@inkeep/open-knowledge 0.13.1-beta.0 → 0.13.1-beta.1

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 (47) hide show
  1. package/dist/assets/skills/discovery/SKILL.md +1 -1
  2. package/dist/assets/skills/project/SKILL.md +1 -1
  3. package/dist/cli.mjs +5 -5
  4. package/dist/constants-zj-D6a5L.mjs +2 -0
  5. package/dist/{dist-BgHiidWe.mjs → dist-FERRdneg.mjs} +1 -1
  6. package/dist/{dist-CiI7c_re.mjs → dist-Pv-QcNKe.mjs} +4 -4
  7. package/dist/{gh-detect-Cv944pRY.mjs → gh-detect-D2MiEraX.mjs} +2 -2
  8. package/dist/index.mjs +1 -1
  9. package/dist/{init-CQHz9Eo_.mjs → init-B0Hidsfj.mjs} +4 -4
  10. package/dist/init-R28SPyC3.mjs +1 -0
  11. package/dist/loader-D4lmTlOS.mjs +1 -0
  12. package/dist/{loader-B2AfLLsp.mjs → loader-OEvCsUOD.mjs} +2 -2
  13. package/dist/{preview-CPA61J_5.mjs → preview-BHk2P9Dm.mjs} +2 -2
  14. package/dist/preview-DO5bfuVs.mjs +1 -0
  15. package/dist/public/assets/{ActivityModeContent-C7UT5nPw.js → ActivityModeContent-dYSS8reE.js} +1 -1
  16. package/dist/public/assets/DocumentContext-B-oxrLtY.js +34 -0
  17. package/dist/public/assets/{GraphPanel-D_syB_bA.js → GraphPanel-B0TgIau7.js} +2 -2
  18. package/dist/public/assets/{OpenInAgentMenuRequestContext-B32rwFc5.js → OpenInAgentMenuRequestContext-r39HcOH8.js} +1 -1
  19. package/dist/public/assets/{SettingsDialogBody-eoMmugU8.js → SettingsDialogBody-DW_oZjfz.js} +2 -2
  20. package/dist/public/assets/{SourceEditor-Bv0JOQGy.js → SourceEditor-vRkBKGpM.js} +2 -2
  21. package/dist/public/assets/config-validation-events-D2hu2bJf.js +12 -0
  22. package/dist/public/assets/index-14_Rgzs9.js +1970 -0
  23. package/dist/public/assets/{keyboard-shortcuts-4gOv8mfC.js → keyboard-shortcuts-CE3ut3wk.js} +1 -1
  24. package/dist/public/assets/{prop-types-D5A0KxlP.js → prop-types-rWEy3Nmv.js} +163 -163
  25. package/dist/public/assets/{target-navigation-intent-C27lEBAt.js → target-navigation-intent-BeYNBlOx.js} +1 -1
  26. package/dist/public/index.html +7 -7
  27. package/dist/{repair-launch-json-C899rVft.mjs → repair-launch-json-DixAuGM9.mjs} +2 -2
  28. package/dist/{repair-mcp-configs-D-AOuCWn.mjs → repair-mcp-configs-5HQGdE2G.mjs} +2 -2
  29. package/dist/repair-skills-C_h_l--W.mjs +1 -0
  30. package/dist/{repair-skills-XP895X_X.mjs → repair-skills-OdHTdsUa.mjs} +2 -2
  31. package/dist/{server-lock-BpjJj3OD-y1muWCxH.mjs → server-lock-BpjJj3OD-CHC__Hj9.mjs} +6 -6
  32. package/dist/server-lock-CyhBidkz-BDr_KNnC.mjs +1 -0
  33. package/dist/{src-Be4jcFmx.mjs → src-DKNW3Oob.mjs} +2 -2
  34. package/dist/{start-DPb95zm2.mjs → start-DiA6G6BK.mjs} +2 -2
  35. package/dist/start-QBtkSahy.mjs +1 -0
  36. package/dist/{write-project-skill-Cr3J4-oP.mjs → write-project-skill-CIXAI50Z.mjs} +2 -2
  37. package/package.json +1 -1
  38. package/dist/constants-CgNRuvJK.mjs +0 -2
  39. package/dist/init-DPPCzrFX.mjs +0 -1
  40. package/dist/loader-DxwcQ0es.mjs +0 -1
  41. package/dist/preview-BgXIkJNx.mjs +0 -1
  42. package/dist/public/assets/DocumentContext-GuHu10Ar.js +0 -34
  43. package/dist/public/assets/config-validation-events-DrZyfdiG.js +0 -12
  44. package/dist/public/assets/index-DYGsRjyv.js +0 -1970
  45. package/dist/repair-skills-B3cZab7R.mjs +0 -1
  46. package/dist/server-lock-CyhBidkz-B1PFmuPr.mjs +0 -1
  47. package/dist/start-Bp5PTONb.mjs +0 -1
@@ -1,2 +1,2 @@
1
- import{o as e}from"./chunk-CFjPhJqf.js";import{a as t,o as n,t as r}from"./compiler-runtime-Cs91PcD2.js";import{Dt as i,Et as a,H as o,M as s,N as c,P as l,Sn as u,W as d,Y as ee,Z as f,_n as p,bn as m,fn as h,gn as g,hn as _,mn as v,pn as y,un as b,vn as x,xn as S,yn as C}from"./DocumentContext-GuHu10Ar.js";import{$n as w,Lt as T,da as te,ji as ne}from"./prop-types-D5A0KxlP.js";import{l as re}from"./keyboard-shortcuts-4gOv8mfC.js";import{$ as E,Dt as ie,Et as D,Ft as O,J as k,Ot as A,P as j,Q as M,Tt as N,X as P,jt as F,pt as ae,ut as oe,xt as I}from"./dist-Du-s1q8P.js";import{a as se,d as ce,i as le,m as ue,n as de,p as fe,u as pe}from"./OpenInAgentMenuRequestContext-B32rwFc5.js";var L=e(t(),1),me=r(),R=class e{constructor(e,t){this.yanchor=e,this.yhead=t}toJSON(){return{yanchor:p(this.yanchor),yhead:p(this.yhead)}}static fromJSON(t){return new e(_(t.yanchor),_(t.yhead))}},z=class{constructor(e,t){this.ytext=e,this.awareness=t,this.undoManager=new h(e)}toYPos(e,t=0){return g(this.ytext,e,t)}fromYPos(e){let t=v(_(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 R(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?D.cursor(n.pos,n.assoc):D.range(t.pos,n.pos)}},B=A.define({combine(e){return e[e.length-1]}}),V=I.define(),H=class{constructor(e){this.view=e,this.conf=e.state.facet(B),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:[V.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(V)===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,`
2
- `);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)}},U=M.fromClass(H),W=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`}}),G=I.define(),K=class extends E{constructor(e,t){super(),this.color=e,this.name=t}toDOM(){return x(`span`,[m(`class`,`cm-ySelectionCaret`),m(`style`,`background-color: ${this.color}; border-color: ${this.color}`)],[C(`⁠`),x(`div`,[m(`class`,`cm-ySelectionCaretDot`)]),C(`⁠`),x(`div`,[m(`class`,`cm-ySelectionInfo`)],[C(this.name)]),C(`⁠`)])}eq(e){return e.color===this.color}compare(e){return e.color===this.color}updateDOM(){return!1}get estimatedHeight(){return-1}ignoreEvent(){return!0}},q=class{constructor(e){this.conf=e.state.facet(B),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:[G.of([])]})},this._awareness=this.conf.awareness,this._awareness.on(`change`,this._listener),this.decorations=F.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:_(a.cursor.anchor),s=a.cursor==null?null:_(a.cursor.head);if(i!=null){let e=g(t,i.anchor),n=g(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,o)=>{if(o===r.doc.clientID)return;let s=a.cursor;if(s==null||s.anchor==null||s.head==null)return;let c=v(s.anchor,n),l=v(s.head,n);if(c==null||l==null||c.type!==t||l.type!==t)return;let{color:d=`#30bced`,name:ee=`Anonymous`}=a.user||{},f=a.user&&a.user.colorLight||d+`33`,p=u(c.index,l.index),m=S(c.index,l.index),h=e.view.state.doc.lineAt(p),g=e.view.state.doc.lineAt(m);if(h.number===g.number)i.push({from:p,to:m,value:k.mark({attributes:{style:`background-color: ${f}`},class:`cm-ySelection`})});else{i.push({from:p,to:h.from+h.length,value:k.mark({attributes:{style:`background-color: ${f}`},class:`cm-ySelection`})}),i.push({from:g.from,to:m,value:k.mark({attributes:{style:`background-color: ${f}`},class:`cm-ySelection`})});for(let t=h.number+1;t<g.number;t++){let n=e.view.state.doc.line(t).from;i.push({from:n,to:n,value:k.line({attributes:{style:`background-color: ${f}`,class:`cm-yLineSelection`}})})}}i.push({from:l.index,to:l.index,value:k.widget({side:l.index-c.index>0?-1:1,block:!1,widget:new K(d,ee)})})}),this.decorations=k.set(i,!0)}},J=M.fromClass(q,{decorations:e=>e.decorations}),Y=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}},X=A.define({combine(e){return e[e.length-1]}});I.define();var Z=class{constructor(e){this.view=e,this.conf=e.state.facet(X),this._undoManager=this.conf.undoManager,this.syncConf=e.state.facet(B),this._beforeChangeSelection=null,this._mux=b(),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(V)!==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)}},Q=M.fromClass(Z),he=({state:e,dispatch:t})=>e.facet(X).undo()||!0,ge=({state:e,dispatch:t})=>e.facet(X).redo()||!0,_e=(e,t,{undoManager:n=new h(e)}={})=>{let r=new z(e,t),i=[B.of(r),U];return t&&i.push(W,J),n!==!1&&i.push(X.of(new Y(n)),Q,P.domEventHandlers({beforeinput(e,t){return e.inputType===`historyUndo`?he(t):e.inputType===`historyRedo`?ge(t):!1}})),i},ve=k.mark({class:`cm-link-ref-broken`}),ye=/^\s{0,3}\[([^\]]+)\]:\s/,be=/\[([^\]]*)\]\[([^\]]*)\]/g,xe=new Set([`FencedCode`,`CodeBlock`,`InlineCode`]);function $(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 Se(e){let t=[];return j(e).iterate({enter(e){if(xe.has(e.name))return t.push({from:e.from,to:e.to}),!1}}),t.sort((e,t)=>e.from-t.from),t}function Ce(e){let t=new Set,n=[],r=e.doc,i=Se(e);for(let e=1;e<=r.lines;e++){let n=r.line(e);if($(n.from,i))continue;let a=ye.exec(n.text);a&&t.add(a[1].toLowerCase())}for(let e=1;e<=r.lines;e++){let t=r.line(e);if(!$(t.from,i)&&!ye.test(t.text))for(be.lastIndex=0;;){let e=be.exec(t.text);if(!e)break;let r=t.from+e.index;if($(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(ve.range(e.from,e.to));return a.sort((e,t)=>e.from-t.from),k.set(a)}var we=O.define({create(e){return Ce(e)},update(e,t){return t.docChanged?Ce(t.state):e},provide:e=>P.decorations.from(e)}),Te=/^(\s*(?:[-*+]|\d+[.)]) (?:\[[ x]\] )?)/,Ee=k.mark({class:`cm-del`}),De=k.line({class:`cm-table-header`,attributes:{style:`--list-hang: 2ch`}}),Oe=k.line({class:`cm-table-row`,attributes:{style:`--list-hang: 2ch`}});function ke(e){let t=0;for(let n of e)if(n===` `)t++;else if(n===` `)t+=4;else break;return t}function Ae(e){if(e.doc.lines<2)return null;let t=e.doc.line(1);if(!T.test(t.text))return null;for(let n=2;n<=e.doc.lines;n++){let r=e.doc.line(n);if(T.test(r.text))return{from:t.from,to:r.to}}return null}function je(e,t){let n=[],r=j(e),i=Ae(e),a=e=>i!==null&&e>=i.from&&e<=i.to;for(let{from:i,to:o}of t)r.iterate({from:i,to:o,enter(t){if(!a(t.from)){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(Ee.range(e,r)),!1}if(t.name===`ListItem`){let r=e.doc.lineAt(t.from),i=Te.exec(r.text),a=i?i[1].length:2,o=k.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=ke(r.text),a=k.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(De.range(r.from)),!1}if(t.name===`TableRow`){let r=e.doc.lineAt(t.from);return n.push(Oe.range(r.from)),!1}if(t.name===`TableDelimiter`&&t.node.parent?.name===`Table`){let r=e.doc.lineAt(t.from);return n.push(Oe.range(r.from)),!1}}}});return n.sort((e,t)=>e.from-t.from||e.value.startSide-t.value.startSide),k.set(n)}var Me=class{decorations;constructor(e){this.decorations=je(e.state,e.visibleRanges)}update(e){(e.docChanged||e.viewportChanged||j(e.startState)!==j(e.state))&&(this.decorations=je(e.view.state,e.view.visibleRanges))}},Ne=M.fromClass(Me,{decorations:e=>e.decorations});function Pe(){return[Ne,we]}var Fe=n(),Ie=56;function Le(e,t){let n=e.state.doc,r=1;if(n.lines>=1&&T.test(n.line(1).text)){for(let e=2;e<=n.lines;e++)if(T.test(n.line(e).text)){r=e+1;break}}let i=w(),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:D.cursor(r.from),effects:P.scrollIntoView(r.from,{y:`start`})}),e.focus();return}a++}}}function Re(e,t){requestAnimationFrame(()=>{let n=e.state.doc,r=Math.min(t.offset,n.length);e.dispatch({selection:D.cursor(r),effects:P.scrollIntoView(r,{y:`center`})}),e.focus()})}function ze(e){let t=e.state.selection.main;return t.empty?``:e.state.sliceDoc(t.from,t.to)}function Be(e){let t=(0,me.c)(39),{docName:n,ytext:r,provider:o,placeholder:u,isSourceModeActive:p}=e,m=(0,L.useRef)(null),h=(0,L.useRef)(null),g;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(g=new N,t[0]=g):g=t[0];let _=(0,L.useRef)(g),v;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(v=new N,t[1]=v):v=t[1];let y=(0,L.useRef)(v),b;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(b=new N,t[2]=b):b=t[2];let x=(0,L.useRef)(b),[S,C]=(0,L.useState)(null);if(S)throw S;let{resolvedTheme:w}=te(),{merged:T}=d(),{openSelection:E}=de(),D=(0,L.useRef)(E),O=(0,L.useRef)(p),k=T?.editor?.wordWrap??!0,A,j;t[3]===E?(A=t[4],j=t[5]):(A=()=>{D.current=E},j=[E],t[3]=E,t[4]=A,t[5]=j),(0,L.useEffect)(A,j);let M,F;t[6]===p?(M=t[7],F=t[8]):(M=()=>{O.current=p},F=[p],t[6]=p,t[7]=M,t[8]=F),(0,L.useEffect)(M,F);let I=(0,L.useRef)(null),R;t[9]!==u||t[10]!==o||t[11]!==w||t[12]!==k||t[13]!==r?(R=()=>{let e=m.current;if(!e)return;let t=o.configuration.name??``,n,c=He;try{n=a({docName:t,container:e,sizeStats:{viewCount:0,bytes:r.length},factory:e=>{let n=null,i=f({ydoc:o.document,ytext:r}),a=new P({state:ie.create({doc:r.toString(),extensions:[pe,oe.of([ee]),_e(r,o.awareness),...s({themeCompartment:_.current,resolvedTheme:w,ydoc:o.document,wordWrapCompartment:x.current,wordWrap:k}),Pe(),i,P.updateListener.of(e=>{!e.selectionSet&&!e.docChanged||(n!==null&&clearTimeout(n),n=setTimeout(()=>{n=null,le(t,`source`,se(e.view))},120))}),P.domEventHandlers({keydown:(e,n)=>!O.current||!ne()||!re(e,`edit-with-ai`)?!1:(e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation(),D.current({docName:t,instruction:``,selectionMarkdown:ze(n)}),!0)}),y.current.of(ae(u??``)),P.theme({"&":{height:`100%`}}),P.scrollMargins.of(Ve)]}),parent:e});le(t,`source`,se(a));let l=a.contentDOM;return l.addEventListener(`keydown`,c),l.addEventListener(`paste`,c),l.addEventListener(`drop`,c),l.addEventListener(`cut`,c),{view:a,ydoc:o.document,ytext:r,provider:o}}}),I.current=n,h.current=n.view}catch(e){let t=e;console.error(`[SourceEditor] mountCmEditor failed`,t),I.current=null,h.current=null,C(t instanceof Error?t:Error(String(t)))}return()=>{let e=I.current;e&&i(e),I.current=null,h.current=null}},t[9]=u,t[10]=o,t[11]=w,t[12]=k,t[13]=r,t[14]=R):R=t[14];let z;t[15]!==o||t[16]!==r?(z=[r,o],t[15]=o,t[16]=r,t[17]=z):z=t[17],(0,L.useEffect)(R,z);let B,V;t[18]===n?(B=t[19],V=t[20]):(B=()=>{},V=[n],t[18]=n,t[19]=B,t[20]=V),(0,L.useEffect)(B,V);let H,U;t[21]===w?(H=t[22],U=t[23]):(H=()=>{h.current&&h.current.dispatch({effects:_.current.reconfigure(w===`dark`?c:l)})},U=[w],t[21]=w,t[22]=H,t[23]=U),(0,L.useEffect)(H,U);let W,G;t[24]===k?(W=t[25],G=t[26]):(W=()=>{h.current&&h.current.dispatch({effects:x.current.reconfigure(k?P.lineWrapping:[])})},G=[k],t[24]=k,t[25]=W,t[26]=G),(0,L.useEffect)(W,G);let K,q;t[27]===u?(K=t[28],q=t[29]):(K=()=>{h.current&&h.current.dispatch({effects:y.current.reconfigure(ae(u??``))})},q=[u],t[27]=u,t[28]=K,t[29]=q),(0,L.useEffect)(K,q);let J,Y;t[30]!==n||t[31]!==p?(J=()=>{let e=function(e){let t=e.detail;if(!t||t.mode!==`source`||!p)return;let r=h.current;r&&(Le(r,t),fe(n))};return window.addEventListener(ce,e),()=>window.removeEventListener(ce,e)},Y=[n,p],t[30]=n,t[31]=p,t[32]=J,t[33]=Y):(J=t[32],Y=t[33]),(0,L.useEffect)(J,Y);let X,Z;t[34]!==n||t[35]!==p?(X=()=>{if(!p)return;let e=h.current;if(!e)return;let t=ue(n);if(t){if(t.kind===`outline`){Le(e,t.detail);return}Re(e,t.detail)}},Z=[n,p],t[34]=n,t[35]=p,t[36]=X,t[37]=Z):(X=t[36],Z=t[37]),(0,L.useEffect)(X,Z);let Q;return t[38]===Symbol.for(`react.memo_cache_sentinel`)?(Q=(0,Fe.jsx)(`div`,{ref:m,className:`source-editor h-full pb-3`}),t[38]=Q):Q=t[38],Q}function Ve(){return{top:Ie}}function He(){return o()}export{Be as SourceEditor};
1
+ import{o as e}from"./chunk-CFjPhJqf.js";import{a as t,o as n,t as r}from"./compiler-runtime-Cs91PcD2.js";import{Dt as i,Et as a,H as o,M as s,N as c,P as l,Sn as u,W as d,Y as ee,Z as f,_n as p,bn as m,fn as h,gn as g,hn as _,mn as v,pn as y,un as b,vn as x,xn as S,yn as C}from"./DocumentContext-B-oxrLtY.js";import{$n as w,Lt as T,Mi as te,fa as ne}from"./prop-types-rWEy3Nmv.js";import{l as re}from"./keyboard-shortcuts-CE3ut3wk.js";import{$ as E,Dt as ie,Et as D,Ft as O,J as k,Ot as A,P as j,Q as M,Tt as N,X as P,jt as F,pt as ae,ut as oe,xt as I}from"./dist-Du-s1q8P.js";import{a as se,d as ce,i as le,m as ue,n as de,p as fe,u as pe}from"./OpenInAgentMenuRequestContext-r39HcOH8.js";var L=e(t(),1),me=r(),R=class e{constructor(e,t){this.yanchor=e,this.yhead=t}toJSON(){return{yanchor:p(this.yanchor),yhead:p(this.yhead)}}static fromJSON(t){return new e(_(t.yanchor),_(t.yhead))}},z=class{constructor(e,t){this.ytext=e,this.awareness=t,this.undoManager=new h(e)}toYPos(e,t=0){return g(this.ytext,e,t)}fromYPos(e){let t=v(_(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 R(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?D.cursor(n.pos,n.assoc):D.range(t.pos,n.pos)}},B=A.define({combine(e){return e[e.length-1]}}),V=I.define(),H=class{constructor(e){this.view=e,this.conf=e.state.facet(B),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:[V.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(V)===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,`
2
+ `);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)}},U=M.fromClass(H),W=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`}}),G=I.define(),K=class extends E{constructor(e,t){super(),this.color=e,this.name=t}toDOM(){return x(`span`,[m(`class`,`cm-ySelectionCaret`),m(`style`,`background-color: ${this.color}; border-color: ${this.color}`)],[C(`⁠`),x(`div`,[m(`class`,`cm-ySelectionCaretDot`)]),C(`⁠`),x(`div`,[m(`class`,`cm-ySelectionInfo`)],[C(this.name)]),C(`⁠`)])}eq(e){return e.color===this.color}compare(e){return e.color===this.color}updateDOM(){return!1}get estimatedHeight(){return-1}ignoreEvent(){return!0}},q=class{constructor(e){this.conf=e.state.facet(B),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:[G.of([])]})},this._awareness=this.conf.awareness,this._awareness.on(`change`,this._listener),this.decorations=F.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:_(a.cursor.anchor),s=a.cursor==null?null:_(a.cursor.head);if(i!=null){let e=g(t,i.anchor),n=g(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,o)=>{if(o===r.doc.clientID)return;let s=a.cursor;if(s==null||s.anchor==null||s.head==null)return;let c=v(s.anchor,n),l=v(s.head,n);if(c==null||l==null||c.type!==t||l.type!==t)return;let{color:d=`#30bced`,name:ee=`Anonymous`}=a.user||{},f=a.user&&a.user.colorLight||d+`33`,p=u(c.index,l.index),m=S(c.index,l.index),h=e.view.state.doc.lineAt(p),g=e.view.state.doc.lineAt(m);if(h.number===g.number)i.push({from:p,to:m,value:k.mark({attributes:{style:`background-color: ${f}`},class:`cm-ySelection`})});else{i.push({from:p,to:h.from+h.length,value:k.mark({attributes:{style:`background-color: ${f}`},class:`cm-ySelection`})}),i.push({from:g.from,to:m,value:k.mark({attributes:{style:`background-color: ${f}`},class:`cm-ySelection`})});for(let t=h.number+1;t<g.number;t++){let n=e.view.state.doc.line(t).from;i.push({from:n,to:n,value:k.line({attributes:{style:`background-color: ${f}`,class:`cm-yLineSelection`}})})}}i.push({from:l.index,to:l.index,value:k.widget({side:l.index-c.index>0?-1:1,block:!1,widget:new K(d,ee)})})}),this.decorations=k.set(i,!0)}},J=M.fromClass(q,{decorations:e=>e.decorations}),Y=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}},X=A.define({combine(e){return e[e.length-1]}});I.define();var Z=class{constructor(e){this.view=e,this.conf=e.state.facet(X),this._undoManager=this.conf.undoManager,this.syncConf=e.state.facet(B),this._beforeChangeSelection=null,this._mux=b(),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(V)!==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)}},Q=M.fromClass(Z),he=({state:e,dispatch:t})=>e.facet(X).undo()||!0,ge=({state:e,dispatch:t})=>e.facet(X).redo()||!0,_e=(e,t,{undoManager:n=new h(e)}={})=>{let r=new z(e,t),i=[B.of(r),U];return t&&i.push(W,J),n!==!1&&i.push(X.of(new Y(n)),Q,P.domEventHandlers({beforeinput(e,t){return e.inputType===`historyUndo`?he(t):e.inputType===`historyRedo`?ge(t):!1}})),i},ve=k.mark({class:`cm-link-ref-broken`}),ye=/^\s{0,3}\[([^\]]+)\]:\s/,be=/\[([^\]]*)\]\[([^\]]*)\]/g,xe=new Set([`FencedCode`,`CodeBlock`,`InlineCode`]);function $(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 Se(e){let t=[];return j(e).iterate({enter(e){if(xe.has(e.name))return t.push({from:e.from,to:e.to}),!1}}),t.sort((e,t)=>e.from-t.from),t}function Ce(e){let t=new Set,n=[],r=e.doc,i=Se(e);for(let e=1;e<=r.lines;e++){let n=r.line(e);if($(n.from,i))continue;let a=ye.exec(n.text);a&&t.add(a[1].toLowerCase())}for(let e=1;e<=r.lines;e++){let t=r.line(e);if(!$(t.from,i)&&!ye.test(t.text))for(be.lastIndex=0;;){let e=be.exec(t.text);if(!e)break;let r=t.from+e.index;if($(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(ve.range(e.from,e.to));return a.sort((e,t)=>e.from-t.from),k.set(a)}var we=O.define({create(e){return Ce(e)},update(e,t){return t.docChanged?Ce(t.state):e},provide:e=>P.decorations.from(e)}),Te=/^(\s*(?:[-*+]|\d+[.)]) (?:\[[ x]\] )?)/,Ee=k.mark({class:`cm-del`}),De=k.line({class:`cm-table-header`,attributes:{style:`--list-hang: 2ch`}}),Oe=k.line({class:`cm-table-row`,attributes:{style:`--list-hang: 2ch`}});function ke(e){let t=0;for(let n of e)if(n===` `)t++;else if(n===` `)t+=4;else break;return t}function Ae(e){if(e.doc.lines<2)return null;let t=e.doc.line(1);if(!T.test(t.text))return null;for(let n=2;n<=e.doc.lines;n++){let r=e.doc.line(n);if(T.test(r.text))return{from:t.from,to:r.to}}return null}function je(e,t){let n=[],r=j(e),i=Ae(e),a=e=>i!==null&&e>=i.from&&e<=i.to;for(let{from:i,to:o}of t)r.iterate({from:i,to:o,enter(t){if(!a(t.from)){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(Ee.range(e,r)),!1}if(t.name===`ListItem`){let r=e.doc.lineAt(t.from),i=Te.exec(r.text),a=i?i[1].length:2,o=k.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=ke(r.text),a=k.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(De.range(r.from)),!1}if(t.name===`TableRow`){let r=e.doc.lineAt(t.from);return n.push(Oe.range(r.from)),!1}if(t.name===`TableDelimiter`&&t.node.parent?.name===`Table`){let r=e.doc.lineAt(t.from);return n.push(Oe.range(r.from)),!1}}}});return n.sort((e,t)=>e.from-t.from||e.value.startSide-t.value.startSide),k.set(n)}var Me=class{decorations;constructor(e){this.decorations=je(e.state,e.visibleRanges)}update(e){(e.docChanged||e.viewportChanged||j(e.startState)!==j(e.state))&&(this.decorations=je(e.view.state,e.view.visibleRanges))}},Ne=M.fromClass(Me,{decorations:e=>e.decorations});function Pe(){return[Ne,we]}var Fe=n(),Ie=56;function Le(e,t){let n=e.state.doc,r=1;if(n.lines>=1&&T.test(n.line(1).text)){for(let e=2;e<=n.lines;e++)if(T.test(n.line(e).text)){r=e+1;break}}let i=w(),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:D.cursor(r.from),effects:P.scrollIntoView(r.from,{y:`start`})}),e.focus();return}a++}}}function Re(e,t){requestAnimationFrame(()=>{let n=e.state.doc,r=Math.min(t.offset,n.length);e.dispatch({selection:D.cursor(r),effects:P.scrollIntoView(r,{y:`center`})}),e.focus()})}function ze(e){let t=e.state.selection.main;return t.empty?``:e.state.sliceDoc(t.from,t.to)}function Be(e){let t=(0,me.c)(39),{docName:n,ytext:r,provider:o,placeholder:u,isSourceModeActive:p}=e,m=(0,L.useRef)(null),h=(0,L.useRef)(null),g;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(g=new N,t[0]=g):g=t[0];let _=(0,L.useRef)(g),v;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(v=new N,t[1]=v):v=t[1];let y=(0,L.useRef)(v),b;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(b=new N,t[2]=b):b=t[2];let x=(0,L.useRef)(b),[S,C]=(0,L.useState)(null);if(S)throw S;let{resolvedTheme:w}=ne(),{merged:T}=d(),{openSelection:E}=de(),D=(0,L.useRef)(E),O=(0,L.useRef)(p),k=T?.editor?.wordWrap??!0,A,j;t[3]===E?(A=t[4],j=t[5]):(A=()=>{D.current=E},j=[E],t[3]=E,t[4]=A,t[5]=j),(0,L.useEffect)(A,j);let M,F;t[6]===p?(M=t[7],F=t[8]):(M=()=>{O.current=p},F=[p],t[6]=p,t[7]=M,t[8]=F),(0,L.useEffect)(M,F);let I=(0,L.useRef)(null),R;t[9]!==u||t[10]!==o||t[11]!==w||t[12]!==k||t[13]!==r?(R=()=>{let e=m.current;if(!e)return;let t=o.configuration.name??``,n,c=He;try{n=a({docName:t,container:e,sizeStats:{viewCount:0,bytes:r.length},factory:e=>{let n=null,i=f({ydoc:o.document,ytext:r}),a=new P({state:ie.create({doc:r.toString(),extensions:[pe,oe.of([ee]),_e(r,o.awareness),...s({themeCompartment:_.current,resolvedTheme:w,ydoc:o.document,wordWrapCompartment:x.current,wordWrap:k}),Pe(),i,P.updateListener.of(e=>{!e.selectionSet&&!e.docChanged||(n!==null&&clearTimeout(n),n=setTimeout(()=>{n=null,le(t,`source`,se(e.view))},120))}),P.domEventHandlers({keydown:(e,n)=>!O.current||!te()||!re(e,`edit-with-ai`)?!1:(e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation(),D.current({docName:t,instruction:``,selectionMarkdown:ze(n)}),!0)}),y.current.of(ae(u??``)),P.theme({"&":{height:`100%`}}),P.scrollMargins.of(Ve)]}),parent:e});le(t,`source`,se(a));let l=a.contentDOM;return l.addEventListener(`keydown`,c),l.addEventListener(`paste`,c),l.addEventListener(`drop`,c),l.addEventListener(`cut`,c),{view:a,ydoc:o.document,ytext:r,provider:o}}}),I.current=n,h.current=n.view}catch(e){let t=e;console.error(`[SourceEditor] mountCmEditor failed`,t),I.current=null,h.current=null,C(t instanceof Error?t:Error(String(t)))}return()=>{let e=I.current;e&&i(e),I.current=null,h.current=null}},t[9]=u,t[10]=o,t[11]=w,t[12]=k,t[13]=r,t[14]=R):R=t[14];let z;t[15]!==o||t[16]!==r?(z=[r,o],t[15]=o,t[16]=r,t[17]=z):z=t[17],(0,L.useEffect)(R,z);let B,V;t[18]===n?(B=t[19],V=t[20]):(B=()=>{},V=[n],t[18]=n,t[19]=B,t[20]=V),(0,L.useEffect)(B,V);let H,U;t[21]===w?(H=t[22],U=t[23]):(H=()=>{h.current&&h.current.dispatch({effects:_.current.reconfigure(w===`dark`?c:l)})},U=[w],t[21]=w,t[22]=H,t[23]=U),(0,L.useEffect)(H,U);let W,G;t[24]===k?(W=t[25],G=t[26]):(W=()=>{h.current&&h.current.dispatch({effects:x.current.reconfigure(k?P.lineWrapping:[])})},G=[k],t[24]=k,t[25]=W,t[26]=G),(0,L.useEffect)(W,G);let K,q;t[27]===u?(K=t[28],q=t[29]):(K=()=>{h.current&&h.current.dispatch({effects:y.current.reconfigure(ae(u??``))})},q=[u],t[27]=u,t[28]=K,t[29]=q),(0,L.useEffect)(K,q);let J,Y;t[30]!==n||t[31]!==p?(J=()=>{let e=function(e){let t=e.detail;if(!t||t.mode!==`source`||!p)return;let r=h.current;r&&(Le(r,t),fe(n))};return window.addEventListener(ce,e),()=>window.removeEventListener(ce,e)},Y=[n,p],t[30]=n,t[31]=p,t[32]=J,t[33]=Y):(J=t[32],Y=t[33]),(0,L.useEffect)(J,Y);let X,Z;t[34]!==n||t[35]!==p?(X=()=>{if(!p)return;let e=h.current;if(!e)return;let t=ue(n);if(t){if(t.kind===`outline`){Le(e,t.detail);return}Re(e,t.detail)}},Z=[n,p],t[34]=n,t[35]=p,t[36]=X,t[37]=Z):(X=t[36],Z=t[37]),(0,L.useEffect)(X,Z);let Q;return t[38]===Symbol.for(`react.memo_cache_sentinel`)?(Q=(0,Fe.jsx)(`div`,{ref:m,className:`source-editor h-full pb-3`}),t[38]=Q):Q=t[38],Q}function Ve(){return{top:Ie}}function He(){return o()}export{Be as SourceEditor};