ninekit-cli 1.0.0 → 1.1.0
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/README.md
CHANGED
|
@@ -36,16 +36,6 @@ Comprehensive documentation in `/docs`:
|
|
|
36
36
|
- **[nk watch](./docs/nk-watch.md)** - GitHub issue monitoring daemon
|
|
37
37
|
- **[nk content](./docs/nk-content.md)** - Automated content generation from git activity
|
|
38
38
|
|
|
39
|
-
## Prerequisites
|
|
40
|
-
|
|
41
|
-
Before using NineKit CLI, you need to:
|
|
42
|
-
|
|
43
|
-
1. **Purchase a NineKit Starter Kit** from [NineKit.cc](https://ninekit.chiendt.io.vn)
|
|
44
|
-
2. **Get Repository Access**: After purchase, you'll receive access to the private GitHub repository containing your kit
|
|
45
|
-
3. **Create a GitHub Personal Access Token** (PAT) with `repo` scope to download releases
|
|
46
|
-
|
|
47
|
-
Without a purchased kit and repository access, the CLI will not be able to download any project templates.
|
|
48
|
-
|
|
49
39
|
## Installation
|
|
50
40
|
|
|
51
41
|
The NineKit CLI is published on npm at [npmjs.com/package/ninekit-cli](https://www.npmjs.com/package/ninekit-cli).
|
package/cli-manifest.json
CHANGED
package/dist/index.js
CHANGED
|
@@ -64309,7 +64309,7 @@ var package_default;
|
|
|
64309
64309
|
var init_package = __esm(() => {
|
|
64310
64310
|
package_default = {
|
|
64311
64311
|
name: "ninekit-cli",
|
|
64312
|
-
version: "1.
|
|
64312
|
+
version: "1.1.0",
|
|
64313
64313
|
description: "CLI tool for bootstrapping and updating NineKit projects",
|
|
64314
64314
|
type: "module",
|
|
64315
64315
|
repository: {
|
|
@@ -66179,7 +66179,7 @@ async function checkHookLogs(projectDir) {
|
|
|
66179
66179
|
async function checkCliVersion() {
|
|
66180
66180
|
try {
|
|
66181
66181
|
if (process.env.NK_TEST_HOME) {
|
|
66182
|
-
logger.verbose("
|
|
66182
|
+
logger.verbose("NinekitChecker: Skipping CLI version check in test mode");
|
|
66183
66183
|
return {
|
|
66184
66184
|
id: "cli-version",
|
|
66185
66185
|
name: "CLI Version",
|
|
@@ -82859,12 +82859,12 @@ var BANNER_LINES;
|
|
|
82859
82859
|
var init_help_banner = __esm(() => {
|
|
82860
82860
|
init_help_colors();
|
|
82861
82861
|
BANNER_LINES = [
|
|
82862
|
-
"
|
|
82863
|
-
"
|
|
82864
|
-
"
|
|
82865
|
-
"
|
|
82866
|
-
"
|
|
82867
|
-
"
|
|
82862
|
+
" █████╗ ██╗ ██╗",
|
|
82863
|
+
"██╔══██╗██║ ██╔╝",
|
|
82864
|
+
"╚██████║█████╔╝ ",
|
|
82865
|
+
" ╚═══██║██╔═██╗ ",
|
|
82866
|
+
" █████╔╝██║ ██╗",
|
|
82867
|
+
" ╚════╝ ╚═╝ ╚═╝"
|
|
82868
82868
|
];
|
|
82869
82869
|
});
|
|
82870
82870
|
|
|
@@ -84672,7 +84672,7 @@ function getBaseUrl() {
|
|
|
84672
84672
|
return (process.env.NK_BASE_URL ?? "https://ninekit.chiendt.io.vn").replace(/\/$/, "");
|
|
84673
84673
|
}
|
|
84674
84674
|
|
|
84675
|
-
class
|
|
84675
|
+
class NinekitHttpClient {
|
|
84676
84676
|
apiKey;
|
|
84677
84677
|
baseUrl;
|
|
84678
84678
|
constructor(apiKey, baseUrl) {
|
|
@@ -84755,7 +84755,7 @@ function createApiClient(claudeDir) {
|
|
|
84755
84755
|
if (!apiKey) {
|
|
84756
84756
|
throw new CkApiError("MISSING_API_KEY", "No API key found. Run `nk api setup` to configure your NineKit API key.", 401);
|
|
84757
84757
|
}
|
|
84758
|
-
return new
|
|
84758
|
+
return new NinekitHttpClient(apiKey);
|
|
84759
84759
|
}
|
|
84760
84760
|
|
|
84761
84761
|
// src/commands/api/reviewweb/reviewweb-extract-handler.ts
|
|
@@ -89793,70 +89793,70 @@ init_shared2();
|
|
|
89793
89793
|
init_hook_health_checker();
|
|
89794
89794
|
|
|
89795
89795
|
// src/domains/health-checks/ninekit-checker.ts
|
|
89796
|
-
class
|
|
89796
|
+
class NinekitChecker {
|
|
89797
89797
|
group = "ninekit";
|
|
89798
89798
|
projectDir;
|
|
89799
89799
|
constructor(projectDir = process.cwd()) {
|
|
89800
89800
|
this.projectDir = projectDir;
|
|
89801
89801
|
}
|
|
89802
89802
|
async run() {
|
|
89803
|
-
logger.verbose("
|
|
89803
|
+
logger.verbose("NinekitChecker: Scanning NineKit setup", {
|
|
89804
89804
|
projectDir: this.projectDir
|
|
89805
89805
|
});
|
|
89806
89806
|
const setup = await getNineKitSetup(this.projectDir);
|
|
89807
|
-
logger.verbose("
|
|
89807
|
+
logger.verbose("NinekitChecker: Setup scan complete");
|
|
89808
89808
|
const results = [];
|
|
89809
|
-
logger.verbose("
|
|
89809
|
+
logger.verbose("NinekitChecker: Checking CLI version");
|
|
89810
89810
|
results.push(await checkCliVersion());
|
|
89811
|
-
logger.verbose("
|
|
89811
|
+
logger.verbose("NinekitChecker: Checking CLI install method");
|
|
89812
89812
|
results.push(await checkCliInstallMethod());
|
|
89813
|
-
logger.verbose("
|
|
89813
|
+
logger.verbose("NinekitChecker: Checking global install");
|
|
89814
89814
|
results.push(checkGlobalInstall(setup));
|
|
89815
|
-
logger.verbose("
|
|
89815
|
+
logger.verbose("NinekitChecker: Checking project install");
|
|
89816
89816
|
results.push(checkProjectInstall(setup));
|
|
89817
|
-
logger.verbose("
|
|
89817
|
+
logger.verbose("NinekitChecker: Checking CLAUDE.md files");
|
|
89818
89818
|
results.push(...checkClaudeMd(setup, this.projectDir));
|
|
89819
|
-
logger.verbose("
|
|
89819
|
+
logger.verbose("NinekitChecker: Checking active plan");
|
|
89820
89820
|
results.push(checkActivePlan(this.projectDir));
|
|
89821
|
-
logger.verbose("
|
|
89821
|
+
logger.verbose("NinekitChecker: Checking skills scripts");
|
|
89822
89822
|
results.push(...checkSkillsScripts(setup));
|
|
89823
|
-
logger.verbose("
|
|
89823
|
+
logger.verbose("NinekitChecker: Checking component counts");
|
|
89824
89824
|
results.push(checkComponentCounts(setup));
|
|
89825
|
-
logger.verbose("
|
|
89825
|
+
logger.verbose("NinekitChecker: Checking skill budget");
|
|
89826
89826
|
results.push(...await checkSkillBudget(setup, this.projectDir));
|
|
89827
|
-
logger.verbose("
|
|
89827
|
+
logger.verbose("NinekitChecker: Checking required environment keys");
|
|
89828
89828
|
results.push(...await checkEnvKeys(setup));
|
|
89829
|
-
logger.verbose("
|
|
89829
|
+
logger.verbose("NinekitChecker: Checking global dir readability");
|
|
89830
89830
|
results.push(await checkGlobalDirReadable());
|
|
89831
|
-
logger.verbose("
|
|
89831
|
+
logger.verbose("NinekitChecker: Checking global dir writability");
|
|
89832
89832
|
results.push(await checkGlobalDirWritable());
|
|
89833
|
-
logger.verbose("
|
|
89833
|
+
logger.verbose("NinekitChecker: Checking hooks directory");
|
|
89834
89834
|
results.push(await checkHooksExist(this.projectDir));
|
|
89835
|
-
logger.verbose("
|
|
89835
|
+
logger.verbose("NinekitChecker: Checking hook syntax");
|
|
89836
89836
|
results.push(await checkHookSyntax(this.projectDir));
|
|
89837
|
-
logger.verbose("
|
|
89837
|
+
logger.verbose("NinekitChecker: Checking hook dependencies");
|
|
89838
89838
|
results.push(await checkHookDeps(this.projectDir));
|
|
89839
|
-
logger.verbose("
|
|
89839
|
+
logger.verbose("NinekitChecker: Checking hook runtime");
|
|
89840
89840
|
results.push(await checkHookRuntime(this.projectDir));
|
|
89841
|
-
logger.verbose("
|
|
89841
|
+
logger.verbose("NinekitChecker: Checking hook command paths");
|
|
89842
89842
|
results.push(await checkHookCommandPaths(this.projectDir));
|
|
89843
|
-
logger.verbose("
|
|
89843
|
+
logger.verbose("NinekitChecker: Checking legacy hook prompts");
|
|
89844
89844
|
results.push(await checkLegacyHookPrompts(this.projectDir));
|
|
89845
|
-
logger.verbose("
|
|
89845
|
+
logger.verbose("NinekitChecker: Checking hook file references");
|
|
89846
89846
|
results.push(await checkHookFileReferences(this.projectDir));
|
|
89847
|
-
logger.verbose("
|
|
89847
|
+
logger.verbose("NinekitChecker: Checking hook config");
|
|
89848
89848
|
results.push(await checkHookConfig(this.projectDir));
|
|
89849
|
-
logger.verbose("
|
|
89849
|
+
logger.verbose("NinekitChecker: Checking hook crash logs");
|
|
89850
89850
|
results.push(await checkHookLogs(this.projectDir));
|
|
89851
|
-
logger.verbose("
|
|
89851
|
+
logger.verbose("NinekitChecker: Checking Python venv");
|
|
89852
89852
|
results.push(await checkPythonVenv(this.projectDir));
|
|
89853
|
-
logger.verbose("
|
|
89853
|
+
logger.verbose("NinekitChecker: Checking settings.json validity");
|
|
89854
89854
|
results.push(await checkSettingsValid(this.projectDir));
|
|
89855
|
-
logger.verbose("
|
|
89855
|
+
logger.verbose("NinekitChecker: Checking path references");
|
|
89856
89856
|
results.push(await checkPathRefsValid(this.projectDir));
|
|
89857
|
-
logger.verbose("
|
|
89857
|
+
logger.verbose("NinekitChecker: Checking project config completeness");
|
|
89858
89858
|
results.push(await checkProjectConfigCompleteness(setup, this.projectDir));
|
|
89859
|
-
logger.verbose("
|
|
89859
|
+
logger.verbose("NinekitChecker: All checks complete");
|
|
89860
89860
|
return results;
|
|
89861
89861
|
}
|
|
89862
89862
|
}
|
|
@@ -91061,7 +91061,7 @@ class ReportGenerator {
|
|
|
91061
91061
|
const divider = "=".repeat(65);
|
|
91062
91062
|
const sectionDivider = "─".repeat(65);
|
|
91063
91063
|
lines.push(divider);
|
|
91064
|
-
lines.push("
|
|
91064
|
+
lines.push("NINEKIT DIAGNOSTIC REPORT");
|
|
91065
91065
|
lines.push(`Generated: ${summary.timestamp}`);
|
|
91066
91066
|
lines.push(`CLI Version: ${this.getSystemInfo().cliVersion}`);
|
|
91067
91067
|
lines.push(divider);
|
|
@@ -91447,7 +91447,7 @@ async function doctorCommand(options2 = {}) {
|
|
|
91447
91447
|
function createDoctorRunner(options2) {
|
|
91448
91448
|
const runner = new CheckRunner(options2);
|
|
91449
91449
|
runner.registerChecker(new SystemChecker);
|
|
91450
|
-
runner.registerChecker(new
|
|
91450
|
+
runner.registerChecker(new NinekitChecker);
|
|
91451
91451
|
runner.registerChecker(new AuthChecker);
|
|
91452
91452
|
runner.registerChecker(new PlatformChecker);
|
|
91453
91453
|
runner.registerChecker(new NetworkChecker);
|
|
@@ -27,7 +27,7 @@ Please change the parent <Route path="${b}"> to <Route path="${b==="/"?"*":`${b}
|
|
|
27
27
|
rounded-full transition-all
|
|
28
28
|
${r?"w-0.5 h-8":"h-0.5 w-8"}
|
|
29
29
|
${e?"bg-dash-accent":"bg-dash-border group-hover:bg-dash-text-muted"}
|
|
30
|
-
`})})},b4=[{type:"navigation",name:"Dashboard",description:"Project overview",route:"/"},{type:"navigation",name:"Config Editor",description:"Edit Claude configuration",route:"/config/global"},{type:"navigation",name:"Skills",description:"Browse and manage skills",route:"/skills"},{type:"navigation",name:"Migrate",description:"Migrate stack to other providers",route:"/migrate"},{type:"navigation",name:"Status Line",description:"Customize Claude Code statusline",route:"/statusline"},{type:"navigation",name:"Plans",description:"Visual dashboard for plans and phases",route:"/plans"},{type:"navigation",name:"System",description:"System updates and environment info",route:"/system"}];function y4(t,e){if(!e.trim())return!0;const n=`${t.name} ${t.description}`.toLowerCase();return e.toLowerCase().trim().split(/\s+/).every(r=>n.includes(r))}function a1(t){const e=[];for(const n of t)n.children?e.push(...a1(n.children)):e.push({type:"command",name:n.name,description:n.description??"",route:`/commands?selected=${encodeURIComponent(n.path)}`});return e}function v4({projects:t}){const[e,n]=g.useState([]),[r,s]=g.useState(!0);g.useEffect(()=>{let l=!1;async function d(){const u=[],[h,f,p]=await Promise.allSettled([fetch("/api/agents/browser"),fetch("/api/commands"),fetch("/api/skills/browse")]);if(h.status==="fulfilled"&&h.value.ok)try{const m=await h.value.json();for(const x of m.agents??[])u.push({type:"agent",name:x.name||x.slug,description:x.description??"",route:`/agents?selected=${encodeURIComponent(x.slug)}`})}catch{}if(f.status==="fulfilled"&&f.value.ok)try{const m=await f.value.json();u.push(...a1(m.tree??[]))}catch{}if(p.status==="fulfilled"&&p.value.ok)try{const m=await p.value.json();for(const x of m.skills??[])u.push({type:"skill",name:x.name,description:x.description??"",route:`/skills?selected=${encodeURIComponent(x.name)}`})}catch{}l||(n(u),s(!1))}return d(),()=>{l=!0}},[]);const i=g.useMemo(()=>t.filter(l=>!l.path.endsWith("/.claude")&&l.path!=="~/.claude").map(l=>({type:"project",name:l.name||l.path.split("/").pop()||l.path,description:l.path,route:`/project/${l.id}`})),[t]),o=g.useMemo(()=>[...b4,...i,...e],[i,e]);return{search:g.useMemo(()=>l=>{const u=l.trim()?o.filter(f=>y4(f,l)):o,h={project:[],navigation:[],agent:[],command:[],skill:[]};for(const f of u){const p=h[f.type];p.length<5&&p.push(f)}return h},[o]),loading:r}}const Vg=["navigation","project","agent","command","skill"],w4={navigation:"bg-dash-accent/20 text-dash-accent",project:"bg-dash-text-muted/20 text-dash-text-muted",agent:"bg-[#e85d4a]/20 text-[#e85d4a]",command:"bg-blue-500/20 text-blue-400",skill:"bg-green-500/20 text-green-400"};function Wg({text:t,query:e}){if(!e.trim())return c.jsx("span",{children:t});const n=e.trim().toLowerCase().split(/\s+/).filter(Boolean).sort((i,o)=>o.length-i.length),r=[];let s=t;for(;s.length>0;){let i=-1,o=0,a="";for(const l of n){const d=s.toLowerCase().indexOf(l);d!==-1&&(i===-1||d<i||d===i&&l.length>o)&&(i=d,o=l.length,a=l)}if(i===-1||!a){r.push({text:s,match:!1});break}i>0&&r.push({text:s.slice(0,i),match:!1}),r.push({text:s.slice(i,i+o),match:!0}),s=s.slice(i+o)}return c.jsx("span",{children:r.map((i,o)=>i.match?c.jsx("mark",{className:"bg-dash-accent/30 text-dash-text rounded-sm px-0.5",children:i.text},`m${o}`):c.jsx("span",{children:i.text},`s${o}`))})}const k4=({open:t,projects:e,onClose:n})=>{const{t:r}=te(),s=Lt(),i=g.useRef(null),o=g.useRef(null),[a,l]=g.useState(""),[d,u]=g.useState(0),{search:h,loading:f}=v4({projects:e}),p=h(a),m=Vg.flatMap(k=>p[k]??[]);g.useEffect(()=>{t&&(l(""),u(0),setTimeout(()=>i.current?.focus(),0))},[t]),g.useEffect(()=>{o.current?.querySelector(`[data-idx="${d}"]`)?.scrollIntoView({block:"nearest"})},[d]);const x=g.useCallback(k=>{s(k.route),n()},[s,n]),b=g.useCallback(k=>{if(k.key==="Escape"){n();return}if(k.key==="ArrowDown"){k.preventDefault(),u(C=>Math.min(C+1,m.length-1));return}if(k.key==="ArrowUp"){k.preventDefault(),u(C=>Math.max(C-1,0));return}if(k.key==="Enter"){k.preventDefault();const C=m[d];C&&x(C)}},[m,d,n,x]),y=k=>{l(k.target.value),u(0)};if(!t)return null;let w=0;const v=k=>{switch(k){case"navigation":return r("paletteNavigation");case"project":return r("paletteProjects");case"agent":return r("paletteAgents");case"command":return r("paletteCommands");case"skill":return r("paletteSkills")}};return c.jsx("div",{className:"fixed inset-0 z-50 flex items-start justify-center pt-[12vh]",style:{background:"rgba(0,0,0,0.5)",backdropFilter:"blur(4px)"},"aria-label":"Search",onClick:n,onKeyDown:k=>k.key==="Escape"&&n(),children:c.jsxs("div",{className:"w-full max-w-[600px] mx-4 bg-dash-surface border border-dash-border rounded-xl shadow-2xl overflow-hidden",onClick:k=>k.stopPropagation(),onKeyDown:k=>k.stopPropagation(),children:[c.jsxs("div",{className:"flex items-center gap-3 px-4 py-3 border-b border-dash-border",children:[c.jsx("svg",{className:"w-4 h-4 text-dash-text-muted shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:c.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})}),c.jsx("input",{ref:i,type:"text",className:"flex-1 bg-transparent text-dash-text placeholder:text-dash-text-muted text-base outline-none",placeholder:r("palettePlaceholder"),value:a,onChange:y,onKeyDown:b,autoComplete:"off",spellCheck:!1}),c.jsx("kbd",{className:"hidden sm:block text-[10px] text-dash-text-muted bg-dash-surface border border-dash-border rounded px-1.5 py-0.5",children:"esc"})]}),c.jsxs("div",{ref:o,className:"max-h-[420px] overflow-y-auto py-2",children:[f&&c.jsx("div",{className:"px-4 py-6 text-center text-dash-text-muted text-sm",children:r("loading")}),!f&&m.length===0&&c.jsx("div",{className:"px-4 py-6 text-center text-dash-text-muted text-sm",children:r("paletteNoResults")}),!f&&Vg.map(k=>{const C=p[k];if(!C||C.length===0)return null;const N=v(k);return c.jsxs("div",{children:[c.jsx("div",{className:"px-4 py-1.5 text-[10px] font-semibold uppercase tracking-widest text-dash-text-muted",children:N}),C.map(D=>{const S=w++,E=S===d;return c.jsxs("button",{type:"button","data-idx":S,className:`w-full flex items-center gap-3 px-4 py-2.5 text-left cursor-pointer transition-colors ${E?"bg-dash-accent/10 text-dash-text":"text-dash-text hover:bg-dash-surface"}`,onClick:()=>x(D),onMouseEnter:()=>u(S),children:[c.jsx("span",{className:`shrink-0 text-[10px] font-medium px-1.5 py-0.5 rounded ${w4[k]}`,children:N}),c.jsxs("div",{className:"flex-1 min-w-0",children:[c.jsx("div",{className:"text-sm font-medium truncate",children:c.jsx(Wg,{text:D.name,query:a})}),D.description&&c.jsx("div",{className:"text-xs text-dash-text-muted truncate mt-0.5",children:c.jsx(Wg,{text:D.description,query:a})})]}),E&&c.jsx("kbd",{className:"shrink-0 text-[10px] text-dash-text-muted bg-dash-surface border border-dash-border rounded px-1.5 py-0.5",children:"↵"})]},`${k}-${D.route}`)})]},k)})]}),m.length>0&&c.jsxs("div",{className:"px-4 py-2 border-t border-dash-border flex gap-4 text-[10px] text-dash-text-muted",children:[c.jsx("span",{children:"↑↓ navigate"}),c.jsx("span",{children:"↵ select"}),c.jsx("span",{children:"esc close"})]})]})})},wt="/api";class Bu extends Error{constructor(){super("Backend server is not running. Start it with: nk config"),this.name="ServerUnavailableError"}}async function Vt(){try{if(!(await fetch(`${wt}/health`,{method:"GET"})).ok)throw new Bu}catch(t){throw t instanceof Bu?t:new Bu}}function Yd(t){return{id:t.id,name:t.name,path:t.path,health:t.health,kitType:t.kitType||"engineer",model:t.model,activeHooks:t.activeHooks,mcpServers:t.mcpServers,skills:t.skills,pinned:t.pinned,tags:t.tags,addedAt:t.addedAt,lastOpened:t.lastOpened,planSettings:t.planSettings,activePlans:t.activePlans,preferences:t.preferences}}async function l1(){await Vt();const t=await fetch(`${wt}/projects`);if(!t.ok)throw new Error("Failed to fetch projects");return(await t.json()).map(Yd)}const Qc=new Map,S4=5e3;async function C4(t){const e=Qc.get(t);if(e&&Date.now()-e.timestamp<S4)return e.data;await Vt();const n=await fetch(`${wt}/projects/${encodeURIComponent(t)}`);if(!n.ok)throw new Error("Failed to fetch project");const r=await n.json(),s=Yd(r);return Qc.set(t,{data:s,timestamp:Date.now()}),s}function c1(t){t?Qc.delete(t):Qc.clear()}async function j4(t,e){try{await Vt();const n=e!==void 0?`?limit=${e}`:"",r=await fetch(`${wt}/sessions/${encodeURIComponent(t)}${n}`);return r.ok?r.json():[]}catch{return[]}}async function N4(t,e,n,r){await Vt();const s=new URLSearchParams;n!==void 0&&s.set("limit",String(n)),r!==void 0&&s.set("offset",String(r));const i=await fetch(`${wt}/sessions/${encodeURIComponent(t)}/${encodeURIComponent(e)}?${s.toString()}`);if(!i.ok)throw new Error("Failed to fetch session detail");return i.json()}async function P4(t,e){await Vt();const n=new URLSearchParams;t&&n.set("projectId",t);const r=await fetch(`${wt}/actions/options?${n.toString()}`,{signal:e});if(!r.ok)throw new Error("Failed to fetch action options");return r.json()}async function D4(t,e,n,r){await Vt();const s=await fetch(`${wt}/actions/open`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:t,path:e,appId:n,projectId:r})});if(!s.ok){const i=await s.json().catch(()=>({error:"Action failed"}));throw new Error(i.error||"Action failed")}}async function E4(){await Vt();try{const r=await fetch(`${wt}/settings/raw`);if(r.ok)return r.json()}catch{}const t=await fetch(`${wt}/settings`);if(!t.ok)throw new Error("Failed to fetch settings file");const e=await t.json(),n=e.settings&&typeof e.settings=="object"?e.settings:{model:e.model,permissions:e.permissions,hookCount:e.hookCount,mcpServerCount:e.mcpServerCount};return{path:e.settingsPath??"~/.claude/settings.json",exists:e.settingsExists??!0,settings:n}}async function O4(t){await Vt();const e=await fetch(`${wt}/settings/raw`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({settings:t})});if(!e.ok){const n=await e.json().catch(()=>({error:"Failed to save settings file"}));throw new Error(n.error||"Failed to save settings file")}return e.json()}async function M4(t){await Vt();const e=await fetch(`${wt}/projects`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!e.ok){const r=await e.text();throw new Error(r||"Failed to add project")}const n=await e.json();return Yd(n)}async function A4(t){await Vt();const e=await fetch(`${wt}/projects/${encodeURIComponent(t)}`,{method:"DELETE"});if(!e.ok){const n=await e.text();throw new Error(n||"Failed to remove project")}c1(t)}async function d1(t,e){await Vt();const n=await fetch(`${wt}/projects/${encodeURIComponent(t)}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!n.ok){const s=await n.text();throw new Error(s||"Failed to update project")}c1(t);const r=await n.json();return Yd(r)}async function T4(){const t=await fetch(`${wt}/metadata/global`);return t.ok?t.json():(console.error("Failed to fetch global metadata"),{})}async function R4(){await Vt();const t=await fetch(`${wt}/dashboard/stats`);if(!t.ok)throw new Error("Failed to fetch dashboard stats");return t.json()}async function L4(){await Vt();const t=await fetch(`${wt}/system/info`);if(!t.ok)throw new Error("Failed to fetch system info");return t.json()}async function I4(){await Vt();const t=await fetch(`${wt}/migrate/providers`);if(!t.ok)throw new Error("Failed to fetch migration providers");return t.json()}async function _u(){await Vt();const t=await fetch(`${wt}/migrate/discovery`);if(!t.ok)throw new Error("Failed to discover migration items");return t.json()}function $4(){const[t,e]=g.useState(null),[n,r]=g.useState(!0),[s,i]=g.useState(null);return g.useEffect(()=>{let o=!1;async function a(){r(!0),i(null);try{const l=await R4();if(o)return;e({agents:l.agents??0,commands:l.commands??0,skills:l.skills??0,mcpServers:l.mcpServers??0})}catch(l){if(o)return;i(l instanceof Error?l.message:"Failed to load counts")}finally{o||r(!1)}}return a(),()=>{o=!0}},[]),{counts:t,loading:n,error:s}}var Yr=(t=>(t.HEALTHY="healthy",t.WARNING="warning",t.ERROR="error",t.LOADING="loading",t.UNKNOWN="unknown",t))(Yr||{}),ur=(t=>(t.ENGINEER="engineer",t.MARKETING="marketing",t.ARCHITECT="architect",t.RESEARCHER="researcher",t.DEVOP="devops",t))(ur||{});const B4=({isOpen:t,onClose:e,onAdd:n})=>{const{t:r}=te(),[s,i]=g.useState(""),[o,a]=g.useState(""),[l,d]=g.useState(!1),[u,h]=g.useState(null);g.useEffect(()=>{t||(i(""),a(""),h(null),d(!1))},[t]),g.useEffect(()=>{if(!t)return;const p=m=>{m.key==="Escape"&&e()};return document.addEventListener("keydown",p),()=>document.removeEventListener("keydown",p)},[t]),g.useEffect(()=>{if(!t)return;const p=document.activeElement;return document.querySelector("#project-path")?.focus(),()=>{p?.focus()}},[t]);const f=async p=>{if(p.preventDefault(),!s.trim()){h(r("pathRequired"));return}try{d(!0),h(null);const m={path:s.trim(),...o.trim()&&{alias:o.trim()}};await n(m),e()}catch(m){h(m instanceof Error?m.message:r("failedToAdd"))}finally{d(!1)}};return t?c.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",onClick:e,children:c.jsxs("div",{className:"bg-dash-surface border border-dash-border rounded-lg shadow-xl max-w-md w-full mx-4",onClick:p=>p.stopPropagation(),children:[c.jsxs("div",{className:"px-6 py-4 border-b border-dash-border",children:[c.jsx("h2",{className:"text-lg font-bold text-dash-text",children:r("addProjectTitle")}),c.jsx("p",{className:"text-sm text-dash-text-muted mt-1",children:r("addProjectDescription")})]}),c.jsxs("form",{onSubmit:f,className:"p-6 space-y-4",children:[c.jsxs("div",{children:[c.jsxs("label",{htmlFor:"project-path",className:"block text-sm font-medium text-dash-text mb-2",children:[r("projectPath")," ",c.jsx("span",{className:"text-red-500",children:"*"})]}),c.jsx("input",{id:"project-path",type:"text",value:s,onChange:p=>i(p.target.value),placeholder:r("pathPlaceholder"),disabled:l,className:"w-full px-3 py-2 bg-dash-bg border border-dash-border rounded-md text-dash-text placeholder-dash-text-muted focus:outline-none focus:ring-2 focus:ring-dash-accent focus:border-transparent disabled:opacity-50 disabled:cursor-not-allowed"})]}),c.jsxs("div",{children:[c.jsxs("label",{htmlFor:"project-alias",className:"block text-sm font-medium text-dash-text mb-2",children:[r("alias")," ",r("aliasOptional")]}),c.jsx("input",{id:"project-alias",type:"text",value:o,onChange:p=>a(p.target.value),placeholder:r("aliasPlaceholder"),disabled:l,className:"w-full px-3 py-2 bg-dash-bg border border-dash-border rounded-md text-dash-text placeholder-dash-text-muted focus:outline-none focus:ring-2 focus:ring-dash-accent focus:border-transparent disabled:opacity-50 disabled:cursor-not-allowed"}),c.jsx("p",{className:"text-xs text-dash-text-muted mt-1",children:r("aliasDescription")})]}),u&&c.jsx("div",{className:"px-3 py-2 bg-red-500/10 border border-red-500/20 rounded-md",children:c.jsx("p",{className:"text-sm text-red-500",children:u})}),c.jsxs("div",{className:"flex gap-3 pt-2",children:[c.jsx("button",{type:"button",onClick:e,disabled:l,className:"flex-1 px-4 py-2 border border-dash-border rounded-md text-dash-text-secondary hover:bg-dash-surface-hover transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:r("cancel")}),c.jsx("button",{type:"submit",disabled:l||!s.trim(),className:"flex-1 px-4 py-2 bg-dash-accent text-white rounded-md hover:bg-dash-accent/90 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:r(l?"adding":"addProject")})]})]})]})}):null},_4=({vertical:t=!1})=>{const{lang:e,setLang:n}=te();return c.jsxs("div",{className:`flex ${t?"flex-col":""} items-center rounded-lg border border-dash-border overflow-hidden`,children:[c.jsx("button",{onClick:()=>n("en"),className:`px-2 py-1 text-xs font-medium transition-colors ${e==="en"?"bg-dash-accent text-dash-bg":"text-dash-text-muted hover:bg-dash-surface-hover"}`,title:"English",children:"EN"}),c.jsx("button",{onClick:()=>n("vi"),className:`px-2 py-1 text-xs font-medium transition-colors ${e==="vi"?"bg-dash-accent text-dash-bg":"text-dash-text-muted hover:bg-dash-surface-hover"}`,title:"Tiếng Việt",children:"VI"})]})},F4=({projects:t,currentProjectId:e,isCollapsed:n,width:r,isConnected:s,theme:i,onSwitchProject:o,onToggle:a,onAddProject:l,onToggleTheme:d})=>{const{t:u}=te(),h=Lt(),f=gn(),[p,m]=g.useState(!1),{counts:x}=$4(),b=f.pathname==="/"||f.pathname==="/dashboard",y=b,w=f.pathname==="/config/global",v=f.pathname==="/migrate",k=f.pathname==="/statusline",C=f.pathname==="/mcp",N=f.pathname.startsWith("/plans"),D=f.pathname==="/agents",S=f.pathname==="/commands",E=f.pathname==="/skills",O=f.pathname==="/workflows",P=[...t].filter(M=>!M.path.endsWith("/.claude")&&M.path!=="~/.claude").sort((M,T)=>M.pinned&&!T.pinned?-1:!M.pinned&&T.pinned?1:M.name.localeCompare(T.name)),A=r?{width:`${r}px`}:void 0,I=r?"":n?"w-14":"w-72",j=r?r>=160:!n;return c.jsxs("aside",{style:A,className:`${I} bg-dash-surface border-r border-dash-border flex flex-col transition-all duration-300 ease-in-out z-20 h-full overflow-hidden`,children:[c.jsxs("div",{className:`flex items-center ${j?"p-6 gap-3":"p-2 justify-center"}`,children:[c.jsx("img",{src:"/images/logo-transparent-32.png",alt:"NineKit",className:"w-8 h-8 shrink-0"}),j&&c.jsxs("div",{className:"overflow-hidden",children:[c.jsx("h1",{className:"text-sm font-bold truncate tracking-tight text-dash-text",children:"NineKit"}),c.jsx("p",{className:"text-[10px] text-dash-text-muted font-medium uppercase tracking-wider",children:u("controlCenter")})]})]}),c.jsxs("div",{className:`${j?"px-4":"px-2"} py-2 space-y-1`,children:[j&&c.jsx("p",{className:"px-2 pb-2 text-[10px] font-bold text-dash-text-muted uppercase tracking-widest",children:u("overviewSection")}),c.jsx(sr,{icon:c.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:c.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5H7a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 104 0M9 5a2 2 0 014 0m-6 4h10M9 12h6m-6 4h4"})}),label:u("plansNav"),isCollapsed:!j,active:N,onClick:()=>h("/plans")}),c.jsx(sr,{icon:c.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:c.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3 12l2-2m0 0l7-7 7 7M5 10v10a1 1 0 001 1h3m10-11l2 2m-2-2v10a1 1 0 01-1 1h-3m-6 0a1 1 0 001-1v-4a1 1 0 011-1h2a1 1 0 011 1v4a1 1 0 001 1m-6 0h6"})}),label:u("systemNavLabel"),isCollapsed:!j,active:b,onClick:()=>h("/")})]}),c.jsxs("div",{className:`${j?"px-4":"px-2"} py-2 space-y-1 border-t border-dash-border`,children:[j&&c.jsx("p",{className:"px-2 pb-2 pt-2 text-[10px] font-bold text-dash-text-muted uppercase tracking-widest",children:u("entitiesSection")}),c.jsx(sr,{icon:c.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:c.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 10V3L4 14h7v7l9-11h-7z"})}),label:u("workflowsTitle"),isCollapsed:!j,active:O,onClick:()=>h("/workflows")}),c.jsx(sr,{icon:c.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:c.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M17 20h5v-2a3 3 0 00-5.356-1.857M17 20H7m10 0v-2c0-.656-.126-1.283-.356-1.857M7 20H2v-2a3 3 0 015.356-1.857M7 20v-2c0-.656.126-1.283.356-1.857m0 0a5.002 5.002 0 019.288 0M15 7a3 3 0 11-6 0 3 3 0 016 0z"})}),label:u("agentsBrowser"),isCollapsed:!j,active:D,onClick:()=>h("/agents"),badge:j&&x?String(x.agents):void 0}),c.jsx(sr,{icon:c.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:c.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 9l3 3-3 3m5 0h3M5 20h14a2 2 0 002-2V6a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z"})}),label:u("commandsBrowser"),isCollapsed:!j,active:S,onClick:()=>h("/commands"),badge:j&&x?String(x.commands):void 0}),c.jsx(sr,{icon:c.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:c.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9.663 17h4.673M12 3v1m6.364 1.636l-.707.707M21 12h-1M4 12H3m3.343-5.657l-.707-.707m2.828 9.9a5 5 0 117.072 0l-.548.547A3.374 3.374 0 0014 18.469V19a2 2 0 11-4 0v-.531c0-.895-.356-1.754-.988-2.386l-.548-.547z"})}),label:u("skillsNav"),isCollapsed:!j,active:E,onClick:()=>h("/skills"),badge:j&&x?String(x.skills):void 0}),c.jsx(sr,{icon:c.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:c.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 12h14M12 5l7 7-7 7"})}),label:u("mcpTitle"),isCollapsed:!j,active:C,onClick:()=>h("/mcp"),badge:j&&x?String(x.mcpServers):void 0})]}),c.jsxs("div",{className:`${j?"px-4":"px-2"} py-2 space-y-1 border-t border-dash-border`,children:[j&&c.jsx("p",{className:"px-2 pb-2 pt-2 text-[10px] font-bold text-dash-text-muted uppercase tracking-widest",children:u("toolsSection")}),c.jsx(sr,{icon:c.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:[c.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z"}),c.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"})]}),label:u("configEditor"),isCollapsed:!j,active:w,onClick:()=>h("/config/global")}),c.jsx(sr,{icon:c.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:c.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 17V7m0 10a2 2 0 01-2 2H5a2 2 0 01-2-2V7a2 2 0 012-2h2a2 2 0 012 2m0 10a2 2 0 002 2h2a2 2 0 002-2M9 7a2 2 0 012-2h2a2 2 0 012 2m0 10V7m0 10a2 2 0 002 2h2a2 2 0 002-2V7a2 2 0 00-2-2h-2a2 2 0 00-2 2"})}),label:u("statusline"),isCollapsed:!j,active:k,onClick:()=>h("/statusline")}),c.jsx(sr,{icon:c.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:c.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M11 4a2 2 0 114 0v1a1 1 0 001 1h3a1 1 0 011 1v3a1 1 0 01-1 1h-1a2 2 0 100 4h1a1 1 0 011 1v3a1 1 0 01-1 1h-3a1 1 0 01-1-1v-1a2 2 0 10-4 0v1a1 1 0 01-1 1H7a1 1 0 01-1-1v-3a1 1 0 00-1-1H4a2 2 0 110-4h1a1 1 0 001-1V7a1 1 0 011-1h3a1 1 0 001-1V4z"})}),label:u("migrate"),isCollapsed:!j,active:v,onClick:()=>h("/migrate")})]}),c.jsxs("div",{className:`flex-1 overflow-y-auto overflow-x-hidden ${j?"px-4":"px-2"} py-2 space-y-1 border-t border-dash-border`,children:[j&&c.jsx("p",{className:"px-2 pb-2 pt-2 text-[10px] font-bold text-dash-text-muted uppercase tracking-widest",children:u("projects")}),P.map(M=>{const T=f.pathname.endsWith("/config"),L=e===M.id&&!w&&!T&&!v&&!k&&!C&&!N&&!D&&!S&&!E&&!O&&!y;return c.jsxs("button",{onClick:()=>o(M.id),className:`w-full group relative flex items-center ${j?"gap-2.5 px-2 py-1.5":"justify-center p-2"} rounded-md transition-colors ${L?"bg-dash-accent-subtle text-dash-accent border border-dash-accent/10":"text-dash-text-secondary hover:bg-dash-surface-hover hover:text-dash-text border border-transparent"}`,children:[c.jsx("div",{className:`w-2 h-2 rounded-full shrink-0 ${M.health===Yr.HEALTHY?"bg-dash-accent":M.health===Yr.WARNING?"bg-orange-400":"bg-red-500"} ${L?"animate-pulse":""}`}),j&&c.jsxs(c.Fragment,{children:[M.pinned&&c.jsx("span",{className:"text-xs",children:"📌"}),c.jsx("span",{className:"text-sm font-medium truncate",children:M.name})]}),!j&&c.jsxs("div",{className:"absolute left-14 px-2 py-1 bg-dash-text text-dash-bg text-xs rounded opacity-0 group-hover:opacity-100 transition-opacity whitespace-nowrap pointer-events-none border border-dash-border z-50",children:[M.pinned&&"📌 ",M.name]})]},M.id)}),c.jsxs("button",{onClick:()=>m(!0),className:`w-full flex items-center ${j?"gap-3 p-2.5":"justify-center p-2"} rounded-md text-dash-text-muted hover:bg-dash-surface-hover hover:text-dash-text-secondary transition-colors mt-4`,children:[c.jsx("div",{className:`${j?"w-5 h-5":""} flex items-center justify-center`,children:c.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:c.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})})}),j&&c.jsx("span",{className:"text-sm font-medium",children:u("addProject")})]})]}),c.jsx(B4,{isOpen:p,onClose:()=>m(!1),onAdd:l}),c.jsx("div",{className:"border-t border-dash-border",children:c.jsxs("div",{className:`py-3 flex items-center ${j?"px-3 justify-between":"justify-center flex-col gap-2"}`,children:[c.jsxs("div",{className:"flex items-center gap-2",title:u(s?"sync":"offline"),children:[c.jsx("div",{className:`w-2 h-2 rounded-full shrink-0 ${s?"bg-dash-accent shadow-[0_0_8px_var(--dash-accent-glow)]":"bg-red-500"}`}),j&&c.jsx("span",{className:"text-[10px] font-bold text-dash-text-muted uppercase tracking-widest",children:u(s?"sync":"offline")})]}),c.jsxs("div",{className:`flex items-center gap-1 ${j?"":"flex-col"}`,children:[c.jsx(_4,{vertical:!j}),c.jsx("button",{onClick:d,className:"w-8 h-8 rounded-lg flex items-center justify-center text-dash-text-muted hover:bg-dash-surface-hover hover:text-dash-text transition-colors",title:u(i==="dark"?"switchToLight":"switchToDark"),children:i==="dark"?c.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:c.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 3v1m0 16v1m9-9h-1M4 12H3m15.364-6.364l-.707.707M6.343 17.657l-.707.707M17.657 17.657l-.707-.707M6.343 6.343l-.707-.707M12 5a7 7 0 100 14 7 7 0 000-14z"})}):c.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:c.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M20.354 15.354A9 9 0 018.646 3.646 9.003 9.003 0 0012 21a9.003 9.003 0 008.354-5.646z"})})}),c.jsx("button",{onClick:a,className:"w-8 h-8 rounded-lg flex items-center justify-center text-dash-text-muted hover:bg-dash-surface-hover hover:text-dash-text transition-colors",title:u(n?"expand":"collapse"),children:n?c.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:c.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 5l7 7-7 7M5 5l7 7-7 7"})}):c.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:c.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M11 19l-7-7 7-7m8 14l-7-7 7-7"})})})]})]})})]})},sr=({icon:t,label:e,badge:n,isCollapsed:r,active:s,onClick:i,disabled:o})=>c.jsxs("button",{onClick:i,disabled:o,className:`w-full group relative flex items-center ${r?"justify-center p-2":"gap-3 p-2"} rounded-md transition-colors ${o?"opacity-50 cursor-not-allowed":s?"bg-dash-surface-hover text-dash-text":"text-dash-text-secondary hover:bg-dash-surface-hover hover:text-dash-text"}`,children:[c.jsx("div",{className:`${r?"":"w-5 h-5"} flex items-center justify-center`,children:t}),!r&&c.jsxs(c.Fragment,{children:[c.jsx("span",{className:"text-sm font-medium flex-1 text-left",children:e}),n&&c.jsx("span",{className:"ml-auto text-[10px] font-mono text-dash-text-disabled bg-dash-surface px-1.5 py-0.5 rounded",children:n})]}),r&&c.jsx("div",{className:"absolute left-14 px-2 py-1 bg-dash-text text-dash-bg text-xs rounded opacity-0 group-hover:opacity-100 transition-opacity whitespace-nowrap pointer-events-none border border-dash-border z-50",children:e})]});function z4(t){const[e,n]=g.useState([]),[r,s]=g.useState(!1),[i,o]=g.useState(null),a=g.useCallback(async()=>{if(!t){n([]);return}try{s(!0),o(null);const l=await j4(t,999);n(l)}catch(l){o(l instanceof Error?l.message:"Failed to load sessions")}finally{s(!1)}},[t]);return g.useEffect(()=>{a()},[a]),{sessions:e,loading:r,error:i,reload:a}}function H4(){const[t,e]=g.useState([]),[n,r]=g.useState(!0),[s,i]=g.useState(null),o=g.useCallback(async()=>{try{r(!0),i(null);const u=await l1();e(u)}catch(u){i(u instanceof Error?u.message:"Failed to load projects")}finally{r(!1)}},[]),a=g.useCallback(async u=>{const h=await M4(u);return await o(),h},[o]),l=g.useCallback(async u=>{await A4(u),await o()},[o]),d=g.useCallback(async(u,h)=>{const f=await d1(u,h);return await o(),f},[o]);return g.useEffect(()=>{o()},[o]),{projects:t,loading:n,error:s,reload:o,addProject:a,removeProject:l,updateProject:d}}function V4(t,e,n=50,r=0){const[s,i]=g.useState(null),[o,a]=g.useState(!1),[l,d]=g.useState(null),u=g.useCallback(async()=>{if(!t||!e){i(null);return}try{a(!0),d(null);const h=await N4(t,e,n,r);i(h)}catch(h){d(h instanceof Error?h.message:"Failed to load")}finally{a(!1)}},[t,e,n,r]);return g.useEffect(()=>{u()},[u]),{data:s,loading:o,error:l,reload:u}}function Xi({storageKey:t,defaultSize:e,minSize:n,maxSize:r,direction:s="horizontal",invert:i=!1}){const[o,a]=g.useState(()=>{if(typeof window>"u")return e;const p=localStorage.getItem(t);if(p){const m=Number.parseInt(p,10);if(!Number.isNaN(m)&&m>=n&&m<=r)return m}return e}),[l,d]=g.useState(!1);g.useEffect(()=>{localStorage.setItem(t,String(o))},[o,t]);const u=g.useCallback(p=>{p.preventDefault(),d(!0);const m=s==="horizontal"?p.clientX:p.clientY,x=o,b=w=>{const k=((s==="horizontal"?w.clientX:w.clientY)-m)*(i?-1:1),C=Math.max(n,Math.min(r,x+k));a(C)},y=()=>{d(!1),document.removeEventListener("mousemove",b),document.removeEventListener("mouseup",y),document.body.style.cursor="",document.body.style.userSelect=""};document.addEventListener("mousemove",b),document.addEventListener("mouseup",y),document.body.style.cursor=s==="horizontal"?"col-resize":"row-resize",document.body.style.userSelect="none"},[o,n,r,s,i]),h=g.useCallback(()=>{a(e)},[e]),f=g.useCallback(p=>{a(Math.max(n,Math.min(r,p)))},[n,r]);return{size:o,isDragging:l,startDrag:u,setSize:f,reset:h}}const W4=()=>{const{t}=te(),e=Lt(),n=gn(),{projectId:r}=pl(),[s,i]=g.useState(null);g.useEffect(()=>{r&&i(r)},[r]);const[o,a]=g.useState(()=>typeof window<"u"&&localStorage.getItem("ninekit-theme")||"dark"),[l]=g.useState(!0),[d,u]=g.useState(!1);g.useEffect(()=>{const P=A=>{(A.metaKey||A.ctrlKey)&&A.key==="k"&&(A.preventDefault(),u(I=>!I))};return window.addEventListener("keydown",P),()=>window.removeEventListener("keydown",P)},[]);const{size:h,isDragging:f,startDrag:p,setSize:m}=Xi({storageKey:"ninekit-sidebar-width",defaultSize:288,minSize:56,maxSize:400}),x=h<=56,{projects:b,loading:y,error:w,addProject:v,reload:k}=H4(),C=async P=>{await v(P)};g.useEffect(()=>{const P=n.pathname.startsWith("/project/");b.length===0||r||!P||e(`/project/${b[0].id}`,{replace:!0})},[b,r,e,n.pathname]),g.useEffect(()=>{const P=window.document.documentElement;o==="dark"?(P.classList.add("dark"),P.setAttribute("data-theme","dark")):(P.classList.remove("dark"),P.setAttribute("data-theme","light")),localStorage.setItem("ninekit-theme",o)},[o]);const N=()=>a(P=>P==="light"?"dark":"light"),D=g.useMemo(()=>b.find(P=>P.id===s)||null,[b,s]),S=P=>{e(`/project/${P}`)},E=()=>{m(x?288:56)};if(y)return c.jsx("div",{className:"flex h-screen w-full bg-dash-bg text-dash-text items-center justify-center",children:c.jsx("div",{className:"animate-pulse text-dash-text-muted",children:t("loading")})});if(w)return c.jsx("div",{className:"flex h-screen w-full bg-dash-bg text-dash-text items-center justify-center",children:c.jsxs("div",{className:"text-red-500",children:[t("error"),": ",w]})});const O={project:D,isConnected:l,theme:o,onToggleTheme:N,reloadProjects:k};return c.jsxs("div",{className:"flex h-screen w-full bg-dash-bg text-dash-text overflow-hidden font-sans transition-colors duration-300",children:[c.jsx(k4,{open:d,projects:b,onClose:()=>u(!1)}),c.jsx(F4,{projects:b,currentProjectId:s,isCollapsed:x,width:h,isConnected:l,theme:o,onSwitchProject:S,onToggle:E,onAddProject:C,onToggleTheme:N}),c.jsx(Mn,{direction:"horizontal",isDragging:f,onMouseDown:p}),c.jsx("div",{className:"flex-1 flex flex-col min-w-0 h-full relative",children:c.jsx("main",{className:"flex-1 flex flex-col overflow-hidden p-4 md:p-6",children:c.jsx(E3,{context:O})})})]})};function Tc(t){return t.toLowerCase().trim().replace(/[`*_~]/g,"").replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")}function K4(t){return t.split(`
|
|
30
|
+
`})})},b4=[{type:"navigation",name:"Dashboard",description:"Project overview",route:"/"},{type:"navigation",name:"Config Editor",description:"Edit Claude configuration",route:"/config/global"},{type:"navigation",name:"Skills",description:"Browse and manage skills",route:"/skills"},{type:"navigation",name:"Migrate",description:"Migrate stack to other providers",route:"/migrate"},{type:"navigation",name:"Status Line",description:"Customize Claude Code statusline",route:"/statusline"},{type:"navigation",name:"Plans",description:"Visual dashboard for plans and phases",route:"/plans"},{type:"navigation",name:"System",description:"System updates and environment info",route:"/system"}];function y4(t,e){if(!e.trim())return!0;const n=`${t.name} ${t.description}`.toLowerCase();return e.toLowerCase().trim().split(/\s+/).every(r=>n.includes(r))}function a1(t){const e=[];for(const n of t)n.children?e.push(...a1(n.children)):e.push({type:"command",name:n.name,description:n.description??"",route:`/commands?selected=${encodeURIComponent(n.path)}`});return e}function v4({projects:t}){const[e,n]=g.useState([]),[r,s]=g.useState(!0);g.useEffect(()=>{let l=!1;async function d(){const u=[],[h,f,p]=await Promise.allSettled([fetch("/api/agents/browser"),fetch("/api/commands"),fetch("/api/skills/browse")]);if(h.status==="fulfilled"&&h.value.ok)try{const m=await h.value.json();for(const x of m.agents??[])u.push({type:"agent",name:x.name||x.slug,description:x.description??"",route:`/agents?selected=${encodeURIComponent(x.slug)}`})}catch{}if(f.status==="fulfilled"&&f.value.ok)try{const m=await f.value.json();u.push(...a1(m.tree??[]))}catch{}if(p.status==="fulfilled"&&p.value.ok)try{const m=await p.value.json();for(const x of m.skills??[])u.push({type:"skill",name:x.name,description:x.description??"",route:`/skills?selected=${encodeURIComponent(x.name)}`})}catch{}l||(n(u),s(!1))}return d(),()=>{l=!0}},[]);const i=g.useMemo(()=>t.filter(l=>!l.path.endsWith("/.claude")&&l.path!=="~/.claude").map(l=>({type:"project",name:l.name||l.path.split("/").pop()||l.path,description:l.path,route:`/project/${l.id}`})),[t]),o=g.useMemo(()=>[...b4,...i,...e],[i,e]);return{search:g.useMemo(()=>l=>{const u=l.trim()?o.filter(f=>y4(f,l)):o,h={project:[],navigation:[],agent:[],command:[],skill:[]};for(const f of u){const p=h[f.type];p.length<5&&p.push(f)}return h},[o]),loading:r}}const Vg=["navigation","project","agent","command","skill"],w4={navigation:"bg-dash-accent/20 text-dash-accent",project:"bg-dash-text-muted/20 text-dash-text-muted",agent:"bg-[#e85d4a]/20 text-[#e85d4a]",command:"bg-blue-500/20 text-blue-400",skill:"bg-green-500/20 text-green-400"};function Wg({text:t,query:e}){if(!e.trim())return c.jsx("span",{children:t});const n=e.trim().toLowerCase().split(/\s+/).filter(Boolean).sort((i,o)=>o.length-i.length),r=[];let s=t;for(;s.length>0;){let i=-1,o=0,a="";for(const l of n){const d=s.toLowerCase().indexOf(l);d!==-1&&(i===-1||d<i||d===i&&l.length>o)&&(i=d,o=l.length,a=l)}if(i===-1||!a){r.push({text:s,match:!1});break}i>0&&r.push({text:s.slice(0,i),match:!1}),r.push({text:s.slice(i,i+o),match:!0}),s=s.slice(i+o)}return c.jsx("span",{children:r.map((i,o)=>i.match?c.jsx("mark",{className:"bg-dash-accent/30 text-dash-text rounded-sm px-0.5",children:i.text},`m${o}`):c.jsx("span",{children:i.text},`s${o}`))})}const k4=({open:t,projects:e,onClose:n})=>{const{t:r}=te(),s=Lt(),i=g.useRef(null),o=g.useRef(null),[a,l]=g.useState(""),[d,u]=g.useState(0),{search:h,loading:f}=v4({projects:e}),p=h(a),m=Vg.flatMap(k=>p[k]??[]);g.useEffect(()=>{t&&(l(""),u(0),setTimeout(()=>i.current?.focus(),0))},[t]),g.useEffect(()=>{o.current?.querySelector(`[data-idx="${d}"]`)?.scrollIntoView({block:"nearest"})},[d]);const x=g.useCallback(k=>{s(k.route),n()},[s,n]),b=g.useCallback(k=>{if(k.key==="Escape"){n();return}if(k.key==="ArrowDown"){k.preventDefault(),u(C=>Math.min(C+1,m.length-1));return}if(k.key==="ArrowUp"){k.preventDefault(),u(C=>Math.max(C-1,0));return}if(k.key==="Enter"){k.preventDefault();const C=m[d];C&&x(C)}},[m,d,n,x]),y=k=>{l(k.target.value),u(0)};if(!t)return null;let w=0;const v=k=>{switch(k){case"navigation":return r("paletteNavigation");case"project":return r("paletteProjects");case"agent":return r("paletteAgents");case"command":return r("paletteCommands");case"skill":return r("paletteSkills")}};return c.jsx("div",{className:"fixed inset-0 z-50 flex items-start justify-center pt-[12vh]",style:{background:"rgba(0,0,0,0.5)",backdropFilter:"blur(4px)"},"aria-label":"Search",onClick:n,onKeyDown:k=>k.key==="Escape"&&n(),children:c.jsxs("div",{className:"w-full max-w-[600px] mx-4 bg-dash-surface border border-dash-border rounded-xl shadow-2xl overflow-hidden",onClick:k=>k.stopPropagation(),onKeyDown:k=>k.stopPropagation(),children:[c.jsxs("div",{className:"flex items-center gap-3 px-4 py-3 border-b border-dash-border",children:[c.jsx("svg",{className:"w-4 h-4 text-dash-text-muted shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:c.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})}),c.jsx("input",{ref:i,type:"text",className:"flex-1 bg-transparent text-dash-text placeholder:text-dash-text-muted text-base outline-none",placeholder:r("palettePlaceholder"),value:a,onChange:y,onKeyDown:b,autoComplete:"off",spellCheck:!1}),c.jsx("kbd",{className:"hidden sm:block text-[10px] text-dash-text-muted bg-dash-surface border border-dash-border rounded px-1.5 py-0.5",children:"esc"})]}),c.jsxs("div",{ref:o,className:"max-h-[420px] overflow-y-auto py-2",children:[f&&c.jsx("div",{className:"px-4 py-6 text-center text-dash-text-muted text-sm",children:r("loading")}),!f&&m.length===0&&c.jsx("div",{className:"px-4 py-6 text-center text-dash-text-muted text-sm",children:r("paletteNoResults")}),!f&&Vg.map(k=>{const C=p[k];if(!C||C.length===0)return null;const N=v(k);return c.jsxs("div",{children:[c.jsx("div",{className:"px-4 py-1.5 text-[10px] font-semibold uppercase tracking-widest text-dash-text-muted",children:N}),C.map(D=>{const S=w++,E=S===d;return c.jsxs("button",{type:"button","data-idx":S,className:`w-full flex items-center gap-3 px-4 py-2.5 text-left cursor-pointer transition-colors ${E?"bg-dash-accent/10 text-dash-text":"text-dash-text hover:bg-dash-surface"}`,onClick:()=>x(D),onMouseEnter:()=>u(S),children:[c.jsx("span",{className:`shrink-0 text-[10px] font-medium px-1.5 py-0.5 rounded ${w4[k]}`,children:N}),c.jsxs("div",{className:"flex-1 min-w-0",children:[c.jsx("div",{className:"text-sm font-medium truncate",children:c.jsx(Wg,{text:D.name,query:a})}),D.description&&c.jsx("div",{className:"text-xs text-dash-text-muted truncate mt-0.5",children:c.jsx(Wg,{text:D.description,query:a})})]}),E&&c.jsx("kbd",{className:"shrink-0 text-[10px] text-dash-text-muted bg-dash-surface border border-dash-border rounded px-1.5 py-0.5",children:"↵"})]},`${k}-${D.route}`)})]},k)})]}),m.length>0&&c.jsxs("div",{className:"px-4 py-2 border-t border-dash-border flex gap-4 text-[10px] text-dash-text-muted",children:[c.jsx("span",{children:"↑↓ navigate"}),c.jsx("span",{children:"↵ select"}),c.jsx("span",{children:"esc close"})]})]})})},wt="/api";class Bu extends Error{constructor(){super("Backend server is not running. Start it with: nk config"),this.name="ServerUnavailableError"}}async function Vt(){try{if(!(await fetch(`${wt}/health`,{method:"GET"})).ok)throw new Bu}catch(t){throw t instanceof Bu?t:new Bu}}function Yd(t){return{id:t.id,name:t.name,path:t.path,health:t.health,kitType:t.kitType||"engineer",model:t.model,activeHooks:t.activeHooks,mcpServers:t.mcpServers,skills:t.skills,pinned:t.pinned,tags:t.tags,addedAt:t.addedAt,lastOpened:t.lastOpened,planSettings:t.planSettings,activePlans:t.activePlans,preferences:t.preferences}}async function l1(){await Vt();const t=await fetch(`${wt}/projects`);if(!t.ok)throw new Error("Failed to fetch projects");return(await t.json()).map(Yd)}const Qc=new Map,S4=5e3;async function C4(t){const e=Qc.get(t);if(e&&Date.now()-e.timestamp<S4)return e.data;await Vt();const n=await fetch(`${wt}/projects/${encodeURIComponent(t)}`);if(!n.ok)throw new Error("Failed to fetch project");const r=await n.json(),s=Yd(r);return Qc.set(t,{data:s,timestamp:Date.now()}),s}function c1(t){t?Qc.delete(t):Qc.clear()}async function j4(t,e){try{await Vt();const n=e!==void 0?`?limit=${e}`:"",r=await fetch(`${wt}/sessions/${encodeURIComponent(t)}${n}`);return r.ok?r.json():[]}catch{return[]}}async function N4(t,e,n,r){await Vt();const s=new URLSearchParams;n!==void 0&&s.set("limit",String(n)),r!==void 0&&s.set("offset",String(r));const i=await fetch(`${wt}/sessions/${encodeURIComponent(t)}/${encodeURIComponent(e)}?${s.toString()}`);if(!i.ok)throw new Error("Failed to fetch session detail");return i.json()}async function P4(t,e){await Vt();const n=new URLSearchParams;t&&n.set("projectId",t);const r=await fetch(`${wt}/actions/options?${n.toString()}`,{signal:e});if(!r.ok)throw new Error("Failed to fetch action options");return r.json()}async function D4(t,e,n,r){await Vt();const s=await fetch(`${wt}/actions/open`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:t,path:e,appId:n,projectId:r})});if(!s.ok){const i=await s.json().catch(()=>({error:"Action failed"}));throw new Error(i.error||"Action failed")}}async function E4(){await Vt();try{const r=await fetch(`${wt}/settings/raw`);if(r.ok)return r.json()}catch{}const t=await fetch(`${wt}/settings`);if(!t.ok)throw new Error("Failed to fetch settings file");const e=await t.json(),n=e.settings&&typeof e.settings=="object"?e.settings:{model:e.model,permissions:e.permissions,hookCount:e.hookCount,mcpServerCount:e.mcpServerCount};return{path:e.settingsPath??"~/.claude/settings.json",exists:e.settingsExists??!0,settings:n}}async function O4(t){await Vt();const e=await fetch(`${wt}/settings/raw`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({settings:t})});if(!e.ok){const n=await e.json().catch(()=>({error:"Failed to save settings file"}));throw new Error(n.error||"Failed to save settings file")}return e.json()}async function M4(t){await Vt();const e=await fetch(`${wt}/projects`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!e.ok){const r=await e.text();throw new Error(r||"Failed to add project")}const n=await e.json();return Yd(n)}async function A4(t){await Vt();const e=await fetch(`${wt}/projects/${encodeURIComponent(t)}`,{method:"DELETE"});if(!e.ok){const n=await e.text();throw new Error(n||"Failed to remove project")}c1(t)}async function d1(t,e){await Vt();const n=await fetch(`${wt}/projects/${encodeURIComponent(t)}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!n.ok){const s=await n.text();throw new Error(s||"Failed to update project")}c1(t);const r=await n.json();return Yd(r)}async function T4(){const t=await fetch(`${wt}/metadata/global`);return t.ok?t.json():(console.error("Failed to fetch global metadata"),{})}async function R4(){await Vt();const t=await fetch(`${wt}/dashboard/stats`);if(!t.ok)throw new Error("Failed to fetch dashboard stats");return t.json()}async function L4(){await Vt();const t=await fetch(`${wt}/system/info`);if(!t.ok)throw new Error("Failed to fetch system info");return t.json()}async function I4(){await Vt();const t=await fetch(`${wt}/migrate/providers`);if(!t.ok)throw new Error("Failed to fetch migration providers");return t.json()}async function _u(){await Vt();const t=await fetch(`${wt}/migrate/discovery`);if(!t.ok)throw new Error("Failed to discover migration items");return t.json()}function $4(){const[t,e]=g.useState(null),[n,r]=g.useState(!0),[s,i]=g.useState(null);return g.useEffect(()=>{let o=!1;async function a(){r(!0),i(null);try{const l=await R4();if(o)return;e({agents:l.agents??0,commands:l.commands??0,skills:l.skills??0,mcpServers:l.mcpServers??0})}catch(l){if(o)return;i(l instanceof Error?l.message:"Failed to load counts")}finally{o||r(!1)}}return a(),()=>{o=!0}},[]),{counts:t,loading:n,error:s}}var Yr=(t=>(t.HEALTHY="healthy",t.WARNING="warning",t.ERROR="error",t.LOADING="loading",t.UNKNOWN="unknown",t))(Yr||{}),ur=(t=>(t.ENGINEER="engineer",t.MARKETING="marketing",t.ARCHITECT="architect",t.RESEARCHER="researcher",t.DEVOP="devops",t))(ur||{});const B4=({isOpen:t,onClose:e,onAdd:n})=>{const{t:r}=te(),[s,i]=g.useState(""),[o,a]=g.useState(""),[l,d]=g.useState(!1),[u,h]=g.useState(null);g.useEffect(()=>{t||(i(""),a(""),h(null),d(!1))},[t]),g.useEffect(()=>{if(!t)return;const p=m=>{m.key==="Escape"&&e()};return document.addEventListener("keydown",p),()=>document.removeEventListener("keydown",p)},[t]),g.useEffect(()=>{if(!t)return;const p=document.activeElement;return document.querySelector("#project-path")?.focus(),()=>{p?.focus()}},[t]);const f=async p=>{if(p.preventDefault(),!s.trim()){h(r("pathRequired"));return}try{d(!0),h(null);const m={path:s.trim(),...o.trim()&&{alias:o.trim()}};await n(m),e()}catch(m){h(m instanceof Error?m.message:r("failedToAdd"))}finally{d(!1)}};return t?c.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",onClick:e,children:c.jsxs("div",{className:"bg-dash-surface border border-dash-border rounded-lg shadow-xl max-w-md w-full mx-4",onClick:p=>p.stopPropagation(),children:[c.jsxs("div",{className:"px-6 py-4 border-b border-dash-border",children:[c.jsx("h2",{className:"text-lg font-bold text-dash-text",children:r("addProjectTitle")}),c.jsx("p",{className:"text-sm text-dash-text-muted mt-1",children:r("addProjectDescription")})]}),c.jsxs("form",{onSubmit:f,className:"p-6 space-y-4",children:[c.jsxs("div",{children:[c.jsxs("label",{htmlFor:"project-path",className:"block text-sm font-medium text-dash-text mb-2",children:[r("projectPath")," ",c.jsx("span",{className:"text-red-500",children:"*"})]}),c.jsx("input",{id:"project-path",type:"text",value:s,onChange:p=>i(p.target.value),placeholder:r("pathPlaceholder"),disabled:l,className:"w-full px-3 py-2 bg-dash-bg border border-dash-border rounded-md text-dash-text placeholder-dash-text-muted focus:outline-none focus:ring-2 focus:ring-dash-accent focus:border-transparent disabled:opacity-50 disabled:cursor-not-allowed"})]}),c.jsxs("div",{children:[c.jsxs("label",{htmlFor:"project-alias",className:"block text-sm font-medium text-dash-text mb-2",children:[r("alias")," ",r("aliasOptional")]}),c.jsx("input",{id:"project-alias",type:"text",value:o,onChange:p=>a(p.target.value),placeholder:r("aliasPlaceholder"),disabled:l,className:"w-full px-3 py-2 bg-dash-bg border border-dash-border rounded-md text-dash-text placeholder-dash-text-muted focus:outline-none focus:ring-2 focus:ring-dash-accent focus:border-transparent disabled:opacity-50 disabled:cursor-not-allowed"}),c.jsx("p",{className:"text-xs text-dash-text-muted mt-1",children:r("aliasDescription")})]}),u&&c.jsx("div",{className:"px-3 py-2 bg-red-500/10 border border-red-500/20 rounded-md",children:c.jsx("p",{className:"text-sm text-red-500",children:u})}),c.jsxs("div",{className:"flex gap-3 pt-2",children:[c.jsx("button",{type:"button",onClick:e,disabled:l,className:"flex-1 px-4 py-2 border border-dash-border rounded-md text-dash-text-secondary hover:bg-dash-surface-hover transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:r("cancel")}),c.jsx("button",{type:"submit",disabled:l||!s.trim(),className:"flex-1 px-4 py-2 bg-dash-accent text-white rounded-md hover:bg-dash-accent/90 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:r(l?"adding":"addProject")})]})]})]})}):null},_4=({vertical:t=!1})=>{const{lang:e,setLang:n}=te();return c.jsxs("div",{className:`flex ${t?"flex-col":""} items-center rounded-lg border border-dash-border overflow-hidden`,children:[c.jsx("button",{onClick:()=>n("en"),className:`px-2 py-1 text-xs font-medium transition-colors ${e==="en"?"bg-dash-accent text-dash-bg":"text-dash-text-muted hover:bg-dash-surface-hover"}`,title:"English",children:"EN"}),c.jsx("button",{onClick:()=>n("vi"),className:`px-2 py-1 text-xs font-medium transition-colors ${e==="vi"?"bg-dash-accent text-dash-bg":"text-dash-text-muted hover:bg-dash-surface-hover"}`,title:"Tiếng Việt",children:"VI"})]})},F4=({projects:t,currentProjectId:e,isCollapsed:n,width:r,isConnected:s,theme:i,onSwitchProject:o,onToggle:a,onAddProject:l,onToggleTheme:d})=>{const{t:u}=te(),h=Lt(),f=gn(),[p,m]=g.useState(!1),{counts:x}=$4(),b=f.pathname==="/"||f.pathname==="/dashboard",y=b,w=f.pathname==="/config/global",v=f.pathname==="/migrate",k=f.pathname==="/statusline",C=f.pathname==="/mcp",N=f.pathname.startsWith("/plans"),D=f.pathname==="/agents",S=f.pathname==="/commands",E=f.pathname==="/skills",O=f.pathname==="/workflows",P=[...t].filter(M=>!M.path.endsWith("/.claude")&&M.path!=="~/.claude").sort((M,T)=>M.pinned&&!T.pinned?-1:!M.pinned&&T.pinned?1:M.name.localeCompare(T.name)),A=r?{width:`${r}px`}:void 0,I=r?"":n?"w-14":"w-72",j=r?r>=160:!n;return c.jsxs("aside",{style:A,className:`${I} bg-dash-surface border-r border-dash-border flex flex-col transition-all duration-300 ease-in-out z-20 h-full overflow-hidden`,children:[c.jsxs("div",{className:`flex items-center ${j?"p-6 gap-3":"p-2 justify-center"}`,children:[c.jsx("img",{src:"/images/ninekit-logo.png",alt:"NineKit",className:"w-8 h-8 shrink-0"}),j&&c.jsxs("div",{className:"overflow-hidden",children:[c.jsx("h1",{className:"text-sm font-bold truncate tracking-tight text-dash-text",children:"NineKit"}),c.jsx("p",{className:"text-[10px] text-dash-text-muted font-medium uppercase tracking-wider",children:u("controlCenter")})]})]}),c.jsxs("div",{className:`${j?"px-4":"px-2"} py-2 space-y-1`,children:[j&&c.jsx("p",{className:"px-2 pb-2 text-[10px] font-bold text-dash-text-muted uppercase tracking-widest",children:u("overviewSection")}),c.jsx(sr,{icon:c.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:c.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5H7a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 104 0M9 5a2 2 0 014 0m-6 4h10M9 12h6m-6 4h4"})}),label:u("plansNav"),isCollapsed:!j,active:N,onClick:()=>h("/plans")}),c.jsx(sr,{icon:c.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:c.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3 12l2-2m0 0l7-7 7 7M5 10v10a1 1 0 001 1h3m10-11l2 2m-2-2v10a1 1 0 01-1 1h-3m-6 0a1 1 0 001-1v-4a1 1 0 011-1h2a1 1 0 011 1v4a1 1 0 001 1m-6 0h6"})}),label:u("systemNavLabel"),isCollapsed:!j,active:b,onClick:()=>h("/")})]}),c.jsxs("div",{className:`${j?"px-4":"px-2"} py-2 space-y-1 border-t border-dash-border`,children:[j&&c.jsx("p",{className:"px-2 pb-2 pt-2 text-[10px] font-bold text-dash-text-muted uppercase tracking-widest",children:u("entitiesSection")}),c.jsx(sr,{icon:c.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:c.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 10V3L4 14h7v7l9-11h-7z"})}),label:u("workflowsTitle"),isCollapsed:!j,active:O,onClick:()=>h("/workflows")}),c.jsx(sr,{icon:c.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:c.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M17 20h5v-2a3 3 0 00-5.356-1.857M17 20H7m10 0v-2c0-.656-.126-1.283-.356-1.857M7 20H2v-2a3 3 0 015.356-1.857M7 20v-2c0-.656.126-1.283.356-1.857m0 0a5.002 5.002 0 019.288 0M15 7a3 3 0 11-6 0 3 3 0 016 0z"})}),label:u("agentsBrowser"),isCollapsed:!j,active:D,onClick:()=>h("/agents"),badge:j&&x?String(x.agents):void 0}),c.jsx(sr,{icon:c.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:c.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 9l3 3-3 3m5 0h3M5 20h14a2 2 0 002-2V6a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z"})}),label:u("commandsBrowser"),isCollapsed:!j,active:S,onClick:()=>h("/commands"),badge:j&&x?String(x.commands):void 0}),c.jsx(sr,{icon:c.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:c.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9.663 17h4.673M12 3v1m6.364 1.636l-.707.707M21 12h-1M4 12H3m3.343-5.657l-.707-.707m2.828 9.9a5 5 0 117.072 0l-.548.547A3.374 3.374 0 0014 18.469V19a2 2 0 11-4 0v-.531c0-.895-.356-1.754-.988-2.386l-.548-.547z"})}),label:u("skillsNav"),isCollapsed:!j,active:E,onClick:()=>h("/skills"),badge:j&&x?String(x.skills):void 0}),c.jsx(sr,{icon:c.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:c.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 12h14M12 5l7 7-7 7"})}),label:u("mcpTitle"),isCollapsed:!j,active:C,onClick:()=>h("/mcp"),badge:j&&x?String(x.mcpServers):void 0})]}),c.jsxs("div",{className:`${j?"px-4":"px-2"} py-2 space-y-1 border-t border-dash-border`,children:[j&&c.jsx("p",{className:"px-2 pb-2 pt-2 text-[10px] font-bold text-dash-text-muted uppercase tracking-widest",children:u("toolsSection")}),c.jsx(sr,{icon:c.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:[c.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z"}),c.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"})]}),label:u("configEditor"),isCollapsed:!j,active:w,onClick:()=>h("/config/global")}),c.jsx(sr,{icon:c.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:c.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 17V7m0 10a2 2 0 01-2 2H5a2 2 0 01-2-2V7a2 2 0 012-2h2a2 2 0 012 2m0 10a2 2 0 002 2h2a2 2 0 002-2M9 7a2 2 0 012-2h2a2 2 0 012 2m0 10V7m0 10a2 2 0 002 2h2a2 2 0 002-2V7a2 2 0 00-2-2h-2a2 2 0 00-2 2"})}),label:u("statusline"),isCollapsed:!j,active:k,onClick:()=>h("/statusline")}),c.jsx(sr,{icon:c.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:c.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M11 4a2 2 0 114 0v1a1 1 0 001 1h3a1 1 0 011 1v3a1 1 0 01-1 1h-1a2 2 0 100 4h1a1 1 0 011 1v3a1 1 0 01-1 1h-3a1 1 0 01-1-1v-1a2 2 0 10-4 0v1a1 1 0 01-1 1H7a1 1 0 01-1-1v-3a1 1 0 00-1-1H4a2 2 0 110-4h1a1 1 0 001-1V7a1 1 0 011-1h3a1 1 0 001-1V4z"})}),label:u("migrate"),isCollapsed:!j,active:v,onClick:()=>h("/migrate")})]}),c.jsxs("div",{className:`flex-1 overflow-y-auto overflow-x-hidden ${j?"px-4":"px-2"} py-2 space-y-1 border-t border-dash-border`,children:[j&&c.jsx("p",{className:"px-2 pb-2 pt-2 text-[10px] font-bold text-dash-text-muted uppercase tracking-widest",children:u("projects")}),P.map(M=>{const T=f.pathname.endsWith("/config"),L=e===M.id&&!w&&!T&&!v&&!k&&!C&&!N&&!D&&!S&&!E&&!O&&!y;return c.jsxs("button",{onClick:()=>o(M.id),className:`w-full group relative flex items-center ${j?"gap-2.5 px-2 py-1.5":"justify-center p-2"} rounded-md transition-colors ${L?"bg-dash-accent-subtle text-dash-accent border border-dash-accent/10":"text-dash-text-secondary hover:bg-dash-surface-hover hover:text-dash-text border border-transparent"}`,children:[c.jsx("div",{className:`w-2 h-2 rounded-full shrink-0 ${M.health===Yr.HEALTHY?"bg-dash-accent":M.health===Yr.WARNING?"bg-orange-400":"bg-red-500"} ${L?"animate-pulse":""}`}),j&&c.jsxs(c.Fragment,{children:[M.pinned&&c.jsx("span",{className:"text-xs",children:"📌"}),c.jsx("span",{className:"text-sm font-medium truncate",children:M.name})]}),!j&&c.jsxs("div",{className:"absolute left-14 px-2 py-1 bg-dash-text text-dash-bg text-xs rounded opacity-0 group-hover:opacity-100 transition-opacity whitespace-nowrap pointer-events-none border border-dash-border z-50",children:[M.pinned&&"📌 ",M.name]})]},M.id)}),c.jsxs("button",{onClick:()=>m(!0),className:`w-full flex items-center ${j?"gap-3 p-2.5":"justify-center p-2"} rounded-md text-dash-text-muted hover:bg-dash-surface-hover hover:text-dash-text-secondary transition-colors mt-4`,children:[c.jsx("div",{className:`${j?"w-5 h-5":""} flex items-center justify-center`,children:c.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:c.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})})}),j&&c.jsx("span",{className:"text-sm font-medium",children:u("addProject")})]})]}),c.jsx(B4,{isOpen:p,onClose:()=>m(!1),onAdd:l}),c.jsx("div",{className:"border-t border-dash-border",children:c.jsxs("div",{className:`py-3 flex items-center ${j?"px-3 justify-between":"justify-center flex-col gap-2"}`,children:[c.jsxs("div",{className:"flex items-center gap-2",title:u(s?"sync":"offline"),children:[c.jsx("div",{className:`w-2 h-2 rounded-full shrink-0 ${s?"bg-dash-accent shadow-[0_0_8px_var(--dash-accent-glow)]":"bg-red-500"}`}),j&&c.jsx("span",{className:"text-[10px] font-bold text-dash-text-muted uppercase tracking-widest",children:u(s?"sync":"offline")})]}),c.jsxs("div",{className:`flex items-center gap-1 ${j?"":"flex-col"}`,children:[c.jsx(_4,{vertical:!j}),c.jsx("button",{onClick:d,className:"w-8 h-8 rounded-lg flex items-center justify-center text-dash-text-muted hover:bg-dash-surface-hover hover:text-dash-text transition-colors",title:u(i==="dark"?"switchToLight":"switchToDark"),children:i==="dark"?c.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:c.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 3v1m0 16v1m9-9h-1M4 12H3m15.364-6.364l-.707.707M6.343 17.657l-.707.707M17.657 17.657l-.707-.707M6.343 6.343l-.707-.707M12 5a7 7 0 100 14 7 7 0 000-14z"})}):c.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:c.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M20.354 15.354A9 9 0 018.646 3.646 9.003 9.003 0 0012 21a9.003 9.003 0 008.354-5.646z"})})}),c.jsx("button",{onClick:a,className:"w-8 h-8 rounded-lg flex items-center justify-center text-dash-text-muted hover:bg-dash-surface-hover hover:text-dash-text transition-colors",title:u(n?"expand":"collapse"),children:n?c.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:c.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 5l7 7-7 7M5 5l7 7-7 7"})}):c.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:c.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M11 19l-7-7 7-7m8 14l-7-7 7-7"})})})]})]})})]})},sr=({icon:t,label:e,badge:n,isCollapsed:r,active:s,onClick:i,disabled:o})=>c.jsxs("button",{onClick:i,disabled:o,className:`w-full group relative flex items-center ${r?"justify-center p-2":"gap-3 p-2"} rounded-md transition-colors ${o?"opacity-50 cursor-not-allowed":s?"bg-dash-surface-hover text-dash-text":"text-dash-text-secondary hover:bg-dash-surface-hover hover:text-dash-text"}`,children:[c.jsx("div",{className:`${r?"":"w-5 h-5"} flex items-center justify-center`,children:t}),!r&&c.jsxs(c.Fragment,{children:[c.jsx("span",{className:"text-sm font-medium flex-1 text-left",children:e}),n&&c.jsx("span",{className:"ml-auto text-[10px] font-mono text-dash-text-disabled bg-dash-surface px-1.5 py-0.5 rounded",children:n})]}),r&&c.jsx("div",{className:"absolute left-14 px-2 py-1 bg-dash-text text-dash-bg text-xs rounded opacity-0 group-hover:opacity-100 transition-opacity whitespace-nowrap pointer-events-none border border-dash-border z-50",children:e})]});function z4(t){const[e,n]=g.useState([]),[r,s]=g.useState(!1),[i,o]=g.useState(null),a=g.useCallback(async()=>{if(!t){n([]);return}try{s(!0),o(null);const l=await j4(t,999);n(l)}catch(l){o(l instanceof Error?l.message:"Failed to load sessions")}finally{s(!1)}},[t]);return g.useEffect(()=>{a()},[a]),{sessions:e,loading:r,error:i,reload:a}}function H4(){const[t,e]=g.useState([]),[n,r]=g.useState(!0),[s,i]=g.useState(null),o=g.useCallback(async()=>{try{r(!0),i(null);const u=await l1();e(u)}catch(u){i(u instanceof Error?u.message:"Failed to load projects")}finally{r(!1)}},[]),a=g.useCallback(async u=>{const h=await M4(u);return await o(),h},[o]),l=g.useCallback(async u=>{await A4(u),await o()},[o]),d=g.useCallback(async(u,h)=>{const f=await d1(u,h);return await o(),f},[o]);return g.useEffect(()=>{o()},[o]),{projects:t,loading:n,error:s,reload:o,addProject:a,removeProject:l,updateProject:d}}function V4(t,e,n=50,r=0){const[s,i]=g.useState(null),[o,a]=g.useState(!1),[l,d]=g.useState(null),u=g.useCallback(async()=>{if(!t||!e){i(null);return}try{a(!0),d(null);const h=await N4(t,e,n,r);i(h)}catch(h){d(h instanceof Error?h.message:"Failed to load")}finally{a(!1)}},[t,e,n,r]);return g.useEffect(()=>{u()},[u]),{data:s,loading:o,error:l,reload:u}}function Xi({storageKey:t,defaultSize:e,minSize:n,maxSize:r,direction:s="horizontal",invert:i=!1}){const[o,a]=g.useState(()=>{if(typeof window>"u")return e;const p=localStorage.getItem(t);if(p){const m=Number.parseInt(p,10);if(!Number.isNaN(m)&&m>=n&&m<=r)return m}return e}),[l,d]=g.useState(!1);g.useEffect(()=>{localStorage.setItem(t,String(o))},[o,t]);const u=g.useCallback(p=>{p.preventDefault(),d(!0);const m=s==="horizontal"?p.clientX:p.clientY,x=o,b=w=>{const k=((s==="horizontal"?w.clientX:w.clientY)-m)*(i?-1:1),C=Math.max(n,Math.min(r,x+k));a(C)},y=()=>{d(!1),document.removeEventListener("mousemove",b),document.removeEventListener("mouseup",y),document.body.style.cursor="",document.body.style.userSelect=""};document.addEventListener("mousemove",b),document.addEventListener("mouseup",y),document.body.style.cursor=s==="horizontal"?"col-resize":"row-resize",document.body.style.userSelect="none"},[o,n,r,s,i]),h=g.useCallback(()=>{a(e)},[e]),f=g.useCallback(p=>{a(Math.max(n,Math.min(r,p)))},[n,r]);return{size:o,isDragging:l,startDrag:u,setSize:f,reset:h}}const W4=()=>{const{t}=te(),e=Lt(),n=gn(),{projectId:r}=pl(),[s,i]=g.useState(null);g.useEffect(()=>{r&&i(r)},[r]);const[o,a]=g.useState(()=>typeof window<"u"&&localStorage.getItem("ninekit-theme")||"dark"),[l]=g.useState(!0),[d,u]=g.useState(!1);g.useEffect(()=>{const P=A=>{(A.metaKey||A.ctrlKey)&&A.key==="k"&&(A.preventDefault(),u(I=>!I))};return window.addEventListener("keydown",P),()=>window.removeEventListener("keydown",P)},[]);const{size:h,isDragging:f,startDrag:p,setSize:m}=Xi({storageKey:"ninekit-sidebar-width",defaultSize:288,minSize:56,maxSize:400}),x=h<=56,{projects:b,loading:y,error:w,addProject:v,reload:k}=H4(),C=async P=>{await v(P)};g.useEffect(()=>{const P=n.pathname.startsWith("/project/");b.length===0||r||!P||e(`/project/${b[0].id}`,{replace:!0})},[b,r,e,n.pathname]),g.useEffect(()=>{const P=window.document.documentElement;o==="dark"?(P.classList.add("dark"),P.setAttribute("data-theme","dark")):(P.classList.remove("dark"),P.setAttribute("data-theme","light")),localStorage.setItem("ninekit-theme",o)},[o]);const N=()=>a(P=>P==="light"?"dark":"light"),D=g.useMemo(()=>b.find(P=>P.id===s)||null,[b,s]),S=P=>{e(`/project/${P}`)},E=()=>{m(x?288:56)};if(y)return c.jsx("div",{className:"flex h-screen w-full bg-dash-bg text-dash-text items-center justify-center",children:c.jsx("div",{className:"animate-pulse text-dash-text-muted",children:t("loading")})});if(w)return c.jsx("div",{className:"flex h-screen w-full bg-dash-bg text-dash-text items-center justify-center",children:c.jsxs("div",{className:"text-red-500",children:[t("error"),": ",w]})});const O={project:D,isConnected:l,theme:o,onToggleTheme:N,reloadProjects:k};return c.jsxs("div",{className:"flex h-screen w-full bg-dash-bg text-dash-text overflow-hidden font-sans transition-colors duration-300",children:[c.jsx(k4,{open:d,projects:b,onClose:()=>u(!1)}),c.jsx(F4,{projects:b,currentProjectId:s,isCollapsed:x,width:h,isConnected:l,theme:o,onSwitchProject:S,onToggle:E,onAddProject:C,onToggleTheme:N}),c.jsx(Mn,{direction:"horizontal",isDragging:f,onMouseDown:p}),c.jsx("div",{className:"flex-1 flex flex-col min-w-0 h-full relative",children:c.jsx("main",{className:"flex-1 flex flex-col overflow-hidden p-4 md:p-6",children:c.jsx(E3,{context:O})})})]})};function Tc(t){return t.toLowerCase().trim().replace(/[`*_~]/g,"").replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")}function K4(t){return t.split(`
|
|
31
31
|
`).flatMap(e=>{const n=/^(#{1,6})\s+(.+)$/.exec(e.trim());return n?[{level:n[1].length,text:n[2].trim(),id:Tc(n[2])}]:[]})}function Nr(t,e){const n=/(\*\*(.+?)\*\*|\*(.+?)\*|_(.+?)_|`([^`]+)`|\[([^\]]+)\]\(([^)]+)\))/g,r=[];let s=0,i=0;for(const o of t.matchAll(n)){o.index!==void 0&&o.index>s&&r.push(t.slice(s,o.index));const a=`${e}-inline-${i++}`;o[0].startsWith("**")?r.push(c.jsx("strong",{children:o[2]},a)):o[0].startsWith("`")?r.push(c.jsx("code",{className:"bg-[var(--dash-surface)] border border-[var(--dash-border)] px-1.5 py-0.5 rounded text-sm font-mono text-[var(--dash-accent)]",children:o[5]},a)):o[0].startsWith("[")?r.push(c.jsx("a",{href:o[7],target:"_blank",rel:"noopener noreferrer",className:"text-[var(--dash-accent)] hover:underline",children:o[6]},a)):r.push(c.jsx("em",{children:o[3]??o[4]},a)),o.index!==void 0&&(s=o.index+o[0].length)}return s<t.length&&r.push(t.slice(s)),r.length===1?r[0]:c.jsx(c.Fragment,{children:r})}const qs=({content:t,className:e=""})=>{const n=t.split(`
|
|
32
32
|
`),r=[];let s=0,i=0;function o(){return i+=1,`md-${i}`}if(n[0]?.trim()==="---"){for(s=1;s<n.length&&n[s]?.trim()!=="---";)s++;s++}for(;s<n.length;){const a=n[s];if(a.startsWith("```")){const l=a.slice(3).trim(),d=[];for(s++;s<n.length&&!n[s].startsWith("```");)d.push(n[s]),s++;const u=o();r.push(c.jsxs("div",{className:"my-3",children:[l&&c.jsx("div",{className:"text-[10px] font-mono text-[var(--dash-text-muted)] bg-[var(--dash-surface)] border border-b-0 border-[var(--dash-border)] rounded-t px-3 py-1",children:l}),c.jsx("pre",{className:["overflow-x-auto p-4 text-xs font-mono text-[var(--dash-text)]","bg-[var(--dash-surface)] border border-[var(--dash-border)]",l?"rounded-b":"rounded"].join(" "),children:c.jsx("code",{children:d.join(`
|
|
33
33
|
`)})})]},u)),s++;continue}if(/^(-{3,}|\*{3,}|_{3,})$/.test(a.trim())){r.push(c.jsx("hr",{className:"border-[var(--dash-border)] my-4"},o())),s++;continue}if(a.startsWith("### ")){const l=a.slice(4);r.push(c.jsx("h3",{id:Tc(l),className:"text-sm font-semibold text-[var(--dash-text)] mt-4 mb-1 scroll-mt-24",children:Nr(l,`h3-${i}`)},o())),s++;continue}if(a.startsWith("## ")){const l=a.slice(3);r.push(c.jsx("h2",{id:Tc(l),className:"text-base font-semibold text-[var(--dash-text)] mt-5 mb-2 pb-1 border-b border-[var(--dash-border)] scroll-mt-24",children:Nr(l,`h2-${i}`)},o())),s++;continue}if(a.startsWith("# ")){const l=a.slice(2);r.push(c.jsx("h1",{id:Tc(l),className:"text-xl font-bold text-[var(--dash-text)] mt-4 mb-2 first:mt-0 scroll-mt-24",children:Nr(l,`h1-${i}`)},o())),s++;continue}if(a.trim().startsWith("|")&&/^\|(?:\s*:?-+:?\s*\|)+\s*$/.test(n[s+1]?.trim()??"")){const l=a.trim().split("|").slice(1,-1).map(h=>h.trim()),d=[];for(s+=2;s<n.length&&n[s].trim().startsWith("|");)d.push(n[s].trim().split("|").slice(1,-1).map(h=>h.trim())),s++;const u=o();r.push(c.jsx("div",{className:"my-4 overflow-x-auto rounded-lg border border-[var(--dash-border)]",children:c.jsxs("table",{className:"min-w-full text-sm",children:[c.jsx("thead",{className:"bg-[var(--dash-surface)] text-[var(--dash-text)]",children:c.jsx("tr",{children:l.map((h,f)=>c.jsx("th",{className:"px-3 py-2 text-left font-semibold",children:Nr(h,`${u}-head-${f}`)},`${u}-head-${f}`))})}),c.jsx("tbody",{children:d.map((h,f)=>c.jsx("tr",{className:"border-t border-[var(--dash-border)] text-[var(--dash-text-muted)]",children:h.map((p,m)=>c.jsx("td",{className:"px-3 py-2 align-top",children:Nr(p,`${u}-cell-${f}-${m}`)},`${u}-cell-${f}-${m}`))},`${u}-row-${f}`))})]})},u));continue}if(a.startsWith("> ")){const l=[];for(;s<n.length&&n[s].startsWith("> ");)l.push(n[s].slice(2)),s++;const d=o();r.push(c.jsx("blockquote",{className:"border-l-2 border-[var(--dash-accent)] pl-4 italic text-[var(--dash-text-muted)] my-2",children:l.map((u,h)=>c.jsx("p",{className:"text-sm leading-relaxed",children:Nr(u,`${d}-q${h}`)},`${d}-q${h}`))},d));continue}if(/^\s*[-*+] /.test(a)){const l=[];for(;s<n.length&&/^\s*[-*+] /.test(n[s]);)l.push(n[s].replace(/^\s*[-*+] /,"")),s++;const d=o();r.push(c.jsx("ul",{className:"list-disc pl-6 space-y-1 my-2",children:l.map((u,h)=>c.jsx("li",{className:"text-sm text-[var(--dash-text)] leading-relaxed",children:Nr(u,`${d}-li${h}`)},`${d}-li${h}`))},d));continue}if(/^\d+\. /.test(a)){const l=[];for(;s<n.length&&/^\d+\. /.test(n[s]);)l.push(n[s].replace(/^\d+\. /,"")),s++;const d=o();r.push(c.jsx("ol",{className:"list-decimal pl-6 space-y-1 my-2",children:l.map((u,h)=>c.jsx("li",{className:"text-sm text-[var(--dash-text)] leading-relaxed",children:Nr(u,`${d}-ol${h}`)},`${d}-ol${h}`))},d));continue}if(a.trim()===""){r.push(c.jsx("div",{className:"h-2"},o())),s++;continue}r.push(c.jsx("p",{className:"text-sm text-[var(--dash-text)] leading-relaxed my-1",children:Nr(a,`p-${i}`)},o())),s++}return c.jsx("div",{className:`markdown-content ${e}`.trim(),children:r})};function U4(){const[t,e]=g.useState([]),[n,r]=g.useState(!0),[s,i]=g.useState(null),o=g.useCallback(async()=>{try{r(!0),i(null);const a=await fetch("/api/agents/browser");if(!a.ok)throw new Error(`Request failed: ${a.status}`);const l=await a.json();e(l.agents)}catch(a){i(a instanceof Error?a.message:"Failed to load agents")}finally{r(!1)}},[]);return g.useEffect(()=>{o()},[o]),{agents:t,loading:n,error:s,reload:o}}function G4(t){const[e,n]=g.useState(null),[r,s]=g.useState(!1),[i,o]=g.useState(null),a=g.useCallback(async()=>{if(t)try{s(!0),o(null);const l=await fetch(`/api/agents/browser/${encodeURIComponent(t)}`);if(l.status===404)throw new Error("Agent not found");if(!l.ok)throw new Error(`Request failed: ${l.status}`);const d=await l.json();n(d)}catch(l){o(l instanceof Error?l.message:"Failed to load agent")}finally{s(!1)}},[t]);return g.useEffect(()=>{a()},[a]),{agent:e,loading:r,error:i}}function q4(){return c.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"w-3.5 h-3.5 shrink-0 text-dash-accent",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:c.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9.75 3.104v5.714a2.25 2.25 0 01-.659 1.591L5 14.5M9.75 3.104c-.251.023-.501.05-.75.082m.75-.082a24.301 24.301 0 014.5 0m0 0v5.714a2.25 2.25 0 001.357 2.059l1.045.467A4.5 4.5 0 0121 15.75v.75m-4.5-6.75a.75.75 0 00-.75.75v3a.75.75 0 001.5 0v-3a.75.75 0 00-.75-.75z"})})}function u1(t){if(!t)return"unset";const e=t.toLowerCase();return e.includes("opus")?"opus":e.includes("sonnet")?"sonnet":e.includes("haiku")?"haiku":"unset"}function Y4(t){if(!t)return"unset";const e=u1(t);return e!=="unset"?e:t.length>16?`${t.slice(0,14)}…`:t}const X4=({label:t,active:e,onClick:n})=>c.jsx("button",{type:"button",onClick:n,className:["px-2.5 py-0.5 rounded-full text-xs font-medium border transition-colors",e?"bg-dash-accent-subtle text-dash-accent border-dash-accent/30":"bg-transparent text-dash-text-muted border-dash-border hover:border-dash-accent/40 hover:text-dash-text"].join(" "),children:t});function Q4({agent:t,selected:e,onClick:n}){return c.jsxs("button",{type:"button",onClick:n,className:["w-full flex items-start gap-2 px-3 py-2 rounded-md transition-colors text-left group",e?"bg-dash-accent/10 border border-dash-accent/30":"hover:bg-dash-surface-hover border border-transparent"].join(" "),children:[c.jsx(q4,{}),c.jsxs("div",{className:"flex-1 min-w-0",children:[c.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[c.jsx("span",{className:"text-sm font-semibold text-dash-accent font-mono",children:t.name}),t.model&&c.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-dash-accent-subtle text-dash-accent font-medium shrink-0",children:Y4(t.model)})]}),t.description&&c.jsx("p",{className:"text-xs text-dash-text-muted mt-0.5 truncate",children:t.description})]})]})}function J4({label:t,count:e}){return c.jsxs("div",{className:"flex items-center gap-2 px-2 py-1.5",children:[c.jsx("span",{className:"text-xs font-bold text-dash-text-muted uppercase tracking-wider flex-1",children:t}),c.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-dash-accent-subtle text-dash-accent font-semibold",children:e})]})}const Z4=new Set(["name","description","color"]),eN=({frontmatter:t})=>{const e=Object.entries(t).filter(([n,r])=>!Z4.has(n)&&r!==void 0&&r!==null&&r!=="");return e.length===0?null:c.jsx("div",{className:"rounded-lg border border-dash-border overflow-hidden text-sm",children:c.jsx("table",{className:"w-full",children:c.jsx("tbody",{children:e.map(([n,r])=>c.jsxs("tr",{className:"border-b border-dash-border last:border-0",children:[c.jsx("td",{className:"px-3 py-2 font-mono text-xs text-dash-text-muted bg-dash-surface w-32 shrink-0 align-top",children:n}),c.jsx("td",{className:"px-3 py-2 text-xs text-dash-text break-all",children:typeof r=="object"?JSON.stringify(r):String(r)})]},n))})})})},tN=({slug:t})=>{const{t:e}=te(),{agent:n,loading:r,error:s}=G4(t);return r?c.jsx("div",{className:"flex items-center justify-center h-32 text-sm text-dash-text-muted",children:e("loading")}):s?c.jsx("div",{className:"rounded-lg border border-red-300 bg-red-50 dark:bg-red-900/20 p-4 text-red-600 dark:text-red-400 text-sm",children:s}):n?c.jsxs("div",{className:"flex flex-col gap-4",children:[c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsx("h2",{className:"text-base font-semibold text-dash-text font-mono truncate flex-1",children:n.name}),c.jsx("span",{className:"text-xs px-2 py-0.5 rounded bg-dash-accent-subtle text-dash-accent font-semibold shrink-0",children:e("sessionReadOnly")})]}),n.description&&c.jsx("div",{className:"rounded-lg border border-dash-border bg-dash-surface px-4 py-3",children:c.jsx("p",{className:"text-sm text-dash-text-muted",children:n.description})}),c.jsx("div",{className:"flex items-center gap-2 text-xs text-dash-text-muted",children:c.jsxs("span",{className:"font-mono px-2 py-0.5 rounded bg-dash-surface border border-dash-border text-dash-accent",children:[n.dirLabel,"/",t,".md"]})}),c.jsx(eN,{frontmatter:n.frontmatter}),n.body&&c.jsx("div",{className:"rounded-lg border border-dash-border bg-dash-surface p-5 overflow-x-auto",children:c.jsx(qs,{content:n.body})})]}):null},nN=({message:t})=>c.jsx("div",{className:"flex items-center justify-center h-full text-sm text-dash-text-muted",children:t}),rN=()=>{const{t}=te(),{agents:e,loading:n,error:r}=U4(),[s,i]=g.useState(""),[o,a]=g.useState("all"),[l,d]=g.useState(null),{size:u,isDragging:h,startDrag:f}=Xi({storageKey:"nk-agents-panel-width",defaultSize:380,minSize:260,maxSize:650}),p=g.useMemo(()=>{let b=e;if(s.trim()){const y=s.toLowerCase();b=b.filter(w=>w.name.toLowerCase().includes(y)||w.description.toLowerCase().includes(y))}return o!=="all"&&(b=b.filter(y=>u1(y.model)===o)),b},[e,s,o]),m=g.useMemo(()=>{const b=new Map;for(const y of p){const w=b.get(y.dirLabel)??[];w.push(y),b.set(y.dirLabel,w)}return b},[p]),x=[{key:"all",label:t("filterAll")},{key:"opus",label:"Opus"},{key:"sonnet",label:"Sonnet"},{key:"haiku",label:"Haiku"},{key:"unset",label:"Unset"}];return c.jsxs("div",{className:"flex h-full overflow-hidden",children:[c.jsxs("div",{style:{width:`${u}px`},className:"shrink-0 flex flex-col overflow-hidden border-r border-dash-border",children:[c.jsxs("div",{className:"shrink-0 px-4 pt-4 pb-3 border-b border-dash-border",children:[c.jsxs("div",{className:"flex items-start justify-between mb-3",children:[c.jsxs("div",{children:[c.jsx("h1",{className:"text-base font-bold text-dash-text",children:t("agentsBrowser")}),!n&&!r&&c.jsx("p",{className:"text-xs text-dash-text-muted mt-0.5",children:t("agentsBrowserCount").replace("{count}",String(e.length))}),c.jsx("p",{className:"text-[11px] text-dash-text-muted font-mono mt-0.5",children:"~/.claude/agents/"})]}),c.jsx("span",{className:"text-xs px-2 py-0.5 rounded bg-dash-accent-subtle text-dash-accent font-semibold shrink-0",children:t("sessionReadOnly")})]}),c.jsxs("div",{className:"relative mb-2",children:[c.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-dash-text-muted pointer-events-none",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:c.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})}),c.jsx("input",{type:"text",value:s,onChange:b=>i(b.target.value),placeholder:t("searchAgentsPlaceholder"),className:"w-full pl-9 pr-4 py-2 text-sm bg-dash-surface border border-dash-border rounded-lg text-dash-text placeholder:text-dash-text-muted focus:outline-none focus:border-dash-accent/50 transition-colors"}),s&&c.jsx("button",{type:"button",onClick:()=>i(""),className:"absolute right-3 top-1/2 -translate-y-1/2 text-dash-text-muted hover:text-dash-text transition-colors",children:c.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:c.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),c.jsx("div",{className:"flex items-center gap-1 flex-wrap",children:x.map(({key:b,label:y})=>c.jsx(X4,{label:y,active:o===b,onClick:()=>a(b)},b))})]}),c.jsxs("div",{className:"flex-1 overflow-y-auto px-2 py-2",children:[n&&c.jsx("div",{className:"flex flex-1 items-center justify-center text-dash-text-muted text-sm p-8",children:t("loading")}),!n&&r&&c.jsx("div",{className:"rounded-lg border border-red-300 bg-red-50 dark:bg-red-900/20 p-4 text-red-600 dark:text-red-400 text-sm m-2",children:r}),!n&&!r&&m.size===0&&c.jsx("div",{className:"flex items-center justify-center p-8 text-dash-text-muted text-sm",children:t("noAgentsFound")}),!n&&!r&&m.size>0&&c.jsx("div",{className:"flex flex-col gap-2 pb-4",children:Array.from(m.entries()).map(([b,y])=>c.jsxs("div",{children:[m.size>1&&c.jsx(J4,{label:b,count:y.length}),c.jsx("div",{className:"space-y-0.5",children:y.map(w=>c.jsx(Q4,{agent:w,selected:l===w.slug,onClick:()=>d(w.slug)},`${w.dirLabel}/${w.slug}`))})]},b))})]})]}),c.jsx(Mn,{onMouseDown:f,isDragging:h,direction:"horizontal"}),c.jsx("div",{className:"flex-1 overflow-y-auto p-6",children:l?c.jsx(tN,{slug:l}):c.jsx(nN,{message:t("selectToView")})})]})};function sN(){const[t,e]=g.useState([]),[n,r]=g.useState(!0),[s,i]=g.useState(null),o=g.useCallback(async()=>{try{r(!0),i(null);const a=await fetch("/api/commands");if(!a.ok)throw new Error(`HTTP ${a.status}`);const l=await a.json();e(l.tree)}catch(a){i(a instanceof Error?a.message:"Failed to load")}finally{r(!1)}},[]);return g.useEffect(()=>{o()},[o]),{tree:t,loading:n,error:s,reload:o}}function iN(t){const[e,n]=g.useState(null),[r,s]=g.useState(!1),[i,o]=g.useState(null),a=g.useCallback(async()=>{if(!t){n(null);return}try{s(!0),o(null);const l=t.replace(/\//g,"--"),d=await fetch(`/api/commands/detail/${encodeURIComponent(l)}`);if(!d.ok)throw new Error(`HTTP ${d.status}`);const u=await d.json();n(u)}catch(l){o(l instanceof Error?l.message:"Failed to load")}finally{s(!1)}},[t]);return g.useEffect(()=>{a()},[a]),{detail:e,loading:r,error:i,reload:a}}function h1(t){const e=[];for(const n of t)n.children?e.push(...h1(n.children)):e.push(n);return e}function f1(t){return h1(t).length}function oN(){return c.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"w-4 h-4 shrink-0",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:c.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3 7a2 2 0 012-2h4l2 2h8a2 2 0 012 2v8a2 2 0 01-2 2H5a2 2 0 01-2-2V7z"})})}function p1({open:t}){return c.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:`w-3 h-3 shrink-0 transition-transform ${t?"rotate-90":""}`,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:c.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})})}function aN(){return c.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"w-3.5 h-3.5 shrink-0 text-dash-accent",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:c.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 9l3 3-3 3m5 0h3"})})}function m1(t,e){if(!e)return!0;const n=e.toLowerCase();return t.name.toLowerCase().includes(n)||t.description?.toLowerCase().includes(n)?!0:t.children?t.children.some(r=>m1(r,n)):!1}function g1(t,e){return e?t.filter(n=>m1(n,e)).map(n=>n.children?{...n,children:g1(n.children,e)}:n):t}function x1({node:t,selected:e,onSelect:n}){return c.jsxs("button",{type:"button",onClick:()=>n(t.path),className:["w-full flex items-start gap-2 px-3 py-2 rounded-md transition-colors text-left group",e?"bg-dash-accent/10 border border-dash-accent/30":"hover:bg-dash-surface-hover border border-transparent"].join(" "),children:[c.jsx(aN,{}),c.jsxs("div",{className:"flex-1 min-w-0",children:[c.jsxs("span",{className:"text-sm font-semibold text-dash-accent font-mono",children:["/",t.name]}),t.description&&c.jsx("p",{className:"text-xs text-dash-text-muted mt-0.5 truncate",children:t.description})]})]})}function b1({node:t,depth:e,forceOpen:n,selectedPath:r,onSelect:s}){const[i,o]=g.useState(!0),a=n||i,l=f1(t.children??[]);return c.jsxs("div",{className:e>0?"ml-3 border-l border-dash-border pl-2":"",children:[c.jsxs("button",{type:"button",onClick:()=>o(d=>!d),className:"w-full flex items-center gap-2 px-2 py-1.5 rounded-md hover:bg-dash-surface-hover transition-colors text-left",children:[c.jsx(p1,{open:a}),c.jsx(oN,{}),c.jsx("span",{className:"text-xs font-bold text-dash-text-muted uppercase tracking-wider flex-1",children:t.name}),c.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-dash-accent-subtle text-dash-accent font-semibold",children:l})]}),a&&c.jsx("div",{className:"mt-0.5 space-y-0.5",children:(t.children??[]).map(d=>d.children?c.jsx(b1,{node:d,depth:e+1,forceOpen:n,selectedPath:r,onSelect:s},d.path):c.jsx(x1,{node:d,selected:r===d.path,onSelect:s},d.path))})]})}function lN({nodes:t,forceOpen:e,selectedPath:n,onSelect:r,label:s}){const[i,o]=g.useState(!0),a=e||i;return t.length===0?null:c.jsxs("div",{children:[c.jsxs("button",{type:"button",onClick:()=>o(l=>!l),className:"w-full flex items-center gap-2 px-2 py-1.5 rounded-md hover:bg-dash-surface-hover transition-colors text-left",children:[c.jsx(p1,{open:a}),c.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"w-4 h-4 shrink-0 text-dash-text-muted",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:c.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3 12l2-2m0 0l7-7 7 7M5 10v10a1 1 0 001 1h3m10-11l2 2m-2-2v10a1 1 0 01-1 1h-3m-6 0a1 1 0 001-1v-4a1 1 0 011-1h2a1 1 0 011 1v4a1 1 0 001 1m-6 0h6"})}),c.jsx("span",{className:"text-xs font-bold text-dash-text-muted uppercase tracking-wider flex-1",children:s}),c.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-dash-accent-subtle text-dash-accent font-semibold",children:t.length})]}),a&&c.jsx("div",{className:"mt-0.5 space-y-0.5",children:t.map(l=>c.jsx(x1,{node:l,selected:n===l.path,onSelect:r},l.path))})]})}const cN=({commandPath:t})=>{const{t:e}=te(),{detail:n,loading:r,error:s}=iN(t);return r?c.jsx("div",{className:"flex items-center justify-center h-32 text-sm text-dash-text-muted",children:e("sessionLoading")}):s?c.jsxs("div",{className:"rounded-lg border border-red-300 bg-red-50 dark:bg-red-900/20 p-4 text-red-600 dark:text-red-400 text-sm",children:[e("sessionError"),": ",s]}):n?c.jsxs("div",{className:"flex flex-col gap-4",children:[c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsxs("h2",{className:"text-base font-semibold text-dash-text font-mono truncate flex-1",children:["/",n.name]}),c.jsx("span",{className:"text-xs px-2 py-0.5 rounded bg-dash-accent-subtle text-dash-accent font-semibold shrink-0",children:e("sessionReadOnly")})]}),n.description&&c.jsx("div",{className:"rounded-lg border border-dash-border bg-dash-surface px-4 py-3",children:c.jsx("p",{className:"text-sm text-dash-text-muted",children:n.description})}),c.jsx("div",{className:"flex items-center gap-2 text-xs text-dash-text-muted",children:c.jsxs("span",{className:"font-mono px-2 py-0.5 rounded bg-dash-surface border border-dash-border text-dash-accent",children:["~/.claude/commands/",n.path]})}),c.jsx("div",{className:"rounded-lg border border-dash-border bg-dash-surface p-5 overflow-x-auto",children:c.jsx(qs,{content:n.content})})]}):null},dN=({message:t})=>c.jsx("div",{className:"flex items-center justify-center h-full text-sm text-dash-text-muted",children:t}),uN=()=>{const{t}=te(),{tree:e,loading:n,error:r}=sN(),[s,i]=g.useState(""),[o,a]=g.useState(null),{size:l,isDragging:d,startDrag:u}=Xi({storageKey:"nk-commands-panel-width",defaultSize:380,minSize:260,maxSize:650}),h=g.useMemo(()=>g1(e,s),[e,s]),f=h.filter(b=>!b.children),p=h.filter(b=>b.children),m=g.useMemo(()=>f1(e),[e]),x=s.trim().length>0;return c.jsxs("div",{className:"flex h-full overflow-hidden",children:[c.jsxs("div",{style:{width:`${l}px`},className:"shrink-0 flex flex-col overflow-hidden border-r border-dash-border",children:[c.jsxs("div",{className:"shrink-0 px-4 pt-4 pb-3 border-b border-dash-border",children:[c.jsxs("div",{className:"flex items-start justify-between mb-3",children:[c.jsxs("div",{children:[c.jsx("h1",{className:"text-base font-bold text-dash-text",children:t("commandsBrowser")}),!n&&!r&&c.jsx("p",{className:"text-xs text-dash-text-muted mt-0.5",children:t("commandsCount").replace("{count}",String(m))}),c.jsx("p",{className:"text-[11px] text-dash-text-muted font-mono mt-0.5",children:"~/.claude/commands/"})]}),c.jsx("span",{className:"text-xs px-2 py-0.5 rounded bg-dash-accent-subtle text-dash-accent font-semibold shrink-0",children:t("sessionReadOnly")})]}),c.jsxs("div",{className:"relative",children:[c.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-dash-text-muted pointer-events-none",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:c.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})}),c.jsx("input",{type:"text",value:s,onChange:b=>i(b.target.value),placeholder:t("searchCommandsPlaceholder"),className:"w-full pl-9 pr-4 py-2 text-sm bg-dash-surface border border-dash-border rounded-lg text-dash-text placeholder:text-dash-text-muted focus:outline-none focus:border-dash-accent/50 transition-colors"}),s&&c.jsx("button",{type:"button",onClick:()=>i(""),className:"absolute right-3 top-1/2 -translate-y-1/2 text-dash-text-muted hover:text-dash-text transition-colors",children:c.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:c.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})]}),c.jsxs("div",{className:"flex-1 overflow-y-auto px-2 py-2",children:[n&&c.jsx("div",{className:"flex flex-1 items-center justify-center text-dash-text-muted text-sm p-8",children:t("sessionLoading")}),!n&&r&&c.jsxs("div",{className:"rounded-lg border border-red-300 bg-red-50 dark:bg-red-900/20 p-4 text-red-600 dark:text-red-400 text-sm m-2",children:[t("sessionError"),": ",r]}),!n&&!r&&h.length===0&&c.jsx("div",{className:"flex items-center justify-center p-8 text-dash-text-muted text-sm",children:t("noCommandsFound")}),!n&&!r&&h.length>0&&c.jsxs("div",{className:"flex flex-col gap-2 pb-4",children:[c.jsx(lN,{nodes:f,forceOpen:x,selectedPath:o,onSelect:a,label:t("rootCommands")}),p.map(b=>c.jsx(b1,{node:b,depth:0,forceOpen:x,selectedPath:o,onSelect:a},b.path))]})]})]}),c.jsx(Mn,{onMouseDown:u,isDragging:d,direction:"horizontal"}),c.jsx("div",{className:"flex-1 overflow-y-auto p-6",children:o?c.jsx(cN,{commandPath:o}):c.jsx(dN,{message:t("selectToView")})})]})},y1=({title:t,filePath:e,onBack:n,onSave:r,onReset:s,saveStatus:i,syntaxError:o,showResetConfirm:a,setShowResetConfirm:l,badge:d,showActions:u=!0,showFilePath:h=!0})=>{const{t:f}=te();return c.jsxs("div",{className:"flex items-center justify-between mb-3 shrink-0",children:[c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsx("button",{onClick:n,className:"px-2 py-1 rounded-lg bg-dash-surface hover:bg-dash-surface-hover border border-dash-border text-sm text-dash-text-secondary hover:text-dash-text flex items-center group transition-all font-medium shadow-sm",title:f("backToDashboard"),children:c.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"w-4 h-4 group-hover:-translate-x-0.5 transition-transform",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:c.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 19l-7-7 7-7"})})}),c.jsx("h1",{className:"text-xl font-bold tracking-tight text-dash-text",children:t}),d,h&&c.jsx("span",{className:"text-xs text-dash-text-muted mono",children:e})]}),u&&c.jsxs("div",{className:"flex items-center gap-2 relative",children:[a?c.jsxs("div",{className:"flex items-center gap-2 bg-red-500/10 border border-red-500/30 rounded-lg px-2 py-1 animate-in fade-in duration-200",children:[c.jsx("span",{className:"text-xs text-red-500 font-medium",children:f("confirmReset")}),c.jsx("button",{onClick:s,className:"px-2 py-0.5 rounded bg-red-500 text-white text-xs font-bold hover:bg-red-600 transition-colors",children:f("confirm")}),c.jsx("button",{onClick:()=>l(!1),className:"px-2 py-0.5 rounded bg-dash-surface text-dash-text-secondary text-xs font-bold hover:bg-dash-surface-hover transition-colors border border-dash-border",children:f("cancel")})]}):c.jsx("button",{onClick:()=>l(!0),className:"px-3 py-1.5 rounded-lg bg-dash-surface text-xs font-bold text-dash-text-secondary hover:bg-dash-surface-hover transition-colors border border-dash-border",children:f("resetToDefault")}),c.jsx("button",{onClick:r,disabled:!!o||i==="saving",className:`px-3 py-1.5 rounded-lg text-xs font-bold transition-all tracking-widest uppercase ${o?"bg-dash-surface text-dash-text-muted cursor-not-allowed border border-dash-border":i==="saved"?"bg-green-500 text-white shadow-lg shadow-green-500/20":i==="error"?"bg-red-500 text-white":"bg-dash-accent text-dash-bg hover:bg-dash-accent-hover shadow-lg shadow-dash-accent/20"}`,children:f(i==="saving"?"saving":i==="saved"?"saved":i==="error"?"saveFailed":"saveChanges")})]})]})},v1={plan:{path:"plan",type:"object",default:"{}",description:"Configuration for plan management including naming conventions, resolution strategies, and validation workflows.",descriptionVi:"Cấu hình quản lý kế hoạch bao gồm quy ước đặt tên, chiến lược giải quyết và quy trình xác thực.",effect:"Controls how plans are created (namingFormat), located (resolution), and reviewed (validation) during development.",effectVi:"Điều khiển cách tạo kế hoạch (namingFormat), định vị (resolution) và xem xét (validation) trong quá trình phát triển."},"plan.resolution":{path:"plan.resolution",type:"object",default:"{}",description:"Settings for resolving which plan is currently active. Uses cascading resolution: session state (explicit) → branch name matching (suggested).",descriptionVi:"Cài đặt để xác định kế hoạch đang hoạt động. Sử dụng giải quyết theo tầng: trạng thái phiên (rõ ràng) → khớp tên nhánh (gợi ý).",effect:"'session' = ACTIVE (explicitly set via set-active-plan). 'branch' = SUGGESTED (hint from git branch name). 'mostRecent' was removed to avoid stale plan pollution.",effectVi:"'session' = ĐANG HOẠT ĐỘNG (đặt rõ ràng qua set-active-plan). 'branch' = GỢI Ý (từ tên nhánh git). 'mostRecent' đã bị xóa để tránh ô nhiễm kế hoạch cũ."},"plan.validation":{path:"plan.validation",type:"object",default:"{}",description:"Settings for the plan validation interview that reviews assumptions, risks, and architecture decisions.",descriptionVi:"Cài đặt cho phỏng vấn xác thực kế hoạch để xem xét giả định, rủi ro và quyết định kiến trúc.",effect:"Runs validation interview based on mode: 'prompt' (ask first), 'auto' (run automatically), 'strict' (enforce validation), 'none' (skip). Questions focus on configured areas.",effectVi:"Chạy phỏng vấn xác thực dựa trên chế độ: 'prompt' (hỏi trước), 'auto' (tự chạy), 'strict' (bắt buộc xác thực), 'none' (bỏ qua). Câu hỏi tập trung vào các lĩnh vực đã cấu hình."},paths:{path:"paths",type:"object",default:"{}",description:"Custom paths for project directories. Supports relative paths (from project root) or absolute paths for consolidated setups.",descriptionVi:"Đường dẫn tùy chỉnh cho các thư mục dự án. Hỗ trợ đường dẫn tương đối (từ thư mục gốc) hoặc tuyệt đối cho thiết lập tập trung.",effect:"Relative paths are resolved from project root. Absolute paths allow consolidated plans across repos.",effectVi:"Đường dẫn tương đối được giải quyết từ thư mục gốc dự án. Đường dẫn tuyệt đối cho phép kế hoạch tập trung giữa các repo."},locale:{path:"locale",type:"object",default:"{}",description:"Language settings separating internal AI reasoning from user-facing output for optimal precision.",descriptionVi:"Cài đặt ngôn ngữ tách suy luận AI nội bộ khỏi đầu ra cho người dùng để có độ chính xác tối ưu.",effect:"thinkingLanguage: for reasoning/logic (recommended: 'en'). responseLanguage: for user output (e.g., 'vi' for Vietnamese responses).",effectVi:"thinkingLanguage: cho suy luận/logic (khuyến nghị: 'en'). responseLanguage: cho đầu ra người dùng (vd: 'vi' cho phản hồi tiếng Việt)."},trust:{path:"trust",type:"object",default:"{}",description:"Trusted execution mode for bypassing certain security confirmations in controlled environments.",descriptionVi:"Chế độ thực thi tin cậy để bỏ qua một số xác nhận bảo mật trong môi trường được kiểm soát.",effect:"When trust.enabled=true, security prompts may be skipped. passphrase is used for context injection testing.",effectVi:"Khi trust.enabled=true, các lời nhắc bảo mật có thể bị bỏ qua. passphrase dùng để kiểm tra tiêm ngữ cảnh."},project:{path:"project",type:"object",default:"{}",description:"Override automatic project detection. Set to 'auto' for automatic detection or specify exact values.",descriptionVi:"Ghi đè phát hiện dự án tự động. Đặt 'auto' để tự động phát hiện hoặc chỉ định giá trị cụ thể.",effect:"type: single-repo/monorepo/library. packageManager: npm/yarn/pnpm/bun. framework: next/nuxt/astro/etc.",effectVi:"type: single-repo/monorepo/library. packageManager: npm/yarn/pnpm/bun. framework: next/nuxt/astro/v.v."},codingLevel:{path:"codingLevel",type:"number",default:"-1",validValues:["-1","0","1","2","3","4","5"],description:"Controls the communication style and depth of explanations based on user's coding experience level.",descriptionVi:"Điều khiển phong cách giao tiếp và độ sâu giải thích dựa trên trình độ lập trình của người dùng.",effect:"Loads corresponding output style and injects it into the session context. Changes how Claude explains code and structures responses.",effectVi:"Tải phong cách đầu ra tương ứng và đưa vào ngữ cảnh phiên. Thay đổi cách Claude giải thích code và cấu trúc phản hồi.",example:`{
|
|
Binary file
|
package/dist/ui/index.html
CHANGED
|
@@ -71,7 +71,7 @@
|
|
|
71
71
|
background: var(--dash-text-muted);
|
|
72
72
|
}
|
|
73
73
|
</style>
|
|
74
|
-
<script type="module" crossorigin src="/assets/index-
|
|
74
|
+
<script type="module" crossorigin src="/assets/index-ji8HfB0T.js"></script>
|
|
75
75
|
<link rel="modulepreload" crossorigin href="/assets/vendor-DtOhX2xw.js">
|
|
76
76
|
<link rel="stylesheet" crossorigin href="/assets/index-R4f9D835.css">
|
|
77
77
|
</head>
|