@sifxprime/krouter 0.5.104 → 0.5.106

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 (396) hide show
  1. package/app/.next-cli-build/BUILD_ID +1 -1
  2. package/app/.next-cli-build/app-path-routes-manifest.json +5 -5
  3. package/app/.next-cli-build/build-manifest.json +2 -2
  4. package/app/.next-cli-build/server/app/(dashboard)/dashboard/basic-chat/page_client-reference-manifest.js +1 -1
  5. package/app/.next-cli-build/server/app/(dashboard)/dashboard/cli-tools/[toolId]/page.js.nft.json +1 -1
  6. package/app/.next-cli-build/server/app/(dashboard)/dashboard/cli-tools/[toolId]/page_client-reference-manifest.js +1 -1
  7. package/app/.next-cli-build/server/app/(dashboard)/dashboard/cli-tools/page.js.nft.json +1 -1
  8. package/app/.next-cli-build/server/app/(dashboard)/dashboard/cli-tools/page_client-reference-manifest.js +1 -1
  9. package/app/.next-cli-build/server/app/(dashboard)/dashboard/combos/page_client-reference-manifest.js +1 -1
  10. package/app/.next-cli-build/server/app/(dashboard)/dashboard/console-log/page_client-reference-manifest.js +1 -1
  11. package/app/.next-cli-build/server/app/(dashboard)/dashboard/endpoint/page.js.nft.json +1 -1
  12. package/app/.next-cli-build/server/app/(dashboard)/dashboard/endpoint/page_client-reference-manifest.js +1 -1
  13. package/app/.next-cli-build/server/app/(dashboard)/dashboard/environment/page_client-reference-manifest.js +1 -1
  14. package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/[kind]/[id]/page_client-reference-manifest.js +1 -1
  15. package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/[kind]/page_client-reference-manifest.js +1 -1
  16. package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/combo/[id]/page_client-reference-manifest.js +1 -1
  17. package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/web/page_client-reference-manifest.js +1 -1
  18. package/app/.next-cli-build/server/app/(dashboard)/dashboard/mitm/page_client-reference-manifest.js +1 -1
  19. package/app/.next-cli-build/server/app/(dashboard)/dashboard/page.js.nft.json +1 -1
  20. package/app/.next-cli-build/server/app/(dashboard)/dashboard/page_client-reference-manifest.js +1 -1
  21. package/app/.next-cli-build/server/app/(dashboard)/dashboard/profile/page_client-reference-manifest.js +1 -1
  22. package/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/[id]/page.js +1 -1
  23. package/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/[id]/page_client-reference-manifest.js +1 -1
  24. package/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/new/page_client-reference-manifest.js +1 -1
  25. package/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/page_client-reference-manifest.js +1 -1
  26. package/app/.next-cli-build/server/app/(dashboard)/dashboard/proxy-pools/page_client-reference-manifest.js +1 -1
  27. package/app/.next-cli-build/server/app/(dashboard)/dashboard/quota/page.js +1 -1
  28. package/app/.next-cli-build/server/app/(dashboard)/dashboard/quota/page_client-reference-manifest.js +1 -1
  29. package/app/.next-cli-build/server/app/(dashboard)/dashboard/skills/page_client-reference-manifest.js +1 -1
  30. package/app/.next-cli-build/server/app/(dashboard)/dashboard/token-saver/page_client-reference-manifest.js +1 -1
  31. package/app/.next-cli-build/server/app/(dashboard)/dashboard/translator/page_client-reference-manifest.js +1 -1
  32. package/app/.next-cli-build/server/app/(dashboard)/dashboard/usage/page_client-reference-manifest.js +1 -1
  33. package/app/.next-cli-build/server/app/_global-error/page_client-reference-manifest.js +1 -1
  34. package/app/.next-cli-build/server/app/_global-error.html +1 -1
  35. package/app/.next-cli-build/server/app/_global-error.rsc +1 -1
  36. package/app/.next-cli-build/server/app/_global-error.segments/_full.segment.rsc +1 -1
  37. package/app/.next-cli-build/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
  38. package/app/.next-cli-build/server/app/_global-error.segments/_global-error.segment.rsc +1 -1
  39. package/app/.next-cli-build/server/app/_global-error.segments/_head.segment.rsc +1 -1
  40. package/app/.next-cli-build/server/app/_global-error.segments/_index.segment.rsc +1 -1
  41. package/app/.next-cli-build/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  42. package/app/.next-cli-build/server/app/_not-found/page_client-reference-manifest.js +1 -1
  43. package/app/.next-cli-build/server/app/_not-found.html +1 -1
  44. package/app/.next-cli-build/server/app/_not-found.rsc +4 -4
  45. package/app/.next-cli-build/server/app/_not-found.segments/_full.segment.rsc +4 -4
  46. package/app/.next-cli-build/server/app/_not-found.segments/_head.segment.rsc +1 -1
  47. package/app/.next-cli-build/server/app/_not-found.segments/_index.segment.rsc +4 -4
  48. package/app/.next-cli-build/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
  49. package/app/.next-cli-build/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
  50. package/app/.next-cli-build/server/app/_not-found.segments/_tree.segment.rsc +2 -2
  51. package/app/.next-cli-build/server/app/api/auth/login/route.js.nft.json +1 -1
  52. package/app/.next-cli-build/server/app/api/auth/logout/route.js.nft.json +1 -1
  53. package/app/.next-cli-build/server/app/api/auth/oidc/callback/route.js.nft.json +1 -1
  54. package/app/.next-cli-build/server/app/api/auth/oidc/start/route.js.nft.json +1 -1
  55. package/app/.next-cli-build/server/app/api/auth/oidc/test/route.js.nft.json +1 -1
  56. package/app/.next-cli-build/server/app/api/auth/reset-password/route.js.nft.json +1 -1
  57. package/app/.next-cli-build/server/app/api/auth/status/route.js.nft.json +1 -1
  58. package/app/.next-cli-build/server/app/api/cli-tools/all-statuses/route.js.nft.json +1 -1
  59. package/app/.next-cli-build/server/app/api/cli-tools/antigravity-mitm/alias/route.js.nft.json +1 -1
  60. package/app/.next-cli-build/server/app/api/cli-tools/antigravity-mitm/route.js.nft.json +1 -1
  61. package/app/.next-cli-build/server/app/api/cli-tools/copilot-settings/route.js.nft.json +1 -1
  62. package/app/.next-cli-build/server/app/api/cli-tools/cowork-settings/route.js.nft.json +1 -1
  63. package/app/.next-cli-build/server/app/api/combos/[id]/route.js.nft.json +1 -1
  64. package/app/.next-cli-build/server/app/api/combos/route.js.nft.json +1 -1
  65. package/app/.next-cli-build/server/app/api/import/route.js.nft.json +1 -1
  66. package/app/.next-cli-build/server/app/api/keys/[id]/route.js.nft.json +1 -1
  67. package/app/.next-cli-build/server/app/api/keys/route.js.nft.json +1 -1
  68. package/app/.next-cli-build/server/app/api/media-providers/tts/deepgram/voices/route.js.nft.json +1 -1
  69. package/app/.next-cli-build/server/app/api/media-providers/tts/elevenlabs/voices/route.js.nft.json +1 -1
  70. package/app/.next-cli-build/server/app/api/media-providers/tts/inworld/voices/route.js.nft.json +1 -1
  71. package/app/.next-cli-build/server/app/api/media-providers/tts/minimax/voices/route.js.nft.json +1 -1
  72. package/app/.next-cli-build/server/app/api/mitm/cert/route.js.nft.json +1 -1
  73. package/app/.next-cli-build/server/app/api/models/alias/route.js.nft.json +1 -1
  74. package/app/.next-cli-build/server/app/api/models/availability/route.js.nft.json +1 -1
  75. package/app/.next-cli-build/server/app/api/models/custom/route.js.nft.json +1 -1
  76. package/app/.next-cli-build/server/app/api/models/disabled/route.js.nft.json +1 -1
  77. package/app/.next-cli-build/server/app/api/models/live/route.js.nft.json +1 -1
  78. package/app/.next-cli-build/server/app/api/models/live-by-connection/route.js.nft.json +1 -1
  79. package/app/.next-cli-build/server/app/api/models/route.js +1 -1
  80. package/app/.next-cli-build/server/app/api/models/route.js.nft.json +1 -1
  81. package/app/.next-cli-build/server/app/api/models/test/route.js +1 -1
  82. package/app/.next-cli-build/server/app/api/models/test/route.js.nft.json +1 -1
  83. package/app/.next-cli-build/server/app/api/oauth/[provider]/[action]/route.js.nft.json +1 -1
  84. package/app/.next-cli-build/server/app/api/oauth/codex/bulk-import/route.js.nft.json +1 -1
  85. package/app/.next-cli-build/server/app/api/oauth/codex/import-token/route.js.nft.json +1 -1
  86. package/app/.next-cli-build/server/app/api/oauth/cursor/import/route.js.nft.json +1 -1
  87. package/app/.next-cli-build/server/app/api/oauth/gitlab/pat/route.js.nft.json +1 -1
  88. package/app/.next-cli-build/server/app/api/oauth/iflow/cookie/route.js.nft.json +1 -1
  89. package/app/.next-cli-build/server/app/api/oauth/kiro/import/route.js.nft.json +1 -1
  90. package/app/.next-cli-build/server/app/api/oauth/kiro/social-exchange/route.js.nft.json +1 -1
  91. package/app/.next-cli-build/server/app/api/pricing/route.js.nft.json +1 -1
  92. package/app/.next-cli-build/server/app/api/provider-nodes/[id]/route.js.nft.json +1 -1
  93. package/app/.next-cli-build/server/app/api/provider-nodes/route.js.nft.json +1 -1
  94. package/app/.next-cli-build/server/app/api/providers/[id]/models/route.js.nft.json +1 -1
  95. package/app/.next-cli-build/server/app/api/providers/[id]/route.js.nft.json +1 -1
  96. package/app/.next-cli-build/server/app/api/providers/[id]/test/route.js.nft.json +1 -1
  97. package/app/.next-cli-build/server/app/api/providers/[id]/test-models/route.js +1 -1
  98. package/app/.next-cli-build/server/app/api/providers/[id]/test-models/route.js.nft.json +1 -1
  99. package/app/.next-cli-build/server/app/api/providers/client/route.js.nft.json +1 -1
  100. package/app/.next-cli-build/server/app/api/providers/route.js +1 -1
  101. package/app/.next-cli-build/server/app/api/providers/route.js.nft.json +1 -1
  102. package/app/.next-cli-build/server/app/api/providers/test-batch/route.js.nft.json +1 -1
  103. package/app/.next-cli-build/server/app/api/providers/validate/route.js +1 -1
  104. package/app/.next-cli-build/server/app/api/providers/validate/route.js.nft.json +1 -1
  105. package/app/.next-cli-build/server/app/api/providers/zenith/route.js.nft.json +1 -1
  106. package/app/.next-cli-build/server/app/api/proxy-pools/[id]/route.js.nft.json +1 -1
  107. package/app/.next-cli-build/server/app/api/proxy-pools/[id]/test/route.js.nft.json +1 -1
  108. package/app/.next-cli-build/server/app/api/proxy-pools/cloudflare-deploy/route.js.nft.json +1 -1
  109. package/app/.next-cli-build/server/app/api/proxy-pools/deno-deploy/route.js.nft.json +1 -1
  110. package/app/.next-cli-build/server/app/api/proxy-pools/route.js.nft.json +1 -1
  111. package/app/.next-cli-build/server/app/api/proxy-pools/vercel-deploy/route.js.nft.json +1 -1
  112. package/app/.next-cli-build/server/app/api/settings/database/route.js.nft.json +1 -1
  113. package/app/.next-cli-build/server/app/api/settings/require-login/route.js.nft.json +1 -1
  114. package/app/.next-cli-build/server/app/api/settings/route.js.nft.json +1 -1
  115. package/app/.next-cli-build/server/app/api/translator/console-logs/route.js +1 -1
  116. package/app/.next-cli-build/server/app/api/translator/console-logs/stream/route.js +1 -1
  117. package/app/.next-cli-build/server/app/api/translator/send/route.js.nft.json +1 -1
  118. package/app/.next-cli-build/server/app/api/translator/translate/route.js.nft.json +1 -1
  119. package/app/.next-cli-build/server/app/api/tunnel/disable/route.js.nft.json +1 -1
  120. package/app/.next-cli-build/server/app/api/tunnel/enable/route.js.nft.json +1 -1
  121. package/app/.next-cli-build/server/app/api/tunnel/status/route.js.nft.json +1 -1
  122. package/app/.next-cli-build/server/app/api/tunnel/tailscale-check/route.js.nft.json +1 -1
  123. package/app/.next-cli-build/server/app/api/tunnel/tailscale-disable/route.js.nft.json +1 -1
  124. package/app/.next-cli-build/server/app/api/tunnel/tailscale-enable/route.js.nft.json +1 -1
  125. package/app/.next-cli-build/server/app/api/tunnel/tailscale-install/route.js.nft.json +1 -1
  126. package/app/.next-cli-build/server/app/api/usage/[connectionId]/route.js +1 -1
  127. package/app/.next-cli-build/server/app/api/usage/[connectionId]/route.js.nft.json +1 -1
  128. package/app/.next-cli-build/server/app/api/usage/chart/route.js.nft.json +1 -1
  129. package/app/.next-cli-build/server/app/api/usage/history/route.js.nft.json +1 -1
  130. package/app/.next-cli-build/server/app/api/usage/providers/route.js.nft.json +1 -1
  131. package/app/.next-cli-build/server/app/api/usage/request-details/route.js.nft.json +1 -1
  132. package/app/.next-cli-build/server/app/api/usage/request-logs/route.js.nft.json +1 -1
  133. package/app/.next-cli-build/server/app/api/usage/stats/route.js.nft.json +1 -1
  134. package/app/.next-cli-build/server/app/api/usage/stream/route.js.nft.json +1 -1
  135. package/app/.next-cli-build/server/app/api/v1/api/chat/route.js.nft.json +1 -1
  136. package/app/.next-cli-build/server/app/api/v1/audio/speech/route.js.nft.json +1 -1
  137. package/app/.next-cli-build/server/app/api/v1/audio/transcriptions/route.js.nft.json +1 -1
  138. package/app/.next-cli-build/server/app/api/v1/chat/completions/route.js.nft.json +1 -1
  139. package/app/.next-cli-build/server/app/api/v1/embeddings/route.js.nft.json +1 -1
  140. package/app/.next-cli-build/server/app/api/v1/images/generations/route.js.nft.json +1 -1
  141. package/app/.next-cli-build/server/app/api/v1/messages/route.js.nft.json +1 -1
  142. package/app/.next-cli-build/server/app/api/v1/models/[kind]/route.js.nft.json +1 -1
  143. package/app/.next-cli-build/server/app/api/v1/models/route.js.nft.json +1 -1
  144. package/app/.next-cli-build/server/app/api/v1/responses/compact/route.js.nft.json +1 -1
  145. package/app/.next-cli-build/server/app/api/v1/responses/route.js.nft.json +1 -1
  146. package/app/.next-cli-build/server/app/api/v1/route.js.nft.json +1 -1
  147. package/app/.next-cli-build/server/app/api/v1/search/route.js.nft.json +1 -1
  148. package/app/.next-cli-build/server/app/api/v1/web/fetch/route.js.nft.json +1 -1
  149. package/app/.next-cli-build/server/app/api/v1beta/models/[...path]/route.js.nft.json +1 -1
  150. package/app/.next-cli-build/server/app/api/version/route.js +1 -1
  151. package/app/.next-cli-build/server/app/api/version/shutdown/route.js +1 -1
  152. package/app/.next-cli-build/server/app/api/version/shutdown/route.js.nft.json +1 -1
  153. package/app/.next-cli-build/server/app/api/version/update/route.js +1 -1
  154. package/app/.next-cli-build/server/app/api/version/update/route.js.nft.json +1 -1
  155. package/app/.next-cli-build/server/app/callback/page_client-reference-manifest.js +1 -1
  156. package/app/.next-cli-build/server/app/callback.html +1 -1
  157. package/app/.next-cli-build/server/app/callback.rsc +4 -4
  158. package/app/.next-cli-build/server/app/callback.segments/_full.segment.rsc +4 -4
  159. package/app/.next-cli-build/server/app/callback.segments/_head.segment.rsc +1 -1
  160. package/app/.next-cli-build/server/app/callback.segments/_index.segment.rsc +4 -4
  161. package/app/.next-cli-build/server/app/callback.segments/_tree.segment.rsc +2 -2
  162. package/app/.next-cli-build/server/app/callback.segments/callback/__PAGE__.segment.rsc +1 -1
  163. package/app/.next-cli-build/server/app/callback.segments/callback.segment.rsc +1 -1
  164. package/app/.next-cli-build/server/app/dashboard/basic-chat.html +1 -1
  165. package/app/.next-cli-build/server/app/dashboard/basic-chat.rsc +6 -6
  166. package/app/.next-cli-build/server/app/dashboard/basic-chat.segments/!KGRhc2hib2FyZCk/dashboard/basic-chat/__PAGE__.segment.rsc +2 -2
  167. package/app/.next-cli-build/server/app/dashboard/basic-chat.segments/!KGRhc2hib2FyZCk/dashboard/basic-chat.segment.rsc +1 -1
  168. package/app/.next-cli-build/server/app/dashboard/basic-chat.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  169. package/app/.next-cli-build/server/app/dashboard/basic-chat.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  170. package/app/.next-cli-build/server/app/dashboard/basic-chat.segments/_full.segment.rsc +6 -6
  171. package/app/.next-cli-build/server/app/dashboard/basic-chat.segments/_head.segment.rsc +1 -1
  172. package/app/.next-cli-build/server/app/dashboard/basic-chat.segments/_index.segment.rsc +4 -4
  173. package/app/.next-cli-build/server/app/dashboard/basic-chat.segments/_tree.segment.rsc +2 -2
  174. package/app/.next-cli-build/server/app/dashboard/cli-tools.html +1 -1
  175. package/app/.next-cli-build/server/app/dashboard/cli-tools.rsc +6 -6
  176. package/app/.next-cli-build/server/app/dashboard/cli-tools.segments/!KGRhc2hib2FyZCk/dashboard/cli-tools/__PAGE__.segment.rsc +2 -2
  177. package/app/.next-cli-build/server/app/dashboard/cli-tools.segments/!KGRhc2hib2FyZCk/dashboard/cli-tools.segment.rsc +1 -1
  178. package/app/.next-cli-build/server/app/dashboard/cli-tools.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  179. package/app/.next-cli-build/server/app/dashboard/cli-tools.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  180. package/app/.next-cli-build/server/app/dashboard/cli-tools.segments/_full.segment.rsc +6 -6
  181. package/app/.next-cli-build/server/app/dashboard/cli-tools.segments/_head.segment.rsc +1 -1
  182. package/app/.next-cli-build/server/app/dashboard/cli-tools.segments/_index.segment.rsc +4 -4
  183. package/app/.next-cli-build/server/app/dashboard/cli-tools.segments/_tree.segment.rsc +2 -2
  184. package/app/.next-cli-build/server/app/dashboard/combos.html +1 -1
  185. package/app/.next-cli-build/server/app/dashboard/combos.rsc +6 -6
  186. package/app/.next-cli-build/server/app/dashboard/combos.segments/!KGRhc2hib2FyZCk/dashboard/combos/__PAGE__.segment.rsc +2 -2
  187. package/app/.next-cli-build/server/app/dashboard/combos.segments/!KGRhc2hib2FyZCk/dashboard/combos.segment.rsc +1 -1
  188. package/app/.next-cli-build/server/app/dashboard/combos.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  189. package/app/.next-cli-build/server/app/dashboard/combos.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  190. package/app/.next-cli-build/server/app/dashboard/combos.segments/_full.segment.rsc +6 -6
  191. package/app/.next-cli-build/server/app/dashboard/combos.segments/_head.segment.rsc +1 -1
  192. package/app/.next-cli-build/server/app/dashboard/combos.segments/_index.segment.rsc +4 -4
  193. package/app/.next-cli-build/server/app/dashboard/combos.segments/_tree.segment.rsc +2 -2
  194. package/app/.next-cli-build/server/app/dashboard/endpoint.html +1 -1
  195. package/app/.next-cli-build/server/app/dashboard/endpoint.rsc +6 -6
  196. package/app/.next-cli-build/server/app/dashboard/endpoint.segments/!KGRhc2hib2FyZCk/dashboard/endpoint/__PAGE__.segment.rsc +2 -2
  197. package/app/.next-cli-build/server/app/dashboard/endpoint.segments/!KGRhc2hib2FyZCk/dashboard/endpoint.segment.rsc +1 -1
  198. package/app/.next-cli-build/server/app/dashboard/endpoint.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  199. package/app/.next-cli-build/server/app/dashboard/endpoint.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  200. package/app/.next-cli-build/server/app/dashboard/endpoint.segments/_full.segment.rsc +6 -6
  201. package/app/.next-cli-build/server/app/dashboard/endpoint.segments/_head.segment.rsc +1 -1
  202. package/app/.next-cli-build/server/app/dashboard/endpoint.segments/_index.segment.rsc +4 -4
  203. package/app/.next-cli-build/server/app/dashboard/endpoint.segments/_tree.segment.rsc +2 -2
  204. package/app/.next-cli-build/server/app/dashboard/environment.html +1 -1
  205. package/app/.next-cli-build/server/app/dashboard/environment.rsc +6 -6
  206. package/app/.next-cli-build/server/app/dashboard/environment.segments/!KGRhc2hib2FyZCk/dashboard/environment/__PAGE__.segment.rsc +2 -2
  207. package/app/.next-cli-build/server/app/dashboard/environment.segments/!KGRhc2hib2FyZCk/dashboard/environment.segment.rsc +1 -1
  208. package/app/.next-cli-build/server/app/dashboard/environment.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  209. package/app/.next-cli-build/server/app/dashboard/environment.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  210. package/app/.next-cli-build/server/app/dashboard/environment.segments/_full.segment.rsc +6 -6
  211. package/app/.next-cli-build/server/app/dashboard/environment.segments/_head.segment.rsc +1 -1
  212. package/app/.next-cli-build/server/app/dashboard/environment.segments/_index.segment.rsc +4 -4
  213. package/app/.next-cli-build/server/app/dashboard/environment.segments/_tree.segment.rsc +2 -2
  214. package/app/.next-cli-build/server/app/dashboard/media-providers/web.html +1 -1
  215. package/app/.next-cli-build/server/app/dashboard/media-providers/web.rsc +6 -6
  216. package/app/.next-cli-build/server/app/dashboard/media-providers/web.segments/!KGRhc2hib2FyZCk/dashboard/media-providers/web/__PAGE__.segment.rsc +2 -2
  217. package/app/.next-cli-build/server/app/dashboard/media-providers/web.segments/!KGRhc2hib2FyZCk/dashboard/media-providers/web.segment.rsc +1 -1
  218. package/app/.next-cli-build/server/app/dashboard/media-providers/web.segments/!KGRhc2hib2FyZCk/dashboard/media-providers.segment.rsc +1 -1
  219. package/app/.next-cli-build/server/app/dashboard/media-providers/web.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  220. package/app/.next-cli-build/server/app/dashboard/media-providers/web.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  221. package/app/.next-cli-build/server/app/dashboard/media-providers/web.segments/_full.segment.rsc +6 -6
  222. package/app/.next-cli-build/server/app/dashboard/media-providers/web.segments/_head.segment.rsc +1 -1
  223. package/app/.next-cli-build/server/app/dashboard/media-providers/web.segments/_index.segment.rsc +4 -4
  224. package/app/.next-cli-build/server/app/dashboard/media-providers/web.segments/_tree.segment.rsc +2 -2
  225. package/app/.next-cli-build/server/app/dashboard/mitm.html +1 -1
  226. package/app/.next-cli-build/server/app/dashboard/mitm.rsc +6 -6
  227. package/app/.next-cli-build/server/app/dashboard/mitm.segments/!KGRhc2hib2FyZCk/dashboard/mitm/__PAGE__.segment.rsc +2 -2
  228. package/app/.next-cli-build/server/app/dashboard/mitm.segments/!KGRhc2hib2FyZCk/dashboard/mitm.segment.rsc +1 -1
  229. package/app/.next-cli-build/server/app/dashboard/mitm.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  230. package/app/.next-cli-build/server/app/dashboard/mitm.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  231. package/app/.next-cli-build/server/app/dashboard/mitm.segments/_full.segment.rsc +6 -6
  232. package/app/.next-cli-build/server/app/dashboard/mitm.segments/_head.segment.rsc +1 -1
  233. package/app/.next-cli-build/server/app/dashboard/mitm.segments/_index.segment.rsc +4 -4
  234. package/app/.next-cli-build/server/app/dashboard/mitm.segments/_tree.segment.rsc +2 -2
  235. package/app/.next-cli-build/server/app/dashboard/profile.html +1 -1
  236. package/app/.next-cli-build/server/app/dashboard/profile.rsc +6 -6
  237. package/app/.next-cli-build/server/app/dashboard/profile.segments/!KGRhc2hib2FyZCk/dashboard/profile/__PAGE__.segment.rsc +2 -2
  238. package/app/.next-cli-build/server/app/dashboard/profile.segments/!KGRhc2hib2FyZCk/dashboard/profile.segment.rsc +1 -1
  239. package/app/.next-cli-build/server/app/dashboard/profile.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  240. package/app/.next-cli-build/server/app/dashboard/profile.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  241. package/app/.next-cli-build/server/app/dashboard/profile.segments/_full.segment.rsc +6 -6
  242. package/app/.next-cli-build/server/app/dashboard/profile.segments/_head.segment.rsc +1 -1
  243. package/app/.next-cli-build/server/app/dashboard/profile.segments/_index.segment.rsc +4 -4
  244. package/app/.next-cli-build/server/app/dashboard/profile.segments/_tree.segment.rsc +2 -2
  245. package/app/.next-cli-build/server/app/dashboard/providers/new.html +1 -1
  246. package/app/.next-cli-build/server/app/dashboard/providers/new.rsc +6 -6
  247. package/app/.next-cli-build/server/app/dashboard/providers/new.segments/!KGRhc2hib2FyZCk/dashboard/providers/new/__PAGE__.segment.rsc +2 -2
  248. package/app/.next-cli-build/server/app/dashboard/providers/new.segments/!KGRhc2hib2FyZCk/dashboard/providers/new.segment.rsc +1 -1
  249. package/app/.next-cli-build/server/app/dashboard/providers/new.segments/!KGRhc2hib2FyZCk/dashboard/providers.segment.rsc +1 -1
  250. package/app/.next-cli-build/server/app/dashboard/providers/new.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  251. package/app/.next-cli-build/server/app/dashboard/providers/new.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  252. package/app/.next-cli-build/server/app/dashboard/providers/new.segments/_full.segment.rsc +6 -6
  253. package/app/.next-cli-build/server/app/dashboard/providers/new.segments/_head.segment.rsc +1 -1
  254. package/app/.next-cli-build/server/app/dashboard/providers/new.segments/_index.segment.rsc +4 -4
  255. package/app/.next-cli-build/server/app/dashboard/providers/new.segments/_tree.segment.rsc +2 -2
  256. package/app/.next-cli-build/server/app/dashboard/providers.html +1 -1
  257. package/app/.next-cli-build/server/app/dashboard/providers.rsc +6 -6
  258. package/app/.next-cli-build/server/app/dashboard/providers.segments/!KGRhc2hib2FyZCk/dashboard/providers/__PAGE__.segment.rsc +2 -2
  259. package/app/.next-cli-build/server/app/dashboard/providers.segments/!KGRhc2hib2FyZCk/dashboard/providers.segment.rsc +1 -1
  260. package/app/.next-cli-build/server/app/dashboard/providers.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  261. package/app/.next-cli-build/server/app/dashboard/providers.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  262. package/app/.next-cli-build/server/app/dashboard/providers.segments/_full.segment.rsc +6 -6
  263. package/app/.next-cli-build/server/app/dashboard/providers.segments/_head.segment.rsc +1 -1
  264. package/app/.next-cli-build/server/app/dashboard/providers.segments/_index.segment.rsc +4 -4
  265. package/app/.next-cli-build/server/app/dashboard/providers.segments/_tree.segment.rsc +2 -2
  266. package/app/.next-cli-build/server/app/dashboard/proxy-pools.html +1 -1
  267. package/app/.next-cli-build/server/app/dashboard/proxy-pools.rsc +6 -6
  268. package/app/.next-cli-build/server/app/dashboard/proxy-pools.segments/!KGRhc2hib2FyZCk/dashboard/proxy-pools/__PAGE__.segment.rsc +2 -2
  269. package/app/.next-cli-build/server/app/dashboard/proxy-pools.segments/!KGRhc2hib2FyZCk/dashboard/proxy-pools.segment.rsc +1 -1
  270. package/app/.next-cli-build/server/app/dashboard/proxy-pools.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  271. package/app/.next-cli-build/server/app/dashboard/proxy-pools.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  272. package/app/.next-cli-build/server/app/dashboard/proxy-pools.segments/_full.segment.rsc +6 -6
  273. package/app/.next-cli-build/server/app/dashboard/proxy-pools.segments/_head.segment.rsc +1 -1
  274. package/app/.next-cli-build/server/app/dashboard/proxy-pools.segments/_index.segment.rsc +4 -4
  275. package/app/.next-cli-build/server/app/dashboard/proxy-pools.segments/_tree.segment.rsc +2 -2
  276. package/app/.next-cli-build/server/app/dashboard/quota.html +2 -2
  277. package/app/.next-cli-build/server/app/dashboard/quota.rsc +7 -7
  278. package/app/.next-cli-build/server/app/dashboard/quota.segments/!KGRhc2hib2FyZCk/dashboard/quota/__PAGE__.segment.rsc +3 -3
  279. package/app/.next-cli-build/server/app/dashboard/quota.segments/!KGRhc2hib2FyZCk/dashboard/quota.segment.rsc +1 -1
  280. package/app/.next-cli-build/server/app/dashboard/quota.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  281. package/app/.next-cli-build/server/app/dashboard/quota.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  282. package/app/.next-cli-build/server/app/dashboard/quota.segments/_full.segment.rsc +7 -7
  283. package/app/.next-cli-build/server/app/dashboard/quota.segments/_head.segment.rsc +1 -1
  284. package/app/.next-cli-build/server/app/dashboard/quota.segments/_index.segment.rsc +4 -4
  285. package/app/.next-cli-build/server/app/dashboard/quota.segments/_tree.segment.rsc +2 -2
  286. package/app/.next-cli-build/server/app/dashboard/settings/pricing/page_client-reference-manifest.js +1 -1
  287. package/app/.next-cli-build/server/app/dashboard/settings/pricing.html +1 -1
  288. package/app/.next-cli-build/server/app/dashboard/settings/pricing.rsc +4 -4
  289. package/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/_full.segment.rsc +4 -4
  290. package/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/_head.segment.rsc +1 -1
  291. package/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/_index.segment.rsc +4 -4
  292. package/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/_tree.segment.rsc +2 -2
  293. package/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/dashboard/settings/pricing/__PAGE__.segment.rsc +1 -1
  294. package/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/dashboard/settings/pricing.segment.rsc +1 -1
  295. package/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/dashboard/settings.segment.rsc +1 -1
  296. package/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/dashboard.segment.rsc +1 -1
  297. package/app/.next-cli-build/server/app/dashboard/skills.html +1 -1
  298. package/app/.next-cli-build/server/app/dashboard/skills.rsc +6 -6
  299. package/app/.next-cli-build/server/app/dashboard/skills.segments/!KGRhc2hib2FyZCk/dashboard/skills/__PAGE__.segment.rsc +2 -2
  300. package/app/.next-cli-build/server/app/dashboard/skills.segments/!KGRhc2hib2FyZCk/dashboard/skills.segment.rsc +1 -1
  301. package/app/.next-cli-build/server/app/dashboard/skills.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  302. package/app/.next-cli-build/server/app/dashboard/skills.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  303. package/app/.next-cli-build/server/app/dashboard/skills.segments/_full.segment.rsc +6 -6
  304. package/app/.next-cli-build/server/app/dashboard/skills.segments/_head.segment.rsc +1 -1
  305. package/app/.next-cli-build/server/app/dashboard/skills.segments/_index.segment.rsc +4 -4
  306. package/app/.next-cli-build/server/app/dashboard/skills.segments/_tree.segment.rsc +2 -2
  307. package/app/.next-cli-build/server/app/dashboard/token-saver.html +1 -1
  308. package/app/.next-cli-build/server/app/dashboard/token-saver.rsc +6 -6
  309. package/app/.next-cli-build/server/app/dashboard/token-saver.segments/!KGRhc2hib2FyZCk/dashboard/token-saver/__PAGE__.segment.rsc +2 -2
  310. package/app/.next-cli-build/server/app/dashboard/token-saver.segments/!KGRhc2hib2FyZCk/dashboard/token-saver.segment.rsc +1 -1
  311. package/app/.next-cli-build/server/app/dashboard/token-saver.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  312. package/app/.next-cli-build/server/app/dashboard/token-saver.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  313. package/app/.next-cli-build/server/app/dashboard/token-saver.segments/_full.segment.rsc +6 -6
  314. package/app/.next-cli-build/server/app/dashboard/token-saver.segments/_head.segment.rsc +1 -1
  315. package/app/.next-cli-build/server/app/dashboard/token-saver.segments/_index.segment.rsc +4 -4
  316. package/app/.next-cli-build/server/app/dashboard/token-saver.segments/_tree.segment.rsc +2 -2
  317. package/app/.next-cli-build/server/app/dashboard/translator.html +1 -1
  318. package/app/.next-cli-build/server/app/dashboard/translator.rsc +6 -6
  319. package/app/.next-cli-build/server/app/dashboard/translator.segments/!KGRhc2hib2FyZCk/dashboard/translator/__PAGE__.segment.rsc +2 -2
  320. package/app/.next-cli-build/server/app/dashboard/translator.segments/!KGRhc2hib2FyZCk/dashboard/translator.segment.rsc +1 -1
  321. package/app/.next-cli-build/server/app/dashboard/translator.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  322. package/app/.next-cli-build/server/app/dashboard/translator.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  323. package/app/.next-cli-build/server/app/dashboard/translator.segments/_full.segment.rsc +6 -6
  324. package/app/.next-cli-build/server/app/dashboard/translator.segments/_head.segment.rsc +1 -1
  325. package/app/.next-cli-build/server/app/dashboard/translator.segments/_index.segment.rsc +4 -4
  326. package/app/.next-cli-build/server/app/dashboard/translator.segments/_tree.segment.rsc +2 -2
  327. package/app/.next-cli-build/server/app/dashboard/usage.html +1 -1
  328. package/app/.next-cli-build/server/app/dashboard/usage.rsc +6 -6
  329. package/app/.next-cli-build/server/app/dashboard/usage.segments/!KGRhc2hib2FyZCk/dashboard/usage/__PAGE__.segment.rsc +2 -2
  330. package/app/.next-cli-build/server/app/dashboard/usage.segments/!KGRhc2hib2FyZCk/dashboard/usage.segment.rsc +1 -1
  331. package/app/.next-cli-build/server/app/dashboard/usage.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  332. package/app/.next-cli-build/server/app/dashboard/usage.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  333. package/app/.next-cli-build/server/app/dashboard/usage.segments/_full.segment.rsc +6 -6
  334. package/app/.next-cli-build/server/app/dashboard/usage.segments/_head.segment.rsc +1 -1
  335. package/app/.next-cli-build/server/app/dashboard/usage.segments/_index.segment.rsc +4 -4
  336. package/app/.next-cli-build/server/app/dashboard/usage.segments/_tree.segment.rsc +2 -2
  337. package/app/.next-cli-build/server/app/dashboard.html +1 -1
  338. package/app/.next-cli-build/server/app/dashboard.rsc +6 -6
  339. package/app/.next-cli-build/server/app/dashboard.segments/!KGRhc2hib2FyZCk/dashboard/__PAGE__.segment.rsc +2 -2
  340. package/app/.next-cli-build/server/app/dashboard.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  341. package/app/.next-cli-build/server/app/dashboard.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  342. package/app/.next-cli-build/server/app/dashboard.segments/_full.segment.rsc +6 -6
  343. package/app/.next-cli-build/server/app/dashboard.segments/_head.segment.rsc +1 -1
  344. package/app/.next-cli-build/server/app/dashboard.segments/_index.segment.rsc +4 -4
  345. package/app/.next-cli-build/server/app/dashboard.segments/_tree.segment.rsc +2 -2
  346. package/app/.next-cli-build/server/app/index.html +1 -1
  347. package/app/.next-cli-build/server/app/index.rsc +4 -4
  348. package/app/.next-cli-build/server/app/index.segments/__PAGE__.segment.rsc +1 -1
  349. package/app/.next-cli-build/server/app/index.segments/_full.segment.rsc +4 -4
  350. package/app/.next-cli-build/server/app/index.segments/_head.segment.rsc +1 -1
  351. package/app/.next-cli-build/server/app/index.segments/_index.segment.rsc +4 -4
  352. package/app/.next-cli-build/server/app/index.segments/_tree.segment.rsc +2 -2
  353. package/app/.next-cli-build/server/app/landing/page_client-reference-manifest.js +1 -1
  354. package/app/.next-cli-build/server/app/landing.html +1 -1
  355. package/app/.next-cli-build/server/app/landing.rsc +4 -4
  356. package/app/.next-cli-build/server/app/landing.segments/_full.segment.rsc +4 -4
  357. package/app/.next-cli-build/server/app/landing.segments/_head.segment.rsc +1 -1
  358. package/app/.next-cli-build/server/app/landing.segments/_index.segment.rsc +4 -4
  359. package/app/.next-cli-build/server/app/landing.segments/_tree.segment.rsc +2 -2
  360. package/app/.next-cli-build/server/app/landing.segments/landing/__PAGE__.segment.rsc +1 -1
  361. package/app/.next-cli-build/server/app/landing.segments/landing.segment.rsc +1 -1
  362. package/app/.next-cli-build/server/app/login/page_client-reference-manifest.js +1 -1
  363. package/app/.next-cli-build/server/app/login.html +1 -1
  364. package/app/.next-cli-build/server/app/login.rsc +5 -5
  365. package/app/.next-cli-build/server/app/login.segments/_full.segment.rsc +5 -5
  366. package/app/.next-cli-build/server/app/login.segments/_head.segment.rsc +1 -1
  367. package/app/.next-cli-build/server/app/login.segments/_index.segment.rsc +4 -4
  368. package/app/.next-cli-build/server/app/login.segments/_tree.segment.rsc +2 -2
  369. package/app/.next-cli-build/server/app/login.segments/login/__PAGE__.segment.rsc +2 -2
  370. package/app/.next-cli-build/server/app/login.segments/login.segment.rsc +1 -1
  371. package/app/.next-cli-build/server/app/page_client-reference-manifest.js +1 -1
  372. package/app/.next-cli-build/server/app-paths-manifest.json +5 -5
  373. package/app/.next-cli-build/server/chunks/1450.js +1 -1
  374. package/app/.next-cli-build/server/chunks/2365.js +1 -1
  375. package/app/.next-cli-build/server/chunks/4884.js +1 -1
  376. package/app/.next-cli-build/server/chunks/706.js +1 -1
  377. package/app/.next-cli-build/server/chunks/7153.js +1 -1
  378. package/app/.next-cli-build/server/chunks/8361.js +1 -1
  379. package/app/.next-cli-build/server/middleware-build-manifest.js +1 -1
  380. package/app/.next-cli-build/server/middleware.js +1 -1
  381. package/app/.next-cli-build/server/pages/404.html +1 -1
  382. package/app/.next-cli-build/server/pages/500.html +1 -1
  383. package/app/.next-cli-build/static/chunks/{1321-7899d6e86f1a3c5d.js → 1321-b7ecb2d17394abca.js} +1 -1
  384. package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/providers/[id]/{page-69ee736a8c5cf1e3.js → page-d51587e691cd1d6b.js} +1 -1
  385. package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/quota/page-409fa206f9ed68a6.js +1 -0
  386. package/app/.next-cli-build/static/css/309831cb83ff1693.css +1 -0
  387. package/app/cli/.build-home/.krouter/db/backups/{upgrade-0.5.100-to-0.5.101-0.5.101-20260713-173318 → upgrade-0.5.104-to-0.5.105-0.5.105-20260717-040329}/data.sqlite +0 -0
  388. package/app/cli/.build-home/.krouter/db/backups/{upgrade-0.5.99-to-0.5.100-0.5.100-20260713-171040 → upgrade-0.5.105-to-0.5.106-0.5.106-20260717-041652}/data.sqlite +0 -0
  389. package/app/cli/.build-home/.krouter/db/data.sqlite +0 -0
  390. package/app/cli/package.json +1 -1
  391. package/app/package.json +1 -1
  392. package/package.json +1 -1
  393. package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/quota/page-4937d5646f7b17c6.js +0 -1
  394. package/app/.next-cli-build/static/css/701ed312539668cd.css +0 -1
  395. /package/app/.next-cli-build/static/{AUt_AkUkYOdSZipu9v-f- → QTc5qoqcWlAOcSfUYLSfc}/_buildManifest.js +0 -0
  396. /package/app/.next-cli-build/static/{AUt_AkUkYOdSZipu9v-f- → QTc5qoqcWlAOcSfUYLSfc}/_ssgManifest.js +0 -0
@@ -8,4 +8,4 @@ sk-key-only-auto-named`;function k({isOpen:e,provider:t,providerName:s,isCompati
8
8
  "idToken": "eyJhbGc...",
9
9
  "email": "user@example.com"
10
10
  }
11
- ]`;function $({isOpen:e,onClose:t,onSuccess:s}){let[l,r]=(0,i.useState)(""),[n,o]=(0,i.useState)(!1),[c,m]=(0,i.useState)(""),[p,u]=(0,i.useState)(null),h=()=>{n||(r(""),m(""),u(null),t())},f=async()=>{var e;let t;m(""),u(null);let a=l.trim();if(!a)return;try{t=JSON.parse(a)}catch(e){m(`${(0,x.Tl)("Invalid JSON")}: ${e.message}`);return}let i=Array.isArray(e=t)?e:e&&"object"==typeof e?Array.isArray(e.accounts)?e.accounts:[e]:null;if(!i||0===i.length)return void m((0,x.Tl)("No accounts found in input"));o(!0);try{let e=await fetch("/api/oauth/codex/bulk-import",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({accounts:i})}),t=await e.json();if(!e.ok)return void m(t?.error||`Request failed: ${e.status}`);u(t),t.success>0&&"function"==typeof s&&s()}catch(e){m(e.message||(0,x.Tl)("Request failed"))}finally{o(!1)}},g=p?.results?.filter(e=>!e.ok)||[];return(0,a.jsx)(d.aF,{isOpen:e,title:(0,x.Tl)("Bulk Add Codex Accounts"),onClose:h,children:(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,a.jsx)("p",{className:"text-xs text-text-muted",children:(0,x.Tl)("Paste an array of codex account JSON objects. Each must include accessToken (and ideally refreshToken, idToken).")}),(0,a.jsx)("textarea",{className:"w-full rounded border border-accent/30 bg-sidebar p-2 text-sm font-mono resize-y min-h-[240px] focus:outline-none focus:ring-1 focus:ring-primary",placeholder:A,value:l,onChange:e=>r(e.target.value),disabled:n}),c&&(0,a.jsx)("p",{className:"text-xs text-red-500 break-words",children:c}),p&&(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,a.jsxs)("div",{className:`text-sm font-medium ${p.failed>0?"text-yellow-400":"text-green-400"}`,children:["✓ ",p.success," ",(0,x.Tl)("added"),p.failed>0?`, ✗ ${p.failed} ${(0,x.Tl)("failed")}`:""]}),g.length>0&&(0,a.jsx)("ul",{className:"rounded border border-accent/20 bg-sidebar/50 p-2 text-xs font-mono max-h-40 overflow-y-auto",children:g.map(e=>(0,a.jsxs)("li",{className:"text-red-400",children:["[",e.index,"] ",e.error]},e.index))})]}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(d.$n,{onClick:f,fullWidth:!0,disabled:n||!l.trim(),children:n?(0,x.Tl)("Importing..."):(0,x.Tl)("Import All")}),(0,a.jsx)(d.$n,{onClick:h,variant:"ghost",fullWidth:!0,disabled:n,children:(0,x.Tl)("Close")})]})]})})}$.propTypes={isOpen:g().bool.isRequired,onClose:g().func.isRequired,onSuccess:g().func};let T={free:{label:"Free",variant:"success",accent:"green"},freetier:{label:"Free tier",variant:"success",accent:"emerald"},oauth:{label:"OAuth",variant:"primary",accent:"primary"},paid:{label:"API key",variant:"default",accent:"neutral"},webcookie:{label:"Cookie",variant:"warning",accent:"amber"}};function I({capabilities:e,connectionCount:t=0,headerIconPath:s}){let[l,r]=(0,i.useState)(!1);if(!e)return null;let c=T[e.tier]||T.paid,m=e.color?`${e.color}10`:"rgba(148,163,184,0.08)",p=e.color?`${e.color}30`:"rgba(148,163,184,0.20)",x=[];return e.links.apiKey&&x.push({href:e.links.apiKey,icon:"key",label:"Get API key"}),e.links.signup&&!e.links.apiKey&&x.push({href:e.links.signup,icon:"person_add",label:"Sign up"}),e.links.homepage&&x.push({href:e.links.homepage,icon:"language",label:"Homepage"}),e.links.docs&&x.push({href:e.links.docs,icon:"menu_book",label:"Docs"}),e.links.pricing&&x.push({href:e.links.pricing,icon:"sell",label:"Pricing"}),(0,a.jsxs)("div",{className:"flex min-w-0 flex-col gap-4",children:[(0,a.jsxs)(n(),{href:"/dashboard/providers",className:"inline-flex items-center gap-1 text-sm text-text-muted hover:text-primary transition-colors",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-lg",children:"arrow_back"}),"Back to Providers"]}),(0,a.jsxs)("div",{className:"relative overflow-hidden rounded-2xl border p-5 sm:p-7",style:{borderColor:p,background:`linear-gradient(140deg, ${m} 0%, transparent 55%)`},children:[(0,a.jsxs)("div",{className:"flex min-w-0 flex-col gap-5 sm:flex-row sm:items-start sm:justify-between",children:[(0,a.jsxs)("div",{className:"flex min-w-0 items-start gap-4",children:[(0,a.jsx)("div",{className:"flex size-14 shrink-0 items-center justify-center rounded-xl shadow-sm",style:{backgroundColor:e.color?`${e.color}20`:"rgba(148,163,184,0.15)"},children:l||!s?(0,a.jsx)("span",{className:"text-base font-bold",style:{color:e.color||"inherit"},children:e.textIcon||e.id.slice(0,2).toUpperCase()}):(0,a.jsx)(o.default,{src:s,alt:e.name,width:56,height:56,className:"max-h-14 max-w-14 rounded-xl object-contain",sizes:"56px",onError:()=>r(!0)})}),(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,a.jsx)("h1",{className:"truncate text-2xl font-semibold tracking-tight sm:text-3xl",children:e.name}),(0,a.jsx)(d.Ex,{variant:c.variant,size:"sm",children:c.label}),e.deprecated&&(0,a.jsx)(d.Ex,{variant:"warning",size:"sm",children:"deprecated"})]}),(0,a.jsxs)("p",{className:"mt-1 text-sm text-text-muted",children:[t," connection",1===t?"":"s",e.serviceKinds.length>1&&(0,a.jsxs)(a.Fragment,{children:[" \xb7 ",e.serviceKinds.join(" \xb7 ")]})]})]})]}),x.length>0&&(0,a.jsx)("div",{className:"flex flex-wrap gap-1.5 sm:justify-end",children:x.map(e=>(0,a.jsxs)("a",{href:e.href,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 rounded-full border border-border bg-bg/60 px-2.5 py-1 text-xs text-text-main hover:border-primary hover:text-primary transition-colors backdrop-blur",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:e.icon}),e.label]},e.label))})]}),e.notices.body&&!e.deprecated&&(0,a.jsx)("p",{className:"mt-4 max-w-3xl text-sm leading-relaxed text-text-muted",children:e.notices.body})]}),e.deprecated&&e.notices.warning&&(0,a.jsxs)("div",{className:"flex items-start gap-2 rounded-lg border border-yellow-500/30 bg-yellow-500/10 px-3 py-2",children:[(0,a.jsx)("span",{className:"material-symbols-outlined mt-0.5 shrink-0 text-[16px] text-yellow-500",children:"warning"}),(0,a.jsx)("p",{className:"text-xs leading-relaxed text-red-600 dark:text-yellow-400",children:e.notices.warning})]})]})}I.propTypes={capabilities:g().object,connectionCount:g().number,headerIconPath:g().string};let P={oauth:{icon:"lock",label:"Sign in with OAuth",tabLabel:"OAuth"},apikey:{icon:"key",label:"Add API key",tabLabel:"API key"},free:{icon:"bolt",label:"Connect for free",tabLabel:"Free"},cookie:{icon:"cookie",label:"Paste session cookie",tabLabel:"Cookie"},compatible:{icon:"developer_board",label:"Configure endpoint",tabLabel:"Compatible"}};function O({children:e,accentColor:t}){return(0,a.jsx)("div",{className:"rounded-xl border p-5 sm:p-6",style:{borderColor:t?`${t}25`:void 0,background:t?`linear-gradient(160deg, ${t}08, transparent 70%)`:void 0},children:e})}let E={oauth:function({capabilities:e,onOAuth:t,onBulkImport:s}){return(0,a.jsx)(O,{accentColor:e.color,children:(0,a.jsxs)("div",{className:"flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between",children:[(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsxs)("h3",{className:"text-base font-semibold",children:["Sign in with ",e.name]}),(0,a.jsx)("p",{className:"mt-0.5 text-sm text-text-muted",children:"One click. We handle the OAuth callback and store your session locally. You can add multiple accounts."})]}),(0,a.jsxs)("div",{className:"flex flex-wrap gap-2 sm:flex-nowrap",children:[e.features.bulkImport&&s&&(0,a.jsx)(d.$n,{size:"md",icon:"playlist_add",variant:"secondary",onClick:s,children:"Bulk import"}),(0,a.jsxs)(d.$n,{size:"md",icon:"lock",onClick:t,children:["Sign in with ",e.name]})]})]})})},apikey:function({capabilities:e,onApiKey:t}){return(0,a.jsx)(O,{accentColor:e.color,children:(0,a.jsxs)("div",{className:"flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between",children:[(0,a.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,a.jsxs)("h3",{className:"text-base font-semibold",children:["Paste your ",e.name," API key"]}),(0,a.jsxs)("p",{className:"mt-0.5 text-sm text-text-muted",children:[e.links.apiKey?(0,a.jsxs)(a.Fragment,{children:["Grab a key from"," ",(0,a.jsx)("a",{href:e.links.apiKey,target:"_blank",rel:"noopener noreferrer",className:"text-primary underline decoration-primary/40 underline-offset-4 hover:decoration-primary",children:new URL(e.links.apiKey).hostname})," ","and paste it in."]}):(0,a.jsx)(a.Fragment,{children:"Paste your API key to connect."})," ","Stored locally, never sent anywhere except ",e.name,"."]})]}),(0,a.jsx)(d.$n,{size:"md",icon:"key",onClick:t,children:"Add API key"})]})})},free:function({capabilities:e,onFree:t}){return(0,a.jsx)(O,{accentColor:e.color||"#10B981",children:(0,a.jsxs)("div",{className:"flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between",children:[(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsxs)("div",{className:"mb-1 flex items-center gap-2",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px] text-green-500",children:"bolt"}),(0,a.jsxs)("h3",{className:"text-base font-semibold",children:[e.name," is free — one click to connect"]})]}),(0,a.jsx)("p",{className:"text-sm text-text-muted",children:"No key, no signup, no card. Just click connect and start using it."})]}),(0,a.jsx)(d.$n,{size:"md",icon:"add",onClick:t,children:"Connect"})]})})},cookie:function({capabilities:e,onCookie:t}){let[s,l]=(0,i.useState)(!1);return(0,a.jsx)(O,{accentColor:e.color||"#F59E0B",children:(0,a.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,a.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsx)("h3",{className:"text-base font-semibold",children:"Advanced: connect with session cookie"}),(0,a.jsxs)("p",{className:"mt-0.5 text-sm text-text-muted",children:["For power users. Extract the ",e.name," cookie from your browser and paste it here."]})]}),(0,a.jsx)("button",{type:"button",onClick:()=>l(e=>!e),className:"text-xs text-text-muted hover:text-primary",children:s?"hide":"show"})]}),s&&(0,a.jsxs)("div",{className:"rounded-lg border border-border bg-bg/70 p-3",children:[(0,a.jsxs)("ol",{className:"mb-3 list-decimal space-y-1 pl-4 text-xs text-text-muted",children:[(0,a.jsxs)("li",{children:["Open ",e.name," in your browser and sign in."]}),(0,a.jsx)("li",{children:"Open DevTools → Application → Cookies."}),(0,a.jsx)("li",{children:"Copy the session cookie value."}),(0,a.jsx)("li",{children:"Paste it in the modal."})]}),(0,a.jsx)(d.$n,{size:"sm",icon:"cookie",onClick:t,children:"Paste cookie"})]})]})})},compatible:function({capabilities:e,onCompatible:t}){return(0,a.jsx)(O,{accentColor:e.color,children:(0,a.jsxs)("div",{className:"flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between",children:[(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsx)("h3",{className:"text-base font-semibold",children:"Use as OpenAI-compatible endpoint"}),(0,a.jsx)("p",{className:"mt-0.5 text-sm text-text-muted",children:"Point at any OpenAI-shaped base URL (self-hosted, LiteLLM, custom proxy). Fetches the live model list after you connect."})]}),(0,a.jsx)(d.$n,{size:"md",icon:"developer_board",onClick:t,children:"Configure endpoint"})]})})}};function R({capabilities:e,onOAuth:t,onApiKey:s,onFree:l,onCookie:r,onCompatible:n,onBulkImport:o}){let d=e?.authModes||[],[c,m]=(0,i.useState)(d[0]||"apikey");if(!e||0===d.length)return null;let p=E[c]||E.apikey,x=d.length>1;return(0,a.jsxs)("div",{className:"flex min-w-0 flex-col gap-3",children:[x&&(0,a.jsx)("div",{className:"flex flex-wrap gap-1 rounded-lg border border-border bg-sidebar/40 p-1",children:d.map(e=>{let t=P[e]||{icon:"add",tabLabel:e},s=e===c;return(0,a.jsxs)("button",{type:"button",onClick:()=>m(e),className:`inline-flex items-center gap-1.5 rounded-md px-3 py-1.5 text-xs font-medium transition-colors ${s?"bg-bg text-text-main shadow-sm":"text-text-muted hover:text-text-main"}`,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:t.icon}),t.tabLabel]},e)})}),(0,a.jsx)(p,{capabilities:e,onOAuth:t,onApiKey:s,onFree:l,onCookie:r,onCompatible:n,onBulkImport:o})]})}function D({providerId:e,models:t=[]}){let[s,l]=(0,i.useState)(""),[r,n]=(0,i.useState)({status:"idle"}),o=(0,i.useCallback)(async()=>{if(e){n(e=>({...e,status:"ok"===e.status?"refreshing":"loading"}));try{let t=new URLSearchParams({providerId:e});s&&t.set("model",s);let a=await fetch(`/api/providers/zenith?${t.toString()}`,{cache:"no-store"}),i=await a.json();i.success?n({status:"ok",winner:i.winner,count:i.count,leaderboard:i.leaderboard}):n({status:"error",error:i.error||"Zenith read failed"})}catch(e){n({status:"error",error:e?.message||"Network error"})}}},[e,s]);if((0,i.useEffect)(()=>{o();let e=setInterval(o,1e4);return()=>clearInterval(e)},[o]),"idle"===r.status||"loading"===r.status||"error"===r.status||!r.winner||(r.count??0)<2)return null;let d=r.winner;return(0,a.jsxs)("div",{className:"mb-3 flex flex-wrap items-center gap-2 rounded-lg border border-primary/20 bg-primary/[0.04] px-3 py-2 text-xs",children:[(0,a.jsxs)("span",{className:"inline-flex items-center gap-1 text-primary font-medium",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:"route"}),"Next request →"]}),(0,a.jsx)("span",{className:"font-medium text-text-main",children:d.name}),(0,a.jsxs)("span",{className:"rounded-md border border-primary/30 bg-primary/10 px-1.5 py-0.5 font-mono text-[10px] text-primary",children:["Z:",d.finalScore]}),(0,a.jsxs)("span",{className:"text-text-muted",children:["health ",d.healthScore," \xb7 quota \xd7",d.quotaFactor," \xb7 priority +",d.priorityBonus]}),t.length>0&&(0,a.jsxs)("div",{className:"ml-auto flex items-center gap-1.5",children:[(0,a.jsx)("span",{className:"text-text-muted",children:"Model:"}),(0,a.jsxs)("select",{value:s,onChange:e=>l(e.target.value),className:"rounded-md border border-border bg-bg px-1.5 py-0.5 text-[11px] focus:outline-none focus:border-primary",children:[(0,a.jsx)("option",{value:"",children:"(any)"}),t.map(e=>(0,a.jsx)("option",{value:e.id,children:e.id},e.id))]})]})]})}function _({providerId:e}){let[t,s]=(0,i.useState)(!1),[l,r]=(0,i.useState)([]),[n,o]=(0,i.useState)(!1),d=(0,i.useCallback)(async()=>{if(e){o(!0);try{let t=await fetch(`/api/providers/zenith/log?providerId=${e}&limit=50`,{cache:"no-store"}),s=await t.json();s.success&&r(s.entries||[])}catch{}finally{o(!1)}}},[e]);return(0,i.useEffect)(()=>{if(!t)return;d();let e=setInterval(d,5e3);return()=>clearInterval(e)},[t,d]),(0,a.jsxs)("div",{className:"mt-4 rounded-lg border border-border",children:[(0,a.jsxs)("button",{type:"button",onClick:()=>s(e=>!e),className:"flex w-full items-center justify-between px-3 py-2 text-xs text-text-muted hover:text-text-main",children:[(0,a.jsxs)("span",{className:"inline-flex items-center gap-1.5",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:"history"}),"Routing decisions",l.length>0&&(0,a.jsxs)("span",{className:"text-text-muted",children:["(",l.length,")"]})]}),(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:t?"expand_less":"expand_more"})]}),t&&(0,a.jsxs)("div",{className:"max-h-64 overflow-y-auto border-t border-border/50 px-3 py-2",children:[n&&0===l.length&&(0,a.jsx)("p",{className:"text-xs text-text-muted",children:"Loading…"}),!n&&0===l.length&&(0,a.jsx)("p",{className:"text-xs text-text-muted",children:"No decisions recorded yet. Fire a request through kRouter to populate."}),(0,a.jsx)("ul",{className:"space-y-1",children:l.map((e,t)=>(0,a.jsxs)("li",{className:"flex flex-wrap items-center gap-2 border-b border-border/30 py-1 text-[11px] font-mono last:border-0",children:[(0,a.jsx)("span",{className:"text-text-muted",children:function(e){let t=Math.floor((Date.now()-e)/1e3);if(t<5)return"just now";if(t<60)return`${t}s ago`;let s=Math.floor(t/60);return s<60?`${s}m ago`:`${Math.floor(s/60)}h ago`}(e.at)}),e.model&&(0,a.jsx)("span",{className:"text-text-main",children:e.model}),(0,a.jsx)("span",{className:"text-text-muted",children:"→"}),(0,a.jsx)("span",{className:"text-text-main",children:e.connectionId.slice(0,8)}),null!=e.score&&(0,a.jsxs)("span",{className:"text-primary",children:["Z:",e.score]}),null!=e.latencyMs&&(0,a.jsxs)("span",{className:"text-text-muted",children:[e.latencyMs,"ms"]}),(0,a.jsx)("span",{className:e.success?"text-green-500":"text-red-500",children:e.success?"✓":"✗"})]},`${e.at}-${t}`))})]})]})}function z(){let e,t=(0,l.useParams)(),s=(0,l.useRouter)(),r=t.id,[u,f]=(0,i.useState)([]),[g,y]=(0,i.useState)(!0),[j,w]=(0,i.useState)(null),[A,T]=(0,i.useState)([]),[P,O]=(0,i.useState)(!1),[E,z]=(0,i.useState)(!1),[U,q]=(0,i.useState)(!1),[M,K]=(0,i.useState)(""),[L,F]=(0,i.useState)(!1),[J,B]=(0,i.useState)(!1),[W,V]=(0,i.useState)(!1),[H,G]=(0,i.useState)(!1),[Q,Z]=(0,i.useState)(null),[Y,X]=(0,i.useState)({}),[ee,et]=(0,i.useState)(!1),[es,ea]=(0,i.useState)({}),[ei,el]=(0,i.useState)(""),[er,en]=(0,i.useState)(new Set),[eo,ed]=(0,i.useState)(!1),[ec,em]=(0,i.useState)(!1),[ep,ex]=(0,i.useState)([]),[eu,eh]=(0,i.useState)("__none__"),[ef,eg]=(0,i.useState)(!1),[eb,ey]=(0,i.useState)(null),[ev,ej]=(0,i.useState)(""),[eN,ew]=(0,i.useState)("auto"),[ek,eC]=(0,i.useState)({enabled:!1,connections:{}}),[eS,eA]=(0,i.useState)([]),[e$,eT]=(0,i.useState)([]),[eI,eP]=(0,i.useState)(!1),[eO,eE]=(0,i.useState)(""),[eR,eD]=(0,i.useState)(new Set),[e_,ez]=(0,i.useState)([]),[eU,eq]=(0,i.useState)([]),[eM,eK]=(0,i.useState)(null),[eL,eF]=(0,i.useState)(!1),[eJ,eB]=(0,i.useState)(!1),[eW,eV]=(0,i.useState)(!1),[eH,eG]=(0,i.useState)(null),[eQ,eZ]=(0,i.useState)({}),[eY,eX]=(0,i.useState)(null),e0=(0,i.useRef)(!1),[e1,e5]=(0,i.useState)(!1),{copied:e2,copy:e4}=(0,p.C)(),e3="ag_risk_confirmed",e6=()=>{O(!0)},e7=()=>{"antigravity"===r&&"true"!==window.localStorage.getItem(e3)?eF(!0):ta?e6():(K(""),q(!0))},e8=()=>{K(""),q(!0)},e9=()=>{ta?e7():e8()},te=j?{id:j.id,name:j.name||("anthropic-compatible"===j.type?"Anthropic Compatible":"OpenAI Compatible"),color:"anthropic-compatible"===j.type?"#D97757":"#10A37F",textIcon:"anthropic-compatible"===j.type?"AC":"OC",apiType:j.apiType,baseUrl:j.baseUrl,type:j.type}:c.zN[r]||c.fg[r]||c.IS[r]||c.nJ[r]||c.br[r],tt=j?null:function(e){let t=c.zN[e]?c.zN:c.fg[e]?c.fg:c.IS[e]?c.IS:c.nJ[e]?c.nJ:c.br[e]?c.br:null;if(!t)return null;let s=t[e],a=t===c.IS&&s?.noAuth?"free":t===c.IS||t===c.zN?"oauth":t===c.br?"cookie":t===c.fg&&s?.noAuth?"free":(t===c.fg||c.nJ,"apikey"),i=Array.isArray(s.authModes)?s.authModes.filter(e=>e!==a):[],l=[a,...i],r=(0,c.mq)(e)||(0,c.gb)(e);r&&!l.includes("compatible")&&l.push("compatible");let n=s.notice||{};return{id:e,name:s.name||e,icon:s.icon,image:s.image,textIcon:s.textIcon,color:s.color,tier:t===c.IS?"free":t===c.nJ?"freetier":t===c.zN?"oauth":t===c.br?"webcookie":s?.noAuth?"free":"paid",authModes:l,links:{homepage:s.website,apiKey:n.apiKeyUrl,signup:n.signupUrl,pricing:s.searchViaChat?.pricingUrl,docs:s.docsUrl},features:{autoPing:"claude"===e&&"oauth"===a,bulkImport:"codex"===e,compatibleModels:r,customModels:!s.passthroughModels,passthroughModels:!!s.passthroughModels,hasRegions:Array.isArray(s.regions)&&s.regions.length>0,hasProviderSpecificData:!!s.hasProviderSpecificData},serviceKinds:s.serviceKinds||["llm"],thinking:s.thinkingConfig||null,notices:{body:n.text,warning:s.deprecationNotice},deprecated:!!s.deprecated,regions:s.regions,defaultRegion:s.defaultRegion,noAuth:!!s.noAuth,_raw:s}}(r),ts=te?.authModes||[],ta=!!c.zN[r]||!!c.IS[r]||ts.includes("oauth"),ti=!!c.fg[r]||ts.includes("apikey"),tl=!!c.IS[r]?.noAuth,tr=(0,m.KC)(r),tn=(0,c.wG)(r),to=(0,c.mq)(r),td=(0,c.gb)(r),tc=to||td,tm=!tc&&ta&&ti,tp="xai"===r?"Grok Build OAuth":"OAuth",tx="xai"===r?"xAI API Key":"API Key";c.Q2[r]?.thinkingConfig||c.s9.extended;let tu=tc?r:tn,th=tc?j?.prefix||r:tn,tf=(0,i.useCallback)(async()=>{try{let e=await fetch(`/api/models/disabled?providerAlias=${encodeURIComponent(tu)}`,{cache:"no-store"}),t=await e.json();e.ok&&eq(t.ids||[])}catch(e){console.log("Error fetching disabled models:",e)}},[tu]),tg=async e=>{try{(await fetch("/api/models/disabled",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerAlias:tu,ids:[e]})})).ok&&await tf()}catch(e){console.log("Error disabling model:",e)}},tb=async e=>{try{(await fetch(`/api/models/disabled?providerAlias=${encodeURIComponent(tu)}&id=${encodeURIComponent(e)}`,{method:"DELETE"})).ok&&await tf()}catch(e){console.log("Error enabling model:",e)}},ty=async e=>{e.length&&eK({title:"Disable All Models",message:`Disable all ${e.length} model(s)?`,onConfirm:async()=>{eK(null);try{(await fetch("/api/models/disabled",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerAlias:tu,ids:e})})).ok&&await tf()}catch(e){console.log("Error disabling all models:",e)}}})},tv=async()=>{try{(await fetch(`/api/models/disabled?providerAlias=${encodeURIComponent(tu)}`,{method:"DELETE"})).ok&&await tf()}catch(e){console.log("Error enabling all models:",e)}},tj=(0,i.useCallback)(async()=>{try{let e=await fetch("/api/models/alias"),t=await e.json();e.ok&&X(t.aliases||{})}catch(e){console.log("Error fetching aliases:",e)}},[]);(0,i.useEffect)(()=>{"kilocode"===r&&fetch("/api/providers/kilo/free-models").then(e=>e.json()).then(e=>{e.models?.length&&ez(e.models)}).catch(()=>{})},[r]);let tN=(0,i.useCallback)(async()=>{try{let[e,t,s,a]=await Promise.all([fetch("/api/providers",{cache:"no-store"}),fetch("/api/provider-nodes",{cache:"no-store"}),fetch("/api/proxy-pools?isActive=true",{cache:"no-store"}),fetch("/api/settings",{cache:"no-store"})]),i=await e.json(),l=await t.json(),n=await s.json(),o=a.ok?await a.json():{};if(e.ok){let e=(i.connections||[]).filter(e=>e.provider===r);f(e)}s.ok&&T(n.proxyPools||[]);let d=(o.providerStrategies||{})[r]||{};ey(d.fallbackStrategy||null),ej(null!=d.stickyRoundRobinLimit?String(d.stickyRoundRobinLimit):"1");let c=(o.providerThinking||{})[r]||{};ew(c.mode||"auto");let m=o.claudeAutoPing||{};if(eC({enabled:!0===m.enabled,connections:m.connections||{}}),t.ok){let e=(l.nodes||[]).find(e=>e.id===r)||null;if(!e&&tc)for(let t=0;t<3;t+=1){await new Promise(e=>setTimeout(e,150));let t=await fetch("/api/provider-nodes",{cache:"no-store"});if(t.ok&&(e=((await t.json()).nodes||[]).find(e=>e.id===r)||null))break}w(e)}}catch(e){console.log("Error fetching connections:",e)}finally{y(!1)}},[r,tc]),tw=async e=>{try{let t=await fetch(`/api/provider-nodes/${r}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),s=await t.json();t.ok&&(w(s.node),await tN(),V(!1))}catch(e){console.log("Error updating provider node:",e)}},tk=async(e,t)=>{try{let s=await fetch("/api/settings",{cache:"no-store"}),a=(s.ok?await s.json():{}).providerStrategies||{},i={};e&&(i.fallbackStrategy=e),"round-robin"===e&&""!==t&&(i.stickyRoundRobinLimit=Number(t)||3);let l={...a};0===Object.keys(i).length?delete l[r]:l[r]=i,await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerStrategies:l})})}catch(e){console.log("Error saving provider strategy:",e)}},tC=async(e,t)=>{eC({...ek,connections:{...ek.connections,[e]:t}});try{let s=await fetch("/api/settings",{cache:"no-store"}),a=(s.ok?await s.json():{}).claudeAutoPing||{},i={...a,connections:{...a.connections||{},[e]:t}};await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({claudeAutoPing:i})}),eC({enabled:!0===i.enabled,connections:i.connections})}catch(e){console.log("Error saving auto-ping config:",e),eC(ek)}};(0,i.useEffect)(()=>{tN(),tj(),tf()},[tN,tj,tf]);let[tS,tA]=(0,i.useState)({});(0,i.useEffect)(()=>{let e=!1,t=async()=>{try{let t=await fetch("/api/providers/health",{cache:"no-store"});if(!t.ok)return;let s=await t.json();!e&&s?.success&&s.snapshot&&tA(s.snapshot)}catch{}};t();let s=setInterval(t,1e4);return()=>{e=!0,clearInterval(s)}},[]),(0,i.useEffect)(()=>{let e=(c.zN[r]||c.fg[r]||c.IS[r]||c.nJ[r])?.modelsFetcher;e&&h(e).then(eA)},[r]);let t$=(0,i.useCallback)(async()=>{if(0===u.length)return;let e=u.find(e=>!1!==e.isActive)||u[0];if(e){eP(!0);try{let t=null;try{let s=await fetch(`/api/models/live-by-connection?connectionId=${e.id}`),a=s.ok?await s.json():null;a?.success&&a?.models?.length?t={models:a.models}:a?.code==="no_fetcher"&&(t=null)}catch{}if(!t){let s=await fetch(`/api/providers/${e.id}/models`);t=s.ok?await s.json():null}t?.models?.length&&(eT(t.models),eD(e=>{if(e.size>0)return e;let s=t.models[0]?.id||"",a=s.includes("/")?s.split("/")[0]:"other";return new Set([a])}))}catch{}finally{eP(!1)}}},[r,u]);(0,i.useEffect)(()=>{t$()},[t$]);let tT=async(e,t,s=tn)=>{let a=`${s}/${e}`;try{let e=await fetch("/api/models/alias",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:a,alias:t})});if(e.ok)await tj();else{let t=await e.json();alert(t.error||"Failed to set alias")}}catch(e){console.log("Error setting alias:",e)}},tI=async e=>{try{(await fetch(`/api/models/alias?alias=${encodeURIComponent(e)}`,{method:"DELETE"})).ok&&await tj()}catch(e){console.log("Error deleting alias:",e)}},tP=async()=>{if(e1)return;let e=u.find(e=>!1!==e.isActive);if(!e)return void alert((0,x.Tl)("Please add an active Qoder connection first"));e5(!0);try{let t=await fetch(`/api/providers/${e.id}/models`),s=await t.json();if(!t.ok)return void alert(s.error||(0,x.Tl)("Failed to fetch models"));let a=s.models||[];if(0===a.length)return void alert((0,x.Tl)("No models returned"));let i=0;for(let e of a){let t=e.id||e.name;if(!t)continue;let s=t.replace(/^qoder\//,""),a=`${tu}/${s}`;!Object.values(Y).includes(a)&&(Y[s]||(await tT(s,s,tu),i+=1))}0===i?alert((0,x.Tl)("All models already exist, no new models added")):alert((0,x.Tl)("Successfully added")+` ${i} `+(0,x.Tl)("models"))}catch(e){console.log("Error importing Qoder models:",e),alert((0,x.Tl)("Error fetching models")+": "+e.message)}finally{e5(!1)}},tO=async()=>{if(eJ||0===u.length)return;let e=Object.fromEntries(u.map(e=>[e.id,{state:"queued",error:null}]));e0.current=!1,eB(!0),eV(!1),eG(null),eZ(e),eX({total:u.length,completed:0,passed:0,failed:0,stopped:!1});let t=0,s=0;try{for(let e=0;e<u.length;e+=1){if(e0.current){eX({total:u.length,completed:e,passed:t,failed:s,stopped:!0});break}let a=u[e];eG(a.id),eZ(e=>({...e,[a.id]:{state:"testing",error:null}}));try{let e=await fetch(`/api/providers/${a.id}/test`,{method:"POST"}),i=await e.json(),l=!!i.valid;l?t+=1:s+=1,eZ(e=>({...e,[a.id]:{state:l?"success":"failed",error:l?null:i.error||null}}))}catch(e){s+=1,eZ(t=>({...t,[a.id]:{state:"failed",error:e.message||"Test failed"}}))}eX({total:u.length,completed:e+1,passed:t,failed:s,stopped:!1}),e<u.length-1&&await new Promise(e=>setTimeout(e,1e3))}}finally{eG(null),eB(!1),eV(!1),e0.current=!1}},tE=async e=>{eK({title:"Delete Connection",message:"Delete this connection?",onConfirm:async()=>{eK(null);try{(await fetch(`/api/providers/${e}`,{method:"DELETE"})).ok&&f(u.filter(t=>t.id!==e))}catch(e){console.log("Error deleting connection:",e)}}})},tR=()=>{tN(),O(!1)},tD=async e=>{K("");try{let t=await fetch("/api/providers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:r,...e})}),s=null;try{s=await t.json()}catch{s=null}if(t.ok){await tN(),q(!1);return}K(s?.error||"Failed to save connection")}catch(e){console.log("Error saving connection:",e),K("Failed to save connection")}},t_=async e=>{try{(await fetch(`/api/providers/${Q.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})).ok&&(await tN(),B(!1))}catch(e){console.log("Error updating connection:",e)}},tz=async(e,t)=>{try{(await fetch(`/api/providers/${e}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({isActive:t})})).ok&&f(s=>s.map(s=>s.id===e?{...s,isActive:t}:s))}catch(e){console.log("Error updating connection status:",e)}},tU=async(e,t)=>{let s=[...u];[s[e],s[t]]=[s[t],s[e]],f(s);try{await Promise.all([fetch(`/api/providers/${s[e].id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({priority:e})}),fetch(`/api/providers/${s[t].id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({priority:t})})])}catch(e){console.log("Error swapping priority:",e),await tN()}},tq=u.filter(e=>ep.includes(e.id));u.length>0&&(ep.length,u.length),(0,i.useEffect)(()=>{ex(e=>e.filter(e=>u.some(t=>t.id===e)))},[u]),(()=>{if(0===tq.length)return;let e=new Set(tq.map(e=>e.providerSpecificData?.proxyPoolId||"__none__"));if(1===e.size){let t=[...e][0];if("__none__"===t)return;let s=A.find(e=>e.id===t);return s?.name}})();let tM=()=>{ef||G(!1)},tK=async e=>{eg(!0);try{let t=0;for(let{connectionId:s,proxyPoolId:a}of e)try{(await fetch(`/api/providers/${s}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({proxyPoolId:a})})).ok||(t+=1)}catch(e){console.log("Error applying proxy for",s,e),t+=1}t>0&&alert(`Updated with ${t} failed request(s).`),await tN(),G(!1)}finally{eg(!1)}},tL=e=>tK(u.map(t=>({connectionId:t.id,proxyPoolId:e}))),tF=(0,a.jsx)("div",{className:"flex min-w-0 flex-col divide-y divide-black/[0.03] dark:divide-white/[0.03]",children:u.map((e,t)=>(0,a.jsx)("div",{className:"flex min-w-0 items-stretch",children:(0,a.jsx)("div",{className:"flex-1 min-w-0",children:(0,a.jsx)(N,{connection:e,proxyPools:A,health:tS[e.id],isOAuth:ta,isFirst:0===t,isLast:t===u.length-1,onMoveUp:()=>tU(t,t-1),onMoveDown:()=>tU(t,t+1),onToggleActive:t=>tz(e.id,t),autoPing:"claude"===r&&"oauth"===e.authType?{on:!0===ek.connections[e.id],onToggle:t=>tC(e.id,t)}:null,onUpdateProxy:async t=>{try{(await fetch(`/api/providers/${e.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({proxyPoolId:t||null})})).ok&&f(s=>s.map(s=>s.id===e.id?{...s,providerSpecificData:{...s.providerSpecificData,proxyPoolId:t||null}}:s))}catch(e){console.log("Error updating proxy:",e)}},onEdit:()=>{Z(e),B(!0)},onDelete:()=>tE(e.id),oneByOneStatus:eQ[e.id]||null})})},e.id))}),tJ=A.filter(e=>!0===e.isActive),tB=(0,a.jsx)(d.aF,{isOpen:H,onClose:tM,title:`Apply Proxy (${u.length} connections)`,children:(0,a.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,a.jsxs)("div",{className:"flex flex-col",children:[(0,a.jsxs)("button",{onClick:()=>{let e=A.filter(e=>!0===e.isActive);return 0===e.length?void alert("No active proxy pools available."):tK(u.map((t,s)=>({connectionId:t.id,proxyPoolId:e[s%e.length].id})))},disabled:ef||0===tJ.length,className:"flex items-center gap-2 rounded-lg px-3 py-2 text-left transition-colors hover:bg-black/[0.04] dark:hover:bg-white/[0.04] disabled:cursor-not-allowed disabled:opacity-50",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[18px]",children:"sync_alt"}),(0,a.jsx)("span",{className:"text-sm text-text-main",children:"One-to-one (rotate)"})]}),(0,a.jsxs)("button",{onClick:()=>tL(null),disabled:ef,className:"flex items-center gap-2 rounded-lg px-3 py-2 text-left transition-colors hover:bg-black/[0.04] dark:hover:bg-white/[0.04] disabled:cursor-not-allowed disabled:opacity-50",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[18px]",children:"link_off"}),(0,a.jsx)("span",{className:"text-sm text-text-main",children:"None (unbind all)"})]}),A.map(e=>(0,a.jsxs)("button",{onClick:()=>tL(e.id),disabled:ef||!0!==e.isActive,className:"flex items-center gap-2 rounded-lg px-3 py-2 text-left transition-colors hover:bg-black/[0.04] dark:hover:bg-white/[0.04] disabled:cursor-not-allowed disabled:opacity-50",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[18px]",children:"lan"}),(0,a.jsx)("span",{className:"truncate text-sm text-text-main",children:e.name}),!0!==e.isActive&&(0,a.jsx)("span",{className:"text-[10px] text-text-muted",children:"(inactive)"})]},e.id))]}),ef&&(0,a.jsx)("p",{className:"text-xs text-text-muted",children:"Applying..."}),(0,a.jsx)(d.$n,{onClick:tM,variant:"ghost",fullWidth:!0,disabled:ef,children:"Cancel"})]})}),tW=async e=>{if(!er.has(e)){en(t=>new Set([...t,e]));try{let t=await fetch("/api/models/test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:`${tu}/${e}`})}),s=await t.json();ea(t=>({...t,[e]:s.ok?"ok":"error"})),s.ok||el(s.error||"Model not reachable")}catch{ea(t=>({...t,[e]:"error"}))}finally{en(t=>{let s=new Set(t);return s.delete(e),s})}}},tV=async e=>{if(eo)return;ed(!0);let t=[];try{for(let s=0;s<e.length;s+=5){let a=e.slice(s,s+5);await Promise.all(a.map(async e=>{en(t=>new Set([...t,e.id]));try{let s=await fetch("/api/models/test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:`${tu}/${e.id}`})}),a=await s.json(),i=a.ok?"ok":"error";ea(t=>({...t,[e.id]:i})),a.ok&&t.push(e)}catch{ea(t=>({...t,[e.id]:"error"}))}finally{en(t=>{let s=new Set(t);return s.delete(e.id),s})}}))}for(let e of t)await tT(e.id,e.id,tu);t.length>0&&document.getElementById("available-models-section")?.scrollIntoView({behavior:"smooth"})}finally{ed(!1)}};if(g)return(0,a.jsxs)("div",{className:"flex flex-col gap-8",children:[(0,a.jsx)(d.Qv,{}),(0,a.jsx)(d.Qv,{})]});if(!te)return(0,a.jsxs)("div",{className:"text-center py-20",children:[(0,a.jsx)("p",{className:"text-text-muted",children:"Provider not found"}),(0,a.jsx)(n(),{href:"/dashboard/providers",className:"text-primary mt-4 inline-block",children:"Back to Providers"})]});let tH=()=>to&&te.apiType?"responses"===te.apiType?"/providers/oai-r.png":"/providers/oai-cc.png":td?"/providers/anthropic-m.png":`/providers/${te.id}.png`;return(0,a.jsxs)("div",{className:"flex min-w-0 flex-col gap-6 px-1 sm:gap-8 sm:px-0",children:[tt?(0,a.jsx)(I,{capabilities:tt,connectionCount:u.length,headerIconPath:ee?null:tH()}):(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsxs)(n(),{href:"/dashboard/providers",className:"inline-flex items-center gap-1 text-sm text-text-muted hover:text-primary transition-colors mb-4",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-lg",children:"arrow_back"}),"Back to Providers"]}),(0,a.jsxs)("div",{className:"flex min-w-0 items-center gap-3 sm:gap-4",children:[(0,a.jsx)("div",{className:"flex size-12 shrink-0 items-center justify-center rounded-lg",style:{backgroundColor:`${te.color}15`},children:ee?(0,a.jsx)("span",{className:"text-sm font-bold",style:{color:te.color},children:te.textIcon||te.id.slice(0,2).toUpperCase()}):(0,a.jsx)(o.default,{src:tH(),alt:te.name,width:48,height:48,className:"max-h-12 max-w-12 rounded-lg object-contain",sizes:"48px",onError:()=>et(!0)})}),(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsx)("h1",{className:"truncate text-2xl font-semibold tracking-tight sm:text-3xl",children:te.name}),(0,a.jsxs)("p",{className:"text-text-muted",children:[u.length," connection",1===u.length?"":"s"]})]})]})]}),tc&&j&&(0,a.jsx)(d.Zp,{children:(0,a.jsxs)("div",{className:"mb-4 flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsx)("h2",{className:"text-lg font-semibold",children:td?"Anthropic Compatible Details":"OpenAI Compatible Details"}),(0,a.jsxs)("p",{className:"break-all text-sm text-text-muted",children:[td?"Messages API":"responses"===j.apiType?"Responses API":"Chat Completions"," \xb7 ",(j.baseUrl||"").replace(/\/$/,""),"/",td?"messages":"responses"===j.apiType?"responses":"chat/completions"]})]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-2 sm:flex sm:items-center",children:[(0,a.jsx)(d.$n,{size:"sm",icon:"add",onClick:()=>{K(""),q(!0)},className:"w-full sm:w-auto",children:"Add API Key"}),(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",icon:"edit",onClick:()=>V(!0),className:"w-full sm:w-auto",children:"Edit"}),(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",icon:"delete",onClick:async()=>{eK({title:"Delete Compatible Node",message:`Delete this ${td?"Anthropic":"OpenAI"} Compatible node?`,onConfirm:async()=>{eK(null);try{(await fetch(`/api/provider-nodes/${r}`,{method:"DELETE"})).ok&&s.push("/dashboard/providers")}catch(e){console.log("Error deleting provider node:",e)}}})},className:"w-full sm:w-auto",children:"Delete"})]})]})}),tl?(0,a.jsx)(d.gw,{providerId:r}):(0,a.jsxs)(d.Zp,{children:[(0,a.jsxs)("div",{className:"mb-4 flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[(0,a.jsx)("h2",{className:"text-lg font-semibold",children:"Connections"}),(0,a.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:gap-4",children:[u.length>0&&A.length>0&&(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",icon:"lan",onClick:()=>G(!0),children:"Apply Proxy"}),u.length>0&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",icon:"sync",onClick:tO,disabled:eJ,children:eJ?"Testing Connection One-by-One...":"Test Connection One-by-One"}),eJ&&(0,a.jsx)(d.$n,{size:"sm",variant:"ghost",icon:"stop",onClick:()=>{eJ&&(e0.current=!0,eV(!0))},disabled:eW,children:eW?"Stopping...":"Stop"})]}),(0,a.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,a.jsx)("span",{className:"text-xs text-text-muted font-medium",children:"Round Robin"}),(0,a.jsx)(d.lM,{checked:"round-robin"===eb,onChange:e=>{let t=e?"round-robin":null,s=e?ev||"1":ev;e&&!ev&&ej("1"),ey(t),tk(t,s)}}),"round-robin"===eb&&(0,a.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,a.jsx)("span",{className:"text-xs text-text-muted",children:"Sticky:"}),(0,a.jsx)("input",{type:"number",min:1,value:ev,onChange:e=>{var t;ej(t=e.target.value),tk("round-robin",t)},placeholder:"1",className:"w-14 px-2 py-1 text-xs border border-border rounded-md bg-background focus:outline-none focus:border-primary"})]})]})]})]}),0===u.length?tt?(0,a.jsx)(R,{capabilities:tt,onOAuth:e7,onApiKey:e8,onFree:e9,onCookie:()=>z(!0),onCompatible:e8,onBulkImport:()=>F(!0)}):(0,a.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[(0,a.jsx)("div",{className:"inline-flex items-center justify-center w-9 h-9 rounded-full bg-primary/10 text-primary shrink-0",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"key"})}),(0,a.jsx)("p",{className:"text-sm text-text-muted",children:"No connections yet"})]}),(0,a.jsx)(d.$n,{size:"sm",icon:"add",onClick:e9,children:"Add API Key"})]}):(0,a.jsxs)(a.Fragment,{children:[eY&&(0,a.jsx)("div",{className:"mb-4 rounded-lg border border-black/10 bg-black/[0.02] px-3 py-2 text-xs text-text-muted dark:border-white/10 dark:bg-white/[0.03]",children:(0,a.jsxs)("div",{className:"flex flex-wrap items-center gap-3",children:[(0,a.jsxs)("span",{children:["Total: ",eY.total]}),(0,a.jsxs)("span",{children:["Completed: ",eY.completed]}),(0,a.jsxs)("span",{children:["Passed: ",eY.passed]}),(0,a.jsxs)("span",{children:["Failed: ",eY.failed]}),eY.stopped&&(0,a.jsx)("span",{className:"text-amber-600 dark:text-amber-400",children:"Stopped"}),eJ&&eH&&(0,a.jsxs)("span",{children:["Running: ",u.find(e=>e.id===eH)?.name||eH]})]})}),!tc&&tt&&(0,a.jsx)(D,{providerId:r,models:e$}),tF,!tc&&tt&&(0,a.jsx)(_,{providerId:r}),!tc&&(0,a.jsxs)("div",{className:"mt-4 grid grid-cols-1 gap-2 sm:flex",children:["iflow"===r&&(0,a.jsx)(d.$n,{size:"sm",icon:"cookie",variant:"secondary",onClick:()=>z(!0),title:"Add connection using browser cookie",className:"w-full sm:w-auto",children:"Cookie"}),"codex"===r&&(0,a.jsx)(d.$n,{size:"sm",icon:"playlist_add",variant:"secondary",onClick:()=>F(!0),title:(0,x.Tl)("Bulk import codex accounts from JSON"),className:"w-full sm:w-auto",children:(0,x.Tl)("Bulk Add")}),tm?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(d.$n,{size:"sm",icon:"lock",variant:"secondary",onClick:e7,className:"w-full sm:w-auto",children:tp}),(0,a.jsx)(d.$n,{size:"sm",icon:"key",onClick:e8,className:"w-full sm:w-auto",children:tx})]}):(0,a.jsx)(d.$n,{size:"sm",icon:"add",onClick:e9,className:"w-full sm:w-auto",children:"Add"})]})]})]}),(0,a.jsxs)(d.Zp,{id:"available-models-section",children:[(0,a.jsxs)("div",{className:"mb-4 flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between",children:[(0,a.jsx)("h2",{className:"text-lg font-semibold",children:"Available Models"}),!tc&&(e=[...tr,...e_.filter(e=>!tr.some(t=>t.id===e.id))].filter(e=>!e.type||"llm"===e.type).map(e=>e.id).filter(e=>!eU.includes(e)),(0,a.jsxs)("div",{className:"flex gap-2",children:[eU.length>0&&(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",icon:"restart_alt",onClick:tv,children:"Active All"}),e.length>0&&(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",icon:"block",onClick:()=>ty(e),children:"Disable All"})]}))]}),!!ei&&(0,a.jsx)("p",{className:"text-xs text-red-500 mb-3 break-words",children:ei}),(()=>{if(tc)return(0,a.jsx)(v,{providerStorageAlias:tu,providerDisplayAlias:th,modelAliases:Y,copied:e2,onCopy:e4,onSetAlias:tT,onDeleteAlias:tI,connections:u,isAnthropic:td});let e=[...tr,...e_.filter(e=>!tr.some(t=>t.id===e.id))].filter(e=>!e.type||"llm"===e.type),t=new Set(eU),s=e.filter(e=>!t.has(e.id)),i=e.filter(e=>t.has(e.id)),l=Object.entries(Y).filter(([e,t])=>{let s=`${tu}/`;if(!t.startsWith(s))return!1;let a=t.slice(s.length);return te.passthroughModels?!tr.some(e=>e.id===a):!tr.some(e=>e.id===a)&&e===a}).map(([e,t])=>({id:t.slice(`${tu}/`.length),alias:e,fullModel:t}));return(0,a.jsxs)("div",{className:"flex flex-wrap gap-3",children:[l.map(e=>(0,a.jsx)(b,{model:{id:e.id},fullModel:`${th}/${e.id}`,alias:e.alias,copied:e2,onCopy:e4,onSetAlias:()=>{},onDeleteAlias:()=>tI(e.alias),testStatus:es[e.id],onTest:u.length>0||tl?()=>tW(e.id):void 0,isTesting:er.has(e.id),isCustom:!0,isFree:!1},e.id)),s.map(e=>{let t=`${tu}/${e.id}`,s=`${r}/${e.id}`,i=Object.entries(Y).find(([,e])=>e===t||e===s)?.[0];return(0,a.jsx)(b,{model:e,fullModel:`${th}/${e.id}`,alias:i,copied:e2,onCopy:e4,onSetAlias:t=>tT(e.id,t,tu),onDeleteAlias:()=>tI(i),testStatus:es[e.id],onTest:u.length>0||tl?()=>tW(e.id):void 0,isTesting:er.has(e.id),isFree:e.isFree,onDisable:()=>tg(e.id)},e.id)}),(0,a.jsxs)("button",{onClick:()=>em(!0),className:"flex w-full items-center justify-center gap-1.5 rounded-lg border border-dashed border-primary/40 px-3 py-2 text-xs text-primary transition-colors hover:border-primary hover:bg-primary/5 sm:w-auto",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:"add"}),"Add Model"]}),"qoder"===r&&u.some(e=>!1!==e.isActive)&&(0,a.jsxs)("button",{onClick:tP,disabled:e1,className:"flex w-full items-center justify-center gap-1.5 rounded-lg border border-dashed border-blue-500/40 px-3 py-2 text-xs text-blue-600 dark:text-blue-400 transition-colors hover:border-blue-500 hover:bg-blue-500/5 sm:w-auto disabled:opacity-50 disabled:cursor-not-allowed",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",style:e1?{animation:"spin 1s linear infinite"}:void 0,children:e1?"progress_activity":"download"}),e1?(0,x.Tl)("Fetching..."):(0,x.Tl)("Fetch Qoder Models")]}),(()=>{let e=new Set([...s.map(e=>e.id),...l.map(e=>e.id)]),t=e$.length>0?e$:eS,r=e$.length>0,n=t.filter(t=>t.id&&!e.has(t.id)),o=new Set(e$.map(e=>e.id).filter(Boolean)),d=i.filter(e=>e.id&&!o.has(e.id)).map(e=>({...e,dropped:!0})),c=new Set(d.map(e=>e.id)),m=[...n.filter(e=>!c.has(e.id)),...d];if(!eI&&0===m.length&&0===t.length)return null;let p=eO.trim().toLowerCase(),x=p?m.filter(e=>e.id.toLowerCase().includes(p)||e.name&&e.name.toLowerCase().includes(p)):m,u={};x.forEach(e=>{if(!e.id)return;let t=e.id.includes("/")?e.id.split("/")[0]:"models";u[t]||(u[t]=[]),u[t].push(e)});let h=Object.entries(u).sort((e,t)=>t[1].length-e[1].length),f=x.filter(e=>!e.dropped).slice(0,50);return(0,a.jsxs)("div",{className:"w-full mt-4 space-y-2",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"text-xs font-medium text-text-muted shrink-0",children:eI?"Loading...":`${r?"From API":"Suggested"} (${n.length})${d.length>0?` \xb7 ${d.length} dropped`:""}`}),(0,a.jsxs)("div",{className:"relative flex-1 min-w-0",children:[(0,a.jsx)("span",{className:"material-symbols-outlined absolute left-2.5 top-1/2 -translate-y-1/2 text-[13px] text-text-muted/60 pointer-events-none select-none",children:"search"}),(0,a.jsx)("input",{type:"text",value:eO,onChange:e=>eE(e.target.value),placeholder:"Search models...",className:"w-full h-7 pl-7 pr-7 text-xs rounded-lg bg-bg border border-border-subtle text-text-main placeholder:text-text-muted/50 focus:outline-none focus:ring-1 focus:ring-primary/30 focus:border-primary/40 transition-colors"}),eO&&(0,a.jsx)("button",{onClick:()=>eE(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-text-muted/50 hover:text-text-muted transition-colors",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[13px]",children:"close"})})]}),(0,a.jsx)("button",{onClick:t$,disabled:eI,title:"Refresh",className:"shrink-0 h-7 w-7 flex items-center justify-center rounded-lg border border-border-subtle text-text-muted hover:text-primary hover:border-primary/40 hover:bg-primary/5 transition-colors disabled:opacity-40",children:(0,a.jsx)("span",{className:`material-symbols-outlined text-[14px] ${eI?"animate-spin":""}`,children:"refresh"})}),!eI&&f.length>0&&(0,a.jsxs)("button",{onClick:()=>tV(f),disabled:eo,title:`Test up to ${f.length} models and auto-add passing ones`,className:"shrink-0 h-7 flex items-center gap-1 px-2.5 rounded-lg border border-border-subtle text-xs text-text-muted hover:text-green-600 hover:border-green-500/40 hover:bg-green-500/5 transition-colors disabled:opacity-40",children:[(0,a.jsx)("span",{className:`material-symbols-outlined text-[13px] ${eo?"animate-spin":""}`,children:eo?"progress_activity":"play_circle"}),eo?"Testing...":"Test All"]})]}),p&&(0,a.jsxs)("p",{className:"text-xs text-text-muted",children:[x.length," result",1!==x.length?"s":""]}),eI?(0,a.jsxs)("div",{className:"flex items-center gap-2 py-4 text-xs text-text-muted",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[15px] animate-spin",children:"progress_activity"}),"Fetching models from provider API..."]}):0===h.length?p?(0,a.jsxs)("p",{className:"text-xs text-text-muted py-2",children:['No models match "',eO,'"']}):null:(0,a.jsx)("div",{className:"space-y-1",children:h.map(([e,t])=>{let s=eR.has(e),i=t.filter(e=>!e.dropped&&"ok"===es[e.id]).length,l=t.filter(e=>!e.dropped&&"error"===es[e.id]).length,r=t.filter(e=>e.dropped).length;return(0,a.jsxs)("div",{className:"rounded-xl border border-border-subtle overflow-hidden",children:[(0,a.jsxs)("button",{onClick:()=>eD(t=>{let s=new Set(t);return s.has(e)?s.delete(e):s.add(e),s}),className:"w-full flex items-center gap-2 px-3 py-2 text-xs bg-bg hover:bg-surface-2/60 transition-colors text-left",children:[(0,a.jsx)("span",{className:"font-semibold text-text-main flex-1",children:e}),i>0&&(0,a.jsxs)("span",{className:"text-green-600 dark:text-green-400 font-medium",children:[i," ✓"]}),l>0&&(0,a.jsxs)("span",{className:"text-red-500 font-medium",children:[l," ✗"]}),r>0&&(0,a.jsxs)("span",{className:"px-1.5 py-0.5 rounded-md bg-amber-500/10 text-amber-600 dark:text-amber-400 text-[10px] font-medium",children:[r," dropped"]}),(0,a.jsx)("span",{className:"px-1.5 py-0.5 rounded-md bg-black/[0.06] dark:bg-white/[0.06] text-text-muted tabular-nums font-medium",children:t.length}),(0,a.jsx)("span",{className:"material-symbols-outlined text-[15px] text-text-muted/60",children:s?"expand_less":"expand_more"})]}),s&&(0,a.jsx)("div",{className:"px-3 pt-2 pb-3 flex flex-wrap gap-1.5 border-t border-border-subtle bg-surface/50",children:t.map(e=>{let t=e.id.includes("/")?e.id.split("/").slice(1).join("/"):e.id,s=es[e.id],i=er.has(e.id);return e.dropped?(0,a.jsxs)("button",{onClick:async()=>{await tb(e.id),document.getElementById("available-models-section")?.scrollIntoView({behavior:"smooth"})},title:`Recently Dropped — click to restore: ${e.id}`,className:"group flex items-center gap-1 px-2.5 py-1.5 rounded-lg border border-amber-400/40 bg-amber-500/5 text-amber-700 dark:text-amber-400 text-xs hover:bg-amber-500/10 hover:border-amber-400/60 transition-colors",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[12px]",children:"history"}),(0,a.jsx)("span",{children:t}),e.contextLength>0&&(0,a.jsxs)("span",{className:"opacity-50 text-[10px] ml-0.5",children:[(e.contextLength/1e3).toFixed(0),"k"]})]},e.id):(0,a.jsxs)("button",{onClick:async()=>{await tT(e.id,e.id,tu),document.getElementById("available-models-section")?.scrollIntoView({behavior:"smooth"})},title:`Add: ${e.name||e.id}`,className:["group flex items-center gap-1 px-2.5 py-1.5 rounded-lg border text-xs transition-colors","ok"===s?"border-green-500/30 bg-green-500/5 text-green-700 dark:text-green-400 hover:bg-green-500/10":"error"===s?"border-red-400/30 bg-red-500/5 text-red-600 dark:text-red-400 hover:bg-red-500/10":"border-border-subtle text-text-muted hover:text-primary hover:border-primary/40 hover:bg-primary/5"].join(" "),children:[i?(0,a.jsx)("span",{className:"material-symbols-outlined text-[12px] animate-spin",children:"progress_activity"}):"ok"===s?(0,a.jsx)("span",{className:"material-symbols-outlined text-[12px]",children:"check"}):"error"===s?(0,a.jsx)("span",{className:"material-symbols-outlined text-[12px]",children:"close"}):(0,a.jsx)("span",{className:"material-symbols-outlined text-[12px] opacity-50 group-hover:opacity-100",children:"add"}),(0,a.jsx)("span",{children:t}),e.contextLength>0&&(0,a.jsxs)("span",{className:"opacity-40 text-[10px] ml-0.5",children:[(e.contextLength/1e3).toFixed(0),"k"]})]},e.id)})})]},e)})})]})})()]})})()]}),tB,"kiro"===r?(0,a.jsx)(d.Mh,{isOpen:P,providerInfo:te,onSuccess:tR,onClose:()=>O(!1)}):"cursor"===r?(0,a.jsx)(d.G9,{isOpen:P,onSuccess:tR,onClose:()=>O(!1)}):"gitlab"===r?(0,a.jsx)(d.vj,{isOpen:P,providerInfo:te,onSuccess:tR,onClose:()=>O(!1)}):(0,a.jsx)(d.LF,{isOpen:P,provider:r,providerInfo:te,onSuccess:tR,onClose:()=>O(!1)}),"iflow"===r&&(0,a.jsx)(d.vE,{isOpen:E,onSuccess:()=>{tN(),z(!1)},onClose:()=>z(!1)}),(0,a.jsx)(k,{isOpen:U,provider:r,providerName:te.name,isCompatible:tc,isAnthropic:td,authType:te?.authType,authHint:te?.authHint,website:te?.website,proxyPools:A,error:M,existingNames:u.map(e=>e.name).filter(Boolean),onSave:tD,onBulkDone:tN,onClose:()=>{K(""),q(!1)}}),(0,a.jsx)(d.wI,{isOpen:J,connection:Q,proxyPools:A,onSave:t_,onClose:()=>B(!1)}),tc&&(0,a.jsx)(C,{isOpen:W,node:j,onSave:tw,onClose:()=>V(!1),isAnthropic:td}),!tc&&(0,a.jsx)(S,{isOpen:ec,providerAlias:tu,providerDisplayAlias:th,onSave:async e=>{let t=te?.passthroughModels?e.split("/").pop():e;await tT(e,t,tu),em(!1)},onClose:()=>em(!1)}),"codex"===r&&(0,a.jsx)($,{isOpen:L,onClose:()=>F(!1),onSuccess:tN}),(0,a.jsx)(d.uo,{isOpen:eL,onClose:()=>eF(!1),onConfirm:()=>{(window.localStorage.setItem(e3,"true"),eF(!1),ta)?e6():e8()},title:"Risk Notice",message:te?.deprecationNotice,confirmText:"I Understand, Continue",cancelText:"Cancel",variant:"danger"}),(0,a.jsx)(d.uo,{isOpen:!!eM,onClose:()=>eK(null),onConfirm:eM?.onConfirm,title:eM?.title||"Confirm",message:eM?.message,variant:"danger"})]})}R.propTypes={capabilities:g().object,onOAuth:g().func,onApiKey:g().func,onFree:g().func,onCookie:g().func,onCompatible:g().func,onBulkImport:g().func},D.propTypes={providerId:g().string.isRequired,models:g().array},_.propTypes={providerId:g().string.isRequired}}},e=>{e.O(0,[7504,5772,1321,5497,8441,3794,7358],()=>e(e.s=76487)),_N_E=e.O()}]);
11
+ ]`;function $({isOpen:e,onClose:t,onSuccess:s}){let[l,r]=(0,i.useState)(""),[n,o]=(0,i.useState)(!1),[c,m]=(0,i.useState)(""),[p,u]=(0,i.useState)(null),h=()=>{n||(r(""),m(""),u(null),t())},f=async()=>{var e;let t;m(""),u(null);let a=l.trim();if(!a)return;try{t=JSON.parse(a)}catch(e){m(`${(0,x.Tl)("Invalid JSON")}: ${e.message}`);return}let i=Array.isArray(e=t)?e:e&&"object"==typeof e?Array.isArray(e.accounts)?e.accounts:[e]:null;if(!i||0===i.length)return void m((0,x.Tl)("No accounts found in input"));o(!0);try{let e=await fetch("/api/oauth/codex/bulk-import",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({accounts:i})}),t=await e.json();if(!e.ok)return void m(t?.error||`Request failed: ${e.status}`);u(t),t.success>0&&"function"==typeof s&&s()}catch(e){m(e.message||(0,x.Tl)("Request failed"))}finally{o(!1)}},g=p?.results?.filter(e=>!e.ok)||[];return(0,a.jsx)(d.aF,{isOpen:e,title:(0,x.Tl)("Bulk Add Codex Accounts"),onClose:h,children:(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,a.jsx)("p",{className:"text-xs text-text-muted",children:(0,x.Tl)("Paste an array of codex account JSON objects. Each must include accessToken (and ideally refreshToken, idToken).")}),(0,a.jsx)("textarea",{className:"w-full rounded border border-accent/30 bg-sidebar p-2 text-sm font-mono resize-y min-h-[240px] focus:outline-none focus:ring-1 focus:ring-primary",placeholder:A,value:l,onChange:e=>r(e.target.value),disabled:n}),c&&(0,a.jsx)("p",{className:"text-xs text-red-500 break-words",children:c}),p&&(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,a.jsxs)("div",{className:`text-sm font-medium ${p.failed>0?"text-yellow-400":"text-green-400"}`,children:["✓ ",p.success," ",(0,x.Tl)("added"),p.failed>0?`, ✗ ${p.failed} ${(0,x.Tl)("failed")}`:""]}),g.length>0&&(0,a.jsx)("ul",{className:"rounded border border-accent/20 bg-sidebar/50 p-2 text-xs font-mono max-h-40 overflow-y-auto",children:g.map(e=>(0,a.jsxs)("li",{className:"text-red-400",children:["[",e.index,"] ",e.error]},e.index))})]}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(d.$n,{onClick:f,fullWidth:!0,disabled:n||!l.trim(),children:n?(0,x.Tl)("Importing..."):(0,x.Tl)("Import All")}),(0,a.jsx)(d.$n,{onClick:h,variant:"ghost",fullWidth:!0,disabled:n,children:(0,x.Tl)("Close")})]})]})})}$.propTypes={isOpen:g().bool.isRequired,onClose:g().func.isRequired,onSuccess:g().func};let T={free:{label:"Free",variant:"success",accent:"green"},freetier:{label:"Free tier",variant:"success",accent:"emerald"},oauth:{label:"OAuth",variant:"primary",accent:"primary"},paid:{label:"API key",variant:"default",accent:"neutral"},webcookie:{label:"Cookie",variant:"warning",accent:"amber"}};function I({capabilities:e,connectionCount:t=0,headerIconPath:s}){let[l,r]=(0,i.useState)(!1);if(!e)return null;let c=T[e.tier]||T.paid,m=e.color?`${e.color}10`:"rgba(148,163,184,0.08)",p=e.color?`${e.color}30`:"rgba(148,163,184,0.20)",x=[];return e.links.apiKey&&x.push({href:e.links.apiKey,icon:"key",label:"Get API key"}),e.links.signup&&!e.links.apiKey&&x.push({href:e.links.signup,icon:"person_add",label:"Sign up"}),e.links.homepage&&x.push({href:e.links.homepage,icon:"language",label:"Homepage"}),e.links.docs&&x.push({href:e.links.docs,icon:"menu_book",label:"Docs"}),e.links.pricing&&x.push({href:e.links.pricing,icon:"sell",label:"Pricing"}),(0,a.jsxs)("div",{className:"flex min-w-0 flex-col gap-4",children:[(0,a.jsxs)(n(),{href:"/dashboard/providers",className:"inline-flex items-center gap-1 text-sm text-text-muted hover:text-primary transition-colors",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-lg",children:"arrow_back"}),"Back to Providers"]}),(0,a.jsxs)("div",{className:"relative overflow-hidden rounded-2xl border p-5 sm:p-7",style:{borderColor:p,background:`linear-gradient(140deg, ${m} 0%, transparent 55%)`},children:[(0,a.jsxs)("div",{className:"flex min-w-0 flex-col gap-5 sm:flex-row sm:items-start sm:justify-between",children:[(0,a.jsxs)("div",{className:"flex min-w-0 items-start gap-4",children:[(0,a.jsx)("div",{className:"flex size-14 shrink-0 items-center justify-center rounded-xl shadow-sm",style:{backgroundColor:e.color?`${e.color}20`:"rgba(148,163,184,0.15)"},children:l||!s?(0,a.jsx)("span",{className:"text-base font-bold",style:{color:e.color||"inherit"},children:e.textIcon||e.id.slice(0,2).toUpperCase()}):(0,a.jsx)(o.default,{src:s,alt:e.name,width:56,height:56,className:"max-h-14 max-w-14 rounded-xl object-contain",sizes:"56px",onError:()=>r(!0)})}),(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,a.jsx)("h1",{className:"truncate text-2xl font-semibold tracking-tight sm:text-3xl",children:e.name}),(0,a.jsx)(d.Ex,{variant:c.variant,size:"sm",children:c.label}),e.deprecated&&(0,a.jsx)(d.Ex,{variant:"warning",size:"sm",children:"deprecated"})]}),(0,a.jsxs)("p",{className:"mt-1 text-sm text-text-muted",children:[t," connection",1===t?"":"s",e.serviceKinds.length>1&&(0,a.jsxs)(a.Fragment,{children:[" \xb7 ",e.serviceKinds.join(" \xb7 ")]})]})]})]}),x.length>0&&(0,a.jsx)("div",{className:"flex flex-wrap gap-1.5 sm:justify-end",children:x.map(e=>(0,a.jsxs)("a",{href:e.href,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 rounded-full border border-border bg-bg/60 px-2.5 py-1 text-xs text-text-main hover:border-primary hover:text-primary transition-colors backdrop-blur",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:e.icon}),e.label]},e.label))})]}),e.notices.body&&!e.deprecated&&(0,a.jsx)("p",{className:"mt-4 max-w-3xl text-sm leading-relaxed text-text-muted",children:e.notices.body})]}),e.deprecated&&e.notices.warning&&(0,a.jsxs)("div",{className:"flex items-start gap-2 rounded-lg border border-yellow-500/30 bg-yellow-500/10 px-3 py-2",children:[(0,a.jsx)("span",{className:"material-symbols-outlined mt-0.5 shrink-0 text-[16px] text-yellow-500",children:"warning"}),(0,a.jsx)("p",{className:"text-xs leading-relaxed text-red-600 dark:text-yellow-400",children:e.notices.warning})]})]})}I.propTypes={capabilities:g().object,connectionCount:g().number,headerIconPath:g().string};let P={oauth:{icon:"lock",label:"Sign in with OAuth",tabLabel:"OAuth"},apikey:{icon:"key",label:"Add API key",tabLabel:"API key"},free:{icon:"bolt",label:"Connect for free",tabLabel:"Free"},cookie:{icon:"cookie",label:"Paste session cookie",tabLabel:"Cookie"},compatible:{icon:"developer_board",label:"Configure endpoint",tabLabel:"Compatible"}};function O({children:e,accentColor:t}){return(0,a.jsx)("div",{className:"rounded-xl border p-5 sm:p-6",style:{borderColor:t?`${t}25`:void 0,background:t?`linear-gradient(160deg, ${t}08, transparent 70%)`:void 0},children:e})}let E={oauth:function({capabilities:e,onOAuth:t,onBulkImport:s}){return(0,a.jsx)(O,{accentColor:e.color,children:(0,a.jsxs)("div",{className:"flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between",children:[(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsxs)("h3",{className:"text-base font-semibold",children:["Sign in with ",e.name]}),(0,a.jsx)("p",{className:"mt-0.5 text-sm text-text-muted",children:"One click. We handle the OAuth callback and store your session locally. You can add multiple accounts."})]}),(0,a.jsxs)("div",{className:"flex flex-wrap gap-2 sm:flex-nowrap",children:[e.features.bulkImport&&s&&(0,a.jsx)(d.$n,{size:"md",icon:"playlist_add",variant:"secondary",onClick:s,children:"Bulk import"}),(0,a.jsxs)(d.$n,{size:"md",icon:"lock",onClick:t,children:["Sign in with ",e.name]})]})]})})},apikey:function({capabilities:e,onApiKey:t}){return(0,a.jsx)(O,{accentColor:e.color,children:(0,a.jsxs)("div",{className:"flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between",children:[(0,a.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,a.jsxs)("h3",{className:"text-base font-semibold",children:["Paste your ",e.name," API key"]}),(0,a.jsxs)("p",{className:"mt-0.5 text-sm text-text-muted",children:[e.links.apiKey?(0,a.jsxs)(a.Fragment,{children:["Grab a key from"," ",(0,a.jsx)("a",{href:e.links.apiKey,target:"_blank",rel:"noopener noreferrer",className:"text-primary underline decoration-primary/40 underline-offset-4 hover:decoration-primary",children:new URL(e.links.apiKey).hostname})," ","and paste it in."]}):(0,a.jsx)(a.Fragment,{children:"Paste your API key to connect."})," ","Stored locally, never sent anywhere except ",e.name,"."]})]}),(0,a.jsx)(d.$n,{size:"md",icon:"key",onClick:t,children:"Add API key"})]})})},free:function({capabilities:e,onFree:t}){return(0,a.jsx)(O,{accentColor:e.color||"#10B981",children:(0,a.jsxs)("div",{className:"flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between",children:[(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsxs)("div",{className:"mb-1 flex items-center gap-2",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px] text-green-500",children:"bolt"}),(0,a.jsxs)("h3",{className:"text-base font-semibold",children:[e.name," is free — one click to connect"]})]}),(0,a.jsx)("p",{className:"text-sm text-text-muted",children:"No key, no signup, no card. Just click connect and start using it."})]}),(0,a.jsx)(d.$n,{size:"md",icon:"add",onClick:t,children:"Connect"})]})})},cookie:function({capabilities:e,onCookie:t}){let[s,l]=(0,i.useState)(!1);return(0,a.jsx)(O,{accentColor:e.color||"#F59E0B",children:(0,a.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,a.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsx)("h3",{className:"text-base font-semibold",children:"Advanced: connect with session cookie"}),(0,a.jsxs)("p",{className:"mt-0.5 text-sm text-text-muted",children:["For power users. Extract the ",e.name," cookie from your browser and paste it here."]})]}),(0,a.jsx)("button",{type:"button",onClick:()=>l(e=>!e),className:"text-xs text-text-muted hover:text-primary",children:s?"hide":"show"})]}),s&&(0,a.jsxs)("div",{className:"rounded-lg border border-border bg-bg/70 p-3",children:[(0,a.jsxs)("ol",{className:"mb-3 list-decimal space-y-1 pl-4 text-xs text-text-muted",children:[(0,a.jsxs)("li",{children:["Open ",e.name," in your browser and sign in."]}),(0,a.jsx)("li",{children:"Open DevTools → Application → Cookies."}),(0,a.jsx)("li",{children:"Copy the session cookie value."}),(0,a.jsx)("li",{children:"Paste it in the modal."})]}),(0,a.jsx)(d.$n,{size:"sm",icon:"cookie",onClick:t,children:"Paste cookie"})]})]})})},compatible:function({capabilities:e,onCompatible:t}){return(0,a.jsx)(O,{accentColor:e.color,children:(0,a.jsxs)("div",{className:"flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between",children:[(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsx)("h3",{className:"text-base font-semibold",children:"Use as OpenAI-compatible endpoint"}),(0,a.jsx)("p",{className:"mt-0.5 text-sm text-text-muted",children:"Point at any OpenAI-shaped base URL (self-hosted, LiteLLM, custom proxy). Fetches the live model list after you connect."})]}),(0,a.jsx)(d.$n,{size:"md",icon:"developer_board",onClick:t,children:"Configure endpoint"})]})})}};function R({capabilities:e,onOAuth:t,onApiKey:s,onFree:l,onCookie:r,onCompatible:n,onBulkImport:o}){let d=e?.authModes||[],[c,m]=(0,i.useState)(d[0]||"apikey");if(!e||0===d.length)return null;let p=E[c]||E.apikey,x=d.length>1;return(0,a.jsxs)("div",{className:"flex min-w-0 flex-col gap-3",children:[x&&(0,a.jsx)("div",{className:"flex flex-wrap gap-1 rounded-lg border border-border bg-sidebar/40 p-1",children:d.map(e=>{let t=P[e]||{icon:"add",tabLabel:e},s=e===c;return(0,a.jsxs)("button",{type:"button",onClick:()=>m(e),className:`inline-flex items-center gap-1.5 rounded-md px-3 py-1.5 text-xs font-medium transition-colors ${s?"bg-bg text-text-main shadow-sm":"text-text-muted hover:text-text-main"}`,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:t.icon}),t.tabLabel]},e)})}),(0,a.jsx)(p,{capabilities:e,onOAuth:t,onApiKey:s,onFree:l,onCookie:r,onCompatible:n,onBulkImport:o})]})}function D({providerId:e,models:t=[]}){let[s,l]=(0,i.useState)(""),[r,n]=(0,i.useState)({status:"idle"}),o=(0,i.useCallback)(async()=>{if(e){n(e=>({...e,status:"ok"===e.status?"refreshing":"loading"}));try{let t=new URLSearchParams({providerId:e});s&&t.set("model",s);let a=await fetch(`/api/providers/zenith?${t.toString()}`,{cache:"no-store"}),i=await a.json();i.success?n({status:"ok",winner:i.winner,count:i.count,leaderboard:i.leaderboard}):n({status:"error",error:i.error||"Zenith read failed"})}catch(e){n({status:"error",error:e?.message||"Network error"})}}},[e,s]);if((0,i.useEffect)(()=>{o();let e=setInterval(o,1e4);return()=>clearInterval(e)},[o]),"idle"===r.status||"loading"===r.status||"error"===r.status||!r.winner||(r.count??0)<2)return null;let d=r.winner;return(0,a.jsxs)("div",{className:"mb-3 flex flex-wrap items-center gap-2 rounded-lg border border-primary/20 bg-primary/[0.04] px-3 py-2 text-xs",children:[(0,a.jsxs)("span",{className:"inline-flex items-center gap-1 text-primary font-medium",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:"route"}),"Next request →"]}),(0,a.jsx)("span",{className:"font-medium text-text-main",children:d.name}),(0,a.jsxs)("span",{className:"rounded-md border border-primary/30 bg-primary/10 px-1.5 py-0.5 font-mono text-[10px] text-primary",children:["Z:",d.finalScore]}),(0,a.jsxs)("span",{className:"text-text-muted",children:["health ",d.healthScore," \xb7 quota \xd7",d.quotaFactor," \xb7 priority +",d.priorityBonus]}),t.length>0&&(0,a.jsxs)("div",{className:"ml-auto flex items-center gap-1.5",children:[(0,a.jsx)("span",{className:"text-text-muted",children:"Model:"}),(0,a.jsxs)("select",{value:s,onChange:e=>l(e.target.value),className:"rounded-md border border-border bg-bg px-1.5 py-0.5 text-[11px] focus:outline-none focus:border-primary",children:[(0,a.jsx)("option",{value:"",children:"(any)"}),t.map(e=>(0,a.jsx)("option",{value:e.id,children:e.id},e.id))]})]})]})}function _({providerId:e}){let[t,s]=(0,i.useState)(!1),[l,r]=(0,i.useState)([]),[n,o]=(0,i.useState)(!1),d=(0,i.useCallback)(async()=>{if(e){o(!0);try{let t=await fetch(`/api/providers/zenith/log?providerId=${e}&limit=50`,{cache:"no-store"}),s=await t.json();s.success&&r(s.entries||[])}catch{}finally{o(!1)}}},[e]);return(0,i.useEffect)(()=>{if(!t)return;d();let e=setInterval(d,5e3);return()=>clearInterval(e)},[t,d]),(0,a.jsxs)("div",{className:"mt-4 rounded-lg border border-border",children:[(0,a.jsxs)("button",{type:"button",onClick:()=>s(e=>!e),className:"flex w-full items-center justify-between px-3 py-2 text-xs text-text-muted hover:text-text-main",children:[(0,a.jsxs)("span",{className:"inline-flex items-center gap-1.5",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:"history"}),"Routing decisions",l.length>0&&(0,a.jsxs)("span",{className:"text-text-muted",children:["(",l.length,")"]})]}),(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:t?"expand_less":"expand_more"})]}),t&&(0,a.jsxs)("div",{className:"max-h-64 overflow-y-auto border-t border-border/50 px-3 py-2",children:[n&&0===l.length&&(0,a.jsx)("p",{className:"text-xs text-text-muted",children:"Loading…"}),!n&&0===l.length&&(0,a.jsx)("p",{className:"text-xs text-text-muted",children:"No decisions recorded yet. Fire a request through kRouter to populate."}),(0,a.jsx)("ul",{className:"space-y-1",children:l.map((e,t)=>(0,a.jsxs)("li",{className:"flex flex-wrap items-center gap-2 border-b border-border/30 py-1 text-[11px] font-mono last:border-0",children:[(0,a.jsx)("span",{className:"text-text-muted",children:function(e){let t=Math.floor((Date.now()-e)/1e3);if(t<5)return"just now";if(t<60)return`${t}s ago`;let s=Math.floor(t/60);return s<60?`${s}m ago`:`${Math.floor(s/60)}h ago`}(e.at)}),e.model&&(0,a.jsx)("span",{className:"text-text-main",children:e.model}),(0,a.jsx)("span",{className:"text-text-muted",children:"→"}),(0,a.jsx)("span",{className:"text-text-main",children:e.connectionId.slice(0,8)}),null!=e.score&&(0,a.jsxs)("span",{className:"text-primary",children:["Z:",e.score]}),null!=e.latencyMs&&(0,a.jsxs)("span",{className:"text-text-muted",children:[e.latencyMs,"ms"]}),(0,a.jsx)("span",{className:e.success?"text-green-500":"text-red-500",children:e.success?"✓":"✗"})]},`${e.at}-${t}`))})]})]})}function z(){let e,t=(0,l.useParams)(),s=(0,l.useRouter)(),r=t.id,[u,f]=(0,i.useState)([]),[g,y]=(0,i.useState)(!0),[j,w]=(0,i.useState)(null),[A,T]=(0,i.useState)([]),[P,O]=(0,i.useState)(!1),[E,z]=(0,i.useState)(!1),[U,q]=(0,i.useState)(!1),[M,K]=(0,i.useState)(""),[L,F]=(0,i.useState)(!1),[J,B]=(0,i.useState)(!1),[W,V]=(0,i.useState)(!1),[H,G]=(0,i.useState)(!1),[Q,Z]=(0,i.useState)(null),[Y,X]=(0,i.useState)({}),[ee,et]=(0,i.useState)(!1),[es,ea]=(0,i.useState)({}),[ei,el]=(0,i.useState)(""),[er,en]=(0,i.useState)(new Set),[eo,ed]=(0,i.useState)(!1),[ec,em]=(0,i.useState)(!1),[ep,ex]=(0,i.useState)([]),[eu,eh]=(0,i.useState)("__none__"),[ef,eg]=(0,i.useState)(!1),[eb,ey]=(0,i.useState)(null),[ev,ej]=(0,i.useState)(""),[eN,ew]=(0,i.useState)("auto"),[ek,eC]=(0,i.useState)({enabled:!1,connections:{}}),[eS,eA]=(0,i.useState)([]),[e$,eT]=(0,i.useState)([]),[eI,eP]=(0,i.useState)(!1),[eO,eE]=(0,i.useState)(""),[eR,eD]=(0,i.useState)(new Set),[e_,ez]=(0,i.useState)([]),[eU,eq]=(0,i.useState)([]),[eM,eK]=(0,i.useState)(null),[eL,eF]=(0,i.useState)(!1),[eJ,eB]=(0,i.useState)(!1),[eW,eV]=(0,i.useState)(!1),[eH,eG]=(0,i.useState)(null),[eQ,eZ]=(0,i.useState)({}),[eY,eX]=(0,i.useState)(null),e0=(0,i.useRef)(!1),[e1,e5]=(0,i.useState)(!1),{copied:e2,copy:e4}=(0,p.C)(),e3="ag_risk_confirmed",e6=()=>{O(!0)},e7=()=>{"antigravity"===r&&"true"!==window.localStorage.getItem(e3)?eF(!0):tl?e6():(K(""),q(!0))},e8=()=>{K(""),q(!0)},e9=()=>{tl?e7():e8()},te=j?{id:j.id,name:j.name||("anthropic-compatible"===j.type?"Anthropic Compatible":"OpenAI Compatible"),color:"anthropic-compatible"===j.type?"#D97757":"#10A37F",textIcon:"anthropic-compatible"===j.type?"AC":"OC",apiType:j.apiType,baseUrl:j.baseUrl,type:j.type}:c.zN[r]||c.fg[r]||c.IS[r]||c.nJ[r]||c.br[r],tt=j?null:function(e){let t=c.zN[e]?c.zN:c.fg[e]?c.fg:c.IS[e]?c.IS:c.nJ[e]?c.nJ:c.br[e]?c.br:null;if(!t)return null;let s=t[e],a=t===c.IS&&s?.noAuth?"free":t===c.IS||t===c.zN?"oauth":t===c.br?"cookie":t===c.fg&&s?.noAuth?"free":(t===c.fg||c.nJ,"apikey"),i=Array.isArray(s.authModes)?s.authModes.filter(e=>e!==a):[],l=[a,...i],r=(0,c.mq)(e)||(0,c.gb)(e);r&&!l.includes("compatible")&&l.push("compatible");let n=s.notice||{};return{id:e,name:s.name||e,icon:s.icon,image:s.image,textIcon:s.textIcon,color:s.color,tier:t===c.IS?"free":t===c.nJ?"freetier":t===c.zN?"oauth":t===c.br?"webcookie":s?.noAuth?"free":"paid",authModes:l,links:{homepage:s.website,apiKey:n.apiKeyUrl,signup:n.signupUrl,pricing:s.searchViaChat?.pricingUrl,docs:s.docsUrl},features:{autoPing:"claude"===e&&"oauth"===a,bulkImport:"codex"===e,compatibleModels:r,customModels:!s.passthroughModels,passthroughModels:!!s.passthroughModels,hasRegions:Array.isArray(s.regions)&&s.regions.length>0,hasProviderSpecificData:!!s.hasProviderSpecificData},serviceKinds:s.serviceKinds||["llm"],thinking:s.thinkingConfig||null,notices:{body:n.text,warning:s.deprecationNotice},deprecated:!!s.deprecated,regions:s.regions,defaultRegion:s.defaultRegion,noAuth:!!s.noAuth,_raw:s}}(r),ts="codex"===r?"codexAutoPing":"claudeAutoPing",ta="claude"===r||"codex"===r,ti=te?.authModes||[],tl=!!c.zN[r]||!!c.IS[r]||ti.includes("oauth"),tr=!!c.fg[r]||ti.includes("apikey"),tn=!!c.IS[r]?.noAuth,to=(0,m.KC)(r),td=(0,c.wG)(r),tc=(0,c.mq)(r),tm=(0,c.gb)(r),tp=tc||tm,tx=!tp&&tl&&tr,tu="xai"===r?"Grok Build OAuth":"OAuth",th="xai"===r?"xAI API Key":"API Key";c.Q2[r]?.thinkingConfig||c.s9.extended;let tf=tp?r:td,tg=tp?j?.prefix||r:td,tb=(0,i.useCallback)(async()=>{try{let e=await fetch(`/api/models/disabled?providerAlias=${encodeURIComponent(tf)}`,{cache:"no-store"}),t=await e.json();e.ok&&eq(t.ids||[])}catch(e){console.log("Error fetching disabled models:",e)}},[tf]),ty=async e=>{try{(await fetch("/api/models/disabled",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerAlias:tf,ids:[e]})})).ok&&await tb()}catch(e){console.log("Error disabling model:",e)}},tv=async e=>{try{(await fetch(`/api/models/disabled?providerAlias=${encodeURIComponent(tf)}&id=${encodeURIComponent(e)}`,{method:"DELETE"})).ok&&await tb()}catch(e){console.log("Error enabling model:",e)}},tj=async e=>{e.length&&eK({title:"Disable All Models",message:`Disable all ${e.length} model(s)?`,onConfirm:async()=>{eK(null);try{(await fetch("/api/models/disabled",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerAlias:tf,ids:e})})).ok&&await tb()}catch(e){console.log("Error disabling all models:",e)}}})},tN=async()=>{try{(await fetch(`/api/models/disabled?providerAlias=${encodeURIComponent(tf)}`,{method:"DELETE"})).ok&&await tb()}catch(e){console.log("Error enabling all models:",e)}},tw=(0,i.useCallback)(async()=>{try{let e=await fetch("/api/models/alias"),t=await e.json();e.ok&&X(t.aliases||{})}catch(e){console.log("Error fetching aliases:",e)}},[]);(0,i.useEffect)(()=>{"kilocode"===r&&fetch("/api/providers/kilo/free-models").then(e=>e.json()).then(e=>{e.models?.length&&ez(e.models)}).catch(()=>{})},[r]);let tk=(0,i.useCallback)(async()=>{try{let[e,t,s,a]=await Promise.all([fetch("/api/providers",{cache:"no-store"}),fetch("/api/provider-nodes",{cache:"no-store"}),fetch("/api/proxy-pools?isActive=true",{cache:"no-store"}),fetch("/api/settings",{cache:"no-store"})]),i=await e.json(),l=await t.json(),n=await s.json(),o=a.ok?await a.json():{};if(e.ok){let e=(i.connections||[]).filter(e=>e.provider===r);f(e)}s.ok&&T(n.proxyPools||[]);let d=(o.providerStrategies||{})[r]||{};ey(d.fallbackStrategy||null),ej(null!=d.stickyRoundRobinLimit?String(d.stickyRoundRobinLimit):"1");let c=(o.providerThinking||{})[r]||{};ew(c.mode||"auto");let m=o[ts]||{};if(eC({enabled:!0===m.enabled,connections:m.connections||{}}),t.ok){let e=(l.nodes||[]).find(e=>e.id===r)||null;if(!e&&tp)for(let t=0;t<3;t+=1){await new Promise(e=>setTimeout(e,150));let t=await fetch("/api/provider-nodes",{cache:"no-store"});if(t.ok&&(e=((await t.json()).nodes||[]).find(e=>e.id===r)||null))break}w(e)}}catch(e){console.log("Error fetching connections:",e)}finally{y(!1)}},[r,tp]),tC=async e=>{try{let t=await fetch(`/api/provider-nodes/${r}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),s=await t.json();t.ok&&(w(s.node),await tk(),V(!1))}catch(e){console.log("Error updating provider node:",e)}},tS=async(e,t)=>{try{let s=await fetch("/api/settings",{cache:"no-store"}),a=(s.ok?await s.json():{}).providerStrategies||{},i={};e&&(i.fallbackStrategy=e),"round-robin"===e&&""!==t&&(i.stickyRoundRobinLimit=Number(t)||3);let l={...a};0===Object.keys(i).length?delete l[r]:l[r]=i,await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerStrategies:l})})}catch(e){console.log("Error saving provider strategy:",e)}},tA=async(e,t)=>{eC({...ek,connections:{...ek.connections,[e]:t}});try{let s=await fetch("/api/settings",{cache:"no-store"}),a=(s.ok?await s.json():{})[ts]||{},i={...a,connections:{...a.connections||{},[e]:t}};await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({[ts]:i})}),eC({enabled:!0===i.enabled,connections:i.connections})}catch(e){console.log("Error saving auto-ping config:",e),eC(ek)}};(0,i.useEffect)(()=>{tk(),tw(),tb()},[tk,tw,tb]);let[t$,tT]=(0,i.useState)({});(0,i.useEffect)(()=>{let e=!1,t=async()=>{try{let t=await fetch("/api/providers/health",{cache:"no-store"});if(!t.ok)return;let s=await t.json();!e&&s?.success&&s.snapshot&&tT(s.snapshot)}catch{}};t();let s=setInterval(t,1e4);return()=>{e=!0,clearInterval(s)}},[]),(0,i.useEffect)(()=>{let e=(c.zN[r]||c.fg[r]||c.IS[r]||c.nJ[r])?.modelsFetcher;e&&h(e).then(eA)},[r]);let tI=(0,i.useCallback)(async()=>{if(0===u.length)return;let e=u.find(e=>!1!==e.isActive)||u[0];if(e){eP(!0);try{let t=null;try{let s=await fetch(`/api/models/live-by-connection?connectionId=${e.id}`),a=s.ok?await s.json():null;a?.success&&a?.models?.length?t={models:a.models}:a?.code==="no_fetcher"&&(t=null)}catch{}if(!t){let s=await fetch(`/api/providers/${e.id}/models`);t=s.ok?await s.json():null}t?.models?.length&&(eT(t.models),eD(e=>{if(e.size>0)return e;let s=t.models[0]?.id||"",a=s.includes("/")?s.split("/")[0]:"other";return new Set([a])}))}catch{}finally{eP(!1)}}},[r,u]);(0,i.useEffect)(()=>{tI()},[tI]);let tP=async(e,t,s=td)=>{let a=`${s}/${e}`;try{let e=await fetch("/api/models/alias",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:a,alias:t})});if(e.ok)await tw();else{let t=await e.json();alert(t.error||"Failed to set alias")}}catch(e){console.log("Error setting alias:",e)}},tO=async e=>{try{(await fetch(`/api/models/alias?alias=${encodeURIComponent(e)}`,{method:"DELETE"})).ok&&await tw()}catch(e){console.log("Error deleting alias:",e)}},tE=async()=>{if(e1)return;let e=u.find(e=>!1!==e.isActive);if(!e)return void alert((0,x.Tl)("Please add an active Qoder connection first"));e5(!0);try{let t=await fetch(`/api/providers/${e.id}/models`),s=await t.json();if(!t.ok)return void alert(s.error||(0,x.Tl)("Failed to fetch models"));let a=s.models||[];if(0===a.length)return void alert((0,x.Tl)("No models returned"));let i=0;for(let e of a){let t=e.id||e.name;if(!t)continue;let s=t.replace(/^qoder\//,""),a=`${tf}/${s}`;!Object.values(Y).includes(a)&&(Y[s]||(await tP(s,s,tf),i+=1))}0===i?alert((0,x.Tl)("All models already exist, no new models added")):alert((0,x.Tl)("Successfully added")+` ${i} `+(0,x.Tl)("models"))}catch(e){console.log("Error importing Qoder models:",e),alert((0,x.Tl)("Error fetching models")+": "+e.message)}finally{e5(!1)}},tR=async()=>{if(eJ||0===u.length)return;let e=Object.fromEntries(u.map(e=>[e.id,{state:"queued",error:null}]));e0.current=!1,eB(!0),eV(!1),eG(null),eZ(e),eX({total:u.length,completed:0,passed:0,failed:0,stopped:!1});let t=0,s=0;try{for(let e=0;e<u.length;e+=1){if(e0.current){eX({total:u.length,completed:e,passed:t,failed:s,stopped:!0});break}let a=u[e];eG(a.id),eZ(e=>({...e,[a.id]:{state:"testing",error:null}}));try{let e=await fetch(`/api/providers/${a.id}/test`,{method:"POST"}),i=await e.json(),l=!!i.valid;l?t+=1:s+=1,eZ(e=>({...e,[a.id]:{state:l?"success":"failed",error:l?null:i.error||null}}))}catch(e){s+=1,eZ(t=>({...t,[a.id]:{state:"failed",error:e.message||"Test failed"}}))}eX({total:u.length,completed:e+1,passed:t,failed:s,stopped:!1}),e<u.length-1&&await new Promise(e=>setTimeout(e,1e3))}}finally{eG(null),eB(!1),eV(!1),e0.current=!1}},tD=async e=>{eK({title:"Delete Connection",message:"Delete this connection?",onConfirm:async()=>{eK(null);try{(await fetch(`/api/providers/${e}`,{method:"DELETE"})).ok&&f(u.filter(t=>t.id!==e))}catch(e){console.log("Error deleting connection:",e)}}})},t_=()=>{tk(),O(!1)},tz=async e=>{K("");try{let t=await fetch("/api/providers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:r,...e})}),s=null;try{s=await t.json()}catch{s=null}if(t.ok){await tk(),q(!1);return}K(s?.error||"Failed to save connection")}catch(e){console.log("Error saving connection:",e),K("Failed to save connection")}},tU=async e=>{try{(await fetch(`/api/providers/${Q.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})).ok&&(await tk(),B(!1))}catch(e){console.log("Error updating connection:",e)}},tq=async(e,t)=>{try{(await fetch(`/api/providers/${e}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({isActive:t})})).ok&&f(s=>s.map(s=>s.id===e?{...s,isActive:t}:s))}catch(e){console.log("Error updating connection status:",e)}},tM=async(e,t)=>{let s=[...u];[s[e],s[t]]=[s[t],s[e]],f(s);try{await Promise.all([fetch(`/api/providers/${s[e].id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({priority:e})}),fetch(`/api/providers/${s[t].id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({priority:t})})])}catch(e){console.log("Error swapping priority:",e),await tk()}},tK=u.filter(e=>ep.includes(e.id));u.length>0&&(ep.length,u.length),(0,i.useEffect)(()=>{ex(e=>e.filter(e=>u.some(t=>t.id===e)))},[u]),(()=>{if(0===tK.length)return;let e=new Set(tK.map(e=>e.providerSpecificData?.proxyPoolId||"__none__"));if(1===e.size){let t=[...e][0];if("__none__"===t)return;let s=A.find(e=>e.id===t);return s?.name}})();let tL=()=>{ef||G(!1)},tF=async e=>{eg(!0);try{let t=0;for(let{connectionId:s,proxyPoolId:a}of e)try{(await fetch(`/api/providers/${s}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({proxyPoolId:a})})).ok||(t+=1)}catch(e){console.log("Error applying proxy for",s,e),t+=1}t>0&&alert(`Updated with ${t} failed request(s).`),await tk(),G(!1)}finally{eg(!1)}},tJ=e=>tF(u.map(t=>({connectionId:t.id,proxyPoolId:e}))),tB=(0,a.jsx)("div",{className:"flex min-w-0 flex-col divide-y divide-black/[0.03] dark:divide-white/[0.03]",children:u.map((e,t)=>(0,a.jsx)("div",{className:"flex min-w-0 items-stretch",children:(0,a.jsx)("div",{className:"flex-1 min-w-0",children:(0,a.jsx)(N,{connection:e,proxyPools:A,health:t$[e.id],isOAuth:tl,isFirst:0===t,isLast:t===u.length-1,onMoveUp:()=>tM(t,t-1),onMoveDown:()=>tM(t,t+1),onToggleActive:t=>tq(e.id,t),autoPing:ta&&"oauth"===e.authType?{on:!0===ek.connections[e.id],onToggle:t=>tA(e.id,t)}:null,onUpdateProxy:async t=>{try{(await fetch(`/api/providers/${e.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({proxyPoolId:t||null})})).ok&&f(s=>s.map(s=>s.id===e.id?{...s,providerSpecificData:{...s.providerSpecificData,proxyPoolId:t||null}}:s))}catch(e){console.log("Error updating proxy:",e)}},onEdit:()=>{Z(e),B(!0)},onDelete:()=>tD(e.id),oneByOneStatus:eQ[e.id]||null})})},e.id))}),tW=A.filter(e=>!0===e.isActive),tV=(0,a.jsx)(d.aF,{isOpen:H,onClose:tL,title:`Apply Proxy (${u.length} connections)`,children:(0,a.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,a.jsxs)("div",{className:"flex flex-col",children:[(0,a.jsxs)("button",{onClick:()=>{let e=A.filter(e=>!0===e.isActive);return 0===e.length?void alert("No active proxy pools available."):tF(u.map((t,s)=>({connectionId:t.id,proxyPoolId:e[s%e.length].id})))},disabled:ef||0===tW.length,className:"flex items-center gap-2 rounded-lg px-3 py-2 text-left transition-colors hover:bg-black/[0.04] dark:hover:bg-white/[0.04] disabled:cursor-not-allowed disabled:opacity-50",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[18px]",children:"sync_alt"}),(0,a.jsx)("span",{className:"text-sm text-text-main",children:"One-to-one (rotate)"})]}),(0,a.jsxs)("button",{onClick:()=>tJ(null),disabled:ef,className:"flex items-center gap-2 rounded-lg px-3 py-2 text-left transition-colors hover:bg-black/[0.04] dark:hover:bg-white/[0.04] disabled:cursor-not-allowed disabled:opacity-50",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[18px]",children:"link_off"}),(0,a.jsx)("span",{className:"text-sm text-text-main",children:"None (unbind all)"})]}),A.map(e=>(0,a.jsxs)("button",{onClick:()=>tJ(e.id),disabled:ef||!0!==e.isActive,className:"flex items-center gap-2 rounded-lg px-3 py-2 text-left transition-colors hover:bg-black/[0.04] dark:hover:bg-white/[0.04] disabled:cursor-not-allowed disabled:opacity-50",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[18px]",children:"lan"}),(0,a.jsx)("span",{className:"truncate text-sm text-text-main",children:e.name}),!0!==e.isActive&&(0,a.jsx)("span",{className:"text-[10px] text-text-muted",children:"(inactive)"})]},e.id))]}),ef&&(0,a.jsx)("p",{className:"text-xs text-text-muted",children:"Applying..."}),(0,a.jsx)(d.$n,{onClick:tL,variant:"ghost",fullWidth:!0,disabled:ef,children:"Cancel"})]})}),tH=async e=>{if(!er.has(e)){en(t=>new Set([...t,e]));try{let t=await fetch("/api/models/test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:`${tf}/${e}`})}),s=await t.json();ea(t=>({...t,[e]:s.ok?"ok":"error"})),s.ok||el(s.error||"Model not reachable")}catch{ea(t=>({...t,[e]:"error"}))}finally{en(t=>{let s=new Set(t);return s.delete(e),s})}}},tG=async e=>{if(eo)return;ed(!0);let t=[];try{for(let s=0;s<e.length;s+=5){let a=e.slice(s,s+5);await Promise.all(a.map(async e=>{en(t=>new Set([...t,e.id]));try{let s=await fetch("/api/models/test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:`${tf}/${e.id}`})}),a=await s.json(),i=a.ok?"ok":"error";ea(t=>({...t,[e.id]:i})),a.ok&&t.push(e)}catch{ea(t=>({...t,[e.id]:"error"}))}finally{en(t=>{let s=new Set(t);return s.delete(e.id),s})}}))}for(let e of t)await tP(e.id,e.id,tf);t.length>0&&document.getElementById("available-models-section")?.scrollIntoView({behavior:"smooth"})}finally{ed(!1)}};if(g)return(0,a.jsxs)("div",{className:"flex flex-col gap-8",children:[(0,a.jsx)(d.Qv,{}),(0,a.jsx)(d.Qv,{})]});if(!te)return(0,a.jsxs)("div",{className:"text-center py-20",children:[(0,a.jsx)("p",{className:"text-text-muted",children:"Provider not found"}),(0,a.jsx)(n(),{href:"/dashboard/providers",className:"text-primary mt-4 inline-block",children:"Back to Providers"})]});let tQ=()=>tc&&te.apiType?"responses"===te.apiType?"/providers/oai-r.png":"/providers/oai-cc.png":tm?"/providers/anthropic-m.png":`/providers/${te.id}.png`;return(0,a.jsxs)("div",{className:"flex min-w-0 flex-col gap-6 px-1 sm:gap-8 sm:px-0",children:[tt?(0,a.jsx)(I,{capabilities:tt,connectionCount:u.length,headerIconPath:ee?null:tQ()}):(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsxs)(n(),{href:"/dashboard/providers",className:"inline-flex items-center gap-1 text-sm text-text-muted hover:text-primary transition-colors mb-4",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-lg",children:"arrow_back"}),"Back to Providers"]}),(0,a.jsxs)("div",{className:"flex min-w-0 items-center gap-3 sm:gap-4",children:[(0,a.jsx)("div",{className:"flex size-12 shrink-0 items-center justify-center rounded-lg",style:{backgroundColor:`${te.color}15`},children:ee?(0,a.jsx)("span",{className:"text-sm font-bold",style:{color:te.color},children:te.textIcon||te.id.slice(0,2).toUpperCase()}):(0,a.jsx)(o.default,{src:tQ(),alt:te.name,width:48,height:48,className:"max-h-12 max-w-12 rounded-lg object-contain",sizes:"48px",onError:()=>et(!0)})}),(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsx)("h1",{className:"truncate text-2xl font-semibold tracking-tight sm:text-3xl",children:te.name}),(0,a.jsxs)("p",{className:"text-text-muted",children:[u.length," connection",1===u.length?"":"s"]})]})]})]}),tp&&j&&(0,a.jsx)(d.Zp,{children:(0,a.jsxs)("div",{className:"mb-4 flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsx)("h2",{className:"text-lg font-semibold",children:tm?"Anthropic Compatible Details":"OpenAI Compatible Details"}),(0,a.jsxs)("p",{className:"break-all text-sm text-text-muted",children:[tm?"Messages API":"responses"===j.apiType?"Responses API":"Chat Completions"," \xb7 ",(j.baseUrl||"").replace(/\/$/,""),"/",tm?"messages":"responses"===j.apiType?"responses":"chat/completions"]})]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-2 sm:flex sm:items-center",children:[(0,a.jsx)(d.$n,{size:"sm",icon:"add",onClick:()=>{K(""),q(!0)},className:"w-full sm:w-auto",children:"Add API Key"}),(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",icon:"edit",onClick:()=>V(!0),className:"w-full sm:w-auto",children:"Edit"}),(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",icon:"delete",onClick:async()=>{eK({title:"Delete Compatible Node",message:`Delete this ${tm?"Anthropic":"OpenAI"} Compatible node?`,onConfirm:async()=>{eK(null);try{(await fetch(`/api/provider-nodes/${r}`,{method:"DELETE"})).ok&&s.push("/dashboard/providers")}catch(e){console.log("Error deleting provider node:",e)}}})},className:"w-full sm:w-auto",children:"Delete"})]})]})}),tn?(0,a.jsx)(d.gw,{providerId:r}):(0,a.jsxs)(d.Zp,{children:[(0,a.jsxs)("div",{className:"mb-4 flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[(0,a.jsx)("h2",{className:"text-lg font-semibold",children:"Connections"}),(0,a.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:gap-4",children:[u.length>0&&A.length>0&&(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",icon:"lan",onClick:()=>G(!0),children:"Apply Proxy"}),u.length>0&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",icon:"sync",onClick:tR,disabled:eJ,children:eJ?"Testing Connection One-by-One...":"Test Connection One-by-One"}),eJ&&(0,a.jsx)(d.$n,{size:"sm",variant:"ghost",icon:"stop",onClick:()=>{eJ&&(e0.current=!0,eV(!0))},disabled:eW,children:eW?"Stopping...":"Stop"})]}),(0,a.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,a.jsx)("span",{className:"text-xs text-text-muted font-medium",children:"Round Robin"}),(0,a.jsx)(d.lM,{checked:"round-robin"===eb,onChange:e=>{let t=e?"round-robin":null,s=e?ev||"1":ev;e&&!ev&&ej("1"),ey(t),tS(t,s)}}),"round-robin"===eb&&(0,a.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,a.jsx)("span",{className:"text-xs text-text-muted",children:"Sticky:"}),(0,a.jsx)("input",{type:"number",min:1,value:ev,onChange:e=>{var t;ej(t=e.target.value),tS("round-robin",t)},placeholder:"1",className:"w-14 px-2 py-1 text-xs border border-border rounded-md bg-background focus:outline-none focus:border-primary"})]})]})]})]}),0===u.length?tt?(0,a.jsx)(R,{capabilities:tt,onOAuth:e7,onApiKey:e8,onFree:e9,onCookie:()=>z(!0),onCompatible:e8,onBulkImport:()=>F(!0)}):(0,a.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[(0,a.jsx)("div",{className:"inline-flex items-center justify-center w-9 h-9 rounded-full bg-primary/10 text-primary shrink-0",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"key"})}),(0,a.jsx)("p",{className:"text-sm text-text-muted",children:"No connections yet"})]}),(0,a.jsx)(d.$n,{size:"sm",icon:"add",onClick:e9,children:"Add API Key"})]}):(0,a.jsxs)(a.Fragment,{children:[eY&&(0,a.jsx)("div",{className:"mb-4 rounded-lg border border-black/10 bg-black/[0.02] px-3 py-2 text-xs text-text-muted dark:border-white/10 dark:bg-white/[0.03]",children:(0,a.jsxs)("div",{className:"flex flex-wrap items-center gap-3",children:[(0,a.jsxs)("span",{children:["Total: ",eY.total]}),(0,a.jsxs)("span",{children:["Completed: ",eY.completed]}),(0,a.jsxs)("span",{children:["Passed: ",eY.passed]}),(0,a.jsxs)("span",{children:["Failed: ",eY.failed]}),eY.stopped&&(0,a.jsx)("span",{className:"text-amber-600 dark:text-amber-400",children:"Stopped"}),eJ&&eH&&(0,a.jsxs)("span",{children:["Running: ",u.find(e=>e.id===eH)?.name||eH]})]})}),!tp&&tt&&(0,a.jsx)(D,{providerId:r,models:e$}),tB,!tp&&tt&&(0,a.jsx)(_,{providerId:r}),!tp&&(0,a.jsxs)("div",{className:"mt-4 grid grid-cols-1 gap-2 sm:flex",children:["iflow"===r&&(0,a.jsx)(d.$n,{size:"sm",icon:"cookie",variant:"secondary",onClick:()=>z(!0),title:"Add connection using browser cookie",className:"w-full sm:w-auto",children:"Cookie"}),"codex"===r&&(0,a.jsx)(d.$n,{size:"sm",icon:"playlist_add",variant:"secondary",onClick:()=>F(!0),title:(0,x.Tl)("Bulk import codex accounts from JSON"),className:"w-full sm:w-auto",children:(0,x.Tl)("Bulk Add")}),tx?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(d.$n,{size:"sm",icon:"lock",variant:"secondary",onClick:e7,className:"w-full sm:w-auto",children:tu}),(0,a.jsx)(d.$n,{size:"sm",icon:"key",onClick:e8,className:"w-full sm:w-auto",children:th})]}):(0,a.jsx)(d.$n,{size:"sm",icon:"add",onClick:e9,className:"w-full sm:w-auto",children:"Add"})]})]})]}),(0,a.jsxs)(d.Zp,{id:"available-models-section",children:[(0,a.jsxs)("div",{className:"mb-4 flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between",children:[(0,a.jsx)("h2",{className:"text-lg font-semibold",children:"Available Models"}),!tp&&(e=[...to,...e_.filter(e=>!to.some(t=>t.id===e.id))].filter(e=>!e.type||"llm"===e.type).map(e=>e.id).filter(e=>!eU.includes(e)),(0,a.jsxs)("div",{className:"flex gap-2",children:[eU.length>0&&(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",icon:"restart_alt",onClick:tN,children:"Active All"}),e.length>0&&(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",icon:"block",onClick:()=>tj(e),children:"Disable All"})]}))]}),!!ei&&(0,a.jsx)("p",{className:"text-xs text-red-500 mb-3 break-words",children:ei}),(()=>{if(tp)return(0,a.jsx)(v,{providerStorageAlias:tf,providerDisplayAlias:tg,modelAliases:Y,copied:e2,onCopy:e4,onSetAlias:tP,onDeleteAlias:tO,connections:u,isAnthropic:tm});let e=[...to,...e_.filter(e=>!to.some(t=>t.id===e.id))].filter(e=>!e.type||"llm"===e.type),t=new Set(eU),s=e.filter(e=>!t.has(e.id)),i=e.filter(e=>t.has(e.id)),l=Object.entries(Y).filter(([e,t])=>{let s=`${tf}/`;if(!t.startsWith(s))return!1;let a=t.slice(s.length);return te.passthroughModels?!to.some(e=>e.id===a):!to.some(e=>e.id===a)&&e===a}).map(([e,t])=>({id:t.slice(`${tf}/`.length),alias:e,fullModel:t}));return(0,a.jsxs)("div",{className:"flex flex-wrap gap-3",children:[l.map(e=>(0,a.jsx)(b,{model:{id:e.id},fullModel:`${tg}/${e.id}`,alias:e.alias,copied:e2,onCopy:e4,onSetAlias:()=>{},onDeleteAlias:()=>tO(e.alias),testStatus:es[e.id],onTest:u.length>0||tn?()=>tH(e.id):void 0,isTesting:er.has(e.id),isCustom:!0,isFree:!1},e.id)),s.map(e=>{let t=`${tf}/${e.id}`,s=`${r}/${e.id}`,i=Object.entries(Y).find(([,e])=>e===t||e===s)?.[0];return(0,a.jsx)(b,{model:e,fullModel:`${tg}/${e.id}`,alias:i,copied:e2,onCopy:e4,onSetAlias:t=>tP(e.id,t,tf),onDeleteAlias:()=>tO(i),testStatus:es[e.id],onTest:u.length>0||tn?()=>tH(e.id):void 0,isTesting:er.has(e.id),isFree:e.isFree,onDisable:()=>ty(e.id)},e.id)}),(0,a.jsxs)("button",{onClick:()=>em(!0),className:"flex w-full items-center justify-center gap-1.5 rounded-lg border border-dashed border-primary/40 px-3 py-2 text-xs text-primary transition-colors hover:border-primary hover:bg-primary/5 sm:w-auto",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:"add"}),"Add Model"]}),"qoder"===r&&u.some(e=>!1!==e.isActive)&&(0,a.jsxs)("button",{onClick:tE,disabled:e1,className:"flex w-full items-center justify-center gap-1.5 rounded-lg border border-dashed border-blue-500/40 px-3 py-2 text-xs text-blue-600 dark:text-blue-400 transition-colors hover:border-blue-500 hover:bg-blue-500/5 sm:w-auto disabled:opacity-50 disabled:cursor-not-allowed",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",style:e1?{animation:"spin 1s linear infinite"}:void 0,children:e1?"progress_activity":"download"}),e1?(0,x.Tl)("Fetching..."):(0,x.Tl)("Fetch Qoder Models")]}),(()=>{let e=new Set([...s.map(e=>e.id),...l.map(e=>e.id)]),t=e$.length>0?e$:eS,r=e$.length>0,n=t.filter(t=>t.id&&!e.has(t.id)),o=new Set(e$.map(e=>e.id).filter(Boolean)),d=i.filter(e=>e.id&&!o.has(e.id)).map(e=>({...e,dropped:!0})),c=new Set(d.map(e=>e.id)),m=[...n.filter(e=>!c.has(e.id)),...d];if(!eI&&0===m.length&&0===t.length)return null;let p=eO.trim().toLowerCase(),x=p?m.filter(e=>e.id.toLowerCase().includes(p)||e.name&&e.name.toLowerCase().includes(p)):m,u={};x.forEach(e=>{if(!e.id)return;let t=e.id.includes("/")?e.id.split("/")[0]:"models";u[t]||(u[t]=[]),u[t].push(e)});let h=Object.entries(u).sort((e,t)=>t[1].length-e[1].length),f=x.filter(e=>!e.dropped).slice(0,50);return(0,a.jsxs)("div",{className:"w-full mt-4 space-y-2",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"text-xs font-medium text-text-muted shrink-0",children:eI?"Loading...":`${r?"From API":"Suggested"} (${n.length})${d.length>0?` \xb7 ${d.length} dropped`:""}`}),(0,a.jsxs)("div",{className:"relative flex-1 min-w-0",children:[(0,a.jsx)("span",{className:"material-symbols-outlined absolute left-2.5 top-1/2 -translate-y-1/2 text-[13px] text-text-muted/60 pointer-events-none select-none",children:"search"}),(0,a.jsx)("input",{type:"text",value:eO,onChange:e=>eE(e.target.value),placeholder:"Search models...",className:"w-full h-7 pl-7 pr-7 text-xs rounded-lg bg-bg border border-border-subtle text-text-main placeholder:text-text-muted/50 focus:outline-none focus:ring-1 focus:ring-primary/30 focus:border-primary/40 transition-colors"}),eO&&(0,a.jsx)("button",{onClick:()=>eE(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-text-muted/50 hover:text-text-muted transition-colors",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[13px]",children:"close"})})]}),(0,a.jsx)("button",{onClick:tI,disabled:eI,title:"Refresh",className:"shrink-0 h-7 w-7 flex items-center justify-center rounded-lg border border-border-subtle text-text-muted hover:text-primary hover:border-primary/40 hover:bg-primary/5 transition-colors disabled:opacity-40",children:(0,a.jsx)("span",{className:`material-symbols-outlined text-[14px] ${eI?"animate-spin":""}`,children:"refresh"})}),!eI&&f.length>0&&(0,a.jsxs)("button",{onClick:()=>tG(f),disabled:eo,title:`Test up to ${f.length} models and auto-add passing ones`,className:"shrink-0 h-7 flex items-center gap-1 px-2.5 rounded-lg border border-border-subtle text-xs text-text-muted hover:text-green-600 hover:border-green-500/40 hover:bg-green-500/5 transition-colors disabled:opacity-40",children:[(0,a.jsx)("span",{className:`material-symbols-outlined text-[13px] ${eo?"animate-spin":""}`,children:eo?"progress_activity":"play_circle"}),eo?"Testing...":"Test All"]})]}),p&&(0,a.jsxs)("p",{className:"text-xs text-text-muted",children:[x.length," result",1!==x.length?"s":""]}),eI?(0,a.jsxs)("div",{className:"flex items-center gap-2 py-4 text-xs text-text-muted",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[15px] animate-spin",children:"progress_activity"}),"Fetching models from provider API..."]}):0===h.length?p?(0,a.jsxs)("p",{className:"text-xs text-text-muted py-2",children:['No models match "',eO,'"']}):null:(0,a.jsx)("div",{className:"space-y-1",children:h.map(([e,t])=>{let s=eR.has(e),i=t.filter(e=>!e.dropped&&"ok"===es[e.id]).length,l=t.filter(e=>!e.dropped&&"error"===es[e.id]).length,r=t.filter(e=>e.dropped).length;return(0,a.jsxs)("div",{className:"rounded-xl border border-border-subtle overflow-hidden",children:[(0,a.jsxs)("button",{onClick:()=>eD(t=>{let s=new Set(t);return s.has(e)?s.delete(e):s.add(e),s}),className:"w-full flex items-center gap-2 px-3 py-2 text-xs bg-bg hover:bg-surface-2/60 transition-colors text-left",children:[(0,a.jsx)("span",{className:"font-semibold text-text-main flex-1",children:e}),i>0&&(0,a.jsxs)("span",{className:"text-green-600 dark:text-green-400 font-medium",children:[i," ✓"]}),l>0&&(0,a.jsxs)("span",{className:"text-red-500 font-medium",children:[l," ✗"]}),r>0&&(0,a.jsxs)("span",{className:"px-1.5 py-0.5 rounded-md bg-amber-500/10 text-amber-600 dark:text-amber-400 text-[10px] font-medium",children:[r," dropped"]}),(0,a.jsx)("span",{className:"px-1.5 py-0.5 rounded-md bg-black/[0.06] dark:bg-white/[0.06] text-text-muted tabular-nums font-medium",children:t.length}),(0,a.jsx)("span",{className:"material-symbols-outlined text-[15px] text-text-muted/60",children:s?"expand_less":"expand_more"})]}),s&&(0,a.jsx)("div",{className:"px-3 pt-2 pb-3 flex flex-wrap gap-1.5 border-t border-border-subtle bg-surface/50",children:t.map(e=>{let t=e.id.includes("/")?e.id.split("/").slice(1).join("/"):e.id,s=es[e.id],i=er.has(e.id);return e.dropped?(0,a.jsxs)("button",{onClick:async()=>{await tv(e.id),document.getElementById("available-models-section")?.scrollIntoView({behavior:"smooth"})},title:`Recently Dropped — click to restore: ${e.id}`,className:"group flex items-center gap-1 px-2.5 py-1.5 rounded-lg border border-amber-400/40 bg-amber-500/5 text-amber-700 dark:text-amber-400 text-xs hover:bg-amber-500/10 hover:border-amber-400/60 transition-colors",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[12px]",children:"history"}),(0,a.jsx)("span",{children:t}),e.contextLength>0&&(0,a.jsxs)("span",{className:"opacity-50 text-[10px] ml-0.5",children:[(e.contextLength/1e3).toFixed(0),"k"]})]},e.id):(0,a.jsxs)("button",{onClick:async()=>{await tP(e.id,e.id,tf),document.getElementById("available-models-section")?.scrollIntoView({behavior:"smooth"})},title:`Add: ${e.name||e.id}`,className:["group flex items-center gap-1 px-2.5 py-1.5 rounded-lg border text-xs transition-colors","ok"===s?"border-green-500/30 bg-green-500/5 text-green-700 dark:text-green-400 hover:bg-green-500/10":"error"===s?"border-red-400/30 bg-red-500/5 text-red-600 dark:text-red-400 hover:bg-red-500/10":"border-border-subtle text-text-muted hover:text-primary hover:border-primary/40 hover:bg-primary/5"].join(" "),children:[i?(0,a.jsx)("span",{className:"material-symbols-outlined text-[12px] animate-spin",children:"progress_activity"}):"ok"===s?(0,a.jsx)("span",{className:"material-symbols-outlined text-[12px]",children:"check"}):"error"===s?(0,a.jsx)("span",{className:"material-symbols-outlined text-[12px]",children:"close"}):(0,a.jsx)("span",{className:"material-symbols-outlined text-[12px] opacity-50 group-hover:opacity-100",children:"add"}),(0,a.jsx)("span",{children:t}),e.contextLength>0&&(0,a.jsxs)("span",{className:"opacity-40 text-[10px] ml-0.5",children:[(e.contextLength/1e3).toFixed(0),"k"]})]},e.id)})})]},e)})})]})})()]})})()]}),tV,"kiro"===r?(0,a.jsx)(d.Mh,{isOpen:P,providerInfo:te,onSuccess:t_,onClose:()=>O(!1)}):"cursor"===r?(0,a.jsx)(d.G9,{isOpen:P,onSuccess:t_,onClose:()=>O(!1)}):"gitlab"===r?(0,a.jsx)(d.vj,{isOpen:P,providerInfo:te,onSuccess:t_,onClose:()=>O(!1)}):(0,a.jsx)(d.LF,{isOpen:P,provider:r,providerInfo:te,onSuccess:t_,onClose:()=>O(!1)}),"iflow"===r&&(0,a.jsx)(d.vE,{isOpen:E,onSuccess:()=>{tk(),z(!1)},onClose:()=>z(!1)}),(0,a.jsx)(k,{isOpen:U,provider:r,providerName:te.name,isCompatible:tp,isAnthropic:tm,authType:te?.authType,authHint:te?.authHint,website:te?.website,proxyPools:A,error:M,existingNames:u.map(e=>e.name).filter(Boolean),onSave:tz,onBulkDone:tk,onClose:()=>{K(""),q(!1)}}),(0,a.jsx)(d.wI,{isOpen:J,connection:Q,proxyPools:A,onSave:tU,onClose:()=>B(!1)}),tp&&(0,a.jsx)(C,{isOpen:W,node:j,onSave:tC,onClose:()=>V(!1),isAnthropic:tm}),!tp&&(0,a.jsx)(S,{isOpen:ec,providerAlias:tf,providerDisplayAlias:tg,onSave:async e=>{let t=te?.passthroughModels?e.split("/").pop():e;await tP(e,t,tf),em(!1)},onClose:()=>em(!1)}),"codex"===r&&(0,a.jsx)($,{isOpen:L,onClose:()=>F(!1),onSuccess:tk}),(0,a.jsx)(d.uo,{isOpen:eL,onClose:()=>eF(!1),onConfirm:()=>{(window.localStorage.setItem(e3,"true"),eF(!1),tl)?e6():e8()},title:"Risk Notice",message:te?.deprecationNotice,confirmText:"I Understand, Continue",cancelText:"Cancel",variant:"danger"}),(0,a.jsx)(d.uo,{isOpen:!!eM,onClose:()=>eK(null),onConfirm:eM?.onConfirm,title:eM?.title||"Confirm",message:eM?.message,variant:"danger"})]})}R.propTypes={capabilities:g().object,onOAuth:g().func,onApiKey:g().func,onFree:g().func,onCookie:g().func,onCompatible:g().func,onBulkImport:g().func},D.propTypes={providerId:g().string.isRequired,models:g().array},_.propTypes={providerId:g().string.isRequired}}},e=>{e.O(0,[7504,5772,1321,5497,8441,3794,7358],()=>e(e.s=76487)),_N_E=e.O()}]);
@@ -0,0 +1 @@
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[3826],{50574:(e,t,r)=>{Promise.resolve().then(r.bind(r,75095)),Promise.resolve().then(r.bind(r,25086))},75095:(e,t,r)=>{"use strict";r.d(t,{default:()=>$});var a=r(95155),s=r(12115),i=r(57250),n=r(45564);function l(e,t){return t&&0!==t?!e||e<0?100:e>=t?0:Math.round((t-e)/t*100):0}function o(e){return e&&"object"==typeof e?String(e.modelKey||e.name||"").trim():""}function c(e,t){let r=t?.[e]?.hidden;return new Set(Array.isArray(r)?r.map(String):[])}function d({quotas:e=[],compact:t=!1,sortMode:r="default",showSortLabel:i=!1,onHideQuota:n=null}){let[o,c]=(0,s.useState)(1),u=(0,s.useMemo)(()=>e.map((e,t)=>({...e,index:t,remaining:e?.remaining!==void 0?Math.max(0,Math.round(e.remaining)):e?.remainingPercentage!==void 0?Math.round(e.remainingPercentage):l(e?.used,e?.total)})),[e]),m=(0,s.useMemo)(()=>"remaining-asc"===r?[...u].sort((e,t)=>e.remaining-t.remaining||e.name.localeCompare(t.name)):"remaining-desc"===r?[...u].sort((e,t)=>t.remaining-e.remaining||e.name.localeCompare(t.name)):u,[u,r]),x=Math.max(1,Math.ceil(m.length/10));if((0,s.useEffect)(()=>{c(1)},[r,e]),(0,s.useEffect)(()=>{c(e=>Math.min(e,x))},[x]),!e||0===e.length)return null;let h=m.slice((o-1)*10,10*o),p=0===m.length?0:(o-1)*10+1,b=Math.min(10*o,m.length),g=t?"py-1 px-1.5":"py-2 px-3",f=t?"text-[11px]":"text-sm",y=t?"text-[11px]":"text-sm",v=t?"text-[10px] leading-tight":"text-xs";return(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,a.jsxs)("div",{className:"text-[10px] text-text-muted",children:[m.length," quota",m.length>1?"s":""]}),i&&(0,a.jsx)("div",{className:"rounded-md border border-black/10 bg-black/[0.02] px-2 py-1 text-[10px] text-text-muted dark:border-white/10 dark:bg-white/[0.03]",children:"Sorted by account remaining"})]}),(0,a.jsx)("div",{className:"overflow-x-auto",children:(0,a.jsx)("table",{className:"w-full table-fixed text-left",children:(0,a.jsx)("tbody",{children:h.map(e=>{var r;let s=(r=e.remaining)>70?{text:"text-green-600 dark:text-green-400",bg:"bg-green-500",bgLight:"bg-green-500/10",emoji:"\uD83D\uDFE2"}:r>=30?{text:"text-yellow-600 dark:text-yellow-400",bg:"bg-yellow-500",bgLight:"bg-yellow-500/10",emoji:"\uD83D\uDFE1"}:{text:"text-red-600 dark:text-red-400",bg:"bg-red-500",bgLight:"bg-red-500/10",emoji:"\uD83D\uDD34"},i=function(e){if(!e)return"-";try{let t="string"==typeof e?new Date(e):e,r=new Date,a=t-r;if(a<=0)return"-";let s=Math.ceil(a/6e4);if(s<60)return`${s}m`;let i=Math.floor(s/60),n=s%60;if(i<24)return`${i}h ${n}m`;let l=Math.floor(i/24);return`${l}d ${i%24}h ${n}m`}catch(e){return"-"}}(e.resetAt),l=function(e){if(!e)return null;try{let t=new Date(e),r=new Date,a=new Date(r.getFullYear(),r.getMonth(),r.getDate()),s=new Date(a);s.setDate(s.getDate()+1);let i="";i=t>=a&&t<s?"Today":t>=s&&t<new Date(s.getTime()+864e5)?"Tomorrow":t.toLocaleDateString("en-US",{month:"short",day:"numeric"});let n=t.toLocaleTimeString("en-US",{hour:"numeric",minute:"2-digit",hour12:!0});return`${i}, ${n}`}catch{return null}}(e.resetAt);return(0,a.jsxs)("tr",{className:"border-b border-black/5 dark:border-white/5 hover:bg-black/[0.02] dark:hover:bg-white/[0.02] transition-colors",children:[(0,a.jsx)("td",{className:`${g} w-[30%]`,children:(0,a.jsxs)("div",{className:"group/qrow flex items-center gap-1.5 min-w-0",children:[(0,a.jsx)("span",{className:"text-[10px] shrink-0",children:s.emoji}),(0,a.jsx)("span",{className:`${f} font-medium text-text-primary truncate`,children:e.name}),n&&(0,a.jsx)("button",{type:"button",onClick:()=>n(e),className:"shrink-0 opacity-0 group-hover/qrow:opacity-100 text-text-muted hover:text-red-500 transition-opacity",title:`Hide "${e.name}"`,"aria-label":`Hide ${e.name}`,children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[13px] align-middle",children:"visibility_off"})})]})}),(0,a.jsx)("td",{className:`${g} w-[45%]`,children:(0,a.jsxs)("div",{className:t?"space-y-1":"space-y-1.5",children:[(0,a.jsx)("div",{className:`${t?"h-1":"h-1.5"} rounded-full overflow-hidden border ${s.bgLight} ${0===e.remaining?"border-black/10 dark:border-white/10":"border-transparent"}`,children:(0,a.jsx)("div",{className:`h-full transition-all duration-300 ${s.bg}`,style:{width:`${Math.min(e.remaining,100)}%`}})}),(0,a.jsxs)("div",{className:`flex items-center justify-between ${t?"text-[10px]":"text-xs"}`,children:[(0,a.jsx)("span",{className:"text-text-muted",children:100===e.total?`${e.used}% used`:`${e.used.toLocaleString()} / ${e.total>0?e.total.toLocaleString():"∞"}`}),(0,a.jsxs)("span",{className:`font-medium ${s.text}`,children:[e.remaining,"%"]})]})]})}),(0,a.jsx)("td",{className:`${g} w-[25%]`,children:"-"!==i||l?t?(0,a.jsx)("div",{className:`${y} text-text-primary font-medium truncate`,title:l||"",children:"-"!==i?`in ${i}`:l}):(0,a.jsxs)("div",{className:"space-y-0.5",children:["-"!==i&&(0,a.jsxs)("div",{className:`${y} text-text-primary font-medium`,children:["in ",i]}),l&&(0,a.jsx)("div",{className:`${v} text-text-muted`,children:l})]}):(0,a.jsx)("div",{className:`${y} text-text-muted italic`,children:"N/A"})})]},`${e.name}-${e.index}`)})})})}),x>1&&(0,a.jsxs)("div",{className:"rounded-md border border-black/10 bg-black/[0.02] px-2 py-1.5 dark:border-white/10 dark:bg-white/[0.03]",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between gap-2 text-[10px] text-text-muted",children:[(0,a.jsxs)("span",{children:["Showing ",p,"-",b," of ",m.length]}),(0,a.jsxs)("span",{children:["Page ",o," / ",x]})]}),(0,a.jsxs)("div",{className:"mt-1.5 flex items-center justify-end gap-1",children:[(0,a.jsx)("button",{type:"button",onClick:()=>c(e=>Math.max(1,e-1)),disabled:1===o,className:"flex h-6 items-center rounded-md border border-black/10 px-2 text-[10px] text-text-primary transition-colors hover:bg-black/5 disabled:cursor-not-allowed disabled:opacity-40 dark:border-white/10 dark:hover:bg-white/5",children:"Prev"}),(0,a.jsx)("button",{type:"button",onClick:()=>c(e=>Math.min(x,e+1)),disabled:o===x,className:"flex h-6 items-center rounded-md border border-black/10 px-2 text-[10px] text-text-primary transition-colors hover:bg-black/5 disabled:cursor-not-allowed disabled:opacity-40 dark:border-white/10 dark:hover:bg-white/5",children:"Next"})]})]})]})}var u=r(98542),m=r(84588),x=r(35497),h=r(52679);function p(e){let t=e=>"string"==typeof e&&/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e);return t(e.email)?e.email:(t(e.name),e.name)}function b(e,t){let r=t[e.id]?.quotas?.[0];return r&&"number"==typeof r.remaining?r.remaining:1/0}function g(e){let t={};return e.forEach(e=>{t[e.id]=!0}),t}function f(e,t){let r=new Set(t.map(e=>e.id));return Object.fromEntries(Object.entries(e).filter(([e])=>r.has(e)))}async function y(e,t){return await e(t)}let v="quotaCacheData";function w(){try{let e=window.localStorage.getItem(v);return e?JSON.parse(e):{}}catch(e){return console.error("Error reading quota cache:",e),{}}}function j(e,t){try{let r=w();r[e]={...t,cachedAt:new Date().toISOString()},window.localStorage.setItem(v,JSON.stringify(r))}catch(e){console.error("Error writing quota cache:",e)}}let k="quotaAutoRefresh",N=[{value:"all",label:"All accounts"},{value:"active",label:"Active"},{value:"inactive",label:"Turned off"}],S=[{value:"default",label:"Default quota order"},{value:"remaining-asc",label:"% quota: low to high"},{value:"remaining-desc",label:"% quota: high to low"}],C=[10,20,50,100];function $(){let[e,t]=(0,s.useState)([]),[r,$]=(0,s.useState)({}),[A,q]=(0,s.useState)({}),[P,E]=(0,s.useState)({}),[M,T]=(0,s.useState)(!0),[D,O]=(0,s.useState)({}),[I,_]=(0,s.useState)({}),[z,L]=(0,s.useState)(null),[F,U]=(0,s.useState)(!1),[J,R]=(0,s.useState)(!1),[H,K]=(0,s.useState)(60),[V,B]=(0,s.useState)(!0),[G,Q]=(0,s.useState)(null),[W,Y]=(0,s.useState)(null),[X,Z]=(0,s.useState)(!1),[ee,et]=(0,s.useState)(null),[er,ea]=(0,s.useState)([]),[es,ei]=(0,s.useState)("all"),[en,el]=(0,s.useState)([]),[eo,ec]=(0,s.useState)("all"),[ed,eu]=(0,s.useState)("default"),[em,ex]=(0,s.useState)(!1),[eh,ep]=(0,s.useState)(!1),[eb,eg]=(0,s.useState)(!1),[ef,ey]=(0,s.useState)(1),[ev,ew]=(0,s.useState)(20),[ej,ek]=(0,s.useState)(String(20)),[eN,eS]=(0,s.useState)({page:1,pageSize:20,total:0,totalPages:1}),[eC,e$]=(0,s.useState)({eligibleConnections:0,providerFilteredConnections:0}),eA=(0,s.useRef)(null),eq=(0,s.useRef)(null),eP=(0,s.useCallback)(async(e=ef)=>{try{var r,a;let s=new URLSearchParams({page:String(e),pageSize:String(ev),accountStatus:eo,sort:"priority"});"all"!==es&&s.set("provider",es);let i=await fetch(`/api/providers/client?${s.toString()}`);if(!i.ok)throw Error("Failed to fetch connections");let n=await i.json(),l=n.connections||[],o=(r=n.pagination,r||{page:1,pageSize:ev,total:0,totalPages:1}),c=function(e,t=0){return e||{eligibleConnections:t,providerFilteredConnections:t}}(n.totals,l.length);return t(l),el(n.providerOptions||[]),eS(o),e$(c),ey((a=n.pagination,a?.page||e)),l}catch(e){return console.error("Error fetching connections:",e),t([]),el([]),eS({page:1,pageSize:ev,total:0,totalPages:1}),e$({eligibleConnections:0,providerFilteredConnections:0}),[]}},[eo,em,ef,ev,es]),eE=(0,s.useCallback)(async(e,t)=>{q(t=>({...t,[e]:!0})),E(t=>({...t,[e]:null}));try{console.log(`[ProviderLimits] Fetching quota for ${t} (${e})`);let r=await fetch(`/api/usage/${e}`);if(!r.ok){let a=(await r.json().catch(()=>({}))).error||r.statusText;if(404===r.status)return void console.warn(`[ProviderLimits] Connection not found for ${t}, skipping`);if(401===r.status){console.warn(`[ProviderLimits] Auth error for ${t}:`,a);let r={quotas:[],message:a};$(t=>({...t,[e]:r})),j(e,r);return}throw Error(`HTTP ${r.status}: ${a}`)}let a=await r.json();console.log(`[ProviderLimits] Got quota for ${t}:`,a);let s={quotas:function(e,t){if(!t||"object"!=typeof t)return[];let r=[];try{switch(e.toLowerCase()){case"github":default:t.quotas&&Object.entries(t.quotas).forEach(([e,t])=>{r.push({name:e,used:t.used||0,total:t.total||0,resetAt:t.resetAt||null})});break;case"antigravity":t.quotas&&Object.entries(t.quotas).forEach(([e,t])=>{r.push({name:t.displayName||e,modelKey:e,used:t.used||0,total:t.total||0,resetAt:t.resetAt||null,remainingPercentage:t.remainingPercentage})});break;case"codex":t.quotas&&Object.entries(t.quotas).forEach(([e,t])=>{r.push({name:e,used:t.used||0,total:t.total||0,remaining:t.remaining,resetAt:t.resetAt||null})});break;case"kiro":t.quotas&&Object.entries(t.quotas).forEach(([e,t])=>{r.push({name:e,used:t.used||0,total:t.total||0,resetAt:t.resetAt||null})});break;case"qoder":t.quotas&&Object.entries(t.quotas).forEach(([e,t])=>{("organization"!==e||t&&0!==(Number(t.total)||0))&&r.push({name:"user"===e?"Personal":"organization"===e?"Organization":e,used:t.used||0,total:t.total||0,unit:t.unit,resetAt:t.resetAt||null})});break;case"claude":t.message?r.push({name:"error",used:0,total:0,resetAt:null,message:t.message}):t.quotas&&Object.entries(t.quotas).forEach(([e,t])=>{r.push({name:e,used:t.used||0,total:t.total||0,resetAt:t.resetAt||null})});break;case"vercel-ai-gateway":t.quotas&&Object.entries(t.quotas).forEach(([e,t])=>{r.push({name:e,used:t.used||0,total:t.total||0,resetAt:t.resetAt||null,remainingPercentage:t.remainingPercentage})})}}catch(t){return console.error(`Error parsing quota data for ${e}:`,t),[]}let a=(0,n.KC)(e);if(a.length>0){let e=new Map(a.map((e,t)=>[e.id,t]));r.sort((t,r)=>{let a=t.modelKey||t.name,s=r.modelKey||r.name;return(e.get(a)??999)-(e.get(s)??999)})}return r}(t,a),plan:a.plan||null,message:a.message||null,raw:a};$(t=>({...t,[e]:s})),j(e,s)}catch(r){console.error(`[ProviderLimits] Error fetching quota for ${t} (${e}):`,r),E(t=>({...t,[e]:r.message||"Failed to fetch quota"}))}finally{q(t=>({...t,[e]:!1}))}},[]),eM=(0,s.useCallback)(async(e,t)=>{await eE(e,t),L(new Date)},[eE]),eT=(0,s.useCallback)(async e=>{if(confirm("Delete this connection?")){Q(e);try{if((await fetch(`/api/providers/${e}`,{method:"DELETE"})).ok){$(t=>{let r={...t};return delete r[e],r}),q(t=>{let r={...t};return delete r[e],r}),E(t=>{let r={...t};return delete r[e],r});try{let t=w();t[e]&&(delete t[e],window.localStorage.setItem(v,JSON.stringify(t)))}catch(e){console.error("Error deleting cache entry:",e)}await y(eP,ef)}}catch(e){console.error("Error deleting connection:",e)}finally{Q(null)}}},[eP,ef]),eD=(0,s.useCallback)(async(e,t)=>{Y(e);try{(await fetch(`/api/providers/${e}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({isActive:t})})).ok&&($(e=>({...e})),await y(eP,ef))}catch(e){console.error("Error updating connection status:",e)}finally{Y(null)}},[eP,ef]),eO=(0,s.useCallback)(async e=>{if(!ee?.id)return;let t=ee.id,r=ee.provider;try{(await fetch(`/api/providers/${t}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})).ok&&(await eP(),Z(!1),et(null),h.wb.includes(r)&&await eE(t,r))}catch(e){console.error("Error saving connection:",e)}},[ee,eP,eE]);(0,s.useEffect)(()=>{let e=!1;return fetch("/api/proxy-pools?isActive=true",{cache:"no-store"}).then(e=>e.json()).then(t=>{!e&&t?.proxyPools&&ea(t.proxyPools)}).catch(()=>{}),()=>{e=!0}},[]);let eI=(0,s.useCallback)(async()=>{if(!J){R(!0),K(60);try{let e=await eP(ef);q(g(e)),E(t=>f(t,e)),$(t=>f(t,e)),await Promise.all(e.map(e=>eE(e.id,e.provider))),L(new Date)}catch(e){console.error("Error refreshing all providers:",e)}finally{R(!1)}}},[J,eP,eE,ef]);(0,s.useEffect)(()=>{(async()=>{B(!0);let e=await eP(ef);B(!1),q(g(e)),E(t=>f(t,e)),$(t=>f(t,e)),await Promise.all(e.map(e=>eE(e.id,e.provider))),L(new Date)})()},[eP,eE,ef]),(0,s.useEffect)(()=>{let e=window.localStorage.getItem(k);T(null===e||"true"===e),U(!0)},[]),(0,s.useEffect)(()=>{F&&window.localStorage.setItem(k,String(M))},[M,F]),(0,s.useEffect)(()=>{fetch("/api/settings",{cache:"no-store"}).then(e=>e.ok?e.json():{}).then(e=>{O(e?.claudeAutoPing?.connections||{}),_(e?.quotaVisibility||{})}).catch(()=>{})},[]);let e_=(0,s.useCallback)(async(e,t,r)=>{let a=new Set((I?.[e]?.hidden||[]).map(String));r?a.add(String(t)):a.delete(String(t));let s={...I,[e]:{...I?.[e]||{},hidden:[...a]}};_(s);try{let t=await fetch("/api/settings",{cache:"no-store"}),r={...(t.ok?await t.json():{}).quotaVisibility||{},[e]:s[e]};await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({quotaVisibility:r})}),_(r)}catch{_(I)}},[I]),ez=(0,s.useCallback)(async(e,t)=>{let r={...D,[e]:t};O(r);try{let e=await fetch("/api/settings",{cache:"no-store"}),t={...(e.ok?await e.json():{}).claudeAutoPing||{},connections:r};await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({claudeAutoPing:t})})}catch{O(D)}},[D]);(0,s.useEffect)(()=>{if(!F||!M){eA.current&&(clearInterval(eA.current),eA.current=null),eq.current&&(clearInterval(eq.current),eq.current=null);return}return eA.current=setInterval(()=>{eI()},6e4),eq.current=setInterval(()=>{K(e=>e<=1?60:e-1)},1e3),()=>{eA.current&&clearInterval(eA.current),eq.current&&clearInterval(eq.current)}},[M,eI,F]),(0,s.useEffect)(()=>{let e=()=>{document.hidden?(eA.current&&(clearInterval(eA.current),eA.current=null),eq.current&&(clearInterval(eq.current),eq.current=null)):M&&F&&(eA.current=setInterval(eI,6e4),eq.current=setInterval(()=>{K(e=>e<=1?60:e-1)},1e3))};return document.addEventListener("visibilitychange",e),()=>{document.removeEventListener("visibilitychange",e)}},[M,eI,F]);let eL=(0,s.useMemo)(()=>(function(e,t,r,a,s){if("codex"===a&&"default"!==s)return[...e].sort((e,r)=>{let a=b(e,t),i=b(r,t),n="remaining-asc"===s?a-i:i-a;return 0!==n?n:(p(e)||"").localeCompare(p(r)||"")});if(!r)return e;let i=e=>{let r=(t[e.id]?.quotas||[]).map(e=>e.resetAt?new Date(e.resetAt).getTime():1/0).filter(e=>Number.isFinite(e));return r.length>0?Math.min(...r):1/0};return[...e].sort((e,t)=>{let r=i(e)-i(t);return 0!==r?r:(e.provider||"").localeCompare(t.provider||"")||(p(e)||"").localeCompare(p(t)||"")})})(e,r,em,es,ed),[e,r,em,es,ed]),eF=e=>{let t=r[e.id]?.quotas;return!!t?.length&&t.some(e=>!!e.total&&!(e.total<=0)&&5>=l(e.used,e.total))},eU=(0,s.useCallback)(async(e,t)=>{if(e.length&&!eb){eg(!0);try{await Promise.all(e.map(e=>fetch(`/api/providers/${e}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({isActive:t})}))),await y(eP,ef)}catch(e){console.error("Error bulk toggling connections:",e)}finally{eg(!1)}}},[eb,eP,ef]),eJ="all"===es?"All providers":es,eR=eC.eligibleConnections>0,eH=eL.length>0,eK=eC.eligibleConnections?eC.providerFilteredConnections?{icon:"filter_alt_off",title:"No Accounts On This Page",description:"Try moving to another page or refreshing the current filters."}:{icon:"filter_alt_off",title:"No Accounts Match Current Filters",description:"all"===es?"Try changing the account status filter to see more quota trackers.":`No ${"inactive"===eo?"turned off":"active"===eo?"active":"matching"} accounts found for ${es}.`}:{icon:"cloud_off",title:"No Providers Connected",description:"Connect to providers with OAuth to track your API quota limits and usage."},eV=function(e){var t;let{start:r,end:a}=(t=e).total?{start:(t.page-1)*t.pageSize+1,end:Math.min(t.page*t.pageSize,t.total)}:{start:0,end:0};return`Showing ${r}-${a} of ${e.total}`}(eN),eB=!C.includes(ev);return V||eR?V||eH?(0,a.jsxs)("div",{className:"space-y-6",children:[(0,a.jsx)("div",{className:"flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-end",children:(0,a.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5",children:[(0,a.jsxs)("div",{className:"relative",children:[(0,a.jsxs)("button",{type:"button",onClick:()=>ep(e=>!e),className:"flex h-8 items-center justify-between gap-1 rounded-lg border border-black/10 bg-black/[0.02] px-2 text-xs text-text-primary transition-colors hover:bg-black/5 dark:border-white/10 dark:bg-white/[0.03] dark:hover:bg-white/10","aria-haspopup":"menu","aria-expanded":eh,title:"Filter quota providers",children:[(0,a.jsxs)("span",{className:"flex min-w-0 items-center gap-1.5",children:["all"===es?(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px] text-text-muted",children:"apps"}):(0,a.jsx)(i.A,{src:`/providers/${es}.png`,alt:es,size:18,className:"size-[18px] rounded object-contain",fallbackText:es.slice(0,2).toUpperCase()}),(0,a.jsx)("span",{className:"truncate capitalize hidden lg:inline",children:eJ})]}),(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px] text-text-muted",children:"expand_more"})]}),eh&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("button",{type:"button",className:"fixed inset-0 z-30 bg-transparent","aria-label":"Close provider filter",onClick:()=>ep(!1)}),(0,a.jsxs)("div",{className:"absolute left-0 z-40 mt-2 w-64 overflow-hidden rounded-2xl border border-black/10 bg-surface/95 p-1.5 shadow-xl shadow-black/10 backdrop-blur dark:border-white/10 dark:bg-surface/95 sm:w-72",children:[(0,a.jsxs)("button",{type:"button",onClick:()=>{"all"!==es&&ey(1),ei("all"),ep(!1)},className:`flex w-full items-center gap-3 rounded-xl px-3 py-2.5 text-left text-sm transition-colors ${"all"===es?"bg-primary/10 text-primary":"text-text-primary hover:bg-black/5 dark:hover:bg-white/10"}`,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[22px]",children:"apps"}),(0,a.jsx)("span",{className:"font-medium",children:"All providers"}),"all"===es&&(0,a.jsx)("span",{className:"material-symbols-outlined ml-auto text-[20px]",children:"check"})]}),(0,a.jsx)("div",{className:"my-1 h-px bg-black/10 dark:bg-white/10"}),(0,a.jsx)("div",{className:"max-h-72 overflow-y-auto pr-1",children:en.map(e=>(0,a.jsxs)("button",{type:"button",onClick:()=>{es!==e&&ey(1),ei(e),ep(!1)},className:`flex w-full items-center gap-3 rounded-xl px-3 py-2.5 text-left text-sm transition-colors ${es===e?"bg-primary/10 text-primary":"text-text-primary hover:bg-black/5 dark:hover:bg-white/10"}`,children:[(0,a.jsx)(i.A,{src:`/providers/${e}.png`,alt:e,size:24,className:"size-6 rounded-md object-contain",fallbackText:e.slice(0,2).toUpperCase()}),(0,a.jsx)("span",{className:"font-medium capitalize",children:e}),es===e&&(0,a.jsx)("span",{className:"material-symbols-outlined ml-auto text-[20px]",children:"check"})]},e))})]})]})]}),(0,a.jsx)("select",{value:eo,onChange:e=>{let t=e.target.value;eo!==t&&ey(1),ec(t)},className:"h-8 rounded-lg border border-black/10 bg-black/[0.02] px-2 text-xs text-text-primary outline-none transition-colors hover:bg-black/5 dark:border-white/10 dark:bg-white/[0.03] dark:hover:bg-white/10","aria-label":"Filter accounts by status",children:N.map(e=>(0,a.jsx)("option",{value:e.value,children:e.label},e.value))}),"codex"===es&&(0,a.jsx)("select",{value:ed,onChange:e=>eu(e.target.value),className:"h-8 rounded-lg border border-black/10 bg-black/[0.02] px-2 text-xs text-text-primary outline-none transition-colors hover:bg-black/5 dark:border-white/10 dark:bg-white/[0.03] dark:hover:bg-white/10","aria-label":"Sort Codex quotas by remaining",children:S.map(e=>(0,a.jsx)("option",{value:e.value,children:e.label},e.value))}),(0,a.jsxs)("button",{type:"button",onClick:()=>ex(e=>!e),"aria-pressed":em,className:`flex h-8 shrink-0 items-center gap-1 rounded-lg border px-2 text-xs transition-colors ${em?"border-amber-500/40 bg-amber-500/10 text-amber-500":"border-black/10 text-text-primary hover:bg-black/5 dark:border-white/10 dark:hover:bg-white/5"}`,title:"Sort accounts by earliest quota reset time",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"hourglass_top"}),(0,a.jsx)("span",{className:"hidden sm:inline",children:"Expiring first"})]}),(0,a.jsxs)("button",{type:"button",onClick:()=>{eU(eL.filter(e=>(e.isActive??!0)&&eF(e)).map(e=>e.id),!1)},disabled:eb,className:"flex h-8 shrink-0 items-center gap-1 rounded-lg border border-red-500/30 px-2 text-xs text-red-500 transition-colors hover:bg-red-500/10 disabled:opacity-50",title:"Disable connections with depleted quota on the current page",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"block"}),(0,a.jsx)("span",{className:"hidden sm:inline",children:"Turn off Empty"})]}),(0,a.jsxs)("button",{type:"button",onClick:()=>{eU(eL.filter(e=>!(e.isActive??!0)&&!eF(e)).map(e=>e.id),!0)},disabled:eb,className:"flex h-8 shrink-0 items-center gap-1 rounded-lg border border-emerald-500/30 px-2 text-xs text-emerald-500 transition-colors hover:bg-emerald-500/10 disabled:opacity-50",title:"Enable connections that still have quota on the current page",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"check_circle"}),(0,a.jsx)("span",{className:"hidden sm:inline",children:"Turn on Available"})]}),(0,a.jsxs)("button",{onClick:()=>T(e=>!e),className:"flex h-8 shrink-0 items-center gap-1 rounded-lg border border-black/10 px-2 text-xs transition-colors hover:bg-black/5 dark:border-white/10 dark:hover:bg-white/5",title:M?"Disable auto-refresh":"Enable auto-refresh",children:[(0,a.jsx)("span",{className:`material-symbols-outlined text-[14px] ${M?"text-primary":"text-text-muted"}`,children:M?"toggle_on":"toggle_off"}),(0,a.jsx)("span",{className:"hidden text-text-primary sm:inline",children:"Auto-refresh"}),M&&(0,a.jsxs)("span",{className:"text-[10px] text-text-muted tabular-nums",children:["(",H,"s)"]})]}),(0,a.jsx)("button",{type:"button",onClick:eI,disabled:J,className:"flex h-8 shrink-0 items-center gap-1 rounded-lg border border-black/10 px-2 text-xs text-text-primary transition-colors hover:bg-black/5 dark:border-white/10 dark:hover:bg-white/5 disabled:opacity-50",title:"Refresh all",children:(0,a.jsx)("span",{className:`material-symbols-outlined text-[14px] ${J?"animate-spin":""}`,children:"refresh"})})]})}),em&&(0,a.jsx)("div",{className:"rounded-xl border border-amber-500/20 bg-amber-500/10 px-3 py-2 text-xs text-amber-700 dark:text-amber-300",children:"Expiring-first currently reorders accounts inside the current page. Cross-page ordering still follows backend pagination."}),(0,a.jsx)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:eL.map(e=>{let t,s,n,l=r[e.id],h=A[e.id],b=P[e.id],g=!1===e.isActive,f=G===e.id||W===e.id;return(0,a.jsxs)(m.default,{padding:"none",className:`min-w-0 ${g?"opacity-60":""}`,children:[(0,a.jsx)("div",{className:"px-3 py-2 border-b border-black/10 dark:border-white/10",children:(0,a.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,a.jsx)("div",{className:"w-8 h-8 shrink-0 rounded-md flex items-center justify-center overflow-hidden",children:(0,a.jsx)(i.A,{src:`/providers/${e.provider}.png`,alt:e.provider,size:32,className:"object-contain",fallbackText:e.provider?.slice(0,2).toUpperCase()||"PR"})}),(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsx)("h3",{className:"text-sm font-semibold text-text-primary capitalize truncate",children:e.provider}),p(e)?(0,a.jsx)("p",{className:"text-xs text-text-muted truncate",children:p(e)}):null]})]}),(0,a.jsxs)("div",{className:"flex items-center gap-1 shrink-0",children:["claude"===e.provider&&"oauth"===e.authType&&(0,a.jsx)(x.m_,{text:"When your 5h quota runs out, auto-sends a request the moment it resets so a new window starts right away.",children:(0,a.jsx)("button",{type:"button",onClick:()=>ez(e.id,!0!==D[e.id]),"aria-label":"Toggle auto-ping",className:`flex h-8 w-8 items-center justify-center rounded-lg transition-colors hover:bg-black/5 dark:hover:bg-white/5 ${!0===D[e.id]?"text-primary":"text-text-muted"}`,children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"bolt"})})}),(0,a.jsx)("button",{type:"button",onClick:()=>eM(e.id,e.provider),disabled:h||f,"aria-label":"Refresh quota",className:"p-1.5 rounded-lg hover:bg-black/5 dark:hover:bg-white/5 transition-colors disabled:opacity-50",title:"Refresh quota",children:(0,a.jsx)("span",{className:`material-symbols-outlined text-[18px] text-text-muted ${h?"animate-spin":""}`,children:"refresh"})}),(0,a.jsx)("button",{type:"button",onClick:()=>{et(e),Z(!0)},disabled:f,"aria-label":"Edit connection",className:"p-1.5 rounded-lg hover:bg-black/5 dark:hover:bg-white/5 text-text-muted hover:text-primary transition-colors disabled:opacity-50",title:"Edit connection",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"edit"})}),(0,a.jsx)("button",{type:"button",onClick:()=>eT(e.id),disabled:f,"aria-label":"Delete connection",className:"p-1.5 rounded-lg hover:bg-red-500/10 text-red-500 transition-colors disabled:opacity-50",title:"Delete connection",children:(0,a.jsx)("span",{className:`material-symbols-outlined text-[18px] ${G===e.id?"animate-pulse":""}`,children:"delete"})}),(0,a.jsx)("div",{className:"inline-flex items-center pl-0.5",title:e.isActive??!0?"Disable connection":"Enable connection",children:(0,a.jsx)(u.default,{size:"sm",checked:e.isActive??!0,disabled:f,onChange:t=>eD(e.id,t)})})]})]})}),(0,a.jsx)("div",{className:"px-2 py-1.5",children:h?(0,a.jsx)("div",{className:"text-center py-5 text-text-muted",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[28px] animate-spin",children:"progress_activity"})}):b?(0,a.jsxs)("div",{className:"text-center py-5",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[28px] text-red-500",children:"error"}),(0,a.jsx)("p",{className:"mt-1.5 text-xs text-text-muted",children:b})]}):l?.message?(0,a.jsx)("div",{className:"text-center py-5",children:(0,a.jsx)("p",{className:"text-xs text-text-muted",children:l.message})}):(t=l?.quotas||[],s=function(e,t=[],r={}){if(!Array.isArray(t)||0===t.length)return[];let a=c(e,r);return 0===a.size?t:t.filter(e=>!a.has(o(e)))}(e.provider,t,I),n=function(e,t=[],r={}){if(!Array.isArray(t)||0===t.length)return[];let a=c(e,r);return 0===a.size?[]:t.filter(e=>a.has(o(e)))}(e.provider,t,I),(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(d,{quotas:s,compact:!0,sortMode:"default",showSortLabel:"codex"===e.provider&&"default"!==ed,onHideQuota:t=>e_(e.provider,o(t),!0)}),n.length>0&&(0,a.jsxs)("div",{className:"mt-2 flex flex-wrap items-center gap-1.5 text-[11px] text-text-muted",children:[(0,a.jsxs)("span",{children:[n.length," hidden:"]}),n.map(t=>{let r=o(t);return(0,a.jsxs)("button",{type:"button",onClick:()=>e_(e.provider,r,!1),className:"inline-flex items-center gap-1 rounded border border-border px-1.5 py-0.5 hover:border-primary hover:text-primary transition-colors",title:`Show "${t.name}" again`,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[13px]",children:"visibility"}),t.name]},r)})]})]}))})]},e.id)})}),(0,a.jsx)("div",{className:"rounded-xl border border-black/10 bg-black/[0.02] px-3 py-2 dark:border-white/10 dark:bg-white/[0.03]",children:(0,a.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[(0,a.jsx)("span",{className:"text-xs text-text-muted",children:eV}),(0,a.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,a.jsxs)("select",{value:eB?"custom":String(ev),onChange:e=>{let t=e.target.value;if("custom"===t)return;let r=Number.parseInt(t,10);Number.isFinite(r)&&(ey(1),ew(r),ek(String(r)))},className:"h-8 rounded-lg border border-black/10 bg-black/[0.02] px-2 text-xs text-text-primary outline-none transition-colors hover:bg-black/5 dark:border-white/10 dark:bg-white/[0.03] dark:hover:bg-white/10","aria-label":"Accounts per page",children:[C.map(e=>(0,a.jsxs)("option",{value:String(e),children:[e," / page"]},e)),(0,a.jsx)("option",{value:"custom",children:"Custom"})]}),(0,a.jsx)("input",{type:"number",min:"1",max:String(500),inputMode:"numeric",value:ej,onChange:e=>ek(e.target.value),onBlur:()=>{let e=Number.parseInt(ej,10);if(!Number.isFinite(e))return void ek(String(ev));let t=Math.min(500,Math.max(1,e));ey(1),ew(t),ek(String(t))},onKeyDown:e=>{if("Enter"!==e.key)return;let t=Number.parseInt(ej,10);if(!Number.isFinite(t))return void ek(String(ev));let r=Math.min(500,Math.max(1,t));ey(1),ew(r),ek(String(r))},className:"h-8 w-20 rounded-lg border border-black/10 bg-black/[0.02] px-2 text-xs text-text-primary outline-none transition-colors hover:bg-black/5 dark:border-white/10 dark:bg-white/[0.03] dark:hover:bg-white/10","aria-label":"Custom accounts per page",placeholder:"Custom"}),(0,a.jsxs)("span",{className:"text-xs text-text-muted",children:["Page ",eN.page," / ",eN.totalPages]})]}),(0,a.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,a.jsx)("button",{type:"button",onClick:()=>ey(1),disabled:eN.page<=1||V||J,className:"flex h-8 items-center rounded-lg border border-black/10 px-3 text-xs text-text-primary transition-colors hover:bg-black/5 disabled:cursor-not-allowed disabled:opacity-40 dark:border-white/10 dark:hover:bg-white/5",children:"First Page"}),(0,a.jsx)("button",{type:"button",onClick:()=>ey(e=>Math.max(1,e-1)),disabled:eN.page<=1||V||J,className:"flex h-8 w-8 items-center justify-center rounded-lg border border-black/10 text-text-primary transition-colors hover:bg-black/5 disabled:cursor-not-allowed disabled:opacity-40 dark:border-white/10 dark:hover:bg-white/5","aria-label":"Previous accounts page",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"chevron_left"})}),(0,a.jsx)("button",{type:"button",onClick:()=>ey(e=>Math.min(eN.totalPages,e+1)),disabled:eN.page>=eN.totalPages||V||J,className:"flex h-8 w-8 items-center justify-center rounded-lg border border-black/10 text-text-primary transition-colors hover:bg-black/5 disabled:cursor-not-allowed disabled:opacity-40 dark:border-white/10 dark:hover:bg-white/5","aria-label":"Next accounts page",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"chevron_right"})}),(0,a.jsx)("button",{type:"button",onClick:()=>ey(eN.totalPages),disabled:eN.page>=eN.totalPages||V||J,className:"flex h-8 items-center rounded-lg border border-black/10 px-3 text-xs text-text-primary transition-colors hover:bg-black/5 disabled:cursor-not-allowed disabled:opacity-40 dark:border-white/10 dark:hover:bg-white/5",children:"Last Page"})]})]})}),(0,a.jsx)(x.wI,{isOpen:X,connection:ee,proxyPools:er,onSave:eO,onClose:()=>{Z(!1),et(null)}})]}):(0,a.jsx)(m.default,{padding:"lg",children:(0,a.jsxs)("div",{className:"text-center py-12",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[64px] text-text-muted opacity-20",children:eK.icon}),(0,a.jsx)("h3",{className:"mt-4 text-lg font-semibold text-text-primary",children:eK.title}),(0,a.jsx)("p",{className:"mt-2 text-sm text-text-muted max-w-md mx-auto",children:eK.description})]})}):(0,a.jsx)(m.default,{padding:"lg",children:(0,a.jsxs)("div",{className:"text-center py-12",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[64px] text-text-muted opacity-20",children:"cloud_off"}),(0,a.jsx)("h3",{className:"mt-4 text-lg font-semibold text-text-primary",children:"No Providers Connected"}),(0,a.jsx)("p",{className:"mt-2 text-sm text-text-muted max-w-md mx-auto",children:"Connect to providers with OAuth to track your API quota limits and usage."})]})})}}},e=>{e.O(0,[7504,1321,5497,8441,3794,7358],()=>e(e.s=50574)),_N_E=e.O()}]);