@inkeep/open-knowledge 0.6.0-beta.6 → 0.6.0-beta.8
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/discovery/SKILL.md +1 -1
- package/dist/assets/skills/project/SKILL.md +1 -1
- package/dist/cli.mjs +10 -10
- package/dist/constants-HL-7SyJ2.mjs +2 -0
- package/dist/index.d.mts +15 -9
- package/dist/index.mjs +1 -1
- package/dist/init-BtOr-X4H.mjs +1 -0
- package/dist/{init-DMpZzyPQ.mjs → init-al09RZM6.mjs} +8 -8
- package/dist/{loader-2OdJfRxG.mjs → loader-B64XEbbD.mjs} +2 -2
- package/dist/loader-BGK5A8F9.mjs +1 -0
- package/dist/{preview-CVpbjLGm.mjs → preview-CYIUoqRn.mjs} +2 -2
- package/dist/preview-DZKfHXsi.mjs +1 -0
- package/dist/public/assets/SettingsDialogBody-E4CxiCsR.js +7 -0
- package/dist/public/assets/config-validation-events-BAWD3yoI.js +10 -0
- package/dist/public/assets/{index-DMINOczF.js → index-DrLQYAlB.js} +5 -7
- package/dist/public/index.html +2 -2
- package/dist/{repair-launch-json-BfO8g0C9.mjs → repair-launch-json-CKIaPf4Q.mjs} +2 -2
- package/dist/{repair-mcp-configs-DhvDQUcW.mjs → repair-mcp-configs-nHEH7ZXG.mjs} +2 -2
- package/dist/src-DJUgVPb0.mjs +2 -0
- package/dist/{start-Bscs6Im4.mjs → start-B0qxkaI0.mjs} +2 -2
- package/dist/start-BS3czGsk.mjs +1 -0
- package/package.json +1 -1
- package/dist/constants-COv1QTl7.mjs +0 -2
- package/dist/init-DZBi-cEQ.mjs +0 -1
- package/dist/loader-xYG3UrFw.mjs +0 -1
- package/dist/preview-DeihrKlb.mjs +0 -1
- package/dist/public/assets/SettingsDialogBody-Dr2p2Reu.js +0 -11
- package/dist/public/assets/config-validation-events-CXyf_fVy.js +0 -10
- package/dist/src-B5o3ciyJ.mjs +0 -2
- package/dist/start-DGxYOlJ8.mjs +0 -1
package/dist/index.d.mts
CHANGED
|
@@ -139,6 +139,16 @@ interface ParsedGitHubBlobUrl {
|
|
|
139
139
|
declare function parseGitUrl(input: string): ParsedGitUrl | null;
|
|
140
140
|
declare function parseGitHubBlobUrl(input: string): ParsedGitHubBlobUrl | null;
|
|
141
141
|
//#endregion
|
|
142
|
+
//#region src/integrations/project-integration-writers.d.ts
|
|
143
|
+
type IntegrationId = 'mcp-config' | 'project-skill';
|
|
144
|
+
interface IntegrationWriteOutcome {
|
|
145
|
+
readonly integration: IntegrationId;
|
|
146
|
+
readonly editorId: EditorId;
|
|
147
|
+
readonly action: 'written' | 'overwritten' | 'skipped-unsupported' | 'failed';
|
|
148
|
+
readonly path?: string;
|
|
149
|
+
readonly error?: string;
|
|
150
|
+
}
|
|
151
|
+
//#endregion
|
|
142
152
|
//#region src/integrations/resolve-project-root.d.ts
|
|
143
153
|
interface ResolveProjectRootResult {
|
|
144
154
|
/** Where `.ok/` lives or will live. Equals `realpath(cwd)` when no
|
|
@@ -168,19 +178,15 @@ interface ResolveProjectRootOptions {
|
|
|
168
178
|
declare function resolveProjectRoot(cwd: string, opts?: ResolveProjectRootOptions): ResolveProjectRootResult;
|
|
169
179
|
//#endregion
|
|
170
180
|
//#region src/integrations/write-project-ai-integrations.d.ts
|
|
171
|
-
type ProjectAiIntegrationOutcome = 'written' | 'overwritten' | 'failed' | 'skipped-no-project-surface';
|
|
172
|
-
interface ProjectAiEditorOutcome {
|
|
173
|
-
readonly editorId: EditorId;
|
|
174
|
-
readonly outcome: ProjectAiIntegrationOutcome;
|
|
175
|
-
readonly error?: string;
|
|
176
|
-
}
|
|
177
181
|
interface ProjectAiIntegrationsResult {
|
|
178
|
-
|
|
182
|
+
/** Per-(editor × integration) outcomes — MCP config and the project-local
|
|
183
|
+
* runtime skill for every selected editor. */
|
|
184
|
+
readonly integrations: IntegrationWriteOutcome[];
|
|
179
185
|
/** Result of `<projectDir>/.claude/launch.json` scaffolding; present iff
|
|
180
|
-
*
|
|
186
|
+
* `'claude'` was in `selectedEditorIds`. */
|
|
181
187
|
readonly claudeLaunchJson?: LaunchJsonResult;
|
|
182
188
|
}
|
|
183
189
|
declare function writeProjectAiIntegrations(projectDir: string, selectedEditorIds: readonly EditorId[], installOptions?: McpInstallOptions): ProjectAiIntegrationsResult;
|
|
184
190
|
//#endregion
|
|
185
|
-
export { ALL_EDITOR_IDS, EDITOR_LABELS, EDITOR_TARGETS, type EditorId, type EditorMcpResult, type EditorMcpTarget, type ExpectedShareRepo, LAUNCH_CONFIG_NAME, type LaunchJsonResult, type LoadConfigResult, type McpEntryClassification, type McpInstallOptions, type ParsedGitHubBlobUrl, type PreviewResult, type
|
|
191
|
+
export { ALL_EDITOR_IDS, EDITOR_LABELS, EDITOR_TARGETS, type EditorId, type EditorMcpResult, type EditorMcpTarget, type ExpectedShareRepo, type IntegrationWriteOutcome, LAUNCH_CONFIG_NAME, type LaunchJsonResult, type LoadConfigResult, type McpEntryClassification, type McpInstallOptions, type ParsedGitHubBlobUrl, type PreviewResult, type ProjectAiIntegrationsResult, type ResolveProjectRootOptions, type ResolveProjectRootResult, type ShareFolderValidationResult, type UserMcpConfigsOptions, classifyExistingMcpEntry, detectInstalledEditors, initContent, loadConfig, parseGitHubBlobUrl, parseGitUrl, previewContent, readExistingMcpEntry, resolveProjectRoot, scaffoldLaunchJson, validateLocalFolderForShare, writeEditorMcpConfig, writeProjectAiIntegrations, writeUserMcpConfigs };
|
|
186
192
|
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{b as e,d as t,f as n,g as r,h as i,i as a,m as o,r as s,s as c,t as l,u,y as d}from"./init-al09RZM6.mjs";import{i as f,n as p,r as m,t as h}from"./src-DJUgVPb0.mjs";import{n as g}from"./loader-B64XEbbD.mjs";import{n as _}from"./preview-CYIUoqRn.mjs";export{o as ALL_EDITOR_IDS,i as EDITOR_LABELS,r as EDITOR_TARGETS,l as LAUNCH_CONFIG_NAME,s as classifyExistingMcpEntry,a as detectInstalledEditors,e as initContent,g as loadConfig,m as parseGitHubBlobUrl,f as parseGitUrl,_ as previewContent,c as readExistingMcpEntry,d as resolveProjectRoot,u as scaffoldLaunchJson,p as validateLocalFolderForShare,t as writeEditorMcpConfig,h as writeProjectAiIntegrations,n as writeUserMcpConfigs};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{l as e}from"./init-al09RZM6.mjs";export{e as runInit};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{i as e,o as t,t as n}from"./chunk-FK9Q3tQk.mjs";import{r,t as i}from"./esm-CEs3LWY3.mjs";import{$r as a,D as o,N as s,Nt as c,Qr as l,Un as u,ai as d,an as f,di as p,fn as m,gi as h,hi as g,ii as _,in as v,jt as y,ln as b,ri as x,rn as S,si as C}from"./dist-soQLoIV1.mjs";import{n as ee,t as te}from"./constants-COv1QTl7.mjs";import{t as w}from"./is-object-C-4FJ0rP.mjs";import{i as T,o as E,r as ne,s as D,t as O}from"./colors-BtKMHmBX.mjs";import{t as re}from"./preview-CVpbjLGm.mjs";import{execFileSync as ie}from"node:child_process";import ae,{basename as oe,dirname as k,isAbsolute as A,join as j,posix as M,relative as N,resolve as P,sep as F,win32 as I}from"node:path";import{cpSync as se,existsSync as L,lstatSync as ce,mkdirSync as R,readFileSync as z,realpathSync as le,rmSync as ue,writeFileSync as B}from"node:fs";import V from"node:process";import{homedir as H}from"node:os";import{AsyncLocalStorage as de,AsyncResource as fe}from"node:async_hooks";import{stripVTControlCharacters as pe,styleText as U}from"node:util";import*as me from"node:readline";import{randomUUID as he}from"node:crypto";import{createServer as ge,request as _e}from"node:http";import{connect as ve}from"node:net";function ye(){return V.platform.startsWith(`win`)?!!V.env.CI||!!V.env.WT_SESSION||!!V.env.TERMINUS_SUBLIME||V.env.ConEmuTask===`{cmd::Cmder}`||V.env.TERM_PROGRAM===`Terminus-Sublime`||V.env.TERM_PROGRAM===`vscode`||V.env.TERM===`xterm-256color`||V.env.TERM===`alacritty`||V.env.TERMINAL_EMULATOR===`JetBrains-JediTerm`:V.env.TERM!==`linux`}const be={circleQuestionMark:`(?)`,questionMarkPrefix:`(?)`,square:`█`,squareDarkShade:`▓`,squareMediumShade:`▒`,squareLightShade:`░`,squareTop:`▀`,squareBottom:`▄`,squareLeft:`▌`,squareRight:`▐`,squareCenter:`■`,bullet:`●`,dot:`․`,ellipsis:`…`,pointerSmall:`›`,triangleUp:`▲`,triangleUpSmall:`▴`,triangleDown:`▼`,triangleDownSmall:`▾`,triangleLeftSmall:`◂`,triangleRightSmall:`▸`,home:`⌂`,heart:`♥`,musicNote:`♪`,musicNoteBeamed:`♫`,arrowUp:`↑`,arrowDown:`↓`,arrowLeft:`←`,arrowRight:`→`,arrowLeftRight:`↔`,arrowUpDown:`↕`,almostEqual:`≈`,notEqual:`≠`,lessOrEqual:`≤`,greaterOrEqual:`≥`,identical:`≡`,infinity:`∞`,subscriptZero:`₀`,subscriptOne:`₁`,subscriptTwo:`₂`,subscriptThree:`₃`,subscriptFour:`₄`,subscriptFive:`₅`,subscriptSix:`₆`,subscriptSeven:`₇`,subscriptEight:`₈`,subscriptNine:`₉`,oneHalf:`½`,oneThird:`⅓`,oneQuarter:`¼`,oneFifth:`⅕`,oneSixth:`⅙`,oneEighth:`⅛`,twoThirds:`⅔`,twoFifths:`⅖`,threeQuarters:`¾`,threeFifths:`⅗`,threeEighths:`⅜`,fourFifths:`⅘`,fiveSixths:`⅚`,fiveEighths:`⅝`,sevenEighths:`⅞`,line:`─`,lineBold:`━`,lineDouble:`═`,lineDashed0:`┄`,lineDashed1:`┅`,lineDashed2:`┈`,lineDashed3:`┉`,lineDashed4:`╌`,lineDashed5:`╍`,lineDashed6:`╴`,lineDashed7:`╶`,lineDashed8:`╸`,lineDashed9:`╺`,lineDashed10:`╼`,lineDashed11:`╾`,lineDashed12:`−`,lineDashed13:`–`,lineDashed14:`‐`,lineDashed15:`⁃`,lineVertical:`│`,lineVerticalBold:`┃`,lineVerticalDouble:`║`,lineVerticalDashed0:`┆`,lineVerticalDashed1:`┇`,lineVerticalDashed2:`┊`,lineVerticalDashed3:`┋`,lineVerticalDashed4:`╎`,lineVerticalDashed5:`╏`,lineVerticalDashed6:`╵`,lineVerticalDashed7:`╷`,lineVerticalDashed8:`╹`,lineVerticalDashed9:`╻`,lineVerticalDashed10:`╽`,lineVerticalDashed11:`╿`,lineDownLeft:`┐`,lineDownLeftArc:`╮`,lineDownBoldLeftBold:`┓`,lineDownBoldLeft:`┒`,lineDownLeftBold:`┑`,lineDownDoubleLeftDouble:`╗`,lineDownDoubleLeft:`╖`,lineDownLeftDouble:`╕`,lineDownRight:`┌`,lineDownRightArc:`╭`,lineDownBoldRightBold:`┏`,lineDownBoldRight:`┎`,lineDownRightBold:`┍`,lineDownDoubleRightDouble:`╔`,lineDownDoubleRight:`╓`,lineDownRightDouble:`╒`,lineUpLeft:`┘`,lineUpLeftArc:`╯`,lineUpBoldLeftBold:`┛`,lineUpBoldLeft:`┚`,lineUpLeftBold:`┙`,lineUpDoubleLeftDouble:`╝`,lineUpDoubleLeft:`╜`,lineUpLeftDouble:`╛`,lineUpRight:`└`,lineUpRightArc:`╰`,lineUpBoldRightBold:`┗`,lineUpBoldRight:`┖`,lineUpRightBold:`┕`,lineUpDoubleRightDouble:`╚`,lineUpDoubleRight:`╙`,lineUpRightDouble:`╘`,lineUpDownLeft:`┤`,lineUpBoldDownBoldLeftBold:`┫`,lineUpBoldDownBoldLeft:`┨`,lineUpDownLeftBold:`┥`,lineUpBoldDownLeftBold:`┩`,lineUpDownBoldLeftBold:`┪`,lineUpDownBoldLeft:`┧`,lineUpBoldDownLeft:`┦`,lineUpDoubleDownDoubleLeftDouble:`╣`,lineUpDoubleDownDoubleLeft:`╢`,lineUpDownLeftDouble:`╡`,lineUpDownRight:`├`,lineUpBoldDownBoldRightBold:`┣`,lineUpBoldDownBoldRight:`┠`,lineUpDownRightBold:`┝`,lineUpBoldDownRightBold:`┡`,lineUpDownBoldRightBold:`┢`,lineUpDownBoldRight:`┟`,lineUpBoldDownRight:`┞`,lineUpDoubleDownDoubleRightDouble:`╠`,lineUpDoubleDownDoubleRight:`╟`,lineUpDownRightDouble:`╞`,lineDownLeftRight:`┬`,lineDownBoldLeftBoldRightBold:`┳`,lineDownLeftBoldRightBold:`┯`,lineDownBoldLeftRight:`┰`,lineDownBoldLeftBoldRight:`┱`,lineDownBoldLeftRightBold:`┲`,lineDownLeftRightBold:`┮`,lineDownLeftBoldRight:`┭`,lineDownDoubleLeftDoubleRightDouble:`╦`,lineDownDoubleLeftRight:`╥`,lineDownLeftDoubleRightDouble:`╤`,lineUpLeftRight:`┴`,lineUpBoldLeftBoldRightBold:`┻`,lineUpLeftBoldRightBold:`┷`,lineUpBoldLeftRight:`┸`,lineUpBoldLeftBoldRight:`┹`,lineUpBoldLeftRightBold:`┺`,lineUpLeftRightBold:`┶`,lineUpLeftBoldRight:`┵`,lineUpDoubleLeftDoubleRightDouble:`╩`,lineUpDoubleLeftRight:`╨`,lineUpLeftDoubleRightDouble:`╧`,lineUpDownLeftRight:`┼`,lineUpBoldDownBoldLeftBoldRightBold:`╋`,lineUpDownBoldLeftBoldRightBold:`╈`,lineUpBoldDownLeftBoldRightBold:`╇`,lineUpBoldDownBoldLeftRightBold:`╊`,lineUpBoldDownBoldLeftBoldRight:`╉`,lineUpBoldDownLeftRight:`╀`,lineUpDownBoldLeftRight:`╁`,lineUpDownLeftBoldRight:`┽`,lineUpDownLeftRightBold:`┾`,lineUpBoldDownBoldLeftRight:`╂`,lineUpDownLeftBoldRightBold:`┿`,lineUpBoldDownLeftBoldRight:`╃`,lineUpBoldDownLeftRightBold:`╄`,lineUpDownBoldLeftBoldRight:`╅`,lineUpDownBoldLeftRightBold:`╆`,lineUpDoubleDownDoubleLeftDoubleRightDouble:`╬`,lineUpDoubleDownDoubleLeftRight:`╫`,lineUpDownLeftDoubleRightDouble:`╪`,lineCross:`╳`,lineBackslash:`╲`,lineSlash:`╱`},xe={tick:`✔`,info:`ℹ`,warning:`⚠`,cross:`✘`,squareSmall:`◻`,squareSmallFilled:`◼`,circle:`◯`,circleFilled:`◉`,circleDotted:`◌`,circleDouble:`◎`,circleCircle:`ⓞ`,circleCross:`ⓧ`,circlePipe:`Ⓘ`,radioOn:`◉`,radioOff:`◯`,checkboxOn:`☒`,checkboxOff:`☐`,checkboxCircleOn:`ⓧ`,checkboxCircleOff:`Ⓘ`,pointer:`❯`,triangleUpOutline:`△`,triangleLeft:`◀`,triangleRight:`▶`,lozenge:`◆`,lozengeOutline:`◇`,hamburger:`☰`,smiley:`㋡`,mustache:`෴`,star:`★`,play:`▶`,nodejs:`⬢`,oneSeventh:`⅐`,oneNinth:`⅑`,oneTenth:`⅒`},Se={tick:`√`,info:`i`,warning:`‼`,cross:`×`,squareSmall:`□`,squareSmallFilled:`■`,circle:`( )`,circleFilled:`(*)`,circleDotted:`( )`,circleDouble:`( )`,circleCircle:`(○)`,circleCross:`(×)`,circlePipe:`(│)`,radioOn:`(*)`,radioOff:`( )`,checkboxOn:`[×]`,checkboxOff:`[ ]`,checkboxCircleOn:`(×)`,checkboxCircleOff:`( )`,pointer:`>`,triangleUpOutline:`∆`,triangleLeft:`◄`,triangleRight:`►`,lozenge:`♦`,lozengeOutline:`◊`,hamburger:`≡`,smiley:`☺`,mustache:`┌─┐`,star:`✶`,play:`►`,nodejs:`♦`,oneSeventh:`1/7`,oneNinth:`1/9`,oneTenth:`1/10`},Ce={...be,...xe},we={...be,...Se},W=ye()?Ce:we;Object.entries(xe);var Te=n(((t,n)=>{n.exports=i;function r(t){let n={defaultWidth:0,output:process.stdout,tty:e(`tty`)};return t?(Object.keys(n).forEach(function(e){t[e]||(t[e]=n[e])}),t):n}function i(e){let t=r(e);if(t.output.getWindowSize)return t.output.getWindowSize()[0]||t.defaultWidth;if(t.tty.getWindowSize)return t.tty.getWindowSize()[1]||t.defaultWidth;if(t.output.columns)return t.output.columns;if(process.env.CLI_WIDTH){let e=parseInt(process.env.CLI_WIDTH,10);if(!isNaN(e)&&e!==0)return e}return t.defaultWidth}}));const Ee=(()=>{let e=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g;return t=>{let n=0;for(e.lastIndex=0;e.test(t);)n+=1;return t.length-n}})(),De=e=>e===12288||e>=65281&&e<=65376||e>=65504&&e<=65510,Oe=e=>e===8987||e===9001||e>=12272&&e<=12287||e>=12289&&e<=12350||e>=12441&&e<=12543||e>=12549&&e<=12591||e>=12593&&e<=12686||e>=12688&&e<=12771||e>=12783&&e<=12830||e>=12832&&e<=12871||e>=12880&&e<=19903||e>=65040&&e<=65049||e>=65072&&e<=65106||e>=65108&&e<=65126||e>=65128&&e<=65131||e>=127488&&e<=127490||e>=127504&&e<=127547||e>=127552&&e<=127560||e>=131072&&e<=196605||e>=196608&&e<=262141,ke=/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]|\u001b\]8;[^;]*;.*?(?:\u0007|\u001b\u005c)/y,Ae=/[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y,je=/(?:(?![\uFF61-\uFF9F\uFF00-\uFFEF])[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}\p{Script=Tangut}]){1,1000}/uy,Me=/\t{1,1000}/y,Ne=/[\u{1F1E6}-\u{1F1FF}]{2}|\u{1F3F4}[\u{E0061}-\u{E007A}]{2}[\u{E0030}-\u{E0039}\u{E0061}-\u{E007A}]{1,3}\u{E007F}|(?:\p{Emoji}\uFE0F\u20E3?|\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation})(?:\u200D(?:\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation}|\p{Emoji}\uFE0F\u20E3?))*/uy,Pe=/(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y,Fe=/\p{M}+/gu,Ie={limit:1/0,ellipsis:``},Le=(e,t={},n={})=>{let r=t.limit??1/0,i=t.ellipsis??``,a=t?.ellipsisWidth??(i?Le(i,Ie,n).width:0),o=n.controlWidth??0,s=n.tabWidth??8,c=n.emojiWidth??2,l=n.regularWidth??1,u=n.wideWidth??2,d=[[Pe,l],[ke,0],[Ae,o],[Me,s],[Ne,c],[je,u]],f=0,p=0,m=e.length,h=0,g=!1,_=m,v=Math.max(0,r-a),y=0,b=0,x=0,S=0;outer:for(;;){if(b>y||p>=m&&p>f){let t=e.slice(y,b)||e.slice(f,p);h=0;for(let e of t.replaceAll(Fe,``)){let t=e.codePointAt(0)||0;if(S=De(t)?2:Oe(t)?u:l,x+S>v&&(_=Math.min(_,Math.max(y,f)+h)),x+S>r){g=!0;break outer}h+=e.length,x+=S}y=b=0}if(p>=m)break outer;for(let t=0,n=d.length;t<n;t++){let[n,i]=d[t];if(n.lastIndex=p,n.test(e)){if(h=n===je?Ee(e.slice(p,n.lastIndex)):n===Ne?1:n.lastIndex-p,S=h*i,x+S>v&&(_=Math.min(_,p+Math.floor((v-x)/i))),x+S>r){g=!0;break outer}x+=S,y=f,b=p,p=f=n.lastIndex;continue outer}}p+=1}return{width:g?v:x,index:g?_:m,truncated:g,ellipsed:g&&r>=a}},Re={limit:1/0,ellipsis:``,ellipsisWidth:0},G=(e,t={})=>Le(e,Re,t).width,ze=`]8;;`,Be=RegExp(`(?:\\[(?<code>\\d+)m|\\${ze}(?<uri>.*))`,`y`),Ve=e=>{if(e>=30&&e<=37||e>=90&&e<=97)return 39;if(e>=40&&e<=47||e>=100&&e<=107)return 49;if(e===1||e===2)return 22;if(e===3)return 23;if(e===4)return 24;if(e===7)return 27;if(e===8)return 28;if(e===9)return 29;if(e===0)return 0},He=e=>`[${e}m`,Ue=e=>`${ze}${e}`,We=(e,t,n)=>{let r=t[Symbol.iterator](),i=!1,a=!1,o=e.at(-1),s=o===void 0?0:G(o),c=r.next(),l=r.next(),u=0;for(;!c.done;){let o=c.value,d=G(o);s+d<=n?e[e.length-1]+=o:(e.push(o),s=0),(o===`\x1B`||o===``)&&(i=!0,a=t.startsWith(ze,u+1)),i?a?o===`\x07`&&(i=!1,a=!1):o===`m`&&(i=!1):(s+=d,s===n&&!l.done&&(e.push(``),s=0)),c=l,l=r.next(),u+=o.length}o=e.at(-1),!s&&o!==void 0&&o.length&&e.length>1&&(e[e.length-2]+=e.pop())},Ge=e=>{let t=e.split(` `),n=t.length;for(;n&&!G(t[n-1]);)n--;return n===t.length?e:t.slice(0,n).join(` `)+t.slice(n).join(``)},Ke=(e,t,n={})=>{if(n.trim!==!1&&e.trim()===``)return``;let r=``,i,a,o=e.split(` `),s=[``],c=0;for(let e=0;e<o.length;e++){let r=o[e];if(n.trim!==!1){let e=s.at(-1)??``,t=e.trimStart();e.length!==t.length&&(s[s.length-1]=t,c=G(t))}e!==0&&(c>=t&&(n.wordWrap===!1||n.trim===!1)&&(s.push(``),c=0),(c||n.trim===!1)&&(s[s.length-1]+=` `,c++));let i=G(r);if(n.hard&&i>t){let e=t-c,n=1+Math.floor((i-e-1)/t);Math.floor((i-1)/t)<n&&s.push(``),We(s,r,t),c=G(s.at(-1)??``);continue}if(c+i>t&&c&&i){if(n.wordWrap===!1&&c<t){We(s,r,t),c=G(s.at(-1)??``);continue}s.push(``),c=0}if(c+i>t&&n.wordWrap===!1){We(s,r,t),c=G(s.at(-1)??``);continue}s[s.length-1]+=r,c+=i}n.trim!==!1&&(s=s.map(e=>Ge(e)));let l=s.join(`
|
|
1
|
+
import{i as e,o as t,t as n}from"./chunk-FK9Q3tQk.mjs";import{r,t as i}from"./esm-CEs3LWY3.mjs";import{$r as a,D as o,N as s,Nt as c,Qr as l,Un as u,ai as d,an as f,di as p,fn as m,gi as h,hi as g,ii as _,in as v,jt as y,ln as b,ri as x,rn as S,si as C}from"./dist-soQLoIV1.mjs";import{n as ee,t as te}from"./constants-HL-7SyJ2.mjs";import{t as w}from"./is-object-C-4FJ0rP.mjs";import{i as T,o as E,r as ne,s as D,t as O}from"./colors-BtKMHmBX.mjs";import{t as re}from"./preview-CYIUoqRn.mjs";import{execFileSync as ie}from"node:child_process";import ae,{basename as oe,dirname as k,isAbsolute as A,join as j,posix as M,relative as N,resolve as P,sep as F,win32 as I}from"node:path";import{cpSync as se,existsSync as L,lstatSync as ce,mkdirSync as R,readFileSync as z,realpathSync as le,rmSync as ue,writeFileSync as B}from"node:fs";import V from"node:process";import{homedir as H}from"node:os";import{AsyncLocalStorage as de,AsyncResource as fe}from"node:async_hooks";import{stripVTControlCharacters as pe,styleText as U}from"node:util";import*as me from"node:readline";import{randomUUID as he}from"node:crypto";import{createServer as ge,request as _e}from"node:http";import{connect as ve}from"node:net";function ye(){return V.platform.startsWith(`win`)?!!V.env.CI||!!V.env.WT_SESSION||!!V.env.TERMINUS_SUBLIME||V.env.ConEmuTask===`{cmd::Cmder}`||V.env.TERM_PROGRAM===`Terminus-Sublime`||V.env.TERM_PROGRAM===`vscode`||V.env.TERM===`xterm-256color`||V.env.TERM===`alacritty`||V.env.TERMINAL_EMULATOR===`JetBrains-JediTerm`:V.env.TERM!==`linux`}const be={circleQuestionMark:`(?)`,questionMarkPrefix:`(?)`,square:`█`,squareDarkShade:`▓`,squareMediumShade:`▒`,squareLightShade:`░`,squareTop:`▀`,squareBottom:`▄`,squareLeft:`▌`,squareRight:`▐`,squareCenter:`■`,bullet:`●`,dot:`․`,ellipsis:`…`,pointerSmall:`›`,triangleUp:`▲`,triangleUpSmall:`▴`,triangleDown:`▼`,triangleDownSmall:`▾`,triangleLeftSmall:`◂`,triangleRightSmall:`▸`,home:`⌂`,heart:`♥`,musicNote:`♪`,musicNoteBeamed:`♫`,arrowUp:`↑`,arrowDown:`↓`,arrowLeft:`←`,arrowRight:`→`,arrowLeftRight:`↔`,arrowUpDown:`↕`,almostEqual:`≈`,notEqual:`≠`,lessOrEqual:`≤`,greaterOrEqual:`≥`,identical:`≡`,infinity:`∞`,subscriptZero:`₀`,subscriptOne:`₁`,subscriptTwo:`₂`,subscriptThree:`₃`,subscriptFour:`₄`,subscriptFive:`₅`,subscriptSix:`₆`,subscriptSeven:`₇`,subscriptEight:`₈`,subscriptNine:`₉`,oneHalf:`½`,oneThird:`⅓`,oneQuarter:`¼`,oneFifth:`⅕`,oneSixth:`⅙`,oneEighth:`⅛`,twoThirds:`⅔`,twoFifths:`⅖`,threeQuarters:`¾`,threeFifths:`⅗`,threeEighths:`⅜`,fourFifths:`⅘`,fiveSixths:`⅚`,fiveEighths:`⅝`,sevenEighths:`⅞`,line:`─`,lineBold:`━`,lineDouble:`═`,lineDashed0:`┄`,lineDashed1:`┅`,lineDashed2:`┈`,lineDashed3:`┉`,lineDashed4:`╌`,lineDashed5:`╍`,lineDashed6:`╴`,lineDashed7:`╶`,lineDashed8:`╸`,lineDashed9:`╺`,lineDashed10:`╼`,lineDashed11:`╾`,lineDashed12:`−`,lineDashed13:`–`,lineDashed14:`‐`,lineDashed15:`⁃`,lineVertical:`│`,lineVerticalBold:`┃`,lineVerticalDouble:`║`,lineVerticalDashed0:`┆`,lineVerticalDashed1:`┇`,lineVerticalDashed2:`┊`,lineVerticalDashed3:`┋`,lineVerticalDashed4:`╎`,lineVerticalDashed5:`╏`,lineVerticalDashed6:`╵`,lineVerticalDashed7:`╷`,lineVerticalDashed8:`╹`,lineVerticalDashed9:`╻`,lineVerticalDashed10:`╽`,lineVerticalDashed11:`╿`,lineDownLeft:`┐`,lineDownLeftArc:`╮`,lineDownBoldLeftBold:`┓`,lineDownBoldLeft:`┒`,lineDownLeftBold:`┑`,lineDownDoubleLeftDouble:`╗`,lineDownDoubleLeft:`╖`,lineDownLeftDouble:`╕`,lineDownRight:`┌`,lineDownRightArc:`╭`,lineDownBoldRightBold:`┏`,lineDownBoldRight:`┎`,lineDownRightBold:`┍`,lineDownDoubleRightDouble:`╔`,lineDownDoubleRight:`╓`,lineDownRightDouble:`╒`,lineUpLeft:`┘`,lineUpLeftArc:`╯`,lineUpBoldLeftBold:`┛`,lineUpBoldLeft:`┚`,lineUpLeftBold:`┙`,lineUpDoubleLeftDouble:`╝`,lineUpDoubleLeft:`╜`,lineUpLeftDouble:`╛`,lineUpRight:`└`,lineUpRightArc:`╰`,lineUpBoldRightBold:`┗`,lineUpBoldRight:`┖`,lineUpRightBold:`┕`,lineUpDoubleRightDouble:`╚`,lineUpDoubleRight:`╙`,lineUpRightDouble:`╘`,lineUpDownLeft:`┤`,lineUpBoldDownBoldLeftBold:`┫`,lineUpBoldDownBoldLeft:`┨`,lineUpDownLeftBold:`┥`,lineUpBoldDownLeftBold:`┩`,lineUpDownBoldLeftBold:`┪`,lineUpDownBoldLeft:`┧`,lineUpBoldDownLeft:`┦`,lineUpDoubleDownDoubleLeftDouble:`╣`,lineUpDoubleDownDoubleLeft:`╢`,lineUpDownLeftDouble:`╡`,lineUpDownRight:`├`,lineUpBoldDownBoldRightBold:`┣`,lineUpBoldDownBoldRight:`┠`,lineUpDownRightBold:`┝`,lineUpBoldDownRightBold:`┡`,lineUpDownBoldRightBold:`┢`,lineUpDownBoldRight:`┟`,lineUpBoldDownRight:`┞`,lineUpDoubleDownDoubleRightDouble:`╠`,lineUpDoubleDownDoubleRight:`╟`,lineUpDownRightDouble:`╞`,lineDownLeftRight:`┬`,lineDownBoldLeftBoldRightBold:`┳`,lineDownLeftBoldRightBold:`┯`,lineDownBoldLeftRight:`┰`,lineDownBoldLeftBoldRight:`┱`,lineDownBoldLeftRightBold:`┲`,lineDownLeftRightBold:`┮`,lineDownLeftBoldRight:`┭`,lineDownDoubleLeftDoubleRightDouble:`╦`,lineDownDoubleLeftRight:`╥`,lineDownLeftDoubleRightDouble:`╤`,lineUpLeftRight:`┴`,lineUpBoldLeftBoldRightBold:`┻`,lineUpLeftBoldRightBold:`┷`,lineUpBoldLeftRight:`┸`,lineUpBoldLeftBoldRight:`┹`,lineUpBoldLeftRightBold:`┺`,lineUpLeftRightBold:`┶`,lineUpLeftBoldRight:`┵`,lineUpDoubleLeftDoubleRightDouble:`╩`,lineUpDoubleLeftRight:`╨`,lineUpLeftDoubleRightDouble:`╧`,lineUpDownLeftRight:`┼`,lineUpBoldDownBoldLeftBoldRightBold:`╋`,lineUpDownBoldLeftBoldRightBold:`╈`,lineUpBoldDownLeftBoldRightBold:`╇`,lineUpBoldDownBoldLeftRightBold:`╊`,lineUpBoldDownBoldLeftBoldRight:`╉`,lineUpBoldDownLeftRight:`╀`,lineUpDownBoldLeftRight:`╁`,lineUpDownLeftBoldRight:`┽`,lineUpDownLeftRightBold:`┾`,lineUpBoldDownBoldLeftRight:`╂`,lineUpDownLeftBoldRightBold:`┿`,lineUpBoldDownLeftBoldRight:`╃`,lineUpBoldDownLeftRightBold:`╄`,lineUpDownBoldLeftBoldRight:`╅`,lineUpDownBoldLeftRightBold:`╆`,lineUpDoubleDownDoubleLeftDoubleRightDouble:`╬`,lineUpDoubleDownDoubleLeftRight:`╫`,lineUpDownLeftDoubleRightDouble:`╪`,lineCross:`╳`,lineBackslash:`╲`,lineSlash:`╱`},xe={tick:`✔`,info:`ℹ`,warning:`⚠`,cross:`✘`,squareSmall:`◻`,squareSmallFilled:`◼`,circle:`◯`,circleFilled:`◉`,circleDotted:`◌`,circleDouble:`◎`,circleCircle:`ⓞ`,circleCross:`ⓧ`,circlePipe:`Ⓘ`,radioOn:`◉`,radioOff:`◯`,checkboxOn:`☒`,checkboxOff:`☐`,checkboxCircleOn:`ⓧ`,checkboxCircleOff:`Ⓘ`,pointer:`❯`,triangleUpOutline:`△`,triangleLeft:`◀`,triangleRight:`▶`,lozenge:`◆`,lozengeOutline:`◇`,hamburger:`☰`,smiley:`㋡`,mustache:`෴`,star:`★`,play:`▶`,nodejs:`⬢`,oneSeventh:`⅐`,oneNinth:`⅑`,oneTenth:`⅒`},Se={tick:`√`,info:`i`,warning:`‼`,cross:`×`,squareSmall:`□`,squareSmallFilled:`■`,circle:`( )`,circleFilled:`(*)`,circleDotted:`( )`,circleDouble:`( )`,circleCircle:`(○)`,circleCross:`(×)`,circlePipe:`(│)`,radioOn:`(*)`,radioOff:`( )`,checkboxOn:`[×]`,checkboxOff:`[ ]`,checkboxCircleOn:`(×)`,checkboxCircleOff:`( )`,pointer:`>`,triangleUpOutline:`∆`,triangleLeft:`◄`,triangleRight:`►`,lozenge:`♦`,lozengeOutline:`◊`,hamburger:`≡`,smiley:`☺`,mustache:`┌─┐`,star:`✶`,play:`►`,nodejs:`♦`,oneSeventh:`1/7`,oneNinth:`1/9`,oneTenth:`1/10`},Ce={...be,...xe},we={...be,...Se},W=ye()?Ce:we;Object.entries(xe);var Te=n(((t,n)=>{n.exports=i;function r(t){let n={defaultWidth:0,output:process.stdout,tty:e(`tty`)};return t?(Object.keys(n).forEach(function(e){t[e]||(t[e]=n[e])}),t):n}function i(e){let t=r(e);if(t.output.getWindowSize)return t.output.getWindowSize()[0]||t.defaultWidth;if(t.tty.getWindowSize)return t.tty.getWindowSize()[1]||t.defaultWidth;if(t.output.columns)return t.output.columns;if(process.env.CLI_WIDTH){let e=parseInt(process.env.CLI_WIDTH,10);if(!isNaN(e)&&e!==0)return e}return t.defaultWidth}}));const Ee=(()=>{let e=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g;return t=>{let n=0;for(e.lastIndex=0;e.test(t);)n+=1;return t.length-n}})(),De=e=>e===12288||e>=65281&&e<=65376||e>=65504&&e<=65510,Oe=e=>e===8987||e===9001||e>=12272&&e<=12287||e>=12289&&e<=12350||e>=12441&&e<=12543||e>=12549&&e<=12591||e>=12593&&e<=12686||e>=12688&&e<=12771||e>=12783&&e<=12830||e>=12832&&e<=12871||e>=12880&&e<=19903||e>=65040&&e<=65049||e>=65072&&e<=65106||e>=65108&&e<=65126||e>=65128&&e<=65131||e>=127488&&e<=127490||e>=127504&&e<=127547||e>=127552&&e<=127560||e>=131072&&e<=196605||e>=196608&&e<=262141,ke=/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]|\u001b\]8;[^;]*;.*?(?:\u0007|\u001b\u005c)/y,Ae=/[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y,je=/(?:(?![\uFF61-\uFF9F\uFF00-\uFFEF])[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}\p{Script=Tangut}]){1,1000}/uy,Me=/\t{1,1000}/y,Ne=/[\u{1F1E6}-\u{1F1FF}]{2}|\u{1F3F4}[\u{E0061}-\u{E007A}]{2}[\u{E0030}-\u{E0039}\u{E0061}-\u{E007A}]{1,3}\u{E007F}|(?:\p{Emoji}\uFE0F\u20E3?|\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation})(?:\u200D(?:\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation}|\p{Emoji}\uFE0F\u20E3?))*/uy,Pe=/(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y,Fe=/\p{M}+/gu,Ie={limit:1/0,ellipsis:``},Le=(e,t={},n={})=>{let r=t.limit??1/0,i=t.ellipsis??``,a=t?.ellipsisWidth??(i?Le(i,Ie,n).width:0),o=n.controlWidth??0,s=n.tabWidth??8,c=n.emojiWidth??2,l=n.regularWidth??1,u=n.wideWidth??2,d=[[Pe,l],[ke,0],[Ae,o],[Me,s],[Ne,c],[je,u]],f=0,p=0,m=e.length,h=0,g=!1,_=m,v=Math.max(0,r-a),y=0,b=0,x=0,S=0;outer:for(;;){if(b>y||p>=m&&p>f){let t=e.slice(y,b)||e.slice(f,p);h=0;for(let e of t.replaceAll(Fe,``)){let t=e.codePointAt(0)||0;if(S=De(t)?2:Oe(t)?u:l,x+S>v&&(_=Math.min(_,Math.max(y,f)+h)),x+S>r){g=!0;break outer}h+=e.length,x+=S}y=b=0}if(p>=m)break outer;for(let t=0,n=d.length;t<n;t++){let[n,i]=d[t];if(n.lastIndex=p,n.test(e)){if(h=n===je?Ee(e.slice(p,n.lastIndex)):n===Ne?1:n.lastIndex-p,S=h*i,x+S>v&&(_=Math.min(_,p+Math.floor((v-x)/i))),x+S>r){g=!0;break outer}x+=S,y=f,b=p,p=f=n.lastIndex;continue outer}}p+=1}return{width:g?v:x,index:g?_:m,truncated:g,ellipsed:g&&r>=a}},Re={limit:1/0,ellipsis:``,ellipsisWidth:0},G=(e,t={})=>Le(e,Re,t).width,ze=`]8;;`,Be=RegExp(`(?:\\[(?<code>\\d+)m|\\${ze}(?<uri>.*))`,`y`),Ve=e=>{if(e>=30&&e<=37||e>=90&&e<=97)return 39;if(e>=40&&e<=47||e>=100&&e<=107)return 49;if(e===1||e===2)return 22;if(e===3)return 23;if(e===4)return 24;if(e===7)return 27;if(e===8)return 28;if(e===9)return 29;if(e===0)return 0},He=e=>`[${e}m`,Ue=e=>`${ze}${e}`,We=(e,t,n)=>{let r=t[Symbol.iterator](),i=!1,a=!1,o=e.at(-1),s=o===void 0?0:G(o),c=r.next(),l=r.next(),u=0;for(;!c.done;){let o=c.value,d=G(o);s+d<=n?e[e.length-1]+=o:(e.push(o),s=0),(o===`\x1B`||o===``)&&(i=!0,a=t.startsWith(ze,u+1)),i?a?o===`\x07`&&(i=!1,a=!1):o===`m`&&(i=!1):(s+=d,s===n&&!l.done&&(e.push(``),s=0)),c=l,l=r.next(),u+=o.length}o=e.at(-1),!s&&o!==void 0&&o.length&&e.length>1&&(e[e.length-2]+=e.pop())},Ge=e=>{let t=e.split(` `),n=t.length;for(;n&&!G(t[n-1]);)n--;return n===t.length?e:t.slice(0,n).join(` `)+t.slice(n).join(``)},Ke=(e,t,n={})=>{if(n.trim!==!1&&e.trim()===``)return``;let r=``,i,a,o=e.split(` `),s=[``],c=0;for(let e=0;e<o.length;e++){let r=o[e];if(n.trim!==!1){let e=s.at(-1)??``,t=e.trimStart();e.length!==t.length&&(s[s.length-1]=t,c=G(t))}e!==0&&(c>=t&&(n.wordWrap===!1||n.trim===!1)&&(s.push(``),c=0),(c||n.trim===!1)&&(s[s.length-1]+=` `,c++));let i=G(r);if(n.hard&&i>t){let e=t-c,n=1+Math.floor((i-e-1)/t);Math.floor((i-1)/t)<n&&s.push(``),We(s,r,t),c=G(s.at(-1)??``);continue}if(c+i>t&&c&&i){if(n.wordWrap===!1&&c<t){We(s,r,t),c=G(s.at(-1)??``);continue}s.push(``),c=0}if(c+i>t&&n.wordWrap===!1){We(s,r,t),c=G(s.at(-1)??``);continue}s[s.length-1]+=r,c+=i}n.trim!==!1&&(s=s.map(e=>Ge(e)));let l=s.join(`
|
|
2
2
|
`),u=!1;for(let e=0;e<l.length;e++){let t=l[e];if(r+=t,u)u=!1;else if(u=t>=`\ud800`&&t<=`\udbff`,u)continue;if(t===`\x1B`||t===``){Be.lastIndex=e+1;let t=Be.exec(l)?.groups;if(t?.code!==void 0){let e=Number.parseFloat(t.code);i=e===39?void 0:e}else t?.uri!==void 0&&(a=t.uri.length===0?void 0:t.uri)}if(l[e+1]===`
|
|
3
3
|
`){a&&(r+=Ue(``));let e=i?Ve(i):void 0;i&&e&&(r+=He(e))}else t===`
|
|
4
4
|
`&&(i&&Ve(i)&&(r+=He(i)),a&&(r+=Ue(a)))}return r},qe=/\r?\n/;function Je(e,t,n){return String(e).normalize().split(qe).map(e=>Ke(e,t,n)).join(`
|
|
@@ -400,10 +400,10 @@ last-spawn-error.log
|
|
|
400
400
|
# drafts/ # exclude a directory
|
|
401
401
|
# *.draft.md # exclude files matching a pattern
|
|
402
402
|
# !keep.md # re-include a file .gitignore excluded
|
|
403
|
-
`,`.okignore`)?r.push(`.okignore`):a.push(`.okignore`),{created:r,updated:i,skipped:a}}function $n(e,t){let n=N(t,e);return n.length>0&&!n.startsWith(`..`)&&!A(n)}const er=e=>{try{let t=ie(`git`,[`rev-parse`,`--show-toplevel`],{cwd:e,encoding:`utf8`,stdio:[`ignore`,`pipe`,`ignore`]}).trim();return t.length>0?t:null}catch{return null}};function tr(e,t={}){let n=t.homeDir??H(),r=t.gitTopLevel??er,i=P(e),a;try{a=le(i)}catch{a=i}let o=a,s=0;for(;s<30&&!(o===n||o===`/`||o===``);){if(m(o))return{projectRoot:o,defaultContentDir:`.`,ancestorPromoted:o!==a,gitRootPromoted:!1};let e=k(o);if(e===o)break;o=e,s+=1}let c=r(a);return c!==null&&$n(c,n)?c===a?{projectRoot:i,defaultContentDir:`.`,ancestorPromoted:!1,gitRootPromoted:!1}:{projectRoot:c,defaultContentDir:`.`,ancestorPromoted:!1,gitRootPromoted:!0}:{projectRoot:i,defaultContentDir:`.`,ancestorPromoted:!1,gitRootPromoted:!1}}
|
|
404
|
-
`)}\r\n\r\n`),n.length>0&&o.write(n)}catch(e){c({event:`proxy-upgrade-handshake-write-failed`,err:e});return}o.on(`data`,e=>{t.writable&&t.write(e)}),t.on(`data`,e=>{o.writable&&o.write(e)})}),o.once(`timeout`,()=>{c({event:`proxy-upgrade-upstream-connect-timeout`})}),o.on(`error`,e=>c({event:`proxy-upgrade-upstream-error`,err:e})),t.on(`error`,e=>c({event:`proxy-upgrade-client-error`,err:e})),o.once(`close`,()=>c()),t.once(`close`,()=>c())}const
|
|
405
|
-
`)?n:`${n}\n`,`utf-8`)}
|
|
406
|
-
`,required:!1,theme:{icon:{checked:`[x]`,unchecked:`[ ]`}},choices:[{name:`User-level (~/.claude.json, ~/.cursor/mcp.json, …)`,value:`user`,checked:!0},{name:`Project-level (.mcp.json, .cursor/mcp.json, …)`,value:`project`,checked:!0}]});return e.includes(`user`)&&e.includes(`project`)?`both`:e.includes(`user`)?`user`:e.includes(`project`)?`project`:null}async function Gr(e){return e.mcp===!1?null:e.scope?e.scope:e.isTTY??process.stdout.isTTY?(e.promptFn??Wr)():`both`}const Kr=`0.0.1`,qr=`open-knowledge-ui`,Jr=[`-y`,`@inkeep/open-knowledge@latest`,`ui`];function Yr(e,t={}){let n=j(e,`.claude`,`launch.json`),r=t.cliPath===void 0?t.mode===`dev`?{name:qr,runtimeExecutable:`node`,runtimeArgs:[or(),`ui`],port:kr,autoPort:!0}:{name:qr,runtimeExecutable:`npx`,runtimeArgs:[...Jr],port:kr,autoPort:!0}:{name:qr,runtimeExecutable:t.cliPath,runtimeArgs:[`ui`],port:kr,autoPort:!0};try{if(Vr(n,e),!L(n))return R(k(n),{recursive:!0}),B(n,`${JSON.stringify({version:Kr,configurations:[r]},null,2)}\n`,`utf-8`),{action:`created`,configPath:n};let t=z(n,`utf-8`).trim(),i=t?JSON.parse(t):{};if(!w(i))return{action:`failed`,configPath:n,error:`launch.json root is not an object`};let a=Array.isArray(i.configurations)?i.configurations:[],o=a.findIndex(e=>w(e)&&e.name===`open-knowledge-ui`);o>=0?a[o]=r:a.push(r);let s={...i,version:i.version??Kr,configurations:a};return B(n,`${JSON.stringify(s,null,2)}\n`,`utf-8`),{action:o>=0?`merged`:`created`,configPath:n}}catch(e){return{action:`failed`,configPath:n,error:e instanceof Error?e.message:String(e)}}}function Xr(e,t,n){try{return L(e.detectPath?.(t,n)??k(e.configPath(t,n)))}catch{return!1}}function Zr(e,t,n,r,i){let a=e.serverName(t),o;try{o=i??e.configPath(t,r)}catch(t){return{editorId:e.id,label:e.label,action:`failed`,configPath:``,serverName:a,error:t instanceof Error?t.message:String(t)}}if(!i&&!n.skipAvailabilityCheck&&!Xr(e,t,r))return{editorId:e.id,label:e.label,action:`skipped-missing`,configPath:o,serverName:a};if(i!==void 0)try{Vr(o,t)}catch(t){return{editorId:e.id,label:e.label,action:`failed`,configPath:o,serverName:a,error:t instanceof Error?t.message:String(t),configScope:`project`}}let s;try{s=e.format===`toml`?Rr(o):Lr(o)}catch(t){return{editorId:e.id,label:e.label,action:`failed`,configPath:o,serverName:a,error:t instanceof Error?t.message:String(t)}}let c=s[e.topLevelKey]??{},l=c[a],u;try{u=e.buildEntry(t,n)}catch(t){return{editorId:e.id,label:e.label,action:`failed`,configPath:o,serverName:a,error:t instanceof Error?t.message:String(t)}}let d={...s,[e.topLevelKey]:{...c,[a]:u}};try{e.format===`toml`?Br(o,d):zr(o,d)}catch(t){return{editorId:e.id,label:e.label,action:`failed`,configPath:o,serverName:a,error:t instanceof Error?t.message:String(t)}}return{editorId:e.id,label:e.label,action:l===void 0?`written`:`overwritten`,configPath:o,serverName:a,...i===void 0?{}:{configScope:`project`}}}function Qr(e,t){let n=e.projectSkillPath?.(t);if(!n)return{editorId:e.id,label:e.label,action:`skipped-unsupported`,path:``};try{let r=u(`project`,{checkDesktop:!0}),i=k(n);Vr(i,t);let a=L(n)?`overwritten`:`written`;return ue(i,{recursive:!0,force:!0}),R(k(i),{recursive:!0}),se(r,i,{recursive:!0}),{editorId:e.id,label:e.label,action:a,path:n}}catch(t){return{editorId:e.id,label:e.label,action:`failed`,path:n,error:t instanceof Error?t.message:String(t)}}}function $r(e,t){let n=e.projectConfigPath?.(t);if(!(!n||!L(n)))return{editorId:e.id,label:e.label,path:n}}async function ei(e){let t=vr(e.editors),n={mode:`published`,cliPath:e.cliPath,skipAvailabilityCheck:!0};return t.map(t=>Zr(t,``,n,e.home))}function ti(e,t,n,r){let i=ni(e,t,n,r);return i.kind===`present`?i.entry:null}function ni(e,t,n,r){let i;try{i=r??e.configPath(t,n)}catch{return{kind:`absent`}}if(!L(i))return{kind:`absent`};let a;try{a=z(i,`utf-8`)}catch(e){return{kind:`corrupt`,error:e instanceof Error?e.message:String(e)}}if(a.trim()===``)return{kind:`corrupt`,error:`file is empty`};let o;try{o=e.format===`toml`?Rr(i):Lr(i)}catch(e){return{kind:`corrupt`,error:e instanceof Error?e.message:String(e)}}let s=o[e.topLevelKey];if(!w(s))return{kind:`no-entry`};let c=s[e.serverName(t)];return w(c)?{kind:`present`,entry:c}:{kind:`no-entry`}}async function ri(e={}){let t=P(e.cwd??process.cwd()),n=tr(t,{homeDir:e.home}),r=n.projectRoot,i=!L(j(r,`.ok`));n.ancestorPromoted?console.log(`[ok] Opened existing project at ${r}`):n.gitRootPromoted&&i&&console.log(`[ok] Initialized OK at ${r} — opened parent of ${N(r,t)} because it contains a .git folder`);let a={mode:e.devMcp?`dev`:`published`},o=await c(r),s;try{s=Qn(r,{contentDir:n.defaultContentDir})}catch(t){let n=Q.claude.configPath(r,e.home);return{projectRoot:r,contentCreated:[],contentUpdated:[],contentSkipped:[],editors:[],projectSkills:[],legacyProjectConfigs:[],didGitInit:o.didInit,claudeDesktopDetected:!1,mcpAction:`failed`,mcpPath:n,mcpError:`Content scaffolding failed: ${t instanceof Error?t.message:String(t)}`}}let l=await Gr({scope:e.scope,mcp:e.mcp,isTTY:e.isTTY,promptFn:e.promptFn}),u=e.editors??ai(r,e.home),d=e.editors??nr.filter(e=>Q[e].projectConfigPath!==void 0),f=vr(u),p=vr(d),m=e.mcp===!1||l===null,h=Array.from(new Map([...f,...m?[]:p].map(e=>[e.id,e])).values()),g=f.filter(t=>Xr(t,r,e.home)),_=[],v=[],b=new Set;for(let t of h){if(m){let n=``;try{n=t.configPath(r,e.home)}catch{}_.push({editorId:t.id,label:t.label,action:`skipped-flag`,configPath:n,serverName:t.serverName(r)});continue}if(Hr(l)&&f.includes(t)&&_.push(Zr(t,r,a,e.home)),Ur(l)&&p.includes(t)&&t.projectConfigPath){let n=t.projectConfigPath(r),i=Zr(t,r,a,e.home,n);_.push(i),(i.action===`written`||i.action===`overwritten`)&&b.add(n)}}for(let e of p)e.projectSkillPath&&v.push(Qr(e,r));let x=!m&&l!==null&&Ur(l)?p.filter(e=>!e.projectConfigPath).map(e=>e.label):void 0,C=m?[]:g.map(e=>$r(e,r)).filter(e=>e!==void 0).filter(e=>!b.has(e.path)),ee=g.some(e=>e.id===`claude`)&&!m?Yr(r,a):void 0,te=await(e.installUserSkill??S)({home:e.home}),w=y({home:e.home}),T=m?`skipped-flag`:`skipped-missing`,E=_.find(e=>e.editorId===`claude`)??_[0]??{action:T,configPath:Q.claude.configPath(r,e.home)};return{projectRoot:r,contentCreated:s.created,contentUpdated:s.updated,contentSkipped:s.skipped,editors:_,projectSkills:v,legacyProjectConfigs:C,launchJson:ee,skillInstall:te,didGitInit:o.didInit,claudeDesktopDetected:w,mcpAction:E.action,mcpPath:E.configPath,mcpError:`error`in E?E.error:void 0,projectScopeUnsupportedLabels:x}}function ii(e,t){let n=[],r=e.editors.some(e=>e.action===`written`||e.action===`overwritten`),i=e.editors.some(e=>e.action===`failed`)||e.projectSkills.some(e=>e.action===`failed`),a=e.editors.length>0&&e.editors.every(e=>e.action===`skipped-flag`),o=e.editors.length>0&&e.editors.every(e=>e.action===`skipped-missing`),s=e=>{let n=e.configPath.startsWith(t)?N(t,e.configPath):e.configPath;switch(e.action){case`created`:return` app preview server ${n} configured for Claude Code Desktop embedded browser`;case`merged`:return` app preview server ${n} updated for Claude Code Desktop embedded browser`;case`failed`:return` app preview server ${n} FAILED: ${e.error}`}};e.didGitInit&&n.push(`Initialized git repo at ${t}/.git/ (default branch: main)`);let c=j(t,`.ok`);if(e.contentCreated.length>0||e.contentUpdated.length>0?(n.push(O(`Content scaffolded at ${c}/`)),e.contentCreated.length>0&&n.push(` Created: ${e.contentCreated.join(`, `)}`),e.contentUpdated.length>0&&n.push(` Updated: ${e.contentUpdated.join(`, `)}`)):n.push(O(`Content already present at ${c}/`)),e.contentSkipped.length>0&&n.push(` Skipped (already exist): ${e.contentSkipped.join(`, `)}`),n.push(``),e.mcpError&&e.editors.length===0)n.push(`Warning: ${e.mcpError}`);else if(e.editors.length===0)if(n.push(O(`MCP server configuration:`)),e.mcpAction===`skipped-flag`)n.push(` MCP config not written — use without --no-mcp to configure editors`);else if(e.projectScopeUnsupportedLabels&&e.projectScopeUnsupportedLabels.length>0){let t=e.projectScopeUnsupportedLabels.join(`, `),r=e.projectScopeUnsupportedLabels.length===1?`does`:`do`;n.push(` ${t} ${r} not support project-level config; skipped`)}else n.push(` No supported editor config directories detected; skipped MCP registration`);else if(a)n.push(`MCP config not written — use without --no-mcp to configure editors`);else if(o)n.push(O(`MCP server configuration:`)),n.push(` No supported editor config directories detected; skipped MCP registration`);else{n.push(O(`MCP server configuration:`));for(let r of e.editors){let i=r.configPath.startsWith(t)?N(t,r.configPath):r.configPath.replace(/^\/Users\/[^/]+/,`~`),a=r.serverName===`open-knowledge`?``:` (${r.serverName})`,o=r.configScope===`project`?` (project)`:``,c=`${r.label}${o}`,l=` `.repeat(Math.max(1,20-c.length)),u=r.editorId===`claude-desktop`&&(r.action===`written`||r.action===`overwritten`)?` — quit and relaunch Claude Desktop to activate`:``;switch(r.action){case`written`:n.push(` ${c}${l}${i} ${E(`registered`)}${a}${u}`);break;case`overwritten`:n.push(` ${c}${l}${i} ${E(`updated`)}${a}${u}`);break;case`skipped-missing`:n.push(` ${c}${l}${i} config root missing; skipped`);break;case`failed`:n.push(` ${c}${l}${i} ${ne(`FAILED`)}: ${r.error}`);break;case`skipped-flag`:break}r.editorId===`claude`&&e.launchJson&&n.push(s(e.launchJson))}if(e.projectScopeUnsupportedLabels&&e.projectScopeUnsupportedLabels.length>0){let t=e.projectScopeUnsupportedLabels.join(`, `),r=e.projectScopeUnsupportedLabels.length===1?`does`:`do`;n.push(` ${t} ${r} not support project-level config; skipped`)}}if(e.projectSkills.length>0){n.push(``),n.push(O(`Project-local skills:`));for(let r of e.projectSkills){let e=`${r.label} (project)`,i=` `.repeat(Math.max(1,20-e.length)),a=r.path?N(t,r.path):``;switch(r.action){case`written`:n.push(` ${e}${i}${a} ${E(`installed`)}`);break;case`overwritten`:n.push(` ${e}${i}${a} ${E(`updated`)}`);break;case`skipped-unsupported`:n.push(` ${e}${i}no known project skill surface; skipped`);break;case`failed`:n.push(` ${e}${i}${a} ${ne(`FAILED`)}: ${r.error}`);break}}}if(i&&(n.push(``),n.push(`For failed editors, add the MCP server entry or project skill manually. See:`),n.push(` https://github.com/inkeep/open-knowledge#mcp-setup`)),e.legacyProjectConfigs.length>0){n.push(``),n.push(`Project MCP configs found:`);for(let r of e.legacyProjectConfigs)n.push(` ${r.label} ${N(t,r.path)}`);n.push(` These project-local files may override the global config. Remove them if you want fully user-scoped MCP setup in this project.`)}if(e.skillInstall)switch(n.push(``),n.push(O(`User-global skill:`)),e.skillInstall){case`installed`:n.push(` open-knowledge ${E(`installed to detected agent hosts`)} via \`npx skills\``);break;case`skip-current`:n.push(` open-knowledge ${E(`already installed at current version`)}`);break;case`failed`:n.push(` ${D(`open-knowledge install failed — MCP still configured; run manually:`)}`),n.push(` ${D(` npx skills@~1.5.0 add <bundled-path> --agent '*' -g -y --copy`)}`);break}if(e.claudeDesktopDetected&&(n.push(``),n.push(`Claude Desktop App detected. To enable in Claude Chat & Cowork, run: ${O(`ok install-skill`)}`)),e.preview?(n.push(``),n.push(re(e.preview,t))):e.previewWarning&&(n.push(``),n.push(`Content preview unavailable: ${e.previewWarning}`)),r){let t=new Set,r=e.editors.filter(e=>e.action===`written`||e.action===`overwritten`).filter(e=>!t.has(e.editorId)&&t.add(e.editorId)).map(e=>e.label);n.push(``),n.push(`${E(`✓`)} ${O(`Next steps:`)}`),n.push(` 1. Open your editor (${T(r.join(` / `))})`),n.push(` 2. Approve the MCP server when prompted`),n.push(` 3. (Optional) scaffold the starter knowledge-base structure:`),n.push(` - ${T(`ok seed`)} — empty repo, Karpathy 3-layer`),n.push(` - ${T(`mcp__open-knowledge__discover`)} — existing repo, extract conventions`),n.push(` 4. Use the MCP workflow tools as you build the wiki:`),n.push(` - ${T(`mcp__open-knowledge__ingest`)} — capture an external source`),n.push(` - ${T(`mcp__open-knowledge__research`)} — gather sources and write findings`),n.push(` - ${T(`mcp__open-knowledge__consolidate`)} — promote research to canonical articles`)}return n.join(`
|
|
407
|
-
`)}function ai(e,t){let n=[];for(let r of
|
|
408
|
-
`),e.stderr&&process.stderr.write(`${e.stderr.trim()}\n`),process.exitCode=1;return}throw e}try{let{previewContent:e}=await import(`./preview-
|
|
409
|
-
//# sourceMappingURL=init-
|
|
403
|
+
`,`.okignore`)?r.push(`.okignore`):a.push(`.okignore`),{created:r,updated:i,skipped:a}}function $n(e,t){let n=N(t,e);return n.length>0&&!n.startsWith(`..`)&&!A(n)}const er=e=>{try{let t=ie(`git`,[`rev-parse`,`--show-toplevel`],{cwd:e,encoding:`utf8`,stdio:[`ignore`,`pipe`,`ignore`]}).trim();return t.length>0?t:null}catch{return null}};function tr(e,t={}){let n=t.homeDir??H(),r=t.gitTopLevel??er,i=P(e),a;try{a=le(i)}catch{a=i}let o=a,s=0;for(;s<30&&!(o===n||o===`/`||o===``);){if(m(o))return{projectRoot:o,defaultContentDir:`.`,ancestorPromoted:o!==a,gitRootPromoted:!1};let e=k(o);if(e===o)break;o=e,s+=1}let c=r(a);return c!==null&&$n(c,n)?c===a?{projectRoot:i,defaultContentDir:`.`,ancestorPromoted:!1,gitRootPromoted:!1}:{projectRoot:c,defaultContentDir:`.`,ancestorPromoted:!1,gitRootPromoted:!0}:{projectRoot:i,defaultContentDir:`.`,ancestorPromoted:!1,gitRootPromoted:!1}}function nr(e,t){let n;try{n=le(t)}catch{n=P(t)}let r;try{r=ce(e)}catch(e){if(e.code!==`ENOENT`)throw e}if(r?.isSymbolicLink())throw Error(`Refusing to write through a symbolic link at ${e}. Remove the symlink and re-run project setup.`);let i=k(e);for(;i.length>1&&i!==F;){let t;try{t=le(i)}catch(e){if(e.code===`ENOENT`){i=k(i);continue}throw e}let r=N(n,t);if(r===``||!r.startsWith(`..`)&&!A(r))return;throw Error(`Refusing to write at ${e}: ancestor ${i} resolves to ${t}, which is outside the project directory ${n}. A symbolic link in the path likely escapes the project. Remove the symlink and re-run project setup.`)}}function rr(e,t){let n=e.projectSkillPath?.(t);if(!n)return{editorId:e.id,label:e.label,action:`skipped-unsupported`,path:``};try{let r=u(`project`,{checkDesktop:!0}),i=k(n);nr(i,t);let a=L(n)?`overwritten`:`written`;return ue(i,{recursive:!0,force:!0}),R(k(i),{recursive:!0}),se(r,i,{recursive:!0}),{editorId:e.id,label:e.label,action:a,path:n}}catch(t){return{editorId:e.id,label:e.label,action:`failed`,path:n,error:t instanceof Error?t.message:String(t)}}}const ir=l,ar=x,or=[`-y`,`@inkeep/open-knowledge@latest`,`mcp`],sr={MCP_DEBUG:`1`,OK_LOG_FILE:`/tmp/ok-mcp.log`};function cr(e=process.argv[1]){if(!e)throw Error(`Cannot infer the local CLI entry for --dev-mcp because process.argv[1] is empty.`);let t=P(e);if(oe(t)===`cli.mjs`&&oe(k(t))===`dist`)return t;let n=t.split(F),r=n.lastIndexOf(`packages`);if(r===-1||n[r+1]!==`cli`)throw Error(`Cannot infer the repo root for --dev-mcp from ${t}. Run the local CLI from this repo so the built dist path can be derived.`);let i=n.slice(0,r);return j(i.length===0?F:i.join(F),`packages`,`cli`,`dist`,`cli.mjs`)}function lr(e={}){return e.cliPath?{command:e.cliPath,args:[`mcp`]}:e.mode===`dev`?{command:`node`,args:[cr(),`mcp`],env:{...sr}}:{command:`npx`,args:[...or]}}function ur(e){return e===`win32`?I:M}function dr(e={}){let t=e.platformName??process.platform,n=e.home??H();return ur(t).join(n,`.claude.json`)}function fr(e={}){let t=e.platformName??process.platform,n=e.home??H(),r=e.env??process.env;if(t===`darwin`)return M.join(n,`Library`,`Application Support`,`Claude`,`claude_desktop_config.json`);if(t===`win32`){let e=r.APPDATA??I.join(n,`AppData`,`Roaming`);return I.join(e,`Claude`,`claude_desktop_config.json`)}throw Error(`Claude Desktop is not available on ${t}. Supported: macOS, Windows.`)}function pr(e={}){let t=e.platformName??process.platform,n=e.home??H();return ur(t).join(n,`.cursor`,`mcp.json`)}function mr(e={}){let t=e.platformName??process.platform,n=e.home??H();return(e.env??process.env).CODEX_HOME??ur(t).join(n,`.codex`)}function hr(e={}){return ur(e.platformName??process.platform).join(mr(e),`config.toml`)}function gr(e,t){if(e===t)return!0;if(Array.isArray(e)&&Array.isArray(t))return e.length===t.length&&e.every((e,n)=>gr(e,t[n]));if(w(e)&&w(t)){let n=Object.keys(e).sort(),r=Object.keys(t).sort();return n.length===r.length&&n.every((e,t)=>e===r[t])&&n.every(n=>gr(e[n],t[n]))}return!1}function _r(e,t){return Object.entries(t).every(([t,n])=>gr(e[t],n))}function vr(e,t){return{...e,...t}}function yr(e){return{...e,isCompatible(t,n,r){return _r(t,e.buildEntry(n,r))},mergeManagedFields(t,n,r){return vr(t,e.buildEntry(n,r))}}}const Q={claude:yr({id:`claude`,label:ar.claude,configPath:(e,t)=>dr({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>o,buildEntry:(e,t)=>lr(t),scope:`global`,detectPath:(e,t)=>j(t??H(),`.claude`),projectConfigPath:e=>j(e,`.mcp.json`),projectSkillPath:e=>j(e,`.claude`,`skills`,`open-knowledge`,`SKILL.md`)}),"claude-desktop":yr({id:`claude-desktop`,label:ar[`claude-desktop`],configPath:(e,t)=>fr({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>o,buildEntry:(e,t)=>lr(t),scope:`global`,detectPath:(e,t)=>k(fr({home:t}))}),cursor:yr({id:`cursor`,label:ar.cursor,configPath:(e,t)=>pr({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>o,buildEntry:(e,t)=>lr(t),scope:`global`,detectPath:(e,t)=>k(pr({home:t})),projectConfigPath:e=>j(e,`.cursor`,`mcp.json`),projectSkillPath:e=>j(e,`.cursor`,`skills`,`open-knowledge`,`SKILL.md`)}),codex:yr({id:`codex`,label:ar.codex,configPath:(e,t)=>hr({home:t}),format:`toml`,topLevelKey:`mcp_servers`,serverName:()=>o,buildEntry:(e,t)=>lr(t),scope:`global`,detectPath:(e,t)=>k(hr({home:t})),projectConfigPath:e=>j(e,`.codex`,`config.toml`),projectSkillPath:e=>j(e,`.agents`,`skills`,`open-knowledge`,`SKILL.md`)})};function br(e){let t=e.filter(e=>!Object.hasOwn(Q,e));if(t.length>0)throw Error(`Unknown editor(s): ${t.join(`, `)}. Valid options: ${ir.join(`, `)}`);return e.map(e=>Q[e])}function $(e,t,n,r,i){let a=`urn:uuid:${he()}`;if(e.headersSent||e.writableEnded||e.destroyed){console.error(`[ok ui] emitProblem called after headers sent — suppressed`,{type:n,status:t,instance:a});return}let o={type:n,title:r,status:t,instance:a,...i===void 0?{}:{detail:i}},s=C.safeParse(o);if(!s.success){console.error(`[ok ui] emitProblem produced an invalid ProblemDetails body:`,{issues:s.error.issues,originalStatus:t,body:o}),e.writeHead(500,{"Content-Type":`application/problem+json`,"X-Content-Type-Options":`nosniff`,"Cache-Control":`no-store`}),e.end(JSON.stringify({type:`urn:ok:error:internal-server-error`,title:`Internal server error.`,status:500,instance:a}));return}e.writeHead(t,{"Content-Type":`application/problem+json`,"X-Content-Type-Options":`nosniff`,"Cache-Control":`no-store`}),e.end(JSON.stringify(o))}const xr=1e4;function Sr(e,t){let n=e.socket?.remoteAddress;if(n!==void 0&&!b(n))return $(t,403,`urn:ok:error:loopback-required`,`Request must originate from a loopback address.`),!0;if(!f(e.headers.host))return $(t,403,`urn:ok:error:host-not-allowed`,`Host header is not in the loopback allowlist.`),!0;let r=e.headers.origin;return r!==void 0&&!v(r)?($(t,403,`urn:ok:error:invalid-origin`,`Origin header is not in the loopback allowlist.`),!0):!1}const Cr=3e4;function wr(e,t){let n=e.socket?.remoteAddress;if(n!==void 0&&!b(n)||!f(e.headers.host))return t.destroy(),!0;let r=e.headers.origin;return typeof r==`string`&&!v(r)?(t.destroy(),!0):!1}function Tr(e,t,n,r,i,a){a.add(t),t.once(`close`,()=>a.delete(t));let o=ve({host:r,port:i,timeout:xr});a.add(o),o.once(`close`,()=>a.delete(o));let s=!1,c=n=>{if(!s){if(s=!0,n!==void 0){let t=n.err;console.warn(JSON.stringify({event:n.event,upstreamHost:r,upstreamPort:i,url:e.url,code:t instanceof Error?t.code:void 0,message:t instanceof Error?t.message:void 0}))}try{o.destroy()}catch{}try{t.destroy()}catch{}}};o.once(`connect`,()=>{o.setTimeout(0);let a=[`${e.method??`GET`} ${e.url??`/`} HTTP/1.1`,`host: ${r}:${i}`];for(let[t,n]of Object.entries(e.headers))if(t.toLowerCase()!==`host`&&n!==void 0)if(Array.isArray(n))for(let e of n)a.push(`${t}: ${e}`);else a.push(`${t}: ${n}`);try{o.write(`${a.join(`\r
|
|
404
|
+
`)}\r\n\r\n`),n.length>0&&o.write(n)}catch(e){c({event:`proxy-upgrade-handshake-write-failed`,err:e});return}o.on(`data`,e=>{t.writable&&t.write(e)}),t.on(`data`,e=>{o.writable&&o.write(e)})}),o.once(`timeout`,()=>{c({event:`proxy-upgrade-upstream-connect-timeout`})}),o.on(`error`,e=>c({event:`proxy-upgrade-upstream-error`,err:e})),t.on(`error`,e=>c({event:`proxy-upgrade-client-error`,err:e})),o.once(`close`,()=>c()),t.once(`close`,()=>c())}const Er=[`connection`,`keep-alive`,`proxy-authenticate`,`proxy-authorization`,`te`,`trailer`,`transfer-encoding`,`upgrade`,`cookie`,`set-cookie`];async function Dr(e){let t=e.upstreamTimeoutMs??xr,n=new Set,r=ge((n,r)=>{Sr(n,r)||kr(n,r,e.upstreamHost,e.upstreamPort,t)});r.on(`upgrade`,(t,r,i)=>{wr(t,r)||Tr(t,r,i,e.upstreamHost,e.upstreamPort,n)}),await new Promise((t,n)=>{let i=e=>n(e);r.once(`error`,i),r.listen(e.listenPort,e.host,()=>{r.off(`error`,i),t()})});let i=r.address();return{httpServer:r,port:typeof i==`object`&&i?i.port:e.listenPort,close:()=>new Promise(e=>{for(let e of n)try{e.destroy()}catch{}n.clear(),r.close(()=>e()),r.closeIdleConnections()})}}function Or(e,t,n){kr(e,t,n.upstreamHost,n.upstreamPort,n.upstreamTimeoutMs??xr)}function kr(e,t,n,r,i){let a={...e.headers};delete a.host;for(let e of Er)delete a[e];e.setTimeout(Cr,()=>{if(t.headersSent)try{t.end()}catch{}else try{$(t,408,`urn:ok:error:request-timeout`,`Proxy request exceeded the per-request deadline.`,`Slow-loris-class: client did not finish within ${Cr/1e3}s.`)}catch{}try{e.socket?.destroy()}catch{}});let o=_e({host:n,port:r,method:e.method,path:e.url,headers:{...a,host:`${n}:${r}`}},e=>{let n={...e.headers};for(let e of Er)delete n[e];t.writeHead(e.statusCode??502,n),e.pipe(t),e.once(`error`,()=>{try{t.end()}catch{}})});i>0&&o.setTimeout(i,()=>{if(!t.headersSent)$(t,504,`urn:ok:error:gateway-timeout`,`Upstream did not respond before the gateway deadline.`,`Upstream timeout: ${i/1e3}s elapsed without a response.`);else try{t.end()}catch{}o.destroy()}),o.on(`error`,()=>{if(!t.headersSent)$(t,502,`urn:ok:error:collab-server-not-running`,`Collab server is unreachable.`,`Upstream connection failed or dropped before a response was received.`);else try{t.end()}catch{}}),e.on(`error`,()=>{o.destroy()}),e.pipe(o)}const Ar=39847,jr=39848;async function Mr(e){await Promise.all(e.map(e=>new Promise(t=>{e.close(()=>t())})))}async function Nr(e){let{existsSync:t}=await import(`node:fs`),{createServer:n}=await import(`node:http`),{resolve:r}=await import(`node:path`),{acquireUiLock:i,createAssetServeMiddleware:o,createContentFilter:s,readServerLock:c,releaseUiLock:l,updateUiLockPort:u}=await import(`./dist-7_PKsuCz.mjs`),{default:f}=await import(`./build-B4ZT2GMK.mjs`),{resolveContentDir:m,resolveLockDir:h}=await import(`./dist-7_PKsuCz.mjs`),g=m(e.config,e.cwd),v=h(e.cwd);i(v,{port:0,worktreeRoot:e.cwd});let y=import.meta.dirname??new URL(`.`,import.meta.url).pathname,b=[r(y,`public`),r(y,`../../app/dist`),r(y,`../../../app/dist`)].find(e=>t(e)),x=b?f(b,{single:!0,gzip:!0,immutable:!0,extensions:[]}):null,S=t(g)?o({contentFilter:s({projectDir:e.cwd,contentDir:g}),contentSirv:f(g,{dotfiles:!1,dev:!0,extensions:[]}),inlineExtensions:d,assetExtensions:a,blocklistExtensions:_}):null,C=e.port,ee=null,te=(e,t)=>{let n=e.url?.split(`?`)[0];if((n===`/`||n===``)&&(e.url=`/index.html`),!(n?.startsWith(`/api/`)&&Sr(e,t))){if(n===`/api/config`&&(e.method===`GET`||e.method===`HEAD`)){ee?.();let n=c(v),r=e.headers.host??`localhost:${C}`,i=n&&n.port>0?`ws://${r}/collab`:null,a=JSON.stringify({collabUrl:i,previewUrl:null,port:C});t.setHeader(`Content-Type`,`application/json`),t.setHeader(`Cache-Control`,`no-store`),t.setHeader(`X-Content-Type-Options`,`nosniff`),t.statusCode=200,e.method===`HEAD`?t.end():t.end(a);return}if(n?.startsWith(`/api/`)){ee?.();let r=c(v);if(!r||r.port<=0){$(t,503,`urn:ok:error:collab-server-not-running`,"Collab server not running. Start `ok start` or run `ok status`.",`Path: ${n}`);return}Or(e,t,{upstreamHost:`localhost`,upstreamPort:r.port});return}if(x&&n?.startsWith(`/assets/`)){x(e,t,()=>{S?S(e,t,()=>Pr(t,n)):Pr(t,n)});return}if(S){S(e,t,()=>{x?x(e,t):Pr(t,n)});return}if(x){x(e,t);return}Pr(t,n)}},w=new Set,T=(e,t,n)=>{if(wr(e,t))return;let r=e.url?.split(`?`)[0]??``;if(r!==`/collab`&&!r.startsWith(`/collab/`)){t.destroy();return}let i=c(v);if(!i||i.port<=0){console.warn(JSON.stringify({event:`ok-ui-upgrade-no-collab-lock`,url:r,reason:"server.lock missing or port unbound — is `ok start` running?"})),t.destroy();return}Tr(e,t,n,`localhost`,i.port,w)},E=()=>{for(let e of w)try{e.destroy()}catch{}w.clear()},ne=e.host===void 0?[`::1`,`127.0.0.1`]:[e.host],D=[],O=e.port,re=e=>e instanceof Error&&e.code===`EADDRINUSE`,ie=async()=>{await Promise.all(D.splice(0).map(e=>new Promise(t=>{try{e.close(()=>t())}catch{t()}})))},ae=async e=>{O=e;for(let e of ne){let t=n(te);t.on(`upgrade`,T),D.push(t),await new Promise((n,r)=>{let i=e=>r(e);t.once(`error`,i),t.listen(O,e,()=>{t.off(`error`,i);let e=t.address();typeof e==`object`&&e&&(O=e.port),n()})})}};try{try{await ae(e.port)}catch(t){if(e.fallbackToKernel===!0&&re(t))await ie(),await ae(0);else throw t}}catch(e){await ie();try{l(v)}catch{}throw e}let oe=O;C=oe,u(v,oe);let k=e.scheduler??p,A=e.safetyNetMs??432e5,j=null,M=!1,N=!1,P=()=>{M||(M=!0,j!==null&&(k.clearTimeout(j),j=null))},F=()=>{if(P(),!N){N=!0;try{l(v)}catch{}}},I=()=>{M||A<=0||(j!==null&&(k.clearTimeout(j),j=null),j=k.setTimeout(()=>{j=null,console.warn(`[ui] safety-net (${A}ms) reached — shutting down (D-025 backstop)`);try{e.onSafetyNet?.()}catch{}E();for(let e of D)try{e.close()}catch{}F()},A))},se=()=>{M||A<=0||I()};return ee=se,I(),{httpServers:D,port:oe,release:F,detachSafetyNet:P,nudgeSafetyNet:se,drainUpgradeSockets:E}}function Pr(e,t){$(e,404,`urn:ok:error:not-found`,`Resource not found.`,t===void 0?void 0:`Path: ${t}`)}function Fr(e,t){if(e!==void 0){let t=Number.parseInt(e,10);if(Number.isNaN(t)||t<0||t>65535)throw Error(`Invalid --port value '${e}'`);return{port:t,fallbackToKernel:!1}}if(t!==void 0&&t!==``){let e=Number.parseInt(t,10);if(Number.isNaN(e)||e<0||e>65535)throw Error(`Invalid PORT env value '${t}'`);return{port:e,fallbackToKernel:!1}}return{port:Ar,fallbackToKernel:!0}}async function Ir(e){let t=e.readLock??(async()=>{let{readUiLock:t}=await import(`./dist-7_PKsuCz.mjs`);return t(e.lockDir)}),n=await t();if(!n)throw Error(`UI lock collision reported but the lock disappeared before handling — retry acquiring.`);if(n.port===e.requestedPort&&n.port>0)return{mode:`already-running`,port:n.port};let r=n.port;if(r===0){let n=Date.now()+(e.pollDeadlineMs??2e3),i=e.pollIntervalMs??100;for(;Date.now()<n;){await new Promise(e=>{setTimeout(e,i)});let e=await t();if(e&&e.port>0){r=e.port;break}}if(r===0)throw Error("UI did not bind within 2s; run `ok clean`");if(r===e.requestedPort)return{mode:`already-running`,port:r}}return{mode:`proxy`,handle:await Dr({listenPort:e.requestedPort,host:e.host,upstreamHost:`localhost`,upstreamPort:r}),upstreamPort:r}}function Lr(e){return new i(`ui`).description(`Serve the Open Knowledge React editor UI`).option(`-p, --port <port>`,`UI port (default: $PORT env or ${Ar}, kernel-allocated fallback if busy)`).option(`-H, --host <host>`,"UI host. Default: two-socket loopback bind (`[::1]` + `127.0.0.1`) so cross-family collisions fail loud. Pass an explicit host (e.g. `127.0.0.1`, `0.0.0.0`) to bind a single socket on that host.").action(async t=>{let{dim:n}=await import(`./colors-BCE2jNgl.mjs`),{UiLockCollisionError:r}=await import(`./dist-7_PKsuCz.mjs`),{resolveLockDir:i}=await import(`./dist-7_PKsuCz.mjs`),a=e(),o=t.host,s;try{s=Fr(t.port,process.env.PORT)}catch(e){console.error(e instanceof Error?e.message:String(e)),process.exitCode=1;return}let c=s.port;try{let e=await Nr({config:a,cwd:process.cwd(),port:c,fallbackToKernel:s.fallbackToKernel,host:o}),t=o===void 0||o===`::`||o===`0.0.0.0`?`localhost`:o;console.log(`${n(`[ui]`)} listening on http://${t}:${e.port}`);let r=!1,i=t=>{if(r)return;r=!0,console.log(n(`\n[ui] Shutting down (${t})`)),e.detachSafetyNet();let i=()=>{try{e.release()}finally{process.exit(process.exitCode??0)}};e.drainUpgradeSockets(),Mr(e.httpServers).then(i,i),setTimeout(i,2e3).unref()};process.once(`SIGINT`,()=>i(`SIGINT`)),process.once(`SIGTERM`,()=>i(`SIGTERM`));return}catch(e){if(!(e instanceof r))throw e;let t=i(process.cwd()),a=o??`localhost`,s;try{s=await Ir({requestedPort:c,host:a,lockDir:t})}catch(e){console.error(e instanceof Error?e.message:String(e)),process.exit(1)}if(s.mode===`already-running`){if(console.log(`UI already running at http://${a}:${s.port}`),Rr(process)){await new Promise(e=>{let t=t=>{console.log(n(`\n[ui-keepalive] Shutting down (${t})`)),e()};process.once(`SIGINT`,()=>t(`SIGINT`)),process.once(`SIGTERM`,()=>t(`SIGTERM`))});return}process.exit(0)}console.log(`UI running at http://${a}:${s.upstreamPort}; acting as HTTP proxy on port ${s.handle.port}`);let l=!1,u=e=>{l||(l=!0,console.log(n(`\n[ui-proxy] Shutting down (${e})`)),s.handle.close().finally(()=>process.exit(process.exitCode??0)),setTimeout(()=>process.exit(process.exitCode??0),2e3).unref())};process.once(`SIGINT`,()=>u(`SIGINT`)),process.once(`SIGTERM`,()=>u(`SIGTERM`))}})}function Rr(e){let t=e.stdout.isTTY===!0,n=typeof e.env.PORT==`string`&&e.env.PORT!==``;return!t||n}function zr(e){if(!L(e))return{};let t=z(e,`utf-8`).trim();if(t===``)return{};try{let n=JSON.parse(t);if(w(n))return n;throw Error(`${e} root must be a JSON object`)}catch(t){throw t instanceof SyntaxError?Error(`${e} contains invalid JSON: ${t.message}`):t}}function Br(e){if(!L(e))return{};let t=z(e,`utf-8`).trim();if(t===``)return{};try{let n=Fn(t);if(w(n))return n;throw Error(`${e} root must be a TOML table`)}catch(t){throw Error(`${e} contains invalid TOML: ${t instanceof Error?t.message:String(t)}`)}}function Vr(e,t){R(k(e),{recursive:!0}),B(e,`${JSON.stringify(t,null,2)}\n`,`utf-8`)}function Hr(e,t){R(k(e),{recursive:!0});let n=Gn(t);B(e,n.endsWith(`
|
|
405
|
+
`)?n:`${n}\n`,`utf-8`)}const Ur=e=>e!==`project`,Wr=e=>e!==`user`;async function Gr(){let e=await dn({message:`Where should the MCP server be configured?
|
|
406
|
+
`,required:!1,theme:{icon:{checked:`[x]`,unchecked:`[ ]`}},choices:[{name:`User-level (~/.claude.json, ~/.cursor/mcp.json, …)`,value:`user`,checked:!0},{name:`Project-level (.mcp.json, .cursor/mcp.json, …)`,value:`project`,checked:!0}]});return e.includes(`user`)&&e.includes(`project`)?`both`:e.includes(`user`)?`user`:e.includes(`project`)?`project`:null}async function Kr(e){return e.mcp===!1?null:e.scope?e.scope:e.isTTY??process.stdout.isTTY?(e.promptFn??Gr)():`both`}const qr=`0.0.1`,Jr=`open-knowledge-ui`,Yr=[`-y`,`@inkeep/open-knowledge@latest`,`ui`];function Xr(e,t={}){let n=j(e,`.claude`,`launch.json`),r=t.cliPath===void 0?t.mode===`dev`?{name:Jr,runtimeExecutable:`node`,runtimeArgs:[cr(),`ui`],port:jr,autoPort:!0}:{name:Jr,runtimeExecutable:`npx`,runtimeArgs:[...Yr],port:jr,autoPort:!0}:{name:Jr,runtimeExecutable:t.cliPath,runtimeArgs:[`ui`],port:jr,autoPort:!0};try{if(nr(n,e),!L(n))return R(k(n),{recursive:!0}),B(n,`${JSON.stringify({version:qr,configurations:[r]},null,2)}\n`,`utf-8`),{action:`created`,configPath:n};let t=z(n,`utf-8`).trim(),i=t?JSON.parse(t):{};if(!w(i))return{action:`failed`,configPath:n,error:`launch.json root is not an object`};let a=Array.isArray(i.configurations)?i.configurations:[],o=a.findIndex(e=>w(e)&&e.name===`open-knowledge-ui`);o>=0?a[o]=r:a.push(r);let s={...i,version:i.version??qr,configurations:a};return B(n,`${JSON.stringify(s,null,2)}\n`,`utf-8`),{action:o>=0?`merged`:`created`,configPath:n}}catch(e){return{action:`failed`,configPath:n,error:e instanceof Error?e.message:String(e)}}}function Zr(e,t,n){try{return L(e.detectPath?.(t,n)??k(e.configPath(t,n)))}catch{return!1}}function Qr(e,t,n,r,i){let a=e.serverName(t),o;try{o=i??e.configPath(t,r)}catch(t){return{editorId:e.id,label:e.label,action:`failed`,configPath:``,serverName:a,error:t instanceof Error?t.message:String(t)}}if(!i&&!n.skipAvailabilityCheck&&!Zr(e,t,r))return{editorId:e.id,label:e.label,action:`skipped-missing`,configPath:o,serverName:a};if(i!==void 0)try{nr(o,t)}catch(t){return{editorId:e.id,label:e.label,action:`failed`,configPath:o,serverName:a,error:t instanceof Error?t.message:String(t),configScope:`project`}}let s;try{s=e.format===`toml`?Br(o):zr(o)}catch(t){return{editorId:e.id,label:e.label,action:`failed`,configPath:o,serverName:a,error:t instanceof Error?t.message:String(t)}}let c=s[e.topLevelKey]??{},l=c[a],u;try{u=e.buildEntry(t,n)}catch(t){return{editorId:e.id,label:e.label,action:`failed`,configPath:o,serverName:a,error:t instanceof Error?t.message:String(t)}}let d={...s,[e.topLevelKey]:{...c,[a]:u}};try{e.format===`toml`?Hr(o,d):Vr(o,d)}catch(t){return{editorId:e.id,label:e.label,action:`failed`,configPath:o,serverName:a,error:t instanceof Error?t.message:String(t)}}return{editorId:e.id,label:e.label,action:l===void 0?`written`:`overwritten`,configPath:o,serverName:a,...i===void 0?{}:{configScope:`project`}}}function $r(e,t){let n=e.projectConfigPath?.(t);if(!(!n||!L(n)))return{editorId:e.id,label:e.label,path:n}}async function ei(e){let t=br(e.editors),n={mode:`published`,cliPath:e.cliPath,skipAvailabilityCheck:!0};return t.map(t=>Qr(t,``,n,e.home))}function ti(e,t,n,r){let i=ni(e,t,n,r);return i.kind===`present`?i.entry:null}function ni(e,t,n,r){let i;try{i=r??e.configPath(t,n)}catch{return{kind:`absent`}}if(!L(i))return{kind:`absent`};let a;try{a=z(i,`utf-8`)}catch(e){return{kind:`corrupt`,error:e instanceof Error?e.message:String(e)}}if(a.trim()===``)return{kind:`corrupt`,error:`file is empty`};let o;try{o=e.format===`toml`?Br(i):zr(i)}catch(e){return{kind:`corrupt`,error:e instanceof Error?e.message:String(e)}}let s=o[e.topLevelKey];if(!w(s))return{kind:`no-entry`};let c=s[e.serverName(t)];return w(c)?{kind:`present`,entry:c}:{kind:`no-entry`}}async function ri(e={}){let t=P(e.cwd??process.cwd()),n=tr(t,{homeDir:e.home}),r=n.projectRoot,i=!L(j(r,`.ok`));n.ancestorPromoted?console.log(`[ok] Opened existing project at ${r}`):n.gitRootPromoted&&i&&console.log(`[ok] Initialized OK at ${r} — opened parent of ${N(r,t)} because it contains a .git folder`);let a={mode:e.devMcp?`dev`:`published`},o=await c(r),s;try{s=Qn(r,{contentDir:n.defaultContentDir})}catch(t){let n=Q.claude.configPath(r,e.home);return{projectRoot:r,contentCreated:[],contentUpdated:[],contentSkipped:[],editors:[],projectSkills:[],legacyProjectConfigs:[],didGitInit:o.didInit,claudeDesktopDetected:!1,mcpAction:`failed`,mcpPath:n,mcpError:`Content scaffolding failed: ${t instanceof Error?t.message:String(t)}`}}let l=await Kr({scope:e.scope,mcp:e.mcp,isTTY:e.isTTY,promptFn:e.promptFn}),u=e.editors??ai(r,e.home),d=e.editors??ir.filter(e=>Q[e].projectConfigPath!==void 0),f=br(u),p=br(d),m=e.mcp===!1||l===null,h=Array.from(new Map([...f,...m?[]:p].map(e=>[e.id,e])).values()),g=f.filter(t=>Zr(t,r,e.home)),_=[],v=[],b=new Set;for(let t of h){if(m){let n=``;try{n=t.configPath(r,e.home)}catch{}_.push({editorId:t.id,label:t.label,action:`skipped-flag`,configPath:n,serverName:t.serverName(r)});continue}if(Ur(l)&&f.includes(t)&&_.push(Qr(t,r,a,e.home)),Wr(l)&&p.includes(t)&&t.projectConfigPath){let n=t.projectConfigPath(r),i=Qr(t,r,a,e.home,n);_.push(i),(i.action===`written`||i.action===`overwritten`)&&b.add(n)}}for(let e of p)e.projectSkillPath&&v.push(rr(e,r));let x=!m&&l!==null&&Wr(l)?p.filter(e=>!e.projectConfigPath).map(e=>e.label):void 0,C=m?[]:g.map(e=>$r(e,r)).filter(e=>e!==void 0).filter(e=>!b.has(e.path)),ee=g.some(e=>e.id===`claude`)&&!m?Xr(r,a):void 0,te=await(e.installUserSkill??S)({home:e.home}),w=y({home:e.home}),T=m?`skipped-flag`:`skipped-missing`,E=_.find(e=>e.editorId===`claude`)??_[0]??{action:T,configPath:Q.claude.configPath(r,e.home)};return{projectRoot:r,contentCreated:s.created,contentUpdated:s.updated,contentSkipped:s.skipped,editors:_,projectSkills:v,legacyProjectConfigs:C,launchJson:ee,skillInstall:te,didGitInit:o.didInit,claudeDesktopDetected:w,mcpAction:E.action,mcpPath:E.configPath,mcpError:`error`in E?E.error:void 0,projectScopeUnsupportedLabels:x}}function ii(e,t){let n=[],r=e.editors.some(e=>e.action===`written`||e.action===`overwritten`),i=e.editors.some(e=>e.action===`failed`)||e.projectSkills.some(e=>e.action===`failed`),a=e.editors.length>0&&e.editors.every(e=>e.action===`skipped-flag`),o=e.editors.length>0&&e.editors.every(e=>e.action===`skipped-missing`),s=e=>{let n=e.configPath.startsWith(t)?N(t,e.configPath):e.configPath;switch(e.action){case`created`:return` app preview server ${n} configured for Claude Code Desktop embedded browser`;case`merged`:return` app preview server ${n} updated for Claude Code Desktop embedded browser`;case`failed`:return` app preview server ${n} FAILED: ${e.error}`}};e.didGitInit&&n.push(`Initialized git repo at ${t}/.git/ (default branch: main)`);let c=j(t,`.ok`);if(e.contentCreated.length>0||e.contentUpdated.length>0?(n.push(O(`Content scaffolded at ${c}/`)),e.contentCreated.length>0&&n.push(` Created: ${e.contentCreated.join(`, `)}`),e.contentUpdated.length>0&&n.push(` Updated: ${e.contentUpdated.join(`, `)}`)):n.push(O(`Content already present at ${c}/`)),e.contentSkipped.length>0&&n.push(` Skipped (already exist): ${e.contentSkipped.join(`, `)}`),n.push(``),e.mcpError&&e.editors.length===0)n.push(`Warning: ${e.mcpError}`);else if(e.editors.length===0)if(n.push(O(`MCP server configuration:`)),e.mcpAction===`skipped-flag`)n.push(` MCP config not written — use without --no-mcp to configure editors`);else if(e.projectScopeUnsupportedLabels&&e.projectScopeUnsupportedLabels.length>0){let t=e.projectScopeUnsupportedLabels.join(`, `),r=e.projectScopeUnsupportedLabels.length===1?`does`:`do`;n.push(` ${t} ${r} not support project-level config; skipped`)}else n.push(` No supported editor config directories detected; skipped MCP registration`);else if(a)n.push(`MCP config not written — use without --no-mcp to configure editors`);else if(o)n.push(O(`MCP server configuration:`)),n.push(` No supported editor config directories detected; skipped MCP registration`);else{n.push(O(`MCP server configuration:`));for(let r of e.editors){let i=r.configPath.startsWith(t)?N(t,r.configPath):r.configPath.replace(/^\/Users\/[^/]+/,`~`),a=r.serverName===`open-knowledge`?``:` (${r.serverName})`,o=r.configScope===`project`?` (project)`:``,c=`${r.label}${o}`,l=` `.repeat(Math.max(1,20-c.length)),u=r.editorId===`claude-desktop`&&(r.action===`written`||r.action===`overwritten`)?` — quit and relaunch Claude Desktop to activate`:``;switch(r.action){case`written`:n.push(` ${c}${l}${i} ${E(`registered`)}${a}${u}`);break;case`overwritten`:n.push(` ${c}${l}${i} ${E(`updated`)}${a}${u}`);break;case`skipped-missing`:n.push(` ${c}${l}${i} config root missing; skipped`);break;case`failed`:n.push(` ${c}${l}${i} ${ne(`FAILED`)}: ${r.error}`);break;case`skipped-flag`:break}r.editorId===`claude`&&e.launchJson&&n.push(s(e.launchJson))}if(e.projectScopeUnsupportedLabels&&e.projectScopeUnsupportedLabels.length>0){let t=e.projectScopeUnsupportedLabels.join(`, `),r=e.projectScopeUnsupportedLabels.length===1?`does`:`do`;n.push(` ${t} ${r} not support project-level config; skipped`)}}if(e.projectSkills.length>0){n.push(``),n.push(O(`Project-local skills:`));for(let r of e.projectSkills){let e=`${r.label} (project)`,i=` `.repeat(Math.max(1,20-e.length)),a=r.path?N(t,r.path):``;switch(r.action){case`written`:n.push(` ${e}${i}${a} ${E(`installed`)}`);break;case`overwritten`:n.push(` ${e}${i}${a} ${E(`updated`)}`);break;case`skipped-unsupported`:n.push(` ${e}${i}no known project skill surface; skipped`);break;case`failed`:n.push(` ${e}${i}${a} ${ne(`FAILED`)}: ${r.error}`);break}}}if(i&&(n.push(``),n.push(`For failed editors, add the MCP server entry or project skill manually. See:`),n.push(` https://github.com/inkeep/open-knowledge#mcp-setup`)),e.legacyProjectConfigs.length>0){n.push(``),n.push(`Project MCP configs found:`);for(let r of e.legacyProjectConfigs)n.push(` ${r.label} ${N(t,r.path)}`);n.push(` These project-local files may override the global config. Remove them if you want fully user-scoped MCP setup in this project.`)}if(e.skillInstall)switch(n.push(``),n.push(O(`User-global skill:`)),e.skillInstall){case`installed`:n.push(` open-knowledge ${E(`installed to detected agent hosts`)} via \`npx skills\``);break;case`skip-current`:n.push(` open-knowledge ${E(`already installed at current version`)}`);break;case`failed`:n.push(` ${D(`open-knowledge install failed — MCP still configured; run manually:`)}`),n.push(` ${D(` npx skills@~1.5.0 add <bundled-path> --agent '*' -g -y --copy`)}`);break}if(e.claudeDesktopDetected&&(n.push(``),n.push(`Claude Desktop App detected. To enable in Claude Chat & Cowork, run: ${O(`ok install-skill`)}`)),e.preview?(n.push(``),n.push(re(e.preview,t))):e.previewWarning&&(n.push(``),n.push(`Content preview unavailable: ${e.previewWarning}`)),r){let t=new Set,r=e.editors.filter(e=>e.action===`written`||e.action===`overwritten`).filter(e=>!t.has(e.editorId)&&t.add(e.editorId)).map(e=>e.label);n.push(``),n.push(`${E(`✓`)} ${O(`Next steps:`)}`),n.push(` 1. Open your editor (${T(r.join(` / `))})`),n.push(` 2. Approve the MCP server when prompted`),n.push(` 3. (Optional) scaffold the starter knowledge-base structure:`),n.push(` - ${T(`ok seed`)} — empty repo, Karpathy 3-layer`),n.push(` - ${T(`mcp__open-knowledge__discover`)} — existing repo, extract conventions`),n.push(` 4. Use the MCP workflow tools as you build the wiki:`),n.push(` - ${T(`mcp__open-knowledge__ingest`)} — capture an external source`),n.push(` - ${T(`mcp__open-knowledge__research`)} — gather sources and write findings`),n.push(` - ${T(`mcp__open-knowledge__consolidate`)} — promote research to canonical articles`)}return n.join(`
|
|
407
|
+
`)}function ai(e,t){let n=[];for(let r of ir)Zr(Q[r],e,t)&&n.push(r);return n}function oi(){return new i(`init`).description(`Scaffold .ok/ in the current directory and register the MCP server for your editor(s)`).option(`--mcp`,`Register the MCP server for selected editors (default: true)`,!0).option(`--no-mcp`,`Scaffold the .ok/ directory but do not touch MCP config`).option(`--dev-mcp`,`Register a local dev MCP entry using node + packages/cli/dist/cli.mjs with debug logging`).addOption(new r(`--scope <scope>`,`Write MCP config at user level, project level, or both`).choices([`user`,`project`,`both`])).action(async e=>{let t=process.cwd(),n;try{n=await ri({cwd:t,mcp:e.mcp,devMcp:e.devMcp,scope:e.scope})}catch(e){if(e instanceof s){process.stderr.write(`open-knowledge requires git to initialize a parent repo. Install git or run 'git init' yourself, then re-run.
|
|
408
|
+
`),e.stderr&&process.stderr.write(`${e.stderr.trim()}\n`),process.exitCode=1;return}throw e}try{let{previewContent:e}=await import(`./preview-DZKfHXsi.mjs`),{loadConfig:t}=await import(`./loader-BGK5A8F9.mjs`),{resolveContentDir:r}=await import(`./dist-7_PKsuCz.mjs`),{config:i}=t(n.projectRoot),a=r(i,n.projectRoot);n.preview=e({projectDir:n.projectRoot,contentDir:a})}catch(e){n.previewWarning=e instanceof Error?e.message:String(e)}process.stdout.write(`${ii(n,n.projectRoot)}\n`),(n.editors.some(e=>e.action===`failed`)||n.mcpAction===`failed`)&&(process.exitCode=1)})}export{Te as A,ut as C,ot as D,ht as E,Ye as O,lt as S,dt as T,or as _,ii as a,Qn as b,Kr as c,Qr as d,ei as f,Q as g,ar as h,ai as i,W as j,Je as k,ri as l,ir as m,Yr as n,oi as o,Lr as p,ni as r,ti as s,Jr as t,Xr as u,rr as v,pt as w,ft as x,tr as y};
|
|
409
|
+
//# sourceMappingURL=init-al09RZM6.mjs.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{Jr as e,f as t,fi as n,ji as r,qr as i,vi as a}from"./dist-soQLoIV1.mjs";import{t as o}from"./constants-
|
|
1
|
+
import{Jr as e,f as t,fi as n,ji as r,qr as i,vi as a}from"./dist-soQLoIV1.mjs";import{t as o}from"./constants-HL-7SyJ2.mjs";import{t as s}from"./is-object-C-4FJ0rP.mjs";import{resolve as c}from"node:path";import{existsSync as l,readFileSync as u}from"node:fs";import{realpath as d}from"node:fs/promises";async function f(e){let t=c(e);try{return await d(t)}catch(e){if(e.code!==`ENOENT`){let n=e instanceof Error?e.message:String(e);console.warn(`[normalize-cwd] realpath failed for ${t}: ${n}`)}return t}}var p=r();function m(e,t){let n={...e};for(let r of Object.keys(t)){let i=e[r],a=t[r];s(a)&&s(i)?n[r]=m(i,a):a!==void 0&&(n[r]=a)}return n}function h(e){if(!l(e))return{value:null,path:e,source:null,doc:null};let t;try{t=u(e,`utf-8`)}catch(t){return console.warn(`[config] Failed to read ${e}: ${t instanceof Error?t.message:t}`),{value:null,path:e,source:null,doc:null}}let n=(0,p.parseDocument)(t);if(n.errors.length>0)return console.warn(`[config] Failed to parse ${e}: ${n.errors.map(e=>e.message).join(`; `)}`),{value:null,path:e,source:t,doc:null};let r=n.toJSON();return s(r)?{value:r,path:e,source:t,doc:n}:{value:null,path:e,source:t,doc:n}}const g=[`include`,`exclude`];function _(e){let t="Run `ok config migrate` to strip the obsolete key from config.yml automatically, or remove it by hand.";return e===`exclude`?[`Move these patterns to .okignore at the project root (gitignore syntax, 1:1 migration).`,t].join(` `):[`content.include has been removed.`,`For subdirectory scoping, set content.dir in .ok/config.yml instead.`,`For pattern-based filtering, use .okignore (gitignore syntax — exclude-only; do not copy include patterns directly).`,t].join(` `)}function v(e){let t=e.value;if(!s(t))return[];let n=t.content;if(!s(n))return[];let r=[];for(let t of g)if(t in n){let n=[`content`,t],i;e.doc!==null&&e.source!==null&&(i=a({file:e.path,source:e.source,doc:e.doc,path:n})),r.push({code:`REMOVED_KEY`,path:n,redirect:_(t),...i===void 0?{}:{source:i}})}return r}function y(e,t){return e.map(e=>{let n=e.path.map(e=>typeof e==`symbol`?String(e):e),r={path:n,message:e.message,issueCode:e.code};if(t.doc!==null&&t.source!==null){let e=a({file:t.path,source:t.source,doc:t.doc,path:n});if(e!==void 0)return{...r,source:e}}return r})}function b(r){let a=r??process.cwd(),s=[],l=e(`user`,a),u=i({absPath:l}),d={};u.valid&&u.source!==void 0?(d=m(d,u.value),s.push(l)):u.valid;let f=c(a,`.ok`,o),p=h(f);if(p.value!==null){let e=v(p);if(e.length>0)throw Error(e.map(n).join(`
|
|
2
2
|
|
|
3
3
|
`));d=m(d,p.value),s.push(f)}x(d,[`upload`,`maxBytes`],`streaming uploads have no user-facing cap`),x(d,[`github`,`oauthAppClientId`],`use the OPEN_KNOWLEDGE_GITHUB_CLIENT_ID env var instead`),x(d,[`server`,`host`],`use the --host flag or HOST env var instead`),x(d,[`server`,`openOnAgentEdit`]),x(d,[`mcp`,`autoStart`],`to disable auto-start, set OK_MCP_AUTOSTART=0`),x(d,[`mcp`,`tools`,`read_document`,`historyDepth`]),x(d,[`mcp`,`tools`,`grep`,`maxResults`]),x(d,[`mcp`,`tools`,`search`,`maxResults`]),x(d,[`preview`,`baseUrl`],"preview URLs now resolve only to the running UI process — start one with `ok ui`");let g=t.safeParse(d);if(!g.success){let e={code:`SCHEMA_INVALID`,issues:y(g.error.issues,p)};throw Error(n(e))}return{config:g.data,sources:s}}function x(e,t,n){let r=e;for(let e=0;e<t.length-1;e++){if(!s(r))return;r=r[t[e]]}if(!s(r))return;let i=t[t.length-1];if(r[i]===void 0)return;let a=t.join(`.`);console.warn(`[config] ${a} is no longer user-configurable; ${n??`the value is hardcoded in @inkeep/open-knowledge-core`}. Remove the key to silence this warning.`)}function S(e){let t=e.cacheMs??1e3,n=e.loadConfigFn??b,r=new Map,i=new Map,a=f(e.startupCwd);return async o=>{let s=await f(o??e.startupCwd),c=Date.now(),l=r.get(s);if(l&&l.expiresAt>c)return l.config;let u=i.get(s);if(u)return await u;let d=(async()=>{if(s===await a)return r.set(s,{config:e.startupConfig,expiresAt:Date.now()+t}),e.startupConfig;let i=n(s).config;return r.set(s,{config:i,expiresAt:Date.now()+t}),i})();i.set(s,d);try{return await d}finally{i.delete(s)}}}export{b as n,S as t};
|
|
4
|
-
//# sourceMappingURL=loader-
|
|
4
|
+
//# sourceMappingURL=loader-B64XEbbD.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as e}from"./loader-B64XEbbD.mjs";export{e as loadConfig};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{bt as e}from"./dist-soQLoIV1.mjs";import"./constants-
|
|
1
|
+
import{bt as e}from"./dist-soQLoIV1.mjs";import"./constants-HL-7SyJ2.mjs";import{join as t,relative as n}from"node:path";import{existsSync as r,lstatSync as i,readdirSync as a,realpathSync as o,statSync as s}from"node:fs";function c(r){let{projectDir:c,contentDir:l,sampleCap:u=5}=r,d=[],f=[];try{i(l)}catch(e){return{totalCount:0,sample:[],contentDir:l,warnings:[`cannot access content directory ${l}: ${e instanceof Error?e.message:String(e)}`]}}let p;try{p=e({projectDir:c,contentDir:l})}catch(e){return{totalCount:0,sample:[],contentDir:l,warnings:[e instanceof Error?e.message:String(e)]}}function m(e){let r;try{r=a(e,{withFileTypes:!0})}catch(t){let r=t instanceof Error?t.message:String(t);d.push(`could not read directory ${n(l,e)||`.`}: ${r}`);return}for(let i of r){let r=t(e,i.name);if(i.isSymbolicLink()){let e;try{e=o(r)}catch(e){let t=e.code;t===`ENOENT`||t===`ELOOP`?d.push(`broken or cyclic symlink: ${n(l,r)}`):d.push(`cannot resolve symlink ${n(l,r)}: ${t??`unknown error`}`);continue}let t;try{t=s(e)}catch{continue}if(t.isDirectory()){let e=n(l,r);if(p.isDirExcluded(e))continue;m(r)}else if(t.isFile()){let e=n(l,r);if(p.isExcluded(e))continue;f.push(e)}}else if(i.isDirectory()){let e=n(l,r);if(p.isDirExcluded(e))continue;m(r)}else if(i.isFile()){let e=n(l,r);if(p.isExcluded(e))continue;f.push(e)}}}return m(l),{totalCount:f.length,sample:f.slice(0,u),contentDir:l,warnings:d}}function l(e,i){let a=[],o=n(i,e.contentDir),s=o===``?`./`:`./${o}`;if(a.push(`Content:`),a.push(` Found ${e.totalCount} markdown files in ${s}`),e.sample.length>0){let t=e.sample.join(`, `),n=e.totalCount>e.sample.length?`, …`:``;a.push(` Sample: ${t}${n}`)}if(e.warnings.length>0)for(let t of e.warnings)a.push(` Warning: ${t}`);return a.push(``),r(t(i,`.ok`,`config.yml`))?(a.push(` To adjust scope, add patterns to .okignore at the project root.`),a.push(` To change the content root, edit .ok/config.yml → content.dir.`)):a.push(" Run `open-knowledge init` to scaffold config + .okignore."),a.push(``),a.push(` Re-check anytime: open-knowledge preview`),a.join(`
|
|
2
2
|
`)}export{c as n,l as t};
|
|
3
|
-
//# sourceMappingURL=preview-
|
|
3
|
+
//# sourceMappingURL=preview-CYIUoqRn.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as e,t}from"./preview-CYIUoqRn.mjs";export{t as formatPreviewBlock,e as previewContent};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import{o as e,t}from"./chunk-CFjPhJqf.js";import{n,r,t as i}from"./compiler-runtime-CVnuRdak.js";import{An as a,E as o,M as s,Sn as c,jn as l,wn as u}from"./DocumentContext-CqL0pPxh.js";import{C as d,E as f,S as p,T as m,t as h,x as g}from"./dialog-B6QxSuMP.js";import{A as _,D as v,O as y,ai as b,c as x,di as S,dt as C,er as w,lt as T,oi as E,si as D,zn as O}from"./doc-hash-BUfOgpiD.js";import{C as k,S as A,g as j,t as M}from"./button-JrGyO3-P.js";import{At as N,B as P,F,I as ee,L as I,M as te,N as L,O as ne,P as re,Q as ie,R as ae,U as oe,V as R,W as se,X as ce,Z as le,_ as ue,a as de,b as fe,c as pe,d as me,f as he,g as ge,h as _e,i as ve,j as ye,kt as be,l as xe,lt as Se,m as Ce,n as we,o as Te,p as Ee,s as De,tt as Oe,u as ke,ut as z,v as Ae,z as je}from"./config-validation-events-BAWD3yoI.js";import{i as Me}from"./collapsible-CYwJ8q8x.js";import{n as Ne,t as Pe}from"./toggle-group-BvHaWPjZ.js";import{t as Fe}from"./label-Bdsqm1CY.js";var Ie=k(`rotate-ccw`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}]]),B=i(),V=e(n(),1),Le=e=>e.type===`checkbox`,Re=e=>e instanceof Date,H=e=>e==null,ze=e=>typeof e==`object`,U=e=>!H(e)&&!Array.isArray(e)&&ze(e)&&!Re(e),Be=e=>U(e)&&e.target?Le(e.target)?e.target.checked:e.target.value:e,Ve=(e,t)=>t.split(`.`).some((t,n,r)=>!isNaN(Number(t))&&e.has(r.slice(0,n).join(`.`))),He=e=>{let t=e.constructor&&e.constructor.prototype;return U(t)&&t.hasOwnProperty(`isPrototypeOf`)},Ue=typeof window<`u`&&window.HTMLElement!==void 0&&typeof document<`u`;function W(e){if(e instanceof Date)return new Date(e);let t=typeof FileList<`u`&&e instanceof FileList;if(Ue&&(e instanceof Blob||t))return e;let n=Array.isArray(e);if(!n&&!(U(e)&&He(e)))return e;let r=n?[]:Object.create(Object.getPrototypeOf(e));for(let t in e)Object.prototype.hasOwnProperty.call(e,t)&&(r[t]=W(e[t]));return r}var We=e=>/^\w*$/.test(e),G=e=>e===void 0,Ge=e=>Array.isArray(e)?e.filter(Boolean):[],Ke=e=>Ge(e.replace(/["|']|\]/g,``).split(/\.|\[/)),K=(e,t,n)=>{if(!t||!U(e))return n;let r=(We(t)?[t]:Ke(t)).reduce((e,t)=>H(e)?void 0:e[t],e);return G(r)||r===e?G(e[t])?n:e[t]:r},q=e=>typeof e==`boolean`,J=e=>typeof e==`function`,Y=(e,t,n)=>{let r=-1,i=We(t)?[t]:Ke(t),a=i.length,o=a-1;for(;++r<a;){let t=i[r],a=n;if(r!==o){let n=e[t];a=U(n)||Array.isArray(n)?n:isNaN(+i[r+1])?{}:[]}if(t===`__proto__`||t===`constructor`||t===`prototype`)return;e[t]=a,e=e[t]}},qe={BLUR:`blur`,FOCUS_OUT:`focusout`,CHANGE:`change`,SUBMIT:`submit`,TRIGGER:`trigger`,VALID:`valid`},Je={onBlur:`onBlur`,onChange:`onChange`,onSubmit:`onSubmit`,onTouched:`onTouched`,all:`all`},Ye={max:`max`,min:`min`,maxLength:`maxLength`,minLength:`minLength`,pattern:`pattern`,required:`required`,validate:`validate`},Xe=`form`,Ze=`root`,Qe=V.createContext(null);Qe.displayName=`HookFormControlContext`;var $e=()=>V.useContext(Qe),et=(e,t,n,r=!0)=>{let i={defaultValues:t._defaultValues};for(let a in e)Object.defineProperty(i,a,{get:()=>{let i=a;return t._proxyFormState[i]!==Je.all&&(t._proxyFormState[i]=!r||Je.all),n&&(n[i]=!0),e[i]}});return i},tt=typeof window<`u`?V.useLayoutEffect:V.useEffect;function nt(e){let t=$e(),{control:n=t,disabled:r,name:i,exact:a}=e||{},[o,s]=V.useState(n._formState),c=V.useRef({isDirty:!1,isLoading:!1,dirtyFields:!1,touchedFields:!1,validatingFields:!1,isValidating:!1,isValid:!1,errors:!1});return tt(()=>n._subscribe({name:i,formState:c.current,exact:a,callback:e=>{!r&&s({...n._formState,...e})}}),[i,r,a]),V.useEffect(()=>{c.current.isValid&&n._setValid(!0)},[n]),V.useMemo(()=>et(o,n,c.current,!1),[o,n])}var X=e=>typeof e==`string`,rt=(e,t,n,r,i)=>X(e)?(r&&t.watch.add(e),K(n,e,i)):Array.isArray(e)?e.map(e=>(r&&t.watch.add(e),K(n,e))):(r&&(t.watchAll=!0),n),it=e=>H(e)||!ze(e);function at(e,t,n=new WeakSet){if(e===t)return!0;if(it(e)||it(t))return Object.is(e,t);if(Re(e)&&Re(t))return Object.is(e.getTime(),t.getTime());let r=Object.keys(e),i=Object.keys(t);if(r.length!==i.length)return!1;if(n.has(e)||n.has(t))return!0;n.add(e),n.add(t);for(let i of r){let r=e[i];if(!(i in t))return!1;if(i!==`ref`){let e=t[i];if(Re(r)&&Re(e)||(U(r)||Array.isArray(r))&&(U(e)||Array.isArray(e))?!at(r,e,n):!Object.is(r,e))return!1}}return!0}function ot(e){let t=$e(),{control:n=t,name:r,defaultValue:i,disabled:a,exact:o,compute:s}=e||{},c=V.useRef(i),l=V.useRef(s),u=V.useRef(void 0),d=V.useRef(n),f=V.useRef(r);l.current=s;let[p,m]=V.useState(()=>{let e=n._getWatch(r,c.current);return l.current?l.current(e):e}),h=V.useCallback(e=>{let t=rt(r,n._names,e||n._formValues,!1,c.current);return l.current?l.current(t):t},[n._formValues,n._names,r]),g=V.useCallback(e=>{if(!a){let t=rt(r,n._names,e||n._formValues,!1,c.current);if(l.current){let e=l.current(t);at(e,u.current)||(m(e),u.current=e)}else m(t)}},[n._formValues,n._names,a,r]);tt(()=>((d.current!==n||!at(f.current,r))&&(d.current=n,f.current=r,g()),n._subscribe({name:r,formState:{values:!0},exact:o,callback:e=>{g(e.values)}})),[n,o,r,g]),V.useEffect(()=>n._removeUnmounted());let _=d.current!==n,v=f.current,y=V.useMemo(()=>{if(a)return null;let e=!_&&!at(v,r);return _||e?h():null},[a,_,r,v,h]);return y===null?p:y}function st(e){let t=$e(),{name:n,disabled:r,control:i=t,shouldUnregister:a,defaultValue:o,exact:s=!0}=e,c=Ve(i._names.array,n),l=ot({control:i,name:n,defaultValue:V.useMemo(()=>K(i._formValues,n,K(i._defaultValues,n,o)),[i,n,o]),exact:s}),u=nt({control:i,name:n,exact:s}),d=V.useRef(e),f=V.useRef(i.register(n,{...e.rules,value:l,...q(e.disabled)?{disabled:e.disabled}:{}}));d.current=e;let p=V.useMemo(()=>Object.defineProperties({},{invalid:{enumerable:!0,get:()=>!!K(u.errors,n)},isDirty:{enumerable:!0,get:()=>!!K(u.dirtyFields,n)},isTouched:{enumerable:!0,get:()=>!!K(u.touchedFields,n)},isValidating:{enumerable:!0,get:()=>!!K(u.validatingFields,n)},error:{enumerable:!0,get:()=>K(u.errors,n)}}),[u,n]),m=V.useCallback(e=>f.current.onChange({target:{value:Be(e),name:n},type:qe.CHANGE}),[n]),h=V.useCallback(()=>f.current.onBlur({target:{value:K(i._formValues,n),name:n},type:qe.BLUR}),[n,i._formValues]),g=V.useCallback(e=>{let t=K(i._fields,n);t&&t._f&&e&&(t._f.ref={focus:()=>J(e.focus)&&e.focus(),select:()=>J(e.select)&&e.select(),setCustomValidity:t=>J(e.setCustomValidity)&&e.setCustomValidity(t),reportValidity:()=>J(e.reportValidity)&&e.reportValidity()})},[i._fields,n]),_=V.useMemo(()=>({name:n,value:l,...q(r)||u.disabled?{disabled:u.disabled||r}:{},onChange:m,onBlur:h,ref:g}),[n,r,u.disabled,m,h,g,l]);return V.useEffect(()=>{let e=i._options.shouldUnregister||a;i.register(n,{...d.current.rules,...q(d.current.disabled)?{disabled:d.current.disabled}:{}});let t=(e,t)=>{let n=K(i._fields,e);n&&n._f&&(n._f.mount=t)};if(t(n,!0),e){let e=W(K(i._options.defaultValues,n,d.current.defaultValue));Y(i._defaultValues,n,e),G(K(i._formValues,n))&&Y(i._formValues,n,e)}return!c&&i.register(n),()=>{(c?e&&!i._state.action:e)?i.unregister(n):t(n,!1)}},[n,i,c,a]),V.useEffect(()=>{i._setDisabledField({disabled:r,name:n})},[r,n,i]),V.useMemo(()=>({field:_,formState:u,fieldState:p}),[_,u,p])}var ct=e=>e.render(st(e)),lt=V.createContext(null);lt.displayName=`HookFormContext`;var ut=()=>V.useContext(lt),dt=e=>{let{children:t,watch:n,getValues:r,getFieldState:i,setError:a,clearErrors:o,setValue:s,trigger:c,formState:l,resetField:u,reset:d,handleSubmit:f,unregister:p,control:m,register:h,setFocus:g,subscribe:_}=e,v=V.useMemo(()=>({watch:n,getValues:r,getFieldState:i,setError:a,clearErrors:o,setValue:s,trigger:c,formState:l,resetField:u,reset:d,handleSubmit:f,unregister:p,control:m,register:h,setFocus:g,subscribe:_}),[o,m,l,i,r,f,h,d,u,a,g,s,_,c,p,n]);return V.createElement(lt.Provider,{value:v},V.createElement(Qe.Provider,{value:v.control},t))},ft=(e,t,n,r,i)=>t?{...n[e],types:{...n[e]&&n[e].types?n[e].types:{},[r]:i||!0}}:{},pt=e=>Array.isArray(e)?e:[e],mt=()=>{let e=[];return{get observers(){return e},next:t=>{for(let n of e)n.next&&n.next(t)},subscribe:t=>(e.push(t),{unsubscribe:()=>{e=e.filter(e=>e!==t)}}),unsubscribe:()=>{e=[]}}};function ht(e,t){let n={};for(let r in e)if(e.hasOwnProperty(r)){let i=e[r],a=t[r];if(i&&U(i)&&a){let e=ht(i,a);U(e)&&(n[r]=e)}else e[r]&&(n[r]=a)}return n}var Z=e=>U(e)&&!Object.keys(e).length,gt=e=>e.type===`file`,_t=e=>{if(!Ue)return!1;let t=e?e.ownerDocument:0;return e instanceof(t&&t.defaultView?t.defaultView.HTMLElement:HTMLElement)},vt=e=>e.type===`select-multiple`,yt=e=>e.type===`radio`,bt=e=>yt(e)||Le(e),xt=e=>_t(e)&&e.isConnected;function St(e,t){let n=t.slice(0,-1).length,r=0;for(;r<n;){if(H(e)){e=void 0;break}e=e[t[r]],r++}return e}function Ct(e){for(let t in e)if(e.hasOwnProperty(t)&&!G(e[t]))return!1;return!0}function Q(e,t){if(X(t)&&Object.prototype.hasOwnProperty.call(e,t))return delete e[t],e;let n=Array.isArray(t)?t:We(t)?[t]:Ke(t),r=n.length===1?e:St(e,n),i=n.length-1,a=n[i];return r&&delete r[a],i!==0&&(U(r)&&Z(r)||Array.isArray(r)&&Ct(r))&&Q(e,n.slice(0,-1)),e}var wt=e=>{for(let t in e)if(J(e[t]))return!0;return!1};function Tt(e){return Array.isArray(e)||U(e)&&!wt(e)}function Et(e,t={}){for(let n in e){let r=e[n];Tt(r)?(t[n]=Array.isArray(r)?[]:{},Et(r,t[n])):G(r)||(t[n]=!0)}return t}function Dt(e,t,n){n||=Et(t);for(let r in e){let i=e[r];if(Tt(i))G(t)||it(n[r])?n[r]=Et(i,Array.isArray(i)?[]:{}):Dt(i,H(t)?{}:t[r],n[r]);else{let e=t[r];n[r]=!at(i,e)}}return n}var Ot={value:!1,isValid:!1},kt={value:!0,isValid:!0},At=e=>{if(Array.isArray(e)){if(e.length>1){let t=e.filter(e=>e&&e.checked&&!e.disabled).map(e=>e.value);return{value:t,isValid:!!t.length}}return e[0].checked&&!e[0].disabled?e[0].attributes&&!G(e[0].attributes.value)?G(e[0].value)||e[0].value===``?kt:{value:e[0].value,isValid:!0}:kt:Ot}return Ot},jt=(e,{valueAsNumber:t,valueAsDate:n,setValueAs:r})=>G(e)?e:t?e===``?NaN:e&&+e:n&&X(e)?new Date(e):r?r(e):e,Mt={isValid:!1,value:null},Nt=e=>Array.isArray(e)?e.reduce((e,t)=>t&&t.checked&&!t.disabled?{isValid:!0,value:t.value}:e,Mt):Mt;function Pt(e){let t=e.ref;return gt(t)?t.files:yt(t)?Nt(e.refs).value:vt(t)?[...t.selectedOptions].map(({value:e})=>e):Le(t)?At(e.refs).value:jt(G(t.value)?e.ref.value:t.value,e)}var Ft=e=>e.substring(0,e.search(/\.\d+(\.|$)/))||e,It=(e,t,n,r)=>{let i={};for(let n of e){let e=K(t,n);e&&Y(i,n,e._f)}return{criteriaMode:n,names:[...e],fields:i,shouldUseNativeValidation:r}},Lt=e=>e instanceof RegExp,Rt=e=>G(e)?e:Lt(e)?e.source:U(e)?Lt(e.value)?e.value.source:e.value:e,zt=e=>({isOnSubmit:!e||e===Je.onSubmit,isOnBlur:e===Je.onBlur,isOnChange:e===Je.onChange,isOnAll:e===Je.all,isOnTouch:e===Je.onTouched}),Bt=`AsyncFunction`,Vt=e=>!!e&&!!e.validate&&!!(J(e.validate)&&e.validate.constructor.name===Bt||U(e.validate)&&Object.values(e.validate).find(e=>e.constructor.name===Bt)),Ht=e=>e.mount&&(e.required||e.min||e.max||e.maxLength||e.minLength||e.pattern||e.validate),Ut=(e,t,n)=>!n&&(t.watchAll||t.watch.has(e)||[...t.watch].some(t=>e.startsWith(t)&&/^\.\w+/.test(e.slice(t.length)))),Wt=(e,t,n,r)=>{for(let i of n||Object.keys(e)){let n=K(e,i);if(n){let{_f:e,...a}=n;if(e){if(e.refs&&e.refs[0]&&t(e.refs[0],i)&&!r||e.ref&&t(e.ref,e.name)&&!r)return!0;if(Wt(a,t))break}else if(U(a)&&Wt(a,t))break}}};function Gt(e,t,n){let r=K(e,n);if(r||We(n))return{error:r,name:n};let i=n.split(`.`);for(;i.length;){let r=i.join(`.`),a=K(t,r),o=K(e,r);if(a&&!Array.isArray(a)&&n!==r)return{name:n};if(o&&o.type)return{name:r,error:o};if(o&&o.root&&o.root.type)return{name:`${r}.root`,error:o.root};i.pop()}return{name:n}}var Kt=(e,t,n,r)=>{n(e);let{name:i,...a}=e;return Z(a)||Object.keys(a).length>=Object.keys(t).length||Object.keys(a).find(e=>t[e]===(!r||Je.all))},qt=(e,t,n)=>!e||!t||e===t||pt(e).some(e=>e&&(n?e===t:e.startsWith(t)||t.startsWith(e))),Jt=(e,t,n,r,i)=>i.isOnAll?!1:!n&&i.isOnTouch?!(t||e):(n?r.isOnBlur:i.isOnBlur)?!e:(n?r.isOnChange:i.isOnChange)?e:!0,Yt=(e,t)=>!Ge(K(e,t)).length&&Q(e,t),Xt=(e,t,n)=>{let r=pt(K(e,n));return Y(r,Ze,t[n]),Y(e,n,r),e};function Zt(e,t,n=`validate`){if(X(e)||Array.isArray(e)&&e.every(X)||q(e)&&!e)return{type:n,message:X(e)?e:``,ref:t}}var Qt=e=>U(e)&&!Lt(e)?e:{value:e,message:``},$t=async(e,t,n,r,i,a)=>{let{ref:o,refs:s,required:c,maxLength:l,minLength:u,min:d,max:f,pattern:p,validate:m,name:h,valueAsNumber:g,mount:_}=e._f,v=K(n,h);if(!_||t.has(h))return{};let y=s?s[0]:o,b=e=>{i&&y.reportValidity&&(y.setCustomValidity(q(e)?``:e||``),y.reportValidity())},x={},S=yt(o),C=Le(o),w=S||C,T=(g||gt(o))&&G(o.value)&&G(v)||_t(o)&&o.value===``||v===``||Array.isArray(v)&&!v.length||g&&typeof v==`number`&&isNaN(v),E=ft.bind(null,h,r,x),D=(e,t,n,r=Ye.maxLength,i=Ye.minLength)=>{let a=e?t:n;x[h]={type:e?r:i,message:a,ref:o,...E(e?r:i,a)}};if(a?!Array.isArray(v)||!v.length:c&&(!w&&(T||H(v))||q(v)&&!v||C&&!At(s).isValid||S&&!Nt(s).isValid)){let{value:e,message:t}=X(c)?{value:!!c,message:c}:Qt(c);if(e&&(x[h]={type:Ye.required,message:t,ref:y,...E(Ye.required,t)},!r))return b(t),x}if(!T&&(!H(d)||!H(f))){let e,t,n=Qt(f),i=Qt(d);if(!H(v)&&!isNaN(v)){let r=o.valueAsNumber||v&&+v;H(n.value)||(e=r>n.value),H(i.value)||(t=r<i.value)}else{let r=o.valueAsDate||new Date(v),a=e=>new Date(new Date().toDateString()+` `+e),s=o.type==`time`,c=o.type==`week`;X(n.value)&&v&&(e=s?a(v)>a(n.value):c?v>n.value:r>new Date(n.value)),X(i.value)&&v&&(t=s?a(v)<a(i.value):c?v<i.value:r<new Date(i.value))}if((e||t)&&(D(!!e,n.message,i.message,Ye.max,Ye.min),!r))return b(x[h].message),x}if((l||u)&&!T&&(X(v)||a&&Array.isArray(v))){let e=Qt(l),t=Qt(u),n=!H(e.value)&&v.length>+e.value,i=!H(t.value)&&v.length<+t.value;if((n||i)&&(D(n,e.message,t.message),!r))return b(x[h].message),x}if(p&&!T&&X(v)){let{value:e,message:t}=Qt(p);if(Lt(e)&&!v.match(e)&&(x[h]={type:Ye.pattern,message:t,ref:o,...E(Ye.pattern,t)},!r))return b(t),x}if(m){if(J(m)){let e=Zt(await m(v,n),y);if(e&&(x[h]={...e,...E(Ye.validate,e.message)},!r))return b(e.message),x}else if(U(m)){let e={};for(let t in m){if(!Z(e)&&!r)break;let i=Zt(await m[t](v,n),y,t);i&&(e={...i,...E(t,i.message)},b(i.message),r&&(x[h]=e))}if(!Z(e)&&(x[h]={ref:y,...e},!r))return x}}return b(!0),x},en={mode:Je.onSubmit,reValidateMode:Je.onChange,shouldFocusError:!0};function tn(e={}){let t={...en,...e},n={submitCount:0,isDirty:!1,isReady:!1,isLoading:J(t.defaultValues),isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{},errors:t.errors||{},disabled:t.disabled||!1},r={},i=(U(t.defaultValues)||U(t.values))&&W(t.defaultValues||t.values)||{},a=t.shouldUnregister?{}:W(i),o={action:!1,mount:!1,watch:!1,keepIsValid:!1},s={mount:new Set,disabled:new Set,unMount:new Set,array:new Set,watch:new Set,registerName:new Set},c,l=0,u={isDirty:!1,dirtyFields:!1,validatingFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1},d={...u},f={...d},p={array:mt(),state:mt()},m=t.criteriaMode===Je.all,h=e=>t=>{clearTimeout(l),l=setTimeout(e,t)},g=async e=>{if(!o.keepIsValid&&!t.disabled&&(d.isValid||f.isValid||e)){let e;t.resolver?(e=Z((await T()).errors),_()):e=await O({fields:r,onlyCheckValid:!0,eventType:qe.VALID}),e!==n.isValid&&p.state.next({isValid:e})}},_=(e,r)=>{!t.disabled&&(d.isValidating||d.validatingFields||f.isValidating||f.validatingFields)&&((e||Array.from(s.mount)).forEach(e=>{e&&(r?Y(n.validatingFields,e,r):Q(n.validatingFields,e))}),p.state.next({validatingFields:n.validatingFields,isValidating:!Z(n.validatingFields)}))},v=e=>{let t=Dt(i,a),r=Ft(e);Y(n.dirtyFields,r,K(t,r))},y=(e,i=[],s,c,l=!0,u=!0)=>{if(c&&s&&!t.disabled){if(o.action=!0,u&&Array.isArray(K(r,e))){let t=s(K(r,e),c.argA,c.argB);l&&Y(r,e,t)}if(u&&Array.isArray(K(n.errors,e))){let t=s(K(n.errors,e),c.argA,c.argB);l&&Y(n.errors,e,t),Yt(n.errors,e)}if((d.touchedFields||f.touchedFields)&&u&&Array.isArray(K(n.touchedFields,e))){let t=s(K(n.touchedFields,e),c.argA,c.argB);l&&Y(n.touchedFields,e,t)}(d.dirtyFields||f.dirtyFields)&&v(e),p.state.next({name:e,isDirty:A(e,i),dirtyFields:n.dirtyFields,errors:n.errors,isValid:n.isValid})}else Y(a,e,i)},b=(e,t)=>{Y(n.errors,e,t),p.state.next({errors:n.errors})},x=e=>{n.errors=e,p.state.next({errors:n.errors,isValid:!1})},S=(e,t,n,s)=>{let c=K(r,e);if(c){let r=K(a,e,G(n)?K(i,e):n);G(r)||s&&s.defaultChecked||t?Y(a,e,t?r:Pt(c._f)):N(e,r),o.mount&&!o.action&&g()}},C=(e,r,a,o,s)=>{let c=!1,l=!1,u={name:e};if(!t.disabled){if(!a||o){(d.isDirty||f.isDirty)&&(l=n.isDirty,n.isDirty=u.isDirty=A(),c=l!==u.isDirty);let t=at(K(i,e),r);l=!!K(n.dirtyFields,e),t?Q(n.dirtyFields,e):Y(n.dirtyFields,e,!0),u.dirtyFields=n.dirtyFields,c||=(d.dirtyFields||f.dirtyFields)&&l!==!t}if(a){let t=K(n.touchedFields,e);t||(Y(n.touchedFields,e,a),u.touchedFields=n.touchedFields,c||=(d.touchedFields||f.touchedFields)&&t!==a)}c&&s&&p.state.next(u)}return c?u:{}},w=(e,r,i,a)=>{let o=K(n.errors,e),s=(d.isValid||f.isValid)&&q(r)&&n.isValid!==r;if(t.delayError&&i?(c=h(()=>b(e,i)),c(t.delayError)):(clearTimeout(l),c=null,i?Y(n.errors,e,i):Q(n.errors,e)),(i?!at(o,i):o)||!Z(a)||s){let t={...a,...s&&q(r)?{isValid:r}:{},errors:n.errors,name:e};n={...n,...t},p.state.next(t)}},T=async e=>(_(e,!0),await t.resolver(a,t.context,It(e||s.mount,r,t.criteriaMode,t.shouldUseNativeValidation))),E=async e=>{let{errors:t}=await T(e);if(_(e),e)for(let r of e){let e=K(t,r);e?Y(n.errors,r,e):Q(n.errors,r)}else n.errors=t;return t},D=async({name:t,eventType:r})=>{if(e.validate){let i=await e.validate({formValues:a,formState:n,name:t,eventType:r});if(U(i))for(let e in i)i[e]&&ae(`${Xe}.${e}`,{message:X(i.message)?i.message:``,type:Ye.validate});else X(i)||!i?ae(Xe,{message:i||``,type:Ye.validate}):ie(Xe);return i}return!0},O=async({fields:r,onlyCheckValid:i,name:o,eventType:c,context:l={valid:!0,runRootValidation:!1}})=>{if(e.validate&&(l.runRootValidation=!0,!await D({name:o,eventType:c})&&(l.valid=!1,i)))return l.valid;for(let o in r){let u=r[o];if(u){let{_f:r,...f}=u;if(r){let o=s.array.has(r.name),c=u._f&&Vt(u._f);c&&d.validatingFields&&_([r.name],!0);let f=await $t(u,s.disabled,a,m,t.shouldUseNativeValidation&&!i,o);if(c&&d.validatingFields&&_([r.name]),f[r.name]&&(l.valid=!1,i)||(!i&&(K(f,r.name)?o?Xt(n.errors,f,r.name):Y(n.errors,r.name,f[r.name]):Q(n.errors,r.name)),e.shouldUseNativeValidation&&f[r.name]))break}!Z(f)&&await O({context:l,onlyCheckValid:i,fields:f,name:o,eventType:c})}}return l.valid},k=()=>{for(let e of s.unMount){let t=K(r,e);t&&(t._f.refs?t._f.refs.every(e=>!xt(e)):!xt(t._f.ref))&&ce(e)}s.unMount=new Set},A=(e,n)=>!t.disabled&&(e&&n&&Y(a,e,n),!at(ne(),i)),j=(e,t,n)=>rt(e,s,{...o.mount?a:G(t)?i:X(e)?{[e]:t}:t},n,t),M=e=>Ge(K(o.mount?a:i,e,t.shouldUnregister?K(i,e,[]):[])),N=(e,t,n={})=>{let i=K(r,e),o=t;if(i){let n=i._f;n&&(!n.disabled&&Y(a,e,jt(t,n)),o=_t(n.ref)&&H(t)?``:t,vt(n.ref)?[...n.ref.options].forEach(e=>e.selected=o.includes(e.value)):n.refs?Le(n.ref)?n.refs.forEach(e=>{(!e.defaultChecked||!e.disabled)&&(Array.isArray(o)?e.checked=!!o.find(t=>t===e.value):e.checked=o===e.value||!!o)}):n.refs.forEach(e=>e.checked=e.value===o):gt(n.ref)?n.ref.value=``:(n.ref.value=o,n.ref.type||p.state.next({name:e,values:W(a)})))}(n.shouldDirty||n.shouldTouch)&&C(e,o,n.shouldTouch,n.shouldDirty,!0),n.shouldValidate&&L(e)},P=(e,t,n)=>{for(let i in t){if(!t.hasOwnProperty(i))return;let a=t[i],o=e+`.`+i,c=K(r,o);(s.array.has(e)||U(a)||c&&!c._f)&&!Re(a)?P(o,a,n):N(o,a,n)}},F=(e,t,i={})=>{let c=K(r,e),l=s.array.has(e),u=W(t),d=at(K(a,e),u);if(Y(a,e,u),l)p.array.next({name:e,values:W(a)}),i.shouldDirty&&(v(e),p.state.next({name:e,dirtyFields:n.dirtyFields,isDirty:A(e,u)}));else{let t=Array.isArray(u)&&!u.length||Z(u);!c||c._f||H(u)||t?N(e,u,i):P(e,u,i)}d||(Ut(e,s)?p.state.next({...n,name:e,values:W(a)}):p.state.next({name:o.mount?e:void 0,values:W(a)}))},ee=e=>{let t=J(e)?e(a):e;at(a,t)||(a={...a,...t},p.state.next({...n,values:a}))},I=async i=>{o.mount=!0;let l=i.target,u=l.name,h=!0,v=K(r,u),y=e=>{h=Number.isNaN(e)||Re(e)&&isNaN(e.getTime())||at(e,K(a,u,e))},b=zt(t.mode),x=zt(t.reValidateMode);if(v){let o,S,E=l.type?Pt(v._f):Be(i),k=i.type===qe.BLUR||i.type===qe.FOCUS_OUT,A=!Ht(v._f)&&!e.validate&&!t.resolver&&!K(n.errors,u)&&!v._f.deps||Jt(k,K(n.touchedFields,u),n.isSubmitted,x,b),j=Ut(u,s,k);Y(a,u,E),k?(!l||!l.readOnly)&&(v._f.onBlur&&v._f.onBlur(i),c&&c(0)):v._f.onChange&&v._f.onChange(i);let M=C(u,E,k),N=!Z(M)||j;if(!k&&p.state.next({name:u,type:i.type,values:W(a)}),A)return(d.isValid||f.isValid)&&(t.mode===`onBlur`?k&&g():k||g()),N&&p.state.next({name:u,...j?{}:M});if(!t.resolver&&e.validate&&await D({name:u,eventType:i.type}),!k&&j&&p.state.next({...n}),t.resolver){let{errors:e}=await T([u]);if(_([u]),y(E),h){let t=Gt(n.errors,r,u),i=Gt(e,r,t.name||u);o=i.error,u=i.name,S=Z(e)}}else _([u],!0),o=(await $t(v,s.disabled,a,m,t.shouldUseNativeValidation))[u],_([u]),y(E),h&&(o?S=!1:(d.isValid||f.isValid)&&(S=await O({fields:r,onlyCheckValid:!0,name:u,eventType:i.type})));h&&(v._f.deps&&(!Array.isArray(v._f.deps)||v._f.deps.length>0)&&L(v._f.deps),w(u,S,o,M))}},te=(e,t)=>{if(K(n.errors,t)&&e.focus)return e.focus(),1},L=async(e,i={})=>{let a,o,c=pt(e);if(t.resolver){let t=await E(G(e)?e:c);a=Z(t),o=e?!c.some(e=>K(t,e)):a}else e?(o=(await Promise.all(c.map(async e=>{let t=K(r,e);return await O({fields:t&&t._f?{[e]:t}:t,eventType:qe.TRIGGER})}))).every(Boolean),!(!o&&!n.isValid)&&g()):o=a=await O({fields:r,name:e,eventType:qe.TRIGGER});return p.state.next({...!X(e)||(d.isValid||f.isValid)&&a!==n.isValid?{}:{name:e},...t.resolver||!e?{isValid:a}:{},errors:n.errors}),i.shouldFocus&&!o&&Wt(r,te,e?c:s.mount),o},ne=(e,t)=>{let r={...o.mount?a:i};return t&&(r=ht(t.dirtyFields?n.dirtyFields:n.touchedFields,r)),G(e)?r:X(e)?K(r,e):e.map(e=>K(r,e))},re=(e,t)=>({invalid:!!K((t||n).errors,e),isDirty:!!K((t||n).dirtyFields,e),error:K((t||n).errors,e),isValidating:!!K(n.validatingFields,e),isTouched:!!K((t||n).touchedFields,e)}),ie=e=>{let t=e?pt(e):void 0;t?.forEach(e=>Q(n.errors,e)),t?t.forEach(e=>{p.state.next({name:e,errors:n.errors})}):p.state.next({errors:{}})},ae=(e,t,i)=>{let a=(K(r,e,{_f:{}})._f||{}).ref,{ref:o,message:s,type:c,...l}=K(n.errors,e)||{};Y(n.errors,e,{...l,...t,ref:a}),p.state.next({name:e,errors:n.errors,isValid:!1}),i&&i.shouldFocus&&a&&a.focus&&a.focus()},oe=(e,t)=>J(e)?p.state.subscribe({next:n=>`values`in n&&e(n.values||j(void 0,t),n)}):j(e,t,!0),R=e=>p.state.subscribe({next:t=>{if(qt(e.name,t.name,e.exact)&&Kt(t,e.formState||d,ve,e.reRenderRoot)){let r={...a};e.callback({values:r,...n,...t,defaultValues:i})}}}).unsubscribe,se=e=>(o.mount=!0,f={...f,...e.formState},R({...e,formState:{...u,...e.formState}})),ce=(e,o={})=>{for(let c of e?pt(e):s.mount)s.mount.delete(c),s.array.delete(c),o.keepValue||(Q(r,c),Q(a,c)),!o.keepError&&Q(n.errors,c),!o.keepDirty&&Q(n.dirtyFields,c),!o.keepTouched&&Q(n.touchedFields,c),!o.keepIsValidating&&Q(n.validatingFields,c),!t.shouldUnregister&&!o.keepDefaultValue&&Q(i,c);p.state.next({values:W(a)}),p.state.next({...n,...o.keepDirty?{isDirty:A()}:{}}),!o.keepIsValid&&g()},le=({disabled:e,name:t})=>{if(q(e)&&o.mount||e||s.disabled.has(t)){let n=s.disabled.has(t)!==!!e;e?s.disabled.add(t):s.disabled.delete(t),n&&o.mount&&!o.action&&g()}},ue=(e,n={})=>{let a=K(r,e),c=q(n.disabled)||q(t.disabled),l=!s.registerName.has(e)&&a&&a._f&&!a._f.mount;return Y(r,e,{...a||{},_f:{...a&&a._f?a._f:{ref:{name:e}},name:e,mount:!0,...n}}),s.mount.add(e),a&&!l?le({disabled:q(n.disabled)?n.disabled:t.disabled,name:e}):S(e,!0,n.value),{...c?{disabled:n.disabled||t.disabled}:{},...t.progressive?{required:!!n.required,min:Rt(n.min),max:Rt(n.max),minLength:Rt(n.minLength),maxLength:Rt(n.maxLength),pattern:Rt(n.pattern)}:{},name:e,onChange:I,onBlur:I,ref:c=>{if(c){s.registerName.add(e),ue(e,n),s.registerName.delete(e),a=K(r,e);let t=G(c.value)&&c.querySelectorAll&&c.querySelectorAll(`input,select,textarea`)[0]||c,o=bt(t),l=a._f.refs||[];if(o?l.find(e=>e===t):t===a._f.ref)return;Y(r,e,{_f:{...a._f,...o?{refs:[...l.filter(xt),t,...Array.isArray(K(i,e))?[{}]:[]],ref:{type:t.type,name:e}}:{ref:t}}}),S(e,!1,void 0,t)}else a=K(r,e,{}),a._f&&(a._f.mount=!1),(t.shouldUnregister||n.shouldUnregister)&&!(Ve(s.array,e)&&o.action)&&s.unMount.add(e)}}},de=()=>t.shouldFocusError&&Wt(r,te,s.mount),fe=e=>{q(e)&&(p.state.next({disabled:e}),Wt(r,(t,n)=>{let i=K(r,n);i&&(t.disabled=i._f.disabled||e,Array.isArray(i._f.refs)&&i._f.refs.forEach(t=>{t.disabled=i._f.disabled||e}))},0,!1))},pe=(e,i)=>async o=>{let c;o&&(o.preventDefault&&o.preventDefault(),o.persist&&o.persist());let l=W(a);if(p.state.next({isSubmitting:!0}),t.resolver){let{errors:e,values:t}=await T();_(),n.errors=e,l=W(t)}else await O({fields:r,eventType:qe.SUBMIT});if(s.disabled.size)for(let e of s.disabled)Q(l,e);if(Q(n.errors,Ze),Z(n.errors)){p.state.next({errors:{}});try{await e(l,o)}catch(e){c=e}}else i&&await i({...n.errors},o),de(),setTimeout(de);if(p.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:Z(n.errors)&&!c,submitCount:n.submitCount+1,errors:n.errors}),c)throw c},me=(e,t={})=>{K(r,e)&&(G(t.defaultValue)?F(e,W(K(i,e))):(F(e,t.defaultValue),Y(i,e,W(t.defaultValue))),t.keepTouched||Q(n.touchedFields,e),t.keepDirty||(Q(n.dirtyFields,e),n.isDirty=t.defaultValue?A(e,W(K(i,e))):A()),t.keepError||(Q(n.errors,e),d.isValid&&g()),p.state.next({...n}))},he=(e,c={})=>{let l=e?W(e):i,u=W(l),f=Z(e),m=f?i:u;if(c.keepDefaultValues||(i=l),!c.keepValues){if(c.keepDirtyValues){let e=new Set([...s.mount,...Object.keys(Dt(i,a))]);for(let t of Array.from(e)){let e=K(n.dirtyFields,t),r=K(a,t),i=K(m,t);e&&!G(r)?Y(m,t,r):!e&&!G(i)&&F(t,i)}}else{if(Ue&&G(e))for(let e of s.mount){let t=K(r,e);if(t&&t._f){let e=Array.isArray(t._f.refs)?t._f.refs[0]:t._f.ref;if(_t(e)){let t=e.closest(`form`);if(t){t.reset();break}}}}if(c.keepFieldsRef)for(let e of s.mount)F(e,K(m,e));else r={}}a=t.shouldUnregister?c.keepDefaultValues?W(i):{}:W(m),p.array.next({values:{...m}}),p.state.next({values:{...m}})}s={mount:c.keepDirtyValues?s.mount:new Set,unMount:new Set,array:new Set,registerName:new Set,disabled:new Set,watch:new Set,watchAll:!1,focus:``},o.mount=!d.isValid||!!c.keepIsValid||!!c.keepDirtyValues||!t.shouldUnregister&&!Z(m),o.watch=!!t.shouldUnregister,o.keepIsValid=!!c.keepIsValid,o.action=!1,c.keepErrors||(n.errors={}),p.state.next({submitCount:c.keepSubmitCount?n.submitCount:0,isDirty:f?!1:c.keepDirty?n.isDirty:!!(c.keepDefaultValues&&!at(e,i)),isSubmitted:c.keepIsSubmitted?n.isSubmitted:!1,dirtyFields:f?{}:c.keepDirtyValues?c.keepDefaultValues&&a?Dt(i,a):n.dirtyFields:c.keepDefaultValues&&e?Dt(i,e):c.keepDirty?n.dirtyFields:{},touchedFields:c.keepTouched?n.touchedFields:{},errors:c.keepErrors?n.errors:{},isSubmitSuccessful:c.keepIsSubmitSuccessful?n.isSubmitSuccessful:!1,isSubmitting:!1,defaultValues:i})},ge=(e,n)=>he(J(e)?e(a):e,{...t.resetOptions,...n}),_e=(e,t={})=>{let n=K(r,e),i=n&&n._f;if(i){let e=i.refs?i.refs[0]:i.ref;e.focus&&setTimeout(()=>{e.focus(),t.shouldSelect&&J(e.select)&&e.select()})}},ve=e=>{n={...n,...e}},ye={control:{register:ue,unregister:ce,getFieldState:re,handleSubmit:pe,setError:ae,_subscribe:R,_runSchema:T,_updateIsValidating:_,_focusError:de,_getWatch:j,_getDirty:A,_setValid:g,_setFieldArray:y,_setDisabledField:le,_setErrors:x,_getFieldArray:M,_reset:he,_resetDefaultValues:()=>J(t.defaultValues)&&t.defaultValues().then(e=>{ge(e,t.resetOptions),p.state.next({isLoading:!1})}),_removeUnmounted:k,_disableForm:fe,_subjects:p,_proxyFormState:d,get _fields(){return r},get _formValues(){return a},get _state(){return o},set _state(e){o=e},get _defaultValues(){return i},get _names(){return s},set _names(e){s=e},get _formState(){return n},get _options(){return t},set _options(e){t={...t,...e}}},subscribe:se,trigger:L,register:ue,handleSubmit:pe,watch:oe,setValue:F,setValues:ee,getValues:ne,reset:ge,resetField:me,clearErrors:ie,unregister:ce,setError:ae,setFocus:_e,getFieldState:re};return{...ye,formControl:ye}}function nn(e={}){let t=V.useRef(void 0),n=V.useRef(void 0),[r,i]=V.useState({isDirty:!1,isValidating:!1,isLoading:J(e.defaultValues),isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,submitCount:0,dirtyFields:{},touchedFields:{},validatingFields:{},errors:e.errors||{},disabled:e.disabled||!1,isReady:!1,defaultValues:J(e.defaultValues)?void 0:e.defaultValues});if(!t.current)if(e.formControl)t.current={...e.formControl,formState:r},e.defaultValues&&!J(e.defaultValues)&&e.formControl.reset(e.defaultValues,e.resetOptions);else{let{formControl:n,...i}=tn(e);t.current={...i,formState:r}}let a=t.current.control;return a._options=e,tt(()=>{let e=a._subscribe({formState:a._proxyFormState,callback:()=>i({...a._formState}),reRenderRoot:!0});return i(e=>({...e,isReady:!0})),a._formState.isReady=!0,e},[a]),V.useEffect(()=>a._disableForm(e.disabled),[a,e.disabled]),V.useEffect(()=>{e.mode&&(a._options.mode=e.mode),e.reValidateMode&&(a._options.reValidateMode=e.reValidateMode)},[a,e.mode,e.reValidateMode]),V.useEffect(()=>{e.errors&&(a._setErrors(e.errors),a._focusError())},[a,e.errors]),V.useEffect(()=>{e.shouldUnregister&&a._subjects.state.next({values:a._getWatch()})},[a,e.shouldUnregister]),V.useEffect(()=>{if(a._proxyFormState.isDirty){let e=a._getDirty();e!==r.isDirty&&a._subjects.state.next({isDirty:e})}},[a,r.isDirty]),V.useEffect(()=>{e.values&&!at(e.values,n.current)?(a._reset(e.values,{keepFieldsRef:!0,...a._options.resetOptions}),a._options.resetOptions?.keepIsValid||a._setValid(),n.current=e.values,i(e=>({...e}))):a._resetDefaultValues()},[a,e.values]),V.useEffect(()=>{a._state.mount||(a._setValid(),a._state.mount=!0),a._state.watch&&(a._state.watch=!1,a._subjects.state.next({...a._formState})),a._removeUnmounted()}),t.current.formState=V.useMemo(()=>et(r,a),[a,r]),t.current}var $=r(),rn=dt,an=V.createContext({}),on=e=>{let t=(0,B.c)(9),n;t[0]===e?n=t[1]:({...n}=e,t[0]=e,t[1]=n);let r;t[2]===n.name?r=t[3]:(r={name:n.name},t[2]=n.name,t[3]=r);let i;t[4]===n?i=t[5]:(i=(0,$.jsx)(ct,{...n}),t[4]=n,t[5]=i);let a;return t[6]!==r||t[7]!==i?(a=(0,$.jsx)(an.Provider,{value:r,children:i}),t[6]=r,t[7]=i,t[8]=a):a=t[8],a},sn=()=>{let e=(0,B.c)(13),t=V.use(an),n=V.use(cn),{getFieldState:r}=ut(),i;e[0]===t.name?i=e[1]:(i={name:t.name},e[0]=t.name,e[1]=i);let a=nt(i),o;e[2]!==t.name||e[3]!==a||e[4]!==r?(o=r(t.name,a),e[2]=t.name,e[3]=a,e[4]=r,e[5]=o):o=e[5];let s=o;if(!t)throw Error(`useFormField should be used within <FormField>`);let{id:c}=n,l=`${c}-form-item`,u=`${c}-form-item-description`,d=`${c}-form-item-message`,f;return e[6]!==t.name||e[7]!==s||e[8]!==c||e[9]!==l||e[10]!==u||e[11]!==d?(f={id:c,name:t.name,formItemId:l,formDescriptionId:u,formMessageId:d,...s},e[6]=t.name,e[7]=s,e[8]=c,e[9]=l,e[10]=u,e[11]=d,e[12]=f):f=e[12],f},cn=V.createContext({});function ln(e){let t=(0,B.c)(13),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i=V.useId(),a;t[3]===i?a=t[4]:(a={id:i},t[3]=i,t[4]=a);let o;t[5]===n?o=t[6]:(o=A(`grid gap-2`,n),t[5]=n,t[6]=o);let s;t[7]!==r||t[8]!==o?(s=(0,$.jsx)(`div`,{"data-slot":`form-item`,className:o,...r}),t[7]=r,t[8]=o,t[9]=s):s=t[9];let c;return t[10]!==a||t[11]!==s?(c=(0,$.jsx)(cn.Provider,{value:a,children:s}),t[10]=a,t[11]=s,t[12]=c):c=t[12],c}function un(e){let t=(0,B.c)(10),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let{error:i,formItemId:a}=sn(),o=!!i,s;t[3]===n?s=t[4]:(s=A(`data-[error=true]:text-destructive`,n),t[3]=n,t[4]=s);let c;return t[5]!==a||t[6]!==r||t[7]!==o||t[8]!==s?(c=(0,$.jsx)(Fe,{"data-slot":`form-label`,"data-error":o,className:s,htmlFor:a,...r}),t[5]=a,t[6]=r,t[7]=o,t[8]=s,t[9]=c):c=t[9],c}function dn(e){let t=(0,B.c)(7),n;t[0]===e?n=t[1]:({...n}=e,t[0]=e,t[1]=n);let{error:r,formItemId:i,formDescriptionId:a,formMessageId:o}=sn(),s=r?`${a} ${o}`:`${a}`,c=!!r,l;return t[2]!==i||t[3]!==n||t[4]!==s||t[5]!==c?(l=(0,$.jsx)(j,{"data-slot":`form-control`,id:i,"aria-describedby":s,"aria-invalid":c,...n}),t[2]=i,t[3]=n,t[4]=s,t[5]=c,t[6]=l):l=t[6],l}function fn(e){let t=(0,B.c)(9),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let{formDescriptionId:i}=sn(),a;t[3]===n?a=t[4]:(a=A(`text-sm text-muted-foreground`,n),t[3]=n,t[4]=a);let o;return t[5]!==i||t[6]!==r||t[7]!==a?(o=(0,$.jsx)(`p`,{"data-slot":`form-description`,id:i,className:a,...r}),t[5]=i,t[6]=r,t[7]=a,t[8]=o):o=t[8],o}function pn(e){let t=(0,B.c)(11),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let{error:i,formMessageId:a}=sn(),o=i?String(i?.message??``):r.children;if(!o)return null;let s=i?`alert`:void 0,c;t[3]===n?c=t[4]:(c=A(`text-sm text-destructive`,n),t[3]=n,t[4]=c);let l;return t[5]!==o||t[6]!==a||t[7]!==r||t[8]!==s||t[9]!==c?(l=(0,$.jsx)(`p`,{"data-slot":`form-message`,id:a,role:s,className:c,...r,children:o}),t[5]=o,t[6]=a,t[7]=r,t[8]=s,t[9]=c,t[10]=l):l=t[10],l}var mn=e(t(((e,t)=>{function n(e){return Array.isArray(e)?e:[e]}var r=``,i=` `,a=`\\`,o=/^\s+$/,s=/(?:[^\\]|^)\\$/,c=/^\\!/,l=/^\\#/,u=/\r?\n/g,d=/^\.*\/|^\.+$/,f=`/`,p=`node-ignore`;typeof Symbol<`u`&&(p=Symbol.for(`node-ignore`));var m=p,h=(e,t,n)=>Object.defineProperty(e,t,{value:n}),g=/([0-z])-([0-z])/g,_=()=>!1,v=e=>e.replace(g,(e,t,n)=>t.charCodeAt(0)<=n.charCodeAt(0)?e:r),y=e=>{let{length:t}=e;return e.slice(0,t-t%2)},b=[[/^\uFEFF/,()=>r],[/((?:\\\\)*?)(\\?\s+)$/,(e,t,n)=>t+(n.indexOf(`\\`)===0?i:r)],[/(\\+?)\s/g,(e,t)=>{let{length:n}=t;return t.slice(0,n-n%2)+i}],[/[\\$.|*+(){^]/g,e=>`\\${e}`],[/(?!\\)\?/g,()=>`[^/]`],[/^\//,()=>`^`],[/\//g,()=>`\\/`],[/^\^*\\\*\\\*\\\//,()=>`^(?:.*\\/)?`],[/^(?=[^^])/,function(){return/\/(?!$)/.test(this)?`^`:`(?:^|\\/)`}],[/\\\/\\\*\\\*(?=\\\/|$)/g,(e,t,n)=>t+6<n.length?`(?:\\/[^\\/]+)*`:`\\/.+`],[/(^|[^\\]+)(\\\*)+(?=.+)/g,(e,t,n)=>t+n.replace(/\\\*/g,`[^\\/]*`)],[/\\\\\\(?=[$.|*+(){^])/g,()=>a],[/\\\\/g,()=>a],[/(\\)?\[([^\]/]*?)(\\*)($|\])/g,(e,t,n,r,i)=>t===a?`\\[${n}${y(r)}${i}`:i===`]`&&r.length%2==0?`[${v(n)}${r}]`:`[]`],[/(?:[^*])$/,e=>/\/$/.test(e)?`${e}$`:`${e}(?=$|\\/$)`],[/(\^|\\\/)?\\\*$/,(e,t)=>`${t?`${t}[^/]+`:`[^/]*`}(?=$|\\/$)`]],x=Object.create(null),S=(e,t)=>{let n=x[e];return n||(n=b.reduce((t,[n,r])=>t.replace(n,r.bind(e)),e),x[e]=n),t?new RegExp(n,`i`):new RegExp(n)},C=e=>typeof e==`string`,w=e=>e&&C(e)&&!o.test(e)&&!s.test(e)&&e.indexOf(`#`)!==0,T=e=>e.split(u),E=class{constructor(e,t,n,r){this.origin=e,this.pattern=t,this.negative=n,this.regex=r}},D=(e,t)=>{let n=e,r=!1;e.indexOf(`!`)===0&&(r=!0,e=e.substr(1)),e=e.replace(c,`!`).replace(l,`#`);let i=S(e,t);return new E(n,e,r,i)},O=(e,t)=>{throw new t(e)},k=(e,t,n)=>C(e)?e?k.isNotRelative(e)?n(`path should be a \`path.relative()\`d string, but got "${t}"`,RangeError):!0:n(`path must not be empty`,TypeError):n(`path must be a string, but got \`${t}\``,TypeError),A=e=>d.test(e);k.isNotRelative=A,k.convert=e=>e;var j=class{constructor({ignorecase:e=!0,ignoreCase:t=e,allowRelativePaths:n=!1}={}){h(this,m,!0),this._rules=[],this._ignoreCase=t,this._allowRelativePaths=n,this._initCache()}_initCache(){this._ignoreCache=Object.create(null),this._testCache=Object.create(null)}_addPattern(e){if(e&&e[m]){this._rules=this._rules.concat(e._rules),this._added=!0;return}if(w(e)){let t=D(e,this._ignoreCase);this._added=!0,this._rules.push(t)}}add(e){return this._added=!1,n(C(e)?T(e):e).forEach(this._addPattern,this),this._added&&this._initCache(),this}addPattern(e){return this.add(e)}_testOne(e,t){let n=!1,r=!1;return this._rules.forEach(i=>{let{negative:a}=i;r===a&&n!==r||a&&!n&&!r&&!t||i.regex.test(e)&&(n=!a,r=a)}),{ignored:n,unignored:r}}_test(e,t,n,r){let i=e&&k.convert(e);return k(i,e,this._allowRelativePaths?_:O),this._t(i,t,n,r)}_t(e,t,n,r){if(e in t)return t[e];if(r||=e.split(f),r.pop(),!r.length)return t[e]=this._testOne(e,n);let i=this._t(r.join(f)+f,t,n,r);return t[e]=i.ignored?i:this._testOne(e,n)}ignores(e){return this._test(e,this._ignoreCache,!1).ignored}createFilter(){return e=>!this.ignores(e)}filter(e){return n(e).filter(this.createFilter())}test(e){return this._test(e,this._testCache,!0)}},M=e=>new j(e);if(M.isPathValid=e=>k(e&&k.convert(e),e,_),M.default=M,t.exports=M,typeof process<`u`&&({}.IGNORE_TEST_WIN32||process.platform===`win32`)){k.convert=e=>/^\\\\\?\\/.test(e)||/["<>|\u0000-\u001F]+/u.test(e)?e:e.replace(/\\/g,`/`);let e=/^[a-z]:\//i;k.isNotRelative=t=>e.test(t)||A(t)}}))(),1),hn=new Map;function gn(e){let t=hn.get(e);if(t)return hn.delete(e),hn.set(e,t),t;let n=(0,mn.default)();if(n.add(e),hn.set(e,n),hn.size>256){let e=hn.keys().next().value;e!==void 0&&hn.delete(e)}return n}function _n(e,t){let n=e.trim();if(n.length===0||n.startsWith(`#`))return 0;let r=gn(n),i=0;for(let e of t)e.length!==0&&r.ignores(e)&&(i+=1);return i}var vn={"trailing-backslash":`Trailing backslash — line continuation isn't supported.`,"unmatched-bracket":`Unmatched [ — character class is open.`,"lone-bang":`Lone ! — negation needs a pattern after it.`,"leading-whitespace":`Leading whitespace — the rule may not match as expected.`,"embedded-newline":`Embedded line break — the row spans multiple lines.`};function yn(e){let t=[];if(e.length===0||e.trimStart().startsWith(`#`))return t;/[\r\n]/.test(e)&&t.push({code:`embedded-newline`,message:vn[`embedded-newline`]}),/^\s/.test(e)&&t.push({code:`leading-whitespace`,message:vn[`leading-whitespace`]});let n=e.trim();return n===`!`&&t.push({code:`lone-bang`,message:vn[`lone-bang`]}),n.endsWith(`\\`)&&t.push({code:`trailing-backslash`,message:vn[`trailing-backslash`]}),bn(n,`[`)>bn(n,`]`)&&t.push({code:`unmatched-bracket`,message:vn[`unmatched-bracket`]}),t}function bn(e,t){let n=0;for(let r=0;r<e.length;r++)e[r]===t&&n++;return n}var xn=`https://openknowledge.ai/docs/features/ignore-patterns`,Sn=1200,Cn=150,wn=150,Tn=5e3,En=600,Dn=400,On=`okignore-show-advanced`;function kn(e){let t=(0,B.c)(3),{binding:n,synced:r}=e;if(n===null||!r){let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(An,{}),t[0]=e):e=t[0],e}let i;return t[1]===n?i=t[2]:(i=(0,$.jsx)(jn,{binding:n}),t[1]=n,t[2]=i),i}function An(){let e=(0,B.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsxs)(`section`,{"aria-labelledby":`settings-okignore-title`,className:`space-y-3`,"data-testid":`settings-okignore-skeleton`,children:[(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`h3`,{id:`settings-okignore-title`,className:`text-base font-semibold`,children:(0,$.jsx)(m,{id:`3zyg_A`})}),(0,$.jsx)(z,{className:`h-4 w-72`})]}),(0,$.jsx)(z,{className:`h-20 w-full`})]}),e[0]=t):t=e[0],t}function jn(e){let t=(0,B.c)(72),{binding:n}=e,{_:r}=f(),i;t[0]===n?i=t[1]:(i=()=>n.current(),t[0]=n,t[1]=i);let[a,o]=(0,V.useState)(i),s,c;t[2]===n?(s=t[3],c=t[4]):(s=()=>n.subscribe(e=>{o(e)}),c=[n],t[2]=n,t[3]=s,t[4]=c),(0,V.useEffect)(s,c);let{pages:l,pageMeta:u,assetPaths:d}=x(),p;t[5]!==d||t[6]!==u||t[7]!==l?(p=Qn(l,u,d),t[5]=d,t[6]=u,t[7]=l,t[8]=p):p=t[8];let h=p,_,v;t[9]===a?(_=t[10],v=t[11]):(_=ke(a),v=xe(_),t[9]=a,t[10]=_,t[11]=v);let y=v,b=y.length===0,[S,C]=(0,V.useState)(null),w=(0,V.useRef)(null),T,E;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(T=()=>()=>{w.current&&clearTimeout(w.current)},E=[],t[12]=T,t[13]=E):(T=t[12],E=t[13]),(0,V.useEffect)(T,E);let D;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(D=e=>{C({key:e,ts:Date.now()}),w.current&&clearTimeout(w.current),w.current=setTimeout(()=>C(null),Sn)},t[14]=D):D=t[14];let k=D,[A,j]=(0,V.useState)(null),M=(0,V.useRef)(null),N,P;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(P=()=>()=>{M.current&&clearTimeout(M.current)},N=[],t[15]=N,t[16]=P):(N=t[15],P=t[16]),(0,V.useEffect)(P,N);let I,te;t[17]===n?(I=t[18],te=t[19]):(I=()=>we(e=>{e.docName===`__config__/okignore`&&n.notifyRejection(e.error)}),te=[n],t[17]=n,t[18]=I,t[19]=te),(0,V.useEffect)(I,te);let L,ne;t[20]===n?(L=t[21],ne=t[22]):(L=()=>n.subscribeRejection(e=>{let{error:t}=e,n=Jn(t);j({message:n?.detail??O(t),lineNumber:n?.lineNumber,ts:Date.now()}),M.current&&clearTimeout(M.current),M.current=setTimeout(()=>j(null),Tn)}),ne=[n],t[20]=n,t[21]=L,t[22]=ne),(0,V.useEffect)(L,ne);let re,ie;t[23]===r?(re=t[24],ie=t[25]):(re=()=>ve(e=>{let{path:t}=e;g.error(r({id:`3oh0nQ`,values:{path:t}}),{description:e.error,id:`okignore-nested-error:${e.path}`,duration:8e3})}),ie=[r],t[23]=r,t[24]=re,t[25]=ie),(0,V.useEffect)(re,ie);let oe;t[26]===n?oe=t[27]:(oe=e=>{n.patch(e)},t[26]=n,t[27]=oe);let R=oe,se;t[28]!==R||t[29]!==_||t[30]!==y?(se=(e,t)=>{let n=t.trim(),r=y[e];if(r&&n!==r.text){if(n.length===0){R(Ee(me(_,e)));return}R(Ee(De(_,e,n))),k(qn(n,e))}},t[28]=R,t[29]=_,t[30]=y,t[31]=se):se=t[31];let ce=se,le;t[32]!==R||t[33]!==_?(le=e=>{R(Ee(me(_,e)))},t[32]=R,t[33]=_,t[34]=le):le=t[34];let ue=le,de;t[35]!==R||t[36]!==_||t[37]!==y.length?(de=e=>{let t=e.trim();if(t.length===0)return;let n=pe(_,t);if(n>=0){k(qn(t,n));return}R(Ee(Te(_,t))),k(qn(t,y.length))},t[35]=R,t[36]=_,t[37]=y.length,t[38]=de):de=t[38];let fe=de,ge;t[39]!==R||t[40]!==_?(ge=e=>{let t=String(e.active.id),n=e.over?String(e.over.id):null;if(!n||t===n)return;let r=Kn(t),i=Kn(n);r<0||i<0||r===i||R(Ee(he(_,r,i)))},t[39]=R,t[40]=_,t[41]=ge):ge=t[41];let _e=ge,be;t[42]===Symbol.for(`react.memo_cache_sentinel`)?(be={activationConstraint:{distance:4}},t[42]=be):be=t[42];let Se;t[43]===Symbol.for(`react.memo_cache_sentinel`)?(Se={coordinateGetter:ye},t[43]=Se):Se=t[43];let Ce=je(ae(ee,be),ae(F,Se)),Oe=A===null?null:`rejection-${A.ts}`,[z,Ae]=tr(),Me;t[44]===Symbol.for(`react.memo_cache_sentinel`)?(Me=(0,$.jsx)(`h3`,{id:`settings-okignore-title`,className:`text-base font-semibold`,children:(0,$.jsx)(m,{id:`3zyg_A`})}),t[44]=Me):Me=t[44];let Ne;t[45]===Symbol.for(`react.memo_cache_sentinel`)?(Ne=(0,$.jsxs)(`div`,{className:`space-y-1`,children:[Me,(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:(0,$.jsx)(m,{id:`Z5h97D`,components:{0:(0,$.jsx)(`a`,{href:xn,target:`_blank`,rel:`noreferrer noopener`,className:`text-primary underline-offset-2 hover:underline`,"data-testid":`settings-okignore-primer`})}})})]}),t[45]=Ne):Ne=t[45];let Pe;t[46]===A?Pe=t[47]:(Pe=A===null?null:(0,$.jsx)(Pn,{rejection:A}),t[46]=A,t[47]=Pe);let Fe;t[48]!==n||t[49]!==h||t[50]!==fe||t[51]!==_e||t[52]!==ce||t[53]!==ue||t[54]!==b||t[55]!==y||t[56]!==Oe||t[57]!==S||t[58]!==Ce||t[59]!==z||t[60]!==a?(Fe=z?(0,$.jsx)(Mn,{binding:n,text:a}):b?(0,$.jsx)(Fn,{onAdd:fe,rejectionFlashKey:Oe,filePaths:h}):(0,$.jsx)(In,{patterns:y,sensors:Ce,onDragEnd:_e,onEdit:ce,onRemove:ue,onAdd:fe,savedFlash:S,rejectionFlashKey:Oe,filePaths:h}),t[48]=n,t[49]=h,t[50]=fe,t[51]=_e,t[52]=ce,t[53]=ue,t[54]=b,t[55]=y,t[56]=Oe,t[57]=S,t[58]=Ce,t[59]=z,t[60]=a,t[61]=Fe):Fe=t[61];let Ie;t[62]!==Ae||t[63]!==z?(Ie=()=>Ae(!z),t[62]=Ae,t[63]=z,t[64]=Ie):Ie=t[64];let Le;t[65]!==z||t[66]!==Ie?(Le=(0,$.jsx)(`div`,{className:`flex justify-end`,children:(0,$.jsx)(Nn,{enabled:z,onToggle:Ie})}),t[65]=z,t[66]=Ie,t[67]=Le):Le=t[67];let Re;return t[68]!==Pe||t[69]!==Fe||t[70]!==Le?(Re=(0,$.jsxs)(`section`,{"aria-labelledby":`settings-okignore-title`,className:`space-y-3`,"data-testid":`settings-okignore-section`,children:[Ne,Pe,Fe,Le]}),t[68]=Pe,t[69]=Fe,t[70]=Le,t[71]=Re):Re=t[71],Re}function Mn(e){let t=(0,B.c)(31),{binding:n,text:r}=e,{_:i}=f(),[a,o]=(0,V.useState)(r),s=(0,V.useRef)(r),c=(0,V.useRef)(!1),l=(0,V.useRef)(r),u=(0,V.useRef)(null),d,p;t[0]===r?(d=t[1],p=t[2]):(d=()=>{c.current||r!==s.current&&(o(r),l.current=r,s.current=r)},p=[r],t[0]=r,t[1]=d,t[2]=p),(0,V.useEffect)(d,p);let m,h;t[3]===a?(m=t[4],h=t[5]):(m=()=>{l.current=a},h=[a],t[3]=a,t[4]=m,t[5]=h),(0,V.useEffect)(m,h);let g,_;t[6]===n?(g=t[7],_=t[8]):(g=()=>()=>{u.current&&(clearTimeout(u.current),u.current=null,l.current!==s.current&&(n.patch(l.current),s.current=l.current))},_=[n],t[6]=n,t[7]=g,t[8]=_),(0,V.useEffect)(g,_);let v;t[9]===n?v=t[10]:(v=e=>{u.current&&clearTimeout(u.current),u.current=setTimeout(()=>{u.current=null,e!==s.current&&(s.current=e,n.patch(e))},Dn)},t[9]=n,t[10]=v);let y=v,b;t[11]===n?b=t[12]:(b=()=>{u.current&&=(clearTimeout(u.current),null),l.current!==s.current&&(s.current=l.current,n.patch(l.current))},t[11]=n,t[12]=b);let x=b,S;t[13]===y?S=t[14]:(S=e=>{o(e.target.value),y(e.target.value)},t[13]=y,t[14]=S);let C;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(C=()=>{c.current=!0},t[15]=C):C=t[15];let w;t[16]===x?w=t[17]:(w=()=>{c.current=!1,x()},t[16]=x,t[17]=w);let T;t[18]===a?T=t[19]:(T=a.split(`
|
|
2
|
+
`),t[18]=a,t[19]=T);let E=Math.max(6,Math.min(20,T.length+1)),D;t[20]===i?D=t[21]:(D=i({id:`rssK8c`}),t[20]=i,t[21]=D);let O;t[22]===i?O=t[23]:(O=i({id:`AeHuzT`}),t[22]=i,t[23]=O);let k;return t[24]!==a||t[25]!==w||t[26]!==E||t[27]!==D||t[28]!==O||t[29]!==S?(k=(0,$.jsx)(`textarea`,{value:a,onChange:S,onFocus:C,onBlur:w,spellCheck:!1,rows:E,"aria-label":D,placeholder:O,className:`min-h-32 w-full rounded-md border border-input bg-background px-3 py-2 font-mono text-xs outline-none transition-colors focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50`,"data-testid":`settings-okignore-advanced-textarea`}),t[24]=a,t[25]=w,t[26]=E,t[27]=D,t[28]=O,t[29]=S,t[30]=k):k=t[30],k}function Nn(e){let t=(0,B.c)(6),{enabled:n,onToggle:r}=e,i;t[0]===n?i=t[1]:(i=n?(0,$.jsx)(m,{id:`9PQysm`}):(0,$.jsx)(m,{id:`Nv3mUj`}),t[0]=n,t[1]=i);let a;return t[2]!==n||t[3]!==r||t[4]!==i?(a=(0,$.jsx)(M,{type:`button`,variant:`ghost`,size:`sm`,onClick:r,"aria-pressed":n,className:`h-7 px-2 text-xs text-muted-foreground hover:text-foreground`,"data-testid":`settings-okignore-show-advanced-toggle`,children:i}),t[2]=n,t[3]=r,t[4]=i,t[5]=a):a=t[5],a}function Pn(e){let t=(0,B.c)(7),{rejection:n}=e,{_:r}=f(),{lineNumber:i,message:a}=n,o;t[0]!==r||t[1]!==i||t[2]!==a?(o=r(i===void 0?{id:`G7-rf8`,values:{message:a}}:{id:`P3NS4G`,values:{lineNumber:i,message:a}}),t[0]=r,t[1]=i,t[2]=a,t[3]=o):o=t[3];let s=o,c;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,$.jsx)(S,{"aria-hidden":`true`,className:`mt-0.5 size-4 shrink-0`}),t[4]=c):c=t[4];let l;return t[5]===s?l=t[6]:(l=(0,$.jsxs)(`div`,{role:`status`,"aria-live":`polite`,"data-testid":`settings-okignore-rejection-banner`,className:`flex items-start gap-2 rounded-md border border-destructive/30 bg-destructive/5 px-3 py-2 text-sm text-destructive animate-in fade-in`,children:[c,(0,$.jsx)(`span`,{children:s})]}),t[5]=s,t[6]=l),l}function Fn(e){let t=(0,B.c)(8),{onAdd:n,rejectionFlashKey:r,filePaths:i}=e,{_:a}=f(),o;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:(0,$.jsx)(m,{id:`makN88`})}),t[0]=o):o=t[0];let s;t[1]===a?s=t[2]:(s=a({id:`Gx0VS1`}),t[1]=a,t[2]=s);let c;return t[3]!==i||t[4]!==n||t[5]!==r||t[6]!==s?(c=(0,$.jsxs)(`div`,{className:`space-y-3 rounded-md border border-dashed p-4`,"data-testid":`settings-okignore-empty`,children:[o,(0,$.jsx)(Bn,{onAdd:n,placeholder:s,rejectionFlashKey:r,filePaths:i})]}),t[3]=i,t[4]=n,t[5]=r,t[6]=s,t[7]=c):c=t[7],c}function In(e){let t=(0,B.c)(35),{patterns:n,sensors:r,onDragEnd:i,onEdit:a,onRemove:o,onAdd:s,savedFlash:c,rejectionFlashKey:l,filePaths:u}=e,{_:d}=f(),p;t[0]===n?p=t[1]:(p=n.map(Ln),t[0]=n,t[1]=p);let m=p,h;t[2]===d?h=t[3]:(h=d({id:`3zyg_A`}),t[2]=d,t[3]=h);let g;if(t[4]!==u||t[5]!==a||t[6]!==o||t[7]!==n||t[8]!==c){let e;t[10]!==u||t[11]!==a||t[12]!==o||t[13]!==c?(e=(e,t)=>{let n=qn(e.text,t),r=c!==null&&c.key===n;return(0,$.jsx)(Rn,{sortableId:Gn(t),patternIndex:t,pattern:e,onEdit:a,onRemove:o,flashActive:r,filePaths:u},Gn(t))},t[10]=u,t[11]=a,t[12]=o,t[13]=c,t[14]=e):e=t[14],g=n.map(e),t[4]=u,t[5]=a,t[6]=o,t[7]=n,t[8]=c,t[9]=g}else g=t[9];let _;t[15]!==h||t[16]!==g?(_=(0,$.jsx)(`ul`,{"aria-label":h,className:`divide-y rounded-md border`,"data-testid":`settings-okignore-list`,children:g}),t[15]=h,t[16]=g,t[17]=_):_=t[17];let v;t[18]!==m||t[19]!==_?(v=(0,$.jsx)(ne,{items:m,strategy:L,children:_}),t[18]=m,t[19]=_,t[20]=v):v=t[20];let y;t[21]!==i||t[22]!==r||t[23]!==v?(y=(0,$.jsx)(re,{sensors:r,collisionDetection:I,onDragEnd:i,children:v}),t[21]=i,t[22]=r,t[23]=v,t[24]=y):y=t[24];let b;t[25]===d?b=t[26]:(b=d({id:`cZGNlb`}),t[25]=d,t[26]=b);let x;t[27]!==u||t[28]!==s||t[29]!==l||t[30]!==b?(x=(0,$.jsx)(Bn,{onAdd:s,placeholder:b,rejectionFlashKey:l,filePaths:u}),t[27]=u,t[28]=s,t[29]=l,t[30]=b,t[31]=x):x=t[31];let S;return t[32]!==y||t[33]!==x?(S=(0,$.jsxs)(`div`,{className:`space-y-2`,children:[y,x]}),t[32]=y,t[33]=x,t[34]=S):S=t[34],S}function Ln(e,t){return Gn(t)}function Rn(e){let t=(0,B.c)(47),{sortableId:n,patternIndex:r,pattern:i,onEdit:a,onRemove:o,flashActive:s,filePaths:c}=e,{_:l}=f(),u;t[0]===n?u=t[1]:(u={id:n},t[0]=n,t[1]=u);let{attributes:d,listeners:m,setNodeRef:h,transform:g,transition:_,isDragging:v}=te(u),y=i.text,b;t[2]===g?b=t[3]:(b=P.Transform.toString(g),t[2]=g,t[3]=b);let x=v?.5:void 0,S=v?1:void 0,C;t[4]!==b||t[5]!==x||t[6]!==S||t[7]!==_?(C={transform:b,transition:_,opacity:x,zIndex:S},t[4]=b,t[5]=x,t[6]=S,t[7]=_,t[8]=C):C=t[8];let w=C,T;t[9]!==l||t[10]!==y?(T=l({id:`7_bFEL`,values:{patternText:y}}),t[9]=l,t[10]=y,t[11]=T):T=t[11];let E;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(E=(0,$.jsx)(be,{className:`size-3.5`}),t[12]=E):E=t[12];let D;t[13]!==d||t[14]!==m||t[15]!==T?(D=(0,$.jsx)(M,{type:`button`,variant:`ghost`,size:`icon-sm`,"data-testid":`settings-okignore-drag-handle`,"aria-label":T,...d,...m,className:`h-7 w-4 shrink-0 cursor-grab touch-none px-0 text-muted-foreground/40 hover:text-foreground focus-visible:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring active:cursor-grabbing`,children:E}),t[13]=d,t[14]=m,t[15]=T,t[16]=D):D=t[16];let O;t[17]!==a||t[18]!==r?(O=e=>a(r,e),t[17]=a,t[18]=r,t[19]=O):O=t[19];let k;t[20]!==c||t[21]!==i.text||t[22]!==r||t[23]!==O?(k=(0,$.jsx)(zn,{patternIndex:r,initialText:i.text,onCommit:O,filePaths:c}),t[20]=c,t[21]=i.text,t[22]=r,t[23]=O,t[24]=k):k=t[24];let A;t[25]===s?A=t[26]:(A=(0,$.jsx)(Wn,{visible:s}),t[25]=s,t[26]=A);let j;t[27]!==l||t[28]!==y?(j=l({id:`S9Vnum`,values:{patternText:y}}),t[27]=l,t[28]=y,t[29]=j):j=t[29];let N;t[30]!==o||t[31]!==r?(N=()=>o(r),t[30]=o,t[31]=r,t[32]=N):N=t[32];let F;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(F=(0,$.jsx)(p,{className:`size-3.5`}),t[33]=F):F=t[33];let ee;t[34]!==j||t[35]!==N?(ee=(0,$.jsx)(M,{type:`button`,variant:`ghost`,size:`icon-sm`,"data-testid":`settings-okignore-remove`,"aria-label":j,onClick:N,className:`h-7 w-7 shrink-0 text-muted-foreground hover:text-destructive`,children:F}),t[34]=j,t[35]=N,t[36]=ee):ee=t[36];let I;t[37]!==k||t[38]!==A||t[39]!==ee||t[40]!==D?(I=(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[D,k,A,ee]}),t[37]=k,t[38]=A,t[39]=ee,t[40]=D,t[41]=I):I=t[41];let L;return t[42]!==r||t[43]!==h||t[44]!==w||t[45]!==I?(L=(0,$.jsx)(`li`,{ref:h,style:w,className:`flex flex-col gap-0.5 px-2 py-1.5`,"data-testid":`settings-okignore-row`,"data-pattern-index":r,children:I}),t[42]=r,t[43]=h,t[44]=w,t[45]=I,t[46]=L):L=t[46],L}function zn(e){let t=(0,B.c)(31),{patternIndex:n,initialText:r,onCommit:i,filePaths:a}=e,{_:o}=f(),[s,c]=(0,V.useState)(r),l=(0,V.useRef)(r),u=(0,V.useRef)(!1),d,p;t[0]===r?(d=t[1],p=t[2]):(d=()=>{u.current||r!==l.current&&(c(r),l.current=r)},p=[r],t[0]=r,t[1]=d,t[2]=p),(0,V.useEffect)(d,p);let m=Yn(s),h=Xn(s,a),g=n+1,_;t[3]!==s||t[4]!==i?(_=()=>{s!==l.current&&(l.current=s,i(s))},t[3]=s,t[4]=i,t[5]=_):_=t[5];let v=_,y,b;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(y=e=>c(e.target.value),b=()=>{u.current=!0},t[6]=y,t[7]=b):(y=t[6],b=t[7]);let x;t[8]===v?x=t[9]:(x=()=>{u.current=!1,v()},t[8]=v,t[9]=x);let S;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(S=e=>{e.key===`Enter`?(e.preventDefault(),e.currentTarget.blur()):e.key===`Escape`&&(e.preventDefault(),c(l.current),e.currentTarget.blur())},t[10]=S):S=t[10];let C;t[11]!==o||t[12]!==g?(C=o({id:`-YV1Uo`,values:{patternNumber:g}}),t[11]=o,t[12]=g,t[13]=C):C=t[13];let w=m.length>0?`border-amber-500/60 focus-visible:ring-amber-500/40`:``,T;t[14]===w?T=t[15]:(T=A(`h-7 flex-1 font-mono text-xs`,w),t[14]=w,t[15]=T);let E;t[16]!==s||t[17]!==T||t[18]!==x||t[19]!==C?(E=(0,$.jsx)(Me,{value:s,onChange:y,onFocus:b,onBlur:x,onKeyDown:S,"aria-label":C,className:T,"data-testid":`settings-okignore-row-input`}),t[16]=s,t[17]=T,t[18]=x,t[19]=C,t[20]=E):E=t[20];let D;t[21]===m?D=t[22]:(D=(0,$.jsx)(Vn,{warnings:m}),t[21]=m,t[22]=D);let O;t[23]!==E||t[24]!==D?(O=(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1`,children:[E,D]}),t[23]=E,t[24]=D,t[25]=O):O=t[25];let k;t[26]===h?k=t[27]:(k=(0,$.jsx)(Zn,{count:h}),t[26]=h,t[27]=k);let j;return t[28]!==O||t[29]!==k?(j=(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col`,children:[O,k]}),t[28]=O,t[29]=k,t[30]=j):j=t[30],j}function Bn(e){let t=(0,B.c)(34),{onAdd:n,placeholder:r,rejectionFlashKey:i,filePaths:a}=e,{_:o}=f(),[s,c]=(0,V.useState)(``),l=Yn(s),u=Xn(s,a),d=rr(i),p;t[0]!==n||t[1]!==s?(p=()=>{let e=s.trim();e.length!==0&&(n(e),c(``))},t[0]=n,t[1]=s,t[2]=p):p=t[2];let h=p,g;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(g=e=>c(e.target.value),t[3]=g):g=t[3];let _;t[4]===h?_=t[5]:(_=e=>{e.key===`Enter`&&(e.preventDefault(),h())},t[4]=h,t[5]=_);let v;t[6]===o?v=t[7]:(v=o({id:`p9sdCy`}),t[6]=o,t[7]=v);let y=d?`border-destructive ring-2 ring-destructive/30 focus-visible:ring-destructive/50`:l.length>0?`border-amber-500/60 focus-visible:ring-amber-500/40`:``,b;t[8]===y?b=t[9]:(b=A(`h-8 text-sm`,y),t[8]=y,t[9]=b);let x=d?`true`:void 0,S;t[10]!==s||t[11]!==r||t[12]!==_||t[13]!==v||t[14]!==b||t[15]!==x?(S=(0,$.jsx)(Me,{value:s,onChange:g,onKeyDown:_,placeholder:r,"aria-label":v,className:b,"data-testid":`settings-okignore-add-input`,"data-rejection-flashing":x}),t[10]=s,t[11]=r,t[12]=_,t[13]=v,t[14]=b,t[15]=x,t[16]=S):S=t[16];let C;t[17]===l?C=t[18]:(C=(0,$.jsx)(Vn,{warnings:l}),t[17]=l,t[18]=C);let w;t[19]===s?w=t[20]:(w=s.trim(),t[19]=s,t[20]=w);let T=w.length===0,E;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(E=(0,$.jsx)(m,{id:`BY-g4_`}),t[21]=E):E=t[21];let D;t[22]!==h||t[23]!==T?(D=(0,$.jsx)(M,{size:`sm`,onClick:h,disabled:T,"data-testid":`settings-okignore-add-button`,children:E}),t[22]=h,t[23]=T,t[24]=D):D=t[24];let O;t[25]!==D||t[26]!==S||t[27]!==C?(O=(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[S,C,D]}),t[25]=D,t[26]=S,t[27]=C,t[28]=O):O=t[28];let k;t[29]===u?k=t[30]:(k=(0,$.jsx)(Zn,{count:u}),t[29]=u,t[30]=k);let j;return t[31]!==O||t[32]!==k?(j=(0,$.jsxs)(`div`,{className:`flex flex-col gap-0.5`,"data-testid":`settings-okignore-add`,children:[O,k]}),t[31]=O,t[32]=k,t[33]=j):j=t[33],j}function Vn(e){let t=(0,B.c)(31),{warnings:n}=e,{_:r}=f();if(n.length===0){let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(`span`,{"aria-hidden":`true`,className:`flex w-4 shrink-0 justify-center`,"data-testid":`settings-okignore-warning-indicator`,"data-warnings":`0`}),t[0]=e):e=t[0],e}let i,a,o,s,c,l,u;t[1]!==r||t[2]!==n?(o=n.map(Un).join(` `),a=v,i=_,u=!0,s=`status`,c=`polite`,l=r({id:`NORKZU`,values:{summary:o}}),t[1]=r,t[2]=n,t[3]=i,t[4]=a,t[5]=o,t[6]=s,t[7]=c,t[8]=l,t[9]=u):(i=t[3],a=t[4],o=t[5],s=t[6],c=t[7],l=t[8],u=t[9]);let d=String(n.length),p;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,$.jsx)(S,{"aria-hidden":`true`,className:`size-3.5`}),t[10]=p):p=t[10];let m;t[11]===o?m=t[12]:(m=(0,$.jsx)(`span`,{className:`sr-only`,children:o}),t[11]=o,t[12]=m);let h;t[13]!==s||t[14]!==c||t[15]!==l||t[16]!==d||t[17]!==m?(h=(0,$.jsxs)(`span`,{role:s,"aria-live":c,"aria-label":l,className:`flex w-4 shrink-0 cursor-help justify-center text-amber-500`,"data-testid":`settings-okignore-warning-indicator`,"data-warnings":d,children:[p,m]}),t[13]=s,t[14]=c,t[15]=l,t[16]=d,t[17]=m,t[18]=h):h=t[18];let g;t[19]!==i||t[20]!==u||t[21]!==h?(g=(0,$.jsx)(i,{asChild:u,children:h}),t[19]=i,t[20]=u,t[21]=h,t[22]=g):g=t[22];let b;t[23]===n?b=t[24]:(b=n.map(Hn),t[23]=n,t[24]=b);let x;t[25]===b?x=t[26]:(x=(0,$.jsx)(y,{side:`top`,className:`max-w-xs`,children:(0,$.jsx)(`ul`,{className:`list-disc space-y-1 pl-4`,children:b})}),t[25]=b,t[26]=x);let C;return t[27]!==a||t[28]!==x||t[29]!==g?(C=(0,$.jsxs)(a,{children:[g,x]}),t[27]=a,t[28]=x,t[29]=g,t[30]=C):C=t[30],C}function Hn(e){return(0,$.jsx)(`li`,{children:e.message},e.code)}function Un(e){return e.message}function Wn(e){let t=(0,B.c)(4),{visible:n}=e,r;t[0]===n?r=t[1]:(r=n?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(d,{"aria-hidden":`true`,className:`size-3.5`}),(0,$.jsx)(`span`,{className:`sr-only`,children:(0,$.jsx)(m,{id:`idD8Ev`})})]}):null,t[0]=n,t[1]=r);let i;return t[2]===r?i=t[3]:(i=(0,$.jsx)(`span`,{role:`status`,"aria-live":`polite`,className:`flex w-4 shrink-0 justify-center text-emerald-600`,"data-testid":`settings-okignore-saved-indicator`,children:r}),t[2]=r,t[3]=i),i}function Gn(e){return`okignore-pattern-${e}`}function Kn(e){let t=e.match(/^okignore-pattern-(\d+)$/);if(!t)return-1;let n=Number.parseInt(t[1]??``,10);return Number.isNaN(n)?-1:n}function qn(e,t){return`${t}::${e}`}function Jn(e){return!w(e)||e.code!==`OKIGNORE_INVALID`?null:{detail:e.detail,lineNumber:e.lineNumber}}function Yn(e){let t=(0,B.c)(5),n;t[0]===e?n=t[1]:(n=()=>e.length===0?[]:yn(e),t[0]=e,t[1]=n);let[r,i]=(0,V.useState)(n),a,o;return t[2]===e?(a=t[3],o=t[4]):(a=()=>{if(e.length===0){i([]);return}let t=setTimeout(()=>{i(yn(e))},Cn);return()=>clearTimeout(t)},o=[e],t[2]=e,t[3]=a,t[4]=o),(0,V.useEffect)(a,o),r}function Xn(e,t){let n=(0,B.c)(9),r;n[0]===e?r=n[1]:(r=e.trim(),n[0]=e,n[1]=r);let i=r,a;n[2]!==t||n[3]!==i?(a=()=>i.length===0?null:_n(i,t),n[2]=t,n[3]=i,n[4]=a):a=n[4];let[o,s]=(0,V.useState)(a),c,l;return n[5]!==t||n[6]!==i?(c=()=>{if(i.length===0){s(null);return}let e=setTimeout(()=>{s(_n(i,t))},wn);return()=>clearTimeout(e)},l=[i,t],n[5]=t,n[6]=i,n[7]=c,n[8]=l):(c=n[7],l=n[8]),(0,V.useEffect)(c,l),o}function Zn(e){let t=(0,B.c)(12),{count:n}=e;if(n===null){let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(`span`,{"aria-hidden":`true`,className:`block h-3.5`,"data-testid":`settings-okignore-preview`,"data-preview-state":`hidden`}),t[0]=e):e=t[0],e}let r=n===0,i=String(n),a=r?`text-muted-foreground/70`:`text-muted-foreground`,o;t[1]===a?o=t[2]:(o=A(`block text-xs`,a),t[1]=a,t[2]=o);let s;t[3]===n?s=t[4]:(s=(0,$.jsx)(m,{id:`-3Qbv7`,values:{count:n}}),t[3]=n,t[4]=s);let c;t[5]===r?c=t[6]:(c=r?(0,$.jsx)(`span`,{className:`ml-1 text-muted-foreground/60`,children:(0,$.jsx)(m,{id:`5kWklo`})}):null,t[5]=r,t[6]=c);let l;return t[7]!==i||t[8]!==o||t[9]!==s||t[10]!==c?(l=(0,$.jsxs)(`span`,{role:`status`,"aria-live":`polite`,"data-testid":`settings-okignore-preview`,"data-preview-state":`visible`,"data-preview-count":i,className:o,children:[s,c]}),t[7]=i,t[8]=o,t[9]=s,t[10]=c,t[11]=l):l=t[11],l}function Qn(e,t,n){let r=[];for(let n of e){let e=t.get(n)?.docExt??`.md`;r.push(n+e)}for(let e of n)r.push(e);return r}function $n(){try{return globalThis.localStorage?.getItem(On)===`true`}catch{return!1}}function er(e){try{globalThis.localStorage?.setItem(On,e?`true`:`false`)}catch(e){console.debug(`[OkignoreSection] localStorage unavailable; advanced toggle will not persist:`,e)}}function tr(){let e=(0,B.c)(3),[t,n]=(0,V.useState)(nr),r;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=e=>{n(e),er(e)},e[0]=r):r=e[0];let i=r,a;return e[1]===t?a=e[2]:(a=[t,i],e[1]=t,e[2]=a),a}function nr(){return $n()}function rr(e){let t=(0,B.c)(3),[n,r]=(0,V.useState)(!1),i,a;return t[0]===e?(i=t[1],a=t[2]):(i=()=>{if(e===null)return;r(!0);let t=setTimeout(()=>r(!1),En);return()=>clearTimeout(t)},a=[e],t[0]=e,t[1]=i,t[2]=a),(0,V.useEffect)(i,a),n}function ir(e){let t=(0,B.c)(86),{config:n}=e,{_:r}=f(),{state:i,refresh:a}=Se(``),[o,s]=(0,V.useState)(null),[c,l]=(0,V.useState)(null),[u,d]=(0,V.useState)(!1),[p,_]=(0,V.useState)(!1),v,y,b,x,S,C,w,T,E,D;if(t[0]!==r||t[1]!==n||t[2]!==p||t[3]!==a||t[4]!==i){D=Symbol.for(`react.early_return_sentinel`);bb0:{let e=i.status===`ready`?(i.data.folder.templates_available??[]).filter(e=>e.scope===n.scope).sort(or):[],o;if(t[15]!==r||t[16]!==a?(o=async function(e){d(!0);let t=await fe(``,e.name);if(d(!1),!t.ok){let{error:e}=t;g.error(r({id:`yOGrCR`,values:{error:e}}));return}let{name:n}=e;g.success(r({id:`I23A-U`,values:{name:n}})),l(null),a()},t[15]=r,t[16]=a,t[17]=o):o=t[17],y=o,i.status===`error`){let{loadErrorTitle:e}=n,{message:r}=i,o=`settings-${n.testIdPrefix}-section`,s;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(s=()=>_(!0),t[18]=s):s=t[18];let c;t[19]!==n.description||t[20]!==n.settingsId||t[21]!==n.testIdPrefix||t[22]!==n.title?(c=(0,$.jsx)(sr,{settingsId:n.settingsId,testIdPrefix:n.testIdPrefix,title:n.title,description:n.description,onNewClick:s}),t[19]=n.description,t[20]=n.settingsId,t[21]=n.testIdPrefix,t[22]=n.title,t[23]=c):c=t[23];let l;t[24]!==e||t[25]!==r?(l=(0,$.jsx)(`div`,{className:`rounded-lg border border-destructive/30 bg-destructive/5 p-4 text-sm text-destructive`,role:`alert`,children:(0,$.jsx)(m,{id:`uH_S-u`,values:{loadErrorTitle:e,message:r}})}),t[24]=e,t[25]=r,t[26]=l):l=t[26];let u;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(u=new Set,t[27]=u):u=t[27];let d;t[28]!==p||t[29]!==a?(d=(0,$.jsx)(ue,{folderPath:``,existingNames:u,open:p,onOpenChange:_,onCreated:a}),t[28]=p,t[29]=a,t[30]=d):d=t[30];let f;t[31]!==n.settingsId||t[32]!==o||t[33]!==c||t[34]!==l||t[35]!==d?(f=(0,$.jsxs)(`section`,{className:`space-y-3`,"aria-labelledby":n.settingsId,"data-testid":o,children:[c,l,d]}),t[31]=n.settingsId,t[32]=o,t[33]=c,t[34]=l,t[35]=d,t[36]=f):f=t[36],D=f;break bb0}if(i.status===`idle`||i.status===`loading`){let e=`settings-${n.testIdPrefix}-section`,r;t[37]!==n.description||t[38]!==n.settingsId||t[39]!==n.testIdPrefix||t[40]!==n.title?(r=(0,$.jsx)(sr,{settingsId:n.settingsId,testIdPrefix:n.testIdPrefix,title:n.title,description:n.description}),t[37]=n.description,t[38]=n.settingsId,t[39]=n.testIdPrefix,t[40]=n.title,t[41]=r):r=t[41];let i;t[42]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,$.jsxs)(`div`,{className:`rounded-lg border bg-card p-3 space-y-2`,children:[(0,$.jsx)(z,{className:`h-12 w-full`}),(0,$.jsx)(z,{className:`h-12 w-full`})]}),t[42]=i):i=t[42];let a;t[43]!==n.settingsId||t[44]!==e||t[45]!==r?(a=(0,$.jsxs)(`section`,{className:`space-y-3`,"aria-labelledby":n.settingsId,"data-testid":e,children:[r,i]}),t[43]=n.settingsId,t[44]=e,t[45]=r,t[46]=a):a=t[46],D=a;break bb0}S=`space-y-3`,C=n.settingsId,w=`settings-${n.testIdPrefix}-section`;let c;t[47]===Symbol.for(`react.memo_cache_sentinel`)?(c=()=>_(!0),t[47]=c):c=t[47],t[48]!==n.description||t[49]!==n.settingsId||t[50]!==n.testIdPrefix||t[51]!==n.title?(T=(0,$.jsx)(sr,{settingsId:n.settingsId,testIdPrefix:n.testIdPrefix,title:n.title,description:n.description,onNewClick:c}),t[48]=n.description,t[49]=n.settingsId,t[50]=n.testIdPrefix,t[51]=n.title,t[52]=T):T=t[52];let u=e.length===0?(0,$.jsx)(`p`,{className:`px-3 py-4 text-sm text-muted-foreground`,"data-testid":`settings-${n.testIdPrefix}-empty`,children:n.emptyMessage}):(0,$.jsx)(`ul`,{className:`space-y-1 p-2`,"data-testid":`settings-${n.testIdPrefix}-list`,children:e.map(e=>(0,$.jsx)(cr,{template:e,badge:n.badge,testIdPrefix:n.testIdPrefix,onEdit:()=>s(e),onDelete:()=>l(e)},e.name))});t[53]===u?E=t[54]:(E=(0,$.jsx)(`div`,{className:`rounded-lg border bg-card`,children:u}),t[53]=u,t[54]=E),v=ue,b=``,x=new Set(e.map(ar))}t[0]=r,t[1]=n,t[2]=p,t[3]=a,t[4]=i,t[5]=v,t[6]=y,t[7]=b,t[8]=x,t[9]=S,t[10]=C,t[11]=w,t[12]=T,t[13]=E,t[14]=D}else v=t[5],y=t[6],b=t[7],x=t[8],S=t[9],C=t[10],w=t[11],T=t[12],E=t[13],D=t[14];if(D!==Symbol.for(`react.early_return_sentinel`))return D;let O;t[55]!==v||t[56]!==p||t[57]!==a||t[58]!==b||t[59]!==x?(O=(0,$.jsx)(v,{folderPath:b,existingNames:x,open:p,onOpenChange:_,onCreated:a}),t[55]=v,t[56]=p,t[57]=a,t[58]=b,t[59]=x,t[60]=O):O=t[60];let k;t[61]===Symbol.for(`react.memo_cache_sentinel`)?(k=e=>{e||s(null)},t[61]=k):k=t[61];let A;t[62]!==o||t[63]!==a?(A=(0,$.jsx)(ge,{folderPath:``,template:o,onOpenChange:k,onSaved:a}),t[62]=o,t[63]=a,t[64]=A):A=t[64];let j=!!c,M;t[65]===u?M=t[66]:(M=e=>{!e&&!u&&l(null)},t[65]=u,t[66]=M);let N;t[67]!==n.deleteWarning||t[68]!==n.itemNoun||t[69]!==c||t[70]!==u||t[71]!==y?(N=c&&(0,$.jsx)(Ae,{itemName:`${n.itemNoun} "${c.name}"`,isSubmitting:u,onDelete:()=>y(c),customDescription:n.deleteWarning}),t[67]=n.deleteWarning,t[68]=n.itemNoun,t[69]=c,t[70]=u,t[71]=y,t[72]=N):N=t[72];let P;t[73]!==j||t[74]!==M||t[75]!==N?(P=(0,$.jsx)(h,{open:j,onOpenChange:M,children:N}),t[73]=j,t[74]=M,t[75]=N,t[76]=P):P=t[76];let F;return t[77]!==A||t[78]!==P||t[79]!==S||t[80]!==C||t[81]!==w||t[82]!==T||t[83]!==E||t[84]!==O?(F=(0,$.jsxs)(`section`,{className:S,"aria-labelledby":C,"data-testid":w,children:[T,E,O,A,P]}),t[77]=A,t[78]=P,t[79]=S,t[80]=C,t[81]=w,t[82]=T,t[83]=E,t[84]=O,t[85]=F):F=t[85],F}function ar(e){return e.name}function or(e,t){let n=(e.title??e.name).toLowerCase(),r=(t.title??t.name).toLowerCase();return n.localeCompare(r)}function sr(e){let t=(0,B.c)(14),{settingsId:n,testIdPrefix:r,title:i,description:o,onNewClick:s}=e,c;t[0]!==n||t[1]!==i?(c=(0,$.jsx)(`h3`,{id:n,className:`text-base font-semibold`,children:i}),t[0]=n,t[1]=i,t[2]=c):c=t[2];let l;t[3]===o?l=t[4]:(l=(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:o}),t[3]=o,t[4]=l);let u;t[5]!==c||t[6]!==l?(u=(0,$.jsxs)(`div`,{children:[c,l]}),t[5]=c,t[6]=l,t[7]=u):u=t[7];let d;t[8]!==s||t[9]!==r?(d=s?(0,$.jsxs)(M,{variant:`outline`,size:`sm`,className:`font-mono uppercase shrink-0`,onClick:s,"data-testid":`settings-${r}-new-button`,children:[(0,$.jsx)(a,{className:`size-3.5`,"aria-hidden":!0}),(0,$.jsx)(m,{id:`G1Gw0v`})]}):null,t[8]=s,t[9]=r,t[10]=d):d=t[10];let f;return t[11]!==u||t[12]!==d?(f=(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[u,d]}),t[11]=u,t[12]=d,t[13]=f):f=t[13],f}function cr(e){let t=(0,B.c)(46),{template:n,badge:r,testIdPrefix:i,onEdit:a,onDelete:o}=e,{_:s}=f(),d=n.title&&n.title!==n.name,p=n.title??n.name,h=`settings-${i}-row`,g=n.name,_=`settings-${i}-row-edit`,v=n.title??n.name,y;t[0]===v?y=t[1]:(y=(0,$.jsx)(`span`,{className:`font-medium truncate`,children:v}),t[0]=v,t[1]=y);let b;t[2]!==d||t[3]!==n.name?(b=d?(0,$.jsx)(`code`,{className:`font-mono text-xs text-muted-foreground shrink-0`,children:n.name}):null,t[2]=d,t[3]=n.name,t[4]=b):b=t[4];let x;t[5]!==r.label||t[6]!==r.variant?(x=(0,$.jsx)(c,{variant:r.variant,className:`ml-auto shrink-0 text-2xs`,children:r.label}),t[5]=r.label,t[6]=r.variant,t[7]=x):x=t[7];let S;t[8]!==y||t[9]!==b||t[10]!==x?(S=(0,$.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[y,b,x]}),t[8]=y,t[9]=b,t[10]=x,t[11]=S):S=t[11];let C;t[12]===n.description?C=t[13]:(C=n.description?(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground truncate mt-0.5`,children:n.description}):null,t[12]=n.description,t[13]=C);let w;t[14]!==a||t[15]!==_||t[16]!==S||t[17]!==C?(w=(0,$.jsxs)(`button`,{type:`button`,onClick:a,className:`min-w-0 flex-1 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring rounded-sm`,"data-testid":_,children:[S,C]}),t[14]=a,t[15]=_,t[16]=S,t[17]=C,t[18]=w):w=t[18];let T;t[19]!==s||t[20]!==p?(T=s({id:`Z7fox7`,values:{rowLabel:p}}),t[19]=s,t[20]=p,t[21]=T):T=t[21];let E;t[22]===Symbol.for(`react.memo_cache_sentinel`)?(E=(0,$.jsx)(N,{className:`size-4`,"aria-hidden":!0}),t[22]=E):E=t[22];let D;t[23]===T?D=t[24]:(D=(0,$.jsx)(ce,{asChild:!0,children:(0,$.jsx)(M,{variant:`ghost`,size:`icon`,className:`size-7 shrink-0 opacity-0 group-hover:opacity-100 focus-visible:opacity-100 data-[state=open]:opacity-100`,"aria-label":T,children:E})}),t[23]=T,t[24]=D);let O=`settings-${i}-row-edit-menuitem`,k,A;t[25]===Symbol.for(`react.memo_cache_sentinel`)?(k=(0,$.jsx)(l,{"aria-hidden":!0}),A=(0,$.jsx)(m,{id:`ePK91l`}),t[25]=k,t[26]=A):(k=t[25],A=t[26]);let j;t[27]!==a||t[28]!==O?(j=(0,$.jsxs)(se,{onSelect:a,"data-testid":O,children:[k,A]}),t[27]=a,t[28]=O,t[29]=j):j=t[29];let P=`settings-${i}-row-delete-menuitem`,F,ee;t[30]===Symbol.for(`react.memo_cache_sentinel`)?(F=(0,$.jsx)(u,{"aria-hidden":!0}),ee=(0,$.jsx)(m,{id:`cnGeoo`}),t[30]=F,t[31]=ee):(F=t[30],ee=t[31]);let I;t[32]!==o||t[33]!==P?(I=(0,$.jsxs)(se,{variant:`destructive`,onSelect:o,"data-testid":P,children:[F,ee]}),t[32]=o,t[33]=P,t[34]=I):I=t[34];let te;t[35]!==j||t[36]!==I?(te=(0,$.jsxs)(oe,{align:`end`,children:[j,I]}),t[35]=j,t[36]=I,t[37]=te):te=t[37];let L;t[38]!==D||t[39]!==te?(L=(0,$.jsxs)(R,{children:[D,te]}),t[38]=D,t[39]=te,t[40]=L):L=t[40];let ne;return t[41]!==h||t[42]!==w||t[43]!==L||t[44]!==n.name?(ne=(0,$.jsxs)(`li`,{className:`group flex items-center gap-2 rounded-md px-2 py-2 hover:bg-muted/50 text-sm`,"data-testid":h,"data-template-name":g,children:[w,L]}),t[41]=h,t[42]=w,t[43]=L,t[44]=n.name,t[45]=ne):ne=t[45],ne}function lr(){let e=(0,B.c)(22),{_:t}=f(),n;e[0]===t?n=e[1]:(n=t({id:`hBMK4W`}),e[0]=t,e[1]=n);let r;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,$.jsx)(m,{id:`nft48x`,components:{0:(0,$.jsx)(`code`,{className:`font-mono`})}}),e[2]=r):r=e[2];let i;e[3]===t?i=e[4]:(i=t({id:`6Pxqwv`}),e[3]=t,e[4]=i);let a;e[5]===t?a=e[6]:(a=t({id:`7-NvM7`}),e[5]=t,e[6]=a);let o;e[7]===t?o=e[8]:(o=t({id:`FQlArb`}),e[7]=t,e[8]=o);let s;e[9]===t?s=e[10]:(s=t({id:`BD0XSC`}),e[9]=t,e[10]=s);let c;e[11]===t?c=e[12]:(c=t({id:`ysxgu8`}),e[11]=t,e[12]=c);let l;e[13]===c?l=e[14]:(l={label:c,variant:`gray`},e[13]=c,e[14]=l);let u;return e[15]!==n||e[16]!==i||e[17]!==a||e[18]!==o||e[19]!==s||e[20]!==l?(u=(0,$.jsx)(ir,{config:{scope:`local`,title:n,description:r,emptyMessage:i,deleteWarning:a,itemNoun:o,loadErrorTitle:s,badge:l,settingsId:`settings-project-templates-title`,testIdPrefix:`project-templates`}}),e[15]=n,e[16]=i,e[17]=a,e[18]=o,e[19]=s,e[20]=l,e[21]=u):u=e[21],u}function ur(e,t){if(e.length===0)throw Error(`buildPatch: path must be non-empty`);let[n,...r]=e;return r.length===0?{[String(n)]:t}:{[String(n)]:ur(r,t)}}function dr(e){let t=e;for(let e=0;e<16;e++){if(t==null)return;let e=t?._zod?.def;if(e?.type===`default`){let t=e.defaultValue;return typeof t==`function`?t():t}let n=t?._zod?.def?.innerType;if(n===void 0)return;t=n}}function fr(e){let t=e;for(let e=0;e<16;e++){if(t==null)return;let e=t?._zod?.def;if(!e)return;if(e.type===`default`||e.type===`optional`||e.type===`nullable`){t=e.innerType;continue}return e.type}}function pr(e){let t=e;for(let e=0;e<16;e++){if(t==null)return;let e=t?._zod?.def;if(!e)return;if(e.type===`enum`)return e.entries?Object.values(e.entries):void 0;if(e.innerType!==void 0){t=e.innerType;continue}return}}function mr(e){let t=(0,B.c)(14),n;t[0]===e?n=t[1]:(n=e.current(),t[0]=e,t[1]=n);let r=n,i;t[2]===r?i=t[3]:(i={defaultValues:r,mode:`onBlur`},t[2]=r,t[3]=i);let a=nn(i),o,s;t[4]!==e||t[5]!==a?(o=()=>e.subscribe(e=>{hr(a,e)}),s=[e,a],t[4]=e,t[5]=a,t[6]=o,t[7]=s):(o=t[6],s=t[7]),(0,V.useEffect)(o,s);let c;t[8]!==e||t[9]!==a?(c=t=>gr(a,e,t),t[8]=e,t[9]=a,t[10]=c):c=t[10];let l=c,u;return t[11]!==l||t[12]!==a?(u={form:a,commitField:l},t[11]=l,t[12]=a,t[13]=u):u=t[13],u}function hr(e,t){e.reset(t,{keepDirtyValues:!0,keepDirty:!0,keepTouched:!0})}function gr(e,t,n){let r=e.getValues(n),i=ur(yr(n),r),a=t.patch(i);if(a.ok)return e.clearErrors(n),e.resetField(n,{defaultValue:r,keepError:!1}),!0;if(w(a.error)&&a.error.code===`SCHEMA_INVALID`&&a.error.issues.length>0){e.clearErrors(n);for(let t of a.error.issues){let r=t.path.length>0?t.path.map(String).join(`.`):n;e.setError(r,{type:`config-binding`,message:t.message})}}else e.setError(n,{type:`config-binding`,message:_r(a.error,n)});return!1}function _r(e,t){if(w(e)&&e.code===`SCHEMA_INVALID`){let n=e.issues.find(e=>vr(e,t));if(n)return n.message}return O(e)}function vr(e,t){return e.path.map(String).join(`.`)===t}function yr(e){return e.split(`.`)}var br=[{path:[`appearance`,`theme`],label:{id:`FEr96N`},description:{id:`JZ8cO6`},control:`enum-toggle`},{path:[`editor`,`wordWrap`],label:{id:`iKSP5j`},description:{id:`mmpzAq`}}];function xr(e){let t=(0,B.c)(9),{activeId:n,userBinding:r,okignoreBinding:i,okignoreSynced:a}=e,{_:o}=f();if(n===`preferences`){let e;return t[0]!==o||t[1]!==r?(e=r?(0,$.jsx)(wr,{title:o({id:`Q6hhn8`}),description:o({id:`Y_kL7X`}),scope:`user`,binding:r,fields:br}):(0,$.jsx)(Cr,{}),t[0]=o,t[1]=r,t[2]=e):e=t[2],e}if(n===`sync`){let e;return t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Er,{}),t[3]=e):e=t[3],e}if(n===`project-templates`){let e;return t[4]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(lr,{}),t[4]=e):e=t[4],e}if(n===`okignore`){let e;return t[5]!==i||t[6]!==a?(e=(0,$.jsx)(kn,{binding:i,synced:a}),t[5]=i,t[6]=a,t[7]=e):e=t[7],e}if(n===`claude-desktop`){let e;return t[8]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Nr,{}),t[8]=e):e=t[8],e}return null}function Sr(e){if(!w(e)||e.code!==`SCHEMA_INVALID`)return null;let t=e.issues[0];return!t||t.path.length===0?null:t.path.map(String).join(`.`)}function Cr(){let e=(0,B.c)(3),t,n;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(z,{className:`h-5 w-32`}),n=(0,$.jsx)(z,{className:`h-4 w-64`}),e[0]=t,e[1]=n):(t=e[0],n=e[1]);let r;return e[2]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,$.jsxs)(`div`,{className:`space-y-3`,children:[t,n,(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(z,{className:`h-9 w-full`}),(0,$.jsx)(z,{className:`h-9 w-full`})]})]}),e[2]=r):r=e[2],r}function wr(e){let t=(0,B.c)(14),{title:n,description:r,scope:i,binding:a,fields:o}=e,{form:s,commitField:c}=mr(a),[l,u]=(0,V.useState)(null),d=(0,V.useRef)(null),f,p;t[0]!==s||t[1]!==i?(f=()=>{let e=i===`project`?T:C,t=we(t=>{if(t.docName!==e)return;g.error(O(t.error),{duration:8e3});let n=Sr(t.error);n&&(s.setError(n,{type:`config-validation-rejected`,message:_r(t.error,n)}),s.setFocus(n),u(n),d.current&&clearTimeout(d.current),d.current=setTimeout(()=>{u(null),s.clearErrors(n)},600))});return()=>{t(),d.current&&clearTimeout(d.current)}},p=[i,s],t[0]=s,t[1]=i,t[2]=f,t[3]=p):(f=t[2],p=t[3]),(0,V.useEffect)(f,p);let m;t[4]!==c||t[5]!==r||t[6]!==o||t[7]!==l||t[8]!==i||t[9]!==n?(m=(0,$.jsx)(Tr,{title:n,description:r,scope:i,fields:o,commitField:c,flashedPath:l}),t[4]=c,t[5]=r,t[6]=o,t[7]=l,t[8]=i,t[9]=n,t[10]=m):m=t[10];let h;return t[11]!==s||t[12]!==m?(h=(0,$.jsx)(rn,{...s,children:m}),t[11]=s,t[12]=m,t[13]=h):h=t[13],h}function Tr(e){let t=(0,B.c)(23),{title:n,description:r,scope:i,fields:a,commitField:o,flashedPath:s}=e,c=`settings-section-${i}-title`,l;t[0]!==n||t[1]!==c?(l=(0,$.jsx)(`h3`,{id:c,className:`text-base font-semibold`,children:n}),t[0]=n,t[1]=c,t[2]=l):l=t[2];let u;t[3]===r?u=t[4]:(u=(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:r}),t[3]=r,t[4]=u);let d;t[5]!==l||t[6]!==u?(d=(0,$.jsxs)(`div`,{className:`space-y-1`,children:[l,u]}),t[5]=l,t[6]=u,t[7]=d):d=t[7];let f;if(t[8]!==o||t[9]!==a||t[10]!==s||t[11]!==i){let e;t[13]!==o||t[14]!==s||t[15]!==i?(e=e=>(0,$.jsx)(Dr,{field:e,scope:i,commitField:o,isFlashed:s===e.path.join(`.`)},e.path.join(`.`)),t[13]=o,t[14]=s,t[15]=i,t[16]=e):e=t[16],f=a.map(e),t[8]=o,t[9]=a,t[10]=s,t[11]=i,t[12]=f}else f=t[12];let p;t[17]===f?p=t[18]:(p=(0,$.jsx)(`div`,{className:`space-y-10`,children:f}),t[17]=f,t[18]=p);let m;return t[19]!==d||t[20]!==p||t[21]!==c?(m=(0,$.jsxs)(`section`,{"aria-labelledby":c,className:`space-y-3`,children:[d,p]}),t[19]=d,t[20]=p,t[21]=c,t[22]=m):m=t[22],m}function Er(){let e=(0,B.c)(26),{_:t}=f(),n=Oe(),{projectLocalConfig:r,projectLocalSynced:i}=o(),{confirmOpen:a,setConfirmOpen:c,onToggleRequest:l,onConfirm:u}=le(ie());if(n&&!n.hasRemote&&n.state===`dormant`){let t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(`h3`,{id:`settings-sync-title`,className:`text-base font-semibold`,children:(0,$.jsx)(m,{id:`Nu4DdT`})}),e[0]=t):t=e[0];let n;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsxs)(`div`,{className:`space-y-1`,children:[t,(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:(0,$.jsx)(m,{id:`8C2UQ5`})})]}),e[1]=n):n=e[1];let r;return e[2]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,$.jsxs)(`section`,{"aria-labelledby":`settings-sync-title`,className:`space-y-3`,"data-testid":`settings-sync-empty`,children:[n,(0,$.jsx)(`div`,{className:`rounded-md border p-3 text-sm text-muted-foreground`,children:(0,$.jsx)(m,{id:`vQayZz`,components:{0:(0,$.jsx)(`code`,{className:`rounded bg-muted px-1 py-0.5 font-mono text-xs`})}})})]}),e[2]=r):r=e[2],r}let d=r?.autoSync?.enabled??!1,p=!i,h;e[3]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,$.jsx)(`h3`,{id:`settings-sync-title`,className:`text-base font-semibold`,children:(0,$.jsx)(m,{id:`Nu4DdT`})}),e[3]=h):h=e[3];let g;e[4]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,$.jsxs)(`div`,{className:`space-y-1`,children:[h,(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:(0,$.jsx)(m,{id:`T67A0Y`})})]}),e[4]=g):g=e[4];let _;e[5]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,$.jsx)(`label`,{htmlFor:`settings-sync-toggle`,className:`text-sm font-medium`,children:(0,$.jsx)(m,{id:`Nx7BWE`})}),e[5]=_):_=e[5];let v;e[6]===d?v=e[7]:(v=(0,$.jsxs)(`div`,{children:[_,(0,$.jsx)(`p`,{className:`text-muted-foreground text-1sm`,children:d?(0,$.jsx)(m,{id:`-gdcIo`}):(0,$.jsx)(m,{id:`qUB_o_`})})]}),e[6]=d,e[7]=v);let y;e[8]!==t||e[9]!==d?(y=t(d?{id:`OmHTGj`}:{id:`MKOVhz`}),e[8]=t,e[9]=d,e[10]=y):y=e[10];let b;e[11]!==p||e[12]!==d||e[13]!==l||e[14]!==y?(b=(0,$.jsx)(s,{id:`settings-sync-toggle`,checked:d,disabled:p,onCheckedChange:l,"aria-label":y,"data-testid":`settings-sync-toggle`}),e[11]=p,e[12]=d,e[13]=l,e[14]=y,e[15]=b):b=e[15];let x;e[16]!==v||e[17]!==b?(x=(0,$.jsx)(`div`,{className:`rounded-md border p-3`,children:(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[v,b]})}),e[16]=v,e[17]=b,e[18]=x):x=e[18];let S;e[19]!==a||e[20]!==u||e[21]!==c?(S=(0,$.jsx)(Ce,{open:a,onOpenChange:c,onConfirm:u}),e[19]=a,e[20]=u,e[21]=c,e[22]=S):S=e[22];let C;return e[23]!==x||e[24]!==S?(C=(0,$.jsxs)(`section`,{"aria-labelledby":`settings-sync-title`,className:`space-y-3`,children:[g,x,S]}),e[23]=x,e[24]=S,e[25]=C):C=e[25],C}function Dr({field:e,scope:t,commitField:n,isFlashed:r}){"use no memo";let{_:i}=f(),a=ut(),o=D(b,e.path),s=o?fr(o):void 0,c=o?dr(o):void 0,l=o?pr(o):void 0,u=o?E(o):void 0,d=u?.scope===`project`&&t!==`project`||u?.scope===`user`&&t!==`user`,p=e.path.join(`.`),h=i(e.label),[g,x]=(0,V.useState)(!1),S=(0,V.useRef)(null);(0,V.useEffect)(()=>()=>{S.current&&clearTimeout(S.current)},[]);let C=()=>{x(!0),S.current&&clearTimeout(S.current),S.current=setTimeout(()=>x(!1),1200)},w=()=>{let e=n(p);return e&&C(),e},T=()=>a.getFieldState(p).isDirty?w():!0,O=()=>{let e=c===void 0?null:c;a.setValue(p,e,{shouldDirty:!1}),w()},k=A(`relative`,r&&`animate-settings-flash`);return(0,$.jsx)(on,{control:a.control,name:p,render:({field:n})=>{let r=!d&&(c!==void 0||n.value!==void 0);return(0,$.jsxs)(ln,{className:k,"data-field":e.path.join(`.`),"data-scope":t,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsx)(un,{className:`text-sm font-medium`,children:h}),r?(0,$.jsxs)(v,{children:[(0,$.jsx)(_,{asChild:!0,children:(0,$.jsx)(M,{variant:`ghost`,size:`icon`,className:`h-5 w-5 text-muted-foreground opacity-60 hover:opacity-100`,onClick:O,"aria-label":i({id:`lhjq3G`,values:{labelText:h}}),children:(0,$.jsx)(Ie,{className:`size-3.5`})})}),(0,$.jsx)(y,{children:(0,$.jsx)(m,{id:`L-rMC9`})})]}):null]}),e.description?(0,$.jsx)(fn,{className:`text-muted-foreground text-1sm`,children:i(e.description)}):null,(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(dn,{children:(0,$.jsx)(Or,{field:e,ctl:n,typeTag:s,enumOptions:l,onCommit:T})}),(0,$.jsx)(Mr,{visible:g})]}),(0,$.jsx)(pn,{"data-field-error":e.path.join(`.`)})]})}})}function Or({field:e,ctl:t,typeTag:n,enumOptions:r,onCommit:i,...a}){"use no memo";let{_:o}=f();if(n===`boolean`)return(0,$.jsx)(s,{...a,checked:!!t.value,ref:t.ref,onCheckedChange:e=>{t.onChange(e),i()},onBlur:t.onBlur});if(n===`enum`&&r&&r.length>0&&(e.control===`enum-toggle`||r.length<=4)){let{id:n,...s}=a;return(0,$.jsx)(Pe,{...s,type:`single`,value:typeof t.value==`string`?t.value:``,ref:t.ref,onValueChange:e=>{e&&(t.onChange(e),i())},onBlur:t.onBlur,variant:`segmented`,size:`sm`,spacing:1,className:`bg-muted dark:bg-background p-0.5 rounded-lg`,"aria-label":o(e.label),children:r.map((e,t)=>(0,$.jsx)(Ne,{value:e,id:t===0?n:void 0,className:`text-1sm capitalize`,children:e},e))})}return n===`number`||n===`int`?(0,$.jsx)(Ar,{ctl:t,onCommit:i,...a}):n===`array`?(0,$.jsx)(jr,{ctl:t,onCommit:i,...a}):(0,$.jsx)(kr,{ctl:t,onCommit:i,...a})}function kr({ctl:e,onCommit:t,...n}){"use no memo";return(0,$.jsx)(Me,{...n,value:typeof e.value==`string`?e.value:``,ref:e.ref,onChange:t=>e.onChange(t.target.value),onBlur:()=>{e.onBlur(),t()},onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),t())},className:`h-8 text-sm`})}function Ar({ctl:e,onCommit:t,...n}){"use no memo";let[r,i]=(0,V.useState)(e.value===void 0?``:String(e.value)),a=(0,V.useRef)(e.value);(0,V.useEffect)(()=>{a.current!==e.value&&(i(e.value===void 0?``:String(e.value)),a.current=e.value)},[e.value]);let o=()=>{let n=Number(r);if(!Number.isFinite(n)){e.onChange(r),t();return}e.onChange(n),t(),a.current=n};return(0,$.jsx)(Me,{...n,type:`number`,value:r,ref:e.ref,onChange:e=>i(e.target.value),onBlur:()=>{e.onBlur(),o()},onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),o())},className:`h-8 w-28 text-sm tabular-nums`})}function jr({ctl:e,onCommit:t,...n}){"use no memo";let r=Array.isArray(e.value)?e.value.join(`
|
|
3
|
+
`):``,[i,a]=(0,V.useState)(r),o=(0,V.useRef)(r);(0,V.useEffect)(()=>{let t=Array.isArray(e.value)?e.value.join(`
|
|
4
|
+
`):``;t!==o.current&&(a(t),o.current=t)},[e.value]);let s=()=>{let n=i.split(`
|
|
5
|
+
`).map(e=>e.trim()).filter(e=>e.length>0);e.onChange(n),t(),o.current=n.join(`
|
|
6
|
+
`)};return(0,$.jsx)(`textarea`,{...n,value:i,ref:e.ref,onChange:e=>a(e.target.value),onBlur:()=>{e.onBlur(),s()},rows:Math.max(2,Math.min(6,i.split(`
|
|
7
|
+
`).length)),className:`min-h-16 w-full rounded-md border border-input bg-background px-3 py-1.5 font-mono text-xs outline-none transition-colors focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40`})}function Mr(e){let t=(0,B.c)(4),{visible:n}=e,r;t[0]===n?r=t[1]:(r=n?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(d,{"aria-hidden":`true`,className:`size-3.5`}),(0,$.jsx)(`span`,{className:`sr-only`,children:(0,$.jsx)(m,{id:`idD8Ev`})})]}):null,t[0]=n,t[1]=r);let i;return t[2]===r?i=t[3]:(i=(0,$.jsx)(`span`,{role:`status`,"aria-live":`polite`,className:`text-emerald-600`,children:r}),t[2]=r,t[3]=i),i}function Nr(){let e=(0,B.c)(16),[t,n]=(0,V.useState)(!1),{skillInstalled:r,refresh:i}=_e(),a;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,$.jsx)(`h3`,{id:`settings-integrations-title`,className:`text-base font-semibold`,children:(0,$.jsx)(m,{id:`nbfdhU`})}),e[0]=a):a=e[0];let o;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,$.jsxs)(`div`,{className:`space-y-1`,children:[a,(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:(0,$.jsx)(m,{id:`FF5rwn`})})]}),e[1]=o):o=e[1];let s;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,$.jsx)(`div`,{className:`text-sm font-medium`,children:(0,$.jsx)(m,{id:`QQghPu`})}),e[2]=s):s=e[2];let c;e[3]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,$.jsxs)(`div`,{children:[s,(0,$.jsx)(`p`,{className:`text-muted-foreground text-1sm`,children:(0,$.jsx)(m,{id:`Wcv-Zi`})})]}),e[3]=c):c=e[3];let l;e[4]===Symbol.for(`react.memo_cache_sentinel`)?(l=()=>n(!0),e[4]=l):l=e[4];let u;e[5]===r?u=e[6]:(u=(0,$.jsx)(`div`,{className:`rounded-md border p-3`,children:(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[c,(0,$.jsx)(M,{variant:`outline`,size:`sm`,onClick:l,"data-testid":`settings-install-claude-desktop`,className:`uppercase font-mono`,children:r?(0,$.jsx)(m,{id:`YGIi_c`}):(0,$.jsx)(m,{id:`TKQ7K-`})})]})}),e[5]=r,e[6]=u);let d;e[7]===i?d=e[8]:(d=e=>{n(e),e||i()},e[7]=i,e[8]=d);let f;e[9]!==t||e[10]!==r||e[11]!==d?(f=(0,$.jsx)(de,{open:t,onOpenChange:d,reinstall:r}),e[9]=t,e[10]=r,e[11]=d,e[12]=f):f=e[12];let p;return e[13]!==u||e[14]!==f?(p=(0,$.jsxs)(`section`,{"aria-labelledby":`settings-integrations-title`,className:`space-y-3`,children:[o,u,f]}),e[13]=u,e[14]=f,e[15]=p):p=e[15],p}export{xr as SettingsDialogBody};
|