omniroute 1.4.2 → 1.4.4

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 (469) hide show
  1. package/app/.next/BUILD_ID +1 -1
  2. package/app/.next/app-path-routes-manifest.json +33 -33
  3. package/app/.next/build-manifest.json +2 -2
  4. package/app/.next/prerender-manifest.json +3 -3
  5. package/app/.next/server/app/(dashboard)/dashboard/analytics/page_client-reference-manifest.js +1 -1
  6. package/app/.next/server/app/(dashboard)/dashboard/api-manager/page_client-reference-manifest.js +1 -1
  7. package/app/.next/server/app/(dashboard)/dashboard/audit-log/page_client-reference-manifest.js +1 -1
  8. package/app/.next/server/app/(dashboard)/dashboard/cli-tools/page_client-reference-manifest.js +1 -1
  9. package/app/.next/server/app/(dashboard)/dashboard/combos/page.js +1 -1
  10. package/app/.next/server/app/(dashboard)/dashboard/combos/page_client-reference-manifest.js +1 -1
  11. package/app/.next/server/app/(dashboard)/dashboard/costs/page_client-reference-manifest.js +1 -1
  12. package/app/.next/server/app/(dashboard)/dashboard/endpoint/page_client-reference-manifest.js +1 -1
  13. package/app/.next/server/app/(dashboard)/dashboard/health/page_client-reference-manifest.js +1 -1
  14. package/app/.next/server/app/(dashboard)/dashboard/limits/page_client-reference-manifest.js +1 -1
  15. package/app/.next/server/app/(dashboard)/dashboard/logs/page_client-reference-manifest.js +1 -1
  16. package/app/.next/server/app/(dashboard)/dashboard/onboarding/page_client-reference-manifest.js +1 -1
  17. package/app/.next/server/app/(dashboard)/dashboard/page_client-reference-manifest.js +1 -1
  18. package/app/.next/server/app/(dashboard)/dashboard/profile/page_client-reference-manifest.js +1 -1
  19. package/app/.next/server/app/(dashboard)/dashboard/providers/[id]/page.js +1 -1
  20. package/app/.next/server/app/(dashboard)/dashboard/providers/[id]/page_client-reference-manifest.js +1 -1
  21. package/app/.next/server/app/(dashboard)/dashboard/providers/new/page_client-reference-manifest.js +1 -1
  22. package/app/.next/server/app/(dashboard)/dashboard/providers/page_client-reference-manifest.js +1 -1
  23. package/app/.next/server/app/(dashboard)/dashboard/settings/page_client-reference-manifest.js +1 -1
  24. package/app/.next/server/app/(dashboard)/dashboard/settings/pricing/page_client-reference-manifest.js +1 -1
  25. package/app/.next/server/app/(dashboard)/dashboard/translator/page_client-reference-manifest.js +1 -1
  26. package/app/.next/server/app/(dashboard)/dashboard/usage/page_client-reference-manifest.js +1 -1
  27. package/app/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
  28. package/app/.next/server/app/_global-error.html +2 -2
  29. package/app/.next/server/app/_global-error.rsc +1 -1
  30. package/app/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  31. package/app/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
  32. package/app/.next/server/app/_global-error.segments/_global-error.segment.rsc +1 -1
  33. package/app/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  34. package/app/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  35. package/app/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  36. package/app/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  37. package/app/.next/server/app/_not-found.html +1 -1
  38. package/app/.next/server/app/_not-found.rsc +2 -2
  39. package/app/.next/server/app/_not-found.segments/_full.segment.rsc +2 -2
  40. package/app/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
  41. package/app/.next/server/app/_not-found.segments/_index.segment.rsc +2 -2
  42. package/app/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
  43. package/app/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
  44. package/app/.next/server/app/_not-found.segments/_tree.segment.rsc +1 -1
  45. package/app/.next/server/app/api/auth/login/route.js +1 -1
  46. package/app/.next/server/app/api/auth/login/route_client-reference-manifest.js +1 -1
  47. package/app/.next/server/app/api/auth/logout/route_client-reference-manifest.js +1 -1
  48. package/app/.next/server/app/api/auth/status/route_client-reference-manifest.js +1 -1
  49. package/app/.next/server/app/api/cache/route_client-reference-manifest.js +1 -1
  50. package/app/.next/server/app/api/cache/stats/route_client-reference-manifest.js +1 -1
  51. package/app/.next/server/app/api/cli-tools/antigravity-mitm/alias/route.js +2 -2
  52. package/app/.next/server/app/api/cli-tools/antigravity-mitm/alias/route_client-reference-manifest.js +1 -1
  53. package/app/.next/server/app/api/cli-tools/antigravity-mitm/route.js +2 -2
  54. package/app/.next/server/app/api/cli-tools/antigravity-mitm/route_client-reference-manifest.js +1 -1
  55. package/app/.next/server/app/api/cli-tools/backups/route.js +1 -1
  56. package/app/.next/server/app/api/cli-tools/backups/route_client-reference-manifest.js +1 -1
  57. package/app/.next/server/app/api/cli-tools/claude-settings/route.js +2 -2
  58. package/app/.next/server/app/api/cli-tools/claude-settings/route_client-reference-manifest.js +1 -1
  59. package/app/.next/server/app/api/cli-tools/cline-settings/route.js +2 -2
  60. package/app/.next/server/app/api/cli-tools/cline-settings/route_client-reference-manifest.js +1 -1
  61. package/app/.next/server/app/api/cli-tools/codex-profiles/route.js +1 -1
  62. package/app/.next/server/app/api/cli-tools/codex-profiles/route_client-reference-manifest.js +1 -1
  63. package/app/.next/server/app/api/cli-tools/codex-settings/route.js +1 -1
  64. package/app/.next/server/app/api/cli-tools/codex-settings/route_client-reference-manifest.js +1 -1
  65. package/app/.next/server/app/api/cli-tools/droid-settings/route.js +2 -2
  66. package/app/.next/server/app/api/cli-tools/droid-settings/route_client-reference-manifest.js +1 -1
  67. package/app/.next/server/app/api/cli-tools/guide-settings/[toolId]/route_client-reference-manifest.js +1 -1
  68. package/app/.next/server/app/api/cli-tools/kilo-settings/route.js +1 -1
  69. package/app/.next/server/app/api/cli-tools/kilo-settings/route_client-reference-manifest.js +1 -1
  70. package/app/.next/server/app/api/cli-tools/openclaw-settings/route.js +1 -1
  71. package/app/.next/server/app/api/cli-tools/openclaw-settings/route_client-reference-manifest.js +1 -1
  72. package/app/.next/server/app/api/cli-tools/runtime/[toolId]/route.js +2 -2
  73. package/app/.next/server/app/api/cli-tools/runtime/[toolId]/route_client-reference-manifest.js +1 -1
  74. package/app/.next/server/app/api/cli-tools/status/route.js +1 -1
  75. package/app/.next/server/app/api/cli-tools/status/route_client-reference-manifest.js +1 -1
  76. package/app/.next/server/app/api/cloud/auth/route_client-reference-manifest.js +1 -1
  77. package/app/.next/server/app/api/cloud/credentials/update/route_client-reference-manifest.js +1 -1
  78. package/app/.next/server/app/api/cloud/model/resolve/route_client-reference-manifest.js +1 -1
  79. package/app/.next/server/app/api/cloud/models/alias/route_client-reference-manifest.js +1 -1
  80. package/app/.next/server/app/api/combos/[id]/route_client-reference-manifest.js +1 -1
  81. package/app/.next/server/app/api/combos/metrics/route_client-reference-manifest.js +1 -1
  82. package/app/.next/server/app/api/combos/route_client-reference-manifest.js +1 -1
  83. package/app/.next/server/app/api/combos/test/route_client-reference-manifest.js +1 -1
  84. package/app/.next/server/app/api/compliance/audit-log/route_client-reference-manifest.js +1 -1
  85. package/app/.next/server/app/api/db-backups/export/route_client-reference-manifest.js +1 -1
  86. package/app/.next/server/app/api/db-backups/exportAll/route_client-reference-manifest.js +1 -1
  87. package/app/.next/server/app/api/db-backups/import/route.js +1 -1
  88. package/app/.next/server/app/api/db-backups/import/route_client-reference-manifest.js +1 -1
  89. package/app/.next/server/app/api/db-backups/route_client-reference-manifest.js +1 -1
  90. package/app/.next/server/app/api/evals/[suiteId]/route_client-reference-manifest.js +1 -1
  91. package/app/.next/server/app/api/evals/route_client-reference-manifest.js +1 -1
  92. package/app/.next/server/app/api/fallback/chains/route_client-reference-manifest.js +1 -1
  93. package/app/.next/server/app/api/init/route_client-reference-manifest.js +1 -1
  94. package/app/.next/server/app/api/keys/[id]/route_client-reference-manifest.js +1 -1
  95. package/app/.next/server/app/api/keys/route_client-reference-manifest.js +1 -1
  96. package/app/.next/server/app/api/logs/console/route_client-reference-manifest.js +1 -1
  97. package/app/.next/server/app/api/models/alias/route.js +1 -1
  98. package/app/.next/server/app/api/models/alias/route.js.nft.json +1 -1
  99. package/app/.next/server/app/api/models/alias/route_client-reference-manifest.js +1 -1
  100. package/app/.next/server/app/api/models/availability/route_client-reference-manifest.js +1 -1
  101. package/app/.next/server/app/api/models/catalog/route_client-reference-manifest.js +1 -1
  102. package/app/.next/server/app/api/models/route.js +1 -1
  103. package/app/.next/server/app/api/models/route_client-reference-manifest.js +1 -1
  104. package/app/.next/server/app/api/monitoring/health/route.js +1 -1
  105. package/app/.next/server/app/api/monitoring/health/route_client-reference-manifest.js +1 -1
  106. package/app/.next/server/app/api/oauth/[provider]/[action]/route_client-reference-manifest.js +1 -1
  107. package/app/.next/server/app/api/oauth/cursor/auto-import/route_client-reference-manifest.js +1 -1
  108. package/app/.next/server/app/api/oauth/cursor/import/route_client-reference-manifest.js +1 -1
  109. package/app/.next/server/app/api/oauth/kiro/auto-import/route_client-reference-manifest.js +1 -1
  110. package/app/.next/server/app/api/oauth/kiro/import/route_client-reference-manifest.js +1 -1
  111. package/app/.next/server/app/api/oauth/kiro/social-authorize/route_client-reference-manifest.js +1 -1
  112. package/app/.next/server/app/api/oauth/kiro/social-exchange/route_client-reference-manifest.js +1 -1
  113. package/app/.next/server/app/api/policies/route_client-reference-manifest.js +1 -1
  114. package/app/.next/server/app/api/pricing/defaults/route_client-reference-manifest.js +1 -1
  115. package/app/.next/server/app/api/pricing/models/route_client-reference-manifest.js +1 -1
  116. package/app/.next/server/app/api/pricing/route_client-reference-manifest.js +1 -1
  117. package/app/.next/server/app/api/provider-metrics/route_client-reference-manifest.js +1 -1
  118. package/app/.next/server/app/api/provider-models/route.js +1 -1
  119. package/app/.next/server/app/api/provider-models/route.js.nft.json +1 -1
  120. package/app/.next/server/app/api/provider-models/route_client-reference-manifest.js +1 -1
  121. package/app/.next/server/app/api/provider-nodes/[id]/route_client-reference-manifest.js +1 -1
  122. package/app/.next/server/app/api/provider-nodes/route_client-reference-manifest.js +1 -1
  123. package/app/.next/server/app/api/provider-nodes/validate/route_client-reference-manifest.js +1 -1
  124. package/app/.next/server/app/api/providers/[id]/models/route_client-reference-manifest.js +1 -1
  125. package/app/.next/server/app/api/providers/[id]/route_client-reference-manifest.js +1 -1
  126. package/app/.next/server/app/api/providers/[id]/test/route_client-reference-manifest.js +1 -1
  127. package/app/.next/server/app/api/providers/client/route_client-reference-manifest.js +1 -1
  128. package/app/.next/server/app/api/providers/route.js +1 -1
  129. package/app/.next/server/app/api/providers/route_client-reference-manifest.js +1 -1
  130. package/app/.next/server/app/api/providers/test-batch/route_client-reference-manifest.js +1 -1
  131. package/app/.next/server/app/api/providers/validate/route_client-reference-manifest.js +1 -1
  132. package/app/.next/server/app/api/rate-limit/route_client-reference-manifest.js +1 -1
  133. package/app/.next/server/app/api/rate-limits/route_client-reference-manifest.js +1 -1
  134. package/app/.next/server/app/api/resilience/reset/route_client-reference-manifest.js +1 -1
  135. package/app/.next/server/app/api/resilience/route_client-reference-manifest.js +1 -1
  136. package/app/.next/server/app/api/restart/route_client-reference-manifest.js +1 -1
  137. package/app/.next/server/app/api/sessions/route_client-reference-manifest.js +1 -1
  138. package/app/.next/server/app/api/settings/combo-defaults/route_client-reference-manifest.js +1 -1
  139. package/app/.next/server/app/api/settings/ip-filter/route_client-reference-manifest.js +1 -1
  140. package/app/.next/server/app/api/settings/proxy/route_client-reference-manifest.js +1 -1
  141. package/app/.next/server/app/api/settings/proxy/test/route_client-reference-manifest.js +1 -1
  142. package/app/.next/server/app/api/settings/require-login/route_client-reference-manifest.js +1 -1
  143. package/app/.next/server/app/api/settings/route_client-reference-manifest.js +1 -1
  144. package/app/.next/server/app/api/settings/system-prompt/route_client-reference-manifest.js +1 -1
  145. package/app/.next/server/app/api/settings/thinking-budget/route_client-reference-manifest.js +1 -1
  146. package/app/.next/server/app/api/shutdown/route_client-reference-manifest.js +1 -1
  147. package/app/.next/server/app/api/storage/health/route_client-reference-manifest.js +1 -1
  148. package/app/.next/server/app/api/sync/cloud/route_client-reference-manifest.js +1 -1
  149. package/app/.next/server/app/api/sync/initialize/route_client-reference-manifest.js +1 -1
  150. package/app/.next/server/app/api/tags/route_client-reference-manifest.js +1 -1
  151. package/app/.next/server/app/api/telemetry/summary/route_client-reference-manifest.js +1 -1
  152. package/app/.next/server/app/api/token-health/route_client-reference-manifest.js +1 -1
  153. package/app/.next/server/app/api/translator/detect/route_client-reference-manifest.js +1 -1
  154. package/app/.next/server/app/api/translator/history/route_client-reference-manifest.js +1 -1
  155. package/app/.next/server/app/api/translator/load/route_client-reference-manifest.js +1 -1
  156. package/app/.next/server/app/api/translator/save/route_client-reference-manifest.js +1 -1
  157. package/app/.next/server/app/api/translator/send/route_client-reference-manifest.js +1 -1
  158. package/app/.next/server/app/api/translator/translate/route_client-reference-manifest.js +1 -1
  159. package/app/.next/server/app/api/usage/[connectionId]/route_client-reference-manifest.js +1 -1
  160. package/app/.next/server/app/api/usage/analytics/route_client-reference-manifest.js +1 -1
  161. package/app/.next/server/app/api/usage/budget/route_client-reference-manifest.js +1 -1
  162. package/app/.next/server/app/api/usage/call-logs/[id]/route_client-reference-manifest.js +1 -1
  163. package/app/.next/server/app/api/usage/call-logs/route_client-reference-manifest.js +1 -1
  164. package/app/.next/server/app/api/usage/history/route_client-reference-manifest.js +1 -1
  165. package/app/.next/server/app/api/usage/logs/route_client-reference-manifest.js +1 -1
  166. package/app/.next/server/app/api/usage/proxy-logs/route_client-reference-manifest.js +1 -1
  167. package/app/.next/server/app/api/usage/request-logs/route_client-reference-manifest.js +1 -1
  168. package/app/.next/server/app/api/v1/api/chat/route_client-reference-manifest.js +1 -1
  169. package/app/.next/server/app/api/v1/audio/speech/route_client-reference-manifest.js +1 -1
  170. package/app/.next/server/app/api/v1/audio/transcriptions/route_client-reference-manifest.js +1 -1
  171. package/app/.next/server/app/api/v1/chat/completions/route_client-reference-manifest.js +1 -1
  172. package/app/.next/server/app/api/v1/embeddings/route_client-reference-manifest.js +1 -1
  173. package/app/.next/server/app/api/v1/images/generations/route_client-reference-manifest.js +1 -1
  174. package/app/.next/server/app/api/v1/messages/count_tokens/route_client-reference-manifest.js +1 -1
  175. package/app/.next/server/app/api/v1/messages/route_client-reference-manifest.js +1 -1
  176. package/app/.next/server/app/api/v1/models/route.js +2 -2
  177. package/app/.next/server/app/api/v1/models/route.js.nft.json +1 -1
  178. package/app/.next/server/app/api/v1/models/route_client-reference-manifest.js +1 -1
  179. package/app/.next/server/app/api/v1/moderations/route_client-reference-manifest.js +1 -1
  180. package/app/.next/server/app/api/v1/providers/[provider]/chat/completions/route_client-reference-manifest.js +1 -1
  181. package/app/.next/server/app/api/v1/providers/[provider]/embeddings/route_client-reference-manifest.js +1 -1
  182. package/app/.next/server/app/api/v1/providers/[provider]/images/generations/route_client-reference-manifest.js +1 -1
  183. package/app/.next/server/app/api/v1/rerank/route_client-reference-manifest.js +1 -1
  184. package/app/.next/server/app/api/v1/responses/route_client-reference-manifest.js +1 -1
  185. package/app/.next/server/app/api/v1/route_client-reference-manifest.js +1 -1
  186. package/app/.next/server/app/api/v1beta/models/[...path]/route_client-reference-manifest.js +1 -1
  187. package/app/.next/server/app/api/v1beta/models/route_client-reference-manifest.js +1 -1
  188. package/app/.next/server/app/callback/page_client-reference-manifest.js +1 -1
  189. package/app/.next/server/app/callback.html +1 -1
  190. package/app/.next/server/app/callback.rsc +2 -2
  191. package/app/.next/server/app/callback.segments/_full.segment.rsc +2 -2
  192. package/app/.next/server/app/callback.segments/_head.segment.rsc +1 -1
  193. package/app/.next/server/app/callback.segments/_index.segment.rsc +2 -2
  194. package/app/.next/server/app/callback.segments/_tree.segment.rsc +1 -1
  195. package/app/.next/server/app/callback.segments/callback/__PAGE__.segment.rsc +1 -1
  196. package/app/.next/server/app/callback.segments/callback.segment.rsc +1 -1
  197. package/app/.next/server/app/dashboard/analytics.html +2 -2
  198. package/app/.next/server/app/dashboard/analytics.rsc +4 -4
  199. package/app/.next/server/app/dashboard/analytics.segments/!KGRhc2hib2FyZCk/dashboard/analytics/__PAGE__.segment.rsc +2 -2
  200. package/app/.next/server/app/dashboard/analytics.segments/!KGRhc2hib2FyZCk/dashboard/analytics.segment.rsc +1 -1
  201. package/app/.next/server/app/dashboard/analytics.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  202. package/app/.next/server/app/dashboard/analytics.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  203. package/app/.next/server/app/dashboard/analytics.segments/_full.segment.rsc +4 -4
  204. package/app/.next/server/app/dashboard/analytics.segments/_head.segment.rsc +1 -1
  205. package/app/.next/server/app/dashboard/analytics.segments/_index.segment.rsc +2 -2
  206. package/app/.next/server/app/dashboard/analytics.segments/_tree.segment.rsc +1 -1
  207. package/app/.next/server/app/dashboard/api-manager.html +1 -1
  208. package/app/.next/server/app/dashboard/api-manager.rsc +4 -4
  209. package/app/.next/server/app/dashboard/api-manager.segments/!KGRhc2hib2FyZCk/dashboard/api-manager/__PAGE__.segment.rsc +2 -2
  210. package/app/.next/server/app/dashboard/api-manager.segments/!KGRhc2hib2FyZCk/dashboard/api-manager.segment.rsc +1 -1
  211. package/app/.next/server/app/dashboard/api-manager.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  212. package/app/.next/server/app/dashboard/api-manager.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  213. package/app/.next/server/app/dashboard/api-manager.segments/_full.segment.rsc +4 -4
  214. package/app/.next/server/app/dashboard/api-manager.segments/_head.segment.rsc +1 -1
  215. package/app/.next/server/app/dashboard/api-manager.segments/_index.segment.rsc +2 -2
  216. package/app/.next/server/app/dashboard/api-manager.segments/_tree.segment.rsc +1 -1
  217. package/app/.next/server/app/dashboard/audit-log.html +1 -1
  218. package/app/.next/server/app/dashboard/audit-log.rsc +3 -3
  219. package/app/.next/server/app/dashboard/audit-log.segments/!KGRhc2hib2FyZCk/dashboard/audit-log/__PAGE__.segment.rsc +1 -1
  220. package/app/.next/server/app/dashboard/audit-log.segments/!KGRhc2hib2FyZCk/dashboard/audit-log.segment.rsc +1 -1
  221. package/app/.next/server/app/dashboard/audit-log.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  222. package/app/.next/server/app/dashboard/audit-log.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  223. package/app/.next/server/app/dashboard/audit-log.segments/_full.segment.rsc +3 -3
  224. package/app/.next/server/app/dashboard/audit-log.segments/_head.segment.rsc +1 -1
  225. package/app/.next/server/app/dashboard/audit-log.segments/_index.segment.rsc +2 -2
  226. package/app/.next/server/app/dashboard/audit-log.segments/_tree.segment.rsc +1 -1
  227. package/app/.next/server/app/dashboard/cli-tools.html +1 -1
  228. package/app/.next/server/app/dashboard/cli-tools.rsc +4 -4
  229. package/app/.next/server/app/dashboard/cli-tools.segments/!KGRhc2hib2FyZCk/dashboard/cli-tools/__PAGE__.segment.rsc +2 -2
  230. package/app/.next/server/app/dashboard/cli-tools.segments/!KGRhc2hib2FyZCk/dashboard/cli-tools.segment.rsc +1 -1
  231. package/app/.next/server/app/dashboard/cli-tools.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  232. package/app/.next/server/app/dashboard/cli-tools.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  233. package/app/.next/server/app/dashboard/cli-tools.segments/_full.segment.rsc +4 -4
  234. package/app/.next/server/app/dashboard/cli-tools.segments/_head.segment.rsc +1 -1
  235. package/app/.next/server/app/dashboard/cli-tools.segments/_index.segment.rsc +2 -2
  236. package/app/.next/server/app/dashboard/cli-tools.segments/_tree.segment.rsc +1 -1
  237. package/app/.next/server/app/dashboard/combos.html +1 -1
  238. package/app/.next/server/app/dashboard/combos.rsc +4 -4
  239. package/app/.next/server/app/dashboard/combos.segments/!KGRhc2hib2FyZCk/dashboard/combos/__PAGE__.segment.rsc +2 -2
  240. package/app/.next/server/app/dashboard/combos.segments/!KGRhc2hib2FyZCk/dashboard/combos.segment.rsc +1 -1
  241. package/app/.next/server/app/dashboard/combos.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  242. package/app/.next/server/app/dashboard/combos.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  243. package/app/.next/server/app/dashboard/combos.segments/_full.segment.rsc +4 -4
  244. package/app/.next/server/app/dashboard/combos.segments/_head.segment.rsc +1 -1
  245. package/app/.next/server/app/dashboard/combos.segments/_index.segment.rsc +2 -2
  246. package/app/.next/server/app/dashboard/combos.segments/_tree.segment.rsc +1 -1
  247. package/app/.next/server/app/dashboard/costs.html +1 -1
  248. package/app/.next/server/app/dashboard/costs.rsc +4 -4
  249. package/app/.next/server/app/dashboard/costs.segments/!KGRhc2hib2FyZCk/dashboard/costs/__PAGE__.segment.rsc +2 -2
  250. package/app/.next/server/app/dashboard/costs.segments/!KGRhc2hib2FyZCk/dashboard/costs.segment.rsc +1 -1
  251. package/app/.next/server/app/dashboard/costs.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  252. package/app/.next/server/app/dashboard/costs.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  253. package/app/.next/server/app/dashboard/costs.segments/_full.segment.rsc +4 -4
  254. package/app/.next/server/app/dashboard/costs.segments/_head.segment.rsc +1 -1
  255. package/app/.next/server/app/dashboard/costs.segments/_index.segment.rsc +2 -2
  256. package/app/.next/server/app/dashboard/costs.segments/_tree.segment.rsc +1 -1
  257. package/app/.next/server/app/dashboard/endpoint.html +1 -1
  258. package/app/.next/server/app/dashboard/endpoint.rsc +4 -4
  259. package/app/.next/server/app/dashboard/endpoint.segments/!KGRhc2hib2FyZCk/dashboard/endpoint/__PAGE__.segment.rsc +2 -2
  260. package/app/.next/server/app/dashboard/endpoint.segments/!KGRhc2hib2FyZCk/dashboard/endpoint.segment.rsc +1 -1
  261. package/app/.next/server/app/dashboard/endpoint.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  262. package/app/.next/server/app/dashboard/endpoint.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  263. package/app/.next/server/app/dashboard/endpoint.segments/_full.segment.rsc +4 -4
  264. package/app/.next/server/app/dashboard/endpoint.segments/_head.segment.rsc +1 -1
  265. package/app/.next/server/app/dashboard/endpoint.segments/_index.segment.rsc +2 -2
  266. package/app/.next/server/app/dashboard/endpoint.segments/_tree.segment.rsc +1 -1
  267. package/app/.next/server/app/dashboard/health.html +1 -1
  268. package/app/.next/server/app/dashboard/health.rsc +4 -4
  269. package/app/.next/server/app/dashboard/health.segments/!KGRhc2hib2FyZCk/dashboard/health/__PAGE__.segment.rsc +2 -2
  270. package/app/.next/server/app/dashboard/health.segments/!KGRhc2hib2FyZCk/dashboard/health.segment.rsc +1 -1
  271. package/app/.next/server/app/dashboard/health.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  272. package/app/.next/server/app/dashboard/health.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  273. package/app/.next/server/app/dashboard/health.segments/_full.segment.rsc +4 -4
  274. package/app/.next/server/app/dashboard/health.segments/_head.segment.rsc +1 -1
  275. package/app/.next/server/app/dashboard/health.segments/_index.segment.rsc +2 -2
  276. package/app/.next/server/app/dashboard/health.segments/_tree.segment.rsc +1 -1
  277. package/app/.next/server/app/dashboard/limits.html +2 -2
  278. package/app/.next/server/app/dashboard/limits.rsc +4 -4
  279. package/app/.next/server/app/dashboard/limits.segments/!KGRhc2hib2FyZCk/dashboard/limits/__PAGE__.segment.rsc +2 -2
  280. package/app/.next/server/app/dashboard/limits.segments/!KGRhc2hib2FyZCk/dashboard/limits.segment.rsc +1 -1
  281. package/app/.next/server/app/dashboard/limits.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  282. package/app/.next/server/app/dashboard/limits.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  283. package/app/.next/server/app/dashboard/limits.segments/_full.segment.rsc +4 -4
  284. package/app/.next/server/app/dashboard/limits.segments/_head.segment.rsc +1 -1
  285. package/app/.next/server/app/dashboard/limits.segments/_index.segment.rsc +2 -2
  286. package/app/.next/server/app/dashboard/limits.segments/_tree.segment.rsc +1 -1
  287. package/app/.next/server/app/dashboard/logs.html +1 -1
  288. package/app/.next/server/app/dashboard/logs.rsc +4 -4
  289. package/app/.next/server/app/dashboard/logs.segments/!KGRhc2hib2FyZCk/dashboard/logs/__PAGE__.segment.rsc +2 -2
  290. package/app/.next/server/app/dashboard/logs.segments/!KGRhc2hib2FyZCk/dashboard/logs.segment.rsc +1 -1
  291. package/app/.next/server/app/dashboard/logs.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  292. package/app/.next/server/app/dashboard/logs.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  293. package/app/.next/server/app/dashboard/logs.segments/_full.segment.rsc +4 -4
  294. package/app/.next/server/app/dashboard/logs.segments/_head.segment.rsc +1 -1
  295. package/app/.next/server/app/dashboard/logs.segments/_index.segment.rsc +2 -2
  296. package/app/.next/server/app/dashboard/logs.segments/_tree.segment.rsc +1 -1
  297. package/app/.next/server/app/dashboard/onboarding.html +1 -1
  298. package/app/.next/server/app/dashboard/onboarding.rsc +3 -3
  299. package/app/.next/server/app/dashboard/onboarding.segments/!KGRhc2hib2FyZCk/dashboard/onboarding/__PAGE__.segment.rsc +1 -1
  300. package/app/.next/server/app/dashboard/onboarding.segments/!KGRhc2hib2FyZCk/dashboard/onboarding.segment.rsc +1 -1
  301. package/app/.next/server/app/dashboard/onboarding.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  302. package/app/.next/server/app/dashboard/onboarding.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  303. package/app/.next/server/app/dashboard/onboarding.segments/_full.segment.rsc +3 -3
  304. package/app/.next/server/app/dashboard/onboarding.segments/_head.segment.rsc +1 -1
  305. package/app/.next/server/app/dashboard/onboarding.segments/_index.segment.rsc +2 -2
  306. package/app/.next/server/app/dashboard/onboarding.segments/_tree.segment.rsc +1 -1
  307. package/app/.next/server/app/dashboard/profile.html +1 -1
  308. package/app/.next/server/app/dashboard/profile.rsc +3 -3
  309. package/app/.next/server/app/dashboard/profile.segments/!KGRhc2hib2FyZCk/dashboard/profile/__PAGE__.segment.rsc +1 -1
  310. package/app/.next/server/app/dashboard/profile.segments/!KGRhc2hib2FyZCk/dashboard/profile.segment.rsc +1 -1
  311. package/app/.next/server/app/dashboard/profile.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  312. package/app/.next/server/app/dashboard/profile.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  313. package/app/.next/server/app/dashboard/profile.segments/_full.segment.rsc +3 -3
  314. package/app/.next/server/app/dashboard/profile.segments/_head.segment.rsc +1 -1
  315. package/app/.next/server/app/dashboard/profile.segments/_index.segment.rsc +2 -2
  316. package/app/.next/server/app/dashboard/profile.segments/_tree.segment.rsc +1 -1
  317. package/app/.next/server/app/dashboard/providers/new.html +2 -2
  318. package/app/.next/server/app/dashboard/providers/new.rsc +4 -4
  319. package/app/.next/server/app/dashboard/providers/new.segments/!KGRhc2hib2FyZCk/dashboard/providers/new/__PAGE__.segment.rsc +2 -2
  320. package/app/.next/server/app/dashboard/providers/new.segments/!KGRhc2hib2FyZCk/dashboard/providers/new.segment.rsc +1 -1
  321. package/app/.next/server/app/dashboard/providers/new.segments/!KGRhc2hib2FyZCk/dashboard/providers.segment.rsc +1 -1
  322. package/app/.next/server/app/dashboard/providers/new.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  323. package/app/.next/server/app/dashboard/providers/new.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  324. package/app/.next/server/app/dashboard/providers/new.segments/_full.segment.rsc +4 -4
  325. package/app/.next/server/app/dashboard/providers/new.segments/_head.segment.rsc +1 -1
  326. package/app/.next/server/app/dashboard/providers/new.segments/_index.segment.rsc +2 -2
  327. package/app/.next/server/app/dashboard/providers/new.segments/_tree.segment.rsc +1 -1
  328. package/app/.next/server/app/dashboard/providers.html +2 -2
  329. package/app/.next/server/app/dashboard/providers.rsc +4 -4
  330. package/app/.next/server/app/dashboard/providers.segments/!KGRhc2hib2FyZCk/dashboard/providers/__PAGE__.segment.rsc +2 -2
  331. package/app/.next/server/app/dashboard/providers.segments/!KGRhc2hib2FyZCk/dashboard/providers.segment.rsc +1 -1
  332. package/app/.next/server/app/dashboard/providers.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  333. package/app/.next/server/app/dashboard/providers.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  334. package/app/.next/server/app/dashboard/providers.segments/_full.segment.rsc +4 -4
  335. package/app/.next/server/app/dashboard/providers.segments/_head.segment.rsc +1 -1
  336. package/app/.next/server/app/dashboard/providers.segments/_index.segment.rsc +2 -2
  337. package/app/.next/server/app/dashboard/providers.segments/_tree.segment.rsc +1 -1
  338. package/app/.next/server/app/dashboard/settings/pricing.html +2 -2
  339. package/app/.next/server/app/dashboard/settings/pricing.rsc +3 -3
  340. package/app/.next/server/app/dashboard/settings/pricing.segments/!KGRhc2hib2FyZCk/dashboard/settings/pricing/__PAGE__.segment.rsc +1 -1
  341. package/app/.next/server/app/dashboard/settings/pricing.segments/!KGRhc2hib2FyZCk/dashboard/settings/pricing.segment.rsc +1 -1
  342. package/app/.next/server/app/dashboard/settings/pricing.segments/!KGRhc2hib2FyZCk/dashboard/settings.segment.rsc +1 -1
  343. package/app/.next/server/app/dashboard/settings/pricing.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  344. package/app/.next/server/app/dashboard/settings/pricing.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  345. package/app/.next/server/app/dashboard/settings/pricing.segments/_full.segment.rsc +3 -3
  346. package/app/.next/server/app/dashboard/settings/pricing.segments/_head.segment.rsc +1 -1
  347. package/app/.next/server/app/dashboard/settings/pricing.segments/_index.segment.rsc +2 -2
  348. package/app/.next/server/app/dashboard/settings/pricing.segments/_tree.segment.rsc +1 -1
  349. package/app/.next/server/app/dashboard/settings.html +1 -1
  350. package/app/.next/server/app/dashboard/settings.rsc +4 -4
  351. package/app/.next/server/app/dashboard/settings.segments/!KGRhc2hib2FyZCk/dashboard/settings/__PAGE__.segment.rsc +2 -2
  352. package/app/.next/server/app/dashboard/settings.segments/!KGRhc2hib2FyZCk/dashboard/settings.segment.rsc +1 -1
  353. package/app/.next/server/app/dashboard/settings.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  354. package/app/.next/server/app/dashboard/settings.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  355. package/app/.next/server/app/dashboard/settings.segments/_full.segment.rsc +4 -4
  356. package/app/.next/server/app/dashboard/settings.segments/_head.segment.rsc +1 -1
  357. package/app/.next/server/app/dashboard/settings.segments/_index.segment.rsc +2 -2
  358. package/app/.next/server/app/dashboard/settings.segments/_tree.segment.rsc +1 -1
  359. package/app/.next/server/app/dashboard/translator.html +2 -2
  360. package/app/.next/server/app/dashboard/translator.rsc +4 -4
  361. package/app/.next/server/app/dashboard/translator.segments/!KGRhc2hib2FyZCk/dashboard/translator/__PAGE__.segment.rsc +2 -2
  362. package/app/.next/server/app/dashboard/translator.segments/!KGRhc2hib2FyZCk/dashboard/translator.segment.rsc +1 -1
  363. package/app/.next/server/app/dashboard/translator.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  364. package/app/.next/server/app/dashboard/translator.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  365. package/app/.next/server/app/dashboard/translator.segments/_full.segment.rsc +4 -4
  366. package/app/.next/server/app/dashboard/translator.segments/_head.segment.rsc +1 -1
  367. package/app/.next/server/app/dashboard/translator.segments/_index.segment.rsc +2 -2
  368. package/app/.next/server/app/dashboard/translator.segments/_tree.segment.rsc +1 -1
  369. package/app/.next/server/app/dashboard/usage.html +1 -1
  370. package/app/.next/server/app/dashboard/usage.rsc +4 -4
  371. package/app/.next/server/app/dashboard/usage.segments/!KGRhc2hib2FyZCk/dashboard/usage/__PAGE__.segment.rsc +2 -2
  372. package/app/.next/server/app/dashboard/usage.segments/!KGRhc2hib2FyZCk/dashboard/usage.segment.rsc +1 -1
  373. package/app/.next/server/app/dashboard/usage.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  374. package/app/.next/server/app/dashboard/usage.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  375. package/app/.next/server/app/dashboard/usage.segments/_full.segment.rsc +4 -4
  376. package/app/.next/server/app/dashboard/usage.segments/_head.segment.rsc +1 -1
  377. package/app/.next/server/app/dashboard/usage.segments/_index.segment.rsc +2 -2
  378. package/app/.next/server/app/dashboard/usage.segments/_tree.segment.rsc +1 -1
  379. package/app/.next/server/app/docs/page.js +1 -1
  380. package/app/.next/server/app/docs/page_client-reference-manifest.js +1 -1
  381. package/app/.next/server/app/docs.html +1 -1
  382. package/app/.next/server/app/docs.rsc +2 -2
  383. package/app/.next/server/app/docs.segments/_full.segment.rsc +2 -2
  384. package/app/.next/server/app/docs.segments/_head.segment.rsc +1 -1
  385. package/app/.next/server/app/docs.segments/_index.segment.rsc +2 -2
  386. package/app/.next/server/app/docs.segments/_tree.segment.rsc +1 -1
  387. package/app/.next/server/app/docs.segments/docs/__PAGE__.segment.rsc +1 -1
  388. package/app/.next/server/app/docs.segments/docs.segment.rsc +1 -1
  389. package/app/.next/server/app/forbidden/page_client-reference-manifest.js +1 -1
  390. package/app/.next/server/app/forbidden.html +1 -1
  391. package/app/.next/server/app/forbidden.rsc +2 -2
  392. package/app/.next/server/app/forbidden.segments/_full.segment.rsc +2 -2
  393. package/app/.next/server/app/forbidden.segments/_head.segment.rsc +1 -1
  394. package/app/.next/server/app/forbidden.segments/_index.segment.rsc +2 -2
  395. package/app/.next/server/app/forbidden.segments/_tree.segment.rsc +1 -1
  396. package/app/.next/server/app/forbidden.segments/forbidden/__PAGE__.segment.rsc +1 -1
  397. package/app/.next/server/app/forbidden.segments/forbidden.segment.rsc +1 -1
  398. package/app/.next/server/app/forgot-password/page_client-reference-manifest.js +1 -1
  399. package/app/.next/server/app/forgot-password.html +1 -1
  400. package/app/.next/server/app/forgot-password.rsc +3 -3
  401. package/app/.next/server/app/forgot-password.segments/_full.segment.rsc +3 -3
  402. package/app/.next/server/app/forgot-password.segments/_head.segment.rsc +1 -1
  403. package/app/.next/server/app/forgot-password.segments/_index.segment.rsc +2 -2
  404. package/app/.next/server/app/forgot-password.segments/_tree.segment.rsc +1 -1
  405. package/app/.next/server/app/forgot-password.segments/forgot-password/__PAGE__.segment.rsc +2 -2
  406. package/app/.next/server/app/forgot-password.segments/forgot-password.segment.rsc +1 -1
  407. package/app/.next/server/app/index.html +1 -1
  408. package/app/.next/server/app/index.rsc +2 -2
  409. package/app/.next/server/app/index.segments/__PAGE__.segment.rsc +1 -1
  410. package/app/.next/server/app/index.segments/_full.segment.rsc +2 -2
  411. package/app/.next/server/app/index.segments/_head.segment.rsc +1 -1
  412. package/app/.next/server/app/index.segments/_index.segment.rsc +2 -2
  413. package/app/.next/server/app/index.segments/_tree.segment.rsc +1 -1
  414. package/app/.next/server/app/landing/page_client-reference-manifest.js +1 -1
  415. package/app/.next/server/app/landing.html +1 -1
  416. package/app/.next/server/app/landing.rsc +2 -2
  417. package/app/.next/server/app/landing.segments/_full.segment.rsc +2 -2
  418. package/app/.next/server/app/landing.segments/_head.segment.rsc +1 -1
  419. package/app/.next/server/app/landing.segments/_index.segment.rsc +2 -2
  420. package/app/.next/server/app/landing.segments/_tree.segment.rsc +1 -1
  421. package/app/.next/server/app/landing.segments/landing/__PAGE__.segment.rsc +1 -1
  422. package/app/.next/server/app/landing.segments/landing.segment.rsc +1 -1
  423. package/app/.next/server/app/login/page_client-reference-manifest.js +1 -1
  424. package/app/.next/server/app/login.html +1 -1
  425. package/app/.next/server/app/login.rsc +3 -3
  426. package/app/.next/server/app/login.segments/_full.segment.rsc +3 -3
  427. package/app/.next/server/app/login.segments/_head.segment.rsc +1 -1
  428. package/app/.next/server/app/login.segments/_index.segment.rsc +2 -2
  429. package/app/.next/server/app/login.segments/_tree.segment.rsc +1 -1
  430. package/app/.next/server/app/login.segments/login/__PAGE__.segment.rsc +2 -2
  431. package/app/.next/server/app/login.segments/login.segment.rsc +1 -1
  432. package/app/.next/server/app/page_client-reference-manifest.js +1 -1
  433. package/app/.next/server/app/privacy/page_client-reference-manifest.js +1 -1
  434. package/app/.next/server/app/privacy.html +1 -1
  435. package/app/.next/server/app/privacy.rsc +2 -2
  436. package/app/.next/server/app/privacy.segments/_full.segment.rsc +2 -2
  437. package/app/.next/server/app/privacy.segments/_head.segment.rsc +1 -1
  438. package/app/.next/server/app/privacy.segments/_index.segment.rsc +2 -2
  439. package/app/.next/server/app/privacy.segments/_tree.segment.rsc +1 -1
  440. package/app/.next/server/app/privacy.segments/privacy/__PAGE__.segment.rsc +1 -1
  441. package/app/.next/server/app/privacy.segments/privacy.segment.rsc +1 -1
  442. package/app/.next/server/app/terms/page_client-reference-manifest.js +1 -1
  443. package/app/.next/server/app/terms.html +1 -1
  444. package/app/.next/server/app/terms.rsc +2 -2
  445. package/app/.next/server/app/terms.segments/_full.segment.rsc +2 -2
  446. package/app/.next/server/app/terms.segments/_head.segment.rsc +1 -1
  447. package/app/.next/server/app/terms.segments/_index.segment.rsc +2 -2
  448. package/app/.next/server/app/terms.segments/_tree.segment.rsc +1 -1
  449. package/app/.next/server/app/terms.segments/terms/__PAGE__.segment.rsc +1 -1
  450. package/app/.next/server/app/terms.segments/terms.segment.rsc +1 -1
  451. package/app/.next/server/app-paths-manifest.json +33 -33
  452. package/app/.next/server/chunks/2767.js +1 -1
  453. package/app/.next/server/chunks/2901.js +2 -2
  454. package/app/.next/server/chunks/9824.js +2 -2
  455. package/app/.next/server/chunks/9979.js +1 -1
  456. package/app/.next/server/middleware.js +3 -3
  457. package/app/.next/server/pages/404.html +1 -1
  458. package/app/.next/server/pages/500.html +2 -2
  459. package/app/.next/server/server-reference-manifest.js +1 -1
  460. package/app/.next/server/server-reference-manifest.json +1 -1
  461. package/app/.next/static/chunks/{5846-0dd696b0ace9c63d.js → 5846-1bd03fb1b4b4c154.js} +1 -1
  462. package/app/.next/static/chunks/{993-0fb5100db47366c5.js → 993-4cb24412f8681dc9.js} +2 -2
  463. package/app/.next/static/chunks/app/(dashboard)/dashboard/combos/{page-24700772c6569500.js → page-f017a1a13b450ed3.js} +1 -1
  464. package/app/.next/static/chunks/app/(dashboard)/dashboard/providers/[id]/page-56e8174ce9caec1b.js +1 -0
  465. package/app/package.json +1 -1
  466. package/package.json +1 -1
  467. package/app/.next/static/chunks/app/(dashboard)/dashboard/providers/[id]/page-26ec85a0bf8624f2.js +0 -1
  468. /package/app/.next/static/{MWIZItneSj8laKrHFH9vx → vSmFE3KrF-V4aQjNDtjwN}/_buildManifest.js +0 -0
  469. /package/app/.next/static/{MWIZItneSj8laKrHFH9vx → vSmFE3KrF-V4aQjNDtjwN}/_ssgManifest.js +0 -0
@@ -1 +1 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[3649],{2729:(e,t,s)=>{"use strict";s.r(t),s.d(t,{default:()=>c});var a=s(95155),r=s(12115),l=s(40993),o=s(30949),i=s(67671);let n=/^[a-zA-Z0-9_/.-]+$/;function d(e){return"string"==typeof e?{model:e,weight:0}:{model:e.model,weight:e.weight||0}}function c(){let[e,t]=(0,r.useState)([]),[s,n]=(0,r.useState)(!0),[d,c]=(0,r.useState)(!1),[p,h]=(0,r.useState)(null),[b,g]=(0,r.useState)([]),[f,y]=(0,r.useState)({}),[v,j]=(0,r.useState)(null),[N,k]=(0,r.useState)(null),{copied:w,copy:C}=(0,o.C)(),S=(0,i.i)(),[$,M]=(0,r.useState)(null),[T,_]=(0,r.useState)(null);(0,r.useEffect)(()=>{P(),fetch("/api/settings/proxy").then(e=>e.ok?e.json():null).then(e=>_(e)).catch(()=>{})},[]);let P=async()=>{try{let[e,s,a]=await Promise.all([fetch("/api/combos"),fetch("/api/providers"),fetch("/api/combos/metrics")]),r=await e.json(),l=await s.json(),o=await a.json();if(e.ok&&t(r.combos||[]),s.ok){let e=(l.connections||[]).filter(e=>"active"===e.testStatus||"success"===e.testStatus);g(e)}a.ok&&y(o.metrics||{})}catch(e){console.log("Error fetching data:",e)}finally{n(!1)}},E=async e=>{try{let t=await fetch("/api/combos",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(t.ok)await P(),c(!1),S.success("Combo created successfully");else{let e=await t.json();S.error(e.error?.message||e.error||"Failed to create combo")}}catch(e){S.error("Error creating combo")}},O=async(e,t)=>{try{let s=await fetch(`/api/combos/${e}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(s.ok)await P(),h(null),S.success("Combo updated successfully");else{let e=await s.json();S.error(e.error?.message||e.error||"Failed to update combo")}}catch(e){S.error("Error updating combo")}},D=async s=>{if(confirm("Delete this combo?"))try{(await fetch(`/api/combos/${s}`,{method:"DELETE"})).ok&&(t(e.filter(e=>e.id!==s)),S.success("Combo deleted"))}catch(e){S.error("Error deleting combo")}},R=async t=>{let s=t.name.replace(/-copy(-\d+)?$/,""),a=e.map(e=>e.name),r=`${s}-copy`,l=1;for(;a.includes(r);)l++,r=`${s}-copy-${l}`;let o={name:r,models:t.models,strategy:t.strategy||"priority",config:t.config||{}};await E(o)},q=async e=>{k(e.name),j(null);try{let t=await fetch("/api/combos/test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({comboName:e.name})}),s=await t.json();j(s)}catch(e){j({error:"Test request failed"}),S.error("Test request failed")}},A=async e=>{let s=!1===e.isActive;t(t=>t.map(t=>t.id===e.id?{...t,isActive:s}:t));try{await fetch(`/api/combos/${e.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({isActive:s})})}catch(a){t(t=>t.map(t=>t.id===e.id?{...t,isActive:!s}:t)),S.error("Failed to toggle combo")}};return s?(0,a.jsxs)("div",{className:"flex flex-col gap-6",children:[(0,a.jsx)(l.Qv,{}),(0,a.jsx)(l.Qv,{})]}):(0,a.jsxs)("div",{className:"flex flex-col gap-6",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("h1",{className:"text-2xl font-semibold",children:"Combos"}),(0,a.jsx)("p",{className:"text-sm text-text-muted mt-1",children:"Create model combos with weighted routing and fallback support"})]}),(0,a.jsx)(l.$n,{icon:"add",onClick:()=>c(!0),children:"Create Combo"})]}),0===e.length?(0,a.jsx)(l.pp,{icon:"\uD83E\uDDE9",title:"No combos yet",description:"Create model combos with weighted routing and fallback support",actionLabel:"Create Combo",onAction:()=>c(!0)}):(0,a.jsx)("div",{className:"flex flex-col gap-4",children:e.map(e=>(0,a.jsx)(m,{combo:e,metrics:f[e.name],copied:w,onCopy:C,onEdit:()=>h(e),onDelete:()=>D(e.id),onDuplicate:()=>R(e),onTest:()=>q(e),testing:N===e.name,onProxy:()=>M(e),hasProxy:!!T?.combos?.[e.id],onToggle:()=>A(e)},e.id))}),v&&(0,a.jsx)(l.aF,{isOpen:!!v,onClose:()=>{j(null),k(null)},title:`Test Results — ${N}`,children:(0,a.jsx)(x,{results:v})}),(0,a.jsx)(u,{isOpen:d,onClose:()=>c(!1),onSave:E,activeProviders:b,combo:null},"create"),(0,a.jsx)(u,{isOpen:!!p,combo:p,onClose:()=>h(null),onSave:e=>O(p.id,e),activeProviders:b},p?.id||"new"),$&&(0,a.jsx)(l.KN,{isOpen:!!$,onClose:()=>M(null),level:"combo",levelId:$.id,levelLabel:$.name})]})}function m({combo:e,metrics:t,copied:s,onCopy:r,onEdit:o,onDelete:i,onDuplicate:n,onTest:c,testing:m,onProxy:x,hasProxy:u,onToggle:p}){let h=e.strategy||"priority",b=e.models||[],g=!1===e.isActive;return(0,a.jsx)(l.Zp,{padding:"sm",className:`group ${g?"opacity-50":""}`,children:(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsxs)("div",{className:"flex items-center gap-3 flex-1 min-w-0",children:[(0,a.jsx)("div",{className:"size-8 rounded-lg bg-primary/10 flex items-center justify-center shrink-0",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-primary text-[18px]",children:"layers"})}),(0,a.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("code",{className:"text-sm font-medium font-mono truncate",children:e.name}),(0,a.jsx)("span",{className:`text-[9px] uppercase font-semibold px-1.5 py-0.5 rounded-full ${"weighted"===h?"bg-amber-500/15 text-amber-600 dark:text-amber-400":"round-robin"===h?"bg-emerald-500/15 text-emerald-600 dark:text-emerald-400":"random"===h?"bg-purple-500/15 text-purple-600 dark:text-purple-400":"least-used"===h?"bg-cyan-500/15 text-cyan-600 dark:text-cyan-400":"cost-optimized"===h?"bg-teal-500/15 text-teal-600 dark:text-teal-400":"bg-blue-500/15 text-blue-600 dark:text-blue-400"}`,children:h}),u&&(0,a.jsxs)("span",{className:"text-[9px] uppercase font-semibold px-1.5 py-0.5 rounded-full bg-primary/15 text-primary flex items-center gap-0.5",title:"Proxy configured",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[11px]",children:"vpn_lock"}),"proxy"]}),(0,a.jsx)("button",{onClick:t=>{t.stopPropagation(),r(e.name,`combo-${e.id}`)},className:"p-0.5 hover:bg-black/5 dark:hover:bg-white/5 rounded text-text-muted hover:text-primary transition-colors opacity-0 group-hover:opacity-100",title:"Copy combo name",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:s===`combo-${e.id}`?"check":"content_copy"})})]}),(0,a.jsxs)("div",{className:"flex items-center gap-1 mt-0.5 flex-wrap",children:[0===b.length?(0,a.jsx)("span",{className:"text-xs text-text-muted italic",children:"No models"}):b.slice(0,3).map((e,t)=>{let{model:s,weight:r}=d(e);return(0,a.jsxs)("code",{className:"text-[10px] font-mono bg-black/5 dark:bg-white/5 px-1.5 py-0.5 rounded text-text-muted",children:[s,"weighted"===h&&r>0?` (${r}%)`:""]},t)}),b.length>3&&(0,a.jsxs)("span",{className:"text-[10px] text-text-muted",children:["+",b.length-3," more"]})]}),t&&(0,a.jsxs)("div",{className:"flex items-center gap-3 mt-1",children:[(0,a.jsxs)("span",{className:"text-[10px] text-text-muted",children:[(0,a.jsx)("span",{className:"text-emerald-500",children:t.totalSuccesses}),"/",t.totalRequests," reqs"]}),(0,a.jsxs)("span",{className:"text-[10px] text-text-muted",children:[t.successRate,"% success"]}),(0,a.jsxs)("span",{className:"text-[10px] text-text-muted",children:["~",t.avgLatencyMs,"ms"]}),t.fallbackRate>0&&(0,a.jsxs)("span",{className:"text-[10px] text-amber-500",children:[t.fallbackRate,"% fallback"]})]})]})]}),(0,a.jsxs)("div",{className:"flex items-center gap-1.5 shrink-0 ml-2",children:[(0,a.jsx)(l.lM,{size:"sm",checked:!g,onChange:p,title:g?"Enable combo":"Disable combo"}),(0,a.jsxs)("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[(0,a.jsx)("button",{onClick:c,disabled:m,className:"p-1.5 hover:bg-black/5 dark:hover:bg-white/5 rounded text-text-muted hover:text-emerald-500 transition-colors",title:"Test combo",children:(0,a.jsx)("span",{className:`material-symbols-outlined text-[16px] ${m?"animate-spin":""}`,children:m?"progress_activity":"play_arrow"})}),(0,a.jsx)("button",{onClick:n,className:"p-1.5 hover:bg-black/5 dark:hover:bg-white/5 rounded text-text-muted hover:text-primary transition-colors",title:"Duplicate",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"content_copy"})}),(0,a.jsx)("button",{onClick:x,className:"p-1.5 hover:bg-black/5 dark:hover:bg-white/5 rounded text-text-muted hover:text-primary transition-colors",title:"Proxy configuration",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"vpn_lock"})}),(0,a.jsx)("button",{onClick:o,className:"p-1.5 hover:bg-black/5 dark:hover:bg-white/5 rounded text-text-muted hover:text-primary transition-colors",title:"Edit",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"edit"})}),(0,a.jsx)("button",{onClick:i,className:"p-1.5 hover:bg-red-500/10 rounded text-red-500 transition-colors",title:"Delete",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"delete"})})]})]})]})})}function x({results:e}){return e.error?(0,a.jsxs)("div",{className:"flex items-center gap-2 text-red-500 text-sm",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"error"}),"string"==typeof e.error?e.error:JSON.stringify(e.error)]}):(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[e.resolvedBy&&(0,a.jsxs)("div",{className:"flex items-center gap-2 text-sm",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-emerald-500 text-[18px]",children:"check_circle"}),(0,a.jsxs)("span",{children:["Resolved by:"," ",(0,a.jsx)("code",{className:"text-xs bg-emerald-500/10 text-emerald-600 dark:text-emerald-400 px-1.5 py-0.5 rounded",children:e.resolvedBy})]})]}),e.results?.map((e,t)=>(0,a.jsxs)("div",{className:"flex items-center gap-2 text-xs px-2 py-1.5 rounded bg-black/[0.02] dark:bg-white/[0.02]",children:[(0,a.jsx)("span",{className:`material-symbols-outlined text-[14px] ${"ok"===e.status?"text-emerald-500":"skipped"===e.status?"text-text-muted":"text-red-500"}`,children:"ok"===e.status?"check_circle":"skipped"===e.status?"skip_next":"error"}),(0,a.jsx)("code",{className:"font-mono flex-1",children:e.model}),void 0!==e.latencyMs&&(0,a.jsxs)("span",{className:"text-text-muted",children:[e.latencyMs,"ms"]}),(0,a.jsx)("span",{className:`text-[10px] uppercase font-medium ${"ok"===e.status?"text-emerald-500":"skipped"===e.status?"text-text-muted":"text-red-500"}`,children:e.status})]},t))]})}function u({isOpen:e,combo:t,onClose:s,onSave:o,activeProviders:i}){let[c,m]=(0,r.useState)(t?.name||""),[x,u]=(0,r.useState)(()=>(t?.models||[]).map(e=>d(e))),[h,b]=(0,r.useState)(t?.strategy||"priority"),[g,f]=(0,r.useState)(!1),[y,v]=(0,r.useState)(!1),[j,N]=(0,r.useState)(""),[k,w]=(0,r.useState)({}),[C,S]=(0,r.useState)([]),[$,M]=(0,r.useState)(!1),[T,_]=(0,r.useState)(t?.config||{}),[P,E]=(0,r.useState)(null),[O,D]=(0,r.useState)(null),R=async()=>{try{let[e,t]=await Promise.all([fetch("/api/models/alias"),fetch("/api/provider-nodes")]);if(!e.ok||!t.ok)throw Error(`Failed to fetch data: aliases=${e.status}, nodes=${t.status}`);let[s,a]=await Promise.all([e.json(),t.json()]);w(s.aliases||{}),S(a.nodes||[])}catch(e){console.error("Error fetching modal data:",e)}};(0,r.useEffect)(()=>{e&&R()},[e]);let q=e=>e.trim()?n.test(e)?(N(""),!0):(N("Only letters, numbers, -, _, / and . allowed"),!1):(N("Name is required"),!1),A=(0,r.useCallback)(e=>{let t=e.split("/");if(2!==t.length)return e;let[s,a]=t,r=C.find(e=>e.id===s);return r?`${r.name}/${a}`:e},[C]),z=e=>{e.target&&(e.currentTarget.style.opacity="1"),E(null),D(null)},F=async()=>{if(!q(c))return;v(!0);let e={name:c.trim(),models:"weighted"===h?x:x.map(e=>e.model),strategy:h},t={...T};"round-robin"===h&&(void 0!==T.concurrencyPerModel&&(t.concurrencyPerModel=T.concurrencyPerModel),void 0!==T.queueTimeoutMs&&(t.queueTimeoutMs=T.queueTimeoutMs)),Object.keys(t).length>0&&(e.config=t),await o(e),v(!1)},L=!!t;return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(l.aF,{isOpen:e,onClose:s,title:L?"Edit Combo":"Create Combo",children:(0,a.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)(l.pd,{label:"Combo Name",value:c,onChange:e=>{let t=e.target.value;m(t),t?q(t):N("")},placeholder:"my-combo",error:j}),(0,a.jsx)("p",{className:"text-[10px] text-text-muted mt-0.5",children:"Letters, numbers, -, _, / and . allowed"})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"text-sm font-medium mb-1.5 block",children:"Routing Strategy"}),(0,a.jsx)("div",{className:"grid grid-cols-3 gap-1 p-0.5 bg-black/5 dark:bg-white/5 rounded-lg",children:[{value:"priority",label:"Priority",icon:"sort"},{value:"weighted",label:"Weighted",icon:"percent"},{value:"round-robin",label:"Round-Robin",icon:"autorenew"},{value:"random",label:"Random",icon:"shuffle"},{value:"least-used",label:"Least-Used",icon:"low_priority"},{value:"cost-optimized",label:"Cost-Opt",icon:"savings"}].map(e=>(0,a.jsxs)("button",{onClick:()=>b(e.value),className:`py-1.5 px-2 rounded-md text-xs font-medium transition-all ${h===e.value?"bg-white dark:bg-bg-main shadow-sm text-primary":"text-text-muted hover:text-text-main"}`,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px] align-middle mr-0.5",children:e.icon}),e.label]},e.value))}),(0,a.jsx)("p",{className:"text-[10px] text-text-muted mt-0.5",children:{priority:"Sequential fallback: tries model 1 first, then 2, etc.",weighted:"Distributes traffic by weight percentage with fallback","round-robin":"Circular distribution: each request goes to the next model in rotation",random:"Uniform random selection, then fallback to remaining models","least-used":"Picks the model with fewest requests, balancing load over time","cost-optimized":"Routes to the cheapest model first based on pricing"}[h]})]}),(0,a.jsxs)("div",{children:[(0,a.jsxs)("div",{className:"flex items-center justify-between mb-1.5",children:[(0,a.jsx)("label",{className:"text-sm font-medium",children:"Models"}),"weighted"===h&&x.length>1&&(0,a.jsx)("button",{onClick:()=>{let e=x.length;if(0===e)return;let t=Math.floor(100/e),s=100-t*e;u(x.map((e,a)=>({...e,weight:t+(0===a?s:0)})))},className:"text-[10px] text-primary hover:text-primary/80 transition-colors",children:"Auto-balance"})]}),0===x.length?(0,a.jsxs)("div",{className:"text-center py-4 border border-dashed border-black/10 dark:border-white/10 rounded-lg bg-black/[0.01] dark:bg-white/[0.01]",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-text-muted text-xl mb-1",children:"layers"}),(0,a.jsx)("p",{className:"text-xs text-text-muted",children:"No models added yet"})]}):(0,a.jsx)("div",{className:"flex flex-col gap-1 max-h-[240px] overflow-y-auto",children:x.map((e,t)=>(0,a.jsxs)("div",{draggable:!0,onDragStart:e=>{E(t),e.dataTransfer.effectAllowed="move",e.dataTransfer.setData("text/plain",t.toString()),e.target&&setTimeout(()=>e.currentTarget.style.opacity="0.5",0)},onDragEnd:z,onDragOver:e=>{e.preventDefault(),e.dataTransfer.dropEffect="move",D(t)},onDrop:e=>((e,t)=>{if(e.preventDefault(),null===P||P===t)return;let s=[...x],[a]=s.splice(P,1);s.splice(t,0,a),u(s),E(null),D(null)})(e,t),className:`group/item flex items-center gap-1.5 px-2 py-1.5 rounded-md transition-all cursor-grab active:cursor-grabbing ${O===t&&P!==t?"bg-primary/10 border border-primary/30":"bg-black/[0.02] dark:bg-white/[0.02] hover:bg-black/[0.04] dark:hover:bg-white/[0.04] border border-transparent"} ${P===t?"opacity-50":""}`,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px] text-text-muted/40 cursor-grab shrink-0",children:"drag_indicator"}),(0,a.jsx)("span",{className:"text-[10px] font-medium text-text-muted w-3 text-center shrink-0",children:t+1}),(0,a.jsx)("div",{className:"flex-1 min-w-0 px-1 text-xs text-text-main truncate",children:A(e.model)}),"weighted"===h&&(0,a.jsxs)("div",{className:"flex items-center gap-0.5 shrink-0",children:[(0,a.jsx)("input",{type:"number",min:"0",max:"100",value:e.weight,onChange:e=>{var s;let a;return s=e.target.value,void((a=[...x])[t]={...a[t],weight:Math.max(0,Math.min(100,Number(s)||0))},u(a))},className:"w-10 text-[11px] text-center py-0.5 rounded border border-black/10 dark:border-white/10 bg-transparent focus:border-primary focus:outline-none"}),(0,a.jsx)("span",{className:"text-[10px] text-text-muted",children:"%"})]}),"priority"===h&&(0,a.jsxs)("div",{className:"flex items-center gap-0.5",children:[(0,a.jsx)("button",{onClick:()=>(e=>{if(0===e)return;let t=[...x];[t[e-1],t[e]]=[t[e],t[e-1]],u(t)})(t),disabled:0===t,className:`p-0.5 rounded ${0===t?"text-text-muted/20 cursor-not-allowed":"text-text-muted hover:text-primary hover:bg-black/5 dark:hover:bg-white/5"}`,title:"Move up",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[12px]",children:"arrow_upward"})}),(0,a.jsx)("button",{onClick:()=>(e=>{if(e===x.length-1)return;let t=[...x];[t[e],t[e+1]]=[t[e+1],t[e]],u(t)})(t),disabled:t===x.length-1,className:`p-0.5 rounded ${t===x.length-1?"text-text-muted/20 cursor-not-allowed":"text-text-muted hover:text-primary hover:bg-black/5 dark:hover:bg-white/5"}`,title:"Move down",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[12px]",children:"arrow_downward"})})]}),(0,a.jsx)("button",{onClick:()=>{u(x.filter((e,s)=>s!==t))},className:"p-0.5 hover:bg-red-500/10 rounded text-text-muted hover:text-red-500 transition-all",title:"Remove",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[12px]",children:"close"})})]},`${e.model}-${t}`))}),"weighted"===h&&x.length>0&&(0,a.jsx)(p,{models:x}),(0,a.jsxs)("button",{onClick:()=>f(!0),className:"w-full mt-2 py-2 border border-dashed border-black/10 dark:border-white/10 rounded-lg text-xs text-text-muted hover:text-primary hover:border-primary/30 transition-colors flex items-center justify-center gap-1",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"add"}),"Add Model"]})]}),(0,a.jsxs)("button",{onClick:()=>M(!$),className:"flex items-center gap-1 text-xs text-text-muted hover:text-text-main transition-colors self-start",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:$?"expand_less":"expand_more"}),"Advanced Settings"]}),$&&(0,a.jsxs)("div",{className:"flex flex-col gap-2 p-3 bg-black/[0.02] dark:bg-white/[0.02] rounded-lg border border-black/5 dark:border-white/5",children:[(0,a.jsxs)("div",{className:"grid grid-cols-2 gap-2",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"text-[10px] text-text-muted mb-0.5 block",children:"Max Retries"}),(0,a.jsx)("input",{type:"number",min:"0",max:"10",value:T.maxRetries??"",placeholder:"1",onChange:e=>_({...T,maxRetries:e.target.value?Number(e.target.value):void 0}),className:"w-full text-xs py-1.5 px-2 rounded border border-black/10 dark:border-white/10 bg-transparent focus:border-primary focus:outline-none"})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"text-[10px] text-text-muted mb-0.5 block",children:"Retry Delay (ms)"}),(0,a.jsx)("input",{type:"number",min:"0",max:"60000",step:"500",value:T.retryDelayMs??"",placeholder:"2000",onChange:e=>_({...T,retryDelayMs:e.target.value?Number(e.target.value):void 0}),className:"w-full text-xs py-1.5 px-2 rounded border border-black/10 dark:border-white/10 bg-transparent focus:border-primary focus:outline-none"})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"text-[10px] text-text-muted mb-0.5 block",children:"Timeout (ms)"}),(0,a.jsx)("input",{type:"number",min:"1000",max:"600000",step:"1000",value:T.timeoutMs??"",placeholder:"120000",onChange:e=>_({...T,timeoutMs:e.target.value?Number(e.target.value):void 0}),className:"w-full text-xs py-1.5 px-2 rounded border border-black/10 dark:border-white/10 bg-transparent focus:border-primary focus:outline-none"})]}),(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("label",{className:"text-[10px] text-text-muted",children:"Healthcheck"}),(0,a.jsx)("input",{type:"checkbox",checked:!1!==T.healthCheckEnabled,onChange:e=>_({...T,healthCheckEnabled:e.target.checked}),className:"accent-primary"})]})]}),"round-robin"===h&&(0,a.jsxs)("div",{className:"grid grid-cols-2 gap-2 pt-2 border-t border-black/5 dark:border-white/5",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"text-[10px] text-text-muted mb-0.5 block",children:"Concurrency / Model"}),(0,a.jsx)("input",{type:"number",min:"1",max:"20",value:T.concurrencyPerModel??"",placeholder:"3",onChange:e=>_({...T,concurrencyPerModel:e.target.value?Number(e.target.value):void 0}),className:"w-full text-xs py-1.5 px-2 rounded border border-black/10 dark:border-white/10 bg-transparent focus:border-primary focus:outline-none"})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"text-[10px] text-text-muted mb-0.5 block",children:"Queue Timeout (ms)"}),(0,a.jsx)("input",{type:"number",min:"1000",max:"120000",step:"1000",value:T.queueTimeoutMs??"",placeholder:"30000",onChange:e=>_({...T,queueTimeoutMs:e.target.value?Number(e.target.value):void 0}),className:"w-full text-xs py-1.5 px-2 rounded border border-black/10 dark:border-white/10 bg-transparent focus:border-primary focus:outline-none"})]})]}),(0,a.jsx)("p",{className:"text-[10px] text-text-muted",children:"Leave empty to use global defaults. These override per-provider settings."})]}),(0,a.jsxs)("div",{className:"flex gap-2 pt-1",children:[(0,a.jsx)(l.$n,{onClick:s,variant:"ghost",fullWidth:!0,size:"sm",children:"Cancel"}),(0,a.jsx)(l.$n,{onClick:F,fullWidth:!0,size:"sm",disabled:!c.trim()||!!j||y,children:y?"Saving...":L?"Save":"Create"})]})]})}),(0,a.jsx)(l.rq,{isOpen:g,onClose:()=>f(!1),onSelect:e=>{x.find(t=>t.model===e.value)||u([...x,{model:e.value,weight:0}])},activeProviders:i,modelAliases:k,title:"Add Model to Combo",selectedModel:null})]})}function p({models:e}){let t=e.reduce((e,t)=>e+(t.weight||0),0),s=100===t,r=["bg-blue-500","bg-emerald-500","bg-amber-500","bg-purple-500","bg-rose-500","bg-cyan-500","bg-orange-500","bg-indigo-500"];return(0,a.jsxs)("div",{className:"mt-1.5",children:[(0,a.jsx)("div",{className:"h-1.5 rounded-full bg-black/5 dark:bg-white/5 overflow-hidden flex",children:e.map((e,t)=>e.weight?(0,a.jsx)("div",{className:`${r[t%r.length]} transition-all duration-300`,style:{width:`${Math.min(e.weight,100)}%`}},t):null)}),(0,a.jsxs)("div",{className:"flex items-center justify-between mt-0.5",children:[(0,a.jsx)("div",{className:"flex gap-1",children:e.map((e,t)=>e.weight>0&&(0,a.jsxs)("span",{className:"flex items-center gap-0.5 text-[9px] text-text-muted",children:[(0,a.jsx)("span",{className:`inline-block w-1.5 h-1.5 rounded-full ${r[t%r.length]}`}),e.weight,"%"]},t))}),(0,a.jsxs)("span",{className:`text-[10px] font-medium ${s?"text-emerald-500":t>100?"text-red-500":"text-amber-500"}`,children:[t,"%",!s&&t>0&&" ≠ 100%"]})]})]})}},7762:(e,t,s)=>{Promise.resolve().then(s.bind(s,2729))}},e=>{e.O(0,[8500,9751,782,1149,5846,993,8441,3794,7358],()=>e(e.s=7762)),_N_E=e.O()}]);
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[3649],{2729:(e,t,s)=>{"use strict";s.r(t),s.d(t,{default:()=>c});var a=s(95155),r=s(12115),l=s(40993),o=s(30949),i=s(67671);let n=/^[a-zA-Z0-9_/.-]+$/;function d(e){return"string"==typeof e?{model:e,weight:0}:{model:e.model,weight:e.weight||0}}function c(){let[e,t]=(0,r.useState)([]),[s,n]=(0,r.useState)(!0),[d,c]=(0,r.useState)(!1),[p,h]=(0,r.useState)(null),[b,g]=(0,r.useState)([]),[f,y]=(0,r.useState)({}),[v,j]=(0,r.useState)(null),[N,k]=(0,r.useState)(null),{copied:w,copy:C}=(0,o.C)(),S=(0,i.i)(),[$,M]=(0,r.useState)(null),[T,_]=(0,r.useState)(null);(0,r.useEffect)(()=>{P(),fetch("/api/settings/proxy").then(e=>e.ok?e.json():null).then(e=>_(e)).catch(()=>{})},[]);let P=async()=>{try{let[e,s,a]=await Promise.all([fetch("/api/combos"),fetch("/api/providers"),fetch("/api/combos/metrics")]),r=await e.json(),l=await s.json(),o=await a.json();if(e.ok&&t(r.combos||[]),s.ok){let e=(l.connections||[]).filter(e=>"active"===e.testStatus||"success"===e.testStatus);g(e)}a.ok&&y(o.metrics||{})}catch(e){console.log("Error fetching data:",e)}finally{n(!1)}},E=async e=>{try{let t=await fetch("/api/combos",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(t.ok)await P(),c(!1),S.success("Combo created successfully");else{let e=await t.json();S.error(e.error?.message||e.error||"Failed to create combo")}}catch(e){S.error("Error creating combo")}},O=async(e,t)=>{try{let s=await fetch(`/api/combos/${e}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(s.ok)await P(),h(null),S.success("Combo updated successfully");else{let e=await s.json();S.error(e.error?.message||e.error||"Failed to update combo")}}catch(e){S.error("Error updating combo")}},D=async s=>{if(confirm("Delete this combo?"))try{(await fetch(`/api/combos/${s}`,{method:"DELETE"})).ok&&(t(e.filter(e=>e.id!==s)),S.success("Combo deleted"))}catch(e){S.error("Error deleting combo")}},R=async t=>{let s=t.name.replace(/-copy(-\d+)?$/,""),a=e.map(e=>e.name),r=`${s}-copy`,l=1;for(;a.includes(r);)l++,r=`${s}-copy-${l}`;let o={name:r,models:t.models,strategy:t.strategy||"priority",config:t.config||{}};await E(o)},q=async e=>{k(e.name),j(null);try{let t=await fetch("/api/combos/test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({comboName:e.name})}),s=await t.json();j(s)}catch(e){j({error:"Test request failed"}),S.error("Test request failed")}},A=async e=>{let s=!1===e.isActive;t(t=>t.map(t=>t.id===e.id?{...t,isActive:s}:t));try{await fetch(`/api/combos/${e.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({isActive:s})})}catch(a){t(t=>t.map(t=>t.id===e.id?{...t,isActive:!s}:t)),S.error("Failed to toggle combo")}};return s?(0,a.jsxs)("div",{className:"flex flex-col gap-6",children:[(0,a.jsx)(l.Qv,{}),(0,a.jsx)(l.Qv,{})]}):(0,a.jsxs)("div",{className:"flex flex-col gap-6",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("h1",{className:"text-2xl font-semibold",children:"Combos"}),(0,a.jsx)("p",{className:"text-sm text-text-muted mt-1",children:"Create model combos with weighted routing and fallback support"})]}),(0,a.jsx)(l.$n,{icon:"add",onClick:()=>c(!0),children:"Create Combo"})]}),0===e.length?(0,a.jsx)(l.pp,{icon:"\uD83E\uDDE9",title:"No combos yet",description:"Create model combos with weighted routing and fallback support",actionLabel:"Create Combo",onAction:()=>c(!0)}):(0,a.jsx)("div",{className:"flex flex-col gap-4",children:e.map(e=>(0,a.jsx)(m,{combo:e,metrics:f[e.name],copied:w,onCopy:C,onEdit:()=>h(e),onDelete:()=>D(e.id),onDuplicate:()=>R(e),onTest:()=>q(e),testing:N===e.name,onProxy:()=>M(e),hasProxy:!!T?.combos?.[e.id],onToggle:()=>A(e)},e.id))}),v&&(0,a.jsx)(l.aF,{isOpen:!!v,onClose:()=>{j(null),k(null)},title:`Test Results — ${N}`,children:(0,a.jsx)(x,{results:v})}),(0,a.jsx)(u,{isOpen:d,onClose:()=>c(!1),onSave:E,activeProviders:b,combo:null},"create"),(0,a.jsx)(u,{isOpen:!!p,combo:p,onClose:()=>h(null),onSave:e=>O(p.id,e),activeProviders:b},p?.id||"new"),$&&(0,a.jsx)(l.KN,{isOpen:!!$,onClose:()=>M(null),level:"combo",levelId:$.id,levelLabel:$.name})]})}function m({combo:e,metrics:t,copied:s,onCopy:r,onEdit:o,onDelete:i,onDuplicate:n,onTest:c,testing:m,onProxy:x,hasProxy:u,onToggle:p}){let h=e.strategy||"priority",b=e.models||[],g=!1===e.isActive;return(0,a.jsx)(l.Zp,{padding:"sm",className:`group ${g?"opacity-50":""}`,children:(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsxs)("div",{className:"flex items-center gap-3 flex-1 min-w-0",children:[(0,a.jsx)("div",{className:"size-8 rounded-lg bg-primary/10 flex items-center justify-center shrink-0",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-primary text-[18px]",children:"layers"})}),(0,a.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("code",{className:"text-sm font-medium font-mono truncate",children:e.name}),(0,a.jsx)("span",{className:`text-[9px] uppercase font-semibold px-1.5 py-0.5 rounded-full ${"weighted"===h?"bg-amber-500/15 text-amber-600 dark:text-amber-400":"round-robin"===h?"bg-emerald-500/15 text-emerald-600 dark:text-emerald-400":"random"===h?"bg-purple-500/15 text-purple-600 dark:text-purple-400":"least-used"===h?"bg-cyan-500/15 text-cyan-600 dark:text-cyan-400":"cost-optimized"===h?"bg-teal-500/15 text-teal-600 dark:text-teal-400":"bg-blue-500/15 text-blue-600 dark:text-blue-400"}`,children:h}),u&&(0,a.jsxs)("span",{className:"text-[9px] uppercase font-semibold px-1.5 py-0.5 rounded-full bg-primary/15 text-primary flex items-center gap-0.5",title:"Proxy configured",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[11px]",children:"vpn_lock"}),"proxy"]}),(0,a.jsx)("button",{onClick:t=>{t.stopPropagation(),r(e.name,`combo-${e.id}`)},className:"p-0.5 hover:bg-black/5 dark:hover:bg-white/5 rounded text-text-muted hover:text-primary transition-colors opacity-0 group-hover:opacity-100",title:"Copy combo name",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:s===`combo-${e.id}`?"check":"content_copy"})})]}),(0,a.jsxs)("div",{className:"flex items-center gap-1 mt-0.5 flex-wrap",children:[0===b.length?(0,a.jsx)("span",{className:"text-xs text-text-muted italic",children:"No models"}):b.slice(0,3).map((e,t)=>{let{model:s,weight:r}=d(e);return(0,a.jsxs)("code",{className:"text-[10px] font-mono bg-black/5 dark:bg-white/5 px-1.5 py-0.5 rounded text-text-muted",children:[s,"weighted"===h&&r>0?` (${r}%)`:""]},t)}),b.length>3&&(0,a.jsxs)("span",{className:"text-[10px] text-text-muted",children:["+",b.length-3," more"]})]}),t&&(0,a.jsxs)("div",{className:"flex items-center gap-3 mt-1",children:[(0,a.jsxs)("span",{className:"text-[10px] text-text-muted",children:[(0,a.jsx)("span",{className:"text-emerald-500",children:t.totalSuccesses}),"/",t.totalRequests," reqs"]}),(0,a.jsxs)("span",{className:"text-[10px] text-text-muted",children:[t.successRate,"% success"]}),(0,a.jsxs)("span",{className:"text-[10px] text-text-muted",children:["~",t.avgLatencyMs,"ms"]}),t.fallbackRate>0&&(0,a.jsxs)("span",{className:"text-[10px] text-amber-500",children:[t.fallbackRate,"% fallback"]})]})]})]}),(0,a.jsxs)("div",{className:"flex items-center gap-1.5 shrink-0 ml-2",children:[(0,a.jsx)(l.lM,{size:"sm",checked:!g,onChange:p,title:g?"Enable combo":"Disable combo"}),(0,a.jsxs)("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[(0,a.jsx)("button",{onClick:c,disabled:m,className:"p-1.5 hover:bg-black/5 dark:hover:bg-white/5 rounded text-text-muted hover:text-emerald-500 transition-colors",title:"Test combo",children:(0,a.jsx)("span",{className:`material-symbols-outlined text-[16px] ${m?"animate-spin":""}`,children:m?"progress_activity":"play_arrow"})}),(0,a.jsx)("button",{onClick:n,className:"p-1.5 hover:bg-black/5 dark:hover:bg-white/5 rounded text-text-muted hover:text-primary transition-colors",title:"Duplicate",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"content_copy"})}),(0,a.jsx)("button",{onClick:x,className:"p-1.5 hover:bg-black/5 dark:hover:bg-white/5 rounded text-text-muted hover:text-primary transition-colors",title:"Proxy configuration",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"vpn_lock"})}),(0,a.jsx)("button",{onClick:o,className:"p-1.5 hover:bg-black/5 dark:hover:bg-white/5 rounded text-text-muted hover:text-primary transition-colors",title:"Edit",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"edit"})}),(0,a.jsx)("button",{onClick:i,className:"p-1.5 hover:bg-red-500/10 rounded text-red-500 transition-colors",title:"Delete",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"delete"})})]})]})]})})}function x({results:e}){return e.error?(0,a.jsxs)("div",{className:"flex items-center gap-2 text-red-500 text-sm",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"error"}),"string"==typeof e.error?e.error:JSON.stringify(e.error)]}):(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[e.resolvedBy&&(0,a.jsxs)("div",{className:"flex items-center gap-2 text-sm",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-emerald-500 text-[18px]",children:"check_circle"}),(0,a.jsxs)("span",{children:["Resolved by:"," ",(0,a.jsx)("code",{className:"text-xs bg-emerald-500/10 text-emerald-600 dark:text-emerald-400 px-1.5 py-0.5 rounded",children:e.resolvedBy})]})]}),e.results?.map((e,t)=>(0,a.jsxs)("div",{className:"flex items-center gap-2 text-xs px-2 py-1.5 rounded bg-black/[0.02] dark:bg-white/[0.02]",children:[(0,a.jsx)("span",{className:`material-symbols-outlined text-[14px] ${"ok"===e.status?"text-emerald-500":"skipped"===e.status?"text-text-muted":"text-red-500"}`,children:"ok"===e.status?"check_circle":"skipped"===e.status?"skip_next":"error"}),(0,a.jsx)("code",{className:"font-mono flex-1",children:e.model}),void 0!==e.latencyMs&&(0,a.jsxs)("span",{className:"text-text-muted",children:[e.latencyMs,"ms"]}),(0,a.jsx)("span",{className:`text-[10px] uppercase font-medium ${"ok"===e.status?"text-emerald-500":"skipped"===e.status?"text-text-muted":"text-red-500"}`,children:e.status})]},t))]})}function u({isOpen:e,combo:t,onClose:s,onSave:o,activeProviders:i}){let[c,m]=(0,r.useState)(t?.name||""),[x,u]=(0,r.useState)(()=>(t?.models||[]).map(e=>d(e))),[h,b]=(0,r.useState)(t?.strategy||"priority"),[g,f]=(0,r.useState)(!1),[y,v]=(0,r.useState)(!1),[j,N]=(0,r.useState)(""),[k,w]=(0,r.useState)({}),[C,S]=(0,r.useState)([]),[$,M]=(0,r.useState)(!1),[T,_]=(0,r.useState)(t?.config||{}),[P,E]=(0,r.useState)(null),[O,D]=(0,r.useState)(null),R=async()=>{try{let[e,t]=await Promise.all([fetch("/api/models/alias"),fetch("/api/provider-nodes")]);if(!e.ok||!t.ok)throw Error(`Failed to fetch data: aliases=${e.status}, nodes=${t.status}`);let[s,a]=await Promise.all([e.json(),t.json()]);w(s.aliases||{}),S(a.nodes||[])}catch(e){console.error("Error fetching modal data:",e)}};(0,r.useEffect)(()=>{e&&R()},[e]);let q=e=>e.trim()?n.test(e)?(N(""),!0):(N("Only letters, numbers, -, _, / and . allowed"),!1):(N("Name is required"),!1),A=(0,r.useCallback)(e=>{let t=e.split("/");if(2!==t.length)return e;let[s,a]=t,r=C.find(e=>e.id===s||e.prefix===s);return r?`${r.name}/${a}`:e},[C]),z=e=>{e.target&&(e.currentTarget.style.opacity="1"),E(null),D(null)},F=async()=>{if(!q(c))return;v(!0);let e={name:c.trim(),models:"weighted"===h?x:x.map(e=>e.model),strategy:h},t={...T};"round-robin"===h&&(void 0!==T.concurrencyPerModel&&(t.concurrencyPerModel=T.concurrencyPerModel),void 0!==T.queueTimeoutMs&&(t.queueTimeoutMs=T.queueTimeoutMs)),Object.keys(t).length>0&&(e.config=t),await o(e),v(!1)},L=!!t;return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(l.aF,{isOpen:e,onClose:s,title:L?"Edit Combo":"Create Combo",children:(0,a.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)(l.pd,{label:"Combo Name",value:c,onChange:e=>{let t=e.target.value;m(t),t?q(t):N("")},placeholder:"my-combo",error:j}),(0,a.jsx)("p",{className:"text-[10px] text-text-muted mt-0.5",children:"Letters, numbers, -, _, / and . allowed"})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"text-sm font-medium mb-1.5 block",children:"Routing Strategy"}),(0,a.jsx)("div",{className:"grid grid-cols-3 gap-1 p-0.5 bg-black/5 dark:bg-white/5 rounded-lg",children:[{value:"priority",label:"Priority",icon:"sort"},{value:"weighted",label:"Weighted",icon:"percent"},{value:"round-robin",label:"Round-Robin",icon:"autorenew"},{value:"random",label:"Random",icon:"shuffle"},{value:"least-used",label:"Least-Used",icon:"low_priority"},{value:"cost-optimized",label:"Cost-Opt",icon:"savings"}].map(e=>(0,a.jsxs)("button",{onClick:()=>b(e.value),className:`py-1.5 px-2 rounded-md text-xs font-medium transition-all ${h===e.value?"bg-white dark:bg-bg-main shadow-sm text-primary":"text-text-muted hover:text-text-main"}`,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px] align-middle mr-0.5",children:e.icon}),e.label]},e.value))}),(0,a.jsx)("p",{className:"text-[10px] text-text-muted mt-0.5",children:{priority:"Sequential fallback: tries model 1 first, then 2, etc.",weighted:"Distributes traffic by weight percentage with fallback","round-robin":"Circular distribution: each request goes to the next model in rotation",random:"Uniform random selection, then fallback to remaining models","least-used":"Picks the model with fewest requests, balancing load over time","cost-optimized":"Routes to the cheapest model first based on pricing"}[h]})]}),(0,a.jsxs)("div",{children:[(0,a.jsxs)("div",{className:"flex items-center justify-between mb-1.5",children:[(0,a.jsx)("label",{className:"text-sm font-medium",children:"Models"}),"weighted"===h&&x.length>1&&(0,a.jsx)("button",{onClick:()=>{let e=x.length;if(0===e)return;let t=Math.floor(100/e),s=100-t*e;u(x.map((e,a)=>({...e,weight:t+(0===a?s:0)})))},className:"text-[10px] text-primary hover:text-primary/80 transition-colors",children:"Auto-balance"})]}),0===x.length?(0,a.jsxs)("div",{className:"text-center py-4 border border-dashed border-black/10 dark:border-white/10 rounded-lg bg-black/[0.01] dark:bg-white/[0.01]",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-text-muted text-xl mb-1",children:"layers"}),(0,a.jsx)("p",{className:"text-xs text-text-muted",children:"No models added yet"})]}):(0,a.jsx)("div",{className:"flex flex-col gap-1 max-h-[240px] overflow-y-auto",children:x.map((e,t)=>(0,a.jsxs)("div",{draggable:!0,onDragStart:e=>{E(t),e.dataTransfer.effectAllowed="move",e.dataTransfer.setData("text/plain",t.toString()),e.target&&setTimeout(()=>e.currentTarget.style.opacity="0.5",0)},onDragEnd:z,onDragOver:e=>{e.preventDefault(),e.dataTransfer.dropEffect="move",D(t)},onDrop:e=>((e,t)=>{if(e.preventDefault(),null===P||P===t)return;let s=[...x],[a]=s.splice(P,1);s.splice(t,0,a),u(s),E(null),D(null)})(e,t),className:`group/item flex items-center gap-1.5 px-2 py-1.5 rounded-md transition-all cursor-grab active:cursor-grabbing ${O===t&&P!==t?"bg-primary/10 border border-primary/30":"bg-black/[0.02] dark:bg-white/[0.02] hover:bg-black/[0.04] dark:hover:bg-white/[0.04] border border-transparent"} ${P===t?"opacity-50":""}`,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px] text-text-muted/40 cursor-grab shrink-0",children:"drag_indicator"}),(0,a.jsx)("span",{className:"text-[10px] font-medium text-text-muted w-3 text-center shrink-0",children:t+1}),(0,a.jsx)("div",{className:"flex-1 min-w-0 px-1 text-xs text-text-main truncate",children:A(e.model)}),"weighted"===h&&(0,a.jsxs)("div",{className:"flex items-center gap-0.5 shrink-0",children:[(0,a.jsx)("input",{type:"number",min:"0",max:"100",value:e.weight,onChange:e=>{var s;let a;return s=e.target.value,void((a=[...x])[t]={...a[t],weight:Math.max(0,Math.min(100,Number(s)||0))},u(a))},className:"w-10 text-[11px] text-center py-0.5 rounded border border-black/10 dark:border-white/10 bg-transparent focus:border-primary focus:outline-none"}),(0,a.jsx)("span",{className:"text-[10px] text-text-muted",children:"%"})]}),"priority"===h&&(0,a.jsxs)("div",{className:"flex items-center gap-0.5",children:[(0,a.jsx)("button",{onClick:()=>(e=>{if(0===e)return;let t=[...x];[t[e-1],t[e]]=[t[e],t[e-1]],u(t)})(t),disabled:0===t,className:`p-0.5 rounded ${0===t?"text-text-muted/20 cursor-not-allowed":"text-text-muted hover:text-primary hover:bg-black/5 dark:hover:bg-white/5"}`,title:"Move up",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[12px]",children:"arrow_upward"})}),(0,a.jsx)("button",{onClick:()=>(e=>{if(e===x.length-1)return;let t=[...x];[t[e],t[e+1]]=[t[e+1],t[e]],u(t)})(t),disabled:t===x.length-1,className:`p-0.5 rounded ${t===x.length-1?"text-text-muted/20 cursor-not-allowed":"text-text-muted hover:text-primary hover:bg-black/5 dark:hover:bg-white/5"}`,title:"Move down",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[12px]",children:"arrow_downward"})})]}),(0,a.jsx)("button",{onClick:()=>{u(x.filter((e,s)=>s!==t))},className:"p-0.5 hover:bg-red-500/10 rounded text-text-muted hover:text-red-500 transition-all",title:"Remove",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[12px]",children:"close"})})]},`${e.model}-${t}`))}),"weighted"===h&&x.length>0&&(0,a.jsx)(p,{models:x}),(0,a.jsxs)("button",{onClick:()=>f(!0),className:"w-full mt-2 py-2 border border-dashed border-black/10 dark:border-white/10 rounded-lg text-xs text-text-muted hover:text-primary hover:border-primary/30 transition-colors flex items-center justify-center gap-1",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"add"}),"Add Model"]})]}),(0,a.jsxs)("button",{onClick:()=>M(!$),className:"flex items-center gap-1 text-xs text-text-muted hover:text-text-main transition-colors self-start",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:$?"expand_less":"expand_more"}),"Advanced Settings"]}),$&&(0,a.jsxs)("div",{className:"flex flex-col gap-2 p-3 bg-black/[0.02] dark:bg-white/[0.02] rounded-lg border border-black/5 dark:border-white/5",children:[(0,a.jsxs)("div",{className:"grid grid-cols-2 gap-2",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"text-[10px] text-text-muted mb-0.5 block",children:"Max Retries"}),(0,a.jsx)("input",{type:"number",min:"0",max:"10",value:T.maxRetries??"",placeholder:"1",onChange:e=>_({...T,maxRetries:e.target.value?Number(e.target.value):void 0}),className:"w-full text-xs py-1.5 px-2 rounded border border-black/10 dark:border-white/10 bg-transparent focus:border-primary focus:outline-none"})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"text-[10px] text-text-muted mb-0.5 block",children:"Retry Delay (ms)"}),(0,a.jsx)("input",{type:"number",min:"0",max:"60000",step:"500",value:T.retryDelayMs??"",placeholder:"2000",onChange:e=>_({...T,retryDelayMs:e.target.value?Number(e.target.value):void 0}),className:"w-full text-xs py-1.5 px-2 rounded border border-black/10 dark:border-white/10 bg-transparent focus:border-primary focus:outline-none"})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"text-[10px] text-text-muted mb-0.5 block",children:"Timeout (ms)"}),(0,a.jsx)("input",{type:"number",min:"1000",max:"600000",step:"1000",value:T.timeoutMs??"",placeholder:"120000",onChange:e=>_({...T,timeoutMs:e.target.value?Number(e.target.value):void 0}),className:"w-full text-xs py-1.5 px-2 rounded border border-black/10 dark:border-white/10 bg-transparent focus:border-primary focus:outline-none"})]}),(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("label",{className:"text-[10px] text-text-muted",children:"Healthcheck"}),(0,a.jsx)("input",{type:"checkbox",checked:!1!==T.healthCheckEnabled,onChange:e=>_({...T,healthCheckEnabled:e.target.checked}),className:"accent-primary"})]})]}),"round-robin"===h&&(0,a.jsxs)("div",{className:"grid grid-cols-2 gap-2 pt-2 border-t border-black/5 dark:border-white/5",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"text-[10px] text-text-muted mb-0.5 block",children:"Concurrency / Model"}),(0,a.jsx)("input",{type:"number",min:"1",max:"20",value:T.concurrencyPerModel??"",placeholder:"3",onChange:e=>_({...T,concurrencyPerModel:e.target.value?Number(e.target.value):void 0}),className:"w-full text-xs py-1.5 px-2 rounded border border-black/10 dark:border-white/10 bg-transparent focus:border-primary focus:outline-none"})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"text-[10px] text-text-muted mb-0.5 block",children:"Queue Timeout (ms)"}),(0,a.jsx)("input",{type:"number",min:"1000",max:"120000",step:"1000",value:T.queueTimeoutMs??"",placeholder:"30000",onChange:e=>_({...T,queueTimeoutMs:e.target.value?Number(e.target.value):void 0}),className:"w-full text-xs py-1.5 px-2 rounded border border-black/10 dark:border-white/10 bg-transparent focus:border-primary focus:outline-none"})]})]}),(0,a.jsx)("p",{className:"text-[10px] text-text-muted",children:"Leave empty to use global defaults. These override per-provider settings."})]}),(0,a.jsxs)("div",{className:"flex gap-2 pt-1",children:[(0,a.jsx)(l.$n,{onClick:s,variant:"ghost",fullWidth:!0,size:"sm",children:"Cancel"}),(0,a.jsx)(l.$n,{onClick:F,fullWidth:!0,size:"sm",disabled:!c.trim()||!!j||y,children:y?"Saving...":L?"Save":"Create"})]})]})}),(0,a.jsx)(l.rq,{isOpen:g,onClose:()=>f(!1),onSelect:e=>{x.find(t=>t.model===e.value)||u([...x,{model:e.value,weight:0}])},activeProviders:i,modelAliases:k,title:"Add Model to Combo",selectedModel:null})]})}function p({models:e}){let t=e.reduce((e,t)=>e+(t.weight||0),0),s=100===t,r=["bg-blue-500","bg-emerald-500","bg-amber-500","bg-purple-500","bg-rose-500","bg-cyan-500","bg-orange-500","bg-indigo-500"];return(0,a.jsxs)("div",{className:"mt-1.5",children:[(0,a.jsx)("div",{className:"h-1.5 rounded-full bg-black/5 dark:bg-white/5 overflow-hidden flex",children:e.map((e,t)=>e.weight?(0,a.jsx)("div",{className:`${r[t%r.length]} transition-all duration-300`,style:{width:`${Math.min(e.weight,100)}%`}},t):null)}),(0,a.jsxs)("div",{className:"flex items-center justify-between mt-0.5",children:[(0,a.jsx)("div",{className:"flex gap-1",children:e.map((e,t)=>e.weight>0&&(0,a.jsxs)("span",{className:"flex items-center gap-0.5 text-[9px] text-text-muted",children:[(0,a.jsx)("span",{className:`inline-block w-1.5 h-1.5 rounded-full ${r[t%r.length]}`}),e.weight,"%"]},t))}),(0,a.jsxs)("span",{className:`text-[10px] font-medium ${s?"text-emerald-500":t>100?"text-red-500":"text-amber-500"}`,children:[t,"%",!s&&t>0&&" ≠ 100%"]})]})]})}},7762:(e,t,s)=>{Promise.resolve().then(s.bind(s,2729))}},e=>{e.O(0,[8500,9751,782,1149,5846,993,8441,3794,7358],()=>e(e.s=7762)),_N_E=e.O()}]);
@@ -0,0 +1 @@
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[2134],{56411:(e,t,r)=>{Promise.resolve().then(r.bind(r,88618))},88618:(e,t,r)=>{"use strict";r.r(t),r.d(t,{default:()=>f});var s=r(95155),a=r(12115),i=r(67671),l=r(14051),o=r.n(l),n=r(73321),d=r(98500),c=r.n(d),m=r(5772),p=r(40993),u=r(20909),h=r(81135),x=r(30949);function f(){let e=(0,n.useParams)(),t=(0,n.useRouter)(),r=e.id,[i,l]=(0,a.useState)([]),[o,d]=(0,a.useState)(!0),[f,v]=(0,a.useState)(null),[N,w]=(0,a.useState)(!1),[$,T]=(0,a.useState)(!1),[E,I]=(0,a.useState)(!1),[R,O]=(0,a.useState)(!1),[P,_]=(0,a.useState)(null),[q,U]=(0,a.useState)(null),[D,F]=(0,a.useState)({}),[K,L]=(0,a.useState)(!1),{copied:M,copy:z}=(0,x.C)(),J=(0,a.useRef)(!1),V=(0,a.useRef)(!1),[W,B]=(0,a.useState)(null),[Z,G]=(0,a.useState)(null),[Q,H]=(0,a.useState)(!1),[X,Y]=(0,a.useState)(!1),[ee,et]=(0,a.useState)({current:0,total:0,phase:"idle",status:"",logs:[],error:"",importedCount:0}),er=f?{id:f.id,name:f.name||("anthropic-compatible"===f.type?"Anthropic Compatible":"OpenAI Compatible"),color:"anthropic-compatible"===f.type?"#D97757":"#10A37F",textIcon:"anthropic-compatible"===f.type?"AC":"OC",apiType:f.apiType,baseUrl:f.baseUrl,type:f.type}:u.IS[r]||u.zN[r]||u.fg[r],es=!!u.IS[r]||!!u.zN[r],ea=(0,h.KC)(r),ei=(0,u.wG)(r),el=(0,u.mq)(r),eo=(0,u.gb)(r),en=el||eo,ed=en?r:ei,ec=en?f?.prefix||r:ei,em=(0,a.useCallback)(async()=>{try{let e=await fetch("/api/models/alias"),t=await e.json();e.ok&&F(t.aliases||{})}catch(e){console.log("Error fetching aliases:",e)}},[]),ep=(0,a.useCallback)(async()=>{try{let[e,t]=await Promise.all([fetch("/api/providers",{cache:"no-store"}),fetch("/api/provider-nodes",{cache:"no-store"})]),s=await e.json(),a=await t.json();if(e.ok){let e=(s.connections||[]).filter(e=>e.provider===r);l(e)}if(t.ok){let e=(a.nodes||[]).find(e=>e.id===r)||null;if(!e&&en)for(let t=0;t<3;t+=1){await new Promise(e=>setTimeout(e,150));let t=await fetch("/api/provider-nodes",{cache:"no-store"});if(t.ok&&(e=((await t.json()).nodes||[]).find(e=>e.id===r)||null))break}v(e)}}catch(e){console.log("Error fetching connections:",e)}finally{d(!1)}},[r,en]),eu=async e=>{try{let t=await fetch(`/api/provider-nodes/${r}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),s=await t.json();t.ok&&(v(s.node),await ep(),O(!1))}catch(e){console.log("Error updating provider node:",e)}};(0,a.useEffect)(()=>{ep(),em(),fetch("/api/settings/proxy").then(e=>e.ok?e.json():null).then(e=>G(e)).catch(()=>{})},[ep,em]),(0,a.useEffect)(()=>{o||0!==i.length||!er||en||J.current||V.current||(J.current=!0,es?w(!0):T(!0))},[o]);let eh=async(e,t,r=ei)=>{let s=`${r}/${e}`;try{let e=await fetch("/api/models/alias",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:s,alias:t})});if(e.ok)await em();else{let t=await e.json();alert(t.error||"Failed to set alias")}}catch(e){console.log("Error setting alias:",e)}},ex=async e=>{try{(await fetch(`/api/models/alias?alias=${encodeURIComponent(e)}`,{method:"DELETE"})).ok&&await em()}catch(e){console.log("Error deleting alias:",e)}},ef=async e=>{if(confirm("Delete this connection?"))try{(await fetch(`/api/providers/${e}`,{method:"DELETE"})).ok&&l(i.filter(t=>t.id!==e))}catch(e){console.log("Error deleting connection:",e)}},ey=(0,a.useCallback)(()=>{ep(),w(!1)},[ep]),eg=async e=>{try{let t=await fetch("/api/providers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:r,...e})});if(t.ok)return await ep(),T(!1),null;let s=await t.json().catch(()=>({}));return s.error?.message||s.error||"Failed to save connection"}catch(e){return console.log("Error saving connection:",e),"Failed to save connection. Please try again."}},ev=async e=>{try{(await fetch(`/api/providers/${P.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})).ok&&(await ep(),I(!1))}catch(e){console.log("Error updating connection:",e)}},eb=async(e,t)=>{try{(await fetch(`/api/providers/${e}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({isActive:t})})).ok&&l(r=>r.map(r=>r.id===e?{...r,isActive:t}:r))}catch(e){console.log("Error updating connection status:",e)}},ej=async(e,t)=>{try{(await fetch("/api/rate-limits",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({connectionId:e,enabled:t})})).ok&&l(r=>r.map(r=>r.id===e?{...r,rateLimitProtection:t}:r))}catch(e){console.error("Error toggling rate limit:",e)}},eN=async e=>{if(e&&!q){U(e);try{let t=await fetch(`/api/providers/${e}/test`,{method:"POST"});if(!t.ok){let e=await t.json().catch(()=>({}));alert(e.error||"Failed to retest connection");return}await ep()}catch(e){console.error("Error retesting connection:",e)}finally{U(null)}}},ew=async(e,t)=>{if(e&&t)try{let r=t.priority,s=e.priority;r===s&&(r=i.indexOf(e)>i.indexOf(t)?t.priority-.5:t.priority+.5),await Promise.all([fetch(`/api/providers/${e.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({priority:r})}),fetch(`/api/providers/${t.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({priority:s})})]),await ep()}catch(e){console.log("Error swapping priority:",e)}},ek=async()=>{if(Q)return;let e=i.find(e=>!1!==e.isActive);if(e){H(!0),Y(!0),et({current:0,total:0,phase:"fetching",status:"Fetching available models...",logs:[],error:"",importedCount:0});try{let t=await fetch(`/api/providers/${e.id}/models`),s=await t.json();if(!t.ok)return void et(e=>({...e,phase:"error",status:"Failed to fetch models",error:s.error||"Failed to import models"}));let a=s.models||[];if(0===a.length)return void et(e=>({...e,phase:"done",status:"No models found",logs:["No models returned from /models endpoint."]}));et(e=>({...e,phase:"importing",total:a.length,status:`Importing 0 of ${a.length} models...`,logs:[`Found ${a.length} models. Starting import...`]}));let i=0;for(let e=0;e<a.length;e++){let t=a[e],s=t.id||t.name||t.model;if(!s)continue;let l=s.split("/"),o=l[l.length-1];et(t=>({...t,current:e+1,status:`Importing ${e+1} of ${a.length} models...`,logs:[...t.logs,`Importing ${s}...`]})),await fetch("/api/provider-models",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:r,modelId:s,modelName:t.name||s,source:"imported"})}),D[o]||await eh(s,o,ed),i+=1}await em(),et(e=>({...e,phase:"done",current:a.length,status:i>0?`Successfully imported ${i} model${1===i?"":"s"}!`:"No new models were added (all already exist).",logs:[...e.logs,i>0?`✓ Done! ${i} model${1===i?"":"s"} imported.`:"No new models were added."],importedCount:i})),i>0&&setTimeout(()=>{window.location.reload()},2e3)}catch(e){console.log("Error importing models:",e),et(t=>({...t,phase:"error",status:"Import failed",error:e instanceof Error?e.message:"An unexpected error occurred"}))}finally{H(!1)}}},eC=async(e,t)=>{Y(!0),et({current:0,total:0,phase:"fetching",status:"Fetching available models...",logs:[],error:"",importedCount:0});try{let r=(await e()).models||[];if(0===r.length)return void et(e=>({...e,phase:"done",status:"No models found",logs:["No models returned from /models endpoint."]}));et(e=>({...e,phase:"importing",total:r.length,status:`Importing 0 of ${r.length} models...`,logs:[`Found ${r.length} models. Starting import...`]}));let s=0;for(let e=0;e<r.length;e++){let a=r[e],i=a.id||a.name||a.model;i&&(et(t=>({...t,current:e+1,status:`Importing ${e+1} of ${r.length} models...`,logs:[...t.logs,`Importing ${i}...`]})),await t(a)&&(s+=1))}et(e=>({...e,phase:"done",current:r.length,status:s>0?`Successfully imported ${s} model${1===s?"":"s"}!`:"No new models were added.",logs:[...e.logs,s>0?`✓ Done! ${s} model${1===s?"":"s"} imported.`:"No new models were added."],importedCount:s})),s>0&&setTimeout(()=>{window.location.reload()},2e3)}catch(e){console.log("Error importing models:",e),et(t=>({...t,phase:"error",status:"Import failed",error:e instanceof Error?e.message:"An unexpected error occurred"}))}},eA=i.some(e=>!1!==e.isActive);return o?(0,s.jsxs)("div",{className:"flex flex-col gap-8",children:[(0,s.jsx)(p.Qv,{}),(0,s.jsx)(p.Qv,{})]}):er?(0,s.jsxs)("div",{className:"flex flex-col gap-8",children:[(0,s.jsxs)("div",{children:[(0,s.jsxs)(c(),{href:"/dashboard/providers",className:"inline-flex items-center gap-1 text-sm text-text-muted hover:text-primary transition-colors mb-4",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-lg",children:"arrow_back"}),"Back to Providers"]}),(0,s.jsxs)("div",{className:"flex items-center gap-4",children:[(0,s.jsx)("div",{className:"rounded-lg flex items-center justify-center",style:{backgroundColor:`${er.color}15`},children:K?(0,s.jsx)("span",{className:"text-sm font-bold",style:{color:er.color},children:er.textIcon||er.id.slice(0,2).toUpperCase()}):(0,s.jsx)(m.default,{src:el&&er.apiType?"responses"===er.apiType?"/providers/oai-r.png":"/providers/oai-cc.png":eo?"/providers/anthropic-m.png":`/providers/${er.id}.png`,alt:er.name,width:48,height:48,className:"object-contain rounded-lg max-w-[48px] max-h-[48px]",sizes:"48px",onError:()=>L(!0)})}),(0,s.jsxs)("div",{children:[er.website?(0,s.jsxs)("a",{href:er.website,target:"_blank",rel:"noopener noreferrer",className:"text-3xl font-semibold tracking-tight hover:underline inline-flex items-center gap-2",style:{color:er.color},children:[er.name,(0,s.jsx)("span",{className:"material-symbols-outlined text-lg opacity-60",children:"open_in_new"})]}):(0,s.jsx)("h1",{className:"text-3xl font-semibold tracking-tight",children:er.name}),(0,s.jsxs)("p",{className:"text-text-muted",children:[i.length," connection",1===i.length?"":"s"]})]})]})]}),en&&f&&(0,s.jsxs)(p.Zp,{children:[(0,s.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("h2",{className:"text-lg font-semibold",children:eo?"Anthropic Compatible Details":"OpenAI Compatible Details"}),(0,s.jsxs)("p",{className:"text-sm text-text-muted",children:[eo?"Messages API":"responses"===f.apiType?"Responses API":"Chat Completions"," ","\xb7 ",(f.baseUrl||"").replace(/\/$/,""),"/",eo?"messages":"responses"===f.apiType?"responses":"chat/completions"]})]}),(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)(p.$n,{size:"sm",icon:"add",onClick:()=>T(!0),disabled:i.length>0,children:"Add"}),(0,s.jsx)(p.$n,{size:"sm",variant:"secondary",icon:"edit",onClick:()=>O(!0),children:"Edit"}),(0,s.jsx)(p.$n,{size:"sm",variant:"secondary",icon:"delete",onClick:async()=>{if(confirm(`Delete this ${eo?"Anthropic":"OpenAI"} Compatible node?`))try{(await fetch(`/api/provider-nodes/${r}`,{method:"DELETE"})).ok&&t.push("/dashboard/providers")}catch(e){console.log("Error deleting provider node:",e)}},children:"Delete"})]})]}),i.length>0&&(0,s.jsx)("p",{className:"text-sm text-text-muted",children:"Only one connection is allowed per compatible node. Add another node if you need more connections."})]}),(0,s.jsxs)(p.Zp,{children:[(0,s.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,s.jsx)("h2",{className:"text-lg font-semibold",children:"Connections"}),!en&&(0,s.jsx)(p.$n,{size:"sm",icon:"add",onClick:()=>es?w(!0):T(!0),children:"Add"})]}),0===i.length?(0,s.jsxs)("div",{className:"text-center py-12",children:[(0,s.jsx)("div",{className:"inline-flex items-center justify-center w-16 h-16 rounded-full bg-primary/10 text-primary mb-4",children:(0,s.jsx)("span",{className:"material-symbols-outlined text-[32px]",children:es?"lock":"key"})}),(0,s.jsx)("p",{className:"text-text-main font-medium mb-1",children:"No connections yet"}),(0,s.jsx)("p",{className:"text-sm text-text-muted mb-4",children:"Add your first connection to get started"}),!en&&(0,s.jsx)(p.$n,{icon:"add",onClick:()=>es?w(!0):T(!0),children:"Add Connection"})]}):(0,s.jsx)("div",{className:"flex flex-col divide-y divide-black/[0.03] dark:divide-white/[0.03]",children:i.sort((e,t)=>(e.priority||0)-(t.priority||0)).map((e,t)=>(0,s.jsx)(k,{connection:e,isOAuth:es,isFirst:0===t,isLast:t===i.length-1,onMoveUp:()=>ew(e,i[t-1]),onMoveDown:()=>ew(e,i[t+1]),onToggleActive:t=>eb(e.id,t),onToggleRateLimit:t=>ej(e.id,t),onRetest:()=>eN(e.id),isRetesting:q===e.id,onEdit:()=>{_(e),I(!0)},onDelete:()=>ef(e.id),onReauth:es?()=>w(!0):void 0,onProxy:()=>B({level:"key",id:e.id,label:e.name||e.email||e.id}),hasProxy:!!Z?.keys?.[e.id]},e.id))})]}),(0,s.jsxs)(p.Zp,{children:[(0,s.jsx)("h2",{className:"text-lg font-semibold mb-4",children:"Available Models"}),(()=>{if(en)return(0,s.jsx)(j,{providerStorageAlias:ed,providerDisplayAlias:ec,modelAliases:D,copied:M,onCopy:z,onSetAlias:eh,onDeleteAlias:ex,connections:i,isAnthropic:eo,onImportWithProgress:eC});if(er.passthroughModels)return(0,s.jsxs)("div",{children:[(0,s.jsxs)("div",{className:"flex items-center gap-2 mb-4",children:[(0,s.jsx)(p.$n,{size:"sm",variant:"secondary",icon:"download",onClick:ek,disabled:!eA||Q,children:Q?"Importing...":"Import from /models"}),!eA&&(0,s.jsx)("span",{className:"text-xs text-text-muted",children:"Add a connection to enable importing."})]}),(0,s.jsx)(g,{providerAlias:ei,modelAliases:D,copied:M,onCopy:z,onSetAlias:eh,onDeleteAlias:ex})]});let e=(0,s.jsxs)("div",{className:"flex items-center gap-2 mb-4",children:[(0,s.jsx)(p.$n,{size:"sm",variant:"secondary",icon:"download",onClick:ek,disabled:!eA||Q,children:Q?"Importing...":"Import from /models"}),!eA&&(0,s.jsx)("span",{className:"text-xs text-text-muted",children:"Add a connection to enable importing."})]});return 0===ea.length?(0,s.jsxs)("div",{children:[e,(0,s.jsx)("p",{className:"text-sm text-text-muted",children:"No models configured"})]}):(0,s.jsxs)("div",{children:[e,(0,s.jsx)("div",{className:"flex flex-wrap gap-3",children:ea.map(e=>{let t=`${ed}/${e.id}`,a=`${r}/${e.id}`,i=Object.entries(D).find(([,e])=>e===t||e===a)?.[0];return(0,s.jsx)(y,{model:e,fullModel:`${ec}/${e.id}`,alias:i,copied:M,onCopy:z,onSetAlias:t=>eh(e.id,t,ed),onDeleteAlias:()=>ex(i)},e.id)})})]})})(),!en&&(0,s.jsx)(b,{providerId:r,providerAlias:ec,copied:M,onCopy:z})]}),"kiro"===r?(0,s.jsx)(p.Mh,{isOpen:N,providerInfo:er,onSuccess:ey,onClose:()=>{V.current=!0,w(!1)}}):"cursor"===r?(0,s.jsx)(p.G9,{isOpen:N,onSuccess:ey,onClose:()=>{V.current=!0,w(!1)}}):(0,s.jsx)(p.LF,{isOpen:N,provider:r,providerInfo:er,onSuccess:ey,onClose:()=>{V.current=!0,w(!1)}}),(0,s.jsx)(C,{isOpen:$,provider:r,providerName:er.name,isCompatible:en,isAnthropic:eo,onSave:eg,onClose:()=>T(!1)}),(0,s.jsx)(A,{isOpen:E,connection:P,onSave:ev,onClose:()=>I(!1)}),en&&(0,s.jsx)(S,{isOpen:R,node:f,onSave:eu,onClose:()=>O(!1),isAnthropic:eo}),W&&(0,s.jsx)(p.KN,{isOpen:!!W,onClose:()=>B(null),level:W.level,levelId:W.id,levelLabel:W.label}),(0,s.jsx)(p.aF,{isOpen:X,onClose:()=>{("done"===ee.phase||"error"===ee.phase)&&Y(!1)},title:"Importing Models",size:"md",closeOnOverlay:!1,showCloseButton:"done"===ee.phase||"error"===ee.phase,children:(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,s.jsxs)("div",{className:"flex items-center gap-3",children:["fetching"===ee.phase&&(0,s.jsx)("span",{className:"material-symbols-outlined text-primary animate-spin",children:"progress_activity"}),"importing"===ee.phase&&(0,s.jsx)("span",{className:"material-symbols-outlined text-primary animate-spin",children:"progress_activity"}),"done"===ee.phase&&(0,s.jsx)("span",{className:"material-symbols-outlined text-green-500",children:"check_circle"}),"error"===ee.phase&&(0,s.jsx)("span",{className:"material-symbols-outlined text-red-500",children:"error"}),(0,s.jsx)("span",{className:"text-sm font-medium text-text-main",children:ee.status})]}),("importing"===ee.phase||"done"===ee.phase)&&ee.total>0&&(0,s.jsxs)("div",{className:"w-full",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between mb-1",children:[(0,s.jsxs)("span",{className:"text-xs text-text-muted",children:[ee.current," / ",ee.total]}),(0,s.jsxs)("span",{className:"text-xs text-text-muted",children:[Math.round(ee.current/ee.total*100),"%"]})]}),(0,s.jsx)("div",{className:"w-full h-2.5 bg-black/10 dark:bg-white/10 rounded-full overflow-hidden",children:(0,s.jsx)("div",{className:"h-full rounded-full transition-all duration-300 ease-out",style:{width:`${ee.current/ee.total*100}%`,background:"done"===ee.phase?"linear-gradient(90deg, #22c55e, #16a34a)":"linear-gradient(90deg, var(--color-primary), var(--color-primary-hover, var(--color-primary)))"}})})]}),"fetching"===ee.phase&&(0,s.jsx)("div",{className:"w-full h-2.5 bg-black/10 dark:bg-white/10 rounded-full overflow-hidden",children:(0,s.jsx)("div",{className:"h-full rounded-full animate-pulse",style:{width:"60%",background:"linear-gradient(90deg, var(--color-primary), var(--color-primary-hover, var(--color-primary)))"}})}),"error"===ee.phase&&ee.error&&(0,s.jsx)("div",{className:"p-3 rounded-lg bg-red-500/10 border border-red-500/20",children:(0,s.jsx)("p",{className:"text-sm text-red-400",children:ee.error})}),ee.logs.length>0&&(0,s.jsx)("div",{className:"max-h-48 overflow-y-auto rounded-lg bg-black/5 dark:bg-white/5 p-3 border border-black/5 dark:border-white/5",children:(0,s.jsx)("div",{className:"flex flex-col gap-1",children:ee.logs.map((e,t)=>(0,s.jsx)("p",{className:`text-xs font-mono ${e.startsWith("✓")?"text-green-500 font-semibold":"text-text-muted"}`,children:e},t))})}),"done"===ee.phase&&ee.importedCount>0&&(0,s.jsx)("p",{className:"text-xs text-text-muted text-center animate-pulse",children:"Page will refresh automatically..."})]})})]}):(0,s.jsxs)("div",{className:"text-center py-20",children:[(0,s.jsx)("p",{className:"text-text-muted",children:"Provider not found"}),(0,s.jsx)(c(),{href:"/dashboard/providers",className:"text-primary mt-4 inline-block",children:"Back to Providers"})]})}function y({model:e,fullModel:t,alias:r,copied:a,onCopy:i,onSetAlias:l,onDeleteAlias:o}){return(0,s.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 rounded-lg border border-border hover:bg-sidebar/50",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-base text-text-muted",children:"smart_toy"}),(0,s.jsx)("code",{className:"text-xs text-text-muted font-mono bg-sidebar px-1.5 py-0.5 rounded",children:t}),(0,s.jsx)("button",{onClick:()=>i(t,`model-${e.id}`),className:"p-0.5 hover:bg-sidebar rounded text-text-muted hover:text-primary",title:"Copy model",children:(0,s.jsx)("span",{className:"material-symbols-outlined text-sm",children:a===`model-${e.id}`?"check":"content_copy"})})]})}function g({providerAlias:e,modelAliases:t,copied:r,onCopy:i,onSetAlias:l,onDeleteAlias:o}){let[n,d]=(0,a.useState)(""),[c,m]=(0,a.useState)(!1),u=Object.entries(t).filter(([,t])=>t.startsWith(`${e}/`)).map(([t,r])=>({modelId:r.replace(`${e}/`,""),fullModel:r,alias:t})),h=async()=>{let e;if(!n.trim()||c)return;let r=n.trim(),s=(e=r.split("/"))[e.length-1];if(t[s])return void alert(`Alias "${s}" already exists. Please use a different model or edit existing alias.`);m(!0);try{await l(r,s),d("")}catch(e){console.log("Error adding model:",e)}finally{m(!1)}};return(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,s.jsx)("p",{className:"text-sm text-text-muted",children:"OpenRouter supports any model. Add models and create aliases for quick access."}),(0,s.jsxs)("div",{className:"flex items-end gap-2",children:[(0,s.jsxs)("div",{className:"flex-1",children:[(0,s.jsx)("label",{htmlFor:"new-model-input",className:"text-xs text-text-muted mb-1 block",children:"Model ID (from OpenRouter)"}),(0,s.jsx)("input",{id:"new-model-input",type:"text",value:n,onChange:e=>d(e.target.value),onKeyDown:e=>"Enter"===e.key&&h(),placeholder:"anthropic/claude-3-opus",className:"w-full px-3 py-2 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary"})]}),(0,s.jsx)(p.$n,{size:"sm",icon:"add",onClick:h,disabled:!n.trim()||c,children:c?"Adding...":"Add"})]}),u.length>0&&(0,s.jsx)("div",{className:"flex flex-col gap-3",children:u.map(({modelId:e,fullModel:t,alias:a})=>(0,s.jsx)(v,{modelId:e,fullModel:t,copied:r,onCopy:i,onDeleteAlias:()=>o(a)},t))})]})}function v({modelId:e,fullModel:t,copied:r,onCopy:a,onDeleteAlias:i}){return(0,s.jsxs)("div",{className:"flex items-center gap-3 p-3 rounded-lg border border-border hover:bg-sidebar/50",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-base text-text-muted",children:"smart_toy"}),(0,s.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,s.jsx)("p",{className:"text-sm font-medium truncate",children:e}),(0,s.jsxs)("div",{className:"flex items-center gap-1 mt-1",children:[(0,s.jsx)("code",{className:"text-xs text-text-muted font-mono bg-sidebar px-1.5 py-0.5 rounded",children:t}),(0,s.jsx)("button",{onClick:()=>a(t,`model-${e}`),className:"p-0.5 hover:bg-sidebar rounded text-text-muted hover:text-primary",title:"Copy model",children:(0,s.jsx)("span",{className:"material-symbols-outlined text-sm",children:r===`model-${e}`?"check":"content_copy"})})]})]}),(0,s.jsx)("button",{onClick:i,className:"p-1 hover:bg-red-50 rounded text-red-500",title:"Remove model",children:(0,s.jsx)("span",{className:"material-symbols-outlined text-sm",children:"delete"})})]})}function b({providerId:e,providerAlias:t,copied:r,onCopy:i}){let[l,o]=(0,a.useState)([]),[n,d]=(0,a.useState)(""),[c,m]=(0,a.useState)(""),[u,h]=(0,a.useState)(!1),[x,f]=(0,a.useState)(!0),y=(0,a.useCallback)(async()=>{try{let t=await fetch(`/api/provider-models?provider=${encodeURIComponent(e)}`);if(t.ok){let e=await t.json();o(e.models||[])}}catch(e){console.error("Failed to fetch custom models:",e)}finally{f(!1)}},[e]);(0,a.useEffect)(()=>{y()},[y]);let g=async()=>{if(n.trim()&&!u){h(!0);try{(await fetch("/api/provider-models",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:e,modelId:n.trim(),modelName:c.trim()||void 0})})).ok&&(d(""),m(""),await y())}catch(e){console.error("Failed to add custom model:",e)}finally{h(!1)}}},v=async t=>{try{await fetch(`/api/provider-models?provider=${encodeURIComponent(e)}&model=${encodeURIComponent(t)}`,{method:"DELETE"}),await y()}catch(e){console.error("Failed to remove custom model:",e)}};return(0,s.jsxs)("div",{className:"mt-6 pt-6 border-t border-border",children:[(0,s.jsxs)("h3",{className:"text-sm font-semibold mb-3 flex items-center gap-2",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-base text-primary",children:"tune"}),"Custom Models"]}),(0,s.jsx)("p",{className:"text-xs text-text-muted mb-3",children:"Add model IDs not in the default list. These will be available for routing."}),(0,s.jsxs)("div",{className:"flex items-end gap-2 mb-3",children:[(0,s.jsxs)("div",{className:"flex-1",children:[(0,s.jsx)("label",{htmlFor:"custom-model-id",className:"text-xs text-text-muted mb-1 block",children:"Model ID"}),(0,s.jsx)("input",{id:"custom-model-id",type:"text",value:n,onChange:e=>d(e.target.value),onKeyDown:e=>"Enter"===e.key&&g(),placeholder:"e.g. gpt-4.5-turbo",className:"w-full px-3 py-2 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary"})]}),(0,s.jsxs)("div",{className:"w-40",children:[(0,s.jsx)("label",{htmlFor:"custom-model-name",className:"text-xs text-text-muted mb-1 block",children:"Display Name"}),(0,s.jsx)("input",{id:"custom-model-name",type:"text",value:c,onChange:e=>m(e.target.value),onKeyDown:e=>"Enter"===e.key&&g(),placeholder:"Optional",className:"w-full px-3 py-2 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary"})]}),(0,s.jsx)(p.$n,{size:"sm",icon:"add",onClick:g,disabled:!n.trim()||u,children:u?"Adding...":"Add"})]}),x?(0,s.jsx)("p",{className:"text-xs text-text-muted",children:"Loading..."}):l.length>0?(0,s.jsx)("div",{className:"flex flex-col gap-2",children:l.map(e=>{let a=`${t}/${e.id}`,l=`custom-${e.id}`;return(0,s.jsxs)("div",{className:"flex items-center gap-3 p-3 rounded-lg border border-border hover:bg-sidebar/50",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-base text-primary",children:"tune"}),(0,s.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,s.jsx)("p",{className:"text-sm font-medium truncate",children:e.name||e.id}),(0,s.jsxs)("div",{className:"flex items-center gap-1 mt-1",children:[(0,s.jsx)("code",{className:"text-xs text-text-muted font-mono bg-sidebar px-1.5 py-0.5 rounded",children:a}),(0,s.jsx)("button",{onClick:()=>i(a,l),className:"p-0.5 hover:bg-sidebar rounded text-text-muted hover:text-primary",title:"Copy model",children:(0,s.jsx)("span",{className:"material-symbols-outlined text-sm",children:r===l?"check":"content_copy"})})]})]}),(0,s.jsx)("button",{onClick:()=>v(e.id),className:"p-1 hover:bg-red-50 rounded text-red-500",title:"Remove custom model",children:(0,s.jsx)("span",{className:"material-symbols-outlined text-sm",children:"delete"})})]},e.id)})}):(0,s.jsx)("p",{className:"text-xs text-text-muted",children:"No custom models added yet."})]})}function j({providerStorageAlias:e,providerDisplayAlias:t,modelAliases:r,copied:l,onCopy:o,onSetAlias:n,onDeleteAlias:d,connections:c,isAnthropic:m,onImportWithProgress:u}){let[h,x]=(0,a.useState)(""),[f,y]=(0,a.useState)(!1),[g,b]=(0,a.useState)(!1),j=(0,i.i)(),N=Object.entries(r).filter(([,t])=>t.startsWith(`${e}/`)).map(([t,r])=>({modelId:r.replace(`${e}/`,""),fullModel:r,alias:t})),w=e=>{let s,a=(s=e.split("/"))[s.length-1];if(!r[a])return a;let i=`${t}-${a}`;return r[i]?null:i},k=async()=>{if(!h.trim()||f)return;let t=h.trim(),r=w(t);if(!r)return void j.error("All suggested aliases already exist. Please choose a different model or remove conflicting aliases.");y(!0);try{let s=await fetch("/api/provider-models",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:e,modelId:t,modelName:t,source:"manual"})});if(!s.ok){let e={};try{e=await s.json()}catch(e){console.error("Failed to parse error response from custom model API:",e)}throw Error(e.error?.message||"Failed to save custom model")}await n(t,r,e),x(""),j.success(`Model ${t} added successfully`)}catch(e){console.error("Error adding model:",e),j.error(e instanceof Error?e.message:"Failed to add model. Please try again.")}finally{y(!1)}},C=async()=>{if(g)return;let t=c.find(e=>!1!==e.isActive);if(t){b(!0);try{await u(async()=>{let e=await fetch(`/api/providers/${t.id}/models`),r=await e.json();if(!e.ok)throw Error(r.error||"Failed to import models");return r},async t=>{let r=t.id||t.name||t.model;if(!r)return!1;let s=w(r);return!!s&&((await fetch("/api/provider-models",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:e,modelId:r,modelName:t.name||r,source:"imported"})})).ok?(await n(r,s,e),!0):(j.error("Failed to save imported model to custom database"),!1))})}catch(e){console.error("Error importing models:",e),j.error("Failed to import models. Please try again.")}finally{b(!1)}}},A=c.some(e=>!1!==e.isActive),S=async(t,r)=>{try{if(!(await fetch(`/api/provider-models?provider=${encodeURIComponent(e)}&model=${encodeURIComponent(t)}`,{method:"DELETE"})).ok)throw Error("Failed to remove model from database");await d(r),j.success("Model removed successfully")}catch(e){console.error("Error deleting model:",e),j.error(e instanceof Error?e.message:"Failed to delete model. Please try again.")}};return(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,s.jsxs)("p",{className:"text-sm text-text-muted",children:["Add ",m?"Anthropic":"OpenAI","-compatible models manually or import them from the /models endpoint."]}),(0,s.jsxs)("div",{className:"flex items-end gap-2 flex-wrap",children:[(0,s.jsxs)("div",{className:"flex-1 min-w-[240px]",children:[(0,s.jsx)("label",{htmlFor:"new-compatible-model-input",className:"text-xs text-text-muted mb-1 block",children:"Model ID"}),(0,s.jsx)("input",{id:"new-compatible-model-input",type:"text",value:h,onChange:e=>x(e.target.value),onKeyDown:e=>"Enter"===e.key&&k(),placeholder:m?"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,s.jsx)(p.$n,{size:"sm",icon:"add",onClick:k,disabled:!h.trim()||f,children:f?"Adding...":"Add"}),(0,s.jsx)(p.$n,{size:"sm",variant:"secondary",icon:"download",onClick:C,disabled:!A||g,children:g?"Importing...":"Import from /models"})]}),!A&&(0,s.jsx)("p",{className:"text-xs text-text-muted",children:"Add a connection to enable importing models."}),N.length>0&&(0,s.jsx)("div",{className:"flex flex-col gap-3",children:N.map(({modelId:e,fullModel:r,alias:a})=>(0,s.jsx)(v,{modelId:e,fullModel:`${t}/${e}`,copied:l,onCopy:o,onDeleteAlias:()=>S(e,a)},r))})]})}function N({until:e}){let[t,r]=(0,a.useState)("");return((0,a.useEffect)(()=>{let t=()=>{let t=new Date(e).getTime()-Date.now();if(t<=0)return void r("");let s=Math.floor(t/1e3);if(s<60)r(`${s}s`);else if(s<3600)r(`${Math.floor(s/60)}m ${s%60}s`);else{let e=Math.floor(s/3600),t=Math.floor(s%3600/60);r(`${e}h ${t}m`)}};t();let s=setInterval(t,1e3);return()=>clearInterval(s)},[e]),t)?(0,s.jsxs)("span",{className:"text-xs text-orange-500 font-mono",children:["⏱ ",t]}):null}y.propTypes={model:o().shape({id:o().string.isRequired}).isRequired,fullModel:o().string.isRequired,alias:o().string,copied:o().string,onCopy:o().func.isRequired},g.propTypes={providerAlias:o().string.isRequired,modelAliases:o().object.isRequired,copied:o().string,onCopy:o().func.isRequired,onSetAlias:o().func.isRequired,onDeleteAlias:o().func.isRequired},v.propTypes={modelId:o().string.isRequired,fullModel:o().string.isRequired,copied:o().string,onCopy:o().func.isRequired,onDeleteAlias:o().func.isRequired},b.propTypes={providerId:o().string.isRequired,providerAlias:o().string.isRequired,copied:o().string,onCopy:o().func.isRequired},j.propTypes={providerStorageAlias:o().string.isRequired,providerDisplayAlias:o().string.isRequired,modelAliases:o().object.isRequired,copied:o().string,onCopy:o().func.isRequired,onSetAlias:o().func.isRequired,onDeleteAlias:o().func.isRequired,connections:o().arrayOf(o().shape({id:o().string,isActive:o().bool})).isRequired,isAnthropic:o().bool,onImportWithProgress:o().func.isRequired},N.propTypes={until:o().string.isRequired};let w={runtime_error:{label:"Local runtime",variant:"warning"},upstream_auth_error:{label:"Upstream auth",variant:"error"},auth_missing:{label:"Missing credential",variant:"warning"},token_refresh_failed:{label:"Refresh failed",variant:"warning"},token_expired:{label:"Token expired",variant:"warning"},upstream_rate_limited:{label:"Rate limited",variant:"warning"},upstream_unavailable:{label:"Upstream unavailable",variant:"error"},network_error:{label:"Network error",variant:"warning"},unsupported:{label:"Test unsupported",variant:"default"},upstream_error:{label:"Upstream error",variant:"error"}};function k({connection:e,isOAuth:t,isFirst:r,isLast:i,onMoveUp:l,onMoveDown:o,onToggleActive:n,onToggleRateLimit:d,onRetest:c,isRetesting:m,onEdit:u,onDelete:h,onReauth:x,onProxy:f,hasProxy:y}){let g=t?e.name||e.email||e.displayName||"OAuth Account":e.name,[v,b]=(0,a.useState)(!1);(0,a.useEffect)(()=>{let t=()=>{b(e.rateLimitedUntil&&new Date(e.rateLimitedUntil).getTime()>Date.now())};t();let r=e.rateLimitedUntil?setInterval(t,1e3):null;return()=>{r&&clearInterval(r)}},[e.rateLimitedUntil]);let j="unavailable"!==e.testStatus||v?e.testStatus:"active",k=function(e,t,r){if(!1===e.isActive)return{statusVariant:"default",statusLabel:"disabled",errorType:null,errorBadge:null,errorTextClass:"text-text-muted"};if("active"===t||"success"===t)return{statusVariant:"success",statusLabel:"connected",errorType:null,errorBadge:null,errorTextClass:"text-text-muted"};let s=function(e,t){if(t)return"upstream_rate_limited";if(e.lastErrorType)return e.lastErrorType;let r=Number(e.errorCode);if(401===r||403===r)return"upstream_auth_error";if(429===r)return"upstream_rate_limited";if(r>=500)return"upstream_unavailable";let s=(e.lastError||"").toLowerCase();return s?s.includes("runtime")||s.includes("not runnable")||s.includes("not installed")||s.includes("healthcheck")?"runtime_error":s.includes("refresh failed")?"token_refresh_failed":s.includes("token expired")||s.includes("expired")?"token_expired":s.includes("invalid api key")||s.includes("token invalid")||s.includes("revoked")||s.includes("access denied")||s.includes("unauthorized")?"upstream_auth_error":s.includes("rate limit")||s.includes("quota")||s.includes("too many requests")||s.includes("429")?"upstream_rate_limited":s.includes("fetch failed")||s.includes("network")||s.includes("timeout")||s.includes("econn")||s.includes("enotfound")?"network_error":s.includes("not supported")?"unsupported":"upstream_error":null}(e,r),a=s&&w[s]||null;return"runtime_error"===s?{statusVariant:"warning",statusLabel:"runtime issue",errorType:s,errorBadge:a,errorTextClass:"text-yellow-600 dark:text-yellow-400"}:"upstream_auth_error"===s||"auth_missing"===s||"token_refresh_failed"===s||"token_expired"===s?{statusVariant:"error",statusLabel:"auth failed",errorType:s,errorBadge:a,errorTextClass:"text-red-500"}:"upstream_rate_limited"===s?{statusVariant:"warning",statusLabel:"rate limited",errorType:s,errorBadge:a,errorTextClass:"text-yellow-600 dark:text-yellow-400"}:"network_error"===s?{statusVariant:"warning",statusLabel:"network issue",errorType:s,errorBadge:a,errorTextClass:"text-yellow-600 dark:text-yellow-400"}:"unsupported"===s?{statusVariant:"default",statusLabel:"test unsupported",errorType:s,errorBadge:a,errorTextClass:"text-text-muted"}:{statusVariant:"error",statusLabel:t||"error",errorType:s,errorBadge:a,errorTextClass:"text-red-500"}}(e,j,v),C=!!e.rateLimitProtection;return(0,s.jsxs)("div",{className:`group flex items-center justify-between p-3 rounded-lg hover:bg-black/[0.02] dark:hover:bg-white/[0.02] transition-colors ${!1===e.isActive?"opacity-60":""}`,children:[(0,s.jsxs)("div",{className:"flex items-center gap-3 flex-1 min-w-0",children:[(0,s.jsxs)("div",{className:"flex flex-col",children:[(0,s.jsx)("button",{onClick:l,disabled:r,className:`p-0.5 rounded ${r?"text-text-muted/30 cursor-not-allowed":"hover:bg-sidebar text-text-muted hover:text-primary"}`,children:(0,s.jsx)("span",{className:"material-symbols-outlined text-sm",children:"keyboard_arrow_up"})}),(0,s.jsx)("button",{onClick:o,disabled:i,className:`p-0.5 rounded ${i?"text-text-muted/30 cursor-not-allowed":"hover:bg-sidebar text-text-muted hover:text-primary"}`,children:(0,s.jsx)("span",{className:"material-symbols-outlined text-sm",children:"keyboard_arrow_down"})})]}),(0,s.jsx)("span",{className:"material-symbols-outlined text-base text-text-muted",children:t?"lock":"key"}),(0,s.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,s.jsx)("p",{className:"text-sm font-medium truncate",children:g}),(0,s.jsxs)("div",{className:"flex items-center gap-2 mt-1 flex-wrap",children:[(0,s.jsx)(p.Ex,{variant:k.statusVariant,size:"sm",dot:!0,children:k.statusLabel}),v&&!1!==e.isActive&&(0,s.jsx)(N,{until:e.rateLimitedUntil}),k.errorBadge&&!1!==e.isActive&&(0,s.jsx)(p.Ex,{variant:k.errorBadge.variant,size:"sm",children:k.errorBadge.label}),e.lastError&&!1!==e.isActive&&(0,s.jsx)("span",{className:`text-xs truncate max-w-[300px] ${k.errorTextClass}`,title:e.lastError,children:e.lastError}),(0,s.jsxs)("span",{className:"text-xs text-text-muted",children:["#",e.priority]}),e.globalPriority&&(0,s.jsxs)("span",{className:"text-xs text-text-muted",children:["Auto: ",e.globalPriority]}),(0,s.jsx)("span",{className:"text-text-muted/30 select-none",children:"|"}),(0,s.jsxs)("button",{onClick:()=>d(!C),className:`inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-xs font-medium transition-all cursor-pointer ${C?"bg-emerald-500/15 text-emerald-500 hover:bg-emerald-500/25":"bg-black/[0.03] dark:bg-white/[0.03] text-text-muted/50 hover:text-text-muted hover:bg-black/[0.06] dark:hover:bg-white/[0.06]"}`,title:C?"Click to disable rate limit protection":"Click to enable rate limit protection",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-[13px]",children:"shield"}),C?"Protected":"Unprotected"]}),y&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("span",{className:"text-text-muted/30 select-none",children:"|"}),(0,s.jsxs)("span",{className:"inline-flex items-center gap-0.5 px-1.5 py-0.5 rounded text-xs font-medium bg-primary/15 text-primary",title:"Proxy configured",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-[13px]",children:"vpn_lock"}),"Proxy"]})]})]})]})]}),(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)(p.$n,{size:"sm",variant:"ghost",icon:"refresh",loading:m,disabled:!1===e.isActive,onClick:c,className:"!h-7 !px-2 text-xs",title:"Retest authentication",children:"Retest"}),(0,s.jsx)(p.lM,{size:"sm",checked:e.isActive??!0,onChange:n,title:e.isActive??!0?"Disable connection":"Enable connection"}),(0,s.jsxs)("div",{className:"flex gap-1 ml-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[x&&(0,s.jsx)("button",{onClick:x,className:"p-2 hover:bg-amber-500/10 rounded text-amber-600 hover:text-amber-500",title:"Re-authenticate this connection",children:(0,s.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"passkey"})}),(0,s.jsx)("button",{onClick:u,className:"p-2 hover:bg-black/5 dark:hover:bg-white/5 rounded text-text-muted hover:text-primary",children:(0,s.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"edit"})}),(0,s.jsx)("button",{onClick:f,className:"p-2 hover:bg-black/5 dark:hover:bg-white/5 rounded text-text-muted hover:text-primary",title:"Proxy config",children:(0,s.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"vpn_lock"})}),(0,s.jsx)("button",{onClick:h,className:"p-2 hover:bg-red-500/10 rounded text-red-500",children:(0,s.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"delete"})})]})]})]})}function C({isOpen:e,provider:t,providerName:r,isCompatible:i,isAnthropic:l,onSave:o,onClose:n}){let[d,c]=(0,a.useState)({name:"",apiKey:"",priority:1}),[m,u]=(0,a.useState)(!1),[h,x]=(0,a.useState)(null),[f,y]=(0,a.useState)(!1),[g,v]=(0,a.useState)(null),b=async()=>{u(!0),v(null);try{let e=await fetch("/api/providers/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:t,apiKey:d.apiKey})}),r=await e.json();x(r.valid?"success":"failed")}catch{x("failed")}finally{u(!1)}},j=async()=>{if(t&&d.apiKey){y(!0),v(null);try{let e=!1;try{u(!0),x(null);let r=await fetch("/api/providers/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:t,apiKey:d.apiKey})});e=!!(await r.json()).valid,x(e?"success":"failed")}catch{x("failed")}finally{u(!1)}if(!e)return void v("API key validation failed. Please check your key and try again.");let r=await o({name:d.name,apiKey:d.apiKey,priority:d.priority,testStatus:"active"});r&&v("string"==typeof r?r:"Failed to save connection")}finally{y(!1)}}};return t?(0,s.jsx)(p.aF,{isOpen:e,title:`Add ${r||t} API Key`,onClose:n,children:(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,s.jsx)(p.pd,{label:"Name",value:d.name,onChange:e=>c({...d,name:e.target.value}),placeholder:"Production Key"}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(p.pd,{label:"API Key",type:"password",value:d.apiKey,onChange:e=>c({...d,apiKey:e.target.value}),className:"flex-1"}),(0,s.jsx)("div",{className:"pt-6",children:(0,s.jsx)(p.$n,{onClick:b,disabled:!d.apiKey||m||f,variant:"secondary",children:m?"Checking...":"Check"})})]}),h&&(0,s.jsx)(p.Ex,{variant:"success"===h?"success":"error",children:"success"===h?"Valid":"Invalid"}),g&&(0,s.jsx)("div",{className:"text-sm text-red-500 bg-red-500/10 border border-red-500/20 rounded-lg px-3 py-2",children:g}),i&&(0,s.jsx)("p",{className:"text-xs text-text-muted",children:l?`Validation checks ${r||"Anthropic Compatible"} by verifying the API key.`:`Validation checks ${r||"OpenAI Compatible"} via /models on your base URL.`}),(0,s.jsx)(p.pd,{label:"Priority",type:"number",value:d.priority,onChange:e=>c({...d,priority:Number.parseInt(e.target.value)||1})}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(p.$n,{onClick:j,fullWidth:!0,disabled:!d.name||!d.apiKey||f,children:f?"Saving...":"Save"}),(0,s.jsx)(p.$n,{onClick:n,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})}):null}function A({isOpen:e,connection:t,onSave:r,onClose:i}){let[l,o]=(0,a.useState)({name:"",priority:1,apiKey:"",healthCheckInterval:60}),[n,d]=(0,a.useState)(!1),[c,m]=(0,a.useState)(null),[h,x]=(0,a.useState)(!1),[f,y]=(0,a.useState)(null),[g,v]=(0,a.useState)(!1);(0,a.useEffect)(()=>{t&&(o({name:t.name||"",priority:t.priority||1,apiKey:"",healthCheckInterval:t.healthCheckInterval??60}),m(null),y(null))},[t]);let b=async()=>{if(t?.provider){d(!0),m(null);try{let e=await fetch(`/api/providers/${t.id}/test`,{method:"POST"}),r=await e.json();m({valid:!!r.valid,diagnosis:r.diagnosis||null,message:r.error||null})}catch{m({valid:!1,diagnosis:{type:"network_error"},message:"Failed to test connection"})}finally{d(!1)}}},j=async()=>{if(t?.provider&&l.apiKey){x(!0),y(null);try{let e=await fetch("/api/providers/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:t.provider,apiKey:l.apiKey})}),r=await e.json();y(r.valid?"success":"failed")}catch{y("failed")}finally{x(!1)}}},N=async()=>{v(!0);try{let e={name:l.name,priority:l.priority,healthCheckInterval:l.healthCheckInterval};if(!k&&l.apiKey){e.apiKey=l.apiKey;let r="success"===f;if(!r)try{x(!0),y(null);let e=await fetch("/api/providers/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:t.provider,apiKey:l.apiKey})});r=!!(await e.json()).valid,y(r?"success":"failed")}catch{y("failed")}finally{x(!1)}r&&(e.testStatus="active",e.lastError=null,e.lastErrorAt=null,e.lastErrorType=null,e.lastErrorSource=null,e.errorCode=null,e.rateLimitedUntil=null)}await r(e)}finally{v(!1)}};if(!t)return null;let k="oauth"===t.authType,C=(0,u.mq)(t.provider)||(0,u.gb)(t.provider),A=!c?.valid&&c?.diagnosis?.type&&w[c.diagnosis.type]||null;return(0,s.jsx)(p.aF,{isOpen:e,title:"Edit Connection",onClose:i,children:(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,s.jsx)(p.pd,{label:"Name",value:l.name,onChange:e=>o({...l,name:e.target.value}),placeholder:k?"Account name":"Production Key"}),k&&t.email&&(0,s.jsxs)("div",{className:"bg-sidebar/50 p-3 rounded-lg",children:[(0,s.jsx)("p",{className:"text-sm text-text-muted mb-1",children:"Email"}),(0,s.jsx)("p",{className:"font-medium",children:t.email})]}),k&&(0,s.jsx)(p.pd,{label:"Health Check (min)",type:"number",value:l.healthCheckInterval,onChange:e=>o({...l,healthCheckInterval:Math.max(0,Number.parseInt(e.target.value)||0)}),hint:"Proactive token refresh interval. 0 = disabled."}),(0,s.jsx)(p.pd,{label:"Priority",type:"number",value:l.priority,onChange:e=>o({...l,priority:Number.parseInt(e.target.value)||1})}),!k&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(p.pd,{label:"API Key",type:"password",value:l.apiKey,onChange:e=>o({...l,apiKey:e.target.value}),placeholder:"Enter new API key",hint:"Leave blank to keep the current API key.",className:"flex-1"}),(0,s.jsx)("div",{className:"pt-6",children:(0,s.jsx)(p.$n,{onClick:j,disabled:!l.apiKey||h||g,variant:"secondary",children:h?"Checking...":"Check"})})]}),f&&(0,s.jsx)(p.Ex,{variant:"success"===f?"success":"error",children:"success"===f?"Valid":"Invalid"})]}),!C&&(0,s.jsxs)("div",{className:"flex items-center gap-3",children:[(0,s.jsx)(p.$n,{onClick:b,variant:"secondary",disabled:n,children:n?"Testing...":"Test Connection"}),c&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(p.Ex,{variant:c.valid?"success":"error",children:c.valid?"Valid":"Failed"}),A&&(0,s.jsx)(p.Ex,{variant:A.variant,children:A.label})]})]}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(p.$n,{onClick:N,fullWidth:!0,disabled:g,children:g?"Saving...":"Save"}),(0,s.jsx)(p.$n,{onClick:i,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})})}function S({isOpen:e,node:t,onSave:r,onClose:i,isAnthropic:l}){let[o,n]=(0,a.useState)({name:"",prefix:"",apiType:"chat",baseUrl:"https://api.openai.com/v1"}),[d,c]=(0,a.useState)(!1),[m,u]=(0,a.useState)(""),[h,x]=(0,a.useState)(!1),[f,y]=(0,a.useState)(null);(0,a.useEffect)(()=>{t&&n({name:t.name||"",prefix:t.prefix||"",apiType:t.apiType||"chat",baseUrl:t.baseUrl||(l?"https://api.anthropic.com/v1":"https://api.openai.com/v1")})},[t,l]);let g=async()=>{if(o.name.trim()&&o.prefix.trim()&&o.baseUrl.trim()){c(!0);try{let e={name:o.name,prefix:o.prefix,baseUrl:o.baseUrl};l||(e.apiType=o.apiType),await r(e)}finally{c(!1)}}},v=async()=>{x(!0);try{let e=await fetch("/api/provider-nodes/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:o.baseUrl,apiKey:m,type:l?"anthropic-compatible":"openai-compatible"})}),t=await e.json();y(t.valid?"success":"failed")}catch{y("failed")}finally{x(!1)}};return t?(0,s.jsx)(p.aF,{isOpen:e,title:`Edit ${l?"Anthropic":"OpenAI"} Compatible`,onClose:i,children:(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,s.jsx)(p.pd,{label:"Name",value:o.name,onChange:e=>n({...o,name:e.target.value}),placeholder:`${l?"Anthropic":"OpenAI"} Compatible (Prod)`,hint:"Required. A friendly label for this node."}),(0,s.jsx)(p.pd,{label:"Prefix",value:o.prefix,onChange:e=>n({...o,prefix:e.target.value}),placeholder:l?"ac-prod":"oc-prod",hint:"Required. Used as the provider prefix for model IDs."}),!l&&(0,s.jsx)(p.l6,{label:"API Type",options:[{value:"chat",label:"Chat Completions"},{value:"responses",label:"Responses API"}],value:o.apiType,onChange:e=>n({...o,apiType:e.target.value})}),(0,s.jsx)(p.pd,{label:"Base URL",value:o.baseUrl,onChange:e=>n({...o,baseUrl:e.target.value}),placeholder:l?"https://api.anthropic.com/v1":"https://api.openai.com/v1",hint:`Use the base URL (ending in /v1) for your ${l?"Anthropic":"OpenAI"}-compatible API.`}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(p.pd,{label:"API Key (for Check)",type:"password",value:m,onChange:e=>u(e.target.value),className:"flex-1"}),(0,s.jsx)("div",{className:"pt-6",children:(0,s.jsx)(p.$n,{onClick:v,disabled:!m||h||!o.baseUrl.trim(),variant:"secondary",children:h?"Checking...":"Check"})})]}),f&&(0,s.jsx)(p.Ex,{variant:"success"===f?"success":"error",children:"success"===f?"Valid":"Invalid"}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(p.$n,{onClick:g,fullWidth:!0,disabled:!o.name.trim()||!o.prefix.trim()||!o.baseUrl.trim()||d,children:d?"Saving...":"Save"}),(0,s.jsx)(p.$n,{onClick:i,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})}):null}k.propTypes={connection:o().shape({id:o().string,name:o().string,email:o().string,displayName:o().string,rateLimitedUntil:o().string,rateLimitProtection:o().bool,testStatus:o().string,isActive:o().bool,priority:o().number,lastError:o().string,lastErrorType:o().string,lastErrorSource:o().string,errorCode:o().oneOfType([o().string,o().number]),globalPriority:o().number}).isRequired,isOAuth:o().bool.isRequired,isFirst:o().bool.isRequired,isLast:o().bool.isRequired,onMoveUp:o().func.isRequired,onMoveDown:o().func.isRequired,onToggleActive:o().func.isRequired,onToggleRateLimit:o().func.isRequired,onRetest:o().func.isRequired,isRetesting:o().bool,onEdit:o().func.isRequired,onDelete:o().func.isRequired,onReauth:o().func},C.propTypes={isOpen:o().bool.isRequired,provider:o().string,providerName:o().string,isCompatible:o().bool,isAnthropic:o().bool,onSave:o().func.isRequired,onClose:o().func.isRequired},A.propTypes={isOpen:o().bool.isRequired,connection:o().shape({id:o().string,name:o().string,email:o().string,priority:o().number,authType:o().string,provider:o().string}),onSave:o().func.isRequired,onClose:o().func.isRequired},S.propTypes={isOpen:o().bool.isRequired,node:o().shape({id:o().string,name:o().string,prefix:o().string,apiType:o().string,baseUrl:o().string}),onSave:o().func.isRequired,onClose:o().func.isRequired,isAnthropic:o().bool}}},e=>{e.O(0,[8500,9751,782,1149,5846,993,8441,3794,7358],()=>e(e.s=56411)),_N_E=e.O()}]);
package/app/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "omniroute",
3
- "version": "1.4.2",
3
+ "version": "1.4.4",
4
4
  "description": "Smart AI Router with auto fallback — route to FREE & cheap models, zero downtime. Works with Cursor, Cline, Claude Desktop, Codex, and any OpenAI-compatible tool.",
5
5
  "type": "module",
6
6
  "bin": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "omniroute",
3
- "version": "1.4.2",
3
+ "version": "1.4.4",
4
4
  "description": "Smart AI Router with auto fallback — route to FREE & cheap models, zero downtime. Works with Cursor, Cline, Claude Desktop, Codex, and any OpenAI-compatible tool.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -1 +0,0 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[2134],{56411:(e,t,s)=>{Promise.resolve().then(s.bind(s,88618))},88618:(e,t,s)=>{"use strict";s.r(t),s.d(t,{default:()=>h});var r=s(95155),a=s(12115),i=s(14051),l=s.n(i),n=s(73321),o=s(98500),d=s.n(o),c=s(5772),m=s(40993),p=s(20909),u=s(81135),x=s(30949);function h(){let e=(0,n.useParams)(),t=(0,n.useRouter)(),s=e.id,[i,l]=(0,a.useState)([]),[o,h]=(0,a.useState)(!0),[y,j]=(0,a.useState)(null),[N,S]=(0,a.useState)(!1),[$,T]=(0,a.useState)(!1),[I,E]=(0,a.useState)(!1),[R,O]=(0,a.useState)(!1),[P,_]=(0,a.useState)(null),[q,U]=(0,a.useState)(null),[D,K]=(0,a.useState)({}),[L,F]=(0,a.useState)(!1),{copied:M,copy:z}=(0,x.C)(),J=(0,a.useRef)(!1),V=(0,a.useRef)(!1),[W,B]=(0,a.useState)(null),[Z,G]=(0,a.useState)(null),[Q,H]=(0,a.useState)(!1),[X,Y]=(0,a.useState)(!1),[ee,et]=(0,a.useState)({current:0,total:0,phase:"idle",status:"",logs:[],error:"",importedCount:0}),es=y?{id:y.id,name:y.name||("anthropic-compatible"===y.type?"Anthropic Compatible":"OpenAI Compatible"),color:"anthropic-compatible"===y.type?"#D97757":"#10A37F",textIcon:"anthropic-compatible"===y.type?"AC":"OC",apiType:y.apiType,baseUrl:y.baseUrl,type:y.type}:p.IS[s]||p.zN[s]||p.fg[s],er=!!p.IS[s]||!!p.zN[s],ea=(0,u.KC)(s),ei=(0,p.wG)(s),el=(0,p.mq)(s),en=(0,p.gb)(s),eo=el||en,ed=eo?s:ei,ec=eo?y?.prefix||s:ei,em=(0,a.useCallback)(async()=>{try{let e=await fetch("/api/models/alias"),t=await e.json();e.ok&&K(t.aliases||{})}catch(e){console.log("Error fetching aliases:",e)}},[]),ep=(0,a.useCallback)(async()=>{try{let[e,t]=await Promise.all([fetch("/api/providers",{cache:"no-store"}),fetch("/api/provider-nodes",{cache:"no-store"})]),r=await e.json(),a=await t.json();if(e.ok){let e=(r.connections||[]).filter(e=>e.provider===s);l(e)}if(t.ok){let e=(a.nodes||[]).find(e=>e.id===s)||null;if(!e&&eo)for(let t=0;t<3;t+=1){await new Promise(e=>setTimeout(e,150));let t=await fetch("/api/provider-nodes",{cache:"no-store"});if(t.ok&&(e=((await t.json()).nodes||[]).find(e=>e.id===s)||null))break}j(e)}}catch(e){console.log("Error fetching connections:",e)}finally{h(!1)}},[s,eo]),eu=async e=>{try{let t=await fetch(`/api/provider-nodes/${s}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),r=await t.json();t.ok&&(j(r.node),await ep(),O(!1))}catch(e){console.log("Error updating provider node:",e)}};(0,a.useEffect)(()=>{ep(),em(),fetch("/api/settings/proxy").then(e=>e.ok?e.json():null).then(e=>G(e)).catch(()=>{})},[ep,em]),(0,a.useEffect)(()=>{o||0!==i.length||!es||eo||J.current||V.current||(J.current=!0,er?S(!0):T(!0))},[o]);let ex=async(e,t,s=ei)=>{let r=`${s}/${e}`;try{let e=await fetch("/api/models/alias",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:r,alias:t})});if(e.ok)await em();else{let t=await e.json();alert(t.error||"Failed to set alias")}}catch(e){console.log("Error setting alias:",e)}},eh=async e=>{try{(await fetch(`/api/models/alias?alias=${encodeURIComponent(e)}`,{method:"DELETE"})).ok&&await em()}catch(e){console.log("Error deleting alias:",e)}},ef=async e=>{if(confirm("Delete this connection?"))try{(await fetch(`/api/providers/${e}`,{method:"DELETE"})).ok&&l(i.filter(t=>t.id!==e))}catch(e){console.log("Error deleting connection:",e)}},eg=(0,a.useCallback)(()=>{ep(),S(!1)},[ep]),ey=async e=>{try{let t=await fetch("/api/providers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:s,...e})});if(t.ok)return await ep(),T(!1),null;let r=await t.json().catch(()=>({}));return r.error?.message||r.error||"Failed to save connection"}catch(e){return console.log("Error saving connection:",e),"Failed to save connection. Please try again."}},eb=async e=>{try{(await fetch(`/api/providers/${P.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})).ok&&(await ep(),E(!1))}catch(e){console.log("Error updating connection:",e)}},ev=async(e,t)=>{try{(await fetch(`/api/providers/${e}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({isActive:t})})).ok&&l(s=>s.map(s=>s.id===e?{...s,isActive:t}:s))}catch(e){console.log("Error updating connection status:",e)}},ej=async(e,t)=>{try{(await fetch("/api/rate-limits",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({connectionId:e,enabled:t})})).ok&&l(s=>s.map(s=>s.id===e?{...s,rateLimitProtection:t}:s))}catch(e){console.error("Error toggling rate limit:",e)}},eN=async e=>{if(e&&!q){U(e);try{let t=await fetch(`/api/providers/${e}/test`,{method:"POST"});if(!t.ok){let e=await t.json().catch(()=>({}));alert(e.error||"Failed to retest connection");return}await ep()}catch(e){console.error("Error retesting connection:",e)}finally{U(null)}}},ew=async(e,t)=>{if(e&&t)try{let s=t.priority,r=e.priority;s===r&&(s=i.indexOf(e)>i.indexOf(t)?t.priority-.5:t.priority+.5),await Promise.all([fetch(`/api/providers/${e.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({priority:s})}),fetch(`/api/providers/${t.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({priority:r})})]),await ep()}catch(e){console.log("Error swapping priority:",e)}},ek=async()=>{if(Q)return;let e=i.find(e=>!1!==e.isActive);if(e){H(!0),Y(!0),et({current:0,total:0,phase:"fetching",status:"Fetching available models...",logs:[],error:"",importedCount:0});try{let t=await fetch(`/api/providers/${e.id}/models`),r=await t.json();if(!t.ok)return void et(e=>({...e,phase:"error",status:"Failed to fetch models",error:r.error||"Failed to import models"}));let a=r.models||[];if(0===a.length)return void et(e=>({...e,phase:"done",status:"No models found",logs:["No models returned from /models endpoint."]}));et(e=>({...e,phase:"importing",total:a.length,status:`Importing 0 of ${a.length} models...`,logs:[`Found ${a.length} models. Starting import...`]}));let i=0;for(let e=0;e<a.length;e++){let t=a[e],r=t.id||t.name||t.model;if(!r)continue;let l=r.split("/"),n=l[l.length-1];et(t=>({...t,current:e+1,status:`Importing ${e+1} of ${a.length} models...`,logs:[...t.logs,`Importing ${r}...`]})),await fetch("/api/provider-models",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:s,modelId:r,modelName:t.name||r,source:"imported"})}),D[n]||await ex(r,n,ed),i+=1}await em(),et(e=>({...e,phase:"done",current:a.length,status:i>0?`Successfully imported ${i} model${1===i?"":"s"}!`:"No new models were added (all already exist).",logs:[...e.logs,i>0?`✓ Done! ${i} model${1===i?"":"s"} imported.`:"No new models were added."],importedCount:i})),i>0&&setTimeout(()=>{window.location.reload()},2e3)}catch(e){console.log("Error importing models:",e),et(t=>({...t,phase:"error",status:"Import failed",error:e instanceof Error?e.message:"An unexpected error occurred"}))}finally{H(!1)}}},eC=async(e,t)=>{Y(!0),et({current:0,total:0,phase:"fetching",status:"Fetching available models...",logs:[],error:"",importedCount:0});try{let s=(await e()).models||[];if(0===s.length)return void et(e=>({...e,phase:"done",status:"No models found",logs:["No models returned from /models endpoint."]}));et(e=>({...e,phase:"importing",total:s.length,status:`Importing 0 of ${s.length} models...`,logs:[`Found ${s.length} models. Starting import...`]}));let r=0;for(let e=0;e<s.length;e++){let a=s[e],i=a.id||a.name||a.model;i&&(et(t=>({...t,current:e+1,status:`Importing ${e+1} of ${s.length} models...`,logs:[...t.logs,`Importing ${i}...`]})),await t(a)&&(r+=1))}et(e=>({...e,phase:"done",current:s.length,status:r>0?`Successfully imported ${r} model${1===r?"":"s"}!`:"No new models were added.",logs:[...e.logs,r>0?`✓ Done! ${r} model${1===r?"":"s"} imported.`:"No new models were added."],importedCount:r})),r>0&&setTimeout(()=>{window.location.reload()},2e3)}catch(e){console.log("Error importing models:",e),et(t=>({...t,phase:"error",status:"Import failed",error:e instanceof Error?e.message:"An unexpected error occurred"}))}},eA=i.some(e=>!1!==e.isActive);return o?(0,r.jsxs)("div",{className:"flex flex-col gap-8",children:[(0,r.jsx)(m.Qv,{}),(0,r.jsx)(m.Qv,{})]}):es?(0,r.jsxs)("div",{className:"flex flex-col gap-8",children:[(0,r.jsxs)("div",{children:[(0,r.jsxs)(d(),{href:"/dashboard/providers",className:"inline-flex items-center gap-1 text-sm text-text-muted hover:text-primary transition-colors mb-4",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-lg",children:"arrow_back"}),"Back to Providers"]}),(0,r.jsxs)("div",{className:"flex items-center gap-4",children:[(0,r.jsx)("div",{className:"rounded-lg flex items-center justify-center",style:{backgroundColor:`${es.color}15`},children:L?(0,r.jsx)("span",{className:"text-sm font-bold",style:{color:es.color},children:es.textIcon||es.id.slice(0,2).toUpperCase()}):(0,r.jsx)(c.default,{src:el&&es.apiType?"responses"===es.apiType?"/providers/oai-r.png":"/providers/oai-cc.png":en?"/providers/anthropic-m.png":`/providers/${es.id}.png`,alt:es.name,width:48,height:48,className:"object-contain rounded-lg max-w-[48px] max-h-[48px]",sizes:"48px",onError:()=>F(!0)})}),(0,r.jsxs)("div",{children:[es.website?(0,r.jsxs)("a",{href:es.website,target:"_blank",rel:"noopener noreferrer",className:"text-3xl font-semibold tracking-tight hover:underline inline-flex items-center gap-2",style:{color:es.color},children:[es.name,(0,r.jsx)("span",{className:"material-symbols-outlined text-lg opacity-60",children:"open_in_new"})]}):(0,r.jsx)("h1",{className:"text-3xl font-semibold tracking-tight",children:es.name}),(0,r.jsxs)("p",{className:"text-text-muted",children:[i.length," connection",1===i.length?"":"s"]})]})]})]}),eo&&y&&(0,r.jsxs)(m.Zp,{children:[(0,r.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("h2",{className:"text-lg font-semibold",children:en?"Anthropic Compatible Details":"OpenAI Compatible Details"}),(0,r.jsxs)("p",{className:"text-sm text-text-muted",children:[en?"Messages API":"responses"===y.apiType?"Responses API":"Chat Completions"," ","\xb7 ",(y.baseUrl||"").replace(/\/$/,""),"/",en?"messages":"responses"===y.apiType?"responses":"chat/completions"]})]}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)(m.$n,{size:"sm",icon:"add",onClick:()=>T(!0),disabled:i.length>0,children:"Add"}),(0,r.jsx)(m.$n,{size:"sm",variant:"secondary",icon:"edit",onClick:()=>O(!0),children:"Edit"}),(0,r.jsx)(m.$n,{size:"sm",variant:"secondary",icon:"delete",onClick:async()=>{if(confirm(`Delete this ${en?"Anthropic":"OpenAI"} Compatible node?`))try{(await fetch(`/api/provider-nodes/${s}`,{method:"DELETE"})).ok&&t.push("/dashboard/providers")}catch(e){console.log("Error deleting provider node:",e)}},children:"Delete"})]})]}),i.length>0&&(0,r.jsx)("p",{className:"text-sm text-text-muted",children:"Only one connection is allowed per compatible node. Add another node if you need more connections."})]}),(0,r.jsxs)(m.Zp,{children:[(0,r.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,r.jsx)("h2",{className:"text-lg font-semibold",children:"Connections"}),!eo&&(0,r.jsx)(m.$n,{size:"sm",icon:"add",onClick:()=>er?S(!0):T(!0),children:"Add"})]}),0===i.length?(0,r.jsxs)("div",{className:"text-center py-12",children:[(0,r.jsx)("div",{className:"inline-flex items-center justify-center w-16 h-16 rounded-full bg-primary/10 text-primary mb-4",children:(0,r.jsx)("span",{className:"material-symbols-outlined text-[32px]",children:er?"lock":"key"})}),(0,r.jsx)("p",{className:"text-text-main font-medium mb-1",children:"No connections yet"}),(0,r.jsx)("p",{className:"text-sm text-text-muted mb-4",children:"Add your first connection to get started"}),!eo&&(0,r.jsx)(m.$n,{icon:"add",onClick:()=>er?S(!0):T(!0),children:"Add Connection"})]}):(0,r.jsx)("div",{className:"flex flex-col divide-y divide-black/[0.03] dark:divide-white/[0.03]",children:i.sort((e,t)=>(e.priority||0)-(t.priority||0)).map((e,t)=>(0,r.jsx)(w,{connection:e,isOAuth:er,isFirst:0===t,isLast:t===i.length-1,onMoveUp:()=>ew(e,i[t-1]),onMoveDown:()=>ew(e,i[t+1]),onToggleActive:t=>ev(e.id,t),onToggleRateLimit:t=>ej(e.id,t),onRetest:()=>eN(e.id),isRetesting:q===e.id,onEdit:()=>{_(e),E(!0)},onDelete:()=>ef(e.id),onReauth:er?()=>S(!0):void 0,onProxy:()=>B({level:"key",id:e.id,label:e.name||e.email||e.id}),hasProxy:!!Z?.keys?.[e.id]},e.id))})]}),(0,r.jsxs)(m.Zp,{children:[(0,r.jsx)("h2",{className:"text-lg font-semibold mb-4",children:"Available Models"}),(()=>{if(eo)return(0,r.jsx)(v,{providerStorageAlias:ed,providerDisplayAlias:ec,modelAliases:D,copied:M,onCopy:z,onSetAlias:ex,onDeleteAlias:eh,connections:i,isAnthropic:en,onImportWithProgress:eC});if(es.passthroughModels)return(0,r.jsxs)("div",{children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 mb-4",children:[(0,r.jsx)(m.$n,{size:"sm",variant:"secondary",icon:"download",onClick:ek,disabled:!eA||Q,children:Q?"Importing...":"Import from /models"}),!eA&&(0,r.jsx)("span",{className:"text-xs text-text-muted",children:"Add a connection to enable importing."})]}),(0,r.jsx)(g,{providerAlias:ei,modelAliases:D,copied:M,onCopy:z,onSetAlias:ex,onDeleteAlias:eh})]});let e=(0,r.jsxs)("div",{className:"flex items-center gap-2 mb-4",children:[(0,r.jsx)(m.$n,{size:"sm",variant:"secondary",icon:"download",onClick:ek,disabled:!eA||Q,children:Q?"Importing...":"Import from /models"}),!eA&&(0,r.jsx)("span",{className:"text-xs text-text-muted",children:"Add a connection to enable importing."})]});return 0===ea.length?(0,r.jsxs)("div",{children:[e,(0,r.jsx)("p",{className:"text-sm text-text-muted",children:"No models configured"})]}):(0,r.jsxs)("div",{children:[e,(0,r.jsx)("div",{className:"flex flex-wrap gap-3",children:ea.map(e=>{let t=`${ed}/${e.id}`,a=`${s}/${e.id}`,i=Object.entries(D).find(([,e])=>e===t||e===a)?.[0];return(0,r.jsx)(f,{model:e,fullModel:`${ec}/${e.id}`,alias:i,copied:M,onCopy:z,onSetAlias:t=>ex(e.id,t,ed),onDeleteAlias:()=>eh(i)},e.id)})})]})})(),!eo&&(0,r.jsx)(b,{providerId:s,providerAlias:ec,copied:M,onCopy:z})]}),"kiro"===s?(0,r.jsx)(m.Mh,{isOpen:N,providerInfo:es,onSuccess:eg,onClose:()=>{V.current=!0,S(!1)}}):"cursor"===s?(0,r.jsx)(m.G9,{isOpen:N,onSuccess:eg,onClose:()=>{V.current=!0,S(!1)}}):(0,r.jsx)(m.LF,{isOpen:N,provider:s,providerInfo:es,onSuccess:eg,onClose:()=>{V.current=!0,S(!1)}}),(0,r.jsx)(k,{isOpen:$,provider:s,providerName:es.name,isCompatible:eo,isAnthropic:en,onSave:ey,onClose:()=>T(!1)}),(0,r.jsx)(C,{isOpen:I,connection:P,onSave:eb,onClose:()=>E(!1)}),eo&&(0,r.jsx)(A,{isOpen:R,node:y,onSave:eu,onClose:()=>O(!1),isAnthropic:en}),W&&(0,r.jsx)(m.KN,{isOpen:!!W,onClose:()=>B(null),level:W.level,levelId:W.id,levelLabel:W.label}),(0,r.jsx)(m.aF,{isOpen:X,onClose:()=>{("done"===ee.phase||"error"===ee.phase)&&Y(!1)},title:"Importing Models",size:"md",closeOnOverlay:!1,showCloseButton:"done"===ee.phase||"error"===ee.phase,children:(0,r.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,r.jsxs)("div",{className:"flex items-center gap-3",children:["fetching"===ee.phase&&(0,r.jsx)("span",{className:"material-symbols-outlined text-primary animate-spin",children:"progress_activity"}),"importing"===ee.phase&&(0,r.jsx)("span",{className:"material-symbols-outlined text-primary animate-spin",children:"progress_activity"}),"done"===ee.phase&&(0,r.jsx)("span",{className:"material-symbols-outlined text-green-500",children:"check_circle"}),"error"===ee.phase&&(0,r.jsx)("span",{className:"material-symbols-outlined text-red-500",children:"error"}),(0,r.jsx)("span",{className:"text-sm font-medium text-text-main",children:ee.status})]}),("importing"===ee.phase||"done"===ee.phase)&&ee.total>0&&(0,r.jsxs)("div",{className:"w-full",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between mb-1",children:[(0,r.jsxs)("span",{className:"text-xs text-text-muted",children:[ee.current," / ",ee.total]}),(0,r.jsxs)("span",{className:"text-xs text-text-muted",children:[Math.round(ee.current/ee.total*100),"%"]})]}),(0,r.jsx)("div",{className:"w-full h-2.5 bg-black/10 dark:bg-white/10 rounded-full overflow-hidden",children:(0,r.jsx)("div",{className:"h-full rounded-full transition-all duration-300 ease-out",style:{width:`${ee.current/ee.total*100}%`,background:"done"===ee.phase?"linear-gradient(90deg, #22c55e, #16a34a)":"linear-gradient(90deg, var(--color-primary), var(--color-primary-hover, var(--color-primary)))"}})})]}),"fetching"===ee.phase&&(0,r.jsx)("div",{className:"w-full h-2.5 bg-black/10 dark:bg-white/10 rounded-full overflow-hidden",children:(0,r.jsx)("div",{className:"h-full rounded-full animate-pulse",style:{width:"60%",background:"linear-gradient(90deg, var(--color-primary), var(--color-primary-hover, var(--color-primary)))"}})}),"error"===ee.phase&&ee.error&&(0,r.jsx)("div",{className:"p-3 rounded-lg bg-red-500/10 border border-red-500/20",children:(0,r.jsx)("p",{className:"text-sm text-red-400",children:ee.error})}),ee.logs.length>0&&(0,r.jsx)("div",{className:"max-h-48 overflow-y-auto rounded-lg bg-black/5 dark:bg-white/5 p-3 border border-black/5 dark:border-white/5",children:(0,r.jsx)("div",{className:"flex flex-col gap-1",children:ee.logs.map((e,t)=>(0,r.jsx)("p",{className:`text-xs font-mono ${e.startsWith("✓")?"text-green-500 font-semibold":"text-text-muted"}`,children:e},t))})}),"done"===ee.phase&&ee.importedCount>0&&(0,r.jsx)("p",{className:"text-xs text-text-muted text-center animate-pulse",children:"Page will refresh automatically..."})]})})]}):(0,r.jsxs)("div",{className:"text-center py-20",children:[(0,r.jsx)("p",{className:"text-text-muted",children:"Provider not found"}),(0,r.jsx)(d(),{href:"/dashboard/providers",className:"text-primary mt-4 inline-block",children:"Back to Providers"})]})}function f({model:e,fullModel:t,alias:s,copied:a,onCopy:i,onSetAlias:l,onDeleteAlias:n}){return(0,r.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 rounded-lg border border-border hover:bg-sidebar/50",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-base text-text-muted",children:"smart_toy"}),(0,r.jsx)("code",{className:"text-xs text-text-muted font-mono bg-sidebar px-1.5 py-0.5 rounded",children:t}),(0,r.jsx)("button",{onClick:()=>i(t,`model-${e.id}`),className:"p-0.5 hover:bg-sidebar rounded text-text-muted hover:text-primary",title:"Copy model",children:(0,r.jsx)("span",{className:"material-symbols-outlined text-sm",children:a===`model-${e.id}`?"check":"content_copy"})})]})}function g({providerAlias:e,modelAliases:t,copied:s,onCopy:i,onSetAlias:l,onDeleteAlias:n}){let[o,d]=(0,a.useState)(""),[c,p]=(0,a.useState)(!1),u=Object.entries(t).filter(([,t])=>t.startsWith(`${e}/`)).map(([t,s])=>({modelId:s.replace(`${e}/`,""),fullModel:s,alias:t})),x=async()=>{let e;if(!o.trim()||c)return;let s=o.trim(),r=(e=s.split("/"))[e.length-1];if(t[r])return void alert(`Alias "${r}" already exists. Please use a different model or edit existing alias.`);p(!0);try{await l(s,r),d("")}catch(e){console.log("Error adding model:",e)}finally{p(!1)}};return(0,r.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,r.jsx)("p",{className:"text-sm text-text-muted",children:"OpenRouter supports any model. Add models and create aliases for quick access."}),(0,r.jsxs)("div",{className:"flex items-end gap-2",children:[(0,r.jsxs)("div",{className:"flex-1",children:[(0,r.jsx)("label",{htmlFor:"new-model-input",className:"text-xs text-text-muted mb-1 block",children:"Model ID (from OpenRouter)"}),(0,r.jsx)("input",{id:"new-model-input",type:"text",value:o,onChange:e=>d(e.target.value),onKeyDown:e=>"Enter"===e.key&&x(),placeholder:"anthropic/claude-3-opus",className:"w-full px-3 py-2 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary"})]}),(0,r.jsx)(m.$n,{size:"sm",icon:"add",onClick:x,disabled:!o.trim()||c,children:c?"Adding...":"Add"})]}),u.length>0&&(0,r.jsx)("div",{className:"flex flex-col gap-3",children:u.map(({modelId:e,fullModel:t,alias:a})=>(0,r.jsx)(y,{modelId:e,fullModel:t,copied:s,onCopy:i,onDeleteAlias:()=>n(a)},t))})]})}function y({modelId:e,fullModel:t,copied:s,onCopy:a,onDeleteAlias:i}){return(0,r.jsxs)("div",{className:"flex items-center gap-3 p-3 rounded-lg border border-border hover:bg-sidebar/50",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-base text-text-muted",children:"smart_toy"}),(0,r.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,r.jsx)("p",{className:"text-sm font-medium truncate",children:e}),(0,r.jsxs)("div",{className:"flex items-center gap-1 mt-1",children:[(0,r.jsx)("code",{className:"text-xs text-text-muted font-mono bg-sidebar px-1.5 py-0.5 rounded",children:t}),(0,r.jsx)("button",{onClick:()=>a(t,`model-${e}`),className:"p-0.5 hover:bg-sidebar rounded text-text-muted hover:text-primary",title:"Copy model",children:(0,r.jsx)("span",{className:"material-symbols-outlined text-sm",children:s===`model-${e}`?"check":"content_copy"})})]})]}),(0,r.jsx)("button",{onClick:i,className:"p-1 hover:bg-red-50 rounded text-red-500",title:"Remove model",children:(0,r.jsx)("span",{className:"material-symbols-outlined text-sm",children:"delete"})})]})}function b({providerId:e,providerAlias:t,copied:s,onCopy:i}){let[l,n]=(0,a.useState)([]),[o,d]=(0,a.useState)(""),[c,p]=(0,a.useState)(""),[u,x]=(0,a.useState)(!1),[h,f]=(0,a.useState)(!0),g=(0,a.useCallback)(async()=>{try{let t=await fetch(`/api/provider-models?provider=${e}`);if(t.ok){let e=await t.json();n(e.models||[])}}catch(e){console.error("Failed to fetch custom models:",e)}finally{f(!1)}},[e]);(0,a.useEffect)(()=>{g()},[g]);let y=async()=>{if(o.trim()&&!u){x(!0);try{(await fetch("/api/provider-models",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:e,modelId:o.trim(),modelName:c.trim()||void 0})})).ok&&(d(""),p(""),await g())}catch(e){console.error("Failed to add custom model:",e)}finally{x(!1)}}},b=async t=>{try{await fetch(`/api/provider-models?provider=${e}&model=${encodeURIComponent(t)}`,{method:"DELETE"}),await g()}catch(e){console.error("Failed to remove custom model:",e)}};return(0,r.jsxs)("div",{className:"mt-6 pt-6 border-t border-border",children:[(0,r.jsxs)("h3",{className:"text-sm font-semibold mb-3 flex items-center gap-2",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-base text-primary",children:"tune"}),"Custom Models"]}),(0,r.jsx)("p",{className:"text-xs text-text-muted mb-3",children:"Add model IDs not in the default list. These will be available for routing."}),(0,r.jsxs)("div",{className:"flex items-end gap-2 mb-3",children:[(0,r.jsxs)("div",{className:"flex-1",children:[(0,r.jsx)("label",{htmlFor:"custom-model-id",className:"text-xs text-text-muted mb-1 block",children:"Model ID"}),(0,r.jsx)("input",{id:"custom-model-id",type:"text",value:o,onChange:e=>d(e.target.value),onKeyDown:e=>"Enter"===e.key&&y(),placeholder:"e.g. gpt-4.5-turbo",className:"w-full px-3 py-2 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary"})]}),(0,r.jsxs)("div",{className:"w-40",children:[(0,r.jsx)("label",{htmlFor:"custom-model-name",className:"text-xs text-text-muted mb-1 block",children:"Display Name"}),(0,r.jsx)("input",{id:"custom-model-name",type:"text",value:c,onChange:e=>p(e.target.value),onKeyDown:e=>"Enter"===e.key&&y(),placeholder:"Optional",className:"w-full px-3 py-2 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary"})]}),(0,r.jsx)(m.$n,{size:"sm",icon:"add",onClick:y,disabled:!o.trim()||u,children:u?"Adding...":"Add"})]}),h?(0,r.jsx)("p",{className:"text-xs text-text-muted",children:"Loading..."}):l.length>0?(0,r.jsx)("div",{className:"flex flex-col gap-2",children:l.map(e=>{let a=`${t}/${e.id}`,l=`custom-${e.id}`;return(0,r.jsxs)("div",{className:"flex items-center gap-3 p-3 rounded-lg border border-border hover:bg-sidebar/50",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-base text-primary",children:"tune"}),(0,r.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,r.jsx)("p",{className:"text-sm font-medium truncate",children:e.name||e.id}),(0,r.jsxs)("div",{className:"flex items-center gap-1 mt-1",children:[(0,r.jsx)("code",{className:"text-xs text-text-muted font-mono bg-sidebar px-1.5 py-0.5 rounded",children:a}),(0,r.jsx)("button",{onClick:()=>i(a,l),className:"p-0.5 hover:bg-sidebar rounded text-text-muted hover:text-primary",title:"Copy model",children:(0,r.jsx)("span",{className:"material-symbols-outlined text-sm",children:s===l?"check":"content_copy"})})]})]}),(0,r.jsx)("button",{onClick:()=>b(e.id),className:"p-1 hover:bg-red-50 rounded text-red-500",title:"Remove custom model",children:(0,r.jsx)("span",{className:"material-symbols-outlined text-sm",children:"delete"})})]},e.id)})}):(0,r.jsx)("p",{className:"text-xs text-text-muted",children:"No custom models added yet."})]})}function v({providerStorageAlias:e,providerDisplayAlias:t,modelAliases:s,copied:i,onCopy:l,onSetAlias:n,onDeleteAlias:o,connections:d,isAnthropic:c,onImportWithProgress:p}){let[u,x]=(0,a.useState)(""),[h,f]=(0,a.useState)(!1),[g,b]=(0,a.useState)(!1),v=Object.entries(s).filter(([,t])=>t.startsWith(`${e}/`)).map(([t,s])=>({modelId:s.replace(`${e}/`,""),fullModel:s,alias:t})),j=e=>{let r,a=(r=e.split("/"))[r.length-1];if(!s[a])return a;let i=`${t}-${a}`;return s[i]?null:i},N=async()=>{if(!u.trim()||h)return;let t=u.trim(),s=j(t);if(!s)return void alert("All suggested aliases already exist. Please choose a different model or remove conflicting aliases.");f(!0);try{await n(t,s,e),x("")}catch(e){console.log("Error adding model:",e)}finally{f(!1)}},w=async()=>{if(g)return;let t=d.find(e=>!1!==e.isActive);if(t){b(!0);try{await p(async()=>{let e=await fetch(`/api/providers/${t.id}/models`),s=await e.json();if(!e.ok)throw Error(s.error||"Failed to import models");return s},async t=>{let s=t.id||t.name||t.model;if(!s)return!1;let r=j(s);return!!r&&(await n(s,r,e),!0)})}catch(e){console.log("Error importing models:",e)}finally{b(!1)}}},k=d.some(e=>!1!==e.isActive);return(0,r.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,r.jsxs)("p",{className:"text-sm text-text-muted",children:["Add ",c?"Anthropic":"OpenAI","-compatible models manually or import them from the /models endpoint."]}),(0,r.jsxs)("div",{className:"flex items-end gap-2 flex-wrap",children:[(0,r.jsxs)("div",{className:"flex-1 min-w-[240px]",children:[(0,r.jsx)("label",{htmlFor:"new-compatible-model-input",className:"text-xs text-text-muted mb-1 block",children:"Model ID"}),(0,r.jsx)("input",{id:"new-compatible-model-input",type:"text",value:u,onChange:e=>x(e.target.value),onKeyDown:e=>"Enter"===e.key&&N(),placeholder:c?"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,r.jsx)(m.$n,{size:"sm",icon:"add",onClick:N,disabled:!u.trim()||h,children:h?"Adding...":"Add"}),(0,r.jsx)(m.$n,{size:"sm",variant:"secondary",icon:"download",onClick:w,disabled:!k||g,children:g?"Importing...":"Import from /models"})]}),!k&&(0,r.jsx)("p",{className:"text-xs text-text-muted",children:"Add a connection to enable importing models."}),v.length>0&&(0,r.jsx)("div",{className:"flex flex-col gap-3",children:v.map(({modelId:e,fullModel:s,alias:a})=>(0,r.jsx)(y,{modelId:e,fullModel:`${t}/${e}`,copied:i,onCopy:l,onDeleteAlias:()=>o(a)},s))})]})}function j({until:e}){let[t,s]=(0,a.useState)("");return((0,a.useEffect)(()=>{let t=()=>{let t=new Date(e).getTime()-Date.now();if(t<=0)return void s("");let r=Math.floor(t/1e3);if(r<60)s(`${r}s`);else if(r<3600)s(`${Math.floor(r/60)}m ${r%60}s`);else{let e=Math.floor(r/3600),t=Math.floor(r%3600/60);s(`${e}h ${t}m`)}};t();let r=setInterval(t,1e3);return()=>clearInterval(r)},[e]),t)?(0,r.jsxs)("span",{className:"text-xs text-orange-500 font-mono",children:["⏱ ",t]}):null}f.propTypes={model:l().shape({id:l().string.isRequired}).isRequired,fullModel:l().string.isRequired,alias:l().string,copied:l().string,onCopy:l().func.isRequired},g.propTypes={providerAlias:l().string.isRequired,modelAliases:l().object.isRequired,copied:l().string,onCopy:l().func.isRequired,onSetAlias:l().func.isRequired,onDeleteAlias:l().func.isRequired},y.propTypes={modelId:l().string.isRequired,fullModel:l().string.isRequired,copied:l().string,onCopy:l().func.isRequired,onDeleteAlias:l().func.isRequired},b.propTypes={providerId:l().string.isRequired,providerAlias:l().string.isRequired,copied:l().string,onCopy:l().func.isRequired},v.propTypes={providerStorageAlias:l().string.isRequired,providerDisplayAlias:l().string.isRequired,modelAliases:l().object.isRequired,copied:l().string,onCopy:l().func.isRequired,onSetAlias:l().func.isRequired,onDeleteAlias:l().func.isRequired,connections:l().arrayOf(l().shape({id:l().string,isActive:l().bool})).isRequired,isAnthropic:l().bool,onImportWithProgress:l().func.isRequired},j.propTypes={until:l().string.isRequired};let N={runtime_error:{label:"Local runtime",variant:"warning"},upstream_auth_error:{label:"Upstream auth",variant:"error"},auth_missing:{label:"Missing credential",variant:"warning"},token_refresh_failed:{label:"Refresh failed",variant:"warning"},token_expired:{label:"Token expired",variant:"warning"},upstream_rate_limited:{label:"Rate limited",variant:"warning"},upstream_unavailable:{label:"Upstream unavailable",variant:"error"},network_error:{label:"Network error",variant:"warning"},unsupported:{label:"Test unsupported",variant:"default"},upstream_error:{label:"Upstream error",variant:"error"}};function w({connection:e,isOAuth:t,isFirst:s,isLast:i,onMoveUp:l,onMoveDown:n,onToggleActive:o,onToggleRateLimit:d,onRetest:c,isRetesting:p,onEdit:u,onDelete:x,onReauth:h,onProxy:f,hasProxy:g}){let y=t?e.name||e.email||e.displayName||"OAuth Account":e.name,[b,v]=(0,a.useState)(!1);(0,a.useEffect)(()=>{let t=()=>{v(e.rateLimitedUntil&&new Date(e.rateLimitedUntil).getTime()>Date.now())};t();let s=e.rateLimitedUntil?setInterval(t,1e3):null;return()=>{s&&clearInterval(s)}},[e.rateLimitedUntil]);let w="unavailable"!==e.testStatus||b?e.testStatus:"active",k=function(e,t,s){if(!1===e.isActive)return{statusVariant:"default",statusLabel:"disabled",errorType:null,errorBadge:null,errorTextClass:"text-text-muted"};if("active"===t||"success"===t)return{statusVariant:"success",statusLabel:"connected",errorType:null,errorBadge:null,errorTextClass:"text-text-muted"};let r=function(e,t){if(t)return"upstream_rate_limited";if(e.lastErrorType)return e.lastErrorType;let s=Number(e.errorCode);if(401===s||403===s)return"upstream_auth_error";if(429===s)return"upstream_rate_limited";if(s>=500)return"upstream_unavailable";let r=(e.lastError||"").toLowerCase();return r?r.includes("runtime")||r.includes("not runnable")||r.includes("not installed")||r.includes("healthcheck")?"runtime_error":r.includes("refresh failed")?"token_refresh_failed":r.includes("token expired")||r.includes("expired")?"token_expired":r.includes("invalid api key")||r.includes("token invalid")||r.includes("revoked")||r.includes("access denied")||r.includes("unauthorized")?"upstream_auth_error":r.includes("rate limit")||r.includes("quota")||r.includes("too many requests")||r.includes("429")?"upstream_rate_limited":r.includes("fetch failed")||r.includes("network")||r.includes("timeout")||r.includes("econn")||r.includes("enotfound")?"network_error":r.includes("not supported")?"unsupported":"upstream_error":null}(e,s),a=r&&N[r]||null;return"runtime_error"===r?{statusVariant:"warning",statusLabel:"runtime issue",errorType:r,errorBadge:a,errorTextClass:"text-yellow-600 dark:text-yellow-400"}:"upstream_auth_error"===r||"auth_missing"===r||"token_refresh_failed"===r||"token_expired"===r?{statusVariant:"error",statusLabel:"auth failed",errorType:r,errorBadge:a,errorTextClass:"text-red-500"}:"upstream_rate_limited"===r?{statusVariant:"warning",statusLabel:"rate limited",errorType:r,errorBadge:a,errorTextClass:"text-yellow-600 dark:text-yellow-400"}:"network_error"===r?{statusVariant:"warning",statusLabel:"network issue",errorType:r,errorBadge:a,errorTextClass:"text-yellow-600 dark:text-yellow-400"}:"unsupported"===r?{statusVariant:"default",statusLabel:"test unsupported",errorType:r,errorBadge:a,errorTextClass:"text-text-muted"}:{statusVariant:"error",statusLabel:t||"error",errorType:r,errorBadge:a,errorTextClass:"text-red-500"}}(e,w,b),C=!!e.rateLimitProtection;return(0,r.jsxs)("div",{className:`group flex items-center justify-between p-3 rounded-lg hover:bg-black/[0.02] dark:hover:bg-white/[0.02] transition-colors ${!1===e.isActive?"opacity-60":""}`,children:[(0,r.jsxs)("div",{className:"flex items-center gap-3 flex-1 min-w-0",children:[(0,r.jsxs)("div",{className:"flex flex-col",children:[(0,r.jsx)("button",{onClick:l,disabled:s,className:`p-0.5 rounded ${s?"text-text-muted/30 cursor-not-allowed":"hover:bg-sidebar text-text-muted hover:text-primary"}`,children:(0,r.jsx)("span",{className:"material-symbols-outlined text-sm",children:"keyboard_arrow_up"})}),(0,r.jsx)("button",{onClick:n,disabled:i,className:`p-0.5 rounded ${i?"text-text-muted/30 cursor-not-allowed":"hover:bg-sidebar text-text-muted hover:text-primary"}`,children:(0,r.jsx)("span",{className:"material-symbols-outlined text-sm",children:"keyboard_arrow_down"})})]}),(0,r.jsx)("span",{className:"material-symbols-outlined text-base text-text-muted",children:t?"lock":"key"}),(0,r.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,r.jsx)("p",{className:"text-sm font-medium truncate",children:y}),(0,r.jsxs)("div",{className:"flex items-center gap-2 mt-1 flex-wrap",children:[(0,r.jsx)(m.Ex,{variant:k.statusVariant,size:"sm",dot:!0,children:k.statusLabel}),b&&!1!==e.isActive&&(0,r.jsx)(j,{until:e.rateLimitedUntil}),k.errorBadge&&!1!==e.isActive&&(0,r.jsx)(m.Ex,{variant:k.errorBadge.variant,size:"sm",children:k.errorBadge.label}),e.lastError&&!1!==e.isActive&&(0,r.jsx)("span",{className:`text-xs truncate max-w-[300px] ${k.errorTextClass}`,title:e.lastError,children:e.lastError}),(0,r.jsxs)("span",{className:"text-xs text-text-muted",children:["#",e.priority]}),e.globalPriority&&(0,r.jsxs)("span",{className:"text-xs text-text-muted",children:["Auto: ",e.globalPriority]}),(0,r.jsx)("span",{className:"text-text-muted/30 select-none",children:"|"}),(0,r.jsxs)("button",{onClick:()=>d(!C),className:`inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-xs font-medium transition-all cursor-pointer ${C?"bg-emerald-500/15 text-emerald-500 hover:bg-emerald-500/25":"bg-black/[0.03] dark:bg-white/[0.03] text-text-muted/50 hover:text-text-muted hover:bg-black/[0.06] dark:hover:bg-white/[0.06]"}`,title:C?"Click to disable rate limit protection":"Click to enable rate limit protection",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-[13px]",children:"shield"}),C?"Protected":"Unprotected"]}),g&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("span",{className:"text-text-muted/30 select-none",children:"|"}),(0,r.jsxs)("span",{className:"inline-flex items-center gap-0.5 px-1.5 py-0.5 rounded text-xs font-medium bg-primary/15 text-primary",title:"Proxy configured",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-[13px]",children:"vpn_lock"}),"Proxy"]})]})]})]})]}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)(m.$n,{size:"sm",variant:"ghost",icon:"refresh",loading:p,disabled:!1===e.isActive,onClick:c,className:"!h-7 !px-2 text-xs",title:"Retest authentication",children:"Retest"}),(0,r.jsx)(m.lM,{size:"sm",checked:e.isActive??!0,onChange:o,title:e.isActive??!0?"Disable connection":"Enable connection"}),(0,r.jsxs)("div",{className:"flex gap-1 ml-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[h&&(0,r.jsx)("button",{onClick:h,className:"p-2 hover:bg-amber-500/10 rounded text-amber-600 hover:text-amber-500",title:"Re-authenticate this connection",children:(0,r.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"passkey"})}),(0,r.jsx)("button",{onClick:u,className:"p-2 hover:bg-black/5 dark:hover:bg-white/5 rounded text-text-muted hover:text-primary",children:(0,r.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"edit"})}),(0,r.jsx)("button",{onClick:f,className:"p-2 hover:bg-black/5 dark:hover:bg-white/5 rounded text-text-muted hover:text-primary",title:"Proxy config",children:(0,r.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"vpn_lock"})}),(0,r.jsx)("button",{onClick:x,className:"p-2 hover:bg-red-500/10 rounded text-red-500",children:(0,r.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"delete"})})]})]})]})}function k({isOpen:e,provider:t,providerName:s,isCompatible:i,isAnthropic:l,onSave:n,onClose:o}){let[d,c]=(0,a.useState)({name:"",apiKey:"",priority:1}),[p,u]=(0,a.useState)(!1),[x,h]=(0,a.useState)(null),[f,g]=(0,a.useState)(!1),[y,b]=(0,a.useState)(null),v=async()=>{u(!0),b(null);try{let e=await fetch("/api/providers/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:t,apiKey:d.apiKey})}),s=await e.json();h(s.valid?"success":"failed")}catch{h("failed")}finally{u(!1)}},j=async()=>{if(t&&d.apiKey){g(!0),b(null);try{let e=!1;try{u(!0),h(null);let s=await fetch("/api/providers/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:t,apiKey:d.apiKey})});e=!!(await s.json()).valid,h(e?"success":"failed")}catch{h("failed")}finally{u(!1)}if(!e)return void b("API key validation failed. Please check your key and try again.");let s=await n({name:d.name,apiKey:d.apiKey,priority:d.priority,testStatus:"active"});s&&b("string"==typeof s?s:"Failed to save connection")}finally{g(!1)}}};return t?(0,r.jsx)(m.aF,{isOpen:e,title:`Add ${s||t} API Key`,onClose:o,children:(0,r.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,r.jsx)(m.pd,{label:"Name",value:d.name,onChange:e=>c({...d,name:e.target.value}),placeholder:"Production Key"}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)(m.pd,{label:"API Key",type:"password",value:d.apiKey,onChange:e=>c({...d,apiKey:e.target.value}),className:"flex-1"}),(0,r.jsx)("div",{className:"pt-6",children:(0,r.jsx)(m.$n,{onClick:v,disabled:!d.apiKey||p||f,variant:"secondary",children:p?"Checking...":"Check"})})]}),x&&(0,r.jsx)(m.Ex,{variant:"success"===x?"success":"error",children:"success"===x?"Valid":"Invalid"}),y&&(0,r.jsx)("div",{className:"text-sm text-red-500 bg-red-500/10 border border-red-500/20 rounded-lg px-3 py-2",children:y}),i&&(0,r.jsx)("p",{className:"text-xs text-text-muted",children:l?`Validation checks ${s||"Anthropic Compatible"} by verifying the API key.`:`Validation checks ${s||"OpenAI Compatible"} via /models on your base URL.`}),(0,r.jsx)(m.pd,{label:"Priority",type:"number",value:d.priority,onChange:e=>c({...d,priority:Number.parseInt(e.target.value)||1})}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)(m.$n,{onClick:j,fullWidth:!0,disabled:!d.name||!d.apiKey||f,children:f?"Saving...":"Save"}),(0,r.jsx)(m.$n,{onClick:o,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})}):null}function C({isOpen:e,connection:t,onSave:s,onClose:i}){let[l,n]=(0,a.useState)({name:"",priority:1,apiKey:"",healthCheckInterval:60}),[o,d]=(0,a.useState)(!1),[c,u]=(0,a.useState)(null),[x,h]=(0,a.useState)(!1),[f,g]=(0,a.useState)(null),[y,b]=(0,a.useState)(!1);(0,a.useEffect)(()=>{t&&(n({name:t.name||"",priority:t.priority||1,apiKey:"",healthCheckInterval:t.healthCheckInterval??60}),u(null),g(null))},[t]);let v=async()=>{if(t?.provider){d(!0),u(null);try{let e=await fetch(`/api/providers/${t.id}/test`,{method:"POST"}),s=await e.json();u({valid:!!s.valid,diagnosis:s.diagnosis||null,message:s.error||null})}catch{u({valid:!1,diagnosis:{type:"network_error"},message:"Failed to test connection"})}finally{d(!1)}}},j=async()=>{if(t?.provider&&l.apiKey){h(!0),g(null);try{let e=await fetch("/api/providers/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:t.provider,apiKey:l.apiKey})}),s=await e.json();g(s.valid?"success":"failed")}catch{g("failed")}finally{h(!1)}}},w=async()=>{b(!0);try{let e={name:l.name,priority:l.priority,healthCheckInterval:l.healthCheckInterval};if(!k&&l.apiKey){e.apiKey=l.apiKey;let s="success"===f;if(!s)try{h(!0),g(null);let e=await fetch("/api/providers/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:t.provider,apiKey:l.apiKey})});s=!!(await e.json()).valid,g(s?"success":"failed")}catch{g("failed")}finally{h(!1)}s&&(e.testStatus="active",e.lastError=null,e.lastErrorAt=null,e.lastErrorType=null,e.lastErrorSource=null,e.errorCode=null,e.rateLimitedUntil=null)}await s(e)}finally{b(!1)}};if(!t)return null;let k="oauth"===t.authType,C=(0,p.mq)(t.provider)||(0,p.gb)(t.provider),A=!c?.valid&&c?.diagnosis?.type&&N[c.diagnosis.type]||null;return(0,r.jsx)(m.aF,{isOpen:e,title:"Edit Connection",onClose:i,children:(0,r.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,r.jsx)(m.pd,{label:"Name",value:l.name,onChange:e=>n({...l,name:e.target.value}),placeholder:k?"Account name":"Production Key"}),k&&t.email&&(0,r.jsxs)("div",{className:"bg-sidebar/50 p-3 rounded-lg",children:[(0,r.jsx)("p",{className:"text-sm text-text-muted mb-1",children:"Email"}),(0,r.jsx)("p",{className:"font-medium",children:t.email})]}),k&&(0,r.jsx)(m.pd,{label:"Health Check (min)",type:"number",value:l.healthCheckInterval,onChange:e=>n({...l,healthCheckInterval:Math.max(0,Number.parseInt(e.target.value)||0)}),hint:"Proactive token refresh interval. 0 = disabled."}),(0,r.jsx)(m.pd,{label:"Priority",type:"number",value:l.priority,onChange:e=>n({...l,priority:Number.parseInt(e.target.value)||1})}),!k&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)(m.pd,{label:"API Key",type:"password",value:l.apiKey,onChange:e=>n({...l,apiKey:e.target.value}),placeholder:"Enter new API key",hint:"Leave blank to keep the current API key.",className:"flex-1"}),(0,r.jsx)("div",{className:"pt-6",children:(0,r.jsx)(m.$n,{onClick:j,disabled:!l.apiKey||x||y,variant:"secondary",children:x?"Checking...":"Check"})})]}),f&&(0,r.jsx)(m.Ex,{variant:"success"===f?"success":"error",children:"success"===f?"Valid":"Invalid"})]}),!C&&(0,r.jsxs)("div",{className:"flex items-center gap-3",children:[(0,r.jsx)(m.$n,{onClick:v,variant:"secondary",disabled:o,children:o?"Testing...":"Test Connection"}),c&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(m.Ex,{variant:c.valid?"success":"error",children:c.valid?"Valid":"Failed"}),A&&(0,r.jsx)(m.Ex,{variant:A.variant,children:A.label})]})]}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)(m.$n,{onClick:w,fullWidth:!0,disabled:y,children:y?"Saving...":"Save"}),(0,r.jsx)(m.$n,{onClick:i,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})})}function A({isOpen:e,node:t,onSave:s,onClose:i,isAnthropic:l}){let[n,o]=(0,a.useState)({name:"",prefix:"",apiType:"chat",baseUrl:"https://api.openai.com/v1"}),[d,c]=(0,a.useState)(!1),[p,u]=(0,a.useState)(""),[x,h]=(0,a.useState)(!1),[f,g]=(0,a.useState)(null);(0,a.useEffect)(()=>{t&&o({name:t.name||"",prefix:t.prefix||"",apiType:t.apiType||"chat",baseUrl:t.baseUrl||(l?"https://api.anthropic.com/v1":"https://api.openai.com/v1")})},[t,l]);let y=async()=>{if(n.name.trim()&&n.prefix.trim()&&n.baseUrl.trim()){c(!0);try{let e={name:n.name,prefix:n.prefix,baseUrl:n.baseUrl};l||(e.apiType=n.apiType),await s(e)}finally{c(!1)}}},b=async()=>{h(!0);try{let e=await fetch("/api/provider-nodes/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:n.baseUrl,apiKey:p,type:l?"anthropic-compatible":"openai-compatible"})}),t=await e.json();g(t.valid?"success":"failed")}catch{g("failed")}finally{h(!1)}};return t?(0,r.jsx)(m.aF,{isOpen:e,title:`Edit ${l?"Anthropic":"OpenAI"} Compatible`,onClose:i,children:(0,r.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,r.jsx)(m.pd,{label:"Name",value:n.name,onChange:e=>o({...n,name:e.target.value}),placeholder:`${l?"Anthropic":"OpenAI"} Compatible (Prod)`,hint:"Required. A friendly label for this node."}),(0,r.jsx)(m.pd,{label:"Prefix",value:n.prefix,onChange:e=>o({...n,prefix:e.target.value}),placeholder:l?"ac-prod":"oc-prod",hint:"Required. Used as the provider prefix for model IDs."}),!l&&(0,r.jsx)(m.l6,{label:"API Type",options:[{value:"chat",label:"Chat Completions"},{value:"responses",label:"Responses API"}],value:n.apiType,onChange:e=>o({...n,apiType:e.target.value})}),(0,r.jsx)(m.pd,{label:"Base URL",value:n.baseUrl,onChange:e=>o({...n,baseUrl:e.target.value}),placeholder:l?"https://api.anthropic.com/v1":"https://api.openai.com/v1",hint:`Use the base URL (ending in /v1) for your ${l?"Anthropic":"OpenAI"}-compatible API.`}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)(m.pd,{label:"API Key (for Check)",type:"password",value:p,onChange:e=>u(e.target.value),className:"flex-1"}),(0,r.jsx)("div",{className:"pt-6",children:(0,r.jsx)(m.$n,{onClick:b,disabled:!p||x||!n.baseUrl.trim(),variant:"secondary",children:x?"Checking...":"Check"})})]}),f&&(0,r.jsx)(m.Ex,{variant:"success"===f?"success":"error",children:"success"===f?"Valid":"Invalid"}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)(m.$n,{onClick:y,fullWidth:!0,disabled:!n.name.trim()||!n.prefix.trim()||!n.baseUrl.trim()||d,children:d?"Saving...":"Save"}),(0,r.jsx)(m.$n,{onClick:i,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})}):null}w.propTypes={connection:l().shape({id:l().string,name:l().string,email:l().string,displayName:l().string,rateLimitedUntil:l().string,rateLimitProtection:l().bool,testStatus:l().string,isActive:l().bool,priority:l().number,lastError:l().string,lastErrorType:l().string,lastErrorSource:l().string,errorCode:l().oneOfType([l().string,l().number]),globalPriority:l().number}).isRequired,isOAuth:l().bool.isRequired,isFirst:l().bool.isRequired,isLast:l().bool.isRequired,onMoveUp:l().func.isRequired,onMoveDown:l().func.isRequired,onToggleActive:l().func.isRequired,onToggleRateLimit:l().func.isRequired,onRetest:l().func.isRequired,isRetesting:l().bool,onEdit:l().func.isRequired,onDelete:l().func.isRequired,onReauth:l().func},k.propTypes={isOpen:l().bool.isRequired,provider:l().string,providerName:l().string,isCompatible:l().bool,isAnthropic:l().bool,onSave:l().func.isRequired,onClose:l().func.isRequired},C.propTypes={isOpen:l().bool.isRequired,connection:l().shape({id:l().string,name:l().string,email:l().string,priority:l().number,authType:l().string,provider:l().string}),onSave:l().func.isRequired,onClose:l().func.isRequired},A.propTypes={isOpen:l().bool.isRequired,node:l().shape({id:l().string,name:l().string,prefix:l().string,apiType:l().string,baseUrl:l().string}),onSave:l().func.isRequired,onClose:l().func.isRequired,isAnthropic:l().bool}}},e=>{e.O(0,[8500,9751,782,1149,5846,993,8441,3794,7358],()=>e(e.s=56411)),_N_E=e.O()}]);