@inkeep/open-knowledge 0.49.0-beta.0 → 0.49.0-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 (32) hide show
  1. package/dist/{acp-harness-probe-OAUXrVlX.mjs → acp-harness-probe-D-srkjjf.mjs} +2 -2
  2. package/dist/cli.mjs +6 -6
  3. package/dist/constants-XFun_cA1.mjs +2 -0
  4. package/dist/index.mjs +1 -1
  5. package/dist/{init-DVqvn49c.mjs → init-Cy5aJiTB.mjs} +3 -3
  6. package/dist/init-D3XERiKn.mjs +1 -0
  7. package/dist/{launch-json-removal-gyM7Qq8D.mjs → launch-json-removal-CW3uB0l0.mjs} +2 -2
  8. package/dist/{loader-DIkhAerx.mjs → loader-BUu0YikQ.mjs} +2 -2
  9. package/dist/loader-qtUfrHA1.mjs +1 -0
  10. package/dist/{preview-CA6178UK.mjs → preview-JtgY3qRY.mjs} +2 -2
  11. package/dist/preview-OSbvhHSx.mjs +1 -0
  12. package/dist/public/assets/FeedbackForm-7G6WGcZE.js +1 -0
  13. package/dist/public/assets/{SourceEditor-BOoVa3uM.js → SourceEditor-CLl_3ALr.js} +1 -1
  14. package/dist/public/assets/{globals-i3eL0jPG.js → globals-CiUwipyS.js} +1 -1
  15. package/dist/public/assets/{index-D5YIDhNI.js → index-BqVIdejq.js} +3 -3
  16. package/dist/public/assets/typing-burst-detector-BR1q4MiH.js +8 -0
  17. package/dist/public/assets/{uninstall-BB82xD6i.js → uninstall-CiLtWDdT.js} +1 -1
  18. package/dist/public/index.html +3 -3
  19. package/dist/public/uninstall.html +2 -2
  20. package/dist/{repair-launch-json-BcgI-mgP.mjs → repair-launch-json-BlmQ4LvZ.mjs} +2 -2
  21. package/dist/{repair-mcp-configs-D4xRlEq2.mjs → repair-mcp-configs-CRNWg0xP.mjs} +2 -2
  22. package/dist/{src-DXRHZM_g.mjs → src-PPz3BSLC.mjs} +2 -2
  23. package/dist/{start-rZaX9a0M.mjs → start-DwZQwCGs.mjs} +2 -2
  24. package/dist/start-pnh29Vpw.mjs +1 -0
  25. package/package.json +4 -4
  26. package/dist/constants-D2wdItjz.mjs +0 -2
  27. package/dist/init-6-Ku7lp3.mjs +0 -1
  28. package/dist/loader-y4lPa7MY.mjs +0 -1
  29. package/dist/preview-DzBQkzdO.mjs +0 -1
  30. package/dist/public/assets/FeedbackForm-DIejsFNO.js +0 -1
  31. package/dist/public/assets/typing-burst-detector-Cw9AAqnc.js +0 -8
  32. package/dist/start-Cf95uRUA.mjs +0 -1
@@ -1,3 +1,3 @@
1
- import{jr as e}from"./src-YfpQ2LX0.mjs";import"./constants-D2wdItjz.mjs";import{join as t,relative as n}from"node:path";import{existsSync as r,lstatSync as i,readdirSync as a,realpathSync as o,statSync as s}from"node:fs";function c(r){let{projectDir:c,contentDir:l,sampleCap:u=5}=r,d=[],f=[];try{i(l)}catch(e){return{totalCount:0,sample:[],contentDir:l,warnings:[`cannot access content directory ${l}: ${e instanceof Error?e.message:String(e)}`]}}let p;try{p=e({projectDir:c,contentDir:l})}catch(e){return{totalCount:0,sample:[],contentDir:l,warnings:[e instanceof Error?e.message:String(e)]}}function m(e){let r;try{r=a(e,{withFileTypes:!0})}catch(t){let r=t instanceof Error?t.message:String(t);d.push(`could not read directory ${n(l,e)||`.`}: ${r}`);return}for(let i of r){let r=t(e,i.name);if(i.isSymbolicLink()){let e;try{e=o(r)}catch(e){let t=e.code;t===`ENOENT`||t===`ELOOP`?d.push(`broken or cyclic symlink: ${n(l,r)}`):d.push(`cannot resolve symlink ${n(l,r)}: ${t??`unknown error`}`);continue}let t;try{t=s(e)}catch{continue}if(t.isDirectory()){let e=n(l,r);if(p.isDirExcluded(e))continue;m(r)}else if(t.isFile()){let e=n(l,r);if(p.isExcluded(e))continue;f.push(e)}}else if(i.isDirectory()){let e=n(l,r);if(p.isDirExcluded(e))continue;m(r)}else if(i.isFile()){let e=n(l,r);if(p.isExcluded(e))continue;f.push(e)}}}return m(l),{totalCount:f.length,sample:f.slice(0,u),contentDir:l,warnings:d}}function l(e,i){let a=[],o=n(i,e.contentDir),s=o===``?`./`:`./${o}`;if(a.push(`Content:`),a.push(` Found ${e.totalCount} markdown files in ${s}`),e.sample.length>0){let t=e.sample.join(`, `),n=e.totalCount>e.sample.length?`, …`:``;a.push(` Sample: ${t}${n}`)}if(e.warnings.length>0)for(let t of e.warnings)a.push(` Warning: ${t}`);return a.push(``),r(t(i,`.ok`,`config.yml`))?(a.push(` To adjust scope, add patterns to .okignore at the project root.`),a.push(` To change the content root, edit .ok/config.yml → content.dir.`)):a.push(" Run `open-knowledge init` to scaffold config + .okignore."),a.push(``),a.push(` Re-check anytime: open-knowledge preview`),a.join(`
1
+ import{jr as e}from"./src-YfpQ2LX0.mjs";import"./constants-XFun_cA1.mjs";import{join as t,relative as n}from"node:path";import{existsSync as r,lstatSync as i,readdirSync as a,realpathSync as o,statSync as s}from"node:fs";function c(r){let{projectDir:c,contentDir:l,sampleCap:u=5}=r,d=[],f=[];try{i(l)}catch(e){return{totalCount:0,sample:[],contentDir:l,warnings:[`cannot access content directory ${l}: ${e instanceof Error?e.message:String(e)}`]}}let p;try{p=e({projectDir:c,contentDir:l})}catch(e){return{totalCount:0,sample:[],contentDir:l,warnings:[e instanceof Error?e.message:String(e)]}}function m(e){let r;try{r=a(e,{withFileTypes:!0})}catch(t){let r=t instanceof Error?t.message:String(t);d.push(`could not read directory ${n(l,e)||`.`}: ${r}`);return}for(let i of r){let r=t(e,i.name);if(i.isSymbolicLink()){let e;try{e=o(r)}catch(e){let t=e.code;t===`ENOENT`||t===`ELOOP`?d.push(`broken or cyclic symlink: ${n(l,r)}`):d.push(`cannot resolve symlink ${n(l,r)}: ${t??`unknown error`}`);continue}let t;try{t=s(e)}catch{continue}if(t.isDirectory()){let e=n(l,r);if(p.isDirExcluded(e))continue;m(r)}else if(t.isFile()){let e=n(l,r);if(p.isExcluded(e))continue;f.push(e)}}else if(i.isDirectory()){let e=n(l,r);if(p.isDirExcluded(e))continue;m(r)}else if(i.isFile()){let e=n(l,r);if(p.isExcluded(e))continue;f.push(e)}}}return m(l),{totalCount:f.length,sample:f.slice(0,u),contentDir:l,warnings:d}}function l(e,i){let a=[],o=n(i,e.contentDir),s=o===``?`./`:`./${o}`;if(a.push(`Content:`),a.push(` Found ${e.totalCount} markdown files in ${s}`),e.sample.length>0){let t=e.sample.join(`, `),n=e.totalCount>e.sample.length?`, …`:``;a.push(` Sample: ${t}${n}`)}if(e.warnings.length>0)for(let t of e.warnings)a.push(` Warning: ${t}`);return a.push(``),r(t(i,`.ok`,`config.yml`))?(a.push(` To adjust scope, add patterns to .okignore at the project root.`),a.push(` To change the content root, edit .ok/config.yml → content.dir.`)):a.push(" Run `open-knowledge init` to scaffold config + .okignore."),a.push(``),a.push(` Re-check anytime: open-knowledge preview`),a.join(`
2
2
  `)}export{c as n,l as t};
3
- //# sourceMappingURL=preview-CA6178UK.mjs.map
3
+ //# sourceMappingURL=preview-JtgY3qRY.mjs.map
@@ -0,0 +1 @@
1
+ import{n as e,t}from"./preview-JtgY3qRY.mjs";export{t as formatPreviewBlock,e as previewContent};
@@ -0,0 +1 @@
1
+ import{t as e}from"./index-BqVIdejq.js";export{e as FeedbackForm};
@@ -1 +1 @@
1
- import{o as e}from"./chunk-CYidjpOJ.js";import{t}from"./jsx-runtime-BUgB2tll.js";import{Gt as n,Lt as r,Rt as i,Xt as a,_t as o,bt as s,gn as c,k as l,mn as u,xt as d,yt as f}from"./DocumentContext-CzZ4OdU4.js";import{t as p}from"./react-f2sANaYj.js";import{n as m}from"./dist-PQ5KMVDh.js";import{t as h}from"./compiler-runtime-BfE3aGVn.js";import{E as g,a as ee,i as te,o as ne}from"./CodeMirrorPropInput-Bou_Ebnm.js";import{Ea as _,Ia as v,Li as re,T as ie,Tr as y,ba as b,ti as ae}from"./dist-P5PuqHtu2.js";import{A as oe,C as x,D as se,I as ce,N as le,a as ue,i as de,j as fe,t as pe,u as me,x as he}from"./typing-burst-detector-Cw9AAqnc.js";import{f as S,g as C}from"./doc-paths-BUecntHC.js";import{v as ge}from"./use-settings-route-B10M97I7.js";import{J as w}from"./navigation-targets-BTpBtlo2.js";import"./config-provider-BTrHDE5x.js";import{n as _e}from"./config-context-3DA5oQRi.js";import{Dt as T,E,Et as D,Ft as O,It as k,J as A,Ot as ve,P as j,Q as M,X as N,_ as P,ct as F,dt as I,ft as L,ht as R,l as z,lt as B,mt as ye,nt as V,rt as H,st as U,tt as W,y as G}from"./dist-zYQJXuRH.js";import{a as be,n as K}from"./cm-theme-CUwlOcHl.js";import{i as q,n as J,o as Y,r as X}from"./dist-DgD72kci.js";import{o as xe,r as Se}from"./selection-context-BSXn0gOl.js";import{l as Ce}from"./lint-config-client-Ctx6XxuK.js";import{a as we,i as Z,n as Te,o as Ee,r as De,t as Oe}from"./dist-BX-8uxZE.js";import{n as ke,t as Ae}from"./src-DC-8XMb-.js";var Q=e(p(),1),je=h();function Me(){let e=d();return e===null?null:new Set(e.keys())}function Ne(e,t,n){let r=[],i=j(e);if(n!=null){let a=[];for(let{from:e,to:n}of t)i.iterate({from:e,to:n,enter(e){if(e.name===`InlineCode`||e.name===`FencedCode`)return a.push({from:e.from,to:e.to}),!1}});let o=(e,t)=>a.some(n=>e>=n.from&&t<=n.to);for(let{from:i,to:a}of t){let t=e.doc.sliceString(i,a);_.lastIndex=0;for(let e=_.exec(t);e!==null;e=_.exec(t)){let t=e[2];if(!v(t))continue;let a=i+(e.index??0)+e[1].length,s=a+t.length+1;o(a,s)||r.push(A.mark({class:n.has(t)?`cm-skill-ref`:`cm-skill-ref cm-skill-ref-missing`,attributes:{"data-skill-ref":t}}).range(a,s))}}}for(let{from:a,to:s}of t)i.iterate({from:a,to:s,enter(t){if(t.name!==`InlineCode`)return;let i=e.doc.sliceString(t.from,t.to),a=i.length-i.replace(/^`+/,``).length,s=i.length-i.replace(/`+$/,``).length,c=i.slice(a,i.length-s),l=/^\/([a-z0-9][a-z0-9-]{1,63})$/.exec(c)?.[1];if(l!==void 0&&v(l)&&n!=null)return r.push(A.mark({class:n.has(l)?`cm-skill-ref`:`cm-skill-ref cm-skill-ref-missing`,attributes:{"data-skill-ref":l}}).range(t.from+a,t.to-s)),!1;let u=o.exec(c);if(u)return r.push(A.mark({class:`cm-skill-path-link`,attributes:{"data-skill-path":u[1]}}).range(t.from+a,t.to-s)),!1}});return r.sort((e,t)=>e.from-t.from||e.value.startSide-t.value.startSide),A.set(r)}function Pe(e){let t=s(e);return t===null?[]:[M.fromClass(class{decorations;constructor(e){this.decorations=Ne(e.state,e.visibleRanges,Me())}update(e){(e.docChanged||e.viewportChanged||j(e.startState)!==j(e.state))&&(this.decorations=Ne(e.view.state,e.view.visibleRanges,Me()))}},{decorations:e=>e.decorations}),N.domEventHandlers({mousedown(n){let r=n.target?.closest?.(`[data-skill-ref]`),i=r instanceof HTMLElement?r.dataset.skillRef:void 0;if(i!==void 0){n.preventDefault();let e=d()?.get(i);return window.location.hash=e===void 0?C():S(w({scope:e.scope,name:i,path:e.path})),!0}let a=n.target?.closest?.(`.cm-skill-path-link`),o=a instanceof HTMLElement?a.dataset.skillPath:void 0;return o===void 0?!1:(n.preventDefault(),window.location.hash=f(t,e,o),!0)}})]}function Fe(e,t){return e.enabled?[Oe(),De(async n=>Ie(n.state.doc,await y(n.state.doc.toString(),e,t)),{delay:600})]:[]}function $(e,t){let n=Math.min(Math.max(t.line+1,1),e.lines),r=e.line(n);return Math.min(r.from+Math.max(0,t.character),r.to)}function Ie(e,t){let n=[];for(let r of t){let t=$(e,r.range.start),i=$(e,r.range.end),a={from:t,to:Math.max(i,t),severity:r.severity,message:r.message,source:`${r.source}/${r.code}`},o=Le(r);o&&(a.actions=[o]),n.push(a)}return n}function Le(e){let t=e.fixes;return!t||t.length===0?null:{name:`Fix`,apply(e){let n=e.state.doc;e.dispatch({changes:t.map(e=>({from:$(n,e.range.start),to:$(n,e.range.end),insert:e.newText}))})}}}var Re=[L(),F(),B(),P(),V(),H(),ve.allowMultipleSelections.of(!0),E(),z(),X(),J(),R(),W(),U(),Z(),I.of([...q,...K,...Ee,...G,...Y,...Te])],ze=A.mark({class:`cm-link-ref-broken`}),Be=/^\s{0,3}\[([^\]]+)\]:\s/,Ve=/\[([^\]]*)\]\[([^\]]*)\]/g,He=new Set([`FencedCode`,`CodeBlock`,`InlineCode`]);function Ue(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 We(e){let t=[];return j(e).iterate({enter(e){if(He.has(e.name))return t.push({from:e.from,to:e.to}),!1}}),t.sort((e,t)=>e.from-t.from),t}function Ge(e){let t=new Set,n=[],r=e.doc,i=We(e);for(let e=1;e<=r.lines;e++){let n=r.line(e);if(Ue(n.from,i))continue;let a=Be.exec(n.text);a&&t.add(a[1].toLowerCase())}for(let e=1;e<=r.lines;e++){let t=r.line(e);if(!Ue(t.from,i)&&!Be.test(t.text))for(Ve.lastIndex=0;;){let e=Ve.exec(t.text);if(!e)break;let r=t.from+e.index;if(Ue(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(ze.range(e.from,e.to));return a.sort((e,t)=>e.from-t.from),A.set(a)}var Ke=k.define({create(e){return Ge(e)},update(e,t){return t.docChanged?Ge(t.state):e},provide:e=>N.decorations.from(e)}),qe=/^(\s*(?:[-*+]|\d+[.)]) (?:\[[ x]\] )?)/,Je=A.mark({class:`cm-del`}),Ye=A.line({class:`cm-table-header`,attributes:{style:`--list-hang: 2ch`}}),Xe=A.line({class:`cm-table-row`,attributes:{style:`--list-hang: 2ch`}});function Ze(e){let t=0;for(let n of e)if(n===` `)t++;else if(n===` `)t+=4;else break;return t}function Qe(e){if(e.doc.lines<2)return null;let t=e.doc.line(1);if(!b.test(t.text))return null;for(let n=2;n<=e.doc.lines;n++){let r=e.doc.line(n);if(b.test(r.text))return{from:t.from,to:r.to}}return null}function $e(e,t){let n=[],r=j(e),i=Qe(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(Je.range(e,r)),!1}if(t.name===`ListItem`){let r=e.doc.lineAt(t.from),i=qe.exec(r.text),a=i?i[1].length:2,o=A.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=Ze(r.text),a=A.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(Ye.range(r.from)),!1}if(t.name===`TableRow`){let r=e.doc.lineAt(t.from);return n.push(Xe.range(r.from)),!1}if(t.name===`TableDelimiter`&&t.node.parent?.name===`Table`){let r=e.doc.lineAt(t.from);return n.push(Xe.range(r.from)),!1}}}});return n.sort((e,t)=>e.from-t.from||e.value.startSide-t.value.startSide),A.set(n)}var et=class{decorations;constructor(e){this.decorations=$e(e.state,e.visibleRanges)}update(e){(e.docChanged||e.viewportChanged||j(e.startState)!==j(e.state))&&(this.decorations=$e(e.view.state,e.view.visibleRanges))}},tt=M.fromClass(et,{decorations:e=>e.decorations});function nt(){return[tt,Ke]}var rt=t(),it=56,at=O.define();function ot(e,t,n){let r=x(e.state.doc)[t.index];r&&a(n,()=>{e.dispatch({selection:T.cursor(r.from),effects:N.scrollIntoView(r.from,{y:`start`})}),e.focus()})}function st(e,t,n,r){requestAnimationFrame(()=>{if(!n())return;let i=e.state.doc,o=Math.min(t.offset,i.length);a(r,()=>{e.dispatch({selection:T.cursor(o),effects:N.scrollIntoView(o,{y:`center`})}),e.focus()})})}function ct(e,t,n){let r=e.state.doc,i=Math.min(Math.max(t.line,1),r.lines),o=r.line(i),s=Math.min(o.from+Math.max(0,t.column-1),o.to);a(n,()=>{e.dispatch({selection:T.cursor(s),effects:N.scrollIntoView(s,{y:`start`})}),e.focus()})}function lt(e){let t=(0,je.c)(50),{docName:a,ytext:o,provider:s,placeholder:d,isSourceModeActive:f}=e,p=(0,Q.useRef)(null),h=(0,Q.useRef)(null),[g,_]=(0,Q.useState)(null);if(g)throw g;let{resolvedTheme:v}=m(),{merged:y}=_e(),b=(0,Q.useRef)(f),x=y?.editor?.wordWrap??!0,{data:S}=Ce(a),C;t[0]!==S?.effective||t[1]!==y?(C=S?.effective??(y?.contentRules?ae(y.contentRules):ie),t[0]=S?.effective,t[1]=y,t[2]=C):C=t[2];let w=C,T;t[3]===w?T=t[4]:(T=JSON.stringify(w),t[3]=w,t[4]=T);let E=T,O,k;t[5]===f?(O=t[6],k=t[7]):(O=()=>{b.current=f},k=[f],t[5]=f,t[6]=O,t[7]=k),(0,Q.useEffect)(O,k);let A=(0,Q.useRef)(null),j;t[8]!==a||t[9]!==w||t[10]!==d||t[11]!==s||t[12]!==v||t[13]!==x||t[14]!==o?(j=()=>{let e=p.current;if(!e)return;let t=s.configuration.name??``,f,m=dt;try{f=r({docName:t,container:e,sizeStats:{viewCount:0,bytes:o.length},factory:e=>{let r=null,i=l({ydoc:s.document,ytext:o}),c=new D,u=new D,f=new D,p=new D,h=new N({state:ve.create({doc:o.toString(),extensions:[Re,we({scrollToMatch:e=>n(t)?N.scrollIntoView(e,{y:`start`}):at.of(null)}),I.of([be]),Ae(o,s.awareness),I.of(ke),...te({themeCompartment:c,resolvedTheme:v,ydoc:s.document,wordWrapCompartment:u,wordWrap:x,currentDocName:t}),nt(),Pe(t),ce(),p.of(Fe(w,a)),i,N.updateListener.of(e=>{!e.selectionSet&&!e.docChanged||(r!==null&&clearTimeout(r),r=setTimeout(()=>{r=null,de(t,`source`,ue(e.view)),Se(t,`source`,xe(e.view,t))},120))}),N.domEventHandlers({keydown:(e,t)=>!b.current||!re()||!ge(e,`edit-with-ai`)?!1:(e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation(),pe(),!0)}),f.of(ye(d??``)),N.theme({"&":{height:`100%`}}),N.scrollMargins.of(ut)]}),parent:e});de(t,`source`,ue(h)),Se(t,`source`,xe(h,t));let g=h.contentDOM;return g.addEventListener(`keydown`,m),g.addEventListener(`paste`,m),g.addEventListener(`drop`,m),g.addEventListener(`cut`,m),{view:h,ydoc:s.document,ytext:o,provider:s,themeCompartment:c,wordWrapCompartment:u,placeholderCompartment:f,lintCompartment:p}}}),A.current=f,h.current=f.view,u(a,f.view)}catch(e){let t=e;console.error(`[SourceEditor] mountCmEditor failed`,t),A.current=null,h.current=null,_(t instanceof Error?t:Error(String(t)))}return()=>{let e=A.current;e&&(i(e),c(a,e.view)),A.current=null,h.current=null}},t[8]=a,t[9]=w,t[10]=d,t[11]=s,t[12]=v,t[13]=x,t[14]=o,t[15]=j):j=t[15];let M;t[16]!==s||t[17]!==o?(M=[o,s],t[16]=s,t[17]=o,t[18]=M):M=t[18],(0,Q.useEffect)(j,M);let P,F;t[19]===a?(P=t[20],F=t[21]):(P=()=>{},F=[a],t[19]=a,t[20]=P,t[21]=F),(0,Q.useEffect)(P,F);let L,R;t[22]===v?(L=t[23],R=t[24]):(R=()=>{let e=A.current;e&&e.view.dispatch({effects:e.themeCompartment.reconfigure(v===`dark`?ee:ne)})},L=[v],t[22]=v,t[23]=L,t[24]=R),(0,Q.useEffect)(R,L);let z,B;t[25]===x?(z=t[26],B=t[27]):(z=()=>{let e=A.current;e&&e.view.dispatch({effects:e.wordWrapCompartment.reconfigure(x?N.lineWrapping:[])})},B=[x],t[25]=x,t[26]=z,t[27]=B),(0,Q.useEffect)(z,B);let V,H;t[28]===d?(V=t[29],H=t[30]):(V=()=>{let e=A.current;e&&e.view.dispatch({effects:e.placeholderCompartment.reconfigure(ye(d??``))})},H=[d],t[28]=d,t[29]=V,t[30]=H),(0,Q.useEffect)(V,H);let U;t[31]!==a||t[32]!==w?(U=()=>{let e=A.current;e&&e.view.dispatch({effects:e.lintCompartment.reconfigure(Fe(w,a))})},t[31]=a,t[32]=w,t[33]=U):U=t[33];let W;t[34]===E?W=t[35]:(W=[E],t[34]=E,t[35]=W),(0,Q.useEffect)(U,W);let G,K;t[36]!==a||t[37]!==f?(G=()=>{let e=function(e){let t=e.detail;if(!t||t.docName!==a||t.mode!==`source`||!f)return;let n=h.current;n&&(ot(n,t,a),oe(a))};return window.addEventListener(he,e),()=>window.removeEventListener(he,e)},K=[a,f],t[36]=a,t[37]=f,t[38]=G,t[39]=K):(G=t[38],K=t[39]),(0,Q.useEffect)(G,K);let q,J;t[40]!==a||t[41]!==f?(q=()=>{let e=function(e){let t=e.detail;if(!t||t.docName!==a||!f)return;let n=h.current;n&&(ct(n,t,a),oe(a))};return window.addEventListener(me,e),()=>window.removeEventListener(me,e)},J=[a,f],t[40]=a,t[41]=f,t[42]=q,t[43]=J):(q=t[42],J=t[43]),(0,Q.useEffect)(q,J);let Y,X;t[44]!==a||t[45]!==f||t[46]!==s?(Y=()=>{if(!f)return;let e=h.current;if(!e)return;let t=le(a);if(!t)return;if(t.kind!==`selection-offset`){fe(a),t.kind===`outline`?ot(e,t.detail,a):t.kind===`lint`?ct(e,t.detail,a):t.kind===`raw-mdx`&&st(e,t.detail,()=>b.current,a);return}let n=!1,r=null;return queueMicrotask(()=>{if(n)return;let t=le(a);t?.kind===`selection-offset`&&(r=se({view:e,docName:a,navigation:t,ydoc:s.document,transition:{from:`wysiwyg`,to:`source`}}),r&&fe(a))}),()=>{n=!0,r?.cancel(`mode-flip`)}},X=[a,f,s],t[44]=a,t[45]=f,t[46]=s,t[47]=Y,t[48]=X):(Y=t[47],X=t[48]),(0,Q.useEffect)(Y,X);let Z;return t[49]===Symbol.for(`react.memo_cache_sentinel`)?(Z=(0,rt.jsx)(`div`,{ref:p,className:`source-editor h-full pb-3`}),t[49]=Z):Z=t[49],Z}function ut(){return{top:it}}function dt(){return g()}export{lt as SourceEditor,st as applyRawMdxNavigation};
1
+ import{o as e}from"./chunk-CYidjpOJ.js";import{t}from"./jsx-runtime-BUgB2tll.js";import{Gt as n,Lt as r,Rt as i,Xt as a,_t as o,bt as s,gn as c,k as l,mn as u,xt as d,yt as f}from"./DocumentContext-CzZ4OdU4.js";import{t as p}from"./react-f2sANaYj.js";import{n as m}from"./dist-PQ5KMVDh.js";import{t as h}from"./compiler-runtime-BfE3aGVn.js";import{E as g,a as ee,i as te,o as ne}from"./CodeMirrorPropInput-Bou_Ebnm.js";import{Ea as _,Ia as v,Li as re,T as ie,Tr as y,ba as b,ti as ae}from"./dist-P5PuqHtu2.js";import{A as oe,C as x,D as se,I as ce,N as le,a as ue,i as de,j as fe,t as pe,u as me,x as he}from"./typing-burst-detector-BR1q4MiH.js";import{f as S,g as C}from"./doc-paths-BUecntHC.js";import{v as ge}from"./use-settings-route-B10M97I7.js";import{J as w}from"./navigation-targets-BTpBtlo2.js";import"./config-provider-BTrHDE5x.js";import{n as _e}from"./config-context-3DA5oQRi.js";import{Dt as T,E,Et as D,Ft as O,It as k,J as A,Ot as ve,P as j,Q as M,X as N,_ as P,ct as F,dt as I,ft as L,ht as R,l as z,lt as B,mt as ye,nt as V,rt as H,st as U,tt as W,y as G}from"./dist-zYQJXuRH.js";import{a as be,n as K}from"./cm-theme-CUwlOcHl.js";import{i as q,n as J,o as Y,r as X}from"./dist-DgD72kci.js";import{o as xe,r as Se}from"./selection-context-BSXn0gOl.js";import{l as Ce}from"./lint-config-client-Ctx6XxuK.js";import{a as we,i as Z,n as Te,o as Ee,r as De,t as Oe}from"./dist-BX-8uxZE.js";import{n as ke,t as Ae}from"./src-DC-8XMb-.js";var Q=e(p(),1),je=h();function Me(){let e=d();return e===null?null:new Set(e.keys())}function Ne(e,t,n){let r=[],i=j(e);if(n!=null){let a=[];for(let{from:e,to:n}of t)i.iterate({from:e,to:n,enter(e){if(e.name===`InlineCode`||e.name===`FencedCode`)return a.push({from:e.from,to:e.to}),!1}});let o=(e,t)=>a.some(n=>e>=n.from&&t<=n.to);for(let{from:i,to:a}of t){let t=e.doc.sliceString(i,a);_.lastIndex=0;for(let e=_.exec(t);e!==null;e=_.exec(t)){let t=e[2];if(!v(t))continue;let a=i+(e.index??0)+e[1].length,s=a+t.length+1;o(a,s)||r.push(A.mark({class:n.has(t)?`cm-skill-ref`:`cm-skill-ref cm-skill-ref-missing`,attributes:{"data-skill-ref":t}}).range(a,s))}}}for(let{from:a,to:s}of t)i.iterate({from:a,to:s,enter(t){if(t.name!==`InlineCode`)return;let i=e.doc.sliceString(t.from,t.to),a=i.length-i.replace(/^`+/,``).length,s=i.length-i.replace(/`+$/,``).length,c=i.slice(a,i.length-s),l=/^\/([a-z0-9][a-z0-9-]{1,63})$/.exec(c)?.[1];if(l!==void 0&&v(l)&&n!=null)return r.push(A.mark({class:n.has(l)?`cm-skill-ref`:`cm-skill-ref cm-skill-ref-missing`,attributes:{"data-skill-ref":l}}).range(t.from+a,t.to-s)),!1;let u=o.exec(c);if(u)return r.push(A.mark({class:`cm-skill-path-link`,attributes:{"data-skill-path":u[1]}}).range(t.from+a,t.to-s)),!1}});return r.sort((e,t)=>e.from-t.from||e.value.startSide-t.value.startSide),A.set(r)}function Pe(e){let t=s(e);return t===null?[]:[M.fromClass(class{decorations;constructor(e){this.decorations=Ne(e.state,e.visibleRanges,Me())}update(e){(e.docChanged||e.viewportChanged||j(e.startState)!==j(e.state))&&(this.decorations=Ne(e.view.state,e.view.visibleRanges,Me()))}},{decorations:e=>e.decorations}),N.domEventHandlers({mousedown(n){let r=n.target?.closest?.(`[data-skill-ref]`),i=r instanceof HTMLElement?r.dataset.skillRef:void 0;if(i!==void 0){n.preventDefault();let e=d()?.get(i);return window.location.hash=e===void 0?C():S(w({scope:e.scope,name:i,path:e.path})),!0}let a=n.target?.closest?.(`.cm-skill-path-link`),o=a instanceof HTMLElement?a.dataset.skillPath:void 0;return o===void 0?!1:(n.preventDefault(),window.location.hash=f(t,e,o),!0)}})]}function Fe(e,t){return e.enabled?[Oe(),De(async n=>Ie(n.state.doc,await y(n.state.doc.toString(),e,t)),{delay:600})]:[]}function $(e,t){let n=Math.min(Math.max(t.line+1,1),e.lines),r=e.line(n);return Math.min(r.from+Math.max(0,t.character),r.to)}function Ie(e,t){let n=[];for(let r of t){let t=$(e,r.range.start),i=$(e,r.range.end),a={from:t,to:Math.max(i,t),severity:r.severity,message:r.message,source:`${r.source}/${r.code}`},o=Le(r);o&&(a.actions=[o]),n.push(a)}return n}function Le(e){let t=e.fixes;return!t||t.length===0?null:{name:`Fix`,apply(e){let n=e.state.doc;e.dispatch({changes:t.map(e=>({from:$(n,e.range.start),to:$(n,e.range.end),insert:e.newText}))})}}}var Re=[L(),F(),B(),P(),V(),H(),ve.allowMultipleSelections.of(!0),E(),z(),X(),J(),R(),W(),U(),Z(),I.of([...q,...K,...Ee,...G,...Y,...Te])],ze=A.mark({class:`cm-link-ref-broken`}),Be=/^\s{0,3}\[([^\]]+)\]:\s/,Ve=/\[([^\]]*)\]\[([^\]]*)\]/g,He=new Set([`FencedCode`,`CodeBlock`,`InlineCode`]);function Ue(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 We(e){let t=[];return j(e).iterate({enter(e){if(He.has(e.name))return t.push({from:e.from,to:e.to}),!1}}),t.sort((e,t)=>e.from-t.from),t}function Ge(e){let t=new Set,n=[],r=e.doc,i=We(e);for(let e=1;e<=r.lines;e++){let n=r.line(e);if(Ue(n.from,i))continue;let a=Be.exec(n.text);a&&t.add(a[1].toLowerCase())}for(let e=1;e<=r.lines;e++){let t=r.line(e);if(!Ue(t.from,i)&&!Be.test(t.text))for(Ve.lastIndex=0;;){let e=Ve.exec(t.text);if(!e)break;let r=t.from+e.index;if(Ue(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(ze.range(e.from,e.to));return a.sort((e,t)=>e.from-t.from),A.set(a)}var Ke=k.define({create(e){return Ge(e)},update(e,t){return t.docChanged?Ge(t.state):e},provide:e=>N.decorations.from(e)}),qe=/^(\s*(?:[-*+]|\d+[.)]) (?:\[[ x]\] )?)/,Je=A.mark({class:`cm-del`}),Ye=A.line({class:`cm-table-header`,attributes:{style:`--list-hang: 2ch`}}),Xe=A.line({class:`cm-table-row`,attributes:{style:`--list-hang: 2ch`}});function Ze(e){let t=0;for(let n of e)if(n===` `)t++;else if(n===` `)t+=4;else break;return t}function Qe(e){if(e.doc.lines<2)return null;let t=e.doc.line(1);if(!b.test(t.text))return null;for(let n=2;n<=e.doc.lines;n++){let r=e.doc.line(n);if(b.test(r.text))return{from:t.from,to:r.to}}return null}function $e(e,t){let n=[],r=j(e),i=Qe(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(Je.range(e,r)),!1}if(t.name===`ListItem`){let r=e.doc.lineAt(t.from),i=qe.exec(r.text),a=i?i[1].length:2,o=A.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=Ze(r.text),a=A.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(Ye.range(r.from)),!1}if(t.name===`TableRow`){let r=e.doc.lineAt(t.from);return n.push(Xe.range(r.from)),!1}if(t.name===`TableDelimiter`&&t.node.parent?.name===`Table`){let r=e.doc.lineAt(t.from);return n.push(Xe.range(r.from)),!1}}}});return n.sort((e,t)=>e.from-t.from||e.value.startSide-t.value.startSide),A.set(n)}var et=class{decorations;constructor(e){this.decorations=$e(e.state,e.visibleRanges)}update(e){(e.docChanged||e.viewportChanged||j(e.startState)!==j(e.state))&&(this.decorations=$e(e.view.state,e.view.visibleRanges))}},tt=M.fromClass(et,{decorations:e=>e.decorations});function nt(){return[tt,Ke]}var rt=t(),it=56,at=O.define();function ot(e,t,n){let r=x(e.state.doc)[t.index];r&&a(n,()=>{e.dispatch({selection:T.cursor(r.from),effects:N.scrollIntoView(r.from,{y:`start`})}),e.focus()})}function st(e,t,n,r){requestAnimationFrame(()=>{if(!n())return;let i=e.state.doc,o=Math.min(t.offset,i.length);a(r,()=>{e.dispatch({selection:T.cursor(o),effects:N.scrollIntoView(o,{y:`center`})}),e.focus()})})}function ct(e,t,n){let r=e.state.doc,i=Math.min(Math.max(t.line,1),r.lines),o=r.line(i),s=Math.min(o.from+Math.max(0,t.column-1),o.to);a(n,()=>{e.dispatch({selection:T.cursor(s),effects:N.scrollIntoView(s,{y:`start`})}),e.focus()})}function lt(e){let t=(0,je.c)(50),{docName:a,ytext:o,provider:s,placeholder:d,isSourceModeActive:f}=e,p=(0,Q.useRef)(null),h=(0,Q.useRef)(null),[g,_]=(0,Q.useState)(null);if(g)throw g;let{resolvedTheme:v}=m(),{merged:y}=_e(),b=(0,Q.useRef)(f),x=y?.editor?.wordWrap??!0,{data:S}=Ce(a),C;t[0]!==S?.effective||t[1]!==y?(C=S?.effective??(y?.contentRules?ae(y.contentRules):ie),t[0]=S?.effective,t[1]=y,t[2]=C):C=t[2];let w=C,T;t[3]===w?T=t[4]:(T=JSON.stringify(w),t[3]=w,t[4]=T);let E=T,O,k;t[5]===f?(O=t[6],k=t[7]):(O=()=>{b.current=f},k=[f],t[5]=f,t[6]=O,t[7]=k),(0,Q.useEffect)(O,k);let A=(0,Q.useRef)(null),j;t[8]!==a||t[9]!==w||t[10]!==d||t[11]!==s||t[12]!==v||t[13]!==x||t[14]!==o?(j=()=>{let e=p.current;if(!e)return;let t=s.configuration.name??``,f,m=dt;try{f=r({docName:t,container:e,sizeStats:{viewCount:0,bytes:o.length},factory:e=>{let r=null,i=l({ydoc:s.document,ytext:o}),c=new D,u=new D,f=new D,p=new D,h=new N({state:ve.create({doc:o.toString(),extensions:[Re,we({scrollToMatch:e=>n(t)?N.scrollIntoView(e,{y:`start`}):at.of(null)}),I.of([be]),Ae(o,s.awareness),I.of(ke),...te({themeCompartment:c,resolvedTheme:v,ydoc:s.document,wordWrapCompartment:u,wordWrap:x,currentDocName:t}),nt(),Pe(t),ce(),p.of(Fe(w,a)),i,N.updateListener.of(e=>{!e.selectionSet&&!e.docChanged||(r!==null&&clearTimeout(r),r=setTimeout(()=>{r=null,de(t,`source`,ue(e.view)),Se(t,`source`,xe(e.view,t))},120))}),N.domEventHandlers({keydown:(e,t)=>!b.current||!re()||!ge(e,`edit-with-ai`)?!1:(e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation(),pe(),!0)}),f.of(ye(d??``)),N.theme({"&":{height:`100%`}}),N.scrollMargins.of(ut)]}),parent:e});de(t,`source`,ue(h)),Se(t,`source`,xe(h,t));let g=h.contentDOM;return g.addEventListener(`keydown`,m),g.addEventListener(`paste`,m),g.addEventListener(`drop`,m),g.addEventListener(`cut`,m),{view:h,ydoc:s.document,ytext:o,provider:s,themeCompartment:c,wordWrapCompartment:u,placeholderCompartment:f,lintCompartment:p}}}),A.current=f,h.current=f.view,u(a,f.view)}catch(e){let t=e;console.error(`[SourceEditor] mountCmEditor failed`,t),A.current=null,h.current=null,_(t instanceof Error?t:Error(String(t)))}return()=>{let e=A.current;e&&(i(e),c(a,e.view)),A.current=null,h.current=null}},t[8]=a,t[9]=w,t[10]=d,t[11]=s,t[12]=v,t[13]=x,t[14]=o,t[15]=j):j=t[15];let M;t[16]!==s||t[17]!==o?(M=[o,s],t[16]=s,t[17]=o,t[18]=M):M=t[18],(0,Q.useEffect)(j,M);let P,F;t[19]===a?(P=t[20],F=t[21]):(P=()=>{},F=[a],t[19]=a,t[20]=P,t[21]=F),(0,Q.useEffect)(P,F);let L,R;t[22]===v?(L=t[23],R=t[24]):(R=()=>{let e=A.current;e&&e.view.dispatch({effects:e.themeCompartment.reconfigure(v===`dark`?ee:ne)})},L=[v],t[22]=v,t[23]=L,t[24]=R),(0,Q.useEffect)(R,L);let z,B;t[25]===x?(z=t[26],B=t[27]):(z=()=>{let e=A.current;e&&e.view.dispatch({effects:e.wordWrapCompartment.reconfigure(x?N.lineWrapping:[])})},B=[x],t[25]=x,t[26]=z,t[27]=B),(0,Q.useEffect)(z,B);let V,H;t[28]===d?(V=t[29],H=t[30]):(V=()=>{let e=A.current;e&&e.view.dispatch({effects:e.placeholderCompartment.reconfigure(ye(d??``))})},H=[d],t[28]=d,t[29]=V,t[30]=H),(0,Q.useEffect)(V,H);let U;t[31]!==a||t[32]!==w?(U=()=>{let e=A.current;e&&e.view.dispatch({effects:e.lintCompartment.reconfigure(Fe(w,a))})},t[31]=a,t[32]=w,t[33]=U):U=t[33];let W;t[34]===E?W=t[35]:(W=[E],t[34]=E,t[35]=W),(0,Q.useEffect)(U,W);let G,K;t[36]!==a||t[37]!==f?(G=()=>{let e=function(e){let t=e.detail;if(!t||t.docName!==a||t.mode!==`source`||!f)return;let n=h.current;n&&(ot(n,t,a),oe(a))};return window.addEventListener(he,e),()=>window.removeEventListener(he,e)},K=[a,f],t[36]=a,t[37]=f,t[38]=G,t[39]=K):(G=t[38],K=t[39]),(0,Q.useEffect)(G,K);let q,J;t[40]!==a||t[41]!==f?(q=()=>{let e=function(e){let t=e.detail;if(!t||t.docName!==a||!f)return;let n=h.current;n&&(ct(n,t,a),oe(a))};return window.addEventListener(me,e),()=>window.removeEventListener(me,e)},J=[a,f],t[40]=a,t[41]=f,t[42]=q,t[43]=J):(q=t[42],J=t[43]),(0,Q.useEffect)(q,J);let Y,X;t[44]!==a||t[45]!==f||t[46]!==s?(Y=()=>{if(!f)return;let e=h.current;if(!e)return;let t=le(a);if(!t)return;if(t.kind!==`selection-offset`){fe(a),t.kind===`outline`?ot(e,t.detail,a):t.kind===`lint`?ct(e,t.detail,a):t.kind===`raw-mdx`&&st(e,t.detail,()=>b.current,a);return}let n=!1,r=null;return queueMicrotask(()=>{if(n)return;let t=le(a);t?.kind===`selection-offset`&&(r=se({view:e,docName:a,navigation:t,ydoc:s.document,transition:{from:`wysiwyg`,to:`source`}}),r&&fe(a))}),()=>{n=!0,r?.cancel(`mode-flip`)}},X=[a,f,s],t[44]=a,t[45]=f,t[46]=s,t[47]=Y,t[48]=X):(Y=t[47],X=t[48]),(0,Q.useEffect)(Y,X);let Z;return t[49]===Symbol.for(`react.memo_cache_sentinel`)?(Z=(0,rt.jsx)(`div`,{ref:p,className:`source-editor h-full pb-3`}),t[49]=Z):Z=t[49],Z}function ut(){return{top:it}}function dt(){return g()}export{lt as SourceEditor,st as applyRawMdxNavigation};