@inkeep/open-knowledge 0.0.0-dev-20260428030816 → 0.0.0-dev-20260428055023

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/dist/cli.mjs +4 -4
  2. package/dist/constants-D9m8dzHP.mjs +2 -0
  3. package/dist/{dist-DlLqW1l-.mjs → dist-CC_QsyED.mjs} +1 -1
  4. package/dist/{dist-BVi1kLgS.mjs → dist-DoVDgyml.mjs} +11 -11
  5. package/dist/index.mjs +1 -1
  6. package/dist/init-D-fChIzY.mjs +1 -0
  7. package/dist/init-D3711KPb.mjs +1 -0
  8. package/dist/{init-lR-iOYyJ.mjs → init-DNs9ffRY.mjs} +3 -3
  9. package/dist/{init-DzmV7EWn.mjs → init-DVCAi_du.mjs} +2 -2
  10. package/dist/loader-Bc5pJk1m.mjs +1 -0
  11. package/dist/{loader-Dftbh71h.mjs → loader-C9LBHYiT.mjs} +2 -2
  12. package/dist/paths-CDgE-NKk.mjs +1 -0
  13. package/dist/{paths-9SFXgdez.mjs → paths-zc2uvZxY.mjs} +2 -2
  14. package/dist/{preview-BWEEPmtf.mjs → preview-CPxqdDCe.mjs} +2 -2
  15. package/dist/preview-EfkiZS-n.mjs +1 -0
  16. package/dist/public/assets/{ActivityModeContent-QSE28ToP.js → ActivityModeContent-JeYMJ8N-.js} +1 -1
  17. package/dist/public/assets/{DocumentContext-C7zXwLGg.js → DocumentContext-D9TYylem.js} +1 -1
  18. package/dist/public/assets/McpConsentDialogBody-BNfu0z8x.js +1 -0
  19. package/dist/public/assets/{SourceEditor-B5_U1uud.js → SourceEditor-DBzpEf4D.js} +2 -2
  20. package/dist/public/assets/{clipboard-BcHcwwH2.js → clipboard-C0HbTlCM.js} +3 -3
  21. package/dist/public/assets/{index-CfLPPlu0.js → index-CjMTCid5.js} +72 -72
  22. package/dist/public/index.html +3 -3
  23. package/dist/server-lock-QiPvrcO9-A3jWEIJ6.mjs +2 -0
  24. package/dist/server-lock-QiPvrcO9-CB330FUa.mjs +1 -0
  25. package/dist/src-CccGTsc2.mjs +1 -0
  26. package/dist/{start-YQGf2koi.mjs → start-BnROvKwD.mjs} +2 -2
  27. package/dist/start-DdFbQnn0.mjs +1 -0
  28. package/package.json +1 -1
  29. package/dist/constants-BFC8WUGR.mjs +0 -2
  30. package/dist/init-CpubW-xy.mjs +0 -1
  31. package/dist/init-Kk_OD9gS.mjs +0 -1
  32. package/dist/loader-BVRsmTqA.mjs +0 -1
  33. package/dist/paths-tkdx_ODM.mjs +0 -1
  34. package/dist/preview-BJIwF_YN.mjs +0 -1
  35. package/dist/public/assets/McpConsentDialogBody-FBruOF3J.js +0 -1
  36. package/dist/server-lock-CH0GCP_4-DXqutMlt.mjs +0 -2
  37. package/dist/server-lock-CH0GCP_4-MazZqjDk.mjs +0 -1
  38. package/dist/src-CEe0tBjV.mjs +0 -1
  39. package/dist/start-Bt3IMsVN.mjs +0 -1
@@ -0,0 +1 @@
1
+ import{i as e,n as t,r as n,t as r}from"./index-CjMTCid5.js";export{r as McpConsentDialogBody,r as default,t as computeInitialSelection,n as selectedIdsOrdered,e as toggleSelectedId};
@@ -1,3 +1,3 @@
1
1
  const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./dist-DlS42TIP.js","./dist-CgLbXgrr.js","./chunk-DECur_0Z.js","./w3c-keyname-CSlwavrd.js","./dist-GlH2KPqY.js","./dist-DeDgmJv2.js","./dist-DR1MrLJC.js","./dist-D2wwoXzm.js","./dist-BqO6NfD-.js"])))=>i.map(i=>d[i]);
2
- import{r as e}from"./chunk-DECur_0Z.js";import{d as t}from"./propagation-api-Bugyj7xy.js";import{n,r,t as i}from"./compiler-runtime-Y11fyRVL.js";import{l as a}from"./panel-BCRdtBla.js";import{$ as o,D as s,E as c,F as l,G as u,J as d,K as f,N as p,O as m,Q as h,T as g,U as _,V as v,W as y,X as b,Y as x,Z as S,_ as C,g as w,h as T,m as E,q as D,u as O}from"./DocumentContext-C7zXwLGg.js";import{L as ee,P as te,U as k,_ as ne,z as re}from"./PageListContext-DNRRECTw.js";import{_ as ie,a as ae,c as oe,d as se,f as ce,g as le,h as ue,l as de,m as fe,p as pe,s as me,t as he,u as ge,v as _e}from"./clipboard-BcHcwwH2.js";import{At as ve,Dt as A,Et as ye,N as j,Nt as M,Pt as N,Q as be,Tt as P,Y as F,Z as I,a as L,bt as R,ft as z,jt as B,lt as xe,q as V,wt as Se}from"./dist-CgLbXgrr.js";var H=e(n(),1),Ce=i(),we=class e{constructor(e,t){this.yanchor=e,this.yhead=t}toJSON(){return{yanchor:d(this.yanchor),yhead:d(this.yhead)}}static fromJSON(t){return new e(f(t.yanchor),f(t.yhead))}},Te=class{constructor(e,t){this.ytext=e,this.awareness=t,this.undoManager=new _(e)}toYPos(e,t=0){return D(this.ytext,e,t)}fromYPos(e){let t=u(f(e),this.ytext.doc);if(t==null||t.type!==this.ytext)throw Error(`[y-codemirror] The position you want to retrieve was created by a different document`);return{pos:t.index,assoc:t.assoc}}toYRange(e){let t=e.assoc;return new we(this.toYPos(e.anchor,t),this.toYPos(e.head,t))}fromYRange(e){let t=this.fromYPos(e.yanchor),n=this.fromYPos(e.yhead);return t.pos===n.pos?P.cursor(n.pos,n.assoc):P.range(t.pos,n.pos)}},U=A.define({combine(e){return e[e.length-1]}}),W=R.define(),Ee=class{constructor(e){this.view=e,this.conf=e.state.facet(U),this._observer=(t,n)=>{if(n.origin!==this.conf){let n=t.delta,r=[],i=0;for(let e=0;e<n.length;e++){let t=n[e];t.insert==null?t.delete==null?i+=t.retain:(r.push({from:i,to:i+t.delete,insert:``}),i+=t.delete):r.push({from:i,to:i,insert:t.insert})}e.dispatch({changes:r,annotations:[W.of(this.conf)]})}},this._ytext=this.conf.ytext,this._ytext.observe(this._observer)}update(e){if(!e.docChanged||e.transactions.length>0&&e.transactions[0].annotation(W)===this.conf)return;let t=this.conf.ytext;t.doc.transact(()=>{let n=0;e.changes.iterChanges((e,r,i,a,o)=>{let s=o.sliceString(0,o.length,`
3
- `);e!==r&&t.delete(e+n,r-e),s.length>0&&t.insert(e+n,s),n+=s.length-(r-e)})},this.conf)}destroy(){this._ytext.unobserve(this._observer)}},De=I.fromClass(Ee),Oe=F.baseTheme({".cm-ySelection":{},".cm-yLineSelection":{padding:0,margin:`0px 2px 0px 4px`},".cm-ySelectionCaret":{position:`relative`,borderLeft:`1px solid black`,borderRight:`1px solid black`,marginLeft:`-1px`,marginRight:`-1px`,boxSizing:`border-box`,display:`inline`},".cm-ySelectionCaretDot":{borderRadius:`50%`,position:`absolute`,width:`.4em`,height:`.4em`,top:`-.2em`,left:`-.2em`,backgroundColor:`inherit`,transition:`transform .3s ease-in-out`,boxSizing:`border-box`},".cm-ySelectionCaret:hover > .cm-ySelectionCaretDot":{transformOrigin:`bottom center`,transform:`scale(0)`},".cm-ySelectionInfo":{position:`absolute`,top:`-1.05em`,left:`-1px`,fontSize:`.75em`,fontFamily:`serif`,fontStyle:`normal`,fontWeight:`normal`,lineHeight:`normal`,userSelect:`none`,color:`white`,paddingLeft:`2px`,paddingRight:`2px`,zIndex:101,transition:`opacity .3s ease-in-out`,backgroundColor:`inherit`,opacity:0,transitionDelay:`0s`,whiteSpace:`nowrap`},".cm-ySelectionCaret:hover > .cm-ySelectionInfo":{opacity:1,transitionDelay:`0s`}}),ke=R.define(),Ae=class extends be{constructor(e,t){super(),this.color=e,this.name=t}toDOM(){return x(`span`,[S(`class`,`cm-ySelectionCaret`),S(`style`,`background-color: ${this.color}; border-color: ${this.color}`)],[b(`⁠`),x(`div`,[S(`class`,`cm-ySelectionCaretDot`)]),b(`⁠`),x(`div`,[S(`class`,`cm-ySelectionInfo`)],[b(this.name)]),b(`⁠`)])}eq(e){return e.color===this.color}compare(e){return e.color===this.color}updateDOM(){return!1}get estimatedHeight(){return-1}ignoreEvent(){return!0}},je=class{constructor(e){this.conf=e.state.facet(U),this._listener=({added:t,updated:n,removed:r},i,a)=>{t.concat(n).concat(r).findIndex(e=>e!==this.conf.awareness.doc.clientID)>=0&&e.dispatch({annotations:[ke.of([])]})},this._awareness=this.conf.awareness,this._awareness.on(`change`,this._listener),this.decorations=ve.of([])}destroy(){this._awareness.off(`change`,this._listener)}update(e){let t=this.conf.ytext,n=t.doc,r=this.conf.awareness,i=[],a=this.conf.awareness.getLocalState();if(a!=null){let n=e.view.hasFocus&&e.view.dom.ownerDocument.hasFocus(),i=n?e.state.selection.main:null,o=a.cursor==null?null:f(a.cursor.anchor),s=a.cursor==null?null:f(a.cursor.head);if(i!=null){let e=D(t,i.anchor),n=D(t,i.head);(a.cursor==null||!y(o,e)||!y(s,n))&&r.setLocalStateField(`cursor`,{anchor:e,head:n})}else a.cursor!=null&&n&&r.setLocalStateField(`cursor`,null)}r.getStates().forEach((a,s)=>{if(s===r.doc.clientID)return;let c=a.cursor;if(c==null||c.anchor==null||c.head==null)return;let l=u(c.anchor,n),d=u(c.head,n);if(l==null||d==null||l.type!==t||d.type!==t)return;let{color:f=`#30bced`,name:p=`Anonymous`}=a.user||{},m=a.user&&a.user.colorLight||f+`33`,g=o(l.index,d.index),_=h(l.index,d.index),v=e.view.state.doc.lineAt(g),y=e.view.state.doc.lineAt(_);if(v.number===y.number)i.push({from:g,to:_,value:V.mark({attributes:{style:`background-color: ${m}`},class:`cm-ySelection`})});else{i.push({from:g,to:v.from+v.length,value:V.mark({attributes:{style:`background-color: ${m}`},class:`cm-ySelection`})}),i.push({from:y.from,to:_,value:V.mark({attributes:{style:`background-color: ${m}`},class:`cm-ySelection`})});for(let t=v.number+1;t<y.number;t++){let n=e.view.state.doc.line(t).from;i.push({from:n,to:n,value:V.line({attributes:{style:`background-color: ${m}`,class:`cm-yLineSelection`}})})}}i.push({from:d.index,to:d.index,value:V.widget({side:d.index-l.index>0?-1:1,block:!1,widget:new Ae(f,p)})})}),this.decorations=V.set(i,!0)}},Me=I.fromClass(je,{decorations:e=>e.decorations}),Ne=class{constructor(e){this.undoManager=e}addTrackedOrigin(e){this.undoManager.addTrackedOrigin(e)}removeTrackedOrigin(e){this.undoManager.removeTrackedOrigin(e)}undo(){return this.undoManager.undo()!=null}redo(){return this.undoManager.redo()!=null}},G=A.define({combine(e){return e[e.length-1]}});R.define();var Pe=class{constructor(e){this.view=e,this.conf=e.state.facet(G),this._undoManager=this.conf.undoManager,this.syncConf=e.state.facet(U),this._beforeChangeSelection=null,this._mux=v(),this._onStackItemAdded=({stackItem:e,changedParentTypes:t})=>{t.has(this.syncConf.ytext)&&this._beforeChangeSelection&&!e.meta.has(this)&&e.meta.set(this,this._beforeChangeSelection)},this._onStackItemPopped=({stackItem:t})=>{let n=t.meta.get(this);if(n){let t=this.syncConf.fromYRange(n);e.dispatch(e.state.update({selection:t,effects:[F.scrollIntoView(t)]})),this._storeSelection()}},this._storeSelection=()=>{this._beforeChangeSelection=this.syncConf.toYRange(this.view.state.selection.main)},this._undoManager.on(`stack-item-added`,this._onStackItemAdded),this._undoManager.on(`stack-item-popped`,this._onStackItemPopped),this._undoManager.addTrackedOrigin(this.syncConf)}update(e){e.selectionSet&&(e.transactions.length===0||e.transactions[0].annotation(W)!==this.syncConf)&&this._storeSelection()}destroy(){this._undoManager.off(`stack-item-added`,this._onStackItemAdded),this._undoManager.off(`stack-item-popped`,this._onStackItemPopped),this._undoManager.removeTrackedOrigin(this.syncConf)}},Fe=I.fromClass(Pe),Ie=({state:e,dispatch:t})=>e.facet(G).undo()||!0,Le=({state:e,dispatch:t})=>e.facet(G).redo()||!0,Re=(e,t,{undoManager:n=new _(e)}={})=>{let r=new Te(e,t),i=[U.of(r),De];return t&&i.push(Oe,Me),n!==!1&&i.push(G.of(new Ne(n)),Fe,F.domEventHandlers({beforeinput(e,t){return e.inputType===`historyUndo`?Ie(t):e.inputType===`historyRedo`?Le(t):!1}})),i},ze=[L.of({name:`javascript`,alias:[`js`,`jsx`],extensions:[`js`,`mjs`,`cjs`,`jsx`],load:async()=>fe({jsx:!0})}),L.of({name:`typescript`,alias:[`ts`,`tsx`],extensions:[`ts`,`mts`,`cts`,`tsx`],load:async()=>fe({typescript:!0,jsx:!0})}),L.of({name:`json`,alias:[`jsonc`],extensions:[`json`,`jsonc`],load:()=>t(()=>import(`./dist-DlS42TIP.js`).then(e=>e.json()),__vite__mapDeps([0,1,2,3,4]),import.meta.url)}),L.of({name:`yaml`,alias:[`yml`],extensions:[`yaml`,`yml`],load:()=>t(()=>import(`./dist-DeDgmJv2.js`).then(e=>e.yaml()),__vite__mapDeps([5,1,2,3,4]),import.meta.url)}),L.of({name:`css`,alias:[`scss`,`less`],extensions:[`css`,`scss`,`less`],load:async()=>ue()}),L.of({name:`html`,alias:[`htm`],extensions:[`html`,`htm`],load:async()=>pe()}),L.of({name:`python`,alias:[`py`],extensions:[`py`,`pyw`],load:()=>t(()=>import(`./dist-DR1MrLJC.js`).then(e=>e.python()),__vite__mapDeps([6,7,1,2,3,4]),import.meta.url)}),L.of({name:`rust`,alias:[`rs`],extensions:[`rs`],load:()=>t(()=>import(`./dist-BqO6NfD-.js`).then(e=>e.rust()),__vite__mapDeps([8,1,2,3,4]),import.meta.url)}),L.of({name:`markdown`,alias:[`md`,`mdx`],extensions:[`md`,`mdx`,`markdown`],load:async()=>se()}),L.of({name:`bash`,alias:[`sh`,`shell`,`zsh`],extensions:[`sh`,`bash`,`zsh`],load:async()=>{let[{StreamLanguage:e,LanguageSupport:n},{shell:r}]=await Promise.all([t(()=>import(`./dist-CgLbXgrr.js`).then(e=>e.m),__vite__mapDeps([1,2,3]),import.meta.url),t(()=>import(`./shell-7yok6dsz.js`),[],import.meta.url)]);return new n(e.define(r))}}),L.of({name:`go`,alias:[`golang`],extensions:[`go`],load:async()=>{let[{StreamLanguage:e,LanguageSupport:n},{go:r}]=await Promise.all([t(()=>import(`./dist-CgLbXgrr.js`).then(e=>e.m),__vite__mapDeps([1,2,3]),import.meta.url),t(()=>import(`./go-DatQmDtN.js`),[],import.meta.url)]);return new n(e.define(r))}})],Be=M.define(),Ve=M.define(),He=V.line({class:`agent-flash`}),Ue=N.define({create(){return V.none},update(e,t){e=e.map(t.changes);for(let n of t.effects)if(n.is(Be)){let{from:r,to:i}=n.value,a=[];for(let e=r;e<=i;){let n=t.state.doc.lineAt(e);a.push(He.range(n.from)),e=n.to+1}e=e.update({add:a,sort:!0})}else n.is(Ve)&&(e=V.none);return e},provide:e=>F.decorations.from(e)});function We(e){let t=e.getMap(`agent-flash`);return[Ue,I.define(e=>{let n=0,r=Date.now(),i=null,a=null,o=!1;function s(){let t=e.state.doc.length;t!==0&&(o||(e.dispatch({effects:Be.of({from:0,to:t})}),a&&clearTimeout(a),a=setTimeout(()=>{a=null,!o&&e.dispatch({effects:Ve.of(null)})},ne)))}let c=e=>{if(re(t),!k(t,r))return;r=Date.now();let a=Date.now();if(a-n<500){if(!i){let e=500-(a-n);i=setTimeout(()=>{i=null,n=Date.now(),s()},e)}return}n=a,s()};t.observe(c);let l=()=>{document.visibilityState===`visible`?k(t,r)&&(r=Date.now(),n=Date.now(),s()):r=Date.now()};return document.addEventListener(`visibilitychange`,l),{update(e){},destroy(){o=!0,t.unobserve(c),document.removeEventListener(`visibilitychange`,l),i&&=(clearTimeout(i),null),a&&=(clearTimeout(a),null)}}})]}var K=/\[([^\]\n]*)\]\((<[^>\n]+>|[^)\s\n]+)(?:\s+(?:"[^"\n]*"|'[^'\n]*'|\([^)\n]*\)))?\)/g,Ge=V.mark({class:`cm-md-internal-link`});function Ke(e,t){return t>0&&e[t-1]===`!`}function qe(e){let t=e[2]??``;return t.startsWith(`<`)&&t.endsWith(`>`)?t.slice(1,-1):t}function Je(e){let t=new B;for(let{from:n,to:r}of e.visibleRanges){let i=e.state.doc.sliceString(n,r);K.lastIndex=0;let a=K.exec(i);for(;a!==null;){let e=Ke(i,a.index)?null:g(qe(a));e&&e.kind!==`external`&&t.add(n+a.index,n+a.index+a[0].length,Ge),a=K.exec(i)}}return t.finish()}var Ye=I.fromClass(class{decorations;constructor(e){this.decorations=Je(e)}update(e){(e.docChanged||e.viewportChanged)&&(this.decorations=Je(e.view))}},{decorations:e=>e.decorations}),Xe=F.domEventHandlers({mousedown(e,t){if(!e.ctrlKey&&!e.metaKey)return!1;let n=t.posAtCoords({x:e.clientX,y:e.clientY});if(n===null)return!1;let r=t.state.doc.lineAt(n);K.lastIndex=0;let i=K.exec(r.text);for(;i!==null;){let t=r.from+i.index,a=t+i[0].length;if(n>=t&&n<=a){let t=Ke(r.text,i.index)?null:g(qe(i));if(t&&t.kind!==`external`)return e.preventDefault(),t.kind===`doc`&&m(e)?(s(t),!0):(c(t),!0)}i=K.exec(r.text)}return!1}}),Ze=F.theme({".cm-md-internal-link":{color:`oklch(52.7% 0.154 228.4)`,fontWeight:`500`},".cm-md-internal-link:hover":{textDecoration:`underline`,cursor:`pointer`}});function Qe(){return[Ye,Xe,Ze]}var $e=5e3,q=null,et=0,tt=null,J=new Map;async function nt(){let e=Date.now();return q&&e-et<$e?q:(q=await T(),et=e,tt=st(q),q)}async function rt(e){let t=Date.now(),n=J.get(e);if(n!==void 0&&t-n.time<$e)return n.headings;try{let n=await E(e);return J.set(e,{headings:n,time:t}),n}catch(n){return console.warn(`[wiki-link-source] /api/page-headings fetch failed:`,n),J.set(e,{headings:[],time:t}),[]}}var Y=/\[\[[^\]]*?\]\]/g,it=V.mark({class:`cm-wiki-link`}),at=V.mark({class:`cm-wiki-link cm-wiki-link-broken`});function ot(e){let t=new Set;for(let n of e)t.add(n.docName.toLowerCase()),n.title&&t.add(n.title.toLowerCase());return t}function st(e){let t=ot(e);for(let n of e){let e=n.docName.split(`/`);e.pop();let r=``;for(let n of e)r=r?`${r}/${n}`:n,t.add(r.toLowerCase())}return t}function ct(e){return e.split(/[#|]/)[0].trim().toLowerCase()}function lt(e){let t=new B,n=q?tt:null;for(let{from:r,to:i}of e.visibleRanges){let a=e.state.doc.sliceString(r,i);Y.lastIndex=0;let o=Y.exec(a);for(;o!==null;){let e=it;if(n){let t=ct(o[0].slice(2,-2));t&&!n.has(t)&&(e=at)}t.add(r+o.index,r+o.index+o[0].length,e),o=Y.exec(a)}}return t.finish()}var ut=I.fromClass(class{decorations;cacheWarmAtBuild;constructor(e){this.cacheWarmAtBuild=q!==null,this.decorations=lt(e),this.cacheWarmAtBuild||this.warmCache(e)}update(e){let t=q!==null;(e.docChanged||e.viewportChanged||!this.cacheWarmAtBuild&&t)&&(this.cacheWarmAtBuild=t,this.decorations=lt(e.view))}warmCache(e){nt().then(()=>{try{e.dispatch({})}catch{}}).catch(e=>{console.warn(`[wiki-link-source] warmCache fetch failed:`,e)})}},{decorations:e=>e.decorations}),X=/\[\[([^[\]|#]+?)(?:#([^\]|]+?))?(?:\|([^\]]+?))?\]\]/g,dt=F.domEventHandlers({mousedown(e,t){if(!e.ctrlKey&&!e.metaKey)return!1;let n=t.posAtCoords({x:e.clientX,y:e.clientY});if(n===null)return!1;let r=t.state.doc.lineAt(n);X.lastIndex=0;let i=X.exec(r.text);for(;i!==null;){let t=r.from+i.index,a=t+i[0].length;if(n>=t&&n<=a){let t=i[1]?.trim(),n=i[2]?.trim()||null;if(t){let r=te(t,n);if(!r)return!1;e.preventDefault(),r.kind===`external`?window.open(r.url,`_blank`,`noopener,noreferrer`):m(e)?s(r):window.location.hash=r.anchor?`#/${r.docName}?anchor=${encodeURIComponent(r.anchor)}`:`#/${r.docName}`}return!0}i=X.exec(r.text)}return!1}});async function ft(e){let t=e.state.doc.sliceString(0,e.pos).match(/\[\[([^\]]*)$/);if(!t)return null;let n=t[1],r=e.pos-n.length,i=n.indexOf(`#`);if(i>0){let e=n.slice(0,i),t=n.slice(i+1),a=r+i+1,o=await rt(e);if(!o.length)return null;let s=w(o,t);return s.length?{from:a,filter:!1,options:s.map(e=>({label:e.text,detail:`H${e.level}`,apply(t,n,r,i){let a=t.state.doc.sliceString(i,i+2)===`]]`?``:`]]`;t.dispatch({changes:{from:r,to:i,insert:e.slug+a},selection:{anchor:r+e.slug.length+a.length}})}}))}:null}return{from:r,filter:!1,options:C(await nt().catch(e=>(console.warn(`[wiki-link-source] Failed to fetch pages:`,e),[])),n).map(e=>({label:e.title,detail:e.title===e.docName?void 0:e.docName,apply(t,n,r,i){let a=t.state.doc.sliceString(i,i+2)===`]]`?``:`]]`;t.dispatch({changes:{from:r,to:i,insert:e.docName+a},selection:{anchor:r+e.docName.length+a.length}})}}))}}var pt=F.theme({".cm-wiki-link":{color:`oklch(52.7% 0.154 228.4)`,fontWeight:`500`},".cm-wiki-link:hover":{textDecoration:`underline`,cursor:`pointer`}});function mt(){return[ut,dt,pt,ce.data.of({autocomplete:ft})]}var ht=V.mark({class:`cm-link-ref-broken`}),gt=/^\s{0,3}\[([^\]]+)\]:\s/,_t=/\[([^\]]*)\]\[([^\]]*)\]/g,vt=new Set([`FencedCode`,`CodeBlock`,`InlineCode`]);function Z(e,t){let n=0,r=t.length-1;for(;n<=r;){let i=n+r>>1,a=t[i];if(e<a.from)r=i-1;else if(e>=a.to)n=i+1;else return!0}return!1}function yt(e){let t=[];return j(e).iterate({enter(e){if(vt.has(e.name))return t.push({from:e.from,to:e.to}),!1}}),t.sort((e,t)=>e.from-t.from),t}function Q(e){let t=new Set,n=[],r=e.doc,i=yt(e);for(let e=1;e<=r.lines;e++){let n=r.line(e);if(Z(n.from,i))continue;let a=gt.exec(n.text);a&&t.add(a[1].toLowerCase())}for(let e=1;e<=r.lines;e++){let t=r.line(e);if(!Z(t.from,i)&&!gt.test(t.text))for(_t.lastIndex=0;;){let e=_t.exec(t.text);if(!e)break;let r=t.from+e.index;if(Z(r,i))continue;let a=e[2]||e[1];n.push({from:r,to:r+e[0].length,label:a.toLowerCase()})}}let a=[];for(let e of n)t.has(e.label)||a.push(ht.range(e.from,e.to));return a.sort((e,t)=>e.from-t.from),V.set(a)}var bt=N.define({create(e){return Q(e)},update(e,t){return t.docChanged?Q(t.state):e},provide:e=>F.decorations.from(e)}),xt=/^(\s*(?:[-*+]|\d+[.)]) (?:\[[ x]\] )?)/,St=V.mark({class:`cm-del`}),Ct=V.line({class:`cm-table-header`}),wt=V.line({class:`cm-table-row`});function Tt(e){let t=0;for(let n of e)if(n===` `)t++;else if(n===` `)t+=4;else break;return t}function Et(e,t){let n=[],r=j(e);for(let{from:i,to:a}of t)r.iterate({from:i,to:a,enter(t){if(t.name===`Strikethrough`){let e=t.from,r=t.to,i=t.node.cursor();if(i.firstChild())do i.name===`StrikethroughMark`&&(i.from===t.from?e=i.to:r=i.from);while(i.nextSibling());return e<r&&n.push(St.range(e,r)),!1}if(t.name===`ListItem`){let r=e.doc.lineAt(t.from),i=xt.exec(r.text),a=i?i[1].length:2,o=V.line({class:`cm-list-item`,attributes:{style:`--list-hang: ${a}ch`}});n.push(o.range(r.from));return}if(t.name===`FencedCode`){let r=e.doc.lineAt(t.from),i=e.doc.lineAt(t.to);for(let t=r.number+1;t<i.number;t++){let r=e.doc.line(t),i=Tt(r.text),a=V.line({class:`cm-fenced-code-line`,attributes:{style:`--line-indent: ${i}`}});n.push(a.range(r.from))}return!1}if(t.name===`TableHeader`){let r=e.doc.lineAt(t.from);return n.push(Ct.range(r.from)),!1}if(t.name===`TableRow`){let r=e.doc.lineAt(t.from);return n.push(wt.range(r.from)),!1}if(t.name===`TableDelimiter`&&t.node.parent?.name===`Table`){let r=e.doc.lineAt(t.from);return n.push(wt.range(r.from)),!1}}});return n.sort((e,t)=>e.from-t.from||e.value.startSide-t.value.startSide),V.set(n)}var Dt=class{decorations;constructor(e){this.decorations=Et(e.state,e.visibleRanges)}update(e){(e.docChanged||e.viewportChanged||j(e.startState)!==j(e.state))&&(this.decorations=Et(e.view.state,e.view.visibleRanges))}},Ot=I.fromClass(Dt,{decorations:e=>e.decorations});function kt(){return[Ot,bt]}var At=r(),jt=ge({settings:{background:`var(--background)`,gutterBackground:`var(--background)`}}),Mt=de({settings:{background:`var(--background)`,gutterBackground:`var(--background)`}}),Nt=new Se,Pt=new Se;function $(e,t){let n=e.state.doc,r=1;if(n.lines>=1&&n.line(1).text===`---`){for(let e=2;e<=n.lines;e++)if(n.line(e).text===`---`){r=e+1;break}}let i=ee(),a=0;for(let o=r;o<=n.lines;o++){let r=n.line(o);if(!i(r.text)&&/^#{1,6}\s/.test(r.text)){if(a===t.index){e.dispatch({selection:P.cursor(r.from),effects:F.scrollIntoView(r.from,{y:`start`})}),e.focus();return}a++}}}function Ft(e,t){requestAnimationFrame(()=>{let n=e.state.doc,r=Math.min(t.offset,n.length);e.dispatch({selection:P.cursor(r),effects:F.scrollIntoView(r,{y:`center`})}),e.focus()})}function It(e){let t=(0,Ce.c)(29),{docName:n,ytext:r,provider:i,placeholder:o,isSourceModeActive:s}=e,c=(0,H.useRef)(null),u=(0,H.useRef)(null),[d,f]=(0,H.useState)(null);if(d)throw d;let{resolvedTheme:m}=a(),h;t[0]!==s||t[1]!==i.awareness?(h=()=>{let e=i.awareness;if(e)return e.setLocalStateField(`mode`,s?`source`:`wysiwyg`),()=>{e.setLocalStateField(`mode`,`wysiwyg`)}},t[0]=s,t[1]=i.awareness,t[2]=h):h=t[2];let g;t[3]!==s||t[4]!==i?(g=[i,s],t[3]=s,t[4]=i,t[5]=g):g=t[5],(0,H.useEffect)(h,g);let _=(0,H.useRef)(null),v;t[6]!==o||t[7]!==i||t[8]!==m||t[9]!==r?(v=()=>{let e=c.current;if(!e)return;let t=i.configuration.name??``,n,a=Lt;try{n=p({docName:t,container:e,sizeStats:{viewCount:0,bytes:r.length},factory:e=>{let t=he({ydoc:i.document,ytext:r}),n=new F({state:ye.create({doc:r.toString(),extensions:[me,xe.of([oe]),se({base:ce,extensions:[le],codeLanguages:ze}),Re(r,i.awareness),We(i.document),mt(),Qe(),kt(),t,Nt.of(m===`dark`?jt:Mt),Pt.of(z(o??``)),F.lineWrapping,F.theme({"&":{height:`100%`}})]}),parent:e}),s=n.contentDOM;return s.addEventListener(`keydown`,a),s.addEventListener(`paste`,a),s.addEventListener(`drop`,a),s.addEventListener(`cut`,a),{view:n,ydoc:i.document,ytext:r,provider:i}}}),_.current=n,u.current=n.view}catch(e){let t=e;console.error(`[SourceEditor] mountCmEditor failed`,t),_.current=null,u.current=null,f(t instanceof Error?t:Error(String(t)))}return()=>{let e=_.current;e&&l(e),_.current=null,u.current=null}},t[6]=o,t[7]=i,t[8]=m,t[9]=r,t[10]=v):v=t[10];let y;t[11]!==i||t[12]!==r?(y=[r,i],t[11]=i,t[12]=r,t[13]=y):y=t[13],(0,H.useEffect)(v,y);let b,x;t[14]===m?(b=t[15],x=t[16]):(b=()=>{u.current&&u.current.dispatch({effects:Nt.reconfigure(m===`dark`?jt:Mt)})},x=[m],t[14]=m,t[15]=b,t[16]=x),(0,H.useEffect)(b,x);let S,C;t[17]===o?(S=t[18],C=t[19]):(S=()=>{u.current&&u.current.dispatch({effects:Pt.reconfigure(z(o??``))})},C=[o],t[17]=o,t[18]=S,t[19]=C),(0,H.useEffect)(S,C);let w,T;t[20]!==n||t[21]!==s?(T=()=>{let e=function(e){let t=e.detail;if(!t||t.mode!==`source`||!s)return;let r=u.current;r&&($(r,t),ie(n))};return window.addEventListener(ae,e),()=>window.removeEventListener(ae,e)},w=[n,s],t[20]=n,t[21]=s,t[22]=w,t[23]=T):(w=t[22],T=t[23]),(0,H.useEffect)(T,w);let E,D;t[24]!==n||t[25]!==s?(E=()=>{if(!s)return;let e=u.current;if(!e)return;let t=_e(n);if(t){if(t.kind===`outline`){$(e,t.detail);return}Ft(e,t.detail)}},D=[n,s],t[24]=n,t[25]=s,t[26]=E,t[27]=D):(E=t[26],D=t[27]),(0,H.useEffect)(E,D);let O;return t[28]===Symbol.for(`react.memo_cache_sentinel`)?(O=(0,At.jsx)(`div`,{ref:c,className:`source-editor h-full py-3`}),t[28]=O):O=t[28],O}function Lt(){return O()}export{It as SourceEditor};
2
+ import{r as e}from"./chunk-DECur_0Z.js";import{d as t}from"./propagation-api-Bugyj7xy.js";import{n,r,t as i}from"./compiler-runtime-Y11fyRVL.js";import{l as a}from"./panel-BCRdtBla.js";import{$ as o,D as s,E as c,G as l,H as u,I as d,J as f,K as p,O as m,P as h,Q as g,W as _,X as v,Y as y,Z as b,_ as x,d as S,et as C,g as w,h as T,k as E,q as D,v as O}from"./DocumentContext-D9TYylem.js";import{L as ee,P as te,U as k,_ as ne,z as re}from"./PageListContext-DNRRECTw.js";import{_ as ie,a as ae,c as oe,d as se,f as ce,g as le,h as ue,l as de,m as fe,p as pe,s as me,t as he,u as ge,v as _e}from"./clipboard-C0HbTlCM.js";import{At as ve,Dt as A,Et as ye,N as j,Nt as M,Pt as N,Q as be,Tt as P,Y as F,Z as I,a as L,bt as R,ft as z,jt as B,lt as xe,q as V,wt as Se}from"./dist-CgLbXgrr.js";var H=e(n(),1),Ce=i(),we=class e{constructor(e,t){this.yanchor=e,this.yhead=t}toJSON(){return{yanchor:y(this.yanchor),yhead:y(this.yhead)}}static fromJSON(t){return new e(D(t.yanchor),D(t.yhead))}},Te=class{constructor(e,t){this.ytext=e,this.awareness=t,this.undoManager=new _(e)}toYPos(e,t=0){return f(this.ytext,e,t)}fromYPos(e){let t=p(D(e),this.ytext.doc);if(t==null||t.type!==this.ytext)throw Error(`[y-codemirror] The position you want to retrieve was created by a different document`);return{pos:t.index,assoc:t.assoc}}toYRange(e){let t=e.assoc;return new we(this.toYPos(e.anchor,t),this.toYPos(e.head,t))}fromYRange(e){let t=this.fromYPos(e.yanchor),n=this.fromYPos(e.yhead);return t.pos===n.pos?P.cursor(n.pos,n.assoc):P.range(t.pos,n.pos)}},U=A.define({combine(e){return e[e.length-1]}}),W=R.define(),Ee=class{constructor(e){this.view=e,this.conf=e.state.facet(U),this._observer=(t,n)=>{if(n.origin!==this.conf){let n=t.delta,r=[],i=0;for(let e=0;e<n.length;e++){let t=n[e];t.insert==null?t.delete==null?i+=t.retain:(r.push({from:i,to:i+t.delete,insert:``}),i+=t.delete):r.push({from:i,to:i,insert:t.insert})}e.dispatch({changes:r,annotations:[W.of(this.conf)]})}},this._ytext=this.conf.ytext,this._ytext.observe(this._observer)}update(e){if(!e.docChanged||e.transactions.length>0&&e.transactions[0].annotation(W)===this.conf)return;let t=this.conf.ytext;t.doc.transact(()=>{let n=0;e.changes.iterChanges((e,r,i,a,o)=>{let s=o.sliceString(0,o.length,`
3
+ `);e!==r&&t.delete(e+n,r-e),s.length>0&&t.insert(e+n,s),n+=s.length-(r-e)})},this.conf)}destroy(){this._ytext.unobserve(this._observer)}},De=I.fromClass(Ee),Oe=F.baseTheme({".cm-ySelection":{},".cm-yLineSelection":{padding:0,margin:`0px 2px 0px 4px`},".cm-ySelectionCaret":{position:`relative`,borderLeft:`1px solid black`,borderRight:`1px solid black`,marginLeft:`-1px`,marginRight:`-1px`,boxSizing:`border-box`,display:`inline`},".cm-ySelectionCaretDot":{borderRadius:`50%`,position:`absolute`,width:`.4em`,height:`.4em`,top:`-.2em`,left:`-.2em`,backgroundColor:`inherit`,transition:`transform .3s ease-in-out`,boxSizing:`border-box`},".cm-ySelectionCaret:hover > .cm-ySelectionCaretDot":{transformOrigin:`bottom center`,transform:`scale(0)`},".cm-ySelectionInfo":{position:`absolute`,top:`-1.05em`,left:`-1px`,fontSize:`.75em`,fontFamily:`serif`,fontStyle:`normal`,fontWeight:`normal`,lineHeight:`normal`,userSelect:`none`,color:`white`,paddingLeft:`2px`,paddingRight:`2px`,zIndex:101,transition:`opacity .3s ease-in-out`,backgroundColor:`inherit`,opacity:0,transitionDelay:`0s`,whiteSpace:`nowrap`},".cm-ySelectionCaret:hover > .cm-ySelectionInfo":{opacity:1,transitionDelay:`0s`}}),ke=R.define(),Ae=class extends be{constructor(e,t){super(),this.color=e,this.name=t}toDOM(){return v(`span`,[g(`class`,`cm-ySelectionCaret`),g(`style`,`background-color: ${this.color}; border-color: ${this.color}`)],[b(`⁠`),v(`div`,[g(`class`,`cm-ySelectionCaretDot`)]),b(`⁠`),v(`div`,[g(`class`,`cm-ySelectionInfo`)],[b(this.name)]),b(`⁠`)])}eq(e){return e.color===this.color}compare(e){return e.color===this.color}updateDOM(){return!1}get estimatedHeight(){return-1}ignoreEvent(){return!0}},je=class{constructor(e){this.conf=e.state.facet(U),this._listener=({added:t,updated:n,removed:r},i,a)=>{t.concat(n).concat(r).findIndex(e=>e!==this.conf.awareness.doc.clientID)>=0&&e.dispatch({annotations:[ke.of([])]})},this._awareness=this.conf.awareness,this._awareness.on(`change`,this._listener),this.decorations=ve.of([])}destroy(){this._awareness.off(`change`,this._listener)}update(e){let t=this.conf.ytext,n=t.doc,r=this.conf.awareness,i=[],a=this.conf.awareness.getLocalState();if(a!=null){let n=e.view.hasFocus&&e.view.dom.ownerDocument.hasFocus(),i=n?e.state.selection.main:null,o=a.cursor==null?null:D(a.cursor.anchor),s=a.cursor==null?null:D(a.cursor.head);if(i!=null){let e=f(t,i.anchor),n=f(t,i.head);(a.cursor==null||!l(o,e)||!l(s,n))&&r.setLocalStateField(`cursor`,{anchor:e,head:n})}else a.cursor!=null&&n&&r.setLocalStateField(`cursor`,null)}r.getStates().forEach((a,s)=>{if(s===r.doc.clientID)return;let c=a.cursor;if(c==null||c.anchor==null||c.head==null)return;let l=p(c.anchor,n),u=p(c.head,n);if(l==null||u==null||l.type!==t||u.type!==t)return;let{color:d=`#30bced`,name:f=`Anonymous`}=a.user||{},m=a.user&&a.user.colorLight||d+`33`,h=C(l.index,u.index),g=o(l.index,u.index),_=e.view.state.doc.lineAt(h),v=e.view.state.doc.lineAt(g);if(_.number===v.number)i.push({from:h,to:g,value:V.mark({attributes:{style:`background-color: ${m}`},class:`cm-ySelection`})});else{i.push({from:h,to:_.from+_.length,value:V.mark({attributes:{style:`background-color: ${m}`},class:`cm-ySelection`})}),i.push({from:v.from,to:g,value:V.mark({attributes:{style:`background-color: ${m}`},class:`cm-ySelection`})});for(let t=_.number+1;t<v.number;t++){let n=e.view.state.doc.line(t).from;i.push({from:n,to:n,value:V.line({attributes:{style:`background-color: ${m}`,class:`cm-yLineSelection`}})})}}i.push({from:u.index,to:u.index,value:V.widget({side:u.index-l.index>0?-1:1,block:!1,widget:new Ae(d,f)})})}),this.decorations=V.set(i,!0)}},Me=I.fromClass(je,{decorations:e=>e.decorations}),Ne=class{constructor(e){this.undoManager=e}addTrackedOrigin(e){this.undoManager.addTrackedOrigin(e)}removeTrackedOrigin(e){this.undoManager.removeTrackedOrigin(e)}undo(){return this.undoManager.undo()!=null}redo(){return this.undoManager.redo()!=null}},G=A.define({combine(e){return e[e.length-1]}});R.define();var Pe=class{constructor(e){this.view=e,this.conf=e.state.facet(G),this._undoManager=this.conf.undoManager,this.syncConf=e.state.facet(U),this._beforeChangeSelection=null,this._mux=u(),this._onStackItemAdded=({stackItem:e,changedParentTypes:t})=>{t.has(this.syncConf.ytext)&&this._beforeChangeSelection&&!e.meta.has(this)&&e.meta.set(this,this._beforeChangeSelection)},this._onStackItemPopped=({stackItem:t})=>{let n=t.meta.get(this);if(n){let t=this.syncConf.fromYRange(n);e.dispatch(e.state.update({selection:t,effects:[F.scrollIntoView(t)]})),this._storeSelection()}},this._storeSelection=()=>{this._beforeChangeSelection=this.syncConf.toYRange(this.view.state.selection.main)},this._undoManager.on(`stack-item-added`,this._onStackItemAdded),this._undoManager.on(`stack-item-popped`,this._onStackItemPopped),this._undoManager.addTrackedOrigin(this.syncConf)}update(e){e.selectionSet&&(e.transactions.length===0||e.transactions[0].annotation(W)!==this.syncConf)&&this._storeSelection()}destroy(){this._undoManager.off(`stack-item-added`,this._onStackItemAdded),this._undoManager.off(`stack-item-popped`,this._onStackItemPopped),this._undoManager.removeTrackedOrigin(this.syncConf)}},Fe=I.fromClass(Pe),Ie=({state:e,dispatch:t})=>e.facet(G).undo()||!0,Le=({state:e,dispatch:t})=>e.facet(G).redo()||!0,Re=(e,t,{undoManager:n=new _(e)}={})=>{let r=new Te(e,t),i=[U.of(r),De];return t&&i.push(Oe,Me),n!==!1&&i.push(G.of(new Ne(n)),Fe,F.domEventHandlers({beforeinput(e,t){return e.inputType===`historyUndo`?Ie(t):e.inputType===`historyRedo`?Le(t):!1}})),i},ze=[L.of({name:`javascript`,alias:[`js`,`jsx`],extensions:[`js`,`mjs`,`cjs`,`jsx`],load:async()=>fe({jsx:!0})}),L.of({name:`typescript`,alias:[`ts`,`tsx`],extensions:[`ts`,`mts`,`cts`,`tsx`],load:async()=>fe({typescript:!0,jsx:!0})}),L.of({name:`json`,alias:[`jsonc`],extensions:[`json`,`jsonc`],load:()=>t(()=>import(`./dist-DlS42TIP.js`).then(e=>e.json()),__vite__mapDeps([0,1,2,3,4]),import.meta.url)}),L.of({name:`yaml`,alias:[`yml`],extensions:[`yaml`,`yml`],load:()=>t(()=>import(`./dist-DeDgmJv2.js`).then(e=>e.yaml()),__vite__mapDeps([5,1,2,3,4]),import.meta.url)}),L.of({name:`css`,alias:[`scss`,`less`],extensions:[`css`,`scss`,`less`],load:async()=>ue()}),L.of({name:`html`,alias:[`htm`],extensions:[`html`,`htm`],load:async()=>pe()}),L.of({name:`python`,alias:[`py`],extensions:[`py`,`pyw`],load:()=>t(()=>import(`./dist-DR1MrLJC.js`).then(e=>e.python()),__vite__mapDeps([6,7,1,2,3,4]),import.meta.url)}),L.of({name:`rust`,alias:[`rs`],extensions:[`rs`],load:()=>t(()=>import(`./dist-BqO6NfD-.js`).then(e=>e.rust()),__vite__mapDeps([8,1,2,3,4]),import.meta.url)}),L.of({name:`markdown`,alias:[`md`,`mdx`],extensions:[`md`,`mdx`,`markdown`],load:async()=>se()}),L.of({name:`bash`,alias:[`sh`,`shell`,`zsh`],extensions:[`sh`,`bash`,`zsh`],load:async()=>{let[{StreamLanguage:e,LanguageSupport:n},{shell:r}]=await Promise.all([t(()=>import(`./dist-CgLbXgrr.js`).then(e=>e.m),__vite__mapDeps([1,2,3]),import.meta.url),t(()=>import(`./shell-7yok6dsz.js`),[],import.meta.url)]);return new n(e.define(r))}}),L.of({name:`go`,alias:[`golang`],extensions:[`go`],load:async()=>{let[{StreamLanguage:e,LanguageSupport:n},{go:r}]=await Promise.all([t(()=>import(`./dist-CgLbXgrr.js`).then(e=>e.m),__vite__mapDeps([1,2,3]),import.meta.url),t(()=>import(`./go-DatQmDtN.js`),[],import.meta.url)]);return new n(e.define(r))}})],Be=M.define(),Ve=M.define(),He=V.line({class:`agent-flash`}),Ue=N.define({create(){return V.none},update(e,t){e=e.map(t.changes);for(let n of t.effects)if(n.is(Be)){let{from:r,to:i}=n.value,a=[];for(let e=r;e<=i;){let n=t.state.doc.lineAt(e);a.push(He.range(n.from)),e=n.to+1}e=e.update({add:a,sort:!0})}else n.is(Ve)&&(e=V.none);return e},provide:e=>F.decorations.from(e)});function We(e){let t=e.getMap(`agent-flash`);return[Ue,I.define(e=>{let n=0,r=Date.now(),i=null,a=null,o=!1;function s(){let t=e.state.doc.length;t!==0&&(o||(e.dispatch({effects:Be.of({from:0,to:t})}),a&&clearTimeout(a),a=setTimeout(()=>{a=null,!o&&e.dispatch({effects:Ve.of(null)})},ne)))}let c=e=>{if(re(t),!k(t,r))return;r=Date.now();let a=Date.now();if(a-n<500){if(!i){let e=500-(a-n);i=setTimeout(()=>{i=null,n=Date.now(),s()},e)}return}n=a,s()};t.observe(c);let l=()=>{document.visibilityState===`visible`?k(t,r)&&(r=Date.now(),n=Date.now(),s()):r=Date.now()};return document.addEventListener(`visibilitychange`,l),{update(e){},destroy(){o=!0,t.unobserve(c),document.removeEventListener(`visibilitychange`,l),i&&=(clearTimeout(i),null),a&&=(clearTimeout(a),null)}}})]}var K=/\[([^\]\n]*)\]\((<[^>\n]+>|[^)\s\n]+)(?:\s+(?:"[^"\n]*"|'[^'\n]*'|\([^)\n]*\)))?\)/g,Ge=V.mark({class:`cm-md-internal-link`});function Ke(e,t){return t>0&&e[t-1]===`!`}function qe(e){let t=e[2]??``;return t.startsWith(`<`)&&t.endsWith(`>`)?t.slice(1,-1):t}function Je(e){let t=new B;for(let{from:n,to:r}of e.visibleRanges){let i=e.state.doc.sliceString(n,r);K.lastIndex=0;let a=K.exec(i);for(;a!==null;){let e=Ke(i,a.index)?null:c(qe(a));e&&e.kind!==`external`&&t.add(n+a.index,n+a.index+a[0].length,Ge),a=K.exec(i)}}return t.finish()}var Ye=I.fromClass(class{decorations;constructor(e){this.decorations=Je(e)}update(e){(e.docChanged||e.viewportChanged)&&(this.decorations=Je(e.view))}},{decorations:e=>e.decorations}),Xe=F.domEventHandlers({mousedown(e,t){if(!e.ctrlKey&&!e.metaKey)return!1;let n=t.posAtCoords({x:e.clientX,y:e.clientY});if(n===null)return!1;let r=t.state.doc.lineAt(n);K.lastIndex=0;let i=K.exec(r.text);for(;i!==null;){let t=r.from+i.index,a=t+i[0].length;if(n>=t&&n<=a){let t=Ke(r.text,i.index)?null:c(qe(i));if(t&&t.kind!==`external`)return e.preventDefault(),t.kind===`doc`&&E(e)?(m(t),!0):(s(t),!0)}i=K.exec(r.text)}return!1}}),Ze=F.theme({".cm-md-internal-link":{color:`oklch(52.7% 0.154 228.4)`,fontWeight:`500`},".cm-md-internal-link:hover":{textDecoration:`underline`,cursor:`pointer`}});function Qe(){return[Ye,Xe,Ze]}var $e=5e3,q=null,et=0,tt=null,J=new Map;async function nt(){let e=Date.now();return q&&e-et<$e?q:(q=await w(),et=e,tt=st(q),q)}async function rt(e){let t=Date.now(),n=J.get(e);if(n!==void 0&&t-n.time<$e)return n.headings;try{let n=await T(e);return J.set(e,{headings:n,time:t}),n}catch(n){return console.warn(`[wiki-link-source] /api/page-headings fetch failed:`,n),J.set(e,{headings:[],time:t}),[]}}var Y=/\[\[[^\]]*?\]\]/g,it=V.mark({class:`cm-wiki-link`}),at=V.mark({class:`cm-wiki-link cm-wiki-link-broken`});function ot(e){let t=new Set;for(let n of e)t.add(n.docName.toLowerCase()),n.title&&t.add(n.title.toLowerCase());return t}function st(e){let t=ot(e);for(let n of e){let e=n.docName.split(`/`);e.pop();let r=``;for(let n of e)r=r?`${r}/${n}`:n,t.add(r.toLowerCase())}return t}function ct(e){return e.split(/[#|]/)[0].trim().toLowerCase()}function lt(e){let t=new B,n=q?tt:null;for(let{from:r,to:i}of e.visibleRanges){let a=e.state.doc.sliceString(r,i);Y.lastIndex=0;let o=Y.exec(a);for(;o!==null;){let e=it;if(n){let t=ct(o[0].slice(2,-2));t&&!n.has(t)&&(e=at)}t.add(r+o.index,r+o.index+o[0].length,e),o=Y.exec(a)}}return t.finish()}var ut=I.fromClass(class{decorations;cacheWarmAtBuild;constructor(e){this.cacheWarmAtBuild=q!==null,this.decorations=lt(e),this.cacheWarmAtBuild||this.warmCache(e)}update(e){let t=q!==null;(e.docChanged||e.viewportChanged||!this.cacheWarmAtBuild&&t)&&(this.cacheWarmAtBuild=t,this.decorations=lt(e.view))}warmCache(e){nt().then(()=>{try{e.dispatch({})}catch{}}).catch(e=>{console.warn(`[wiki-link-source] warmCache fetch failed:`,e)})}},{decorations:e=>e.decorations}),X=/\[\[([^[\]|#]+?)(?:#([^\]|]+?))?(?:\|([^\]]+?))?\]\]/g,dt=F.domEventHandlers({mousedown(e,t){if(!e.ctrlKey&&!e.metaKey)return!1;let n=t.posAtCoords({x:e.clientX,y:e.clientY});if(n===null)return!1;let r=t.state.doc.lineAt(n);X.lastIndex=0;let i=X.exec(r.text);for(;i!==null;){let t=r.from+i.index,a=t+i[0].length;if(n>=t&&n<=a){let t=i[1]?.trim(),n=i[2]?.trim()||null;if(t){let r=te(t,n);if(!r)return!1;e.preventDefault(),r.kind===`external`?window.open(r.url,`_blank`,`noopener,noreferrer`):E(e)?m(r):window.location.hash=r.anchor?`#/${r.docName}?anchor=${encodeURIComponent(r.anchor)}`:`#/${r.docName}`}return!0}i=X.exec(r.text)}return!1}});async function ft(e){let t=e.state.doc.sliceString(0,e.pos).match(/\[\[([^\]]*)$/);if(!t)return null;let n=t[1],r=e.pos-n.length,i=n.indexOf(`#`);if(i>0){let e=n.slice(0,i),t=n.slice(i+1),a=r+i+1,o=await rt(e);if(!o.length)return null;let s=x(o,t);return s.length?{from:a,filter:!1,options:s.map(e=>({label:e.text,detail:`H${e.level}`,apply(t,n,r,i){let a=t.state.doc.sliceString(i,i+2)===`]]`?``:`]]`;t.dispatch({changes:{from:r,to:i,insert:e.slug+a},selection:{anchor:r+e.slug.length+a.length}})}}))}:null}return{from:r,filter:!1,options:O(await nt().catch(e=>(console.warn(`[wiki-link-source] Failed to fetch pages:`,e),[])),n).map(e=>({label:e.title,detail:e.title===e.docName?void 0:e.docName,apply(t,n,r,i){let a=t.state.doc.sliceString(i,i+2)===`]]`?``:`]]`;t.dispatch({changes:{from:r,to:i,insert:e.docName+a},selection:{anchor:r+e.docName.length+a.length}})}}))}}var pt=F.theme({".cm-wiki-link":{color:`oklch(52.7% 0.154 228.4)`,fontWeight:`500`},".cm-wiki-link:hover":{textDecoration:`underline`,cursor:`pointer`}});function mt(){return[ut,dt,pt,ce.data.of({autocomplete:ft})]}var ht=V.mark({class:`cm-link-ref-broken`}),gt=/^\s{0,3}\[([^\]]+)\]:\s/,_t=/\[([^\]]*)\]\[([^\]]*)\]/g,vt=new Set([`FencedCode`,`CodeBlock`,`InlineCode`]);function Z(e,t){let n=0,r=t.length-1;for(;n<=r;){let i=n+r>>1,a=t[i];if(e<a.from)r=i-1;else if(e>=a.to)n=i+1;else return!0}return!1}function yt(e){let t=[];return j(e).iterate({enter(e){if(vt.has(e.name))return t.push({from:e.from,to:e.to}),!1}}),t.sort((e,t)=>e.from-t.from),t}function Q(e){let t=new Set,n=[],r=e.doc,i=yt(e);for(let e=1;e<=r.lines;e++){let n=r.line(e);if(Z(n.from,i))continue;let a=gt.exec(n.text);a&&t.add(a[1].toLowerCase())}for(let e=1;e<=r.lines;e++){let t=r.line(e);if(!Z(t.from,i)&&!gt.test(t.text))for(_t.lastIndex=0;;){let e=_t.exec(t.text);if(!e)break;let r=t.from+e.index;if(Z(r,i))continue;let a=e[2]||e[1];n.push({from:r,to:r+e[0].length,label:a.toLowerCase()})}}let a=[];for(let e of n)t.has(e.label)||a.push(ht.range(e.from,e.to));return a.sort((e,t)=>e.from-t.from),V.set(a)}var bt=N.define({create(e){return Q(e)},update(e,t){return t.docChanged?Q(t.state):e},provide:e=>F.decorations.from(e)}),xt=/^(\s*(?:[-*+]|\d+[.)]) (?:\[[ x]\] )?)/,St=V.mark({class:`cm-del`}),Ct=V.line({class:`cm-table-header`}),wt=V.line({class:`cm-table-row`});function Tt(e){let t=0;for(let n of e)if(n===` `)t++;else if(n===` `)t+=4;else break;return t}function Et(e,t){let n=[],r=j(e);for(let{from:i,to:a}of t)r.iterate({from:i,to:a,enter(t){if(t.name===`Strikethrough`){let e=t.from,r=t.to,i=t.node.cursor();if(i.firstChild())do i.name===`StrikethroughMark`&&(i.from===t.from?e=i.to:r=i.from);while(i.nextSibling());return e<r&&n.push(St.range(e,r)),!1}if(t.name===`ListItem`){let r=e.doc.lineAt(t.from),i=xt.exec(r.text),a=i?i[1].length:2,o=V.line({class:`cm-list-item`,attributes:{style:`--list-hang: ${a}ch`}});n.push(o.range(r.from));return}if(t.name===`FencedCode`){let r=e.doc.lineAt(t.from),i=e.doc.lineAt(t.to);for(let t=r.number+1;t<i.number;t++){let r=e.doc.line(t),i=Tt(r.text),a=V.line({class:`cm-fenced-code-line`,attributes:{style:`--line-indent: ${i}`}});n.push(a.range(r.from))}return!1}if(t.name===`TableHeader`){let r=e.doc.lineAt(t.from);return n.push(Ct.range(r.from)),!1}if(t.name===`TableRow`){let r=e.doc.lineAt(t.from);return n.push(wt.range(r.from)),!1}if(t.name===`TableDelimiter`&&t.node.parent?.name===`Table`){let r=e.doc.lineAt(t.from);return n.push(wt.range(r.from)),!1}}});return n.sort((e,t)=>e.from-t.from||e.value.startSide-t.value.startSide),V.set(n)}var Dt=class{decorations;constructor(e){this.decorations=Et(e.state,e.visibleRanges)}update(e){(e.docChanged||e.viewportChanged||j(e.startState)!==j(e.state))&&(this.decorations=Et(e.view.state,e.view.visibleRanges))}},Ot=I.fromClass(Dt,{decorations:e=>e.decorations});function kt(){return[Ot,bt]}var At=r(),jt=ge({settings:{background:`var(--background)`,gutterBackground:`var(--background)`}}),Mt=de({settings:{background:`var(--background)`,gutterBackground:`var(--background)`}}),Nt=new Se,Pt=new Se;function $(e,t){let n=e.state.doc,r=1;if(n.lines>=1&&n.line(1).text===`---`){for(let e=2;e<=n.lines;e++)if(n.line(e).text===`---`){r=e+1;break}}let i=ee(),a=0;for(let o=r;o<=n.lines;o++){let r=n.line(o);if(!i(r.text)&&/^#{1,6}\s/.test(r.text)){if(a===t.index){e.dispatch({selection:P.cursor(r.from),effects:F.scrollIntoView(r.from,{y:`start`})}),e.focus();return}a++}}}function Ft(e,t){requestAnimationFrame(()=>{let n=e.state.doc,r=Math.min(t.offset,n.length);e.dispatch({selection:P.cursor(r),effects:F.scrollIntoView(r,{y:`center`})}),e.focus()})}function It(e){let t=(0,Ce.c)(29),{docName:n,ytext:r,provider:i,placeholder:o,isSourceModeActive:s}=e,c=(0,H.useRef)(null),l=(0,H.useRef)(null),[u,f]=(0,H.useState)(null);if(u)throw u;let{resolvedTheme:p}=a(),m;t[0]!==s||t[1]!==i.awareness?(m=()=>{let e=i.awareness;if(e)return e.setLocalStateField(`mode`,s?`source`:`wysiwyg`),()=>{e.setLocalStateField(`mode`,`wysiwyg`)}},t[0]=s,t[1]=i.awareness,t[2]=m):m=t[2];let g;t[3]!==s||t[4]!==i?(g=[i,s],t[3]=s,t[4]=i,t[5]=g):g=t[5],(0,H.useEffect)(m,g);let _=(0,H.useRef)(null),v;t[6]!==o||t[7]!==i||t[8]!==p||t[9]!==r?(v=()=>{let e=c.current;if(!e)return;let t=i.configuration.name??``,n,a=Lt;try{n=h({docName:t,container:e,sizeStats:{viewCount:0,bytes:r.length},factory:e=>{let t=he({ydoc:i.document,ytext:r}),n=new F({state:ye.create({doc:r.toString(),extensions:[me,xe.of([oe]),se({base:ce,extensions:[le],codeLanguages:ze}),Re(r,i.awareness),We(i.document),mt(),Qe(),kt(),t,Nt.of(p===`dark`?jt:Mt),Pt.of(z(o??``)),F.lineWrapping,F.theme({"&":{height:`100%`}})]}),parent:e}),s=n.contentDOM;return s.addEventListener(`keydown`,a),s.addEventListener(`paste`,a),s.addEventListener(`drop`,a),s.addEventListener(`cut`,a),{view:n,ydoc:i.document,ytext:r,provider:i}}}),_.current=n,l.current=n.view}catch(e){let t=e;console.error(`[SourceEditor] mountCmEditor failed`,t),_.current=null,l.current=null,f(t instanceof Error?t:Error(String(t)))}return()=>{let e=_.current;e&&d(e),_.current=null,l.current=null}},t[6]=o,t[7]=i,t[8]=p,t[9]=r,t[10]=v):v=t[10];let y;t[11]!==i||t[12]!==r?(y=[r,i],t[11]=i,t[12]=r,t[13]=y):y=t[13],(0,H.useEffect)(v,y);let b,x;t[14]===p?(b=t[15],x=t[16]):(b=()=>{l.current&&l.current.dispatch({effects:Nt.reconfigure(p===`dark`?jt:Mt)})},x=[p],t[14]=p,t[15]=b,t[16]=x),(0,H.useEffect)(b,x);let S,C;t[17]===o?(S=t[18],C=t[19]):(S=()=>{l.current&&l.current.dispatch({effects:Pt.reconfigure(z(o??``))})},C=[o],t[17]=o,t[18]=S,t[19]=C),(0,H.useEffect)(S,C);let w,T;t[20]!==n||t[21]!==s?(T=()=>{let e=function(e){let t=e.detail;if(!t||t.mode!==`source`||!s)return;let r=l.current;r&&($(r,t),ie(n))};return window.addEventListener(ae,e),()=>window.removeEventListener(ae,e)},w=[n,s],t[20]=n,t[21]=s,t[22]=w,t[23]=T):(w=t[22],T=t[23]),(0,H.useEffect)(T,w);let E,D;t[24]!==n||t[25]!==s?(E=()=>{if(!s)return;let e=l.current;if(!e)return;let t=_e(n);if(t){if(t.kind===`outline`){$(e,t.detail);return}Ft(e,t.detail)}},D=[n,s],t[24]=n,t[25]=s,t[26]=E,t[27]=D):(E=t[26],D=t[27]),(0,H.useEffect)(E,D);let O;return t[28]===Symbol.for(`react.memo_cache_sentinel`)?(O=(0,At.jsx)(`div`,{ref:c,className:`source-editor h-full py-3`}),t[28]=O):O=t[28],O}function Lt(){return S()}export{It as SourceEditor};
@@ -1,4 +1,4 @@
1
- import{r as e}from"./chunk-DECur_0Z.js";import{n as t,r as n,t as r}from"./compiler-runtime-Y11fyRVL.js";import{a as i,f as a,i as o,n as s,o as c,r as l,s as u,t as d,u as f}from"./panel-BCRdtBla.js";import{n as p}from"./button-BPXuMr5W.js";import{G as m,n as ee,q as te,rt as ne}from"./DocumentContext-C7zXwLGg.js";import{x as re}from"./dialog-CtSN0d2b.js";import{Ft as ie,J as ae,M as oe,Rt as se,W as ce,Y as le,g as ue,n as de,v as fe}from"./PageListContext-DNRRECTw.js";import{$ as h,A as g,B as _,Bt as v,Ct as y,D as pe,Dt as b,E as x,Et as me,Ft as he,G as S,H as ge,Ht as _e,I as C,It as ve,J as ye,K as be,L as w,Lt as xe,M as Se,N as T,Nt as E,P as Ce,Pt as D,Q as we,Rt as Te,S as Ee,St as De,T as Oe,Tt as O,U as ke,V as Ae,Vt as je,W as Me,Y as k,Z as Ne,_ as Pe,a as Fe,at as Ie,b as Le,bt as Re,c as ze,ct as Be,d as Ve,et as He,f as Ue,g as We,gt as Ge,h as Ke,ht as qe,i as Je,j as Ye,jt as Xe,k as Ze,kt as Qe,l as $e,lt as et,mt as tt,n as nt,nt as rt,o as it,ot as at,p as ot,pt as st,q as A,r as ct,s as lt,st as ut,t as dt,tt as ft,u as pt,ut as mt,v as ht,vt as j,w as gt,x as _t,xt as vt,y as yt,z as bt,zt as xt}from"./dist-CgLbXgrr.js";import{a as St,c as M,i as Ct,n as wt,o as Tt,r as Et,s as Dt,t as Ot}from"./dist-D2wwoXzm.js";import{i as kt,n as N,r as At,t as jt}from"./dist-GlH2KPqY.js";var Mt=e(t(),1),Nt=r(),Pt=new Map;function Ft(e,t){Pt.set(e,t)}function It(e){let t=Pt.get(e)??null;return Pt.delete(e),t}function Lt(e){Pt.delete(e)}var Rt=class e{static create(t,n,r,i,a){return new e(t,n,r,i+(i<<8)+t+(n<<4)|0,a,[],[])}constructor(e,t,n,r,i,a,o){this.type=e,this.value=t,this.from=n,this.hash=r,this.end=i,this.children=a,this.positions=o,this.hashProp=[[_.contextHash,r]]}addChild(e,t){e.prop(_.contextHash)!=this.hash&&(e=new S(e.type,e.children,e.positions,e.length,this.hashProp)),this.children.push(e),this.positions.push(t)}toTree(e,t=this.end){let n=this.children.length-1;return n>=0&&(t=Math.max(t,this.positions[n]+this.children[n].length+this.from)),new S(e.types[this.type],this.children,this.positions,t-this.from).balance({makeTree:(e,t,n)=>new S(ge.none,e,t,n,this.hashProp)})}},P;(function(e){e[e.Document=1]=`Document`,e[e.CodeBlock=2]=`CodeBlock`,e[e.FencedCode=3]=`FencedCode`,e[e.Blockquote=4]=`Blockquote`,e[e.HorizontalRule=5]=`HorizontalRule`,e[e.BulletList=6]=`BulletList`,e[e.OrderedList=7]=`OrderedList`,e[e.ListItem=8]=`ListItem`,e[e.ATXHeading1=9]=`ATXHeading1`,e[e.ATXHeading2=10]=`ATXHeading2`,e[e.ATXHeading3=11]=`ATXHeading3`,e[e.ATXHeading4=12]=`ATXHeading4`,e[e.ATXHeading5=13]=`ATXHeading5`,e[e.ATXHeading6=14]=`ATXHeading6`,e[e.SetextHeading1=15]=`SetextHeading1`,e[e.SetextHeading2=16]=`SetextHeading2`,e[e.HTMLBlock=17]=`HTMLBlock`,e[e.LinkReference=18]=`LinkReference`,e[e.Paragraph=19]=`Paragraph`,e[e.CommentBlock=20]=`CommentBlock`,e[e.ProcessingInstructionBlock=21]=`ProcessingInstructionBlock`,e[e.Escape=22]=`Escape`,e[e.Entity=23]=`Entity`,e[e.HardBreak=24]=`HardBreak`,e[e.Emphasis=25]=`Emphasis`,e[e.StrongEmphasis=26]=`StrongEmphasis`,e[e.Link=27]=`Link`,e[e.Image=28]=`Image`,e[e.InlineCode=29]=`InlineCode`,e[e.HTMLTag=30]=`HTMLTag`,e[e.Comment=31]=`Comment`,e[e.ProcessingInstruction=32]=`ProcessingInstruction`,e[e.Autolink=33]=`Autolink`,e[e.HeaderMark=34]=`HeaderMark`,e[e.QuoteMark=35]=`QuoteMark`,e[e.ListMark=36]=`ListMark`,e[e.LinkMark=37]=`LinkMark`,e[e.EmphasisMark=38]=`EmphasisMark`,e[e.CodeMark=39]=`CodeMark`,e[e.CodeText=40]=`CodeText`,e[e.CodeInfo=41]=`CodeInfo`,e[e.LinkTitle=42]=`LinkTitle`,e[e.LinkLabel=43]=`LinkLabel`,e[e.URL=44]=`URL`})(P||={});var zt=class{constructor(e,t){this.start=e,this.content=t,this.marks=[],this.parsers=[]}},Bt=class{constructor(){this.text=``,this.baseIndent=0,this.basePos=0,this.depth=0,this.markers=[],this.pos=0,this.indent=0,this.next=-1}forward(){this.basePos>this.pos&&this.forwardInner()}forwardInner(){let e=this.skipSpace(this.basePos);this.indent=this.countIndent(e,this.pos,this.indent),this.pos=e,this.next=e==this.text.length?-1:this.text.charCodeAt(e)}skipSpace(e){return Ut(this.text,e)}reset(e){for(this.text=e,this.baseIndent=this.basePos=this.pos=this.indent=0,this.forwardInner(),this.depth=1;this.markers.length;)this.markers.pop()}moveBase(e){this.basePos=e,this.baseIndent=this.countIndent(e,this.pos,this.indent)}moveBaseColumn(e){this.baseIndent=e,this.basePos=this.findColumn(e)}addMarker(e){this.markers.push(e)}countIndent(e,t=0,n=0){for(let r=t;r<e;r++)n+=this.text.charCodeAt(r)==9?4-n%4:1;return n}findColumn(e){let t=0;for(let n=0;t<this.text.length&&n<e;t++)n+=this.text.charCodeAt(t)==9?4-n%4:1;return t}scrub(){if(!this.baseIndent)return this.text;let e=``;for(let t=0;t<this.basePos;t++)e+=` `;return e+this.text.slice(this.basePos)}};function Vt(e,t,n){if(n.pos==n.text.length||e!=t.block&&n.indent>=t.stack[n.depth+1].value+n.baseIndent)return!0;if(n.indent>=n.baseIndent+4)return!1;let r=(e.type==P.OrderedList?Xt:Yt)(n,t,!1);return r>0&&(e.type!=P.BulletList||qt(n,t,!1)<0)&&n.text.charCodeAt(n.pos+r-1)==e.value}var Ht={[P.Blockquote](e,t,n){return n.next==62?(n.markers.push(I(P.QuoteMark,t.lineStart+n.pos,t.lineStart+n.pos+1)),n.moveBase(n.pos+(F(n.text.charCodeAt(n.pos+1))?2:1)),e.end=t.lineStart+n.text.length,!0):!1},[P.ListItem](e,t,n){return n.indent<n.baseIndent+e.value&&n.next>-1?!1:(n.moveBaseColumn(n.baseIndent+e.value),!0)},[P.OrderedList]:Vt,[P.BulletList]:Vt,[P.Document](){return!0}};function F(e){return e==32||e==9||e==10||e==13}function Ut(e,t=0){for(;t<e.length&&F(e.charCodeAt(t));)t++;return t}function Wt(e,t,n){for(;t>n&&F(e.charCodeAt(t-1));)t--;return t}function Gt(e){if(e.next!=96&&e.next!=126)return-1;let t=e.pos+1;for(;t<e.text.length&&e.text.charCodeAt(t)==e.next;)t++;if(t<e.pos+3)return-1;if(e.next==96){for(let n=t;n<e.text.length;n++)if(e.text.charCodeAt(n)==96)return-1}return t}function Kt(e){return e.next==62?e.text.charCodeAt(e.pos+1)==32?2:1:-1}function qt(e,t,n){if(e.next!=42&&e.next!=45&&e.next!=95)return-1;let r=1;for(let t=e.pos+1;t<e.text.length;t++){let n=e.text.charCodeAt(t);if(n==e.next)r++;else if(!F(n))return-1}return n&&e.next==45&&Qt(e)>-1&&e.depth==t.stack.length&&t.parser.leafBlockParsers.indexOf(dn.SetextHeading)>-1||r<3?-1:1}function Jt(e,t){for(let n=e.stack.length-1;n>=0;n--)if(e.stack[n].type==t)return!0;return!1}function Yt(e,t,n){return(e.next==45||e.next==43||e.next==42)&&(e.pos==e.text.length-1||F(e.text.charCodeAt(e.pos+1)))&&(!n||Jt(t,P.BulletList)||e.skipSpace(e.pos+2)<e.text.length)?1:-1}function Xt(e,t,n){let r=e.pos,i=e.next;for(;i>=48&&i<=57;){if(r++,r==e.text.length)return-1;i=e.text.charCodeAt(r)}return r==e.pos||r>e.pos+9||i!=46&&i!=41||r<e.text.length-1&&!F(e.text.charCodeAt(r+1))||n&&!Jt(t,P.OrderedList)&&(e.skipSpace(r+1)==e.text.length||r>e.pos+1||e.next!=49)?-1:r+1-e.pos}function Zt(e){if(e.next!=35)return-1;let t=e.pos+1;for(;t<e.text.length&&e.text.charCodeAt(t)==35;)t++;if(t<e.text.length&&e.text.charCodeAt(t)!=32)return-1;let n=t-e.pos;return n>6?-1:n}function Qt(e){if(e.next!=45&&e.next!=61||e.indent>=e.baseIndent+4)return-1;let t=e.pos+1;for(;t<e.text.length&&e.text.charCodeAt(t)==e.next;)t++;let n=t;for(;t<e.text.length&&F(e.text.charCodeAt(t));)t++;return t==e.text.length?n:-1}var $t=/^[ \t]*$/,en=/-->/,tn=/\?>/,nn=[[/^<(?:script|pre|style)(?:\s|>|$)/i,/<\/(?:script|pre|style)>/i],[/^\s*<!--/,en],[/^\s*<\?/,tn],[/^\s*<![A-Z]/,/>/],[/^\s*<!\[CDATA\[/,/\]\]>/],[/^\s*<\/?(?:address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h1|h2|h3|h4|h5|h6|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|nav|noframes|ol|optgroup|option|p|param|section|source|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul)(?:\s|\/?>|$)/i,$t],[/^\s*(?:<\/[a-z][\w-]*\s*>|<[a-z][\w-]*(\s+[a-z:_][\w-.]*(?:\s*=\s*(?:[^\s"'=<>`]+|'[^']*'|"[^"]*"))?)*\s*>)\s*$/i,$t]];function rn(e,t,n){if(e.next!=60)return-1;let r=e.text.slice(e.pos);for(let e=0,t=nn.length-+!!n;e<t;e++)if(nn[e][0].test(r))return e;return-1}function an(e,t){let n=e.countIndent(t,e.pos,e.indent),r=e.countIndent(e.skipSpace(t),t,n);return r>=n+5?n+1:r}function on(e,t,n){let r=e.length-1;r>=0&&e[r].to==t&&e[r].type==P.CodeText?e[r].to=n:e.push(I(P.CodeText,t,n))}var sn={LinkReference:void 0,IndentedCode(e,t){let n=t.baseIndent+4;if(t.indent<n)return!1;let r=t.findColumn(n),i=e.lineStart+r,a=e.lineStart+t.text.length,o=[],s=[];for(on(o,i,a);e.nextLine()&&t.depth>=e.stack.length;)if(t.pos==t.text.length){on(s,e.lineStart-1,e.lineStart);for(let e of t.markers)s.push(e)}else if(t.indent<n)break;else{if(s.length){for(let e of s)e.type==P.CodeText?on(o,e.from,e.to):o.push(e);s=[]}on(o,e.lineStart-1,e.lineStart);for(let e of t.markers)o.push(e);a=e.lineStart+t.text.length;let n=e.lineStart+t.findColumn(t.baseIndent+4);n<a&&on(o,n,a)}return s.length&&(s=s.filter(e=>e.type!=P.CodeText),s.length&&(t.markers=s.concat(t.markers))),e.addNode(e.buffer.writeElements(o,-i).finish(P.CodeBlock,a-i),i),!0},FencedCode(e,t){let n=Gt(t);if(n<0)return!1;let r=e.lineStart+t.pos,i=t.next,a=n-t.pos,o=t.skipSpace(n),s=Wt(t.text,t.text.length,o),c=[I(P.CodeMark,r,r+a)];o<s&&c.push(I(P.CodeInfo,e.lineStart+o,e.lineStart+s));for(let n=!0,r=!0,o=!1;e.nextLine()&&t.depth>=e.stack.length;n=!1){let s=t.pos;if(t.indent-t.baseIndent<4)for(;s<t.text.length&&t.text.charCodeAt(s)==i;)s++;if(s-t.pos>=a&&t.skipSpace(s)==t.text.length){for(let e of t.markers)c.push(e);r&&o&&on(c,e.lineStart-1,e.lineStart),c.push(I(P.CodeMark,e.lineStart+t.pos,e.lineStart+s)),e.nextLine();break}else{o=!0,n||(on(c,e.lineStart-1,e.lineStart),r=!1);for(let e of t.markers)c.push(e);let i=e.lineStart+t.basePos,a=e.lineStart+t.text.length;i<a&&(on(c,i,a),r=!1)}}return e.addNode(e.buffer.writeElements(c,-r).finish(P.FencedCode,e.prevLineEnd()-r),r),!0},Blockquote(e,t){let n=Kt(t);return n<0?!1:(e.startContext(P.Blockquote,t.pos),e.addNode(P.QuoteMark,e.lineStart+t.pos,e.lineStart+t.pos+1),t.moveBase(t.pos+n),null)},HorizontalRule(e,t){if(qt(t,e,!1)<0)return!1;let n=e.lineStart+t.pos;return e.nextLine(),e.addNode(P.HorizontalRule,n),!0},BulletList(e,t){let n=Yt(t,e,!1);if(n<0)return!1;e.block.type!=P.BulletList&&e.startContext(P.BulletList,t.basePos,t.next);let r=an(t,t.pos+1);return e.startContext(P.ListItem,t.basePos,r-t.baseIndent),e.addNode(P.ListMark,e.lineStart+t.pos,e.lineStart+t.pos+n),t.moveBaseColumn(r),null},OrderedList(e,t){let n=Xt(t,e,!1);if(n<0)return!1;e.block.type!=P.OrderedList&&e.startContext(P.OrderedList,t.basePos,t.text.charCodeAt(t.pos+n-1));let r=an(t,t.pos+n);return e.startContext(P.ListItem,t.basePos,r-t.baseIndent),e.addNode(P.ListMark,e.lineStart+t.pos,e.lineStart+t.pos+n),t.moveBaseColumn(r),null},ATXHeading(e,t){let n=Zt(t);if(n<0)return!1;let r=t.pos,i=e.lineStart+r,a=Wt(t.text,t.text.length,r),o=a;for(;o>r&&t.text.charCodeAt(o-1)==t.next;)o--;(o==a||o==r||!F(t.text.charCodeAt(o-1)))&&(o=t.text.length);let s=e.buffer.write(P.HeaderMark,0,n).writeElements(e.parser.parseInline(t.text.slice(r+n+1,o),i+n+1),-i);o<t.text.length&&s.write(P.HeaderMark,o-r,a-r);let c=s.finish(P.ATXHeading1-1+n,t.text.length-r);return e.nextLine(),e.addNode(c,i),!0},HTMLBlock(e,t){let n=rn(t,e,!1);if(n<0)return!1;let r=e.lineStart+t.pos,i=nn[n][1],a=[],o=i!=$t;for(;!i.test(t.text)&&e.nextLine();){if(t.depth<e.stack.length){o=!1;break}for(let e of t.markers)a.push(e)}o&&e.nextLine();let s=i==en?P.CommentBlock:i==tn?P.ProcessingInstructionBlock:P.HTMLBlock,c=e.prevLineEnd();return e.addNode(e.buffer.writeElements(a,-r).finish(s,c-r),r),!0},SetextHeading:void 0},cn=class{constructor(e){this.stage=0,this.elts=[],this.pos=0,this.start=e.start,this.advance(e.content)}nextLine(e,t,n){if(this.stage==-1)return!1;let r=n.content+`
1
+ import{r as e}from"./chunk-DECur_0Z.js";import{n as t,r as n,t as r}from"./compiler-runtime-Y11fyRVL.js";import{a as i,f as a,i as o,n as s,o as c,r as l,s as u,t as d,u as f}from"./panel-BCRdtBla.js";import{n as p}from"./button-BPXuMr5W.js";import{J as m,K as ee,it as te,n as ne}from"./DocumentContext-D9TYylem.js";import{x as re}from"./dialog-CtSN0d2b.js";import{Ft as ie,J as ae,M as oe,Rt as se,W as ce,Y as le,g as ue,n as de,v as fe}from"./PageListContext-DNRRECTw.js";import{$ as h,A as g,B as _,Bt as v,Ct as y,D as pe,Dt as b,E as x,Et as me,Ft as he,G as S,H as ge,Ht as _e,I as C,It as ve,J as ye,K as be,L as w,Lt as xe,M as Se,N as T,Nt as E,P as Ce,Pt as D,Q as we,Rt as Te,S as Ee,St as De,T as Oe,Tt as O,U as ke,V as Ae,Vt as je,W as Me,Y as k,Z as Ne,_ as Pe,a as Fe,at as Ie,b as Le,bt as Re,c as ze,ct as Be,d as Ve,et as He,f as Ue,g as We,gt as Ge,h as Ke,ht as qe,i as Je,j as Ye,jt as Xe,k as Ze,kt as Qe,l as $e,lt as et,mt as tt,n as nt,nt as rt,o as it,ot as at,p as ot,pt as st,q as A,r as ct,s as lt,st as ut,t as dt,tt as ft,u as pt,ut as mt,v as ht,vt as j,w as gt,x as _t,xt as vt,y as yt,z as bt,zt as xt}from"./dist-CgLbXgrr.js";import{a as St,c as M,i as Ct,n as wt,o as Tt,r as Et,s as Dt,t as Ot}from"./dist-D2wwoXzm.js";import{i as kt,n as N,r as At,t as jt}from"./dist-GlH2KPqY.js";var Mt=e(t(),1),Nt=r(),Pt=new Map;function Ft(e,t){Pt.set(e,t)}function It(e){let t=Pt.get(e)??null;return Pt.delete(e),t}function Lt(e){Pt.delete(e)}var Rt=class e{static create(t,n,r,i,a){return new e(t,n,r,i+(i<<8)+t+(n<<4)|0,a,[],[])}constructor(e,t,n,r,i,a,o){this.type=e,this.value=t,this.from=n,this.hash=r,this.end=i,this.children=a,this.positions=o,this.hashProp=[[_.contextHash,r]]}addChild(e,t){e.prop(_.contextHash)!=this.hash&&(e=new S(e.type,e.children,e.positions,e.length,this.hashProp)),this.children.push(e),this.positions.push(t)}toTree(e,t=this.end){let n=this.children.length-1;return n>=0&&(t=Math.max(t,this.positions[n]+this.children[n].length+this.from)),new S(e.types[this.type],this.children,this.positions,t-this.from).balance({makeTree:(e,t,n)=>new S(ge.none,e,t,n,this.hashProp)})}},P;(function(e){e[e.Document=1]=`Document`,e[e.CodeBlock=2]=`CodeBlock`,e[e.FencedCode=3]=`FencedCode`,e[e.Blockquote=4]=`Blockquote`,e[e.HorizontalRule=5]=`HorizontalRule`,e[e.BulletList=6]=`BulletList`,e[e.OrderedList=7]=`OrderedList`,e[e.ListItem=8]=`ListItem`,e[e.ATXHeading1=9]=`ATXHeading1`,e[e.ATXHeading2=10]=`ATXHeading2`,e[e.ATXHeading3=11]=`ATXHeading3`,e[e.ATXHeading4=12]=`ATXHeading4`,e[e.ATXHeading5=13]=`ATXHeading5`,e[e.ATXHeading6=14]=`ATXHeading6`,e[e.SetextHeading1=15]=`SetextHeading1`,e[e.SetextHeading2=16]=`SetextHeading2`,e[e.HTMLBlock=17]=`HTMLBlock`,e[e.LinkReference=18]=`LinkReference`,e[e.Paragraph=19]=`Paragraph`,e[e.CommentBlock=20]=`CommentBlock`,e[e.ProcessingInstructionBlock=21]=`ProcessingInstructionBlock`,e[e.Escape=22]=`Escape`,e[e.Entity=23]=`Entity`,e[e.HardBreak=24]=`HardBreak`,e[e.Emphasis=25]=`Emphasis`,e[e.StrongEmphasis=26]=`StrongEmphasis`,e[e.Link=27]=`Link`,e[e.Image=28]=`Image`,e[e.InlineCode=29]=`InlineCode`,e[e.HTMLTag=30]=`HTMLTag`,e[e.Comment=31]=`Comment`,e[e.ProcessingInstruction=32]=`ProcessingInstruction`,e[e.Autolink=33]=`Autolink`,e[e.HeaderMark=34]=`HeaderMark`,e[e.QuoteMark=35]=`QuoteMark`,e[e.ListMark=36]=`ListMark`,e[e.LinkMark=37]=`LinkMark`,e[e.EmphasisMark=38]=`EmphasisMark`,e[e.CodeMark=39]=`CodeMark`,e[e.CodeText=40]=`CodeText`,e[e.CodeInfo=41]=`CodeInfo`,e[e.LinkTitle=42]=`LinkTitle`,e[e.LinkLabel=43]=`LinkLabel`,e[e.URL=44]=`URL`})(P||={});var zt=class{constructor(e,t){this.start=e,this.content=t,this.marks=[],this.parsers=[]}},Bt=class{constructor(){this.text=``,this.baseIndent=0,this.basePos=0,this.depth=0,this.markers=[],this.pos=0,this.indent=0,this.next=-1}forward(){this.basePos>this.pos&&this.forwardInner()}forwardInner(){let e=this.skipSpace(this.basePos);this.indent=this.countIndent(e,this.pos,this.indent),this.pos=e,this.next=e==this.text.length?-1:this.text.charCodeAt(e)}skipSpace(e){return Ut(this.text,e)}reset(e){for(this.text=e,this.baseIndent=this.basePos=this.pos=this.indent=0,this.forwardInner(),this.depth=1;this.markers.length;)this.markers.pop()}moveBase(e){this.basePos=e,this.baseIndent=this.countIndent(e,this.pos,this.indent)}moveBaseColumn(e){this.baseIndent=e,this.basePos=this.findColumn(e)}addMarker(e){this.markers.push(e)}countIndent(e,t=0,n=0){for(let r=t;r<e;r++)n+=this.text.charCodeAt(r)==9?4-n%4:1;return n}findColumn(e){let t=0;for(let n=0;t<this.text.length&&n<e;t++)n+=this.text.charCodeAt(t)==9?4-n%4:1;return t}scrub(){if(!this.baseIndent)return this.text;let e=``;for(let t=0;t<this.basePos;t++)e+=` `;return e+this.text.slice(this.basePos)}};function Vt(e,t,n){if(n.pos==n.text.length||e!=t.block&&n.indent>=t.stack[n.depth+1].value+n.baseIndent)return!0;if(n.indent>=n.baseIndent+4)return!1;let r=(e.type==P.OrderedList?Xt:Yt)(n,t,!1);return r>0&&(e.type!=P.BulletList||qt(n,t,!1)<0)&&n.text.charCodeAt(n.pos+r-1)==e.value}var Ht={[P.Blockquote](e,t,n){return n.next==62?(n.markers.push(I(P.QuoteMark,t.lineStart+n.pos,t.lineStart+n.pos+1)),n.moveBase(n.pos+(F(n.text.charCodeAt(n.pos+1))?2:1)),e.end=t.lineStart+n.text.length,!0):!1},[P.ListItem](e,t,n){return n.indent<n.baseIndent+e.value&&n.next>-1?!1:(n.moveBaseColumn(n.baseIndent+e.value),!0)},[P.OrderedList]:Vt,[P.BulletList]:Vt,[P.Document](){return!0}};function F(e){return e==32||e==9||e==10||e==13}function Ut(e,t=0){for(;t<e.length&&F(e.charCodeAt(t));)t++;return t}function Wt(e,t,n){for(;t>n&&F(e.charCodeAt(t-1));)t--;return t}function Gt(e){if(e.next!=96&&e.next!=126)return-1;let t=e.pos+1;for(;t<e.text.length&&e.text.charCodeAt(t)==e.next;)t++;if(t<e.pos+3)return-1;if(e.next==96){for(let n=t;n<e.text.length;n++)if(e.text.charCodeAt(n)==96)return-1}return t}function Kt(e){return e.next==62?e.text.charCodeAt(e.pos+1)==32?2:1:-1}function qt(e,t,n){if(e.next!=42&&e.next!=45&&e.next!=95)return-1;let r=1;for(let t=e.pos+1;t<e.text.length;t++){let n=e.text.charCodeAt(t);if(n==e.next)r++;else if(!F(n))return-1}return n&&e.next==45&&Qt(e)>-1&&e.depth==t.stack.length&&t.parser.leafBlockParsers.indexOf(dn.SetextHeading)>-1||r<3?-1:1}function Jt(e,t){for(let n=e.stack.length-1;n>=0;n--)if(e.stack[n].type==t)return!0;return!1}function Yt(e,t,n){return(e.next==45||e.next==43||e.next==42)&&(e.pos==e.text.length-1||F(e.text.charCodeAt(e.pos+1)))&&(!n||Jt(t,P.BulletList)||e.skipSpace(e.pos+2)<e.text.length)?1:-1}function Xt(e,t,n){let r=e.pos,i=e.next;for(;i>=48&&i<=57;){if(r++,r==e.text.length)return-1;i=e.text.charCodeAt(r)}return r==e.pos||r>e.pos+9||i!=46&&i!=41||r<e.text.length-1&&!F(e.text.charCodeAt(r+1))||n&&!Jt(t,P.OrderedList)&&(e.skipSpace(r+1)==e.text.length||r>e.pos+1||e.next!=49)?-1:r+1-e.pos}function Zt(e){if(e.next!=35)return-1;let t=e.pos+1;for(;t<e.text.length&&e.text.charCodeAt(t)==35;)t++;if(t<e.text.length&&e.text.charCodeAt(t)!=32)return-1;let n=t-e.pos;return n>6?-1:n}function Qt(e){if(e.next!=45&&e.next!=61||e.indent>=e.baseIndent+4)return-1;let t=e.pos+1;for(;t<e.text.length&&e.text.charCodeAt(t)==e.next;)t++;let n=t;for(;t<e.text.length&&F(e.text.charCodeAt(t));)t++;return t==e.text.length?n:-1}var $t=/^[ \t]*$/,en=/-->/,tn=/\?>/,nn=[[/^<(?:script|pre|style)(?:\s|>|$)/i,/<\/(?:script|pre|style)>/i],[/^\s*<!--/,en],[/^\s*<\?/,tn],[/^\s*<![A-Z]/,/>/],[/^\s*<!\[CDATA\[/,/\]\]>/],[/^\s*<\/?(?:address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h1|h2|h3|h4|h5|h6|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|nav|noframes|ol|optgroup|option|p|param|section|source|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul)(?:\s|\/?>|$)/i,$t],[/^\s*(?:<\/[a-z][\w-]*\s*>|<[a-z][\w-]*(\s+[a-z:_][\w-.]*(?:\s*=\s*(?:[^\s"'=<>`]+|'[^']*'|"[^"]*"))?)*\s*>)\s*$/i,$t]];function rn(e,t,n){if(e.next!=60)return-1;let r=e.text.slice(e.pos);for(let e=0,t=nn.length-+!!n;e<t;e++)if(nn[e][0].test(r))return e;return-1}function an(e,t){let n=e.countIndent(t,e.pos,e.indent),r=e.countIndent(e.skipSpace(t),t,n);return r>=n+5?n+1:r}function on(e,t,n){let r=e.length-1;r>=0&&e[r].to==t&&e[r].type==P.CodeText?e[r].to=n:e.push(I(P.CodeText,t,n))}var sn={LinkReference:void 0,IndentedCode(e,t){let n=t.baseIndent+4;if(t.indent<n)return!1;let r=t.findColumn(n),i=e.lineStart+r,a=e.lineStart+t.text.length,o=[],s=[];for(on(o,i,a);e.nextLine()&&t.depth>=e.stack.length;)if(t.pos==t.text.length){on(s,e.lineStart-1,e.lineStart);for(let e of t.markers)s.push(e)}else if(t.indent<n)break;else{if(s.length){for(let e of s)e.type==P.CodeText?on(o,e.from,e.to):o.push(e);s=[]}on(o,e.lineStart-1,e.lineStart);for(let e of t.markers)o.push(e);a=e.lineStart+t.text.length;let n=e.lineStart+t.findColumn(t.baseIndent+4);n<a&&on(o,n,a)}return s.length&&(s=s.filter(e=>e.type!=P.CodeText),s.length&&(t.markers=s.concat(t.markers))),e.addNode(e.buffer.writeElements(o,-i).finish(P.CodeBlock,a-i),i),!0},FencedCode(e,t){let n=Gt(t);if(n<0)return!1;let r=e.lineStart+t.pos,i=t.next,a=n-t.pos,o=t.skipSpace(n),s=Wt(t.text,t.text.length,o),c=[I(P.CodeMark,r,r+a)];o<s&&c.push(I(P.CodeInfo,e.lineStart+o,e.lineStart+s));for(let n=!0,r=!0,o=!1;e.nextLine()&&t.depth>=e.stack.length;n=!1){let s=t.pos;if(t.indent-t.baseIndent<4)for(;s<t.text.length&&t.text.charCodeAt(s)==i;)s++;if(s-t.pos>=a&&t.skipSpace(s)==t.text.length){for(let e of t.markers)c.push(e);r&&o&&on(c,e.lineStart-1,e.lineStart),c.push(I(P.CodeMark,e.lineStart+t.pos,e.lineStart+s)),e.nextLine();break}else{o=!0,n||(on(c,e.lineStart-1,e.lineStart),r=!1);for(let e of t.markers)c.push(e);let i=e.lineStart+t.basePos,a=e.lineStart+t.text.length;i<a&&(on(c,i,a),r=!1)}}return e.addNode(e.buffer.writeElements(c,-r).finish(P.FencedCode,e.prevLineEnd()-r),r),!0},Blockquote(e,t){let n=Kt(t);return n<0?!1:(e.startContext(P.Blockquote,t.pos),e.addNode(P.QuoteMark,e.lineStart+t.pos,e.lineStart+t.pos+1),t.moveBase(t.pos+n),null)},HorizontalRule(e,t){if(qt(t,e,!1)<0)return!1;let n=e.lineStart+t.pos;return e.nextLine(),e.addNode(P.HorizontalRule,n),!0},BulletList(e,t){let n=Yt(t,e,!1);if(n<0)return!1;e.block.type!=P.BulletList&&e.startContext(P.BulletList,t.basePos,t.next);let r=an(t,t.pos+1);return e.startContext(P.ListItem,t.basePos,r-t.baseIndent),e.addNode(P.ListMark,e.lineStart+t.pos,e.lineStart+t.pos+n),t.moveBaseColumn(r),null},OrderedList(e,t){let n=Xt(t,e,!1);if(n<0)return!1;e.block.type!=P.OrderedList&&e.startContext(P.OrderedList,t.basePos,t.text.charCodeAt(t.pos+n-1));let r=an(t,t.pos+n);return e.startContext(P.ListItem,t.basePos,r-t.baseIndent),e.addNode(P.ListMark,e.lineStart+t.pos,e.lineStart+t.pos+n),t.moveBaseColumn(r),null},ATXHeading(e,t){let n=Zt(t);if(n<0)return!1;let r=t.pos,i=e.lineStart+r,a=Wt(t.text,t.text.length,r),o=a;for(;o>r&&t.text.charCodeAt(o-1)==t.next;)o--;(o==a||o==r||!F(t.text.charCodeAt(o-1)))&&(o=t.text.length);let s=e.buffer.write(P.HeaderMark,0,n).writeElements(e.parser.parseInline(t.text.slice(r+n+1,o),i+n+1),-i);o<t.text.length&&s.write(P.HeaderMark,o-r,a-r);let c=s.finish(P.ATXHeading1-1+n,t.text.length-r);return e.nextLine(),e.addNode(c,i),!0},HTMLBlock(e,t){let n=rn(t,e,!1);if(n<0)return!1;let r=e.lineStart+t.pos,i=nn[n][1],a=[],o=i!=$t;for(;!i.test(t.text)&&e.nextLine();){if(t.depth<e.stack.length){o=!1;break}for(let e of t.markers)a.push(e)}o&&e.nextLine();let s=i==en?P.CommentBlock:i==tn?P.ProcessingInstructionBlock:P.HTMLBlock,c=e.prevLineEnd();return e.addNode(e.buffer.writeElements(a,-r).finish(s,c-r),r),!0},SetextHeading:void 0},cn=class{constructor(e){this.stage=0,this.elts=[],this.pos=0,this.start=e.start,this.advance(e.content)}nextLine(e,t,n){if(this.stage==-1)return!1;let r=n.content+`
2
2
  `+t.scrub(),i=this.advance(r);return i>-1&&i<r.length?this.complete(e,n,i):!1}finish(e,t){return(this.stage==2||this.stage==3)&&Ut(t.content,this.pos)==t.content.length?this.complete(e,t,t.content.length):!1}complete(e,t,n){return e.addLeafElement(t,I(P.LinkReference,this.start,this.start+n,this.elts)),!0}nextStage(e){return e?(this.pos=e.to-this.start,this.elts.push(e),this.stage++,!0):(e===!1&&(this.stage=-1),!1)}advance(e){for(;;)if(this.stage==-1)return-1;else if(this.stage==0){if(!this.nextStage(Fn(e,this.pos,this.start,!0)))return-1;if(e.charCodeAt(this.pos)!=58)return this.stage=-1;this.elts.push(I(P.LinkMark,this.pos+this.start,this.pos+this.start+1)),this.pos++}else if(this.stage==1){if(!this.nextStage(Nn(e,Ut(e,this.pos),this.start)))return-1}else if(this.stage==2){let t=Ut(e,this.pos),n=0;if(t>this.pos){let r=Pn(e,t,this.start);if(r){let t=ln(e,r.to-this.start);t>0&&(this.nextStage(r),n=t)}}return n||=ln(e,this.pos),n>0&&n<e.length?n:-1}else return ln(e,this.pos)}};function ln(e,t){for(;t<e.length;t++){let n=e.charCodeAt(t);if(n==10)break;if(!F(n))return-1}return t}var un=class{nextLine(e,t,n){let r=t.depth<e.stack.length?-1:Qt(t),i=t.next;if(r<0)return!1;let a=I(P.HeaderMark,e.lineStart+t.pos,e.lineStart+r);return e.nextLine(),e.addLeafElement(n,I(i==61?P.SetextHeading1:P.SetextHeading2,n.start,e.prevLineEnd(),[...e.parser.parseInline(n.content,n.start),a])),!0}finish(){return!1}},dn={LinkReference(e,t){return t.content.charCodeAt(0)==91?new cn(t):null},SetextHeading(){return new un}},fn=[(e,t)=>Zt(t)>=0,(e,t)=>Gt(t)>=0,(e,t)=>Kt(t)>=0,(e,t)=>Yt(t,e,!0)>=0,(e,t)=>Xt(t,e,!0)>=0,(e,t)=>qt(t,e,!0)>=0,(e,t)=>rn(t,e,!0)>=0],pn={text:``,end:0},mn=class{constructor(e,t,n,r){this.parser=e,this.input=t,this.ranges=r,this.line=new Bt,this.atEnd=!1,this.reusePlaceholders=new Map,this.stoppedAt=null,this.rangeI=0,this.to=r[r.length-1].to,this.lineStart=this.absoluteLineStart=this.absoluteLineEnd=r[0].from,this.block=Rt.create(P.Document,0,this.lineStart,0,0),this.stack=[this.block],this.fragments=n.length?new zn(n,t):null,this.readLine()}get parsedPos(){return this.absoluteLineStart}advance(){if(this.stoppedAt!=null&&this.absoluteLineStart>this.stoppedAt)return this.finish();let{line:e}=this;for(;;){for(let t=0;;){let n=e.depth<this.stack.length?this.stack[this.stack.length-1]:null;for(;t<e.markers.length&&(!n||e.markers[t].from<n.end);){let n=e.markers[t++];this.addNode(n.type,n.from,n.to)}if(!n)break;this.finishContext()}if(e.pos<e.text.length)break;if(!this.nextLine())return this.finish()}if(this.fragments&&this.reuseFragment(e.basePos))return null;start:for(;;){for(let t of this.parser.blockParsers)if(t){let n=t(this,e);if(n!=0){if(n==1)return null;e.forward();continue start}}break}let t=new zt(this.lineStart+e.pos,e.text.slice(e.pos));for(let e of this.parser.leafBlockParsers)if(e){let n=e(this,t);n&&t.parsers.push(n)}lines:for(;this.nextLine()&&e.pos!=e.text.length;){if(e.indent<e.baseIndent+4){for(let n of this.parser.endLeafBlock)if(n(this,e,t))break lines}for(let n of t.parsers)if(n.nextLine(this,e,t))return null;t.content+=`
3
3
  `+e.scrub();for(let n of e.markers)t.marks.push(n)}return this.finishLeaf(t),null}stopAt(e){if(this.stoppedAt!=null&&this.stoppedAt<e)throw RangeError(`Can't move stoppedAt forward`);this.stoppedAt=e}reuseFragment(e){if(!this.fragments.moveTo(this.absoluteLineStart+e,this.absoluteLineStart)||!this.fragments.matches(this.block.hash))return!1;let t=this.fragments.takeNodes(this);return t?(this.absoluteLineStart+=t,this.lineStart=Bn(this.absoluteLineStart,this.ranges),this.moveRangeI(),this.absoluteLineStart<this.to?(this.lineStart++,this.absoluteLineStart++,this.readLine()):(this.atEnd=!0,this.readLine()),!0):!1}get depth(){return this.stack.length}parentType(e=this.depth-1){return this.parser.nodeSet.types[this.stack[e].type]}nextLine(){return this.lineStart+=this.line.text.length,this.absoluteLineEnd>=this.to?(this.absoluteLineStart=this.absoluteLineEnd,this.atEnd=!0,this.readLine(),!1):(this.lineStart++,this.absoluteLineStart=this.absoluteLineEnd+1,this.moveRangeI(),this.readLine(),!0)}peekLine(){return this.scanLine(this.absoluteLineEnd+1).text}moveRangeI(){for(;this.rangeI<this.ranges.length-1&&this.absoluteLineStart>=this.ranges[this.rangeI].to;)this.rangeI++,this.absoluteLineStart=Math.max(this.absoluteLineStart,this.ranges[this.rangeI].from)}scanLine(e){let t=pn;if(t.end=e,e>=this.to)t.text=``;else if(t.text=this.lineChunkAt(e),t.end+=t.text.length,this.ranges.length>1){let e=this.absoluteLineStart,n=this.rangeI;for(;this.ranges[n].to<t.end;){n++;let r=this.ranges[n].from,i=this.lineChunkAt(r);t.end=r+i.length,t.text=t.text.slice(0,this.ranges[n-1].to-e)+i,e=t.end-t.text.length}}return t}readLine(){let{line:e}=this,{text:t,end:n}=this.scanLine(this.absoluteLineStart);for(this.absoluteLineEnd=n,e.reset(t);e.depth<this.stack.length;e.depth++){let t=this.stack[e.depth],n=this.parser.skipContextMarkup[t.type];if(!n)throw Error(`Unhandled block context `+P[t.type]);let r=this.line.markers.length;if(!n(t,this,e)){this.line.markers.length>r&&(t.end=this.line.markers[this.line.markers.length-1].to),e.forward();break}e.forward()}}lineChunkAt(e){let t=this.input.chunk(e),n;if(this.input.lineChunks)n=t==`
4
4
  `?``:t;else{let e=t.indexOf(`
@@ -26,7 +26,7 @@ import{r as e}from"./chunk-DECur_0Z.js";import{n as t,r as n,t as r}from"./compi
26
26
  }`,{label:`interface`,detail:`definition`,type:`keyword`}),M("type ${name} = ${type}",{label:`type`,detail:`definition`,type:`keyword`}),M(`enum \${name} {
27
27
  \${}
28
28
  }`,{label:`enum`,detail:`definition`,type:`keyword`})]),io=new ke,ao=new Set([`Script`,`Block`,`FunctionExpression`,`FunctionDeclaration`,`ArrowFunction`,`MethodDeclaration`,`ForStatement`]);function oo(e){return(t,n)=>{let r=t.node.getChild(`VariableDefinition`);return r&&n(r,e),!0}}var so=[`FunctionDeclaration`],co={FunctionDeclaration:oo(`function`),ClassDeclaration:oo(`class`),ClassExpression:()=>!0,EnumDeclaration:oo(`constant`),TypeAliasDeclaration:oo(`type`),NamespaceDeclaration:oo(`namespace`),VariableDefinition(e,t){e.matchContext(so)||t(e,`variable`)},TypeDefinition(e,t){t(e,`type`)},__proto__:null};function lo(e,t){let n=io.get(t);if(n)return n;let r=[],i=!0;function a(t,n){let i=e.sliceString(t.from,t.to);r.push({label:i,type:n})}return t.cursor(bt.IncludeAnonymous).iterate(t=>{if(i)i=!1;else if(t.name){let e=co[t.name];if(e&&e(t,a)||ao.has(t.name))return!1}else if(t.to-t.from>8192){for(let n of lo(e,t.node))r.push(n);return!1}}),io.set(t,r),r}var uo=/^[\w$\xa1-\uffff][\w$\d\xa1-\uffff]*$/,fo=[`TemplateString`,`String`,`RegExp`,`LineComment`,`BlockComment`,`VariableDefinition`,`TypeDefinition`,`Label`,`PropertyDefinition`,`PropertyName`,`PrivatePropertyDefinition`,`PrivatePropertyName`,`JSXText`,`JSXAttributeValue`,`JSXOpenTag`,`JSXCloseTag`,`JSXSelfClosingTag`,`.`,`?.`];function po(e){let t=T(e.state).resolveInner(e.pos,-1);if(fo.indexOf(t.name)>-1)return null;let n=t.name==`VariableName`||t.to-t.from<20&&uo.test(e.state.sliceDoc(t.from,t.to));if(!n&&!e.explicit)return null;let r=[];for(let n=t;n;n=n.parent)ao.has(n.name)&&(r=r.concat(lo(e.state.doc,n)));return{options:r,from:n?t.from:e.pos,validFor:uo}}var z=ct.define({name:`javascript`,parser:to.configure({props:[gt.add({IfStatement:pt({except:/^\s*({|else\b)/}),TryStatement:pt({except:/^\s*({|catch\b|finally\b)/}),LabeledStatement:Ke,SwitchBody:e=>{let t=e.textAfter,n=/^\s*\}/.test(t),r=/^\s*(case|default)\b/.test(t);return e.baseIndent+(n?0:r?1:2)*e.unit},Block:ot({closing:`}`}),ArrowFunction:e=>e.baseIndent+e.unit,"TemplateString BlockComment":()=>null,"Statement Property":pt({except:/^\s*{/}),JSXElement(e){let t=/^\s*<\//.test(e.textAfter);return e.lineIndent(e.node.from)+(t?0:e.unit)},JSXEscape(e){let t=/\s*\}/.test(e.textAfter);return e.lineIndent(e.node.from)+(t?0:e.unit)},"JSXOpenTag JSXSelfClosingTag"(e){return e.column(e.node.from)+e.unit}}),yt.add({"Block ClassBody SwitchBody EnumBody ObjectExpression ArrayExpression ObjectType":Pe,BlockComment(e){return{from:e.from+2,to:e.to-2}},JSXElement(e){let t=e.firstChild;if(!t||t.name==`JSXSelfClosingTag`)return null;let n=e.lastChild;return{from:t.to,to:n.type.isError?e.to:n.from}},"JSXSelfClosingTag JSXOpenTag"(e){let t=e.firstChild?.nextSibling,n=e.lastChild;return!t||t.type.isError?null:{from:t.to,to:n.type.isError?e.to:n.from}}})]}),languageData:{closeBrackets:{brackets:[`(`,`[`,`{`,`'`,`"`,"`"]},commentTokens:{line:`//`,block:{open:`/*`,close:`*/`}},indentOnInput:/^\s*(?:case |default:|\{|\}|<\/)$/,wordChars:`$`}}),mo={test:e=>/^JSX/.test(e.name),facet:Ue({commentTokens:{block:{open:`{/*`,close:`*/}`}}})},ho=z.configure({dialect:`ts`},`typescript`),go=z.configure({dialect:`jsx`,props:[Ye.add(e=>e.isTop?[mo]:void 0)]}),_o=z.configure({dialect:`jsx ts`,props:[Ye.add(e=>e.isTop?[mo]:void 0)]},`typescript`),vo=e=>({label:e,type:`keyword`}),yo=`break case const continue default delete export extends false finally in instanceof let new return static super switch this throw true typeof var yield`.split(` `).map(vo),bo=yo.concat([`declare`,`implements`,`private`,`protected`,`public`].map(vo));function xo(e={}){let t=e.jsx?e.typescript?_o:go:e.typescript?ho:z,n=e.typescript?ro.concat(bo):no.concat(yo);return new it(t,[z.data.of({autocomplete:Dt(fo,St(n))}),z.data.of({autocomplete:po}),e.jsx?To:[]])}function So(e){for(;;){if(e.name==`JSXOpenTag`||e.name==`JSXSelfClosingTag`||e.name==`JSXFragmentTag`)return e;if(e.name==`JSXEscape`||!e.parent)return null;e=e.parent}}function Co(e,t,n=e.length){for(let r=t?.firstChild;r;r=r.nextSibling)if(r.name==`JSXIdentifier`||r.name==`JSXBuiltin`||r.name==`JSXNamespacedName`||r.name==`JSXMemberExpression`)return e.sliceString(r.from,Math.min(r.to,n));return``}var wo=typeof navigator==`object`&&/Android\b/.test(navigator.userAgent),To=k.inputHandler.of((e,t,n,r,i)=>{if((wo?e.composing:e.compositionStarted)||e.state.readOnly||t!=n||r!=`>`&&r!=`/`||!z.isActiveAt(e.state,t,-1))return!1;let a=i(),{state:o}=a,s=o.changeByRange(e=>{let{head:t}=e,n=T(o).resolveInner(t-1,-1),i;if(n.name==`JSXStartTag`&&(n=n.parent),!(o.doc.sliceString(t-1,t)!=r||n.name==`JSXAttributeValue`&&n.to>t)){if(r==`>`&&n.name==`JSXFragmentTag`)return{range:e,changes:{from:t,insert:`</>`}};if(r==`/`&&n.name==`JSXStartCloseTag`){let e=n.parent,r=e.parent;if(r&&e.from==t-2&&((i=Co(o.doc,r.firstChild,t))||r.firstChild?.name==`JSXFragmentTag`)){let e=`${i}>`;return{range:O.cursor(t+e.length,-1),changes:{from:t,insert:e}}}}else if(r==`>`){let r=So(n);if(r&&r.name==`JSXOpenTag`&&!/^\/?>|^<\//.test(o.doc.sliceString(t,t+2))&&(i=Co(o.doc,r,t)))return{range:e,changes:{from:t,insert:`</${i}>`}}}}return{range:e}});return s.changes.empty?!1:(e.dispatch([a,o.update(s,{userEvent:`input.complete`,scrollIntoView:!0})]),!0)}),Eo=[`_blank`,`_self`,`_top`,`_parent`],Do=[`ascii`,`utf-8`,`utf-16`,`latin1`,`latin1`],Oo=[`get`,`post`,`put`,`delete`],ko=[`application/x-www-form-urlencoded`,`multipart/form-data`,`text/plain`],B=[`true`,`false`],V={},Ao={a:{attrs:{href:null,ping:null,type:null,media:null,target:Eo,hreflang:null}},abbr:V,address:V,area:{attrs:{alt:null,coords:null,href:null,target:null,ping:null,media:null,hreflang:null,type:null,shape:[`default`,`rect`,`circle`,`poly`]}},article:V,aside:V,audio:{attrs:{src:null,mediagroup:null,crossorigin:[`anonymous`,`use-credentials`],preload:[`none`,`metadata`,`auto`],autoplay:[`autoplay`],loop:[`loop`],controls:[`controls`]}},b:V,base:{attrs:{href:null,target:Eo}},bdi:V,bdo:V,blockquote:{attrs:{cite:null}},body:V,br:V,button:{attrs:{form:null,formaction:null,name:null,value:null,autofocus:[`autofocus`],disabled:[`autofocus`],formenctype:ko,formmethod:Oo,formnovalidate:[`novalidate`],formtarget:Eo,type:[`submit`,`reset`,`button`]}},canvas:{attrs:{width:null,height:null}},caption:V,center:V,cite:V,code:V,col:{attrs:{span:null}},colgroup:{attrs:{span:null}},command:{attrs:{type:[`command`,`checkbox`,`radio`],label:null,icon:null,radiogroup:null,command:null,title:null,disabled:[`disabled`],checked:[`checked`]}},data:{attrs:{value:null}},datagrid:{attrs:{disabled:[`disabled`],multiple:[`multiple`]}},datalist:{attrs:{data:null}},dd:V,del:{attrs:{cite:null,datetime:null}},details:{attrs:{open:[`open`]}},dfn:V,div:V,dl:V,dt:V,em:V,embed:{attrs:{src:null,type:null,width:null,height:null}},eventsource:{attrs:{src:null}},fieldset:{attrs:{disabled:[`disabled`],form:null,name:null}},figcaption:V,figure:V,footer:V,form:{attrs:{action:null,name:null,"accept-charset":Do,autocomplete:[`on`,`off`],enctype:ko,method:Oo,novalidate:[`novalidate`],target:Eo}},h1:V,h2:V,h3:V,h4:V,h5:V,h6:V,head:{children:[`title`,`base`,`link`,`style`,`meta`,`script`,`noscript`,`command`]},header:V,hgroup:V,hr:V,html:{attrs:{manifest:null}},i:V,iframe:{attrs:{src:null,srcdoc:null,name:null,width:null,height:null,sandbox:[`allow-top-navigation`,`allow-same-origin`,`allow-forms`,`allow-scripts`],seamless:[`seamless`]}},img:{attrs:{alt:null,src:null,ismap:null,usemap:null,width:null,height:null,crossorigin:[`anonymous`,`use-credentials`]}},input:{attrs:{alt:null,dirname:null,form:null,formaction:null,height:null,list:null,max:null,maxlength:null,min:null,name:null,pattern:null,placeholder:null,size:null,src:null,step:null,value:null,width:null,accept:[`audio/*`,`video/*`,`image/*`],autocomplete:[`on`,`off`],autofocus:[`autofocus`],checked:[`checked`],disabled:[`disabled`],formenctype:ko,formmethod:Oo,formnovalidate:[`novalidate`],formtarget:Eo,multiple:[`multiple`],readonly:[`readonly`],required:[`required`],type:[`hidden`,`text`,`search`,`tel`,`url`,`email`,`password`,`datetime`,`date`,`month`,`week`,`time`,`datetime-local`,`number`,`range`,`color`,`checkbox`,`radio`,`file`,`submit`,`image`,`reset`,`button`]}},ins:{attrs:{cite:null,datetime:null}},kbd:V,keygen:{attrs:{challenge:null,form:null,name:null,autofocus:[`autofocus`],disabled:[`disabled`],keytype:[`RSA`]}},label:{attrs:{for:null,form:null}},legend:V,li:{attrs:{value:null}},link:{attrs:{href:null,type:null,hreflang:null,media:null,sizes:[`all`,`16x16`,`16x16 32x32`,`16x16 32x32 64x64`]}},map:{attrs:{name:null}},mark:V,menu:{attrs:{label:null,type:[`list`,`context`,`toolbar`]}},meta:{attrs:{content:null,charset:Do,name:[`viewport`,`application-name`,`author`,`description`,`generator`,`keywords`],"http-equiv":[`content-language`,`content-type`,`default-style`,`refresh`]}},meter:{attrs:{value:null,min:null,low:null,high:null,max:null,optimum:null}},nav:V,noscript:V,object:{attrs:{data:null,type:null,name:null,usemap:null,form:null,width:null,height:null,typemustmatch:[`typemustmatch`]}},ol:{attrs:{reversed:[`reversed`],start:null,type:[`1`,`a`,`A`,`i`,`I`]},children:[`li`,`script`,`template`,`ul`,`ol`]},optgroup:{attrs:{disabled:[`disabled`],label:null}},option:{attrs:{disabled:[`disabled`],label:null,selected:[`selected`],value:null}},output:{attrs:{for:null,form:null,name:null}},p:V,param:{attrs:{name:null,value:null}},pre:V,progress:{attrs:{value:null,max:null}},q:{attrs:{cite:null}},rp:V,rt:V,ruby:V,samp:V,script:{attrs:{type:[`text/javascript`],src:null,async:[`async`],defer:[`defer`],charset:Do}},section:V,select:{attrs:{form:null,name:null,size:null,autofocus:[`autofocus`],disabled:[`disabled`],multiple:[`multiple`]}},slot:{attrs:{name:null}},small:V,source:{attrs:{src:null,type:null,media:null}},span:V,strong:V,style:{attrs:{type:[`text/css`],media:null,scoped:null}},sub:V,summary:V,sup:V,table:V,tbody:V,td:{attrs:{colspan:null,rowspan:null,headers:null}},template:V,textarea:{attrs:{dirname:null,form:null,maxlength:null,name:null,placeholder:null,rows:null,cols:null,autofocus:[`autofocus`],disabled:[`disabled`],readonly:[`readonly`],required:[`required`],wrap:[`soft`,`hard`]}},tfoot:V,th:{attrs:{colspan:null,rowspan:null,headers:null,scope:[`row`,`col`,`rowgroup`,`colgroup`]}},thead:V,time:{attrs:{datetime:null}},title:V,tr:V,track:{attrs:{src:null,label:null,default:null,kind:[`subtitles`,`captions`,`descriptions`,`chapters`,`metadata`],srclang:null}},ul:{children:[`li`,`script`,`template`,`ul`,`ol`]},var:V,video:{attrs:{src:null,poster:null,width:null,height:null,crossorigin:[`anonymous`,`use-credentials`],preload:[`auto`,`metadata`,`none`],autoplay:[`autoplay`],mediagroup:[`movie`],muted:[`muted`],controls:[`controls`]}},wbr:V},jo={accesskey:null,class:null,contenteditable:B,contextmenu:null,dir:[`ltr`,`rtl`,`auto`],draggable:[`true`,`false`,`auto`],dropzone:[`copy`,`move`,`link`,`string:`,`file:`],hidden:[`hidden`],id:null,inert:[`inert`],itemid:null,itemprop:null,itemref:null,itemscope:[`itemscope`],itemtype:null,lang:[`ar`,`bn`,`de`,`en-GB`,`en-US`,`es`,`fr`,`hi`,`id`,`ja`,`pa`,`pt`,`ru`,`tr`,`zh`],spellcheck:B,autocorrect:B,autocapitalize:B,style:null,tabindex:null,title:null,translate:[`yes`,`no`],rel:[`stylesheet`,`alternate`,`author`,`bookmark`,`help`,`license`,`next`,`nofollow`,`noreferrer`,`prefetch`,`prev`,`search`,`tag`],role:`alert application article banner button cell checkbox complementary contentinfo dialog document feed figure form grid gridcell heading img list listbox listitem main navigation region row rowgroup search switch tab table tabpanel textbox timer`.split(` `),"aria-activedescendant":null,"aria-atomic":B,"aria-autocomplete":[`inline`,`list`,`both`,`none`],"aria-busy":B,"aria-checked":[`true`,`false`,`mixed`,`undefined`],"aria-controls":null,"aria-describedby":null,"aria-disabled":B,"aria-dropeffect":null,"aria-expanded":[`true`,`false`,`undefined`],"aria-flowto":null,"aria-grabbed":[`true`,`false`,`undefined`],"aria-haspopup":B,"aria-hidden":B,"aria-invalid":[`true`,`false`,`grammar`,`spelling`],"aria-label":null,"aria-labelledby":null,"aria-level":null,"aria-live":[`off`,`polite`,`assertive`],"aria-multiline":B,"aria-multiselectable":B,"aria-owns":null,"aria-posinset":null,"aria-pressed":[`true`,`false`,`mixed`,`undefined`],"aria-readonly":B,"aria-relevant":null,"aria-required":B,"aria-selected":[`true`,`false`,`undefined`],"aria-setsize":null,"aria-sort":[`ascending`,`descending`,`none`,`other`],"aria-valuemax":null,"aria-valuemin":null,"aria-valuenow":null,"aria-valuetext":null},Mo=`beforeunload copy cut dragstart dragover dragleave dragenter dragend drag paste focus blur change click load mousedown mouseenter mouseleave mouseup keydown keyup resize scroll unload`.split(` `).map(e=>`on`+e);for(let e of Mo)jo[e]=null;var No=class{constructor(e,t){this.tags={...Ao,...e},this.globalAttrs={...jo,...t},this.allTags=Object.keys(this.tags),this.globalAttrNames=Object.keys(this.globalAttrs)}};No.default=new No;function Po(e,t,n=e.length){if(!t)return``;let r=t.firstChild,i=r&&r.getChild(`TagName`);return i?e.sliceString(i.from,Math.min(i.to,n)):``}function Fo(e,t=!1){for(;e;e=e.parent)if(e.name==`Element`)if(t)t=!1;else return e;return null}function Io(e,t,n){return n.tags[Po(e,Fo(t))]?.children||n.allTags}function Lo(e,t){let n=[];for(let r=Fo(t);r&&!r.type.isTop;r=Fo(r.parent)){let i=Po(e,r);if(i&&r.lastChild.name==`CloseTag`)break;i&&n.indexOf(i)<0&&(t.name==`EndTag`||t.from>=r.firstChild.to)&&n.push(i)}return n}var Ro=/^[:\-\.\w\u00b7-\uffff]*$/;function zo(e,t,n,r,i){let a=/\s*>/.test(e.sliceDoc(i,i+5))?``:`>`,o=Fo(n,n.name==`StartTag`||n.name==`TagName`);return{from:r,to:i,options:Io(e.doc,o,t).map(e=>({label:e,type:`type`})).concat(Lo(e.doc,n).map((e,t)=>({label:`/`+e,apply:`/`+e+a,type:`type`,boost:99-t}))),validFor:/^\/?[:\-\.\w\u00b7-\uffff]*$/}}function Bo(e,t,n,r){let i=/\s*>/.test(e.sliceDoc(r,r+5))?``:`>`;return{from:n,to:r,options:Lo(e.doc,t).map((e,t)=>({label:e,apply:e+i,type:`type`,boost:99-t})),validFor:Ro}}function Vo(e,t,n,r){let i=[],a=0;for(let r of Io(e.doc,n,t))i.push({label:`<`+r,type:`type`});for(let t of Lo(e.doc,n))i.push({label:`</`+t+`>`,type:`type`,boost:99-a++});return{from:r,to:r,options:i,validFor:/^<\/?[:\-\.\w\u00b7-\uffff]*$/}}function Ho(e,t,n,r,i){let a=Fo(n),o=a?t.tags[Po(e.doc,a)]:null,s=o&&o.attrs?Object.keys(o.attrs):[];return{from:r,to:i,options:(o&&o.globalAttrs===!1?s:s.length?s.concat(t.globalAttrNames):t.globalAttrNames).map(e=>({label:e,type:`property`})),validFor:Ro}}function Uo(e,t,n,r,i){let a=n.parent?.getChild(`AttributeName`),o=[],s;if(a){let c=e.sliceDoc(a.from,a.to),l=t.globalAttrs[c];if(!l){let r=Fo(n),i=r?t.tags[Po(e.doc,r)]:null;l=i?.attrs&&i.attrs[c]}if(l){let t=e.sliceDoc(r,i).toLowerCase(),n=`"`,a=`"`;/^['"]/.test(t)?(s=t[0]==`"`?/^[^"]*$/:/^[^']*$/,n=``,a=e.sliceDoc(i,i+1)==t[0]?``:t[0],t=t.slice(1),r++):s=/^[^\s<>='"]*$/;for(let e of l)o.push({label:e,apply:n+e+a,type:`constant`})}}return{from:r,to:i,options:o,validFor:s}}function Wo(e,t){let{state:n,pos:r}=t,i=T(n).resolveInner(r,-1),a=i.resolve(r);for(let e=r,t;a==i&&(t=i.childBefore(e));){let n=t.lastChild;if(!n||!n.type.isError||n.from<n.to)break;a=i=t,e=n.from}return i.name==`TagName`?i.parent&&/CloseTag$/.test(i.parent.name)?Bo(n,i,i.from,r):zo(n,e,i,i.from,r):i.name==`StartTag`||i.name==`IncompleteTag`?zo(n,e,i,r,r):i.name==`StartCloseTag`||i.name==`IncompleteCloseTag`?Bo(n,i,r,r):i.name==`OpenTag`||i.name==`SelfClosingTag`||i.name==`AttributeName`?Ho(n,e,i,i.name==`AttributeName`?i.from:r,r):i.name==`Is`||i.name==`AttributeValue`||i.name==`UnquotedAttributeValue`?Uo(n,e,i,i.name==`Is`?r:i.from,r):t.explicit&&(a.name==`Element`||a.name==`Text`||a.name==`Document`)?Vo(n,e,i,r):null}function Go(e){return Wo(No.default,e)}function Ko(e){let{extraTags:t,extraGlobalAttributes:n}=e,r=n||t?new No(t,n):No.default;return e=>Wo(r,e)}var qo=z.parser.configure({top:`SingleExpression`}),Jo=[{tag:`script`,attrs:e=>e.type==`text/typescript`||e.lang==`ts`,parser:ho.parser},{tag:`script`,attrs:e=>e.type==`text/babel`||e.type==`text/jsx`,parser:go.parser},{tag:`script`,attrs:e=>e.type==`text/typescript-jsx`,parser:_o.parser},{tag:`script`,attrs(e){return/^(importmap|speculationrules|application\/(.+\+)?json)$/i.test(e.type)},parser:qo},{tag:`script`,attrs(e){return!e.type||/^(?:text|application)\/(?:x-)?(?:java|ecma)script$|^module$|^$/i.test(e.type)},parser:z.parser},{tag:`style`,attrs(e){return(!e.lang||e.lang==`css`)&&(!e.type||/^(text\/)?(x-)?(stylesheet|css)$/i.test(e.type))},parser:va.parser}],Yo=[{name:`style`,parser:va.parser.configure({top:`Styles`})}].concat(Mo.map(e=>({name:e,parser:z.parser}))),Xo=ct.define({name:`html`,parser:vi.configure({props:[gt.add({Element(e){let t=/^(\s*)(<\/)?/.exec(e.textAfter);return e.node.to<=e.pos+t[0].length?e.continue():e.lineIndent(e.node.from)+(t[2]?0:e.unit)},"OpenTag CloseTag SelfClosingTag"(e){return e.column(e.node.from)+e.unit},Document(e){if(e.pos+/\s*/.exec(e.textAfter)[0].length<e.node.to)return e.continue();let t=null,n;for(let n=e.node;;){let e=n.lastChild;if(!e||e.name!=`Element`||e.to!=n.to)break;t=n=e}return t&&!((n=t.lastChild)&&(n.name==`CloseTag`||n.name==`SelfClosingTag`))?e.lineIndent(t.from)+e.unit:null}}),yt.add({Element(e){let t=e.firstChild,n=e.lastChild;return!t||t.name!=`OpenTag`?null:{from:t.to,to:n.name==`CloseTag`?n.from:e.to}}}),$e.add({"OpenTag CloseTag":e=>e.getChild(`TagName`)})]}),languageData:{commentTokens:{block:{open:`<!--`,close:`-->`}},indentOnInput:/^\s*<\/\w+\W$/,wordChars:`-_`}}),Zo=Xo.configure({wrap:Si(Jo,Yo)});function Qo(e={}){let t=``,n;return e.matchClosingTags===!1&&(t=`noMatch`),e.selfClosingTags===!0&&(t=(t?t+` `:``)+`selfClosing`),(e.nestedLanguages&&e.nestedLanguages.length||e.nestedAttributes&&e.nestedAttributes.length)&&(n=Si((e.nestedLanguages||[]).concat(Jo),(e.nestedAttributes||[]).concat(Yo))),new it(n?Xo.configure({wrap:n,dialect:t}):t?Zo.configure({dialect:t}):Zo,[Zo.data.of({autocomplete:Ko(e)}),e.autoCloseTags===!1?[]:es,xo().support,ya().support])}var $o=new Set(`area base br col command embed frame hr img input keygen link meta param source track wbr menuitem`.split(` `)),es=k.inputHandler.of((e,t,n,r,i)=>{if(e.composing||e.state.readOnly||t!=n||r!=`>`&&r!=`/`||!Zo.isActiveAt(e.state,t,-1))return!1;let a=i(),{state:o}=a,s=o.changeByRange(e=>{let t=o.doc.sliceString(e.from-1,e.to)==r,{head:n}=e,i=T(o).resolveInner(n,-1),a;if(t&&r==`>`&&i.name==`EndTag`){let t=i.parent;if(t.parent?.lastChild?.name!=`CloseTag`&&(a=Po(o.doc,t.parent,n))&&!$o.has(a))return{range:e,changes:{from:n,to:n+ +(o.doc.sliceString(n,n+1)===`>`),insert:`</${a}>`}}}else if(t&&r==`/`&&i.name==`IncompleteCloseTag`){let e=i.parent;if(i.from==n-2&&e.lastChild?.name!=`CloseTag`&&(a=Po(o.doc,e,n))&&!$o.has(a)){let e=n+ +(o.doc.sliceString(n,n+1)===`>`),t=`${a}>`;return{range:O.cursor(n+t.length,-1),changes:{from:n,to:e,insert:t}}}}return{range:e}});return s.changes.empty?!1:(e.dispatch([a,o.update(s,{userEvent:`input.complete`,scrollIntoView:!0})]),!0)}),ts=Ue({commentTokens:{block:{open:`<!--`,close:`-->`}}}),ns=new _,rs=Hn.configure({props:[yt.add(e=>!e.is(`Block`)||e.is(`Document`)||is(e)!=null||as(e)?void 0:(e,t)=>({from:t.doc.lineAt(e.from).to,to:e.to})),ns.add(is),gt.add({Document:()=>null}),Ze.add({Document:ts})]});function is(e){let t=/^(?:ATX|Setext)Heading(\d)$/.exec(e.name);return t?+t[1]:void 0}function as(e){return e.name==`OrderedList`||e.name==`BulletList`}function os(e,t){let n=e;for(;;){let e=n.nextSibling,r;if(!e||(r=is(e.type))!=null&&r<=t)break;n=e}return n.to}var ss=Le.of((e,t,n)=>{for(let r=T(e).resolveInner(n,-1);r&&!(r.from<t);r=r.parent){let e=r.type.prop(ns);if(e==null)continue;let t=os(r,e);if(t>n)return{from:n,to:t}}return null});function cs(e){return new Je(ts,e,[],`markdown`)}var ls=cs(rs),us=cs(rs.configure([cr,dr,ur,fr,{props:[yt.add({Table:(e,t)=>({from:t.doc.lineAt(e.from).to,to:e.to})})]}]));function ds(e,t){return n=>{if(n&&e){let t=null;if(n=/\S*/.exec(n)[0],t=typeof e==`function`?e(n):Fe.matchLanguageName(e,n,!0),t instanceof Fe)return t.support?t.support.language.parser:lt.getSkippingParser(t.load());if(t)return t.parser}return t?t.parser:null}}var fs=class{constructor(e,t,n,r,i,a,o){this.node=e,this.from=t,this.to=n,this.spaceBefore=r,this.spaceAfter=i,this.type=a,this.item=o}blank(e,t=!0){let n=this.spaceBefore+(this.node.name==`Blockquote`?`>`:``);if(e!=null){for(;n.length<e;)n+=` `;return n}else{for(let e=this.to-this.from-n.length-this.spaceAfter.length;e>0;e--)n+=` `;return n+(t?this.spaceAfter:``)}}marker(e,t){let n=this.node.name==`OrderedList`?String(+ms(this.item,e)[2]+t):``;return this.spaceBefore+n+this.type+this.spaceAfter}};function ps(e,t){let n=[],r=[];for(let t=e;t;t=t.parent){if(t.name==`FencedCode`)return r;(t.name==`ListItem`||t.name==`Blockquote`)&&n.push(t)}for(let e=n.length-1;e>=0;e--){let i=n[e],a,o=t.lineAt(i.from),s=i.from-o.from;if(i.name==`Blockquote`&&(a=/^ *>( ?)/.exec(o.text.slice(s))))r.push(new fs(i,s,s+a[0].length,``,a[1],`>`,null));else if(i.name==`ListItem`&&i.parent.name==`OrderedList`&&(a=/^( *)\d+([.)])( *)/.exec(o.text.slice(s)))){let e=a[3],t=a[0].length;e.length>=4&&(e=e.slice(0,e.length-4),t-=4),r.push(new fs(i.parent,s,s+t,a[1],e,a[2],i))}else if(i.name==`ListItem`&&i.parent.name==`BulletList`&&(a=/^( *)([-+*])( {1,4}\[[ xX]\])?( +)/.exec(o.text.slice(s)))){let e=a[4],t=a[0].length;e.length>4&&(e=e.slice(0,e.length-4),t-=4);let n=a[2];a[3]&&(n+=a[3].replace(/[xX]/,` `)),r.push(new fs(i.parent,s,s+t,a[1],e,n,i))}}return r}function ms(e,t){return/^(\s*)(\d+)(?=[.)])/.exec(t.sliceString(e.from,e.from+10))}function hs(e,t,n,r=0){for(let i=-1,a=e;;){if(a.name==`ListItem`){let e=ms(a,t),o=+e[2];if(i>=0){if(o!=i+1)return;n.push({from:a.from+e[1].length,to:a.from+e[0].length,insert:String(i+2+r)})}i=o}let e=a.nextSibling;if(!e)break;a=e}}function gs(e,t){let n=/^[ \t]*/.exec(e)[0].length;if(!n||t.facet(pe)!=` `)return e;let r=v(e,4,n),i=``;for(let e=r;e>0;)e>=4?(i+=` `,e-=4):(i+=` `,e--);return i+e.slice(n)}var _s=((e={})=>({state:t,dispatch:n})=>{let r=T(t),{doc:i}=t,a=null,o=t.changeByRange(n=>{if(!n.empty||!us.isActiveAt(t,n.from,-1)&&!us.isActiveAt(t,n.from,1))return a={range:n};let o=n.from,s=i.lineAt(o),c=ps(r.resolveInner(o,-1),i);for(;c.length&&c[c.length-1].from>o-s.from;)c.pop();if(!c.length)return a={range:n};let l=c[c.length-1];if(l.to-l.spaceAfter.length>o-s.from)return a={range:n};let u=o>=l.to-l.spaceAfter.length&&!/\S/.test(s.text.slice(l.to));if(l.item&&u){let n=l.node.firstChild,r=l.node.getChild(`ListItem`,`ListItem`);if(n.to>=o||r&&r.to<o||s.from>0&&!/[^\s>]/.test(i.lineAt(s.from-1).text)||e.nonTightLists===!1){let e=c.length>1?c[c.length-2]:null,t,n=``;e&&e.item?(t=s.from+e.from,n=e.marker(i,1)):t=s.from+(e?e.to:0);let r=[{from:t,to:o,insert:n}];return l.node.name==`OrderedList`&&hs(l.item,i,r,-2),e&&e.node.name==`OrderedList`&&hs(e.item,i,r),{range:O.cursor(t+n.length),changes:r}}else{let e=bs(c,t,s);return{range:O.cursor(o+e.length+1),changes:{from:s.from,insert:e+t.lineBreak}}}}if(l.node.name==`Blockquote`&&u&&s.from){let e=i.lineAt(s.from-1),r=/>\s*$/.exec(e.text);if(r&&r.index==l.from){let i=t.changes([{from:e.from+r.index,to:e.to},{from:s.from+l.from,to:s.to}]);return{range:n.map(i),changes:i}}}let d=[];l.node.name==`OrderedList`&&hs(l.item,i,d);let f=l.item&&l.item.from<s.from,p=``;if(!f||/^[\s\d.)\-+*>]*/.exec(s.text)[0].length>=l.to)for(let e=0,t=c.length-1;e<=t;e++)p+=e==t&&!f?c[e].marker(i,1):c[e].blank(e<t?v(s.text,4,c[e+1].from)-p.length:null);let m=o;for(;m>s.from&&/\s/.test(s.text.charAt(m-s.from-1));)m--;return p=gs(p,t),ys(l.node,t.doc)&&(p=bs(c,t,s)+t.lineBreak+p),d.push({from:m,to:o,insert:t.lineBreak+p}),{range:O.cursor(m+p.length+1),changes:d}});return a?!1:(n(t.update(o,{scrollIntoView:!0,userEvent:`input`})),!0)})();function vs(e){return e.name==`QuoteMark`||e.name==`ListMark`}function ys(e,t){if(e.name!=`OrderedList`&&e.name!=`BulletList`)return!1;let n=e.firstChild,r=e.getChild(`ListItem`,`ListItem`);if(!r)return!1;let i=t.lineAt(n.to),a=t.lineAt(r.from),o=/^[\s>]*$/.test(i.text);return i.number+ +!o<a.number}function bs(e,t,n){let r=``;for(let t=0,i=e.length-2;t<=i;t++)r+=e[t].blank(t<i?v(n.text,4,e[t+1].from)-r.length:null,t<i);return gs(r,t)}function xs(e,t){let n=e.resolveInner(t,-1),r=t;vs(n)&&(r=n.from,n=n.parent);for(let e;e=n.childBefore(r);)if(vs(e))r=e.from;else if(e.name==`OrderedList`||e.name==`BulletList`)n=e.lastChild,r=n.to;else break;return n}var Ss=[{key:`Enter`,run:_s},{key:`Backspace`,run:({state:e,dispatch:t})=>{let n=T(e),r=null,i=e.changeByRange(t=>{let i=t.from,{doc:a}=e;if(t.empty&&us.isActiveAt(e,t.from)){let t=a.lineAt(i),r=ps(xs(n,i),a);if(r.length){let n=r[r.length-1],a=n.to-n.spaceAfter.length+ +!!n.spaceAfter;if(i-t.from>a&&!/\S/.test(t.text.slice(a,i-t.from)))return{range:O.cursor(t.from+a),changes:{from:t.from+a,to:i}};if(i-t.from==a&&(!n.item||t.from<=n.item.from||!/\S/.test(t.text.slice(0,n.to)))){let r=t.from+n.from;if(n.item&&n.node.from<n.item.from&&/\S/.test(t.text.slice(n.from,n.to))){let i=n.blank(v(t.text,4,n.to)-v(t.text,4,n.from));return r==t.from&&(i=gs(i,e)),{range:O.cursor(r+i.length),changes:{from:r,to:t.from+n.to,insert:i}}}if(r<i)return{range:O.cursor(r),changes:{from:r,to:i}}}}}return r={range:t}});return r?!1:(t(e.update(i,{scrollIntoView:!0,userEvent:`delete`})),!0)}}],Cs=Qo({matchClosingTags:!1});function ws(e={}){let{codeLanguages:t,defaultCodeLanguage:n,addKeymap:r=!0,base:{parser:i}=ls,completeHTMLTags:a=!0,pasteURLAsLink:o=!0,htmlTagLanguage:s=Cs}=e;if(!(i instanceof gn))throw RangeError("Base parser provided to `markdown` should be a Markdown parser");let c=e.extensions?[e.extensions]:[],l=[s.support,ss],u;o&&l.push(ks),n instanceof it?(l.push(n.support),u=n.language):n&&(u=n);let d=t||u?ds(t,u):void 0;c.push(Wn({codeParser:d,htmlParser:s.language.parser})),r&&l.push(Qe.high(et.of(Ss)));let f=cs(i.configure(c));return a&&l.push(f.data.of({autocomplete:Ts})),new it(f,l)}function Ts(e){let{state:t,pos:n}=e,r=/<[:\-\.\w\u00b7-\uffff]*$/.exec(t.sliceDoc(n-25,n));if(!r)return null;let i=T(t).resolveInner(n,-1);for(;i&&!i.type.isTop;){if(i.name==`CodeBlock`||i.name==`FencedCode`||i.name==`ProcessingInstructionBlock`||i.name==`CommentBlock`||i.name==`Link`||i.name==`Image`)return null;i=i.parent}return{from:n-r[0].length,to:n,options:Ds(),validFor:/^<[:\-\.\w\u00b7-\uffff]*$/}}var Es=null;function Ds(){if(Es)return Es;let e=Go(new Ot(me.create({extensions:Cs}),0,!0));return Es=e?e.options:[]}var Os=/code|horizontalrule|html|link|comment|processing|escape|entity|image|mark|url/i,ks=k.domEventHandlers({paste:(e,t)=>{let{main:n}=t.state.selection;if(n.empty)return!1;let r=e.clipboardData?.getData(`text/plain`);if(!r||!/^(https?:\/\/|mailto:|xmpp:|www\.)/.test(r)||(/^www\./.test(r)&&(r=`https://`+r),!us.isActiveAt(t.state,n.from,1)))return!1;let i=T(t.state),a=!1;return i.iterate({from:n.from,to:n.to,enter:e=>{(e.from>n.from||Os.test(e.name))&&(a=!0)},leave:e=>{e.to<n.to&&(a=!0)}}),a?!1:(t.dispatch({changes:[{from:n.from,insert:`[`},{from:n.to,insert:`](${r})`}],userEvent:`input.paste`,scrollIntoView:!0}),!0)}});function As(){return As=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},As.apply(null,arguments)}var js=e=>{var{theme:t,settings:n={},styles:r=[]}=e,i={".cm-gutters":{}},a={};n.background&&(a.backgroundColor=n.background),n.backgroundImage&&(a.backgroundImage=n.backgroundImage),n.foreground&&(a.color=n.foreground),n.fontSize&&(a.fontSize=n.fontSize),(n.background||n.foreground)&&(i[`&`]=a),n.fontFamily&&(i[`&.cm-editor .cm-scroller`]={fontFamily:n.fontFamily}),n.gutterBackground&&(i[`.cm-gutters`].backgroundColor=n.gutterBackground),n.gutterForeground&&(i[`.cm-gutters`].color=n.gutterForeground),n.gutterBorder&&(i[`.cm-gutters`].borderRightColor=n.gutterBorder),n.caret&&(i[`.cm-content`]={caretColor:n.caret},i[`.cm-cursor, .cm-dropCursor`]={borderLeftColor:n.caret});var o={};return n.gutterActiveForeground&&(o.color=n.gutterActiveForeground),n.lineHighlight&&(i[`.cm-activeLine`]={backgroundColor:n.lineHighlight},o.backgroundColor=n.lineHighlight),i[`.cm-activeLineGutter`]=o,n.selection&&(i[`&.cm-focused .cm-selectionBackground, & .cm-line::selection, & .cm-selectionLayer .cm-selectionBackground, .cm-content ::selection`]={background:n.selection+` !important`}),n.selectionMatch&&(i[`& .cm-selectionMatch`]={backgroundColor:n.selectionMatch}),[k.theme(i,{dark:t===`dark`}),Se(dt.define(r))]},Ms={background:`#2E3235`,foreground:`#DDDDDD`,caret:`#DDDDDD`,selection:`#202325`,selectionMatch:`#202325`,gutterBackground:`#292d30`,gutterForeground:`#808080`,gutterBorder:`1px solid #ffffff10`,lineHighlight:`#B9D2FF30`},Ns=[{tag:w.keyword,color:`#fda331`},{tag:[w.name,w.deleted,w.character,w.propertyName,w.macroName],color:`#b5bd68`},{tag:[w.variableName],color:`#6fb3d2`},{tag:[w.function(w.variableName)],color:`#fda331`},{tag:[w.labelName],color:`#fc6d24`},{tag:[w.color,w.constant(w.name),w.standard(w.name)],color:`#fda331`},{tag:[w.definition(w.name),w.separator],color:`#cc99cc`},{tag:[w.brace],color:`#cc99cc`},{tag:[w.annotation],color:`#fc6d24`},{tag:[w.number,w.changed,w.annotation,w.modifier,w.self,w.namespace],color:`#fda331`},{tag:[w.typeName,w.className],color:`#6fb3d2`},{tag:[w.operator,w.operatorKeyword],color:`#cc99cc`},{tag:[w.tagName],color:`#fda331`},{tag:[w.squareBracket],color:`#cc99cc`},{tag:[w.angleBracket],color:`#cc99cc`},{tag:[w.attributeName],color:`#6fb3d2`},{tag:[w.regexp],color:`#fda331`},{tag:[w.quote],color:`#DDDDDD`},{tag:[w.string],color:`#b5bd68`},{tag:w.link,color:`#6987AF`,textDecoration:`underline`,textUnderlinePosition:`under`},{tag:[w.url,w.escape,w.special(w.string)],color:`#8abeb7`},{tag:[w.meta],color:`#A54543`},{tag:[w.comment],color:`#808080`,fontStyle:`italic`},{tag:w.monospace,color:`#DDDDDD`},{tag:w.strong,fontWeight:`bold`,color:`#fda331`},{tag:w.emphasis,fontStyle:`italic`,color:`#6fb3d2`},{tag:w.strikethrough,textDecoration:`line-through`},{tag:w.heading,fontWeight:`bold`,color:`#DDDDDD`},{tag:w.special(w.heading1),fontWeight:`bold`,color:`#DDDDDD`},{tag:w.heading1,fontWeight:`bold`,color:`#DDDDDD`},{tag:[w.heading2,w.heading3,w.heading4],fontWeight:`bold`,color:`#DDDDDD`},{tag:[w.heading5,w.heading6],color:`#DDDDDD`},{tag:[w.atom,w.bool,w.special(w.variableName)],color:`#8abeb7`},{tag:[w.processingInstruction,w.inserted],color:`#8abeb7`},{tag:[w.contentSeparator],color:`#6fb3d2`},{tag:w.invalid,color:`#B9D2FF`,borderBottom:`1px dotted #fc6d24`}],Ps=e=>{var{theme:t=`dark`,settings:n={},styles:r=[]}=e||{};return js({theme:t,settings:As({},Ms,n),styles:[...Ns,...r]})};Ps();var Fs={background:`#ffffff`,foreground:`#2e3440`,caret:`#3b4252`,selection:`#eceff4`,selectionMatch:`#e5e9f0`,gutterBackground:`#eceff4`,gutterForeground:`#2e3440`,gutterBorder:`none`,lineHighlight:`#02255f11`},Is=[{tag:w.keyword,color:`#5e81ac`},{tag:[w.name,w.deleted,w.character,w.propertyName,w.macroName],color:`#d08770`},{tag:[w.variableName],color:`#d08770`},{tag:[w.function(w.variableName)],color:`#5e81ac`},{tag:[w.labelName],color:`#81a1c1`},{tag:[w.color,w.constant(w.name),w.standard(w.name)],color:`#5e81ac`},{tag:[w.definition(w.name),w.separator],color:`#a3be8c`},{tag:[w.brace],color:`#8fbcbb`},{tag:[w.annotation],color:`#d30102`},{tag:[w.number,w.changed,w.annotation,w.modifier,w.self,w.namespace],color:`#88c0d0`},{tag:[w.typeName,w.className],color:`#ebcb8b`},{tag:[w.operator,w.operatorKeyword],color:`#a3be8c`},{tag:[w.tagName],color:`#b48ead`},{tag:[w.squareBracket],color:`#bf616a`},{tag:[w.angleBracket],color:`#d08770`},{tag:[w.attributeName],color:`#ebcb8b`},{tag:[w.regexp],color:`#5e81ac`},{tag:[w.quote],color:`#3b4252`},{tag:[w.string],color:`#d08770`},{tag:w.link,color:`#8fbcbb`,textDecoration:`underline`,textUnderlinePosition:`under`},{tag:[w.url,w.escape,w.special(w.string)],color:`#d08770`},{tag:[w.meta],color:`#88c0d0`},{tag:[w.comment],color:`#434c5e`,fontStyle:`italic`},{tag:w.strong,fontWeight:`bold`,color:`#5e81ac`},{tag:w.emphasis,fontStyle:`italic`,color:`#5e81ac`},{tag:w.strikethrough,textDecoration:`line-through`},{tag:w.heading,fontWeight:`bold`,color:`#5e81ac`},{tag:w.special(w.heading1),fontWeight:`bold`,color:`#5e81ac`},{tag:w.heading1,fontWeight:`bold`,color:`#5e81ac`},{tag:[w.heading2,w.heading3,w.heading4],fontWeight:`bold`,color:`#5e81ac`},{tag:[w.heading5,w.heading6],color:`#5e81ac`},{tag:[w.atom,w.bool,w.special(w.variableName)],color:`#d08770`},{tag:[w.processingInstruction,w.inserted],color:`#8fbcbb`},{tag:[w.contentSeparator],color:`#ebcb8b`},{tag:w.invalid,color:`#434c5e`,borderBottom:`1px dotted #d30102`}],Ls=e=>{var{theme:t=`light`,settings:n={},styles:r=[]}=e||{};return js({theme:t,settings:As({},Fs,n),styles:[...Is,...r]})};Ls();var Rs=e=>{let{state:t}=e,n=t.doc.lineAt(t.selection.main.from),r=Us(e.state,n.from);return r.line?Bs(e):r.block?Hs(e):!1};function zs(e,t){return({state:n,dispatch:r})=>{if(n.readOnly)return!1;let i=e(t,n);return i?(r(n.update(i)),!0):!1}}var Bs=zs(Js,0),Vs=zs(qs,0),Hs=zs((e,t)=>qs(e,t,Ks(t)),0);function Us(e,t){let n=e.languageDataAt(`commentTokens`,t,1);return n.length?n[0]:{}}var Ws=50;function Gs(e,{open:t,close:n},r,i){let a=e.sliceDoc(r-Ws,r),o=e.sliceDoc(i,i+Ws),s=/\s*$/.exec(a)[0].length,c=/^\s*/.exec(o)[0].length,l=a.length-s;if(a.slice(l-t.length,l)==t&&o.slice(c,c+n.length)==n)return{open:{pos:r-s,margin:s&&1},close:{pos:i+c,margin:c&&1}};let u,d;i-r<=2*Ws?u=d=e.sliceDoc(r,i):(u=e.sliceDoc(r,r+Ws),d=e.sliceDoc(i-Ws,i));let f=/^\s*/.exec(u)[0].length,p=/\s*$/.exec(d)[0].length,m=d.length-p-n.length;return u.slice(f,f+t.length)==t&&d.slice(m,m+n.length)==n?{open:{pos:r+f+t.length,margin:+!!/\s/.test(u.charAt(f+t.length))},close:{pos:i-p-n.length,margin:+!!/\s/.test(d.charAt(m-1))}}:null}function Ks(e){let t=[];for(let n of e.selection.ranges){let r=e.doc.lineAt(n.from),i=n.to<=r.to?r:e.doc.lineAt(n.to);i.from>r.from&&i.from==n.to&&(i=n.to==r.to+1?r:e.doc.lineAt(n.to-1));let a=t.length-1;a>=0&&t[a].to>r.from?t[a].to=i.to:t.push({from:r.from+/^\s*/.exec(r.text)[0].length,to:i.to})}return t}function qs(e,t,n=t.selection.ranges){let r=n.map(e=>Us(t,e.from).block);if(!r.every(e=>e))return null;let i=n.map((e,n)=>Gs(t,r[n],e.from,e.to));if(e!=2&&!i.every(e=>e))return{changes:t.changes(n.map((e,t)=>i[t]?[]:[{from:e.from,insert:r[t].open+` `},{from:e.to,insert:` `+r[t].close}]))};if(e!=1&&i.some(e=>e)){let e=[];for(let t=0,n;t<i.length;t++)if(n=i[t]){let i=r[t],{open:a,close:o}=n;e.push({from:a.pos-i.open.length,to:a.pos+a.margin},{from:o.pos-o.margin,to:o.pos+i.close.length})}return{changes:e}}return null}function Js(e,t,n=t.selection.ranges){let r=[],i=-1;ranges:for(let{from:e,to:a}of n){let n=r.length,o=1e9,s;for(let n=e;n<=a;){let c=t.doc.lineAt(n);if(s==null&&(s=Us(t,c.from).line,!s))continue ranges;if(c.from>i&&(e==a||a>c.from)){i=c.from;let e=/^\s*/.exec(c.text)[0].length,t=e==c.length,n=c.text.slice(e,e+s.length)==s?e:-1;e<c.text.length&&e<o&&(o=e),r.push({line:c,comment:n,token:s,indent:e,empty:t,single:!1})}n=c.to+1}if(o<1e9)for(let e=n;e<r.length;e++)r[e].indent<r[e].line.text.length&&(r[e].indent=o);r.length==n+1&&(r[n].single=!0)}if(e!=2&&r.some(e=>e.comment<0&&(!e.empty||e.single))){let e=[];for(let{line:t,token:n,indent:i,empty:a,single:o}of r)(o||!a)&&e.push({from:t.from+i,insert:n+` `});let n=t.changes(e);return{changes:n,selection:t.selection.map(n,1)}}else if(e!=1&&r.some(e=>e.comment>=0)){let e=[];for(let{line:t,comment:n,token:i}of r)if(n>=0){let r=t.from+n,a=r+i.length;t.text[a-t.from]==` `&&a++,e.push({from:r,to:a})}return{changes:e}}return null}var Ys=Re.define(),Xs=Re.define(),Zs=b.define(),Qs=b.define({combine(e){return xt(e,{minDepth:100,newGroupDelay:500,joinToEvent:(e,t)=>t},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,t)=>(n,r)=>e(n,r)||t(n,r)})}}),$s=D.define({create(){return _c.empty},update(e,t){let n=t.state.facet(Qs),r=t.annotation(Ys);if(r){let i=oc.fromTransaction(t,r.selection),a=r.side,o=a==0?e.undone:e.done;return o=i?sc(o,o.length,n.minDepth,i):fc(o,t.startState.selection),new _c(a==0?r.rest:o,a==0?o:r.rest)}let i=t.annotation(Xs);if((i==`full`||i==`before`)&&(e=e.isolate()),t.annotation(ve.addToHistory)===!1)return t.changes.empty?e:e.addMapping(t.changes.desc);let a=oc.fromTransaction(t),o=t.annotation(ve.time),s=t.annotation(ve.userEvent);return a?e=e.addChanges(a,o,s,n,t):t.selection&&(e=e.addSelection(t.startState.selection,o,s,n.newGroupDelay)),(i==`full`||i==`after`)&&(e=e.isolate()),e},toJSON(e){return{done:e.done.map(e=>e.toJSON()),undone:e.undone.map(e=>e.toJSON())}},fromJSON(e){return new _c(e.done.map(oc.fromJSON),e.undone.map(oc.fromJSON))}});function ec(e={}){return[$s,Qs.of(e),k.domEventHandlers({beforeinput(e,t){let n=e.inputType==`historyUndo`?nc:e.inputType==`historyRedo`?rc:null;return n?(e.preventDefault(),n(t)):!1}})]}function tc(e,t){return function({state:n,dispatch:r}){if(!t&&n.readOnly)return!1;let i=n.field($s,!1);if(!i)return!1;let a=i.pop(e,n,t);return a?(r(a),!0):!1}}var nc=tc(0,!1),rc=tc(1,!1),ic=tc(0,!0),ac=tc(1,!0),oc=class e{constructor(e,t,n,r,i){this.changes=e,this.effects=t,this.mapped=n,this.startSelection=r,this.selectionsAfter=i}setSelAfter(t){return new e(this.changes,this.effects,this.mapped,this.startSelection,t)}toJSON(){return{changes:this.changes?.toJSON(),mapped:this.mapped?.toJSON(),startSelection:this.startSelection?.toJSON(),selectionsAfter:this.selectionsAfter.map(e=>e.toJSON())}}static fromJSON(t){return new e(t.changes&&De.fromJSON(t.changes),[],t.mapped&&vt.fromJSON(t.mapped),t.startSelection&&O.fromJSON(t.startSelection),t.selectionsAfter.map(O.fromJSON))}static fromTransaction(t,n){let r=H;for(let e of t.startState.facet(Zs)){let n=e(t);n.length&&(r=r.concat(n))}return!r.length&&t.changes.empty?null:new e(t.changes.invert(t.startState.doc),r,void 0,n||t.startState.selection,H)}static selection(t){return new e(void 0,H,void 0,void 0,t)}};function sc(e,t,n,r){let i=t+1>n+20?t-n-1:0,a=e.slice(i,t);return a.push(r),a}function cc(e,t){let n=[],r=!1;return e.iterChangedRanges((e,t)=>n.push(e,t)),t.iterChangedRanges((e,t,i,a)=>{for(let e=0;e<n.length;){let t=n[e++],o=n[e++];a>=t&&i<=o&&(r=!0)}}),r}function lc(e,t){return e.ranges.length==t.ranges.length&&e.ranges.filter((e,n)=>e.empty!=t.ranges[n].empty).length===0}function uc(e,t){return e.length?t.length?e.concat(t):e:t}var H=[],dc=200;function fc(e,t){if(e.length){let n=e[e.length-1],r=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-dc));return r.length&&r[r.length-1].eq(t)?e:(r.push(t),sc(e,e.length-1,1e9,n.setSelAfter(r)))}else return[oc.selection([t])]}function pc(e){let t=e[e.length-1],n=e.slice();return n[e.length-1]=t.setSelAfter(t.selectionsAfter.slice(0,t.selectionsAfter.length-1)),n}function mc(e,t){if(!e.length)return e;let n=e.length,r=H;for(;n;){let i=hc(e[n-1],t,r);if(i.changes&&!i.changes.empty||i.effects.length){let t=e.slice(0,n);return t[n-1]=i,t}else t=i.mapped,n--,r=i.selectionsAfter}return r.length?[oc.selection(r)]:H}function hc(e,t,n){let r=uc(e.selectionsAfter.length?e.selectionsAfter.map(e=>e.map(t)):H,n);if(!e.changes)return oc.selection(r);let i=e.changes.map(t),a=t.mapDesc(e.changes,!0),o=e.mapped?e.mapped.composeDesc(a):a;return new oc(i,E.mapEffects(e.effects,t),o,e.startSelection.map(a),r)}var gc=/^(input\.type|delete)($|\.)/,_c=class e{constructor(e,t,n=0,r=void 0){this.done=e,this.undone=t,this.prevTime=n,this.prevUserEvent=r}isolate(){return this.prevTime?new e(this.done,this.undone):this}addChanges(t,n,r,i,a){let o=this.done,s=o[o.length-1];return o=s&&s.changes&&!s.changes.empty&&t.changes&&(!r||gc.test(r))&&(!s.selectionsAfter.length&&n-this.prevTime<i.newGroupDelay&&i.joinToEvent(a,cc(s.changes,t.changes))||r==`input.type.compose`)?sc(o,o.length-1,i.minDepth,new oc(t.changes.compose(s.changes),uc(E.mapEffects(t.effects,s.changes),s.effects),s.mapped,s.startSelection,H)):sc(o,o.length,i.minDepth,t),new e(o,H,n,r)}addSelection(t,n,r,i){let a=this.done.length?this.done[this.done.length-1].selectionsAfter:H;return a.length>0&&n-this.prevTime<i&&r==this.prevUserEvent&&r&&/^select($|\.)/.test(r)&&lc(a[a.length-1],t)?this:new e(fc(this.done,t),this.undone,n,r)}addMapping(t){return new e(mc(this.done,t),mc(this.undone,t),this.prevTime,this.prevUserEvent)}pop(e,t,n){let r=e==0?this.done:this.undone;if(r.length==0)return null;let i=r[r.length-1],a=i.selectionsAfter[0]||(i.startSelection?i.startSelection.map(i.changes.invertedDesc,1):t.selection);if(n&&i.selectionsAfter.length)return t.update({selection:i.selectionsAfter[i.selectionsAfter.length-1],annotations:Ys.of({side:e,rest:pc(r),selection:a}),userEvent:e==0?`select.undo`:`select.redo`,scrollIntoView:!0});if(i.changes){let n=r.length==1?H:r.slice(0,r.length-1);return i.mapped&&(n=mc(n,i.mapped)),t.update({changes:i.changes,selection:i.startSelection,effects:i.effects,annotations:Ys.of({side:e,rest:n,selection:a}),filter:!1,userEvent:e==0?`undo`:`redo`,scrollIntoView:!0})}else return null}};_c.empty=new _c(H,H);var vc=[{key:`Mod-z`,run:nc,preventDefault:!0},{key:`Mod-y`,mac:`Mod-Shift-z`,run:rc,preventDefault:!0},{linux:`Ctrl-Shift-z`,run:rc,preventDefault:!0},{key:`Mod-u`,run:ic,preventDefault:!0},{key:`Alt-u`,mac:`Mod-Shift-u`,run:ac,preventDefault:!0}];function yc(e,t){return O.create(e.ranges.map(t),e.mainIndex)}function U(e,t){return e.update({selection:t,scrollIntoView:!0,userEvent:`select`})}function W({state:e,dispatch:t},n){let r=yc(e.selection,n);return r.eq(e.selection,!0)?!1:(t(U(e,r)),!0)}function bc(e,t){return O.cursor(t?e.to:e.from)}function xc(e,t){return W(e,n=>n.empty?e.moveByChar(n,t):bc(n,t))}function G(e){return e.textDirectionAt(e.state.selection.main.head)==ye.LTR}var Sc=e=>xc(e,!G(e)),Cc=e=>xc(e,G(e));function wc(e,t){return W(e,n=>n.empty?e.moveByGroup(n,t):bc(n,t))}var Tc=e=>wc(e,!G(e)),Ec=e=>wc(e,G(e));typeof Intl<`u`&&Intl.Segmenter;function Dc(e,t,n){if(t.type.prop(n))return!0;let r=t.to-t.from;return r&&(r>2||/[^\s,.;:]/.test(e.sliceDoc(t.from,t.to)))||t.firstChild}function Oc(e,t,n){let r=T(e).resolveInner(t.head),i=n?_.closedBy:_.openedBy;for(let a=t.head;;){let t=n?r.childAfter(a):r.childBefore(a);if(!t)break;Dc(e,t,i)?r=t:a=n?t.to:t.from}let a=r.type.prop(i),o,s;return s=a&&(o=n?g(e,r.from,1):g(e,r.to,-1))&&o.matched?n?o.end.to:o.end.from:n?r.to:r.from,O.cursor(s,n?-1:1)}var kc=e=>W(e,t=>Oc(e.state,t,!G(e))),Ac=e=>W(e,t=>Oc(e.state,t,G(e)));function jc(e,t){return W(e,n=>{if(!n.empty)return bc(n,t);let r=e.moveVertically(n,t);return r.head==n.head?e.moveToLineBoundary(n,t):r})}var Mc=e=>jc(e,!1),Nc=e=>jc(e,!0);function Pc(e){let t=e.scrollDOM.clientHeight<e.scrollDOM.scrollHeight-2,n=0,r=0,i;if(t){for(let t of e.state.facet(k.scrollMargins)){let i=t(e);i?.top&&(n=Math.max(i?.top,n)),i?.bottom&&(r=Math.max(i?.bottom,r))}i=e.scrollDOM.clientHeight-n-r}else i=(e.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:n,marginBottom:r,selfScroll:t,height:Math.max(e.defaultLineHeight,i-5)}}function Fc(e,t){let n=Pc(e),{state:r}=e,i=yc(r.selection,r=>r.empty?e.moveVertically(r,t,n.height):bc(r,t));if(i.eq(r.selection))return!1;let a;if(n.selfScroll){let t=e.coordsAtPos(r.selection.main.head),o=e.scrollDOM.getBoundingClientRect(),s=o.top+n.marginTop,c=o.bottom-n.marginBottom;t&&t.top>s&&t.bottom<c&&(a=k.scrollIntoView(i.main.head,{y:`start`,yMargin:t.top-s}))}return e.dispatch(U(r,i),{effects:a}),!0}var Ic=e=>Fc(e,!1),Lc=e=>Fc(e,!0);function Rc(e,t,n){let r=e.lineBlockAt(t.head),i=e.moveToLineBoundary(t,n);if(i.head==t.head&&i.head!=(n?r.to:r.from)&&(i=e.moveToLineBoundary(t,n,!1)),!n&&i.head==r.from&&r.length){let n=/^\s*/.exec(e.state.sliceDoc(r.from,Math.min(r.from+100,r.to)))[0].length;n&&t.head!=r.from+n&&(i=O.cursor(r.from+n))}return i}var zc=e=>W(e,t=>Rc(e,t,!0)),Bc=e=>W(e,t=>Rc(e,t,!1)),Vc=e=>W(e,t=>Rc(e,t,!G(e))),Hc=e=>W(e,t=>Rc(e,t,G(e))),Uc=e=>W(e,t=>O.cursor(e.lineBlockAt(t.head).from,1)),Wc=e=>W(e,t=>O.cursor(e.lineBlockAt(t.head).to,-1));function Gc(e,t,n){let r=!1,i=yc(e.selection,t=>{let i=g(e,t.head,-1)||g(e,t.head,1)||t.head>0&&g(e,t.head-1,1)||t.head<e.doc.length&&g(e,t.head+1,-1);if(!i||!i.end)return t;r=!0;let a=i.start.from==t.head?i.end.to:i.end.from;return n?O.range(t.anchor,a):O.cursor(a)});return r?(t(U(e,i)),!0):!1}var Kc=({state:e,dispatch:t})=>Gc(e,t,!1);function K(e,t){let n=yc(e.state.selection,e=>{let n=t(e);return O.range(e.anchor,n.head,n.goalColumn,n.bidiLevel||void 0,n.assoc)});return n.eq(e.state.selection)?!1:(e.dispatch(U(e.state,n)),!0)}function qc(e,t){return K(e,n=>e.moveByChar(n,t))}var Jc=e=>qc(e,!G(e)),Yc=e=>qc(e,G(e));function Xc(e,t){return K(e,n=>e.moveByGroup(n,t))}var Zc=e=>Xc(e,!G(e)),Qc=e=>Xc(e,G(e)),$c=e=>K(e,t=>Oc(e.state,t,!G(e))),el=e=>K(e,t=>Oc(e.state,t,G(e)));function tl(e,t){return K(e,n=>e.moveVertically(n,t))}var nl=e=>tl(e,!1),rl=e=>tl(e,!0);function il(e,t){return K(e,n=>e.moveVertically(n,t,Pc(e).height))}var al=e=>il(e,!1),ol=e=>il(e,!0),sl=e=>K(e,t=>Rc(e,t,!0)),cl=e=>K(e,t=>Rc(e,t,!1)),ll=e=>K(e,t=>Rc(e,t,!G(e))),ul=e=>K(e,t=>Rc(e,t,G(e))),dl=e=>K(e,t=>O.cursor(e.lineBlockAt(t.head).from)),fl=e=>K(e,t=>O.cursor(e.lineBlockAt(t.head).to)),pl=({state:e,dispatch:t})=>(t(U(e,{anchor:0})),!0),ml=({state:e,dispatch:t})=>(t(U(e,{anchor:e.doc.length})),!0),hl=({state:e,dispatch:t})=>(t(U(e,{anchor:e.selection.main.anchor,head:0})),!0),gl=({state:e,dispatch:t})=>(t(U(e,{anchor:e.selection.main.anchor,head:e.doc.length})),!0),_l=({state:e,dispatch:t})=>(t(e.update({selection:{anchor:0,head:e.doc.length},userEvent:`select`})),!0),vl=({state:e,dispatch:t})=>{let n=Ll(e).map(({from:t,to:n})=>O.range(t,Math.min(n+1,e.doc.length)));return t(e.update({selection:O.create(n),userEvent:`select`})),!0},yl=({state:e,dispatch:t})=>{let n=yc(e.selection,t=>{let n=T(e),r=n.resolveStack(t.from,1);if(t.empty){let e=n.resolveStack(t.from,-1);e.node.from>=r.node.from&&e.node.to<=r.node.to&&(r=e)}for(let e=r;e;e=e.next){let{node:n}=e;if((n.from<t.from&&n.to>=t.to||n.to>t.to&&n.from<=t.from)&&e.next)return O.range(n.to,n.from)}return t});return n.eq(e.selection)?!1:(t(U(e,n)),!0)};function bl(e,t){let{state:n}=e,r=n.selection,i=n.selection.ranges.slice();for(let r of n.selection.ranges){let a=n.doc.lineAt(r.head);if(t?a.to<e.state.doc.length:a.from>0)for(let n=r;;){let r=e.moveVertically(n,t);if(r.head<a.from||r.head>a.to){i.some(e=>e.head==r.head)||i.push(r);break}else if(r.head==n.head)break;else n=r}}return i.length==r.ranges.length?!1:(e.dispatch(U(n,O.create(i,i.length-1))),!0)}var xl=e=>bl(e,!1),Sl=e=>bl(e,!0),Cl=({state:e,dispatch:t})=>{let n=e.selection,r=null;return n.ranges.length>1?r=O.create([n.main]):n.main.empty||(r=O.create([O.cursor(n.main.head)])),r?(t(U(e,r)),!0):!1};function wl(e,t){if(e.state.readOnly)return!1;let n=`delete.selection`,{state:r}=e,i=r.changeByRange(r=>{let{from:i,to:a}=r;if(i==a){let o=t(r);o<i?(n=`delete.backward`,o=Tl(e,o,!1)):o>i&&(n=`delete.forward`,o=Tl(e,o,!0)),i=Math.min(i,o),a=Math.max(a,o)}else i=Tl(e,i,!1),a=Tl(e,a,!0);return i==a?{range:r}:{changes:{from:i,to:a},range:O.cursor(i,i<r.head?-1:1)}});return i.changes.empty?!1:(e.dispatch(r.update(i,{scrollIntoView:!0,userEvent:n,effects:n==`delete.selection`?k.announce.of(r.phrase(`Selection deleted`)):void 0})),!0)}function Tl(e,t,n){if(e instanceof k)for(let r of e.state.facet(k.atomicRanges).map(t=>t(e)))r.between(t,t,(e,r)=>{e<t&&r>t&&(t=n?r:e)});return t}var El=(e,t,n)=>wl(e,r=>{let i=r.from,{state:a}=e,o=a.doc.lineAt(i),s,c;if(n&&!t&&i>o.from&&i<o.from+200&&!/[^ \t]/.test(s=o.text.slice(0,i-o.from))){if(s[s.length-1]==` `)return i-1;let e=v(s,a.tabSize)%_t(a)||_t(a);for(let t=0;t<e&&s[s.length-1-t]==` `;t++)i--;c=i}else c=je(o.text,i-o.from,t,t)+o.from,c==i&&o.number!=(t?a.doc.lines:1)?c+=t?1:-1:!t&&/[\ufe00-\ufe0f]/.test(o.text.slice(c-o.from,i-o.from))&&(c=je(o.text,c-o.from,!1,!1)+o.from);return c}),Dl=e=>El(e,!1,!0),Ol=e=>El(e,!0,!1),kl=(e,t)=>wl(e,n=>{let r=n.head,{state:i}=e,a=i.doc.lineAt(r),o=i.charCategorizer(r);for(let e=null;;){if(r==(t?a.to:a.from)){r==n.head&&a.number!=(t?i.doc.lines:1)&&(r+=t?1:-1);break}let s=je(a.text,r-a.from,t)+a.from,c=a.text.slice(Math.min(r,s)-a.from,Math.max(r,s)-a.from),l=o(c);if(e!=null&&l!=e)break;(c!=` `||r!=n.head)&&(e=l),r=s}return r}),Al=e=>kl(e,!1),jl=e=>kl(e,!0),Ml=e=>wl(e,t=>{let n=e.lineBlockAt(t.head).to;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)}),Nl=e=>wl(e,t=>{let n=e.moveToLineBoundary(t,!1).head;return t.head>n?n:Math.max(0,t.head-1)}),Pl=e=>wl(e,t=>{let n=e.moveToLineBoundary(t,!0).head;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)}),Fl=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange(e=>({changes:{from:e.from,to:e.to,insert:he.of([``,``])},range:O.cursor(e.from)}));return t(e.update(n,{scrollIntoView:!0,userEvent:`input`})),!0},Il=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange(t=>{if(!t.empty||t.from==0||t.from==e.doc.length)return{range:t};let n=t.from,r=e.doc.lineAt(n),i=n==r.from?n-1:je(r.text,n-r.from,!1)+r.from,a=n==r.to?n+1:je(r.text,n-r.from,!0)+r.from;return{changes:{from:i,to:a,insert:e.doc.slice(n,a).append(e.doc.slice(i,n))},range:O.cursor(a)}});return n.changes.empty?!1:(t(e.update(n,{scrollIntoView:!0,userEvent:`move.character`})),!0)};function Ll(e){let t=[],n=-1;for(let r of e.selection.ranges){let i=e.doc.lineAt(r.from),a=e.doc.lineAt(r.to);if(!r.empty&&r.to==a.from&&(a=e.doc.lineAt(r.to-1)),n>=i.number){let e=t[t.length-1];e.to=a.to,e.ranges.push(r)}else t.push({from:i.from,to:a.to,ranges:[r]});n=a.number+1}return t}function Rl(e,t,n){if(e.readOnly)return!1;let r=[],i=[];for(let t of Ll(e)){if(n?t.to==e.doc.length:t.from==0)continue;let a=e.doc.lineAt(n?t.to+1:t.from-1),o=a.length+1;if(n){r.push({from:t.to,to:a.to},{from:t.from,insert:a.text+e.lineBreak});for(let n of t.ranges)i.push(O.range(Math.min(e.doc.length,n.anchor+o),Math.min(e.doc.length,n.head+o)))}else{r.push({from:a.from,to:t.from},{from:t.to,insert:e.lineBreak+a.text});for(let e of t.ranges)i.push(O.range(e.anchor-o,e.head-o))}}return r.length?(t(e.update({changes:r,scrollIntoView:!0,selection:O.create(i,e.selection.mainIndex),userEvent:`move.line`})),!0):!1}var zl=({state:e,dispatch:t})=>Rl(e,t,!1),Bl=({state:e,dispatch:t})=>Rl(e,t,!0);function Vl(e,t,n){if(e.readOnly)return!1;let r=[];for(let t of Ll(e))n?r.push({from:t.from,insert:e.doc.slice(t.from,t.to)+e.lineBreak}):r.push({from:t.to,insert:e.lineBreak+e.doc.slice(t.from,t.to)});let i=e.changes(r);return t(e.update({changes:i,selection:e.selection.map(i,n?1:-1),scrollIntoView:!0,userEvent:`input.copyline`})),!0}var Hl=({state:e,dispatch:t})=>Vl(e,t,!1),Ul=({state:e,dispatch:t})=>Vl(e,t,!0),Wl=e=>{if(e.state.readOnly)return!1;let{state:t}=e,n=t.changes(Ll(t).map(({from:e,to:n})=>(e>0?e--:n<t.doc.length&&n++,{from:e,to:n}))),r=yc(t.selection,t=>{let n;if(e.lineWrapping){let r=e.lineBlockAt(t.head),i=e.coordsAtPos(t.head,t.assoc||1);i&&(n=r.bottom+e.documentTop-i.bottom+e.defaultLineHeight/2)}return e.moveVertically(t,!0,n)}).map(n);return e.dispatch({changes:n,selection:r,scrollIntoView:!0,userEvent:`delete.line`}),!0};function Gl(e,t){if(/\(\)|\[\]|\{\}/.test(e.sliceDoc(t-1,t+1)))return{from:t,to:t};let n=T(e).resolveInner(t),r=n.childBefore(t),i=n.childAfter(t),a;return r&&i&&r.to<=t&&i.from>=t&&(a=r.type.prop(_.closedBy))&&a.indexOf(i.name)>-1&&e.doc.lineAt(r.to).from==e.doc.lineAt(i.from).from&&!/\S/.test(e.sliceDoc(r.to,i.from))?{from:r.to,to:i.from}:null}var Kl=Jl(!1),ql=Jl(!0);function Jl(e){return({state:t,dispatch:n})=>{if(t.readOnly)return!1;let r=t.changeByRange(n=>{let{from:r,to:i}=n,a=t.doc.lineAt(r),o=!e&&r==i&&Gl(t,r);e&&(r=i=(i<=a.to?a:t.doc.lineAt(i)).to);let s=new nt(t,{simulateBreak:r,simulateDoubleBreak:!!o}),c=Ee(s,r);for(c??=v(/^\s*/.exec(t.doc.lineAt(r).text)[0],t.tabSize);i<a.to&&/\s/.test(a.text[i-a.from]);)i++;o?{from:r,to:i}=o:r>a.from&&r<a.from+100&&!/\S/.test(a.text.slice(0,r))&&(r=a.from);let l=[``,x(t,c)];return o&&l.push(x(t,s.lineIndent(a.from,-1))),{changes:{from:r,to:i,insert:he.of(l)},range:O.cursor(r+1+l[1].length)}});return n(t.update(r,{scrollIntoView:!0,userEvent:`input`})),!0}}function Yl(e,t){let n=-1;return e.changeByRange(r=>{let i=[];for(let a=r.from;a<=r.to;){let o=e.doc.lineAt(a);o.number>n&&(r.empty||r.to>o.from)&&(t(o,i,r),n=o.number),a=o.to+1}let a=e.changes(i);return{changes:i,range:O.range(a.mapPos(r.anchor,1),a.mapPos(r.head,1))}})}var Xl=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=Object.create(null),r=new nt(e,{overrideIndentation:e=>n[e]??-1}),i=Yl(e,(t,i,a)=>{let o=Ee(r,t.from);if(o==null)return;/\S/.test(t.text)||(o=0);let s=/^\s*/.exec(t.text)[0],c=x(e,o);(s!=c||a.from<t.from+s.length)&&(n[t.from]=o,i.push({from:t.from,to:t.from+s.length,insert:c}))});return i.changes.empty||t(e.update(i,{userEvent:`indent`})),!0},Zl=({state:e,dispatch:t})=>e.readOnly?!1:(t(e.update(Yl(e,(t,n)=>{n.push({from:t.from,insert:e.facet(pe)})}),{userEvent:`input.indent`})),!0),Ql=({state:e,dispatch:t})=>e.readOnly?!1:(t(e.update(Yl(e,(t,n)=>{let r=/^\s*/.exec(t.text)[0];if(!r)return;let i=v(r,e.tabSize),a=0,o=x(e,Math.max(0,i-_t(e)));for(;a<r.length&&a<o.length&&r.charCodeAt(a)==o.charCodeAt(a);)a++;n.push({from:t.from+a,to:t.from+r.length,insert:o.slice(a)})}),{userEvent:`delete.dedent`})),!0),$l=e=>(e.setTabFocusMode(),!0),eu=[{key:`Ctrl-b`,run:Sc,shift:Jc,preventDefault:!0},{key:`Ctrl-f`,run:Cc,shift:Yc},{key:`Ctrl-p`,run:Mc,shift:nl},{key:`Ctrl-n`,run:Nc,shift:rl},{key:`Ctrl-a`,run:Uc,shift:dl},{key:`Ctrl-e`,run:Wc,shift:fl},{key:`Ctrl-d`,run:Ol},{key:`Ctrl-h`,run:Dl},{key:`Ctrl-k`,run:Ml},{key:`Ctrl-Alt-h`,run:Al},{key:`Ctrl-o`,run:Fl},{key:`Ctrl-t`,run:Il},{key:`Ctrl-v`,run:Lc}],tu=[{key:`ArrowLeft`,run:Sc,shift:Jc,preventDefault:!0},{key:`Mod-ArrowLeft`,mac:`Alt-ArrowLeft`,run:Tc,shift:Zc,preventDefault:!0},{mac:`Cmd-ArrowLeft`,run:Vc,shift:ll,preventDefault:!0},{key:`ArrowRight`,run:Cc,shift:Yc,preventDefault:!0},{key:`Mod-ArrowRight`,mac:`Alt-ArrowRight`,run:Ec,shift:Qc,preventDefault:!0},{mac:`Cmd-ArrowRight`,run:Hc,shift:ul,preventDefault:!0},{key:`ArrowUp`,run:Mc,shift:nl,preventDefault:!0},{mac:`Cmd-ArrowUp`,run:pl,shift:hl},{mac:`Ctrl-ArrowUp`,run:Ic,shift:al},{key:`ArrowDown`,run:Nc,shift:rl,preventDefault:!0},{mac:`Cmd-ArrowDown`,run:ml,shift:gl},{mac:`Ctrl-ArrowDown`,run:Lc,shift:ol},{key:`PageUp`,run:Ic,shift:al},{key:`PageDown`,run:Lc,shift:ol},{key:`Home`,run:Bc,shift:cl,preventDefault:!0},{key:`Mod-Home`,run:pl,shift:hl},{key:`End`,run:zc,shift:sl,preventDefault:!0},{key:`Mod-End`,run:ml,shift:gl},{key:`Enter`,run:Kl,shift:Kl},{key:`Mod-a`,run:_l},{key:`Backspace`,run:Dl,shift:Dl,preventDefault:!0},{key:`Delete`,run:Ol,preventDefault:!0},{key:`Mod-Backspace`,mac:`Alt-Backspace`,run:Al,preventDefault:!0},{key:`Mod-Delete`,mac:`Alt-Delete`,run:jl,preventDefault:!0},{mac:`Mod-Backspace`,run:Nl,preventDefault:!0},{mac:`Mod-Delete`,run:Pl,preventDefault:!0}].concat(eu.map(e=>({mac:e.key,run:e.run,shift:e.shift}))),nu=[{key:`Alt-ArrowLeft`,mac:`Ctrl-ArrowLeft`,run:kc,shift:$c},{key:`Alt-ArrowRight`,mac:`Ctrl-ArrowRight`,run:Ac,shift:el},{key:`Alt-ArrowUp`,run:zl},{key:`Shift-Alt-ArrowUp`,run:Hl},{key:`Alt-ArrowDown`,run:Bl},{key:`Shift-Alt-ArrowDown`,run:Ul},{key:`Mod-Alt-ArrowUp`,run:xl},{key:`Mod-Alt-ArrowDown`,run:Sl},{key:`Escape`,run:Cl},{key:`Mod-Enter`,run:ql},{key:`Alt-l`,mac:`Ctrl-l`,run:vl},{key:`Mod-i`,run:yl,preventDefault:!0},{key:`Mod-[`,run:Ql},{key:`Mod-]`,run:Zl},{key:`Mod-Alt-\\`,run:Xl},{key:`Shift-Mod-k`,run:Wl},{key:`Shift-Mod-\\`,run:Kc},{key:`Mod-/`,run:Rs},{key:`Alt-A`,run:Vs},{key:`Ctrl-m`,mac:`Shift-Alt-m`,run:$l}].concat(tu),ru={key:`Tab`,run:Zl,shift:Ql},iu=typeof String.prototype.normalize==`function`?e=>e.normalize(`NFKD`):e=>e,au=class{constructor(e,t,n=0,r=e.length,i,a){this.test=a,this.value={from:0,to:0},this.done=!1,this.matches=[],this.buffer=``,this.bufferPos=0,this.iter=e.iterRange(n,r),this.bufferStart=n,this.normalize=i?e=>i(iu(e)):iu,this.query=this.normalize(t)}peek(){if(this.bufferPos==this.buffer.length){if(this.bufferStart+=this.buffer.length,this.iter.next(),this.iter.done)return-1;this.bufferPos=0,this.buffer=this.iter.value}return xe(this.buffer,this.bufferPos)}next(){for(;this.matches.length;)this.matches.pop();return this.nextOverlapping()}nextOverlapping(){for(;;){let e=this.peek();if(e<0)return this.done=!0,this;let t=_e(e),n=this.bufferStart+this.bufferPos;this.bufferPos+=Te(e);let r=this.normalize(t);if(r.length)for(let e=0,i=n;;e++){let a=r.charCodeAt(e),o=this.match(a,i,this.bufferPos+this.bufferStart);if(e==r.length-1){if(o)return this.value=o,this;break}i==n&&e<t.length&&t.charCodeAt(e)==a&&i++}}}match(e,t,n){let r=null;for(let t=0;t<this.matches.length;t+=2){let i=this.matches[t],a=!1;this.query.charCodeAt(i)==e&&(i==this.query.length-1?r={from:this.matches[t+1],to:n}:(this.matches[t]++,a=!0)),a||(this.matches.splice(t,2),t-=2)}return this.query.charCodeAt(0)==e&&(this.query.length==1?r={from:t,to:n}:this.matches.push(1,t)),r&&this.test&&!this.test(r.from,r.to,this.buffer,this.bufferStart)&&(r=null),r}};typeof Symbol<`u`&&(au.prototype[Symbol.iterator]=function(){return this});var ou={from:-1,to:-1,match:/.*/.exec(``)},su=`gm`+(/x/.unicode==null?``:`u`),cu=class{constructor(e,t,n,r=0,i=e.length){if(this.text=e,this.to=i,this.curLine=``,this.done=!1,this.value=ou,/\\[sWDnr]|\n|\r|\[\^/.test(t))return new du(e,t,n,r,i);this.re=new RegExp(t,su+(n?.ignoreCase?`i`:``)),this.test=n?.test,this.iter=e.iter(),this.curLineStart=e.lineAt(r).from,this.matchPos=pu(e,r),this.getLine(this.curLineStart)}getLine(e){this.iter.next(e),this.iter.lineBreak?this.curLine=``:(this.curLine=this.iter.value,this.curLineStart+this.curLine.length>this.to&&(this.curLine=this.curLine.slice(0,this.to-this.curLineStart)),this.iter.next())}nextLine(){this.curLineStart=this.curLineStart+this.curLine.length+1,this.curLineStart>this.to?this.curLine=``:this.getLine(0)}next(){for(let e=this.matchPos-this.curLineStart;;){this.re.lastIndex=e;let t=this.matchPos<=this.to&&this.re.exec(this.curLine);if(t){let n=this.curLineStart+t.index,r=n+t[0].length;if(this.matchPos=pu(this.text,r+ +(n==r)),n==this.curLineStart+this.curLine.length&&this.nextLine(),(n<r||n>this.value.to)&&(!this.test||this.test(n,r,t)))return this.value={from:n,to:r,match:t},this;e=this.matchPos-this.curLineStart}else if(this.curLineStart+this.curLine.length<this.to)this.nextLine(),e=0;else return this.done=!0,this}}},lu=new WeakMap,uu=class e{constructor(e,t){this.from=e,this.text=t}get to(){return this.from+this.text.length}static get(t,n,r){let i=lu.get(t);if(!i||i.from>=r||i.to<=n){let i=new e(n,t.sliceString(n,r));return lu.set(t,i),i}if(i.from==n&&i.to==r)return i;let{text:a,from:o}=i;return o>n&&(a=t.sliceString(n,o)+a,o=n),i.to<r&&(a+=t.sliceString(i.to,r)),lu.set(t,new e(o,a)),new e(n,a.slice(n-o,r-o))}},du=class{constructor(e,t,n,r,i){this.text=e,this.to=i,this.done=!1,this.value=ou,this.matchPos=pu(e,r),this.re=new RegExp(t,su+(n?.ignoreCase?`i`:``)),this.test=n?.test,this.flat=uu.get(e,r,this.chunkEnd(r+5e3))}chunkEnd(e){return e>=this.to?this.to:this.text.lineAt(e).to}next(){for(;;){let e=this.re.lastIndex=this.matchPos-this.flat.from,t=this.re.exec(this.flat.text);if(t&&!t[0]&&t.index==e&&(this.re.lastIndex=e+1,t=this.re.exec(this.flat.text)),t){let e=this.flat.from+t.index,n=e+t[0].length;if((this.flat.to>=this.to||t.index+t[0].length<=this.flat.text.length-10)&&(!this.test||this.test(e,n,t)))return this.value={from:e,to:n,match:t},this.matchPos=pu(this.text,n+ +(e==n)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=uu.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+this.flat.text.length*2))}}};typeof Symbol<`u`&&(cu.prototype[Symbol.iterator]=du.prototype[Symbol.iterator]=function(){return this});function fu(e){try{return new RegExp(e,su),!0}catch{return!1}}function pu(e,t){if(t>=e.length)return t;let n=e.lineAt(t),r;for(;t<n.to&&(r=n.text.charCodeAt(t-n.from))>=56320&&r<57344;)t++;return t}var mu=e=>{let{state:t}=e,n=String(t.doc.lineAt(e.state.selection.main.head).number),{close:r,result:i}=qe(e,{label:t.phrase(`Go to line`),input:{type:`text`,name:`line`,value:n},focus:!0,submitLabel:t.phrase(`go`)});return i.then(n=>{let i=n&&/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(n.elements.line.value);if(!i){e.dispatch({effects:r});return}let a=t.doc.lineAt(t.selection.main.head),[,o,s,c,l]=i,u=c?+c.slice(1):0,d=s?+s:a.number;if(s&&l){let e=d/100;o&&(e=e*(o==`-`?-1:1)+a.number/t.doc.lines),d=Math.round(t.doc.lines*e)}else s&&o&&(d=d*(o==`-`?-1:1)+a.number);let f=t.doc.line(Math.max(1,Math.min(t.doc.lines,d))),p=O.cursor(f.from+Math.max(0,Math.min(u,f.length)));e.dispatch({effects:[r,k.scrollIntoView(p.from,{y:`center`})],selection:p})}),!0},hu={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},gu=b.define({combine(e){return xt(e,hu,{highlightWordAroundCursor:(e,t)=>e||t,minSelectionLength:Math.min,maxMatches:Math.min})}});function _u(e){let t=[Cu,Su];return e&&t.push(gu.of(e)),t}var vu=A.mark({class:`cm-selectionMatch`}),yu=A.mark({class:`cm-selectionMatch cm-selectionMatch-main`});function bu(e,t,n,r){return(n==0||e(t.sliceDoc(n-1,n))!=y.Word)&&(r==t.doc.length||e(t.sliceDoc(r,r+1))!=y.Word)}function xu(e,t,n,r){return e(t.sliceDoc(n,n+1))==y.Word&&e(t.sliceDoc(r-1,r))==y.Word}var Su=Ne.fromClass(class{constructor(e){this.decorations=this.getDeco(e)}update(e){(e.selectionSet||e.docChanged||e.viewportChanged)&&(this.decorations=this.getDeco(e.view))}getDeco(e){let t=e.state.facet(gu),{state:n}=e,r=n.selection;if(r.ranges.length>1)return A.none;let i=r.main,a,o=null;if(i.empty){if(!t.highlightWordAroundCursor)return A.none;let e=n.wordAt(i.head);if(!e)return A.none;o=n.charCategorizer(i.head),a=n.sliceDoc(e.from,e.to)}else{let e=i.to-i.from;if(e<t.minSelectionLength||e>200)return A.none;if(t.wholeWords){if(a=n.sliceDoc(i.from,i.to),o=n.charCategorizer(i.head),!(bu(o,n,i.from,i.to)&&xu(o,n,i.from,i.to)))return A.none}else if(a=n.sliceDoc(i.from,i.to),!a)return A.none}let s=[];for(let r of e.visibleRanges){let e=new au(n.doc,a,r.from,r.to);for(;!e.next().done;){let{from:r,to:a}=e.value;if((!o||bu(o,n,r,a))&&(i.empty&&r<=i.from&&a>=i.to?s.push(yu.range(r,a)):(r>=i.to||a<=i.from)&&s.push(vu.range(r,a)),s.length>t.maxMatches))return A.none}}return A.set(s)}},{decorations:e=>e.decorations}),Cu=k.baseTheme({".cm-selectionMatch":{backgroundColor:`#99ff7780`},".cm-searchMatch .cm-selectionMatch":{backgroundColor:`transparent`}}),wu=({state:e,dispatch:t})=>{let{selection:n}=e,r=O.create(n.ranges.map(t=>e.wordAt(t.head)||O.cursor(t.head)),n.mainIndex);return r.eq(n)?!1:(t(e.update({selection:r})),!0)};function Tu(e,t){let{main:n,ranges:r}=e.selection,i=e.wordAt(n.head),a=i&&i.from==n.from&&i.to==n.to;for(let n=!1,i=new au(e.doc,t,r[r.length-1].to);;)if(i.next(),i.done){if(n)return null;i=new au(e.doc,t,0,Math.max(0,r[r.length-1].from-1)),n=!0}else{if(n&&r.some(e=>e.from==i.value.from))continue;if(a){let t=e.wordAt(i.value.from);if(!t||t.from!=i.value.from||t.to!=i.value.to)continue}return i.value}}var Eu=({state:e,dispatch:t})=>{let{ranges:n}=e.selection;if(n.some(e=>e.from===e.to))return wu({state:e,dispatch:t});let r=e.sliceDoc(n[0].from,n[0].to);if(e.selection.ranges.some(t=>e.sliceDoc(t.from,t.to)!=r))return!1;let i=Tu(e,r);return i?(t(e.update({selection:e.selection.addRange(O.range(i.from,i.to),!1),effects:k.scrollIntoView(i.to)})),!0):!1},Du=b.define({combine(e){return xt(e,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:e=>new sd(e),scrollToMatch:e=>k.scrollIntoView(e)})}}),Ou=class{constructor(e){this.search=e.search,this.caseSensitive=!!e.caseSensitive,this.literal=!!e.literal,this.regexp=!!e.regexp,this.replace=e.replace||``,this.valid=!!this.search&&(!this.regexp||fu(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!e.wholeWord,this.test=e.test}unquote(e){return this.literal?e:e.replace(/\\([nrt\\])/g,(e,t)=>t==`n`?`
29
- `:t==`r`?`\r`:t==`t`?` `:`\\`)}eq(e){return this.search==e.search&&this.replace==e.replace&&this.caseSensitive==e.caseSensitive&&this.regexp==e.regexp&&this.wholeWord==e.wholeWord&&this.test==e.test}create(){return this.regexp?new zu(this):new Nu(this)}getCursor(e,t=0,n){let r=e.doc?e:me.create({doc:e});return n??=r.doc.length,this.regexp?Fu(this,r,t,n):ju(this,r,t,n)}},ku=class{constructor(e){this.spec=e}};function Au(e,t,n){return(r,i,a,o)=>n&&!n(r,i,a,o)?!1:e(r>=o&&i<=o+a.length?a.slice(r-o,i-o):t.doc.sliceString(r,i),t,r,i)}function ju(e,t,n,r){let i;return e.wholeWord&&(i=Mu(t.doc,t.charCategorizer(t.selection.main.head))),e.test&&(i=Au(e.test,t,i)),new au(t.doc,e.unquoted,n,r,e.caseSensitive?void 0:e=>e.toLowerCase(),i)}function Mu(e,t){return(n,r,i,a)=>((a>n||a+i.length<r)&&(a=Math.max(0,n-2),i=e.sliceString(a,Math.min(e.length,r+2))),(t(Iu(i,n-a))!=y.Word||t(Lu(i,n-a))!=y.Word)&&(t(Lu(i,r-a))!=y.Word||t(Iu(i,r-a))!=y.Word))}var Nu=class extends ku{constructor(e){super(e)}nextMatch(e,t,n){let r=ju(this.spec,e,n,e.doc.length).nextOverlapping();if(r.done){let n=Math.min(e.doc.length,t+this.spec.unquoted.length);r=ju(this.spec,e,0,n).nextOverlapping()}return r.done||r.value.from==t&&r.value.to==n?null:r.value}prevMatchInRange(e,t,n){for(let r=n;;){let n=Math.max(t,r-1e4-this.spec.unquoted.length),i=ju(this.spec,e,n,r),a=null;for(;!i.nextOverlapping().done;)a=i.value;if(a)return a;if(n==t)return null;r-=1e4}}prevMatch(e,t,n){let r=this.prevMatchInRange(e,0,t);return r||=this.prevMatchInRange(e,Math.max(0,n-this.spec.unquoted.length),e.doc.length),r&&(r.from!=t||r.to!=n)?r:null}getReplacement(e){return this.spec.unquote(this.spec.replace)}matchAll(e,t){let n=ju(this.spec,e,0,e.doc.length),r=[];for(;!n.next().done;){if(r.length>=t)return null;r.push(n.value)}return r}highlight(e,t,n,r){let i=ju(this.spec,e,Math.max(0,t-this.spec.unquoted.length),Math.min(n+this.spec.unquoted.length,e.doc.length));for(;!i.next().done;)r(i.value.from,i.value.to)}};function Pu(e,t,n){return(r,i,a)=>(!n||n(r,i,a))&&e(a[0],t,r,i)}function Fu(e,t,n,r){let i;return e.wholeWord&&(i=Ru(t.charCategorizer(t.selection.main.head))),e.test&&(i=Pu(e.test,t,i)),new cu(t.doc,e.search,{ignoreCase:!e.caseSensitive,test:i},n,r)}function Iu(e,t){return e.slice(je(e,t,!1),t)}function Lu(e,t){return e.slice(t,je(e,t))}function Ru(e){return(t,n,r)=>!r[0].length||(e(Iu(r.input,r.index))!=y.Word||e(Lu(r.input,r.index))!=y.Word)&&(e(Lu(r.input,r.index+r[0].length))!=y.Word||e(Iu(r.input,r.index+r[0].length))!=y.Word)}var zu=class extends ku{nextMatch(e,t,n){let r=Fu(this.spec,e,n,e.doc.length).next();return r.done&&(r=Fu(this.spec,e,0,t).next()),r.done?null:r.value}prevMatchInRange(e,t,n){for(let r=1;;r++){let i=Math.max(t,n-r*1e4),a=Fu(this.spec,e,i,n),o=null;for(;!a.next().done;)o=a.value;if(o&&(i==t||o.from>i+10))return o;if(i==t)return null}}prevMatch(e,t,n){return this.prevMatchInRange(e,0,t)||this.prevMatchInRange(e,n,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace).replace(/\$([$&]|\d+)/g,(t,n)=>{if(n==`&`)return e.match[0];if(n==`$`)return`$`;for(let t=n.length;t>0;t--){let r=+n.slice(0,t);if(r>0&&r<e.match.length)return e.match[r]+n.slice(t)}return t})}matchAll(e,t){let n=Fu(this.spec,e,0,e.doc.length),r=[];for(;!n.next().done;){if(r.length>=t)return null;r.push(n.value)}return r}highlight(e,t,n,r){let i=Fu(this.spec,e,Math.max(0,t-250),Math.min(n+250,e.doc.length));for(;!i.next().done;)r(i.value.from,i.value.to)}},Bu=E.define(),Vu=E.define(),Hu=D.define({create(e){return new Uu(td(e).create(),null)},update(e,t){for(let n of t.effects)n.is(Bu)?e=new Uu(n.value.create(),e.panel):n.is(Vu)&&(e=new Uu(e.query,n.value?ed:null));return e},provide:e=>Ge.from(e,e=>e.panel)}),Uu=class{constructor(e,t){this.query=e,this.panel=t}},Wu=A.mark({class:`cm-searchMatch`}),Gu=A.mark({class:`cm-searchMatch cm-searchMatch-selected`}),Ku=Ne.fromClass(class{constructor(e){this.view=e,this.decorations=this.highlight(e.state.field(Hu))}update(e){let t=e.state.field(Hu);(t!=e.startState.field(Hu)||e.docChanged||e.selectionSet||e.viewportChanged)&&(this.decorations=this.highlight(t))}highlight({query:e,panel:t}){if(!t||!e.spec.valid)return A.none;let{view:n}=this,r=new Xe;for(let t=0,i=n.visibleRanges,a=i.length;t<a;t++){let{from:o,to:s}=i[t];for(;t<a-1&&s>i[t+1].from-500;)s=i[++t].to;e.highlight(n.state,o,s,(e,t)=>{let i=n.state.selection.ranges.some(n=>n.from==e&&n.to==t);r.add(e,t,i?Gu:Wu)})}return r.finish()}},{decorations:e=>e.decorations});function qu(e){return t=>{let n=t.state.field(Hu,!1);return n&&n.query.spec.valid?e(t,n):id(t)}}var Ju=qu((e,{query:t})=>{let{to:n}=e.state.selection.main,r=t.nextMatch(e.state,n,n);if(!r)return!1;let i=O.single(r.from,r.to),a=e.state.facet(Du);return e.dispatch({selection:i,effects:[ud(e,r),a.scrollToMatch(i.main,e)],userEvent:`select.search`}),rd(e),!0}),Yu=qu((e,{query:t})=>{let{state:n}=e,{from:r}=n.selection.main,i=t.prevMatch(n,r,r);if(!i)return!1;let a=O.single(i.from,i.to),o=e.state.facet(Du);return e.dispatch({selection:a,effects:[ud(e,i),o.scrollToMatch(a.main,e)],userEvent:`select.search`}),rd(e),!0}),Xu=qu((e,{query:t})=>{let n=t.matchAll(e.state,1e3);return!n||!n.length?!1:(e.dispatch({selection:O.create(n.map(e=>O.range(e.from,e.to))),userEvent:`select.search.matches`}),!0)}),Zu=({state:e,dispatch:t})=>{let n=e.selection;if(n.ranges.length>1||n.main.empty)return!1;let{from:r,to:i}=n.main,a=[],o=0;for(let t=new au(e.doc,e.sliceDoc(r,i));!t.next().done;){if(a.length>1e3)return!1;t.value.from==r&&(o=a.length),a.push(O.range(t.value.from,t.value.to))}return t(e.update({selection:O.create(a,o),userEvent:`select.search.matches`})),!0},Qu=qu((e,{query:t})=>{let{state:n}=e,{from:r,to:i}=n.selection.main;if(n.readOnly)return!1;let a=t.nextMatch(n,r,r);if(!a)return!1;let o=a,s=[],c,l,u=[];o.from==r&&o.to==i&&(l=n.toText(t.getReplacement(o)),s.push({from:o.from,to:o.to,insert:l}),o=t.nextMatch(n,o.from,o.to),u.push(k.announce.of(n.phrase(`replaced match on line $`,n.doc.lineAt(r).number)+`.`)));let d=e.state.changes(s);return o&&(c=O.single(o.from,o.to).map(d),u.push(ud(e,o)),u.push(n.facet(Du).scrollToMatch(c.main,e))),e.dispatch({changes:d,selection:c,effects:u,userEvent:`input.replace`}),!0}),$u=qu((e,{query:t})=>{if(e.state.readOnly)return!1;let n=t.matchAll(e.state,1e9).map(e=>{let{from:n,to:r}=e;return{from:n,to:r,insert:t.getReplacement(e)}});if(!n.length)return!1;let r=e.state.phrase(`replaced $ matches`,n.length)+`.`;return e.dispatch({changes:n,effects:k.announce.of(r),userEvent:`input.replace.all`}),!0});function ed(e){return e.state.facet(Du).createPanel(e)}function td(e,t){let n=e.selection.main,r=n.empty||n.to>n.from+100?``:e.sliceDoc(n.from,n.to);if(t&&!r)return t;let i=e.facet(Du);return new Ou({search:t?.literal??i.literal?r:r.replace(/\n/g,`\\n`),caseSensitive:t?.caseSensitive??i.caseSensitive,literal:t?.literal??i.literal,regexp:t?.regexp??i.regexp,wholeWord:t?.wholeWord??i.wholeWord})}function nd(e){let t=rt(e,ed);return t&&t.dom.querySelector(`[main-field]`)}function rd(e){let t=nd(e);t&&t==e.root.activeElement&&t.select()}var id=e=>{let t=e.state.field(Hu,!1);if(t&&t.panel){let n=nd(e);if(n&&n!=e.root.activeElement){let r=td(e.state,t.query.spec);r.valid&&e.dispatch({effects:Bu.of(r)}),n.focus(),n.select()}}else e.dispatch({effects:[Vu.of(!0),t?Bu.of(td(e.state,t.query.spec)):E.appendConfig.of(fd)]});return!0},ad=e=>{let t=e.state.field(Hu,!1);if(!t||!t.panel)return!1;let n=rt(e,ed);return n&&n.dom.contains(e.root.activeElement)&&e.focus(),e.dispatch({effects:Vu.of(!1)}),!0},od=[{key:`Mod-f`,run:id,scope:`editor search-panel`},{key:`F3`,run:Ju,shift:Yu,scope:`editor search-panel`,preventDefault:!0},{key:`Mod-g`,run:Ju,shift:Yu,scope:`editor search-panel`,preventDefault:!0},{key:`Escape`,run:ad,scope:`editor search-panel`},{key:`Mod-Shift-l`,run:Zu},{key:`Mod-Alt-g`,run:mu},{key:`Mod-d`,run:Eu,preventDefault:!0}],sd=class{constructor(e){this.view=e;let t=this.query=e.state.field(Hu).query.spec;this.commit=this.commit.bind(this),this.searchField=j(`input`,{value:t.search,placeholder:q(e,`Find`),"aria-label":q(e,`Find`),class:`cm-textfield`,name:`search`,form:``,"main-field":`true`,onchange:this.commit,onkeyup:this.commit}),this.replaceField=j(`input`,{value:t.replace,placeholder:q(e,`Replace`),"aria-label":q(e,`Replace`),class:`cm-textfield`,name:`replace`,form:``,onchange:this.commit,onkeyup:this.commit}),this.caseField=j(`input`,{type:`checkbox`,name:`case`,form:``,checked:t.caseSensitive,onchange:this.commit}),this.reField=j(`input`,{type:`checkbox`,name:`re`,form:``,checked:t.regexp,onchange:this.commit}),this.wordField=j(`input`,{type:`checkbox`,name:`word`,form:``,checked:t.wholeWord,onchange:this.commit});function n(e,t,n){return j(`button`,{class:`cm-button`,name:e,onclick:t,type:`button`},n)}this.dom=j(`div`,{onkeydown:e=>this.keydown(e),class:`cm-search`},[this.searchField,n(`next`,()=>Ju(e),[q(e,`next`)]),n(`prev`,()=>Yu(e),[q(e,`previous`)]),n(`select`,()=>Xu(e),[q(e,`all`)]),j(`label`,null,[this.caseField,q(e,`match case`)]),j(`label`,null,[this.reField,q(e,`regexp`)]),j(`label`,null,[this.wordField,q(e,`by word`)]),...e.state.readOnly?[]:[j(`br`),this.replaceField,n(`replace`,()=>Qu(e),[q(e,`replace`)]),n(`replaceAll`,()=>$u(e),[q(e,`replace all`)])],j(`button`,{name:`close`,onclick:()=>ad(e),"aria-label":q(e,`close`),type:`button`},[`×`])])}commit(){let e=new Ou({search:this.searchField.value,caseSensitive:this.caseField.checked,regexp:this.reField.checked,wholeWord:this.wordField.checked,replace:this.replaceField.value});e.eq(this.query)||(this.query=e,this.view.dispatch({effects:Bu.of(e)}))}keydown(e){tt(this.view,e,`search-panel`)?e.preventDefault():e.keyCode==13&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?Yu:Ju)(this.view)):e.keyCode==13&&e.target==this.replaceField&&(e.preventDefault(),Qu(this.view))}update(e){for(let t of e.transactions)for(let e of t.effects)e.is(Bu)&&!e.value.eq(this.query)&&this.setQuery(e.value)}setQuery(e){this.query=e,this.searchField.value=e.search,this.replaceField.value=e.replace,this.caseField.checked=e.caseSensitive,this.reField.checked=e.regexp,this.wordField.checked=e.wholeWord}mount(){this.searchField.select()}get pos(){return 80}get top(){return this.view.state.facet(Du).top}};function q(e,t){return e.state.phrase(t)}var cd=30,ld=/[\s\.,:;?!]/;function ud(e,{from:t,to:n}){let r=e.state.doc.lineAt(t),i=e.state.doc.lineAt(n).to,a=Math.max(r.from,t-cd),o=Math.min(i,n+cd),s=e.state.sliceDoc(a,o);if(a!=r.from){for(let e=0;e<cd;e++)if(!ld.test(s[e+1])&&ld.test(s[e])){s=s.slice(e);break}}if(o!=i){for(let e=s.length-1;e>s.length-cd;e--)if(!ld.test(s[e-1])&&ld.test(s[e])){s=s.slice(0,e);break}}return k.announce.of(`${e.state.phrase(`current match`)}. ${s} ${e.state.phrase(`on line`)} ${r.number}.`)}var dd=k.baseTheme({".cm-panel.cm-search":{padding:`2px 6px 4px`,position:`relative`,"& [name=close]":{position:`absolute`,top:`0`,right:`4px`,backgroundColor:`inherit`,border:`none`,font:`inherit`,padding:0,margin:0},"& input, & button, & label":{margin:`.2em .6em .2em 0`},"& input[type=checkbox]":{marginRight:`.2em`},"& label":{fontSize:`80%`,whiteSpace:`pre`}},"&light .cm-searchMatch":{backgroundColor:`#ffff0054`},"&dark .cm-searchMatch":{backgroundColor:`#00ffff8a`},"&light .cm-searchMatch-selected":{backgroundColor:`#ff6a0054`},"&dark .cm-searchMatch-selected":{backgroundColor:`#ff00ff8a`}}),fd=[Hu,Qe.low(Ku),dd],pd=class{constructor(e,t,n){this.from=e,this.to=t,this.diagnostic=n}},md=class e{constructor(e,t,n){this.diagnostics=e,this.panel=t,this.selected=n}static init(t,n,r){let i=r.facet(Dd).markerFilter;i&&(t=i(t,r));let a=t.slice().sort((e,t)=>e.from-t.from||e.to-t.to),o=new Xe,s=[],c=0,l=r.doc.iter(),u=0,d=r.doc.length;for(let e=0;;){let t=e==a.length?null:a[e];if(!t&&!s.length)break;let n,r;if(s.length)n=c,r=s.reduce((e,t)=>Math.min(e,t.to),t&&t.from>n?t.from:1e8);else{if(n=t.from,n>d)break;r=t.to,s.push(t),e++}for(;e<a.length;){let t=a[e];if(t.from==n&&(t.to>t.from||t.to==n))s.push(t),e++,r=Math.min(t.to,r);else{r=Math.min(t.from,r);break}}r=Math.min(r,d);let i=!1;if(s.some(e=>e.from==n&&(e.to==r||r==d))&&(i=n==r,!i&&r-n<10)){let e=n-(u+l.value.length);e>0&&(l.next(e),u=n);for(let e=n;;){if(e>=r){i=!0;break}if(!l.lineBreak&&u+l.value.length>e)break;e=u+l.value.length,u+=l.value.length,l.next()}}let f=Rd(s);if(i)o.add(n,n,A.widget({widget:new jd(f),diagnostics:s.slice()}));else{let e=s.reduce((e,t)=>t.markClass?e+` `+t.markClass:e,``);o.add(n,r,A.mark({class:`cm-lintRange cm-lintRange-`+f+e,diagnostics:s.slice(),inclusiveEnd:s.some(e=>e.to>r)}))}if(c=r,c==d)break;for(let e=0;e<s.length;e++)s[e].to<=c&&s.splice(e--,1)}let f=o.finish();return new e(f,n,hd(f))}};function hd(e,t=null,n=0){let r=null;return e.between(n,1e9,(e,n,{spec:i})=>{if(!(t&&i.diagnostics.indexOf(t)<0))if(!r)r=new pd(e,n,t||i.diagnostics[0]);else if(i.diagnostics.indexOf(r.diagnostic)<0)return!1;else r=new pd(r.from,n,r.diagnostic)}),r}function gd(e,t){let n=t.pos,r=t.end||n,i=e.state.facet(Dd).hideOn(e,n,r);if(i!=null)return i;let a=e.startState.doc.lineAt(t.pos);return!!(e.effects.some(e=>e.is(vd))||e.changes.touchesRange(a.from,Math.max(a.to,r)))}function _d(e,t){return e.field(J,!1)?t:t.concat(E.appendConfig.of(zd))}var vd=E.define(),yd=E.define(),bd=E.define(),J=D.define({create(){return new md(A.none,null,null)},update(e,t){if(t.docChanged&&e.diagnostics.size){let n=e.diagnostics.map(t.changes),r=null,i=e.panel;if(e.selected){let i=t.changes.mapPos(e.selected.from,1);r=hd(n,e.selected.diagnostic,i)||hd(n,null,i)}!n.size&&i&&t.state.facet(Dd).autoPanel&&(i=null),e=new md(n,i,r)}for(let n of t.effects)if(n.is(vd)){let r=t.state.facet(Dd).autoPanel?n.value.length?Nd.open:null:e.panel;e=md.init(n.value,r,t.state)}else n.is(yd)?e=new md(e.diagnostics,n.value?Nd.open:null,e.selected):n.is(bd)&&(e=new md(e.diagnostics,e.panel,n.value));return e},provide:e=>[Ge.from(e,e=>e.panel),k.decorations.from(e,e=>e.diagnostics)]}),xd=A.mark({class:`cm-lintRange cm-lintRange-active`});function Sd(e,t,n){let{diagnostics:r}=e.state.field(J),i,a=-1,o=-1;r.between(t-+(n<0),t+ +(n>0),(e,r,{spec:s})=>{if(t>=e&&t<=r&&(e==r||(t>e||n>0)&&(t<r||n<0)))return i=s.diagnostics,a=e,o=r,!1});let s=e.state.facet(Dd).tooltipFilter;return i&&s&&(i=s(i,e.state)),i?{pos:a,end:o,above:e.state.doc.lineAt(a).to<o,create(){return{dom:Cd(e,i)}}}:null}function Cd(e,t){return j(`ul`,{class:`cm-tooltip-lint`},t.map(t=>Ad(e,t,!1)))}var wd=e=>{let t=e.state.field(J,!1);(!t||!t.panel)&&e.dispatch({effects:_d(e.state,[yd.of(!0)])});let n=rt(e,Nd.open);return n&&n.dom.querySelector(`.cm-panel-lint ul`).focus(),!0},Td=e=>{let t=e.state.field(J,!1);return!t||!t.panel?!1:(e.dispatch({effects:yd.of(!1)}),!0)},Ed=[{key:`Mod-Shift-m`,run:wd,preventDefault:!0},{key:`F8`,run:e=>{let t=e.state.field(J,!1);if(!t)return!1;let n=e.state.selection.main,r=hd(t.diagnostics,null,n.to+1);return!r&&(r=hd(t.diagnostics,null,0),!r||r.from==n.from&&r.to==n.to)?!1:(e.dispatch({selection:{anchor:r.from,head:r.to},scrollIntoView:!0}),!0)}}],Dd=b.define({combine(e){return{sources:e.map(e=>e.source).filter(e=>e!=null),...xt(e.map(e=>e.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{delay:Math.max,markerFilter:Od,tooltipFilter:Od,needsRefresh:(e,t)=>e?t?n=>e(n)||t(n):e:t,hideOn:(e,t)=>e?t?(n,r,i)=>e(n,r,i)||t(n,r,i):e:t,autoPanel:(e,t)=>e||t})}}});function Od(e,t){return e?t?(n,r)=>t(e(n,r),r):e:t}function kd(e){let t=[];if(e)actions:for(let{name:n}of e){for(let e=0;e<n.length;e++){let r=n[e];if(/[a-zA-Z]/.test(r)&&!t.some(e=>e.toLowerCase()==r.toLowerCase())){t.push(r);continue actions}}t.push(``)}return t}function Ad(e,t,n){let r=n?kd(t.actions):[];return j(`li`,{class:`cm-diagnostic cm-diagnostic-`+t.severity},j(`span`,{class:`cm-diagnosticText`},t.renderMessage?t.renderMessage(e):t.message),t.actions?.map((n,i)=>{let a=!1,o=r=>{if(r.preventDefault(),a)return;a=!0;let i=hd(e.state.field(J).diagnostics,t);i&&n.apply(e,i.from,i.to)},{name:s}=n,c=r[i]?s.indexOf(r[i]):-1,l=c<0?s:[s.slice(0,c),j(`u`,s.slice(c,c+1)),s.slice(c+1)];return j(`button`,{type:`button`,class:`cm-diagnosticAction`+(n.markClass?` `+n.markClass:``),onclick:o,onmousedown:o,"aria-label":` Action: ${s}${c<0?``:` (access key "${r[i]})"`}.`},l)}),t.source&&j(`div`,{class:`cm-diagnosticSource`},t.source))}var jd=class extends we{constructor(e){super(),this.sev=e}eq(e){return e.sev==this.sev}toDOM(){return j(`span`,{class:`cm-lintPoint cm-lintPoint-`+this.sev})}},Md=class{constructor(e,t){this.diagnostic=t,this.id=`item_`+Math.floor(Math.random()*4294967295).toString(16),this.dom=Ad(e,t,!0),this.dom.id=this.id,this.dom.setAttribute(`role`,`option`)}},Nd=class e{constructor(e){this.view=e,this.items=[],this.list=j(`ul`,{tabIndex:0,role:`listbox`,"aria-label":this.view.state.phrase(`Diagnostics`),onkeydown:t=>{if(!(t.ctrlKey||t.altKey||t.metaKey)){if(t.keyCode==27)Td(this.view),this.view.focus();else if(t.keyCode==38||t.keyCode==33)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(t.keyCode==40||t.keyCode==34)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(t.keyCode==36)this.moveSelection(0);else if(t.keyCode==35)this.moveSelection(this.items.length-1);else if(t.keyCode==13)this.view.focus();else if(t.keyCode>=65&&t.keyCode<=90&&this.selectedIndex>=0){let{diagnostic:n}=this.items[this.selectedIndex],r=kd(n.actions);for(let i=0;i<r.length;i++)if(r[i].toUpperCase().charCodeAt(0)==t.keyCode){let t=hd(this.view.state.field(J).diagnostics,n);t&&n.actions[i].apply(e,t.from,t.to)}}else return;t.preventDefault()}},onclick:e=>{for(let t=0;t<this.items.length;t++)this.items[t].dom.contains(e.target)&&this.moveSelection(t)}}),this.dom=j(`div`,{class:`cm-panel-lint`},this.list,j(`button`,{type:`button`,name:`close`,"aria-label":this.view.state.phrase(`close`),onclick:()=>Td(this.view)},`×`)),this.update()}get selectedIndex(){let e=this.view.state.field(J).selected;if(!e)return-1;for(let t=0;t<this.items.length;t++)if(this.items[t].diagnostic==e.diagnostic)return t;return-1}update(){let{diagnostics:e,selected:t}=this.view.state.field(J),n=0,r=!1,i=null,a=new Set;for(e.between(0,this.view.state.doc.length,(e,o,{spec:s})=>{for(let e of s.diagnostics){if(a.has(e))continue;a.add(e);let o=-1,s;for(let t=n;t<this.items.length;t++)if(this.items[t].diagnostic==e){o=t;break}o<0?(s=new Md(this.view,e),this.items.splice(n,0,s),r=!0):(s=this.items[o],o>n&&(this.items.splice(n,o-n),r=!0)),t&&s.diagnostic==t.diagnostic?s.dom.hasAttribute(`aria-selected`)||(s.dom.setAttribute(`aria-selected`,`true`),i=s):s.dom.hasAttribute(`aria-selected`)&&s.dom.removeAttribute(`aria-selected`),n++}});n<this.items.length&&!(this.items.length==1&&this.items[0].diagnostic.from<0);)r=!0,this.items.pop();this.items.length==0&&(this.items.push(new Md(this.view,{from:-1,to:-1,severity:`info`,message:this.view.state.phrase(`No diagnostics`)})),r=!0),i?(this.list.setAttribute(`aria-activedescendant`,i.id),this.view.requestMeasure({key:this,read:()=>({sel:i.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:e,panel:t})=>{let n=t.height/this.list.offsetHeight;e.top<t.top?this.list.scrollTop-=(t.top-e.top)/n:e.bottom>t.bottom&&(this.list.scrollTop+=(e.bottom-t.bottom)/n)}})):this.selectedIndex<0&&this.list.removeAttribute(`aria-activedescendant`),r&&this.sync()}sync(){let e=this.list.firstChild;function t(){let t=e;e=t.nextSibling,t.remove()}for(let n of this.items)if(n.dom.parentNode==this.list){for(;e!=n.dom;)t();e=n.dom.nextSibling}else this.list.insertBefore(n.dom,e);for(;e;)t()}moveSelection(e){if(this.selectedIndex<0)return;let t=hd(this.view.state.field(J).diagnostics,this.items[e].diagnostic);t&&this.view.dispatch({selection:{anchor:t.from,head:t.to},scrollIntoView:!0,effects:bd.of(t)})}static open(t){return new e(t)}};function Pd(e,t=`viewBox="0 0 40 40"`){return`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" ${t}>${encodeURIComponent(e)}</svg>')`}function Fd(e){return Pd(`<path d="m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0" stroke="${e}" fill="none" stroke-width=".7"/>`,`width="6" height="3"`)}var Id=k.baseTheme({".cm-diagnostic":{padding:`3px 6px 3px 8px`,marginLeft:`-1px`,display:`block`,whiteSpace:`pre-wrap`},".cm-diagnostic-error":{borderLeft:`5px solid #d11`},".cm-diagnostic-warning":{borderLeft:`5px solid orange`},".cm-diagnostic-info":{borderLeft:`5px solid #999`},".cm-diagnostic-hint":{borderLeft:`5px solid #66d`},".cm-diagnosticAction":{font:`inherit`,border:`none`,padding:`2px 4px`,backgroundColor:`#444`,color:`white`,borderRadius:`3px`,marginLeft:`8px`,cursor:`pointer`},".cm-diagnosticSource":{fontSize:`70%`,opacity:.7},".cm-lintRange":{backgroundPosition:`left bottom`,backgroundRepeat:`repeat-x`,paddingBottom:`0.7px`},".cm-lintRange-error":{backgroundImage:Fd(`#d11`)},".cm-lintRange-warning":{backgroundImage:Fd(`orange`)},".cm-lintRange-info":{backgroundImage:Fd(`#999`)},".cm-lintRange-hint":{backgroundImage:Fd(`#66d`)},".cm-lintRange-active":{backgroundColor:`#ffdd9980`},".cm-tooltip-lint":{padding:0,margin:0},".cm-lintPoint":{position:`relative`,"&:after":{content:`""`,position:`absolute`,bottom:0,left:`-2px`,borderLeft:`3px solid transparent`,borderRight:`3px solid transparent`,borderBottom:`4px solid #d11`}},".cm-lintPoint-warning":{"&:after":{borderBottomColor:`orange`}},".cm-lintPoint-info":{"&:after":{borderBottomColor:`#999`}},".cm-lintPoint-hint":{"&:after":{borderBottomColor:`#66d`}},".cm-panel.cm-panel-lint":{position:`relative`,"& ul":{maxHeight:`100px`,overflowY:`auto`,"& [aria-selected]":{backgroundColor:`#ddd`,"& u":{textDecoration:`underline`}},"&:focus [aria-selected]":{background_fallback:`#bdf`,backgroundColor:`Highlight`,color_fallback:`white`,color:`HighlightText`},"& u":{textDecoration:`none`},padding:0,margin:0},"& [name=close]":{position:`absolute`,top:`0`,right:`2px`,background:`inherit`,border:`none`,font:`inherit`,padding:0,margin:0}},"&dark .cm-lintRange-active":{backgroundColor:`#86714a80`},"&dark .cm-panel.cm-panel-lint ul":{"& [aria-selected]":{backgroundColor:`#2e343e`}}});function Ld(e){return e==`error`?4:e==`warning`?3:e==`info`?2:1}function Rd(e){let t=`hint`,n=1;for(let r of e){let e=Ld(r.severity);e>n&&(n=e,t=r.severity)}return t}var zd=[J,k.decorations.compute([J],e=>{let{selected:t,panel:n}=e.field(J);return!t||!n||t.from==t.to?A.none:A.set([xd.range(t.from,t.to)])}),Be(Sd,{hideOn:gd}),Id],Bd=[mt(),at(),ut(),ec(),We(),He(),ft(),me.allowMultipleSelections.of(!0),Oe(),Se(Ve,{fallback:!0}),ze(),Et(),wt(),st(),h(),Ie(),_u(),et.of([...Ct,...nu,...od,...vc,...ht,...Tt,...Ed])];ut(),ec(),He(),Se(Ve,{fallback:!0}),et.of([...nu,...vc]);function Vd(e,t){let n=(0,Nt.c)(4),r=t===void 0?!1:t,[i,a]=(0,Mt.useState)(void 0),o=(0,Mt.useRef)(null),s,c;return n[0]!==r||n[1]!==e?(s=()=>{if(r||e.length===0){a(void 0);return}let t=function(){let t=window.innerHeight/2,n,r;for(let i of e){let e=document.getElementById(i);if(!e)continue;let a=e.getBoundingClientRect().top;a<0?n=i:r===void 0&&a<t&&(r=i)}a(r??n??e[0])},n=function(){o.current===null&&(o.current=requestAnimationFrame(()=>{o.current=null,t()}))};return document.addEventListener(`scroll`,n,{capture:!0,passive:!0}),t(),()=>{document.removeEventListener(`scroll`,n,{capture:!0}),o.current!==null&&(cancelAnimationFrame(o.current),o.current=null)}},c=[e,r],n[0]=r,n[1]=e,n[2]=s,n[3]=c):(s=n[2],c=n[3]),(0,Mt.useEffect)(s,c),i}var Y=n(),Hd=300;async function Ud(e){let t=await fetch(`/api/page-headings?docName=${encodeURIComponent(e)}`);if(!t.ok)throw Error(`Server error: ${t.status} ${t.statusText}`);let n=await t.json();if(!n.ok)throw Error(n.error??`Failed to load headings`);return n.headings??[]}var Wd=32,Gd=6,Kd=6,qd=8;function Jd(e){return(e-1)*qd+.5}function Yd(e){if(e.length===0)return``;let t=[];for(let n=0;n<e.length;n++){let r=Jd(e[n].level),i=n*Wd+Gd,a=n*Wd+Wd-Kd;t.push(`${n===0?`M`:`L`}${r} ${i}`),t.push(`L${r} ${a}`)}return t.join(` `)}var Xd=`open-knowledge:outline-nav`;function Zd(e){let t=(0,Nt.c)(2),n;return t[0]===e?n=t[1]:(n=(0,Y.jsx)(ne,{name:`outline-panel`,children:(0,Y.jsx)(Qd,{...e})}),t[0]=e,t[1]=n),n}function Qd(e){let t=(0,Nt.c)(54),{docName:n,isSourceMode:r,className:m}=e,te=m===void 0?``:m,{pages:ne,loading:re}=de(),ie=a(),{activeProvider:ae,activeDocName:oe}=ee(),se,ce;t[0]===n?(se=t[1],ce=t[2]):(se=[`page-headings`,n],ce=()=>Ud(n),t[0]=n,t[1]=se,t[2]=ce);let le;t[3]!==n||t[4]!==re||t[5]!==ne?(le=!re&&ne.has(n),t[3]=n,t[4]=re,t[5]=ne,t[6]=le):le=t[6];let ue;t[7]!==se||t[8]!==ce||t[9]!==le?(ue={queryKey:se,queryFn:ce,enabled:le,staleTime:1/0},t[7]=se,t[8]=ce,t[9]=le,t[10]=ue):ue=t[10];let{data:fe,isLoading:h,error:g}=f(ue),_;t[11]===fe?_=t[12]:(_=fe===void 0?[]:fe,t[11]=fe,t[12]=_);let v=_,y,pe;t[13]!==oe||t[14]!==ae||t[15]!==n||t[16]!==ie?(y=()=>{if(!ae||oe!==n)return;let e=ae.document,t=null,r=()=>{t!==null&&clearTimeout(t),t=setTimeout(()=>{t=null,ie.invalidateQueries({queryKey:[`page-headings`,n]})},Hd)};return e.on(`update`,r),()=>{e.off(`update`,r),t!==null&&clearTimeout(t)}},pe=[ae,oe,n,ie],t[13]=oe,t[14]=ae,t[15]=n,t[16]=ie,t[17]=y,t[18]=pe):(y=t[17],pe=t[18]),(0,Mt.useEffect)(y,pe);let b;t[19]===v?b=t[20]:(b=v.map(ef),t[19]=v,t[20]=b);let x=Vd(b,r),me;t[21]!==x||t[22]!==v?(me=x?v.findIndex(e=>e.slug===x):-1,t[21]=x,t[22]=v,t[23]=me):me=t[23];let he=me,S;t[24]!==n||t[25]!==r?(S=function(e,t){let i={index:e,slug:t,mode:r?`source`:`wysiwyg`};i.mode===`source`&&Ft(n,{kind:`outline`,detail:i}),window.dispatchEvent(new CustomEvent(Xd,{detail:i}))},t[24]=n,t[25]=r,t[26]=S):S=t[26];let ge=S,_e=(v.reduce($d,1)-1)*qd+1,C=v.length*Wd,ve;t[27]===v?ve=t[28]:(ve=Yd(v),t[27]=v,t[28]=ve);let ye=ve,be=ye?`url("data:image/svg+xml,${encodeURIComponent(`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${_e} ${C}"><path d="${ye}" stroke="black" stroke-width="2" fill="none" /></svg>`)}")`:void 0,w=he>=0?he*Wd+Gd:0,xe=he>=0?Wd-Gd-Kd:0,Se;t[29]===Symbol.for(`react.memo_cache_sentinel`)?(Se=(0,Y.jsx)(u,{children:`Outline`}),t[29]=Se):Se=t[29];let T;t[30]!==v.length||t[31]!==h?(T=!h&&(0,Y.jsx)(l,{children:v.length}),t[30]=v.length,t[31]=h,t[32]=T):T=t[32];let E;t[33]===T?E=t[34]:(E=(0,Y.jsxs)(c,{children:[Se,T]}),t[33]=T,t[34]=E);let Ce;t[35]!==x||t[36]!==g||t[37]!==ge||t[38]!==v||t[39]!==h||t[40]!==ye||t[41]!==be||t[42]!==C||t[43]!==_e||t[44]!==xe||t[45]!==w?(Ce=g?(0,Y.jsx)(i,{className:`px-2`,children:g instanceof Error?g.message:`Failed to load headings`}):v.length===0&&!h?(0,Y.jsx)(o,{className:`px-2`,children:`No headings yet.`}):(0,Y.jsxs)(`nav`,{"aria-label":`Document outline`,className:`relative`,children:[(0,Y.jsx)(`svg`,{width:_e,height:C,className:`pointer-events-none absolute left-0 top-0`,"aria-hidden":`true`,children:(0,Y.jsx)(`path`,{d:ye,fill:`none`,strokeWidth:`1`,style:{stroke:`var(--border)`}})}),be&&(0,Y.jsx)(`div`,{className:`pointer-events-none absolute left-0 top-0`,style:{width:_e,height:C,maskImage:be,WebkitMaskImage:be},children:(0,Y.jsx)(`div`,{className:`w-full motion-safe:[transition:transform_0.25s_var(--ease-out-strong),height_0.1s_var(--ease-out-strong)]`,style:{transform:`translateY(${w}px)`,height:xe,backgroundColor:`var(--primary)`}})}),v.map((e,t)=>{let n=e.slug===x;return(0,Y.jsx)(`button`,{type:`button`,"aria-current":n?`location`:void 0,onClick:()=>ge(t,e.slug),className:p(`w-full cursor-pointer truncate py-1.5 pe-2 text-left text-sm transition-colors`,n?`font-medium text-primary`:`text-muted-foreground hover:text-foreground`),style:{paddingLeft:`${(e.level-1)*qd+16}px`},title:e.text,children:e.text},t)})]}),t[35]=x,t[36]=g,t[37]=ge,t[38]=v,t[39]=h,t[40]=ye,t[41]=be,t[42]=C,t[43]=_e,t[44]=xe,t[45]=w,t[46]=Ce):Ce=t[46];let D;t[47]!==h||t[48]!==Ce?(D=(0,Y.jsx)(s,{className:`px-3 py-2`,"aria-busy":h,children:Ce}),t[47]=h,t[48]=Ce,t[49]=D):D=t[49];let we;return t[50]!==te||t[51]!==E||t[52]!==D?(we=(0,Y.jsxs)(d,{className:te,children:[E,D]}),t[50]=te,t[51]=E,t[52]=D,t[53]=we):we=t[53],we}function $d(e,t){return Math.max(e,t.level)}function ef(e){return e.slug}function tf(e){if(!e)return`plaintext`;if(e.types.includes(`vscode-editor-data`))return`vscode`;if(e.types.includes(`text/x-gfm`))return`gfm`;let t=e.getData(`text/html`);return t?/data-pm-slice/i.test(t)?`pm-origin`:/docs-internal-guid-/i.test(t)?`gdocs`:/xmlns:o="urn:schemas-microsoft-com:office/i.test(t)||/<meta[^>]*Generator[^>]*Microsoft Word/i.test(t)?`word`:/class="gmail_|class='gmail_/i.test(t)?`gmail`:/notionvc:/i.test(t)?`notion`:/Cocoa HTML Writer/i.test(t)?`apple`:/c-message_kit__|c-message__|c-compose/i.test(t)?`slack`:/google-sheets-html-origin/i.test(t)?`gsheets`:/data-hovercard-type=/i.test(t)?`github`:`generic`:`plaintext`}var nf=250,rf=100;function X(e,t){let n=performance.now()-e;n<(t.op===`paste`?nf:rf)||console.warn(JSON.stringify({event:`clipboard-slow-op`,op:t.op,view:t.view,elapsedMs:Math.round(n),branch:t.branch,source:t.source,...t.htmlBytes==null?{}:{htmlBytes:t.htmlBytes}}))}function Z(e){console.warn(JSON.stringify({event:`clipboard-source-detected`,view:e.view,source:e.source,branch:e.branch}))}function Q(e){console.warn(JSON.stringify({event:`clipboard-html-conversion-failed`,view:e.view,stage:e.stage,source:e.source,...e.branch==null?{}:{branch:e.branch},reason:e.reason,...e.errorClass==null?{}:{errorClass:e.errorClass},...e.htmlBytes==null?{}:{htmlBytes:e.htmlBytes}}))}function af(e){console.warn(JSON.stringify({event:`clipboard-serialize-failed`,view:e.view,kind:e.kind,reason:e.reason}))}function of(e){console.warn(JSON.stringify({event:`clipboard-chunked-insert-failed`,view:e.view,chunksCompleted:e.chunksCompleted,totalChunks:e.totalChunks,bytesWritten:e.bytesWritten,bytesRemaining:e.bytesRemaining,reason:e.reason}))}function $(e){if(e instanceof fe)return`HtmlPayloadTooLargeError`;if(e instanceof ue)return`ChunkedInsertError`;if(e instanceof Error&&e.name&&e.name!==`Error`)return e.name}var sf=/^```/m,cf=/^#{1,6} /m,lf=/^[-*+] /m,uf=/^\d+[.)] /m,df=/\[[^\]\n]+\]\([^)\n]+\)/,ff=/^\|.*\|$/m,pf=/^\|?\s*(:?-+:?)(\s*\|\s*:?-+:?)+\s*\|?$/m,mf=/\$\$[\s\S]+?\$\$/;function hf(e){if(!e)return!1;let t=0;sf.test(e)&&t++,cf.test(e)&&t++,lf.test(e)&&t++,uf.test(e)&&t++,df.test(e)&&t++,ff.test(e)&&pf.test(e)&&t++,mf.test(e)&&t++;let n=e.split(`
29
+ `:t==`r`?`\r`:t==`t`?` `:`\\`)}eq(e){return this.search==e.search&&this.replace==e.replace&&this.caseSensitive==e.caseSensitive&&this.regexp==e.regexp&&this.wholeWord==e.wholeWord&&this.test==e.test}create(){return this.regexp?new zu(this):new Nu(this)}getCursor(e,t=0,n){let r=e.doc?e:me.create({doc:e});return n??=r.doc.length,this.regexp?Fu(this,r,t,n):ju(this,r,t,n)}},ku=class{constructor(e){this.spec=e}};function Au(e,t,n){return(r,i,a,o)=>n&&!n(r,i,a,o)?!1:e(r>=o&&i<=o+a.length?a.slice(r-o,i-o):t.doc.sliceString(r,i),t,r,i)}function ju(e,t,n,r){let i;return e.wholeWord&&(i=Mu(t.doc,t.charCategorizer(t.selection.main.head))),e.test&&(i=Au(e.test,t,i)),new au(t.doc,e.unquoted,n,r,e.caseSensitive?void 0:e=>e.toLowerCase(),i)}function Mu(e,t){return(n,r,i,a)=>((a>n||a+i.length<r)&&(a=Math.max(0,n-2),i=e.sliceString(a,Math.min(e.length,r+2))),(t(Iu(i,n-a))!=y.Word||t(Lu(i,n-a))!=y.Word)&&(t(Lu(i,r-a))!=y.Word||t(Iu(i,r-a))!=y.Word))}var Nu=class extends ku{constructor(e){super(e)}nextMatch(e,t,n){let r=ju(this.spec,e,n,e.doc.length).nextOverlapping();if(r.done){let n=Math.min(e.doc.length,t+this.spec.unquoted.length);r=ju(this.spec,e,0,n).nextOverlapping()}return r.done||r.value.from==t&&r.value.to==n?null:r.value}prevMatchInRange(e,t,n){for(let r=n;;){let n=Math.max(t,r-1e4-this.spec.unquoted.length),i=ju(this.spec,e,n,r),a=null;for(;!i.nextOverlapping().done;)a=i.value;if(a)return a;if(n==t)return null;r-=1e4}}prevMatch(e,t,n){let r=this.prevMatchInRange(e,0,t);return r||=this.prevMatchInRange(e,Math.max(0,n-this.spec.unquoted.length),e.doc.length),r&&(r.from!=t||r.to!=n)?r:null}getReplacement(e){return this.spec.unquote(this.spec.replace)}matchAll(e,t){let n=ju(this.spec,e,0,e.doc.length),r=[];for(;!n.next().done;){if(r.length>=t)return null;r.push(n.value)}return r}highlight(e,t,n,r){let i=ju(this.spec,e,Math.max(0,t-this.spec.unquoted.length),Math.min(n+this.spec.unquoted.length,e.doc.length));for(;!i.next().done;)r(i.value.from,i.value.to)}};function Pu(e,t,n){return(r,i,a)=>(!n||n(r,i,a))&&e(a[0],t,r,i)}function Fu(e,t,n,r){let i;return e.wholeWord&&(i=Ru(t.charCategorizer(t.selection.main.head))),e.test&&(i=Pu(e.test,t,i)),new cu(t.doc,e.search,{ignoreCase:!e.caseSensitive,test:i},n,r)}function Iu(e,t){return e.slice(je(e,t,!1),t)}function Lu(e,t){return e.slice(t,je(e,t))}function Ru(e){return(t,n,r)=>!r[0].length||(e(Iu(r.input,r.index))!=y.Word||e(Lu(r.input,r.index))!=y.Word)&&(e(Lu(r.input,r.index+r[0].length))!=y.Word||e(Iu(r.input,r.index+r[0].length))!=y.Word)}var zu=class extends ku{nextMatch(e,t,n){let r=Fu(this.spec,e,n,e.doc.length).next();return r.done&&(r=Fu(this.spec,e,0,t).next()),r.done?null:r.value}prevMatchInRange(e,t,n){for(let r=1;;r++){let i=Math.max(t,n-r*1e4),a=Fu(this.spec,e,i,n),o=null;for(;!a.next().done;)o=a.value;if(o&&(i==t||o.from>i+10))return o;if(i==t)return null}}prevMatch(e,t,n){return this.prevMatchInRange(e,0,t)||this.prevMatchInRange(e,n,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace).replace(/\$([$&]|\d+)/g,(t,n)=>{if(n==`&`)return e.match[0];if(n==`$`)return`$`;for(let t=n.length;t>0;t--){let r=+n.slice(0,t);if(r>0&&r<e.match.length)return e.match[r]+n.slice(t)}return t})}matchAll(e,t){let n=Fu(this.spec,e,0,e.doc.length),r=[];for(;!n.next().done;){if(r.length>=t)return null;r.push(n.value)}return r}highlight(e,t,n,r){let i=Fu(this.spec,e,Math.max(0,t-250),Math.min(n+250,e.doc.length));for(;!i.next().done;)r(i.value.from,i.value.to)}},Bu=E.define(),Vu=E.define(),Hu=D.define({create(e){return new Uu(td(e).create(),null)},update(e,t){for(let n of t.effects)n.is(Bu)?e=new Uu(n.value.create(),e.panel):n.is(Vu)&&(e=new Uu(e.query,n.value?ed:null));return e},provide:e=>Ge.from(e,e=>e.panel)}),Uu=class{constructor(e,t){this.query=e,this.panel=t}},Wu=A.mark({class:`cm-searchMatch`}),Gu=A.mark({class:`cm-searchMatch cm-searchMatch-selected`}),Ku=Ne.fromClass(class{constructor(e){this.view=e,this.decorations=this.highlight(e.state.field(Hu))}update(e){let t=e.state.field(Hu);(t!=e.startState.field(Hu)||e.docChanged||e.selectionSet||e.viewportChanged)&&(this.decorations=this.highlight(t))}highlight({query:e,panel:t}){if(!t||!e.spec.valid)return A.none;let{view:n}=this,r=new Xe;for(let t=0,i=n.visibleRanges,a=i.length;t<a;t++){let{from:o,to:s}=i[t];for(;t<a-1&&s>i[t+1].from-500;)s=i[++t].to;e.highlight(n.state,o,s,(e,t)=>{let i=n.state.selection.ranges.some(n=>n.from==e&&n.to==t);r.add(e,t,i?Gu:Wu)})}return r.finish()}},{decorations:e=>e.decorations});function qu(e){return t=>{let n=t.state.field(Hu,!1);return n&&n.query.spec.valid?e(t,n):id(t)}}var Ju=qu((e,{query:t})=>{let{to:n}=e.state.selection.main,r=t.nextMatch(e.state,n,n);if(!r)return!1;let i=O.single(r.from,r.to),a=e.state.facet(Du);return e.dispatch({selection:i,effects:[ud(e,r),a.scrollToMatch(i.main,e)],userEvent:`select.search`}),rd(e),!0}),Yu=qu((e,{query:t})=>{let{state:n}=e,{from:r}=n.selection.main,i=t.prevMatch(n,r,r);if(!i)return!1;let a=O.single(i.from,i.to),o=e.state.facet(Du);return e.dispatch({selection:a,effects:[ud(e,i),o.scrollToMatch(a.main,e)],userEvent:`select.search`}),rd(e),!0}),Xu=qu((e,{query:t})=>{let n=t.matchAll(e.state,1e3);return!n||!n.length?!1:(e.dispatch({selection:O.create(n.map(e=>O.range(e.from,e.to))),userEvent:`select.search.matches`}),!0)}),Zu=({state:e,dispatch:t})=>{let n=e.selection;if(n.ranges.length>1||n.main.empty)return!1;let{from:r,to:i}=n.main,a=[],o=0;for(let t=new au(e.doc,e.sliceDoc(r,i));!t.next().done;){if(a.length>1e3)return!1;t.value.from==r&&(o=a.length),a.push(O.range(t.value.from,t.value.to))}return t(e.update({selection:O.create(a,o),userEvent:`select.search.matches`})),!0},Qu=qu((e,{query:t})=>{let{state:n}=e,{from:r,to:i}=n.selection.main;if(n.readOnly)return!1;let a=t.nextMatch(n,r,r);if(!a)return!1;let o=a,s=[],c,l,u=[];o.from==r&&o.to==i&&(l=n.toText(t.getReplacement(o)),s.push({from:o.from,to:o.to,insert:l}),o=t.nextMatch(n,o.from,o.to),u.push(k.announce.of(n.phrase(`replaced match on line $`,n.doc.lineAt(r).number)+`.`)));let d=e.state.changes(s);return o&&(c=O.single(o.from,o.to).map(d),u.push(ud(e,o)),u.push(n.facet(Du).scrollToMatch(c.main,e))),e.dispatch({changes:d,selection:c,effects:u,userEvent:`input.replace`}),!0}),$u=qu((e,{query:t})=>{if(e.state.readOnly)return!1;let n=t.matchAll(e.state,1e9).map(e=>{let{from:n,to:r}=e;return{from:n,to:r,insert:t.getReplacement(e)}});if(!n.length)return!1;let r=e.state.phrase(`replaced $ matches`,n.length)+`.`;return e.dispatch({changes:n,effects:k.announce.of(r),userEvent:`input.replace.all`}),!0});function ed(e){return e.state.facet(Du).createPanel(e)}function td(e,t){let n=e.selection.main,r=n.empty||n.to>n.from+100?``:e.sliceDoc(n.from,n.to);if(t&&!r)return t;let i=e.facet(Du);return new Ou({search:t?.literal??i.literal?r:r.replace(/\n/g,`\\n`),caseSensitive:t?.caseSensitive??i.caseSensitive,literal:t?.literal??i.literal,regexp:t?.regexp??i.regexp,wholeWord:t?.wholeWord??i.wholeWord})}function nd(e){let t=rt(e,ed);return t&&t.dom.querySelector(`[main-field]`)}function rd(e){let t=nd(e);t&&t==e.root.activeElement&&t.select()}var id=e=>{let t=e.state.field(Hu,!1);if(t&&t.panel){let n=nd(e);if(n&&n!=e.root.activeElement){let r=td(e.state,t.query.spec);r.valid&&e.dispatch({effects:Bu.of(r)}),n.focus(),n.select()}}else e.dispatch({effects:[Vu.of(!0),t?Bu.of(td(e.state,t.query.spec)):E.appendConfig.of(fd)]});return!0},ad=e=>{let t=e.state.field(Hu,!1);if(!t||!t.panel)return!1;let n=rt(e,ed);return n&&n.dom.contains(e.root.activeElement)&&e.focus(),e.dispatch({effects:Vu.of(!1)}),!0},od=[{key:`Mod-f`,run:id,scope:`editor search-panel`},{key:`F3`,run:Ju,shift:Yu,scope:`editor search-panel`,preventDefault:!0},{key:`Mod-g`,run:Ju,shift:Yu,scope:`editor search-panel`,preventDefault:!0},{key:`Escape`,run:ad,scope:`editor search-panel`},{key:`Mod-Shift-l`,run:Zu},{key:`Mod-Alt-g`,run:mu},{key:`Mod-d`,run:Eu,preventDefault:!0}],sd=class{constructor(e){this.view=e;let t=this.query=e.state.field(Hu).query.spec;this.commit=this.commit.bind(this),this.searchField=j(`input`,{value:t.search,placeholder:q(e,`Find`),"aria-label":q(e,`Find`),class:`cm-textfield`,name:`search`,form:``,"main-field":`true`,onchange:this.commit,onkeyup:this.commit}),this.replaceField=j(`input`,{value:t.replace,placeholder:q(e,`Replace`),"aria-label":q(e,`Replace`),class:`cm-textfield`,name:`replace`,form:``,onchange:this.commit,onkeyup:this.commit}),this.caseField=j(`input`,{type:`checkbox`,name:`case`,form:``,checked:t.caseSensitive,onchange:this.commit}),this.reField=j(`input`,{type:`checkbox`,name:`re`,form:``,checked:t.regexp,onchange:this.commit}),this.wordField=j(`input`,{type:`checkbox`,name:`word`,form:``,checked:t.wholeWord,onchange:this.commit});function n(e,t,n){return j(`button`,{class:`cm-button`,name:e,onclick:t,type:`button`},n)}this.dom=j(`div`,{onkeydown:e=>this.keydown(e),class:`cm-search`},[this.searchField,n(`next`,()=>Ju(e),[q(e,`next`)]),n(`prev`,()=>Yu(e),[q(e,`previous`)]),n(`select`,()=>Xu(e),[q(e,`all`)]),j(`label`,null,[this.caseField,q(e,`match case`)]),j(`label`,null,[this.reField,q(e,`regexp`)]),j(`label`,null,[this.wordField,q(e,`by word`)]),...e.state.readOnly?[]:[j(`br`),this.replaceField,n(`replace`,()=>Qu(e),[q(e,`replace`)]),n(`replaceAll`,()=>$u(e),[q(e,`replace all`)])],j(`button`,{name:`close`,onclick:()=>ad(e),"aria-label":q(e,`close`),type:`button`},[`×`])])}commit(){let e=new Ou({search:this.searchField.value,caseSensitive:this.caseField.checked,regexp:this.reField.checked,wholeWord:this.wordField.checked,replace:this.replaceField.value});e.eq(this.query)||(this.query=e,this.view.dispatch({effects:Bu.of(e)}))}keydown(e){tt(this.view,e,`search-panel`)?e.preventDefault():e.keyCode==13&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?Yu:Ju)(this.view)):e.keyCode==13&&e.target==this.replaceField&&(e.preventDefault(),Qu(this.view))}update(e){for(let t of e.transactions)for(let e of t.effects)e.is(Bu)&&!e.value.eq(this.query)&&this.setQuery(e.value)}setQuery(e){this.query=e,this.searchField.value=e.search,this.replaceField.value=e.replace,this.caseField.checked=e.caseSensitive,this.reField.checked=e.regexp,this.wordField.checked=e.wholeWord}mount(){this.searchField.select()}get pos(){return 80}get top(){return this.view.state.facet(Du).top}};function q(e,t){return e.state.phrase(t)}var cd=30,ld=/[\s\.,:;?!]/;function ud(e,{from:t,to:n}){let r=e.state.doc.lineAt(t),i=e.state.doc.lineAt(n).to,a=Math.max(r.from,t-cd),o=Math.min(i,n+cd),s=e.state.sliceDoc(a,o);if(a!=r.from){for(let e=0;e<cd;e++)if(!ld.test(s[e+1])&&ld.test(s[e])){s=s.slice(e);break}}if(o!=i){for(let e=s.length-1;e>s.length-cd;e--)if(!ld.test(s[e-1])&&ld.test(s[e])){s=s.slice(0,e);break}}return k.announce.of(`${e.state.phrase(`current match`)}. ${s} ${e.state.phrase(`on line`)} ${r.number}.`)}var dd=k.baseTheme({".cm-panel.cm-search":{padding:`2px 6px 4px`,position:`relative`,"& [name=close]":{position:`absolute`,top:`0`,right:`4px`,backgroundColor:`inherit`,border:`none`,font:`inherit`,padding:0,margin:0},"& input, & button, & label":{margin:`.2em .6em .2em 0`},"& input[type=checkbox]":{marginRight:`.2em`},"& label":{fontSize:`80%`,whiteSpace:`pre`}},"&light .cm-searchMatch":{backgroundColor:`#ffff0054`},"&dark .cm-searchMatch":{backgroundColor:`#00ffff8a`},"&light .cm-searchMatch-selected":{backgroundColor:`#ff6a0054`},"&dark .cm-searchMatch-selected":{backgroundColor:`#ff00ff8a`}}),fd=[Hu,Qe.low(Ku),dd],pd=class{constructor(e,t,n){this.from=e,this.to=t,this.diagnostic=n}},md=class e{constructor(e,t,n){this.diagnostics=e,this.panel=t,this.selected=n}static init(t,n,r){let i=r.facet(Dd).markerFilter;i&&(t=i(t,r));let a=t.slice().sort((e,t)=>e.from-t.from||e.to-t.to),o=new Xe,s=[],c=0,l=r.doc.iter(),u=0,d=r.doc.length;for(let e=0;;){let t=e==a.length?null:a[e];if(!t&&!s.length)break;let n,r;if(s.length)n=c,r=s.reduce((e,t)=>Math.min(e,t.to),t&&t.from>n?t.from:1e8);else{if(n=t.from,n>d)break;r=t.to,s.push(t),e++}for(;e<a.length;){let t=a[e];if(t.from==n&&(t.to>t.from||t.to==n))s.push(t),e++,r=Math.min(t.to,r);else{r=Math.min(t.from,r);break}}r=Math.min(r,d);let i=!1;if(s.some(e=>e.from==n&&(e.to==r||r==d))&&(i=n==r,!i&&r-n<10)){let e=n-(u+l.value.length);e>0&&(l.next(e),u=n);for(let e=n;;){if(e>=r){i=!0;break}if(!l.lineBreak&&u+l.value.length>e)break;e=u+l.value.length,u+=l.value.length,l.next()}}let f=Rd(s);if(i)o.add(n,n,A.widget({widget:new jd(f),diagnostics:s.slice()}));else{let e=s.reduce((e,t)=>t.markClass?e+` `+t.markClass:e,``);o.add(n,r,A.mark({class:`cm-lintRange cm-lintRange-`+f+e,diagnostics:s.slice(),inclusiveEnd:s.some(e=>e.to>r)}))}if(c=r,c==d)break;for(let e=0;e<s.length;e++)s[e].to<=c&&s.splice(e--,1)}let f=o.finish();return new e(f,n,hd(f))}};function hd(e,t=null,n=0){let r=null;return e.between(n,1e9,(e,n,{spec:i})=>{if(!(t&&i.diagnostics.indexOf(t)<0))if(!r)r=new pd(e,n,t||i.diagnostics[0]);else if(i.diagnostics.indexOf(r.diagnostic)<0)return!1;else r=new pd(r.from,n,r.diagnostic)}),r}function gd(e,t){let n=t.pos,r=t.end||n,i=e.state.facet(Dd).hideOn(e,n,r);if(i!=null)return i;let a=e.startState.doc.lineAt(t.pos);return!!(e.effects.some(e=>e.is(vd))||e.changes.touchesRange(a.from,Math.max(a.to,r)))}function _d(e,t){return e.field(J,!1)?t:t.concat(E.appendConfig.of(zd))}var vd=E.define(),yd=E.define(),bd=E.define(),J=D.define({create(){return new md(A.none,null,null)},update(e,t){if(t.docChanged&&e.diagnostics.size){let n=e.diagnostics.map(t.changes),r=null,i=e.panel;if(e.selected){let i=t.changes.mapPos(e.selected.from,1);r=hd(n,e.selected.diagnostic,i)||hd(n,null,i)}!n.size&&i&&t.state.facet(Dd).autoPanel&&(i=null),e=new md(n,i,r)}for(let n of t.effects)if(n.is(vd)){let r=t.state.facet(Dd).autoPanel?n.value.length?Nd.open:null:e.panel;e=md.init(n.value,r,t.state)}else n.is(yd)?e=new md(e.diagnostics,n.value?Nd.open:null,e.selected):n.is(bd)&&(e=new md(e.diagnostics,e.panel,n.value));return e},provide:e=>[Ge.from(e,e=>e.panel),k.decorations.from(e,e=>e.diagnostics)]}),xd=A.mark({class:`cm-lintRange cm-lintRange-active`});function Sd(e,t,n){let{diagnostics:r}=e.state.field(J),i,a=-1,o=-1;r.between(t-+(n<0),t+ +(n>0),(e,r,{spec:s})=>{if(t>=e&&t<=r&&(e==r||(t>e||n>0)&&(t<r||n<0)))return i=s.diagnostics,a=e,o=r,!1});let s=e.state.facet(Dd).tooltipFilter;return i&&s&&(i=s(i,e.state)),i?{pos:a,end:o,above:e.state.doc.lineAt(a).to<o,create(){return{dom:Cd(e,i)}}}:null}function Cd(e,t){return j(`ul`,{class:`cm-tooltip-lint`},t.map(t=>Ad(e,t,!1)))}var wd=e=>{let t=e.state.field(J,!1);(!t||!t.panel)&&e.dispatch({effects:_d(e.state,[yd.of(!0)])});let n=rt(e,Nd.open);return n&&n.dom.querySelector(`.cm-panel-lint ul`).focus(),!0},Td=e=>{let t=e.state.field(J,!1);return!t||!t.panel?!1:(e.dispatch({effects:yd.of(!1)}),!0)},Ed=[{key:`Mod-Shift-m`,run:wd,preventDefault:!0},{key:`F8`,run:e=>{let t=e.state.field(J,!1);if(!t)return!1;let n=e.state.selection.main,r=hd(t.diagnostics,null,n.to+1);return!r&&(r=hd(t.diagnostics,null,0),!r||r.from==n.from&&r.to==n.to)?!1:(e.dispatch({selection:{anchor:r.from,head:r.to},scrollIntoView:!0}),!0)}}],Dd=b.define({combine(e){return{sources:e.map(e=>e.source).filter(e=>e!=null),...xt(e.map(e=>e.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{delay:Math.max,markerFilter:Od,tooltipFilter:Od,needsRefresh:(e,t)=>e?t?n=>e(n)||t(n):e:t,hideOn:(e,t)=>e?t?(n,r,i)=>e(n,r,i)||t(n,r,i):e:t,autoPanel:(e,t)=>e||t})}}});function Od(e,t){return e?t?(n,r)=>t(e(n,r),r):e:t}function kd(e){let t=[];if(e)actions:for(let{name:n}of e){for(let e=0;e<n.length;e++){let r=n[e];if(/[a-zA-Z]/.test(r)&&!t.some(e=>e.toLowerCase()==r.toLowerCase())){t.push(r);continue actions}}t.push(``)}return t}function Ad(e,t,n){let r=n?kd(t.actions):[];return j(`li`,{class:`cm-diagnostic cm-diagnostic-`+t.severity},j(`span`,{class:`cm-diagnosticText`},t.renderMessage?t.renderMessage(e):t.message),t.actions?.map((n,i)=>{let a=!1,o=r=>{if(r.preventDefault(),a)return;a=!0;let i=hd(e.state.field(J).diagnostics,t);i&&n.apply(e,i.from,i.to)},{name:s}=n,c=r[i]?s.indexOf(r[i]):-1,l=c<0?s:[s.slice(0,c),j(`u`,s.slice(c,c+1)),s.slice(c+1)];return j(`button`,{type:`button`,class:`cm-diagnosticAction`+(n.markClass?` `+n.markClass:``),onclick:o,onmousedown:o,"aria-label":` Action: ${s}${c<0?``:` (access key "${r[i]})"`}.`},l)}),t.source&&j(`div`,{class:`cm-diagnosticSource`},t.source))}var jd=class extends we{constructor(e){super(),this.sev=e}eq(e){return e.sev==this.sev}toDOM(){return j(`span`,{class:`cm-lintPoint cm-lintPoint-`+this.sev})}},Md=class{constructor(e,t){this.diagnostic=t,this.id=`item_`+Math.floor(Math.random()*4294967295).toString(16),this.dom=Ad(e,t,!0),this.dom.id=this.id,this.dom.setAttribute(`role`,`option`)}},Nd=class e{constructor(e){this.view=e,this.items=[],this.list=j(`ul`,{tabIndex:0,role:`listbox`,"aria-label":this.view.state.phrase(`Diagnostics`),onkeydown:t=>{if(!(t.ctrlKey||t.altKey||t.metaKey)){if(t.keyCode==27)Td(this.view),this.view.focus();else if(t.keyCode==38||t.keyCode==33)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(t.keyCode==40||t.keyCode==34)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(t.keyCode==36)this.moveSelection(0);else if(t.keyCode==35)this.moveSelection(this.items.length-1);else if(t.keyCode==13)this.view.focus();else if(t.keyCode>=65&&t.keyCode<=90&&this.selectedIndex>=0){let{diagnostic:n}=this.items[this.selectedIndex],r=kd(n.actions);for(let i=0;i<r.length;i++)if(r[i].toUpperCase().charCodeAt(0)==t.keyCode){let t=hd(this.view.state.field(J).diagnostics,n);t&&n.actions[i].apply(e,t.from,t.to)}}else return;t.preventDefault()}},onclick:e=>{for(let t=0;t<this.items.length;t++)this.items[t].dom.contains(e.target)&&this.moveSelection(t)}}),this.dom=j(`div`,{class:`cm-panel-lint`},this.list,j(`button`,{type:`button`,name:`close`,"aria-label":this.view.state.phrase(`close`),onclick:()=>Td(this.view)},`×`)),this.update()}get selectedIndex(){let e=this.view.state.field(J).selected;if(!e)return-1;for(let t=0;t<this.items.length;t++)if(this.items[t].diagnostic==e.diagnostic)return t;return-1}update(){let{diagnostics:e,selected:t}=this.view.state.field(J),n=0,r=!1,i=null,a=new Set;for(e.between(0,this.view.state.doc.length,(e,o,{spec:s})=>{for(let e of s.diagnostics){if(a.has(e))continue;a.add(e);let o=-1,s;for(let t=n;t<this.items.length;t++)if(this.items[t].diagnostic==e){o=t;break}o<0?(s=new Md(this.view,e),this.items.splice(n,0,s),r=!0):(s=this.items[o],o>n&&(this.items.splice(n,o-n),r=!0)),t&&s.diagnostic==t.diagnostic?s.dom.hasAttribute(`aria-selected`)||(s.dom.setAttribute(`aria-selected`,`true`),i=s):s.dom.hasAttribute(`aria-selected`)&&s.dom.removeAttribute(`aria-selected`),n++}});n<this.items.length&&!(this.items.length==1&&this.items[0].diagnostic.from<0);)r=!0,this.items.pop();this.items.length==0&&(this.items.push(new Md(this.view,{from:-1,to:-1,severity:`info`,message:this.view.state.phrase(`No diagnostics`)})),r=!0),i?(this.list.setAttribute(`aria-activedescendant`,i.id),this.view.requestMeasure({key:this,read:()=>({sel:i.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:e,panel:t})=>{let n=t.height/this.list.offsetHeight;e.top<t.top?this.list.scrollTop-=(t.top-e.top)/n:e.bottom>t.bottom&&(this.list.scrollTop+=(e.bottom-t.bottom)/n)}})):this.selectedIndex<0&&this.list.removeAttribute(`aria-activedescendant`),r&&this.sync()}sync(){let e=this.list.firstChild;function t(){let t=e;e=t.nextSibling,t.remove()}for(let n of this.items)if(n.dom.parentNode==this.list){for(;e!=n.dom;)t();e=n.dom.nextSibling}else this.list.insertBefore(n.dom,e);for(;e;)t()}moveSelection(e){if(this.selectedIndex<0)return;let t=hd(this.view.state.field(J).diagnostics,this.items[e].diagnostic);t&&this.view.dispatch({selection:{anchor:t.from,head:t.to},scrollIntoView:!0,effects:bd.of(t)})}static open(t){return new e(t)}};function Pd(e,t=`viewBox="0 0 40 40"`){return`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" ${t}>${encodeURIComponent(e)}</svg>')`}function Fd(e){return Pd(`<path d="m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0" stroke="${e}" fill="none" stroke-width=".7"/>`,`width="6" height="3"`)}var Id=k.baseTheme({".cm-diagnostic":{padding:`3px 6px 3px 8px`,marginLeft:`-1px`,display:`block`,whiteSpace:`pre-wrap`},".cm-diagnostic-error":{borderLeft:`5px solid #d11`},".cm-diagnostic-warning":{borderLeft:`5px solid orange`},".cm-diagnostic-info":{borderLeft:`5px solid #999`},".cm-diagnostic-hint":{borderLeft:`5px solid #66d`},".cm-diagnosticAction":{font:`inherit`,border:`none`,padding:`2px 4px`,backgroundColor:`#444`,color:`white`,borderRadius:`3px`,marginLeft:`8px`,cursor:`pointer`},".cm-diagnosticSource":{fontSize:`70%`,opacity:.7},".cm-lintRange":{backgroundPosition:`left bottom`,backgroundRepeat:`repeat-x`,paddingBottom:`0.7px`},".cm-lintRange-error":{backgroundImage:Fd(`#d11`)},".cm-lintRange-warning":{backgroundImage:Fd(`orange`)},".cm-lintRange-info":{backgroundImage:Fd(`#999`)},".cm-lintRange-hint":{backgroundImage:Fd(`#66d`)},".cm-lintRange-active":{backgroundColor:`#ffdd9980`},".cm-tooltip-lint":{padding:0,margin:0},".cm-lintPoint":{position:`relative`,"&:after":{content:`""`,position:`absolute`,bottom:0,left:`-2px`,borderLeft:`3px solid transparent`,borderRight:`3px solid transparent`,borderBottom:`4px solid #d11`}},".cm-lintPoint-warning":{"&:after":{borderBottomColor:`orange`}},".cm-lintPoint-info":{"&:after":{borderBottomColor:`#999`}},".cm-lintPoint-hint":{"&:after":{borderBottomColor:`#66d`}},".cm-panel.cm-panel-lint":{position:`relative`,"& ul":{maxHeight:`100px`,overflowY:`auto`,"& [aria-selected]":{backgroundColor:`#ddd`,"& u":{textDecoration:`underline`}},"&:focus [aria-selected]":{background_fallback:`#bdf`,backgroundColor:`Highlight`,color_fallback:`white`,color:`HighlightText`},"& u":{textDecoration:`none`},padding:0,margin:0},"& [name=close]":{position:`absolute`,top:`0`,right:`2px`,background:`inherit`,border:`none`,font:`inherit`,padding:0,margin:0}},"&dark .cm-lintRange-active":{backgroundColor:`#86714a80`},"&dark .cm-panel.cm-panel-lint ul":{"& [aria-selected]":{backgroundColor:`#2e343e`}}});function Ld(e){return e==`error`?4:e==`warning`?3:e==`info`?2:1}function Rd(e){let t=`hint`,n=1;for(let r of e){let e=Ld(r.severity);e>n&&(n=e,t=r.severity)}return t}var zd=[J,k.decorations.compute([J],e=>{let{selected:t,panel:n}=e.field(J);return!t||!n||t.from==t.to?A.none:A.set([xd.range(t.from,t.to)])}),Be(Sd,{hideOn:gd}),Id],Bd=[mt(),at(),ut(),ec(),We(),He(),ft(),me.allowMultipleSelections.of(!0),Oe(),Se(Ve,{fallback:!0}),ze(),Et(),wt(),st(),h(),Ie(),_u(),et.of([...Ct,...nu,...od,...vc,...ht,...Tt,...Ed])];ut(),ec(),He(),Se(Ve,{fallback:!0}),et.of([...nu,...vc]);function Vd(e,t){let n=(0,Nt.c)(4),r=t===void 0?!1:t,[i,a]=(0,Mt.useState)(void 0),o=(0,Mt.useRef)(null),s,c;return n[0]!==r||n[1]!==e?(s=()=>{if(r||e.length===0){a(void 0);return}let t=function(){let t=window.innerHeight/2,n,r;for(let i of e){let e=document.getElementById(i);if(!e)continue;let a=e.getBoundingClientRect().top;a<0?n=i:r===void 0&&a<t&&(r=i)}a(r??n??e[0])},n=function(){o.current===null&&(o.current=requestAnimationFrame(()=>{o.current=null,t()}))};return document.addEventListener(`scroll`,n,{capture:!0,passive:!0}),t(),()=>{document.removeEventListener(`scroll`,n,{capture:!0}),o.current!==null&&(cancelAnimationFrame(o.current),o.current=null)}},c=[e,r],n[0]=r,n[1]=e,n[2]=s,n[3]=c):(s=n[2],c=n[3]),(0,Mt.useEffect)(s,c),i}var Y=n(),Hd=300;async function Ud(e){let t=await fetch(`/api/page-headings?docName=${encodeURIComponent(e)}`);if(!t.ok)throw Error(`Server error: ${t.status} ${t.statusText}`);let n=await t.json();if(!n.ok)throw Error(n.error??`Failed to load headings`);return n.headings??[]}var Wd=32,Gd=6,Kd=6,qd=8;function Jd(e){return(e-1)*qd+.5}function Yd(e){if(e.length===0)return``;let t=[];for(let n=0;n<e.length;n++){let r=Jd(e[n].level),i=n*Wd+Gd,a=n*Wd+Wd-Kd;t.push(`${n===0?`M`:`L`}${r} ${i}`),t.push(`L${r} ${a}`)}return t.join(` `)}var Xd=`open-knowledge:outline-nav`;function Zd(e){let t=(0,Nt.c)(2),n;return t[0]===e?n=t[1]:(n=(0,Y.jsx)(te,{name:`outline-panel`,children:(0,Y.jsx)(Qd,{...e})}),t[0]=e,t[1]=n),n}function Qd(e){let t=(0,Nt.c)(54),{docName:n,isSourceMode:r,className:m}=e,ee=m===void 0?``:m,{pages:te,loading:re}=de(),ie=a(),{activeProvider:ae,activeDocName:oe}=ne(),se,ce;t[0]===n?(se=t[1],ce=t[2]):(se=[`page-headings`,n],ce=()=>Ud(n),t[0]=n,t[1]=se,t[2]=ce);let le;t[3]!==n||t[4]!==re||t[5]!==te?(le=!re&&te.has(n),t[3]=n,t[4]=re,t[5]=te,t[6]=le):le=t[6];let ue;t[7]!==se||t[8]!==ce||t[9]!==le?(ue={queryKey:se,queryFn:ce,enabled:le,staleTime:1/0},t[7]=se,t[8]=ce,t[9]=le,t[10]=ue):ue=t[10];let{data:fe,isLoading:h,error:g}=f(ue),_;t[11]===fe?_=t[12]:(_=fe===void 0?[]:fe,t[11]=fe,t[12]=_);let v=_,y,pe;t[13]!==oe||t[14]!==ae||t[15]!==n||t[16]!==ie?(y=()=>{if(!ae||oe!==n)return;let e=ae.document,t=null,r=()=>{t!==null&&clearTimeout(t),t=setTimeout(()=>{t=null,ie.invalidateQueries({queryKey:[`page-headings`,n]})},Hd)};return e.on(`update`,r),()=>{e.off(`update`,r),t!==null&&clearTimeout(t)}},pe=[ae,oe,n,ie],t[13]=oe,t[14]=ae,t[15]=n,t[16]=ie,t[17]=y,t[18]=pe):(y=t[17],pe=t[18]),(0,Mt.useEffect)(y,pe);let b;t[19]===v?b=t[20]:(b=v.map(ef),t[19]=v,t[20]=b);let x=Vd(b,r),me;t[21]!==x||t[22]!==v?(me=x?v.findIndex(e=>e.slug===x):-1,t[21]=x,t[22]=v,t[23]=me):me=t[23];let he=me,S;t[24]!==n||t[25]!==r?(S=function(e,t){let i={index:e,slug:t,mode:r?`source`:`wysiwyg`};i.mode===`source`&&Ft(n,{kind:`outline`,detail:i}),window.dispatchEvent(new CustomEvent(Xd,{detail:i}))},t[24]=n,t[25]=r,t[26]=S):S=t[26];let ge=S,_e=(v.reduce($d,1)-1)*qd+1,C=v.length*Wd,ve;t[27]===v?ve=t[28]:(ve=Yd(v),t[27]=v,t[28]=ve);let ye=ve,be=ye?`url("data:image/svg+xml,${encodeURIComponent(`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${_e} ${C}"><path d="${ye}" stroke="black" stroke-width="2" fill="none" /></svg>`)}")`:void 0,w=he>=0?he*Wd+Gd:0,xe=he>=0?Wd-Gd-Kd:0,Se;t[29]===Symbol.for(`react.memo_cache_sentinel`)?(Se=(0,Y.jsx)(u,{children:`Outline`}),t[29]=Se):Se=t[29];let T;t[30]!==v.length||t[31]!==h?(T=!h&&(0,Y.jsx)(l,{children:v.length}),t[30]=v.length,t[31]=h,t[32]=T):T=t[32];let E;t[33]===T?E=t[34]:(E=(0,Y.jsxs)(c,{children:[Se,T]}),t[33]=T,t[34]=E);let Ce;t[35]!==x||t[36]!==g||t[37]!==ge||t[38]!==v||t[39]!==h||t[40]!==ye||t[41]!==be||t[42]!==C||t[43]!==_e||t[44]!==xe||t[45]!==w?(Ce=g?(0,Y.jsx)(i,{className:`px-2`,children:g instanceof Error?g.message:`Failed to load headings`}):v.length===0&&!h?(0,Y.jsx)(o,{className:`px-2`,children:`No headings yet.`}):(0,Y.jsxs)(`nav`,{"aria-label":`Document outline`,className:`relative`,children:[(0,Y.jsx)(`svg`,{width:_e,height:C,className:`pointer-events-none absolute left-0 top-0`,"aria-hidden":`true`,children:(0,Y.jsx)(`path`,{d:ye,fill:`none`,strokeWidth:`1`,style:{stroke:`var(--border)`}})}),be&&(0,Y.jsx)(`div`,{className:`pointer-events-none absolute left-0 top-0`,style:{width:_e,height:C,maskImage:be,WebkitMaskImage:be},children:(0,Y.jsx)(`div`,{className:`w-full motion-safe:[transition:transform_0.25s_var(--ease-out-strong),height_0.1s_var(--ease-out-strong)]`,style:{transform:`translateY(${w}px)`,height:xe,backgroundColor:`var(--primary)`}})}),v.map((e,t)=>{let n=e.slug===x;return(0,Y.jsx)(`button`,{type:`button`,"aria-current":n?`location`:void 0,onClick:()=>ge(t,e.slug),className:p(`w-full cursor-pointer truncate py-1.5 pe-2 text-left text-sm transition-colors`,n?`font-medium text-primary`:`text-muted-foreground hover:text-foreground`),style:{paddingLeft:`${(e.level-1)*qd+16}px`},title:e.text,children:e.text},t)})]}),t[35]=x,t[36]=g,t[37]=ge,t[38]=v,t[39]=h,t[40]=ye,t[41]=be,t[42]=C,t[43]=_e,t[44]=xe,t[45]=w,t[46]=Ce):Ce=t[46];let D;t[47]!==h||t[48]!==Ce?(D=(0,Y.jsx)(s,{className:`px-3 py-2`,"aria-busy":h,children:Ce}),t[47]=h,t[48]=Ce,t[49]=D):D=t[49];let we;return t[50]!==ee||t[51]!==E||t[52]!==D?(we=(0,Y.jsxs)(d,{className:ee,children:[E,D]}),t[50]=ee,t[51]=E,t[52]=D,t[53]=we):we=t[53],we}function $d(e,t){return Math.max(e,t.level)}function ef(e){return e.slug}function tf(e){if(!e)return`plaintext`;if(e.types.includes(`vscode-editor-data`))return`vscode`;if(e.types.includes(`text/x-gfm`))return`gfm`;let t=e.getData(`text/html`);return t?/data-pm-slice/i.test(t)?`pm-origin`:/docs-internal-guid-/i.test(t)?`gdocs`:/xmlns:o="urn:schemas-microsoft-com:office/i.test(t)||/<meta[^>]*Generator[^>]*Microsoft Word/i.test(t)?`word`:/class="gmail_|class='gmail_/i.test(t)?`gmail`:/notionvc:/i.test(t)?`notion`:/Cocoa HTML Writer/i.test(t)?`apple`:/c-message_kit__|c-message__|c-compose/i.test(t)?`slack`:/google-sheets-html-origin/i.test(t)?`gsheets`:/data-hovercard-type=/i.test(t)?`github`:`generic`:`plaintext`}var nf=250,rf=100;function X(e,t){let n=performance.now()-e;n<(t.op===`paste`?nf:rf)||console.warn(JSON.stringify({event:`clipboard-slow-op`,op:t.op,view:t.view,elapsedMs:Math.round(n),branch:t.branch,source:t.source,...t.htmlBytes==null?{}:{htmlBytes:t.htmlBytes}}))}function Z(e){console.warn(JSON.stringify({event:`clipboard-source-detected`,view:e.view,source:e.source,branch:e.branch}))}function Q(e){console.warn(JSON.stringify({event:`clipboard-html-conversion-failed`,view:e.view,stage:e.stage,source:e.source,...e.branch==null?{}:{branch:e.branch},reason:e.reason,...e.errorClass==null?{}:{errorClass:e.errorClass},...e.htmlBytes==null?{}:{htmlBytes:e.htmlBytes}}))}function af(e){console.warn(JSON.stringify({event:`clipboard-serialize-failed`,view:e.view,kind:e.kind,reason:e.reason}))}function of(e){console.warn(JSON.stringify({event:`clipboard-chunked-insert-failed`,view:e.view,chunksCompleted:e.chunksCompleted,totalChunks:e.totalChunks,bytesWritten:e.bytesWritten,bytesRemaining:e.bytesRemaining,reason:e.reason}))}function $(e){if(e instanceof fe)return`HtmlPayloadTooLargeError`;if(e instanceof ue)return`ChunkedInsertError`;if(e instanceof Error&&e.name&&e.name!==`Error`)return e.name}var sf=/^```/m,cf=/^#{1,6} /m,lf=/^[-*+] /m,uf=/^\d+[.)] /m,df=/\[[^\]\n]+\]\([^)\n]+\)/,ff=/^\|.*\|$/m,pf=/^\|?\s*(:?-+:?)(\s*\|\s*:?-+:?)+\s*\|?$/m,mf=/\$\$[\s\S]+?\$\$/;function hf(e){if(!e)return!1;let t=0;sf.test(e)&&t++,cf.test(e)&&t++,lf.test(e)&&t++,uf.test(e)&&t++,df.test(e)&&t++,ff.test(e)&&pf.test(e)&&t++,mf.test(e)&&t++;let n=e.split(`
30
30
  `).length,r=Math.min(3,Math.floor(n/5));return t>=Math.max(1,r)}var gf=3e3,_f=new Map;function vf(e,t=`Pasted as plain text — some formatting could not be converted.`){let n=Date.now();return n-(_f.get(e)??0)<gf?!1:(_f.set(e,n),re.error(t),!0)}var yf=!1,bf=!1;function xf(e){yf=e.shiftKey}function Sf(e){(e.key===`Shift`||!e.shiftKey)&&(yf=!1)}function Cf(){yf=!1}function wf(){bf||typeof window>`u`||(window.addEventListener(`keydown`,xf,!0),window.addEventListener(`keyup`,Sf,!0),window.addEventListener(`blur`,Cf,!0),bf=!0)}function Tf(){wf()}function Ef(){return wf(),yf}function Df(e){return Ef()?!0:e.shiftKey===!0}function Of(e){return(t,n)=>{let r=n.clipboardData;if(!r||r.types.length===0)return!1;let i=performance.now(),a=tf(r),o=r.getData(`text/plain`),s=r.getData(`text/html`);if(Df(n))return o&&Af(t,o),Z({view:`wysiwyg`,branch:`shift`,source:a}),X(i,{op:`paste`,view:`wysiwyg`,branch:`shift`,source:a}),!0;if(kf(t))return o&&Af(t,o),Z({view:`wysiwyg`,branch:`codeblock`,source:a}),X(i,{op:`paste`,view:`wysiwyg`,branch:`codeblock`,source:a}),!0;let c=r.getData(`vscode-editor-data`);if(c&&o&&Mf(t,c,o,a))return Z({view:`wysiwyg`,branch:`A`,source:a}),X(i,{op:`paste`,view:`wysiwyg`,branch:`A`,source:a}),!0;let l=r.getData(`text/x-gfm`);return l&&Nf(t,l,e,`B`,a)?(Z({view:`wysiwyg`,branch:`B`,source:a}),X(i,{op:`paste`,view:`wysiwyg`,branch:`B`,source:a}),!0):s&&/data-pm-slice/i.test(s)?(Z({view:`wysiwyg`,branch:`C`,source:a}),X(i,{op:`paste`,view:`wysiwyg`,branch:`C`,source:a}),!1):o&&s&&hf(o)&&Nf(t,o,e,`B`,a)?(Z({view:`wysiwyg`,branch:`B`,source:a}),X(i,{op:`paste`,view:`wysiwyg`,branch:`B`,source:a}),!0):s&&Pf(t,s,e,a)?(Z({view:`wysiwyg`,branch:`D`,source:a}),X(i,{op:`paste`,view:`wysiwyg`,branch:`D`,source:a,htmlBytes:s.length}),!0):o?hf(o)&&Nf(t,o,e,`E`,`markdown-text`)?(Z({view:`wysiwyg`,branch:`E`,source:`markdown-text`}),X(i,{op:`paste`,view:`wysiwyg`,branch:`E`,source:`markdown-text`}),!0):(Af(t,o),Z({view:`wysiwyg`,branch:`E`,source:`plaintext`}),X(i,{op:`paste`,view:`wysiwyg`,branch:`E`,source:`plaintext`}),!0):!1}}function kf(e){let{$from:t}=e.state.selection;for(let e=t.depth;e>=0;e--)if(t.node(e).type.name===`codeBlock`)return!0;return!1}function Af(e,t){let{schema:n,tr:r}=e.state;t&&e.dispatch(r.replaceSelectionWith(n.text(t)).scrollIntoView())}var jf=/^[A-Za-z0-9_+-]+$/;function Mf(e,t,n,r){try{let r=JSON.parse(t),i=typeof r.mode==`string`?r.mode:``,a=jf.test(i)?i:``,o=e.state.schema.nodes.codeBlock;if(!o)return!1;let s=o.create({language:a},n?e.state.schema.text(n):null);return e.dispatch(e.state.tr.replaceSelectionWith(s).scrollIntoView()),!0}catch(e){return Q({view:`wysiwyg`,stage:`branchA`,source:r,branch:`A`,reason:e?.message??`unknown`,errorClass:$(e)}),!1}}function Nf(e,t,n,r,i){let a;try{a=n.mdManager.parse(t)}catch(e){return Q({view:`wysiwyg`,stage:`mdManagerParse`,source:i,branch:r,reason:e?.message??`unknown`,errorClass:$(e)}),!1}return Ff(e,a,i,r)}function Pf(e,t,n,r){let i;try{i=ce(t)}catch(e){return Q({view:`wysiwyg`,stage:`htmlToMdast`,source:r,branch:`D`,reason:e?.message??`unknown`,errorClass:$(e),htmlBytes:t.length}),vf(`wysiwyg`),!1}let a;try{a=le(i)}catch(e){return Q({view:`wysiwyg`,stage:`mdastToMarkdown`,source:r,branch:`D`,reason:e?.message??`unknown`,errorClass:$(e),htmlBytes:t.length}),vf(`wysiwyg`),!1}let o;try{o=n.mdManager.parse(a)}catch(e){return Q({view:`wysiwyg`,stage:`mdManagerParse`,source:r,branch:`D`,reason:e?.message??`unknown`,errorClass:$(e),htmlBytes:t.length}),vf(`wysiwyg`),!1}return Ff(e,o,r,`D`,t.length)}function Ff(e,t,n,r,i){try{let n=e.state.schema.nodeFromJSON(t);return e.dispatch(e.state.tr.replaceSelection(n.slice(0,n.content.size)).scrollIntoView()),!0}catch(e){return Q({view:`wysiwyg`,stage:`applyJsonSlice`,source:n,branch:r,reason:e?.message??`unknown`,errorClass:$(e),...i==null?{}:{htmlBytes:i}}),!1}}function If(e){return(t,n)=>{try{return zf(t,n.state.schema,e.mdManager)}catch(e){return console.warn(`[clipboard] text serialize fell through — PM default textBetween`,e),t.content.textBetween(0,t.content.size,`
31
31
 
32
- `)}}}var Lf=class extends ie{mdManager;constructor(e){super({},{}),this.mdManager=e}serializeFragment(e,t,n){try{let t=e.firstChild?.type.schema;if(!t)return n??document.createDocumentFragment();let r=Hf(Bf(e,t,this.mdManager));if(n){for(let e of Array.from(r.childNodes))n.appendChild(e);return n}return r}catch(e){return console.warn(`[clipboard] HTML serialize fell through — PM default DOMSerializer`,e),n??document.createDocumentFragment()}}};function Rf(e){return new Lf(e.mdManager)}function zf(e,t,n){return n.serialize(Vf(e,t))}function Bf(e,t,n){return ae(zf(new se(e,0,0),t,n))}function Vf(e,t){let n=t.topNodeType.createAndFill(null,e.content);if(!n){let e=t.topNodeType.createAndFill();if(!e)throw Error(`[clipboard] schema cannot fill topNodeType`);return e.toJSON()}return n.toJSON()}function Hf(e){let t=new DOMParser().parseFromString(e,`text/html`),n=document.createDocumentFragment();for(let e of Array.from(t.body.childNodes))n.appendChild(e);return n}function Uf(e){return Tf(),k.domEventHandlers({copy:(e,t)=>Wf(e,t,`copy`),cut:(e,t)=>Wf(e,t,`cut`),paste:(t,n)=>Gf(t,n,e)})}function Wf(e,t,n){let{from:r,to:i}=t.state.selection.main;if(r===i)return e.preventDefault(),!0;let a=e.clipboardData;if(!a)return!1;let o=performance.now();try{let s=t.state.sliceDoc(r,i);a.setData(`text/plain`,s);try{a.setData(`text/html`,ae(s))}catch(e){af({view:`source`,kind:`html`,reason:e?.message??`unknown`})}return e.preventDefault(),n===`cut`&&t.dispatch({changes:{from:r,to:i,insert:``}}),X(o,{op:n,view:`source`,branch:`serialize`,source:`local`}),!0}catch(e){return af({view:`source`,kind:`text`,reason:e?.message??`unknown`}),!1}}function Gf(e,t,n){let r=e.clipboardData;if(!r||r.types.length===0)return!1;let i=performance.now(),a=tf(r),o=r.getData(`text/plain`),s=r.getData(`text/html`);if(Df(e))return Z({view:`source`,branch:`shift`,source:a}),X(i,{op:`paste`,view:`source`,branch:`shift`,source:a}),!1;let c=r.getData(`vscode-editor-data`);return c&&o&&qf(t,c,o,a)?(e.preventDefault(),Z({view:`source`,branch:`A`,source:a}),X(i,{op:`paste`,view:`source`,branch:`A`,source:a}),!0):s&&/data-pm-slice/i.test(s)?(Z({view:`source`,branch:`C`,source:a}),X(i,{op:`paste`,view:`source`,branch:`C`,source:a}),!1):s&&Jf(t,s,n,a)?(e.preventDefault(),Z({view:`source`,branch:`D`,source:a}),X(i,{op:`paste`,view:`source`,branch:`D`,source:a,htmlBytes:s.length}),!0):(Z({view:`source`,branch:`E`,source:a}),X(i,{op:`paste`,view:`source`,branch:`E`,source:a}),!1)}var Kf=/^[A-Za-z0-9_+-]+$/;function qf(e,t,n,r){try{let r=JSON.parse(t),i=typeof r.mode==`string`?r.mode:``,a=`\`\`\`${Kf.test(i)?i:``}\n${n}\n\`\`\`\n`,{from:o,to:s}=e.state.selection.main;return e.dispatch({changes:{from:o,to:s,insert:a},selection:{anchor:o+a.length}}),!0}catch(e){return Q({view:`source`,stage:`branchA`,source:r,branch:`A`,reason:e?.message??`unknown`,errorClass:$(e)}),!1}}function Jf(e,t,n,r){let i;try{i=ce(t)}catch(e){return Q({view:`source`,stage:`htmlToMdast`,source:r,branch:`D`,reason:e?.message??`unknown`,errorClass:$(e),htmlBytes:t.length}),!1}let a;try{a=le(i)}catch(e){return Q({view:`source`,stage:`mdastToMarkdown`,source:r,branch:`D`,reason:e?.message??`unknown`,errorClass:$(e),htmlBytes:t.length}),!1}let{from:o,to:s}=e.state.selection.main;if(!(a.length>500*1024))return e.dispatch({changes:{from:o,to:s,insert:a},selection:{anchor:o+a.length}}),!0;let c=o===s?``:e.state.sliceDoc(o,s);o!==s&&e.dispatch({changes:{from:o,to:s,insert:``}});let l=o,u=te(n.ytext,l);return oe(n.ydoc,n.ytext,l,a,{resolveOffset:e=>{let t=m(u,n.ydoc);return t==null?e:t.index+(e-l)}}).catch(i=>{Yf({view:e,source:r,html:t,restoreText:c,anchorIndex:l,anchorRelPos:u,ydoc:n.ydoc,err:i})}),!0}function Yf(e){let{view:t,source:n,html:r,restoreText:i,anchorIndex:a,anchorRelPos:o,ydoc:s,err:c}=e;if(c instanceof ue&&c.bytesWritten>0){let e=o&&s?m(o,s)?.index??a:a,n=Math.min(e+c.bytesWritten,t.state.doc.length);try{t.dispatch({changes:{from:e,to:n,insert:i}})}catch(e){console.warn(`[clipboard] partial-chunk rollback dispatch failed`,e)}}else if(i.length>0)try{t.dispatch({changes:{from:a,to:a,insert:i}})}catch(e){console.warn(`[clipboard] selection-restore dispatch failed`,e)}if(c instanceof ue){of({view:`source`,chunksCompleted:c.chunksCompleted,totalChunks:c.totalChunks,bytesWritten:c.bytesWritten,bytesRemaining:c.bytesRemaining,reason:c.message}),re.error(`Paste was incomplete — ${c.chunksCompleted} of ${c.totalChunks} chunks landed. Your selection has been restored.`);return}Q({view:`source`,stage:`chunkedYTextInsert`,source:n,branch:`D`,reason:c?.message??`unknown`,errorClass:$(c),htmlBytes:r.length}),re.error(`Paste failed. Your selection has been restored.`)}export{Lt as _,Xd as a,ru as c,ws as d,us as f,cr as g,ya as h,Of as i,Ls as l,xo as m,Rf as n,Zd as o,Qo as p,If as r,Bd as s,Uf as t,Ps as u,It as v,Ft as y};
32
+ `)}}}var Lf=class extends ie{mdManager;constructor(e){super({},{}),this.mdManager=e}serializeFragment(e,t,n){try{let t=e.firstChild?.type.schema;if(!t)return n??document.createDocumentFragment();let r=Hf(Bf(e,t,this.mdManager));if(n){for(let e of Array.from(r.childNodes))n.appendChild(e);return n}return r}catch(e){return console.warn(`[clipboard] HTML serialize fell through — PM default DOMSerializer`,e),n??document.createDocumentFragment()}}};function Rf(e){return new Lf(e.mdManager)}function zf(e,t,n){return n.serialize(Vf(e,t))}function Bf(e,t,n){return ae(zf(new se(e,0,0),t,n))}function Vf(e,t){let n=t.topNodeType.createAndFill(null,e.content);if(!n){let e=t.topNodeType.createAndFill();if(!e)throw Error(`[clipboard] schema cannot fill topNodeType`);return e.toJSON()}return n.toJSON()}function Hf(e){let t=new DOMParser().parseFromString(e,`text/html`),n=document.createDocumentFragment();for(let e of Array.from(t.body.childNodes))n.appendChild(e);return n}function Uf(e){return Tf(),k.domEventHandlers({copy:(e,t)=>Wf(e,t,`copy`),cut:(e,t)=>Wf(e,t,`cut`),paste:(t,n)=>Gf(t,n,e)})}function Wf(e,t,n){let{from:r,to:i}=t.state.selection.main;if(r===i)return e.preventDefault(),!0;let a=e.clipboardData;if(!a)return!1;let o=performance.now();try{let s=t.state.sliceDoc(r,i);a.setData(`text/plain`,s);try{a.setData(`text/html`,ae(s))}catch(e){af({view:`source`,kind:`html`,reason:e?.message??`unknown`})}return e.preventDefault(),n===`cut`&&t.dispatch({changes:{from:r,to:i,insert:``}}),X(o,{op:n,view:`source`,branch:`serialize`,source:`local`}),!0}catch(e){return af({view:`source`,kind:`text`,reason:e?.message??`unknown`}),!1}}function Gf(e,t,n){let r=e.clipboardData;if(!r||r.types.length===0)return!1;let i=performance.now(),a=tf(r),o=r.getData(`text/plain`),s=r.getData(`text/html`);if(Df(e))return Z({view:`source`,branch:`shift`,source:a}),X(i,{op:`paste`,view:`source`,branch:`shift`,source:a}),!1;let c=r.getData(`vscode-editor-data`);return c&&o&&qf(t,c,o,a)?(e.preventDefault(),Z({view:`source`,branch:`A`,source:a}),X(i,{op:`paste`,view:`source`,branch:`A`,source:a}),!0):s&&/data-pm-slice/i.test(s)?(Z({view:`source`,branch:`C`,source:a}),X(i,{op:`paste`,view:`source`,branch:`C`,source:a}),!1):s&&Jf(t,s,n,a)?(e.preventDefault(),Z({view:`source`,branch:`D`,source:a}),X(i,{op:`paste`,view:`source`,branch:`D`,source:a,htmlBytes:s.length}),!0):(Z({view:`source`,branch:`E`,source:a}),X(i,{op:`paste`,view:`source`,branch:`E`,source:a}),!1)}var Kf=/^[A-Za-z0-9_+-]+$/;function qf(e,t,n,r){try{let r=JSON.parse(t),i=typeof r.mode==`string`?r.mode:``,a=`\`\`\`${Kf.test(i)?i:``}\n${n}\n\`\`\`\n`,{from:o,to:s}=e.state.selection.main;return e.dispatch({changes:{from:o,to:s,insert:a},selection:{anchor:o+a.length}}),!0}catch(e){return Q({view:`source`,stage:`branchA`,source:r,branch:`A`,reason:e?.message??`unknown`,errorClass:$(e)}),!1}}function Jf(e,t,n,r){let i;try{i=ce(t)}catch(e){return Q({view:`source`,stage:`htmlToMdast`,source:r,branch:`D`,reason:e?.message??`unknown`,errorClass:$(e),htmlBytes:t.length}),!1}let a;try{a=le(i)}catch(e){return Q({view:`source`,stage:`mdastToMarkdown`,source:r,branch:`D`,reason:e?.message??`unknown`,errorClass:$(e),htmlBytes:t.length}),!1}let{from:o,to:s}=e.state.selection.main;if(!(a.length>500*1024))return e.dispatch({changes:{from:o,to:s,insert:a},selection:{anchor:o+a.length}}),!0;let c=o===s?``:e.state.sliceDoc(o,s);o!==s&&e.dispatch({changes:{from:o,to:s,insert:``}});let l=o,u=m(n.ytext,l);return oe(n.ydoc,n.ytext,l,a,{resolveOffset:e=>{let t=ee(u,n.ydoc);return t==null?e:t.index+(e-l)}}).catch(i=>{Yf({view:e,source:r,html:t,restoreText:c,anchorIndex:l,anchorRelPos:u,ydoc:n.ydoc,err:i})}),!0}function Yf(e){let{view:t,source:n,html:r,restoreText:i,anchorIndex:a,anchorRelPos:o,ydoc:s,err:c}=e;if(c instanceof ue&&c.bytesWritten>0){let e=o&&s?ee(o,s)?.index??a:a,n=Math.min(e+c.bytesWritten,t.state.doc.length);try{t.dispatch({changes:{from:e,to:n,insert:i}})}catch(e){console.warn(`[clipboard] partial-chunk rollback dispatch failed`,e)}}else if(i.length>0)try{t.dispatch({changes:{from:a,to:a,insert:i}})}catch(e){console.warn(`[clipboard] selection-restore dispatch failed`,e)}if(c instanceof ue){of({view:`source`,chunksCompleted:c.chunksCompleted,totalChunks:c.totalChunks,bytesWritten:c.bytesWritten,bytesRemaining:c.bytesRemaining,reason:c.message}),re.error(`Paste was incomplete — ${c.chunksCompleted} of ${c.totalChunks} chunks landed. Your selection has been restored.`);return}Q({view:`source`,stage:`chunkedYTextInsert`,source:n,branch:`D`,reason:c?.message??`unknown`,errorClass:$(c),htmlBytes:r.length}),re.error(`Paste failed. Your selection has been restored.`)}export{Lt as _,Xd as a,ru as c,ws as d,us as f,cr as g,ya as h,Of as i,Ls as l,xo as m,Rf as n,Zd as o,Qo as p,If as r,Bd as s,Uf as t,Ps as u,It as v,Ft as y};