@inkeep/open-knowledge 0.0.0-dev-20260428211426 → 0.0.0-dev-20260429160105

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 (65) hide show
  1. package/dist/THIRD_PARTY_NOTICES.md +15 -0
  2. package/dist/cli.mjs +284 -281
  3. package/dist/constants-DLhaxFjM.mjs +2 -0
  4. package/dist/{dist-CXdg7KnM.mjs → dist-CIeZOXfv.mjs} +22 -19
  5. package/dist/{dist-Ct-gJ7iD.mjs → dist-CNDKfHI8.mjs} +1 -1
  6. package/dist/{dist-0qFIeeXA.mjs → dist-DD_wEI4a.mjs} +15 -15
  7. package/dist/index.mjs +1 -1
  8. package/dist/{init-D0YdyLe_.mjs → init-2ZbpRqT6.mjs} +4 -4
  9. package/dist/init-Cy-4UOwQ.mjs +1 -0
  10. package/dist/{init-CMkePWjl.mjs → init-DWGTb8QS.mjs} +22 -7
  11. package/dist/init-DWvyb5i4.mjs +1 -0
  12. package/dist/{loader-BJU3jneI.mjs → loader-B73SzGQk.mjs} +2 -2
  13. package/dist/loader-Ce28eAYb.mjs +1 -0
  14. package/dist/paths-CcD8Nh_5.mjs +1 -0
  15. package/dist/paths-DqWCeGWM.mjs +2 -0
  16. package/dist/{preview-CXP9kBv6.mjs → preview-DRDic3pF.mjs} +2 -2
  17. package/dist/preview-DT0ltjSs.mjs +1 -0
  18. package/dist/public/assets/ActivityModeContent-spvhVGSd.js +2 -0
  19. package/dist/public/assets/DocumentContext-Xq_dn8Vf.js +33 -0
  20. package/dist/public/assets/GraphPanel-C36W-gM6.js +46 -0
  21. package/dist/public/assets/McpConsentDialogBody-CDOor7qb.js +1 -0
  22. package/dist/public/assets/SourceEditor-BeRKaESA.js +2 -0
  23. package/dist/public/assets/{agent-presence-BXsx4eTl.js → agent-presence-XtMgnv3n.js} +1 -1
  24. package/dist/public/assets/clipboard-0XbokP0-.js +5 -0
  25. package/dist/public/assets/{dialog-CtSN0d2b.js → dialog-B7UAZUVJ.js} +1 -1
  26. package/dist/public/assets/{dist-DeDgmJv2.js → dist-5Xm_mb8k.js} +1 -1
  27. package/dist/public/assets/{dist-GlH2KPqY.js → dist-BkmmA9Kx.js} +1 -1
  28. package/dist/public/assets/{dist-BqO6NfD-.js → dist-CBfh7n1S.js} +1 -1
  29. package/dist/public/assets/{dist-DR1MrLJC.js → dist-DUCdsXly.js} +1 -1
  30. package/dist/public/assets/{dist-DlS42TIP.js → dist-DxKDMu0r.js} +1 -1
  31. package/dist/public/assets/{dist-D2wwoXzm.js → dist-gwU6yV0l.js} +1 -1
  32. package/dist/public/assets/index-DmSa5KwJ.js +1843 -0
  33. package/dist/public/assets/index-ldPPE8aY.css +1 -0
  34. package/dist/public/assets/{panel-BCRdtBla.js → panel-DiSt1efw.js} +1 -1
  35. package/dist/public/assets/target-navigation-intent-DlP83APM.js +1 -0
  36. package/dist/public/assets/toggle-group-Cg6YuFV4.js +281 -0
  37. package/dist/public/assets/tooltip-BaQG219g.js +1 -0
  38. package/dist/public/index.html +14 -14
  39. package/dist/src-CCUnFptH.mjs +1 -0
  40. package/dist/start-BaIxHOku.mjs +1 -0
  41. package/dist/start-nj1M3dB_.mjs +2 -0
  42. package/package.json +1 -1
  43. package/dist/constants-DCJlLBSi.mjs +0 -2
  44. package/dist/init-D-5Gc0uq.mjs +0 -1
  45. package/dist/init-DUA_XKK1.mjs +0 -1
  46. package/dist/loader-1GTY76cQ.mjs +0 -1
  47. package/dist/paths-CNpYe27Q.mjs +0 -2
  48. package/dist/paths-fx16Ahvg.mjs +0 -1
  49. package/dist/preview-CHvLSbhb.mjs +0 -1
  50. package/dist/public/assets/ActivityModeContent-Ccu_n0bV.js +0 -2
  51. package/dist/public/assets/DocumentContext-C1msvcHp.js +0 -5
  52. package/dist/public/assets/GraphPanel-CJ_U3W3L.js +0 -46
  53. package/dist/public/assets/McpConsentDialogBody-Csjet19t.js +0 -1
  54. package/dist/public/assets/PageListContext-B5SWnlyE.js +0 -278
  55. package/dist/public/assets/SourceEditor-OFesfBB2.js +0 -3
  56. package/dist/public/assets/clipboard-DAcKCHl1.js +0 -32
  57. package/dist/public/assets/index-CwFTGDhe.js +0 -1843
  58. package/dist/public/assets/index-DjR45Lon.css +0 -1
  59. package/dist/public/assets/toggle-group-LDOO6zaV.js +0 -1
  60. package/dist/public/assets/tooltip-D0MnQ7ZX.js +0 -1
  61. package/dist/src-BIqAAP5m.mjs +0 -1
  62. package/dist/start-BOjBm-nL.mjs +0 -2
  63. package/dist/start-CZFHRjtT.mjs +0 -1
  64. /package/dist/public/assets/{button-BPXuMr5W.js → button-CXhPNzpp.js} +0 -0
  65. /package/dist/public/assets/{dist-CgLbXgrr.js → dist-Bgq0sPT8.js} +0 -0
@@ -1,3 +0,0 @@
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,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 ee}from"./DocumentContext-C1msvcHp.js";import{G as te,Q as O,S as ne,V as re,q as ie}from"./PageListContext-B5SWnlyE.js";import{_ as ae,a as oe,c as se,d as ce,f as le,g as ue,h as de,l as fe,m as pe,p as me,s as he,t as ge,u as _e,v as ve}from"./clipboard-DAcKCHl1.js";import{At as ye,Dt as k,Et as be,N as A,Nt as j,Pt as M,Q as xe,Tt as N,Y as P,Z as F,a as I,bt as L,ft as R,jt as z,lt as Se,q as B,wt as V}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?N.cursor(n.pos,n.assoc):N.range(t.pos,n.pos)}},U=k.define({combine(e){return e[e.length-1]}}),W=L.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=F.fromClass(Ee),Oe=P.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=L.define(),Ae=class extends xe{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=ye.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:B.mark({attributes:{style:`background-color: ${m}`},class:`cm-ySelection`})});else{i.push({from:h,to:_.from+_.length,value:B.mark({attributes:{style:`background-color: ${m}`},class:`cm-ySelection`})}),i.push({from:v.from,to:g,value:B.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:B.line({attributes:{style:`background-color: ${m}`,class:`cm-yLineSelection`}})})}}i.push({from:u.index,to:u.index,value:B.widget({side:u.index-l.index>0?-1:1,block:!1,widget:new Ae(d,f)})})}),this.decorations=B.set(i,!0)}},Me=F.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=k.define({combine(e){return e[e.length-1]}});L.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:[P.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=F.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,P.domEventHandlers({beforeinput(e,t){return e.inputType===`historyUndo`?Ie(t):e.inputType===`historyRedo`?Le(t):!1}})),i},ze=[I.of({name:`javascript`,alias:[`js`,`jsx`],extensions:[`js`,`mjs`,`cjs`,`jsx`],load:async()=>pe({jsx:!0})}),I.of({name:`typescript`,alias:[`ts`,`tsx`],extensions:[`ts`,`mts`,`cts`,`tsx`],load:async()=>pe({typescript:!0,jsx:!0})}),I.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)}),I.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)}),I.of({name:`css`,alias:[`scss`,`less`],extensions:[`css`,`scss`,`less`],load:async()=>de()}),I.of({name:`html`,alias:[`htm`],extensions:[`html`,`htm`],load:async()=>me()}),I.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)}),I.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)}),I.of({name:`markdown`,alias:[`md`,`mdx`],extensions:[`md`,`mdx`,`markdown`],load:async()=>ce()}),I.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))}}),I.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=j.define(),Ve=j.define(),He=B.line({class:`agent-flash`}),Ue=M.define({create(){return B.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=B.none);return e},provide:e=>P.decorations.from(e)});function We(e){let t=e.getMap(`agent-flash`);return[Ue,F.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(ie(t),!O(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`?O(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=B.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 z;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=F.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=P.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=P.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=B.mark({class:`cm-wiki-link`}),at=B.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 z,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=F.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=P.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=re(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:ee(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=P.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,le.data.of({autocomplete:ft})]}var ht=B.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 A(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),B.set(a)}var bt=M.define({create(e){return Q(e)},update(e,t){return t.docChanged?Q(t.state):e},provide:e=>P.decorations.from(e)}),xt=/^(\s*(?:[-*+]|\d+[.)]) (?:\[[ x]\] )?)/,St=B.mark({class:`cm-del`}),Ct=B.line({class:`cm-table-header`}),wt=B.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=A(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=B.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=B.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),B.set(n)}var Dt=class{decorations;constructor(e){this.decorations=Et(e.state,e.visibleRanges)}update(e){(e.docChanged||e.viewportChanged||A(e.startState)!==A(e.state))&&(this.decorations=Et(e.view.state,e.view.visibleRanges))}},Ot=F.fromClass(Dt,{decorations:e=>e.decorations});function kt(){return[Ot,bt]}var At=r(),jt=_e({settings:{background:`var(--background)`,gutterBackground:`var(--background)`}}),Mt=fe({settings:{background:`var(--background)`,gutterBackground:`var(--background)`}}),Nt=new V,Pt=new V;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=te(),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:N.cursor(r.from),effects:P.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:N.cursor(r),effects:P.scrollIntoView(r,{y:`center`})}),e.focus()})}function It(e){let t=(0,Ce.c)(23),{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=(0,H.useRef)(null),g;t[0]!==o||t[1]!==i||t[2]!==p||t[3]!==r?(g=()=>{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=ge({ydoc:i.document,ytext:r}),n=new P({state:be.create({doc:r.toString(),extensions:[he,Se.of([se]),ce({base:le,extensions:[ue],codeLanguages:ze}),Re(r,i.awareness),We(i.document),mt(),Qe(),kt(),t,Nt.of(p===`dark`?jt:Mt),Pt.of(R(o??``)),P.lineWrapping,P.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}}}),m.current=n,l.current=n.view}catch(e){let t=e;console.error(`[SourceEditor] mountCmEditor failed`,t),m.current=null,l.current=null,f(t instanceof Error?t:Error(String(t)))}return()=>{let e=m.current;e&&d(e),m.current=null,l.current=null}},t[0]=o,t[1]=i,t[2]=p,t[3]=r,t[4]=g):g=t[4];let _;t[5]!==i||t[6]!==r?(_=[r,i],t[5]=i,t[6]=r,t[7]=_):_=t[7],(0,H.useEffect)(g,_);let v,y;t[8]===p?(v=t[9],y=t[10]):(v=()=>{l.current&&l.current.dispatch({effects:Nt.reconfigure(p===`dark`?jt:Mt)})},y=[p],t[8]=p,t[9]=v,t[10]=y),(0,H.useEffect)(v,y);let b,x;t[11]===o?(b=t[12],x=t[13]):(b=()=>{l.current&&l.current.dispatch({effects:Pt.reconfigure(R(o??``))})},x=[o],t[11]=o,t[12]=b,t[13]=x),(0,H.useEffect)(b,x);let S,C;t[14]!==n||t[15]!==s?(S=()=>{let e=function(e){let t=e.detail;if(!t||t.mode!==`source`||!s)return;let r=l.current;r&&($(r,t),ae(n))};return window.addEventListener(oe,e),()=>window.removeEventListener(oe,e)},C=[n,s],t[14]=n,t[15]=s,t[16]=S,t[17]=C):(S=t[16],C=t[17]),(0,H.useEffect)(S,C);let w,T;t[18]!==n||t[19]!==s?(T=()=>{if(!s)return;let e=l.current;if(!e)return;let t=ve(n);if(t){if(t.kind===`outline`){$(e,t.detail);return}Ft(e,t.detail)}},w=[n,s],t[18]=n,t[19]=s,t[20]=w,t[21]=T):(w=t[20],T=t[21]),(0,H.useEffect)(T,w);let E;return t[22]===Symbol.for(`react.memo_cache_sentinel`)?(E=(0,At.jsx)(`div`,{ref:c,className:`source-editor h-full py-3`}),t[22]=E):E=t[22],E}function Lt(){return S()}export{It as SourceEditor};