@regression-io/claude-config 0.38.7 → 0.38.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -17,13 +17,36 @@ Claude Code works great out of the box. This tool helps when you need more contr
17
17
 
18
18
  ## Installation
19
19
 
20
+ ### Option A: Desktop App (Recommended)
21
+
22
+ Download the native app from [GitHub Releases](https://github.com/regression-io/claude-config/releases):
23
+
24
+ | Platform | Download |
25
+ |----------|----------|
26
+ | **macOS (Apple Silicon)** | `Claude.Config_*_aarch64.dmg` |
27
+ | **macOS (Intel)** | `Claude.Config_*_x64.dmg` |
28
+ | **Windows** | `Claude.Config_*_x64-setup.exe` |
29
+ | **Linux** | `Claude.Config_*_amd64.deb` or `.AppImage` |
30
+
31
+ No Node.js required. Just download, install, and run.
32
+
33
+ ### Option B: npm Package
34
+
20
35
  ```bash
21
36
  npm install -g @regression-io/claude-config
22
37
  ```
23
38
 
39
+ Requires Node.js 18+.
40
+
24
41
  ## Quick Start
25
42
 
26
- ### New Users
43
+ ### Desktop App Users
44
+
45
+ 1. Download and install from [GitHub Releases](https://github.com/regression-io/claude-config/releases)
46
+ 2. Launch the app
47
+ 3. Add your projects and configure
48
+
49
+ ### npm Package Users
27
50
 
28
51
  ```bash
29
52
  # 1. Install
@@ -36,25 +59,18 @@ claude-config ui install
36
59
  open http://localhost:3333
37
60
  ```
38
61
 
39
- The server now starts automatically on login. Install as a PWA from your browser for app-like access.
62
+ The server starts automatically on login. Install as a PWA from your browser for app-like access.
63
+
64
+ ### Updating
40
65
 
41
- ### Existing Users (Updating)
66
+ **Desktop App:** Download latest from [GitHub Releases](https://github.com/regression-io/claude-config/releases).
42
67
 
68
+ **npm Package:**
43
69
  ```bash
44
- # Option A: Update via CLI
45
70
  claude-config update
46
-
47
- # Option B: Update via UI
48
- # Click the green "Update" button in the header when available
49
-
50
- # After updating, restart to pick up changes:
51
- claude-config ui install # If using auto-start
52
- # OR
53
- claude-config ui stop && claude-config ui # Manual restart
71
+ # Then restart: claude-config ui stop && claude-config ui
54
72
  ```
55
73
 
56
- The UI shows a restart indicator when the running version differs from the installed version.
57
-
58
74
  ### CLI Alternative
59
75
 
60
76
  ```bash
@@ -528,11 +544,22 @@ User settings stored in `~/.claude-config/config.json`:
528
544
  | `ui.port` | Default port for web UI |
529
545
  | `ui.openBrowser` | Auto-open browser on `claude-config ui` |
530
546
 
531
- ## Native Desktop App (Tauri)
547
+ ## Native Desktop App
548
+
549
+ The desktop app provides a true native experience - no terminal, no Node.js, no CLI commands.
532
550
 
533
- For a true desktop experience without running CLI commands, you can build a native macOS app.
551
+ ### Download
534
552
 
535
- ### Building the Desktop App
553
+ Get the latest release from [GitHub Releases](https://github.com/regression-io/claude-config/releases):
554
+
555
+ - **macOS Apple Silicon**: `Claude.Config_*_aarch64.dmg`
556
+ - **macOS Intel**: `Claude.Config_*_x64.dmg`
557
+ - **Windows**: `Claude.Config_*_x64-setup.exe`
558
+ - **Linux**: `Claude.Config_*_amd64.deb` or `.AppImage`
559
+
560
+ ### Building from Source
561
+
562
+ If you prefer to build locally:
536
563
 
537
564
  ```bash
538
565
  # Prerequisites: Rust toolchain
@@ -551,8 +578,6 @@ The `.app` bundle will be created in `src-tauri/target/release/bundle/macos/`.
551
578
  npm run tauri:dev
552
579
  ```
553
580
 
554
- This opens the native window connected to the local Node.js server.
555
-
556
581
  ## Requirements
557
582
 
558
583
  - Node.js 18+
package/lib/constants.js CHANGED
@@ -2,7 +2,7 @@
2
2
  * Constants and tool path configurations
3
3
  */
4
4
 
5
- const VERSION = '0.38.7';
5
+ const VERSION = '0.38.9';
6
6
 
7
7
  // Tool-specific path configurations
8
8
  const TOOL_PATHS = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@regression-io/claude-config",
3
- "version": "0.38.7",
3
+ "version": "0.38.9",
4
4
  "description": "Configuration management UI for Claude Code and Antigravity - manage MCPs, rules, commands, memory, and project folders",
5
5
  "author": "regression.io",
6
6
  "main": "config-loader.js",
@@ -0,0 +1,300 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * Tauri Build Preparation Script
5
+ *
6
+ * Prepares the Node.js server bundle for Tauri packaging:
7
+ * 1. Downloads Node.js binary for target platform
8
+ * 2. Copies server files to bundle location
9
+ * 3. Installs production dependencies
10
+ */
11
+
12
+ const fs = require('fs');
13
+ const path = require('path');
14
+ const https = require('https');
15
+ const { spawnSync } = require('child_process');
16
+ const os = require('os');
17
+
18
+ const ROOT_DIR = path.join(__dirname, '..');
19
+ const SRC_TAURI = path.join(ROOT_DIR, 'src-tauri');
20
+ const BINARIES_DIR = path.join(SRC_TAURI, 'binaries');
21
+ const SERVER_DIR = path.join(SRC_TAURI, 'server');
22
+
23
+ // Node.js version to bundle (LTS)
24
+ const NODE_VERSION = '20.18.1';
25
+
26
+ // Platform detection
27
+ function getPlatform() {
28
+ const platform = os.platform();
29
+ const arch = os.arch();
30
+
31
+ if (platform === 'darwin') {
32
+ return arch === 'arm64' ? 'darwin-arm64' : 'darwin-x64';
33
+ } else if (platform === 'win32') {
34
+ return arch === 'arm64' ? 'win-arm64' : 'win-x64';
35
+ } else if (platform === 'linux') {
36
+ return arch === 'arm64' ? 'linux-arm64' : 'linux-x64';
37
+ }
38
+
39
+ throw new Error(`Unsupported platform: ${platform}-${arch}`);
40
+ }
41
+
42
+ // Get Tauri target triple
43
+ function getTauriTarget() {
44
+ const platform = os.platform();
45
+ const arch = os.arch();
46
+
47
+ if (platform === 'darwin') {
48
+ return arch === 'arm64' ? 'aarch64-apple-darwin' : 'x86_64-apple-darwin';
49
+ } else if (platform === 'win32') {
50
+ return arch === 'arm64' ? 'aarch64-pc-windows-msvc' : 'x86_64-pc-windows-msvc';
51
+ } else if (platform === 'linux') {
52
+ return arch === 'arm64' ? 'aarch64-unknown-linux-gnu' : 'x86_64-unknown-linux-gnu';
53
+ }
54
+
55
+ throw new Error(`Unsupported platform: ${platform}-${arch}`);
56
+ }
57
+
58
+ // Download a file
59
+ async function downloadFile(url, dest) {
60
+ return new Promise((resolve, reject) => {
61
+ console.log(`Downloading: ${url}`);
62
+
63
+ const file = fs.createWriteStream(dest);
64
+
65
+ const request = (reqUrl) => {
66
+ https.get(reqUrl, (response) => {
67
+ if (response.statusCode === 302 || response.statusCode === 301) {
68
+ // Follow redirect
69
+ request(response.headers.location);
70
+ return;
71
+ }
72
+
73
+ if (response.statusCode !== 200) {
74
+ reject(new Error(`HTTP ${response.statusCode}: ${reqUrl}`));
75
+ return;
76
+ }
77
+
78
+ const total = parseInt(response.headers['content-length'], 10);
79
+ let downloaded = 0;
80
+
81
+ response.on('data', (chunk) => {
82
+ downloaded += chunk.length;
83
+ if (total) {
84
+ const pct = Math.round((downloaded / total) * 100);
85
+ process.stdout.write(`\r Progress: ${pct}%`);
86
+ }
87
+ });
88
+
89
+ response.pipe(file);
90
+
91
+ file.on('finish', () => {
92
+ file.close();
93
+ console.log('\n Download complete');
94
+ resolve();
95
+ });
96
+ }).on('error', (err) => {
97
+ fs.unlink(dest, () => {});
98
+ reject(err);
99
+ });
100
+ };
101
+
102
+ request(url);
103
+ });
104
+ }
105
+
106
+ // Extract tar.gz using spawn (safe from injection)
107
+ function extractArchive(archivePath, destDir) {
108
+ console.log(`Extracting to: ${destDir}`);
109
+
110
+ // Use spawnSync with array arguments (safe from shell injection)
111
+ const result = spawnSync('tar', ['-xzf', archivePath, '-C', destDir], {
112
+ stdio: 'inherit'
113
+ });
114
+
115
+ if (result.status !== 0) {
116
+ throw new Error(`Failed to extract archive: ${result.stderr || 'unknown error'}`);
117
+ }
118
+ }
119
+
120
+ // Download Node.js binary
121
+ async function downloadNode() {
122
+ const platform = getPlatform();
123
+ const tauriTarget = getTauriTarget();
124
+ const ext = platform.startsWith('win') ? 'zip' : 'tar.gz';
125
+ const nodeDir = `node-v${NODE_VERSION}-${platform}`;
126
+ const archiveName = `${nodeDir}.${ext}`;
127
+ const url = `https://nodejs.org/dist/v${NODE_VERSION}/${archiveName}`;
128
+
129
+ console.log(`\n=== Downloading Node.js ${NODE_VERSION} for ${platform} ===`);
130
+
131
+ // Create directories
132
+ if (!fs.existsSync(BINARIES_DIR)) {
133
+ fs.mkdirSync(BINARIES_DIR, { recursive: true });
134
+ }
135
+
136
+ const archivePath = path.join(BINARIES_DIR, archiveName);
137
+ const extractDir = BINARIES_DIR;
138
+
139
+ // Download if not already present
140
+ if (!fs.existsSync(archivePath)) {
141
+ await downloadFile(url, archivePath);
142
+ } else {
143
+ console.log(' Archive already exists, skipping download');
144
+ }
145
+
146
+ // Extract
147
+ extractArchive(archivePath, extractDir);
148
+
149
+ // Move node binary to expected location with Tauri naming convention
150
+ const sourceDir = path.join(extractDir, nodeDir);
151
+ const isWindows = platform.startsWith('win');
152
+ const sourceNode = path.join(sourceDir, isWindows ? 'node.exe' : 'bin/node');
153
+
154
+ // Tauri sidecar naming: <name>-<target-triple>[.exe]
155
+ const destNodeName = `node-server-${tauriTarget}${isWindows ? '.exe' : ''}`;
156
+ const destNode = path.join(BINARIES_DIR, destNodeName);
157
+
158
+ if (fs.existsSync(sourceNode)) {
159
+ fs.copyFileSync(sourceNode, destNode);
160
+ fs.chmodSync(destNode, 0o755);
161
+ console.log(` Node binary copied to: ${destNodeName}`);
162
+ }
163
+
164
+ // Clean up extracted directory (keep archive for caching)
165
+ fs.rmSync(sourceDir, { recursive: true, force: true });
166
+
167
+ return destNode;
168
+ }
169
+
170
+ // Copy server files
171
+ function copyServerFiles() {
172
+ console.log('\n=== Copying server files ===');
173
+
174
+ // Create server directory
175
+ if (fs.existsSync(SERVER_DIR)) {
176
+ fs.rmSync(SERVER_DIR, { recursive: true });
177
+ }
178
+ fs.mkdirSync(SERVER_DIR, { recursive: true });
179
+
180
+ // Files to copy (individual files)
181
+ const filesToCopy = [
182
+ 'cli.js',
183
+ 'config-loader.js',
184
+ 'package.json',
185
+ 'ui/server.cjs',
186
+ 'ui/terminal-server.cjs',
187
+ ];
188
+
189
+ // Directories to copy (recursive)
190
+ const dirsToCopy = [
191
+ 'lib',
192
+ 'ui/routes',
193
+ 'ui/dist',
194
+ 'shared',
195
+ ];
196
+
197
+ // Copy individual files
198
+ for (const file of filesToCopy) {
199
+ const src = path.join(ROOT_DIR, file);
200
+ const dest = path.join(SERVER_DIR, file);
201
+ if (fs.existsSync(src)) {
202
+ // Ensure destination directory exists
203
+ fs.mkdirSync(path.dirname(dest), { recursive: true });
204
+ fs.copyFileSync(src, dest);
205
+ console.log(` Copied: ${file}`);
206
+ }
207
+ }
208
+
209
+ // Copy directories
210
+ for (const dir of dirsToCopy) {
211
+ const src = path.join(ROOT_DIR, dir);
212
+ const dest = path.join(SERVER_DIR, dir);
213
+ if (fs.existsSync(src)) {
214
+ copyDirSync(src, dest);
215
+ console.log(` Copied: ${dir}/`);
216
+ }
217
+ }
218
+ }
219
+
220
+ // Recursive directory copy
221
+ function copyDirSync(src, dest) {
222
+ fs.mkdirSync(dest, { recursive: true });
223
+
224
+ const entries = fs.readdirSync(src, { withFileTypes: true });
225
+
226
+ for (const entry of entries) {
227
+ const srcPath = path.join(src, entry.name);
228
+ const destPath = path.join(dest, entry.name);
229
+
230
+ if (entry.isDirectory()) {
231
+ copyDirSync(srcPath, destPath);
232
+ } else {
233
+ fs.copyFileSync(srcPath, destPath);
234
+ }
235
+ }
236
+ }
237
+
238
+ // Install production dependencies
239
+ function installDependencies() {
240
+ console.log('\n=== Installing production dependencies ===');
241
+
242
+ const result = spawnSync('npm', ['install', '--production', '--ignore-scripts'], {
243
+ cwd: SERVER_DIR,
244
+ stdio: 'inherit',
245
+ shell: true
246
+ });
247
+
248
+ if (result.status !== 0) {
249
+ console.warn(' Warning: npm install may have had issues');
250
+ }
251
+
252
+ // Note: node-pty needs to be rebuilt for the target platform
253
+ // This is handled by npm rebuild during the Tauri build
254
+ console.log(' Dependencies installed');
255
+ }
256
+
257
+ // Create a wrapper script for the sidecar
258
+ function createWrapperScript() {
259
+ console.log('\n=== Creating wrapper script ===');
260
+
261
+ const wrapperPath = path.join(SERVER_DIR, 'start-server.js');
262
+ const wrapperContent = `#!/usr/bin/env node
263
+ // Wrapper script to start the server
264
+ // Used by Tauri sidecar
265
+ process.chdir(__dirname);
266
+ require('./cli.js');
267
+ `;
268
+
269
+ fs.writeFileSync(wrapperPath, wrapperContent);
270
+ fs.chmodSync(wrapperPath, 0o755);
271
+ console.log(' Wrapper script created');
272
+ }
273
+
274
+ // Main
275
+ async function main() {
276
+ console.log('=== Claude Config Tauri Build Preparation ===\n');
277
+
278
+ try {
279
+ // Check if we're building for distribution or just development
280
+ const args = process.argv.slice(2);
281
+ const skipNodeDownload = args.includes('--skip-node');
282
+
283
+ if (!skipNodeDownload) {
284
+ await downloadNode();
285
+ }
286
+
287
+ copyServerFiles();
288
+ installDependencies();
289
+ createWrapperScript();
290
+
291
+ console.log('\n=== Build preparation complete! ===');
292
+ console.log('Run `npm run tauri:build` to create the app bundle.');
293
+
294
+ } catch (error) {
295
+ console.error('Build preparation failed:', error);
296
+ process.exit(1);
297
+ }
298
+ }
299
+
300
+ main();
@@ -563,7 +563,7 @@ WARNING: This link could potentially be dangerous`)){const y=window.open();if(y)
563
563
  "API_KEY": "\${API_KEY}"
564
564
  }
565
565
  }
566
- }`,className:"font-mono text-sm bg-gray-50 dark:bg-slate-800",rows:12}),n.jsxs("p",{className:"text-xs text-gray-500 dark:text-slate-400 mt-2",children:["Accepts formats: ",n.jsx("code",{className:"bg-gray-100 dark:bg-slate-700 px-1 rounded",children:'{ "name": { "command": "...", "args": [...] } }'})," or ",n.jsx("code",{className:"bg-gray-100 dark:bg-slate-700 px-1 rounded",children:'{ "mcpServers": { ... } }'})]})]}),n.jsxs(Wt,{children:[n.jsx(le,{variant:"ghost",onClick:()=>w({open:!1,json:""}),children:"Cancel"}),n.jsxs(le,{onClick:y,className:"bg-blue-600 hover:bg-blue-700 text-white",children:[n.jsx(_t,{className:"w-4 h-4 mr-2"}),"Add MCP"]})]})]})})]})}function Gb({content:e,onSave:t,fileType:r}){const[s,o]=C.useState(e||""),[u,d]=C.useState(!1),l=C.useRef(null);C.useEffect(()=>{o(e||"")},[e]);const c=C.useCallback(h=>{l.current&&clearTimeout(l.current),l.current=setTimeout(async()=>{d(!0);try{await t(h)}finally{d(!1)}},800)},[t]),f=h=>{const g=h.target.value;o(g),c(g)},m=fl[r]||fl.claudemd;return n.jsxs("div",{className:"h-full flex flex-col",children:[n.jsxs("div",{className:"flex items-center justify-between p-3 border-b bg-gray-50 dark:bg-slate-800",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(m.icon,{className:Ne("w-4 h-4",m.color)}),n.jsx("span",{className:"text-sm font-medium",children:m.label})]}),n.jsx("div",{className:"flex gap-2",children:u&&n.jsxs(nt,{variant:"outline",className:"text-xs text-blue-600",children:[n.jsx(dr,{className:"w-3 h-3 mr-1 animate-spin"}),"Saving..."]})})]}),n.jsx(vt,{className:"flex-1 w-full font-mono text-sm border-0 rounded-none resize-none p-4",value:s,onChange:f,placeholder:`Enter ${m.label.toLowerCase()} content...`})]})}var UB=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],GB=UB.reduce((e,t)=>{const r=Zu(`Primitive.${t}`),s=C.forwardRef((o,u)=>{const{asChild:d,...l}=o,c=d?r:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),n.jsx(c,{...l,ref:u})});return s.displayName=`Primitive.${t}`,{...e,[t]:s}},{}),KB="Label",pj=C.forwardRef((e,t)=>n.jsx(GB.label,{...e,ref:t,onMouseDown:r=>{var o;r.target.closest("button, input, select, textarea")||((o=e.onMouseDown)==null||o.call(e,r),!r.defaultPrevented&&r.detail>1&&r.preventDefault())}}));pj.displayName=KB;var gj=pj;const qB=ed("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),Ht=C.forwardRef(({className:e,...t},r)=>n.jsx(gj,{ref:r,className:Ne(qB(),e),...t}));Ht.displayName=gj.displayName;var YB=Symbol("radix.slottable");function XB(e){const t=({children:r})=>n.jsx(n.Fragment,{children:r});return t.displayName=`${e}.Slottable`,t.__radixId=YB,t}var[Nd]=qr("Tooltip",[Jo]),Ed=Jo(),xj="TooltipProvider",JB=700,qm="tooltip.open",[QB,Rg]=Nd(xj),vj=e=>{const{__scopeTooltip:t,delayDuration:r=JB,skipDelayDuration:s=300,disableHoverableContent:o=!1,children:u}=e,d=C.useRef(!0),l=C.useRef(!1),c=C.useRef(0);return C.useEffect(()=>{const f=c.current;return()=>window.clearTimeout(f)},[]),n.jsx(QB,{scope:t,isOpenDelayedRef:d,delayDuration:r,onOpen:C.useCallback(()=>{window.clearTimeout(c.current),d.current=!1},[]),onClose:C.useCallback(()=>{window.clearTimeout(c.current),c.current=window.setTimeout(()=>d.current=!0,s)},[s]),isPointerInTransitRef:l,onPointerInTransitChange:C.useCallback(f=>{l.current=f},[]),disableHoverableContent:o,children:u})};vj.displayName=xj;var ml="Tooltip",[ZB,Dl]=Nd(ml),yj=e=>{const{__scopeTooltip:t,children:r,open:s,defaultOpen:o,onOpenChange:u,disableHoverableContent:d,delayDuration:l}=e,c=Rg(ml,e.__scopeTooltip),f=Ed(t),[m,h]=C.useState(null),g=Cn(),w=C.useRef(0),k=d??c.disableHoverableContent,_=l??c.delayDuration,v=C.useRef(!1),[y,x]=ss({prop:s,defaultProp:o??!1,onChange:T=>{T?(c.onOpen(),document.dispatchEvent(new CustomEvent(qm))):c.onClose(),u==null||u(T)},caller:ml}),b=C.useMemo(()=>y?v.current?"delayed-open":"instant-open":"closed",[y]),j=C.useCallback(()=>{window.clearTimeout(w.current),w.current=0,v.current=!1,x(!0)},[x]),E=C.useCallback(()=>{window.clearTimeout(w.current),w.current=0,x(!1)},[x]),P=C.useCallback(()=>{window.clearTimeout(w.current),w.current=window.setTimeout(()=>{v.current=!0,x(!0),w.current=0},_)},[_,x]);return C.useEffect(()=>()=>{w.current&&(window.clearTimeout(w.current),w.current=0)},[]),n.jsx(vg,{...f,children:n.jsx(ZB,{scope:t,contentId:g,open:y,stateAttribute:b,trigger:m,onTriggerChange:h,onTriggerEnter:C.useCallback(()=>{c.isOpenDelayedRef.current?P():j()},[c.isOpenDelayedRef,P,j]),onTriggerLeave:C.useCallback(()=>{k?E():(window.clearTimeout(w.current),w.current=0)},[E,k]),onOpen:j,onClose:E,disableHoverableContent:k,children:r})})};yj.displayName=ml;var Ym="TooltipTrigger",bj=C.forwardRef((e,t)=>{const{__scopeTooltip:r,...s}=e,o=Dl(Ym,r),u=Rg(Ym,r),d=Ed(r),l=C.useRef(null),c=it(t,l,o.onTriggerChange),f=C.useRef(!1),m=C.useRef(!1),h=C.useCallback(()=>f.current=!1,[]);return C.useEffect(()=>()=>document.removeEventListener("pointerup",h),[h]),n.jsx(yg,{asChild:!0,...d,children:n.jsx(Je.button,{"aria-describedby":o.open?o.contentId:void 0,"data-state":o.stateAttribute,...s,ref:c,onPointerMove:Re(e.onPointerMove,g=>{g.pointerType!=="touch"&&!m.current&&!u.isPointerInTransitRef.current&&(o.onTriggerEnter(),m.current=!0)}),onPointerLeave:Re(e.onPointerLeave,()=>{o.onTriggerLeave(),m.current=!1}),onPointerDown:Re(e.onPointerDown,()=>{o.open&&o.onClose(),f.current=!0,document.addEventListener("pointerup",h,{once:!0})}),onFocus:Re(e.onFocus,()=>{f.current||o.onOpen()}),onBlur:Re(e.onBlur,o.onClose),onClick:Re(e.onClick,o.onClose)})})});bj.displayName=Ym;var Mg="TooltipPortal",[eF,tF]=Nd(Mg,{forceMount:void 0}),wj=e=>{const{__scopeTooltip:t,forceMount:r,children:s,container:o}=e,u=Dl(Mg,t);return n.jsx(eF,{scope:t,forceMount:r,children:n.jsx(wr,{present:r||u.open,children:n.jsx(Nl,{asChild:!0,container:o,children:s})})})};wj.displayName=Mg;var zo="TooltipContent",_j=C.forwardRef((e,t)=>{const r=tF(zo,e.__scopeTooltip),{forceMount:s=r.forceMount,side:o="top",...u}=e,d=Dl(zo,e.__scopeTooltip);return n.jsx(wr,{present:s||d.open,children:d.disableHoverableContent?n.jsx(Sj,{side:o,...u,ref:t}):n.jsx(rF,{side:o,...u,ref:t})})}),rF=C.forwardRef((e,t)=>{const r=Dl(zo,e.__scopeTooltip),s=Rg(zo,e.__scopeTooltip),o=C.useRef(null),u=it(t,o),[d,l]=C.useState(null),{trigger:c,onClose:f}=r,m=o.current,{onPointerInTransitChange:h}=s,g=C.useCallback(()=>{l(null),h(!1)},[h]),w=C.useCallback((k,_)=>{const v=k.currentTarget,y={x:k.clientX,y:k.clientY},x=aF(y,v.getBoundingClientRect()),b=lF(y,x),j=cF(_.getBoundingClientRect()),E=dF([...b,...j]);l(E),h(!0)},[h]);return C.useEffect(()=>()=>g(),[g]),C.useEffect(()=>{if(c&&m){const k=v=>w(v,m),_=v=>w(v,c);return c.addEventListener("pointerleave",k),m.addEventListener("pointerleave",_),()=>{c.removeEventListener("pointerleave",k),m.removeEventListener("pointerleave",_)}}},[c,m,w,g]),C.useEffect(()=>{if(d){const k=_=>{const v=_.target,y={x:_.clientX,y:_.clientY},x=(c==null?void 0:c.contains(v))||(m==null?void 0:m.contains(v)),b=!uF(y,d);x?g():b&&(g(),f())};return document.addEventListener("pointermove",k),()=>document.removeEventListener("pointermove",k)}},[c,m,d,f,g]),n.jsx(Sj,{...e,ref:u})}),[nF,sF]=Nd(ml,{isInside:!1}),iF=XB("TooltipContent"),Sj=C.forwardRef((e,t)=>{const{__scopeTooltip:r,children:s,"aria-label":o,onEscapeKeyDown:u,onPointerDownOutside:d,...l}=e,c=Dl(zo,r),f=Ed(r),{onClose:m}=c;return C.useEffect(()=>(document.addEventListener(qm,m),()=>document.removeEventListener(qm,m)),[m]),C.useEffect(()=>{if(c.trigger){const h=g=>{const w=g.target;w!=null&&w.contains(c.trigger)&&m()};return window.addEventListener("scroll",h,{capture:!0}),()=>window.removeEventListener("scroll",h,{capture:!0})}},[c.trigger,m]),n.jsx(jl,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:u,onPointerDownOutside:d,onFocusOutside:h=>h.preventDefault(),onDismiss:m,children:n.jsxs(bg,{"data-state":c.stateAttribute,...f,...l,ref:t,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:[n.jsx(iF,{children:s}),n.jsx(nF,{scope:r,isInside:!0,children:n.jsx(bO,{id:c.contentId,role:"tooltip",children:o||s})})]})})});_j.displayName=zo;var Cj="TooltipArrow",oF=C.forwardRef((e,t)=>{const{__scopeTooltip:r,...s}=e,o=Ed(r);return sF(Cj,r).isInside?null:n.jsx(wg,{...o,...s,ref:t})});oF.displayName=Cj;function aF(e,t){const r=Math.abs(t.top-e.y),s=Math.abs(t.bottom-e.y),o=Math.abs(t.right-e.x),u=Math.abs(t.left-e.x);switch(Math.min(r,s,o,u)){case u:return"left";case o:return"right";case r:return"top";case s:return"bottom";default:throw new Error("unreachable")}}function lF(e,t,r=5){const s=[];switch(t){case"top":s.push({x:e.x-r,y:e.y+r},{x:e.x+r,y:e.y+r});break;case"bottom":s.push({x:e.x-r,y:e.y-r},{x:e.x+r,y:e.y-r});break;case"left":s.push({x:e.x+r,y:e.y-r},{x:e.x+r,y:e.y+r});break;case"right":s.push({x:e.x-r,y:e.y-r},{x:e.x-r,y:e.y+r});break}return s}function cF(e){const{top:t,right:r,bottom:s,left:o}=e;return[{x:o,y:t},{x:r,y:t},{x:r,y:s},{x:o,y:s}]}function uF(e,t){const{x:r,y:s}=e;let o=!1;for(let u=0,d=t.length-1;u<t.length;d=u++){const l=t[u],c=t[d],f=l.x,m=l.y,h=c.x,g=c.y;m>s!=g>s&&r<(h-f)*(s-m)/(g-m)+f&&(o=!o)}return o}function dF(e){const t=e.slice();return t.sort((r,s)=>r.x<s.x?-1:r.x>s.x?1:r.y<s.y?-1:r.y>s.y?1:0),hF(t)}function hF(e){if(e.length<=1)return e.slice();const t=[];for(let s=0;s<e.length;s++){const o=e[s];for(;t.length>=2;){const u=t[t.length-1],d=t[t.length-2];if((u.x-d.x)*(o.y-d.y)>=(u.y-d.y)*(o.x-d.x))t.pop();else break}t.push(o)}t.pop();const r=[];for(let s=e.length-1;s>=0;s--){const o=e[s];for(;r.length>=2;){const u=r[r.length-1],d=r[r.length-2];if((u.x-d.x)*(o.y-d.y)>=(u.y-d.y)*(o.x-d.x))r.pop();else break}r.push(o)}return r.pop(),t.length===1&&r.length===1&&t[0].x===r[0].x&&t[0].y===r[0].y?t:t.concat(r)}var fF=vj,mF=yj,pF=bj,gF=wj,kj=_j;const Ho=fF,on=mF,an=pF,Gr=C.forwardRef(({className:e,sideOffset:t=4,...r},s)=>n.jsx(gF,{children:n.jsx(kj,{ref:s,sideOffset:t,className:Ne("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),...r})}));Gr.displayName=kj.displayName;const xF=ed("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"}}),Wo=C.forwardRef(({className:e,variant:t,...r},s)=>n.jsx("div",{ref:s,role:"alert",className:Ne(xF({variant:t}),e),...r}));Wo.displayName="Alert";const vF=C.forwardRef(({className:e,...t},r)=>n.jsx("h5",{ref:r,className:Ne("mb-1 font-medium leading-none tracking-tight",e),...t}));vF.displayName="AlertTitle";const Vo=C.forwardRef(({className:e,...t},r)=>n.jsx("div",{ref:r,className:Ne("text-sm [&_p]:leading-relaxed",e),...t}));Vo.displayName="AlertDescription";var Pd="Collapsible",[yF]=qr(Pd),[bF,Dg]=yF(Pd),jj=C.forwardRef((e,t)=>{const{__scopeCollapsible:r,open:s,defaultOpen:o,disabled:u,onOpenChange:d,...l}=e,[c,f]=ss({prop:s,defaultProp:o??!1,onChange:d,caller:Pd});return n.jsx(bF,{scope:r,disabled:u,contentId:Cn(),open:c,onOpenToggle:C.useCallback(()=>f(m=>!m),[f]),children:n.jsx(Je.div,{"data-state":Ig(c),"data-disabled":u?"":void 0,...l,ref:t})})});jj.displayName=Pd;var Nj="CollapsibleTrigger",Ej=C.forwardRef((e,t)=>{const{__scopeCollapsible:r,...s}=e,o=Dg(Nj,r);return n.jsx(Je.button,{type:"button","aria-controls":o.contentId,"aria-expanded":o.open||!1,"data-state":Ig(o.open),"data-disabled":o.disabled?"":void 0,disabled:o.disabled,...s,ref:t,onClick:Re(e.onClick,o.onOpenToggle)})});Ej.displayName=Nj;var Lg="CollapsibleContent",Pj=C.forwardRef((e,t)=>{const{forceMount:r,...s}=e,o=Dg(Lg,e.__scopeCollapsible);return n.jsx(wr,{present:r||o.open,children:({present:u})=>n.jsx(wF,{...s,ref:t,present:u})})});Pj.displayName=Lg;var wF=C.forwardRef((e,t)=>{const{__scopeCollapsible:r,present:s,children:o,...u}=e,d=Dg(Lg,r),[l,c]=C.useState(s),f=C.useRef(null),m=it(t,f),h=C.useRef(0),g=h.current,w=C.useRef(0),k=w.current,_=d.open||l,v=C.useRef(_),y=C.useRef(void 0);return C.useEffect(()=>{const x=requestAnimationFrame(()=>v.current=!1);return()=>cancelAnimationFrame(x)},[]),hr(()=>{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),c(s)}},[d.open,s]),n.jsx(Je.div,{"data-state":Ig(d.open),"data-disabled":d.disabled?"":void 0,id:d.contentId,hidden:!_,...u,ref:m,style:{"--radix-collapsible-content-height":g?`${g}px`:void 0,"--radix-collapsible-content-width":k?`${k}px`:void 0,...e.style},children:_&&o})});function Ig(e){return e?"open":"closed"}var _F=jj;const Ad=_F,Td=Ej,Rd=Pj,Xm=[{name:"Bash",icon:Jt,description:"Shell commands",color:"text-purple-600",bgColor:"bg-purple-50",badgeClass:"bg-purple-100 text-purple-700 border-purple-200"},{name:"Read",icon:br,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:Vp,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:E1,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:Bi,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:Cl,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:Oo,description:"MCP server tools",color:"text-indigo-600",bgColor:"bg-indigo-50",badgeClass:"bg-indigo-100 text-indigo-700 border-indigo-200"}],Kb=[{category:"Git",name:"Git Status",pattern:"Bash(git status:*)",description:"Check repository status",icon:Jt},{category:"Git",name:"Git Add",pattern:"Bash(git add:*)",description:"Stage files for commit",icon:Jt},{category:"Git",name:"Git Commit",pattern:"Bash(git commit:*)",description:"Create commits",icon:Jt},{category:"Git",name:"Git Push",pattern:"Bash(git push:*)",description:"Push to remote repository",icon:Jt},{category:"Git",name:"Git Diff",pattern:"Bash(git diff:*)",description:"Show changes",icon:Jt},{category:"NPM",name:"NPM Install",pattern:"Bash(npm install:*)",description:"Install dependencies",icon:Jt},{category:"NPM",name:"NPM Run Scripts",pattern:"Bash(npm run:*)",description:"Run package scripts",icon:Jt},{category:"NPM",name:"NPM Test",pattern:"Bash(npm test:*)",description:"Run tests",icon:Jt},{category:"Files",name:"Read All Files",pattern:"Read(**)",description:"Read any file in the project",icon:br},{category:"Files",name:"Edit All Files",pattern:"Edit(**)",description:"Edit any file in the project",icon:Vp},{category:"Security",name:"Deny .env Files",pattern:"Read(./.env)",description:"Block reading environment files",icon:br,suggestedCategory:"deny"},{category:"Security",name:"Deny All .env",pattern:"Read(**/.env*)",description:"Block all environment files",icon:br,suggestedCategory:"deny"},{category:"Commands",name:"List Files",pattern:"Bash(ls:*)",description:"List directory contents",icon:Jt},{category:"Commands",name:"Find Files",pattern:"Bash(find:*)",description:"Find files and directories",icon:Jt},{category:"MCP",name:"Filesystem Operations",pattern:"mcp__filesystem__*",description:"All filesystem MCP operations",icon:Oo},{category:"MCP",name:"GitHub Operations",pattern:"mcp__github__*",description:"All GitHub MCP operations",icon:Oo}];function Md(e){if(!e)return{type:"unknown",value:"",hasWildcard:!1,description:""};if(e.startsWith("mcp__")){const r=e.split("__");return{type:"mcp",value:e,server:r[1]||"",tool:r[2]||"",hasWildcard:e.includes("*"),description:`MCP tool: ${r.slice(1).join("/")}`}}if(e==="WebSearch")return{type:"WebSearch",value:"",hasWildcard:!1,description:"Web search capability"};const t=e.match(/^(\w+)\((.+)\)$/);if(t){const[,r,s]=t,o=s.includes("*");return{type:r,value:s,hasWildcard:o,description:kF(r,s)}}return{type:"unknown",value:e,hasWildcard:e.includes("*"),description:e}}function SF(e,t){return e==="WebSearch"?"WebSearch":e==="mcp"?t:t?`${e}(${t})`:""}function CF(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 t=e.match(/^(\w+)\((.+)\)$/);if(!t)return"Invalid pattern format. Expected: Type(value) or mcp__server__tool";const[,r]=t,s=["Bash","Read","Edit","Write","WebFetch"];return s.includes(r)?null:`Unknown permission type: ${r}. Valid types: ${s.join(", ")}`}function kF(e,t){switch(e){case"Bash":if(t.includes(":")){const[r,s]=t.split(":");return s==="*"?`Run "${r}" with any arguments`:`Run "${r} ${s}"`}return`Run "${t}"`;case"Read":return t==="**"?"Read all files":t.includes("**")?`Read files matching ${t}`:`Read ${t}`;case"Edit":return t==="**"?"Edit all files":t.includes("**")?`Edit files matching ${t}`:`Edit ${t}`;case"Write":return t==="**"?"Write to any file":t.includes("**")?`Write files matching ${t}`:`Write to ${t}`;case"WebFetch":return t==="*"?"Fetch any URL":`Fetch URLs matching ${t}`;default:return t}}function jF(e){return Xm.find(r=>r.name===e)||Xm[0]}function NF(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 qb(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 EF(e,t){const r=Md(e),{type:s,value:o}=r,u={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=u[t]||u.ask;let l="",c="",f=[];switch(s){case"Bash":if(o.includes(":")){const[w,k]=o.split(":");k==="*"?(l=`Run "${w}" command`,c=`Allows running the ${w} command with any arguments`,f=[`${w} build`,`${w} test`,`${w} --help`]):(l=`Run "${w} ${k}"`,c="Allows running this specific command",f=[`${w} ${k}`])}else o==="*"?(l="Run any terminal command",c="Allows executing any command in the terminal. Use with caution!",f=["npm install","git push","rm files"]):(l=`Run "${o}" command`,c="Allows running this specific command",f=[o]);break;case"Read":if(o==="**")l="Read any file",c="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`,c=`Allows reading any file ending in .${w}`,f=[`file.${w}`,`src/component.${w}`]}else o.startsWith("./")?(l=`Read files in ${o}`,c=`Allows reading files in the ${o.replace("./","")} directory`):(l=`Read "${o}"`,c="Allows reading files matching this pattern");break;case"Edit":if(o==="**")l="Edit any file",c="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`,c=`Allows modifying any file ending in .${w}`}else o.startsWith("./")?(l=`Edit files in ${o}`,c=`Allows modifying files in the ${o.replace("./","")} directory`):(l=`Edit "${o}"`,c="Allows modifying files matching this pattern");break;case"Write":o==="**"?(l="Create any file",c="Allows creating new files anywhere in the project"):(l=`Create files in "${o}"`,c="Allows creating new files matching this pattern");break;case"WebFetch":o==="*"?(l="Fetch any URL",c="Allows making HTTP requests to any website",f=["api.github.com","docs.example.com"]):(l=`Fetch from ${o}`,c="Allows making HTTP requests to URLs matching this pattern");break;case"WebSearch":l="Search the web",c="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`,c=`Allows using any tool from the ${h} MCP server`):(l=`Use ${h}/${g}`,c=`Allows using the ${g} tool from the ${h} MCP server`);break;default:l=e,c="Custom permission rule"}return{summary:l,detail:c,examples:f,categoryMeaning:`${d.prefix} — ${d.meaning}`}}function PF(e){const t={Bash:[],Read:[],Edit:[],Write:[],WebFetch:[],WebSearch:[],mcp:[],other:[]};for(const s of e){const u=Md(s).type;t[u]?t[u].push(s):t.other.push(s)}return["Bash","Read","Edit","Write","WebFetch","WebSearch","mcp","other"].filter(s=>t[s].length>0).map(s=>({type:s,rules:t[s]}))}function AF({rule:e,category:t,onEdit:r,onDelete:s,readOnly:o}){const[u,d]=C.useState(!1),l=Md(e);jF(l.type);const c=EF(e,t),f=e.length>25?e.substring(0,22)+"...":e;return n.jsxs("div",{className:"inline-flex items-center group",onMouseEnter:()=>d(!0),onMouseLeave:()=>d(!1),children:[n.jsxs(on,{children:[n.jsx(an,{asChild:!0,children:n.jsx("span",{className:"inline-block",children:n.jsx(nt,{variant:"secondary",className:Ne("cursor-default transition-all text-xs font-mono py-1 px-2 h-7",t==="allow"&&"bg-green-100 dark:bg-green-950 text-green-800 dark:text-green-300",t==="ask"&&"bg-amber-100 dark:bg-amber-950 text-amber-800 dark:text-amber-300",t==="deny"&&"bg-red-100 dark:bg-red-950 text-red-800 dark:text-red-300",!o&&"rounded-r-none"),children:f})})}),n.jsx(Gr,{side:"bottom",className:"max-w-md p-3",children:n.jsxs("div",{className:"space-y-2",children:[n.jsxs("div",{children:[n.jsx("p",{className:"text-sm font-medium",children:c.summary}),n.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:c.detail})]}),n.jsx("div",{className:Ne("text-xs px-2 py-1 rounded",t==="allow"&&"bg-green-500/20 text-green-700 dark:text-green-300",t==="ask"&&"bg-amber-500/20 text-amber-700 dark:text-amber-300",t==="deny"&&"bg-red-500/20 text-red-700 dark:text-red-300"),children:c.categoryMeaning}),c.examples&&c.examples.length>0&&n.jsxs("div",{className:"text-xs text-muted-foreground",children:[n.jsx("span",{className:"font-medium",children:"Examples: "}),c.examples.join(", ")]}),n.jsxs("code",{className:"text-[10px] text-muted-foreground/70 block break-all",children:["Pattern: ",e]})]})})]}),!o&&n.jsxs(Ns,{children:[n.jsx(Es,{asChild:!0,children:n.jsx("button",{className:Ne("h-7 px-1 rounded-r transition-all border-l","hover:bg-black/10 dark:hover:bg-white/10",t==="allow"&&"bg-green-200 dark:bg-green-900 border-green-300 dark:border-green-800",t==="ask"&&"bg-amber-200 dark:bg-amber-900 border-amber-300 dark:border-amber-800",t==="deny"&&"bg-red-200 dark:bg-red-900 border-red-300 dark:border-red-800",u?"opacity-100":"opacity-0"),children:n.jsx(A5,{className:"w-3 h-3"})})}),n.jsxs(os,{align:"end",className:"w-32",children:[n.jsx(Ct,{onClick:r,children:"Edit"}),n.jsx(vr,{}),n.jsx(Ct,{onClick:s,className:"text-red-600",children:"Delete"})]})]})]})}const Yb={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 TF({type:e,rules:t,category:r,onEdit:s,onDelete:o,onAddRule:u,readOnly:d,defaultExpanded:l=!1}){const[c,f]=C.useState(l||t.length<=5),m=Yb[e]||Yb.other;return t.length===0?null:n.jsxs("div",{className:"border border-gray-200 dark:border-slate-700 rounded-lg overflow-hidden",children:[n.jsxs("button",{onClick:()=>f(!c),className:Ne("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:[n.jsx(rn,{className:Ne("w-4 h-4 text-gray-400 transition-transform",c&&"rotate-90")}),n.jsx("span",{className:Ne("font-medium text-sm",m.color),children:m.label}),n.jsx(nt,{variant:"secondary",className:"text-xs",children:t.length}),!c&&t.length>0&&n.jsxs("span",{className:"text-xs text-gray-400 dark:text-slate-500 truncate flex-1 ml-2",children:[t.slice(0,3).join(", "),t.length>3&&"..."]})]}),c&&n.jsx("div",{className:"p-3 bg-white dark:bg-slate-900",children:n.jsxs("div",{className:"flex flex-wrap gap-2",children:[t.map(h=>n.jsx(AF,{rule:h,category:r,onEdit:()=>s(h),onDelete:()=>o(h),readOnly:d},h)),!d&&n.jsxs(le,{variant:"outline",size:"sm",className:"h-7 text-xs",onClick:u,children:[n.jsx(_t,{className:"w-3 h-3 mr-1"}),"Add"]})]})})]})}function RF({open:e,onOpenChange:t,onSubmit:r,defaultCategory:s="allow",defaultRule:o="",isEditing:u=!1,existingRules:d=[]}){const[l,c]=C.useState("preset"),[f,m]=C.useState(s),[h,g]=C.useState("Bash"),[w,k]=C.useState(""),[_,v]=C.useState(o),[y,x]=C.useState(new Set),[b,j]=C.useState(""),[E,P]=C.useState(null);C.useEffect(()=>{if(e)if(m(s),x(new Set),j(""),o&&u){const K=Md(o);g(K.type==="unknown"?"Bash":K.type),k(K.value),v(o),c("builder")}else g("Bash"),k(""),v(""),c("preset")},[e,o,s,u]);const T=K=>{x(G=>{const U=new Set(G);return U.has(K)?U.delete(K):U.add(K),U})},N=()=>{const K=I.filter(G=>!d.includes(G.pattern)).map(G=>G.pattern);x(new Set(K))},M=()=>{x(new Set)},O=C.useMemo(()=>l==="freeform"?_:l==="builder"?SF(h,w):"",[l,h,w,_]);C.useEffect(()=>{if(l!=="preset"){const K=CF(O);P(K)}else P(null)},[O,l]);const I=C.useMemo(()=>{if(!b)return Kb;const K=b.toLowerCase();return Kb.filter(G=>G.name.toLowerCase().includes(K)||G.pattern.toLowerCase().includes(K)||G.description.toLowerCase().includes(K)||G.category.toLowerCase().includes(K))},[b]),H=C.useMemo(()=>{const K={};return I.forEach(G=>{K[G.category]||(K[G.category]=[]),K[G.category].push(G)}),K},[I]),W=()=>{if(l==="preset"){const K=Array.from(y);if(K.length===0)return;for(const G of K)r(f,G);t(!1)}else{if(E||!O)return;r(f,O),t(!1)}},Y=l==="preset"?y.size===0:!O||!!E,$=LF(h);return n.jsx(Bt,{open:e,onOpenChange:t,children:n.jsxs(Tt,{className:"max-w-2xl max-h-[90vh] overflow-hidden flex flex-col",children:[n.jsxs(Rt,{children:[n.jsx(Mt,{className:"flex items-center gap-2",children:u?n.jsxs(n.Fragment,{children:[n.jsx(E1,{className:"w-5 h-5 text-indigo-600"}),"Edit Permission Rule"]}):n.jsxs(n.Fragment,{children:[n.jsx(Qn,{className:"w-5 h-5 text-indigo-600"}),"Add Permission Rule"]})}),n.jsx(ar,{children:"Create a permission rule to control Claude Code's behavior."})]}),n.jsxs("div",{className:"flex-1 overflow-auto space-y-6 py-4",children:[n.jsxs("div",{className:"space-y-2",children:[n.jsx(Ht,{children:"Permission Category"}),n.jsxs(nn,{value:f,onValueChange:m,children:[n.jsx(Vr,{children:n.jsx(sn,{})}),n.jsxs(Ur,{children:[n.jsx(Pt,{value:"allow",children:n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("div",{className:"w-3 h-3 rounded-full bg-green-500"}),"Allow - Execute without asking"]})}),n.jsx(Pt,{value:"ask",children:n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("div",{className:"w-3 h-3 rounded-full bg-amber-500"}),"Ask - Require confirmation"]})}),n.jsx(Pt,{value:"deny",children:n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("div",{className:"w-3 h-3 rounded-full bg-red-500"}),"Deny - Block entirely"]})})]})]})]}),n.jsxs(jd,{value:l,onValueChange:c,children:[n.jsxs(Ml,{className:"grid w-full grid-cols-3",children:[n.jsxs(On,{value:"preset",children:[n.jsx(Qn,{className:"w-4 h-4 mr-2"}),"Presets"]}),n.jsxs(On,{value:"builder",children:[n.jsx(Jt,{className:"w-4 h-4 mr-2"}),"Builder"]}),n.jsxs(On,{value:"freeform",children:[n.jsx(Vp,{className:"w-4 h-4 mr-2"}),"Freeform"]})]}),n.jsxs(ys,{value:"preset",className:"space-y-4",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(ut,{placeholder:"Search presets...",value:b,onChange:K=>j(K.target.value),className:"flex-1"}),n.jsx(le,{variant:"outline",size:"sm",onClick:N,disabled:I.length===0,children:"Select All"}),n.jsx(le,{variant:"ghost",size:"sm",onClick:M,disabled:y.size===0,children:"Clear"})]}),y.size>0&&n.jsxs("div",{className:"flex items-center gap-2 text-sm text-indigo-600 dark:text-indigo-400",children:[n.jsx(Et,{className:"w-4 h-4"}),y.size," preset",y.size!==1?"s":""," selected"]}),n.jsx("div",{className:"border border-gray-200 dark:border-slate-700 rounded-lg max-h-[220px] overflow-auto",children:Object.entries(H).map(([K,G])=>n.jsxs("div",{className:"border-b border-gray-200 dark:border-slate-700 last:border-b-0",children:[n.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:K}),G.map(U=>{const L=U.icon,R=y.has(U.pattern),B=d.includes(U.pattern);return n.jsxs("label",{className:Ne("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":R?"bg-indigo-50 dark:bg-indigo-950/50":"hover:bg-gray-50 dark:hover:bg-slate-800"),children:[n.jsx(El,{checked:R,onCheckedChange:()=>!B&&T(U.pattern),disabled:B,className:"mt-0.5"}),n.jsx(L,{className:"w-4 h-4 mt-0.5 text-gray-400 dark:text-slate-500 shrink-0"}),n.jsxs("div",{className:"flex-1 min-w-0",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("span",{className:"font-medium text-sm",children:U.name}),B&&n.jsx(nt,{variant:"secondary",className:"text-xs",children:"Added"})]}),n.jsx("code",{className:"text-xs text-gray-500 dark:text-slate-400 block truncate",children:U.pattern})]})]},U.pattern)})]},K))})]}),n.jsxs(ys,{value:"builder",className:"space-y-4",children:[n.jsxs("div",{className:"space-y-2",children:[n.jsx(Ht,{children:"Permission Type"}),n.jsxs(nn,{value:h,onValueChange:g,children:[n.jsx(Vr,{children:n.jsx(sn,{})}),n.jsx(Ur,{children:Xm.map(K=>{const G=K.icon;return n.jsx(Pt,{value:K.name,children:n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(G,{className:"w-4 h-4"}),K.name,n.jsxs("span",{className:"text-xs text-gray-400 dark:text-slate-500",children:["- ",K.description]})]})},K.name)})})]})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx(Ht,{children:MF(h)}),n.jsxs(on,{children:[n.jsx(an,{children:n.jsx(al,{className:"w-4 h-4 text-gray-400"})}),n.jsx(Gr,{className:"max-w-xs",children:DF(h)})]})]}),h==="WebSearch"?n.jsx("p",{className:"text-sm text-gray-500 dark:text-slate-400 italic",children:"WebSearch does not require a value pattern."}):n.jsx(ut,{value:w,onChange:K=>k(K.target.value),placeholder:h==="Bash"?"command:arguments":"path/pattern",className:"font-mono"})]}),$.length>0&&n.jsxs("div",{className:"space-y-2",children:[n.jsx(Ht,{className:"text-xs text-gray-500 dark:text-slate-400",children:"Quick examples:"}),n.jsx("div",{className:"flex flex-wrap gap-2",children:$.map(K=>n.jsx(le,{variant:"outline",size:"sm",className:"text-xs h-7",onClick:()=>k(K.value),children:K.label},K.value))})]})]}),n.jsx(ys,{value:"freeform",className:"space-y-4",children:n.jsxs("div",{className:"space-y-2",children:[n.jsx(Ht,{children:"Rule Pattern"}),n.jsx(vt,{value:_,onChange:K=>v(K.target.value),placeholder:"e.g., Bash(npm run build), Read(**/*.ts)",className:"font-mono text-sm",rows:3}),n.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"&&n.jsxs("div",{className:"space-y-2",children:[n.jsx(Ht,{children:"Generated Rule"}),n.jsx("div",{className:Ne("p-3 rounded-lg border font-mono text-sm",E?"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:O||n.jsx("span",{className:"text-gray-400 dark:text-slate-500",children:"No rule configured"})}),E&&n.jsxs("div",{className:"flex items-center gap-2 text-sm text-red-600",children:[n.jsx(Oi,{className:"w-4 h-4"}),E]})]})]}),n.jsxs(Wt,{children:[n.jsx(le,{variant:"ghost",onClick:()=>t(!1),children:"Cancel"}),n.jsx(le,{onClick:W,disabled:Y,className:"bg-indigo-600 hover:bg-indigo-700 text-white",children:u?"Update Rule":l==="preset"&&y.size>1?`Add ${y.size} Rules`:"Add Rule"})]})]})})}function MF(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 DF(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 LF(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 IF({open:e,onOpenChange:t,mode:r,permissions:s,onImport:o}){const[u,d]=C.useState(""),[l,c]=C.useState(null),[f,m]=C.useState(!1);C.useEffect(()=>{e&&r==="export"?(d(JSON.stringify({permissions:s},null,2)),c(null)):e&&r==="import"&&(d(""),c(null))},[e,r,s]);const h=()=>{navigator.clipboard.writeText(u),m(!0),setTimeout(()=>m(!1),2e3),Z.success("Copied to clipboard")},g=()=>{try{const w=JSON.parse(u);if(!w.permissions){c('JSON must have a "permissions" key');return}const{allow:k=[],ask:_=[],deny:v=[]}=w.permissions;if(!Array.isArray(k)||!Array.isArray(_)||!Array.isArray(v)){c("allow, ask, and deny must be arrays");return}if([...k,..._,...v].some(x=>typeof x!="string")){c("All permission rules must be strings");return}o(w.permissions),t(!1)}catch(w){c("Invalid JSON: "+w.message)}};return n.jsx(Bt,{open:e,onOpenChange:t,children:n.jsxs(Tt,{className:"max-w-lg",children:[n.jsxs(Rt,{children:[n.jsx(Mt,{className:"flex items-center gap-2",children:r==="export"?n.jsxs(n.Fragment,{children:[n.jsx(_l,{className:"w-5 h-5 text-indigo-600"}),"Export Permissions"]}):n.jsxs(n.Fragment,{children:[n.jsx(Mm,{className:"w-5 h-5 text-indigo-600"}),"Import Permissions"]})}),n.jsx(ar,{children:r==="export"?"Copy this JSON to save or share your permission configuration.":"Paste a JSON permission configuration to import."})]}),n.jsxs("div",{className:"space-y-4 py-4",children:[n.jsx(vt,{value:u,onChange:w=>{d(w.target.value),c(null)},placeholder:r==="import"?"Paste JSON here...":"",className:"font-mono text-sm min-h-[300px]",readOnly:r==="export"}),l&&n.jsxs("div",{className:"flex items-center gap-2 text-sm text-red-600",children:[n.jsx(Oi,{className:"w-4 h-4"}),l]})]}),n.jsxs(Wt,{children:[n.jsx(le,{variant:"ghost",onClick:()=>t(!1),children:"Cancel"}),r==="export"?n.jsxs(le,{onClick:h,className:"bg-indigo-600 hover:bg-indigo-700 text-white",children:[f?n.jsx(Et,{className:"w-4 h-4 mr-2"}):n.jsx(Cu,{className:"w-4 h-4 mr-2"}),f?"Copied!":"Copy to Clipboard"]}):n.jsxs(le,{onClick:g,disabled:!u.trim(),className:"bg-indigo-600 hover:bg-indigo-700 text-white",children:[n.jsx(Mm,{className:"w-4 h-4 mr-2"}),"Import"]})]})]})})}function OF({open:e,onOpenChange:t,serverName:r,serverConfig:s={},permissions:o={allow:[],ask:[],deny:[]},onUpdatePermissions:u}){var T,N;const[d,l]=C.useState([]),[c,f]=C.useState(!1),[m,h]=C.useState(null),[g,w]=C.useState("");C.useEffect(()=>{e&&r&&k()},[e,r]);const k=async()=>{f(!0),h(null);try{const M=await we.getMcpServerTools(r);M.error?(h(M.error),l([])):l(M.tools||[])}catch(M){h(M.message),l([])}finally{f(!1)}},_=async()=>{await we.clearMcpToolsCache(r),await k()},v=C.useMemo(()=>{var H,W,Y,$;const M=`mcp__${r}__`,O=`${M}*`,I={allowAll:((H=o.allow)==null?void 0:H.includes(O))||!1,toolPermissions:{}};return(W=o.allow)==null||W.forEach(K=>{K.startsWith(M)&&K!==O&&(I.toolPermissions[K.replace(M,"")]="allow")}),(Y=o.ask)==null||Y.forEach(K=>{K.startsWith(M)&&K!==O&&(I.toolPermissions[K.replace(M,"")]="ask")}),($=o.deny)==null||$.forEach(K=>{K.startsWith(M)&&K!==O&&(I.toolPermissions[K.replace(M,"")]="deny")}),I},[r,o]),y=C.useMemo(()=>{const M=new Set;return d.forEach(O=>M.add(O.name)),Object.keys(v.toolPermissions).forEach(O=>M.add(O)),Array.from(M).sort().map(O=>{const I=d.find(H=>H.name===O);return{name:O,description:(I==null?void 0:I.description)||"",discovered:!!I}})},[d,v.toolPermissions]),x=M=>{const O=`mcp__${r}__*`;u==null||u(r,O,M?"allow":"remove")},b=(M,O)=>{const I=`mcp__${r}__${M}`;v.toolPermissions[M]===O?u==null||u(r,I,"remove"):u==null||u(r,I,O)},j=()=>{const M=g.trim();if(!M)return;const O=`mcp__${r}__${M}`;u==null||u(r,O,"allow"),w("")},E=M=>{const O=`mcp__${r}__${M}`;u==null||u(r,O,"remove")},P=s!=null&&s.command?"stdio":s!=null&&s.url?"sse":"unknown";return n.jsx(Ho,{children:n.jsx(Bt,{open:e,onOpenChange:t,children:n.jsxs(Tt,{className:"sm:max-w-[550px] max-h-[85vh] flex flex-col",children:[n.jsxs(Rt,{children:[n.jsxs(Mt,{className:"flex items-center gap-2",children:[n.jsx(Oo,{className:"w-5 h-5 text-purple-600"}),"Configure ",r]}),n.jsxs(ar,{children:[P==="stdio"&&s.command&&n.jsxs("code",{className:"text-xs bg-gray-100 dark:bg-slate-800 px-2 py-1 rounded",children:[s.command," ",(T=s.args)==null?void 0:T.slice(0,2).join(" "),((N=s.args)==null?void 0:N.length)>2&&"..."]}),P==="sse"&&s.url&&n.jsx("code",{className:"text-xs bg-gray-100 dark:bg-slate-800 px-2 py-1 rounded",children:s.url})]})]}),n.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col space-y-4 py-4",children:[n.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:[n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx(Ps,{className:"w-5 h-5 text-green-600"}),n.jsxs("div",{children:[n.jsx(Ht,{className:"font-medium",children:"Allow all tools"}),n.jsx("p",{className:"text-xs text-gray-500 dark:text-slate-400",children:"Grant permission for all tools from this server"})]})]}),n.jsx(xt,{checked:v.allowAll,onCheckedChange:x})]}),v.allowAll&&n.jsxs(Wo,{children:[n.jsx(Xu,{className:"w-4 h-4"}),n.jsx(Vo,{className:"text-sm",children:"All tools are allowed. Individual tool settings below are informational only."})]}),n.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col space-y-3",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx(Ht,{className:"text-sm font-medium",children:"Available Tools"}),n.jsxs(le,{variant:"ghost",size:"sm",onClick:_,disabled:c,className:"h-7",children:[n.jsx(dr,{className:Ne("w-3 h-3 mr-1",c&&"animate-spin")}),"Refresh"]})]}),m&&n.jsxs(Wo,{variant:"destructive",children:[n.jsx(Oi,{className:"w-4 h-4"}),n.jsxs(Vo,{className:"text-sm",children:[m,n.jsx("p",{className:"text-xs mt-1 opacity-80",children:"You can still add tools manually below."})]})]}),c&&n.jsxs("div",{className:"flex items-center justify-center py-8",children:[n.jsx(dr,{className:"w-5 h-5 animate-spin text-gray-400"}),n.jsx("span",{className:"ml-2 text-sm text-gray-500",children:"Discovering tools..."})]}),!c&&n.jsx(jn,{className:"flex-1 min-h-0 rounded-md border border-gray-200 dark:border-slate-700",children:n.jsx("div",{className:"divide-y divide-gray-200 dark:divide-slate-700",children:y.length>0?y.map(M=>{const O=v.toolPermissions[M.name];return n.jsxs("div",{className:"flex items-center justify-between p-2 hover:bg-gray-50 dark:hover:bg-slate-800/50",children:[n.jsxs("div",{className:"flex-1 min-w-0 mr-2",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("code",{className:"text-sm font-mono truncate",children:M.name}),!M.discovered&&n.jsx(nt,{variant:"outline",className:"text-xs",children:"manual"})]}),M.description&&n.jsx("p",{className:"text-xs text-gray-500 dark:text-slate-400 truncate",children:M.description})]}),n.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[n.jsxs(on,{children:[n.jsx(an,{asChild:!0,children:n.jsx(le,{variant:O==="allow"?"default":"ghost",size:"sm",className:Ne("h-7 w-7 p-0",O==="allow"&&"bg-green-600 hover:bg-green-700"),onClick:()=>b(M.name,"allow"),children:n.jsx(Et,{className:"w-3 h-3"})})}),n.jsx(Gr,{children:"Allow"})]}),n.jsxs(on,{children:[n.jsx(an,{asChild:!0,children:n.jsx(le,{variant:O==="ask"?"default":"ghost",size:"sm",className:Ne("h-7 w-7 p-0",O==="ask"&&"bg-amber-600 hover:bg-amber-700"),onClick:()=>b(M.name,"ask"),children:"?"})}),n.jsx(Gr,{children:"Ask"})]}),n.jsxs(on,{children:[n.jsx(an,{asChild:!0,children:n.jsx(le,{variant:O==="deny"?"default":"ghost",size:"sm",className:Ne("h-7 w-7 p-0",O==="deny"&&"bg-red-600 hover:bg-red-700"),onClick:()=>b(M.name,"deny"),children:n.jsx(_s,{className:"w-3 h-3"})})}),n.jsx(Gr,{children:"Deny"})]}),!M.discovered&&O&&n.jsxs(on,{children:[n.jsx(an,{asChild:!0,children:n.jsx(le,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 text-gray-400 hover:text-red-600",onClick:()=>E(M.name),children:n.jsx(Fn,{className:"w-3 h-3"})})}),n.jsx(Gr,{children:"Remove"})]})]})]},M.name)}):n.jsxs("div",{className:"text-center py-8 text-gray-500 dark:text-slate-400",children:[n.jsx("p",{className:"text-sm",children:"No tools discovered"}),n.jsx("p",{className:"text-xs mt-1",children:"Add tools manually below"})]})})}),n.jsxs("div",{className:"flex gap-2 pt-2 border-t border-gray-200 dark:border-slate-700",children:[n.jsx(ut,{value:g,onChange:M=>w(M.target.value),placeholder:"Add tool manually...",className:"flex-1 text-sm",onKeyDown:M=>{M.key==="Enter"&&(M.preventDefault(),j())}}),n.jsx(le,{size:"sm",onClick:j,disabled:!g.trim(),children:n.jsx(_t,{className:"w-4 h-4"})})]})]}),n.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:[n.jsxs("span",{className:"flex items-center gap-1",children:[n.jsx("div",{className:"w-3 h-3 rounded bg-green-600"}),"Allow"]}),n.jsxs("span",{className:"flex items-center gap-1",children:[n.jsx("div",{className:"w-3 h-3 rounded bg-amber-600"}),"Ask"]}),n.jsxs("span",{className:"flex items-center gap-1",children:[n.jsx("div",{className:"w-3 h-3 rounded bg-red-600"}),"Deny"]}),n.jsx("span",{className:"flex items-center gap-1 ml-auto",children:n.jsx("span",{className:"text-gray-400",children:"Click again to remove"})})]})]}),n.jsx(Wt,{children:n.jsx(le,{variant:"outline",onClick:()=>t(!1),children:"Done"})})]})})})}function BF({mcpServers:e={},permissions:t={allow:[],ask:[],deny:[]},onToggle:r,onUpdatePermission:s,readOnly:o=!1}){const[u,d]=C.useState(!0),[l,c]=C.useState(!1),[f,m]=C.useState(null),h=C.useMemo(()=>Object.keys(e).sort(),[e]),g=v=>{var x;const y=`mcp__${v}__*`;return((x=t.allow)==null?void 0:x.includes(y))||!1},w=v=>{var j,E,P;const y=`mcp__${v}__`,x=`${y}*`;let b=0;return(j=t.allow)==null||j.forEach(T=>{T.startsWith(y)&&T!==x&&b++}),(E=t.ask)==null||E.forEach(T=>{T.startsWith(y)&&T!==x&&b++}),(P=t.deny)==null||P.forEach(T=>{T.startsWith(y)&&T!==x&&b++}),b},k=(v,y)=>{const x=`mcp__${v}__*`;r==null||r(v,x,y)},_=(v,y)=>{y.stopPropagation(),m(v),c(!0)};return h.length===0?null:n.jsxs(n.Fragment,{children:[n.jsxs(Ad,{open:u,onOpenChange:d,className:"mb-6",children:[n.jsx(Td,{asChild:!0,children:n.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:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("div",{className:"w-8 h-8 rounded-lg bg-purple-100 dark:bg-purple-950 flex items-center justify-center",children:n.jsx(Oo,{className:"w-4 h-4 text-purple-600 dark:text-purple-400"})}),n.jsxs("div",{className:"text-left",children:[n.jsx("span",{className:"font-medium text-gray-900 dark:text-white",children:"Quick MCP Permissions"}),n.jsxs(nt,{variant:"secondary",className:"ml-2 text-xs",children:[h.length," server",h.length!==1?"s":""]})]})]}),n.jsx(yr,{className:Ne("w-4 h-4 text-gray-500 transition-transform",u&&"rotate-180")})]})}),n.jsx(Rd,{children:n.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",j=w(v);return n.jsxs("div",{className:"flex items-center justify-between p-3 hover:bg-gray-50 dark:hover:bg-slate-800/50",children:[n.jsx("div",{className:"flex items-center gap-3 flex-1 min-w-0",children:n.jsxs("div",{className:"flex flex-col min-w-0",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("span",{className:"font-medium text-gray-900 dark:text-white",children:v}),y&&n.jsxs(nt,{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:[n.jsx(Et,{className:"w-3 h-3 mr-1"}),"All"]}),!y&&j>0&&n.jsxs(nt,{variant:"outline",className:"text-xs",children:[j," tool",j!==1?"s":""]})]}),n.jsxs("span",{className:"text-xs text-gray-500 dark:text-slate-400 truncate",children:[b==="stdio"&&x.command,b==="sse"&&x.url]})]})}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(le,{variant:"ghost",size:"sm",className:"h-8 px-2",onClick:E=>_(v,E),disabled:o,children:n.jsx(ju,{className:"w-4 h-4"})}),n.jsxs("div",{className:"flex items-center gap-2 pl-2 border-l border-gray-200 dark:border-slate-700",children:[n.jsx("span",{className:"text-xs text-gray-500 dark:text-slate-400 whitespace-nowrap",children:"Allow all"}),n.jsx(xt,{checked:y,onCheckedChange:E=>k(v,E),disabled:o})]})]})]},v)}),n.jsxs("div",{className:"p-3 bg-gray-50 dark:bg-slate-800/50 flex items-start gap-2",children:[n.jsx(Xu,{className:"w-4 h-4 text-gray-400 mt-0.5 flex-shrink-0"}),n.jsxs("p",{className:"text-xs text-gray-500 dark:text-slate-400",children:["Click ",n.jsx(ju,{className:"w-3 h-3 inline mx-0.5"})," to configure specific tool permissions"]})]})]})})]}),f&&n.jsx(OF,{open:l,onOpenChange:c,serverName:f,serverConfig:e[f],permissions:t,onUpdatePermissions:s})]})}function FF({permissions:e,onSave:t,loading:r,readOnly:s=!1,mcpServers:o={}}){const[u,d]=C.useState({allow:[],ask:[],deny:[]}),[l,c]=C.useState("allow"),[f,m]=C.useState(!1),[h,g]=C.useState(!1),[w,k]=C.useState(!1),[_,v]=C.useState(null),[y,x]=C.useState(!1),[b,j]=C.useState("export");C.useEffect(()=>{e&&d({allow:e.allow||[],ask:e.ask||[],deny:e.deny||[]})},[e]);const E=C.useCallback(async $=>{if(!(!t||s)){m(!0);try{await t($)}catch(K){Z.error("Failed to save: "+K.message)}finally{m(!1)}}},[t,s]),P=C.useCallback(($,K)=>{d(G=>{if([...G.allow,...G.ask,...G.deny].includes(K))return Z.error("This rule already exists"),G;const L={...G,[$]:[...G[$],K]};return E(L),Z.success(`Rule added to ${$}`),L})},[E]),T=C.useCallback(($,K,G,U)=>{d(L=>{const R={...L};return R[$]=R[$].filter(B=>B!==K),R[G]=[...R[G],U],E(R),Z.success("Rule updated"),R})},[E]),N=C.useCallback(($,K)=>{d(G=>{const U={...G,[$]:G[$].filter(L=>L!==K)};return E(U),Z.success("Rule deleted"),U})},[E]);C.useCallback(($,K,G)=>{d(U=>{const L={...U,[$]:U[$].filter(R=>R!==K),[G]:[...U[G],K]};return E(L),Z.success(`Moved to ${G}`),L})},[E]);const M=C.useCallback($=>{const K={allow:$.allow||[],ask:$.ask||[],deny:$.deny||[]};d(K),E(K),Z.success("Permissions imported")},[E]),O=C.useCallback(($,K,G)=>{G?P("allow",K):N("allow",K)},[P,N]),I=C.useCallback(($,K,G)=>{d(U=>{const L={allow:[...U.allow||[]],ask:[...U.ask||[]],deny:[...U.deny||[]]};return L.allow=L.allow.filter(R=>R!==K),L.ask=L.ask.filter(R=>R!==K),L.deny=L.deny.filter(R=>R!==K),G==="allow"?L.allow.push(K):G==="ask"?L.ask.push(K):G==="deny"&&L.deny.push(K),E(L),L})},[E]),H=$=>{v(null),c($),k(!0)},W=($,K)=>{v({category:$,rule:K}),k(!0)},Y=u.allow.length+u.ask.length+u.deny.length;return n.jsx(Ho,{children:n.jsxs("div",{className:"space-y-6",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx("div",{className:"w-10 h-10 rounded-lg bg-indigo-100 dark:bg-indigo-950 flex items-center justify-center",children:n.jsx(Ps,{className:"w-5 h-5 text-indigo-600 dark:text-indigo-400"})}),n.jsxs("div",{children:[n.jsx("h2",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:"Claude Code Permissions"}),n.jsx("p",{className:"text-sm text-gray-500 dark:text-slate-400",children:"Configure what Claude Code can do automatically"})]})]}),n.jsxs("div",{className:"flex items-center gap-2",children:[f&&n.jsxs(nt,{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:[n.jsx(dr,{className:"w-3 h-3 mr-1 animate-spin"}),"Saving..."]}),n.jsxs(on,{children:[n.jsx(an,{asChild:!0,children:n.jsx(le,{variant:"outline",size:"sm",onClick:()=>{j("export"),x(!0)},children:n.jsx(_l,{className:"w-4 h-4"})})}),n.jsx(Gr,{children:"Export permissions"})]}),n.jsxs(on,{children:[n.jsx(an,{asChild:!0,children:n.jsx(le,{variant:"outline",size:"sm",onClick:()=>{j("import"),x(!0)},disabled:s,children:n.jsx(Mm,{className:"w-4 h-4"})})}),n.jsx(Gr,{children:"Import permissions"})]})]})]}),n.jsxs(Ad,{open:h,onOpenChange:g,children:[n.jsx(Td,{asChild:!0,children:n.jsxs(le,{variant:"ghost",size:"sm",className:"text-gray-500 dark:text-slate-400",children:[n.jsx(al,{className:"w-4 h-4 mr-2"}),"How permissions work",n.jsx(yr,{className:Ne("w-4 h-4 ml-2 transition-transform",h&&"rotate-180")})]})}),n.jsx(Rd,{children:n.jsxs(Wo,{className:"mt-2",children:[n.jsx(Xu,{className:"w-4 h-4"}),n.jsxs(Vo,{className:"text-sm",children:[n.jsxs("p",{className:"mb-2",children:["Permissions control what Claude Code can do automatically vs. what requires your approval. These settings are stored in ",n.jsx("code",{className:"px-1 py-0.5 bg-gray-100 dark:bg-slate-700 rounded text-xs",children:"~/.claude/settings.json"}),"."]}),n.jsxs("div",{className:"grid grid-cols-3 gap-4 mt-3",children:[n.jsxs("div",{children:[n.jsx(nt,{className:"bg-green-100 dark:bg-green-950 text-green-700 dark:text-green-400 mb-1",children:"Allow"}),n.jsx("p",{className:"text-xs text-gray-600 dark:text-slate-400",children:"Operations run without asking"})]}),n.jsxs("div",{children:[n.jsx(nt,{className:"bg-amber-100 dark:bg-amber-950 text-amber-700 dark:text-amber-400 mb-1",children:"Ask"}),n.jsx("p",{className:"text-xs text-gray-600 dark:text-slate-400",children:"Prompts for confirmation each time"})]}),n.jsxs("div",{children:[n.jsx(nt,{className:"bg-red-100 dark:bg-red-950 text-red-700 dark:text-red-400 mb-1",children:"Deny"}),n.jsx("p",{className:"text-xs text-gray-600 dark:text-slate-400",children:"Blocked entirely"})]})]}),n.jsxs("p",{className:"mt-3 text-xs text-gray-500 dark:text-slate-400",children:["Use wildcards: ",n.jsx("code",{className:"px-1 py-0.5 bg-gray-100 dark:bg-slate-700 rounded",children:"*"})," matches anything,"," ",n.jsx("code",{className:"px-1 py-0.5 bg-gray-100 dark:bg-slate-700 rounded",children:"**"})," matches recursively in paths."]})]})]})})]}),!r&&Object.keys(o).length>0&&n.jsx(BF,{mcpServers:o,permissions:u,onToggle:O,onUpdatePermission:I,readOnly:s}),r&&n.jsx("div",{className:"flex items-center justify-center py-12",children:n.jsx(dr,{className:"w-6 h-6 animate-spin text-gray-400"})}),!r&&Y===0&&n.jsxs(Wo,{children:[n.jsx(Ju,{className:"w-4 h-4"}),n.jsxs(Vo,{children:["No permission rules configured. Claude Code will use default behavior and ask for permission on sensitive operations.",n.jsx(le,{variant:"link",size:"sm",className:"ml-2 p-0 h-auto",onClick:()=>H("allow"),children:"Add your first rule"})]})]}),!r&&n.jsxs(jd,{value:l,onValueChange:c,children:[n.jsx(Ml,{className:"grid w-full grid-cols-3",children:["allow","ask","deny"].map($=>{var U;const K=qb($),G=((U=u[$])==null?void 0:U.length)||0;return n.jsxs(On,{value:$,className:"flex items-center gap-2",children:[n.jsx("div",{className:Ne("w-2 h-2 rounded-full",$==="allow"&&"bg-green-500",$==="ask"&&"bg-amber-500",$==="deny"&&"bg-red-500")}),K.label,G>0&&n.jsx(nt,{variant:"secondary",className:"ml-1 text-xs",children:G})]},$)})}),["allow","ask","deny"].map($=>{const K=qb($),G=u[$]||[],U=PF(G);return n.jsxs(ys,{value:$,className:"space-y-3",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs(on,{children:[n.jsx(an,{asChild:!0,children:n.jsx("p",{className:"text-sm text-gray-500 dark:text-slate-400 cursor-help",children:K.description})}),n.jsx(Gr,{className:"max-w-xs",children:NF($)})]}),n.jsxs(le,{size:"sm",variant:"outline",onClick:()=>H($),disabled:s,children:[n.jsx(_t,{className:"w-4 h-4 mr-1"}),"Add Rules"]})]}),G.length===0?n.jsxs("div",{className:Ne("text-center py-8 rounded-lg border-2 border-dashed",K.borderColor),children:[n.jsxs("p",{className:"text-gray-500 dark:text-slate-400",children:["No rules in ",$]}),n.jsx(le,{variant:"link",size:"sm",onClick:()=>H($),disabled:s,children:"Add rules"})]}):n.jsx("div",{className:"space-y-2",children:U.map(({type:L,rules:R})=>n.jsx(TF,{type:L,rules:R,category:$,onEdit:B=>W($,B),onDelete:B=>N($,B),onAddRule:()=>H($),readOnly:s},L))})]},$)})]}),n.jsx(RF,{open:w,onOpenChange:k,onSubmit:($,K)=>{_?T(_.category,_.rule,$,K):P($,K)},defaultCategory:(_==null?void 0:_.category)||l,defaultRule:(_==null?void 0:_.rule)||"",isEditing:!!_,existingRules:[...u.allow,...u.ask,...u.deny]}),n.jsx(IF,{open:y,onOpenChange:x,mode:b,permissions:u,onImport:M})]})})}const $F=[{id:"claude-sonnet-4-20250514",name:"Claude Sonnet 4",description:"Best balance of speed and capability",tier:"sonnet",recommended:!0},{id:"claude-opus-4-5-20251101",name:"Claude Opus 4.5",description:"Most capable, best for complex tasks",tier:"opus"},{id:"claude-haiku-4-5-20251001",name:"Claude Haiku 4.5",description:"Fastest, best for simple tasks",tier:"haiku"}],zF=[{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-20241022"}];function Aj({settings:e,onSave:t,loading:r,settingsPath:s="~/.claude/settings.json",mcpServers:o={}}){const[u,d]=C.useState({}),[l,c]=C.useState("permissions"),[f,m]=C.useState(!1),[h,g]=C.useState(!1),[w,k]=C.useState(""),[_,v]=C.useState(null),y=C.useRef(null);C.useEffect(()=>{e&&(d(e),k(JSON.stringify(e,null,2)))},[e]),C.useEffect(()=>{h||k(JSON.stringify(u,null,2))},[u,h]);const x=C.useCallback(async N=>{if(t){m(!0);try{await t(N)}catch(M){Z.error("Failed to save: "+M.message)}finally{m(!1)}}},[t]),b=C.useCallback(N=>{y.current&&clearTimeout(y.current),y.current=setTimeout(()=>{x(N)},800)},[x]),j=C.useCallback((N,M,O=!1)=>{d(I=>{const H={...I,[N]:M};return(M===""||M===null||M===void 0)&&delete H[N],O?x(H):b(H),H})},[x,b]),E=C.useCallback(async N=>{const M={...u,permissions:N};d(M),await x(M)},[u,x]),P=N=>{k(N);try{JSON.parse(N),v(null)}catch(M){v(M.message)}},T=async()=>{if(_){Z.error("Fix JSON errors before saving");return}try{const N=JSON.parse(w);d(N),await x(N),Z.success("Settings applied")}catch{Z.error("Invalid JSON")}};return n.jsxs("div",{className:"space-y-6",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx("div",{className:"w-10 h-10 rounded-lg bg-indigo-100 dark:bg-indigo-950 flex items-center justify-center",children:n.jsx(Bn,{className:"w-5 h-5 text-indigo-600 dark:text-indigo-400"})}),n.jsxs("div",{children:[n.jsx("h2",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:"Claude Code Settings"}),n.jsx("p",{className:"text-sm text-gray-500 dark:text-slate-400",children:"Configure Claude Code behavior globally"})]})]}),n.jsxs("div",{className:"flex items-center gap-2",children:[f&&n.jsxs(nt,{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:[n.jsx(dr,{className:"w-3 h-3 mr-1 animate-spin"}),"Saving..."]}),n.jsx(Ho,{children:n.jsxs(on,{children:[n.jsx(an,{asChild:!0,children:n.jsx(le,{variant:"outline",size:"sm",onClick:()=>g(!h),children:h?n.jsx(_1,{className:"w-4 h-4"}):n.jsx(_5,{className:"w-4 h-4"})})}),n.jsx(Gr,{children:h?"Show UI":"Show JSON"})]})})]})]}),n.jsxs("p",{className:"text-sm text-gray-500 dark:text-slate-400",children:["Settings file: ",n.jsx("code",{className:"bg-gray-100 dark:bg-slate-800 px-2 py-0.5 rounded text-xs",children:s})]}),r&&n.jsx("div",{className:"flex items-center justify-center py-12",children:n.jsx(dr,{className:"w-6 h-6 animate-spin text-gray-400"})}),!r&&h&&n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx(Ht,{children:"Raw JSON"}),n.jsxs("div",{className:"flex items-center gap-2",children:[_&&n.jsx(nt,{variant:"destructive",className:"text-xs",children:_}),n.jsxs(le,{size:"sm",onClick:T,disabled:f||!!_,className:"bg-indigo-600 hover:bg-indigo-700 text-white",children:[n.jsx(Et,{className:"w-4 h-4 mr-1"}),"Apply JSON"]})]})]}),n.jsx(vt,{value:w,onChange:N=>P(N.target.value),className:Ne("font-mono text-sm min-h-[400px]",_&&"border-red-300 focus:border-red-500")})]}),!r&&!h&&n.jsxs(jd,{value:l,onValueChange:c,children:[n.jsxs(Ml,{className:"grid w-full grid-cols-4",children:[n.jsxs(On,{value:"permissions",className:"flex items-center gap-2",children:[n.jsx(Ps,{className:"w-4 h-4"}),"Permissions"]}),n.jsxs(On,{value:"model",className:"flex items-center gap-2",children:[n.jsx(Qu,{className:"w-4 h-4"}),"Model"]}),n.jsxs(On,{value:"behavior",className:"flex items-center gap-2",children:[n.jsx(Bn,{className:"w-4 h-4"}),"Behavior"]}),n.jsxs(On,{value:"advanced",className:"flex items-center gap-2",children:[n.jsx(Jt,{className:"w-4 h-4"}),"Advanced"]})]}),n.jsx(ys,{value:"permissions",className:"pt-4",children:n.jsx(FF,{permissions:u.permissions,onSave:E,loading:!1,mcpServers:o})}),n.jsx(ys,{value:"model",className:"space-y-6 pt-4",children:n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{children:[n.jsx(Ht,{className:"text-base font-medium",children:"Default Model"}),n.jsx("p",{className:"text-sm text-gray-500 dark:text-slate-400 mb-3",children:"Select the default model for Claude Code sessions"}),n.jsx("div",{className:"grid gap-3",children:$F.map(N=>n.jsx("button",{onClick:()=>j("model",N.id,!0),className:Ne("w-full p-4 rounded-lg border text-left transition-all",u.model===N.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:n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("span",{className:"font-medium",children:N.name}),N.recommended&&n.jsx(nt,{variant:"secondary",className:"text-xs",children:"Recommended"}),n.jsx(nt,{variant:"outline",className:Ne("text-xs",N.tier==="opus"&&"border-purple-300 text-purple-700",N.tier==="sonnet"&&"border-blue-300 text-blue-700",N.tier==="haiku"&&"border-green-300 text-green-700"),children:N.tier})]}),n.jsx("p",{className:"text-sm text-gray-500 dark:text-slate-400 mt-1",children:N.description})]}),u.model===N.id&&n.jsx(Et,{className:"w-5 h-5 text-indigo-600 dark:text-indigo-400"})]})},N.id))})]}),n.jsxs("div",{children:[n.jsx(Ht,{children:"Custom Model ID"}),n.jsx("p",{className:"text-xs text-gray-500 dark:text-slate-400 mb-2",children:"Override with a specific model ID (for AWS Bedrock, etc.)"}),n.jsx(ut,{value:u.model||"",onChange:N=>j("model",N.target.value),placeholder:"claude-sonnet-4-20250514",className:"font-mono"})]})]})}),n.jsx(ys,{value:"behavior",className:"space-y-6 pt-4",children:n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{className:"flex items-center justify-between p-4 rounded-lg border border-gray-200 dark:border-slate-700",children:[n.jsxs("div",{children:[n.jsx(Ht,{children:"Auto-accept Edits"}),n.jsx("p",{className:"text-sm text-gray-500 dark:text-slate-400",children:"Automatically accept file edits without confirmation"})]}),n.jsx(xt,{checked:u.autoAcceptEdits??!1,onCheckedChange:N=>j("autoAcceptEdits",N,!0)})]}),n.jsxs("div",{className:"flex items-center justify-between p-4 rounded-lg border border-gray-200 dark:border-slate-700",children:[n.jsxs("div",{children:[n.jsx(Ht,{children:"Verbose Output"}),n.jsx("p",{className:"text-sm text-gray-500 dark:text-slate-400",children:"Show detailed output for operations"})]}),n.jsx(xt,{checked:u.verbose??!1,onCheckedChange:N=>j("verbose",N,!0)})]}),n.jsxs("div",{className:"flex items-center justify-between p-4 rounded-lg border border-gray-200 dark:border-slate-700",children:[n.jsxs("div",{children:[n.jsx(Ht,{children:"Enable MCP Servers"}),n.jsx("p",{className:"text-sm text-gray-500 dark:text-slate-400",children:"Allow Claude Code to use MCP server connections"})]}),n.jsx(xt,{checked:u.enableMcp??!0,onCheckedChange:N=>j("enableMcp",N,!0)})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(Ht,{children:"API Base URL"}),n.jsx("p",{className:"text-xs text-gray-500 dark:text-slate-400",children:"Custom API endpoint (for proxies or enterprise deployments)"}),n.jsx(ut,{value:u.apiBaseUrl||"",onChange:N=>j("apiBaseUrl",N.target.value),placeholder:"https://api.anthropic.com",className:"font-mono"})]})]})}),n.jsxs(ys,{value:"advanced",className:"space-y-6 pt-4",children:[n.jsxs(Wo,{children:[n.jsx(Ju,{className:"w-4 h-4"}),n.jsx(Vo,{children:"Advanced settings for power users. Incorrect values may cause Claude Code to malfunction."})]}),n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{children:[n.jsx(Ht,{className:"text-base font-medium",children:"Environment Variables"}),n.jsx("p",{className:"text-sm text-gray-500 dark:text-slate-400 mb-3",children:"Configure model-related environment variables"}),n.jsx("div",{className:"space-y-3",children:zF.map(N=>{var M;return n.jsxs("div",{className:"space-y-1",children:[n.jsx(Ht,{className:"text-sm",children:N.label}),n.jsx("p",{className:"text-xs text-gray-500 dark:text-slate-400",children:N.description}),n.jsx(ut,{value:((M=u.env)==null?void 0:M[N.key])||"",onChange:O=>{const I={...u.env||{},[N.key]:O.target.value};O.target.value||delete I[N.key],j("env",Object.keys(I).length?I:void 0)},placeholder:N.placeholder,className:"font-mono text-sm"})]},N.key)})})]}),n.jsxs("div",{children:[n.jsx(Ht,{className:"text-base font-medium",children:"Hooks"}),n.jsx("p",{className:"text-sm text-gray-500 dark:text-slate-400 mb-3",children:"Scripts to run before/after tool executions (JSON format)"}),n.jsx(vt,{value:u.hooks?JSON.stringify(u.hooks,null,2):"",onChange:N=>{try{const M=N.target.value?JSON.parse(N.target.value):void 0;j("hooks",M)}catch{}},placeholder:`{
566
+ }`,className:"font-mono text-sm bg-gray-50 dark:bg-slate-800",rows:12}),n.jsxs("p",{className:"text-xs text-gray-500 dark:text-slate-400 mt-2",children:["Accepts formats: ",n.jsx("code",{className:"bg-gray-100 dark:bg-slate-700 px-1 rounded",children:'{ "name": { "command": "...", "args": [...] } }'})," or ",n.jsx("code",{className:"bg-gray-100 dark:bg-slate-700 px-1 rounded",children:'{ "mcpServers": { ... } }'})]})]}),n.jsxs(Wt,{children:[n.jsx(le,{variant:"ghost",onClick:()=>w({open:!1,json:""}),children:"Cancel"}),n.jsxs(le,{onClick:y,className:"bg-blue-600 hover:bg-blue-700 text-white",children:[n.jsx(_t,{className:"w-4 h-4 mr-2"}),"Add MCP"]})]})]})})]})}function Gb({content:e,onSave:t,fileType:r}){const[s,o]=C.useState(e||""),[u,d]=C.useState(!1),l=C.useRef(null),c=C.useRef(null),f=C.useRef(e);C.useEffect(()=>{o(e||""),e!==f.current&&(f.current=e,setTimeout(()=>{if(c.current){c.current.focus();const w=(e||"").length;c.current.setSelectionRange(w,w)}},100))},[e]);const m=C.useCallback(w=>{l.current&&clearTimeout(l.current),l.current=setTimeout(async()=>{d(!0);try{await t(w)}finally{d(!1)}},2500)},[t]),h=w=>{const k=w.target.value;o(k),m(k)},g=fl[r]||fl.claudemd;return n.jsxs("div",{className:"h-full flex flex-col",children:[n.jsxs("div",{className:"flex items-center justify-between p-3 border-b bg-gray-50 dark:bg-slate-800",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(g.icon,{className:Ne("w-4 h-4",g.color)}),n.jsx("span",{className:"text-sm font-medium",children:g.label})]}),n.jsx("div",{className:"flex gap-2",children:u&&n.jsxs(nt,{variant:"outline",className:"text-xs text-blue-600",children:[n.jsx(dr,{className:"w-3 h-3 mr-1 animate-spin"}),"Saving..."]})})]}),n.jsx(vt,{ref:c,className:"flex-1 w-full font-mono text-sm border-0 rounded-none resize-none p-4",value:s,onChange:h,placeholder:`Enter ${g.label.toLowerCase()} content...`})]})}var UB=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],GB=UB.reduce((e,t)=>{const r=Zu(`Primitive.${t}`),s=C.forwardRef((o,u)=>{const{asChild:d,...l}=o,c=d?r:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),n.jsx(c,{...l,ref:u})});return s.displayName=`Primitive.${t}`,{...e,[t]:s}},{}),KB="Label",pj=C.forwardRef((e,t)=>n.jsx(GB.label,{...e,ref:t,onMouseDown:r=>{var o;r.target.closest("button, input, select, textarea")||((o=e.onMouseDown)==null||o.call(e,r),!r.defaultPrevented&&r.detail>1&&r.preventDefault())}}));pj.displayName=KB;var gj=pj;const qB=ed("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),Ht=C.forwardRef(({className:e,...t},r)=>n.jsx(gj,{ref:r,className:Ne(qB(),e),...t}));Ht.displayName=gj.displayName;var YB=Symbol("radix.slottable");function XB(e){const t=({children:r})=>n.jsx(n.Fragment,{children:r});return t.displayName=`${e}.Slottable`,t.__radixId=YB,t}var[Nd]=qr("Tooltip",[Jo]),Ed=Jo(),xj="TooltipProvider",JB=700,qm="tooltip.open",[QB,Rg]=Nd(xj),vj=e=>{const{__scopeTooltip:t,delayDuration:r=JB,skipDelayDuration:s=300,disableHoverableContent:o=!1,children:u}=e,d=C.useRef(!0),l=C.useRef(!1),c=C.useRef(0);return C.useEffect(()=>{const f=c.current;return()=>window.clearTimeout(f)},[]),n.jsx(QB,{scope:t,isOpenDelayedRef:d,delayDuration:r,onOpen:C.useCallback(()=>{window.clearTimeout(c.current),d.current=!1},[]),onClose:C.useCallback(()=>{window.clearTimeout(c.current),c.current=window.setTimeout(()=>d.current=!0,s)},[s]),isPointerInTransitRef:l,onPointerInTransitChange:C.useCallback(f=>{l.current=f},[]),disableHoverableContent:o,children:u})};vj.displayName=xj;var ml="Tooltip",[ZB,Dl]=Nd(ml),yj=e=>{const{__scopeTooltip:t,children:r,open:s,defaultOpen:o,onOpenChange:u,disableHoverableContent:d,delayDuration:l}=e,c=Rg(ml,e.__scopeTooltip),f=Ed(t),[m,h]=C.useState(null),g=Cn(),w=C.useRef(0),k=d??c.disableHoverableContent,_=l??c.delayDuration,v=C.useRef(!1),[y,x]=ss({prop:s,defaultProp:o??!1,onChange:T=>{T?(c.onOpen(),document.dispatchEvent(new CustomEvent(qm))):c.onClose(),u==null||u(T)},caller:ml}),b=C.useMemo(()=>y?v.current?"delayed-open":"instant-open":"closed",[y]),j=C.useCallback(()=>{window.clearTimeout(w.current),w.current=0,v.current=!1,x(!0)},[x]),E=C.useCallback(()=>{window.clearTimeout(w.current),w.current=0,x(!1)},[x]),P=C.useCallback(()=>{window.clearTimeout(w.current),w.current=window.setTimeout(()=>{v.current=!0,x(!0),w.current=0},_)},[_,x]);return C.useEffect(()=>()=>{w.current&&(window.clearTimeout(w.current),w.current=0)},[]),n.jsx(vg,{...f,children:n.jsx(ZB,{scope:t,contentId:g,open:y,stateAttribute:b,trigger:m,onTriggerChange:h,onTriggerEnter:C.useCallback(()=>{c.isOpenDelayedRef.current?P():j()},[c.isOpenDelayedRef,P,j]),onTriggerLeave:C.useCallback(()=>{k?E():(window.clearTimeout(w.current),w.current=0)},[E,k]),onOpen:j,onClose:E,disableHoverableContent:k,children:r})})};yj.displayName=ml;var Ym="TooltipTrigger",bj=C.forwardRef((e,t)=>{const{__scopeTooltip:r,...s}=e,o=Dl(Ym,r),u=Rg(Ym,r),d=Ed(r),l=C.useRef(null),c=it(t,l,o.onTriggerChange),f=C.useRef(!1),m=C.useRef(!1),h=C.useCallback(()=>f.current=!1,[]);return C.useEffect(()=>()=>document.removeEventListener("pointerup",h),[h]),n.jsx(yg,{asChild:!0,...d,children:n.jsx(Je.button,{"aria-describedby":o.open?o.contentId:void 0,"data-state":o.stateAttribute,...s,ref:c,onPointerMove:Re(e.onPointerMove,g=>{g.pointerType!=="touch"&&!m.current&&!u.isPointerInTransitRef.current&&(o.onTriggerEnter(),m.current=!0)}),onPointerLeave:Re(e.onPointerLeave,()=>{o.onTriggerLeave(),m.current=!1}),onPointerDown:Re(e.onPointerDown,()=>{o.open&&o.onClose(),f.current=!0,document.addEventListener("pointerup",h,{once:!0})}),onFocus:Re(e.onFocus,()=>{f.current||o.onOpen()}),onBlur:Re(e.onBlur,o.onClose),onClick:Re(e.onClick,o.onClose)})})});bj.displayName=Ym;var Mg="TooltipPortal",[eF,tF]=Nd(Mg,{forceMount:void 0}),wj=e=>{const{__scopeTooltip:t,forceMount:r,children:s,container:o}=e,u=Dl(Mg,t);return n.jsx(eF,{scope:t,forceMount:r,children:n.jsx(wr,{present:r||u.open,children:n.jsx(Nl,{asChild:!0,container:o,children:s})})})};wj.displayName=Mg;var zo="TooltipContent",_j=C.forwardRef((e,t)=>{const r=tF(zo,e.__scopeTooltip),{forceMount:s=r.forceMount,side:o="top",...u}=e,d=Dl(zo,e.__scopeTooltip);return n.jsx(wr,{present:s||d.open,children:d.disableHoverableContent?n.jsx(Sj,{side:o,...u,ref:t}):n.jsx(rF,{side:o,...u,ref:t})})}),rF=C.forwardRef((e,t)=>{const r=Dl(zo,e.__scopeTooltip),s=Rg(zo,e.__scopeTooltip),o=C.useRef(null),u=it(t,o),[d,l]=C.useState(null),{trigger:c,onClose:f}=r,m=o.current,{onPointerInTransitChange:h}=s,g=C.useCallback(()=>{l(null),h(!1)},[h]),w=C.useCallback((k,_)=>{const v=k.currentTarget,y={x:k.clientX,y:k.clientY},x=aF(y,v.getBoundingClientRect()),b=lF(y,x),j=cF(_.getBoundingClientRect()),E=dF([...b,...j]);l(E),h(!0)},[h]);return C.useEffect(()=>()=>g(),[g]),C.useEffect(()=>{if(c&&m){const k=v=>w(v,m),_=v=>w(v,c);return c.addEventListener("pointerleave",k),m.addEventListener("pointerleave",_),()=>{c.removeEventListener("pointerleave",k),m.removeEventListener("pointerleave",_)}}},[c,m,w,g]),C.useEffect(()=>{if(d){const k=_=>{const v=_.target,y={x:_.clientX,y:_.clientY},x=(c==null?void 0:c.contains(v))||(m==null?void 0:m.contains(v)),b=!uF(y,d);x?g():b&&(g(),f())};return document.addEventListener("pointermove",k),()=>document.removeEventListener("pointermove",k)}},[c,m,d,f,g]),n.jsx(Sj,{...e,ref:u})}),[nF,sF]=Nd(ml,{isInside:!1}),iF=XB("TooltipContent"),Sj=C.forwardRef((e,t)=>{const{__scopeTooltip:r,children:s,"aria-label":o,onEscapeKeyDown:u,onPointerDownOutside:d,...l}=e,c=Dl(zo,r),f=Ed(r),{onClose:m}=c;return C.useEffect(()=>(document.addEventListener(qm,m),()=>document.removeEventListener(qm,m)),[m]),C.useEffect(()=>{if(c.trigger){const h=g=>{const w=g.target;w!=null&&w.contains(c.trigger)&&m()};return window.addEventListener("scroll",h,{capture:!0}),()=>window.removeEventListener("scroll",h,{capture:!0})}},[c.trigger,m]),n.jsx(jl,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:u,onPointerDownOutside:d,onFocusOutside:h=>h.preventDefault(),onDismiss:m,children:n.jsxs(bg,{"data-state":c.stateAttribute,...f,...l,ref:t,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:[n.jsx(iF,{children:s}),n.jsx(nF,{scope:r,isInside:!0,children:n.jsx(bO,{id:c.contentId,role:"tooltip",children:o||s})})]})})});_j.displayName=zo;var Cj="TooltipArrow",oF=C.forwardRef((e,t)=>{const{__scopeTooltip:r,...s}=e,o=Ed(r);return sF(Cj,r).isInside?null:n.jsx(wg,{...o,...s,ref:t})});oF.displayName=Cj;function aF(e,t){const r=Math.abs(t.top-e.y),s=Math.abs(t.bottom-e.y),o=Math.abs(t.right-e.x),u=Math.abs(t.left-e.x);switch(Math.min(r,s,o,u)){case u:return"left";case o:return"right";case r:return"top";case s:return"bottom";default:throw new Error("unreachable")}}function lF(e,t,r=5){const s=[];switch(t){case"top":s.push({x:e.x-r,y:e.y+r},{x:e.x+r,y:e.y+r});break;case"bottom":s.push({x:e.x-r,y:e.y-r},{x:e.x+r,y:e.y-r});break;case"left":s.push({x:e.x+r,y:e.y-r},{x:e.x+r,y:e.y+r});break;case"right":s.push({x:e.x-r,y:e.y-r},{x:e.x-r,y:e.y+r});break}return s}function cF(e){const{top:t,right:r,bottom:s,left:o}=e;return[{x:o,y:t},{x:r,y:t},{x:r,y:s},{x:o,y:s}]}function uF(e,t){const{x:r,y:s}=e;let o=!1;for(let u=0,d=t.length-1;u<t.length;d=u++){const l=t[u],c=t[d],f=l.x,m=l.y,h=c.x,g=c.y;m>s!=g>s&&r<(h-f)*(s-m)/(g-m)+f&&(o=!o)}return o}function dF(e){const t=e.slice();return t.sort((r,s)=>r.x<s.x?-1:r.x>s.x?1:r.y<s.y?-1:r.y>s.y?1:0),hF(t)}function hF(e){if(e.length<=1)return e.slice();const t=[];for(let s=0;s<e.length;s++){const o=e[s];for(;t.length>=2;){const u=t[t.length-1],d=t[t.length-2];if((u.x-d.x)*(o.y-d.y)>=(u.y-d.y)*(o.x-d.x))t.pop();else break}t.push(o)}t.pop();const r=[];for(let s=e.length-1;s>=0;s--){const o=e[s];for(;r.length>=2;){const u=r[r.length-1],d=r[r.length-2];if((u.x-d.x)*(o.y-d.y)>=(u.y-d.y)*(o.x-d.x))r.pop();else break}r.push(o)}return r.pop(),t.length===1&&r.length===1&&t[0].x===r[0].x&&t[0].y===r[0].y?t:t.concat(r)}var fF=vj,mF=yj,pF=bj,gF=wj,kj=_j;const Ho=fF,on=mF,an=pF,Gr=C.forwardRef(({className:e,sideOffset:t=4,...r},s)=>n.jsx(gF,{children:n.jsx(kj,{ref:s,sideOffset:t,className:Ne("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),...r})}));Gr.displayName=kj.displayName;const xF=ed("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"}}),Wo=C.forwardRef(({className:e,variant:t,...r},s)=>n.jsx("div",{ref:s,role:"alert",className:Ne(xF({variant:t}),e),...r}));Wo.displayName="Alert";const vF=C.forwardRef(({className:e,...t},r)=>n.jsx("h5",{ref:r,className:Ne("mb-1 font-medium leading-none tracking-tight",e),...t}));vF.displayName="AlertTitle";const Vo=C.forwardRef(({className:e,...t},r)=>n.jsx("div",{ref:r,className:Ne("text-sm [&_p]:leading-relaxed",e),...t}));Vo.displayName="AlertDescription";var Pd="Collapsible",[yF]=qr(Pd),[bF,Dg]=yF(Pd),jj=C.forwardRef((e,t)=>{const{__scopeCollapsible:r,open:s,defaultOpen:o,disabled:u,onOpenChange:d,...l}=e,[c,f]=ss({prop:s,defaultProp:o??!1,onChange:d,caller:Pd});return n.jsx(bF,{scope:r,disabled:u,contentId:Cn(),open:c,onOpenToggle:C.useCallback(()=>f(m=>!m),[f]),children:n.jsx(Je.div,{"data-state":Ig(c),"data-disabled":u?"":void 0,...l,ref:t})})});jj.displayName=Pd;var Nj="CollapsibleTrigger",Ej=C.forwardRef((e,t)=>{const{__scopeCollapsible:r,...s}=e,o=Dg(Nj,r);return n.jsx(Je.button,{type:"button","aria-controls":o.contentId,"aria-expanded":o.open||!1,"data-state":Ig(o.open),"data-disabled":o.disabled?"":void 0,disabled:o.disabled,...s,ref:t,onClick:Re(e.onClick,o.onOpenToggle)})});Ej.displayName=Nj;var Lg="CollapsibleContent",Pj=C.forwardRef((e,t)=>{const{forceMount:r,...s}=e,o=Dg(Lg,e.__scopeCollapsible);return n.jsx(wr,{present:r||o.open,children:({present:u})=>n.jsx(wF,{...s,ref:t,present:u})})});Pj.displayName=Lg;var wF=C.forwardRef((e,t)=>{const{__scopeCollapsible:r,present:s,children:o,...u}=e,d=Dg(Lg,r),[l,c]=C.useState(s),f=C.useRef(null),m=it(t,f),h=C.useRef(0),g=h.current,w=C.useRef(0),k=w.current,_=d.open||l,v=C.useRef(_),y=C.useRef(void 0);return C.useEffect(()=>{const x=requestAnimationFrame(()=>v.current=!1);return()=>cancelAnimationFrame(x)},[]),hr(()=>{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),c(s)}},[d.open,s]),n.jsx(Je.div,{"data-state":Ig(d.open),"data-disabled":d.disabled?"":void 0,id:d.contentId,hidden:!_,...u,ref:m,style:{"--radix-collapsible-content-height":g?`${g}px`:void 0,"--radix-collapsible-content-width":k?`${k}px`:void 0,...e.style},children:_&&o})});function Ig(e){return e?"open":"closed"}var _F=jj;const Ad=_F,Td=Ej,Rd=Pj,Xm=[{name:"Bash",icon:Jt,description:"Shell commands",color:"text-purple-600",bgColor:"bg-purple-50",badgeClass:"bg-purple-100 text-purple-700 border-purple-200"},{name:"Read",icon:br,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:Vp,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:E1,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:Bi,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:Cl,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:Oo,description:"MCP server tools",color:"text-indigo-600",bgColor:"bg-indigo-50",badgeClass:"bg-indigo-100 text-indigo-700 border-indigo-200"}],Kb=[{category:"Git",name:"Git Status",pattern:"Bash(git status:*)",description:"Check repository status",icon:Jt},{category:"Git",name:"Git Add",pattern:"Bash(git add:*)",description:"Stage files for commit",icon:Jt},{category:"Git",name:"Git Commit",pattern:"Bash(git commit:*)",description:"Create commits",icon:Jt},{category:"Git",name:"Git Push",pattern:"Bash(git push:*)",description:"Push to remote repository",icon:Jt},{category:"Git",name:"Git Diff",pattern:"Bash(git diff:*)",description:"Show changes",icon:Jt},{category:"NPM",name:"NPM Install",pattern:"Bash(npm install:*)",description:"Install dependencies",icon:Jt},{category:"NPM",name:"NPM Run Scripts",pattern:"Bash(npm run:*)",description:"Run package scripts",icon:Jt},{category:"NPM",name:"NPM Test",pattern:"Bash(npm test:*)",description:"Run tests",icon:Jt},{category:"Files",name:"Read All Files",pattern:"Read(**)",description:"Read any file in the project",icon:br},{category:"Files",name:"Edit All Files",pattern:"Edit(**)",description:"Edit any file in the project",icon:Vp},{category:"Security",name:"Deny .env Files",pattern:"Read(./.env)",description:"Block reading environment files",icon:br,suggestedCategory:"deny"},{category:"Security",name:"Deny All .env",pattern:"Read(**/.env*)",description:"Block all environment files",icon:br,suggestedCategory:"deny"},{category:"Commands",name:"List Files",pattern:"Bash(ls:*)",description:"List directory contents",icon:Jt},{category:"Commands",name:"Find Files",pattern:"Bash(find:*)",description:"Find files and directories",icon:Jt},{category:"MCP",name:"Filesystem Operations",pattern:"mcp__filesystem__*",description:"All filesystem MCP operations",icon:Oo},{category:"MCP",name:"GitHub Operations",pattern:"mcp__github__*",description:"All GitHub MCP operations",icon:Oo}];function Md(e){if(!e)return{type:"unknown",value:"",hasWildcard:!1,description:""};if(e.startsWith("mcp__")){const r=e.split("__");return{type:"mcp",value:e,server:r[1]||"",tool:r[2]||"",hasWildcard:e.includes("*"),description:`MCP tool: ${r.slice(1).join("/")}`}}if(e==="WebSearch")return{type:"WebSearch",value:"",hasWildcard:!1,description:"Web search capability"};const t=e.match(/^(\w+)\((.+)\)$/);if(t){const[,r,s]=t,o=s.includes("*");return{type:r,value:s,hasWildcard:o,description:kF(r,s)}}return{type:"unknown",value:e,hasWildcard:e.includes("*"),description:e}}function SF(e,t){return e==="WebSearch"?"WebSearch":e==="mcp"?t:t?`${e}(${t})`:""}function CF(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 t=e.match(/^(\w+)\((.+)\)$/);if(!t)return"Invalid pattern format. Expected: Type(value) or mcp__server__tool";const[,r]=t,s=["Bash","Read","Edit","Write","WebFetch"];return s.includes(r)?null:`Unknown permission type: ${r}. Valid types: ${s.join(", ")}`}function kF(e,t){switch(e){case"Bash":if(t.includes(":")){const[r,s]=t.split(":");return s==="*"?`Run "${r}" with any arguments`:`Run "${r} ${s}"`}return`Run "${t}"`;case"Read":return t==="**"?"Read all files":t.includes("**")?`Read files matching ${t}`:`Read ${t}`;case"Edit":return t==="**"?"Edit all files":t.includes("**")?`Edit files matching ${t}`:`Edit ${t}`;case"Write":return t==="**"?"Write to any file":t.includes("**")?`Write files matching ${t}`:`Write to ${t}`;case"WebFetch":return t==="*"?"Fetch any URL":`Fetch URLs matching ${t}`;default:return t}}function jF(e){return Xm.find(r=>r.name===e)||Xm[0]}function NF(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 qb(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 EF(e,t){const r=Md(e),{type:s,value:o}=r,u={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=u[t]||u.ask;let l="",c="",f=[];switch(s){case"Bash":if(o.includes(":")){const[w,k]=o.split(":");k==="*"?(l=`Run "${w}" command`,c=`Allows running the ${w} command with any arguments`,f=[`${w} build`,`${w} test`,`${w} --help`]):(l=`Run "${w} ${k}"`,c="Allows running this specific command",f=[`${w} ${k}`])}else o==="*"?(l="Run any terminal command",c="Allows executing any command in the terminal. Use with caution!",f=["npm install","git push","rm files"]):(l=`Run "${o}" command`,c="Allows running this specific command",f=[o]);break;case"Read":if(o==="**")l="Read any file",c="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`,c=`Allows reading any file ending in .${w}`,f=[`file.${w}`,`src/component.${w}`]}else o.startsWith("./")?(l=`Read files in ${o}`,c=`Allows reading files in the ${o.replace("./","")} directory`):(l=`Read "${o}"`,c="Allows reading files matching this pattern");break;case"Edit":if(o==="**")l="Edit any file",c="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`,c=`Allows modifying any file ending in .${w}`}else o.startsWith("./")?(l=`Edit files in ${o}`,c=`Allows modifying files in the ${o.replace("./","")} directory`):(l=`Edit "${o}"`,c="Allows modifying files matching this pattern");break;case"Write":o==="**"?(l="Create any file",c="Allows creating new files anywhere in the project"):(l=`Create files in "${o}"`,c="Allows creating new files matching this pattern");break;case"WebFetch":o==="*"?(l="Fetch any URL",c="Allows making HTTP requests to any website",f=["api.github.com","docs.example.com"]):(l=`Fetch from ${o}`,c="Allows making HTTP requests to URLs matching this pattern");break;case"WebSearch":l="Search the web",c="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`,c=`Allows using any tool from the ${h} MCP server`):(l=`Use ${h}/${g}`,c=`Allows using the ${g} tool from the ${h} MCP server`);break;default:l=e,c="Custom permission rule"}return{summary:l,detail:c,examples:f,categoryMeaning:`${d.prefix} — ${d.meaning}`}}function PF(e){const t={Bash:[],Read:[],Edit:[],Write:[],WebFetch:[],WebSearch:[],mcp:[],other:[]};for(const s of e){const u=Md(s).type;t[u]?t[u].push(s):t.other.push(s)}return["Bash","Read","Edit","Write","WebFetch","WebSearch","mcp","other"].filter(s=>t[s].length>0).map(s=>({type:s,rules:t[s]}))}function AF({rule:e,category:t,onEdit:r,onDelete:s,readOnly:o}){const[u,d]=C.useState(!1),l=Md(e);jF(l.type);const c=EF(e,t),f=e.length>25?e.substring(0,22)+"...":e;return n.jsxs("div",{className:"inline-flex items-center group",onMouseEnter:()=>d(!0),onMouseLeave:()=>d(!1),children:[n.jsxs(on,{children:[n.jsx(an,{asChild:!0,children:n.jsx("span",{className:"inline-block",children:n.jsx(nt,{variant:"secondary",className:Ne("cursor-default transition-all text-xs font-mono py-1 px-2 h-7",t==="allow"&&"bg-green-100 dark:bg-green-950 text-green-800 dark:text-green-300",t==="ask"&&"bg-amber-100 dark:bg-amber-950 text-amber-800 dark:text-amber-300",t==="deny"&&"bg-red-100 dark:bg-red-950 text-red-800 dark:text-red-300",!o&&"rounded-r-none"),children:f})})}),n.jsx(Gr,{side:"bottom",className:"max-w-md p-3",children:n.jsxs("div",{className:"space-y-2",children:[n.jsxs("div",{children:[n.jsx("p",{className:"text-sm font-medium",children:c.summary}),n.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:c.detail})]}),n.jsx("div",{className:Ne("text-xs px-2 py-1 rounded",t==="allow"&&"bg-green-500/20 text-green-700 dark:text-green-300",t==="ask"&&"bg-amber-500/20 text-amber-700 dark:text-amber-300",t==="deny"&&"bg-red-500/20 text-red-700 dark:text-red-300"),children:c.categoryMeaning}),c.examples&&c.examples.length>0&&n.jsxs("div",{className:"text-xs text-muted-foreground",children:[n.jsx("span",{className:"font-medium",children:"Examples: "}),c.examples.join(", ")]}),n.jsxs("code",{className:"text-[10px] text-muted-foreground/70 block break-all",children:["Pattern: ",e]})]})})]}),!o&&n.jsxs(Ns,{children:[n.jsx(Es,{asChild:!0,children:n.jsx("button",{className:Ne("h-7 px-1 rounded-r transition-all border-l","hover:bg-black/10 dark:hover:bg-white/10",t==="allow"&&"bg-green-200 dark:bg-green-900 border-green-300 dark:border-green-800",t==="ask"&&"bg-amber-200 dark:bg-amber-900 border-amber-300 dark:border-amber-800",t==="deny"&&"bg-red-200 dark:bg-red-900 border-red-300 dark:border-red-800",u?"opacity-100":"opacity-0"),children:n.jsx(A5,{className:"w-3 h-3"})})}),n.jsxs(os,{align:"end",className:"w-32",children:[n.jsx(Ct,{onClick:r,children:"Edit"}),n.jsx(vr,{}),n.jsx(Ct,{onClick:s,className:"text-red-600",children:"Delete"})]})]})]})}const Yb={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 TF({type:e,rules:t,category:r,onEdit:s,onDelete:o,onAddRule:u,readOnly:d,defaultExpanded:l=!1}){const[c,f]=C.useState(l||t.length<=5),m=Yb[e]||Yb.other;return t.length===0?null:n.jsxs("div",{className:"border border-gray-200 dark:border-slate-700 rounded-lg overflow-hidden",children:[n.jsxs("button",{onClick:()=>f(!c),className:Ne("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:[n.jsx(rn,{className:Ne("w-4 h-4 text-gray-400 transition-transform",c&&"rotate-90")}),n.jsx("span",{className:Ne("font-medium text-sm",m.color),children:m.label}),n.jsx(nt,{variant:"secondary",className:"text-xs",children:t.length}),!c&&t.length>0&&n.jsxs("span",{className:"text-xs text-gray-400 dark:text-slate-500 truncate flex-1 ml-2",children:[t.slice(0,3).join(", "),t.length>3&&"..."]})]}),c&&n.jsx("div",{className:"p-3 bg-white dark:bg-slate-900",children:n.jsxs("div",{className:"flex flex-wrap gap-2",children:[t.map(h=>n.jsx(AF,{rule:h,category:r,onEdit:()=>s(h),onDelete:()=>o(h),readOnly:d},h)),!d&&n.jsxs(le,{variant:"outline",size:"sm",className:"h-7 text-xs",onClick:u,children:[n.jsx(_t,{className:"w-3 h-3 mr-1"}),"Add"]})]})})]})}function RF({open:e,onOpenChange:t,onSubmit:r,defaultCategory:s="allow",defaultRule:o="",isEditing:u=!1,existingRules:d=[]}){const[l,c]=C.useState("preset"),[f,m]=C.useState(s),[h,g]=C.useState("Bash"),[w,k]=C.useState(""),[_,v]=C.useState(o),[y,x]=C.useState(new Set),[b,j]=C.useState(""),[E,P]=C.useState(null);C.useEffect(()=>{if(e)if(m(s),x(new Set),j(""),o&&u){const K=Md(o);g(K.type==="unknown"?"Bash":K.type),k(K.value),v(o),c("builder")}else g("Bash"),k(""),v(""),c("preset")},[e,o,s,u]);const T=K=>{x(G=>{const U=new Set(G);return U.has(K)?U.delete(K):U.add(K),U})},N=()=>{const K=I.filter(G=>!d.includes(G.pattern)).map(G=>G.pattern);x(new Set(K))},M=()=>{x(new Set)},O=C.useMemo(()=>l==="freeform"?_:l==="builder"?SF(h,w):"",[l,h,w,_]);C.useEffect(()=>{if(l!=="preset"){const K=CF(O);P(K)}else P(null)},[O,l]);const I=C.useMemo(()=>{if(!b)return Kb;const K=b.toLowerCase();return Kb.filter(G=>G.name.toLowerCase().includes(K)||G.pattern.toLowerCase().includes(K)||G.description.toLowerCase().includes(K)||G.category.toLowerCase().includes(K))},[b]),H=C.useMemo(()=>{const K={};return I.forEach(G=>{K[G.category]||(K[G.category]=[]),K[G.category].push(G)}),K},[I]),W=()=>{if(l==="preset"){const K=Array.from(y);if(K.length===0)return;for(const G of K)r(f,G);t(!1)}else{if(E||!O)return;r(f,O),t(!1)}},Y=l==="preset"?y.size===0:!O||!!E,$=LF(h);return n.jsx(Bt,{open:e,onOpenChange:t,children:n.jsxs(Tt,{className:"max-w-2xl max-h-[90vh] overflow-hidden flex flex-col",children:[n.jsxs(Rt,{children:[n.jsx(Mt,{className:"flex items-center gap-2",children:u?n.jsxs(n.Fragment,{children:[n.jsx(E1,{className:"w-5 h-5 text-indigo-600"}),"Edit Permission Rule"]}):n.jsxs(n.Fragment,{children:[n.jsx(Qn,{className:"w-5 h-5 text-indigo-600"}),"Add Permission Rule"]})}),n.jsx(ar,{children:"Create a permission rule to control Claude Code's behavior."})]}),n.jsxs("div",{className:"flex-1 overflow-auto space-y-6 py-4",children:[n.jsxs("div",{className:"space-y-2",children:[n.jsx(Ht,{children:"Permission Category"}),n.jsxs(nn,{value:f,onValueChange:m,children:[n.jsx(Vr,{children:n.jsx(sn,{})}),n.jsxs(Ur,{children:[n.jsx(Pt,{value:"allow",children:n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("div",{className:"w-3 h-3 rounded-full bg-green-500"}),"Allow - Execute without asking"]})}),n.jsx(Pt,{value:"ask",children:n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("div",{className:"w-3 h-3 rounded-full bg-amber-500"}),"Ask - Require confirmation"]})}),n.jsx(Pt,{value:"deny",children:n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("div",{className:"w-3 h-3 rounded-full bg-red-500"}),"Deny - Block entirely"]})})]})]})]}),n.jsxs(jd,{value:l,onValueChange:c,children:[n.jsxs(Ml,{className:"grid w-full grid-cols-3",children:[n.jsxs(On,{value:"preset",children:[n.jsx(Qn,{className:"w-4 h-4 mr-2"}),"Presets"]}),n.jsxs(On,{value:"builder",children:[n.jsx(Jt,{className:"w-4 h-4 mr-2"}),"Builder"]}),n.jsxs(On,{value:"freeform",children:[n.jsx(Vp,{className:"w-4 h-4 mr-2"}),"Freeform"]})]}),n.jsxs(ys,{value:"preset",className:"space-y-4",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(ut,{placeholder:"Search presets...",value:b,onChange:K=>j(K.target.value),className:"flex-1"}),n.jsx(le,{variant:"outline",size:"sm",onClick:N,disabled:I.length===0,children:"Select All"}),n.jsx(le,{variant:"ghost",size:"sm",onClick:M,disabled:y.size===0,children:"Clear"})]}),y.size>0&&n.jsxs("div",{className:"flex items-center gap-2 text-sm text-indigo-600 dark:text-indigo-400",children:[n.jsx(Et,{className:"w-4 h-4"}),y.size," preset",y.size!==1?"s":""," selected"]}),n.jsx("div",{className:"border border-gray-200 dark:border-slate-700 rounded-lg max-h-[220px] overflow-auto",children:Object.entries(H).map(([K,G])=>n.jsxs("div",{className:"border-b border-gray-200 dark:border-slate-700 last:border-b-0",children:[n.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:K}),G.map(U=>{const L=U.icon,R=y.has(U.pattern),B=d.includes(U.pattern);return n.jsxs("label",{className:Ne("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":R?"bg-indigo-50 dark:bg-indigo-950/50":"hover:bg-gray-50 dark:hover:bg-slate-800"),children:[n.jsx(El,{checked:R,onCheckedChange:()=>!B&&T(U.pattern),disabled:B,className:"mt-0.5"}),n.jsx(L,{className:"w-4 h-4 mt-0.5 text-gray-400 dark:text-slate-500 shrink-0"}),n.jsxs("div",{className:"flex-1 min-w-0",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("span",{className:"font-medium text-sm",children:U.name}),B&&n.jsx(nt,{variant:"secondary",className:"text-xs",children:"Added"})]}),n.jsx("code",{className:"text-xs text-gray-500 dark:text-slate-400 block truncate",children:U.pattern})]})]},U.pattern)})]},K))})]}),n.jsxs(ys,{value:"builder",className:"space-y-4",children:[n.jsxs("div",{className:"space-y-2",children:[n.jsx(Ht,{children:"Permission Type"}),n.jsxs(nn,{value:h,onValueChange:g,children:[n.jsx(Vr,{children:n.jsx(sn,{})}),n.jsx(Ur,{children:Xm.map(K=>{const G=K.icon;return n.jsx(Pt,{value:K.name,children:n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(G,{className:"w-4 h-4"}),K.name,n.jsxs("span",{className:"text-xs text-gray-400 dark:text-slate-500",children:["- ",K.description]})]})},K.name)})})]})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx(Ht,{children:MF(h)}),n.jsxs(on,{children:[n.jsx(an,{children:n.jsx(al,{className:"w-4 h-4 text-gray-400"})}),n.jsx(Gr,{className:"max-w-xs",children:DF(h)})]})]}),h==="WebSearch"?n.jsx("p",{className:"text-sm text-gray-500 dark:text-slate-400 italic",children:"WebSearch does not require a value pattern."}):n.jsx(ut,{value:w,onChange:K=>k(K.target.value),placeholder:h==="Bash"?"command:arguments":"path/pattern",className:"font-mono"})]}),$.length>0&&n.jsxs("div",{className:"space-y-2",children:[n.jsx(Ht,{className:"text-xs text-gray-500 dark:text-slate-400",children:"Quick examples:"}),n.jsx("div",{className:"flex flex-wrap gap-2",children:$.map(K=>n.jsx(le,{variant:"outline",size:"sm",className:"text-xs h-7",onClick:()=>k(K.value),children:K.label},K.value))})]})]}),n.jsx(ys,{value:"freeform",className:"space-y-4",children:n.jsxs("div",{className:"space-y-2",children:[n.jsx(Ht,{children:"Rule Pattern"}),n.jsx(vt,{value:_,onChange:K=>v(K.target.value),placeholder:"e.g., Bash(npm run build), Read(**/*.ts)",className:"font-mono text-sm",rows:3}),n.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"&&n.jsxs("div",{className:"space-y-2",children:[n.jsx(Ht,{children:"Generated Rule"}),n.jsx("div",{className:Ne("p-3 rounded-lg border font-mono text-sm",E?"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:O||n.jsx("span",{className:"text-gray-400 dark:text-slate-500",children:"No rule configured"})}),E&&n.jsxs("div",{className:"flex items-center gap-2 text-sm text-red-600",children:[n.jsx(Oi,{className:"w-4 h-4"}),E]})]})]}),n.jsxs(Wt,{children:[n.jsx(le,{variant:"ghost",onClick:()=>t(!1),children:"Cancel"}),n.jsx(le,{onClick:W,disabled:Y,className:"bg-indigo-600 hover:bg-indigo-700 text-white",children:u?"Update Rule":l==="preset"&&y.size>1?`Add ${y.size} Rules`:"Add Rule"})]})]})})}function MF(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 DF(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 LF(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 IF({open:e,onOpenChange:t,mode:r,permissions:s,onImport:o}){const[u,d]=C.useState(""),[l,c]=C.useState(null),[f,m]=C.useState(!1);C.useEffect(()=>{e&&r==="export"?(d(JSON.stringify({permissions:s},null,2)),c(null)):e&&r==="import"&&(d(""),c(null))},[e,r,s]);const h=()=>{navigator.clipboard.writeText(u),m(!0),setTimeout(()=>m(!1),2e3),Z.success("Copied to clipboard")},g=()=>{try{const w=JSON.parse(u);if(!w.permissions){c('JSON must have a "permissions" key');return}const{allow:k=[],ask:_=[],deny:v=[]}=w.permissions;if(!Array.isArray(k)||!Array.isArray(_)||!Array.isArray(v)){c("allow, ask, and deny must be arrays");return}if([...k,..._,...v].some(x=>typeof x!="string")){c("All permission rules must be strings");return}o(w.permissions),t(!1)}catch(w){c("Invalid JSON: "+w.message)}};return n.jsx(Bt,{open:e,onOpenChange:t,children:n.jsxs(Tt,{className:"max-w-lg",children:[n.jsxs(Rt,{children:[n.jsx(Mt,{className:"flex items-center gap-2",children:r==="export"?n.jsxs(n.Fragment,{children:[n.jsx(_l,{className:"w-5 h-5 text-indigo-600"}),"Export Permissions"]}):n.jsxs(n.Fragment,{children:[n.jsx(Mm,{className:"w-5 h-5 text-indigo-600"}),"Import Permissions"]})}),n.jsx(ar,{children:r==="export"?"Copy this JSON to save or share your permission configuration.":"Paste a JSON permission configuration to import."})]}),n.jsxs("div",{className:"space-y-4 py-4",children:[n.jsx(vt,{value:u,onChange:w=>{d(w.target.value),c(null)},placeholder:r==="import"?"Paste JSON here...":"",className:"font-mono text-sm min-h-[300px]",readOnly:r==="export"}),l&&n.jsxs("div",{className:"flex items-center gap-2 text-sm text-red-600",children:[n.jsx(Oi,{className:"w-4 h-4"}),l]})]}),n.jsxs(Wt,{children:[n.jsx(le,{variant:"ghost",onClick:()=>t(!1),children:"Cancel"}),r==="export"?n.jsxs(le,{onClick:h,className:"bg-indigo-600 hover:bg-indigo-700 text-white",children:[f?n.jsx(Et,{className:"w-4 h-4 mr-2"}):n.jsx(Cu,{className:"w-4 h-4 mr-2"}),f?"Copied!":"Copy to Clipboard"]}):n.jsxs(le,{onClick:g,disabled:!u.trim(),className:"bg-indigo-600 hover:bg-indigo-700 text-white",children:[n.jsx(Mm,{className:"w-4 h-4 mr-2"}),"Import"]})]})]})})}function OF({open:e,onOpenChange:t,serverName:r,serverConfig:s={},permissions:o={allow:[],ask:[],deny:[]},onUpdatePermissions:u}){var T,N;const[d,l]=C.useState([]),[c,f]=C.useState(!1),[m,h]=C.useState(null),[g,w]=C.useState("");C.useEffect(()=>{e&&r&&k()},[e,r]);const k=async()=>{f(!0),h(null);try{const M=await we.getMcpServerTools(r);M.error?(h(M.error),l([])):l(M.tools||[])}catch(M){h(M.message),l([])}finally{f(!1)}},_=async()=>{await we.clearMcpToolsCache(r),await k()},v=C.useMemo(()=>{var H,W,Y,$;const M=`mcp__${r}__`,O=`${M}*`,I={allowAll:((H=o.allow)==null?void 0:H.includes(O))||!1,toolPermissions:{}};return(W=o.allow)==null||W.forEach(K=>{K.startsWith(M)&&K!==O&&(I.toolPermissions[K.replace(M,"")]="allow")}),(Y=o.ask)==null||Y.forEach(K=>{K.startsWith(M)&&K!==O&&(I.toolPermissions[K.replace(M,"")]="ask")}),($=o.deny)==null||$.forEach(K=>{K.startsWith(M)&&K!==O&&(I.toolPermissions[K.replace(M,"")]="deny")}),I},[r,o]),y=C.useMemo(()=>{const M=new Set;return d.forEach(O=>M.add(O.name)),Object.keys(v.toolPermissions).forEach(O=>M.add(O)),Array.from(M).sort().map(O=>{const I=d.find(H=>H.name===O);return{name:O,description:(I==null?void 0:I.description)||"",discovered:!!I}})},[d,v.toolPermissions]),x=M=>{const O=`mcp__${r}__*`;u==null||u(r,O,M?"allow":"remove")},b=(M,O)=>{const I=`mcp__${r}__${M}`;v.toolPermissions[M]===O?u==null||u(r,I,"remove"):u==null||u(r,I,O)},j=()=>{const M=g.trim();if(!M)return;const O=`mcp__${r}__${M}`;u==null||u(r,O,"allow"),w("")},E=M=>{const O=`mcp__${r}__${M}`;u==null||u(r,O,"remove")},P=s!=null&&s.command?"stdio":s!=null&&s.url?"sse":"unknown";return n.jsx(Ho,{children:n.jsx(Bt,{open:e,onOpenChange:t,children:n.jsxs(Tt,{className:"sm:max-w-[550px] max-h-[85vh] flex flex-col",children:[n.jsxs(Rt,{children:[n.jsxs(Mt,{className:"flex items-center gap-2",children:[n.jsx(Oo,{className:"w-5 h-5 text-purple-600"}),"Configure ",r]}),n.jsxs(ar,{children:[P==="stdio"&&s.command&&n.jsxs("code",{className:"text-xs bg-gray-100 dark:bg-slate-800 px-2 py-1 rounded",children:[s.command," ",(T=s.args)==null?void 0:T.slice(0,2).join(" "),((N=s.args)==null?void 0:N.length)>2&&"..."]}),P==="sse"&&s.url&&n.jsx("code",{className:"text-xs bg-gray-100 dark:bg-slate-800 px-2 py-1 rounded",children:s.url})]})]}),n.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col space-y-4 py-4",children:[n.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:[n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx(Ps,{className:"w-5 h-5 text-green-600"}),n.jsxs("div",{children:[n.jsx(Ht,{className:"font-medium",children:"Allow all tools"}),n.jsx("p",{className:"text-xs text-gray-500 dark:text-slate-400",children:"Grant permission for all tools from this server"})]})]}),n.jsx(xt,{checked:v.allowAll,onCheckedChange:x})]}),v.allowAll&&n.jsxs(Wo,{children:[n.jsx(Xu,{className:"w-4 h-4"}),n.jsx(Vo,{className:"text-sm",children:"All tools are allowed. Individual tool settings below are informational only."})]}),n.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col space-y-3",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx(Ht,{className:"text-sm font-medium",children:"Available Tools"}),n.jsxs(le,{variant:"ghost",size:"sm",onClick:_,disabled:c,className:"h-7",children:[n.jsx(dr,{className:Ne("w-3 h-3 mr-1",c&&"animate-spin")}),"Refresh"]})]}),m&&n.jsxs(Wo,{variant:"destructive",children:[n.jsx(Oi,{className:"w-4 h-4"}),n.jsxs(Vo,{className:"text-sm",children:[m,n.jsx("p",{className:"text-xs mt-1 opacity-80",children:"You can still add tools manually below."})]})]}),c&&n.jsxs("div",{className:"flex items-center justify-center py-8",children:[n.jsx(dr,{className:"w-5 h-5 animate-spin text-gray-400"}),n.jsx("span",{className:"ml-2 text-sm text-gray-500",children:"Discovering tools..."})]}),!c&&n.jsx(jn,{className:"flex-1 min-h-0 rounded-md border border-gray-200 dark:border-slate-700",children:n.jsx("div",{className:"divide-y divide-gray-200 dark:divide-slate-700",children:y.length>0?y.map(M=>{const O=v.toolPermissions[M.name];return n.jsxs("div",{className:"flex items-center justify-between p-2 hover:bg-gray-50 dark:hover:bg-slate-800/50",children:[n.jsxs("div",{className:"flex-1 min-w-0 mr-2",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("code",{className:"text-sm font-mono truncate",children:M.name}),!M.discovered&&n.jsx(nt,{variant:"outline",className:"text-xs",children:"manual"})]}),M.description&&n.jsx("p",{className:"text-xs text-gray-500 dark:text-slate-400 truncate",children:M.description})]}),n.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[n.jsxs(on,{children:[n.jsx(an,{asChild:!0,children:n.jsx(le,{variant:O==="allow"?"default":"ghost",size:"sm",className:Ne("h-7 w-7 p-0",O==="allow"&&"bg-green-600 hover:bg-green-700"),onClick:()=>b(M.name,"allow"),children:n.jsx(Et,{className:"w-3 h-3"})})}),n.jsx(Gr,{children:"Allow"})]}),n.jsxs(on,{children:[n.jsx(an,{asChild:!0,children:n.jsx(le,{variant:O==="ask"?"default":"ghost",size:"sm",className:Ne("h-7 w-7 p-0",O==="ask"&&"bg-amber-600 hover:bg-amber-700"),onClick:()=>b(M.name,"ask"),children:"?"})}),n.jsx(Gr,{children:"Ask"})]}),n.jsxs(on,{children:[n.jsx(an,{asChild:!0,children:n.jsx(le,{variant:O==="deny"?"default":"ghost",size:"sm",className:Ne("h-7 w-7 p-0",O==="deny"&&"bg-red-600 hover:bg-red-700"),onClick:()=>b(M.name,"deny"),children:n.jsx(_s,{className:"w-3 h-3"})})}),n.jsx(Gr,{children:"Deny"})]}),!M.discovered&&O&&n.jsxs(on,{children:[n.jsx(an,{asChild:!0,children:n.jsx(le,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 text-gray-400 hover:text-red-600",onClick:()=>E(M.name),children:n.jsx(Fn,{className:"w-3 h-3"})})}),n.jsx(Gr,{children:"Remove"})]})]})]},M.name)}):n.jsxs("div",{className:"text-center py-8 text-gray-500 dark:text-slate-400",children:[n.jsx("p",{className:"text-sm",children:"No tools discovered"}),n.jsx("p",{className:"text-xs mt-1",children:"Add tools manually below"})]})})}),n.jsxs("div",{className:"flex gap-2 pt-2 border-t border-gray-200 dark:border-slate-700",children:[n.jsx(ut,{value:g,onChange:M=>w(M.target.value),placeholder:"Add tool manually...",className:"flex-1 text-sm",onKeyDown:M=>{M.key==="Enter"&&(M.preventDefault(),j())}}),n.jsx(le,{size:"sm",onClick:j,disabled:!g.trim(),children:n.jsx(_t,{className:"w-4 h-4"})})]})]}),n.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:[n.jsxs("span",{className:"flex items-center gap-1",children:[n.jsx("div",{className:"w-3 h-3 rounded bg-green-600"}),"Allow"]}),n.jsxs("span",{className:"flex items-center gap-1",children:[n.jsx("div",{className:"w-3 h-3 rounded bg-amber-600"}),"Ask"]}),n.jsxs("span",{className:"flex items-center gap-1",children:[n.jsx("div",{className:"w-3 h-3 rounded bg-red-600"}),"Deny"]}),n.jsx("span",{className:"flex items-center gap-1 ml-auto",children:n.jsx("span",{className:"text-gray-400",children:"Click again to remove"})})]})]}),n.jsx(Wt,{children:n.jsx(le,{variant:"outline",onClick:()=>t(!1),children:"Done"})})]})})})}function BF({mcpServers:e={},permissions:t={allow:[],ask:[],deny:[]},onToggle:r,onUpdatePermission:s,readOnly:o=!1}){const[u,d]=C.useState(!0),[l,c]=C.useState(!1),[f,m]=C.useState(null),h=C.useMemo(()=>Object.keys(e).sort(),[e]),g=v=>{var x;const y=`mcp__${v}__*`;return((x=t.allow)==null?void 0:x.includes(y))||!1},w=v=>{var j,E,P;const y=`mcp__${v}__`,x=`${y}*`;let b=0;return(j=t.allow)==null||j.forEach(T=>{T.startsWith(y)&&T!==x&&b++}),(E=t.ask)==null||E.forEach(T=>{T.startsWith(y)&&T!==x&&b++}),(P=t.deny)==null||P.forEach(T=>{T.startsWith(y)&&T!==x&&b++}),b},k=(v,y)=>{const x=`mcp__${v}__*`;r==null||r(v,x,y)},_=(v,y)=>{y.stopPropagation(),m(v),c(!0)};return h.length===0?null:n.jsxs(n.Fragment,{children:[n.jsxs(Ad,{open:u,onOpenChange:d,className:"mb-6",children:[n.jsx(Td,{asChild:!0,children:n.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:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("div",{className:"w-8 h-8 rounded-lg bg-purple-100 dark:bg-purple-950 flex items-center justify-center",children:n.jsx(Oo,{className:"w-4 h-4 text-purple-600 dark:text-purple-400"})}),n.jsxs("div",{className:"text-left",children:[n.jsx("span",{className:"font-medium text-gray-900 dark:text-white",children:"Quick MCP Permissions"}),n.jsxs(nt,{variant:"secondary",className:"ml-2 text-xs",children:[h.length," server",h.length!==1?"s":""]})]})]}),n.jsx(yr,{className:Ne("w-4 h-4 text-gray-500 transition-transform",u&&"rotate-180")})]})}),n.jsx(Rd,{children:n.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",j=w(v);return n.jsxs("div",{className:"flex items-center justify-between p-3 hover:bg-gray-50 dark:hover:bg-slate-800/50",children:[n.jsx("div",{className:"flex items-center gap-3 flex-1 min-w-0",children:n.jsxs("div",{className:"flex flex-col min-w-0",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("span",{className:"font-medium text-gray-900 dark:text-white",children:v}),y&&n.jsxs(nt,{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:[n.jsx(Et,{className:"w-3 h-3 mr-1"}),"All"]}),!y&&j>0&&n.jsxs(nt,{variant:"outline",className:"text-xs",children:[j," tool",j!==1?"s":""]})]}),n.jsxs("span",{className:"text-xs text-gray-500 dark:text-slate-400 truncate",children:[b==="stdio"&&x.command,b==="sse"&&x.url]})]})}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(le,{variant:"ghost",size:"sm",className:"h-8 px-2",onClick:E=>_(v,E),disabled:o,children:n.jsx(ju,{className:"w-4 h-4"})}),n.jsxs("div",{className:"flex items-center gap-2 pl-2 border-l border-gray-200 dark:border-slate-700",children:[n.jsx("span",{className:"text-xs text-gray-500 dark:text-slate-400 whitespace-nowrap",children:"Allow all"}),n.jsx(xt,{checked:y,onCheckedChange:E=>k(v,E),disabled:o})]})]})]},v)}),n.jsxs("div",{className:"p-3 bg-gray-50 dark:bg-slate-800/50 flex items-start gap-2",children:[n.jsx(Xu,{className:"w-4 h-4 text-gray-400 mt-0.5 flex-shrink-0"}),n.jsxs("p",{className:"text-xs text-gray-500 dark:text-slate-400",children:["Click ",n.jsx(ju,{className:"w-3 h-3 inline mx-0.5"})," to configure specific tool permissions"]})]})]})})]}),f&&n.jsx(OF,{open:l,onOpenChange:c,serverName:f,serverConfig:e[f],permissions:t,onUpdatePermissions:s})]})}function FF({permissions:e,onSave:t,loading:r,readOnly:s=!1,mcpServers:o={}}){const[u,d]=C.useState({allow:[],ask:[],deny:[]}),[l,c]=C.useState("allow"),[f,m]=C.useState(!1),[h,g]=C.useState(!1),[w,k]=C.useState(!1),[_,v]=C.useState(null),[y,x]=C.useState(!1),[b,j]=C.useState("export");C.useEffect(()=>{e&&d({allow:e.allow||[],ask:e.ask||[],deny:e.deny||[]})},[e]);const E=C.useCallback(async $=>{if(!(!t||s)){m(!0);try{await t($)}catch(K){Z.error("Failed to save: "+K.message)}finally{m(!1)}}},[t,s]),P=C.useCallback(($,K)=>{d(G=>{if([...G.allow,...G.ask,...G.deny].includes(K))return Z.error("This rule already exists"),G;const L={...G,[$]:[...G[$],K]};return E(L),Z.success(`Rule added to ${$}`),L})},[E]),T=C.useCallback(($,K,G,U)=>{d(L=>{const R={...L};return R[$]=R[$].filter(B=>B!==K),R[G]=[...R[G],U],E(R),Z.success("Rule updated"),R})},[E]),N=C.useCallback(($,K)=>{d(G=>{const U={...G,[$]:G[$].filter(L=>L!==K)};return E(U),Z.success("Rule deleted"),U})},[E]);C.useCallback(($,K,G)=>{d(U=>{const L={...U,[$]:U[$].filter(R=>R!==K),[G]:[...U[G],K]};return E(L),Z.success(`Moved to ${G}`),L})},[E]);const M=C.useCallback($=>{const K={allow:$.allow||[],ask:$.ask||[],deny:$.deny||[]};d(K),E(K),Z.success("Permissions imported")},[E]),O=C.useCallback(($,K,G)=>{G?P("allow",K):N("allow",K)},[P,N]),I=C.useCallback(($,K,G)=>{d(U=>{const L={allow:[...U.allow||[]],ask:[...U.ask||[]],deny:[...U.deny||[]]};return L.allow=L.allow.filter(R=>R!==K),L.ask=L.ask.filter(R=>R!==K),L.deny=L.deny.filter(R=>R!==K),G==="allow"?L.allow.push(K):G==="ask"?L.ask.push(K):G==="deny"&&L.deny.push(K),E(L),L})},[E]),H=$=>{v(null),c($),k(!0)},W=($,K)=>{v({category:$,rule:K}),k(!0)},Y=u.allow.length+u.ask.length+u.deny.length;return n.jsx(Ho,{children:n.jsxs("div",{className:"space-y-6",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx("div",{className:"w-10 h-10 rounded-lg bg-indigo-100 dark:bg-indigo-950 flex items-center justify-center",children:n.jsx(Ps,{className:"w-5 h-5 text-indigo-600 dark:text-indigo-400"})}),n.jsxs("div",{children:[n.jsx("h2",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:"Claude Code Permissions"}),n.jsx("p",{className:"text-sm text-gray-500 dark:text-slate-400",children:"Configure what Claude Code can do automatically"})]})]}),n.jsxs("div",{className:"flex items-center gap-2",children:[f&&n.jsxs(nt,{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:[n.jsx(dr,{className:"w-3 h-3 mr-1 animate-spin"}),"Saving..."]}),n.jsxs(on,{children:[n.jsx(an,{asChild:!0,children:n.jsx(le,{variant:"outline",size:"sm",onClick:()=>{j("export"),x(!0)},children:n.jsx(_l,{className:"w-4 h-4"})})}),n.jsx(Gr,{children:"Export permissions"})]}),n.jsxs(on,{children:[n.jsx(an,{asChild:!0,children:n.jsx(le,{variant:"outline",size:"sm",onClick:()=>{j("import"),x(!0)},disabled:s,children:n.jsx(Mm,{className:"w-4 h-4"})})}),n.jsx(Gr,{children:"Import permissions"})]})]})]}),n.jsxs(Ad,{open:h,onOpenChange:g,children:[n.jsx(Td,{asChild:!0,children:n.jsxs(le,{variant:"ghost",size:"sm",className:"text-gray-500 dark:text-slate-400",children:[n.jsx(al,{className:"w-4 h-4 mr-2"}),"How permissions work",n.jsx(yr,{className:Ne("w-4 h-4 ml-2 transition-transform",h&&"rotate-180")})]})}),n.jsx(Rd,{children:n.jsxs(Wo,{className:"mt-2",children:[n.jsx(Xu,{className:"w-4 h-4"}),n.jsxs(Vo,{className:"text-sm",children:[n.jsxs("p",{className:"mb-2",children:["Permissions control what Claude Code can do automatically vs. what requires your approval. These settings are stored in ",n.jsx("code",{className:"px-1 py-0.5 bg-gray-100 dark:bg-slate-700 rounded text-xs",children:"~/.claude/settings.json"}),"."]}),n.jsxs("div",{className:"grid grid-cols-3 gap-4 mt-3",children:[n.jsxs("div",{children:[n.jsx(nt,{className:"bg-green-100 dark:bg-green-950 text-green-700 dark:text-green-400 mb-1",children:"Allow"}),n.jsx("p",{className:"text-xs text-gray-600 dark:text-slate-400",children:"Operations run without asking"})]}),n.jsxs("div",{children:[n.jsx(nt,{className:"bg-amber-100 dark:bg-amber-950 text-amber-700 dark:text-amber-400 mb-1",children:"Ask"}),n.jsx("p",{className:"text-xs text-gray-600 dark:text-slate-400",children:"Prompts for confirmation each time"})]}),n.jsxs("div",{children:[n.jsx(nt,{className:"bg-red-100 dark:bg-red-950 text-red-700 dark:text-red-400 mb-1",children:"Deny"}),n.jsx("p",{className:"text-xs text-gray-600 dark:text-slate-400",children:"Blocked entirely"})]})]}),n.jsxs("p",{className:"mt-3 text-xs text-gray-500 dark:text-slate-400",children:["Use wildcards: ",n.jsx("code",{className:"px-1 py-0.5 bg-gray-100 dark:bg-slate-700 rounded",children:"*"})," matches anything,"," ",n.jsx("code",{className:"px-1 py-0.5 bg-gray-100 dark:bg-slate-700 rounded",children:"**"})," matches recursively in paths."]})]})]})})]}),!r&&Object.keys(o).length>0&&n.jsx(BF,{mcpServers:o,permissions:u,onToggle:O,onUpdatePermission:I,readOnly:s}),r&&n.jsx("div",{className:"flex items-center justify-center py-12",children:n.jsx(dr,{className:"w-6 h-6 animate-spin text-gray-400"})}),!r&&Y===0&&n.jsxs(Wo,{children:[n.jsx(Ju,{className:"w-4 h-4"}),n.jsxs(Vo,{children:["No permission rules configured. Claude Code will use default behavior and ask for permission on sensitive operations.",n.jsx(le,{variant:"link",size:"sm",className:"ml-2 p-0 h-auto",onClick:()=>H("allow"),children:"Add your first rule"})]})]}),!r&&n.jsxs(jd,{value:l,onValueChange:c,children:[n.jsx(Ml,{className:"grid w-full grid-cols-3",children:["allow","ask","deny"].map($=>{var U;const K=qb($),G=((U=u[$])==null?void 0:U.length)||0;return n.jsxs(On,{value:$,className:"flex items-center gap-2",children:[n.jsx("div",{className:Ne("w-2 h-2 rounded-full",$==="allow"&&"bg-green-500",$==="ask"&&"bg-amber-500",$==="deny"&&"bg-red-500")}),K.label,G>0&&n.jsx(nt,{variant:"secondary",className:"ml-1 text-xs",children:G})]},$)})}),["allow","ask","deny"].map($=>{const K=qb($),G=u[$]||[],U=PF(G);return n.jsxs(ys,{value:$,className:"space-y-3",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs(on,{children:[n.jsx(an,{asChild:!0,children:n.jsx("p",{className:"text-sm text-gray-500 dark:text-slate-400 cursor-help",children:K.description})}),n.jsx(Gr,{className:"max-w-xs",children:NF($)})]}),n.jsxs(le,{size:"sm",variant:"outline",onClick:()=>H($),disabled:s,children:[n.jsx(_t,{className:"w-4 h-4 mr-1"}),"Add Rules"]})]}),G.length===0?n.jsxs("div",{className:Ne("text-center py-8 rounded-lg border-2 border-dashed",K.borderColor),children:[n.jsxs("p",{className:"text-gray-500 dark:text-slate-400",children:["No rules in ",$]}),n.jsx(le,{variant:"link",size:"sm",onClick:()=>H($),disabled:s,children:"Add rules"})]}):n.jsx("div",{className:"space-y-2",children:U.map(({type:L,rules:R})=>n.jsx(TF,{type:L,rules:R,category:$,onEdit:B=>W($,B),onDelete:B=>N($,B),onAddRule:()=>H($),readOnly:s},L))})]},$)})]}),n.jsx(RF,{open:w,onOpenChange:k,onSubmit:($,K)=>{_?T(_.category,_.rule,$,K):P($,K)},defaultCategory:(_==null?void 0:_.category)||l,defaultRule:(_==null?void 0:_.rule)||"",isEditing:!!_,existingRules:[...u.allow,...u.ask,...u.deny]}),n.jsx(IF,{open:y,onOpenChange:x,mode:b,permissions:u,onImport:M})]})})}const $F=[{id:"claude-sonnet-4-20250514",name:"Claude Sonnet 4",description:"Best balance of speed and capability",tier:"sonnet",recommended:!0},{id:"claude-opus-4-5-20251101",name:"Claude Opus 4.5",description:"Most capable, best for complex tasks",tier:"opus"},{id:"claude-haiku-4-5-20251001",name:"Claude Haiku 4.5",description:"Fastest, best for simple tasks",tier:"haiku"}],zF=[{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-20241022"}];function Aj({settings:e,onSave:t,loading:r,settingsPath:s="~/.claude/settings.json",mcpServers:o={}}){const[u,d]=C.useState({}),[l,c]=C.useState("permissions"),[f,m]=C.useState(!1),[h,g]=C.useState(!1),[w,k]=C.useState(""),[_,v]=C.useState(null),y=C.useRef(null);C.useEffect(()=>{e&&(d(e),k(JSON.stringify(e,null,2)))},[e]),C.useEffect(()=>{h||k(JSON.stringify(u,null,2))},[u,h]);const x=C.useCallback(async N=>{if(t){m(!0);try{await t(N)}catch(M){Z.error("Failed to save: "+M.message)}finally{m(!1)}}},[t]),b=C.useCallback(N=>{y.current&&clearTimeout(y.current),y.current=setTimeout(()=>{x(N)},800)},[x]),j=C.useCallback((N,M,O=!1)=>{d(I=>{const H={...I,[N]:M};return(M===""||M===null||M===void 0)&&delete H[N],O?x(H):b(H),H})},[x,b]),E=C.useCallback(async N=>{const M={...u,permissions:N};d(M),await x(M)},[u,x]),P=N=>{k(N);try{JSON.parse(N),v(null)}catch(M){v(M.message)}},T=async()=>{if(_){Z.error("Fix JSON errors before saving");return}try{const N=JSON.parse(w);d(N),await x(N),Z.success("Settings applied")}catch{Z.error("Invalid JSON")}};return n.jsxs("div",{className:"space-y-6",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx("div",{className:"w-10 h-10 rounded-lg bg-indigo-100 dark:bg-indigo-950 flex items-center justify-center",children:n.jsx(Bn,{className:"w-5 h-5 text-indigo-600 dark:text-indigo-400"})}),n.jsxs("div",{children:[n.jsx("h2",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:"Claude Code Settings"}),n.jsx("p",{className:"text-sm text-gray-500 dark:text-slate-400",children:"Configure Claude Code behavior globally"})]})]}),n.jsxs("div",{className:"flex items-center gap-2",children:[f&&n.jsxs(nt,{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:[n.jsx(dr,{className:"w-3 h-3 mr-1 animate-spin"}),"Saving..."]}),n.jsx(Ho,{children:n.jsxs(on,{children:[n.jsx(an,{asChild:!0,children:n.jsx(le,{variant:"outline",size:"sm",onClick:()=>g(!h),children:h?n.jsx(_1,{className:"w-4 h-4"}):n.jsx(_5,{className:"w-4 h-4"})})}),n.jsx(Gr,{children:h?"Show UI":"Show JSON"})]})})]})]}),n.jsxs("p",{className:"text-sm text-gray-500 dark:text-slate-400",children:["Settings file: ",n.jsx("code",{className:"bg-gray-100 dark:bg-slate-800 px-2 py-0.5 rounded text-xs",children:s})]}),r&&n.jsx("div",{className:"flex items-center justify-center py-12",children:n.jsx(dr,{className:"w-6 h-6 animate-spin text-gray-400"})}),!r&&h&&n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx(Ht,{children:"Raw JSON"}),n.jsxs("div",{className:"flex items-center gap-2",children:[_&&n.jsx(nt,{variant:"destructive",className:"text-xs",children:_}),n.jsxs(le,{size:"sm",onClick:T,disabled:f||!!_,className:"bg-indigo-600 hover:bg-indigo-700 text-white",children:[n.jsx(Et,{className:"w-4 h-4 mr-1"}),"Apply JSON"]})]})]}),n.jsx(vt,{value:w,onChange:N=>P(N.target.value),className:Ne("font-mono text-sm min-h-[400px]",_&&"border-red-300 focus:border-red-500")})]}),!r&&!h&&n.jsxs(jd,{value:l,onValueChange:c,children:[n.jsxs(Ml,{className:"grid w-full grid-cols-4",children:[n.jsxs(On,{value:"permissions",className:"flex items-center gap-2",children:[n.jsx(Ps,{className:"w-4 h-4"}),"Permissions"]}),n.jsxs(On,{value:"model",className:"flex items-center gap-2",children:[n.jsx(Qu,{className:"w-4 h-4"}),"Model"]}),n.jsxs(On,{value:"behavior",className:"flex items-center gap-2",children:[n.jsx(Bn,{className:"w-4 h-4"}),"Behavior"]}),n.jsxs(On,{value:"advanced",className:"flex items-center gap-2",children:[n.jsx(Jt,{className:"w-4 h-4"}),"Advanced"]})]}),n.jsx(ys,{value:"permissions",className:"pt-4",children:n.jsx(FF,{permissions:u.permissions,onSave:E,loading:!1,mcpServers:o})}),n.jsx(ys,{value:"model",className:"space-y-6 pt-4",children:n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{children:[n.jsx(Ht,{className:"text-base font-medium",children:"Default Model"}),n.jsx("p",{className:"text-sm text-gray-500 dark:text-slate-400 mb-3",children:"Select the default model for Claude Code sessions"}),n.jsx("div",{className:"grid gap-3",children:$F.map(N=>n.jsx("button",{onClick:()=>j("model",N.id,!0),className:Ne("w-full p-4 rounded-lg border text-left transition-all",u.model===N.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:n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("span",{className:"font-medium",children:N.name}),N.recommended&&n.jsx(nt,{variant:"secondary",className:"text-xs",children:"Recommended"}),n.jsx(nt,{variant:"outline",className:Ne("text-xs",N.tier==="opus"&&"border-purple-300 text-purple-700",N.tier==="sonnet"&&"border-blue-300 text-blue-700",N.tier==="haiku"&&"border-green-300 text-green-700"),children:N.tier})]}),n.jsx("p",{className:"text-sm text-gray-500 dark:text-slate-400 mt-1",children:N.description})]}),u.model===N.id&&n.jsx(Et,{className:"w-5 h-5 text-indigo-600 dark:text-indigo-400"})]})},N.id))})]}),n.jsxs("div",{children:[n.jsx(Ht,{children:"Custom Model ID"}),n.jsx("p",{className:"text-xs text-gray-500 dark:text-slate-400 mb-2",children:"Override with a specific model ID (for AWS Bedrock, etc.)"}),n.jsx(ut,{value:u.model||"",onChange:N=>j("model",N.target.value),placeholder:"claude-sonnet-4-20250514",className:"font-mono"})]})]})}),n.jsx(ys,{value:"behavior",className:"space-y-6 pt-4",children:n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{className:"flex items-center justify-between p-4 rounded-lg border border-gray-200 dark:border-slate-700",children:[n.jsxs("div",{children:[n.jsx(Ht,{children:"Auto-accept Edits"}),n.jsx("p",{className:"text-sm text-gray-500 dark:text-slate-400",children:"Automatically accept file edits without confirmation"})]}),n.jsx(xt,{checked:u.autoAcceptEdits??!1,onCheckedChange:N=>j("autoAcceptEdits",N,!0)})]}),n.jsxs("div",{className:"flex items-center justify-between p-4 rounded-lg border border-gray-200 dark:border-slate-700",children:[n.jsxs("div",{children:[n.jsx(Ht,{children:"Verbose Output"}),n.jsx("p",{className:"text-sm text-gray-500 dark:text-slate-400",children:"Show detailed output for operations"})]}),n.jsx(xt,{checked:u.verbose??!1,onCheckedChange:N=>j("verbose",N,!0)})]}),n.jsxs("div",{className:"flex items-center justify-between p-4 rounded-lg border border-gray-200 dark:border-slate-700",children:[n.jsxs("div",{children:[n.jsx(Ht,{children:"Enable MCP Servers"}),n.jsx("p",{className:"text-sm text-gray-500 dark:text-slate-400",children:"Allow Claude Code to use MCP server connections"})]}),n.jsx(xt,{checked:u.enableMcp??!0,onCheckedChange:N=>j("enableMcp",N,!0)})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(Ht,{children:"API Base URL"}),n.jsx("p",{className:"text-xs text-gray-500 dark:text-slate-400",children:"Custom API endpoint (for proxies or enterprise deployments)"}),n.jsx(ut,{value:u.apiBaseUrl||"",onChange:N=>j("apiBaseUrl",N.target.value),placeholder:"https://api.anthropic.com",className:"font-mono"})]})]})}),n.jsxs(ys,{value:"advanced",className:"space-y-6 pt-4",children:[n.jsxs(Wo,{children:[n.jsx(Ju,{className:"w-4 h-4"}),n.jsx(Vo,{children:"Advanced settings for power users. Incorrect values may cause Claude Code to malfunction."})]}),n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{children:[n.jsx(Ht,{className:"text-base font-medium",children:"Environment Variables"}),n.jsx("p",{className:"text-sm text-gray-500 dark:text-slate-400 mb-3",children:"Configure model-related environment variables"}),n.jsx("div",{className:"space-y-3",children:zF.map(N=>{var M;return n.jsxs("div",{className:"space-y-1",children:[n.jsx(Ht,{className:"text-sm",children:N.label}),n.jsx("p",{className:"text-xs text-gray-500 dark:text-slate-400",children:N.description}),n.jsx(ut,{value:((M=u.env)==null?void 0:M[N.key])||"",onChange:O=>{const I={...u.env||{},[N.key]:O.target.value};O.target.value||delete I[N.key],j("env",Object.keys(I).length?I:void 0)},placeholder:N.placeholder,className:"font-mono text-sm"})]},N.key)})})]}),n.jsxs("div",{children:[n.jsx(Ht,{className:"text-base font-medium",children:"Hooks"}),n.jsx("p",{className:"text-sm text-gray-500 dark:text-slate-400 mb-3",children:"Scripts to run before/after tool executions (JSON format)"}),n.jsx(vt,{value:u.hooks?JSON.stringify(u.hooks,null,2):"",onChange:N=>{try{const M=N.target.value?JSON.parse(N.target.value):void 0;j("hooks",M)}catch{}},placeholder:`{
567
567
  "preToolExecution": "~/.claude/hooks/pre.sh",
568
568
  "postToolExecution": "~/.claude/hooks/post.sh"
569
569
  }`,className:"font-mono text-sm min-h-[120px]"})]}),n.jsxs("div",{children:[n.jsx(Ht,{className:"text-base font-medium",children:"Custom Settings"}),n.jsx("p",{className:"text-sm text-gray-500 dark:text-slate-400 mb-3",children:"Add any additional settings as JSON key-value pairs"}),n.jsx(vt,{value:(()=>{const N=["permissions","model","autoAcceptEdits","verbose","enableMcp","apiBaseUrl","env","hooks"],M=Object.keys(u).filter(O=>!N.includes(O)).reduce((O,I)=>({...O,[I]:u[I]}),{});return Object.keys(M).length?JSON.stringify(M,null,2):""})(),onChange:N=>{try{const M=N.target.value?JSON.parse(N.target.value):{},I=["permissions","model","autoAcceptEdits","verbose","enableMcp","apiBaseUrl","env","hooks"].reduce((H,W)=>(u[W]!==void 0&&(H[W]=u[W]),H),{});d({...I,...M}),setHasChanges(!0)}catch{}},placeholder:`{
@@ -631,44 +631,52 @@ ${x.description}`;break;case"history":case"context":default:if(!x.content.trim()
631
631
  This won't delete any files.`))try{const v=await we.removeProject(_.id);v.success?(r(y=>y.filter(x=>x.id!==_.id)),Z.success(`Removed project: ${_.name}`)):Z.error(v.error||"Failed to remove project")}catch(v){Z.error("Failed to remove project: "+v.message)}},k=_=>{r(v=>[...v,{..._,exists:!0,hasClaudeConfig:!1}])};return u?n.jsx("div",{className:"flex items-center justify-center h-64",children:n.jsx(dt,{className:"w-8 h-8 animate-spin text-indigo-600"})}):n.jsxs("div",{className:"space-y-6",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx("div",{className:"w-10 h-10 rounded-lg bg-indigo-100 dark:bg-indigo-900/30 flex items-center justify-center",children:n.jsx(ai,{className:"w-5 h-5 text-indigo-600 dark:text-indigo-400"})}),n.jsxs("div",{children:[n.jsx("h2",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:"Projects"}),n.jsx("p",{className:"text-sm text-gray-500 dark:text-slate-400",children:"Registered projects for quick switching"})]})]}),n.jsxs("div",{className:"flex gap-2",children:[n.jsxs(le,{variant:"outline",onClick:h,size:"sm",children:[n.jsx(dr,{className:"w-4 h-4 mr-2"}),"Refresh"]}),n.jsxs(le,{onClick:()=>m(!0),className:"bg-indigo-600 hover:bg-indigo-700",children:[n.jsx(_t,{className:"w-4 h-4 mr-2"}),"Add Project"]})]})]}),n.jsx("div",{className:"bg-blue-50 dark:bg-blue-950/30 border border-blue-200 dark:border-blue-800 rounded-lg p-4 text-sm text-blue-700 dark:text-blue-400",children:n.jsx("p",{children:"Projects registered here can be quickly switched in the header dropdown. The UI will update to show the selected project's configuration."})}),n.jsx("div",{className:"bg-white dark:bg-slate-950 rounded-xl border border-gray-200 dark:border-slate-800 shadow-sm overflow-hidden",children:t.length===0?n.jsxs("div",{className:"p-12 text-center",children:[n.jsx(gr,{className:"w-12 h-12 mx-auto mb-4 text-gray-300 dark:text-slate-600"}),n.jsx("h3",{className:"text-lg font-medium text-gray-900 dark:text-white mb-2",children:"No Projects Yet"}),n.jsx("p",{className:"text-sm text-gray-500 dark:text-slate-400 mb-4",children:"Add your first project to get started with quick switching."}),n.jsxs(le,{onClick:()=>m(!0),children:[n.jsx(_t,{className:"w-4 h-4 mr-2"}),"Add Your First Project"]})]}):n.jsx("div",{className:"divide-y divide-gray-100 dark:divide-slate-800",children:t.map(_=>n.jsxs("div",{className:`p-4 flex items-center gap-4 transition-colors ${_.isActive?"bg-indigo-50 dark:bg-indigo-950/30":"hover:bg-gray-50 dark:hover:bg-slate-900"}`,children:[n.jsx("div",{className:`w-10 h-10 rounded-lg flex items-center justify-center ${_.isActive?"bg-indigo-100 dark:bg-indigo-900/50":_.exists?"bg-gray-100 dark:bg-slate-800":"bg-amber-100 dark:bg-amber-900/30"}`,children:_.isActive?n.jsx(Et,{className:"w-5 h-5 text-indigo-600 dark:text-indigo-400"}):_.exists?n.jsx(gr,{className:"w-5 h-5 text-gray-500 dark:text-slate-400"}):n.jsx(Ju,{className:"w-5 h-5 text-amber-600 dark:text-amber-400"})}),n.jsxs("div",{className:"flex-1 min-w-0",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("h3",{className:`font-medium truncate ${_.isActive?"text-indigo-700 dark:text-indigo-400":"text-gray-900 dark:text-white"}`,children:_.name}),_.hasClaudeConfig&&n.jsx("span",{className:"text-xs bg-green-100 dark:bg-green-900/30 text-green-700 dark:text-green-400 px-1.5 py-0.5 rounded",children:".claude"}),_.isActive&&n.jsx("span",{className:"text-xs bg-indigo-100 dark:bg-indigo-900/50 text-indigo-700 dark:text-indigo-400 px-1.5 py-0.5 rounded",children:"Active"})]}),n.jsx("p",{className:"text-sm text-gray-500 dark:text-slate-400 font-mono truncate",children:_.path.replace(/^\/Users\/[^/]+/,"~")}),!_.exists&&n.jsx("p",{className:"text-xs text-amber-600 dark:text-amber-400 mt-1",children:"Path not found - the directory may have been moved or deleted"})]}),n.jsxs("div",{className:"flex items-center gap-2",children:[!_.isActive&&_.exists&&n.jsx(le,{size:"sm",onClick:()=>g(_.id),disabled:l===_.id,children:l===_.id?n.jsx(dt,{className:"w-4 h-4 animate-spin"}):"Select"}),n.jsx(le,{size:"sm",variant:"ghost",onClick:()=>w(_),className:"text-gray-500 dark:text-slate-400 hover:text-red-600 dark:hover:text-red-400",title:"Remove from registry",children:n.jsx(Fn,{className:"w-4 h-4"})})]})]},_.id))})}),n.jsxs("div",{className:"bg-gray-50 dark:bg-slate-900 rounded-lg p-4 border border-transparent dark:border-slate-800",children:[n.jsx("h4",{className:"text-sm font-medium text-gray-900 dark:text-white mb-2",children:"CLI Commands"}),n.jsxs("div",{className:"space-y-1 text-sm text-gray-600 dark:text-slate-400 font-mono",children:[n.jsx("p",{children:"claude-config project add [path] # Add project"}),n.jsx("p",{children:"claude-config project remove <name> # Remove project"}),n.jsx("p",{children:"claude-config project # List projects"})]})]}),n.jsx(Rj,{open:f,onOpenChange:m,onAdded:k})]})}const lH=[{id:"getting-started",title:"Getting Started",icon:Li,subsections:[{id:"installation",title:"Installation"},{id:"quick-start",title:"Quick Start"},{id:"updating",title:"Updating"}]},{id:"projects",title:"Project Management",icon:ri,subsections:[{id:"project-registry",title:"Project Registry"},{id:"project-switching",title:"Switching Projects"},{id:"project-structure",title:"Project Structure"}]},{id:"file-explorer",title:"Project Explorer",icon:gr,subsections:[{id:"claude-folders",title:".claude Folders"},{id:"rules",title:"Rules"},{id:"commands",title:"Commands"},{id:"workflows",title:"Workflows"},{id:"hierarchy",title:"Configuration Hierarchy"},{id:"subprojects",title:"Sub-Projects"}]},{id:"workstreams",title:"Workstreams",icon:ri,isNew:!0,subsections:[{id:"workstreams-overview",title:"Overview"},{id:"creating-workstreams",title:"Creating Workstreams"},{id:"workstream-hooks",title:"Hook Integration"},{id:"activity-tracking",title:"Activity Tracking"},{id:"smart-sync",title:"Smart Sync"}]},{id:"plugins",title:"Plugins",icon:ns,isNew:!0,subsections:[{id:"plugins-overview",title:"Overview"},{id:"installing-plugins",title:"Installing Plugins"},{id:"plugin-marketplaces",title:"Marketplaces"}]},{id:"mcp-registry",title:"MCP Registry",icon:ns,subsections:[{id:"mcp-overview",title:"Overview"},{id:"adding-mcps",title:"Adding MCPs"},{id:"configuring-mcps",title:"Configuring MCPs"},{id:"environment-vars",title:"Environment Variables"}]},{id:"memory",title:"Memory System",icon:Ii,subsections:[{id:"memory-overview",title:"Overview"},{id:"global-memory",title:"Global Memory"},{id:"project-memory",title:"Project Memory"},{id:"memory-entries",title:"Memory Entry Types"}]},{id:"claude-settings",title:"Claude Code Settings",icon:Ps,subsections:[{id:"permissions",title:"Permissions"},{id:"model-selection",title:"Model Selection"},{id:"behavior",title:"Behavior Settings"},{id:"hooks",title:"Hooks"}]},{id:"gemini-settings",title:"Gemini CLI Settings",icon:Jt,isNew:!0,subsections:[{id:"gemini-model",title:"Model Selection"},{id:"gemini-display",title:"Display Options"},{id:"gemini-general",title:"General Settings"},{id:"gemini-sandbox",title:"Sandbox Mode"}]},{id:"antigravity-settings",title:"Antigravity Settings",icon:Sl,isNew:!0,subsections:[{id:"antigravity-security",title:"Security Policies"},{id:"antigravity-mcp",title:"MCP Servers"},{id:"antigravity-browser",title:"Browser Allowlist"},{id:"antigravity-agent",title:"Agent Mode"}]},{id:"cli",title:"CLI Reference",icon:Jt,subsections:[{id:"cli-overview",title:"Overview"},{id:"cli-commands",title:"All Commands"},{id:"daemon-mode",title:"Daemon Mode"}]},{id:"multi-tool",title:"Multi-Tool Support",icon:Gt,subsections:[{id:"supported-tools",title:"Supported Tools"},{id:"gemini-cli",title:"Gemini CLI"},{id:"antigravity",title:"Antigravity"},{id:"tool-differences",title:"Tool Differences"},{id:"enabling-tools",title:"Enabling Tools"},{id:"syncing-rules",title:"Syncing Rules"}]},{id:"keyboard",title:"Keyboard Shortcuts",icon:eM,subsections:[]},{id:"troubleshooting",title:"Troubleshooting",icon:al,subsections:[{id:"common-issues",title:"Common Issues"},{id:"getting-help",title:"Getting Help"}]}],cH={installation:{title:"Installation",content:`
632
632
  ## Installation
633
633
 
634
- Install claude-config globally via npm:
634
+ Choose your preferred installation method:
635
635
 
636
- \`\`\`bash
637
- npm install -g @regression-io/claude-config
638
- \`\`\`
636
+ ### Option A: Desktop App (Recommended)
639
637
 
640
- Or install from GitHub directly:
638
+ Download the native app from [GitHub Releases](https://github.com/regression-io/claude-config/releases):
641
639
 
642
- \`\`\`bash
643
- npm install -g github:regression-io/claude-config
644
- \`\`\`
640
+ | Platform | Download |
641
+ |----------|----------|
642
+ | **macOS (Apple Silicon)** | \`Claude.Config_*_aarch64.dmg\` |
643
+ | **macOS (Intel)** | \`Claude.Config_*_x64.dmg\` |
644
+ | **Windows** | \`Claude.Config_*_x64-setup.exe\` |
645
+ | **Linux** | \`Claude.Config_*_amd64.deb\` or \`.AppImage\` |
645
646
 
646
- ### Requirements
647
+ The desktop app bundles everything - no Node.js or npm required. Just download, install, and run.
647
648
 
648
- - **Node.js 18+** is required
649
- - Works on macOS, Linux, and Windows (with some limitations)
649
+ ### Option B: npm Package (CLI)
650
650
 
651
- ### Verify Installation
651
+ Install globally via npm:
652
652
 
653
- After installation, verify it's working:
653
+ \`\`\`bash
654
+ npm install -g @regression-io/claude-config
655
+ \`\`\`
656
+
657
+ **Requirements:** Node.js 18+
658
+
659
+ Verify installation:
654
660
 
655
661
  \`\`\`bash
656
662
  claude-config --version
657
663
  \`\`\`
658
664
 
659
- This should display the version number and installation paths.
665
+ Then start the UI:
666
+
667
+ \`\`\`bash
668
+ claude-config ui
669
+ \`\`\`
660
670
  `},"quick-start":{title:"Quick Start",content:`
661
671
  ## Quick Start
662
672
 
663
673
  Claude Code works great out of the box. This tool helps you manage its configuration visually.
664
674
 
665
- ### 1. Start the Config UI
675
+ ### 1. Launch Claude Config
666
676
 
667
- \`\`\`bash
668
- claude-config ui
669
- \`\`\`
677
+ **Desktop App:** Double-click the app after installing from GitHub Releases.
670
678
 
671
- This opens a web UI for managing Claude Code settings.
679
+ **CLI:** Run \`claude-config ui\` in your terminal.
672
680
 
673
681
  ### 2. Add Your Projects
674
682
 
@@ -692,25 +700,27 @@ claude
692
700
 
693
701
  Claude Code automatically reads configuration from the \`.claude/\` folder.
694
702
 
695
- ### Optional: Install as App
703
+ ### Optional: Install as PWA
696
704
 
697
- The UI is a PWA - install it to your taskbar via Chrome/Edge's install button or Safari's Share → Add to Dock.
705
+ Using the CLI version? The UI is a PWA - install it to your taskbar via Chrome/Edge's install button or Safari's Share → Add to Dock.
698
706
  `},updating:{title:"Updating",content:`
699
707
  ## Updating
700
708
 
701
- ### Automatic Update Detection
709
+ ### Desktop App
710
+
711
+ Download the latest version from [GitHub Releases](https://github.com/regression-io/claude-config/releases) and install over your existing installation.
712
+
713
+ ### npm Package
702
714
 
703
715
  The UI automatically checks npm for new versions. When an update is available, you'll see a notification in the Preferences page.
704
716
 
705
- ### Manual Update
717
+ **Manual update:**
706
718
 
707
719
  \`\`\`bash
708
720
  npm install -g @regression-io/claude-config@latest
709
721
  \`\`\`
710
722
 
711
- ### After Updating
712
-
713
- If you have the UI running as a daemon, restart it:
723
+ **After updating (if using daemon mode):**
714
724
 
715
725
  \`\`\`bash
716
726
  claude-config ui stop
@@ -2383,6 +2393,14 @@ This cannot be undone.`))try{const Le=await we.deleteWorkstream(re.id);Le.succes
2383
2393
  Defaulting to \`null\`.`}var z2=O2,OH=F2;const H2=C.forwardRef(({className:e,value:t,...r},s)=>n.jsx(z2,{ref:s,className:Ne("relative h-2 w-full overflow-hidden rounded-full bg-primary/20",e),...r,children:n.jsx(OH,{className:"h-full w-full flex-1 bg-primary transition-all",style:{transform:`translateX(-${100-(t||0)}%)`}})}));H2.displayName=z2.displayName;const Ha=[{id:"welcome",title:"Welcome",icon:Gt,subsections:[{id:"intro",title:"What is Claude Config?"},{id:"what-youll-learn",title:"What You'll Learn"}]},{id:"first-project",title:"Your First Project",icon:ni,subsections:[{id:"adding-project",title:"Adding a Project"},{id:"exploring-project",title:"Exploring Your Project"},{id:"claude-folder",title:"The .claude Folder"}]},{id:"rules-guide",title:"Working with Rules",icon:br,subsections:[{id:"what-are-rules",title:"What Are Rules?"},{id:"creating-rules",title:"Creating Your First Rule"},{id:"rule-tips",title:"Tips for Great Rules"}]},{id:"mcp-guide",title:"MCP Servers",icon:ns,subsections:[{id:"what-are-mcps",title:"What Are MCPs?"},{id:"adding-mcp",title:"Adding Your First MCP"},{id:"mcp-config",title:"Configuring MCPs"}]},{id:"permissions-guide",title:"Permissions",icon:Ps,subsections:[{id:"understanding-permissions",title:"How Permissions Work"},{id:"setting-permissions",title:"Setting Up Permissions"},{id:"permission-patterns",title:"Permission Patterns"}]},{id:"memory-guide",title:"Memory System",icon:Ii,subsections:[{id:"what-is-memory",title:"What is Memory?"},{id:"using-memory",title:"Using Memory"}]},{id:"plugins-guide",title:"Plugins",icon:Fi,subsections:[{id:"what-are-plugins",title:"What Are Plugins?"},{id:"installing-plugin",title:"Installing a Plugin"}]},{id:"workstreams-guide",title:"Workstreams",icon:Qa,subsections:[{id:"what-are-workstreams",title:"What Are Workstreams?"},{id:"creating-workstream",title:"Creating a Workstream"}]},{id:"multi-tool-guide",title:"Multi-Tool Support",icon:Qn,subsections:[{id:"other-tools",title:"Beyond Claude Code"},{id:"syncing-tools",title:"Syncing Between Tools"}]},{id:"next-steps",title:"Next Steps",icon:Sl,subsections:[]}],BH={intro:{title:"What is Claude Config?",content:`
2384
2394
  Think of Claude Config as your **control center** for Claude Code (and other AI coding tools). Instead of manually editing JSON files or remembering command-line flags, you get a friendly UI to manage everything.
2385
2395
 
2396
+ ### How are you using Claude Config?
2397
+
2398
+ **Desktop App** - Downloaded from [GitHub Releases](https://github.com/regression-io/claude-config/releases). No terminal needed!
2399
+
2400
+ **npm Package** - Installed via \`npm install -g @regression-io/claude-config\` and running \`claude-config ui\`.
2401
+
2402
+ Both work identically - this tutorial applies to either.
2403
+
2386
2404
  ### What can you do here?
2387
2405
 
2388
2406
  - **Register projects** you're working on
@@ -3217,7 +3235,7 @@ Click **"Create MCP"** to build your own MCP server. Great for connecting Claude
3217
3235
  - \`Cmd/Ctrl + ,\` - Open preferences
3218
3236
  - \`Cmd/Ctrl + R\` - Refresh
3219
3237
 
3220
- **Useful CLI Commands**
3238
+ **For CLI Users**
3221
3239
  \`\`\`bash
3222
3240
  claude-config ui # Start the UI
3223
3241
  claude-config ui stop # Stop the daemon
@@ -3225,6 +3243,8 @@ claude-config apply # Apply config to current project
3225
3243
  claude-config --help # See all commands
3226
3244
  \`\`\`
3227
3245
 
3246
+ *Desktop app users: These commands are optional - the app handles everything automatically.*
3247
+
3228
3248
  ### Thank You!
3229
3249
 
3230
3250
  Thanks for using Claude Config. We built this to make working with AI coding tools easier and more powerful.
@@ -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-DTADVG7R.js"></script>
22
+ <script type="module" crossorigin src="/assets/index-CMz5cwWK.js"></script>
23
23
  <link rel="stylesheet" crossorigin href="/assets/index-1RcqzPnS.css">
24
24
  </head>
25
25
  <body>