@inkeep/open-knowledge 0.4.0-beta.33 → 0.4.0-beta.35
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.
- package/dist/assets/skills/open-knowledge/SKILL.md +1 -1
- package/dist/cli.mjs +4 -4
- package/dist/constants-CYW0QlsD.mjs +2 -0
- package/dist/index.mjs +1 -1
- package/dist/{init-JGxedyCK.mjs → init-BTHdxa_n.mjs} +3 -3
- package/dist/init-G3kzr6yr.mjs +1 -0
- package/dist/loader-BYZR4kPx.mjs +1 -0
- package/dist/{loader-CqNnLnr8.mjs → loader-DMfwha4o.mjs} +2 -2
- package/dist/{preview-DTGBU5TT.mjs → preview-CGtrTO6X.mjs} +2 -2
- package/dist/preview-Dh_pwkLj.mjs +1 -0
- package/dist/public/assets/{ActivityModeContent-PLMlj69Z.js → ActivityModeContent-CukRGM5b.js} +1 -1
- package/dist/public/assets/{DocumentContext-DyDoN3zw.js → DocumentContext-Dnlc0y78.js} +1 -1
- package/dist/public/assets/{SettingsDialog-BZIR95bl.js → SettingsDialog-D01daWLi.js} +1 -1
- package/dist/public/assets/{SourceEditor-BSNx4vgo.js → SourceEditor-oc5DmPOz.js} +2 -2
- package/dist/public/assets/{config-validation-events-CQdOhgu4.js → config-validation-events-BhBbdwp7.js} +1 -1
- package/dist/public/assets/index-DhEY5RAu.css +1 -0
- package/dist/public/assets/{index-DplFbAir.js → index-n61bMVO9.js} +67 -67
- package/dist/public/assets/{typing-burst-detector-2N-LtlIn.js → typing-burst-detector-niWkdPcc.js} +1 -1
- package/dist/public/index.html +5 -5
- package/dist/{src-DVcU_9tV.mjs → src-CfKtV4lW.mjs} +2 -2
- package/dist/{start-C2_KsW6g.mjs → start-D__quKIc.mjs} +2 -2
- package/dist/start-Fx7-B1XK.mjs +1 -0
- package/package.json +1 -1
- package/dist/constants-BorE8dNB.mjs +0 -2
- package/dist/init-CFMa0dvy.mjs +0 -1
- package/dist/loader-DwwnYa3l.mjs +0 -1
- package/dist/preview-uOPZjObT.mjs +0 -1
- package/dist/public/assets/index-CjbILLtI.css +0 -1
- package/dist/start-Cp8P8LGU.mjs +0 -1
package/dist/public/assets/{typing-burst-detector-2N-LtlIn.js → typing-burst-detector-niWkdPcc.js}
RENAMED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{o as e}from"./chunk-CFjPhJqf.js";import{n as t,r as n,t as r}from"./compiler-runtime-CVnuRdak.js";import{D as i,O as a,Yt as o,k as s,n as c,nt as l}from"./DocumentContext-
|
|
1
|
+
import{o as e}from"./chunk-CFjPhJqf.js";import{n as t,r as n,t as r}from"./compiler-runtime-CVnuRdak.js";import{D as i,O as a,Yt as o,k as s,n as c,nt as l}from"./DocumentContext-Dnlc0y78.js";import{a as u,c as d,i as f,n as ee,o as te,r as ne,s as re,t as ie,u as ae}from"./panel-8fydlQgn.js";import{At as p,Dt as m,s as oe}from"./doc-hash-D_cCMufM.js";import{r as se}from"./button-C1nwPVFQ.js";import{$ as h,At as g,Bt as _,Dt as v,E as y,Et as b,Ft as x,Ht as S,J as C,Mt as w,N as T,Ot as E,Pt as D,Q as O,Rt as k,Ut as A,X as j,_ as ce,_t as M,ct as N,dt as P,et as F,f as I,gt as L,ht as R,l as le,lt as ue,mt as de,nt as fe,ot as pe,rt as me,st as he,tt as ge,ut as _e,wt as z,y as ve,yt as B,zt as ye}from"./dist-Du-s1q8P.js";import{i as be,n as xe,o as Se,r as Ce}from"./dist-BrsSsfiw.js";var we=e(t(),1),Te=r(),Ee=new Map;function De(e,t){Ee.set(e,t)}function Oe(e){let t=Ee.get(e)??null;return Ee.delete(e),t}function ke(e){Ee.delete(e)}var Ae=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(Ae(e)):Ae,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 k(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=A(e),n=this.bufferStart+this.bufferPos;this.bufferPos+=ye(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(``)},Me=`gm`+(/x/.unicode==null?``:`u`),Ne=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 Ie(e,t,n,r,i);this.re=new RegExp(t,Me+(n?.ignoreCase?`i`:``)),this.test=n?.test,this.iter=e.iter(),this.curLineStart=e.lineAt(r).from,this.matchPos=Re(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=Re(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}}},Pe=new WeakMap,Fe=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=Pe.get(t);if(!i||i.from>=r||i.to<=n){let i=new e(n,t.sliceString(n,r));return Pe.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)),Pe.set(t,new e(o,a)),new e(n,a.slice(n-o,r-o))}},Ie=class{constructor(e,t,n,r,i){this.text=e,this.to=i,this.done=!1,this.value=je,this.matchPos=Re(e,r),this.re=new RegExp(t,Me+(n?.ignoreCase?`i`:``)),this.test=n?.test,this.flat=Fe.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=Re(this.text,n+ +(e==n)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=Fe.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+this.flat.text.length*2))}}};typeof Symbol<`u`&&(Ne.prototype[Symbol.iterator]=Ie.prototype[Symbol.iterator]=function(){return this});function Le(e){try{return new RegExp(e,Me),!0}catch{return!1}}function Re(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 ze=e=>{let{state:t}=e,n=String(t.doc.lineAt(e.state.selection.main.head).number),{close:r,result:i}=L(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))),ee=b.cursor(f.from+Math.max(0,Math.min(u,f.length)));e.dispatch({effects:[r,j.scrollIntoView(ee.from,{y:`center`})],selection:ee})}),!0},Be={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},Ve=E.define({combine(e){return _(e,Be,{highlightWordAroundCursor:(e,t)=>e||t,minSelectionLength:Math.min,maxMatches:Math.min})}});function He(e){let t=[Je,qe];return e&&t.push(Ve.of(e)),t}var Ue=C.mark({class:`cm-selectionMatch`}),We=C.mark({class:`cm-selectionMatch cm-selectionMatch-main`});function Ge(e,t,n,r){return(n==0||e(t.sliceDoc(n-1,n))!=z.Word)&&(r==t.doc.length||e(t.sliceDoc(r,r+1))!=z.Word)}function Ke(e,t,n,r){return e(t.sliceDoc(n,n+1))==z.Word&&e(t.sliceDoc(r-1,r))==z.Word}var qe=O.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(Ve),{state:n}=e,r=n.selection;if(r.ranges.length>1)return C.none;let i=r.main,a,o=null;if(i.empty){if(!t.highlightWordAroundCursor)return C.none;let e=n.wordAt(i.head);if(!e)return C.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 C.none;if(t.wholeWords){if(a=n.sliceDoc(i.from,i.to),o=n.charCategorizer(i.head),!(Ge(o,n,i.from,i.to)&&Ke(o,n,i.from,i.to)))return C.none}else if(a=n.sliceDoc(i.from,i.to),!a)return C.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||Ge(o,n,r,a))&&(i.empty&&r<=i.from&&a>=i.to?s.push(We.range(r,a)):(r>=i.to||a<=i.from)&&s.push(Ue.range(r,a)),s.length>t.maxMatches))return C.none}}return C.set(s)}},{decorations:e=>e.decorations}),Je=j.baseTheme({".cm-selectionMatch":{backgroundColor:`#99ff7780`},".cm-searchMatch .cm-selectionMatch":{backgroundColor:`transparent`}}),Ye=({state:e,dispatch:t})=>{let{selection:n}=e,r=b.create(n.ranges.map(t=>e.wordAt(t.head)||b.cursor(t.head)),n.mainIndex);return r.eq(n)?!1:(t(e.update({selection:r})),!0)};function Xe(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 Ze=({state:e,dispatch:t})=>{let{ranges:n}=e.selection;if(n.some(e=>e.from===e.to))return Ye({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=Xe(e,r);return i?(t(e.update({selection:e.selection.addRange(b.range(i.from,i.to),!1),effects:j.scrollIntoView(i.to)})),!0):!1},H=E.define({combine(e){return _(e,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:e=>new Et(e),scrollToMatch:e=>j.scrollIntoView(e)})}}),Qe=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||Le(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 st(this):new nt(this)}getCursor(e,t=0,n){let r=e.doc?e:v.create({doc:e});return n??=r.doc.length,this.regexp?W(this,r,t,n):U(this,r,t,n)}},$e=class{constructor(e){this.spec=e}};function et(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=tt(t.doc,t.charCategorizer(t.selection.main.head))),e.test&&(i=et(e.test,t,i)),new V(t.doc,e.unquoted,n,r,e.caseSensitive?void 0:e=>e.toLowerCase(),i)}function tt(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(it(i,n-a))!=z.Word||t(at(i,n-a))!=z.Word)&&(t(at(i,r-a))!=z.Word||t(it(i,r-a))!=z.Word))}var nt=class extends $e{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 rt(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=ot(t.charCategorizer(t.selection.main.head))),e.test&&(i=rt(e.test,t,i)),new Ne(t.doc,e.search,{ignoreCase:!e.caseSensitive,test:i},n,r)}function it(e,t){return e.slice(S(e,t,!1),t)}function at(e,t){return e.slice(t,S(e,t))}function ot(e){return(t,n,r)=>!r[0].length||(e(it(r.input,r.index))!=z.Word||e(at(r.input,r.index))!=z.Word)&&(e(at(r.input,r.index+r[0].length))!=z.Word||e(it(r.input,r.index+r[0].length))!=z.Word)}var st=class extends $e{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=D.define(),ct=D.define(),K=x.define({create(e){return new lt(bt(e).create(),null)},update(e,t){for(let n of t.effects)n.is(G)?e=new lt(n.value.create(),e.panel):n.is(ct)&&(e=new lt(e.query,n.value?yt:null));return e},provide:e=>M.from(e,e=>e.panel)}),lt=class{constructor(e,t){this.query=e,this.panel=t}},ut=C.mark({class:`cm-searchMatch`}),dt=C.mark({class:`cm-searchMatch cm-searchMatch-selected`}),ft=O.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 C.none;let{view:n}=this,r=new w;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?dt:ut)})}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):Ct(t)}}var pt=q((e,{query:t})=>{let{to:n}=e.state.selection.main,r=t.nextMatch(e.state,n,n);if(!r)return!1;let i=b.single(r.from,r.to),a=e.state.facet(H);return e.dispatch({selection:i,effects:[kt(e,r),a.scrollToMatch(i.main,e)],userEvent:`select.search`}),St(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=b.single(i.from,i.to),o=e.state.facet(H);return e.dispatch({selection:a,effects:[kt(e,i),o.scrollToMatch(a.main,e)],userEvent:`select.search`}),St(e),!0}),ht=q((e,{query:t})=>{let n=t.matchAll(e.state,1e3);return!n||!n.length?!1:(e.dispatch({selection:b.create(n.map(e=>b.range(e.from,e.to))),userEvent:`select.search.matches`}),!0)}),gt=({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(b.range(t.value.from,t.value.to))}return t(e.update({selection:b.create(a,o),userEvent:`select.search.matches`})),!0},_t=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(j.announce.of(n.phrase(`replaced match on line $`,n.doc.lineAt(r).number)+`.`)));let d=e.state.changes(s);return o&&(c=b.single(o.from,o.to).map(d),u.push(kt(e,o)),u.push(n.facet(H).scrollToMatch(c.main,e))),e.dispatch({changes:d,selection:c,effects:u,userEvent:`input.replace`}),!0}),vt=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:j.announce.of(r),userEvent:`input.replace.all`}),!0});function yt(e){return e.state.facet(H).createPanel(e)}function bt(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 Qe({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 xt(e){let t=me(e,yt);return t&&t.dom.querySelector(`[main-field]`)}function St(e){let t=xt(e);t&&t==e.root.activeElement&&t.select()}var Ct=e=>{let t=e.state.field(K,!1);if(t&&t.panel){let n=xt(e);if(n&&n!=e.root.activeElement){let r=bt(e.state,t.query.spec);r.valid&&e.dispatch({effects:G.of(r)}),n.focus(),n.select()}}else e.dispatch({effects:[ct.of(!0),t?G.of(bt(e.state,t.query.spec)):D.appendConfig.of(jt)]});return!0},wt=e=>{let t=e.state.field(K,!1);if(!t||!t.panel)return!1;let n=me(e,yt);return n&&n.dom.contains(e.root.activeElement)&&e.focus(),e.dispatch({effects:ct.of(!1)}),!0},Tt=[{key:`Mod-f`,run:Ct,scope:`editor search-panel`},{key:`F3`,run:pt,shift:mt,scope:`editor search-panel`,preventDefault:!0},{key:`Mod-g`,run:pt,shift:mt,scope:`editor search-panel`,preventDefault:!0},{key:`Escape`,run:wt,scope:`editor search-panel`},{key:`Mod-Shift-l`,run:gt},{key:`Mod-Alt-g`,run:ze},{key:`Mod-d`,run:Ze,preventDefault:!0}],Et=class{constructor(e){this.view=e;let t=this.query=e.state.field(K).query.spec;this.commit=this.commit.bind(this),this.searchField=B(`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=B(`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=B(`input`,{type:`checkbox`,name:`case`,form:``,checked:t.caseSensitive,onchange:this.commit}),this.reField=B(`input`,{type:`checkbox`,name:`re`,form:``,checked:t.regexp,onchange:this.commit}),this.wordField=B(`input`,{type:`checkbox`,name:`word`,form:``,checked:t.wholeWord,onchange:this.commit});function n(e,t,n){return B(`button`,{class:`cm-button`,name:e,onclick:t,type:`button`},n)}this.dom=B(`div`,{onkeydown:e=>this.keydown(e),class:`cm-search`},[this.searchField,n(`next`,()=>pt(e),[J(e,`next`)]),n(`prev`,()=>mt(e),[J(e,`previous`)]),n(`select`,()=>ht(e),[J(e,`all`)]),B(`label`,null,[this.caseField,J(e,`match case`)]),B(`label`,null,[this.reField,J(e,`regexp`)]),B(`label`,null,[this.wordField,J(e,`by word`)]),...e.state.readOnly?[]:[B(`br`),this.replaceField,n(`replace`,()=>_t(e),[J(e,`replace`)]),n(`replaceAll`,()=>vt(e),[J(e,`replace all`)])],B(`button`,{name:`close`,onclick:()=>wt(e),"aria-label":J(e,`close`),type:`button`},[`×`])])}commit(){let e=new Qe({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){R(this.view,e,`search-panel`)?e.preventDefault():e.keyCode==13&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?mt:pt)(this.view)):e.keyCode==13&&e.target==this.replaceField&&(e.preventDefault(),_t(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 Dt=30,Ot=/[\s\.,:;?!]/;function kt(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-Dt),o=Math.min(i,n+Dt),s=e.state.sliceDoc(a,o);if(a!=r.from){for(let e=0;e<Dt;e++)if(!Ot.test(s[e+1])&&Ot.test(s[e])){s=s.slice(e);break}}if(o!=i){for(let e=s.length-1;e>s.length-Dt;e--)if(!Ot.test(s[e-1])&&Ot.test(s[e])){s=s.slice(0,e);break}}return j.announce.of(`${e.state.phrase(`current match`)}. ${s} ${e.state.phrase(`on line`)} ${r.number}.`)}var At=j.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`}}),jt=[K,g.low(ft),At],Mt=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 w,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=en(s);if(i)o.add(n,n,C.widget({widget:new qt(f),diagnostics:s.slice()}));else{let e=s.reduce((e,t)=>t.markClass?e+` `+t.markClass:e,``);o.add(n,r,C.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 Mt(e,n,t||i.diagnostics[0]);else if(i.diagnostics.indexOf(r.diagnostic)<0)return!1;else r=new Mt(r.from,n,r.diagnostic)}),r}function Nt(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(Ft))||e.changes.touchesRange(a.from,Math.max(a.to,r)))}function Pt(e,t){return e.field(Z,!1)?t:t.concat(D.appendConfig.of(tn))}var Ft=D.define(),It=D.define(),Lt=D.define(),Z=x.define({create(){return new Y(C.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(Ft)){let r=t.state.facet(Q).autoPanel?n.value.length?Yt.open:null:e.panel;e=Y.init(n.value,r,t.state)}else n.is(It)?e=new Y(e.diagnostics,n.value?Yt.open:null,e.selected):n.is(Lt)&&(e=new Y(e.diagnostics,e.panel,n.value));return e},provide:e=>[M.from(e,e=>e.panel),j.decorations.from(e,e=>e.diagnostics)]}),Rt=C.mark({class:`cm-lintRange cm-lintRange-active`});function zt(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:Bt(e,i)}}}:null}function Bt(e,t){return B(`ul`,{class:`cm-tooltip-lint`},t.map(t=>Kt(e,t,!1)))}var Vt=e=>{let t=e.state.field(Z,!1);(!t||!t.panel)&&e.dispatch({effects:Pt(e.state,[It.of(!0)])});let n=me(e,Yt.open);return n&&n.dom.querySelector(`.cm-panel-lint ul`).focus(),!0},Ht=e=>{let t=e.state.field(Z,!1);return!t||!t.panel?!1:(e.dispatch({effects:It.of(!1)}),!0)},Ut=[{key:`Mod-Shift-m`,run:Vt,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=E.define({combine(e){return{sources:e.map(e=>e.source).filter(e=>e!=null),..._(e.map(e=>e.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{delay:Math.max,markerFilter:Wt,tooltipFilter:Wt,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 Wt(e,t){return e?t?(n,r)=>t(e(n,r),r):e:t}function Gt(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 Kt(e,t,n){let r=n?Gt(t.actions):[];return B(`li`,{class:`cm-diagnostic cm-diagnostic-`+t.severity},B(`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),B(`u`,s.slice(c,c+1)),s.slice(c+1)];return B(`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&&B(`div`,{class:`cm-diagnosticSource`},t.source))}var qt=class extends h{constructor(e){super(),this.sev=e}eq(e){return e.sev==this.sev}toDOM(){return B(`span`,{class:`cm-lintPoint cm-lintPoint-`+this.sev})}},Jt=class{constructor(e,t){this.diagnostic=t,this.id=`item_`+Math.floor(Math.random()*4294967295).toString(16),this.dom=Kt(e,t,!0),this.dom.id=this.id,this.dom.setAttribute(`role`,`option`)}},Yt=class e{constructor(e){this.view=e,this.items=[],this.list=B(`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)Ht(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=Gt(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=B(`div`,{class:`cm-panel-lint`},this.list,B(`button`,{type:`button`,name:`close`,"aria-label":this.view.state.phrase(`close`),onclick:()=>Ht(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 Jt(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 Jt(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:Lt.of(t)})}static open(t){return new e(t)}};function Xt(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 Zt(e){return Xt(`<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 Qt=j.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:Zt(`#d11`)},".cm-lintRange-warning":{backgroundImage:Zt(`orange`)},".cm-lintRange-info":{backgroundImage:Zt(`#999`)},".cm-lintRange-hint":{backgroundImage:Zt(`#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 $t(e){return e==`error`?4:e==`warning`?3:e==`info`?2:1}function en(e){let t=`hint`,n=1;for(let r of e){let e=$t(r.severity);e>n&&(n=e,t=r.severity)}return t}var tn=[Z,j.decorations.compute([Z],e=>{let{selected:t,panel:n}=e.field(Z);return!t||!n||t.from==t.to?C.none:C.set([Rt.range(t.from,t.to)])}),ue(zt,{hideOn:Nt}),Qt],nn=[P(),he(),N(),a(),ce(),ge(),fe(),v.allowMultipleSelections.of(!0),y(),T(I,{fallback:!0}),le(),Ce(),xe(),de(),F(),pe(),He(),_e.of([...be,...i,...Tt,...s,...ve,...Se,...Ut])];N(),a(),ge(),T(I,{fallback:!0}),_e.of([...i,...s]);function rn(e,t){let n=(0,Te.c)(4),r=t===void 0?!1:t,[i,a]=(0,we.useState)(void 0),o=(0,we.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,we.useEffect)(s,c),i}var $=n(),an=300;async function on(e){let t=await fetch(`/api/page-headings?docName=${encodeURIComponent(e)}`),n;try{n=await t.json()}catch(e){throw new l(`Page headings response was not JSON`,{cause:e,status:t.status})}if(!t.ok){let e=p.safeParse(n);throw e.success?Error(e.data.title):new l(`Page headings error response did not match RFC 9457`,{status:t.status})}let r=m.safeParse(n);if(!r.success)throw new l(`Page headings response did not match success schema`,{status:t.status});return r.data.headings??[]}var sn=32,cn=12,ln=6,un=`open-knowledge:outline-nav`;function dn(e){let t=(0,Te.c)(2),n;return t[0]===e?n=t[1]:(n=(0,$.jsx)(o,{name:`outline-panel`,children:(0,$.jsx)(fn,{...e})}),t[0]=e,t[1]=n),n}function fn(e){let t=(0,Te.c)(49),{docName:n,isSourceMode:r,className:i}=e,a=i===void 0?``:i,{pages:o,loading:s}=oe(),l=ae(),{activeProvider:p,activeDocName:m}=c(),h,g;t[0]===n?(h=t[1],g=t[2]):(h=[`page-headings`,n],g=()=>on(n),t[0]=n,t[1]=h,t[2]=g);let _;t[3]!==n||t[4]!==s||t[5]!==o?(_=!s&&o.has(n),t[3]=n,t[4]=s,t[5]=o,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}=d(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]!==n||t[16]!==l?(w=()=>{if(!p||m!==n)return;let e=p.document,t=null,r=()=>{t!==null&&clearTimeout(t),t=setTimeout(()=>{t=null,l.invalidateQueries({queryKey:[`page-headings`,n]})},an)};return e.on(`update`,r),()=>{e.off(`update`,r),t!==null&&clearTimeout(t)}},T=[p,m,n,l],t[13]=m,t[14]=p,t[15]=n,t[16]=l,t[17]=w,t[18]=T):(w=t[17],T=t[18]),(0,we.useEffect)(w,T);let E;t[19]===C?E=t[20]:(E=C.map(pn),t[19]=C,t[20]=E);let D=rn(E,r),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]!==n||t[25]!==r?(A=function(e,t){let i={index:e,slug:t,mode:r?`source`:`wysiwyg`};i.mode===`source`&&De(n,{kind:`outline`,detail:i}),window.dispatchEvent(new CustomEvent(un,{detail:i}))},t[24]=n,t[25]=r,t[26]=A):A=t[26];let j=A,ce=((k>=0?C[k].level:1)-1)*cn+(cn-ln)/2,M=k*sn+(sn-ln)/2,N;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(N=(0,$.jsx)(re,{children:`Outline`}),t[27]=N):N=t[27];let P;t[28]!==C.length||t[29]!==b?(P=!b&&(0,$.jsx)(ne,{children:C.length}),t[28]=C.length,t[29]=b,t[30]=P):P=t[30];let F;t[31]===P?F=t[32]:(F=(0,$.jsxs)(te,{children:[N,P]}),t[31]=P,t[32]=F);let I;t[33]!==k||t[34]!==D||t[35]!==x||t[36]!==j||t[37]!==C||t[38]!==b||t[39]!==ce||t[40]!==M?(I=x?(0,$.jsx)(u,{className:`px-2`,children:x instanceof Error?x.message:`Failed to load headings`}):C.length===0&&!b?(0,$.jsx)(f,{className:`px-2`,children:`No headings yet.`}):(0,$.jsxs)(`nav`,{"aria-label":`Document outline`,className:`relative`,children:[k>=0&&(0,$.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:ln,height:ln,transform:`translate(${ce}px, ${M}px)`}}),C.map((e,t)=>{let n=e.slug===D;return(0,$.jsx)(`button`,{type:`button`,"aria-current":n?`location`:void 0,onClick:()=>j(t,e.slug),className:se(`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)*cn+20}px`},title:e.text,children:e.text},t)})]}),t[33]=k,t[34]=D,t[35]=x,t[36]=j,t[37]=C,t[38]=b,t[39]=ce,t[40]=M,t[41]=I):I=t[41];let L;t[42]!==b||t[43]!==I?(L=(0,$.jsx)(ee,{className:`px-3 py-2`,"aria-busy":b,children:I}),t[42]=b,t[43]=I,t[44]=L):L=t[44];let R;return t[45]!==a||t[46]!==F||t[47]!==L?(R=(0,$.jsxs)(ie,{className:a,children:[F,L]}),t[45]=a,t[46]=F,t[47]=L,t[48]=R):R=t[48],R}function pn(e){return e.slug}export{Oe as a,ke as i,dn as n,De as o,nn as r,un as t};
|
package/dist/public/index.html
CHANGED
|
@@ -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-
|
|
51
|
+
<script type="module" crossorigin src="./assets/index-n61bMVO9.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-B5t0fahT.js">
|
|
@@ -67,20 +67,20 @@
|
|
|
67
67
|
<link rel="modulepreload" crossorigin href="./assets/dist-OTL8-1C2.js">
|
|
68
68
|
<link rel="modulepreload" crossorigin href="./assets/dist-Bej94Urx.js">
|
|
69
69
|
<link rel="modulepreload" crossorigin href="./assets/input-BOmkuBId.js">
|
|
70
|
-
<link rel="modulepreload" crossorigin href="./assets/DocumentContext-
|
|
70
|
+
<link rel="modulepreload" crossorigin href="./assets/DocumentContext-Dnlc0y78.js">
|
|
71
71
|
<link rel="modulepreload" crossorigin href="./assets/panel-8fydlQgn.js">
|
|
72
|
-
<link rel="modulepreload" crossorigin href="./assets/typing-burst-detector-
|
|
72
|
+
<link rel="modulepreload" crossorigin href="./assets/typing-burst-detector-niWkdPcc.js">
|
|
73
73
|
<link rel="modulepreload" crossorigin href="./assets/label-Dv_9VZWz.js">
|
|
74
74
|
<link rel="modulepreload" crossorigin href="./assets/toggle-group-CnwuxlqO.js">
|
|
75
75
|
<link rel="modulepreload" crossorigin href="./assets/dialog-BFN-ujuF.js">
|
|
76
76
|
<link rel="modulepreload" crossorigin href="./assets/textarea-CaFqgjns.js">
|
|
77
|
-
<link rel="modulepreload" crossorigin href="./assets/config-validation-events-
|
|
77
|
+
<link rel="modulepreload" crossorigin href="./assets/config-validation-events-BhBbdwp7.js">
|
|
78
78
|
<link rel="modulepreload" crossorigin href="./assets/mcp-consent-store-DZ1pCmhN.js">
|
|
79
79
|
<link rel="modulepreload" crossorigin href="./assets/tooltip-DZMJlHWf.js">
|
|
80
80
|
<link rel="modulepreload" crossorigin href="./assets/agent-presence-BrTlNKmt.js">
|
|
81
81
|
<link rel="modulepreload" crossorigin href="./assets/target-navigation-intent-D3oiWq7j.js">
|
|
82
82
|
<link rel="modulepreload" crossorigin href="./assets/consent-store-lB0p7dI5.js">
|
|
83
|
-
<link rel="stylesheet" crossorigin href="./assets/index-
|
|
83
|
+
<link rel="stylesheet" crossorigin href="./assets/index-DhEY5RAu.css">
|
|
84
84
|
</head>
|
|
85
85
|
|
|
86
86
|
<body class="antialiased">
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{c as e,f as t,s as n}from"./init-
|
|
2
|
-
//# sourceMappingURL=src-
|
|
1
|
+
import{c as e,f as t,s as n}from"./init-BTHdxa_n.mjs";import"./loader-DMfwha4o.mjs";import"./preview-CGtrTO6X.mjs";function r(r,i,a={}){let o=[];for(let n of i){let i=t[n],s=i.projectConfigPath?.(r);if(!s){o.push({editorId:n,outcome:`skipped-no-project-surface`});continue}let c;try{c=e(i,r,a,void 0,s)}catch(e){o.push({editorId:n,outcome:`failed`,error:e instanceof Error?e.message:String(e)});continue}if(c.action===`written`||c.action===`overwritten`){o.push({editorId:n,outcome:c.action});continue}if(c.action===`failed`){o.push({editorId:n,outcome:`failed`,error:c.error});continue}o.push({editorId:n,outcome:`failed`,error:`unexpected project-scope action: ${c.action}`})}return{editorOutcomes:o,claudeLaunchJson:i.includes(`claude`)?n(r,a):void 0}}export{r as t};
|
|
2
|
+
//# sourceMappingURL=src-CfKtV4lW.mjs.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{n as e,t}from"./esm-CEs3LWY3.mjs";import"./dist-k62w-4-v.mjs";import{n}from"./constants-
|
|
1
|
+
import{n as e,t}from"./esm-CEs3LWY3.mjs";import"./dist-k62w-4-v.mjs";import{n}from"./constants-CYW0QlsD.mjs";import{spawn as r}from"node:child_process";import{join as i}from"node:path";import{closeSync as a,existsSync as o,mkdirSync as s,openSync as c,statSync as l}from"node:fs";import{homedir as u}from"node:os";import{setTimeout as d}from"node:timers/promises";const f=`Open Knowledge.app`,p=`/Applications/${f}`;function m(){return{platform:process.platform,env:process.env,execPath:process.execPath,isTTY:process.stdout.isTTY,statSync:e=>{try{return l(e,{throwIfNoEntry:!1})??null}catch{return null}}}}function h(e){if(e.env.ELECTRON_RUN_AS_NODE===`1`){let t=/(.+?\.app)\/Contents\/MacOS\//.exec(e.execPath);if(t?.[1])return t[1]}if(g(e,p))return p;let t=i(e.homeDir??u(),`Applications`,f);return g(e,t)?t:null}function g(e,t){try{let n=i(t,`Contents`,`MacOS`,`Open Knowledge`),r=e.statSync(n);return r&&typeof r.isFile==`function`?r.isFile():!1}catch{return!1}}function _(e){if(e.env.OK_FORCE_BROWSER===`1`)return{available:!1,reason:`force-browser`};if(e.platform!==`darwin`)return{available:!1,reason:`darwin-only`};let t;try{t=h(e)}catch{return{available:!1,reason:`stat-error`}}return t?e.env.OK_FORCE_DESKTOP===`1`?{available:!0,reason:`available`,bundlePath:t}:e.isTTY!==!0||e.env.SSH_CONNECTION||e.env.SSH_TTY?{available:!1,reason:`headless`,bundlePath:t}:{available:!0,reason:`available`,bundlePath:t}:{available:!1,reason:`no-bundle`}}function v(e){(e.log??(e=>console.error(e)))("Launching Open Knowledge desktop… (use `ok start` for the browser server, or `OK_FORCE_BROWSER=1` to always skip)"),e.spawn(`open`,[`-b`,`com.inkeep.open-knowledge`],{detached:!0,stdio:`ignore`}).unref()}function y(e=`no-bundle`){switch(e){case`no-bundle`:return`Desktop app not found at ${p}. Install via DMG, or omit --mode for browser mode.`;case`darwin-only`:return`Desktop app is macOS-only on this release. Use --mode=browser, or omit --mode for the server fallback.`;case`headless`:return`Desktop launch is gated in headless contexts (CI, SSH, non-TTY stdout). Set OK_FORCE_DESKTOP=1 to override, or use --mode=browser.`;case`force-browser`:return`OK_FORCE_BROWSER=1 is set — desktop dispatch is disabled. Unset it to use --mode=app.`;case`stat-error`:return`Failed to inspect desktop bundle at ${p} (filesystem error). Check permissions or use --mode=browser.`;case`available`:return`Desktop app appears available at ${p} but launch dispatch did not fire (caller bug).`}}function b(){let e=process.execPath,t=process.argv[1];return t?{command:e,prefixArgs:[t]}:(console.warn(`[self-spawn] process.argv[1] is empty — falling back to \`npx @inkeep/open-knowledge\`. This re-introduces the version-drift surface that re-exec was fixing. Observed argv: ${JSON.stringify(process.argv)}`),{command:`npx`,prefixArgs:[`@inkeep/open-knowledge`]})}function x(e,t){return e.host??t.HOST??`localhost`}var S=class extends Error{cwd;constructor(e){super("This directory isn't set up yet. Run `ok init` first, then `ok start` again."),this.name=`OkDirMissingError`,this.cwd=e}};function C(e){return e.uiLock?e.isAlive(e.uiLock.pid)?{action:`skip`,reason:`alive`,pid:e.uiLock.pid,port:e.uiLock.port}:{action:`spawn`,reason:`stale`,stalePid:e.uiLock.pid}:{action:`spawn`,reason:`absent`}}function w(e){o(e.lockDir)||s(e.lockDir,{recursive:!0});let t=c(i(e.lockDir,`last-spawn-error.log`),`w`),n=e.spawn??r,{PORT:l,...u}=process.env,d=b();try{let r=n(d.command,[...d.prefixArgs,...e.args??[`ui`]],{detached:!0,stdio:[`ignore`,`ignore`,t],cwd:e.cwd,env:u});return r.unref(),r}finally{try{a(t)}catch{}}}async function T(e){let t=e.now()+e.timeoutMs;for(;e.now()<t;){let t=e.readUiLock();if(t&&t.port>0)return t.port;await e.sleep(e.pollIntervalMs)}let n=e.readUiLock();return n&&n.port>0?n.port:null}function E(e){let t=e.sigtermGraceMs??1e4,n=e.sigtermPollIntervalMs??200,r=e.sleep??(e=>d(e));return async()=>{try{let i=e.readUiLock();if(i&&e.isAlive(i.pid))try{e.killPid(i.pid,`SIGTERM`),e.log?.info({pid:i.pid,port:i.port},`idle-shutdown: SIGTERM UI sibling`);let a=Date.now()+t;for(;Date.now()<a&&e.isAlive(i.pid);)await r(n);if(e.isAlive(i.pid))try{e.killPid(i.pid,`SIGKILL`),e.log?.warn({pid:i.pid,graceMs:t},`idle-shutdown: SIGTERM grace expired — escalated to SIGKILL`)}catch(t){e.log?.error({pid:i.pid,err:t instanceof Error?t.message:String(t)},`idle-shutdown: SIGKILL failed`)}}catch(t){e.log?.warn({pid:i.pid,err:t instanceof Error?t.message:String(t)},`idle-shutdown: failed to SIGTERM UI sibling`)}}catch(t){e.log?.warn({err:t instanceof Error?t.message:String(t)},`idle-shutdown: UI lookup failed; proceeding with destroy`)}await e.destroy()}}async function D(e){let{config:t,cwd:n,host:r}=e,i=e.skipAutoInit??!1,a=e.skipUiAutoSpawn??!1,o=e.idleThresholdMs??18e5,{existsSync:s,mkdirSync:c}=await import(`node:fs`),{resolve:l}=await import(`node:path`),{bootServer:u,getLogger:f,isProcessAlive:p,readUiLock:m,resolveContentDir:h}=await import(`./dist-BXmbRKLs.mjs`),g=e.log??f(`start`),_=l(n,`.ok`);if(!i&&!s(_))throw new S(n);let v=h(t,n);s(v)||(c(v,{recursive:!0}),g.info({contentDir:v},`Created content directory`));let y=null,b=await u({config:t,contentDir:v,projectDir:n,contentRoot:t.content.dir,port:e.port,host:r,quiet:!1,localOpCliArgs:[process.execPath,process.argv[1]],attachUiSibling:!0,idleShutdownMs:o,skipAutoInit:!0,spawnUiSiblingFn:async({lockDir:t})=>{if(y=C({uiLock:m(t),isAlive:p}),y.action===`spawn`&&!a)try{w({lockDir:t,cwd:n,spawn:e.spawn}),g.info({reason:y.reason},`[start] auto-spawned ok ui sibling`)}catch(e){console.warn(`[start] failed to auto-spawn ok ui: ${e instanceof Error?e.message:String(e)}`)}else y.action===`skip`&&g.info({port:y.port,pid:y.pid},`UI already running at port ${y.port}`)},idleShutdownHandler:e=>E({readUiLock:()=>m(b.lockDir),isAlive:p,killPid:(e,t)=>{process.kill(e,t)},destroy:e,log:g}),log:g});y||={action:`skip`,reason:`alive`,pid:0,port:0};let x=y,D=null;if(x.action===`skip`)D=x.port>0?x.port:null;else if(!a){let t=e.uiBindTimeoutMs??3e3;D=await T({readUiLock:()=>m(b.lockDir),now:Date.now,sleep:e=>d(e),timeoutMs:t,pollIntervalMs:50}),D===null&&g.warn({timeoutMs:t},`[start] ok ui did not bind within timeout — banner falls back to API URL`)}return{httpServer:b.httpServer,destroy:b.destroy,lockDir:b.lockDir,contentDir:v,port:b.port,ready:b.ready,degraded:b.degraded,uiSpawnDecision:y,resolvedUiPort:D}}function O(t){if(t===`browser`||t===`app`)return t;throw new e(`--mode must be 'browser' or 'app'`)}async function k(e,t){let{renderBanner:r}=await import(`./banner-8cQrR88n.mjs`),{dim:i,error:a,warning:o}=await import(`./colors-BCE2jNgl.mjs`),s=process.cwd(),c=e,l=x(t,process.env),u=t.port===void 0?void 0:Number(t.port),d=process.env.PORT?Number(process.env.PORT):void 0,f=u??d,p;try{p=await D({config:c,cwd:s,host:l,port:f})}catch(e){e instanceof S&&(console.error(a(e.message)),process.exit(1));let t=A(e,s,await import(`./dist-BXmbRKLs.mjs`));t!==null&&(console.error(a(t)),process.exit(1)),console.error(`${a(`Failed to start:`)} ${e instanceof Error?e.stack??e.message:String(e)}`),process.exit(1)}let m=!1,h=async e=>{if(!m){m=!0,console.log(i(`\nShutting down (${e})...`));try{await p.destroy()}catch(e){console.error(`${a(`destroy() failed:`)} ${e instanceof Error?e.stack??e.message:String(e)}`),process.exitCode=1}process.exit(process.exitCode??0)}};process.once(`SIGINT`,()=>{h(`SIGINT`)}),process.once(`SIGTERM`,()=>{h(`SIGTERM`)});let g=`http://${l}:${p.port}`,_=l===`0.0.0.0`||l===`::`?`http://0.0.0.0:${p.port}`:void 0,v=p.resolvedUiPort,y=v!==null&&v>0?`http://${l}:${v}`:g;console.log(r({name:`open-knowledge`,version:n,localUrl:y,apiUrl:y===g?void 0:g,networkUrl:_}));let b={"shadow-repo":`Version history and branch-switch safety unavailable`,"file-watcher":`External file changes will not sync to the editor`,"head-watcher":`Git branch switches may cause document inconsistency`};p.ready.then(async()=>{if(p.degraded.length>0){console.log();for(let e of p.degraded){let t=b[e]??`${e} (check server logs for details)`;console.warn(` ${o(`⚠`)} ${o(e)}: ${i(t)}`)}console.log()}if(t.open){let{openBrowser:e}=await import(`./open-browser-BOeCxs2W.mjs`);e(y)}}).catch(e=>{console.error(` ${a(`Server initialization failed:`)} ${e instanceof Error?e.message:String(e)}`)})}function A(e,t,n){let r=n.ServerLockCollisionError;if(r===void 0||!(e instanceof r))return null;try{let e=i(t,`.ok`),r=n.readServerLock(e);return r?r.kind===`interactive`?`Open Knowledge desktop is currently running on this project. Quit it or use --cwd to point elsewhere.`:r.kind===`mcp-spawned`?"An MCP-spawned server holds this lock; it should release on idle-shutdown (~30 min). Or run `ok stop`.":"Open Knowledge server is already running on this project — check `ok status` or `ok stop`.":"Open Knowledge server is already running on this project — check `ok status` or `ok stop`."}catch{return null}}function j(e){return new t(`start`).description(`Start the knowledge base collab server`).option(`-p, --port <port>`,`Server port`,void 0).option(`-H, --host <host>`,`Server host`,void 0).option(`--open`,`Open browser after start`).option(`--mode <mode>`,`Force dispatch mode: 'browser' or 'app'`,O).action(async t=>{let n=e();if(t.mode===`app`){t.open&&(process.stderr.write(`error: option '--mode=app' cannot be combined with '--open' (--open opens a browser tab against the local server, which app mode does not boot)
|
|
2
2
|
`),process.exit(2));let e=[];if(t.port!==void 0&&e.push(`--port`),t.host!==void 0&&e.push(`--host`),e.length>0){let t=process.env.OK_LOG_LEVEL??`info`;(t===`debug`||t===`trace`)&&console.error(`--mode=app: ignoring ${e.join(`, `)}`)}let n=_(m());if(n.available){v({spawn:r});return}console.error(y(n.reason)),process.exit(1)}await k(n,t)})}export{C as a,w as c,b as d,m as f,E as i,j as l,v as m,T as n,x as o,_ as p,D as r,k as s,S as t,A as u};
|
|
3
|
-
//# sourceMappingURL=start-
|
|
3
|
+
//# sourceMappingURL=start-D__quKIc.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{l as e}from"./start-D__quKIc.mjs";export{e as startCommand};
|
package/package.json
CHANGED
package/dist/init-CFMa0dvy.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{o as e}from"./init-JGxedyCK.mjs";export{e as runInit};
|
package/dist/loader-DwwnYa3l.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{n as e}from"./loader-CqNnLnr8.mjs";export{e as loadConfig};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{n as e,t}from"./preview-DTGBU5TT.mjs";export{t as formatPreviewBlock,e as previewContent};
|