@inkeep/open-knowledge 0.19.1 → 0.19.2-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 (48) 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 +6 -6
  4. package/dist/constants-CrJFjAGV.mjs +2 -0
  5. package/dist/{dist-CSYT3uRJ.mjs → dist-CAMeZSbI.mjs} +1 -1
  6. package/dist/{dist-dm_DI4lI.mjs → dist-L7DxXZ3e.mjs} +3 -3
  7. package/dist/{gh-detect-Drsi8mbA.mjs → gh-detect-D1zn4tRp.mjs} +2 -2
  8. package/dist/index.mjs +1 -1
  9. package/dist/init-BrbEuEbu.mjs +1 -0
  10. package/dist/{init-CmYOMgKC.mjs → init-FqiSJrgt.mjs} +4 -4
  11. package/dist/{loader-BxJBw2fK.mjs → loader-DXtBgcFj.mjs} +2 -2
  12. package/dist/loader-DthfP_c1.mjs +1 -0
  13. package/dist/preview-CKvW1411.mjs +1 -0
  14. package/dist/{preview-BV7XB7mb.mjs → preview-DeZLVNJn.mjs} +2 -2
  15. package/dist/public/assets/{ActivityModeContent-Dy1_JO4s.js → ActivityModeContent-BRxTdXzQ.js} +1 -1
  16. package/dist/public/assets/{DocumentContext-DppavGIB.js → DocumentContext-FzcL7UQZ.js} +11 -11
  17. package/dist/public/assets/{GraphPanel-B7tXBL9C.js → GraphPanel-Bell61wS.js} +2 -2
  18. package/dist/public/assets/{SettingsDialogBody-DgfCMlWX.js → SettingsDialogBody-dRCqGCnU.js} +2 -2
  19. package/dist/public/assets/{SourceEditor-CvVog_I5.js → SourceEditor-Bqcnc-Cc.js} +1 -1
  20. package/dist/public/assets/{TerminalPanel-gtDefA9J.js → TerminalPanel-Ta2Zl6Q8.js} +1 -1
  21. package/dist/public/assets/{config-validation-events-De91seTf.js → config-validation-events-gsbmznWN.js} +4 -4
  22. package/dist/public/assets/{dist-DzbxRXt5.js → dist-D2H0qs9k.js} +153 -153
  23. package/dist/public/assets/{index-Do4YGiKm.js → index--4pY9sQD.js} +11 -11
  24. package/dist/public/assets/{keyboard-shortcuts-CrOPSj32.js → keyboard-shortcuts-DdDIPI_l.js} +1 -1
  25. package/dist/public/assets/prop-types-CMddcK9H.js +11 -0
  26. package/dist/public/assets/{target-navigation-intent-BW8U2Njg.js → target-navigation-intent-Dxk9beLq.js} +1 -1
  27. package/dist/public/assets/{telemetry-impl-CSrH5jFm.js → telemetry-impl-DosSnbwM.js} +1 -1
  28. package/dist/public/assets/{typing-burst-detector-Wg72tb4K.js → typing-burst-detector-ktvC37ND.js} +1 -1
  29. package/dist/public/index.html +8 -8
  30. package/dist/{repair-launch-json-il6GUyPg.mjs → repair-launch-json-BaBh5Lb5.mjs} +2 -2
  31. package/dist/{repair-mcp-configs-CHoCpteG.mjs → repair-mcp-configs-ulh0L1bV.mjs} +2 -2
  32. package/dist/repair-skills-B6FAnZg1.mjs +1 -0
  33. package/dist/{repair-skills-CsRymFFj.mjs → repair-skills-CtiRAipc.mjs} +2 -2
  34. package/dist/server-lock-8Lv6A-Xa-HmVDbKSU.mjs +1 -0
  35. package/dist/{server-lock-CN2YHwpP-Cvbk69Pj.mjs → server-lock-CN2YHwpP-BWnMEaYY.mjs} +28 -28
  36. package/dist/{src-CybvsBnx.mjs → src-Ca_Iewxt.mjs} +2 -2
  37. package/dist/start-BtefHlUQ.mjs +1 -0
  38. package/dist/{start-w9D1neaB.mjs → start-Bzdvh77I.mjs} +2 -2
  39. package/dist/{write-project-skill-C3yO9LBO.mjs → write-project-skill-CpgIz0Rh.mjs} +2 -2
  40. package/package.json +1 -1
  41. package/dist/constants-BIi4blBg.mjs +0 -2
  42. package/dist/init-H3fMgKPp.mjs +0 -1
  43. package/dist/loader-BLqkBLEJ.mjs +0 -1
  44. package/dist/preview-EZePcwsb.mjs +0 -1
  45. package/dist/public/assets/prop-types-C0kDsvPx.js +0 -11
  46. package/dist/repair-skills-B57xTnpU.mjs +0 -1
  47. package/dist/server-lock-8Lv6A-Xa-BTQcAAhW.mjs +0 -1
  48. package/dist/start-CvWGTEtx.mjs +0 -1
@@ -1,4 +1,4 @@
1
- import{o as e}from"./chunk-CFjPhJqf.js";import{a as t,i as n,o as r,r as i,t as a}from"./compiler-runtime-Cs91PcD2.js";import{$ as o,An as s,G as c,K as l,it as u,n as d,q as f,ut as p}from"./DocumentContext-DppavGIB.js";import{a as ee,c as te,i as ne,n as re,o as ie,r as ae,s as oe,t as se,u as ce}from"./panel-BQ1weDcE.js";import{at as m,dr as h,nt as g}from"./dist-DzbxRXt5.js";import{l as le}from"./button-CmLxDlCv.js";import{i as ue,z as _}from"./prop-types-C0kDsvPx.js";import{$ as v,At as y,Bt as b,Dt as x,E as S,Et as C,Ft as w,Ht as T,J as E,Mt as D,N as O,Ot as k,Pt as A,Q as j,Rt as de,Ut as fe,X as M,_ as N,_t as P,ct as F,dt as I,et as L,f as pe,gt as me,ht as he,l as ge,lt as _e,mt as ve,nt as ye,ot as be,rt as xe,st as Se,tt as Ce,ut as we,wt as R,y as Te,yt as z,zt as Ee}from"./dist-C0jOOVYt.js";import{i as De,n as Oe,o as ke,r as Ae}from"./dist-j3LJSXW6.js";var je=e(t(),1),Me=a(),Ne=new Map;function Pe(e,t){Ne.set(e,t)}function Fe(e){let t=Ne.get(e)??null;return Ne.delete(e),t}function Ie(e){Ne.delete(e)}function Le(e,t){let n=(0,Me.c)(4),r=t===void 0?!1:t,[i,a]=(0,je.useState)(void 0),o=(0,je.useRef)(null),s,c;return n[0]!==r||n[1]!==e?(s=()=>{if(r||e.length===0){a(void 0);return}let t=function(){let t=window.innerHeight/2,n,r;for(let i of e){let e=document.getElementById(i);if(!e)continue;let a=e.getBoundingClientRect().top;a<0?n=i:r===void 0&&a<t&&(r=i)}a(r??n??e[0])},n=function(){o.current===null&&(o.current=requestAnimationFrame(()=>{o.current=null,t()}))};return document.addEventListener(`scroll`,n,{capture:!0,passive:!0}),t(),()=>{document.removeEventListener(`scroll`,n,{capture:!0}),o.current!==null&&(cancelAnimationFrame(o.current),o.current=null)}},c=[e,r],n[0]=r,n[1]=e,n[2]=s,n[3]=c):(s=n[2],c=n[3]),(0,je.useEffect)(s,c),i}var B=r(),Re=300;async function ze(e){let t=await fetch(`/api/page-headings?docName=${encodeURIComponent(e)}`),n;try{n=await t.json()}catch(e){throw new p(_._({id:`qAQVSD`}),{cause:e,status:t.status})}if(!t.ok){let e=m.safeParse(n);throw e.success?Error(e.data.title):new p(_._({id:`zlErBl`}),{status:t.status})}let r=g.safeParse(n);if(!r.success)throw new p(_._({id:`XW18jo`}),{status:t.status});return r.data.headings??[]}var Be=32,Ve=12,He=6,Ue=`open-knowledge:outline-nav`;function We(e){let t=(0,Me.c)(2),n;return t[0]===e?n=t[1]:(n=(0,B.jsx)(s,{name:`outline-panel`,children:(0,B.jsx)(Ge,{...e})}),t[0]=e,t[1]=n),n}function Ge(e){let t=(0,Me.c)(50),{docName:r,isSourceMode:a,className:o}=e,s=o===void 0?``:o,{_:c}=n(),{pages:l,loading:u}=ue(),f=ce(),{activeProvider:p,activeDocName:m}=d(),h,g;t[0]===r?(h=t[1],g=t[2]):(h=[`page-headings`,r],g=()=>ze(r),t[0]=r,t[1]=h,t[2]=g);let _;t[3]!==r||t[4]!==u||t[5]!==l?(_=!u&&l.has(r),t[3]=r,t[4]=u,t[5]=l,t[6]=_):_=t[6];let v;t[7]!==h||t[8]!==g||t[9]!==_?(v={queryKey:h,queryFn:g,enabled:_,staleTime:1/0},t[7]=h,t[8]=g,t[9]=_,t[10]=v):v=t[10];let{data:y,isLoading:b,error:x}=te(v),S;t[11]===y?S=t[12]:(S=y===void 0?[]:y,t[11]=y,t[12]=S);let C=S,w,T;t[13]!==m||t[14]!==p||t[15]!==r||t[16]!==f?(w=()=>{if(!p||m!==r)return;let e=p.document,t=null,n=()=>{t!==null&&clearTimeout(t),t=setTimeout(()=>{t=null,f.invalidateQueries({queryKey:[`page-headings`,r]})},Re)};return e.on(`update`,n),()=>{e.off(`update`,n),t!==null&&clearTimeout(t)}},T=[p,m,r,f],t[13]=m,t[14]=p,t[15]=r,t[16]=f,t[17]=w,t[18]=T):(w=t[17],T=t[18]),(0,je.useEffect)(w,T);let E;t[19]===C?E=t[20]:(E=C.map(Ke),t[19]=C,t[20]=E);let D=Le(E,a),O;t[21]!==D||t[22]!==C?(O=D?C.findIndex(e=>e.slug===D):-1,t[21]=D,t[22]=C,t[23]=O):O=t[23];let k=O,A;t[24]!==r||t[25]!==a?(A=function(e,t){let n={index:e,slug:t,mode:a?`source`:`wysiwyg`};n.mode===`source`&&Pe(r,{kind:`outline`,detail:n}),window.dispatchEvent(new CustomEvent(Ue,{detail:n}))},t[24]=r,t[25]=a,t[26]=A):A=t[26];let j=A,de=((k>=0?C[k].level:1)-1)*Ve+(Ve-He)/2,fe=k*Be+(Be-He)/2,M;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(M=(0,B.jsx)(oe,{children:(0,B.jsx)(i,{id:`dD7NPy`})}),t[27]=M):M=t[27];let N;t[28]!==C.length||t[29]!==b?(N=!b&&(0,B.jsx)(ae,{children:C.length}),t[28]=C.length,t[29]=b,t[30]=N):N=t[30];let P;t[31]===N?P=t[32]:(P=(0,B.jsxs)(ie,{children:[M,N]}),t[31]=N,t[32]=P);let F;t[33]!==c||t[34]!==k||t[35]!==D||t[36]!==x||t[37]!==j||t[38]!==C||t[39]!==b||t[40]!==de||t[41]!==fe?(F=x?(0,B.jsx)(ee,{className:`px-2`,children:x instanceof Error?x.message:c({id:`GuqOb1`})}):C.length===0&&!b?(0,B.jsx)(ne,{className:`px-2`,children:(0,B.jsx)(i,{id:`0BB9ID`})}):(0,B.jsxs)(`nav`,{"aria-label":c({id:`BymzO4`}),className:`relative`,children:[k>=0&&(0,B.jsx)(`div`,{"aria-hidden":`true`,className:`pointer-events-none absolute left-0 top-0 rounded-full bg-primary motion-safe:[transition:transform_0.25s_var(--ease-out-strong)]`,style:{width:He,height:He,transform:`translate(${de}px, ${fe}px)`}}),C.map((e,t)=>{let n=e.slug===D;return(0,B.jsx)(`button`,{type:`button`,"aria-current":n?`location`:void 0,onClick:()=>j(t,e.slug),className:le(`w-full cursor-pointer truncate py-1.5 pe-2 text-left text-sm transition-colors`,n?`font-medium text-primary`:`text-muted-foreground hover:text-foreground`),style:{paddingLeft:`${(e.level-1)*Ve+20}px`},title:e.text,children:e.text},t)})]}),t[33]=c,t[34]=k,t[35]=D,t[36]=x,t[37]=j,t[38]=C,t[39]=b,t[40]=de,t[41]=fe,t[42]=F):F=t[42];let I;t[43]!==b||t[44]!==F?(I=(0,B.jsx)(re,{className:`px-3 py-2`,"aria-busy":b,children:F}),t[43]=b,t[44]=F,t[45]=I):I=t[45];let L;return t[46]!==s||t[47]!==P||t[48]!==I?(L=(0,B.jsxs)(se,{className:s,children:[P,I]}),t[46]=s,t[47]=P,t[48]=I,t[49]=L):L=t[49],L}function Ke(e){return e.slug}var qe=typeof String.prototype.normalize==`function`?e=>e.normalize(`NFKD`):e=>e,V=class{constructor(e,t,n=0,r=e.length,i,a){this.test=a,this.value={from:0,to:0},this.done=!1,this.matches=[],this.buffer=``,this.bufferPos=0,this.iter=e.iterRange(n,r),this.bufferStart=n,this.normalize=i?e=>i(qe(e)):qe,this.query=this.normalize(t)}peek(){if(this.bufferPos==this.buffer.length){if(this.bufferStart+=this.buffer.length,this.iter.next(),this.iter.done)return-1;this.bufferPos=0,this.buffer=this.iter.value}return de(this.buffer,this.bufferPos)}next(){for(;this.matches.length;)this.matches.pop();return this.nextOverlapping()}nextOverlapping(){for(;;){let e=this.peek();if(e<0)return this.done=!0,this;let t=fe(e),n=this.bufferStart+this.bufferPos;this.bufferPos+=Ee(e);let r=this.normalize(t);if(r.length)for(let e=0,i=n;;e++){let a=r.charCodeAt(e),o=this.match(a,i,this.bufferPos+this.bufferStart);if(e==r.length-1){if(o)return this.value=o,this;break}i==n&&e<t.length&&t.charCodeAt(e)==a&&i++}}}match(e,t,n){let r=null;for(let t=0;t<this.matches.length;t+=2){let i=this.matches[t],a=!1;this.query.charCodeAt(i)==e&&(i==this.query.length-1?r={from:this.matches[t+1],to:n}:(this.matches[t]++,a=!0)),a||(this.matches.splice(t,2),t-=2)}return this.query.charCodeAt(0)==e&&(this.query.length==1?r={from:t,to:n}:this.matches.push(1,t)),r&&this.test&&!this.test(r.from,r.to,this.buffer,this.bufferStart)&&(r=null),r}};typeof Symbol<`u`&&(V.prototype[Symbol.iterator]=function(){return this});var Je={from:-1,to:-1,match:/.*/.exec(``)},Ye=`gm`+(/x/.unicode==null?``:`u`),Xe=class{constructor(e,t,n,r=0,i=e.length){if(this.text=e,this.to=i,this.curLine=``,this.done=!1,this.value=Je,/\\[sWDnr]|\n|\r|\[\^/.test(t))return new $e(e,t,n,r,i);this.re=new RegExp(t,Ye+(n?.ignoreCase?`i`:``)),this.test=n?.test,this.iter=e.iter(),this.curLineStart=e.lineAt(r).from,this.matchPos=tt(e,r),this.getLine(this.curLineStart)}getLine(e){this.iter.next(e),this.iter.lineBreak?this.curLine=``:(this.curLine=this.iter.value,this.curLineStart+this.curLine.length>this.to&&(this.curLine=this.curLine.slice(0,this.to-this.curLineStart)),this.iter.next())}nextLine(){this.curLineStart=this.curLineStart+this.curLine.length+1,this.curLineStart>this.to?this.curLine=``:this.getLine(0)}next(){for(let e=this.matchPos-this.curLineStart;;){this.re.lastIndex=e;let t=this.matchPos<=this.to&&this.re.exec(this.curLine);if(t){let n=this.curLineStart+t.index,r=n+t[0].length;if(this.matchPos=tt(this.text,r+ +(n==r)),n==this.curLineStart+this.curLine.length&&this.nextLine(),(n<r||n>this.value.to)&&(!this.test||this.test(n,r,t)))return this.value={from:n,to:r,match:t},this;e=this.matchPos-this.curLineStart}else if(this.curLineStart+this.curLine.length<this.to)this.nextLine(),e=0;else return this.done=!0,this}}},Ze=new WeakMap,Qe=class e{constructor(e,t){this.from=e,this.text=t}get to(){return this.from+this.text.length}static get(t,n,r){let i=Ze.get(t);if(!i||i.from>=r||i.to<=n){let i=new e(n,t.sliceString(n,r));return Ze.set(t,i),i}if(i.from==n&&i.to==r)return i;let{text:a,from:o}=i;return o>n&&(a=t.sliceString(n,o)+a,o=n),i.to<r&&(a+=t.sliceString(i.to,r)),Ze.set(t,new e(o,a)),new e(n,a.slice(n-o,r-o))}},$e=class{constructor(e,t,n,r,i){this.text=e,this.to=i,this.done=!1,this.value=Je,this.matchPos=tt(e,r),this.re=new RegExp(t,Ye+(n?.ignoreCase?`i`:``)),this.test=n?.test,this.flat=Qe.get(e,r,this.chunkEnd(r+5e3))}chunkEnd(e){return e>=this.to?this.to:this.text.lineAt(e).to}next(){for(;;){let e=this.re.lastIndex=this.matchPos-this.flat.from,t=this.re.exec(this.flat.text);if(t&&!t[0]&&t.index==e&&(this.re.lastIndex=e+1,t=this.re.exec(this.flat.text)),t){let e=this.flat.from+t.index,n=e+t[0].length;if((this.flat.to>=this.to||t.index+t[0].length<=this.flat.text.length-10)&&(!this.test||this.test(e,n,t)))return this.value={from:e,to:n,match:t},this.matchPos=tt(this.text,n+ +(e==n)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=Qe.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+this.flat.text.length*2))}}};typeof Symbol<`u`&&(Xe.prototype[Symbol.iterator]=$e.prototype[Symbol.iterator]=function(){return this});function et(e){try{return new RegExp(e,Ye),!0}catch{return!1}}function tt(e,t){if(t>=e.length)return t;let n=e.lineAt(t),r;for(;t<n.to&&(r=n.text.charCodeAt(t-n.from))>=56320&&r<57344;)t++;return t}var nt=e=>{let{state:t}=e,n=String(t.doc.lineAt(e.state.selection.main.head).number),{close:r,result:i}=me(e,{label:t.phrase(`Go to line`),input:{type:`text`,name:`line`,value:n},focus:!0,submitLabel:t.phrase(`go`)});return i.then(n=>{let i=n&&/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(n.elements.line.value);if(!i){e.dispatch({effects:r});return}let a=t.doc.lineAt(t.selection.main.head),[,o,s,c,l]=i,u=c?+c.slice(1):0,d=s?+s:a.number;if(s&&l){let e=d/100;o&&(e=e*(o==`-`?-1:1)+a.number/t.doc.lines),d=Math.round(t.doc.lines*e)}else s&&o&&(d=d*(o==`-`?-1:1)+a.number);let f=t.doc.line(Math.max(1,Math.min(t.doc.lines,d))),p=C.cursor(f.from+Math.max(0,Math.min(u,f.length)));e.dispatch({effects:[r,M.scrollIntoView(p.from,{y:`center`})],selection:p})}),!0},rt={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},it=k.define({combine(e){return b(e,rt,{highlightWordAroundCursor:(e,t)=>e||t,minSelectionLength:Math.min,maxMatches:Math.min})}});function at(e){let t=[dt,ut];return e&&t.push(it.of(e)),t}var ot=E.mark({class:`cm-selectionMatch`}),st=E.mark({class:`cm-selectionMatch cm-selectionMatch-main`});function ct(e,t,n,r){return(n==0||e(t.sliceDoc(n-1,n))!=R.Word)&&(r==t.doc.length||e(t.sliceDoc(r,r+1))!=R.Word)}function lt(e,t,n,r){return e(t.sliceDoc(n,n+1))==R.Word&&e(t.sliceDoc(r-1,r))==R.Word}var ut=j.fromClass(class{constructor(e){this.decorations=this.getDeco(e)}update(e){(e.selectionSet||e.docChanged||e.viewportChanged)&&(this.decorations=this.getDeco(e.view))}getDeco(e){let t=e.state.facet(it),{state:n}=e,r=n.selection;if(r.ranges.length>1)return E.none;let i=r.main,a,o=null;if(i.empty){if(!t.highlightWordAroundCursor)return E.none;let e=n.wordAt(i.head);if(!e)return E.none;o=n.charCategorizer(i.head),a=n.sliceDoc(e.from,e.to)}else{let e=i.to-i.from;if(e<t.minSelectionLength||e>200)return E.none;if(t.wholeWords){if(a=n.sliceDoc(i.from,i.to),o=n.charCategorizer(i.head),!(ct(o,n,i.from,i.to)&&lt(o,n,i.from,i.to)))return E.none}else if(a=n.sliceDoc(i.from,i.to),!a)return E.none}let s=[];for(let r of e.visibleRanges){let e=new V(n.doc,a,r.from,r.to);for(;!e.next().done;){let{from:r,to:a}=e.value;if((!o||ct(o,n,r,a))&&(i.empty&&r<=i.from&&a>=i.to?s.push(st.range(r,a)):(r>=i.to||a<=i.from)&&s.push(ot.range(r,a)),s.length>t.maxMatches))return E.none}}return E.set(s)}},{decorations:e=>e.decorations}),dt=M.baseTheme({".cm-selectionMatch":{backgroundColor:`#99ff7780`},".cm-searchMatch .cm-selectionMatch":{backgroundColor:`transparent`}}),ft=({state:e,dispatch:t})=>{let{selection:n}=e,r=C.create(n.ranges.map(t=>e.wordAt(t.head)||C.cursor(t.head)),n.mainIndex);return r.eq(n)?!1:(t(e.update({selection:r})),!0)};function pt(e,t){let{main:n,ranges:r}=e.selection,i=e.wordAt(n.head),a=i&&i.from==n.from&&i.to==n.to;for(let n=!1,i=new V(e.doc,t,r[r.length-1].to);;)if(i.next(),i.done){if(n)return null;i=new V(e.doc,t,0,Math.max(0,r[r.length-1].from-1)),n=!0}else{if(n&&r.some(e=>e.from==i.value.from))continue;if(a){let t=e.wordAt(i.value.from);if(!t||t.from!=i.value.from||t.to!=i.value.to)continue}return i.value}}var mt=({state:e,dispatch:t})=>{let{ranges:n}=e.selection;if(n.some(e=>e.from===e.to))return ft({state:e,dispatch:t});let r=e.sliceDoc(n[0].from,n[0].to);if(e.selection.ranges.some(t=>e.sliceDoc(t.from,t.to)!=r))return!1;let i=pt(e,r);return i?(t(e.update({selection:e.selection.addRange(C.range(i.from,i.to),!1),effects:M.scrollIntoView(i.to)})),!0):!1},H=k.define({combine(e){return b(e,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:e=>new Wt(e),scrollToMatch:e=>M.scrollIntoView(e)})}});function ht(e){return e?[H.of(e),Yt]:Yt}var gt=class{constructor(e){this.search=e.search,this.caseSensitive=!!e.caseSensitive,this.literal=!!e.literal,this.regexp=!!e.regexp,this.replace=e.replace||``,this.valid=!!this.search&&(!this.regexp||et(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!e.wholeWord,this.test=e.test}unquote(e){return this.literal?e:e.replace(/\\([nrt\\])/g,(e,t)=>t==`n`?`
1
+ import{o as e}from"./chunk-CFjPhJqf.js";import{a as t,i as n,o as r,r as i,t as a}from"./compiler-runtime-Cs91PcD2.js";import{$ as o,An as s,G as c,K as l,it as u,n as d,q as f,ut as p}from"./DocumentContext-FzcL7UQZ.js";import{a as ee,c as te,i as ne,n as re,o as ie,r as ae,s as oe,t as se,u as ce}from"./panel-BQ1weDcE.js";import{at as m,fr as h,nt as g}from"./dist-D2H0qs9k.js";import{l as le}from"./button-CmLxDlCv.js";import{i as ue,z as _}from"./prop-types-CMddcK9H.js";import{$ as v,At as y,Bt as b,Dt as x,E as S,Et as C,Ft as w,Ht as T,J as E,Mt as D,N as O,Ot as k,Pt as A,Q as j,Rt as de,Ut as fe,X as M,_ as N,_t as P,ct as F,dt as I,et as L,f as pe,gt as me,ht as he,l as ge,lt as _e,mt as ve,nt as ye,ot as be,rt as xe,st as Se,tt as Ce,ut as we,wt as R,y as Te,yt as z,zt as Ee}from"./dist-C0jOOVYt.js";import{i as De,n as Oe,o as ke,r as Ae}from"./dist-j3LJSXW6.js";var je=e(t(),1),Me=a(),Ne=new Map;function Pe(e,t){Ne.set(e,t)}function Fe(e){let t=Ne.get(e)??null;return Ne.delete(e),t}function Ie(e){Ne.delete(e)}function Le(e,t){let n=(0,Me.c)(4),r=t===void 0?!1:t,[i,a]=(0,je.useState)(void 0),o=(0,je.useRef)(null),s,c;return n[0]!==r||n[1]!==e?(s=()=>{if(r||e.length===0){a(void 0);return}let t=function(){let t=window.innerHeight/2,n,r;for(let i of e){let e=document.getElementById(i);if(!e)continue;let a=e.getBoundingClientRect().top;a<0?n=i:r===void 0&&a<t&&(r=i)}a(r??n??e[0])},n=function(){o.current===null&&(o.current=requestAnimationFrame(()=>{o.current=null,t()}))};return document.addEventListener(`scroll`,n,{capture:!0,passive:!0}),t(),()=>{document.removeEventListener(`scroll`,n,{capture:!0}),o.current!==null&&(cancelAnimationFrame(o.current),o.current=null)}},c=[e,r],n[0]=r,n[1]=e,n[2]=s,n[3]=c):(s=n[2],c=n[3]),(0,je.useEffect)(s,c),i}var B=r(),Re=300;async function ze(e){let t=await fetch(`/api/page-headings?docName=${encodeURIComponent(e)}`),n;try{n=await t.json()}catch(e){throw new p(_._({id:`qAQVSD`}),{cause:e,status:t.status})}if(!t.ok){let e=m.safeParse(n);throw e.success?Error(e.data.title):new p(_._({id:`zlErBl`}),{status:t.status})}let r=g.safeParse(n);if(!r.success)throw new p(_._({id:`XW18jo`}),{status:t.status});return r.data.headings??[]}var Be=32,Ve=12,He=6,Ue=`open-knowledge:outline-nav`;function We(e){let t=(0,Me.c)(2),n;return t[0]===e?n=t[1]:(n=(0,B.jsx)(s,{name:`outline-panel`,children:(0,B.jsx)(Ge,{...e})}),t[0]=e,t[1]=n),n}function Ge(e){let t=(0,Me.c)(50),{docName:r,isSourceMode:a,className:o}=e,s=o===void 0?``:o,{_:c}=n(),{pages:l,loading:u}=ue(),f=ce(),{activeProvider:p,activeDocName:m}=d(),h,g;t[0]===r?(h=t[1],g=t[2]):(h=[`page-headings`,r],g=()=>ze(r),t[0]=r,t[1]=h,t[2]=g);let _;t[3]!==r||t[4]!==u||t[5]!==l?(_=!u&&l.has(r),t[3]=r,t[4]=u,t[5]=l,t[6]=_):_=t[6];let v;t[7]!==h||t[8]!==g||t[9]!==_?(v={queryKey:h,queryFn:g,enabled:_,staleTime:1/0},t[7]=h,t[8]=g,t[9]=_,t[10]=v):v=t[10];let{data:y,isLoading:b,error:x}=te(v),S;t[11]===y?S=t[12]:(S=y===void 0?[]:y,t[11]=y,t[12]=S);let C=S,w,T;t[13]!==m||t[14]!==p||t[15]!==r||t[16]!==f?(w=()=>{if(!p||m!==r)return;let e=p.document,t=null,n=()=>{t!==null&&clearTimeout(t),t=setTimeout(()=>{t=null,f.invalidateQueries({queryKey:[`page-headings`,r]})},Re)};return e.on(`update`,n),()=>{e.off(`update`,n),t!==null&&clearTimeout(t)}},T=[p,m,r,f],t[13]=m,t[14]=p,t[15]=r,t[16]=f,t[17]=w,t[18]=T):(w=t[17],T=t[18]),(0,je.useEffect)(w,T);let E;t[19]===C?E=t[20]:(E=C.map(Ke),t[19]=C,t[20]=E);let D=Le(E,a),O;t[21]!==D||t[22]!==C?(O=D?C.findIndex(e=>e.slug===D):-1,t[21]=D,t[22]=C,t[23]=O):O=t[23];let k=O,A;t[24]!==r||t[25]!==a?(A=function(e,t){let n={index:e,slug:t,mode:a?`source`:`wysiwyg`};n.mode===`source`&&Pe(r,{kind:`outline`,detail:n}),window.dispatchEvent(new CustomEvent(Ue,{detail:n}))},t[24]=r,t[25]=a,t[26]=A):A=t[26];let j=A,de=((k>=0?C[k].level:1)-1)*Ve+(Ve-He)/2,fe=k*Be+(Be-He)/2,M;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(M=(0,B.jsx)(oe,{children:(0,B.jsx)(i,{id:`dD7NPy`})}),t[27]=M):M=t[27];let N;t[28]!==C.length||t[29]!==b?(N=!b&&(0,B.jsx)(ae,{children:C.length}),t[28]=C.length,t[29]=b,t[30]=N):N=t[30];let P;t[31]===N?P=t[32]:(P=(0,B.jsxs)(ie,{children:[M,N]}),t[31]=N,t[32]=P);let F;t[33]!==c||t[34]!==k||t[35]!==D||t[36]!==x||t[37]!==j||t[38]!==C||t[39]!==b||t[40]!==de||t[41]!==fe?(F=x?(0,B.jsx)(ee,{className:`px-2`,children:x instanceof Error?x.message:c({id:`GuqOb1`})}):C.length===0&&!b?(0,B.jsx)(ne,{className:`px-2`,children:(0,B.jsx)(i,{id:`0BB9ID`})}):(0,B.jsxs)(`nav`,{"aria-label":c({id:`BymzO4`}),className:`relative`,children:[k>=0&&(0,B.jsx)(`div`,{"aria-hidden":`true`,className:`pointer-events-none absolute left-0 top-0 rounded-full bg-primary motion-safe:[transition:transform_0.25s_var(--ease-out-strong)]`,style:{width:He,height:He,transform:`translate(${de}px, ${fe}px)`}}),C.map((e,t)=>{let n=e.slug===D;return(0,B.jsx)(`button`,{type:`button`,"aria-current":n?`location`:void 0,onClick:()=>j(t,e.slug),className:le(`w-full cursor-pointer truncate py-1.5 pe-2 text-left text-sm transition-colors`,n?`font-medium text-primary`:`text-muted-foreground hover:text-foreground`),style:{paddingLeft:`${(e.level-1)*Ve+20}px`},title:e.text,children:e.text},t)})]}),t[33]=c,t[34]=k,t[35]=D,t[36]=x,t[37]=j,t[38]=C,t[39]=b,t[40]=de,t[41]=fe,t[42]=F):F=t[42];let I;t[43]!==b||t[44]!==F?(I=(0,B.jsx)(re,{className:`px-3 py-2`,"aria-busy":b,children:F}),t[43]=b,t[44]=F,t[45]=I):I=t[45];let L;return t[46]!==s||t[47]!==P||t[48]!==I?(L=(0,B.jsxs)(se,{className:s,children:[P,I]}),t[46]=s,t[47]=P,t[48]=I,t[49]=L):L=t[49],L}function Ke(e){return e.slug}var qe=typeof String.prototype.normalize==`function`?e=>e.normalize(`NFKD`):e=>e,V=class{constructor(e,t,n=0,r=e.length,i,a){this.test=a,this.value={from:0,to:0},this.done=!1,this.matches=[],this.buffer=``,this.bufferPos=0,this.iter=e.iterRange(n,r),this.bufferStart=n,this.normalize=i?e=>i(qe(e)):qe,this.query=this.normalize(t)}peek(){if(this.bufferPos==this.buffer.length){if(this.bufferStart+=this.buffer.length,this.iter.next(),this.iter.done)return-1;this.bufferPos=0,this.buffer=this.iter.value}return de(this.buffer,this.bufferPos)}next(){for(;this.matches.length;)this.matches.pop();return this.nextOverlapping()}nextOverlapping(){for(;;){let e=this.peek();if(e<0)return this.done=!0,this;let t=fe(e),n=this.bufferStart+this.bufferPos;this.bufferPos+=Ee(e);let r=this.normalize(t);if(r.length)for(let e=0,i=n;;e++){let a=r.charCodeAt(e),o=this.match(a,i,this.bufferPos+this.bufferStart);if(e==r.length-1){if(o)return this.value=o,this;break}i==n&&e<t.length&&t.charCodeAt(e)==a&&i++}}}match(e,t,n){let r=null;for(let t=0;t<this.matches.length;t+=2){let i=this.matches[t],a=!1;this.query.charCodeAt(i)==e&&(i==this.query.length-1?r={from:this.matches[t+1],to:n}:(this.matches[t]++,a=!0)),a||(this.matches.splice(t,2),t-=2)}return this.query.charCodeAt(0)==e&&(this.query.length==1?r={from:t,to:n}:this.matches.push(1,t)),r&&this.test&&!this.test(r.from,r.to,this.buffer,this.bufferStart)&&(r=null),r}};typeof Symbol<`u`&&(V.prototype[Symbol.iterator]=function(){return this});var Je={from:-1,to:-1,match:/.*/.exec(``)},Ye=`gm`+(/x/.unicode==null?``:`u`),Xe=class{constructor(e,t,n,r=0,i=e.length){if(this.text=e,this.to=i,this.curLine=``,this.done=!1,this.value=Je,/\\[sWDnr]|\n|\r|\[\^/.test(t))return new $e(e,t,n,r,i);this.re=new RegExp(t,Ye+(n?.ignoreCase?`i`:``)),this.test=n?.test,this.iter=e.iter(),this.curLineStart=e.lineAt(r).from,this.matchPos=tt(e,r),this.getLine(this.curLineStart)}getLine(e){this.iter.next(e),this.iter.lineBreak?this.curLine=``:(this.curLine=this.iter.value,this.curLineStart+this.curLine.length>this.to&&(this.curLine=this.curLine.slice(0,this.to-this.curLineStart)),this.iter.next())}nextLine(){this.curLineStart=this.curLineStart+this.curLine.length+1,this.curLineStart>this.to?this.curLine=``:this.getLine(0)}next(){for(let e=this.matchPos-this.curLineStart;;){this.re.lastIndex=e;let t=this.matchPos<=this.to&&this.re.exec(this.curLine);if(t){let n=this.curLineStart+t.index,r=n+t[0].length;if(this.matchPos=tt(this.text,r+ +(n==r)),n==this.curLineStart+this.curLine.length&&this.nextLine(),(n<r||n>this.value.to)&&(!this.test||this.test(n,r,t)))return this.value={from:n,to:r,match:t},this;e=this.matchPos-this.curLineStart}else if(this.curLineStart+this.curLine.length<this.to)this.nextLine(),e=0;else return this.done=!0,this}}},Ze=new WeakMap,Qe=class e{constructor(e,t){this.from=e,this.text=t}get to(){return this.from+this.text.length}static get(t,n,r){let i=Ze.get(t);if(!i||i.from>=r||i.to<=n){let i=new e(n,t.sliceString(n,r));return Ze.set(t,i),i}if(i.from==n&&i.to==r)return i;let{text:a,from:o}=i;return o>n&&(a=t.sliceString(n,o)+a,o=n),i.to<r&&(a+=t.sliceString(i.to,r)),Ze.set(t,new e(o,a)),new e(n,a.slice(n-o,r-o))}},$e=class{constructor(e,t,n,r,i){this.text=e,this.to=i,this.done=!1,this.value=Je,this.matchPos=tt(e,r),this.re=new RegExp(t,Ye+(n?.ignoreCase?`i`:``)),this.test=n?.test,this.flat=Qe.get(e,r,this.chunkEnd(r+5e3))}chunkEnd(e){return e>=this.to?this.to:this.text.lineAt(e).to}next(){for(;;){let e=this.re.lastIndex=this.matchPos-this.flat.from,t=this.re.exec(this.flat.text);if(t&&!t[0]&&t.index==e&&(this.re.lastIndex=e+1,t=this.re.exec(this.flat.text)),t){let e=this.flat.from+t.index,n=e+t[0].length;if((this.flat.to>=this.to||t.index+t[0].length<=this.flat.text.length-10)&&(!this.test||this.test(e,n,t)))return this.value={from:e,to:n,match:t},this.matchPos=tt(this.text,n+ +(e==n)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=Qe.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+this.flat.text.length*2))}}};typeof Symbol<`u`&&(Xe.prototype[Symbol.iterator]=$e.prototype[Symbol.iterator]=function(){return this});function et(e){try{return new RegExp(e,Ye),!0}catch{return!1}}function tt(e,t){if(t>=e.length)return t;let n=e.lineAt(t),r;for(;t<n.to&&(r=n.text.charCodeAt(t-n.from))>=56320&&r<57344;)t++;return t}var nt=e=>{let{state:t}=e,n=String(t.doc.lineAt(e.state.selection.main.head).number),{close:r,result:i}=me(e,{label:t.phrase(`Go to line`),input:{type:`text`,name:`line`,value:n},focus:!0,submitLabel:t.phrase(`go`)});return i.then(n=>{let i=n&&/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(n.elements.line.value);if(!i){e.dispatch({effects:r});return}let a=t.doc.lineAt(t.selection.main.head),[,o,s,c,l]=i,u=c?+c.slice(1):0,d=s?+s:a.number;if(s&&l){let e=d/100;o&&(e=e*(o==`-`?-1:1)+a.number/t.doc.lines),d=Math.round(t.doc.lines*e)}else s&&o&&(d=d*(o==`-`?-1:1)+a.number);let f=t.doc.line(Math.max(1,Math.min(t.doc.lines,d))),p=C.cursor(f.from+Math.max(0,Math.min(u,f.length)));e.dispatch({effects:[r,M.scrollIntoView(p.from,{y:`center`})],selection:p})}),!0},rt={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},it=k.define({combine(e){return b(e,rt,{highlightWordAroundCursor:(e,t)=>e||t,minSelectionLength:Math.min,maxMatches:Math.min})}});function at(e){let t=[dt,ut];return e&&t.push(it.of(e)),t}var ot=E.mark({class:`cm-selectionMatch`}),st=E.mark({class:`cm-selectionMatch cm-selectionMatch-main`});function ct(e,t,n,r){return(n==0||e(t.sliceDoc(n-1,n))!=R.Word)&&(r==t.doc.length||e(t.sliceDoc(r,r+1))!=R.Word)}function lt(e,t,n,r){return e(t.sliceDoc(n,n+1))==R.Word&&e(t.sliceDoc(r-1,r))==R.Word}var ut=j.fromClass(class{constructor(e){this.decorations=this.getDeco(e)}update(e){(e.selectionSet||e.docChanged||e.viewportChanged)&&(this.decorations=this.getDeco(e.view))}getDeco(e){let t=e.state.facet(it),{state:n}=e,r=n.selection;if(r.ranges.length>1)return E.none;let i=r.main,a,o=null;if(i.empty){if(!t.highlightWordAroundCursor)return E.none;let e=n.wordAt(i.head);if(!e)return E.none;o=n.charCategorizer(i.head),a=n.sliceDoc(e.from,e.to)}else{let e=i.to-i.from;if(e<t.minSelectionLength||e>200)return E.none;if(t.wholeWords){if(a=n.sliceDoc(i.from,i.to),o=n.charCategorizer(i.head),!(ct(o,n,i.from,i.to)&&lt(o,n,i.from,i.to)))return E.none}else if(a=n.sliceDoc(i.from,i.to),!a)return E.none}let s=[];for(let r of e.visibleRanges){let e=new V(n.doc,a,r.from,r.to);for(;!e.next().done;){let{from:r,to:a}=e.value;if((!o||ct(o,n,r,a))&&(i.empty&&r<=i.from&&a>=i.to?s.push(st.range(r,a)):(r>=i.to||a<=i.from)&&s.push(ot.range(r,a)),s.length>t.maxMatches))return E.none}}return E.set(s)}},{decorations:e=>e.decorations}),dt=M.baseTheme({".cm-selectionMatch":{backgroundColor:`#99ff7780`},".cm-searchMatch .cm-selectionMatch":{backgroundColor:`transparent`}}),ft=({state:e,dispatch:t})=>{let{selection:n}=e,r=C.create(n.ranges.map(t=>e.wordAt(t.head)||C.cursor(t.head)),n.mainIndex);return r.eq(n)?!1:(t(e.update({selection:r})),!0)};function pt(e,t){let{main:n,ranges:r}=e.selection,i=e.wordAt(n.head),a=i&&i.from==n.from&&i.to==n.to;for(let n=!1,i=new V(e.doc,t,r[r.length-1].to);;)if(i.next(),i.done){if(n)return null;i=new V(e.doc,t,0,Math.max(0,r[r.length-1].from-1)),n=!0}else{if(n&&r.some(e=>e.from==i.value.from))continue;if(a){let t=e.wordAt(i.value.from);if(!t||t.from!=i.value.from||t.to!=i.value.to)continue}return i.value}}var mt=({state:e,dispatch:t})=>{let{ranges:n}=e.selection;if(n.some(e=>e.from===e.to))return ft({state:e,dispatch:t});let r=e.sliceDoc(n[0].from,n[0].to);if(e.selection.ranges.some(t=>e.sliceDoc(t.from,t.to)!=r))return!1;let i=pt(e,r);return i?(t(e.update({selection:e.selection.addRange(C.range(i.from,i.to),!1),effects:M.scrollIntoView(i.to)})),!0):!1},H=k.define({combine(e){return b(e,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:e=>new Wt(e),scrollToMatch:e=>M.scrollIntoView(e)})}});function ht(e){return e?[H.of(e),Yt]:Yt}var gt=class{constructor(e){this.search=e.search,this.caseSensitive=!!e.caseSensitive,this.literal=!!e.literal,this.regexp=!!e.regexp,this.replace=e.replace||``,this.valid=!!this.search&&(!this.regexp||et(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!e.wholeWord,this.test=e.test}unquote(e){return this.literal?e:e.replace(/\\([nrt\\])/g,(e,t)=>t==`n`?`
2
2
  `:t==`r`?`\r`:t==`t`?` `:`\\`)}eq(e){return this.search==e.search&&this.replace==e.replace&&this.caseSensitive==e.caseSensitive&&this.regexp==e.regexp&&this.wholeWord==e.wholeWord&&this.test==e.test}create(){return this.regexp?new Tt(this):new bt(this)}getCursor(e,t=0,n){let r=e.doc?e:x.create({doc:e});return n??=r.doc.length,this.regexp?W(this,r,t,n):U(this,r,t,n)}},_t=class{constructor(e){this.spec=e}};function vt(e,t,n){return(r,i,a,o)=>n&&!n(r,i,a,o)?!1:e(r>=o&&i<=o+a.length?a.slice(r-o,i-o):t.doc.sliceString(r,i),t,r,i)}function U(e,t,n,r){let i;return e.wholeWord&&(i=yt(t.doc,t.charCategorizer(t.selection.main.head))),e.test&&(i=vt(e.test,t,i)),new V(t.doc,e.unquoted,n,r,e.caseSensitive?void 0:e=>e.toLowerCase(),i)}function yt(e,t){return(n,r,i,a)=>((a>n||a+i.length<r)&&(a=Math.max(0,n-2),i=e.sliceString(a,Math.min(e.length,r+2))),(t(St(i,n-a))!=R.Word||t(Ct(i,n-a))!=R.Word)&&(t(Ct(i,r-a))!=R.Word||t(St(i,r-a))!=R.Word))}var bt=class extends _t{constructor(e){super(e)}nextMatch(e,t,n){let r=U(this.spec,e,n,e.doc.length).nextOverlapping();if(r.done){let n=Math.min(e.doc.length,t+this.spec.unquoted.length);r=U(this.spec,e,0,n).nextOverlapping()}return r.done||r.value.from==t&&r.value.to==n?null:r.value}prevMatchInRange(e,t,n){for(let r=n;;){let n=Math.max(t,r-1e4-this.spec.unquoted.length),i=U(this.spec,e,n,r),a=null;for(;!i.nextOverlapping().done;)a=i.value;if(a)return a;if(n==t)return null;r-=1e4}}prevMatch(e,t,n){let r=this.prevMatchInRange(e,0,t);return r||=this.prevMatchInRange(e,Math.max(0,n-this.spec.unquoted.length),e.doc.length),r&&(r.from!=t||r.to!=n)?r:null}getReplacement(e){return this.spec.unquote(this.spec.replace)}matchAll(e,t){let n=U(this.spec,e,0,e.doc.length),r=[];for(;!n.next().done;){if(r.length>=t)return null;r.push(n.value)}return r}highlight(e,t,n,r){let i=U(this.spec,e,Math.max(0,t-this.spec.unquoted.length),Math.min(n+this.spec.unquoted.length,e.doc.length));for(;!i.next().done;)r(i.value.from,i.value.to)}};function xt(e,t,n){return(r,i,a)=>(!n||n(r,i,a))&&e(a[0],t,r,i)}function W(e,t,n,r){let i;return e.wholeWord&&(i=wt(t.charCategorizer(t.selection.main.head))),e.test&&(i=xt(e.test,t,i)),new Xe(t.doc,e.search,{ignoreCase:!e.caseSensitive,test:i},n,r)}function St(e,t){return e.slice(T(e,t,!1),t)}function Ct(e,t){return e.slice(t,T(e,t))}function wt(e){return(t,n,r)=>!r[0].length||(e(St(r.input,r.index))!=R.Word||e(Ct(r.input,r.index))!=R.Word)&&(e(Ct(r.input,r.index+r[0].length))!=R.Word||e(St(r.input,r.index+r[0].length))!=R.Word)}var Tt=class extends _t{nextMatch(e,t,n){let r=W(this.spec,e,n,e.doc.length).next();return r.done&&(r=W(this.spec,e,0,t).next()),r.done?null:r.value}prevMatchInRange(e,t,n){for(let r=1;;r++){let i=Math.max(t,n-r*1e4),a=W(this.spec,e,i,n),o=null;for(;!a.next().done;)o=a.value;if(o&&(i==t||o.from>i+10))return o;if(i==t)return null}}prevMatch(e,t,n){return this.prevMatchInRange(e,0,t)||this.prevMatchInRange(e,n,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace).replace(/\$([$&]|\d+)/g,(t,n)=>{if(n==`&`)return e.match[0];if(n==`$`)return`$`;for(let t=n.length;t>0;t--){let r=+n.slice(0,t);if(r>0&&r<e.match.length)return e.match[r]+n.slice(t)}return t})}matchAll(e,t){let n=W(this.spec,e,0,e.doc.length),r=[];for(;!n.next().done;){if(r.length>=t)return null;r.push(n.value)}return r}highlight(e,t,n,r){let i=W(this.spec,e,Math.max(0,t-250),Math.min(n+250,e.doc.length));for(;!i.next().done;)r(i.value.from,i.value.to)}},G=A.define(),Et=A.define(),K=w.define({create(e){return new Dt(Rt(e).create(),null)},update(e,t){for(let n of t.effects)n.is(G)?e=new Dt(n.value.create(),e.panel):n.is(Et)&&(e=new Dt(e.query,n.value?Lt:null));return e},provide:e=>P.from(e,e=>e.panel)}),Dt=class{constructor(e,t){this.query=e,this.panel=t}},Ot=E.mark({class:`cm-searchMatch`}),kt=E.mark({class:`cm-searchMatch cm-searchMatch-selected`}),At=j.fromClass(class{constructor(e){this.view=e,this.decorations=this.highlight(e.state.field(K))}update(e){let t=e.state.field(K);(t!=e.startState.field(K)||e.docChanged||e.selectionSet||e.viewportChanged)&&(this.decorations=this.highlight(t))}highlight({query:e,panel:t}){if(!t||!e.spec.valid)return E.none;let{view:n}=this,r=new D;for(let t=0,i=n.visibleRanges,a=i.length;t<a;t++){let{from:o,to:s}=i[t];for(;t<a-1&&s>i[t+1].from-500;)s=i[++t].to;e.highlight(n.state,o,s,(e,t)=>{let i=n.state.selection.ranges.some(n=>n.from==e&&n.to==t);r.add(e,t,i?kt:Ot)})}return r.finish()}},{decorations:e=>e.decorations});function q(e){return t=>{let n=t.state.field(K,!1);return n&&n.query.spec.valid?e(t,n):Vt(t)}}var jt=q((e,{query:t})=>{let{to:n}=e.state.selection.main,r=t.nextMatch(e.state,n,n);if(!r)return!1;let i=C.single(r.from,r.to),a=e.state.facet(H);return e.dispatch({selection:i,effects:[qt(e,r),a.scrollToMatch(i.main,e)],userEvent:`select.search`}),Bt(e),!0}),Mt=q((e,{query:t})=>{let{state:n}=e,{from:r}=n.selection.main,i=t.prevMatch(n,r,r);if(!i)return!1;let a=C.single(i.from,i.to),o=e.state.facet(H);return e.dispatch({selection:a,effects:[qt(e,i),o.scrollToMatch(a.main,e)],userEvent:`select.search`}),Bt(e),!0}),Nt=q((e,{query:t})=>{let n=t.matchAll(e.state,1e3);return!n||!n.length?!1:(e.dispatch({selection:C.create(n.map(e=>C.range(e.from,e.to))),userEvent:`select.search.matches`}),!0)}),Pt=({state:e,dispatch:t})=>{let n=e.selection;if(n.ranges.length>1||n.main.empty)return!1;let{from:r,to:i}=n.main,a=[],o=0;for(let t=new V(e.doc,e.sliceDoc(r,i));!t.next().done;){if(a.length>1e3)return!1;t.value.from==r&&(o=a.length),a.push(C.range(t.value.from,t.value.to))}return t(e.update({selection:C.create(a,o),userEvent:`select.search.matches`})),!0},Ft=q((e,{query:t})=>{let{state:n}=e,{from:r,to:i}=n.selection.main;if(n.readOnly)return!1;let a=t.nextMatch(n,r,r);if(!a)return!1;let o=a,s=[],c,l,u=[];o.from==r&&o.to==i&&(l=n.toText(t.getReplacement(o)),s.push({from:o.from,to:o.to,insert:l}),o=t.nextMatch(n,o.from,o.to),u.push(M.announce.of(n.phrase(`replaced match on line $`,n.doc.lineAt(r).number)+`.`)));let d=e.state.changes(s);return o&&(c=C.single(o.from,o.to).map(d),u.push(qt(e,o)),u.push(n.facet(H).scrollToMatch(c.main,e))),e.dispatch({changes:d,selection:c,effects:u,userEvent:`input.replace`}),!0}),It=q((e,{query:t})=>{if(e.state.readOnly)return!1;let n=t.matchAll(e.state,1e9).map(e=>{let{from:n,to:r}=e;return{from:n,to:r,insert:t.getReplacement(e)}});if(!n.length)return!1;let r=e.state.phrase(`replaced $ matches`,n.length)+`.`;return e.dispatch({changes:n,effects:M.announce.of(r),userEvent:`input.replace.all`}),!0});function Lt(e){return e.state.facet(H).createPanel(e)}function Rt(e,t){let n=e.selection.main,r=n.empty||n.to>n.from+100?``:e.sliceDoc(n.from,n.to);if(t&&!r)return t;let i=e.facet(H);return new gt({search:t?.literal??i.literal?r:r.replace(/\n/g,`\\n`),caseSensitive:t?.caseSensitive??i.caseSensitive,literal:t?.literal??i.literal,regexp:t?.regexp??i.regexp,wholeWord:t?.wholeWord??i.wholeWord})}function zt(e){let t=xe(e,Lt);return t&&t.dom.querySelector(`[main-field]`)}function Bt(e){let t=zt(e);t&&t==e.root.activeElement&&t.select()}var Vt=e=>{let t=e.state.field(K,!1);if(t&&t.panel){let n=zt(e);if(n&&n!=e.root.activeElement){let r=Rt(e.state,t.query.spec);r.valid&&e.dispatch({effects:G.of(r)}),n.focus(),n.select()}}else e.dispatch({effects:[Et.of(!0),t?G.of(Rt(e.state,t.query.spec)):A.appendConfig.of(Yt)]});return!0},Ht=e=>{let t=e.state.field(K,!1);if(!t||!t.panel)return!1;let n=xe(e,Lt);return n&&n.dom.contains(e.root.activeElement)&&e.focus(),e.dispatch({effects:Et.of(!1)}),!0},Ut=[{key:`Mod-f`,run:Vt,scope:`editor search-panel`},{key:`F3`,run:jt,shift:Mt,scope:`editor search-panel`,preventDefault:!0},{key:`Mod-g`,run:jt,shift:Mt,scope:`editor search-panel`,preventDefault:!0},{key:`Escape`,run:Ht,scope:`editor search-panel`},{key:`Mod-Shift-l`,run:Pt},{key:`Mod-Alt-g`,run:nt},{key:`Mod-d`,run:mt,preventDefault:!0}],Wt=class{constructor(e){this.view=e;let t=this.query=e.state.field(K).query.spec;this.commit=this.commit.bind(this),this.searchField=z(`input`,{value:t.search,placeholder:J(e,`Find`),"aria-label":J(e,`Find`),class:`cm-textfield`,name:`search`,form:``,"main-field":`true`,onchange:this.commit,onkeyup:this.commit}),this.replaceField=z(`input`,{value:t.replace,placeholder:J(e,`Replace`),"aria-label":J(e,`Replace`),class:`cm-textfield`,name:`replace`,form:``,onchange:this.commit,onkeyup:this.commit}),this.caseField=z(`input`,{type:`checkbox`,name:`case`,form:``,checked:t.caseSensitive,onchange:this.commit}),this.reField=z(`input`,{type:`checkbox`,name:`re`,form:``,checked:t.regexp,onchange:this.commit}),this.wordField=z(`input`,{type:`checkbox`,name:`word`,form:``,checked:t.wholeWord,onchange:this.commit});function n(e,t,n){return z(`button`,{class:`cm-button`,name:e,onclick:t,type:`button`},n)}this.dom=z(`div`,{onkeydown:e=>this.keydown(e),class:`cm-search`},[this.searchField,n(`next`,()=>jt(e),[J(e,`next`)]),n(`prev`,()=>Mt(e),[J(e,`previous`)]),n(`select`,()=>Nt(e),[J(e,`all`)]),z(`label`,null,[this.caseField,J(e,`match case`)]),z(`label`,null,[this.reField,J(e,`regexp`)]),z(`label`,null,[this.wordField,J(e,`by word`)]),...e.state.readOnly?[]:[z(`br`),this.replaceField,n(`replace`,()=>Ft(e),[J(e,`replace`)]),n(`replaceAll`,()=>It(e),[J(e,`replace all`)])],z(`button`,{name:`close`,onclick:()=>Ht(e),"aria-label":J(e,`close`),type:`button`},[`×`])])}commit(){let e=new gt({search:this.searchField.value,caseSensitive:this.caseField.checked,regexp:this.reField.checked,wholeWord:this.wordField.checked,replace:this.replaceField.value});e.eq(this.query)||(this.query=e,this.view.dispatch({effects:G.of(e)}))}keydown(e){he(this.view,e,`search-panel`)?e.preventDefault():e.keyCode==13&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?Mt:jt)(this.view)):e.keyCode==13&&e.target==this.replaceField&&(e.preventDefault(),Ft(this.view))}update(e){for(let t of e.transactions)for(let e of t.effects)e.is(G)&&!e.value.eq(this.query)&&this.setQuery(e.value)}setQuery(e){this.query=e,this.searchField.value=e.search,this.replaceField.value=e.replace,this.caseField.checked=e.caseSensitive,this.reField.checked=e.regexp,this.wordField.checked=e.wholeWord}mount(){this.searchField.select()}get pos(){return 80}get top(){return this.view.state.facet(H).top}};function J(e,t){return e.state.phrase(t)}var Gt=30,Kt=/[\s\.,:;?!]/;function qt(e,{from:t,to:n}){let r=e.state.doc.lineAt(t),i=e.state.doc.lineAt(n).to,a=Math.max(r.from,t-Gt),o=Math.min(i,n+Gt),s=e.state.sliceDoc(a,o);if(a!=r.from){for(let e=0;e<Gt;e++)if(!Kt.test(s[e+1])&&Kt.test(s[e])){s=s.slice(e);break}}if(o!=i){for(let e=s.length-1;e>s.length-Gt;e--)if(!Kt.test(s[e-1])&&Kt.test(s[e])){s=s.slice(0,e);break}}return M.announce.of(`${e.state.phrase(`current match`)}. ${s} ${e.state.phrase(`on line`)} ${r.number}.`)}var Jt=M.baseTheme({".cm-panel.cm-search":{padding:`2px 6px 4px`,position:`relative`,"& [name=close]":{position:`absolute`,top:`0`,right:`4px`,backgroundColor:`inherit`,border:`none`,font:`inherit`,padding:0,margin:0},"& input, & button, & label":{margin:`.2em .6em .2em 0`},"& input[type=checkbox]":{marginRight:`.2em`},"& label":{fontSize:`80%`,whiteSpace:`pre`}},"&light .cm-searchMatch":{backgroundColor:`#ffff0054`},"&dark .cm-searchMatch":{backgroundColor:`#00ffff8a`},"&light .cm-searchMatch-selected":{backgroundColor:`#ff6a0054`},"&dark .cm-searchMatch-selected":{backgroundColor:`#ff00ff8a`}}),Yt=[K,y.low(At),Jt],Xt=class{constructor(e,t,n){this.from=e,this.to=t,this.diagnostic=n}},Y=class e{constructor(e,t,n){this.diagnostics=e,this.panel=t,this.selected=n}static init(t,n,r){let i=r.facet(Q).markerFilter;i&&(t=i(t,r));let a=t.slice().sort((e,t)=>e.from-t.from||e.to-t.to),o=new D,s=[],c=0,l=r.doc.iter(),u=0,d=r.doc.length;for(let e=0;;){let t=e==a.length?null:a[e];if(!t&&!s.length)break;let n,r;if(s.length)n=c,r=s.reduce((e,t)=>Math.min(e,t.to),t&&t.from>n?t.from:1e8);else{if(n=t.from,n>d)break;r=t.to,s.push(t),e++}for(;e<a.length;){let t=a[e];if(t.from==n&&(t.to>t.from||t.to==n))s.push(t),e++,r=Math.min(t.to,r);else{r=Math.min(t.from,r);break}}r=Math.min(r,d);let i=!1;if(s.some(e=>e.from==n&&(e.to==r||r==d))&&(i=n==r,!i&&r-n<10)){let e=n-(u+l.value.length);e>0&&(l.next(e),u=n);for(let e=n;;){if(e>=r){i=!0;break}if(!l.lineBreak&&u+l.value.length>e)break;e=u+l.value.length,u+=l.value.length,l.next()}}let f=vn(s);if(i)o.add(n,n,E.widget({widget:new fn(f),diagnostics:s.slice()}));else{let e=s.reduce((e,t)=>t.markClass?e+` `+t.markClass:e,``);o.add(n,r,E.mark({class:`cm-lintRange cm-lintRange-`+f+e,diagnostics:s.slice(),inclusiveEnd:s.some(e=>e.to>r)}))}if(c=r,c==d)break;for(let e=0;e<s.length;e++)s[e].to<=c&&s.splice(e--,1)}let f=o.finish();return new e(f,n,X(f))}};function X(e,t=null,n=0){let r=null;return e.between(n,1e9,(e,n,{spec:i})=>{if(!(t&&i.diagnostics.indexOf(t)<0))if(!r)r=new Xt(e,n,t||i.diagnostics[0]);else if(i.diagnostics.indexOf(r.diagnostic)<0)return!1;else r=new Xt(r.from,n,r.diagnostic)}),r}function Zt(e,t){let n=t.pos,r=t.end||n,i=e.state.facet(Q).hideOn(e,n,r);if(i!=null)return i;let a=e.startState.doc.lineAt(t.pos);return!!(e.effects.some(e=>e.is($t))||e.changes.touchesRange(a.from,Math.max(a.to,r)))}function Qt(e,t){return e.field(Z,!1)?t:t.concat(A.appendConfig.of(yn))}var $t=A.define(),en=A.define(),tn=A.define(),Z=w.define({create(){return new Y(E.none,null,null)},update(e,t){if(t.docChanged&&e.diagnostics.size){let n=e.diagnostics.map(t.changes),r=null,i=e.panel;if(e.selected){let i=t.changes.mapPos(e.selected.from,1);r=X(n,e.selected.diagnostic,i)||X(n,null,i)}!n.size&&i&&t.state.facet(Q).autoPanel&&(i=null),e=new Y(n,i,r)}for(let n of t.effects)if(n.is($t)){let r=t.state.facet(Q).autoPanel?n.value.length?mn.open:null:e.panel;e=Y.init(n.value,r,t.state)}else n.is(en)?e=new Y(e.diagnostics,n.value?mn.open:null,e.selected):n.is(tn)&&(e=new Y(e.diagnostics,e.panel,n.value));return e},provide:e=>[P.from(e,e=>e.panel),M.decorations.from(e,e=>e.diagnostics)]}),nn=E.mark({class:`cm-lintRange cm-lintRange-active`});function rn(e,t,n){let{diagnostics:r}=e.state.field(Z),i,a=-1,o=-1;r.between(t-+(n<0),t+ +(n>0),(e,r,{spec:s})=>{if(t>=e&&t<=r&&(e==r||(t>e||n>0)&&(t<r||n<0)))return i=s.diagnostics,a=e,o=r,!1});let s=e.state.facet(Q).tooltipFilter;return i&&s&&(i=s(i,e.state)),i?{pos:a,end:o,above:e.state.doc.lineAt(a).to<o,create(){return{dom:an(e,i)}}}:null}function an(e,t){return z(`ul`,{class:`cm-tooltip-lint`},t.map(t=>dn(e,t,!1)))}var on=e=>{let t=e.state.field(Z,!1);(!t||!t.panel)&&e.dispatch({effects:Qt(e.state,[en.of(!0)])});let n=xe(e,mn.open);return n&&n.dom.querySelector(`.cm-panel-lint ul`).focus(),!0},sn=e=>{let t=e.state.field(Z,!1);return!t||!t.panel?!1:(e.dispatch({effects:en.of(!1)}),!0)},cn=[{key:`Mod-Shift-m`,run:on,preventDefault:!0},{key:`F8`,run:e=>{let t=e.state.field(Z,!1);if(!t)return!1;let n=e.state.selection.main,r=X(t.diagnostics,null,n.to+1);return!r&&(r=X(t.diagnostics,null,0),!r||r.from==n.from&&r.to==n.to)?!1:(e.dispatch({selection:{anchor:r.from,head:r.to},scrollIntoView:!0}),!0)}}],Q=k.define({combine(e){return{sources:e.map(e=>e.source).filter(e=>e!=null),...b(e.map(e=>e.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{delay:Math.max,markerFilter:ln,tooltipFilter:ln,needsRefresh:(e,t)=>e?t?n=>e(n)||t(n):e:t,hideOn:(e,t)=>e?t?(n,r,i)=>e(n,r,i)||t(n,r,i):e:t,autoPanel:(e,t)=>e||t})}}});function ln(e,t){return e?t?(n,r)=>t(e(n,r),r):e:t}function un(e){let t=[];if(e)actions:for(let{name:n}of e){for(let e=0;e<n.length;e++){let r=n[e];if(/[a-zA-Z]/.test(r)&&!t.some(e=>e.toLowerCase()==r.toLowerCase())){t.push(r);continue actions}}t.push(``)}return t}function dn(e,t,n){let r=n?un(t.actions):[];return z(`li`,{class:`cm-diagnostic cm-diagnostic-`+t.severity},z(`span`,{class:`cm-diagnosticText`},t.renderMessage?t.renderMessage(e):t.message),t.actions?.map((n,i)=>{let a=!1,o=r=>{if(r.preventDefault(),a)return;a=!0;let i=X(e.state.field(Z).diagnostics,t);i&&n.apply(e,i.from,i.to)},{name:s}=n,c=r[i]?s.indexOf(r[i]):-1,l=c<0?s:[s.slice(0,c),z(`u`,s.slice(c,c+1)),s.slice(c+1)];return z(`button`,{type:`button`,class:`cm-diagnosticAction`+(n.markClass?` `+n.markClass:``),onclick:o,onmousedown:o,"aria-label":` Action: ${s}${c<0?``:` (access key "${r[i]})"`}.`},l)}),t.source&&z(`div`,{class:`cm-diagnosticSource`},t.source))}var fn=class extends v{constructor(e){super(),this.sev=e}eq(e){return e.sev==this.sev}toDOM(){return z(`span`,{class:`cm-lintPoint cm-lintPoint-`+this.sev})}},pn=class{constructor(e,t){this.diagnostic=t,this.id=`item_`+Math.floor(Math.random()*4294967295).toString(16),this.dom=dn(e,t,!0),this.dom.id=this.id,this.dom.setAttribute(`role`,`option`)}},mn=class e{constructor(e){this.view=e,this.items=[],this.list=z(`ul`,{tabIndex:0,role:`listbox`,"aria-label":this.view.state.phrase(`Diagnostics`),onkeydown:t=>{if(!(t.ctrlKey||t.altKey||t.metaKey)){if(t.keyCode==27)sn(this.view),this.view.focus();else if(t.keyCode==38||t.keyCode==33)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(t.keyCode==40||t.keyCode==34)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(t.keyCode==36)this.moveSelection(0);else if(t.keyCode==35)this.moveSelection(this.items.length-1);else if(t.keyCode==13)this.view.focus();else if(t.keyCode>=65&&t.keyCode<=90&&this.selectedIndex>=0){let{diagnostic:n}=this.items[this.selectedIndex],r=un(n.actions);for(let i=0;i<r.length;i++)if(r[i].toUpperCase().charCodeAt(0)==t.keyCode){let t=X(this.view.state.field(Z).diagnostics,n);t&&n.actions[i].apply(e,t.from,t.to)}}else return;t.preventDefault()}},onclick:e=>{for(let t=0;t<this.items.length;t++)this.items[t].dom.contains(e.target)&&this.moveSelection(t)}}),this.dom=z(`div`,{class:`cm-panel-lint`},this.list,z(`button`,{type:`button`,name:`close`,"aria-label":this.view.state.phrase(`close`),onclick:()=>sn(this.view)},`×`)),this.update()}get selectedIndex(){let e=this.view.state.field(Z).selected;if(!e)return-1;for(let t=0;t<this.items.length;t++)if(this.items[t].diagnostic==e.diagnostic)return t;return-1}update(){let{diagnostics:e,selected:t}=this.view.state.field(Z),n=0,r=!1,i=null,a=new Set;for(e.between(0,this.view.state.doc.length,(e,o,{spec:s})=>{for(let e of s.diagnostics){if(a.has(e))continue;a.add(e);let o=-1,s;for(let t=n;t<this.items.length;t++)if(this.items[t].diagnostic==e){o=t;break}o<0?(s=new pn(this.view,e),this.items.splice(n,0,s),r=!0):(s=this.items[o],o>n&&(this.items.splice(n,o-n),r=!0)),t&&s.diagnostic==t.diagnostic?s.dom.hasAttribute(`aria-selected`)||(s.dom.setAttribute(`aria-selected`,`true`),i=s):s.dom.hasAttribute(`aria-selected`)&&s.dom.removeAttribute(`aria-selected`),n++}});n<this.items.length&&!(this.items.length==1&&this.items[0].diagnostic.from<0);)r=!0,this.items.pop();this.items.length==0&&(this.items.push(new pn(this.view,{from:-1,to:-1,severity:`info`,message:this.view.state.phrase(`No diagnostics`)})),r=!0),i?(this.list.setAttribute(`aria-activedescendant`,i.id),this.view.requestMeasure({key:this,read:()=>({sel:i.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:e,panel:t})=>{let n=t.height/this.list.offsetHeight;e.top<t.top?this.list.scrollTop-=(t.top-e.top)/n:e.bottom>t.bottom&&(this.list.scrollTop+=(e.bottom-t.bottom)/n)}})):this.selectedIndex<0&&this.list.removeAttribute(`aria-activedescendant`),r&&this.sync()}sync(){let e=this.list.firstChild;function t(){let t=e;e=t.nextSibling,t.remove()}for(let n of this.items)if(n.dom.parentNode==this.list){for(;e!=n.dom;)t();e=n.dom.nextSibling}else this.list.insertBefore(n.dom,e);for(;e;)t()}moveSelection(e){if(this.selectedIndex<0)return;let t=X(this.view.state.field(Z).diagnostics,this.items[e].diagnostic);t&&this.view.dispatch({selection:{anchor:t.from,head:t.to},scrollIntoView:!0,effects:tn.of(t)})}static open(t){return new e(t)}};function hn(e,t=`viewBox="0 0 40 40"`){return`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" ${t}>${encodeURIComponent(e)}</svg>')`}function $(e){return hn(`<path d="m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0" stroke="${e}" fill="none" stroke-width=".7"/>`,`width="6" height="3"`)}var gn=M.baseTheme({".cm-diagnostic":{padding:`3px 6px 3px 8px`,marginLeft:`-1px`,display:`block`,whiteSpace:`pre-wrap`},".cm-diagnostic-error":{borderLeft:`5px solid #d11`},".cm-diagnostic-warning":{borderLeft:`5px solid orange`},".cm-diagnostic-info":{borderLeft:`5px solid #999`},".cm-diagnostic-hint":{borderLeft:`5px solid #66d`},".cm-diagnosticAction":{font:`inherit`,border:`none`,padding:`2px 4px`,backgroundColor:`#444`,color:`white`,borderRadius:`3px`,marginLeft:`8px`,cursor:`pointer`},".cm-diagnosticSource":{fontSize:`70%`,opacity:.7},".cm-lintRange":{backgroundPosition:`left bottom`,backgroundRepeat:`repeat-x`,paddingBottom:`0.7px`},".cm-lintRange-error":{backgroundImage:$(`#d11`)},".cm-lintRange-warning":{backgroundImage:$(`orange`)},".cm-lintRange-info":{backgroundImage:$(`#999`)},".cm-lintRange-hint":{backgroundImage:$(`#66d`)},".cm-lintRange-active":{backgroundColor:`#ffdd9980`},".cm-tooltip-lint":{padding:0,margin:0},".cm-lintPoint":{position:`relative`,"&:after":{content:`""`,position:`absolute`,bottom:0,left:`-2px`,borderLeft:`3px solid transparent`,borderRight:`3px solid transparent`,borderBottom:`4px solid #d11`}},".cm-lintPoint-warning":{"&:after":{borderBottomColor:`orange`}},".cm-lintPoint-info":{"&:after":{borderBottomColor:`#999`}},".cm-lintPoint-hint":{"&:after":{borderBottomColor:`#66d`}},".cm-panel.cm-panel-lint":{position:`relative`,"& ul":{maxHeight:`100px`,overflowY:`auto`,"& [aria-selected]":{backgroundColor:`#ddd`,"& u":{textDecoration:`underline`}},"&:focus [aria-selected]":{background_fallback:`#bdf`,backgroundColor:`Highlight`,color_fallback:`white`,color:`HighlightText`},"& u":{textDecoration:`none`},padding:0,margin:0},"& [name=close]":{position:`absolute`,top:`0`,right:`2px`,background:`inherit`,border:`none`,font:`inherit`,padding:0,margin:0}},"&dark .cm-lintRange-active":{backgroundColor:`#86714a80`},"&dark .cm-panel.cm-panel-lint ul":{"& [aria-selected]":{backgroundColor:`#2e343e`}}});function _n(e){return e==`error`?4:e==`warning`?3:e==`info`?2:1}function vn(e){let t=`hint`,n=1;for(let r of e){let e=_n(r.severity);e>n&&(n=e,t=r.severity)}return t}var yn=[Z,M.decorations.compute([Z],e=>{let{selected:t,panel:n}=e.field(Z);return!t||!n||t.from==t.to?E.none:E.set([nn.range(t.from,t.to)])}),_e(rn,{hideOn:Zt}),gn],bn=[I(),Se(),F(),l(),N(),Ce(),ye(),x.allowMultipleSelections.of(!0),S(),O(pe,{fallback:!0}),ge(),Ae(),Oe(),ve(),L(),be(),at(),we.of([...De,...c,...Ut,...f,...Te,...ke,...cn])];F(),l(),Ce(),O(pe,{fallback:!0}),we.of([...c,...f]);var xn={words:0,chars:0,tokens:0},Sn=/[ -〿぀-ゟ゠-ヿ㐀-䶿一-鿿豈-﫿＀-￯฀-๿ក-៿]/,Cn=/[\p{L}\p{N}]/u,wn=new Set([`text`,`inlineCode`,`code`,`tag`]),Tn=new Set([`html`,`definition`,`footnoteDefinition`,`yaml`,`toml`,`image`,`imageReference`,`mdxFlowExpression`,`mdxTextExpression`,`mdxjsEsm`,`rawMdxFallback`,`rawMdxFallbackMdast`]),En=new Set([`paragraph`,`heading`,`blockquote`,`list`,`listItem`,`thematicBreak`,`table`,`tableRow`,`tableCell`,`mdxJsxFlowElement`,`commentBlock`]);function Dn(e,t){if(!e)return;let n=e.type;if(!Tn.has(n)){if(wn.has(n)){e.value&&(t.push(e.value),n===`code`&&t.push(`
3
3
  `));return}if(n===`wikiLink`||n===`wikiLinkEmbed`){let n=e.data?.alias??e.value??``;n&&t.push(n);return}if(Array.isArray(e.children)){for(let n of e.children)Dn(n,t);if(En.has(n)&&t.length>0){let e=t[t.length-1];e&&!e.endsWith(`
4
4
  `)&&t.push(`
@@ -48,7 +48,7 @@
48
48
  -->
49
49
  <script>(() => { let t = 'system'; try { const r = localStorage.getItem('ok-theme-v1'); if (r === 'light' || r === 'dark' || r === 'system') t = r; } catch {} let dark = t === 'dark'; if (t === 'system') { try { dark = window.matchMedia('(prefers-color-scheme: dark)').matches; } catch {} } if (dark) document.documentElement.classList.add('dark'); if (window.okDesktop) document.documentElement.classList.add('electron-mode'); })();</script>
50
50
  <style>html { background-color: #fafafa } html.dark { background-color: #171717 }</style>
51
- <script type="module" crossorigin src="./assets/index-Do4YGiKm.js"></script>
51
+ <script type="module" crossorigin src="./assets/index--4pY9sQD.js"></script>
52
52
  <link rel="modulepreload" crossorigin href="./assets/chunk-CFjPhJqf.js">
53
53
  <link rel="modulepreload" crossorigin href="./assets/preload-helper-2ej06EnG.js">
54
54
  <link rel="modulepreload" crossorigin href="./assets/w3c-keyname-nBRha8PK.js">
@@ -67,25 +67,25 @@
67
67
  <link rel="modulepreload" crossorigin href="./assets/dist-CSynDsuh.js">
68
68
  <link rel="modulepreload" crossorigin href="./assets/tooltip-DjrmDp0P.js">
69
69
  <link rel="modulepreload" crossorigin href="./assets/trace-api-DPMyR1_m.js">
70
- <link rel="modulepreload" crossorigin href="./assets/dist-DzbxRXt5.js">
71
- <link rel="modulepreload" crossorigin href="./assets/prop-types-C0kDsvPx.js">
70
+ <link rel="modulepreload" crossorigin href="./assets/dist-D2H0qs9k.js">
71
+ <link rel="modulepreload" crossorigin href="./assets/prop-types-CMddcK9H.js">
72
72
  <link rel="modulepreload" crossorigin href="./assets/propagation-api-qAYD7s-v.js">
73
73
  <link rel="modulepreload" crossorigin href="./assets/collapsible-BzkAcCLq.js">
74
74
  <link rel="modulepreload" crossorigin href="./assets/dist-DuNRfJxD.js">
75
75
  <link rel="modulepreload" crossorigin href="./assets/dialog-uOgi9SAD.js">
76
- <link rel="modulepreload" crossorigin href="./assets/DocumentContext-DppavGIB.js">
76
+ <link rel="modulepreload" crossorigin href="./assets/DocumentContext-FzcL7UQZ.js">
77
77
  <link rel="modulepreload" crossorigin href="./assets/panel-BQ1weDcE.js">
78
- <link rel="modulepreload" crossorigin href="./assets/typing-burst-detector-Wg72tb4K.js">
78
+ <link rel="modulepreload" crossorigin href="./assets/typing-burst-detector-ktvC37ND.js">
79
79
  <link rel="modulepreload" crossorigin href="./assets/checkbox-BlEgF5ZV.js">
80
80
  <link rel="modulepreload" crossorigin href="./assets/dist-C_giuVsx.js">
81
81
  <link rel="modulepreload" crossorigin href="./assets/textarea-DV1qaluU.js">
82
82
  <link rel="modulepreload" crossorigin href="./assets/toggle-group-DsgJIlng.js">
83
- <link rel="modulepreload" crossorigin href="./assets/config-validation-events-De91seTf.js">
83
+ <link rel="modulepreload" crossorigin href="./assets/config-validation-events-gsbmznWN.js">
84
84
  <link rel="modulepreload" crossorigin href="./assets/agent-presence-DYKkeiBZ.js">
85
85
  <link rel="modulepreload" crossorigin href="./assets/project-paths-lA0ULe1F.js">
86
- <link rel="modulepreload" crossorigin href="./assets/target-navigation-intent-BW8U2Njg.js">
86
+ <link rel="modulepreload" crossorigin href="./assets/target-navigation-intent-Dxk9beLq.js">
87
87
  <link rel="modulepreload" crossorigin href="./assets/terminal-theme-BhdZI3O9.js">
88
- <link rel="modulepreload" crossorigin href="./assets/keyboard-shortcuts-CrOPSj32.js">
88
+ <link rel="modulepreload" crossorigin href="./assets/keyboard-shortcuts-DdDIPI_l.js">
89
89
  <link rel="modulepreload" crossorigin href="./assets/mcp-consent-store-BmlKYN7O.js">
90
90
  <link rel="stylesheet" crossorigin href="./assets/DocumentContext-B0sQn39F.css">
91
91
  <link rel="stylesheet" crossorigin href="./assets/index-DlZTOWgT.css">
@@ -1,2 +1,2 @@
1
- import{h as e,n as t}from"./init-CmYOMgKC.mjs";import{t as n}from"./is-object-Cg453afR.mjs";import{existsSync as r,readFileSync as i}from"node:fs";import{join as a}from"node:path";const o=[[`@inkeep/open-knowledge`,`ui`],[`-y`,`@inkeep/open-knowledge`,`ui`],t];function s(e){if(e.runtimeExecutable===`/bin/sh`&&Array.isArray(e.runtimeArgs)){let t=e.runtimeArgs[2];if(typeof t==`string`){if(t.includes(`# ok-ui-v1`))return`canonical`;if(/# ok-ui-v\d+/.test(t))return`legacy-bare`}return`preserved`}if(e.runtimeExecutable===`npx`&&Array.isArray(e.runtimeArgs)){for(let t of o)if(c(e.runtimeArgs,t))return`legacy-bare`}return`preserved`}function c(e,t){if(e.length!==t.length)return!1;for(let n=0;n<t.length;n++)if(e[n]!==t[n])return!1;return!0}function l(t){let o=t.logger??u,c=a(t.projectDir,`.claude`,`launch.json`);if(t.reclaimDisableEnv===`1`)return o({event:`launch-json-repair-skipped`,reason:`reclaim-disabled`}),{outcome:{configPath:c,outcome:`skipped-reclaim-disabled`},repairedCount:0};if(!r(c))return{outcome:{configPath:c,outcome:`no-file`},repairedCount:0};let l;try{let e=i(c,`utf-8`).trim();l=e?JSON.parse(e):{}}catch(e){let t=e instanceof Error?e.message:String(e);return o({event:`launch-json-repair-read-failed`,configPath:c,error:t}),{outcome:{configPath:c,outcome:`read-failed`,error:t},repairedCount:0}}if(!n(l)){let e=`launch.json root is not an object`;return o({event:`launch-json-repair-read-failed`,configPath:c,error:e}),{outcome:{configPath:c,outcome:`read-failed`,error:e},repairedCount:0}}let d=l.configurations;if(!Array.isArray(d))return{outcome:{configPath:c,outcome:`no-entry`},repairedCount:0};let f=d.find(e=>n(e)&&e.name===`open-knowledge-ui`);if(!f)return{outcome:{configPath:c,outcome:`no-entry`},repairedCount:0};let p=s(f);if(p===`canonical`)return{outcome:{configPath:c,outcome:`canonical`},repairedCount:0};if(p===`preserved`)return{outcome:{configPath:c,outcome:`preserved`},repairedCount:0};let m=e(t.projectDir,{mode:`published`});if(m.action===`failed`){let e=m.error??`unknown write failure`;return o({event:`launch-json-repair-write-failed`,configPath:c,error:e}),{outcome:{configPath:c,outcome:`write-failed`,error:e},repairedCount:0}}return o({event:`launch-json-repair-applied`,configPath:c}),{outcome:{configPath:c,outcome:`repaired`},repairedCount:1}}function u(e){process.stderr.write(`${JSON.stringify(e)}\n`)}export{l as repairLaunchJson};
2
- //# sourceMappingURL=repair-launch-json-il6GUyPg.mjs.map
1
+ import{h as e,n as t}from"./init-FqiSJrgt.mjs";import{t as n}from"./is-object-Cg453afR.mjs";import{existsSync as r,readFileSync as i}from"node:fs";import{join as a}from"node:path";const o=[[`@inkeep/open-knowledge`,`ui`],[`-y`,`@inkeep/open-knowledge`,`ui`],t];function s(e){if(e.runtimeExecutable===`/bin/sh`&&Array.isArray(e.runtimeArgs)){let t=e.runtimeArgs[2];if(typeof t==`string`){if(t.includes(`# ok-ui-v1`))return`canonical`;if(/# ok-ui-v\d+/.test(t))return`legacy-bare`}return`preserved`}if(e.runtimeExecutable===`npx`&&Array.isArray(e.runtimeArgs)){for(let t of o)if(c(e.runtimeArgs,t))return`legacy-bare`}return`preserved`}function c(e,t){if(e.length!==t.length)return!1;for(let n=0;n<t.length;n++)if(e[n]!==t[n])return!1;return!0}function l(t){let o=t.logger??u,c=a(t.projectDir,`.claude`,`launch.json`);if(t.reclaimDisableEnv===`1`)return o({event:`launch-json-repair-skipped`,reason:`reclaim-disabled`}),{outcome:{configPath:c,outcome:`skipped-reclaim-disabled`},repairedCount:0};if(!r(c))return{outcome:{configPath:c,outcome:`no-file`},repairedCount:0};let l;try{let e=i(c,`utf-8`).trim();l=e?JSON.parse(e):{}}catch(e){let t=e instanceof Error?e.message:String(e);return o({event:`launch-json-repair-read-failed`,configPath:c,error:t}),{outcome:{configPath:c,outcome:`read-failed`,error:t},repairedCount:0}}if(!n(l)){let e=`launch.json root is not an object`;return o({event:`launch-json-repair-read-failed`,configPath:c,error:e}),{outcome:{configPath:c,outcome:`read-failed`,error:e},repairedCount:0}}let d=l.configurations;if(!Array.isArray(d))return{outcome:{configPath:c,outcome:`no-entry`},repairedCount:0};let f=d.find(e=>n(e)&&e.name===`open-knowledge-ui`);if(!f)return{outcome:{configPath:c,outcome:`no-entry`},repairedCount:0};let p=s(f);if(p===`canonical`)return{outcome:{configPath:c,outcome:`canonical`},repairedCount:0};if(p===`preserved`)return{outcome:{configPath:c,outcome:`preserved`},repairedCount:0};let m=e(t.projectDir,{mode:`published`});if(m.action===`failed`){let e=m.error??`unknown write failure`;return o({event:`launch-json-repair-write-failed`,configPath:c,error:e}),{outcome:{configPath:c,outcome:`write-failed`,error:e},repairedCount:0}}return o({event:`launch-json-repair-applied`,configPath:c}),{outcome:{configPath:c,outcome:`repaired`},repairedCount:1}}function u(e){process.stderr.write(`${JSON.stringify(e)}\n`)}export{l as repairLaunchJson};
2
+ //# sourceMappingURL=repair-launch-json-BaBh5Lb5.mjs.map
@@ -1,2 +1,2 @@
1
- import{d as e,g as t}from"./init-CmYOMgKC.mjs";import{c as n,o as r,r as i}from"./write-project-skill-C3yO9LBO.mjs";import{t as a}from"./mcp-migrate-event-D0NrGjvc.mjs";import{homedir as o}from"node:os";function s(e){let t=e.logger??u,n=e.home??o(),a=[];if(e.reclaimDisableEnv===`1`)return t({event:`mcp-config-repair-skipped`,reason:`reclaim-disabled`}),{outcomes:a,repairedCount:0};for(let o of i){let i=r[o],s=c(()=>i.configPath(``,n));if(s!==null&&a.push(l({scope:`user`,editorId:o,target:i,home:n,cwd:``,configPath:s,configPathOverride:void 0,logger:t})),i.projectConfigPath){let n=i.projectConfigPath,r=c(()=>n(e.projectDir));r!==null&&a.push(l({scope:`project`,editorId:o,target:i,home:void 0,cwd:e.projectDir,configPath:r,configPathOverride:r,logger:t}))}}return{outcomes:a,repairedCount:a.filter(e=>e.outcome===`repaired`).length}}function c(e){try{return e()}catch{return null}}function l(r){let i={scope:r.scope,editorId:r.editorId,configPath:r.configPath},o=e(r.target,r.cwd,r.home,r.configPathOverride);if(o===null)return{...i,outcome:`no-entry`};if(n(o))return{...i,outcome:`canonical`};r.logger(a({scope:r.scope,surface:`cli-repair`,editorId:r.editorId,configPath:r.configPath,priorEntry:o}));let s=t(r.target,r.cwd,{mode:`published`,skipAvailabilityCheck:!0},r.home,r.configPathOverride);if(s.action===`failed`){let e=s.error??`unknown write failure`;return r.logger({event:`mcp-config-repair-write-failed`,scope:r.scope,editorId:r.editorId,configPath:r.configPath,error:e}),{...i,outcome:`write-failed`,error:e}}return{...i,outcome:`repaired`}}function u(e){process.stderr.write(`${JSON.stringify(e)}\n`)}export{s as repairMcpConfigs};
2
- //# sourceMappingURL=repair-mcp-configs-CHoCpteG.mjs.map
1
+ import{d as e,g as t}from"./init-FqiSJrgt.mjs";import{c as n,o as r,r as i}from"./write-project-skill-CpgIz0Rh.mjs";import{t as a}from"./mcp-migrate-event-D0NrGjvc.mjs";import{homedir as o}from"node:os";function s(e){let t=e.logger??u,n=e.home??o(),a=[];if(e.reclaimDisableEnv===`1`)return t({event:`mcp-config-repair-skipped`,reason:`reclaim-disabled`}),{outcomes:a,repairedCount:0};for(let o of i){let i=r[o],s=c(()=>i.configPath(``,n));if(s!==null&&a.push(l({scope:`user`,editorId:o,target:i,home:n,cwd:``,configPath:s,configPathOverride:void 0,logger:t})),i.projectConfigPath){let n=i.projectConfigPath,r=c(()=>n(e.projectDir));r!==null&&a.push(l({scope:`project`,editorId:o,target:i,home:void 0,cwd:e.projectDir,configPath:r,configPathOverride:r,logger:t}))}}return{outcomes:a,repairedCount:a.filter(e=>e.outcome===`repaired`).length}}function c(e){try{return e()}catch{return null}}function l(r){let i={scope:r.scope,editorId:r.editorId,configPath:r.configPath},o=e(r.target,r.cwd,r.home,r.configPathOverride);if(o===null)return{...i,outcome:`no-entry`};if(n(o))return{...i,outcome:`canonical`};r.logger(a({scope:r.scope,surface:`cli-repair`,editorId:r.editorId,configPath:r.configPath,priorEntry:o}));let s=t(r.target,r.cwd,{mode:`published`,skipAvailabilityCheck:!0},r.home,r.configPathOverride);if(s.action===`failed`){let e=s.error??`unknown write failure`;return r.logger({event:`mcp-config-repair-write-failed`,scope:r.scope,editorId:r.editorId,configPath:r.configPath,error:e}),{...i,outcome:`write-failed`,error:e}}return{...i,outcome:`repaired`}}function u(e){process.stderr.write(`${JSON.stringify(e)}\n`)}export{s as repairMcpConfigs};
2
+ //# sourceMappingURL=repair-mcp-configs-ulh0L1bV.mjs.map
@@ -0,0 +1 @@
1
+ import{t as e}from"./repair-skills-CtiRAipc.mjs";export{e as repairSkills};
@@ -1,3 +1,3 @@
1
- import{t as e}from"./esm-BLMtE3s6.mjs";import{Mr as t,Or as n,Rr as r,Vi as i,wr as a}from"./dist-dm_DI4lI.mjs";import{i as o,o as s,t as c}from"./write-project-skill-C3yO9LBO.mjs";import{existsSync as l,mkdirSync as u,readFileSync as d,readdirSync as f,rmSync as p,statSync as m,writeFileSync as h}from"node:fs";import{dirname as g,join as _,resolve as v}from"node:path";import{homedir as y}from"node:os";const b=[{hostDir:`.claude`,editorId:`claude`},{hostDir:`.cursor`,editorId:`cursor`},{hostDir:`.agents`,editorId:`codex`},{hostDir:`.agents`,editorId:`opencode`}],x=`open-knowledge-discovery`,S=[`.agents`,`skills`,x],C={existsSync:e=>l(e),isDirectory:e=>{try{return m(e).isDirectory()}catch(e){if(e.code===`ENOENT`)return!1;throw e}},readdirSync:e=>f(e),readFileSync:e=>d(e),writeFileSync:(e,t)=>{h(e,t)},mkdirSync:(e,t)=>{u(e,t)},rmSync:(e,t)=>{p(e,t)}},w={resolveProjectBundledSkillDir:()=>r(`project`,{checkDesktop:!1}),resolveDiscoveryBundledSkillDir:()=>r(`discovery`,{checkDesktop:!1}),readBundledVersion:()=>a(),readRecordedVersion:e=>n(e,`cli-hosts`),writeRecordedVersion:(e,t)=>i(e,`cli-hosts`,t,`cli-start`),recordEvent:e=>t(e)};function T(e){process.stderr.write(`${JSON.stringify(e)}\n`)}function E(e,t,n){n.rmSync(t,{recursive:!0,force:!0}),n.mkdirSync(g(t),{recursive:!0}),D(e,t,n)}function D(e,t,n){n.mkdirSync(t,{recursive:!0});for(let r of n.readdirSync(e)){let i=_(e,r),a=_(t,r);n.isDirectory(i)?D(i,a,n):n.writeFileSync(a,n.readFileSync(i))}}function O(e,t){if(!e)return!1;try{return t.existsSync(e)?t.readFileSync(e).toString(`utf8`).includes(o):!1}catch{return!1}}function k(e,t,n,r){let i;try{i=t.resolveProjectBundledSkillDir()}catch(e){return r({event:`project-skill-reclaim-bundle-missing`,scope:`project`,error:e instanceof Error?e.message:String(e)}),{outcome:`skipped`,reason:`bundle-missing`}}let a=[];for(let t of b){let o=_(e,t.hostDir,`skills`,`open-knowledge`),l=_(o,`SKILL.md`),u=n.existsSync(l),d=s[t.editorId]?.projectConfigPath?.(e),f=!u&&O(d,n);if(!u&&!f){a.push({editorId:t.editorId,hostDir:t.hostDir,path:o,outcome:`no-token`}),r({event:`project-skill-reclaim-no-token`,scope:`project`,editorId:t.editorId,path:o});continue}try{c(o,e),E(i,o,n);let s=u?`reclaimed`:`created`;a.push({editorId:t.editorId,hostDir:t.hostDir,path:o,outcome:s}),r({event:u?`project-skill-reclaim-reclaimed`:`project-skill-reclaim-created`,scope:`project`,editorId:t.editorId,path:o})}catch(e){let n=e instanceof Error?e.message:String(e);a.push({editorId:t.editorId,hostDir:t.hostDir,path:o,outcome:`failed`,error:n}),r({event:`project-skill-reclaim-failed`,scope:`project`,editorId:t.editorId,path:o,error:n})}}return{outcome:`done`,entries:a}}async function A(e,t,n,r){let i=e=>{t.recordEvent(e).catch(()=>{})},a=()=>new Date().toISOString(),o;try{o=await t.readBundledVersion()}catch(e){let t=e instanceof Error?e.message:String(e);return r({event:`user-skill-reclaim-version-read-failed`,scope:`user`,error:t}),i({ts:a(),surface:`cli-start`,target:`cli-hosts`,bundle:`discovery`,outcome:`failed`,reason:`version-read-failed:${t}`}),{outcome:`skipped`,reason:`version-read-failed`}}let s;try{s=await t.readRecordedVersion(e)}catch(e){r({event:`user-skill-reclaim-version-read-error`,scope:`user`,error:e instanceof Error?e.message:String(e)}),s=null}if(s!==null&&s===o)return r({event:`user-skill-reclaim-skipped-version-current`,scope:`user`,version:o}),{outcome:`skipped`,reason:`version-current`};let c;try{c=t.resolveDiscoveryBundledSkillDir()}catch(e){let t=e instanceof Error?e.message:String(e);return r({event:`user-skill-reclaim-bundle-missing`,scope:`user`,error:t}),i({ts:a(),surface:`cli-start`,target:`cli-hosts`,bundle:`discovery`,outcome:`failed`,reason:`bundle-missing:${t}`}),{outcome:`skipped`,reason:`bundle-missing`}}let l=[],u=_(e,...S),d=n.existsSync(u);try{E(c,u,n),l.push({kind:`central`,path:u,outcome:d?`overwritten`:`written`}),r({event:`user-skill-reclaim-central-written`,scope:`user`,path:u,preexisting:d,version:o})}catch(e){let t=e instanceof Error?e.message:String(e);l.push({kind:`central`,path:u,outcome:`failed`,error:t}),r({event:`user-skill-reclaim-central-failed`,scope:`user`,path:u,error:t})}for(let t of b){let i=_(e,t.hostDir),a=_(i,`skills`,x);if(a===u){l.push({kind:`host`,editorId:t.editorId,hostDir:t.hostDir,path:a,outcome:`skipped-collapsed-with-central`});continue}if(!n.existsSync(i)){l.push({kind:`host`,editorId:t.editorId,hostDir:t.hostDir,path:a,outcome:`skipped-host-absent`});continue}let s=n.existsSync(a);try{E(c,a,n),l.push({kind:`host`,editorId:t.editorId,hostDir:t.hostDir,path:a,outcome:s?`overwritten`:`written`}),r({event:`user-skill-reclaim-host-written`,scope:`user`,editorId:t.editorId,hostDir:t.hostDir,path:a,preexisting:s,version:o})}catch(e){let n=e instanceof Error?e.message:String(e);l.push({kind:`host`,editorId:t.editorId,hostDir:t.hostDir,path:a,outcome:`failed`,error:n}),r({event:`user-skill-reclaim-host-failed`,scope:`user`,editorId:t.editorId,hostDir:t.hostDir,path:a,error:n})}}let f=l.find(e=>e.kind===`central`);if(f?.outcome===`written`||f?.outcome===`overwritten`){let n=null;try{await t.writeRecordedVersion(e,o),r({event:`user-skill-reclaim-version-recorded`,scope:`user`,version:o})}catch(e){n=e instanceof Error?e.message:String(e),r({event:`user-skill-reclaim-version-record-failed`,scope:`user`,version:o,error:n})}i({ts:a(),surface:`cli-start`,target:`cli-hosts`,bundle:`discovery`,outcome:n===null?`installed`:`failed`,version:o,...n===null?{}:{reason:`state-write-failed:${n}`}})}else{let e=l.some(e=>e.kind===`host`&&e.outcome===`failed`);i({ts:a(),surface:`cli-start`,target:`cli-hosts`,bundle:`discovery`,outcome:`failed`,version:o,reason:e?`all-writes-failed`:`no-hosts-installed`})}return{outcome:`done`,version:o,entries:l}}async function j(e){let t=e.logger??T,n=e.fs??C,r=e.home??y(),i={...w,...e.deps};return e.reclaimDisableEnv===`1`?(t({event:`skill-repair-skipped`,reason:`reclaim-disabled`}),{status:`skipped`,reason:`reclaim-disabled`}):{status:`done`,project:k(e.projectDir,i,n,t),user:await A(r,i,n,t)}}function M(e){return e.status===`skipped`?e.reason===`reclaim-disabled`?0:1:e.project.outcome===`skipped`||e.user.outcome===`skipped`&&e.user.reason!==`version-current`||e.project.entries.some(e=>e.outcome===`failed`)||e.user.outcome===`done`&&e.user.entries.some(e=>e.outcome===`failed`)?1:0}function N(e){if(e.status===`skipped`)return`Skipped: ${e.reason}`;let t=[`Skill reclaim complete.`];if(e.project.outcome===`done`){let n=e.project.entries.filter(e=>e.outcome===`reclaimed`).length,r=e.project.entries.filter(e=>e.outcome===`created`).length,i=e.project.entries.filter(e=>e.outcome===`no-token`).length,a=e.project.entries.filter(e=>e.outcome===`failed`).length;t.push(` Project: ${n} reclaimed, ${r} created, ${i} no-token, ${a} failed.`)}else t.push(` Project: skipped (${e.project.reason}).`);if(e.user.outcome===`done`){let n=e.user.entries.filter(e=>e.outcome===`written`||e.outcome===`overwritten`).length,r=e.user.entries.filter(e=>e.outcome===`skipped-host-absent`||e.outcome===`skipped-collapsed-with-central`).length,i=e.user.entries.filter(e=>e.outcome===`failed`).length;t.push(` User (${e.user.version}): ${n} written, ${r} skipped, ${i} failed.`)}else t.push(` User: skipped (${e.user.reason}).`);return t.join(`
1
+ import{t as e}from"./esm-BLMtE3s6.mjs";import{Mr as t,Or as n,Rr as r,Vi as i,wr as a}from"./dist-L7DxXZ3e.mjs";import{i as o,o as s,t as c}from"./write-project-skill-CpgIz0Rh.mjs";import{existsSync as l,mkdirSync as u,readFileSync as d,readdirSync as f,rmSync as p,statSync as m,writeFileSync as h}from"node:fs";import{dirname as g,join as _,resolve as v}from"node:path";import{homedir as y}from"node:os";const b=[{hostDir:`.claude`,editorId:`claude`},{hostDir:`.cursor`,editorId:`cursor`},{hostDir:`.agents`,editorId:`codex`},{hostDir:`.agents`,editorId:`opencode`}],x=`open-knowledge-discovery`,S=[`.agents`,`skills`,x],C={existsSync:e=>l(e),isDirectory:e=>{try{return m(e).isDirectory()}catch(e){if(e.code===`ENOENT`)return!1;throw e}},readdirSync:e=>f(e),readFileSync:e=>d(e),writeFileSync:(e,t)=>{h(e,t)},mkdirSync:(e,t)=>{u(e,t)},rmSync:(e,t)=>{p(e,t)}},w={resolveProjectBundledSkillDir:()=>r(`project`,{checkDesktop:!1}),resolveDiscoveryBundledSkillDir:()=>r(`discovery`,{checkDesktop:!1}),readBundledVersion:()=>a(),readRecordedVersion:e=>n(e,`cli-hosts`),writeRecordedVersion:(e,t)=>i(e,`cli-hosts`,t,`cli-start`),recordEvent:e=>t(e)};function T(e){process.stderr.write(`${JSON.stringify(e)}\n`)}function E(e,t,n){n.rmSync(t,{recursive:!0,force:!0}),n.mkdirSync(g(t),{recursive:!0}),D(e,t,n)}function D(e,t,n){n.mkdirSync(t,{recursive:!0});for(let r of n.readdirSync(e)){let i=_(e,r),a=_(t,r);n.isDirectory(i)?D(i,a,n):n.writeFileSync(a,n.readFileSync(i))}}function O(e,t){if(!e)return!1;try{return t.existsSync(e)?t.readFileSync(e).toString(`utf8`).includes(o):!1}catch{return!1}}function k(e,t,n,r){let i;try{i=t.resolveProjectBundledSkillDir()}catch(e){return r({event:`project-skill-reclaim-bundle-missing`,scope:`project`,error:e instanceof Error?e.message:String(e)}),{outcome:`skipped`,reason:`bundle-missing`}}let a=[];for(let t of b){let o=_(e,t.hostDir,`skills`,`open-knowledge`),l=_(o,`SKILL.md`),u=n.existsSync(l),d=s[t.editorId]?.projectConfigPath?.(e),f=!u&&O(d,n);if(!u&&!f){a.push({editorId:t.editorId,hostDir:t.hostDir,path:o,outcome:`no-token`}),r({event:`project-skill-reclaim-no-token`,scope:`project`,editorId:t.editorId,path:o});continue}try{c(o,e),E(i,o,n);let s=u?`reclaimed`:`created`;a.push({editorId:t.editorId,hostDir:t.hostDir,path:o,outcome:s}),r({event:u?`project-skill-reclaim-reclaimed`:`project-skill-reclaim-created`,scope:`project`,editorId:t.editorId,path:o})}catch(e){let n=e instanceof Error?e.message:String(e);a.push({editorId:t.editorId,hostDir:t.hostDir,path:o,outcome:`failed`,error:n}),r({event:`project-skill-reclaim-failed`,scope:`project`,editorId:t.editorId,path:o,error:n})}}return{outcome:`done`,entries:a}}async function A(e,t,n,r){let i=e=>{t.recordEvent(e).catch(()=>{})},a=()=>new Date().toISOString(),o;try{o=await t.readBundledVersion()}catch(e){let t=e instanceof Error?e.message:String(e);return r({event:`user-skill-reclaim-version-read-failed`,scope:`user`,error:t}),i({ts:a(),surface:`cli-start`,target:`cli-hosts`,bundle:`discovery`,outcome:`failed`,reason:`version-read-failed:${t}`}),{outcome:`skipped`,reason:`version-read-failed`}}let s;try{s=await t.readRecordedVersion(e)}catch(e){r({event:`user-skill-reclaim-version-read-error`,scope:`user`,error:e instanceof Error?e.message:String(e)}),s=null}if(s!==null&&s===o)return r({event:`user-skill-reclaim-skipped-version-current`,scope:`user`,version:o}),{outcome:`skipped`,reason:`version-current`};let c;try{c=t.resolveDiscoveryBundledSkillDir()}catch(e){let t=e instanceof Error?e.message:String(e);return r({event:`user-skill-reclaim-bundle-missing`,scope:`user`,error:t}),i({ts:a(),surface:`cli-start`,target:`cli-hosts`,bundle:`discovery`,outcome:`failed`,reason:`bundle-missing:${t}`}),{outcome:`skipped`,reason:`bundle-missing`}}let l=[],u=_(e,...S),d=n.existsSync(u);try{E(c,u,n),l.push({kind:`central`,path:u,outcome:d?`overwritten`:`written`}),r({event:`user-skill-reclaim-central-written`,scope:`user`,path:u,preexisting:d,version:o})}catch(e){let t=e instanceof Error?e.message:String(e);l.push({kind:`central`,path:u,outcome:`failed`,error:t}),r({event:`user-skill-reclaim-central-failed`,scope:`user`,path:u,error:t})}for(let t of b){let i=_(e,t.hostDir),a=_(i,`skills`,x);if(a===u){l.push({kind:`host`,editorId:t.editorId,hostDir:t.hostDir,path:a,outcome:`skipped-collapsed-with-central`});continue}if(!n.existsSync(i)){l.push({kind:`host`,editorId:t.editorId,hostDir:t.hostDir,path:a,outcome:`skipped-host-absent`});continue}let s=n.existsSync(a);try{E(c,a,n),l.push({kind:`host`,editorId:t.editorId,hostDir:t.hostDir,path:a,outcome:s?`overwritten`:`written`}),r({event:`user-skill-reclaim-host-written`,scope:`user`,editorId:t.editorId,hostDir:t.hostDir,path:a,preexisting:s,version:o})}catch(e){let n=e instanceof Error?e.message:String(e);l.push({kind:`host`,editorId:t.editorId,hostDir:t.hostDir,path:a,outcome:`failed`,error:n}),r({event:`user-skill-reclaim-host-failed`,scope:`user`,editorId:t.editorId,hostDir:t.hostDir,path:a,error:n})}}let f=l.find(e=>e.kind===`central`);if(f?.outcome===`written`||f?.outcome===`overwritten`){let n=null;try{await t.writeRecordedVersion(e,o),r({event:`user-skill-reclaim-version-recorded`,scope:`user`,version:o})}catch(e){n=e instanceof Error?e.message:String(e),r({event:`user-skill-reclaim-version-record-failed`,scope:`user`,version:o,error:n})}i({ts:a(),surface:`cli-start`,target:`cli-hosts`,bundle:`discovery`,outcome:n===null?`installed`:`failed`,version:o,...n===null?{}:{reason:`state-write-failed:${n}`}})}else{let e=l.some(e=>e.kind===`host`&&e.outcome===`failed`);i({ts:a(),surface:`cli-start`,target:`cli-hosts`,bundle:`discovery`,outcome:`failed`,version:o,reason:e?`all-writes-failed`:`no-hosts-installed`})}return{outcome:`done`,version:o,entries:l}}async function j(e){let t=e.logger??T,n=e.fs??C,r=e.home??y(),i={...w,...e.deps};return e.reclaimDisableEnv===`1`?(t({event:`skill-repair-skipped`,reason:`reclaim-disabled`}),{status:`skipped`,reason:`reclaim-disabled`}):{status:`done`,project:k(e.projectDir,i,n,t),user:await A(r,i,n,t)}}function M(e){return e.status===`skipped`?e.reason===`reclaim-disabled`?0:1:e.project.outcome===`skipped`||e.user.outcome===`skipped`&&e.user.reason!==`version-current`||e.project.entries.some(e=>e.outcome===`failed`)||e.user.outcome===`done`&&e.user.entries.some(e=>e.outcome===`failed`)?1:0}function N(e){if(e.status===`skipped`)return`Skipped: ${e.reason}`;let t=[`Skill reclaim complete.`];if(e.project.outcome===`done`){let n=e.project.entries.filter(e=>e.outcome===`reclaimed`).length,r=e.project.entries.filter(e=>e.outcome===`created`).length,i=e.project.entries.filter(e=>e.outcome===`no-token`).length,a=e.project.entries.filter(e=>e.outcome===`failed`).length;t.push(` Project: ${n} reclaimed, ${r} created, ${i} no-token, ${a} failed.`)}else t.push(` Project: skipped (${e.project.reason}).`);if(e.user.outcome===`done`){let n=e.user.entries.filter(e=>e.outcome===`written`||e.outcome===`overwritten`).length,r=e.user.entries.filter(e=>e.outcome===`skipped-host-absent`||e.outcome===`skipped-collapsed-with-central`).length,i=e.user.entries.filter(e=>e.outcome===`failed`).length;t.push(` User (${e.user.version}): ${n} written, ${r} skipped, ${i} failed.`)}else t.push(` User: skipped (${e.user.reason}).`);return t.join(`
2
2
  `)}function P(){return new e(`repair-skills`).description("Refresh bundled SKILL.md files for installed AI editors (project-local + user-global). Runs automatically during `ok start`; this command forces an explicit sweep.").action(async()=>{let e=await j({projectDir:v(process.cwd()),reclaimDisableEnv:process.env.OK_RECLAIM_DISABLE??null});process.stdout.write(`${N(e)}\n`),process.exitCode=M(e)})}export{P as n,j as t};
3
- //# sourceMappingURL=repair-skills-CsRymFFj.mjs.map
3
+ //# sourceMappingURL=repair-skills-CtiRAipc.mjs.map
@@ -0,0 +1 @@
1
+ import{g as e}from"./server-lock-CN2YHwpP-BWnMEaYY.mjs";export{e as updateServerLockPort};