@kaitranntt/ccs 7.74.0 → 7.75.0-dev.10

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 (850) 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.d.ts +1 -1
  6. package/dist/api/services/profile-writer.d.ts.map +1 -1
  7. package/dist/api/services/profile-writer.js +12 -6
  8. package/dist/api/services/profile-writer.js.map +1 -1
  9. package/dist/auth/profile-registry.d.ts.map +1 -1
  10. package/dist/auth/profile-registry.js +9 -0
  11. package/dist/auth/profile-registry.js.map +1 -1
  12. package/dist/bin/ccsxp-runtime.d.ts +8 -0
  13. package/dist/bin/ccsxp-runtime.d.ts.map +1 -1
  14. package/dist/bin/ccsxp-runtime.js +60 -3
  15. package/dist/bin/ccsxp-runtime.js.map +1 -1
  16. package/dist/ccs.js +29 -4
  17. package/dist/ccs.js.map +1 -1
  18. package/dist/cliproxy/{account-manager.d.ts → accounts/account-manager.d.ts} +2 -2
  19. package/dist/cliproxy/accounts/account-manager.d.ts.map +1 -0
  20. package/dist/cliproxy/{account-manager.js → accounts/account-manager.js} +34 -34
  21. package/dist/cliproxy/accounts/account-manager.js.map +1 -0
  22. package/dist/cliproxy/{account-safety.d.ts → accounts/account-safety.d.ts} +1 -1
  23. package/dist/cliproxy/accounts/account-safety.d.ts.map +1 -0
  24. package/dist/cliproxy/{account-safety.js → accounts/account-safety.js} +10 -5
  25. package/dist/cliproxy/accounts/account-safety.js.map +1 -0
  26. package/dist/cliproxy/accounts/account-stats-key.d.ts.map +1 -0
  27. package/dist/cliproxy/accounts/account-stats-key.js.map +1 -0
  28. package/dist/cliproxy/accounts/registry.js +1 -1
  29. package/dist/cliproxy/accounts/registry.js.map +1 -1
  30. package/dist/cliproxy/accounts/token-file-ops.js +1 -1
  31. package/dist/cliproxy/accounts/token-file-ops.js.map +1 -1
  32. package/dist/cliproxy/{codex-plan-compatibility.d.ts → ai-providers/codex-plan-compatibility.d.ts} +4 -4
  33. package/dist/cliproxy/ai-providers/codex-plan-compatibility.d.ts.map +1 -0
  34. package/dist/cliproxy/{codex-plan-compatibility.js → ai-providers/codex-plan-compatibility.js} +6 -5
  35. package/dist/cliproxy/ai-providers/codex-plan-compatibility.js.map +1 -0
  36. package/dist/cliproxy/ai-providers/codex-reasoning-proxy.d.ts.map +1 -0
  37. package/dist/cliproxy/{codex-reasoning-proxy.js → ai-providers/codex-reasoning-proxy.js} +1 -1
  38. package/dist/cliproxy/ai-providers/codex-reasoning-proxy.js.map +1 -0
  39. package/dist/cliproxy/ai-providers/config-store.js +3 -3
  40. package/dist/cliproxy/ai-providers/config-store.js.map +1 -1
  41. package/dist/cliproxy/{managed-model-prefixes.d.ts → ai-providers/managed-model-prefixes.d.ts} +1 -1
  42. package/dist/cliproxy/ai-providers/managed-model-prefixes.d.ts.map +1 -0
  43. package/dist/cliproxy/{managed-model-prefixes.js → ai-providers/managed-model-prefixes.js} +3 -3
  44. package/dist/cliproxy/ai-providers/managed-model-prefixes.js.map +1 -0
  45. package/dist/cliproxy/{model-id-normalizer.d.ts → ai-providers/model-id-normalizer.d.ts} +1 -1
  46. package/dist/cliproxy/ai-providers/model-id-normalizer.d.ts.map +1 -0
  47. package/dist/cliproxy/{model-id-normalizer.js → ai-providers/model-id-normalizer.js} +1 -1
  48. package/dist/cliproxy/ai-providers/model-id-normalizer.js.map +1 -0
  49. package/dist/cliproxy/ai-providers/openai-compat-manager.d.ts.map +1 -0
  50. package/dist/cliproxy/{openai-compat-manager.js → ai-providers/openai-compat-manager.js} +7 -6
  51. package/dist/cliproxy/ai-providers/openai-compat-manager.js.map +1 -0
  52. package/dist/cliproxy/ai-providers/schema-sanitizer.d.ts.map +1 -0
  53. package/dist/cliproxy/ai-providers/schema-sanitizer.js.map +1 -0
  54. package/dist/cliproxy/ai-providers/service.d.ts.map +1 -1
  55. package/dist/cliproxy/ai-providers/service.js +10 -3
  56. package/dist/cliproxy/ai-providers/service.js.map +1 -1
  57. package/dist/cliproxy/{tool-name-mapper.d.ts → ai-providers/tool-name-mapper.d.ts} +7 -2
  58. package/dist/cliproxy/ai-providers/tool-name-mapper.d.ts.map +1 -0
  59. package/dist/cliproxy/{tool-name-mapper.js → ai-providers/tool-name-mapper.js} +35 -21
  60. package/dist/cliproxy/ai-providers/tool-name-mapper.js.map +1 -0
  61. package/dist/cliproxy/{tool-name-sanitizer.d.ts → ai-providers/tool-name-sanitizer.d.ts} +2 -1
  62. package/dist/cliproxy/ai-providers/tool-name-sanitizer.d.ts.map +1 -0
  63. package/dist/cliproxy/{tool-name-sanitizer.js → ai-providers/tool-name-sanitizer.js} +23 -3
  64. package/dist/cliproxy/ai-providers/tool-name-sanitizer.js.map +1 -0
  65. package/dist/cliproxy/auth/antigravity-responsibility.d.ts.map +1 -0
  66. package/dist/cliproxy/{antigravity-responsibility.js → auth/antigravity-responsibility.js} +2 -2
  67. package/dist/cliproxy/auth/antigravity-responsibility.js.map +1 -0
  68. package/dist/cliproxy/{auth-handler.d.ts → auth/auth-handler.d.ts} +5 -5
  69. package/dist/cliproxy/auth/auth-handler.d.ts.map +1 -0
  70. package/dist/cliproxy/{auth-handler.js → auth/auth-handler.js} +23 -23
  71. package/dist/cliproxy/auth/auth-handler.js.map +1 -0
  72. package/dist/cliproxy/{auth-session-manager.d.ts → auth/auth-session-manager.d.ts} +1 -1
  73. package/dist/cliproxy/auth/auth-session-manager.d.ts.map +1 -0
  74. package/dist/cliproxy/{auth-session-manager.js → auth/auth-session-manager.js} +16 -9
  75. package/dist/cliproxy/auth/auth-session-manager.js.map +1 -0
  76. package/dist/cliproxy/auth/auth-token-manager.d.ts.map +1 -0
  77. package/dist/cliproxy/{auth-token-manager.js → auth/auth-token-manager.js} +6 -6
  78. package/dist/cliproxy/auth/auth-token-manager.js.map +1 -0
  79. package/dist/cliproxy/auth/auth-types.d.ts +1 -1
  80. package/dist/cliproxy/auth/auth-types.d.ts.map +1 -1
  81. package/dist/cliproxy/auth/auth-utils.d.ts.map +1 -0
  82. package/dist/cliproxy/auth/auth-utils.js.map +1 -0
  83. package/dist/cliproxy/auth/device-code-handler.d.ts.map +1 -0
  84. package/dist/cliproxy/auth/device-code-handler.js.map +1 -0
  85. package/dist/cliproxy/auth/kiro-import.js +1 -1
  86. package/dist/cliproxy/auth/kiro-import.js.map +1 -1
  87. package/dist/cliproxy/auth/oauth-handler.d.ts +2 -2
  88. package/dist/cliproxy/auth/oauth-handler.d.ts.map +1 -1
  89. package/dist/cliproxy/auth/oauth-handler.js +25 -5
  90. package/dist/cliproxy/auth/oauth-handler.js.map +1 -1
  91. package/dist/cliproxy/auth/oauth-process.d.ts +1 -1
  92. package/dist/cliproxy/auth/oauth-process.d.ts.map +1 -1
  93. package/dist/cliproxy/auth/oauth-process.js +3 -3
  94. package/dist/cliproxy/auth/oauth-process.js.map +1 -1
  95. package/dist/cliproxy/auth/project-selection-handler.d.ts.map +1 -0
  96. package/dist/cliproxy/auth/project-selection-handler.js.map +1 -0
  97. package/dist/cliproxy/{provider-entitlement-evidence.d.ts → auth/provider-entitlement-evidence.d.ts} +1 -1
  98. package/dist/cliproxy/auth/provider-entitlement-evidence.d.ts.map +1 -0
  99. package/dist/cliproxy/auth/provider-entitlement-evidence.js.map +1 -0
  100. package/dist/cliproxy/{provider-entitlement-types.d.ts → auth/provider-entitlement-types.d.ts} +1 -1
  101. package/dist/cliproxy/auth/provider-entitlement-types.d.ts.map +1 -0
  102. package/dist/cliproxy/auth/provider-entitlement-types.js.map +1 -0
  103. package/dist/cliproxy/auth/provider-refreshers/index.js +1 -1
  104. package/dist/cliproxy/auth/provider-refreshers/index.js.map +1 -1
  105. package/dist/cliproxy/auth/token-expiry-checker.js +1 -1
  106. package/dist/cliproxy/auth/token-expiry-checker.js.map +1 -1
  107. package/dist/cliproxy/auth/token-manager.d.ts +1 -1
  108. package/dist/cliproxy/auth/token-manager.d.ts.map +1 -1
  109. package/dist/cliproxy/auth/token-manager.js +4 -4
  110. package/dist/cliproxy/auth/token-manager.js.map +1 -1
  111. package/dist/cliproxy/binary/extractor.js +1 -1
  112. package/dist/cliproxy/binary/extractor.js.map +1 -1
  113. package/dist/cliproxy/binary/installer.d.ts +1 -1
  114. package/dist/cliproxy/binary/installer.d.ts.map +1 -1
  115. package/dist/cliproxy/binary/installer.js +1 -1
  116. package/dist/cliproxy/binary/installer.js.map +1 -1
  117. package/dist/cliproxy/binary/lifecycle.d.ts.map +1 -1
  118. package/dist/cliproxy/binary/lifecycle.js +5 -4
  119. package/dist/cliproxy/binary/lifecycle.js.map +1 -1
  120. package/dist/cliproxy/{platform-detector.d.ts → binary/platform-detector.d.ts} +1 -1
  121. package/dist/cliproxy/binary/platform-detector.d.ts.map +1 -0
  122. package/dist/cliproxy/binary/platform-detector.js.map +1 -0
  123. package/dist/cliproxy/binary/tar-extractor.d.ts.map +1 -1
  124. package/dist/cliproxy/binary/tar-extractor.js +1 -1
  125. package/dist/cliproxy/binary/tar-extractor.js.map +1 -1
  126. package/dist/cliproxy/binary/version-cache.js +2 -2
  127. package/dist/cliproxy/binary/version-cache.js.map +1 -1
  128. package/dist/cliproxy/binary/version-checker.js +1 -1
  129. package/dist/cliproxy/binary/version-checker.js.map +1 -1
  130. package/dist/cliproxy/binary/zip-extractor.d.ts.map +1 -1
  131. package/dist/cliproxy/binary/zip-extractor.js +1 -1
  132. package/dist/cliproxy/binary/zip-extractor.js.map +1 -1
  133. package/dist/cliproxy/binary-manager.js +2 -2
  134. package/dist/cliproxy/binary-manager.js.map +1 -1
  135. package/dist/cliproxy/{base-config-loader.d.ts → config/base-config-loader.d.ts} +1 -1
  136. package/dist/cliproxy/config/base-config-loader.d.ts.map +1 -0
  137. package/dist/cliproxy/{base-config-loader.js → config/base-config-loader.js} +1 -1
  138. package/dist/cliproxy/config/base-config-loader.js.map +1 -0
  139. package/dist/cliproxy/config/composite-validator.d.ts.map +1 -0
  140. package/dist/cliproxy/{composite-validator.js → config/composite-validator.js} +2 -2
  141. package/dist/cliproxy/config/composite-validator.js.map +1 -0
  142. package/dist/cliproxy/{config-generator.d.ts → config/config-generator.d.ts} +1 -1
  143. package/dist/cliproxy/config/config-generator.d.ts.map +1 -0
  144. package/dist/cliproxy/{config-generator.js → config/config-generator.js} +1 -1
  145. package/dist/cliproxy/config/config-generator.js.map +1 -0
  146. package/dist/cliproxy/config/env-builder.js +3 -3
  147. package/dist/cliproxy/config/env-builder.js.map +1 -1
  148. package/dist/cliproxy/config/generator.d.ts +2 -1
  149. package/dist/cliproxy/config/generator.d.ts.map +1 -1
  150. package/dist/cliproxy/config/generator.js +28 -4
  151. package/dist/cliproxy/config/generator.js.map +1 -1
  152. package/dist/cliproxy/{model-config.d.ts → config/model-config.d.ts} +1 -1
  153. package/dist/cliproxy/config/model-config.d.ts.map +1 -0
  154. package/dist/cliproxy/{model-config.js → config/model-config.js} +5 -5
  155. package/dist/cliproxy/config/model-config.js.map +1 -0
  156. package/dist/cliproxy/config/thinking-config.js +1 -1
  157. package/dist/cliproxy/config/thinking-config.js.map +1 -1
  158. package/dist/cliproxy/{cliproxy-executor.d.ts → executor/cliproxy-executor.d.ts} +2 -2
  159. package/dist/cliproxy/executor/cliproxy-executor.d.ts.map +1 -0
  160. package/dist/cliproxy/{cliproxy-executor.js → executor/cliproxy-executor.js} +6 -6
  161. package/dist/cliproxy/executor/cliproxy-executor.js.map +1 -0
  162. package/dist/cliproxy/executor/env-resolver.d.ts +5 -5
  163. package/dist/cliproxy/executor/env-resolver.d.ts.map +1 -1
  164. package/dist/cliproxy/executor/env-resolver.js +3 -3
  165. package/dist/cliproxy/executor/env-resolver.js.map +1 -1
  166. package/dist/cliproxy/executor/index.d.ts +5 -0
  167. package/dist/cliproxy/executor/index.d.ts.map +1 -1
  168. package/dist/cliproxy/executor/index.js +39 -23
  169. package/dist/cliproxy/executor/index.js.map +1 -1
  170. package/dist/cliproxy/executor/lifecycle-manager.js +1 -1
  171. package/dist/cliproxy/executor/lifecycle-manager.js.map +1 -1
  172. package/dist/cliproxy/executor/retry-handler.js +4 -4
  173. package/dist/cliproxy/executor/retry-handler.js.map +1 -1
  174. package/dist/cliproxy/executor/session-bridge.d.ts.map +1 -1
  175. package/dist/cliproxy/executor/session-bridge.js +3 -3
  176. package/dist/cliproxy/executor/session-bridge.js.map +1 -1
  177. package/dist/cliproxy/index.d.ts +31 -31
  178. package/dist/cliproxy/index.d.ts.map +1 -1
  179. package/dist/cliproxy/index.js +20 -20
  180. package/dist/cliproxy/index.js.map +1 -1
  181. package/dist/cliproxy/{management-api-client.d.ts → management/management-api-client.d.ts} +1 -1
  182. package/dist/cliproxy/management/management-api-client.d.ts.map +1 -0
  183. package/dist/cliproxy/{management-api-client.js → management/management-api-client.js} +4 -3
  184. package/dist/cliproxy/management/management-api-client.js.map +1 -0
  185. package/dist/cliproxy/management/management-api-types.d.ts.map +1 -0
  186. package/dist/cliproxy/management/management-api-types.js.map +1 -0
  187. package/dist/cliproxy/management/remote-token-uploader.d.ts.map +1 -0
  188. package/dist/cliproxy/{remote-token-uploader.js → management/remote-token-uploader.js} +2 -2
  189. package/dist/cliproxy/management/remote-token-uploader.js.map +1 -0
  190. package/dist/cliproxy/model-catalog.d.ts.map +1 -1
  191. package/dist/cliproxy/model-catalog.js +13 -1
  192. package/dist/cliproxy/model-catalog.js.map +1 -1
  193. package/dist/cliproxy/proxy/https-tunnel-proxy.d.ts.map +1 -0
  194. package/dist/cliproxy/{https-tunnel-proxy.js → proxy/https-tunnel-proxy.js} +7 -2
  195. package/dist/cliproxy/proxy/https-tunnel-proxy.js.map +1 -0
  196. package/dist/cliproxy/{proxy-config-resolver.d.ts → proxy/proxy-config-resolver.d.ts} +1 -1
  197. package/dist/cliproxy/proxy/proxy-config-resolver.d.ts.map +1 -0
  198. package/dist/cliproxy/{proxy-config-resolver.js → proxy/proxy-config-resolver.js} +3 -3
  199. package/dist/cliproxy/proxy/proxy-config-resolver.js.map +1 -0
  200. package/dist/cliproxy/{proxy-detector.d.ts → proxy/proxy-detector.d.ts} +1 -1
  201. package/dist/cliproxy/proxy/proxy-detector.d.ts.map +1 -0
  202. package/dist/cliproxy/{proxy-detector.js → proxy/proxy-detector.js} +7 -7
  203. package/dist/cliproxy/proxy/proxy-detector.js.map +1 -0
  204. package/dist/cliproxy/proxy/proxy-target-resolver.d.ts.map +1 -0
  205. package/dist/cliproxy/{proxy-target-resolver.js → proxy/proxy-target-resolver.js} +7 -7
  206. package/dist/cliproxy/proxy/proxy-target-resolver.js.map +1 -0
  207. package/dist/cliproxy/proxy/tool-sanitization-proxy.d.ts.map +1 -0
  208. package/dist/cliproxy/{tool-sanitization-proxy.js → proxy/tool-sanitization-proxy.js} +6 -6
  209. package/dist/cliproxy/proxy/tool-sanitization-proxy.js.map +1 -0
  210. package/dist/cliproxy/quota/gemini-cli-quota-normalizer.d.ts.map +1 -0
  211. package/dist/cliproxy/quota/gemini-cli-quota-normalizer.js.map +1 -0
  212. package/dist/cliproxy/quota/quota-fetcher-claude-normalizer.d.ts.map +1 -0
  213. package/dist/cliproxy/{quota-fetcher-claude-normalizer.js → quota/quota-fetcher-claude-normalizer.js} +17 -13
  214. package/dist/cliproxy/quota/quota-fetcher-claude-normalizer.js.map +1 -0
  215. package/dist/cliproxy/quota/quota-fetcher-claude.d.ts.map +1 -0
  216. package/dist/cliproxy/{quota-fetcher-claude.js → quota/quota-fetcher-claude.js} +3 -3
  217. package/dist/cliproxy/quota/quota-fetcher-claude.js.map +1 -0
  218. package/dist/cliproxy/{quota-fetcher-codex.d.ts → quota/quota-fetcher-codex.d.ts} +18 -3
  219. package/dist/cliproxy/quota/quota-fetcher-codex.d.ts.map +1 -0
  220. package/dist/cliproxy/{quota-fetcher-codex.js → quota/quota-fetcher-codex.js} +78 -28
  221. package/dist/cliproxy/quota/quota-fetcher-codex.js.map +1 -0
  222. package/dist/cliproxy/quota/quota-fetcher-gemini-cli.d.ts.map +1 -0
  223. package/dist/cliproxy/{quota-fetcher-gemini-cli.js → quota/quota-fetcher-gemini-cli.js} +6 -6
  224. package/dist/cliproxy/quota/quota-fetcher-gemini-cli.js.map +1 -0
  225. package/dist/cliproxy/quota/quota-fetcher-ghcp.d.ts.map +1 -0
  226. package/dist/cliproxy/{quota-fetcher-ghcp.js → quota/quota-fetcher-ghcp.js} +21 -10
  227. package/dist/cliproxy/quota/quota-fetcher-ghcp.js.map +1 -0
  228. package/dist/cliproxy/{quota-fetcher.d.ts → quota/quota-fetcher.d.ts} +3 -3
  229. package/dist/cliproxy/quota/quota-fetcher.d.ts.map +1 -0
  230. package/dist/cliproxy/{quota-fetcher.js → quota/quota-fetcher.js} +5 -5
  231. package/dist/cliproxy/quota/quota-fetcher.js.map +1 -0
  232. package/dist/cliproxy/{quota-manager.d.ts → quota/quota-manager.d.ts} +7 -4
  233. package/dist/cliproxy/quota/quota-manager.d.ts.map +1 -0
  234. package/dist/cliproxy/{quota-manager.js → quota/quota-manager.js} +184 -70
  235. package/dist/cliproxy/quota/quota-manager.js.map +1 -0
  236. package/dist/cliproxy/quota/quota-response-cache.d.ts.map +1 -0
  237. package/dist/cliproxy/quota/quota-response-cache.js.map +1 -0
  238. package/dist/cliproxy/{quota-types.d.ts → quota/quota-types.d.ts} +17 -3
  239. package/dist/cliproxy/quota/quota-types.d.ts.map +1 -0
  240. package/dist/cliproxy/quota/quota-types.js.map +1 -0
  241. package/dist/cliproxy/{routing-strategy-http.d.ts → routing/routing-strategy-http.d.ts} +2 -1
  242. package/dist/cliproxy/routing/routing-strategy-http.d.ts.map +1 -0
  243. package/dist/cliproxy/{routing-strategy-http.js → routing/routing-strategy-http.js} +8 -3
  244. package/dist/cliproxy/routing/routing-strategy-http.js.map +1 -0
  245. package/dist/cliproxy/routing/routing-strategy.d.ts +41 -0
  246. package/dist/cliproxy/routing/routing-strategy.d.ts.map +1 -0
  247. package/dist/cliproxy/routing/routing-strategy.js +272 -0
  248. package/dist/cliproxy/routing/routing-strategy.js.map +1 -0
  249. package/dist/cliproxy/service-manager.d.ts +17 -1
  250. package/dist/cliproxy/service-manager.d.ts.map +1 -1
  251. package/dist/cliproxy/service-manager.js +15 -10
  252. package/dist/cliproxy/service-manager.js.map +1 -1
  253. package/dist/cliproxy/services/binary-service.js +1 -1
  254. package/dist/cliproxy/services/binary-service.js.map +1 -1
  255. package/dist/cliproxy/{catalog-cache.d.ts → services/catalog-cache.d.ts} +3 -3
  256. package/dist/cliproxy/services/catalog-cache.d.ts.map +1 -0
  257. package/dist/cliproxy/{catalog-cache.js → services/catalog-cache.js} +4 -4
  258. package/dist/cliproxy/services/catalog-cache.js.map +1 -0
  259. package/dist/cliproxy/{catalog-routing.d.ts → services/catalog-routing.d.ts} +3 -3
  260. package/dist/cliproxy/services/catalog-routing.d.ts.map +1 -0
  261. package/dist/cliproxy/{catalog-routing.js → services/catalog-routing.js} +1 -1
  262. package/dist/cliproxy/services/catalog-routing.js.map +1 -0
  263. package/dist/cliproxy/services/proxy-lifecycle-service.js +1 -1
  264. package/dist/cliproxy/services/proxy-lifecycle-service.js.map +1 -1
  265. package/dist/cliproxy/{remote-auth-fetcher.d.ts → services/remote-auth-fetcher.d.ts} +2 -2
  266. package/dist/cliproxy/services/remote-auth-fetcher.d.ts.map +1 -0
  267. package/dist/cliproxy/{remote-auth-fetcher.js → services/remote-auth-fetcher.js} +2 -2
  268. package/dist/cliproxy/services/remote-auth-fetcher.js.map +1 -0
  269. package/dist/cliproxy/services/remote-proxy-client.d.ts.map +1 -0
  270. package/dist/cliproxy/{remote-proxy-client.js → services/remote-proxy-client.js} +1 -1
  271. package/dist/cliproxy/services/remote-proxy-client.js.map +1 -0
  272. package/dist/cliproxy/services/startup-lock.d.ts.map +1 -0
  273. package/dist/cliproxy/{startup-lock.js → services/startup-lock.js} +2 -2
  274. package/dist/cliproxy/services/startup-lock.js.map +1 -0
  275. package/dist/cliproxy/services/stats-fetcher.d.ts.map +1 -0
  276. package/dist/cliproxy/{stats-fetcher.js → services/stats-fetcher.js} +2 -2
  277. package/dist/cliproxy/services/stats-fetcher.js.map +1 -0
  278. package/dist/cliproxy/services/stats-transformer.d.ts.map +1 -0
  279. package/dist/cliproxy/{stats-transformer.js → services/stats-transformer.js} +3 -3
  280. package/dist/cliproxy/services/stats-transformer.js.map +1 -0
  281. package/dist/cliproxy/services/variant-config-adapter.js +1 -1
  282. package/dist/cliproxy/services/variant-config-adapter.js.map +1 -1
  283. package/dist/cliproxy/services/variant-service.js +3 -3
  284. package/dist/cliproxy/services/variant-service.js.map +1 -1
  285. package/dist/cliproxy/services/variant-settings.js +3 -3
  286. package/dist/cliproxy/services/variant-settings.js.map +1 -1
  287. package/dist/cliproxy/session-tracker.js +2 -2
  288. package/dist/cliproxy/session-tracker.js.map +1 -1
  289. package/dist/cliproxy/sync/local-config-sync.js +1 -1
  290. package/dist/cliproxy/sync/local-config-sync.js.map +1 -1
  291. package/dist/cliproxy/sync/profile-mapper.d.ts +1 -1
  292. package/dist/cliproxy/sync/profile-mapper.d.ts.map +1 -1
  293. package/dist/cliproxy/sync/profile-mapper.js +21 -0
  294. package/dist/cliproxy/sync/profile-mapper.js.map +1 -1
  295. package/dist/cliproxy/types/binary-types.d.ts +48 -0
  296. package/dist/cliproxy/types/binary-types.d.ts.map +1 -0
  297. package/dist/cliproxy/types/binary-types.js +6 -0
  298. package/dist/cliproxy/types/binary-types.js.map +1 -0
  299. package/dist/cliproxy/types/config-types.d.ts +89 -0
  300. package/dist/cliproxy/types/config-types.d.ts.map +1 -0
  301. package/dist/cliproxy/types/config-types.js +6 -0
  302. package/dist/cliproxy/types/config-types.js.map +1 -0
  303. package/dist/cliproxy/types/index.d.ts +5 -0
  304. package/dist/cliproxy/types/index.d.ts.map +1 -0
  305. package/dist/cliproxy/types/index.js +21 -0
  306. package/dist/cliproxy/types/index.js.map +1 -0
  307. package/dist/cliproxy/types/platform-types.d.ts +17 -0
  308. package/dist/cliproxy/types/platform-types.d.ts.map +1 -0
  309. package/dist/cliproxy/types/platform-types.js +6 -0
  310. package/dist/cliproxy/types/platform-types.js.map +1 -0
  311. package/dist/cliproxy/types/provider-types.d.ts +27 -0
  312. package/dist/cliproxy/types/provider-types.d.ts.map +1 -0
  313. package/dist/cliproxy/types/provider-types.js +16 -0
  314. package/dist/cliproxy/types/provider-types.js.map +1 -0
  315. package/dist/cliproxy/types.d.ts +4 -273
  316. package/dist/cliproxy/types.d.ts.map +1 -1
  317. package/dist/cliproxy/types.js +18 -14
  318. package/dist/cliproxy/types.js.map +1 -1
  319. package/dist/commands/api-command/create-command.d.ts.map +1 -1
  320. package/dist/commands/api-command/create-command.js +4 -1
  321. package/dist/commands/api-command/create-command.js.map +1 -1
  322. package/dist/commands/api-command/help.d.ts.map +1 -1
  323. package/dist/commands/api-command/help.js +4 -0
  324. package/dist/commands/api-command/help.js.map +1 -1
  325. package/dist/commands/api-command/shared.d.ts +2 -1
  326. package/dist/commands/api-command/shared.d.ts.map +1 -1
  327. package/dist/commands/api-command/shared.js +9 -0
  328. package/dist/commands/api-command/shared.js.map +1 -1
  329. package/dist/commands/cleanup-command.js +1 -1
  330. package/dist/commands/cleanup-command.js.map +1 -1
  331. package/dist/commands/cliproxy/auth-subcommand.js +1 -1
  332. package/dist/commands/cliproxy/auth-subcommand.js.map +1 -1
  333. package/dist/commands/cliproxy/catalog-subcommand.js +4 -4
  334. package/dist/commands/cliproxy/catalog-subcommand.js.map +1 -1
  335. package/dist/commands/cliproxy/help-subcommand.d.ts.map +1 -1
  336. package/dist/commands/cliproxy/help-subcommand.js +4 -2
  337. package/dist/commands/cliproxy/help-subcommand.js.map +1 -1
  338. package/dist/commands/cliproxy/index.d.ts.map +1 -1
  339. package/dist/commands/cliproxy/index.js +12 -0
  340. package/dist/commands/cliproxy/index.js.map +1 -1
  341. package/dist/commands/cliproxy/install-subcommand.js +1 -1
  342. package/dist/commands/cliproxy/install-subcommand.js.map +1 -1
  343. package/dist/commands/cliproxy/proxy-lifecycle-subcommand.js +1 -1
  344. package/dist/commands/cliproxy/proxy-lifecycle-subcommand.js.map +1 -1
  345. package/dist/commands/cliproxy/quota-subcommand.d.ts +1 -1
  346. package/dist/commands/cliproxy/quota-subcommand.d.ts.map +1 -1
  347. package/dist/commands/cliproxy/quota-subcommand.js +87 -31
  348. package/dist/commands/cliproxy/quota-subcommand.js.map +1 -1
  349. package/dist/commands/cliproxy/routing-subcommand.d.ts +3 -0
  350. package/dist/commands/cliproxy/routing-subcommand.d.ts.map +1 -1
  351. package/dist/commands/cliproxy/routing-subcommand.js +128 -3
  352. package/dist/commands/cliproxy/routing-subcommand.js.map +1 -1
  353. package/dist/commands/cliproxy/variant-subcommand.js +4 -4
  354. package/dist/commands/cliproxy/variant-subcommand.js.map +1 -1
  355. package/dist/commands/command-catalog.d.ts.map +1 -1
  356. package/dist/commands/command-catalog.js +4 -1
  357. package/dist/commands/command-catalog.js.map +1 -1
  358. package/dist/commands/completion-backend.d.ts.map +1 -1
  359. package/dist/commands/completion-backend.js +16 -1
  360. package/dist/commands/completion-backend.js.map +1 -1
  361. package/dist/commands/config-command.js +1 -1
  362. package/dist/commands/config-command.js.map +1 -1
  363. package/dist/commands/config-dashboard-host.d.ts.map +1 -1
  364. package/dist/commands/config-dashboard-host.js +14 -2
  365. package/dist/commands/config-dashboard-host.js.map +1 -1
  366. package/dist/commands/doctor-command.d.ts.map +1 -1
  367. package/dist/commands/doctor-command.js +9 -0
  368. package/dist/commands/doctor-command.js.map +1 -1
  369. package/dist/commands/tokens-command.js +1 -1
  370. package/dist/commands/tokens-command.js.map +1 -1
  371. package/dist/config/config-loader-facade.d.ts +57 -0
  372. package/dist/config/config-loader-facade.d.ts.map +1 -0
  373. package/dist/config/config-loader-facade.js +131 -0
  374. package/dist/config/config-loader-facade.js.map +1 -0
  375. package/dist/config/schemas/auth.d.ts +97 -0
  376. package/dist/config/schemas/auth.d.ts.map +1 -0
  377. package/dist/config/schemas/auth.js +25 -0
  378. package/dist/config/schemas/auth.js.map +1 -0
  379. package/dist/config/schemas/browser.d.ts +53 -0
  380. package/dist/config/schemas/browser.d.ts.map +1 -0
  381. package/dist/config/schemas/browser.js +27 -0
  382. package/dist/config/schemas/browser.js.map +1 -0
  383. package/dist/config/schemas/channels.d.ts +27 -0
  384. package/dist/config/schemas/channels.d.ts.map +1 -0
  385. package/dist/config/schemas/channels.js +19 -0
  386. package/dist/config/schemas/channels.js.map +1 -0
  387. package/dist/config/schemas/cliproxy.d.ts +140 -0
  388. package/dist/config/schemas/cliproxy.d.ts.map +1 -0
  389. package/dist/config/schemas/cliproxy.js +18 -0
  390. package/dist/config/schemas/cliproxy.js.map +1 -0
  391. package/dist/config/schemas/copilot-cursor.d.ts +75 -0
  392. package/dist/config/schemas/copilot-cursor.d.ts.map +1 -0
  393. package/dist/config/schemas/copilot-cursor.js +36 -0
  394. package/dist/config/schemas/copilot-cursor.js.map +1 -0
  395. package/dist/config/schemas/index.d.ts +28 -0
  396. package/dist/config/schemas/index.d.ts.map +1 -0
  397. package/dist/config/schemas/index.js +51 -0
  398. package/dist/config/schemas/index.js.map +1 -0
  399. package/dist/config/schemas/logging.d.ts +43 -0
  400. package/dist/config/schemas/logging.d.ts.map +1 -0
  401. package/dist/config/schemas/logging.js +23 -0
  402. package/dist/config/schemas/logging.js.map +1 -0
  403. package/dist/config/schemas/providers.d.ts +14 -0
  404. package/dist/config/schemas/providers.d.ts.map +1 -0
  405. package/dist/config/schemas/providers.js +21 -0
  406. package/dist/config/schemas/providers.js.map +1 -0
  407. package/dist/config/schemas/proxy-server.d.ts +141 -0
  408. package/dist/config/schemas/proxy-server.d.ts.map +1 -0
  409. package/dist/config/schemas/proxy-server.js +71 -0
  410. package/dist/config/schemas/proxy-server.js.map +1 -0
  411. package/dist/config/schemas/quota.d.ts +88 -0
  412. package/dist/config/schemas/quota.d.ts.map +1 -0
  413. package/dist/config/schemas/quota.js +47 -0
  414. package/dist/config/schemas/quota.js.map +1 -0
  415. package/dist/config/schemas/thinking.d.ts +50 -0
  416. package/dist/config/schemas/thinking.d.ts.map +1 -0
  417. package/dist/config/schemas/thinking.js +26 -0
  418. package/dist/config/schemas/thinking.js.map +1 -0
  419. package/dist/config/schemas/unified-config.d.ts +74 -0
  420. package/dist/config/schemas/unified-config.d.ts.map +1 -0
  421. package/dist/config/schemas/unified-config.js +131 -0
  422. package/dist/config/schemas/unified-config.js.map +1 -0
  423. package/dist/config/schemas/version.d.ts +23 -0
  424. package/dist/config/schemas/version.d.ts.map +1 -0
  425. package/dist/config/schemas/version.js +26 -0
  426. package/dist/config/schemas/version.js.map +1 -0
  427. package/dist/config/schemas/websearch.d.ts +138 -0
  428. package/dist/config/schemas/websearch.d.ts.map +1 -0
  429. package/dist/config/schemas/websearch.js +12 -0
  430. package/dist/config/schemas/websearch.js.map +1 -0
  431. package/dist/config/unified-config-loader.d.ts.map +1 -1
  432. package/dist/config/unified-config-loader.js +27 -1
  433. package/dist/config/unified-config-loader.js.map +1 -1
  434. package/dist/config/unified-config-types.d.ts +3 -814
  435. package/dist/config/unified-config-types.d.ts.map +1 -1
  436. package/dist/config/unified-config-types.js +19 -317
  437. package/dist/config/unified-config-types.js.map +1 -1
  438. package/dist/copilot/copilot-auth.d.ts.map +1 -1
  439. package/dist/copilot/copilot-auth.js +22 -0
  440. package/dist/copilot/copilot-auth.js.map +1 -1
  441. package/dist/copilot/copilot-daemon.d.ts.map +1 -1
  442. package/dist/copilot/copilot-daemon.js +26 -0
  443. package/dist/copilot/copilot-daemon.js.map +1 -1
  444. package/dist/copilot/copilot-executor.d.ts +1 -1
  445. package/dist/copilot/copilot-executor.d.ts.map +1 -1
  446. package/dist/copilot/copilot-executor.js +23 -1
  447. package/dist/copilot/copilot-executor.js.map +1 -1
  448. package/dist/cursor/cursor-daemon.d.ts.map +1 -1
  449. package/dist/cursor/cursor-daemon.js +28 -1
  450. package/dist/cursor/cursor-daemon.js.map +1 -1
  451. package/dist/cursor/cursor-executor.d.ts.map +1 -1
  452. package/dist/cursor/cursor-executor.js +17 -1
  453. package/dist/cursor/cursor-executor.js.map +1 -1
  454. package/dist/delegation/headless-executor.d.ts.map +1 -1
  455. package/dist/delegation/headless-executor.js +17 -2
  456. package/dist/delegation/headless-executor.js.map +1 -1
  457. package/dist/docker/docker-bootstrap.js +1 -1
  458. package/dist/docker/docker-bootstrap.js.map +1 -1
  459. package/dist/errors/error-types.d.ts +9 -0
  460. package/dist/errors/error-types.d.ts.map +1 -1
  461. package/dist/errors/error-types.js +15 -1
  462. package/dist/errors/error-types.js.map +1 -1
  463. package/dist/errors/index.d.ts +1 -1
  464. package/dist/errors/index.d.ts.map +1 -1
  465. package/dist/errors/index.js +3 -1
  466. package/dist/errors/index.js.map +1 -1
  467. package/dist/glmt/glmt-proxy.d.ts.map +1 -1
  468. package/dist/glmt/glmt-proxy.js +7 -0
  469. package/dist/glmt/glmt-proxy.js.map +1 -1
  470. package/dist/glmt/glmt-transformer.d.ts.map +1 -1
  471. package/dist/glmt/glmt-transformer.js +1 -3
  472. package/dist/glmt/glmt-transformer.js.map +1 -1
  473. package/dist/management/checks/image-analysis-check.js +2 -2
  474. package/dist/management/checks/image-analysis-check.js.map +1 -1
  475. package/dist/management/instance-manager.d.ts.map +1 -1
  476. package/dist/management/instance-manager.js +9 -0
  477. package/dist/management/instance-manager.js.map +1 -1
  478. package/dist/management/plugin-path-normalizer.d.ts +7 -0
  479. package/dist/management/plugin-path-normalizer.d.ts.map +1 -0
  480. package/dist/management/plugin-path-normalizer.js +82 -0
  481. package/dist/management/plugin-path-normalizer.js.map +1 -0
  482. package/dist/management/shared-manager.d.ts +1 -2
  483. package/dist/management/shared-manager.d.ts.map +1 -1
  484. package/dist/management/shared-manager.js +8 -56
  485. package/dist/management/shared-manager.js.map +1 -1
  486. package/dist/proxy/server/messages-route.d.ts.map +1 -1
  487. package/dist/proxy/server/messages-route.js +50 -9
  488. package/dist/proxy/server/messages-route.js.map +1 -1
  489. package/dist/proxy/server/proxy-server.d.ts.map +1 -1
  490. package/dist/proxy/server/proxy-server.js +24 -6
  491. package/dist/proxy/server/proxy-server.js.map +1 -1
  492. package/dist/proxy/transformers/request-transformer.d.ts +1 -0
  493. package/dist/proxy/transformers/request-transformer.d.ts.map +1 -1
  494. package/dist/proxy/transformers/request-transformer.js +10 -9
  495. package/dist/proxy/transformers/request-transformer.js.map +1 -1
  496. package/dist/services/logging/index.d.ts +6 -1
  497. package/dist/services/logging/index.d.ts.map +1 -1
  498. package/dist/services/logging/index.js +16 -1
  499. package/dist/services/logging/index.js.map +1 -1
  500. package/dist/services/logging/log-context.d.ts +41 -0
  501. package/dist/services/logging/log-context.d.ts.map +1 -0
  502. package/dist/services/logging/log-context.js +51 -0
  503. package/dist/services/logging/log-context.js.map +1 -0
  504. package/dist/services/logging/log-redaction.d.ts +8 -0
  505. package/dist/services/logging/log-redaction.d.ts.map +1 -1
  506. package/dist/services/logging/log-redaction.js +40 -3
  507. package/dist/services/logging/log-redaction.js.map +1 -1
  508. package/dist/services/logging/log-types.d.ts +30 -0
  509. package/dist/services/logging/log-types.d.ts.map +1 -1
  510. package/dist/services/logging/log-types.js +15 -1
  511. package/dist/services/logging/log-types.js.map +1 -1
  512. package/dist/services/logging/logger.d.ts +17 -0
  513. package/dist/services/logging/logger.d.ts.map +1 -1
  514. package/dist/services/logging/logger.js +23 -4
  515. package/dist/services/logging/logger.js.map +1 -1
  516. package/dist/shared/claude-extension-setup.js +1 -1
  517. package/dist/shared/claude-extension-setup.js.map +1 -1
  518. package/dist/targets/claude-adapter.d.ts.map +1 -1
  519. package/dist/targets/claude-adapter.js +11 -0
  520. package/dist/targets/claude-adapter.js.map +1 -1
  521. package/dist/targets/codex-adapter.d.ts.map +1 -1
  522. package/dist/targets/codex-adapter.js +11 -0
  523. package/dist/targets/codex-adapter.js.map +1 -1
  524. package/dist/targets/droid-adapter.d.ts.map +1 -1
  525. package/dist/targets/droid-adapter.js +11 -0
  526. package/dist/targets/droid-adapter.js.map +1 -1
  527. package/dist/targets/target-metadata.js +1 -1
  528. package/dist/targets/target-metadata.js.map +1 -1
  529. package/dist/ui/assets/{accounts-D0Z5AVKW.js → accounts-CDgKt-GZ.js} +1 -1
  530. package/dist/ui/assets/{alert-dialog-CzJucE0e.js → alert-dialog-CRqbTpjm.js} +1 -1
  531. package/dist/ui/assets/{api-DXAf4i-v.js → api-C7W2ibtd.js} +1 -1
  532. package/dist/ui/assets/{auth-section-BrnnHBi-.js → auth-section-RBgQQrdk.js} +1 -1
  533. package/dist/ui/assets/{backups-section-DCBcfZ-C.js → backups-section-DptarTls.js} +1 -1
  534. package/dist/ui/assets/{channels-BSapONLx.js → channels-BMQs4wmY.js} +1 -1
  535. package/dist/ui/assets/{charts-BBPXh0Ar.js → charts-CeK2xCSo.js} +1 -1
  536. package/dist/ui/assets/{checkbox-Bd7X5Xud.js → checkbox-BrRyK0T3.js} +1 -1
  537. package/dist/ui/assets/{claude-extension-BYJxm4B5.js → claude-extension-DrSuOyf4.js} +1 -1
  538. package/dist/ui/assets/cliproxy-CdqYwRJH.js +3 -0
  539. package/dist/ui/assets/{cliproxy-ai-providers-D7r2Us_Y.js → cliproxy-ai-providers-B8aZTWIe.js} +1 -1
  540. package/dist/ui/assets/{cliproxy-control-panel-Cmo3ArVL.js → cliproxy-control-panel-BpXgvmht.js} +1 -1
  541. package/dist/ui/assets/{code-highlight-BRUf_pqB.js → code-highlight-D4E79GKQ.js} +1 -1
  542. package/dist/ui/assets/codex-CYoq5g4z.js +27 -0
  543. package/dist/ui/assets/{confirm-dialog--zJgz4y0.js → confirm-dialog-CP-4T1Wp.js} +1 -1
  544. package/dist/ui/assets/{copilot-2ARJ9YVb.js → copilot-aEdlrY3S.js} +1 -1
  545. package/dist/ui/assets/{cursor-CQNCrVt0.js → cursor-CSJ0aqxS.js} +1 -1
  546. package/dist/ui/assets/{droid-Dl5wRjDv.js → droid-DTdvqOvV.js} +1 -1
  547. package/dist/ui/assets/{form-utils-Bcoyqxpq.js → form-utils-CuHzLhJZ.js} +1 -1
  548. package/dist/ui/assets/{globalenv-section-T1imQsSA.js → globalenv-section-DXbRVgOM.js} +1 -1
  549. package/dist/ui/assets/health-CDce37cB.js +1 -0
  550. package/dist/ui/assets/icons-DQFHtVq5.js +1 -0
  551. package/dist/ui/assets/index-6xrth3Oz.css +1 -0
  552. package/dist/ui/assets/index-Bm9k7s_T.js +1 -0
  553. package/dist/ui/assets/{index-DFgCoUVv.js → index-D_FmvtnX.js} +1 -1
  554. package/dist/ui/assets/{index-CqJFugM4.js → index-DjxqZO4B.js} +1 -1
  555. package/dist/ui/assets/index-Fd17BSGq.js +72 -0
  556. package/dist/ui/assets/index-KK76yIJk.js +1 -0
  557. package/dist/ui/assets/{index-fV5BBuAO.js → index-dnIWLkjb.js} +1 -1
  558. package/dist/ui/assets/{index-DH916Tyi.js → index-vN-yw8kw.js} +1 -1
  559. package/dist/ui/assets/logs-C_MtpQIE.js +1 -0
  560. package/dist/ui/assets/masked-input-BAWBYIqo.js +1 -0
  561. package/dist/ui/assets/{notifications-B2HqRBj7.js → notifications-B4_o8bcr.js} +1 -1
  562. package/dist/ui/assets/proxy-C4-M_9kB.js +9 -0
  563. package/dist/ui/assets/proxy-status-widget-DUqasX3c.js +1 -0
  564. package/dist/ui/assets/{radix-ui-Zb8sVEtn.js → radix-ui-nu4wz29m.js} +1 -1
  565. package/dist/ui/assets/{raw-json-settings-editor-panel-DNmb_vR-.js → raw-json-settings-editor-panel-DuVlOXFi.js} +1 -1
  566. package/dist/ui/assets/{react-vendor-CNOkPC89.js → react-vendor-Bjx91N7w.js} +1 -1
  567. package/dist/ui/assets/{searchable-select--iFe00dY.js → searchable-select-BCxZHr8N.js} +1 -1
  568. package/dist/ui/assets/{separator-CaGbNw8E.js → separator-BV4BKMsB.js} +1 -1
  569. package/dist/ui/assets/{shared-Cgk48Wu3.js → shared-D-Cu_o1h.js} +1 -1
  570. package/dist/ui/assets/{table-CKuoPAz4.js → table-DW66THR9.js} +1 -1
  571. package/dist/ui/assets/{tanstack-CrmUhA7Z.js → tanstack-bhJxV1h8.js} +1 -1
  572. package/dist/ui/assets/updates-V0D_Q8n4.js +1 -0
  573. package/dist/ui/index.html +9 -9
  574. package/dist/utils/hooks/get-image-analysis-hook-env.d.ts +1 -1
  575. package/dist/utils/hooks/get-image-analysis-hook-env.d.ts.map +1 -1
  576. package/dist/utils/hooks/get-image-analysis-hook-env.js +2 -2
  577. package/dist/utils/hooks/get-image-analysis-hook-env.js.map +1 -1
  578. package/dist/utils/hooks/image-analysis-backend-resolver.js +1 -1
  579. package/dist/utils/hooks/image-analysis-backend-resolver.js.map +1 -1
  580. package/dist/utils/hooks/image-analysis-runtime-status.d.ts +4 -4
  581. package/dist/utils/hooks/image-analysis-runtime-status.d.ts.map +1 -1
  582. package/dist/utils/hooks/image-analysis-runtime-status.js +5 -5
  583. package/dist/utils/hooks/image-analysis-runtime-status.js.map +1 -1
  584. package/dist/utils/openai-compat-launch-settings.d.ts +7 -0
  585. package/dist/utils/openai-compat-launch-settings.d.ts.map +1 -0
  586. package/dist/utils/openai-compat-launch-settings.js +61 -0
  587. package/dist/utils/openai-compat-launch-settings.js.map +1 -0
  588. package/dist/utils/retry-strategy.d.ts +37 -0
  589. package/dist/utils/retry-strategy.d.ts.map +1 -0
  590. package/dist/utils/retry-strategy.js +99 -0
  591. package/dist/utils/retry-strategy.js.map +1 -0
  592. package/dist/utils/shell-executor.d.ts +1 -1
  593. package/dist/utils/shell-executor.d.ts.map +1 -1
  594. package/dist/utils/shell-executor.js +11 -1
  595. package/dist/utils/shell-executor.js.map +1 -1
  596. package/dist/web-server/health/cliproxy-checks.js +2 -2
  597. package/dist/web-server/health/cliproxy-checks.js.map +1 -1
  598. package/dist/web-server/index.js +2 -2
  599. package/dist/web-server/index.js.map +1 -1
  600. package/dist/web-server/jsonl-parser.d.ts.map +1 -1
  601. package/dist/web-server/jsonl-parser.js +22 -4
  602. package/dist/web-server/jsonl-parser.js.map +1 -1
  603. package/dist/web-server/model-pricing.d.ts +8 -6
  604. package/dist/web-server/model-pricing.d.ts.map +1 -1
  605. package/dist/web-server/model-pricing.js +80 -29
  606. package/dist/web-server/model-pricing.js.map +1 -1
  607. package/dist/web-server/models-dev/pricing-resolver.d.ts +18 -0
  608. package/dist/web-server/models-dev/pricing-resolver.d.ts.map +1 -0
  609. package/dist/web-server/models-dev/pricing-resolver.js +153 -0
  610. package/dist/web-server/models-dev/pricing-resolver.js.map +1 -0
  611. package/dist/web-server/models-dev/registry-cache.d.ts +19 -0
  612. package/dist/web-server/models-dev/registry-cache.d.ts.map +1 -0
  613. package/dist/web-server/models-dev/registry-cache.js +155 -0
  614. package/dist/web-server/models-dev/registry-cache.js.map +1 -0
  615. package/dist/web-server/models-dev/types.d.ts +39 -0
  616. package/dist/web-server/models-dev/types.d.ts.map +1 -0
  617. package/dist/web-server/models-dev/types.js +3 -0
  618. package/dist/web-server/models-dev/types.js.map +1 -0
  619. package/dist/web-server/overview-routes.js +1 -1
  620. package/dist/web-server/overview-routes.js.map +1 -1
  621. package/dist/web-server/routes/account-routes.js +1 -1
  622. package/dist/web-server/routes/account-routes.js.map +1 -1
  623. package/dist/web-server/routes/catalog-routes.js +1 -1
  624. package/dist/web-server/routes/catalog-routes.js.map +1 -1
  625. package/dist/web-server/routes/cliproxy-auth-routes.js +10 -10
  626. package/dist/web-server/routes/cliproxy-auth-routes.js.map +1 -1
  627. package/dist/web-server/routes/cliproxy-routing-routes.d.ts.map +1 -1
  628. package/dist/web-server/routes/cliproxy-routing-routes.js +36 -1
  629. package/dist/web-server/routes/cliproxy-routing-routes.js.map +1 -1
  630. package/dist/web-server/routes/cliproxy-stats-routes.js +10 -10
  631. package/dist/web-server/routes/cliproxy-stats-routes.js.map +1 -1
  632. package/dist/web-server/routes/image-analysis-routes.js +1 -1
  633. package/dist/web-server/routes/image-analysis-routes.js.map +1 -1
  634. package/dist/web-server/routes/profile-routes.d.ts.map +1 -1
  635. package/dist/web-server/routes/profile-routes.js +13 -3
  636. package/dist/web-server/routes/profile-routes.js.map +1 -1
  637. package/dist/web-server/routes/provider-routes.js +1 -1
  638. package/dist/web-server/routes/provider-routes.js.map +1 -1
  639. package/dist/web-server/routes/proxy-routes.js +2 -2
  640. package/dist/web-server/routes/proxy-routes.js.map +1 -1
  641. package/dist/web-server/routes/route-helpers.d.ts +1 -0
  642. package/dist/web-server/routes/route-helpers.d.ts.map +1 -1
  643. package/dist/web-server/routes/route-helpers.js +12 -1
  644. package/dist/web-server/routes/route-helpers.js.map +1 -1
  645. package/dist/web-server/routes/settings-routes.js +2 -2
  646. package/dist/web-server/routes/settings-routes.js.map +1 -1
  647. package/dist/web-server/routes/variant-routes.js +1 -1
  648. package/dist/web-server/routes/variant-routes.js.map +1 -1
  649. package/dist/web-server/services/cliproxy-dashboard-install-service.js +1 -1
  650. package/dist/web-server/services/cliproxy-dashboard-install-service.js.map +1 -1
  651. package/dist/web-server/usage/aggregator.d.ts +1 -0
  652. package/dist/web-server/usage/aggregator.d.ts.map +1 -1
  653. package/dist/web-server/usage/aggregator.js +121 -20
  654. package/dist/web-server/usage/aggregator.js.map +1 -1
  655. package/dist/web-server/usage/cliproxy-usage-syncer.d.ts +1 -16
  656. package/dist/web-server/usage/cliproxy-usage-syncer.d.ts.map +1 -1
  657. package/dist/web-server/usage/cliproxy-usage-syncer.js +160 -56
  658. package/dist/web-server/usage/cliproxy-usage-syncer.js.map +1 -1
  659. package/dist/web-server/usage/cliproxy-usage-transformer.d.ts +23 -7
  660. package/dist/web-server/usage/cliproxy-usage-transformer.d.ts.map +1 -1
  661. package/dist/web-server/usage/cliproxy-usage-transformer.js +191 -28
  662. package/dist/web-server/usage/cliproxy-usage-transformer.js.map +1 -1
  663. package/dist/web-server/usage/codex-native-usage-collector.d.ts +11 -0
  664. package/dist/web-server/usage/codex-native-usage-collector.d.ts.map +1 -0
  665. package/dist/web-server/usage/codex-native-usage-collector.js +177 -0
  666. package/dist/web-server/usage/codex-native-usage-collector.js.map +1 -0
  667. package/dist/web-server/usage/data-aggregator.d.ts.map +1 -1
  668. package/dist/web-server/usage/data-aggregator.js +45 -46
  669. package/dist/web-server/usage/data-aggregator.js.map +1 -1
  670. package/dist/web-server/usage/droid-native-usage-collector.d.ts +14 -0
  671. package/dist/web-server/usage/droid-native-usage-collector.d.ts.map +1 -0
  672. package/dist/web-server/usage/droid-native-usage-collector.js +201 -0
  673. package/dist/web-server/usage/droid-native-usage-collector.js.map +1 -0
  674. package/dist/web-server/usage/handlers.d.ts +1 -0
  675. package/dist/web-server/usage/handlers.d.ts.map +1 -1
  676. package/dist/web-server/usage/handlers.js +155 -45
  677. package/dist/web-server/usage/handlers.js.map +1 -1
  678. package/dist/web-server/usage/model-identity.d.ts +16 -0
  679. package/dist/web-server/usage/model-identity.d.ts.map +1 -0
  680. package/dist/web-server/usage/model-identity.js +70 -0
  681. package/dist/web-server/usage/model-identity.js.map +1 -0
  682. package/dist/web-server/usage/sqlite-cli.d.ts +3 -0
  683. package/dist/web-server/usage/sqlite-cli.d.ts.map +1 -0
  684. package/dist/web-server/usage/sqlite-cli.js +62 -0
  685. package/dist/web-server/usage/sqlite-cli.js.map +1 -0
  686. package/dist/web-server/usage/types.d.ts +6 -0
  687. package/dist/web-server/usage/types.d.ts.map +1 -1
  688. package/dist/web-server/websocket.js +2 -2
  689. package/dist/web-server/websocket.js.map +1 -1
  690. package/lib/mcp/ccs-browser-server.cjs +309 -121
  691. package/package.json +1 -1
  692. package/scripts/dev-release.sh +4 -2
  693. package/scripts/run-test-bucket.js +2 -1
  694. package/dist/cliproxy/account-manager.d.ts.map +0 -1
  695. package/dist/cliproxy/account-manager.js.map +0 -1
  696. package/dist/cliproxy/account-safety.d.ts.map +0 -1
  697. package/dist/cliproxy/account-safety.js.map +0 -1
  698. package/dist/cliproxy/account-stats-key.d.ts.map +0 -1
  699. package/dist/cliproxy/account-stats-key.js.map +0 -1
  700. package/dist/cliproxy/antigravity-responsibility.d.ts.map +0 -1
  701. package/dist/cliproxy/antigravity-responsibility.js.map +0 -1
  702. package/dist/cliproxy/auth-handler.d.ts.map +0 -1
  703. package/dist/cliproxy/auth-handler.js.map +0 -1
  704. package/dist/cliproxy/auth-session-manager.d.ts.map +0 -1
  705. package/dist/cliproxy/auth-session-manager.js.map +0 -1
  706. package/dist/cliproxy/auth-token-manager.d.ts.map +0 -1
  707. package/dist/cliproxy/auth-token-manager.js.map +0 -1
  708. package/dist/cliproxy/auth-utils.d.ts.map +0 -1
  709. package/dist/cliproxy/auth-utils.js.map +0 -1
  710. package/dist/cliproxy/base-config-loader.d.ts.map +0 -1
  711. package/dist/cliproxy/base-config-loader.js.map +0 -1
  712. package/dist/cliproxy/catalog-cache.d.ts.map +0 -1
  713. package/dist/cliproxy/catalog-cache.js.map +0 -1
  714. package/dist/cliproxy/catalog-routing.d.ts.map +0 -1
  715. package/dist/cliproxy/catalog-routing.js.map +0 -1
  716. package/dist/cliproxy/cliproxy-executor.d.ts.map +0 -1
  717. package/dist/cliproxy/cliproxy-executor.js.map +0 -1
  718. package/dist/cliproxy/codex-plan-compatibility.d.ts.map +0 -1
  719. package/dist/cliproxy/codex-plan-compatibility.js.map +0 -1
  720. package/dist/cliproxy/codex-reasoning-proxy.d.ts.map +0 -1
  721. package/dist/cliproxy/codex-reasoning-proxy.js.map +0 -1
  722. package/dist/cliproxy/composite-validator.d.ts.map +0 -1
  723. package/dist/cliproxy/composite-validator.js.map +0 -1
  724. package/dist/cliproxy/config-generator.d.ts.map +0 -1
  725. package/dist/cliproxy/config-generator.js.map +0 -1
  726. package/dist/cliproxy/device-code-handler.d.ts.map +0 -1
  727. package/dist/cliproxy/device-code-handler.js.map +0 -1
  728. package/dist/cliproxy/gemini-cli-quota-normalizer.d.ts.map +0 -1
  729. package/dist/cliproxy/gemini-cli-quota-normalizer.js.map +0 -1
  730. package/dist/cliproxy/https-tunnel-proxy.d.ts.map +0 -1
  731. package/dist/cliproxy/https-tunnel-proxy.js.map +0 -1
  732. package/dist/cliproxy/managed-model-prefixes.d.ts.map +0 -1
  733. package/dist/cliproxy/managed-model-prefixes.js.map +0 -1
  734. package/dist/cliproxy/management-api-client.d.ts.map +0 -1
  735. package/dist/cliproxy/management-api-client.js.map +0 -1
  736. package/dist/cliproxy/management-api-types.d.ts.map +0 -1
  737. package/dist/cliproxy/management-api-types.js.map +0 -1
  738. package/dist/cliproxy/model-config.d.ts.map +0 -1
  739. package/dist/cliproxy/model-config.js.map +0 -1
  740. package/dist/cliproxy/model-id-normalizer.d.ts.map +0 -1
  741. package/dist/cliproxy/model-id-normalizer.js.map +0 -1
  742. package/dist/cliproxy/openai-compat-manager.d.ts.map +0 -1
  743. package/dist/cliproxy/openai-compat-manager.js.map +0 -1
  744. package/dist/cliproxy/platform-detector.d.ts.map +0 -1
  745. package/dist/cliproxy/platform-detector.js.map +0 -1
  746. package/dist/cliproxy/project-selection-handler.d.ts.map +0 -1
  747. package/dist/cliproxy/project-selection-handler.js.map +0 -1
  748. package/dist/cliproxy/provider-entitlement-evidence.d.ts.map +0 -1
  749. package/dist/cliproxy/provider-entitlement-evidence.js.map +0 -1
  750. package/dist/cliproxy/provider-entitlement-types.d.ts.map +0 -1
  751. package/dist/cliproxy/provider-entitlement-types.js.map +0 -1
  752. package/dist/cliproxy/proxy-config-resolver.d.ts.map +0 -1
  753. package/dist/cliproxy/proxy-config-resolver.js.map +0 -1
  754. package/dist/cliproxy/proxy-detector.d.ts.map +0 -1
  755. package/dist/cliproxy/proxy-detector.js.map +0 -1
  756. package/dist/cliproxy/proxy-target-resolver.d.ts.map +0 -1
  757. package/dist/cliproxy/proxy-target-resolver.js.map +0 -1
  758. package/dist/cliproxy/quota-fetcher-claude-normalizer.d.ts.map +0 -1
  759. package/dist/cliproxy/quota-fetcher-claude-normalizer.js.map +0 -1
  760. package/dist/cliproxy/quota-fetcher-claude.d.ts.map +0 -1
  761. package/dist/cliproxy/quota-fetcher-claude.js.map +0 -1
  762. package/dist/cliproxy/quota-fetcher-codex.d.ts.map +0 -1
  763. package/dist/cliproxy/quota-fetcher-codex.js.map +0 -1
  764. package/dist/cliproxy/quota-fetcher-gemini-cli.d.ts.map +0 -1
  765. package/dist/cliproxy/quota-fetcher-gemini-cli.js.map +0 -1
  766. package/dist/cliproxy/quota-fetcher-ghcp.d.ts.map +0 -1
  767. package/dist/cliproxy/quota-fetcher-ghcp.js.map +0 -1
  768. package/dist/cliproxy/quota-fetcher.d.ts.map +0 -1
  769. package/dist/cliproxy/quota-fetcher.js.map +0 -1
  770. package/dist/cliproxy/quota-manager.d.ts.map +0 -1
  771. package/dist/cliproxy/quota-manager.js.map +0 -1
  772. package/dist/cliproxy/quota-response-cache.d.ts.map +0 -1
  773. package/dist/cliproxy/quota-response-cache.js.map +0 -1
  774. package/dist/cliproxy/quota-types.d.ts.map +0 -1
  775. package/dist/cliproxy/quota-types.js.map +0 -1
  776. package/dist/cliproxy/remote-auth-fetcher.d.ts.map +0 -1
  777. package/dist/cliproxy/remote-auth-fetcher.js.map +0 -1
  778. package/dist/cliproxy/remote-proxy-client.d.ts.map +0 -1
  779. package/dist/cliproxy/remote-proxy-client.js.map +0 -1
  780. package/dist/cliproxy/remote-token-uploader.d.ts.map +0 -1
  781. package/dist/cliproxy/remote-token-uploader.js.map +0 -1
  782. package/dist/cliproxy/routing-strategy-http.d.ts.map +0 -1
  783. package/dist/cliproxy/routing-strategy-http.js.map +0 -1
  784. package/dist/cliproxy/routing-strategy.d.ts +0 -18
  785. package/dist/cliproxy/routing-strategy.d.ts.map +0 -1
  786. package/dist/cliproxy/routing-strategy.js +0 -126
  787. package/dist/cliproxy/routing-strategy.js.map +0 -1
  788. package/dist/cliproxy/schema-sanitizer.d.ts.map +0 -1
  789. package/dist/cliproxy/schema-sanitizer.js.map +0 -1
  790. package/dist/cliproxy/startup-lock.d.ts.map +0 -1
  791. package/dist/cliproxy/startup-lock.js.map +0 -1
  792. package/dist/cliproxy/stats-fetcher.d.ts.map +0 -1
  793. package/dist/cliproxy/stats-fetcher.js.map +0 -1
  794. package/dist/cliproxy/stats-transformer.d.ts.map +0 -1
  795. package/dist/cliproxy/stats-transformer.js.map +0 -1
  796. package/dist/cliproxy/tool-name-mapper.d.ts.map +0 -1
  797. package/dist/cliproxy/tool-name-mapper.js.map +0 -1
  798. package/dist/cliproxy/tool-name-sanitizer.d.ts.map +0 -1
  799. package/dist/cliproxy/tool-name-sanitizer.js.map +0 -1
  800. package/dist/cliproxy/tool-sanitization-proxy.d.ts.map +0 -1
  801. package/dist/cliproxy/tool-sanitization-proxy.js.map +0 -1
  802. package/dist/ui/assets/cliproxy-G5JuFm2j.js +0 -3
  803. package/dist/ui/assets/codex-4VNBJ4Nb.js +0 -27
  804. package/dist/ui/assets/health-CNous3WN.js +0 -1
  805. package/dist/ui/assets/icons-DyorC3Xk.js +0 -1
  806. package/dist/ui/assets/index-2X8-14xr.js +0 -72
  807. package/dist/ui/assets/index-BcLnqcxD.js +0 -1
  808. package/dist/ui/assets/index-Be3dhMW3.js +0 -9
  809. package/dist/ui/assets/index-DuTB1_9r.css +0 -1
  810. package/dist/ui/assets/logs-CZsWbq7X.js +0 -1
  811. package/dist/ui/assets/masked-input-_EkW1Pzo.js +0 -1
  812. package/dist/ui/assets/proxy-status-widget-D82T2X4F.js +0 -1
  813. package/dist/ui/assets/updates-Dr8Yq-Pm.js +0 -1
  814. /package/dist/cliproxy/{account-stats-key.d.ts → accounts/account-stats-key.d.ts} +0 -0
  815. /package/dist/cliproxy/{account-stats-key.js → accounts/account-stats-key.js} +0 -0
  816. /package/dist/cliproxy/{codex-reasoning-proxy.d.ts → ai-providers/codex-reasoning-proxy.d.ts} +0 -0
  817. /package/dist/cliproxy/{openai-compat-manager.d.ts → ai-providers/openai-compat-manager.d.ts} +0 -0
  818. /package/dist/cliproxy/{schema-sanitizer.d.ts → ai-providers/schema-sanitizer.d.ts} +0 -0
  819. /package/dist/cliproxy/{schema-sanitizer.js → ai-providers/schema-sanitizer.js} +0 -0
  820. /package/dist/cliproxy/{antigravity-responsibility.d.ts → auth/antigravity-responsibility.d.ts} +0 -0
  821. /package/dist/cliproxy/{auth-token-manager.d.ts → auth/auth-token-manager.d.ts} +0 -0
  822. /package/dist/cliproxy/{auth-utils.d.ts → auth/auth-utils.d.ts} +0 -0
  823. /package/dist/cliproxy/{auth-utils.js → auth/auth-utils.js} +0 -0
  824. /package/dist/cliproxy/{device-code-handler.d.ts → auth/device-code-handler.d.ts} +0 -0
  825. /package/dist/cliproxy/{device-code-handler.js → auth/device-code-handler.js} +0 -0
  826. /package/dist/cliproxy/{project-selection-handler.d.ts → auth/project-selection-handler.d.ts} +0 -0
  827. /package/dist/cliproxy/{project-selection-handler.js → auth/project-selection-handler.js} +0 -0
  828. /package/dist/cliproxy/{provider-entitlement-evidence.js → auth/provider-entitlement-evidence.js} +0 -0
  829. /package/dist/cliproxy/{provider-entitlement-types.js → auth/provider-entitlement-types.js} +0 -0
  830. /package/dist/cliproxy/{platform-detector.js → binary/platform-detector.js} +0 -0
  831. /package/dist/cliproxy/{composite-validator.d.ts → config/composite-validator.d.ts} +0 -0
  832. /package/dist/cliproxy/{management-api-types.d.ts → management/management-api-types.d.ts} +0 -0
  833. /package/dist/cliproxy/{management-api-types.js → management/management-api-types.js} +0 -0
  834. /package/dist/cliproxy/{remote-token-uploader.d.ts → management/remote-token-uploader.d.ts} +0 -0
  835. /package/dist/cliproxy/{https-tunnel-proxy.d.ts → proxy/https-tunnel-proxy.d.ts} +0 -0
  836. /package/dist/cliproxy/{proxy-target-resolver.d.ts → proxy/proxy-target-resolver.d.ts} +0 -0
  837. /package/dist/cliproxy/{tool-sanitization-proxy.d.ts → proxy/tool-sanitization-proxy.d.ts} +0 -0
  838. /package/dist/cliproxy/{gemini-cli-quota-normalizer.d.ts → quota/gemini-cli-quota-normalizer.d.ts} +0 -0
  839. /package/dist/cliproxy/{gemini-cli-quota-normalizer.js → quota/gemini-cli-quota-normalizer.js} +0 -0
  840. /package/dist/cliproxy/{quota-fetcher-claude-normalizer.d.ts → quota/quota-fetcher-claude-normalizer.d.ts} +0 -0
  841. /package/dist/cliproxy/{quota-fetcher-claude.d.ts → quota/quota-fetcher-claude.d.ts} +0 -0
  842. /package/dist/cliproxy/{quota-fetcher-gemini-cli.d.ts → quota/quota-fetcher-gemini-cli.d.ts} +0 -0
  843. /package/dist/cliproxy/{quota-fetcher-ghcp.d.ts → quota/quota-fetcher-ghcp.d.ts} +0 -0
  844. /package/dist/cliproxy/{quota-response-cache.d.ts → quota/quota-response-cache.d.ts} +0 -0
  845. /package/dist/cliproxy/{quota-response-cache.js → quota/quota-response-cache.js} +0 -0
  846. /package/dist/cliproxy/{quota-types.js → quota/quota-types.js} +0 -0
  847. /package/dist/cliproxy/{remote-proxy-client.d.ts → services/remote-proxy-client.d.ts} +0 -0
  848. /package/dist/cliproxy/{startup-lock.d.ts → services/startup-lock.d.ts} +0 -0
  849. /package/dist/cliproxy/{stats-fetcher.d.ts → services/stats-fetcher.d.ts} +0 -0
  850. /package/dist/cliproxy/{stats-transformer.d.ts → services/stats-transformer.d.ts} +0 -0
@@ -1,3 +0,0 @@
1
- import{j as e}from"./radix-ui-Zb8sVEtn.js";import{r as d}from"./react-vendor-CNOkPC89.js";import{a as ht,u as $t,b as Ss}from"./tanstack-CrmUhA7Z.js";import{a8 as Ms,a as W,d as K,C as Wt,b as Qt,a9 as Jt,aa as Xt,c as X,P as gt,B as H,ab as ue,L as Y,I as de,r as qe,s as ze,t as Ge,v as Be,w as ye,ac as Yt,ad as Zt,ae as Ps,af as Ds,ag as Is,u as es,ah as ft,ai as vt,aj as jt,ak as bt,W as me,al as ts,am as It,an as Es,ao as Ts,ap as Qe,aq as ss,Y as Ve,ar as Rs,as as Et,at as Tt,au as Ls,av as Os,aw as _s,ax as Fs,ay as Us,az as Ks,aA as Hs,aB as qs,aC as Rt,aD as zs,x as as,aE as Gs,n as Nt,aF as Bs,aG as yt,aH as Lt,aI as ns,aJ as Vs,m as $s,aK as Ws,aL as Qs,aM as lt,T as dt,p as ct,q as ut,aN as Js,aO as Xs,aP as Ys,aQ as Ot,aR as Zs,aS as ea,aT as ta,aU as sa,aV as aa,aW as na,Q as ia,R as ra,U as _t,V as Ft,aX as oa,aY as la,aZ as da,a_ as ca,a$ as ua,b0 as ma,b1 as pa,b2 as xa,b3 as ha,b4 as ga,b5 as fa,b6 as va,b7 as ja,S as ba}from"./index-2X8-14xr.js";import{C as mt}from"./default-ports-1QQSffYX.js";import{t as B}from"./notifications-B2HqRBj7.js";import{C as is,L as ce,p as ke,$ as Na,m as we,o as rs,aG as kt,R as wt,q as Pe,aa as De,T as Je,a7 as Ut,aH as os,aF as ya,z as Ct,Z as Ie,_ as ls,i as ka,u as ds,aI as wa,au as Ca,X as At,a9 as cs,J as us,D as ms,aJ as Aa,at as ps,aK as Sa,ax as Ma,aL as xs}from"./icons-DyorC3Xk.js";import{R as $e,A as Kt,D as at,i as Pa,a as Da}from"./antigravity-responsibility-constants-Bvh4Ybz0.js";import{C as We}from"./checkbox-Bd7X5Xud.js";import{C as Ia}from"./confirm-dialog--zJgz4y0.js";import{S as St}from"./separator-CaGbNw8E.js";import{S as Ea}from"./searchable-select--iFe00dY.js";import{P as Ta}from"./proxy-status-widget-D82T2X4F.js";import"./utils-CzKF5WmX.js";import"./form-utils-Bcoyqxpq.js";import"./code-highlight-BRUf_pqB.js";import"./alert-dialog-CzJucE0e.js";const se="gemini-3.1-pro-high",Ce="gemini-3.1-pro-low",Ra=Object.freeze({"gemini-3-pro-high":se,"gemini-3.1-pro-high":se,"gemini-3-pro-low":Ce,"gemini-3.1-pro-low":Ce,"gemini-3-pro-preview":se,"gemini-3-pro-preview-customtools":se,"gemini-3.1-pro-preview":se,"gemini-3.1-pro-preview-customtools":se,"gemini-3-1-pro-preview":se,"gemini-3-1-pro-preview-customtools":se}),hs=Object.freeze({"gemini-3-pro-preview":"gemini-3.1-pro-preview","gemini-3.1-pro-preview":"gemini-3-pro-preview","gemini-3-flash-preview":"gemini-3.1-flash-preview","gemini-3.1-flash-preview":"gemini-3-flash-preview"}),La=/^gemini-(\d+(?:[.-]\d+)*)-(pro|flash)-preview(-customtools)?$/i,Oa=["agy/","gcli/"];function J(t){return Ms(t).toLowerCase()}function _a(t){const a=t.trim(),s=a.toLowerCase();for(const i of Oa)if(s.startsWith(i))return a.slice(i.length);return a}function Fa(t){return t.replace(/-customtools$/i,"")}function Ua(t){return Ra[J(t)]}function Xe(t){const a=J(t),s=a.match(La);if(!s)return null;const[,i,n,c]=s;return{normalizedId:a,version:i.split(/[.-]/).map(l=>Number(l)),family:n,customtools:!!c,dottedVersion:i.includes(".")}}function gs(t,a){const s=Math.max(t.length,a.length);for(let i=0;i<s;i+=1){const n=t[i]??0,c=a[i]??0;if(n!==c)return n>c?1:-1}return 0}function Ka(t,a,s){if(t.customtools!==a.customtools)return t.customtools?1:-1;const i=gs(t.version,a.version);if(i!==0)return i>0?-1:1;const n=+(t.dottedVersion===s.dottedVersion),c=+(a.dottedVersion===s.dottedVersion);return n!==c?c-n:t.normalizedId.localeCompare(a.normalizedId)}function Ht(t,a){const s=J(a);return t.find(i=>J(i.id)===s)?.id}function Ha(t,a){const s=Xe(t);return!s||a.length===0?void 0:a.map(n=>{const c=Xe(n.id);return!c||c.family!==s.family?null:{id:n.id,info:c}}).filter(n=>!!n).sort((n,c)=>Ka(n.info,c.info,s))[0]?.id}const xe={agy:{provider:"agy",displayName:"Antigravity",defaultModel:"claude-opus-4-6-thinking",models:[{id:"claude-opus-4-6-thinking",name:"Claude Opus 4.6 Thinking",description:"Latest flagship, extended thinking",extendedContext:!1,presetMapping:{default:"claude-opus-4-6-thinking",opus:"claude-opus-4-6-thinking",sonnet:"claude-sonnet-4-6",haiku:"claude-sonnet-4-6"}},{id:"claude-sonnet-4-6",name:"Claude Sonnet 4.6",description:"Latest Sonnet with thinking budget support",presetMapping:{default:"claude-sonnet-4-6",opus:"claude-opus-4-6-thinking",sonnet:"claude-sonnet-4-6",haiku:"claude-sonnet-4-6"}},{id:se,name:"Gemini Pro High",description:"Current Antigravity Gemini Pro route with higher reasoning budget",extendedContext:!0,presetMapping:{default:se,opus:se,sonnet:se,haiku:"gemini-3-1-flash-preview"}},{id:Ce,name:"Gemini Pro Low",description:"Current Antigravity Gemini Pro route with the lighter quota tier",extendedContext:!0,presetMapping:{default:Ce,opus:Ce,sonnet:Ce,haiku:"gemini-3-1-flash-preview"}},{id:"gemini-3-1-flash-preview",name:"Gemini Flash",description:"Resolves to the best advertised Gemini Flash preview via Antigravity",extendedContext:!0,presetMapping:{default:"gemini-3-1-flash-preview",opus:se,sonnet:se,haiku:"gemini-3-1-flash-preview"}}]},gemini:{provider:"gemini",displayName:"Gemini",defaultModel:"gemini-2.5-pro",models:[{id:"gemini-3.1-pro-preview",name:"Gemini Pro",tier:"paid",description:"Uses the best advertised Gemini Pro preview when Google exposes one",extendedContext:!0,presetMapping:{default:"gemini-3.1-pro-preview",opus:"gemini-3.1-pro-preview",sonnet:"gemini-3.1-pro-preview",haiku:"gemini-3-flash-preview"}},{id:"gemini-3-flash-preview",name:"Gemini Flash",tier:"paid",description:"Uses the best advertised Gemini Flash preview when Google exposes one",extendedContext:!0,presetMapping:{default:"gemini-3-flash-preview",opus:"gemini-3.1-pro-preview",sonnet:"gemini-3.1-pro-preview",haiku:"gemini-3-flash-preview"}},{id:"gemini-2.5-pro",name:"Gemini 2.5 Pro",description:"Stable, works with free Google account",extendedContext:!0,presetMapping:{default:"gemini-2.5-pro",opus:"gemini-2.5-pro",sonnet:"gemini-2.5-pro",haiku:"gemini-2.5-flash"}}]},codex:{provider:"codex",displayName:"Codex",defaultModel:"gpt-5-codex",models:[{id:"gpt-5-codex",name:"GPT-5 Codex",description:"Cross-plan safe Codex default",codexMaxEffort:"xhigh",presetMapping:{default:"gpt-5-codex",opus:"gpt-5-codex",sonnet:"gpt-5-codex",haiku:"gpt-5-codex-mini"}},{id:"gpt-5-codex-mini",name:"GPT-5 Codex Mini",description:"Faster and cheaper Codex option",codexMaxEffort:"high",presetMapping:{default:"gpt-5-codex-mini",opus:"gpt-5-codex",sonnet:"gpt-5-codex",haiku:"gpt-5-codex-mini"}},{id:"gpt-5-mini",name:"GPT-5 Mini",description:"Legacy mini model ID kept for backwards compatibility",codexMaxEffort:"high",presetMapping:{default:"gpt-5-mini",opus:"gpt-5-codex",sonnet:"gpt-5-mini",haiku:"gpt-5-mini"}},{id:"gpt-5.1-codex-mini",name:"GPT-5.1 Codex Mini",description:"Legacy fast Codex mini model",codexMaxEffort:"high",presetMapping:{default:"gpt-5.1-codex-mini",opus:"gpt-5.1-codex-max",sonnet:"gpt-5.1-codex-max",haiku:"gpt-5.1-codex-mini"}},{id:"gpt-5.1-codex-max",name:"GPT-5.1 Codex Max",description:"Higher-effort Codex model with xhigh support",codexMaxEffort:"xhigh",presetMapping:{default:"gpt-5.1-codex-max",opus:"gpt-5.1-codex-max",sonnet:"gpt-5.1-codex-max",haiku:"gpt-5.1-codex-mini"}},{id:"gpt-5.2-codex",name:"GPT-5.2 Codex",description:"Cross-plan Codex model with xhigh support",codexMaxEffort:"xhigh",presetMapping:{default:"gpt-5.2-codex",opus:"gpt-5.2-codex",sonnet:"gpt-5.2-codex",haiku:"gpt-5-codex-mini"}},{id:"gpt-5.3-codex",name:"GPT-5.3 Codex",tier:"paid",description:"Paid Codex plans only",codexMaxEffort:"xhigh",presetMapping:{default:"gpt-5.3-codex",opus:"gpt-5.3-codex",sonnet:"gpt-5.3-codex",haiku:"gpt-5-codex-mini"}},{id:"gpt-5.3-codex-spark",name:"GPT-5.3 Codex Spark",tier:"paid",description:"Paid Codex plans only, ultra-fast coding model",codexMaxEffort:"xhigh",presetMapping:{default:"gpt-5.3-codex-spark",opus:"gpt-5.3-codex",sonnet:"gpt-5.3-codex",haiku:"gpt-5-codex-mini"}},{id:"gpt-5.4",name:"GPT-5.4",tier:"paid",description:"Paid Codex plans only, latest GPT-5 family model",codexMaxEffort:"xhigh",presetMapping:{default:"gpt-5.4",opus:"gpt-5.4",sonnet:"gpt-5.4",haiku:"gpt-5-codex-mini"}}]},qwen:{provider:"qwen",displayName:"Qwen",defaultModel:"qwen3-coder-plus",models:[{id:"qwen3-coder-plus",name:"Qwen3 Coder Plus",description:"Code-focused model (1M context)",presetMapping:{default:"qwen3-coder-plus",opus:"qwen3-max",sonnet:"qwen3-coder-plus",haiku:"qwen3-coder-flash"}},{id:"qwen3-max",name:"Qwen3 Max",description:"Flagship model (256K context)",presetMapping:{default:"qwen3-max",opus:"qwen3-max",sonnet:"qwen3-coder-plus",haiku:"qwen3-coder-flash"}},{id:"qwen3-max-preview",name:"Qwen3 Max Preview",description:"Preview with thinking support (256K)",presetMapping:{default:"qwen3-max-preview",opus:"qwen3-max-preview",sonnet:"qwen3-max",haiku:"qwen3-coder-flash"}},{id:"qwen3-235b",name:"Qwen3 235B",description:"Large 235B A22B model",presetMapping:{default:"qwen3-235b",opus:"qwen3-max",sonnet:"qwen3-235b",haiku:"qwen3-coder-flash"}},{id:"qwen3-vl-plus",name:"Qwen3 VL Plus",description:"Vision-language multimodal"},{id:"qwen3-coder-flash",name:"Qwen3 Coder Flash",description:"Fast code generation"},{id:"qwen3-32b",name:"Qwen3 32B",description:"Qwen3 32B model"}]},iflow:{provider:"iflow",displayName:"iFlow",defaultModel:"qwen3-coder-plus",models:[{id:"qwen3-coder-plus",name:"Qwen3 Coder Plus",description:"Recommended default for iFlow accounts",presetMapping:{default:"qwen3-coder-plus",opus:"qwen3-coder-plus",sonnet:"qwen3-coder-plus",haiku:"qwen3-coder-plus"}},{id:"qwen3-max",name:"Qwen3 Max",description:"Flagship Qwen model via iFlow"},{id:"kimi-k2",name:"Kimi K2",description:"Kimi model currently available via iFlow"},{id:"deepseek-v3.2",name:"DeepSeek V3.2",description:"Current DeepSeek V3.2 model via iFlow"},{id:"deepseek-r1",name:"DeepSeek R1",description:"Reasoning-focused DeepSeek model"},{id:"glm-4.6",name:"GLM 4.6",description:"Zhipu GLM 4.6 via iFlow"},{id:"qwen3-vl-plus",name:"Qwen3 VL Plus",description:"Vision-language model"}]},kimi:{provider:"kimi",displayName:"Kimi (Moonshot)",defaultModel:"kimi-k2.5",models:[{id:"kimi-k2.5",name:"Kimi K2.5",description:"Latest multimodal model (262K context)",presetMapping:{default:"kimi-k2.5",opus:"kimi-k2.5",sonnet:"kimi-k2-thinking",haiku:"kimi-k2"}},{id:"kimi-k2-thinking",name:"Kimi K2 Thinking",description:"Extended reasoning model",presetMapping:{default:"kimi-k2-thinking",opus:"kimi-k2.5",sonnet:"kimi-k2-thinking",haiku:"kimi-k2"}},{id:"kimi-k2",name:"Kimi K2",description:"Flagship coding model"}]},kiro:{provider:"kiro",displayName:"Kiro (AWS)",defaultModel:"kiro-claude-sonnet-4-6",models:[{id:"kiro-claude-opus-4-6",name:"Kiro Claude Opus 4.6",description:"Claude Opus 4.6 via Kiro (2.2x credit)",presetMapping:{default:"kiro-claude-opus-4-6",opus:"kiro-claude-opus-4-6",sonnet:"kiro-claude-sonnet-4-6",haiku:"kiro-claude-haiku-4-5"}},{id:"kiro-claude-sonnet-4-6",name:"Kiro Claude Sonnet 4.6",description:"Claude Sonnet 4.6 via Kiro (1.3x credit)",presetMapping:{default:"kiro-claude-sonnet-4-6",opus:"kiro-claude-opus-4-6",sonnet:"kiro-claude-sonnet-4-6",haiku:"kiro-claude-haiku-4-5"}},{id:"kiro-claude-opus-4-5",name:"Kiro Claude Opus 4.5",description:"Claude Opus 4.5 via Kiro (2.2x credit)",presetMapping:{default:"kiro-claude-opus-4-5",opus:"kiro-claude-opus-4-5",sonnet:"kiro-claude-sonnet-4-5",haiku:"kiro-claude-haiku-4-5"}},{id:"kiro-claude-sonnet-4-5",name:"Kiro Claude Sonnet 4.5",description:"Claude Sonnet 4.5 via Kiro (1.3x credit)",presetMapping:{default:"kiro-claude-sonnet-4-5",opus:"kiro-claude-opus-4-5",sonnet:"kiro-claude-sonnet-4-5",haiku:"kiro-claude-haiku-4-5"}},{id:"kiro-claude-sonnet-4",name:"Kiro Claude Sonnet 4",description:"Claude Sonnet 4 via Kiro (1.3x credit)",presetMapping:{default:"kiro-claude-sonnet-4",opus:"kiro-claude-opus-4-5",sonnet:"kiro-claude-sonnet-4",haiku:"kiro-claude-haiku-4-5"}},{id:"kiro-claude-haiku-4-5",name:"Kiro Claude Haiku 4.5",description:"Claude Haiku 4.5 via Kiro (0.4x credit)"}]},ghcp:{provider:"ghcp",displayName:"GitHub Copilot (OAuth)",defaultModel:"claude-sonnet-4.5",models:[{id:"claude-opus-4.5",name:"Claude Opus 4.5",description:"Anthropic Claude Opus 4.5 via GitHub Copilot",presetMapping:{default:"claude-opus-4.5",opus:"claude-opus-4.5",sonnet:"claude-sonnet-4.5",haiku:"claude-haiku-4.5"}},{id:"claude-sonnet-4.5",name:"Claude Sonnet 4.5",description:"Anthropic Claude Sonnet 4.5 via GitHub Copilot",presetMapping:{default:"claude-sonnet-4.5",opus:"claude-opus-4.5",sonnet:"claude-sonnet-4.5",haiku:"claude-haiku-4.5"}},{id:"claude-sonnet-4",name:"Claude Sonnet 4",description:"Anthropic Claude Sonnet 4 via GitHub Copilot"},{id:"claude-haiku-4.5",name:"Claude Haiku 4.5",description:"Anthropic Claude Haiku 4.5 via GitHub Copilot"},{id:"gpt-5.2",name:"GPT-5.2",description:"OpenAI GPT-5.2 via GitHub Copilot",presetMapping:{default:"gpt-5.2",opus:"gpt-5.2",sonnet:"gpt-5.1",haiku:"gpt-5-mini"}},{id:"gpt-5.1",name:"GPT-5.1",description:"OpenAI GPT-5.1 via GitHub Copilot"},{id:"gpt-5",name:"GPT-5",description:"OpenAI GPT-5 via GitHub Copilot"},{id:"gpt-5-mini",name:"GPT-5 Mini",description:"OpenAI GPT-5 Mini via GitHub Copilot"},{id:"gemini-3-pro",name:"Gemini 3 Pro",description:"Google Gemini 3 Pro via GitHub Copilot"}]},claude:{provider:"claude",displayName:"Claude (Anthropic)",defaultModel:"claude-sonnet-4-6",models:[{id:"claude-opus-4-6",name:"Claude Opus 4.6",description:"Latest flagship model",extendedContext:!0,presetMapping:{default:"claude-opus-4-6",opus:"claude-opus-4-6",sonnet:"claude-sonnet-4-6",haiku:"claude-haiku-4-5-20251001"}},{id:"claude-sonnet-4-6",name:"Claude Sonnet 4.6",description:"Balanced performance and speed",extendedContext:!0,presetMapping:{default:"claude-sonnet-4-6",opus:"claude-opus-4-6",sonnet:"claude-sonnet-4-6",haiku:"claude-haiku-4-5-20251001"}},{id:"claude-opus-4-5-20251101",name:"Claude Opus 4.5",description:"Most capable Claude model",extendedContext:!0,presetMapping:{default:"claude-opus-4-5-20251101",opus:"claude-opus-4-5-20251101",sonnet:"claude-sonnet-4-5-20250929",haiku:"claude-haiku-4-5-20251001"}},{id:"claude-sonnet-4-5-20250929",name:"Claude Sonnet 4.5",description:"Balanced performance and speed",extendedContext:!0,presetMapping:{default:"claude-sonnet-4-5-20250929",opus:"claude-opus-4-5-20251101",sonnet:"claude-sonnet-4-5-20250929",haiku:"claude-haiku-4-5-20251001"}},{id:"claude-sonnet-4-20250514",name:"Claude Sonnet 4",description:"Previous generation Sonnet",extendedContext:!0,presetMapping:{default:"claude-sonnet-4-20250514",opus:"claude-opus-4-5-20251101",sonnet:"claude-sonnet-4-20250514",haiku:"claude-haiku-4-5-20251001"}},{id:"claude-haiku-4-5-20251001",name:"Claude Haiku 4.5",description:"Fast and efficient"}]}};function Se(t,a){if(!t)return;const s=J(a);if(t.provider==="agy"){const l=Ua(s);if(l){const o=t.models.find(r=>r.id===l);if(o)return o}}const i=hs[s.toLowerCase()],n=t.models.find(l=>l.id===s||l.id===i);if(n)return n;const c=Xe(s);if(c)return t.models.map(l=>({model:l,info:Xe(l.id)})).filter(l=>!!(l.info&&l.info.family===c.family)).sort((l,o)=>gs(o.info.version,l.info.version))[0]?.model}function qa(t){if(t==="free")return"free";if(typeof t=="string"&&t.trim().length>0)return"paid"}function za(t,a){const s=xe[t.toLowerCase()];if(!a||a.models.length===0)return s;const i=a.models.map(o=>({id:o.id,owned_by:a.provider})),n=a.models.map(o=>{const r=Se(s,o.id);return{...o,name:o.name||r?.name||o.id,tier:r?.tier??qa(o.tier),description:o.description??r?.description,broken:r?.broken,issueUrl:r?.issueUrl,deprecated:r?.deprecated,deprecationReason:r?.deprecationReason,extendedContext:o.extendedContext??r?.extendedContext,presetMapping:r?.presetMapping}}),c=s?.defaultModel?Ae(s.defaultModel,i):void 0,l=typeof c=="string"&&i.some(o=>J(o.id)===J(c));return{provider:a.provider,displayName:a.displayName||s?.displayName||t,defaultModel:l?c:a.defaultModel,models:n}}function Mt(t){const a={},s=new Set([...Object.keys(xe),...Object.keys(t??{})]);for(const i of s){const n=za(i,t?.[i]);n&&(a[i]=n)}return a}function fs(t,a,s){const i=Se(s,a);return i||Se(xe[t.toLowerCase()],a)}function Ae(t,a=[]){const s=J(t),i=Ha(s,a);if(i)return i;const n=Ht(a,s);if(n)return n;const c=hs[s];return(c?Ht(a,c):void 0)??s}function Ga(t,a=[]){return{default:Ae(t.default,a),opus:Ae(t.opus,a),sonnet:Ae(t.sonnet,a),haiku:Ae(t.haiku,a)}}function Pt(t,a=[]){if(!t)return[];const s=xe[t.provider.toLowerCase()]??t,i=new Set;return s.models.map(n=>{const c=Ae(n.id,a),l=n.presetMapping?Ga(n.presetMapping,a):void 0,o=t.models.find(r=>J(r.id)===J(c));return{...n,id:c,name:o?.name||n.name,description:o?.description??n.description,presetMapping:l}}).filter(n=>i.has(n.id)?!1:(i.add(n.id),!0))}function Ba(t,a,s=[]){const i=t.trim().toLowerCase();if(!a||!i)return[];const n=xe[i]??a,c=Pt(a,s),l=new Set(c.map(m=>J(m.id))),o=new Set(c.map(m=>Se(n,m.id)?.id).filter(m=>!!m).map(m=>J(m))),r=new Set,p=new Set(s.map(m=>J(m.id)));return s.filter(m=>{const j=J(m.id),g=_a(m.id),x=Fa(g),T=Se(n,g)??Se(n,x);if(l.has(J(g))||j!==J(g)&&p.has(J(g)))return!1;const k=J(x);if(k!==J(g)&&p.has(k))return!1;const D=T?J(T.id):k;return T&&o.has(D)||r.has(D)||!T&&i==="agy"?!1:(r.add(D),!0)})}function Va(t,a,s){return fs(t,a,s)?.extendedContext===!0}const nt="ccs-internal-managed";async function $a(){try{const t=await fetch("/api/settings/auth/tokens/raw");return t.ok?(await t.json())?.apiKey?.value??nt:nt}catch{return nt}}async function Wa(t,a){if(a)return a;try{const s=await fetch("/api/cliproxy/catalog");if(!s.ok)return xe[t];const i=await s.json();return Mt(i.catalogs)[t]??xe[t]}catch{return xe[t]}}async function pt(t,a,s){const i=await Wa(t,s);if(!i)return{success:!1};const n=i.models.find(p=>p.id===i.defaultModel)||i.models[0],c=n?.presetMapping||{default:i.defaultModel,opus:i.defaultModel,sonnet:i.defaultModel,haiku:i.defaultModel},l=await $a(),r={env:{ANTHROPIC_BASE_URL:`http://127.0.0.1:${mt}/api/provider/${t}`,ANTHROPIC_AUTH_TOKEN:l,ANTHROPIC_MODEL:c.default,ANTHROPIC_DEFAULT_OPUS_MODEL:c.opus,ANTHROPIC_DEFAULT_SONNET_MODEL:c.sonnet,ANTHROPIC_DEFAULT_HAIKU_MODEL:c.haiku}};try{return{success:(await fetch(`/api/settings/${t}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({settings:r})})).ok,presetName:n?.name||i.defaultModel}}catch{return{success:!1}}}function Qa({currentProgress:t,allSteps:a}){return e.jsx("div",{className:"flex justify-center gap-1 pt-2",children:a.map((s,i)=>e.jsx("div",{className:`w-2 h-2 rounded-full transition-colors ${t>=i?"bg-primary":"bg-muted"}`},s))})}function Ja({providers:t,onSelect:a}){return e.jsx("div",{className:"grid gap-2",children:t.map(s=>e.jsxs("button",{onClick:()=>a(s.id),className:"flex items-center justify-between p-3 border rounded-lg hover:bg-muted/50 transition-colors text-left",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:s.name}),e.jsx("div",{className:"text-xs text-muted-foreground",children:s.description})]}),e.jsx(is,{className:"w-4 h-4 text-muted-foreground"})]},s.id))})}function Xa({selectedProvider:t,providers:a,authCommand:s,isRefreshing:i,isPending:n,onBack:c,onStartAuth:l,onRefresh:o}){const{t:r}=W(),[p,m]=d.useState(!1),j=async g=>{await navigator.clipboard.writeText(g),m(!0),setTimeout(()=>m(!1),2e3)};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"text-center space-y-3",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:r("setupWizard.authStep.authenticateWith",{provider:a.find(g=>g.id===t)?.name})}),e.jsx(K,{onClick:l,disabled:n,className:"w-full gap-2",size:"lg",children:n?e.jsxs(e.Fragment,{children:[e.jsx(ce,{className:"w-4 h-4 animate-spin"}),r("setupWizard.authStep.authenticating")]}):e.jsxs(e.Fragment,{children:[e.jsx(ke,{className:"w-4 h-4"}),r("setupWizard.authStep.authenticateInBrowser")]})}),n&&e.jsx("p",{className:"text-xs text-muted-foreground",children:r("setupWizard.authStep.completeOAuth")})]}),e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"absolute inset-0 flex items-center",children:e.jsx("span",{className:"w-full border-t"})}),e.jsx("div",{className:"relative flex justify-center text-xs uppercase",children:e.jsx("span",{className:"bg-background px-2 text-muted-foreground",children:r("setupWizard.authStep.orUseTerminal")})})]}),e.jsx(Wt,{children:e.jsxs(Qt,{className:"p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(Na,{className:"w-4 h-4"}),r("setupWizard.authStep.runCommandHint")]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("code",{className:"flex-1 px-3 py-2 bg-muted rounded-md font-mono text-sm",children:s}),e.jsx(K,{variant:"outline",size:"icon",onClick:()=>j(s),children:p?e.jsx(we,{className:"w-4 h-4 text-green-500"}):e.jsx(rs,{className:"w-4 h-4"})})]})]})}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(K,{variant:"ghost",onClick:c,disabled:n,children:[e.jsx(kt,{className:"w-4 h-4 mr-2"}),r("setupWizard.authStep.back")]}),e.jsxs(K,{variant:"outline",onClick:o,disabled:i||n,children:[e.jsx(wt,{className:`w-4 h-4 mr-2 ${i?"animate-spin":""}`}),r(i?"setupWizard.authStep.checking":"setupWizard.authStep.refreshStatus")]})]})]})}function Ya({accounts:t,privacyMode:a,onSelect:s,onAddNew:i,onBack:n}){const{t:c}=W();return e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:c("setupWizard.accountStep.selectAccount",{count:t.length})}),e.jsx("div",{className:"grid gap-2 max-h-[320px] overflow-y-auto pr-1",children:t.map(l=>{const o=Jt(l.id,l.email,l.tokenFile),r=l.provider?.toLowerCase()==="codex"?Xt(o):null;return e.jsxs("button",{type:"button",onClick:()=>s(l),className:"flex items-center justify-between p-3 border rounded-lg hover:bg-muted/50 transition-colors text-left",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-8 h-8 rounded-full bg-muted flex items-center justify-center",children:e.jsx(Pe,{className:"w-4 h-4 text-muted-foreground"})}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:X("font-medium",a&&gt),children:o.email}),e.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[r?.label?e.jsx(H,{variant:"outline",className:X("text-[10px] h-4 px-1.5 border-transparent",r.audience==="business"?"bg-sky-500/12 text-sky-700 dark:text-sky-300":r.audience==="free"?"bg-slate-200/70 text-slate-700 dark:bg-slate-700/40 dark:text-slate-200":"bg-emerald-500/12 text-emerald-700 dark:text-emerald-300"),children:r.label}):o.audienceLabel?e.jsx(H,{variant:"outline",className:X("text-[10px] h-4 px-1.5 border-transparent",o.audience==="business"?"bg-sky-500/12 text-sky-700 dark:text-sky-300":o.audience==="free"?"bg-slate-200/70 text-slate-700 dark:bg-slate-700/40 dark:text-slate-200":"bg-emerald-500/12 text-emerald-700 dark:text-emerald-300"),children:o.audienceLabel}):null,!r?.label&&o.detailLabel&&e.jsx(H,{variant:"outline",className:"text-[10px] h-4 px-1.5",children:o.detailLabel}),l.isDefault&&e.jsx("span",{className:"text-xs text-muted-foreground",children:c("setupWizard.accountStep.defaultAccount")})]})]})]}),e.jsx(is,{className:"w-4 h-4 text-muted-foreground"})]},l.id)})}),e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"absolute inset-0 flex items-center",children:e.jsx("span",{className:"w-full border-t"})}),e.jsx("div",{className:"relative flex justify-center text-xs uppercase",children:e.jsx("span",{className:"bg-background px-2 text-muted-foreground",children:c("setupWizard.accountStep.or")})})]}),e.jsxs("button",{type:"button",className:"w-full flex items-center gap-3 p-3 border-2 border-dashed border-primary/50 rounded-lg hover:border-primary hover:bg-primary/5 transition-colors text-left",onClick:i,children:[e.jsx("div",{className:"w-8 h-8 rounded-full bg-primary/10 flex items-center justify-center shrink-0",children:e.jsx(ke,{className:"w-4 h-4 text-primary"})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-primary",children:c("setupWizard.accountStep.addNewAccount")}),e.jsx("div",{className:"text-xs text-muted-foreground",children:c("setupWizard.accountStep.addNewAccountDesc")})]})]}),e.jsx("div",{className:"flex items-center justify-between pt-2",children:e.jsxs(K,{variant:"ghost",onClick:n,children:[e.jsx(kt,{className:"w-4 h-4 mr-2"}),c("setupWizard.accountStep.back")]})})]})}const qt="__custom__";function Za({selectedProvider:t,catalog:a,selectedAccount:s,variantName:i,modelName:n,isPending:c,privacyMode:l,onVariantNameChange:o,onModelChange:r,onBack:p,onSkip:m,onCreate:j}){const{t:g}=W(),x=a||xe[t],T=x?.models||[],k=n&&!T.some(f=>f.id===n),[D,A]=d.useState(k),C=t==="agy"&&n.trim().length>0?ue(n):!1,y=s?Jt(s.id,s.email,s.tokenFile):null,w=t==="codex"&&y?Xt(y):null,h=f=>{f===qt?(A(!0),r("")):(A(!1),r(f))};return e.jsxs("div",{className:"space-y-4",children:[s&&e.jsxs("div",{className:"flex items-start gap-2 p-2 bg-muted/50 rounded-md text-sm",children:[e.jsx(Pe,{className:"w-4 h-4"}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs("span",{children:[g("setupVariant.using")," ",e.jsx("span",{className:X(l&&gt),children:y?.email})]}),(y?.audienceLabel||y?.detailLabel)&&e.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[w?.label?e.jsx(H,{variant:"outline",className:X("text-[10px] h-4 px-1.5 border-transparent",w.audience==="business"?"bg-sky-500/12 text-sky-700 dark:text-sky-300":w.audience==="free"?"bg-slate-200/70 text-slate-700 dark:bg-slate-700/40 dark:text-slate-200":"bg-emerald-500/12 text-emerald-700 dark:text-emerald-300"),children:w.label}):y?.audienceLabel?e.jsx(H,{variant:"outline",className:X("text-[10px] h-4 px-1.5 border-transparent",y.audience==="business"?"bg-sky-500/12 text-sky-700 dark:text-sky-300":y.audience==="free"?"bg-slate-200/70 text-slate-700 dark:bg-slate-700/40 dark:text-slate-200":"bg-emerald-500/12 text-emerald-700 dark:text-emerald-300"),children:y.audienceLabel}):null,!w?.label&&y?.detailLabel&&e.jsx(H,{variant:"outline",className:"text-[10px] h-4 px-1.5",children:y.detailLabel})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Y,{htmlFor:"variant-name",children:g("setupVariant.variantNameRequired")}),e.jsx(de,{id:"variant-name",value:i,onChange:f=>o(f.target.value),placeholder:g("setupVariant.variantNamePlaceholder")}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:[g("setupVariant.invokeHintPrefix")," ccs ",i||"<name>",' "prompt"']})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Y,{children:g("setupVariant.model")}),D?e.jsxs("div",{className:"space-y-2",children:[e.jsx(de,{value:n,onChange:f=>r(f.target.value),placeholder:g("setupVariant.modelPlaceholder")}),C&&e.jsx("p",{className:"text-xs text-destructive",children:g("providerEditor.agyDenylist")}),e.jsx("button",{type:"button",className:"text-xs text-primary hover:underline",onClick:()=>{A(!1),t==="agy"&&ue(n)&&r("")},children:g("setupVariant.choosePresetInstead")})]}):e.jsxs(qe,{value:T.some(f=>f.id===n)?n:"",onValueChange:h,children:[e.jsx(ze,{children:e.jsx(Ge,{placeholder:g("setupVariant.selectModel")})}),e.jsxs(Be,{children:[T.map(f=>e.jsx(ye,{value:f.id,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{children:f.name}),f.description&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:["- ",f.description]})]})},f.id)),e.jsx(ye,{value:qt,children:e.jsx("span",{className:"text-primary",children:g("setupVariant.customModelName")})})]})]}),e.jsx("div",{className:"text-xs text-muted-foreground",children:D?g("setupVariant.enterAnyModel"):g("setupVariant.defaultModel",{model:x?.defaultModel||g("setupVariant.providerDefault")})})]}),e.jsxs("div",{className:"flex items-center justify-between pt-2",children:[e.jsxs(K,{variant:"ghost",onClick:p,children:[e.jsx(kt,{className:"w-4 h-4 mr-2"}),g("setupVariant.back")]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(K,{variant:"ghost",onClick:m,children:g("setupVariant.skip")}),e.jsx(K,{onClick:j,disabled:!i||c||C,children:g(c?"setupVariant.creating":"setupVariant.createVariant")})]})]}),e.jsx("p",{className:"text-xs text-center text-muted-foreground",children:g("setupVariant.skipHint")})]})}function en({variantName:t,onClose:a}){const{t:s}=W();return e.jsxs("div",{className:"space-y-4 text-center",children:[e.jsx("div",{className:"flex justify-center",children:e.jsx("div",{className:"w-16 h-16 bg-green-100 dark:bg-green-900/30 rounded-full flex items-center justify-center",children:e.jsx(we,{className:"w-8 h-8 text-green-600 dark:text-green-400"})})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-semibold text-lg",children:s("setupWizard.successStep.title")}),e.jsx("div",{className:"text-sm text-muted-foreground",children:s("setupWizard.successStep.subtitle")})]}),e.jsx(Wt,{children:e.jsxs(Qt,{className:"p-4 space-y-2",children:[e.jsx("div",{className:"text-sm text-muted-foreground",children:s("setupWizard.successStep.usage")}),e.jsxs("code",{className:"block px-3 py-2 bg-muted rounded-md font-mono text-sm",children:["ccs ",t,' "your prompt here"']})]})}),e.jsx(K,{onClick:a,className:"w-full",children:s("setupWizard.successStep.done")})]})}function tn({open:t,onClose:a}){const[s,i]=d.useState("provider"),[n,c]=d.useState(""),[l,o]=d.useState(null),[r,p]=d.useState(""),[m,j]=d.useState(""),[g,x]=d.useState(!1),[T,k]=d.useState(!1),{data:D,refetch:A}=Yt(),{data:C}=Zt(),y=Ps(),w=Ds(),h=Is(),{privacyMode:f}=es(),I=D?.authStatus.find(R=>R.provider===n),u=d.useMemo(()=>I?.accounts||[],[I?.accounts]),E=d.useMemo(()=>Mt(C?.catalogs),[C?.catalogs]),N=!!C;d.useEffect(()=>{if(!t){const R=setTimeout(()=>{i("provider"),c(""),o(null),p(""),j(""),k(!1)},0);return()=>clearTimeout(R)}},[t]),d.useEffect(()=>{if(s==="auth"&&u.length>0&&!T){const R=setTimeout(()=>{i("account")},0);return()=>clearTimeout(R)}},[s,u,T]);const z=async()=>{x(!0),await A(),x(!1)},P=()=>{const R=(I?.accounts?.length||0)===0;w.mutate({provider:n},{onSuccess:async b=>{if(R){const Q=await pt(n,void 0,N?E[n]:void 0);Q.success&&Q.presetName?B.success(`Applied "${Q.presetName}" preset`):Q.success||B.warning(me.t("commonToast.accountAddedPresetFailed"))}b.account&&(o(b.account),i("variant")),A()}})},L=R=>{c(R),(D?.authStatus.find(te=>te.provider===R)?.accounts||[]).length===0?i("auth"):i("account")},_=R=>{o(R),i("variant")},G=async()=>{if(!(!r||!n))try{await y.mutateAsync({name:r,provider:n,model:m||void 0,account:l?.id}),i("success")}catch(R){console.error("Failed to create variant:",R)}},V=`ccs ${n} --auth --add`,q=Ts(s),S=R=>{if(!R&&(w.isPending&&n&&h.mutate(n),s==="success"||s==="provider")){a();return}};return e.jsx(ft,{open:t,onOpenChange:S,children:e.jsxs(vt,{className:"sm:max-w-lg",onPointerDownOutside:R=>{s!=="success"&&s!=="provider"&&R.preventDefault()},onEscapeKeyDown:R=>{(w.isPending||y.isPending)&&R.preventDefault()},children:[e.jsxs(jt,{children:[e.jsxs(bt,{className:"flex items-center gap-2",children:[e.jsx(De,{className:"w-5 h-5 text-primary"}),me.t("setupWizard.title")]}),e.jsxs(ts,{children:[s==="provider"&&me.t("setupWizard.stepProviderDesc"),s==="auth"&&me.t("setupWizard.stepAuthDesc"),s==="account"&&me.t("setupWizard.stepAccountDesc"),s==="variant"&&me.t("setupWizard.stepVariantDesc"),s==="success"&&me.t("setupWizard.stepSuccessDesc")]})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[s==="provider"&&e.jsx(Ja,{providers:It,onSelect:L}),s==="auth"&&e.jsx(Xa,{selectedProvider:n,providers:It,authCommand:V,isRefreshing:g,isPending:w.isPending,onBack:()=>i("provider"),onStartAuth:P,onRefresh:z}),s==="account"&&e.jsx(Ya,{accounts:u,privacyMode:f,onSelect:_,onAddNew:()=>{k(!0),i("auth")},onBack:()=>i("provider")}),s==="variant"&&e.jsx(Za,{selectedProvider:n,catalog:E[n],selectedAccount:l,variantName:r,modelName:m,isPending:y.isPending,privacyMode:f,onVariantNameChange:p,onModelChange:j,onBack:()=>u.length>0?i("account"):i("provider"),onSkip:a,onCreate:G}),s==="success"&&e.jsx(en,{variantName:r,onClose:a})]}),e.jsx(Qa,{currentProgress:q,allSteps:Es})]})})}const sn=3e3,an=300*1e3,nn=3;function it(t){t.invalidateQueries({queryKey:["cliproxy-catalog"]}),t.invalidateQueries({queryKey:["cliproxy-models"]})}async function rt(t){const a=await t.text();if(!a)return{};try{return JSON.parse(a)}catch{const s=t.status>=400?`Request failed with status ${t.status}`:void 0;return s?{error:s}:{}}}const fe={provider:null,isAuthenticating:!1,error:null,authUrl:null,oauthState:null,isSubmittingCallback:!1,isDeviceCodeFlow:!1};function rn(){const{t}=W(),[a,s]=d.useState(fe),i=d.useRef(fe),n=d.useRef(0),c=d.useRef(null),l=d.useRef(null),o=d.useRef(0),r=d.useRef(0),p=d.useRef(!1),m=ht(),j=d.useCallback(A=>A===n.current,[]),g=d.useCallback(()=>{l.current&&(clearInterval(l.current),l.current=null),r.current=0},[]);d.useEffect(()=>()=>{c.current?.abort(),g(),p.current=!1},[g]),d.useEffect(()=>{i.current=a},[a]);const x=d.useCallback(async(A,C,y)=>{if(j(y)){if(Date.now()-o.current>an){g(),j(y)&&s(w=>({...w,isAuthenticating:!1,error:t("toasts.providerAuthTimeout")}));return}try{const w=await fetch(`/api/cliproxy/auth/${A}/status?state=${encodeURIComponent(C)}`);if(!j(y))return;const h=await w.json();if(r.current=0,h.status==="ok"){if(!(typeof h.account=="object"&&h.account!==null)){g();const I=t("toasts.providerAccountRegistrationFailed");B.error(I),s(u=>({...u,isAuthenticating:!1,error:I}));return}g(),m.invalidateQueries({queryKey:["cliproxy-auth"]}),m.invalidateQueries({queryKey:["cliproxy-accounts"]}),m.invalidateQueries({queryKey:["account-quota"]}),it(m),B.success(t("toasts.providerAuthSuccess",{provider:A})),p.current=!1,s(fe)}else if(h.status==="auth_url"){const f=h.url||h.auth_url;f&&(s(I=>({...I,authUrl:f})),p.current||(p.current=!0,window.open(f,"_blank")))}else if(h.status==="device_code"){g();const f=h.user_code&&h.verification_url?`Open ${h.verification_url} and enter code: ${h.user_code}`:"Switch to Device Code method and try again.";B.error(t("toasts.providerDeviceCodeInCallback")),s(I=>({...I,isAuthenticating:!1,error:f}))}else if(h.status==="error"){g();const f=h.error||"Authentication failed";B.error(f),s(I=>({...I,isAuthenticating:!1,error:f}))}}catch(w){if(!j(y)||(r.current+=1,r.current<nn))return;g();const h=w instanceof Error&&w.message.trim().length>0?w.message:t("toasts.providerLostStatusEndpoint");B.error(h),s(f=>({...f,isAuthenticating:!1,error:h}))}}},[j,m,g,t]),T=d.useCallback(async(A,C)=>{if(!Qe(A)){s({...fe,error:t("toasts.providerUnknown",{provider:A})});return}c.current?.abort(),g(),p.current=!1,r.current=0;const y=new AbortController,w=n.current+1;n.current=w,c.current=y;const f=(C?.flowType||(ss(A)?"device_code":"authorization_code"))==="device_code",I=C?.startEndpoint||(f?"start":"start-url"),u={nickname:C?.nickname,kiroMethod:C?.kiroMethod,kiroIDCStartUrl:C?.kiroIDCStartUrl,kiroIDCRegion:C?.kiroIDCRegion,kiroIDCFlow:C?.kiroIDCFlow,gitlabAuthMode:C?.gitlabAuthMode,gitlabBaseUrl:C?.gitlabBaseUrl,gitlabPersonalAccessToken:C?.gitlabPersonalAccessToken,riskAcknowledgement:C?.riskAcknowledgement};s({provider:A,isAuthenticating:!0,error:null,authUrl:null,oauthState:null,isSubmittingCallback:!1,isDeviceCodeFlow:f});try{if(I==="start")fetch(`/api/cliproxy/auth/${A}/start`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(u),signal:y.signal}).then(async E=>{if(!j(w))return;const N=await rt(E);if(!j(w))return;const z=N.success===!0,P=typeof N.account=="object"&&N.account!==null;if(E.ok&&z&&P)m.invalidateQueries({queryKey:["cliproxy-auth"]}),m.invalidateQueries({queryKey:["cliproxy-accounts"]}),m.invalidateQueries({queryKey:["account-quota"]}),it(m),p.current=!1,s(fe);else{const L=typeof N.error=="string"?N.error:t(z?"toasts.providerAccountRegistrationFailed":"auth.loginFailed");B.error(L),s(_=>({..._,isAuthenticating:!1,error:L}))}}).catch(E=>{if(!j(w)||E instanceof Error&&E.name==="AbortError")return;const N=E instanceof Error?E.message:"Authentication failed";B.error(N),s(z=>({...z,isAuthenticating:!1,error:N}))});else{const E=await fetch(`/api/cliproxy/auth/${A}/start-url`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(u),signal:y.signal});if(!j(w))return;const N=await rt(E);if(!j(w))return;const z=N.success===!0;if(!E.ok||!z){const _=typeof N.error=="string"?N.error:t("toasts.providerStartOAuthFailed");throw new Error(_)}const P=typeof N.authUrl=="string"?N.authUrl:null,L=typeof N.state=="string"?N.state:null;if(s(_=>({..._,authUrl:P,oauthState:L})),P&&(p.current=!0,window.open(P,"_blank")),L){if(o.current=Date.now(),!P){if(await x(A,L,w),!j(w))return;const _=i.current;if(!_.isAuthenticating||_.provider!==A)return}l.current=setInterval(()=>{x(A,L,w)},sn)}}}catch(E){if(!j(w))return;if(E instanceof Error&&E.name==="AbortError"){p.current=!1,s(fe);return}const N=E instanceof Error?E.message:t("auth.loginFailed");B.error(N),s(z=>({...z,isAuthenticating:!1,error:N}))}},[j,x,g,m,t]),k=d.useCallback(()=>{const A=a.provider;n.current+=1,c.current?.abort(),g(),p.current=!1,s(fe),A&&Ve.cliproxy.auth.cancel(A).catch(()=>{})},[a.provider,g]),D=d.useCallback(async A=>{if(!a.provider)return;const C=n.current,y=a.provider;s(w=>({...w,isSubmittingCallback:!0,error:null}));try{const w=await fetch(`/api/cliproxy/auth/${y}/submit-callback`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({redirectUrl:A})});if(!j(C))return;const h=await rt(w);if(!j(C))return;const f=h.success===!0,I=h.status==="wait",u=typeof h.account=="object"&&h.account!==null;if(w.ok&&I)s(E=>({...E,isSubmittingCallback:!1,error:null}));else if(w.ok&&f&&u)g(),m.invalidateQueries({queryKey:["cliproxy-auth"]}),m.invalidateQueries({queryKey:["cliproxy-accounts"]}),m.invalidateQueries({queryKey:["account-quota"]}),it(m),B.success(t("toasts.providerAuthSuccess",{provider:y})),s(fe);else{const E=typeof h.error=="string"?h.error:t(f?"toasts.providerAccountRegistrationFailed":"toasts.providerCallbackFailed");throw new Error(E)}}catch(w){if(!j(C))return;const h=w instanceof Error?w.message:t("toasts.providerSubmitCallbackFailed");B.error(h),s(f=>({...f,isSubmittingCallback:!1,error:h}))}},[j,a.provider,m,g,t]);return d.useMemo(()=>({...a,startAuth:T,cancelAuth:k,submitCallback:D}),[a,T,k,D])}function xt({className:t,compact:a=!1,showAcknowledgement:s=!1,acknowledgementPhrase:i=$e,acknowledgementText:n="",onAcknowledgementTextChange:c,disabled:l=!1,showProxySettingsLink:o=!1}){const{t:r}=W(),p=r("accountSafetyWarning.title"),m=r("accountSafetyWarning.subtitle"),j=r("accountSafetyWarning.firstLine"),g=r("accountSafetyWarning.secondLine"),x="https://github.com/kaitranntt/ccs/issues/509",T=r("accountSafetyWarning.issueLabel"),k=r("accountSafetyWarning.proxySettingsLabel");return a?e.jsx("section",{role:"alert",className:X("border-b border-amber-200/70 bg-amber-50/45 dark:bg-amber-950/5",t),children:e.jsxs("div",{className:"flex flex-col gap-3 px-6 py-3 lg:flex-row lg:items-start lg:justify-between",children:[e.jsxs("div",{className:"min-w-0 flex items-start gap-3",children:[e.jsx("div",{className:"mt-0.5 inline-flex h-6 w-6 items-center justify-center rounded-md bg-amber-500/12 text-amber-700 dark:text-amber-300",children:e.jsx(Je,{className:"h-3.5 w-3.5"})}),e.jsxs("div",{className:"min-w-0 space-y-1",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("p",{className:"text-xs font-semibold leading-5",children:p}),e.jsx("p",{className:"text-[11px] text-muted-foreground",children:m})]}),e.jsx("p",{className:"text-xs leading-5 text-muted-foreground",children:j}),e.jsx("p",{className:"text-xs font-medium leading-5 text-amber-900 dark:text-amber-200",children:g})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 lg:justify-end",children:[e.jsxs("a",{href:x,target:"_blank",rel:"noreferrer",className:"inline-flex items-center gap-1 rounded-md border border-amber-500/25 bg-background/90 px-2 py-1 text-[11px] font-medium text-amber-800 transition-colors hover:bg-amber-500/10 dark:text-amber-200",children:[T,e.jsx(ke,{className:"h-3 w-3"})]}),o?e.jsxs("a",{href:"/settings?tab=proxy",className:"inline-flex items-center gap-1 rounded-md border border-amber-500/25 bg-background/90 px-2 py-1 text-[11px] font-medium text-amber-800 transition-colors hover:bg-amber-500/10 dark:text-amber-200",children:[e.jsx(Ut,{className:"h-3 w-3"}),k]}):null,e.jsx(H,{variant:"outline",className:"border-amber-500/40 text-[10px] text-amber-700 dark:text-amber-300",children:"High Risk"})]})]})}):e.jsxs("section",{role:"alert",className:X("relative overflow-hidden rounded-xl border border-amber-500/30 bg-gradient-to-br from-amber-50 via-background to-rose-50/70 shadow-sm dark:from-amber-950/20 dark:to-rose-950/20",t),children:[e.jsx("div",{className:"absolute inset-x-0 top-0 h-0.5 bg-gradient-to-r from-amber-500 via-orange-500 to-rose-500"}),e.jsxs("div",{className:"space-y-3 p-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"flex items-start gap-2.5",children:[e.jsx("div",{className:"mt-0.5 inline-flex h-7 w-7 items-center justify-center rounded-md bg-amber-500/15 text-amber-700 dark:text-amber-400",children:e.jsx(Je,{className:"h-4 w-4"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-semibold leading-5",children:p}),e.jsx("p",{className:"text-xs text-muted-foreground",children:m})]})]}),e.jsx(H,{variant:"outline",className:"border-amber-500/40 text-amber-700 dark:text-amber-300",children:"High Risk"})]}),e.jsxs("div",{className:"space-y-2 text-sm leading-relaxed",children:[e.jsx("p",{children:j}),e.jsx("p",{className:"font-medium text-amber-900 dark:text-amber-200",children:g}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"CCS is provided as-is and does not take responsibility for suspension, bans, or access loss from upstream providers."})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs("a",{href:x,target:"_blank",rel:"noreferrer",className:"inline-flex items-center gap-1.5 rounded-md border border-amber-500/30 bg-amber-500/10 px-2.5 py-1 text-xs font-medium text-amber-800 transition-colors hover:bg-amber-500/15 dark:text-amber-200",children:[T,e.jsx(ke,{className:"h-3.5 w-3.5"})]}),o&&e.jsxs("a",{href:"/settings?tab=proxy",className:"inline-flex items-center gap-1.5 rounded-md border border-amber-500/30 bg-amber-500/10 px-2.5 py-1 text-xs font-medium text-amber-800 transition-colors hover:bg-amber-500/15 dark:text-amber-200",children:[e.jsx(Ut,{className:"h-3.5 w-3.5"}),k]}),e.jsx("span",{className:"rounded-md border border-border/70 bg-muted/60 px-2.5 py-1 text-xs text-muted-foreground",children:"Applies to CLI and dashboard auth"})]}),s&&c&&e.jsxs("div",{className:"rounded-lg border border-amber-500/25 bg-amber-500/5 p-2.5",children:[e.jsxs(Y,{htmlFor:"account-risk-ack-text",className:"text-xs leading-5",children:["Type exact phrase to continue:"," ",e.jsx("code",{className:"rounded bg-muted px-1 py-0.5 font-mono",children:i})]}),e.jsx(de,{id:"account-risk-ack-text",value:n,onChange:D=>c(D.target.value),placeholder:i,disabled:l,className:"mt-2 font-mono text-xs"})]})]})]})}function on({className:t,value:a,onChange:s,disabled:i=!1}){const{t:n}=W(),c=[a.reviewedIssue509,a.understandsBanRisk,a.acceptsFullResponsibility,a.typedPhrase.trim().replace(/\s+/g," ").toUpperCase()===Kt].filter(Boolean).length,l=c/4*100,o=r=>{s({...a,...r})};return e.jsxs("section",{role:"alert",className:X("relative overflow-hidden rounded-xl border border-rose-500/35 bg-gradient-to-br from-rose-50 via-background to-amber-50/70 p-4 shadow-sm dark:from-rose-950/20 dark:to-amber-950/20",t),children:[e.jsx("div",{className:"absolute inset-x-0 top-0 h-0.5 bg-gradient-to-r from-rose-500 via-orange-500 to-amber-500"}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"flex items-start gap-2.5",children:[e.jsx("div",{className:"mt-0.5 inline-flex h-7 w-7 items-center justify-center rounded-md bg-rose-500/15 text-rose-700 dark:text-rose-300",children:e.jsx(Je,{className:"h-4 w-4"})}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-sm font-semibold leading-5",children:n("antigravityChecklist.title")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:n("antigravityChecklist.subtitle")})]})]}),e.jsx(H,{variant:"outline",className:"border-rose-500/40 text-rose-700 dark:text-rose-300",children:n("antigravityChecklist.mandatory")})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between text-xs text-muted-foreground",children:[e.jsx("span",{children:n("antigravityChecklist.completion")}),e.jsx("span",{children:n("antigravityChecklist.stepsCount",{current:c})})]}),e.jsx(Rs,{value:l,className:"h-2"})]}),e.jsxs("div",{className:"space-y-3 rounded-lg border border-rose-500/20 bg-rose-500/5 p-3",children:[e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(We,{id:"agy-step-reviewed-issue",checked:a.reviewedIssue509,onCheckedChange:r=>o({reviewedIssue509:!!r}),disabled:i}),e.jsx(Y,{htmlFor:"agy-step-reviewed-issue",className:"text-xs leading-5",children:"Step 1: I reviewed issue #509 and understand AGY OAuth can trigger account bans/suspensions."})]}),e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(We,{id:"agy-step-understands-risk",checked:a.understandsBanRisk,onCheckedChange:r=>o({understandsBanRisk:!!r}),disabled:i}),e.jsx(Y,{htmlFor:"agy-step-understands-risk",className:"text-xs leading-5",children:"Step 2: I understand this OAuth action is my own decision and I accept the upstream risk."})]}),e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(We,{id:"agy-step-accept-responsibility",checked:a.acceptsFullResponsibility,onCheckedChange:r=>o({acceptsFullResponsibility:!!r}),disabled:i}),e.jsx(Y,{htmlFor:"agy-step-accept-responsibility",className:"text-xs leading-5",children:"Step 3: I accept full responsibility. CCS is not liable for suspension, bans, or access loss."})]})]}),e.jsxs("div",{className:"space-y-2 rounded-lg border border-amber-500/25 bg-amber-500/5 p-3",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-xs font-medium text-amber-800 dark:text-amber-200",children:[e.jsx(os,{className:"h-3.5 w-3.5"}),"Step 4: Type exact phrase to continue"]}),e.jsx(de,{value:a.typedPhrase,onChange:r=>o({typedPhrase:r.target.value}),placeholder:Kt,disabled:i,className:"font-mono text-xs"})]}),e.jsx("div",{className:"flex flex-wrap items-center gap-2 text-xs",children:e.jsxs("a",{href:"https://github.com/kaitranntt/ccs/issues/509",target:"_blank",rel:"noreferrer",className:"inline-flex items-center gap-1.5 rounded-md border border-rose-500/30 bg-rose-500/10 px-2.5 py-1 font-medium text-rose-800 transition-colors hover:bg-rose-500/15 dark:text-rose-200",children:["Read issue #509",e.jsx(ke,{className:"h-3.5 w-3.5"})]})})]})]})}function ln(t){return t.trim().replace(/\s+/g," ").toUpperCase()}function dn({open:t,onClose:a,provider:s,displayName:i,catalog:n,isFirstAccount:c=!1}){const[l,o]=d.useState(""),[r,p]=d.useState(""),[m,j]=d.useState(!1),[g,x]=d.useState(null),[T,k]=d.useState(""),[D,A]=d.useState(at),[C,y]=d.useState(!1),[w,h]=d.useState(!1),[f,I]=d.useState(Et),[u,E]=d.useState(""),[N,z]=d.useState(""),[P,L]=d.useState(Tt),[_,G]=d.useState("oauth"),[V,q]=d.useState(""),[S,R]=d.useState(""),{t:b}=W(),Q=d.useRef(!1),te=d.useRef(0),ne=d.useRef(!1),U=rn(),ae=Ls(),$=s==="kiro",Z=s==="gitlab",ie=s==="agy"||s==="gemini",v=s==="gemini"&&!C,O=s==="agy"&&!C,be=ie&&w,Ee=Pa(D),Te=ln(T)===$e,Ye=ss(s),Re=Os(f),he=$&&f==="idc",Ne=$&&Fs(f),Me=$?_s(f,P):void 0,Ze=$?Ks(f):void 0,et=$?Me==="device_code":Ye,re=U.isAuthenticating||ae.isPending,Le=l.trim(),Oe=u.trim(),_e=N.trim(),Fe=V.trim(),F=S.trim(),ee=g||U.error,oe=d.useCallback(async()=>{const M=await fetch("/api/settings/auth/antigravity-risk");if(!M.ok)throw new Error("Failed to load power user mode setting");return(await M.json()).antigravityAckBypass===!0},[]),ge=d.useCallback(async({pendingMessage:M=null,disabledMessage:pe=null}={})=>{const st=++te.current;h(!0),M!==null&&x(M);try{const Ue=await oe();return te.current!==st||(y(Ue),pe?x(Ue?null:pe):M!==null&&x(null)),Ue}catch{return te.current!==st||(y(!1),x(pe??b("addAccountDialog.powerUserLoadFailed")),ne.current||(ne.current=!0,B.error(b("addAccountDialog.powerUserLoadFailed")))),!1}finally{te.current===st&&h(!1)}},[oe,b]),tt=()=>{o(""),p(""),j(!1),x(null),k(""),A(at),y(!1),h(!1),I(Et),E(""),z(""),L(Tt),G("oauth"),q(""),R(""),te.current+=1,ne.current=!1,Q.current=!1,a()};d.useEffect(()=>{t&&(k(""),A(at),x(null))},[s,t]),d.useEffect(()=>()=>{te.current+=1},[]),d.useEffect(()=>{if(!t||!ie){te.current+=1,y(!1),h(!1);return}ge()},[t,s,ie,ge]),d.useEffect(()=>{if(!t||s!=="agy"||!U.error||!C)return;const M=U.error.toLowerCase();(M.includes("agy_risk_ack_required")||M.includes("responsibility acknowledgement")||M.includes("responsibility checklist"))&&ge({pendingMessage:b("addAccountDialog.powerUserLoading"),disabledMessage:b("addAccountDialog.powerUserUnavailableRetry")})},[U.error,t,C,s,ge,b]),d.useEffect(()=>{!U.isAuthenticating&&!U.error&&U.provider===null&&t&&Q.current&&(Q.current=!1,(async()=>{try{const pe=await pt(s,void 0,n);pe.success&&pe.presetName&&c&&B.success(`Applied "${pe.presetName}" preset`)}catch{}tt()})())},[U.isAuthenticating,U.error,U.provider]);const Dt=()=>{U.cancelAuth(),tt()},ys=async()=>{U.authUrl&&(await navigator.clipboard.writeText(U.authUrl),j(!0),setTimeout(()=>j(!1),2e3))},ks=()=>{r.trim()&&U.submitCallback(r.trim())},ws=()=>{if(be){x(b("addAccountDialog.powerUserLoading"));return}if(O&&!Ee){x("Complete all Antigravity responsibility steps before authenticating this provider.");return}if(v&&!Te){x(`Type "${$e}" to acknowledge the account safety warning before authenticating this provider.`);return}if(x(null),he&&!Oe){x("IDC Start URL is required for Kiro IAM Identity Center login.");return}if(Z&&_==="pat"&&!F){x(b("addAccountDialog.gitlabPatRequired"));return}Q.current=!0,U.startAuth(s,{nickname:Le||void 0,kiroMethod:$?f:void 0,kiroIDCStartUrl:he?Oe:void 0,kiroIDCRegion:he&&_e?_e:void 0,kiroIDCFlow:he?P:void 0,gitlabAuthMode:Z?_:void 0,gitlabBaseUrl:Z&&Fe?Fe:void 0,gitlabPersonalAccessToken:Z&&_==="pat"&&F?F:void 0,flowType:$?Me:void 0,startEndpoint:$?Ze:Z&&_==="pat"?"start":void 0,riskAcknowledgement:O?{version:Da,reviewedIssue509:D.reviewedIssue509,understandsBanRisk:D.understandsBanRisk,acceptsFullResponsibility:D.acceptsFullResponsibility,typedPhrase:D.typedPhrase}:void 0})},Cs=()=>{Q.current=!0,ae.mutate(void 0,{onSuccess:async()=>{const M=await pt("kiro",void 0,n);M.success&&M.presetName&&c&&B.success(`Applied "${M.presetName}" preset`),tt()}})},As=M=>{M||Dt()},le=U.isAuthenticating;return e.jsx(ft,{open:t,onOpenChange:As,children:e.jsxs(vt,{className:"sm:max-w-md",onInteractOutside:M=>{le&&M.preventDefault()},children:[e.jsxs(jt,{children:[e.jsx(bt,{children:b("addAccountDialog.title",{displayName:i})}),e.jsx(ts,{children:b($?"addAccountDialog.descKiro":et?"addAccountDialog.descDeviceCode":"addAccountDialog.descOauth")})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[O&&!le&&e.jsx(on,{value:D,onChange:M=>{A(M),x(null)},disabled:re}),ie&&C&&!le&&e.jsxs("div",{className:"rounded-lg border border-amber-400/35 bg-amber-50/70 p-3 text-xs text-amber-900 dark:border-amber-800/60 dark:bg-amber-950/25 dark:text-amber-100",children:[e.jsxs("div",{className:"mb-1.5 flex items-center gap-1.5 font-semibold",children:[e.jsx(os,{className:"h-3.5 w-3.5"}),b("addAccountDialog.powerUserEnabled")]}),b("addAccountDialog.powerUserSkipped")]}),v&&!le&&e.jsx(xt,{showAcknowledgement:!0,acknowledgementPhrase:$e,acknowledgementText:T,onAcknowledgementTextChange:M=>{k(M),x(null)},disabled:re}),$&&!le&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(Y,{htmlFor:"kiro-auth-method",children:b("addAccountDialog.authMethod")}),e.jsxs(qe,{value:f,onValueChange:M=>{I(M),x(null)},children:[e.jsx(ze,{id:"kiro-auth-method",children:e.jsx(Ge,{placeholder:b("addAccountDialog.selectKiroAuthMethod")})}),e.jsx(Be,{children:Us.map(M=>e.jsx(ye,{value:M.id,children:M.label},M.id))})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:Re.description}),Ne&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["If your browser does not return automatically after login, CCS can accept the final",e.jsx("span",{className:"mx-1 rounded bg-muted px-1.5 py-0.5 font-mono text-[11px]",children:"kiro://..."}),"callback URL in the next step."]})]}),he&&!le&&e.jsxs("div",{className:"space-y-4 rounded-lg border border-border/60 bg-muted/20 p-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(Y,{htmlFor:"kiro-idc-start-url",children:"IDC Start URL"}),e.jsx(de,{id:"kiro-idc-start-url",value:u,onChange:M=>{E(M.target.value),x(null)},placeholder:"https://d-xxx.awsapps.com/start",disabled:re}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Required for organization IAM Identity Center login."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Y,{htmlFor:"kiro-idc-region",children:"IDC Region"}),e.jsx(de,{id:"kiro-idc-region",value:N,onChange:M=>{z(M.target.value),x(null)},placeholder:"us-east-1",disabled:re}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Optional. Leave blank to use the upstream default region."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Y,{htmlFor:"kiro-idc-flow",children:"IDC Flow"}),e.jsxs(qe,{value:P,onValueChange:M=>{L(M),x(null)},children:[e.jsx(ze,{id:"kiro-idc-flow",children:e.jsx(Ge,{placeholder:"{/* TODO i18n: missing key */}Select IDC flow"})}),e.jsxs(Be,{children:[e.jsx(ye,{value:"authcode",children:"Authorization Code"}),e.jsx(ye,{value:"device",children:"Device Code"})]})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Auth Code opens a browser and may need the final callback URL pasted back. Device Code shows a verification code instead."})]})]}),Z&&!le&&e.jsxs("div",{className:"space-y-4 rounded-lg border border-border/60 bg-muted/20 p-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(Y,{htmlFor:"gitlab-auth-mode",children:b("addAccountDialog.gitlabAuthMethod")}),e.jsxs(qe,{value:_,onValueChange:M=>{G(M),x(null)},children:[e.jsx(ze,{id:"gitlab-auth-mode",children:e.jsx(Ge,{placeholder:b("addAccountDialog.selectGitlabAuthMethod")})}),e.jsxs(Be,{children:[e.jsx(ye,{value:"oauth",children:b("addAccountDialog.gitlabAuthOAuth")}),e.jsx(ye,{value:"pat",children:b("addAccountDialog.gitlabAuthPat")})]})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:b("addAccountDialog.gitlabAuthHint")})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Y,{htmlFor:"gitlab-base-url",children:b("addAccountDialog.gitlabUrl")}),e.jsx(de,{id:"gitlab-base-url",value:V,onChange:M=>{q(M.target.value),x(null)},placeholder:b("addAccountDialog.gitlabUrlPlaceholder"),disabled:re}),e.jsx("p",{className:"text-xs text-muted-foreground",children:b("addAccountDialog.gitlabUrlHint")})]}),_==="pat"&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(Y,{htmlFor:"gitlab-pat",children:b("addAccountDialog.gitlabPat")}),e.jsx(de,{id:"gitlab-pat",type:"password",value:S,onChange:M=>{R(M.target.value),x(null)},placeholder:b("addAccountDialog.gitlabPatPlaceholder"),disabled:re}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[b("addAccountDialog.gitlabPatHint")," ",e.jsx("span",{className:"font-mono",children:"api"})," and"," ",e.jsx("span",{className:"font-mono",children:"read_user"})," scopes."]})]})]}),!le&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(Y,{htmlFor:"nickname",children:b("addAccountDialog.nicknameOptional")}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Pe,{className:"w-4 h-4 text-muted-foreground"}),e.jsx(de,{id:"nickname",value:l,onChange:M=>{o(M.target.value),x(null)},placeholder:b("addAccountDialog.nicknamePlaceholder"),disabled:re,className:"flex-1"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:b("addAccountDialog.nicknameOptionalHint")})]}),le&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"text-center",children:[e.jsxs("p",{className:"text-sm text-muted-foreground",children:[e.jsx(ce,{className:"w-4 h-4 inline mr-2 animate-spin"}),b("addAccountDialog.waitingForAuth")]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:U.isDeviceCodeFlow?b("addAccountDialog.deviceCodeHint"):Ne?"Complete sign-in in your browser. If it does not return automatically, paste the final kiro:// callback URL below.":b("addAccountDialog.browserHint")})]}),U.authUrl&&!U.isDeviceCodeFlow&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(Y,{className:"text-xs",children:b("addAccountDialog.openUrlLabel")}),e.jsxs("div",{className:"p-3 bg-muted rounded-md",children:[e.jsx("p",{className:"text-xs text-muted-foreground break-all font-mono line-clamp-3",children:U.authUrl}),e.jsxs("div",{className:"flex gap-2 mt-2",children:[e.jsx(K,{variant:"outline",size:"sm",onClick:ys,children:m?e.jsxs(e.Fragment,{children:[e.jsx(we,{className:"w-3 h-3 mr-1"}),b("addAccountDialog.copied")]}):e.jsxs(e.Fragment,{children:[e.jsx(rs,{className:"w-3 h-3 mr-1"}),b("addAccountDialog.copy")]})}),e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>{if(!U.authUrl)return;const M=window.open(U.authUrl,"_blank");(!M||M.closed||typeof M.closed>"u")&&B.warning(b("addAccountDialog.popupBlocked"),{duration:5e3})},children:[e.jsx(ke,{className:"w-3 h-3 mr-1"}),b("addAccountDialog.open")]})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Y,{htmlFor:"callback-url",className:"text-xs",children:Ne?"Browser did not return? Paste the final kiro:// callback URL:":b("addAccountDialog.redirectPasteLabel")}),e.jsx(de,{id:"callback-url",value:r,onChange:M=>p(M.target.value),placeholder:Ne?"kiro://kiro.kiroAgent/authenticate-success?code=...&state=...":b("addAccountDialog.callbackPlaceholder"),className:"font-mono text-xs"}),e.jsx(K,{variant:"secondary",size:"sm",onClick:ks,disabled:!r.trim()||U.isSubmittingCallback,children:U.isSubmittingCallback?e.jsxs(e.Fragment,{children:[e.jsx(ce,{className:"w-3 h-3 mr-1 animate-spin"}),b("addAccountDialog.submitting")]}):b("addAccountDialog.submitCallback")})]})]}),!U.authUrl&&!U.isDeviceCodeFlow&&e.jsx("p",{className:"text-xs text-center text-muted-foreground",children:Ne?"Preparing the Kiro sign-in URL. If it does not open automatically, it will appear here shortly.":b("addAccountDialog.preparingUrl")})]}),ee&&e.jsx("p",{className:"text-xs text-center text-destructive",children:ee}),ae.isPending&&e.jsxs("p",{className:"text-sm text-center text-muted-foreground",children:[e.jsx(ce,{className:"w-4 h-4 inline mr-2 animate-spin"}),b("addAccountDialog.importingToken")]}),e.jsxs("div",{className:"flex items-center justify-end gap-2 pt-2",children:[e.jsx(K,{variant:"ghost",onClick:Dt,children:b("addAccountDialog.cancel")}),$&&!le&&e.jsx(K,{variant:"outline",onClick:Cs,disabled:re,children:ae.isPending?e.jsxs(e.Fragment,{children:[e.jsx(ce,{className:"w-4 h-4 mr-2 animate-spin"}),b("addAccountDialog.importing")]}):e.jsxs(e.Fragment,{children:[e.jsx(ya,{className:"w-4 h-4 mr-2"}),b("addAccountDialog.importFromIde")]})}),!le&&e.jsxs(K,{onClick:ws,disabled:re||be||O&&!Ee||v&&!Te,children:[e.jsx(ke,{className:"w-4 h-4 mr-2"}),b("addAccountDialog.authenticate")]})]})]})]})})}const cn=["ANTHROPIC_BASE_URL","ANTHROPIC_AUTH_TOKEN"];function un(t){const a=t?.env||{};return cn.filter(s=>!a[s]?.trim())}function mn(t,a){const[s,i]=d.useState(null),[n,c]=d.useState(!1),l=ht(),{data:o,isLoading:r,refetch:p}=$t({queryKey:["settings",t],queryFn:async()=>{const P=await fetch(`/api/settings/${t}/raw`);if(!P.ok){const L=t==="cursor"?`~/.ccs/cliproxy/providers/${t}.settings.json`:Qe(t)?`~/.ccs/${t}.settings.json`:`~/.ccs/profiles/${t}/settings.json`;return{profile:t,settings:{env:{}},mtime:Date.now(),path:L}}return P.json()}}),m=o?.settings,j=d.useMemo(()=>s!==null?s:m?JSON.stringify(m,null,2):`{
2
- "env": {}
3
- }`,[s,m]),g=d.useCallback(P=>{i(P)},[]),x=d.useMemo(()=>{try{return JSON.parse(j)}catch{return m||{env:{}}}},[j,m]),T=x?.env?.ANTHROPIC_MODEL,k=x?.env?.ANTHROPIC_DEFAULT_OPUS_MODEL,D=x?.env?.ANTHROPIC_DEFAULT_SONNET_MODEL,A=x?.env?.ANTHROPIC_DEFAULT_HAIKU_MODEL,C=d.useMemo(()=>Hs(x?.env||{}),[x]),y=d.useCallback((P,L)=>qs(P,L,{supportsExtendedContext:_=>Va(t,_,a)}),[a,t]),w=d.useCallback((P,L)=>{const _={...x?.env||{},[P]:L},G=Rt(P)?y(_,C):_;delete G.CCS_EXTENDED_CONTEXT;const V={...x,env:G};i(JSON.stringify(V,null,2))},[y,x,C]),h=d.useCallback(P=>{const L=x?.env||{},_=y(L,P);delete _.CCS_EXTENDED_CONTEXT;const G={...x,env:_};i(JSON.stringify(G,null,2))},[y,x]),f=d.useCallback(P=>{const L={...x?.env||{},...P},G=Object.keys(P).some(Rt)?y(L,C):L;delete G.CCS_EXTENDED_CONTEXT;const V={...x,env:G};i(JSON.stringify(V,null,2))},[y,x,C]),I=d.useMemo(()=>{try{return JSON.parse(j),!0}catch{return!1}},[j]),u=d.useMemo(()=>s===null?!1:s!==JSON.stringify(m,null,2),[s,m]),E=d.useMemo(()=>un(x),[x]),N=Ss({mutationFn:async()=>{const P=JSON.parse(j),L=await fetch(`/api/settings/${t}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({settings:P,expectedMtime:o?.mtime})});if(L.status===409)throw new Error("CONFLICT");if(!L.ok)throw new Error("Failed to save");return L.json()},onSuccess:P=>{l.invalidateQueries({queryKey:["settings",t]}),i(null),P?.warning?B.success(me.t("settings.saved"),{description:P.warning}):B.success(me.t("settings.saved"))},onError:P=>{P.message==="CONFLICT"?c(!0):B.error(P.message)}}),z=async P=>{c(!1),P?(await p(),N.mutate()):i(null)};return{data:o,isLoading:r,refetch:p,rawJsonContent:j,rawJsonEdits:s,isRawJsonValid:I,hasChanges:u,currentSettings:x,currentModel:T,opusModel:k,sonnetModel:D,haikuModel:A,extendedContextEnabled:C,toggleExtendedContext:h,handleRawJsonChange:g,updateEnvValue:w,updateEnvValues:f,saveMutation:{mutate:()=>N.mutate(),isPending:N.isPending},conflictDialog:n,setConflictDialog:c,handleConflictResolve:z,missingRequiredFields:E}}const vs=/-(medium|high|xhigh)$/i,pn=["medium","high","xhigh"];function js(t){return t?.trim()??""}function bs(t){if(!t)return;const a=js(t).match(vs);if(a?.[1])return a[1].toLowerCase()}function Ns(t){return js(t).replace(vs,"")}function zt(t,a){const s=Ns(t);return!s||!a?s:`${s}-${a}`}function xn(t,a){if(!a){const n=bs(t);return[zt(t,n)]}const s=Ns(t),i=[s];for(const n of pn)if(i.push(zt(s,n)),n===a)break;return i}function hn(t,a){if(!t)return null;const s=bs(t);return s?{label:`Pinned ${s}`,explicit:!0}:{label:"Auto effort",explicit:!1}}function gn({label:t}){return e.jsx(H,{variant:"outline",className:"text-[9px] h-4 px-1",children:t})}function Ke({modelId:t}){const a=hn(t);return a?e.jsx(H,{variant:a.explicit?"secondary":"outline",className:"text-[9px] h-4 px-1 uppercase",children:a.label}):null}function Gt(t,a){if(!t)return"";if(!a?.prefix)return t;const s=`${a.prefix}/`;return t.startsWith(s)?t.slice(s.length):t}function He(t,a){return a?.recommendedModelId??t}function ot(t,a,s){return s?xn(a,t):[a]}function je({label:t,description:a,value:s,onChange:i,catalog:n,allModels:c,routing:l,disabled:o}){const{t:r}=W(),p=n?.provider==="codex",m=d.useMemo(()=>Pt(n,c),[c,n]),j=d.useMemo(()=>Ba(n?.provider??"",n,c),[c,n]),g=new Set(m.map(h=>h.id)),x=d.useMemo(()=>new Map((l?.models??[]).map(h=>[h.modelId.toLowerCase(),h])),[l]),T=d.useMemo(()=>new Set(m.flatMap(h=>ot(h.codexMaxEffort,He(h.id,x.get(h.id.toLowerCase())),p))),[p,m,x]),k=d.useMemo(()=>x.get(Gt(s,l).toLowerCase()),[l,x,s]),D=m.flatMap(h=>{const f=x.get(h.id.toLowerCase());return ot(h.codexMaxEffort,He(h.id,f),p).map(u=>({value:u,groupKey:"recommended",searchText:`${u} ${h.id} ${h.name} ${f?.recommendedModelId??""}`,keywords:[h.tier??"",n?.provider??""],triggerContent:e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"truncate font-mono text-xs",children:u}),f?.pinnedAvailable?e.jsx(H,{variant:"secondary",className:"text-[9px] h-4 px-1 uppercase",children:f.prefix}):null,p&&e.jsx(Ke,{modelId:u})]}),itemContent:e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"truncate font-mono text-xs",children:u}),h.tier==="paid"&&e.jsx(gn,{label:r("providerModelSelector.paid")}),f?.unprefixedStatus==="shadowed"?e.jsx(H,{variant:"outline",className:"text-[9px] h-4 px-1",children:r("providerModelSelector.shadowed")}):null,f?.unprefixedStatus==="prefix-only"?e.jsx(H,{variant:"outline",className:"text-[9px] h-4 px-1",children:r("providerModelSelector.prefixOnly")}):null,p&&e.jsx(Ke,{modelId:u})]})}))}),A=j.filter(h=>!g.has(h.id)).filter(h=>!T.has(He(h.id,x.get(h.id.toLowerCase())))).flatMap(h=>{const f=x.get(h.id.toLowerCase());return ot(void 0,He(h.id,f),p).map(u=>({value:u,groupKey:"all",searchText:`${u} ${h.id} ${f?.recommendedModelId??""}`,keywords:[h.owned_by],triggerContent:e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"truncate font-mono text-xs",children:u}),f?.pinnedAvailable?e.jsx(H,{variant:"secondary",className:"text-[9px] h-4 px-1 uppercase",children:f.prefix}):null,p&&e.jsx(Ke,{modelId:u})]}),itemContent:e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"truncate font-mono text-xs",children:u}),f?.unprefixedStatus==="shadowed"?e.jsx(H,{variant:"outline",className:"text-[9px] h-4 px-1",children:r("providerModelSelector.shadowed")}):null,f?.unprefixedStatus==="prefix-only"?e.jsx(H,{variant:"outline",className:"text-[9px] h-4 px-1",children:r("providerModelSelector.prefixOnly")}):null,p&&e.jsx(Ke,{modelId:u})]})}))}),C=!!s&&!D.some(h=>h.value===s)&&!A.some(h=>h.value===s),y=s?{value:s,groupKey:"current",searchText:s,triggerContent:e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"truncate font-mono text-xs",children:s}),e.jsx(H,{variant:"outline",className:"text-[9px] h-4 px-1",children:r("providerModelSelector.current")})]}),itemContent:e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"truncate font-mono text-xs",children:s}),e.jsx(H,{variant:"outline",className:"text-[9px] h-4 px-1",children:r("providerModelSelector.current")})]})}:null,w=D.length+A.length>0;return e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium",children:t}),a&&e.jsx("p",{className:"text-[10px] text-muted-foreground",children:a})]}),e.jsx(Ea,{value:s||void 0,onChange:i,disabled:o,placeholder:r("providerModelSelector.selectModel"),searchPlaceholder:r("searchableSelect.searchModels"),emptyText:r(w?"searchableSelect.noResults":"providerModelSelector.noModelsAvailable"),triggerClassName:"h-9",groups:[...C&&y?[{key:"current",label:e.jsx("span",{className:"text-xs text-muted-foreground",children:r("providerModelSelector.currentValue")})}]:[],{key:"recommended",label:e.jsx("span",{className:"text-xs text-primary",children:r("providerModelSelector.recommended")})},...A.length>0?[{key:"all",label:e.jsx("span",{className:"text-xs text-muted-foreground",children:r("providerModelSelector.allModelsCount",{count:A.length})})}]:[]],options:[...C&&y?[y]:[],...D,...A]}),k?e.jsxs("div",{className:X("rounded-md border px-2.5 py-2 text-[11px]",k.unprefixedStatus==="safe"?"border-border/70 bg-muted/25 text-muted-foreground":"border-amber-300/60 bg-amber-50 text-amber-900 dark:border-amber-500/30 dark:bg-amber-950/25 dark:text-amber-100"),children:[e.jsxs("div",{className:"font-medium",children:[k.pinnedAvailable?r("providerModelSelector.preferredPinnedModel"):r("providerModelSelector.pinnedRouteStatus")," ",e.jsx("code",{children:k.pinnedAvailable?k.recommendedModelId:k.pinnedModelId})]}),e.jsx("p",{className:"mt-1 leading-5",children:k.summary})]}):null,s&&!k&&Gt(s,l)!==s?e.jsx("div",{className:"rounded-md border border-amber-300/60 bg-amber-50 px-2.5 py-2 text-[11px] text-amber-900 dark:border-amber-500/30 dark:bg-amber-950/25 dark:text-amber-100",children:r("providerModelSelector.pinnedModelNotAdvertised",{model:s})}):null]})}function Bt(t,a){const s=i=>a?.models.find(c=>c.modelId.toLowerCase()===i.toLowerCase())?.recommendedModelId??i;return{default:s(t.default),opus:s(t.opus),sonnet:s(t.sonnet),haiku:s(t.haiku)}}function fn({open:t,onClose:a,currentValues:s,onApply:i,onSave:n,isSaving:c,catalog:l,allModels:o,routing:r}){const{t:p}=W(),[m,j]=d.useState(Bt(s,r)),[g,x]=d.useState(""),T=k=>{k?(j(Bt(s,r)),x("")):a()};return e.jsx(ft,{open:t,onOpenChange:T,children:e.jsxs(vt,{className:"sm:max-w-md",children:[e.jsx(jt,{children:e.jsxs(bt,{className:"flex items-center gap-2",children:[e.jsx(De,{className:"w-4 h-4"}),p("customPresetDialog.title")]})}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(Y,{htmlFor:"preset-name",children:p("customPresetDialog.presetNameOptional")}),e.jsx(de,{id:"preset-name",value:g,onChange:k=>x(k.target.value),placeholder:p("customPresetDialog.presetNamePlaceholder"),className:"text-sm"})]}),e.jsx(St,{}),l?.provider==="codex"&&e.jsxs("p",{className:"text-[11px] text-muted-foreground rounded-md border bg-muted/30 px-2.5 py-2",children:[p("customPresetDialog.codexTipPrefix")," ",e.jsx("code",{children:"-medium"}),", ",e.jsx("code",{children:"-high"}),", and"," ",e.jsx("code",{children:"-xhigh"})," ",p("customPresetDialog.codexTipSuffix")]}),e.jsx(je,{label:p("customPresetDialog.defaultModel"),description:p("customPresetDialog.defaultModelDesc"),value:m.default,onChange:k=>j({...m,default:k}),catalog:l,allModels:o,routing:r}),e.jsx(je,{label:p("customPresetDialog.opusModel"),description:p("customPresetDialog.opusModelDesc"),value:m.opus,onChange:k=>j({...m,opus:k}),catalog:l,allModels:o,routing:r}),e.jsx(je,{label:p("customPresetDialog.sonnetModel"),description:p("customPresetDialog.sonnetModelDesc"),value:m.sonnet,onChange:k=>j({...m,sonnet:k}),catalog:l,allModels:o,routing:r}),e.jsx(je,{label:p("customPresetDialog.haikuModel"),description:p("customPresetDialog.haikuModelDesc"),value:m.haiku,onChange:k=>j({...m,haiku:k}),catalog:l,allModels:o,routing:r})]}),e.jsxs(zs,{className:"gap-2 sm:gap-0",children:[e.jsx(K,{variant:"outline",onClick:a,children:p("customPresetDialog.cancel")}),n&&e.jsxs(K,{variant:"secondary",onClick:()=>n(m,g||void 0),disabled:c||!g.trim(),children:[c?e.jsx(ce,{className:"w-4 h-4 mr-1 animate-spin"}):e.jsx(Ct,{className:"w-4 h-4 mr-1"}),p("customPresetDialog.savePreset")]}),e.jsxs(K,{onClick:()=>i(m,g||void 0),children:[e.jsx(Ie,{className:"w-4 h-4 mr-1"}),p("customPresetDialog.applyPreset")]})]})]})})}function ve({label:t,command:a}){return e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-muted-foreground",children:t}),e.jsxs("div",{className:"mt-1 flex gap-2",children:[e.jsx("code",{className:"flex-1 px-2 py-1.5 bg-muted rounded text-xs font-mono truncate",children:a}),e.jsx(as,{value:a,size:"icon",className:"h-6 w-6"})]})]})}function vn({provider:t,displayName:a,baseProvider:s,defaultTarget:i,data:n,authStatus:c,supportsModelConfig:l=!1}){const{t:o}=W(),r=i||"claude",p=r==="droid",m=t==="codex",j=s||c.provider||t,g=Gs(j),x=r==="claude"?`ccs ${t}`:`ccs ${t} --target claude`,T=`${x} --config`,k=`${x} --auth --add`,D=`${x} --accounts`;return e.jsx(Nt,{className:"h-full",children:e.jsxs("div",{className:"p-4 space-y-6",children:[e.jsxs("div",{children:[e.jsxs("h3",{className:"text-sm font-medium flex items-center gap-2 mb-3",children:[e.jsx(ls,{className:"w-4 h-4"}),"Provider Information"]}),e.jsxs("div",{className:"space-y-3 bg-card rounded-lg border p-4 shadow-sm",children:[e.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-2 text-sm items-center",children:[e.jsx("span",{className:"font-medium text-muted-foreground",children:o("providerEditor.provider")}),e.jsx("span",{className:"font-mono",children:a})]}),n&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-2 text-sm items-center",children:[e.jsx("span",{className:"font-medium text-muted-foreground",children:o("providerEditor.filePath")}),e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx("code",{className:"bg-muted px-1.5 py-0.5 rounded text-xs break-all",children:n.path}),e.jsx(as,{value:n.path,size:"icon",className:"h-5 w-5"})]})]}),e.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-2 text-sm items-center",children:[e.jsx("span",{className:"font-medium text-muted-foreground",children:o("providerEditor.lastModified")}),e.jsx("span",{className:"text-xs",children:new Date(n.mtime).toLocaleString()})]})]}),e.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-2 text-sm items-center",children:[e.jsx("span",{className:"font-medium text-muted-foreground",children:o("providerEditor.status")}),c.authenticated?e.jsxs(H,{variant:"outline",className:"w-fit text-green-600 border-green-200 bg-green-50",children:[e.jsx(ka,{className:"w-3 h-3 mr-1"}),"Authenticated"]}):e.jsx(H,{variant:"outline",className:"w-fit text-muted-foreground",children:"Not connected"})]}),e.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-2 text-sm items-center",children:[e.jsx("span",{className:"font-medium text-muted-foreground",children:o("providerEditor.defaultTarget")}),e.jsx("span",{className:"font-mono",children:r})]}),g&&e.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-2 text-sm items-start",children:[e.jsx("span",{className:"font-medium text-muted-foreground",children:o("providerConfig.trackLabel")}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("span",{className:"font-mono",children:o(g.labelKey)}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[o(g.hintKey),Bs(j)?` ${o("providerConfig.plusTrackNote")}`:""]})]})]})]})]}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-medium mb-3",children:o("providerEditor.quickUsage")}),e.jsxs("div",{className:"space-y-3 bg-card rounded-lg border p-4 shadow-sm",children:[e.jsx(ve,{label:"Run with prompt",command:`ccs ${t} "your prompt"`}),m&&e.jsxs(e.Fragment,{children:[e.jsx(ve,{label:"Run on native Codex (shortcut)",command:'ccsxp "your prompt"'}),e.jsx(ve,{label:"Run on native Codex (--target)",command:`ccs ${t} --target codex "your prompt"`})]}),e.jsx(ve,{label:p?"Droid alias (explicit)":"Run on Droid",command:`ccs-droid ${t} "your prompt"`}),e.jsx(ve,{label:p?"Override to Claude":"Run on Droid (--target)",command:`ccs ${t} --target ${p?"claude":"droid"} "your prompt"`}),l&&e.jsx(ve,{label:r==="claude"?"Change model":"Change model (Claude target)",command:T}),e.jsx(ve,{label:r==="claude"?"Add account":"Add account (Claude target)",command:k}),e.jsx(ve,{label:r==="claude"?"List accounts":"List accounts (Claude target)",command:D}),r!=="claude"&&e.jsx("p",{className:"text-xs text-muted-foreground",children:"Account and model-management flags stay on Claude target. Codex and Droid runtime launches reject those CLIProxy management commands."})]})]})]})})}function jn(t){const a=t.replace(/\\/g,"/"),i=a.lastIndexOf("/cliproxy/providers/");return i!==-1?a.slice(i+1):a.replace(/^.*\//,"")}function bn({displayName:t,logoProvider:a,provider:s,data:i,isLoading:n,hasChanges:c,isRawJsonValid:l,isSaving:o,isRemoteMode:r,port:p,onRefetch:m,onSave:j}){const{t:g}=W();return e.jsxs("div",{className:"px-6 py-4 border-b bg-background flex items-center justify-between shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(yt,{provider:a||s,size:"lg"}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h2",{className:"text-lg font-semibold",children:t}),r&&e.jsxs(H,{variant:"secondary",className:"text-xs gap-1 bg-blue-100 text-blue-700 dark:bg-blue-900/30 dark:text-blue-400",children:[e.jsx(ds,{className:"w-3 h-3"}),"Remote"]}),p&&e.jsxs(H,{variant:"outline",className:"text-xs gap-1 font-mono",children:[e.jsx(wa,{className:"w-3 h-3"}),":",p]}),!r&&i?.path&&e.jsx(H,{variant:"outline",className:"text-xs",children:jn(i.path)})]}),r?e.jsx("p",{className:"text-xs text-blue-600 dark:text-blue-400 mt-0.5",children:"Traffic auto-routed to remote server"}):i&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:[g("providerEditor.lastModified"),": ",new Date(i.mtime).toLocaleString()]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(K,{variant:"ghost",size:"sm",onClick:m,disabled:n,children:e.jsx(wt,{className:`w-4 h-4 ${n?"animate-spin":""}`})}),e.jsx(K,{size:"sm",onClick:j,disabled:o||!c||!l,children:o?e.jsxs(e.Fragment,{children:[e.jsx(ce,{className:"w-4 h-4 mr-1 animate-spin"}),"Saving..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Ca,{className:"w-4 h-4 mr-1"}),"Save"]})})]})]})}function Nn({models:t,provider:a,enabled:s,onToggle:i,disabled:n,className:c}){const{t:l}=W();if(t.length===0)return null;const o=t.some(m=>Lt(m.id)),r=t.some(m=>!Lt(m.id));let p="Compatible mappings stay on standard context unless you turn this on.";return o&&r?p="Gemini-compatible mappings can use 1M automatically. Claude mappings stay plain unless you turn this on.":o&&(p="Gemini-compatible mappings can use 1M by default. Turn this off to keep standard context."),e.jsxs("div",{className:X("rounded-lg border p-3 space-y-2",s?"border-primary/50 bg-primary/5":"border-border bg-muted/30",c),children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ie,{className:X("w-4 h-4",s?"text-primary":"text-muted-foreground")}),e.jsx("span",{className:"text-sm font-medium",children:l("extendedContext.extendedContext")}),e.jsx(H,{variant:s?"default":"secondary",className:"text-[10px] h-5 px-1.5",children:"1M tokens"})]}),e.jsx(ns,{checked:s,onCheckedChange:i,disabled:n})]}),e.jsxs("div",{className:"flex items-start gap-2 text-xs text-muted-foreground",children:[e.jsx(ls,{className:"w-3.5 h-3.5 mt-0.5 shrink-0"}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs("p",{children:["Applies the explicit ",e.jsx("code",{children:"[1m]"})," long-context suffix to compatible saved mappings."]}),e.jsx("p",{className:"text-[10px]",children:p}),e.jsxs("p",{className:"text-amber-600 dark:text-amber-500",children:["CCS only saves ",e.jsx("code",{children:"[1m]"}),". Provider pricing and entitlement are separate, and some accounts can still return 429 extra-usage errors for long-context requests."]})]})]})]})}function yn(t,a){const s=t.presetMapping||{default:t.id,opus:t.id,sonnet:t.id,haiku:t.id};return{ANTHROPIC_MODEL:a(s.default),ANTHROPIC_DEFAULT_OPUS_MODEL:a(s.opus),ANTHROPIC_DEFAULT_SONNET_MODEL:a(s.sonnet),ANTHROPIC_DEFAULT_HAIKU_MODEL:a(s.haiku)}}function kn({catalog:t,savedPresets:a,currentModel:s,opusModel:i,sonnetModel:n,haikuModel:c,providerModels:l,routing:o,provider:r,extendedContextEnabled:p,onExtendedContextToggle:m,onApplyPreset:j,onUpdateEnvValue:g,onOpenCustomPreset:x,onDeletePreset:T,isDeletePending:k}){const{t:D}=W(),A=(o?.models??[]).some(u=>u.pinnedAvailable),C=d.useMemo(()=>new Map((o?.models??[]).map(u=>[u.modelId.toLowerCase(),u])),[o]),y=u=>C.get(u.toLowerCase())?.recommendedModelId??u,w=d.useMemo(()=>{if(!t)return[];const u=[s,i,n,c].filter(N=>!!N).map(N=>Vs(N));return[...new Set(u)].map(N=>fs(t.provider,N,t)).filter(N=>!!N?.extendedContext)},[t,s,i,n,c]),h=d.useMemo(()=>Pt(t,l),[t,l]),f=d.useMemo(()=>{const u=h.filter(N=>N.presetMapping);return u.length===0?[]:u.some(N=>N.tier==="paid")?[{key:"free",label:"Free Tier",description:"Available on free or paid plans",badgeClassName:"text-[10px] bg-green-100 text-green-700 border-green-200",iconClassName:"text-green-600",models:u.filter(N=>N.tier!=="paid")},{key:"paid",label:"Paid Tier",description:"Requires paid access",badgeClassName:"text-[10px] bg-amber-100 text-amber-700 border-amber-200",iconClassName:"text-amber-700",models:u.filter(N=>N.tier==="paid")}].filter(N=>N.models.length>0):[{key:"default",models:u.slice(0,4)}]},[h]),I=f.length>0||a.length>0;return e.jsxs(e.Fragment,{children:[I&&e.jsxs("div",{children:[e.jsxs("h3",{className:"text-sm font-medium mb-2 flex items-center gap-2",children:[e.jsx(De,{className:"w-4 h-4"}),"Presets"]}),e.jsx("p",{className:"text-xs text-muted-foreground mb-3",children:D("providerEditor.presets")}),e.jsxs("div",{className:"space-y-4",children:[f.map(u=>e.jsxs("div",{children:["label"in u&&u.label&&e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(H,{variant:"outline",className:u.badgeClassName,children:u.label}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:u.description})]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:u.models.map(E=>e.jsxs(K,{variant:"outline",size:"sm",className:"text-xs h-7 gap-1",onClick:()=>j(yn(E,y)),children:[e.jsx(Ie,{className:`w-3 h-3 ${"iconClassName"in u?u.iconClassName:""}`}),E.name]},E.id))})]},u.key)),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[a.map(u=>e.jsxs("div",{className:"group relative",children:[e.jsxs(K,{variant:"secondary",size:"sm",className:"text-xs h-7 gap-1 pr-6",onClick:()=>{j({ANTHROPIC_MODEL:y(u.default),ANTHROPIC_DEFAULT_OPUS_MODEL:y(u.opus),ANTHROPIC_DEFAULT_SONNET_MODEL:y(u.sonnet),ANTHROPIC_DEFAULT_HAIKU_MODEL:y(u.haiku)})},children:[e.jsx(Ct,{className:"w-3 h-3 fill-current"}),u.name]}),e.jsx(K,{variant:"ghost",size:"icon",className:"absolute right-0 top-0 h-7 w-5 opacity-0 group-hover:opacity-100 hover:text-destructive",onClick:E=>{E.stopPropagation(),T(u.name)},disabled:k,children:e.jsx(At,{className:"w-3 h-3"})})]},u.name)),e.jsxs(K,{variant:"outline",size:"sm",className:"text-xs h-7 gap-1 border-primary/50 text-primary hover:bg-primary/10 hover:border-primary",onClick:x,children:[e.jsx(cs,{className:"w-3 h-3"}),"Custom"]})]})]})]}),e.jsx(St,{}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-medium mb-2",children:D("providerEditor.modelMapping")}),e.jsx("p",{className:"text-xs text-muted-foreground mb-4",children:"Configure which models to use for each tier"}),o?e.jsx("p",{className:"text-[11px] text-muted-foreground mb-3 rounded-md border bg-muted/30 px-2.5 py-2",children:A?e.jsxs(e.Fragment,{children:["Preferred pinned model names use the ",e.jsxs("code",{children:[o.prefix,"/"]})," prefix. Unprefixed names can still resolve to a different backend when providers overlap."]}):e.jsxs(e.Fragment,{children:["Managed pinning for ",e.jsxs("code",{children:[o.prefix,"/"]})," is not currently advertised by the proxy. Unprefixed names may still be ambiguous until prefix repair completes."]})}):null,r==="codex"&&e.jsxs("p",{className:"text-[11px] text-muted-foreground mb-3 rounded-md border bg-muted/30 px-2.5 py-2",children:["Codex tip: suffixes ",e.jsx("code",{children:"-medium"}),", ",e.jsx("code",{children:"-high"}),", and ",e.jsx("code",{children:"-xhigh"})," ","pin reasoning effort. Select a suffixed model to pin effort; unsuffixed models use Thinking settings."]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(je,{label:"Default Model",description:"Used when no specific tier is requested",value:s,onChange:u=>g("ANTHROPIC_MODEL",u),catalog:t,allModels:l,routing:o}),w.length>0&&m&&e.jsx(Nn,{models:w,provider:r,enabled:p??!1,onToggle:m}),e.jsx(je,{label:"Opus (Most capable)",description:"For complex reasoning tasks",value:i,onChange:u=>g("ANTHROPIC_DEFAULT_OPUS_MODEL",u),catalog:t,allModels:l,routing:o}),e.jsx(je,{label:"Sonnet (Balanced)",description:"Balance of speed and capability",value:n,onChange:u=>g("ANTHROPIC_DEFAULT_SONNET_MODEL",u),catalog:t,allModels:l,routing:o}),e.jsx(je,{label:"Haiku (Fast)",description:"Quick responses for simple tasks",value:c,onChange:u=>g("ANTHROPIC_DEFAULT_HAIKU_MODEL",u),catalog:t,allModels:l,routing:o})]})]})]})}function wn(t,a,s){return t?e.jsx(lt,{children:e.jsxs(dt,{children:[e.jsx(ct,{asChild:!0,children:e.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[e.jsx(Sa,{className:"w-3 h-3","aria-hidden":"true"}),e.jsx("span",{className:X("font-mono max-w-[180px] truncate",a&&gt),title:t,children:t})]})}),e.jsx(ut,{side:"bottom",children:e.jsx("p",{className:"text-xs",children:s("providerEditor.gcpProjectIdReadonly")})})]})}):e.jsx(lt,{children:e.jsxs(dt,{children:[e.jsx(ct,{asChild:!0,children:e.jsxs("div",{className:"flex items-center gap-1 text-xs text-amber-600 dark:text-amber-500",children:[e.jsx(Je,{className:"w-3 h-3","aria-label":"Warning"}),e.jsx("span",{children:s("providerEditor.projectIdNA")})]})}),e.jsx(ut,{side:"bottom",className:"max-w-[250px]",children:e.jsxs("div",{className:"text-xs space-y-1",children:[e.jsx("p",{className:"font-medium text-amber-600",children:s("providerEditor.missingProjectId")}),e.jsx("p",{children:s("providerEditor.missingProjectIdHint")})]})})]})})}function Cn({account:t,onSetDefault:a,onRemove:s,onPauseToggle:i,isRemoving:n,isPausingAccount:c,privacyMode:l,showQuota:o,selectable:r,selected:p,onSelectChange:m}){const{t:j}=W(),g=t.provider.toLowerCase(),{data:x}=$s(o),{data:T,isLoading:k}=Ws(g,t.id,o),D=Qs(x,t)?.lastUsedAt,A=r||i?e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[r&&e.jsx("button",{type:"button",onClick:()=>m?.(!p),className:X("flex items-center justify-center w-5 h-5 rounded border-2 transition-colors shrink-0",p?"bg-primary border-primary text-primary-foreground":"border-muted-foreground/30 hover:border-primary/50"),"aria-label":p?"Deselect account":"Select account",children:p&&e.jsx(we,{className:"w-3 h-3"})}),i&&e.jsx(lt,{children:e.jsxs(dt,{children:[e.jsx(ct,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0",onClick:()=>i(!t.paused),disabled:c,children:c?e.jsx(ce,{className:"w-4 h-4 animate-spin"}):t.paused?e.jsx(us,{className:"w-4 h-4 text-emerald-500"}):e.jsx(ms,{className:"w-4 h-4 text-muted-foreground hover:text-foreground"})})}),e.jsx(ut,{side:"top",children:t.paused?"Resume account":"Pause account"})]})})]}):void 0,C=e.jsxs(Js,{children:[e.jsx(Xs,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0",children:e.jsx(Aa,{className:"w-4 h-4"})})}),e.jsxs(Ys,{align:"end",children:[!t.isDefault&&e.jsxs(Ot,{onClick:a,children:[e.jsx(Ct,{className:"w-4 h-4 mr-2"}),"Set as default"]}),e.jsxs(Ot,{className:"text-destructive focus:text-destructive",onClick:s,disabled:n,children:[e.jsx(ps,{className:"w-4 h-4 mr-2"}),n?"Removing...":"Remove account"]})]})]});return e.jsx("div",{className:X("rounded-lg border p-3 transition-colors overflow-hidden",t.isDefault?"border-primary/30 bg-primary/5":"border-border hover:bg-muted/30",t.paused&&"opacity-75",p&&"ring-2 ring-primary/50 bg-primary/5"),children:e.jsx(Zs,{mode:"detailed",provider:t.provider,accountId:t.id,email:t.email,displayEmail:t.email||t.id,tokenFile:t.tokenFile,tier:t.tier,isDefault:t.isDefault,paused:t.paused,privacyMode:l,showQuota:o,quota:T,quotaLoading:k,runtimeLastUsed:D,beforeIdentity:A,headerEnd:C,bodySlot:t.provider==="agy"?wn(t.projectId,l,j):null,quotaInsetClassName:"pl-11"})})}function An({selectedCount:t,onPauseSelected:a,onResumeSelected:s,onClearSelection:i,isPausing:n,isResuming:c}){if(t<1)return null;const l=n||c;return e.jsxs("div",{className:"flex items-center gap-3 p-2 bg-muted/50 rounded-lg border mt-2",children:[e.jsxs("span",{className:"text-sm text-muted-foreground",children:[t," selected"]}),e.jsx(K,{variant:"ghost",size:"sm",className:"text-xs h-6 px-2",onClick:i,disabled:l,children:"Clear"}),e.jsxs("div",{className:"flex gap-2 ml-auto",children:[e.jsxs(K,{size:"sm",variant:"outline",className:"h-7 text-xs gap-1",onClick:a,disabled:l,children:[n?e.jsx(ce,{className:"w-3 h-3 animate-spin"}):e.jsx(ms,{className:"w-3 h-3"}),"Pause Selected"]}),e.jsxs(K,{size:"sm",variant:"outline",className:"h-7 text-xs gap-1",onClick:s,disabled:l,children:[c?e.jsx(ce,{className:"w-3 h-3 animate-spin"}):e.jsx(us,{className:"w-3 h-3"}),"Resume Selected"]})]})]})}function Sn({accounts:t,onAddAccount:a,onSetDefault:s,onRemoveAccount:i,onPauseToggle:n,onSoloMode:c,onBulkPause:l,onBulkResume:o,isRemovingAccount:r,isPausingAccount:p,isSoloingAccount:m,isBulkPausing:j,isBulkResuming:g,privacyMode:x,showQuota:T,isKiro:k,kiroNoIncognito:D,onKiroNoIncognitoChange:A,kiroSettingsLoading:C}){const{t:y}=W(),[w,h]=d.useState(new Set),f=d.useMemo(()=>new Set(t.map(S=>S.id)),[t]),I=d.useMemo(()=>new Set([...w].filter(S=>f.has(S))),[w,f]),u=!!(l&&o),E=I.size,N=t.length>0&&I.size===t.length,z=I.size>0&&I.size<t.length,P=d.useCallback(S=>{h(R=>{const b=new Set(R);return b.has(S)?b.delete(S):b.add(S),b})},[]),L=d.useCallback(()=>{h(new Set(t.map(S=>S.id)))},[t]),_=d.useCallback(()=>{h(new Set)},[]),G=d.useCallback(()=>{N?_():L()},[N,L,_]),V=d.useCallback(()=>{l&&I.size>0&&(l(Array.from(I)),h(new Set))},[l,I]),q=d.useCallback(()=>{o&&I.size>0&&(o(Array.from(I)),h(new Set))},[o,I]);return e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsxs("h3",{className:"text-sm font-medium flex items-center gap-2",children:[u&&t.length>0&&e.jsx(We,{checked:N,onCheckedChange:G,"aria-label":"Select all accounts",className:z?"data-[state=checked]:bg-primary/50":"",...z?{"data-state":"indeterminate"}:{}}),e.jsx(Pe,{className:"w-4 h-4"}),"Accounts",t.length>0&&e.jsx(H,{variant:"secondary",className:"text-xs",children:t.length})]}),e.jsxs(K,{variant:"default",size:"sm",className:"h-7 text-xs gap-1",onClick:a,children:[e.jsx(cs,{className:"w-3 h-3"}),"Add"]})]}),u&&E>0&&e.jsx(An,{selectedCount:E,onPauseSelected:V,onResumeSelected:q,onClearSelection:_,isPausing:!!j,isResuming:!!g}),t.length>0?e.jsx("div",{className:"space-y-2",children:t.map(S=>e.jsx(Cn,{account:S,onSetDefault:()=>s(S.id),onRemove:()=>i(S.id),onPauseToggle:n?R=>n(S.id,R):void 0,onSoloMode:c?()=>c(S.id):void 0,isRemoving:r,isPausingAccount:p,isSoloingAccount:m,privacyMode:x,showQuota:T,selectable:u,selected:I.has(S.id),onSelectChange:()=>P(S.id)},S.id))}):e.jsxs("div",{className:"py-6 text-center text-muted-foreground bg-muted/30 rounded-lg border border-dashed",children:[e.jsx(Pe,{className:"w-8 h-8 mx-auto mb-2 opacity-50"}),e.jsx("p",{className:"text-sm",children:y("providerEditor.noAccountsConnected")}),e.jsx("p",{className:"text-xs opacity-70",children:y("providerEditor.addAccountToStart")})]}),k&&A&&e.jsx("div",{className:"mt-3 pt-3 border-t border-dashed",children:e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(ds,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:y("providerEditor.useIncognito")})]}),e.jsx(ns,{checked:!D,onCheckedChange:S=>A(!S),disabled:C,className:"scale-90"})]})})]})}function Mn({provider:t,catalog:a,savedPresets:s,currentModel:i,opusModel:n,sonnetModel:c,haikuModel:l,providerModels:o,routing:r,extendedContextEnabled:p,onExtendedContextToggle:m,onApplyPreset:j,onUpdateEnvValue:g,onOpenCustomPreset:x,onDeletePreset:T,isDeletePending:k,accounts:D,onAddAccount:A,onSetDefault:C,onRemoveAccount:y,onPauseToggle:w,onSoloMode:h,onBulkPause:f,onBulkResume:I,isRemovingAccount:u,isPausingAccount:E,isSoloingAccount:N,isBulkPausing:z,isBulkResuming:P,privacyMode:L,isRemoteMode:_}){const G=t.toLowerCase(),V=(ea.includes(G)||["anthropic","antigravity","gemini-cli","copilot","github-copilot"].includes(G))&&!_,q=t==="kiro",[S,R]=d.useState(!0),[b,Q]=d.useState(!0),[te,ne]=d.useState(!1),U=d.useCallback(async()=>{if(q)try{Q(!0);const Z=(await Ve.config.get()).cliproxy;R(Z?.kiro_no_incognito??!0)}catch{R(!0)}finally{Q(!1)}},[q]),ae=d.useCallback(async $=>{R($),ne(!0);try{const Z=await Ve.config.get(),ie=Z.cliproxy??{};await Ve.config.update({...Z,cliproxy:{...ie,kiro_no_incognito:$}})}catch{R(!$)}finally{ne(!1)}},[]);return d.useEffect(()=>{U()},[U]),e.jsx(Nt,{className:"flex-1",children:e.jsxs("div",{className:"p-4 space-y-6",children:[e.jsx(kn,{catalog:a,savedPresets:s,currentModel:i,opusModel:n,sonnetModel:c,haikuModel:l,providerModels:o,routing:r,provider:t,extendedContextEnabled:p,onExtendedContextToggle:m,onApplyPreset:j,onUpdateEnvValue:g,onOpenCustomPreset:x,onDeletePreset:T,isDeletePending:k}),e.jsx(St,{}),e.jsx(Sn,{accounts:D,onAddAccount:A,onSetDefault:C,onRemoveAccount:y,onPauseToggle:w,onSoloMode:h,onBulkPause:f,onBulkResume:I,isRemovingAccount:u,isPausingAccount:E,isSoloingAccount:N,isBulkPausing:z,isBulkResuming:P,privacyMode:L,showQuota:V,isKiro:q,kiroNoIncognito:S,onKiroNoIncognitoChange:ae,kiroSettingsLoading:b||te})]})})}function Vt({provider:t,displayName:a,authStatus:s,catalog:i,routing:n,logoProvider:c,baseProvider:l,isRemoteMode:o,port:r,defaultTarget:p,topNotice:m,onAddAccount:j,onSetDefault:g,onRemoveAccount:x,onPauseToggle:T,onSoloMode:k,onBulkPause:D,onBulkResume:A,isRemovingAccount:C,isPausingAccount:y,isSoloingAccount:w,isBulkPausing:h,isBulkResuming:f}){const[I,u]=d.useState(!1),{privacyMode:E}=es(),{t:N}=W(),{data:z}=ta(),{data:P}=sa(t),L=aa(),_=na(),G=l||t,V=G.toLowerCase()==="agy",q=d.useMemo(()=>{const F=P?.presets||[];return V?F.filter(ee=>!ue(ee.default)&&!ue(ee.opus)&&!ue(ee.sonnet)&&!ue(ee.haiku)):F},[V,P?.presets]),S=d.useMemo(()=>{if(!z?.models)return[];const ee={gemini:["google"],agy:["antigravity"],codex:["openai"],cursor:["cursor"],gitlab:["gitlab","duo"],codebuddy:["codebuddy"],qwen:["alibaba","qwen"],iflow:["iflow"],kilo:["kilo"],kiro:["kiro","aws"],ghcp:["github","copilot"],kimi:["kimi","moonshot"]}[G.toLowerCase()]||[G.toLowerCase()];return z.models.filter(oe=>ee.some(ge=>oe.owned_by.toLowerCase().includes(ge))?V?!ue(oe.id):!0:!1)},[V,z,G]),R=(l||t).toLowerCase(),{data:b,isLoading:Q,refetch:te,rawJsonContent:ne,rawJsonEdits:U,isRawJsonValid:ae,hasChanges:$,currentModel:Z,opusModel:ie,sonnetModel:v,haikuModel:O,extendedContextEnabled:be,toggleExtendedContext:Ee,handleRawJsonChange:Te,updateEnvValue:Ye,updateEnvValues:Re,saveMutation:he,conflictDialog:Ne,handleConflictResolve:Me,missingRequiredFields:Ze}=mn(t,i),et=d.useMemo(()=>(s.accounts||[]).map(F=>({...F,provider:F.provider||l||t})),[s.accounts,l,t]),{data:re}=$t({queryKey:["auth-tokens-raw"],queryFn:async()=>{const F=await fetch("/api/settings/auth/tokens/raw");return F.ok?F.json():{apiKey:{value:"ccs-internal-managed"}}},staleTime:6e4}),Le=re?.apiKey?.value??"ccs-internal-managed",Oe=F=>{if(V&&[F.ANTHROPIC_MODEL,F.ANTHROPIC_DEFAULT_OPUS_MODEL,F.ANTHROPIC_DEFAULT_SONNET_MODEL,F.ANTHROPIC_DEFAULT_HAIKU_MODEL].some(oe=>typeof oe=="string"&&ue(oe))){B.error(N("providerEditor.agyDenylist"));return}Re({ANTHROPIC_BASE_URL:`http://127.0.0.1:${r??mt}/api/provider/${R}`,ANTHROPIC_AUTH_TOKEN:Le,...F}),B.success(`Applied "${F.ANTHROPIC_MODEL?.split("/").pop()||"preset"}" preset`)},_e=(F,ee)=>{if(V&&[F.default,F.opus,F.sonnet,F.haiku].some(ge=>ue(ge))){B.error(N("providerEditor.agyDenylist"));return}Re({ANTHROPIC_BASE_URL:`http://127.0.0.1:${r??mt}/api/provider/${R}`,ANTHROPIC_AUTH_TOKEN:Le,ANTHROPIC_MODEL:F.default,ANTHROPIC_DEFAULT_OPUS_MODEL:F.opus,ANTHROPIC_DEFAULT_SONNET_MODEL:F.sonnet,ANTHROPIC_DEFAULT_HAIKU_MODEL:F.haiku}),B.success(`Applied ${ee?`"${ee}"`:"custom"} preset`),u(!1)},Fe=(F,ee)=>{if(!ee){B.error(me.t("commonToast.enterPresetName"));return}if(V&&[F.default,F.opus,F.sonnet,F.haiku].some(oe=>ue(oe))){B.error(N("providerEditor.agyDenylist"));return}L.mutate({profile:t,data:{name:ee,...F}}),u(!1)};return e.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[e.jsx(bn,{provider:t,displayName:a,logoProvider:c,data:b,isLoading:Q,hasChanges:$,isRawJsonValid:ae,isSaving:he.isPending,isRemoteMode:o,port:r,onRefetch:te,onSave:()=>he.mutate()}),m?e.jsx("div",{className:"border-b bg-muted/10 px-4 py-3",children:m}):null,Q?e.jsxs("div",{className:"flex-1 flex items-center justify-center",children:[e.jsx(ce,{className:"w-8 h-8 animate-spin text-muted-foreground"}),e.jsx("span",{className:"ml-3 text-muted-foreground",children:N("providerEditor.loadingSettings")})]}):e.jsxs("div",{className:"min-h-0 flex-1 grid grid-cols-[40%_60%] divide-x overflow-hidden",children:[e.jsx("div",{className:"flex min-h-0 min-w-0 flex-col overflow-hidden bg-muted/5",children:e.jsxs(ia,{defaultValue:"config",className:"h-full flex flex-col",children:[e.jsx("div",{className:"px-4 pt-4 shrink-0",children:e.jsxs(ra,{className:"w-full",children:[e.jsx(_t,{value:"config",className:"flex-1",children:"Model Config"}),e.jsx(_t,{value:"info",className:"flex-1",children:"Info & Usage"})]})}),e.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[e.jsx(Ft,{value:"config",className:"flex-1 mt-0 border-0 p-0 data-[state=inactive]:hidden flex flex-col overflow-hidden",children:e.jsx(Mn,{provider:t,catalog:i,savedPresets:q,currentModel:Z,opusModel:ie,sonnetModel:v,haikuModel:O,providerModels:S,routing:n,extendedContextEnabled:be,onExtendedContextToggle:Ee,onApplyPreset:Oe,onUpdateEnvValue:Ye,onOpenCustomPreset:()=>u(!0),onDeletePreset:F=>_.mutate({profile:t,name:F}),isDeletePending:_.isPending,accounts:et,onAddAccount:j,onSetDefault:g,onRemoveAccount:x,onPauseToggle:T,onSoloMode:k,onBulkPause:D,onBulkResume:A,isRemovingAccount:C,isPausingAccount:y,isSoloingAccount:w,isBulkPausing:h,isBulkResuming:f,privacyMode:E,isRemoteMode:o})}),e.jsx(Ft,{value:"info",className:"h-full mt-0 border-0 p-0 data-[state=inactive]:hidden",children:e.jsx(vn,{provider:t,displayName:a,baseProvider:l,defaultTarget:p,data:b,authStatus:s,supportsModelConfig:!!i})})]})]})}),e.jsxs("div",{className:"flex min-h-0 min-w-0 flex-col overflow-hidden",children:[e.jsxs("div",{className:"px-6 py-2 bg-muted/30 border-b flex items-center gap-2 shrink-0 h-[45px]",children:[e.jsx(Ma,{className:"w-4 h-4 text-muted-foreground"}),e.jsxs("span",{className:"text-sm font-medium text-muted-foreground",children:[N("rawEditorSection.rawConfig")," (JSON)"]})]}),e.jsx(oa,{rawJsonContent:ne,isRawJsonValid:ae,rawJsonEdits:U,onRawJsonChange:Te,profileEnv:b?.settings?.env,missingRequiredFields:Ze})]})]}),e.jsx(Ia,{open:Ne,title:"File Modified Externally",description:"This settings file was modified by another process. Overwrite with your changes or discard?",confirmText:"Overwrite",variant:"destructive",onConfirm:()=>Me(!0),onCancel:()=>Me(!1)}),e.jsx(fn,{open:I,onClose:()=>u(!1),currentValues:{default:Z||"",opus:ie||"",sonnet:v||"",haiku:O||""},onApply:_e,onSave:Fe,isSaving:L.isPending,catalog:i,allModels:S,routing:n})]})}function Pn({status:t,isSelected:a,onSelect:s}){const{t:i}=W(),n=t.accounts?.length||0;return e.jsxs("button",{className:X("w-full flex items-center gap-3 px-3 py-2.5 rounded-lg transition-colors cursor-pointer text-left",a?"bg-primary/10 border border-primary/20":"hover:bg-muted border border-transparent"),onClick:s,children:[e.jsx(yt,{provider:t.provider,size:"md"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-medium text-sm truncate",children:t.displayName}),n>0&&e.jsx(H,{variant:"secondary",className:"text-[10px] h-4 px-1",children:n})]}),e.jsx("div",{className:"flex items-center gap-1.5 mt-0.5",children:t.authenticated?e.jsxs(e.Fragment,{children:[e.jsx(we,{className:"w-3 h-3 text-green-600"}),e.jsx("span",{className:"text-xs text-green-600",children:i("cliproxyPage.connected")})]}):e.jsxs(e.Fragment,{children:[e.jsx(At,{className:"w-3 h-3 text-muted-foreground"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:i("cliproxyPage.notConnected")})]})})]})]})}function Dn({variant:t,parentAuth:a,isSelected:s,onSelect:i,onDelete:n,isDeleting:c}){const{t:l}=W(),o=()=>{i()};return e.jsxs("div",{role:"button",tabIndex:0,className:X("group w-full flex items-center gap-3 px-3 py-2 rounded-lg transition-colors cursor-pointer text-left pl-6",s?"bg-primary/10 border border-primary/20":"hover:bg-muted border border-transparent"),onClick:o,onKeyDown:r=>{(r.key==="Enter"||r.key===" ")&&(r.preventDefault(),o())},children:[e.jsxs("div",{className:"relative",children:[e.jsx(yt,{provider:t.provider,size:"sm"}),e.jsx(xs,{className:"w-2.5 h-2.5 absolute -bottom-0.5 -right-0.5 text-muted-foreground"})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-medium text-sm truncate",children:t.name}),e.jsx(H,{variant:"outline",className:"text-[9px] h-4 px-1",children:l("cliproxyPage.variant")}),e.jsx(H,{variant:"outline",className:"text-[9px] h-4 px-1 uppercase",children:t.target||"claude"})]}),e.jsx("div",{className:"flex items-center gap-1.5 mt-0.5",children:a?.authenticated?e.jsxs(e.Fragment,{children:[e.jsx(we,{className:"w-3 h-3 text-green-600"}),e.jsx("span",{className:"text-xs text-muted-foreground truncate",children:l("cliproxyPage.viaProvider",{provider:t.provider})})]}):e.jsxs(e.Fragment,{children:[e.jsx(At,{className:"w-3 h-3 text-muted-foreground"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:l("cliproxyPage.parentNotConnected")})]})})]}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-6 w-6 opacity-0 group-hover:opacity-100 hover:text-destructive",onClick:r=>{r.stopPropagation(),n()},disabled:c,children:e.jsx(ps,{className:"w-3 h-3"})})]})}function In({onSetup:t}){const{t:a}=W();return e.jsx("div",{className:"flex-1 flex items-center justify-center bg-muted/20",children:e.jsxs("div",{className:"text-center max-w-md px-8",children:[e.jsx("div",{className:"w-16 h-16 rounded-full bg-muted flex items-center justify-center mx-auto mb-6",children:e.jsx(Ie,{className:"w-8 h-8 text-muted-foreground"})}),e.jsx("h2",{className:"text-xl font-semibold mb-2",children:a("cliproxyPage.emptyTitle")}),e.jsx("p",{className:"text-muted-foreground mb-4",children:a("cliproxyPage.emptyDesc")}),e.jsxs("p",{className:"text-xs text-muted-foreground mb-6",children:[a("cliproxyPage.emptyControlPanelPrefix")," ",e.jsx("a",{href:"/cliproxy/control-panel",className:"text-primary hover:underline",children:a("cliproxyPage.controlPanel")}),"."]}),e.jsxs(K,{onClick:t,className:"gap-2",children:[e.jsx(De,{className:"w-4 h-4"}),a("cliproxyPage.quickSetup")]})]})})}function Qn(){const{t}=W(),a=ht(),{data:s,isLoading:i}=Yt(),{data:n,isFetching:c}=la(),{data:l}=Zt(),{data:o}=da(),r=ca(),p=ua(),m=ma(),j=pa(),g=xa(),x=ha(),T=ga(),k=fa(),[D,A]=d.useState(()=>{if(typeof window<"u"){const O=new URLSearchParams(window.location.search).get("provider")?.trim().toLowerCase();return O&&Qe(O)?O:localStorage.getItem("cliproxy-selected-provider")}return null}),[C,y]=d.useState(null),[w,h]=d.useState(!1),[f,I]=d.useState(()=>{if(typeof window>"u")return null;const v=new URLSearchParams(window.location.search),O=v.get("provider")?.trim().toLowerCase();return v.get("action")!=="auth"||!O||!Qe(O)?null:{provider:O,displayName:va(O),isFirstAccount:!1}}),u=d.useMemo(()=>s?.authStatus||[],[s?.authStatus]),E=d.useMemo(()=>ja(u,v=>v.provider),[u]),N=s?.source==="remote",z=d.useMemo(()=>n?.variants||[],[n?.variants]),P=d.useMemo(()=>Mt(l?.catalogs),[l?.catalogs]),L=l?.routing??{},_=!!l,G=v=>{A(v),v&&localStorage.setItem("cliproxy-selected-provider",v)},V=d.useMemo(()=>C?null:D&&u.some(v=>v.provider===D)?D:u.length>0&&(u.find(O=>(O.accounts?.length||0)>0)?.provider||u[0]?.provider)||null,[D,C,u]),q=u.find(v=>v.provider===V),S=z.find(v=>v.name===C),R=S?u.find(v=>v.provider===S.provider):void 0,b=(S?.provider||q?.provider||"").toLowerCase().trim(),Q=b==="gemini"||b==="agy",te=()=>{a.invalidateQueries({queryKey:["cliproxy"]}),a.invalidateQueries({queryKey:["cliproxy-auth"]}),a.invalidateQueries({queryKey:["cliproxy-catalog"]}),a.invalidateQueries({queryKey:["cliproxy-models"]})},ne=(v,O,be)=>{m.isPending||j.isPending||(be?m.mutate({provider:v,accountId:O}):j.mutate({provider:v,accountId:O}))},U=(v,O)=>{g.isPending||g.mutate({provider:v,accountId:O})},ae=(v,O)=>{x.isPending||x.mutate({provider:v,accountIds:O})},$=(v,O)=>{T.isPending||T.mutate({provider:v,accountIds:O})},Z=v=>{G(v),y(null)},ie=v=>{y(v),G(null)};return e.jsxs("div",{className:"flex h-full min-h-0 overflow-hidden",children:[e.jsxs("div",{className:"w-80 border-r flex flex-col bg-muted/30",children:[e.jsxs("div",{className:"p-4 border-b bg-background",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ie,{className:"w-5 h-5 text-primary"}),e.jsx("h1",{className:"font-semibold",children:o?.backendLabel??"CLIProxy"})]}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:te,disabled:c,children:e.jsx(wt,{className:X("w-4 h-4",c&&"animate-spin")})})]}),e.jsx("p",{className:"text-xs text-muted-foreground mb-3",children:t("cliproxyPage.accountManagement")}),e.jsxs(K,{variant:"default",size:"sm",className:"w-full gap-2",onClick:()=>h(!0),children:[e.jsx(De,{className:"w-4 h-4"}),t("cliproxyPage.quickSetup")]})]}),e.jsx(Nt,{className:"flex-1",children:e.jsxs("div",{className:"p-2",children:[e.jsx("div",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide px-3 py-2",children:t("cliproxyPage.providers")}),i?e.jsx("div",{className:"space-y-2 px-2",children:[1,2,3,4].map(v=>e.jsx(ba,{className:"h-14 w-full rounded-lg"},v))}):e.jsx("div",{className:"space-y-4",children:E.map(v=>e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"px-3",children:[e.jsx("div",{className:"text-[11px] font-medium uppercase tracking-wide text-muted-foreground",children:t(v.labelKey)}),e.jsx("p",{className:"mt-1 text-[11px] leading-relaxed text-muted-foreground",children:t(v.hintKey)})]}),e.jsx("div",{className:"space-y-1",children:v.items.map(O=>e.jsx(Pn,{status:O,isSelected:V===O.provider,onSelect:()=>Z(O.provider)},O.provider))})]},v.id))}),z.length>0&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide px-3 py-2 mt-4 flex items-center gap-1.5",children:[e.jsx(xs,{className:"w-3 h-3"}),t("cliproxyPage.variants")]}),e.jsx("div",{className:"space-y-1",children:z.map(v=>e.jsx(Dn,{variant:v,parentAuth:u.find(O=>O.provider===v.provider),isSelected:C===v.name,onSelect:()=>ie(v.name),onDelete:()=>k.mutate(v.name),isDeleting:k.isPending},v.name))})]})]})}),e.jsx("div",{className:"p-3 border-t",children:e.jsx(Ta,{})}),e.jsx("div",{className:"p-3 border-t bg-background text-xs text-muted-foreground",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{children:t("cliproxyPage.providerCount",{count:u.length})}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(we,{className:"w-3 h-3 text-green-600"}),t("cliproxyPage.connectedCount",{count:u.filter(v=>v.authenticated).length})]})]})})]}),e.jsx("div",{className:"flex-1 flex min-w-0 flex-col overflow-hidden bg-background",children:S&&R?e.jsx(e.Fragment,{children:e.jsx(Vt,{provider:S.name,displayName:t("cliproxyPage.variantDisplay",{name:S.name,provider:S.provider}),authStatus:R,catalog:P[S.provider],routing:L[S.provider],logoProvider:S.provider,baseProvider:S.provider,defaultTarget:S.target,isRemoteMode:N,port:S.port,topNotice:Q?e.jsx(xt,{compact:!0,showProxySettingsLink:!0}):void 0,onAddAccount:()=>I({provider:S.provider,displayName:R.displayName,isFirstAccount:(R.accounts?.length||0)===0}),onSetDefault:v=>r.mutate({provider:S.provider,accountId:v}),onRemoveAccount:v=>p.mutate({provider:S.provider,accountId:v}),onPauseToggle:(v,O)=>ne(S.provider,v,O),onSoloMode:v=>U(S.provider,v),onBulkPause:v=>ae(S.provider,v),onBulkResume:v=>$(S.provider,v),isRemovingAccount:p.isPending,isPausingAccount:m.isPending||j.isPending,isSoloingAccount:g.isPending,isBulkPausing:x.isPending,isBulkResuming:T.isPending})}):q?e.jsx(e.Fragment,{children:e.jsx(Vt,{provider:q.provider,displayName:q.displayName,authStatus:q,catalog:P[q.provider],routing:L[q.provider],isRemoteMode:N,topNotice:Q?e.jsx(xt,{compact:!0,showProxySettingsLink:!0}):void 0,onAddAccount:()=>I({provider:q.provider,displayName:q.displayName,isFirstAccount:(q.accounts?.length||0)===0}),onSetDefault:v=>r.mutate({provider:q.provider,accountId:v}),onRemoveAccount:v=>p.mutate({provider:q.provider,accountId:v}),onPauseToggle:(v,O)=>ne(q.provider,v,O),onSoloMode:v=>U(q.provider,v),onBulkPause:v=>ae(q.provider,v),onBulkResume:v=>$(q.provider,v),isRemovingAccount:p.isPending,isPausingAccount:m.isPending||j.isPending,isSoloingAccount:g.isPending,isBulkPausing:x.isPending,isBulkResuming:T.isPending})}):e.jsx(In,{onSetup:()=>h(!0)})}),e.jsx(tn,{open:w,onClose:()=>h(!1)}),e.jsx(dn,{open:f!==null,onClose:()=>I(null),provider:f?.provider||"",displayName:f?.displayName||"",catalog:_&&f?.provider?P[f.provider]:void 0,isFirstAccount:f?.isFirstAccount||!1})]})}export{Qn as CliproxyPage};
@@ -1,27 +0,0 @@
1
- import{j as e}from"./radix-ui-Zb8sVEtn.js";import{r as N}from"./react-vendor-CNOkPC89.js";import{t as U}from"./notifications-B2HqRBj7.js";import{C as I,j as F,k as W,B as _,b as K,a as E,d as C,aI as J,r as P,s as O,t as D,v as L,w as b,I as S,n as fe,W as y,bf as se,bg as Pe,c as Oe,bm as He,bn as ve,bo as Qe,Q as Je,R as Ze,U as ae,V as oe,bh as be}from"./index-2X8-14xr.js";import{aa as es,aS as ss,at as re,L as z,n as rs,aT as ts,aU as ns,aC as as,w as os,a7 as ls,aV as is,aW as cs,aX as ds,ai as me,p as we,$ as xs,m as us,o as ms,_ as ps,S as hs,aN as Ne,aY as fs,x as gs,I as js,T as vs,N as bs}from"./icons-DyorC3Xk.js";import{S as ee}from"./separator-CaGbNw8E.js";import{a as ws,u as ye,b as Ce}from"./tanstack-CrmUhA7Z.js";import"./code-highlight-BRUf_pqB.js";import{T as Ns,a as ys,b as Se,c as le,d as Cs,e as ie}from"./table-CKuoPAz4.js";import{R as Ss}from"./raw-json-settings-editor-panel-DNmb_vR-.js";import"./utils-CzKF5WmX.js";import"./form-utils-Bcoyqxpq.js";function Z({title:s,icon:r,badge:t,description:l,disabledReason:o,children:n}){return e.jsxs(I,{children:[e.jsxs(F,{className:"pb-2",children:[e.jsxs(W,{className:"flex items-center gap-2 text-base",children:[r,s,t?e.jsx(_,{variant:"outline",className:"text-[10px] font-normal",children:t}):null]}),l?e.jsx("p",{className:"text-xs text-muted-foreground",children:l}):null]}),e.jsxs(K,{className:"space-y-3",children:[o?e.jsx("p",{className:"text-xs text-amber-600",children:o}):null,n]})]})}function _s({catalog:s,state:r,disabled:t=!1,disabledReason:l,onToggle:o}){const{t:n}=E(),a=new Set(s.map(i=>i.name)),c=Object.entries(r).filter(([i])=>!a.has(i)).sort(([i],[d])=>i.localeCompare(d));return e.jsxs(Z,{title:n("codex.features"),badge:"features",icon:e.jsx(es,{className:"h-4 w-4"}),description:n("codex.featuresDesc"),disabledReason:l,children:[e.jsx("div",{className:"space-y-2",children:s.map(i=>{const d=r[i.name]??null;return e.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-md border px-3 py-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("p",{className:"text-sm font-medium",children:i.label}),e.jsx(_,{variant:"outline",className:"font-mono text-[10px]",children:i.name})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:i.description})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[d!==null?e.jsx(C,{variant:"outline",size:"sm",onClick:()=>o(i.name,null),disabled:t,children:n("codex.useDefault")}):null,e.jsx(J,{checked:d===!0,onCheckedChange:m=>o(i.name,m),disabled:t})]})]},i.name)})}),c.length>0?e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:n("codex.configOnlyFlags")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:n("codex.configOnlyFlagsDesc")})]}),c.map(([i,d])=>e.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-md border border-dashed px-3 py-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("p",{className:"text-sm font-medium",children:i}),e.jsx(_,{variant:"secondary",className:"text-[10px]",children:n("codex.existing")})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:n(d===null?"codex.nonBooleanForm":"codex.discoveredFromFile")})]}),d===null?e.jsx(_,{variant:"outline",children:n("codex.rawOnly")}):e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(C,{variant:"outline",size:"sm",onClick:()=>o(i,null),disabled:t,children:n("codex.useDefault")}),e.jsx(J,{checked:d===!0,onCheckedChange:m=>o(i,m),disabled:t})]})]},i))]}):null]})}const ks={name:"",transport:"stdio",command:null,args:[],url:null,enabled:!0,required:!1,startupTimeoutSec:null,toolTimeoutSec:null,enabledTools:[],disabledTools:[],isCcsManaged:!1,managementSurface:null};function ce(s){return s.join(", ")}function de(s){return s.split(",").map(r=>r.trim()).filter(Boolean)}function Ts({initialDraft:s,isNew:r,disabled:t,saving:l,canDelete:o,onSave:n,onDelete:a}){const{t:c}=E(),[i,d]=N.useState(s),m=r&&i.name.trim()==="ccs_browser";return e.jsxs(e.Fragment,{children:[m?e.jsxs("div",{className:"rounded-md border border-amber-500/30 bg-amber-500/10 px-3 py-2 text-sm text-amber-900 dark:text-amber-200",children:[e.jsx("strong",{children:"ccs_browser"})," is reserved for the CCS-managed browser tooling path. Configure it from ",e.jsx("code",{children:"Settings > Browser"})," instead of creating it here."]}):null,e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsx(S,{value:i.name,onChange:p=>d(x=>({...x,name:p.target.value})),placeholder:"playwright",disabled:t||!r}),e.jsxs(P,{value:i.transport,onValueChange:p=>d(x=>({...x,transport:p})),disabled:t,children:[e.jsx(O,{children:e.jsx(D,{})}),e.jsxs(L,{children:[e.jsx(b,{value:"stdio",children:c("codex.stdio")}),e.jsx(b,{value:"streamable-http",children:c("codex.streamableHttp")})]})]}),i.transport==="stdio"?e.jsxs(e.Fragment,{children:[e.jsx(S,{value:i.command??"",onChange:p=>d(x=>({...x,command:p.target.value||null})),placeholder:"npx",disabled:t}),e.jsx(S,{value:ce(i.args),onChange:p=>d(x=>({...x,args:de(p.target.value)})),placeholder:"@playwright/mcp@latest, --flag",disabled:t})]}):e.jsx(S,{className:"sm:col-span-2",value:i.url??"",onChange:p=>d(x=>({...x,url:p.target.value||null})),placeholder:"https://example.test/mcp",disabled:t}),e.jsx(S,{type:"number",min:1,value:i.startupTimeoutSec??"",onChange:p=>d(x=>({...x,startupTimeoutSec:p.target.value?Number(p.target.value):null})),placeholder:"Startup timeout (sec)",disabled:t}),e.jsx(S,{type:"number",min:1,value:i.toolTimeoutSec??"",onChange:p=>d(x=>({...x,toolTimeoutSec:p.target.value?Number(p.target.value):null})),placeholder:"Tool timeout (sec)",disabled:t}),e.jsx(S,{value:ce(i.enabledTools),onChange:p=>d(x=>({...x,enabledTools:de(p.target.value)})),placeholder:"enabled_tools",disabled:t}),e.jsx(S,{value:ce(i.disabledTools),onChange:p=>d(x=>({...x,disabledTools:de(p.target.value)})),placeholder:"disabled_tools",disabled:t})]}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsxs("label",{className:"flex items-center justify-between rounded-md border px-3 py-2 text-sm",children:["Enabled",e.jsx(J,{checked:i.enabled,onCheckedChange:p=>d(x=>({...x,enabled:p})),disabled:t})]}),e.jsxs("label",{className:"flex items-center justify-between rounded-md border px-3 py-2 text-sm",children:["Required",e.jsx(J,{checked:i.required,onCheckedChange:p=>d(x=>({...x,required:p})),disabled:t})]})]}),e.jsxs("div",{className:"flex justify-between gap-2",children:[e.jsxs(C,{variant:"outline",onClick:a,disabled:t||l||!o,children:[e.jsx(re,{className:"mr-2 h-4 w-4"}),"Delete"]}),e.jsxs(C,{onClick:()=>n(i.name,{transport:i.transport,command:i.command,args:i.args,url:i.url,enabled:i.enabled,required:i.required,startupTimeoutSec:i.startupTimeoutSec,toolTimeoutSec:i.toolTimeoutSec,enabledTools:i.enabledTools,disabledTools:i.disabledTools}),disabled:t||l||i.name.trim().length===0||m,children:[l?e.jsx(z,{className:"mr-2 h-4 w-4 animate-spin"}):null,"Save MCP server"]})]})]})}function Es({entries:s,disabled:r=!1,disabledReason:t,saving:l=!1,onSave:o,onDelete:n}){const{t:a}=E(),[c,i]=N.useState("new"),d=N.useMemo(()=>s.find(j=>j.name===c)??null,[s,c]),m=d??ks,p=JSON.stringify(m),x=d?.isCcsManaged&&d.managementSurface==="browser-settings";return e.jsxs(Z,{title:"MCP servers",badge:"mcp_servers",icon:e.jsx(ss,{className:"h-4 w-4"}),description:"Manage the safe MCP transport fields. Keep auth headers and bearer tokens in raw TOML.",disabledReason:t,children:[x?e.jsxs("div",{className:"rounded-md border border-amber-500/30 bg-amber-500/10 px-3 py-2 text-sm text-amber-900 dark:text-amber-200",children:[e.jsx("strong",{children:d?.name})," is CCS-managed. Configure browser tooling from"," ",e.jsx("code",{children:"Settings > Browser"}),"; the generic MCP editor is read-only for this entry."]}):null,e.jsxs(P,{value:c,onValueChange:i,disabled:r,children:[e.jsx(O,{children:e.jsx(D,{placeholder:"Select MCP server"})}),e.jsxs(L,{children:[e.jsx(b,{value:"new",children:a("codex.createNewMcpServer")}),s.map(j=>e.jsx(b,{value:j.name,children:j.isCcsManaged?`${j.name} (CCS managed)`:j.name},j.name))]})]}),e.jsx(Ts,{initialDraft:m,isNew:c==="new",disabled:r||!!x,saving:l,canDelete:d!==null&&!x,onDelete:async()=>{d&&(await n(d.name),i("new"))},onSave:async(j,h)=>{await o(j,h),i(j)}},p)]})}const Ps={name:"",displayName:null,baseUrl:null,envKey:null,wireApi:"responses",requiresOpenaiAuth:!1,supportsWebsockets:!1},Os={name:"cliproxy",displayName:"CLIProxy Codex",baseUrl:"http://127.0.0.1:8317/api/provider/codex",envKey:"CLIPROXY_API_KEY",wireApi:"responses",requiresOpenaiAuth:!1,supportsWebsockets:!1};function Ds({initialDraft:s,isNew:r,disabled:t,saving:l,canDelete:o,onSave:n,onDelete:a}){const{t:c}=E(),[i,d]=N.useState(s);return e.jsxs(e.Fragment,{children:[r&&e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 rounded-md border border-dashed px-3 py-2 text-xs text-muted-foreground",children:[e.jsxs("p",{children:["Quick start: apply the CLIProxy Codex preset here, then set"," ",e.jsx("strong",{children:c("codex.defaultProvider")})," to ",e.jsx("code",{children:"cliproxy"})," in Top-level settings."]}),e.jsx(C,{variant:"outline",size:"sm",onClick:()=>d(Os),disabled:t,children:"Use CLIProxy Codex preset"})]}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsx(S,{value:i.name,onChange:m=>d(p=>({...p,name:m.target.value})),placeholder:"Provider id",disabled:t||!r}),e.jsx(S,{value:i.displayName??"",onChange:m=>d(p=>({...p,displayName:m.target.value||null})),placeholder:"Display name",disabled:t}),e.jsx(S,{value:i.baseUrl??"",onChange:m=>d(p=>({...p,baseUrl:m.target.value||null})),placeholder:"http://127.0.0.1:8317/api/provider/codex",disabled:t}),e.jsx(S,{value:i.envKey??"",onChange:m=>d(p=>({...p,envKey:m.target.value||null})),placeholder:"CLIPROXY_API_KEY",disabled:t})]}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-3",children:[e.jsxs(P,{value:i.wireApi??"responses",onValueChange:m=>d(p=>({...p,wireApi:m})),disabled:t,children:[e.jsx(O,{children:e.jsx(D,{})}),e.jsx(L,{children:e.jsx(b,{value:"responses",children:c("codex.responses")})})]}),e.jsxs("label",{className:"flex items-center justify-between rounded-md border px-3 py-2 text-sm",children:["Requires OpenAI auth",e.jsx(J,{checked:i.requiresOpenaiAuth,onCheckedChange:m=>d(p=>({...p,requiresOpenaiAuth:m})),disabled:t})]}),e.jsxs("label",{className:"flex items-center justify-between rounded-md border px-3 py-2 text-sm",children:["Supports websockets",e.jsx(J,{checked:i.supportsWebsockets,onCheckedChange:m=>d(p=>({...p,supportsWebsockets:m})),disabled:t})]})]}),e.jsxs("div",{className:"flex justify-between gap-2",children:[e.jsxs(C,{variant:"outline",onClick:a,disabled:t||l||!o,children:[e.jsx(re,{className:"mr-2 h-4 w-4"}),"Delete"]}),e.jsxs(C,{onClick:()=>n(i.name,{displayName:i.displayName,baseUrl:i.baseUrl,envKey:i.envKey,wireApi:i.wireApi,requiresOpenaiAuth:i.requiresOpenaiAuth,supportsWebsockets:i.supportsWebsockets}),disabled:t||l||i.name.trim().length===0,children:[l?e.jsx(z,{className:"mr-2 h-4 w-4 animate-spin"}):null,"Save provider"]})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["If you want plain native ",e.jsx("code",{children:"codex"})," to default to CLIProxy, save a provider named"," ",e.jsx("code",{children:"cliproxy"})," with ",e.jsx("code",{children:"CLIPROXY_API_KEY"})," here, then pick"," ",e.jsx("code",{children:"cliproxy"})," in the ",e.jsx("strong",{children:c("codex.defaultProvider")})," control above."]})]})}function Ls({entries:s,disabled:r=!1,disabledReason:t,saving:l=!1,onSave:o,onDelete:n}){const{t:a}=E(),[c,i]=N.useState("new"),d=N.useMemo(()=>s.find(x=>x.name===c)??null,[s,c]),m=d??Ps,p=JSON.stringify(m);return e.jsxs(Z,{title:"Model providers",badge:"model_providers",icon:e.jsx(rs,{className:"h-4 w-4"}),description:"Edit the common provider fields CCS can support safely. Keep secret migration and inline bearer tokens in raw TOML.",disabledReason:t,children:[e.jsxs(P,{value:c,onValueChange:i,disabled:r,children:[e.jsx(O,{children:e.jsx(D,{placeholder:"Select provider"})}),e.jsxs(L,{children:[e.jsx(b,{value:"new",children:a("codex.createNewProvider")}),s.map(x=>e.jsx(b,{value:x.name,children:x.name},x.name))]})]}),e.jsx(Ds,{initialDraft:m,isNew:c==="new",disabled:r,saving:l,canDelete:d!==null,onDelete:async()=>{d&&(await n(d.name),i("new"))},onSave:async(x,j)=>{await o(x,j),i(x)}},p)]})}function As({initialName:s,initialModel:r,initialProvider:t,initialEffort:l,providerNames:o,activeProfile:n,selectedEntryName:a,disabled:c,saving:i,onSave:d,onDelete:m,onSetActive:p}){const{t:x}=E(),[j,h]=N.useState(s),[w,M]=N.useState(r),[q,u]=N.useState(t),[v,G]=N.useState(l);return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsx(S,{value:j,onChange:g=>h(g.target.value),placeholder:"deep-review",disabled:c||a!==null}),e.jsx(S,{value:w??"",onChange:g=>M(g.target.value||null),placeholder:"gpt-5.4",disabled:c}),e.jsxs(P,{value:q??"__unset__",onValueChange:g=>u(g==="__unset__"?null:g),disabled:c,children:[e.jsx(O,{children:e.jsx(D,{placeholder:x("codex.useGlobalProvider")})}),e.jsxs(L,{children:[e.jsx(b,{value:"__unset__",children:x("codex.useGlobalProvider")}),o.map(g=>e.jsx(b,{value:g,children:g},g))]})]}),e.jsxs(P,{value:v??"__unset__",onValueChange:g=>G(g==="__unset__"?null:g),disabled:c,children:[e.jsx(O,{children:e.jsx(D,{placeholder:x("codex.useGlobalEffort")})}),e.jsxs(L,{children:[e.jsx(b,{value:"__unset__",children:x("codex.useGlobalEffort")}),["minimal","low","medium","high","xhigh"].map(g=>e.jsx(b,{value:g,children:g},g))]})]})]}),e.jsxs("div",{className:"flex justify-between gap-2",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(C,{variant:"outline",onClick:m,disabled:c||i||!a,children:[e.jsx(re,{className:"mr-2 h-4 w-4"}),"Delete"]}),e.jsx(C,{variant:"outline",onClick:p,disabled:c||i||!a||a===n,children:"Set active"})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(C,{variant:"outline",onClick:()=>d(j,{model:w,modelProvider:q,modelReasoningEffort:v},!1),disabled:c||i||j.trim().length===0,children:[i?e.jsx(z,{className:"mr-2 h-4 w-4 animate-spin"}):null,"Save profile"]}),e.jsxs(C,{onClick:()=>d(j,{model:w,modelProvider:q,modelReasoningEffort:v},!0),disabled:c||i||j.trim().length===0,children:[i?e.jsx(z,{className:"mr-2 h-4 w-4 animate-spin"}):null,"Save + activate"]})]})]})]})}function Ms({activeProfile:s,entries:r,providerNames:t,disabled:l=!1,disabledReason:o,saving:n=!1,onSave:a,onDelete:c,onSetActive:i}){const{t:d}=E(),[m,p]=N.useState("new"),x=N.useMemo(()=>r.find(h=>h.name===m)??null,[r,m]),j=JSON.stringify(x??{name:"",values:{}});return e.jsxs(Z,{title:d("codex.profiles"),badge:"profiles",icon:e.jsx(ts,{className:"h-4 w-4"}),description:"Create reusable Codex overlays and set the active default profile.",disabledReason:o,children:[e.jsxs(P,{value:m,onValueChange:p,disabled:l,children:[e.jsx(O,{children:e.jsx(D,{placeholder:"Select profile"})}),e.jsxs(L,{children:[e.jsx(b,{value:"new",children:d("codex.createNewProfile")}),r.map(h=>e.jsxs(b,{value:h.name,children:[h.name,h.name===s?" (active)":""]},h.name))]})]}),e.jsx(As,{initialName:x?.name??"",initialModel:x?.values.model??null,initialProvider:x?.values.modelProvider??null,initialEffort:x?.values.modelReasoningEffort??null,providerNames:t,activeProfile:s,selectedEntryName:x?.name??null,disabled:l,saving:n,onDelete:async()=>{x&&(await c(x.name),p("new"))},onSetActive:async()=>{x&&await i(x.name)},onSave:async(h,w,M)=>{await a(h,w,M),p(h)}},j)]})}function Rs({workspacePath:s,disabled:r,saving:t,onSave:l}){const{t:o}=E(),[n,a]=N.useState(s),[c,i]=N.useState("trusted");return e.jsxs("div",{className:"grid gap-2 sm:grid-cols-[1fr_160px_auto]",children:[e.jsx(S,{value:n,onChange:d=>a(d.target.value),placeholder:"~/repo or /absolute/path",disabled:r}),e.jsxs(P,{value:c,onValueChange:i,disabled:r,children:[e.jsx(O,{children:e.jsx(D,{})}),e.jsxs(L,{children:[e.jsx(b,{value:"trusted",children:o("codex.trusted")}),e.jsx(b,{value:"untrusted",children:o("codex.untrusted")})]})]}),e.jsxs(C,{onClick:()=>l(n,c),disabled:r||t,children:[t?e.jsx(z,{className:"mr-2 h-4 w-4 animate-spin"}):null,"Save trust"]})]})}function Is({workspacePath:s,entries:r,disabled:t=!1,disabledReason:l,saving:o=!1,onSave:n}){const{t:a}=E();return e.jsxs(Z,{title:"Project trust",badge:"projects",icon:e.jsx(ns,{className:"h-4 w-4"}),description:"Trust current workspaces or remove stale trust entries without opening raw TOML.",disabledReason:l,children:[e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Paths must be absolute or start with ",e.jsx("code",{children:"~/"}),". Relative paths are rejected so CCS does not trust the wrong folder."]}),e.jsx(Rs,{workspacePath:s,disabled:t,saving:o,onSave:n},s),e.jsx(C,{variant:"outline",className:"w-full justify-start",onClick:()=>n(s,"trusted"),disabled:t||o,children:"Trust current workspace"}),e.jsx("div",{className:"space-y-2",children:r.length===0?e.jsx("p",{className:"text-xs text-muted-foreground",children:a("codex.noProjectTrustEntries")}):r.map(c=>e.jsxs("div",{className:"flex items-center justify-between gap-2 rounded-md border px-3 py-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"truncate text-sm font-medium",children:c.path}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["trust_level = ",c.trustLevel]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(C,{variant:"ghost",size:"sm",onClick:()=>n(c.path,c.trustLevel==="trusted"?"untrusted":"trusted"),disabled:t||o,children:"Toggle"}),e.jsx(C,{variant:"ghost",size:"icon",onClick:()=>n(c.path,null),disabled:t||o,children:e.jsx(re,{className:"h-4 w-4"})})]})]},c.path))})]})}const A="__unset__",Fs=105e4,Ws=272e3,_e=8e5,ke=7e5,Ks=new Intl.NumberFormat("en-US");function X(s){return s??A}function Y(s,r){return r&&!s.includes(r)?[r,...s]:s}function xe(s){return Ks.format(s)}function qs(s){return s?.trim().toLowerCase().startsWith("gpt-5.4")??!1}function Us(s,r){const t={};return r.model!==s.model&&(t.model=r.model),r.modelReasoningEffort!==s.modelReasoningEffort&&(t.modelReasoningEffort=r.modelReasoningEffort),r.modelContextWindow!==s.modelContextWindow&&(t.modelContextWindow=r.modelContextWindow),r.modelAutoCompactTokenLimit!==s.modelAutoCompactTokenLimit&&(t.modelAutoCompactTokenLimit=r.modelAutoCompactTokenLimit),r.modelProvider!==s.modelProvider&&(t.modelProvider=r.modelProvider),r.approvalPolicy!==s.approvalPolicy&&(t.approvalPolicy=r.approvalPolicy),r.sandboxMode!==s.sandboxMode&&(t.sandboxMode=r.sandboxMode),r.webSearch!==s.webSearch&&(t.webSearch=r.webSearch),r.toolOutputTokenLimit!==s.toolOutputTokenLimit&&(t.toolOutputTokenLimit=r.toolOutputTokenLimit),r.personality!==s.personality&&(t.personality=r.personality),t}function Vs({initialValues:s,providerNames:r,disabled:t,saving:l,onSave:o}){const{t:n}=E(),[a,c]=N.useState(s),i=Y(["minimal","low","medium","high","xhigh"],a.modelReasoningEffort),d=Y(r,a.modelProvider),m=Y(["on-request","never","untrusted"],a.approvalPolicy),p=Y(["read-only","workspace-write","danger-full-access"],a.sandboxMode),x=Y(["cached","live","disabled"],a.webSearch),j=Y(["none","friendly","pragmatic"],a.personality),h=Us(s,a),w=Object.keys(h).length>0,M=qs(a.model),q=u=>{const v=u.trim();return v.length>0?Number(v):null};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium",children:n("codex.model")}),e.jsx(S,{value:a.model??"",onChange:u=>c(v=>({...v,model:u.target.value||null})),placeholder:"gpt-5.4",disabled:t})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium",children:n("codex.reasoningEffort")}),e.jsxs(P,{value:X(a.modelReasoningEffort),onValueChange:u=>c(v=>({...v,modelReasoningEffort:u===A?null:u})),disabled:t,children:[e.jsx(O,{children:e.jsx(D,{placeholder:n("codex.useDefault")})}),e.jsxs(L,{children:[e.jsx(b,{value:A,children:n("codex.useDefault")}),i.map(u=>e.jsx(b,{value:u,children:u},u))]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium",children:n("codex.defaultProvider")}),e.jsxs(P,{value:X(a.modelProvider),onValueChange:u=>c(v=>({...v,modelProvider:u===A?null:u})),disabled:t,children:[e.jsx(O,{children:e.jsx(D,{placeholder:n("codex.useCodexDefault")})}),e.jsxs(L,{children:[e.jsx(b,{value:A,children:n("codex.useCodexDefault")}),d.map(u=>e.jsx(b,{value:u,children:u},u))]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium",children:n("codex.approvalPolicy")}),e.jsxs(P,{value:X(a.approvalPolicy),onValueChange:u=>c(v=>({...v,approvalPolicy:u===A?null:u})),disabled:t,children:[e.jsx(O,{children:e.jsx(D,{placeholder:n("codex.useDefault")})}),e.jsxs(L,{children:[e.jsx(b,{value:A,children:n("codex.useDefault")}),m.map(u=>e.jsx(b,{value:u,children:u},u))]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium",children:n("codex.sandboxMode")}),e.jsxs(P,{value:X(a.sandboxMode),onValueChange:u=>c(v=>({...v,sandboxMode:u===A?null:u})),disabled:t,children:[e.jsx(O,{children:e.jsx(D,{placeholder:n("codex.useDefault")})}),e.jsxs(L,{children:[e.jsx(b,{value:A,children:n("codex.useDefault")}),p.map(u=>e.jsx(b,{value:u,children:u},u))]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium",children:n("codex.webSearch")}),e.jsxs(P,{value:X(a.webSearch),onValueChange:u=>c(v=>({...v,webSearch:u===A?null:u})),disabled:t,children:[e.jsx(O,{children:e.jsx(D,{placeholder:n("codex.useDefault")})}),e.jsxs(L,{children:[e.jsx(b,{value:A,children:n("codex.useDefault")}),x.map(u=>e.jsx(b,{value:u,children:u},u))]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium",children:n("codex.toolOutputTokenLimit")}),e.jsx(S,{type:"number",min:1,value:a.toolOutputTokenLimit??"",onChange:u=>c(v=>({...v,toolOutputTokenLimit:u.target.value?Number(u.target.value):null})),placeholder:"25000",disabled:t})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium",children:n("codex.personality")}),e.jsxs(P,{value:X(a.personality),onValueChange:u=>c(v=>({...v,personality:u===A?null:u})),disabled:t,children:[e.jsx(O,{children:e.jsx(D,{placeholder:n("codex.useDefault")})}),e.jsxs(L,{children:[e.jsx(b,{value:A,children:n("codex.useDefault")}),j.map(u=>e.jsx(b,{value:u,children:u},u))]})]})]})]}),e.jsxs("div",{className:"space-y-4 rounded-xl border border-amber-500/30 bg-amber-500/5 p-4 shadow-sm dark:bg-amber-400/5",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(os,{className:"h-4 w-4 text-amber-600 dark:text-amber-300"}),e.jsx("p",{className:"text-sm font-semibold",children:n("codex.longContextOverride")}),e.jsx(_,{variant:"outline",className:"border-amber-500/40 bg-background/80 text-[10px] uppercase tracking-[0.16em] text-amber-700 dark:text-amber-300",children:"Manual opt-in only"}),e.jsx(_,{variant:"secondary",className:"text-[10px] uppercase tracking-[0.16em] text-muted-foreground",children:M?"GPT-5.4 selected":"GPT-5.4 reference"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Draft values only. Nothing applies until Save."})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(C,{type:"button",variant:"outline",size:"sm",disabled:t,onClick:()=>c(u=>({...u,modelContextWindow:_e,modelAutoCompactTokenLimit:ke})),children:"Fill cautious pair"}),e.jsx(C,{type:"button",variant:"outline",size:"sm",disabled:t,onClick:()=>c(u=>({...u,modelContextWindow:Fs})),children:"Set official max window"}),e.jsx(C,{type:"button",variant:"ghost",size:"sm",disabled:t,onClick:()=>c(u=>({...u,modelContextWindow:null,modelAutoCompactTokenLimit:null})),children:"Clear"})]})]}),e.jsxs("div",{className:"grid gap-2 sm:grid-cols-3",children:[e.jsxs("div",{className:"rounded-lg border bg-background/85 px-3 py-3 shadow-sm shadow-black/5",children:[e.jsx("p",{className:"text-[10px] font-medium uppercase tracking-wide text-muted-foreground",children:"Official max"}),e.jsx("p",{className:"mt-1 font-mono text-base font-semibold text-foreground",children:"1.05M / 1M"}),e.jsx("p",{className:"mt-1 text-[11px] text-muted-foreground",children:n("codex.gptContextCap")})]}),e.jsxs("div",{className:"rounded-lg border bg-background/85 px-3 py-3 shadow-sm shadow-black/5",children:[e.jsx("p",{className:"text-[10px] font-medium uppercase tracking-wide text-muted-foreground",children:"Standard window"}),e.jsx("p",{className:"mt-1 font-mono text-base font-semibold text-foreground",children:xe(Ws)}),e.jsx("p",{className:"mt-1 text-[11px] text-muted-foreground",children:n("codex.normalUsageWindow")})]}),e.jsxs("div",{className:"rounded-lg border bg-background/85 px-3 py-3 shadow-sm shadow-black/5",children:[e.jsx("p",{className:"text-[10px] font-medium uppercase tracking-wide text-muted-foreground",children:"Above 272K"}),e.jsx("p",{className:"mt-1 font-mono text-base font-semibold text-foreground",children:n("codex.counts2x")}),e.jsx("p",{className:"mt-1 text-[11px] text-muted-foreground",children:n("codex.usageLimitCost")})]})]}),e.jsxs("div",{className:"space-y-3 rounded-lg border bg-background/75 px-3 py-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("p",{className:"text-[10px] font-medium uppercase tracking-wide text-muted-foreground",children:"One cautious pair"}),e.jsxs("div",{className:"rounded-full border bg-background px-2.5 py-1 font-mono text-[11px] font-medium",children:["Context ",xe(_e)]}),e.jsxs("div",{className:"rounded-full border bg-background px-2.5 py-1 font-mono text-[11px] font-medium",children:["Auto-compact ",xe(ke)]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[e.jsx(_,{variant:"outline",className:"border-border/70 bg-background/80 text-[10px] uppercase tracking-[0.14em] text-muted-foreground",children:"Not official"}),e.jsx(_,{variant:"outline",className:"border-border/70 bg-background/80 text-[10px] uppercase tracking-[0.14em] text-muted-foreground",children:"Draft only"})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-[11px] text-muted-foreground",children:[e.jsx("span",{children:n("codex.quickFillWarning")}),!M&&a.model?e.jsxs("span",{children:[e.jsx("code",{children:a.model})," should be checked separately."]}):null]})]}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium",children:n("codex.modelContextWindow")}),e.jsx(S,{"aria-label":n("codex.modelContextWindow"),type:"number",min:1,value:a.modelContextWindow??"",onChange:u=>c(v=>({...v,modelContextWindow:q(u.target.value)})),placeholder:"Unset",disabled:t}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Writes ",e.jsx("code",{children:"model_context_window"}),". Leave unset to keep Codex defaults."]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium",children:n("codex.autoCompactTokenLimit")}),e.jsx(S,{"aria-label":n("codex.autoCompactTokenLimit"),type:"number",min:1,value:a.modelAutoCompactTokenLimit??"",onChange:u=>c(v=>({...v,modelAutoCompactTokenLimit:q(u.target.value)})),placeholder:"Unset",disabled:t}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Writes ",e.jsx("code",{children:"model_auto_compact_token_limit"}),". Leave unset to keep model defaults."]})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-[11px] text-muted-foreground",children:[e.jsx("span",{className:"text-[10px] uppercase tracking-[0.14em]",children:"Docs"}),e.jsx("a",{href:"https://developers.openai.com/api/docs/models/gpt-5.4",target:"_blank",rel:"noreferrer",className:"underline underline-offset-2 hover:text-foreground",children:"GPT-5.4 model page"}),e.jsx("a",{href:"https://openai.com/index/introducing-gpt-5-4/",target:"_blank",rel:"noreferrer",className:"underline underline-offset-2 hover:text-foreground",children:"Release notes"}),e.jsx("a",{href:"https://developers.openai.com/codex/config-reference",target:"_blank",rel:"noreferrer",className:"underline underline-offset-2 hover:text-foreground",children:"Config reference"})]})]}),e.jsx("div",{className:"flex justify-end",children:e.jsxs(C,{onClick:()=>o(h),disabled:t||l||!w,children:[l?e.jsx(z,{className:"mr-2 h-4 w-4 animate-spin"}):null,"Save top-level settings"]})})]})}function Bs({values:s,providerNames:r,disabled:t=!1,disabledReason:l,saving:o=!1,onSave:n}){return e.jsx(Z,{title:"Top-level controls",badge:"config.toml",icon:e.jsx(as,{className:"h-4 w-4"}),description:"Structured controls for the stable top-level Codex settings users touch most often. Unsupported upstream shapes stay untouched and should be edited in raw TOML.",disabledReason:l,children:e.jsx(Vs,{initialValues:s,providerNames:r,disabled:t,saving:o,onSave:n},JSON.stringify(s))})}function Gs({workspacePath:s,activeProfile:r,topLevelSettings:t,projectTrustEntries:l,profileEntries:o,modelProviderEntries:n,mcpServerEntries:a,featureCatalog:c,featureState:i,disabled:d,disabledReason:m,saving:p,onPatch:x}){const{t:j}=E();return e.jsx(fe,{className:"h-full",children:e.jsxs("div",{className:"space-y-6 pr-1 pb-6",children:[e.jsxs("div",{className:"group relative overflow-hidden rounded-xl border border-border/80 bg-background/50 p-5 shadow-sm transition-all hover:bg-background hover:shadow-md dark:border-border/60",children:[e.jsx("div",{className:"absolute inset-x-0 -top-px h-px bg-gradient-to-r from-transparent via-foreground/15 to-transparent transition-opacity group-hover:via-foreground/30"}),e.jsxs("div",{className:"flex flex-col gap-6 lg:flex-row lg:items-start lg:justify-between",children:[e.jsxs("div",{className:"flex-1 space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"flex h-9 w-9 items-center justify-center rounded-lg border border-primary/20 bg-primary/10 text-primary transition-colors group-hover:border-primary/30",children:e.jsx(ls,{className:"h-4 w-4"})}),e.jsx("div",{children:e.jsx("h2",{className:"text-base font-semibold tracking-tight text-foreground",children:j("codex.controlCenter")})})]}),e.jsxs("ul",{className:"grid gap-3 sm:grid-cols-2 text-sm text-muted-foreground",children:[e.jsxs("li",{className:"flex items-start gap-2.5",children:[e.jsx(is,{className:"h-4 w-4 shrink-0 text-muted-foreground/60 mt-0.5"}),e.jsxs("span",{className:"leading-relaxed",children:["Writes exclusively to user-layer"," ",e.jsx("code",{className:"text-[11px] bg-muted/70 px-1.5 py-0.5 rounded border border-border/50",children:"config.toml"})]})]}),e.jsxs("li",{className:"flex items-start gap-2.5",children:[e.jsx(cs,{className:"h-4 w-4 shrink-0 text-muted-foreground/60 mt-0.5"}),e.jsx("span",{className:"leading-relaxed",children:"Does not reflect repo trust layers or CLI overrides"})]})]})]}),e.jsx("div",{className:"shrink-0 lg:w-[280px]",children:e.jsx("div",{className:"relative overflow-hidden rounded-lg border border-amber-500/20 bg-amber-500/5 p-4 transition-colors group-hover:border-amber-500/30 group-hover:bg-amber-500/10 dark:border-amber-400/10 dark:bg-amber-400/5",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(ds,{className:"mt-0.5 h-4 w-4 shrink-0 text-amber-600 dark:text-amber-400"}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-[11px] font-bold text-amber-700 dark:text-amber-300 uppercase tracking-wider",children:"Formatting Note"}),e.jsx("p",{className:"text-[13px] leading-relaxed text-amber-800/80 dark:text-amber-200/70",children:"Saves normalize TOML formatting and strip comments. Switch to the raw editor if exact layout matters."})]})]})})})]})]}),e.jsx(Bs,{values:t,providerNames:n.map(h=>h.name),disabled:d,disabledReason:m,saving:p,onSave:h=>x({kind:"top-level",values:h},j("toasts.codexSaved"))}),e.jsx(Is,{workspacePath:s,entries:l,disabled:d,disabledReason:m,saving:p,onSave:(h,w)=>x({kind:"project-trust",path:h,trustLevel:w},w?"Saved project trust entry.":"Removed project trust entry.")}),e.jsx(Ms,{activeProfile:r,entries:o,providerNames:n.map(h=>h.name),disabled:d,disabledReason:m,saving:p,onSave:(h,w,M)=>x({kind:"profile",action:"upsert",name:h,values:w,setAsActive:M},"Saved profile."),onDelete:h=>x({kind:"profile",action:"delete",name:h},"Deleted profile."),onSetActive:h=>x({kind:"profile",action:"set-active",name:h},"Set active profile.")}),e.jsx(Ls,{entries:n,disabled:d,disabledReason:m,saving:p,onSave:(h,w)=>x({kind:"model-provider",action:"upsert",name:h,values:w},"Saved model provider."),onDelete:h=>x({kind:"model-provider",action:"delete",name:h},"Deleted model provider.")}),e.jsx(Es,{entries:a,disabled:d,disabledReason:m,saving:p,onSave:(h,w)=>x({kind:"mcp-server",action:"upsert",name:h,values:w},"Saved MCP server."),onDelete:h=>x({kind:"mcp-server",action:"delete",name:h},"Deleted MCP server.")}),e.jsx(_s,{catalog:c,state:i,disabled:d,disabledReason:m,onToggle:(h,w)=>x({kind:"feature",feature:h,enabled:w},"Saved feature toggle.")})]})})}const De=`model_provider = "cliproxy"
2
-
3
- [model_providers.cliproxy]
4
- base_url = "http://127.0.0.1:8317/api/provider/codex"
5
- env_key = "CLIPROXY_API_KEY"
6
- wire_api = "responses"`,$s=["multi_agent","unified_exec","shell_snapshot","apply_patch_freeform","js_repl","runtime_metrics","prevent_idle_sleep","fast_mode","apps","smart_approvals"];function zs(){return[{name:"multi_agent",label:y.t("codex.featureMultiAgentLabel"),description:y.t("codex.featureMultiAgentDesc")},{name:"unified_exec",label:y.t("codex.featureUnifiedExecLabel"),description:y.t("codex.featureUnifiedExecDesc")},{name:"shell_snapshot",label:y.t("codex.featureShellSnapshotLabel"),description:y.t("codex.featureShellSnapshotDesc")},{name:"apply_patch_freeform",label:y.t("codex.featureApplyPatchLabel"),description:y.t("codex.featureApplyPatchDesc")},{name:"js_repl",label:y.t("codex.featureJsReplLabel"),description:y.t("codex.featureJsReplDesc")},{name:"runtime_metrics",label:y.t("codex.featureRuntimeMetricsLabel"),description:y.t("codex.featureRuntimeMetricsDesc")},{name:"prevent_idle_sleep",label:y.t("codex.featurePreventIdleSleepLabel"),description:y.t("codex.featurePreventIdleSleepDesc")},{name:"fast_mode",label:y.t("codex.featureFastModeLabel"),description:y.t("codex.featureFastModeDesc")},{name:"apps",label:y.t("codex.featureAppsLabel"),description:y.t("codex.featureAppsDesc")},{name:"smart_approvals",label:y.t("codex.featureSmartApprovalsLabel"),description:y.t("codex.featureSmartApprovalsDesc")}]}function B(s){return typeof s=="object"&&s!==null&&!Array.isArray(s)?s:null}function T(s){return typeof s=="string"&&s.trim().length>0?s.trim():null}function Q(s){return typeof s=="number"&&Number.isFinite(s)?s:null}function ue(s){return Array.isArray(s)?s.filter(r=>typeof r=="string").map(r=>r.trim()):[]}function Le(s){return{model:T(s?.model),modelReasoningEffort:T(s?.model_reasoning_effort),modelContextWindow:Q(s?.model_context_window),modelAutoCompactTokenLimit:Q(s?.model_auto_compact_token_limit),modelProvider:T(s?.model_provider),approvalPolicy:T(s?.approval_policy),sandboxMode:T(s?.sandbox_mode),webSearch:T(s?.web_search),toolOutputTokenLimit:Q(s?.tool_output_token_limit),personality:T(s?.personality)}}function Xs(s){const r=B(s?.projects);return r?Object.entries(r).map(([t,l])=>{const o=T(B(l)?.trust_level);return o?{path:t,trustLevel:o}:null}).filter(t=>t!==null).sort((t,l)=>t.path.localeCompare(l.path)):[]}function Ys(s){const r=B(s?.profiles);return r?Object.entries(r).map(([t,l])=>({name:t,values:Le(B(l))})).sort((t,l)=>t.name.localeCompare(l.name)):[]}function Hs(s){const r=B(s?.model_providers);return r?Object.entries(r).map(([t,l])=>{const o=B(l);return o?{name:t,displayName:T(o.name),baseUrl:T(o.base_url),envKey:T(o.env_key),wireApi:T(o.wire_api),requiresOpenaiAuth:o.requires_openai_auth===!0,supportsWebsockets:o.supports_websockets===!0}:null}).filter(t=>t!==null).sort((t,l)=>t.name.localeCompare(l.name)):[]}function Qs(s){const r=B(s?.mcp_servers);return r?Object.entries(r).map(([t,l])=>{const o=B(l);if(!o)return null;const n=T(o.command)?"stdio":"streamable-http",a=Q(o.startup_timeout_ms);return{name:t,transport:n,command:T(o.command),args:ue(o.args),url:T(o.url),enabled:o.enabled!==!1,required:o.required===!0,startupTimeoutSec:Q(o.startup_timeout_sec)??(a!==null?a/1e3:null),toolTimeoutSec:Q(o.tool_timeout_sec),enabledTools:ue(o.enabled_tools),disabledTools:ue(o.disabled_tools),isCcsManaged:t==="ccs_browser",managementSurface:t==="ccs_browser"?"browser-settings":null}}).filter(t=>t!==null).sort((t,l)=>t.name.localeCompare(l.name)):[]}function Js(s){const r=B(s?.features),t={};for(const l of $s){const o=r?.[l];t[l]=typeof o=="boolean"?o:null}if(r)for(const[l,o]of Object.entries(r))l in t||(t[l]=typeof o=="boolean"?o:null);return t}const Zs=[{id:"codex-config-basic",label:"Codex Config Basics",url:"https://developers.openai.com/codex/config-basic",description:"Official user-layer setup, config location, and baseline configuration behavior."},{id:"codex-config-advanced",label:"Codex Config Advanced",url:"https://developers.openai.com/codex/config-advanced",description:"Layering, trust, profiles, and advanced config behavior."},{id:"codex-config-reference",label:"Codex Config Reference",url:"https://developers.openai.com/codex/config-reference",description:"Canonical upstream config surface for providers, MCP, features, and trust."},{id:"codex-releases",label:"Codex GitHub Releases",url:"https://github.com/openai/codex/releases",description:"Track upstream release notes and fast-moving CLI changes."}],er=[{provider:"openai",label:"OpenAI Responses API",apiFormat:"Responses API",url:"https://platform.openai.com/docs/api-reference/responses"}];function sr(s){const r=/https?:\/\/[^\s)]+/g,t=[];let l=0,o;for(;(o=r.exec(s))!==null;){const[n]=o,a=o.index;a>l&&t.push(s.slice(l,a)),t.push(e.jsx("a",{href:n,target:"_blank",rel:"noreferrer",className:"underline underline-offset-2 hover:text-foreground",children:n},`${n}-${a}`)),l=a+n.length}return l<s.length&&t.push(s.slice(l)),t.length>0?t:[s]}function rr({diagnostics:s}){const{t:r}=E(),t=s.docsReference??{notes:[],links:[],providerDocs:[],providerValues:[],settingsHierarchy:[]},l=t.links.length>0?t.links:Zs,o=t.providerDocs.length>0?t.providerDocs:er;return e.jsx(fe,{className:"h-full",children:e.jsxs("div",{className:"space-y-4 pr-1",children:[e.jsxs(I,{children:[e.jsx(F,{className:"pb-2",children:e.jsxs(W,{className:"flex items-center gap-2 text-base",children:[e.jsx(me,{className:"h-4 w-4"}),"CCS bridge recipe"]})}),e.jsxs(K,{className:"space-y-3 text-sm text-muted-foreground",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("p",{children:[e.jsx("strong",{children:"Built-in:"})," Use ",e.jsx("code",{children:"ccsxp"})," for the CCS provider shortcut."]}),e.jsxs("p",{children:[e.jsx("strong",{children:"Native:"})," Configure the recipe below to use CLIProxy directly with"," ",e.jsx("code",{children:"codex"}),"."]})]}),e.jsx("pre",{className:"overflow-x-auto rounded-md border bg-muted/20 p-3 text-xs text-foreground",children:De}),e.jsxs("ol",{className:"ml-4 list-decimal space-y-1.5 [&>li]:pl-1",children:[e.jsxs("li",{children:["Save the ",e.jsx("code",{children:"cliproxy"})," provider in your user config."]}),e.jsxs("li",{children:["Set top-level ",e.jsx("code",{children:"model_provider"})," to ",e.jsx("code",{children:"cliproxy"}),"."]}),e.jsxs("li",{children:["Export ",e.jsx("code",{children:"CLIPROXY_API_KEY"})," before launching native Codex."]})]}),e.jsxs("p",{children:["CCS-managed browser tooling belongs to ",e.jsx("code",{children:"Settings > Browser"}),". Do not edit the ",e.jsx("code",{children:"ccs_browser"})," entry from the generic MCP card unless you are intentionally overriding the managed path in raw TOML."]})]})]}),e.jsxs(I,{children:[e.jsx(F,{className:"pb-2",children:e.jsxs(W,{className:"flex items-center gap-2 text-base",children:[e.jsx(me,{className:"h-4 w-4"}),"Upstream notes"]})}),e.jsxs(K,{className:"space-y-2 text-sm",children:[t.notes.length>0&&e.jsx("ul",{className:"ml-4 list-disc space-y-1.5 text-muted-foreground [&>li]:pl-1",children:t.notes.map((n,a)=>e.jsx("li",{children:sr(n)},`${a}-${n}`))}),e.jsx(ee,{}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-xs uppercase tracking-wide text-muted-foreground",children:r("codex.codexDocs")}),e.jsx("div",{className:"space-y-1.5",children:l.map(n=>e.jsxs("a",{href:n.url,target:"_blank",rel:"noreferrer",className:"block rounded-md border px-2.5 py-2 transition-colors hover:bg-muted/50",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("span",{className:"text-xs font-medium",children:n.label}),e.jsx(we,{className:"h-3.5 w-3.5 text-muted-foreground"})]}),e.jsx("p",{className:"mt-0.5 text-[11px] text-muted-foreground",children:n.description}),e.jsx("p",{className:"mt-1 break-all font-mono text-[11px] text-muted-foreground/90 underline underline-offset-2",children:n.url})]},n.id))})]}),e.jsx(ee,{}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-xs uppercase tracking-wide text-muted-foreground",children:"Provider / bridge reference"}),e.jsx("div",{className:"space-y-1.5",children:o.map(n=>e.jsxs("a",{href:n.url,target:"_blank",rel:"noreferrer",className:"block rounded-md border px-2.5 py-2 transition-colors hover:bg-muted/50",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("span",{className:"text-xs font-medium",children:n.label}),e.jsx(we,{className:"h-3.5 w-3.5 text-muted-foreground"})]}),e.jsxs("p",{className:"mt-0.5 text-[11px] text-muted-foreground",children:["provider: ",n.provider," | format: ",n.apiFormat]}),e.jsx("p",{className:"mt-1 break-all font-mono text-[11px] text-muted-foreground/90 underline underline-offset-2",children:n.url})]},`${n.provider}-${n.url}`))})]}),t.providerValues.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(ee,{}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Provider values: ",t.providerValues.join(", ")]})]}),t.settingsHierarchy.length>0&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Settings hierarchy: ",t.settingsHierarchy.join(" -> ")]})]})]})]})})}function tr(s,r){let t=s.slice(0,r).split(/\r\n|\n|\r/g);return[t.length,t.pop().length+1]}function nr(s,r,t){let l=s.split(/\r\n|\n|\r/g),o="",n=(Math.log10(r+1)|0)+1;for(let a=r-1;a<=r+1;a++){let c=l[a-1];c&&(o+=a.toString().padEnd(n," "),o+=": ",o+=c,o+=`
7
- `,a===r&&(o+=" ".repeat(n+t+2),o+=`^
8
- `))}return o}class f extends Error{line;column;codeblock;constructor(r,t){const[l,o]=tr(t.toml,t.ptr),n=nr(t.toml,l,o);super(`Invalid TOML document: ${r}
9
-
10
- ${n}`,t),this.line=l,this.column=o,this.codeblock=n}}function ar(s,r){let t=0;for(;s[r-++t]==="\\";);return--t&&t%2}function pe(s,r=0,t=s.length){let l=s.indexOf(`
11
- `,r);return s[l-1]==="\r"&&l--,l<=t?l:-1}function te(s,r){for(let t=r;t<s.length;t++){let l=s[t];if(l===`
12
- `)return t;if(l==="\r"&&s[t+1]===`
13
- `)return t+1;if(l<" "&&l!==" "||l==="")throw new f("control characters are not allowed in comments",{toml:s,ptr:r})}return s.length}function V(s,r,t,l){let o;for(;;){for(;(o=s[r])===" "||o===" "||!t&&(o===`
14
- `||o==="\r"&&s[r+1]===`
15
- `);)r++;if(l||o!=="#")break;r=te(s,r)}return r}function or(s,r,t,l,o=!1){if(!l)return r=pe(s,r),r<0?s.length:r;for(let n=r;n<s.length;n++){let a=s[n];if(a==="#")n=pe(s,n);else{if(a===t)return n+1;if(a===l||o&&(a===`
16
- `||a==="\r"&&s[n+1]===`
17
- `))return n}}throw new f("cannot find end of structure",{toml:s,ptr:r})}function Ae(s,r){let t=s[r],l=t===s[r+1]&&s[r+1]===s[r+2]?s.slice(r,r+3):t;r+=l.length-1;do r=s.indexOf(l,++r);while(r>-1&&t!=="'"&&ar(s,r));return r>-1&&(r+=l.length,l.length>1&&(s[r]===t&&r++,s[r]===t&&r++)),r}let lr=/^(\d{4}-\d{2}-\d{2})?[T ]?(?:(\d{2}):\d{2}(?::\d{2}(?:\.\d+)?)?)?(Z|[-+]\d{2}:\d{2})?$/i;class H extends Date{#s=!1;#r=!1;#e=null;constructor(r){let t=!0,l=!0,o="Z";if(typeof r=="string"){let n=r.match(lr);n?(n[1]||(t=!1,r=`0000-01-01T${r}`),l=!!n[2],l&&r[10]===" "&&(r=r.replace(" ","T")),n[2]&&+n[2]>23?r="":(o=n[3]||null,r=r.toUpperCase(),!o&&l&&(r+="Z"))):r=""}super(r),isNaN(this.getTime())||(this.#s=t,this.#r=l,this.#e=o)}isDateTime(){return this.#s&&this.#r}isLocal(){return!this.#s||!this.#r||!this.#e}isDate(){return this.#s&&!this.#r}isTime(){return this.#r&&!this.#s}isValid(){return this.#s||this.#r}toISOString(){let r=super.toISOString();if(this.isDate())return r.slice(0,10);if(this.isTime())return r.slice(11,23);if(this.#e===null)return r.slice(0,-1);if(this.#e==="Z")return r;let t=+this.#e.slice(1,3)*60+ +this.#e.slice(4,6);return t=this.#e[0]==="-"?t:-t,new Date(this.getTime()-t*6e4).toISOString().slice(0,-1)+this.#e}static wrapAsOffsetDateTime(r,t="Z"){let l=new H(r);return l.#e=t,l}static wrapAsLocalDateTime(r){let t=new H(r);return t.#e=null,t}static wrapAsLocalDate(r){let t=new H(r);return t.#r=!1,t.#e=null,t}static wrapAsLocalTime(r){let t=new H(r);return t.#s=!1,t.#e=null,t}}let ir=/^((0x[0-9a-fA-F](_?[0-9a-fA-F])*)|(([+-]|0[ob])?\d(_?\d)*))$/,cr=/^[+-]?\d(_?\d)*(\.\d(_?\d)*)?([eE][+-]?\d(_?\d)*)?$/,dr=/^[+-]?0[0-9_]/,xr=/^[0-9a-f]{2,8}$/i,Te={b:"\b",t:" ",n:`
18
- `,f:"\f",r:"\r",e:"\x1B",'"':'"',"\\":"\\"};function Me(s,r=0,t=s.length){let l=s[r]==="'",o=s[r++]===s[r]&&s[r]===s[r+1];o&&(t-=2,s[r+=2]==="\r"&&r++,s[r]===`
19
- `&&r++);let n=0,a,c="",i=r;for(;r<t-1;){let d=s[r++];if(d===`
20
- `||d==="\r"&&s[r]===`
21
- `){if(!o)throw new f("newlines are not allowed in strings",{toml:s,ptr:r-1})}else if(d<" "&&d!==" "||d==="")throw new f("control characters are not allowed in strings",{toml:s,ptr:r-1});if(a){if(a=!1,d==="x"||d==="u"||d==="U"){let m=s.slice(r,r+=d==="x"?2:d==="u"?4:8);if(!xr.test(m))throw new f("invalid unicode escape",{toml:s,ptr:n});try{c+=String.fromCodePoint(parseInt(m,16))}catch{throw new f("invalid unicode escape",{toml:s,ptr:n})}}else if(o&&(d===`
22
- `||d===" "||d===" "||d==="\r")){if(r=V(s,r-1,!0),s[r]!==`
23
- `&&s[r]!=="\r")throw new f("invalid escape: only line-ending whitespace may be escaped",{toml:s,ptr:n});r=V(s,r)}else if(d in Te)c+=Te[d];else throw new f("unrecognized escape sequence",{toml:s,ptr:n});i=r}else!l&&d==="\\"&&(n=r-1,a=!0,c+=s.slice(i,n))}return c+s.slice(i,t-1)}function ur(s,r,t,l){if(s==="true")return!0;if(s==="false")return!1;if(s==="-inf")return-1/0;if(s==="inf"||s==="+inf")return 1/0;if(s==="nan"||s==="+nan"||s==="-nan")return NaN;if(s==="-0")return l?0n:0;let o=ir.test(s);if(o||cr.test(s)){if(dr.test(s))throw new f("leading zeroes are not allowed",{toml:r,ptr:t});s=s.replace(/_/g,"");let a=+s;if(isNaN(a))throw new f("invalid number",{toml:r,ptr:t});if(o){if((o=!Number.isSafeInteger(a))&&!l)throw new f("integer value cannot be represented losslessly",{toml:r,ptr:t});(o||l===!0)&&(a=BigInt(s))}return a}const n=new H(s);if(!n.isValid())throw new f("invalid value",{toml:r,ptr:t});return n}function mr(s,r,t){let l=s.slice(r,t),o=l.indexOf("#");return o>-1&&(te(s,o),l=l.slice(0,o)),[l.trimEnd(),o]}function ge(s,r,t,l,o){if(l===0)throw new f("document contains excessively nested structures. aborting.",{toml:s,ptr:r});let n=s[r];if(n==="["||n==="{"){let[i,d]=n==="["?fr(s,r,l,o):hr(s,r,l,o);if(t){if(d=V(s,d),s[d]===",")d++;else if(s[d]!==t)throw new f("expected comma or end of structure",{toml:s,ptr:d})}return[i,d]}let a;if(n==='"'||n==="'"){a=Ae(s,r);let i=Me(s,r,a);if(t){if(a=V(s,a),s[a]&&s[a]!==","&&s[a]!==t&&s[a]!==`
24
- `&&s[a]!=="\r")throw new f("unexpected character encountered",{toml:s,ptr:a});a+=+(s[a]===",")}return[i,a]}a=or(s,r,",",t);let c=mr(s,r,a-+(s[a-1]===","));if(!c[0])throw new f("incomplete key-value declaration: no value specified",{toml:s,ptr:r});return t&&c[1]>-1&&(a=V(s,r+c[1]),a+=+(s[a]===",")),[ur(c[0],s,r,o),a]}let pr=/^[a-zA-Z0-9-_]+[ \t]*$/;function he(s,r,t="="){let l=r-1,o=[],n=s.indexOf(t,r);if(n<0)throw new f("incomplete key-value: cannot find end of key",{toml:s,ptr:r});do{let a=s[r=++l];if(a!==" "&&a!==" ")if(a==='"'||a==="'"){if(a===s[r+1]&&a===s[r+2])throw new f("multiline strings are not allowed in keys",{toml:s,ptr:r});let c=Ae(s,r);if(c<0)throw new f("unfinished string encountered",{toml:s,ptr:r});l=s.indexOf(".",c);let i=s.slice(c,l<0||l>n?n:l),d=pe(i);if(d>-1)throw new f("newlines are not allowed in keys",{toml:s,ptr:r+l+d});if(i.trimStart())throw new f("found extra tokens after the string part",{toml:s,ptr:c});if(n<c&&(n=s.indexOf(t,c),n<0))throw new f("incomplete key-value: cannot find end of key",{toml:s,ptr:r});o.push(Me(s,r,c))}else{l=s.indexOf(".",r);let c=s.slice(r,l<0||l>n?n:l);if(!pr.test(c))throw new f("only letter, numbers, dashes and underscores are allowed in keys",{toml:s,ptr:r});o.push(c.trimEnd())}}while(l+1&&l<n);return[o,V(s,n+1,!0,!0)]}function hr(s,r,t,l){let o={},n=new Set,a;for(r++;(a=s[r++])!=="}"&&a;){if(a===",")throw new f("expected value, found comma",{toml:s,ptr:r-1});if(a==="#")r=te(s,r);else if(a!==" "&&a!==" "&&a!==`
25
- `&&a!=="\r"){let c,i=o,d=!1,[m,p]=he(s,r-1);for(let h=0;h<m.length;h++){if(h&&(i=d?i[c]:i[c]={}),c=m[h],(d=Object.hasOwn(i,c))&&(typeof i[c]!="object"||n.has(i[c])))throw new f("trying to redefine an already defined value",{toml:s,ptr:r});!d&&c==="__proto__"&&Object.defineProperty(i,c,{enumerable:!0,configurable:!0,writable:!0})}if(d)throw new f("trying to redefine an already defined value",{toml:s,ptr:r});let[x,j]=ge(s,p,"}",t-1,l);n.add(x),i[c]=x,r=j}}if(!a)throw new f("unfinished table encountered",{toml:s,ptr:r});return[o,r]}function fr(s,r,t,l){let o=[],n;for(r++;(n=s[r++])!=="]"&&n;){if(n===",")throw new f("expected value, found comma",{toml:s,ptr:r-1});if(n==="#")r=te(s,r);else if(n!==" "&&n!==" "&&n!==`
26
- `&&n!=="\r"){let a=ge(s,r-1,"]",t-1,l);o.push(a[0]),r=a[1]}}if(!n)throw new f("unfinished array encountered",{toml:s,ptr:r});return[o,r]}function Ee(s,r,t,l){let o=r,n=t,a,c=!1,i;for(let d=0;d<s.length;d++){if(d){if(o=c?o[a]:o[a]={},n=(i=n[a]).c,l===0&&(i.t===1||i.t===2))return null;if(i.t===2){let m=o.length-1;o=o[m],n=n[m].c}}if(a=s[d],(c=Object.hasOwn(o,a))&&n[a]?.t===0&&n[a]?.d)return null;c||(a==="__proto__"&&(Object.defineProperty(o,a,{enumerable:!0,configurable:!0,writable:!0}),Object.defineProperty(n,a,{enumerable:!0,configurable:!0,writable:!0})),n[a]={t:d<s.length-1&&l===2?3:l,d:!1,i:0,c:{}})}if(i=n[a],i.t!==l&&!(l===1&&i.t===3)||(l===2&&(i.d||(i.d=!0,o[a]=[]),o[a].push(o={}),i.c[i.i++]=i={t:1,d:!1,i:0,c:{}}),i.d))return null;if(i.d=!0,l===1)o=c?o[a]:o[a]={};else if(l===0&&c)return null;return[a,o,i.c]}function gr(s,{maxDepth:r=1e3,integersAsBigInt:t}={}){let l={},o={},n=l,a=o;for(let c=V(s,0);c<s.length;){if(s[c]==="["){let i=s[++c]==="[",d=he(s,c+=+i,"]");if(i){if(s[d[1]-1]!=="]")throw new f("expected end of table declaration",{toml:s,ptr:d[1]-1});d[1]++}let m=Ee(d[0],l,o,i?2:1);if(!m)throw new f("trying to redefine an already defined table or value",{toml:s,ptr:c});a=m[2],n=m[1],c=d[1]}else{let i=he(s,c),d=Ee(i[0],n,a,0);if(!d)throw new f("trying to redefine an already defined table or value",{toml:s,ptr:c});let m=ge(s,i[1],void 0,r,t);d[1][d[0]]=m[0],c=m[1]}if(c=V(s,c,!0),s[c]&&s[c]!==`
27
- `&&s[c]!=="\r")throw new f("each key-value declaration must be followed by an end-of-line",{toml:s,ptr:c});c=V(s,c)}return l}function jr(s){return typeof s=="object"&&s!==null&&!Array.isArray(s)}function vr(s){if(!s.trim())return{};const t=gr(s);if(!jr(t))throw new Error("TOML root must be a table.");return t}function Re(s){try{return{config:vr(s),parseError:null}}catch(r){return{config:null,parseError:r.message}}}async function br(){const s=await fetch(se("/codex/diagnostics"));if(!s.ok)throw new Error("Failed to fetch Codex diagnostics");return s.json()}async function wr(){const s=await fetch(se("/codex/config/raw"));if(!s.ok)throw new Error("Failed to fetch Codex raw config");return s.json()}async function Nr(s){const r=await fetch(se("/codex/config/raw"),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(r.status===409)throw new Pe("Codex raw config changed externally");if(!r.ok){const t=await r.json().catch(()=>null);throw new Error(t?.error||"Failed to save Codex raw config")}return r.json()}async function yr(s){const r=await fetch(se("/codex/config/patch"),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(r.status===409)throw new Pe("Codex config changed externally");if(!r.ok){const t=await r.json().catch(()=>null);throw new Error(t?.error||"Failed to patch Codex config")}return r.json()}function Cr(){const s=ws(),r=ye({queryKey:["codex-diagnostics"],queryFn:br,refetchInterval:1e4}),t=ye({queryKey:["codex-raw-config"],queryFn:wr}),l=Ce({mutationFn:Nr,onSuccess:(n,a)=>{s.setQueryData(["codex-raw-config"],c=>{const i=c?.path??"$CODEX_HOME/config.toml",d=c?.resolvedPath??i,m=Re(a.rawText);return{path:i,resolvedPath:d,exists:!0,mtime:n.mtime,rawText:a.rawText,config:m.config,parseError:m.parseError,readError:null}}),s.invalidateQueries({queryKey:["codex-diagnostics"]})}}),o=Ce({mutationFn:yr,onSuccess:n=>{s.setQueryData(["codex-raw-config"],n),s.invalidateQueries({queryKey:["codex-diagnostics"]})}});return N.useMemo(()=>({diagnostics:r.data,diagnosticsLoading:r.isLoading,diagnosticsError:r.error,refetchDiagnostics:r.refetch,rawConfig:t.data,rawConfigLoading:t.isLoading,rawConfigError:t.error,refetchRawConfig:t.refetch,saveRawConfig:l.mutate,saveRawConfigAsync:l.mutateAsync,isSavingRawConfig:l.isPending,patchConfig:o.mutate,patchConfigAsync:o.mutateAsync,isPatchingConfig:o.isPending}),[r.data,r.isLoading,r.error,r.refetch,t.data,t.isLoading,t.error,t.refetch,l.mutate,l.mutateAsync,l.isPending,o.mutate,o.mutateAsync,o.isPending])}const Sr=[{label:"Start Default",command:"ccs",description:"Launch Claude with default profile"},{label:"GLM Profile",command:"ccs glm",description:"Switch to GLM model"},{label:"Health Check",command:"ccs doctor",description:"Run system diagnostics"},{label:"Delegate Task",command:'ccs glm -p "your task"',description:"Delegate to GLM profile"}];function _r({snippets:s=Sr}){const[r,t]=N.useState(null),{t:l}=E(),o=async(n,a)=>{await navigator.clipboard.writeText(n),t(a),setTimeout(()=>t(null),2e3)};return e.jsxs(I,{children:[e.jsx(F,{className:"pb-3",children:e.jsxs(W,{className:"text-lg flex items-center gap-2",children:[e.jsx(xs,{className:"w-5 h-5 text-muted-foreground"}),l("quickCommands.title")]})}),e.jsx(K,{children:e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-2",children:s.map((n,a)=>e.jsxs("div",{className:Oe("group flex items-center justify-between gap-2 px-3 py-2","rounded-lg border bg-muted/30 hover:bg-muted/50 transition-colors"),children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:n.label}),e.jsx("code",{className:"text-sm font-mono font-medium truncate block",children:n.command})]}),e.jsx(C,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0 opacity-0 group-hover:opacity-100 transition-opacity",onClick:()=>o(n.command,a),title:n.description,children:r===a?e.jsx(us,{className:"h-4 w-4 text-green-600"}):e.jsx(ms,{className:"h-4 w-4"})})]},a))})})]})}function kr(s){return!s||!Number.isFinite(s)?"N/A":new Date(s).toLocaleString()}function Tr(s){return!s||s<=0?"0 B":s<1024?`${s} B`:s<1024*1024?`${(s/1024).toFixed(1)} KB`:`${(s/(1024*1024)).toFixed(2)} MB`}function k({label:s,value:r,mono:t=!1}){return e.jsxs("div",{className:"flex items-start justify-between gap-3 text-sm",children:[e.jsx("span",{className:"text-muted-foreground shrink-0",children:s}),e.jsx("span",{className:Oe("text-right break-all",t&&"font-mono text-xs"),children:r})]})}function Er({diagnostics:s}){const{t:r}=E(),t=s.config.activeProfile?`codex --profile ${s.config.activeProfile}`:"codex",l=s.binary.supportsConfigOverrides;return e.jsx(fe,{className:"h-full",children:e.jsxs("div",{className:"space-y-4 pr-1",children:[e.jsxs(I,{children:[e.jsx(F,{className:"pb-2",children:e.jsxs(W,{className:"flex items-center gap-2 text-base",children:[e.jsx(ps,{className:"h-4 w-4"}),r("codex.howCodexWorks")]})}),e.jsx(K,{className:"text-sm text-muted-foreground",children:e.jsxs("ul",{className:"ml-4 list-disc space-y-1.5 [&>li]:pl-1",children:[e.jsx("li",{children:r("codex.nativeDesc")}),e.jsxs("li",{children:[e.jsx("strong",{children:r("codex.nativeConfigLabel")})," ",r("codex.nativeConfigDesc")]}),e.jsxs("li",{children:[e.jsx("strong",{children:r("codex.transientOverridesLabel")})," ",r("codex.transientOverridesDesc")]}),e.jsxs("li",{children:[e.jsx("strong",{children:r("codex.cliproxyDefaultLabel")})," ",r("codex.cliproxyDefaultDesc")]}),e.jsx("li",{children:r("codex.apiProfilesDefault")})]})})]}),e.jsxs(I,{children:[e.jsx(F,{className:"pb-2",children:e.jsxs(W,{className:"flex items-center gap-2 text-base",children:[e.jsx(hs,{className:"h-4 w-4"}),r("codex.runtimeInstall")]})}),e.jsxs(K,{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:r("codex.status")}),e.jsx(_,{variant:s.binary.installed?"default":"secondary",children:s.binary.installed?r("codex.detected"):r("codex.notFound")})]}),e.jsx(k,{label:r("codex.detectionSource"),value:s.binary.source,mono:!0}),e.jsx(k,{label:r("codex.binaryPath"),value:s.binary.path||r("codex.notFound"),mono:!0}),e.jsx(k,{label:r("codex.installDirectory"),value:s.binary.installDir||"N/A",mono:!0}),e.jsx(k,{label:r("codex.versionLabel"),value:s.binary.version||"Unknown",mono:!0}),e.jsx(k,{label:r("codex.nativeAliases"),value:"ccs-codex, ccsx",mono:!0}),e.jsx(k,{label:r("codex.ccsProviderShortcut"),value:"ccsxp",mono:!0}),e.jsxs("div",{className:"flex items-center justify-between rounded-md border px-3 py-2",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:r("codex.configOverrideSupport")}),e.jsx(_,{variant:s.binary.supportsConfigOverrides?"default":"secondary",children:s.binary.supportsConfigOverrides?r("codex.available"):r("codex.missing")})]})]})]}),e.jsxs(I,{children:[e.jsx(F,{className:"pb-2",children:e.jsxs(W,{className:"flex items-center gap-2 text-base",children:[e.jsx(Ne,{className:"h-4 w-4"}),r("codex.cliproxyNativeCodex")]})}),e.jsx(K,{className:"space-y-3 text-sm text-muted-foreground",children:l?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("p",{children:e.jsx("strong",{children:r("codex.twoSupportedPaths")})}),e.jsxs("ul",{className:"ml-4 list-disc space-y-1 [&>li]:pl-1",children:[e.jsxs("li",{children:[e.jsx("strong",{children:r("codex.builtInLabel")})," ",r("codex.builtInCcsxpDesc")]}),e.jsxs("li",{children:[e.jsx("strong",{children:r("codex.nativeRecipeLabel")})," ",r("codex.nativeRecipeDesc")]})]})]}),e.jsxs("div",{className:"rounded-md border bg-muted/20 p-3",children:[e.jsx("p",{className:"font-medium text-foreground",children:r("codex.codexNativeRecipe")}),e.jsx("pre",{className:"mt-2 overflow-x-auto rounded-md bg-background p-3 text-xs text-foreground",children:De})]}),e.jsxs("ol",{className:"ml-4 list-decimal space-y-1.5 [&>li]:pl-1",children:[e.jsx("li",{children:r("codex.saveProviderNamedCliproxy")}),e.jsx("li",{children:r("codex.inTopLevelSetDefault")}),e.jsx("li",{children:r("codex.exportCliproxyApiKey")})]})]}):e.jsx("p",{children:r("codex.noConfigOverrides")})})]}),e.jsxs(I,{children:[e.jsx(F,{className:"pb-2",children:e.jsxs(W,{className:"flex items-center gap-2 text-base",children:[e.jsx(fs,{className:"h-4 w-4"}),r("codex.configFile")]})}),e.jsx(K,{className:"space-y-3",children:e.jsxs("div",{className:"rounded-md border p-3 space-y-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("span",{className:"font-medium text-sm",children:r("codex.userConfig")}),s.file.exists?e.jsx(gs,{className:"h-4 w-4 text-green-600"}):e.jsx(js,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsx(k,{label:r("codex.path"),value:s.file.path,mono:!0}),e.jsx(k,{label:r("codex.resolved"),value:s.file.resolvedPath,mono:!0}),e.jsx(k,{label:r("codex.size"),value:Tr(s.file.sizeBytes)}),e.jsx(k,{label:r("codex.lastModified"),value:kr(s.file.mtimeMs)}),s.file.parseError&&e.jsxs("p",{className:"text-xs text-amber-600",children:[r("codex.tomlWarning"),": ",s.file.parseError]}),s.file.readError&&e.jsxs("p",{className:"text-xs text-destructive",children:[r("codex.readWarning"),": ",s.file.readError]})]})})]}),e.jsxs(I,{children:[e.jsx(F,{className:"pb-2",children:e.jsxs(W,{className:"flex items-center gap-2 text-base",children:[e.jsx(me,{className:"h-4 w-4"}),r("codex.currentUserLayerSummary")]})}),e.jsxs(K,{className:"space-y-3",children:[e.jsx(k,{label:r("codex.model"),value:s.config.model||r("codex.notSet"),mono:!0}),e.jsx(k,{label:r("codex.defaultProvider"),value:s.config.modelProvider||r("codex.notSet"),mono:!0}),e.jsx(k,{label:r("codex.activeProfile"),value:s.config.activeProfile||r("codex.notSet"),mono:!0}),e.jsx(k,{label:r("codex.approvalPolicy"),value:s.config.approvalPolicy||r("codex.notSet"),mono:!0}),e.jsx(k,{label:r("codex.sandboxMode"),value:s.config.sandboxMode||r("codex.notSet"),mono:!0}),e.jsx(k,{label:r("codex.webSearch"),value:s.config.webSearch||r("codex.notSet"),mono:!0}),e.jsx(ee,{}),e.jsxs("div",{className:"grid grid-cols-2 gap-2 text-xs",children:[e.jsx(_,{variant:"outline",className:"justify-center",children:r("codex.providersCount",{count:s.config.modelProviderCount})}),e.jsx(_,{variant:"outline",className:"justify-center",children:r("codex.profilesCount",{count:s.config.profileCount})}),e.jsx(_,{variant:"outline",className:"justify-center",children:r("codex.enabledFeaturesCount",{count:s.config.enabledFeatures.length})}),e.jsx(_,{variant:"outline",className:"justify-center",children:r("codex.mcpServersCount",{count:s.config.mcpServerCount})})]}),s.config.topLevelKeys.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-xs uppercase tracking-wide text-muted-foreground",children:r("codex.userLayerKeysPresent")}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:s.config.topLevelKeys.map(o=>e.jsx(_,{variant:"secondary",className:"font-mono text-[10px]",children:o},o))})]})]})]}),e.jsx(_r,{snippets:[{label:r("codex.nativeShortAlias"),command:"ccsx",description:"Launch the short native Codex runtime alias."},{label:r("codex.ccsCodexShortcut"),command:'ccsxp "your prompt"',description:l?r("codex.runBuiltInCodex"):"Requires a Codex build that exposes --config overrides."},{label:r("codex.explicitProviderRoute"),command:'ccs codex --target codex "your prompt"',description:l?r("codex.runBuiltInCodexExplicit"):"Requires a Codex build that exposes --config overrides."},{label:s.config.activeProfile?"Inspect active profile":r("codex.openNativeCodex"),command:t,description:s.config.activeProfile?"Inspect the active named profile directly in native Codex.":"Open native Codex without forcing a named profile overlay."}]}),e.jsxs(I,{children:[e.jsx(F,{className:"pb-2",children:e.jsxs(W,{className:"flex items-center gap-2 text-base",children:[e.jsx(Ne,{className:"h-4 w-4"}),r("codex.runtimeVsProvider")]})}),e.jsxs(K,{className:"grid gap-3 md:grid-cols-2",children:[e.jsxs("div",{className:"flex flex-col rounded-md border p-3 text-sm",children:[e.jsx("p",{className:"font-medium text-foreground",children:r("codex.nativeCodexRuntime")}),e.jsxs("ul",{className:"mt-2 flex-grow list-disc space-y-1.5 pl-4 text-muted-foreground [&>li]:pl-1",children:[e.jsx("li",{children:e.jsx("code",{children:"ccs-codex"})}),e.jsx("li",{children:e.jsx("code",{children:"ccsx"})}),e.jsx("li",{children:e.jsx("code",{children:"--target codex"})})]}),e.jsx(_,{variant:"secondary",className:"mt-4 w-fit justify-center font-normal",children:r("codex.honorsSavedNativeConfig")})]}),e.jsxs("div",{className:"flex flex-col rounded-md border p-3 text-sm",children:[e.jsx("p",{className:"font-medium text-foreground",children:r("codex.ccsCodexProvider")}),l?e.jsxs(e.Fragment,{children:[e.jsxs("ul",{className:"mt-2 flex-grow list-disc space-y-1.5 pl-4 text-muted-foreground [&>li]:pl-1",children:[e.jsx("li",{children:e.jsx("code",{children:"ccsxp"})}),e.jsx("li",{children:e.jsx("code",{children:"ccs codex --target codex"})})]}),e.jsx(_,{variant:"secondary",className:"mt-4 w-fit justify-center font-normal",children:r("codex.usesTransientOverrides")})]}):e.jsx("p",{className:"mt-2 text-muted-foreground",children:r("codex.unavailableNoConfig")})]})]})]}),e.jsxs(I,{children:[e.jsx(F,{className:"pb-2",children:e.jsx(W,{className:"text-base",children:r("codex.supportedFlows")})}),e.jsx(K,{children:e.jsxs(Ns,{children:[e.jsx(ys,{children:e.jsxs(Se,{children:[e.jsx(le,{children:r("codex.flow")}),e.jsx(le,{children:r("codex.status")}),e.jsx(le,{children:r("codex.notes")})]})}),e.jsx(Cs,{children:s.supportMatrix.map(o=>e.jsxs(Se,{children:[e.jsx(ie,{className:"font-mono text-xs",children:o.label}),e.jsx(ie,{children:e.jsx(_,{variant:o.supported?"default":"secondary",children:o.supported?r("codex.yes"):r("codex.no")})}),e.jsx(ie,{className:"text-xs text-muted-foreground",children:o.notes})]},o.id))})]})})]}),s.warnings.length>0&&e.jsxs(I,{className:"border-amber-200 bg-amber-50/50 dark:bg-amber-950/20",children:[e.jsx(F,{className:"pb-2",children:e.jsxs(W,{className:"flex items-center gap-2 text-base",children:[e.jsx(vs,{className:"h-4 w-4 text-amber-600"}),r("codex.warningsTitle")]})}),e.jsx(K,{className:"space-y-1.5",children:s.warnings.map(o=>e.jsxs("p",{className:"text-sm text-amber-800 dark:text-amber-300",children:["- ",o]},o))})]})]})})}function Ur(){const{t:s}=E(),r=zs(),{diagnostics:t,diagnosticsLoading:l,diagnosticsError:o,refetchDiagnostics:n,rawConfig:a,rawConfigLoading:c,rawConfigError:i,refetchRawConfig:d,saveRawConfigAsync:m,isSavingRawConfig:p,patchConfigAsync:x,isPatchingConfig:j}=Cr(),[h,w]=N.useState(null),M=a?.rawText??"",q=h??M,u=h!==null&&h!==M,v=Re(q),G=v.parseError?{valid:!1,error:v.parseError}:{valid:!0},g=a?.config??null,Ie=c||!a||u||a?.parseError!==null||a?.readError!==null,Fe=i?"Structured controls unavailable: failed to load the current config.toml.":a?.readError?`Structured controls unavailable: ${a.readError}`:u?G.valid?"Save or discard raw TOML edits before using structured controls.":"Fix or discard raw TOML edits before using structured controls.":a?.parseError?`Structured controls disabled: ${a.parseError}`:null,We=N.useMemo(()=>Le(g),[g]),Ke=N.useMemo(()=>Xs(g),[g]),qe=N.useMemo(()=>Ys(g),[g]),Ue=N.useMemo(()=>Hs(g),[g]),Ve=N.useMemo(()=>Qs(g),[g]),Be=N.useMemo(()=>Js(g),[g]),Ge=R=>{if(R===M){w(null);return}w(R)},$e=async()=>{try{if((await Promise.all([n(),d()])).some($=>!$||$.status==="error"||$.isError||$.error)){U.error(s("toasts.codexRefreshFailed"));return}w(null)}catch(R){U.error(R.message||s("toasts.codexRefreshError"))}},ze=async()=>{if(!G.valid){U.error(s("toasts.codexFixToml"));return}try{await m({rawText:q,expectedMtime:a?.exists?a.mtime:void 0}),w(null),U.success(s("toasts.codexSaved")),await n()}catch(R){be(R)?U.error(s("toasts.codexChangedExternally")):U.error(R.message||s("toasts.codexSaveFailed"))}},Xe=async(R,je)=>{try{await x({...R,expectedMtime:a?.exists?a.mtime:void 0}),w(null),U.success(je)}catch($){be($)?U.error(s("toasts.codexChangedExternally")):U.error($.message||s("toasts.codexUpdateFailed"))}},ne="mt-0 h-full border-0 p-0 data-[state=inactive]:hidden",Ye=()=>l?e.jsxs("div",{className:"flex h-full items-center justify-center text-muted-foreground",children:[e.jsx(z,{className:"mr-2 h-5 w-5 animate-spin"}),"Loading Codex diagnostics..."]}):o||!t?e.jsx("div",{className:"flex h-full items-center justify-center px-6 text-center text-destructive",children:"Failed to load Codex diagnostics."}):e.jsxs(Je,{defaultValue:"overview",className:"flex h-full flex-col",children:[e.jsx("div",{className:"shrink-0 px-4 pt-4",children:e.jsxs(Ze,{className:"grid w-full grid-cols-3",children:[e.jsx(ae,{value:"overview",children:s("codexPage.overview")}),e.jsx(ae,{value:"controls",children:s("codexPage.controlCenter")}),e.jsx(ae,{value:"docs",children:s("codexPage.docs")})]})}),e.jsxs("div",{className:"flex-1 min-h-0 overflow-hidden px-4 pb-4 pt-3",children:[e.jsx(oe,{value:"overview",className:ne,children:e.jsx(Er,{diagnostics:t})}),e.jsx(oe,{value:"controls",className:ne,children:e.jsx(Gs,{workspacePath:t.workspacePath,activeProfile:t.config.activeProfile,topLevelSettings:We,projectTrustEntries:Ke,profileEntries:qe,modelProviderEntries:Ue,mcpServerEntries:Ve,featureCatalog:r,featureState:Be,disabled:Ie,disabledReason:Fe,saving:j,onPatch:Xe})}),e.jsx(oe,{value:"docs",className:ne,children:e.jsx(rr,{diagnostics:t})})]})]});return e.jsx("div",{className:"h-full min-h-0 overflow-hidden",children:e.jsxs(He,{direction:"horizontal",className:"h-full",children:[e.jsx(ve,{defaultSize:45,minSize:35,children:e.jsx("div",{className:"h-full border-r bg-muted/20",children:Ye()})}),e.jsx(Qe,{className:"group flex w-2 cursor-col-resize items-center justify-center bg-border transition-colors hover:bg-primary/20",children:e.jsx(bs,{className:"h-3 w-3 text-muted-foreground group-hover:text-primary"})}),e.jsx(ve,{defaultSize:55,minSize:35,children:e.jsx(Ss,{title:"Codex config.toml",pathLabel:a?.path||t?.file.path||"$CODEX_HOME/config.toml",loading:c,parseWarning:G.valid?a?.parseError:G.error,readWarning:a?.readError,value:q,dirty:u,readOnly:!!a?.readError,saving:p,saveDisabled:!u||p||c||!G.valid||!!a?.readError,onChange:R=>{Ge(R)},onSave:ze,onRefresh:$e,onDiscard:()=>w(null),language:"toml",loadingLabel:"Loading config.toml...",parseWarningLabel:"TOML warning",ownershipNotice:e.jsxs("div",{className:"rounded-md border border-amber-200 bg-amber-50/60 px-3 py-2 text-sm text-amber-900 dark:bg-amber-950/20 dark:text-amber-300",children:[e.jsx("p",{className:"font-medium",children:"This file is upstream-owned by Codex CLI."}),e.jsxs("p",{children:["CCS does not keep ",e.jsx("code",{children:"~/.codex/config.toml"})," in sync for you."]}),e.jsxs("p",{children:["CCS-backed Codex launches may apply transient ",e.jsx("code",{children:"-c"})," overrides and",e.jsx("code",{children:" CCS_CODEX_API_KEY"}),"; those effective values may not appear here."]})]})})})]})})}export{Ur as CodexPage};
@@ -1 +0,0 @@
1
- import{j as e}from"./radix-ui-Zb8sVEtn.js";import{a as N,c as l,d as p,M as k,N as C,O as S,B as R,S as h}from"./index-2X8-14xr.js";import{u as W,a as E,b as O}from"./tanstack-CrmUhA7Z.js";import{t as g}from"./notifications-B2HqRBj7.js";import{r as j}from"./react-vendor-CNOkPC89.js";import{b6 as y,C as P,$ as I,o as M,Z as T,i as $,U as H,e as A,ab as z,s as F,Y as B,R as D}from"./icons-DyorC3Xk.js";import"./utils-CzKF5WmX.js";import"./form-utils-Bcoyqxpq.js";import"./code-highlight-BRUf_pqB.js";const q={sm:{dimension:80,strokeWidth:6,fontSize:"text-lg",labelSize:"text-[10px]"},md:{dimension:120,strokeWidth:8,fontSize:"text-3xl",labelSize:"text-xs"},lg:{dimension:160,strokeWidth:10,fontSize:"text-4xl",labelSize:"text-sm"}},G={ok:{stroke:"#22C55E",glow:"rgba(34, 197, 94, 0.4)"},warning:{stroke:"#EAB308",glow:"rgba(234, 179, 8, 0.4)"},error:{stroke:"#EF4444",glow:"rgba(239, 68, 68, 0.4)"}};function K({passed:s,total:t,status:a,size:r="md"}){const{t:i}=N(),o=q[r],c=G[a],n=t>0?Math.round(s/t*100):0,d=(o.dimension-o.strokeWidth)/2,u=2*Math.PI*d,f=u-n/100*u,x=o.dimension/2;return e.jsxs("div",{className:"relative inline-flex items-center justify-center",children:[e.jsxs("svg",{width:o.dimension,height:o.dimension,className:"transform -rotate-90",style:{filter:`drop-shadow(0 0 8px ${c.glow})`},children:[e.jsx("circle",{cx:x,cy:x,r:d,fill:"none",stroke:"currentColor",strokeWidth:o.strokeWidth,className:"text-muted/30"}),e.jsx("circle",{cx:x,cy:x,r:d,fill:"none",stroke:c.stroke,strokeWidth:o.strokeWidth,strokeLinecap:"round",strokeDasharray:u,strokeDashoffset:f,className:"transition-all duration-1000 ease-out"}),n>0&&e.jsx("circle",{cx:x+d*Math.cos(n/100*2*Math.PI-Math.PI/2),cy:x+d*Math.sin(n/100*2*Math.PI-Math.PI/2),r:o.strokeWidth/2,fill:c.stroke,className:"animate-pulse",style:{filter:`drop-shadow(0 0 4px ${c.glow})`}})]}),e.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center",children:[e.jsx("span",{className:l("font-mono font-bold tracking-tight",o.fontSize),children:n}),e.jsx("span",{className:l("font-mono uppercase tracking-widest text-muted-foreground",o.labelSize),children:i("health.healthLabel")})]})]})}function b({label:s,value:t,color:a,bgColor:r}){return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:l("w-2 h-2 rounded-full animate-pulse",r)}),e.jsx("span",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:s}),e.jsx("span",{className:l("font-mono font-bold text-sm",a),children:t})]})}function L({total:s,passed:t,warnings:a,errors:r,info:i}){const{t:o}=N(),c=t/s*100,n=a/s*100,d=r/s*100,u=i/s*100;return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"h-2 rounded-full overflow-hidden bg-muted/50 flex",children:[d>0&&e.jsx("div",{className:"h-full bg-red-500 transition-all duration-500",style:{width:`${d}%`}}),n>0&&e.jsx("div",{className:"h-full bg-yellow-500 transition-all duration-500",style:{width:`${n}%`}}),u>0&&e.jsx("div",{className:"h-full bg-blue-500 transition-all duration-500",style:{width:`${u}%`}}),c>0&&e.jsx("div",{className:"h-full bg-green-500 transition-all duration-500",style:{width:`${c}%`}})]}),e.jsxs("div",{className:"flex items-center justify-between gap-4 flex-wrap",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:o("health.checks")}),e.jsx("span",{className:"font-mono font-bold text-lg",children:s})]}),e.jsxs("div",{className:"flex items-center gap-4 flex-wrap",children:[e.jsx(b,{label:"OK",value:t,color:"text-green-500",bgColor:"bg-green-500"}),e.jsx(b,{label:"WARN",value:a,color:"text-yellow-500",bgColor:"bg-yellow-500"}),e.jsx(b,{label:"ERR",value:r,color:"text-red-500",bgColor:"bg-red-500"}),e.jsx(b,{label:"INFO",value:i,color:"text-blue-500",bgColor:"bg-blue-500"})]})]})]})}function Q(){return W({queryKey:["health"],queryFn:async()=>(await fetch("/api/health")).json(),refetchInterval:3e4})}function U(){const s=E();return O({mutationFn:async t=>{const a=await fetch(`/api/health/fix/${t}`,{method:"POST"}),r=await a.json();if(!a.ok)throw new Error(r.message);return r},onSuccess:t=>{s.invalidateQueries({queryKey:["health"]}),g.success(t.message)},onError:t=>{g.error(t.message)}})}const Z={ok:{dot:"bg-green-500",label:"OK",labelColor:"text-green-500"},warning:{dot:"bg-yellow-500",label:"WARN",labelColor:"text-yellow-500"},error:{dot:"bg-red-500",label:"ERR",labelColor:"text-red-500"},info:{dot:"bg-blue-500",label:"INFO",labelColor:"text-blue-500"}};function Y({check:s}){const{t}=N(),a=U(),r=Z[s.status],[i,o]=j.useState(!1),c=s.details||s.fix,n=d=>{navigator.clipboard.writeText(d),g.success(t("health.copied"))};return c?e.jsx(k,{open:i,onOpenChange:o,children:e.jsxs("div",{className:l("group rounded-lg border transition-all duration-150",i?"border-border bg-muted/30":"border-transparent hover:border-border/50 hover:bg-muted/50"),children:[e.jsx(C,{asChild:!0,children:e.jsxs("button",{className:"w-full flex items-center gap-3 px-3 py-2 text-left",children:[e.jsxs("div",{className:"relative flex items-center justify-center w-4 h-4",children:[e.jsx("div",{className:l("w-2 h-2 rounded-full",r.dot)}),s.status!=="ok"&&e.jsx("div",{className:l("absolute w-2 h-2 rounded-full animate-ping opacity-75",r.dot)})]}),e.jsx("span",{className:"flex-1 text-sm font-medium truncate",children:s.name}),e.jsxs("span",{className:l("font-mono text-xs font-semibold",r.labelColor),children:["[",r.label,"]"]}),e.jsx(P,{className:l("w-4 h-4 text-muted-foreground transition-transform duration-200",i&&"rotate-90")})]})}),e.jsx(S,{children:e.jsxs("div",{className:"px-3 pb-3 pt-1 space-y-2 ml-7",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:s.message}),s.details&&e.jsx("pre",{className:"text-xs font-mono text-muted-foreground bg-background/50 rounded p-2 overflow-x-auto border border-border/50",children:s.details}),s.fix&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"flex-1 flex items-center gap-2 bg-background/50 rounded px-2 py-1.5 border border-border/50",children:[e.jsx(I,{className:"w-3 h-3 text-muted-foreground shrink-0"}),e.jsx("code",{className:"text-xs font-mono flex-1 truncate",children:s.fix}),e.jsx(p,{variant:"ghost",size:"sm",onClick:()=>s.fix&&n(s.fix),className:"h-5 w-5 p-0",children:e.jsx(M,{className:"w-3 h-3"})})]}),s.fixable&&s.status!=="ok"&&e.jsxs(p,{size:"sm",onClick:()=>a.mutate(s.id),disabled:a.isPending,className:"h-7 px-3 text-xs",children:[e.jsx(y,{className:"w-3 h-3 mr-1"}),t("health.applyFix")]})]})]})})]})}):e.jsxs("div",{className:l("group flex items-center gap-3 px-3 py-2 rounded-lg","hover:bg-muted/50 transition-colors duration-150","border border-transparent hover:border-border/50"),children:[e.jsxs("div",{className:"relative flex items-center justify-center w-4 h-4",children:[e.jsx("div",{className:l("w-2 h-2 rounded-full",r.dot)}),s.status!=="ok"&&e.jsx("div",{className:l("absolute w-2 h-2 rounded-full animate-ping opacity-75",r.dot)})]}),e.jsx("span",{className:"flex-1 text-sm font-medium truncate",children:s.name}),e.jsxs("span",{className:l("font-mono text-xs font-semibold",r.labelColor),children:["[",r.label,"]"]}),s.fixable&&s.status!=="ok"&&e.jsxs(p,{size:"sm",variant:"ghost",onClick:()=>a.mutate(s.id),disabled:a.isPending,className:"h-6 px-2 text-xs opacity-0 group-hover:opacity-100 transition-opacity",children:[e.jsx(y,{className:"w-3 h-3 mr-1"}),t("health.fix")]})]})}const J={Monitor:z,Settings:A,Users:H,Shield:$,Zap:T};function V({group:s,defaultOpen:t=!0}){const[a,r]=j.useState(t),i=J[s.icon]||z,o=s.checks.filter(m=>m.status==="ok").length,c=s.checks.length,n=s.checks.some(m=>m.status==="error"),d=s.checks.some(m=>m.status==="warning"),u=Math.round(o/c*100),f=n?"text-red-500":d?"text-yellow-500":"text-green-500",x=n?"bg-red-500":d?"bg-yellow-500":"bg-green-500";return e.jsx(k,{open:a,onOpenChange:r,children:e.jsxs("div",{className:l("rounded-lg border transition-all duration-200",n?"border-red-500/30":d?"border-yellow-500/30":"border-border"),children:[e.jsx(C,{asChild:!0,children:e.jsxs("button",{className:l("w-full flex items-center gap-3 p-3 text-left rounded-lg","hover:bg-muted/50 transition-colors duration-150",a&&"rounded-b-none border-b border-border/50"),children:[e.jsx("div",{className:l("p-1.5 rounded-md",n?"bg-red-500/10 text-red-500":d?"bg-yellow-500/10 text-yellow-500":"bg-muted text-muted-foreground"),children:e.jsx(i,{className:"w-4 h-4"})}),e.jsx("span",{className:"flex-1 text-sm font-semibold",children:s.name}),!a&&e.jsx("div",{className:"flex items-center gap-2",children:e.jsx("div",{className:"w-16 h-1.5 rounded-full bg-muted overflow-hidden",children:e.jsx("div",{className:l("h-full transition-all duration-500",x),style:{width:`${u}%`}})})}),e.jsxs("span",{className:l("font-mono text-xs font-semibold",f),children:[o,"/",c]}),e.jsx(F,{className:l("w-4 h-4 text-muted-foreground transition-transform duration-200",a&&"rotate-180")})]})}),e.jsx(S,{children:e.jsx("div",{className:"p-2 space-y-0.5",children:s.checks.map(m=>e.jsx(Y,{check:m},m.id))})})]})})}function X(s){return s.errors>0?"error":s.warnings>0?"warning":"ok"}function _(s,t){const a=Math.floor((Date.now()-s)/1e3);if(a<5)return t("health.justNow");if(a<60)return t("health.secondsAgo",{count:a});const r=Math.floor(a/60);if(r<60)return t("health.minutesAgo",{count:r});const i=Math.floor(r/60);return t("health.hoursAgo",{count:i})}function ee(s){return[...s].sort((t,a)=>{const r=t.checks.filter(n=>n.status==="error").length,i=a.checks.filter(n=>n.status==="error").length,o=t.checks.filter(n=>n.status==="warning").length,c=a.checks.filter(n=>n.status==="warning").length;return r!==i?i-r:c-o})}function se(){return e.jsxs("div",{className:"font-mono text-sm text-muted-foreground flex items-center gap-2",children:[e.jsx("span",{className:"text-green-500",children:"$"}),e.jsx("span",{children:"ccs doctor"})]})}function te(){return e.jsxs("div",{className:"p-6 max-w-6xl mx-auto space-y-6",children:[e.jsx("div",{className:"rounded-xl border bg-gradient-to-br from-background to-muted/20 p-6",children:e.jsxs("div",{className:"flex items-center gap-6",children:[e.jsx(h,{className:"w-[120px] h-[120px] rounded-full"}),e.jsxs("div",{className:"flex-1 space-y-3",children:[e.jsx(h,{className:"h-5 w-48"}),e.jsx(h,{className:"h-8 w-64"}),e.jsx(h,{className:"h-4 w-32"})]})]})}),e.jsx(h,{className:"h-16 w-full rounded-lg"}),e.jsx("div",{className:"space-y-3",children:[1,2,3,4].map(s=>e.jsx(h,{className:"h-20 rounded-lg"},s))})]})}function xe(){const{t:s}=N(),{data:t,isLoading:a,refetch:r,dataUpdatedAt:i}=Q(),o=i,[c,n]=j.useState(0);j.useEffect(()=>{const m=setInterval(()=>n(v=>v+1),1e3);return()=>clearInterval(m)},[]);const d=()=>{navigator.clipboard.writeText("ccs doctor"),g.success(s("health.copied"))},u=()=>{r(),g.info(s("health.refreshing"))};if(a&&!t)return e.jsx(te,{});const f=t?X(t.summary):"ok",x=t?.groups?ee(t.groups):[];return e.jsxs("div",{className:"p-6 max-w-6xl mx-auto space-y-6",children:[e.jsxs("div",{className:l("relative overflow-hidden rounded-xl border p-6","bg-gradient-to-br from-background via-background to-muted/30"),children:[e.jsx("div",{className:"absolute inset-0 opacity-[0.02] pointer-events-none",style:{backgroundImage:"repeating-linear-gradient(0deg, transparent, transparent 2px, currentColor 2px, currentColor 3px)"}}),e.jsx("div",{className:"absolute inset-0 opacity-[0.03] pointer-events-none",children:e.jsx("div",{className:"absolute inset-0",style:{backgroundImage:"radial-gradient(circle at 1px 1px, currentColor 1px, transparent 0)",backgroundSize:"24px 24px"}})}),e.jsxs("div",{className:"relative flex flex-col md:flex-row items-start md:items-center gap-6",children:[t&&e.jsx("div",{className:"shrink-0",children:e.jsx(K,{passed:t.summary.passed,total:t.summary.total-t.summary.info,status:f,size:"md"})}),e.jsxs("div",{className:"flex-1 space-y-3",children:[e.jsx(se,{}),e.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[e.jsx("h1",{className:"text-2xl font-bold font-mono tracking-tight",children:s("health.systemHealth")}),t?.version&&e.jsx(R,{variant:"outline",className:"font-mono text-xs bg-muted/50",children:s("health.build",{version:t.version})})]}),e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(B,{className:"w-4 h-4 text-muted-foreground"}),e.jsx("span",{className:"text-muted-foreground",children:s("health.lastScan")}),e.jsx("span",{className:"font-mono",children:o?_(o,s):"--"}),e.jsx("span",{className:"text-muted-foreground",children:"|"}),e.jsx("span",{className:"text-muted-foreground",children:s("health.autoRefresh")}),e.jsx("span",{className:"font-mono text-green-500",children:"30s"})]})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsxs(p,{variant:"outline",size:"sm",onClick:d,className:"gap-2 font-mono text-xs",children:[e.jsx(I,{className:"w-3 h-3"}),"ccs doctor",e.jsx(M,{className:"w-3 h-3 opacity-50"})]}),e.jsxs(p,{variant:"outline",size:"sm",onClick:u,disabled:a,className:"gap-2",children:[e.jsx(D,{className:l("w-4 h-4",a&&"animate-spin")}),e.jsx("span",{className:"hidden sm:inline",children:s("health.refresh")}),e.jsx("kbd",{className:"hidden md:inline-flex h-5 items-center gap-1 rounded border bg-muted px-1.5 font-mono text-[10px] font-medium text-muted-foreground",children:"R"})]})]})]})]}),t&&e.jsx("div",{className:"rounded-lg border bg-card p-4",children:e.jsx(L,{total:t.summary.total,passed:t.summary.passed,warnings:t.summary.warnings,errors:t.summary.errors,info:t.summary.info})}),x.length>0&&e.jsx("div",{className:"space-y-3",children:x.map((m,v)=>e.jsx(V,{group:m,defaultOpen:v<2||m.checks.some(w=>w.status==="error"||w.status==="warning")},m.id))}),e.jsxs("div",{className:"flex items-center justify-between text-xs text-muted-foreground border-t pt-4",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("span",{children:[s("health.version")," ",e.jsx("span",{className:"font-mono",children:t?.version??"--"})]}),e.jsxs("span",{children:[s("health.platform")," ",e.jsx("span",{className:"font-mono",children:typeof navigator<"u"?navigator.platform:"linux"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-2 h-2 rounded-full bg-green-500 animate-pulse"}),e.jsx("span",{children:s("health.liveMonitoring")})]})]})]})}export{xe as HealthPage};