@kaitranntt/ccs 7.75.0 → 7.76.0-dev.2

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 (739) hide show
  1. package/dist/api/services/cliproxy-profile-bridge.js +4 -4
  2. package/dist/api/services/cliproxy-profile-bridge.js.map +1 -1
  3. package/dist/api/services/profile-lifecycle-validation.js +1 -1
  4. package/dist/api/services/profile-lifecycle-validation.js.map +1 -1
  5. package/dist/api/services/profile-writer.js +1 -1
  6. package/dist/api/services/profile-writer.js.map +1 -1
  7. package/dist/auth/profile-registry.d.ts.map +1 -1
  8. package/dist/auth/profile-registry.js +9 -0
  9. package/dist/auth/profile-registry.js.map +1 -1
  10. package/dist/ccs.js +77 -9
  11. package/dist/ccs.js.map +1 -1
  12. package/dist/cliproxy/{account-manager.d.ts → accounts/account-manager.d.ts} +2 -2
  13. package/dist/cliproxy/accounts/account-manager.d.ts.map +1 -0
  14. package/dist/cliproxy/{account-manager.js → accounts/account-manager.js} +34 -34
  15. package/dist/cliproxy/accounts/account-manager.js.map +1 -0
  16. package/dist/cliproxy/{account-safety.d.ts → accounts/account-safety.d.ts} +1 -1
  17. package/dist/cliproxy/accounts/account-safety.d.ts.map +1 -0
  18. package/dist/cliproxy/{account-safety.js → accounts/account-safety.js} +5 -5
  19. package/dist/cliproxy/accounts/account-safety.js.map +1 -0
  20. package/dist/cliproxy/accounts/account-stats-key.d.ts.map +1 -0
  21. package/dist/cliproxy/accounts/account-stats-key.js.map +1 -0
  22. package/dist/cliproxy/accounts/registry.js +1 -1
  23. package/dist/cliproxy/accounts/registry.js.map +1 -1
  24. package/dist/cliproxy/accounts/token-file-ops.js +1 -1
  25. package/dist/cliproxy/accounts/token-file-ops.js.map +1 -1
  26. package/dist/cliproxy/{codex-plan-compatibility.d.ts → ai-providers/codex-plan-compatibility.d.ts} +4 -4
  27. package/dist/cliproxy/ai-providers/codex-plan-compatibility.d.ts.map +1 -0
  28. package/dist/cliproxy/{codex-plan-compatibility.js → ai-providers/codex-plan-compatibility.js} +5 -5
  29. package/dist/cliproxy/ai-providers/codex-plan-compatibility.js.map +1 -0
  30. package/dist/cliproxy/ai-providers/codex-reasoning-proxy.d.ts.map +1 -0
  31. package/dist/cliproxy/{codex-reasoning-proxy.js → ai-providers/codex-reasoning-proxy.js} +1 -1
  32. package/dist/cliproxy/ai-providers/codex-reasoning-proxy.js.map +1 -0
  33. package/dist/cliproxy/ai-providers/config-store.js +3 -3
  34. package/dist/cliproxy/ai-providers/config-store.js.map +1 -1
  35. package/dist/cliproxy/{managed-model-prefixes.d.ts → ai-providers/managed-model-prefixes.d.ts} +1 -1
  36. package/dist/cliproxy/ai-providers/managed-model-prefixes.d.ts.map +1 -0
  37. package/dist/cliproxy/{managed-model-prefixes.js → ai-providers/managed-model-prefixes.js} +3 -3
  38. package/dist/cliproxy/ai-providers/managed-model-prefixes.js.map +1 -0
  39. package/dist/cliproxy/{model-id-normalizer.d.ts → ai-providers/model-id-normalizer.d.ts} +1 -1
  40. package/dist/cliproxy/ai-providers/model-id-normalizer.d.ts.map +1 -0
  41. package/dist/cliproxy/{model-id-normalizer.js → ai-providers/model-id-normalizer.js} +1 -1
  42. package/dist/cliproxy/ai-providers/model-id-normalizer.js.map +1 -0
  43. package/dist/cliproxy/ai-providers/openai-compat-manager.d.ts.map +1 -0
  44. package/dist/cliproxy/{openai-compat-manager.js → ai-providers/openai-compat-manager.js} +7 -6
  45. package/dist/cliproxy/ai-providers/openai-compat-manager.js.map +1 -0
  46. package/dist/cliproxy/ai-providers/schema-sanitizer.d.ts.map +1 -0
  47. package/dist/cliproxy/ai-providers/schema-sanitizer.js.map +1 -0
  48. package/dist/cliproxy/{tool-name-mapper.d.ts → ai-providers/tool-name-mapper.d.ts} +7 -2
  49. package/dist/cliproxy/ai-providers/tool-name-mapper.d.ts.map +1 -0
  50. package/dist/cliproxy/{tool-name-mapper.js → ai-providers/tool-name-mapper.js} +35 -21
  51. package/dist/cliproxy/ai-providers/tool-name-mapper.js.map +1 -0
  52. package/dist/cliproxy/{tool-name-sanitizer.d.ts → ai-providers/tool-name-sanitizer.d.ts} +2 -1
  53. package/dist/cliproxy/ai-providers/tool-name-sanitizer.d.ts.map +1 -0
  54. package/dist/cliproxy/{tool-name-sanitizer.js → ai-providers/tool-name-sanitizer.js} +23 -3
  55. package/dist/cliproxy/ai-providers/tool-name-sanitizer.js.map +1 -0
  56. package/dist/cliproxy/auth/antigravity-responsibility.d.ts.map +1 -0
  57. package/dist/cliproxy/{antigravity-responsibility.js → auth/antigravity-responsibility.js} +2 -2
  58. package/dist/cliproxy/auth/antigravity-responsibility.js.map +1 -0
  59. package/dist/cliproxy/{auth-handler.d.ts → auth/auth-handler.d.ts} +5 -5
  60. package/dist/cliproxy/auth/auth-handler.d.ts.map +1 -0
  61. package/dist/cliproxy/{auth-handler.js → auth/auth-handler.js} +23 -23
  62. package/dist/cliproxy/auth/auth-handler.js.map +1 -0
  63. package/dist/cliproxy/{auth-session-manager.d.ts → auth/auth-session-manager.d.ts} +1 -1
  64. package/dist/cliproxy/auth/auth-session-manager.d.ts.map +1 -0
  65. package/dist/cliproxy/{auth-session-manager.js → auth/auth-session-manager.js} +16 -9
  66. package/dist/cliproxy/auth/auth-session-manager.js.map +1 -0
  67. package/dist/cliproxy/auth/auth-token-manager.d.ts.map +1 -0
  68. package/dist/cliproxy/{auth-token-manager.js → auth/auth-token-manager.js} +6 -6
  69. package/dist/cliproxy/auth/auth-token-manager.js.map +1 -0
  70. package/dist/cliproxy/auth/auth-types.d.ts +1 -1
  71. package/dist/cliproxy/auth/auth-types.d.ts.map +1 -1
  72. package/dist/cliproxy/auth/auth-utils.d.ts.map +1 -0
  73. package/dist/cliproxy/auth/auth-utils.js.map +1 -0
  74. package/dist/cliproxy/auth/device-code-handler.d.ts.map +1 -0
  75. package/dist/cliproxy/auth/device-code-handler.js.map +1 -0
  76. package/dist/cliproxy/auth/kiro-import.js +1 -1
  77. package/dist/cliproxy/auth/kiro-import.js.map +1 -1
  78. package/dist/cliproxy/auth/oauth-handler.d.ts +2 -2
  79. package/dist/cliproxy/auth/oauth-handler.d.ts.map +1 -1
  80. package/dist/cliproxy/auth/oauth-handler.js +25 -5
  81. package/dist/cliproxy/auth/oauth-handler.js.map +1 -1
  82. package/dist/cliproxy/auth/oauth-process.d.ts +1 -1
  83. package/dist/cliproxy/auth/oauth-process.d.ts.map +1 -1
  84. package/dist/cliproxy/auth/oauth-process.js +3 -3
  85. package/dist/cliproxy/auth/oauth-process.js.map +1 -1
  86. package/dist/cliproxy/auth/project-selection-handler.d.ts.map +1 -0
  87. package/dist/cliproxy/auth/project-selection-handler.js.map +1 -0
  88. package/dist/cliproxy/{provider-entitlement-evidence.d.ts → auth/provider-entitlement-evidence.d.ts} +1 -1
  89. package/dist/cliproxy/auth/provider-entitlement-evidence.d.ts.map +1 -0
  90. package/dist/cliproxy/auth/provider-entitlement-evidence.js.map +1 -0
  91. package/dist/cliproxy/{provider-entitlement-types.d.ts → auth/provider-entitlement-types.d.ts} +1 -1
  92. package/dist/cliproxy/auth/provider-entitlement-types.d.ts.map +1 -0
  93. package/dist/cliproxy/auth/provider-entitlement-types.js.map +1 -0
  94. package/dist/cliproxy/auth/provider-refreshers/index.js +1 -1
  95. package/dist/cliproxy/auth/provider-refreshers/index.js.map +1 -1
  96. package/dist/cliproxy/auth/token-expiry-checker.js +1 -1
  97. package/dist/cliproxy/auth/token-expiry-checker.js.map +1 -1
  98. package/dist/cliproxy/auth/token-manager.d.ts +1 -1
  99. package/dist/cliproxy/auth/token-manager.d.ts.map +1 -1
  100. package/dist/cliproxy/auth/token-manager.js +4 -4
  101. package/dist/cliproxy/auth/token-manager.js.map +1 -1
  102. package/dist/cliproxy/binary/extractor.js +1 -1
  103. package/dist/cliproxy/binary/extractor.js.map +1 -1
  104. package/dist/cliproxy/binary/installer.d.ts +1 -1
  105. package/dist/cliproxy/binary/installer.d.ts.map +1 -1
  106. package/dist/cliproxy/binary/installer.js +1 -1
  107. package/dist/cliproxy/binary/installer.js.map +1 -1
  108. package/dist/cliproxy/binary/lifecycle.js +3 -3
  109. package/dist/cliproxy/binary/lifecycle.js.map +1 -1
  110. package/dist/cliproxy/{platform-detector.d.ts → binary/platform-detector.d.ts} +5 -5
  111. package/dist/cliproxy/binary/platform-detector.d.ts.map +1 -0
  112. package/dist/cliproxy/{platform-detector.js → binary/platform-detector.js} +2 -2
  113. package/dist/cliproxy/binary/platform-detector.js.map +1 -0
  114. package/dist/cliproxy/binary/tar-extractor.d.ts.map +1 -1
  115. package/dist/cliproxy/binary/tar-extractor.js +1 -1
  116. package/dist/cliproxy/binary/tar-extractor.js.map +1 -1
  117. package/dist/cliproxy/binary/version-cache.js +2 -2
  118. package/dist/cliproxy/binary/version-cache.js.map +1 -1
  119. package/dist/cliproxy/binary/version-checker.js +1 -1
  120. package/dist/cliproxy/binary/version-checker.js.map +1 -1
  121. package/dist/cliproxy/binary/zip-extractor.d.ts.map +1 -1
  122. package/dist/cliproxy/binary/zip-extractor.js +1 -1
  123. package/dist/cliproxy/binary/zip-extractor.js.map +1 -1
  124. package/dist/cliproxy/binary-manager.js +2 -2
  125. package/dist/cliproxy/binary-manager.js.map +1 -1
  126. package/dist/cliproxy/{base-config-loader.d.ts → config/base-config-loader.d.ts} +1 -1
  127. package/dist/cliproxy/config/base-config-loader.d.ts.map +1 -0
  128. package/dist/cliproxy/{base-config-loader.js → config/base-config-loader.js} +1 -1
  129. package/dist/cliproxy/config/base-config-loader.js.map +1 -0
  130. package/dist/cliproxy/config/composite-validator.d.ts.map +1 -0
  131. package/dist/cliproxy/{composite-validator.js → config/composite-validator.js} +2 -2
  132. package/dist/cliproxy/config/composite-validator.js.map +1 -0
  133. package/dist/cliproxy/{config-generator.d.ts → config/config-generator.d.ts} +1 -1
  134. package/dist/cliproxy/config/config-generator.d.ts.map +1 -0
  135. package/dist/cliproxy/{config-generator.js → config/config-generator.js} +1 -1
  136. package/dist/cliproxy/config/config-generator.js.map +1 -0
  137. package/dist/cliproxy/config/env-builder.js +3 -3
  138. package/dist/cliproxy/config/env-builder.js.map +1 -1
  139. package/dist/cliproxy/config/generator.js +3 -3
  140. package/dist/cliproxy/config/generator.js.map +1 -1
  141. package/dist/cliproxy/{model-config.d.ts → config/model-config.d.ts} +1 -1
  142. package/dist/cliproxy/config/model-config.d.ts.map +1 -0
  143. package/dist/cliproxy/{model-config.js → config/model-config.js} +5 -5
  144. package/dist/cliproxy/config/model-config.js.map +1 -0
  145. package/dist/cliproxy/config/thinking-config.js +1 -1
  146. package/dist/cliproxy/config/thinking-config.js.map +1 -1
  147. package/dist/cliproxy/{cliproxy-executor.d.ts → executor/cliproxy-executor.d.ts} +2 -2
  148. package/dist/cliproxy/executor/cliproxy-executor.d.ts.map +1 -0
  149. package/dist/cliproxy/{cliproxy-executor.js → executor/cliproxy-executor.js} +6 -6
  150. package/dist/cliproxy/executor/cliproxy-executor.js.map +1 -0
  151. package/dist/cliproxy/executor/env-resolver.d.ts +5 -5
  152. package/dist/cliproxy/executor/env-resolver.d.ts.map +1 -1
  153. package/dist/cliproxy/executor/env-resolver.js +3 -3
  154. package/dist/cliproxy/executor/env-resolver.js.map +1 -1
  155. package/dist/cliproxy/executor/index.d.ts +1 -1
  156. package/dist/cliproxy/executor/index.d.ts.map +1 -1
  157. package/dist/cliproxy/executor/index.js +18 -18
  158. package/dist/cliproxy/executor/index.js.map +1 -1
  159. package/dist/cliproxy/executor/lifecycle-manager.js +1 -1
  160. package/dist/cliproxy/executor/lifecycle-manager.js.map +1 -1
  161. package/dist/cliproxy/executor/retry-handler.js +3 -3
  162. package/dist/cliproxy/executor/retry-handler.js.map +1 -1
  163. package/dist/cliproxy/executor/session-bridge.d.ts.map +1 -1
  164. package/dist/cliproxy/executor/session-bridge.js +3 -3
  165. package/dist/cliproxy/executor/session-bridge.js.map +1 -1
  166. package/dist/cliproxy/index.d.ts +31 -31
  167. package/dist/cliproxy/index.d.ts.map +1 -1
  168. package/dist/cliproxy/index.js +20 -20
  169. package/dist/cliproxy/index.js.map +1 -1
  170. package/dist/cliproxy/{management-api-client.d.ts → management/management-api-client.d.ts} +1 -1
  171. package/dist/cliproxy/management/management-api-client.d.ts.map +1 -0
  172. package/dist/cliproxy/{management-api-client.js → management/management-api-client.js} +1 -1
  173. package/dist/cliproxy/management/management-api-client.js.map +1 -0
  174. package/dist/cliproxy/management/management-api-types.d.ts.map +1 -0
  175. package/dist/cliproxy/management/management-api-types.js.map +1 -0
  176. package/dist/cliproxy/management/remote-token-uploader.d.ts.map +1 -0
  177. package/dist/cliproxy/{remote-token-uploader.js → management/remote-token-uploader.js} +2 -2
  178. package/dist/cliproxy/management/remote-token-uploader.js.map +1 -0
  179. package/dist/cliproxy/model-catalog.js +1 -1
  180. package/dist/cliproxy/model-catalog.js.map +1 -1
  181. package/dist/cliproxy/proxy/https-tunnel-proxy.d.ts.map +1 -0
  182. package/dist/cliproxy/{https-tunnel-proxy.js → proxy/https-tunnel-proxy.js} +7 -2
  183. package/dist/cliproxy/proxy/https-tunnel-proxy.js.map +1 -0
  184. package/dist/cliproxy/{proxy-config-resolver.d.ts → proxy/proxy-config-resolver.d.ts} +1 -1
  185. package/dist/cliproxy/proxy/proxy-config-resolver.d.ts.map +1 -0
  186. package/dist/cliproxy/{proxy-config-resolver.js → proxy/proxy-config-resolver.js} +3 -3
  187. package/dist/cliproxy/proxy/proxy-config-resolver.js.map +1 -0
  188. package/dist/cliproxy/{proxy-detector.d.ts → proxy/proxy-detector.d.ts} +1 -1
  189. package/dist/cliproxy/proxy/proxy-detector.d.ts.map +1 -0
  190. package/dist/cliproxy/{proxy-detector.js → proxy/proxy-detector.js} +7 -7
  191. package/dist/cliproxy/proxy/proxy-detector.js.map +1 -0
  192. package/dist/cliproxy/proxy/proxy-target-resolver.d.ts.map +1 -0
  193. package/dist/cliproxy/{proxy-target-resolver.js → proxy/proxy-target-resolver.js} +7 -7
  194. package/dist/cliproxy/proxy/proxy-target-resolver.js.map +1 -0
  195. package/dist/cliproxy/proxy/tool-sanitization-proxy.d.ts.map +1 -0
  196. package/dist/cliproxy/{tool-sanitization-proxy.js → proxy/tool-sanitization-proxy.js} +6 -6
  197. package/dist/cliproxy/proxy/tool-sanitization-proxy.js.map +1 -0
  198. package/dist/cliproxy/quota/gemini-cli-quota-normalizer.d.ts.map +1 -0
  199. package/dist/cliproxy/quota/gemini-cli-quota-normalizer.js.map +1 -0
  200. package/dist/cliproxy/quota/quota-fetcher-claude-normalizer.d.ts.map +1 -0
  201. package/dist/cliproxy/{quota-fetcher-claude-normalizer.js → quota/quota-fetcher-claude-normalizer.js} +1 -1
  202. package/dist/cliproxy/quota/quota-fetcher-claude-normalizer.js.map +1 -0
  203. package/dist/cliproxy/quota/quota-fetcher-claude.d.ts.map +1 -0
  204. package/dist/cliproxy/{quota-fetcher-claude.js → quota/quota-fetcher-claude.js} +3 -3
  205. package/dist/cliproxy/quota/quota-fetcher-claude.js.map +1 -0
  206. package/dist/cliproxy/quota/quota-fetcher-codex.d.ts.map +1 -0
  207. package/dist/cliproxy/{quota-fetcher-codex.js → quota/quota-fetcher-codex.js} +4 -4
  208. package/dist/cliproxy/quota/quota-fetcher-codex.js.map +1 -0
  209. package/dist/cliproxy/quota/quota-fetcher-gemini-cli.d.ts.map +1 -0
  210. package/dist/cliproxy/{quota-fetcher-gemini-cli.js → quota/quota-fetcher-gemini-cli.js} +6 -6
  211. package/dist/cliproxy/quota/quota-fetcher-gemini-cli.js.map +1 -0
  212. package/dist/cliproxy/quota/quota-fetcher-ghcp.d.ts.map +1 -0
  213. package/dist/cliproxy/{quota-fetcher-ghcp.js → quota/quota-fetcher-ghcp.js} +2 -2
  214. package/dist/cliproxy/quota/quota-fetcher-ghcp.js.map +1 -0
  215. package/dist/cliproxy/{quota-fetcher.d.ts → quota/quota-fetcher.d.ts} +3 -3
  216. package/dist/cliproxy/quota/quota-fetcher.d.ts.map +1 -0
  217. package/dist/cliproxy/{quota-fetcher.js → quota/quota-fetcher.js} +33 -14
  218. package/dist/cliproxy/quota/quota-fetcher.js.map +1 -0
  219. package/dist/cliproxy/{quota-manager.d.ts → quota/quota-manager.d.ts} +2 -2
  220. package/dist/cliproxy/quota/quota-manager.d.ts.map +1 -0
  221. package/dist/cliproxy/{quota-manager.js → quota/quota-manager.js} +7 -7
  222. package/dist/cliproxy/quota/quota-manager.js.map +1 -0
  223. package/dist/cliproxy/quota/quota-response-cache.d.ts.map +1 -0
  224. package/dist/cliproxy/quota/quota-response-cache.js.map +1 -0
  225. package/dist/cliproxy/{quota-types.d.ts → quota/quota-types.d.ts} +1 -1
  226. package/dist/cliproxy/quota/quota-types.d.ts.map +1 -0
  227. package/dist/cliproxy/quota/quota-types.js.map +1 -0
  228. package/dist/cliproxy/{routing-strategy-http.d.ts → routing/routing-strategy-http.d.ts} +1 -1
  229. package/dist/cliproxy/routing/routing-strategy-http.d.ts.map +1 -0
  230. package/dist/cliproxy/{routing-strategy-http.js → routing/routing-strategy-http.js} +1 -1
  231. package/dist/cliproxy/routing/routing-strategy-http.js.map +1 -0
  232. package/dist/cliproxy/{routing-strategy.d.ts → routing/routing-strategy.d.ts} +1 -1
  233. package/dist/cliproxy/routing/routing-strategy.d.ts.map +1 -0
  234. package/dist/cliproxy/{routing-strategy.js → routing/routing-strategy.js} +3 -3
  235. package/dist/cliproxy/routing/routing-strategy.js.map +1 -0
  236. package/dist/cliproxy/service-manager.d.ts +3 -3
  237. package/dist/cliproxy/service-manager.d.ts.map +1 -1
  238. package/dist/cliproxy/service-manager.js +5 -5
  239. package/dist/cliproxy/service-manager.js.map +1 -1
  240. package/dist/cliproxy/services/binary-service.js +1 -1
  241. package/dist/cliproxy/services/binary-service.js.map +1 -1
  242. package/dist/cliproxy/{catalog-cache.d.ts → services/catalog-cache.d.ts} +3 -3
  243. package/dist/cliproxy/services/catalog-cache.d.ts.map +1 -0
  244. package/dist/cliproxy/{catalog-cache.js → services/catalog-cache.js} +4 -4
  245. package/dist/cliproxy/services/catalog-cache.js.map +1 -0
  246. package/dist/cliproxy/{catalog-routing.d.ts → services/catalog-routing.d.ts} +3 -3
  247. package/dist/cliproxy/services/catalog-routing.d.ts.map +1 -0
  248. package/dist/cliproxy/{catalog-routing.js → services/catalog-routing.js} +1 -1
  249. package/dist/cliproxy/services/catalog-routing.js.map +1 -0
  250. package/dist/cliproxy/services/proxy-lifecycle-service.js +1 -1
  251. package/dist/cliproxy/services/proxy-lifecycle-service.js.map +1 -1
  252. package/dist/cliproxy/{remote-auth-fetcher.d.ts → services/remote-auth-fetcher.d.ts} +2 -2
  253. package/dist/cliproxy/services/remote-auth-fetcher.d.ts.map +1 -0
  254. package/dist/cliproxy/{remote-auth-fetcher.js → services/remote-auth-fetcher.js} +2 -2
  255. package/dist/cliproxy/services/remote-auth-fetcher.js.map +1 -0
  256. package/dist/cliproxy/services/remote-proxy-client.d.ts.map +1 -0
  257. package/dist/cliproxy/{remote-proxy-client.js → services/remote-proxy-client.js} +1 -1
  258. package/dist/cliproxy/services/remote-proxy-client.js.map +1 -0
  259. package/dist/cliproxy/services/startup-lock.d.ts.map +1 -0
  260. package/dist/cliproxy/{startup-lock.js → services/startup-lock.js} +2 -2
  261. package/dist/cliproxy/services/startup-lock.js.map +1 -0
  262. package/dist/cliproxy/services/stats-fetcher.d.ts.map +1 -0
  263. package/dist/cliproxy/{stats-fetcher.js → services/stats-fetcher.js} +2 -2
  264. package/dist/cliproxy/services/stats-fetcher.js.map +1 -0
  265. package/dist/cliproxy/services/stats-transformer.d.ts.map +1 -0
  266. package/dist/cliproxy/{stats-transformer.js → services/stats-transformer.js} +3 -3
  267. package/dist/cliproxy/services/stats-transformer.js.map +1 -0
  268. package/dist/cliproxy/services/variant-config-adapter.js +1 -1
  269. package/dist/cliproxy/services/variant-config-adapter.js.map +1 -1
  270. package/dist/cliproxy/services/variant-service.js +3 -3
  271. package/dist/cliproxy/services/variant-service.js.map +1 -1
  272. package/dist/cliproxy/services/variant-settings.js +3 -3
  273. package/dist/cliproxy/services/variant-settings.js.map +1 -1
  274. package/dist/cliproxy/session-tracker.js +2 -2
  275. package/dist/cliproxy/session-tracker.js.map +1 -1
  276. package/dist/cliproxy/sync/local-config-sync.js +1 -1
  277. package/dist/cliproxy/sync/local-config-sync.js.map +1 -1
  278. package/dist/cliproxy/sync/profile-mapper.d.ts +1 -1
  279. package/dist/cliproxy/sync/profile-mapper.d.ts.map +1 -1
  280. package/dist/cliproxy/types/binary-types.d.ts +48 -0
  281. package/dist/cliproxy/types/binary-types.d.ts.map +1 -0
  282. package/dist/cliproxy/types/binary-types.js +6 -0
  283. package/dist/cliproxy/types/binary-types.js.map +1 -0
  284. package/dist/cliproxy/types/config-types.d.ts +89 -0
  285. package/dist/cliproxy/types/config-types.d.ts.map +1 -0
  286. package/dist/cliproxy/types/config-types.js +6 -0
  287. package/dist/cliproxy/types/config-types.js.map +1 -0
  288. package/dist/cliproxy/types/index.d.ts +5 -0
  289. package/dist/cliproxy/types/index.d.ts.map +1 -0
  290. package/dist/cliproxy/types/index.js +21 -0
  291. package/dist/cliproxy/types/index.js.map +1 -0
  292. package/dist/cliproxy/types/platform-types.d.ts +17 -0
  293. package/dist/cliproxy/types/platform-types.d.ts.map +1 -0
  294. package/dist/cliproxy/types/platform-types.js +6 -0
  295. package/dist/cliproxy/types/platform-types.js.map +1 -0
  296. package/dist/cliproxy/types/provider-types.d.ts +27 -0
  297. package/dist/cliproxy/types/provider-types.d.ts.map +1 -0
  298. package/dist/cliproxy/types/provider-types.js +16 -0
  299. package/dist/cliproxy/types/provider-types.js.map +1 -0
  300. package/dist/cliproxy/types.d.ts +4 -284
  301. package/dist/cliproxy/types.d.ts.map +1 -1
  302. package/dist/cliproxy/types.js +18 -14
  303. package/dist/cliproxy/types.js.map +1 -1
  304. package/dist/commands/cleanup-command.js +1 -1
  305. package/dist/commands/cleanup-command.js.map +1 -1
  306. package/dist/commands/cliproxy/auth-subcommand.js +1 -1
  307. package/dist/commands/cliproxy/auth-subcommand.js.map +1 -1
  308. package/dist/commands/cliproxy/catalog-subcommand.js +4 -4
  309. package/dist/commands/cliproxy/catalog-subcommand.js.map +1 -1
  310. package/dist/commands/cliproxy/help-subcommand.js +1 -1
  311. package/dist/commands/cliproxy/help-subcommand.js.map +1 -1
  312. package/dist/commands/cliproxy/install-subcommand.js +1 -1
  313. package/dist/commands/cliproxy/install-subcommand.js.map +1 -1
  314. package/dist/commands/cliproxy/proxy-lifecycle-subcommand.js +1 -1
  315. package/dist/commands/cliproxy/proxy-lifecycle-subcommand.js.map +1 -1
  316. package/dist/commands/cliproxy/quota-subcommand.d.ts +1 -1
  317. package/dist/commands/cliproxy/quota-subcommand.d.ts.map +1 -1
  318. package/dist/commands/cliproxy/quota-subcommand.js +8 -8
  319. package/dist/commands/cliproxy/quota-subcommand.js.map +1 -1
  320. package/dist/commands/cliproxy/routing-subcommand.js +1 -1
  321. package/dist/commands/cliproxy/routing-subcommand.js.map +1 -1
  322. package/dist/commands/cliproxy/variant-subcommand.js +4 -4
  323. package/dist/commands/cliproxy/variant-subcommand.js.map +1 -1
  324. package/dist/commands/command-catalog.d.ts.map +1 -1
  325. package/dist/commands/command-catalog.js +4 -0
  326. package/dist/commands/command-catalog.js.map +1 -1
  327. package/dist/commands/config-command.js +1 -1
  328. package/dist/commands/config-command.js.map +1 -1
  329. package/dist/commands/doctor-command.d.ts.map +1 -1
  330. package/dist/commands/doctor-command.js +9 -0
  331. package/dist/commands/doctor-command.js.map +1 -1
  332. package/dist/commands/tokens-command.js +1 -1
  333. package/dist/commands/tokens-command.js.map +1 -1
  334. package/dist/config/config-loader-facade.d.ts +57 -0
  335. package/dist/config/config-loader-facade.d.ts.map +1 -0
  336. package/dist/config/config-loader-facade.js +131 -0
  337. package/dist/config/config-loader-facade.js.map +1 -0
  338. package/dist/config/schemas/auth.d.ts +97 -0
  339. package/dist/config/schemas/auth.d.ts.map +1 -0
  340. package/dist/config/schemas/auth.js +25 -0
  341. package/dist/config/schemas/auth.js.map +1 -0
  342. package/dist/config/schemas/browser.d.ts +53 -0
  343. package/dist/config/schemas/browser.d.ts.map +1 -0
  344. package/dist/config/schemas/browser.js +27 -0
  345. package/dist/config/schemas/browser.js.map +1 -0
  346. package/dist/config/schemas/channels.d.ts +27 -0
  347. package/dist/config/schemas/channels.d.ts.map +1 -0
  348. package/dist/config/schemas/channels.js +19 -0
  349. package/dist/config/schemas/channels.js.map +1 -0
  350. package/dist/config/schemas/cliproxy.d.ts +140 -0
  351. package/dist/config/schemas/cliproxy.d.ts.map +1 -0
  352. package/dist/config/schemas/cliproxy.js +18 -0
  353. package/dist/config/schemas/cliproxy.js.map +1 -0
  354. package/dist/config/schemas/copilot-cursor.d.ts +75 -0
  355. package/dist/config/schemas/copilot-cursor.d.ts.map +1 -0
  356. package/dist/config/schemas/copilot-cursor.js +36 -0
  357. package/dist/config/schemas/copilot-cursor.js.map +1 -0
  358. package/dist/config/schemas/index.d.ts +28 -0
  359. package/dist/config/schemas/index.d.ts.map +1 -0
  360. package/dist/config/schemas/index.js +51 -0
  361. package/dist/config/schemas/index.js.map +1 -0
  362. package/dist/config/schemas/logging.d.ts +43 -0
  363. package/dist/config/schemas/logging.d.ts.map +1 -0
  364. package/dist/config/schemas/logging.js +23 -0
  365. package/dist/config/schemas/logging.js.map +1 -0
  366. package/dist/config/schemas/providers.d.ts +14 -0
  367. package/dist/config/schemas/providers.d.ts.map +1 -0
  368. package/dist/config/schemas/providers.js +21 -0
  369. package/dist/config/schemas/providers.js.map +1 -0
  370. package/dist/config/schemas/proxy-server.d.ts +141 -0
  371. package/dist/config/schemas/proxy-server.d.ts.map +1 -0
  372. package/dist/config/schemas/proxy-server.js +71 -0
  373. package/dist/config/schemas/proxy-server.js.map +1 -0
  374. package/dist/config/schemas/quota.d.ts +88 -0
  375. package/dist/config/schemas/quota.d.ts.map +1 -0
  376. package/dist/config/schemas/quota.js +47 -0
  377. package/dist/config/schemas/quota.js.map +1 -0
  378. package/dist/config/schemas/thinking.d.ts +50 -0
  379. package/dist/config/schemas/thinking.d.ts.map +1 -0
  380. package/dist/config/schemas/thinking.js +26 -0
  381. package/dist/config/schemas/thinking.js.map +1 -0
  382. package/dist/config/schemas/unified-config.d.ts +74 -0
  383. package/dist/config/schemas/unified-config.d.ts.map +1 -0
  384. package/dist/config/schemas/unified-config.js +131 -0
  385. package/dist/config/schemas/unified-config.js.map +1 -0
  386. package/dist/config/schemas/version.d.ts +23 -0
  387. package/dist/config/schemas/version.d.ts.map +1 -0
  388. package/dist/config/schemas/version.js +26 -0
  389. package/dist/config/schemas/version.js.map +1 -0
  390. package/dist/config/schemas/websearch.d.ts +138 -0
  391. package/dist/config/schemas/websearch.d.ts.map +1 -0
  392. package/dist/config/schemas/websearch.js +12 -0
  393. package/dist/config/schemas/websearch.js.map +1 -0
  394. package/dist/config/unified-config-loader.js +1 -1
  395. package/dist/config/unified-config-loader.js.map +1 -1
  396. package/dist/config/unified-config-types.d.ts +3 -818
  397. package/dist/config/unified-config-types.d.ts.map +1 -1
  398. package/dist/config/unified-config-types.js +19 -319
  399. package/dist/config/unified-config-types.js.map +1 -1
  400. package/dist/copilot/copilot-auth.d.ts.map +1 -1
  401. package/dist/copilot/copilot-auth.js +22 -0
  402. package/dist/copilot/copilot-auth.js.map +1 -1
  403. package/dist/copilot/copilot-daemon.d.ts.map +1 -1
  404. package/dist/copilot/copilot-daemon.js +26 -0
  405. package/dist/copilot/copilot-daemon.js.map +1 -1
  406. package/dist/copilot/copilot-executor.d.ts +1 -1
  407. package/dist/copilot/copilot-executor.d.ts.map +1 -1
  408. package/dist/copilot/copilot-executor.js +23 -1
  409. package/dist/copilot/copilot-executor.js.map +1 -1
  410. package/dist/cursor/cursor-daemon.d.ts.map +1 -1
  411. package/dist/cursor/cursor-daemon.js +28 -1
  412. package/dist/cursor/cursor-daemon.js.map +1 -1
  413. package/dist/cursor/cursor-executor.d.ts.map +1 -1
  414. package/dist/cursor/cursor-executor.js +17 -1
  415. package/dist/cursor/cursor-executor.js.map +1 -1
  416. package/dist/delegation/delegation-handler.d.ts.map +1 -1
  417. package/dist/delegation/delegation-handler.js +4 -1
  418. package/dist/delegation/delegation-handler.js.map +1 -1
  419. package/dist/docker/docker-bootstrap.js +1 -1
  420. package/dist/docker/docker-bootstrap.js.map +1 -1
  421. package/dist/errors/error-types.d.ts +9 -0
  422. package/dist/errors/error-types.d.ts.map +1 -1
  423. package/dist/errors/error-types.js +15 -1
  424. package/dist/errors/error-types.js.map +1 -1
  425. package/dist/errors/index.d.ts +1 -1
  426. package/dist/errors/index.d.ts.map +1 -1
  427. package/dist/errors/index.js +3 -1
  428. package/dist/errors/index.js.map +1 -1
  429. package/dist/glmt/glmt-proxy.d.ts.map +1 -1
  430. package/dist/glmt/glmt-proxy.js +7 -0
  431. package/dist/glmt/glmt-proxy.js.map +1 -1
  432. package/dist/glmt/glmt-transformer.d.ts.map +1 -1
  433. package/dist/glmt/glmt-transformer.js +1 -3
  434. package/dist/glmt/glmt-transformer.js.map +1 -1
  435. package/dist/management/checks/image-analysis-check.js +2 -2
  436. package/dist/management/checks/image-analysis-check.js.map +1 -1
  437. package/dist/management/instance-manager.d.ts.map +1 -1
  438. package/dist/management/instance-manager.js +9 -0
  439. package/dist/management/instance-manager.js.map +1 -1
  440. package/dist/management/plugin-path-normalizer.d.ts +7 -0
  441. package/dist/management/plugin-path-normalizer.d.ts.map +1 -0
  442. package/dist/management/plugin-path-normalizer.js +82 -0
  443. package/dist/management/plugin-path-normalizer.js.map +1 -0
  444. package/dist/management/shared-manager.d.ts +1 -2
  445. package/dist/management/shared-manager.d.ts.map +1 -1
  446. package/dist/management/shared-manager.js +8 -56
  447. package/dist/management/shared-manager.js.map +1 -1
  448. package/dist/proxy/server/messages-route.d.ts.map +1 -1
  449. package/dist/proxy/server/messages-route.js +50 -9
  450. package/dist/proxy/server/messages-route.js.map +1 -1
  451. package/dist/proxy/server/proxy-server.d.ts.map +1 -1
  452. package/dist/proxy/server/proxy-server.js +24 -6
  453. package/dist/proxy/server/proxy-server.js.map +1 -1
  454. package/dist/proxy/transformers/request-transformer.d.ts +1 -0
  455. package/dist/proxy/transformers/request-transformer.d.ts.map +1 -1
  456. package/dist/proxy/transformers/request-transformer.js +10 -1
  457. package/dist/proxy/transformers/request-transformer.js.map +1 -1
  458. package/dist/services/logging/index.d.ts +6 -1
  459. package/dist/services/logging/index.d.ts.map +1 -1
  460. package/dist/services/logging/index.js +16 -1
  461. package/dist/services/logging/index.js.map +1 -1
  462. package/dist/services/logging/log-context.d.ts +41 -0
  463. package/dist/services/logging/log-context.d.ts.map +1 -0
  464. package/dist/services/logging/log-context.js +51 -0
  465. package/dist/services/logging/log-context.js.map +1 -0
  466. package/dist/services/logging/log-redaction.d.ts +8 -0
  467. package/dist/services/logging/log-redaction.d.ts.map +1 -1
  468. package/dist/services/logging/log-redaction.js +40 -3
  469. package/dist/services/logging/log-redaction.js.map +1 -1
  470. package/dist/services/logging/log-types.d.ts +30 -0
  471. package/dist/services/logging/log-types.d.ts.map +1 -1
  472. package/dist/services/logging/log-types.js +15 -1
  473. package/dist/services/logging/log-types.js.map +1 -1
  474. package/dist/services/logging/logger.d.ts +17 -0
  475. package/dist/services/logging/logger.d.ts.map +1 -1
  476. package/dist/services/logging/logger.js +23 -4
  477. package/dist/services/logging/logger.js.map +1 -1
  478. package/dist/shared/claude-extension-setup.js +1 -1
  479. package/dist/shared/claude-extension-setup.js.map +1 -1
  480. package/dist/targets/claude-adapter.d.ts.map +1 -1
  481. package/dist/targets/claude-adapter.js +11 -0
  482. package/dist/targets/claude-adapter.js.map +1 -1
  483. package/dist/targets/codex-adapter.d.ts.map +1 -1
  484. package/dist/targets/codex-adapter.js +11 -0
  485. package/dist/targets/codex-adapter.js.map +1 -1
  486. package/dist/targets/droid-adapter.d.ts.map +1 -1
  487. package/dist/targets/droid-adapter.js +11 -0
  488. package/dist/targets/droid-adapter.js.map +1 -1
  489. package/dist/ui/assets/{accounts-CP_Nosd7.js → accounts-CybVGDsm.js} +1 -1
  490. package/dist/ui/assets/{alert-dialog-CjnZBDj3.js → alert-dialog-C6npAhT0.js} +1 -1
  491. package/dist/ui/assets/{api-B7mmrAjt.js → api-DZosWVkR.js} +1 -1
  492. package/dist/ui/assets/{auth-section-BFQ8Mu15.js → auth-section-D4MZkgcP.js} +1 -1
  493. package/dist/ui/assets/{backups-section-CPwm9q19.js → backups-section-DvMJrmHH.js} +1 -1
  494. package/dist/ui/assets/{channels-B2colnY7.js → channels-BVftYfOn.js} +1 -1
  495. package/dist/ui/assets/{charts-BBPXh0Ar.js → charts-CeK2xCSo.js} +1 -1
  496. package/dist/ui/assets/{checkbox-BAMXPp68.js → checkbox-BLRznRTO.js} +1 -1
  497. package/dist/ui/assets/{claude-extension-BDVoXHr-.js → claude-extension-C6OeBQ73.js} +1 -1
  498. package/dist/ui/assets/cliproxy-B3Jyu3r9.js +3 -0
  499. package/dist/ui/assets/{cliproxy-ai-providers-8dH1cHVk.js → cliproxy-ai-providers-BAJ78pUc.js} +1 -1
  500. package/dist/ui/assets/{cliproxy-control-panel-CC8HzA8e.js → cliproxy-control-panel-XEvUMVJe.js} +1 -1
  501. package/dist/ui/assets/{code-highlight-BRUf_pqB.js → code-highlight-D4E79GKQ.js} +1 -1
  502. package/dist/ui/assets/{codex-C6Q9rOwp.js → codex-CY2vikqX.js} +1 -1
  503. package/dist/ui/assets/{confirm-dialog-D0VQlM7B.js → confirm-dialog-DjLHh1qX.js} +1 -1
  504. package/dist/ui/assets/{copilot-CgG2oaRV.js → copilot-afee2lL9.js} +1 -1
  505. package/dist/ui/assets/{cursor-CE1giQU2.js → cursor-DuWy60wp.js} +1 -1
  506. package/dist/ui/assets/{droid-FG2w7nRu.js → droid-FlceoQ6k.js} +1 -1
  507. package/dist/ui/assets/{form-utils-Bcoyqxpq.js → form-utils-CuHzLhJZ.js} +1 -1
  508. package/dist/ui/assets/{globalenv-section-BJbBud4W.js → globalenv-section-DpJ7unxC.js} +1 -1
  509. package/dist/ui/assets/{health-Dh7o4wt7.js → health-BEMgcKD3.js} +1 -1
  510. package/dist/ui/assets/icons-DQFHtVq5.js +1 -0
  511. package/dist/ui/assets/{index-BNTqP5R7.js → index-0GkznW41.js} +1 -1
  512. package/dist/ui/assets/{index-B6bIHdvz.js → index-0n_43sCZ.js} +1 -1
  513. package/dist/ui/assets/index-6xrth3Oz.css +1 -0
  514. package/dist/ui/assets/{index-0mNJhDEG.js → index-BRtgic66.js} +29 -29
  515. package/dist/ui/assets/{index-Bj8UFR7b.js → index-Ba4ysocb.js} +1 -1
  516. package/dist/ui/assets/{index-BNW5qVXZ.js → index-Cj7EjEq6.js} +1 -1
  517. package/dist/ui/assets/{index-X21iqV9e.js → index-Cq9VySs6.js} +1 -1
  518. package/dist/ui/assets/{index-DTAdzUUA.js → index-DOC7_hun.js} +1 -1
  519. package/dist/ui/assets/logs-Dth4naJl.js +1 -0
  520. package/dist/ui/assets/{masked-input-DygH0M2a.js → masked-input-DL6pJ8pE.js} +1 -1
  521. package/dist/ui/assets/{notifications-B2HqRBj7.js → notifications-B4_o8bcr.js} +1 -1
  522. package/dist/ui/assets/{proxy-g4_N-fbB.js → proxy-C4-M_9kB.js} +1 -1
  523. package/dist/ui/assets/{proxy-status-widget-BWjGFUas.js → proxy-status-widget-DW4cPFeD.js} +1 -1
  524. package/dist/ui/assets/{radix-ui-Zb8sVEtn.js → radix-ui-nu4wz29m.js} +1 -1
  525. package/dist/ui/assets/{raw-json-settings-editor-panel-DYpsr-1d.js → raw-json-settings-editor-panel-Dcumu3Qi.js} +1 -1
  526. package/dist/ui/assets/{react-vendor-CNOkPC89.js → react-vendor-Bjx91N7w.js} +1 -1
  527. package/dist/ui/assets/{searchable-select-BKx31cCH.js → searchable-select-CWL2D5Ft.js} +1 -1
  528. package/dist/ui/assets/{separator-mG07scBE.js → separator-Do_vqTQD.js} +1 -1
  529. package/dist/ui/assets/{shared-hbFOfnWU.js → shared-CwWuZx24.js} +1 -1
  530. package/dist/ui/assets/{table-DoECcNZ-.js → table-BP6nBZzg.js} +1 -1
  531. package/dist/ui/assets/{tanstack-CrmUhA7Z.js → tanstack-bhJxV1h8.js} +1 -1
  532. package/dist/ui/assets/{updates-BSeFQRwL.js → updates-BTHJZ7Rk.js} +1 -1
  533. package/dist/ui/index.html +9 -9
  534. package/dist/utils/hooks/get-image-analysis-hook-env.d.ts +1 -1
  535. package/dist/utils/hooks/get-image-analysis-hook-env.d.ts.map +1 -1
  536. package/dist/utils/hooks/get-image-analysis-hook-env.js +2 -2
  537. package/dist/utils/hooks/get-image-analysis-hook-env.js.map +1 -1
  538. package/dist/utils/hooks/image-analysis-backend-resolver.js +1 -1
  539. package/dist/utils/hooks/image-analysis-backend-resolver.js.map +1 -1
  540. package/dist/utils/hooks/image-analysis-runtime-status.d.ts +4 -4
  541. package/dist/utils/hooks/image-analysis-runtime-status.d.ts.map +1 -1
  542. package/dist/utils/hooks/image-analysis-runtime-status.js +5 -5
  543. package/dist/utils/hooks/image-analysis-runtime-status.js.map +1 -1
  544. package/dist/utils/retry-strategy.d.ts +37 -0
  545. package/dist/utils/retry-strategy.d.ts.map +1 -0
  546. package/dist/utils/retry-strategy.js +99 -0
  547. package/dist/utils/retry-strategy.js.map +1 -0
  548. package/dist/web-server/health/cliproxy-checks.js +2 -2
  549. package/dist/web-server/health/cliproxy-checks.js.map +1 -1
  550. package/dist/web-server/index.js +2 -2
  551. package/dist/web-server/index.js.map +1 -1
  552. package/dist/web-server/overview-routes.js +1 -1
  553. package/dist/web-server/overview-routes.js.map +1 -1
  554. package/dist/web-server/routes/account-routes.js +1 -1
  555. package/dist/web-server/routes/account-routes.js.map +1 -1
  556. package/dist/web-server/routes/catalog-routes.js +1 -1
  557. package/dist/web-server/routes/catalog-routes.js.map +1 -1
  558. package/dist/web-server/routes/cliproxy-auth-routes.js +10 -10
  559. package/dist/web-server/routes/cliproxy-auth-routes.js.map +1 -1
  560. package/dist/web-server/routes/cliproxy-routing-routes.js +1 -1
  561. package/dist/web-server/routes/cliproxy-routing-routes.js.map +1 -1
  562. package/dist/web-server/routes/cliproxy-stats-routes.js +10 -10
  563. package/dist/web-server/routes/cliproxy-stats-routes.js.map +1 -1
  564. package/dist/web-server/routes/image-analysis-routes.js +1 -1
  565. package/dist/web-server/routes/image-analysis-routes.js.map +1 -1
  566. package/dist/web-server/routes/provider-routes.js +1 -1
  567. package/dist/web-server/routes/provider-routes.js.map +1 -1
  568. package/dist/web-server/routes/proxy-routes.js +2 -2
  569. package/dist/web-server/routes/proxy-routes.js.map +1 -1
  570. package/dist/web-server/routes/route-helpers.js +1 -1
  571. package/dist/web-server/routes/route-helpers.js.map +1 -1
  572. package/dist/web-server/routes/settings-routes.js +2 -2
  573. package/dist/web-server/routes/settings-routes.js.map +1 -1
  574. package/dist/web-server/routes/variant-routes.js +1 -1
  575. package/dist/web-server/routes/variant-routes.js.map +1 -1
  576. package/dist/web-server/services/cliproxy-dashboard-install-service.js +1 -1
  577. package/dist/web-server/services/cliproxy-dashboard-install-service.js.map +1 -1
  578. package/dist/web-server/usage/cliproxy-usage-syncer.d.ts +1 -1
  579. package/dist/web-server/usage/cliproxy-usage-syncer.d.ts.map +1 -1
  580. package/dist/web-server/usage/cliproxy-usage-syncer.js +1 -1
  581. package/dist/web-server/usage/cliproxy-usage-syncer.js.map +1 -1
  582. package/dist/web-server/usage/cliproxy-usage-transformer.d.ts +1 -1
  583. package/dist/web-server/usage/cliproxy-usage-transformer.d.ts.map +1 -1
  584. package/dist/web-server/usage/cliproxy-usage-transformer.js.map +1 -1
  585. package/dist/web-server/usage/codex-native-usage-collector.d.ts +2 -0
  586. package/dist/web-server/usage/codex-native-usage-collector.d.ts.map +1 -1
  587. package/dist/web-server/usage/codex-native-usage-collector.js +99 -1
  588. package/dist/web-server/usage/codex-native-usage-collector.js.map +1 -1
  589. package/dist/web-server/websocket.js +2 -2
  590. package/dist/web-server/websocket.js.map +1 -1
  591. package/package.json +1 -1
  592. package/scripts/run-test-bucket.js +3 -1
  593. package/dist/cliproxy/account-manager.d.ts.map +0 -1
  594. package/dist/cliproxy/account-manager.js.map +0 -1
  595. package/dist/cliproxy/account-safety.d.ts.map +0 -1
  596. package/dist/cliproxy/account-safety.js.map +0 -1
  597. package/dist/cliproxy/account-stats-key.d.ts.map +0 -1
  598. package/dist/cliproxy/account-stats-key.js.map +0 -1
  599. package/dist/cliproxy/antigravity-responsibility.d.ts.map +0 -1
  600. package/dist/cliproxy/antigravity-responsibility.js.map +0 -1
  601. package/dist/cliproxy/auth-handler.d.ts.map +0 -1
  602. package/dist/cliproxy/auth-handler.js.map +0 -1
  603. package/dist/cliproxy/auth-session-manager.d.ts.map +0 -1
  604. package/dist/cliproxy/auth-session-manager.js.map +0 -1
  605. package/dist/cliproxy/auth-token-manager.d.ts.map +0 -1
  606. package/dist/cliproxy/auth-token-manager.js.map +0 -1
  607. package/dist/cliproxy/auth-utils.d.ts.map +0 -1
  608. package/dist/cliproxy/auth-utils.js.map +0 -1
  609. package/dist/cliproxy/base-config-loader.d.ts.map +0 -1
  610. package/dist/cliproxy/base-config-loader.js.map +0 -1
  611. package/dist/cliproxy/catalog-cache.d.ts.map +0 -1
  612. package/dist/cliproxy/catalog-cache.js.map +0 -1
  613. package/dist/cliproxy/catalog-routing.d.ts.map +0 -1
  614. package/dist/cliproxy/catalog-routing.js.map +0 -1
  615. package/dist/cliproxy/cliproxy-executor.d.ts.map +0 -1
  616. package/dist/cliproxy/cliproxy-executor.js.map +0 -1
  617. package/dist/cliproxy/codex-plan-compatibility.d.ts.map +0 -1
  618. package/dist/cliproxy/codex-plan-compatibility.js.map +0 -1
  619. package/dist/cliproxy/codex-reasoning-proxy.d.ts.map +0 -1
  620. package/dist/cliproxy/codex-reasoning-proxy.js.map +0 -1
  621. package/dist/cliproxy/composite-validator.d.ts.map +0 -1
  622. package/dist/cliproxy/composite-validator.js.map +0 -1
  623. package/dist/cliproxy/config-generator.d.ts.map +0 -1
  624. package/dist/cliproxy/config-generator.js.map +0 -1
  625. package/dist/cliproxy/device-code-handler.d.ts.map +0 -1
  626. package/dist/cliproxy/device-code-handler.js.map +0 -1
  627. package/dist/cliproxy/gemini-cli-quota-normalizer.d.ts.map +0 -1
  628. package/dist/cliproxy/gemini-cli-quota-normalizer.js.map +0 -1
  629. package/dist/cliproxy/https-tunnel-proxy.d.ts.map +0 -1
  630. package/dist/cliproxy/https-tunnel-proxy.js.map +0 -1
  631. package/dist/cliproxy/managed-model-prefixes.d.ts.map +0 -1
  632. package/dist/cliproxy/managed-model-prefixes.js.map +0 -1
  633. package/dist/cliproxy/management-api-client.d.ts.map +0 -1
  634. package/dist/cliproxy/management-api-client.js.map +0 -1
  635. package/dist/cliproxy/management-api-types.d.ts.map +0 -1
  636. package/dist/cliproxy/management-api-types.js.map +0 -1
  637. package/dist/cliproxy/model-config.d.ts.map +0 -1
  638. package/dist/cliproxy/model-config.js.map +0 -1
  639. package/dist/cliproxy/model-id-normalizer.d.ts.map +0 -1
  640. package/dist/cliproxy/model-id-normalizer.js.map +0 -1
  641. package/dist/cliproxy/openai-compat-manager.d.ts.map +0 -1
  642. package/dist/cliproxy/openai-compat-manager.js.map +0 -1
  643. package/dist/cliproxy/platform-detector.d.ts.map +0 -1
  644. package/dist/cliproxy/platform-detector.js.map +0 -1
  645. package/dist/cliproxy/project-selection-handler.d.ts.map +0 -1
  646. package/dist/cliproxy/project-selection-handler.js.map +0 -1
  647. package/dist/cliproxy/provider-entitlement-evidence.d.ts.map +0 -1
  648. package/dist/cliproxy/provider-entitlement-evidence.js.map +0 -1
  649. package/dist/cliproxy/provider-entitlement-types.d.ts.map +0 -1
  650. package/dist/cliproxy/provider-entitlement-types.js.map +0 -1
  651. package/dist/cliproxy/proxy-config-resolver.d.ts.map +0 -1
  652. package/dist/cliproxy/proxy-config-resolver.js.map +0 -1
  653. package/dist/cliproxy/proxy-detector.d.ts.map +0 -1
  654. package/dist/cliproxy/proxy-detector.js.map +0 -1
  655. package/dist/cliproxy/proxy-target-resolver.d.ts.map +0 -1
  656. package/dist/cliproxy/proxy-target-resolver.js.map +0 -1
  657. package/dist/cliproxy/quota-fetcher-claude-normalizer.d.ts.map +0 -1
  658. package/dist/cliproxy/quota-fetcher-claude-normalizer.js.map +0 -1
  659. package/dist/cliproxy/quota-fetcher-claude.d.ts.map +0 -1
  660. package/dist/cliproxy/quota-fetcher-claude.js.map +0 -1
  661. package/dist/cliproxy/quota-fetcher-codex.d.ts.map +0 -1
  662. package/dist/cliproxy/quota-fetcher-codex.js.map +0 -1
  663. package/dist/cliproxy/quota-fetcher-gemini-cli.d.ts.map +0 -1
  664. package/dist/cliproxy/quota-fetcher-gemini-cli.js.map +0 -1
  665. package/dist/cliproxy/quota-fetcher-ghcp.d.ts.map +0 -1
  666. package/dist/cliproxy/quota-fetcher-ghcp.js.map +0 -1
  667. package/dist/cliproxy/quota-fetcher.d.ts.map +0 -1
  668. package/dist/cliproxy/quota-fetcher.js.map +0 -1
  669. package/dist/cliproxy/quota-manager.d.ts.map +0 -1
  670. package/dist/cliproxy/quota-manager.js.map +0 -1
  671. package/dist/cliproxy/quota-response-cache.d.ts.map +0 -1
  672. package/dist/cliproxy/quota-response-cache.js.map +0 -1
  673. package/dist/cliproxy/quota-types.d.ts.map +0 -1
  674. package/dist/cliproxy/quota-types.js.map +0 -1
  675. package/dist/cliproxy/remote-auth-fetcher.d.ts.map +0 -1
  676. package/dist/cliproxy/remote-auth-fetcher.js.map +0 -1
  677. package/dist/cliproxy/remote-proxy-client.d.ts.map +0 -1
  678. package/dist/cliproxy/remote-proxy-client.js.map +0 -1
  679. package/dist/cliproxy/remote-token-uploader.d.ts.map +0 -1
  680. package/dist/cliproxy/remote-token-uploader.js.map +0 -1
  681. package/dist/cliproxy/routing-strategy-http.d.ts.map +0 -1
  682. package/dist/cliproxy/routing-strategy-http.js.map +0 -1
  683. package/dist/cliproxy/routing-strategy.d.ts.map +0 -1
  684. package/dist/cliproxy/routing-strategy.js.map +0 -1
  685. package/dist/cliproxy/schema-sanitizer.d.ts.map +0 -1
  686. package/dist/cliproxy/schema-sanitizer.js.map +0 -1
  687. package/dist/cliproxy/startup-lock.d.ts.map +0 -1
  688. package/dist/cliproxy/startup-lock.js.map +0 -1
  689. package/dist/cliproxy/stats-fetcher.d.ts.map +0 -1
  690. package/dist/cliproxy/stats-fetcher.js.map +0 -1
  691. package/dist/cliproxy/stats-transformer.d.ts.map +0 -1
  692. package/dist/cliproxy/stats-transformer.js.map +0 -1
  693. package/dist/cliproxy/tool-name-mapper.d.ts.map +0 -1
  694. package/dist/cliproxy/tool-name-mapper.js.map +0 -1
  695. package/dist/cliproxy/tool-name-sanitizer.d.ts.map +0 -1
  696. package/dist/cliproxy/tool-name-sanitizer.js.map +0 -1
  697. package/dist/cliproxy/tool-sanitization-proxy.d.ts.map +0 -1
  698. package/dist/cliproxy/tool-sanitization-proxy.js.map +0 -1
  699. package/dist/ui/assets/cliproxy-CuLlmDu7.js +0 -3
  700. package/dist/ui/assets/icons-DyorC3Xk.js +0 -1
  701. package/dist/ui/assets/index-DM5Khyln.css +0 -1
  702. package/dist/ui/assets/logs-CxwEaeVS.js +0 -1
  703. /package/dist/cliproxy/{account-stats-key.d.ts → accounts/account-stats-key.d.ts} +0 -0
  704. /package/dist/cliproxy/{account-stats-key.js → accounts/account-stats-key.js} +0 -0
  705. /package/dist/cliproxy/{codex-reasoning-proxy.d.ts → ai-providers/codex-reasoning-proxy.d.ts} +0 -0
  706. /package/dist/cliproxy/{openai-compat-manager.d.ts → ai-providers/openai-compat-manager.d.ts} +0 -0
  707. /package/dist/cliproxy/{schema-sanitizer.d.ts → ai-providers/schema-sanitizer.d.ts} +0 -0
  708. /package/dist/cliproxy/{schema-sanitizer.js → ai-providers/schema-sanitizer.js} +0 -0
  709. /package/dist/cliproxy/{antigravity-responsibility.d.ts → auth/antigravity-responsibility.d.ts} +0 -0
  710. /package/dist/cliproxy/{auth-token-manager.d.ts → auth/auth-token-manager.d.ts} +0 -0
  711. /package/dist/cliproxy/{auth-utils.d.ts → auth/auth-utils.d.ts} +0 -0
  712. /package/dist/cliproxy/{auth-utils.js → auth/auth-utils.js} +0 -0
  713. /package/dist/cliproxy/{device-code-handler.d.ts → auth/device-code-handler.d.ts} +0 -0
  714. /package/dist/cliproxy/{device-code-handler.js → auth/device-code-handler.js} +0 -0
  715. /package/dist/cliproxy/{project-selection-handler.d.ts → auth/project-selection-handler.d.ts} +0 -0
  716. /package/dist/cliproxy/{project-selection-handler.js → auth/project-selection-handler.js} +0 -0
  717. /package/dist/cliproxy/{provider-entitlement-evidence.js → auth/provider-entitlement-evidence.js} +0 -0
  718. /package/dist/cliproxy/{provider-entitlement-types.js → auth/provider-entitlement-types.js} +0 -0
  719. /package/dist/cliproxy/{composite-validator.d.ts → config/composite-validator.d.ts} +0 -0
  720. /package/dist/cliproxy/{management-api-types.d.ts → management/management-api-types.d.ts} +0 -0
  721. /package/dist/cliproxy/{management-api-types.js → management/management-api-types.js} +0 -0
  722. /package/dist/cliproxy/{remote-token-uploader.d.ts → management/remote-token-uploader.d.ts} +0 -0
  723. /package/dist/cliproxy/{https-tunnel-proxy.d.ts → proxy/https-tunnel-proxy.d.ts} +0 -0
  724. /package/dist/cliproxy/{proxy-target-resolver.d.ts → proxy/proxy-target-resolver.d.ts} +0 -0
  725. /package/dist/cliproxy/{tool-sanitization-proxy.d.ts → proxy/tool-sanitization-proxy.d.ts} +0 -0
  726. /package/dist/cliproxy/{gemini-cli-quota-normalizer.d.ts → quota/gemini-cli-quota-normalizer.d.ts} +0 -0
  727. /package/dist/cliproxy/{gemini-cli-quota-normalizer.js → quota/gemini-cli-quota-normalizer.js} +0 -0
  728. /package/dist/cliproxy/{quota-fetcher-claude-normalizer.d.ts → quota/quota-fetcher-claude-normalizer.d.ts} +0 -0
  729. /package/dist/cliproxy/{quota-fetcher-claude.d.ts → quota/quota-fetcher-claude.d.ts} +0 -0
  730. /package/dist/cliproxy/{quota-fetcher-codex.d.ts → quota/quota-fetcher-codex.d.ts} +0 -0
  731. /package/dist/cliproxy/{quota-fetcher-gemini-cli.d.ts → quota/quota-fetcher-gemini-cli.d.ts} +0 -0
  732. /package/dist/cliproxy/{quota-fetcher-ghcp.d.ts → quota/quota-fetcher-ghcp.d.ts} +0 -0
  733. /package/dist/cliproxy/{quota-response-cache.d.ts → quota/quota-response-cache.d.ts} +0 -0
  734. /package/dist/cliproxy/{quota-response-cache.js → quota/quota-response-cache.js} +0 -0
  735. /package/dist/cliproxy/{quota-types.js → quota/quota-types.js} +0 -0
  736. /package/dist/cliproxy/{remote-proxy-client.d.ts → services/remote-proxy-client.d.ts} +0 -0
  737. /package/dist/cliproxy/{startup-lock.d.ts → services/startup-lock.d.ts} +0 -0
  738. /package/dist/cliproxy/{stats-fetcher.d.ts → services/stats-fetcher.d.ts} +0 -0
  739. /package/dist/cliproxy/{stats-transformer.d.ts → services/stats-transformer.d.ts} +0 -0
@@ -1 +1 @@
1
- import{j as e}from"./radix-ui-Zb8sVEtn.js";import{r as o}from"./react-vendor-CNOkPC89.js";import{a as Ne,bv as ke,Y as re,bi as se,bk as ne,d as C,n as we,B as m,c as g,aI as Se,I as q,r as ie,s as le,t as de,v as oe,w as z,W as l}from"./index-0mNJhDEG.js";import{R as G,w as ce,x as Ae,a8 as me,aC as Ce,A as Me,aa as Pe,at as Be,t as Re,s as _e,a9 as Ve,aL as Te}from"./icons-DyorC3Xk.js";import"./tanstack-CrmUhA7Z.js";import"./notifications-B2HqRBj7.js";import"./utils-CzKF5WmX.js";import"./form-utils-Bcoyqxpq.js";import"./code-highlight-BRUf_pqB.js";const M="__no_backend__";function ue(t){return!!t&&typeof t=="object"&&!Array.isArray(t)&&Object.values(t).every(r=>typeof r=="string")}function De(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;const r=t;return!!r.config&&typeof r.config.enabled=="boolean"&&typeof r.config.timeout=="number"&&ue(r.config.providerModels)&&(r.config.fallbackBackend===null||typeof r.config.fallbackBackend=="string")&&ue(r.config.profileBackends)&&!!r.summary&&typeof r.summary.state=="string"&&typeof r.summary.title=="string"&&typeof r.summary.detail=="string"&&Array.isArray(r.backends)&&Array.isArray(r.profiles)&&!!r.catalog&&Array.isArray(r.catalog.knownBackends)&&Array.isArray(r.catalog.profileNames)&&typeof r.summary.nativeProfileCount=="number"}function Ie(t){return Object.entries(t).sort(([r],[s])=>r.localeCompare(s)).map(([r,s],x)=>({id:`${r}-${s}-${x}`,profileName:r,backendId:s}))}function Ee(t){switch(t){case"ready":return"border-emerald-500/25 bg-emerald-500/10 text-emerald-900 dark:text-emerald-200";case"partial":return"border-amber-500/25 bg-amber-500/10 text-amber-900 dark:text-amber-200";case"needs_setup":return"border-rose-500/25 bg-rose-500/10 text-rose-900 dark:text-rose-200";case"disabled":return"border-border/80 bg-background/85 text-muted-foreground"}}function $e(t){switch(t){case"ready":return"border-emerald-500/25 bg-emerald-500/10 text-emerald-800 dark:text-emerald-200";case"starts_on_launch":return"border-sky-500/25 bg-sky-500/10 text-sky-800 dark:text-sky-200";case"needs_auth":return"border-rose-500/25 bg-rose-500/10 text-rose-800 dark:text-rose-200";case"needs_proxy":return"border-amber-500/25 bg-amber-500/10 text-amber-800 dark:text-amber-200";case"review":return"border-border/80 bg-background/85 text-muted-foreground"}}function ge(t){switch(t){case"active":return l.t("imageAnalysisStatus.badgeReady");case"bypassed":return l.t("imageAnalysisStatus.badgeBypassed");case"fallback":return l.t("imageAnalysisStatus.nativeFallback");case"setup":return l.t("imageAnalysisStatus.badgeSetup");case"disabled":return l.t("imageAnalysisStatus.badgeDisabled");case"native":return l.t("imageAnalysisStatus.badgeNative");case"unresolved":return l.t("imageAnalysisStatus.nativeImageReading")}}function xe(t){switch(t){case"active":return"border-emerald-500/25 bg-emerald-500/10 text-emerald-800 dark:text-emerald-200";case"bypassed":return"border-sky-500/25 bg-sky-500/10 text-sky-800 dark:text-sky-200";case"fallback":case"setup":return"border-amber-500/25 bg-amber-500/10 text-amber-800 dark:text-amber-200";case"native":return"border-emerald-500/25 bg-emerald-500/10 text-emerald-800 dark:text-emerald-200";case"disabled":case"unresolved":return"border-border/80 bg-background/85 text-muted-foreground"}}function Fe(t){switch(t){case"starts_on_launch":return l.t("imageAnalysisSection.backendStartsOnLaunch",{defaultValue:"Starts on launch"});case"needs_auth":return l.t("imageAnalysisStatus.needsAuth");case"needs_proxy":return l.t("imageAnalysisStatus.needsProxy");case"review":return l.t("imageAnalysisSection.review",{defaultValue:"Review"});case"ready":return l.t("imageAnalysisStatus.badgeReady")}}function Oe(t){if(!t)return l.t("imageAnalysisSection.noModelConfigured",{defaultValue:"No model configured."});switch(t.state){case"needs_auth":return t.authReason||l.t("imageAnalysisSection.authenticateToRoute",{defaultValue:"Authenticate to route here."});case"needs_proxy":return t.proxyReason||l.t("imageAnalysisSection.proxyUnavailable",{defaultValue:"Proxy unavailable."});case"starts_on_launch":return l.t("imageAnalysisSection.authReadyLaunchesLocally",{defaultValue:"Auth ready. Launches locally on demand."});case"review":return l.t("imageAnalysisSection.needsManualReview",{defaultValue:"Needs manual review."});case"ready":return null}}function ze(t){switch(t){case"profile-backend":return l.t("imageAnalysisSection.explicitMapping",{defaultValue:"Explicit mapping"});case"fallback-backend":return l.t("imageAnalysisSection.fallbackBackend",{defaultValue:"Fallback backend"});case"cliproxy-provider":return l.t("imageAnalysisSection.providerMatch",{defaultValue:"Provider match"});case"cliproxy-bridge":return l.t("imageAnalysisSection.bridgeMatch",{defaultValue:"Bridge match"});case"native-compatible":return l.t("imageAnalysisSection.nativePath",{defaultValue:"Native path"});case"copilot-alias":return l.t("imageAnalysisSection.copilotAlias",{defaultValue:"Copilot alias"});default:return t.replace(/-/g," ")}}function k(t){return"border-border/50 bg-background/40"}function Le(t){switch(t){case"ready":return"bg-[linear-gradient(90deg,rgba(16,185,129,0.08),transparent_18%),linear-gradient(180deg,rgba(255,255,255,0.72),rgba(255,255,255,0.46))] dark:bg-[linear-gradient(90deg,rgba(16,185,129,0.12),transparent_18%),linear-gradient(180deg,rgba(15,23,42,0.82),rgba(15,23,42,0.56))]";case"starts_on_launch":return"bg-[linear-gradient(90deg,rgba(14,165,233,0.08),transparent_18%),linear-gradient(180deg,rgba(255,255,255,0.72),rgba(255,255,255,0.46))] dark:bg-[linear-gradient(90deg,rgba(14,165,233,0.12),transparent_18%),linear-gradient(180deg,rgba(15,23,42,0.82),rgba(15,23,42,0.56))]";case"needs_auth":return"bg-[linear-gradient(90deg,rgba(244,63,94,0.08),transparent_18%),linear-gradient(180deg,rgba(255,255,255,0.72),rgba(255,255,255,0.46))] dark:bg-[linear-gradient(90deg,rgba(244,63,94,0.12),transparent_18%),linear-gradient(180deg,rgba(15,23,42,0.82),rgba(15,23,42,0.56))]";case"needs_proxy":return"bg-[linear-gradient(90deg,rgba(245,158,11,0.08),transparent_18%),linear-gradient(180deg,rgba(255,255,255,0.72),rgba(255,255,255,0.46))] dark:bg-[linear-gradient(90deg,rgba(245,158,11,0.12),transparent_18%),linear-gradient(180deg,rgba(15,23,42,0.82),rgba(15,23,42,0.56))]";case"review":default:return"bg-[linear-gradient(180deg,rgba(255,255,255,0.74),rgba(255,255,255,0.5))] dark:bg-[linear-gradient(180deg,rgba(15,23,42,0.8),rgba(15,23,42,0.58))]"}}function Ke(t){switch(t){case"ready":return"from-emerald-500 to-emerald-400/30";case"starts_on_launch":return"from-sky-500 to-sky-400/30";case"needs_auth":return"from-rose-500 to-rose-400/30";case"needs_proxy":return"from-amber-500 to-amber-400/30";case"review":default:return"from-slate-400 to-slate-300/20"}}function Ue(t,r){return r.nativeReadPreference?t%2===0?"bg-emerald-500/[0.06]":"bg-emerald-500/[0.08]":t%2===0?"bg-background/75":"bg-muted/18"}function He(t){const r=[`${t.activeProfileCount} routed`,`${t.nativeProfileCount} native`];return t.mappedProfileCount>0&&r.push(`${t.mappedProfileCount} override${t.mappedProfileCount===1?"":"s"}`),r.join(" · ")}function Je(t){return Object.entries(t).reduce((r,[s,x])=>{const h=x.trim();return r[s]=h||null,r},{})}function W(t){return Object.entries(t).filter(([,r])=>r.trim().length>0).map(([r])=>r)}function qe(t){return t.reduce((r,s)=>{const x=s.profileName.trim();return!x||!s.backendId||(r[x]=s.backendId),r},{})}function pe(t,r){const s=Number.parseInt(t.trim(),10);return Number.isInteger(s)?String(Math.min(600,Math.max(10,s))):r}function T({title:t,description:r,icon:s,meta:x,action:h,children:D,className:c}){return e.jsxs("div",{className:g("relative overflow-hidden rounded-2xl border bg-gradient-to-br from-background via-background to-muted/25 p-4 shadow-sm",c),children:[e.jsx("div",{className:"absolute inset-x-0 top-0 h-px bg-gradient-to-r from-primary/40 via-primary/10 to-transparent"}),e.jsxs("div",{className:"relative space-y-4",children:[e.jsxs("div",{className:"flex flex-col gap-3 md:flex-row md:items-start md:justify-between",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"inline-flex h-9 w-9 shrink-0 items-center justify-center rounded-xl border border-primary/20 bg-primary/10 text-primary",children:s}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("h3",{className:"text-base font-semibold tracking-tight",children:t}),x]}),e.jsx("p",{className:"mt-0.5 text-sm leading-5 text-muted-foreground",children:r})]})]}),h&&e.jsx("div",{className:"shrink-0",children:h})]}),e.jsx("div",{className:"space-y-3",children:D})]})]})}function ra(){const{t}=Ne(),{fetchRawConfig:r}=ke(),[s,x]=o.useState(null),[h,D]=o.useState(!0),[c,Y]=o.useState(!1),[I,N]=o.useState(null),[P,L]=o.useState(null),[E,Q]=o.useState(!1),[B,X]=o.useState(!0),[K,U]=o.useState("60"),[v,R]=o.useState(""),[w,$]=o.useState({}),[p,F]=o.useState([]),S=o.useCallback(a=>{X(a.config.enabled),U(String(a.config.timeout)),R(a.config.fallbackBackend??""),$(a.catalog.knownBackends.reduce((n,i)=>(n[i]=a.config.providerModels[i]??"",n),{})),F(Ie(a.config.profileBackends))},[]),H=o.useCallback(async()=>{try{D(!0),N(null);const a=await re.imageAnalysis.get();if(!De(a))throw new Error("Image settings returned an unexpected response. Restart the dashboard server so the new API route is available.");x(a),S(a)}catch(a){N(a instanceof Error?a.message:"Failed to load image settings.")}finally{D(!1)}},[S]);o.useEffect(()=>{H(),r()},[H,r]),o.useEffect(()=>{if(!P)return;const a=window.setTimeout(()=>L(null),2500);return()=>window.clearTimeout(a)},[P]),o.useEffect(()=>{s&&Object.keys(s.config.profileBackends).length>0&&Q(!0)},[s]);const u=o.useMemo(()=>W(w),[w]),Z=o.useMemo(()=>{if(!s)return[];const a=s.catalog.knownBackends.filter(i=>u.includes(i)),n=s.catalog.knownBackends.filter(i=>!u.includes(i));return[...a,...n]},[u,s]),O=o.useMemo(()=>s?.profiles.filter(a=>a.nativeReadPreference)??[],[s]);o.useEffect(()=>{if(u.length===0){R("");return}u.includes(v)||R(u[0])},[u,v]);const _=o.useCallback(async a=>{if(!s)return!1;const n=a?.enabled??B,i=a?.providerModels??w,d=W(i),b=pe(a?.timeout??K,String(s.config.timeout)),y=a?.fallbackBackend??v,A=d.length===0?"":d.includes(y)?y:d[0],f=a?.mappingDrafts??p,V={enabled:n,timeout:b,fallbackBackend:A,providerModels:Je(i),profileBackends:qe(f)},je={enabled:s.config.enabled,timeout:String(s.config.timeout),fallbackBackend:s.config.fallbackBackend??"",providerModels:s.catalog.knownBackends.reduce((j,te)=>(j[te]=s.config.providerModels[te]??null,j),{}),profileBackends:s.config.profileBackends};if(JSON.stringify(V)===JSON.stringify(je))return!0;if(n&&d.length===0)return N("Keep at least one provider model configured, or disable Image globally."),S(s),!1;try{Y(!0),N(null);const j=await re.imageAnalysis.update({enabled:n,timeout:Number.parseInt(b,10),fallbackBackend:A||null,providerModels:V.providerModels,profileBackends:V.profileBackends});return x(j),S(j),L(t("commonToast.settingsSaved")),await r(),!0}catch(j){return N(j instanceof Error?j.message:"Failed to save image settings."),S(s),!1}finally{Y(!1)}},[s,B,v,r,S,p,w,t,K]),ee=async()=>{h||c||(L(null),await Promise.all([H(),r()]))},be=async a=>{if(!c){if(a&&u.length===0){N("Keep at least one provider model configured, or disable Image globally.");return}X(a),await _({enabled:a})}},fe=async a=>{if(!s||c)return;const n=pe(a,String(s.config.timeout));U(n),await _({timeout:n})},he=async a=>{c||(R(a),await _({fallbackBackend:a}))},ae=async(a,n)=>{if(!s||c)return;const i=n.trim(),d={...w,[a]:i},b=W(d);if(B&&b.length===0){N("Disable Image first or keep one backend configured."),$(A=>({...A,[a]:s.config.providerModels[a]??""}));return}const y=b.length===0?"":b.includes(v)?v:b[0];$(d),R(y),await _({providerModels:d,fallbackBackend:y})},ve=(a,n)=>{F(i=>i.map(d=>d.id===a?{...d,...n}:d))},J=async a=>{c||(F(a),await _({mappingDrafts:a}))},ye=p.filter(a=>a.profileName.trim()&&a.backendId).length;return h?e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsxs("div",{className:"flex items-center gap-3 text-muted-foreground",children:[e.jsx(G,{className:"w-5 h-5 animate-spin"}),e.jsx("span",{children:t("settingsPage.imageAnalysisSection.loading")})]})}):s?e.jsxs("div",{className:"relative flex min-h-0 flex-1 flex-col",children:[e.jsxs("div",{className:`absolute left-5 right-5 top-20 z-10 transition-all duration-200 ease-out ${I||P?"translate-y-0 opacity-100":"pointer-events-none -translate-y-2 opacity-0"}`,children:[I&&e.jsxs(se,{variant:"destructive",className:"py-2 shadow-lg",children:[e.jsx(ce,{className:"h-4 w-4"}),e.jsx(ne,{children:I})]}),P&&e.jsxs("div",{className:"flex items-center gap-2 rounded-md border border-green-200 bg-green-50 px-3 py-2 text-green-700 shadow-lg dark:border-green-900/50 dark:bg-green-900/90 dark:text-green-300",children:[e.jsx(Ae,{className:"h-4 w-4 shrink-0"}),e.jsx("span",{className:"text-sm font-medium",children:P})]})]}),e.jsx(we,{className:"min-h-0 flex-1",children:e.jsxs("div",{className:"space-y-6 p-5",children:[e.jsxs("div",{className:"relative overflow-hidden rounded-2xl border bg-gradient-to-br from-background via-background to-muted/30 p-4 shadow-sm",children:[e.jsx("div",{className:"absolute inset-x-0 top-0 h-px bg-gradient-to-r from-primary/70 via-primary/20 to-transparent"}),e.jsx("div",{className:"pointer-events-none absolute inset-0 opacity-[0.035]",style:{backgroundImage:"repeating-linear-gradient(0deg, transparent, transparent 2px, currentColor 2px, currentColor 3px)"}}),e.jsxs("div",{className:"relative",children:[e.jsxs("div",{className:"mb-3 flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"inline-flex h-8 w-8 items-center justify-center rounded-xl border border-primary/20 bg-primary/8 text-primary",children:e.jsx(me,{className:"h-4 w-4"})}),e.jsx("p",{className:"text-sm font-semibold tracking-tight",children:t("settingsPage.imageAnalysisSection.title")})]}),e.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(m,{className:g("border",Ee(s.summary.state)),children:s.summary.title}),e.jsx("span",{children:He(s.summary)})]})]}),e.jsx(C,{variant:"ghost",size:"sm",onClick:ee,disabled:h||c,"aria-label":"Refresh",title:"Refresh",children:e.jsx(G,{className:`h-4 w-4 ${h?"animate-spin":""}`})})]}),e.jsxs("div",{className:"mt-3 grid gap-2 sm:grid-cols-2",children:[e.jsxs("div",{className:"rounded-[18px] border bg-background/72 px-3 py-2.5 backdrop-blur-sm",children:[e.jsx("div",{className:"text-[10px] font-medium uppercase tracking-[0.14em] text-muted-foreground",children:"Active routes"}),e.jsx("div",{className:"mt-1.5 text-xl font-semibold text-foreground",children:s.summary.activeProfileCount}),e.jsx("p",{className:"mt-0.5 text-[11px] text-muted-foreground",children:"Current target path"})]}),e.jsxs("div",{className:"rounded-[18px] border bg-background/72 px-3 py-2.5 backdrop-blur-sm",children:[e.jsx("div",{className:"text-[10px] font-medium uppercase tracking-[0.14em] text-muted-foreground",children:"Native path"}),e.jsx("div",{className:"mt-1.5 text-xl font-semibold text-foreground",children:s.summary.nativeProfileCount}),e.jsx("p",{className:"mt-0.5 text-[11px] text-muted-foreground",children:"Skip transformer"})]})]})]})]}),e.jsxs(T,{tone:"amber",eyebrow:"Control deck",title:"Core setup",description:t("settingsPage.imageAnalysisSection.description"),icon:e.jsx(Ce,{className:"h-4 w-4"}),meta:e.jsxs(m,{variant:"outline",className:"border-amber-500/25 bg-amber-500/10 text-[10px]",children:[u.length," configured"]}),children:[e.jsxs("div",{className:"grid gap-2 lg:grid-cols-3",children:[e.jsxs("div",{className:g("rounded-[18px] border px-3.5 py-3 shadow-sm",k()),children:[e.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-[0.14em] text-amber-700/75 dark:text-amber-300/75",children:"Enabled"}),e.jsxs("div",{className:"mt-2.5 flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx("div",{className:"text-sm font-semibold text-foreground",children:B?"Transformer on":"Transformer off"}),e.jsx("p",{className:"text-[11px] leading-4 text-muted-foreground",children:"Profile flags stay untouched."})]}),e.jsx(Se,{checked:B,onCheckedChange:a=>{be(a)},disabled:c})]})]}),e.jsxs("div",{className:g("rounded-[18px] border px-3.5 py-3 shadow-sm",k()),children:[e.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-[0.14em] text-amber-700/75 dark:text-amber-300/75",children:"Timeout"}),e.jsxs("div",{className:"mt-2.5 flex items-center gap-2",children:[e.jsx(q,{value:K,onChange:a=>U(a.target.value),inputMode:"numeric",className:"h-10 border-amber-500/15 bg-background/90 text-base",disabled:c,onBlur:a=>{fe(a.currentTarget.value)},onKeyDown:a=>{a.key==="Enter"&&a.currentTarget.blur()}}),e.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:"sec"})]}),e.jsx("p",{className:"mt-1.5 text-[11px] leading-4 text-muted-foreground",children:"Keeps large reads from hanging."})]}),e.jsxs("div",{className:g("rounded-[18px] border px-3.5 py-3 shadow-sm",k()),children:[e.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-[0.14em] text-amber-700/75 dark:text-amber-300/75",children:"Fallback backend"}),e.jsx("div",{className:"mt-2.5",children:e.jsxs(ie,{value:v||M,onValueChange:a=>{he(a===M?"":a)},disabled:c,children:[e.jsx(le,{className:"h-10 border-amber-500/15 bg-background/90",children:e.jsx(de,{placeholder:t("settingsPage.thinkingSection.configureModelFirst")})}),e.jsx(oe,{children:u.length===0?e.jsx(z,{value:M,children:t("settingsPage.thinkingSection.configureModelFirst")}):u.map(a=>e.jsx(z,{value:a,children:a},a))})]})}),e.jsx("p",{className:"mt-1.5 text-[11px] leading-4 text-muted-foreground",children:"Used when no direct route exists."})]})]}),e.jsxs("div",{className:"mt-3 flex flex-wrap gap-1.5",children:[e.jsxs("div",{className:"rounded-full border border-amber-500/15 bg-background/80 px-2.5 py-1 text-[11px] text-muted-foreground",children:[ye," overrides"]}),e.jsxs("div",{className:"rounded-full border border-amber-500/15 bg-background/80 px-2.5 py-1 text-[11px] text-muted-foreground",children:[O.length," native"]}),e.jsxs("div",{className:"rounded-full border border-amber-500/15 bg-background/80 px-2.5 py-1 text-[11px] text-muted-foreground",children:[v||"No fallback"," fallback"]})]})]}),e.jsx(T,{tone:"cyan",eyebrow:"Route inventory",title:"Backend routes",description:"Model entry plus route health.",icon:e.jsx(Me,{className:"h-4 w-4"}),meta:e.jsxs(m,{variant:"outline",className:"border-cyan-500/25 bg-cyan-500/10 text-[10px]",children:[Z.length," backends"]}),children:e.jsx("div",{className:"overflow-hidden rounded-[20px] border border-cyan-500/12 bg-background/65 shadow-sm backdrop-blur-sm",children:Z.map((a,n)=>{const i=s.backends.find(f=>f.backendId===a),d=i?.displayName||a,b=w[a]??"",y=Oe(i),A=b?[`${i?.profilesUsing??0} active`,i?.authReadiness==="missing"?"auth missing":i?.proxyReadiness==="stopped"?"starts on launch":null].filter(Boolean).join(" · "):"No model configured.";return e.jsxs("div",{className:g("relative px-3 py-3 md:px-4",n>0&&"border-t border-cyan-500/10",Le(i?.state)),children:[e.jsx("div",{className:g("absolute bottom-3 left-0 top-3 w-1 rounded-r-full bg-gradient-to-b",Ke(i?.state))}),e.jsxs("div",{className:"pl-2.5",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("h4",{className:"text-sm font-semibold text-foreground",children:d}),e.jsx(m,{variant:"outline",className:"font-mono text-[10px]",children:a}),i?.profilesUsing?e.jsxs(m,{variant:"outline",className:"border-cyan-500/20 bg-cyan-500/10 text-[10px]",children:[i.profilesUsing," active"]}):null]}),e.jsx("p",{className:"mt-0.5 text-[11px] leading-4 text-muted-foreground",children:A})]}),e.jsx(m,{className:g("border",i?$e(i.state):"border-border/80 bg-background/85 text-muted-foreground"),children:i?Fe(i.state):"Inactive"})]}),e.jsxs("div",{className:"mt-2 flex flex-col gap-2 sm:flex-row",children:[e.jsx(q,{className:"h-10 flex-1 border-cyan-500/15 bg-background/88 text-base",placeholder:t("imageAnalysisSection.setModel",{defaultValue:"Set model"}),value:b,disabled:c,onChange:f=>$(V=>({...V,[a]:f.target.value})),onBlur:f=>{ae(a,f.currentTarget.value)},onKeyDown:f=>{f.key==="Enter"&&f.currentTarget.blur()}}),b.trim().length>0&&e.jsx(C,{type:"button",variant:"outline",size:"sm",className:"h-10 sm:self-stretch",disabled:c,onClick:()=>{ae(a,"")},children:t("common.clear",{defaultValue:"Clear"})})]}),y&&e.jsx("p",{className:"mt-1.5 text-[11px] leading-4 text-muted-foreground",children:y})]})]},a)})})}),e.jsx(T,{tone:"emerald",eyebrow:"Native path",title:"Native reading",description:"Profiles that skip the transformer.",icon:e.jsx(Pe,{className:"h-4 w-4"}),meta:e.jsxs(m,{variant:"outline",children:[O.length," profiles"]}),children:O.length===0?e.jsx("div",{className:g("rounded-[18px] border border-dashed px-3.5 py-3.5 text-sm text-muted-foreground",k()),children:t("imageAnalysisSection.noProfilesPreferNative",{defaultValue:"No profiles prefer native reading yet."})}):e.jsx("div",{className:"grid gap-2 md:grid-cols-2",children:O.map(a=>e.jsx("div",{className:g("rounded-[18px] border px-3.5 py-3 shadow-sm",k()),children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("div",{className:"truncate text-sm font-semibold text-foreground",children:a.name}),e.jsx(m,{variant:"outline",className:"text-[10px]",children:a.kind==="variant"?t("cliproxyPage.variant"):t("apiProfiles.title")}),e.jsx(m,{variant:"outline",className:"text-[10px]",children:a.nativeImageCapable?t("imageAnalysisStatus.capabilityVerified"):t("imageAnalysisSection.review",{defaultValue:"Review"})})]}),e.jsxs("div",{className:"mt-1 text-[11px] leading-4 text-muted-foreground",children:[a.profileModel||t("imageAnalysisSection.modelNotDetected",{defaultValue:"Model not detected"})," ","·"," ",a.nativeImageReason||t("imageAnalysisSection.nativeReadPreferred",{defaultValue:"Native read preferred."})]})]}),e.jsx(m,{className:g("border",xe(a.currentTargetMode)),children:ge(a.currentTargetMode)})]})},`native-${a.kind}-${a.name}`))})}),e.jsxs(T,{tone:"slate",eyebrow:"Override lab",title:"Profile routing",description:"Only for explicit route overrides.",icon:e.jsx(Te,{className:"h-4 w-4"}),meta:e.jsx(m,{variant:"outline",className:"border-amber-500/25 bg-amber-500/10 text-[10px] text-amber-800 dark:text-amber-200",children:"Advanced"}),action:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(C,{type:"button",variant:"outline",size:"sm",onClick:()=>Q(a=>!a),children:[E?e.jsx(Re,{className:"mr-1 h-4 w-4"}):e.jsx(_e,{className:"mr-1 h-4 w-4"}),E?t("common.hide",{defaultValue:"Hide"}):t("common.show",{defaultValue:"Show"})]}),E&&e.jsxs(C,{type:"button",variant:"outline",size:"sm",onClick:()=>F(a=>[...a,{id:`mapping-${Date.now()}`,profileName:"",backendId:u[0]??""}]),disabled:u.length===0||c,children:[e.jsx(Ve,{className:"mr-1 h-4 w-4"}),t("imageAnalysisSection.addMapping",{defaultValue:"Add mapping"})]})]}),className:"border-dashed",children:[e.jsx("datalist",{id:"image-profile-suggestions",children:s.catalog.profileNames.map(a=>e.jsx("option",{value:a},a))}),E?e.jsx("div",{className:"space-y-2",children:p.length===0?e.jsx("div",{className:g("rounded-[18px] border border-dashed px-3.5 py-3.5 text-sm text-muted-foreground",k()),children:"No explicit overrides saved."}):e.jsx("div",{className:"space-y-2",children:p.map(a=>e.jsxs("div",{className:"rounded-[18px] border border-slate-400/20 bg-[linear-gradient(180deg,rgba(255,255,255,0.72),rgba(248,250,252,0.52))] p-3 shadow-sm dark:bg-[linear-gradient(180deg,rgba(15,23,42,0.84),rgba(15,23,42,0.56))]",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-[11px] leading-4 text-muted-foreground",children:[e.jsx("span",{children:t("imageAnalysisSection.directOverride",{defaultValue:"Direct override"})}),!(a.profileName.trim()&&a.backendId)&&e.jsx(m,{variant:"outline",className:"text-[10px]",children:"Draft"})]}),e.jsxs(C,{type:"button",variant:"ghost",size:"sm",disabled:c,onClick:()=>{const n=p.filter(i=>i.id!==a.id);J(n)},children:[e.jsx(Be,{className:"mr-1 h-4 w-4"}),t("common.remove",{defaultValue:"Remove"})]})]}),e.jsxs("div",{className:"mt-2 grid gap-2 sm:grid-cols-2",children:[e.jsx(q,{value:a.profileName,list:"image-profile-suggestions",disabled:c,placeholder:t("imageAnalysisSection.profileOrVariantName",{defaultValue:"Profile or variant name"}),className:"h-10 border-slate-400/15 bg-background/88 text-base",onChange:n=>{ve(a.id,{profileName:n.target.value})},onBlur:n=>{const i=p.map(d=>d.id===a.id?{...d,profileName:n.currentTarget.value.trim()}:d);J(i)},onKeyDown:n=>{n.key==="Enter"&&n.currentTarget.blur()}}),e.jsxs(ie,{value:a.backendId||M,disabled:c,onValueChange:n=>{const i=p.map(d=>d.id===a.id?{...d,backendId:n===M?"":n}:d);J(i)},children:[e.jsx(le,{className:"h-10 border-slate-400/15 bg-background/88",children:e.jsx(de,{placeholder:t("settingsPage.thinkingSection.configureModelFirst")})}),e.jsx(oe,{children:u.length===0?e.jsx(z,{value:M,children:t("settingsPage.thinkingSection.configureModelFirst")}):u.map(n=>e.jsx(z,{value:n,children:n},n))})]})]})]},a.id))})}):e.jsxs("div",{className:g("rounded-[18px] border border-dashed px-3.5 py-3 text-sm text-muted-foreground",k()),children:["Hidden by default.",p.length>0?` ${p.length} override${p.length===1?"":"s"} saved.`:" No overrides saved."]})]}),e.jsx(T,{tone:"slate",eyebrow:"Audit view",title:"Coverage",description:"Read-only routing ledger for the current path.",icon:e.jsx(me,{className:"h-4 w-4"}),meta:e.jsxs(m,{variant:"outline",children:[s.profiles.length," profiles"]}),children:e.jsx("div",{className:"overflow-hidden rounded-[20px] border border-slate-400/15 bg-background/75 shadow-sm backdrop-blur-sm",children:s.profiles.map((a,n)=>e.jsxs("div",{className:g("grid gap-2 px-3.5 py-2.5 md:grid-cols-[minmax(0,1fr)_auto] md:items-center",n>0&&"border-t border-slate-400/12",Ue(n,a)),children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("div",{className:"truncate text-sm font-semibold text-foreground",children:a.name}),e.jsx(m,{variant:"outline",className:"text-[10px]",children:a.kind==="variant"?t("cliproxyPage.variant"):t("apiProfiles.title")}),e.jsx(m,{variant:"outline",className:"font-mono text-[10px] uppercase",children:a.target}),a.nativeReadPreference&&e.jsx(m,{variant:"outline",className:"border-emerald-500/20 bg-emerald-500/10 text-[10px]",children:"Native"})]}),e.jsxs("div",{className:"mt-0.5 text-[11px] leading-4 text-muted-foreground",children:[a.backendDisplayName||a.profileModel||"Native file access"," ·"," ",ze(a.resolutionSource)]})]}),e.jsxs("div",{className:"flex items-center gap-2 md:justify-end",children:[a.profileModel&&e.jsx(m,{variant:"outline",className:"font-mono text-[10px]",children:a.profileModel}),e.jsx(m,{className:g("border",xe(a.currentTargetMode)),children:ge(a.currentTargetMode)})]})]},`${a.kind}-${a.name}`))})})]})})]}):e.jsxs("div",{className:"p-5",children:[e.jsxs(se,{variant:"destructive",children:[e.jsx(ce,{className:"h-4 w-4"}),e.jsx(ne,{children:I??t("settingsPage.imageAnalysisSection.description")})]}),e.jsx("div",{className:"mt-4",children:e.jsxs(C,{variant:"outline",size:"sm",onClick:ee,children:[e.jsx(G,{className:"mr-1 h-4 w-4"}),t("sharedPage.retry")]})})]})}export{ra as default};
1
+ import{j as e}from"./radix-ui-nu4wz29m.js";import{r as o}from"./react-vendor-Bjx91N7w.js";import{a as Ne,bA as ke,Y as re,bi as se,bk as ne,d as C,n as we,B as m,c as g,aI as Se,I as q,r as ie,s as le,t as de,v as oe,w as z,W as l}from"./index-BRtgic66.js";import{R as G,w as ce,x as Ae,a8 as me,aC as Ce,A as Me,aa as Pe,at as Be,t as Re,s as _e,a9 as Ve,aL as Te}from"./icons-DQFHtVq5.js";import"./tanstack-bhJxV1h8.js";import"./notifications-B4_o8bcr.js";import"./utils-CzKF5WmX.js";import"./form-utils-CuHzLhJZ.js";import"./code-highlight-D4E79GKQ.js";const M="__no_backend__";function ue(t){return!!t&&typeof t=="object"&&!Array.isArray(t)&&Object.values(t).every(r=>typeof r=="string")}function De(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;const r=t;return!!r.config&&typeof r.config.enabled=="boolean"&&typeof r.config.timeout=="number"&&ue(r.config.providerModels)&&(r.config.fallbackBackend===null||typeof r.config.fallbackBackend=="string")&&ue(r.config.profileBackends)&&!!r.summary&&typeof r.summary.state=="string"&&typeof r.summary.title=="string"&&typeof r.summary.detail=="string"&&Array.isArray(r.backends)&&Array.isArray(r.profiles)&&!!r.catalog&&Array.isArray(r.catalog.knownBackends)&&Array.isArray(r.catalog.profileNames)&&typeof r.summary.nativeProfileCount=="number"}function Ie(t){return Object.entries(t).sort(([r],[s])=>r.localeCompare(s)).map(([r,s],x)=>({id:`${r}-${s}-${x}`,profileName:r,backendId:s}))}function Ee(t){switch(t){case"ready":return"border-emerald-500/25 bg-emerald-500/10 text-emerald-900 dark:text-emerald-200";case"partial":return"border-amber-500/25 bg-amber-500/10 text-amber-900 dark:text-amber-200";case"needs_setup":return"border-rose-500/25 bg-rose-500/10 text-rose-900 dark:text-rose-200";case"disabled":return"border-border/80 bg-background/85 text-muted-foreground"}}function $e(t){switch(t){case"ready":return"border-emerald-500/25 bg-emerald-500/10 text-emerald-800 dark:text-emerald-200";case"starts_on_launch":return"border-sky-500/25 bg-sky-500/10 text-sky-800 dark:text-sky-200";case"needs_auth":return"border-rose-500/25 bg-rose-500/10 text-rose-800 dark:text-rose-200";case"needs_proxy":return"border-amber-500/25 bg-amber-500/10 text-amber-800 dark:text-amber-200";case"review":return"border-border/80 bg-background/85 text-muted-foreground"}}function ge(t){switch(t){case"active":return l.t("imageAnalysisStatus.badgeReady");case"bypassed":return l.t("imageAnalysisStatus.badgeBypassed");case"fallback":return l.t("imageAnalysisStatus.nativeFallback");case"setup":return l.t("imageAnalysisStatus.badgeSetup");case"disabled":return l.t("imageAnalysisStatus.badgeDisabled");case"native":return l.t("imageAnalysisStatus.badgeNative");case"unresolved":return l.t("imageAnalysisStatus.nativeImageReading")}}function xe(t){switch(t){case"active":return"border-emerald-500/25 bg-emerald-500/10 text-emerald-800 dark:text-emerald-200";case"bypassed":return"border-sky-500/25 bg-sky-500/10 text-sky-800 dark:text-sky-200";case"fallback":case"setup":return"border-amber-500/25 bg-amber-500/10 text-amber-800 dark:text-amber-200";case"native":return"border-emerald-500/25 bg-emerald-500/10 text-emerald-800 dark:text-emerald-200";case"disabled":case"unresolved":return"border-border/80 bg-background/85 text-muted-foreground"}}function Fe(t){switch(t){case"starts_on_launch":return l.t("imageAnalysisSection.backendStartsOnLaunch",{defaultValue:"Starts on launch"});case"needs_auth":return l.t("imageAnalysisStatus.needsAuth");case"needs_proxy":return l.t("imageAnalysisStatus.needsProxy");case"review":return l.t("imageAnalysisSection.review",{defaultValue:"Review"});case"ready":return l.t("imageAnalysisStatus.badgeReady")}}function Oe(t){if(!t)return l.t("imageAnalysisSection.noModelConfigured",{defaultValue:"No model configured."});switch(t.state){case"needs_auth":return t.authReason||l.t("imageAnalysisSection.authenticateToRoute",{defaultValue:"Authenticate to route here."});case"needs_proxy":return t.proxyReason||l.t("imageAnalysisSection.proxyUnavailable",{defaultValue:"Proxy unavailable."});case"starts_on_launch":return l.t("imageAnalysisSection.authReadyLaunchesLocally",{defaultValue:"Auth ready. Launches locally on demand."});case"review":return l.t("imageAnalysisSection.needsManualReview",{defaultValue:"Needs manual review."});case"ready":return null}}function ze(t){switch(t){case"profile-backend":return l.t("imageAnalysisSection.explicitMapping",{defaultValue:"Explicit mapping"});case"fallback-backend":return l.t("imageAnalysisSection.fallbackBackend",{defaultValue:"Fallback backend"});case"cliproxy-provider":return l.t("imageAnalysisSection.providerMatch",{defaultValue:"Provider match"});case"cliproxy-bridge":return l.t("imageAnalysisSection.bridgeMatch",{defaultValue:"Bridge match"});case"native-compatible":return l.t("imageAnalysisSection.nativePath",{defaultValue:"Native path"});case"copilot-alias":return l.t("imageAnalysisSection.copilotAlias",{defaultValue:"Copilot alias"});default:return t.replace(/-/g," ")}}function k(t){return"border-border/50 bg-background/40"}function Le(t){switch(t){case"ready":return"bg-[linear-gradient(90deg,rgba(16,185,129,0.08),transparent_18%),linear-gradient(180deg,rgba(255,255,255,0.72),rgba(255,255,255,0.46))] dark:bg-[linear-gradient(90deg,rgba(16,185,129,0.12),transparent_18%),linear-gradient(180deg,rgba(15,23,42,0.82),rgba(15,23,42,0.56))]";case"starts_on_launch":return"bg-[linear-gradient(90deg,rgba(14,165,233,0.08),transparent_18%),linear-gradient(180deg,rgba(255,255,255,0.72),rgba(255,255,255,0.46))] dark:bg-[linear-gradient(90deg,rgba(14,165,233,0.12),transparent_18%),linear-gradient(180deg,rgba(15,23,42,0.82),rgba(15,23,42,0.56))]";case"needs_auth":return"bg-[linear-gradient(90deg,rgba(244,63,94,0.08),transparent_18%),linear-gradient(180deg,rgba(255,255,255,0.72),rgba(255,255,255,0.46))] dark:bg-[linear-gradient(90deg,rgba(244,63,94,0.12),transparent_18%),linear-gradient(180deg,rgba(15,23,42,0.82),rgba(15,23,42,0.56))]";case"needs_proxy":return"bg-[linear-gradient(90deg,rgba(245,158,11,0.08),transparent_18%),linear-gradient(180deg,rgba(255,255,255,0.72),rgba(255,255,255,0.46))] dark:bg-[linear-gradient(90deg,rgba(245,158,11,0.12),transparent_18%),linear-gradient(180deg,rgba(15,23,42,0.82),rgba(15,23,42,0.56))]";case"review":default:return"bg-[linear-gradient(180deg,rgba(255,255,255,0.74),rgba(255,255,255,0.5))] dark:bg-[linear-gradient(180deg,rgba(15,23,42,0.8),rgba(15,23,42,0.58))]"}}function Ke(t){switch(t){case"ready":return"from-emerald-500 to-emerald-400/30";case"starts_on_launch":return"from-sky-500 to-sky-400/30";case"needs_auth":return"from-rose-500 to-rose-400/30";case"needs_proxy":return"from-amber-500 to-amber-400/30";case"review":default:return"from-slate-400 to-slate-300/20"}}function Ue(t,r){return r.nativeReadPreference?t%2===0?"bg-emerald-500/[0.06]":"bg-emerald-500/[0.08]":t%2===0?"bg-background/75":"bg-muted/18"}function He(t){const r=[`${t.activeProfileCount} routed`,`${t.nativeProfileCount} native`];return t.mappedProfileCount>0&&r.push(`${t.mappedProfileCount} override${t.mappedProfileCount===1?"":"s"}`),r.join(" · ")}function Je(t){return Object.entries(t).reduce((r,[s,x])=>{const h=x.trim();return r[s]=h||null,r},{})}function W(t){return Object.entries(t).filter(([,r])=>r.trim().length>0).map(([r])=>r)}function qe(t){return t.reduce((r,s)=>{const x=s.profileName.trim();return!x||!s.backendId||(r[x]=s.backendId),r},{})}function pe(t,r){const s=Number.parseInt(t.trim(),10);return Number.isInteger(s)?String(Math.min(600,Math.max(10,s))):r}function T({title:t,description:r,icon:s,meta:x,action:h,children:D,className:c}){return e.jsxs("div",{className:g("relative overflow-hidden rounded-2xl border bg-gradient-to-br from-background via-background to-muted/25 p-4 shadow-sm",c),children:[e.jsx("div",{className:"absolute inset-x-0 top-0 h-px bg-gradient-to-r from-primary/40 via-primary/10 to-transparent"}),e.jsxs("div",{className:"relative space-y-4",children:[e.jsxs("div",{className:"flex flex-col gap-3 md:flex-row md:items-start md:justify-between",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"inline-flex h-9 w-9 shrink-0 items-center justify-center rounded-xl border border-primary/20 bg-primary/10 text-primary",children:s}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("h3",{className:"text-base font-semibold tracking-tight",children:t}),x]}),e.jsx("p",{className:"mt-0.5 text-sm leading-5 text-muted-foreground",children:r})]})]}),h&&e.jsx("div",{className:"shrink-0",children:h})]}),e.jsx("div",{className:"space-y-3",children:D})]})]})}function ra(){const{t}=Ne(),{fetchRawConfig:r}=ke(),[s,x]=o.useState(null),[h,D]=o.useState(!0),[c,Y]=o.useState(!1),[I,N]=o.useState(null),[P,L]=o.useState(null),[E,Q]=o.useState(!1),[B,X]=o.useState(!0),[K,U]=o.useState("60"),[v,R]=o.useState(""),[w,$]=o.useState({}),[p,F]=o.useState([]),S=o.useCallback(a=>{X(a.config.enabled),U(String(a.config.timeout)),R(a.config.fallbackBackend??""),$(a.catalog.knownBackends.reduce((n,i)=>(n[i]=a.config.providerModels[i]??"",n),{})),F(Ie(a.config.profileBackends))},[]),H=o.useCallback(async()=>{try{D(!0),N(null);const a=await re.imageAnalysis.get();if(!De(a))throw new Error("Image settings returned an unexpected response. Restart the dashboard server so the new API route is available.");x(a),S(a)}catch(a){N(a instanceof Error?a.message:"Failed to load image settings.")}finally{D(!1)}},[S]);o.useEffect(()=>{H(),r()},[H,r]),o.useEffect(()=>{if(!P)return;const a=window.setTimeout(()=>L(null),2500);return()=>window.clearTimeout(a)},[P]),o.useEffect(()=>{s&&Object.keys(s.config.profileBackends).length>0&&Q(!0)},[s]);const u=o.useMemo(()=>W(w),[w]),Z=o.useMemo(()=>{if(!s)return[];const a=s.catalog.knownBackends.filter(i=>u.includes(i)),n=s.catalog.knownBackends.filter(i=>!u.includes(i));return[...a,...n]},[u,s]),O=o.useMemo(()=>s?.profiles.filter(a=>a.nativeReadPreference)??[],[s]);o.useEffect(()=>{if(u.length===0){R("");return}u.includes(v)||R(u[0])},[u,v]);const _=o.useCallback(async a=>{if(!s)return!1;const n=a?.enabled??B,i=a?.providerModels??w,d=W(i),b=pe(a?.timeout??K,String(s.config.timeout)),y=a?.fallbackBackend??v,A=d.length===0?"":d.includes(y)?y:d[0],f=a?.mappingDrafts??p,V={enabled:n,timeout:b,fallbackBackend:A,providerModels:Je(i),profileBackends:qe(f)},je={enabled:s.config.enabled,timeout:String(s.config.timeout),fallbackBackend:s.config.fallbackBackend??"",providerModels:s.catalog.knownBackends.reduce((j,te)=>(j[te]=s.config.providerModels[te]??null,j),{}),profileBackends:s.config.profileBackends};if(JSON.stringify(V)===JSON.stringify(je))return!0;if(n&&d.length===0)return N("Keep at least one provider model configured, or disable Image globally."),S(s),!1;try{Y(!0),N(null);const j=await re.imageAnalysis.update({enabled:n,timeout:Number.parseInt(b,10),fallbackBackend:A||null,providerModels:V.providerModels,profileBackends:V.profileBackends});return x(j),S(j),L(t("commonToast.settingsSaved")),await r(),!0}catch(j){return N(j instanceof Error?j.message:"Failed to save image settings."),S(s),!1}finally{Y(!1)}},[s,B,v,r,S,p,w,t,K]),ee=async()=>{h||c||(L(null),await Promise.all([H(),r()]))},be=async a=>{if(!c){if(a&&u.length===0){N("Keep at least one provider model configured, or disable Image globally.");return}X(a),await _({enabled:a})}},fe=async a=>{if(!s||c)return;const n=pe(a,String(s.config.timeout));U(n),await _({timeout:n})},he=async a=>{c||(R(a),await _({fallbackBackend:a}))},ae=async(a,n)=>{if(!s||c)return;const i=n.trim(),d={...w,[a]:i},b=W(d);if(B&&b.length===0){N("Disable Image first or keep one backend configured."),$(A=>({...A,[a]:s.config.providerModels[a]??""}));return}const y=b.length===0?"":b.includes(v)?v:b[0];$(d),R(y),await _({providerModels:d,fallbackBackend:y})},ve=(a,n)=>{F(i=>i.map(d=>d.id===a?{...d,...n}:d))},J=async a=>{c||(F(a),await _({mappingDrafts:a}))},ye=p.filter(a=>a.profileName.trim()&&a.backendId).length;return h?e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsxs("div",{className:"flex items-center gap-3 text-muted-foreground",children:[e.jsx(G,{className:"w-5 h-5 animate-spin"}),e.jsx("span",{children:t("settingsPage.imageAnalysisSection.loading")})]})}):s?e.jsxs("div",{className:"relative flex min-h-0 flex-1 flex-col",children:[e.jsxs("div",{className:`absolute left-5 right-5 top-20 z-10 transition-all duration-200 ease-out ${I||P?"translate-y-0 opacity-100":"pointer-events-none -translate-y-2 opacity-0"}`,children:[I&&e.jsxs(se,{variant:"destructive",className:"py-2 shadow-lg",children:[e.jsx(ce,{className:"h-4 w-4"}),e.jsx(ne,{children:I})]}),P&&e.jsxs("div",{className:"flex items-center gap-2 rounded-md border border-green-200 bg-green-50 px-3 py-2 text-green-700 shadow-lg dark:border-green-900/50 dark:bg-green-900/90 dark:text-green-300",children:[e.jsx(Ae,{className:"h-4 w-4 shrink-0"}),e.jsx("span",{className:"text-sm font-medium",children:P})]})]}),e.jsx(we,{className:"min-h-0 flex-1",children:e.jsxs("div",{className:"space-y-6 p-5",children:[e.jsxs("div",{className:"relative overflow-hidden rounded-2xl border bg-gradient-to-br from-background via-background to-muted/30 p-4 shadow-sm",children:[e.jsx("div",{className:"absolute inset-x-0 top-0 h-px bg-gradient-to-r from-primary/70 via-primary/20 to-transparent"}),e.jsx("div",{className:"pointer-events-none absolute inset-0 opacity-[0.035]",style:{backgroundImage:"repeating-linear-gradient(0deg, transparent, transparent 2px, currentColor 2px, currentColor 3px)"}}),e.jsxs("div",{className:"relative",children:[e.jsxs("div",{className:"mb-3 flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"inline-flex h-8 w-8 items-center justify-center rounded-xl border border-primary/20 bg-primary/8 text-primary",children:e.jsx(me,{className:"h-4 w-4"})}),e.jsx("p",{className:"text-sm font-semibold tracking-tight",children:t("settingsPage.imageAnalysisSection.title")})]}),e.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(m,{className:g("border",Ee(s.summary.state)),children:s.summary.title}),e.jsx("span",{children:He(s.summary)})]})]}),e.jsx(C,{variant:"ghost",size:"sm",onClick:ee,disabled:h||c,"aria-label":"Refresh",title:"Refresh",children:e.jsx(G,{className:`h-4 w-4 ${h?"animate-spin":""}`})})]}),e.jsxs("div",{className:"mt-3 grid gap-2 sm:grid-cols-2",children:[e.jsxs("div",{className:"rounded-[18px] border bg-background/72 px-3 py-2.5 backdrop-blur-sm",children:[e.jsx("div",{className:"text-[10px] font-medium uppercase tracking-[0.14em] text-muted-foreground",children:"Active routes"}),e.jsx("div",{className:"mt-1.5 text-xl font-semibold text-foreground",children:s.summary.activeProfileCount}),e.jsx("p",{className:"mt-0.5 text-[11px] text-muted-foreground",children:"Current target path"})]}),e.jsxs("div",{className:"rounded-[18px] border bg-background/72 px-3 py-2.5 backdrop-blur-sm",children:[e.jsx("div",{className:"text-[10px] font-medium uppercase tracking-[0.14em] text-muted-foreground",children:"Native path"}),e.jsx("div",{className:"mt-1.5 text-xl font-semibold text-foreground",children:s.summary.nativeProfileCount}),e.jsx("p",{className:"mt-0.5 text-[11px] text-muted-foreground",children:"Skip transformer"})]})]})]})]}),e.jsxs(T,{tone:"amber",eyebrow:"Control deck",title:"Core setup",description:t("settingsPage.imageAnalysisSection.description"),icon:e.jsx(Ce,{className:"h-4 w-4"}),meta:e.jsxs(m,{variant:"outline",className:"border-amber-500/25 bg-amber-500/10 text-[10px]",children:[u.length," configured"]}),children:[e.jsxs("div",{className:"grid gap-2 lg:grid-cols-3",children:[e.jsxs("div",{className:g("rounded-[18px] border px-3.5 py-3 shadow-sm",k()),children:[e.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-[0.14em] text-amber-700/75 dark:text-amber-300/75",children:"Enabled"}),e.jsxs("div",{className:"mt-2.5 flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx("div",{className:"text-sm font-semibold text-foreground",children:B?"Transformer on":"Transformer off"}),e.jsx("p",{className:"text-[11px] leading-4 text-muted-foreground",children:"Profile flags stay untouched."})]}),e.jsx(Se,{checked:B,onCheckedChange:a=>{be(a)},disabled:c})]})]}),e.jsxs("div",{className:g("rounded-[18px] border px-3.5 py-3 shadow-sm",k()),children:[e.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-[0.14em] text-amber-700/75 dark:text-amber-300/75",children:"Timeout"}),e.jsxs("div",{className:"mt-2.5 flex items-center gap-2",children:[e.jsx(q,{value:K,onChange:a=>U(a.target.value),inputMode:"numeric",className:"h-10 border-amber-500/15 bg-background/90 text-base",disabled:c,onBlur:a=>{fe(a.currentTarget.value)},onKeyDown:a=>{a.key==="Enter"&&a.currentTarget.blur()}}),e.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:"sec"})]}),e.jsx("p",{className:"mt-1.5 text-[11px] leading-4 text-muted-foreground",children:"Keeps large reads from hanging."})]}),e.jsxs("div",{className:g("rounded-[18px] border px-3.5 py-3 shadow-sm",k()),children:[e.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-[0.14em] text-amber-700/75 dark:text-amber-300/75",children:"Fallback backend"}),e.jsx("div",{className:"mt-2.5",children:e.jsxs(ie,{value:v||M,onValueChange:a=>{he(a===M?"":a)},disabled:c,children:[e.jsx(le,{className:"h-10 border-amber-500/15 bg-background/90",children:e.jsx(de,{placeholder:t("settingsPage.thinkingSection.configureModelFirst")})}),e.jsx(oe,{children:u.length===0?e.jsx(z,{value:M,children:t("settingsPage.thinkingSection.configureModelFirst")}):u.map(a=>e.jsx(z,{value:a,children:a},a))})]})}),e.jsx("p",{className:"mt-1.5 text-[11px] leading-4 text-muted-foreground",children:"Used when no direct route exists."})]})]}),e.jsxs("div",{className:"mt-3 flex flex-wrap gap-1.5",children:[e.jsxs("div",{className:"rounded-full border border-amber-500/15 bg-background/80 px-2.5 py-1 text-[11px] text-muted-foreground",children:[ye," overrides"]}),e.jsxs("div",{className:"rounded-full border border-amber-500/15 bg-background/80 px-2.5 py-1 text-[11px] text-muted-foreground",children:[O.length," native"]}),e.jsxs("div",{className:"rounded-full border border-amber-500/15 bg-background/80 px-2.5 py-1 text-[11px] text-muted-foreground",children:[v||"No fallback"," fallback"]})]})]}),e.jsx(T,{tone:"cyan",eyebrow:"Route inventory",title:"Backend routes",description:"Model entry plus route health.",icon:e.jsx(Me,{className:"h-4 w-4"}),meta:e.jsxs(m,{variant:"outline",className:"border-cyan-500/25 bg-cyan-500/10 text-[10px]",children:[Z.length," backends"]}),children:e.jsx("div",{className:"overflow-hidden rounded-[20px] border border-cyan-500/12 bg-background/65 shadow-sm backdrop-blur-sm",children:Z.map((a,n)=>{const i=s.backends.find(f=>f.backendId===a),d=i?.displayName||a,b=w[a]??"",y=Oe(i),A=b?[`${i?.profilesUsing??0} active`,i?.authReadiness==="missing"?"auth missing":i?.proxyReadiness==="stopped"?"starts on launch":null].filter(Boolean).join(" · "):"No model configured.";return e.jsxs("div",{className:g("relative px-3 py-3 md:px-4",n>0&&"border-t border-cyan-500/10",Le(i?.state)),children:[e.jsx("div",{className:g("absolute bottom-3 left-0 top-3 w-1 rounded-r-full bg-gradient-to-b",Ke(i?.state))}),e.jsxs("div",{className:"pl-2.5",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("h4",{className:"text-sm font-semibold text-foreground",children:d}),e.jsx(m,{variant:"outline",className:"font-mono text-[10px]",children:a}),i?.profilesUsing?e.jsxs(m,{variant:"outline",className:"border-cyan-500/20 bg-cyan-500/10 text-[10px]",children:[i.profilesUsing," active"]}):null]}),e.jsx("p",{className:"mt-0.5 text-[11px] leading-4 text-muted-foreground",children:A})]}),e.jsx(m,{className:g("border",i?$e(i.state):"border-border/80 bg-background/85 text-muted-foreground"),children:i?Fe(i.state):"Inactive"})]}),e.jsxs("div",{className:"mt-2 flex flex-col gap-2 sm:flex-row",children:[e.jsx(q,{className:"h-10 flex-1 border-cyan-500/15 bg-background/88 text-base",placeholder:t("imageAnalysisSection.setModel",{defaultValue:"Set model"}),value:b,disabled:c,onChange:f=>$(V=>({...V,[a]:f.target.value})),onBlur:f=>{ae(a,f.currentTarget.value)},onKeyDown:f=>{f.key==="Enter"&&f.currentTarget.blur()}}),b.trim().length>0&&e.jsx(C,{type:"button",variant:"outline",size:"sm",className:"h-10 sm:self-stretch",disabled:c,onClick:()=>{ae(a,"")},children:t("common.clear",{defaultValue:"Clear"})})]}),y&&e.jsx("p",{className:"mt-1.5 text-[11px] leading-4 text-muted-foreground",children:y})]})]},a)})})}),e.jsx(T,{tone:"emerald",eyebrow:"Native path",title:"Native reading",description:"Profiles that skip the transformer.",icon:e.jsx(Pe,{className:"h-4 w-4"}),meta:e.jsxs(m,{variant:"outline",children:[O.length," profiles"]}),children:O.length===0?e.jsx("div",{className:g("rounded-[18px] border border-dashed px-3.5 py-3.5 text-sm text-muted-foreground",k()),children:t("imageAnalysisSection.noProfilesPreferNative",{defaultValue:"No profiles prefer native reading yet."})}):e.jsx("div",{className:"grid gap-2 md:grid-cols-2",children:O.map(a=>e.jsx("div",{className:g("rounded-[18px] border px-3.5 py-3 shadow-sm",k()),children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("div",{className:"truncate text-sm font-semibold text-foreground",children:a.name}),e.jsx(m,{variant:"outline",className:"text-[10px]",children:a.kind==="variant"?t("cliproxyPage.variant"):t("apiProfiles.title")}),e.jsx(m,{variant:"outline",className:"text-[10px]",children:a.nativeImageCapable?t("imageAnalysisStatus.capabilityVerified"):t("imageAnalysisSection.review",{defaultValue:"Review"})})]}),e.jsxs("div",{className:"mt-1 text-[11px] leading-4 text-muted-foreground",children:[a.profileModel||t("imageAnalysisSection.modelNotDetected",{defaultValue:"Model not detected"})," ","·"," ",a.nativeImageReason||t("imageAnalysisSection.nativeReadPreferred",{defaultValue:"Native read preferred."})]})]}),e.jsx(m,{className:g("border",xe(a.currentTargetMode)),children:ge(a.currentTargetMode)})]})},`native-${a.kind}-${a.name}`))})}),e.jsxs(T,{tone:"slate",eyebrow:"Override lab",title:"Profile routing",description:"Only for explicit route overrides.",icon:e.jsx(Te,{className:"h-4 w-4"}),meta:e.jsx(m,{variant:"outline",className:"border-amber-500/25 bg-amber-500/10 text-[10px] text-amber-800 dark:text-amber-200",children:"Advanced"}),action:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(C,{type:"button",variant:"outline",size:"sm",onClick:()=>Q(a=>!a),children:[E?e.jsx(Re,{className:"mr-1 h-4 w-4"}):e.jsx(_e,{className:"mr-1 h-4 w-4"}),E?t("common.hide",{defaultValue:"Hide"}):t("common.show",{defaultValue:"Show"})]}),E&&e.jsxs(C,{type:"button",variant:"outline",size:"sm",onClick:()=>F(a=>[...a,{id:`mapping-${Date.now()}`,profileName:"",backendId:u[0]??""}]),disabled:u.length===0||c,children:[e.jsx(Ve,{className:"mr-1 h-4 w-4"}),t("imageAnalysisSection.addMapping",{defaultValue:"Add mapping"})]})]}),className:"border-dashed",children:[e.jsx("datalist",{id:"image-profile-suggestions",children:s.catalog.profileNames.map(a=>e.jsx("option",{value:a},a))}),E?e.jsx("div",{className:"space-y-2",children:p.length===0?e.jsx("div",{className:g("rounded-[18px] border border-dashed px-3.5 py-3.5 text-sm text-muted-foreground",k()),children:"No explicit overrides saved."}):e.jsx("div",{className:"space-y-2",children:p.map(a=>e.jsxs("div",{className:"rounded-[18px] border border-slate-400/20 bg-[linear-gradient(180deg,rgba(255,255,255,0.72),rgba(248,250,252,0.52))] p-3 shadow-sm dark:bg-[linear-gradient(180deg,rgba(15,23,42,0.84),rgba(15,23,42,0.56))]",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-[11px] leading-4 text-muted-foreground",children:[e.jsx("span",{children:t("imageAnalysisSection.directOverride",{defaultValue:"Direct override"})}),!(a.profileName.trim()&&a.backendId)&&e.jsx(m,{variant:"outline",className:"text-[10px]",children:"Draft"})]}),e.jsxs(C,{type:"button",variant:"ghost",size:"sm",disabled:c,onClick:()=>{const n=p.filter(i=>i.id!==a.id);J(n)},children:[e.jsx(Be,{className:"mr-1 h-4 w-4"}),t("common.remove",{defaultValue:"Remove"})]})]}),e.jsxs("div",{className:"mt-2 grid gap-2 sm:grid-cols-2",children:[e.jsx(q,{value:a.profileName,list:"image-profile-suggestions",disabled:c,placeholder:t("imageAnalysisSection.profileOrVariantName",{defaultValue:"Profile or variant name"}),className:"h-10 border-slate-400/15 bg-background/88 text-base",onChange:n=>{ve(a.id,{profileName:n.target.value})},onBlur:n=>{const i=p.map(d=>d.id===a.id?{...d,profileName:n.currentTarget.value.trim()}:d);J(i)},onKeyDown:n=>{n.key==="Enter"&&n.currentTarget.blur()}}),e.jsxs(ie,{value:a.backendId||M,disabled:c,onValueChange:n=>{const i=p.map(d=>d.id===a.id?{...d,backendId:n===M?"":n}:d);J(i)},children:[e.jsx(le,{className:"h-10 border-slate-400/15 bg-background/88",children:e.jsx(de,{placeholder:t("settingsPage.thinkingSection.configureModelFirst")})}),e.jsx(oe,{children:u.length===0?e.jsx(z,{value:M,children:t("settingsPage.thinkingSection.configureModelFirst")}):u.map(n=>e.jsx(z,{value:n,children:n},n))})]})]})]},a.id))})}):e.jsxs("div",{className:g("rounded-[18px] border border-dashed px-3.5 py-3 text-sm text-muted-foreground",k()),children:["Hidden by default.",p.length>0?` ${p.length} override${p.length===1?"":"s"} saved.`:" No overrides saved."]})]}),e.jsx(T,{tone:"slate",eyebrow:"Audit view",title:"Coverage",description:"Read-only routing ledger for the current path.",icon:e.jsx(me,{className:"h-4 w-4"}),meta:e.jsxs(m,{variant:"outline",children:[s.profiles.length," profiles"]}),children:e.jsx("div",{className:"overflow-hidden rounded-[20px] border border-slate-400/15 bg-background/75 shadow-sm backdrop-blur-sm",children:s.profiles.map((a,n)=>e.jsxs("div",{className:g("grid gap-2 px-3.5 py-2.5 md:grid-cols-[minmax(0,1fr)_auto] md:items-center",n>0&&"border-t border-slate-400/12",Ue(n,a)),children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("div",{className:"truncate text-sm font-semibold text-foreground",children:a.name}),e.jsx(m,{variant:"outline",className:"text-[10px]",children:a.kind==="variant"?t("cliproxyPage.variant"):t("apiProfiles.title")}),e.jsx(m,{variant:"outline",className:"font-mono text-[10px] uppercase",children:a.target}),a.nativeReadPreference&&e.jsx(m,{variant:"outline",className:"border-emerald-500/20 bg-emerald-500/10 text-[10px]",children:"Native"})]}),e.jsxs("div",{className:"mt-0.5 text-[11px] leading-4 text-muted-foreground",children:[a.backendDisplayName||a.profileModel||"Native file access"," ·"," ",ze(a.resolutionSource)]})]}),e.jsxs("div",{className:"flex items-center gap-2 md:justify-end",children:[a.profileModel&&e.jsx(m,{variant:"outline",className:"font-mono text-[10px]",children:a.profileModel}),e.jsx(m,{className:g("border",xe(a.currentTargetMode)),children:ge(a.currentTargetMode)})]})]},`${a.kind}-${a.name}`))})})]})})]}):e.jsxs("div",{className:"p-5",children:[e.jsxs(se,{variant:"destructive",children:[e.jsx(ce,{className:"h-4 w-4"}),e.jsx(ne,{children:I??t("settingsPage.imageAnalysisSection.description")})]}),e.jsx("div",{className:"mt-4",children:e.jsxs(C,{variant:"outline",size:"sm",onClick:ee,children:[e.jsx(G,{className:"mr-1 h-4 w-4"}),t("sharedPage.retry")]})})]})}export{ra as default};
@@ -1 +1 @@
1
- import{j as e}from"./radix-ui-Zb8sVEtn.js";import{r as o}from"./react-vendor-CNOkPC89.js";import{bt as ie,bu as ne,Y as E,a as Y,bv as oe,bi as O,bk as R,d as h,n as le,c as w,L as f,I as T,r as $,s as H,t as F,v as U,w as V,aI as G,M as ce,N as ue,O as xe}from"./index-0mNJhDEG.js";import{m as g,A as me}from"./proxy-g4_N-fbB.js";import{R as N,I as B,x as k,ab as ge,_ as be,ba as pe,w as Q,$ as he,a6 as fe,e as we,s as je}from"./icons-DyorC3Xk.js";import"./tanstack-CrmUhA7Z.js";import"./notifications-B2HqRBj7.js";import"./utils-CzKF5WmX.js";import"./form-utils-Bcoyqxpq.js";import"./code-highlight-BRUf_pqB.js";function ve(r,s){return{claude:{...r.claude,...s.claude},codex:{...r.codex,...s.codex}}}function Ne(){const{state:r}=ie(),s=ne(),i=o.useCallback(async()=>{try{s.setBrowserLoading(!0),s.setBrowserError(null);const d=await E.browser.get();s.setBrowserConfig(d.config),s.setBrowserStatus(d.status)}catch(d){s.setBrowserError(d.message)}finally{s.setBrowserLoading(!1),s.setBrowserStatusLoading(!1)}},[s]),a=o.useCallback(async()=>{try{s.setBrowserStatusLoading(!0),s.setBrowserError(null);const d=await E.browser.getStatus();return s.setBrowserStatus(d),d}catch(d){return s.setBrowserError(d.message),null}finally{s.setBrowserStatusLoading(!1)}},[s]),c=o.useCallback(async d=>{const l=r.browserConfig;if(!l)return!1;const b=ve(l,d);s.setBrowserConfig(b);try{s.setBrowserSaving(!0),s.setBrowserError(null);const x=await E.browser.update(d);return s.setBrowserConfig(x.browser.config),s.setBrowserStatus(x.browser.status),s.setBrowserSuccess(!0),window.setTimeout(()=>s.setBrowserSuccess(!1),1500),!0}catch(x){return s.setBrowserConfig(l),s.setBrowserError(x.message),!1}finally{s.setBrowserSaving(!1)}},[s,r.browserConfig]);return{config:r.browserConfig,status:r.browserStatus,loading:r.browserLoading,statusLoading:r.browserStatusLoading,saving:r.browserSaving,error:r.browserError,success:r.browserSuccess,fetchConfig:i,fetchStatus:a,saveConfig:c}}function ke(r){const s=r.toLowerCase();return s.includes("mac")?"darwin":s.includes("win")?"win32":"linux"}function ye(r=navigator){const s=typeof r.userAgentData?.platform=="string"?r.userAgentData.platform:"",i=typeof r.platform=="string"&&r.platform.trim()?r.platform:r.userAgent;return ke(s||i||"")}function Se(r){if(!/^\d+$/.test(r.trim()))return null;const s=Number.parseInt(r.trim(),10);return s<1||s>65535?null:s}const q=["disabled","readonly","readwrite"];function D(r,s){return r(`settingsPage.browserSection.evalMode.options.${s}`)}function Ce(r,s,i){const a=JSON.stringify(r);return i==="darwin"?`open -na "Google Chrome" --args --remote-debugging-port=${s} --user-data-dir=${a}`:i==="win32"?`chrome.exe --remote-debugging-port=${s} --user-data-dir=${a}`:`google-chrome --remote-debugging-port=${s} --user-data-dir=${a}`}function J({children:r,className:s,title:i,description:a,badge:c,action:d}){return e.jsx("div",{className:w("group relative overflow-hidden rounded-[2.5rem] border border-border/60 bg-muted/20 p-1.5 transition-all duration-700 ease-[cubic-bezier(0.32,0.72,0,1)] dark:border-white/[0.08] dark:bg-zinc-900/35",s),children:e.jsxs("div",{className:"relative overflow-hidden rounded-[calc(2.5rem-0.375rem)] border border-border/70 bg-card/90 shadow-[0_12px_36px_-18px_rgba(15,23,42,0.18)] dark:border-white/[0.08] dark:bg-zinc-900/70 dark:shadow-[0_18px_44px_-24px_rgba(0,0,0,0.55)]",children:[e.jsx("div",{className:"pointer-events-none absolute inset-0 shadow-[inset_0_1px_0_rgba(255,255,255,0.28)] dark:shadow-[inset_0_1px_0_rgba(255,255,255,0.04)]"}),(i||d)&&e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-4 border-b border-border/60 px-8 py-6 dark:border-white/[0.06]",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("h3",{className:"text-xl font-semibold tracking-tight",children:i}),c]}),a&&e.jsx("p",{className:"text-sm text-muted-foreground",children:a})]}),d&&e.jsx("div",{className:"flex items-center gap-2",children:d})]}),e.jsx("div",{className:"px-8 py-8",children:r})]})})}function K({state:r,title:s,detail:i,nextStep:a}){const{t:c}=Y(),d=r==="ready"||r==="enabled",l=!d&&r!=="disabled";return e.jsx("div",{className:w("relative overflow-hidden rounded-2xl border p-4 transition-all duration-500",d?"border-emerald-500/20 bg-emerald-500/[0.03] dark:bg-emerald-500/[0.02]":l?"border-amber-500/20 bg-amber-500/[0.03] dark:bg-amber-500/[0.02]":"border-border/60 bg-muted/30 dark:border-white/[0.06] dark:bg-zinc-900/45"),children:e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx("div",{className:w("flex h-10 w-10 shrink-0 items-center justify-center rounded-xl transition-transform duration-500 group-hover:scale-110",d?"bg-emerald-500/10 text-emerald-600":l?"bg-amber-500/10 text-amber-600":"bg-slate-500/10 text-slate-500"),children:d?e.jsx(k,{size:24}):l?e.jsx(Q,{size:24}):e.jsx(B,{size:24})}),e.jsxs("div",{className:"min-w-0 flex-1 space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm font-semibold uppercase tracking-wider text-muted-foreground/60",children:c("settingsPage.browserSection.readiness")}),d&&e.jsx(g.span,{animate:{opacity:[.4,1,.4]},transition:{duration:2,repeat:1/0},className:"h-1.5 w-1.5 rounded-full bg-emerald-500"})]}),e.jsx("h4",{className:"font-medium text-foreground",children:s}),e.jsx("p",{className:"text-sm leading-relaxed text-muted-foreground",children:i}),a&&e.jsxs("div",{className:"mt-3 flex items-start gap-2 rounded-lg border border-border/50 bg-muted/35 p-3 dark:border-white/[0.05] dark:bg-zinc-900/45",children:[e.jsx(fe,{size:14,className:"mt-0.5 shrink-0 text-primary"}),e.jsxs("p",{className:"text-xs leading-normal",children:[e.jsxs("span",{className:"font-semibold text-primary",children:[c("settingsPage.browserSection.nextStep"),":"]})," ",a]})]})]})]})})}function W({title:r,children:s,defaultOpen:i=!1}){const[a,c]=o.useState(i);return e.jsxs(ce,{open:a,onOpenChange:c,className:"overflow-hidden rounded-2xl border border-border/60 bg-muted/20 dark:border-white/[0.06] dark:bg-zinc-900/30",children:[e.jsx(ue,{asChild:!0,children:e.jsxs("button",{className:"flex w-full items-center justify-between px-6 py-4 text-sm font-medium transition-colors hover:bg-muted/40 dark:hover:bg-zinc-900/50",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(we,{size:16,className:"text-muted-foreground"}),r]}),e.jsx(je,{size:16,className:w("transition-transform duration-300",a&&"rotate-180")})]})}),e.jsx(xe,{children:e.jsx("div",{className:"border-t border-border/60 px-6 py-6 dark:border-white/[0.06]",children:s})})]})}function Oe(){const{t:r}=Y(),{fetchRawConfig:s}=oe(),{config:i,status:a,loading:c,statusLoading:d,saving:l,error:b,success:x,fetchConfig:y,fetchStatus:_,saveConfig:S}=Ne(),[Z,m]=o.useState(null),[ee,C]=o.useState(null),[P,p]=o.useState(null);o.useEffect(()=>{y()},[y]),o.useEffect(()=>{if(!P&&!x)return;const n=window.setTimeout(()=>p(null),2500);return()=>window.clearTimeout(n)},[P,x]);const t=Z??i,j=o.useMemo(()=>t?Ce(t.claude.userDataDir,t.claude.devtoolsPort,ye()):"",[t]),M=ee??String(t?.claude.devtoolsPort??9222),v=Se(M),z=M.trim().length>0&&v===null,A=i!==null&&t!==null&&(i.claude.enabled!==t.claude.enabled||i.claude.userDataDir!==t.claude.userDataDir||i.claude.devtoolsPort!==v||i.claude.evalMode!==t.claude.evalMode),re=i!==null&&t!==null&&(i.codex.enabled!==t.codex.enabled||i.codex.evalMode!==t.codex.evalMode),I=o.useCallback(async()=>{p(null),m(null),C(null),await Promise.all([y(),s()])},[y,s]),se=o.useCallback(async()=>{await _()&&p(r("settingsPage.browserSection.messages.statusRefreshed"))},[_,r]),ae=o.useCallback(async()=>{if(!t||v===null)return;await S({claude:{enabled:t.claude.enabled,userDataDir:t.claude.userDataDir.trim(),devtoolsPort:v,evalMode:t.claude.evalMode}})&&(await s(),p(null),m(null),C(null))},[v,t,s,S]),te=o.useCallback(async()=>{if(!t)return;await S({codex:{enabled:t.codex.enabled,evalMode:t.codex.evalMode}})&&(await s(),p(null),m(null),C(null))},[t,s,S]),de=o.useCallback(async()=>{j&&(await navigator.clipboard.writeText(j),p(r("settingsPage.browserSection.messages.launchCommandCopied")))},[j,r]);return c?e.jsx("div",{className:"flex flex-1 items-center justify-center",children:e.jsxs("div",{className:"flex flex-col items-center gap-4 text-muted-foreground",children:[e.jsx(g.div,{animate:{rotate:360},transition:{duration:1.5,repeat:1/0,ease:"linear"},children:e.jsx(N,{size:32})}),e.jsx("span",{className:"text-sm font-medium uppercase tracking-widest opacity-60",children:r("settings.loading")})]})}):!i||!a||!t?e.jsx("div",{className:"p-8",children:e.jsxs(O,{variant:"destructive",className:"rounded-[2rem] p-8 shadow-xl",children:[e.jsx(B,{size:24}),e.jsx(R,{className:"mt-2 text-md leading-relaxed",children:b??r("settingsPage.browserSection.description")}),e.jsx("div",{className:"mt-6",children:e.jsxs(h,{variant:"outline",className:"rounded-full px-6 transition-transform active:scale-95",onClick:I,children:[e.jsx(N,{className:"mr-2 h-4 w-4"}),r("sharedPage.retry")]})})]})}):e.jsxs("div",{className:"relative flex min-h-0 flex-1 flex-col overflow-hidden bg-background",children:[e.jsx(me,{children:(b||x||P)&&e.jsx(g.div,{initial:{opacity:0,y:-20,scale:.95},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:-20,scale:.95},className:"absolute left-1/2 top-6 z-50 -translate-x-1/2",children:b?e.jsxs("div",{className:"flex items-center gap-3 rounded-full border border-rose-500/20 bg-card/95 px-6 py-2.5 text-sm font-medium text-rose-600 shadow-2xl dark:bg-zinc-900/85",children:[e.jsx(B,{size:18}),b]}):e.jsxs("div",{className:"flex items-center gap-3 rounded-full border border-emerald-500/20 bg-card/95 px-6 py-2.5 text-sm font-medium text-emerald-600 shadow-2xl dark:bg-zinc-900/85",children:[e.jsx(k,{size:18}),P??r("commonToast.settingsSaved")]})})}),e.jsx(le,{className:"flex-1",children:e.jsxs("div",{className:"mx-auto max-w-[1240px] space-y-12 p-8 py-16",children:[e.jsxs(g.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:"flex flex-wrap items-end justify-between gap-6",children:[e.jsx("div",{className:"space-y-4",children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"flex h-12 w-12 items-center justify-center rounded-2xl bg-primary/10 text-primary",children:e.jsx(ge,{size:28})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl font-bold tracking-tight",children:r("settingsPage.browserSection.title")}),e.jsx("p",{className:"mt-1 text-muted-foreground",children:r("settingsPage.browserSection.description")})]})]})}),e.jsxs(h,{variant:"outline",className:"rounded-full border-border/70 bg-background/85 shadow-sm transition-all hover:bg-muted/50 active:scale-95 dark:border-white/[0.08] dark:bg-zinc-900/70 dark:hover:bg-zinc-900",onClick:I,disabled:l||c,children:[e.jsx(N,{className:w("mr-2 h-4 w-4",d&&"animate-spin")}),r("settings.refresh")]})]}),e.jsx(g.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:.1},children:e.jsxs(O,{className:"items-center rounded-3xl border-primary/10 bg-primary/[0.04] p-6 py-4 dark:border-primary/15 dark:bg-primary/[0.05]",children:[e.jsx(be,{className:"h-5 w-5 text-primary"}),e.jsxs(R,{className:"ml-2 text-sm",children:[e.jsx("span",{className:"font-semibold text-primary/80",children:r("settingsPage.browserSection.primaryTitle")})," ",r("settingsPage.browserSection.primaryDescription")]})]})}),e.jsx(g.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:.2},children:e.jsx(J,{title:r("settingsPage.browserSection.claude.title"),description:r("settingsPage.browserSection.claude.description"),action:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2 rounded-full border border-border/60 bg-muted/30 px-4 py-2 dark:border-white/[0.06] dark:bg-zinc-900/45",children:[e.jsx(f,{htmlFor:"browser-claude-enabled",className:"cursor-pointer text-xs font-semibold leading-none",children:t.claude.enabled?"ENABLED":"DISABLED"}),e.jsx(G,{id:"browser-claude-enabled",checked:t.claude.enabled,onCheckedChange:n=>m(u=>L(u??t,{enabled:n}))})]}),e.jsxs(h,{onClick:ae,disabled:l||z||!A,className:"rounded-full px-6 shadow-md transition-transform active:scale-95",children:[l?e.jsx(N,{className:"mr-2 h-4 w-4 animate-spin"}):e.jsx(k,{size:16,className:"mr-2"}),r("settingsPage.browserSection.actions.saveClaude")]}),e.jsxs(h,{variant:"outline",className:"rounded-full border-border/70 bg-background/85 shadow-sm transition-all hover:bg-muted/50 active:scale-95 dark:border-white/[0.08] dark:bg-zinc-900/70 dark:hover:bg-zinc-900",onClick:se,disabled:l||d||A||z,children:[e.jsx(he,{size:16,className:"mr-2"}),r("settingsPage.browserSection.actions.testConnection")]})]}),children:e.jsxs("div",{className:"grid gap-12",children:[e.jsx(K,{state:a.claude.state,title:a.claude.title,detail:a.claude.detail,nextStep:a.claude.nextStep}),e.jsxs("div",{className:"grid gap-8 lg:grid-cols-2",children:[e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsx(f,{htmlFor:"browser-claude-user-data-dir",className:"text-sm font-semibold tracking-wide text-muted-foreground/80",children:r("settingsPage.browserSection.claude.userDataDir")}),e.jsx(T,{id:"browser-claude-user-data-dir",value:t.claude.userDataDir,onChange:n=>m(u=>L(u??t,{userDataDir:n.target.value})),className:"rounded-xl border-border/70 bg-background/85 dark:border-white/[0.08] dark:bg-zinc-900/70",placeholder:a.claude.recommendedUserDataDir}),e.jsx("p",{className:"text-[11px] leading-relaxed text-muted-foreground/70",children:r("settingsPage.browserSection.claude.userDataDirHint")})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(f,{htmlFor:"browser-claude-devtools-port",className:"text-sm font-semibold tracking-wide text-muted-foreground/80",children:r("settingsPage.browserSection.claude.devtoolsPort")}),e.jsx(T,{id:"browser-claude-devtools-port",value:M,onChange:n=>C(n.target.value),inputMode:"numeric",className:"max-w-[120px] rounded-xl border-border/70 bg-background/85 dark:border-white/[0.08] dark:bg-zinc-900/70"}),e.jsx("p",{className:w("text-[11px] leading-relaxed text-muted-foreground/70",z&&"text-rose-500"),children:r(z?"settingsPage.browserSection.claude.devtoolsPortInvalid":"settingsPage.browserSection.claude.devtoolsPortHint")})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(f,{className:"text-sm font-semibold tracking-wide text-muted-foreground/80",children:r("settingsPage.browserSection.evalMode.label")}),e.jsxs($,{value:t.claude.evalMode,onValueChange:n=>m(u=>L(u??t,{evalMode:n})),children:[e.jsx(H,{className:"rounded-xl border-border/70 bg-background/85 dark:border-white/[0.08] dark:bg-zinc-900/70",children:e.jsx(F,{})}),e.jsx(U,{children:q.map(n=>e.jsx(V,{value:n,children:D(r,n)},n))})]}),e.jsx("p",{className:"text-[11px] leading-relaxed text-muted-foreground/70",children:r("settingsPage.browserSection.claude.evalModeHint")})]})]}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"group/launch relative overflow-hidden rounded-2xl border border-border/60 bg-muted/20 p-5 transition-all hover:bg-muted/35 dark:border-white/[0.06] dark:bg-zinc-900/35 dark:hover:bg-zinc-900/50",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-[11px] font-bold uppercase tracking-[0.15em] text-primary/70",children:r("settingsPage.browserSection.claude.launchGuidance")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:r("settingsPage.browserSection.claude.launchGuidanceHint")})]}),e.jsx(h,{variant:"ghost",size:"sm",className:"h-8 w-8 rounded-full p-0 transition-transform active:scale-90",onClick:de,disabled:!j,children:e.jsx(pe,{size:18})})]}),e.jsx("code",{className:"mt-4 block break-all rounded-lg border border-border/50 bg-background/80 p-3 font-mono text-[10px] leading-relaxed dark:border-white/[0.05] dark:bg-zinc-900/60",children:j})]}),a.claude.overrideActive&&e.jsxs("div",{className:"flex items-center gap-3 rounded-2xl border border-amber-500/10 bg-amber-500/[0.05] p-4 text-xs font-medium text-amber-700 dark:text-amber-300",children:[e.jsx(Q,{size:18}),r("settingsPage.browserSection.claude.overrideMessage",{source:a.claude.source})]})]})]}),e.jsx(W,{title:r("settingsPage.browserSection.technicalDetails"),defaultOpen:a.claude.state!=="ready",children:e.jsxs("div",{className:"grid gap-6 sm:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-[10px] font-bold uppercase tracking-widest text-muted-foreground/50",children:r("settingsPage.browserSection.claude.effectivePath")}),e.jsx("div",{className:"rounded-lg border border-border/50 bg-muted/25 p-3 dark:border-white/[0.05] dark:bg-zinc-900/45",children:e.jsx("p",{className:"break-all font-mono text-[11px] leading-relaxed",children:a.claude.effectiveUserDataDir})}),e.jsxs("p",{className:"text-[10px] font-medium text-muted-foreground/60",children:[e.jsxs("span",{className:"font-bold",children:[r("settingsPage.browserSection.claude.recommendedPath"),":"]})," ",a.claude.recommendedUserDataDir]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-[10px] font-bold uppercase tracking-widest text-muted-foreground/50",children:r("settingsPage.browserSection.claude.managedRuntime")}),e.jsxs("div",{className:"rounded-lg border border-border/50 bg-muted/25 p-3 dark:border-white/[0.05] dark:bg-zinc-900/45",children:[e.jsx("p",{className:"font-semibold text-primary/80",children:a.claude.managedMcpServerName}),e.jsx("p",{className:"mt-1 break-all font-mono text-[11px] leading-relaxed text-muted-foreground/80",children:a.claude.managedMcpServerPath})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-[10px] font-bold uppercase tracking-widest text-muted-foreground/50",children:r("settingsPage.browserSection.evalMode.label")}),e.jsx("div",{className:"rounded-lg border border-border/50 bg-muted/25 p-3 dark:border-white/[0.05] dark:bg-zinc-900/45",children:e.jsx("p",{className:"font-mono text-[11px] font-semibold",children:D(r,a.claude.evalMode)})})]})]})})]})})}),e.jsx(g.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:.3},children:e.jsx(J,{title:r("settingsPage.browserSection.codex.title"),description:r("settingsPage.browserSection.codex.description"),action:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2 rounded-full border border-border/60 bg-muted/30 px-4 py-2 dark:border-white/[0.06] dark:bg-zinc-900/45",children:[e.jsx(f,{htmlFor:"browser-codex-enabled",className:"cursor-pointer text-xs font-semibold leading-none",children:t.codex.enabled?"ENABLED":"DISABLED"}),e.jsx(G,{id:"browser-codex-enabled",checked:t.codex.enabled,onCheckedChange:n=>m(u=>X(u??t,{enabled:n}))})]}),e.jsxs(h,{onClick:te,disabled:l||!re,className:"rounded-full px-6 shadow-md transition-transform active:scale-95",children:[l?e.jsx(N,{className:"mr-2 h-4 w-4 animate-spin"}):e.jsx(k,{size:16,className:"mr-2"}),r("settingsPage.browserSection.actions.saveCodex")]})]}),children:e.jsxs("div",{className:"grid gap-12",children:[e.jsx(K,{state:a.codex.state,title:a.codex.title,detail:a.codex.detail,nextStep:a.codex.nextStep}),e.jsxs("div",{className:"max-w-md space-y-3",children:[e.jsx(f,{className:"text-sm font-semibold tracking-wide text-muted-foreground/80",children:r("settingsPage.browserSection.evalMode.label")}),e.jsxs($,{value:t.codex.evalMode,onValueChange:n=>m(u=>X(u??t,{evalMode:n})),children:[e.jsx(H,{className:"rounded-xl border-border/70 bg-background/85 dark:border-white/[0.08] dark:bg-zinc-900/70",children:e.jsx(F,{})}),e.jsx(U,{children:q.map(n=>e.jsx(V,{value:n,children:D(r,n)},n))})]}),e.jsx("p",{className:"text-[11px] leading-relaxed text-muted-foreground/70",children:r("settingsPage.browserSection.codex.evalModeHint")})]}),e.jsx(W,{title:r("settingsPage.browserSection.technicalDetails"),defaultOpen:a.codex.state==="unsupported_build",children:e.jsxs("div",{className:"grid gap-6 sm:grid-cols-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-[10px] font-bold uppercase tracking-widest text-muted-foreground/50",children:r("settingsPage.browserSection.codex.serverName")}),e.jsx("div",{className:"rounded-lg border border-border/50 bg-muted/25 p-3 dark:border-white/[0.05] dark:bg-zinc-900/45",children:e.jsx("p",{className:"font-mono text-[11px] font-semibold",children:a.codex.serverName})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-[10px] font-bold uppercase tracking-widest text-muted-foreground/50",children:r("settingsPage.browserSection.codex.overrideSupport")}),e.jsxs("div",{className:"flex items-center gap-2 rounded-lg border border-border/50 bg-muted/25 p-3 font-medium text-xs dark:border-white/[0.05] dark:bg-zinc-900/45",children:[a.codex.supportsConfigOverrides?e.jsx(k,{className:"text-emerald-500",size:16}):e.jsx(B,{className:"text-rose-500",size:16}),a.codex.supportsConfigOverrides?r("settingsPage.browserSection.codex.overrideSupported"):r("settingsPage.browserSection.codex.overrideUnsupported")]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-[10px] font-bold uppercase tracking-widest text-muted-foreground/50",children:r("settingsPage.browserSection.codex.binary")}),e.jsxs("div",{className:"rounded-lg border border-border/50 bg-muted/25 p-3 dark:border-white/[0.05] dark:bg-zinc-900/45",children:[e.jsx("p",{className:"break-all font-mono text-[11px] leading-relaxed",children:a.codex.binaryPath??r("settingsPage.browserSection.codex.notDetected")}),a.codex.version&&e.jsx("div",{className:"mt-2 inline-flex rounded-full bg-primary/10 px-2 py-0.5 text-[10px] font-bold text-primary",children:a.codex.version})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-[10px] font-bold uppercase tracking-widest text-muted-foreground/50",children:r("settingsPage.browserSection.evalMode.label")}),e.jsx("div",{className:"rounded-lg border border-border/50 bg-muted/25 p-3 dark:border-white/[0.05] dark:bg-zinc-900/45",children:e.jsx("p",{className:"font-mono text-[11px] font-semibold",children:D(r,a.codex.evalMode)})})]})]})})]})})})]})})]})}function L(r,s){return{...r,claude:{...r.claude,...s}}}function X(r,s){return{...r,codex:{...r.codex,...s}}}export{Oe as default};
1
+ import{j as e}from"./radix-ui-nu4wz29m.js";import{r as o}from"./react-vendor-Bjx91N7w.js";import{by as ie,bz as ne,Y as E,a as Y,bA as oe,bi as O,bk as R,d as h,n as le,c as w,L as f,I as T,r as $,s as H,t as F,v as U,w as V,aI as G,M as ce,N as ue,O as xe}from"./index-BRtgic66.js";import{m as g,A as me}from"./proxy-C4-M_9kB.js";import{R as N,I as B,x as k,ab as ge,_ as be,ba as pe,w as Q,$ as he,a6 as fe,e as we,s as je}from"./icons-DQFHtVq5.js";import"./tanstack-bhJxV1h8.js";import"./notifications-B4_o8bcr.js";import"./utils-CzKF5WmX.js";import"./form-utils-CuHzLhJZ.js";import"./code-highlight-D4E79GKQ.js";function ve(r,s){return{claude:{...r.claude,...s.claude},codex:{...r.codex,...s.codex}}}function Ne(){const{state:r}=ie(),s=ne(),i=o.useCallback(async()=>{try{s.setBrowserLoading(!0),s.setBrowserError(null);const d=await E.browser.get();s.setBrowserConfig(d.config),s.setBrowserStatus(d.status)}catch(d){s.setBrowserError(d.message)}finally{s.setBrowserLoading(!1),s.setBrowserStatusLoading(!1)}},[s]),a=o.useCallback(async()=>{try{s.setBrowserStatusLoading(!0),s.setBrowserError(null);const d=await E.browser.getStatus();return s.setBrowserStatus(d),d}catch(d){return s.setBrowserError(d.message),null}finally{s.setBrowserStatusLoading(!1)}},[s]),c=o.useCallback(async d=>{const l=r.browserConfig;if(!l)return!1;const b=ve(l,d);s.setBrowserConfig(b);try{s.setBrowserSaving(!0),s.setBrowserError(null);const x=await E.browser.update(d);return s.setBrowserConfig(x.browser.config),s.setBrowserStatus(x.browser.status),s.setBrowserSuccess(!0),window.setTimeout(()=>s.setBrowserSuccess(!1),1500),!0}catch(x){return s.setBrowserConfig(l),s.setBrowserError(x.message),!1}finally{s.setBrowserSaving(!1)}},[s,r.browserConfig]);return{config:r.browserConfig,status:r.browserStatus,loading:r.browserLoading,statusLoading:r.browserStatusLoading,saving:r.browserSaving,error:r.browserError,success:r.browserSuccess,fetchConfig:i,fetchStatus:a,saveConfig:c}}function ke(r){const s=r.toLowerCase();return s.includes("mac")?"darwin":s.includes("win")?"win32":"linux"}function ye(r=navigator){const s=typeof r.userAgentData?.platform=="string"?r.userAgentData.platform:"",i=typeof r.platform=="string"&&r.platform.trim()?r.platform:r.userAgent;return ke(s||i||"")}function Se(r){if(!/^\d+$/.test(r.trim()))return null;const s=Number.parseInt(r.trim(),10);return s<1||s>65535?null:s}const q=["disabled","readonly","readwrite"];function D(r,s){return r(`settingsPage.browserSection.evalMode.options.${s}`)}function Ce(r,s,i){const a=JSON.stringify(r);return i==="darwin"?`open -na "Google Chrome" --args --remote-debugging-port=${s} --user-data-dir=${a}`:i==="win32"?`chrome.exe --remote-debugging-port=${s} --user-data-dir=${a}`:`google-chrome --remote-debugging-port=${s} --user-data-dir=${a}`}function J({children:r,className:s,title:i,description:a,badge:c,action:d}){return e.jsx("div",{className:w("group relative overflow-hidden rounded-[2.5rem] border border-border/60 bg-muted/20 p-1.5 transition-all duration-700 ease-[cubic-bezier(0.32,0.72,0,1)] dark:border-white/[0.08] dark:bg-zinc-900/35",s),children:e.jsxs("div",{className:"relative overflow-hidden rounded-[calc(2.5rem-0.375rem)] border border-border/70 bg-card/90 shadow-[0_12px_36px_-18px_rgba(15,23,42,0.18)] dark:border-white/[0.08] dark:bg-zinc-900/70 dark:shadow-[0_18px_44px_-24px_rgba(0,0,0,0.55)]",children:[e.jsx("div",{className:"pointer-events-none absolute inset-0 shadow-[inset_0_1px_0_rgba(255,255,255,0.28)] dark:shadow-[inset_0_1px_0_rgba(255,255,255,0.04)]"}),(i||d)&&e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-4 border-b border-border/60 px-8 py-6 dark:border-white/[0.06]",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("h3",{className:"text-xl font-semibold tracking-tight",children:i}),c]}),a&&e.jsx("p",{className:"text-sm text-muted-foreground",children:a})]}),d&&e.jsx("div",{className:"flex items-center gap-2",children:d})]}),e.jsx("div",{className:"px-8 py-8",children:r})]})})}function K({state:r,title:s,detail:i,nextStep:a}){const{t:c}=Y(),d=r==="ready"||r==="enabled",l=!d&&r!=="disabled";return e.jsx("div",{className:w("relative overflow-hidden rounded-2xl border p-4 transition-all duration-500",d?"border-emerald-500/20 bg-emerald-500/[0.03] dark:bg-emerald-500/[0.02]":l?"border-amber-500/20 bg-amber-500/[0.03] dark:bg-amber-500/[0.02]":"border-border/60 bg-muted/30 dark:border-white/[0.06] dark:bg-zinc-900/45"),children:e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx("div",{className:w("flex h-10 w-10 shrink-0 items-center justify-center rounded-xl transition-transform duration-500 group-hover:scale-110",d?"bg-emerald-500/10 text-emerald-600":l?"bg-amber-500/10 text-amber-600":"bg-slate-500/10 text-slate-500"),children:d?e.jsx(k,{size:24}):l?e.jsx(Q,{size:24}):e.jsx(B,{size:24})}),e.jsxs("div",{className:"min-w-0 flex-1 space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm font-semibold uppercase tracking-wider text-muted-foreground/60",children:c("settingsPage.browserSection.readiness")}),d&&e.jsx(g.span,{animate:{opacity:[.4,1,.4]},transition:{duration:2,repeat:1/0},className:"h-1.5 w-1.5 rounded-full bg-emerald-500"})]}),e.jsx("h4",{className:"font-medium text-foreground",children:s}),e.jsx("p",{className:"text-sm leading-relaxed text-muted-foreground",children:i}),a&&e.jsxs("div",{className:"mt-3 flex items-start gap-2 rounded-lg border border-border/50 bg-muted/35 p-3 dark:border-white/[0.05] dark:bg-zinc-900/45",children:[e.jsx(fe,{size:14,className:"mt-0.5 shrink-0 text-primary"}),e.jsxs("p",{className:"text-xs leading-normal",children:[e.jsxs("span",{className:"font-semibold text-primary",children:[c("settingsPage.browserSection.nextStep"),":"]})," ",a]})]})]})]})})}function W({title:r,children:s,defaultOpen:i=!1}){const[a,c]=o.useState(i);return e.jsxs(ce,{open:a,onOpenChange:c,className:"overflow-hidden rounded-2xl border border-border/60 bg-muted/20 dark:border-white/[0.06] dark:bg-zinc-900/30",children:[e.jsx(ue,{asChild:!0,children:e.jsxs("button",{className:"flex w-full items-center justify-between px-6 py-4 text-sm font-medium transition-colors hover:bg-muted/40 dark:hover:bg-zinc-900/50",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(we,{size:16,className:"text-muted-foreground"}),r]}),e.jsx(je,{size:16,className:w("transition-transform duration-300",a&&"rotate-180")})]})}),e.jsx(xe,{children:e.jsx("div",{className:"border-t border-border/60 px-6 py-6 dark:border-white/[0.06]",children:s})})]})}function Oe(){const{t:r}=Y(),{fetchRawConfig:s}=oe(),{config:i,status:a,loading:c,statusLoading:d,saving:l,error:b,success:x,fetchConfig:y,fetchStatus:L,saveConfig:S}=Ne(),[Z,m]=o.useState(null),[ee,C]=o.useState(null),[P,p]=o.useState(null);o.useEffect(()=>{y()},[y]),o.useEffect(()=>{if(!P&&!x)return;const n=window.setTimeout(()=>p(null),2500);return()=>window.clearTimeout(n)},[P,x]);const t=Z??i,j=o.useMemo(()=>t?Ce(t.claude.userDataDir,t.claude.devtoolsPort,ye()):"",[t]),M=ee??String(t?.claude.devtoolsPort??9222),v=Se(M),z=M.trim().length>0&&v===null,_=i!==null&&t!==null&&(i.claude.enabled!==t.claude.enabled||i.claude.userDataDir!==t.claude.userDataDir||i.claude.devtoolsPort!==v||i.claude.evalMode!==t.claude.evalMode),re=i!==null&&t!==null&&(i.codex.enabled!==t.codex.enabled||i.codex.evalMode!==t.codex.evalMode),I=o.useCallback(async()=>{p(null),m(null),C(null),await Promise.all([y(),s()])},[y,s]),se=o.useCallback(async()=>{await L()&&p(r("settingsPage.browserSection.messages.statusRefreshed"))},[L,r]),ae=o.useCallback(async()=>{if(!t||v===null)return;await S({claude:{enabled:t.claude.enabled,userDataDir:t.claude.userDataDir.trim(),devtoolsPort:v,evalMode:t.claude.evalMode}})&&(await s(),p(null),m(null),C(null))},[v,t,s,S]),te=o.useCallback(async()=>{if(!t)return;await S({codex:{enabled:t.codex.enabled,evalMode:t.codex.evalMode}})&&(await s(),p(null),m(null),C(null))},[t,s,S]),de=o.useCallback(async()=>{j&&(await navigator.clipboard.writeText(j),p(r("settingsPage.browserSection.messages.launchCommandCopied")))},[j,r]);return c?e.jsx("div",{className:"flex flex-1 items-center justify-center",children:e.jsxs("div",{className:"flex flex-col items-center gap-4 text-muted-foreground",children:[e.jsx(g.div,{animate:{rotate:360},transition:{duration:1.5,repeat:1/0,ease:"linear"},children:e.jsx(N,{size:32})}),e.jsx("span",{className:"text-sm font-medium uppercase tracking-widest opacity-60",children:r("settings.loading")})]})}):!i||!a||!t?e.jsx("div",{className:"p-8",children:e.jsxs(O,{variant:"destructive",className:"rounded-[2rem] p-8 shadow-xl",children:[e.jsx(B,{size:24}),e.jsx(R,{className:"mt-2 text-md leading-relaxed",children:b??r("settingsPage.browserSection.description")}),e.jsx("div",{className:"mt-6",children:e.jsxs(h,{variant:"outline",className:"rounded-full px-6 transition-transform active:scale-95",onClick:I,children:[e.jsx(N,{className:"mr-2 h-4 w-4"}),r("sharedPage.retry")]})})]})}):e.jsxs("div",{className:"relative flex min-h-0 flex-1 flex-col overflow-hidden bg-background",children:[e.jsx(me,{children:(b||x||P)&&e.jsx(g.div,{initial:{opacity:0,y:-20,scale:.95},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:-20,scale:.95},className:"absolute left-1/2 top-6 z-50 -translate-x-1/2",children:b?e.jsxs("div",{className:"flex items-center gap-3 rounded-full border border-rose-500/20 bg-card/95 px-6 py-2.5 text-sm font-medium text-rose-600 shadow-2xl dark:bg-zinc-900/85",children:[e.jsx(B,{size:18}),b]}):e.jsxs("div",{className:"flex items-center gap-3 rounded-full border border-emerald-500/20 bg-card/95 px-6 py-2.5 text-sm font-medium text-emerald-600 shadow-2xl dark:bg-zinc-900/85",children:[e.jsx(k,{size:18}),P??r("commonToast.settingsSaved")]})})}),e.jsx(le,{className:"flex-1",children:e.jsxs("div",{className:"mx-auto max-w-[1240px] space-y-12 p-8 py-16",children:[e.jsxs(g.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:"flex flex-wrap items-end justify-between gap-6",children:[e.jsx("div",{className:"space-y-4",children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"flex h-12 w-12 items-center justify-center rounded-2xl bg-primary/10 text-primary",children:e.jsx(ge,{size:28})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl font-bold tracking-tight",children:r("settingsPage.browserSection.title")}),e.jsx("p",{className:"mt-1 text-muted-foreground",children:r("settingsPage.browserSection.description")})]})]})}),e.jsxs(h,{variant:"outline",className:"rounded-full border-border/70 bg-background/85 shadow-sm transition-all hover:bg-muted/50 active:scale-95 dark:border-white/[0.08] dark:bg-zinc-900/70 dark:hover:bg-zinc-900",onClick:I,disabled:l||c,children:[e.jsx(N,{className:w("mr-2 h-4 w-4",d&&"animate-spin")}),r("settings.refresh")]})]}),e.jsx(g.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:.1},children:e.jsxs(O,{className:"items-center rounded-3xl border-primary/10 bg-primary/[0.04] p-6 py-4 dark:border-primary/15 dark:bg-primary/[0.05]",children:[e.jsx(be,{className:"h-5 w-5 text-primary"}),e.jsxs(R,{className:"ml-2 text-sm",children:[e.jsx("span",{className:"font-semibold text-primary/80",children:r("settingsPage.browserSection.primaryTitle")})," ",r("settingsPage.browserSection.primaryDescription")]})]})}),e.jsx(g.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:.2},children:e.jsx(J,{title:r("settingsPage.browserSection.claude.title"),description:r("settingsPage.browserSection.claude.description"),action:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2 rounded-full border border-border/60 bg-muted/30 px-4 py-2 dark:border-white/[0.06] dark:bg-zinc-900/45",children:[e.jsx(f,{htmlFor:"browser-claude-enabled",className:"cursor-pointer text-xs font-semibold leading-none",children:t.claude.enabled?"ENABLED":"DISABLED"}),e.jsx(G,{id:"browser-claude-enabled",checked:t.claude.enabled,onCheckedChange:n=>m(u=>A(u??t,{enabled:n}))})]}),e.jsxs(h,{onClick:ae,disabled:l||z||!_,className:"rounded-full px-6 shadow-md transition-transform active:scale-95",children:[l?e.jsx(N,{className:"mr-2 h-4 w-4 animate-spin"}):e.jsx(k,{size:16,className:"mr-2"}),r("settingsPage.browserSection.actions.saveClaude")]}),e.jsxs(h,{variant:"outline",className:"rounded-full border-border/70 bg-background/85 shadow-sm transition-all hover:bg-muted/50 active:scale-95 dark:border-white/[0.08] dark:bg-zinc-900/70 dark:hover:bg-zinc-900",onClick:se,disabled:l||d||_||z,children:[e.jsx(he,{size:16,className:"mr-2"}),r("settingsPage.browserSection.actions.testConnection")]})]}),children:e.jsxs("div",{className:"grid gap-12",children:[e.jsx(K,{state:a.claude.state,title:a.claude.title,detail:a.claude.detail,nextStep:a.claude.nextStep}),e.jsxs("div",{className:"grid gap-8 lg:grid-cols-2",children:[e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsx(f,{htmlFor:"browser-claude-user-data-dir",className:"text-sm font-semibold tracking-wide text-muted-foreground/80",children:r("settingsPage.browserSection.claude.userDataDir")}),e.jsx(T,{id:"browser-claude-user-data-dir",value:t.claude.userDataDir,onChange:n=>m(u=>A(u??t,{userDataDir:n.target.value})),className:"rounded-xl border-border/70 bg-background/85 dark:border-white/[0.08] dark:bg-zinc-900/70",placeholder:a.claude.recommendedUserDataDir}),e.jsx("p",{className:"text-[11px] leading-relaxed text-muted-foreground/70",children:r("settingsPage.browserSection.claude.userDataDirHint")})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(f,{htmlFor:"browser-claude-devtools-port",className:"text-sm font-semibold tracking-wide text-muted-foreground/80",children:r("settingsPage.browserSection.claude.devtoolsPort")}),e.jsx(T,{id:"browser-claude-devtools-port",value:M,onChange:n=>C(n.target.value),inputMode:"numeric",className:"max-w-[120px] rounded-xl border-border/70 bg-background/85 dark:border-white/[0.08] dark:bg-zinc-900/70"}),e.jsx("p",{className:w("text-[11px] leading-relaxed text-muted-foreground/70",z&&"text-rose-500"),children:r(z?"settingsPage.browserSection.claude.devtoolsPortInvalid":"settingsPage.browserSection.claude.devtoolsPortHint")})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(f,{className:"text-sm font-semibold tracking-wide text-muted-foreground/80",children:r("settingsPage.browserSection.evalMode.label")}),e.jsxs($,{value:t.claude.evalMode,onValueChange:n=>m(u=>A(u??t,{evalMode:n})),children:[e.jsx(H,{className:"rounded-xl border-border/70 bg-background/85 dark:border-white/[0.08] dark:bg-zinc-900/70",children:e.jsx(F,{})}),e.jsx(U,{children:q.map(n=>e.jsx(V,{value:n,children:D(r,n)},n))})]}),e.jsx("p",{className:"text-[11px] leading-relaxed text-muted-foreground/70",children:r("settingsPage.browserSection.claude.evalModeHint")})]})]}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"group/launch relative overflow-hidden rounded-2xl border border-border/60 bg-muted/20 p-5 transition-all hover:bg-muted/35 dark:border-white/[0.06] dark:bg-zinc-900/35 dark:hover:bg-zinc-900/50",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-[11px] font-bold uppercase tracking-[0.15em] text-primary/70",children:r("settingsPage.browserSection.claude.launchGuidance")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:r("settingsPage.browserSection.claude.launchGuidanceHint")})]}),e.jsx(h,{variant:"ghost",size:"sm",className:"h-8 w-8 rounded-full p-0 transition-transform active:scale-90",onClick:de,disabled:!j,children:e.jsx(pe,{size:18})})]}),e.jsx("code",{className:"mt-4 block break-all rounded-lg border border-border/50 bg-background/80 p-3 font-mono text-[10px] leading-relaxed dark:border-white/[0.05] dark:bg-zinc-900/60",children:j})]}),a.claude.overrideActive&&e.jsxs("div",{className:"flex items-center gap-3 rounded-2xl border border-amber-500/10 bg-amber-500/[0.05] p-4 text-xs font-medium text-amber-700 dark:text-amber-300",children:[e.jsx(Q,{size:18}),r("settingsPage.browserSection.claude.overrideMessage",{source:a.claude.source})]})]})]}),e.jsx(W,{title:r("settingsPage.browserSection.technicalDetails"),defaultOpen:a.claude.state!=="ready",children:e.jsxs("div",{className:"grid gap-6 sm:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-[10px] font-bold uppercase tracking-widest text-muted-foreground/50",children:r("settingsPage.browserSection.claude.effectivePath")}),e.jsx("div",{className:"rounded-lg border border-border/50 bg-muted/25 p-3 dark:border-white/[0.05] dark:bg-zinc-900/45",children:e.jsx("p",{className:"break-all font-mono text-[11px] leading-relaxed",children:a.claude.effectiveUserDataDir})}),e.jsxs("p",{className:"text-[10px] font-medium text-muted-foreground/60",children:[e.jsxs("span",{className:"font-bold",children:[r("settingsPage.browserSection.claude.recommendedPath"),":"]})," ",a.claude.recommendedUserDataDir]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-[10px] font-bold uppercase tracking-widest text-muted-foreground/50",children:r("settingsPage.browserSection.claude.managedRuntime")}),e.jsxs("div",{className:"rounded-lg border border-border/50 bg-muted/25 p-3 dark:border-white/[0.05] dark:bg-zinc-900/45",children:[e.jsx("p",{className:"font-semibold text-primary/80",children:a.claude.managedMcpServerName}),e.jsx("p",{className:"mt-1 break-all font-mono text-[11px] leading-relaxed text-muted-foreground/80",children:a.claude.managedMcpServerPath})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-[10px] font-bold uppercase tracking-widest text-muted-foreground/50",children:r("settingsPage.browserSection.evalMode.label")}),e.jsx("div",{className:"rounded-lg border border-border/50 bg-muted/25 p-3 dark:border-white/[0.05] dark:bg-zinc-900/45",children:e.jsx("p",{className:"font-mono text-[11px] font-semibold",children:D(r,a.claude.evalMode)})})]})]})})]})})}),e.jsx(g.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:.3},children:e.jsx(J,{title:r("settingsPage.browserSection.codex.title"),description:r("settingsPage.browserSection.codex.description"),action:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2 rounded-full border border-border/60 bg-muted/30 px-4 py-2 dark:border-white/[0.06] dark:bg-zinc-900/45",children:[e.jsx(f,{htmlFor:"browser-codex-enabled",className:"cursor-pointer text-xs font-semibold leading-none",children:t.codex.enabled?"ENABLED":"DISABLED"}),e.jsx(G,{id:"browser-codex-enabled",checked:t.codex.enabled,onCheckedChange:n=>m(u=>X(u??t,{enabled:n}))})]}),e.jsxs(h,{onClick:te,disabled:l||!re,className:"rounded-full px-6 shadow-md transition-transform active:scale-95",children:[l?e.jsx(N,{className:"mr-2 h-4 w-4 animate-spin"}):e.jsx(k,{size:16,className:"mr-2"}),r("settingsPage.browserSection.actions.saveCodex")]})]}),children:e.jsxs("div",{className:"grid gap-12",children:[e.jsx(K,{state:a.codex.state,title:a.codex.title,detail:a.codex.detail,nextStep:a.codex.nextStep}),e.jsxs("div",{className:"max-w-md space-y-3",children:[e.jsx(f,{className:"text-sm font-semibold tracking-wide text-muted-foreground/80",children:r("settingsPage.browserSection.evalMode.label")}),e.jsxs($,{value:t.codex.evalMode,onValueChange:n=>m(u=>X(u??t,{evalMode:n})),children:[e.jsx(H,{className:"rounded-xl border-border/70 bg-background/85 dark:border-white/[0.08] dark:bg-zinc-900/70",children:e.jsx(F,{})}),e.jsx(U,{children:q.map(n=>e.jsx(V,{value:n,children:D(r,n)},n))})]}),e.jsx("p",{className:"text-[11px] leading-relaxed text-muted-foreground/70",children:r("settingsPage.browserSection.codex.evalModeHint")})]}),e.jsx(W,{title:r("settingsPage.browserSection.technicalDetails"),defaultOpen:a.codex.state==="unsupported_build",children:e.jsxs("div",{className:"grid gap-6 sm:grid-cols-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-[10px] font-bold uppercase tracking-widest text-muted-foreground/50",children:r("settingsPage.browserSection.codex.serverName")}),e.jsx("div",{className:"rounded-lg border border-border/50 bg-muted/25 p-3 dark:border-white/[0.05] dark:bg-zinc-900/45",children:e.jsx("p",{className:"font-mono text-[11px] font-semibold",children:a.codex.serverName})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-[10px] font-bold uppercase tracking-widest text-muted-foreground/50",children:r("settingsPage.browserSection.codex.overrideSupport")}),e.jsxs("div",{className:"flex items-center gap-2 rounded-lg border border-border/50 bg-muted/25 p-3 font-medium text-xs dark:border-white/[0.05] dark:bg-zinc-900/45",children:[a.codex.supportsConfigOverrides?e.jsx(k,{className:"text-emerald-500",size:16}):e.jsx(B,{className:"text-rose-500",size:16}),a.codex.supportsConfigOverrides?r("settingsPage.browserSection.codex.overrideSupported"):r("settingsPage.browserSection.codex.overrideUnsupported")]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-[10px] font-bold uppercase tracking-widest text-muted-foreground/50",children:r("settingsPage.browserSection.codex.binary")}),e.jsxs("div",{className:"rounded-lg border border-border/50 bg-muted/25 p-3 dark:border-white/[0.05] dark:bg-zinc-900/45",children:[e.jsx("p",{className:"break-all font-mono text-[11px] leading-relaxed",children:a.codex.binaryPath??r("settingsPage.browserSection.codex.notDetected")}),a.codex.version&&e.jsx("div",{className:"mt-2 inline-flex rounded-full bg-primary/10 px-2 py-0.5 text-[10px] font-bold text-primary",children:a.codex.version})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-[10px] font-bold uppercase tracking-widest text-muted-foreground/50",children:r("settingsPage.browserSection.evalMode.label")}),e.jsx("div",{className:"rounded-lg border border-border/50 bg-muted/25 p-3 dark:border-white/[0.05] dark:bg-zinc-900/45",children:e.jsx("p",{className:"font-mono text-[11px] font-semibold",children:D(r,a.codex.evalMode)})})]})]})})]})})})]})})]})}function A(r,s){return{...r,claude:{...r.claude,...s}}}function X(r,s){return{...r,codex:{...r.codex,...s}}}export{Oe as default};
@@ -1 +1 @@
1
- import{j as e}from"./radix-ui-Zb8sVEtn.js";import{r as g,c as ge}from"./react-vendor-CNOkPC89.js";import{u as U,a as $,C as j,b as y,S as f,c as x,P as v,B as K,d as z,e as se,f as je,g as te,h as ye,i as ae,j as w,k as L,l as Ne,m as we,n as be,o as ve}from"./index-0mNJhDEG.js";import{a3 as ke,am as ne,an as Q,ao as re,a1 as le,aa as Ce,G as Se,ap as De,R as Te,$ as V,U as Le,Z as ie,v as $e,ae as H,aq as Re,Y as Fe,C as Me,ar as Pe,as as Be}from"./icons-DyorC3Xk.js";import{a as Ae,u as O}from"./tanstack-CrmUhA7Z.js";import{K as P,L as oe,f as S,H as Ue}from"./utils-CzKF5WmX.js";import{R as ce,A as Oe,C as Ie,X as qe,Y as Z,T as de,a as X,P as Ke,b as Ee,c as _e}from"./charts-BBPXh0Ar.js";import"./notifications-B2HqRBj7.js";import"./form-utils-Bcoyqxpq.js";import"./code-highlight-BRUf_pqB.js";function Ge({data:s,isLoading:t}){const{privacyMode:a}=U(),{t:n}=$(),o=s?.totalTokens??0,r=s?.totalInputTokens??0,i=s?.totalOutputTokens??0,d=s?.totalCacheTokens??0,l=r+i;if(t)return e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-5 gap-4",children:[1,2,3,4,5].map(m=>e.jsx(j,{children:e.jsx(y,{className:"p-6",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(f,{className:"h-4 w-[100px]"}),e.jsx(f,{className:"h-8 w-[80px]"})]}),e.jsx(f,{className:"h-8 w-8 rounded-lg"})]})})},m))});const c=(s?.tokenBreakdown?.cacheCreation?.cost??0)+(s?.tokenBreakdown?.cacheRead?.cost??0),h=s?.totalCost?Math.round(c/s.totalCost*100):0,u=d>0&&o>l,p=d>0&&!u?"Total Tokens (I/O)":n("analyticsSummary.totalTokens"),D=u?`${T(r)} in / ${T(i)} out / ${T(d)} cache`:n("analyticsSummary.totalTokensSubtitle",{input:T(r),output:T(i)}),k=[{title:p,value:o,icon:ke,format:m=>T(m),color:"text-blue-600",bgColor:"bg-blue-100 dark:bg-blue-900/20",subtitle:D},{title:n("analyticsSummary.totalCost"),value:s?.totalCost??0,icon:ne,format:m=>`$${m.toFixed(2)}`,color:"text-green-600",bgColor:"bg-green-100 dark:bg-green-900/20",subtitle:n("analyticsSummary.totalCostSubtitle",{value:s?.averageCostPerDay?.toFixed(2)??"0.00"})},{title:n("analyticsSummary.cacheTokens"),value:s?.totalCacheTokens??0,icon:Q,format:m=>T(m),color:"text-cyan-600",bgColor:"bg-cyan-100 dark:bg-cyan-900/20",subtitle:n("analyticsSummary.cacheTokensSubtitle",{cost:c.toFixed(2),percent:h})},{title:n("analyticsSummary.inputCost"),value:s?.tokenBreakdown?.input?.cost??0,icon:re,format:m=>`$${m.toFixed(2)}`,color:"text-purple-600",bgColor:"bg-purple-100 dark:bg-purple-900/20",subtitle:n("analyticsSummary.tokensSubtitle",{value:T(s?.tokenBreakdown?.input?.tokens??0)})},{title:n("analyticsSummary.outputCost"),value:s?.tokenBreakdown?.output?.cost??0,icon:le,format:m=>`$${m.toFixed(2)}`,color:"text-orange-600",bgColor:"bg-orange-100 dark:bg-orange-900/20",subtitle:n("analyticsSummary.tokensSubtitle",{value:T(s?.tokenBreakdown?.output?.tokens??0)})}];return e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-5 gap-4",children:k.map((m,b)=>{const C=m.icon;return e.jsx(j,{className:"hover:shadow-md transition-shadow",children:e.jsx(y,{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:m.title}),e.jsx("p",{className:x("text-xl font-bold truncate",a&&v),children:m.format(m.value)}),m.subtitle&&e.jsx("p",{className:x("text-[10px] text-muted-foreground truncate",a&&v),children:m.subtitle})]}),e.jsx("div",{className:x("p-2 rounded-lg shrink-0",m.bgColor),children:e.jsx(C,{className:x("h-4 w-4",m.color)})})]})})},b)})})}function T(s){return s>=1e6?`${(s/1e6).toFixed(1)}M`:s>=1e3?`${(s/1e3).toFixed(1)}K`:s.toLocaleString()}function He({model:s}){const{privacyMode:t}=U(),{t:a}=$(),n=We(s.ioRatio),r=s.cacheCreationTokens+s.cacheReadTokens>0?"All Tokens":a("analyticsCards.totalTokens");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(Ce,{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(K,{variant:"secondary",className:"text-[10px] h-5 px-1.5",children:[s.percentage.toFixed(1),"% usage"]}),e.jsxs(K,{variant:n.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:x("text-lg font-bold",t&&v),children:["$",s.cost.toFixed(2)]}),e.jsx("p",{className:"text-[10px] text-muted-foreground uppercase tracking-wider",children:a("analyticsCards.totalCost")})]}),e.jsxs("div",{className:"p-2 rounded-md bg-muted/50 border text-center",children:[e.jsx("p",{className:x("text-lg font-bold",t&&v),children:Ye(s.tokens)}),e.jsx("p",{className:"text-[10px] text-muted-foreground uppercase tracking-wider",children:r})]})]}),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:x("space-y-1",t&&v),children:[e.jsx(W,{label:"Input",tokens:s.inputTokens,cost:s.costBreakdown.input.cost,color:"#335c67",icon:re}),e.jsx(W,{label:"Output",tokens:s.outputTokens,cost:s.costBreakdown.output.cost,color:"#fff3b0",icon:le}),e.jsx(W,{label:"Cache Write",tokens:s.cacheCreationTokens,cost:s.costBreakdown.cacheCreation.cost,color:"#e09f3e",icon:Q}),e.jsx(W,{label:"Cache Read",tokens:s.cacheReadTokens,cost:s.costBreakdown.cacheRead.cost,color:"#9e2a2b",icon:Q})]})]}),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(Se,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsx("span",{className:"text-xs font-medium",children:a("analyticsCards.inputOutputRatio")})]}),e.jsx("p",{className:"text-[11px] text-muted-foreground leading-snug",children:n.description})]})]})}function W({label:s,tokens:t,cost:a,color:n,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:n}}),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:ze(t)})]})]})]})}function We(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 ze(s){return s.toLocaleString()}function Ye(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()}const Qe="/api";function N(s){const t=s.getFullYear(),a=String(s.getMonth()+1).padStart(2,"0"),n=String(s.getDate()).padStart(2,"0");return`${t}${a}${n}`}function M(s,t){const a=t.toString();return a?`${s}?${a}`:s}const B={summary:s=>{const t=new URLSearchParams;return s?.startDate&&t.append("since",N(s.startDate)),s?.endDate&&t.append("until",N(s.endDate)),R(M("/usage/summary",t))},trends:s=>{const t=new URLSearchParams;return s?.startDate&&t.append("since",N(s.startDate)),s?.endDate&&t.append("until",N(s.endDate)),R(M("/usage/daily",t))},hourly:s=>{const t=new URLSearchParams;return s?.startDate&&t.append("since",N(s.startDate)),s?.endDate&&t.append("until",N(s.endDate)),R(M("/usage/hourly",t))},models:s=>{const t=new URLSearchParams;return s?.startDate&&t.append("since",N(s.startDate)),s?.endDate&&t.append("until",N(s.endDate)),R(M("/usage/models",t))},sessions:s=>{const t=new URLSearchParams;return s?.startDate&&t.append("since",N(s.startDate)),s?.endDate&&t.append("until",N(s.endDate)),s?.limit&&t.append("limit",s.limit.toString()),s?.offset&&t.append("offset",s.offset.toString()),R(M("/usage/sessions",t))},monthly:s=>{const t=new URLSearchParams;return s?.startDate&&t.append("since",N(s.startDate)),s?.endDate&&t.append("until",N(s.endDate)),R(M("/usage/monthly",t))},refresh:async()=>{if(!(await fetch(`${Qe}/usage/refresh`,{method:"POST",headers:{"Content-Type":"application/json"}})).ok)throw new Error("Failed to refresh usage cache")},status:()=>R("/usage/status"),insights:s=>{const t=new URLSearchParams;return s?.startDate&&t.append("since",N(s.startDate)),s?.endDate&&t.append("until",N(s.endDate)),R(M("/usage/insights",t))}};async function R(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 n=await a.json();return n.data||n}function Ve(s){return O({queryKey:["usage","summary",s],queryFn:()=>B.summary(s),staleTime:60*1e3})}function Ze(s){return O({queryKey:["usage","trends",s],queryFn:()=>B.trends(s),staleTime:60*1e3})}function Xe(s){return O({queryKey:["usage","hourly",s],queryFn:()=>B.hourly(s),staleTime:60*1e3})}function Je(s){return O({queryKey:["usage","models",s],queryFn:()=>B.models(s),staleTime:60*1e3})}function es(){const s=Ae();return g.useCallback(async()=>{await B.refresh(),await s.invalidateQueries({queryKey:["usage"]})},[s])}function ss(){return O({queryKey:["usage","status"],queryFn:()=>B.status(),staleTime:10*1e3,refetchInterval:30*1e3})}function ts(s){return O({queryKey:["usage","sessions",s],queryFn:()=>B.sessions(s),staleTime:60*1e3})}const as=50;function ns(){const[s,t]=g.useState({from:P(new Date,30),to:new Date}),[a,n]=g.useState(!1),[o,r]=g.useState(null),[i,d]=g.useState(null),[l,c]=g.useState("daily"),h=es(),u=g.useCallback(async()=>{n(!0);try{await h()}finally{n(!1)}},[h]),p=g.useMemo(()=>({startDate:s?.from,endDate:s?.to}),[s?.from,s?.to]),{data:D,isLoading:k}=Ve(p),{data:m,isLoading:b}=Ze(p),{data:C,isLoading:I}=Xe(p),{data:F,isLoading:q}=Je(p),{data:Y,isLoading:E}=ts({...p,limit:as}),{data:_}=ss(),xe=g.useCallback(()=>{const A=new Date;t({from:P(A,1),to:A}),c("hourly")},[]),ue=g.useCallback(A=>{t(A),c("daily")},[]),me=g.useMemo(()=>_?.lastFetch?oe(new Date(_.lastFetch),{addSuffix:!0}):null,[_?.lastFetch]),he=g.useCallback((A,pe)=>{const G=pe.currentTarget.getBoundingClientRect();d({x:G.left+G.width/2,y:G.top+G.height/2}),r(A)},[]),fe=g.useCallback(()=>{r(null),d(null)},[]);return{dateRange:s,isRefreshing:a,viewMode:l,selectedModel:o,popoverPosition:i,summary:D,trends:m,hourlyData:C,models:F,sessions:Y,status:_,isSummaryLoading:k,isTrendsLoading:b,isHourlyLoading:I,isModelsLoading:q,isSessionsLoading:E,isLoading:k||b||q||E,handleRefresh:u,handleTodayClick:xe,handleDateRangeChange:ue,handleModelClick:he,handlePopoverClose:fe,lastUpdatedText:me}}function rs({value:s,onChange:t,presets:a=[{label:"Last 7 days",range:{from:P(new Date,7),to:new Date}},{label:"Last 30 days",range:{from:P(new Date,30),to:new Date}},{label:"Last 90 days",range:{from:P(new Date,90),to:new Date}}],className:n}){const[o,r]=ge.useState(!1),{t:i}=$(),d=l=>!s||!s.from||!s.to||!l.from||!l.to?!1:S(s.from,"yyyy-MM-dd")===S(l.from,"yyyy-MM-dd")&&S(s.to,"yyyy-MM-dd")===S(l.to,"yyyy-MM-dd");return e.jsxs("div",{className:x("flex flex-wrap items-center gap-2",n),children:[a.map(l=>e.jsx(z,{variant:d(l.range)?"default":"outline",size:"sm",onClick:()=>t(l.range),children:l.label},l.label)),e.jsxs(se,{open:o,onOpenChange:r,children:[e.jsx(je,{asChild:!0,children:e.jsxs(z,{id:"date",variant:"outline",className:x("w-auto min-w-[200px] sm:min-w-[240px] justify-start text-left font-normal",!s&&"text-muted-foreground"),children:[e.jsx(De,{className:"mr-2 h-4 w-4"}),s?.from?s.to?e.jsxs(e.Fragment,{children:[S(s.from,"LLL dd, y")," - ",S(s.to,"LLL dd, y")]}):S(s.from,"LLL dd, y"):e.jsx("span",{children:i("dateRangeFilter.pickADate")})]})}),e.jsx(te,{className:"w-auto p-0",align:"end",children:e.jsx(ye,{initialFocus:!0,mode:"range",defaultMonth:s?.from,selected:s,onSelect:t,numberOfMonths:2})})]})]})}function ls({dateRange:s,onDateRangeChange:t,onTodayClick:a,onRefresh:n,isRefreshing:o,lastUpdatedText:r,viewMode:i}){const{t:d}=$();return e.jsxs("div",{className:"flex flex-col gap-3 shrink-0 xl:flex-row xl:items-center xl:justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl font-semibold",children:d("analytics.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:d("analytics.subtitle")})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 xl:justify-end",children:[e.jsx(z,{variant:i==="hourly"?"default":"outline",size:"sm",className:"h-8",onClick:a,children:"24H"}),e.jsx(rs,{className:"flex-wrap",value:s,onChange:t,presets:[{label:"7D",range:{from:P(new Date,7),to:new Date}},{label:"30D",range:{from:P(new Date,30),to:new Date}},{label:d("analytics.month"),range:{from:Ue(new Date),to:new Date}},{label:d("analytics.allTime"),range:{from:void 0,to:new Date}}]}),r&&e.jsx("span",{className:"text-xs text-muted-foreground whitespace-nowrap",children:d("analytics.updated",{value:r})}),e.jsx(z,{variant:"outline",size:"sm",className:"gap-2 h-8",onClick:n,disabled:o,children:e.jsx(Te,{className:`w-3.5 h-3.5 ${o?"animate-spin":""}`})})]})]})}function is({data:s,isLoading:t,granularity:a="daily",className:n}){const{privacyMode:o}=U(),{t:r}=$(),i=g.useMemo(()=>!s||s.length===0?[]:s.map(c=>{const h="hour"in c?c.hour:c.date;return{...c,dateFormatted:os(h,a),costRounded:Number(c.cost.toFixed(4))}}),[s,a]);if(t)return e.jsx(f,{className:x("h-full w-full",n)});if(!s||s.length===0)return e.jsx("div",{className:x("h-full flex items-center justify-center",n),children:e.jsx("p",{className:"text-muted-foreground",children:r(a==="hourly"?"analytics.noDailyUsage":"analytics.noUsageData")})});const d=({x:l,y:c,payload:h,isRight:u})=>{const p=u?`$${h.value}`:J(Number(h.value));return e.jsx("text",{x:l,y:c,dy:4,textAnchor:u?"start":"end",fontSize:12,fill:"currentColor",className:x("fill-muted-foreground",o&&"blur-[4px]"),children:p})};return e.jsx("div",{className:x("w-full h-full",n),children:e.jsx(ce,{width:"100%",height:"100%",children:e.jsxs(Oe,{data:i,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(Ie,{strokeDasharray:"3 3",className:"stroke-muted"}),e.jsx(qe,{dataKey:"dateFormatted",tick:{fontSize:12},tickLine:!1,axisLine:{className:"stroke-muted"}}),e.jsx(Z,{yAxisId:"left",orientation:"left",tick:l=>e.jsx(d,{...l,isRight:!1}),tickLine:!1,axisLine:{className:"stroke-muted"}}),e.jsx(Z,{yAxisId:"right",orientation:"right",tick:l=>e.jsx(d,{...l,isRight:!0}),tickLine:!1,axisLine:{className:"stroke-muted"}}),e.jsx(de,{content:({active:l,payload:c,label:h})=>!l||!c||!c.length?null:e.jsxs("div",{className:"rounded-lg border bg-background p-3 shadow-lg",children:[e.jsx("p",{className:"font-medium mb-2",children:h}),c.map((u,p)=>e.jsxs("p",{className:x("text-sm",o&&v),style:{color:u.color},children:[u.name,":"," ",u.name==="Tokens"?J(Number(u.value)||0):`$${u.value}`]},p))]})}),e.jsx(X,{yAxisId:"left",type:"monotone",dataKey:"tokens",stroke:"#0080FF",strokeWidth:2,fillOpacity:1,fill:"url(#tokenGradient)",name:"Tokens"}),e.jsx(X,{yAxisId:"right",type:"monotone",dataKey:"costRounded",stroke:"#00C49F",strokeWidth:2,fillOpacity:1,fill:"url(#costGradient)",name:"Cost"})]})})})}function os(s,t){if(t==="hourly"){const[n,o]=s.split(" ");if(n&&o){const r=new Date(`${n}T${o}:00Z`);return S(r,"HH:mm")}return s}const a=new Date(s);return t==="monthly"?S(a,"MMM yyyy"):S(a,"MMM dd")}function J(s){return s>=1e6?`${(s/1e6).toFixed(1)}M`:s>=1e3?`${(s/1e3).toFixed(1)}K`:s.toLocaleString()}function cs({data:s,isLoading:t,className:a}){const{privacyMode:n}=U(),{t:o}=$(),r=g.useMemo(()=>!s||s.length===0?[]:s.map(l=>({name:l.model,value:l.tokens,cost:l.cost,percentage:l.percentage,fill:ae(l.model)})),[s]);if(t)return e.jsx(f,{className:x("h-full min-h-[100px] w-full",a)});if(!s||s.length===0)return e.jsx("div",{className:x("h-full min-h-[100px] flex items-center justify-center",a),children:e.jsx("p",{className:"text-muted-foreground",children:o("analyticsCards.noModelData")})});const i=({active:l,payload:c})=>{if(!l||!c)return null;const h=c;if(!h.length)return null;const u=h[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:u.name}),e.jsxs("p",{className:x("text-muted-foreground",n&&v),children:[ds(u.value)," (",u.percentage.toFixed(1),"%)"]}),e.jsxs("p",{className:x("text-muted-foreground",n&&v),children:["$",u.cost.toFixed(4)]})]})},d=l=>l.percentage>5?`${l.percentage.toFixed(1)}%`:"";return e.jsx("div",{className:x("w-full h-full min-h-[100px]",a),children:e.jsx(ce,{width:"100%",height:"100%",children:e.jsxs(Ke,{children:[e.jsx(Ee,{data:r,cx:"50%",cy:"50%",labelLine:!1,label:d,innerRadius:50,outerRadius:70,paddingAngle:2,dataKey:"value",children:r.map((l,c)=>e.jsx(_e,{fill:l.fill,strokeWidth:1},`cell-${c}`))}),e.jsx(de,{content:i})]})})})}function ds(s){return s>=1e6?`${(s/1e6).toFixed(1)}M`:s>=1e3?`${(s/1e3).toFixed(1)}K`:s.toLocaleString()}function xs(s){if(!s)return"";const a=s.replace(/^\/|\/$/g,"").split("/").filter(n=>n.length>0);return a[a.length-1]||""}function us({data:s,isLoading:t,className:a}){const{privacyMode:n}=U(),{t:o}=$(),r=g.useMemo(()=>{if(!s?.sessions||s.sessions.length===0)return null;const i=s.sessions,d=s.total,l=i.length,c=s.hasMore||s.offset>0,u=i.reduce((p,D)=>p+D.cost,0)/i.length;return{displayedSessions:c?l:d,totalSessions:d,avgCost:u,hasPartialSample:c,recentSessions:i.slice(0,3)}},[s]);return t?e.jsxs(j,{className:x("flex flex-col h-full min-h-0 overflow-hidden gap-0 py-0",a),children:[e.jsx(w,{className:"px-3 py-2",children:e.jsx(f,{className:"h-5 w-32"})}),e.jsx(y,{className:"px-3 pb-3 pt-0 flex-1",children:e.jsx(f,{className:"h-full w-full"})})]}):r?e.jsxs(j,{className:x("flex flex-col h-full min-h-0 overflow-hidden gap-0 py-0 shadow-sm",a),children:[e.jsx(w,{className:"px-3 py-2",children:e.jsxs(L,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(V,{className:"w-4 h-4"}),"Session Stats"]})}),e.jsxs(y,{className:"px-3 pb-3 pt-0 flex-1 min-h-0 flex flex-col gap-3",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:r.displayedSessions})]}),e.jsx("p",{className:"text-[10px] text-muted-foreground uppercase tracking-wider mt-0.5",children:r.hasPartialSample?"Sampled Sessions":"Total Sessions"}),r.hasPartialSample&&e.jsxs("p",{className:"text-[10px] text-muted-foreground mt-0.5",children:[r.totalSessions," total"]})]}),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(ie,{className:"w-4 h-4"}),e.jsxs("span",{className:x("text-xl font-bold",n&&v),children:["$",r.avgCost.toFixed(2)]})]}),e.jsx("p",{className:"text-[10px] text-muted-foreground uppercase tracking-wider mt-0.5",children:r.hasPartialSample?"Recent Avg Cost":"Avg Cost/Session"})]})]}),e.jsxs("div",{className:"flex-1 min-h-0 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($e,{className:"w-3 h-3"}),"Recent Activity"]}),e.jsx("div",{className:"space-y-1.5 max-h-full overflow-y-auto pr-1",children:r.recentSessions.map(i=>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.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"font-medium truncate",title:i.projectPath,children:xs(i.projectPath)}),(i.target??"claude")!=="claude"&&e.jsx("span",{className:"shrink-0 px-1 py-0 text-[9px] font-medium rounded bg-purple-100 text-purple-700 dark:bg-purple-900/30 dark:text-purple-300 uppercase",children:i.target})]}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:oe(new Date(i.lastActivity),{addSuffix:!0})})]}),e.jsxs("div",{className:x("text-right shrink-0 ml-2",n&&v),children:[e.jsxs("div",{className:"font-mono",children:["$",i.cost.toFixed(2)]}),e.jsxs("div",{className:"text-[10px] text-muted-foreground",children:[ms(i.tokens??i.inputTokens+i.outputTokens)," ","toks"]})]})]},i.sessionId))})]})]})]}):e.jsxs(j,{className:x("flex flex-col h-full min-h-0 overflow-hidden gap-0 py-0",a),children:[e.jsx(w,{className:"px-3 py-2",children:e.jsxs(L,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(V,{className:"w-4 h-4"}),"Session Stats"]})}),e.jsx(y,{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:o("analyticsCards.noSessionData")})})]})}function ms(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 hs({className:s,isLoading:t}){const{data:a,isLoading:n}=Ne(),{data:o,isLoading:r,error:i}=we(a?.running),{t:d}=$();if(t||n||a?.running&&r)return e.jsxs(j,{className:x("flex flex-col h-full min-h-0 overflow-hidden gap-0 py-0",s),children:[e.jsx(w,{className:"px-3 py-2",children:e.jsxs(L,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(H,{className:"h-4 w-4"}),"CLIProxy Stats"]})}),e.jsx(y,{className:"px-3 pb-3 pt-0 flex-1",children:e.jsxs("div",{className:"space-y-3",children:[e.jsx(f,{className:"h-4 w-[100px]"}),e.jsx(f,{className:"h-16 w-full"})]})})]});if(!a?.running)return e.jsxs(j,{className:x("flex flex-col h-full min-h-0 overflow-hidden gap-0 py-0 border-dashed",s),children:[e.jsx(w,{className:"px-3 py-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(L,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(H,{className:"h-4 w-4 text-muted-foreground"}),"CLIProxy Stats"]}),e.jsx(K,{variant:"secondary",className:"text-[10px] h-5",children:d("cliproxyStatsOverview.offline")})]})}),e.jsx(y,{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:d("cliproxyStatsOverview.noActiveSessionHint")})})]});if(i)return e.jsxs(j,{className:x("flex flex-col h-full min-h-0 overflow-hidden gap-0 py-0 border-destructive/50",s),children:[e.jsx(w,{className:"px-3 py-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(L,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(H,{className:"h-4 w-4"}),"CLIProxy Stats"]}),e.jsx(K,{variant:"destructive",className:"text-[10px] h-5",children:"Error"})]})}),e.jsx(y,{className:"px-3 pb-3 pt-0 flex-1",children:e.jsx("p",{className:"text-xs text-destructive",children:i.message})})]});const c=o?.totalRequests??0,h=o?.quotaExceededCount??0,u=c-h,p=c>0?Math.round(u/c*100):100,D=o?.tokens?.total??0,k=Object.entries(o?.requestsByModel??{}).sort((b,C)=>C[1]-b[1]).slice(0,4),m=k.length>0?k[0][1]:1;return e.jsxs(j,{className:x("flex flex-col h-full min-h-0 overflow-hidden gap-0 py-0",s),children:[e.jsx(w,{className:"px-3 py-2 border-b bg-muted/5",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(L,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(H,{className:"h-4 w-4"}),"CLIProxy Stats"]}),e.jsxs(K,{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(ie,{className:"h-3 w-3 mr-0.5"}),d("cliproxyStatsOverview.running")]})]})}),e.jsx(y,{className:"p-0 flex-1 min-h-0",children:e.jsx(be,{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:`${p*.88} 88`,strokeLinecap:"round",className:p>=90?"text-green-500":"text-amber-500"})]}),e.jsxs("span",{className:"absolute inset-0 flex items-center justify-center text-[8px] font-bold",children:[p,"%"]})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-lg font-bold leading-none",children:ee(c)}),e.jsx("div",{className:"text-[9px] text-muted-foreground mt-0.5",children:h>0?`${h} 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(Re,{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:ee(D)}),e.jsx("div",{className:"text-[9px] text-muted-foreground mt-0.5",children:d("cliproxyStatsOverview.totalTokens")})]})]})]}),k.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(Fe,{className:"h-3 w-3"}),d("cliproxyStatsOverview.modelsUsed")]}),e.jsx("div",{className:"space-y-1",children:k.map(([b,C])=>{const I=Math.round(C/m*100),F=fs(b);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:b,children:F}),e.jsx("span",{className:"text-muted-foreground shrink-0 ml-2",children:C})]}),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:`${I}%`}})})]},b)})})]})]})})})]})}function ee(s){return s>=1e6?`${(s/1e6).toFixed(1)}M`:s>=1e3?`${(s/1e3).toFixed(1)}K`:s.toLocaleString()}function fs(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}function ps(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 gs({models:s,isLoading:t,onModelClick:a,privacyMode:n}){const{t:o}=$();return e.jsxs(j,{className:"flex flex-col h-full min-h-0 overflow-hidden gap-0 py-0 shadow-sm lg:col-span-4",children:[e.jsx(w,{className:"px-3 py-2",children:e.jsxs(L,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(ne,{className:"w-4 h-4"}),o("analyticsPages.costByModel")]})}),e.jsx(y,{className:"px-2 pb-2 pt-0 flex-1 min-h-0 overflow-y-auto",children:t?e.jsx(f,{className:"h-full w-full"}):e.jsxs("div",{className:"space-y-0.5",children:[[...s||[]].sort((r,i)=>i.cost-r.cost).map(r=>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:i=>a(r,i),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:ae(r.model)}}),e.jsx("span",{className:"font-medium truncate group-hover:underline underline-offset-2",children:r.model})]}),e.jsx(js,{model:r}),e.jsx("span",{className:x("text-[10px] text-muted-foreground w-14 text-right shrink-0",n&&v),children:ps(r.tokens)}),e.jsxs("span",{className:x("font-mono font-medium w-16 text-right shrink-0",n&&v),children:["$",r.cost.toFixed(2)]}),e.jsx(Me,{className:"w-3 h-3 opacity-0 group-hover:opacity-50 transition-opacity shrink-0"})]},r.model)),e.jsx(ys,{})]})})]})}function js({model:s}){const t={input:"#335c67",output:"#fff3b0",cacheWrite:"#e09f3e",cacheRead:"#9e2a2b"},a=n=>s.cost>0?n/s.cost*100:0;return 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:t.input,width:`${a(s.costBreakdown.input.cost)}%`},title:`Input: $${s.costBreakdown.input.cost.toFixed(2)}`}),e.jsx("div",{className:"h-full",style:{backgroundColor:t.output,width:`${a(s.costBreakdown.output.cost)}%`},title:`Output: $${s.costBreakdown.output.cost.toFixed(2)}`}),e.jsx("div",{className:"h-full",style:{backgroundColor:t.cacheWrite,width:`${a(s.costBreakdown.cacheCreation.cost)}%`},title:`Cache Write: $${s.costBreakdown.cacheCreation.cost.toFixed(2)}`}),e.jsx("div",{className:"h-full",style:{backgroundColor:t.cacheRead,width:`${a(s.costBreakdown.cacheRead.cost)}%`},title:`Cache Read: $${s.costBreakdown.cacheRead.cost.toFixed(2)}`})]})})}function ys(){const s=[{color:"#335c67",label:"Input"},{color:"#fff3b0",label:"Output",hasBorder:!0},{color:"#e09f3e",label:"Cache Write"},{color:"#9e2a2b",label:"Cache Read"}];return e.jsx("div",{className:"flex items-center gap-3 pt-2 px-2 text-[10px] text-muted-foreground border-t mt-2",children:s.map(({color:t,label:a,hasBorder:n})=>e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx("div",{className:x("w-2 h-2 rounded-full",n&&"border border-muted-foreground/30"),style:{backgroundColor:t}}),a]},a))})}function Ns({viewMode:s,trends:t,hourlyData:a,models:n,sessions:o,isTrendsLoading:r,isHourlyLoading:i,isModelsLoading:d,isSessionsLoading:l,isSummaryLoading:c,onModelClick:h}){const{privacyMode:u}=U();return e.jsxs("div",{className:"min-h-0 grid gap-4 lg:grid-rows-[minmax(260px,1.2fr)_minmax(220px,0.9fr)]",children:[e.jsxs(j,{className:"flex flex-col h-full min-h-[220px] lg:min-h-[240px] overflow-hidden gap-0 py-0 shadow-sm",children:[e.jsx(w,{className:"px-3 py-2 shrink-0",children:e.jsxs(L,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(Pe,{className:"w-4 h-4"}),s==="hourly"?"Last 24 Hours":"Usage Trends"]})}),e.jsx(y,{className:"px-3 pb-3 pt-0 flex-1 min-h-0",children:e.jsx(is,{data:s==="hourly"?a||[]:t||[],isLoading:s==="hourly"?i:r,granularity:s==="hourly"?"hourly":"daily"})})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-10 gap-4 h-auto min-h-[220px] lg:h-full lg:min-h-[220px] lg:grid-rows-[minmax(0,1fr)] lg:[&>*]:min-h-0",children:[e.jsx(gs,{models:n,isLoading:d,onModelClick:h,privacyMode:u}),e.jsxs(j,{className:"flex flex-col h-full min-h-0 overflow-hidden gap-0 py-0 shadow-sm lg:col-span-2",children:[e.jsx(w,{className:"px-3 py-2",children:e.jsxs(L,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(Be,{className:"w-4 h-4"}),"Model Usage"]})}),e.jsx(y,{className:"px-2 pb-2 pt-0 flex-1 min-h-0 flex items-center justify-center",children:e.jsx(cs,{data:n||[],isLoading:d,className:"h-full w-full"})})]}),e.jsx(us,{data:o,isLoading:l,className:"lg:col-span-2"}),e.jsx(hs,{isLoading:c,className:"lg:col-span-2"})]})]})}function Rs(){return e.jsxs("div",{className:"space-y-4 h-full overflow-hidden",children:[e.jsxs(j,{className:"flex flex-col min-h-[300px]",children:[e.jsx(w,{className:"p-4 pb-2",children:e.jsx(f,{className:"h-4 w-32"})}),e.jsx(y,{className:"p-4 pt-0 flex-1",children:e.jsx(f,{className:"h-full w-full"})})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:[e.jsxs(j,{className:"flex flex-col min-h-[250px]",children:[e.jsx(w,{className:"p-4 pb-2",children:e.jsx(f,{className:"h-4 w-28"})}),e.jsx(y,{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(f,{className:"w-2.5 h-2.5 rounded-full"}),e.jsx(f,{className:"h-3 w-24"})]}),e.jsx(f,{className:"h-3 w-16"})]},s))})})]}),e.jsxs(j,{className:"flex flex-col min-h-[250px]",children:[e.jsx(w,{className:"p-4 pb-2",children:e.jsx(f,{className:"h-4 w-28"})}),e.jsx(y,{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(f,{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(f,{className:"w-2 h-2 rounded-full"}),e.jsx(f,{className:"h-3 w-20"})]},s))})]})})]})]})]})}function Fs(){const s=g.useRef(null),{dateRange:t,handleDateRangeChange:a,handleTodayClick:n,handleRefresh:o,isRefreshing:r,lastUpdatedText:i,viewMode:d,summary:l,isSummaryLoading:c,trends:h,hourlyData:u,models:p,sessions:D,isTrendsLoading:k,isHourlyLoading:m,isModelsLoading:b,isSessionsLoading:C,handleModelClick:I,selectedModel:F,popoverPosition:q,handlePopoverClose:Y}=ns();return e.jsxs("div",{className:"grid h-full min-h-0 grid-rows-[auto_auto_minmax(0,1fr)] gap-4 overflow-y-auto px-4 py-4",children:[e.jsx(ls,{dateRange:t,onDateRangeChange:a,onTodayClick:n,onRefresh:o,isRefreshing:r,lastUpdatedText:i,viewMode:d}),e.jsx(Ge,{data:l,isLoading:c}),e.jsx(Ns,{viewMode:d,trends:h,hourlyData:u,models:p,sessions:D,isTrendsLoading:k,isHourlyLoading:m,isModelsLoading:b,isSessionsLoading:C,isSummaryLoading:c,onModelClick:I}),e.jsxs(se,{open:!!F,onOpenChange:E=>!E&&Y(),children:[e.jsx(ve,{asChild:!0,children:e.jsx("div",{ref:s,className:"fixed pointer-events-none",style:{left:q?.x??0,top:q?.y??0,width:1,height:1}})}),e.jsx(te,{className:"w-80 p-3",side:"top",align:"center",children:F&&e.jsx(He,{model:F})})]})]})}export{Fs as AnalyticsPage,Rs as AnalyticsSkeleton};
1
+ import{j as e}from"./radix-ui-nu4wz29m.js";import{r as g,E as ge}from"./react-vendor-Bjx91N7w.js";import{u as U,a as $,C as j,b as y,S as f,c as x,P as v,B as K,d as z,e as se,f as je,g as te,h as ye,i as ae,j as w,k as L,l as Ne,m as we,n as be,o as ve}from"./index-BRtgic66.js";import{a3 as ke,am as ne,an as Q,ao as re,a1 as le,aa as Ce,G as Se,ap as De,R as Te,$ as V,U as Le,Z as ie,v as $e,ae as H,aq as Fe,Y as Re,C as Me,ar as Pe,as as Be}from"./icons-DQFHtVq5.js";import{a as Ae,u as O}from"./tanstack-bhJxV1h8.js";import{K as P,L as oe,f as S,H as Ue}from"./utils-CzKF5WmX.js";import{R as ce,A as Oe,C as Ie,X as qe,Y as Z,T as de,a as X,P as Ke,b as Ee,c as _e}from"./charts-CeK2xCSo.js";import"./notifications-B4_o8bcr.js";import"./form-utils-CuHzLhJZ.js";import"./code-highlight-D4E79GKQ.js";function Ge({data:s,isLoading:t}){const{privacyMode:a}=U(),{t:n}=$(),o=s?.totalTokens??0,r=s?.totalInputTokens??0,i=s?.totalOutputTokens??0,d=s?.totalCacheTokens??0,l=r+i;if(t)return e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-5 gap-4",children:[1,2,3,4,5].map(m=>e.jsx(j,{children:e.jsx(y,{className:"p-6",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(f,{className:"h-4 w-[100px]"}),e.jsx(f,{className:"h-8 w-[80px]"})]}),e.jsx(f,{className:"h-8 w-8 rounded-lg"})]})})},m))});const c=(s?.tokenBreakdown?.cacheCreation?.cost??0)+(s?.tokenBreakdown?.cacheRead?.cost??0),h=s?.totalCost?Math.round(c/s.totalCost*100):0,u=d>0&&o>l,p=d>0&&!u?"Total Tokens (I/O)":n("analyticsSummary.totalTokens"),D=u?`${T(r)} in / ${T(i)} out / ${T(d)} cache`:n("analyticsSummary.totalTokensSubtitle",{input:T(r),output:T(i)}),k=[{title:p,value:o,icon:ke,format:m=>T(m),color:"text-blue-600",bgColor:"bg-blue-100 dark:bg-blue-900/20",subtitle:D},{title:n("analyticsSummary.totalCost"),value:s?.totalCost??0,icon:ne,format:m=>`$${m.toFixed(2)}`,color:"text-green-600",bgColor:"bg-green-100 dark:bg-green-900/20",subtitle:n("analyticsSummary.totalCostSubtitle",{value:s?.averageCostPerDay?.toFixed(2)??"0.00"})},{title:n("analyticsSummary.cacheTokens"),value:s?.totalCacheTokens??0,icon:Q,format:m=>T(m),color:"text-cyan-600",bgColor:"bg-cyan-100 dark:bg-cyan-900/20",subtitle:n("analyticsSummary.cacheTokensSubtitle",{cost:c.toFixed(2),percent:h})},{title:n("analyticsSummary.inputCost"),value:s?.tokenBreakdown?.input?.cost??0,icon:re,format:m=>`$${m.toFixed(2)}`,color:"text-purple-600",bgColor:"bg-purple-100 dark:bg-purple-900/20",subtitle:n("analyticsSummary.tokensSubtitle",{value:T(s?.tokenBreakdown?.input?.tokens??0)})},{title:n("analyticsSummary.outputCost"),value:s?.tokenBreakdown?.output?.cost??0,icon:le,format:m=>`$${m.toFixed(2)}`,color:"text-orange-600",bgColor:"bg-orange-100 dark:bg-orange-900/20",subtitle:n("analyticsSummary.tokensSubtitle",{value:T(s?.tokenBreakdown?.output?.tokens??0)})}];return e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-5 gap-4",children:k.map((m,b)=>{const C=m.icon;return e.jsx(j,{className:"hover:shadow-md transition-shadow",children:e.jsx(y,{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:m.title}),e.jsx("p",{className:x("text-xl font-bold truncate",a&&v),children:m.format(m.value)}),m.subtitle&&e.jsx("p",{className:x("text-[10px] text-muted-foreground truncate",a&&v),children:m.subtitle})]}),e.jsx("div",{className:x("p-2 rounded-lg shrink-0",m.bgColor),children:e.jsx(C,{className:x("h-4 w-4",m.color)})})]})})},b)})})}function T(s){return s>=1e6?`${(s/1e6).toFixed(1)}M`:s>=1e3?`${(s/1e3).toFixed(1)}K`:s.toLocaleString()}function He({model:s}){const{privacyMode:t}=U(),{t:a}=$(),n=We(s.ioRatio),r=s.cacheCreationTokens+s.cacheReadTokens>0?"All Tokens":a("analyticsCards.totalTokens");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(Ce,{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(K,{variant:"secondary",className:"text-[10px] h-5 px-1.5",children:[s.percentage.toFixed(1),"% usage"]}),e.jsxs(K,{variant:n.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:x("text-lg font-bold",t&&v),children:["$",s.cost.toFixed(2)]}),e.jsx("p",{className:"text-[10px] text-muted-foreground uppercase tracking-wider",children:a("analyticsCards.totalCost")})]}),e.jsxs("div",{className:"p-2 rounded-md bg-muted/50 border text-center",children:[e.jsx("p",{className:x("text-lg font-bold",t&&v),children:Ye(s.tokens)}),e.jsx("p",{className:"text-[10px] text-muted-foreground uppercase tracking-wider",children:r})]})]}),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:x("space-y-1",t&&v),children:[e.jsx(W,{label:"Input",tokens:s.inputTokens,cost:s.costBreakdown.input.cost,color:"#335c67",icon:re}),e.jsx(W,{label:"Output",tokens:s.outputTokens,cost:s.costBreakdown.output.cost,color:"#fff3b0",icon:le}),e.jsx(W,{label:"Cache Write",tokens:s.cacheCreationTokens,cost:s.costBreakdown.cacheCreation.cost,color:"#e09f3e",icon:Q}),e.jsx(W,{label:"Cache Read",tokens:s.cacheReadTokens,cost:s.costBreakdown.cacheRead.cost,color:"#9e2a2b",icon:Q})]})]}),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(Se,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsx("span",{className:"text-xs font-medium",children:a("analyticsCards.inputOutputRatio")})]}),e.jsx("p",{className:"text-[11px] text-muted-foreground leading-snug",children:n.description})]})]})}function W({label:s,tokens:t,cost:a,color:n,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:n}}),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:ze(t)})]})]})]})}function We(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 ze(s){return s.toLocaleString()}function Ye(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()}const Qe="/api";function N(s){const t=s.getFullYear(),a=String(s.getMonth()+1).padStart(2,"0"),n=String(s.getDate()).padStart(2,"0");return`${t}${a}${n}`}function M(s,t){const a=t.toString();return a?`${s}?${a}`:s}const B={summary:s=>{const t=new URLSearchParams;return s?.startDate&&t.append("since",N(s.startDate)),s?.endDate&&t.append("until",N(s.endDate)),F(M("/usage/summary",t))},trends:s=>{const t=new URLSearchParams;return s?.startDate&&t.append("since",N(s.startDate)),s?.endDate&&t.append("until",N(s.endDate)),F(M("/usage/daily",t))},hourly:s=>{const t=new URLSearchParams;return s?.startDate&&t.append("since",N(s.startDate)),s?.endDate&&t.append("until",N(s.endDate)),F(M("/usage/hourly",t))},models:s=>{const t=new URLSearchParams;return s?.startDate&&t.append("since",N(s.startDate)),s?.endDate&&t.append("until",N(s.endDate)),F(M("/usage/models",t))},sessions:s=>{const t=new URLSearchParams;return s?.startDate&&t.append("since",N(s.startDate)),s?.endDate&&t.append("until",N(s.endDate)),s?.limit&&t.append("limit",s.limit.toString()),s?.offset&&t.append("offset",s.offset.toString()),F(M("/usage/sessions",t))},monthly:s=>{const t=new URLSearchParams;return s?.startDate&&t.append("since",N(s.startDate)),s?.endDate&&t.append("until",N(s.endDate)),F(M("/usage/monthly",t))},refresh:async()=>{if(!(await fetch(`${Qe}/usage/refresh`,{method:"POST",headers:{"Content-Type":"application/json"}})).ok)throw new Error("Failed to refresh usage cache")},status:()=>F("/usage/status"),insights:s=>{const t=new URLSearchParams;return s?.startDate&&t.append("since",N(s.startDate)),s?.endDate&&t.append("until",N(s.endDate)),F(M("/usage/insights",t))}};async function F(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 n=await a.json();return n.data||n}function Ve(s){return O({queryKey:["usage","summary",s],queryFn:()=>B.summary(s),staleTime:60*1e3})}function Ze(s){return O({queryKey:["usage","trends",s],queryFn:()=>B.trends(s),staleTime:60*1e3})}function Xe(s){return O({queryKey:["usage","hourly",s],queryFn:()=>B.hourly(s),staleTime:60*1e3})}function Je(s){return O({queryKey:["usage","models",s],queryFn:()=>B.models(s),staleTime:60*1e3})}function es(){const s=Ae();return g.useCallback(async()=>{await B.refresh(),await s.invalidateQueries({queryKey:["usage"]})},[s])}function ss(){return O({queryKey:["usage","status"],queryFn:()=>B.status(),staleTime:10*1e3,refetchInterval:30*1e3})}function ts(s){return O({queryKey:["usage","sessions",s],queryFn:()=>B.sessions(s),staleTime:60*1e3})}const as=50;function ns(){const[s,t]=g.useState({from:P(new Date,30),to:new Date}),[a,n]=g.useState(!1),[o,r]=g.useState(null),[i,d]=g.useState(null),[l,c]=g.useState("daily"),h=es(),u=g.useCallback(async()=>{n(!0);try{await h()}finally{n(!1)}},[h]),p=g.useMemo(()=>({startDate:s?.from,endDate:s?.to}),[s?.from,s?.to]),{data:D,isLoading:k}=Ve(p),{data:m,isLoading:b}=Ze(p),{data:C,isLoading:I}=Xe(p),{data:R,isLoading:q}=Je(p),{data:Y,isLoading:E}=ts({...p,limit:as}),{data:_}=ss(),xe=g.useCallback(()=>{const A=new Date;t({from:P(A,1),to:A}),c("hourly")},[]),ue=g.useCallback(A=>{t(A),c("daily")},[]),me=g.useMemo(()=>_?.lastFetch?oe(new Date(_.lastFetch),{addSuffix:!0}):null,[_?.lastFetch]),he=g.useCallback((A,pe)=>{const G=pe.currentTarget.getBoundingClientRect();d({x:G.left+G.width/2,y:G.top+G.height/2}),r(A)},[]),fe=g.useCallback(()=>{r(null),d(null)},[]);return{dateRange:s,isRefreshing:a,viewMode:l,selectedModel:o,popoverPosition:i,summary:D,trends:m,hourlyData:C,models:R,sessions:Y,status:_,isSummaryLoading:k,isTrendsLoading:b,isHourlyLoading:I,isModelsLoading:q,isSessionsLoading:E,isLoading:k||b||q||E,handleRefresh:u,handleTodayClick:xe,handleDateRangeChange:ue,handleModelClick:he,handlePopoverClose:fe,lastUpdatedText:me}}function rs({value:s,onChange:t,presets:a=[{label:"Last 7 days",range:{from:P(new Date,7),to:new Date}},{label:"Last 30 days",range:{from:P(new Date,30),to:new Date}},{label:"Last 90 days",range:{from:P(new Date,90),to:new Date}}],className:n}){const[o,r]=ge.useState(!1),{t:i}=$(),d=l=>!s||!s.from||!s.to||!l.from||!l.to?!1:S(s.from,"yyyy-MM-dd")===S(l.from,"yyyy-MM-dd")&&S(s.to,"yyyy-MM-dd")===S(l.to,"yyyy-MM-dd");return e.jsxs("div",{className:x("flex flex-wrap items-center gap-2",n),children:[a.map(l=>e.jsx(z,{variant:d(l.range)?"default":"outline",size:"sm",onClick:()=>t(l.range),children:l.label},l.label)),e.jsxs(se,{open:o,onOpenChange:r,children:[e.jsx(je,{asChild:!0,children:e.jsxs(z,{id:"date",variant:"outline",className:x("w-auto min-w-[200px] sm:min-w-[240px] justify-start text-left font-normal",!s&&"text-muted-foreground"),children:[e.jsx(De,{className:"mr-2 h-4 w-4"}),s?.from?s.to?e.jsxs(e.Fragment,{children:[S(s.from,"LLL dd, y")," - ",S(s.to,"LLL dd, y")]}):S(s.from,"LLL dd, y"):e.jsx("span",{children:i("dateRangeFilter.pickADate")})]})}),e.jsx(te,{className:"w-auto p-0",align:"end",children:e.jsx(ye,{initialFocus:!0,mode:"range",defaultMonth:s?.from,selected:s,onSelect:t,numberOfMonths:2})})]})]})}function ls({dateRange:s,onDateRangeChange:t,onTodayClick:a,onRefresh:n,isRefreshing:o,lastUpdatedText:r,viewMode:i}){const{t:d}=$();return e.jsxs("div",{className:"flex flex-col gap-3 shrink-0 xl:flex-row xl:items-center xl:justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl font-semibold",children:d("analytics.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:d("analytics.subtitle")})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 xl:justify-end",children:[e.jsx(z,{variant:i==="hourly"?"default":"outline",size:"sm",className:"h-8",onClick:a,children:"24H"}),e.jsx(rs,{className:"flex-wrap",value:s,onChange:t,presets:[{label:"7D",range:{from:P(new Date,7),to:new Date}},{label:"30D",range:{from:P(new Date,30),to:new Date}},{label:d("analytics.month"),range:{from:Ue(new Date),to:new Date}},{label:d("analytics.allTime"),range:{from:void 0,to:new Date}}]}),r&&e.jsx("span",{className:"text-xs text-muted-foreground whitespace-nowrap",children:d("analytics.updated",{value:r})}),e.jsx(z,{variant:"outline",size:"sm",className:"gap-2 h-8",onClick:n,disabled:o,children:e.jsx(Te,{className:`w-3.5 h-3.5 ${o?"animate-spin":""}`})})]})]})}function is({data:s,isLoading:t,granularity:a="daily",className:n}){const{privacyMode:o}=U(),{t:r}=$(),i=g.useMemo(()=>!s||s.length===0?[]:s.map(c=>{const h="hour"in c?c.hour:c.date;return{...c,dateFormatted:os(h,a),costRounded:Number(c.cost.toFixed(4))}}),[s,a]);if(t)return e.jsx(f,{className:x("h-full w-full",n)});if(!s||s.length===0)return e.jsx("div",{className:x("h-full flex items-center justify-center",n),children:e.jsx("p",{className:"text-muted-foreground",children:r(a==="hourly"?"analytics.noDailyUsage":"analytics.noUsageData")})});const d=({x:l,y:c,payload:h,isRight:u})=>{const p=u?`$${h.value}`:J(Number(h.value));return e.jsx("text",{x:l,y:c,dy:4,textAnchor:u?"start":"end",fontSize:12,fill:"currentColor",className:x("fill-muted-foreground",o&&"blur-[4px]"),children:p})};return e.jsx("div",{className:x("w-full h-full",n),children:e.jsx(ce,{width:"100%",height:"100%",children:e.jsxs(Oe,{data:i,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(Ie,{strokeDasharray:"3 3",className:"stroke-muted"}),e.jsx(qe,{dataKey:"dateFormatted",tick:{fontSize:12},tickLine:!1,axisLine:{className:"stroke-muted"}}),e.jsx(Z,{yAxisId:"left",orientation:"left",tick:l=>e.jsx(d,{...l,isRight:!1}),tickLine:!1,axisLine:{className:"stroke-muted"}}),e.jsx(Z,{yAxisId:"right",orientation:"right",tick:l=>e.jsx(d,{...l,isRight:!0}),tickLine:!1,axisLine:{className:"stroke-muted"}}),e.jsx(de,{content:({active:l,payload:c,label:h})=>!l||!c||!c.length?null:e.jsxs("div",{className:"rounded-lg border bg-background p-3 shadow-lg",children:[e.jsx("p",{className:"font-medium mb-2",children:h}),c.map((u,p)=>e.jsxs("p",{className:x("text-sm",o&&v),style:{color:u.color},children:[u.name,":"," ",u.name==="Tokens"?J(Number(u.value)||0):`$${u.value}`]},p))]})}),e.jsx(X,{yAxisId:"left",type:"monotone",dataKey:"tokens",stroke:"#0080FF",strokeWidth:2,fillOpacity:1,fill:"url(#tokenGradient)",name:"Tokens"}),e.jsx(X,{yAxisId:"right",type:"monotone",dataKey:"costRounded",stroke:"#00C49F",strokeWidth:2,fillOpacity:1,fill:"url(#costGradient)",name:"Cost"})]})})})}function os(s,t){if(t==="hourly"){const[n,o]=s.split(" ");if(n&&o){const r=new Date(`${n}T${o}:00Z`);return S(r,"HH:mm")}return s}const a=new Date(s);return t==="monthly"?S(a,"MMM yyyy"):S(a,"MMM dd")}function J(s){return s>=1e6?`${(s/1e6).toFixed(1)}M`:s>=1e3?`${(s/1e3).toFixed(1)}K`:s.toLocaleString()}function cs({data:s,isLoading:t,className:a}){const{privacyMode:n}=U(),{t:o}=$(),r=g.useMemo(()=>!s||s.length===0?[]:s.map(l=>({name:l.model,value:l.tokens,cost:l.cost,percentage:l.percentage,fill:ae(l.model)})),[s]);if(t)return e.jsx(f,{className:x("h-full min-h-[100px] w-full",a)});if(!s||s.length===0)return e.jsx("div",{className:x("h-full min-h-[100px] flex items-center justify-center",a),children:e.jsx("p",{className:"text-muted-foreground",children:o("analyticsCards.noModelData")})});const i=({active:l,payload:c})=>{if(!l||!c)return null;const h=c;if(!h.length)return null;const u=h[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:u.name}),e.jsxs("p",{className:x("text-muted-foreground",n&&v),children:[ds(u.value)," (",u.percentage.toFixed(1),"%)"]}),e.jsxs("p",{className:x("text-muted-foreground",n&&v),children:["$",u.cost.toFixed(4)]})]})},d=l=>l.percentage>5?`${l.percentage.toFixed(1)}%`:"";return e.jsx("div",{className:x("w-full h-full min-h-[100px]",a),children:e.jsx(ce,{width:"100%",height:"100%",children:e.jsxs(Ke,{children:[e.jsx(Ee,{data:r,cx:"50%",cy:"50%",labelLine:!1,label:d,innerRadius:50,outerRadius:70,paddingAngle:2,dataKey:"value",children:r.map((l,c)=>e.jsx(_e,{fill:l.fill,strokeWidth:1},`cell-${c}`))}),e.jsx(de,{content:i})]})})})}function ds(s){return s>=1e6?`${(s/1e6).toFixed(1)}M`:s>=1e3?`${(s/1e3).toFixed(1)}K`:s.toLocaleString()}function xs(s){if(!s)return"";const a=s.replace(/^\/|\/$/g,"").split("/").filter(n=>n.length>0);return a[a.length-1]||""}function us({data:s,isLoading:t,className:a}){const{privacyMode:n}=U(),{t:o}=$(),r=g.useMemo(()=>{if(!s?.sessions||s.sessions.length===0)return null;const i=s.sessions,d=s.total,l=i.length,c=s.hasMore||s.offset>0,u=i.reduce((p,D)=>p+D.cost,0)/i.length;return{displayedSessions:c?l:d,totalSessions:d,avgCost:u,hasPartialSample:c,recentSessions:i.slice(0,3)}},[s]);return t?e.jsxs(j,{className:x("flex flex-col h-full min-h-0 overflow-hidden gap-0 py-0",a),children:[e.jsx(w,{className:"px-3 py-2",children:e.jsx(f,{className:"h-5 w-32"})}),e.jsx(y,{className:"px-3 pb-3 pt-0 flex-1",children:e.jsx(f,{className:"h-full w-full"})})]}):r?e.jsxs(j,{className:x("flex flex-col h-full min-h-0 overflow-hidden gap-0 py-0 shadow-sm",a),children:[e.jsx(w,{className:"px-3 py-2",children:e.jsxs(L,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(V,{className:"w-4 h-4"}),"Session Stats"]})}),e.jsxs(y,{className:"px-3 pb-3 pt-0 flex-1 min-h-0 flex flex-col gap-3",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:r.displayedSessions})]}),e.jsx("p",{className:"text-[10px] text-muted-foreground uppercase tracking-wider mt-0.5",children:r.hasPartialSample?"Sampled Sessions":"Total Sessions"}),r.hasPartialSample&&e.jsxs("p",{className:"text-[10px] text-muted-foreground mt-0.5",children:[r.totalSessions," total"]})]}),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(ie,{className:"w-4 h-4"}),e.jsxs("span",{className:x("text-xl font-bold",n&&v),children:["$",r.avgCost.toFixed(2)]})]}),e.jsx("p",{className:"text-[10px] text-muted-foreground uppercase tracking-wider mt-0.5",children:r.hasPartialSample?"Recent Avg Cost":"Avg Cost/Session"})]})]}),e.jsxs("div",{className:"flex-1 min-h-0 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($e,{className:"w-3 h-3"}),"Recent Activity"]}),e.jsx("div",{className:"space-y-1.5 max-h-full overflow-y-auto pr-1",children:r.recentSessions.map(i=>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.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"font-medium truncate",title:i.projectPath,children:xs(i.projectPath)}),(i.target??"claude")!=="claude"&&e.jsx("span",{className:"shrink-0 px-1 py-0 text-[9px] font-medium rounded bg-purple-100 text-purple-700 dark:bg-purple-900/30 dark:text-purple-300 uppercase",children:i.target})]}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:oe(new Date(i.lastActivity),{addSuffix:!0})})]}),e.jsxs("div",{className:x("text-right shrink-0 ml-2",n&&v),children:[e.jsxs("div",{className:"font-mono",children:["$",i.cost.toFixed(2)]}),e.jsxs("div",{className:"text-[10px] text-muted-foreground",children:[ms(i.tokens??i.inputTokens+i.outputTokens)," ","toks"]})]})]},i.sessionId))})]})]})]}):e.jsxs(j,{className:x("flex flex-col h-full min-h-0 overflow-hidden gap-0 py-0",a),children:[e.jsx(w,{className:"px-3 py-2",children:e.jsxs(L,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(V,{className:"w-4 h-4"}),"Session Stats"]})}),e.jsx(y,{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:o("analyticsCards.noSessionData")})})]})}function ms(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 hs({className:s,isLoading:t}){const{data:a,isLoading:n}=Ne(),{data:o,isLoading:r,error:i}=we(a?.running),{t:d}=$();if(t||n||a?.running&&r)return e.jsxs(j,{className:x("flex flex-col h-full min-h-0 overflow-hidden gap-0 py-0",s),children:[e.jsx(w,{className:"px-3 py-2",children:e.jsxs(L,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(H,{className:"h-4 w-4"}),"CLIProxy Stats"]})}),e.jsx(y,{className:"px-3 pb-3 pt-0 flex-1",children:e.jsxs("div",{className:"space-y-3",children:[e.jsx(f,{className:"h-4 w-[100px]"}),e.jsx(f,{className:"h-16 w-full"})]})})]});if(!a?.running)return e.jsxs(j,{className:x("flex flex-col h-full min-h-0 overflow-hidden gap-0 py-0 border-dashed",s),children:[e.jsx(w,{className:"px-3 py-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(L,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(H,{className:"h-4 w-4 text-muted-foreground"}),"CLIProxy Stats"]}),e.jsx(K,{variant:"secondary",className:"text-[10px] h-5",children:d("cliproxyStatsOverview.offline")})]})}),e.jsx(y,{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:d("cliproxyStatsOverview.noActiveSessionHint")})})]});if(i)return e.jsxs(j,{className:x("flex flex-col h-full min-h-0 overflow-hidden gap-0 py-0 border-destructive/50",s),children:[e.jsx(w,{className:"px-3 py-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(L,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(H,{className:"h-4 w-4"}),"CLIProxy Stats"]}),e.jsx(K,{variant:"destructive",className:"text-[10px] h-5",children:"Error"})]})}),e.jsx(y,{className:"px-3 pb-3 pt-0 flex-1",children:e.jsx("p",{className:"text-xs text-destructive",children:i.message})})]});const c=o?.totalRequests??0,h=o?.quotaExceededCount??0,u=c-h,p=c>0?Math.round(u/c*100):100,D=o?.tokens?.total??0,k=Object.entries(o?.requestsByModel??{}).sort((b,C)=>C[1]-b[1]).slice(0,4),m=k.length>0?k[0][1]:1;return e.jsxs(j,{className:x("flex flex-col h-full min-h-0 overflow-hidden gap-0 py-0",s),children:[e.jsx(w,{className:"px-3 py-2 border-b bg-muted/5",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(L,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(H,{className:"h-4 w-4"}),"CLIProxy Stats"]}),e.jsxs(K,{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(ie,{className:"h-3 w-3 mr-0.5"}),d("cliproxyStatsOverview.running")]})]})}),e.jsx(y,{className:"p-0 flex-1 min-h-0",children:e.jsx(be,{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:`${p*.88} 88`,strokeLinecap:"round",className:p>=90?"text-green-500":"text-amber-500"})]}),e.jsxs("span",{className:"absolute inset-0 flex items-center justify-center text-[8px] font-bold",children:[p,"%"]})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-lg font-bold leading-none",children:ee(c)}),e.jsx("div",{className:"text-[9px] text-muted-foreground mt-0.5",children:h>0?`${h} 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(Fe,{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:ee(D)}),e.jsx("div",{className:"text-[9px] text-muted-foreground mt-0.5",children:d("cliproxyStatsOverview.totalTokens")})]})]})]}),k.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(Re,{className:"h-3 w-3"}),d("cliproxyStatsOverview.modelsUsed")]}),e.jsx("div",{className:"space-y-1",children:k.map(([b,C])=>{const I=Math.round(C/m*100),R=fs(b);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:b,children:R}),e.jsx("span",{className:"text-muted-foreground shrink-0 ml-2",children:C})]}),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:`${I}%`}})})]},b)})})]})]})})})]})}function ee(s){return s>=1e6?`${(s/1e6).toFixed(1)}M`:s>=1e3?`${(s/1e3).toFixed(1)}K`:s.toLocaleString()}function fs(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}function ps(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 gs({models:s,isLoading:t,onModelClick:a,privacyMode:n}){const{t:o}=$();return e.jsxs(j,{className:"flex flex-col h-full min-h-0 overflow-hidden gap-0 py-0 shadow-sm lg:col-span-4",children:[e.jsx(w,{className:"px-3 py-2",children:e.jsxs(L,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(ne,{className:"w-4 h-4"}),o("analyticsPages.costByModel")]})}),e.jsx(y,{className:"px-2 pb-2 pt-0 flex-1 min-h-0 overflow-y-auto",children:t?e.jsx(f,{className:"h-full w-full"}):e.jsxs("div",{className:"space-y-0.5",children:[[...s||[]].sort((r,i)=>i.cost-r.cost).map(r=>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:i=>a(r,i),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:ae(r.model)}}),e.jsx("span",{className:"font-medium truncate group-hover:underline underline-offset-2",children:r.model})]}),e.jsx(js,{model:r}),e.jsx("span",{className:x("text-[10px] text-muted-foreground w-14 text-right shrink-0",n&&v),children:ps(r.tokens)}),e.jsxs("span",{className:x("font-mono font-medium w-16 text-right shrink-0",n&&v),children:["$",r.cost.toFixed(2)]}),e.jsx(Me,{className:"w-3 h-3 opacity-0 group-hover:opacity-50 transition-opacity shrink-0"})]},r.model)),e.jsx(ys,{})]})})]})}function js({model:s}){const t={input:"#335c67",output:"#fff3b0",cacheWrite:"#e09f3e",cacheRead:"#9e2a2b"},a=n=>s.cost>0?n/s.cost*100:0;return 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:t.input,width:`${a(s.costBreakdown.input.cost)}%`},title:`Input: $${s.costBreakdown.input.cost.toFixed(2)}`}),e.jsx("div",{className:"h-full",style:{backgroundColor:t.output,width:`${a(s.costBreakdown.output.cost)}%`},title:`Output: $${s.costBreakdown.output.cost.toFixed(2)}`}),e.jsx("div",{className:"h-full",style:{backgroundColor:t.cacheWrite,width:`${a(s.costBreakdown.cacheCreation.cost)}%`},title:`Cache Write: $${s.costBreakdown.cacheCreation.cost.toFixed(2)}`}),e.jsx("div",{className:"h-full",style:{backgroundColor:t.cacheRead,width:`${a(s.costBreakdown.cacheRead.cost)}%`},title:`Cache Read: $${s.costBreakdown.cacheRead.cost.toFixed(2)}`})]})})}function ys(){const s=[{color:"#335c67",label:"Input"},{color:"#fff3b0",label:"Output",hasBorder:!0},{color:"#e09f3e",label:"Cache Write"},{color:"#9e2a2b",label:"Cache Read"}];return e.jsx("div",{className:"flex items-center gap-3 pt-2 px-2 text-[10px] text-muted-foreground border-t mt-2",children:s.map(({color:t,label:a,hasBorder:n})=>e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx("div",{className:x("w-2 h-2 rounded-full",n&&"border border-muted-foreground/30"),style:{backgroundColor:t}}),a]},a))})}function Ns({viewMode:s,trends:t,hourlyData:a,models:n,sessions:o,isTrendsLoading:r,isHourlyLoading:i,isModelsLoading:d,isSessionsLoading:l,isSummaryLoading:c,onModelClick:h}){const{privacyMode:u}=U();return e.jsxs("div",{className:"min-h-0 grid gap-4 lg:grid-rows-[minmax(260px,1.2fr)_minmax(220px,0.9fr)]",children:[e.jsxs(j,{className:"flex flex-col h-full min-h-[220px] lg:min-h-[240px] overflow-hidden gap-0 py-0 shadow-sm",children:[e.jsx(w,{className:"px-3 py-2 shrink-0",children:e.jsxs(L,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(Pe,{className:"w-4 h-4"}),s==="hourly"?"Last 24 Hours":"Usage Trends"]})}),e.jsx(y,{className:"px-3 pb-3 pt-0 flex-1 min-h-0",children:e.jsx(is,{data:s==="hourly"?a||[]:t||[],isLoading:s==="hourly"?i:r,granularity:s==="hourly"?"hourly":"daily"})})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-10 gap-4 h-auto min-h-[220px] lg:h-full lg:min-h-[220px] lg:grid-rows-[minmax(0,1fr)] lg:[&>*]:min-h-0",children:[e.jsx(gs,{models:n,isLoading:d,onModelClick:h,privacyMode:u}),e.jsxs(j,{className:"flex flex-col h-full min-h-0 overflow-hidden gap-0 py-0 shadow-sm lg:col-span-2",children:[e.jsx(w,{className:"px-3 py-2",children:e.jsxs(L,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(Be,{className:"w-4 h-4"}),"Model Usage"]})}),e.jsx(y,{className:"px-2 pb-2 pt-0 flex-1 min-h-0 flex items-center justify-center",children:e.jsx(cs,{data:n||[],isLoading:d,className:"h-full w-full"})})]}),e.jsx(us,{data:o,isLoading:l,className:"lg:col-span-2"}),e.jsx(hs,{isLoading:c,className:"lg:col-span-2"})]})]})}function Fs(){return e.jsxs("div",{className:"space-y-4 h-full overflow-hidden",children:[e.jsxs(j,{className:"flex flex-col min-h-[300px]",children:[e.jsx(w,{className:"p-4 pb-2",children:e.jsx(f,{className:"h-4 w-32"})}),e.jsx(y,{className:"p-4 pt-0 flex-1",children:e.jsx(f,{className:"h-full w-full"})})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:[e.jsxs(j,{className:"flex flex-col min-h-[250px]",children:[e.jsx(w,{className:"p-4 pb-2",children:e.jsx(f,{className:"h-4 w-28"})}),e.jsx(y,{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(f,{className:"w-2.5 h-2.5 rounded-full"}),e.jsx(f,{className:"h-3 w-24"})]}),e.jsx(f,{className:"h-3 w-16"})]},s))})})]}),e.jsxs(j,{className:"flex flex-col min-h-[250px]",children:[e.jsx(w,{className:"p-4 pb-2",children:e.jsx(f,{className:"h-4 w-28"})}),e.jsx(y,{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(f,{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(f,{className:"w-2 h-2 rounded-full"}),e.jsx(f,{className:"h-3 w-20"})]},s))})]})})]})]})]})}function Rs(){const s=g.useRef(null),{dateRange:t,handleDateRangeChange:a,handleTodayClick:n,handleRefresh:o,isRefreshing:r,lastUpdatedText:i,viewMode:d,summary:l,isSummaryLoading:c,trends:h,hourlyData:u,models:p,sessions:D,isTrendsLoading:k,isHourlyLoading:m,isModelsLoading:b,isSessionsLoading:C,handleModelClick:I,selectedModel:R,popoverPosition:q,handlePopoverClose:Y}=ns();return e.jsxs("div",{className:"grid h-full min-h-0 grid-rows-[auto_auto_minmax(0,1fr)] gap-4 overflow-y-auto px-4 py-4",children:[e.jsx(ls,{dateRange:t,onDateRangeChange:a,onTodayClick:n,onRefresh:o,isRefreshing:r,lastUpdatedText:i,viewMode:d}),e.jsx(Ge,{data:l,isLoading:c}),e.jsx(Ns,{viewMode:d,trends:h,hourlyData:u,models:p,sessions:D,isTrendsLoading:k,isHourlyLoading:m,isModelsLoading:b,isSessionsLoading:C,isSummaryLoading:c,onModelClick:I}),e.jsxs(se,{open:!!R,onOpenChange:E=>!E&&Y(),children:[e.jsx(ve,{asChild:!0,children:e.jsx("div",{ref:s,className:"fixed pointer-events-none",style:{left:q?.x??0,top:q?.y??0,width:1,height:1}})}),e.jsx(te,{className:"w-80 p-3",side:"top",align:"center",children:R&&e.jsx(He,{model:R})})]})]})}export{Rs as AnalyticsPage,Fs as AnalyticsSkeleton};
@@ -1 +1 @@
1
- import{j as e}from"./radix-ui-Zb8sVEtn.js";import{r as o}from"./react-vendor-CNOkPC89.js";import{a as q,bi as J,bk as X,d as I,n as Y,L as A,r as R,s as M,t as K,v as B,w as E,I as F,aI as Q}from"./index-0mNJhDEG.js";import{R as $,w as Z,x as ee,ad as se,_ as te,s as re}from"./icons-DyorC3Xk.js";import"./tanstack-CrmUhA7Z.js";import"./notifications-B2HqRBj7.js";import"./utils-CzKF5WmX.js";import"./form-utils-Bcoyqxpq.js";import"./code-highlight-BRUf_pqB.js";const z={mode:"auto",tier_defaults:{opus:"high",sonnet:"medium",haiku:"low"},show_warnings:!0},U=1e4;function ie(){const[t,i]=o.useState(null),[b,d]=o.useState(!0),[_,N]=o.useState(!1),[p,g]=o.useState(null),[P,y]=o.useState(!1),f=o.useRef(void 0),w=o.useRef(!1),k=o.useCallback(async()=>{const r=new AbortController,c=setTimeout(()=>r.abort(),U);try{d(!0),g(null);const n=await fetch("/api/thinking",{signal:r.signal});if(clearTimeout(c),!n.ok)throw n.headers.get("content-type")?.includes("text/html")?new Error(`Server error (${n.status})`):new Error("Failed to load Thinking config");const m=await n.json();i(m.config||z),f.current=m.lastModified,w.current=!0}catch(n){clearTimeout(c),n.name==="AbortError"?g("Request timeout - please try again"):g(n.message)}finally{d(!1)}return()=>r.abort()},[]),l=o.useCallback(async r=>{if(!w.current||t===null){g("Cannot save settings before they load. Click Refresh and try again.");return}const c=t,n={...c,...r.mode!==void 0?{mode:r.mode}:{},...r.tier_defaults!==void 0?{tier_defaults:r.tier_defaults}:{},...r.show_warnings!==void 0?{show_warnings:r.show_warnings}:{}};r.clear_override||r.override===null?delete n.override:r.override!==void 0&&(n.override=r.override),r.clear_provider_overrides||r.provider_overrides===null?delete n.provider_overrides:r.provider_overrides!==void 0&&(n.provider_overrides=r.provider_overrides),i(n);const m=new AbortController,h=setTimeout(()=>m.abort(),U);try{N(!0),g(null);const x={...n,lastModified:f.current},u=await fetch("/api/thinking",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(x),signal:m.signal});if(clearTimeout(h),!u.ok){if(u.headers.get("content-type")?.includes("text/html"))throw new Error(`Server error (${u.status})`);const s=await u.json();throw u.status===409?new Error("Config changed by another session. Refreshing..."):new Error(s.error||"Failed to save")}const v=await u.json();i(v.config),f.current=v.lastModified,y(!0),setTimeout(()=>y(!1),1500)}catch(x){clearTimeout(h),i(c),x.name==="AbortError"?g("Request timeout - please try again"):(g(x.message),x.message.includes("another session")&&setTimeout(()=>k(),1e3))}finally{N(!1)}},[t,k]),T=o.useCallback(r=>{l({mode:r})},[l]),C=o.useCallback((r,c)=>{const n=t?.tier_defaults||z.tier_defaults;l({tier_defaults:{...n,[r]:c}})},[t,l]),O=o.useCallback(r=>{l({show_warnings:r})},[l]),D=o.useCallback(r=>{if(r===void 0){l({override:null,clear_override:!0});return}l({override:r,clear_override:!1})},[l]),L=o.useCallback((r,c,n)=>{const m=t?.provider_overrides||{},h=m[r]||{};if(n===void 0){const{[c]:x,...u}=h,v=Object.keys(u).length>0?u:void 0,{[r]:S,...s}=m,a=v?{...s,[r]:v}:s;l({provider_overrides:Object.keys(a).length>0?a:null,clear_provider_overrides:Object.keys(a).length===0})}else l({provider_overrides:{...m,[r]:{...h,[c]:n}},clear_provider_overrides:!1})},[t,l]);return{config:t||z,loading:b,saving:_,error:p,success:P,fetchConfig:k,saveConfig:l,setMode:T,setTierDefault:C,setShowWarnings:O,setOverride:D,setProviderOverride:L}}const H=[{value:"minimal",label:"Minimal (512 tokens)"},{value:"low",label:"Low (1K tokens)"},{value:"medium",label:"Medium (8K tokens)"},{value:"high",label:"High (24K tokens)"},{value:"xhigh",label:"Extra High (32K tokens)"},{value:"max",label:"Max (adaptive ceiling)"},{value:"auto",label:"Auto (dynamic)"}],ne=[{value:"__none__",label:"None (use CLI flags only)"},...H,{value:"__custom__",label:"Custom budget (number)"},{value:"off",label:"Off (disable thinking)"}],ae=["agy","gemini","codex"],G=0,V=1e5;function fe(){const{t}=q(),{config:i,loading:b,saving:d,error:_,success:N,fetchConfig:p,setMode:g,setTierDefault:P,setShowWarnings:y,setOverride:f,setProviderOverride:w}=ie(),[k,l]=o.useState(null),[T,C]=o.useState(""),[O,D]=o.useState([]),[L,r]=o.useState(null),c=o.useMemo(()=>Array.from(new Set([...ae,...Object.keys(i.provider_overrides??{}),...O])),[O,i.provider_overrides]),n=i.override===void 0?"__none__":typeof i.override=="number"||/^\d+$/.test(String(i.override))?"__custom__":String(i.override),m=typeof i.override=="number"||/^\d+$/.test(String(i.override??""))?String(i.override):"",h=L??m,x=Object.keys(i.provider_overrides??{}).length>0,u=k??x;o.useEffect(()=>{p()},[p]);const v=()=>{const s=T.trim().toLowerCase();s&&(c.includes(s)||D(a=>[...a,s]),C(""),l(!0))},S=()=>{const s=h.trim();if(!s){f(void 0);return}const a=Number.parseInt(s,10);Number.isNaN(a)||a<G||a>V||!/^\d+$/.test(s)||f(a)};return b?e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsxs("div",{className:"flex items-center gap-3 text-muted-foreground",children:[e.jsx($,{className:"w-5 h-5 animate-spin"}),e.jsx("span",{children:t("settings.loading")})]})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:`absolute left-5 right-5 top-20 z-10 transition-all duration-200 ease-out ${_||N?"opacity-100 translate-y-0":"opacity-0 -translate-y-2 pointer-events-none"}`,children:[_&&e.jsx(J,{variant:"destructive",className:"py-2 shadow-lg",children:e.jsxs("div",{className:"flex items-center justify-between w-full",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Z,{className:"h-4 w-4"}),e.jsx(X,{children:_})]}),e.jsxs(I,{variant:"outline",size:"sm",onClick:p,className:"h-7 px-2 text-xs border-destructive/50 hover:bg-destructive/10",children:[e.jsx($,{className:"w-3 h-3 mr-1"}),t("sharedPage.retry")]})]})}),N&&e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-md border border-green-200 bg-green-50 text-green-700 shadow-lg dark:border-green-900/50 dark:bg-green-900/90 dark:text-green-300",children:[e.jsx(ee,{className:"h-4 w-4 shrink-0"}),e.jsx("span",{className:"text-sm font-medium",children:t("settings.saved")})]})]}),e.jsx(Y,{className:"flex-1",children:e.jsxs("div",{className:"p-5 space-y-6",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(se,{className:"w-5 h-5 text-primary"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:t("settingsThinking.description")})]}),e.jsxs("div",{className:"flex items-start gap-2 p-3 rounded-lg bg-blue-50 dark:bg-blue-900/20 border border-blue-200 dark:border-blue-800",children:[e.jsx(te,{className:"w-4 h-4 text-blue-600 dark:text-blue-400 shrink-0 mt-0.5"}),e.jsxs("div",{className:"text-sm text-blue-700 dark:text-blue-300",children:[e.jsx("p",{className:"font-medium",children:t("settingsThinking.supportedProviders")}),e.jsxs("ul",{className:"mt-1 space-y-0.5 text-blue-600 dark:text-blue-400",children:[e.jsxs("li",{children:[t("settingsThinking.supportLine1Prefix")," ",e.jsx("strong",{children:"agy"}),","," ",e.jsx("strong",{children:"gemini"})," ",t("settingsThinking.supportLine1Suffix")]}),e.jsxs("li",{children:[t("settingsThinking.supportLine2Prefix")," ",e.jsx("strong",{children:"codex"})," ",t("settingsThinking.supportLine2SuffixPrefix"),e.jsx("code",{children:"--effort"}),t("settingsThinking.supportLine2SuffixPostfix")]}),e.jsxs("li",{children:[t("settingsThinking.supportLine3Prefix")," ",e.jsx("code",{children:"-high"}),t("settingsThinking.supportLine3Suffix")]})]})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-base font-medium",children:t("settingsThinking.modeTitle")}),e.jsx("div",{className:"space-y-2",children:["auto","off","manual"].map(s=>e.jsxs("div",{className:`flex items-center justify-between p-4 rounded-lg cursor-pointer transition-colors ${i.mode===s?"bg-primary/10 border border-primary/30":"bg-muted/50 hover:bg-muted/80"} ${d?"opacity-70 pointer-events-none":""}`,onClick:()=>{d||g(s)},children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium capitalize",children:s}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[s==="auto"&&t("settingsThinking.modeAutoDesc"),s==="off"&&t("settingsThinking.modeOffDesc"),s==="manual"&&t("settingsThinking.modeManualDesc")]})]}),e.jsx("div",{className:`w-4 h-4 rounded-full border-2 ${i.mode===s?"bg-primary border-primary":"border-muted-foreground/50"}`})]},s))})]}),i.mode==="auto"&&e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-base font-medium",children:t("settingsThinking.tierDefaults")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:t("settingsThinking.tierDefaultsDesc")}),e.jsx("div",{className:"space-y-3",children:["opus","sonnet","haiku"].map(s=>e.jsxs("div",{className:"flex items-center gap-4 p-3 rounded-lg bg-muted/30",children:[e.jsx(A,{className:"w-20 capitalize font-medium",children:s}),e.jsxs(R,{value:i.tier_defaults[s],onValueChange:a=>P(s,a),disabled:d,children:[e.jsx(M,{className:"flex-1",children:e.jsx(K,{})}),e.jsx(B,{children:H.map(a=>e.jsx(E,{value:a.value,children:a.label},a.value))})]})]},s))})]}),i.mode==="manual"&&e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-base font-medium",children:t("settingsThinking.persistentOverride")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:t("settingsThinking.persistentOverrideDesc")}),e.jsxs(R,{value:n,onValueChange:s=>{if(s==="__none__"){f(void 0);return}if(s==="__custom__"){h||r("8192");return}r(null),f(s)},disabled:d,children:[e.jsx(M,{children:e.jsx(K,{})}),e.jsx(B,{children:ne.map(s=>e.jsx(E,{value:s.value,children:s.label},s.value))})]}),n==="__custom__"&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(F,{type:"number",min:G,max:V,value:h,onChange:s=>r(s.target.value),onBlur:S,disabled:d,placeholder:t("settingsThinking.enterCustomBudget")}),e.jsx(I,{type:"button",size:"sm",variant:"outline",onClick:S,disabled:d,children:t("settingsThinking.apply")})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Range: ",G," to ",V]})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("button",{type:"button",className:"flex items-center gap-2 text-base font-medium w-full text-left",onClick:()=>l(s=>!(s??x)),disabled:d,children:[e.jsx(re,{className:`w-4 h-4 transition-transform ${u?"rotate-0":"-rotate-90"}`}),t("settingsThinking.providerOverrides",{count:Object.keys(i.provider_overrides??{}).length})]}),u&&e.jsxs("div",{className:"space-y-3",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:t("settingsThinking.providerOverridesDesc")}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(F,{value:T,onChange:s=>C(s.target.value),disabled:d,placeholder:t("settingsThinking.addProviderPlaceholder")}),e.jsx(I,{type:"button",size:"sm",variant:"outline",onClick:v,disabled:d,children:t("settingsGlobalEnv.add")})]}),c.map(s=>e.jsxs("div",{className:"space-y-2 p-3 rounded-lg bg-muted/30",children:[e.jsx(A,{className:"capitalize font-medium text-sm",children:s}),e.jsx("div",{className:"grid grid-cols-3 gap-2",children:["opus","sonnet","haiku"].map(a=>{const W=i.provider_overrides?.[s]?.[a]||"__default__";return e.jsxs("div",{className:"space-y-1",children:[e.jsx(A,{className:"text-xs text-muted-foreground capitalize",children:a}),e.jsxs(R,{value:W,onValueChange:j=>w(s,a,j==="__default__"?void 0:j),disabled:d,children:[e.jsx(M,{className:"h-8 text-xs",children:e.jsx(K,{})}),e.jsxs(B,{children:[e.jsx(E,{value:"__default__",children:t("cursorPage.default")}),H.map(j=>e.jsx(E,{value:j.value,children:j.label},j.value))]})]})]},a)})})]},s))]})]}),e.jsxs("div",{className:"flex items-center justify-between p-4 rounded-lg bg-muted/50",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:t("settingsThinking.showWarnings")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:t("settingsThinking.showWarningsDesc")})]}),e.jsx(Q,{checked:i.show_warnings??!0,onCheckedChange:y,disabled:d})]}),e.jsxs("div",{className:"p-4 rounded-lg border bg-muted/30",children:[e.jsx("h4",{className:"text-sm font-medium mb-2",children:t("settingsThinking.cliEnvOverride")}),e.jsxs("p",{className:"text-sm text-muted-foreground mb-2",children:["Override per session with flags or"," ",e.jsx("code",{className:"px-1.5 py-0.5 rounded bg-muted",children:"CCS_THINKING"})," env var. Priority: flag > env > config."]}),e.jsxs("div",{className:"space-y-1 text-sm font-mono text-muted-foreground",children:[e.jsx("p",{children:"ccs gemini --thinking high"}),e.jsx("p",{children:"ccs codex --effort xhigh"}),e.jsx("p",{children:'CCS_THINKING=high ccs codex "debug this"'}),e.jsx("p",{children:"ccs config thinking --mode auto"})]})]})]})}),e.jsx("div",{className:"p-4 border-t bg-background",children:e.jsxs(I,{variant:"outline",size:"sm",onClick:p,disabled:b||d,className:"w-full",children:[e.jsx($,{className:`w-4 h-4 mr-2 ${b?"animate-spin":""}`}),t("settings.refresh")]})})]})}export{fe as default};
1
+ import{j as e}from"./radix-ui-nu4wz29m.js";import{r as o}from"./react-vendor-Bjx91N7w.js";import{a as q,bi as J,bk as X,d as I,n as Y,L as A,r as R,s as M,t as K,v as B,w as E,I as F,aI as Q}from"./index-BRtgic66.js";import{R as $,w as Z,x as ee,ad as se,_ as te,s as re}from"./icons-DQFHtVq5.js";import"./tanstack-bhJxV1h8.js";import"./notifications-B4_o8bcr.js";import"./utils-CzKF5WmX.js";import"./form-utils-CuHzLhJZ.js";import"./code-highlight-D4E79GKQ.js";const z={mode:"auto",tier_defaults:{opus:"high",sonnet:"medium",haiku:"low"},show_warnings:!0},U=1e4;function ie(){const[t,i]=o.useState(null),[b,d]=o.useState(!0),[_,N]=o.useState(!1),[p,g]=o.useState(null),[P,y]=o.useState(!1),f=o.useRef(void 0),w=o.useRef(!1),k=o.useCallback(async()=>{const r=new AbortController,c=setTimeout(()=>r.abort(),U);try{d(!0),g(null);const n=await fetch("/api/thinking",{signal:r.signal});if(clearTimeout(c),!n.ok)throw n.headers.get("content-type")?.includes("text/html")?new Error(`Server error (${n.status})`):new Error("Failed to load Thinking config");const m=await n.json();i(m.config||z),f.current=m.lastModified,w.current=!0}catch(n){clearTimeout(c),n.name==="AbortError"?g("Request timeout - please try again"):g(n.message)}finally{d(!1)}return()=>r.abort()},[]),l=o.useCallback(async r=>{if(!w.current||t===null){g("Cannot save settings before they load. Click Refresh and try again.");return}const c=t,n={...c,...r.mode!==void 0?{mode:r.mode}:{},...r.tier_defaults!==void 0?{tier_defaults:r.tier_defaults}:{},...r.show_warnings!==void 0?{show_warnings:r.show_warnings}:{}};r.clear_override||r.override===null?delete n.override:r.override!==void 0&&(n.override=r.override),r.clear_provider_overrides||r.provider_overrides===null?delete n.provider_overrides:r.provider_overrides!==void 0&&(n.provider_overrides=r.provider_overrides),i(n);const m=new AbortController,h=setTimeout(()=>m.abort(),U);try{N(!0),g(null);const x={...n,lastModified:f.current},u=await fetch("/api/thinking",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(x),signal:m.signal});if(clearTimeout(h),!u.ok){if(u.headers.get("content-type")?.includes("text/html"))throw new Error(`Server error (${u.status})`);const s=await u.json();throw u.status===409?new Error("Config changed by another session. Refreshing..."):new Error(s.error||"Failed to save")}const v=await u.json();i(v.config),f.current=v.lastModified,y(!0),setTimeout(()=>y(!1),1500)}catch(x){clearTimeout(h),i(c),x.name==="AbortError"?g("Request timeout - please try again"):(g(x.message),x.message.includes("another session")&&setTimeout(()=>k(),1e3))}finally{N(!1)}},[t,k]),T=o.useCallback(r=>{l({mode:r})},[l]),C=o.useCallback((r,c)=>{const n=t?.tier_defaults||z.tier_defaults;l({tier_defaults:{...n,[r]:c}})},[t,l]),O=o.useCallback(r=>{l({show_warnings:r})},[l]),D=o.useCallback(r=>{if(r===void 0){l({override:null,clear_override:!0});return}l({override:r,clear_override:!1})},[l]),L=o.useCallback((r,c,n)=>{const m=t?.provider_overrides||{},h=m[r]||{};if(n===void 0){const{[c]:x,...u}=h,v=Object.keys(u).length>0?u:void 0,{[r]:S,...s}=m,a=v?{...s,[r]:v}:s;l({provider_overrides:Object.keys(a).length>0?a:null,clear_provider_overrides:Object.keys(a).length===0})}else l({provider_overrides:{...m,[r]:{...h,[c]:n}},clear_provider_overrides:!1})},[t,l]);return{config:t||z,loading:b,saving:_,error:p,success:P,fetchConfig:k,saveConfig:l,setMode:T,setTierDefault:C,setShowWarnings:O,setOverride:D,setProviderOverride:L}}const H=[{value:"minimal",label:"Minimal (512 tokens)"},{value:"low",label:"Low (1K tokens)"},{value:"medium",label:"Medium (8K tokens)"},{value:"high",label:"High (24K tokens)"},{value:"xhigh",label:"Extra High (32K tokens)"},{value:"max",label:"Max (adaptive ceiling)"},{value:"auto",label:"Auto (dynamic)"}],ne=[{value:"__none__",label:"None (use CLI flags only)"},...H,{value:"__custom__",label:"Custom budget (number)"},{value:"off",label:"Off (disable thinking)"}],ae=["agy","gemini","codex"],G=0,V=1e5;function fe(){const{t}=q(),{config:i,loading:b,saving:d,error:_,success:N,fetchConfig:p,setMode:g,setTierDefault:P,setShowWarnings:y,setOverride:f,setProviderOverride:w}=ie(),[k,l]=o.useState(null),[T,C]=o.useState(""),[O,D]=o.useState([]),[L,r]=o.useState(null),c=o.useMemo(()=>Array.from(new Set([...ae,...Object.keys(i.provider_overrides??{}),...O])),[O,i.provider_overrides]),n=i.override===void 0?"__none__":typeof i.override=="number"||/^\d+$/.test(String(i.override))?"__custom__":String(i.override),m=typeof i.override=="number"||/^\d+$/.test(String(i.override??""))?String(i.override):"",h=L??m,x=Object.keys(i.provider_overrides??{}).length>0,u=k??x;o.useEffect(()=>{p()},[p]);const v=()=>{const s=T.trim().toLowerCase();s&&(c.includes(s)||D(a=>[...a,s]),C(""),l(!0))},S=()=>{const s=h.trim();if(!s){f(void 0);return}const a=Number.parseInt(s,10);Number.isNaN(a)||a<G||a>V||!/^\d+$/.test(s)||f(a)};return b?e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsxs("div",{className:"flex items-center gap-3 text-muted-foreground",children:[e.jsx($,{className:"w-5 h-5 animate-spin"}),e.jsx("span",{children:t("settings.loading")})]})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:`absolute left-5 right-5 top-20 z-10 transition-all duration-200 ease-out ${_||N?"opacity-100 translate-y-0":"opacity-0 -translate-y-2 pointer-events-none"}`,children:[_&&e.jsx(J,{variant:"destructive",className:"py-2 shadow-lg",children:e.jsxs("div",{className:"flex items-center justify-between w-full",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Z,{className:"h-4 w-4"}),e.jsx(X,{children:_})]}),e.jsxs(I,{variant:"outline",size:"sm",onClick:p,className:"h-7 px-2 text-xs border-destructive/50 hover:bg-destructive/10",children:[e.jsx($,{className:"w-3 h-3 mr-1"}),t("sharedPage.retry")]})]})}),N&&e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-md border border-green-200 bg-green-50 text-green-700 shadow-lg dark:border-green-900/50 dark:bg-green-900/90 dark:text-green-300",children:[e.jsx(ee,{className:"h-4 w-4 shrink-0"}),e.jsx("span",{className:"text-sm font-medium",children:t("settings.saved")})]})]}),e.jsx(Y,{className:"flex-1",children:e.jsxs("div",{className:"p-5 space-y-6",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(se,{className:"w-5 h-5 text-primary"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:t("settingsThinking.description")})]}),e.jsxs("div",{className:"flex items-start gap-2 p-3 rounded-lg bg-blue-50 dark:bg-blue-900/20 border border-blue-200 dark:border-blue-800",children:[e.jsx(te,{className:"w-4 h-4 text-blue-600 dark:text-blue-400 shrink-0 mt-0.5"}),e.jsxs("div",{className:"text-sm text-blue-700 dark:text-blue-300",children:[e.jsx("p",{className:"font-medium",children:t("settingsThinking.supportedProviders")}),e.jsxs("ul",{className:"mt-1 space-y-0.5 text-blue-600 dark:text-blue-400",children:[e.jsxs("li",{children:[t("settingsThinking.supportLine1Prefix")," ",e.jsx("strong",{children:"agy"}),","," ",e.jsx("strong",{children:"gemini"})," ",t("settingsThinking.supportLine1Suffix")]}),e.jsxs("li",{children:[t("settingsThinking.supportLine2Prefix")," ",e.jsx("strong",{children:"codex"})," ",t("settingsThinking.supportLine2SuffixPrefix"),e.jsx("code",{children:"--effort"}),t("settingsThinking.supportLine2SuffixPostfix")]}),e.jsxs("li",{children:[t("settingsThinking.supportLine3Prefix")," ",e.jsx("code",{children:"-high"}),t("settingsThinking.supportLine3Suffix")]})]})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-base font-medium",children:t("settingsThinking.modeTitle")}),e.jsx("div",{className:"space-y-2",children:["auto","off","manual"].map(s=>e.jsxs("div",{className:`flex items-center justify-between p-4 rounded-lg cursor-pointer transition-colors ${i.mode===s?"bg-primary/10 border border-primary/30":"bg-muted/50 hover:bg-muted/80"} ${d?"opacity-70 pointer-events-none":""}`,onClick:()=>{d||g(s)},children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium capitalize",children:s}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[s==="auto"&&t("settingsThinking.modeAutoDesc"),s==="off"&&t("settingsThinking.modeOffDesc"),s==="manual"&&t("settingsThinking.modeManualDesc")]})]}),e.jsx("div",{className:`w-4 h-4 rounded-full border-2 ${i.mode===s?"bg-primary border-primary":"border-muted-foreground/50"}`})]},s))})]}),i.mode==="auto"&&e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-base font-medium",children:t("settingsThinking.tierDefaults")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:t("settingsThinking.tierDefaultsDesc")}),e.jsx("div",{className:"space-y-3",children:["opus","sonnet","haiku"].map(s=>e.jsxs("div",{className:"flex items-center gap-4 p-3 rounded-lg bg-muted/30",children:[e.jsx(A,{className:"w-20 capitalize font-medium",children:s}),e.jsxs(R,{value:i.tier_defaults[s],onValueChange:a=>P(s,a),disabled:d,children:[e.jsx(M,{className:"flex-1",children:e.jsx(K,{})}),e.jsx(B,{children:H.map(a=>e.jsx(E,{value:a.value,children:a.label},a.value))})]})]},s))})]}),i.mode==="manual"&&e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-base font-medium",children:t("settingsThinking.persistentOverride")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:t("settingsThinking.persistentOverrideDesc")}),e.jsxs(R,{value:n,onValueChange:s=>{if(s==="__none__"){f(void 0);return}if(s==="__custom__"){h||r("8192");return}r(null),f(s)},disabled:d,children:[e.jsx(M,{children:e.jsx(K,{})}),e.jsx(B,{children:ne.map(s=>e.jsx(E,{value:s.value,children:s.label},s.value))})]}),n==="__custom__"&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(F,{type:"number",min:G,max:V,value:h,onChange:s=>r(s.target.value),onBlur:S,disabled:d,placeholder:t("settingsThinking.enterCustomBudget")}),e.jsx(I,{type:"button",size:"sm",variant:"outline",onClick:S,disabled:d,children:t("settingsThinking.apply")})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Range: ",G," to ",V]})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("button",{type:"button",className:"flex items-center gap-2 text-base font-medium w-full text-left",onClick:()=>l(s=>!(s??x)),disabled:d,children:[e.jsx(re,{className:`w-4 h-4 transition-transform ${u?"rotate-0":"-rotate-90"}`}),t("settingsThinking.providerOverrides",{count:Object.keys(i.provider_overrides??{}).length})]}),u&&e.jsxs("div",{className:"space-y-3",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:t("settingsThinking.providerOverridesDesc")}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(F,{value:T,onChange:s=>C(s.target.value),disabled:d,placeholder:t("settingsThinking.addProviderPlaceholder")}),e.jsx(I,{type:"button",size:"sm",variant:"outline",onClick:v,disabled:d,children:t("settingsGlobalEnv.add")})]}),c.map(s=>e.jsxs("div",{className:"space-y-2 p-3 rounded-lg bg-muted/30",children:[e.jsx(A,{className:"capitalize font-medium text-sm",children:s}),e.jsx("div",{className:"grid grid-cols-3 gap-2",children:["opus","sonnet","haiku"].map(a=>{const W=i.provider_overrides?.[s]?.[a]||"__default__";return e.jsxs("div",{className:"space-y-1",children:[e.jsx(A,{className:"text-xs text-muted-foreground capitalize",children:a}),e.jsxs(R,{value:W,onValueChange:j=>w(s,a,j==="__default__"?void 0:j),disabled:d,children:[e.jsx(M,{className:"h-8 text-xs",children:e.jsx(K,{})}),e.jsxs(B,{children:[e.jsx(E,{value:"__default__",children:t("cursorPage.default")}),H.map(j=>e.jsx(E,{value:j.value,children:j.label},j.value))]})]})]},a)})})]},s))]})]}),e.jsxs("div",{className:"flex items-center justify-between p-4 rounded-lg bg-muted/50",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:t("settingsThinking.showWarnings")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:t("settingsThinking.showWarningsDesc")})]}),e.jsx(Q,{checked:i.show_warnings??!0,onCheckedChange:y,disabled:d})]}),e.jsxs("div",{className:"p-4 rounded-lg border bg-muted/30",children:[e.jsx("h4",{className:"text-sm font-medium mb-2",children:t("settingsThinking.cliEnvOverride")}),e.jsxs("p",{className:"text-sm text-muted-foreground mb-2",children:["Override per session with flags or"," ",e.jsx("code",{className:"px-1.5 py-0.5 rounded bg-muted",children:"CCS_THINKING"})," env var. Priority: flag > env > config."]}),e.jsxs("div",{className:"space-y-1 text-sm font-mono text-muted-foreground",children:[e.jsx("p",{children:"ccs gemini --thinking high"}),e.jsx("p",{children:"ccs codex --effort xhigh"}),e.jsx("p",{children:'CCS_THINKING=high ccs codex "debug this"'}),e.jsx("p",{children:"ccs config thinking --mode auto"})]})]})]})}),e.jsx("div",{className:"p-4 border-t bg-background",children:e.jsxs(I,{variant:"outline",size:"sm",onClick:p,disabled:b||d,className:"w-full",children:[e.jsx($,{className:`w-4 h-4 mr-2 ${b?"animate-spin":""}`}),t("settings.refresh")]})})]})}export{fe as default};