@kaitranntt/ccs 6.4.0-dev.3 → 6.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (84) hide show
  1. package/VERSION +1 -1
  2. package/dist/auth/profile-detector.d.ts +1 -5
  3. package/dist/auth/profile-detector.d.ts.map +1 -1
  4. package/dist/auth/profile-detector.js +0 -31
  5. package/dist/auth/profile-detector.js.map +1 -1
  6. package/dist/ccs.d.ts +8 -0
  7. package/dist/ccs.d.ts.map +1 -1
  8. package/dist/ccs.js +11 -92
  9. package/dist/ccs.js.map +1 -1
  10. package/dist/commands/help-command.d.ts.map +1 -1
  11. package/dist/commands/help-command.js +0 -16
  12. package/dist/commands/help-command.js.map +1 -1
  13. package/dist/config/reserved-names.d.ts +1 -1
  14. package/dist/config/reserved-names.d.ts.map +1 -1
  15. package/dist/config/reserved-names.js +0 -2
  16. package/dist/config/reserved-names.js.map +1 -1
  17. package/dist/config/unified-config-loader.d.ts.map +1 -1
  18. package/dist/config/unified-config-loader.js +0 -30
  19. package/dist/config/unified-config-loader.js.map +1 -1
  20. package/dist/config/unified-config-types.d.ts +2 -45
  21. package/dist/config/unified-config-types.d.ts.map +1 -1
  22. package/dist/config/unified-config-types.js +2 -18
  23. package/dist/config/unified-config-types.js.map +1 -1
  24. package/dist/ui/assets/{accounts-OHf-47mH.js → accounts-aPbCYgXy.js} +1 -1
  25. package/dist/ui/assets/{analytics-C4uOxyuU.js → analytics-ByHzJ4fO.js} +1 -1
  26. package/dist/ui/assets/{api-B_mbwU9C.js → api-DRVliui6.js} +1 -1
  27. package/dist/ui/assets/{card-CR0u1y_L.js → card-CkFFTnqL.js} +1 -1
  28. package/dist/ui/assets/{cliproxy-tXwMpEJd.js → cliproxy-CJ5njiYX.js} +1 -1
  29. package/dist/ui/assets/{cliproxy-control-panel-DIIw97Bs.js → cliproxy-control-panel-C9y82uCL.js} +1 -1
  30. package/dist/ui/assets/{code-editor-CVohe7u9.js → code-editor-D1jkWlaX.js} +1 -1
  31. package/dist/ui/assets/health-B4BNP_1z.js +1 -0
  32. package/dist/ui/assets/icons-B9AtZK5c.js +1 -0
  33. package/dist/ui/assets/index-B_6ILhjh.css +1 -0
  34. package/dist/ui/assets/index-EyLCmFok.js +44 -0
  35. package/dist/ui/assets/settings-DcAQTmWn.js +1 -0
  36. package/dist/ui/assets/shared-DJshj6er.js +1 -0
  37. package/dist/ui/index.html +3 -3
  38. package/dist/utils/update-checker.d.ts +2 -14
  39. package/dist/utils/update-checker.d.ts.map +1 -1
  40. package/dist/utils/update-checker.js +9 -39
  41. package/dist/utils/update-checker.js.map +1 -1
  42. package/dist/web-server/routes.js +0 -275
  43. package/dist/web-server/routes.js.map +1 -1
  44. package/package.json +1 -1
  45. package/dist/commands/copilot-command.d.ts +0 -10
  46. package/dist/commands/copilot-command.d.ts.map +0 -1
  47. package/dist/commands/copilot-command.js +0 -227
  48. package/dist/commands/copilot-command.js.map +0 -1
  49. package/dist/copilot/copilot-auth.d.ts +0 -52
  50. package/dist/copilot/copilot-auth.d.ts.map +0 -1
  51. package/dist/copilot/copilot-auth.js +0 -201
  52. package/dist/copilot/copilot-auth.js.map +0 -1
  53. package/dist/copilot/copilot-daemon.d.ts +0 -36
  54. package/dist/copilot/copilot-daemon.d.ts.map +0 -1
  55. package/dist/copilot/copilot-daemon.js +0 -237
  56. package/dist/copilot/copilot-daemon.js.map +0 -1
  57. package/dist/copilot/copilot-executor.d.ts +0 -26
  58. package/dist/copilot/copilot-executor.d.ts.map +0 -1
  59. package/dist/copilot/copilot-executor.js +0 -144
  60. package/dist/copilot/copilot-executor.js.map +0 -1
  61. package/dist/copilot/copilot-models.d.ts +0 -34
  62. package/dist/copilot/copilot-models.d.ts.map +0 -1
  63. package/dist/copilot/copilot-models.js +0 -261
  64. package/dist/copilot/copilot-models.js.map +0 -1
  65. package/dist/copilot/copilot-package-manager.d.ts +0 -93
  66. package/dist/copilot/copilot-package-manager.d.ts.map +0 -1
  67. package/dist/copilot/copilot-package-manager.js +0 -488
  68. package/dist/copilot/copilot-package-manager.js.map +0 -1
  69. package/dist/copilot/index.d.ts +0 -13
  70. package/dist/copilot/index.d.ts.map +0 -1
  71. package/dist/copilot/index.js +0 -63
  72. package/dist/copilot/index.js.map +0 -1
  73. package/dist/copilot/types.d.ts +0 -65
  74. package/dist/copilot/types.d.ts.map +0 -1
  75. package/dist/copilot/types.js +0 -8
  76. package/dist/copilot/types.js.map +0 -1
  77. package/dist/ui/assets/copilot-C-eWI9Ce.js +0 -4
  78. package/dist/ui/assets/health-Dh8bSHe-.js +0 -1
  79. package/dist/ui/assets/icons-WTNLz24z.js +0 -1
  80. package/dist/ui/assets/index-BXPLu3zJ.js +0 -44
  81. package/dist/ui/assets/index-D2qNwUdc.css +0 -1
  82. package/dist/ui/assets/settings-Bi8Aw4yN.js +0 -1
  83. package/dist/ui/assets/shared-DQlPCpix.js +0 -1
  84. package/dist/ui/assets/switch-pOvJh4Ez.js +0 -1
@@ -12,9 +12,8 @@
12
12
  * Unified config version.
13
13
  * Version 2 = YAML unified format
14
14
  * Version 3 = WebSearch config with model configuration for Gemini/OpenCode
15
- * Version 4 = Copilot API integration (GitHub Copilot proxy)
16
15
  */
17
- export declare const UNIFIED_CONFIG_VERSION = 4;
16
+ export declare const UNIFIED_CONFIG_VERSION = 3;
18
17
  /**
19
18
  * Account configuration (formerly in profiles.json).
20
19
  * Represents an isolated Claude instance via CLAUDE_CONFIG_DIR.
@@ -136,40 +135,6 @@ export interface WebSearchProvidersConfig {
136
135
  /** OpenCode - built-in web search (FREE via OpenCode Zen) */
137
136
  opencode?: OpenCodeWebSearchConfig;
138
137
  }
139
- /**
140
- * Copilot API account type.
141
- */
142
- export type CopilotAccountType = 'individual' | 'business' | 'enterprise';
143
- /**
144
- * Copilot API configuration.
145
- * Enables GitHub Copilot subscription usage via copilot-api proxy.
146
- * Strictly opt-in - disabled by default.
147
- *
148
- * !! DISCLAIMER - USE AT YOUR OWN RISK !!
149
- * This uses an UNOFFICIAL reverse-engineered API.
150
- * Excessive usage may trigger GitHub account restrictions.
151
- * CCS provides NO WARRANTY and accepts NO RESPONSIBILITY for any consequences.
152
- */
153
- export interface CopilotConfig {
154
- /** Enable Copilot integration (default: false) - must be explicitly enabled */
155
- enabled: boolean;
156
- /** Auto-start copilot-api daemon when using profile (default: false) */
157
- auto_start: boolean;
158
- /** Port for copilot-api proxy (default: 4141) */
159
- port: number;
160
- /** GitHub Copilot account type (default: individual) */
161
- account_type: CopilotAccountType;
162
- /** Rate limit in seconds between requests (null = no limit) */
163
- rate_limit: number | null;
164
- /** Wait instead of error when rate limit is hit (default: true) */
165
- wait_on_limit: boolean;
166
- /** Default model ID (e.g., claude-sonnet-4.5) */
167
- model: string;
168
- /** Model mapping for Claude tiers - maps opus/sonnet/haiku to specific models */
169
- opus_model?: string;
170
- sonnet_model?: string;
171
- haiku_model?: string;
172
- }
173
138
  /**
174
139
  * WebSearch configuration.
175
140
  * Uses CLI tools (Gemini CLI, Grok CLI, OpenCode) for third-party profiles.
@@ -203,7 +168,7 @@ export interface WebSearchConfig {
203
168
  * Stored in ~/.ccs/config.yaml
204
169
  */
205
170
  export interface UnifiedConfig {
206
- /** Config version (4 for copilot support) */
171
+ /** Config version (2 for unified format) */
207
172
  version: number;
208
173
  /** Default profile name to use when none specified */
209
174
  default?: string;
@@ -217,8 +182,6 @@ export interface UnifiedConfig {
217
182
  preferences: PreferencesConfig;
218
183
  /** WebSearch configuration */
219
184
  websearch?: WebSearchConfig;
220
- /** Copilot API configuration (GitHub Copilot proxy) */
221
- copilot?: CopilotConfig;
222
185
  }
223
186
  /**
224
187
  * Secrets configuration structure.
@@ -231,12 +194,6 @@ export interface SecretsConfig {
231
194
  /** Profile secrets mapping: profile_name -> { key: value } */
232
195
  profiles: Record<string, Record<string, string>>;
233
196
  }
234
- /**
235
- * Default Copilot configuration.
236
- * Strictly opt-in - disabled by default.
237
- * Uses gpt-4.1 as default model (free tier compatible).
238
- */
239
- export declare const DEFAULT_COPILOT_CONFIG: CopilotConfig;
240
197
  /**
241
198
  * Create an empty unified config with defaults.
242
199
  */
@@ -1 +1 @@
1
- {"version":3,"file":"unified-config-types.d.ts","sourceRoot":"","sources":["../../src/config/unified-config-types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH;;;;;GAKG;AACH,eAAO,MAAM,sBAAsB,IAAI,CAAC;AAExC;;;GAGG;AACH,MAAM,WAAW,aAAa;IAC5B,6CAA6C;IAC7C,OAAO,EAAE,MAAM,CAAC;IAChB,sDAAsD;IACtD,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1B;AAED;;;;;;GAMG;AACH,MAAM,WAAW,aAAa;IAC5B,0CAA0C;IAC1C,IAAI,EAAE,KAAK,CAAC;IACZ,+DAA+D;IAC/D,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;;GAGG;AACH,MAAM,MAAM,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAEnD;;;;;;GAMG;AACH,MAAM,WAAW,qBAAqB;IACpC,2BAA2B;IAC3B,QAAQ,EAAE,QAAQ,GAAG,OAAO,GAAG,KAAK,GAAG,MAAM,GAAG,OAAO,CAAC;IACxD,mDAAmD;IACnD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,yEAAyE;IACzE,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;;;GAIG;AACH,MAAM,WAAW,qBAAqB;IACpC,oEAAoE;IACpE,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,4DAA4D;IAC5D,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,mDAAmD;IACnD,cAAc,EAAE,aAAa,CAAC;IAC9B,oDAAoD;IACpD,SAAS,EAAE,SAAS,MAAM,EAAE,CAAC;IAC7B,qCAAqC;IACrC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,qBAAqB,CAAC,CAAC;IAChD,kDAAkD;IAClD,OAAO,CAAC,EAAE,qBAAqB,CAAC;CACjC;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,0BAA0B;IAC1B,KAAK,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,QAAQ,CAAC;IACpC,iCAAiC;IACjC,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,qCAAqC;IACrC,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAED;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,sDAAsD;IACtD,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,+CAA+C;IAC/C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,uCAAuC;IACvC,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,6EAA6E;IAC7E,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,uCAAuC;IACvC,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC,yDAAyD;IACzD,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,iDAAiD;IACjD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,uCAAuC;IACvC,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;;GAGG;AACH,MAAM,WAAW,wBAAwB;IACvC,yEAAyE;IACzE,MAAM,CAAC,EAAE,qBAAqB,CAAC;IAC/B,wDAAwD;IACxD,IAAI,CAAC,EAAE,mBAAmB,CAAC;IAC3B,6DAA6D;IAC7D,QAAQ,CAAC,EAAE,uBAAuB,CAAC;CACpC;AAED;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAAG,YAAY,GAAG,UAAU,GAAG,YAAY,CAAC;AAE1E;;;;;;;;;GASG;AACH,MAAM,WAAW,aAAa;IAC5B,+EAA+E;IAC/E,OAAO,EAAE,OAAO,CAAC;IACjB,wEAAwE;IACxE,UAAU,EAAE,OAAO,CAAC;IACpB,iDAAiD;IACjD,IAAI,EAAE,MAAM,CAAC;IACb,wDAAwD;IACxD,YAAY,EAAE,kBAAkB,CAAC;IACjC,+DAA+D;IAC/D,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,mEAAmE;IACnE,aAAa,EAAE,OAAO,CAAC;IACvB,iDAAiD;IACjD,KAAK,EAAE,MAAM,CAAC;IACd,iFAAiF;IACjF,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;;;GAIG;AACH,MAAM,WAAW,eAAe;IAC9B,+DAA+D;IAC/D,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,yCAAyC;IACzC,SAAS,CAAC,EAAE,wBAAwB,CAAC;IAErC,+CAA+C;IAC/C,MAAM,CAAC,EAAE;QACP,OAAO,CAAC,EAAE,OAAO,CAAC;QAClB,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB,CAAC;IACF,yBAAyB;IACzB,IAAI,CAAC,EAAE,YAAY,GAAG,UAAU,CAAC;IACjC,yBAAyB;IACzB,QAAQ,CAAC,EAAE,MAAM,GAAG,kBAAkB,GAAG,OAAO,GAAG,QAAQ,CAAC;IAC5D,yBAAyB;IACzB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,yBAAyB;IACzB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,yBAAyB;IACzB,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC7B,yBAAyB;IACzB,SAAS,CAAC,EAAE,OAAO,EAAE,CAAC;CACvB;AAED;;;GAGG;AACH,MAAM,WAAW,aAAa;IAC5B,6CAA6C;IAC7C,OAAO,EAAE,MAAM,CAAC;IAChB,sDAAsD;IACtD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,yDAAyD;IACzD,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;IACxC,6CAA6C;IAC7C,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;IACxC,6BAA6B;IAC7B,QAAQ,EAAE,cAAc,CAAC;IACzB,uBAAuB;IACvB,WAAW,EAAE,iBAAiB,CAAC;IAC/B,8BAA8B;IAC9B,SAAS,CAAC,EAAE,eAAe,CAAC;IAC5B,uDAAuD;IACvD,OAAO,CAAC,EAAE,aAAa,CAAC;CACzB;AAED;;;;GAIG;AACH,MAAM,WAAW,aAAa;IAC5B,sBAAsB;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,8DAA8D;IAC9D,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;CAClD;AAED;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,EAAE,aAQpC,CAAC;AAEF;;GAEG;AACH,wBAAgB,wBAAwB,IAAI,aAAa,CAyCxD;AAED;;GAEG;AACH,wBAAgB,wBAAwB,IAAI,aAAa,CAKxD;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,OAAO,GAAG,GAAG,IAAI,aAAa,CAMlE;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,OAAO,GAAG,GAAG,IAAI,aAAa,CAIlE"}
1
+ {"version":3,"file":"unified-config-types.d.ts","sourceRoot":"","sources":["../../src/config/unified-config-types.ts"],"names":[],"mappings":"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"}
@@ -10,28 +10,13 @@
10
10
  * Into a single config.yaml + secrets.yaml structure.
11
11
  */
12
12
  Object.defineProperty(exports, "__esModule", { value: true });
13
- exports.isSecretsConfig = exports.isUnifiedConfig = exports.createEmptySecretsConfig = exports.createEmptyUnifiedConfig = exports.DEFAULT_COPILOT_CONFIG = exports.UNIFIED_CONFIG_VERSION = void 0;
13
+ exports.isSecretsConfig = exports.isUnifiedConfig = exports.createEmptySecretsConfig = exports.createEmptyUnifiedConfig = exports.UNIFIED_CONFIG_VERSION = void 0;
14
14
  /**
15
15
  * Unified config version.
16
16
  * Version 2 = YAML unified format
17
17
  * Version 3 = WebSearch config with model configuration for Gemini/OpenCode
18
- * Version 4 = Copilot API integration (GitHub Copilot proxy)
19
18
  */
20
- exports.UNIFIED_CONFIG_VERSION = 4;
21
- /**
22
- * Default Copilot configuration.
23
- * Strictly opt-in - disabled by default.
24
- * Uses gpt-4.1 as default model (free tier compatible).
25
- */
26
- exports.DEFAULT_COPILOT_CONFIG = {
27
- enabled: false,
28
- auto_start: false,
29
- port: 4141,
30
- account_type: 'individual',
31
- rate_limit: null,
32
- wait_on_limit: true,
33
- model: 'gpt-4.1', // Free tier compatible
34
- };
19
+ exports.UNIFIED_CONFIG_VERSION = 3;
35
20
  /**
36
21
  * Create an empty unified config with defaults.
37
22
  */
@@ -74,7 +59,6 @@ function createEmptyUnifiedConfig() {
74
59
  },
75
60
  },
76
61
  },
77
- copilot: { ...exports.DEFAULT_COPILOT_CONFIG },
78
62
  };
79
63
  }
80
64
  exports.createEmptyUnifiedConfig = createEmptyUnifiedConfig;
@@ -1 +1 @@
1
- {"version":3,"file":"unified-config-types.js","sourceRoot":"","sources":["../../src/config/unified-config-types.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;;AAEH;;;;;GAKG;AACU,QAAA,sBAAsB,GAAG,CAAC,CAAC;AA2OxC;;;;GAIG;AACU,QAAA,sBAAsB,GAAkB;IACnD,OAAO,EAAE,KAAK;IACd,UAAU,EAAE,KAAK;IACjB,IAAI,EAAE,IAAI;IACV,YAAY,EAAE,YAAY;IAC1B,UAAU,EAAE,IAAI;IAChB,aAAa,EAAE,IAAI;IACnB,KAAK,EAAE,SAAS,EAAE,uBAAuB;CAC1C,CAAC;AAEF;;GAEG;AACH,SAAgB,wBAAwB;IACtC,OAAO;QACL,OAAO,EAAE,8BAAsB;QAC/B,OAAO,EAAE,SAAS;QAClB,QAAQ,EAAE,EAAE;QACZ,QAAQ,EAAE,EAAE;QACZ,QAAQ,EAAE;YACR,cAAc,EAAE,EAAE;YAClB,SAAS,EAAE,CAAC,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC;YACtD,QAAQ,EAAE,EAAE;YACZ,OAAO,EAAE;gBACP,OAAO,EAAE,KAAK;gBACd,WAAW,EAAE,KAAK;aACnB;SACF;QACD,WAAW,EAAE;YACX,KAAK,EAAE,QAAQ;YACf,SAAS,EAAE,KAAK;YAChB,WAAW,EAAE,IAAI;SAClB;QACD,SAAS,EAAE;YACT,OAAO,EAAE,IAAI;YACb,SAAS,EAAE;gBACT,MAAM,EAAE;oBACN,OAAO,EAAE,IAAI;oBACb,KAAK,EAAE,kBAAkB;oBACzB,OAAO,EAAE,EAAE;iBACZ;gBACD,QAAQ,EAAE;oBACR,OAAO,EAAE,KAAK;oBACd,KAAK,EAAE,oBAAoB;oBAC3B,OAAO,EAAE,EAAE;iBACZ;gBACD,IAAI,EAAE;oBACJ,OAAO,EAAE,KAAK;oBACd,OAAO,EAAE,EAAE;iBACZ;aACF;SACF;QACD,OAAO,EAAE,EAAE,GAAG,8BAAsB,EAAE;KACvC,CAAC;AACJ,CAAC;AAzCD,4DAyCC;AAED;;GAEG;AACH,SAAgB,wBAAwB;IACtC,OAAO;QACL,OAAO,EAAE,CAAC;QACV,QAAQ,EAAE,EAAE;KACb,CAAC;AACJ,CAAC;AALD,4DAKC;AAED;;;;GAIG;AACH,SAAgB,eAAe,CAAC,GAAY;IAC1C,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,KAAK,IAAI;QAAE,OAAO,KAAK,CAAC;IAC1D,MAAM,MAAM,GAAG,GAA8B,CAAC;IAC9C,mEAAmE;IACnE,oFAAoF;IACpF,OAAO,OAAO,MAAM,CAAC,OAAO,KAAK,QAAQ,IAAI,MAAM,CAAC,OAAO,IAAI,CAAC,CAAC;AACnE,CAAC;AAND,0CAMC;AAED;;GAEG;AACH,SAAgB,eAAe,CAAC,GAAY;IAC1C,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,KAAK,IAAI;QAAE,OAAO,KAAK,CAAC;IAC1D,MAAM,MAAM,GAAG,GAA8B,CAAC;IAC9C,OAAO,OAAO,MAAM,CAAC,OAAO,KAAK,QAAQ,IAAI,OAAO,MAAM,CAAC,QAAQ,KAAK,QAAQ,CAAC;AACnF,CAAC;AAJD,0CAIC"}
1
+ {"version":3,"file":"unified-config-types.js","sourceRoot":"","sources":["../../src/config/unified-config-types.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;;AAEH;;;;GAIG;AACU,QAAA,sBAAsB,GAAG,CAAC,CAAC;AAqMxC;;GAEG;AACH,SAAgB,wBAAwB;IACtC,OAAO;QACL,OAAO,EAAE,8BAAsB;QAC/B,OAAO,EAAE,SAAS;QAClB,QAAQ,EAAE,EAAE;QACZ,QAAQ,EAAE,EAAE;QACZ,QAAQ,EAAE;YACR,cAAc,EAAE,EAAE;YAClB,SAAS,EAAE,CAAC,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC;YACtD,QAAQ,EAAE,EAAE;YACZ,OAAO,EAAE;gBACP,OAAO,EAAE,KAAK;gBACd,WAAW,EAAE,KAAK;aACnB;SACF;QACD,WAAW,EAAE;YACX,KAAK,EAAE,QAAQ;YACf,SAAS,EAAE,KAAK;YAChB,WAAW,EAAE,IAAI;SAClB;QACD,SAAS,EAAE;YACT,OAAO,EAAE,IAAI;YACb,SAAS,EAAE;gBACT,MAAM,EAAE;oBACN,OAAO,EAAE,IAAI;oBACb,KAAK,EAAE,kBAAkB;oBACzB,OAAO,EAAE,EAAE;iBACZ;gBACD,QAAQ,EAAE;oBACR,OAAO,EAAE,KAAK;oBACd,KAAK,EAAE,oBAAoB;oBAC3B,OAAO,EAAE,EAAE;iBACZ;gBACD,IAAI,EAAE;oBACJ,OAAO,EAAE,KAAK;oBACd,OAAO,EAAE,EAAE;iBACZ;aACF;SACF;KACF,CAAC;AACJ,CAAC;AAxCD,4DAwCC;AAED;;GAEG;AACH,SAAgB,wBAAwB;IACtC,OAAO;QACL,OAAO,EAAE,CAAC;QACV,QAAQ,EAAE,EAAE;KACb,CAAC;AACJ,CAAC;AALD,4DAKC;AAED;;;;GAIG;AACH,SAAgB,eAAe,CAAC,GAAY;IAC1C,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,KAAK,IAAI;QAAE,OAAO,KAAK,CAAC;IAC1D,MAAM,MAAM,GAAG,GAA8B,CAAC;IAC9C,mEAAmE;IACnE,oFAAoF;IACpF,OAAO,OAAO,MAAM,CAAC,OAAO,KAAK,QAAQ,IAAI,MAAM,CAAC,OAAO,IAAI,CAAC,CAAC;AACnE,CAAC;AAND,0CAMC;AAED;;GAEG;AACH,SAAgB,eAAe,CAAC,GAAY;IAC1C,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,KAAK,IAAI;QAAE,OAAO,KAAK,CAAC;IAC1D,MAAM,MAAM,GAAG,GAA8B,CAAC;IAC9C,OAAO,OAAO,MAAM,CAAC,OAAO,KAAK,QAAQ,IAAI,OAAO,MAAM,CAAC,QAAQ,KAAK,QAAQ,CAAC;AACnF,CAAC;AAJD,0CAIC"}
@@ -1 +1 @@
1
- import{j as e}from"./radix-ui-VbLlN_Dz.js";import{a as x,u as p,b as h,d as f,f as l,g as b}from"./tanstack-yybD444-.js";import"./react-vendor-DMek_JCF.js";import{c as r,Z as u,B as g}from"./index-BXPLu3zJ.js";import{t as d}from"./notifications-cqk-Qeo2.js";import{j}from"./icons-WTNLz24z.js";import"./utils-CzKF5WmX.js";import"./form-utils-BXvNPyud.js";import"./code-highlight-C2TXE0-z.js";function y({className:s,...t}){return e.jsx("div",{"data-slot":"table-container",className:"relative w-full overflow-x-auto",children:e.jsx("table",{"data-slot":"table",className:r("w-full caption-bottom text-sm",s),...t})})}function N({className:s,...t}){return e.jsx("thead",{"data-slot":"table-header",className:r("[&_tr]:border-b",s),...t})}function w({className:s,...t}){return e.jsx("tbody",{"data-slot":"table-body",className:r("[&_tr:last-child]:border-0",s),...t})}function i({className:s,...t}){return e.jsx("tr",{"data-slot":"table-row",className:r("hover:bg-muted/50 data-[state=selected]:bg-muted border-b transition-colors",s),...t})}function v({className:s,...t}){return e.jsx("th",{"data-slot":"table-head",className:r("text-foreground h-10 px-2 text-left align-middle font-medium whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",s),...t})}function C({className:s,...t}){return e.jsx("td",{"data-slot":"table-cell",className:r("p-2 align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",s),...t})}function D(){return x({queryKey:["accounts"],queryFn:()=>u.accounts.list()})}function T(){const s=p();return h({mutationFn:t=>u.accounts.setDefault(t),onSuccess:(t,o)=>{s.invalidateQueries({queryKey:["accounts"]}),d.success(`Default account set to "${o}"`)},onError:t=>{d.error(t.message)}})}function A({data:s,defaultAccount:t}){const o=T(),c=f({data:s,columns:[{accessorKey:"name",header:"Name",size:200,cell:({row:a})=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-medium",children:a.original.name}),a.original.name===t&&e.jsx("span",{className:"text-xs bg-primary/10 text-primary px-1.5 py-0.5 rounded border border-primary/20",children:"default"})]})},{accessorKey:"type",header:"Type",size:100,cell:({row:a})=>e.jsx("span",{className:"capitalize text-muted-foreground",children:a.original.type||"oauth"})},{accessorKey:"created",header:"Created",size:150,cell:({row:a})=>{const n=new Date(a.original.created);return e.jsx("span",{className:"text-muted-foreground",children:n.toLocaleDateString()})}},{accessorKey:"last_used",header:"Last Used",size:150,cell:({row:a})=>{if(!a.original.last_used)return e.jsx("span",{className:"text-muted-foreground/50",children:"-"});const n=new Date(a.original.last_used);return e.jsx("span",{className:"text-muted-foreground",children:n.toLocaleDateString()})}},{id:"actions",header:"Actions",size:100,cell:({row:a})=>{const n=a.original.name===t;return e.jsxs(g,{variant:n?"secondary":"default",size:"sm",className:"h-8 px-2 w-full",disabled:n||o.isPending,onClick:()=>o.mutate(a.original.name),children:[e.jsx(j,{className:`w-3 h-3 mr-1.5 ${n?"opacity-50":""}`}),n?"Active":"Set Default"]})}}],getCoreRowModel:b()});return s.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:["No accounts found. Use ",e.jsx("code",{className:"text-sm bg-muted px-1 rounded",children:"ccs login"})," to add accounts."]}):e.jsx("div",{className:"border rounded-md",children:e.jsxs(y,{children:[e.jsx(N,{children:c.getHeaderGroups().map(a=>e.jsx(i,{children:a.headers.map(n=>{const m={name:"w-[200px]",type:"w-[100px]",created:"w-[150px]",last_used:"w-[150px]",actions:"w-[100px]"}[n.id]||"w-auto";return e.jsx(v,{className:m,children:n.isPlaceholder?null:l(n.column.columnDef.header,n.getContext())},n.id)})},a.id))}),e.jsx(w,{children:c.getRowModel().rows.map(a=>e.jsx(i,{children:a.getVisibleCells().map(n=>e.jsx(C,{children:l(n.column.columnDef.cell,n.getContext())},n.id))},a.id))})]})})}function H(){const{data:s,isLoading:t}=D();return e.jsxs("div",{className:"p-6 max-w-6xl mx-auto space-y-8",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Accounts"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Manage multi-account Claude sessions (profiles.json)"})]})}),t?e.jsx("div",{className:"text-muted-foreground",children:"Loading accounts..."}):e.jsx(A,{data:s?.accounts||[],defaultAccount:s?.default??null}),e.jsx("div",{className:"text-sm text-muted-foreground border-t pt-4 mt-4",children:e.jsxs("p",{children:["Accounts are isolated Claude instances with separate sessions.",e.jsx("br",{}),"Use ",e.jsx("code",{className:"bg-muted px-1 rounded",children:"ccs auth create <name>"})," to add new accounts via CLI."]})})]})}export{H as AccountsPage};
1
+ import{j as e}from"./radix-ui-VbLlN_Dz.js";import{a as x,u as p,b as h,d as f,f as l,g as b}from"./tanstack-yybD444-.js";import"./react-vendor-DMek_JCF.js";import{c as r,T as u,B as g}from"./index-EyLCmFok.js";import{t as d}from"./notifications-cqk-Qeo2.js";import{j}from"./icons-B9AtZK5c.js";import"./utils-CzKF5WmX.js";import"./form-utils-BXvNPyud.js";import"./code-highlight-C2TXE0-z.js";function y({className:s,...t}){return e.jsx("div",{"data-slot":"table-container",className:"relative w-full overflow-x-auto",children:e.jsx("table",{"data-slot":"table",className:r("w-full caption-bottom text-sm",s),...t})})}function N({className:s,...t}){return e.jsx("thead",{"data-slot":"table-header",className:r("[&_tr]:border-b",s),...t})}function w({className:s,...t}){return e.jsx("tbody",{"data-slot":"table-body",className:r("[&_tr:last-child]:border-0",s),...t})}function i({className:s,...t}){return e.jsx("tr",{"data-slot":"table-row",className:r("hover:bg-muted/50 data-[state=selected]:bg-muted border-b transition-colors",s),...t})}function v({className:s,...t}){return e.jsx("th",{"data-slot":"table-head",className:r("text-foreground h-10 px-2 text-left align-middle font-medium whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",s),...t})}function C({className:s,...t}){return e.jsx("td",{"data-slot":"table-cell",className:r("p-2 align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",s),...t})}function D(){return x({queryKey:["accounts"],queryFn:()=>u.accounts.list()})}function T(){const s=p();return h({mutationFn:t=>u.accounts.setDefault(t),onSuccess:(t,o)=>{s.invalidateQueries({queryKey:["accounts"]}),d.success(`Default account set to "${o}"`)},onError:t=>{d.error(t.message)}})}function A({data:s,defaultAccount:t}){const o=T(),c=f({data:s,columns:[{accessorKey:"name",header:"Name",size:200,cell:({row:a})=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-medium",children:a.original.name}),a.original.name===t&&e.jsx("span",{className:"text-xs bg-primary/10 text-primary px-1.5 py-0.5 rounded border border-primary/20",children:"default"})]})},{accessorKey:"type",header:"Type",size:100,cell:({row:a})=>e.jsx("span",{className:"capitalize text-muted-foreground",children:a.original.type||"oauth"})},{accessorKey:"created",header:"Created",size:150,cell:({row:a})=>{const n=new Date(a.original.created);return e.jsx("span",{className:"text-muted-foreground",children:n.toLocaleDateString()})}},{accessorKey:"last_used",header:"Last Used",size:150,cell:({row:a})=>{if(!a.original.last_used)return e.jsx("span",{className:"text-muted-foreground/50",children:"-"});const n=new Date(a.original.last_used);return e.jsx("span",{className:"text-muted-foreground",children:n.toLocaleDateString()})}},{id:"actions",header:"Actions",size:100,cell:({row:a})=>{const n=a.original.name===t;return e.jsxs(g,{variant:n?"secondary":"default",size:"sm",className:"h-8 px-2 w-full",disabled:n||o.isPending,onClick:()=>o.mutate(a.original.name),children:[e.jsx(j,{className:`w-3 h-3 mr-1.5 ${n?"opacity-50":""}`}),n?"Active":"Set Default"]})}}],getCoreRowModel:b()});return s.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:["No accounts found. Use ",e.jsx("code",{className:"text-sm bg-muted px-1 rounded",children:"ccs login"})," to add accounts."]}):e.jsx("div",{className:"border rounded-md",children:e.jsxs(y,{children:[e.jsx(N,{children:c.getHeaderGroups().map(a=>e.jsx(i,{children:a.headers.map(n=>{const m={name:"w-[200px]",type:"w-[100px]",created:"w-[150px]",last_used:"w-[150px]",actions:"w-[100px]"}[n.id]||"w-auto";return e.jsx(v,{className:m,children:n.isPlaceholder?null:l(n.column.columnDef.header,n.getContext())},n.id)})},a.id))}),e.jsx(w,{children:c.getRowModel().rows.map(a=>e.jsx(i,{children:a.getVisibleCells().map(n=>e.jsx(C,{children:l(n.column.columnDef.cell,n.getContext())},n.id))},a.id))})]})})}function H(){const{data:s,isLoading:t}=D();return e.jsxs("div",{className:"p-6 max-w-6xl mx-auto space-y-8",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Accounts"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Manage multi-account Claude sessions (profiles.json)"})]})}),t?e.jsx("div",{className:"text-muted-foreground",children:"Loading accounts..."}):e.jsx(A,{data:s?.accounts||[],defaultAccount:s?.default??null}),e.jsx("div",{className:"text-sm text-muted-foreground border-t pt-4 mt-4",children:e.jsxs("p",{children:["Accounts are isolated Claude instances with separate sessions.",e.jsx("br",{}),"Use ",e.jsx("code",{className:"bg-muted px-1 rounded",children:"ccs auth create <name>"})," to add new accounts via CLI."]})})]})}export{H as AccountsPage};
@@ -1 +1 @@
1
- import{j as e}from"./radix-ui-VbLlN_Dz.js";import{c as ge,r as p}from"./react-vendor-DMek_JCF.js";import{C as g,a as j,b as N,c as C}from"./card-CR0u1y_L.js";import{c as i,B as I,P as ee,a as je,b as se,C as Ne,u as R,S as m,d as y,g as te,e as B,f as ye,h as be,i as we,j as ve}from"./index-BXPLu3zJ.js";import{K as F,f as k,L as H,H as ke}from"./utils-CzKF5WmX.js";import{N as Ce,O as $e,Q as ae,V as W,Y as re,_ as ne,w as Se,G as De,$ as Q,U as Le,Z as le,z as Fe,a0 as q,a1 as Te,a2 as Me,p as Re,a3 as Pe,b as Ae,a4 as Be}from"./icons-WTNLz24z.js";import{R as ie,A as Ue,C as qe,X as Oe,Y as V,T as oe,a as Z,P as Ie,b as Ke,c as Ee}from"./charts-D_0N6JY8.js";import{u as Ge,a as P}from"./tanstack-yybD444-.js";import"./notifications-cqk-Qeo2.js";import"./form-utils-BXvNPyud.js";import"./code-highlight-C2TXE0-z.js";function He({value:s,onChange:t,presets:a=[{label:"Last 7 days",range:{from:F(new Date,7),to:new Date}},{label:"Last 30 days",range:{from:F(new Date,30),to:new Date}},{label:"Last 90 days",range:{from:F(new Date,90),to:new Date}}],className:d}){const[o,c]=ge.useState(!1),n=r=>!s||!s.from||!s.to||!r.from||!r.to?!1:k(s.from,"yyyy-MM-dd")===k(r.from,"yyyy-MM-dd")&&k(s.to,"yyyy-MM-dd")===k(r.to,"yyyy-MM-dd");return e.jsxs("div",{className:i("flex items-center gap-2",d),children:[a.map(r=>e.jsx(I,{variant:n(r.range)?"default":"outline",size:"sm",onClick:()=>t(r.range),children:r.label},r.label)),e.jsxs(ee,{open:o,onOpenChange:c,children:[e.jsx(je,{asChild:!0,children:e.jsxs(I,{id:"date",variant:"outline",className:i("w-auto min-w-[240px] justify-start text-left font-normal",!s&&"text-muted-foreground"),children:[e.jsx(Ce,{className:"mr-2 h-4 w-4"}),s?.from?s.to?e.jsxs(e.Fragment,{children:[k(s.from,"LLL dd, y")," - ",k(s.to,"LLL dd, y")]}):k(s.from,"LLL dd, y"):e.jsx("span",{children:"Pick a date"})]})}),e.jsx(se,{className:"w-auto p-0",align:"end",children:e.jsx(Ne,{initialFocus:!0,mode:"range",defaultMonth:s?.from,selected:s,onSelect:t,numberOfMonths:2})})]})]})}function We({data:s,isLoading:t}){const{privacyMode:a}=R();if(t)return e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 xl:grid-cols-5 gap-4",children:[1,2,3,4,5].map(n=>e.jsx(g,{children:e.jsx(j,{className:"p-6",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(m,{className:"h-4 w-[100px]"}),e.jsx(m,{className:"h-8 w-[80px]"})]}),e.jsx(m,{className:"h-8 w-8 rounded-lg"})]})})},n))});const d=(s?.tokenBreakdown?.cacheCreation?.cost??0)+(s?.tokenBreakdown?.cacheRead?.cost??0),o=s?.totalCost?Math.round(d/s.totalCost*100):0,c=[{title:"Total Tokens",value:s?.totalTokens??0,icon:$e,format:n=>M(n),color:"text-blue-600",bgColor:"bg-blue-100 dark:bg-blue-900/20",subtitle:`${M(s?.totalInputTokens??0)} in / ${M(s?.totalOutputTokens??0)} out`},{title:"Total Cost",value:s?.totalCost??0,icon:ae,format:n=>`$${n.toFixed(2)}`,color:"text-green-600",bgColor:"bg-green-100 dark:bg-green-900/20",subtitle:`$${s?.averageCostPerDay?.toFixed(2)??"0.00"}/day avg`},{title:"Cache Tokens",value:s?.totalCacheTokens??0,icon:W,format:n=>M(n),color:"text-cyan-600",bgColor:"bg-cyan-100 dark:bg-cyan-900/20",subtitle:`$${d.toFixed(2)} (${o}% of cost)`},{title:"Input Cost",value:s?.tokenBreakdown?.input?.cost??0,icon:re,format:n=>`$${n.toFixed(2)}`,color:"text-purple-600",bgColor:"bg-purple-100 dark:bg-purple-900/20",subtitle:`${M(s?.tokenBreakdown?.input?.tokens??0)} tokens`},{title:"Output Cost",value:s?.tokenBreakdown?.output?.cost??0,icon:ne,format:n=>`$${n.toFixed(2)}`,color:"text-orange-600",bgColor:"bg-orange-100 dark:bg-orange-900/20",subtitle:`${M(s?.tokenBreakdown?.output?.tokens??0)} tokens`}];return e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 xl:grid-cols-5 gap-4",children:c.map((n,r)=>{const x=n.icon;return e.jsx(g,{className:"hover:shadow-md transition-shadow",children:e.jsx(j,{className:"p-4",children:e.jsxs("div",{className:"flex items-center justify-between space-x-2",children:[e.jsxs("div",{className:"space-y-1 min-w-0",children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground truncate",children:n.title}),e.jsx("p",{className:i("text-xl font-bold truncate",a&&y),children:n.format(n.value)}),n.subtitle&&e.jsx("p",{className:i("text-[10px] text-muted-foreground truncate",a&&y),children:n.subtitle})]}),e.jsx("div",{className:i("p-2 rounded-lg shrink-0",n.bgColor),children:e.jsx(x,{className:i("h-4 w-4",n.color)})})]})})},r)})})}function M(s){return s>=1e6?`${(s/1e6).toFixed(1)}M`:s>=1e3?`${(s/1e3).toFixed(1)}K`:s.toLocaleString()}function _e({data:s,isLoading:t,granularity:a="daily",className:d}){const{privacyMode:o}=R(),c=p.useMemo(()=>!s||s.length===0?[]:(a==="hourly"?s:[...s].reverse()).map(x=>{const u="hour"in x?x.hour:x.date;return{...x,dateFormatted:ze(u,a),costRounded:Number(x.cost.toFixed(4))}}),[s,a]);if(t)return e.jsx(m,{className:i("h-full w-full",d)});if(!s||s.length===0)return e.jsx("div",{className:i("h-full flex items-center justify-center",d),children:e.jsx("p",{className:"text-muted-foreground",children:a==="hourly"?"No usage data for today":"No usage data available"})});const n=({x:r,y:x,payload:u,isRight:f})=>{const h=f?`$${u.value}`:X(Number(u.value));return e.jsx("text",{x:r,y:x,dy:4,textAnchor:f?"start":"end",fontSize:12,fill:"currentColor",className:i("fill-muted-foreground",o&&"blur-[4px]"),children:h})};return e.jsx("div",{className:i("w-full h-full",d),children:e.jsx(ie,{width:"100%",height:"100%",children:e.jsxs(Ue,{data:c,margin:{top:5,right:30,left:20,bottom:5},children:[e.jsxs("defs",{children:[e.jsxs("linearGradient",{id:"tokenGradient",x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"5%",stopColor:"#0080FF",stopOpacity:.8}),e.jsx("stop",{offset:"95%",stopColor:"#0080FF",stopOpacity:.1})]}),e.jsxs("linearGradient",{id:"costGradient",x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"5%",stopColor:"#00C49F",stopOpacity:.8}),e.jsx("stop",{offset:"95%",stopColor:"#00C49F",stopOpacity:.1})]})]}),e.jsx(qe,{strokeDasharray:"3 3",className:"stroke-muted"}),e.jsx(Oe,{dataKey:"dateFormatted",tick:{fontSize:12},tickLine:!1,axisLine:{className:"stroke-muted"}}),e.jsx(V,{yAxisId:"left",orientation:"left",tick:r=>e.jsx(n,{...r,isRight:!1}),tickLine:!1,axisLine:{className:"stroke-muted"}}),e.jsx(V,{yAxisId:"right",orientation:"right",tick:r=>e.jsx(n,{...r,isRight:!0}),tickLine:!1,axisLine:{className:"stroke-muted"}}),e.jsx(oe,{content:({active:r,payload:x,label:u})=>{if(!r||!x||!x.length)return null;const f=x[0].payload;return e.jsxs("div",{className:"rounded-lg border bg-background p-3 shadow-lg",children:[e.jsx("p",{className:"font-medium mb-2",children:u}),x.map((h,S)=>e.jsxs("p",{className:i("text-sm",o&&y),style:{color:h.color},children:[h.name,":"," ",h.name==="Tokens"?X(Number(h.value)||0):`$${h.value}`]},S)),"requests"in f&&e.jsxs("p",{className:i("text-sm text-muted-foreground mt-1",o&&y),children:["Requests: ",f.requests]})]})}}),e.jsx(Z,{yAxisId:"left",type:"monotone",dataKey:"tokens",stroke:"#0080FF",strokeWidth:2,fillOpacity:1,fill:"url(#tokenGradient)",name:"Tokens"}),e.jsx(Z,{yAxisId:"right",type:"monotone",dataKey:"costRounded",stroke:"#00C49F",strokeWidth:2,fillOpacity:1,fill:"url(#costGradient)",name:"Cost"})]})})})}function ze(s,t){if(t==="hourly"){const[d,o]=s.split(" ");if(d&&o){const c=new Date(`${d}T${o}:00Z`);return k(c,"HH:mm")}return s}const a=new Date(s);return t==="monthly"?k(a,"MMM yyyy"):k(a,"MMM dd")}function X(s){return s>=1e6?`${(s/1e6).toFixed(1)}M`:s>=1e3?`${(s/1e3).toFixed(1)}K`:s.toLocaleString()}function Ye({data:s,isLoading:t,className:a}){const{privacyMode:d}=R(),o=p.useMemo(()=>!s||s.length===0?[]:s.map(r=>({name:r.model,value:r.tokens,cost:r.cost,percentage:r.percentage,fill:te(r.model)})),[s]);if(t)return e.jsx(m,{className:i("h-[300px] w-full",a)});if(!s||s.length===0)return e.jsx("div",{className:i("h-[300px] flex items-center justify-center",a),children:e.jsx("p",{className:"text-muted-foreground",children:"No model data available"})});const c=({active:r,payload:x})=>{if(!r||!x)return null;const u=x;if(!u.length)return null;const f=u[0].payload;return e.jsxs("div",{className:"rounded-lg border bg-background p-2 shadow-lg text-xs",children:[e.jsx("p",{className:"font-medium mb-1",children:f.name}),e.jsxs("p",{className:i("text-muted-foreground",d&&y),children:[Qe(f.value)," (",f.percentage.toFixed(1),"%)"]}),e.jsxs("p",{className:i("text-muted-foreground",d&&y),children:["$",f.cost.toFixed(4)]})]})},n=r=>r.percentage>5?`${r.percentage.toFixed(1)}%`:"";return e.jsx("div",{className:i("w-full",a),children:e.jsx(ie,{width:"100%",height:250,children:e.jsxs(Ie,{children:[e.jsx(Ke,{data:o,cx:"50%",cy:"50%",labelLine:!1,label:n,innerRadius:50,outerRadius:70,paddingAngle:2,dataKey:"value",children:o.map((r,x)=>e.jsx(Ee,{fill:r.fill,strokeWidth:1},`cell-${x}`))}),e.jsx(oe,{content:c})]})})})}function Qe(s){return s>=1e6?`${(s/1e6).toFixed(1)}M`:s>=1e3?`${(s/1e3).toFixed(1)}K`:s.toLocaleString()}function Ve({model:s}){const{privacyMode:t}=R(),a=Ze(s.ioRatio);return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Se,{className:"h-4 w-4 text-primary shrink-0"}),e.jsx("h4",{className:"font-semibold leading-none truncate",title:s.model,children:s.model})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(B,{variant:"secondary",className:"text-[10px] h-5 px-1.5",children:[s.percentage.toFixed(1),"% usage"]}),e.jsxs(B,{variant:a.variant,className:"text-[10px] h-5 px-1.5",children:[s.ioRatio.toFixed(0),":1 I/O"]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"p-2 rounded-md bg-muted/50 border text-center",children:[e.jsxs("p",{className:i("text-lg font-bold",t&&y),children:["$",s.cost.toFixed(2)]}),e.jsx("p",{className:"text-[10px] text-muted-foreground uppercase tracking-wider",children:"Total Cost"})]}),e.jsxs("div",{className:"p-2 rounded-md bg-muted/50 border text-center",children:[e.jsx("p",{className:i("text-lg font-bold",t&&y),children:Je(s.tokens)}),e.jsx("p",{className:"text-[10px] text-muted-foreground uppercase tracking-wider",children:"Total Tokens"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("h5",{className:"text-[11px] font-medium text-muted-foreground uppercase tracking-wider",children:"Token Breakdown"}),e.jsxs("div",{className:i("space-y-1",t&&y),children:[e.jsx(O,{label:"Input",tokens:s.inputTokens,cost:s.costBreakdown.input.cost,color:"#335c67",icon:re}),e.jsx(O,{label:"Output",tokens:s.outputTokens,cost:s.costBreakdown.output.cost,color:"#fff3b0",icon:ne}),e.jsx(O,{label:"Cache Write",tokens:s.cacheCreationTokens,cost:s.costBreakdown.cacheCreation.cost,color:"#e09f3e",icon:W}),e.jsx(O,{label:"Cache Read",tokens:s.cacheReadTokens,cost:s.costBreakdown.cacheRead.cost,color:"#9e2a2b",icon:W})]})]}),e.jsxs("div",{className:"p-2.5 rounded-md border bg-muted/20 space-y-1.5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(De,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsx("span",{className:"text-xs font-medium",children:"Input/Output Ratio"})]}),e.jsx("p",{className:"text-[11px] text-muted-foreground leading-snug",children:a.description})]})]})}function O({label:s,tokens:t,cost:a,color:d,icon:o}){return t===0?null:e.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[e.jsx("div",{className:"w-1 h-6 rounded-full shrink-0",style:{backgroundColor:d}}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"font-medium truncate",children:s}),e.jsxs("span",{className:"font-mono text-muted-foreground",children:["$",a.toFixed(3)]})]}),e.jsxs("div",{className:"flex items-center gap-1.5 text-muted-foreground",children:[e.jsx(o,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{children:Xe(t)})]})]})]})}function Ze(s){return s>=200?{variant:"destructive",description:"Extended thinking or large context loading. Expected for reasoning models."}:s>=50?{variant:"secondary",description:"More input than output. Typical for analysis tasks."}:s>=5?{variant:"outline",description:"Balanced input/output ratio for typical coding tasks."}:{variant:"default",description:"More output than input. Generation-heavy workload."}}function Xe(s){return s.toLocaleString()}function Je(s){return s>=1e9?`${(s/1e9).toFixed(1)}B`:s>=1e6?`${(s/1e6).toFixed(1)}M`:s>=1e3?`${(s/1e3).toFixed(1)}K`:s.toString()}function es({data:s,isLoading:t,className:a}){const{privacyMode:d}=R(),o=p.useMemo(()=>{if(!s?.sessions||s.sessions.length===0)return null;const c=s.sessions,n=s.total,r=c.reduce((v,b)=>v+(b.inputTokens+b.outputTokens),0),x=Math.round(r/c.length),f=c.reduce((v,b)=>v+b.cost,0)/c.length,h=c[0],S=h?H(new Date(h.lastActivity),{addSuffix:!0}):"N/A";return{totalSessions:n,avgTokens:x,avgCost:f,lastActive:S,recentSessions:c.slice(0,3)}},[s]);return t?e.jsxs(g,{className:i("flex flex-col h-full",a),children:[e.jsx(N,{className:"px-3 py-2",children:e.jsx(m,{className:"h-5 w-32"})}),e.jsx(j,{className:"px-3 pb-3 pt-0 flex-1",children:e.jsx(m,{className:"h-full w-full"})})]}):o?e.jsxs(g,{className:i("flex flex-col h-full shadow-sm",a),children:[e.jsx(N,{className:"px-3 py-2",children:e.jsxs(C,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(Q,{className:"w-4 h-4"}),"Session Stats"]})}),e.jsxs(j,{className:"px-3 pb-3 pt-0 flex-1 flex flex-col gap-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"p-2 rounded-md bg-muted/50 border text-center",children:[e.jsxs("div",{className:"flex items-center justify-center gap-1.5 text-blue-600 dark:text-blue-400",children:[e.jsx(Le,{className:"w-4 h-4"}),e.jsx("span",{className:"text-xl font-bold",children:o.totalSessions})]}),e.jsx("p",{className:"text-[10px] text-muted-foreground uppercase tracking-wider mt-0.5",children:"Total Sessions"})]}),e.jsxs("div",{className:"p-2 rounded-md bg-muted/50 border text-center",children:[e.jsxs("div",{className:"flex items-center justify-center gap-1.5 text-green-600 dark:text-green-400",children:[e.jsx(le,{className:"w-4 h-4"}),e.jsxs("span",{className:i("text-xl font-bold",d&&y),children:["$",o.avgCost.toFixed(2)]})]}),e.jsx("p",{className:"text-[10px] text-muted-foreground uppercase tracking-wider mt-0.5",children:"Avg Cost/Session"})]})]}),e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground font-medium mb-1",children:[e.jsx(Fe,{className:"w-3 h-3"}),"Recent Activity"]}),e.jsx("div",{className:"space-y-1.5",children:o.recentSessions.map(c=>e.jsxs("div",{className:"flex items-center justify-between text-xs p-1.5 rounded bg-muted/30 hover:bg-muted/50 transition-colors",children:[e.jsxs("div",{className:"flex flex-col min-w-0 flex-1",children:[e.jsx("span",{className:"font-medium truncate",title:c.projectPath,children:c.projectPath.split("/").pop()}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:H(new Date(c.lastActivity),{addSuffix:!0})})]}),e.jsxs("div",{className:i("text-right shrink-0 ml-2",d&&y),children:[e.jsxs("div",{className:"font-mono",children:["$",c.cost.toFixed(2)]}),e.jsxs("div",{className:"text-[10px] text-muted-foreground",children:[ss(c.inputTokens+c.outputTokens)," toks"]})]})]},c.sessionId))})]})]})]}):e.jsxs(g,{className:i("flex flex-col h-full",a),children:[e.jsx(N,{className:"px-3 py-2",children:e.jsxs(C,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(Q,{className:"w-4 h-4"}),"Session Stats"]})}),e.jsx(j,{className:"px-3 pb-3 pt-0 flex-1 flex items-center justify-center",children:e.jsx("p",{className:"text-sm text-muted-foreground text-center",children:"No session data available"})})]})}function ss(s){return s>=1e9?`${(s/1e9).toFixed(1)}B`:s>=1e6?`${(s/1e6).toFixed(1)}M`:s>=1e3?`${(s/1e3).toFixed(1)}K`:s.toString()}function ts({className:s,isLoading:t}){const{data:a,isLoading:d}=ye(),{data:o,isLoading:c,error:n}=be(a?.running);if(t||d||a?.running&&c)return e.jsxs(g,{className:i("flex flex-col h-full",s),children:[e.jsx(N,{className:"px-3 py-2",children:e.jsxs(C,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(q,{className:"h-4 w-4"}),"CLIProxy Stats"]})}),e.jsx(j,{className:"px-3 pb-3 pt-0 flex-1",children:e.jsxs("div",{className:"space-y-3",children:[e.jsx(m,{className:"h-4 w-[100px]"}),e.jsx(m,{className:"h-16 w-full"})]})})]});if(!a?.running)return e.jsxs(g,{className:i("flex flex-col h-full border-dashed",s),children:[e.jsx(N,{className:"px-3 py-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(C,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(q,{className:"h-4 w-4 text-muted-foreground"}),"CLIProxy Stats"]}),e.jsx(B,{variant:"secondary",className:"text-[10px] h-5",children:"Offline"})]})}),e.jsx(j,{className:"px-3 pb-3 pt-0 flex-1 flex items-center justify-center",children:e.jsx("p",{className:"text-xs text-muted-foreground text-center",children:"Start a CLIProxy session (gemini, codex, agy) to collect stats."})})]});if(n)return e.jsxs(g,{className:i("flex flex-col h-full border-destructive/50",s),children:[e.jsx(N,{className:"px-3 py-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(C,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(q,{className:"h-4 w-4"}),"CLIProxy Stats"]}),e.jsx(B,{variant:"destructive",className:"text-[10px] h-5",children:"Error"})]})}),e.jsx(j,{className:"px-3 pb-3 pt-0 flex-1",children:e.jsx("p",{className:"text-xs text-destructive",children:n.message})})]});const x=o?.totalRequests??0,u=o?.quotaExceededCount??0,f=x-u,h=x>0?Math.round(f/x*100):100,S=o?.tokens?.total??0,v=Object.entries(o?.requestsByModel??{}).sort((D,L)=>L[1]-D[1]).slice(0,4),b=v.length>0?v[0][1]:1;return e.jsxs(g,{className:i("flex flex-col h-full overflow-hidden",s),children:[e.jsx(N,{className:"px-3 py-2 border-b bg-muted/5",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(C,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(q,{className:"h-4 w-4"}),"CLIProxy Stats"]}),e.jsxs(B,{variant:"outline",className:"text-[10px] h-5 text-green-600 border-green-200 bg-green-50 dark:bg-green-900/10 dark:border-green-800",children:[e.jsx(le,{className:"h-3 w-3 mr-0.5"}),"Running"]})]})}),e.jsx(j,{className:"p-0 flex-1 min-h-0",children:e.jsx(we,{className:"h-full",children:e.jsxs("div",{className:"p-3 space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2 p-2 rounded-lg bg-muted/30",children:[e.jsxs("div",{className:"relative",children:[e.jsxs("svg",{className:"w-10 h-10 -rotate-90",viewBox:"0 0 36 36",children:[e.jsx("circle",{cx:"18",cy:"18",r:"14",fill:"none",stroke:"currentColor",strokeWidth:"3",className:"text-muted/30"}),e.jsx("circle",{cx:"18",cy:"18",r:"14",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeDasharray:`${h*.88} 88`,strokeLinecap:"round",className:h>=90?"text-green-500":"text-amber-500"})]}),e.jsxs("span",{className:"absolute inset-0 flex items-center justify-center text-[8px] font-bold",children:[h,"%"]})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-lg font-bold leading-none",children:J(x)}),e.jsx("div",{className:"text-[9px] text-muted-foreground mt-0.5",children:u>0?`${u} failed`:"All success"})]})]}),e.jsxs("div",{className:"flex items-center gap-2 p-2 rounded-lg bg-muted/30",children:[e.jsx("div",{className:"p-1.5 rounded-md bg-purple-100 dark:bg-purple-900/20",children:e.jsx(Te,{className:"h-4 w-4 text-purple-600"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-lg font-bold leading-none",children:J(S)}),e.jsx("div",{className:"text-[9px] text-muted-foreground mt-0.5",children:"Total tokens"})]})]})]}),v.length>0&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] font-medium text-muted-foreground",children:[e.jsx(Me,{className:"h-3 w-3"}),"Models Used"]}),e.jsx("div",{className:"space-y-1",children:v.map(([D,L])=>{const K=Math.round(L/b*100),E=as(D);return e.jsxs("div",{className:"group",children:[e.jsxs("div",{className:"flex items-center justify-between text-[10px] mb-0.5",children:[e.jsx("span",{className:"truncate font-medium",title:D,children:E}),e.jsx("span",{className:"text-muted-foreground shrink-0 ml-2",children:L})]}),e.jsx("div",{className:"h-1 bg-muted/50 rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full bg-accent/70 rounded-full transition-all",style:{width:`${K}%`}})})]},D)})})]})]})})})]})}function J(s){return s>=1e6?`${(s/1e6).toFixed(1)}M`:s>=1e3?`${(s/1e3).toFixed(1)}K`:s.toLocaleString()}function as(s){let t=s.replace(/^gemini-claude-/,"").replace(/^gemini-/,"").replace(/^claude-/,"").replace(/^anthropic\./,"").replace(/-thinking$/," Thinking");return t=t.split(/[-_]/).map(a=>a.charAt(0).toUpperCase()+a.slice(1)).join(" "),t.length>20&&(t=t.slice(0,18)+"..."),t}const rs="/api";function w(s){const t=s.getFullYear(),a=String(s.getMonth()+1).padStart(2,"0"),d=String(s.getDate()).padStart(2,"0");return`${t}${a}${d}`}const T={summary:s=>{const t=new URLSearchParams;return s?.startDate&&t.append("since",w(s.startDate)),s?.endDate&&t.append("until",w(s.endDate)),s?.profile&&t.append("profile",s.profile),$(`/usage/summary?${t}`)},trends:s=>{const t=new URLSearchParams;return s?.startDate&&t.append("since",w(s.startDate)),s?.endDate&&t.append("until",w(s.endDate)),s?.profile&&t.append("profile",s.profile),$(`/usage/daily?${t}`)},hourly:s=>{const t=new URLSearchParams;return s?.startDate&&t.append("since",w(s.startDate)),s?.endDate&&t.append("until",w(s.endDate)),$(`/usage/hourly?${t}`)},models:s=>{const t=new URLSearchParams;return s?.startDate&&t.append("since",w(s.startDate)),s?.endDate&&t.append("until",w(s.endDate)),s?.profile&&t.append("profile",s.profile),$(`/usage/models?${t}`)},sessions:s=>{const t=new URLSearchParams;return s?.startDate&&t.append("since",w(s.startDate)),s?.endDate&&t.append("until",w(s.endDate)),s?.profile&&t.append("profile",s.profile),s?.limit&&t.append("limit",s.limit.toString()),s?.offset&&t.append("offset",s.offset.toString()),$(`/usage/sessions?${t}`)},monthly:(s,t)=>{const a=new URLSearchParams;return s&&a.append("months",s.toString()),t&&a.append("profile",t),$(`/usage/monthly?${a}`)},refresh:async()=>{if(!(await fetch(`${rs}/usage/refresh`,{method:"POST",headers:{"Content-Type":"application/json"}})).ok)throw new Error("Failed to refresh usage cache")},status:()=>$("/usage/status"),insights:s=>{const t=new URLSearchParams;return s?.startDate&&t.append("since",w(s.startDate)),s?.endDate&&t.append("until",w(s.endDate)),s?.profile&&t.append("profile",s.profile),$(`/usage/insights?${t}`)}};async function $(s){const a=await fetch(`/api${s}`,{headers:{"Content-Type":"application/json"}});if(!a.ok){const o=await a.json().catch(()=>({error:"Unknown error"}));throw new Error(o.error||a.statusText)}const d=await a.json();return d.data||d}function ns(s){return P({queryKey:["usage","summary",s],queryFn:()=>T.summary(s),staleTime:60*1e3})}function ls(s){return P({queryKey:["usage","trends",s],queryFn:()=>T.trends(s),staleTime:60*1e3})}function is(s){return P({queryKey:["usage","hourly",s],queryFn:()=>T.hourly(s),staleTime:60*1e3})}function os(s){return P({queryKey:["usage","models",s],queryFn:()=>T.models(s),staleTime:60*1e3})}function cs(){const s=Ge();return p.useCallback(async()=>{await T.refresh(),await s.invalidateQueries({queryKey:["usage"]})},[s])}function ds(){return P({queryKey:["usage","status"],queryFn:()=>T.status(),staleTime:10*1e3,refetchInterval:30*1e3})}function xs(s){return P({queryKey:["usage","sessions",s],queryFn:()=>T.sessions(s),staleTime:60*1e3})}function us(s){return s>=1e9?`${(s/1e9).toFixed(1)}B`:s>=1e6?`${(s/1e6).toFixed(1)}M`:s>=1e3?`${(s/1e3).toFixed(0)}K`:s.toString()}function ks(){const{privacyMode:s}=R(),[t,a]=p.useState({from:F(new Date,30),to:new Date}),[d,o]=p.useState(!1),[c,n]=p.useState(null),[r,x]=p.useState(null),[u,f]=p.useState("daily"),h=p.useRef(null),S=cs(),v=async()=>{o(!0);try{await S()}finally{o(!1)}},b={startDate:t?.from,endDate:t?.to},{data:D,isLoading:L}=ns(b),{data:K,isLoading:E}=ls(b),{data:ce,isLoading:de}=is(b),{data:_,isLoading:z}=os(b),{data:xe,isLoading:ue}=xs({...b,limit:3}),{data:G}=ds(),me=p.useCallback(()=>{const l=new Date;a({from:F(l,1),to:l}),f("hourly")},[]),fe=p.useCallback(l=>{a(l),f("daily")},[]),Y=p.useMemo(()=>G?.lastFetch?H(new Date(G.lastFetch),{addSuffix:!0}):null,[G?.lastFetch]),he=p.useCallback((l,A)=>{const U=A.currentTarget.getBoundingClientRect();x({x:U.left+U.width/2,y:U.top+U.height/2}),n(l)},[]),pe=p.useCallback(()=>{n(null),x(null)},[]);return e.jsxs("div",{className:"flex flex-col h-full overflow-hidden px-4 pt-4 pb-50 gap-4",children:[e.jsxs("div",{className:"flex items-center justify-between shrink-0",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl font-semibold",children:"Analytics"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Track usage & insights"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(I,{variant:u==="hourly"?"default":"outline",size:"sm",className:"h-8",onClick:me,children:"24H"}),e.jsx(He,{value:t,onChange:fe,presets:[{label:"7D",range:{from:F(new Date,7),to:new Date}},{label:"30D",range:{from:F(new Date,30),to:new Date}},{label:"Month",range:{from:ke(new Date),to:new Date}},{label:"All Time",range:{from:void 0,to:new Date}}]}),Y&&e.jsxs("span",{className:"text-xs text-muted-foreground whitespace-nowrap",children:["Updated ",Y]}),e.jsx(I,{variant:"outline",size:"sm",className:"gap-2 h-8",onClick:v,disabled:d,children:e.jsx(Re,{className:`w-3.5 h-3.5 ${d?"animate-spin":""}`})})]})]}),e.jsx(We,{data:D,isLoading:L}),e.jsxs("div",{className:"flex-1 flex flex-col min-h-0 gap-4",children:[e.jsxs(g,{className:"flex flex-col flex-1 min-h-0 max-h-[500px] overflow-hidden shadow-sm",children:[e.jsx(N,{className:"px-3 py-2 shrink-0",children:e.jsxs(C,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(Pe,{className:"w-4 h-4"}),u==="hourly"?"Last 24 Hours":"Usage Trends"]})}),e.jsx(j,{className:"px-3 pb-3 pt-0 flex-1 min-h-0",children:e.jsx(_e,{data:u==="hourly"?ce||[]:K||[],isLoading:u==="hourly"?de:E,granularity:u==="hourly"?"hourly":"daily"})})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-10 gap-4 h-auto lg:h-[180px] shrink-0",children:[e.jsxs(g,{className:"flex flex-col h-full min-h-0 shadow-sm lg:col-span-4",children:[e.jsx(N,{className:"px-3 py-2",children:e.jsxs(C,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(ae,{className:"w-4 h-4"}),"Cost by Model"]})}),e.jsx(j,{className:"px-2 pb-2 pt-0 flex-1 min-h-0 overflow-y-auto",children:z?e.jsx(m,{className:"h-full w-full"}):e.jsxs("div",{className:"space-y-0.5",children:[[..._||[]].sort((l,A)=>A.cost-l.cost).map(l=>e.jsxs("button",{className:"group flex items-center text-xs w-full hover:bg-muted/50 rounded px-2 py-1.5 transition-colors cursor-pointer gap-3",onClick:A=>he(l,A),title:"Click for details",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0 w-[180px] shrink-0",children:[e.jsx("div",{className:"w-2 h-2 rounded-full shrink-0",style:{backgroundColor:te(l.model)}}),e.jsx("span",{className:"font-medium truncate group-hover:underline underline-offset-2",children:l.model})]}),e.jsx("div",{className:"flex-1 flex items-center gap-1 min-w-0",children:e.jsxs("div",{className:"flex-1 h-2 bg-muted rounded-full overflow-hidden flex",children:[e.jsx("div",{className:"h-full",style:{backgroundColor:"#335c67",width:`${l.cost>0?l.costBreakdown.input.cost/l.cost*100:0}%`},title:`Input: $${l.costBreakdown.input.cost.toFixed(2)}`}),e.jsx("div",{className:"h-full",style:{backgroundColor:"#fff3b0",width:`${l.cost>0?l.costBreakdown.output.cost/l.cost*100:0}%`},title:`Output: $${l.costBreakdown.output.cost.toFixed(2)}`}),e.jsx("div",{className:"h-full",style:{backgroundColor:"#e09f3e",width:`${l.cost>0?l.costBreakdown.cacheCreation.cost/l.cost*100:0}%`},title:`Cache Write: $${l.costBreakdown.cacheCreation.cost.toFixed(2)}`}),e.jsx("div",{className:"h-full",style:{backgroundColor:"#9e2a2b",width:`${l.cost>0?l.costBreakdown.cacheRead.cost/l.cost*100:0}%`},title:`Cache Read: $${l.costBreakdown.cacheRead.cost.toFixed(2)}`})]})}),e.jsx("span",{className:i("text-[10px] text-muted-foreground w-14 text-right shrink-0",s&&y),children:us(l.tokens)}),e.jsxs("span",{className:i("font-mono font-medium w-16 text-right shrink-0",s&&y),children:["$",l.cost.toFixed(2)]}),e.jsx(Ae,{className:"w-3 h-3 opacity-0 group-hover:opacity-50 transition-opacity shrink-0"})]},l.model)),e.jsxs("div",{className:"flex items-center gap-3 pt-2 px-2 text-[10px] text-muted-foreground border-t mt-2",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx("div",{className:"w-2 h-2 rounded-full",style:{backgroundColor:"#335c67"}}),"Input"]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx("div",{className:"w-2 h-2 rounded-full border border-muted-foreground/30",style:{backgroundColor:"#fff3b0"}}),"Output"]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx("div",{className:"w-2 h-2 rounded-full",style:{backgroundColor:"#e09f3e"}}),"Cache Write"]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx("div",{className:"w-2 h-2 rounded-full",style:{backgroundColor:"#9e2a2b"}}),"Cache Read"]})]})]})})]}),e.jsxs(g,{className:"flex flex-col h-full min-h-0 shadow-sm lg:col-span-2",children:[e.jsx(N,{className:"px-3 py-2",children:e.jsxs(C,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(Be,{className:"w-4 h-4"}),"Model Usage"]})}),e.jsx(j,{className:"px-2 pb-2 pt-0 flex-1 min-h-0 flex items-center justify-center",children:e.jsx(Ye,{data:_||[],isLoading:z,className:"h-full w-full"})})]}),e.jsx(es,{data:xe,isLoading:ue,className:"lg:col-span-2"}),e.jsx(ts,{isLoading:L,className:"lg:col-span-2"})]}),e.jsxs(ee,{open:!!c,onOpenChange:l=>!l&&pe(),children:[e.jsx(ve,{asChild:!0,children:e.jsx("div",{ref:h,className:"fixed pointer-events-none",style:{left:r?.x??0,top:r?.y??0,width:1,height:1}})}),e.jsx(se,{className:"w-80 p-3",side:"top",align:"center",children:c&&e.jsx(Ve,{model:c})})]})]})]})}function Cs(){return e.jsxs("div",{className:"space-y-4 h-full overflow-hidden",children:[e.jsxs(g,{className:"flex flex-col min-h-[300px]",children:[e.jsx(N,{className:"p-4 pb-2",children:e.jsx(m,{className:"h-4 w-32"})}),e.jsx(j,{className:"p-4 pt-0 flex-1",children:e.jsx(m,{className:"h-full w-full"})})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:[e.jsxs(g,{className:"flex flex-col min-h-[250px]",children:[e.jsx(N,{className:"p-4 pb-2",children:e.jsx(m,{className:"h-4 w-28"})}),e.jsx(j,{className:"p-4 pt-2",children:e.jsx("div",{className:"space-y-3",children:[1,2,3,4,5].map(s=>e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(m,{className:"w-2.5 h-2.5 rounded-full"}),e.jsx(m,{className:"h-3 w-24"})]}),e.jsx(m,{className:"h-3 w-16"})]},s))})})]}),e.jsxs(g,{className:"flex flex-col min-h-[250px]",children:[e.jsx(N,{className:"p-4 pb-2",children:e.jsx(m,{className:"h-4 w-28"})}),e.jsx(j,{className:"p-4 pt-0 flex-1",children:e.jsxs("div",{className:"flex w-full h-full items-center",children:[e.jsx("div",{className:"flex-1 flex justify-center",children:e.jsx(m,{className:"h-[180px] w-[180px] rounded-full"})}),e.jsx("div",{className:"w-[140px] shrink-0 pl-2 space-y-2",children:[1,2,3,4].map(s=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(m,{className:"w-2 h-2 rounded-full"}),e.jsx(m,{className:"h-3 w-20"})]},s))})]})})]})]})]})}export{ks as AnalyticsPage,Cs as AnalyticsSkeleton};
1
+ import{j as e}from"./radix-ui-VbLlN_Dz.js";import{c as ge,r as p}from"./react-vendor-DMek_JCF.js";import{C as g,a as j,b as N,c as C}from"./card-CkFFTnqL.js";import{c as i,B as I,P as ee,a as je,b as se,C as Ne,u as R,S as m,d as y,g as te,e as B,f as ye,h as be,i as we,j as ve}from"./index-EyLCmFok.js";import{K as F,f as k,L as H,H as ke}from"./utils-CzKF5WmX.js";import{N as Ce,O as $e,Q as ae,V as W,Y as re,_ as ne,w as Se,G as De,$ as Q,U as Le,Z as le,z as Fe,a0 as q,a1 as Te,a2 as Me,p as Re,a3 as Pe,a as Ae,a4 as Be}from"./icons-B9AtZK5c.js";import{R as ie,A as Ue,C as qe,X as Oe,Y as V,T as oe,a as Z,P as Ie,b as Ke,c as Ee}from"./charts-D_0N6JY8.js";import{u as Ge,a as P}from"./tanstack-yybD444-.js";import"./notifications-cqk-Qeo2.js";import"./form-utils-BXvNPyud.js";import"./code-highlight-C2TXE0-z.js";function He({value:s,onChange:t,presets:a=[{label:"Last 7 days",range:{from:F(new Date,7),to:new Date}},{label:"Last 30 days",range:{from:F(new Date,30),to:new Date}},{label:"Last 90 days",range:{from:F(new Date,90),to:new Date}}],className:d}){const[o,c]=ge.useState(!1),n=r=>!s||!s.from||!s.to||!r.from||!r.to?!1:k(s.from,"yyyy-MM-dd")===k(r.from,"yyyy-MM-dd")&&k(s.to,"yyyy-MM-dd")===k(r.to,"yyyy-MM-dd");return e.jsxs("div",{className:i("flex items-center gap-2",d),children:[a.map(r=>e.jsx(I,{variant:n(r.range)?"default":"outline",size:"sm",onClick:()=>t(r.range),children:r.label},r.label)),e.jsxs(ee,{open:o,onOpenChange:c,children:[e.jsx(je,{asChild:!0,children:e.jsxs(I,{id:"date",variant:"outline",className:i("w-auto min-w-[240px] justify-start text-left font-normal",!s&&"text-muted-foreground"),children:[e.jsx(Ce,{className:"mr-2 h-4 w-4"}),s?.from?s.to?e.jsxs(e.Fragment,{children:[k(s.from,"LLL dd, y")," - ",k(s.to,"LLL dd, y")]}):k(s.from,"LLL dd, y"):e.jsx("span",{children:"Pick a date"})]})}),e.jsx(se,{className:"w-auto p-0",align:"end",children:e.jsx(Ne,{initialFocus:!0,mode:"range",defaultMonth:s?.from,selected:s,onSelect:t,numberOfMonths:2})})]})]})}function We({data:s,isLoading:t}){const{privacyMode:a}=R();if(t)return e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 xl:grid-cols-5 gap-4",children:[1,2,3,4,5].map(n=>e.jsx(g,{children:e.jsx(j,{className:"p-6",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(m,{className:"h-4 w-[100px]"}),e.jsx(m,{className:"h-8 w-[80px]"})]}),e.jsx(m,{className:"h-8 w-8 rounded-lg"})]})})},n))});const d=(s?.tokenBreakdown?.cacheCreation?.cost??0)+(s?.tokenBreakdown?.cacheRead?.cost??0),o=s?.totalCost?Math.round(d/s.totalCost*100):0,c=[{title:"Total Tokens",value:s?.totalTokens??0,icon:$e,format:n=>M(n),color:"text-blue-600",bgColor:"bg-blue-100 dark:bg-blue-900/20",subtitle:`${M(s?.totalInputTokens??0)} in / ${M(s?.totalOutputTokens??0)} out`},{title:"Total Cost",value:s?.totalCost??0,icon:ae,format:n=>`$${n.toFixed(2)}`,color:"text-green-600",bgColor:"bg-green-100 dark:bg-green-900/20",subtitle:`$${s?.averageCostPerDay?.toFixed(2)??"0.00"}/day avg`},{title:"Cache Tokens",value:s?.totalCacheTokens??0,icon:W,format:n=>M(n),color:"text-cyan-600",bgColor:"bg-cyan-100 dark:bg-cyan-900/20",subtitle:`$${d.toFixed(2)} (${o}% of cost)`},{title:"Input Cost",value:s?.tokenBreakdown?.input?.cost??0,icon:re,format:n=>`$${n.toFixed(2)}`,color:"text-purple-600",bgColor:"bg-purple-100 dark:bg-purple-900/20",subtitle:`${M(s?.tokenBreakdown?.input?.tokens??0)} tokens`},{title:"Output Cost",value:s?.tokenBreakdown?.output?.cost??0,icon:ne,format:n=>`$${n.toFixed(2)}`,color:"text-orange-600",bgColor:"bg-orange-100 dark:bg-orange-900/20",subtitle:`${M(s?.tokenBreakdown?.output?.tokens??0)} tokens`}];return e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 xl:grid-cols-5 gap-4",children:c.map((n,r)=>{const x=n.icon;return e.jsx(g,{className:"hover:shadow-md transition-shadow",children:e.jsx(j,{className:"p-4",children:e.jsxs("div",{className:"flex items-center justify-between space-x-2",children:[e.jsxs("div",{className:"space-y-1 min-w-0",children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground truncate",children:n.title}),e.jsx("p",{className:i("text-xl font-bold truncate",a&&y),children:n.format(n.value)}),n.subtitle&&e.jsx("p",{className:i("text-[10px] text-muted-foreground truncate",a&&y),children:n.subtitle})]}),e.jsx("div",{className:i("p-2 rounded-lg shrink-0",n.bgColor),children:e.jsx(x,{className:i("h-4 w-4",n.color)})})]})})},r)})})}function M(s){return s>=1e6?`${(s/1e6).toFixed(1)}M`:s>=1e3?`${(s/1e3).toFixed(1)}K`:s.toLocaleString()}function _e({data:s,isLoading:t,granularity:a="daily",className:d}){const{privacyMode:o}=R(),c=p.useMemo(()=>!s||s.length===0?[]:(a==="hourly"?s:[...s].reverse()).map(x=>{const u="hour"in x?x.hour:x.date;return{...x,dateFormatted:ze(u,a),costRounded:Number(x.cost.toFixed(4))}}),[s,a]);if(t)return e.jsx(m,{className:i("h-full w-full",d)});if(!s||s.length===0)return e.jsx("div",{className:i("h-full flex items-center justify-center",d),children:e.jsx("p",{className:"text-muted-foreground",children:a==="hourly"?"No usage data for today":"No usage data available"})});const n=({x:r,y:x,payload:u,isRight:f})=>{const h=f?`$${u.value}`:X(Number(u.value));return e.jsx("text",{x:r,y:x,dy:4,textAnchor:f?"start":"end",fontSize:12,fill:"currentColor",className:i("fill-muted-foreground",o&&"blur-[4px]"),children:h})};return e.jsx("div",{className:i("w-full h-full",d),children:e.jsx(ie,{width:"100%",height:"100%",children:e.jsxs(Ue,{data:c,margin:{top:5,right:30,left:20,bottom:5},children:[e.jsxs("defs",{children:[e.jsxs("linearGradient",{id:"tokenGradient",x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"5%",stopColor:"#0080FF",stopOpacity:.8}),e.jsx("stop",{offset:"95%",stopColor:"#0080FF",stopOpacity:.1})]}),e.jsxs("linearGradient",{id:"costGradient",x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"5%",stopColor:"#00C49F",stopOpacity:.8}),e.jsx("stop",{offset:"95%",stopColor:"#00C49F",stopOpacity:.1})]})]}),e.jsx(qe,{strokeDasharray:"3 3",className:"stroke-muted"}),e.jsx(Oe,{dataKey:"dateFormatted",tick:{fontSize:12},tickLine:!1,axisLine:{className:"stroke-muted"}}),e.jsx(V,{yAxisId:"left",orientation:"left",tick:r=>e.jsx(n,{...r,isRight:!1}),tickLine:!1,axisLine:{className:"stroke-muted"}}),e.jsx(V,{yAxisId:"right",orientation:"right",tick:r=>e.jsx(n,{...r,isRight:!0}),tickLine:!1,axisLine:{className:"stroke-muted"}}),e.jsx(oe,{content:({active:r,payload:x,label:u})=>{if(!r||!x||!x.length)return null;const f=x[0].payload;return e.jsxs("div",{className:"rounded-lg border bg-background p-3 shadow-lg",children:[e.jsx("p",{className:"font-medium mb-2",children:u}),x.map((h,S)=>e.jsxs("p",{className:i("text-sm",o&&y),style:{color:h.color},children:[h.name,":"," ",h.name==="Tokens"?X(Number(h.value)||0):`$${h.value}`]},S)),"requests"in f&&e.jsxs("p",{className:i("text-sm text-muted-foreground mt-1",o&&y),children:["Requests: ",f.requests]})]})}}),e.jsx(Z,{yAxisId:"left",type:"monotone",dataKey:"tokens",stroke:"#0080FF",strokeWidth:2,fillOpacity:1,fill:"url(#tokenGradient)",name:"Tokens"}),e.jsx(Z,{yAxisId:"right",type:"monotone",dataKey:"costRounded",stroke:"#00C49F",strokeWidth:2,fillOpacity:1,fill:"url(#costGradient)",name:"Cost"})]})})})}function ze(s,t){if(t==="hourly"){const[d,o]=s.split(" ");if(d&&o){const c=new Date(`${d}T${o}:00Z`);return k(c,"HH:mm")}return s}const a=new Date(s);return t==="monthly"?k(a,"MMM yyyy"):k(a,"MMM dd")}function X(s){return s>=1e6?`${(s/1e6).toFixed(1)}M`:s>=1e3?`${(s/1e3).toFixed(1)}K`:s.toLocaleString()}function Ye({data:s,isLoading:t,className:a}){const{privacyMode:d}=R(),o=p.useMemo(()=>!s||s.length===0?[]:s.map(r=>({name:r.model,value:r.tokens,cost:r.cost,percentage:r.percentage,fill:te(r.model)})),[s]);if(t)return e.jsx(m,{className:i("h-[300px] w-full",a)});if(!s||s.length===0)return e.jsx("div",{className:i("h-[300px] flex items-center justify-center",a),children:e.jsx("p",{className:"text-muted-foreground",children:"No model data available"})});const c=({active:r,payload:x})=>{if(!r||!x)return null;const u=x;if(!u.length)return null;const f=u[0].payload;return e.jsxs("div",{className:"rounded-lg border bg-background p-2 shadow-lg text-xs",children:[e.jsx("p",{className:"font-medium mb-1",children:f.name}),e.jsxs("p",{className:i("text-muted-foreground",d&&y),children:[Qe(f.value)," (",f.percentage.toFixed(1),"%)"]}),e.jsxs("p",{className:i("text-muted-foreground",d&&y),children:["$",f.cost.toFixed(4)]})]})},n=r=>r.percentage>5?`${r.percentage.toFixed(1)}%`:"";return e.jsx("div",{className:i("w-full",a),children:e.jsx(ie,{width:"100%",height:250,children:e.jsxs(Ie,{children:[e.jsx(Ke,{data:o,cx:"50%",cy:"50%",labelLine:!1,label:n,innerRadius:50,outerRadius:70,paddingAngle:2,dataKey:"value",children:o.map((r,x)=>e.jsx(Ee,{fill:r.fill,strokeWidth:1},`cell-${x}`))}),e.jsx(oe,{content:c})]})})})}function Qe(s){return s>=1e6?`${(s/1e6).toFixed(1)}M`:s>=1e3?`${(s/1e3).toFixed(1)}K`:s.toLocaleString()}function Ve({model:s}){const{privacyMode:t}=R(),a=Ze(s.ioRatio);return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Se,{className:"h-4 w-4 text-primary shrink-0"}),e.jsx("h4",{className:"font-semibold leading-none truncate",title:s.model,children:s.model})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(B,{variant:"secondary",className:"text-[10px] h-5 px-1.5",children:[s.percentage.toFixed(1),"% usage"]}),e.jsxs(B,{variant:a.variant,className:"text-[10px] h-5 px-1.5",children:[s.ioRatio.toFixed(0),":1 I/O"]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"p-2 rounded-md bg-muted/50 border text-center",children:[e.jsxs("p",{className:i("text-lg font-bold",t&&y),children:["$",s.cost.toFixed(2)]}),e.jsx("p",{className:"text-[10px] text-muted-foreground uppercase tracking-wider",children:"Total Cost"})]}),e.jsxs("div",{className:"p-2 rounded-md bg-muted/50 border text-center",children:[e.jsx("p",{className:i("text-lg font-bold",t&&y),children:Je(s.tokens)}),e.jsx("p",{className:"text-[10px] text-muted-foreground uppercase tracking-wider",children:"Total Tokens"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("h5",{className:"text-[11px] font-medium text-muted-foreground uppercase tracking-wider",children:"Token Breakdown"}),e.jsxs("div",{className:i("space-y-1",t&&y),children:[e.jsx(O,{label:"Input",tokens:s.inputTokens,cost:s.costBreakdown.input.cost,color:"#335c67",icon:re}),e.jsx(O,{label:"Output",tokens:s.outputTokens,cost:s.costBreakdown.output.cost,color:"#fff3b0",icon:ne}),e.jsx(O,{label:"Cache Write",tokens:s.cacheCreationTokens,cost:s.costBreakdown.cacheCreation.cost,color:"#e09f3e",icon:W}),e.jsx(O,{label:"Cache Read",tokens:s.cacheReadTokens,cost:s.costBreakdown.cacheRead.cost,color:"#9e2a2b",icon:W})]})]}),e.jsxs("div",{className:"p-2.5 rounded-md border bg-muted/20 space-y-1.5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(De,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsx("span",{className:"text-xs font-medium",children:"Input/Output Ratio"})]}),e.jsx("p",{className:"text-[11px] text-muted-foreground leading-snug",children:a.description})]})]})}function O({label:s,tokens:t,cost:a,color:d,icon:o}){return t===0?null:e.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[e.jsx("div",{className:"w-1 h-6 rounded-full shrink-0",style:{backgroundColor:d}}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"font-medium truncate",children:s}),e.jsxs("span",{className:"font-mono text-muted-foreground",children:["$",a.toFixed(3)]})]}),e.jsxs("div",{className:"flex items-center gap-1.5 text-muted-foreground",children:[e.jsx(o,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{children:Xe(t)})]})]})]})}function Ze(s){return s>=200?{variant:"destructive",description:"Extended thinking or large context loading. Expected for reasoning models."}:s>=50?{variant:"secondary",description:"More input than output. Typical for analysis tasks."}:s>=5?{variant:"outline",description:"Balanced input/output ratio for typical coding tasks."}:{variant:"default",description:"More output than input. Generation-heavy workload."}}function Xe(s){return s.toLocaleString()}function Je(s){return s>=1e9?`${(s/1e9).toFixed(1)}B`:s>=1e6?`${(s/1e6).toFixed(1)}M`:s>=1e3?`${(s/1e3).toFixed(1)}K`:s.toString()}function es({data:s,isLoading:t,className:a}){const{privacyMode:d}=R(),o=p.useMemo(()=>{if(!s?.sessions||s.sessions.length===0)return null;const c=s.sessions,n=s.total,r=c.reduce((v,b)=>v+(b.inputTokens+b.outputTokens),0),x=Math.round(r/c.length),f=c.reduce((v,b)=>v+b.cost,0)/c.length,h=c[0],S=h?H(new Date(h.lastActivity),{addSuffix:!0}):"N/A";return{totalSessions:n,avgTokens:x,avgCost:f,lastActive:S,recentSessions:c.slice(0,3)}},[s]);return t?e.jsxs(g,{className:i("flex flex-col h-full",a),children:[e.jsx(N,{className:"px-3 py-2",children:e.jsx(m,{className:"h-5 w-32"})}),e.jsx(j,{className:"px-3 pb-3 pt-0 flex-1",children:e.jsx(m,{className:"h-full w-full"})})]}):o?e.jsxs(g,{className:i("flex flex-col h-full shadow-sm",a),children:[e.jsx(N,{className:"px-3 py-2",children:e.jsxs(C,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(Q,{className:"w-4 h-4"}),"Session Stats"]})}),e.jsxs(j,{className:"px-3 pb-3 pt-0 flex-1 flex flex-col gap-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"p-2 rounded-md bg-muted/50 border text-center",children:[e.jsxs("div",{className:"flex items-center justify-center gap-1.5 text-blue-600 dark:text-blue-400",children:[e.jsx(Le,{className:"w-4 h-4"}),e.jsx("span",{className:"text-xl font-bold",children:o.totalSessions})]}),e.jsx("p",{className:"text-[10px] text-muted-foreground uppercase tracking-wider mt-0.5",children:"Total Sessions"})]}),e.jsxs("div",{className:"p-2 rounded-md bg-muted/50 border text-center",children:[e.jsxs("div",{className:"flex items-center justify-center gap-1.5 text-green-600 dark:text-green-400",children:[e.jsx(le,{className:"w-4 h-4"}),e.jsxs("span",{className:i("text-xl font-bold",d&&y),children:["$",o.avgCost.toFixed(2)]})]}),e.jsx("p",{className:"text-[10px] text-muted-foreground uppercase tracking-wider mt-0.5",children:"Avg Cost/Session"})]})]}),e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground font-medium mb-1",children:[e.jsx(Fe,{className:"w-3 h-3"}),"Recent Activity"]}),e.jsx("div",{className:"space-y-1.5",children:o.recentSessions.map(c=>e.jsxs("div",{className:"flex items-center justify-between text-xs p-1.5 rounded bg-muted/30 hover:bg-muted/50 transition-colors",children:[e.jsxs("div",{className:"flex flex-col min-w-0 flex-1",children:[e.jsx("span",{className:"font-medium truncate",title:c.projectPath,children:c.projectPath.split("/").pop()}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:H(new Date(c.lastActivity),{addSuffix:!0})})]}),e.jsxs("div",{className:i("text-right shrink-0 ml-2",d&&y),children:[e.jsxs("div",{className:"font-mono",children:["$",c.cost.toFixed(2)]}),e.jsxs("div",{className:"text-[10px] text-muted-foreground",children:[ss(c.inputTokens+c.outputTokens)," toks"]})]})]},c.sessionId))})]})]})]}):e.jsxs(g,{className:i("flex flex-col h-full",a),children:[e.jsx(N,{className:"px-3 py-2",children:e.jsxs(C,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(Q,{className:"w-4 h-4"}),"Session Stats"]})}),e.jsx(j,{className:"px-3 pb-3 pt-0 flex-1 flex items-center justify-center",children:e.jsx("p",{className:"text-sm text-muted-foreground text-center",children:"No session data available"})})]})}function ss(s){return s>=1e9?`${(s/1e9).toFixed(1)}B`:s>=1e6?`${(s/1e6).toFixed(1)}M`:s>=1e3?`${(s/1e3).toFixed(1)}K`:s.toString()}function ts({className:s,isLoading:t}){const{data:a,isLoading:d}=ye(),{data:o,isLoading:c,error:n}=be(a?.running);if(t||d||a?.running&&c)return e.jsxs(g,{className:i("flex flex-col h-full",s),children:[e.jsx(N,{className:"px-3 py-2",children:e.jsxs(C,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(q,{className:"h-4 w-4"}),"CLIProxy Stats"]})}),e.jsx(j,{className:"px-3 pb-3 pt-0 flex-1",children:e.jsxs("div",{className:"space-y-3",children:[e.jsx(m,{className:"h-4 w-[100px]"}),e.jsx(m,{className:"h-16 w-full"})]})})]});if(!a?.running)return e.jsxs(g,{className:i("flex flex-col h-full border-dashed",s),children:[e.jsx(N,{className:"px-3 py-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(C,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(q,{className:"h-4 w-4 text-muted-foreground"}),"CLIProxy Stats"]}),e.jsx(B,{variant:"secondary",className:"text-[10px] h-5",children:"Offline"})]})}),e.jsx(j,{className:"px-3 pb-3 pt-0 flex-1 flex items-center justify-center",children:e.jsx("p",{className:"text-xs text-muted-foreground text-center",children:"Start a CLIProxy session (gemini, codex, agy) to collect stats."})})]});if(n)return e.jsxs(g,{className:i("flex flex-col h-full border-destructive/50",s),children:[e.jsx(N,{className:"px-3 py-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(C,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(q,{className:"h-4 w-4"}),"CLIProxy Stats"]}),e.jsx(B,{variant:"destructive",className:"text-[10px] h-5",children:"Error"})]})}),e.jsx(j,{className:"px-3 pb-3 pt-0 flex-1",children:e.jsx("p",{className:"text-xs text-destructive",children:n.message})})]});const x=o?.totalRequests??0,u=o?.quotaExceededCount??0,f=x-u,h=x>0?Math.round(f/x*100):100,S=o?.tokens?.total??0,v=Object.entries(o?.requestsByModel??{}).sort((D,L)=>L[1]-D[1]).slice(0,4),b=v.length>0?v[0][1]:1;return e.jsxs(g,{className:i("flex flex-col h-full overflow-hidden",s),children:[e.jsx(N,{className:"px-3 py-2 border-b bg-muted/5",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(C,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(q,{className:"h-4 w-4"}),"CLIProxy Stats"]}),e.jsxs(B,{variant:"outline",className:"text-[10px] h-5 text-green-600 border-green-200 bg-green-50 dark:bg-green-900/10 dark:border-green-800",children:[e.jsx(le,{className:"h-3 w-3 mr-0.5"}),"Running"]})]})}),e.jsx(j,{className:"p-0 flex-1 min-h-0",children:e.jsx(we,{className:"h-full",children:e.jsxs("div",{className:"p-3 space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2 p-2 rounded-lg bg-muted/30",children:[e.jsxs("div",{className:"relative",children:[e.jsxs("svg",{className:"w-10 h-10 -rotate-90",viewBox:"0 0 36 36",children:[e.jsx("circle",{cx:"18",cy:"18",r:"14",fill:"none",stroke:"currentColor",strokeWidth:"3",className:"text-muted/30"}),e.jsx("circle",{cx:"18",cy:"18",r:"14",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeDasharray:`${h*.88} 88`,strokeLinecap:"round",className:h>=90?"text-green-500":"text-amber-500"})]}),e.jsxs("span",{className:"absolute inset-0 flex items-center justify-center text-[8px] font-bold",children:[h,"%"]})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-lg font-bold leading-none",children:J(x)}),e.jsx("div",{className:"text-[9px] text-muted-foreground mt-0.5",children:u>0?`${u} failed`:"All success"})]})]}),e.jsxs("div",{className:"flex items-center gap-2 p-2 rounded-lg bg-muted/30",children:[e.jsx("div",{className:"p-1.5 rounded-md bg-purple-100 dark:bg-purple-900/20",children:e.jsx(Te,{className:"h-4 w-4 text-purple-600"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-lg font-bold leading-none",children:J(S)}),e.jsx("div",{className:"text-[9px] text-muted-foreground mt-0.5",children:"Total tokens"})]})]})]}),v.length>0&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] font-medium text-muted-foreground",children:[e.jsx(Me,{className:"h-3 w-3"}),"Models Used"]}),e.jsx("div",{className:"space-y-1",children:v.map(([D,L])=>{const K=Math.round(L/b*100),E=as(D);return e.jsxs("div",{className:"group",children:[e.jsxs("div",{className:"flex items-center justify-between text-[10px] mb-0.5",children:[e.jsx("span",{className:"truncate font-medium",title:D,children:E}),e.jsx("span",{className:"text-muted-foreground shrink-0 ml-2",children:L})]}),e.jsx("div",{className:"h-1 bg-muted/50 rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full bg-accent/70 rounded-full transition-all",style:{width:`${K}%`}})})]},D)})})]})]})})})]})}function J(s){return s>=1e6?`${(s/1e6).toFixed(1)}M`:s>=1e3?`${(s/1e3).toFixed(1)}K`:s.toLocaleString()}function as(s){let t=s.replace(/^gemini-claude-/,"").replace(/^gemini-/,"").replace(/^claude-/,"").replace(/^anthropic\./,"").replace(/-thinking$/," Thinking");return t=t.split(/[-_]/).map(a=>a.charAt(0).toUpperCase()+a.slice(1)).join(" "),t.length>20&&(t=t.slice(0,18)+"..."),t}const rs="/api";function w(s){const t=s.getFullYear(),a=String(s.getMonth()+1).padStart(2,"0"),d=String(s.getDate()).padStart(2,"0");return`${t}${a}${d}`}const T={summary:s=>{const t=new URLSearchParams;return s?.startDate&&t.append("since",w(s.startDate)),s?.endDate&&t.append("until",w(s.endDate)),s?.profile&&t.append("profile",s.profile),$(`/usage/summary?${t}`)},trends:s=>{const t=new URLSearchParams;return s?.startDate&&t.append("since",w(s.startDate)),s?.endDate&&t.append("until",w(s.endDate)),s?.profile&&t.append("profile",s.profile),$(`/usage/daily?${t}`)},hourly:s=>{const t=new URLSearchParams;return s?.startDate&&t.append("since",w(s.startDate)),s?.endDate&&t.append("until",w(s.endDate)),$(`/usage/hourly?${t}`)},models:s=>{const t=new URLSearchParams;return s?.startDate&&t.append("since",w(s.startDate)),s?.endDate&&t.append("until",w(s.endDate)),s?.profile&&t.append("profile",s.profile),$(`/usage/models?${t}`)},sessions:s=>{const t=new URLSearchParams;return s?.startDate&&t.append("since",w(s.startDate)),s?.endDate&&t.append("until",w(s.endDate)),s?.profile&&t.append("profile",s.profile),s?.limit&&t.append("limit",s.limit.toString()),s?.offset&&t.append("offset",s.offset.toString()),$(`/usage/sessions?${t}`)},monthly:(s,t)=>{const a=new URLSearchParams;return s&&a.append("months",s.toString()),t&&a.append("profile",t),$(`/usage/monthly?${a}`)},refresh:async()=>{if(!(await fetch(`${rs}/usage/refresh`,{method:"POST",headers:{"Content-Type":"application/json"}})).ok)throw new Error("Failed to refresh usage cache")},status:()=>$("/usage/status"),insights:s=>{const t=new URLSearchParams;return s?.startDate&&t.append("since",w(s.startDate)),s?.endDate&&t.append("until",w(s.endDate)),s?.profile&&t.append("profile",s.profile),$(`/usage/insights?${t}`)}};async function $(s){const a=await fetch(`/api${s}`,{headers:{"Content-Type":"application/json"}});if(!a.ok){const o=await a.json().catch(()=>({error:"Unknown error"}));throw new Error(o.error||a.statusText)}const d=await a.json();return d.data||d}function ns(s){return P({queryKey:["usage","summary",s],queryFn:()=>T.summary(s),staleTime:60*1e3})}function ls(s){return P({queryKey:["usage","trends",s],queryFn:()=>T.trends(s),staleTime:60*1e3})}function is(s){return P({queryKey:["usage","hourly",s],queryFn:()=>T.hourly(s),staleTime:60*1e3})}function os(s){return P({queryKey:["usage","models",s],queryFn:()=>T.models(s),staleTime:60*1e3})}function cs(){const s=Ge();return p.useCallback(async()=>{await T.refresh(),await s.invalidateQueries({queryKey:["usage"]})},[s])}function ds(){return P({queryKey:["usage","status"],queryFn:()=>T.status(),staleTime:10*1e3,refetchInterval:30*1e3})}function xs(s){return P({queryKey:["usage","sessions",s],queryFn:()=>T.sessions(s),staleTime:60*1e3})}function us(s){return s>=1e9?`${(s/1e9).toFixed(1)}B`:s>=1e6?`${(s/1e6).toFixed(1)}M`:s>=1e3?`${(s/1e3).toFixed(0)}K`:s.toString()}function ks(){const{privacyMode:s}=R(),[t,a]=p.useState({from:F(new Date,30),to:new Date}),[d,o]=p.useState(!1),[c,n]=p.useState(null),[r,x]=p.useState(null),[u,f]=p.useState("daily"),h=p.useRef(null),S=cs(),v=async()=>{o(!0);try{await S()}finally{o(!1)}},b={startDate:t?.from,endDate:t?.to},{data:D,isLoading:L}=ns(b),{data:K,isLoading:E}=ls(b),{data:ce,isLoading:de}=is(b),{data:_,isLoading:z}=os(b),{data:xe,isLoading:ue}=xs({...b,limit:3}),{data:G}=ds(),me=p.useCallback(()=>{const l=new Date;a({from:F(l,1),to:l}),f("hourly")},[]),fe=p.useCallback(l=>{a(l),f("daily")},[]),Y=p.useMemo(()=>G?.lastFetch?H(new Date(G.lastFetch),{addSuffix:!0}):null,[G?.lastFetch]),he=p.useCallback((l,A)=>{const U=A.currentTarget.getBoundingClientRect();x({x:U.left+U.width/2,y:U.top+U.height/2}),n(l)},[]),pe=p.useCallback(()=>{n(null),x(null)},[]);return e.jsxs("div",{className:"flex flex-col h-full overflow-hidden px-4 pt-4 pb-50 gap-4",children:[e.jsxs("div",{className:"flex items-center justify-between shrink-0",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl font-semibold",children:"Analytics"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Track usage & insights"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(I,{variant:u==="hourly"?"default":"outline",size:"sm",className:"h-8",onClick:me,children:"24H"}),e.jsx(He,{value:t,onChange:fe,presets:[{label:"7D",range:{from:F(new Date,7),to:new Date}},{label:"30D",range:{from:F(new Date,30),to:new Date}},{label:"Month",range:{from:ke(new Date),to:new Date}},{label:"All Time",range:{from:void 0,to:new Date}}]}),Y&&e.jsxs("span",{className:"text-xs text-muted-foreground whitespace-nowrap",children:["Updated ",Y]}),e.jsx(I,{variant:"outline",size:"sm",className:"gap-2 h-8",onClick:v,disabled:d,children:e.jsx(Re,{className:`w-3.5 h-3.5 ${d?"animate-spin":""}`})})]})]}),e.jsx(We,{data:D,isLoading:L}),e.jsxs("div",{className:"flex-1 flex flex-col min-h-0 gap-4",children:[e.jsxs(g,{className:"flex flex-col flex-1 min-h-0 max-h-[500px] overflow-hidden shadow-sm",children:[e.jsx(N,{className:"px-3 py-2 shrink-0",children:e.jsxs(C,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(Pe,{className:"w-4 h-4"}),u==="hourly"?"Last 24 Hours":"Usage Trends"]})}),e.jsx(j,{className:"px-3 pb-3 pt-0 flex-1 min-h-0",children:e.jsx(_e,{data:u==="hourly"?ce||[]:K||[],isLoading:u==="hourly"?de:E,granularity:u==="hourly"?"hourly":"daily"})})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-10 gap-4 h-auto lg:h-[180px] shrink-0",children:[e.jsxs(g,{className:"flex flex-col h-full min-h-0 shadow-sm lg:col-span-4",children:[e.jsx(N,{className:"px-3 py-2",children:e.jsxs(C,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(ae,{className:"w-4 h-4"}),"Cost by Model"]})}),e.jsx(j,{className:"px-2 pb-2 pt-0 flex-1 min-h-0 overflow-y-auto",children:z?e.jsx(m,{className:"h-full w-full"}):e.jsxs("div",{className:"space-y-0.5",children:[[..._||[]].sort((l,A)=>A.cost-l.cost).map(l=>e.jsxs("button",{className:"group flex items-center text-xs w-full hover:bg-muted/50 rounded px-2 py-1.5 transition-colors cursor-pointer gap-3",onClick:A=>he(l,A),title:"Click for details",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0 w-[180px] shrink-0",children:[e.jsx("div",{className:"w-2 h-2 rounded-full shrink-0",style:{backgroundColor:te(l.model)}}),e.jsx("span",{className:"font-medium truncate group-hover:underline underline-offset-2",children:l.model})]}),e.jsx("div",{className:"flex-1 flex items-center gap-1 min-w-0",children:e.jsxs("div",{className:"flex-1 h-2 bg-muted rounded-full overflow-hidden flex",children:[e.jsx("div",{className:"h-full",style:{backgroundColor:"#335c67",width:`${l.cost>0?l.costBreakdown.input.cost/l.cost*100:0}%`},title:`Input: $${l.costBreakdown.input.cost.toFixed(2)}`}),e.jsx("div",{className:"h-full",style:{backgroundColor:"#fff3b0",width:`${l.cost>0?l.costBreakdown.output.cost/l.cost*100:0}%`},title:`Output: $${l.costBreakdown.output.cost.toFixed(2)}`}),e.jsx("div",{className:"h-full",style:{backgroundColor:"#e09f3e",width:`${l.cost>0?l.costBreakdown.cacheCreation.cost/l.cost*100:0}%`},title:`Cache Write: $${l.costBreakdown.cacheCreation.cost.toFixed(2)}`}),e.jsx("div",{className:"h-full",style:{backgroundColor:"#9e2a2b",width:`${l.cost>0?l.costBreakdown.cacheRead.cost/l.cost*100:0}%`},title:`Cache Read: $${l.costBreakdown.cacheRead.cost.toFixed(2)}`})]})}),e.jsx("span",{className:i("text-[10px] text-muted-foreground w-14 text-right shrink-0",s&&y),children:us(l.tokens)}),e.jsxs("span",{className:i("font-mono font-medium w-16 text-right shrink-0",s&&y),children:["$",l.cost.toFixed(2)]}),e.jsx(Ae,{className:"w-3 h-3 opacity-0 group-hover:opacity-50 transition-opacity shrink-0"})]},l.model)),e.jsxs("div",{className:"flex items-center gap-3 pt-2 px-2 text-[10px] text-muted-foreground border-t mt-2",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx("div",{className:"w-2 h-2 rounded-full",style:{backgroundColor:"#335c67"}}),"Input"]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx("div",{className:"w-2 h-2 rounded-full border border-muted-foreground/30",style:{backgroundColor:"#fff3b0"}}),"Output"]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx("div",{className:"w-2 h-2 rounded-full",style:{backgroundColor:"#e09f3e"}}),"Cache Write"]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx("div",{className:"w-2 h-2 rounded-full",style:{backgroundColor:"#9e2a2b"}}),"Cache Read"]})]})]})})]}),e.jsxs(g,{className:"flex flex-col h-full min-h-0 shadow-sm lg:col-span-2",children:[e.jsx(N,{className:"px-3 py-2",children:e.jsxs(C,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(Be,{className:"w-4 h-4"}),"Model Usage"]})}),e.jsx(j,{className:"px-2 pb-2 pt-0 flex-1 min-h-0 flex items-center justify-center",children:e.jsx(Ye,{data:_||[],isLoading:z,className:"h-full w-full"})})]}),e.jsx(es,{data:xe,isLoading:ue,className:"lg:col-span-2"}),e.jsx(ts,{isLoading:L,className:"lg:col-span-2"})]}),e.jsxs(ee,{open:!!c,onOpenChange:l=>!l&&pe(),children:[e.jsx(ve,{asChild:!0,children:e.jsx("div",{ref:h,className:"fixed pointer-events-none",style:{left:r?.x??0,top:r?.y??0,width:1,height:1}})}),e.jsx(se,{className:"w-80 p-3",side:"top",align:"center",children:c&&e.jsx(Ve,{model:c})})]})]})]})}function Cs(){return e.jsxs("div",{className:"space-y-4 h-full overflow-hidden",children:[e.jsxs(g,{className:"flex flex-col min-h-[300px]",children:[e.jsx(N,{className:"p-4 pb-2",children:e.jsx(m,{className:"h-4 w-32"})}),e.jsx(j,{className:"p-4 pt-0 flex-1",children:e.jsx(m,{className:"h-full w-full"})})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:[e.jsxs(g,{className:"flex flex-col min-h-[250px]",children:[e.jsx(N,{className:"p-4 pb-2",children:e.jsx(m,{className:"h-4 w-28"})}),e.jsx(j,{className:"p-4 pt-2",children:e.jsx("div",{className:"space-y-3",children:[1,2,3,4,5].map(s=>e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(m,{className:"w-2.5 h-2.5 rounded-full"}),e.jsx(m,{className:"h-3 w-24"})]}),e.jsx(m,{className:"h-3 w-16"})]},s))})})]}),e.jsxs(g,{className:"flex flex-col min-h-[250px]",children:[e.jsx(N,{className:"p-4 pb-2",children:e.jsx(m,{className:"h-4 w-28"})}),e.jsx(j,{className:"p-4 pt-0 flex-1",children:e.jsxs("div",{className:"flex w-full h-full items-center",children:[e.jsx("div",{className:"flex-1 flex justify-center",children:e.jsx(m,{className:"h-[180px] w-[180px] rounded-full"})}),e.jsx("div",{className:"w-[140px] shrink-0 pl-2 space-y-2",children:[1,2,3,4].map(s=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(m,{className:"w-2 h-2 rounded-full"}),e.jsx(m,{className:"h-3 w-20"})]},s))})]})})]})]})]})}export{ks as AnalyticsPage,Cs as AnalyticsSkeleton};
@@ -1 +1 @@
1
- import{j as e}from"./radix-ui-VbLlN_Dz.js";import{r}from"./react-vendor-DMek_JCF.js";import{k as S,l as A,B as i,I,i as D,m as L,n as M,o as E,c as R,p as z,q as B,e as j}from"./index-BXPLu3zJ.js";import{a0 as O,t as g,a5 as F,a6 as y,p as T,a7 as U,l as C,q,a8 as Q,a9 as H}from"./icons-WTNLz24z.js";import"./tanstack-yybD444-.js";import"./notifications-cqk-Qeo2.js";import"./utils-CzKF5WmX.js";import"./form-utils-BXvNPyud.js";import"./code-highlight-C2TXE0-z.js";function se(){const{data:a,isLoading:d,isError:x,refetch:u}=S(),h=A(),[l,p]=r.useState(null),[o,w]=r.useState(""),[b,n]=r.useState(!1),[c,m]=r.useState(null),t=r.useMemo(()=>a?.profiles||[],[a?.profiles]),N=r.useMemo(()=>t.filter(s=>s.name.toLowerCase().includes(o.toLowerCase())),[t,o]),v=r.useMemo(()=>l&&t.some(s=>s.name===l)?l:t.length>0?t[0].name:null,[l,t]),P=s=>{h.mutate(s,{onSuccess:()=>{l===s&&p(null),m(null)}})},k=s=>{n(!1),p(s)},f=t.find(s=>s.name===v);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-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(O,{className:"w-5 h-5 text-primary"}),e.jsx("h1",{className:"font-semibold",children:"API Profiles"})]}),e.jsxs(i,{size:"sm",onClick:()=>{n(!0)},children:[e.jsx(g,{className:"w-4 h-4 mr-1"}),"New"]})]}),e.jsxs("div",{className:"relative",children:[e.jsx(F,{className:"absolute left-2.5 top-2.5 h-4 w-4 text-muted-foreground"}),e.jsx(I,{placeholder:"Search profiles...",className:"pl-8 h-9",value:o,onChange:s=>w(s.target.value)})]})]}),e.jsx(D,{className:"flex-1",children:d?e.jsx("div",{className:"p-4 text-sm text-muted-foreground",children:"Loading profiles..."}):x?e.jsx("div",{className:"p-4 text-center",children:e.jsxs("div",{className:"space-y-3 py-8",children:[e.jsx(y,{className:"w-12 h-12 mx-auto text-destructive/50"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:"Failed to load profiles"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Unable to fetch API profiles. Please try again."})]}),e.jsxs(i,{size:"sm",variant:"outline",onClick:()=>u(),children:[e.jsx(T,{className:"w-4 h-4 mr-1"}),"Retry"]})]})}):N.length===0?e.jsx("div",{className:"p-4 text-center",children:t.length===0?e.jsxs("div",{className:"space-y-3 py-8",children:[e.jsx(U,{className:"w-12 h-12 mx-auto text-muted-foreground/50"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:"No API profiles yet"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Create your first profile to connect to custom API endpoints"})]}),e.jsxs(i,{size:"sm",variant:"outline",onClick:()=>{n(!0)},children:[e.jsx(g,{className:"w-4 h-4 mr-1"}),"Create Profile"]})]}):e.jsxs("p",{className:"text-sm text-muted-foreground py-4",children:['No profiles match "',o,'"']})}):e.jsx("div",{className:"p-2 space-y-1",children:N.map(s=>e.jsx(W,{profile:s,isSelected:v===s.name,onSelect:()=>{p(s.name)},onDelete:()=>m(s.name)},s.name))})}),t.length>0&&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:[t.length," profile",t.length!==1?"s":""]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(C,{className:"w-3 h-3 text-green-600"}),t.filter(s=>s.configured).length," configured"]})]})})]}),e.jsx("div",{className:"flex-1 flex flex-col min-w-0",children:f?e.jsx(L,{profileName:f.name,onDelete:()=>m(f.name)}):e.jsx(Y,{onCreateClick:()=>{n(!0)}})}),e.jsx(M,{open:b,onOpenChange:n,onSuccess:k}),e.jsx(E,{open:!!c,title:"Delete Profile",description:`Are you sure you want to delete "${c}"? This will remove the settings file and cannot be undone.`,confirmText:"Delete",variant:"destructive",onConfirm:()=>c&&P(c),onCancel:()=>m(null)})]})}function W({profile:a,isSelected:d,onSelect:x,onDelete:u}){return e.jsxs("div",{className:R("group flex items-center gap-2 px-3 py-2.5 rounded-md cursor-pointer transition-colors",d?"bg-primary/10 border border-primary/20":"hover:bg-muted border border-transparent"),onClick:x,children:[a.configured?e.jsx(C,{className:"w-4 h-4 text-green-600 shrink-0"}):e.jsx(y,{className:"w-4 h-4 text-yellow-600 shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"font-medium text-sm truncate",children:a.name}),e.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[e.jsx("div",{className:"text-xs text-muted-foreground truncate flex-1",children:a.settingsPath}),e.jsx(z,{value:a.settingsPath,size:"icon",className:"h-5 w-5 opacity-0 group-hover:opacity-100 transition-opacity"})]})]}),e.jsx(i,{variant:"ghost",size:"icon",className:"h-7 w-7 opacity-0 group-hover:opacity-100 transition-opacity",onClick:h=>{h.stopPropagation(),u()},children:e.jsx(q,{className:"w-3.5 h-3.5 text-destructive"})})]})}function Y({onCreateClick:a}){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(Q,{className:"w-16 h-16 mx-auto text-muted-foreground/30 mb-6"}),e.jsx("h2",{className:"text-xl font-semibold mb-2",children:"API Profile Manager"}),e.jsx("p",{className:"text-muted-foreground mb-6",children:"Configure custom API endpoints for Claude CLI. Connect to proxy services like copilot-api, OpenRouter, or your own API backend."}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs(i,{onClick:a,className:"w-full",children:[e.jsx(g,{className:"w-4 h-4 mr-2"}),"Create Your First Profile"]}),e.jsx(B,{className:"my-4"}),e.jsxs("div",{className:"text-left space-y-2",children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"What you can configure:"}),e.jsxs("ul",{className:"text-sm text-muted-foreground space-y-1.5",children:[e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsx(j,{variant:"outline",className:"text-xs shrink-0 mt-0.5",children:"URL"}),e.jsx("span",{children:"Custom API base URL endpoint"})]}),e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsx(j,{variant:"outline",className:"text-xs shrink-0 mt-0.5",children:"Auth"}),e.jsx("span",{children:"API key or authentication token"})]}),e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsx(j,{variant:"outline",className:"text-xs shrink-0 mt-0.5",children:"Models"}),e.jsx("span",{children:"Model mapping for Opus/Sonnet/Haiku"})]})]})]}),e.jsx("div",{className:"pt-4",children:e.jsxs("a",{href:"https://github.com/kaitranntt/ccs#api-profiles",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center text-xs text-primary hover:underline",children:["Learn more about API profiles",e.jsx(H,{className:"w-3 h-3 ml-1"})]})})]})]})})}export{se as ApiPage};
1
+ import{j as e}from"./radix-ui-VbLlN_Dz.js";import{r}from"./react-vendor-DMek_JCF.js";import{k as S,l as A,B as i,I,i as D,m as L,n as M,o as E,c as R,p as z,q as B,e as j}from"./index-EyLCmFok.js";import{a0 as O,t as g,a5 as F,a6 as y,p as T,a7 as U,l as C,q,a8 as Q,a9 as H}from"./icons-B9AtZK5c.js";import"./tanstack-yybD444-.js";import"./notifications-cqk-Qeo2.js";import"./utils-CzKF5WmX.js";import"./form-utils-BXvNPyud.js";import"./code-highlight-C2TXE0-z.js";function se(){const{data:a,isLoading:d,isError:x,refetch:u}=S(),h=A(),[l,p]=r.useState(null),[o,w]=r.useState(""),[b,n]=r.useState(!1),[c,m]=r.useState(null),t=r.useMemo(()=>a?.profiles||[],[a?.profiles]),N=r.useMemo(()=>t.filter(s=>s.name.toLowerCase().includes(o.toLowerCase())),[t,o]),v=r.useMemo(()=>l&&t.some(s=>s.name===l)?l:t.length>0?t[0].name:null,[l,t]),P=s=>{h.mutate(s,{onSuccess:()=>{l===s&&p(null),m(null)}})},k=s=>{n(!1),p(s)},f=t.find(s=>s.name===v);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-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(O,{className:"w-5 h-5 text-primary"}),e.jsx("h1",{className:"font-semibold",children:"API Profiles"})]}),e.jsxs(i,{size:"sm",onClick:()=>{n(!0)},children:[e.jsx(g,{className:"w-4 h-4 mr-1"}),"New"]})]}),e.jsxs("div",{className:"relative",children:[e.jsx(F,{className:"absolute left-2.5 top-2.5 h-4 w-4 text-muted-foreground"}),e.jsx(I,{placeholder:"Search profiles...",className:"pl-8 h-9",value:o,onChange:s=>w(s.target.value)})]})]}),e.jsx(D,{className:"flex-1",children:d?e.jsx("div",{className:"p-4 text-sm text-muted-foreground",children:"Loading profiles..."}):x?e.jsx("div",{className:"p-4 text-center",children:e.jsxs("div",{className:"space-y-3 py-8",children:[e.jsx(y,{className:"w-12 h-12 mx-auto text-destructive/50"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:"Failed to load profiles"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Unable to fetch API profiles. Please try again."})]}),e.jsxs(i,{size:"sm",variant:"outline",onClick:()=>u(),children:[e.jsx(T,{className:"w-4 h-4 mr-1"}),"Retry"]})]})}):N.length===0?e.jsx("div",{className:"p-4 text-center",children:t.length===0?e.jsxs("div",{className:"space-y-3 py-8",children:[e.jsx(U,{className:"w-12 h-12 mx-auto text-muted-foreground/50"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:"No API profiles yet"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Create your first profile to connect to custom API endpoints"})]}),e.jsxs(i,{size:"sm",variant:"outline",onClick:()=>{n(!0)},children:[e.jsx(g,{className:"w-4 h-4 mr-1"}),"Create Profile"]})]}):e.jsxs("p",{className:"text-sm text-muted-foreground py-4",children:['No profiles match "',o,'"']})}):e.jsx("div",{className:"p-2 space-y-1",children:N.map(s=>e.jsx(W,{profile:s,isSelected:v===s.name,onSelect:()=>{p(s.name)},onDelete:()=>m(s.name)},s.name))})}),t.length>0&&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:[t.length," profile",t.length!==1?"s":""]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(C,{className:"w-3 h-3 text-green-600"}),t.filter(s=>s.configured).length," configured"]})]})})]}),e.jsx("div",{className:"flex-1 flex flex-col min-w-0",children:f?e.jsx(L,{profileName:f.name,onDelete:()=>m(f.name)}):e.jsx(Y,{onCreateClick:()=>{n(!0)}})}),e.jsx(M,{open:b,onOpenChange:n,onSuccess:k}),e.jsx(E,{open:!!c,title:"Delete Profile",description:`Are you sure you want to delete "${c}"? This will remove the settings file and cannot be undone.`,confirmText:"Delete",variant:"destructive",onConfirm:()=>c&&P(c),onCancel:()=>m(null)})]})}function W({profile:a,isSelected:d,onSelect:x,onDelete:u}){return e.jsxs("div",{className:R("group flex items-center gap-2 px-3 py-2.5 rounded-md cursor-pointer transition-colors",d?"bg-primary/10 border border-primary/20":"hover:bg-muted border border-transparent"),onClick:x,children:[a.configured?e.jsx(C,{className:"w-4 h-4 text-green-600 shrink-0"}):e.jsx(y,{className:"w-4 h-4 text-yellow-600 shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"font-medium text-sm truncate",children:a.name}),e.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[e.jsx("div",{className:"text-xs text-muted-foreground truncate flex-1",children:a.settingsPath}),e.jsx(z,{value:a.settingsPath,size:"icon",className:"h-5 w-5 opacity-0 group-hover:opacity-100 transition-opacity"})]})]}),e.jsx(i,{variant:"ghost",size:"icon",className:"h-7 w-7 opacity-0 group-hover:opacity-100 transition-opacity",onClick:h=>{h.stopPropagation(),u()},children:e.jsx(q,{className:"w-3.5 h-3.5 text-destructive"})})]})}function Y({onCreateClick:a}){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(Q,{className:"w-16 h-16 mx-auto text-muted-foreground/30 mb-6"}),e.jsx("h2",{className:"text-xl font-semibold mb-2",children:"API Profile Manager"}),e.jsx("p",{className:"text-muted-foreground mb-6",children:"Configure custom API endpoints for Claude CLI. Connect to proxy services like copilot-api, OpenRouter, or your own API backend."}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs(i,{onClick:a,className:"w-full",children:[e.jsx(g,{className:"w-4 h-4 mr-2"}),"Create Your First Profile"]}),e.jsx(B,{className:"my-4"}),e.jsxs("div",{className:"text-left space-y-2",children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"What you can configure:"}),e.jsxs("ul",{className:"text-sm text-muted-foreground space-y-1.5",children:[e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsx(j,{variant:"outline",className:"text-xs shrink-0 mt-0.5",children:"URL"}),e.jsx("span",{children:"Custom API base URL endpoint"})]}),e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsx(j,{variant:"outline",className:"text-xs shrink-0 mt-0.5",children:"Auth"}),e.jsx("span",{children:"API key or authentication token"})]}),e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsx(j,{variant:"outline",className:"text-xs shrink-0 mt-0.5",children:"Models"}),e.jsx("span",{children:"Model mapping for Opus/Sonnet/Haiku"})]})]})]}),e.jsx("div",{className:"pt-4",children:e.jsxs("a",{href:"https://github.com/kaitranntt/ccs#api-profiles",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center text-xs text-primary hover:underline",children:["Learn more about API profiles",e.jsx(H,{className:"w-3 h-3 ml-1"})]})})]})]})})}export{se as ApiPage};
@@ -1 +1 @@
1
- import{j as t}from"./radix-ui-VbLlN_Dz.js";import"./react-vendor-DMek_JCF.js";import{c as o}from"./index-BXPLu3zJ.js";function n({className:a,...r}){return t.jsx("div",{"data-slot":"card",className:o("bg-card text-card-foreground flex flex-col gap-6 rounded-xl border py-6 shadow-sm",a),...r})}function c({className:a,...r}){return t.jsx("div",{"data-slot":"card-header",className:o("@container/card-header grid auto-rows-min grid-rows-[auto_auto] items-start gap-2 px-6 has-data-[slot=card-action]:grid-cols-[1fr_auto] [.border-b]:pb-6",a),...r})}function i({className:a,...r}){return t.jsx("div",{"data-slot":"card-title",className:o("leading-none font-semibold",a),...r})}function l({className:a,...r}){return t.jsx("div",{"data-slot":"card-content",className:o("px-6",a),...r})}export{n as C,l as a,c as b,i as c};
1
+ import{j as t}from"./radix-ui-VbLlN_Dz.js";import"./react-vendor-DMek_JCF.js";import{c as o}from"./index-EyLCmFok.js";function n({className:a,...r}){return t.jsx("div",{"data-slot":"card",className:o("bg-card text-card-foreground flex flex-col gap-6 rounded-xl border py-6 shadow-sm",a),...r})}function c({className:a,...r}){return t.jsx("div",{"data-slot":"card-header",className:o("@container/card-header grid auto-rows-min grid-rows-[auto_auto] items-start gap-2 px-6 has-data-[slot=card-action]:grid-cols-[1fr_auto] [.border-b]:pb-6",a),...r})}function i({className:a,...r}){return t.jsx("div",{"data-slot":"card-title",className:o("leading-none font-semibold",a),...r})}function l({className:a,...r}){return t.jsx("div",{"data-slot":"card-content",className:o("px-6",a),...r})}export{n as C,l as a,c as b,i as c};
@@ -1 +1 @@
1
- import{j as e}from"./radix-ui-VbLlN_Dz.js";import{r as o}from"./react-vendor-DMek_JCF.js";import{u as fe}from"./tanstack-yybD444-.js";import{r as Y,s as je,t as Z,u as ve,D as J,v as X,w as ee,x as se,y as te,B as m,c as b,d as E,L as T,I as ae,z as Ne,A as we,E as ye,F as be,G as Ce,H as Se,J as Ae,K as ke,M as Pe,N as De,O as Me,i as Fe,S as Le,Q as $,R as ne,e as ie}from"./index-BXPLu3zJ.js";import{C as U,a as K}from"./card-CR0u1y_L.js";import{w as z,b as W,L as re,a9 as V,$ as Oe,j as P,o as Re,aa as R,p as M,y as G,A as Te,ab as _,U as Ve,z as Ge,Z as de,ac as ce,X as le,q as ze}from"./icons-WTNLz24z.js";import"./notifications-cqk-Qeo2.js";import"./utils-CzKF5WmX.js";import"./form-utils-BXvNPyud.js";import"./code-highlight-C2TXE0-z.js";const F={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"},{id:"gemini-claude-sonnet-4-5-thinking",name:"Claude Sonnet 4.5 Thinking",description:"Balanced with extended thinking"},{id:"gemini-claude-sonnet-4-5",name:"Claude Sonnet 4.5",description:"Fast and capable"},{id:"gemini-3-pro-preview",name:"Gemini 3 Pro",description:"Google latest model via Antigravity"}]},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"},{id:"gemini-2.5-pro",name:"Gemini 2.5 Pro",description:"Stable, works with free Google account"}]},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"}]}},H=[{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"}];function Ie({open:a,onClose:c}){const[n,i]=o.useState("provider"),[r,u]=o.useState(""),[d,j]=o.useState(null),[p,f]=o.useState(""),[v,A]=o.useState(""),[L,N]=o.useState(!1),[w,C]=o.useState(!1),[x,S]=o.useState(!1),{data:k,refetch:h}=Y(),l=je(),g=Z(),{privacyMode:D}=ve(),y=k?.authStatus.find(s=>s.provider===r)?.accounts||[];o.useEffect(()=>{if(!a){const s=setTimeout(()=>{i("provider"),u(""),j(null),f(""),A(""),N(!1),S(!1)},0);return()=>clearTimeout(s)}},[a]),o.useEffect(()=>{if(n==="auth"&&y.length>0&&!x){const s=setTimeout(()=>{i("account")},0);return()=>clearTimeout(s)}},[n,y,x]);const t=async s=>{await navigator.clipboard.writeText(s),N(!0),setTimeout(()=>N(!1),2e3)},O=async()=>{C(!0),await h(),C(!1)},oe=()=>{g.mutate({provider:r},{onSuccess:s=>{s.account&&(j(s.account),i("variant")),h()}})},me=s=>{u(s),(k?.authStatus.find(ge=>ge.provider===s)?.accounts||[]).length===0?i("auth"):i("account")},ue=s=>{j(s),i("variant")},xe=async()=>{if(!(!p||!r))try{await l.mutateAsync({name:p,provider:r,model:v||void 0,account:d?.id}),i("success")}catch(s){console.error("Failed to create variant:",s)}},Q=`ccs ${r} --auth --add`,q=["provider","auth","variant","success"],pe=(s=>s==="account"?1:q.indexOf(s))(n),he=s=>{if(!s&&(n==="success"||n==="provider")){c();return}};return e.jsx(J,{open:a,onOpenChange:he,children:e.jsxs(X,{className:"sm:max-w-lg",onPointerDownOutside:s=>{n!=="success"&&n!=="provider"&&s.preventDefault()},onEscapeKeyDown:s=>{(g.isPending||l.isPending)&&s.preventDefault()},children:[e.jsxs(ee,{children:[e.jsxs(se,{className:"flex items-center gap-2",children:[e.jsx(z,{className:"w-5 h-5 text-primary"}),"Quick Setup Wizard"]}),e.jsxs(te,{children:[n==="provider"&&"Select a provider to get started",n==="auth"&&"Authenticate with your provider",n==="account"&&"Select which account to use",n==="variant"&&"Create your custom variant",n==="success"&&"Setup complete!"]})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[n==="provider"&&e.jsx("div",{className:"grid gap-2",children:H.map(s=>e.jsxs("button",{onClick:()=>me(s.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:s.name}),e.jsx("div",{className:"text-xs text-muted-foreground",children:s.description})]}),e.jsx(W,{className:"w-4 h-4 text-muted-foreground"})]},s.id))}),n==="auth"&&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 ",H.find(s=>s.id===r)?.name," to add an account"]}),e.jsx(m,{onClick:oe,disabled:g.isPending,className:"w-full gap-2",size:"lg",children:g.isPending?e.jsxs(e.Fragment,{children:[e.jsx(re,{className:"w-4 h-4 animate-spin"}),"Authenticating..."]}):e.jsxs(e.Fragment,{children:[e.jsx(V,{className:"w-4 h-4"}),"Authenticate in Browser"]})}),g.isPending&&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(U,{children:e.jsxs(K,{className:"p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(Oe,{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:Q}),e.jsx(m,{variant:"outline",size:"icon",onClick:()=>t(Q),children:L?e.jsx(P,{className:"w-4 h-4 text-green-500"}):e.jsx(Re,{className:"w-4 h-4"})})]})]})}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(m,{variant:"ghost",onClick:()=>i("provider"),disabled:g.isPending,children:[e.jsx(R,{className:"w-4 h-4 mr-2"}),"Back"]}),e.jsxs(m,{variant:"outline",onClick:O,disabled:w||g.isPending,children:[e.jsx(M,{className:`w-4 h-4 mr-2 ${w?"animate-spin":""}`}),w?"Checking...":"Refresh Status"]})]})]}),n==="account"&&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 (",y.length,")"]}),e.jsx("div",{className:"grid gap-2",children:y.map(s=>e.jsxs("button",{type:"button",onClick:()=>ue(s),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(G,{className:"w-4 h-4 text-muted-foreground"})}),e.jsxs("div",{children:[e.jsx("div",{className:b("font-medium",D&&E),children:s.email||s.id}),s.isDefault&&e.jsx("div",{className:"text-xs text-muted-foreground",children:"Default account"})]})]}),e.jsx(W,{className:"w-4 h-4 text-muted-foreground"})]},s.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:()=>{S(!0),i("auth")},children:[e.jsx("div",{className:"w-8 h-8 rounded-full bg-primary/10 flex items-center justify-center shrink-0",children:e.jsx(V,{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(m,{variant:"ghost",onClick:()=>i("provider"),children:[e.jsx(R,{className:"w-4 h-4 mr-2"}),"Back"]})})]}),n==="variant"&&e.jsxs("div",{className:"space-y-4",children:[d&&e.jsxs("div",{className:"flex items-center gap-2 p-2 bg-muted/50 rounded-md text-sm",children:[e.jsx(G,{className:"w-4 h-4"}),e.jsxs("span",{children:["Using:"," ",e.jsx("span",{className:b(D&&E),children:d.email||d.id})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(T,{htmlFor:"variant-name",children:"Variant Name *"}),e.jsx(ae,{id:"variant-name",value:p,onChange:s=>f(s.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 ",p||"<name>",' "prompt"']})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(T,{children:"Model"}),e.jsxs(Ne,{value:v,onValueChange:A,children:[e.jsx(we,{children:e.jsx(ye,{placeholder:"Select a model"})}),e.jsx(be,{children:F[r]?.models.map(s=>e.jsx(Ce,{value:s.id,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{children:s.name}),s.description&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:["- ",s.description]})]})},s.id))})]}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:["Default: ",F[r]?.defaultModel||"provider default"]})]}),e.jsxs("div",{className:"flex items-center justify-between pt-2",children:[e.jsxs(m,{variant:"ghost",onClick:()=>y.length>0?i("account"):i("provider"),children:[e.jsx(R,{className:"w-4 h-4 mr-2"}),"Back"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(m,{variant:"ghost",onClick:c,children:"Skip"}),e.jsx(m,{onClick:xe,disabled:!p||l.isPending,children:l.isPending?"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"})]}),n==="success"&&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(P,{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(U,{children:e.jsxs(K,{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 ",p,' "your prompt here"']})]})}),e.jsx(m,{onClick:c,className:"w-full",children:"Done"})]})]}),e.jsx("div",{className:"flex justify-center gap-1 pt-2",children:q.map((s,B)=>e.jsx("div",{className:`w-2 h-2 rounded-full transition-colors ${pe>=B?"bg-primary":"bg-muted"}`},s))})]})})}function Qe({open:a,onClose:c,provider:n,displayName:i}){const[r,u]=o.useState(""),d=Z(),j=()=>{d.mutate({provider:n,nickname:r.trim()||void 0},{onSuccess:()=>{u(""),c()}})},p=f=>{!f&&!d.isPending&&(u(""),c())};return e.jsx(J,{open:a,onOpenChange:p,children:e.jsxs(X,{className:"sm:max-w-md",children:[e.jsxs(ee,{children:[e.jsxs(se,{children:["Add ",i," Account"]}),e.jsx(te,{children:"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(T,{htmlFor:"nickname",children:"Nickname (optional)"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(G,{className:"w-4 h-4 text-muted-foreground"}),e.jsx(ae,{id:"nickname",value:r,onChange:f=>u(f.target.value),placeholder:"e.g., work, personal",disabled:d.isPending,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(m,{variant:"ghost",onClick:c,disabled:d.isPending,children:"Cancel"}),e.jsx(m,{onClick:j,disabled:d.isPending,children:d.isPending?e.jsxs(e.Fragment,{children:[e.jsx(re,{className:"w-4 h-4 mr-2 animate-spin"}),"Authenticating..."]}):e.jsxs(e.Fragment,{children:[e.jsx(V,{className:"w-4 h-4 mr-2"}),"Authenticate"]})})]}),d.isPending&&e.jsx("p",{className:"text-sm text-center text-muted-foreground",children:"Complete the OAuth flow in your browser..."})]})]})})}function qe(a){if(!a)return"";const c=new Date(a).getTime(),i=Date.now()-c,r=Math.floor(i/(1e3*60*60)),u=Math.floor(i%(1e3*60*60)/(1e3*60));return r>0?`${r}h ${u}m`:`${u}m`}function Be(){const{data:a,isLoading:c}=Se(),n=Ae(),i=a?.running??!1;return e.jsxs("div",{className:b("rounded-lg border p-3 transition-colors",i?"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:b("w-2 h-2 rounded-full",i?"bg-green-500 animate-pulse":"bg-muted-foreground/30")}),e.jsx("span",{className:"text-sm font-medium",children:"CLIProxy Service"})]}),e.jsx("div",{className:"flex items-center gap-1",children:c?e.jsx(M,{className:"w-3 h-3 animate-spin text-muted-foreground"}):i?e.jsx(Te,{className:"w-3 h-3 text-green-600"}):e.jsx(_,{className:"w-3 h-3 text-muted-foreground"})})]}),i&&a?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 ",a.port]}),a.sessionCount!==void 0&&a.sessionCount>0&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Ve,{className:"w-3 h-3"}),a.sessionCount," session",a.sessionCount!==1?"s":""]}),a.startedAt&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Ge,{className:"w-3 h-3"}),qe(a.startedAt)]})]}):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(m,{variant:"outline",size:"sm",className:"h-7 text-xs gap-1",onClick:()=>n.mutate(),disabled:n.isPending,children:[n.isPending?e.jsx(M,{className:"w-3 h-3 animate-spin"}):e.jsx(_,{className:"w-3 h-3"}),"Start"]})]})]})}function Ee({status:a,isSelected:c,onSelect:n}){const i=a.accounts?.length||0;return e.jsxs("button",{className:b("w-full flex items-center gap-3 px-3 py-2.5 rounded-lg transition-colors cursor-pointer text-left",c?"bg-primary/10 border border-primary/20":"hover:bg-muted border border-transparent"),onClick:n,children:[e.jsx(ne,{provider:a.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:a.displayName}),i>0&&e.jsx(ie,{variant:"secondary",className:"text-[10px] h-4 px-1",children:i})]}),e.jsx("div",{className:"flex items-center gap-1.5 mt-0.5",children:a.authenticated?e.jsxs(e.Fragment,{children:[e.jsx(P,{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(le,{className:"w-3 h-3 text-muted-foreground"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"Not connected"})]})})]})]})}function $e({variant:a,parentAuth:c,isSelected:n,onSelect:i,onDelete:r,isDeleting:u}){return e.jsxs("button",{className:b("group w-full flex items-center gap-3 px-3 py-2 rounded-lg transition-colors cursor-pointer text-left pl-6",n?"bg-primary/10 border border-primary/20":"hover:bg-muted border border-transparent"),onClick:i,children:[e.jsxs("div",{className:"relative",children:[e.jsx(ne,{provider:a.provider,size:"sm"}),e.jsx(ce,{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:a.name}),e.jsx(ie,{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:c?.authenticated?e.jsxs(e.Fragment,{children:[e.jsx(P,{className:"w-3 h-3 text-green-600"}),e.jsxs("span",{className:"text-xs text-muted-foreground truncate",children:["via ",a.provider]})]}):e.jsxs(e.Fragment,{children:[e.jsx(le,{className:"w-3 h-3 text-muted-foreground"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"Parent not connected"})]})})]}),e.jsx(m,{variant:"ghost",size:"icon",className:"h-6 w-6 opacity-0 group-hover:opacity-100 hover:text-destructive",onClick:d=>{d.stopPropagation(),r()},disabled:u,children:e.jsx(ze,{className:"w-3 h-3"})})]})}function Ue({onSetup:a}){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(de,{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(m,{onClick:a,className:"gap-2",children:[e.jsx(z,{className:"w-4 h-4"}),"Quick Setup"]})]})})}function ns(){const a=fe(),{data:c,isLoading:n}=Y(),{data:i,isFetching:r}=ke(),u=Pe(),d=De(),j=Me(),[p,f]=o.useState(null),[v,A]=o.useState(null),[L,N]=o.useState(!1),[w,C]=o.useState(null),x=c?.authStatus||[],S=i?.variants||[],k=o.useMemo(()=>v?null:p&&x.some(t=>t.provider===p)?p:x.length>0?x[0].provider:null,[p,v,x]),h=x.find(t=>t.provider===k),l=S.find(t=>t.name===v),g=l?x.find(t=>t.provider===l.provider):void 0,D=()=>{a.invalidateQueries({queryKey:["cliproxy"]}),a.invalidateQueries({queryKey:["cliproxy-auth"]})},I=t=>{f(t),A(null)},y=t=>{A(t),f(null)};return e.jsxs("div",{className:"h-[calc(100vh-100px)] flex",children:[e.jsxs("div",{className:"w-64 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(de,{className:"w-5 h-5 text-primary"}),e.jsx("h1",{className:"font-semibold",children:"CLIProxy"})]}),e.jsx(m,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:D,disabled:r,children:e.jsx(M,{className:b("w-4 h-4",r&&"animate-spin")})})]}),e.jsx("p",{className:"text-xs text-muted-foreground mb-3",children:"CCS-level account management"}),e.jsxs(m,{variant:"default",size:"sm",className:"w-full gap-2",onClick:()=>N(!0),children:[e.jsx(z,{className:"w-4 h-4"}),"Quick Setup"]})]}),e.jsx(Fe,{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"}),n?e.jsx("div",{className:"space-y-2 px-2",children:[1,2,3,4].map(t=>e.jsx(Le,{className:"h-14 w-full rounded-lg"},t))}):e.jsx("div",{className:"space-y-1",children:x.map(t=>e.jsx(Ee,{status:t,isSelected:k===t.provider,onSelect:()=>I(t.provider)},t.provider))}),S.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(ce,{className:"w-3 h-3"}),"Variants"]}),e.jsx("div",{className:"space-y-1",children:S.map(t=>e.jsx($e,{variant:t,parentAuth:x.find(O=>O.provider===t.provider),isSelected:v===t.name,onSelect:()=>y(t.name),onDelete:()=>j.mutate(t.name),isDeleting:j.isPending},t.name))})]})]})}),e.jsx("div",{className:"p-3 border-t",children:e.jsx(Be,{})}),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:[x.length," provider",x.length!==1?"s":""]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(P,{className:"w-3 h-3 text-green-600"}),x.filter(t=>t.authenticated).length," connected"]})]})})]}),e.jsx("div",{className:"flex-1 flex flex-col min-w-0 bg-background",children:l&&g?e.jsx($,{provider:l.name,displayName:`${l.name} (${l.provider} variant)`,authStatus:g,catalog:F[l.provider],logoProvider:l.provider,onAddAccount:()=>C({provider:l.provider,displayName:g.displayName}),onSetDefault:t=>u.mutate({provider:l.provider,accountId:t}),onRemoveAccount:t=>d.mutate({provider:l.provider,accountId:t}),isRemovingAccount:d.isPending}):h?e.jsx($,{provider:h.provider,displayName:h.displayName,authStatus:h,catalog:F[h.provider],onAddAccount:()=>C({provider:h.provider,displayName:h.displayName}),onSetDefault:t=>u.mutate({provider:h.provider,accountId:t}),onRemoveAccount:t=>d.mutate({provider:h.provider,accountId:t}),isRemovingAccount:d.isPending}):e.jsx(Ue,{onSetup:()=>N(!0)})}),e.jsx(Ie,{open:L,onClose:()=>N(!1)}),e.jsx(Qe,{open:w!==null,onClose:()=>C(null),provider:w?.provider||"",displayName:w?.displayName||""})]})}export{ns as CliproxyPage};
1
+ import{j as e}from"./radix-ui-VbLlN_Dz.js";import{r as o}from"./react-vendor-DMek_JCF.js";import{u as fe}from"./tanstack-yybD444-.js";import{r as Y,s as je,t as Z,u as ve,D as J,v as X,w as ee,x as se,y as te,B as m,c as b,d as E,L as T,I as ae,z as Ne,A as we,E as ye,F as be,G as Ce,H as Se,J as Ae,K as ke,M as Pe,N as De,O as Me,i as Fe,S as Le,Q as $,R as ne,e as ie}from"./index-EyLCmFok.js";import{C as U,a as K}from"./card-CkFFTnqL.js";import{w as z,a as W,L as re,a9 as V,$ as Oe,j as P,o as Re,aa as R,p as M,y as G,A as Te,ab as _,U as Ve,z as Ge,Z as de,ac as ce,X as le,q as ze}from"./icons-B9AtZK5c.js";import"./notifications-cqk-Qeo2.js";import"./utils-CzKF5WmX.js";import"./form-utils-BXvNPyud.js";import"./code-highlight-C2TXE0-z.js";const F={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"},{id:"gemini-claude-sonnet-4-5-thinking",name:"Claude Sonnet 4.5 Thinking",description:"Balanced with extended thinking"},{id:"gemini-claude-sonnet-4-5",name:"Claude Sonnet 4.5",description:"Fast and capable"},{id:"gemini-3-pro-preview",name:"Gemini 3 Pro",description:"Google latest model via Antigravity"}]},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"},{id:"gemini-2.5-pro",name:"Gemini 2.5 Pro",description:"Stable, works with free Google account"}]},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"}]}},H=[{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"}];function Ie({open:a,onClose:c}){const[n,i]=o.useState("provider"),[r,u]=o.useState(""),[d,j]=o.useState(null),[p,f]=o.useState(""),[v,A]=o.useState(""),[L,N]=o.useState(!1),[w,C]=o.useState(!1),[x,S]=o.useState(!1),{data:k,refetch:h}=Y(),l=je(),g=Z(),{privacyMode:D}=ve(),y=k?.authStatus.find(s=>s.provider===r)?.accounts||[];o.useEffect(()=>{if(!a){const s=setTimeout(()=>{i("provider"),u(""),j(null),f(""),A(""),N(!1),S(!1)},0);return()=>clearTimeout(s)}},[a]),o.useEffect(()=>{if(n==="auth"&&y.length>0&&!x){const s=setTimeout(()=>{i("account")},0);return()=>clearTimeout(s)}},[n,y,x]);const t=async s=>{await navigator.clipboard.writeText(s),N(!0),setTimeout(()=>N(!1),2e3)},O=async()=>{C(!0),await h(),C(!1)},oe=()=>{g.mutate({provider:r},{onSuccess:s=>{s.account&&(j(s.account),i("variant")),h()}})},me=s=>{u(s),(k?.authStatus.find(ge=>ge.provider===s)?.accounts||[]).length===0?i("auth"):i("account")},ue=s=>{j(s),i("variant")},xe=async()=>{if(!(!p||!r))try{await l.mutateAsync({name:p,provider:r,model:v||void 0,account:d?.id}),i("success")}catch(s){console.error("Failed to create variant:",s)}},Q=`ccs ${r} --auth --add`,q=["provider","auth","variant","success"],pe=(s=>s==="account"?1:q.indexOf(s))(n),he=s=>{if(!s&&(n==="success"||n==="provider")){c();return}};return e.jsx(J,{open:a,onOpenChange:he,children:e.jsxs(X,{className:"sm:max-w-lg",onPointerDownOutside:s=>{n!=="success"&&n!=="provider"&&s.preventDefault()},onEscapeKeyDown:s=>{(g.isPending||l.isPending)&&s.preventDefault()},children:[e.jsxs(ee,{children:[e.jsxs(se,{className:"flex items-center gap-2",children:[e.jsx(z,{className:"w-5 h-5 text-primary"}),"Quick Setup Wizard"]}),e.jsxs(te,{children:[n==="provider"&&"Select a provider to get started",n==="auth"&&"Authenticate with your provider",n==="account"&&"Select which account to use",n==="variant"&&"Create your custom variant",n==="success"&&"Setup complete!"]})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[n==="provider"&&e.jsx("div",{className:"grid gap-2",children:H.map(s=>e.jsxs("button",{onClick:()=>me(s.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:s.name}),e.jsx("div",{className:"text-xs text-muted-foreground",children:s.description})]}),e.jsx(W,{className:"w-4 h-4 text-muted-foreground"})]},s.id))}),n==="auth"&&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 ",H.find(s=>s.id===r)?.name," to add an account"]}),e.jsx(m,{onClick:oe,disabled:g.isPending,className:"w-full gap-2",size:"lg",children:g.isPending?e.jsxs(e.Fragment,{children:[e.jsx(re,{className:"w-4 h-4 animate-spin"}),"Authenticating..."]}):e.jsxs(e.Fragment,{children:[e.jsx(V,{className:"w-4 h-4"}),"Authenticate in Browser"]})}),g.isPending&&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(U,{children:e.jsxs(K,{className:"p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(Oe,{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:Q}),e.jsx(m,{variant:"outline",size:"icon",onClick:()=>t(Q),children:L?e.jsx(P,{className:"w-4 h-4 text-green-500"}):e.jsx(Re,{className:"w-4 h-4"})})]})]})}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(m,{variant:"ghost",onClick:()=>i("provider"),disabled:g.isPending,children:[e.jsx(R,{className:"w-4 h-4 mr-2"}),"Back"]}),e.jsxs(m,{variant:"outline",onClick:O,disabled:w||g.isPending,children:[e.jsx(M,{className:`w-4 h-4 mr-2 ${w?"animate-spin":""}`}),w?"Checking...":"Refresh Status"]})]})]}),n==="account"&&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 (",y.length,")"]}),e.jsx("div",{className:"grid gap-2",children:y.map(s=>e.jsxs("button",{type:"button",onClick:()=>ue(s),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(G,{className:"w-4 h-4 text-muted-foreground"})}),e.jsxs("div",{children:[e.jsx("div",{className:b("font-medium",D&&E),children:s.email||s.id}),s.isDefault&&e.jsx("div",{className:"text-xs text-muted-foreground",children:"Default account"})]})]}),e.jsx(W,{className:"w-4 h-4 text-muted-foreground"})]},s.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:()=>{S(!0),i("auth")},children:[e.jsx("div",{className:"w-8 h-8 rounded-full bg-primary/10 flex items-center justify-center shrink-0",children:e.jsx(V,{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(m,{variant:"ghost",onClick:()=>i("provider"),children:[e.jsx(R,{className:"w-4 h-4 mr-2"}),"Back"]})})]}),n==="variant"&&e.jsxs("div",{className:"space-y-4",children:[d&&e.jsxs("div",{className:"flex items-center gap-2 p-2 bg-muted/50 rounded-md text-sm",children:[e.jsx(G,{className:"w-4 h-4"}),e.jsxs("span",{children:["Using:"," ",e.jsx("span",{className:b(D&&E),children:d.email||d.id})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(T,{htmlFor:"variant-name",children:"Variant Name *"}),e.jsx(ae,{id:"variant-name",value:p,onChange:s=>f(s.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 ",p||"<name>",' "prompt"']})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(T,{children:"Model"}),e.jsxs(Ne,{value:v,onValueChange:A,children:[e.jsx(we,{children:e.jsx(ye,{placeholder:"Select a model"})}),e.jsx(be,{children:F[r]?.models.map(s=>e.jsx(Ce,{value:s.id,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{children:s.name}),s.description&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:["- ",s.description]})]})},s.id))})]}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:["Default: ",F[r]?.defaultModel||"provider default"]})]}),e.jsxs("div",{className:"flex items-center justify-between pt-2",children:[e.jsxs(m,{variant:"ghost",onClick:()=>y.length>0?i("account"):i("provider"),children:[e.jsx(R,{className:"w-4 h-4 mr-2"}),"Back"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(m,{variant:"ghost",onClick:c,children:"Skip"}),e.jsx(m,{onClick:xe,disabled:!p||l.isPending,children:l.isPending?"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"})]}),n==="success"&&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(P,{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(U,{children:e.jsxs(K,{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 ",p,' "your prompt here"']})]})}),e.jsx(m,{onClick:c,className:"w-full",children:"Done"})]})]}),e.jsx("div",{className:"flex justify-center gap-1 pt-2",children:q.map((s,B)=>e.jsx("div",{className:`w-2 h-2 rounded-full transition-colors ${pe>=B?"bg-primary":"bg-muted"}`},s))})]})})}function Qe({open:a,onClose:c,provider:n,displayName:i}){const[r,u]=o.useState(""),d=Z(),j=()=>{d.mutate({provider:n,nickname:r.trim()||void 0},{onSuccess:()=>{u(""),c()}})},p=f=>{!f&&!d.isPending&&(u(""),c())};return e.jsx(J,{open:a,onOpenChange:p,children:e.jsxs(X,{className:"sm:max-w-md",children:[e.jsxs(ee,{children:[e.jsxs(se,{children:["Add ",i," Account"]}),e.jsx(te,{children:"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(T,{htmlFor:"nickname",children:"Nickname (optional)"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(G,{className:"w-4 h-4 text-muted-foreground"}),e.jsx(ae,{id:"nickname",value:r,onChange:f=>u(f.target.value),placeholder:"e.g., work, personal",disabled:d.isPending,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(m,{variant:"ghost",onClick:c,disabled:d.isPending,children:"Cancel"}),e.jsx(m,{onClick:j,disabled:d.isPending,children:d.isPending?e.jsxs(e.Fragment,{children:[e.jsx(re,{className:"w-4 h-4 mr-2 animate-spin"}),"Authenticating..."]}):e.jsxs(e.Fragment,{children:[e.jsx(V,{className:"w-4 h-4 mr-2"}),"Authenticate"]})})]}),d.isPending&&e.jsx("p",{className:"text-sm text-center text-muted-foreground",children:"Complete the OAuth flow in your browser..."})]})]})})}function qe(a){if(!a)return"";const c=new Date(a).getTime(),i=Date.now()-c,r=Math.floor(i/(1e3*60*60)),u=Math.floor(i%(1e3*60*60)/(1e3*60));return r>0?`${r}h ${u}m`:`${u}m`}function Be(){const{data:a,isLoading:c}=Se(),n=Ae(),i=a?.running??!1;return e.jsxs("div",{className:b("rounded-lg border p-3 transition-colors",i?"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:b("w-2 h-2 rounded-full",i?"bg-green-500 animate-pulse":"bg-muted-foreground/30")}),e.jsx("span",{className:"text-sm font-medium",children:"CLIProxy Service"})]}),e.jsx("div",{className:"flex items-center gap-1",children:c?e.jsx(M,{className:"w-3 h-3 animate-spin text-muted-foreground"}):i?e.jsx(Te,{className:"w-3 h-3 text-green-600"}):e.jsx(_,{className:"w-3 h-3 text-muted-foreground"})})]}),i&&a?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 ",a.port]}),a.sessionCount!==void 0&&a.sessionCount>0&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Ve,{className:"w-3 h-3"}),a.sessionCount," session",a.sessionCount!==1?"s":""]}),a.startedAt&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Ge,{className:"w-3 h-3"}),qe(a.startedAt)]})]}):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(m,{variant:"outline",size:"sm",className:"h-7 text-xs gap-1",onClick:()=>n.mutate(),disabled:n.isPending,children:[n.isPending?e.jsx(M,{className:"w-3 h-3 animate-spin"}):e.jsx(_,{className:"w-3 h-3"}),"Start"]})]})]})}function Ee({status:a,isSelected:c,onSelect:n}){const i=a.accounts?.length||0;return e.jsxs("button",{className:b("w-full flex items-center gap-3 px-3 py-2.5 rounded-lg transition-colors cursor-pointer text-left",c?"bg-primary/10 border border-primary/20":"hover:bg-muted border border-transparent"),onClick:n,children:[e.jsx(ne,{provider:a.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:a.displayName}),i>0&&e.jsx(ie,{variant:"secondary",className:"text-[10px] h-4 px-1",children:i})]}),e.jsx("div",{className:"flex items-center gap-1.5 mt-0.5",children:a.authenticated?e.jsxs(e.Fragment,{children:[e.jsx(P,{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(le,{className:"w-3 h-3 text-muted-foreground"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"Not connected"})]})})]})]})}function $e({variant:a,parentAuth:c,isSelected:n,onSelect:i,onDelete:r,isDeleting:u}){return e.jsxs("button",{className:b("group w-full flex items-center gap-3 px-3 py-2 rounded-lg transition-colors cursor-pointer text-left pl-6",n?"bg-primary/10 border border-primary/20":"hover:bg-muted border border-transparent"),onClick:i,children:[e.jsxs("div",{className:"relative",children:[e.jsx(ne,{provider:a.provider,size:"sm"}),e.jsx(ce,{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:a.name}),e.jsx(ie,{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:c?.authenticated?e.jsxs(e.Fragment,{children:[e.jsx(P,{className:"w-3 h-3 text-green-600"}),e.jsxs("span",{className:"text-xs text-muted-foreground truncate",children:["via ",a.provider]})]}):e.jsxs(e.Fragment,{children:[e.jsx(le,{className:"w-3 h-3 text-muted-foreground"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"Parent not connected"})]})})]}),e.jsx(m,{variant:"ghost",size:"icon",className:"h-6 w-6 opacity-0 group-hover:opacity-100 hover:text-destructive",onClick:d=>{d.stopPropagation(),r()},disabled:u,children:e.jsx(ze,{className:"w-3 h-3"})})]})}function Ue({onSetup:a}){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(de,{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(m,{onClick:a,className:"gap-2",children:[e.jsx(z,{className:"w-4 h-4"}),"Quick Setup"]})]})})}function ns(){const a=fe(),{data:c,isLoading:n}=Y(),{data:i,isFetching:r}=ke(),u=Pe(),d=De(),j=Me(),[p,f]=o.useState(null),[v,A]=o.useState(null),[L,N]=o.useState(!1),[w,C]=o.useState(null),x=c?.authStatus||[],S=i?.variants||[],k=o.useMemo(()=>v?null:p&&x.some(t=>t.provider===p)?p:x.length>0?x[0].provider:null,[p,v,x]),h=x.find(t=>t.provider===k),l=S.find(t=>t.name===v),g=l?x.find(t=>t.provider===l.provider):void 0,D=()=>{a.invalidateQueries({queryKey:["cliproxy"]}),a.invalidateQueries({queryKey:["cliproxy-auth"]})},I=t=>{f(t),A(null)},y=t=>{A(t),f(null)};return e.jsxs("div",{className:"h-[calc(100vh-100px)] flex",children:[e.jsxs("div",{className:"w-64 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(de,{className:"w-5 h-5 text-primary"}),e.jsx("h1",{className:"font-semibold",children:"CLIProxy"})]}),e.jsx(m,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:D,disabled:r,children:e.jsx(M,{className:b("w-4 h-4",r&&"animate-spin")})})]}),e.jsx("p",{className:"text-xs text-muted-foreground mb-3",children:"CCS-level account management"}),e.jsxs(m,{variant:"default",size:"sm",className:"w-full gap-2",onClick:()=>N(!0),children:[e.jsx(z,{className:"w-4 h-4"}),"Quick Setup"]})]}),e.jsx(Fe,{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"}),n?e.jsx("div",{className:"space-y-2 px-2",children:[1,2,3,4].map(t=>e.jsx(Le,{className:"h-14 w-full rounded-lg"},t))}):e.jsx("div",{className:"space-y-1",children:x.map(t=>e.jsx(Ee,{status:t,isSelected:k===t.provider,onSelect:()=>I(t.provider)},t.provider))}),S.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(ce,{className:"w-3 h-3"}),"Variants"]}),e.jsx("div",{className:"space-y-1",children:S.map(t=>e.jsx($e,{variant:t,parentAuth:x.find(O=>O.provider===t.provider),isSelected:v===t.name,onSelect:()=>y(t.name),onDelete:()=>j.mutate(t.name),isDeleting:j.isPending},t.name))})]})]})}),e.jsx("div",{className:"p-3 border-t",children:e.jsx(Be,{})}),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:[x.length," provider",x.length!==1?"s":""]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(P,{className:"w-3 h-3 text-green-600"}),x.filter(t=>t.authenticated).length," connected"]})]})})]}),e.jsx("div",{className:"flex-1 flex flex-col min-w-0 bg-background",children:l&&g?e.jsx($,{provider:l.name,displayName:`${l.name} (${l.provider} variant)`,authStatus:g,catalog:F[l.provider],logoProvider:l.provider,onAddAccount:()=>C({provider:l.provider,displayName:g.displayName}),onSetDefault:t=>u.mutate({provider:l.provider,accountId:t}),onRemoveAccount:t=>d.mutate({provider:l.provider,accountId:t}),isRemovingAccount:d.isPending}):h?e.jsx($,{provider:h.provider,displayName:h.displayName,authStatus:h,catalog:F[h.provider],onAddAccount:()=>C({provider:h.provider,displayName:h.displayName}),onSetDefault:t=>u.mutate({provider:h.provider,accountId:t}),onRemoveAccount:t=>d.mutate({provider:h.provider,accountId:t}),isRemovingAccount:d.isPending}):e.jsx(Ue,{onSetup:()=>N(!0)})}),e.jsx(Ie,{open:L,onClose:()=>N(!1)}),e.jsx(Qe,{open:w!==null,onClose:()=>C(null),provider:w?.provider||"",displayName:w?.displayName||""})]})}export{ns as CliproxyPage};
@@ -1 +1 @@
1
- import{j as e}from"./radix-ui-VbLlN_Dz.js";import{r as s}from"./react-vendor-DMek_JCF.js";import{G as b,p as d,a6 as g,K as j,X as p}from"./icons-WTNLz24z.js";const N=8317,C="ccs";function y({port:t=N}){const n=s.useRef(null),[r,c]=s.useState(!0),[o,a]=s.useState(null),[x,l]=s.useState(!1),[m,u]=s.useState(!0),i=`http://localhost:${t}/management.html`;s.useEffect(()=>{(async()=>{try{(await fetch(`http://localhost:${t}/`,{signal:AbortSignal.timeout(2e3)})).ok?(l(!0),a(null)):(l(!1),a("CLIProxy returned an error"))}catch{l(!1),a("CLIProxy is not running")}})()},[t]);const h=s.useCallback(()=>{if(c(!1),n.current?.contentWindow)try{n.current.contentWindow.postMessage({type:"ccs-auto-login",apiBase:`http://localhost:${t}`,managementKey:C},`http://localhost:${t}`)}catch{console.debug("[ControlPanelEmbed] postMessage failed - cross-origin")}},[t]),f=()=>{c(!0),n.current&&(n.current.src=i)};return!x&&o?e.jsxs("div",{className:"flex-1 flex flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between p-4 border-b",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(b,{className:"w-5 h-5 text-primary"}),e.jsx("h2",{className:"font-semibold",children:"CLIProxy Control Panel"})]}),e.jsxs("button",{className:"inline-flex items-center gap-2 px-3 py-1.5 text-sm border rounded-md hover:bg-muted",onClick:f,children:[e.jsx(d,{className:"w-4 h-4"}),"Retry"]})]}),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-destructive/10 flex items-center justify-center mx-auto mb-6",children:e.jsx(g,{className:"w-8 h-8 text-destructive"})}),e.jsx("h3",{className:"text-lg font-semibold mb-2",children:"CLIProxy Not Available"}),e.jsx("p",{className:"text-muted-foreground mb-4",children:o}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Start a CLIProxy session with"," ",e.jsx("code",{className:"bg-muted px-1 rounded",children:"ccs gemini"})," or run"," ",e.jsx("code",{className:"bg-muted px-1 rounded",children:"ccs config"})," which auto-starts it."]})]})})]}):e.jsxs("div",{className:"flex-1 flex flex-col relative",children:[m&&!r&&e.jsx("div",{className:"absolute top-2 left-1/2 -translate-x-1/2 z-20",children:e.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 bg-blue-50 dark:bg-blue-950 border border-blue-200 dark:border-blue-800 rounded-md text-sm",children:[e.jsx(j,{className:"h-3.5 w-3.5 text-blue-600"}),e.jsxs("span",{children:["Key:"," ",e.jsx("code",{className:"bg-blue-100 dark:bg-blue-900 px-1 rounded font-mono font-semibold",children:"ccs"})]}),e.jsx("button",{className:"text-blue-600 hover:text-blue-800 dark:hover:text-blue-400",onClick:()=>u(!1),children:e.jsx(p,{className:"h-3.5 w-3.5"})})]})}),r&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-background/80 z-10",children:e.jsxs("div",{className:"text-center",children:[e.jsx(d,{className:"w-8 h-8 animate-spin text-primary mx-auto mb-2"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading Control Panel..."})]})}),e.jsx("iframe",{ref:n,src:i,className:"flex-1 w-full border-0",title:"CLIProxy Management Panel",onLoad:h})]})}function E(){return e.jsx("div",{className:"h-[calc(100vh-100px)] flex flex-col",children:e.jsx(y,{})})}export{E as CliproxyControlPanelPage};
1
+ import{j as e}from"./radix-ui-VbLlN_Dz.js";import{r as s}from"./react-vendor-DMek_JCF.js";import{G as b,p as d,a6 as g,K as j,X as p}from"./icons-B9AtZK5c.js";const N=8317,C="ccs";function y({port:t=N}){const n=s.useRef(null),[r,c]=s.useState(!0),[o,a]=s.useState(null),[x,l]=s.useState(!1),[m,u]=s.useState(!0),i=`http://localhost:${t}/management.html`;s.useEffect(()=>{(async()=>{try{(await fetch(`http://localhost:${t}/`,{signal:AbortSignal.timeout(2e3)})).ok?(l(!0),a(null)):(l(!1),a("CLIProxy returned an error"))}catch{l(!1),a("CLIProxy is not running")}})()},[t]);const h=s.useCallback(()=>{if(c(!1),n.current?.contentWindow)try{n.current.contentWindow.postMessage({type:"ccs-auto-login",apiBase:`http://localhost:${t}`,managementKey:C},`http://localhost:${t}`)}catch{console.debug("[ControlPanelEmbed] postMessage failed - cross-origin")}},[t]),f=()=>{c(!0),n.current&&(n.current.src=i)};return!x&&o?e.jsxs("div",{className:"flex-1 flex flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between p-4 border-b",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(b,{className:"w-5 h-5 text-primary"}),e.jsx("h2",{className:"font-semibold",children:"CLIProxy Control Panel"})]}),e.jsxs("button",{className:"inline-flex items-center gap-2 px-3 py-1.5 text-sm border rounded-md hover:bg-muted",onClick:f,children:[e.jsx(d,{className:"w-4 h-4"}),"Retry"]})]}),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-destructive/10 flex items-center justify-center mx-auto mb-6",children:e.jsx(g,{className:"w-8 h-8 text-destructive"})}),e.jsx("h3",{className:"text-lg font-semibold mb-2",children:"CLIProxy Not Available"}),e.jsx("p",{className:"text-muted-foreground mb-4",children:o}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Start a CLIProxy session with"," ",e.jsx("code",{className:"bg-muted px-1 rounded",children:"ccs gemini"})," or run"," ",e.jsx("code",{className:"bg-muted px-1 rounded",children:"ccs config"})," which auto-starts it."]})]})})]}):e.jsxs("div",{className:"flex-1 flex flex-col relative",children:[m&&!r&&e.jsx("div",{className:"absolute top-2 left-1/2 -translate-x-1/2 z-20",children:e.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 bg-blue-50 dark:bg-blue-950 border border-blue-200 dark:border-blue-800 rounded-md text-sm",children:[e.jsx(j,{className:"h-3.5 w-3.5 text-blue-600"}),e.jsxs("span",{children:["Key:"," ",e.jsx("code",{className:"bg-blue-100 dark:bg-blue-900 px-1 rounded font-mono font-semibold",children:"ccs"})]}),e.jsx("button",{className:"text-blue-600 hover:text-blue-800 dark:hover:text-blue-400",onClick:()=>u(!1),children:e.jsx(p,{className:"h-3.5 w-3.5"})})]})}),r&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-background/80 z-10",children:e.jsxs("div",{className:"text-center",children:[e.jsx(d,{className:"w-8 h-8 animate-spin text-primary mx-auto mb-2"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading Control Panel..."})]})}),e.jsx("iframe",{ref:n,src:i,className:"flex-1 w-full border-0",title:"CLIProxy Management Panel",onLoad:h})]})}function E(){return e.jsx("div",{className:"h-[calc(100vh-100px)] flex flex-col",children:e.jsx(y,{})})}export{E as CliproxyControlPanelPage};
@@ -1,2 +1,2 @@
1
- import{j as e}from"./radix-ui-VbLlN_Dz.js";import{r as p}from"./react-vendor-DMek_JCF.js";import{aa as $,c as d,ab as A,B as I}from"./index-BXPLu3zJ.js";import{H as w,t as E}from"./code-highlight-C2TXE0-z.js";import{d as K,E as O,l as M,a6 as P}from"./icons-WTNLz24z.js";import"./tanstack-yybD444-.js";import"./notifications-cqk-Qeo2.js";import"./utils-CzKF5WmX.js";import"./form-utils-BXvNPyud.js";const F=[/^ANTHROPIC_AUTH_TOKEN$/,/_API_KEY$/,/_AUTH_TOKEN$/,/_SECRET$/,/_SECRET_KEY$/,/^API_KEY$/,/^AUTH_TOKEN$/,/^SECRET$/,/_PASSWORD$/,/^PASSWORD$/,/_CREDENTIAL$/,/_PRIVATE_KEY$/];function H(t){return F.some(n=>n.test(t))}function V(t){if(!t.trim())return{valid:!0};try{return JSON.parse(t),{valid:!0}}catch(n){const r=n.message,u=r.match(/position (\d+)/);if(u){const m=parseInt(u[1],10),o=t.substring(0,m).split(`
1
+ import{j as e}from"./radix-ui-VbLlN_Dz.js";import{r as p}from"./react-vendor-DMek_JCF.js";import{a3 as $,c as d,a4 as A,B as I}from"./index-EyLCmFok.js";import{H as w,t as E}from"./code-highlight-C2TXE0-z.js";import{c as K,E as O,l as M,a6 as P}from"./icons-B9AtZK5c.js";import"./tanstack-yybD444-.js";import"./notifications-cqk-Qeo2.js";import"./utils-CzKF5WmX.js";import"./form-utils-BXvNPyud.js";const F=[/^ANTHROPIC_AUTH_TOKEN$/,/_API_KEY$/,/_AUTH_TOKEN$/,/_SECRET$/,/_SECRET_KEY$/,/^API_KEY$/,/^AUTH_TOKEN$/,/^SECRET$/,/_PASSWORD$/,/^PASSWORD$/,/_CREDENTIAL$/,/_PRIVATE_KEY$/];function H(t){return F.some(n=>n.test(t))}function V(t){if(!t.trim())return{valid:!0};try{return JSON.parse(t),{valid:!0}}catch(n){const r=n.message,u=r.match(/position (\d+)/);if(u){const m=parseInt(u[1],10),o=t.substring(0,m).split(`
2
2
  `);return{valid:!1,error:r,line:o.length}}return{valid:!1,error:r}}}function q({value:t,onChange:n,language:a="json",readonly:r=!1,className:u,minHeight:m="300px"}){const{isDark:o}=$(),[N,h]=p.useState(!1),[l,j]=p.useState(!0),i=p.useMemo(()=>a==="json"?V(t):{valid:!0},[t,a]),b=p.useCallback(S=>e.jsx(w,{theme:o?E.nightOwl:E.github,code:S,language:a,children:({tokens:_,getLineProps:C,getTokenProps:T})=>{let c=!1;return e.jsx(e.Fragment,{children:_.map((x,g)=>e.jsx("div",{...C({line:x}),className:d(i.line===g+1&&"bg-destructive/20"),children:x.map((s,y)=>{let v=!1;if(s.types.includes("property")){const R=s.content.replace(/['"]/g,"");H(R)?c=!0:c=!1}else(s.types.includes("string")||s.types.includes("number")||s.types.includes("boolean"))&&c?(v=!0,c=!1):s.types.includes("punctuation")&&s.content!==":"&&s.content!=="["&&s.content!=="{"&&(c=!1);const f=T({token:s});return v&&l&&(f.className=d(f.className,"blur-[3px] select-none opacity-70 transition-all duration-200")),e.jsx("span",{...f},y)})},g))})}}),[o,a,i.line,l]);return e.jsxs("div",{className:d("flex flex-col",u),children:[e.jsxs("div",{className:d("relative rounded-md border overflow-hidden","bg-muted/30",N&&"ring-2 ring-ring ring-offset-2 ring-offset-background",r&&"opacity-70 cursor-not-allowed",!i.valid&&"border-destructive"),style:{minHeight:m},children:[e.jsx(A,{value:t,onValueChange:r?()=>{}:n,highlight:b,padding:12,disabled:r,onFocus:()=>h(!0),onBlur:()=>h(!1),textareaClassName:d("focus:outline-none font-mono text-sm",r&&"cursor-not-allowed"),preClassName:"font-mono text-sm",style:{fontFamily:"ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace",fontSize:"0.875rem",minHeight:m}},o?"dark-editor":"light-editor"),e.jsx("div",{className:"absolute top-2 right-2 z-10 opacity-50 hover:opacity-100 transition-opacity",children:e.jsx(I,{variant:"ghost",size:"icon",className:"h-6 w-6 bg-background/50 hover:bg-background border shadow-sm rounded-full",onClick:()=>j(!l),title:l?"Reveal sensitive values":"Mask sensitive values",children:l?e.jsx(K,{className:"h-3 w-3"}):e.jsx(O,{className:"h-3 w-3"})})})]}),e.jsxs("div",{className:"flex items-center gap-2 mt-2 text-xs",children:[i.valid?e.jsxs("span",{className:"flex items-center gap-1 text-muted-foreground",children:[e.jsx(M,{className:"w-3 h-3 text-green-500"}),"Valid ",a.toUpperCase()]}):e.jsxs("span",{className:"flex items-center gap-1 text-destructive",children:[e.jsx(P,{className:"w-3 h-3"}),i.error,i.line&&` (line ${i.line})`]}),r&&e.jsx("span",{className:"ml-auto text-muted-foreground",children:"(Read-only)"})]})]})}export{q as CodeEditor};