@kaitranntt/ccs 7.20.1 → 7.21.0-dev.1

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.
Files changed (46) hide show
  1. package/README.md +1 -1
  2. package/dist/cliproxy/account-manager.d.ts +3 -1
  3. package/dist/cliproxy/account-manager.d.ts.map +1 -1
  4. package/dist/cliproxy/account-manager.js +33 -4
  5. package/dist/cliproxy/account-manager.js.map +1 -1
  6. package/dist/cliproxy/auth/token-manager.d.ts.map +1 -1
  7. package/dist/cliproxy/auth/token-manager.js +2 -1
  8. package/dist/cliproxy/auth/token-manager.js.map +1 -1
  9. package/dist/commands/api-command.js +2 -2
  10. package/dist/commands/api-command.js.map +1 -1
  11. package/dist/ui/assets/{accounts-Be6b-nwn.js → accounts-BUcnX5Y0.js} +1 -1
  12. package/dist/ui/assets/{alert-dialog-CM5u0JHs.js → alert-dialog-Bg5o3Alj.js} +1 -1
  13. package/dist/ui/assets/{api-mj8kMJz1.js → api-CpMMwav8.js} +1 -1
  14. package/dist/ui/assets/auth-section-DQKmNhEN.js +1 -0
  15. package/dist/ui/assets/backups-section-CAKQf9nt.js +1 -0
  16. package/dist/ui/assets/cliproxy-D7mwG-x5.js +3 -0
  17. package/dist/ui/assets/{cliproxy-control-panel-wKdIZ6WV.js → cliproxy-control-panel-DAGDQIWu.js} +1 -1
  18. package/dist/ui/assets/{confirm-dialog-BcIEdkmr.js → confirm-dialog-BkwrKQU-.js} +1 -1
  19. package/dist/ui/assets/{copilot-CK7anGeR.js → copilot-RcBRlgWE.js} +3 -3
  20. package/dist/ui/assets/{globalenv-section-BgoWz-A2.js → globalenv-section-BnZYuxPb.js} +1 -1
  21. package/dist/ui/assets/{health-Clpm6LpQ.js → health-D23qstbb.js} +1 -1
  22. package/dist/ui/assets/icons-v7BVCs0w.js +1 -0
  23. package/dist/ui/assets/{index-C3Ezj6Tb.js → index-01cE8Y7q.js} +1 -1
  24. package/dist/ui/assets/index-4JMryYp8.js +1 -0
  25. package/dist/ui/assets/index-CVpEoaQG.css +1 -0
  26. package/dist/ui/assets/{index-fYt7TJz8.js → index-CiTGfxdk.js} +1 -1
  27. package/dist/ui/assets/index-bcsgnPfl.js +47 -0
  28. package/dist/ui/assets/{radix-ui-CFOhsBGh.js → radix-ui-DP8--cuX.js} +1 -1
  29. package/dist/ui/assets/{shared-C95GV4af.js → shared-DBaRgOZg.js} +1 -1
  30. package/dist/ui/assets/{switch-CUS7UF_z.js → switch-LDXs_uRr.js} +1 -1
  31. package/dist/ui/assets/{tanstack-U3Rle5gh.js → tanstack-C1q4365B.js} +1 -1
  32. package/dist/ui/index.html +5 -5
  33. package/dist/web-server/routes/index.d.ts.map +1 -1
  34. package/dist/web-server/routes/index.js +3 -0
  35. package/dist/web-server/routes/index.js.map +1 -1
  36. package/dist/web-server/routes/persist-routes.d.ts +6 -0
  37. package/dist/web-server/routes/persist-routes.d.ts.map +1 -0
  38. package/dist/web-server/routes/persist-routes.js +286 -0
  39. package/dist/web-server/routes/persist-routes.js.map +1 -0
  40. package/package.json +1 -1
  41. package/dist/ui/assets/auth-section-nFosGq6Z.js +0 -1
  42. package/dist/ui/assets/cliproxy-DlHYA8zi.js +0 -3
  43. package/dist/ui/assets/icons-WqZToXEO.js +0 -1
  44. package/dist/ui/assets/index-B3Y_vbPs.js +0 -1
  45. package/dist/ui/assets/index-CDRTPpUQ.js +0 -47
  46. package/dist/ui/assets/index-CNsISHN_.css +0 -1
@@ -0,0 +1,286 @@
1
+ "use strict";
2
+ /**
3
+ * Persist Routes - Backup management for ~/.claude/settings.json
4
+ */
5
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ var desc = Object.getOwnPropertyDescriptor(m, k);
8
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
9
+ desc = { enumerable: true, get: function() { return m[k]; } };
10
+ }
11
+ Object.defineProperty(o, k2, desc);
12
+ }) : (function(o, m, k, k2) {
13
+ if (k2 === undefined) k2 = k;
14
+ o[k2] = m[k];
15
+ }));
16
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
17
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
18
+ }) : function(o, v) {
19
+ o["default"] = v;
20
+ });
21
+ var __importStar = (this && this.__importStar) || function (mod) {
22
+ if (mod && mod.__esModule) return mod;
23
+ var result = {};
24
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
25
+ __setModuleDefault(result, mod);
26
+ return result;
27
+ };
28
+ var __importDefault = (this && this.__importDefault) || function (mod) {
29
+ return (mod && mod.__esModule) ? mod : { "default": mod };
30
+ };
31
+ Object.defineProperty(exports, "__esModule", { value: true });
32
+ const express_1 = require("express");
33
+ const express_rate_limit_1 = __importDefault(require("express-rate-limit"));
34
+ const fs = __importStar(require("fs"));
35
+ const path = __importStar(require("path"));
36
+ const os = __importStar(require("os"));
37
+ const router = (0, express_1.Router)();
38
+ /** Rate limiter for restore endpoint - prevents abuse */
39
+ const restoreRateLimiter = (0, express_rate_limit_1.default)({
40
+ windowMs: 60 * 1000, // 1 minute
41
+ max: 5, // 5 restore attempts per minute
42
+ message: { error: 'Too many restore attempts. Please try again later.' },
43
+ standardHeaders: true,
44
+ legacyHeaders: false,
45
+ });
46
+ /**
47
+ * Async mutex for restore operations - prevents race conditions
48
+ *
49
+ * Design: Uses a Promise queue pattern for atomic lock acquisition.
50
+ * When the mutex is locked, subsequent callers are added to a queue
51
+ * and immediately receive `false` when released, signaling they should
52
+ * return a 409 Conflict rather than wait. This prevents request pileup
53
+ * while ensuring only one restore can execute at a time.
54
+ */
55
+ class RestoreMutex {
56
+ constructor() {
57
+ this.locked = false;
58
+ this.queue = [];
59
+ }
60
+ /**
61
+ * Attempt to acquire the mutex
62
+ * @returns true if acquired, false if already locked (queued request)
63
+ */
64
+ async acquire() {
65
+ if (this.locked) {
66
+ // Already locked - add to queue and wait
67
+ return new Promise((resolve) => {
68
+ this.queue.push(() => resolve(false)); // Return false = was queued, reject
69
+ });
70
+ }
71
+ this.locked = true;
72
+ return true;
73
+ }
74
+ /** Release the mutex, signaling next queued request (if any) to fail */
75
+ release() {
76
+ const next = this.queue.shift();
77
+ if (next) {
78
+ next(); // Signal queued request to fail
79
+ }
80
+ else {
81
+ this.locked = false;
82
+ }
83
+ }
84
+ }
85
+ const restoreMutex = new RestoreMutex();
86
+ /** Get Claude settings.json path */
87
+ function getClaudeSettingsPath() {
88
+ return path.join(os.homedir(), '.claude', 'settings.json');
89
+ }
90
+ /** Check if path is a symlink (security check) */
91
+ function isSymlink(filePath) {
92
+ try {
93
+ const stats = fs.lstatSync(filePath);
94
+ return stats.isSymbolicLink();
95
+ }
96
+ catch {
97
+ return false;
98
+ }
99
+ }
100
+ /** Get all backup files sorted by date (newest first) */
101
+ function getBackupFiles() {
102
+ const settingsPath = getClaudeSettingsPath();
103
+ const dir = path.dirname(settingsPath);
104
+ if (!fs.existsSync(dir)) {
105
+ return [];
106
+ }
107
+ const backupPattern = /^settings\.json\.backup\.(\d{8}_\d{6})$/;
108
+ const files = fs
109
+ .readdirSync(dir)
110
+ .filter((f) => backupPattern.test(f))
111
+ .map((f) => {
112
+ const match = f.match(backupPattern);
113
+ if (!match)
114
+ return null;
115
+ const timestamp = match[1];
116
+ const year = parseInt(timestamp.slice(0, 4));
117
+ const month = parseInt(timestamp.slice(4, 6)) - 1;
118
+ const day = parseInt(timestamp.slice(6, 8));
119
+ const hour = parseInt(timestamp.slice(9, 11));
120
+ const min = parseInt(timestamp.slice(11, 13));
121
+ const sec = parseInt(timestamp.slice(13, 15));
122
+ return {
123
+ path: path.join(dir, f),
124
+ timestamp,
125
+ date: new Date(year, month, day, hour, min, sec),
126
+ };
127
+ })
128
+ .filter((f) => f !== null)
129
+ .sort((a, b) => b.date.getTime() - a.date.getTime());
130
+ return files;
131
+ }
132
+ /**
133
+ * GET /api/persist/backups - List available backups
134
+ */
135
+ router.get('/backups', (_req, res) => {
136
+ try {
137
+ const backups = getBackupFiles();
138
+ res.json({
139
+ backups: backups.map((b, i) => ({
140
+ timestamp: b.timestamp,
141
+ date: b.date.toISOString(),
142
+ isLatest: i === 0,
143
+ })),
144
+ });
145
+ }
146
+ catch (error) {
147
+ res.status(500).json({ error: error.message });
148
+ }
149
+ });
150
+ /**
151
+ * POST /api/persist/restore - Restore from a backup
152
+ * Body: { timestamp?: string } - If not provided, restores latest
153
+ * Rate limited: 5 requests per minute
154
+ */
155
+ router.post('/restore', restoreRateLimiter, async (req, res) => {
156
+ // Atomic mutex acquisition - prevents race conditions
157
+ const acquired = await restoreMutex.acquire();
158
+ if (!acquired) {
159
+ res.status(409).json({ error: 'Restore already in progress' });
160
+ return;
161
+ }
162
+ try {
163
+ const { timestamp } = req.body;
164
+ const backups = getBackupFiles();
165
+ if (backups.length === 0) {
166
+ res.status(404).json({ error: 'No backups found' });
167
+ return;
168
+ }
169
+ // Find backup
170
+ let backup;
171
+ if (!timestamp) {
172
+ backup = backups[0]; // Latest
173
+ }
174
+ else {
175
+ const found = backups.find((b) => b.timestamp === timestamp);
176
+ if (!found) {
177
+ res.status(404).json({ error: `Backup not found: ${timestamp}` });
178
+ return;
179
+ }
180
+ backup = found;
181
+ }
182
+ // Security: reject symlinks to prevent path traversal attacks
183
+ if (isSymlink(backup.path)) {
184
+ res.status(400).json({ error: 'Backup file is a symlink - refusing for security' });
185
+ return;
186
+ }
187
+ const settingsPath = getClaudeSettingsPath();
188
+ if (isSymlink(settingsPath)) {
189
+ res.status(400).json({ error: 'settings.json is a symlink - refusing for security' });
190
+ return;
191
+ }
192
+ // Read backup content securely using file descriptor to prevent TOCTOU
193
+ // Open with O_NOFOLLOW equivalent check then read atomically
194
+ let backupContent;
195
+ let fd;
196
+ try {
197
+ // Verify not symlink immediately before open
198
+ const stats = fs.lstatSync(backup.path);
199
+ if (stats.isSymbolicLink()) {
200
+ res
201
+ .status(400)
202
+ .json({ error: 'Backup became symlink during read - refusing for security' });
203
+ return;
204
+ }
205
+ // Open file descriptor for atomic read
206
+ fd = fs.openSync(backup.path, 'r');
207
+ const buffer = Buffer.alloc(stats.size);
208
+ fs.readSync(fd, buffer, 0, stats.size, 0);
209
+ backupContent = buffer.toString('utf8');
210
+ const parsed = JSON.parse(backupContent);
211
+ if (typeof parsed !== 'object' || parsed === null || Array.isArray(parsed)) {
212
+ res.status(400).json({ error: 'Backup file is corrupted' });
213
+ return;
214
+ }
215
+ }
216
+ catch (err) {
217
+ const error = err;
218
+ if (error.code === 'ENOENT') {
219
+ res.status(404).json({ error: 'Backup was deleted during restore' });
220
+ return;
221
+ }
222
+ res.status(400).json({ error: 'Backup file is corrupted or invalid JSON' });
223
+ return;
224
+ }
225
+ finally {
226
+ if (fd !== undefined) {
227
+ try {
228
+ fs.closeSync(fd);
229
+ }
230
+ catch {
231
+ // Ignore close errors
232
+ }
233
+ }
234
+ }
235
+ // Atomic restore with rollback capability
236
+ const settingsDir = path.dirname(settingsPath);
237
+ const tempPath = path.join(settingsDir, 'settings.json.restore-tmp');
238
+ const rollbackPath = path.join(settingsDir, 'settings.json.rollback-tmp');
239
+ try {
240
+ // Step 1: Backup current settings for rollback
241
+ if (fs.existsSync(settingsPath)) {
242
+ fs.copyFileSync(settingsPath, rollbackPath);
243
+ }
244
+ // Step 2: Write validated content to temp file
245
+ fs.writeFileSync(tempPath, backupContent, 'utf8');
246
+ // Step 3: Atomic rename (replaces existing file)
247
+ fs.renameSync(tempPath, settingsPath);
248
+ // Step 4: Cleanup rollback backup on success
249
+ if (fs.existsSync(rollbackPath)) {
250
+ fs.unlinkSync(rollbackPath);
251
+ }
252
+ res.json({
253
+ success: true,
254
+ timestamp: backup.timestamp,
255
+ date: backup.date.toISOString(),
256
+ });
257
+ }
258
+ catch (error) {
259
+ // Rollback on failure
260
+ try {
261
+ if (fs.existsSync(rollbackPath)) {
262
+ fs.renameSync(rollbackPath, settingsPath);
263
+ }
264
+ if (fs.existsSync(tempPath)) {
265
+ fs.unlinkSync(tempPath);
266
+ }
267
+ }
268
+ catch (rollbackErr) {
269
+ console.error('[persist-routes] Rollback failed:', rollbackErr);
270
+ res.status(500).json({
271
+ error: 'Restore failed and rollback unsuccessful - manual recovery may be needed',
272
+ });
273
+ return;
274
+ }
275
+ throw error;
276
+ }
277
+ }
278
+ catch (error) {
279
+ res.status(500).json({ error: error.message });
280
+ }
281
+ finally {
282
+ restoreMutex.release();
283
+ }
284
+ });
285
+ exports.default = router;
286
+ //# sourceMappingURL=persist-routes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"persist-routes.js","sourceRoot":"","sources":["../../../src/web-server/routes/persist-routes.ts"],"names":[],"mappings":"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"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kaitranntt/ccs",
3
- "version": "7.20.1",
3
+ "version": "7.21.0-dev.1",
4
4
  "description": "Claude Code Switch - Instant profile switching between Claude Sonnet 4.5 and GLM 4.6",
5
5
  "keywords": [
6
6
  "cli",
@@ -1 +0,0 @@
1
- import{j as e}from"./radix-ui-CFOhsBGh.js";import{r as t}from"./react-vendor-CNOkPC89.js";import{aR as Y,aM as _,aO as H,m as Q,I as b,b as i}from"./index-CDRTPpUQ.js";import{a2 as E,_ as V,p as W,k as X,E as K,d as A,j as T,l as P,aD as Z,Y as ee,R as se,ad as ae}from"./icons-WqZToXEO.js";import"./tanstack-U3Rle5gh.js";import"./notifications-B2HqRBj7.js";import"./utils-CzKF5WmX.js";import"./form-utils-C-pVd1--.js";import"./code-highlight-BRUf_pqB.js";function ue(){const{fetchRawConfig:o}=Y(),[a,R]=t.useState(null),[g,v]=t.useState(!0),[n,c]=t.useState(!1),[x,r]=t.useState(null),[p,f]=t.useState(null),[y,I]=t.useState(!1),[j,z]=t.useState(!1),[d,w]=t.useState(null),[m,N]=t.useState(null),[L,C]=t.useState(!1),[U,k]=t.useState(!1),u=t.useCallback(async()=>{try{v(!0),r(null);const s=await fetch("/api/settings/auth/tokens/raw");if(!s.ok)throw new Error("Failed to fetch auth tokens");const l=await s.json();R(l)}catch(s){r(s instanceof Error?s.message:"Unknown error")}finally{v(!1)}},[]);t.useEffect(()=>{u(),o()},[u,o]),t.useEffect(()=>{if(p){const s=setTimeout(()=>f(null),3e3);return()=>clearTimeout(s)}},[p]),t.useEffect(()=>{if(x){const s=setTimeout(()=>r(null),5e3);return()=>clearTimeout(s)}},[x]);const F=async()=>{const s=d!==null&&d!==a?.apiKey.value,l=m!==null&&m!==a?.managementSecret.value;if(!(!s&&!l))try{c(!0),r(null);const h={};s&&(h.apiKey=d),l&&(h.managementSecret=m);const S=await fetch("/api/settings/auth/tokens",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(h)});if(!S.ok){const J=await S.json();throw new Error(J.error||"Failed to save tokens")}f("Tokens updated. Restart CLIProxy to apply."),w(null),N(null),await u(),await o()}catch(h){r(h instanceof Error?h.message:"Unknown error")}finally{c(!1)}},O=async()=>{try{c(!0),r(null);const s=await fetch("/api/settings/auth/tokens/regenerate-secret",{method:"POST"});if(!s.ok){const l=await s.json();throw new Error(l.error||"Failed to regenerate secret")}f("New management secret generated. Restart CLIProxy to apply."),await u(),await o()}catch(s){r(s instanceof Error?s.message:"Unknown error")}finally{c(!1)}},D=async()=>{try{c(!0),r(null);const s=await fetch("/api/settings/auth/tokens/reset",{method:"POST"});if(!s.ok){const l=await s.json();throw new Error(l.error||"Failed to reset tokens")}f("Tokens reset to defaults. Restart CLIProxy to apply."),w(null),N(null),await u(),await o()}catch(s){r(s instanceof Error?s.message:"Unknown error")}finally{c(!1)}},M=async()=>{a&&(await navigator.clipboard.writeText(a.apiKey.value),C(!0),setTimeout(()=>C(!1),2e3))},$=async()=>{a&&(await navigator.clipboard.writeText(a.managementSecret.value),k(!0),setTimeout(()=>k(!1),2e3))};if(g||!a)return e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsxs("div",{className:"flex items-center gap-3 text-muted-foreground",children:[e.jsx(E,{className:"w-5 h-5 animate-spin"}),e.jsx("span",{children:"Loading..."})]})});const q=d??a.apiKey.value,B=m??a.managementSecret.value,G=d!==null&&d!==a.apiKey.value||m!==null&&m!==a.managementSecret.value;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:`absolute left-5 right-5 top-20 z-10 transition-all duration-200 ease-out ${x||p?"opacity-100 translate-y-0":"opacity-0 -translate-y-2 pointer-events-none"}`,children:[x&&e.jsxs(_,{variant:"destructive",className:"py-2 shadow-lg",children:[e.jsx(V,{className:"h-4 w-4"}),e.jsx(H,{children:x})]}),p&&e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-md border border-green-200 bg-green-50 text-green-700 shadow-lg dark:border-green-900/50 dark:bg-green-900/90 dark:text-green-300",children:[e.jsx(W,{className:"h-4 w-4 shrink-0"}),e.jsx("span",{className:"text-sm font-medium",children:p})]})]}),e.jsx(Q,{className:"flex-1",children:e.jsxs("div",{className:"p-5 space-y-6",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Configure CLIProxy authentication tokens. Changes require CLIProxy restart."}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(X,{className:"w-4 h-4 text-primary"}),e.jsx("h3",{className:"text-base font-medium",children:"API Key"}),a.apiKey.isCustom&&e.jsx("span",{className:"text-xs px-2 py-0.5 rounded bg-amber-100 text-amber-700 dark:bg-amber-900/50 dark:text-amber-300",children:"Custom"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Used by Claude Code to authenticate with CLIProxy"}),e.jsx("div",{className:"flex gap-2",children:e.jsxs("div",{className:"relative flex-1",children:[e.jsx(b,{type:y?"text":"password",value:q,onChange:s=>w(s.target.value),placeholder:"API key",disabled:n,className:"pr-20 font-mono text-sm"}),e.jsxs("div",{className:"absolute right-2 top-1/2 -translate-y-1/2 flex gap-1",children:[e.jsx(i,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0",onClick:()=>I(!y),children:y?e.jsx(K,{className:"w-4 h-4"}):e.jsx(A,{className:"w-4 h-4"})}),e.jsx(i,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0",onClick:M,disabled:!a.apiKey.value,children:L?e.jsx(T,{className:"w-4 h-4 text-green-600"}):e.jsx(P,{className:"w-4 h-4"})})]})]})})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Z,{className:"w-4 h-4 text-primary"}),e.jsx("h3",{className:"text-base font-medium",children:"Management Secret"}),a.managementSecret.isCustom&&e.jsx("span",{className:"text-xs px-2 py-0.5 rounded bg-amber-100 text-amber-700 dark:bg-amber-900/50 dark:text-amber-300",children:"Custom"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Used by CCS dashboard to access CLIProxy management APIs"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(b,{type:j?"text":"password",value:B,onChange:s=>N(s.target.value),placeholder:"Management secret",disabled:n,className:"pr-20 font-mono text-sm"}),e.jsxs("div",{className:"absolute right-2 top-1/2 -translate-y-1/2 flex gap-1",children:[e.jsx(i,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0",onClick:()=>z(!j),children:j?e.jsx(K,{className:"w-4 h-4"}):e.jsx(A,{className:"w-4 h-4"})}),e.jsx(i,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0",onClick:$,disabled:!a.managementSecret.value,children:U?e.jsx(T,{className:"w-4 h-4 text-green-600"}):e.jsx(P,{className:"w-4 h-4"})})]})]}),e.jsx(i,{variant:"outline",size:"sm",onClick:O,disabled:n,title:"Generate new secure secret",children:e.jsx(ee,{className:"w-4 h-4"})})]})]}),e.jsxs("div",{className:"pt-4 border-t",children:[e.jsxs(i,{variant:"outline",size:"sm",onClick:D,disabled:n||!a.apiKey.isCustom&&!a.managementSecret.isCustom,className:"gap-2",children:[e.jsx(se,{className:"w-4 h-4"}),"Reset to Defaults"]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-2",children:"Resets both API key and management secret to their default values."})]})]})}),e.jsxs("div",{className:"p-4 border-t bg-background flex gap-2",children:[e.jsxs(i,{variant:"outline",size:"sm",onClick:()=>{u(),o()},disabled:g||n,className:"flex-1",children:[e.jsx(E,{className:`w-4 h-4 mr-2 ${g?"animate-spin":""}`}),"Refresh"]}),e.jsxs(i,{variant:"default",size:"sm",onClick:F,disabled:!G||n,className:"flex-1",children:[e.jsx(ae,{className:`w-4 h-4 mr-2 ${n?"animate-pulse":""}`}),n?"Saving...":"Save"]})]})]})}export{ue as default};
@@ -1,3 +0,0 @@
1
- import{j as e}from"./radix-ui-CFOhsBGh.js";import{r as p}from"./react-vendor-CNOkPC89.js";import{u as Ke,a as me,b as fs}from"./tanstack-U3Rle5gh.js";import{b as w,C as $e,a as qe,c as T,P as ue,L as Z,I as xe,X as pe,Y as he,Z as ge,_ as fe,$ as ee,a0 as ze,a1 as js,a2 as Be,a3 as Qe,u as Je,a4 as je,a5 as ve,a6 as Ne,a7 as we,a8 as Ye,a9 as vs,aa as Ee,ab as Ie,B as L,ac as Ns,q as We,m as be,l as ws,ad as bs,ae as ys,af as Cs,ag as ks,ah as As,ai as Ss,aj as ie,ak as Xe,T as Ze,o as es,al as Ps,p as ss,am as Ms,an as Ts,ao as W,ap as Ds,aq as Os,ar as Es,as as Is,H as _s,J as Ls,K as _e,M as Le,at as Rs,au as Fs,av as Us,aw as Hs,ax as Vs,ay as Gs,az as Ks,aA as $s,E as qs,G as zs,aB as Bs,aC as Qs,aD as Js,aE as Ys,aF as Ws,aG as Xs,S as Zs}from"./index-CDRTPpUQ.js";import{t as F}from"./notifications-B2HqRBj7.js";import{b as ts,L as q,m as ye,v as et,j as z,l as st,aj as Ce,a2 as $,n as B,Y as J,ak as as,al as se,Z as te,I as tt,f as at,$ as ke,am as nt,ad as it,X as ae,V as ns,an as Re,s as X,ao as rt,ap as ot,ac as is,p as lt,aq as ct,ag as dt,A as mt,ar as ut,as as xt,S as pt,at as Fe,au as ht,av as gt,U as ft,T as Ue,aw as rs}from"./icons-WqZToXEO.js";import{S as Ae,C as jt}from"./confirm-dialog-BcIEdkmr.js";import{S as vt}from"./switch-CUS7UF_z.js";import{A as Nt,a as wt,b as bt,c as yt,d as Ct,e as kt,f as At,g as St}from"./alert-dialog-CM5u0JHs.js";import"./utils-CzKF5WmX.js";import"./form-utils-C-pVd1--.js";import"./code-highlight-BRUf_pqB.js";const Q={agy:{provider:"agy",displayName:"Antigravity",defaultModel:"gemini-claude-opus-4-5-thinking",models:[{id:"gemini-claude-opus-4-5-thinking",name:"Claude Opus 4.5 Thinking",description:"Most capable, extended thinking",presetMapping:{default:"gemini-claude-opus-4-5-thinking",opus:"gemini-claude-opus-4-5-thinking",sonnet:"gemini-claude-sonnet-4-5-thinking",haiku:"gemini-claude-sonnet-4-5"}},{id:"gemini-claude-sonnet-4-5-thinking",name:"Claude Sonnet 4.5 Thinking",description:"Balanced with extended thinking",presetMapping:{default:"gemini-claude-sonnet-4-5-thinking",opus:"gemini-claude-opus-4-5-thinking",sonnet:"gemini-claude-sonnet-4-5-thinking",haiku:"gemini-claude-sonnet-4-5"}},{id:"gemini-claude-sonnet-4-5",name:"Claude Sonnet 4.5",description:"Fast and capable",presetMapping:{default:"gemini-claude-sonnet-4-5",opus:"gemini-claude-opus-4-5-thinking",sonnet:"gemini-claude-sonnet-4-5",haiku:"gemini-claude-sonnet-4-5"}},{id:"gemini-3-pro-preview",name:"Gemini 3 Pro",description:"Google latest model via Antigravity",presetMapping:{default:"gemini-3-pro-preview",opus:"gemini-3-pro-preview",sonnet:"gemini-3-pro-preview",haiku:"gemini-3-flash-preview"}},{id:"gemini-3-flash-preview",name:"Gemini 3 Flash",description:"Fast Gemini model via Antigravity",presetMapping:{default:"gemini-3-flash-preview",opus:"gemini-3-pro-preview",sonnet:"gemini-3-pro-preview",haiku:"gemini-3-flash-preview"}}]},gemini:{provider:"gemini",displayName:"Gemini",defaultModel:"gemini-2.5-pro",models:[{id:"gemini-3-pro-preview",name:"Gemini 3 Pro",tier:"paid",description:"Latest model, requires paid Google account",presetMapping:{default:"gemini-3-pro-preview",opus:"gemini-3-pro-preview",sonnet:"gemini-3-pro-preview",haiku:"gemini-3-flash-preview"}},{id:"gemini-3-flash-preview",name:"Gemini 3 Flash",tier:"paid",description:"Fast Gemini 3 model, requires paid Google account",presetMapping:{default:"gemini-3-flash-preview",opus:"gemini-3-pro-preview",sonnet:"gemini-3-pro-preview",haiku:"gemini-3-flash-preview"}},{id:"gemini-2.5-pro",name:"Gemini 2.5 Pro",description:"Stable, works with free Google account",presetMapping:{default:"gemini-2.5-pro",opus:"gemini-2.5-pro",sonnet:"gemini-2.5-pro",haiku:"gemini-2.5-flash"}}]},codex:{provider:"codex",displayName:"Codex",defaultModel:"gpt-5.1-codex-max",models:[{id:"gpt-5.1-codex-max",name:"Codex Max (5.1)",description:"Most capable Codex model",presetMapping:{default:"gpt-5.1-codex-max",opus:"gpt-5.1-codex-max-high",sonnet:"gpt-5.1-codex-max",haiku:"gpt-5.1-codex-mini-high"}},{id:"gpt-5.2",name:"GPT 5.2",description:"Latest GPT model",presetMapping:{default:"gpt-5.2",opus:"gpt-5.2",sonnet:"gpt-5.2",haiku:"gpt-5.2"}},{id:"gpt-5.1-codex-mini",name:"Codex Mini",description:"Fast and efficient Codex model"}]},qwen:{provider:"qwen",displayName:"Qwen",defaultModel:"qwen-coder-plus",models:[{id:"qwen-coder-plus",name:"Qwen Coder Plus",description:"Alibaba code-focused model"},{id:"qwen-max",name:"Qwen Max",description:"Most capable Qwen model"}]},iflow:{provider:"iflow",displayName:"iFlow",defaultModel:"iflow-default",models:[{id:"iflow-default",name:"iFlow Default",description:"Default iFlow model"}]},kiro:{provider:"kiro",displayName:"Kiro (AWS)",defaultModel:"kiro-claude-sonnet-4-5",models:[{id:"kiro-claude-opus-4-5",name:"Kiro Claude Opus 4.5",description:"Claude Opus 4.5 via Kiro (2.2x credit)",presetMapping:{default:"kiro-claude-opus-4-5",opus:"kiro-claude-opus-4-5",sonnet:"kiro-claude-sonnet-4-5",haiku:"kiro-claude-haiku-4-5"}},{id:"kiro-claude-sonnet-4-5",name:"Kiro Claude Sonnet 4.5",description:"Claude Sonnet 4.5 via Kiro (1.3x credit)",presetMapping:{default:"kiro-claude-sonnet-4-5",opus:"kiro-claude-opus-4-5",sonnet:"kiro-claude-sonnet-4-5",haiku:"kiro-claude-haiku-4-5"}},{id:"kiro-claude-sonnet-4",name:"Kiro Claude Sonnet 4",description:"Claude Sonnet 4 via Kiro (1.3x credit)",presetMapping:{default:"kiro-claude-sonnet-4",opus:"kiro-claude-opus-4-5",sonnet:"kiro-claude-sonnet-4",haiku:"kiro-claude-haiku-4-5"}},{id:"kiro-claude-haiku-4-5",name:"Kiro Claude Haiku 4.5",description:"Claude Haiku 4.5 via Kiro (0.4x credit)"}]},ghcp:{provider:"ghcp",displayName:"GitHub Copilot (OAuth)",defaultModel:"claude-sonnet-4.5",models:[{id:"claude-opus-4.5",name:"Claude Opus 4.5",description:"Anthropic Claude Opus 4.5 via GitHub Copilot",presetMapping:{default:"claude-opus-4.5",opus:"claude-opus-4.5",sonnet:"claude-sonnet-4.5",haiku:"claude-haiku-4.5"}},{id:"claude-sonnet-4.5",name:"Claude Sonnet 4.5",description:"Anthropic Claude Sonnet 4.5 via GitHub Copilot",presetMapping:{default:"claude-sonnet-4.5",opus:"claude-opus-4.5",sonnet:"claude-sonnet-4.5",haiku:"claude-haiku-4.5"}},{id:"claude-sonnet-4",name:"Claude Sonnet 4",description:"Anthropic Claude Sonnet 4 via GitHub Copilot"},{id:"claude-haiku-4.5",name:"Claude Haiku 4.5",description:"Anthropic Claude Haiku 4.5 via GitHub Copilot"},{id:"gpt-5.2",name:"GPT-5.2",description:"OpenAI GPT-5.2 via GitHub Copilot",presetMapping:{default:"gpt-5.2",opus:"gpt-5.2",sonnet:"gpt-5.1",haiku:"gpt-5-mini"}},{id:"gpt-5.1",name:"GPT-5.1",description:"OpenAI GPT-5.1 via GitHub Copilot"},{id:"gpt-5",name:"GPT-5",description:"OpenAI GPT-5 via GitHub Copilot"},{id:"gpt-5-mini",name:"GPT-5 Mini",description:"OpenAI GPT-5 Mini via GitHub Copilot"},{id:"gemini-3-pro",name:"Gemini 3 Pro",description:"Google Gemini 3 Pro via GitHub Copilot"}]}},ce=8317,re="ccs-internal-managed";async function Pt(){try{const s=await fetch("/api/settings/auth/tokens/raw");return s.ok?(await s.json())?.apiKey?.value??re:re}catch{return re}}async function de(s,n){const t=Q[s];if(!t)return{success:!1};const a=t.models[0],i=a?.presetMapping||{default:t.defaultModel,opus:t.defaultModel,sonnet:t.defaultModel,haiku:t.defaultModel},l=await Pt(),u={env:{ANTHROPIC_BASE_URL:`http://127.0.0.1:${ce}/api/provider/${s}`,ANTHROPIC_AUTH_TOKEN:l,ANTHROPIC_MODEL:i.default,ANTHROPIC_DEFAULT_OPUS_MODEL:i.opus,ANTHROPIC_DEFAULT_SONNET_MODEL:i.sonnet,ANTHROPIC_DEFAULT_HAIKU_MODEL:i.haiku}};try{return{success:(await fetch(`/api/settings/${s}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({settings:u})})).ok,presetName:a?.name||t.defaultModel}}catch{return{success:!1}}}const He=[{id:"gemini",name:"Google Gemini",description:"Gemini Pro/Flash models"},{id:"codex",name:"OpenAI Codex",description:"GPT-4 and codex models"},{id:"agy",name:"Antigravity",description:"Antigravity AI models"},{id:"qwen",name:"Alibaba Qwen",description:"Qwen Code models"},{id:"iflow",name:"iFlow",description:"iFlow AI models"},{id:"kiro",name:"Kiro (AWS)",description:"AWS CodeWhisperer models"},{id:"ghcp",name:"GitHub Copilot (OAuth)",description:"GitHub Copilot via OAuth"}],os=["provider","auth","variant","success"];function Mt(s){return s==="account"?1:os.indexOf(s)}function Tt({currentProgress:s,allSteps:n}){return e.jsx("div",{className:"flex justify-center gap-1 pt-2",children:n.map((t,a)=>e.jsx("div",{className:`w-2 h-2 rounded-full transition-colors ${s>=a?"bg-primary":"bg-muted"}`},t))})}function Dt({providers:s,onSelect:n}){return e.jsx("div",{className:"grid gap-2",children:s.map(t=>e.jsxs("button",{onClick:()=>n(t.id),className:"flex items-center justify-between p-3 border rounded-lg hover:bg-muted/50 transition-colors text-left",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:t.name}),e.jsx("div",{className:"text-xs text-muted-foreground",children:t.description})]}),e.jsx(ts,{className:"w-4 h-4 text-muted-foreground"})]},t.id))})}function Ot({selectedProvider:s,providers:n,authCommand:t,isRefreshing:a,isPending:i,onBack:l,onStartAuth:c,onRefresh:u}){const[r,d]=p.useState(!1),h=async x=>{await navigator.clipboard.writeText(x),d(!0),setTimeout(()=>d(!1),2e3)};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"text-center space-y-3",children:[e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Authenticate with ",n.find(x=>x.id===s)?.name," to add an account"]}),e.jsx(w,{onClick:c,disabled:i,className:"w-full gap-2",size:"lg",children:i?e.jsxs(e.Fragment,{children:[e.jsx(q,{className:"w-4 h-4 animate-spin"}),"Authenticating..."]}):e.jsxs(e.Fragment,{children:[e.jsx(ye,{className:"w-4 h-4"}),"Authenticate in Browser"]})}),i&&e.jsx("p",{className:"text-xs text-muted-foreground",children:"Complete the OAuth flow in your browser..."})]}),e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"absolute inset-0 flex items-center",children:e.jsx("span",{className:"w-full border-t"})}),e.jsx("div",{className:"relative flex justify-center text-xs uppercase",children:e.jsx("span",{className:"bg-background px-2 text-muted-foreground",children:"Or use terminal"})})]}),e.jsx($e,{children:e.jsxs(qe,{className:"p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(et,{className:"w-4 h-4"}),"Run this command in your terminal:"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("code",{className:"flex-1 px-3 py-2 bg-muted rounded-md font-mono text-sm",children:t}),e.jsx(w,{variant:"outline",size:"icon",onClick:()=>h(t),children:r?e.jsx(z,{className:"w-4 h-4 text-green-500"}):e.jsx(st,{className:"w-4 h-4"})})]})]})}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(w,{variant:"ghost",onClick:l,disabled:i,children:[e.jsx(Ce,{className:"w-4 h-4 mr-2"}),"Back"]}),e.jsxs(w,{variant:"outline",onClick:u,disabled:a||i,children:[e.jsx($,{className:`w-4 h-4 mr-2 ${a?"animate-spin":""}`}),a?"Checking...":"Refresh Status"]})]})]})}function Et({accounts:s,privacyMode:n,onSelect:t,onAddNew:a,onBack:i}){return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:["Select an account (",s.length,")"]}),e.jsx("div",{className:"grid gap-2",children:s.map(l=>e.jsxs("button",{type:"button",onClick:()=>t(l),className:"flex items-center justify-between p-3 border rounded-lg hover:bg-muted/50 transition-colors text-left",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-8 h-8 rounded-full bg-muted flex items-center justify-center",children:e.jsx(B,{className:"w-4 h-4 text-muted-foreground"})}),e.jsxs("div",{children:[e.jsx("div",{className:T("font-medium",n&&ue),children:l.email||l.id}),l.isDefault&&e.jsx("div",{className:"text-xs text-muted-foreground",children:"Default account"})]})]}),e.jsx(ts,{className:"w-4 h-4 text-muted-foreground"})]},l.id))}),e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"absolute inset-0 flex items-center",children:e.jsx("span",{className:"w-full border-t"})}),e.jsx("div",{className:"relative flex justify-center text-xs uppercase",children:e.jsx("span",{className:"bg-background px-2 text-muted-foreground",children:"Or"})})]}),e.jsxs("button",{type:"button",className:"w-full flex items-center gap-3 p-3 border-2 border-dashed border-primary/50 rounded-lg hover:border-primary hover:bg-primary/5 transition-colors text-left",onClick:a,children:[e.jsx("div",{className:"w-8 h-8 rounded-full bg-primary/10 flex items-center justify-center shrink-0",children:e.jsx(ye,{className:"w-4 h-4 text-primary"})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-primary",children:"Add new account"}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Authenticate with a different account"})]})]}),e.jsx("div",{className:"flex items-center justify-between pt-2",children:e.jsxs(w,{variant:"ghost",onClick:i,children:[e.jsx(Ce,{className:"w-4 h-4 mr-2"}),"Back"]})})]})}function It({selectedProvider:s,selectedAccount:n,variantName:t,modelName:a,isPending:i,privacyMode:l,onVariantNameChange:c,onModelChange:u,onBack:r,onSkip:d,onCreate:h}){return e.jsxs("div",{className:"space-y-4",children:[n&&e.jsxs("div",{className:"flex items-center gap-2 p-2 bg-muted/50 rounded-md text-sm",children:[e.jsx(B,{className:"w-4 h-4"}),e.jsxs("span",{children:["Using:"," ",e.jsx("span",{className:T(l&&ue),children:n.email||n.id})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{htmlFor:"variant-name",children:"Variant Name *"}),e.jsx(xe,{id:"variant-name",value:t,onChange:x=>c(x.target.value),placeholder:"e.g., my-gemini, g3, flash"}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:["Use this name to invoke: ccs ",t||"<name>",' "prompt"']})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{children:"Model"}),e.jsxs(pe,{value:a,onValueChange:u,children:[e.jsx(he,{children:e.jsx(ge,{placeholder:"Select a model"})}),e.jsx(fe,{children:Q[s]?.models.map(x=>e.jsx(ee,{value:x.id,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{children:x.name}),x.description&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:["- ",x.description]})]})},x.id))})]}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:["Default: ",Q[s]?.defaultModel||"provider default"]})]}),e.jsxs("div",{className:"flex items-center justify-between pt-2",children:[e.jsxs(w,{variant:"ghost",onClick:r,children:[e.jsx(Ce,{className:"w-4 h-4 mr-2"}),"Back"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(w,{variant:"ghost",onClick:d,children:"Skip"}),e.jsx(w,{onClick:h,disabled:!t||i,children:i?"Creating...":"Create Variant"})]})]}),e.jsx("p",{className:"text-xs text-center text-muted-foreground",children:"Skip if you just wanted to add an account without creating a variant"})]})}function _t({variantName:s,onClose:n}){return e.jsxs("div",{className:"space-y-4 text-center",children:[e.jsx("div",{className:"flex justify-center",children:e.jsx("div",{className:"w-16 h-16 bg-green-100 dark:bg-green-900/30 rounded-full flex items-center justify-center",children:e.jsx(z,{className:"w-8 h-8 text-green-600 dark:text-green-400"})})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-semibold text-lg",children:"Variant Created!"}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"Your custom variant is ready to use"})]}),e.jsx($e,{children:e.jsxs(qe,{className:"p-4 space-y-2",children:[e.jsx("div",{className:"text-sm text-muted-foreground",children:"Usage:"}),e.jsxs("code",{className:"block px-3 py-2 bg-muted rounded-md font-mono text-sm",children:["ccs ",s,' "your prompt here"']})]})}),e.jsx(w,{onClick:n,className:"w-full",children:"Done"})]})}function Lt({open:s,onClose:n}){const[t,a]=p.useState("provider"),[i,l]=p.useState(""),[c,u]=p.useState(null),[r,d]=p.useState(""),[h,x]=p.useState(""),[g,o]=p.useState(!1),[b,A]=p.useState(!1),{data:v,refetch:O}=ze(),k=js(),D=Be(),P=Qe(),{privacyMode:_}=Je(),y=v?.authStatus.find(N=>N.provider===i),j=p.useMemo(()=>y?.accounts||[],[y?.accounts]);p.useEffect(()=>{if(!s){const N=setTimeout(()=>{a("provider"),l(""),u(null),d(""),x(""),A(!1)},0);return()=>clearTimeout(N)}},[s]),p.useEffect(()=>{if(t==="auth"&&j.length>0&&!b){const N=setTimeout(()=>{a("account")},0);return()=>clearTimeout(N)}},[t,j,b]);const f=async()=>{o(!0),await O(),o(!1)},S=()=>{const N=(y?.accounts?.length||0)===0;D.mutate({provider:i},{onSuccess:async H=>{if(N){const V=await de(i);V.success&&V.presetName?F.success(`Applied "${V.presetName}" preset`):V.success||F.warning("Account added, but failed to apply default preset")}H.account&&(u(H.account),a("variant")),O()}})},E=N=>{l(N),(v?.authStatus.find(ne=>ne.provider===N)?.accounts||[]).length===0?a("auth"):a("account")},R=N=>{u(N),a("variant")},U=async()=>{if(!(!r||!i))try{await k.mutateAsync({name:r,provider:i,model:h||void 0,account:c?.id}),a("success")}catch(N){console.error("Failed to create variant:",N)}},m=`ccs ${i} --auth --add`,C=Mt(t),M=N=>{if(!N&&(D.isPending&&i&&P.mutate(i),t==="success"||t==="provider")){n();return}};return e.jsx(je,{open:s,onOpenChange:M,children:e.jsxs(ve,{className:"sm:max-w-lg",onPointerDownOutside:N=>{t!=="success"&&t!=="provider"&&N.preventDefault()},onEscapeKeyDown:N=>{(D.isPending||k.isPending)&&N.preventDefault()},children:[e.jsxs(Ne,{children:[e.jsxs(we,{className:"flex items-center gap-2",children:[e.jsx(J,{className:"w-5 h-5 text-primary"}),"Quick Setup Wizard"]}),e.jsxs(Ye,{children:[t==="provider"&&"Select a provider to get started",t==="auth"&&"Authenticate with your provider",t==="account"&&"Select which account to use",t==="variant"&&"Create your custom variant",t==="success"&&"Setup complete!"]})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[t==="provider"&&e.jsx(Dt,{providers:He,onSelect:E}),t==="auth"&&e.jsx(Ot,{selectedProvider:i,providers:He,authCommand:m,isRefreshing:g,isPending:D.isPending,onBack:()=>a("provider"),onStartAuth:S,onRefresh:f}),t==="account"&&e.jsx(Et,{accounts:j,privacyMode:_,onSelect:R,onAddNew:()=>{A(!0),a("auth")},onBack:()=>a("provider")}),t==="variant"&&e.jsx(It,{selectedProvider:i,selectedAccount:c,variantName:r,modelName:h,isPending:k.isPending,privacyMode:_,onVariantNameChange:d,onModelChange:x,onBack:()=>j.length>0?a("account"):a("provider"),onSkip:n,onCreate:U}),t==="success"&&e.jsx(_t,{variantName:r,onClose:n})]}),e.jsx(Tt,{currentProgress:C,allSteps:os})]})})}function Rt({open:s,onClose:n,provider:t,displayName:a,isFirstAccount:i=!1}){const[l,c]=p.useState(""),u=Be(),r=vs(),d=Qe(),h=t==="kiro",x=u.isPending||r.isPending,g=()=>{x&&d.mutate(t),c(""),n()},o=()=>{u.mutate({provider:t,nickname:l.trim()||void 0},{onSuccess:async()=>{const v=await de(t);v.success&&v.presetName?i&&F.success(`Applied "${v.presetName}" preset`):v.success||F.warning("Account added, but failed to apply default preset. You may need to configure settings manually."),c(""),n()}})},b=()=>{r.mutate(void 0,{onSuccess:async()=>{const v=await de("kiro");v.success&&v.presetName&&i&&F.success(`Applied "${v.presetName}" preset`),c(""),n()}})},A=v=>{v||g()};return e.jsx(je,{open:s,onOpenChange:A,children:e.jsxs(ve,{className:"sm:max-w-md",children:[e.jsxs(Ne,{children:[e.jsxs(we,{children:["Add ",a," Account"]}),e.jsx(Ye,{children:h?"Authenticate via browser or import an existing token from Kiro IDE.":"Click the button below to authenticate a new account. A browser window will open for OAuth."})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{htmlFor:"nickname",children:"Nickname (optional)"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(B,{className:"w-4 h-4 text-muted-foreground"}),e.jsx(xe,{id:"nickname",value:l,onChange:v=>c(v.target.value),placeholder:"e.g., work, personal",disabled:x,className:"flex-1"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"A friendly name to identify this account. Auto-generated from email if left empty."})]}),e.jsxs("div",{className:"flex items-center justify-end gap-2 pt-2",children:[e.jsx(w,{variant:"ghost",onClick:g,children:"Cancel"}),h&&e.jsx(w,{variant:"outline",onClick:b,disabled:x,children:r.isPending?e.jsxs(e.Fragment,{children:[e.jsx(q,{className:"w-4 h-4 mr-2 animate-spin"}),"Importing..."]}):e.jsxs(e.Fragment,{children:[e.jsx(as,{className:"w-4 h-4 mr-2"}),"Import from IDE"]})}),e.jsx(w,{onClick:o,disabled:x,children:u.isPending?e.jsxs(e.Fragment,{children:[e.jsx(q,{className:"w-4 h-4 mr-2 animate-spin"}),"Authenticating..."]}):e.jsxs(e.Fragment,{children:[e.jsx(ye,{className:"w-4 h-4 mr-2"}),"Authenticate"]})})]}),u.isPending&&e.jsx("p",{className:"text-sm text-center text-muted-foreground",children:"Complete the OAuth flow in your browser..."}),r.isPending&&e.jsx("p",{className:"text-sm text-center text-muted-foreground",children:"Importing token from Kiro IDE..."})]})]})})}const Ft=["ANTHROPIC_BASE_URL","ANTHROPIC_AUTH_TOKEN"];function Ut(s){const n=s?.env||{};return Ft.filter(t=>!n[t]?.trim())}function Ht(s){const[n,t]=p.useState(null),[a,i]=p.useState(!1),l=Ke(),{data:c,isLoading:u,refetch:r}=me({queryKey:["settings",s],queryFn:async()=>{const f=await fetch(`/api/settings/${s}/raw`);return f.ok?f.json():{profile:s,settings:{env:{}},mtime:Date.now(),path:`~/.ccs/profiles/${s}/settings.json`}}}),d=c?.settings,h=p.useMemo(()=>n!==null?n:d?JSON.stringify(d,null,2):`{
2
- "env": {}
3
- }`,[n,d]),x=p.useCallback(f=>{t(f)},[]),g=p.useMemo(()=>{try{return JSON.parse(h)}catch{return d||{env:{}}}},[h,d]),o=g?.env?.ANTHROPIC_MODEL,b=g?.env?.ANTHROPIC_DEFAULT_OPUS_MODEL,A=g?.env?.ANTHROPIC_DEFAULT_SONNET_MODEL,v=g?.env?.ANTHROPIC_DEFAULT_HAIKU_MODEL,O=p.useCallback((f,S)=>{const E={...g?.env||{},[f]:S},R={...g,env:E};t(JSON.stringify(R,null,2))},[g]),k=p.useCallback(f=>{const S={...g?.env||{},...f},E={...g,env:S};t(JSON.stringify(E,null,2))},[g]),D=p.useMemo(()=>{try{return JSON.parse(h),!0}catch{return!1}},[h]),P=p.useMemo(()=>n===null?!1:n!==JSON.stringify(d,null,2),[n,d]),_=p.useMemo(()=>Ut(g),[g]),y=fs({mutationFn:async()=>{const f=JSON.parse(h),S=await fetch(`/api/settings/${s}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({settings:f,expectedMtime:c?.mtime})});if(S.status===409)throw new Error("CONFLICT");if(!S.ok)throw new Error("Failed to save");return S.json()},onSuccess:f=>{l.invalidateQueries({queryKey:["settings",s]}),t(null),f?.warning?F.success("Settings saved",{description:f.warning}):F.success("Settings saved")},onError:f=>{f.message==="CONFLICT"?i(!0):F.error(f.message)}}),j=async f=>{i(!1),f?(await r(),y.mutate()):t(null)};return{data:c,isLoading:u,refetch:r,rawJsonContent:h,rawJsonEdits:n,isRawJsonValid:D,hasChanges:P,currentSettings:g,currentModel:o,opusModel:b,sonnetModel:A,haikuModel:v,handleRawJsonChange:x,updateEnvValue:O,updateEnvValues:k,saveMutation:{mutate:()=>y.mutate(),isPending:y.isPending},conflictDialog:a,setConflictDialog:i,handleConflictResolve:j,missingRequiredFields:_}}function K({label:s,description:n,value:t,onChange:a,catalog:i,allModels:l,disabled:c}){const u=new Set(i?.models.map(r=>r.id)||[]);return e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium",children:s}),n&&e.jsx("p",{className:"text-[10px] text-muted-foreground",children:n})]}),e.jsxs(pe,{value:t||"",onValueChange:a,disabled:c,children:[e.jsx(he,{className:"h-9",children:e.jsx(ge,{placeholder:"Select model",children:t&&e.jsx("span",{className:"truncate font-mono text-xs",children:t})})}),e.jsxs(fe,{className:"max-h-[300px]",children:[i&&i.models.length>0&&e.jsxs(Ee,{children:[e.jsx(Ie,{className:"text-xs text-primary",children:"Recommended"}),i.models.map(r=>e.jsx(ee,{value:r.id,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"truncate font-mono text-xs",children:r.id}),r.tier==="paid"&&e.jsx(L,{variant:"outline",className:"text-[9px] h-4 px-1",children:"PAID"}),t===r.id&&e.jsx(z,{className:"w-3 h-3 text-primary ml-auto"})]})},r.id))]}),l.length>0&&e.jsxs(Ee,{children:[e.jsxs(Ie,{className:"text-xs text-muted-foreground",children:["All Models (",l.length,")"]}),l.filter(r=>!u.has(r.id)).map(r=>e.jsx(ee,{value:r.id,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"truncate font-mono text-xs",children:r.id}),t===r.id&&e.jsx(z,{className:"w-3 h-3 text-primary ml-auto"})]})},r.id))]}),(!i||i.models.length===0)&&l.length===0&&e.jsx("div",{className:"py-2 px-3 text-xs text-muted-foreground",children:"No models available"})]})]})]})}function Vt({open:s,onClose:n,currentValues:t,onApply:a,onSave:i,isSaving:l,catalog:c,allModels:u}){const[r,d]=p.useState(t),[h,x]=p.useState(""),g=o=>{o?(d(t),x("")):n()};return e.jsx(je,{open:s,onOpenChange:g,children:e.jsxs(ve,{className:"sm:max-w-md",children:[e.jsx(Ne,{children:e.jsxs(we,{className:"flex items-center gap-2",children:[e.jsx(J,{className:"w-4 h-4"}),"Custom Preset"]})}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{htmlFor:"preset-name",children:"Preset Name (optional)"}),e.jsx(xe,{id:"preset-name",value:h,onChange:o=>x(o.target.value),placeholder:"e.g., My Custom Config",className:"text-sm"})]}),e.jsx(Ae,{}),e.jsx(K,{label:"Default Model",description:"Used when no specific tier is requested",value:r.default,onChange:o=>d({...r,default:o}),catalog:c,allModels:u}),e.jsx(K,{label:"Opus (Most capable)",description:"For complex reasoning tasks",value:r.opus,onChange:o=>d({...r,opus:o}),catalog:c,allModels:u}),e.jsx(K,{label:"Sonnet (Balanced)",description:"Balance of speed and capability",value:r.sonnet,onChange:o=>d({...r,sonnet:o}),catalog:c,allModels:u}),e.jsx(K,{label:"Haiku (Fast)",description:"Quick responses for simple tasks",value:r.haiku,onChange:o=>d({...r,haiku:o}),catalog:c,allModels:u})]}),e.jsxs(Ns,{className:"gap-2 sm:gap-0",children:[e.jsx(w,{variant:"outline",onClick:n,children:"Cancel"}),i&&e.jsxs(w,{variant:"secondary",onClick:()=>i(r,h||void 0),disabled:l||!h.trim(),children:[l?e.jsx(q,{className:"w-4 h-4 mr-1 animate-spin"}):e.jsx(se,{className:"w-4 h-4 mr-1"}),"Save Preset"]}),e.jsxs(w,{onClick:()=>a(r,h||void 0),children:[e.jsx(te,{className:"w-4 h-4 mr-1"}),"Apply Preset"]})]})]})})}function Y({label:s,command:n}){return e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-muted-foreground",children:s}),e.jsxs("div",{className:"mt-1 flex gap-2",children:[e.jsx("code",{className:"flex-1 px-2 py-1.5 bg-muted rounded text-xs font-mono truncate",children:n}),e.jsx(We,{value:n,size:"icon",className:"h-6 w-6"})]})]})}function Gt({provider:s,displayName:n,data:t,authStatus:a}){return e.jsx(be,{className:"h-full",children:e.jsxs("div",{className:"p-4 space-y-6",children:[e.jsxs("div",{children:[e.jsxs("h3",{className:"text-sm font-medium flex items-center gap-2 mb-3",children:[e.jsx(tt,{className:"w-4 h-4"}),"Provider Information"]}),e.jsxs("div",{className:"space-y-3 bg-card rounded-lg border p-4 shadow-sm",children:[e.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-2 text-sm items-center",children:[e.jsx("span",{className:"font-medium text-muted-foreground",children:"Provider"}),e.jsx("span",{className:"font-mono",children:n})]}),t&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-2 text-sm items-center",children:[e.jsx("span",{className:"font-medium text-muted-foreground",children:"File Path"}),e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx("code",{className:"bg-muted px-1.5 py-0.5 rounded text-xs break-all",children:t.path}),e.jsx(We,{value:t.path,size:"icon",className:"h-5 w-5"})]})]}),e.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-2 text-sm items-center",children:[e.jsx("span",{className:"font-medium text-muted-foreground",children:"Last Modified"}),e.jsx("span",{className:"text-xs",children:new Date(t.mtime).toLocaleString()})]})]}),e.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-2 text-sm items-center",children:[e.jsx("span",{className:"font-medium text-muted-foreground",children:"Status"}),a.authenticated?e.jsxs(L,{variant:"outline",className:"w-fit text-green-600 border-green-200 bg-green-50",children:[e.jsx(at,{className:"w-3 h-3 mr-1"}),"Authenticated"]}):e.jsx(L,{variant:"outline",className:"w-fit text-muted-foreground",children:"Not connected"})]})]})]}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-medium mb-3",children:"Quick Usage"}),e.jsxs("div",{className:"space-y-3 bg-card rounded-lg border p-4 shadow-sm",children:[e.jsx(Y,{label:"Run with prompt",command:`ccs ${s} "your prompt"`}),e.jsx(Y,{label:"Change model",command:`ccs ${s} --config`}),e.jsx(Y,{label:"Add account",command:`ccs ${s} --add`}),e.jsx(Y,{label:"List accounts",command:`ccs ${s} --accounts`})]})]})]})})}const Kt={gemini:"/assets/providers/gemini-color.svg",codex:"/assets/providers/openai.svg",agy:"/assets/providers/agy.png",qwen:"/assets/providers/qwen-color.svg",iflow:"/assets/providers/iflow.png",kiro:"/assets/providers/kiro.png",ghcp:"/assets/providers/copilot.svg"},$t={gemini:{text:"text-blue-600",letter:"G"},claude:{text:"text-orange-600",letter:"C"},codex:{text:"text-emerald-600",letter:"X"},agy:{text:"text-violet-600",letter:"A"},qwen:{text:"text-cyan-600",letter:"Q"},iflow:{text:"text-indigo-600",letter:"i"},kiro:{text:"text-teal-600",letter:"K"},ghcp:{text:"text-green-600",letter:"C"}},qt={sm:{container:"w-6 h-6",icon:"w-4 h-4",text:"text-xs"},md:{container:"w-8 h-8",icon:"w-5 h-5",text:"text-sm"},lg:{container:"w-12 h-12",icon:"w-8 h-8",text:"text-lg"}};function Se({provider:s,className:n,size:t="md"}){const a=s.toLowerCase(),i=$t[a]||{text:"text-gray-600",letter:s[0]?.toUpperCase()||"?"},l=qt[t],c=Kt[a];return e.jsx("div",{className:T("flex items-center justify-center rounded-md",c&&"bg-white p-1",l.container,n),children:c?e.jsx("img",{src:c,alt:`${s} logo`,className:T(l.icon,"object-contain")}):e.jsx("span",{className:T("font-semibold",i.text,l.text),children:i.letter})})}function zt({displayName:s,logoProvider:n,provider:t,data:a,isLoading:i,hasChanges:l,isRawJsonValid:c,isSaving:u,isRemoteMode:r,port:d,onRefetch:h,onSave:x}){return e.jsxs("div",{className:"px-6 py-4 border-b bg-background flex items-center justify-between shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Se,{provider:n||t,size:"lg"}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h2",{className:"text-lg font-semibold",children:s}),r&&e.jsxs(L,{variant:"secondary",className:"text-xs gap-1 bg-blue-100 text-blue-700 dark:bg-blue-900/30 dark:text-blue-400",children:[e.jsx(ke,{className:"w-3 h-3"}),"Remote"]}),d&&e.jsxs(L,{variant:"outline",className:"text-xs gap-1 font-mono",children:[e.jsx(nt,{className:"w-3 h-3"}),":",d]}),!r&&a?.path&&e.jsx(L,{variant:"outline",className:"text-xs",children:a.path.replace(/^.*[\\/]/,"")})]}),r?e.jsx("p",{className:"text-xs text-blue-600 dark:text-blue-400 mt-0.5",children:"Traffic auto-routed to remote server"}):a&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:["Last modified: ",new Date(a.mtime).toLocaleString()]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(w,{variant:"ghost",size:"sm",onClick:h,disabled:i,children:e.jsx($,{className:`w-4 h-4 ${i?"animate-spin":""}`})}),e.jsx(w,{size:"sm",onClick:x,disabled:u||!l||!c,children:u?e.jsxs(e.Fragment,{children:[e.jsx(q,{className:"w-4 h-4 mr-1 animate-spin"}),"Saving..."]}):e.jsxs(e.Fragment,{children:[e.jsx(it,{className:"w-4 h-4 mr-1"}),"Save"]})})]})]})}function Bt({catalog:s,savedPresets:n,currentModel:t,opusModel:a,sonnetModel:i,haikuModel:l,providerModels:c,onApplyPreset:u,onUpdateEnvValue:r,onOpenCustomPreset:d,onDeletePreset:h,isDeletePending:x}){const g=s&&s.models.length>0||n.length>0;return e.jsxs(e.Fragment,{children:[g&&e.jsxs("div",{children:[e.jsxs("h3",{className:"text-sm font-medium mb-2 flex items-center gap-2",children:[e.jsx(J,{className:"w-4 h-4"}),"Presets"]}),e.jsx("p",{className:"text-xs text-muted-foreground mb-3",children:"Apply pre-configured model mappings"}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[s?.models.slice(0,4).map(o=>e.jsxs(w,{variant:"outline",size:"sm",className:"text-xs h-7 gap-1",onClick:()=>{const b=o.presetMapping||{default:o.id,opus:o.id,sonnet:o.id,haiku:o.id};u({ANTHROPIC_MODEL:b.default,ANTHROPIC_DEFAULT_OPUS_MODEL:b.opus,ANTHROPIC_DEFAULT_SONNET_MODEL:b.sonnet,ANTHROPIC_DEFAULT_HAIKU_MODEL:b.haiku})},children:[e.jsx(te,{className:"w-3 h-3"}),o.name]},o.id)),n.map(o=>e.jsxs("div",{className:"group relative",children:[e.jsxs(w,{variant:"secondary",size:"sm",className:"text-xs h-7 gap-1 pr-6",onClick:()=>{u({ANTHROPIC_MODEL:o.default,ANTHROPIC_DEFAULT_OPUS_MODEL:o.opus,ANTHROPIC_DEFAULT_SONNET_MODEL:o.sonnet,ANTHROPIC_DEFAULT_HAIKU_MODEL:o.haiku})},children:[e.jsx(se,{className:"w-3 h-3 fill-current"}),o.name]}),e.jsx(w,{variant:"ghost",size:"icon",className:"absolute right-0 top-0 h-7 w-5 opacity-0 group-hover:opacity-100 hover:text-destructive",onClick:b=>{b.stopPropagation(),h(o.name)},disabled:x,children:e.jsx(ae,{className:"w-3 h-3"})})]},o.name)),e.jsxs(w,{variant:"outline",size:"sm",className:"text-xs h-7 gap-1 border-primary/50 text-primary hover:bg-primary/10 hover:border-primary",onClick:d,children:[e.jsx(ns,{className:"w-3 h-3"}),"Custom"]})]})]}),e.jsx(Ae,{}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-medium mb-2",children:"Model Mapping"}),e.jsx("p",{className:"text-xs text-muted-foreground mb-4",children:"Configure which models to use for each tier"}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(K,{label:"Default Model",description:"Used when no specific tier is requested",value:t,onChange:o=>r("ANTHROPIC_MODEL",o),catalog:s,allModels:c}),e.jsx(K,{label:"Opus (Most capable)",description:"For complex reasoning tasks",value:a,onChange:o=>r("ANTHROPIC_DEFAULT_OPUS_MODEL",o),catalog:s,allModels:c}),e.jsx(K,{label:"Sonnet (Balanced)",description:"Balance of speed and capability",value:i,onChange:o=>r("ANTHROPIC_DEFAULT_SONNET_MODEL",o),catalog:s,allModels:c}),e.jsx(K,{label:"Haiku (Fast)",description:"Quick responses for simple tasks",value:l,onChange:o=>r("ANTHROPIC_DEFAULT_HAIKU_MODEL",o),catalog:s,allModels:c})]})]})]})}function Qt(s){return s<=20?"bg-destructive":s<=50?"bg-yellow-500":"bg-green-500"}function Ve(s){if(!s)return"";try{const n=new Date(s),a=new Date().getTime()-n.getTime();if(a<0)return"just now";const i=Math.floor(a/(1e3*60)),l=Math.floor(a/(1e3*60*60)),c=Math.floor(a/(1e3*60*60*24));return c>0?`${c}d ago`:l>0?`${l}h ago`:i>0?`${i}m ago`:"just now"}catch{return""}}function Jt(s){if(!s)return!1;try{const n=new Date(s);return new Date().getTime()-n.getTime()<3600*1e3}catch{return!1}}function Yt({account:s,onSetDefault:n,onRemove:t,onPauseToggle:a,isRemoving:i,isPausingAccount:l,privacyMode:c,showQuota:u}){const{data:r}=ws(u&&s.provider==="agy"),{data:d,isLoading:h}=bs(s.provider,s.id,u&&s.provider==="agy"),x=r?.accountStats?.[s.email||s.id]?.lastUsedAt,g=Jt(x),o=d?.success?ys(d.models):null,b=d?.success&&d.models.length>0?Cs(d.models):null;return e.jsxs("div",{className:T("flex flex-col gap-2 p-3 rounded-lg border transition-colors",s.isDefault?"border-primary/30 bg-primary/5":"border-border hover:bg-muted/30"),children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:T("flex items-center justify-center w-8 h-8 rounded-full",s.isDefault?"bg-primary/10":"bg-muted"),children:e.jsx(B,{className:"w-4 h-4"})}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:T("font-medium text-sm",c&&ue),children:s.email||s.id}),s.isDefault&&e.jsxs(L,{variant:"secondary",className:"text-[10px] h-4 px-1.5 gap-0.5",children:[e.jsx(se,{className:"w-2.5 h-2.5 fill-current"}),"Default"]}),s.tier&&s.tier!=="unknown"&&e.jsx(L,{variant:"outline",className:T("text-[10px] h-4 px-1.5 uppercase",s.tier==="paid"&&"border-blue-500 text-blue-600",s.tier==="free"&&"border-gray-400 text-gray-500"),children:s.tier}),s.paused&&e.jsxs(L,{variant:"outline",className:"text-[10px] h-4 px-1.5 border-yellow-500 text-yellow-600",children:[e.jsx(Re,{className:"w-2 h-2 mr-0.5"}),"Paused"]})]}),s.lastUsedAt&&e.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground mt-0.5",children:[e.jsx(X,{className:"w-3 h-3"}),"Last used: ",new Date(s.lastUsedAt).toLocaleDateString()]})]})]}),e.jsxs(ks,{children:[e.jsx(As,{asChild:!0,children:e.jsx(w,{variant:"ghost",size:"icon",className:"h-7 w-7",children:e.jsx(rt,{className:"w-4 h-4"})})}),e.jsxs(Ss,{align:"end",children:[!s.isDefault&&e.jsxs(ie,{onClick:n,children:[e.jsx(se,{className:"w-4 h-4 mr-2"}),"Set as default"]}),a&&e.jsx(ie,{onClick:()=>a(!s.paused),disabled:l,children:s.paused?e.jsxs(e.Fragment,{children:[e.jsx(ot,{className:"w-4 h-4 mr-2"}),l?"Resuming...":"Resume account"]}):e.jsxs(e.Fragment,{children:[e.jsx(Re,{className:"w-4 h-4 mr-2"}),l?"Pausing...":"Pause account"]})}),e.jsxs(ie,{className:"text-destructive focus:text-destructive",onClick:t,disabled:i,children:[e.jsx(is,{className:"w-4 h-4 mr-2"}),i?"Removing...":"Remove account"]})]})]})]}),u&&s.provider==="agy"&&e.jsx("div",{className:"pl-11",children:h?e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsx(q,{className:"w-3 h-3 animate-spin"}),e.jsx("span",{children:"Loading quota..."})]}):o!==null?e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("div",{className:"flex items-center gap-1.5 text-xs",children:g?e.jsxs(e.Fragment,{children:[e.jsx(lt,{className:"w-3 h-3 text-emerald-500"}),e.jsxs("span",{className:"text-emerald-600 dark:text-emerald-400",children:["Active · ",Ve(x)]})]}):x?e.jsxs(e.Fragment,{children:[e.jsx(X,{className:"w-3 h-3 text-muted-foreground"}),e.jsxs("span",{className:"text-muted-foreground",children:["Last used ",Ve(x)]})]}):e.jsxs(e.Fragment,{children:[e.jsx(ct,{className:"w-3 h-3 text-muted-foreground"}),e.jsx("span",{className:"text-muted-foreground",children:"Not used yet"})]})}),e.jsx(Xe,{children:e.jsxs(Ze,{children:[e.jsx(es,{asChild:!0,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ps,{value:o,className:"h-2 flex-1",indicatorClassName:Qt(o)}),e.jsxs("span",{className:"text-xs font-medium w-10 text-right",children:[o,"%"]})]})}),e.jsx(ss,{side:"bottom",className:"max-w-xs",children:e.jsxs("div",{className:"text-xs space-y-1",children:[e.jsx("p",{className:"font-medium",children:"Model Quotas:"}),Ms(d?.models||[]).map(A=>e.jsxs("div",{className:"flex justify-between gap-4",children:[e.jsx("span",{className:"truncate",children:A.displayName||A.name}),e.jsxs("span",{className:"font-mono",children:[A.percentage,"%"]})]},A.name)),b&&e.jsxs("div",{className:"flex items-center gap-1.5 mt-2 pt-2 border-t border-border/50",children:[e.jsx(X,{className:"w-3 h-3 text-blue-400"}),e.jsxs("span",{className:"text-blue-400 font-medium",children:["Resets ",Ts(b)]})]})]})})]})})]}):d?.error?e.jsx("div",{className:"text-xs text-muted-foreground",children:d.error}):null})]})}function Wt({accounts:s,onAddAccount:n,onSetDefault:t,onRemoveAccount:a,onPauseToggle:i,isRemovingAccount:l,isPausingAccount:c,privacyMode:u,showQuota:r,isKiro:d,kiroNoIncognito:h,onKiroNoIncognitoChange:x,kiroSettingsLoading:g}){return e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsxs("h3",{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(B,{className:"w-4 h-4"}),"Accounts",s.length>0&&e.jsx(L,{variant:"secondary",className:"text-xs",children:s.length})]}),e.jsxs(w,{variant:"default",size:"sm",className:"h-7 text-xs gap-1",onClick:n,children:[e.jsx(ns,{className:"w-3 h-3"}),"Add"]})]}),s.length>0?e.jsx("div",{className:"space-y-2",children:s.map(o=>e.jsx(Yt,{account:o,onSetDefault:()=>t(o.id),onRemove:()=>a(o.id),onPauseToggle:i?b=>i(o.id,b):void 0,isRemoving:l,isPausingAccount:c,privacyMode:u,showQuota:r},o.id))}):e.jsxs("div",{className:"py-6 text-center text-muted-foreground bg-muted/30 rounded-lg border border-dashed",children:[e.jsx(B,{className:"w-8 h-8 mx-auto mb-2 opacity-50"}),e.jsx("p",{className:"text-sm",children:"No accounts connected"}),e.jsx("p",{className:"text-xs opacity-70",children:"Add an account to get started"})]}),d&&x&&e.jsx("div",{className:"mt-3 pt-3 border-t border-dashed",children:e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(ke,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:"Use incognito"})]}),e.jsx(vt,{checked:!h,onCheckedChange:o=>x(!o),disabled:g,className:"scale-90"})]})})]})}function Xt({provider:s,catalog:n,savedPresets:t,currentModel:a,opusModel:i,sonnetModel:l,haikuModel:c,providerModels:u,onApplyPreset:r,onUpdateEnvValue:d,onOpenCustomPreset:h,onDeletePreset:x,isDeletePending:g,accounts:o,onAddAccount:b,onSetDefault:A,onRemoveAccount:v,onPauseToggle:O,isRemovingAccount:k,isPausingAccount:D,privacyMode:P,isRemoteMode:_}){const y=s==="kiro",[j,f]=p.useState(!0),[S,E]=p.useState(!0),[R,U]=p.useState(!1),m=p.useCallback(async()=>{if(y)try{E(!0);const N=(await W.config.get()).cliproxy;f(N?.kiro_no_incognito??!0)}catch{f(!0)}finally{E(!1)}},[y]),C=p.useCallback(async M=>{f(M),U(!0);try{const N=await W.config.get(),H=N.cliproxy??{};await W.config.update({...N,cliproxy:{...H,kiro_no_incognito:M}})}catch{f(!M)}finally{U(!1)}},[]);return p.useEffect(()=>{m()},[m]),e.jsx(be,{className:"flex-1",children:e.jsxs("div",{className:"p-4 space-y-6",children:[e.jsx(Bt,{catalog:n,savedPresets:t,currentModel:a,opusModel:i,sonnetModel:l,haikuModel:c,providerModels:u,onApplyPreset:r,onUpdateEnvValue:d,onOpenCustomPreset:h,onDeletePreset:x,isDeletePending:g}),e.jsx(Ae,{}),e.jsx(Wt,{accounts:o,onAddAccount:b,onSetDefault:A,onRemoveAccount:v,onPauseToggle:O,isRemovingAccount:k,isPausingAccount:D,privacyMode:P,showQuota:s==="agy"&&!_,isKiro:y,kiroNoIncognito:j,onKiroNoIncognitoChange:C,kiroSettingsLoading:S||R})]})})}function Ge({provider:s,displayName:n,authStatus:t,catalog:a,logoProvider:i,baseProvider:l,isRemoteMode:c,port:u,onAddAccount:r,onSetDefault:d,onRemoveAccount:h,onPauseToggle:x,isRemovingAccount:g,isPausingAccount:o}){const[b,A]=p.useState(!1),{privacyMode:v}=Je(),{data:O}=Ds(),{data:k}=Os(s),D=Es(),P=Is(),_=k?.presets||[],y=l||s,j=p.useMemo(()=>{if(!O?.models)return[];const G={gemini:["google"],agy:["antigravity"],codex:["openai"],qwen:["alibaba","qwen"],iflow:["iflow"],kiro:["kiro","aws"],ghcp:["github","copilot"]}[y.toLowerCase()]||[y.toLowerCase()];return O.models.filter(Oe=>G.some(gs=>Oe.owned_by.toLowerCase().includes(gs)))},[O,y]),{data:f,isLoading:S,refetch:E,rawJsonContent:R,rawJsonEdits:U,isRawJsonValid:m,hasChanges:C,currentModel:M,opusModel:N,sonnetModel:H,haikuModel:V,handleRawJsonChange:ne,updateEnvValue:ls,updateEnvValues:Pe,saveMutation:Me,conflictDialog:cs,handleConflictResolve:Te,missingRequiredFields:ds}=Ht(s),ms=t.accounts||[],{data:us}=me({queryKey:["auth-tokens-raw"],queryFn:async()=>{const I=await fetch("/api/settings/auth/tokens/raw");return I.ok?I.json():{apiKey:{value:"ccs-internal-managed"}}},staleTime:6e4}),De=us?.apiKey?.value??"ccs-internal-managed",xs=I=>{Pe({ANTHROPIC_BASE_URL:`http://127.0.0.1:${u??ce}/api/provider/${s}`,ANTHROPIC_AUTH_TOKEN:De,...I}),F.success(`Applied "${I.ANTHROPIC_MODEL?.split("/").pop()||"preset"}" preset`)},ps=(I,G)=>{Pe({ANTHROPIC_BASE_URL:`http://127.0.0.1:${u??ce}/api/provider/${s}`,ANTHROPIC_AUTH_TOKEN:De,ANTHROPIC_MODEL:I.default,ANTHROPIC_DEFAULT_OPUS_MODEL:I.opus,ANTHROPIC_DEFAULT_SONNET_MODEL:I.sonnet,ANTHROPIC_DEFAULT_HAIKU_MODEL:I.haiku}),F.success(`Applied ${G?`"${G}"`:"custom"} preset`),A(!1)},hs=(I,G)=>{if(!G){F.error("Please enter a preset name to save");return}D.mutate({profile:s,data:{name:G,...I}}),A(!1)};return e.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[e.jsx(zt,{provider:s,displayName:n,logoProvider:i,data:f,isLoading:S,hasChanges:C,isRawJsonValid:m,isSaving:Me.isPending,isRemoteMode:c,port:u,onRefetch:E,onSave:()=>Me.mutate()}),S?e.jsxs("div",{className:"flex-1 flex items-center justify-center",children:[e.jsx(q,{className:"w-8 h-8 animate-spin text-muted-foreground"}),e.jsx("span",{className:"ml-3 text-muted-foreground",children:"Loading settings..."})]}):e.jsxs("div",{className:"flex-1 grid grid-cols-[40%_60%] divide-x overflow-hidden",children:[e.jsx("div",{className:"flex flex-col overflow-hidden bg-muted/5",children:e.jsxs(_s,{defaultValue:"config",className:"h-full flex flex-col",children:[e.jsx("div",{className:"px-4 pt-4 shrink-0",children:e.jsxs(Ls,{className:"w-full",children:[e.jsx(_e,{value:"config",className:"flex-1",children:"Model Config"}),e.jsx(_e,{value:"info",className:"flex-1",children:"Info & Usage"})]})}),e.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[e.jsx(Le,{value:"config",className:"flex-1 mt-0 border-0 p-0 data-[state=inactive]:hidden flex flex-col overflow-hidden",children:e.jsx(Xt,{provider:s,catalog:a,savedPresets:_,currentModel:M,opusModel:N,sonnetModel:H,haikuModel:V,providerModels:j,onApplyPreset:xs,onUpdateEnvValue:ls,onOpenCustomPreset:()=>A(!0),onDeletePreset:I=>P.mutate({profile:s,name:I}),isDeletePending:P.isPending,accounts:ms,onAddAccount:r,onSetDefault:d,onRemoveAccount:h,onPauseToggle:x,isRemovingAccount:g,isPausingAccount:o,privacyMode:v,isRemoteMode:c})}),e.jsx(Le,{value:"info",className:"h-full mt-0 border-0 p-0 data-[state=inactive]:hidden",children:e.jsx(Gt,{provider:s,displayName:n,data:f,authStatus:t})})]})]})}),e.jsxs("div",{className:"flex flex-col overflow-hidden",children:[e.jsxs("div",{className:"px-6 py-2 bg-muted/30 border-b flex items-center gap-2 shrink-0 h-[45px]",children:[e.jsx(dt,{className:"w-4 h-4 text-muted-foreground"}),e.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:"Raw Configuration (JSON)"})]}),e.jsx(Rs,{rawJsonContent:R,isRawJsonValid:m,rawJsonEdits:U,onRawJsonChange:ne,profileEnv:f?.settings?.env,missingRequiredFields:ds})]})]}),e.jsx(jt,{open:cs,title:"File Modified Externally",description:"This settings file was modified by another process. Overwrite with your changes or discard?",confirmText:"Overwrite",variant:"destructive",onConfirm:()=>Te(!0),onCancel:()=>Te(!1)}),e.jsx(Vt,{open:b,onClose:()=>A(!1),currentValues:{default:M||"",opus:N||"",sonnet:H||"",haiku:V||""},onApply:ps,onSave:hs,isSaving:D.isPending,catalog:a,allModels:j})]})}function oe(s,n){const t=s.replace(/-\d+$/,"").split(".").map(Number),a=n.replace(/-\d+$/,"").split(".").map(Number);for(let i=0;i<3;i++){if((t[i]||0)>(a[i]||0))return!0;if((t[i]||0)<(a[i]||0))return!1}return!1}function Zt(s){if(!s)return"";const n=new Date(s).getTime(),a=Date.now()-n,i=Math.floor(a/(1e3*60*60)),l=Math.floor(a%(1e3*60*60)/(1e3*60));return i>0?`${i}h ${l}m`:`${l}m`}function ea(s){if(!s)return"";const n=Date.now()-s,t=Math.floor(n/(1e3*60)),a=Math.floor(n/(1e3*60*60));return t<1?"just now":t<60?`${t}m ago`:`${a}h ago`}function le({icon:s,tooltip:n,onClick:t,disabled:a,isPending:i,className:l,variant:c="ghost"}){return e.jsxs(Ze,{children:[e.jsx(es,{asChild:!0,children:e.jsx(w,{variant:c==="destructive-ghost"?"ghost":c,size:"sm",className:T("h-7 w-7 p-0",c==="destructive-ghost"&&"hover:bg-destructive/10 hover:text-destructive hover:border-destructive/30",l),onClick:t,disabled:a,children:i?e.jsx($,{className:"w-3.5 h-3.5 animate-spin"}):e.jsx(s,{className:"w-3.5 h-3.5"})})}),e.jsx(ss,{side:"bottom",className:"text-xs",children:n})]})}function sa(){const{data:s,isLoading:n}=Fs(),{data:t}=Us(),{data:a,isLoading:i}=Hs(),l=Vs(),c=Gs(),u=Ks(),r=$s(),[d,h]=p.useState(!1),[x,g]=p.useState(""),[o,b]=p.useState(!1),[A,v]=p.useState(null),{data:O}=me({queryKey:["cliproxy-server-config"],queryFn:()=>W.cliproxyServer.get(),staleTime:3e4}),k=O?.remote,D=k?.enabled&&k?.host,P=s?.running??!1,_=l.isPending||c.isPending||u.isPending||r.isPending,y=t?.hasUpdate??!1,j=t?.isStable===!1,f=t?.currentVersion,S=j?t?.maxStableVersion||a?.latestStable:t?.latestVersion,E=C=>{if(!C)return;const M=a?.maxStableVersion||"6.6.80";if(oe(C,M)){v(C),b(!0);return}r.mutate({version:C})},R=()=>{A&&r.mutate({version:A,force:!0}),b(!1),v(null)},U=()=>{b(!1),v(null)},m=D?(()=>{const C=k.protocol||"http",M=k.port||(C==="https"?443:80);return C==="https"&&M===443||C==="http"&&M===80?k.host:`${k.host}:${M}`})():null;return D?e.jsxs("div",{className:T("rounded-lg border p-3 transition-colors","border-blue-500/30 bg-blue-500/5"),children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ke,{className:"w-4 h-4 text-blue-500"}),e.jsx("span",{className:"text-sm font-medium",children:"Remote Proxy"}),e.jsx(L,{variant:"secondary",className:"text-[10px] h-4 px-1.5 bg-blue-100 text-blue-700 dark:bg-blue-900/30 dark:text-blue-400",children:"Active"})]}),e.jsx(mt,{className:"w-3 h-3 text-blue-600"})]}),e.jsxs("div",{className:"mt-2 text-xs text-muted-foreground",children:[e.jsx("div",{className:"flex items-center gap-1 mb-1",children:e.jsx("span",{className:"font-mono",children:m})}),e.jsx("p",{className:"text-[10px] text-muted-foreground/70 leading-tight",children:"Traffic auto-routed to remote server"})]})]}):e.jsx(Xe,{delayDuration:300,children:e.jsxs("div",{className:T("rounded-lg border p-3 transition-colors",P?"border-green-500/30 bg-green-500/5":"border-muted bg-muted/30"),children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:T("w-2 h-2 rounded-full",P?"bg-green-500 animate-pulse":"bg-muted-foreground/30")}),e.jsx("span",{className:"text-sm font-medium",children:"CLIProxy Plus"})]}),e.jsx("div",{className:"flex items-center gap-1",children:n?e.jsx($,{className:"w-3 h-3 animate-spin text-muted-foreground"}):P?e.jsxs(e.Fragment,{children:[e.jsx(le,{icon:ut,tooltip:"Restart",onClick:()=>u.mutate(),disabled:_,isPending:u.isPending}),e.jsx(le,{icon:xt,tooltip:"Stop",onClick:()=>c.mutate(),disabled:_,isPending:c.isPending,variant:"destructive-ghost"}),e.jsx(le,{icon:d?ae:pt,tooltip:d?"Close":"Version settings",onClick:()=>h(!d),className:d?"bg-muted":void 0})]}):e.jsx(Fe,{className:"w-3 h-3 text-muted-foreground"})})]}),f&&e.jsxs("div",{className:"mt-1.5 flex items-center gap-2",children:[e.jsxs("span",{className:T("text-xs font-mono text-muted-foreground",j&&"text-amber-600 dark:text-amber-400"),children:["v",f]}),(y||j)&&S&&e.jsxs(L,{variant:"secondary",className:T("text-[10px] h-4 px-1.5 gap-0.5 cursor-pointer transition-colors",j?"bg-amber-100 text-amber-700 hover:bg-amber-200 dark:bg-amber-900/30 dark:text-amber-400 dark:hover:bg-amber-900/50":"bg-green-100 text-green-700 hover:bg-green-200 dark:bg-green-900/30 dark:text-green-400 dark:hover:bg-green-900/50"),onClick:()=>E(S),title:`Click to ${j?"downgrade":"update"}`,children:[j?e.jsx(ht,{className:"w-2.5 h-2.5"}):e.jsx(gt,{className:"w-2.5 h-2.5"}),S]})]}),P&&s&&e.jsxs("div",{className:"mt-2 flex items-center gap-4 text-xs text-muted-foreground",children:[e.jsxs("span",{className:"flex items-center gap-1",children:["Port ",s.port]}),s.sessionCount!==void 0&&s.sessionCount>0&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(ft,{className:"w-3 h-3"}),s.sessionCount," session",s.sessionCount!==1?"s":""]}),s.startedAt&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(X,{className:"w-3 h-3"}),Zt(s.startedAt)]})]}),P&&e.jsx(qs,{open:d,onOpenChange:h,children:e.jsxs(zs,{className:"mt-3 pt-3 border-t border-muted",children:[e.jsx("h4",{className:"text-xs font-medium text-muted-foreground mb-3",children:"Version Management"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(pe,{value:x,onValueChange:g,disabled:i,children:[e.jsx(he,{className:"h-8 text-xs flex-1",children:e.jsx(ge,{placeholder:"Select version to install..."})}),e.jsx(fe,{children:a?.versions.slice(0,20).map(C=>{const M=a?.maxStableVersion&&oe(C,a.maxStableVersion);return e.jsx(ee,{value:C,className:"text-xs",children:e.jsxs("span",{className:"flex items-center gap-2",children:["v",C,C===a.latestStable&&e.jsx("span",{className:"text-green-600 dark:text-green-400",children:"(stable)"}),M&&e.jsx("span",{className:"text-amber-600 dark:text-amber-400",children:"⚠"})]})},C)})})]}),e.jsxs(w,{variant:"outline",size:"sm",className:"h-8 text-xs gap-1.5 px-3",onClick:()=>E(x),disabled:r.isPending||!x,children:[r.isPending?e.jsx($,{className:"w-3.5 h-3.5 animate-spin"}):e.jsx(as,{className:"w-3.5 h-3.5"}),"Install"]})]}),x&&a?.maxStableVersion&&oe(x,a.maxStableVersion)&&e.jsxs("div",{className:"mt-2 flex items-center gap-1.5 text-[11px] text-amber-600 dark:text-amber-400",children:[e.jsx(Ue,{className:"w-3.5 h-3.5 flex-shrink-0"}),e.jsxs("span",{children:["Versions above ",a.maxStableVersion," have known issues"]})]}),t?.checkedAt&&e.jsxs("div",{className:"mt-2 text-[10px] text-muted-foreground/60",children:["Last checked ",ea(t.checkedAt)]})]})}),!P&&e.jsxs("div",{className:"mt-2 flex items-center justify-between",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:"Not running"}),e.jsxs(w,{variant:"outline",size:"sm",className:"h-7 text-xs gap-1",onClick:()=>l.mutate(),disabled:l.isPending,children:[l.isPending?e.jsx($,{className:"w-3 h-3 animate-spin"}):e.jsx(Fe,{className:"w-3 h-3"}),"Start"]})]}),e.jsx(Nt,{open:o,onOpenChange:b,children:e.jsxs(wt,{children:[e.jsxs(bt,{children:[e.jsxs(yt,{className:"flex items-center gap-2",children:[e.jsx(Ue,{className:"w-5 h-5 text-amber-500"}),"Install Unstable Version?"]}),e.jsxs(Ct,{className:"space-y-2",children:[e.jsxs("p",{children:["You are about to install ",e.jsxs("strong",{children:["v",A]}),", which is above the maximum stable version"," ",e.jsxs("strong",{children:["v",a?.maxStableVersion||"6.6.80"]}),"."]}),e.jsx("p",{className:"text-amber-600 dark:text-amber-400",children:"This version has known stability issues and may cause unexpected behavior."}),e.jsx("p",{children:"Are you sure you want to proceed?"})]})]}),e.jsxs(kt,{children:[e.jsx(At,{onClick:U,children:"Cancel"}),e.jsx(St,{onClick:R,className:"bg-amber-500 hover:bg-amber-600 text-white",children:"Install Anyway"})]})]})})]})})}function ta({status:s,isSelected:n,onSelect:t}){const a=s.accounts?.length||0;return e.jsxs("button",{className:T("w-full flex items-center gap-3 px-3 py-2.5 rounded-lg transition-colors cursor-pointer text-left",n?"bg-primary/10 border border-primary/20":"hover:bg-muted border border-transparent"),onClick:t,children:[e.jsx(Se,{provider:s.provider,size:"md"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-medium text-sm truncate",children:s.displayName}),a>0&&e.jsx(L,{variant:"secondary",className:"text-[10px] h-4 px-1",children:a})]}),e.jsx("div",{className:"flex items-center gap-1.5 mt-0.5",children:s.authenticated?e.jsxs(e.Fragment,{children:[e.jsx(z,{className:"w-3 h-3 text-green-600"}),e.jsx("span",{className:"text-xs text-green-600",children:"Connected"})]}):e.jsxs(e.Fragment,{children:[e.jsx(ae,{className:"w-3 h-3 text-muted-foreground"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"Not connected"})]})})]})]})}function aa({variant:s,parentAuth:n,isSelected:t,onSelect:a,onDelete:i,isDeleting:l}){return e.jsxs("button",{className:T("group w-full flex items-center gap-3 px-3 py-2 rounded-lg transition-colors cursor-pointer text-left pl-6",t?"bg-primary/10 border border-primary/20":"hover:bg-muted border border-transparent"),onClick:a,children:[e.jsxs("div",{className:"relative",children:[e.jsx(Se,{provider:s.provider,size:"sm"}),e.jsx(rs,{className:"w-2.5 h-2.5 absolute -bottom-0.5 -right-0.5 text-muted-foreground"})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-medium text-sm truncate",children:s.name}),e.jsx(L,{variant:"outline",className:"text-[9px] h-4 px-1",children:"variant"})]}),e.jsx("div",{className:"flex items-center gap-1.5 mt-0.5",children:n?.authenticated?e.jsxs(e.Fragment,{children:[e.jsx(z,{className:"w-3 h-3 text-green-600"}),e.jsxs("span",{className:"text-xs text-muted-foreground truncate",children:["via ",s.provider]})]}):e.jsxs(e.Fragment,{children:[e.jsx(ae,{className:"w-3 h-3 text-muted-foreground"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"Parent not connected"})]})})]}),e.jsx(w,{variant:"ghost",size:"icon",className:"h-6 w-6 opacity-0 group-hover:opacity-100 hover:text-destructive",onClick:c=>{c.stopPropagation(),i()},disabled:l,children:e.jsx(is,{className:"w-3 h-3"})})]})}function na({onSetup:s}){return e.jsx("div",{className:"flex-1 flex items-center justify-center bg-muted/20",children:e.jsxs("div",{className:"text-center max-w-md px-8",children:[e.jsx("div",{className:"w-16 h-16 rounded-full bg-muted flex items-center justify-center mx-auto mb-6",children:e.jsx(te,{className:"w-8 h-8 text-muted-foreground"})}),e.jsx("h2",{className:"text-xl font-semibold mb-2",children:"CCS Profile Manager"}),e.jsx("p",{className:"text-muted-foreground mb-4",children:"Manage OAuth authentication, account preferences, and model selection for CLIProxy providers. Configure how CCS routes requests to different AI backends."}),e.jsxs("p",{className:"text-xs text-muted-foreground mb-6",children:["For live usage stats and real-time monitoring, visit the"," ",e.jsx("a",{href:"/cliproxy/control-panel",className:"text-primary hover:underline",children:"Control Panel"}),"."]}),e.jsxs(w,{onClick:s,className:"gap-2",children:[e.jsx(J,{className:"w-4 h-4"}),"Quick Setup"]})]})})}function fa(){const s=Ke(),{data:n,isLoading:t}=ze(),{data:a,isFetching:i}=Bs(),l=Qs(),c=Js(),u=Ys(),r=Ws(),d=Xs(),[h,x]=p.useState(null),[g,o]=p.useState(null),[b,A]=p.useState(!1),[v,O]=p.useState(null),k=p.useMemo(()=>n?.authStatus||[],[n?.authStatus]),D=n?.source==="remote",P=p.useMemo(()=>a?.variants||[],[a?.variants]),_=p.useMemo(()=>g?null:h&&k.some(m=>m.provider===h)?h:k.length>0?k[0].provider:null,[h,g,k]),y=k.find(m=>m.provider===_),j=P.find(m=>m.name===g),f=j?k.find(m=>m.provider===j.provider):void 0,S=()=>{s.invalidateQueries({queryKey:["cliproxy"]}),s.invalidateQueries({queryKey:["cliproxy-auth"]})},E=(m,C,M)=>{u.isPending||r.isPending||(M?u.mutate({provider:m,accountId:C}):r.mutate({provider:m,accountId:C}))},R=m=>{x(m),o(null)},U=m=>{o(m),x(null)};return e.jsxs("div",{className:"h-[calc(100vh-100px)] flex",children:[e.jsxs("div",{className:"w-80 border-r flex flex-col bg-muted/30",children:[e.jsxs("div",{className:"p-4 border-b bg-background",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(te,{className:"w-5 h-5 text-primary"}),e.jsx("h1",{className:"font-semibold",children:"CLIProxy Plus"})]}),e.jsx(w,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:S,disabled:i,children:e.jsx($,{className:T("w-4 h-4",i&&"animate-spin")})})]}),e.jsx("p",{className:"text-xs text-muted-foreground mb-3",children:"CCS-level account management"}),e.jsxs(w,{variant:"default",size:"sm",className:"w-full gap-2",onClick:()=>A(!0),children:[e.jsx(J,{className:"w-4 h-4"}),"Quick Setup"]})]}),e.jsx(be,{className:"flex-1",children:e.jsxs("div",{className:"p-2",children:[e.jsx("div",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide px-3 py-2",children:"Providers"}),t?e.jsx("div",{className:"space-y-2 px-2",children:[1,2,3,4].map(m=>e.jsx(Zs,{className:"h-14 w-full rounded-lg"},m))}):e.jsx("div",{className:"space-y-1",children:k.map(m=>e.jsx(ta,{status:m,isSelected:_===m.provider,onSelect:()=>R(m.provider)},m.provider))}),P.length>0&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide px-3 py-2 mt-4 flex items-center gap-1.5",children:[e.jsx(rs,{className:"w-3 h-3"}),"Variants"]}),e.jsx("div",{className:"space-y-1",children:P.map(m=>e.jsx(aa,{variant:m,parentAuth:k.find(C=>C.provider===m.provider),isSelected:g===m.name,onSelect:()=>U(m.name),onDelete:()=>d.mutate(m.name),isDeleting:d.isPending},m.name))})]})]})}),e.jsx("div",{className:"p-3 border-t",children:e.jsx(sa,{})}),e.jsx("div",{className:"p-3 border-t bg-background text-xs text-muted-foreground",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{children:[k.length," provider",k.length!==1?"s":""]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(z,{className:"w-3 h-3 text-green-600"}),k.filter(m=>m.authenticated).length," connected"]})]})})]}),e.jsx("div",{className:"flex-1 flex flex-col min-w-0 bg-background",children:j&&f?e.jsx(Ge,{provider:j.name,displayName:`${j.name} (${j.provider} variant)`,authStatus:f,catalog:Q[j.provider],logoProvider:j.provider,baseProvider:j.provider,isRemoteMode:D,port:j.port,onAddAccount:()=>O({provider:j.provider,displayName:f.displayName,isFirstAccount:(f.accounts?.length||0)===0}),onSetDefault:m=>l.mutate({provider:j.provider,accountId:m}),onRemoveAccount:m=>c.mutate({provider:j.provider,accountId:m}),onPauseToggle:(m,C)=>E(j.provider,m,C),isRemovingAccount:c.isPending,isPausingAccount:u.isPending||r.isPending}):y?e.jsx(Ge,{provider:y.provider,displayName:y.displayName,authStatus:y,catalog:Q[y.provider],isRemoteMode:D,onAddAccount:()=>O({provider:y.provider,displayName:y.displayName,isFirstAccount:(y.accounts?.length||0)===0}),onSetDefault:m=>l.mutate({provider:y.provider,accountId:m}),onRemoveAccount:m=>c.mutate({provider:y.provider,accountId:m}),onPauseToggle:(m,C)=>E(y.provider,m,C),isRemovingAccount:c.isPending,isPausingAccount:u.isPending||r.isPending}):e.jsx(na,{onSetup:()=>A(!0)})}),e.jsx(Lt,{open:b,onClose:()=>A(!1)}),e.jsx(Rt,{open:v!==null,onClose:()=>O(null),provider:v?.provider||"",displayName:v?.displayName||"",isFirstAccount:v?.isFirstAccount||!1})]})}export{fa as CliproxyPage};
@@ -1 +0,0 @@
1
- import{r as s}from"./react-vendor-CNOkPC89.js";const _=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),M=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(a,c,o)=>o?o.toUpperCase():c.toLowerCase()),d=t=>{const a=M(t);return a.charAt(0).toUpperCase()+a.slice(1)},r=(...t)=>t.filter((a,c,o)=>!!a&&a.trim()!==""&&o.indexOf(a)===c).join(" ").trim(),x=t=>{for(const a in t)if(a.startsWith("aria-")||a==="role"||a==="title")return!0};var m={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const v=s.forwardRef(({color:t="currentColor",size:a=24,strokeWidth:c=2,absoluteStrokeWidth:o,className:y="",children:n,iconNode:k,...h},i)=>s.createElement("svg",{ref:i,...m,width:a,height:a,stroke:t,strokeWidth:o?Number(c)*24/Number(a):c,className:r("lucide",y),...!n&&!x(h)&&{"aria-hidden":"true"},...h},[...k.map(([p,l])=>s.createElement(p,l)),...Array.isArray(n)?n:[n]]));const e=(t,a)=>{const c=s.forwardRef(({className:o,...y},n)=>s.createElement(v,{ref:n,iconNode:a,className:r(`lucide-${_(d(t))}`,`lucide-${t}`,o),...y}));return c.displayName=d(t),c};const w=[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]],y2=e("activity",w);const f=[["path",{d:"M17 7 7 17",key:"15tmo1"}],["path",{d:"M17 17H7V7",key:"1org7z"}]],h2=e("arrow-down-left",f);const g=[["path",{d:"m7 7 10 10",key:"1fmybs"}],["path",{d:"M17 7v10H7",key:"6fjiku"}]],d2=e("arrow-down-right",g);const $=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],r2=e("arrow-down",$);const N=[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]],k2=e("arrow-left",N);const u=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],i2=e("arrow-right",u);const z=[["path",{d:"M7 7h10v10",key:"1tivn9"}],["path",{d:"M7 17 17 7",key:"1vkiza"}]],p2=e("arrow-up-right",z);const b=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],l2=e("arrow-up",b);const C=[["path",{d:"M12 7v14",key:"1akyts"}],["path",{d:"M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z",key:"ruj8y"}]],_2=e("book-open",C);const j=[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]],M2=e("bot",j);const q=[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}]],x2=e("calendar",q);const A=[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"M18 17V9",key:"2bz60n"}],["path",{d:"M13 17V5",key:"1frdt8"}],["path",{d:"M8 17v-3",key:"17ska0"}]],m2=e("chart-column",A);const H=[["path",{d:"M21 12c.552 0 1.005-.449.95-.998a10 10 0 0 0-8.953-8.951c-.55-.055-.998.398-.998.95v8a1 1 0 0 0 1 1z",key:"pzmjnu"}],["path",{d:"M21.21 15.89A10 10 0 1 1 8 2.83",key:"k2fpak"}]],v2=e("chart-pie",H);const V=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],w2=e("check",V);const L=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],f2=e("chevron-down",L);const S=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],g2=e("chevron-left",S);const R=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],$2=e("chevron-right",R);const P=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],N2=e("chevron-up",P);const E=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]],u2=e("circle-alert",E);const B=[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],z2=e("circle-check-big",B);const D=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],b2=e("circle-check",D);const U=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]],C2=e("circle-question-mark",U);const O=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]],j2=e("circle-x",O);const G=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],q2=e("circle",G);const W=[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],A2=e("clock",W);const F=[["path",{d:"M17.5 19H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z",key:"p7xjir"}]],H2=e("cloud",F);const T=[["path",{d:"m18 16 4-4-4-4",key:"1inbqp"}],["path",{d:"m6 8-4 4 4 4",key:"15zrgr"}],["path",{d:"m14.5 4-5 16",key:"e7oirm"}]],V2=e("code-xml",T);const Z=[["path",{d:"m16 18 6-6-6-6",key:"eg8j8"}],["path",{d:"m8 6-6 6 6 6",key:"ppft3o"}]],L2=e("code",Z);const I=[["circle",{cx:"8",cy:"8",r:"6",key:"3yglwk"}],["path",{d:"M18.09 10.37A6 6 0 1 1 10.34 18",key:"t5s6rm"}],["path",{d:"M7 6h1v4",key:"1obek4"}],["path",{d:"m16.71 13.88.7.71-2.82 2.82",key:"1rbuyh"}]],S2=e("coins",I);const K=[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]],R2=e("copy",K);const X=[["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M17 20v2",key:"1rnc9c"}],["path",{d:"M17 2v2",key:"11trls"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M2 17h2",key:"7oei6x"}],["path",{d:"M2 7h2",key:"asdhe0"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"M20 17h2",key:"1fpfkl"}],["path",{d:"M20 7h2",key:"1o8tra"}],["path",{d:"M7 20v2",key:"4gnj0m"}],["path",{d:"M7 2v2",key:"1i4yhu"}],["rect",{x:"4",y:"4",width:"16",height:"16",rx:"2",key:"1vbyd7"}],["rect",{x:"8",y:"8",width:"8",height:"8",rx:"1",key:"z9xiuo"}]],P2=e("cpu",X);const Q=[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5",key:"1wlel7"}],["path",{d:"M3 12A9 3 0 0 0 21 12",key:"mv7ke4"}]],E2=e("database",Q);const J=[["line",{x1:"12",x2:"12",y1:"2",y2:"22",key:"7eqyqh"}],["path",{d:"M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6",key:"1b0p4s"}]],B2=e("dollar-sign",J);const Y=[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]],D2=e("download",Y);const e1=[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"19",cy:"12",r:"1",key:"1wjl8i"}],["circle",{cx:"5",cy:"12",r:"1",key:"1pcz8c"}]],U2=e("ellipsis",e1);const a1=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]],O2=e("external-link",a1);const t1=[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],G2=e("eye-off",t1);const c1=[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],W2=e("eye",c1);const o1=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 12a1 1 0 0 0-1 1v1a1 1 0 0 1-1 1 1 1 0 0 1 1 1v1a1 1 0 0 0 1 1",key:"1oajmo"}],["path",{d:"M14 18a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1 1 1 0 0 1-1-1v-1a1 1 0 0 0-1-1",key:"mpwhp6"}]],F2=e("file-braces",o1);const n1=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 12.5 8 15l2 2.5",key:"1tg20x"}],["path",{d:"m14 12.5 2 2.5-2 2.5",key:"yinavb"}]],T2=e("file-code",n1);const s1=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]],Z2=e("file-exclamation-point",s1);const y1=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]],I2=e("file-text",y1);const h1=[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]],K2=e("folder-open",h1);const d1=[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]],X2=e("gauge",d1);const r1=[["line",{x1:"6",x2:"6",y1:"3",y2:"15",key:"17qcm7"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M18 9a9 9 0 0 1-9 9",key:"n2h4wq"}]],Q2=e("git-branch",r1);const k1=[["path",{d:"M15 22v-4a4.8 4.8 0 0 0-1-3.5c3 0 6-2 6-5.5.08-1.25-.27-2.48-1-3.5.28-1.15.28-2.35 0-3.5 0 0-1 0-3 1.5-2.64-.5-5.36-.5-8 0C6 2 5 2 5 2c-.3 1.15-.3 2.35 0 3.5A5.403 5.403 0 0 0 4 9c0 3.5 3 5.5 6 5.5-.39.49-.68 1.05-.85 1.65-.17.6-.22 1.23-.15 1.85v4",key:"tonef"}],["path",{d:"M9 18c-4.51 2-5-2-7-2",key:"9comsn"}]],J2=e("github",k1);const i1=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]],Y2=e("globe",i1);const p1=[["circle",{cx:"12",cy:"9",r:"1",key:"124mty"}],["circle",{cx:"19",cy:"9",r:"1",key:"1ruzo2"}],["circle",{cx:"5",cy:"9",r:"1",key:"1a8b28"}],["circle",{cx:"12",cy:"15",r:"1",key:"1e56xg"}],["circle",{cx:"19",cy:"15",r:"1",key:"1a92ep"}],["circle",{cx:"5",cy:"15",r:"1",key:"5r1jwy"}]],e0=e("grip-horizontal",p1);const l1=[["circle",{cx:"9",cy:"12",r:"1",key:"1vctgf"}],["circle",{cx:"9",cy:"5",r:"1",key:"hp0tcf"}],["circle",{cx:"9",cy:"19",r:"1",key:"fkjjf6"}],["circle",{cx:"15",cy:"12",r:"1",key:"1tmaij"}],["circle",{cx:"15",cy:"5",r:"1",key:"19l28e"}],["circle",{cx:"15",cy:"19",r:"1",key:"f4zoj3"}]],a0=e("grip-vertical",l1);const _1=[["path",{d:"M2 9.5a5.5 5.5 0 0 1 9.591-3.676.56.56 0 0 0 .818 0A5.49 5.49 0 0 1 22 9.5c0 2.29-1.5 4-3 5.5l-5.492 5.313a2 2 0 0 1-3 .019L5 15c-1.5-1.5-3-3.2-3-5.5",key:"mvr1a0"}]],t0=e("heart",_1);const M1=[["path",{d:"M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8",key:"5wwlr5"}],["path",{d:"M3 10a2 2 0 0 1 .709-1.528l7-6a2 2 0 0 1 2.582 0l7 6A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z",key:"r6nss1"}]],c0=e("house",M1);const x1=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],o0=e("info",x1);const m1=[["path",{d:"M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z",key:"1s6t7t"}],["circle",{cx:"16.5",cy:"7.5",r:".5",fill:"currentColor",key:"w0ekpg"}]],n0=e("key-round",m1);const v1=[["path",{d:"m15.5 7.5 2.3 2.3a1 1 0 0 0 1.4 0l2.1-2.1a1 1 0 0 0 0-1.4L19 4",key:"g0fldk"}],["path",{d:"m21 2-9.6 9.6",key:"1j0ho8"}],["circle",{cx:"7.5",cy:"15.5",r:"5.5",key:"yqb3hr"}]],s0=e("key",v1);const w1=[["path",{d:"M18 5a2 2 0 0 1 2 2v8.526a2 2 0 0 0 .212.897l1.068 2.127a1 1 0 0 1-.9 1.45H3.62a1 1 0 0 1-.9-1.45l1.068-2.127A2 2 0 0 0 4 15.526V7a2 2 0 0 1 2-2z",key:"1pdavp"}],["path",{d:"M20.054 15.987H3.946",key:"14rxg9"}]],y0=e("laptop",w1);const f1=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],h0=e("loader-circle",f1);const g1=[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]],d0=e("lock",g1);const $1=[["path",{d:"m16 17 5-5-5-5",key:"1bji2h"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}]],r0=e("log-out",$1);const N1=[["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["line",{x1:"8",x2:"16",y1:"21",y2:"21",key:"1svkeh"}],["line",{x1:"12",x2:"12",y1:"17",y2:"21",key:"vw1qmm"}]],k0=e("monitor",N1);const u1=[["path",{d:"M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401",key:"kfwtm"}]],i0=e("moon",u1);const z1=[["rect",{x:"16",y:"16",width:"6",height:"6",rx:"1",key:"4q2zg0"}],["rect",{x:"2",y:"16",width:"6",height:"6",rx:"1",key:"8cvhb9"}],["rect",{x:"9",y:"2",width:"6",height:"6",rx:"1",key:"1egb70"}],["path",{d:"M5 16v-3a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v3",key:"1jsf9p"}],["path",{d:"M12 12V8",key:"2874zd"}]],p0=e("network",z1);const b1=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}]],l0=e("panel-left",b1);const C1=[["rect",{x:"14",y:"3",width:"5",height:"18",rx:"1",key:"kaeet6"}],["rect",{x:"5",y:"3",width:"5",height:"18",rx:"1",key:"1wsw3u"}]],_0=e("pause",C1);const j1=[["path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z",key:"10ikf1"}]],M0=e("play",j1);const q1=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],x0=e("plus",q1);const A1=[["path",{d:"M18.36 6.64A9 9 0 0 1 20.77 15",key:"dxknvb"}],["path",{d:"M6.16 6.16a9 9 0 1 0 12.68 12.68",key:"1x7qb5"}],["path",{d:"M12 2v4",key:"3427ic"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],m0=e("power-off",A1);const H1=[["path",{d:"M12 2v10",key:"mnfbl"}],["path",{d:"M18.4 6.6a9 9 0 1 1-12.77.04",key:"obofu9"}]],v0=e("power",H1);const V1=[["path",{d:"M16.247 7.761a6 6 0 0 1 0 8.478",key:"1fwjs5"}],["path",{d:"M19.075 4.933a10 10 0 0 1 0 14.134",key:"ehdyv1"}],["path",{d:"M4.925 19.067a10 10 0 0 1 0-14.134",key:"1q22gi"}],["path",{d:"M7.753 16.239a6 6 0 0 1 0-8.478",key:"r2q7qm"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}]],w0=e("radio",V1);const L1=[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]],f0=e("refresh-cw",L1);const S1=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]],g0=e("rotate-ccw",S1);const R1=[["path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8",key:"1p45f6"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}]],$0=e("rotate-cw",R1);const P1=[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]],N0=e("save",P1);const E1=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],u0=e("search",E1);const B1=[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]],z0=e("server",B1);const D1=[["path",{d:"M14 17H5",key:"gfn3mx"}],["path",{d:"M19 7h-9",key:"6i9tg"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}],["circle",{cx:"7",cy:"7",r:"3",key:"dfmy0x"}]],b0=e("settings-2",D1);const U1=[["path",{d:"M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915",key:"1i5ecw"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],C0=e("settings",U1);const O1=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],j0=e("shield-check",O1);const G1=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]],q0=e("shield",G1);const W1=[["path",{d:"M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z",key:"1s2grr"}],["path",{d:"M20 2v4",key:"1rf3ol"}],["path",{d:"M22 4h-4",key:"gwowj6"}],["circle",{cx:"4",cy:"20",r:"2",key:"6kqj1y"}]],A0=e("sparkles",W1);const F1=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],H0=e("square",F1);const T1=[["path",{d:"M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z",key:"r04s7s"}]],V0=e("star",T1);const Z1=[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]],L0=e("sun",Z1);const I1=[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]],S0=e("terminal",I1);const K1=[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]],R0=e("trash-2",K1);const X1=[["path",{d:"M16 7h6v6",key:"box55l"}],["path",{d:"m22 7-8.5 8.5-5-5L2 17",key:"1t1m79"}]],P0=e("trending-up",X1);const Q1=[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]],E0=e("triangle-alert",Q1);const J1=[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]],B0=e("user",J1);const Y1=[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["path",{d:"M16 3.128a4 4 0 0 1 0 7.744",key:"16gr8j"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}]],D0=e("users",Y1);const e2=[["path",{d:"m21.64 3.64-1.28-1.28a1.21 1.21 0 0 0-1.72 0L2.36 18.64a1.21 1.21 0 0 0 0 1.72l1.28 1.28a1.2 1.2 0 0 0 1.72 0L21.64 5.36a1.2 1.2 0 0 0 0-1.72",key:"ul74o6"}],["path",{d:"m14 7 3 3",key:"1r5n42"}],["path",{d:"M5 6v4",key:"ilb8ba"}],["path",{d:"M19 14v4",key:"blhpug"}],["path",{d:"M10 2v2",key:"7u0qdc"}],["path",{d:"M7 8H3",key:"zfb6yr"}],["path",{d:"M21 16h-4",key:"1cnmox"}],["path",{d:"M11 3H9",key:"1obp7u"}]],U0=e("wand-sparkles",e2);const a2=[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}],["path",{d:"M5 12.859a10 10 0 0 1 5.17-2.69",key:"1dl1wf"}],["path",{d:"M19 12.859a10 10 0 0 0-2.007-1.523",key:"4k23kn"}],["path",{d:"M2 8.82a15 15 0 0 1 4.177-2.643",key:"1grhjp"}],["path",{d:"M22 8.82a15 15 0 0 0-11.288-3.764",key:"z3jwby"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],O0=e("wifi-off",a2);const t2=[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M2 8.82a15 15 0 0 1 20 0",key:"dnpr2z"}],["path",{d:"M5 12.859a10 10 0 0 1 14 0",key:"1x1e6c"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}]],G0=e("wifi",t2);const c2=[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z",key:"1ngwbx"}]],W0=e("wrench",c2);const o2=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],F0=e("x",o2);const n2=[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]],T0=e("zap",n2);export{Y2 as $,y2 as A,_2 as B,m2 as C,Z2 as D,G2 as E,K2 as F,X2 as G,c0 as H,o0 as I,e0 as J,s0 as K,h0 as L,i0 as M,N2 as N,f2 as O,l0 as P,b0 as Q,g0 as R,C0 as S,E0 as T,D0 as U,x0 as V,O0 as W,F0 as X,A0 as Y,T0 as Z,u2 as _,J2 as a,z0 as a0,T2 as a1,f0 as a2,g2 as a3,d0 as a4,B2 as a5,E2 as a6,d2 as a7,x2 as a8,S2 as a9,M2 as aA,H2 as aB,y0 as aC,j0 as aD,P0 as aa,v2 as ab,R0 as ac,N0 as ad,u0 as ae,U0 as af,V2 as ag,i2 as ah,F2 as ai,k2 as aj,D2 as ak,V0 as al,p0 as am,_0 as an,U2 as ao,M0 as ap,C2 as aq,$0 as ar,H0 as as,v0 as at,r2 as au,l2 as av,Q2 as aw,m0 as ax,W0 as ay,k0 as az,$2 as b,L0 as c,W2 as d,G0 as e,q0 as f,t0 as g,z2 as h,q2 as i,w2 as j,n0 as k,R2 as l,O2 as m,B0 as n,r0 as o,b2 as p,j2 as q,a0 as r,A2 as s,w0 as t,P2 as u,S0 as v,L2 as w,p2 as x,h2 as y,I2 as z};
@@ -1 +0,0 @@
1
- import{j as e}from"./radix-ui-CFOhsBGh.js";import{r as h}from"./react-vendor-CNOkPC89.js";import{aP as J,aQ as ee,ao as L,I as w,X as te,Y as se,Z as ae,_ as oe,$ as F,b as $,aR as re,aM as ne,aO as le,m as ce}from"./index-CDRTPpUQ.js";import{S as M}from"./switch-CUS7UF_z.js";import{aB as B,a2 as R,e as de,p as D,W as ie,_ as me,aC as xe}from"./icons-WqZToXEO.js";import"./tanstack-U3Rle5gh.js";import"./notifications-B2HqRBj7.js";import"./utils-CzKF5WmX.js";import"./form-utils-C-pVd1--.js";import"./code-highlight-BRUf_pqB.js";function ue(){const{state:s}=J(),t=ee(),[l,c]=h.useState(null),[u,g]=h.useState(null),[p,i]=h.useState(null),[f,y]=h.useState(null),[j,b]=h.useState(null),v=h.useCallback(async()=>{try{t.setProxyLoading(!0),t.setProxyError(null);const n=await L.cliproxyServer.get();t.setProxyConfig(n)}catch(n){t.setProxyError(n.message)}finally{t.setProxyLoading(!1)}},[t]),N=h.useCallback(async n=>{const d=s.proxyConfig;if(!d)return;const m={remote:{...d.remote,...n.remote},fallback:{...d.fallback,...n.fallback},local:{...d.local,...n.local}};t.setProxyConfig(m),t.setProxyTestResult(null);try{t.setProxySaving(!0),t.setProxyError(null);const a=await L.cliproxyServer.update(n);t.setProxyConfig(a),t.setProxySuccess(!0),setTimeout(()=>t.setProxySuccess(!1),1500)}catch(a){t.setProxyConfig(d),t.setProxyError(a.message)}finally{t.setProxySaving(!1)}},[s.proxyConfig,t]),C=h.useCallback(async n=>{const{host:d,port:m,protocol:a,authToken:P}=n;if(!d){t.setProxyError("Host is required");return}try{t.setProxyTesting(!0),t.setProxyError(null),t.setProxyTestResult(null);const o=m?parseInt(m,10):void 0,x=await L.cliproxyServer.test({host:d,port:o||void 0,protocol:a,authToken:P||void 0});t.setProxyTestResult(x)}catch(o){t.setProxyError(o.message)}finally{t.setProxyTesting(!1)}},[t]);return{config:s.proxyConfig,loading:s.proxyLoading,saving:s.proxySaving,error:s.proxyError,success:s.proxySuccess,testResult:s.proxyTestResult,testing:s.proxyTesting,editedHost:l,setEditedHost:c,editedPort:u,setEditedPort:g,editedAuthToken:p,setEditedAuthToken:i,editedManagementKey:f,setEditedManagementKey:y,editedLocalPort:j,setEditedLocalPort:b,fetchConfig:v,saveConfig:N,testConnection:C}}function he({config:s,saving:t,displayLocalPort:l,setEditedLocalPort:c,onSaveLocalPort:u,onSaveConfig:g}){const p=s.local;return e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-base font-medium",children:"Local Proxy"}),e.jsxs("div",{className:"space-y-3 p-4 rounded-lg border bg-muted/30",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-sm text-muted-foreground",children:"Port"}),e.jsx(w,{type:"number",value:l,onChange:i=>c(i.target.value),onBlur:u,placeholder:"8317",className:"font-mono max-w-32",disabled:t})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:"Auto-start"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Start local proxy automatically when needed"})]}),e.jsx(M,{checked:p.auto_start??!0,onCheckedChange:i=>g({local:{...p,auto_start:i}}),disabled:t})]})]})]})}function pe({config:s,saving:t,testing:l,testResult:c,displayHost:u,displayPort:g,displayAuthToken:p,displayManagementKey:i,setEditedHost:f,setEditedPort:y,setEditedAuthToken:j,setEditedManagementKey:b,onSaveHost:v,onSavePort:N,onSaveAuthToken:C,onSaveManagementKey:n,onSaveConfig:d,onTestConnection:m}){const a=s.remote,P=o=>o==="https"?443:8317;return e.jsxs("div",{className:"space-y-4 p-4 rounded-lg border bg-muted/30",children:[e.jsxs("h4",{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(B,{className:"w-4 h-4"}),"Remote Server Configuration"]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-sm text-muted-foreground",children:"Host"}),e.jsx(w,{value:u,onChange:o=>f(o.target.value),onBlur:v,placeholder:"192.168.1.100 or proxy.example.com",className:"font-mono",disabled:t})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("label",{className:"text-sm text-muted-foreground",children:["Port"," ",e.jsxs("span",{className:"text-xs opacity-70",children:["(default: ",P(s.remote.protocol||"http"),")"]})]}),e.jsx(w,{type:"text",inputMode:"numeric",value:g,onChange:o=>y(o.target.value.replace(/\D/g,"")),onBlur:N,placeholder:`Leave empty for ${P(s.remote.protocol||"http")}`,className:"font-mono",disabled:t})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-sm text-muted-foreground",children:"Protocol"}),e.jsxs(te,{value:s.remote.protocol||"http",onValueChange:o=>d({remote:{...a,protocol:o}}),disabled:t,children:[e.jsx(se,{children:e.jsx(ae,{})}),e.jsxs(oe,{children:[e.jsx(F,{value:"http",children:"HTTP"}),e.jsx(F,{value:"https",children:"HTTPS"})]})]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-sm text-muted-foreground",children:"API Key (optional)"}),e.jsx(w,{type:"password",value:p,onChange:o=>j(o.target.value),onBlur:C,placeholder:"For /v1/* API endpoints",className:"font-mono",disabled:t}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Used for API requests to /v1/chat/completions"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-sm text-muted-foreground",children:"Management Key (optional)"}),e.jsx(w,{type:"password",value:i,onChange:o=>b(o.target.value),onBlur:n,placeholder:"For /v0/management/* endpoints",className:"font-mono",disabled:t}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Used for dashboard management APIs. Falls back to API Key if not set."})]}),e.jsxs("div",{className:"space-y-3 pt-2",children:[e.jsx($,{onClick:m,disabled:l||!u,variant:"outline",className:"w-full",children:l?e.jsxs(e.Fragment,{children:[e.jsx(R,{className:"w-4 h-4 mr-2 animate-spin"}),"Testing..."]}):e.jsxs(e.Fragment,{children:[e.jsx(de,{className:"w-4 h-4 mr-2"}),"Test Connection"]})}),c&&e.jsx("div",{className:`p-3 rounded-md ${c.reachable?"bg-green-50 border border-green-200 dark:bg-green-900/20 dark:border-green-900/50":"bg-red-50 border border-red-200 dark:bg-red-900/20 dark:border-red-900/50"}`,children:e.jsx("div",{className:"flex items-center gap-2",children:c.reachable?e.jsxs(e.Fragment,{children:[e.jsx(D,{className:"w-4 h-4 text-green-600 dark:text-green-400"}),e.jsxs("span",{className:"text-sm font-medium text-green-700 dark:text-green-300",children:["Connected (",c.latencyMs,"ms)"]})]}):e.jsxs(e.Fragment,{children:[e.jsx(ie,{className:"w-4 h-4 text-red-600 dark:text-red-400"}),e.jsx("span",{className:"text-sm font-medium text-red-700 dark:text-red-300",children:c.error||"Connection failed"})]})})})]})]})}function Se(){const{config:s,loading:t,saving:l,error:c,success:u,testResult:g,testing:p,editedHost:i,setEditedHost:f,editedPort:y,setEditedPort:j,editedAuthToken:b,setEditedAuthToken:v,editedManagementKey:N,setEditedManagementKey:C,editedLocalPort:n,setEditedLocalPort:d,fetchConfig:m,saveConfig:a,testConnection:P}=ue(),{fetchRawConfig:o}=re();if(h.useEffect(()=>{m(),o()},[m,o]),t||!s)return e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsxs("div",{className:"flex items-center gap-3 text-muted-foreground",children:[e.jsx(R,{className:"w-5 h-5 animate-spin"}),e.jsx("span",{children:"Loading..."})]})});const x=s.remote.enabled??!1,k=s.remote,S=s.fallback,U=s.remote.host??"",W=s.remote.port!==void 0?s.remote.port.toString():"",q=s.remote.auth_token??"",z=s.remote.management_key??"",O=(s.local.port??8317).toString(),E=i??U,A=y??W,I=b??q,_=N??z,K=n??O,V=()=>{const r=i??E;r!==s.remote.host&&a({remote:{...k,host:r}}),f(null)},Q=()=>{const r=y??A,T=r===""?void 0:parseInt(r,10),H=T&&!isNaN(T)&&T>0?T:void 0;H!==s.remote.port&&a({remote:{...k,port:H}}),j(null)},X=()=>{const r=b??I;r!==s.remote.auth_token&&a({remote:{...k,auth_token:r}}),v(null)},Y=()=>{const r=N??_;r!==s.remote.management_key&&a({remote:{...k,management_key:r||void 0}}),C(null)},Z=()=>{const r=parseInt(n??K,10);!isNaN(r)&&r!==s.local.port&&a({local:{...s.local,port:r}}),d(null)},G=()=>{P({host:E,port:A,protocol:s.remote.protocol||"http",authToken:I})};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:`absolute left-5 right-5 top-20 z-10 transition-all duration-200 ease-out ${c||u?"opacity-100 translate-y-0":"opacity-0 -translate-y-2 pointer-events-none"}`,children:[c&&e.jsxs(ne,{variant:"destructive",className:"py-2 shadow-lg",children:[e.jsx(me,{className:"h-4 w-4"}),e.jsx(le,{children:c})]}),u&&e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-md border border-green-200 bg-green-50 text-green-700 shadow-lg dark:border-green-900/50 dark:bg-green-900/90 dark:text-green-300",children:[e.jsx(D,{className:"h-4 w-4 shrink-0"}),e.jsx("span",{className:"text-sm font-medium",children:"Saved"})]})]}),e.jsx(ce,{className:"flex-1",children:e.jsxs("div",{className:"p-5 space-y-6",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Configure local or remote CLIProxy Plus connection for proxy-based profiles"}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-base font-medium",children:"Connection Mode"}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("button",{onClick:()=>a({remote:{...k,enabled:!1}}),disabled:l,className:`p-4 rounded-lg border-2 text-left transition-all ${x?"border-border hover:border-muted-foreground/50":"border-primary bg-primary/5"}`,children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx(xe,{className:`w-5 h-5 ${x?"text-muted-foreground":"text-primary"}`}),e.jsx("span",{className:"font-medium",children:"Local"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Run CLIProxy Plus binary on this machine"})]}),e.jsxs("button",{onClick:()=>a({remote:{...k,enabled:!0}}),disabled:l,className:`p-4 rounded-lg border-2 text-left transition-all ${x?"border-primary bg-primary/5":"border-border hover:border-muted-foreground/50"}`,children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx(B,{className:`w-5 h-5 ${x?"text-primary":"text-muted-foreground"}`}),e.jsx("span",{className:"font-medium",children:"Remote"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Connect to a remote CLIProxy Plus server"})]})]})]}),x&&e.jsx(pe,{config:s,saving:l,testing:p,testResult:g,displayHost:E,displayPort:A,displayAuthToken:I,displayManagementKey:_,setEditedHost:f,setEditedPort:j,setEditedAuthToken:v,setEditedManagementKey:C,onSaveHost:V,onSavePort:Q,onSaveAuthToken:X,onSaveManagementKey:Y,onSaveConfig:a,onTestConnection:G}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-base font-medium",children:"Fallback Settings"}),e.jsxs("div",{className:"space-y-3 p-4 rounded-lg border bg-muted/30",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:"Enable fallback to local"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Use local proxy if remote is unreachable"})]}),e.jsx(M,{checked:S.enabled??!0,onCheckedChange:r=>a({fallback:{...S,enabled:r}}),disabled:l||!x})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:"Auto-start local proxy"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Automatically start local proxy on fallback"})]}),e.jsx(M,{checked:S.auto_start??!1,onCheckedChange:r=>a({fallback:{...S,auto_start:r}}),disabled:l||!x||!S.enabled})]})]})]}),!x&&e.jsx(he,{config:s,saving:l,displayLocalPort:K,setEditedLocalPort:d,onSaveLocalPort:Z,onSaveConfig:a})]})}),e.jsx("div",{className:"p-4 border-t bg-background",children:e.jsxs($,{variant:"outline",size:"sm",onClick:()=>{m(),o()},disabled:t||l,className:"w-full",children:[e.jsx(R,{className:`w-4 h-4 mr-2 ${t?"animate-spin":""}`}),"Refresh"]})})]})}export{Se as default};