coder-config 0.51.1-beta → 0.52.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/lib/apply.js CHANGED
@@ -318,12 +318,20 @@ function applyForGemini(registryPath, projectDir = null) {
318
318
 
319
319
  /**
320
320
  * Generate MCP config for Codex CLI
321
+ * Codex reads MCPs from [mcp_servers.<name>] tables in ~/.codex/config.toml
321
322
  */
322
323
  function applyForCodex(registryPath, projectDir = null) {
323
324
  const dir = projectDir || findProjectRoot() || process.cwd();
324
- const paths = TOOL_PATHS.codex;
325
325
  const homeDir = process.env.HOME || '';
326
326
 
327
+ let TOML;
328
+ try {
329
+ TOML = require('@iarna/toml');
330
+ } catch (e) {
331
+ console.error('Error: @iarna/toml not available - cannot generate Codex config');
332
+ return false;
333
+ }
334
+
327
335
  const registry = loadJson(registryPath);
328
336
  if (!registry) {
329
337
  console.error('Error: Could not load MCP registry');
@@ -355,12 +363,12 @@ function applyForCodex(registryPath, projectDir = null) {
355
363
  }
356
364
  }
357
365
 
358
- const output = { mcpServers: {} };
366
+ const mcpServers = {};
359
367
 
360
368
  if (mergedConfig.include && Array.isArray(mergedConfig.include)) {
361
369
  for (const name of mergedConfig.include) {
362
370
  if (registry.mcpServers && registry.mcpServers[name]) {
363
- output.mcpServers[name] = interpolate(registry.mcpServers[name], env);
371
+ mcpServers[name] = interpolate(registry.mcpServers[name], env);
364
372
  }
365
373
  }
366
374
  }
@@ -368,23 +376,51 @@ function applyForCodex(registryPath, projectDir = null) {
368
376
  if (mergedConfig.mcpServers) {
369
377
  for (const [name, config] of Object.entries(mergedConfig.mcpServers)) {
370
378
  if (name.startsWith('_')) continue;
371
- output.mcpServers[name] = interpolate(config, env);
379
+ mcpServers[name] = interpolate(config, env);
372
380
  }
373
381
  }
374
382
 
375
- // Generate per-project config (.codex/mcp.json)
376
- const projectOutputDir = path.join(dir, '.codex');
377
- const projectOutputPath = path.join(projectOutputDir, 'mcp.json');
383
+ // Merge MCPs into ~/.codex/config.toml under [mcp_servers]
384
+ const configPath = path.join(homeDir, '.codex', 'config.toml');
385
+ const configDir = path.dirname(configPath);
386
+ if (!fs.existsSync(configDir)) {
387
+ fs.mkdirSync(configDir, { recursive: true });
388
+ }
378
389
 
379
- if (!fs.existsSync(projectOutputDir)) {
380
- fs.mkdirSync(projectOutputDir, { recursive: true });
390
+ let existingConfig = {};
391
+ if (fs.existsSync(configPath)) {
392
+ try {
393
+ existingConfig = TOML.parse(fs.readFileSync(configPath, 'utf8'));
394
+ } catch (e) {
395
+ console.warn('Warning: Could not parse existing config.toml, preserving as-is');
396
+ existingConfig = {};
397
+ }
381
398
  }
382
399
 
383
- saveJson(projectOutputPath, output);
400
+ // Merge mcp_servers — coder-config managed servers replace, user servers preserved
401
+ const existingMcpServers = existingConfig.mcp_servers || {};
402
+ const managedTag = '_managed_by_coder_config';
384
403
 
385
- const count = Object.keys(output.mcpServers).length;
386
- console.log(`✓ Generated ${projectOutputPath} (Codex CLI)`);
387
- console.log(` └─ ${count} MCP(s): ${Object.keys(output.mcpServers).join(', ')}`);
404
+ // Remove previously managed servers
405
+ for (const [name, server] of Object.entries(existingMcpServers)) {
406
+ if (server && server[managedTag]) {
407
+ delete existingMcpServers[name];
408
+ }
409
+ }
410
+
411
+ // Add new managed servers (tag them so we can clean up on next apply)
412
+ for (const [name, config] of Object.entries(mcpServers)) {
413
+ existingMcpServers[name] = { ...config, [managedTag]: true };
414
+ }
415
+
416
+ existingConfig.mcp_servers = existingMcpServers;
417
+
418
+ const tomlContent = TOML.stringify(existingConfig);
419
+ fs.writeFileSync(configPath, tomlContent, 'utf8');
420
+
421
+ const count = Object.keys(mcpServers).length;
422
+ console.log(`✓ Updated ${configPath} (Codex CLI)`);
423
+ console.log(` └─ ${count} managed MCP(s): ${Object.keys(mcpServers).join(', ')}`);
388
424
 
389
425
  return true;
390
426
  }
package/lib/constants.js CHANGED
@@ -2,7 +2,7 @@
2
2
  * Constants and tool path configurations
3
3
  */
4
4
 
5
- const VERSION = '0.51.1-beta';
5
+ const VERSION = '0.52.0';
6
6
 
7
7
  // Tool-specific path configurations
8
8
  const TOOL_PATHS = {
@@ -61,14 +61,16 @@ const TOOL_PATHS = {
61
61
  name: 'Codex CLI',
62
62
  icon: 'terminal',
63
63
  color: 'green',
64
- globalConfig: '~/.codex/config.json',
65
- globalMcpConfig: '~/.codex/mcps.json',
64
+ globalConfig: '~/.codex/config.toml',
65
+ globalMcpConfig: '~/.codex/mcps.json', // coder-config internal registry
66
66
  projectFolder: '.codex',
67
- projectConfig: '.codex/mcps.json',
67
+ projectConfig: '.codex/mcps.json', // coder-config internal registry
68
68
  projectRules: '.codex/rules',
69
- projectInstructions: 'CODEX.md',
70
- outputFile: '.codex/mcp.json',
69
+ projectInstructions: 'AGENTS.md', // Codex uses AGENTS.md, not CODEX.md
70
+ projectInstructionsOverride: 'AGENTS.override.md',
71
+ outputFile: '~/.codex/config.toml', // MCPs go into [mcp_servers] in config.toml
71
72
  supportsEnvInterpolation: true,
73
+ configFormat: 'toml', // TOML, not JSON
72
74
  },
73
75
  };
74
76
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "coder-config",
3
- "version": "0.51.1-beta",
3
+ "version": "0.52.0",
4
4
  "description": "Configuration manager for AI coding tools - Claude Code, Gemini CLI, Codex CLI, Antigravity. Manage MCPs, rules, permissions, memory, and workstreams.",
5
5
  "author": "regression.io",
6
6
  "main": "config-loader.js",
@@ -605,7 +605,7 @@ WARNING: This link could potentially be dangerous`)){const y=window.open();if(y)
605
605
  `)},I.onerror=O=>{console.error("Terminal WebSocket error:",O),k.write(`\r
606
606
  \x1B[31m[Connection error]\x1B[0m\r
607
607
  `)},k.onData(O=>{I.readyState===WebSocket.OPEN&&I.send(JSON.stringify({type:"input",data:O}))}),k.onResize(({cols:O,rows:z})=>{I.readyState===WebSocket.OPEN&&I.send(JSON.stringify({type:"resize",cols:O,rows:z}))})},[e,r,s,n,o,d,c]);_.useEffect(()=>{const k=()=>{h.current&&m.current&&h.current.fit()};window.addEventListener("resize",k);const N=new ResizeObserver(k);return f.current&&N.observe(f.current),()=>{window.removeEventListener("resize",k),N.disconnect()}},[]),_.useCallback(k=>{g.current&&g.current.readyState===WebSocket.OPEN&&g.current.send(JSON.stringify({type:"input",data:k+"\r"}))},[]),_.useCallback(()=>{g.current&&g.current.readyState===WebSocket.OPEN&&g.current.send(JSON.stringify({type:"kill"}))},[]);const x=_.useCallback(()=>{m.current&&m.current.focus()},[]);_.useCallback(()=>{m.current&&m.current.clear()},[]);const b=_.useCallback(()=>{if(m.current){const N=m.current.buffer.active;let P="";for(let A=0;A<N.length;A++){const E=N.getLine(A);E&&(P+=E.translateToString(!0)+`
608
- `)}navigator.clipboard.writeText(P.trim()).then(()=>{const A=document.getElementById("terminal-copy-btn");A&&(A.classList.add("bg-green-600"),setTimeout(()=>A.classList.remove("bg-green-600"),500))})}},[]);return t.jsxs("div",{className:`relative ${l}`,style:{height:u},children:[t.jsxs("div",{className:"absolute top-2 right-2 z-10 flex items-center gap-2",children:[t.jsx("button",{id:"terminal-copy-btn",onClick:b,className:"px-2 py-1 text-xs bg-gray-700 hover:bg-gray-600 text-gray-300 rounded transition-colors",title:"Copy terminal output",children:"Copy"}),t.jsx("div",{className:`w-2 h-2 rounded-full ${w?"bg-green-500":"bg-red-500"}`}),t.jsx("span",{className:"text-xs text-gray-400",children:w?"Connected":"Disconnected"})]}),t.jsx("div",{ref:f,className:"w-full h-full rounded-lg overflow-hidden",style:{backgroundColor:"#1e1e1e"},onClick:x})]})}wh.sendCommand=(e,r)=>{e&&e.sendCommand&&e.sendCommand(r)};function Yj({open:e,onOpenChange:r,title:s="Terminal",description:n,cwd:o,initialCommand:c,delayedCommand:d,delayedCommandDelay:l=2e3,env:u={},onExit:f,autoCloseOnExit:m=!1,autoCloseDelay:h=1500,headerExtra:g=null}){const w=_.useRef(null),j=_.useRef(null),[S,v]=_.useState(!1),[y,x]=_.useState(!1),[b,k]=_.useState({x:null,y:null}),[N,P]=_.useState({width:1100,height:650}),[A,E]=_.useState(!1),[M,I]=_.useState(!1),O=_.useRef({x:0,y:0}),z=_.useRef({x:0,y:0,width:0,height:0});_.useEffect(()=>{e&&b.x===null&&k({x:Math.max(20,(window.innerWidth-N.width)/2),y:Math.max(20,(window.innerHeight-N.height)/2)})},[e,b.x,N.width,N.height]),_.useEffect(()=>{e&&v(!1)},[e]);const U=_.useCallback((F,re)=>{v(!0),f&&f(F,re),m&&setTimeout(()=>{r(!1)},h)},[f,m,h,r]),X=_.useCallback(F=>{if(y)return;F.preventDefault(),E(!0);const re=j.current.getBoundingClientRect();O.current={x:F.clientX-re.left,y:F.clientY-re.top}},[y]),W=_.useCallback(F=>{if(!A)return;const re=Math.max(0,Math.min(window.innerWidth-100,F.clientX-O.current.x)),ue=Math.max(0,Math.min(window.innerHeight-50,F.clientY-O.current.y));k({x:re,y:ue})},[A]),$=_.useCallback(()=>{E(!1)},[]),Y=_.useCallback(F=>{y||(F.preventDefault(),F.stopPropagation(),I(!0),z.current={x:F.clientX,y:F.clientY,width:N.width,height:N.height})},[y,N]),K=_.useCallback(F=>{if(!M)return;const re=F.clientX-z.current.x,ue=F.clientY-z.current.y;P({width:Math.max(400,z.current.width+re),height:Math.max(300,z.current.height+ue)})},[M]),L=_.useCallback(()=>{I(!1)},[]);_.useEffect(()=>{if(A)return window.addEventListener("mousemove",W),window.addEventListener("mouseup",$),()=>{window.removeEventListener("mousemove",W),window.removeEventListener("mouseup",$)}},[A,W,$]),_.useEffect(()=>{if(M)return window.addEventListener("mousemove",K),window.addEventListener("mouseup",L),()=>{window.removeEventListener("mousemove",K),window.removeEventListener("mouseup",L)}},[M,K,L]);const T=_.useCallback(()=>{x(F=>!F)},[]),B=_.useCallback(F=>{F.key!=="Escape"&&F.stopPropagation()},[]);if(!e)return null;const G=y?{left:0,top:0,width:"100vw",height:"100vh"}:{left:b.x,top:b.y,width:N.width,height:N.height};return t.jsxs("div",{ref:j,className:Ee("fixed z-50 flex flex-col","border bg-background shadow-2xl rounded-lg overflow-hidden",A&&"cursor-grabbing select-none",M&&"select-none"),style:G,onKeyDown:B,children:[t.jsx("div",{className:Ee("px-4 py-2 border-b flex-shrink-0 bg-muted/50",!y&&"cursor-grab"),onMouseDown:X,children:t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[t.jsx(jM,{className:"w-4 h-4 text-muted-foreground flex-shrink-0"}),t.jsxs("div",{className:"min-w-0",children:[t.jsx("h3",{className:"text-sm font-semibold leading-none tracking-tight truncate",children:s}),n&&t.jsx("p",{className:"text-xs text-muted-foreground mt-0.5 truncate",children:n})]})]}),t.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[g,t.jsx(se,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0",onClick:T,tabIndex:-1,children:y?t.jsx(BM,{className:"h-3.5 w-3.5"}):t.jsx(OM,{className:"h-3.5 w-3.5"})}),t.jsx(se,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0",onClick:()=>r(!1),tabIndex:-1,children:t.jsx(Un,{className:"h-3.5 w-3.5"})})]})]})}),t.jsx("div",{ref:w,className:"flex-1 p-2 min-h-0 bg-black",children:t.jsx(wh,{cwd:o,initialCommand:c,delayedCommand:d,delayedCommandDelay:l,env:u,onExit:U,height:"100%",className:"h-full"})}),!y&&t.jsx("div",{className:"absolute bottom-0 right-0 w-4 h-4 cursor-se-resize",onMouseDown:Y,children:t.jsx("svg",{className:"w-full h-full text-muted-foreground/50",viewBox:"0 0 16 16",fill:"currentColor",children:t.jsx("path",{d:"M14 14H10V10H14V14ZM14 6H12V8H14V6ZM6 14H8V12H6V14Z"})})})]})}const wc={mcps:{icon:ys,color:"text-blue-600",bgColor:"bg-blue-50",label:"MCP Servers"},settings:{icon:hn,color:"text-gray-600 dark:text-slate-400",bgColor:"bg-gray-50 dark:bg-slate-800",label:"Settings"},command:{icon:Ut,color:"text-green-600",bgColor:"bg-green-50",label:"Command"},skill:{icon:Wr,color:"text-violet-600",bgColor:"bg-violet-50",label:"Skill"},rule:{icon:Do,color:"text-purple-600",bgColor:"bg-purple-50",label:"Rule"},workflow:{icon:mC,color:"text-cyan-600",bgColor:"bg-cyan-50",label:"Workflow"},claudemd:{icon:Hr,color:"text-orange-600",bgColor:"bg-orange-50",label:"CLAUDE.md"},geminimd:{icon:Hr,color:"text-blue-600",bgColor:"bg-blue-50",label:"GEMINI.md"},env:{icon:Qu,color:"text-yellow-600",bgColor:"bg-yellow-50",label:".env"},memory:{icon:Lo,color:"text-pink-600",bgColor:"bg-pink-50",label:"Memory"},folder:{icon:Xr,color:"text-yellow-600",bgColor:"bg-yellow-50",label:"Folder"}};function bu({item:e,level:r=0,selectedPath:s,onSelect:n,onContextMenu:o,expandedFolders:c,onToggleFolder:d}){const l=wc[e.type]||wc.folder,u=l.icon,f=s===e.path,m=e.type==="folder",h=c[e.path];return t.jsxs("div",{children:[t.jsxs("div",{className:Ee("flex items-center gap-2 px-2 py-1.5 rounded-md cursor-pointer text-sm","hover:bg-gray-100 dark:hover:bg-slate-700 transition-colors",f&&"bg-blue-100 dark:bg-blue-900/30 hover:bg-blue-100 dark:hover:bg-blue-900/30"),style:{paddingLeft:`${r*16+8}px`},onClick:()=>m?d(e.path):n(e),onContextMenu:g=>o(g,e),children:[m&&t.jsx("span",{className:"w-4 h-4 flex items-center justify-center",children:h?t.jsx(xr,{className:"w-3 h-3"}):t.jsx(vs,{className:"w-3 h-3"})}),!m&&t.jsx("span",{className:"w-4"}),t.jsx(u,{className:Ee("w-4 h-4",l.color)}),t.jsx("span",{className:"flex-1 truncate",children:e.name}),e.mcpCount>0&&t.jsx(rt,{variant:"secondary",className:"text-xs px-1.5 py-0",children:e.mcpCount})]}),m&&h&&e.children&&t.jsx("div",{children:e.children.map(g=>t.jsx(bu,{item:g,level:r+1,selectedPath:s,onSelect:n,onContextMenu:o,expandedFolders:c,onToggleFolder:d},g.path))})]})}function _B({folder:e,isExpanded:r,isHome:s,isProject:n,isSubproject:o,depth:c=0,onToggle:d,onCreateFile:l,onInstallPlugin:u,onSelectItem:f,selectedPath:m,onContextMenu:h,expandedFolders:g,onToggleFolder:w,hasSubprojects:j,onAddSubproject:S,onRemoveSubproject:v,onHideSubproject:y,enabledTools:x=["claude"]}){var U,X,W,$,Y,K,L;const b=(U=e.files)==null?void 0:U.some(T=>T.name==="mcps.json"),k=(X=e.files)==null?void 0:X.some(T=>T.name==="settings.json"),N=(W=e.files)==null?void 0:W.some(T=>T.name==="CLAUDE.md"||T.name==="CLAUDE.md (root)"),P=($=e.files)==null?void 0:$.some(T=>T.name===".env"),A=()=>s?"bg-indigo-50 dark:bg-indigo-900/20 hover:bg-indigo-100 dark:hover:bg-indigo-900/30":o&&c>1?"bg-gray-50 dark:bg-slate-800 hover:bg-gray-100 dark:hover:bg-slate-700":o?"bg-amber-50 dark:bg-amber-900/20 hover:bg-amber-100 dark:hover:bg-amber-900/30":n?"bg-green-50 dark:bg-green-900/20 hover:bg-green-100 dark:hover:bg-green-900/30":"bg-gray-50 dark:bg-slate-800 hover:bg-gray-100 dark:hover:bg-slate-700",E=()=>s?"text-indigo-700 dark:text-indigo-400":o&&c>1?"text-gray-600 dark:text-slate-400":o?"text-amber-700 dark:text-amber-400":n?"text-green-700 dark:text-green-400":"text-gray-700 dark:text-slate-300",I=s?Bg:r?Xi:Xr,O=s?"Home":e.label,z=(x.includes("claude")&&((Y=e.files)==null?void 0:Y.length)||0)+(x.includes("gemini")&&((K=e.geminiFiles)==null?void 0:K.length)||0)+(x.includes("antigravity")&&((L=e.agentFiles)==null?void 0:L.length)||0);return t.jsxs("div",{className:"border-b border-gray-200 dark:border-slate-700",children:[t.jsxs("div",{className:Ee("flex items-center gap-2 py-2 cursor-pointer transition-colors",A()),style:{paddingLeft:`${12+c*16}px`,paddingRight:"24px"},onClick:d,children:[t.jsx("span",{className:"w-4 h-4 flex items-center justify-center text-gray-500",children:r?t.jsx(xr,{className:"w-4 h-4"}):t.jsx(vs,{className:"w-4 h-4"})}),t.jsx(I,{className:Ee("w-4 h-4",E())}),t.jsx("span",{className:Ee("flex-1 min-w-0 font-medium text-sm truncate",E()),children:O}),t.jsxs(Nn,{children:[t.jsx(En,{asChild:!0,onClick:T=>T.stopPropagation(),children:t.jsx(se,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0 flex-shrink-0 mr-1 hover:bg-white/50 dark:hover:bg-slate-900/50",children:t.jsx(It,{className:"w-4 h-4"})})}),t.jsxs(un,{align:"end",className:"w-48",children:[t.jsxs("div",{className:"flex items-center gap-1 px-2 py-1.5 border-b mb-1",children:[n&&j&&t.jsx(rt,{variant:"outline",className:"text-[10px] px-1 py-0 bg-green-100 dark:bg-green-900/30 text-green-700 dark:text-green-400 border-green-300 dark:border-green-700",children:"root"}),!e.exists&&!s&&t.jsx(rt,{variant:"outline",className:"text-[10px] px-1 py-0",children:"no config"}),!o&&e.exists&&z===0&&t.jsx("span",{className:"text-[10px] text-muted-foreground",children:"configured"})]}),t.jsxs(Pt,{onClick:T=>{T.stopPropagation(),l(e.dir,"mcps")},disabled:b,className:b?"opacity-50":"",children:[t.jsx(ys,{className:"w-4 h-4 mr-2"}),"mcps.json",b&&t.jsx("span",{className:"ml-auto text-xs text-muted-foreground",children:"exists"})]}),t.jsxs(Pt,{onClick:T=>{T.stopPropagation(),l(e.dir,"settings")},disabled:k,className:k?"opacity-50":"",children:[t.jsx(hn,{className:"w-4 h-4 mr-2"}),"settings.json",k&&t.jsx("span",{className:"ml-auto text-xs text-muted-foreground",children:"exists"})]}),t.jsxs(Pt,{onClick:T=>{T.stopPropagation(),l(e.dir,"env")},disabled:P,className:P?"opacity-50":"",children:[t.jsx(Qu,{className:"w-4 h-4 mr-2"}),".env",P&&t.jsx("span",{className:"ml-auto text-xs text-muted-foreground",children:"exists"})]}),t.jsx(xs,{}),t.jsxs(Pt,{onClick:T=>{T.stopPropagation(),l(e.dir,"skill")},children:[t.jsx(Wr,{className:"w-4 h-4 mr-2"}),"New Skill"]}),t.jsxs(Pt,{onClick:T=>{T.stopPropagation(),l(e.dir,"command")},children:[t.jsx(Ut,{className:"w-4 h-4 mr-2"}),"New Command"]}),t.jsxs(Pt,{onClick:T=>{T.stopPropagation(),l(e.dir,"rule")},children:[t.jsx(Do,{className:"w-4 h-4 mr-2"}),"New Rule"]}),t.jsxs(Pt,{onClick:T=>{T.stopPropagation(),l(e.dir,"workflow")},children:[t.jsx(mC,{className:"w-4 h-4 mr-2"}),"New Workflow"]}),t.jsxs(Pt,{onClick:T=>{T.stopPropagation(),l(e.dir,"memory")},children:[t.jsx(Lo,{className:"w-4 h-4 mr-2"}),"New Memory"]}),t.jsx(xs,{}),t.jsxs(Pt,{onClick:T=>{T.stopPropagation(),u(e.dir,e.name||e.dir.split("/").pop())},children:[t.jsx(Fo,{className:"w-4 h-4 mr-2"}),"Install Plugins"]}),t.jsx(xs,{}),t.jsxs(Pt,{onClick:T=>{T.stopPropagation(),l(e.dir,"claudemd")},disabled:N,className:N?"opacity-50":"",children:[t.jsx(Hr,{className:"w-4 h-4 mr-2"}),"CLAUDE.md",N&&t.jsx("span",{className:"ml-auto text-xs text-muted-foreground",children:"exists"})]}),(n||o)&&S&&t.jsxs(t.Fragment,{children:[t.jsx(xs,{}),t.jsxs(Pt,{onClick:T=>{T.stopPropagation(),S(e.dir)},children:[t.jsx(fi,{className:"w-4 h-4 mr-2"}),"Add Sub-project"]})]}),o&&y&&t.jsxs(Pt,{onClick:T=>{T.stopPropagation(),y(e.dir)},children:[t.jsx(fC,{className:"w-4 h-4 mr-2"}),"Hide"]}),e.isManual&&v&&t.jsxs(Pt,{onClick:T=>{T.stopPropagation(),v(e.dir)},className:"text-destructive focus:text-destructive",children:[t.jsx(ws,{className:"w-4 h-4 mr-2"}),"Remove"]})]})]})]}),r&&t.jsxs("div",{className:"bg-white dark:bg-slate-950 py-1",children:[x.includes("claude")&&e.files&&e.files.length>0&&t.jsxs("div",{className:"mb-1",children:[t.jsxs("div",{className:"px-4 py-1 text-[10px] font-medium text-orange-600 dark:text-orange-400 uppercase tracking-wide flex items-center gap-1",children:[t.jsx(Vt,{className:"w-3 h-3"}),"Claude Code"]}),e.files.map(T=>t.jsx(bu,{item:T,selectedPath:m,onSelect:f,onContextMenu:h,expandedFolders:g,onToggleFolder:w},T.path))]}),x.includes("gemini")&&e.geminiFiles&&e.geminiFiles.length>0&&t.jsxs("div",{className:"mb-1 border-t border-dashed border-gray-200 dark:border-slate-700 pt-1",children:[t.jsxs("div",{className:"px-4 py-1 text-[10px] font-medium text-blue-600 dark:text-blue-400 uppercase tracking-wide flex items-center gap-1",children:[t.jsx(Vt,{className:"w-3 h-3"}),"Gemini CLI"]}),e.geminiFiles.map(T=>t.jsx(bu,{item:T,selectedPath:m,onSelect:f,onContextMenu:h,expandedFolders:g,onToggleFolder:w},T.path))]}),x.includes("antigravity")&&e.agentFiles&&e.agentFiles.length>0&&t.jsxs("div",{className:"mb-1 border-t border-dashed border-gray-200 dark:border-slate-700 pt-1",children:[t.jsxs("div",{className:"px-4 py-1 text-[10px] font-medium text-purple-600 dark:text-purple-400 uppercase tracking-wide flex items-center gap-1",children:[t.jsx(Vt,{className:"w-3 h-3"}),"Antigravity"]}),e.agentFiles.map(T=>t.jsx(bu,{item:T,selectedPath:m,onSelect:f,onContextMenu:h,expandedFolders:g,onToggleFolder:w},T.path))]}),(!x.includes("claude")||!e.files||e.files.length===0)&&(!x.includes("gemini")||!e.geminiFiles||e.geminiFiles.length===0)&&(!x.includes("antigravity")||!e.agentFiles||e.agentFiles.length===0)&&t.jsx("div",{className:"px-4 py-3 text-sm text-gray-400 dark:text-slate-500 italic text-center",children:"No config files. Use + to create."})]})]})}const ft=_.forwardRef(({className:e,...r},s)=>t.jsx("textarea",{className:Ee("flex min-h-[60px] w-full rounded-md border border-input bg-transparent px-3 py-2 text-base shadow-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",e),ref:s,...r}));ft.displayName="Textarea";var _h="Tabs",[SB]=Ls(_h,[xh]),Xj=xh(),[CB,Px]=SB(_h),Jj=_.forwardRef((e,r)=>{const{__scopeTabs:s,value:n,onValueChange:o,defaultValue:c,orientation:d="horizontal",dir:l,activationMode:u="automatic",...f}=e,m=Rc(l),[h,g]=Xn({prop:n,onChange:o,defaultProp:c??"",caller:_h});return t.jsx(CB,{scope:s,baseId:cn(),value:h,onValueChange:g,orientation:d,dir:m,activationMode:u,children:t.jsx(ot.div,{dir:m,"data-orientation":d,...f,ref:r})})});Jj.displayName=_h;var Qj="TabsList",Zj=_.forwardRef((e,r)=>{const{__scopeTabs:s,loop:n=!0,...o}=e,c=Px(Qj,s),d=Xj(s);return t.jsx(Z1,{asChild:!0,...d,orientation:c.orientation,dir:c.dir,loop:n,children:t.jsx(ot.div,{role:"tablist","aria-orientation":c.orientation,...o,ref:r})})});Zj.displayName=Qj;var eN="TabsTrigger",tN=_.forwardRef((e,r)=>{const{__scopeTabs:s,value:n,disabled:o=!1,...c}=e,d=Px(eN,s),l=Xj(s),u=nN(d.baseId,n),f=iN(d.baseId,n),m=n===d.value;return t.jsx(ej,{asChild:!0,...l,focusable:!o,active:m,children:t.jsx(ot.button,{type:"button",role:"tab","aria-selected":m,"aria-controls":f,"data-state":m?"active":"inactive","data-disabled":o?"":void 0,disabled:o,id:u,...c,ref:r,onMouseDown:Fe(e.onMouseDown,h=>{!o&&h.button===0&&h.ctrlKey===!1?d.onValueChange(n):h.preventDefault()}),onKeyDown:Fe(e.onKeyDown,h=>{[" ","Enter"].includes(h.key)&&d.onValueChange(n)}),onFocus:Fe(e.onFocus,()=>{const h=d.activationMode!=="manual";!m&&!o&&h&&d.onValueChange(n)})})})});tN.displayName=eN;var rN="TabsContent",sN=_.forwardRef((e,r)=>{const{__scopeTabs:s,value:n,forceMount:o,children:c,...d}=e,l=Px(rN,s),u=nN(l.baseId,n),f=iN(l.baseId,n),m=n===l.value,h=_.useRef(m);return _.useEffect(()=>{const g=requestAnimationFrame(()=>h.current=!1);return()=>cancelAnimationFrame(g)},[]),t.jsx(Qr,{present:o||m,children:({present:g})=>t.jsx(ot.div,{"data-state":m?"active":"inactive","data-orientation":l.orientation,role:"tabpanel","aria-labelledby":u,hidden:!g,id:f,tabIndex:0,...d,ref:r,style:{...e.style,animationDuration:h.current?"0s":void 0},children:g&&c})})});sN.displayName=rN;function nN(e,r){return`${e}-trigger-${r}`}function iN(e,r){return`${e}-content-${r}`}var kB=Jj,oN=Zj,aN=tN,lN=sN;const $c=kB,ll=_.forwardRef(({className:e,...r},s)=>t.jsx(oN,{ref:s,className:Ee("inline-flex h-9 items-center justify-center rounded-lg bg-muted p-1 text-muted-foreground",e),...r}));ll.displayName=oN.displayName;const Ms=_.forwardRef(({className:e,...r},s)=>t.jsx(aN,{ref:s,className:Ee("inline-flex items-center justify-center whitespace-nowrap rounded-md px-3 py-1 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow",e),...r}));Ms.displayName=aN.displayName;const Hn=_.forwardRef(({className:e,...r},s)=>t.jsx(lN,{ref:s,className:Ee("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",e),...r}));Hn.displayName=lN.displayName;var jB=Symbol("radix.slottable");function NB(e){const r=({children:s})=>t.jsx(t.Fragment,{children:s});return r.displayName=`${e}.Slottable`,r.__radixId=jB,r}var[Sh]=Ls("Tooltip",[ol]),Ch=ol(),cN="TooltipProvider",EB=700,Fp="tooltip.open",[PB,Ax]=Sh(cN),dN=e=>{const{__scopeTooltip:r,delayDuration:s=EB,skipDelayDuration:n=300,disableHoverableContent:o=!1,children:c}=e,d=_.useRef(!0),l=_.useRef(!1),u=_.useRef(0);return _.useEffect(()=>{const f=u.current;return()=>window.clearTimeout(f)},[]),t.jsx(PB,{scope:r,isOpenDelayedRef:d,delayDuration:s,onOpen:_.useCallback(()=>{window.clearTimeout(u.current),d.current=!1},[]),onClose:_.useCallback(()=>{window.clearTimeout(u.current),u.current=window.setTimeout(()=>d.current=!0,n)},[n]),isPointerInTransitRef:l,onPointerInTransitChange:_.useCallback(f=>{l.current=f},[]),disableHoverableContent:o,children:c})};dN.displayName=cN;var _c="Tooltip",[AB,zc]=Sh(_c),uN=e=>{const{__scopeTooltip:r,children:s,open:n,defaultOpen:o,onOpenChange:c,disableHoverableContent:d,delayDuration:l}=e,u=Ax(_c,e.__scopeTooltip),f=Ch(r),[m,h]=_.useState(null),g=cn(),w=_.useRef(0),j=d??u.disableHoverableContent,S=l??u.delayDuration,v=_.useRef(!1),[y,x]=Xn({prop:n,defaultProp:o??!1,onChange:A=>{A?(u.onOpen(),document.dispatchEvent(new CustomEvent(Fp))):u.onClose(),c==null||c(A)},caller:_c}),b=_.useMemo(()=>y?v.current?"delayed-open":"instant-open":"closed",[y]),k=_.useCallback(()=>{window.clearTimeout(w.current),w.current=0,v.current=!1,x(!0)},[x]),N=_.useCallback(()=>{window.clearTimeout(w.current),w.current=0,x(!1)},[x]),P=_.useCallback(()=>{window.clearTimeout(w.current),w.current=window.setTimeout(()=>{v.current=!0,x(!0),w.current=0},S)},[S,x]);return _.useEffect(()=>()=>{w.current&&(window.clearTimeout(w.current),w.current=0)},[]),t.jsx(gx,{...f,children:t.jsx(AB,{scope:r,contentId:g,open:y,stateAttribute:b,trigger:m,onTriggerChange:h,onTriggerEnter:_.useCallback(()=>{u.isOpenDelayedRef.current?P():k()},[u.isOpenDelayedRef,P,k]),onTriggerLeave:_.useCallback(()=>{j?N():(window.clearTimeout(w.current),w.current=0)},[N,j]),onOpen:k,onClose:N,disableHoverableContent:j,children:s})})};uN.displayName=_c;var Bp="TooltipTrigger",hN=_.forwardRef((e,r)=>{const{__scopeTooltip:s,...n}=e,o=zc(Bp,s),c=Ax(Bp,s),d=Ch(s),l=_.useRef(null),u=xt(r,l,o.onTriggerChange),f=_.useRef(!1),m=_.useRef(!1),h=_.useCallback(()=>f.current=!1,[]);return _.useEffect(()=>()=>document.removeEventListener("pointerup",h),[h]),t.jsx(xx,{asChild:!0,...d,children:t.jsx(ot.button,{"aria-describedby":o.open?o.contentId:void 0,"data-state":o.stateAttribute,...n,ref:u,onPointerMove:Fe(e.onPointerMove,g=>{g.pointerType!=="touch"&&!m.current&&!c.isPointerInTransitRef.current&&(o.onTriggerEnter(),m.current=!0)}),onPointerLeave:Fe(e.onPointerLeave,()=>{o.onTriggerLeave(),m.current=!1}),onPointerDown:Fe(e.onPointerDown,()=>{o.open&&o.onClose(),f.current=!0,document.addEventListener("pointerup",h,{once:!0})}),onFocus:Fe(e.onFocus,()=>{f.current||o.onOpen()}),onBlur:Fe(e.onBlur,o.onClose),onClick:Fe(e.onClick,o.onClose)})})});hN.displayName=Bp;var Tx="TooltipPortal",[TB,RB]=Sh(Tx,{forceMount:void 0}),fN=e=>{const{__scopeTooltip:r,forceMount:s,children:n,container:o}=e,c=zc(Tx,r);return t.jsx(TB,{scope:r,forceMount:s,children:t.jsx(Qr,{present:s||c.open,children:t.jsx(Ic,{asChild:!0,container:o,children:n})})})};fN.displayName=Tx;var Qa="TooltipContent",mN=_.forwardRef((e,r)=>{const s=RB(Qa,e.__scopeTooltip),{forceMount:n=s.forceMount,side:o="top",...c}=e,d=zc(Qa,e.__scopeTooltip);return t.jsx(Qr,{present:n||d.open,children:d.disableHoverableContent?t.jsx(pN,{side:o,...c,ref:r}):t.jsx(MB,{side:o,...c,ref:r})})}),MB=_.forwardRef((e,r)=>{const s=zc(Qa,e.__scopeTooltip),n=Ax(Qa,e.__scopeTooltip),o=_.useRef(null),c=xt(r,o),[d,l]=_.useState(null),{trigger:u,onClose:f}=s,m=o.current,{onPointerInTransitChange:h}=n,g=_.useCallback(()=>{l(null),h(!1)},[h]),w=_.useCallback((j,S)=>{const v=j.currentTarget,y={x:j.clientX,y:j.clientY},x=FB(y,v.getBoundingClientRect()),b=BB(y,x),k=$B(S.getBoundingClientRect()),N=HB([...b,...k]);l(N),h(!0)},[h]);return _.useEffect(()=>()=>g(),[g]),_.useEffect(()=>{if(u&&m){const j=v=>w(v,m),S=v=>w(v,u);return u.addEventListener("pointerleave",j),m.addEventListener("pointerleave",S),()=>{u.removeEventListener("pointerleave",j),m.removeEventListener("pointerleave",S)}}},[u,m,w,g]),_.useEffect(()=>{if(d){const j=S=>{const v=S.target,y={x:S.clientX,y:S.clientY},x=(u==null?void 0:u.contains(v))||(m==null?void 0:m.contains(v)),b=!zB(y,d);x?g():b&&(g(),f())};return document.addEventListener("pointermove",j),()=>document.removeEventListener("pointermove",j)}},[u,m,d,f,g]),t.jsx(pN,{...e,ref:c})}),[IB,DB]=Sh(_c,{isInside:!1}),LB=NB("TooltipContent"),pN=_.forwardRef((e,r)=>{const{__scopeTooltip:s,children:n,"aria-label":o,onEscapeKeyDown:c,onPointerDownOutside:d,...l}=e,u=zc(Qa,s),f=Ch(s),{onClose:m}=u;return _.useEffect(()=>(document.addEventListener(Fp,m),()=>document.removeEventListener(Fp,m)),[m]),_.useEffect(()=>{if(u.trigger){const h=g=>{const w=g.target;w!=null&&w.contains(u.trigger)&&m()};return window.addEventListener("scroll",h,{capture:!0}),()=>window.removeEventListener("scroll",h,{capture:!0})}},[u.trigger,m]),t.jsx(Mc,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:c,onPointerDownOutside:d,onFocusOutside:h=>h.preventDefault(),onDismiss:m,children:t.jsxs(vx,{"data-state":u.stateAttribute,...f,...l,ref:r,style:{...l.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[t.jsx(LB,{children:n}),t.jsx(IB,{scope:s,isInside:!0,children:t.jsx(s6,{id:u.contentId,role:"tooltip",children:o||n})})]})})});mN.displayName=Qa;var gN="TooltipArrow",OB=_.forwardRef((e,r)=>{const{__scopeTooltip:s,...n}=e,o=Ch(s);return DB(gN,s).isInside?null:t.jsx(yx,{...o,...n,ref:r})});OB.displayName=gN;function FB(e,r){const s=Math.abs(r.top-e.y),n=Math.abs(r.bottom-e.y),o=Math.abs(r.right-e.x),c=Math.abs(r.left-e.x);switch(Math.min(s,n,o,c)){case c:return"left";case o:return"right";case s:return"top";case n:return"bottom";default:throw new Error("unreachable")}}function BB(e,r,s=5){const n=[];switch(r){case"top":n.push({x:e.x-s,y:e.y+s},{x:e.x+s,y:e.y+s});break;case"bottom":n.push({x:e.x-s,y:e.y-s},{x:e.x+s,y:e.y-s});break;case"left":n.push({x:e.x+s,y:e.y-s},{x:e.x+s,y:e.y+s});break;case"right":n.push({x:e.x-s,y:e.y-s},{x:e.x-s,y:e.y+s});break}return n}function $B(e){const{top:r,right:s,bottom:n,left:o}=e;return[{x:o,y:r},{x:s,y:r},{x:s,y:n},{x:o,y:n}]}function zB(e,r){const{x:s,y:n}=e;let o=!1;for(let c=0,d=r.length-1;c<r.length;d=c++){const l=r[c],u=r[d],f=l.x,m=l.y,h=u.x,g=u.y;m>n!=g>n&&s<(h-f)*(n-m)/(g-m)+f&&(o=!o)}return o}function HB(e){const r=e.slice();return r.sort((s,n)=>s.x<n.x?-1:s.x>n.x?1:s.y<n.y?-1:s.y>n.y?1:0),WB(r)}function WB(e){if(e.length<=1)return e.slice();const r=[];for(let n=0;n<e.length;n++){const o=e[n];for(;r.length>=2;){const c=r[r.length-1],d=r[r.length-2];if((c.x-d.x)*(o.y-d.y)>=(c.y-d.y)*(o.x-d.x))r.pop();else break}r.push(o)}r.pop();const s=[];for(let n=e.length-1;n>=0;n--){const o=e[n];for(;s.length>=2;){const c=s[s.length-1],d=s[s.length-2];if((c.x-d.x)*(o.y-d.y)>=(c.y-d.y)*(o.x-d.x))s.pop();else break}s.push(o)}return s.pop(),r.length===1&&s.length===1&&r[0].x===s[0].x&&r[0].y===s[0].y?r:r.concat(s)}var UB=dN,VB=uN,GB=hN,qB=fN,xN=mN;const ar=UB,Ft=VB,Bt=GB,Ot=_.forwardRef(({className:e,sideOffset:r=4,...s},n)=>t.jsx(qB,{children:t.jsx(xN,{ref:n,sideOffset:r,className:Ee("z-50 overflow-hidden rounded-md bg-primary px-3 py-1.5 text-xs text-primary-foreground animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...s})}));Ot.displayName=xN.displayName;function vN({open:e,onClose:r,onAdd:s}){const[n,o]=_.useState("");_.useEffect(()=>{e&&o("")},[e]);const c=()=>{if(!n.trim()){q.error("Please paste the MCP JSON configuration");return}let d;try{d=JSON.parse(n)}catch{q.error("Invalid JSON format");return}let l={};if(d.mcpServers&&typeof d.mcpServers=="object")l=d.mcpServers;else if(typeof d=="object"&&!Array.isArray(d)){if(Object.keys(d).includes("command")){q.error('JSON is missing the MCP name. Expected: { "name": { "command": "...", "args": [...] } }');return}l=d}if(Object.keys(l).length===0){q.error("No MCP configurations found in the JSON");return}for(const[u,f]of Object.entries(l))if(!f.command){q.error(`MCP "${u}" is missing required "command" field`);return}s(l)};return t.jsx(bt,{open:e,onOpenChange:r,children:t.jsxs(mt,{className:"bg-white dark:bg-slate-950 max-w-2xl",children:[t.jsxs(pt,{children:[t.jsx(gt,{children:"Add MCP to Config"}),t.jsx(sr,{children:"Paste the MCP JSON configuration to add to this config file."})]}),t.jsxs("div",{className:"py-4",children:[t.jsx(ft,{value:n,onChange:d=>o(d.target.value),placeholder:`{
608
+ `)}navigator.clipboard.writeText(P.trim()).then(()=>{const A=document.getElementById("terminal-copy-btn");A&&(A.classList.add("bg-green-600"),setTimeout(()=>A.classList.remove("bg-green-600"),500))})}},[]);return t.jsxs("div",{className:`relative ${l}`,style:{height:u},children:[t.jsxs("div",{className:"absolute top-2 right-2 z-10 flex items-center gap-2",children:[t.jsx("button",{id:"terminal-copy-btn",onClick:b,className:"px-2 py-1 text-xs bg-gray-700 hover:bg-gray-600 text-gray-300 rounded transition-colors",title:"Copy terminal output",children:"Copy"}),t.jsx("div",{className:`w-2 h-2 rounded-full ${w?"bg-green-500":"bg-red-500"}`}),t.jsx("span",{className:"text-xs text-gray-400",children:w?"Connected":"Disconnected"})]}),t.jsx("div",{ref:f,className:"w-full h-full rounded-lg overflow-hidden",style:{backgroundColor:"#1e1e1e"},onClick:x})]})}wh.sendCommand=(e,r)=>{e&&e.sendCommand&&e.sendCommand(r)};function Yj({open:e,onOpenChange:r,title:s="Terminal",description:n,cwd:o,initialCommand:c,delayedCommand:d,delayedCommandDelay:l=2e3,env:u={},onExit:f,autoCloseOnExit:m=!1,autoCloseDelay:h=1500,headerExtra:g=null}){const w=_.useRef(null),j=_.useRef(null),[S,v]=_.useState(!1),[y,x]=_.useState(!1),[b,k]=_.useState({x:null,y:null}),[N,P]=_.useState({width:1100,height:650}),[A,E]=_.useState(!1),[M,I]=_.useState(!1),O=_.useRef({x:0,y:0}),z=_.useRef({x:0,y:0,width:0,height:0});_.useEffect(()=>{e&&b.x===null&&k({x:Math.max(20,(window.innerWidth-N.width)/2),y:Math.max(20,(window.innerHeight-N.height)/2)})},[e,b.x,N.width,N.height]),_.useEffect(()=>{e&&v(!1)},[e]);const U=_.useCallback((F,re)=>{v(!0),f&&f(F,re),m&&setTimeout(()=>{r(!1)},h)},[f,m,h,r]),X=_.useCallback(F=>{if(y)return;F.preventDefault(),E(!0);const re=j.current.getBoundingClientRect();O.current={x:F.clientX-re.left,y:F.clientY-re.top}},[y]),W=_.useCallback(F=>{if(!A)return;const re=Math.max(0,Math.min(window.innerWidth-100,F.clientX-O.current.x)),ue=Math.max(0,Math.min(window.innerHeight-50,F.clientY-O.current.y));k({x:re,y:ue})},[A]),$=_.useCallback(()=>{E(!1)},[]),Y=_.useCallback(F=>{y||(F.preventDefault(),F.stopPropagation(),I(!0),z.current={x:F.clientX,y:F.clientY,width:N.width,height:N.height})},[y,N]),K=_.useCallback(F=>{if(!M)return;const re=F.clientX-z.current.x,ue=F.clientY-z.current.y;P({width:Math.max(400,z.current.width+re),height:Math.max(300,z.current.height+ue)})},[M]),L=_.useCallback(()=>{I(!1)},[]);_.useEffect(()=>{if(A)return window.addEventListener("mousemove",W),window.addEventListener("mouseup",$),()=>{window.removeEventListener("mousemove",W),window.removeEventListener("mouseup",$)}},[A,W,$]),_.useEffect(()=>{if(M)return window.addEventListener("mousemove",K),window.addEventListener("mouseup",L),()=>{window.removeEventListener("mousemove",K),window.removeEventListener("mouseup",L)}},[M,K,L]);const T=_.useCallback(()=>{x(F=>!F)},[]),B=_.useCallback(F=>{F.key!=="Escape"&&F.stopPropagation()},[]);if(!e)return null;const G=y?{left:0,top:0,width:"100vw",height:"100vh"}:{left:b.x,top:b.y,width:N.width,height:N.height};return t.jsxs("div",{ref:j,className:Ee("fixed z-50 flex flex-col","border bg-background shadow-2xl rounded-lg overflow-hidden",A&&"cursor-grabbing select-none",M&&"select-none"),style:G,onKeyDown:B,children:[t.jsx("div",{className:Ee("px-4 py-2 border-b flex-shrink-0 bg-muted/50",!y&&"cursor-grab"),onMouseDown:X,children:t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[t.jsx(jM,{className:"w-4 h-4 text-muted-foreground flex-shrink-0"}),t.jsxs("div",{className:"min-w-0",children:[t.jsx("h3",{className:"text-sm font-semibold leading-none tracking-tight truncate",children:s}),n&&t.jsx("p",{className:"text-xs text-muted-foreground mt-0.5 truncate",children:n})]})]}),t.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[g,t.jsx(se,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0",onClick:T,tabIndex:-1,children:y?t.jsx(BM,{className:"h-3.5 w-3.5"}):t.jsx(OM,{className:"h-3.5 w-3.5"})}),t.jsx(se,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0",onClick:()=>r(!1),tabIndex:-1,children:t.jsx(Un,{className:"h-3.5 w-3.5"})})]})]})}),t.jsx("div",{ref:w,className:"flex-1 p-2 min-h-0 bg-black",children:t.jsx(wh,{cwd:o,initialCommand:c,delayedCommand:d,delayedCommandDelay:l,env:u,onExit:U,height:"100%",className:"h-full"})}),!y&&t.jsx("div",{className:"absolute bottom-0 right-0 w-4 h-4 cursor-se-resize",onMouseDown:Y,children:t.jsx("svg",{className:"w-full h-full text-muted-foreground/50",viewBox:"0 0 16 16",fill:"currentColor",children:t.jsx("path",{d:"M14 14H10V10H14V14ZM14 6H12V8H14V6ZM6 14H8V12H6V14Z"})})})]})}const wc={mcps:{icon:ys,color:"text-blue-600",bgColor:"bg-blue-50",label:"MCP Servers"},settings:{icon:hn,color:"text-gray-600 dark:text-slate-400",bgColor:"bg-gray-50 dark:bg-slate-800",label:"Settings"},command:{icon:Ut,color:"text-green-600",bgColor:"bg-green-50",label:"Command"},skill:{icon:Wr,color:"text-violet-600",bgColor:"bg-violet-50",label:"Skill"},rule:{icon:Do,color:"text-purple-600",bgColor:"bg-purple-50",label:"Rule"},workflow:{icon:mC,color:"text-cyan-600",bgColor:"bg-cyan-50",label:"Workflow"},claudemd:{icon:Hr,color:"text-orange-600",bgColor:"bg-orange-50",label:"CLAUDE.md"},geminimd:{icon:Hr,color:"text-blue-600",bgColor:"bg-blue-50",label:"GEMINI.md"},env:{icon:Qu,color:"text-yellow-600",bgColor:"bg-yellow-50",label:".env"},memory:{icon:Lo,color:"text-pink-600",bgColor:"bg-pink-50",label:"Memory"},folder:{icon:Xr,color:"text-yellow-600",bgColor:"bg-yellow-50",label:"Folder"}};function bu({item:e,level:r=0,selectedPath:s,onSelect:n,onContextMenu:o,expandedFolders:c,onToggleFolder:d}){const l=wc[e.type]||wc.folder,u=l.icon,f=s===e.path,m=e.type==="folder",h=c[e.path];return t.jsxs("div",{children:[t.jsxs("div",{className:Ee("flex items-center gap-2 px-2 py-1.5 rounded-md cursor-pointer text-sm","hover:bg-gray-100 dark:hover:bg-slate-700 transition-colors",f&&"bg-blue-100 dark:bg-blue-900/30 hover:bg-blue-100 dark:hover:bg-blue-900/30"),style:{paddingLeft:`${r*16+8}px`},onClick:()=>m?d(e.path):n(e),onContextMenu:g=>o(g,e),children:[m&&t.jsx("span",{className:"w-4 h-4 flex items-center justify-center",children:h?t.jsx(xr,{className:"w-3 h-3"}):t.jsx(vs,{className:"w-3 h-3"})}),!m&&t.jsx("span",{className:"w-4"}),t.jsx(u,{className:Ee("w-4 h-4",l.color)}),t.jsx("span",{className:"flex-1 truncate",children:e.name}),e.mcpCount>0&&t.jsx(rt,{variant:"secondary",className:"text-xs px-1.5 py-0",children:e.mcpCount})]}),m&&h&&e.children&&t.jsx("div",{children:e.children.map(g=>t.jsx(bu,{item:g,level:r+1,selectedPath:s,onSelect:n,onContextMenu:o,expandedFolders:c,onToggleFolder:d},g.path))})]})}function _B({folder:e,isExpanded:r,isHome:s,isProject:n,isSubproject:o,depth:c=0,onToggle:d,onCreateFile:l,onInstallPlugin:u,onSelectItem:f,selectedPath:m,onContextMenu:h,expandedFolders:g,onToggleFolder:w,hasSubprojects:j,onAddSubproject:S,onRemoveSubproject:v,onHideSubproject:y,enabledTools:x=["claude"]}){var U,X,W,$,Y,K,L;const b=(U=e.files)==null?void 0:U.some(T=>T.name==="mcps.json"),k=(X=e.files)==null?void 0:X.some(T=>T.name==="settings.json"),N=(W=e.files)==null?void 0:W.some(T=>T.name==="CLAUDE.md"||T.name==="CLAUDE.md (root)"),P=($=e.files)==null?void 0:$.some(T=>T.name===".env"),A=()=>s?"bg-indigo-50 dark:bg-indigo-900/20 hover:bg-indigo-100 dark:hover:bg-indigo-900/30":o&&c>1?"bg-gray-50 dark:bg-slate-800 hover:bg-gray-100 dark:hover:bg-slate-700":o?"bg-amber-50 dark:bg-amber-900/20 hover:bg-amber-100 dark:hover:bg-amber-900/30":n?"bg-green-50 dark:bg-green-900/20 hover:bg-green-100 dark:hover:bg-green-900/30":"bg-gray-50 dark:bg-slate-800 hover:bg-gray-100 dark:hover:bg-slate-700",E=()=>s?"text-indigo-700 dark:text-indigo-400":o&&c>1?"text-gray-600 dark:text-slate-400":o?"text-amber-700 dark:text-amber-400":n?"text-green-700 dark:text-green-400":"text-gray-700 dark:text-slate-300",I=s?Bg:r?Xi:Xr,O=s?"Home":e.label,z=(x.includes("claude")&&((Y=e.files)==null?void 0:Y.length)||0)+(x.includes("gemini")&&((K=e.geminiFiles)==null?void 0:K.length)||0)+(x.includes("antigravity")&&((L=e.agentFiles)==null?void 0:L.length)||0);return t.jsxs("div",{className:"border-b border-gray-200 dark:border-slate-700",children:[t.jsxs("div",{className:Ee("flex items-center gap-2 py-2 cursor-pointer transition-colors",A()),style:{paddingLeft:`${12+c*16}px`,paddingRight:"24px"},onClick:d,children:[t.jsx("span",{className:"w-4 h-4 flex items-center justify-center text-gray-500",children:r?t.jsx(xr,{className:"w-4 h-4"}):t.jsx(vs,{className:"w-4 h-4"})}),t.jsx(I,{className:Ee("w-4 h-4",E())}),t.jsx("span",{className:Ee("flex-1 min-w-0 font-medium text-sm truncate",E()),children:O}),t.jsxs(Nn,{children:[t.jsx(En,{asChild:!0,onClick:T=>T.stopPropagation(),children:t.jsx(se,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0 flex-shrink-0 mr-1 hover:bg-white/50 dark:hover:bg-slate-900/50",children:t.jsx(It,{className:"w-4 h-4"})})}),t.jsxs(un,{align:"end",className:"w-48",children:[t.jsxs("div",{className:"flex items-center gap-1 px-2 py-1.5 border-b mb-1",children:[n&&j&&t.jsx(rt,{variant:"outline",className:"text-[10px] px-1 py-0 bg-green-100 dark:bg-green-900/30 text-green-700 dark:text-green-400 border-green-300 dark:border-green-700",children:"root"}),!e.exists&&!s&&t.jsx(rt,{variant:"outline",className:"text-[10px] px-1 py-0",children:"no config"}),!o&&e.exists&&z===0&&t.jsx("span",{className:"text-[10px] text-muted-foreground",children:"configured"})]}),t.jsxs(Pt,{onClick:T=>{T.stopPropagation(),l(e.dir,"mcps")},disabled:b,className:b?"opacity-50":"",children:[t.jsx(ys,{className:"w-4 h-4 mr-2"}),"mcps.json",b&&t.jsx("span",{className:"ml-auto text-xs text-muted-foreground",children:"exists"})]}),t.jsxs(Pt,{onClick:T=>{T.stopPropagation(),l(e.dir,"settings")},disabled:k,className:k?"opacity-50":"",children:[t.jsx(hn,{className:"w-4 h-4 mr-2"}),"settings.json",k&&t.jsx("span",{className:"ml-auto text-xs text-muted-foreground",children:"exists"})]}),t.jsxs(Pt,{onClick:T=>{T.stopPropagation(),l(e.dir,"env")},disabled:P,className:P?"opacity-50":"",children:[t.jsx(Qu,{className:"w-4 h-4 mr-2"}),".env",P&&t.jsx("span",{className:"ml-auto text-xs text-muted-foreground",children:"exists"})]}),t.jsx(xs,{}),t.jsxs(Pt,{onClick:T=>{T.stopPropagation(),l(e.dir,"skill")},children:[t.jsx(Wr,{className:"w-4 h-4 mr-2"}),"New Skill"]}),t.jsxs(Pt,{onClick:T=>{T.stopPropagation(),l(e.dir,"command")},children:[t.jsx(Ut,{className:"w-4 h-4 mr-2"}),"New Command"]}),t.jsxs(Pt,{onClick:T=>{T.stopPropagation(),l(e.dir,"rule")},children:[t.jsx(Do,{className:"w-4 h-4 mr-2"}),"New Rule"]}),t.jsxs(Pt,{onClick:T=>{T.stopPropagation(),l(e.dir,"workflow")},children:[t.jsx(mC,{className:"w-4 h-4 mr-2"}),"New Workflow"]}),t.jsxs(Pt,{onClick:T=>{T.stopPropagation(),l(e.dir,"memory")},children:[t.jsx(Lo,{className:"w-4 h-4 mr-2"}),"New Memory"]}),t.jsx(xs,{}),t.jsxs(Pt,{onClick:T=>{T.stopPropagation(),u(e.dir,e.name||e.dir.split("/").pop())},children:[t.jsx(Fo,{className:"w-4 h-4 mr-2"}),"Install Plugins"]}),t.jsx(xs,{}),t.jsxs(Pt,{onClick:T=>{T.stopPropagation(),l(e.dir,"claudemd")},disabled:N,className:N?"opacity-50":"",children:[t.jsx(Hr,{className:"w-4 h-4 mr-2"}),"CLAUDE.md",N&&t.jsx("span",{className:"ml-auto text-xs text-muted-foreground",children:"exists"})]}),(n||o)&&S&&t.jsxs(t.Fragment,{children:[t.jsx(xs,{}),t.jsxs(Pt,{onClick:T=>{T.stopPropagation(),S(e.dir)},children:[t.jsx(fi,{className:"w-4 h-4 mr-2"}),"Add Sub-project"]})]}),o&&y&&t.jsxs(Pt,{onClick:T=>{T.stopPropagation(),y(e.dir)},children:[t.jsx(fC,{className:"w-4 h-4 mr-2"}),"Hide"]}),e.isManual&&v&&t.jsxs(Pt,{onClick:T=>{T.stopPropagation(),v(e.dir)},className:"text-destructive focus:text-destructive",children:[t.jsx(ws,{className:"w-4 h-4 mr-2"}),"Remove"]})]})]})]}),r&&t.jsxs("div",{className:"bg-white dark:bg-slate-950 py-1",children:[x.includes("claude")&&e.files&&e.files.length>0&&t.jsxs("div",{className:"mb-1",children:[t.jsxs("div",{className:"px-4 py-1 text-[10px] font-medium text-orange-600 dark:text-orange-400 uppercase tracking-wide flex items-center gap-1",children:[t.jsx(Vt,{className:"w-3 h-3"}),"Claude Code"]}),e.files.map(T=>t.jsx(bu,{item:T,selectedPath:m,onSelect:f,onContextMenu:h,expandedFolders:g,onToggleFolder:w},T.path))]}),x.includes("gemini")&&e.geminiFiles&&e.geminiFiles.length>0&&t.jsxs("div",{className:"mb-1 border-t border-dashed border-gray-200 dark:border-slate-700 pt-1",children:[t.jsxs("div",{className:"px-4 py-1 text-[10px] font-medium text-blue-600 dark:text-blue-400 uppercase tracking-wide flex items-center gap-1",children:[t.jsx(Vt,{className:"w-3 h-3"}),"Gemini CLI"]}),e.geminiFiles.map(T=>t.jsx(bu,{item:T,selectedPath:m,onSelect:f,onContextMenu:h,expandedFolders:g,onToggleFolder:w},T.path))]}),x.includes("antigravity")&&e.agentFiles&&e.agentFiles.length>0&&t.jsxs("div",{className:"mb-1 border-t border-dashed border-gray-200 dark:border-slate-700 pt-1",children:[t.jsxs("div",{className:"px-4 py-1 text-[10px] font-medium text-purple-600 dark:text-purple-400 uppercase tracking-wide flex items-center gap-1",children:[t.jsx(Vt,{className:"w-3 h-3"}),"Antigravity"]}),e.agentFiles.map(T=>t.jsx(bu,{item:T,selectedPath:m,onSelect:f,onContextMenu:h,expandedFolders:g,onToggleFolder:w},T.path))]}),(!x.includes("claude")||!e.files||e.files.length===0)&&(!x.includes("gemini")||!e.geminiFiles||e.geminiFiles.length===0)&&(!x.includes("antigravity")||!e.agentFiles||e.agentFiles.length===0)&&t.jsx("div",{className:"px-4 py-3 text-sm text-gray-400 dark:text-slate-500 italic text-center",children:"No config files. Use + to create."})]})]})}const ft=_.forwardRef(({className:e,...r},s)=>t.jsx("textarea",{className:Ee("flex min-h-[60px] w-full rounded-md border border-input bg-transparent px-3 py-2 text-base shadow-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",e),ref:s,...r}));ft.displayName="Textarea";var _h="Tabs",[SB]=Ls(_h,[xh]),Xj=xh(),[CB,Px]=SB(_h),Jj=_.forwardRef((e,r)=>{const{__scopeTabs:s,value:n,onValueChange:o,defaultValue:c,orientation:d="horizontal",dir:l,activationMode:u="automatic",...f}=e,m=Rc(l),[h,g]=Xn({prop:n,onChange:o,defaultProp:c??"",caller:_h});return t.jsx(CB,{scope:s,baseId:cn(),value:h,onValueChange:g,orientation:d,dir:m,activationMode:u,children:t.jsx(ot.div,{dir:m,"data-orientation":d,...f,ref:r})})});Jj.displayName=_h;var Qj="TabsList",Zj=_.forwardRef((e,r)=>{const{__scopeTabs:s,loop:n=!0,...o}=e,c=Px(Qj,s),d=Xj(s);return t.jsx(Z1,{asChild:!0,...d,orientation:c.orientation,dir:c.dir,loop:n,children:t.jsx(ot.div,{role:"tablist","aria-orientation":c.orientation,...o,ref:r})})});Zj.displayName=Qj;var eN="TabsTrigger",tN=_.forwardRef((e,r)=>{const{__scopeTabs:s,value:n,disabled:o=!1,...c}=e,d=Px(eN,s),l=Xj(s),u=nN(d.baseId,n),f=iN(d.baseId,n),m=n===d.value;return t.jsx(ej,{asChild:!0,...l,focusable:!o,active:m,children:t.jsx(ot.button,{type:"button",role:"tab","aria-selected":m,"aria-controls":f,"data-state":m?"active":"inactive","data-disabled":o?"":void 0,disabled:o,id:u,...c,ref:r,onMouseDown:Fe(e.onMouseDown,h=>{!o&&h.button===0&&h.ctrlKey===!1?d.onValueChange(n):h.preventDefault()}),onKeyDown:Fe(e.onKeyDown,h=>{[" ","Enter"].includes(h.key)&&d.onValueChange(n)}),onFocus:Fe(e.onFocus,()=>{const h=d.activationMode!=="manual";!m&&!o&&h&&d.onValueChange(n)})})})});tN.displayName=eN;var rN="TabsContent",sN=_.forwardRef((e,r)=>{const{__scopeTabs:s,value:n,forceMount:o,children:c,...d}=e,l=Px(rN,s),u=nN(l.baseId,n),f=iN(l.baseId,n),m=n===l.value,h=_.useRef(m);return _.useEffect(()=>{const g=requestAnimationFrame(()=>h.current=!1);return()=>cancelAnimationFrame(g)},[]),t.jsx(Qr,{present:o||m,children:({present:g})=>t.jsx(ot.div,{"data-state":m?"active":"inactive","data-orientation":l.orientation,role:"tabpanel","aria-labelledby":u,hidden:!g,id:f,tabIndex:0,...d,ref:r,style:{...e.style,animationDuration:h.current?"0s":void 0},children:g&&c})})});sN.displayName=rN;function nN(e,r){return`${e}-trigger-${r}`}function iN(e,r){return`${e}-content-${r}`}var kB=Jj,oN=Zj,aN=tN,lN=sN;const $c=kB,ll=_.forwardRef(({className:e,...r},s)=>t.jsx(oN,{ref:s,className:Ee("inline-flex h-9 items-center justify-center rounded-lg bg-muted p-1 text-muted-foreground",e),...r}));ll.displayName=oN.displayName;const Ms=_.forwardRef(({className:e,...r},s)=>t.jsx(aN,{ref:s,className:Ee("inline-flex items-center justify-center whitespace-nowrap rounded-md px-3 py-1 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow",e),...r}));Ms.displayName=aN.displayName;const Hn=_.forwardRef(({className:e,...r},s)=>t.jsx(lN,{ref:s,className:Ee("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",e),...r}));Hn.displayName=lN.displayName;var jB=Symbol("radix.slottable");function NB(e){const r=({children:s})=>t.jsx(t.Fragment,{children:s});return r.displayName=`${e}.Slottable`,r.__radixId=jB,r}var[Sh]=Ls("Tooltip",[ol]),Ch=ol(),cN="TooltipProvider",EB=700,Fp="tooltip.open",[PB,Ax]=Sh(cN),dN=e=>{const{__scopeTooltip:r,delayDuration:s=EB,skipDelayDuration:n=300,disableHoverableContent:o=!1,children:c}=e,d=_.useRef(!0),l=_.useRef(!1),u=_.useRef(0);return _.useEffect(()=>{const f=u.current;return()=>window.clearTimeout(f)},[]),t.jsx(PB,{scope:r,isOpenDelayedRef:d,delayDuration:s,onOpen:_.useCallback(()=>{window.clearTimeout(u.current),d.current=!1},[]),onClose:_.useCallback(()=>{window.clearTimeout(u.current),u.current=window.setTimeout(()=>d.current=!0,n)},[n]),isPointerInTransitRef:l,onPointerInTransitChange:_.useCallback(f=>{l.current=f},[]),disableHoverableContent:o,children:c})};dN.displayName=cN;var _c="Tooltip",[AB,zc]=Sh(_c),uN=e=>{const{__scopeTooltip:r,children:s,open:n,defaultOpen:o,onOpenChange:c,disableHoverableContent:d,delayDuration:l}=e,u=Ax(_c,e.__scopeTooltip),f=Ch(r),[m,h]=_.useState(null),g=cn(),w=_.useRef(0),j=d??u.disableHoverableContent,S=l??u.delayDuration,v=_.useRef(!1),[y,x]=Xn({prop:n,defaultProp:o??!1,onChange:A=>{A?(u.onOpen(),document.dispatchEvent(new CustomEvent(Fp))):u.onClose(),c==null||c(A)},caller:_c}),b=_.useMemo(()=>y?v.current?"delayed-open":"instant-open":"closed",[y]),k=_.useCallback(()=>{window.clearTimeout(w.current),w.current=0,v.current=!1,x(!0)},[x]),N=_.useCallback(()=>{window.clearTimeout(w.current),w.current=0,x(!1)},[x]),P=_.useCallback(()=>{window.clearTimeout(w.current),w.current=window.setTimeout(()=>{v.current=!0,x(!0),w.current=0},S)},[S,x]);return _.useEffect(()=>()=>{w.current&&(window.clearTimeout(w.current),w.current=0)},[]),t.jsx(gx,{...f,children:t.jsx(AB,{scope:r,contentId:g,open:y,stateAttribute:b,trigger:m,onTriggerChange:h,onTriggerEnter:_.useCallback(()=>{u.isOpenDelayedRef.current?P():k()},[u.isOpenDelayedRef,P,k]),onTriggerLeave:_.useCallback(()=>{j?N():(window.clearTimeout(w.current),w.current=0)},[N,j]),onOpen:k,onClose:N,disableHoverableContent:j,children:s})})};uN.displayName=_c;var Bp="TooltipTrigger",hN=_.forwardRef((e,r)=>{const{__scopeTooltip:s,...n}=e,o=zc(Bp,s),c=Ax(Bp,s),d=Ch(s),l=_.useRef(null),u=xt(r,l,o.onTriggerChange),f=_.useRef(!1),m=_.useRef(!1),h=_.useCallback(()=>f.current=!1,[]);return _.useEffect(()=>()=>document.removeEventListener("pointerup",h),[h]),t.jsx(xx,{asChild:!0,...d,children:t.jsx(ot.button,{"aria-describedby":o.open?o.contentId:void 0,"data-state":o.stateAttribute,...n,ref:u,onPointerMove:Fe(e.onPointerMove,g=>{g.pointerType!=="touch"&&!m.current&&!c.isPointerInTransitRef.current&&(o.onTriggerEnter(),m.current=!0)}),onPointerLeave:Fe(e.onPointerLeave,()=>{o.onTriggerLeave(),m.current=!1}),onPointerDown:Fe(e.onPointerDown,()=>{o.open&&o.onClose(),f.current=!0,document.addEventListener("pointerup",h,{once:!0})}),onFocus:Fe(e.onFocus,()=>{f.current||o.onOpen()}),onBlur:Fe(e.onBlur,o.onClose),onClick:Fe(e.onClick,o.onClose)})})});hN.displayName=Bp;var Tx="TooltipPortal",[TB,RB]=Sh(Tx,{forceMount:void 0}),fN=e=>{const{__scopeTooltip:r,forceMount:s,children:n,container:o}=e,c=zc(Tx,r);return t.jsx(TB,{scope:r,forceMount:s,children:t.jsx(Qr,{present:s||c.open,children:t.jsx(Ic,{asChild:!0,container:o,children:n})})})};fN.displayName=Tx;var Qa="TooltipContent",mN=_.forwardRef((e,r)=>{const s=RB(Qa,e.__scopeTooltip),{forceMount:n=s.forceMount,side:o="top",...c}=e,d=zc(Qa,e.__scopeTooltip);return t.jsx(Qr,{present:n||d.open,children:d.disableHoverableContent?t.jsx(pN,{side:o,...c,ref:r}):t.jsx(MB,{side:o,...c,ref:r})})}),MB=_.forwardRef((e,r)=>{const s=zc(Qa,e.__scopeTooltip),n=Ax(Qa,e.__scopeTooltip),o=_.useRef(null),c=xt(r,o),[d,l]=_.useState(null),{trigger:u,onClose:f}=s,m=o.current,{onPointerInTransitChange:h}=n,g=_.useCallback(()=>{l(null),h(!1)},[h]),w=_.useCallback((j,S)=>{const v=j.currentTarget,y={x:j.clientX,y:j.clientY},x=FB(y,v.getBoundingClientRect()),b=BB(y,x),k=$B(S.getBoundingClientRect()),N=HB([...b,...k]);l(N),h(!0)},[h]);return _.useEffect(()=>()=>g(),[g]),_.useEffect(()=>{if(u&&m){const j=v=>w(v,m),S=v=>w(v,u);return u.addEventListener("pointerleave",j),m.addEventListener("pointerleave",S),()=>{u.removeEventListener("pointerleave",j),m.removeEventListener("pointerleave",S)}}},[u,m,w,g]),_.useEffect(()=>{if(d){const j=S=>{const v=S.target,y={x:S.clientX,y:S.clientY},x=(u==null?void 0:u.contains(v))||(m==null?void 0:m.contains(v)),b=!zB(y,d);x?g():b&&(g(),f())};return document.addEventListener("pointermove",j),()=>document.removeEventListener("pointermove",j)}},[u,m,d,f,g]),t.jsx(pN,{...e,ref:c})}),[IB,DB]=Sh(_c,{isInside:!1}),LB=NB("TooltipContent"),pN=_.forwardRef((e,r)=>{const{__scopeTooltip:s,children:n,"aria-label":o,onEscapeKeyDown:c,onPointerDownOutside:d,...l}=e,u=zc(Qa,s),f=Ch(s),{onClose:m}=u;return _.useEffect(()=>(document.addEventListener(Fp,m),()=>document.removeEventListener(Fp,m)),[m]),_.useEffect(()=>{if(u.trigger){const h=g=>{const w=g.target;w!=null&&w.contains(u.trigger)&&m()};return window.addEventListener("scroll",h,{capture:!0}),()=>window.removeEventListener("scroll",h,{capture:!0})}},[u.trigger,m]),t.jsx(Mc,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:c,onPointerDownOutside:d,onFocusOutside:h=>h.preventDefault(),onDismiss:m,children:t.jsxs(vx,{"data-state":u.stateAttribute,...f,...l,ref:r,style:{...l.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[t.jsx(LB,{children:n}),t.jsx(IB,{scope:s,isInside:!0,children:t.jsx(s6,{id:u.contentId,role:"tooltip",children:o||n})})]})})});mN.displayName=Qa;var gN="TooltipArrow",OB=_.forwardRef((e,r)=>{const{__scopeTooltip:s,...n}=e,o=Ch(s);return DB(gN,s).isInside?null:t.jsx(yx,{...o,...n,ref:r})});OB.displayName=gN;function FB(e,r){const s=Math.abs(r.top-e.y),n=Math.abs(r.bottom-e.y),o=Math.abs(r.right-e.x),c=Math.abs(r.left-e.x);switch(Math.min(s,n,o,c)){case c:return"left";case o:return"right";case s:return"top";case n:return"bottom";default:throw new Error("unreachable")}}function BB(e,r,s=5){const n=[];switch(r){case"top":n.push({x:e.x-s,y:e.y+s},{x:e.x+s,y:e.y+s});break;case"bottom":n.push({x:e.x-s,y:e.y-s},{x:e.x+s,y:e.y-s});break;case"left":n.push({x:e.x+s,y:e.y-s},{x:e.x+s,y:e.y+s});break;case"right":n.push({x:e.x-s,y:e.y-s},{x:e.x-s,y:e.y+s});break}return n}function $B(e){const{top:r,right:s,bottom:n,left:o}=e;return[{x:o,y:r},{x:s,y:r},{x:s,y:n},{x:o,y:n}]}function zB(e,r){const{x:s,y:n}=e;let o=!1;for(let c=0,d=r.length-1;c<r.length;d=c++){const l=r[c],u=r[d],f=l.x,m=l.y,h=u.x,g=u.y;m>n!=g>n&&s<(h-f)*(n-m)/(g-m)+f&&(o=!o)}return o}function HB(e){const r=e.slice();return r.sort((s,n)=>s.x<n.x?-1:s.x>n.x?1:s.y<n.y?-1:s.y>n.y?1:0),WB(r)}function WB(e){if(e.length<=1)return e.slice();const r=[];for(let n=0;n<e.length;n++){const o=e[n];for(;r.length>=2;){const c=r[r.length-1],d=r[r.length-2];if((c.x-d.x)*(o.y-d.y)>=(c.y-d.y)*(o.x-d.x))r.pop();else break}r.push(o)}r.pop();const s=[];for(let n=e.length-1;n>=0;n--){const o=e[n];for(;s.length>=2;){const c=s[s.length-1],d=s[s.length-2];if((c.x-d.x)*(o.y-d.y)>=(c.y-d.y)*(o.x-d.x))s.pop();else break}s.push(o)}return s.pop(),r.length===1&&s.length===1&&r[0].x===s[0].x&&r[0].y===s[0].y?r:r.concat(s)}var UB=dN,VB=uN,GB=hN,qB=fN,xN=mN;const ar=UB,Ft=VB,Bt=GB,Ot=_.forwardRef(({className:e,sideOffset:r=4,...s},n)=>t.jsx(qB,{children:t.jsx(xN,{ref:n,sideOffset:r,className:Ee("z-50 overflow-hidden rounded-md bg-primary px-3 py-1.5 text-xs text-primary-foreground animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...s})}));Ot.displayName=xN.displayName;function vN({open:e,onClose:r,onAdd:s}){const[n,o]=_.useState("");_.useEffect(()=>{e&&o("")},[e]);const c=()=>{if(!n.trim()){q.error("Please paste the MCP JSON configuration");return}let d;try{d=JSON.parse(n)}catch{q.error("Invalid JSON format");return}let l={};if(d.mcpServers&&typeof d.mcpServers=="object")l=d.mcpServers;else if(typeof d=="object"&&!Array.isArray(d)){if(Object.keys(d).includes("command")){q.error('JSON is missing the MCP name. Expected: { "name": { "command": "...", "args": [...] } }');return}l=d}if(Object.keys(l).length===0){q.error("No MCP configurations found in the JSON");return}for(const[u,f]of Object.entries(l))if(!f.command&&!f.url){q.error(`MCP "${u}" is missing required "command" (stdio) or "url" (http/sse/ws) field`);return}s(l)};return t.jsx(bt,{open:e,onOpenChange:r,children:t.jsxs(mt,{className:"bg-white dark:bg-slate-950 max-w-2xl",children:[t.jsxs(pt,{children:[t.jsx(gt,{children:"Add MCP to Config"}),t.jsx(sr,{children:"Paste the MCP JSON configuration to add to this config file."})]}),t.jsxs("div",{className:"py-4",children:[t.jsx(ft,{value:n,onChange:d=>o(d.target.value),placeholder:`{
609
609
  "my-mcp": {
610
610
  "command": "npx",
611
611
  "args": ["-y", "@example/mcp-server"],
@@ -613,7 +613,7 @@ WARNING: This link could potentially be dangerous`)){const y=window.open();if(y)
613
613
  "API_KEY": "\${API_KEY}"
614
614
  }
615
615
  }
616
- }`,className:"font-mono text-sm bg-gray-50 dark:bg-slate-800",rows:12}),t.jsxs("p",{className:"text-xs text-gray-500 dark:text-slate-400 mt-2",children:["Accepts formats: ",t.jsx("code",{className:"bg-gray-100 dark:bg-slate-700 px-1 rounded",children:'{ "name": { "command": "...", "args": [...] } }'})," or ",t.jsx("code",{className:"bg-gray-100 dark:bg-slate-700 px-1 rounded",children:'{ "mcpServers": { ... } }'})]})]}),t.jsxs(jt,{children:[t.jsx(se,{variant:"ghost",onClick:()=>r(!1),children:"Cancel"}),t.jsxs(se,{onClick:c,className:"bg-blue-600 hover:bg-blue-700 text-white",children:[t.jsx(It,{className:"w-4 h-4 mr-2"}),"Add MCP"]})]})]})})}function KB({content:e,parsed:r,onSave:s,registry:n,configDir:o}){const[c,d]=_.useState(r||{include:[],exclude:[],mcpServers:{}}),[l,u]=_.useState("rich"),[f,m]=_.useState(JSON.stringify(r||{},null,2)),[h,g]=_.useState(!1),[w,j]=_.useState({open:!1,json:""}),[S,v]=_.useState({open:!1,name:"",json:""}),[y,x]=_.useState([]),[b,k]=_.useState(!1),[N,P]=_.useState(!1);_.useEffect(()=>{d(r||{include:[],exclude:[],mcpServers:{}}),m(JSON.stringify(r||{},null,2))},[r]),_.useEffect(()=>{o?fe.getInheritedMcps(o).then($=>{x($.inherited||[]),k($.needsApply||!1)}).catch(()=>{x([]),k(!1)}):(x([]),k(!1))},[o,r]);const A=async $=>{g(!0);try{await s(JSON.stringify($,null,2))}catch(Y){q.error("Failed to save: "+Y.message)}finally{g(!1)}},E=$=>{var L;const Y=(L=c.include)!=null&&L.includes($)?c.include.filter(T=>T!==$):[...c.include||[],$],K={...c,include:Y};d(K),m(JSON.stringify(K,null,2)),A(K)},M=$=>{const Y=c.exclude||[],K=Y.includes($),L=K?Y.filter(B=>B!==$):[...Y,$],T=L.length>0?{...c,exclude:L}:{...c};L.length===0&&delete T.exclude,d(T),m(JSON.stringify(T,null,2)),A(T),q.success(K?`Unblocked ${$}`:`Blocked ${$}`)},I=()=>{try{const $=JSON.parse(f);d($),A($)}catch{q.error("Invalid JSON")}},O=$=>{var K;if((K=c.exclude)==null?void 0:K.includes($)){const L=(c.exclude||[]).filter(B=>B!==$),T=L.length>0?{...c,exclude:L}:{...c};L.length===0&&delete T.exclude,d(T),m(JSON.stringify(T,null,2)),A(T),q.success(`Enabled ${$}`)}else{const L=[...c.exclude||[],$],T={...c,exclude:L};d(T),m(JSON.stringify(T,null,2)),A(T),q.success(`Disabled ${$}`)}},z=()=>{try{const $=JSON.parse(S.json),Y={...c.mcpServers,[S.name]:$},K={...c,mcpServers:Y};d(K),m(JSON.stringify(K,null,2)),A(K),q.success(`Updated ${S.name}`),v({open:!1,name:"",json:""})}catch{q.error("Invalid JSON")}},U=$=>{const Y={...c.mcpServers||{},...$},K={...c,mcpServers:Y};d(K),m(JSON.stringify(K,null,2)),A(K);const L=Object.keys($).length;q.success(`Added ${L} MCP${L>1?"s":""}`),j({open:!1,json:""})},X=n!=null&&n.mcpServers?Object.keys(n.mcpServers):[],W=async()=>{if(o){P(!0);try{const $=await fe.applyCascade(o);if($.success){const Y=$.applied>1?`Applied to ${$.applied} projects`:"Generated .mcp.json";q.success(Y),k(!1)}else $.applied===0&&$.skipped>0?(q.info("No changes needed"),k(!1)):q.error($.error||"Failed to apply")}catch($){q.error("Failed to apply: "+$.message)}finally{P(!1)}}};return t.jsxs("div",{className:"h-full flex flex-col",children:[t.jsxs("div",{className:"flex items-center justify-between p-3 border-b bg-gray-50 dark:bg-slate-800",children:[t.jsx($c,{value:l,onValueChange:u,children:t.jsxs(ll,{className:"h-8",children:[t.jsx(Ms,{value:"rich",className:"text-xs px-3",children:"Rich Editor"}),t.jsx(Ms,{value:"json",className:"text-xs px-3",children:"JSON"})]})}),t.jsxs("div",{className:"flex gap-2 items-center",children:[h&&t.jsx(rt,{variant:"outline",className:"text-xs text-blue-600",children:"Saving..."}),t.jsxs(se,{size:"sm",variant:"outline",onClick:()=>j({open:!0,json:""}),children:[t.jsx(It,{className:"w-4 h-4 mr-1"}),"Add MCP"]}),l==="json"&&t.jsxs(se,{size:"sm",onClick:I,disabled:h,children:[t.jsx(bs,{className:"w-4 h-4 mr-1"}),"Apply JSON"]})]})]}),b&&t.jsxs("div",{className:"mx-3 mt-3 p-3 rounded-lg bg-amber-50 dark:bg-amber-950/30 border border-amber-200 dark:border-amber-800 flex items-center justify-between",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(Is,{className:"w-4 h-4 text-amber-600"}),t.jsxs("span",{className:"text-sm text-amber-800 dark:text-amber-200",children:["No ",t.jsx("code",{className:"bg-amber-100 dark:bg-amber-900 px-1 rounded",children:".mcp.json"})," generated yet. Apply to enable MCPs."]})]}),t.jsx(se,{size:"sm",variant:"outline",onClick:W,disabled:N,className:"border-amber-300 dark:border-amber-700 text-amber-700 dark:text-amber-300 hover:bg-amber-100 dark:hover:bg-amber-900",children:N?t.jsx("span",{className:"animate-pulse",children:"Applying..."}):t.jsxs(t.Fragment,{children:[t.jsx(Io,{className:"w-3 h-3 mr-1"}),"Apply"]})})]}),t.jsx(Xs,{className:"flex-1",children:l==="rich"?t.jsx(ar,{children:t.jsxs("div",{className:"p-4 space-y-2",children:[Object.entries(c.mcpServers||{}).map(([$,Y])=>{var L,T;const K=(L=c.exclude)==null?void 0:L.includes($);return t.jsxs("div",{className:`p-2 rounded border group ${K?"bg-gray-50 dark:bg-slate-900 border-gray-200 dark:border-slate-700":"bg-white dark:bg-slate-950"}`,children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(ys,{className:`w-4 h-4 ${K?"text-gray-400":"text-green-500"}`}),t.jsx("span",{className:`text-sm font-medium ${K?"text-gray-400 line-through":""}`,children:$}),t.jsx(rt,{variant:"outline",className:"text-xs",children:"inline"})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(se,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0 opacity-0 group-hover:opacity-100 text-gray-500 hover:text-gray-700 hover:bg-gray-100 dark:hover:bg-slate-800",onClick:()=>{v({open:!0,name:$,json:JSON.stringify(Y,null,2)})},children:t.jsx(sl,{className:"w-3.5 h-3.5"})}),t.jsx(se,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0 opacity-0 group-hover:opacity-100 text-red-500 hover:text-red-700 hover:bg-red-50 dark:hover:bg-red-950",onClick:()=>{var re;const{[$]:B,...G}=c.mcpServers,F={...c,mcpServers:G};(re=F.exclude)!=null&&re.includes($)&&(F.exclude=F.exclude.filter(ue=>ue!==$),F.exclude.length===0&&delete F.exclude),d(F),m(JSON.stringify(F,null,2)),A(F),q.success(`Removed ${$}`)},children:t.jsx(ws,{className:"w-3.5 h-3.5"})}),t.jsx(_t,{checked:!K,onCheckedChange:()=>O($)})]})]}),t.jsxs("p",{className:`text-xs mt-1 font-mono ${K?"text-gray-400":"text-gray-500 dark:text-slate-400"}`,children:[Y.command," ",(T=Y.args)==null?void 0:T.join(" ")]})]},`inline-${$}`)}),y.map($=>{var K;const Y=(K=c.exclude)==null?void 0:K.includes($.name);return t.jsxs(Ft,{children:[t.jsx(Bt,{asChild:!0,children:t.jsxs("div",{className:`flex items-center justify-between p-2 rounded border ${Y?"bg-red-50 dark:bg-red-950/20 border-red-200 dark:border-red-800":"bg-gray-50 dark:bg-slate-900 border-gray-200 dark:border-slate-700"}`,children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(ys,{className:`w-4 h-4 ${Y?"text-red-400":"text-gray-400"}`}),t.jsx("span",{className:`text-sm ${Y?"text-red-500 line-through":"text-gray-500 dark:text-slate-400"}`,children:$.name}),t.jsxs(rt,{variant:"outline",className:"text-[10px] text-gray-400 border-gray-300 dark:border-slate-600",children:["from ",$.source]})]}),t.jsx(_t,{checked:!Y,onCheckedChange:()=>{Y||q.warning(`Blocking "${$.name}" inherited from ${$.source}`),M($.name)},className:"data-[state=checked]:bg-gray-400 dark:data-[state=checked]:bg-slate-600"})]})}),t.jsxs(Ot,{children:[t.jsxs("p",{children:["Inherited from ",t.jsx("strong",{children:$.source})]}),t.jsx("p",{className:"text-xs text-gray-400",children:Y?"Blocked at this level":"Toggle off to block"})]})]},`inherited-${$.name}`)}),X.map($=>{var L,T;const Y=y.some(B=>B.name===$),K=(L=c.mcpServers)==null?void 0:L[$];return Y||K?null:t.jsxs("div",{className:"flex items-center justify-between p-2 rounded border bg-white dark:bg-slate-950",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(ys,{className:"w-4 h-4 text-blue-500"}),t.jsx("span",{className:"text-sm",children:$})]}),t.jsx(_t,{checked:(T=c.include)==null?void 0:T.includes($),onCheckedChange:()=>E($)})]},$)}),X.length===0&&y.length===0&&Object.keys(c.mcpServers||{}).length===0&&t.jsx("p",{className:"text-sm text-gray-500 dark:text-slate-400",children:'No MCPs configured. Click "Add MCP" to add one.'})]})}):t.jsx(ft,{className:"w-full h-full min-h-[400px] font-mono text-sm border-0 rounded-none resize-none",value:f,onChange:$=>m($.target.value)})}),t.jsx(vN,{open:w.open,onClose:$=>j({...w,open:$}),onAdd:U}),t.jsx(bt,{open:S.open,onOpenChange:$=>v({...S,open:$}),children:t.jsxs(mt,{className:"bg-white dark:bg-slate-950 max-w-2xl",children:[t.jsxs(pt,{children:[t.jsxs(gt,{children:["Edit MCP: ",S.name]}),t.jsx(sr,{children:"Modify the MCP configuration JSON."})]}),t.jsx("div",{className:"py-4",children:t.jsx(ft,{value:S.json,onChange:$=>v({...S,json:$.target.value}),className:"font-mono text-sm bg-gray-50 dark:bg-slate-800",rows:12})}),t.jsxs(jt,{children:[t.jsx(se,{variant:"ghost",onClick:()=>v({open:!1,name:"",json:""}),children:"Cancel"}),t.jsxs(se,{onClick:z,className:"bg-blue-600 hover:bg-blue-700 text-white",children:[t.jsx(bs,{className:"w-4 h-4 mr-2"}),"Save Changes"]})]})]})})]})}function Ew({content:e,onSave:r,fileType:s}){const[n,o]=_.useState(e||""),[c,d]=_.useState(!1),l=_.useRef(null),u=_.useRef(null),f=_.useRef(e);_.useEffect(()=>{o(e||""),e!==f.current&&(f.current=e,setTimeout(()=>{if(u.current){u.current.focus();const w=(e||"").length;u.current.setSelectionRange(w,w)}},100))},[e]);const m=_.useCallback(w=>{l.current&&clearTimeout(l.current),l.current=setTimeout(async()=>{d(!0);try{await r(w)}finally{d(!1)}},2500)},[r]),h=w=>{const j=w.target.value;o(j),m(j)},g=wc[s]||wc.claudemd;return t.jsxs("div",{className:"h-full flex flex-col",children:[t.jsxs("div",{className:"flex items-center justify-between p-3 border-b bg-gray-50 dark:bg-slate-800",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(g.icon,{className:Ee("w-4 h-4",g.color)}),t.jsx("span",{className:"text-sm font-medium",children:g.label})]}),t.jsx("div",{className:"flex gap-2",children:c&&t.jsxs(rt,{variant:"outline",className:"text-xs text-blue-600",children:[t.jsx(Mr,{className:"w-3 h-3 mr-1 animate-spin"}),"Saving..."]})})]}),t.jsx(ft,{ref:u,className:"flex-1 w-full font-mono text-sm border-0 rounded-none resize-none p-4",value:n,onChange:h,placeholder:`Enter ${g.label.toLowerCase()} content...`})]})}var YB=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],XB=YB.reduce((e,r)=>{const s=eh(`Primitive.${r}`),n=_.forwardRef((o,c)=>{const{asChild:d,...l}=o,u=d?s:r;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),t.jsx(u,{...l,ref:c})});return n.displayName=`Primitive.${r}`,{...e,[r]:n}},{}),JB="Label",yN=_.forwardRef((e,r)=>t.jsx(XB.label,{...e,ref:r,onMouseDown:s=>{var o;s.target.closest("button, input, select, textarea")||((o=e.onMouseDown)==null||o.call(e,s),!s.defaultPrevented&&s.detail>1&&s.preventDefault())}}));yN.displayName=JB;var bN=yN;const QB=th("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),Ze=_.forwardRef(({className:e,...r},s)=>t.jsx(bN,{ref:s,className:Ee(QB(),e),...r}));Ze.displayName=bN.displayName;const ZB=th("relative w-full rounded-lg border px-4 py-3 text-sm [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4 [&>svg]:text-foreground [&>svg~*]:pl-7",{variants:{variant:{default:"bg-background text-foreground",destructive:"border-destructive/50 text-destructive dark:border-destructive [&>svg]:text-destructive"}},defaultVariants:{variant:"default"}}),Za=_.forwardRef(({className:e,variant:r,...s},n)=>t.jsx("div",{ref:n,role:"alert",className:Ee(ZB({variant:r}),e),...s}));Za.displayName="Alert";const e8=_.forwardRef(({className:e,...r},s)=>t.jsx("h5",{ref:s,className:Ee("mb-1 font-medium leading-none tracking-tight",e),...r}));e8.displayName="AlertTitle";const el=_.forwardRef(({className:e,...r},s)=>t.jsx("div",{ref:s,className:Ee("text-sm [&_p]:leading-relaxed",e),...r}));el.displayName="AlertDescription";var kh="Collapsible",[t8]=Ls(kh),[r8,Rx]=t8(kh),wN=_.forwardRef((e,r)=>{const{__scopeCollapsible:s,open:n,defaultOpen:o,disabled:c,onOpenChange:d,...l}=e,[u,f]=Xn({prop:n,defaultProp:o??!1,onChange:d,caller:kh});return t.jsx(r8,{scope:s,disabled:c,contentId:cn(),open:u,onOpenToggle:_.useCallback(()=>f(m=>!m),[f]),children:t.jsx(ot.div,{"data-state":Ix(u),"data-disabled":c?"":void 0,...l,ref:r})})});wN.displayName=kh;var _N="CollapsibleTrigger",SN=_.forwardRef((e,r)=>{const{__scopeCollapsible:s,...n}=e,o=Rx(_N,s);return t.jsx(ot.button,{type:"button","aria-controls":o.contentId,"aria-expanded":o.open||!1,"data-state":Ix(o.open),"data-disabled":o.disabled?"":void 0,disabled:o.disabled,...n,ref:r,onClick:Fe(e.onClick,o.onOpenToggle)})});SN.displayName=_N;var Mx="CollapsibleContent",CN=_.forwardRef((e,r)=>{const{forceMount:s,...n}=e,o=Rx(Mx,e.__scopeCollapsible);return t.jsx(Qr,{present:s||o.open,children:({present:c})=>t.jsx(s8,{...n,ref:r,present:c})})});CN.displayName=Mx;var s8=_.forwardRef((e,r)=>{const{__scopeCollapsible:s,present:n,children:o,...c}=e,d=Rx(Mx,s),[l,u]=_.useState(n),f=_.useRef(null),m=xt(r,f),h=_.useRef(0),g=h.current,w=_.useRef(0),j=w.current,S=d.open||l,v=_.useRef(S),y=_.useRef(void 0);return _.useEffect(()=>{const x=requestAnimationFrame(()=>v.current=!1);return()=>cancelAnimationFrame(x)},[]),Ur(()=>{const x=f.current;if(x){y.current=y.current||{transitionDuration:x.style.transitionDuration,animationName:x.style.animationName},x.style.transitionDuration="0s",x.style.animationName="none";const b=x.getBoundingClientRect();h.current=b.height,w.current=b.width,v.current||(x.style.transitionDuration=y.current.transitionDuration,x.style.animationName=y.current.animationName),u(n)}},[d.open,n]),t.jsx(ot.div,{"data-state":Ix(d.open),"data-disabled":d.disabled?"":void 0,id:d.contentId,hidden:!S,...c,ref:m,style:{"--radix-collapsible-content-height":g?`${g}px`:void 0,"--radix-collapsible-content-width":j?`${j}px`:void 0,...e.style},children:S&&o})});function Ix(e){return e?"open":"closed"}var n8=wN;const Hc=n8,Wc=SN,Uc=CN,$p=[{name:"Bash",icon:Ut,description:"Shell commands",color:"text-purple-600",bgColor:"bg-purple-50",badgeClass:"bg-purple-100 text-purple-700 border-purple-200"},{name:"Read",icon:Hr,description:"Read file contents",color:"text-blue-600",bgColor:"bg-blue-50",badgeClass:"bg-blue-100 text-blue-700 border-blue-200"},{name:"Edit",icon:Og,description:"Edit existing files",color:"text-amber-600",bgColor:"bg-amber-50",badgeClass:"bg-amber-100 text-amber-700 border-amber-200"},{name:"Write",icon:sl,description:"Create/write files",color:"text-orange-600",bgColor:"bg-orange-50",badgeClass:"bg-orange-100 text-orange-700 border-orange-200"},{name:"WebFetch",icon:Ji,description:"Fetch web content",color:"text-green-600",bgColor:"bg-green-50",badgeClass:"bg-green-100 text-green-700 border-green-200"},{name:"WebSearch",icon:Tc,description:"Web search capability",color:"text-teal-600",bgColor:"bg-teal-50",badgeClass:"bg-teal-100 text-teal-700 border-teal-200"},{name:"mcp",icon:Ya,description:"MCP server tools",color:"text-indigo-600",bgColor:"bg-indigo-50",badgeClass:"bg-indigo-100 text-indigo-700 border-indigo-200"}],Pw=[{category:"Git",name:"Git Status",pattern:"Bash(git status:*)",description:"Check repository status",icon:Ut},{category:"Git",name:"Git Add",pattern:"Bash(git add:*)",description:"Stage files for commit",icon:Ut},{category:"Git",name:"Git Commit",pattern:"Bash(git commit:*)",description:"Create commits",icon:Ut},{category:"Git",name:"Git Push",pattern:"Bash(git push:*)",description:"Push to remote repository",icon:Ut},{category:"Git",name:"Git Diff",pattern:"Bash(git diff:*)",description:"Show changes",icon:Ut},{category:"NPM",name:"NPM Install",pattern:"Bash(npm install:*)",description:"Install dependencies",icon:Ut},{category:"NPM",name:"NPM Run Scripts",pattern:"Bash(npm run:*)",description:"Run package scripts",icon:Ut},{category:"NPM",name:"NPM Test",pattern:"Bash(npm test:*)",description:"Run tests",icon:Ut},{category:"Files",name:"Read All Files",pattern:"Read(**)",description:"Read any file in the project",icon:Hr},{category:"Files",name:"Edit All Files",pattern:"Edit(**)",description:"Edit any file in the project",icon:Og},{category:"Security",name:"Deny .env Files",pattern:"Read(./.env)",description:"Block reading environment files",icon:Hr,suggestedCategory:"deny"},{category:"Security",name:"Deny All .env",pattern:"Read(**/.env*)",description:"Block all environment files",icon:Hr,suggestedCategory:"deny"},{category:"Commands",name:"List Files",pattern:"Bash(ls:*)",description:"List directory contents",icon:Ut},{category:"Commands",name:"Find Files",pattern:"Bash(find:*)",description:"Find files and directories",icon:Ut},{category:"MCP",name:"Filesystem Operations",pattern:"mcp__filesystem__*",description:"All filesystem MCP operations",icon:Ya},{category:"MCP",name:"GitHub Operations",pattern:"mcp__github__*",description:"All GitHub MCP operations",icon:Ya}];function jh(e){if(!e)return{type:"unknown",value:"",hasWildcard:!1,description:""};if(e.startsWith("mcp__")){const s=e.split("__");return{type:"mcp",value:e,server:s[1]||"",tool:s[2]||"",hasWildcard:e.includes("*"),description:`MCP tool: ${s.slice(1).join("/")}`}}if(e==="WebSearch")return{type:"WebSearch",value:"",hasWildcard:!1,description:"Web search capability"};const r=e.match(/^(\w+)\((.+)\)$/);if(r){const[,s,n]=r,o=n.includes("*");return{type:s,value:n,hasWildcard:o,description:a8(s,n)}}return{type:"unknown",value:e,hasWildcard:e.includes("*"),description:e}}function i8(e,r){return e==="WebSearch"?"WebSearch":e==="mcp"?r:r?`${e}(${r})`:""}function o8(e){if(!e)return"Rule cannot be empty";if(e==="WebSearch")return null;if(e.startsWith("mcp__"))return e.includes("*")||e.match(/^mcp__\w+__\w+$/)?null:"MCP pattern must be: mcp__server__tool";const r=e.match(/^(\w+)\((.+)\)$/);if(!r)return"Invalid pattern format. Expected: Type(value) or mcp__server__tool";const[,s]=r,n=["Bash","Read","Edit","Write","WebFetch"];return n.includes(s)?null:`Unknown permission type: ${s}. Valid types: ${n.join(", ")}`}function a8(e,r){switch(e){case"Bash":if(r.includes(":")){const[s,n]=r.split(":");return n==="*"?`Run "${s}" with any arguments`:`Run "${s} ${n}"`}return`Run "${r}"`;case"Read":return r==="**"?"Read all files":r.includes("**")?`Read files matching ${r}`:`Read ${r}`;case"Edit":return r==="**"?"Edit all files":r.includes("**")?`Edit files matching ${r}`:`Edit ${r}`;case"Write":return r==="**"?"Write to any file":r.includes("**")?`Write files matching ${r}`:`Write to ${r}`;case"WebFetch":return r==="*"?"Fetch any URL":`Fetch URLs matching ${r}`;default:return r}}function l8(e){return $p.find(s=>s.name===e)||$p[0]}function c8(e){return{allow:'Rules in "Allow" will execute automatically without prompting. Use wildcards (*) for flexible matching.',ask:'Rules in "Ask" will prompt for confirmation each time. Good for potentially destructive operations.',deny:'Rules in "Deny" are blocked entirely. Use this to prevent access to sensitive files or dangerous operations.'}[e]}function Aw(e){return{allow:{label:"Allow",color:"text-green-600",bgColor:"bg-green-50",borderColor:"border-green-200",badgeColor:"bg-green-100 text-green-700",description:"Operations that run without asking"},ask:{label:"Ask",color:"text-amber-600",bgColor:"bg-amber-50",borderColor:"border-amber-200",badgeColor:"bg-amber-100 text-amber-700",description:"Operations that require confirmation"},deny:{label:"Deny",color:"text-red-600",bgColor:"bg-red-50",borderColor:"border-red-200",badgeColor:"bg-red-100 text-red-700",description:"Operations that are blocked"}}[e]}function d8(e,r){const s=jh(e),{type:n,value:o}=s,c={allow:{prefix:"✓ Allowed automatically",meaning:"Claude will do this without asking you first"},ask:{prefix:"? Requires approval",meaning:"Claude will ask for your permission each time"},deny:{prefix:"✗ Blocked",meaning:"Claude cannot do this at all"}},d=c[r]||c.ask;let l="",u="",f=[];switch(n){case"Bash":if(o.includes(":")){const[w,j]=o.split(":");j==="*"?(l=`Run "${w}" command`,u=`Allows running the ${w} command with any arguments`,f=[`${w} build`,`${w} test`,`${w} --help`]):(l=`Run "${w} ${j}"`,u="Allows running this specific command",f=[`${w} ${j}`])}else o==="*"?(l="Run any terminal command",u="Allows executing any command in the terminal. Use with caution!",f=["npm install","git push","rm files"]):(l=`Run "${o}" command`,u="Allows running this specific command",f=[o]);break;case"Read":if(o==="**")l="Read any file",u="Allows reading the contents of any file in the project",f=["package.json","src/index.ts",".env"];else if(o.includes("**/*.")){const w=o.split("**.")[1];l=`Read ${w} files`,u=`Allows reading any file ending in .${w}`,f=[`file.${w}`,`src/component.${w}`]}else o.startsWith("./")?(l=`Read files in ${o}`,u=`Allows reading files in the ${o.replace("./","")} directory`):(l=`Read "${o}"`,u="Allows reading files matching this pattern");break;case"Edit":if(o==="**")l="Edit any file",u="Allows modifying the contents of any file. Changes can be undone with git.",f=["package.json","src/index.ts"];else if(o.includes("**/*.")){const w=o.split("**.")[1];l=`Edit ${w} files`,u=`Allows modifying any file ending in .${w}`}else o.startsWith("./")?(l=`Edit files in ${o}`,u=`Allows modifying files in the ${o.replace("./","")} directory`):(l=`Edit "${o}"`,u="Allows modifying files matching this pattern");break;case"Write":o==="**"?(l="Create any file",u="Allows creating new files anywhere in the project"):(l=`Create files in "${o}"`,u="Allows creating new files matching this pattern");break;case"WebFetch":o==="*"?(l="Fetch any URL",u="Allows making HTTP requests to any website",f=["api.github.com","docs.example.com"]):(l=`Fetch from ${o}`,u="Allows making HTTP requests to URLs matching this pattern");break;case"WebSearch":l="Search the web",u="Allows Claude to search the internet for information";break;case"mcp":const m=e.split("__"),h=m[1]||"unknown",g=m[2]||"*";g==="*"||e.endsWith("*")?(l=`Use ${h} tools`,u=`Allows using any tool from the ${h} MCP server`):(l=`Use ${h}/${g}`,u=`Allows using the ${g} tool from the ${h} MCP server`);break;default:l=e,u="Custom permission rule"}return{summary:l,detail:u,examples:f,categoryMeaning:`${d.prefix} — ${d.meaning}`}}function u8(e){const r={Bash:[],Read:[],Edit:[],Write:[],WebFetch:[],WebSearch:[],mcp:[],other:[]};for(const n of e){const c=jh(n).type;r[c]?r[c].push(n):r.other.push(n)}return["Bash","Read","Edit","Write","WebFetch","WebSearch","mcp","other"].filter(n=>r[n].length>0).map(n=>({type:n,rules:r[n]}))}function h8({rule:e,category:r,onEdit:s,onDelete:n,readOnly:o}){const[c,d]=_.useState(!1),l=jh(e);l8(l.type);const u=d8(e,r),f=e.length>25?e.substring(0,22)+"...":e;return t.jsxs("div",{className:"inline-flex items-center group",onMouseEnter:()=>d(!0),onMouseLeave:()=>d(!1),children:[t.jsxs(Ft,{children:[t.jsx(Bt,{asChild:!0,children:t.jsx("span",{className:"inline-block",children:t.jsx(rt,{variant:"secondary",className:Ee("cursor-default transition-all text-xs font-mono py-1 px-2 h-7",r==="allow"&&"bg-green-100 dark:bg-green-950 text-green-800 dark:text-green-300",r==="ask"&&"bg-amber-100 dark:bg-amber-950 text-amber-800 dark:text-amber-300",r==="deny"&&"bg-red-100 dark:bg-red-950 text-red-800 dark:text-red-300",!o&&"rounded-r-none"),children:f})})}),t.jsx(Ot,{side:"bottom",className:"max-w-md p-3",children:t.jsxs("div",{className:"space-y-2",children:[t.jsxs("div",{children:[t.jsx("p",{className:"text-sm font-medium",children:u.summary}),t.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:u.detail})]}),t.jsx("div",{className:Ee("text-xs px-2 py-1 rounded",r==="allow"&&"bg-green-500/20 text-green-700 dark:text-green-300",r==="ask"&&"bg-amber-500/20 text-amber-700 dark:text-amber-300",r==="deny"&&"bg-red-500/20 text-red-700 dark:text-red-300"),children:u.categoryMeaning}),u.examples&&u.examples.length>0&&t.jsxs("div",{className:"text-xs text-muted-foreground",children:[t.jsx("span",{className:"font-medium",children:"Examples: "}),u.examples.join(", ")]}),t.jsxs("code",{className:"text-[10px] text-muted-foreground/70 block break-all",children:["Pattern: ",e]})]})})]}),!o&&t.jsxs(Nn,{children:[t.jsx(En,{asChild:!0,children:t.jsx("button",{className:Ee("h-7 px-1 rounded-r transition-all border-l","hover:bg-black/10 dark:hover:bg-white/10",r==="allow"&&"bg-green-200 dark:bg-green-900 border-green-300 dark:border-green-800",r==="ask"&&"bg-amber-200 dark:bg-amber-900 border-amber-300 dark:border-amber-800",r==="deny"&&"bg-red-200 dark:bg-red-900 border-red-300 dark:border-red-800",c?"opacity-100":"opacity-0"),children:t.jsx(iM,{className:"w-3 h-3"})})}),t.jsxs(un,{align:"end",className:"w-32",children:[t.jsx(Pt,{onClick:s,children:"Edit"}),t.jsx(xs,{}),t.jsx(Pt,{onClick:n,className:"text-red-600",children:"Delete"})]})]})]})}const Tw={Bash:{label:"Bash",color:"text-purple-600 dark:text-purple-400"},Read:{label:"Read",color:"text-blue-600 dark:text-blue-400"},Edit:{label:"Edit",color:"text-orange-600 dark:text-orange-400"},Write:{label:"Write",color:"text-green-600 dark:text-green-400"},WebFetch:{label:"WebFetch",color:"text-cyan-600 dark:text-cyan-400"},WebSearch:{label:"WebSearch",color:"text-teal-600 dark:text-teal-400"},mcp:{label:"MCP",color:"text-indigo-600 dark:text-indigo-400"},other:{label:"Other",color:"text-gray-600 dark:text-gray-400"}};function f8({type:e,rules:r,category:s,onEdit:n,onDelete:o,onAddRule:c,readOnly:d,defaultExpanded:l=!1}){const[u,f]=_.useState(l||r.length<=5),m=Tw[e]||Tw.other;return r.length===0?null:t.jsxs("div",{className:"border border-gray-200 dark:border-slate-700 rounded-lg overflow-hidden",children:[t.jsxs("button",{onClick:()=>f(!u),className:Ee("w-full flex items-center gap-2 px-3 py-2 text-left","bg-gray-50 dark:bg-slate-800/50 hover:bg-gray-100 dark:hover:bg-slate-800","transition-colors"),children:[t.jsx(vs,{className:Ee("w-4 h-4 text-gray-400 transition-transform",u&&"rotate-90")}),t.jsx("span",{className:Ee("font-medium text-sm",m.color),children:m.label}),t.jsx(rt,{variant:"secondary",className:"text-xs",children:r.length}),!u&&r.length>0&&t.jsxs("span",{className:"text-xs text-gray-400 dark:text-slate-500 truncate flex-1 ml-2",children:[r.slice(0,3).join(", "),r.length>3&&"..."]})]}),u&&t.jsx("div",{className:"p-3 bg-white dark:bg-slate-900",children:t.jsxs("div",{className:"flex flex-wrap gap-2",children:[r.map(h=>t.jsx(h8,{rule:h,category:s,onEdit:()=>n(h),onDelete:()=>o(h),readOnly:d},h)),!d&&t.jsxs(se,{variant:"outline",size:"sm",className:"h-7 text-xs",onClick:c,children:[t.jsx(It,{className:"w-3 h-3 mr-1"}),"Add"]})]})})]})}function m8({open:e,onOpenChange:r,onSubmit:s,defaultCategory:n="allow",defaultRule:o="",isEditing:c=!1,existingRules:d=[]}){const[l,u]=_.useState("preset"),[f,m]=_.useState(n),[h,g]=_.useState("Bash"),[w,j]=_.useState(""),[S,v]=_.useState(o),[y,x]=_.useState(new Set),[b,k]=_.useState(""),[N,P]=_.useState(null);_.useEffect(()=>{if(e)if(m(n),x(new Set),k(""),o&&c){const $=jh(o);g($.type==="unknown"?"Bash":$.type),j($.value),v(o),u("builder")}else g("Bash"),j(""),v(""),u("preset")},[e,o,n,c]);const A=$=>{x(Y=>{const K=new Set(Y);return K.has($)?K.delete($):K.add($),K})},E=()=>{const $=O.filter(Y=>!d.includes(Y.pattern)).map(Y=>Y.pattern);x(new Set($))},M=()=>{x(new Set)},I=_.useMemo(()=>l==="freeform"?S:l==="builder"?i8(h,w):"",[l,h,w,S]);_.useEffect(()=>{if(l!=="preset"){const $=o8(I);P($)}else P(null)},[I,l]);const O=_.useMemo(()=>{if(!b)return Pw;const $=b.toLowerCase();return Pw.filter(Y=>Y.name.toLowerCase().includes($)||Y.pattern.toLowerCase().includes($)||Y.description.toLowerCase().includes($)||Y.category.toLowerCase().includes($))},[b]),z=_.useMemo(()=>{const $={};return O.forEach(Y=>{$[Y.category]||($[Y.category]=[]),$[Y.category].push(Y)}),$},[O]),U=()=>{if(l==="preset"){const $=Array.from(y);if($.length===0)return;for(const Y of $)s(f,Y);r(!1)}else{if(N||!I)return;s(f,I),r(!1)}},X=l==="preset"?y.size===0:!I||!!N,W=x8(h);return t.jsx(bt,{open:e,onOpenChange:r,children:t.jsxs(mt,{className:"max-w-2xl max-h-[90vh] overflow-hidden flex flex-col",children:[t.jsxs(pt,{children:[t.jsx(gt,{className:"flex items-center gap-2",children:c?t.jsxs(t.Fragment,{children:[t.jsx(sl,{className:"w-5 h-5 text-indigo-600"}),"Edit Permission Rule"]}):t.jsxs(t.Fragment,{children:[t.jsx(Wr,{className:"w-5 h-5 text-indigo-600"}),"Add Permission Rule"]})}),t.jsx(sr,{children:"Create a permission rule to control Claude Code's behavior."})]}),t.jsxs("div",{className:"flex-1 overflow-auto space-y-6 py-4",children:[t.jsxs("div",{className:"space-y-2",children:[t.jsx(Ze,{children:"Permission Category"}),t.jsxs(vr,{value:f,onValueChange:m,children:[t.jsx(hr,{children:t.jsx(yr,{})}),t.jsxs(fr,{children:[t.jsx(At,{value:"allow",children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("div",{className:"w-3 h-3 rounded-full bg-green-500"}),"Allow - Execute without asking"]})}),t.jsx(At,{value:"ask",children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("div",{className:"w-3 h-3 rounded-full bg-amber-500"}),"Ask - Require confirmation"]})}),t.jsx(At,{value:"deny",children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("div",{className:"w-3 h-3 rounded-full bg-red-500"}),"Deny - Block entirely"]})})]})]})]}),t.jsxs($c,{value:l,onValueChange:u,children:[t.jsxs(ll,{className:"grid w-full grid-cols-3",children:[t.jsxs(Ms,{value:"preset",children:[t.jsx(Wr,{className:"w-4 h-4 mr-2"}),"Presets"]}),t.jsxs(Ms,{value:"builder",children:[t.jsx(Ut,{className:"w-4 h-4 mr-2"}),"Builder"]}),t.jsxs(Ms,{value:"freeform",children:[t.jsx(Og,{className:"w-4 h-4 mr-2"}),"Freeform"]})]}),t.jsxs(Hn,{value:"preset",className:"space-y-4",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(He,{placeholder:"Search presets...",value:b,onChange:$=>k($.target.value),className:"flex-1"}),t.jsx(se,{variant:"outline",size:"sm",onClick:E,disabled:O.length===0,children:"Select All"}),t.jsx(se,{variant:"ghost",size:"sm",onClick:M,disabled:y.size===0,children:"Clear"})]}),y.size>0&&t.jsxs("div",{className:"flex items-center gap-2 text-sm text-indigo-600 dark:text-indigo-400",children:[t.jsx(Mt,{className:"w-4 h-4"}),y.size," preset",y.size!==1?"s":""," selected"]}),t.jsx("div",{className:"border border-gray-200 dark:border-slate-700 rounded-lg max-h-[220px] overflow-auto",children:Object.entries(z).map(([$,Y])=>t.jsxs("div",{className:"border-b border-gray-200 dark:border-slate-700 last:border-b-0",children:[t.jsx("div",{className:"px-3 py-1.5 bg-gray-50 dark:bg-slate-800 font-medium text-xs text-gray-600 dark:text-slate-300 sticky top-0",children:$}),Y.map(K=>{const L=K.icon,T=y.has(K.pattern),B=d.includes(K.pattern);return t.jsxs("label",{className:Ee("flex items-start gap-2 px-3 py-2 cursor-pointer transition-colors",B?"opacity-50 cursor-not-allowed bg-gray-100 dark:bg-slate-800":T?"bg-indigo-50 dark:bg-indigo-950/50":"hover:bg-gray-50 dark:hover:bg-slate-800"),children:[t.jsx(Dc,{checked:T,onCheckedChange:()=>!B&&A(K.pattern),disabled:B,className:"mt-0.5"}),t.jsx(L,{className:"w-4 h-4 mt-0.5 text-gray-400 dark:text-slate-500 shrink-0"}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"font-medium text-sm",children:K.name}),B&&t.jsx(rt,{variant:"secondary",className:"text-xs",children:"Added"})]}),t.jsx("code",{className:"text-xs text-gray-500 dark:text-slate-400 block truncate",children:K.pattern})]})]},K.pattern)})]},$))})]}),t.jsxs(Hn,{value:"builder",className:"space-y-4",children:[t.jsxs("div",{className:"space-y-2",children:[t.jsx(Ze,{children:"Permission Type"}),t.jsxs(vr,{value:h,onValueChange:g,children:[t.jsx(hr,{children:t.jsx(yr,{})}),t.jsx(fr,{children:$p.map($=>{const Y=$.icon;return t.jsx(At,{value:$.name,children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(Y,{className:"w-4 h-4"}),$.name,t.jsxs("span",{className:"text-xs text-gray-400 dark:text-slate-500",children:["- ",$.description]})]})},$.name)})})]})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx(Ze,{children:p8(h)}),t.jsxs(Ft,{children:[t.jsx(Bt,{children:t.jsx(Fa,{className:"w-4 h-4 text-gray-400"})}),t.jsx(Ot,{className:"max-w-xs",children:g8(h)})]})]}),h==="WebSearch"?t.jsx("p",{className:"text-sm text-gray-500 dark:text-slate-400 italic",children:"WebSearch does not require a value pattern."}):t.jsx(He,{value:w,onChange:$=>j($.target.value),placeholder:h==="Bash"?"command:arguments":"path/pattern",className:"font-mono"})]}),W.length>0&&t.jsxs("div",{className:"space-y-2",children:[t.jsx(Ze,{className:"text-xs text-gray-500 dark:text-slate-400",children:"Quick examples:"}),t.jsx("div",{className:"flex flex-wrap gap-2",children:W.map($=>t.jsx(se,{variant:"outline",size:"sm",className:"text-xs h-7",onClick:()=>j($.value),children:$.label},$.value))})]})]}),t.jsx(Hn,{value:"freeform",className:"space-y-4",children:t.jsxs("div",{className:"space-y-2",children:[t.jsx(Ze,{children:"Rule Pattern"}),t.jsx(ft,{value:S,onChange:$=>v($.target.value),placeholder:"e.g., Bash(npm run build), Read(**/*.ts)",className:"font-mono text-sm",rows:3}),t.jsx("p",{className:"text-xs text-gray-500 dark:text-slate-400",children:"Enter the full permission pattern. Use * for wildcards and : for Bash argument separation."})]})})]}),l!=="preset"&&t.jsxs("div",{className:"space-y-2",children:[t.jsx(Ze,{children:"Generated Rule"}),t.jsx("div",{className:Ee("p-3 rounded-lg border font-mono text-sm",N?"bg-red-50 dark:bg-red-950/50 border-red-200 dark:border-red-800 text-red-700 dark:text-red-400":"bg-gray-50 dark:bg-slate-800 border-gray-200 dark:border-slate-700 text-gray-700 dark:text-slate-300"),children:I||t.jsx("span",{className:"text-gray-400 dark:text-slate-500",children:"No rule configured"})}),N&&t.jsxs("div",{className:"flex items-center gap-2 text-sm text-red-600",children:[t.jsx(Is,{className:"w-4 h-4"}),N]})]})]}),t.jsxs(jt,{children:[t.jsx(se,{variant:"ghost",onClick:()=>r(!1),children:"Cancel"}),t.jsx(se,{onClick:U,disabled:X,className:"bg-indigo-600 hover:bg-indigo-700 text-white",children:c?"Update Rule":l==="preset"&&y.size>1?`Add ${y.size} Rules`:"Add Rule"})]})]})})}function p8(e){return{Bash:"Command Pattern",Read:"File Path Pattern",Edit:"File Path Pattern",Write:"File Path Pattern",WebFetch:"URL Pattern",WebSearch:"N/A",mcp:"Tool Name"}[e]||"Value"}function g8(e){return{Bash:"Format: command:arguments. Use * for wildcards. Example: npm run:* matches npm run build, npm run test, etc.",Read:"File path pattern. Use ** for recursive matching. Example: **/*.ts matches all TypeScript files.",Edit:"File path pattern. Use ** for recursive matching.",Write:"File path pattern. Use ** for recursive matching.",WebFetch:"URL pattern. Example: https://api.github.com/* matches all GitHub API calls.",WebSearch:"No value needed - this enables/disables web search entirely.",mcp:"MCP tool name in format: mcp__server__tool"}[e]||""}function x8(e){return{Bash:[{label:"npm run *",value:"npm run:*"},{label:"git add *",value:"git add:*"},{label:"git commit *",value:"git commit:*"},{label:"ls *",value:"ls:*"}],Read:[{label:"All files",value:"**"},{label:"TypeScript",value:"**/*.ts"},{label:"Source only",value:"./src/**"}],Edit:[{label:"All files",value:"**"},{label:"Source only",value:"./src/**"}],Write:[{label:"All files",value:"**"}],WebFetch:[{label:"Any URL",value:"*"},{label:"GitHub API",value:"https://api.github.com/*"}],mcp:[{label:"Filesystem read",value:"mcp__filesystem__read_file"},{label:"GitHub PR",value:"mcp__github__create_pull_request"}]}[e]||[]}function v8({open:e,onOpenChange:r,mode:s,permissions:n,onImport:o}){const[c,d]=_.useState(""),[l,u]=_.useState(null),[f,m]=_.useState(!1);_.useEffect(()=>{e&&s==="export"?(d(JSON.stringify({permissions:n},null,2)),u(null)):e&&s==="import"&&(d(""),u(null))},[e,s,n]);const h=()=>{navigator.clipboard.writeText(c),m(!0),setTimeout(()=>m(!1),2e3),q.success("Copied to clipboard")},g=()=>{try{const w=JSON.parse(c);if(!w.permissions){u('JSON must have a "permissions" key');return}const{allow:j=[],ask:S=[],deny:v=[]}=w.permissions;if(!Array.isArray(j)||!Array.isArray(S)||!Array.isArray(v)){u("allow, ask, and deny must be arrays");return}if([...j,...S,...v].some(x=>typeof x!="string")){u("All permission rules must be strings");return}o(w.permissions),r(!1)}catch(w){u("Invalid JSON: "+w.message)}};return t.jsx(bt,{open:e,onOpenChange:r,children:t.jsxs(mt,{className:"max-w-lg",children:[t.jsxs(pt,{children:[t.jsx(gt,{className:"flex items-center gap-2",children:s==="export"?t.jsxs(t.Fragment,{children:[t.jsx(xi,{className:"w-5 h-5 text-indigo-600"}),"Export Permissions"]}):t.jsxs(t.Fragment,{children:[t.jsx(Sp,{className:"w-5 h-5 text-indigo-600"}),"Import Permissions"]})}),t.jsx(sr,{children:s==="export"?"Copy this JSON to save or share your permission configuration.":"Paste a JSON permission configuration to import."})]}),t.jsxs("div",{className:"space-y-4 py-4",children:[t.jsx(ft,{value:c,onChange:w=>{d(w.target.value),u(null)},placeholder:s==="import"?"Paste JSON here...":"",className:"font-mono text-sm min-h-[300px]",readOnly:s==="export"}),l&&t.jsxs("div",{className:"flex items-center gap-2 text-sm text-red-600",children:[t.jsx(Is,{className:"w-4 h-4"}),l]})]}),t.jsxs(jt,{children:[t.jsx(se,{variant:"ghost",onClick:()=>r(!1),children:"Cancel"}),s==="export"?t.jsxs(se,{onClick:h,className:"bg-indigo-600 hover:bg-indigo-700 text-white",children:[f?t.jsx(Mt,{className:"w-4 h-4 mr-2"}):t.jsx(Ka,{className:"w-4 h-4 mr-2"}),f?"Copied!":"Copy to Clipboard"]}):t.jsxs(se,{onClick:g,disabled:!c.trim(),className:"bg-indigo-600 hover:bg-indigo-700 text-white",children:[t.jsx(Sp,{className:"w-4 h-4 mr-2"}),"Import"]})]})]})})}function y8({open:e,onOpenChange:r,serverName:s,serverConfig:n={},permissions:o={allow:[],ask:[],deny:[]},onUpdatePermissions:c}){var A,E;const[d,l]=_.useState([]),[u,f]=_.useState(!1),[m,h]=_.useState(null),[g,w]=_.useState("");_.useEffect(()=>{e&&s&&j()},[e,s]);const j=async()=>{f(!0),h(null);try{const M=await fe.getMcpServerTools(s);M.error?(h(M.error),l([])):l(M.tools||[])}catch(M){h(M.message),l([])}finally{f(!1)}},S=async()=>{await fe.clearMcpToolsCache(s),await j()},v=_.useMemo(()=>{var z,U,X,W;const M=`mcp__${s}__`,I=`${M}*`,O={allowAll:((z=o.allow)==null?void 0:z.includes(I))||!1,toolPermissions:{}};return(U=o.allow)==null||U.forEach($=>{$.startsWith(M)&&$!==I&&(O.toolPermissions[$.replace(M,"")]="allow")}),(X=o.ask)==null||X.forEach($=>{$.startsWith(M)&&$!==I&&(O.toolPermissions[$.replace(M,"")]="ask")}),(W=o.deny)==null||W.forEach($=>{$.startsWith(M)&&$!==I&&(O.toolPermissions[$.replace(M,"")]="deny")}),O},[s,o]),y=_.useMemo(()=>{const M=new Set;return d.forEach(I=>M.add(I.name)),Object.keys(v.toolPermissions).forEach(I=>M.add(I)),Array.from(M).sort().map(I=>{const O=d.find(z=>z.name===I);return{name:I,description:(O==null?void 0:O.description)||"",discovered:!!O}})},[d,v.toolPermissions]),x=M=>{const I=`mcp__${s}__*`;c==null||c(s,I,M?"allow":"remove")},b=(M,I)=>{const O=`mcp__${s}__${M}`;v.toolPermissions[M]===I?c==null||c(s,O,"remove"):c==null||c(s,O,I)},k=()=>{const M=g.trim();if(!M)return;const I=`mcp__${s}__${M}`;c==null||c(s,I,"allow"),w("")},N=M=>{const I=`mcp__${s}__${M}`;c==null||c(s,I,"remove")},P=n!=null&&n.command?"stdio":n!=null&&n.url?"sse":"unknown";return t.jsx(ar,{children:t.jsx(bt,{open:e,onOpenChange:r,children:t.jsxs(mt,{className:"sm:max-w-[550px] max-h-[85vh] flex flex-col",children:[t.jsxs(pt,{children:[t.jsxs(gt,{className:"flex items-center gap-2",children:[t.jsx(Ya,{className:"w-5 h-5 text-purple-600"}),"Configure ",s]}),t.jsxs(sr,{children:[P==="stdio"&&n.command&&t.jsxs("code",{className:"text-xs bg-gray-100 dark:bg-slate-800 px-2 py-1 rounded",children:[n.command," ",(A=n.args)==null?void 0:A.slice(0,2).join(" "),((E=n.args)==null?void 0:E.length)>2&&"..."]}),P==="sse"&&n.url&&t.jsx("code",{className:"text-xs bg-gray-100 dark:bg-slate-800 px-2 py-1 rounded",children:n.url})]})]}),t.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col space-y-4 py-4",children:[t.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg border border-gray-200 dark:border-slate-700 bg-gray-50 dark:bg-slate-800/50",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(Qn,{className:"w-5 h-5 text-green-600"}),t.jsxs("div",{children:[t.jsx(Ze,{className:"font-medium",children:"Allow all tools"}),t.jsx("p",{className:"text-xs text-gray-500 dark:text-slate-400",children:"Grant permission for all tools from this server"})]})]}),t.jsx(_t,{checked:v.allowAll,onCheckedChange:x})]}),v.allowAll&&t.jsxs(Za,{children:[t.jsx(Zu,{className:"w-4 h-4"}),t.jsx(el,{className:"text-sm",children:"All tools are allowed. Individual tool settings below are informational only."})]}),t.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col space-y-3",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx(Ze,{className:"text-sm font-medium",children:"Available Tools"}),t.jsxs(se,{variant:"ghost",size:"sm",onClick:S,disabled:u,className:"h-7",children:[t.jsx(Mr,{className:Ee("w-3 h-3 mr-1",u&&"animate-spin")}),"Refresh"]})]}),m&&t.jsxs(Za,{variant:"destructive",children:[t.jsx(Is,{className:"w-4 h-4"}),t.jsxs(el,{className:"text-sm",children:[m,t.jsx("p",{className:"text-xs mt-1 opacity-80",children:"You can still add tools manually below."})]})]}),u&&t.jsxs("div",{className:"flex items-center justify-center py-8",children:[t.jsx(Mr,{className:"w-5 h-5 animate-spin text-gray-400"}),t.jsx("span",{className:"ml-2 text-sm text-gray-500",children:"Discovering tools..."})]}),!u&&t.jsx(Xs,{className:"flex-1 min-h-0 rounded-md border border-gray-200 dark:border-slate-700",children:t.jsx("div",{className:"divide-y divide-gray-200 dark:divide-slate-700",children:y.length>0?y.map(M=>{const I=v.toolPermissions[M.name];return t.jsxs("div",{className:"flex items-center justify-between p-2 hover:bg-gray-50 dark:hover:bg-slate-800/50",children:[t.jsxs("div",{className:"flex-1 min-w-0 mr-2",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("code",{className:"text-sm font-mono truncate",children:M.name}),!M.discovered&&t.jsx(rt,{variant:"outline",className:"text-xs",children:"manual"})]}),M.description&&t.jsx("p",{className:"text-xs text-gray-500 dark:text-slate-400 truncate",children:M.description})]}),t.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[t.jsxs(Ft,{children:[t.jsx(Bt,{asChild:!0,children:t.jsx(se,{variant:I==="allow"?"default":"ghost",size:"sm",className:Ee("h-7 w-7 p-0",I==="allow"&&"bg-green-600 hover:bg-green-700"),onClick:()=>b(M.name,"allow"),children:t.jsx(Mt,{className:"w-3 h-3"})})}),t.jsx(Ot,{children:"Allow"})]}),t.jsxs(Ft,{children:[t.jsx(Bt,{asChild:!0,children:t.jsx(se,{variant:I==="ask"?"default":"ghost",size:"sm",className:Ee("h-7 w-7 p-0",I==="ask"&&"bg-amber-600 hover:bg-amber-700"),onClick:()=>b(M.name,"ask"),children:"?"})}),t.jsx(Ot,{children:"Ask"})]}),t.jsxs(Ft,{children:[t.jsx(Bt,{asChild:!0,children:t.jsx(se,{variant:I==="deny"?"default":"ghost",size:"sm",className:Ee("h-7 w-7 p-0",I==="deny"&&"bg-red-600 hover:bg-red-700"),onClick:()=>b(M.name,"deny"),children:t.jsx(Un,{className:"w-3 h-3"})})}),t.jsx(Ot,{children:"Deny"})]}),!M.discovered&&I&&t.jsxs(Ft,{children:[t.jsx(Bt,{asChild:!0,children:t.jsx(se,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 text-gray-400 hover:text-red-600",onClick:()=>N(M.name),children:t.jsx(ws,{className:"w-3 h-3"})})}),t.jsx(Ot,{children:"Remove"})]})]})]},M.name)}):t.jsxs("div",{className:"text-center py-8 text-gray-500 dark:text-slate-400",children:[t.jsx("p",{className:"text-sm",children:"No tools discovered"}),t.jsx("p",{className:"text-xs mt-1",children:"Add tools manually below"})]})})}),t.jsxs("div",{className:"flex gap-2 pt-2 border-t border-gray-200 dark:border-slate-700",children:[t.jsx(He,{value:g,onChange:M=>w(M.target.value),placeholder:"Add tool manually...",className:"flex-1 text-sm",onKeyDown:M=>{M.key==="Enter"&&(M.preventDefault(),k())}}),t.jsx(se,{size:"sm",onClick:k,disabled:!g.trim(),children:t.jsx(It,{className:"w-4 h-4"})})]})]}),t.jsxs("div",{className:"flex items-center gap-4 text-xs text-gray-500 dark:text-slate-400 pt-2 border-t border-gray-200 dark:border-slate-700",children:[t.jsxs("span",{className:"flex items-center gap-1",children:[t.jsx("div",{className:"w-3 h-3 rounded bg-green-600"}),"Allow"]}),t.jsxs("span",{className:"flex items-center gap-1",children:[t.jsx("div",{className:"w-3 h-3 rounded bg-amber-600"}),"Ask"]}),t.jsxs("span",{className:"flex items-center gap-1",children:[t.jsx("div",{className:"w-3 h-3 rounded bg-red-600"}),"Deny"]}),t.jsx("span",{className:"flex items-center gap-1 ml-auto",children:t.jsx("span",{className:"text-gray-400",children:"Click again to remove"})})]})]}),t.jsx(jt,{children:t.jsx(se,{variant:"outline",onClick:()=>r(!1),children:"Done"})})]})})})}function b8({mcpServers:e={},permissions:r={allow:[],ask:[],deny:[]},onToggle:s,onUpdatePermission:n,readOnly:o=!1}){const[c,d]=_.useState(!0),[l,u]=_.useState(!1),[f,m]=_.useState(null),h=_.useMemo(()=>Object.keys(e).sort(),[e]),g=v=>{var x;const y=`mcp__${v}__*`;return((x=r.allow)==null?void 0:x.includes(y))||!1},w=v=>{var k,N,P;const y=`mcp__${v}__`,x=`${y}*`;let b=0;return(k=r.allow)==null||k.forEach(A=>{A.startsWith(y)&&A!==x&&b++}),(N=r.ask)==null||N.forEach(A=>{A.startsWith(y)&&A!==x&&b++}),(P=r.deny)==null||P.forEach(A=>{A.startsWith(y)&&A!==x&&b++}),b},j=(v,y)=>{const x=`mcp__${v}__*`;s==null||s(v,x,y)},S=(v,y)=>{y.stopPropagation(),m(v),u(!0)};return h.length===0?null:t.jsxs(t.Fragment,{children:[t.jsxs(Hc,{open:c,onOpenChange:d,className:"mb-6",children:[t.jsx(Wc,{asChild:!0,children:t.jsxs("button",{className:"w-full flex items-center justify-between p-3 rounded-lg border border-gray-200 dark:border-slate-700 hover:bg-gray-50 dark:hover:bg-slate-800/50 transition-colors",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("div",{className:"w-8 h-8 rounded-lg bg-purple-100 dark:bg-purple-950 flex items-center justify-center",children:t.jsx(Ya,{className:"w-4 h-4 text-purple-600 dark:text-purple-400"})}),t.jsxs("div",{className:"text-left",children:[t.jsx("span",{className:"font-medium text-gray-900 dark:text-white",children:"Quick MCP Permissions"}),t.jsxs(rt,{variant:"secondary",className:"ml-2 text-xs",children:[h.length," server",h.length!==1?"s":""]})]})]}),t.jsx(xr,{className:Ee("w-4 h-4 text-gray-500 transition-transform",c&&"rotate-180")})]})}),t.jsx(Uc,{children:t.jsxs("div",{className:"mt-2 rounded-lg border border-gray-200 dark:border-slate-700 divide-y divide-gray-200 dark:divide-slate-700",children:[h.map(v=>{const y=g(v),x=e[v],b=x!=null&&x.command?"stdio":x!=null&&x.url?"sse":"unknown",k=w(v);return t.jsxs("div",{className:"flex items-center justify-between p-3 hover:bg-gray-50 dark:hover:bg-slate-800/50",children:[t.jsx("div",{className:"flex items-center gap-3 flex-1 min-w-0",children:t.jsxs("div",{className:"flex flex-col min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"font-medium text-gray-900 dark:text-white",children:v}),y&&t.jsxs(rt,{variant:"outline",className:"text-xs bg-green-50 dark:bg-green-950 text-green-700 dark:text-green-400 border-green-200 dark:border-green-800",children:[t.jsx(Mt,{className:"w-3 h-3 mr-1"}),"All"]}),!y&&k>0&&t.jsxs(rt,{variant:"outline",className:"text-xs",children:[k," tool",k!==1?"s":""]})]}),t.jsxs("span",{className:"text-xs text-gray-500 dark:text-slate-400 truncate",children:[b==="stdio"&&x.command,b==="sse"&&x.url]})]})}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(se,{variant:"ghost",size:"sm",className:"h-8 px-2",onClick:N=>S(v,N),disabled:o,children:t.jsx(_p,{className:"w-4 h-4"})}),t.jsxs("div",{className:"flex items-center gap-2 pl-2 border-l border-gray-200 dark:border-slate-700",children:[t.jsx("span",{className:"text-xs text-gray-500 dark:text-slate-400 whitespace-nowrap",children:"Allow all"}),t.jsx(_t,{checked:y,onCheckedChange:N=>j(v,N),disabled:o})]})]})]},v)}),t.jsxs("div",{className:"p-3 bg-gray-50 dark:bg-slate-800/50 flex items-start gap-2",children:[t.jsx(Zu,{className:"w-4 h-4 text-gray-400 mt-0.5 flex-shrink-0"}),t.jsxs("p",{className:"text-xs text-gray-500 dark:text-slate-400",children:["Click ",t.jsx(_p,{className:"w-3 h-3 inline mx-0.5"})," to configure specific tool permissions"]})]})]})})]}),f&&t.jsx(y8,{open:l,onOpenChange:u,serverName:f,serverConfig:e[f],permissions:r,onUpdatePermissions:n})]})}function w8({permissions:e,onSave:r,loading:s,readOnly:n=!1,mcpServers:o={}}){const[c,d]=_.useState({allow:[],ask:[],deny:[]}),[l,u]=_.useState("allow"),[f,m]=_.useState(!1),[h,g]=_.useState(!1),[w,j]=_.useState(!1),[S,v]=_.useState(null),[y,x]=_.useState(!1),[b,k]=_.useState("export");_.useEffect(()=>{e&&d({allow:e.allow||[],ask:e.ask||[],deny:e.deny||[]})},[e]);const N=_.useCallback(async W=>{if(!(!r||n)){m(!0);try{await r(W)}catch($){q.error("Failed to save: "+$.message)}finally{m(!1)}}},[r,n]),P=_.useCallback((W,$)=>{d(Y=>{if([...Y.allow,...Y.ask,...Y.deny].includes($))return q.error("This rule already exists"),Y;const L={...Y,[W]:[...Y[W],$]};return N(L),q.success(`Rule added to ${W}`),L})},[N]),A=_.useCallback((W,$,Y,K)=>{d(L=>{const T={...L};return T[W]=T[W].filter(B=>B!==$),T[Y]=[...T[Y],K],N(T),q.success("Rule updated"),T})},[N]),E=_.useCallback((W,$)=>{d(Y=>{const K={...Y,[W]:Y[W].filter(L=>L!==$)};return N(K),q.success("Rule deleted"),K})},[N]);_.useCallback((W,$,Y)=>{d(K=>{const L={...K,[W]:K[W].filter(T=>T!==$),[Y]:[...K[Y],$]};return N(L),q.success(`Moved to ${Y}`),L})},[N]);const M=_.useCallback(W=>{const $={allow:W.allow||[],ask:W.ask||[],deny:W.deny||[]};d($),N($),q.success("Permissions imported")},[N]),I=_.useCallback((W,$,Y)=>{Y?P("allow",$):E("allow",$)},[P,E]),O=_.useCallback((W,$,Y)=>{d(K=>{const L={allow:[...K.allow||[]],ask:[...K.ask||[]],deny:[...K.deny||[]]};return L.allow=L.allow.filter(T=>T!==$),L.ask=L.ask.filter(T=>T!==$),L.deny=L.deny.filter(T=>T!==$),Y==="allow"?L.allow.push($):Y==="ask"?L.ask.push($):Y==="deny"&&L.deny.push($),N(L),L})},[N]),z=W=>{v(null),u(W),j(!0)},U=(W,$)=>{v({category:W,rule:$}),j(!0)},X=c.allow.length+c.ask.length+c.deny.length;return t.jsx(ar,{children:t.jsxs("div",{className:"space-y-6",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("div",{className:"w-10 h-10 rounded-lg bg-indigo-100 dark:bg-indigo-950 flex items-center justify-center",children:t.jsx(Qn,{className:"w-5 h-5 text-indigo-600 dark:text-indigo-400"})}),t.jsxs("div",{children:[t.jsx("h2",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:"Claude Code Permissions"}),t.jsx("p",{className:"text-sm text-gray-500 dark:text-slate-400",children:"Configure what Claude Code can do automatically"})]})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[f&&t.jsxs(rt,{variant:"outline",className:"bg-blue-50 dark:bg-blue-950/50 text-blue-700 dark:text-blue-400 border-blue-200 dark:border-blue-800",children:[t.jsx(Mr,{className:"w-3 h-3 mr-1 animate-spin"}),"Saving..."]}),t.jsxs(Ft,{children:[t.jsx(Bt,{asChild:!0,children:t.jsx(se,{variant:"outline",size:"sm",onClick:()=>{k("export"),x(!0)},children:t.jsx(xi,{className:"w-4 h-4"})})}),t.jsx(Ot,{children:"Export permissions"})]}),t.jsxs(Ft,{children:[t.jsx(Bt,{asChild:!0,children:t.jsx(se,{variant:"outline",size:"sm",onClick:()=>{k("import"),x(!0)},disabled:n,children:t.jsx(Sp,{className:"w-4 h-4"})})}),t.jsx(Ot,{children:"Import permissions"})]})]})]}),t.jsxs(Hc,{open:h,onOpenChange:g,children:[t.jsx(Wc,{asChild:!0,children:t.jsxs(se,{variant:"ghost",size:"sm",className:"text-gray-500 dark:text-slate-400",children:[t.jsx(Fa,{className:"w-4 h-4 mr-2"}),"How permissions work",t.jsx(xr,{className:Ee("w-4 h-4 ml-2 transition-transform",h&&"rotate-180")})]})}),t.jsx(Uc,{children:t.jsxs(Za,{className:"mt-2",children:[t.jsx(Zu,{className:"w-4 h-4"}),t.jsxs(el,{className:"text-sm",children:[t.jsxs("p",{className:"mb-2",children:["Permissions control what Claude Code can do automatically vs. what requires your approval. These settings are stored in ",t.jsx("code",{className:"px-1 py-0.5 bg-gray-100 dark:bg-slate-700 rounded text-xs",children:"~/.claude/settings.json"}),"."]}),t.jsxs("div",{className:"grid grid-cols-3 gap-4 mt-3",children:[t.jsxs("div",{children:[t.jsx(rt,{className:"bg-green-100 dark:bg-green-950 text-green-700 dark:text-green-400 mb-1",children:"Allow"}),t.jsx("p",{className:"text-xs text-gray-600 dark:text-slate-400",children:"Operations run without asking"})]}),t.jsxs("div",{children:[t.jsx(rt,{className:"bg-amber-100 dark:bg-amber-950 text-amber-700 dark:text-amber-400 mb-1",children:"Ask"}),t.jsx("p",{className:"text-xs text-gray-600 dark:text-slate-400",children:"Prompts for confirmation each time"})]}),t.jsxs("div",{children:[t.jsx(rt,{className:"bg-red-100 dark:bg-red-950 text-red-700 dark:text-red-400 mb-1",children:"Deny"}),t.jsx("p",{className:"text-xs text-gray-600 dark:text-slate-400",children:"Blocked entirely"})]})]}),t.jsxs("p",{className:"mt-3 text-xs text-gray-500 dark:text-slate-400",children:["Use wildcards: ",t.jsx("code",{className:"px-1 py-0.5 bg-gray-100 dark:bg-slate-700 rounded",children:"*"})," matches anything,"," ",t.jsx("code",{className:"px-1 py-0.5 bg-gray-100 dark:bg-slate-700 rounded",children:"**"})," matches recursively in paths."]})]})]})})]}),!s&&Object.keys(o).length>0&&t.jsx(b8,{mcpServers:o,permissions:c,onToggle:I,onUpdatePermission:O,readOnly:n}),s&&t.jsx("div",{className:"flex items-center justify-center py-12",children:t.jsx(Mr,{className:"w-6 h-6 animate-spin text-gray-400"})}),!s&&X===0&&t.jsxs(Za,{children:[t.jsx(Gi,{className:"w-4 h-4"}),t.jsxs(el,{children:["No permission rules configured. Claude Code will use default behavior and ask for permission on sensitive operations.",t.jsx(se,{variant:"link",size:"sm",className:"ml-2 p-0 h-auto",onClick:()=>z("allow"),children:"Add your first rule"})]})]}),!s&&t.jsxs($c,{value:l,onValueChange:u,children:[t.jsx(ll,{className:"grid w-full grid-cols-3",children:["allow","ask","deny"].map(W=>{var K;const $=Aw(W),Y=((K=c[W])==null?void 0:K.length)||0;return t.jsxs(Ms,{value:W,className:"flex items-center gap-2",children:[t.jsx("div",{className:Ee("w-2 h-2 rounded-full",W==="allow"&&"bg-green-500",W==="ask"&&"bg-amber-500",W==="deny"&&"bg-red-500")}),$.label,Y>0&&t.jsx(rt,{variant:"secondary",className:"ml-1 text-xs",children:Y})]},W)})}),["allow","ask","deny"].map(W=>{const $=Aw(W),Y=c[W]||[],K=u8(Y);return t.jsxs(Hn,{value:W,className:"space-y-3",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs(Ft,{children:[t.jsx(Bt,{asChild:!0,children:t.jsx("p",{className:"text-sm text-gray-500 dark:text-slate-400 cursor-help",children:$.description})}),t.jsx(Ot,{className:"max-w-xs",children:c8(W)})]}),t.jsxs(se,{size:"sm",variant:"outline",onClick:()=>z(W),disabled:n,children:[t.jsx(It,{className:"w-4 h-4 mr-1"}),"Add Rules"]})]}),Y.length===0?t.jsxs("div",{className:Ee("text-center py-8 rounded-lg border-2 border-dashed",$.borderColor),children:[t.jsxs("p",{className:"text-gray-500 dark:text-slate-400",children:["No rules in ",W]}),t.jsx(se,{variant:"link",size:"sm",onClick:()=>z(W),disabled:n,children:"Add rules"})]}):t.jsx("div",{className:"space-y-2",children:K.map(({type:L,rules:T})=>t.jsx(f8,{type:L,rules:T,category:W,onEdit:B=>U(W,B),onDelete:B=>E(W,B),onAddRule:()=>z(W),readOnly:n},L))})]},W)})]}),t.jsx(m8,{open:w,onOpenChange:j,onSubmit:(W,$)=>{S?A(S.category,S.rule,W,$):P(W,$)},defaultCategory:(S==null?void 0:S.category)||l,defaultRule:(S==null?void 0:S.rule)||"",isEditing:!!S,existingRules:[...c.allow,...c.ask,...c.deny]}),t.jsx(v8,{open:y,onOpenChange:x,mode:b,permissions:c,onImport:M})]})})}const _8=[{id:"claude-opus-4-6",name:"Claude Opus 4.6",description:"Most capable, best for complex tasks",tier:"opus",recommended:!0},{id:"claude-sonnet-4-6",name:"Claude Sonnet 4.6",description:"Fast output, great balance of speed and capability",tier:"sonnet"},{id:"claude-sonnet-4-5-20250929",name:"Claude Sonnet 4.5",description:"Previous generation, balanced",tier:"sonnet"},{id:"claude-haiku-4-5-20251001",name:"Claude Haiku 4.5",description:"Fastest, best for simple tasks",tier:"haiku"}],S8=[{value:"low",label:"Low",description:"Faster, less thorough"},{value:"medium",label:"Medium",description:"Balanced"},{value:"high",label:"High",description:"Most thorough reasoning"}],C8=[{value:"default",label:"Default",description:"Ask for most tool uses"},{value:"plan",label:"Plan",description:"Read-only, no edits allowed"},{value:"acceptEdits",label:"Accept Edits",description:"Auto-approve file edits"},{value:"auto",label:"Auto",description:"AI classifies safe vs risky actions"},{value:"dontAsk",label:"Don't Ask",description:"Auto-approve most actions"},{value:"bypassPermissions",label:"Bypass Permissions",description:"No restrictions (dangerous)"}],k8=[{value:"auto",label:"Auto"},{value:"in-process",label:"In-process"},{value:"tmux",label:"Tmux"}],j8=[{key:"ANTHROPIC_SMALL_FAST_MODEL",label:"Small/Fast Model",description:"Model for background tasks and quick operations",placeholder:"claude-haiku-4-5-20251001"},{key:"CLAUDE_CODE_SUBAGENT_MODEL",label:"Subagent Model",description:"Model used for subagent/background processing",placeholder:"claude-haiku-4-5-20251001"},{key:"MAX_THINKING_TOKENS",label:"Max Thinking Tokens",description:"Extended thinking budget (0 to disable)",placeholder:"5000"},{key:"CLAUDE_CODE_MAX_OUTPUT_TOKENS",label:"Max Output Tokens",description:"Maximum output tokens per response (32000-64000)",placeholder:"32000"},{key:"BASH_DEFAULT_TIMEOUT_MS",label:"Bash Default Timeout (ms)",description:"Default timeout for bash commands",placeholder:"120000"},{key:"BASH_MAX_TIMEOUT_MS",label:"Bash Max Timeout (ms)",description:"Maximum allowed timeout for bash commands",placeholder:"600000"},{key:"CLAUDE_AUTOCOMPACT_PCT_OVERRIDE",label:"Auto-compact Threshold (%)",description:"Context usage percentage to trigger auto-compaction (1-100)",placeholder:"75"},{key:"MCP_TIMEOUT",label:"MCP Startup Timeout (ms)",description:"Timeout for MCP server startup",placeholder:"10000"},{key:"MCP_TOOL_TIMEOUT",label:"MCP Tool Timeout (ms)",description:"Timeout for MCP tool execution",placeholder:"30000"}],Rw=["permissions","model","modelOverrides","effortLevel","availableModels","alwaysThinkingEnabled","showThinkingSummaries","enableAllProjectMcpServers","respectGitignore","cleanupPeriodDays","plansDirectory","disableAllHooks","language","teammateMode","outputStyle","attribution","sandbox","env","hooks","voiceEnabled","autoMemoryEnabled","autoMemoryDirectory","defaultShell","worktree","autoUpdatesChannel","prefersReducedMotion","claudeMdExcludes","disableSkillShellExecution"];function zr({label:e,description:r,checked:s,onCheckedChange:n}){return t.jsxs("div",{className:"flex items-center justify-between p-4 rounded-lg border border-gray-200 dark:border-slate-700",children:[t.jsxs("div",{children:[t.jsx(Ze,{children:e}),t.jsx("p",{className:"text-sm text-gray-500 dark:text-slate-400",children:r})]}),t.jsx(_t,{checked:s,onCheckedChange:n})]})}function kN({settings:e,onSave:r,loading:s,settingsPath:n="~/.claude/settings.json",mcpServers:o={}}){var O,z,U,X,W,$,Y,K,L,T,B,G,F,re,ue,he,J,H,ae,ie,Z,ce,Ce,Re,We,pe,_e,Be,Ve,Je,Ct,Se,me,be;const[c,d]=_.useState({}),[l,u]=_.useState("permissions"),[f,m]=_.useState(!1),[h,g]=_.useState(!1),[w,j]=_.useState(""),[S,v]=_.useState(null),y=_.useRef(null);_.useEffect(()=>{e&&(d(e),j(JSON.stringify(e,null,2)))},[e]),_.useEffect(()=>{h||j(JSON.stringify(c,null,2))},[c,h]);const x=_.useCallback(async ee=>{if(r){m(!0);try{await r(ee)}catch(oe){q.error("Failed to save: "+oe.message)}finally{m(!1)}}},[r]),b=_.useCallback(ee=>{y.current&&clearTimeout(y.current),y.current=setTimeout(()=>x(ee),800)},[x]),k=_.useCallback((ee,oe,we=!1)=>{d(ke=>{const Oe={...ke,[ee]:oe};return(oe===""||oe===null||oe===void 0)&&delete Oe[ee],we?x(Oe):b(Oe),Oe})},[x,b]),N=_.useCallback((ee,oe,we,ke=!0)=>{d(Oe=>{const $e={...Oe[ee]||{},[oe]:we};(we===""||we===null||we===void 0)&&delete $e[oe];const ct={...Oe};return Object.keys($e).length?ct[ee]=$e:delete ct[ee],ke?x(ct):b(ct),ct})},[x,b]),P=_.useCallback((ee,oe,we,ke,Oe=!0)=>{d($e=>{const ct={...$e[ee]||{}},st={...ct[oe]||{},[we]:ke};(ke===""||ke===null||ke===void 0)&&delete st[we],Object.keys(st).length?ct[oe]=st:delete ct[oe];const Ht={...$e};return Object.keys(ct).length?Ht[ee]=ct:delete Ht[ee],Oe?x(Ht):b(Ht),Ht})},[x,b]),A=_.useCallback(async ee=>{const oe={...c,permissions:ee};d(oe),await x(oe)},[c,x]),E=ee=>{j(ee);try{JSON.parse(ee),v(null)}catch(oe){v(oe.message)}},M=async()=>{if(S){q.error("Fix JSON errors before saving");return}try{const ee=JSON.parse(w);d(ee),await x(ee),q.success("Settings applied")}catch{q.error("Invalid JSON")}},I=ee=>{const oe=ee?ee.split(",").map(we=>we.trim()).filter(Boolean):[];return oe.length?oe:void 0};return t.jsxs("div",{className:"space-y-6",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("div",{className:"w-10 h-10 rounded-lg bg-indigo-100 dark:bg-indigo-950 flex items-center justify-center",children:t.jsx(hn,{className:"w-5 h-5 text-indigo-600 dark:text-indigo-400"})}),t.jsxs("div",{children:[t.jsx("h2",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:"Claude Code Settings"}),t.jsx("p",{className:"text-sm text-gray-500 dark:text-slate-400",children:"Configure Claude Code behavior globally"})]})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[f&&t.jsxs(rt,{variant:"outline",className:"bg-blue-50 dark:bg-blue-950/50 text-blue-700 dark:text-blue-400 border-blue-200 dark:border-blue-800",children:[t.jsx(Mr,{className:"w-3 h-3 mr-1 animate-spin"}),"Saving..."]}),t.jsx(ar,{children:t.jsxs(Ft,{children:[t.jsx(Bt,{asChild:!0,children:t.jsx(se,{variant:"outline",size:"sm",onClick:()=>g(!h),children:h?t.jsx(Lg,{className:"w-4 h-4"}):t.jsx(J5,{className:"w-4 h-4"})})}),t.jsx(Ot,{children:h?"Show UI":"Show JSON"})]})})]})]}),t.jsxs("p",{className:"text-sm text-gray-500 dark:text-slate-400",children:["Settings file: ",t.jsx("code",{className:"bg-gray-100 dark:bg-slate-800 px-2 py-0.5 rounded text-xs",children:n})]}),s&&t.jsx("div",{className:"flex items-center justify-center py-12",children:t.jsx(Mr,{className:"w-6 h-6 animate-spin text-gray-400"})}),!s&&h&&t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx(Ze,{children:"Raw JSON"}),t.jsxs("div",{className:"flex items-center gap-2",children:[S&&t.jsx(rt,{variant:"destructive",className:"text-xs",children:S}),t.jsxs(se,{size:"sm",onClick:M,disabled:f||!!S,className:"bg-indigo-600 hover:bg-indigo-700 text-white",children:[t.jsx(Mt,{className:"w-4 h-4 mr-1"}),"Apply JSON"]})]})]}),t.jsx(ft,{value:w,onChange:ee=>E(ee.target.value),className:Ee("font-mono text-sm min-h-[400px]",S&&"border-red-300 focus:border-red-500")})]}),!s&&!h&&t.jsxs($c,{value:l,onValueChange:u,children:[t.jsxs(ll,{className:"grid w-full grid-cols-5",children:[t.jsxs(Ms,{value:"permissions",className:"flex items-center gap-2",children:[t.jsx(Qn,{className:"w-4 h-4"}),"Permissions"]}),t.jsxs(Ms,{value:"model",className:"flex items-center gap-2",children:[t.jsx(Io,{className:"w-4 h-4"}),"Model"]}),t.jsxs(Ms,{value:"behavior",className:"flex items-center gap-2",children:[t.jsx(hn,{className:"w-4 h-4"}),"Behavior"]}),t.jsxs(Ms,{value:"sandbox",className:"flex items-center gap-2",children:[t.jsx(DM,{className:"w-4 h-4"}),"Sandbox"]}),t.jsxs(Ms,{value:"advanced",className:"flex items-center gap-2",children:[t.jsx(Ut,{className:"w-4 h-4"}),"Advanced"]})]}),t.jsxs(Hn,{value:"permissions",className:"space-y-6 pt-4",children:[t.jsx(w8,{permissions:c.permissions,onSave:A,loading:!1,mcpServers:o}),t.jsxs("div",{className:"space-y-4 pt-2",children:[t.jsx(Ze,{className:"text-base font-medium",children:"Permission Defaults"}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(Ze,{className:"text-sm",children:"Default Permission Mode"}),t.jsx("p",{className:"text-xs text-gray-500 dark:text-slate-400",children:"Starting permission mode for new sessions"}),t.jsxs(vr,{value:((O=c.permissions)==null?void 0:O.defaultMode)||"default",onValueChange:ee=>N("permissions","defaultMode",ee==="default"?void 0:ee),children:[t.jsx(hr,{children:t.jsx(yr,{})}),t.jsx(fr,{children:C8.map(ee=>t.jsx(At,{value:ee.value,children:ee.label},ee.value))})]})]}),t.jsx(zr,{label:"Disable Bypass Permissions Mode",description:"Prevent using dangerously-skip-permissions flag",checked:((z=c.permissions)==null?void 0:z.disableBypassPermissionsMode)==="disable",onCheckedChange:ee=>N("permissions","disableBypassPermissionsMode",ee?"disable":void 0)}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(Ze,{className:"text-sm",children:"Additional Directories"}),t.jsx("p",{className:"text-xs text-gray-500 dark:text-slate-400",children:"Extra paths Claude can access (comma-separated)"}),t.jsx(He,{value:(((U=c.permissions)==null?void 0:U.additionalDirectories)||[]).join(", "),onChange:ee=>N("permissions","additionalDirectories",I(ee.target.value),!1),placeholder:"~/other-project, /shared/docs",className:"font-mono text-sm"})]})]})]}),t.jsx(Hn,{value:"model",className:"space-y-6 pt-4",children:t.jsxs("div",{className:"space-y-6",children:[t.jsxs("div",{children:[t.jsx(Ze,{className:"text-base font-medium",children:"Default Model"}),t.jsx("p",{className:"text-sm text-gray-500 dark:text-slate-400 mb-3",children:"Select the default model for Claude Code sessions"}),t.jsx("div",{className:"grid gap-3",children:_8.map(ee=>t.jsx("button",{onClick:()=>k("model",ee.id,!0),className:Ee("w-full p-4 rounded-lg border text-left transition-all",c.model===ee.id?"border-indigo-500 bg-indigo-50 dark:bg-indigo-950/50":"border-gray-200 dark:border-slate-700 hover:border-gray-300 dark:hover:border-slate-600"),children:t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"font-medium",children:ee.name}),ee.recommended&&t.jsx(rt,{variant:"secondary",className:"text-xs",children:"Recommended"}),t.jsx(rt,{variant:"outline",className:Ee("text-xs",ee.tier==="opus"&&"border-purple-300 text-purple-700",ee.tier==="sonnet"&&"border-blue-300 text-blue-700",ee.tier==="haiku"&&"border-green-300 text-green-700"),children:ee.tier})]}),t.jsx("p",{className:"text-sm text-gray-500 dark:text-slate-400 mt-1",children:ee.description})]}),c.model===ee.id&&t.jsx(Mt,{className:"w-5 h-5 text-indigo-600 dark:text-indigo-400"})]})},ee.id))})]}),t.jsxs("div",{children:[t.jsx(Ze,{className:"text-base font-medium",children:"Effort Level"}),t.jsx("p",{className:"text-sm text-gray-500 dark:text-slate-400 mb-3",children:"Opus reasoning effort (affects speed vs thoroughness)"}),t.jsx("div",{className:"grid grid-cols-3 gap-3",children:S8.map(ee=>t.jsxs("button",{onClick:()=>k("effortLevel",ee.value,!0),className:Ee("p-3 rounded-lg border text-left transition-all",c.effortLevel===ee.value?"border-indigo-500 bg-indigo-50 dark:bg-indigo-950/50":"border-gray-200 dark:border-slate-700 hover:border-gray-300 dark:hover:border-slate-600"),children:[t.jsx("span",{className:"font-medium text-sm",children:ee.label}),t.jsx("p",{className:"text-xs text-gray-500 dark:text-slate-400 mt-1",children:ee.description})]},ee.value))})]}),t.jsx(zr,{label:"Always Enable Extended Thinking",description:"Enable extended thinking by default for all conversations",checked:c.alwaysThinkingEnabled??!1,onCheckedChange:ee=>k("alwaysThinkingEnabled",ee,!0)}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(Ze,{children:"Restrict Available Models"}),t.jsx("p",{className:"text-xs text-gray-500 dark:text-slate-400",children:"Comma-separated list of model aliases users can select (empty = all)"}),t.jsx(He,{value:(c.availableModels||[]).join(", "),onChange:ee=>k("availableModels",I(ee.target.value)),placeholder:"opus, sonnet, haiku",className:"font-mono text-sm"})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(Ze,{children:"Custom Model ID"}),t.jsx("p",{className:"text-xs text-gray-500 dark:text-slate-400",children:"Override with a specific model ID (for AWS Bedrock, etc.)"}),t.jsx(He,{value:c.model||"",onChange:ee=>k("model",ee.target.value),placeholder:"claude-opus-4-6",className:"font-mono"})]})]})}),t.jsx(Hn,{value:"behavior",className:"space-y-6 pt-4",children:t.jsxs("div",{className:"space-y-4",children:[t.jsx(Ze,{className:"text-base font-medium",children:"Session Behavior"}),t.jsx(zr,{label:"Respect .gitignore",description:"Honor .gitignore patterns when searching files",checked:c.respectGitignore??!0,onCheckedChange:ee=>k("respectGitignore",ee,!0)}),t.jsx(zr,{label:"Show Thinking Summaries",description:"Display summaries of extended thinking",checked:c.showThinkingSummaries??!1,onCheckedChange:ee=>k("showThinkingSummaries",ee,!0)}),t.jsx(zr,{label:"Voice Dictation",description:"Enable push-to-talk voice input",checked:c.voiceEnabled??!1,onCheckedChange:ee=>k("voiceEnabled",ee,!0)}),t.jsx(zr,{label:"Reduced Motion",description:"Reduce UI animations",checked:c.prefersReducedMotion??!1,onCheckedChange:ee=>k("prefersReducedMotion",ee,!0)}),t.jsx(Ze,{className:"text-base font-medium pt-2",children:"Memory"}),t.jsx(zr,{label:"Auto Memory",description:"Allow Claude to automatically save notes across sessions",checked:c.autoMemoryEnabled??!0,onCheckedChange:ee=>k("autoMemoryEnabled",ee,!0)}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(Ze,{className:"text-sm",children:"Auto Memory Directory"}),t.jsx("p",{className:"text-xs text-gray-500 dark:text-slate-400",children:"Custom path for auto-memory storage"}),t.jsx(He,{value:c.autoMemoryDirectory||"",onChange:ee=>k("autoMemoryDirectory",ee.target.value),placeholder:"~/.claude/projects/<project>/memory",className:"font-mono text-sm"})]}),t.jsx(Ze,{className:"text-base font-medium pt-2",children:"MCP & Servers"}),t.jsx(zr,{label:"Enable All Project MCP Servers",description:"Auto-approve all MCP servers defined in project .mcp.json",checked:c.enableAllProjectMcpServers??!1,onCheckedChange:ee=>k("enableAllProjectMcpServers",ee,!0)}),t.jsx(Ze,{className:"text-base font-medium pt-2",children:"Hooks"}),t.jsx(zr,{label:"Disable All Hooks",description:"Kill switch to disable all hook scripts",checked:c.disableAllHooks??!1,onCheckedChange:ee=>k("disableAllHooks",ee,!0)}),t.jsx(Ze,{className:"text-base font-medium pt-2",children:"Display"}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(Ze,{className:"text-sm",children:"Language"}),t.jsx("p",{className:"text-xs text-gray-500 dark:text-slate-400",children:"Response language preference"}),t.jsx(He,{value:c.language||"",onChange:ee=>k("language",ee.target.value),placeholder:"english",className:"font-mono text-sm"})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(Ze,{className:"text-sm",children:"Output Style"}),t.jsx("p",{className:"text-xs text-gray-500 dark:text-slate-400",children:"Named output style for responses"}),t.jsx(He,{value:c.outputStyle||"",onChange:ee=>k("outputStyle",ee.target.value),placeholder:"concise",className:"font-mono text-sm"})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(Ze,{className:"text-sm",children:"Teammate Mode"}),t.jsx("p",{className:"text-xs text-gray-500 dark:text-slate-400",children:"How agent team teammates are displayed"}),t.jsxs(vr,{value:c.teammateMode||"auto",onValueChange:ee=>k("teammateMode",ee==="auto"?void 0:ee,!0),children:[t.jsx(hr,{children:t.jsx(yr,{})}),t.jsx(fr,{children:k8.map(ee=>t.jsx(At,{value:ee.value,children:ee.label},ee.value))})]})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(Ze,{className:"text-sm",children:"Default Shell"}),t.jsx("p",{className:"text-xs text-gray-500 dark:text-slate-400",children:"Shell used for bash commands"}),t.jsxs(vr,{value:c.defaultShell||"bash",onValueChange:ee=>k("defaultShell",ee==="bash"?void 0:ee,!0),children:[t.jsx(hr,{children:t.jsx(yr,{})}),t.jsxs(fr,{children:[t.jsx(At,{value:"bash",children:"Bash"}),t.jsx(At,{value:"powershell",children:"PowerShell"})]})]})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(Ze,{className:"text-sm",children:"Auto-updates Channel"}),t.jsx("p",{className:"text-xs text-gray-500 dark:text-slate-400",children:"Release channel for auto-updates"}),t.jsxs(vr,{value:c.autoUpdatesChannel||"latest",onValueChange:ee=>k("autoUpdatesChannel",ee==="latest"?void 0:ee,!0),children:[t.jsx(hr,{children:t.jsx(yr,{})}),t.jsxs(fr,{children:[t.jsx(At,{value:"latest",children:"Latest (default)"}),t.jsx(At,{value:"stable",children:"Stable"})]})]})]}),t.jsx(Ze,{className:"text-base font-medium pt-2",children:"Worktree"}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(Ze,{className:"text-sm",children:"Symlink Directories"}),t.jsx("p",{className:"text-xs text-gray-500 dark:text-slate-400",children:"Directories to symlink into worktrees (comma-separated)"}),t.jsx(He,{value:(((X=c.worktree)==null?void 0:X.symlinkDirectories)||[]).join(", "),onChange:ee=>N("worktree","symlinkDirectories",I(ee.target.value),!1),placeholder:"node_modules, .venv",className:"font-mono text-sm"})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(Ze,{className:"text-sm",children:"Sparse Paths"}),t.jsx("p",{className:"text-xs text-gray-500 dark:text-slate-400",children:"Git sparse-checkout paths for worktrees (comma-separated)"}),t.jsx(He,{value:(((W=c.worktree)==null?void 0:W.sparsePaths)||[]).join(", "),onChange:ee=>N("worktree","sparsePaths",I(ee.target.value),!1),placeholder:"src/, lib/",className:"font-mono text-sm"})]}),t.jsx(Ze,{className:"text-base font-medium pt-2",children:"Paths & Cleanup"}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(Ze,{className:"text-sm",children:"Plans Directory"}),t.jsx("p",{className:"text-xs text-gray-500 dark:text-slate-400",children:"Directory where plan files are saved"}),t.jsx(He,{value:c.plansDirectory||"",onChange:ee=>k("plansDirectory",ee.target.value),placeholder:"./plans",className:"font-mono text-sm"})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(Ze,{className:"text-sm",children:"Cleanup Period (days)"}),t.jsx("p",{className:"text-xs text-gray-500 dark:text-slate-400",children:"Auto-cleanup interval for old session data (min: 1)"}),t.jsx(He,{type:"number",min:"1",value:c.cleanupPeriodDays??"",onChange:ee=>k("cleanupPeriodDays",ee.target.value?Math.max(1,Number(ee.target.value)):void 0),placeholder:"30",className:"font-mono text-sm w-32"})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(Ze,{className:"text-sm",children:"CLAUDE.md Excludes"}),t.jsx("p",{className:"text-xs text-gray-500 dark:text-slate-400",children:"Glob patterns to skip specific CLAUDE.md files (comma-separated)"}),t.jsx(He,{value:(c.claudeMdExcludes||[]).join(", "),onChange:ee=>k("claudeMdExcludes",I(ee.target.value)),placeholder:"packages/legacy/CLAUDE.md",className:"font-mono text-sm"})]}),t.jsx(zr,{label:"Disable Skill Shell Execution",description:"Prevent skills/commands from running shell commands",checked:c.disableSkillShellExecution??!1,onCheckedChange:ee=>k("disableSkillShellExecution",ee,!0)}),t.jsx(Ze,{className:"text-base font-medium pt-2",children:"Attribution"}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(Ze,{className:"text-sm",children:"Commit Attribution"}),t.jsx("p",{className:"text-xs text-gray-500 dark:text-slate-400",children:"Template appended to commit messages"}),t.jsx(ft,{value:(($=c.attribution)==null?void 0:$.commit)||"",onChange:ee=>N("attribution","commit",ee.target.value||void 0,!1),placeholder:`Generated with AI
616
+ }`,className:"font-mono text-sm bg-gray-50 dark:bg-slate-800",rows:12}),t.jsxs("p",{className:"text-xs text-gray-500 dark:text-slate-400 mt-2",children:["Accepts formats: ",t.jsx("code",{className:"bg-gray-100 dark:bg-slate-700 px-1 rounded",children:'{ "name": { "command": "...", "args": [...] } }'})," or ",t.jsx("code",{className:"bg-gray-100 dark:bg-slate-700 px-1 rounded",children:'{ "mcpServers": { ... } }'})]})]}),t.jsxs(jt,{children:[t.jsx(se,{variant:"ghost",onClick:()=>r(!1),children:"Cancel"}),t.jsxs(se,{onClick:c,className:"bg-blue-600 hover:bg-blue-700 text-white",children:[t.jsx(It,{className:"w-4 h-4 mr-2"}),"Add MCP"]})]})]})})}function KB({content:e,parsed:r,onSave:s,registry:n,configDir:o}){const[c,d]=_.useState(r||{include:[],exclude:[],mcpServers:{}}),[l,u]=_.useState("rich"),[f,m]=_.useState(JSON.stringify(r||{},null,2)),[h,g]=_.useState(!1),[w,j]=_.useState({open:!1,json:""}),[S,v]=_.useState({open:!1,name:"",json:""}),[y,x]=_.useState([]),[b,k]=_.useState(!1),[N,P]=_.useState(!1);_.useEffect(()=>{d(r||{include:[],exclude:[],mcpServers:{}}),m(JSON.stringify(r||{},null,2))},[r]),_.useEffect(()=>{o?fe.getInheritedMcps(o).then($=>{x($.inherited||[]),k($.needsApply||!1)}).catch(()=>{x([]),k(!1)}):(x([]),k(!1))},[o,r]);const A=async $=>{g(!0);try{await s(JSON.stringify($,null,2))}catch(Y){q.error("Failed to save: "+Y.message)}finally{g(!1)}},E=$=>{var L;const Y=(L=c.include)!=null&&L.includes($)?c.include.filter(T=>T!==$):[...c.include||[],$],K={...c,include:Y};d(K),m(JSON.stringify(K,null,2)),A(K)},M=$=>{const Y=c.exclude||[],K=Y.includes($),L=K?Y.filter(B=>B!==$):[...Y,$],T=L.length>0?{...c,exclude:L}:{...c};L.length===0&&delete T.exclude,d(T),m(JSON.stringify(T,null,2)),A(T),q.success(K?`Unblocked ${$}`:`Blocked ${$}`)},I=()=>{try{const $=JSON.parse(f);d($),A($)}catch{q.error("Invalid JSON")}},O=$=>{var K;if((K=c.exclude)==null?void 0:K.includes($)){const L=(c.exclude||[]).filter(B=>B!==$),T=L.length>0?{...c,exclude:L}:{...c};L.length===0&&delete T.exclude,d(T),m(JSON.stringify(T,null,2)),A(T),q.success(`Enabled ${$}`)}else{const L=[...c.exclude||[],$],T={...c,exclude:L};d(T),m(JSON.stringify(T,null,2)),A(T),q.success(`Disabled ${$}`)}},z=()=>{try{const $=JSON.parse(S.json),Y={...c.mcpServers,[S.name]:$},K={...c,mcpServers:Y};d(K),m(JSON.stringify(K,null,2)),A(K),q.success(`Updated ${S.name}`),v({open:!1,name:"",json:""})}catch{q.error("Invalid JSON")}},U=$=>{const Y={...c.mcpServers||{},...$},K={...c,mcpServers:Y};d(K),m(JSON.stringify(K,null,2)),A(K);const L=Object.keys($).length;q.success(`Added ${L} MCP${L>1?"s":""}`),j({open:!1,json:""})},X=n!=null&&n.mcpServers?Object.keys(n.mcpServers):[],W=async()=>{if(o){P(!0);try{const $=await fe.applyCascade(o);if($.success){const Y=$.applied>1?`Applied to ${$.applied} projects`:"Generated .mcp.json";q.success(Y),k(!1)}else $.applied===0&&$.skipped>0?(q.info("No changes needed"),k(!1)):q.error($.error||"Failed to apply")}catch($){q.error("Failed to apply: "+$.message)}finally{P(!1)}}};return t.jsxs("div",{className:"h-full flex flex-col",children:[t.jsxs("div",{className:"flex items-center justify-between p-3 border-b bg-gray-50 dark:bg-slate-800",children:[t.jsx($c,{value:l,onValueChange:u,children:t.jsxs(ll,{className:"h-8",children:[t.jsx(Ms,{value:"rich",className:"text-xs px-3",children:"Rich Editor"}),t.jsx(Ms,{value:"json",className:"text-xs px-3",children:"JSON"})]})}),t.jsxs("div",{className:"flex gap-2 items-center",children:[h&&t.jsx(rt,{variant:"outline",className:"text-xs text-blue-600",children:"Saving..."}),t.jsxs(se,{size:"sm",variant:"outline",onClick:()=>j({open:!0,json:""}),children:[t.jsx(It,{className:"w-4 h-4 mr-1"}),"Add MCP"]}),l==="json"&&t.jsxs(se,{size:"sm",onClick:I,disabled:h,children:[t.jsx(bs,{className:"w-4 h-4 mr-1"}),"Apply JSON"]})]})]}),b&&t.jsxs("div",{className:"mx-3 mt-3 p-3 rounded-lg bg-amber-50 dark:bg-amber-950/30 border border-amber-200 dark:border-amber-800 flex items-center justify-between",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(Is,{className:"w-4 h-4 text-amber-600"}),t.jsxs("span",{className:"text-sm text-amber-800 dark:text-amber-200",children:["No ",t.jsx("code",{className:"bg-amber-100 dark:bg-amber-900 px-1 rounded",children:".mcp.json"})," generated yet. Apply to enable MCPs."]})]}),t.jsx(se,{size:"sm",variant:"outline",onClick:W,disabled:N,className:"border-amber-300 dark:border-amber-700 text-amber-700 dark:text-amber-300 hover:bg-amber-100 dark:hover:bg-amber-900",children:N?t.jsx("span",{className:"animate-pulse",children:"Applying..."}):t.jsxs(t.Fragment,{children:[t.jsx(Io,{className:"w-3 h-3 mr-1"}),"Apply"]})})]}),t.jsx(Xs,{className:"flex-1",children:l==="rich"?t.jsx(ar,{children:t.jsxs("div",{className:"p-4 space-y-2",children:[Object.entries(c.mcpServers||{}).map(([$,Y])=>{var L,T;const K=(L=c.exclude)==null?void 0:L.includes($);return t.jsxs("div",{className:`p-2 rounded border group ${K?"bg-gray-50 dark:bg-slate-900 border-gray-200 dark:border-slate-700":"bg-white dark:bg-slate-950"}`,children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(ys,{className:`w-4 h-4 ${K?"text-gray-400":"text-green-500"}`}),t.jsx("span",{className:`text-sm font-medium ${K?"text-gray-400 line-through":""}`,children:$}),t.jsx(rt,{variant:"outline",className:"text-xs",children:"inline"})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(se,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0 opacity-0 group-hover:opacity-100 text-gray-500 hover:text-gray-700 hover:bg-gray-100 dark:hover:bg-slate-800",onClick:()=>{v({open:!0,name:$,json:JSON.stringify(Y,null,2)})},children:t.jsx(sl,{className:"w-3.5 h-3.5"})}),t.jsx(se,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0 opacity-0 group-hover:opacity-100 text-red-500 hover:text-red-700 hover:bg-red-50 dark:hover:bg-red-950",onClick:()=>{var re;const{[$]:B,...G}=c.mcpServers,F={...c,mcpServers:G};(re=F.exclude)!=null&&re.includes($)&&(F.exclude=F.exclude.filter(ue=>ue!==$),F.exclude.length===0&&delete F.exclude),d(F),m(JSON.stringify(F,null,2)),A(F),q.success(`Removed ${$}`)},children:t.jsx(ws,{className:"w-3.5 h-3.5"})}),t.jsx(_t,{checked:!K,onCheckedChange:()=>O($)})]})]}),t.jsx("p",{className:`text-xs mt-1 font-mono ${K?"text-gray-400":"text-gray-500 dark:text-slate-400"}`,children:Y.url?`${Y.type||"http"}: ${Y.url}`:`${Y.command} ${((T=Y.args)==null?void 0:T.join(" "))||""}`})]},`inline-${$}`)}),y.map($=>{var K;const Y=(K=c.exclude)==null?void 0:K.includes($.name);return t.jsxs(Ft,{children:[t.jsx(Bt,{asChild:!0,children:t.jsxs("div",{className:`flex items-center justify-between p-2 rounded border ${Y?"bg-red-50 dark:bg-red-950/20 border-red-200 dark:border-red-800":"bg-gray-50 dark:bg-slate-900 border-gray-200 dark:border-slate-700"}`,children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(ys,{className:`w-4 h-4 ${Y?"text-red-400":"text-gray-400"}`}),t.jsx("span",{className:`text-sm ${Y?"text-red-500 line-through":"text-gray-500 dark:text-slate-400"}`,children:$.name}),t.jsxs(rt,{variant:"outline",className:"text-[10px] text-gray-400 border-gray-300 dark:border-slate-600",children:["from ",$.source]})]}),t.jsx(_t,{checked:!Y,onCheckedChange:()=>{Y||q.warning(`Blocking "${$.name}" inherited from ${$.source}`),M($.name)},className:"data-[state=checked]:bg-gray-400 dark:data-[state=checked]:bg-slate-600"})]})}),t.jsxs(Ot,{children:[t.jsxs("p",{children:["Inherited from ",t.jsx("strong",{children:$.source})]}),t.jsx("p",{className:"text-xs text-gray-400",children:Y?"Blocked at this level":"Toggle off to block"})]})]},`inherited-${$.name}`)}),X.map($=>{var L,T;const Y=y.some(B=>B.name===$),K=(L=c.mcpServers)==null?void 0:L[$];return Y||K?null:t.jsxs("div",{className:"flex items-center justify-between p-2 rounded border bg-white dark:bg-slate-950",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(ys,{className:"w-4 h-4 text-blue-500"}),t.jsx("span",{className:"text-sm",children:$})]}),t.jsx(_t,{checked:(T=c.include)==null?void 0:T.includes($),onCheckedChange:()=>E($)})]},$)}),X.length===0&&y.length===0&&Object.keys(c.mcpServers||{}).length===0&&t.jsx("p",{className:"text-sm text-gray-500 dark:text-slate-400",children:'No MCPs configured. Click "Add MCP" to add one.'})]})}):t.jsx(ft,{className:"w-full h-full min-h-[400px] font-mono text-sm border-0 rounded-none resize-none",value:f,onChange:$=>m($.target.value)})}),t.jsx(vN,{open:w.open,onClose:$=>j({...w,open:$}),onAdd:U}),t.jsx(bt,{open:S.open,onOpenChange:$=>v({...S,open:$}),children:t.jsxs(mt,{className:"bg-white dark:bg-slate-950 max-w-2xl",children:[t.jsxs(pt,{children:[t.jsxs(gt,{children:["Edit MCP: ",S.name]}),t.jsx(sr,{children:"Modify the MCP configuration JSON."})]}),t.jsx("div",{className:"py-4",children:t.jsx(ft,{value:S.json,onChange:$=>v({...S,json:$.target.value}),className:"font-mono text-sm bg-gray-50 dark:bg-slate-800",rows:12})}),t.jsxs(jt,{children:[t.jsx(se,{variant:"ghost",onClick:()=>v({open:!1,name:"",json:""}),children:"Cancel"}),t.jsxs(se,{onClick:z,className:"bg-blue-600 hover:bg-blue-700 text-white",children:[t.jsx(bs,{className:"w-4 h-4 mr-2"}),"Save Changes"]})]})]})})]})}function Ew({content:e,onSave:r,fileType:s}){const[n,o]=_.useState(e||""),[c,d]=_.useState(!1),l=_.useRef(null),u=_.useRef(null),f=_.useRef(e);_.useEffect(()=>{o(e||""),e!==f.current&&(f.current=e,setTimeout(()=>{if(u.current){u.current.focus();const w=(e||"").length;u.current.setSelectionRange(w,w)}},100))},[e]);const m=_.useCallback(w=>{l.current&&clearTimeout(l.current),l.current=setTimeout(async()=>{d(!0);try{await r(w)}finally{d(!1)}},2500)},[r]),h=w=>{const j=w.target.value;o(j),m(j)},g=wc[s]||wc.claudemd;return t.jsxs("div",{className:"h-full flex flex-col",children:[t.jsxs("div",{className:"flex items-center justify-between p-3 border-b bg-gray-50 dark:bg-slate-800",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(g.icon,{className:Ee("w-4 h-4",g.color)}),t.jsx("span",{className:"text-sm font-medium",children:g.label})]}),t.jsx("div",{className:"flex gap-2",children:c&&t.jsxs(rt,{variant:"outline",className:"text-xs text-blue-600",children:[t.jsx(Mr,{className:"w-3 h-3 mr-1 animate-spin"}),"Saving..."]})})]}),t.jsx(ft,{ref:u,className:"flex-1 w-full font-mono text-sm border-0 rounded-none resize-none p-4",value:n,onChange:h,placeholder:`Enter ${g.label.toLowerCase()} content...`})]})}var YB=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],XB=YB.reduce((e,r)=>{const s=eh(`Primitive.${r}`),n=_.forwardRef((o,c)=>{const{asChild:d,...l}=o,u=d?s:r;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),t.jsx(u,{...l,ref:c})});return n.displayName=`Primitive.${r}`,{...e,[r]:n}},{}),JB="Label",yN=_.forwardRef((e,r)=>t.jsx(XB.label,{...e,ref:r,onMouseDown:s=>{var o;s.target.closest("button, input, select, textarea")||((o=e.onMouseDown)==null||o.call(e,s),!s.defaultPrevented&&s.detail>1&&s.preventDefault())}}));yN.displayName=JB;var bN=yN;const QB=th("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),Ze=_.forwardRef(({className:e,...r},s)=>t.jsx(bN,{ref:s,className:Ee(QB(),e),...r}));Ze.displayName=bN.displayName;const ZB=th("relative w-full rounded-lg border px-4 py-3 text-sm [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4 [&>svg]:text-foreground [&>svg~*]:pl-7",{variants:{variant:{default:"bg-background text-foreground",destructive:"border-destructive/50 text-destructive dark:border-destructive [&>svg]:text-destructive"}},defaultVariants:{variant:"default"}}),Za=_.forwardRef(({className:e,variant:r,...s},n)=>t.jsx("div",{ref:n,role:"alert",className:Ee(ZB({variant:r}),e),...s}));Za.displayName="Alert";const e8=_.forwardRef(({className:e,...r},s)=>t.jsx("h5",{ref:s,className:Ee("mb-1 font-medium leading-none tracking-tight",e),...r}));e8.displayName="AlertTitle";const el=_.forwardRef(({className:e,...r},s)=>t.jsx("div",{ref:s,className:Ee("text-sm [&_p]:leading-relaxed",e),...r}));el.displayName="AlertDescription";var kh="Collapsible",[t8]=Ls(kh),[r8,Rx]=t8(kh),wN=_.forwardRef((e,r)=>{const{__scopeCollapsible:s,open:n,defaultOpen:o,disabled:c,onOpenChange:d,...l}=e,[u,f]=Xn({prop:n,defaultProp:o??!1,onChange:d,caller:kh});return t.jsx(r8,{scope:s,disabled:c,contentId:cn(),open:u,onOpenToggle:_.useCallback(()=>f(m=>!m),[f]),children:t.jsx(ot.div,{"data-state":Ix(u),"data-disabled":c?"":void 0,...l,ref:r})})});wN.displayName=kh;var _N="CollapsibleTrigger",SN=_.forwardRef((e,r)=>{const{__scopeCollapsible:s,...n}=e,o=Rx(_N,s);return t.jsx(ot.button,{type:"button","aria-controls":o.contentId,"aria-expanded":o.open||!1,"data-state":Ix(o.open),"data-disabled":o.disabled?"":void 0,disabled:o.disabled,...n,ref:r,onClick:Fe(e.onClick,o.onOpenToggle)})});SN.displayName=_N;var Mx="CollapsibleContent",CN=_.forwardRef((e,r)=>{const{forceMount:s,...n}=e,o=Rx(Mx,e.__scopeCollapsible);return t.jsx(Qr,{present:s||o.open,children:({present:c})=>t.jsx(s8,{...n,ref:r,present:c})})});CN.displayName=Mx;var s8=_.forwardRef((e,r)=>{const{__scopeCollapsible:s,present:n,children:o,...c}=e,d=Rx(Mx,s),[l,u]=_.useState(n),f=_.useRef(null),m=xt(r,f),h=_.useRef(0),g=h.current,w=_.useRef(0),j=w.current,S=d.open||l,v=_.useRef(S),y=_.useRef(void 0);return _.useEffect(()=>{const x=requestAnimationFrame(()=>v.current=!1);return()=>cancelAnimationFrame(x)},[]),Ur(()=>{const x=f.current;if(x){y.current=y.current||{transitionDuration:x.style.transitionDuration,animationName:x.style.animationName},x.style.transitionDuration="0s",x.style.animationName="none";const b=x.getBoundingClientRect();h.current=b.height,w.current=b.width,v.current||(x.style.transitionDuration=y.current.transitionDuration,x.style.animationName=y.current.animationName),u(n)}},[d.open,n]),t.jsx(ot.div,{"data-state":Ix(d.open),"data-disabled":d.disabled?"":void 0,id:d.contentId,hidden:!S,...c,ref:m,style:{"--radix-collapsible-content-height":g?`${g}px`:void 0,"--radix-collapsible-content-width":j?`${j}px`:void 0,...e.style},children:S&&o})});function Ix(e){return e?"open":"closed"}var n8=wN;const Hc=n8,Wc=SN,Uc=CN,$p=[{name:"Bash",icon:Ut,description:"Shell commands",color:"text-purple-600",bgColor:"bg-purple-50",badgeClass:"bg-purple-100 text-purple-700 border-purple-200"},{name:"Read",icon:Hr,description:"Read file contents",color:"text-blue-600",bgColor:"bg-blue-50",badgeClass:"bg-blue-100 text-blue-700 border-blue-200"},{name:"Edit",icon:Og,description:"Edit existing files",color:"text-amber-600",bgColor:"bg-amber-50",badgeClass:"bg-amber-100 text-amber-700 border-amber-200"},{name:"Write",icon:sl,description:"Create/write files",color:"text-orange-600",bgColor:"bg-orange-50",badgeClass:"bg-orange-100 text-orange-700 border-orange-200"},{name:"WebFetch",icon:Ji,description:"Fetch web content",color:"text-green-600",bgColor:"bg-green-50",badgeClass:"bg-green-100 text-green-700 border-green-200"},{name:"WebSearch",icon:Tc,description:"Web search capability",color:"text-teal-600",bgColor:"bg-teal-50",badgeClass:"bg-teal-100 text-teal-700 border-teal-200"},{name:"mcp",icon:Ya,description:"MCP server tools",color:"text-indigo-600",bgColor:"bg-indigo-50",badgeClass:"bg-indigo-100 text-indigo-700 border-indigo-200"}],Pw=[{category:"Git",name:"Git Status",pattern:"Bash(git status:*)",description:"Check repository status",icon:Ut},{category:"Git",name:"Git Add",pattern:"Bash(git add:*)",description:"Stage files for commit",icon:Ut},{category:"Git",name:"Git Commit",pattern:"Bash(git commit:*)",description:"Create commits",icon:Ut},{category:"Git",name:"Git Push",pattern:"Bash(git push:*)",description:"Push to remote repository",icon:Ut},{category:"Git",name:"Git Diff",pattern:"Bash(git diff:*)",description:"Show changes",icon:Ut},{category:"NPM",name:"NPM Install",pattern:"Bash(npm install:*)",description:"Install dependencies",icon:Ut},{category:"NPM",name:"NPM Run Scripts",pattern:"Bash(npm run:*)",description:"Run package scripts",icon:Ut},{category:"NPM",name:"NPM Test",pattern:"Bash(npm test:*)",description:"Run tests",icon:Ut},{category:"Files",name:"Read All Files",pattern:"Read(**)",description:"Read any file in the project",icon:Hr},{category:"Files",name:"Edit All Files",pattern:"Edit(**)",description:"Edit any file in the project",icon:Og},{category:"Security",name:"Deny .env Files",pattern:"Read(./.env)",description:"Block reading environment files",icon:Hr,suggestedCategory:"deny"},{category:"Security",name:"Deny All .env",pattern:"Read(**/.env*)",description:"Block all environment files",icon:Hr,suggestedCategory:"deny"},{category:"Commands",name:"List Files",pattern:"Bash(ls:*)",description:"List directory contents",icon:Ut},{category:"Commands",name:"Find Files",pattern:"Bash(find:*)",description:"Find files and directories",icon:Ut},{category:"MCP",name:"Filesystem Operations",pattern:"mcp__filesystem__*",description:"All filesystem MCP operations",icon:Ya},{category:"MCP",name:"GitHub Operations",pattern:"mcp__github__*",description:"All GitHub MCP operations",icon:Ya}];function jh(e){if(!e)return{type:"unknown",value:"",hasWildcard:!1,description:""};if(e.startsWith("mcp__")){const s=e.split("__");return{type:"mcp",value:e,server:s[1]||"",tool:s[2]||"",hasWildcard:e.includes("*"),description:`MCP tool: ${s.slice(1).join("/")}`}}if(e==="WebSearch")return{type:"WebSearch",value:"",hasWildcard:!1,description:"Web search capability"};const r=e.match(/^(\w+)\((.+)\)$/);if(r){const[,s,n]=r,o=n.includes("*");return{type:s,value:n,hasWildcard:o,description:a8(s,n)}}return{type:"unknown",value:e,hasWildcard:e.includes("*"),description:e}}function i8(e,r){return e==="WebSearch"?"WebSearch":e==="mcp"?r:r?`${e}(${r})`:""}function o8(e){if(!e)return"Rule cannot be empty";if(e==="WebSearch")return null;if(e.startsWith("mcp__"))return e.includes("*")||e.match(/^mcp__\w+__\w+$/)?null:"MCP pattern must be: mcp__server__tool";const r=e.match(/^(\w+)\((.+)\)$/);if(!r)return"Invalid pattern format. Expected: Type(value) or mcp__server__tool";const[,s]=r,n=["Bash","Read","Edit","Write","WebFetch"];return n.includes(s)?null:`Unknown permission type: ${s}. Valid types: ${n.join(", ")}`}function a8(e,r){switch(e){case"Bash":if(r.includes(":")){const[s,n]=r.split(":");return n==="*"?`Run "${s}" with any arguments`:`Run "${s} ${n}"`}return`Run "${r}"`;case"Read":return r==="**"?"Read all files":r.includes("**")?`Read files matching ${r}`:`Read ${r}`;case"Edit":return r==="**"?"Edit all files":r.includes("**")?`Edit files matching ${r}`:`Edit ${r}`;case"Write":return r==="**"?"Write to any file":r.includes("**")?`Write files matching ${r}`:`Write to ${r}`;case"WebFetch":return r==="*"?"Fetch any URL":`Fetch URLs matching ${r}`;default:return r}}function l8(e){return $p.find(s=>s.name===e)||$p[0]}function c8(e){return{allow:'Rules in "Allow" will execute automatically without prompting. Use wildcards (*) for flexible matching.',ask:'Rules in "Ask" will prompt for confirmation each time. Good for potentially destructive operations.',deny:'Rules in "Deny" are blocked entirely. Use this to prevent access to sensitive files or dangerous operations.'}[e]}function Aw(e){return{allow:{label:"Allow",color:"text-green-600",bgColor:"bg-green-50",borderColor:"border-green-200",badgeColor:"bg-green-100 text-green-700",description:"Operations that run without asking"},ask:{label:"Ask",color:"text-amber-600",bgColor:"bg-amber-50",borderColor:"border-amber-200",badgeColor:"bg-amber-100 text-amber-700",description:"Operations that require confirmation"},deny:{label:"Deny",color:"text-red-600",bgColor:"bg-red-50",borderColor:"border-red-200",badgeColor:"bg-red-100 text-red-700",description:"Operations that are blocked"}}[e]}function d8(e,r){const s=jh(e),{type:n,value:o}=s,c={allow:{prefix:"✓ Allowed automatically",meaning:"Claude will do this without asking you first"},ask:{prefix:"? Requires approval",meaning:"Claude will ask for your permission each time"},deny:{prefix:"✗ Blocked",meaning:"Claude cannot do this at all"}},d=c[r]||c.ask;let l="",u="",f=[];switch(n){case"Bash":if(o.includes(":")){const[w,j]=o.split(":");j==="*"?(l=`Run "${w}" command`,u=`Allows running the ${w} command with any arguments`,f=[`${w} build`,`${w} test`,`${w} --help`]):(l=`Run "${w} ${j}"`,u="Allows running this specific command",f=[`${w} ${j}`])}else o==="*"?(l="Run any terminal command",u="Allows executing any command in the terminal. Use with caution!",f=["npm install","git push","rm files"]):(l=`Run "${o}" command`,u="Allows running this specific command",f=[o]);break;case"Read":if(o==="**")l="Read any file",u="Allows reading the contents of any file in the project",f=["package.json","src/index.ts",".env"];else if(o.includes("**/*.")){const w=o.split("**.")[1];l=`Read ${w} files`,u=`Allows reading any file ending in .${w}`,f=[`file.${w}`,`src/component.${w}`]}else o.startsWith("./")?(l=`Read files in ${o}`,u=`Allows reading files in the ${o.replace("./","")} directory`):(l=`Read "${o}"`,u="Allows reading files matching this pattern");break;case"Edit":if(o==="**")l="Edit any file",u="Allows modifying the contents of any file. Changes can be undone with git.",f=["package.json","src/index.ts"];else if(o.includes("**/*.")){const w=o.split("**.")[1];l=`Edit ${w} files`,u=`Allows modifying any file ending in .${w}`}else o.startsWith("./")?(l=`Edit files in ${o}`,u=`Allows modifying files in the ${o.replace("./","")} directory`):(l=`Edit "${o}"`,u="Allows modifying files matching this pattern");break;case"Write":o==="**"?(l="Create any file",u="Allows creating new files anywhere in the project"):(l=`Create files in "${o}"`,u="Allows creating new files matching this pattern");break;case"WebFetch":o==="*"?(l="Fetch any URL",u="Allows making HTTP requests to any website",f=["api.github.com","docs.example.com"]):(l=`Fetch from ${o}`,u="Allows making HTTP requests to URLs matching this pattern");break;case"WebSearch":l="Search the web",u="Allows Claude to search the internet for information";break;case"mcp":const m=e.split("__"),h=m[1]||"unknown",g=m[2]||"*";g==="*"||e.endsWith("*")?(l=`Use ${h} tools`,u=`Allows using any tool from the ${h} MCP server`):(l=`Use ${h}/${g}`,u=`Allows using the ${g} tool from the ${h} MCP server`);break;default:l=e,u="Custom permission rule"}return{summary:l,detail:u,examples:f,categoryMeaning:`${d.prefix} — ${d.meaning}`}}function u8(e){const r={Bash:[],Read:[],Edit:[],Write:[],WebFetch:[],WebSearch:[],mcp:[],other:[]};for(const n of e){const c=jh(n).type;r[c]?r[c].push(n):r.other.push(n)}return["Bash","Read","Edit","Write","WebFetch","WebSearch","mcp","other"].filter(n=>r[n].length>0).map(n=>({type:n,rules:r[n]}))}function h8({rule:e,category:r,onEdit:s,onDelete:n,readOnly:o}){const[c,d]=_.useState(!1),l=jh(e);l8(l.type);const u=d8(e,r),f=e.length>25?e.substring(0,22)+"...":e;return t.jsxs("div",{className:"inline-flex items-center group",onMouseEnter:()=>d(!0),onMouseLeave:()=>d(!1),children:[t.jsxs(Ft,{children:[t.jsx(Bt,{asChild:!0,children:t.jsx("span",{className:"inline-block",children:t.jsx(rt,{variant:"secondary",className:Ee("cursor-default transition-all text-xs font-mono py-1 px-2 h-7",r==="allow"&&"bg-green-100 dark:bg-green-950 text-green-800 dark:text-green-300",r==="ask"&&"bg-amber-100 dark:bg-amber-950 text-amber-800 dark:text-amber-300",r==="deny"&&"bg-red-100 dark:bg-red-950 text-red-800 dark:text-red-300",!o&&"rounded-r-none"),children:f})})}),t.jsx(Ot,{side:"bottom",className:"max-w-md p-3",children:t.jsxs("div",{className:"space-y-2",children:[t.jsxs("div",{children:[t.jsx("p",{className:"text-sm font-medium",children:u.summary}),t.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:u.detail})]}),t.jsx("div",{className:Ee("text-xs px-2 py-1 rounded",r==="allow"&&"bg-green-500/20 text-green-700 dark:text-green-300",r==="ask"&&"bg-amber-500/20 text-amber-700 dark:text-amber-300",r==="deny"&&"bg-red-500/20 text-red-700 dark:text-red-300"),children:u.categoryMeaning}),u.examples&&u.examples.length>0&&t.jsxs("div",{className:"text-xs text-muted-foreground",children:[t.jsx("span",{className:"font-medium",children:"Examples: "}),u.examples.join(", ")]}),t.jsxs("code",{className:"text-[10px] text-muted-foreground/70 block break-all",children:["Pattern: ",e]})]})})]}),!o&&t.jsxs(Nn,{children:[t.jsx(En,{asChild:!0,children:t.jsx("button",{className:Ee("h-7 px-1 rounded-r transition-all border-l","hover:bg-black/10 dark:hover:bg-white/10",r==="allow"&&"bg-green-200 dark:bg-green-900 border-green-300 dark:border-green-800",r==="ask"&&"bg-amber-200 dark:bg-amber-900 border-amber-300 dark:border-amber-800",r==="deny"&&"bg-red-200 dark:bg-red-900 border-red-300 dark:border-red-800",c?"opacity-100":"opacity-0"),children:t.jsx(iM,{className:"w-3 h-3"})})}),t.jsxs(un,{align:"end",className:"w-32",children:[t.jsx(Pt,{onClick:s,children:"Edit"}),t.jsx(xs,{}),t.jsx(Pt,{onClick:n,className:"text-red-600",children:"Delete"})]})]})]})}const Tw={Bash:{label:"Bash",color:"text-purple-600 dark:text-purple-400"},Read:{label:"Read",color:"text-blue-600 dark:text-blue-400"},Edit:{label:"Edit",color:"text-orange-600 dark:text-orange-400"},Write:{label:"Write",color:"text-green-600 dark:text-green-400"},WebFetch:{label:"WebFetch",color:"text-cyan-600 dark:text-cyan-400"},WebSearch:{label:"WebSearch",color:"text-teal-600 dark:text-teal-400"},mcp:{label:"MCP",color:"text-indigo-600 dark:text-indigo-400"},other:{label:"Other",color:"text-gray-600 dark:text-gray-400"}};function f8({type:e,rules:r,category:s,onEdit:n,onDelete:o,onAddRule:c,readOnly:d,defaultExpanded:l=!1}){const[u,f]=_.useState(l||r.length<=5),m=Tw[e]||Tw.other;return r.length===0?null:t.jsxs("div",{className:"border border-gray-200 dark:border-slate-700 rounded-lg overflow-hidden",children:[t.jsxs("button",{onClick:()=>f(!u),className:Ee("w-full flex items-center gap-2 px-3 py-2 text-left","bg-gray-50 dark:bg-slate-800/50 hover:bg-gray-100 dark:hover:bg-slate-800","transition-colors"),children:[t.jsx(vs,{className:Ee("w-4 h-4 text-gray-400 transition-transform",u&&"rotate-90")}),t.jsx("span",{className:Ee("font-medium text-sm",m.color),children:m.label}),t.jsx(rt,{variant:"secondary",className:"text-xs",children:r.length}),!u&&r.length>0&&t.jsxs("span",{className:"text-xs text-gray-400 dark:text-slate-500 truncate flex-1 ml-2",children:[r.slice(0,3).join(", "),r.length>3&&"..."]})]}),u&&t.jsx("div",{className:"p-3 bg-white dark:bg-slate-900",children:t.jsxs("div",{className:"flex flex-wrap gap-2",children:[r.map(h=>t.jsx(h8,{rule:h,category:s,onEdit:()=>n(h),onDelete:()=>o(h),readOnly:d},h)),!d&&t.jsxs(se,{variant:"outline",size:"sm",className:"h-7 text-xs",onClick:c,children:[t.jsx(It,{className:"w-3 h-3 mr-1"}),"Add"]})]})})]})}function m8({open:e,onOpenChange:r,onSubmit:s,defaultCategory:n="allow",defaultRule:o="",isEditing:c=!1,existingRules:d=[]}){const[l,u]=_.useState("preset"),[f,m]=_.useState(n),[h,g]=_.useState("Bash"),[w,j]=_.useState(""),[S,v]=_.useState(o),[y,x]=_.useState(new Set),[b,k]=_.useState(""),[N,P]=_.useState(null);_.useEffect(()=>{if(e)if(m(n),x(new Set),k(""),o&&c){const $=jh(o);g($.type==="unknown"?"Bash":$.type),j($.value),v(o),u("builder")}else g("Bash"),j(""),v(""),u("preset")},[e,o,n,c]);const A=$=>{x(Y=>{const K=new Set(Y);return K.has($)?K.delete($):K.add($),K})},E=()=>{const $=O.filter(Y=>!d.includes(Y.pattern)).map(Y=>Y.pattern);x(new Set($))},M=()=>{x(new Set)},I=_.useMemo(()=>l==="freeform"?S:l==="builder"?i8(h,w):"",[l,h,w,S]);_.useEffect(()=>{if(l!=="preset"){const $=o8(I);P($)}else P(null)},[I,l]);const O=_.useMemo(()=>{if(!b)return Pw;const $=b.toLowerCase();return Pw.filter(Y=>Y.name.toLowerCase().includes($)||Y.pattern.toLowerCase().includes($)||Y.description.toLowerCase().includes($)||Y.category.toLowerCase().includes($))},[b]),z=_.useMemo(()=>{const $={};return O.forEach(Y=>{$[Y.category]||($[Y.category]=[]),$[Y.category].push(Y)}),$},[O]),U=()=>{if(l==="preset"){const $=Array.from(y);if($.length===0)return;for(const Y of $)s(f,Y);r(!1)}else{if(N||!I)return;s(f,I),r(!1)}},X=l==="preset"?y.size===0:!I||!!N,W=x8(h);return t.jsx(bt,{open:e,onOpenChange:r,children:t.jsxs(mt,{className:"max-w-2xl max-h-[90vh] overflow-hidden flex flex-col",children:[t.jsxs(pt,{children:[t.jsx(gt,{className:"flex items-center gap-2",children:c?t.jsxs(t.Fragment,{children:[t.jsx(sl,{className:"w-5 h-5 text-indigo-600"}),"Edit Permission Rule"]}):t.jsxs(t.Fragment,{children:[t.jsx(Wr,{className:"w-5 h-5 text-indigo-600"}),"Add Permission Rule"]})}),t.jsx(sr,{children:"Create a permission rule to control Claude Code's behavior."})]}),t.jsxs("div",{className:"flex-1 overflow-auto space-y-6 py-4",children:[t.jsxs("div",{className:"space-y-2",children:[t.jsx(Ze,{children:"Permission Category"}),t.jsxs(vr,{value:f,onValueChange:m,children:[t.jsx(hr,{children:t.jsx(yr,{})}),t.jsxs(fr,{children:[t.jsx(At,{value:"allow",children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("div",{className:"w-3 h-3 rounded-full bg-green-500"}),"Allow - Execute without asking"]})}),t.jsx(At,{value:"ask",children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("div",{className:"w-3 h-3 rounded-full bg-amber-500"}),"Ask - Require confirmation"]})}),t.jsx(At,{value:"deny",children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("div",{className:"w-3 h-3 rounded-full bg-red-500"}),"Deny - Block entirely"]})})]})]})]}),t.jsxs($c,{value:l,onValueChange:u,children:[t.jsxs(ll,{className:"grid w-full grid-cols-3",children:[t.jsxs(Ms,{value:"preset",children:[t.jsx(Wr,{className:"w-4 h-4 mr-2"}),"Presets"]}),t.jsxs(Ms,{value:"builder",children:[t.jsx(Ut,{className:"w-4 h-4 mr-2"}),"Builder"]}),t.jsxs(Ms,{value:"freeform",children:[t.jsx(Og,{className:"w-4 h-4 mr-2"}),"Freeform"]})]}),t.jsxs(Hn,{value:"preset",className:"space-y-4",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(He,{placeholder:"Search presets...",value:b,onChange:$=>k($.target.value),className:"flex-1"}),t.jsx(se,{variant:"outline",size:"sm",onClick:E,disabled:O.length===0,children:"Select All"}),t.jsx(se,{variant:"ghost",size:"sm",onClick:M,disabled:y.size===0,children:"Clear"})]}),y.size>0&&t.jsxs("div",{className:"flex items-center gap-2 text-sm text-indigo-600 dark:text-indigo-400",children:[t.jsx(Mt,{className:"w-4 h-4"}),y.size," preset",y.size!==1?"s":""," selected"]}),t.jsx("div",{className:"border border-gray-200 dark:border-slate-700 rounded-lg max-h-[220px] overflow-auto",children:Object.entries(z).map(([$,Y])=>t.jsxs("div",{className:"border-b border-gray-200 dark:border-slate-700 last:border-b-0",children:[t.jsx("div",{className:"px-3 py-1.5 bg-gray-50 dark:bg-slate-800 font-medium text-xs text-gray-600 dark:text-slate-300 sticky top-0",children:$}),Y.map(K=>{const L=K.icon,T=y.has(K.pattern),B=d.includes(K.pattern);return t.jsxs("label",{className:Ee("flex items-start gap-2 px-3 py-2 cursor-pointer transition-colors",B?"opacity-50 cursor-not-allowed bg-gray-100 dark:bg-slate-800":T?"bg-indigo-50 dark:bg-indigo-950/50":"hover:bg-gray-50 dark:hover:bg-slate-800"),children:[t.jsx(Dc,{checked:T,onCheckedChange:()=>!B&&A(K.pattern),disabled:B,className:"mt-0.5"}),t.jsx(L,{className:"w-4 h-4 mt-0.5 text-gray-400 dark:text-slate-500 shrink-0"}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"font-medium text-sm",children:K.name}),B&&t.jsx(rt,{variant:"secondary",className:"text-xs",children:"Added"})]}),t.jsx("code",{className:"text-xs text-gray-500 dark:text-slate-400 block truncate",children:K.pattern})]})]},K.pattern)})]},$))})]}),t.jsxs(Hn,{value:"builder",className:"space-y-4",children:[t.jsxs("div",{className:"space-y-2",children:[t.jsx(Ze,{children:"Permission Type"}),t.jsxs(vr,{value:h,onValueChange:g,children:[t.jsx(hr,{children:t.jsx(yr,{})}),t.jsx(fr,{children:$p.map($=>{const Y=$.icon;return t.jsx(At,{value:$.name,children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(Y,{className:"w-4 h-4"}),$.name,t.jsxs("span",{className:"text-xs text-gray-400 dark:text-slate-500",children:["- ",$.description]})]})},$.name)})})]})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx(Ze,{children:p8(h)}),t.jsxs(Ft,{children:[t.jsx(Bt,{children:t.jsx(Fa,{className:"w-4 h-4 text-gray-400"})}),t.jsx(Ot,{className:"max-w-xs",children:g8(h)})]})]}),h==="WebSearch"?t.jsx("p",{className:"text-sm text-gray-500 dark:text-slate-400 italic",children:"WebSearch does not require a value pattern."}):t.jsx(He,{value:w,onChange:$=>j($.target.value),placeholder:h==="Bash"?"command:arguments":"path/pattern",className:"font-mono"})]}),W.length>0&&t.jsxs("div",{className:"space-y-2",children:[t.jsx(Ze,{className:"text-xs text-gray-500 dark:text-slate-400",children:"Quick examples:"}),t.jsx("div",{className:"flex flex-wrap gap-2",children:W.map($=>t.jsx(se,{variant:"outline",size:"sm",className:"text-xs h-7",onClick:()=>j($.value),children:$.label},$.value))})]})]}),t.jsx(Hn,{value:"freeform",className:"space-y-4",children:t.jsxs("div",{className:"space-y-2",children:[t.jsx(Ze,{children:"Rule Pattern"}),t.jsx(ft,{value:S,onChange:$=>v($.target.value),placeholder:"e.g., Bash(npm run build), Read(**/*.ts)",className:"font-mono text-sm",rows:3}),t.jsx("p",{className:"text-xs text-gray-500 dark:text-slate-400",children:"Enter the full permission pattern. Use * for wildcards and : for Bash argument separation."})]})})]}),l!=="preset"&&t.jsxs("div",{className:"space-y-2",children:[t.jsx(Ze,{children:"Generated Rule"}),t.jsx("div",{className:Ee("p-3 rounded-lg border font-mono text-sm",N?"bg-red-50 dark:bg-red-950/50 border-red-200 dark:border-red-800 text-red-700 dark:text-red-400":"bg-gray-50 dark:bg-slate-800 border-gray-200 dark:border-slate-700 text-gray-700 dark:text-slate-300"),children:I||t.jsx("span",{className:"text-gray-400 dark:text-slate-500",children:"No rule configured"})}),N&&t.jsxs("div",{className:"flex items-center gap-2 text-sm text-red-600",children:[t.jsx(Is,{className:"w-4 h-4"}),N]})]})]}),t.jsxs(jt,{children:[t.jsx(se,{variant:"ghost",onClick:()=>r(!1),children:"Cancel"}),t.jsx(se,{onClick:U,disabled:X,className:"bg-indigo-600 hover:bg-indigo-700 text-white",children:c?"Update Rule":l==="preset"&&y.size>1?`Add ${y.size} Rules`:"Add Rule"})]})]})})}function p8(e){return{Bash:"Command Pattern",Read:"File Path Pattern",Edit:"File Path Pattern",Write:"File Path Pattern",WebFetch:"URL Pattern",WebSearch:"N/A",mcp:"Tool Name"}[e]||"Value"}function g8(e){return{Bash:"Format: command:arguments. Use * for wildcards. Example: npm run:* matches npm run build, npm run test, etc.",Read:"File path pattern. Use ** for recursive matching. Example: **/*.ts matches all TypeScript files.",Edit:"File path pattern. Use ** for recursive matching.",Write:"File path pattern. Use ** for recursive matching.",WebFetch:"URL pattern. Example: https://api.github.com/* matches all GitHub API calls.",WebSearch:"No value needed - this enables/disables web search entirely.",mcp:"MCP tool name in format: mcp__server__tool"}[e]||""}function x8(e){return{Bash:[{label:"npm run *",value:"npm run:*"},{label:"git add *",value:"git add:*"},{label:"git commit *",value:"git commit:*"},{label:"ls *",value:"ls:*"}],Read:[{label:"All files",value:"**"},{label:"TypeScript",value:"**/*.ts"},{label:"Source only",value:"./src/**"}],Edit:[{label:"All files",value:"**"},{label:"Source only",value:"./src/**"}],Write:[{label:"All files",value:"**"}],WebFetch:[{label:"Any URL",value:"*"},{label:"GitHub API",value:"https://api.github.com/*"}],mcp:[{label:"Filesystem read",value:"mcp__filesystem__read_file"},{label:"GitHub PR",value:"mcp__github__create_pull_request"}]}[e]||[]}function v8({open:e,onOpenChange:r,mode:s,permissions:n,onImport:o}){const[c,d]=_.useState(""),[l,u]=_.useState(null),[f,m]=_.useState(!1);_.useEffect(()=>{e&&s==="export"?(d(JSON.stringify({permissions:n},null,2)),u(null)):e&&s==="import"&&(d(""),u(null))},[e,s,n]);const h=()=>{navigator.clipboard.writeText(c),m(!0),setTimeout(()=>m(!1),2e3),q.success("Copied to clipboard")},g=()=>{try{const w=JSON.parse(c);if(!w.permissions){u('JSON must have a "permissions" key');return}const{allow:j=[],ask:S=[],deny:v=[]}=w.permissions;if(!Array.isArray(j)||!Array.isArray(S)||!Array.isArray(v)){u("allow, ask, and deny must be arrays");return}if([...j,...S,...v].some(x=>typeof x!="string")){u("All permission rules must be strings");return}o(w.permissions),r(!1)}catch(w){u("Invalid JSON: "+w.message)}};return t.jsx(bt,{open:e,onOpenChange:r,children:t.jsxs(mt,{className:"max-w-lg",children:[t.jsxs(pt,{children:[t.jsx(gt,{className:"flex items-center gap-2",children:s==="export"?t.jsxs(t.Fragment,{children:[t.jsx(xi,{className:"w-5 h-5 text-indigo-600"}),"Export Permissions"]}):t.jsxs(t.Fragment,{children:[t.jsx(Sp,{className:"w-5 h-5 text-indigo-600"}),"Import Permissions"]})}),t.jsx(sr,{children:s==="export"?"Copy this JSON to save or share your permission configuration.":"Paste a JSON permission configuration to import."})]}),t.jsxs("div",{className:"space-y-4 py-4",children:[t.jsx(ft,{value:c,onChange:w=>{d(w.target.value),u(null)},placeholder:s==="import"?"Paste JSON here...":"",className:"font-mono text-sm min-h-[300px]",readOnly:s==="export"}),l&&t.jsxs("div",{className:"flex items-center gap-2 text-sm text-red-600",children:[t.jsx(Is,{className:"w-4 h-4"}),l]})]}),t.jsxs(jt,{children:[t.jsx(se,{variant:"ghost",onClick:()=>r(!1),children:"Cancel"}),s==="export"?t.jsxs(se,{onClick:h,className:"bg-indigo-600 hover:bg-indigo-700 text-white",children:[f?t.jsx(Mt,{className:"w-4 h-4 mr-2"}):t.jsx(Ka,{className:"w-4 h-4 mr-2"}),f?"Copied!":"Copy to Clipboard"]}):t.jsxs(se,{onClick:g,disabled:!c.trim(),className:"bg-indigo-600 hover:bg-indigo-700 text-white",children:[t.jsx(Sp,{className:"w-4 h-4 mr-2"}),"Import"]})]})]})})}function y8({open:e,onOpenChange:r,serverName:s,serverConfig:n={},permissions:o={allow:[],ask:[],deny:[]},onUpdatePermissions:c}){var A,E;const[d,l]=_.useState([]),[u,f]=_.useState(!1),[m,h]=_.useState(null),[g,w]=_.useState("");_.useEffect(()=>{e&&s&&j()},[e,s]);const j=async()=>{f(!0),h(null);try{const M=await fe.getMcpServerTools(s);M.error?(h(M.error),l([])):l(M.tools||[])}catch(M){h(M.message),l([])}finally{f(!1)}},S=async()=>{await fe.clearMcpToolsCache(s),await j()},v=_.useMemo(()=>{var z,U,X,W;const M=`mcp__${s}__`,I=`${M}*`,O={allowAll:((z=o.allow)==null?void 0:z.includes(I))||!1,toolPermissions:{}};return(U=o.allow)==null||U.forEach($=>{$.startsWith(M)&&$!==I&&(O.toolPermissions[$.replace(M,"")]="allow")}),(X=o.ask)==null||X.forEach($=>{$.startsWith(M)&&$!==I&&(O.toolPermissions[$.replace(M,"")]="ask")}),(W=o.deny)==null||W.forEach($=>{$.startsWith(M)&&$!==I&&(O.toolPermissions[$.replace(M,"")]="deny")}),O},[s,o]),y=_.useMemo(()=>{const M=new Set;return d.forEach(I=>M.add(I.name)),Object.keys(v.toolPermissions).forEach(I=>M.add(I)),Array.from(M).sort().map(I=>{const O=d.find(z=>z.name===I);return{name:I,description:(O==null?void 0:O.description)||"",discovered:!!O}})},[d,v.toolPermissions]),x=M=>{const I=`mcp__${s}__*`;c==null||c(s,I,M?"allow":"remove")},b=(M,I)=>{const O=`mcp__${s}__${M}`;v.toolPermissions[M]===I?c==null||c(s,O,"remove"):c==null||c(s,O,I)},k=()=>{const M=g.trim();if(!M)return;const I=`mcp__${s}__${M}`;c==null||c(s,I,"allow"),w("")},N=M=>{const I=`mcp__${s}__${M}`;c==null||c(s,I,"remove")},P=n!=null&&n.command?"stdio":n!=null&&n.url?"sse":"unknown";return t.jsx(ar,{children:t.jsx(bt,{open:e,onOpenChange:r,children:t.jsxs(mt,{className:"sm:max-w-[550px] max-h-[85vh] flex flex-col",children:[t.jsxs(pt,{children:[t.jsxs(gt,{className:"flex items-center gap-2",children:[t.jsx(Ya,{className:"w-5 h-5 text-purple-600"}),"Configure ",s]}),t.jsxs(sr,{children:[P==="stdio"&&n.command&&t.jsxs("code",{className:"text-xs bg-gray-100 dark:bg-slate-800 px-2 py-1 rounded",children:[n.command," ",(A=n.args)==null?void 0:A.slice(0,2).join(" "),((E=n.args)==null?void 0:E.length)>2&&"..."]}),P==="sse"&&n.url&&t.jsx("code",{className:"text-xs bg-gray-100 dark:bg-slate-800 px-2 py-1 rounded",children:n.url})]})]}),t.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col space-y-4 py-4",children:[t.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg border border-gray-200 dark:border-slate-700 bg-gray-50 dark:bg-slate-800/50",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(Qn,{className:"w-5 h-5 text-green-600"}),t.jsxs("div",{children:[t.jsx(Ze,{className:"font-medium",children:"Allow all tools"}),t.jsx("p",{className:"text-xs text-gray-500 dark:text-slate-400",children:"Grant permission for all tools from this server"})]})]}),t.jsx(_t,{checked:v.allowAll,onCheckedChange:x})]}),v.allowAll&&t.jsxs(Za,{children:[t.jsx(Zu,{className:"w-4 h-4"}),t.jsx(el,{className:"text-sm",children:"All tools are allowed. Individual tool settings below are informational only."})]}),t.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col space-y-3",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx(Ze,{className:"text-sm font-medium",children:"Available Tools"}),t.jsxs(se,{variant:"ghost",size:"sm",onClick:S,disabled:u,className:"h-7",children:[t.jsx(Mr,{className:Ee("w-3 h-3 mr-1",u&&"animate-spin")}),"Refresh"]})]}),m&&t.jsxs(Za,{variant:"destructive",children:[t.jsx(Is,{className:"w-4 h-4"}),t.jsxs(el,{className:"text-sm",children:[m,t.jsx("p",{className:"text-xs mt-1 opacity-80",children:"You can still add tools manually below."})]})]}),u&&t.jsxs("div",{className:"flex items-center justify-center py-8",children:[t.jsx(Mr,{className:"w-5 h-5 animate-spin text-gray-400"}),t.jsx("span",{className:"ml-2 text-sm text-gray-500",children:"Discovering tools..."})]}),!u&&t.jsx(Xs,{className:"flex-1 min-h-0 rounded-md border border-gray-200 dark:border-slate-700",children:t.jsx("div",{className:"divide-y divide-gray-200 dark:divide-slate-700",children:y.length>0?y.map(M=>{const I=v.toolPermissions[M.name];return t.jsxs("div",{className:"flex items-center justify-between p-2 hover:bg-gray-50 dark:hover:bg-slate-800/50",children:[t.jsxs("div",{className:"flex-1 min-w-0 mr-2",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("code",{className:"text-sm font-mono truncate",children:M.name}),!M.discovered&&t.jsx(rt,{variant:"outline",className:"text-xs",children:"manual"})]}),M.description&&t.jsx("p",{className:"text-xs text-gray-500 dark:text-slate-400 truncate",children:M.description})]}),t.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[t.jsxs(Ft,{children:[t.jsx(Bt,{asChild:!0,children:t.jsx(se,{variant:I==="allow"?"default":"ghost",size:"sm",className:Ee("h-7 w-7 p-0",I==="allow"&&"bg-green-600 hover:bg-green-700"),onClick:()=>b(M.name,"allow"),children:t.jsx(Mt,{className:"w-3 h-3"})})}),t.jsx(Ot,{children:"Allow"})]}),t.jsxs(Ft,{children:[t.jsx(Bt,{asChild:!0,children:t.jsx(se,{variant:I==="ask"?"default":"ghost",size:"sm",className:Ee("h-7 w-7 p-0",I==="ask"&&"bg-amber-600 hover:bg-amber-700"),onClick:()=>b(M.name,"ask"),children:"?"})}),t.jsx(Ot,{children:"Ask"})]}),t.jsxs(Ft,{children:[t.jsx(Bt,{asChild:!0,children:t.jsx(se,{variant:I==="deny"?"default":"ghost",size:"sm",className:Ee("h-7 w-7 p-0",I==="deny"&&"bg-red-600 hover:bg-red-700"),onClick:()=>b(M.name,"deny"),children:t.jsx(Un,{className:"w-3 h-3"})})}),t.jsx(Ot,{children:"Deny"})]}),!M.discovered&&I&&t.jsxs(Ft,{children:[t.jsx(Bt,{asChild:!0,children:t.jsx(se,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 text-gray-400 hover:text-red-600",onClick:()=>N(M.name),children:t.jsx(ws,{className:"w-3 h-3"})})}),t.jsx(Ot,{children:"Remove"})]})]})]},M.name)}):t.jsxs("div",{className:"text-center py-8 text-gray-500 dark:text-slate-400",children:[t.jsx("p",{className:"text-sm",children:"No tools discovered"}),t.jsx("p",{className:"text-xs mt-1",children:"Add tools manually below"})]})})}),t.jsxs("div",{className:"flex gap-2 pt-2 border-t border-gray-200 dark:border-slate-700",children:[t.jsx(He,{value:g,onChange:M=>w(M.target.value),placeholder:"Add tool manually...",className:"flex-1 text-sm",onKeyDown:M=>{M.key==="Enter"&&(M.preventDefault(),k())}}),t.jsx(se,{size:"sm",onClick:k,disabled:!g.trim(),children:t.jsx(It,{className:"w-4 h-4"})})]})]}),t.jsxs("div",{className:"flex items-center gap-4 text-xs text-gray-500 dark:text-slate-400 pt-2 border-t border-gray-200 dark:border-slate-700",children:[t.jsxs("span",{className:"flex items-center gap-1",children:[t.jsx("div",{className:"w-3 h-3 rounded bg-green-600"}),"Allow"]}),t.jsxs("span",{className:"flex items-center gap-1",children:[t.jsx("div",{className:"w-3 h-3 rounded bg-amber-600"}),"Ask"]}),t.jsxs("span",{className:"flex items-center gap-1",children:[t.jsx("div",{className:"w-3 h-3 rounded bg-red-600"}),"Deny"]}),t.jsx("span",{className:"flex items-center gap-1 ml-auto",children:t.jsx("span",{className:"text-gray-400",children:"Click again to remove"})})]})]}),t.jsx(jt,{children:t.jsx(se,{variant:"outline",onClick:()=>r(!1),children:"Done"})})]})})})}function b8({mcpServers:e={},permissions:r={allow:[],ask:[],deny:[]},onToggle:s,onUpdatePermission:n,readOnly:o=!1}){const[c,d]=_.useState(!0),[l,u]=_.useState(!1),[f,m]=_.useState(null),h=_.useMemo(()=>Object.keys(e).sort(),[e]),g=v=>{var x;const y=`mcp__${v}__*`;return((x=r.allow)==null?void 0:x.includes(y))||!1},w=v=>{var k,N,P;const y=`mcp__${v}__`,x=`${y}*`;let b=0;return(k=r.allow)==null||k.forEach(A=>{A.startsWith(y)&&A!==x&&b++}),(N=r.ask)==null||N.forEach(A=>{A.startsWith(y)&&A!==x&&b++}),(P=r.deny)==null||P.forEach(A=>{A.startsWith(y)&&A!==x&&b++}),b},j=(v,y)=>{const x=`mcp__${v}__*`;s==null||s(v,x,y)},S=(v,y)=>{y.stopPropagation(),m(v),u(!0)};return h.length===0?null:t.jsxs(t.Fragment,{children:[t.jsxs(Hc,{open:c,onOpenChange:d,className:"mb-6",children:[t.jsx(Wc,{asChild:!0,children:t.jsxs("button",{className:"w-full flex items-center justify-between p-3 rounded-lg border border-gray-200 dark:border-slate-700 hover:bg-gray-50 dark:hover:bg-slate-800/50 transition-colors",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("div",{className:"w-8 h-8 rounded-lg bg-purple-100 dark:bg-purple-950 flex items-center justify-center",children:t.jsx(Ya,{className:"w-4 h-4 text-purple-600 dark:text-purple-400"})}),t.jsxs("div",{className:"text-left",children:[t.jsx("span",{className:"font-medium text-gray-900 dark:text-white",children:"Quick MCP Permissions"}),t.jsxs(rt,{variant:"secondary",className:"ml-2 text-xs",children:[h.length," server",h.length!==1?"s":""]})]})]}),t.jsx(xr,{className:Ee("w-4 h-4 text-gray-500 transition-transform",c&&"rotate-180")})]})}),t.jsx(Uc,{children:t.jsxs("div",{className:"mt-2 rounded-lg border border-gray-200 dark:border-slate-700 divide-y divide-gray-200 dark:divide-slate-700",children:[h.map(v=>{const y=g(v),x=e[v],b=x!=null&&x.command?"stdio":x!=null&&x.url?"sse":"unknown",k=w(v);return t.jsxs("div",{className:"flex items-center justify-between p-3 hover:bg-gray-50 dark:hover:bg-slate-800/50",children:[t.jsx("div",{className:"flex items-center gap-3 flex-1 min-w-0",children:t.jsxs("div",{className:"flex flex-col min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"font-medium text-gray-900 dark:text-white",children:v}),y&&t.jsxs(rt,{variant:"outline",className:"text-xs bg-green-50 dark:bg-green-950 text-green-700 dark:text-green-400 border-green-200 dark:border-green-800",children:[t.jsx(Mt,{className:"w-3 h-3 mr-1"}),"All"]}),!y&&k>0&&t.jsxs(rt,{variant:"outline",className:"text-xs",children:[k," tool",k!==1?"s":""]})]}),t.jsxs("span",{className:"text-xs text-gray-500 dark:text-slate-400 truncate",children:[b==="stdio"&&x.command,b==="sse"&&x.url]})]})}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(se,{variant:"ghost",size:"sm",className:"h-8 px-2",onClick:N=>S(v,N),disabled:o,children:t.jsx(_p,{className:"w-4 h-4"})}),t.jsxs("div",{className:"flex items-center gap-2 pl-2 border-l border-gray-200 dark:border-slate-700",children:[t.jsx("span",{className:"text-xs text-gray-500 dark:text-slate-400 whitespace-nowrap",children:"Allow all"}),t.jsx(_t,{checked:y,onCheckedChange:N=>j(v,N),disabled:o})]})]})]},v)}),t.jsxs("div",{className:"p-3 bg-gray-50 dark:bg-slate-800/50 flex items-start gap-2",children:[t.jsx(Zu,{className:"w-4 h-4 text-gray-400 mt-0.5 flex-shrink-0"}),t.jsxs("p",{className:"text-xs text-gray-500 dark:text-slate-400",children:["Click ",t.jsx(_p,{className:"w-3 h-3 inline mx-0.5"})," to configure specific tool permissions"]})]})]})})]}),f&&t.jsx(y8,{open:l,onOpenChange:u,serverName:f,serverConfig:e[f],permissions:r,onUpdatePermissions:n})]})}function w8({permissions:e,onSave:r,loading:s,readOnly:n=!1,mcpServers:o={}}){const[c,d]=_.useState({allow:[],ask:[],deny:[]}),[l,u]=_.useState("allow"),[f,m]=_.useState(!1),[h,g]=_.useState(!1),[w,j]=_.useState(!1),[S,v]=_.useState(null),[y,x]=_.useState(!1),[b,k]=_.useState("export");_.useEffect(()=>{e&&d({allow:e.allow||[],ask:e.ask||[],deny:e.deny||[]})},[e]);const N=_.useCallback(async W=>{if(!(!r||n)){m(!0);try{await r(W)}catch($){q.error("Failed to save: "+$.message)}finally{m(!1)}}},[r,n]),P=_.useCallback((W,$)=>{d(Y=>{if([...Y.allow,...Y.ask,...Y.deny].includes($))return q.error("This rule already exists"),Y;const L={...Y,[W]:[...Y[W],$]};return N(L),q.success(`Rule added to ${W}`),L})},[N]),A=_.useCallback((W,$,Y,K)=>{d(L=>{const T={...L};return T[W]=T[W].filter(B=>B!==$),T[Y]=[...T[Y],K],N(T),q.success("Rule updated"),T})},[N]),E=_.useCallback((W,$)=>{d(Y=>{const K={...Y,[W]:Y[W].filter(L=>L!==$)};return N(K),q.success("Rule deleted"),K})},[N]);_.useCallback((W,$,Y)=>{d(K=>{const L={...K,[W]:K[W].filter(T=>T!==$),[Y]:[...K[Y],$]};return N(L),q.success(`Moved to ${Y}`),L})},[N]);const M=_.useCallback(W=>{const $={allow:W.allow||[],ask:W.ask||[],deny:W.deny||[]};d($),N($),q.success("Permissions imported")},[N]),I=_.useCallback((W,$,Y)=>{Y?P("allow",$):E("allow",$)},[P,E]),O=_.useCallback((W,$,Y)=>{d(K=>{const L={allow:[...K.allow||[]],ask:[...K.ask||[]],deny:[...K.deny||[]]};return L.allow=L.allow.filter(T=>T!==$),L.ask=L.ask.filter(T=>T!==$),L.deny=L.deny.filter(T=>T!==$),Y==="allow"?L.allow.push($):Y==="ask"?L.ask.push($):Y==="deny"&&L.deny.push($),N(L),L})},[N]),z=W=>{v(null),u(W),j(!0)},U=(W,$)=>{v({category:W,rule:$}),j(!0)},X=c.allow.length+c.ask.length+c.deny.length;return t.jsx(ar,{children:t.jsxs("div",{className:"space-y-6",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("div",{className:"w-10 h-10 rounded-lg bg-indigo-100 dark:bg-indigo-950 flex items-center justify-center",children:t.jsx(Qn,{className:"w-5 h-5 text-indigo-600 dark:text-indigo-400"})}),t.jsxs("div",{children:[t.jsx("h2",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:"Claude Code Permissions"}),t.jsx("p",{className:"text-sm text-gray-500 dark:text-slate-400",children:"Configure what Claude Code can do automatically"})]})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[f&&t.jsxs(rt,{variant:"outline",className:"bg-blue-50 dark:bg-blue-950/50 text-blue-700 dark:text-blue-400 border-blue-200 dark:border-blue-800",children:[t.jsx(Mr,{className:"w-3 h-3 mr-1 animate-spin"}),"Saving..."]}),t.jsxs(Ft,{children:[t.jsx(Bt,{asChild:!0,children:t.jsx(se,{variant:"outline",size:"sm",onClick:()=>{k("export"),x(!0)},children:t.jsx(xi,{className:"w-4 h-4"})})}),t.jsx(Ot,{children:"Export permissions"})]}),t.jsxs(Ft,{children:[t.jsx(Bt,{asChild:!0,children:t.jsx(se,{variant:"outline",size:"sm",onClick:()=>{k("import"),x(!0)},disabled:n,children:t.jsx(Sp,{className:"w-4 h-4"})})}),t.jsx(Ot,{children:"Import permissions"})]})]})]}),t.jsxs(Hc,{open:h,onOpenChange:g,children:[t.jsx(Wc,{asChild:!0,children:t.jsxs(se,{variant:"ghost",size:"sm",className:"text-gray-500 dark:text-slate-400",children:[t.jsx(Fa,{className:"w-4 h-4 mr-2"}),"How permissions work",t.jsx(xr,{className:Ee("w-4 h-4 ml-2 transition-transform",h&&"rotate-180")})]})}),t.jsx(Uc,{children:t.jsxs(Za,{className:"mt-2",children:[t.jsx(Zu,{className:"w-4 h-4"}),t.jsxs(el,{className:"text-sm",children:[t.jsxs("p",{className:"mb-2",children:["Permissions control what Claude Code can do automatically vs. what requires your approval. These settings are stored in ",t.jsx("code",{className:"px-1 py-0.5 bg-gray-100 dark:bg-slate-700 rounded text-xs",children:"~/.claude/settings.json"}),"."]}),t.jsxs("div",{className:"grid grid-cols-3 gap-4 mt-3",children:[t.jsxs("div",{children:[t.jsx(rt,{className:"bg-green-100 dark:bg-green-950 text-green-700 dark:text-green-400 mb-1",children:"Allow"}),t.jsx("p",{className:"text-xs text-gray-600 dark:text-slate-400",children:"Operations run without asking"})]}),t.jsxs("div",{children:[t.jsx(rt,{className:"bg-amber-100 dark:bg-amber-950 text-amber-700 dark:text-amber-400 mb-1",children:"Ask"}),t.jsx("p",{className:"text-xs text-gray-600 dark:text-slate-400",children:"Prompts for confirmation each time"})]}),t.jsxs("div",{children:[t.jsx(rt,{className:"bg-red-100 dark:bg-red-950 text-red-700 dark:text-red-400 mb-1",children:"Deny"}),t.jsx("p",{className:"text-xs text-gray-600 dark:text-slate-400",children:"Blocked entirely"})]})]}),t.jsxs("p",{className:"mt-3 text-xs text-gray-500 dark:text-slate-400",children:["Use wildcards: ",t.jsx("code",{className:"px-1 py-0.5 bg-gray-100 dark:bg-slate-700 rounded",children:"*"})," matches anything,"," ",t.jsx("code",{className:"px-1 py-0.5 bg-gray-100 dark:bg-slate-700 rounded",children:"**"})," matches recursively in paths."]})]})]})})]}),!s&&Object.keys(o).length>0&&t.jsx(b8,{mcpServers:o,permissions:c,onToggle:I,onUpdatePermission:O,readOnly:n}),s&&t.jsx("div",{className:"flex items-center justify-center py-12",children:t.jsx(Mr,{className:"w-6 h-6 animate-spin text-gray-400"})}),!s&&X===0&&t.jsxs(Za,{children:[t.jsx(Gi,{className:"w-4 h-4"}),t.jsxs(el,{children:["No permission rules configured. Claude Code will use default behavior and ask for permission on sensitive operations.",t.jsx(se,{variant:"link",size:"sm",className:"ml-2 p-0 h-auto",onClick:()=>z("allow"),children:"Add your first rule"})]})]}),!s&&t.jsxs($c,{value:l,onValueChange:u,children:[t.jsx(ll,{className:"grid w-full grid-cols-3",children:["allow","ask","deny"].map(W=>{var K;const $=Aw(W),Y=((K=c[W])==null?void 0:K.length)||0;return t.jsxs(Ms,{value:W,className:"flex items-center gap-2",children:[t.jsx("div",{className:Ee("w-2 h-2 rounded-full",W==="allow"&&"bg-green-500",W==="ask"&&"bg-amber-500",W==="deny"&&"bg-red-500")}),$.label,Y>0&&t.jsx(rt,{variant:"secondary",className:"ml-1 text-xs",children:Y})]},W)})}),["allow","ask","deny"].map(W=>{const $=Aw(W),Y=c[W]||[],K=u8(Y);return t.jsxs(Hn,{value:W,className:"space-y-3",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs(Ft,{children:[t.jsx(Bt,{asChild:!0,children:t.jsx("p",{className:"text-sm text-gray-500 dark:text-slate-400 cursor-help",children:$.description})}),t.jsx(Ot,{className:"max-w-xs",children:c8(W)})]}),t.jsxs(se,{size:"sm",variant:"outline",onClick:()=>z(W),disabled:n,children:[t.jsx(It,{className:"w-4 h-4 mr-1"}),"Add Rules"]})]}),Y.length===0?t.jsxs("div",{className:Ee("text-center py-8 rounded-lg border-2 border-dashed",$.borderColor),children:[t.jsxs("p",{className:"text-gray-500 dark:text-slate-400",children:["No rules in ",W]}),t.jsx(se,{variant:"link",size:"sm",onClick:()=>z(W),disabled:n,children:"Add rules"})]}):t.jsx("div",{className:"space-y-2",children:K.map(({type:L,rules:T})=>t.jsx(f8,{type:L,rules:T,category:W,onEdit:B=>U(W,B),onDelete:B=>E(W,B),onAddRule:()=>z(W),readOnly:n},L))})]},W)})]}),t.jsx(m8,{open:w,onOpenChange:j,onSubmit:(W,$)=>{S?A(S.category,S.rule,W,$):P(W,$)},defaultCategory:(S==null?void 0:S.category)||l,defaultRule:(S==null?void 0:S.rule)||"",isEditing:!!S,existingRules:[...c.allow,...c.ask,...c.deny]}),t.jsx(v8,{open:y,onOpenChange:x,mode:b,permissions:c,onImport:M})]})})}const _8=[{id:"claude-opus-4-6",name:"Claude Opus 4.6",description:"Most capable, best for complex tasks",tier:"opus",recommended:!0},{id:"claude-sonnet-4-6",name:"Claude Sonnet 4.6",description:"Fast output, great balance of speed and capability",tier:"sonnet"},{id:"claude-sonnet-4-5-20250929",name:"Claude Sonnet 4.5",description:"Previous generation, balanced",tier:"sonnet"},{id:"claude-haiku-4-5-20251001",name:"Claude Haiku 4.5",description:"Fastest, best for simple tasks",tier:"haiku"}],S8=[{value:"low",label:"Low",description:"Faster, less thorough"},{value:"medium",label:"Medium",description:"Balanced"},{value:"high",label:"High",description:"Most thorough reasoning"}],C8=[{value:"default",label:"Default",description:"Ask for most tool uses"},{value:"plan",label:"Plan",description:"Read-only, no edits allowed"},{value:"acceptEdits",label:"Accept Edits",description:"Auto-approve file edits"},{value:"auto",label:"Auto",description:"AI classifies safe vs risky actions"},{value:"dontAsk",label:"Don't Ask",description:"Auto-approve most actions"},{value:"bypassPermissions",label:"Bypass Permissions",description:"No restrictions (dangerous)"}],k8=[{value:"auto",label:"Auto"},{value:"in-process",label:"In-process"},{value:"tmux",label:"Tmux"}],j8=[{key:"ANTHROPIC_SMALL_FAST_MODEL",label:"Small/Fast Model",description:"Model for background tasks and quick operations",placeholder:"claude-haiku-4-5-20251001"},{key:"CLAUDE_CODE_SUBAGENT_MODEL",label:"Subagent Model",description:"Model used for subagent/background processing",placeholder:"claude-haiku-4-5-20251001"},{key:"MAX_THINKING_TOKENS",label:"Max Thinking Tokens",description:"Extended thinking budget (0 to disable)",placeholder:"5000"},{key:"CLAUDE_CODE_MAX_OUTPUT_TOKENS",label:"Max Output Tokens",description:"Maximum output tokens per response (32000-64000)",placeholder:"32000"},{key:"BASH_DEFAULT_TIMEOUT_MS",label:"Bash Default Timeout (ms)",description:"Default timeout for bash commands",placeholder:"120000"},{key:"BASH_MAX_TIMEOUT_MS",label:"Bash Max Timeout (ms)",description:"Maximum allowed timeout for bash commands",placeholder:"600000"},{key:"CLAUDE_AUTOCOMPACT_PCT_OVERRIDE",label:"Auto-compact Threshold (%)",description:"Context usage percentage to trigger auto-compaction (1-100)",placeholder:"75"},{key:"MCP_TIMEOUT",label:"MCP Startup Timeout (ms)",description:"Timeout for MCP server startup",placeholder:"10000"},{key:"MCP_TOOL_TIMEOUT",label:"MCP Tool Timeout (ms)",description:"Timeout for MCP tool execution",placeholder:"30000"}],Rw=["permissions","model","modelOverrides","effortLevel","availableModels","alwaysThinkingEnabled","showThinkingSummaries","enableAllProjectMcpServers","respectGitignore","cleanupPeriodDays","plansDirectory","disableAllHooks","language","teammateMode","outputStyle","attribution","sandbox","env","hooks","voiceEnabled","autoMemoryEnabled","autoMemoryDirectory","defaultShell","worktree","autoUpdatesChannel","prefersReducedMotion","claudeMdExcludes","disableSkillShellExecution"];function zr({label:e,description:r,checked:s,onCheckedChange:n}){return t.jsxs("div",{className:"flex items-center justify-between p-4 rounded-lg border border-gray-200 dark:border-slate-700",children:[t.jsxs("div",{children:[t.jsx(Ze,{children:e}),t.jsx("p",{className:"text-sm text-gray-500 dark:text-slate-400",children:r})]}),t.jsx(_t,{checked:s,onCheckedChange:n})]})}function kN({settings:e,onSave:r,loading:s,settingsPath:n="~/.claude/settings.json",mcpServers:o={}}){var O,z,U,X,W,$,Y,K,L,T,B,G,F,re,ue,he,J,H,ae,ie,Z,ce,Ce,Re,We,pe,_e,Be,Ve,Je,Ct,Se,me,be;const[c,d]=_.useState({}),[l,u]=_.useState("permissions"),[f,m]=_.useState(!1),[h,g]=_.useState(!1),[w,j]=_.useState(""),[S,v]=_.useState(null),y=_.useRef(null);_.useEffect(()=>{e&&(d(e),j(JSON.stringify(e,null,2)))},[e]),_.useEffect(()=>{h||j(JSON.stringify(c,null,2))},[c,h]);const x=_.useCallback(async ee=>{if(r){m(!0);try{await r(ee)}catch(oe){q.error("Failed to save: "+oe.message)}finally{m(!1)}}},[r]),b=_.useCallback(ee=>{y.current&&clearTimeout(y.current),y.current=setTimeout(()=>x(ee),800)},[x]),k=_.useCallback((ee,oe,we=!1)=>{d(ke=>{const Oe={...ke,[ee]:oe};return(oe===""||oe===null||oe===void 0)&&delete Oe[ee],we?x(Oe):b(Oe),Oe})},[x,b]),N=_.useCallback((ee,oe,we,ke=!0)=>{d(Oe=>{const $e={...Oe[ee]||{},[oe]:we};(we===""||we===null||we===void 0)&&delete $e[oe];const ct={...Oe};return Object.keys($e).length?ct[ee]=$e:delete ct[ee],ke?x(ct):b(ct),ct})},[x,b]),P=_.useCallback((ee,oe,we,ke,Oe=!0)=>{d($e=>{const ct={...$e[ee]||{}},st={...ct[oe]||{},[we]:ke};(ke===""||ke===null||ke===void 0)&&delete st[we],Object.keys(st).length?ct[oe]=st:delete ct[oe];const Ht={...$e};return Object.keys(ct).length?Ht[ee]=ct:delete Ht[ee],Oe?x(Ht):b(Ht),Ht})},[x,b]),A=_.useCallback(async ee=>{const oe={...c,permissions:ee};d(oe),await x(oe)},[c,x]),E=ee=>{j(ee);try{JSON.parse(ee),v(null)}catch(oe){v(oe.message)}},M=async()=>{if(S){q.error("Fix JSON errors before saving");return}try{const ee=JSON.parse(w);d(ee),await x(ee),q.success("Settings applied")}catch{q.error("Invalid JSON")}},I=ee=>{const oe=ee?ee.split(",").map(we=>we.trim()).filter(Boolean):[];return oe.length?oe:void 0};return t.jsxs("div",{className:"space-y-6",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("div",{className:"w-10 h-10 rounded-lg bg-indigo-100 dark:bg-indigo-950 flex items-center justify-center",children:t.jsx(hn,{className:"w-5 h-5 text-indigo-600 dark:text-indigo-400"})}),t.jsxs("div",{children:[t.jsx("h2",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:"Claude Code Settings"}),t.jsx("p",{className:"text-sm text-gray-500 dark:text-slate-400",children:"Configure Claude Code behavior globally"})]})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[f&&t.jsxs(rt,{variant:"outline",className:"bg-blue-50 dark:bg-blue-950/50 text-blue-700 dark:text-blue-400 border-blue-200 dark:border-blue-800",children:[t.jsx(Mr,{className:"w-3 h-3 mr-1 animate-spin"}),"Saving..."]}),t.jsx(ar,{children:t.jsxs(Ft,{children:[t.jsx(Bt,{asChild:!0,children:t.jsx(se,{variant:"outline",size:"sm",onClick:()=>g(!h),children:h?t.jsx(Lg,{className:"w-4 h-4"}):t.jsx(J5,{className:"w-4 h-4"})})}),t.jsx(Ot,{children:h?"Show UI":"Show JSON"})]})})]})]}),t.jsxs("p",{className:"text-sm text-gray-500 dark:text-slate-400",children:["Settings file: ",t.jsx("code",{className:"bg-gray-100 dark:bg-slate-800 px-2 py-0.5 rounded text-xs",children:n})]}),s&&t.jsx("div",{className:"flex items-center justify-center py-12",children:t.jsx(Mr,{className:"w-6 h-6 animate-spin text-gray-400"})}),!s&&h&&t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx(Ze,{children:"Raw JSON"}),t.jsxs("div",{className:"flex items-center gap-2",children:[S&&t.jsx(rt,{variant:"destructive",className:"text-xs",children:S}),t.jsxs(se,{size:"sm",onClick:M,disabled:f||!!S,className:"bg-indigo-600 hover:bg-indigo-700 text-white",children:[t.jsx(Mt,{className:"w-4 h-4 mr-1"}),"Apply JSON"]})]})]}),t.jsx(ft,{value:w,onChange:ee=>E(ee.target.value),className:Ee("font-mono text-sm min-h-[400px]",S&&"border-red-300 focus:border-red-500")})]}),!s&&!h&&t.jsxs($c,{value:l,onValueChange:u,children:[t.jsxs(ll,{className:"grid w-full grid-cols-5",children:[t.jsxs(Ms,{value:"permissions",className:"flex items-center gap-2",children:[t.jsx(Qn,{className:"w-4 h-4"}),"Permissions"]}),t.jsxs(Ms,{value:"model",className:"flex items-center gap-2",children:[t.jsx(Io,{className:"w-4 h-4"}),"Model"]}),t.jsxs(Ms,{value:"behavior",className:"flex items-center gap-2",children:[t.jsx(hn,{className:"w-4 h-4"}),"Behavior"]}),t.jsxs(Ms,{value:"sandbox",className:"flex items-center gap-2",children:[t.jsx(DM,{className:"w-4 h-4"}),"Sandbox"]}),t.jsxs(Ms,{value:"advanced",className:"flex items-center gap-2",children:[t.jsx(Ut,{className:"w-4 h-4"}),"Advanced"]})]}),t.jsxs(Hn,{value:"permissions",className:"space-y-6 pt-4",children:[t.jsx(w8,{permissions:c.permissions,onSave:A,loading:!1,mcpServers:o}),t.jsxs("div",{className:"space-y-4 pt-2",children:[t.jsx(Ze,{className:"text-base font-medium",children:"Permission Defaults"}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(Ze,{className:"text-sm",children:"Default Permission Mode"}),t.jsx("p",{className:"text-xs text-gray-500 dark:text-slate-400",children:"Starting permission mode for new sessions"}),t.jsxs(vr,{value:((O=c.permissions)==null?void 0:O.defaultMode)||"default",onValueChange:ee=>N("permissions","defaultMode",ee==="default"?void 0:ee),children:[t.jsx(hr,{children:t.jsx(yr,{})}),t.jsx(fr,{children:C8.map(ee=>t.jsx(At,{value:ee.value,children:ee.label},ee.value))})]})]}),t.jsx(zr,{label:"Disable Bypass Permissions Mode",description:"Prevent using dangerously-skip-permissions flag",checked:((z=c.permissions)==null?void 0:z.disableBypassPermissionsMode)==="disable",onCheckedChange:ee=>N("permissions","disableBypassPermissionsMode",ee?"disable":void 0)}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(Ze,{className:"text-sm",children:"Additional Directories"}),t.jsx("p",{className:"text-xs text-gray-500 dark:text-slate-400",children:"Extra paths Claude can access (comma-separated)"}),t.jsx(He,{value:(((U=c.permissions)==null?void 0:U.additionalDirectories)||[]).join(", "),onChange:ee=>N("permissions","additionalDirectories",I(ee.target.value),!1),placeholder:"~/other-project, /shared/docs",className:"font-mono text-sm"})]})]})]}),t.jsx(Hn,{value:"model",className:"space-y-6 pt-4",children:t.jsxs("div",{className:"space-y-6",children:[t.jsxs("div",{children:[t.jsx(Ze,{className:"text-base font-medium",children:"Default Model"}),t.jsx("p",{className:"text-sm text-gray-500 dark:text-slate-400 mb-3",children:"Select the default model for Claude Code sessions"}),t.jsx("div",{className:"grid gap-3",children:_8.map(ee=>t.jsx("button",{onClick:()=>k("model",ee.id,!0),className:Ee("w-full p-4 rounded-lg border text-left transition-all",c.model===ee.id?"border-indigo-500 bg-indigo-50 dark:bg-indigo-950/50":"border-gray-200 dark:border-slate-700 hover:border-gray-300 dark:hover:border-slate-600"),children:t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"font-medium",children:ee.name}),ee.recommended&&t.jsx(rt,{variant:"secondary",className:"text-xs",children:"Recommended"}),t.jsx(rt,{variant:"outline",className:Ee("text-xs",ee.tier==="opus"&&"border-purple-300 text-purple-700",ee.tier==="sonnet"&&"border-blue-300 text-blue-700",ee.tier==="haiku"&&"border-green-300 text-green-700"),children:ee.tier})]}),t.jsx("p",{className:"text-sm text-gray-500 dark:text-slate-400 mt-1",children:ee.description})]}),c.model===ee.id&&t.jsx(Mt,{className:"w-5 h-5 text-indigo-600 dark:text-indigo-400"})]})},ee.id))})]}),t.jsxs("div",{children:[t.jsx(Ze,{className:"text-base font-medium",children:"Effort Level"}),t.jsx("p",{className:"text-sm text-gray-500 dark:text-slate-400 mb-3",children:"Opus reasoning effort (affects speed vs thoroughness)"}),t.jsx("div",{className:"grid grid-cols-3 gap-3",children:S8.map(ee=>t.jsxs("button",{onClick:()=>k("effortLevel",ee.value,!0),className:Ee("p-3 rounded-lg border text-left transition-all",c.effortLevel===ee.value?"border-indigo-500 bg-indigo-50 dark:bg-indigo-950/50":"border-gray-200 dark:border-slate-700 hover:border-gray-300 dark:hover:border-slate-600"),children:[t.jsx("span",{className:"font-medium text-sm",children:ee.label}),t.jsx("p",{className:"text-xs text-gray-500 dark:text-slate-400 mt-1",children:ee.description})]},ee.value))})]}),t.jsx(zr,{label:"Always Enable Extended Thinking",description:"Enable extended thinking by default for all conversations",checked:c.alwaysThinkingEnabled??!1,onCheckedChange:ee=>k("alwaysThinkingEnabled",ee,!0)}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(Ze,{children:"Restrict Available Models"}),t.jsx("p",{className:"text-xs text-gray-500 dark:text-slate-400",children:"Comma-separated list of model aliases users can select (empty = all)"}),t.jsx(He,{value:(c.availableModels||[]).join(", "),onChange:ee=>k("availableModels",I(ee.target.value)),placeholder:"opus, sonnet, haiku",className:"font-mono text-sm"})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(Ze,{children:"Custom Model ID"}),t.jsx("p",{className:"text-xs text-gray-500 dark:text-slate-400",children:"Override with a specific model ID (for AWS Bedrock, etc.)"}),t.jsx(He,{value:c.model||"",onChange:ee=>k("model",ee.target.value),placeholder:"claude-opus-4-6",className:"font-mono"})]})]})}),t.jsx(Hn,{value:"behavior",className:"space-y-6 pt-4",children:t.jsxs("div",{className:"space-y-4",children:[t.jsx(Ze,{className:"text-base font-medium",children:"Session Behavior"}),t.jsx(zr,{label:"Respect .gitignore",description:"Honor .gitignore patterns when searching files",checked:c.respectGitignore??!0,onCheckedChange:ee=>k("respectGitignore",ee,!0)}),t.jsx(zr,{label:"Show Thinking Summaries",description:"Display summaries of extended thinking",checked:c.showThinkingSummaries??!1,onCheckedChange:ee=>k("showThinkingSummaries",ee,!0)}),t.jsx(zr,{label:"Voice Dictation",description:"Enable push-to-talk voice input",checked:c.voiceEnabled??!1,onCheckedChange:ee=>k("voiceEnabled",ee,!0)}),t.jsx(zr,{label:"Reduced Motion",description:"Reduce UI animations",checked:c.prefersReducedMotion??!1,onCheckedChange:ee=>k("prefersReducedMotion",ee,!0)}),t.jsx(Ze,{className:"text-base font-medium pt-2",children:"Memory"}),t.jsx(zr,{label:"Auto Memory",description:"Allow Claude to automatically save notes across sessions",checked:c.autoMemoryEnabled??!0,onCheckedChange:ee=>k("autoMemoryEnabled",ee,!0)}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(Ze,{className:"text-sm",children:"Auto Memory Directory"}),t.jsx("p",{className:"text-xs text-gray-500 dark:text-slate-400",children:"Custom path for auto-memory storage"}),t.jsx(He,{value:c.autoMemoryDirectory||"",onChange:ee=>k("autoMemoryDirectory",ee.target.value),placeholder:"~/.claude/projects/<project>/memory",className:"font-mono text-sm"})]}),t.jsx(Ze,{className:"text-base font-medium pt-2",children:"MCP & Servers"}),t.jsx(zr,{label:"Enable All Project MCP Servers",description:"Auto-approve all MCP servers defined in project .mcp.json",checked:c.enableAllProjectMcpServers??!1,onCheckedChange:ee=>k("enableAllProjectMcpServers",ee,!0)}),t.jsx(Ze,{className:"text-base font-medium pt-2",children:"Hooks"}),t.jsx(zr,{label:"Disable All Hooks",description:"Kill switch to disable all hook scripts",checked:c.disableAllHooks??!1,onCheckedChange:ee=>k("disableAllHooks",ee,!0)}),t.jsx(Ze,{className:"text-base font-medium pt-2",children:"Display"}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(Ze,{className:"text-sm",children:"Language"}),t.jsx("p",{className:"text-xs text-gray-500 dark:text-slate-400",children:"Response language preference"}),t.jsx(He,{value:c.language||"",onChange:ee=>k("language",ee.target.value),placeholder:"english",className:"font-mono text-sm"})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(Ze,{className:"text-sm",children:"Output Style"}),t.jsx("p",{className:"text-xs text-gray-500 dark:text-slate-400",children:"Named output style for responses"}),t.jsx(He,{value:c.outputStyle||"",onChange:ee=>k("outputStyle",ee.target.value),placeholder:"concise",className:"font-mono text-sm"})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(Ze,{className:"text-sm",children:"Teammate Mode"}),t.jsx("p",{className:"text-xs text-gray-500 dark:text-slate-400",children:"How agent team teammates are displayed"}),t.jsxs(vr,{value:c.teammateMode||"auto",onValueChange:ee=>k("teammateMode",ee==="auto"?void 0:ee,!0),children:[t.jsx(hr,{children:t.jsx(yr,{})}),t.jsx(fr,{children:k8.map(ee=>t.jsx(At,{value:ee.value,children:ee.label},ee.value))})]})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(Ze,{className:"text-sm",children:"Default Shell"}),t.jsx("p",{className:"text-xs text-gray-500 dark:text-slate-400",children:"Shell used for bash commands"}),t.jsxs(vr,{value:c.defaultShell||"bash",onValueChange:ee=>k("defaultShell",ee==="bash"?void 0:ee,!0),children:[t.jsx(hr,{children:t.jsx(yr,{})}),t.jsxs(fr,{children:[t.jsx(At,{value:"bash",children:"Bash"}),t.jsx(At,{value:"powershell",children:"PowerShell"})]})]})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(Ze,{className:"text-sm",children:"Auto-updates Channel"}),t.jsx("p",{className:"text-xs text-gray-500 dark:text-slate-400",children:"Release channel for auto-updates"}),t.jsxs(vr,{value:c.autoUpdatesChannel||"latest",onValueChange:ee=>k("autoUpdatesChannel",ee==="latest"?void 0:ee,!0),children:[t.jsx(hr,{children:t.jsx(yr,{})}),t.jsxs(fr,{children:[t.jsx(At,{value:"latest",children:"Latest (default)"}),t.jsx(At,{value:"stable",children:"Stable"})]})]})]}),t.jsx(Ze,{className:"text-base font-medium pt-2",children:"Worktree"}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(Ze,{className:"text-sm",children:"Symlink Directories"}),t.jsx("p",{className:"text-xs text-gray-500 dark:text-slate-400",children:"Directories to symlink into worktrees (comma-separated)"}),t.jsx(He,{value:(((X=c.worktree)==null?void 0:X.symlinkDirectories)||[]).join(", "),onChange:ee=>N("worktree","symlinkDirectories",I(ee.target.value),!1),placeholder:"node_modules, .venv",className:"font-mono text-sm"})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(Ze,{className:"text-sm",children:"Sparse Paths"}),t.jsx("p",{className:"text-xs text-gray-500 dark:text-slate-400",children:"Git sparse-checkout paths for worktrees (comma-separated)"}),t.jsx(He,{value:(((W=c.worktree)==null?void 0:W.sparsePaths)||[]).join(", "),onChange:ee=>N("worktree","sparsePaths",I(ee.target.value),!1),placeholder:"src/, lib/",className:"font-mono text-sm"})]}),t.jsx(Ze,{className:"text-base font-medium pt-2",children:"Paths & Cleanup"}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(Ze,{className:"text-sm",children:"Plans Directory"}),t.jsx("p",{className:"text-xs text-gray-500 dark:text-slate-400",children:"Directory where plan files are saved"}),t.jsx(He,{value:c.plansDirectory||"",onChange:ee=>k("plansDirectory",ee.target.value),placeholder:"./plans",className:"font-mono text-sm"})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(Ze,{className:"text-sm",children:"Cleanup Period (days)"}),t.jsx("p",{className:"text-xs text-gray-500 dark:text-slate-400",children:"Auto-cleanup interval for old session data (min: 1)"}),t.jsx(He,{type:"number",min:"1",value:c.cleanupPeriodDays??"",onChange:ee=>k("cleanupPeriodDays",ee.target.value?Math.max(1,Number(ee.target.value)):void 0),placeholder:"30",className:"font-mono text-sm w-32"})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(Ze,{className:"text-sm",children:"CLAUDE.md Excludes"}),t.jsx("p",{className:"text-xs text-gray-500 dark:text-slate-400",children:"Glob patterns to skip specific CLAUDE.md files (comma-separated)"}),t.jsx(He,{value:(c.claudeMdExcludes||[]).join(", "),onChange:ee=>k("claudeMdExcludes",I(ee.target.value)),placeholder:"packages/legacy/CLAUDE.md",className:"font-mono text-sm"})]}),t.jsx(zr,{label:"Disable Skill Shell Execution",description:"Prevent skills/commands from running shell commands",checked:c.disableSkillShellExecution??!1,onCheckedChange:ee=>k("disableSkillShellExecution",ee,!0)}),t.jsx(Ze,{className:"text-base font-medium pt-2",children:"Attribution"}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(Ze,{className:"text-sm",children:"Commit Attribution"}),t.jsx("p",{className:"text-xs text-gray-500 dark:text-slate-400",children:"Template appended to commit messages"}),t.jsx(ft,{value:(($=c.attribution)==null?void 0:$.commit)||"",onChange:ee=>N("attribution","commit",ee.target.value||void 0,!1),placeholder:`Generated with AI
617
617
 
618
618
  Co-Authored-By: AI <ai@example.com>`,className:"font-mono text-sm min-h-[80px]"})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(Ze,{className:"text-sm",children:"PR Attribution"}),t.jsx("p",{className:"text-xs text-gray-500 dark:text-slate-400",children:"Template appended to pull request descriptions"}),t.jsx(ft,{value:((Y=c.attribution)==null?void 0:Y.pr)||"",onChange:ee=>N("attribution","pr",ee.target.value||void 0,!1),placeholder:"Generated with Claude Code",className:"font-mono text-sm min-h-[60px]"})]})]})}),t.jsx(Hn,{value:"sandbox",className:"space-y-6 pt-4",children:t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{children:[t.jsx(Ze,{className:"text-base font-medium",children:"Sandbox Configuration"}),t.jsx("p",{className:"text-sm text-gray-500 dark:text-slate-400",children:"Filesystem and network sandboxing for Claude Code commands"})]}),t.jsx(zr,{label:"Enable Sandbox",description:"Restrict filesystem and network access for bash commands",checked:((K=c.sandbox)==null?void 0:K.enabled)??!1,onCheckedChange:ee=>N("sandbox","enabled",ee)}),t.jsx(zr,{label:"Auto-allow Bash When Sandboxed",description:"Automatically approve bash commands when sandbox is active",checked:((L=c.sandbox)==null?void 0:L.autoAllowBashIfSandboxed)??!0,onCheckedChange:ee=>N("sandbox","autoAllowBashIfSandboxed",ee)}),t.jsx(zr,{label:"Fail If Sandbox Unavailable",description:"Exit if the sandbox environment cannot be started",checked:((T=c.sandbox)==null?void 0:T.failIfUnavailable)??!1,onCheckedChange:ee=>N("sandbox","failIfUnavailable",ee)}),t.jsx(Ze,{className:"text-base font-medium pt-2",children:"Filesystem Rules"}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(Ze,{className:"text-sm",children:"Allow Write"}),t.jsx("p",{className:"text-xs text-gray-500 dark:text-slate-400",children:"Additional writable paths (comma-separated)"}),t.jsx(He,{value:(((G=(B=c.sandbox)==null?void 0:B.filesystem)==null?void 0:G.allowWrite)||[]).join(", "),onChange:ee=>P("sandbox","filesystem","allowWrite",I(ee.target.value),!1),placeholder:"/tmp/builds, ~/output",className:"font-mono text-sm"})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(Ze,{className:"text-sm",children:"Deny Write"}),t.jsx("p",{className:"text-xs text-gray-500 dark:text-slate-400",children:"Blocked write paths (comma-separated)"}),t.jsx(He,{value:(((re=(F=c.sandbox)==null?void 0:F.filesystem)==null?void 0:re.denyWrite)||[]).join(", "),onChange:ee=>P("sandbox","filesystem","denyWrite",I(ee.target.value),!1),placeholder:"~/.ssh, ~/.gnupg",className:"font-mono text-sm"})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(Ze,{className:"text-sm",children:"Deny Read"}),t.jsx("p",{className:"text-xs text-gray-500 dark:text-slate-400",children:"Blocked read paths (comma-separated)"}),t.jsx(He,{value:(((he=(ue=c.sandbox)==null?void 0:ue.filesystem)==null?void 0:he.denyRead)||[]).join(", "),onChange:ee=>P("sandbox","filesystem","denyRead",I(ee.target.value),!1),placeholder:"~/.ssh, ~/.gnupg, ~/.aws",className:"font-mono text-sm"})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(Ze,{className:"text-sm",children:"Allow Read (within denied)"}),t.jsx("p",{className:"text-xs text-gray-500 dark:text-slate-400",children:"Re-allow specific paths within denyRead (comma-separated)"}),t.jsx(He,{value:(((H=(J=c.sandbox)==null?void 0:J.filesystem)==null?void 0:H.allowRead)||[]).join(", "),onChange:ee=>P("sandbox","filesystem","allowRead",I(ee.target.value),!1),placeholder:"~/.ssh/known_hosts",className:"font-mono text-sm"})]}),t.jsx(Ze,{className:"text-base font-medium pt-2",children:"Network Rules"}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(Ze,{className:"text-sm",children:"Allowed Domains"}),t.jsx("p",{className:"text-xs text-gray-500 dark:text-slate-400",children:"Domains accessible in sandbox mode (comma-separated, supports wildcards)"}),t.jsx(He,{value:(((ie=(ae=c.sandbox)==null?void 0:ae.network)==null?void 0:ie.allowedDomains)||[]).join(", "),onChange:ee=>P("sandbox","network","allowedDomains",I(ee.target.value),!1),placeholder:"github.com, *.npmjs.org, registry.yarnpkg.com",className:"font-mono text-sm"})]}),t.jsx(zr,{label:"Allow Local Port Binding",description:"Allow sandboxed commands to bind to local ports",checked:((ce=(Z=c.sandbox)==null?void 0:Z.network)==null?void 0:ce.allowLocalBinding)??!1,onCheckedChange:ee=>P("sandbox","network","allowLocalBinding",ee)}),t.jsx(zr,{label:"Allow All Unix Sockets",description:"Allow sandboxed commands to use any Unix socket",checked:((Re=(Ce=c.sandbox)==null?void 0:Ce.network)==null?void 0:Re.allowAllUnixSockets)??!1,onCheckedChange:ee=>P("sandbox","network","allowAllUnixSockets",ee)}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(Ze,{className:"text-sm",children:"Allowed Unix Sockets"}),t.jsx("p",{className:"text-xs text-gray-500 dark:text-slate-400",children:"Specific Unix sockets accessible in sandbox (comma-separated)"}),t.jsx(He,{value:(((pe=(We=c.sandbox)==null?void 0:We.network)==null?void 0:pe.allowUnixSockets)||[]).join(", "),onChange:ee=>P("sandbox","network","allowUnixSockets",I(ee.target.value),!1),placeholder:"~/.ssh/agent-socket",className:"font-mono text-sm"})]}),t.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[t.jsxs("div",{className:"space-y-2",children:[t.jsx(Ze,{className:"text-sm",children:"HTTP Proxy Port"}),t.jsx(He,{type:"number",value:((Be=(_e=c.sandbox)==null?void 0:_e.network)==null?void 0:Be.httpProxyPort)??"",onChange:ee=>P("sandbox","network","httpProxyPort",ee.target.value?Number(ee.target.value):void 0),placeholder:"8080",className:"font-mono text-sm"})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(Ze,{className:"text-sm",children:"SOCKS Proxy Port"}),t.jsx(He,{type:"number",value:((Je=(Ve=c.sandbox)==null?void 0:Ve.network)==null?void 0:Je.socksProxyPort)??"",onChange:ee=>P("sandbox","network","socksProxyPort",ee.target.value?Number(ee.target.value):void 0),placeholder:"8081",className:"font-mono text-sm"})]})]}),t.jsx(Ze,{className:"text-base font-medium pt-2",children:"Advanced"}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(Ze,{className:"text-sm",children:"Excluded Commands"}),t.jsx("p",{className:"text-xs text-gray-500 dark:text-slate-400",children:"Commands excluded from sandbox restrictions (comma-separated)"}),t.jsx(He,{value:(((Ct=c.sandbox)==null?void 0:Ct.excludedCommands)||[]).join(", "),onChange:ee=>N("sandbox","excludedCommands",I(ee.target.value),!1),placeholder:"git, docker",className:"font-mono text-sm"})]}),t.jsx(zr,{label:"Allow Unsandboxed Commands",description:"Allow running commands outside the sandbox when needed",checked:((Se=c.sandbox)==null?void 0:Se.allowUnsandboxedCommands)??!1,onCheckedChange:ee=>N("sandbox","allowUnsandboxedCommands",ee)}),t.jsx(zr,{label:"Enable Weaker Nested Sandbox",description:"Use less restrictive sandbox for Docker/WSL2 (Linux)",checked:((me=c.sandbox)==null?void 0:me.enableWeakerNestedSandbox)??!1,onCheckedChange:ee=>N("sandbox","enableWeakerNestedSandbox",ee)}),t.jsx(zr,{label:"Enable Weaker Network Isolation",description:"Allow TLS trust service access in sandbox (macOS)",checked:((be=c.sandbox)==null?void 0:be.enableWeakerNetworkIsolation)??!1,onCheckedChange:ee=>N("sandbox","enableWeakerNetworkIsolation",ee)})]})}),t.jsxs(Hn,{value:"advanced",className:"space-y-6 pt-4",children:[t.jsxs(Za,{children:[t.jsx(Gi,{className:"w-4 h-4"}),t.jsx(el,{children:"Advanced settings for power users. Incorrect values may cause Claude Code to malfunction."})]}),t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{children:[t.jsx(Ze,{className:"text-base font-medium",children:"Environment Variables"}),t.jsx("p",{className:"text-sm text-gray-500 dark:text-slate-400 mb-3",children:"Configure model, timeout, and runtime environment variables"}),t.jsx("div",{className:"space-y-3",children:j8.map(ee=>{var oe;return t.jsxs("div",{className:"space-y-1",children:[t.jsx(Ze,{className:"text-sm",children:ee.label}),t.jsx("p",{className:"text-xs text-gray-500 dark:text-slate-400",children:ee.description}),t.jsx(He,{value:((oe=c.env)==null?void 0:oe[ee.key])||"",onChange:we=>{const ke={...c.env||{},[ee.key]:we.target.value};we.target.value||delete ke[ee.key],k("env",Object.keys(ke).length?ke:void 0)},placeholder:ee.placeholder,className:"font-mono text-sm"})]},ee.key)})})]}),t.jsxs("div",{children:[t.jsx(Ze,{className:"text-base font-medium",children:"Hooks"}),t.jsx("p",{className:"text-sm text-gray-500 dark:text-slate-400 mb-3",children:"Scripts to run before/after tool executions (JSON format)"}),t.jsx(ft,{value:c.hooks?JSON.stringify(c.hooks,null,2):"",onChange:ee=>{try{const oe=ee.target.value?JSON.parse(ee.target.value):void 0;k("hooks",oe)}catch{}},placeholder:`{
619
619
  "PreToolUse": [{ "matcher": "Bash", "hooks": [{ "type": "command", "command": "~/.claude/hooks/pre.sh" }] }],
@@ -623,7 +623,7 @@ Co-Authored-By: AI <ai@example.com>`,className:"font-mono text-sm min-h-[80px]"}
623
623
  }`,className:"font-mono text-sm min-h-[100px]"})]})]})]})]})]})}const N8=[{id:"Default",name:"Default"},{id:"GitHub",name:"GitHub"},{id:"Monokai",name:"Monokai"},{id:"SolarizedDark",name:"Solarized Dark"},{id:"SolarizedLight",name:"Solarized Light"}],E8=[{id:"gemini-2.5-pro",name:"Gemini 2.5 Pro",description:"Most capable"},{id:"gemini-2.5-flash",name:"Gemini 2.5 Flash",description:"Fast and efficient"},{id:"gemini-2.0-pro",name:"Gemini 2.0 Pro",description:"Previous generation"},{id:"gemini-2.0-flash",name:"Gemini 2.0 Flash",description:"Previous generation fast"}];function jN({settings:e,onSave:r,loading:s,settingsPath:n}){var A,E,M,I;const[o,c]=_.useState(e||{}),[d,l]=_.useState(!1),[u,f]=_.useState("rich"),[m,h]=_.useState(JSON.stringify(e||{},null,2)),[g,w]=_.useState({open:!1,name:"",json:""}),[j,S]=_.useState({}),v=async()=>{l(!0);try{if(u==="json")try{const O=JSON.parse(m);await r(O),c(O)}catch{q.error("Invalid JSON"),l(!1);return}else await r(o),h(JSON.stringify(o,null,2));q.success("Settings saved")}finally{l(!1)}},y=(O,z,U)=>{c(X=>({...X,[O]:{...X[O],[z]:U}}))},x=(O,z,U=!1)=>{var X;return((X=o==null?void 0:o[O])==null?void 0:X[z])??U},b=o.mcpServers||{},k=()=>{const{name:O,json:z}=g;if(!O.trim()){q.error("Please enter a name for the MCP");return}let U;try{U=JSON.parse(z)}catch{q.error("Invalid JSON configuration");return}if(!U.command){q.error('MCP config must have a "command" field');return}c(X=>({...X,mcpServers:{...X.mcpServers,[O.trim()]:U}})),w({open:!1,name:"",json:""}),q.success(`Added MCP: ${O}`)},N=O=>{c(z=>{const{[O]:U,...X}=z.mcpServers||{};return{...z,mcpServers:X}}),q.success(`Removed MCP: ${O}`)},P=O=>{S(z=>({...z,[O]:!z[O]}))};return t.jsxs("div",{className:"space-y-6",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("div",{className:"w-10 h-10 rounded-lg bg-blue-500/10 flex items-center justify-center",children:t.jsx(Ut,{className:"w-5 h-5 text-blue-500"})}),t.jsxs("div",{children:[t.jsxs("h2",{className:"text-lg font-semibold text-foreground flex items-center gap-2",children:["Gemini CLI Settings",t.jsxs(rt,{variant:"outline",className:"text-xs font-normal text-blue-600 border-blue-300 dark:border-blue-700",children:[t.jsx(Vt,{className:"w-3 h-3 mr-1"}),"Google"]})]}),t.jsxs("p",{className:"text-sm text-muted-foreground",children:["Stored in: ",t.jsx("code",{className:"bg-muted px-1.5 py-0.5 rounded text-xs",children:n})]})]})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs("div",{className:"flex bg-muted rounded-lg p-1",children:[t.jsx("button",{className:`px-3 py-1 text-sm rounded-md transition-colors ${u==="rich"?"bg-background shadow-sm":"text-muted-foreground hover:text-foreground"}`,onClick:()=>f("rich"),children:"Settings"}),t.jsx("button",{className:`px-3 py-1 text-sm rounded-md transition-colors ${u==="json"?"bg-background shadow-sm":"text-muted-foreground hover:text-foreground"}`,onClick:()=>{h(JSON.stringify(o,null,2)),f("json")},children:"JSON"})]}),t.jsxs(se,{onClick:v,disabled:d||s,children:[d?t.jsx(et,{className:"w-4 h-4 mr-2 animate-spin"}):t.jsx(bs,{className:"w-4 h-4 mr-2"}),"Save"]})]})]}),u==="json"?t.jsx("div",{className:"border border-border rounded-lg bg-card overflow-hidden",children:t.jsx(ft,{value:m,onChange:O=>h(O.target.value),className:"font-mono text-sm min-h-[500px] border-0 rounded-none resize-none",placeholder:"{ }"})}):t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"border border-border rounded-lg p-4 bg-card",children:[t.jsxs("div",{className:"flex items-center justify-between mb-4",children:[t.jsxs("h3",{className:"text-sm font-medium text-foreground flex items-center gap-2",children:[t.jsx(ys,{className:"w-4 h-4 text-blue-500"}),"MCP Servers",t.jsx(rt,{variant:"secondary",className:"text-xs",children:Object.keys(b).length})]}),t.jsxs(se,{size:"sm",variant:"outline",onClick:()=>w({open:!0,name:"",json:`{
624
624
  "command": "npx",
625
625
  "args": ["-y", "@example/mcp-server"]
626
- }`}),children:[t.jsx(It,{className:"w-4 h-4 mr-1"}),"Add MCP"]})]}),t.jsx("div",{className:"space-y-2",children:Object.keys(b).length===0?t.jsx("p",{className:"text-sm text-muted-foreground italic",children:"No MCP servers configured"}):Object.entries(b).map(([O,z])=>t.jsxs(Hc,{open:j[O],onOpenChange:()=>P(O),children:[t.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg border bg-background group",children:[t.jsxs(Wc,{className:"flex items-center gap-2 flex-1 text-left",children:[j[O]?t.jsx(xr,{className:"w-4 h-4 text-muted-foreground"}):t.jsx(vs,{className:"w-4 h-4 text-muted-foreground"}),t.jsx(ys,{className:"w-4 h-4 text-blue-500"}),t.jsx("span",{className:"font-medium text-sm",children:O}),t.jsx("span",{className:"text-xs text-muted-foreground font-mono",children:z.command})]}),t.jsx(se,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0 opacity-0 group-hover:opacity-100 text-destructive hover:text-destructive",onClick:()=>N(O),children:t.jsx(ws,{className:"w-4 h-4"})})]}),t.jsx(Uc,{children:t.jsx("div",{className:"mt-2 ml-6 p-3 rounded-lg bg-muted/50 border",children:t.jsx("pre",{className:"text-xs font-mono text-muted-foreground overflow-x-auto",children:JSON.stringify(z,null,2)})})})]},O))})]}),t.jsxs("div",{className:"border border-border rounded-lg p-4 bg-card",children:[t.jsxs("h3",{className:"text-sm font-medium text-foreground mb-4 flex items-center gap-2",children:[t.jsx(Vt,{className:"w-4 h-4 text-blue-500"}),"Model"]}),t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("label",{className:"text-sm font-medium text-foreground",children:"Default Model"}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Model used for Gemini CLI sessions"})]}),t.jsxs(vr,{value:x("model","name",""),onValueChange:O=>y("model","name",O),children:[t.jsx(hr,{className:"w-48",children:t.jsx(yr,{placeholder:"Select model"})}),t.jsx(fr,{children:E8.map(O=>t.jsx(At,{value:O.id,children:t.jsx("div",{className:"flex flex-col",children:t.jsx("span",{children:O.name})})},O.id))})]})]}),t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("label",{className:"text-sm font-medium text-foreground",children:"Preview Features"}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Enable access to experimental models and features"})]}),t.jsx(_t,{checked:x("general","previewFeatures",!1),onCheckedChange:O=>y("general","previewFeatures",O)})]})]})]}),t.jsxs("div",{className:"border border-border rounded-lg p-4 bg-card",children:[t.jsxs("h3",{className:"text-sm font-medium text-foreground mb-4 flex items-center gap-2",children:[t.jsx(YM,{className:"w-4 h-4 text-blue-500"}),"Appearance"]}),t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("label",{className:"text-sm font-medium text-foreground",children:"Theme"}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Color theme for the CLI interface"})]}),t.jsxs(vr,{value:x("ui","theme","Default"),onValueChange:O=>y("ui","theme",O),children:[t.jsx(hr,{className:"w-40",children:t.jsx(yr,{})}),t.jsx(fr,{children:N8.map(O=>t.jsx(At,{value:O.id,children:O.name},O.id))})]})]}),t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("label",{className:"text-sm font-medium text-foreground",children:"Output Format"}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Format for CLI output"})]}),t.jsxs(vr,{value:x("output","format","text"),onValueChange:O=>y("output","format",O),children:[t.jsx(hr,{className:"w-40",children:t.jsx(yr,{})}),t.jsxs(fr,{children:[t.jsx(At,{value:"text",children:"Text"}),t.jsx(At,{value:"json",children:"JSON"})]})]})]})]})]}),t.jsxs("div",{className:"border border-border rounded-lg p-4 bg-card",children:[t.jsxs("h3",{className:"text-sm font-medium text-foreground mb-4 flex items-center gap-2",children:[t.jsx(pC,{className:"w-4 h-4 text-blue-500"}),"Display Options"]}),t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("label",{className:"text-sm font-medium text-foreground",children:"Dynamic Window Title"}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Update title with status icons (Ready, Working, etc.)"})]}),t.jsx(_t,{checked:x("ui","dynamicWindowTitle",!0),onCheckedChange:O=>y("ui","dynamicWindowTitle",O)})]}),t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("label",{className:"text-sm font-medium text-foreground",children:"Show Line Numbers"}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Display line numbers in chat"})]}),t.jsx(_t,{checked:x("ui","showLineNumbers",!0),onCheckedChange:O=>y("ui","showLineNumbers",O)})]}),t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("label",{className:"text-sm font-medium text-foreground",children:"Show Citations"}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Display citations for generated text"})]}),t.jsx(_t,{checked:x("ui","showCitations",!1),onCheckedChange:O=>y("ui","showCitations",O)})]}),t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("label",{className:"text-sm font-medium text-foreground",children:"Hide Context Summary"}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Hide GEMINI.md and MCP servers above input"})]}),t.jsx(_t,{checked:x("ui","hideContextSummary",!1),onCheckedChange:O=>y("ui","hideContextSummary",O)})]}),t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("label",{className:"text-sm font-medium text-foreground",children:"Hide Footer"}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Remove footer entirely from the UI"})]}),t.jsx(_t,{checked:x("ui","hideFooter",!1),onCheckedChange:O=>y("ui","hideFooter",O)})]}),t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("label",{className:"text-sm font-medium text-foreground",children:"Screen Reader Mode"}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Render output in plain-text for accessibility"})]}),t.jsx(_t,{checked:((E=(A=o==null?void 0:o.ui)==null?void 0:A.accessibility)==null?void 0:E.screenReader)??!1,onCheckedChange:O=>c(z=>{var U;return{...z,ui:{...z.ui,accessibility:{...(U=z.ui)==null?void 0:U.accessibility,screenReader:O}}}})})]})]})]}),t.jsxs("div",{className:"border border-border rounded-lg p-4 bg-card",children:[t.jsxs("h3",{className:"text-sm font-medium text-foreground mb-4 flex items-center gap-2",children:[t.jsx(hn,{className:"w-4 h-4 text-blue-500"}),"General"]}),t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("label",{className:"text-sm font-medium text-foreground",children:"Vim Mode"}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Enable Vim keybindings in the prompt editor"})]}),t.jsx(_t,{checked:x("general","vimMode",!1),onCheckedChange:O=>y("general","vimMode",O)})]}),t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("label",{className:"text-sm font-medium text-foreground",children:"Auto Update"}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Allow automatic updates to Gemini CLI"})]}),t.jsx(_t,{checked:x("general","enableAutoUpdate",!0),onCheckedChange:O=>y("general","enableAutoUpdate",O)})]}),t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("label",{className:"text-sm font-medium text-foreground",children:"Checkpointing"}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Enable session recovery support"})]}),t.jsx(_t,{checked:((I=(M=o==null?void 0:o.general)==null?void 0:M.checkpointing)==null?void 0:I.enabled)??!1,onCheckedChange:O=>c(z=>{var U;return{...z,general:{...z.general,checkpointing:{...(U=z.general)==null?void 0:U.checkpointing,enabled:O}}}})})]}),t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("label",{className:"text-sm font-medium text-foreground",children:"Respect .gitignore"}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Exclude files matching .gitignore patterns"})]}),t.jsx(_t,{checked:x("general","respectGitignore",!0),onCheckedChange:O=>y("general","respectGitignore",O)})]})]})]}),t.jsxs("div",{className:"border border-border rounded-lg p-4 bg-card",children:[t.jsxs("h3",{className:"text-sm font-medium text-foreground mb-4 flex items-center gap-2",children:[t.jsx(Qn,{className:"w-4 h-4 text-blue-500"}),"Privacy"]}),t.jsx("div",{className:"space-y-4",children:t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("label",{className:"text-sm font-medium text-foreground",children:"Usage Statistics"}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Allow collection of anonymous usage data"})]}),t.jsx(_t,{checked:x("privacy","usageStatisticsEnabled",!0),onCheckedChange:O=>y("privacy","usageStatisticsEnabled",O)})]})})]})]}),t.jsx(bt,{open:g.open,onOpenChange:O=>w({...g,open:O}),children:t.jsxs(mt,{className:"bg-card",children:[t.jsxs(pt,{children:[t.jsx(gt,{children:"Add MCP Server"}),t.jsx(sr,{children:"Add a new MCP server to Gemini CLI"})]}),t.jsxs("div",{className:"space-y-4 py-4",children:[t.jsxs("div",{children:[t.jsx("label",{className:"text-sm font-medium",children:"Name"}),t.jsx(He,{value:g.name,onChange:O=>w({...g,name:O.target.value}),placeholder:"my-mcp-server",className:"mt-1"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"text-sm font-medium",children:"Configuration (JSON)"}),t.jsx(ft,{value:g.json,onChange:O=>w({...g,json:O.target.value}),className:"mt-1 font-mono text-sm",rows:6})]})]}),t.jsxs(jt,{children:[t.jsx(se,{variant:"ghost",onClick:()=>w({open:!1,name:"",json:""}),children:"Cancel"}),t.jsxs(se,{onClick:k,children:[t.jsx(It,{className:"w-4 h-4 mr-2"}),"Add MCP"]})]})]})})]})}function P8({content:e,parsed:r,onSave:s,filePath:n}){const o=async l=>{const u=JSON.stringify(l,null,2);s(u)},c=(n==null?void 0:n.includes(".gemini"))||(n==null?void 0:n.includes("/.gemini/")),d=(n==null?void 0:n.includes(".agent"))||(n==null?void 0:n.includes("/antigravity/"));return c&&!d?t.jsx("div",{className:"h-full overflow-auto p-4",children:t.jsx(jN,{settings:r||{},onSave:o,loading:!1,settingsPath:n||"~/.gemini/settings.json"})}):t.jsx("div",{className:"h-full overflow-auto p-4",children:t.jsx(kN,{settings:r||{},onSave:o,loading:!1,settingsPath:n||"~/.claude/settings.json"})})}function A8({content:e,parsed:r,onSave:s,registry:n}){const[o,c]=_.useState(r||{}),[d,l]=_.useState((r==null?void 0:r.mcpServers)||{}),[u,f]=_.useState("rich"),[m,h]=_.useState(JSON.stringify((r==null?void 0:r.mcpServers)||{},null,2)),[g,w]=_.useState(!1),[j,S]=_.useState({open:!1,json:""});_.useEffect(()=>{c(r||{}),l((r==null?void 0:r.mcpServers)||{}),h(JSON.stringify((r==null?void 0:r.mcpServers)||{},null,2))},[r]);const v=async A=>{w(!0);try{const E={...o,mcpServers:A};await s(JSON.stringify(E,null,2)),c(E)}catch(E){q.error("Failed to save: "+E.message)}finally{w(!1)}},y=A=>{var E;if(d[A]){const{[A]:M,...I}=d;l(I),h(JSON.stringify(I,null,2)),v(I),q.success(`Removed ${A} from global MCPs`)}else if((E=n==null?void 0:n.mcpServers)!=null&&E[A]){const M={...d,[A]:n.mcpServers[A]};l(M),h(JSON.stringify(M,null,2)),v(M),q.success(`Added ${A} to global MCPs`)}},x=A=>{const{[A]:E,...M}=d;l(M),h(JSON.stringify(M,null,2)),v(M),q.success(`Removed ${A}`)},b=A=>{const E={...d,...A};l(E),h(JSON.stringify(E,null,2)),v(E),S({open:!1,json:""});const M=Object.keys(A).length;q.success(`Added ${M} MCP${M>1?"s":""}`)},k=()=>{try{const A=JSON.parse(m);l(A),v(A),q.success("Saved")}catch(A){q.error("Invalid JSON: "+A.message)}},N=n!=null&&n.mcpServers?Object.keys(n.mcpServers):[],P=Object.entries(d).filter(([A,E])=>{var I;const M=(I=n==null?void 0:n.mcpServers)==null?void 0:I[A];return M?JSON.stringify(E)!==JSON.stringify(M):!0});return t.jsxs("div",{className:"h-full flex flex-col",children:[t.jsxs("div",{className:"flex items-center justify-between p-3 border-b bg-gray-50 dark:bg-slate-800",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(Ji,{className:"w-4 h-4 text-orange-500"}),t.jsx("span",{className:"text-sm font-medium",children:"Global MCPs"}),t.jsx(rt,{variant:"outline",className:"text-xs",children:"~/.claude.json"})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx($c,{value:u,onValueChange:f,children:t.jsxs(ll,{className:"h-8",children:[t.jsx(Ms,{value:"rich",className:"text-xs px-3",children:"Rich Editor"}),t.jsx(Ms,{value:"json",className:"text-xs px-3",children:"JSON"})]})}),g&&t.jsx(rt,{variant:"outline",className:"text-xs text-blue-600",children:"Saving..."}),t.jsxs(se,{size:"sm",variant:"outline",onClick:()=>S({open:!0,json:""}),children:[t.jsx(It,{className:"w-4 h-4 mr-1"}),"Add MCP"]}),u==="json"&&t.jsxs(se,{size:"sm",onClick:k,disabled:g,children:[t.jsx(bs,{className:"w-4 h-4 mr-1"}),"Apply JSON"]})]})]}),t.jsxs("div",{className:"mx-3 mt-3 p-3 rounded-lg bg-orange-50 dark:bg-orange-950/30 border border-orange-200 dark:border-orange-800 flex items-center gap-2",children:[t.jsx(Is,{className:"w-4 h-4 text-orange-600 shrink-0"}),t.jsxs("span",{className:"text-sm text-orange-800 dark:text-orange-200",children:["Global MCPs are available in ",t.jsx("strong",{children:"all projects"}),". They're stored in ",t.jsx("code",{className:"bg-orange-100 dark:bg-orange-900 px-1 rounded",children:"~/.claude.json"}),"."]})]}),t.jsx(Xs,{className:"flex-1",children:u==="rich"?t.jsx(ar,{children:t.jsxs("div",{className:"p-4 space-y-2",children:[P.map(([A,E])=>{var M;return t.jsxs("div",{className:"p-2 rounded border bg-white dark:bg-slate-950 group",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(ys,{className:"w-4 h-4 text-green-500"}),t.jsx("span",{className:"text-sm font-medium",children:A})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(rt,{variant:"outline",className:"text-xs",children:"custom"}),t.jsx(se,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0 opacity-0 group-hover:opacity-100 text-red-500 hover:text-red-700 hover:bg-red-50",onClick:()=>x(A),children:t.jsx(ws,{className:"w-3.5 h-3.5"})})]})]}),t.jsxs("p",{className:"text-xs text-gray-500 dark:text-slate-400 mt-1 font-mono",children:[E.command," ",(M=E.args)==null?void 0:M.join(" ")]})]},`custom-${A}`)}),N.map(A=>{var I;const E=!!d[A],M=n.mcpServers[A];return t.jsxs(Ft,{children:[t.jsx(Bt,{asChild:!0,children:t.jsxs("div",{className:`flex items-center justify-between p-2 rounded border ${E?"bg-green-50 dark:bg-green-950/20 border-green-200 dark:border-green-800":"bg-gray-50 dark:bg-slate-900 border-gray-200 dark:border-slate-700"}`,children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(ys,{className:`w-4 h-4 ${E?"text-green-500":"text-gray-400"}`}),t.jsx("span",{className:`text-sm ${E?"font-medium":"text-gray-500 dark:text-slate-400"}`,children:A}),M.description&&t.jsxs("span",{className:"text-xs text-gray-400 dark:text-slate-500 hidden sm:inline",children:["— ",M.description]})]}),t.jsx(_t,{checked:E,onCheckedChange:()=>y(A),className:E?"data-[state=checked]:bg-green-500":""})]})}),t.jsxs(Ot,{children:[t.jsxs("p",{className:"font-mono text-xs",children:[M.command," ",(I=M.args)==null?void 0:I.join(" ")]}),M.description&&t.jsx("p",{className:"text-xs text-gray-400 mt-1",children:M.description})]})]},`registry-${A}`)}),N.length===0&&P.length===0&&t.jsx("p",{className:"text-sm text-muted-foreground text-center py-8",children:"No MCPs configured. Use the registry toggle or add a custom MCP."})]})}):t.jsxs("div",{className:"p-4 space-y-3",children:[t.jsx("p",{className:"text-xs text-muted-foreground",children:"Edit the mcpServers section (other ~/.claude.json settings are preserved)"}),t.jsx(ft,{value:m,onChange:A=>h(A.target.value),className:"font-mono text-sm h-[400px]",placeholder:"{}"})]})}),t.jsx(vN,{open:j.open,onClose:A=>S({...j,open:A}),onAdd:b})]})}function T8({open:e,onClose:r,item:s,intermediatePaths:n,onMove:o}){const[c,d]=_.useState("copy"),[l,u]=_.useState(null),[f,m]=_.useState(""),[h,g]=_.useState(!1),w=()=>{const j=f.trim()||l;if(!j){q.error("Please select or enter a target path");return}o(s.path,j,c,h)};return t.jsx(bt,{open:e,onOpenChange:r,children:t.jsxs(mt,{className:"max-w-md",children:[t.jsxs(pt,{children:[t.jsxs(gt,{children:[c==="copy"?"Copy":"Move"," ",s==null?void 0:s.name]}),t.jsx(sr,{children:"Select a destination for this file"})]}),t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"flex gap-2",children:[t.jsxs(se,{variant:c==="copy"?"default":"outline",size:"sm",onClick:()=>d("copy"),children:[t.jsx(Ka,{className:"w-4 h-4 mr-1"})," Copy"]}),t.jsxs(se,{variant:c==="move"?"default":"outline",size:"sm",onClick:()=>d("move"),children:[t.jsx(gC,{className:"w-4 h-4 mr-1"})," Move"]})]}),t.jsx("div",{className:"space-y-2 max-h-48 overflow-y-auto",children:n==null?void 0:n.map(j=>t.jsxs("div",{className:Ee("flex items-center justify-between p-2 rounded border cursor-pointer",l===j.dir?"border-blue-500 bg-blue-50 dark:bg-blue-900/20":"hover:bg-gray-50 dark:hover:bg-slate-800"),onClick:()=>{u(j.dir),m("")},children:[t.jsxs("div",{className:"flex items-center gap-2",children:[j.isHome?t.jsx(Bg,{className:"w-4 h-4"}):t.jsx(Xr,{className:"w-4 h-4"}),t.jsx("span",{className:"text-sm",children:j.label})]}),j.hasClaudeFolder?t.jsx(rt,{variant:"secondary",className:"text-xs",children:"exists"}):t.jsx(rt,{variant:"outline",className:"text-xs",children:"create"})]},j.dir))}),t.jsxs("div",{children:[t.jsx("label",{className:"text-sm font-medium",children:"Or enter custom path:"}),t.jsx(He,{className:"mt-1 font-mono text-sm",placeholder:"/path/to/directory",value:f,onChange:j=>{m(j.target.value),u(null)}})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(_t,{checked:h,onCheckedChange:g}),t.jsx("span",{className:"text-sm",children:"Merge if target exists"})]})]}),t.jsxs(jt,{children:[t.jsx(se,{variant:"ghost",onClick:r,children:"Cancel"}),t.jsx(se,{onClick:w,children:c==="copy"?"Copy":"Move"})]})]})})}function R8({open:e,onClose:r,item:s,onRename:n}){const[o,c]=_.useState("");_.useEffect(()=>{s!=null&&s.name&&c(s.type==="skill"?s.name:s.name.replace(/\.md$/,""))},[s,e]);const d=()=>{if(!o.trim()){q.error("Please enter a name");return}n(s,o.trim())};return t.jsx(bt,{open:e,onOpenChange:r,children:t.jsxs(mt,{className:"sm:max-w-md",children:[t.jsx(pt,{children:t.jsxs(gt,{children:["Rename ",s==null?void 0:s.type]})}),t.jsxs("div",{children:[t.jsx("label",{className:"text-sm font-medium",children:"New name"}),t.jsx(He,{className:"mt-1",placeholder:"new-name",value:o,onChange:l=>c(l.target.value),onKeyDown:l=>l.key==="Enter"&&d()}),t.jsx("p",{className:"text-xs text-gray-500 dark:text-slate-400 mt-1",children:(s==null?void 0:s.type)==="skill"?"Enter the skill name":".md extension will be added automatically"})]}),t.jsxs(jt,{children:[t.jsx(se,{variant:"ghost",onClick:r,children:"Cancel"}),t.jsx(se,{onClick:d,children:"Rename"})]})]})})}function M8({open:e,onClose:r,dir:s,type:n,onCreate:o}){const[c,d]=_.useState("");_.useEffect(()=>{d("")},[e]);const l=()=>{if((n==="command"||n==="rule"||n==="workflow"||n==="memory"||n==="skill")&&!c.trim()){q.error("Please enter a name");return}let m;n==="skill"?m=c.trim().replace(/\.md$/,"").replace(/[^a-zA-Z0-9_-]/g,"-"):n==="command"||n==="rule"||n==="workflow"||n==="memory"?m=c.endsWith(".md")?c:`${c}.md`:m=c,o(s,m,n)},u=wc[n]||{},f=n==="command"||n==="rule"||n==="workflow"||n==="memory"||n==="skill";return t.jsx(bt,{open:e,onOpenChange:r,children:t.jsxs(mt,{className:"max-w-sm",children:[t.jsx(pt,{children:t.jsxs(gt,{children:["Create ",u.label||n]})}),f&&t.jsxs("div",{children:[t.jsx("label",{className:"text-sm font-medium",children:"Name"}),t.jsx(He,{className:"mt-1",placeholder:n==="skill"?"my-skill":n==="command"?"my-command.md":n==="workflow"?"my-workflow.md":n==="memory"?"context.md":"my-rule.md",value:c,onChange:m=>d(m.target.value),onKeyDown:m=>m.key==="Enter"&&l()})]}),t.jsxs(jt,{children:[t.jsx(se,{variant:"ghost",onClick:r,children:"Cancel"}),t.jsx(se,{onClick:l,children:"Create"})]})]})})}function I8({project:e,onRefresh:r}){var Be,Ve,Je,Ct;const[s,n]=_.useState([]),[o,c]=_.useState([]),[d,l]=_.useState(null),[u,f]=_.useState(null),[m,h]=_.useState(null),[g,w]=_.useState(()=>{try{return localStorage.getItem("claude-config-expanded-folder")||null}catch{return null}}),[j,S]=_.useState({}),[v,y]=_.useState(!0),[x,b]=_.useState({open:!1,item:null}),[k,N]=_.useState({open:!1,dir:null,type:null}),[P,A]=_.useState({open:!1,item:null}),[E,M]=_.useState(!1),[I,O]=_.useState({open:!1,projectDir:null}),[z,U]=_.useState({open:!1,dir:null,name:null}),[X,W]=_.useState({open:!1,dir:null}),[$,Y]=_.useState({x:0,y:0,item:null}),[K,L]=_.useState(["claude"]),T=_.useCallback(async()=>{var Se;try{y(!0);const[me,be,ee,oe]=await Promise.all([fe.getClaudeFolders(),fe.getIntermediatePaths(),fe.getRegistry(),fe.getConfig()]);if(n(me),c(be),l(ee),L(((Se=oe.config)==null?void 0:Se.enabledTools)||["claude"]),me.length>0){const we=localStorage.getItem("claude-config-expanded-folder");if(!we||!me.find(ke=>ke.dir===we)){const ke=me.filter(ct=>!ct.isSubproject),Oe=ke.length>1?ke[ke.length-1]:ke[0],$e=(Oe==null?void 0:Oe.dir)||me[0].dir;w($e);try{localStorage.setItem("claude-config-expanded-folder",$e)}catch{}}}}catch(me){q.error("Failed to load data: "+me.message)}finally{y(!1)}},[]);_.useEffect(()=>{T(),f(null),h(null)},[T,e==null?void 0:e.dir]);const B=Se=>{const me=g===Se?null:Se;w(me);try{me?localStorage.setItem("claude-config-expanded-folder",me):localStorage.removeItem("claude-config-expanded-folder")}catch{}},G=async Se=>{f(Se);try{const me=await fe.getClaudeFile(Se.path);h(me)}catch(me){q.error("Failed to load file: "+me.message)}},F=async Se=>{if(u)try{await fe.saveClaudeFile(u.path,Se),q.success("Saved");const me=await fe.getClaudeFile(u.path);h(me),T()}catch(me){q.error("Failed to save: "+me.message)}},re=Se=>{S(me=>({...me,[Se]:!me[Se]}))},ue=(Se,me)=>{Se.preventDefault(),Y({x:Se.clientX,y:Se.clientY,item:me})},he=async(Se,me)=>{me==="command"||me==="rule"||me==="workflow"||me==="memory"||me==="skill"?N({open:!0,dir:Se,type:me}):me==="claudemd"?W({open:!0,dir:Se}):J(Se,me==="mcps"?"mcps.json":me==="settings"?"settings.json":me==="env"?".env":"CLAUDE.md",me)},J=async(Se,me,be)=>{try{const ee=await fe.createClaudeFile(Se,me,be);if(q.success("Created"),N({open:!1,dir:null,type:null}),await T(),ee.path){const oe={path:ee.path,name:me,type:["command","rule","workflow","env","mcps","settings","claudemd","memory","skill"].includes(be)?be:"file"};f(oe),h({content:ee.content||"",parsed:null})}}catch(ee){q.error("Failed to create: "+ee.message)}},H=async(Se,me)=>{try{const be=await fe.renameClaudeFile(Se.path,me);be.success?(q.success("Renamed"),A({open:!1,item:null}),await T(),f({...Se,path:be.newPath,name:me.endsWith(".md")?me:`${me}.md`})):q.error(be.error||"Failed to rename")}catch(be){q.error("Failed to rename: "+be.message)}},ae=async Se=>{if(confirm(`Delete ${Se.name}?`))try{await fe.deleteClaudeFile(Se.path),q.success("Deleted"),(u==null?void 0:u.path)===Se.path&&(f(null),h(null)),T()}catch(me){q.error("Failed to delete: "+me.message)}},ie=async(Se,me,be,ee)=>{try{await fe.moveClaudeItem(Se,me,be,ee),q.success(be==="copy"?"Copied":"Moved"),b({open:!1,item:null}),T()}catch(oe){q.error("Failed: "+oe.message)}},Z=async Se=>{if(Se)try{const me=await fe.addManualSubproject(I.projectDir,Se);me.success?(q.success(`Added sub-project: ${Se.split("/").pop()}`),O({open:!1,projectDir:null}),T()):q.error(me.error||"Failed to add sub-project")}catch(me){q.error("Failed to add sub-project: "+me.message)}},ce=async Se=>{const me=s.find(be=>!be.isSubproject&&!be.isHome);if(me)try{const be=await fe.removeManualSubproject(me.dir,Se);be.success?(q.success("Removed sub-project"),T()):q.error(be.error||"Failed to remove sub-project")}catch(be){q.error("Failed to remove sub-project: "+be.message)}},Ce=async Se=>{const me=s.find(be=>!be.isSubproject&&!be.isHome);if(me)try{const be=await fe.hideSubproject(me.dir,Se);be.success?(q.success("Sub-project hidden"),T()):q.error(be.error||"Failed to hide sub-project")}catch(be){q.error("Failed to hide sub-project: "+be.message)}},Re=()=>{if(!u||!m)return t.jsx("div",{className:"h-full flex items-center justify-center text-gray-500 dark:text-slate-400",children:t.jsxs("div",{className:"text-center",children:[t.jsx(bp,{className:"w-12 h-12 mx-auto mb-2 opacity-50"}),t.jsx("p",{children:"Select a file to edit"})]})});const Se=u.path?u.path.replace(/\/.claude\/mcps\.json$/,""):null;switch(u.type){case"global-mcps":return t.jsx(A8,{content:m.content,parsed:m.parsed,onSave:F,registry:d});case"mcps":return t.jsx(KB,{content:m.content,parsed:m.parsed,onSave:F,registry:d,configDir:Se});case"settings":return t.jsx(P8,{content:m.content,parsed:m.parsed,onSave:F,filePath:u==null?void 0:u.path});case"command":case"rule":case"workflow":case"skill":case"claudemd":case"env":return t.jsx(Ew,{content:m.content,onSave:F,fileType:u.type});default:return t.jsx(Ew,{content:m.content,onSave:F,fileType:"claudemd"})}};if(v)return t.jsx("div",{className:"h-full flex items-center justify-center",children:t.jsx(Mr,{className:"w-6 h-6 animate-spin text-gray-400"})});const We=s.some(Se=>Se.isSubproject),pe=(Se,me)=>me===0,_e=(Se,me)=>{const be=s.findIndex(ee=>ee.isSubproject);return!Se.isSubproject&&(be>=0?me===be-1:me===s.length-1)};return t.jsxs("div",{className:"h-full flex",children:[t.jsxs("div",{className:"w-76 border-r flex flex-col bg-white dark:bg-slate-950",children:[t.jsxs("div",{className:"flex items-center justify-between p-3 border-b",children:[t.jsx("h2",{className:"font-semibold text-sm",children:"Project Config"}),t.jsxs("div",{className:"flex gap-1",children:[K.includes("claude")&&K.includes("antigravity")&&t.jsxs(se,{variant:"ghost",size:"sm",className:"h-7 px-2",onClick:()=>M(!0),title:"Sync rules between tools",children:[t.jsx(N5,{className:"w-4 h-4 mr-1"}),"Sync"]}),t.jsx(se,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0",onClick:T,children:t.jsx(Mr,{className:"w-4 h-4"})})]})]}),t.jsx(Xs,{className:"flex-1",children:s.map((Se,me)=>t.jsx(_B,{folder:Se,isExpanded:g===Se.dir,isHome:pe(Se,me),isProject:_e(Se,me),isSubproject:Se.isSubproject,depth:Se.depth||0,onToggle:()=>B(Se.dir),onCreateFile:he,onInstallPlugin:(be,ee)=>U({open:!0,dir:be,name:ee}),onSelectItem:G,selectedPath:u==null?void 0:u.path,onContextMenu:ue,expandedFolders:j,onToggleFolder:re,hasSubprojects:We,onAddSubproject:be=>O({open:!0,projectDir:be}),onRemoveSubproject:ce,onHideSubproject:Ce,enabledTools:K},Se.dir))})]}),t.jsxs("div",{className:"flex-1 flex flex-col bg-gray-50 dark:bg-slate-900",children:[u&&t.jsxs("div",{className:"flex items-center justify-between px-4 py-2 border-b bg-white dark:bg-slate-950",children:[t.jsx("div",{className:"flex items-center gap-2 text-sm",children:t.jsx("span",{className:"text-gray-500 dark:text-slate-400 font-mono truncate max-w-md",children:u.path})}),t.jsxs("div",{className:"flex gap-1",children:[t.jsx(se,{variant:"ghost",size:"sm",onClick:()=>b({open:!0,item:u}),children:t.jsx(Ka,{className:"w-4 h-4"})}),t.jsx(se,{variant:"ghost",size:"sm",onClick:()=>ae(u),children:t.jsx(ws,{className:"w-4 h-4"})})]})]}),t.jsx("div",{className:"flex-1",children:Re()})]}),$.item&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"fixed inset-0 z-40",onClick:()=>Y({x:0,y:0,item:null})}),t.jsxs("div",{className:"fixed z-50 bg-white dark:bg-slate-950 rounded-md shadow-lg border py-1 min-w-[160px]",style:{left:$.x,top:$.y},children:[(((Be=$.item)==null?void 0:Be.type)==="rule"||((Ve=$.item)==null?void 0:Ve.type)==="command"||((Je=$.item)==null?void 0:Je.type)==="workflow"||((Ct=$.item)==null?void 0:Ct.type)==="skill")&&t.jsxs("button",{className:"w-full px-3 py-2 text-sm text-left hover:bg-gray-100 dark:hover:bg-slate-800 flex items-center",onClick:()=>{A({open:!0,item:$.item}),Y({x:0,y:0,item:null})},children:[t.jsx(xC,{className:"w-4 h-4 mr-2"})," Rename"]}),t.jsxs("button",{className:"w-full px-3 py-2 text-sm text-left hover:bg-gray-100 dark:hover:bg-slate-800 flex items-center",onClick:()=>{b({open:!0,item:$.item}),Y({x:0,y:0,item:null})},children:[t.jsx(Ka,{className:"w-4 h-4 mr-2"})," Copy to..."]}),t.jsxs("button",{className:"w-full px-3 py-2 text-sm text-left hover:bg-gray-100 dark:hover:bg-slate-800 flex items-center",onClick:()=>{b({open:!0,item:$.item}),Y({x:0,y:0,item:null})},children:[t.jsx(gC,{className:"w-4 h-4 mr-2"})," Move to..."]}),t.jsx("div",{className:"border-t my-1"}),t.jsxs("button",{className:"w-full px-3 py-2 text-sm text-left hover:bg-gray-100 dark:hover:bg-slate-800 flex items-center text-red-600",onClick:()=>{ae($.item),Y({x:0,y:0,item:null})},children:[t.jsx(ws,{className:"w-4 h-4 mr-2"})," Delete"]})]})]}),t.jsx(T8,{open:x.open,onClose:()=>b({open:!1,item:null}),item:x.item,intermediatePaths:o,onMove:ie}),t.jsx(M8,{open:k.open,onClose:()=>N({open:!1,dir:null,type:null}),dir:k.dir,type:k.type,onCreate:J}),t.jsx(R8,{open:P.open,onClose:()=>A({open:!1,item:null}),item:P.item,onRename:H}),t.jsx(I6,{open:E,onOpenChange:M,projectDir:e==null?void 0:e.dir,onSynced:T}),t.jsx(pB,{open:z.open,onOpenChange:Se=>U({...z,open:Se}),projectDir:z.dir,projectName:z.name}),t.jsx(wx,{open:I.open,onOpenChange:Se=>O({...I,open:Se}),onSelect:Z,type:"directory",title:"Add Sub-project",initialPath:I.projectDir||"~"}),t.jsx(Yj,{open:X.open,onOpenChange:Se=>{W({...X,open:Se}),Se||T()},title:"Initialize CLAUDE.md",description:"Running claude -p /init to generate project-aware CLAUDE.md",cwd:X.dir,initialCommand:"claude -p /init; exit",autoCloseOnExit:!0,autoCloseDelay:2e3})]})}function D8({projects:e=[],activeProject:r=null,onSwitch:s,onAddClick:n,onManageClick:o,disabled:c=!1}){const d=(r==null?void 0:r.name)||"No project selected";return t.jsxs(Nn,{children:[t.jsx(En,{asChild:!0,children:t.jsxs(se,{variant:"outline",className:"gap-2 max-w-[220px] h-9",disabled:c,children:[t.jsx(Xi,{className:"w-4 h-4 text-indigo-500 flex-shrink-0"}),t.jsx("span",{className:"truncate font-medium",children:d}),t.jsx(xr,{className:"w-4 h-4 opacity-50 flex-shrink-0"})]})}),t.jsxs(un,{align:"start",className:"w-72",children:[t.jsx(bc,{className:"text-xs text-gray-500 font-normal",children:"Projects"}),t.jsx(xs,{}),e.length===0?t.jsxs("div",{className:"px-3 py-6 text-sm text-gray-500 text-center",children:[t.jsx(Xr,{className:"w-8 h-8 mx-auto mb-2 text-gray-300"}),t.jsx("p",{children:"No projects registered"}),t.jsx("p",{className:"text-xs mt-1",children:"Add a project to get started"})]}):t.jsx("div",{className:"max-h-64 overflow-y-auto",children:e.map(l=>t.jsxs(Pt,{onClick:()=>!l.isActive&&s(l.id),className:`flex items-start gap-2 py-2 cursor-pointer ${l.isActive?"bg-indigo-50":""}`,disabled:l.isActive,children:[t.jsx("div",{className:"mt-0.5 flex-shrink-0",children:l.isActive?t.jsx(Mt,{className:"w-4 h-4 text-indigo-600"}):l.exists?t.jsx(Xr,{className:"w-4 h-4 text-gray-400"}):t.jsx(Gi,{className:"w-4 h-4 text-amber-500"})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:`truncate font-medium ${l.isActive?"text-indigo-700":""}`,children:l.name}),t.jsx("div",{className:"truncate text-xs text-gray-400 font-mono",children:l.path.replace(/^\/Users\/[^/]+/,"~")}),!l.exists&&t.jsx("div",{className:"text-xs text-amber-600 mt-0.5",children:"Path not found"})]}),l.hasClaudeConfig&&t.jsx("div",{className:"flex-shrink-0",children:t.jsx("div",{className:"w-2 h-2 rounded-full bg-green-400",title:"Has .claude config"})})]},l.id))}),t.jsx(xs,{}),t.jsxs(Pt,{onClick:n,className:"gap-2 cursor-pointer",children:[t.jsx(It,{className:"w-4 h-4"}),"Add Project"]}),e.length>0&&t.jsxs(Pt,{onClick:o,className:"gap-2 cursor-pointer",children:[t.jsx(_p,{className:"w-4 h-4"}),"Manage Projects"]})]})]})}const zm="claude-config-welcome-seen";function L8({onStartTutorial:e}){const[r,s]=_.useState(!1),[n,o]=_.useState(!0);_.useEffect(()=>{if(!localStorage.getItem(zm)){const u=setTimeout(()=>s(!0),500);return()=>clearTimeout(u)}},[]);const c=()=>{n&&localStorage.setItem(zm,"true"),s(!1)},d=()=>{n&&localStorage.setItem(zm,"true"),s(!1),e==null||e()};return t.jsx(bt,{open:r,onOpenChange:s,children:t.jsxs(mt,{className:"sm:max-w-lg",children:[t.jsxs(pt,{children:[t.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[t.jsx("div",{className:"w-12 h-12 rounded-xl bg-gradient-to-br from-indigo-500 to-purple-600 flex items-center justify-center shadow-lg",children:t.jsx(hn,{className:"w-6 h-6 text-white"})}),t.jsx(gt,{className:"text-2xl",children:"Welcome to Coder Config"})]}),t.jsx(sr,{className:"text-base pt-2",children:"Your control center for Claude Code and AI coding tools."})]}),t.jsxs("div",{className:"py-4 space-y-4",children:[t.jsx("p",{className:"text-sm text-muted-foreground",children:"We built Coder Config because managing AI coding assistants shouldn't require editing JSON files or memorizing command-line flags. You deserve a visual interface that makes configuration easy."}),t.jsxs("div",{className:"grid grid-cols-3 gap-3 py-2",children:[t.jsxs("div",{className:"text-center p-3 rounded-lg bg-muted/50",children:[t.jsx(Yn,{className:"w-5 h-5 mx-auto mb-2 text-indigo-500"}),t.jsx("span",{className:"text-xs text-muted-foreground",children:"MCP Servers"})]}),t.jsxs("div",{className:"text-center p-3 rounded-lg bg-muted/50",children:[t.jsx(Qn,{className:"w-5 h-5 mx-auto mb-2 text-green-500"}),t.jsx("span",{className:"text-xs text-muted-foreground",children:"Permissions"})]}),t.jsxs("div",{className:"text-center p-3 rounded-lg bg-muted/50",children:[t.jsx(Vt,{className:"w-5 h-5 mx-auto mb-2 text-amber-500"}),t.jsx("span",{className:"text-xs text-muted-foreground",children:"Rules & Memory"})]})]}),t.jsx("p",{className:"text-sm text-muted-foreground",children:"Take our guided tutorial to learn the basics, or dive in and explore on your own."}),t.jsxs("div",{className:"flex items-center gap-2 pt-2",children:[t.jsx(Dc,{id:"dont-ask",checked:n,onCheckedChange:o}),t.jsx(Ze,{htmlFor:"dont-ask",className:"text-sm text-muted-foreground cursor-pointer",children:"Don't show this again"})]})]}),t.jsxs(jt,{className:"flex gap-2 sm:gap-2",children:[t.jsx(se,{variant:"ghost",onClick:c,children:"Skip for now"}),t.jsxs(se,{onClick:d,className:"gap-2",children:[t.jsx(Pu,{className:"w-4 h-4"}),"Start Tutorial",t.jsx(Dg,{className:"w-4 h-4"})]})]})]})})}const Hm="claude-config:claude-init-preference";function NN({open:e,onOpenChange:r,onAdded:s}){const[n,o]=_.useState(""),[c,d]=_.useState(""),[l,u]=_.useState(!1),[f,m]=_.useState(!1),[h,g]=_.useState(!0),[w,j]=_.useState([]),[S,v]=_.useState(null),y=_.useRef(null);_.useEffect(()=>{const N=localStorage.getItem(Hm);N==="never"?g(!1):N==="always"&&g(!0)},[]),_.useEffect(()=>{if(e){o(""),d(""),j([]),v(null);const N=localStorage.getItem(Hm);g(N!=="never")}},[e]),_.useEffect(()=>{y.current&&(y.current.scrollTop=y.current.scrollHeight)},[w]),_.useEffect(()=>{if(n&&!c){const N=n.split("/").pop();d(N||"")}},[n]);const x=N=>{o(N),u(!1)},b=async()=>{if(!n){q.error("Please select a project path");return}m(!0),j([]),v(null);try{if(h){v("running");const P=await new Promise(A=>{const E=new EventSource(`/api/projects/init-stream?path=${encodeURIComponent(n)}`);E.onmessage=M=>{const I=JSON.parse(M.data);I.type==="output"?j(O=>[...O,I.text]):I.type==="status"?j(O=>[...O,I.message+`
626
+ }`}),children:[t.jsx(It,{className:"w-4 h-4 mr-1"}),"Add MCP"]})]}),t.jsx("div",{className:"space-y-2",children:Object.keys(b).length===0?t.jsx("p",{className:"text-sm text-muted-foreground italic",children:"No MCP servers configured"}):Object.entries(b).map(([O,z])=>t.jsxs(Hc,{open:j[O],onOpenChange:()=>P(O),children:[t.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg border bg-background group",children:[t.jsxs(Wc,{className:"flex items-center gap-2 flex-1 text-left",children:[j[O]?t.jsx(xr,{className:"w-4 h-4 text-muted-foreground"}):t.jsx(vs,{className:"w-4 h-4 text-muted-foreground"}),t.jsx(ys,{className:"w-4 h-4 text-blue-500"}),t.jsx("span",{className:"font-medium text-sm",children:O}),t.jsx("span",{className:"text-xs text-muted-foreground font-mono",children:z.command})]}),t.jsx(se,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0 opacity-0 group-hover:opacity-100 text-destructive hover:text-destructive",onClick:()=>N(O),children:t.jsx(ws,{className:"w-4 h-4"})})]}),t.jsx(Uc,{children:t.jsx("div",{className:"mt-2 ml-6 p-3 rounded-lg bg-muted/50 border",children:t.jsx("pre",{className:"text-xs font-mono text-muted-foreground overflow-x-auto",children:JSON.stringify(z,null,2)})})})]},O))})]}),t.jsxs("div",{className:"border border-border rounded-lg p-4 bg-card",children:[t.jsxs("h3",{className:"text-sm font-medium text-foreground mb-4 flex items-center gap-2",children:[t.jsx(Vt,{className:"w-4 h-4 text-blue-500"}),"Model"]}),t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("label",{className:"text-sm font-medium text-foreground",children:"Default Model"}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Model used for Gemini CLI sessions"})]}),t.jsxs(vr,{value:x("model","name",""),onValueChange:O=>y("model","name",O),children:[t.jsx(hr,{className:"w-48",children:t.jsx(yr,{placeholder:"Select model"})}),t.jsx(fr,{children:E8.map(O=>t.jsx(At,{value:O.id,children:t.jsx("div",{className:"flex flex-col",children:t.jsx("span",{children:O.name})})},O.id))})]})]}),t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("label",{className:"text-sm font-medium text-foreground",children:"Preview Features"}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Enable access to experimental models and features"})]}),t.jsx(_t,{checked:x("general","previewFeatures",!1),onCheckedChange:O=>y("general","previewFeatures",O)})]})]})]}),t.jsxs("div",{className:"border border-border rounded-lg p-4 bg-card",children:[t.jsxs("h3",{className:"text-sm font-medium text-foreground mb-4 flex items-center gap-2",children:[t.jsx(YM,{className:"w-4 h-4 text-blue-500"}),"Appearance"]}),t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("label",{className:"text-sm font-medium text-foreground",children:"Theme"}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Color theme for the CLI interface"})]}),t.jsxs(vr,{value:x("ui","theme","Default"),onValueChange:O=>y("ui","theme",O),children:[t.jsx(hr,{className:"w-40",children:t.jsx(yr,{})}),t.jsx(fr,{children:N8.map(O=>t.jsx(At,{value:O.id,children:O.name},O.id))})]})]}),t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("label",{className:"text-sm font-medium text-foreground",children:"Output Format"}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Format for CLI output"})]}),t.jsxs(vr,{value:x("output","format","text"),onValueChange:O=>y("output","format",O),children:[t.jsx(hr,{className:"w-40",children:t.jsx(yr,{})}),t.jsxs(fr,{children:[t.jsx(At,{value:"text",children:"Text"}),t.jsx(At,{value:"json",children:"JSON"})]})]})]})]})]}),t.jsxs("div",{className:"border border-border rounded-lg p-4 bg-card",children:[t.jsxs("h3",{className:"text-sm font-medium text-foreground mb-4 flex items-center gap-2",children:[t.jsx(pC,{className:"w-4 h-4 text-blue-500"}),"Display Options"]}),t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("label",{className:"text-sm font-medium text-foreground",children:"Dynamic Window Title"}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Update title with status icons (Ready, Working, etc.)"})]}),t.jsx(_t,{checked:x("ui","dynamicWindowTitle",!0),onCheckedChange:O=>y("ui","dynamicWindowTitle",O)})]}),t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("label",{className:"text-sm font-medium text-foreground",children:"Show Line Numbers"}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Display line numbers in chat"})]}),t.jsx(_t,{checked:x("ui","showLineNumbers",!0),onCheckedChange:O=>y("ui","showLineNumbers",O)})]}),t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("label",{className:"text-sm font-medium text-foreground",children:"Show Citations"}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Display citations for generated text"})]}),t.jsx(_t,{checked:x("ui","showCitations",!1),onCheckedChange:O=>y("ui","showCitations",O)})]}),t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("label",{className:"text-sm font-medium text-foreground",children:"Hide Context Summary"}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Hide GEMINI.md and MCP servers above input"})]}),t.jsx(_t,{checked:x("ui","hideContextSummary",!1),onCheckedChange:O=>y("ui","hideContextSummary",O)})]}),t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("label",{className:"text-sm font-medium text-foreground",children:"Hide Footer"}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Remove footer entirely from the UI"})]}),t.jsx(_t,{checked:x("ui","hideFooter",!1),onCheckedChange:O=>y("ui","hideFooter",O)})]}),t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("label",{className:"text-sm font-medium text-foreground",children:"Screen Reader Mode"}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Render output in plain-text for accessibility"})]}),t.jsx(_t,{checked:((E=(A=o==null?void 0:o.ui)==null?void 0:A.accessibility)==null?void 0:E.screenReader)??!1,onCheckedChange:O=>c(z=>{var U;return{...z,ui:{...z.ui,accessibility:{...(U=z.ui)==null?void 0:U.accessibility,screenReader:O}}}})})]})]})]}),t.jsxs("div",{className:"border border-border rounded-lg p-4 bg-card",children:[t.jsxs("h3",{className:"text-sm font-medium text-foreground mb-4 flex items-center gap-2",children:[t.jsx(hn,{className:"w-4 h-4 text-blue-500"}),"General"]}),t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("label",{className:"text-sm font-medium text-foreground",children:"Vim Mode"}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Enable Vim keybindings in the prompt editor"})]}),t.jsx(_t,{checked:x("general","vimMode",!1),onCheckedChange:O=>y("general","vimMode",O)})]}),t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("label",{className:"text-sm font-medium text-foreground",children:"Auto Update"}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Allow automatic updates to Gemini CLI"})]}),t.jsx(_t,{checked:x("general","enableAutoUpdate",!0),onCheckedChange:O=>y("general","enableAutoUpdate",O)})]}),t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("label",{className:"text-sm font-medium text-foreground",children:"Checkpointing"}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Enable session recovery support"})]}),t.jsx(_t,{checked:((I=(M=o==null?void 0:o.general)==null?void 0:M.checkpointing)==null?void 0:I.enabled)??!1,onCheckedChange:O=>c(z=>{var U;return{...z,general:{...z.general,checkpointing:{...(U=z.general)==null?void 0:U.checkpointing,enabled:O}}}})})]}),t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("label",{className:"text-sm font-medium text-foreground",children:"Respect .gitignore"}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Exclude files matching .gitignore patterns"})]}),t.jsx(_t,{checked:x("general","respectGitignore",!0),onCheckedChange:O=>y("general","respectGitignore",O)})]})]})]}),t.jsxs("div",{className:"border border-border rounded-lg p-4 bg-card",children:[t.jsxs("h3",{className:"text-sm font-medium text-foreground mb-4 flex items-center gap-2",children:[t.jsx(Qn,{className:"w-4 h-4 text-blue-500"}),"Privacy"]}),t.jsx("div",{className:"space-y-4",children:t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("label",{className:"text-sm font-medium text-foreground",children:"Usage Statistics"}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Allow collection of anonymous usage data"})]}),t.jsx(_t,{checked:x("privacy","usageStatisticsEnabled",!0),onCheckedChange:O=>y("privacy","usageStatisticsEnabled",O)})]})})]})]}),t.jsx(bt,{open:g.open,onOpenChange:O=>w({...g,open:O}),children:t.jsxs(mt,{className:"bg-card",children:[t.jsxs(pt,{children:[t.jsx(gt,{children:"Add MCP Server"}),t.jsx(sr,{children:"Add a new MCP server to Gemini CLI"})]}),t.jsxs("div",{className:"space-y-4 py-4",children:[t.jsxs("div",{children:[t.jsx("label",{className:"text-sm font-medium",children:"Name"}),t.jsx(He,{value:g.name,onChange:O=>w({...g,name:O.target.value}),placeholder:"my-mcp-server",className:"mt-1"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"text-sm font-medium",children:"Configuration (JSON)"}),t.jsx(ft,{value:g.json,onChange:O=>w({...g,json:O.target.value}),className:"mt-1 font-mono text-sm",rows:6})]})]}),t.jsxs(jt,{children:[t.jsx(se,{variant:"ghost",onClick:()=>w({open:!1,name:"",json:""}),children:"Cancel"}),t.jsxs(se,{onClick:k,children:[t.jsx(It,{className:"w-4 h-4 mr-2"}),"Add MCP"]})]})]})})]})}function P8({content:e,parsed:r,onSave:s,filePath:n}){const o=async l=>{const u=JSON.stringify(l,null,2);s(u)},c=(n==null?void 0:n.includes(".gemini"))||(n==null?void 0:n.includes("/.gemini/")),d=(n==null?void 0:n.includes(".agent"))||(n==null?void 0:n.includes("/antigravity/"));return c&&!d?t.jsx("div",{className:"h-full overflow-auto p-4",children:t.jsx(jN,{settings:r||{},onSave:o,loading:!1,settingsPath:n||"~/.gemini/settings.json"})}):t.jsx("div",{className:"h-full overflow-auto p-4",children:t.jsx(kN,{settings:r||{},onSave:o,loading:!1,settingsPath:n||"~/.claude/settings.json"})})}function A8({content:e,parsed:r,onSave:s,registry:n}){const[o,c]=_.useState(r||{}),[d,l]=_.useState((r==null?void 0:r.mcpServers)||{}),[u,f]=_.useState("rich"),[m,h]=_.useState(JSON.stringify((r==null?void 0:r.mcpServers)||{},null,2)),[g,w]=_.useState(!1),[j,S]=_.useState({open:!1,json:""});_.useEffect(()=>{c(r||{}),l((r==null?void 0:r.mcpServers)||{}),h(JSON.stringify((r==null?void 0:r.mcpServers)||{},null,2))},[r]);const v=async A=>{w(!0);try{const E={...o,mcpServers:A};await s(JSON.stringify(E,null,2)),c(E)}catch(E){q.error("Failed to save: "+E.message)}finally{w(!1)}},y=A=>{var E;if(d[A]){const{[A]:M,...I}=d;l(I),h(JSON.stringify(I,null,2)),v(I),q.success(`Removed ${A} from global MCPs`)}else if((E=n==null?void 0:n.mcpServers)!=null&&E[A]){const M={...d,[A]:n.mcpServers[A]};l(M),h(JSON.stringify(M,null,2)),v(M),q.success(`Added ${A} to global MCPs`)}},x=A=>{const{[A]:E,...M}=d;l(M),h(JSON.stringify(M,null,2)),v(M),q.success(`Removed ${A}`)},b=A=>{const E={...d,...A};l(E),h(JSON.stringify(E,null,2)),v(E),S({open:!1,json:""});const M=Object.keys(A).length;q.success(`Added ${M} MCP${M>1?"s":""}`)},k=()=>{try{const A=JSON.parse(m);l(A),v(A),q.success("Saved")}catch(A){q.error("Invalid JSON: "+A.message)}},N=n!=null&&n.mcpServers?Object.keys(n.mcpServers):[],P=Object.entries(d).filter(([A,E])=>{var I;const M=(I=n==null?void 0:n.mcpServers)==null?void 0:I[A];return M?JSON.stringify(E)!==JSON.stringify(M):!0});return t.jsxs("div",{className:"h-full flex flex-col",children:[t.jsxs("div",{className:"flex items-center justify-between p-3 border-b bg-gray-50 dark:bg-slate-800",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(Ji,{className:"w-4 h-4 text-orange-500"}),t.jsx("span",{className:"text-sm font-medium",children:"Global MCPs"}),t.jsx(rt,{variant:"outline",className:"text-xs",children:"~/.claude.json"})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx($c,{value:u,onValueChange:f,children:t.jsxs(ll,{className:"h-8",children:[t.jsx(Ms,{value:"rich",className:"text-xs px-3",children:"Rich Editor"}),t.jsx(Ms,{value:"json",className:"text-xs px-3",children:"JSON"})]})}),g&&t.jsx(rt,{variant:"outline",className:"text-xs text-blue-600",children:"Saving..."}),t.jsxs(se,{size:"sm",variant:"outline",onClick:()=>S({open:!0,json:""}),children:[t.jsx(It,{className:"w-4 h-4 mr-1"}),"Add MCP"]}),u==="json"&&t.jsxs(se,{size:"sm",onClick:k,disabled:g,children:[t.jsx(bs,{className:"w-4 h-4 mr-1"}),"Apply JSON"]})]})]}),t.jsxs("div",{className:"mx-3 mt-3 p-3 rounded-lg bg-orange-50 dark:bg-orange-950/30 border border-orange-200 dark:border-orange-800 flex items-center gap-2",children:[t.jsx(Is,{className:"w-4 h-4 text-orange-600 shrink-0"}),t.jsxs("span",{className:"text-sm text-orange-800 dark:text-orange-200",children:["Global MCPs are available in ",t.jsx("strong",{children:"all projects"}),". They're stored in ",t.jsx("code",{className:"bg-orange-100 dark:bg-orange-900 px-1 rounded",children:"~/.claude.json"}),"."]})]}),t.jsx(Xs,{className:"flex-1",children:u==="rich"?t.jsx(ar,{children:t.jsxs("div",{className:"p-4 space-y-2",children:[P.map(([A,E])=>{var M;return t.jsxs("div",{className:"p-2 rounded border bg-white dark:bg-slate-950 group",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(ys,{className:"w-4 h-4 text-green-500"}),t.jsx("span",{className:"text-sm font-medium",children:A})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(rt,{variant:"outline",className:"text-xs",children:"custom"}),t.jsx(se,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0 opacity-0 group-hover:opacity-100 text-red-500 hover:text-red-700 hover:bg-red-50",onClick:()=>x(A),children:t.jsx(ws,{className:"w-3.5 h-3.5"})})]})]}),t.jsx("p",{className:"text-xs text-gray-500 dark:text-slate-400 mt-1 font-mono",children:E.url?`${E.type||"http"}: ${E.url}`:`${E.command} ${((M=E.args)==null?void 0:M.join(" "))||""}`})]},`custom-${A}`)}),N.map(A=>{var I;const E=!!d[A],M=n.mcpServers[A];return t.jsxs(Ft,{children:[t.jsx(Bt,{asChild:!0,children:t.jsxs("div",{className:`flex items-center justify-between p-2 rounded border ${E?"bg-green-50 dark:bg-green-950/20 border-green-200 dark:border-green-800":"bg-gray-50 dark:bg-slate-900 border-gray-200 dark:border-slate-700"}`,children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(ys,{className:`w-4 h-4 ${E?"text-green-500":"text-gray-400"}`}),t.jsx("span",{className:`text-sm ${E?"font-medium":"text-gray-500 dark:text-slate-400"}`,children:A}),M.description&&t.jsxs("span",{className:"text-xs text-gray-400 dark:text-slate-500 hidden sm:inline",children:["— ",M.description]})]}),t.jsx(_t,{checked:E,onCheckedChange:()=>y(A),className:E?"data-[state=checked]:bg-green-500":""})]})}),t.jsxs(Ot,{children:[t.jsx("p",{className:"font-mono text-xs",children:M.url?`${M.type||"http"}: ${M.url}`:`${M.command} ${((I=M.args)==null?void 0:I.join(" "))||""}`}),M.description&&t.jsx("p",{className:"text-xs text-gray-400 mt-1",children:M.description})]})]},`registry-${A}`)}),N.length===0&&P.length===0&&t.jsx("p",{className:"text-sm text-muted-foreground text-center py-8",children:"No MCPs configured. Use the registry toggle or add a custom MCP."})]})}):t.jsxs("div",{className:"p-4 space-y-3",children:[t.jsx("p",{className:"text-xs text-muted-foreground",children:"Edit the mcpServers section (other ~/.claude.json settings are preserved)"}),t.jsx(ft,{value:m,onChange:A=>h(A.target.value),className:"font-mono text-sm h-[400px]",placeholder:"{}"})]})}),t.jsx(vN,{open:j.open,onClose:A=>S({...j,open:A}),onAdd:b})]})}function T8({open:e,onClose:r,item:s,intermediatePaths:n,onMove:o}){const[c,d]=_.useState("copy"),[l,u]=_.useState(null),[f,m]=_.useState(""),[h,g]=_.useState(!1),w=()=>{const j=f.trim()||l;if(!j){q.error("Please select or enter a target path");return}o(s.path,j,c,h)};return t.jsx(bt,{open:e,onOpenChange:r,children:t.jsxs(mt,{className:"max-w-md",children:[t.jsxs(pt,{children:[t.jsxs(gt,{children:[c==="copy"?"Copy":"Move"," ",s==null?void 0:s.name]}),t.jsx(sr,{children:"Select a destination for this file"})]}),t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"flex gap-2",children:[t.jsxs(se,{variant:c==="copy"?"default":"outline",size:"sm",onClick:()=>d("copy"),children:[t.jsx(Ka,{className:"w-4 h-4 mr-1"})," Copy"]}),t.jsxs(se,{variant:c==="move"?"default":"outline",size:"sm",onClick:()=>d("move"),children:[t.jsx(gC,{className:"w-4 h-4 mr-1"})," Move"]})]}),t.jsx("div",{className:"space-y-2 max-h-48 overflow-y-auto",children:n==null?void 0:n.map(j=>t.jsxs("div",{className:Ee("flex items-center justify-between p-2 rounded border cursor-pointer",l===j.dir?"border-blue-500 bg-blue-50 dark:bg-blue-900/20":"hover:bg-gray-50 dark:hover:bg-slate-800"),onClick:()=>{u(j.dir),m("")},children:[t.jsxs("div",{className:"flex items-center gap-2",children:[j.isHome?t.jsx(Bg,{className:"w-4 h-4"}):t.jsx(Xr,{className:"w-4 h-4"}),t.jsx("span",{className:"text-sm",children:j.label})]}),j.hasClaudeFolder?t.jsx(rt,{variant:"secondary",className:"text-xs",children:"exists"}):t.jsx(rt,{variant:"outline",className:"text-xs",children:"create"})]},j.dir))}),t.jsxs("div",{children:[t.jsx("label",{className:"text-sm font-medium",children:"Or enter custom path:"}),t.jsx(He,{className:"mt-1 font-mono text-sm",placeholder:"/path/to/directory",value:f,onChange:j=>{m(j.target.value),u(null)}})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(_t,{checked:h,onCheckedChange:g}),t.jsx("span",{className:"text-sm",children:"Merge if target exists"})]})]}),t.jsxs(jt,{children:[t.jsx(se,{variant:"ghost",onClick:r,children:"Cancel"}),t.jsx(se,{onClick:w,children:c==="copy"?"Copy":"Move"})]})]})})}function R8({open:e,onClose:r,item:s,onRename:n}){const[o,c]=_.useState("");_.useEffect(()=>{s!=null&&s.name&&c(s.type==="skill"?s.name:s.name.replace(/\.md$/,""))},[s,e]);const d=()=>{if(!o.trim()){q.error("Please enter a name");return}n(s,o.trim())};return t.jsx(bt,{open:e,onOpenChange:r,children:t.jsxs(mt,{className:"sm:max-w-md",children:[t.jsx(pt,{children:t.jsxs(gt,{children:["Rename ",s==null?void 0:s.type]})}),t.jsxs("div",{children:[t.jsx("label",{className:"text-sm font-medium",children:"New name"}),t.jsx(He,{className:"mt-1",placeholder:"new-name",value:o,onChange:l=>c(l.target.value),onKeyDown:l=>l.key==="Enter"&&d()}),t.jsx("p",{className:"text-xs text-gray-500 dark:text-slate-400 mt-1",children:(s==null?void 0:s.type)==="skill"?"Enter the skill name":".md extension will be added automatically"})]}),t.jsxs(jt,{children:[t.jsx(se,{variant:"ghost",onClick:r,children:"Cancel"}),t.jsx(se,{onClick:d,children:"Rename"})]})]})})}function M8({open:e,onClose:r,dir:s,type:n,onCreate:o}){const[c,d]=_.useState("");_.useEffect(()=>{d("")},[e]);const l=()=>{if((n==="command"||n==="rule"||n==="workflow"||n==="memory"||n==="skill")&&!c.trim()){q.error("Please enter a name");return}let m;n==="skill"?m=c.trim().replace(/\.md$/,"").replace(/[^a-zA-Z0-9_-]/g,"-"):n==="command"||n==="rule"||n==="workflow"||n==="memory"?m=c.endsWith(".md")?c:`${c}.md`:m=c,o(s,m,n)},u=wc[n]||{},f=n==="command"||n==="rule"||n==="workflow"||n==="memory"||n==="skill";return t.jsx(bt,{open:e,onOpenChange:r,children:t.jsxs(mt,{className:"max-w-sm",children:[t.jsx(pt,{children:t.jsxs(gt,{children:["Create ",u.label||n]})}),f&&t.jsxs("div",{children:[t.jsx("label",{className:"text-sm font-medium",children:"Name"}),t.jsx(He,{className:"mt-1",placeholder:n==="skill"?"my-skill":n==="command"?"my-command.md":n==="workflow"?"my-workflow.md":n==="memory"?"context.md":"my-rule.md",value:c,onChange:m=>d(m.target.value),onKeyDown:m=>m.key==="Enter"&&l()})]}),t.jsxs(jt,{children:[t.jsx(se,{variant:"ghost",onClick:r,children:"Cancel"}),t.jsx(se,{onClick:l,children:"Create"})]})]})})}function I8({project:e,onRefresh:r}){var Be,Ve,Je,Ct;const[s,n]=_.useState([]),[o,c]=_.useState([]),[d,l]=_.useState(null),[u,f]=_.useState(null),[m,h]=_.useState(null),[g,w]=_.useState(()=>{try{return localStorage.getItem("claude-config-expanded-folder")||null}catch{return null}}),[j,S]=_.useState({}),[v,y]=_.useState(!0),[x,b]=_.useState({open:!1,item:null}),[k,N]=_.useState({open:!1,dir:null,type:null}),[P,A]=_.useState({open:!1,item:null}),[E,M]=_.useState(!1),[I,O]=_.useState({open:!1,projectDir:null}),[z,U]=_.useState({open:!1,dir:null,name:null}),[X,W]=_.useState({open:!1,dir:null}),[$,Y]=_.useState({x:0,y:0,item:null}),[K,L]=_.useState(["claude"]),T=_.useCallback(async()=>{var Se;try{y(!0);const[me,be,ee,oe]=await Promise.all([fe.getClaudeFolders(),fe.getIntermediatePaths(),fe.getRegistry(),fe.getConfig()]);if(n(me),c(be),l(ee),L(((Se=oe.config)==null?void 0:Se.enabledTools)||["claude"]),me.length>0){const we=localStorage.getItem("claude-config-expanded-folder");if(!we||!me.find(ke=>ke.dir===we)){const ke=me.filter(ct=>!ct.isSubproject),Oe=ke.length>1?ke[ke.length-1]:ke[0],$e=(Oe==null?void 0:Oe.dir)||me[0].dir;w($e);try{localStorage.setItem("claude-config-expanded-folder",$e)}catch{}}}}catch(me){q.error("Failed to load data: "+me.message)}finally{y(!1)}},[]);_.useEffect(()=>{T(),f(null),h(null)},[T,e==null?void 0:e.dir]);const B=Se=>{const me=g===Se?null:Se;w(me);try{me?localStorage.setItem("claude-config-expanded-folder",me):localStorage.removeItem("claude-config-expanded-folder")}catch{}},G=async Se=>{f(Se);try{const me=await fe.getClaudeFile(Se.path);h(me)}catch(me){q.error("Failed to load file: "+me.message)}},F=async Se=>{if(u)try{await fe.saveClaudeFile(u.path,Se),q.success("Saved");const me=await fe.getClaudeFile(u.path);h(me),T()}catch(me){q.error("Failed to save: "+me.message)}},re=Se=>{S(me=>({...me,[Se]:!me[Se]}))},ue=(Se,me)=>{Se.preventDefault(),Y({x:Se.clientX,y:Se.clientY,item:me})},he=async(Se,me)=>{me==="command"||me==="rule"||me==="workflow"||me==="memory"||me==="skill"?N({open:!0,dir:Se,type:me}):me==="claudemd"?W({open:!0,dir:Se}):J(Se,me==="mcps"?"mcps.json":me==="settings"?"settings.json":me==="env"?".env":"CLAUDE.md",me)},J=async(Se,me,be)=>{try{const ee=await fe.createClaudeFile(Se,me,be);if(q.success("Created"),N({open:!1,dir:null,type:null}),await T(),ee.path){const oe={path:ee.path,name:me,type:["command","rule","workflow","env","mcps","settings","claudemd","memory","skill"].includes(be)?be:"file"};f(oe),h({content:ee.content||"",parsed:null})}}catch(ee){q.error("Failed to create: "+ee.message)}},H=async(Se,me)=>{try{const be=await fe.renameClaudeFile(Se.path,me);be.success?(q.success("Renamed"),A({open:!1,item:null}),await T(),f({...Se,path:be.newPath,name:me.endsWith(".md")?me:`${me}.md`})):q.error(be.error||"Failed to rename")}catch(be){q.error("Failed to rename: "+be.message)}},ae=async Se=>{if(confirm(`Delete ${Se.name}?`))try{await fe.deleteClaudeFile(Se.path),q.success("Deleted"),(u==null?void 0:u.path)===Se.path&&(f(null),h(null)),T()}catch(me){q.error("Failed to delete: "+me.message)}},ie=async(Se,me,be,ee)=>{try{await fe.moveClaudeItem(Se,me,be,ee),q.success(be==="copy"?"Copied":"Moved"),b({open:!1,item:null}),T()}catch(oe){q.error("Failed: "+oe.message)}},Z=async Se=>{if(Se)try{const me=await fe.addManualSubproject(I.projectDir,Se);me.success?(q.success(`Added sub-project: ${Se.split("/").pop()}`),O({open:!1,projectDir:null}),T()):q.error(me.error||"Failed to add sub-project")}catch(me){q.error("Failed to add sub-project: "+me.message)}},ce=async Se=>{const me=s.find(be=>!be.isSubproject&&!be.isHome);if(me)try{const be=await fe.removeManualSubproject(me.dir,Se);be.success?(q.success("Removed sub-project"),T()):q.error(be.error||"Failed to remove sub-project")}catch(be){q.error("Failed to remove sub-project: "+be.message)}},Ce=async Se=>{const me=s.find(be=>!be.isSubproject&&!be.isHome);if(me)try{const be=await fe.hideSubproject(me.dir,Se);be.success?(q.success("Sub-project hidden"),T()):q.error(be.error||"Failed to hide sub-project")}catch(be){q.error("Failed to hide sub-project: "+be.message)}},Re=()=>{if(!u||!m)return t.jsx("div",{className:"h-full flex items-center justify-center text-gray-500 dark:text-slate-400",children:t.jsxs("div",{className:"text-center",children:[t.jsx(bp,{className:"w-12 h-12 mx-auto mb-2 opacity-50"}),t.jsx("p",{children:"Select a file to edit"})]})});const Se=u.path?u.path.replace(/\/.claude\/mcps\.json$/,""):null;switch(u.type){case"global-mcps":return t.jsx(A8,{content:m.content,parsed:m.parsed,onSave:F,registry:d});case"mcps":return t.jsx(KB,{content:m.content,parsed:m.parsed,onSave:F,registry:d,configDir:Se});case"settings":return t.jsx(P8,{content:m.content,parsed:m.parsed,onSave:F,filePath:u==null?void 0:u.path});case"command":case"rule":case"workflow":case"skill":case"claudemd":case"env":return t.jsx(Ew,{content:m.content,onSave:F,fileType:u.type});default:return t.jsx(Ew,{content:m.content,onSave:F,fileType:"claudemd"})}};if(v)return t.jsx("div",{className:"h-full flex items-center justify-center",children:t.jsx(Mr,{className:"w-6 h-6 animate-spin text-gray-400"})});const We=s.some(Se=>Se.isSubproject),pe=(Se,me)=>me===0,_e=(Se,me)=>{const be=s.findIndex(ee=>ee.isSubproject);return!Se.isSubproject&&(be>=0?me===be-1:me===s.length-1)};return t.jsxs("div",{className:"h-full flex",children:[t.jsxs("div",{className:"w-76 border-r flex flex-col bg-white dark:bg-slate-950",children:[t.jsxs("div",{className:"flex items-center justify-between p-3 border-b",children:[t.jsx("h2",{className:"font-semibold text-sm",children:"Project Config"}),t.jsxs("div",{className:"flex gap-1",children:[K.includes("claude")&&K.includes("antigravity")&&t.jsxs(se,{variant:"ghost",size:"sm",className:"h-7 px-2",onClick:()=>M(!0),title:"Sync rules between tools",children:[t.jsx(N5,{className:"w-4 h-4 mr-1"}),"Sync"]}),t.jsx(se,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0",onClick:T,children:t.jsx(Mr,{className:"w-4 h-4"})})]})]}),t.jsx(Xs,{className:"flex-1",children:s.map((Se,me)=>t.jsx(_B,{folder:Se,isExpanded:g===Se.dir,isHome:pe(Se,me),isProject:_e(Se,me),isSubproject:Se.isSubproject,depth:Se.depth||0,onToggle:()=>B(Se.dir),onCreateFile:he,onInstallPlugin:(be,ee)=>U({open:!0,dir:be,name:ee}),onSelectItem:G,selectedPath:u==null?void 0:u.path,onContextMenu:ue,expandedFolders:j,onToggleFolder:re,hasSubprojects:We,onAddSubproject:be=>O({open:!0,projectDir:be}),onRemoveSubproject:ce,onHideSubproject:Ce,enabledTools:K},Se.dir))})]}),t.jsxs("div",{className:"flex-1 flex flex-col bg-gray-50 dark:bg-slate-900",children:[u&&t.jsxs("div",{className:"flex items-center justify-between px-4 py-2 border-b bg-white dark:bg-slate-950",children:[t.jsx("div",{className:"flex items-center gap-2 text-sm",children:t.jsx("span",{className:"text-gray-500 dark:text-slate-400 font-mono truncate max-w-md",children:u.path})}),t.jsxs("div",{className:"flex gap-1",children:[t.jsx(se,{variant:"ghost",size:"sm",onClick:()=>b({open:!0,item:u}),children:t.jsx(Ka,{className:"w-4 h-4"})}),t.jsx(se,{variant:"ghost",size:"sm",onClick:()=>ae(u),children:t.jsx(ws,{className:"w-4 h-4"})})]})]}),t.jsx("div",{className:"flex-1",children:Re()})]}),$.item&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"fixed inset-0 z-40",onClick:()=>Y({x:0,y:0,item:null})}),t.jsxs("div",{className:"fixed z-50 bg-white dark:bg-slate-950 rounded-md shadow-lg border py-1 min-w-[160px]",style:{left:$.x,top:$.y},children:[(((Be=$.item)==null?void 0:Be.type)==="rule"||((Ve=$.item)==null?void 0:Ve.type)==="command"||((Je=$.item)==null?void 0:Je.type)==="workflow"||((Ct=$.item)==null?void 0:Ct.type)==="skill")&&t.jsxs("button",{className:"w-full px-3 py-2 text-sm text-left hover:bg-gray-100 dark:hover:bg-slate-800 flex items-center",onClick:()=>{A({open:!0,item:$.item}),Y({x:0,y:0,item:null})},children:[t.jsx(xC,{className:"w-4 h-4 mr-2"})," Rename"]}),t.jsxs("button",{className:"w-full px-3 py-2 text-sm text-left hover:bg-gray-100 dark:hover:bg-slate-800 flex items-center",onClick:()=>{b({open:!0,item:$.item}),Y({x:0,y:0,item:null})},children:[t.jsx(Ka,{className:"w-4 h-4 mr-2"})," Copy to..."]}),t.jsxs("button",{className:"w-full px-3 py-2 text-sm text-left hover:bg-gray-100 dark:hover:bg-slate-800 flex items-center",onClick:()=>{b({open:!0,item:$.item}),Y({x:0,y:0,item:null})},children:[t.jsx(gC,{className:"w-4 h-4 mr-2"})," Move to..."]}),t.jsx("div",{className:"border-t my-1"}),t.jsxs("button",{className:"w-full px-3 py-2 text-sm text-left hover:bg-gray-100 dark:hover:bg-slate-800 flex items-center text-red-600",onClick:()=>{ae($.item),Y({x:0,y:0,item:null})},children:[t.jsx(ws,{className:"w-4 h-4 mr-2"})," Delete"]})]})]}),t.jsx(T8,{open:x.open,onClose:()=>b({open:!1,item:null}),item:x.item,intermediatePaths:o,onMove:ie}),t.jsx(M8,{open:k.open,onClose:()=>N({open:!1,dir:null,type:null}),dir:k.dir,type:k.type,onCreate:J}),t.jsx(R8,{open:P.open,onClose:()=>A({open:!1,item:null}),item:P.item,onRename:H}),t.jsx(I6,{open:E,onOpenChange:M,projectDir:e==null?void 0:e.dir,onSynced:T}),t.jsx(pB,{open:z.open,onOpenChange:Se=>U({...z,open:Se}),projectDir:z.dir,projectName:z.name}),t.jsx(wx,{open:I.open,onOpenChange:Se=>O({...I,open:Se}),onSelect:Z,type:"directory",title:"Add Sub-project",initialPath:I.projectDir||"~"}),t.jsx(Yj,{open:X.open,onOpenChange:Se=>{W({...X,open:Se}),Se||T()},title:"Initialize CLAUDE.md",description:"Running claude -p /init to generate project-aware CLAUDE.md",cwd:X.dir,initialCommand:"claude -p /init; exit",autoCloseOnExit:!0,autoCloseDelay:2e3})]})}function D8({projects:e=[],activeProject:r=null,onSwitch:s,onAddClick:n,onManageClick:o,disabled:c=!1}){const d=(r==null?void 0:r.name)||"No project selected";return t.jsxs(Nn,{children:[t.jsx(En,{asChild:!0,children:t.jsxs(se,{variant:"outline",className:"gap-2 max-w-[220px] h-9",disabled:c,children:[t.jsx(Xi,{className:"w-4 h-4 text-indigo-500 flex-shrink-0"}),t.jsx("span",{className:"truncate font-medium",children:d}),t.jsx(xr,{className:"w-4 h-4 opacity-50 flex-shrink-0"})]})}),t.jsxs(un,{align:"start",className:"w-72",children:[t.jsx(bc,{className:"text-xs text-gray-500 font-normal",children:"Projects"}),t.jsx(xs,{}),e.length===0?t.jsxs("div",{className:"px-3 py-6 text-sm text-gray-500 text-center",children:[t.jsx(Xr,{className:"w-8 h-8 mx-auto mb-2 text-gray-300"}),t.jsx("p",{children:"No projects registered"}),t.jsx("p",{className:"text-xs mt-1",children:"Add a project to get started"})]}):t.jsx("div",{className:"max-h-64 overflow-y-auto",children:e.map(l=>t.jsxs(Pt,{onClick:()=>!l.isActive&&s(l.id),className:`flex items-start gap-2 py-2 cursor-pointer ${l.isActive?"bg-indigo-50":""}`,disabled:l.isActive,children:[t.jsx("div",{className:"mt-0.5 flex-shrink-0",children:l.isActive?t.jsx(Mt,{className:"w-4 h-4 text-indigo-600"}):l.exists?t.jsx(Xr,{className:"w-4 h-4 text-gray-400"}):t.jsx(Gi,{className:"w-4 h-4 text-amber-500"})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:`truncate font-medium ${l.isActive?"text-indigo-700":""}`,children:l.name}),t.jsx("div",{className:"truncate text-xs text-gray-400 font-mono",children:l.path.replace(/^\/Users\/[^/]+/,"~")}),!l.exists&&t.jsx("div",{className:"text-xs text-amber-600 mt-0.5",children:"Path not found"})]}),l.hasClaudeConfig&&t.jsx("div",{className:"flex-shrink-0",children:t.jsx("div",{className:"w-2 h-2 rounded-full bg-green-400",title:"Has .claude config"})})]},l.id))}),t.jsx(xs,{}),t.jsxs(Pt,{onClick:n,className:"gap-2 cursor-pointer",children:[t.jsx(It,{className:"w-4 h-4"}),"Add Project"]}),e.length>0&&t.jsxs(Pt,{onClick:o,className:"gap-2 cursor-pointer",children:[t.jsx(_p,{className:"w-4 h-4"}),"Manage Projects"]})]})]})}const zm="claude-config-welcome-seen";function L8({onStartTutorial:e}){const[r,s]=_.useState(!1),[n,o]=_.useState(!0);_.useEffect(()=>{if(!localStorage.getItem(zm)){const u=setTimeout(()=>s(!0),500);return()=>clearTimeout(u)}},[]);const c=()=>{n&&localStorage.setItem(zm,"true"),s(!1)},d=()=>{n&&localStorage.setItem(zm,"true"),s(!1),e==null||e()};return t.jsx(bt,{open:r,onOpenChange:s,children:t.jsxs(mt,{className:"sm:max-w-lg",children:[t.jsxs(pt,{children:[t.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[t.jsx("div",{className:"w-12 h-12 rounded-xl bg-gradient-to-br from-indigo-500 to-purple-600 flex items-center justify-center shadow-lg",children:t.jsx(hn,{className:"w-6 h-6 text-white"})}),t.jsx(gt,{className:"text-2xl",children:"Welcome to Coder Config"})]}),t.jsx(sr,{className:"text-base pt-2",children:"Your control center for Claude Code and AI coding tools."})]}),t.jsxs("div",{className:"py-4 space-y-4",children:[t.jsx("p",{className:"text-sm text-muted-foreground",children:"We built Coder Config because managing AI coding assistants shouldn't require editing JSON files or memorizing command-line flags. You deserve a visual interface that makes configuration easy."}),t.jsxs("div",{className:"grid grid-cols-3 gap-3 py-2",children:[t.jsxs("div",{className:"text-center p-3 rounded-lg bg-muted/50",children:[t.jsx(Yn,{className:"w-5 h-5 mx-auto mb-2 text-indigo-500"}),t.jsx("span",{className:"text-xs text-muted-foreground",children:"MCP Servers"})]}),t.jsxs("div",{className:"text-center p-3 rounded-lg bg-muted/50",children:[t.jsx(Qn,{className:"w-5 h-5 mx-auto mb-2 text-green-500"}),t.jsx("span",{className:"text-xs text-muted-foreground",children:"Permissions"})]}),t.jsxs("div",{className:"text-center p-3 rounded-lg bg-muted/50",children:[t.jsx(Vt,{className:"w-5 h-5 mx-auto mb-2 text-amber-500"}),t.jsx("span",{className:"text-xs text-muted-foreground",children:"Rules & Memory"})]})]}),t.jsx("p",{className:"text-sm text-muted-foreground",children:"Take our guided tutorial to learn the basics, or dive in and explore on your own."}),t.jsxs("div",{className:"flex items-center gap-2 pt-2",children:[t.jsx(Dc,{id:"dont-ask",checked:n,onCheckedChange:o}),t.jsx(Ze,{htmlFor:"dont-ask",className:"text-sm text-muted-foreground cursor-pointer",children:"Don't show this again"})]})]}),t.jsxs(jt,{className:"flex gap-2 sm:gap-2",children:[t.jsx(se,{variant:"ghost",onClick:c,children:"Skip for now"}),t.jsxs(se,{onClick:d,className:"gap-2",children:[t.jsx(Pu,{className:"w-4 h-4"}),"Start Tutorial",t.jsx(Dg,{className:"w-4 h-4"})]})]})]})})}const Hm="claude-config:claude-init-preference";function NN({open:e,onOpenChange:r,onAdded:s}){const[n,o]=_.useState(""),[c,d]=_.useState(""),[l,u]=_.useState(!1),[f,m]=_.useState(!1),[h,g]=_.useState(!0),[w,j]=_.useState([]),[S,v]=_.useState(null),y=_.useRef(null);_.useEffect(()=>{const N=localStorage.getItem(Hm);N==="never"?g(!1):N==="always"&&g(!0)},[]),_.useEffect(()=>{if(e){o(""),d(""),j([]),v(null);const N=localStorage.getItem(Hm);g(N!=="never")}},[e]),_.useEffect(()=>{y.current&&(y.current.scrollTop=y.current.scrollHeight)},[w]),_.useEffect(()=>{if(n&&!c){const N=n.split("/").pop();d(N||"")}},[n]);const x=N=>{o(N),u(!1)},b=async()=>{if(!n){q.error("Please select a project path");return}m(!0),j([]),v(null);try{if(h){v("running");const P=await new Promise(A=>{const E=new EventSource(`/api/projects/init-stream?path=${encodeURIComponent(n)}`);E.onmessage=M=>{const I=JSON.parse(M.data);I.type==="output"?j(O=>[...O,I.text]):I.type==="status"?j(O=>[...O,I.message+`
627
627
  `]):I.type==="skip"?j(O=>[...O,I.message+`
628
628
  `]):I.type==="done"?(E.close(),v(I.success?"success":"error"),A(I.success)):I.type==="error"&&(j(O=>[...O,`Error: ${I.message}
629
629
  `]),E.close(),v("error"),A(!1))},E.onerror=()=>{E.close(),j(M=>[...M,`Connection error - is Claude Code installed?
@@ -19,7 +19,7 @@
19
19
 
20
20
  <!-- PWA Manifest -->
21
21
  <link rel="manifest" href="/manifest.json">
22
- <script type="module" crossorigin src="/assets/index-aY482VZO.js"></script>
22
+ <script type="module" crossorigin src="/assets/index-CZhSoM0H.js"></script>
23
23
  <link rel="stylesheet" crossorigin href="/assets/index-BiF3i3y5.css">
24
24
  </head>
25
25
  <body>