@ltgiang/9router 0.5.37 → 0.5.39

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 (536) hide show
  1. package/app/.next-cli-build/BUILD_ID +1 -1
  2. package/app/.next-cli-build/app-path-routes-manifest.json +13 -13
  3. package/app/.next-cli-build/build-manifest.json +2 -2
  4. package/app/.next-cli-build/server/app/(dashboard)/dashboard/basic-chat/page.js +1 -1
  5. package/app/.next-cli-build/server/app/(dashboard)/dashboard/basic-chat/page.js.nft.json +1 -1
  6. package/app/.next-cli-build/server/app/(dashboard)/dashboard/basic-chat/page_client-reference-manifest.js +1 -1
  7. package/app/.next-cli-build/server/app/(dashboard)/dashboard/cli-tools/[toolId]/page.js +1 -1
  8. package/app/.next-cli-build/server/app/(dashboard)/dashboard/cli-tools/[toolId]/page.js.nft.json +1 -1
  9. package/app/.next-cli-build/server/app/(dashboard)/dashboard/cli-tools/[toolId]/page_client-reference-manifest.js +1 -1
  10. package/app/.next-cli-build/server/app/(dashboard)/dashboard/cli-tools/page.js +1 -1
  11. package/app/.next-cli-build/server/app/(dashboard)/dashboard/cli-tools/page.js.nft.json +1 -1
  12. package/app/.next-cli-build/server/app/(dashboard)/dashboard/cli-tools/page_client-reference-manifest.js +1 -1
  13. package/app/.next-cli-build/server/app/(dashboard)/dashboard/combos/page.js +2 -2
  14. package/app/.next-cli-build/server/app/(dashboard)/dashboard/combos/page.js.nft.json +1 -1
  15. package/app/.next-cli-build/server/app/(dashboard)/dashboard/combos/page_client-reference-manifest.js +1 -1
  16. package/app/.next-cli-build/server/app/(dashboard)/dashboard/console-log/page.js +1 -1
  17. package/app/.next-cli-build/server/app/(dashboard)/dashboard/console-log/page.js.nft.json +1 -1
  18. package/app/.next-cli-build/server/app/(dashboard)/dashboard/console-log/page_client-reference-manifest.js +1 -1
  19. package/app/.next-cli-build/server/app/(dashboard)/dashboard/endpoint/page.js +1 -1
  20. package/app/.next-cli-build/server/app/(dashboard)/dashboard/endpoint/page.js.nft.json +1 -1
  21. package/app/.next-cli-build/server/app/(dashboard)/dashboard/endpoint/page_client-reference-manifest.js +1 -1
  22. package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/[kind]/[id]/page.js +9 -9
  23. package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/[kind]/[id]/page.js.nft.json +1 -1
  24. package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/[kind]/[id]/page_client-reference-manifest.js +1 -1
  25. package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/[kind]/page.js +2 -2
  26. package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/[kind]/page.js.nft.json +1 -1
  27. package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/[kind]/page_client-reference-manifest.js +1 -1
  28. package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/combo/[id]/page.js +2 -2
  29. package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/combo/[id]/page.js.nft.json +1 -1
  30. package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/combo/[id]/page_client-reference-manifest.js +1 -1
  31. package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/web/page.js +2 -2
  32. package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/web/page.js.nft.json +1 -1
  33. package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/web/page_client-reference-manifest.js +1 -1
  34. package/app/.next-cli-build/server/app/(dashboard)/dashboard/mitm/page.js +1 -1
  35. package/app/.next-cli-build/server/app/(dashboard)/dashboard/mitm/page.js.nft.json +1 -1
  36. package/app/.next-cli-build/server/app/(dashboard)/dashboard/mitm/page_client-reference-manifest.js +1 -1
  37. package/app/.next-cli-build/server/app/(dashboard)/dashboard/page.js +1 -1
  38. package/app/.next-cli-build/server/app/(dashboard)/dashboard/page.js.nft.json +1 -1
  39. package/app/.next-cli-build/server/app/(dashboard)/dashboard/page_client-reference-manifest.js +1 -1
  40. package/app/.next-cli-build/server/app/(dashboard)/dashboard/profile/page.js +1 -1
  41. package/app/.next-cli-build/server/app/(dashboard)/dashboard/profile/page.js.nft.json +1 -1
  42. package/app/.next-cli-build/server/app/(dashboard)/dashboard/profile/page_client-reference-manifest.js +1 -1
  43. package/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/[id]/page.js +2 -2
  44. package/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/[id]/page.js.nft.json +1 -1
  45. package/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/[id]/page_client-reference-manifest.js +1 -1
  46. package/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/new/page.js +1 -1
  47. package/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/new/page.js.nft.json +1 -1
  48. package/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/new/page_client-reference-manifest.js +1 -1
  49. package/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/page.js +1 -1
  50. package/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/page.js.nft.json +1 -1
  51. package/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/page_client-reference-manifest.js +1 -1
  52. package/app/.next-cli-build/server/app/(dashboard)/dashboard/proxy-pools/page.js +1 -1
  53. package/app/.next-cli-build/server/app/(dashboard)/dashboard/proxy-pools/page.js.nft.json +1 -1
  54. package/app/.next-cli-build/server/app/(dashboard)/dashboard/proxy-pools/page_client-reference-manifest.js +1 -1
  55. package/app/.next-cli-build/server/app/(dashboard)/dashboard/quota/page.js +2 -2
  56. package/app/.next-cli-build/server/app/(dashboard)/dashboard/quota/page.js.nft.json +1 -1
  57. package/app/.next-cli-build/server/app/(dashboard)/dashboard/quota/page_client-reference-manifest.js +1 -1
  58. package/app/.next-cli-build/server/app/(dashboard)/dashboard/skills/page.js +1 -1
  59. package/app/.next-cli-build/server/app/(dashboard)/dashboard/skills/page.js.nft.json +1 -1
  60. package/app/.next-cli-build/server/app/(dashboard)/dashboard/skills/page_client-reference-manifest.js +1 -1
  61. package/app/.next-cli-build/server/app/(dashboard)/dashboard/token-saver/page.js +1 -1
  62. package/app/.next-cli-build/server/app/(dashboard)/dashboard/token-saver/page.js.nft.json +1 -1
  63. package/app/.next-cli-build/server/app/(dashboard)/dashboard/token-saver/page_client-reference-manifest.js +1 -1
  64. package/app/.next-cli-build/server/app/(dashboard)/dashboard/translator/page.js +1 -1
  65. package/app/.next-cli-build/server/app/(dashboard)/dashboard/translator/page.js.nft.json +1 -1
  66. package/app/.next-cli-build/server/app/(dashboard)/dashboard/translator/page_client-reference-manifest.js +1 -1
  67. package/app/.next-cli-build/server/app/(dashboard)/dashboard/usage/page.js +2 -2
  68. package/app/.next-cli-build/server/app/(dashboard)/dashboard/usage/page.js.nft.json +1 -1
  69. package/app/.next-cli-build/server/app/(dashboard)/dashboard/usage/page_client-reference-manifest.js +1 -1
  70. package/app/.next-cli-build/server/app/_global-error/page.js.nft.json +1 -1
  71. package/app/.next-cli-build/server/app/_global-error/page_client-reference-manifest.js +1 -1
  72. package/app/.next-cli-build/server/app/_global-error.html +1 -1
  73. package/app/.next-cli-build/server/app/_global-error.rsc +1 -1
  74. package/app/.next-cli-build/server/app/_global-error.segments/_full.segment.rsc +1 -1
  75. package/app/.next-cli-build/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
  76. package/app/.next-cli-build/server/app/_global-error.segments/_global-error.segment.rsc +1 -1
  77. package/app/.next-cli-build/server/app/_global-error.segments/_head.segment.rsc +1 -1
  78. package/app/.next-cli-build/server/app/_global-error.segments/_index.segment.rsc +1 -1
  79. package/app/.next-cli-build/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  80. package/app/.next-cli-build/server/app/_not-found/page.js +1 -1
  81. package/app/.next-cli-build/server/app/_not-found/page.js.nft.json +1 -1
  82. package/app/.next-cli-build/server/app/_not-found/page_client-reference-manifest.js +1 -1
  83. package/app/.next-cli-build/server/app/_not-found.html +1 -1
  84. package/app/.next-cli-build/server/app/_not-found.rsc +4 -4
  85. package/app/.next-cli-build/server/app/_not-found.segments/_full.segment.rsc +4 -4
  86. package/app/.next-cli-build/server/app/_not-found.segments/_head.segment.rsc +1 -1
  87. package/app/.next-cli-build/server/app/_not-found.segments/_index.segment.rsc +4 -4
  88. package/app/.next-cli-build/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
  89. package/app/.next-cli-build/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
  90. package/app/.next-cli-build/server/app/_not-found.segments/_tree.segment.rsc +1 -1
  91. package/app/.next-cli-build/server/app/api/auth/login/route.js.nft.json +1 -1
  92. package/app/.next-cli-build/server/app/api/auth/logout/route.js.nft.json +1 -1
  93. package/app/.next-cli-build/server/app/api/auth/oidc/callback/route.js.nft.json +1 -1
  94. package/app/.next-cli-build/server/app/api/auth/oidc/start/route.js.nft.json +1 -1
  95. package/app/.next-cli-build/server/app/api/auth/oidc/test/route.js.nft.json +1 -1
  96. package/app/.next-cli-build/server/app/api/auth/reset-password/route.js.nft.json +1 -1
  97. package/app/.next-cli-build/server/app/api/auth/status/route.js.nft.json +1 -1
  98. package/app/.next-cli-build/server/app/api/cli-tools/all-statuses/route.js +1 -1
  99. package/app/.next-cli-build/server/app/api/cli-tools/all-statuses/route.js.nft.json +1 -1
  100. package/app/.next-cli-build/server/app/api/cli-tools/antigravity-mitm/alias/route.js.nft.json +1 -1
  101. package/app/.next-cli-build/server/app/api/cli-tools/antigravity-mitm/route.js.nft.json +1 -1
  102. package/app/.next-cli-build/server/app/api/cli-tools/claude-settings/route.js.nft.json +1 -1
  103. package/app/.next-cli-build/server/app/api/cli-tools/cline-settings/route.js.nft.json +1 -1
  104. package/app/.next-cli-build/server/app/api/cli-tools/codex-settings/route.js.nft.json +1 -1
  105. package/app/.next-cli-build/server/app/api/cli-tools/copilot-settings/route.js.nft.json +1 -1
  106. package/app/.next-cli-build/server/app/api/cli-tools/cowork-mcp-registry/route.js.nft.json +1 -1
  107. package/app/.next-cli-build/server/app/api/cli-tools/cowork-mcp-tools/route.js.nft.json +1 -1
  108. package/app/.next-cli-build/server/app/api/cli-tools/cowork-settings/route.js +1 -1
  109. package/app/.next-cli-build/server/app/api/cli-tools/cowork-settings/route.js.nft.json +1 -1
  110. package/app/.next-cli-build/server/app/api/cli-tools/deepseek-tui-settings/route.js.nft.json +1 -1
  111. package/app/.next-cli-build/server/app/api/cli-tools/droid-settings/route.js.nft.json +1 -1
  112. package/app/.next-cli-build/server/app/api/cli-tools/hermes-settings/route.js.nft.json +1 -1
  113. package/app/.next-cli-build/server/app/api/cli-tools/jcode-settings/route.js.nft.json +1 -1
  114. package/app/.next-cli-build/server/app/api/cli-tools/kilo-settings/route.js.nft.json +1 -1
  115. package/app/.next-cli-build/server/app/api/cli-tools/openclaw-settings/route.js.nft.json +1 -1
  116. package/app/.next-cli-build/server/app/api/cli-tools/opencode-settings/route.js.nft.json +1 -1
  117. package/app/.next-cli-build/server/app/api/combos/[id]/route.js +1 -1
  118. package/app/.next-cli-build/server/app/api/combos/[id]/route.js.nft.json +1 -1
  119. package/app/.next-cli-build/server/app/api/combos/reorder/route.js.nft.json +1 -1
  120. package/app/.next-cli-build/server/app/api/combos/route.js.nft.json +1 -1
  121. package/app/.next-cli-build/server/app/api/headroom/start/route.js.nft.json +1 -1
  122. package/app/.next-cli-build/server/app/api/headroom/status/route.js.nft.json +1 -1
  123. package/app/.next-cli-build/server/app/api/headroom/stop/route.js.nft.json +1 -1
  124. package/app/.next-cli-build/server/app/api/health/route.js.nft.json +1 -1
  125. package/app/.next-cli-build/server/app/api/init/route.js.nft.json +1 -1
  126. package/app/.next-cli-build/server/app/api/keys/[id]/route.js.nft.json +1 -1
  127. package/app/.next-cli-build/server/app/api/keys/route.js.nft.json +1 -1
  128. package/app/.next-cli-build/server/app/api/locale/route.js.nft.json +1 -1
  129. package/app/.next-cli-build/server/app/api/mcp/[plugin]/message/route.js.nft.json +1 -1
  130. package/app/.next-cli-build/server/app/api/mcp/[plugin]/sse/route.js.nft.json +1 -1
  131. package/app/.next-cli-build/server/app/api/media-providers/tts/deepgram/voices/route.js.nft.json +1 -1
  132. package/app/.next-cli-build/server/app/api/media-providers/tts/elevenlabs/voices/route.js +1 -1
  133. package/app/.next-cli-build/server/app/api/media-providers/tts/elevenlabs/voices/route.js.nft.json +1 -1
  134. package/app/.next-cli-build/server/app/api/media-providers/tts/inworld/voices/route.js.nft.json +1 -1
  135. package/app/.next-cli-build/server/app/api/media-providers/tts/minimax/voices/route.js.nft.json +1 -1
  136. package/app/.next-cli-build/server/app/api/media-providers/tts/voices/route.js +1 -1
  137. package/app/.next-cli-build/server/app/api/media-providers/tts/voices/route.js.nft.json +1 -1
  138. package/app/.next-cli-build/server/app/api/models/alias/route.js.nft.json +1 -1
  139. package/app/.next-cli-build/server/app/api/models/availability/route.js.nft.json +1 -1
  140. package/app/.next-cli-build/server/app/api/models/custom/route.js.nft.json +1 -1
  141. package/app/.next-cli-build/server/app/api/models/disabled/route.js.nft.json +1 -1
  142. package/app/.next-cli-build/server/app/api/models/order/route.js.nft.json +1 -1
  143. package/app/.next-cli-build/server/app/api/models/route.js +1 -1
  144. package/app/.next-cli-build/server/app/api/models/route.js.nft.json +1 -1
  145. package/app/.next-cli-build/server/app/api/models/test/route.js +1 -1
  146. package/app/.next-cli-build/server/app/api/models/test/route.js.nft.json +1 -1
  147. package/app/.next-cli-build/server/app/api/oauth/[provider]/[action]/route.js +1 -1
  148. package/app/.next-cli-build/server/app/api/oauth/[provider]/[action]/route.js.nft.json +1 -1
  149. package/app/.next-cli-build/server/app/api/oauth/codex/bulk-import/route.js +1 -1
  150. package/app/.next-cli-build/server/app/api/oauth/codex/bulk-import/route.js.nft.json +1 -1
  151. package/app/.next-cli-build/server/app/api/oauth/codex/import-token/route.js +1 -1
  152. package/app/.next-cli-build/server/app/api/oauth/codex/import-token/route.js.nft.json +1 -1
  153. package/app/.next-cli-build/server/app/api/oauth/cursor/auto-import/route.js.nft.json +1 -1
  154. package/app/.next-cli-build/server/app/api/oauth/cursor/import/route.js +1 -1
  155. package/app/.next-cli-build/server/app/api/oauth/cursor/import/route.js.nft.json +1 -1
  156. package/app/.next-cli-build/server/app/api/oauth/gitlab/pat/route.js.nft.json +1 -1
  157. package/app/.next-cli-build/server/app/api/oauth/iflow/cookie/route.js.nft.json +1 -1
  158. package/app/.next-cli-build/server/app/api/oauth/kiro/api-key/route.js +1 -1
  159. package/app/.next-cli-build/server/app/api/oauth/kiro/api-key/route.js.nft.json +1 -1
  160. package/app/.next-cli-build/server/app/api/oauth/kiro/auto-import/route.js.nft.json +1 -1
  161. package/app/.next-cli-build/server/app/api/oauth/kiro/import/route.js +1 -1
  162. package/app/.next-cli-build/server/app/api/oauth/kiro/import/route.js.nft.json +1 -1
  163. package/app/.next-cli-build/server/app/api/oauth/kiro/import-cli-proxy/route.js.nft.json +1 -1
  164. package/app/.next-cli-build/server/app/api/oauth/kiro/social-authorize/route.js +1 -1
  165. package/app/.next-cli-build/server/app/api/oauth/kiro/social-authorize/route.js.nft.json +1 -1
  166. package/app/.next-cli-build/server/app/api/oauth/kiro/social-exchange/route.js +1 -1
  167. package/app/.next-cli-build/server/app/api/oauth/kiro/social-exchange/route.js.nft.json +1 -1
  168. package/app/.next-cli-build/server/app/api/pricing/route.js.nft.json +1 -1
  169. package/app/.next-cli-build/server/app/api/provider-nodes/[id]/route.js.nft.json +1 -1
  170. package/app/.next-cli-build/server/app/api/provider-nodes/route.js.nft.json +1 -1
  171. package/app/.next-cli-build/server/app/api/provider-nodes/validate/route.js.nft.json +1 -1
  172. package/app/.next-cli-build/server/app/api/providers/[id]/connections/disabled/route.js.nft.json +1 -1
  173. package/app/.next-cli-build/server/app/api/providers/[id]/models/route.js +1 -1
  174. package/app/.next-cli-build/server/app/api/providers/[id]/models/route.js.nft.json +1 -1
  175. package/app/.next-cli-build/server/app/api/providers/[id]/pool/pull/route.js.nft.json +1 -1
  176. package/app/.next-cli-build/server/app/api/providers/[id]/pool/push/route.js.nft.json +1 -1
  177. package/app/.next-cli-build/server/app/api/providers/[id]/pool/route.js.nft.json +1 -1
  178. package/app/.next-cli-build/server/app/api/providers/[id]/route.js.nft.json +1 -1
  179. package/app/.next-cli-build/server/app/api/providers/[id]/test/route.js +1 -1
  180. package/app/.next-cli-build/server/app/api/providers/[id]/test/route.js.nft.json +1 -1
  181. package/app/.next-cli-build/server/app/api/providers/[id]/test-models/route.js +1 -1
  182. package/app/.next-cli-build/server/app/api/providers/[id]/test-models/route.js.nft.json +1 -1
  183. package/app/.next-cli-build/server/app/api/providers/client/route.js +1 -1
  184. package/app/.next-cli-build/server/app/api/providers/client/route.js.nft.json +1 -1
  185. package/app/.next-cli-build/server/app/api/providers/kilo/free-models/route.js.nft.json +1 -1
  186. package/app/.next-cli-build/server/app/api/providers/route.js +1 -1
  187. package/app/.next-cli-build/server/app/api/providers/route.js.nft.json +1 -1
  188. package/app/.next-cli-build/server/app/api/providers/suggested-models/route.js.nft.json +1 -1
  189. package/app/.next-cli-build/server/app/api/providers/test-batch/route.js +1 -1
  190. package/app/.next-cli-build/server/app/api/providers/test-batch/route.js.nft.json +1 -1
  191. package/app/.next-cli-build/server/app/api/providers/validate/route.js +1 -1
  192. package/app/.next-cli-build/server/app/api/providers/validate/route.js.nft.json +1 -1
  193. package/app/.next-cli-build/server/app/api/proxy-pools/[id]/route.js.nft.json +1 -1
  194. package/app/.next-cli-build/server/app/api/proxy-pools/[id]/test/route.js.nft.json +1 -1
  195. package/app/.next-cli-build/server/app/api/proxy-pools/cloudflare-deploy/route.js.nft.json +1 -1
  196. package/app/.next-cli-build/server/app/api/proxy-pools/deno-deploy/route.js.nft.json +1 -1
  197. package/app/.next-cli-build/server/app/api/proxy-pools/route.js.nft.json +1 -1
  198. package/app/.next-cli-build/server/app/api/proxy-pools/vercel-deploy/route.js.nft.json +1 -1
  199. package/app/.next-cli-build/server/app/api/settings/database/route.js.nft.json +1 -1
  200. package/app/.next-cli-build/server/app/api/settings/proxy-test/route.js.nft.json +1 -1
  201. package/app/.next-cli-build/server/app/api/settings/require-login/route.js.nft.json +1 -1
  202. package/app/.next-cli-build/server/app/api/settings/route.js +1 -1
  203. package/app/.next-cli-build/server/app/api/settings/route.js.nft.json +1 -1
  204. package/app/.next-cli-build/server/app/api/shutdown/route.js.nft.json +1 -1
  205. package/app/.next-cli-build/server/app/api/tags/route.js.nft.json +1 -1
  206. package/app/.next-cli-build/server/app/api/translator/console-logs/route.js +1 -1
  207. package/app/.next-cli-build/server/app/api/translator/console-logs/route.js.nft.json +1 -1
  208. package/app/.next-cli-build/server/app/api/translator/console-logs/stream/route.js +1 -1
  209. package/app/.next-cli-build/server/app/api/translator/console-logs/stream/route.js.nft.json +1 -1
  210. package/app/.next-cli-build/server/app/api/translator/load/route.js.nft.json +1 -1
  211. package/app/.next-cli-build/server/app/api/translator/save/route.js.nft.json +1 -1
  212. package/app/.next-cli-build/server/app/api/translator/send/route.js +1 -1
  213. package/app/.next-cli-build/server/app/api/translator/send/route.js.nft.json +1 -1
  214. package/app/.next-cli-build/server/app/api/translator/translate/route.js +1 -1
  215. package/app/.next-cli-build/server/app/api/translator/translate/route.js.nft.json +1 -1
  216. package/app/.next-cli-build/server/app/api/tunnel/disable/route.js.nft.json +1 -1
  217. package/app/.next-cli-build/server/app/api/tunnel/enable/route.js.nft.json +1 -1
  218. package/app/.next-cli-build/server/app/api/tunnel/status/route.js.nft.json +1 -1
  219. package/app/.next-cli-build/server/app/api/tunnel/tailscale-check/route.js.nft.json +1 -1
  220. package/app/.next-cli-build/server/app/api/tunnel/tailscale-disable/route.js.nft.json +1 -1
  221. package/app/.next-cli-build/server/app/api/tunnel/tailscale-enable/route.js.nft.json +1 -1
  222. package/app/.next-cli-build/server/app/api/tunnel/tailscale-install/route.js.nft.json +1 -1
  223. package/app/.next-cli-build/server/app/api/usage/[connectionId]/codex-reset-credits/route.js +1 -1
  224. package/app/.next-cli-build/server/app/api/usage/[connectionId]/codex-reset-credits/route.js.nft.json +1 -1
  225. package/app/.next-cli-build/server/app/api/usage/[connectionId]/route.js +1 -1
  226. package/app/.next-cli-build/server/app/api/usage/[connectionId]/route.js.nft.json +1 -1
  227. package/app/.next-cli-build/server/app/api/usage/chart/route.js.nft.json +1 -1
  228. package/app/.next-cli-build/server/app/api/usage/history/route.js.nft.json +1 -1
  229. package/app/.next-cli-build/server/app/api/usage/logs/route.js.nft.json +1 -1
  230. package/app/.next-cli-build/server/app/api/usage/providers/route.js.nft.json +1 -1
  231. package/app/.next-cli-build/server/app/api/usage/request-details/route.js.nft.json +1 -1
  232. package/app/.next-cli-build/server/app/api/usage/request-logs/route.js.nft.json +1 -1
  233. package/app/.next-cli-build/server/app/api/usage/stats/route.js.nft.json +1 -1
  234. package/app/.next-cli-build/server/app/api/usage/stream/route.js.nft.json +1 -1
  235. package/app/.next-cli-build/server/app/api/v1/api/chat/route.js +1 -1
  236. package/app/.next-cli-build/server/app/api/v1/api/chat/route.js.nft.json +1 -1
  237. package/app/.next-cli-build/server/app/api/v1/audio/speech/route.js +1 -1
  238. package/app/.next-cli-build/server/app/api/v1/audio/speech/route.js.nft.json +1 -1
  239. package/app/.next-cli-build/server/app/api/v1/audio/transcriptions/route.js +1 -1
  240. package/app/.next-cli-build/server/app/api/v1/audio/transcriptions/route.js.nft.json +1 -1
  241. package/app/.next-cli-build/server/app/api/v1/audio/voices/route.js.nft.json +1 -1
  242. package/app/.next-cli-build/server/app/api/v1/chat/completions/route.js +1 -1
  243. package/app/.next-cli-build/server/app/api/v1/chat/completions/route.js.nft.json +1 -1
  244. package/app/.next-cli-build/server/app/api/v1/embeddings/route.js +1 -1
  245. package/app/.next-cli-build/server/app/api/v1/embeddings/route.js.nft.json +1 -1
  246. package/app/.next-cli-build/server/app/api/v1/images/generations/route.js +1 -1
  247. package/app/.next-cli-build/server/app/api/v1/images/generations/route.js.nft.json +1 -1
  248. package/app/.next-cli-build/server/app/api/v1/messages/count_tokens/route.js.nft.json +1 -1
  249. package/app/.next-cli-build/server/app/api/v1/messages/route.js +1 -1
  250. package/app/.next-cli-build/server/app/api/v1/messages/route.js.nft.json +1 -1
  251. package/app/.next-cli-build/server/app/api/v1/models/[kind]/route.js +1 -1
  252. package/app/.next-cli-build/server/app/api/v1/models/[kind]/route.js.nft.json +1 -1
  253. package/app/.next-cli-build/server/app/api/v1/models/info/route.js +1 -1
  254. package/app/.next-cli-build/server/app/api/v1/models/info/route.js.nft.json +1 -1
  255. package/app/.next-cli-build/server/app/api/v1/models/route.js +1 -1
  256. package/app/.next-cli-build/server/app/api/v1/models/route.js.nft.json +1 -1
  257. package/app/.next-cli-build/server/app/api/v1/responses/compact/route.js +1 -1
  258. package/app/.next-cli-build/server/app/api/v1/responses/compact/route.js.nft.json +1 -1
  259. package/app/.next-cli-build/server/app/api/v1/responses/route.js +1 -1
  260. package/app/.next-cli-build/server/app/api/v1/responses/route.js.nft.json +1 -1
  261. package/app/.next-cli-build/server/app/api/v1/route.js +1 -1
  262. package/app/.next-cli-build/server/app/api/v1/route.js.nft.json +1 -1
  263. package/app/.next-cli-build/server/app/api/v1/search/route.js +1 -1
  264. package/app/.next-cli-build/server/app/api/v1/search/route.js.nft.json +1 -1
  265. package/app/.next-cli-build/server/app/api/v1/web/fetch/route.js +1 -1
  266. package/app/.next-cli-build/server/app/api/v1/web/fetch/route.js.nft.json +1 -1
  267. package/app/.next-cli-build/server/app/api/v1beta/models/[...path]/route.js +1 -1
  268. package/app/.next-cli-build/server/app/api/v1beta/models/[...path]/route.js.nft.json +1 -1
  269. package/app/.next-cli-build/server/app/api/v1beta/models/route.js +1 -1
  270. package/app/.next-cli-build/server/app/api/v1beta/models/route.js.nft.json +1 -1
  271. package/app/.next-cli-build/server/app/api/version/route.js +1 -1
  272. package/app/.next-cli-build/server/app/api/version/route.js.nft.json +1 -1
  273. package/app/.next-cli-build/server/app/api/version/shutdown/route.js +1 -1
  274. package/app/.next-cli-build/server/app/api/version/shutdown/route.js.nft.json +1 -1
  275. package/app/.next-cli-build/server/app/api/version/update/route.js +1 -1
  276. package/app/.next-cli-build/server/app/api/version/update/route.js.nft.json +1 -1
  277. package/app/.next-cli-build/server/app/callback/page.js +1 -1
  278. package/app/.next-cli-build/server/app/callback/page.js.nft.json +1 -1
  279. package/app/.next-cli-build/server/app/callback/page_client-reference-manifest.js +1 -1
  280. package/app/.next-cli-build/server/app/callback.html +1 -1
  281. package/app/.next-cli-build/server/app/callback.rsc +4 -4
  282. package/app/.next-cli-build/server/app/callback.segments/_full.segment.rsc +4 -4
  283. package/app/.next-cli-build/server/app/callback.segments/_head.segment.rsc +1 -1
  284. package/app/.next-cli-build/server/app/callback.segments/_index.segment.rsc +4 -4
  285. package/app/.next-cli-build/server/app/callback.segments/_tree.segment.rsc +1 -1
  286. package/app/.next-cli-build/server/app/callback.segments/callback/__PAGE__.segment.rsc +1 -1
  287. package/app/.next-cli-build/server/app/callback.segments/callback.segment.rsc +1 -1
  288. package/app/.next-cli-build/server/app/dashboard/basic-chat.html +1 -1
  289. package/app/.next-cli-build/server/app/dashboard/basic-chat.rsc +6 -6
  290. package/app/.next-cli-build/server/app/dashboard/basic-chat.segments/!KGRhc2hib2FyZCk/dashboard/basic-chat/__PAGE__.segment.rsc +2 -2
  291. package/app/.next-cli-build/server/app/dashboard/basic-chat.segments/!KGRhc2hib2FyZCk/dashboard/basic-chat.segment.rsc +1 -1
  292. package/app/.next-cli-build/server/app/dashboard/basic-chat.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  293. package/app/.next-cli-build/server/app/dashboard/basic-chat.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  294. package/app/.next-cli-build/server/app/dashboard/basic-chat.segments/_full.segment.rsc +6 -6
  295. package/app/.next-cli-build/server/app/dashboard/basic-chat.segments/_head.segment.rsc +1 -1
  296. package/app/.next-cli-build/server/app/dashboard/basic-chat.segments/_index.segment.rsc +4 -4
  297. package/app/.next-cli-build/server/app/dashboard/basic-chat.segments/_tree.segment.rsc +1 -1
  298. package/app/.next-cli-build/server/app/dashboard/cli-tools.html +1 -1
  299. package/app/.next-cli-build/server/app/dashboard/cli-tools.rsc +6 -6
  300. package/app/.next-cli-build/server/app/dashboard/cli-tools.segments/!KGRhc2hib2FyZCk/dashboard/cli-tools/__PAGE__.segment.rsc +2 -2
  301. package/app/.next-cli-build/server/app/dashboard/cli-tools.segments/!KGRhc2hib2FyZCk/dashboard/cli-tools.segment.rsc +1 -1
  302. package/app/.next-cli-build/server/app/dashboard/cli-tools.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  303. package/app/.next-cli-build/server/app/dashboard/cli-tools.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  304. package/app/.next-cli-build/server/app/dashboard/cli-tools.segments/_full.segment.rsc +6 -6
  305. package/app/.next-cli-build/server/app/dashboard/cli-tools.segments/_head.segment.rsc +1 -1
  306. package/app/.next-cli-build/server/app/dashboard/cli-tools.segments/_index.segment.rsc +4 -4
  307. package/app/.next-cli-build/server/app/dashboard/cli-tools.segments/_tree.segment.rsc +1 -1
  308. package/app/.next-cli-build/server/app/dashboard/combos.html +1 -1
  309. package/app/.next-cli-build/server/app/dashboard/combos.rsc +6 -6
  310. package/app/.next-cli-build/server/app/dashboard/combos.segments/!KGRhc2hib2FyZCk/dashboard/combos/__PAGE__.segment.rsc +2 -2
  311. package/app/.next-cli-build/server/app/dashboard/combos.segments/!KGRhc2hib2FyZCk/dashboard/combos.segment.rsc +1 -1
  312. package/app/.next-cli-build/server/app/dashboard/combos.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  313. package/app/.next-cli-build/server/app/dashboard/combos.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  314. package/app/.next-cli-build/server/app/dashboard/combos.segments/_full.segment.rsc +6 -6
  315. package/app/.next-cli-build/server/app/dashboard/combos.segments/_head.segment.rsc +1 -1
  316. package/app/.next-cli-build/server/app/dashboard/combos.segments/_index.segment.rsc +4 -4
  317. package/app/.next-cli-build/server/app/dashboard/combos.segments/_tree.segment.rsc +1 -1
  318. package/app/.next-cli-build/server/app/dashboard/endpoint.html +1 -1
  319. package/app/.next-cli-build/server/app/dashboard/endpoint.rsc +6 -6
  320. package/app/.next-cli-build/server/app/dashboard/endpoint.segments/!KGRhc2hib2FyZCk/dashboard/endpoint/__PAGE__.segment.rsc +2 -2
  321. package/app/.next-cli-build/server/app/dashboard/endpoint.segments/!KGRhc2hib2FyZCk/dashboard/endpoint.segment.rsc +1 -1
  322. package/app/.next-cli-build/server/app/dashboard/endpoint.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  323. package/app/.next-cli-build/server/app/dashboard/endpoint.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  324. package/app/.next-cli-build/server/app/dashboard/endpoint.segments/_full.segment.rsc +6 -6
  325. package/app/.next-cli-build/server/app/dashboard/endpoint.segments/_head.segment.rsc +1 -1
  326. package/app/.next-cli-build/server/app/dashboard/endpoint.segments/_index.segment.rsc +4 -4
  327. package/app/.next-cli-build/server/app/dashboard/endpoint.segments/_tree.segment.rsc +1 -1
  328. package/app/.next-cli-build/server/app/dashboard/media-providers/web.html +1 -1
  329. package/app/.next-cli-build/server/app/dashboard/media-providers/web.rsc +6 -6
  330. package/app/.next-cli-build/server/app/dashboard/media-providers/web.segments/!KGRhc2hib2FyZCk/dashboard/media-providers/web/__PAGE__.segment.rsc +2 -2
  331. package/app/.next-cli-build/server/app/dashboard/media-providers/web.segments/!KGRhc2hib2FyZCk/dashboard/media-providers/web.segment.rsc +1 -1
  332. package/app/.next-cli-build/server/app/dashboard/media-providers/web.segments/!KGRhc2hib2FyZCk/dashboard/media-providers.segment.rsc +1 -1
  333. package/app/.next-cli-build/server/app/dashboard/media-providers/web.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  334. package/app/.next-cli-build/server/app/dashboard/media-providers/web.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  335. package/app/.next-cli-build/server/app/dashboard/media-providers/web.segments/_full.segment.rsc +6 -6
  336. package/app/.next-cli-build/server/app/dashboard/media-providers/web.segments/_head.segment.rsc +1 -1
  337. package/app/.next-cli-build/server/app/dashboard/media-providers/web.segments/_index.segment.rsc +4 -4
  338. package/app/.next-cli-build/server/app/dashboard/media-providers/web.segments/_tree.segment.rsc +1 -1
  339. package/app/.next-cli-build/server/app/dashboard/mitm.html +1 -1
  340. package/app/.next-cli-build/server/app/dashboard/mitm.rsc +6 -6
  341. package/app/.next-cli-build/server/app/dashboard/mitm.segments/!KGRhc2hib2FyZCk/dashboard/mitm/__PAGE__.segment.rsc +2 -2
  342. package/app/.next-cli-build/server/app/dashboard/mitm.segments/!KGRhc2hib2FyZCk/dashboard/mitm.segment.rsc +1 -1
  343. package/app/.next-cli-build/server/app/dashboard/mitm.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  344. package/app/.next-cli-build/server/app/dashboard/mitm.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  345. package/app/.next-cli-build/server/app/dashboard/mitm.segments/_full.segment.rsc +6 -6
  346. package/app/.next-cli-build/server/app/dashboard/mitm.segments/_head.segment.rsc +1 -1
  347. package/app/.next-cli-build/server/app/dashboard/mitm.segments/_index.segment.rsc +4 -4
  348. package/app/.next-cli-build/server/app/dashboard/mitm.segments/_tree.segment.rsc +1 -1
  349. package/app/.next-cli-build/server/app/dashboard/profile.html +1 -1
  350. package/app/.next-cli-build/server/app/dashboard/profile.rsc +6 -6
  351. package/app/.next-cli-build/server/app/dashboard/profile.segments/!KGRhc2hib2FyZCk/dashboard/profile/__PAGE__.segment.rsc +2 -2
  352. package/app/.next-cli-build/server/app/dashboard/profile.segments/!KGRhc2hib2FyZCk/dashboard/profile.segment.rsc +1 -1
  353. package/app/.next-cli-build/server/app/dashboard/profile.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  354. package/app/.next-cli-build/server/app/dashboard/profile.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  355. package/app/.next-cli-build/server/app/dashboard/profile.segments/_full.segment.rsc +6 -6
  356. package/app/.next-cli-build/server/app/dashboard/profile.segments/_head.segment.rsc +1 -1
  357. package/app/.next-cli-build/server/app/dashboard/profile.segments/_index.segment.rsc +4 -4
  358. package/app/.next-cli-build/server/app/dashboard/profile.segments/_tree.segment.rsc +1 -1
  359. package/app/.next-cli-build/server/app/dashboard/providers/new.html +1 -1
  360. package/app/.next-cli-build/server/app/dashboard/providers/new.rsc +6 -6
  361. package/app/.next-cli-build/server/app/dashboard/providers/new.segments/!KGRhc2hib2FyZCk/dashboard/providers/new/__PAGE__.segment.rsc +2 -2
  362. package/app/.next-cli-build/server/app/dashboard/providers/new.segments/!KGRhc2hib2FyZCk/dashboard/providers/new.segment.rsc +1 -1
  363. package/app/.next-cli-build/server/app/dashboard/providers/new.segments/!KGRhc2hib2FyZCk/dashboard/providers.segment.rsc +1 -1
  364. package/app/.next-cli-build/server/app/dashboard/providers/new.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  365. package/app/.next-cli-build/server/app/dashboard/providers/new.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  366. package/app/.next-cli-build/server/app/dashboard/providers/new.segments/_full.segment.rsc +6 -6
  367. package/app/.next-cli-build/server/app/dashboard/providers/new.segments/_head.segment.rsc +1 -1
  368. package/app/.next-cli-build/server/app/dashboard/providers/new.segments/_index.segment.rsc +4 -4
  369. package/app/.next-cli-build/server/app/dashboard/providers/new.segments/_tree.segment.rsc +1 -1
  370. package/app/.next-cli-build/server/app/dashboard/providers.html +1 -1
  371. package/app/.next-cli-build/server/app/dashboard/providers.rsc +6 -6
  372. package/app/.next-cli-build/server/app/dashboard/providers.segments/!KGRhc2hib2FyZCk/dashboard/providers/__PAGE__.segment.rsc +2 -2
  373. package/app/.next-cli-build/server/app/dashboard/providers.segments/!KGRhc2hib2FyZCk/dashboard/providers.segment.rsc +1 -1
  374. package/app/.next-cli-build/server/app/dashboard/providers.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  375. package/app/.next-cli-build/server/app/dashboard/providers.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  376. package/app/.next-cli-build/server/app/dashboard/providers.segments/_full.segment.rsc +6 -6
  377. package/app/.next-cli-build/server/app/dashboard/providers.segments/_head.segment.rsc +1 -1
  378. package/app/.next-cli-build/server/app/dashboard/providers.segments/_index.segment.rsc +4 -4
  379. package/app/.next-cli-build/server/app/dashboard/providers.segments/_tree.segment.rsc +1 -1
  380. package/app/.next-cli-build/server/app/dashboard/proxy-pools.html +1 -1
  381. package/app/.next-cli-build/server/app/dashboard/proxy-pools.rsc +6 -6
  382. package/app/.next-cli-build/server/app/dashboard/proxy-pools.segments/!KGRhc2hib2FyZCk/dashboard/proxy-pools/__PAGE__.segment.rsc +2 -2
  383. package/app/.next-cli-build/server/app/dashboard/proxy-pools.segments/!KGRhc2hib2FyZCk/dashboard/proxy-pools.segment.rsc +1 -1
  384. package/app/.next-cli-build/server/app/dashboard/proxy-pools.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  385. package/app/.next-cli-build/server/app/dashboard/proxy-pools.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  386. package/app/.next-cli-build/server/app/dashboard/proxy-pools.segments/_full.segment.rsc +6 -6
  387. package/app/.next-cli-build/server/app/dashboard/proxy-pools.segments/_head.segment.rsc +1 -1
  388. package/app/.next-cli-build/server/app/dashboard/proxy-pools.segments/_index.segment.rsc +4 -4
  389. package/app/.next-cli-build/server/app/dashboard/proxy-pools.segments/_tree.segment.rsc +1 -1
  390. package/app/.next-cli-build/server/app/dashboard/quota.html +2 -2
  391. package/app/.next-cli-build/server/app/dashboard/quota.rsc +7 -7
  392. package/app/.next-cli-build/server/app/dashboard/quota.segments/!KGRhc2hib2FyZCk/dashboard/quota/__PAGE__.segment.rsc +3 -3
  393. package/app/.next-cli-build/server/app/dashboard/quota.segments/!KGRhc2hib2FyZCk/dashboard/quota.segment.rsc +1 -1
  394. package/app/.next-cli-build/server/app/dashboard/quota.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  395. package/app/.next-cli-build/server/app/dashboard/quota.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  396. package/app/.next-cli-build/server/app/dashboard/quota.segments/_full.segment.rsc +7 -7
  397. package/app/.next-cli-build/server/app/dashboard/quota.segments/_head.segment.rsc +1 -1
  398. package/app/.next-cli-build/server/app/dashboard/quota.segments/_index.segment.rsc +4 -4
  399. package/app/.next-cli-build/server/app/dashboard/quota.segments/_tree.segment.rsc +1 -1
  400. package/app/.next-cli-build/server/app/dashboard/settings/pricing/page.js +1 -1
  401. package/app/.next-cli-build/server/app/dashboard/settings/pricing/page.js.nft.json +1 -1
  402. package/app/.next-cli-build/server/app/dashboard/settings/pricing/page_client-reference-manifest.js +1 -1
  403. package/app/.next-cli-build/server/app/dashboard/settings/pricing.html +1 -1
  404. package/app/.next-cli-build/server/app/dashboard/settings/pricing.rsc +4 -4
  405. package/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/_full.segment.rsc +4 -4
  406. package/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/_head.segment.rsc +1 -1
  407. package/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/_index.segment.rsc +4 -4
  408. package/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/_tree.segment.rsc +1 -1
  409. package/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/dashboard/settings/pricing/__PAGE__.segment.rsc +1 -1
  410. package/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/dashboard/settings/pricing.segment.rsc +1 -1
  411. package/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/dashboard/settings.segment.rsc +1 -1
  412. package/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/dashboard.segment.rsc +1 -1
  413. package/app/.next-cli-build/server/app/dashboard/skills.html +1 -1
  414. package/app/.next-cli-build/server/app/dashboard/skills.rsc +6 -6
  415. package/app/.next-cli-build/server/app/dashboard/skills.segments/!KGRhc2hib2FyZCk/dashboard/skills/__PAGE__.segment.rsc +2 -2
  416. package/app/.next-cli-build/server/app/dashboard/skills.segments/!KGRhc2hib2FyZCk/dashboard/skills.segment.rsc +1 -1
  417. package/app/.next-cli-build/server/app/dashboard/skills.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  418. package/app/.next-cli-build/server/app/dashboard/skills.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  419. package/app/.next-cli-build/server/app/dashboard/skills.segments/_full.segment.rsc +6 -6
  420. package/app/.next-cli-build/server/app/dashboard/skills.segments/_head.segment.rsc +1 -1
  421. package/app/.next-cli-build/server/app/dashboard/skills.segments/_index.segment.rsc +4 -4
  422. package/app/.next-cli-build/server/app/dashboard/skills.segments/_tree.segment.rsc +1 -1
  423. package/app/.next-cli-build/server/app/dashboard/token-saver.html +1 -1
  424. package/app/.next-cli-build/server/app/dashboard/token-saver.rsc +6 -6
  425. package/app/.next-cli-build/server/app/dashboard/token-saver.segments/!KGRhc2hib2FyZCk/dashboard/token-saver/__PAGE__.segment.rsc +2 -2
  426. package/app/.next-cli-build/server/app/dashboard/token-saver.segments/!KGRhc2hib2FyZCk/dashboard/token-saver.segment.rsc +1 -1
  427. package/app/.next-cli-build/server/app/dashboard/token-saver.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  428. package/app/.next-cli-build/server/app/dashboard/token-saver.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  429. package/app/.next-cli-build/server/app/dashboard/token-saver.segments/_full.segment.rsc +6 -6
  430. package/app/.next-cli-build/server/app/dashboard/token-saver.segments/_head.segment.rsc +1 -1
  431. package/app/.next-cli-build/server/app/dashboard/token-saver.segments/_index.segment.rsc +4 -4
  432. package/app/.next-cli-build/server/app/dashboard/token-saver.segments/_tree.segment.rsc +1 -1
  433. package/app/.next-cli-build/server/app/dashboard/translator.html +1 -1
  434. package/app/.next-cli-build/server/app/dashboard/translator.rsc +6 -6
  435. package/app/.next-cli-build/server/app/dashboard/translator.segments/!KGRhc2hib2FyZCk/dashboard/translator/__PAGE__.segment.rsc +2 -2
  436. package/app/.next-cli-build/server/app/dashboard/translator.segments/!KGRhc2hib2FyZCk/dashboard/translator.segment.rsc +1 -1
  437. package/app/.next-cli-build/server/app/dashboard/translator.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  438. package/app/.next-cli-build/server/app/dashboard/translator.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  439. package/app/.next-cli-build/server/app/dashboard/translator.segments/_full.segment.rsc +6 -6
  440. package/app/.next-cli-build/server/app/dashboard/translator.segments/_head.segment.rsc +1 -1
  441. package/app/.next-cli-build/server/app/dashboard/translator.segments/_index.segment.rsc +4 -4
  442. package/app/.next-cli-build/server/app/dashboard/translator.segments/_tree.segment.rsc +1 -1
  443. package/app/.next-cli-build/server/app/dashboard/usage.html +1 -1
  444. package/app/.next-cli-build/server/app/dashboard/usage.rsc +6 -6
  445. package/app/.next-cli-build/server/app/dashboard/usage.segments/!KGRhc2hib2FyZCk/dashboard/usage/__PAGE__.segment.rsc +2 -2
  446. package/app/.next-cli-build/server/app/dashboard/usage.segments/!KGRhc2hib2FyZCk/dashboard/usage.segment.rsc +1 -1
  447. package/app/.next-cli-build/server/app/dashboard/usage.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  448. package/app/.next-cli-build/server/app/dashboard/usage.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  449. package/app/.next-cli-build/server/app/dashboard/usage.segments/_full.segment.rsc +6 -6
  450. package/app/.next-cli-build/server/app/dashboard/usage.segments/_head.segment.rsc +1 -1
  451. package/app/.next-cli-build/server/app/dashboard/usage.segments/_index.segment.rsc +4 -4
  452. package/app/.next-cli-build/server/app/dashboard/usage.segments/_tree.segment.rsc +1 -1
  453. package/app/.next-cli-build/server/app/dashboard.html +1 -1
  454. package/app/.next-cli-build/server/app/dashboard.rsc +6 -6
  455. package/app/.next-cli-build/server/app/dashboard.segments/!KGRhc2hib2FyZCk/dashboard/__PAGE__.segment.rsc +2 -2
  456. package/app/.next-cli-build/server/app/dashboard.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  457. package/app/.next-cli-build/server/app/dashboard.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  458. package/app/.next-cli-build/server/app/dashboard.segments/_full.segment.rsc +6 -6
  459. package/app/.next-cli-build/server/app/dashboard.segments/_head.segment.rsc +1 -1
  460. package/app/.next-cli-build/server/app/dashboard.segments/_index.segment.rsc +4 -4
  461. package/app/.next-cli-build/server/app/dashboard.segments/_tree.segment.rsc +1 -1
  462. package/app/.next-cli-build/server/app/favicon.ico/route.js.nft.json +1 -1
  463. package/app/.next-cli-build/server/app/index.html +1 -1
  464. package/app/.next-cli-build/server/app/index.rsc +4 -4
  465. package/app/.next-cli-build/server/app/index.segments/__PAGE__.segment.rsc +1 -1
  466. package/app/.next-cli-build/server/app/index.segments/_full.segment.rsc +4 -4
  467. package/app/.next-cli-build/server/app/index.segments/_head.segment.rsc +1 -1
  468. package/app/.next-cli-build/server/app/index.segments/_index.segment.rsc +4 -4
  469. package/app/.next-cli-build/server/app/index.segments/_tree.segment.rsc +1 -1
  470. package/app/.next-cli-build/server/app/landing/page.js +1 -1
  471. package/app/.next-cli-build/server/app/landing/page.js.nft.json +1 -1
  472. package/app/.next-cli-build/server/app/landing/page_client-reference-manifest.js +1 -1
  473. package/app/.next-cli-build/server/app/landing.html +1 -1
  474. package/app/.next-cli-build/server/app/landing.rsc +4 -4
  475. package/app/.next-cli-build/server/app/landing.segments/_full.segment.rsc +4 -4
  476. package/app/.next-cli-build/server/app/landing.segments/_head.segment.rsc +1 -1
  477. package/app/.next-cli-build/server/app/landing.segments/_index.segment.rsc +4 -4
  478. package/app/.next-cli-build/server/app/landing.segments/_tree.segment.rsc +1 -1
  479. package/app/.next-cli-build/server/app/landing.segments/landing/__PAGE__.segment.rsc +1 -1
  480. package/app/.next-cli-build/server/app/landing.segments/landing.segment.rsc +1 -1
  481. package/app/.next-cli-build/server/app/login/page.js +1 -1
  482. package/app/.next-cli-build/server/app/login/page.js.nft.json +1 -1
  483. package/app/.next-cli-build/server/app/login/page_client-reference-manifest.js +1 -1
  484. package/app/.next-cli-build/server/app/login.html +1 -1
  485. package/app/.next-cli-build/server/app/login.rsc +5 -5
  486. package/app/.next-cli-build/server/app/login.segments/_full.segment.rsc +5 -5
  487. package/app/.next-cli-build/server/app/login.segments/_head.segment.rsc +1 -1
  488. package/app/.next-cli-build/server/app/login.segments/_index.segment.rsc +4 -4
  489. package/app/.next-cli-build/server/app/login.segments/_tree.segment.rsc +1 -1
  490. package/app/.next-cli-build/server/app/login.segments/login/__PAGE__.segment.rsc +2 -2
  491. package/app/.next-cli-build/server/app/login.segments/login.segment.rsc +1 -1
  492. package/app/.next-cli-build/server/app/manifest.webmanifest/route.js.nft.json +1 -1
  493. package/app/.next-cli-build/server/app/page.js +1 -1
  494. package/app/.next-cli-build/server/app/page.js.nft.json +1 -1
  495. package/app/.next-cli-build/server/app/page_client-reference-manifest.js +1 -1
  496. package/app/.next-cli-build/server/app-paths-manifest.json +13 -13
  497. package/app/.next-cli-build/server/chunks/255.js +1 -1
  498. package/app/.next-cli-build/server/chunks/3862.js +1 -1
  499. package/app/.next-cli-build/server/chunks/412.js +2 -2
  500. package/app/.next-cli-build/server/chunks/{9212.js → 4746.js} +1 -1
  501. package/app/.next-cli-build/server/chunks/{9325.js → 4827.js} +1 -1
  502. package/app/.next-cli-build/server/chunks/5330.js +5 -3
  503. package/app/.next-cli-build/server/chunks/6070.js +1 -1
  504. package/app/.next-cli-build/server/chunks/6173.js +1 -0
  505. package/app/.next-cli-build/server/chunks/7247.js +1 -1
  506. package/app/.next-cli-build/server/chunks/{3008.js → 8238.js} +1 -1
  507. package/app/.next-cli-build/server/chunks/8612.js +1 -1
  508. package/app/.next-cli-build/server/chunks/8668.js +1 -1
  509. package/app/.next-cli-build/server/chunks/8914.js +1 -1
  510. package/app/.next-cli-build/server/middleware-build-manifest.js +1 -1
  511. package/app/.next-cli-build/server/pages/404.html +1 -1
  512. package/app/.next-cli-build/server/pages/500.html +1 -1
  513. package/app/.next-cli-build/static/chunks/1321-e4c79e2cdf68e284.js +1 -0
  514. package/app/.next-cli-build/static/chunks/{5497-474ddf2f9f1e240f.js → 5497-98a294643e6a188f.js} +2 -2
  515. package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/basic-chat/{page-7ba4c41756c05cb5.js → page-f72dd3feb26e37b8.js} +1 -1
  516. package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/combos/{page-8b1acb4da984eaa1.js → page-125afc454b5cabed.js} +1 -1
  517. package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/media-providers/[kind]/[id]/page-d6c84f2d5e1f6918.js +59 -0
  518. package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/media-providers/[kind]/{page-8d76903c3a660e35.js → page-a80f28e86b1c62f4.js} +1 -1
  519. package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/media-providers/combo/[id]/{page-58605ef32c4743da.js → page-2fe0585adb58584f.js} +1 -1
  520. package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/media-providers/web/{page-e3f67c61640e6c04.js → page-5d766b35ca3d5649.js} +1 -1
  521. package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/mitm/{page-8087edfe1b477a47.js → page-d7e816b59a7568a3.js} +1 -1
  522. package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/providers/[id]/{page-d79551790a599cc0.js → page-19beba08f131dae3.js} +1 -1
  523. package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/providers/{page-c1d4cc4e73287170.js → page-dce32961998d9205.js} +1 -1
  524. package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/quota/{page-ef9399b03a241d5d.js → page-682f62efbaa33d99.js} +1 -1
  525. package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/usage/{page-3c4a78d014c6e082.js → page-368d5a5281671f5a.js} +1 -1
  526. package/app/cli/.build-home/.9router/db/backups/{upgrade-0.5.21-to-0.5.22-0.5.22-20260630-180928 → upgrade-0.5.36-to-0.5.37-0.5.37-20260706-105502}/data.sqlite +0 -0
  527. package/app/cli/.build-home/.9router/db/backups/{upgrade-0.5.22-to-0.5.26-0.5.26-20260701-181108 → upgrade-0.5.37-to-0.5.38-0.5.38-20260706-111459}/data.sqlite +0 -0
  528. package/app/cli/.build-home/.9router/db/data.sqlite +0 -0
  529. package/app/package.json +1 -1
  530. package/package.json +1 -1
  531. package/app/.next-cli-build/server/chunks/604.js +0 -1
  532. package/app/.next-cli-build/server/chunks/6775.js +0 -1
  533. package/app/.next-cli-build/static/chunks/1321-87efb6064fab51ca.js +0 -1
  534. package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/media-providers/[kind]/[id]/page-7fb2bc13098a64e2.js +0 -59
  535. /package/app/.next-cli-build/static/{CZsjEfWjq_f7idhY_DQnQ → t19opduSGtFKLoqvYoUh6}/_buildManifest.js +0 -0
  536. /package/app/.next-cli-build/static/{CZsjEfWjq_f7idhY_DQnQ → t19opduSGtFKLoqvYoUh6}/_ssgManifest.js +0 -0
@@ -1 +1 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[9260],{63172:(e,s,t)=>{Promise.resolve().then(t.bind(t,71088))},71088:(e,s,t)=>{"use strict";t.r(s),t.d(s,{default:()=>b});var r=t(95155),a=t(98500),i=t.n(a),l=t(12115),o=t(73321),c=t(35497),n=t(57250),d=t(81095);function m(e){let s=Object.entries(e).some(([e,s])=>e.startsWith("modelLock_")&&s&&new Date(s).getTime()>Date.now());return"unavailable"!==e.testStatus||s?e.testStatus:"active"}function x({provider:e,kind:s,connections:t}){let a=d.Q2[e.id],l=!!a?.noAuth,o=t.filter(s=>s.provider===e.id),h=o.filter(e=>{let s=m(e);return"active"===s||"success"===s}).length,p=o.filter(e=>{let s=m(e);return"error"===s||"expired"===s||"unavailable"===s}).length,b=o.length,u=b>0&&o.every(e=>!1===e.isActive);return(0,r.jsx)(i(),{href:`/dashboard/media-providers/${s}/${e.id}`,className:"group",children:(0,r.jsx)(c.Zp,{padding:"xs",className:`h-full hover:bg-black/[0.01] dark:hover:bg-white/[0.01] transition-colors cursor-pointer ${u?"opacity-50":""}`,children:(0,r.jsxs)("div",{className:"flex min-w-0 items-center gap-3",children:[(0,r.jsx)("div",{className:"size-8 rounded-lg flex items-center justify-center shrink-0",style:{backgroundColor:`${e.color?.length>7?e.color:(e.color??"#888")+"15"}`},children:(0,r.jsx)(n.A,{src:`/providers/${e.id}.png`,alt:e.name,size:30,className:"object-contain rounded-lg max-w-[30px] max-h-[30px]",fallbackText:e.textIcon||e.id.slice(0,2).toUpperCase(),fallbackColor:e.color})}),(0,r.jsxs)("div",{children:[(0,r.jsx)("h3",{className:"font-semibold text-sm",children:e.name}),(0,r.jsx)("div",{className:"flex items-center gap-2 mt-0.5 flex-wrap",children:l?(0,r.jsx)(c.Ex,{variant:"success",size:"sm",children:"Ready"}):u?(0,r.jsx)(c.Ex,{variant:"default",size:"sm",children:"Disabled"}):0===b?(0,r.jsx)("span",{className:"text-xs text-text-muted",children:"No connections"}):(0,r.jsxs)(r.Fragment,{children:[h>0&&(0,r.jsxs)(c.Ex,{variant:"success",size:"sm",dot:!0,children:[h," Connected"]}),p>0&&(0,r.jsxs)(c.Ex,{variant:"error",size:"sm",dot:!0,children:[p," Error"]}),0===h&&0===p&&(0,r.jsxs)(c.Ex,{variant:"default",size:"sm",children:[b," Added"]})]})})]})]})})})}function h({combos:e}){return 0===e.length?(0,r.jsx)("p",{className:"text-xs text-text-muted italic",children:"No combos yet."}):(0,r.jsx)("div",{className:"flex flex-col gap-2",children:e.map(e=>(0,r.jsx)(i(),{href:`/dashboard/media-providers/combo/${e.id}`,children:(0,r.jsx)(c.Zp,{padding:"xs",className:"hover:bg-black/[0.02] dark:hover:bg-white/[0.02] transition-colors cursor-pointer",children:(0,r.jsxs)("div",{className:"flex min-w-0 items-center gap-3",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-primary text-[18px]",children:"layers"}),(0,r.jsx)("code",{className:"text-sm font-mono font-medium flex-1 truncate",children:e.name}),(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-1 sm:shrink-0",children:[e.models.slice(0,6).map((e,s)=>{let t="string"==typeof e?e.split("/")[0]:"",a=d.Q2[t];return(0,r.jsx)("div",{title:a?.name||e,className:"size-5 rounded flex items-center justify-center",style:{backgroundColor:`${a?.color??"#888"}15`},children:(0,r.jsx)(n.A,{src:`/providers/${t}.png`,alt:a?.name||t,size:18,className:"object-contain rounded max-w-[18px] max-h-[18px]",fallbackText:a?.textIcon||t.slice(0,2).toUpperCase(),fallbackColor:a?.color})},`${e}-${s}`)}),e.models.length>6&&(0,r.jsxs)("span",{className:"text-[10px] text-text-muted ml-1",children:["+",e.models.length-6]})]}),(0,r.jsx)("span",{className:"text-[11px] text-text-muted shrink-0",children:e.models.length}),(0,r.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[16px]",children:"chevron_right"})]})})},e.id))})}function p({title:e,icon:s,kind:t,providers:a,connections:i,combos:l,onCreateCombo:o}){return(0,r.jsxs)("div",{children:[(0,r.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between mb-3",children:[(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-primary",children:s}),(0,r.jsx)("h2",{className:"text-base font-semibold",children:e}),(0,r.jsxs)("span",{className:"text-xs text-text-muted",children:["(",a.length," providers \xb7 ",l.length," combos)"]})]}),(0,r.jsx)(c.$n,{size:"sm",icon:"add",onClick:o,children:"Create Combo"})]}),l.length>0&&(0,r.jsx)("div",{className:"mb-4",children:(0,r.jsx)(h,{combos:l})}),0===a.length?(0,r.jsx)("div",{className:"text-center py-8 border border-dashed border-border rounded-xl text-text-muted text-sm",children:"No providers."}):(0,r.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4",children:a.map(e=>(0,r.jsx)(x,{provider:e,kind:t,connections:i},e.id))})]})}function b(){let e=(0,o.useRouter)(),[s,t]=(0,l.useState)([]),[a,i]=(0,l.useState)([]),c=async()=>{try{let[e,s]=await Promise.all([fetch("/api/providers",{cache:"no-store"}),fetch("/api/combos",{cache:"no-store"})]);e.ok&&t((await e.json()).connections||[]),s.ok&&i((await s.json()).combos||[])}catch{}};(0,l.useEffect)(()=>{c()},[]);let n=(0,d.o5)("webSearch"),m=(0,d.o5)("webFetch"),x=a.filter(e=>"webSearch"===e.kind),h=a.filter(e=>"webFetch"===e.kind),b=async s=>{let t="webSearch"===s?"search-combo":"fetch-combo",r=t,i=1,l=new Set(a.map(e=>e.name));for(;l.has(r);)r=`${t}-${i++}`;let o=await fetch("/api/combos",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:r,models:[],kind:s})});if(o.ok){let s=await o.json();e.push(`/dashboard/media-providers/combo/${s.id}`)}else alert((await o.json()).error||"Failed to create combo")};return(0,r.jsxs)("div",{className:"flex flex-col gap-8",children:[(0,r.jsx)(p,{title:"Web Search",icon:"search",kind:"webSearch",providers:n,connections:s,combos:x,onCreateCombo:()=>b("webSearch")}),(0,r.jsx)("div",{className:"border-t border-border"}),(0,r.jsx)(p,{title:"Web Fetch",icon:"travel_explore",kind:"webFetch",providers:m,connections:s,combos:h,onCreateCombo:()=>b("webFetch")})]})}}},e=>{e.O(0,[2574,3862,817,5280,1321,705,5497,8441,3794,7358],()=>e(e.s=63172)),_N_E=e.O()}]);
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[9260],{63172:(e,s,t)=>{Promise.resolve().then(t.bind(t,71088))},71088:(e,s,t)=>{"use strict";t.r(s),t.d(s,{default:()=>b});var r=t(95155),a=t(98500),i=t.n(a),l=t(12115),o=t(73321),c=t(35497),n=t(57250),d=t(88105);function m(e){let s=Object.entries(e).some(([e,s])=>e.startsWith("modelLock_")&&s&&new Date(s).getTime()>Date.now());return"unavailable"!==e.testStatus||s?e.testStatus:"active"}function x({provider:e,kind:s,connections:t}){let a=d.Q2[e.id],l=!!a?.noAuth,o=t.filter(s=>s.provider===e.id),h=o.filter(e=>{let s=m(e);return"active"===s||"success"===s}).length,p=o.filter(e=>{let s=m(e);return"error"===s||"expired"===s||"unavailable"===s}).length,b=o.length,u=b>0&&o.every(e=>!1===e.isActive);return(0,r.jsx)(i(),{href:`/dashboard/media-providers/${s}/${e.id}`,className:"group",children:(0,r.jsx)(c.Zp,{padding:"xs",className:`h-full hover:bg-black/[0.01] dark:hover:bg-white/[0.01] transition-colors cursor-pointer ${u?"opacity-50":""}`,children:(0,r.jsxs)("div",{className:"flex min-w-0 items-center gap-3",children:[(0,r.jsx)("div",{className:"size-8 rounded-lg flex items-center justify-center shrink-0",style:{backgroundColor:`${e.color?.length>7?e.color:(e.color??"#888")+"15"}`},children:(0,r.jsx)(n.A,{src:`/providers/${e.id}.png`,alt:e.name,size:30,className:"object-contain rounded-lg max-w-[30px] max-h-[30px]",fallbackText:e.textIcon||e.id.slice(0,2).toUpperCase(),fallbackColor:e.color})}),(0,r.jsxs)("div",{children:[(0,r.jsx)("h3",{className:"font-semibold text-sm",children:e.name}),(0,r.jsx)("div",{className:"flex items-center gap-2 mt-0.5 flex-wrap",children:l?(0,r.jsx)(c.Ex,{variant:"success",size:"sm",children:"Ready"}):u?(0,r.jsx)(c.Ex,{variant:"default",size:"sm",children:"Disabled"}):0===b?(0,r.jsx)("span",{className:"text-xs text-text-muted",children:"No connections"}):(0,r.jsxs)(r.Fragment,{children:[h>0&&(0,r.jsxs)(c.Ex,{variant:"success",size:"sm",dot:!0,children:[h," Connected"]}),p>0&&(0,r.jsxs)(c.Ex,{variant:"error",size:"sm",dot:!0,children:[p," Error"]}),0===h&&0===p&&(0,r.jsxs)(c.Ex,{variant:"default",size:"sm",children:[b," Added"]})]})})]})]})})})}function h({combos:e}){return 0===e.length?(0,r.jsx)("p",{className:"text-xs text-text-muted italic",children:"No combos yet."}):(0,r.jsx)("div",{className:"flex flex-col gap-2",children:e.map(e=>(0,r.jsx)(i(),{href:`/dashboard/media-providers/combo/${e.id}`,children:(0,r.jsx)(c.Zp,{padding:"xs",className:"hover:bg-black/[0.02] dark:hover:bg-white/[0.02] transition-colors cursor-pointer",children:(0,r.jsxs)("div",{className:"flex min-w-0 items-center gap-3",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-primary text-[18px]",children:"layers"}),(0,r.jsx)("code",{className:"text-sm font-mono font-medium flex-1 truncate",children:e.name}),(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-1 sm:shrink-0",children:[e.models.slice(0,6).map((e,s)=>{let t="string"==typeof e?e.split("/")[0]:"",a=d.Q2[t];return(0,r.jsx)("div",{title:a?.name||e,className:"size-5 rounded flex items-center justify-center",style:{backgroundColor:`${a?.color??"#888"}15`},children:(0,r.jsx)(n.A,{src:`/providers/${t}.png`,alt:a?.name||t,size:18,className:"object-contain rounded max-w-[18px] max-h-[18px]",fallbackText:a?.textIcon||t.slice(0,2).toUpperCase(),fallbackColor:a?.color})},`${e}-${s}`)}),e.models.length>6&&(0,r.jsxs)("span",{className:"text-[10px] text-text-muted ml-1",children:["+",e.models.length-6]})]}),(0,r.jsx)("span",{className:"text-[11px] text-text-muted shrink-0",children:e.models.length}),(0,r.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[16px]",children:"chevron_right"})]})})},e.id))})}function p({title:e,icon:s,kind:t,providers:a,connections:i,combos:l,onCreateCombo:o}){return(0,r.jsxs)("div",{children:[(0,r.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between mb-3",children:[(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-primary",children:s}),(0,r.jsx)("h2",{className:"text-base font-semibold",children:e}),(0,r.jsxs)("span",{className:"text-xs text-text-muted",children:["(",a.length," providers \xb7 ",l.length," combos)"]})]}),(0,r.jsx)(c.$n,{size:"sm",icon:"add",onClick:o,children:"Create Combo"})]}),l.length>0&&(0,r.jsx)("div",{className:"mb-4",children:(0,r.jsx)(h,{combos:l})}),0===a.length?(0,r.jsx)("div",{className:"text-center py-8 border border-dashed border-border rounded-xl text-text-muted text-sm",children:"No providers."}):(0,r.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4",children:a.map(e=>(0,r.jsx)(x,{provider:e,kind:t,connections:i},e.id))})]})}function b(){let e=(0,o.useRouter)(),[s,t]=(0,l.useState)([]),[a,i]=(0,l.useState)([]),c=async()=>{try{let[e,s]=await Promise.all([fetch("/api/providers",{cache:"no-store"}),fetch("/api/combos",{cache:"no-store"})]);e.ok&&t((await e.json()).connections||[]),s.ok&&i((await s.json()).combos||[])}catch{}};(0,l.useEffect)(()=>{c()},[]);let n=(0,d.o5)("webSearch"),m=(0,d.o5)("webFetch"),x=a.filter(e=>"webSearch"===e.kind),h=a.filter(e=>"webFetch"===e.kind),b=async s=>{let t="webSearch"===s?"search-combo":"fetch-combo",r=t,i=1,l=new Set(a.map(e=>e.name));for(;l.has(r);)r=`${t}-${i++}`;let o=await fetch("/api/combos",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:r,models:[],kind:s})});if(o.ok){let s=await o.json();e.push(`/dashboard/media-providers/combo/${s.id}`)}else alert((await o.json()).error||"Failed to create combo")};return(0,r.jsxs)("div",{className:"flex flex-col gap-8",children:[(0,r.jsx)(p,{title:"Web Search",icon:"search",kind:"webSearch",providers:n,connections:s,combos:x,onCreateCombo:()=>b("webSearch")}),(0,r.jsx)("div",{className:"border-t border-border"}),(0,r.jsx)(p,{title:"Web Fetch",icon:"travel_explore",kind:"webFetch",providers:m,connections:s,combos:h,onCreateCombo:()=>b("webFetch")})]})}}},e=>{e.O(0,[2574,3862,817,5280,1321,705,5497,8441,3794,7358],()=>e(e.s=63172)),_N_E=e.O()}]);
@@ -1 +1 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[6607],{23879:(e,s,t)=>{"use strict";t.d(s,{default:()=>d});var a=t(95155),i=t(12115),n=t(3534),l=t(28777),o=t(81095),r=t(43666);function d(){let[e,s]=(0,i.useState)([]),[t,d]=(0,i.useState)([]),[c,u]=(0,i.useState)({}),[h,p]=(0,i.useState)(!1),[w,f]=(0,i.useState)(null),[y,x]=(0,i.useState)({running:!1,certExists:!1,dnsStatus:{},hasCachedPassword:!1});(0,i.useEffect)(()=>{g(),v(),m(),S()},[]);let g=async()=>{try{let e=await fetch("/api/providers");if(e.ok){let t=await e.json();s(t.connections||[])}}catch{}},v=async()=>{try{let e=await fetch("/api/keys");if(e.ok){let s=await e.json();d(s.keys||[])}}catch{}},m=async()=>{try{let e=await fetch("/api/models/alias");if(e.ok){let s=await e.json();u(s.aliases||{})}}catch{}},S=async()=>{try{let e=await fetch("/api/settings");if(e.ok){let s=await e.json();p(s.cloudEnabled||!1)}}catch{}},b=()=>e.filter(e=>!1!==e.isActive),k=Object.entries(n.wn);return(0,a.jsxs)("div",{className:"flex w-full flex-col gap-6",children:[(0,a.jsxs)("div",{className:"flex items-start gap-2 px-3 py-2 rounded-lg bg-yellow-500/10 border border-yellow-500/30",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[16px] text-yellow-500 mt-0.5 shrink-0",children:"warning"}),(0,a.jsx)("p",{className:"text-xs text-red-600 dark:text-yellow-400 leading-relaxed",children:"⚠️ MITM intercepts HTTPS traffic of IDE tools (Antigravity, GitHub Copilot, Kiro) via local CA to redirect requests to your providers. May violate ToS → account ban. Use at your own risk."})]}),(0,a.jsx)(r.tA,{apiKeys:t,cloudEnabled:h,onStatusChange:x}),(0,a.jsx)("div",{className:"grid gap-3 sm:gap-4",children:k.map(([e,s])=>(0,a.jsx)(r.kn,{tool:s,isExpanded:w===e,onToggle:()=>f(w===e?null:e),serverRunning:y.running,dnsActive:y.dnsStatus?.[e]||!1,hasCachedPassword:y.hasCachedPassword||!1,needsSudoPassword:!1!==y.needsSudoPassword,isWin:!0===y.isWin,apiKeys:t,activeProviders:b(),hasActiveProviders:b().some(e=>(0,l.KC)(e.provider).length>0||(0,o.mq)(e.provider)||(0,o.gb)(e.provider)),modelAliases:c,cloudEnabled:h,onDnsChange:e=>x(s=>({...s,dnsStatus:e.dnsStatus??s.dnsStatus}))},e))})]})}},46182:(e,s,t)=>{Promise.resolve().then(t.bind(t,23879))}},e=>{e.O(0,[2574,3862,817,5280,5772,1321,705,5497,6069,8441,3794,7358],()=>e(e.s=46182)),_N_E=e.O()}]);
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[6607],{23879:(e,s,t)=>{"use strict";t.d(s,{default:()=>d});var a=t(95155),i=t(12115),n=t(3534),l=t(28777),o=t(88105),r=t(43666);function d(){let[e,s]=(0,i.useState)([]),[t,d]=(0,i.useState)([]),[c,u]=(0,i.useState)({}),[h,p]=(0,i.useState)(!1),[w,f]=(0,i.useState)(null),[y,x]=(0,i.useState)({running:!1,certExists:!1,dnsStatus:{},hasCachedPassword:!1});(0,i.useEffect)(()=>{g(),v(),m(),S()},[]);let g=async()=>{try{let e=await fetch("/api/providers");if(e.ok){let t=await e.json();s(t.connections||[])}}catch{}},v=async()=>{try{let e=await fetch("/api/keys");if(e.ok){let s=await e.json();d(s.keys||[])}}catch{}},m=async()=>{try{let e=await fetch("/api/models/alias");if(e.ok){let s=await e.json();u(s.aliases||{})}}catch{}},S=async()=>{try{let e=await fetch("/api/settings");if(e.ok){let s=await e.json();p(s.cloudEnabled||!1)}}catch{}},b=()=>e.filter(e=>!1!==e.isActive),k=Object.entries(n.wn);return(0,a.jsxs)("div",{className:"flex w-full flex-col gap-6",children:[(0,a.jsxs)("div",{className:"flex items-start gap-2 px-3 py-2 rounded-lg bg-yellow-500/10 border border-yellow-500/30",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[16px] text-yellow-500 mt-0.5 shrink-0",children:"warning"}),(0,a.jsx)("p",{className:"text-xs text-red-600 dark:text-yellow-400 leading-relaxed",children:"⚠️ MITM intercepts HTTPS traffic of IDE tools (Antigravity, GitHub Copilot, Kiro) via local CA to redirect requests to your providers. May violate ToS → account ban. Use at your own risk."})]}),(0,a.jsx)(r.tA,{apiKeys:t,cloudEnabled:h,onStatusChange:x}),(0,a.jsx)("div",{className:"grid gap-3 sm:gap-4",children:k.map(([e,s])=>(0,a.jsx)(r.kn,{tool:s,isExpanded:w===e,onToggle:()=>f(w===e?null:e),serverRunning:y.running,dnsActive:y.dnsStatus?.[e]||!1,hasCachedPassword:y.hasCachedPassword||!1,needsSudoPassword:!1!==y.needsSudoPassword,isWin:!0===y.isWin,apiKeys:t,activeProviders:b(),hasActiveProviders:b().some(e=>(0,l.KC)(e.provider).length>0||(0,o.mq)(e.provider)||(0,o.gb)(e.provider)),modelAliases:c,cloudEnabled:h,onDnsChange:e=>x(s=>({...s,dnsStatus:e.dnsStatus??s.dnsStatus}))},e))})]})}},46182:(e,s,t)=>{Promise.resolve().then(t.bind(t,23879))}},e=>{e.O(0,[2574,3862,817,5280,5772,1321,705,5497,6069,8441,3794,7358],()=>e(e.s=46182)),_N_E=e.O()}]);
@@ -1,4 +1,4 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[2134],{67944:(e,t,s)=>{Promise.resolve().then(s.bind(s,86930))},70217:(e,t,s)=>{"use strict";function a(e,t){return!1===e?"default":"active"===t||"success"===t?"success":"error"===t||"expired"===t||"unavailable"===t?"error":"default"}s.d(t,{g:()=>a})},86930:(e,t,s)=>{"use strict";s.r(t),s.d(t,{default:()=>R});var a=s(95155),i=s(12115),l=s(73321),o=s(98500),r=s.n(o),n=s(5772),d=s(35497),c=s(81095),p=s(28777),m=s(11059),x=s(53593),u=s(73006);let h=new Map;async function f(e){if(!e?.url||!e?.type)return[];let t=h.get(e.url);if(t&&Date.now()<t.expiresAt)return t.data;try{let t=new URLSearchParams({url:e.url,type:e.type}),s=await fetch(`/api/providers/suggested-models?${t}`);if(!s.ok)return[];let a=(await s.json()).data??[];return h.set(e.url,{data:a,expiresAt:Date.now()+6e5}),a}catch{return[]}}function y({customModels:e=[],modelAliases:t={},providerAlias:s,builtInModels:a=[],type:i="llm",includeLegacyAliases:l=!0}){let o=new Set(a.map(e=>e.id)),r=new Set,n=[];for(let t of e){if(!t?.id||t.providerAlias!==s)continue;let e=t?.kind||t?.type||"llm";if(i&&e!==i||o.has(t.id))continue;let a=`${s}/${t.id}`;r.has(a)||(r.add(a),n.push({id:t.id,name:t.name||t.id,fullModel:a,source:"custom",type:e}))}if(!l)return n;let d=`${s}/`;for(let[e,s]of Object.entries(t||{})){if("string"!=typeof s||!s.startsWith(d))continue;let t=s.slice(d.length);!t||o.has(t)||r.has(s)||(r.add(s),n.push({id:t,alias:e,fullModel:s,source:"legacyAlias",type:i||"llm"}))}return n}var g=s(14051),b=s.n(g);function v({model:e,fullModel:t,alias:s,copied:i,onCopy:l,testStatus:o,isCustom:r,isFree:n,onDeleteAlias:c,onTest:p,isTesting:m,onDisable:x,caps:u}){let h="ok"===o?"#22c55e":"error"===o?"#ef4444":void 0;return(0,a.jsx)("div",{className:`group min-w-0 max-w-full rounded-lg border px-3 py-2 ${"ok"===o?"border-green-500/40":"error"===o?"border-red-500/40":"border-border"} hover:bg-sidebar/50`,children:(0,a.jsxs)("div",{className:"flex min-w-0 items-start gap-2 sm:items-center",children:[(0,a.jsx)("span",{className:"material-symbols-outlined shrink-0 text-base",style:h?{color:h}:void 0,children:"ok"===o?"check_circle":"error"===o?"cancel":"smart_toy"}),(0,a.jsxs)("div",{className:"flex min-w-0 flex-1 flex-col gap-1",children:[(0,a.jsx)("code",{className:"max-w-[72vw] truncate rounded bg-sidebar px-1.5 py-0.5 font-mono text-xs text-text-muted sm:max-w-[360px]",children:t}),(0,a.jsxs)("span",{className:"flex min-w-0 items-center text-[9px] gap-1 pl-1",children:[e.name&&(0,a.jsx)("span",{className:"truncate text-[9px] italic text-text-muted/70",children:e.name}),(0,a.jsx)(d.nh,{caps:u,colorOverride:"text-text-muted/70",size:12})]})]}),p&&(0,a.jsxs)("div",{className:"relative shrink-0 group/btn",children:[(0,a.jsx)("button",{onClick:p,disabled:m,className:`rounded p-0.5 text-text-muted transition-opacity hover:bg-sidebar hover:text-primary ${m?"opacity-100":"opacity-100 sm:opacity-0 sm:group-hover:opacity-100"}`,children:(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",style:m?{animation:"spin 1s linear infinite"}:void 0,children:m?"progress_activity":"science"})}),(0,a.jsx)("span",{className:"pointer-events-none absolute mt-1 top-5 left-1/2 -translate-x-1/2 text-[10px] text-text-muted whitespace-nowrap opacity-0 group-hover/btn:opacity-100 transition-opacity",children:m?"Testing...":"Test"})]}),(0,a.jsxs)("div",{className:"relative shrink-0 group/btn",children:[(0,a.jsx)("button",{onClick:()=>l(t,`model-${e.id}`),className:"rounded p-0.5 text-text-muted hover:bg-sidebar hover:text-primary",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:i===`model-${e.id}`?"check":"content_copy"})}),(0,a.jsx)("span",{className:"pointer-events-none absolute mt-1 top-5 left-1/2 -translate-x-1/2 text-[10px] text-text-muted whitespace-nowrap opacity-0 group-hover/btn:opacity-100 transition-opacity",children:i===`model-${e.id}`?"Copied!":"Copy"})]}),r?(0,a.jsx)("button",{onClick:c,className:"ml-auto rounded p-0.5 text-text-muted opacity-100 transition-opacity hover:bg-red-500/10 hover:text-red-500 sm:opacity-0 sm:group-hover:opacity-100",title:"Remove custom model",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:"close"})}):x?(0,a.jsx)("button",{onClick:x,className:"ml-auto rounded p-0.5 text-text-muted opacity-100 transition-opacity hover:bg-red-500/10 hover:text-red-500 sm:opacity-0 sm:group-hover:opacity-100",title:"Disable this model",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:"close"})}):null]})})}function j({modelId:e,fullModel:t,copied:s,onCopy:i,onDeleteAlias:l,onTest:o,testStatus:r,isTesting:n}){let d="ok"===r?"#22c55e":"error"===r?"#ef4444":void 0;return(0,a.jsxs)("div",{className:`flex items-center gap-3 p-3 rounded-lg border ${"ok"===r?"border-green-500/40":"error"===r?"border-red-500/40":"border-border"} hover:bg-sidebar/50`,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-base text-text-muted",style:d?{color:d}:void 0,children:"ok"===r?"check_circle":"error"===r?"cancel":"smart_toy"}),(0,a.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,a.jsx)("p",{className:"text-sm font-medium truncate",children:e}),(0,a.jsxs)("div",{className:"flex items-center gap-1 mt-1",children:[(0,a.jsx)("code",{className:"text-xs text-text-muted font-mono bg-sidebar px-1.5 py-0.5 rounded",children:t}),(0,a.jsxs)("div",{className:"relative group/btn",children:[(0,a.jsx)("button",{onClick:()=>i(t,`model-${e}`),className:"p-0.5 hover:bg-sidebar rounded text-text-muted hover:text-primary",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:s===`model-${e}`?"check":"content_copy"})}),(0,a.jsx)("span",{className:"pointer-events-none absolute top-5 left-1/2 -translate-x-1/2 text-[10px] text-text-muted whitespace-nowrap opacity-0 group-hover/btn:opacity-100 transition-opacity",children:s===`model-${e}`?"Copied!":"Copy"})]}),o&&(0,a.jsxs)("div",{className:"relative group/btn",children:[(0,a.jsx)("button",{onClick:o,disabled:n,className:"p-0.5 hover:bg-sidebar rounded text-text-muted hover:text-primary transition-colors",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",style:n?{animation:"spin 1s linear infinite"}:void 0,children:n?"progress_activity":"science"})}),(0,a.jsx)("span",{className:"pointer-events-none absolute top-5 left-1/2 -translate-x-1/2 text-[10px] text-text-muted whitespace-nowrap opacity-0 group-hover/btn:opacity-100 transition-opacity",children:n?"Testing...":"Test"})]})]})]}),(0,a.jsx)("button",{onClick:l,className:"p-1 hover:bg-red-50 rounded text-red-500",title:"Remove model",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:"delete"})})]})}function k({providerStorageAlias:e,providerDisplayAlias:t,modelAliases:s,customModels:l,copied:o,onCopy:r,onDeleteAlias:n,onAddCustomModel:c,onDeleteCustomModel:p,connections:m,isAnthropic:x}){let[u,h]=(0,i.useState)(""),[f,g]=(0,i.useState)(!1),[b,v]=(0,i.useState)(!1),[w,N]=(0,i.useState)(null),[C,S]=(0,i.useState)({}),$=async t=>{if(!w){N(t);try{let s=await fetch("/api/models/test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:`${e}/${t}`})}),a=await s.json();S(e=>({...e,[t]:a.ok?"ok":"error"}))}catch{S(e=>({...e,[t]:"error"}))}finally{N(null)}}},A=y({customModels:l,modelAliases:s,providerAlias:e,type:"llm"}),T=async()=>{if(!u.trim()||f)return;let e=u.trim();if(A.some(t=>t.id===e))return void alert("Model already exists for this provider.");g(!0);try{await c(e),h("")}catch(e){console.log("Error adding model:",e)}finally{g(!1)}},P=async()=>{if(b)return;let e=m.find(e=>!1!==e.isActive);if(e){v(!0);try{let t=await fetch(`/api/providers/${e.id}/models`),s=await t.json();if(!t.ok)return void alert(s.error||"Failed to import models");let a=s.models||[];if(0===a.length)return void alert("No models returned from /models.");let i=0;for(let e of a){let t=e.id||e.name||e.model;t&&(A.some(e=>e.id===t)||(await c(t),i+=1))}0===i&&alert("No new models were added.")}catch(e){console.log("Error importing models:",e)}finally{v(!1)}}},O=m.some(e=>!1!==e.isActive);return(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,a.jsxs)("p",{className:"text-sm text-text-muted",children:["Add ",x?"Anthropic":"OpenAI","-compatible models manually or import them from the /models endpoint."]}),(0,a.jsxs)("div",{className:"flex items-end gap-2 flex-wrap",children:[(0,a.jsxs)("div",{className:"flex-1 min-w-[240px]",children:[(0,a.jsx)("label",{htmlFor:"new-compatible-model-input",className:"text-xs text-text-muted mb-1 block",children:"Model ID"}),(0,a.jsx)("input",{id:"new-compatible-model-input",type:"text",value:u,onChange:e=>h(e.target.value),onKeyDown:e=>"Enter"===e.key&&T(),placeholder:x?"claude-3-opus-20240229":"gpt-4o",className:"w-full px-3 py-2 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary"})]}),(0,a.jsx)(d.$n,{size:"sm",icon:"add",onClick:T,disabled:!u.trim()||f,children:f?"Adding...":"Add"}),(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",icon:"download",onClick:P,disabled:!O||b,children:b?"Importing...":"Import from /models"})]}),!O&&(0,a.jsx)("p",{className:"text-xs text-text-muted",children:"Add a connection to enable importing models."}),A.length>0&&(0,a.jsx)("div",{className:"flex flex-col gap-3",children:A.map(({id:s,alias:i,source:l})=>(0,a.jsx)(j,{modelId:s,fullModel:`${t}/${s}`,copied:o,onCopy:r,onDeleteAlias:()=>"custom"===l?p(s):n(i),onTest:m.length>0?()=>$(s):void 0,testStatus:C[s],isTesting:w===s},`${l}-${e}/${s}`))})]})}v.propTypes={model:b().shape({id:b().string.isRequired}).isRequired,fullModel:b().string.isRequired,alias:b().string,copied:b().string,onCopy:b().func.isRequired,testStatus:b().oneOf(["ok","error"]),isCustom:b().bool,isFree:b().bool,onDeleteAlias:b().func,onTest:b().func,isTesting:b().bool,onDisable:b().func,caps:b().object},b().string.isRequired,b().string.isRequired,b().string,b().func.isRequired,b().func.isRequired,b().func,b().oneOf(["ok","error"]),b().bool,b().string.isRequired,b().object.isRequired,b().arrayOf(b().object),b().string,b().func.isRequired,b().func.isRequired,b().func.isRequired,b().func.isRequired,k.propTypes={providerStorageAlias:b().string.isRequired,providerDisplayAlias:b().string.isRequired,modelAliases:b().object.isRequired,customModels:b().arrayOf(b().object),copied:b().string,onCopy:b().func.isRequired,onDeleteAlias:b().func.isRequired,onAddCustomModel:b().func.isRequired,onDeleteCustomModel:b().func.isRequired,connections:b().arrayOf(b().shape({id:b().string,isActive:b().bool})).isRequired,isAnthropic:b().bool};var w=s(70217);function N({until:e}){let[t,s]=(0,i.useState)("");return((0,i.useEffect)(()=>{let t=()=>{let t=new Date(e).getTime()-Date.now();if(t<=0)return void s("");let a=Math.floor(t/1e3);if(a<60)s(`${a}s`);else if(a<3600)s(`${Math.floor(a/60)}m ${a%60}s`);else{let e=Math.floor(a/3600),t=Math.floor(a%3600/60);s(`${e}h ${t}m`)}};t();let a=setInterval(t,1e3);return()=>clearInterval(a)},[e]),t)?(0,a.jsxs)("span",{className:"text-xs text-orange-500 font-mono",children:["⏱ ",t]}):null}function C({connection:e,proxyPools:t,isOAuth:s,isFirst:l,isLast:o,onMoveUp:r,onMoveDown:n,onToggleActive:c,onUpdateProxy:p,onEdit:m,onDelete:x,onPushToPool:u,oneByOneStatus:h=null,autoPing:f=null}){let[y,g]=(0,i.useState)(!1),[b,v]=(0,i.useState)(!1),j=(0,i.useRef)(null),k=new Map((t||[]).map(e=>[e.id,e])),S=e.providerSpecificData?.proxyPoolId||null,$=S?k.get(S):null,A=e.providerSpecificData?.connectionProxyEnabled===!0&&!!e.providerSpecificData?.connectionProxyUrl,T=!!S||A,P=$?`Pool: ${$.name}`:S?`Pool: ${S} (inactive/missing)`:A?`Legacy: ${e.providerSpecificData?.connectionProxyUrl}`:"",O=f?.provider==="codex"?"Auto-starts the next 5h Codex window after reset by sending a tiny gpt-5.5 request. Consumes a small amount of quota.":"When your 5h quota runs out, auto-sends a request the moment it resets so a new window starts right away.",E="";if($?.proxyUrl||e.providerSpecificData?.connectionProxyUrl){let t=$?.proxyUrl||e.providerSpecificData?.connectionProxyUrl;try{let e=new URL(t);E=`${e.protocol}//${e.hostname}${e.port?`:${e.port}`:""}`}catch{E=t}}let I=$?.noProxy||e.providerSpecificData?.connectionNoProxy||"",D="default";$?.isActive===!0?D="success":(S||A)&&(D="error"),(0,i.useEffect)(()=>{if(!y)return;let e=e=>{j.current&&!j.current.contains(e.target)&&g(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[y]);let R=async e=>{v(!0);try{await p("__none__"===e?null:e)}finally{v(!1),g(!1)}},U=e.authType||(s?"oauth":"apikey"),z="oauth"===U,_="cookie"===U,q=e.name?.trim()||e.email?.trim()||e.displayName?.trim()||(z?"OAuth Account":_?"Cookie Account":"API Key"),M=e.name?.trim()&&e.email?.trim()&&e.name.trim()!==e.email.trim()?e.email.trim():e.name?.trim()&&e.displayName?.trim()&&e.name.trim()!==e.displayName.trim()?e.displayName.trim():null,[F,K]=(0,i.useState)(!1),J=Object.entries(e).filter(([e])=>e.startsWith("modelLock_")).map(([,e])=>e).filter(e=>!!e).sort()[0]||null;(0,i.useEffect)(()=>{let t=()=>{K(!!Object.entries(e).filter(([e])=>e.startsWith("modelLock_")).map(([,e])=>e).filter(e=>e&&new Date(e).getTime()>Date.now()).sort()[0])};t();let s=J?setInterval(t,1e3):null;return()=>{s&&clearInterval(s)}},[J]);let L="unavailable"!==e.testStatus||F?e.testStatus:"active",B=()=>h?"queued"===h.state?"queued":"testing"===h.state?"testing":"success"===h.state?"success":"failed"===h.state?h.error?`failed: ${h.error}`:"failed":null:null;return(0,a.jsxs)("div",{className:`group flex min-w-0 flex-col gap-3 rounded-lg p-2 transition-colors hover:bg-black/[0.02] dark:hover:bg-white/[0.02] sm:flex-row sm:items-center sm:justify-between ${!1===e.isActive?"opacity-60":""}`,children:[(0,a.jsxs)("div",{className:"flex min-w-0 flex-1 items-start gap-2 sm:items-center sm:gap-3",children:[(0,a.jsxs)("div",{className:"flex shrink-0 flex-col",children:[(0,a.jsx)("button",{onClick:r,disabled:l,className:`p-0.5 rounded ${l?"text-text-muted/30 cursor-not-allowed":"hover:bg-sidebar text-text-muted hover:text-primary"}`,children:(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:"keyboard_arrow_up"})}),(0,a.jsx)("button",{onClick:n,disabled:o,className:`p-0.5 rounded ${o?"text-text-muted/30 cursor-not-allowed":"hover:bg-sidebar text-text-muted hover:text-primary"}`,children:(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:"keyboard_arrow_down"})})]}),(0,a.jsx)("span",{className:"material-symbols-outlined shrink-0 text-base text-text-muted",children:_?"cookie":z?"lock":"key"}),(0,a.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,a.jsx)("p",{className:"text-sm font-medium truncate",children:q}),M&&(0,a.jsx)("p",{className:"text-xs text-text-muted truncate",children:M}),(0,a.jsxs)("div",{className:"mt-1 flex min-w-0 flex-wrap items-center gap-1.5 sm:gap-2",children:[(0,a.jsx)(d.Ex,{variant:(0,w.g)(e.isActive,L),size:"sm",dot:!0,children:!1===e.isActive?"disabled":L||"Unknown"}),(0,a.jsx)(d.Ex,{variant:"default",size:"sm",children:z?"OAuth":_?"Cookie":"API Key"}),T&&(0,a.jsx)(d.Ex,{variant:D,size:"sm",children:"Proxy"}),F&&!1!==e.isActive&&(0,a.jsx)(N,{until:J}),e.lastError&&!1!==e.isActive&&(0,a.jsx)("span",{className:"max-w-full truncate text-xs text-red-500 sm:max-w-[300px]",title:e.lastError,children:e.lastError}),(0,a.jsxs)("span",{className:"text-xs text-text-muted",children:["#",e.priority]}),e.globalPriority&&(0,a.jsxs)("span",{className:"text-xs text-text-muted",children:["Auto: ",e.globalPriority]}),B()&&(0,a.jsx)(d.Ex,{variant:h?"success"===h.state?"success":"failed"===h.state?"error":"testing"===h.state?"primary":"default":"default",size:"sm",children:B()})]}),T&&(0,a.jsxs)("div",{className:"mt-1 flex items-center gap-2 flex-wrap",children:[(0,a.jsx)("span",{className:"max-w-full truncate text-[11px] text-text-muted sm:max-w-[420px]",title:P,children:P}),E&&(0,a.jsx)("code",{className:"max-w-full truncate rounded bg-black/5 px-1 py-0.5 font-mono text-[10px] text-text-muted dark:bg-white/5 sm:max-w-[260px]",children:E}),I&&(0,a.jsxs)("span",{className:"max-w-full truncate text-[11px] text-text-muted sm:max-w-[320px]",title:I,children:["no_proxy: ",I]})]})]})]}),(0,a.jsxs)("div",{className:"flex w-full items-center justify-between gap-2 sm:w-auto sm:justify-end",children:[(0,a.jsxs)("div",{className:"grid flex-1 grid-cols-3 gap-1 sm:flex sm:flex-none",children:[(t||[]).length>0&&(0,a.jsxs)("div",{className:"relative",ref:j,children:[(0,a.jsxs)("button",{onClick:()=>g(e=>!e),className:`flex w-full flex-col items-center rounded px-2 py-1 transition-colors hover:bg-black/5 dark:hover:bg-white/5 ${T?"text-primary":"text-text-muted hover:text-primary"}`,disabled:b,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:b?"progress_activity":"lan"}),(0,a.jsx)("span",{className:"text-[10px] leading-tight",children:"Proxy"})]}),y&&(0,a.jsxs)("div",{className:"absolute right-0 top-full z-50 mt-1 max-w-[78vw] min-w-[160px] rounded-lg border border-border bg-bg py-1 shadow-lg",children:[(0,a.jsx)("button",{onClick:()=>R("__none__"),className:`w-full text-left px-3 py-1.5 text-sm hover:bg-black/5 dark:hover:bg-white/5 ${!S?"text-primary font-medium":"text-text-main"}`,children:"None"}),(t||[]).map(e=>(0,a.jsx)("button",{onClick:()=>R(e.id),className:`w-full text-left px-3 py-1.5 text-sm hover:bg-black/5 dark:hover:bg-white/5 ${S===e.id?"text-primary font-medium":"text-text-main"}`,children:e.name},e.id))]})]}),f&&(0,a.jsx)(d.m_,{text:O,children:(0,a.jsxs)("button",{onClick:()=>f.onToggle(!f.on),className:`flex w-full flex-col items-center rounded px-2 py-1 transition-colors hover:bg-black/5 dark:hover:bg-white/5 ${f.on?"text-primary":"text-text-muted hover:text-primary"}`,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"bolt"}),(0,a.jsx)("span",{className:"text-[10px] leading-tight",children:"Auto-ping"})]})}),(0,a.jsxs)("button",{onClick:m,className:"flex flex-col items-center rounded px-2 py-1 text-text-muted hover:bg-black/5 hover:text-primary dark:hover:bg-white/5",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"edit"}),(0,a.jsx)("span",{className:"text-[10px] leading-tight",children:"Edit"})]}),"apikey"===U&&u&&(0,a.jsxs)("button",{onClick:u,className:"flex flex-col items-center rounded px-2 py-1 text-text-muted hover:bg-black/5 hover:text-primary dark:hover:bg-white/5",title:"Move API key back into key pool reserve",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"upload"}),(0,a.jsx)("span",{className:"text-[10px] leading-tight",children:"To pool"})]}),(0,a.jsxs)("button",{onClick:x,className:"flex flex-col items-center rounded px-2 py-1 text-red-500 hover:bg-red-500/10",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"delete"}),(0,a.jsx)("span",{className:"text-[10px] leading-tight",children:"Delete"})]})]}),(0,a.jsx)(d.lM,{size:"sm",checked:e.isActive??!0,onChange:c,title:e.isActive??!0?"Disable connection":"Enable connection"})]})]})}N.propTypes={until:b().string.isRequired},C.propTypes={connection:b().shape({id:b().string,name:b().string,email:b().string,displayName:b().string,modelLockUntil:b().string,testStatus:b().string,isActive:b().bool,lastError:b().string,priority:b().number,globalPriority:b().number}).isRequired,proxyPools:b().arrayOf(b().shape({id:b().string,name:b().string,proxyUrl:b().string,noProxy:b().string,isActive:b().bool})),isOAuth:b().bool.isRequired,isFirst:b().bool.isRequired,isLast:b().bool.isRequired,onMoveUp:b().func.isRequired,onMoveDown:b().func.isRequired,onToggleActive:b().func.isRequired,onUpdateProxy:b().func,onEdit:b().func.isRequired,onDelete:b().func.isRequired,onPushToPool:b().func,oneByOneStatus:b().shape({state:b().string,error:b().string}),autoPing:b().shape({on:b().bool,onToggle:b().func,provider:b().string})};let S=`name1|sk-key1
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[2134],{67944:(e,t,s)=>{Promise.resolve().then(s.bind(s,86930))},70217:(e,t,s)=>{"use strict";function a(e,t){return!1===e?"default":"active"===t||"success"===t?"success":"error"===t||"expired"===t||"unavailable"===t?"error":"default"}s.d(t,{g:()=>a})},86930:(e,t,s)=>{"use strict";s.r(t),s.d(t,{default:()=>R});var a=s(95155),i=s(12115),l=s(73321),o=s(98500),r=s.n(o),n=s(5772),d=s(35497),c=s(88105),p=s(28777),m=s(11059),x=s(53593),u=s(73006);let h=new Map;async function f(e){if(!e?.url||!e?.type)return[];let t=h.get(e.url);if(t&&Date.now()<t.expiresAt)return t.data;try{let t=new URLSearchParams({url:e.url,type:e.type}),s=await fetch(`/api/providers/suggested-models?${t}`);if(!s.ok)return[];let a=(await s.json()).data??[];return h.set(e.url,{data:a,expiresAt:Date.now()+6e5}),a}catch{return[]}}function y({customModels:e=[],modelAliases:t={},providerAlias:s,builtInModels:a=[],type:i="llm",includeLegacyAliases:l=!0}){let o=new Set(a.map(e=>e.id)),r=new Set,n=[];for(let t of e){if(!t?.id||t.providerAlias!==s)continue;let e=t?.kind||t?.type||"llm";if(i&&e!==i||o.has(t.id))continue;let a=`${s}/${t.id}`;r.has(a)||(r.add(a),n.push({id:t.id,name:t.name||t.id,fullModel:a,source:"custom",type:e}))}if(!l)return n;let d=`${s}/`;for(let[e,s]of Object.entries(t||{})){if("string"!=typeof s||!s.startsWith(d))continue;let t=s.slice(d.length);!t||o.has(t)||r.has(s)||(r.add(s),n.push({id:t,alias:e,fullModel:s,source:"legacyAlias",type:i||"llm"}))}return n}var g=s(14051),b=s.n(g);function v({model:e,fullModel:t,alias:s,copied:i,onCopy:l,testStatus:o,isCustom:r,isFree:n,onDeleteAlias:c,onTest:p,isTesting:m,onDisable:x,caps:u}){let h="ok"===o?"#22c55e":"error"===o?"#ef4444":void 0;return(0,a.jsx)("div",{className:`group min-w-0 max-w-full rounded-lg border px-3 py-2 ${"ok"===o?"border-green-500/40":"error"===o?"border-red-500/40":"border-border"} hover:bg-sidebar/50`,children:(0,a.jsxs)("div",{className:"flex min-w-0 items-start gap-2 sm:items-center",children:[(0,a.jsx)("span",{className:"material-symbols-outlined shrink-0 text-base",style:h?{color:h}:void 0,children:"ok"===o?"check_circle":"error"===o?"cancel":"smart_toy"}),(0,a.jsxs)("div",{className:"flex min-w-0 flex-1 flex-col gap-1",children:[(0,a.jsx)("code",{className:"max-w-[72vw] truncate rounded bg-sidebar px-1.5 py-0.5 font-mono text-xs text-text-muted sm:max-w-[360px]",children:t}),(0,a.jsxs)("span",{className:"flex min-w-0 items-center text-[9px] gap-1 pl-1",children:[e.name&&(0,a.jsx)("span",{className:"truncate text-[9px] italic text-text-muted/70",children:e.name}),(0,a.jsx)(d.nh,{caps:u,colorOverride:"text-text-muted/70",size:12})]})]}),p&&(0,a.jsxs)("div",{className:"relative shrink-0 group/btn",children:[(0,a.jsx)("button",{onClick:p,disabled:m,className:`rounded p-0.5 text-text-muted transition-opacity hover:bg-sidebar hover:text-primary ${m?"opacity-100":"opacity-100 sm:opacity-0 sm:group-hover:opacity-100"}`,children:(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",style:m?{animation:"spin 1s linear infinite"}:void 0,children:m?"progress_activity":"science"})}),(0,a.jsx)("span",{className:"pointer-events-none absolute mt-1 top-5 left-1/2 -translate-x-1/2 text-[10px] text-text-muted whitespace-nowrap opacity-0 group-hover/btn:opacity-100 transition-opacity",children:m?"Testing...":"Test"})]}),(0,a.jsxs)("div",{className:"relative shrink-0 group/btn",children:[(0,a.jsx)("button",{onClick:()=>l(t,`model-${e.id}`),className:"rounded p-0.5 text-text-muted hover:bg-sidebar hover:text-primary",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:i===`model-${e.id}`?"check":"content_copy"})}),(0,a.jsx)("span",{className:"pointer-events-none absolute mt-1 top-5 left-1/2 -translate-x-1/2 text-[10px] text-text-muted whitespace-nowrap opacity-0 group-hover/btn:opacity-100 transition-opacity",children:i===`model-${e.id}`?"Copied!":"Copy"})]}),r?(0,a.jsx)("button",{onClick:c,className:"ml-auto rounded p-0.5 text-text-muted opacity-100 transition-opacity hover:bg-red-500/10 hover:text-red-500 sm:opacity-0 sm:group-hover:opacity-100",title:"Remove custom model",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:"close"})}):x?(0,a.jsx)("button",{onClick:x,className:"ml-auto rounded p-0.5 text-text-muted opacity-100 transition-opacity hover:bg-red-500/10 hover:text-red-500 sm:opacity-0 sm:group-hover:opacity-100",title:"Disable this model",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:"close"})}):null]})})}function j({modelId:e,fullModel:t,copied:s,onCopy:i,onDeleteAlias:l,onTest:o,testStatus:r,isTesting:n}){let d="ok"===r?"#22c55e":"error"===r?"#ef4444":void 0;return(0,a.jsxs)("div",{className:`flex items-center gap-3 p-3 rounded-lg border ${"ok"===r?"border-green-500/40":"error"===r?"border-red-500/40":"border-border"} hover:bg-sidebar/50`,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-base text-text-muted",style:d?{color:d}:void 0,children:"ok"===r?"check_circle":"error"===r?"cancel":"smart_toy"}),(0,a.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,a.jsx)("p",{className:"text-sm font-medium truncate",children:e}),(0,a.jsxs)("div",{className:"flex items-center gap-1 mt-1",children:[(0,a.jsx)("code",{className:"text-xs text-text-muted font-mono bg-sidebar px-1.5 py-0.5 rounded",children:t}),(0,a.jsxs)("div",{className:"relative group/btn",children:[(0,a.jsx)("button",{onClick:()=>i(t,`model-${e}`),className:"p-0.5 hover:bg-sidebar rounded text-text-muted hover:text-primary",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:s===`model-${e}`?"check":"content_copy"})}),(0,a.jsx)("span",{className:"pointer-events-none absolute top-5 left-1/2 -translate-x-1/2 text-[10px] text-text-muted whitespace-nowrap opacity-0 group-hover/btn:opacity-100 transition-opacity",children:s===`model-${e}`?"Copied!":"Copy"})]}),o&&(0,a.jsxs)("div",{className:"relative group/btn",children:[(0,a.jsx)("button",{onClick:o,disabled:n,className:"p-0.5 hover:bg-sidebar rounded text-text-muted hover:text-primary transition-colors",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",style:n?{animation:"spin 1s linear infinite"}:void 0,children:n?"progress_activity":"science"})}),(0,a.jsx)("span",{className:"pointer-events-none absolute top-5 left-1/2 -translate-x-1/2 text-[10px] text-text-muted whitespace-nowrap opacity-0 group-hover/btn:opacity-100 transition-opacity",children:n?"Testing...":"Test"})]})]})]}),(0,a.jsx)("button",{onClick:l,className:"p-1 hover:bg-red-50 rounded text-red-500",title:"Remove model",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:"delete"})})]})}function k({providerStorageAlias:e,providerDisplayAlias:t,modelAliases:s,customModels:l,copied:o,onCopy:r,onDeleteAlias:n,onAddCustomModel:c,onDeleteCustomModel:p,connections:m,isAnthropic:x}){let[u,h]=(0,i.useState)(""),[f,g]=(0,i.useState)(!1),[b,v]=(0,i.useState)(!1),[w,N]=(0,i.useState)(null),[C,S]=(0,i.useState)({}),$=async t=>{if(!w){N(t);try{let s=await fetch("/api/models/test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:`${e}/${t}`})}),a=await s.json();S(e=>({...e,[t]:a.ok?"ok":"error"}))}catch{S(e=>({...e,[t]:"error"}))}finally{N(null)}}},A=y({customModels:l,modelAliases:s,providerAlias:e,type:"llm"}),T=async()=>{if(!u.trim()||f)return;let e=u.trim();if(A.some(t=>t.id===e))return void alert("Model already exists for this provider.");g(!0);try{await c(e),h("")}catch(e){console.log("Error adding model:",e)}finally{g(!1)}},P=async()=>{if(b)return;let e=m.find(e=>!1!==e.isActive);if(e){v(!0);try{let t=await fetch(`/api/providers/${e.id}/models`),s=await t.json();if(!t.ok)return void alert(s.error||"Failed to import models");let a=s.models||[];if(0===a.length)return void alert("No models returned from /models.");let i=0;for(let e of a){let t=e.id||e.name||e.model;t&&(A.some(e=>e.id===t)||(await c(t),i+=1))}0===i&&alert("No new models were added.")}catch(e){console.log("Error importing models:",e)}finally{v(!1)}}},O=m.some(e=>!1!==e.isActive);return(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,a.jsxs)("p",{className:"text-sm text-text-muted",children:["Add ",x?"Anthropic":"OpenAI","-compatible models manually or import them from the /models endpoint."]}),(0,a.jsxs)("div",{className:"flex items-end gap-2 flex-wrap",children:[(0,a.jsxs)("div",{className:"flex-1 min-w-[240px]",children:[(0,a.jsx)("label",{htmlFor:"new-compatible-model-input",className:"text-xs text-text-muted mb-1 block",children:"Model ID"}),(0,a.jsx)("input",{id:"new-compatible-model-input",type:"text",value:u,onChange:e=>h(e.target.value),onKeyDown:e=>"Enter"===e.key&&T(),placeholder:x?"claude-3-opus-20240229":"gpt-4o",className:"w-full px-3 py-2 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary"})]}),(0,a.jsx)(d.$n,{size:"sm",icon:"add",onClick:T,disabled:!u.trim()||f,children:f?"Adding...":"Add"}),(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",icon:"download",onClick:P,disabled:!O||b,children:b?"Importing...":"Import from /models"})]}),!O&&(0,a.jsx)("p",{className:"text-xs text-text-muted",children:"Add a connection to enable importing models."}),A.length>0&&(0,a.jsx)("div",{className:"flex flex-col gap-3",children:A.map(({id:s,alias:i,source:l})=>(0,a.jsx)(j,{modelId:s,fullModel:`${t}/${s}`,copied:o,onCopy:r,onDeleteAlias:()=>"custom"===l?p(s):n(i),onTest:m.length>0?()=>$(s):void 0,testStatus:C[s],isTesting:w===s},`${l}-${e}/${s}`))})]})}v.propTypes={model:b().shape({id:b().string.isRequired}).isRequired,fullModel:b().string.isRequired,alias:b().string,copied:b().string,onCopy:b().func.isRequired,testStatus:b().oneOf(["ok","error"]),isCustom:b().bool,isFree:b().bool,onDeleteAlias:b().func,onTest:b().func,isTesting:b().bool,onDisable:b().func,caps:b().object},b().string.isRequired,b().string.isRequired,b().string,b().func.isRequired,b().func.isRequired,b().func,b().oneOf(["ok","error"]),b().bool,b().string.isRequired,b().object.isRequired,b().arrayOf(b().object),b().string,b().func.isRequired,b().func.isRequired,b().func.isRequired,b().func.isRequired,k.propTypes={providerStorageAlias:b().string.isRequired,providerDisplayAlias:b().string.isRequired,modelAliases:b().object.isRequired,customModels:b().arrayOf(b().object),copied:b().string,onCopy:b().func.isRequired,onDeleteAlias:b().func.isRequired,onAddCustomModel:b().func.isRequired,onDeleteCustomModel:b().func.isRequired,connections:b().arrayOf(b().shape({id:b().string,isActive:b().bool})).isRequired,isAnthropic:b().bool};var w=s(70217);function N({until:e}){let[t,s]=(0,i.useState)("");return((0,i.useEffect)(()=>{let t=()=>{let t=new Date(e).getTime()-Date.now();if(t<=0)return void s("");let a=Math.floor(t/1e3);if(a<60)s(`${a}s`);else if(a<3600)s(`${Math.floor(a/60)}m ${a%60}s`);else{let e=Math.floor(a/3600),t=Math.floor(a%3600/60);s(`${e}h ${t}m`)}};t();let a=setInterval(t,1e3);return()=>clearInterval(a)},[e]),t)?(0,a.jsxs)("span",{className:"text-xs text-orange-500 font-mono",children:["⏱ ",t]}):null}function C({connection:e,proxyPools:t,isOAuth:s,isFirst:l,isLast:o,onMoveUp:r,onMoveDown:n,onToggleActive:c,onUpdateProxy:p,onEdit:m,onDelete:x,onPushToPool:u,oneByOneStatus:h=null,autoPing:f=null}){let[y,g]=(0,i.useState)(!1),[b,v]=(0,i.useState)(!1),j=(0,i.useRef)(null),k=new Map((t||[]).map(e=>[e.id,e])),S=e.providerSpecificData?.proxyPoolId||null,$=S?k.get(S):null,A=e.providerSpecificData?.connectionProxyEnabled===!0&&!!e.providerSpecificData?.connectionProxyUrl,T=!!S||A,P=$?`Pool: ${$.name}`:S?`Pool: ${S} (inactive/missing)`:A?`Legacy: ${e.providerSpecificData?.connectionProxyUrl}`:"",O=f?.provider==="codex"?"Auto-starts the next 5h Codex window after reset by sending a tiny gpt-5.5 request. Consumes a small amount of quota.":"When your 5h quota runs out, auto-sends a request the moment it resets so a new window starts right away.",E="";if($?.proxyUrl||e.providerSpecificData?.connectionProxyUrl){let t=$?.proxyUrl||e.providerSpecificData?.connectionProxyUrl;try{let e=new URL(t);E=`${e.protocol}//${e.hostname}${e.port?`:${e.port}`:""}`}catch{E=t}}let I=$?.noProxy||e.providerSpecificData?.connectionNoProxy||"",D="default";$?.isActive===!0?D="success":(S||A)&&(D="error"),(0,i.useEffect)(()=>{if(!y)return;let e=e=>{j.current&&!j.current.contains(e.target)&&g(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[y]);let R=async e=>{v(!0);try{await p("__none__"===e?null:e)}finally{v(!1),g(!1)}},U=e.authType||(s?"oauth":"apikey"),z="oauth"===U,_="cookie"===U,q=e.name?.trim()||e.email?.trim()||e.displayName?.trim()||(z?"OAuth Account":_?"Cookie Account":"API Key"),M=e.name?.trim()&&e.email?.trim()&&e.name.trim()!==e.email.trim()?e.email.trim():e.name?.trim()&&e.displayName?.trim()&&e.name.trim()!==e.displayName.trim()?e.displayName.trim():null,[F,K]=(0,i.useState)(!1),J=Object.entries(e).filter(([e])=>e.startsWith("modelLock_")).map(([,e])=>e).filter(e=>!!e).sort()[0]||null;(0,i.useEffect)(()=>{let t=()=>{K(!!Object.entries(e).filter(([e])=>e.startsWith("modelLock_")).map(([,e])=>e).filter(e=>e&&new Date(e).getTime()>Date.now()).sort()[0])};t();let s=J?setInterval(t,1e3):null;return()=>{s&&clearInterval(s)}},[J]);let L="unavailable"!==e.testStatus||F?e.testStatus:"active",B=()=>h?"queued"===h.state?"queued":"testing"===h.state?"testing":"success"===h.state?"success":"failed"===h.state?h.error?`failed: ${h.error}`:"failed":null:null;return(0,a.jsxs)("div",{className:`group flex min-w-0 flex-col gap-3 rounded-lg p-2 transition-colors hover:bg-black/[0.02] dark:hover:bg-white/[0.02] sm:flex-row sm:items-center sm:justify-between ${!1===e.isActive?"opacity-60":""}`,children:[(0,a.jsxs)("div",{className:"flex min-w-0 flex-1 items-start gap-2 sm:items-center sm:gap-3",children:[(0,a.jsxs)("div",{className:"flex shrink-0 flex-col",children:[(0,a.jsx)("button",{onClick:r,disabled:l,className:`p-0.5 rounded ${l?"text-text-muted/30 cursor-not-allowed":"hover:bg-sidebar text-text-muted hover:text-primary"}`,children:(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:"keyboard_arrow_up"})}),(0,a.jsx)("button",{onClick:n,disabled:o,className:`p-0.5 rounded ${o?"text-text-muted/30 cursor-not-allowed":"hover:bg-sidebar text-text-muted hover:text-primary"}`,children:(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:"keyboard_arrow_down"})})]}),(0,a.jsx)("span",{className:"material-symbols-outlined shrink-0 text-base text-text-muted",children:_?"cookie":z?"lock":"key"}),(0,a.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,a.jsx)("p",{className:"text-sm font-medium truncate",children:q}),M&&(0,a.jsx)("p",{className:"text-xs text-text-muted truncate",children:M}),(0,a.jsxs)("div",{className:"mt-1 flex min-w-0 flex-wrap items-center gap-1.5 sm:gap-2",children:[(0,a.jsx)(d.Ex,{variant:(0,w.g)(e.isActive,L),size:"sm",dot:!0,children:!1===e.isActive?"disabled":L||"Unknown"}),(0,a.jsx)(d.Ex,{variant:"default",size:"sm",children:z?"OAuth":_?"Cookie":"API Key"}),T&&(0,a.jsx)(d.Ex,{variant:D,size:"sm",children:"Proxy"}),F&&!1!==e.isActive&&(0,a.jsx)(N,{until:J}),e.lastError&&!1!==e.isActive&&(0,a.jsx)("span",{className:"max-w-full truncate text-xs text-red-500 sm:max-w-[300px]",title:e.lastError,children:e.lastError}),(0,a.jsxs)("span",{className:"text-xs text-text-muted",children:["#",e.priority]}),e.globalPriority&&(0,a.jsxs)("span",{className:"text-xs text-text-muted",children:["Auto: ",e.globalPriority]}),B()&&(0,a.jsx)(d.Ex,{variant:h?"success"===h.state?"success":"failed"===h.state?"error":"testing"===h.state?"primary":"default":"default",size:"sm",children:B()})]}),T&&(0,a.jsxs)("div",{className:"mt-1 flex items-center gap-2 flex-wrap",children:[(0,a.jsx)("span",{className:"max-w-full truncate text-[11px] text-text-muted sm:max-w-[420px]",title:P,children:P}),E&&(0,a.jsx)("code",{className:"max-w-full truncate rounded bg-black/5 px-1 py-0.5 font-mono text-[10px] text-text-muted dark:bg-white/5 sm:max-w-[260px]",children:E}),I&&(0,a.jsxs)("span",{className:"max-w-full truncate text-[11px] text-text-muted sm:max-w-[320px]",title:I,children:["no_proxy: ",I]})]})]})]}),(0,a.jsxs)("div",{className:"flex w-full items-center justify-between gap-2 sm:w-auto sm:justify-end",children:[(0,a.jsxs)("div",{className:"grid flex-1 grid-cols-3 gap-1 sm:flex sm:flex-none",children:[(t||[]).length>0&&(0,a.jsxs)("div",{className:"relative",ref:j,children:[(0,a.jsxs)("button",{onClick:()=>g(e=>!e),className:`flex w-full flex-col items-center rounded px-2 py-1 transition-colors hover:bg-black/5 dark:hover:bg-white/5 ${T?"text-primary":"text-text-muted hover:text-primary"}`,disabled:b,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:b?"progress_activity":"lan"}),(0,a.jsx)("span",{className:"text-[10px] leading-tight",children:"Proxy"})]}),y&&(0,a.jsxs)("div",{className:"absolute right-0 top-full z-50 mt-1 max-w-[78vw] min-w-[160px] rounded-lg border border-border bg-bg py-1 shadow-lg",children:[(0,a.jsx)("button",{onClick:()=>R("__none__"),className:`w-full text-left px-3 py-1.5 text-sm hover:bg-black/5 dark:hover:bg-white/5 ${!S?"text-primary font-medium":"text-text-main"}`,children:"None"}),(t||[]).map(e=>(0,a.jsx)("button",{onClick:()=>R(e.id),className:`w-full text-left px-3 py-1.5 text-sm hover:bg-black/5 dark:hover:bg-white/5 ${S===e.id?"text-primary font-medium":"text-text-main"}`,children:e.name},e.id))]})]}),f&&(0,a.jsx)(d.m_,{text:O,children:(0,a.jsxs)("button",{onClick:()=>f.onToggle(!f.on),className:`flex w-full flex-col items-center rounded px-2 py-1 transition-colors hover:bg-black/5 dark:hover:bg-white/5 ${f.on?"text-primary":"text-text-muted hover:text-primary"}`,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"bolt"}),(0,a.jsx)("span",{className:"text-[10px] leading-tight",children:"Auto-ping"})]})}),(0,a.jsxs)("button",{onClick:m,className:"flex flex-col items-center rounded px-2 py-1 text-text-muted hover:bg-black/5 hover:text-primary dark:hover:bg-white/5",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"edit"}),(0,a.jsx)("span",{className:"text-[10px] leading-tight",children:"Edit"})]}),"apikey"===U&&u&&(0,a.jsxs)("button",{onClick:u,className:"flex flex-col items-center rounded px-2 py-1 text-text-muted hover:bg-black/5 hover:text-primary dark:hover:bg-white/5",title:"Move API key back into key pool reserve",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"upload"}),(0,a.jsx)("span",{className:"text-[10px] leading-tight",children:"To pool"})]}),(0,a.jsxs)("button",{onClick:x,className:"flex flex-col items-center rounded px-2 py-1 text-red-500 hover:bg-red-500/10",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"delete"}),(0,a.jsx)("span",{className:"text-[10px] leading-tight",children:"Delete"})]})]}),(0,a.jsx)(d.lM,{size:"sm",checked:e.isActive??!0,onChange:c,title:e.isActive??!0?"Disable connection":"Enable connection"})]})]})}N.propTypes={until:b().string.isRequired},C.propTypes={connection:b().shape({id:b().string,name:b().string,email:b().string,displayName:b().string,modelLockUntil:b().string,testStatus:b().string,isActive:b().bool,lastError:b().string,priority:b().number,globalPriority:b().number}).isRequired,proxyPools:b().arrayOf(b().shape({id:b().string,name:b().string,proxyUrl:b().string,noProxy:b().string,isActive:b().bool})),isOAuth:b().bool.isRequired,isFirst:b().bool.isRequired,isLast:b().bool.isRequired,onMoveUp:b().func.isRequired,onMoveDown:b().func.isRequired,onToggleActive:b().func.isRequired,onUpdateProxy:b().func,onEdit:b().func.isRequired,onDelete:b().func.isRequired,onPushToPool:b().func,oneByOneStatus:b().shape({state:b().string,error:b().string}),autoPing:b().shape({on:b().bool,onToggle:b().func,provider:b().string})};let S=`name1|sk-key1
2
2
  name2|sk-key2
3
3
  sk-key-only-auto-named`;function $({isOpen:e,provider:t,providerName:s,isCompatible:l,isAnthropic:o,authType:r,authHint:n,website:p,proxyPools:m,error:x,onSave:u,onBulkDone:h,onClose:f}){let y="__none__",g="ollama-local"===t,b="cookie"===r,v="xai"===t&&!b,j=b?"Cookie Value":"API Key",k="azure"===t,w="cloudflare-ai"===t,N=c.Q2?.[t]?.regions||null,C=c.Q2?.[t]?.defaultRegion||N?.[0]?.id||"",[A,T]=(0,i.useState)({name:"",apiKey:"",defaultModel:"",priority:1,proxyPoolId:y,ollamaHostUrl:""}),[P,O]=(0,i.useState)({azureEndpoint:"",apiVersion:"2024-10-01-preview",deployment:"",organization:""}),[E,I]=(0,i.useState)({accountId:""}),[D,R]=(0,i.useState)(C),[U,z]=(0,i.useState)(!1),[_,q]=(0,i.useState)(null),[M,F]=(0,i.useState)(!1),[K,J]=(0,i.useState)("single"),[L,B]=(0,i.useState)(""),[W,H]=(0,i.useState)(null),G=()=>g&&A.ollamaHostUrl.trim()?{baseUrl:A.ollamaHostUrl.trim()}:k?{azureEndpoint:P.azureEndpoint,apiVersion:P.apiVersion,deployment:P.deployment,organization:P.organization}:w?{accountId:E.accountId}:N&&D?{region:D}:void 0,V=async()=>{z(!0);try{let e=await fetch("/api/providers/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:t,apiKey:A.apiKey,providerSpecificData:G()})}),s=await e.json();q(s.valid?"success":"failed")}catch{q("failed")}finally{z(!1)}},Q=async()=>{if(t&&(g||A.apiKey)&&(g||A.name)&&(!l||A.defaultModel.trim())){F(!0);try{let e=!1;try{z(!0),q(null);let s=await fetch("/api/providers/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:t,apiKey:A.apiKey,providerSpecificData:G()})});e=!!(await s.json()).valid,q(e?"success":"failed")}catch{q("failed")}finally{z(!1)}await u({name:A.name||(g?"Ollama Local":""),apiKey:A.apiKey,defaultModel:l?A.defaultModel.trim():void 0,priority:A.priority,proxyPoolId:A.proxyPoolId===y?null:A.proxyPoolId,testStatus:e?"active":"unknown",providerSpecificData:G()})}finally{F(!1)}}},Z=e=>{let t=crypto.randomUUID().replace(/-/g,"").slice(0,8).toUpperCase();return e&&"Key"!==e?`${e}-${t}`:`Key-${t}`},X=async()=>{let e=L.split("\n").map(e=>e.trim()).filter(Boolean);if(!e.length)return;F(!0),H(null);let s=0,a=0;for(let i=0;i<e.length;i++){let l,o,r,n=e[i].split("|");if(w){if(n.length<2){a++;continue}l=n[0].trim();let e=n[1].trim();o=Z("CF"),r={accountId:e}}else l=n.length>=2?n.slice(1).join("|").trim():n[0].trim(),o=Z(n.length>=2?n[0].trim():"Key"),r=void 0;try{(await fetch("/api/providers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:t,apiKey:l,name:o,priority:1,testStatus:"unknown",...r?{providerSpecificData:r}:{}})})).ok?s++:a++}catch{a++}}F(!1),H({success:s,failed:a}),s>0&&h&&h()};return t?(0,a.jsx)(d.aF,{isOpen:e,title:`Add ${s||t} ${j}`,onClose:f,children:(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(d.$n,{size:"sm",variant:"single"===K?"primary":"ghost",onClick:()=>{J("single"),H(null)},children:"Single"}),(0,a.jsx)(d.$n,{size:"sm",variant:"bulk"===K?"primary":"ghost",onClick:()=>{J("bulk"),H(null)},children:"Bulk Add"})]}),"bulk"===K&&(0,a.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,a.jsx)("p",{className:"text-xs text-text-muted",children:w?(0,a.jsxs)(a.Fragment,{children:["One key per line. Format: ",(0,a.jsx)("code",{children:"apiKey|accountId"})]}):(0,a.jsxs)(a.Fragment,{children:["One key per line. Format: ",(0,a.jsx)("code",{children:"name|apiKey"})," or just ",(0,a.jsx)("code",{children:"apiKey"})," (auto-named by index)."]})}),(0,a.jsx)("textarea",{className:"w-full rounded border border-accent/30 bg-sidebar p-2 text-sm font-mono resize-y min-h-[140px] focus:outline-none focus:ring-1 focus:ring-primary",placeholder:w?"api-key-1|account-id-1\napi-key-2|account-id-2":S,value:L,onChange:e=>B(e.target.value)}),W&&(0,a.jsxs)("div",{className:`text-sm font-medium ${W.failed>0?"text-yellow-400":"text-green-400"}`,children:["✓ ",W.success," added",W.failed>0?`, ✗ ${W.failed} failed`:""]}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(d.$n,{onClick:X,fullWidth:!0,disabled:M||!L.trim(),children:M?"Adding...":"Add All Keys"}),(0,a.jsx)(d.$n,{onClick:f,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]}),"single"===K&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(d.pd,{label:"Name",value:A.name,onChange:e=>T({...A,name:e.target.value}),placeholder:g?"Ollama Local":"Production Key"}),g&&(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(d.pd,{label:"Ollama Host URL",value:A.ollamaHostUrl,onChange:e=>T({...A,ollamaHostUrl:e.target.value}),placeholder:"http://localhost:11434",className:"flex-1"}),(0,a.jsx)("div",{className:"pt-6",children:(0,a.jsx)(d.$n,{onClick:V,disabled:U||M,variant:"secondary",children:U?"Checking...":"Check"})})]}),!g&&(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(d.pd,{label:j,type:b?"text":"password",value:A.apiKey,onChange:e=>T({...A,apiKey:e.target.value}),placeholder:b?"grok-web"===t?"sso=xxxxx... or just the raw value":"eyJhbGciOi...":v?"xai-...":"",className:"flex-1"}),(0,a.jsx)("div",{className:"pt-6",children:(0,a.jsx)(d.$n,{onClick:V,disabled:!A.apiKey||U||M,variant:"secondary",children:U?"Checking...":"Check"})})]}),v&&(0,a.jsx)("p",{className:"text-xs text-text-muted",children:"Use a direct xAI API key from console.x.ai. This is separate from Grok Build OAuth."}),b&&n&&(0,a.jsxs)("p",{className:"text-xs text-text-muted",children:[n,p&&(0,a.jsxs)(a.Fragment,{children:[" ",(0,a.jsxs)("a",{href:p,target:"_blank",rel:"noopener noreferrer",className:"text-primary underline",children:["Open ",p.replace(/^https?:\/\//,"")]})]})]}),N&&(0,a.jsx)(d.l6,{label:"Region",value:D,onChange:e=>R(e.target.value),options:N.map(e=>({value:e.id,label:e.label}))}),l&&(0,a.jsx)(d.pd,{label:"Default Model",value:A.defaultModel,onChange:e=>T({...A,defaultModel:e.target.value}),placeholder:o?"claude-3-5-sonnet-latest":"gpt-4o-mini"}),g&&(0,a.jsxs)("p",{className:"text-xs text-text-muted",children:["Leave blank to use ",(0,a.jsx)("code",{children:"http://localhost:11434"}),". For remote Ollama, enter the full host URL (e.g. ",(0,a.jsx)("code",{children:"http://192.168.1.10:11434"}),")."]}),_&&(0,a.jsx)(d.Ex,{variant:"success"===_?"success":"error",children:"success"===_?"Valid":"Invalid"}),x&&(0,a.jsx)("p",{className:"text-xs text-red-500 break-words",children:x}),l&&(0,a.jsx)("p",{className:"text-xs text-text-muted",children:"Enter the model ID exactly as your compatible endpoint expects it. This model will be saved as the connection default."}),w&&(0,a.jsxs)("div",{className:"bg-sidebar/50 p-4 rounded-lg border border-accent/20",children:[(0,a.jsx)("h3",{className:"font-semibold mb-3 text-sm",children:"Cloudflare Workers AI"}),(0,a.jsx)(d.pd,{label:"Account ID",value:E.accountId,onChange:e=>I({...E,accountId:e.target.value}),placeholder:"abc123def456..."}),(0,a.jsxs)("p",{className:"text-xs text-text-muted mt-2",children:["Find your Account ID in the right sidebar of ",(0,a.jsx)("a",{href:"https://dash.cloudflare.com",target:"_blank",rel:"noopener noreferrer",className:"text-primary underline",children:"dash.cloudflare.com"})]})]}),k&&(0,a.jsxs)("div",{className:"bg-sidebar/50 p-4 rounded-lg border border-accent/20",children:[(0,a.jsx)("h3",{className:"font-semibold mb-3 text-sm",children:"Azure OpenAI Configuration"}),(0,a.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,a.jsx)(d.pd,{label:"Azure Endpoint",value:P.azureEndpoint,onChange:e=>O({...P,azureEndpoint:e.target.value}),placeholder:"https://your-resource.openai.azure.com"}),(0,a.jsx)(d.pd,{label:"Deployment Name",value:P.deployment,onChange:e=>O({...P,deployment:e.target.value}),placeholder:"gpt-4"}),(0,a.jsx)(d.pd,{label:"API Version",value:P.apiVersion,onChange:e=>O({...P,apiVersion:e.target.value}),placeholder:"2024-10-01-preview"}),(0,a.jsx)(d.pd,{label:"Organization",value:P.organization,onChange:e=>O({...P,organization:e.target.value}),placeholder:"Organization ID"})]})]}),(0,a.jsx)(d.pd,{label:"Priority",type:"number",value:A.priority,onChange:e=>T({...A,priority:Number.parseInt(e.target.value)||1})}),(0,a.jsx)(d.l6,{label:"Proxy Pool",value:A.proxyPoolId,onChange:e=>T({...A,proxyPoolId:e.target.value}),options:[{value:y,label:"None"},...(m||[]).map(e=>({value:e.id,label:e.name}))],placeholder:"None"}),0===(m||[]).length&&(0,a.jsx)("p",{className:"text-xs text-text-muted",children:"No active proxy pools available. Create one in Proxy Pools page first."}),(0,a.jsx)("p",{className:"text-xs text-text-muted",children:"Legacy manual proxy fields are still accepted by API for backward compatibility."}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(d.$n,{onClick:Q,fullWidth:!0,disabled:M||!g&&(!A.name||!A.apiKey)||l&&!A.defaultModel.trim()||k&&(!P.azureEndpoint||!P.deployment||!P.organization)||w&&!E.accountId,children:M?"Saving...":"Save"}),(0,a.jsx)(d.$n,{onClick:f,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})]})}):null}function A({isOpen:e,node:t,onSave:s,onClose:l,isAnthropic:o}){let[r,n]=(0,i.useState)({name:"",prefix:"",apiType:"chat",baseUrl:"https://api.openai.com/v1"}),[c,p]=(0,i.useState)(!1),[m,x]=(0,i.useState)(""),[u,h]=(0,i.useState)(""),[f,y]=(0,i.useState)(!1),[g,b]=(0,i.useState)(null);(0,i.useEffect)(()=>{t&&n({name:t.name||"",prefix:t.prefix||"",apiType:t.apiType||"chat",baseUrl:t.baseUrl||(o?"https://api.anthropic.com/v1":"https://api.openai.com/v1")})},[t,o]);let v=async()=>{if(r.name.trim()&&r.prefix.trim()&&r.baseUrl.trim()){p(!0);try{let e={name:r.name,prefix:r.prefix,baseUrl:r.baseUrl};o||(e.apiType=r.apiType),await s(e)}finally{p(!1)}}},j=async()=>{y(!0);try{let e=await fetch("/api/provider-nodes/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:r.baseUrl,apiKey:m,type:o?"anthropic-compatible":"openai-compatible",modelId:u.trim()||void 0})}),t=await e.json();b(t.valid?"success":"failed")}catch{b("failed")}finally{y(!1)}};return t?(0,a.jsx)(d.aF,{isOpen:e,title:`Edit ${o?"Anthropic":"OpenAI"} Compatible`,onClose:l,children:(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,a.jsx)(d.pd,{label:"Name",value:r.name,onChange:e=>n({...r,name:e.target.value}),placeholder:`${o?"Anthropic":"OpenAI"} Compatible (Prod)`,hint:"Required. A friendly label for this node."}),(0,a.jsx)(d.pd,{label:"Prefix",value:r.prefix,onChange:e=>n({...r,prefix:e.target.value}),placeholder:o?"ac-prod":"oc-prod",hint:"Required. Used as the provider prefix for model IDs."}),!o&&(0,a.jsx)(d.l6,{label:"API Type",options:[{value:"chat",label:"Chat Completions"},{value:"responses",label:"Responses API"}],value:r.apiType,onChange:e=>n({...r,apiType:e.target.value})}),(0,a.jsx)(d.pd,{label:"Base URL",value:r.baseUrl,onChange:e=>n({...r,baseUrl:e.target.value}),placeholder:o?"https://api.anthropic.com/v1":"https://api.openai.com/v1",hint:`Use the base URL (ending in /v1) for your ${o?"Anthropic":"OpenAI"}-compatible API.`}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(d.pd,{label:"API Key (for Check)",type:"password",value:m,onChange:e=>x(e.target.value),className:"flex-1"}),(0,a.jsx)("div",{className:"pt-6",children:(0,a.jsx)(d.$n,{onClick:j,disabled:!m||f||!r.baseUrl.trim(),variant:"secondary",children:f?"Checking...":"Check"})})]}),(0,a.jsx)(d.pd,{label:"Model ID (optional)",value:u,onChange:e=>h(e.target.value),placeholder:"e.g. my-model-id",hint:"If provider lacks /models endpoint, enter a model ID to validate via chat/completions instead."}),g&&(0,a.jsx)(d.Ex,{variant:"success"===g?"success":"error",children:"success"===g?"Valid":"Invalid"}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(d.$n,{onClick:v,fullWidth:!0,disabled:!r.name.trim()||!r.prefix.trim()||!r.baseUrl.trim()||c,children:c?"Saving...":"Save"}),(0,a.jsx)(d.$n,{onClick:l,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})}):null}function T({isOpen:e,providerAlias:t,providerDisplayAlias:s,onSave:l,onClose:o}){let[r,n]=(0,i.useState)(""),[c,p]=(0,i.useState)(null),[m,x]=(0,i.useState)(""),[u,h]=(0,i.useState)(!1);(0,i.useEffect)(()=>{e&&(n(""),p(null),x(""))},[e]);let f=e=>{let s=`${t}/`;return e.startsWith(s)?e.slice(s.length):e},y=async()=>{let e=f(r.trim());if(e){p("testing"),x("");try{let s=await fetch("/api/models/test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:`${t}/${e}`})}),a=await s.json();p(a.ok?"ok":"error"),x(a.error||"")}catch(e){p("error"),x(e.message)}}},g=async()=>{let e=f(r.trim());if(e&&!u){h(!0);try{await l(e)}finally{h(!1)}}};return(0,a.jsx)(d.aF,{isOpen:e,onClose:o,title:"Add Custom Model",children:(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"text-sm font-medium mb-1.5 block",children:"Model ID"}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)("input",{type:"text",value:r,onChange:e=>{n(e.target.value),p(null),x("")},onKeyDown:e=>{"Enter"===e.key&&y()},placeholder:"e.g. claude-opus-4-5",className:"flex-1 px-3 py-2 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary",autoFocus:!0}),(0,a.jsx)(d.$n,{variant:"secondary",icon:"science",loading:"testing"===c,onClick:y,disabled:!r.trim()||"testing"===c,children:"testing"===c?"Testing...":"Test"})]}),(0,a.jsxs)("p",{className:"text-xs text-text-muted mt-1",children:["Sent to provider as: ",(0,a.jsx)("code",{className:"font-mono bg-sidebar px-1 rounded",children:f(r.trim())||"model-id"})]})]}),"ok"===c&&(0,a.jsxs)("div",{className:"flex items-center gap-2 text-sm text-green-600",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-base",children:"check_circle"}),"Model is reachable"]}),"error"===c&&(0,a.jsxs)("div",{className:"flex items-start gap-2 text-sm text-red-500",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-base shrink-0",children:"cancel"}),(0,a.jsx)("span",{children:m||"Model not reachable"})]}),(0,a.jsxs)("div",{className:"flex gap-2 pt-1",children:[(0,a.jsx)(d.$n,{onClick:o,variant:"ghost",fullWidth:!0,size:"sm",children:"Cancel"}),(0,a.jsx)(d.$n,{onClick:g,fullWidth:!0,size:"sm",disabled:!r.trim()||u,children:u?"Adding...":"Add Model"})]})]})})}$.propTypes={isOpen:b().bool.isRequired,provider:b().string,providerName:b().string,isCompatible:b().bool,isAnthropic:b().bool,authType:b().string,authHint:b().string,website:b().string,proxyPools:b().arrayOf(b().shape({id:b().string,name:b().string})),error:b().string,onSave:b().func.isRequired,onBulkDone:b().func,onClose:b().func.isRequired},A.propTypes={isOpen:b().bool.isRequired,node:b().shape({id:b().string,name:b().string,prefix:b().string,apiType:b().string,baseUrl:b().string}),onSave:b().func.isRequired,onClose:b().func.isRequired,isAnthropic:b().bool},T.propTypes={isOpen:b().bool.isRequired,providerAlias:b().string.isRequired,providerDisplayAlias:b().string.isRequired,onSave:b().func.isRequired,onClose:b().func.isRequired};let P=`[
4
4
  {
@@ -1 +1 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[8460],{33150:(e,t,s)=>{Promise.resolve().then(s.bind(s,97678))},97678:(e,t,s)=>{"use strict";s.r(t),s.d(t,{default:()=>j});var r=s(95155),a=s(12115),l=s(14051),i=s.n(l),n=s(35497),o=s(57250),d=s(90620),c=s(81095),p=s(98500),m=s.n(p),x=s(65921),u=s(38003);let h={available:{icon:"check_circle",color:"#22c55e",label:"Available"},cooldown:{icon:"schedule",color:"#f59e0b",label:"Cooldown"},unavailable:{icon:"error",color:"#ef4444",label:"Unavailable"},unknown:{icon:"help",color:"#6b7280",label:"Unknown"}};function f(){let[e,t]=(0,a.useState)(null),[s,l]=(0,a.useState)(!0),[i,o]=(0,a.useState)(!1),[d,c]=(0,a.useState)(null),p=(0,a.useRef)(null),m=(0,x.i)(),u=(0,a.useCallback)(async()=>{try{let e=await fetch("/api/models/availability");if(e.ok){let s=await e.json();t(s)}}catch{}finally{l(!1)}},[]);(0,a.useEffect)(()=>{u();let e=setInterval(u,3e4);return()=>clearInterval(e)},[u]),(0,a.useEffect)(()=>{let e=e=>{p.current&&!p.current.contains(e.target)&&o(!1)};return i&&document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[i]);let f=async(e,t)=>{c(`${e}:${t}`);try{(await fetch("/api/models/availability",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"clearCooldown",provider:e,model:t})})).ok?(m.success(`Cooldown cleared for ${t}`),await u()):m.error("Failed to clear cooldown")}catch{m.error("Failed to clear cooldown")}finally{c(null)}};if(s)return null;let g=e?.models||[],b=0===(e?.unavailableCount||g.filter(e=>"available"!==e.status).length),v={};return g.forEach(e=>{if("available"===e.status)return;let t=e.provider||"unknown";v[t]||(v[t]=[]),v[t].push(e)}),(0,r.jsx)("div",{className:"relative",ref:p,children:i&&(0,r.jsxs)("div",{className:"absolute top-full right-0 mt-2 w-80 bg-surface border border-border rounded-xl shadow-2xl z-50 overflow-hidden",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border bg-bg",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-[16px]",style:{color:b?"#22c55e":"#f59e0b"},children:b?"verified":"warning"}),(0,r.jsx)("span",{className:"text-sm font-semibold text-text-main",children:"Model Status"})]}),(0,r.jsx)("button",{onClick:u,className:"p-1 rounded-lg hover:bg-surface text-text-muted hover:text-text-main transition-colors",title:"Refresh",children:(0,r.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"refresh"})})]}),(0,r.jsx)("div",{className:"px-4 py-3 max-h-60 overflow-y-auto",children:b?(0,r.jsx)("p",{className:"text-sm text-text-muted text-center py-2",children:"All models are responding normally."}):(0,r.jsx)("div",{className:"flex flex-col gap-2.5",children:Object.entries(v).map(([e,t])=>(0,r.jsxs)("div",{children:[(0,r.jsx)("p",{className:"text-xs font-semibold text-text-main mb-1.5 capitalize",children:e}),(0,r.jsx)("div",{className:"flex flex-col gap-1",children:t.map(e=>{let t=h[e.status]||h.unknown,s=d===`${e.provider}:${e.model}`;return(0,r.jsxs)("div",{className:"flex items-center justify-between px-2.5 py-1.5 rounded-lg bg-surface/30",children:[(0,r.jsxs)("div",{className:"flex items-center gap-1.5 min-w-0",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-[14px] shrink-0",style:{color:t.color},children:t.icon}),(0,r.jsx)("span",{className:"font-mono text-xs text-text-main truncate",children:e.model})]}),"cooldown"===e.status&&(0,r.jsx)(n.$n,{size:"sm",variant:"ghost",onClick:()=>f(e.provider,e.model),disabled:s,className:"text-[10px] px-1.5! py-0.5! ml-2",children:s?"...":"Clear"})]},`${e.provider}-${e.model}`)})})]},e))})})]})})}let g={openai:{title:"Add OpenAI Compatible",type:"openai-compatible",defaultBaseUrl:"https://api.openai.com/v1",namePlaceholder:"OpenAI Compatible (Prod)",prefixPlaceholder:"oc-prod",baseUrlHint:"Use the base URL (ending in /v1) for your OpenAI-compatible API.",modelIdPlaceholder:"e.g. gpt-4, claude-3-opus",errorLabel:"OpenAI Compatible",hasApiType:!0},anthropic:{title:"Add Anthropic Compatible",type:"anthropic-compatible",defaultBaseUrl:"https://api.anthropic.com/v1",namePlaceholder:"Anthropic Compatible (Prod)",prefixPlaceholder:"ac-prod",baseUrlHint:"Use the base URL (ending in /v1) for your Anthropic-compatible API. The system will append /messages.",modelIdPlaceholder:"e.g. claude-3-opus",errorLabel:"Anthropic Compatible",hasApiType:!1}},b=[{value:"chat",label:"Chat Completions"},{value:"responses",label:"Responses API"}];function v({variant:e,isOpen:t,onClose:s,onCreated:l}){let i=g[e],o=()=>({name:"",prefix:"",...i.hasApiType?{apiType:"chat"}:{},baseUrl:i.defaultBaseUrl}),[d,c]=(0,a.useState)(o),[p,m]=(0,a.useState)(!1),[x,u]=(0,a.useState)(""),[h,f]=(0,a.useState)(""),[y,j]=(0,a.useState)(!1),[N,w]=(0,a.useState)(null);(0,a.useEffect)(()=>{i.hasApiType?c(e=>({...e,baseUrl:i.defaultBaseUrl})):t&&(w(null),u(""),f(""))},[i.hasApiType?d.apiType:t]);let k=async()=>{if(d.name.trim()&&d.prefix.trim()&&d.baseUrl.trim()){m(!0);try{let e=await fetch("/api/provider-nodes",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:d.name,prefix:d.prefix,...i.hasApiType?{apiType:d.apiType}:{},baseUrl:d.baseUrl,type:i.type})}),t=await e.json();e.ok&&(l(t.node),c(o()),u(""),w(null))}catch(e){console.log(`Error creating ${i.errorLabel} node:`,e)}finally{m(!1)}}},C=async()=>{j(!0);try{let e=await fetch("/api/provider-nodes/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:d.baseUrl,apiKey:x,type:i.type,modelId:h.trim()||void 0})}),t=await e.json();w(t)}catch{w({valid:!1,error:"Network error"})}finally{j(!1)}};return(0,r.jsx)(n.aF,{isOpen:t,title:i.title,onClose:s,children:(0,r.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,r.jsx)(n.pd,{label:"Name",value:d.name,onChange:e=>c({...d,name:e.target.value}),placeholder:i.namePlaceholder,hint:"Required. A friendly label for this node."}),(0,r.jsx)(n.pd,{label:"Prefix",value:d.prefix,onChange:e=>c({...d,prefix:e.target.value}),placeholder:i.prefixPlaceholder,hint:"Required. Used as the provider prefix for model IDs."}),i.hasApiType&&(0,r.jsx)(n.l6,{label:"API Type",options:b,value:d.apiType,onChange:e=>c({...d,apiType:e.target.value})}),(0,r.jsx)(n.pd,{label:"Base URL",value:d.baseUrl,onChange:e=>c({...d,baseUrl:e.target.value}),placeholder:i.defaultBaseUrl,hint:i.baseUrlHint}),(0,r.jsx)(n.pd,{label:"API Key (for Check)",type:"password",value:x,onChange:e=>u(e.target.value)}),(0,r.jsx)(n.pd,{label:"Model ID (optional)",value:h,onChange:e=>f(e.target.value),placeholder:i.modelIdPlaceholder,hint:"If provider lacks /models endpoint, enter a model ID to validate via chat/completions instead."}),(0,r.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center",children:[(0,r.jsx)(n.$n,{onClick:C,disabled:!x||y||!d.baseUrl.trim(),variant:"secondary",className:"w-full sm:w-auto",children:y?"Checking...":"Check"}),(()=>{if(!N)return null;let{valid:e,error:t,method:s}=N;return e?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(n.Ex,{variant:"success",children:"Valid"}),"chat"===s&&(0,r.jsx)("span",{className:"text-sm text-text-muted",children:"(via inference test)"})]}):(0,r.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,r.jsx)(n.Ex,{variant:"error",children:"Invalid"}),t&&(0,r.jsx)("span",{className:"text-sm text-red-500",children:t})]})})()]}),(0,r.jsxs)("div",{className:"flex flex-col gap-2 sm:flex-row",children:[(0,r.jsx)(n.$n,{onClick:k,fullWidth:!0,disabled:!d.name.trim()||!d.prefix.trim()||!d.baseUrl.trim()||p,children:p?"Creating...":"Create"}),(0,r.jsx)(n.$n,{onClick:s,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})})}function y(e,t,s){let a=[];if(e>0&&a.push((0,r.jsxs)(n.Ex,{variant:"success",size:"sm",dot:!0,children:[e," Connected"]},"connected")),t>0){let e=s?`${t} Error (${s})`:`${t} Error`;a.push((0,r.jsx)(n.Ex,{variant:"error",size:"sm",dot:!0,children:e},"error"))}return 0===a.length?(0,r.jsx)("span",{className:"text-text-muted",children:"No connections"}):a}function j(){let[e,t]=(0,a.useState)([]),[s,l]=(0,a.useState)([]),[i,o]=(0,a.useState)(!0),[p,m]=(0,a.useState)(!1),[h,g]=(0,a.useState)(!1),[b,y]=(0,a.useState)(!1),[j,C]=(0,a.useState)(null),[T,A]=(0,a.useState)(null),I=(0,x.i)(),$=(0,u.C)(e=>e.query),E=(0,u.C)(e=>e.register),P=(0,u.C)(e=>e.unregister);(0,a.useEffect)(()=>(E("Search providers..."),()=>P()),[E,P]);let O=e=>!$.trim()||e.toLowerCase().includes($.trim().toLowerCase()),R=(e,t)=>[...e].sort(([e,s],[r,a])=>{let l=s.priority??999,i=a.priority??999;if(l!==i)return l-i;let n=S(e,t),o=S(r,t),d=+(n.connected>0),c=+(o.connected>0);return d!==c?c-d:(s.name||"").localeCompare(a.name||"")});(0,a.useEffect)(()=>{(async()=>{try{let[e,s]=await Promise.all([fetch("/api/providers"),fetch("/api/provider-nodes")]),r=await e.json(),a=await s.json();e.ok&&t(r.connections||[]),s.ok&&l(a.nodes||[])}catch(e){console.log("Error fetching data:",e)}finally{o(!1)}})()},[]);let S=(t,s)=>{let r=Array.isArray(s)?s:[s],a=e.filter(e=>e.provider===t&&r.includes(e.authType)),l=e=>{let t=Object.entries(e).some(([e,t])=>e.startsWith("modelLock_")&&t&&new Date(t).getTime()>Date.now());return"unavailable"!==e.testStatus||t?e.testStatus:"active"},i=a.filter(e=>{let t=l(e);return"active"===t||"success"===t}).length,n=a.filter(e=>{let t=l(e);return"error"===t||"expired"===t||"unavailable"===t}),o=n.length,d=a.length,c=d>0&&a.every(e=>!1===e.isActive),p=n.sort((e,t)=>new Date(t.lastErrorAt||0)-new Date(e.lastErrorAt||0))[0];return{connected:i,error:o,total:d,errorCode:p?function(e){if(!e)return null;let t=e.lastErrorType;if("runtime_error"===t)return"RUNTIME";if("upstream_auth_error"===t||"auth_missing"===t||"token_refresh_failed"===t||"token_expired"===t)return"AUTH";if("upstream_rate_limited"===t)return"429";if("upstream_unavailable"===t)return"5XX";if("network_error"===t)return"NET";let s=Number(e.errorCode);if(Number.isFinite(s)&&s>=400)return String(s);let r=function(e){if(!e)return null;let t=e.match(/\b([45]\d{2})\b/);return t?t[1]:"ERR"}(e.lastError);if("401"===r||"403"===r)return"AUTH";if(r&&"ERR"!==r)return r;let a=(e.lastError||"").toLowerCase();return a.includes("runtime")||a.includes("not runnable")||a.includes("not installed")?"RUNTIME":a.includes("invalid api key")||a.includes("token invalid")||a.includes("revoked")||a.includes("unauthorized")?"AUTH":"ERR"}(p):null,errorTime:p?.lastErrorAt?function(e){if(!e)return"";let t=Math.floor((Date.now()-new Date(e).getTime())/6e4);if(t<1)return"just now";if(t<60)return`${t}m ago`;let s=Math.floor(t/60);if(s<24)return`${s}h ago`;let r=Math.floor(s/24);return`${r}d ago`}(p.lastErrorAt):null,allDisabled:c}},U=async(s,r,a)=>{let l=Array.isArray(r)?r:[r],i=e=>e.provider===s&&l.includes(e.authType),n=e.filter(i);t(e=>e.map(e=>i(e)?{...e,isActive:a}:e)),await Promise.allSettled(n.map(e=>fetch(`/api/providers/${e.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({isActive:a})})))},_=async(e,t=null)=>{if(!j){C("provider"===e?t:e),A(null);try{let s=await fetch("/api/providers/test-batch",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mode:e,providerId:t})}),r=await s.json();if(A(r),r.summary){let{passed:e,failed:t,total:s}=r.summary;0===t?I.success(`All ${s} tests passed`):I.warning(`${e}/${s} passed, ${t} failed`)}}catch(e){A({error:"Test request failed"}),I.error("Provider test failed")}finally{C(null)}}},z=s.filter(e=>"openai-compatible"===e.type).map(e=>({id:e.id,name:e.name||"OpenAI Compatible",color:"#10A37F",textIcon:"OC",apiType:e.apiType})).filter(e=>O(e.name)),q=s.filter(e=>"anthropic-compatible"===e.type).map(e=>({id:e.id,name:e.name||"Anthropic Compatible",color:"#D97757",textIcon:"AC"})).filter(e=>O(e.name)),D=R(Object.entries(d.zN).filter(([,e])=>!e.hidden&&O(e.name)),"oauth"),F=Object.entries(c.IS).filter(([,e])=>!e.hidden&&O(e.name)).sort(([,e],[,t])=>!!t.noAuth-!!e.noAuth),L=R(Object.entries(c.nJ).filter(([,e])=>!e.hidden&&O(e.name)&&(e.serviceKinds??["llm"]).includes("llm")),"freeTier").sort(([,e],[,t])=>!!t.noAuth-!!e.noAuth),M=Object.entries(d.fg).filter(([,e])=>!e.hidden&&(e.serviceKinds??["llm"]).includes("llm")&&O(e.name)).sort(([e,t],[s,r])=>{let a=S(e,"apikey").total>0?0:1,l=S(s,"apikey").total>0?0:1;return a!==l?a-l:(t.name||"").localeCompare(r.name||"")}),K=!!$.trim(),H=K||p?M:M.slice(0,20),J=M.length-20;if(i)return(0,r.jsxs)("div",{className:"flex flex-col gap-8",children:[(0,r.jsx)(n.Qv,{}),(0,r.jsx)(n.Qv,{})]});let B=D.length>0||F.length>0||L.length>0||M.length>0||z.length>0||q.length>0;return(0,r.jsxs)("div",{className:"flex min-w-0 flex-col gap-6 px-1 sm:px-0",children:[!B&&(0,r.jsxs)("div",{className:"text-center py-8 border border-dashed border-border rounded-xl",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-[32px] text-text-muted mb-2",children:"search_off"}),(0,r.jsx)("p",{className:"text-text-muted text-sm",children:"No providers match your search"})]}),(0,r.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,r.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[(0,r.jsxs)("h2",{className:"text-lg sm:text-xl font-semibold flex items-center gap-2 leading-tight",children:["Custom Providers (OpenAI/Anthropic Compatible)"," "]}),(0,r.jsxs)("div",{className:"grid grid-cols-1 gap-2 sm:flex sm:w-auto",children:[(0,r.jsx)(n.$n,{size:"sm",icon:"add",onClick:()=>y(!0),className:"w-full sm:w-auto",children:"Add Anthropic Compatible"}),(0,r.jsx)(n.$n,{size:"sm",variant:"secondary",icon:"add",onClick:()=>g(!0),className:"w-full !bg-white !text-black hover:!bg-gray-100 sm:w-auto",children:"Add OpenAI Compatible"})]})]}),0===z.length&&0===q.length?(0,r.jsxs)("div",{className:"flex items-center justify-center gap-2 py-2 border border-dashed border-border rounded-xl text-text-muted text-sm",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"extension"}),(0,r.jsx)("span",{children:"No custom providers — use buttons above to add OpenAI/Anthropic compatible endpoints"})]}):(0,r.jsx)("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2 sm:gap-4 lg:grid-cols-3 xl:grid-cols-4",children:[...z,...q].map(e=>(0,r.jsx)(w,{providerId:e.id,provider:e,stats:S(e.id,"apikey"),authType:"compatible",onToggle:t=>U(e.id,"apikey",t)},e.id))})]}),D.length>0&&(0,r.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,r.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[(0,r.jsx)("h2",{className:"text-lg sm:text-xl font-semibold flex items-center gap-2 leading-tight",children:"OAuth Providers"}),(0,r.jsxs)("div",{className:"flex w-full flex-col gap-2 sm:w-auto sm:flex-row sm:items-center",children:[(0,r.jsx)(f,{}),(0,r.jsxs)("button",{onClick:()=>_("oauth"),disabled:!!j,className:`flex w-full items-center justify-center gap-1.5 rounded-lg border px-3 py-2 text-xs font-medium transition-colors sm:w-auto sm:py-1.5 ${"oauth"===j?"bg-primary/20 border-primary/40 text-primary animate-pulse":"bg-bg border-border text-text-muted hover:text-text-main hover:border-primary/40"}`,title:"Test all OAuth connections","aria-label":"Test all OAuth connections",children:[(0,r.jsx)("span",{className:`material-symbols-outlined text-[14px]${"oauth"===j?" animate-spin":""}`,children:"play_arrow"}),"oauth"===j?"Testing...":"Test All"]})]})]}),(0,r.jsx)("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2 sm:gap-4 lg:grid-cols-3 xl:grid-cols-4",children:D.map(([e,t])=>(0,r.jsx)(N,{providerId:e,provider:t,stats:S(e,"oauth"),authType:"oauth",onToggle:t=>U(e,"oauth",t)},e))})]}),(F.length>0||L.length>0)&&(0,r.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,r.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[(0,r.jsx)("h2",{className:"text-lg sm:text-xl font-semibold flex items-center gap-2 leading-tight",children:"Free Tier Providers"}),(0,r.jsxs)("button",{onClick:()=>_("free"),disabled:!!j,className:`flex w-full items-center justify-center gap-1.5 rounded-lg border px-3 py-2 text-xs font-medium transition-colors sm:w-auto sm:py-1.5 ${"free"===j?"bg-primary/20 border-primary/40 text-primary animate-pulse":"bg-bg border-border text-text-muted hover:text-text-main hover:border-primary/40"}`,title:"Test all Free connections","aria-label":"Test all Free provider connections",children:[(0,r.jsx)("span",{className:`material-symbols-outlined text-[14px]${"free"===j?" animate-spin":""}`,children:"play_arrow"}),"free"===j?"Testing...":"Test All"]})]}),(0,r.jsxs)("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2 sm:gap-4 lg:grid-cols-3 xl:grid-cols-4",children:[F.map(([e,t])=>{let s="kiro"===e?["oauth","apikey","api_key"]:"oauth";return(0,r.jsx)(N,{providerId:e,provider:t,stats:S(e,s),authType:"free",onToggle:t=>U(e,s,t)},e)}),L.map(([e,t])=>(0,r.jsx)(w,{providerId:e,provider:t,stats:S(e,"apikey"),authType:"apikey",onToggle:t=>U(e,"apikey",t)},e))]})]}),M.length>0&&(0,r.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,r.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[(0,r.jsxs)("h2",{className:"text-lg sm:text-xl font-semibold flex items-center gap-2 leading-tight",children:["API Key Providers"," "]}),(0,r.jsxs)("button",{onClick:()=>_("apikey"),disabled:!!j,className:`flex w-full items-center justify-center gap-1.5 rounded-lg border px-3 py-2 text-xs font-medium transition-colors sm:w-auto sm:py-1.5 ${"apikey"===j?"bg-primary/20 border-primary/40 text-primary animate-pulse":"bg-bg border-border text-text-muted hover:text-text-main hover:border-primary/40"}`,title:"Test all API Key connections","aria-label":"Test all API Key connections",children:[(0,r.jsx)("span",{className:`material-symbols-outlined text-[14px]${"apikey"===j?" animate-spin":""}`,children:"play_arrow"}),"apikey"===j?"Testing...":"Test All"]})]}),(0,r.jsx)("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2 sm:gap-4 lg:grid-cols-3 xl:grid-cols-4",children:H.map(([e,t])=>(0,r.jsx)(w,{providerId:e,provider:t,stats:S(e,"apikey"),authType:"apikey",onToggle:t=>U(e,"apikey",t)},e))}),!K&&!p&&J>0&&(0,r.jsxs)("button",{onClick:()=>m(!0),className:"flex w-full items-center justify-center gap-1.5 rounded-lg border border-dashed border-primary/40 px-3 py-2.5 text-sm font-medium text-primary transition-colors hover:border-primary hover:bg-primary/5",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"expand_more"}),"Show all ",M.length," providers"]})]}),(0,r.jsx)(v,{variant:"openai",isOpen:h,onClose:()=>g(!1),onCreated:e=>{l(t=>[...t,e]),g(!1)}}),(0,r.jsx)(v,{variant:"anthropic",isOpen:b,onClose:()=>y(!1),onCreated:e=>{l(t=>[...t,e]),y(!1)}}),T&&(0,r.jsxs)("div",{className:"fixed inset-0 z-50 flex items-start justify-center px-3 pt-[6vh] sm:pt-[10vh]",onClick:()=>A(null),children:[(0,r.jsx)("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm"}),(0,r.jsxs)("div",{className:"relative bg-surface border border-border rounded-xl w-full max-w-[600px] max-h-[86vh] sm:max-h-[80vh] overflow-y-auto shadow-2xl",onClick:e=>e.stopPropagation(),children:[(0,r.jsxs)("div",{className:"sticky top-0 z-10 flex items-center justify-between px-5 py-3 border-b border-border bg-surface/95 backdrop-blur-sm rounded-t-xl",children:[(0,r.jsx)("h3",{className:"font-semibold",children:"Test Results"}),(0,r.jsx)("button",{onClick:()=>A(null),className:"p-1 rounded-lg hover:bg-bg text-text-muted hover:text-text-main transition-colors","aria-label":"Close test results",children:(0,r.jsx)("span",{className:"material-symbols-outlined text-lg",children:"close"})})]}),(0,r.jsx)("div",{className:"p-5",children:(0,r.jsx)(k,{results:T})})]})]})]})}function N({providerId:e,provider:t,stats:s,authType:a,onToggle:l}){let{connected:i,error:d,errorCode:c,errorTime:p,allDisabled:x}=s,u=!!t.noAuth;return(0,r.jsx)(m(),{href:`/dashboard/providers/${e}`,className:"group min-w-0",children:(0,r.jsx)(n.Zp,{padding:"xs",className:`h-full hover:bg-black/[0.01] dark:hover:bg-white/[0.01] transition-colors cursor-pointer ${x?"opacity-50":""}`,children:(0,r.jsxs)("div",{className:"flex min-w-0 items-center justify-between gap-3",children:[(0,r.jsxs)("div",{className:"flex min-w-0 items-center gap-3",children:[(0,r.jsx)("div",{className:"size-8 shrink-0 rounded-lg flex items-center justify-center",style:{backgroundColor:`${t.color?.length>7?t.color:t.color+"15"}`},children:(0,r.jsx)(o.A,{src:`/providers/${t.id}.png`,alt:t.name,size:30,className:"object-contain rounded-lg max-w-[32px] max-h-[32px]",fallbackText:t.textIcon||t.id.slice(0,2).toUpperCase(),fallbackColor:t.color})}),(0,r.jsxs)("div",{className:"min-w-0",children:[(0,r.jsx)("h3",{className:"truncate font-semibold",children:t.name}),(0,r.jsx)("div",{className:"flex min-w-0 items-center gap-1.5 text-xs flex-wrap",children:x?(0,r.jsx)(n.Ex,{variant:"default",size:"sm",children:(0,r.jsxs)("span",{className:"flex items-center gap-1",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-[12px]",children:"pause_circle"}),"Disabled"]})}):u?(0,r.jsx)(n.Ex,{variant:"success",size:"sm",dot:!0,children:"Ready"}):(0,r.jsxs)(r.Fragment,{children:[y(i,d,c),p&&(0,r.jsx)("span",{className:"text-text-muted",children:p})]})})]})]}),(0,r.jsx)("div",{className:"flex shrink-0 items-center gap-2",children:s.total>0&&(0,r.jsx)("div",{className:"opacity-100 transition-opacity sm:opacity-0 sm:group-hover:opacity-100",onClick:e=>{e.preventDefault(),e.stopPropagation(),l(!!x)},children:(0,r.jsx)(n.lM,{size:"sm",checked:!x,onChange:()=>{},title:x?"Enable provider":"Disable provider"})})})]})})})}function w({providerId:e,provider:t,stats:s,authType:a,onToggle:l}){let{connected:i,error:d,errorCode:p,errorTime:x,allDisabled:u}=s,h=e.startsWith(c.JH),f=e.startsWith(c.DI);return(0,r.jsx)(m(),{href:`/dashboard/providers/${e}`,className:"group min-w-0",children:(0,r.jsx)(n.Zp,{padding:"xs",className:`h-full hover:bg-black/[0.01] dark:hover:bg-white/[0.01] transition-colors cursor-pointer ${u?"opacity-50":""}`,children:(0,r.jsxs)("div",{className:"flex min-w-0 items-center justify-between gap-3",children:[(0,r.jsxs)("div",{className:"flex min-w-0 items-center gap-3",children:[(0,r.jsx)("div",{className:"size-8 shrink-0 rounded-lg flex items-center justify-center",style:{backgroundColor:`${t.color?.length>7?t.color:t.color+"15"}`},children:(0,r.jsx)(o.A,{src:h?"responses"===t.apiType?"/providers/oai-r.png":"/providers/oai-cc.png":f?"/providers/anthropic-m.png":`/providers/${t.id}.png`,alt:t.name,size:30,className:"object-contain rounded-lg max-w-[30px] max-h-[30px]",fallbackText:t.textIcon||t.id.slice(0,2).toUpperCase(),fallbackColor:t.color})}),(0,r.jsxs)("div",{className:"min-w-0",children:[(0,r.jsx)("h3",{className:"truncate font-semibold",children:t.name}),(0,r.jsx)("div",{className:"flex min-w-0 items-center gap-1.5 text-xs flex-wrap",children:u?(0,r.jsx)(n.Ex,{variant:"default",size:"sm",children:(0,r.jsxs)("span",{className:"flex items-center gap-1",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-[12px]",children:"pause_circle"}),"Disabled"]})}):(0,r.jsxs)(r.Fragment,{children:[y(i,d,p),h&&(0,r.jsx)(n.Ex,{variant:"default",size:"sm",children:"responses"===t.apiType?"Responses":"Chat"}),f&&(0,r.jsx)(n.Ex,{variant:"default",size:"sm",children:"Messages"}),x&&(0,r.jsx)("span",{className:"text-text-muted",children:x})]})})]})]}),(0,r.jsx)("div",{className:"flex shrink-0 items-center gap-2",children:s.total>0&&(0,r.jsx)("div",{className:"opacity-100 transition-opacity sm:opacity-0 sm:group-hover:opacity-100",onClick:e=>{e.preventDefault(),e.stopPropagation(),l(!!u)},children:(0,r.jsx)(n.lM,{size:"sm",checked:!u,onChange:()=>{},title:u?"Enable provider":"Disable provider"})})})]})})})}function k({results:e}){if(e.error&&!e.results)return(0,r.jsxs)("div",{className:"text-center py-6",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-red-500 text-[32px] mb-2 block",children:"error"}),(0,r.jsx)("p",{className:"text-sm text-red-400",children:e.error})]});let{summary:t,mode:s}=e,a=e.results||[];return(0,r.jsxs)("div",{className:"flex min-w-0 flex-col gap-3",children:[t&&(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-2 text-xs mb-1 sm:gap-3",children:[(0,r.jsxs)("span",{className:"text-text-muted",children:[{oauth:"OAuth",free:"Free",apikey:"API Key",provider:"Provider",all:"All"}[s]||s," Test"]}),(0,r.jsxs)("span",{className:"px-2 py-0.5 rounded bg-emerald-500/15 text-emerald-400 font-medium",children:[t.passed," passed"]}),t.failed>0&&(0,r.jsxs)("span",{className:"px-2 py-0.5 rounded bg-red-500/15 text-red-400 font-medium",children:[t.failed," failed"]}),(0,r.jsxs)("span",{className:"text-text-muted sm:ml-auto",children:[t.total," tested"]})]}),a.map((e,t)=>(0,r.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-2 rounded-lg bg-black/[0.03] px-3 py-2 text-xs dark:bg-white/[0.03] sm:flex-nowrap",children:[(0,r.jsx)("span",{className:`material-symbols-outlined text-[16px] ${e.valid?"text-emerald-500":"text-red-500"}`,children:e.valid?"check_circle":"error"}),(0,r.jsxs)("div",{className:"min-w-0 flex-[1_1_160px]",children:[(0,r.jsx)("span",{className:"block truncate font-medium sm:inline",children:e.connectionName}),(0,r.jsxs)("span",{className:"block truncate text-text-muted sm:ml-1.5 sm:inline",children:["(",e.provider,")"]})]}),void 0!==e.latencyMs&&(0,r.jsxs)("span",{className:"shrink-0 text-text-muted font-mono tabular-nums",children:[e.latencyMs,"ms"]}),(0,r.jsx)("span",{className:`shrink-0 text-[10px] uppercase font-bold px-1.5 py-0.5 rounded ${e.valid?"bg-emerald-500/15 text-emerald-400":"bg-red-500/15 text-red-400"}`,children:e.valid?"OK":e.diagnosis?.type||"ERROR"})]},e.connectionId||t)),0===a.length&&(0,r.jsx)("div",{className:"text-center py-4 text-text-muted text-sm",children:"No active connections found for this group."})]})}v.propTypes={variant:i().oneOf(["openai","anthropic"]).isRequired,isOpen:i().bool.isRequired,onClose:i().func.isRequired,onCreated:i().func.isRequired},N.propTypes={providerId:i().string.isRequired,provider:i().shape({id:i().string.isRequired,name:i().string.isRequired,color:i().string,textIcon:i().string}).isRequired,stats:i().shape({connected:i().number,error:i().number,errorCode:i().string,errorTime:i().string}).isRequired,authType:i().string,onToggle:i().func},w.propTypes={providerId:i().string.isRequired,provider:i().shape({id:i().string.isRequired,name:i().string.isRequired,color:i().string,textIcon:i().string,apiType:i().string}).isRequired,stats:i().shape({connected:i().number,error:i().number,errorCode:i().string,errorTime:i().string}).isRequired,authType:i().string,onToggle:i().func},k.propTypes={results:i().shape({mode:i().string,results:i().array,summary:i().shape({total:i().number,passed:i().number,failed:i().number}),error:i().string}).isRequired}}},e=>{e.O(0,[2574,3862,817,5280,1321,705,5497,8441,3794,7358],()=>e(e.s=33150)),_N_E=e.O()}]);
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[8460],{33150:(e,t,s)=>{Promise.resolve().then(s.bind(s,97678))},97678:(e,t,s)=>{"use strict";s.r(t),s.d(t,{default:()=>j});var r=s(95155),a=s(12115),l=s(14051),i=s.n(l),n=s(35497),o=s(57250),d=s(90620),c=s(88105),p=s(98500),m=s.n(p),x=s(65921),u=s(38003);let h={available:{icon:"check_circle",color:"#22c55e",label:"Available"},cooldown:{icon:"schedule",color:"#f59e0b",label:"Cooldown"},unavailable:{icon:"error",color:"#ef4444",label:"Unavailable"},unknown:{icon:"help",color:"#6b7280",label:"Unknown"}};function f(){let[e,t]=(0,a.useState)(null),[s,l]=(0,a.useState)(!0),[i,o]=(0,a.useState)(!1),[d,c]=(0,a.useState)(null),p=(0,a.useRef)(null),m=(0,x.i)(),u=(0,a.useCallback)(async()=>{try{let e=await fetch("/api/models/availability");if(e.ok){let s=await e.json();t(s)}}catch{}finally{l(!1)}},[]);(0,a.useEffect)(()=>{u();let e=setInterval(u,3e4);return()=>clearInterval(e)},[u]),(0,a.useEffect)(()=>{let e=e=>{p.current&&!p.current.contains(e.target)&&o(!1)};return i&&document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[i]);let f=async(e,t)=>{c(`${e}:${t}`);try{(await fetch("/api/models/availability",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"clearCooldown",provider:e,model:t})})).ok?(m.success(`Cooldown cleared for ${t}`),await u()):m.error("Failed to clear cooldown")}catch{m.error("Failed to clear cooldown")}finally{c(null)}};if(s)return null;let g=e?.models||[],b=0===(e?.unavailableCount||g.filter(e=>"available"!==e.status).length),v={};return g.forEach(e=>{if("available"===e.status)return;let t=e.provider||"unknown";v[t]||(v[t]=[]),v[t].push(e)}),(0,r.jsx)("div",{className:"relative",ref:p,children:i&&(0,r.jsxs)("div",{className:"absolute top-full right-0 mt-2 w-80 bg-surface border border-border rounded-xl shadow-2xl z-50 overflow-hidden",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border bg-bg",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-[16px]",style:{color:b?"#22c55e":"#f59e0b"},children:b?"verified":"warning"}),(0,r.jsx)("span",{className:"text-sm font-semibold text-text-main",children:"Model Status"})]}),(0,r.jsx)("button",{onClick:u,className:"p-1 rounded-lg hover:bg-surface text-text-muted hover:text-text-main transition-colors",title:"Refresh",children:(0,r.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"refresh"})})]}),(0,r.jsx)("div",{className:"px-4 py-3 max-h-60 overflow-y-auto",children:b?(0,r.jsx)("p",{className:"text-sm text-text-muted text-center py-2",children:"All models are responding normally."}):(0,r.jsx)("div",{className:"flex flex-col gap-2.5",children:Object.entries(v).map(([e,t])=>(0,r.jsxs)("div",{children:[(0,r.jsx)("p",{className:"text-xs font-semibold text-text-main mb-1.5 capitalize",children:e}),(0,r.jsx)("div",{className:"flex flex-col gap-1",children:t.map(e=>{let t=h[e.status]||h.unknown,s=d===`${e.provider}:${e.model}`;return(0,r.jsxs)("div",{className:"flex items-center justify-between px-2.5 py-1.5 rounded-lg bg-surface/30",children:[(0,r.jsxs)("div",{className:"flex items-center gap-1.5 min-w-0",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-[14px] shrink-0",style:{color:t.color},children:t.icon}),(0,r.jsx)("span",{className:"font-mono text-xs text-text-main truncate",children:e.model})]}),"cooldown"===e.status&&(0,r.jsx)(n.$n,{size:"sm",variant:"ghost",onClick:()=>f(e.provider,e.model),disabled:s,className:"text-[10px] px-1.5! py-0.5! ml-2",children:s?"...":"Clear"})]},`${e.provider}-${e.model}`)})})]},e))})})]})})}let g={openai:{title:"Add OpenAI Compatible",type:"openai-compatible",defaultBaseUrl:"https://api.openai.com/v1",namePlaceholder:"OpenAI Compatible (Prod)",prefixPlaceholder:"oc-prod",baseUrlHint:"Use the base URL (ending in /v1) for your OpenAI-compatible API.",modelIdPlaceholder:"e.g. gpt-4, claude-3-opus",errorLabel:"OpenAI Compatible",hasApiType:!0},anthropic:{title:"Add Anthropic Compatible",type:"anthropic-compatible",defaultBaseUrl:"https://api.anthropic.com/v1",namePlaceholder:"Anthropic Compatible (Prod)",prefixPlaceholder:"ac-prod",baseUrlHint:"Use the base URL (ending in /v1) for your Anthropic-compatible API. The system will append /messages.",modelIdPlaceholder:"e.g. claude-3-opus",errorLabel:"Anthropic Compatible",hasApiType:!1}},b=[{value:"chat",label:"Chat Completions"},{value:"responses",label:"Responses API"}];function v({variant:e,isOpen:t,onClose:s,onCreated:l}){let i=g[e],o=()=>({name:"",prefix:"",...i.hasApiType?{apiType:"chat"}:{},baseUrl:i.defaultBaseUrl}),[d,c]=(0,a.useState)(o),[p,m]=(0,a.useState)(!1),[x,u]=(0,a.useState)(""),[h,f]=(0,a.useState)(""),[y,j]=(0,a.useState)(!1),[N,w]=(0,a.useState)(null);(0,a.useEffect)(()=>{i.hasApiType?c(e=>({...e,baseUrl:i.defaultBaseUrl})):t&&(w(null),u(""),f(""))},[i.hasApiType?d.apiType:t]);let k=async()=>{if(d.name.trim()&&d.prefix.trim()&&d.baseUrl.trim()){m(!0);try{let e=await fetch("/api/provider-nodes",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:d.name,prefix:d.prefix,...i.hasApiType?{apiType:d.apiType}:{},baseUrl:d.baseUrl,type:i.type})}),t=await e.json();e.ok&&(l(t.node),c(o()),u(""),w(null))}catch(e){console.log(`Error creating ${i.errorLabel} node:`,e)}finally{m(!1)}}},C=async()=>{j(!0);try{let e=await fetch("/api/provider-nodes/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:d.baseUrl,apiKey:x,type:i.type,modelId:h.trim()||void 0})}),t=await e.json();w(t)}catch{w({valid:!1,error:"Network error"})}finally{j(!1)}};return(0,r.jsx)(n.aF,{isOpen:t,title:i.title,onClose:s,children:(0,r.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,r.jsx)(n.pd,{label:"Name",value:d.name,onChange:e=>c({...d,name:e.target.value}),placeholder:i.namePlaceholder,hint:"Required. A friendly label for this node."}),(0,r.jsx)(n.pd,{label:"Prefix",value:d.prefix,onChange:e=>c({...d,prefix:e.target.value}),placeholder:i.prefixPlaceholder,hint:"Required. Used as the provider prefix for model IDs."}),i.hasApiType&&(0,r.jsx)(n.l6,{label:"API Type",options:b,value:d.apiType,onChange:e=>c({...d,apiType:e.target.value})}),(0,r.jsx)(n.pd,{label:"Base URL",value:d.baseUrl,onChange:e=>c({...d,baseUrl:e.target.value}),placeholder:i.defaultBaseUrl,hint:i.baseUrlHint}),(0,r.jsx)(n.pd,{label:"API Key (for Check)",type:"password",value:x,onChange:e=>u(e.target.value)}),(0,r.jsx)(n.pd,{label:"Model ID (optional)",value:h,onChange:e=>f(e.target.value),placeholder:i.modelIdPlaceholder,hint:"If provider lacks /models endpoint, enter a model ID to validate via chat/completions instead."}),(0,r.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center",children:[(0,r.jsx)(n.$n,{onClick:C,disabled:!x||y||!d.baseUrl.trim(),variant:"secondary",className:"w-full sm:w-auto",children:y?"Checking...":"Check"}),(()=>{if(!N)return null;let{valid:e,error:t,method:s}=N;return e?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(n.Ex,{variant:"success",children:"Valid"}),"chat"===s&&(0,r.jsx)("span",{className:"text-sm text-text-muted",children:"(via inference test)"})]}):(0,r.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,r.jsx)(n.Ex,{variant:"error",children:"Invalid"}),t&&(0,r.jsx)("span",{className:"text-sm text-red-500",children:t})]})})()]}),(0,r.jsxs)("div",{className:"flex flex-col gap-2 sm:flex-row",children:[(0,r.jsx)(n.$n,{onClick:k,fullWidth:!0,disabled:!d.name.trim()||!d.prefix.trim()||!d.baseUrl.trim()||p,children:p?"Creating...":"Create"}),(0,r.jsx)(n.$n,{onClick:s,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})})}function y(e,t,s){let a=[];if(e>0&&a.push((0,r.jsxs)(n.Ex,{variant:"success",size:"sm",dot:!0,children:[e," Connected"]},"connected")),t>0){let e=s?`${t} Error (${s})`:`${t} Error`;a.push((0,r.jsx)(n.Ex,{variant:"error",size:"sm",dot:!0,children:e},"error"))}return 0===a.length?(0,r.jsx)("span",{className:"text-text-muted",children:"No connections"}):a}function j(){let[e,t]=(0,a.useState)([]),[s,l]=(0,a.useState)([]),[i,o]=(0,a.useState)(!0),[p,m]=(0,a.useState)(!1),[h,g]=(0,a.useState)(!1),[b,y]=(0,a.useState)(!1),[j,C]=(0,a.useState)(null),[T,A]=(0,a.useState)(null),I=(0,x.i)(),$=(0,u.C)(e=>e.query),E=(0,u.C)(e=>e.register),P=(0,u.C)(e=>e.unregister);(0,a.useEffect)(()=>(E("Search providers..."),()=>P()),[E,P]);let O=e=>!$.trim()||e.toLowerCase().includes($.trim().toLowerCase()),R=(e,t)=>[...e].sort(([e,s],[r,a])=>{let l=s.priority??999,i=a.priority??999;if(l!==i)return l-i;let n=S(e,t),o=S(r,t),d=+(n.connected>0),c=+(o.connected>0);return d!==c?c-d:(s.name||"").localeCompare(a.name||"")});(0,a.useEffect)(()=>{(async()=>{try{let[e,s]=await Promise.all([fetch("/api/providers"),fetch("/api/provider-nodes")]),r=await e.json(),a=await s.json();e.ok&&t(r.connections||[]),s.ok&&l(a.nodes||[])}catch(e){console.log("Error fetching data:",e)}finally{o(!1)}})()},[]);let S=(t,s)=>{let r=Array.isArray(s)?s:[s],a=e.filter(e=>e.provider===t&&r.includes(e.authType)),l=e=>{let t=Object.entries(e).some(([e,t])=>e.startsWith("modelLock_")&&t&&new Date(t).getTime()>Date.now());return"unavailable"!==e.testStatus||t?e.testStatus:"active"},i=a.filter(e=>{let t=l(e);return"active"===t||"success"===t}).length,n=a.filter(e=>{let t=l(e);return"error"===t||"expired"===t||"unavailable"===t}),o=n.length,d=a.length,c=d>0&&a.every(e=>!1===e.isActive),p=n.sort((e,t)=>new Date(t.lastErrorAt||0)-new Date(e.lastErrorAt||0))[0];return{connected:i,error:o,total:d,errorCode:p?function(e){if(!e)return null;let t=e.lastErrorType;if("runtime_error"===t)return"RUNTIME";if("upstream_auth_error"===t||"auth_missing"===t||"token_refresh_failed"===t||"token_expired"===t)return"AUTH";if("upstream_rate_limited"===t)return"429";if("upstream_unavailable"===t)return"5XX";if("network_error"===t)return"NET";let s=Number(e.errorCode);if(Number.isFinite(s)&&s>=400)return String(s);let r=function(e){if(!e)return null;let t=e.match(/\b([45]\d{2})\b/);return t?t[1]:"ERR"}(e.lastError);if("401"===r||"403"===r)return"AUTH";if(r&&"ERR"!==r)return r;let a=(e.lastError||"").toLowerCase();return a.includes("runtime")||a.includes("not runnable")||a.includes("not installed")?"RUNTIME":a.includes("invalid api key")||a.includes("token invalid")||a.includes("revoked")||a.includes("unauthorized")?"AUTH":"ERR"}(p):null,errorTime:p?.lastErrorAt?function(e){if(!e)return"";let t=Math.floor((Date.now()-new Date(e).getTime())/6e4);if(t<1)return"just now";if(t<60)return`${t}m ago`;let s=Math.floor(t/60);if(s<24)return`${s}h ago`;let r=Math.floor(s/24);return`${r}d ago`}(p.lastErrorAt):null,allDisabled:c}},U=async(s,r,a)=>{let l=Array.isArray(r)?r:[r],i=e=>e.provider===s&&l.includes(e.authType),n=e.filter(i);t(e=>e.map(e=>i(e)?{...e,isActive:a}:e)),await Promise.allSettled(n.map(e=>fetch(`/api/providers/${e.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({isActive:a})})))},_=async(e,t=null)=>{if(!j){C("provider"===e?t:e),A(null);try{let s=await fetch("/api/providers/test-batch",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mode:e,providerId:t})}),r=await s.json();if(A(r),r.summary){let{passed:e,failed:t,total:s}=r.summary;0===t?I.success(`All ${s} tests passed`):I.warning(`${e}/${s} passed, ${t} failed`)}}catch(e){A({error:"Test request failed"}),I.error("Provider test failed")}finally{C(null)}}},z=s.filter(e=>"openai-compatible"===e.type).map(e=>({id:e.id,name:e.name||"OpenAI Compatible",color:"#10A37F",textIcon:"OC",apiType:e.apiType})).filter(e=>O(e.name)),q=s.filter(e=>"anthropic-compatible"===e.type).map(e=>({id:e.id,name:e.name||"Anthropic Compatible",color:"#D97757",textIcon:"AC"})).filter(e=>O(e.name)),D=R(Object.entries(d.zN).filter(([,e])=>!e.hidden&&O(e.name)),"oauth"),F=Object.entries(c.IS).filter(([,e])=>!e.hidden&&O(e.name)).sort(([,e],[,t])=>!!t.noAuth-!!e.noAuth),L=R(Object.entries(c.nJ).filter(([,e])=>!e.hidden&&O(e.name)&&(e.serviceKinds??["llm"]).includes("llm")),"freeTier").sort(([,e],[,t])=>!!t.noAuth-!!e.noAuth),M=Object.entries(d.fg).filter(([,e])=>!e.hidden&&(e.serviceKinds??["llm"]).includes("llm")&&O(e.name)).sort(([e,t],[s,r])=>{let a=S(e,"apikey").total>0?0:1,l=S(s,"apikey").total>0?0:1;return a!==l?a-l:(t.name||"").localeCompare(r.name||"")}),K=!!$.trim(),H=K||p?M:M.slice(0,20),J=M.length-20;if(i)return(0,r.jsxs)("div",{className:"flex flex-col gap-8",children:[(0,r.jsx)(n.Qv,{}),(0,r.jsx)(n.Qv,{})]});let B=D.length>0||F.length>0||L.length>0||M.length>0||z.length>0||q.length>0;return(0,r.jsxs)("div",{className:"flex min-w-0 flex-col gap-6 px-1 sm:px-0",children:[!B&&(0,r.jsxs)("div",{className:"text-center py-8 border border-dashed border-border rounded-xl",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-[32px] text-text-muted mb-2",children:"search_off"}),(0,r.jsx)("p",{className:"text-text-muted text-sm",children:"No providers match your search"})]}),(0,r.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,r.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[(0,r.jsxs)("h2",{className:"text-lg sm:text-xl font-semibold flex items-center gap-2 leading-tight",children:["Custom Providers (OpenAI/Anthropic Compatible)"," "]}),(0,r.jsxs)("div",{className:"grid grid-cols-1 gap-2 sm:flex sm:w-auto",children:[(0,r.jsx)(n.$n,{size:"sm",icon:"add",onClick:()=>y(!0),className:"w-full sm:w-auto",children:"Add Anthropic Compatible"}),(0,r.jsx)(n.$n,{size:"sm",variant:"secondary",icon:"add",onClick:()=>g(!0),className:"w-full !bg-white !text-black hover:!bg-gray-100 sm:w-auto",children:"Add OpenAI Compatible"})]})]}),0===z.length&&0===q.length?(0,r.jsxs)("div",{className:"flex items-center justify-center gap-2 py-2 border border-dashed border-border rounded-xl text-text-muted text-sm",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"extension"}),(0,r.jsx)("span",{children:"No custom providers — use buttons above to add OpenAI/Anthropic compatible endpoints"})]}):(0,r.jsx)("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2 sm:gap-4 lg:grid-cols-3 xl:grid-cols-4",children:[...z,...q].map(e=>(0,r.jsx)(w,{providerId:e.id,provider:e,stats:S(e.id,"apikey"),authType:"compatible",onToggle:t=>U(e.id,"apikey",t)},e.id))})]}),D.length>0&&(0,r.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,r.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[(0,r.jsx)("h2",{className:"text-lg sm:text-xl font-semibold flex items-center gap-2 leading-tight",children:"OAuth Providers"}),(0,r.jsxs)("div",{className:"flex w-full flex-col gap-2 sm:w-auto sm:flex-row sm:items-center",children:[(0,r.jsx)(f,{}),(0,r.jsxs)("button",{onClick:()=>_("oauth"),disabled:!!j,className:`flex w-full items-center justify-center gap-1.5 rounded-lg border px-3 py-2 text-xs font-medium transition-colors sm:w-auto sm:py-1.5 ${"oauth"===j?"bg-primary/20 border-primary/40 text-primary animate-pulse":"bg-bg border-border text-text-muted hover:text-text-main hover:border-primary/40"}`,title:"Test all OAuth connections","aria-label":"Test all OAuth connections",children:[(0,r.jsx)("span",{className:`material-symbols-outlined text-[14px]${"oauth"===j?" animate-spin":""}`,children:"play_arrow"}),"oauth"===j?"Testing...":"Test All"]})]})]}),(0,r.jsx)("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2 sm:gap-4 lg:grid-cols-3 xl:grid-cols-4",children:D.map(([e,t])=>(0,r.jsx)(N,{providerId:e,provider:t,stats:S(e,"oauth"),authType:"oauth",onToggle:t=>U(e,"oauth",t)},e))})]}),(F.length>0||L.length>0)&&(0,r.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,r.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[(0,r.jsx)("h2",{className:"text-lg sm:text-xl font-semibold flex items-center gap-2 leading-tight",children:"Free Tier Providers"}),(0,r.jsxs)("button",{onClick:()=>_("free"),disabled:!!j,className:`flex w-full items-center justify-center gap-1.5 rounded-lg border px-3 py-2 text-xs font-medium transition-colors sm:w-auto sm:py-1.5 ${"free"===j?"bg-primary/20 border-primary/40 text-primary animate-pulse":"bg-bg border-border text-text-muted hover:text-text-main hover:border-primary/40"}`,title:"Test all Free connections","aria-label":"Test all Free provider connections",children:[(0,r.jsx)("span",{className:`material-symbols-outlined text-[14px]${"free"===j?" animate-spin":""}`,children:"play_arrow"}),"free"===j?"Testing...":"Test All"]})]}),(0,r.jsxs)("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2 sm:gap-4 lg:grid-cols-3 xl:grid-cols-4",children:[F.map(([e,t])=>{let s="kiro"===e?["oauth","apikey","api_key"]:"oauth";return(0,r.jsx)(N,{providerId:e,provider:t,stats:S(e,s),authType:"free",onToggle:t=>U(e,s,t)},e)}),L.map(([e,t])=>(0,r.jsx)(w,{providerId:e,provider:t,stats:S(e,"apikey"),authType:"apikey",onToggle:t=>U(e,"apikey",t)},e))]})]}),M.length>0&&(0,r.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,r.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[(0,r.jsxs)("h2",{className:"text-lg sm:text-xl font-semibold flex items-center gap-2 leading-tight",children:["API Key Providers"," "]}),(0,r.jsxs)("button",{onClick:()=>_("apikey"),disabled:!!j,className:`flex w-full items-center justify-center gap-1.5 rounded-lg border px-3 py-2 text-xs font-medium transition-colors sm:w-auto sm:py-1.5 ${"apikey"===j?"bg-primary/20 border-primary/40 text-primary animate-pulse":"bg-bg border-border text-text-muted hover:text-text-main hover:border-primary/40"}`,title:"Test all API Key connections","aria-label":"Test all API Key connections",children:[(0,r.jsx)("span",{className:`material-symbols-outlined text-[14px]${"apikey"===j?" animate-spin":""}`,children:"play_arrow"}),"apikey"===j?"Testing...":"Test All"]})]}),(0,r.jsx)("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2 sm:gap-4 lg:grid-cols-3 xl:grid-cols-4",children:H.map(([e,t])=>(0,r.jsx)(w,{providerId:e,provider:t,stats:S(e,"apikey"),authType:"apikey",onToggle:t=>U(e,"apikey",t)},e))}),!K&&!p&&J>0&&(0,r.jsxs)("button",{onClick:()=>m(!0),className:"flex w-full items-center justify-center gap-1.5 rounded-lg border border-dashed border-primary/40 px-3 py-2.5 text-sm font-medium text-primary transition-colors hover:border-primary hover:bg-primary/5",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"expand_more"}),"Show all ",M.length," providers"]})]}),(0,r.jsx)(v,{variant:"openai",isOpen:h,onClose:()=>g(!1),onCreated:e=>{l(t=>[...t,e]),g(!1)}}),(0,r.jsx)(v,{variant:"anthropic",isOpen:b,onClose:()=>y(!1),onCreated:e=>{l(t=>[...t,e]),y(!1)}}),T&&(0,r.jsxs)("div",{className:"fixed inset-0 z-50 flex items-start justify-center px-3 pt-[6vh] sm:pt-[10vh]",onClick:()=>A(null),children:[(0,r.jsx)("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm"}),(0,r.jsxs)("div",{className:"relative bg-surface border border-border rounded-xl w-full max-w-[600px] max-h-[86vh] sm:max-h-[80vh] overflow-y-auto shadow-2xl",onClick:e=>e.stopPropagation(),children:[(0,r.jsxs)("div",{className:"sticky top-0 z-10 flex items-center justify-between px-5 py-3 border-b border-border bg-surface/95 backdrop-blur-sm rounded-t-xl",children:[(0,r.jsx)("h3",{className:"font-semibold",children:"Test Results"}),(0,r.jsx)("button",{onClick:()=>A(null),className:"p-1 rounded-lg hover:bg-bg text-text-muted hover:text-text-main transition-colors","aria-label":"Close test results",children:(0,r.jsx)("span",{className:"material-symbols-outlined text-lg",children:"close"})})]}),(0,r.jsx)("div",{className:"p-5",children:(0,r.jsx)(k,{results:T})})]})]})]})}function N({providerId:e,provider:t,stats:s,authType:a,onToggle:l}){let{connected:i,error:d,errorCode:c,errorTime:p,allDisabled:x}=s,u=!!t.noAuth;return(0,r.jsx)(m(),{href:`/dashboard/providers/${e}`,className:"group min-w-0",children:(0,r.jsx)(n.Zp,{padding:"xs",className:`h-full hover:bg-black/[0.01] dark:hover:bg-white/[0.01] transition-colors cursor-pointer ${x?"opacity-50":""}`,children:(0,r.jsxs)("div",{className:"flex min-w-0 items-center justify-between gap-3",children:[(0,r.jsxs)("div",{className:"flex min-w-0 items-center gap-3",children:[(0,r.jsx)("div",{className:"size-8 shrink-0 rounded-lg flex items-center justify-center",style:{backgroundColor:`${t.color?.length>7?t.color:t.color+"15"}`},children:(0,r.jsx)(o.A,{src:`/providers/${t.id}.png`,alt:t.name,size:30,className:"object-contain rounded-lg max-w-[32px] max-h-[32px]",fallbackText:t.textIcon||t.id.slice(0,2).toUpperCase(),fallbackColor:t.color})}),(0,r.jsxs)("div",{className:"min-w-0",children:[(0,r.jsx)("h3",{className:"truncate font-semibold",children:t.name}),(0,r.jsx)("div",{className:"flex min-w-0 items-center gap-1.5 text-xs flex-wrap",children:x?(0,r.jsx)(n.Ex,{variant:"default",size:"sm",children:(0,r.jsxs)("span",{className:"flex items-center gap-1",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-[12px]",children:"pause_circle"}),"Disabled"]})}):u?(0,r.jsx)(n.Ex,{variant:"success",size:"sm",dot:!0,children:"Ready"}):(0,r.jsxs)(r.Fragment,{children:[y(i,d,c),p&&(0,r.jsx)("span",{className:"text-text-muted",children:p})]})})]})]}),(0,r.jsx)("div",{className:"flex shrink-0 items-center gap-2",children:s.total>0&&(0,r.jsx)("div",{className:"opacity-100 transition-opacity sm:opacity-0 sm:group-hover:opacity-100",onClick:e=>{e.preventDefault(),e.stopPropagation(),l(!!x)},children:(0,r.jsx)(n.lM,{size:"sm",checked:!x,onChange:()=>{},title:x?"Enable provider":"Disable provider"})})})]})})})}function w({providerId:e,provider:t,stats:s,authType:a,onToggle:l}){let{connected:i,error:d,errorCode:p,errorTime:x,allDisabled:u}=s,h=e.startsWith(c.JH),f=e.startsWith(c.DI);return(0,r.jsx)(m(),{href:`/dashboard/providers/${e}`,className:"group min-w-0",children:(0,r.jsx)(n.Zp,{padding:"xs",className:`h-full hover:bg-black/[0.01] dark:hover:bg-white/[0.01] transition-colors cursor-pointer ${u?"opacity-50":""}`,children:(0,r.jsxs)("div",{className:"flex min-w-0 items-center justify-between gap-3",children:[(0,r.jsxs)("div",{className:"flex min-w-0 items-center gap-3",children:[(0,r.jsx)("div",{className:"size-8 shrink-0 rounded-lg flex items-center justify-center",style:{backgroundColor:`${t.color?.length>7?t.color:t.color+"15"}`},children:(0,r.jsx)(o.A,{src:h?"responses"===t.apiType?"/providers/oai-r.png":"/providers/oai-cc.png":f?"/providers/anthropic-m.png":`/providers/${t.id}.png`,alt:t.name,size:30,className:"object-contain rounded-lg max-w-[30px] max-h-[30px]",fallbackText:t.textIcon||t.id.slice(0,2).toUpperCase(),fallbackColor:t.color})}),(0,r.jsxs)("div",{className:"min-w-0",children:[(0,r.jsx)("h3",{className:"truncate font-semibold",children:t.name}),(0,r.jsx)("div",{className:"flex min-w-0 items-center gap-1.5 text-xs flex-wrap",children:u?(0,r.jsx)(n.Ex,{variant:"default",size:"sm",children:(0,r.jsxs)("span",{className:"flex items-center gap-1",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-[12px]",children:"pause_circle"}),"Disabled"]})}):(0,r.jsxs)(r.Fragment,{children:[y(i,d,p),h&&(0,r.jsx)(n.Ex,{variant:"default",size:"sm",children:"responses"===t.apiType?"Responses":"Chat"}),f&&(0,r.jsx)(n.Ex,{variant:"default",size:"sm",children:"Messages"}),x&&(0,r.jsx)("span",{className:"text-text-muted",children:x})]})})]})]}),(0,r.jsx)("div",{className:"flex shrink-0 items-center gap-2",children:s.total>0&&(0,r.jsx)("div",{className:"opacity-100 transition-opacity sm:opacity-0 sm:group-hover:opacity-100",onClick:e=>{e.preventDefault(),e.stopPropagation(),l(!!u)},children:(0,r.jsx)(n.lM,{size:"sm",checked:!u,onChange:()=>{},title:u?"Enable provider":"Disable provider"})})})]})})})}function k({results:e}){if(e.error&&!e.results)return(0,r.jsxs)("div",{className:"text-center py-6",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-red-500 text-[32px] mb-2 block",children:"error"}),(0,r.jsx)("p",{className:"text-sm text-red-400",children:e.error})]});let{summary:t,mode:s}=e,a=e.results||[];return(0,r.jsxs)("div",{className:"flex min-w-0 flex-col gap-3",children:[t&&(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-2 text-xs mb-1 sm:gap-3",children:[(0,r.jsxs)("span",{className:"text-text-muted",children:[{oauth:"OAuth",free:"Free",apikey:"API Key",provider:"Provider",all:"All"}[s]||s," Test"]}),(0,r.jsxs)("span",{className:"px-2 py-0.5 rounded bg-emerald-500/15 text-emerald-400 font-medium",children:[t.passed," passed"]}),t.failed>0&&(0,r.jsxs)("span",{className:"px-2 py-0.5 rounded bg-red-500/15 text-red-400 font-medium",children:[t.failed," failed"]}),(0,r.jsxs)("span",{className:"text-text-muted sm:ml-auto",children:[t.total," tested"]})]}),a.map((e,t)=>(0,r.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-2 rounded-lg bg-black/[0.03] px-3 py-2 text-xs dark:bg-white/[0.03] sm:flex-nowrap",children:[(0,r.jsx)("span",{className:`material-symbols-outlined text-[16px] ${e.valid?"text-emerald-500":"text-red-500"}`,children:e.valid?"check_circle":"error"}),(0,r.jsxs)("div",{className:"min-w-0 flex-[1_1_160px]",children:[(0,r.jsx)("span",{className:"block truncate font-medium sm:inline",children:e.connectionName}),(0,r.jsxs)("span",{className:"block truncate text-text-muted sm:ml-1.5 sm:inline",children:["(",e.provider,")"]})]}),void 0!==e.latencyMs&&(0,r.jsxs)("span",{className:"shrink-0 text-text-muted font-mono tabular-nums",children:[e.latencyMs,"ms"]}),(0,r.jsx)("span",{className:`shrink-0 text-[10px] uppercase font-bold px-1.5 py-0.5 rounded ${e.valid?"bg-emerald-500/15 text-emerald-400":"bg-red-500/15 text-red-400"}`,children:e.valid?"OK":e.diagnosis?.type||"ERROR"})]},e.connectionId||t)),0===a.length&&(0,r.jsx)("div",{className:"text-center py-4 text-text-muted text-sm",children:"No active connections found for this group."})]})}v.propTypes={variant:i().oneOf(["openai","anthropic"]).isRequired,isOpen:i().bool.isRequired,onClose:i().func.isRequired,onCreated:i().func.isRequired},N.propTypes={providerId:i().string.isRequired,provider:i().shape({id:i().string.isRequired,name:i().string.isRequired,color:i().string,textIcon:i().string}).isRequired,stats:i().shape({connected:i().number,error:i().number,errorCode:i().string,errorTime:i().string}).isRequired,authType:i().string,onToggle:i().func},w.propTypes={providerId:i().string.isRequired,provider:i().shape({id:i().string.isRequired,name:i().string.isRequired,color:i().string,textIcon:i().string,apiType:i().string}).isRequired,stats:i().shape({connected:i().number,error:i().number,errorCode:i().string,errorTime:i().string}).isRequired,authType:i().string,onToggle:i().func},k.propTypes={results:i().shape({mode:i().string,results:i().array,summary:i().shape({total:i().number,passed:i().number,failed:i().number}),error:i().string}).isRequired}}},e=>{e.O(0,[2574,3862,817,5280,1321,705,5497,8441,3794,7358],()=>e(e.s=33150)),_N_E=e.O()}]);
@@ -1 +1 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[3826],{75095:(e,t,r)=>{"use strict";r.d(t,{default:()=>D});var a=r(95155),s=r(12115),i=r(57250),n=r(89563);let l="quotaCacheData",o="quotaAutoRefresh",c=[10,20,50,100],d=[{value:"all",label:"All accounts"},{value:"active",label:"Active"},{value:"inactive",label:"Turned off"}],u=[{value:"default",label:"Default quota order"},{value:"remaining-asc",label:"% quota: low to high"},{value:"remaining-desc",label:"% quota: high to low"}];function m(e){return e.name?.trim()||e.email?.trim()||e.displayName?.trim()||null}function x(e,t){let r=t[e.id]?.quotas?.[0];return r&&"number"==typeof r.remaining?r.remaining:1/0}function h(e){let t={};return e.forEach(e=>{t[e.id]=!0}),t}function p(e,t){let r=new Set(t.map(e=>e.id));return Object.fromEntries(Object.entries(e).filter(([e])=>r.has(e)))}async function b(e,t){return await e(t)}function g(){try{let e=window.localStorage.getItem(l);return e?JSON.parse(e):{}}catch(e){return console.error("Error reading quota cache:",e),{}}}function f(e,t){try{let r=g();r[e]={...t,cachedAt:new Date().toISOString()},window.localStorage.setItem(l,JSON.stringify(r))}catch(e){console.error("Error writing quota cache:",e)}}function y(e,t){return t&&0!==t?!e||e<0?100:e>=t?0:Math.round((t-e)/t*100):0}function v({quotas:e=[],compact:t=!1,sortMode:r="default",showSortLabel:i=!1}){let[n,l]=(0,s.useState)(1),o=(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):y(e?.used,e?.total)})),[e]),c=(0,s.useMemo)(()=>"remaining-asc"===r?[...o].sort((e,t)=>e.remaining-t.remaining||e.name.localeCompare(t.name)):"remaining-desc"===r?[...o].sort((e,t)=>t.remaining-e.remaining||e.name.localeCompare(t.name)):o,[o,r]),d=Math.max(1,Math.ceil(c.length/10));if((0,s.useEffect)(()=>{l(1)},[r,e]),(0,s.useEffect)(()=>{l(e=>Math.min(e,d))},[d]),!e||0===e.length)return null;let u=c.slice((n-1)*10,10*n),m=0===c.length?0:(n-1)*10+1,x=Math.min(10*n,c.length),h=t?"py-1 px-1.5":"py-2 px-3",p=t?"text-[11px]":"text-sm",b=t?"text-[11px]":"text-sm",g=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:[c.length," quota",c.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:u.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),n=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),l=!1!==e.recurring?`in ${i}`:`expires in ${i}`;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:`${h} w-[30%]`,children:(0,a.jsxs)("div",{className:"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:`${p} font-medium text-text-primary truncate`,children:e.name})]})}),(0,a.jsx)("td",{className:`${h} 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.jsxs)("span",{className:"text-text-muted",children:[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:`${h} w-[25%]`,children:"-"!==i||n?t?(0,a.jsx)("div",{className:`${b} text-text-primary font-medium truncate`,title:n||"",children:"-"!==i?l:n}):(0,a.jsxs)("div",{className:"space-y-0.5",children:["-"!==i&&(0,a.jsx)("div",{className:`${b} text-text-primary font-medium`,children:l}),n&&(0,a.jsx)("div",{className:`${g} text-text-muted`,children:n})]}):(0,a.jsx)("div",{className:`${b} text-text-muted italic`,children:"N/A"})})]},`${e.name}-${e.index}`)})})})}),d>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 ",m,"-",x," of ",c.length]}),(0,a.jsxs)("span",{children:["Page ",n," / ",d]})]}),(0,a.jsxs)("div",{className:"mt-1.5 flex items-center justify-end gap-1",children:[(0,a.jsx)("button",{type:"button",onClick:()=>l(e=>Math.max(1,e-1)),disabled:1===n,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:()=>l(e=>Math.min(d,e+1)),disabled:n===d,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 k=r(98542),j=r(97677),w=r(84588),N=r(35497),C=r(81095),S=r(11059);let $={"builder-id":"AWS Builder ID",idc:"IAM Identity Center",google:"Google",github:"GitHub",imported:"Imported Token",api_key:"API Key"},A={claude:"claudeAutoPing",codex:"codexAutoPing"},P={claude:"When your 5h quota runs out, auto-sends a request the moment it resets so a new window starts right away.",codex:"Auto-starts the next 5h Codex window after reset by sending a tiny gpt-5.5 request. Consumes a small amount of quota."};function q(e){return e.name?.trim()&&e.email?.trim()&&e.name.trim()!==e.email.trim()?e.email.trim():e.name?.trim()&&e.displayName?.trim()&&e.name.trim()!==e.displayName.trim()?e.displayName.trim():null}function E(e){let t=e.providerSpecificData?.region;if(t)return t;let r=e.providerSpecificData?.profileArn;return("string"==typeof r?r.split(":")[3]:"")||""}function D(){let{copied:e,copy:t}=(0,S.C)(),[r,D]=(0,s.useState)([]),[M,T]=(0,s.useState)({}),[O,I]=(0,s.useState)({}),[_,F]=(0,s.useState)({}),[L,z]=(0,s.useState)(!0),[R,U]=(0,s.useState)({claude:{},codex:{}}),[J,K]=(0,s.useState)(null),[G,H]=(0,s.useState)(!1),[B,W]=(0,s.useState)(!1),[Y,Q]=(0,s.useState)(60),[V,X]=(0,s.useState)(!0),[Z,ee]=(0,s.useState)(null),[et,er]=(0,s.useState)(null),[ea,es]=(0,s.useState)(null),[ei,en]=(0,s.useState)(null),[el,eo]=(0,s.useState)(!1),[ec,ed]=(0,s.useState)(null),[eu,em]=(0,s.useState)([]),[ex,eh]=(0,s.useState)("all"),[ep,eb]=(0,s.useState)([]),[eg,ef]=(0,s.useState)("all"),[ey,ev]=(0,s.useState)("default"),[ek,ej]=(0,s.useState)(!1),[ew,eN]=(0,s.useState)(!1),[eC,eS]=(0,s.useState)(!1),[e$,eA]=(0,s.useState)(1),[eP,eq]=(0,s.useState)(20),[eE,eD]=(0,s.useState)(String(20)),[eM,eT]=(0,s.useState)({page:1,pageSize:20,total:0,totalPages:1}),[eO,eI]=(0,s.useState)({eligibleConnections:0,providerFilteredConnections:0}),e_=(0,s.useRef)(null),eF=(0,s.useRef)(null),eL=(0,s.useRef)(0),ez=(0,s.useCallback)(async(e=e$)=>{try{var t,r;let a=new URLSearchParams({page:String(e),pageSize:String(eP),accountStatus:eg,sort:"priority"});"all"!==ex&&a.set("provider",ex);let s=await fetch(`/api/providers/client?${a.toString()}`);if(!s.ok)throw Error("Failed to fetch connections");let i=await s.json(),n=i.connections||[],l=(t=i.pagination,t||{page:1,pageSize:eP,total:0,totalPages:1}),o=function(e,t=0){return e||{eligibleConnections:t,providerFilteredConnections:t}}(i.totals,n.length);return D(n),eb(i.providerOptions||[]),eT(l),eI(o),eA((r=i.pagination,r?.page||e)),n}catch(e){return console.error("Error fetching connections:",e),D([]),eb([]),eT({page:1,pageSize:eP,total:0,totalPages:1}),eI({eligibleConnections:0,providerFilteredConnections:0}),[]}},[eg,ek,e$,eP,ex]),eR=(0,s.useCallback)(async(e,t)=>{I(t=>({...t,[e]:!0})),F(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=>({...t,[e]:r})),f(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})});break;case"codebuddy-cn":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,recurring:!1!==t.recurring})})}}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=>({...t,[e]:s})),f(e,s)}catch(r){console.error(`[ProviderLimits] Error fetching quota for ${t} (${e}):`,r),F(t=>({...t,[e]:r.message||"Failed to fetch quota"}))}finally{I(t=>({...t,[e]:!1}))}},[]),eU=(0,s.useCallback)(async(e,t)=>{await eR(e,t),K(new Date)},[eR]),eJ=(0,s.useCallback)(async(e,t)=>{if("codex"===t&&!ea){es(e),F(t=>({...t,[e]:null}));try{let r=await fetch(`/api/usage/${e}/codex-reset-credits`,{method:"POST"}),a=await r.json().catch(()=>({}));if(!r.ok)throw Error(a.message||a.error||a.code||"Failed to reset Codex limit");await eR(e,t),K(new Date)}catch(t){F(r=>({...r,[e]:t.message||"Failed to reset Codex limit"}))}finally{es(null)}}},[eR,ea]),eK=(0,s.useCallback)(async e=>{if(confirm("Delete this connection?")){ee(e);try{if((await fetch(`/api/providers/${e}`,{method:"DELETE"})).ok){T(t=>{let r={...t};return delete r[e],r}),I(t=>{let r={...t};return delete r[e],r}),F(t=>{let r={...t};return delete r[e],r});try{let t=g();t[e]&&(delete t[e],window.localStorage.setItem(l,JSON.stringify(t)))}catch(e){console.error("Error deleting cache entry:",e)}await b(ez,e$)}}catch(e){console.error("Error deleting connection:",e)}finally{ee(null)}}},[ez,e$]),eG=(0,s.useCallback)(async(e,t)=>{er(e);try{(await fetch(`/api/providers/${e}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({isActive:t})})).ok&&(T(e=>({...e})),await b(ez,e$))}catch(e){console.error("Error updating connection status:",e)}finally{er(null)}},[ez,e$]),eH=(0,s.useCallback)(async e=>{if(!ec?.id)return;let t=ec.id,r=ec.provider;try{(await fetch(`/api/providers/${t}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})).ok&&(await ez(),eo(!1),ed(null),C.wb.includes(r)&&await eR(t,r))}catch(e){console.error("Error saving connection:",e)}},[ec,ez,eR]);(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&&em(t.proxyPools)}).catch(()=>{}),()=>{e=!0}},[]);let eB=(0,s.useCallback)(async(e=!1)=>{if(B)return;W(!0),Q(60);let t=eL.current+=1,r=Math.round(3);try{let a=await ez(e$);I(h(a)),F(e=>p(e,a)),T(e=>p(e,a)),await Promise.all(a.filter(a=>e||"claude"!==a.provider||t%r==0).map(e=>eR(e.id,e.provider))),K(new Date)}catch(e){console.error("Error refreshing all providers:",e)}finally{W(!1)}},[B,ez,eR,e$]);(0,s.useEffect)(()=>{(async()=>{X(!0);let e=await ez(e$);X(!1),I(h(e)),F(t=>p(t,e)),T(t=>p(t,e)),await Promise.all(e.map(e=>eR(e.id,e.provider))),K(new Date)})()},[ez,eR,e$]),(0,s.useEffect)(()=>{let e=window.localStorage.getItem(o);z(null===e||"true"===e),H(!0)},[]),(0,s.useEffect)(()=>{G&&window.localStorage.setItem(o,String(L))},[L,G]),(0,s.useEffect)(()=>{fetch("/api/settings",{cache:"no-store"}).then(e=>e.ok?e.json():{}).then(e=>U({claude:e?.claudeAutoPing?.connections||{},codex:e?.codexAutoPing?.connections||{}})).catch(()=>{})},[]);let eW=(0,s.useCallback)(async(e,t,r)=>{let a=A[t];if(!a)return;let s={...R[t]||{},[e]:r};U({...R,[t]:s});try{let e=await fetch("/api/settings",{cache:"no-store"}),t={...(e.ok?await e.json():{})[a]||{},connections:s};await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({[a]:t})})}catch{U(R)}},[R]);(0,s.useEffect)(()=>{if(!G||!L){e_.current&&(clearInterval(e_.current),e_.current=null),eF.current&&(clearInterval(eF.current),eF.current=null);return}return e_.current=setInterval(()=>{eB()},6e4),eF.current=setInterval(()=>{Q(e=>e<=1?60:e-1)},1e3),()=>{e_.current&&clearInterval(e_.current),eF.current&&clearInterval(eF.current)}},[L,eB,G]),(0,s.useEffect)(()=>{let e=()=>{document.hidden?(e_.current&&(clearInterval(e_.current),e_.current=null),eF.current&&(clearInterval(eF.current),eF.current=null)):L&&G&&(e_.current=setInterval(()=>eB(),6e4),eF.current=setInterval(()=>{Q(e=>e<=1?60:e-1)},1e3))};return document.addEventListener("visibilitychange",e),()=>{document.removeEventListener("visibilitychange",e)}},[L,eB,G]);let eY=(0,s.useMemo)(()=>(function(e,t,r,a,s){if("codex"===a&&"default"!==s)return[...e].sort((e,r)=>{let a=x(e,t),i=x(r,t),n="remaining-asc"===s?a-i:i-a;return 0!==n?n:(m(e)||"").localeCompare(m(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||"")||(m(e)||"").localeCompare(m(t)||"")})})(r,M,ek,ex,ey),[r,M,ek,ex,ey]),eQ=e=>{let t=M[e.id]?.quotas;return!!t?.length&&t.some(e=>!!e.total&&!(e.total<=0)&&5>=y(e.used,e.total))},eV=(0,s.useCallback)(async(e,t)=>{if(e.length&&!eC){eS(!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 b(ez,e$)}catch(e){console.error("Error bulk toggling connections:",e)}finally{eS(!1)}}},[eC,ez,e$]),eX="all"===ex?"All providers":ex,eZ=eO.eligibleConnections>0,e0=eY.length>0,e1=eO.eligibleConnections?eO.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"===ex?"Try changing the account status filter to see more quota trackers.":`No ${"inactive"===eg?"turned off":"active"===eg?"active":"matching"} accounts found for ${ex}.`}:{icon:"cloud_off",title:"No Providers Connected",description:"Connect to providers with OAuth to track your API quota limits and usage."},e5=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}`}(eM),e2=!c.includes(eP);return V||eZ?V||e0?(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:()=>eN(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":ew,title:"Filter quota providers",children:[(0,a.jsxs)("span",{className:"flex min-w-0 items-center gap-1.5",children:["all"===ex?(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px] text-text-muted",children:"apps"}):(0,a.jsx)(i.A,{src:`/providers/${ex}.png`,alt:ex,size:18,className:"size-[18px] rounded object-contain",fallbackText:ex.slice(0,2).toUpperCase()}),(0,a.jsx)("span",{className:"truncate capitalize hidden lg:inline",children:eX})]}),(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px] text-text-muted",children:"expand_more"})]}),ew&&(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:()=>eN(!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"!==ex&&eA(1),eh("all"),eN(!1)},className:`flex w-full items-center gap-3 rounded-xl px-3 py-2.5 text-left text-sm transition-colors ${"all"===ex?"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"===ex&&(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:ep.map(e=>(0,a.jsxs)("button",{type:"button",onClick:()=>{ex!==e&&eA(1),eh(e),eN(!1)},className:`flex w-full items-center gap-3 rounded-xl px-3 py-2.5 text-left text-sm transition-colors ${ex===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}),ex===e&&(0,a.jsx)("span",{className:"material-symbols-outlined ml-auto text-[20px]",children:"check"})]},e))})]})]})]}),(0,a.jsx)("select",{value:eg,onChange:e=>{let t=e.target.value;eg!==t&&eA(1),ef(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:d.map(e=>(0,a.jsx)("option",{value:e.value,children:e.label},e.value))}),"codex"===ex&&(0,a.jsx)("select",{value:ey,onChange:e=>ev(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:u.map(e=>(0,a.jsx)("option",{value:e.value,children:e.label},e.value))}),(0,a.jsxs)("button",{type:"button",onClick:()=>ej(e=>!e),"aria-pressed":ek,className:`flex h-8 shrink-0 items-center gap-1 rounded-lg border px-2 text-xs transition-colors ${ek?"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:()=>{eV(eY.filter(e=>(e.isActive??!0)&&eQ(e)).map(e=>e.id),!1)},disabled:eC,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:()=>{eV(eY.filter(e=>!(e.isActive??!0)&&!eQ(e)).map(e=>e.id),!0)},disabled:eC,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:()=>z(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:L?"Disable auto-refresh":"Enable auto-refresh",children:[(0,a.jsx)("span",{className:`material-symbols-outlined text-[14px] ${L?"text-primary":"text-text-muted"}`,children:L?"toggle_on":"toggle_off"}),(0,a.jsx)("span",{className:"hidden text-text-primary sm:inline",children:"Auto-refresh"}),L&&(0,a.jsxs)("span",{className:"text-[10px] text-text-muted tabular-nums",children:["(",Y,"s)"]})]}),(0,a.jsx)("button",{type:"button",onClick:()=>eB(!0),disabled:B,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] ${B?"animate-spin":""}`,children:"refresh"})})]})}),ek&&(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:eY.map(r=>{let s,n,l,o=M[r.id],c=O[r.id],d=_[r.id],u=!1===r.isActive,x="codex"===r.provider,h=Number.isFinite(n="number"==typeof(s=o?.raw?.resetCredits?.availableCount)?s:Number(s))?Math.max(0,n):0,p=ea===r.id,b=Z===r.id||et===r.id||p;return(0,a.jsxs)(w.default,{padding:"none",className:`min-w-0 ${u?"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/${r.provider}.png`,alt:r.provider,size:32,className:"object-contain",fallbackText:r.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:r.provider}),m(r)?(0,a.jsx)("p",{className:"text-xs text-text-muted truncate",children:m(r)}):null,q(r)?(0,a.jsx)("p",{className:"text-[11px] text-text-muted/80 truncate",children:q(r)}):null,"kiro"===r.provider&&(0,a.jsxs)("div",{className:"mt-1 flex flex-wrap items-center gap-1",children:[(0,a.jsx)("span",{className:"rounded-full bg-brand-500/10 px-2 py-0.5 text-[10px] font-semibold text-brand-600 dark:text-brand-300",children:(l=r.providerSpecificData?.authMethod)&&$[l]?$[l]:"api_key"===r.authType?"API Key":"OAuth"}),E(r)&&(0,a.jsx)("span",{className:"rounded-full bg-blue-500/10 px-2 py-0.5 text-[10px] font-semibold text-blue-600 dark:text-blue-400",children:E(r)}),(0,a.jsx)("span",{className:`rounded-full px-2 py-0.5 text-[10px] font-semibold ${u?"bg-surface-2 text-text-muted":"active"===r.testStatus||"success"===r.testStatus?"bg-green-500/10 text-green-600 dark:text-green-400":"error"===r.testStatus||"expired"===r.testStatus||"unavailable"===r.testStatus?"bg-red-500/10 text-red-600 dark:text-red-400":"bg-surface-2 text-text-muted"}`,children:u?"disabled":r.testStatus||"unknown"}),r.providerSpecificData?.profileArn&&(0,a.jsxs)("button",{type:"button",onClick:()=>t(r.providerSpecificData.profileArn,r.id),title:r.providerSpecificData.profileArn,className:"inline-flex max-w-full items-center gap-1 rounded-full border border-border-subtle px-2 py-0.5 text-[10px] text-text-muted transition-colors hover:text-primary",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[12px]",children:e===r.id?"check":"content_copy"}),(0,a.jsx)("code",{className:"truncate font-mono",children:r.providerSpecificData.profileArn})]})]})]})]}),(0,a.jsxs)("div",{className:"flex items-center gap-1 shrink-0",children:[x&&(0,a.jsx)(j.default,{text:h>0?`Use one Codex reset credit. Available: ${h}`:"No Codex reset credits available",children:(0,a.jsxs)("button",{type:"button",onClick:()=>en({connection:r,resetCreditCount:h}),disabled:h<=0||c||b,"aria-label":h>0?`Use one Codex reset credit. ${h} available.`:"No Codex reset credits available",className:`flex h-8 min-w-10 items-center justify-center gap-1 rounded-lg border px-2 text-[11px] font-medium tabular-nums transition-colors focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary/60 disabled:cursor-not-allowed disabled:opacity-60 ${h>0?"border-primary/30 bg-primary/5 text-primary hover:bg-primary/10":"border-black/10 bg-black/[0.02] text-text-muted dark:border-white/10 dark:bg-white/[0.03]"}`,children:[(0,a.jsx)("span",{className:`material-symbols-outlined text-[15px] ${p?"animate-spin":""}`,children:p?"progress_activity":"restart_alt"}),(0,a.jsx)("span",{children:h})]})}),A[r.provider]&&"oauth"===r.authType&&(0,a.jsx)(j.default,{text:P[r.provider],children:(0,a.jsx)("button",{type:"button",onClick:()=>eW(r.id,r.provider,R[r.provider]?.[r.id]!==!0),"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 ${R[r.provider]?.[r.id]===!0?"text-primary":"text-text-muted"}`,children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"bolt"})})}),(0,a.jsx)(j.default,{text:"Refresh quota",children:(0,a.jsx)("button",{type:"button",onClick:()=>eU(r.id,r.provider),disabled:c||b,"aria-label":"Refresh quota",className:"flex h-8 w-8 items-center justify-center rounded-lg hover:bg-black/5 dark:hover:bg-white/5 transition-colors disabled:opacity-50",children:(0,a.jsx)("span",{className:`material-symbols-outlined text-[18px] text-text-muted ${c?"animate-spin":""}`,children:"refresh"})})}),(0,a.jsx)(j.default,{text:"Edit connection",children:(0,a.jsx)("button",{type:"button",onClick:()=>{ed(r),eo(!0)},disabled:b,"aria-label":"Edit connection",className:"flex h-8 w-8 items-center justify-center rounded-lg hover:bg-black/5 dark:hover:bg-white/5 text-text-muted hover:text-primary transition-colors disabled:opacity-50",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"edit"})})}),(0,a.jsx)(j.default,{text:"Delete connection",children:(0,a.jsx)("button",{type:"button",onClick:()=>eK(r.id),disabled:b,"aria-label":"Delete connection",className:"flex h-8 w-8 items-center justify-center rounded-lg hover:bg-red-500/10 text-red-500 transition-colors disabled:opacity-50",children:(0,a.jsx)("span",{className:`material-symbols-outlined text-[18px] ${Z===r.id?"animate-pulse":""}`,children:"delete"})})}),(0,a.jsx)("div",{className:"inline-flex items-center pl-0.5",title:r.isActive??!0?"Disable connection":"Enable connection",children:(0,a.jsx)(k.default,{size:"sm",checked:r.isActive??!0,disabled:b,onChange:e=>eG(r.id,e)})})]})]})}),(0,a.jsx)("div",{className:"px-2 py-1.5",children:c?(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"})}):d?(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:d})]}):o?.message?(0,a.jsx)("div",{className:"text-center py-5",children:(0,a.jsx)("p",{className:"text-xs text-text-muted",children:o.message})}):(0,a.jsx)(v,{quotas:o?.quotas,compact:!0,sortMode:"default",showSortLabel:"codex"===r.provider&&"default"!==ey})})]},r.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:e5}),(0,a.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,a.jsxs)("select",{value:e2?"custom":String(eP),onChange:e=>{let t=e.target.value;if("custom"===t)return;let r=Number.parseInt(t,10);Number.isFinite(r)&&(eA(1),eq(r),eD(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:eE,onChange:e=>eD(e.target.value),onBlur:()=>{let e=Number.parseInt(eE,10);if(!Number.isFinite(e))return void eD(String(eP));let t=Math.min(500,Math.max(1,e));eA(1),eq(t),eD(String(t))},onKeyDown:e=>{if("Enter"!==e.key)return;let t=Number.parseInt(eE,10);if(!Number.isFinite(t))return void eD(String(eP));let r=Math.min(500,Math.max(1,t));eA(1),eq(r),eD(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 ",eM.page," / ",eM.totalPages]})]}),(0,a.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,a.jsx)("button",{type:"button",onClick:()=>eA(1),disabled:eM.page<=1||V||B,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:()=>eA(e=>Math.max(1,e-1)),disabled:eM.page<=1||V||B,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:()=>eA(e=>Math.min(eM.totalPages,e+1)),disabled:eM.page>=eM.totalPages||V||B,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:()=>eA(eM.totalPages),disabled:eM.page>=eM.totalPages||V||B,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)(N.uo,{isOpen:!!ei,onClose:()=>{ea||en(null)},onConfirm:async()=>{let e=ei?.connection;e&&(await eJ(e.id,e.provider),en(null))},title:"Reset Codex limit?",message:`Use 1 Codex reset credit for ${m(ei?.connection||{})||"this account"}. This cannot be undone. Remaining credits: ${ei?.resetCreditCount??0}.`,confirmText:"Reset limit",cancelText:"Cancel",variant:"danger",loading:!!ea}),(0,a.jsx)(N.wI,{isOpen:el,connection:ec,proxyPools:eu,onSave:eH,onClose:()=>{eo(!1),ed(null)}})]}):(0,a.jsx)(w.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:e1.icon}),(0,a.jsx)("h3",{className:"mt-4 text-lg font-semibold text-text-primary",children:e1.title}),(0,a.jsx)("p",{className:"mt-2 text-sm text-text-muted max-w-md mx-auto",children:e1.description})]})}):(0,a.jsx)(w.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."})]})})}},99398:(e,t,r)=>{Promise.resolve().then(r.bind(r,75095)),Promise.resolve().then(r.bind(r,25086))}},e=>{e.O(0,[2574,3862,817,5280,1321,705,5497,8441,3794,7358],()=>e(e.s=99398)),_N_E=e.O()}]);
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[3826],{75095:(e,t,r)=>{"use strict";r.d(t,{default:()=>D});var a=r(95155),s=r(12115),i=r(57250),n=r(36508);let l="quotaCacheData",o="quotaAutoRefresh",c=[10,20,50,100],d=[{value:"all",label:"All accounts"},{value:"active",label:"Active"},{value:"inactive",label:"Turned off"}],u=[{value:"default",label:"Default quota order"},{value:"remaining-asc",label:"% quota: low to high"},{value:"remaining-desc",label:"% quota: high to low"}];function m(e){return e.name?.trim()||e.email?.trim()||e.displayName?.trim()||null}function x(e,t){let r=t[e.id]?.quotas?.[0];return r&&"number"==typeof r.remaining?r.remaining:1/0}function h(e){let t={};return e.forEach(e=>{t[e.id]=!0}),t}function p(e,t){let r=new Set(t.map(e=>e.id));return Object.fromEntries(Object.entries(e).filter(([e])=>r.has(e)))}async function b(e,t){return await e(t)}function g(){try{let e=window.localStorage.getItem(l);return e?JSON.parse(e):{}}catch(e){return console.error("Error reading quota cache:",e),{}}}function f(e,t){try{let r=g();r[e]={...t,cachedAt:new Date().toISOString()},window.localStorage.setItem(l,JSON.stringify(r))}catch(e){console.error("Error writing quota cache:",e)}}function y(e,t){return t&&0!==t?!e||e<0?100:e>=t?0:Math.round((t-e)/t*100):0}function v({quotas:e=[],compact:t=!1,sortMode:r="default",showSortLabel:i=!1}){let[n,l]=(0,s.useState)(1),o=(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):y(e?.used,e?.total)})),[e]),c=(0,s.useMemo)(()=>"remaining-asc"===r?[...o].sort((e,t)=>e.remaining-t.remaining||e.name.localeCompare(t.name)):"remaining-desc"===r?[...o].sort((e,t)=>t.remaining-e.remaining||e.name.localeCompare(t.name)):o,[o,r]),d=Math.max(1,Math.ceil(c.length/10));if((0,s.useEffect)(()=>{l(1)},[r,e]),(0,s.useEffect)(()=>{l(e=>Math.min(e,d))},[d]),!e||0===e.length)return null;let u=c.slice((n-1)*10,10*n),m=0===c.length?0:(n-1)*10+1,x=Math.min(10*n,c.length),h=t?"py-1 px-1.5":"py-2 px-3",p=t?"text-[11px]":"text-sm",b=t?"text-[11px]":"text-sm",g=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:[c.length," quota",c.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:u.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),n=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),l=!1!==e.recurring?`in ${i}`:`expires in ${i}`;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:`${h} w-[30%]`,children:(0,a.jsxs)("div",{className:"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:`${p} font-medium text-text-primary truncate`,children:e.name})]})}),(0,a.jsx)("td",{className:`${h} 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.jsxs)("span",{className:"text-text-muted",children:[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:`${h} w-[25%]`,children:"-"!==i||n?t?(0,a.jsx)("div",{className:`${b} text-text-primary font-medium truncate`,title:n||"",children:"-"!==i?l:n}):(0,a.jsxs)("div",{className:"space-y-0.5",children:["-"!==i&&(0,a.jsx)("div",{className:`${b} text-text-primary font-medium`,children:l}),n&&(0,a.jsx)("div",{className:`${g} text-text-muted`,children:n})]}):(0,a.jsx)("div",{className:`${b} text-text-muted italic`,children:"N/A"})})]},`${e.name}-${e.index}`)})})})}),d>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 ",m,"-",x," of ",c.length]}),(0,a.jsxs)("span",{children:["Page ",n," / ",d]})]}),(0,a.jsxs)("div",{className:"mt-1.5 flex items-center justify-end gap-1",children:[(0,a.jsx)("button",{type:"button",onClick:()=>l(e=>Math.max(1,e-1)),disabled:1===n,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:()=>l(e=>Math.min(d,e+1)),disabled:n===d,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 k=r(98542),j=r(97677),w=r(84588),N=r(35497),C=r(88105),S=r(11059);let $={"builder-id":"AWS Builder ID",idc:"IAM Identity Center",google:"Google",github:"GitHub",imported:"Imported Token",api_key:"API Key"},A={claude:"claudeAutoPing",codex:"codexAutoPing"},P={claude:"When your 5h quota runs out, auto-sends a request the moment it resets so a new window starts right away.",codex:"Auto-starts the next 5h Codex window after reset by sending a tiny gpt-5.5 request. Consumes a small amount of quota."};function q(e){return e.name?.trim()&&e.email?.trim()&&e.name.trim()!==e.email.trim()?e.email.trim():e.name?.trim()&&e.displayName?.trim()&&e.name.trim()!==e.displayName.trim()?e.displayName.trim():null}function E(e){let t=e.providerSpecificData?.region;if(t)return t;let r=e.providerSpecificData?.profileArn;return("string"==typeof r?r.split(":")[3]:"")||""}function D(){let{copied:e,copy:t}=(0,S.C)(),[r,D]=(0,s.useState)([]),[M,T]=(0,s.useState)({}),[O,I]=(0,s.useState)({}),[_,F]=(0,s.useState)({}),[L,z]=(0,s.useState)(!0),[R,U]=(0,s.useState)({claude:{},codex:{}}),[J,K]=(0,s.useState)(null),[G,H]=(0,s.useState)(!1),[B,W]=(0,s.useState)(!1),[Y,Q]=(0,s.useState)(60),[V,X]=(0,s.useState)(!0),[Z,ee]=(0,s.useState)(null),[et,er]=(0,s.useState)(null),[ea,es]=(0,s.useState)(null),[ei,en]=(0,s.useState)(null),[el,eo]=(0,s.useState)(!1),[ec,ed]=(0,s.useState)(null),[eu,em]=(0,s.useState)([]),[ex,eh]=(0,s.useState)("all"),[ep,eb]=(0,s.useState)([]),[eg,ef]=(0,s.useState)("all"),[ey,ev]=(0,s.useState)("default"),[ek,ej]=(0,s.useState)(!1),[ew,eN]=(0,s.useState)(!1),[eC,eS]=(0,s.useState)(!1),[e$,eA]=(0,s.useState)(1),[eP,eq]=(0,s.useState)(20),[eE,eD]=(0,s.useState)(String(20)),[eM,eT]=(0,s.useState)({page:1,pageSize:20,total:0,totalPages:1}),[eO,eI]=(0,s.useState)({eligibleConnections:0,providerFilteredConnections:0}),e_=(0,s.useRef)(null),eF=(0,s.useRef)(null),eL=(0,s.useRef)(0),ez=(0,s.useCallback)(async(e=e$)=>{try{var t,r;let a=new URLSearchParams({page:String(e),pageSize:String(eP),accountStatus:eg,sort:"priority"});"all"!==ex&&a.set("provider",ex);let s=await fetch(`/api/providers/client?${a.toString()}`);if(!s.ok)throw Error("Failed to fetch connections");let i=await s.json(),n=i.connections||[],l=(t=i.pagination,t||{page:1,pageSize:eP,total:0,totalPages:1}),o=function(e,t=0){return e||{eligibleConnections:t,providerFilteredConnections:t}}(i.totals,n.length);return D(n),eb(i.providerOptions||[]),eT(l),eI(o),eA((r=i.pagination,r?.page||e)),n}catch(e){return console.error("Error fetching connections:",e),D([]),eb([]),eT({page:1,pageSize:eP,total:0,totalPages:1}),eI({eligibleConnections:0,providerFilteredConnections:0}),[]}},[eg,ek,e$,eP,ex]),eR=(0,s.useCallback)(async(e,t)=>{I(t=>({...t,[e]:!0})),F(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=>({...t,[e]:r})),f(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})});break;case"codebuddy-cn":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,recurring:!1!==t.recurring})})}}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=>({...t,[e]:s})),f(e,s)}catch(r){console.error(`[ProviderLimits] Error fetching quota for ${t} (${e}):`,r),F(t=>({...t,[e]:r.message||"Failed to fetch quota"}))}finally{I(t=>({...t,[e]:!1}))}},[]),eU=(0,s.useCallback)(async(e,t)=>{await eR(e,t),K(new Date)},[eR]),eJ=(0,s.useCallback)(async(e,t)=>{if("codex"===t&&!ea){es(e),F(t=>({...t,[e]:null}));try{let r=await fetch(`/api/usage/${e}/codex-reset-credits`,{method:"POST"}),a=await r.json().catch(()=>({}));if(!r.ok)throw Error(a.message||a.error||a.code||"Failed to reset Codex limit");await eR(e,t),K(new Date)}catch(t){F(r=>({...r,[e]:t.message||"Failed to reset Codex limit"}))}finally{es(null)}}},[eR,ea]),eK=(0,s.useCallback)(async e=>{if(confirm("Delete this connection?")){ee(e);try{if((await fetch(`/api/providers/${e}`,{method:"DELETE"})).ok){T(t=>{let r={...t};return delete r[e],r}),I(t=>{let r={...t};return delete r[e],r}),F(t=>{let r={...t};return delete r[e],r});try{let t=g();t[e]&&(delete t[e],window.localStorage.setItem(l,JSON.stringify(t)))}catch(e){console.error("Error deleting cache entry:",e)}await b(ez,e$)}}catch(e){console.error("Error deleting connection:",e)}finally{ee(null)}}},[ez,e$]),eG=(0,s.useCallback)(async(e,t)=>{er(e);try{(await fetch(`/api/providers/${e}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({isActive:t})})).ok&&(T(e=>({...e})),await b(ez,e$))}catch(e){console.error("Error updating connection status:",e)}finally{er(null)}},[ez,e$]),eH=(0,s.useCallback)(async e=>{if(!ec?.id)return;let t=ec.id,r=ec.provider;try{(await fetch(`/api/providers/${t}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})).ok&&(await ez(),eo(!1),ed(null),C.wb.includes(r)&&await eR(t,r))}catch(e){console.error("Error saving connection:",e)}},[ec,ez,eR]);(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&&em(t.proxyPools)}).catch(()=>{}),()=>{e=!0}},[]);let eB=(0,s.useCallback)(async(e=!1)=>{if(B)return;W(!0),Q(60);let t=eL.current+=1,r=Math.round(3);try{let a=await ez(e$);I(h(a)),F(e=>p(e,a)),T(e=>p(e,a)),await Promise.all(a.filter(a=>e||"claude"!==a.provider||t%r==0).map(e=>eR(e.id,e.provider))),K(new Date)}catch(e){console.error("Error refreshing all providers:",e)}finally{W(!1)}},[B,ez,eR,e$]);(0,s.useEffect)(()=>{(async()=>{X(!0);let e=await ez(e$);X(!1),I(h(e)),F(t=>p(t,e)),T(t=>p(t,e)),await Promise.all(e.map(e=>eR(e.id,e.provider))),K(new Date)})()},[ez,eR,e$]),(0,s.useEffect)(()=>{let e=window.localStorage.getItem(o);z(null===e||"true"===e),H(!0)},[]),(0,s.useEffect)(()=>{G&&window.localStorage.setItem(o,String(L))},[L,G]),(0,s.useEffect)(()=>{fetch("/api/settings",{cache:"no-store"}).then(e=>e.ok?e.json():{}).then(e=>U({claude:e?.claudeAutoPing?.connections||{},codex:e?.codexAutoPing?.connections||{}})).catch(()=>{})},[]);let eW=(0,s.useCallback)(async(e,t,r)=>{let a=A[t];if(!a)return;let s={...R[t]||{},[e]:r};U({...R,[t]:s});try{let e=await fetch("/api/settings",{cache:"no-store"}),t={...(e.ok?await e.json():{})[a]||{},connections:s};await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({[a]:t})})}catch{U(R)}},[R]);(0,s.useEffect)(()=>{if(!G||!L){e_.current&&(clearInterval(e_.current),e_.current=null),eF.current&&(clearInterval(eF.current),eF.current=null);return}return e_.current=setInterval(()=>{eB()},6e4),eF.current=setInterval(()=>{Q(e=>e<=1?60:e-1)},1e3),()=>{e_.current&&clearInterval(e_.current),eF.current&&clearInterval(eF.current)}},[L,eB,G]),(0,s.useEffect)(()=>{let e=()=>{document.hidden?(e_.current&&(clearInterval(e_.current),e_.current=null),eF.current&&(clearInterval(eF.current),eF.current=null)):L&&G&&(e_.current=setInterval(()=>eB(),6e4),eF.current=setInterval(()=>{Q(e=>e<=1?60:e-1)},1e3))};return document.addEventListener("visibilitychange",e),()=>{document.removeEventListener("visibilitychange",e)}},[L,eB,G]);let eY=(0,s.useMemo)(()=>(function(e,t,r,a,s){if("codex"===a&&"default"!==s)return[...e].sort((e,r)=>{let a=x(e,t),i=x(r,t),n="remaining-asc"===s?a-i:i-a;return 0!==n?n:(m(e)||"").localeCompare(m(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||"")||(m(e)||"").localeCompare(m(t)||"")})})(r,M,ek,ex,ey),[r,M,ek,ex,ey]),eQ=e=>{let t=M[e.id]?.quotas;return!!t?.length&&t.some(e=>!!e.total&&!(e.total<=0)&&5>=y(e.used,e.total))},eV=(0,s.useCallback)(async(e,t)=>{if(e.length&&!eC){eS(!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 b(ez,e$)}catch(e){console.error("Error bulk toggling connections:",e)}finally{eS(!1)}}},[eC,ez,e$]),eX="all"===ex?"All providers":ex,eZ=eO.eligibleConnections>0,e0=eY.length>0,e1=eO.eligibleConnections?eO.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"===ex?"Try changing the account status filter to see more quota trackers.":`No ${"inactive"===eg?"turned off":"active"===eg?"active":"matching"} accounts found for ${ex}.`}:{icon:"cloud_off",title:"No Providers Connected",description:"Connect to providers with OAuth to track your API quota limits and usage."},e5=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}`}(eM),e2=!c.includes(eP);return V||eZ?V||e0?(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:()=>eN(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":ew,title:"Filter quota providers",children:[(0,a.jsxs)("span",{className:"flex min-w-0 items-center gap-1.5",children:["all"===ex?(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px] text-text-muted",children:"apps"}):(0,a.jsx)(i.A,{src:`/providers/${ex}.png`,alt:ex,size:18,className:"size-[18px] rounded object-contain",fallbackText:ex.slice(0,2).toUpperCase()}),(0,a.jsx)("span",{className:"truncate capitalize hidden lg:inline",children:eX})]}),(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px] text-text-muted",children:"expand_more"})]}),ew&&(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:()=>eN(!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"!==ex&&eA(1),eh("all"),eN(!1)},className:`flex w-full items-center gap-3 rounded-xl px-3 py-2.5 text-left text-sm transition-colors ${"all"===ex?"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"===ex&&(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:ep.map(e=>(0,a.jsxs)("button",{type:"button",onClick:()=>{ex!==e&&eA(1),eh(e),eN(!1)},className:`flex w-full items-center gap-3 rounded-xl px-3 py-2.5 text-left text-sm transition-colors ${ex===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}),ex===e&&(0,a.jsx)("span",{className:"material-symbols-outlined ml-auto text-[20px]",children:"check"})]},e))})]})]})]}),(0,a.jsx)("select",{value:eg,onChange:e=>{let t=e.target.value;eg!==t&&eA(1),ef(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:d.map(e=>(0,a.jsx)("option",{value:e.value,children:e.label},e.value))}),"codex"===ex&&(0,a.jsx)("select",{value:ey,onChange:e=>ev(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:u.map(e=>(0,a.jsx)("option",{value:e.value,children:e.label},e.value))}),(0,a.jsxs)("button",{type:"button",onClick:()=>ej(e=>!e),"aria-pressed":ek,className:`flex h-8 shrink-0 items-center gap-1 rounded-lg border px-2 text-xs transition-colors ${ek?"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:()=>{eV(eY.filter(e=>(e.isActive??!0)&&eQ(e)).map(e=>e.id),!1)},disabled:eC,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:()=>{eV(eY.filter(e=>!(e.isActive??!0)&&!eQ(e)).map(e=>e.id),!0)},disabled:eC,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:()=>z(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:L?"Disable auto-refresh":"Enable auto-refresh",children:[(0,a.jsx)("span",{className:`material-symbols-outlined text-[14px] ${L?"text-primary":"text-text-muted"}`,children:L?"toggle_on":"toggle_off"}),(0,a.jsx)("span",{className:"hidden text-text-primary sm:inline",children:"Auto-refresh"}),L&&(0,a.jsxs)("span",{className:"text-[10px] text-text-muted tabular-nums",children:["(",Y,"s)"]})]}),(0,a.jsx)("button",{type:"button",onClick:()=>eB(!0),disabled:B,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] ${B?"animate-spin":""}`,children:"refresh"})})]})}),ek&&(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:eY.map(r=>{let s,n,l,o=M[r.id],c=O[r.id],d=_[r.id],u=!1===r.isActive,x="codex"===r.provider,h=Number.isFinite(n="number"==typeof(s=o?.raw?.resetCredits?.availableCount)?s:Number(s))?Math.max(0,n):0,p=ea===r.id,b=Z===r.id||et===r.id||p;return(0,a.jsxs)(w.default,{padding:"none",className:`min-w-0 ${u?"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/${r.provider}.png`,alt:r.provider,size:32,className:"object-contain",fallbackText:r.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:r.provider}),m(r)?(0,a.jsx)("p",{className:"text-xs text-text-muted truncate",children:m(r)}):null,q(r)?(0,a.jsx)("p",{className:"text-[11px] text-text-muted/80 truncate",children:q(r)}):null,"kiro"===r.provider&&(0,a.jsxs)("div",{className:"mt-1 flex flex-wrap items-center gap-1",children:[(0,a.jsx)("span",{className:"rounded-full bg-brand-500/10 px-2 py-0.5 text-[10px] font-semibold text-brand-600 dark:text-brand-300",children:(l=r.providerSpecificData?.authMethod)&&$[l]?$[l]:"api_key"===r.authType?"API Key":"OAuth"}),E(r)&&(0,a.jsx)("span",{className:"rounded-full bg-blue-500/10 px-2 py-0.5 text-[10px] font-semibold text-blue-600 dark:text-blue-400",children:E(r)}),(0,a.jsx)("span",{className:`rounded-full px-2 py-0.5 text-[10px] font-semibold ${u?"bg-surface-2 text-text-muted":"active"===r.testStatus||"success"===r.testStatus?"bg-green-500/10 text-green-600 dark:text-green-400":"error"===r.testStatus||"expired"===r.testStatus||"unavailable"===r.testStatus?"bg-red-500/10 text-red-600 dark:text-red-400":"bg-surface-2 text-text-muted"}`,children:u?"disabled":r.testStatus||"unknown"}),r.providerSpecificData?.profileArn&&(0,a.jsxs)("button",{type:"button",onClick:()=>t(r.providerSpecificData.profileArn,r.id),title:r.providerSpecificData.profileArn,className:"inline-flex max-w-full items-center gap-1 rounded-full border border-border-subtle px-2 py-0.5 text-[10px] text-text-muted transition-colors hover:text-primary",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[12px]",children:e===r.id?"check":"content_copy"}),(0,a.jsx)("code",{className:"truncate font-mono",children:r.providerSpecificData.profileArn})]})]})]})]}),(0,a.jsxs)("div",{className:"flex items-center gap-1 shrink-0",children:[x&&(0,a.jsx)(j.default,{text:h>0?`Use one Codex reset credit. Available: ${h}`:"No Codex reset credits available",children:(0,a.jsxs)("button",{type:"button",onClick:()=>en({connection:r,resetCreditCount:h}),disabled:h<=0||c||b,"aria-label":h>0?`Use one Codex reset credit. ${h} available.`:"No Codex reset credits available",className:`flex h-8 min-w-10 items-center justify-center gap-1 rounded-lg border px-2 text-[11px] font-medium tabular-nums transition-colors focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary/60 disabled:cursor-not-allowed disabled:opacity-60 ${h>0?"border-primary/30 bg-primary/5 text-primary hover:bg-primary/10":"border-black/10 bg-black/[0.02] text-text-muted dark:border-white/10 dark:bg-white/[0.03]"}`,children:[(0,a.jsx)("span",{className:`material-symbols-outlined text-[15px] ${p?"animate-spin":""}`,children:p?"progress_activity":"restart_alt"}),(0,a.jsx)("span",{children:h})]})}),A[r.provider]&&"oauth"===r.authType&&(0,a.jsx)(j.default,{text:P[r.provider],children:(0,a.jsx)("button",{type:"button",onClick:()=>eW(r.id,r.provider,R[r.provider]?.[r.id]!==!0),"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 ${R[r.provider]?.[r.id]===!0?"text-primary":"text-text-muted"}`,children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"bolt"})})}),(0,a.jsx)(j.default,{text:"Refresh quota",children:(0,a.jsx)("button",{type:"button",onClick:()=>eU(r.id,r.provider),disabled:c||b,"aria-label":"Refresh quota",className:"flex h-8 w-8 items-center justify-center rounded-lg hover:bg-black/5 dark:hover:bg-white/5 transition-colors disabled:opacity-50",children:(0,a.jsx)("span",{className:`material-symbols-outlined text-[18px] text-text-muted ${c?"animate-spin":""}`,children:"refresh"})})}),(0,a.jsx)(j.default,{text:"Edit connection",children:(0,a.jsx)("button",{type:"button",onClick:()=>{ed(r),eo(!0)},disabled:b,"aria-label":"Edit connection",className:"flex h-8 w-8 items-center justify-center rounded-lg hover:bg-black/5 dark:hover:bg-white/5 text-text-muted hover:text-primary transition-colors disabled:opacity-50",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"edit"})})}),(0,a.jsx)(j.default,{text:"Delete connection",children:(0,a.jsx)("button",{type:"button",onClick:()=>eK(r.id),disabled:b,"aria-label":"Delete connection",className:"flex h-8 w-8 items-center justify-center rounded-lg hover:bg-red-500/10 text-red-500 transition-colors disabled:opacity-50",children:(0,a.jsx)("span",{className:`material-symbols-outlined text-[18px] ${Z===r.id?"animate-pulse":""}`,children:"delete"})})}),(0,a.jsx)("div",{className:"inline-flex items-center pl-0.5",title:r.isActive??!0?"Disable connection":"Enable connection",children:(0,a.jsx)(k.default,{size:"sm",checked:r.isActive??!0,disabled:b,onChange:e=>eG(r.id,e)})})]})]})}),(0,a.jsx)("div",{className:"px-2 py-1.5",children:c?(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"})}):d?(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:d})]}):o?.message?(0,a.jsx)("div",{className:"text-center py-5",children:(0,a.jsx)("p",{className:"text-xs text-text-muted",children:o.message})}):(0,a.jsx)(v,{quotas:o?.quotas,compact:!0,sortMode:"default",showSortLabel:"codex"===r.provider&&"default"!==ey})})]},r.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:e5}),(0,a.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,a.jsxs)("select",{value:e2?"custom":String(eP),onChange:e=>{let t=e.target.value;if("custom"===t)return;let r=Number.parseInt(t,10);Number.isFinite(r)&&(eA(1),eq(r),eD(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:eE,onChange:e=>eD(e.target.value),onBlur:()=>{let e=Number.parseInt(eE,10);if(!Number.isFinite(e))return void eD(String(eP));let t=Math.min(500,Math.max(1,e));eA(1),eq(t),eD(String(t))},onKeyDown:e=>{if("Enter"!==e.key)return;let t=Number.parseInt(eE,10);if(!Number.isFinite(t))return void eD(String(eP));let r=Math.min(500,Math.max(1,t));eA(1),eq(r),eD(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 ",eM.page," / ",eM.totalPages]})]}),(0,a.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,a.jsx)("button",{type:"button",onClick:()=>eA(1),disabled:eM.page<=1||V||B,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:()=>eA(e=>Math.max(1,e-1)),disabled:eM.page<=1||V||B,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:()=>eA(e=>Math.min(eM.totalPages,e+1)),disabled:eM.page>=eM.totalPages||V||B,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:()=>eA(eM.totalPages),disabled:eM.page>=eM.totalPages||V||B,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)(N.uo,{isOpen:!!ei,onClose:()=>{ea||en(null)},onConfirm:async()=>{let e=ei?.connection;e&&(await eJ(e.id,e.provider),en(null))},title:"Reset Codex limit?",message:`Use 1 Codex reset credit for ${m(ei?.connection||{})||"this account"}. This cannot be undone. Remaining credits: ${ei?.resetCreditCount??0}.`,confirmText:"Reset limit",cancelText:"Cancel",variant:"danger",loading:!!ea}),(0,a.jsx)(N.wI,{isOpen:el,connection:ec,proxyPools:eu,onSave:eH,onClose:()=>{eo(!1),ed(null)}})]}):(0,a.jsx)(w.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:e1.icon}),(0,a.jsx)("h3",{className:"mt-4 text-lg font-semibold text-text-primary",children:e1.title}),(0,a.jsx)("p",{className:"mt-2 text-sm text-text-muted max-w-md mx-auto",children:e1.description})]})}):(0,a.jsx)(w.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."})]})})}},99398:(e,t,r)=>{Promise.resolve().then(r.bind(r,75095)),Promise.resolve().then(r.bind(r,25086))}},e=>{e.O(0,[2574,3862,817,5280,1321,705,5497,8441,3794,7358],()=>e(e.s=99398)),_N_E=e.O()}]);