omniroute 0.1.0 → 0.2.0

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 (664) hide show
  1. package/README.md +35 -3
  2. package/app/.next/BUILD_ID +1 -1
  3. package/app/.next/app-path-routes-manifest.json +26 -20
  4. package/app/.next/build-manifest.json +3 -3
  5. package/app/.next/prerender-manifest.json +15 -15
  6. package/app/.next/required-server-files.json +3 -3
  7. package/app/.next/routes-manifest.json +36 -0
  8. package/app/.next/server/app/(dashboard)/dashboard/cli-tools/page.js +1 -1
  9. package/app/.next/server/app/(dashboard)/dashboard/cli-tools/page.js.nft.json +1 -1
  10. package/app/.next/server/app/(dashboard)/dashboard/cli-tools/page_client-reference-manifest.js +1 -1
  11. package/app/.next/server/app/(dashboard)/dashboard/combos/page.js +1 -1
  12. package/app/.next/server/app/(dashboard)/dashboard/combos/page.js.nft.json +1 -1
  13. package/app/.next/server/app/(dashboard)/dashboard/combos/page_client-reference-manifest.js +1 -1
  14. package/app/.next/server/app/(dashboard)/dashboard/endpoint/page.js +1 -1
  15. package/app/.next/server/app/(dashboard)/dashboard/endpoint/page.js.nft.json +1 -1
  16. package/app/.next/server/app/(dashboard)/dashboard/endpoint/page_client-reference-manifest.js +1 -1
  17. package/app/.next/server/app/(dashboard)/dashboard/onboarding/page.js +1 -1
  18. package/app/.next/server/app/(dashboard)/dashboard/onboarding/page.js.nft.json +1 -1
  19. package/app/.next/server/app/(dashboard)/dashboard/onboarding/page_client-reference-manifest.js +1 -1
  20. package/app/.next/server/app/(dashboard)/dashboard/page.js +1 -1
  21. package/app/.next/server/app/(dashboard)/dashboard/page.js.nft.json +1 -1
  22. package/app/.next/server/app/(dashboard)/dashboard/page_client-reference-manifest.js +1 -1
  23. package/app/.next/server/app/(dashboard)/dashboard/profile/page.js +1 -1
  24. package/app/.next/server/app/(dashboard)/dashboard/profile/page.js.nft.json +1 -1
  25. package/app/.next/server/app/(dashboard)/dashboard/profile/page_client-reference-manifest.js +1 -1
  26. package/app/.next/server/app/(dashboard)/dashboard/providers/[id]/page.js +1 -1
  27. package/app/.next/server/app/(dashboard)/dashboard/providers/[id]/page.js.nft.json +1 -1
  28. package/app/.next/server/app/(dashboard)/dashboard/providers/[id]/page_client-reference-manifest.js +1 -1
  29. package/app/.next/server/app/(dashboard)/dashboard/providers/new/page.js +1 -1
  30. package/app/.next/server/app/(dashboard)/dashboard/providers/new/page.js.nft.json +1 -1
  31. package/app/.next/server/app/(dashboard)/dashboard/providers/new/page_client-reference-manifest.js +1 -1
  32. package/app/.next/server/app/(dashboard)/dashboard/providers/page.js +1 -1
  33. package/app/.next/server/app/(dashboard)/dashboard/providers/page.js.nft.json +1 -1
  34. package/app/.next/server/app/(dashboard)/dashboard/providers/page_client-reference-manifest.js +1 -1
  35. package/app/.next/server/app/(dashboard)/dashboard/settings/page.js +2 -2
  36. package/app/.next/server/app/(dashboard)/dashboard/settings/page.js.nft.json +1 -1
  37. package/app/.next/server/app/(dashboard)/dashboard/settings/page_client-reference-manifest.js +1 -1
  38. package/app/.next/server/app/(dashboard)/dashboard/settings/pricing/page.js +2 -0
  39. package/app/.next/server/app/(dashboard)/dashboard/settings/pricing/page.js.nft.json +1 -0
  40. package/app/.next/server/app/(dashboard)/dashboard/settings/pricing/page_client-reference-manifest.js +1 -0
  41. package/app/.next/server/app/(dashboard)/dashboard/translator/page.js +1 -1
  42. package/app/.next/server/app/(dashboard)/dashboard/translator/page.js.nft.json +1 -1
  43. package/app/.next/server/app/(dashboard)/dashboard/translator/page_client-reference-manifest.js +1 -1
  44. package/app/.next/server/app/(dashboard)/dashboard/usage/page.js +1 -1
  45. package/app/.next/server/app/(dashboard)/dashboard/usage/page.js.nft.json +1 -1
  46. package/app/.next/server/app/(dashboard)/dashboard/usage/page_client-reference-manifest.js +1 -1
  47. package/app/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
  48. package/app/.next/server/app/_global-error.html +2 -2
  49. package/app/.next/server/app/_global-error.rsc +1 -1
  50. package/app/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  51. package/app/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
  52. package/app/.next/server/app/_global-error.segments/_global-error.segment.rsc +1 -1
  53. package/app/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  54. package/app/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  55. package/app/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  56. package/app/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  57. package/app/.next/server/app/_not-found.html +1 -1
  58. package/app/.next/server/app/_not-found.rsc +3 -3
  59. package/app/.next/server/app/_not-found.segments/_full.segment.rsc +3 -3
  60. package/app/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
  61. package/app/.next/server/app/_not-found.segments/_index.segment.rsc +3 -3
  62. package/app/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
  63. package/app/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
  64. package/app/.next/server/app/_not-found.segments/_tree.segment.rsc +2 -2
  65. package/app/.next/server/app/api/auth/login/route_client-reference-manifest.js +1 -1
  66. package/app/.next/server/app/api/auth/logout/route_client-reference-manifest.js +1 -1
  67. package/app/.next/server/app/api/cli-tools/antigravity-mitm/alias/route.js +2 -2
  68. package/app/.next/server/app/api/cli-tools/antigravity-mitm/alias/route_client-reference-manifest.js +1 -1
  69. package/app/.next/server/app/api/cli-tools/antigravity-mitm/route.js +1 -1
  70. package/app/.next/server/app/api/cli-tools/antigravity-mitm/route_client-reference-manifest.js +1 -1
  71. package/app/.next/server/app/api/cli-tools/backups/route.js +1 -1
  72. package/app/.next/server/app/api/cli-tools/backups/route_client-reference-manifest.js +1 -1
  73. package/app/.next/server/app/api/cli-tools/claude-settings/route.js +2 -2
  74. package/app/.next/server/app/api/cli-tools/claude-settings/route_client-reference-manifest.js +1 -1
  75. package/app/.next/server/app/api/cli-tools/cline-settings/route.js +2 -2
  76. package/app/.next/server/app/api/cli-tools/cline-settings/route_client-reference-manifest.js +1 -1
  77. package/app/.next/server/app/api/cli-tools/codex-profiles/route.js +2 -2
  78. package/app/.next/server/app/api/cli-tools/codex-profiles/route_client-reference-manifest.js +1 -1
  79. package/app/.next/server/app/api/cli-tools/codex-settings/route.js +1 -1
  80. package/app/.next/server/app/api/cli-tools/codex-settings/route_client-reference-manifest.js +1 -1
  81. package/app/.next/server/app/api/cli-tools/droid-settings/route.js +2 -2
  82. package/app/.next/server/app/api/cli-tools/droid-settings/route_client-reference-manifest.js +1 -1
  83. package/app/.next/server/app/api/cli-tools/guide-settings/[toolId]/route_client-reference-manifest.js +1 -1
  84. package/app/.next/server/app/api/cli-tools/kilo-settings/route.js +2 -2
  85. package/app/.next/server/app/api/cli-tools/kilo-settings/route_client-reference-manifest.js +1 -1
  86. package/app/.next/server/app/api/cli-tools/openclaw-settings/route.js +1 -1
  87. package/app/.next/server/app/api/cli-tools/openclaw-settings/route_client-reference-manifest.js +1 -1
  88. package/app/.next/server/app/api/cli-tools/runtime/[toolId]/route.js +2 -2
  89. package/app/.next/server/app/api/cli-tools/runtime/[toolId]/route_client-reference-manifest.js +1 -1
  90. package/app/.next/server/app/api/cloud/auth/route_client-reference-manifest.js +1 -1
  91. package/app/.next/server/app/api/cloud/credentials/update/route_client-reference-manifest.js +1 -1
  92. package/app/.next/server/app/api/cloud/model/resolve/route_client-reference-manifest.js +1 -1
  93. package/app/.next/server/app/api/cloud/models/alias/route_client-reference-manifest.js +1 -1
  94. package/app/.next/server/app/api/combos/[id]/route.js +1 -1
  95. package/app/.next/server/app/api/combos/[id]/route.js.nft.json +1 -1
  96. package/app/.next/server/app/api/combos/[id]/route_client-reference-manifest.js +1 -1
  97. package/app/.next/server/app/api/combos/metrics/route_client-reference-manifest.js +1 -1
  98. package/app/.next/server/app/api/combos/route.js +1 -1
  99. package/app/.next/server/app/api/combos/route.js.nft.json +1 -1
  100. package/app/.next/server/app/api/combos/route_client-reference-manifest.js +1 -1
  101. package/app/.next/server/app/api/combos/test/route_client-reference-manifest.js +1 -1
  102. package/app/.next/server/app/api/db-backups/route_client-reference-manifest.js +1 -1
  103. package/app/.next/server/app/api/init/route_client-reference-manifest.js +1 -1
  104. package/app/.next/server/app/api/keys/[id]/route_client-reference-manifest.js +1 -1
  105. package/app/.next/server/app/api/keys/route_client-reference-manifest.js +1 -1
  106. package/app/.next/server/app/api/models/alias/route_client-reference-manifest.js +1 -1
  107. package/app/.next/server/app/api/models/catalog/route_client-reference-manifest.js +1 -1
  108. package/app/.next/server/app/api/models/route.js +1 -1
  109. package/app/.next/server/app/api/models/route_client-reference-manifest.js +1 -1
  110. package/app/.next/server/app/api/oauth/[provider]/[action]/route_client-reference-manifest.js +1 -1
  111. package/app/.next/server/app/api/oauth/cursor/auto-import/route_client-reference-manifest.js +1 -1
  112. package/app/.next/server/app/api/oauth/cursor/import/route_client-reference-manifest.js +1 -1
  113. package/app/.next/server/app/api/oauth/kiro/auto-import/route_client-reference-manifest.js +1 -1
  114. package/app/.next/server/app/api/oauth/kiro/import/route_client-reference-manifest.js +1 -1
  115. package/app/.next/server/app/api/oauth/kiro/social-authorize/route_client-reference-manifest.js +1 -1
  116. package/app/.next/server/app/api/oauth/kiro/social-exchange/route_client-reference-manifest.js +1 -1
  117. package/app/.next/server/app/api/pricing/defaults/route_client-reference-manifest.js +1 -1
  118. package/app/.next/server/app/api/pricing/models/route.js +156 -0
  119. package/app/.next/server/app/api/pricing/models/route.js.nft.json +1 -0
  120. package/app/.next/server/app/api/pricing/models/route_client-reference-manifest.js +1 -0
  121. package/app/.next/server/app/api/pricing/route_client-reference-manifest.js +1 -1
  122. package/app/.next/server/app/api/provider-models/route_client-reference-manifest.js +1 -1
  123. package/app/.next/server/app/api/provider-nodes/[id]/route_client-reference-manifest.js +1 -1
  124. package/app/.next/server/app/api/provider-nodes/route_client-reference-manifest.js +1 -1
  125. package/app/.next/server/app/api/provider-nodes/validate/route_client-reference-manifest.js +1 -1
  126. package/app/.next/server/app/api/providers/[id]/models/route_client-reference-manifest.js +1 -1
  127. package/app/.next/server/app/api/providers/[id]/route_client-reference-manifest.js +1 -1
  128. package/app/.next/server/app/api/providers/[id]/test/route_client-reference-manifest.js +1 -1
  129. package/app/.next/server/app/api/providers/client/route_client-reference-manifest.js +1 -1
  130. package/app/.next/server/app/api/providers/route.js +1 -1
  131. package/app/.next/server/app/api/providers/route_client-reference-manifest.js +1 -1
  132. package/app/.next/server/app/api/providers/test-batch/route_client-reference-manifest.js +1 -1
  133. package/app/.next/server/app/api/providers/validate/route_client-reference-manifest.js +1 -1
  134. package/app/.next/server/app/api/rate-limit/route.js +1 -1
  135. package/app/.next/server/app/api/rate-limit/route_client-reference-manifest.js +1 -1
  136. package/app/.next/server/app/api/rate-limits/route.js +1 -0
  137. package/app/.next/server/app/api/rate-limits/route.js.nft.json +1 -0
  138. package/app/.next/server/app/api/rate-limits/route_client-reference-manifest.js +1 -0
  139. package/app/.next/server/app/api/restart/route_client-reference-manifest.js +1 -1
  140. package/app/.next/server/app/api/sessions/route.js +1 -0
  141. package/app/.next/server/app/api/sessions/route.js.nft.json +1 -0
  142. package/app/.next/server/app/api/sessions/route_client-reference-manifest.js +1 -0
  143. package/app/.next/server/app/api/settings/combo-defaults/route_client-reference-manifest.js +1 -1
  144. package/app/.next/server/app/api/settings/ip-filter/route.js +1 -0
  145. package/app/.next/server/app/api/settings/ip-filter/route.js.nft.json +1 -0
  146. package/app/.next/server/app/api/settings/ip-filter/route_client-reference-manifest.js +1 -0
  147. package/app/.next/server/app/api/settings/proxy/route_client-reference-manifest.js +1 -1
  148. package/app/.next/server/app/api/settings/proxy/test/route_client-reference-manifest.js +1 -1
  149. package/app/.next/server/app/api/settings/require-login/route_client-reference-manifest.js +1 -1
  150. package/app/.next/server/app/api/settings/route_client-reference-manifest.js +1 -1
  151. package/app/.next/server/app/api/settings/system-prompt/route.js +156 -0
  152. package/app/.next/server/app/api/settings/system-prompt/route.js.nft.json +1 -0
  153. package/app/.next/server/app/api/settings/system-prompt/route_client-reference-manifest.js +1 -0
  154. package/app/.next/server/app/api/settings/thinking-budget/route.js +156 -0
  155. package/app/.next/server/app/api/settings/thinking-budget/route.js.nft.json +1 -0
  156. package/app/.next/server/app/api/settings/thinking-budget/route_client-reference-manifest.js +1 -0
  157. package/app/.next/server/app/api/shutdown/route_client-reference-manifest.js +1 -1
  158. package/app/.next/server/app/api/storage/health/route_client-reference-manifest.js +1 -1
  159. package/app/.next/server/app/api/sync/cloud/route_client-reference-manifest.js +1 -1
  160. package/app/.next/server/app/api/sync/initialize/route_client-reference-manifest.js +1 -1
  161. package/app/.next/server/app/api/tags/route_client-reference-manifest.js +1 -1
  162. package/app/.next/server/app/api/translator/detect/route.js +1 -1
  163. package/app/.next/server/app/api/translator/detect/route_client-reference-manifest.js +1 -1
  164. package/app/.next/server/app/api/translator/history/route_client-reference-manifest.js +1 -1
  165. package/app/.next/server/app/api/translator/load/route_client-reference-manifest.js +1 -1
  166. package/app/.next/server/app/api/translator/save/route_client-reference-manifest.js +1 -1
  167. package/app/.next/server/app/api/translator/send/route.js +1 -1
  168. package/app/.next/server/app/api/translator/send/route_client-reference-manifest.js +1 -1
  169. package/app/.next/server/app/api/translator/translate/route.js +1 -1
  170. package/app/.next/server/app/api/translator/translate/route_client-reference-manifest.js +1 -1
  171. package/app/.next/server/app/api/usage/[connectionId]/route_client-reference-manifest.js +1 -1
  172. package/app/.next/server/app/api/usage/analytics/route_client-reference-manifest.js +1 -1
  173. package/app/.next/server/app/api/usage/call-logs/[id]/route_client-reference-manifest.js +1 -1
  174. package/app/.next/server/app/api/usage/call-logs/route_client-reference-manifest.js +1 -1
  175. package/app/.next/server/app/api/usage/history/route_client-reference-manifest.js +1 -1
  176. package/app/.next/server/app/api/usage/logs/route_client-reference-manifest.js +1 -1
  177. package/app/.next/server/app/api/usage/proxy-logs/route_client-reference-manifest.js +1 -1
  178. package/app/.next/server/app/api/usage/request-logs/route_client-reference-manifest.js +1 -1
  179. package/app/.next/server/app/api/v1/api/chat/route.js +1 -1
  180. package/app/.next/server/app/api/v1/api/chat/route.js.nft.json +1 -1
  181. package/app/.next/server/app/api/v1/api/chat/route_client-reference-manifest.js +1 -1
  182. package/app/.next/server/app/api/v1/audio/speech/route.js +1 -1
  183. package/app/.next/server/app/api/v1/audio/speech/route.js.nft.json +1 -1
  184. package/app/.next/server/app/api/v1/audio/speech/route_client-reference-manifest.js +1 -1
  185. package/app/.next/server/app/api/v1/audio/transcriptions/route.js +1 -1
  186. package/app/.next/server/app/api/v1/audio/transcriptions/route.js.nft.json +1 -1
  187. package/app/.next/server/app/api/v1/audio/transcriptions/route_client-reference-manifest.js +1 -1
  188. package/app/.next/server/app/api/v1/chat/completions/route.js +1 -1
  189. package/app/.next/server/app/api/v1/chat/completions/route.js.nft.json +1 -1
  190. package/app/.next/server/app/api/v1/chat/completions/route_client-reference-manifest.js +1 -1
  191. package/app/.next/server/app/api/v1/embeddings/route.js +1 -1
  192. package/app/.next/server/app/api/v1/embeddings/route.js.nft.json +1 -1
  193. package/app/.next/server/app/api/v1/embeddings/route_client-reference-manifest.js +1 -1
  194. package/app/.next/server/app/api/v1/images/generations/route.js +1 -1
  195. package/app/.next/server/app/api/v1/images/generations/route.js.nft.json +1 -1
  196. package/app/.next/server/app/api/v1/images/generations/route_client-reference-manifest.js +1 -1
  197. package/app/.next/server/app/api/v1/messages/count_tokens/route_client-reference-manifest.js +1 -1
  198. package/app/.next/server/app/api/v1/messages/route.js +1 -1
  199. package/app/.next/server/app/api/v1/messages/route.js.nft.json +1 -1
  200. package/app/.next/server/app/api/v1/messages/route_client-reference-manifest.js +1 -1
  201. package/app/.next/server/app/api/v1/models/route_client-reference-manifest.js +1 -1
  202. package/app/.next/server/app/api/v1/moderations/route.js +1 -1
  203. package/app/.next/server/app/api/v1/moderations/route.js.nft.json +1 -1
  204. package/app/.next/server/app/api/v1/moderations/route_client-reference-manifest.js +1 -1
  205. package/app/.next/server/app/api/v1/providers/[provider]/chat/completions/route.js +1 -1
  206. package/app/.next/server/app/api/v1/providers/[provider]/chat/completions/route.js.nft.json +1 -1
  207. package/app/.next/server/app/api/v1/providers/[provider]/chat/completions/route_client-reference-manifest.js +1 -1
  208. package/app/.next/server/app/api/v1/providers/[provider]/embeddings/route.js +1 -1
  209. package/app/.next/server/app/api/v1/providers/[provider]/embeddings/route.js.nft.json +1 -1
  210. package/app/.next/server/app/api/v1/providers/[provider]/embeddings/route_client-reference-manifest.js +1 -1
  211. package/app/.next/server/app/api/v1/providers/[provider]/images/generations/route.js +1 -1
  212. package/app/.next/server/app/api/v1/providers/[provider]/images/generations/route.js.nft.json +1 -1
  213. package/app/.next/server/app/api/v1/providers/[provider]/images/generations/route_client-reference-manifest.js +1 -1
  214. package/app/.next/server/app/api/v1/rerank/route.js +1 -1
  215. package/app/.next/server/app/api/v1/rerank/route.js.nft.json +1 -1
  216. package/app/.next/server/app/api/v1/rerank/route_client-reference-manifest.js +1 -1
  217. package/app/.next/server/app/api/v1/responses/route.js +1 -1
  218. package/app/.next/server/app/api/v1/responses/route.js.nft.json +1 -1
  219. package/app/.next/server/app/api/v1/responses/route_client-reference-manifest.js +1 -1
  220. package/app/.next/server/app/api/v1/route_client-reference-manifest.js +1 -1
  221. package/app/.next/server/app/api/v1beta/models/[...path]/route.js +1 -1
  222. package/app/.next/server/app/api/v1beta/models/[...path]/route.js.nft.json +1 -1
  223. package/app/.next/server/app/api/v1beta/models/[...path]/route_client-reference-manifest.js +1 -1
  224. package/app/.next/server/app/api/v1beta/models/route_client-reference-manifest.js +1 -1
  225. package/app/.next/server/app/callback/page_client-reference-manifest.js +1 -1
  226. package/app/.next/server/app/callback.html +1 -1
  227. package/app/.next/server/app/callback.rsc +3 -3
  228. package/app/.next/server/app/callback.segments/_full.segment.rsc +3 -3
  229. package/app/.next/server/app/callback.segments/_head.segment.rsc +1 -1
  230. package/app/.next/server/app/callback.segments/_index.segment.rsc +3 -3
  231. package/app/.next/server/app/callback.segments/_tree.segment.rsc +2 -2
  232. package/app/.next/server/app/callback.segments/callback/__PAGE__.segment.rsc +1 -1
  233. package/app/.next/server/app/callback.segments/callback.segment.rsc +1 -1
  234. package/app/.next/server/app/dashboard/cli-tools.html +1 -1
  235. package/app/.next/server/app/dashboard/cli-tools.rsc +5 -5
  236. package/app/.next/server/app/dashboard/cli-tools.segments/!KGRhc2hib2FyZCk/dashboard/cli-tools/__PAGE__.segment.rsc +2 -2
  237. package/app/.next/server/app/dashboard/cli-tools.segments/!KGRhc2hib2FyZCk/dashboard/cli-tools.segment.rsc +1 -1
  238. package/app/.next/server/app/dashboard/cli-tools.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  239. package/app/.next/server/app/dashboard/cli-tools.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  240. package/app/.next/server/app/dashboard/cli-tools.segments/_full.segment.rsc +5 -5
  241. package/app/.next/server/app/dashboard/cli-tools.segments/_head.segment.rsc +1 -1
  242. package/app/.next/server/app/dashboard/cli-tools.segments/_index.segment.rsc +3 -3
  243. package/app/.next/server/app/dashboard/cli-tools.segments/_tree.segment.rsc +2 -2
  244. package/app/.next/server/app/dashboard/combos.html +1 -1
  245. package/app/.next/server/app/dashboard/combos.rsc +5 -5
  246. package/app/.next/server/app/dashboard/combos.segments/!KGRhc2hib2FyZCk/dashboard/combos/__PAGE__.segment.rsc +2 -2
  247. package/app/.next/server/app/dashboard/combos.segments/!KGRhc2hib2FyZCk/dashboard/combos.segment.rsc +1 -1
  248. package/app/.next/server/app/dashboard/combos.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  249. package/app/.next/server/app/dashboard/combos.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  250. package/app/.next/server/app/dashboard/combos.segments/_full.segment.rsc +5 -5
  251. package/app/.next/server/app/dashboard/combos.segments/_head.segment.rsc +1 -1
  252. package/app/.next/server/app/dashboard/combos.segments/_index.segment.rsc +3 -3
  253. package/app/.next/server/app/dashboard/combos.segments/_tree.segment.rsc +2 -2
  254. package/app/.next/server/app/dashboard/endpoint.html +1 -1
  255. package/app/.next/server/app/dashboard/endpoint.rsc +5 -5
  256. package/app/.next/server/app/dashboard/endpoint.segments/!KGRhc2hib2FyZCk/dashboard/endpoint/__PAGE__.segment.rsc +2 -2
  257. package/app/.next/server/app/dashboard/endpoint.segments/!KGRhc2hib2FyZCk/dashboard/endpoint.segment.rsc +1 -1
  258. package/app/.next/server/app/dashboard/endpoint.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  259. package/app/.next/server/app/dashboard/endpoint.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  260. package/app/.next/server/app/dashboard/endpoint.segments/_full.segment.rsc +5 -5
  261. package/app/.next/server/app/dashboard/endpoint.segments/_head.segment.rsc +1 -1
  262. package/app/.next/server/app/dashboard/endpoint.segments/_index.segment.rsc +3 -3
  263. package/app/.next/server/app/dashboard/endpoint.segments/_tree.segment.rsc +2 -2
  264. package/app/.next/server/app/dashboard/onboarding.html +1 -1
  265. package/app/.next/server/app/dashboard/onboarding.rsc +4 -4
  266. package/app/.next/server/app/dashboard/onboarding.segments/!KGRhc2hib2FyZCk/dashboard/onboarding/__PAGE__.segment.rsc +1 -1
  267. package/app/.next/server/app/dashboard/onboarding.segments/!KGRhc2hib2FyZCk/dashboard/onboarding.segment.rsc +1 -1
  268. package/app/.next/server/app/dashboard/onboarding.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  269. package/app/.next/server/app/dashboard/onboarding.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  270. package/app/.next/server/app/dashboard/onboarding.segments/_full.segment.rsc +4 -4
  271. package/app/.next/server/app/dashboard/onboarding.segments/_head.segment.rsc +1 -1
  272. package/app/.next/server/app/dashboard/onboarding.segments/_index.segment.rsc +3 -3
  273. package/app/.next/server/app/dashboard/onboarding.segments/_tree.segment.rsc +2 -2
  274. package/app/.next/server/app/dashboard/profile.html +1 -1
  275. package/app/.next/server/app/dashboard/profile.rsc +4 -4
  276. package/app/.next/server/app/dashboard/profile.segments/!KGRhc2hib2FyZCk/dashboard/profile/__PAGE__.segment.rsc +1 -1
  277. package/app/.next/server/app/dashboard/profile.segments/!KGRhc2hib2FyZCk/dashboard/profile.segment.rsc +1 -1
  278. package/app/.next/server/app/dashboard/profile.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  279. package/app/.next/server/app/dashboard/profile.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  280. package/app/.next/server/app/dashboard/profile.segments/_full.segment.rsc +4 -4
  281. package/app/.next/server/app/dashboard/profile.segments/_head.segment.rsc +1 -1
  282. package/app/.next/server/app/dashboard/profile.segments/_index.segment.rsc +3 -3
  283. package/app/.next/server/app/dashboard/profile.segments/_tree.segment.rsc +2 -2
  284. package/app/.next/server/app/dashboard/providers/new.html +1 -1
  285. package/app/.next/server/app/dashboard/providers/new.rsc +5 -5
  286. package/app/.next/server/app/dashboard/providers/new.segments/!KGRhc2hib2FyZCk/dashboard/providers/new/__PAGE__.segment.rsc +2 -2
  287. package/app/.next/server/app/dashboard/providers/new.segments/!KGRhc2hib2FyZCk/dashboard/providers/new.segment.rsc +1 -1
  288. package/app/.next/server/app/dashboard/providers/new.segments/!KGRhc2hib2FyZCk/dashboard/providers.segment.rsc +1 -1
  289. package/app/.next/server/app/dashboard/providers/new.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  290. package/app/.next/server/app/dashboard/providers/new.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  291. package/app/.next/server/app/dashboard/providers/new.segments/_full.segment.rsc +5 -5
  292. package/app/.next/server/app/dashboard/providers/new.segments/_head.segment.rsc +1 -1
  293. package/app/.next/server/app/dashboard/providers/new.segments/_index.segment.rsc +3 -3
  294. package/app/.next/server/app/dashboard/providers/new.segments/_tree.segment.rsc +2 -2
  295. package/app/.next/server/app/dashboard/providers.html +1 -1
  296. package/app/.next/server/app/dashboard/providers.rsc +5 -5
  297. package/app/.next/server/app/dashboard/providers.segments/!KGRhc2hib2FyZCk/dashboard/providers/__PAGE__.segment.rsc +2 -2
  298. package/app/.next/server/app/dashboard/providers.segments/!KGRhc2hib2FyZCk/dashboard/providers.segment.rsc +1 -1
  299. package/app/.next/server/app/dashboard/providers.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  300. package/app/.next/server/app/dashboard/providers.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  301. package/app/.next/server/app/dashboard/providers.segments/_full.segment.rsc +5 -5
  302. package/app/.next/server/app/dashboard/providers.segments/_head.segment.rsc +1 -1
  303. package/app/.next/server/app/dashboard/providers.segments/_index.segment.rsc +3 -3
  304. package/app/.next/server/app/dashboard/providers.segments/_tree.segment.rsc +2 -2
  305. package/app/.next/server/app/dashboard/settings/pricing.html +1 -1
  306. package/app/.next/server/app/dashboard/settings/pricing.meta +6 -5
  307. package/app/.next/server/app/dashboard/settings/pricing.rsc +17 -16
  308. package/app/.next/server/app/dashboard/settings/pricing.segments/{dashboard → !KGRhc2hib2FyZCk/dashboard}/settings/pricing/__PAGE__.segment.rsc +2 -2
  309. package/app/.next/server/app/dashboard/settings/pricing.segments/{dashboard → !KGRhc2hib2FyZCk/dashboard}/settings/pricing.segment.rsc +1 -1
  310. package/app/.next/server/app/dashboard/settings/pricing.segments/{dashboard → !KGRhc2hib2FyZCk/dashboard}/settings.segment.rsc +1 -1
  311. package/app/.next/server/app/dashboard/settings/pricing.segments/{dashboard.segment.rsc → !KGRhc2hib2FyZCk/dashboard.segment.rsc} +1 -1
  312. package/app/.next/server/app/dashboard/settings/pricing.segments/!KGRhc2hib2FyZCk.segment.rsc +5 -0
  313. package/app/.next/server/app/dashboard/settings/pricing.segments/_full.segment.rsc +17 -16
  314. package/app/.next/server/app/dashboard/settings/pricing.segments/_head.segment.rsc +1 -1
  315. package/app/.next/server/app/dashboard/settings/pricing.segments/_index.segment.rsc +3 -3
  316. package/app/.next/server/app/dashboard/settings/pricing.segments/_tree.segment.rsc +2 -2
  317. package/app/.next/server/app/dashboard/settings.html +1 -1
  318. package/app/.next/server/app/dashboard/settings.rsc +5 -5
  319. package/app/.next/server/app/dashboard/settings.segments/!KGRhc2hib2FyZCk/dashboard/settings/__PAGE__.segment.rsc +2 -2
  320. package/app/.next/server/app/dashboard/settings.segments/!KGRhc2hib2FyZCk/dashboard/settings.segment.rsc +1 -1
  321. package/app/.next/server/app/dashboard/settings.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  322. package/app/.next/server/app/dashboard/settings.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  323. package/app/.next/server/app/dashboard/settings.segments/_full.segment.rsc +5 -5
  324. package/app/.next/server/app/dashboard/settings.segments/_head.segment.rsc +1 -1
  325. package/app/.next/server/app/dashboard/settings.segments/_index.segment.rsc +3 -3
  326. package/app/.next/server/app/dashboard/settings.segments/_tree.segment.rsc +2 -2
  327. package/app/.next/server/app/dashboard/translator.html +2 -2
  328. package/app/.next/server/app/dashboard/translator.rsc +5 -5
  329. package/app/.next/server/app/dashboard/translator.segments/!KGRhc2hib2FyZCk/dashboard/translator/__PAGE__.segment.rsc +2 -2
  330. package/app/.next/server/app/dashboard/translator.segments/!KGRhc2hib2FyZCk/dashboard/translator.segment.rsc +1 -1
  331. package/app/.next/server/app/dashboard/translator.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  332. package/app/.next/server/app/dashboard/translator.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  333. package/app/.next/server/app/dashboard/translator.segments/_full.segment.rsc +5 -5
  334. package/app/.next/server/app/dashboard/translator.segments/_head.segment.rsc +1 -1
  335. package/app/.next/server/app/dashboard/translator.segments/_index.segment.rsc +3 -3
  336. package/app/.next/server/app/dashboard/translator.segments/_tree.segment.rsc +2 -2
  337. package/app/.next/server/app/dashboard/usage.html +1 -1
  338. package/app/.next/server/app/dashboard/usage.rsc +5 -5
  339. package/app/.next/server/app/dashboard/usage.segments/!KGRhc2hib2FyZCk/dashboard/usage/__PAGE__.segment.rsc +2 -2
  340. package/app/.next/server/app/dashboard/usage.segments/!KGRhc2hib2FyZCk/dashboard/usage.segment.rsc +1 -1
  341. package/app/.next/server/app/dashboard/usage.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  342. package/app/.next/server/app/dashboard/usage.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  343. package/app/.next/server/app/dashboard/usage.segments/_full.segment.rsc +5 -5
  344. package/app/.next/server/app/dashboard/usage.segments/_head.segment.rsc +1 -1
  345. package/app/.next/server/app/dashboard/usage.segments/_index.segment.rsc +3 -3
  346. package/app/.next/server/app/dashboard/usage.segments/_tree.segment.rsc +2 -2
  347. package/app/.next/server/app/docs/page.js +1 -1
  348. package/app/.next/server/app/docs/page_client-reference-manifest.js +1 -1
  349. package/app/.next/server/app/docs.html +1 -1
  350. package/app/.next/server/app/docs.rsc +3 -3
  351. package/app/.next/server/app/docs.segments/_full.segment.rsc +3 -3
  352. package/app/.next/server/app/docs.segments/_head.segment.rsc +1 -1
  353. package/app/.next/server/app/docs.segments/_index.segment.rsc +3 -3
  354. package/app/.next/server/app/docs.segments/_tree.segment.rsc +2 -2
  355. package/app/.next/server/app/docs.segments/docs/__PAGE__.segment.rsc +1 -1
  356. package/app/.next/server/app/docs.segments/docs.segment.rsc +1 -1
  357. package/app/.next/server/app/index.html +1 -1
  358. package/app/.next/server/app/index.rsc +3 -3
  359. package/app/.next/server/app/index.segments/__PAGE__.segment.rsc +1 -1
  360. package/app/.next/server/app/index.segments/_full.segment.rsc +3 -3
  361. package/app/.next/server/app/index.segments/_head.segment.rsc +1 -1
  362. package/app/.next/server/app/index.segments/_index.segment.rsc +3 -3
  363. package/app/.next/server/app/index.segments/_tree.segment.rsc +2 -2
  364. package/app/.next/server/app/landing/page_client-reference-manifest.js +1 -1
  365. package/app/.next/server/app/landing.html +1 -1
  366. package/app/.next/server/app/landing.rsc +3 -3
  367. package/app/.next/server/app/landing.segments/_full.segment.rsc +3 -3
  368. package/app/.next/server/app/landing.segments/_head.segment.rsc +1 -1
  369. package/app/.next/server/app/landing.segments/_index.segment.rsc +3 -3
  370. package/app/.next/server/app/landing.segments/_tree.segment.rsc +2 -2
  371. package/app/.next/server/app/landing.segments/landing/__PAGE__.segment.rsc +1 -1
  372. package/app/.next/server/app/landing.segments/landing.segment.rsc +1 -1
  373. package/app/.next/server/app/login/page.js +1 -1
  374. package/app/.next/server/app/login/page.js.nft.json +1 -1
  375. package/app/.next/server/app/login/page_client-reference-manifest.js +1 -1
  376. package/app/.next/server/app/login.html +1 -1
  377. package/app/.next/server/app/login.rsc +4 -4
  378. package/app/.next/server/app/login.segments/_full.segment.rsc +4 -4
  379. package/app/.next/server/app/login.segments/_head.segment.rsc +1 -1
  380. package/app/.next/server/app/login.segments/_index.segment.rsc +3 -3
  381. package/app/.next/server/app/login.segments/_tree.segment.rsc +2 -2
  382. package/app/.next/server/app/login.segments/login/__PAGE__.segment.rsc +2 -2
  383. package/app/.next/server/app/login.segments/login.segment.rsc +1 -1
  384. package/app/.next/server/app/page_client-reference-manifest.js +1 -1
  385. package/app/.next/server/app/privacy/page_client-reference-manifest.js +1 -1
  386. package/app/.next/server/app/privacy.html +1 -1
  387. package/app/.next/server/app/privacy.rsc +3 -3
  388. package/app/.next/server/app/privacy.segments/_full.segment.rsc +3 -3
  389. package/app/.next/server/app/privacy.segments/_head.segment.rsc +1 -1
  390. package/app/.next/server/app/privacy.segments/_index.segment.rsc +3 -3
  391. package/app/.next/server/app/privacy.segments/_tree.segment.rsc +2 -2
  392. package/app/.next/server/app/privacy.segments/privacy/__PAGE__.segment.rsc +1 -1
  393. package/app/.next/server/app/privacy.segments/privacy.segment.rsc +1 -1
  394. package/app/.next/server/app/terms/page_client-reference-manifest.js +1 -1
  395. package/app/.next/server/app/terms.html +1 -1
  396. package/app/.next/server/app/terms.rsc +3 -3
  397. package/app/.next/server/app/terms.segments/_full.segment.rsc +3 -3
  398. package/app/.next/server/app/terms.segments/_head.segment.rsc +1 -1
  399. package/app/.next/server/app/terms.segments/_index.segment.rsc +3 -3
  400. package/app/.next/server/app/terms.segments/_tree.segment.rsc +2 -2
  401. package/app/.next/server/app/terms.segments/terms/__PAGE__.segment.rsc +1 -1
  402. package/app/.next/server/app/terms.segments/terms.segment.rsc +1 -1
  403. package/app/.next/server/app-paths-manifest.json +26 -20
  404. package/app/.next/server/chunks/1483.js +156 -0
  405. package/app/.next/server/chunks/2399.js +1 -0
  406. package/app/.next/server/chunks/3542.js +2 -2
  407. package/app/.next/server/chunks/4755.js +1 -1
  408. package/app/.next/server/chunks/5640.js +1 -1
  409. package/app/.next/server/chunks/6194.js +1 -0
  410. package/app/.next/server/chunks/7615.js +1 -1
  411. package/app/.next/server/chunks/8108.js +1 -1
  412. package/app/.next/server/chunks/867.js +1 -0
  413. package/app/.next/server/chunks/9188.js +1 -1
  414. package/app/.next/server/middleware-build-manifest.js +1 -1
  415. package/app/.next/server/pages/404.html +1 -1
  416. package/app/.next/server/pages/500.html +2 -2
  417. package/app/.next/server/server-reference-manifest.js +1 -1
  418. package/app/.next/server/server-reference-manifest.json +1 -1
  419. package/app/.next/static/XnNWFvV2IXZ4xuX0F1Skg/_buildManifest.js +1 -0
  420. package/app/.next/static/chunks/1525-8aaae9ffdaa67144.js +7 -0
  421. package/app/.next/static/chunks/{7896-81ec5010e89beaf8.js → 7896-4e519429f67f381e.js} +1 -1
  422. package/app/.next/static/chunks/8013-04b90e92e614b5d9.js +1 -0
  423. package/app/.next/static/chunks/app/(dashboard)/dashboard/cli-tools/{page-cef5a81883757c60.js → page-148b0ad18f6bec86.js} +1 -1
  424. package/app/.next/static/chunks/app/(dashboard)/dashboard/combos/{page-82b1b6f14eca9957.js → page-49caa7328acff82d.js} +1 -1
  425. package/app/.next/static/chunks/app/(dashboard)/dashboard/endpoint/page-ab8b870377087bc7.js +1 -0
  426. package/app/.next/static/chunks/app/(dashboard)/dashboard/page-bc5764734a448526.js +1 -0
  427. package/app/.next/static/chunks/app/(dashboard)/dashboard/profile/page-c452284fb77ecee0.js +1 -0
  428. package/app/.next/static/chunks/app/(dashboard)/dashboard/providers/[id]/{page-b731afd377df1fa6.js → page-fb1fa9ae8a3af8c8.js} +1 -1
  429. package/app/.next/static/chunks/app/(dashboard)/dashboard/providers/new/{page-3c6d0b7fade7dd73.js → page-4bd8ea64f2e8008b.js} +1 -1
  430. package/app/.next/static/chunks/app/(dashboard)/dashboard/providers/{page-e5b8862ba1197935.js → page-4140db5a52fc7323.js} +1 -1
  431. package/app/.next/static/chunks/app/(dashboard)/dashboard/settings/page-70619a1bafdc9c4c.js +1 -0
  432. package/app/.next/static/chunks/app/(dashboard)/dashboard/settings/pricing/page-a22d14af518d5b43.js +1 -0
  433. package/app/.next/static/chunks/app/(dashboard)/dashboard/translator/{page-b018be5904c4909c.js → page-c891465a1a2938d2.js} +1 -1
  434. package/app/.next/static/chunks/app/(dashboard)/dashboard/usage/page-9ee5997edb778414.js +1 -0
  435. package/app/.next/static/chunks/app/(dashboard)/{layout-c26bba15e099e382.js → layout-0ee92d902ee7a39c.js} +1 -1
  436. package/app/.next/static/chunks/app/_global-error/page-c452284fb77ecee0.js +1 -0
  437. package/app/.next/static/chunks/app/api/auth/login/route-c452284fb77ecee0.js +1 -0
  438. package/app/.next/static/chunks/app/api/auth/logout/route-c452284fb77ecee0.js +1 -0
  439. package/app/.next/static/chunks/app/api/cli-tools/antigravity-mitm/alias/route-c452284fb77ecee0.js +1 -0
  440. package/app/.next/static/chunks/app/api/cli-tools/antigravity-mitm/route-c452284fb77ecee0.js +1 -0
  441. package/app/.next/static/chunks/app/api/cli-tools/backups/route-c452284fb77ecee0.js +1 -0
  442. package/app/.next/static/chunks/app/api/cli-tools/claude-settings/route-c452284fb77ecee0.js +1 -0
  443. package/app/.next/static/chunks/app/api/cli-tools/cline-settings/route-c452284fb77ecee0.js +1 -0
  444. package/app/.next/static/chunks/app/api/cli-tools/codex-profiles/route-c452284fb77ecee0.js +1 -0
  445. package/app/.next/static/chunks/app/api/cli-tools/codex-settings/route-c452284fb77ecee0.js +1 -0
  446. package/app/.next/static/chunks/app/api/cli-tools/droid-settings/route-c452284fb77ecee0.js +1 -0
  447. package/app/.next/static/chunks/app/api/cli-tools/guide-settings/[toolId]/route-c452284fb77ecee0.js +1 -0
  448. package/app/.next/static/chunks/app/api/cli-tools/kilo-settings/route-c452284fb77ecee0.js +1 -0
  449. package/app/.next/static/chunks/app/api/cli-tools/openclaw-settings/route-c452284fb77ecee0.js +1 -0
  450. package/app/.next/static/chunks/app/api/cli-tools/runtime/[toolId]/route-c452284fb77ecee0.js +1 -0
  451. package/app/.next/static/chunks/app/api/cloud/auth/route-c452284fb77ecee0.js +1 -0
  452. package/app/.next/static/chunks/app/api/cloud/credentials/update/route-c452284fb77ecee0.js +1 -0
  453. package/app/.next/static/chunks/app/api/cloud/model/resolve/route-c452284fb77ecee0.js +1 -0
  454. package/app/.next/static/chunks/app/api/cloud/models/alias/route-c452284fb77ecee0.js +1 -0
  455. package/app/.next/static/chunks/app/api/combos/[id]/route-c452284fb77ecee0.js +1 -0
  456. package/app/.next/static/chunks/app/api/combos/metrics/route-c452284fb77ecee0.js +1 -0
  457. package/app/.next/static/chunks/app/api/combos/route-c452284fb77ecee0.js +1 -0
  458. package/app/.next/static/chunks/app/api/combos/test/route-c452284fb77ecee0.js +1 -0
  459. package/app/.next/static/chunks/app/api/db-backups/route-c452284fb77ecee0.js +1 -0
  460. package/app/.next/static/chunks/app/api/init/route-c452284fb77ecee0.js +1 -0
  461. package/app/.next/static/chunks/app/api/keys/[id]/route-c452284fb77ecee0.js +1 -0
  462. package/app/.next/static/chunks/app/api/keys/route-c452284fb77ecee0.js +1 -0
  463. package/app/.next/static/chunks/app/api/models/alias/route-c452284fb77ecee0.js +1 -0
  464. package/app/.next/static/chunks/app/api/models/catalog/route-c452284fb77ecee0.js +1 -0
  465. package/app/.next/static/chunks/app/api/models/route-c452284fb77ecee0.js +1 -0
  466. package/app/.next/static/chunks/app/api/oauth/[provider]/[action]/route-c452284fb77ecee0.js +1 -0
  467. package/app/.next/static/chunks/app/api/oauth/cursor/auto-import/route-c452284fb77ecee0.js +1 -0
  468. package/app/.next/static/chunks/app/api/oauth/cursor/import/route-c452284fb77ecee0.js +1 -0
  469. package/app/.next/static/chunks/app/api/oauth/kiro/auto-import/route-c452284fb77ecee0.js +1 -0
  470. package/app/.next/static/chunks/app/api/oauth/kiro/import/route-c452284fb77ecee0.js +1 -0
  471. package/app/.next/static/chunks/app/api/oauth/kiro/social-authorize/route-c452284fb77ecee0.js +1 -0
  472. package/app/.next/static/chunks/app/api/oauth/kiro/social-exchange/route-c452284fb77ecee0.js +1 -0
  473. package/app/.next/static/chunks/app/api/pricing/defaults/route-c452284fb77ecee0.js +1 -0
  474. package/app/.next/static/chunks/app/api/pricing/models/route-c452284fb77ecee0.js +1 -0
  475. package/app/.next/static/chunks/app/api/pricing/route-c452284fb77ecee0.js +1 -0
  476. package/app/.next/static/chunks/app/api/provider-models/route-c452284fb77ecee0.js +1 -0
  477. package/app/.next/static/chunks/app/api/provider-nodes/[id]/route-c452284fb77ecee0.js +1 -0
  478. package/app/.next/static/chunks/app/api/provider-nodes/route-c452284fb77ecee0.js +1 -0
  479. package/app/.next/static/chunks/app/api/provider-nodes/validate/route-c452284fb77ecee0.js +1 -0
  480. package/app/.next/static/chunks/app/api/providers/[id]/models/route-c452284fb77ecee0.js +1 -0
  481. package/app/.next/static/chunks/app/api/providers/[id]/route-c452284fb77ecee0.js +1 -0
  482. package/app/.next/static/chunks/app/api/providers/[id]/test/route-c452284fb77ecee0.js +1 -0
  483. package/app/.next/static/chunks/app/api/providers/client/route-c452284fb77ecee0.js +1 -0
  484. package/app/.next/static/chunks/app/api/providers/route-c452284fb77ecee0.js +1 -0
  485. package/app/.next/static/chunks/app/api/providers/test-batch/route-c452284fb77ecee0.js +1 -0
  486. package/app/.next/static/chunks/app/api/providers/validate/route-c452284fb77ecee0.js +1 -0
  487. package/app/.next/static/chunks/app/api/rate-limit/route-c452284fb77ecee0.js +1 -0
  488. package/app/.next/static/chunks/app/api/rate-limits/route-c452284fb77ecee0.js +1 -0
  489. package/app/.next/static/chunks/app/api/restart/route-c452284fb77ecee0.js +1 -0
  490. package/app/.next/static/chunks/app/api/sessions/route-c452284fb77ecee0.js +1 -0
  491. package/app/.next/static/chunks/app/api/settings/combo-defaults/route-c452284fb77ecee0.js +1 -0
  492. package/app/.next/static/chunks/app/api/settings/ip-filter/route-c452284fb77ecee0.js +1 -0
  493. package/app/.next/static/chunks/app/api/settings/proxy/route-c452284fb77ecee0.js +1 -0
  494. package/app/.next/static/chunks/app/api/settings/proxy/test/route-c452284fb77ecee0.js +1 -0
  495. package/app/.next/static/chunks/app/api/settings/require-login/route-c452284fb77ecee0.js +1 -0
  496. package/app/.next/static/chunks/app/api/settings/route-c452284fb77ecee0.js +1 -0
  497. package/app/.next/static/chunks/app/api/settings/system-prompt/route-c452284fb77ecee0.js +1 -0
  498. package/app/.next/static/chunks/app/api/settings/thinking-budget/route-c452284fb77ecee0.js +1 -0
  499. package/app/.next/static/chunks/app/api/shutdown/route-c452284fb77ecee0.js +1 -0
  500. package/app/.next/static/chunks/app/api/storage/health/route-c452284fb77ecee0.js +1 -0
  501. package/app/.next/static/chunks/app/api/sync/cloud/route-c452284fb77ecee0.js +1 -0
  502. package/app/.next/static/chunks/app/api/sync/initialize/route-c452284fb77ecee0.js +1 -0
  503. package/app/.next/static/chunks/app/api/tags/route-c452284fb77ecee0.js +1 -0
  504. package/app/.next/static/chunks/app/api/translator/detect/route-c452284fb77ecee0.js +1 -0
  505. package/app/.next/static/chunks/app/api/translator/history/route-c452284fb77ecee0.js +1 -0
  506. package/app/.next/static/chunks/app/api/translator/load/route-c452284fb77ecee0.js +1 -0
  507. package/app/.next/static/chunks/app/api/translator/save/route-c452284fb77ecee0.js +1 -0
  508. package/app/.next/static/chunks/app/api/translator/send/route-c452284fb77ecee0.js +1 -0
  509. package/app/.next/static/chunks/app/api/translator/translate/route-c452284fb77ecee0.js +1 -0
  510. package/app/.next/static/chunks/app/api/usage/[connectionId]/route-c452284fb77ecee0.js +1 -0
  511. package/app/.next/static/chunks/app/api/usage/analytics/route-c452284fb77ecee0.js +1 -0
  512. package/app/.next/static/chunks/app/api/usage/call-logs/[id]/route-c452284fb77ecee0.js +1 -0
  513. package/app/.next/static/chunks/app/api/usage/call-logs/route-c452284fb77ecee0.js +1 -0
  514. package/app/.next/static/chunks/app/api/usage/history/route-c452284fb77ecee0.js +1 -0
  515. package/app/.next/static/chunks/app/api/usage/logs/route-c452284fb77ecee0.js +1 -0
  516. package/app/.next/static/chunks/app/api/usage/proxy-logs/route-c452284fb77ecee0.js +1 -0
  517. package/app/.next/static/chunks/app/api/usage/request-logs/route-c452284fb77ecee0.js +1 -0
  518. package/app/.next/static/chunks/app/api/v1/api/chat/route-c452284fb77ecee0.js +1 -0
  519. package/app/.next/static/chunks/app/api/v1/audio/speech/route-c452284fb77ecee0.js +1 -0
  520. package/app/.next/static/chunks/app/api/v1/audio/transcriptions/route-c452284fb77ecee0.js +1 -0
  521. package/app/.next/static/chunks/app/api/v1/chat/completions/route-c452284fb77ecee0.js +1 -0
  522. package/app/.next/static/chunks/app/api/v1/embeddings/route-c452284fb77ecee0.js +1 -0
  523. package/app/.next/static/chunks/app/api/v1/images/generations/route-c452284fb77ecee0.js +1 -0
  524. package/app/.next/static/chunks/app/api/v1/messages/count_tokens/route-c452284fb77ecee0.js +1 -0
  525. package/app/.next/static/chunks/app/api/v1/messages/route-c452284fb77ecee0.js +1 -0
  526. package/app/.next/static/chunks/app/api/v1/models/route-c452284fb77ecee0.js +1 -0
  527. package/app/.next/static/chunks/app/api/v1/moderations/route-c452284fb77ecee0.js +1 -0
  528. package/app/.next/static/chunks/app/api/v1/providers/[provider]/chat/completions/route-c452284fb77ecee0.js +1 -0
  529. package/app/.next/static/chunks/app/api/v1/providers/[provider]/embeddings/route-c452284fb77ecee0.js +1 -0
  530. package/app/.next/static/chunks/app/api/v1/providers/[provider]/images/generations/route-c452284fb77ecee0.js +1 -0
  531. package/app/.next/static/chunks/app/api/v1/rerank/route-c452284fb77ecee0.js +1 -0
  532. package/app/.next/static/chunks/app/api/v1/responses/route-c452284fb77ecee0.js +1 -0
  533. package/app/.next/static/chunks/app/api/v1/route-c452284fb77ecee0.js +1 -0
  534. package/app/.next/static/chunks/app/api/v1beta/models/[...path]/route-c452284fb77ecee0.js +1 -0
  535. package/app/.next/static/chunks/app/api/v1beta/models/route-c452284fb77ecee0.js +1 -0
  536. package/app/.next/static/chunks/app/login/{page-6ae7a54603d39926.js → page-e99ed6a85e91ae7c.js} +1 -1
  537. package/app/.next/static/chunks/app/page-c452284fb77ecee0.js +1 -0
  538. package/app/.next/static/chunks/next/dist/client/components/builtin/app-error-c452284fb77ecee0.js +1 -0
  539. package/app/.next/static/chunks/next/dist/client/components/builtin/forbidden-c452284fb77ecee0.js +1 -0
  540. package/app/.next/static/chunks/next/dist/client/components/builtin/not-found-c452284fb77ecee0.js +1 -0
  541. package/app/.next/static/chunks/next/dist/client/components/builtin/unauthorized-c452284fb77ecee0.js +1 -0
  542. package/app/.next/static/chunks/webpack-a2b6b20e2db553f5.js +1 -0
  543. package/app/.next/static/css/5309860f6e486620.css +1 -0
  544. package/app/package.json +1 -1
  545. package/app/server.js +1 -1
  546. package/package.json +1 -1
  547. package/app/.next/server/app/dashboard/settings/pricing/page.js +0 -2
  548. package/app/.next/server/app/dashboard/settings/pricing/page.js.nft.json +0 -1
  549. package/app/.next/server/app/dashboard/settings/pricing/page_client-reference-manifest.js +0 -1
  550. package/app/.next/server/chunks/1137.js +0 -1
  551. package/app/.next/server/chunks/351.js +0 -1
  552. package/app/.next/server/chunks/8152.js +0 -1
  553. package/app/.next/server/chunks/8668.js +0 -156
  554. package/app/.next/static/chunks/1525-92e9b6d0efa5de15.js +0 -7
  555. package/app/.next/static/chunks/7765-b6a02dccdc69da55.js +0 -1
  556. package/app/.next/static/chunks/app/(dashboard)/dashboard/endpoint/page-db18d6249d1949df.js +0 -1
  557. package/app/.next/static/chunks/app/(dashboard)/dashboard/page-03ddcbc4fc0b6c18.js +0 -1
  558. package/app/.next/static/chunks/app/(dashboard)/dashboard/profile/page-529101fdcd1e3b30.js +0 -1
  559. package/app/.next/static/chunks/app/(dashboard)/dashboard/settings/page-8e8021b6e227b5a9.js +0 -1
  560. package/app/.next/static/chunks/app/(dashboard)/dashboard/usage/page-bd8e6146106d32af.js +0 -1
  561. package/app/.next/static/chunks/app/_global-error/page-529101fdcd1e3b30.js +0 -1
  562. package/app/.next/static/chunks/app/api/auth/login/route-529101fdcd1e3b30.js +0 -1
  563. package/app/.next/static/chunks/app/api/auth/logout/route-529101fdcd1e3b30.js +0 -1
  564. package/app/.next/static/chunks/app/api/cli-tools/antigravity-mitm/alias/route-529101fdcd1e3b30.js +0 -1
  565. package/app/.next/static/chunks/app/api/cli-tools/antigravity-mitm/route-529101fdcd1e3b30.js +0 -1
  566. package/app/.next/static/chunks/app/api/cli-tools/backups/route-529101fdcd1e3b30.js +0 -1
  567. package/app/.next/static/chunks/app/api/cli-tools/claude-settings/route-529101fdcd1e3b30.js +0 -1
  568. package/app/.next/static/chunks/app/api/cli-tools/cline-settings/route-529101fdcd1e3b30.js +0 -1
  569. package/app/.next/static/chunks/app/api/cli-tools/codex-profiles/route-529101fdcd1e3b30.js +0 -1
  570. package/app/.next/static/chunks/app/api/cli-tools/codex-settings/route-529101fdcd1e3b30.js +0 -1
  571. package/app/.next/static/chunks/app/api/cli-tools/droid-settings/route-529101fdcd1e3b30.js +0 -1
  572. package/app/.next/static/chunks/app/api/cli-tools/guide-settings/[toolId]/route-529101fdcd1e3b30.js +0 -1
  573. package/app/.next/static/chunks/app/api/cli-tools/kilo-settings/route-529101fdcd1e3b30.js +0 -1
  574. package/app/.next/static/chunks/app/api/cli-tools/openclaw-settings/route-529101fdcd1e3b30.js +0 -1
  575. package/app/.next/static/chunks/app/api/cli-tools/runtime/[toolId]/route-529101fdcd1e3b30.js +0 -1
  576. package/app/.next/static/chunks/app/api/cloud/auth/route-529101fdcd1e3b30.js +0 -1
  577. package/app/.next/static/chunks/app/api/cloud/credentials/update/route-529101fdcd1e3b30.js +0 -1
  578. package/app/.next/static/chunks/app/api/cloud/model/resolve/route-529101fdcd1e3b30.js +0 -1
  579. package/app/.next/static/chunks/app/api/cloud/models/alias/route-529101fdcd1e3b30.js +0 -1
  580. package/app/.next/static/chunks/app/api/combos/[id]/route-529101fdcd1e3b30.js +0 -1
  581. package/app/.next/static/chunks/app/api/combos/metrics/route-529101fdcd1e3b30.js +0 -1
  582. package/app/.next/static/chunks/app/api/combos/route-529101fdcd1e3b30.js +0 -1
  583. package/app/.next/static/chunks/app/api/combos/test/route-529101fdcd1e3b30.js +0 -1
  584. package/app/.next/static/chunks/app/api/db-backups/route-529101fdcd1e3b30.js +0 -1
  585. package/app/.next/static/chunks/app/api/init/route-529101fdcd1e3b30.js +0 -1
  586. package/app/.next/static/chunks/app/api/keys/[id]/route-529101fdcd1e3b30.js +0 -1
  587. package/app/.next/static/chunks/app/api/keys/route-529101fdcd1e3b30.js +0 -1
  588. package/app/.next/static/chunks/app/api/models/alias/route-529101fdcd1e3b30.js +0 -1
  589. package/app/.next/static/chunks/app/api/models/catalog/route-529101fdcd1e3b30.js +0 -1
  590. package/app/.next/static/chunks/app/api/models/route-529101fdcd1e3b30.js +0 -1
  591. package/app/.next/static/chunks/app/api/oauth/[provider]/[action]/route-529101fdcd1e3b30.js +0 -1
  592. package/app/.next/static/chunks/app/api/oauth/cursor/auto-import/route-529101fdcd1e3b30.js +0 -1
  593. package/app/.next/static/chunks/app/api/oauth/cursor/import/route-529101fdcd1e3b30.js +0 -1
  594. package/app/.next/static/chunks/app/api/oauth/kiro/auto-import/route-529101fdcd1e3b30.js +0 -1
  595. package/app/.next/static/chunks/app/api/oauth/kiro/import/route-529101fdcd1e3b30.js +0 -1
  596. package/app/.next/static/chunks/app/api/oauth/kiro/social-authorize/route-529101fdcd1e3b30.js +0 -1
  597. package/app/.next/static/chunks/app/api/oauth/kiro/social-exchange/route-529101fdcd1e3b30.js +0 -1
  598. package/app/.next/static/chunks/app/api/pricing/defaults/route-529101fdcd1e3b30.js +0 -1
  599. package/app/.next/static/chunks/app/api/pricing/route-529101fdcd1e3b30.js +0 -1
  600. package/app/.next/static/chunks/app/api/provider-models/route-529101fdcd1e3b30.js +0 -1
  601. package/app/.next/static/chunks/app/api/provider-nodes/[id]/route-529101fdcd1e3b30.js +0 -1
  602. package/app/.next/static/chunks/app/api/provider-nodes/route-529101fdcd1e3b30.js +0 -1
  603. package/app/.next/static/chunks/app/api/provider-nodes/validate/route-529101fdcd1e3b30.js +0 -1
  604. package/app/.next/static/chunks/app/api/providers/[id]/models/route-529101fdcd1e3b30.js +0 -1
  605. package/app/.next/static/chunks/app/api/providers/[id]/route-529101fdcd1e3b30.js +0 -1
  606. package/app/.next/static/chunks/app/api/providers/[id]/test/route-529101fdcd1e3b30.js +0 -1
  607. package/app/.next/static/chunks/app/api/providers/client/route-529101fdcd1e3b30.js +0 -1
  608. package/app/.next/static/chunks/app/api/providers/route-529101fdcd1e3b30.js +0 -1
  609. package/app/.next/static/chunks/app/api/providers/test-batch/route-529101fdcd1e3b30.js +0 -1
  610. package/app/.next/static/chunks/app/api/providers/validate/route-529101fdcd1e3b30.js +0 -1
  611. package/app/.next/static/chunks/app/api/rate-limit/route-529101fdcd1e3b30.js +0 -1
  612. package/app/.next/static/chunks/app/api/restart/route-529101fdcd1e3b30.js +0 -1
  613. package/app/.next/static/chunks/app/api/settings/combo-defaults/route-529101fdcd1e3b30.js +0 -1
  614. package/app/.next/static/chunks/app/api/settings/proxy/route-529101fdcd1e3b30.js +0 -1
  615. package/app/.next/static/chunks/app/api/settings/proxy/test/route-529101fdcd1e3b30.js +0 -1
  616. package/app/.next/static/chunks/app/api/settings/require-login/route-529101fdcd1e3b30.js +0 -1
  617. package/app/.next/static/chunks/app/api/settings/route-529101fdcd1e3b30.js +0 -1
  618. package/app/.next/static/chunks/app/api/shutdown/route-529101fdcd1e3b30.js +0 -1
  619. package/app/.next/static/chunks/app/api/storage/health/route-529101fdcd1e3b30.js +0 -1
  620. package/app/.next/static/chunks/app/api/sync/cloud/route-529101fdcd1e3b30.js +0 -1
  621. package/app/.next/static/chunks/app/api/sync/initialize/route-529101fdcd1e3b30.js +0 -1
  622. package/app/.next/static/chunks/app/api/tags/route-529101fdcd1e3b30.js +0 -1
  623. package/app/.next/static/chunks/app/api/translator/detect/route-529101fdcd1e3b30.js +0 -1
  624. package/app/.next/static/chunks/app/api/translator/history/route-529101fdcd1e3b30.js +0 -1
  625. package/app/.next/static/chunks/app/api/translator/load/route-529101fdcd1e3b30.js +0 -1
  626. package/app/.next/static/chunks/app/api/translator/save/route-529101fdcd1e3b30.js +0 -1
  627. package/app/.next/static/chunks/app/api/translator/send/route-529101fdcd1e3b30.js +0 -1
  628. package/app/.next/static/chunks/app/api/translator/translate/route-529101fdcd1e3b30.js +0 -1
  629. package/app/.next/static/chunks/app/api/usage/[connectionId]/route-529101fdcd1e3b30.js +0 -1
  630. package/app/.next/static/chunks/app/api/usage/analytics/route-529101fdcd1e3b30.js +0 -1
  631. package/app/.next/static/chunks/app/api/usage/call-logs/[id]/route-529101fdcd1e3b30.js +0 -1
  632. package/app/.next/static/chunks/app/api/usage/call-logs/route-529101fdcd1e3b30.js +0 -1
  633. package/app/.next/static/chunks/app/api/usage/history/route-529101fdcd1e3b30.js +0 -1
  634. package/app/.next/static/chunks/app/api/usage/logs/route-529101fdcd1e3b30.js +0 -1
  635. package/app/.next/static/chunks/app/api/usage/proxy-logs/route-529101fdcd1e3b30.js +0 -1
  636. package/app/.next/static/chunks/app/api/usage/request-logs/route-529101fdcd1e3b30.js +0 -1
  637. package/app/.next/static/chunks/app/api/v1/api/chat/route-529101fdcd1e3b30.js +0 -1
  638. package/app/.next/static/chunks/app/api/v1/audio/speech/route-529101fdcd1e3b30.js +0 -1
  639. package/app/.next/static/chunks/app/api/v1/audio/transcriptions/route-529101fdcd1e3b30.js +0 -1
  640. package/app/.next/static/chunks/app/api/v1/chat/completions/route-529101fdcd1e3b30.js +0 -1
  641. package/app/.next/static/chunks/app/api/v1/embeddings/route-529101fdcd1e3b30.js +0 -1
  642. package/app/.next/static/chunks/app/api/v1/images/generations/route-529101fdcd1e3b30.js +0 -1
  643. package/app/.next/static/chunks/app/api/v1/messages/count_tokens/route-529101fdcd1e3b30.js +0 -1
  644. package/app/.next/static/chunks/app/api/v1/messages/route-529101fdcd1e3b30.js +0 -1
  645. package/app/.next/static/chunks/app/api/v1/models/route-529101fdcd1e3b30.js +0 -1
  646. package/app/.next/static/chunks/app/api/v1/moderations/route-529101fdcd1e3b30.js +0 -1
  647. package/app/.next/static/chunks/app/api/v1/providers/[provider]/chat/completions/route-529101fdcd1e3b30.js +0 -1
  648. package/app/.next/static/chunks/app/api/v1/providers/[provider]/embeddings/route-529101fdcd1e3b30.js +0 -1
  649. package/app/.next/static/chunks/app/api/v1/providers/[provider]/images/generations/route-529101fdcd1e3b30.js +0 -1
  650. package/app/.next/static/chunks/app/api/v1/rerank/route-529101fdcd1e3b30.js +0 -1
  651. package/app/.next/static/chunks/app/api/v1/responses/route-529101fdcd1e3b30.js +0 -1
  652. package/app/.next/static/chunks/app/api/v1/route-529101fdcd1e3b30.js +0 -1
  653. package/app/.next/static/chunks/app/api/v1beta/models/[...path]/route-529101fdcd1e3b30.js +0 -1
  654. package/app/.next/static/chunks/app/api/v1beta/models/route-529101fdcd1e3b30.js +0 -1
  655. package/app/.next/static/chunks/app/dashboard/settings/pricing/page-878ee68a0303128f.js +0 -1
  656. package/app/.next/static/chunks/app/page-529101fdcd1e3b30.js +0 -1
  657. package/app/.next/static/chunks/next/dist/client/components/builtin/app-error-529101fdcd1e3b30.js +0 -1
  658. package/app/.next/static/chunks/next/dist/client/components/builtin/forbidden-529101fdcd1e3b30.js +0 -1
  659. package/app/.next/static/chunks/next/dist/client/components/builtin/not-found-529101fdcd1e3b30.js +0 -1
  660. package/app/.next/static/chunks/next/dist/client/components/builtin/unauthorized-529101fdcd1e3b30.js +0 -1
  661. package/app/.next/static/chunks/webpack-f742cb5c6c3130ec.js +0 -1
  662. package/app/.next/static/css/777d65a484db49a1.css +0 -1
  663. package/app/.next/static/l-F9C6gggjrUWKnAln0Wn/_buildManifest.js +0 -1
  664. /package/app/.next/static/{l-F9C6gggjrUWKnAln0Wn → XnNWFvV2IXZ4xuX0F1Skg}/_ssgManifest.js +0 -0
@@ -1 +1 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[2134],{29556:(e,t,i)=>{"use strict";i.r(t),i.d(t,{default:()=>u});var s=i(95155),a=i(12115),r=i(14051),l=i(73321),n=i(98500),o=i(5772),d=i(71525),c=i(64745),p=i(18595),m=i(26853);function u(){let e=(0,l.useParams)(),t=(0,l.useRouter)(),i=e.id,[r,u]=(0,a.useState)([]),[f,v]=(0,a.useState)(!0),[g,w]=(0,a.useState)(null),[A,S]=(0,a.useState)(!1),[T,$]=(0,a.useState)(!1),[R,E]=(0,a.useState)(!1),[I,O]=(0,a.useState)(!1),[_,P]=(0,a.useState)(null),[q,U]=(0,a.useState)(null),[D,K]=(0,a.useState)({}),[L,M]=(0,a.useState)(!1),{copied:F,copy:z}=(0,m.C)(),V=(0,a.useRef)(!1),J=(0,a.useRef)(!1),[B,W]=(0,a.useState)(null),[Z,G]=(0,a.useState)(null),[Q,H]=(0,a.useState)(!1),X=g?{id:g.id,name:g.name||("anthropic-compatible"===g.type?"Anthropic Compatible":"OpenAI Compatible"),color:"anthropic-compatible"===g.type?"#D97757":"#10A37F",textIcon:"anthropic-compatible"===g.type?"AC":"OC",apiType:g.apiType,baseUrl:g.baseUrl,type:g.type}:c.IS[i]||c.zN[i]||c.fg[i],Y=!!c.IS[i]||!!c.zN[i],ee=(0,p.KC)(i),et=(0,c.wG)(i),ei=(0,c.mq)(i),es=(0,c.gb)(i),ea=ei||es,er=ea?i:et,el=ea?g?.prefix||i:et,en=(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)}},[]),eo=(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===i);u(e)}if(t.ok){let e=(a.nodes||[]).find(e=>e.id===i)||null;if(!e&&ea)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===i)||null))break}w(e)}}catch(e){console.log("Error fetching connections:",e)}finally{v(!1)}},[i,ea]),ed=async e=>{try{let t=await fetch(`/api/provider-nodes/${i}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),s=await t.json();t.ok&&(w(s.node),await eo(),O(!1))}catch(e){console.log("Error updating provider node:",e)}};(0,a.useEffect)(()=>{eo(),en(),fetch("/api/settings/proxy").then(e=>e.ok?e.json():null).then(e=>G(e)).catch(()=>{})},[eo,en]),(0,a.useEffect)(()=>{f||0!==r.length||!X||ea||V.current||J.current||(V.current=!0,Y?S(!0):$(!0))},[f]);let ec=async(e,t,i=et)=>{let s=`${i}/${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 en();else{let t=await e.json();alert(t.error||"Failed to set alias")}}catch(e){console.log("Error setting alias:",e)}},ep=async e=>{try{(await fetch(`/api/models/alias?alias=${encodeURIComponent(e)}`,{method:"DELETE"})).ok&&await en()}catch(e){console.log("Error deleting alias:",e)}},em=async e=>{if(confirm("Delete this connection?"))try{(await fetch(`/api/providers/${e}`,{method:"DELETE"})).ok&&u(r.filter(t=>t.id!==e))}catch(e){console.log("Error deleting connection:",e)}},eu=(0,a.useCallback)(()=>{eo(),S(!1)},[eo]),ex=async e=>{try{(await fetch("/api/providers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:i,...e})})).ok&&(await eo(),$(!1))}catch(e){console.log("Error saving connection:",e)}},eh=async e=>{try{(await fetch(`/api/providers/${_.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})).ok&&(await eo(),E(!1))}catch(e){console.log("Error updating connection:",e)}},ef=async(e,t)=>{try{(await fetch(`/api/providers/${e}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({isActive:t})})).ok&&u(i=>i.map(i=>i.id===e?{...i,isActive:t}:i))}catch(e){console.log("Error updating connection status:",e)}},ey=async(e,t)=>{try{(await fetch("/api/rate-limit",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({connectionId:e,enabled:t})})).ok&&u(i=>i.map(i=>i.id===e?{...i,rateLimitProtection:t}:i))}catch(e){console.error("Error toggling rate limit:",e)}},eb=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 eo()}catch(e){console.error("Error retesting connection:",e)}finally{U(null)}}},ev=async(e,t)=>{if(e&&t)try{let i=t.priority,s=e.priority;i===s&&(i=r.indexOf(e)>r.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:i})}),fetch(`/api/providers/${t.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({priority:s})})]),await eo()}catch(e){console.log("Error swapping priority:",e)}},eg=async()=>{if(Q)return;let e=r.find(e=>!1!==e.isActive);if(e){H(!0);try{let t=await fetch(`/api/providers/${e.id}/models`),i=await t.json();if(!t.ok)return void alert(i.error||"Failed to import models");let s=i.models||[];if(0===s.length)return void alert("No models returned from /models.");let a=0;for(let e of s){let t=e.id||e.name||e.model;if(!t)continue;let i=t.split("/"),s=i[i.length-1];D[s]||(await ec(t,s,er),a+=1)}0===a&&alert("No new models were added (all already exist)."),await en()}catch(e){console.log("Error importing models:",e)}finally{H(!1)}}},ej=r.some(e=>!1!==e.isActive);return f?(0,s.jsxs)("div",{className:"flex flex-col gap-8",children:[(0,s.jsx)(d.Qv,{}),(0,s.jsx)(d.Qv,{})]}):X?(0,s.jsxs)("div",{className:"flex flex-col gap-8",children:[(0,s.jsxs)("div",{children:[(0,s.jsxs)(n,{href:"/dashboard/providers",className:"inline-flex items-center gap-1 text-sm text-text-muted hover:text-primary transition-colors mb-4",children:[(0,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:`${X.color}15`},children:L?(0,s.jsx)("span",{className:"text-sm font-bold",style:{color:X.color},children:X.textIcon||X.id.slice(0,2).toUpperCase()}):(0,s.jsx)(o.default,{src:ei&&X.apiType?"responses"===X.apiType?"/providers/oai-r.png":"/providers/oai-cc.png":es?"/providers/anthropic-m.png":`/providers/${X.id}.png`,alt:X.name,width:48,height:48,className:"object-contain rounded-lg max-w-[48px] max-h-[48px]",sizes:"48px",onError:()=>M(!0)})}),(0,s.jsxs)("div",{children:[X.website?(0,s.jsxs)("a",{href:X.website,target:"_blank",rel:"noopener noreferrer",className:"text-3xl font-semibold tracking-tight hover:underline inline-flex items-center gap-2",style:{color:X.color},children:[X.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:X.name}),(0,s.jsxs)("p",{className:"text-text-muted",children:[r.length," connection",1===r.length?"":"s"]})]})]})]}),ea&&g&&(0,s.jsxs)(d.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:es?"Anthropic Compatible Details":"OpenAI Compatible Details"}),(0,s.jsxs)("p",{className:"text-sm text-text-muted",children:[es?"Messages API":"responses"===g.apiType?"Responses API":"Chat Completions"," ","\xb7 ",(g.baseUrl||"").replace(/\/$/,""),"/",es?"messages":"responses"===g.apiType?"responses":"chat/completions"]})]}),(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)(d.$n,{size:"sm",icon:"add",onClick:()=>$(!0),disabled:r.length>0,children:"Add"}),(0,s.jsx)(d.$n,{size:"sm",variant:"secondary",icon:"edit",onClick:()=>O(!0),children:"Edit"}),(0,s.jsx)(d.$n,{size:"sm",variant:"secondary",icon:"delete",onClick:async()=>{if(confirm(`Delete this ${es?"Anthropic":"OpenAI"} Compatible node?`))try{(await fetch(`/api/provider-nodes/${i}`,{method:"DELETE"})).ok&&t.push("/dashboard/providers")}catch(e){console.log("Error deleting provider node:",e)}},children:"Delete"})]})]}),r.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)(d.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"}),!ea&&(0,s.jsx)(d.$n,{size:"sm",icon:"add",onClick:()=>Y?S(!0):$(!0),children:"Add"})]}),0===r.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:Y?"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"}),!ea&&(0,s.jsx)(d.$n,{icon:"add",onClick:()=>Y?S(!0):$(!0),children:"Add Connection"})]}):(0,s.jsx)("div",{className:"flex flex-col divide-y divide-black/[0.03] dark:divide-white/[0.03]",children:r.sort((e,t)=>(e.priority||0)-(t.priority||0)).map((e,t)=>(0,s.jsx)(j,{connection:e,isOAuth:Y,isFirst:0===t,isLast:t===r.length-1,onMoveUp:()=>ev(e,r[t-1]),onMoveDown:()=>ev(e,r[t+1]),onToggleActive:t=>ef(e.id,t),onToggleRateLimit:t=>ey(e.id,t),onRetest:()=>eb(e.id),isRetesting:q===e.id,onEdit:()=>{P(e),E(!0)},onDelete:()=>em(e.id),onReauth:Y?()=>S(!0):void 0,onProxy:()=>W({level:"key",id:e.id,label:e.name||e.email||e.id}),hasProxy:!!Z?.keys?.[e.id]},e.id))})]}),(0,s.jsxs)(d.Zp,{children:[(0,s.jsx)("h2",{className:"text-lg font-semibold mb-4",children:X.passthroughModels?"Model Aliases":"Available Models"}),(()=>{if(ea)return(0,s.jsx)(b,{providerStorageAlias:er,providerDisplayAlias:el,modelAliases:D,copied:F,onCopy:z,onSetAlias:ec,onDeleteAlias:ep,connections:r,isAnthropic:es});if(X.passthroughModels)return(0,s.jsx)(h,{providerAlias:et,modelAliases:D,copied:F,onCopy:z,onSetAlias:ec,onDeleteAlias:ep});let e=(0,s.jsxs)("div",{className:"flex items-center gap-2 mb-4",children:[(0,s.jsx)(d.$n,{size:"sm",variant:"secondary",icon:"download",onClick:eg,disabled:!ej||Q,children:Q?"Importing...":"Import from /models"}),!ej&&(0,s.jsx)("span",{className:"text-xs text-text-muted",children:"Add a connection to enable importing."})]});return 0===ee.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:ee.map(e=>{let t=`${er}/${e.id}`,a=`${i}/${e.id}`,r=Object.entries(D).find(([,e])=>e===t||e===a)?.[0];return(0,s.jsx)(x,{model:e,fullModel:`${el}/${e.id}`,alias:r,copied:F,onCopy:z,onSetAlias:t=>ec(e.id,t,er),onDeleteAlias:()=>ep(r)},e.id)})})]})})(),!ea&&(0,s.jsx)(y,{providerId:i,providerAlias:el,copied:F,onCopy:z})]}),"kiro"===i?(0,s.jsx)(d.Mh,{isOpen:A,providerInfo:X,onSuccess:eu,onClose:()=>{J.current=!0,S(!1)}}):"cursor"===i?(0,s.jsx)(d.G9,{isOpen:A,onSuccess:eu,onClose:()=>{J.current=!0,S(!1)}}):(0,s.jsx)(d.LF,{isOpen:A,provider:i,providerInfo:X,onSuccess:eu,onClose:()=>{J.current=!0,S(!1)}}),(0,s.jsx)(N,{isOpen:T,provider:i,providerName:X.name,isCompatible:ea,isAnthropic:es,onSave:ex,onClose:()=>$(!1)}),(0,s.jsx)(k,{isOpen:R,connection:_,onSave:eh,onClose:()=>E(!1)}),ea&&(0,s.jsx)(C,{isOpen:I,node:g,onSave:ed,onClose:()=>O(!1),isAnthropic:es}),B&&(0,s.jsx)(d.KN,{isOpen:!!B,onClose:()=>W(null),level:B.level,levelId:B.id,levelLabel:B.label})]}):(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)(n,{href:"/dashboard/providers",className:"text-primary mt-4 inline-block",children:"Back to Providers"})]})}function x({model:e,fullModel:t,alias:i,copied:a,onCopy:r}){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:()=>r(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 h({providerAlias:e,modelAliases:t,copied:i,onCopy:r,onSetAlias:l,onDeleteAlias:n}){let[o,c]=(0,a.useState)(""),[p,m]=(0,a.useState)(!1),u=Object.entries(t).filter(([,t])=>t.startsWith(`${e}/`)).map(([t,i])=>({modelId:i.replace(`${e}/`,""),fullModel:i,alias:t})),x=async()=>{let e;if(!o.trim()||p)return;let i=o.trim(),s=(e=i.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(i,s),c("")}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:o,onChange:e=>c(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,s.jsx)(d.$n,{size:"sm",icon:"add",onClick:x,disabled:!o.trim()||p,children:p?"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)(f,{modelId:e,fullModel:t,copied:i,onCopy:r,onDeleteAlias:()=>n(a)},t))})]})}function f({modelId:e,fullModel:t,copied:i,onCopy:a,onDeleteAlias:r}){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:i===`model-${e}`?"check":"content_copy"})})]})]}),(0,s.jsx)("button",{onClick:r,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 y({providerId:e,providerAlias:t,copied:i,onCopy:r}){let[l,n]=(0,a.useState)([]),[o,c]=(0,a.useState)(""),[p,m]=(0,a.useState)(""),[u,x]=(0,a.useState)(!1),[h,f]=(0,a.useState)(!0),y=(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)(()=>{y()},[y]);let b=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:p.trim()||void 0})})).ok&&(c(""),m(""),await y())}catch(e){console.error("Failed to add custom model:",e)}finally{x(!1)}}},v=async t=>{try{await fetch(`/api/provider-models?provider=${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:o,onChange:e=>c(e.target.value),onKeyDown:e=>"Enter"===e.key&&b(),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:p,onChange:e=>m(e.target.value),onKeyDown:e=>"Enter"===e.key&&b(),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)(d.$n,{size:"sm",icon:"add",onClick:b,disabled:!o.trim()||u,children:u?"Adding...":"Add"})]}),h?(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:()=>r(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:i===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 b({providerStorageAlias:e,providerDisplayAlias:t,modelAliases:i,copied:r,onCopy:l,onSetAlias:n,onDeleteAlias:o,connections:c,isAnthropic:p}){let[m,u]=(0,a.useState)(""),[x,h]=(0,a.useState)(!1),[y,b]=(0,a.useState)(!1),v=Object.entries(i).filter(([,t])=>t.startsWith(`${e}/`)).map(([t,i])=>({modelId:i.replace(`${e}/`,""),fullModel:i,alias:t})),g=e=>{let s,a=(s=e.split("/"))[s.length-1];if(!i[a])return a;let r=`${t}-${a}`;return i[r]?null:r},j=async()=>{if(!m.trim()||x)return;let t=m.trim(),i=g(t);if(!i)return void alert("All suggested aliases already exist. Please choose a different model or remove conflicting aliases.");h(!0);try{await n(t,i,e),u("")}catch(e){console.log("Error adding model:",e)}finally{h(!1)}},N=async()=>{if(y)return;let t=c.find(e=>!1!==e.isActive);if(t){b(!0);try{let i=await fetch(`/api/providers/${t.id}/models`),s=await i.json();if(!i.ok)return void alert(s.error||"Failed to import models");let a=s.models||[];if(0===a.length)return void alert("No models returned from /models.");let r=0;for(let t of a){let i=t.id||t.name||t.model;if(!i)continue;let s=g(i);s&&(await n(i,s,e),r+=1)}0===r&&alert("No new models were added.")}catch(e){console.log("Error importing models:",e)}finally{b(!1)}}},k=c.some(e=>!1!==e.isActive);return(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,s.jsxs)("p",{className:"text-sm text-text-muted",children:["Add ",p?"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:m,onChange:e=>u(e.target.value),onKeyDown:e=>"Enter"===e.key&&j(),placeholder:p?"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)(d.$n,{size:"sm",icon:"add",onClick:j,disabled:!m.trim()||x,children:x?"Adding...":"Add"}),(0,s.jsx)(d.$n,{size:"sm",variant:"secondary",icon:"download",onClick:N,disabled:!k||y,children:y?"Importing...":"Import from /models"})]}),!k&&(0,s.jsx)("p",{className:"text-xs text-text-muted",children:"Add a connection to enable importing models."}),v.length>0&&(0,s.jsx)("div",{className:"flex flex-col gap-3",children:v.map(({modelId:e,fullModel:i,alias:a})=>(0,s.jsx)(f,{modelId:e,fullModel:`${t}/${e}`,copied:r,onCopy:l,onDeleteAlias:()=>o(a)},i))})]})}function v({until:e}){let[t,i]=(0,a.useState)("");return((0,a.useEffect)(()=>{let t=()=>{let t=new Date(e).getTime()-Date.now();if(t<=0)return void i("");let s=Math.floor(t/1e3);if(s<60)i(`${s}s`);else if(s<3600)i(`${Math.floor(s/60)}m ${s%60}s`);else{let e=Math.floor(s/3600),t=Math.floor(s%3600/60);i(`${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}x.propTypes={model:r.shape({id:r.string.isRequired}).isRequired,fullModel:r.string.isRequired,alias:r.string,copied:r.string,onCopy:r.func.isRequired},h.propTypes={providerAlias:r.string.isRequired,modelAliases:r.object.isRequired,copied:r.string,onCopy:r.func.isRequired,onSetAlias:r.func.isRequired,onDeleteAlias:r.func.isRequired},f.propTypes={modelId:r.string.isRequired,fullModel:r.string.isRequired,copied:r.string,onCopy:r.func.isRequired,onDeleteAlias:r.func.isRequired},y.propTypes={providerId:r.string.isRequired,providerAlias:r.string.isRequired,copied:r.string,onCopy:r.func.isRequired},b.propTypes={providerStorageAlias:r.string.isRequired,providerDisplayAlias:r.string.isRequired,modelAliases:r.object.isRequired,copied:r.string,onCopy:r.func.isRequired,onSetAlias:r.func.isRequired,onDeleteAlias:r.func.isRequired,connections:r.arrayOf(r.shape({id:r.string,isActive:r.bool})).isRequired,isAnthropic:r.bool},v.propTypes={until:r.string.isRequired};let g={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 j({connection:e,isOAuth:t,isFirst:i,isLast:r,onMoveUp:l,onMoveDown:n,onToggleActive:o,onToggleRateLimit:c,onRetest:p,isRetesting:m,onEdit:u,onDelete:x,onReauth:h,onProxy:f,hasProxy:y}){let b=t?e.name||e.email||e.displayName||"OAuth Account":e.name,[j,N]=(0,a.useState)(!1);(0,a.useEffect)(()=>{let t=()=>{N(e.rateLimitedUntil&&new Date(e.rateLimitedUntil).getTime()>Date.now())};t();let i=e.rateLimitedUntil?setInterval(t,1e3):null;return()=>{i&&clearInterval(i)}},[e.rateLimitedUntil]);let k="unavailable"!==e.testStatus||j?e.testStatus:"active",C=function(e,t,i){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 i=Number(e.errorCode);if(401===i||403===i)return"upstream_auth_error";if(429===i)return"upstream_rate_limited";if(i>=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,i),a=s&&g[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,k,j),w=!!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: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_up"})}),(0,s.jsx)("button",{onClick:n,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_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:b}),(0,s.jsxs)("div",{className:"flex items-center gap-2 mt-1 flex-wrap",children:[(0,s.jsx)(d.Ex,{variant:C.statusVariant,size:"sm",dot:!0,children:C.statusLabel}),j&&!1!==e.isActive&&(0,s.jsx)(v,{until:e.rateLimitedUntil}),C.errorBadge&&!1!==e.isActive&&(0,s.jsx)(d.Ex,{variant:C.errorBadge.variant,size:"sm",children:C.errorBadge.label}),e.lastError&&!1!==e.isActive&&(0,s.jsx)("span",{className:`text-xs truncate max-w-[300px] ${C.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:()=>c(!w),className:`inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-xs font-medium transition-all cursor-pointer ${w?"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:w?"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"}),w?"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)(d.$n,{size:"sm",variant:"ghost",icon:"refresh",loading:m,disabled:!1===e.isActive,onClick:p,className:"!h-7 !px-2 text-xs",title:"Retest authentication",children:"Retest"}),(0,s.jsx)(d.lM,{size:"sm",checked:e.isActive??!0,onChange:o,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:[h&&(0,s.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,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:x,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 N({isOpen:e,provider:t,providerName:i,isCompatible:r,isAnthropic:l,onSave:n,onClose:o}){let[c,p]=(0,a.useState)({name:"",apiKey:"",priority:1}),[m,u]=(0,a.useState)(!1),[x,h]=(0,a.useState)(null),[f,y]=(0,a.useState)(!1),b=async()=>{u(!0);try{let e=await fetch("/api/providers/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:t,apiKey:c.apiKey})}),i=await e.json();h(i.valid?"success":"failed")}catch{h("failed")}finally{u(!1)}},v=async()=>{if(t&&c.apiKey){y(!0);try{let e=!1;try{u(!0),h(null);let i=await fetch("/api/providers/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:t,apiKey:c.apiKey})});e=!!(await i.json()).valid,h(e?"success":"failed")}catch{h("failed")}finally{u(!1)}await n({name:c.name,apiKey:c.apiKey,priority:c.priority,testStatus:e?"active":"unknown"})}finally{y(!1)}}};return t?(0,s.jsx)(d.aF,{isOpen:e,title:`Add ${i||t} API Key`,onClose:o,children:(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,s.jsx)(d.pd,{label:"Name",value:c.name,onChange:e=>p({...c,name:e.target.value}),placeholder:"Production Key"}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(d.pd,{label:"API Key",type:"password",value:c.apiKey,onChange:e=>p({...c,apiKey:e.target.value}),className:"flex-1"}),(0,s.jsx)("div",{className:"pt-6",children:(0,s.jsx)(d.$n,{onClick:b,disabled:!c.apiKey||m||f,variant:"secondary",children:m?"Checking...":"Check"})})]}),x&&(0,s.jsx)(d.Ex,{variant:"success"===x?"success":"error",children:"success"===x?"Valid":"Invalid"}),r&&(0,s.jsx)("p",{className:"text-xs text-text-muted",children:l?`Validation checks ${i||"Anthropic Compatible"} by verifying the API key.`:`Validation checks ${i||"OpenAI Compatible"} via /models on your base URL.`}),(0,s.jsx)(d.pd,{label:"Priority",type:"number",value:c.priority,onChange:e=>p({...c,priority:Number.parseInt(e.target.value)||1})}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(d.$n,{onClick:v,fullWidth:!0,disabled:!c.name||!c.apiKey||f,children:f?"Saving...":"Save"}),(0,s.jsx)(d.$n,{onClick:o,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})}):null}function k({isOpen:e,connection:t,onSave:i,onClose:r}){let[l,n]=(0,a.useState)({name:"",priority:1,apiKey:"",healthCheckInterval:60}),[o,p]=(0,a.useState)(!1),[m,u]=(0,a.useState)(null),[x,h]=(0,a.useState)(!1),[f,y]=(0,a.useState)(null),[b,v]=(0,a.useState)(!1);(0,a.useEffect)(()=>{t&&(n({name:t.name||"",priority:t.priority||1,apiKey:"",healthCheckInterval:t.healthCheckInterval??60}),u(null),y(null))},[t]);let j=async()=>{if(t?.provider){p(!0),u(null);try{let e=await fetch(`/api/providers/${t.id}/test`,{method:"POST"}),i=await e.json();u({valid:!!i.valid,diagnosis:i.diagnosis||null,message:i.error||null})}catch{u({valid:!1,diagnosis:{type:"network_error"},message:"Failed to test connection"})}finally{p(!1)}}},N=async()=>{if(t?.provider&&l.apiKey){h(!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})}),i=await e.json();y(i.valid?"success":"failed")}catch{y("failed")}finally{h(!1)}}},k=async()=>{v(!0);try{let e={name:l.name,priority:l.priority,healthCheckInterval:l.healthCheckInterval};if(!C&&l.apiKey){e.apiKey=l.apiKey;let i="success"===f;if(!i)try{h(!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})});i=!!(await e.json()).valid,y(i?"success":"failed")}catch{y("failed")}finally{h(!1)}i&&(e.testStatus="active",e.lastError=null,e.lastErrorAt=null,e.lastErrorType=null,e.lastErrorSource=null,e.errorCode=null,e.rateLimitedUntil=null)}await i(e)}finally{v(!1)}};if(!t)return null;let C="oauth"===t.authType,w=(0,c.mq)(t.provider)||(0,c.gb)(t.provider),A=!m?.valid&&m?.diagnosis?.type&&g[m.diagnosis.type]||null;return(0,s.jsx)(d.aF,{isOpen:e,title:"Edit Connection",onClose:r,children:(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,s.jsx)(d.pd,{label:"Name",value:l.name,onChange:e=>n({...l,name:e.target.value}),placeholder:C?"Account name":"Production Key"}),C&&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})]}),C&&(0,s.jsx)(d.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,s.jsx)(d.pd,{label:"Priority",type:"number",value:l.priority,onChange:e=>n({...l,priority:Number.parseInt(e.target.value)||1})}),!C&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(d.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,s.jsx)("div",{className:"pt-6",children:(0,s.jsx)(d.$n,{onClick:N,disabled:!l.apiKey||x||b,variant:"secondary",children:x?"Checking...":"Check"})})]}),f&&(0,s.jsx)(d.Ex,{variant:"success"===f?"success":"error",children:"success"===f?"Valid":"Invalid"})]}),!w&&(0,s.jsxs)("div",{className:"flex items-center gap-3",children:[(0,s.jsx)(d.$n,{onClick:j,variant:"secondary",disabled:o,children:o?"Testing...":"Test Connection"}),m&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(d.Ex,{variant:m.valid?"success":"error",children:m.valid?"Valid":"Failed"}),A&&(0,s.jsx)(d.Ex,{variant:A.variant,children:A.label})]})]}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(d.$n,{onClick:k,fullWidth:!0,disabled:b,children:b?"Saving...":"Save"}),(0,s.jsx)(d.$n,{onClick:r,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})})}function C({isOpen:e,node:t,onSave:i,onClose:r,isAnthropic:l}){let[n,o]=(0,a.useState)({name:"",prefix:"",apiType:"chat",baseUrl:"https://api.openai.com/v1"}),[c,p]=(0,a.useState)(!1),[m,u]=(0,a.useState)(""),[x,h]=(0,a.useState)(!1),[f,y]=(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 b=async()=>{if(n.name.trim()&&n.prefix.trim()&&n.baseUrl.trim()){p(!0);try{let e={name:n.name,prefix:n.prefix,baseUrl:n.baseUrl};l||(e.apiType=n.apiType),await i(e)}finally{p(!1)}}},v=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:m,type:l?"anthropic-compatible":"openai-compatible"})}),t=await e.json();y(t.valid?"success":"failed")}catch{y("failed")}finally{h(!1)}};return t?(0,s.jsx)(d.aF,{isOpen:e,title:`Edit ${l?"Anthropic":"OpenAI"} Compatible`,onClose:r,children:(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,s.jsx)(d.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,s.jsx)(d.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,s.jsx)(d.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,s.jsx)(d.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,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(d.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)(d.$n,{onClick:v,disabled:!m||x||!n.baseUrl.trim(),variant:"secondary",children:x?"Checking...":"Check"})})]}),f&&(0,s.jsx)(d.Ex,{variant:"success"===f?"success":"error",children:"success"===f?"Valid":"Invalid"}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(d.$n,{onClick:b,fullWidth:!0,disabled:!n.name.trim()||!n.prefix.trim()||!n.baseUrl.trim()||c,children:c?"Saving...":"Save"}),(0,s.jsx)(d.$n,{onClick:r,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})}):null}j.propTypes={connection:r.shape({id:r.string,name:r.string,email:r.string,displayName:r.string,rateLimitedUntil:r.string,rateLimitProtection:r.bool,testStatus:r.string,isActive:r.bool,priority:r.number,lastError:r.string,lastErrorType:r.string,lastErrorSource:r.string,errorCode:r.oneOfType([r.string,r.number]),globalPriority:r.number}).isRequired,isOAuth:r.bool.isRequired,isFirst:r.bool.isRequired,isLast:r.bool.isRequired,onMoveUp:r.func.isRequired,onMoveDown:r.func.isRequired,onToggleActive:r.func.isRequired,onToggleRateLimit:r.func.isRequired,onRetest:r.func.isRequired,isRetesting:r.bool,onEdit:r.func.isRequired,onDelete:r.func.isRequired,onReauth:r.func},N.propTypes={isOpen:r.bool.isRequired,provider:r.string,providerName:r.string,isCompatible:r.bool,isAnthropic:r.bool,onSave:r.func.isRequired,onClose:r.func.isRequired},k.propTypes={isOpen:r.bool.isRequired,connection:r.shape({id:r.string,name:r.string,email:r.string,priority:r.number,authType:r.string,provider:r.string}),onSave:r.func.isRequired,onClose:r.func.isRequired},C.propTypes={isOpen:r.bool.isRequired,node:r.shape({id:r.string,name:r.string,prefix:r.string,apiType:r.string,baseUrl:r.string}),onSave:r.func.isRequired,onClose:r.func.isRequired,isAnthropic:r.bool}},80209:(e,t,i)=>{Promise.resolve().then(i.bind(i,29556))}},e=>{e.O(0,[8500,600,7765,7896,1525,8441,3794,7358],()=>e(e.s=80209)),_N_E=e.O()}]);
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[2134],{29556:(e,t,i)=>{"use strict";i.r(t),i.d(t,{default:()=>u});var s=i(95155),a=i(12115),r=i(14051),l=i(73321),n=i(98500),o=i(5772),d=i(71525),c=i(64745),p=i(18595),m=i(26853);function u(){let e=(0,l.useParams)(),t=(0,l.useRouter)(),i=e.id,[r,u]=(0,a.useState)([]),[f,v]=(0,a.useState)(!0),[g,w]=(0,a.useState)(null),[A,S]=(0,a.useState)(!1),[T,$]=(0,a.useState)(!1),[R,E]=(0,a.useState)(!1),[I,O]=(0,a.useState)(!1),[_,P]=(0,a.useState)(null),[q,U]=(0,a.useState)(null),[D,K]=(0,a.useState)({}),[L,M]=(0,a.useState)(!1),{copied:F,copy:z}=(0,m.C)(),V=(0,a.useRef)(!1),J=(0,a.useRef)(!1),[B,W]=(0,a.useState)(null),[Z,G]=(0,a.useState)(null),[Q,H]=(0,a.useState)(!1),X=g?{id:g.id,name:g.name||("anthropic-compatible"===g.type?"Anthropic Compatible":"OpenAI Compatible"),color:"anthropic-compatible"===g.type?"#D97757":"#10A37F",textIcon:"anthropic-compatible"===g.type?"AC":"OC",apiType:g.apiType,baseUrl:g.baseUrl,type:g.type}:c.IS[i]||c.zN[i]||c.fg[i],Y=!!c.IS[i]||!!c.zN[i],ee=(0,p.KC)(i),et=(0,c.wG)(i),ei=(0,c.mq)(i),es=(0,c.gb)(i),ea=ei||es,er=ea?i:et,el=ea?g?.prefix||i:et,en=(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)}},[]),eo=(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===i);u(e)}if(t.ok){let e=(a.nodes||[]).find(e=>e.id===i)||null;if(!e&&ea)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===i)||null))break}w(e)}}catch(e){console.log("Error fetching connections:",e)}finally{v(!1)}},[i,ea]),ed=async e=>{try{let t=await fetch(`/api/provider-nodes/${i}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),s=await t.json();t.ok&&(w(s.node),await eo(),O(!1))}catch(e){console.log("Error updating provider node:",e)}};(0,a.useEffect)(()=>{eo(),en(),fetch("/api/settings/proxy").then(e=>e.ok?e.json():null).then(e=>G(e)).catch(()=>{})},[eo,en]),(0,a.useEffect)(()=>{f||0!==r.length||!X||ea||V.current||J.current||(V.current=!0,Y?S(!0):$(!0))},[f]);let ec=async(e,t,i=et)=>{let s=`${i}/${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 en();else{let t=await e.json();alert(t.error||"Failed to set alias")}}catch(e){console.log("Error setting alias:",e)}},ep=async e=>{try{(await fetch(`/api/models/alias?alias=${encodeURIComponent(e)}`,{method:"DELETE"})).ok&&await en()}catch(e){console.log("Error deleting alias:",e)}},em=async e=>{if(confirm("Delete this connection?"))try{(await fetch(`/api/providers/${e}`,{method:"DELETE"})).ok&&u(r.filter(t=>t.id!==e))}catch(e){console.log("Error deleting connection:",e)}},eu=(0,a.useCallback)(()=>{eo(),S(!1)},[eo]),ex=async e=>{try{(await fetch("/api/providers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:i,...e})})).ok&&(await eo(),$(!1))}catch(e){console.log("Error saving connection:",e)}},eh=async e=>{try{(await fetch(`/api/providers/${_.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})).ok&&(await eo(),E(!1))}catch(e){console.log("Error updating connection:",e)}},ef=async(e,t)=>{try{(await fetch(`/api/providers/${e}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({isActive:t})})).ok&&u(i=>i.map(i=>i.id===e?{...i,isActive:t}:i))}catch(e){console.log("Error updating connection status:",e)}},ey=async(e,t)=>{try{(await fetch("/api/rate-limit",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({connectionId:e,enabled:t})})).ok&&u(i=>i.map(i=>i.id===e?{...i,rateLimitProtection:t}:i))}catch(e){console.error("Error toggling rate limit:",e)}},eb=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 eo()}catch(e){console.error("Error retesting connection:",e)}finally{U(null)}}},ev=async(e,t)=>{if(e&&t)try{let i=t.priority,s=e.priority;i===s&&(i=r.indexOf(e)>r.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:i})}),fetch(`/api/providers/${t.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({priority:s})})]),await eo()}catch(e){console.log("Error swapping priority:",e)}},eg=async()=>{if(Q)return;let e=r.find(e=>!1!==e.isActive);if(e){H(!0);try{let t=await fetch(`/api/providers/${e.id}/models`),i=await t.json();if(!t.ok)return void alert(i.error||"Failed to import models");let s=i.models||[];if(0===s.length)return void alert("No models returned from /models.");let a=0;for(let e of s){let t=e.id||e.name||e.model;if(!t)continue;let i=t.split("/"),s=i[i.length-1];D[s]||(await ec(t,s,er),a+=1)}0===a&&alert("No new models were added (all already exist)."),await en()}catch(e){console.log("Error importing models:",e)}finally{H(!1)}}},ej=r.some(e=>!1!==e.isActive);return f?(0,s.jsxs)("div",{className:"flex flex-col gap-8",children:[(0,s.jsx)(d.Qv,{}),(0,s.jsx)(d.Qv,{})]}):X?(0,s.jsxs)("div",{className:"flex flex-col gap-8",children:[(0,s.jsxs)("div",{children:[(0,s.jsxs)(n,{href:"/dashboard/providers",className:"inline-flex items-center gap-1 text-sm text-text-muted hover:text-primary transition-colors mb-4",children:[(0,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:`${X.color}15`},children:L?(0,s.jsx)("span",{className:"text-sm font-bold",style:{color:X.color},children:X.textIcon||X.id.slice(0,2).toUpperCase()}):(0,s.jsx)(o.default,{src:ei&&X.apiType?"responses"===X.apiType?"/providers/oai-r.png":"/providers/oai-cc.png":es?"/providers/anthropic-m.png":`/providers/${X.id}.png`,alt:X.name,width:48,height:48,className:"object-contain rounded-lg max-w-[48px] max-h-[48px]",sizes:"48px",onError:()=>M(!0)})}),(0,s.jsxs)("div",{children:[X.website?(0,s.jsxs)("a",{href:X.website,target:"_blank",rel:"noopener noreferrer",className:"text-3xl font-semibold tracking-tight hover:underline inline-flex items-center gap-2",style:{color:X.color},children:[X.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:X.name}),(0,s.jsxs)("p",{className:"text-text-muted",children:[r.length," connection",1===r.length?"":"s"]})]})]})]}),ea&&g&&(0,s.jsxs)(d.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:es?"Anthropic Compatible Details":"OpenAI Compatible Details"}),(0,s.jsxs)("p",{className:"text-sm text-text-muted",children:[es?"Messages API":"responses"===g.apiType?"Responses API":"Chat Completions"," ","\xb7 ",(g.baseUrl||"").replace(/\/$/,""),"/",es?"messages":"responses"===g.apiType?"responses":"chat/completions"]})]}),(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)(d.$n,{size:"sm",icon:"add",onClick:()=>$(!0),disabled:r.length>0,children:"Add"}),(0,s.jsx)(d.$n,{size:"sm",variant:"secondary",icon:"edit",onClick:()=>O(!0),children:"Edit"}),(0,s.jsx)(d.$n,{size:"sm",variant:"secondary",icon:"delete",onClick:async()=>{if(confirm(`Delete this ${es?"Anthropic":"OpenAI"} Compatible node?`))try{(await fetch(`/api/provider-nodes/${i}`,{method:"DELETE"})).ok&&t.push("/dashboard/providers")}catch(e){console.log("Error deleting provider node:",e)}},children:"Delete"})]})]}),r.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)(d.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"}),!ea&&(0,s.jsx)(d.$n,{size:"sm",icon:"add",onClick:()=>Y?S(!0):$(!0),children:"Add"})]}),0===r.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:Y?"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"}),!ea&&(0,s.jsx)(d.$n,{icon:"add",onClick:()=>Y?S(!0):$(!0),children:"Add Connection"})]}):(0,s.jsx)("div",{className:"flex flex-col divide-y divide-black/[0.03] dark:divide-white/[0.03]",children:r.sort((e,t)=>(e.priority||0)-(t.priority||0)).map((e,t)=>(0,s.jsx)(j,{connection:e,isOAuth:Y,isFirst:0===t,isLast:t===r.length-1,onMoveUp:()=>ev(e,r[t-1]),onMoveDown:()=>ev(e,r[t+1]),onToggleActive:t=>ef(e.id,t),onToggleRateLimit:t=>ey(e.id,t),onRetest:()=>eb(e.id),isRetesting:q===e.id,onEdit:()=>{P(e),E(!0)},onDelete:()=>em(e.id),onReauth:Y?()=>S(!0):void 0,onProxy:()=>W({level:"key",id:e.id,label:e.name||e.email||e.id}),hasProxy:!!Z?.keys?.[e.id]},e.id))})]}),(0,s.jsxs)(d.Zp,{children:[(0,s.jsx)("h2",{className:"text-lg font-semibold mb-4",children:X.passthroughModels?"Model Aliases":"Available Models"}),(()=>{if(ea)return(0,s.jsx)(b,{providerStorageAlias:er,providerDisplayAlias:el,modelAliases:D,copied:F,onCopy:z,onSetAlias:ec,onDeleteAlias:ep,connections:r,isAnthropic:es});if(X.passthroughModels)return(0,s.jsx)(h,{providerAlias:et,modelAliases:D,copied:F,onCopy:z,onSetAlias:ec,onDeleteAlias:ep});let e=(0,s.jsxs)("div",{className:"flex items-center gap-2 mb-4",children:[(0,s.jsx)(d.$n,{size:"sm",variant:"secondary",icon:"download",onClick:eg,disabled:!ej||Q,children:Q?"Importing...":"Import from /models"}),!ej&&(0,s.jsx)("span",{className:"text-xs text-text-muted",children:"Add a connection to enable importing."})]});return 0===ee.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:ee.map(e=>{let t=`${er}/${e.id}`,a=`${i}/${e.id}`,r=Object.entries(D).find(([,e])=>e===t||e===a)?.[0];return(0,s.jsx)(x,{model:e,fullModel:`${el}/${e.id}`,alias:r,copied:F,onCopy:z,onSetAlias:t=>ec(e.id,t,er),onDeleteAlias:()=>ep(r)},e.id)})})]})})(),!ea&&(0,s.jsx)(y,{providerId:i,providerAlias:el,copied:F,onCopy:z})]}),"kiro"===i?(0,s.jsx)(d.Mh,{isOpen:A,providerInfo:X,onSuccess:eu,onClose:()=>{J.current=!0,S(!1)}}):"cursor"===i?(0,s.jsx)(d.G9,{isOpen:A,onSuccess:eu,onClose:()=>{J.current=!0,S(!1)}}):(0,s.jsx)(d.LF,{isOpen:A,provider:i,providerInfo:X,onSuccess:eu,onClose:()=>{J.current=!0,S(!1)}}),(0,s.jsx)(N,{isOpen:T,provider:i,providerName:X.name,isCompatible:ea,isAnthropic:es,onSave:ex,onClose:()=>$(!1)}),(0,s.jsx)(k,{isOpen:R,connection:_,onSave:eh,onClose:()=>E(!1)}),ea&&(0,s.jsx)(C,{isOpen:I,node:g,onSave:ed,onClose:()=>O(!1),isAnthropic:es}),B&&(0,s.jsx)(d.KN,{isOpen:!!B,onClose:()=>W(null),level:B.level,levelId:B.id,levelLabel:B.label})]}):(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)(n,{href:"/dashboard/providers",className:"text-primary mt-4 inline-block",children:"Back to Providers"})]})}function x({model:e,fullModel:t,alias:i,copied:a,onCopy:r}){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:()=>r(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 h({providerAlias:e,modelAliases:t,copied:i,onCopy:r,onSetAlias:l,onDeleteAlias:n}){let[o,c]=(0,a.useState)(""),[p,m]=(0,a.useState)(!1),u=Object.entries(t).filter(([,t])=>t.startsWith(`${e}/`)).map(([t,i])=>({modelId:i.replace(`${e}/`,""),fullModel:i,alias:t})),x=async()=>{let e;if(!o.trim()||p)return;let i=o.trim(),s=(e=i.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(i,s),c("")}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:o,onChange:e=>c(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,s.jsx)(d.$n,{size:"sm",icon:"add",onClick:x,disabled:!o.trim()||p,children:p?"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)(f,{modelId:e,fullModel:t,copied:i,onCopy:r,onDeleteAlias:()=>n(a)},t))})]})}function f({modelId:e,fullModel:t,copied:i,onCopy:a,onDeleteAlias:r}){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:i===`model-${e}`?"check":"content_copy"})})]})]}),(0,s.jsx)("button",{onClick:r,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 y({providerId:e,providerAlias:t,copied:i,onCopy:r}){let[l,n]=(0,a.useState)([]),[o,c]=(0,a.useState)(""),[p,m]=(0,a.useState)(""),[u,x]=(0,a.useState)(!1),[h,f]=(0,a.useState)(!0),y=(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)(()=>{y()},[y]);let b=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:p.trim()||void 0})})).ok&&(c(""),m(""),await y())}catch(e){console.error("Failed to add custom model:",e)}finally{x(!1)}}},v=async t=>{try{await fetch(`/api/provider-models?provider=${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:o,onChange:e=>c(e.target.value),onKeyDown:e=>"Enter"===e.key&&b(),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:p,onChange:e=>m(e.target.value),onKeyDown:e=>"Enter"===e.key&&b(),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)(d.$n,{size:"sm",icon:"add",onClick:b,disabled:!o.trim()||u,children:u?"Adding...":"Add"})]}),h?(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:()=>r(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:i===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 b({providerStorageAlias:e,providerDisplayAlias:t,modelAliases:i,copied:r,onCopy:l,onSetAlias:n,onDeleteAlias:o,connections:c,isAnthropic:p}){let[m,u]=(0,a.useState)(""),[x,h]=(0,a.useState)(!1),[y,b]=(0,a.useState)(!1),v=Object.entries(i).filter(([,t])=>t.startsWith(`${e}/`)).map(([t,i])=>({modelId:i.replace(`${e}/`,""),fullModel:i,alias:t})),g=e=>{let s,a=(s=e.split("/"))[s.length-1];if(!i[a])return a;let r=`${t}-${a}`;return i[r]?null:r},j=async()=>{if(!m.trim()||x)return;let t=m.trim(),i=g(t);if(!i)return void alert("All suggested aliases already exist. Please choose a different model or remove conflicting aliases.");h(!0);try{await n(t,i,e),u("")}catch(e){console.log("Error adding model:",e)}finally{h(!1)}},N=async()=>{if(y)return;let t=c.find(e=>!1!==e.isActive);if(t){b(!0);try{let i=await fetch(`/api/providers/${t.id}/models`),s=await i.json();if(!i.ok)return void alert(s.error||"Failed to import models");let a=s.models||[];if(0===a.length)return void alert("No models returned from /models.");let r=0;for(let t of a){let i=t.id||t.name||t.model;if(!i)continue;let s=g(i);s&&(await n(i,s,e),r+=1)}0===r&&alert("No new models were added.")}catch(e){console.log("Error importing models:",e)}finally{b(!1)}}},k=c.some(e=>!1!==e.isActive);return(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,s.jsxs)("p",{className:"text-sm text-text-muted",children:["Add ",p?"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:m,onChange:e=>u(e.target.value),onKeyDown:e=>"Enter"===e.key&&j(),placeholder:p?"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)(d.$n,{size:"sm",icon:"add",onClick:j,disabled:!m.trim()||x,children:x?"Adding...":"Add"}),(0,s.jsx)(d.$n,{size:"sm",variant:"secondary",icon:"download",onClick:N,disabled:!k||y,children:y?"Importing...":"Import from /models"})]}),!k&&(0,s.jsx)("p",{className:"text-xs text-text-muted",children:"Add a connection to enable importing models."}),v.length>0&&(0,s.jsx)("div",{className:"flex flex-col gap-3",children:v.map(({modelId:e,fullModel:i,alias:a})=>(0,s.jsx)(f,{modelId:e,fullModel:`${t}/${e}`,copied:r,onCopy:l,onDeleteAlias:()=>o(a)},i))})]})}function v({until:e}){let[t,i]=(0,a.useState)("");return((0,a.useEffect)(()=>{let t=()=>{let t=new Date(e).getTime()-Date.now();if(t<=0)return void i("");let s=Math.floor(t/1e3);if(s<60)i(`${s}s`);else if(s<3600)i(`${Math.floor(s/60)}m ${s%60}s`);else{let e=Math.floor(s/3600),t=Math.floor(s%3600/60);i(`${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}x.propTypes={model:r.shape({id:r.string.isRequired}).isRequired,fullModel:r.string.isRequired,alias:r.string,copied:r.string,onCopy:r.func.isRequired},h.propTypes={providerAlias:r.string.isRequired,modelAliases:r.object.isRequired,copied:r.string,onCopy:r.func.isRequired,onSetAlias:r.func.isRequired,onDeleteAlias:r.func.isRequired},f.propTypes={modelId:r.string.isRequired,fullModel:r.string.isRequired,copied:r.string,onCopy:r.func.isRequired,onDeleteAlias:r.func.isRequired},y.propTypes={providerId:r.string.isRequired,providerAlias:r.string.isRequired,copied:r.string,onCopy:r.func.isRequired},b.propTypes={providerStorageAlias:r.string.isRequired,providerDisplayAlias:r.string.isRequired,modelAliases:r.object.isRequired,copied:r.string,onCopy:r.func.isRequired,onSetAlias:r.func.isRequired,onDeleteAlias:r.func.isRequired,connections:r.arrayOf(r.shape({id:r.string,isActive:r.bool})).isRequired,isAnthropic:r.bool},v.propTypes={until:r.string.isRequired};let g={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 j({connection:e,isOAuth:t,isFirst:i,isLast:r,onMoveUp:l,onMoveDown:n,onToggleActive:o,onToggleRateLimit:c,onRetest:p,isRetesting:m,onEdit:u,onDelete:x,onReauth:h,onProxy:f,hasProxy:y}){let b=t?e.name||e.email||e.displayName||"OAuth Account":e.name,[j,N]=(0,a.useState)(!1);(0,a.useEffect)(()=>{let t=()=>{N(e.rateLimitedUntil&&new Date(e.rateLimitedUntil).getTime()>Date.now())};t();let i=e.rateLimitedUntil?setInterval(t,1e3):null;return()=>{i&&clearInterval(i)}},[e.rateLimitedUntil]);let k="unavailable"!==e.testStatus||j?e.testStatus:"active",C=function(e,t,i){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 i=Number(e.errorCode);if(401===i||403===i)return"upstream_auth_error";if(429===i)return"upstream_rate_limited";if(i>=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,i),a=s&&g[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,k,j),w=!!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: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_up"})}),(0,s.jsx)("button",{onClick:n,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_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:b}),(0,s.jsxs)("div",{className:"flex items-center gap-2 mt-1 flex-wrap",children:[(0,s.jsx)(d.Ex,{variant:C.statusVariant,size:"sm",dot:!0,children:C.statusLabel}),j&&!1!==e.isActive&&(0,s.jsx)(v,{until:e.rateLimitedUntil}),C.errorBadge&&!1!==e.isActive&&(0,s.jsx)(d.Ex,{variant:C.errorBadge.variant,size:"sm",children:C.errorBadge.label}),e.lastError&&!1!==e.isActive&&(0,s.jsx)("span",{className:`text-xs truncate max-w-[300px] ${C.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:()=>c(!w),className:`inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-xs font-medium transition-all cursor-pointer ${w?"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:w?"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"}),w?"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)(d.$n,{size:"sm",variant:"ghost",icon:"refresh",loading:m,disabled:!1===e.isActive,onClick:p,className:"!h-7 !px-2 text-xs",title:"Retest authentication",children:"Retest"}),(0,s.jsx)(d.lM,{size:"sm",checked:e.isActive??!0,onChange:o,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:[h&&(0,s.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,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:x,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 N({isOpen:e,provider:t,providerName:i,isCompatible:r,isAnthropic:l,onSave:n,onClose:o}){let[c,p]=(0,a.useState)({name:"",apiKey:"",priority:1}),[m,u]=(0,a.useState)(!1),[x,h]=(0,a.useState)(null),[f,y]=(0,a.useState)(!1),b=async()=>{u(!0);try{let e=await fetch("/api/providers/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:t,apiKey:c.apiKey})}),i=await e.json();h(i.valid?"success":"failed")}catch{h("failed")}finally{u(!1)}},v=async()=>{if(t&&c.apiKey){y(!0);try{let e=!1;try{u(!0),h(null);let i=await fetch("/api/providers/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:t,apiKey:c.apiKey})});e=!!(await i.json()).valid,h(e?"success":"failed")}catch{h("failed")}finally{u(!1)}await n({name:c.name,apiKey:c.apiKey,priority:c.priority,testStatus:e?"active":"unknown"})}finally{y(!1)}}};return t?(0,s.jsx)(d.aF,{isOpen:e,title:`Add ${i||t} API Key`,onClose:o,children:(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,s.jsx)(d.pd,{label:"Name",value:c.name,onChange:e=>p({...c,name:e.target.value}),placeholder:"Production Key"}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(d.pd,{label:"API Key",type:"password",value:c.apiKey,onChange:e=>p({...c,apiKey:e.target.value}),className:"flex-1"}),(0,s.jsx)("div",{className:"pt-6",children:(0,s.jsx)(d.$n,{onClick:b,disabled:!c.apiKey||m||f,variant:"secondary",children:m?"Checking...":"Check"})})]}),x&&(0,s.jsx)(d.Ex,{variant:"success"===x?"success":"error",children:"success"===x?"Valid":"Invalid"}),r&&(0,s.jsx)("p",{className:"text-xs text-text-muted",children:l?`Validation checks ${i||"Anthropic Compatible"} by verifying the API key.`:`Validation checks ${i||"OpenAI Compatible"} via /models on your base URL.`}),(0,s.jsx)(d.pd,{label:"Priority",type:"number",value:c.priority,onChange:e=>p({...c,priority:Number.parseInt(e.target.value)||1})}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(d.$n,{onClick:v,fullWidth:!0,disabled:!c.name||!c.apiKey||f,children:f?"Saving...":"Save"}),(0,s.jsx)(d.$n,{onClick:o,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})}):null}function k({isOpen:e,connection:t,onSave:i,onClose:r}){let[l,n]=(0,a.useState)({name:"",priority:1,apiKey:"",healthCheckInterval:60}),[o,p]=(0,a.useState)(!1),[m,u]=(0,a.useState)(null),[x,h]=(0,a.useState)(!1),[f,y]=(0,a.useState)(null),[b,v]=(0,a.useState)(!1);(0,a.useEffect)(()=>{t&&(n({name:t.name||"",priority:t.priority||1,apiKey:"",healthCheckInterval:t.healthCheckInterval??60}),u(null),y(null))},[t]);let j=async()=>{if(t?.provider){p(!0),u(null);try{let e=await fetch(`/api/providers/${t.id}/test`,{method:"POST"}),i=await e.json();u({valid:!!i.valid,diagnosis:i.diagnosis||null,message:i.error||null})}catch{u({valid:!1,diagnosis:{type:"network_error"},message:"Failed to test connection"})}finally{p(!1)}}},N=async()=>{if(t?.provider&&l.apiKey){h(!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})}),i=await e.json();y(i.valid?"success":"failed")}catch{y("failed")}finally{h(!1)}}},k=async()=>{v(!0);try{let e={name:l.name,priority:l.priority,healthCheckInterval:l.healthCheckInterval};if(!C&&l.apiKey){e.apiKey=l.apiKey;let i="success"===f;if(!i)try{h(!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})});i=!!(await e.json()).valid,y(i?"success":"failed")}catch{y("failed")}finally{h(!1)}i&&(e.testStatus="active",e.lastError=null,e.lastErrorAt=null,e.lastErrorType=null,e.lastErrorSource=null,e.errorCode=null,e.rateLimitedUntil=null)}await i(e)}finally{v(!1)}};if(!t)return null;let C="oauth"===t.authType,w=(0,c.mq)(t.provider)||(0,c.gb)(t.provider),A=!m?.valid&&m?.diagnosis?.type&&g[m.diagnosis.type]||null;return(0,s.jsx)(d.aF,{isOpen:e,title:"Edit Connection",onClose:r,children:(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,s.jsx)(d.pd,{label:"Name",value:l.name,onChange:e=>n({...l,name:e.target.value}),placeholder:C?"Account name":"Production Key"}),C&&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})]}),C&&(0,s.jsx)(d.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,s.jsx)(d.pd,{label:"Priority",type:"number",value:l.priority,onChange:e=>n({...l,priority:Number.parseInt(e.target.value)||1})}),!C&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(d.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,s.jsx)("div",{className:"pt-6",children:(0,s.jsx)(d.$n,{onClick:N,disabled:!l.apiKey||x||b,variant:"secondary",children:x?"Checking...":"Check"})})]}),f&&(0,s.jsx)(d.Ex,{variant:"success"===f?"success":"error",children:"success"===f?"Valid":"Invalid"})]}),!w&&(0,s.jsxs)("div",{className:"flex items-center gap-3",children:[(0,s.jsx)(d.$n,{onClick:j,variant:"secondary",disabled:o,children:o?"Testing...":"Test Connection"}),m&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(d.Ex,{variant:m.valid?"success":"error",children:m.valid?"Valid":"Failed"}),A&&(0,s.jsx)(d.Ex,{variant:A.variant,children:A.label})]})]}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(d.$n,{onClick:k,fullWidth:!0,disabled:b,children:b?"Saving...":"Save"}),(0,s.jsx)(d.$n,{onClick:r,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})})}function C({isOpen:e,node:t,onSave:i,onClose:r,isAnthropic:l}){let[n,o]=(0,a.useState)({name:"",prefix:"",apiType:"chat",baseUrl:"https://api.openai.com/v1"}),[c,p]=(0,a.useState)(!1),[m,u]=(0,a.useState)(""),[x,h]=(0,a.useState)(!1),[f,y]=(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 b=async()=>{if(n.name.trim()&&n.prefix.trim()&&n.baseUrl.trim()){p(!0);try{let e={name:n.name,prefix:n.prefix,baseUrl:n.baseUrl};l||(e.apiType=n.apiType),await i(e)}finally{p(!1)}}},v=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:m,type:l?"anthropic-compatible":"openai-compatible"})}),t=await e.json();y(t.valid?"success":"failed")}catch{y("failed")}finally{h(!1)}};return t?(0,s.jsx)(d.aF,{isOpen:e,title:`Edit ${l?"Anthropic":"OpenAI"} Compatible`,onClose:r,children:(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,s.jsx)(d.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,s.jsx)(d.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,s.jsx)(d.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,s.jsx)(d.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,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(d.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)(d.$n,{onClick:v,disabled:!m||x||!n.baseUrl.trim(),variant:"secondary",children:x?"Checking...":"Check"})})]}),f&&(0,s.jsx)(d.Ex,{variant:"success"===f?"success":"error",children:"success"===f?"Valid":"Invalid"}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(d.$n,{onClick:b,fullWidth:!0,disabled:!n.name.trim()||!n.prefix.trim()||!n.baseUrl.trim()||c,children:c?"Saving...":"Save"}),(0,s.jsx)(d.$n,{onClick:r,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})}):null}j.propTypes={connection:r.shape({id:r.string,name:r.string,email:r.string,displayName:r.string,rateLimitedUntil:r.string,rateLimitProtection:r.bool,testStatus:r.string,isActive:r.bool,priority:r.number,lastError:r.string,lastErrorType:r.string,lastErrorSource:r.string,errorCode:r.oneOfType([r.string,r.number]),globalPriority:r.number}).isRequired,isOAuth:r.bool.isRequired,isFirst:r.bool.isRequired,isLast:r.bool.isRequired,onMoveUp:r.func.isRequired,onMoveDown:r.func.isRequired,onToggleActive:r.func.isRequired,onToggleRateLimit:r.func.isRequired,onRetest:r.func.isRequired,isRetesting:r.bool,onEdit:r.func.isRequired,onDelete:r.func.isRequired,onReauth:r.func},N.propTypes={isOpen:r.bool.isRequired,provider:r.string,providerName:r.string,isCompatible:r.bool,isAnthropic:r.bool,onSave:r.func.isRequired,onClose:r.func.isRequired},k.propTypes={isOpen:r.bool.isRequired,connection:r.shape({id:r.string,name:r.string,email:r.string,priority:r.number,authType:r.string,provider:r.string}),onSave:r.func.isRequired,onClose:r.func.isRequired},C.propTypes={isOpen:r.bool.isRequired,node:r.shape({id:r.string,name:r.string,prefix:r.string,apiType:r.string,baseUrl:r.string}),onSave:r.func.isRequired,onClose:r.func.isRequired,isAnthropic:r.bool}},80209:(e,t,i)=>{Promise.resolve().then(i.bind(i,29556))}},e=>{e.O(0,[8500,600,8013,7896,1525,8441,3794,7358],()=>e(e.s=80209)),_N_E=e.O()}]);
@@ -1 +1 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[9089],{28033:(e,r,t)=>{"use strict";t.r(r),t.d(r,{default:()=>p});var a=t(95155),s=t(12115),i=t(73321),l=t(98500),d=t(71525),o=t(81172);let n=Object.values(o.Q2).map(e=>({value:e.id,label:e.name})),c=Object.values(o.MA).map(e=>({value:e.id,label:e.name}));function p(){let e=(0,i.useRouter)(),[r,t]=(0,s.useState)(!1),[p,u]=(0,s.useState)({provider:"",authMethod:"api_key",apiKey:"",displayName:"",isActive:!0}),[h,m]=(0,s.useState)({}),x=(e,r)=>{u(t=>({...t,[e]:r})),h[e]&&m(r=>({...r,[e]:null}))},b=async r=>{let a;if(r.preventDefault(),a={},p.provider||(a.provider="Please select a provider"),"api_key"!==p.authMethod||p.apiKey||(a.apiKey="API Key is required"),m(a),0===Object.keys(a).length){t(!0);try{let r=await fetch("/api/providers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(p)});if(r.ok)e.push("/dashboard/providers");else{let e=await r.json();m({submit:e.error||"Failed to create provider"})}}catch(e){m({submit:"An error occurred. Please try again."})}finally{t(!1)}}},v=o.Q2[p.provider];return(0,a.jsxs)("div",{className:"max-w-2xl mx-auto",children:[(0,a.jsxs)("div",{className:"mb-8",children:[(0,a.jsxs)(l,{href:"/dashboard/providers",className:"inline-flex items-center gap-1 text-sm text-text-muted hover:text-primary transition-colors mb-4",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-lg",children:"arrow_back"}),"Back to Providers"]}),(0,a.jsx)("h1",{className:"text-3xl font-semibold tracking-tight",children:"Add New Provider"}),(0,a.jsx)("p",{className:"text-text-muted mt-2",children:"Configure a new AI provider to use with your applications."})]}),(0,a.jsx)(d.Zp,{children:(0,a.jsxs)("form",{onSubmit:b,className:"flex flex-col gap-6",children:[(0,a.jsx)(d.l6,{label:"Provider",options:n,value:p.provider,onChange:e=>x("provider",e.target.value),placeholder:"Select a provider",error:h.provider,required:!0}),v&&(0,a.jsxs)(d.Zp.Section,{className:"flex items-center gap-3",children:[(0,a.jsx)("div",{className:"size-10 rounded-lg flex items-center justify-center bg-bg border border-border",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-xl",style:{color:v.color},children:v.icon})}),(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"font-medium",children:v.name}),(0,a.jsx)("p",{className:"text-sm text-text-muted",children:"Selected provider"})]})]}),(0,a.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,a.jsxs)("label",{className:"text-sm font-medium",children:["Authentication Method ",(0,a.jsx)("span",{className:"text-red-500",children:"*"})]}),(0,a.jsx)("div",{className:"flex gap-3",children:c.map(e=>(0,a.jsxs)("button",{type:"button",onClick:()=>x("authMethod",e.value),className:`flex-1 flex items-center justify-center gap-2 p-4 rounded-lg border transition-all ${p.authMethod===e.value?"border-primary bg-primary/5 text-primary":"border-border hover:border-primary/50"}`,children:[(0,a.jsx)("span",{className:"material-symbols-outlined",children:"api_key"===e.value?"key":"lock"}),(0,a.jsx)("span",{className:"font-medium",children:e.label})]},e.value))})]}),"api_key"===p.authMethod&&(0,a.jsx)(d.pd,{label:"API Key",type:"password",placeholder:"Enter your API key",value:p.apiKey,onChange:e=>x("apiKey",e.target.value),error:h.apiKey,hint:"Your API key will be encrypted and stored securely.",required:!0}),"oauth2"===p.authMethod&&(0,a.jsxs)(d.Zp.Section,{children:[(0,a.jsx)("p",{className:"text-sm text-text-muted mb-4",children:"Connect your account using OAuth2 authentication."}),(0,a.jsx)(d.$n,{type:"button",variant:"secondary",icon:"link",children:"Connect with OAuth2"})]}),(0,a.jsx)(d.pd,{label:"Display Name",placeholder:"e.g., Production API, Dev Environment",value:p.displayName,onChange:e=>x("displayName",e.target.value),hint:"Optional. A friendly name to identify this configuration."}),(0,a.jsx)(d.lM,{checked:p.isActive,onChange:e=>x("isActive",e),label:"Active",description:"Enable this provider for use in your applications"}),h.submit&&(0,a.jsx)("div",{className:"p-4 rounded-lg bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 text-red-600 dark:text-red-400 text-sm",children:h.submit}),(0,a.jsxs)("div",{className:"flex gap-3 pt-4 border-t border-border",children:[(0,a.jsx)(l,{href:"/dashboard/providers",className:"flex-1",children:(0,a.jsx)(d.$n,{type:"button",variant:"ghost",fullWidth:!0,children:"Cancel"})}),(0,a.jsx)(d.$n,{type:"submit",loading:r,fullWidth:!0,className:"flex-1",children:"Create Provider"})]})]})})]})}},52914:(e,r,t)=>{Promise.resolve().then(t.bind(t,28033))}},e=>{e.O(0,[8500,600,7765,7896,1525,8441,3794,7358],()=>e(e.s=52914)),_N_E=e.O()}]);
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[9089],{28033:(e,r,t)=>{"use strict";t.r(r),t.d(r,{default:()=>p});var a=t(95155),s=t(12115),i=t(73321),l=t(98500),d=t(71525),o=t(81172);let n=Object.values(o.Q2).map(e=>({value:e.id,label:e.name})),c=Object.values(o.MA).map(e=>({value:e.id,label:e.name}));function p(){let e=(0,i.useRouter)(),[r,t]=(0,s.useState)(!1),[p,u]=(0,s.useState)({provider:"",authMethod:"api_key",apiKey:"",displayName:"",isActive:!0}),[h,m]=(0,s.useState)({}),x=(e,r)=>{u(t=>({...t,[e]:r})),h[e]&&m(r=>({...r,[e]:null}))},b=async r=>{let a;if(r.preventDefault(),a={},p.provider||(a.provider="Please select a provider"),"api_key"!==p.authMethod||p.apiKey||(a.apiKey="API Key is required"),m(a),0===Object.keys(a).length){t(!0);try{let r=await fetch("/api/providers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(p)});if(r.ok)e.push("/dashboard/providers");else{let e=await r.json();m({submit:e.error||"Failed to create provider"})}}catch(e){m({submit:"An error occurred. Please try again."})}finally{t(!1)}}},v=o.Q2[p.provider];return(0,a.jsxs)("div",{className:"max-w-2xl mx-auto",children:[(0,a.jsxs)("div",{className:"mb-8",children:[(0,a.jsxs)(l,{href:"/dashboard/providers",className:"inline-flex items-center gap-1 text-sm text-text-muted hover:text-primary transition-colors mb-4",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-lg",children:"arrow_back"}),"Back to Providers"]}),(0,a.jsx)("h1",{className:"text-3xl font-semibold tracking-tight",children:"Add New Provider"}),(0,a.jsx)("p",{className:"text-text-muted mt-2",children:"Configure a new AI provider to use with your applications."})]}),(0,a.jsx)(d.Zp,{children:(0,a.jsxs)("form",{onSubmit:b,className:"flex flex-col gap-6",children:[(0,a.jsx)(d.l6,{label:"Provider",options:n,value:p.provider,onChange:e=>x("provider",e.target.value),placeholder:"Select a provider",error:h.provider,required:!0}),v&&(0,a.jsxs)(d.Zp.Section,{className:"flex items-center gap-3",children:[(0,a.jsx)("div",{className:"size-10 rounded-lg flex items-center justify-center bg-bg border border-border",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-xl",style:{color:v.color},children:v.icon})}),(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"font-medium",children:v.name}),(0,a.jsx)("p",{className:"text-sm text-text-muted",children:"Selected provider"})]})]}),(0,a.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,a.jsxs)("label",{className:"text-sm font-medium",children:["Authentication Method ",(0,a.jsx)("span",{className:"text-red-500",children:"*"})]}),(0,a.jsx)("div",{className:"flex gap-3",children:c.map(e=>(0,a.jsxs)("button",{type:"button",onClick:()=>x("authMethod",e.value),className:`flex-1 flex items-center justify-center gap-2 p-4 rounded-lg border transition-all ${p.authMethod===e.value?"border-primary bg-primary/5 text-primary":"border-border hover:border-primary/50"}`,children:[(0,a.jsx)("span",{className:"material-symbols-outlined",children:"api_key"===e.value?"key":"lock"}),(0,a.jsx)("span",{className:"font-medium",children:e.label})]},e.value))})]}),"api_key"===p.authMethod&&(0,a.jsx)(d.pd,{label:"API Key",type:"password",placeholder:"Enter your API key",value:p.apiKey,onChange:e=>x("apiKey",e.target.value),error:h.apiKey,hint:"Your API key will be encrypted and stored securely.",required:!0}),"oauth2"===p.authMethod&&(0,a.jsxs)(d.Zp.Section,{children:[(0,a.jsx)("p",{className:"text-sm text-text-muted mb-4",children:"Connect your account using OAuth2 authentication."}),(0,a.jsx)(d.$n,{type:"button",variant:"secondary",icon:"link",children:"Connect with OAuth2"})]}),(0,a.jsx)(d.pd,{label:"Display Name",placeholder:"e.g., Production API, Dev Environment",value:p.displayName,onChange:e=>x("displayName",e.target.value),hint:"Optional. A friendly name to identify this configuration."}),(0,a.jsx)(d.lM,{checked:p.isActive,onChange:e=>x("isActive",e),label:"Active",description:"Enable this provider for use in your applications"}),h.submit&&(0,a.jsx)("div",{className:"p-4 rounded-lg bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 text-red-600 dark:text-red-400 text-sm",children:h.submit}),(0,a.jsxs)("div",{className:"flex gap-3 pt-4 border-t border-border",children:[(0,a.jsx)(l,{href:"/dashboard/providers",className:"flex-1",children:(0,a.jsx)(d.$n,{type:"button",variant:"ghost",fullWidth:!0,children:"Cancel"})}),(0,a.jsx)(d.$n,{type:"submit",loading:r,fullWidth:!0,className:"flex-1",children:"Create Provider"})]})]})})]})}},52914:(e,r,t)=>{Promise.resolve().then(t.bind(t,28033))}},e=>{e.O(0,[8500,600,8013,7896,1525,8441,3794,7358],()=>e(e.s=52914)),_N_E=e.O()}]);
@@ -1 +1 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[8460],{11200:(e,t,r)=>{"use strict";r.r(t),r.d(t,{default:()=>m});var s=r(95155),a=r(12115),i=r(5772),l=r(14051),n=r(71525),o=r(81172),d=r(64745),c=r(98500);function p(e,t,r){let a=[];if(e>0&&a.push((0,s.jsxs)(n.Ex,{variant:"success",size:"sm",dot:!0,children:[e," Connected"]},"connected")),t>0){let e=r?`${t} Error (${r})`:`${t} Error`;a.push((0,s.jsx)(n.Ex,{variant:"error",size:"sm",dot:!0,children:e},"error"))}return 0===a.length?(0,s.jsx)("span",{className:"text-text-muted",children:"No connections"}):a}function m(){let[e,t]=(0,a.useState)([]),[r,i]=(0,a.useState)([]),[l,c]=(0,a.useState)(!0),[p,m]=(0,a.useState)(!1),[g,v]=(0,a.useState)(!1),[y,j]=(0,a.useState)(null),[N,C]=(0,a.useState)(null);(0,a.useEffect)(()=>{(async()=>{try{let[e,r]=await Promise.all([fetch("/api/providers"),fetch("/api/provider-nodes")]),s=await e.json(),a=await r.json();e.ok&&t(s.connections||[]),r.ok&&i(a.nodes||[])}catch(e){console.log("Error fetching data:",e)}finally{c(!1)}})()},[]);let k=(t,r)=>{let s=e.filter(e=>e.provider===t&&e.authType===r),a=e=>{let t=e.rateLimitedUntil&&new Date(e.rateLimitedUntil).getTime()>Date.now();return"unavailable"!==e.testStatus||t?e.testStatus:"active"},i=s.filter(e=>{let t=a(e);return"active"===t||"success"===t}).length,l=s.filter(e=>{let t=a(e);return"error"===t||"expired"===t||"unavailable"===t}),n=l.length,o=s.length,d=l.sort((e,t)=>new Date(t.lastErrorAt||0)-new Date(e.lastErrorAt||0))[0];return{connected:i,error:n,total:o,errorCode:d?function(e){if(!e)return null;let t=e.lastErrorType;if("runtime_error"===t)return"RUNTIME";if("upstream_auth_error"===t||"auth_missing"===t||"token_refresh_failed"===t||"token_expired"===t)return"AUTH";if("upstream_rate_limited"===t)return"429";if("upstream_unavailable"===t)return"5XX";if("network_error"===t)return"NET";let r=Number(e.errorCode);if(Number.isFinite(r)&&r>=400)return String(r);let s=function(e){if(!e)return null;let t=e.match(/\b([45]\d{2})\b/);return t?t[1]:"ERR"}(e.lastError);if("401"===s||"403"===s)return"AUTH";if(s&&"ERR"!==s)return s;let a=(e.lastError||"").toLowerCase();return a.includes("runtime")||a.includes("not runnable")||a.includes("not installed")?"RUNTIME":a.includes("invalid api key")||a.includes("token invalid")||a.includes("revoked")||a.includes("unauthorized")?"AUTH":"ERR"}(d):null,errorTime:d?.lastErrorAt?function(e){if(!e)return"";let t=Math.floor((Date.now()-new Date(e).getTime())/6e4);if(t<1)return"just now";if(t<60)return`${t}m ago`;let r=Math.floor(t/60);if(r<24)return`${r}h ago`;let s=Math.floor(r/24);return`${s}d ago`}(d.lastErrorAt):null}},T=async(e,t=null)=>{if(!y){j("provider"===e?t:e),C(null);try{let r=await fetch("/api/providers/test-batch",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mode:e,providerId:t})}),s=await r.json();C(s)}catch(e){C({error:"Test request failed"})}finally{j(null)}}},w=r.filter(e=>"openai-compatible"===e.type).map(e=>({id:e.id,name:e.name||"OpenAI Compatible",color:"#10A37F",textIcon:"OC",apiType:e.apiType})),A=r.filter(e=>"anthropic-compatible"===e.type).map(e=>({id:e.id,name:e.name||"Anthropic Compatible",color:"#D97757",textIcon:"AC"}));return l?(0,s.jsxs)("div",{className:"flex flex-col gap-8",children:[(0,s.jsx)(n.Qv,{}),(0,s.jsx)(n.Qv,{})]}):(0,s.jsxs)("div",{className:"flex flex-col gap-6",children:[(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between",children:[(0,s.jsx)("h2",{className:"text-xl font-semibold",children:"OAuth Providers"}),(0,s.jsxs)("button",{onClick:()=>T("oauth"),disabled:!!y,className:`flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-xs font-medium border transition-colors ${"oauth"===y?"bg-primary/20 border-primary/40 text-primary animate-pulse":"bg-bg-subtle border-border text-text-muted hover:text-text-primary hover:border-primary/40"}`,title:"Test all OAuth connections",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"oauth"===y?"sync":"play_arrow"}),"oauth"===y?"Testing...":"Test All"]})]}),(0,s.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4",children:Object.entries(o.zN).map(([e,t])=>(0,s.jsx)(x,{providerId:e,provider:t,stats:k(e,"oauth")},e))})]}),(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between",children:[(0,s.jsx)("h2",{className:"text-xl font-semibold",children:"Free Providers"}),(0,s.jsxs)("button",{onClick:()=>T("free"),disabled:!!y,className:`flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-xs font-medium border transition-colors ${"free"===y?"bg-primary/20 border-primary/40 text-primary animate-pulse":"bg-bg-subtle border-border text-text-muted hover:text-text-primary hover:border-primary/40"}`,title:"Test all Free connections",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"free"===y?"sync":"play_arrow"}),"free"===y?"Testing...":"Test All"]})]}),(0,s.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4",children:Object.entries(d.IS).map(([e,t])=>(0,s.jsx)(x,{providerId:e,provider:t,stats:k(e,"oauth")},e))})]}),(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between",children:[(0,s.jsx)("h2",{className:"text-xl font-semibold",children:"API Key Providers"}),(0,s.jsxs)("button",{onClick:()=>T("apikey"),disabled:!!y,className:`flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-xs font-medium border transition-colors ${"apikey"===y?"bg-primary/20 border-primary/40 text-primary animate-pulse":"bg-bg-subtle border-border text-text-muted hover:text-text-primary hover:border-primary/40"}`,title:"Test all API Key connections",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"apikey"===y?"sync":"play_arrow"}),"apikey"===y?"Testing...":"Test All"]})]}),(0,s.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4",children:Object.entries(o.fg).map(([e,t])=>(0,s.jsx)(u,{providerId:e,provider:t,stats:k(e,"apikey")},e))})]}),(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between",children:[(0,s.jsx)("h2",{className:"text-xl font-semibold",children:"API Key Compatible Providers"}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(w.length>0||A.length>0)&&(0,s.jsxs)("button",{onClick:()=>T("compatible"),disabled:!!y,className:`flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-xs font-medium border transition-colors ${"compatible"===y?"bg-primary/20 border-primary/40 text-primary animate-pulse":"bg-bg-subtle border-border text-text-muted hover:text-text-primary hover:border-primary/40"}`,title:"Test all Compatible connections",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"compatible"===y?"sync":"play_arrow"}),"compatible"===y?"Testing...":"Test All"]}),(0,s.jsx)(n.$n,{size:"sm",icon:"add",onClick:()=>v(!0),children:"Add Anthropic Compatible"}),(0,s.jsx)(n.$n,{size:"sm",variant:"secondary",icon:"add",onClick:()=>m(!0),className:"!bg-white !text-black hover:!bg-gray-100",children:"Add OpenAI Compatible"})]})]}),0===w.length&&0===A.length?(0,s.jsxs)("div",{className:"text-center py-8 border border-dashed border-border rounded-xl",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-[32px] text-text-muted mb-2",children:"extension"}),(0,s.jsx)("p",{className:"text-text-muted text-sm",children:"No compatible providers added yet"}),(0,s.jsx)("p",{className:"text-text-muted text-xs mt-1",children:"Use the buttons above to add OpenAI or Anthropic compatible endpoints"})]}):(0,s.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4",children:[...w,...A].map(e=>(0,s.jsx)(u,{providerId:e.id,provider:e,stats:k(e.id,"apikey")},e.id))})]}),(0,s.jsx)(h,{isOpen:p,onClose:()=>m(!1),onCreated:e=>{i(t=>[...t,e]),m(!1)}}),(0,s.jsx)(b,{isOpen:g,onClose:()=>v(!1),onCreated:e=>{i(t=>[...t,e]),v(!1)}}),N&&(0,s.jsxs)("div",{className:"fixed inset-0 z-50 flex items-start justify-center pt-[10vh]",onClick:()=>C(null),children:[(0,s.jsx)("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm"}),(0,s.jsxs)("div",{className:"relative bg-bg-primary border border-border rounded-xl w-full max-w-[600px] max-h-[80vh] overflow-y-auto shadow-2xl",onClick:e=>e.stopPropagation(),children:[(0,s.jsxs)("div",{className:"sticky top-0 z-10 flex items-center justify-between px-5 py-3 border-b border-border bg-bg-primary/95 backdrop-blur-sm rounded-t-xl",children:[(0,s.jsx)("h3",{className:"font-semibold",children:"Test Results"}),(0,s.jsx)("button",{onClick:()=>C(null),className:"p-1 rounded-lg hover:bg-bg-subtle text-text-muted hover:text-text-primary transition-colors",children:(0,s.jsx)("span",{className:"material-symbols-outlined text-lg",children:"close"})})]}),(0,s.jsx)("div",{className:"p-5",children:(0,s.jsx)(f,{results:N})})]})]})]})}function x({providerId:e,provider:t,stats:r}){let{connected:l,error:o,errorCode:d,errorTime:m}=r,[x,u]=(0,a.useState)(!1);return(0,s.jsx)(c,{href:`/dashboard/providers/${e}`,className:"group",children:(0,s.jsx)(n.Zp,{padding:"xs",className:"h-full hover:bg-black/[0.01] dark:hover:bg-white/[0.01] transition-colors cursor-pointer",children:(0,s.jsxs)("div",{className:"flex items-center justify-between",children:[(0,s.jsxs)("div",{className:"flex items-center gap-3",children:[(0,s.jsx)("div",{className:"size-8 rounded-lg flex items-center justify-center",style:{backgroundColor:`${t.color}15`},children:x?(0,s.jsx)("span",{className:"text-xs font-bold",style:{color:t.color},children:t.textIcon||t.id.slice(0,2).toUpperCase()}):(0,s.jsx)(i.default,{src:`/providers/${t.id}.png`,alt:t.name,width:30,height:30,className:"object-contain rounded-lg max-w-[32px] max-h-[32px]",sizes:"32px",onError:()=>u(!0)})}),(0,s.jsxs)("div",{children:[(0,s.jsx)("h3",{className:"font-semibold",children:t.name}),(0,s.jsxs)("div",{className:"flex items-center gap-2 text-xs flex-wrap",children:[p(l,o,d),m&&(0,s.jsxs)("span",{className:"text-text-muted",children:["• ",m]})]})]})]}),(0,s.jsx)("span",{className:"material-symbols-outlined text-text-muted opacity-0 group-hover:opacity-100 transition-opacity",children:"chevron_right"})]})})})}function u({providerId:e,provider:t,stats:r}){let{connected:l,error:o,errorCode:m,errorTime:x}=r,u=e.startsWith(d.JH),h=e.startsWith(d.DI),[b,f]=(0,a.useState)(!1);return(0,s.jsx)(c,{href:`/dashboard/providers/${e}`,className:"group",children:(0,s.jsx)(n.Zp,{padding:"xs",className:"h-full hover:bg-black/[0.01] dark:hover:bg-white/[0.01] transition-colors cursor-pointer",children:(0,s.jsxs)("div",{className:"flex items-center justify-between",children:[(0,s.jsxs)("div",{className:"flex items-center gap-3",children:[(0,s.jsx)("div",{className:"size-8 rounded-lg flex items-center justify-center",style:{backgroundColor:`${t.color}15`},children:b?(0,s.jsx)("span",{className:"text-xs font-bold",style:{color:t.color},children:t.textIcon||t.id.slice(0,2).toUpperCase()}):(0,s.jsx)(i.default,{src:u?"responses"===t.apiType?"/providers/oai-r.png":"/providers/oai-cc.png":h?"/providers/anthropic-m.png":`/providers/${t.id}.png`,alt:t.name,width:30,height:30,className:"object-contain rounded-lg max-w-[30px] max-h-[30px]",sizes:"30px",onError:()=>f(!0)})}),(0,s.jsxs)("div",{children:[(0,s.jsx)("h3",{className:"font-semibold",children:t.name}),(0,s.jsxs)("div",{className:"flex items-center gap-2 text-xs flex-wrap",children:[p(l,o,m),u&&(0,s.jsx)(n.Ex,{variant:"default",size:"sm",children:"responses"===t.apiType?"Responses":"Chat"}),h&&(0,s.jsx)(n.Ex,{variant:"default",size:"sm",children:"Messages"}),x&&(0,s.jsxs)("span",{className:"text-text-muted",children:["• ",x]})]})]})]}),(0,s.jsx)("span",{className:"material-symbols-outlined text-text-muted opacity-0 group-hover:opacity-100 transition-opacity",children:"chevron_right"})]})})})}function h({isOpen:e,onClose:t,onCreated:r}){let[i,l]=(0,a.useState)({name:"",prefix:"",apiType:"chat",baseUrl:"https://api.openai.com/v1"}),[o,d]=(0,a.useState)(!1),[c,p]=(0,a.useState)(""),[m,x]=(0,a.useState)(!1),[u,h]=(0,a.useState)(null);(0,a.useEffect)(()=>{l(e=>({...e,baseUrl:"https://api.openai.com/v1"}))},[i.apiType]);let b=async()=>{if(i.name.trim()&&i.prefix.trim()&&i.baseUrl.trim()){d(!0);try{let e=await fetch("/api/provider-nodes",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:i.name,prefix:i.prefix,apiType:i.apiType,baseUrl:i.baseUrl,type:"openai-compatible"})}),t=await e.json();e.ok&&(r(t.node),l({name:"",prefix:"",apiType:"chat",baseUrl:"https://api.openai.com/v1"}),p(""),h(null))}catch(e){console.log("Error creating OpenAI Compatible node:",e)}finally{d(!1)}}},f=async()=>{x(!0);try{let e=await fetch("/api/provider-nodes/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:i.baseUrl,apiKey:c,type:"openai-compatible"})}),t=await e.json();h(t.valid?"success":"failed")}catch{h("failed")}finally{x(!1)}};return(0,s.jsx)(n.aF,{isOpen:e,title:"Add OpenAI Compatible",onClose:t,children:(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,s.jsx)(n.pd,{label:"Name",value:i.name,onChange:e=>l({...i,name:e.target.value}),placeholder:"OpenAI Compatible (Prod)",hint:"Required. A friendly label for this node."}),(0,s.jsx)(n.pd,{label:"Prefix",value:i.prefix,onChange:e=>l({...i,prefix:e.target.value}),placeholder:"oc-prod",hint:"Required. Used as the provider prefix for model IDs."}),(0,s.jsx)(n.l6,{label:"API Type",options:[{value:"chat",label:"Chat Completions"},{value:"responses",label:"Responses API"}],value:i.apiType,onChange:e=>l({...i,apiType:e.target.value})}),(0,s.jsx)(n.pd,{label:"Base URL",value:i.baseUrl,onChange:e=>l({...i,baseUrl:e.target.value}),placeholder:"https://api.openai.com/v1",hint:"Use the base URL (ending in /v1) for your OpenAI-compatible API."}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(n.pd,{label:"API Key (for Check)",type:"password",value:c,onChange:e=>p(e.target.value),className:"flex-1"}),(0,s.jsx)("div",{className:"pt-6",children:(0,s.jsx)(n.$n,{onClick:f,disabled:!c||m||!i.baseUrl.trim(),variant:"secondary",children:m?"Checking...":"Check"})})]}),u&&(0,s.jsx)(n.Ex,{variant:"success"===u?"success":"error",children:"success"===u?"Valid":"Invalid"}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(n.$n,{onClick:b,fullWidth:!0,disabled:!i.name.trim()||!i.prefix.trim()||!i.baseUrl.trim()||o,children:o?"Creating...":"Create"}),(0,s.jsx)(n.$n,{onClick:t,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})})}function b({isOpen:e,onClose:t,onCreated:r}){let[i,l]=(0,a.useState)({name:"",prefix:"",baseUrl:"https://api.anthropic.com/v1"}),[o,d]=(0,a.useState)(!1),[c,p]=(0,a.useState)(""),[m,x]=(0,a.useState)(!1),[u,h]=(0,a.useState)(null);(0,a.useEffect)(()=>{e&&(h(null),p(""))},[e]);let b=async()=>{if(i.name.trim()&&i.prefix.trim()&&i.baseUrl.trim()){d(!0);try{let e=await fetch("/api/provider-nodes",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:i.name,prefix:i.prefix,baseUrl:i.baseUrl,type:"anthropic-compatible"})}),t=await e.json();e.ok&&(r(t.node),l({name:"",prefix:"",baseUrl:"https://api.anthropic.com/v1"}),p(""),h(null))}catch(e){console.log("Error creating Anthropic Compatible node:",e)}finally{d(!1)}}},f=async()=>{x(!0);try{let e=await fetch("/api/provider-nodes/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:i.baseUrl,apiKey:c,type:"anthropic-compatible"})}),t=await e.json();h(t.valid?"success":"failed")}catch{h("failed")}finally{x(!1)}};return(0,s.jsx)(n.aF,{isOpen:e,title:"Add Anthropic Compatible",onClose:t,children:(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,s.jsx)(n.pd,{label:"Name",value:i.name,onChange:e=>l({...i,name:e.target.value}),placeholder:"Anthropic Compatible (Prod)",hint:"Required. A friendly label for this node."}),(0,s.jsx)(n.pd,{label:"Prefix",value:i.prefix,onChange:e=>l({...i,prefix:e.target.value}),placeholder:"ac-prod",hint:"Required. Used as the provider prefix for model IDs."}),(0,s.jsx)(n.pd,{label:"Base URL",value:i.baseUrl,onChange:e=>l({...i,baseUrl:e.target.value}),placeholder:"https://api.anthropic.com/v1",hint:"Use the base URL (ending in /v1) for your Anthropic-compatible API. The system will append /messages."}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(n.pd,{label:"API Key (for Check)",type:"password",value:c,onChange:e=>p(e.target.value),className:"flex-1"}),(0,s.jsx)("div",{className:"pt-6",children:(0,s.jsx)(n.$n,{onClick:f,disabled:!c||m||!i.baseUrl.trim(),variant:"secondary",children:m?"Checking...":"Check"})})]}),u&&(0,s.jsx)(n.Ex,{variant:"success"===u?"success":"error",children:"success"===u?"Valid":"Invalid"}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(n.$n,{onClick:b,fullWidth:!0,disabled:!i.name.trim()||!i.prefix.trim()||!i.baseUrl.trim()||o,children:o?"Creating...":"Create"}),(0,s.jsx)(n.$n,{onClick:t,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})})}function f({results:e}){if(e.error&&!e.results)return(0,s.jsxs)("div",{className:"text-center py-6",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-red-500 text-[32px] mb-2 block",children:"error"}),(0,s.jsx)("p",{className:"text-sm text-red-400",children:e.error})]});let{summary:t,mode:r}=e,a=e.results||[];return(0,s.jsxs)("div",{className:"flex flex-col gap-3",children:[t&&(0,s.jsxs)("div",{className:"flex items-center gap-3 text-xs mb-1",children:[(0,s.jsxs)("span",{className:"text-text-muted",children:[{oauth:"OAuth",free:"Free",apikey:"API Key",provider:"Provider",all:"All"}[r]||r," Test"]}),(0,s.jsxs)("span",{className:"px-2 py-0.5 rounded bg-emerald-500/15 text-emerald-400 font-medium",children:[t.passed," passed"]}),t.failed>0&&(0,s.jsxs)("span",{className:"px-2 py-0.5 rounded bg-red-500/15 text-red-400 font-medium",children:[t.failed," failed"]}),(0,s.jsxs)("span",{className:"text-text-muted ml-auto",children:[t.total," tested"]})]}),a.map((e,t)=>(0,s.jsxs)("div",{className:"flex items-center gap-2 text-xs px-3 py-2 rounded-lg bg-black/[0.03] dark:bg-white/[0.03]",children:[(0,s.jsx)("span",{className:`material-symbols-outlined text-[16px] ${e.valid?"text-emerald-500":"text-red-500"}`,children:e.valid?"check_circle":"error"}),(0,s.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,s.jsx)("span",{className:"font-medium",children:e.connectionName}),(0,s.jsxs)("span",{className:"text-text-muted ml-1.5",children:["(",e.provider,")"]})]}),void 0!==e.latencyMs&&(0,s.jsxs)("span",{className:"text-text-muted font-mono tabular-nums",children:[e.latencyMs,"ms"]}),(0,s.jsx)("span",{className:`text-[10px] uppercase font-bold px-1.5 py-0.5 rounded ${e.valid?"bg-emerald-500/15 text-emerald-400":"bg-red-500/15 text-red-400"}`,children:e.valid?"OK":e.diagnosis?.type||"ERROR"})]},e.connectionId||t)),0===a.length&&(0,s.jsx)("div",{className:"text-center py-4 text-text-muted text-sm",children:"No active connections found for this group."})]})}x.propTypes={providerId:l.string.isRequired,provider:l.shape({id:l.string.isRequired,name:l.string.isRequired,color:l.string,textIcon:l.string}).isRequired,stats:l.shape({connected:l.number,error:l.number,errorCode:l.string,errorTime:l.string}).isRequired},u.propTypes={providerId:l.string.isRequired,provider:l.shape({id:l.string.isRequired,name:l.string.isRequired,color:l.string,textIcon:l.string,apiType:l.string}).isRequired,stats:l.shape({connected:l.number,error:l.number,errorCode:l.string,errorTime:l.string}).isRequired},h.propTypes={isOpen:l.bool.isRequired,onClose:l.func.isRequired,onCreated:l.func.isRequired},b.propTypes={isOpen:l.bool.isRequired,onClose:l.func.isRequired,onCreated:l.func.isRequired},f.propTypes={results:l.shape({mode:l.string,results:l.array,summary:l.shape({total:l.number,passed:l.number,failed:l.number}),error:l.string}).isRequired}},96105:(e,t,r)=>{Promise.resolve().then(r.bind(r,11200))}},e=>{e.O(0,[8500,600,7765,7896,1525,8441,3794,7358],()=>e(e.s=96105)),_N_E=e.O()}]);
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[8460],{11200:(e,t,r)=>{"use strict";r.r(t),r.d(t,{default:()=>m});var s=r(95155),a=r(12115),i=r(5772),l=r(14051),n=r(71525),o=r(81172),d=r(64745),c=r(98500);function p(e,t,r){let a=[];if(e>0&&a.push((0,s.jsxs)(n.Ex,{variant:"success",size:"sm",dot:!0,children:[e," Connected"]},"connected")),t>0){let e=r?`${t} Error (${r})`:`${t} Error`;a.push((0,s.jsx)(n.Ex,{variant:"error",size:"sm",dot:!0,children:e},"error"))}return 0===a.length?(0,s.jsx)("span",{className:"text-text-muted",children:"No connections"}):a}function m(){let[e,t]=(0,a.useState)([]),[r,i]=(0,a.useState)([]),[l,c]=(0,a.useState)(!0),[p,m]=(0,a.useState)(!1),[g,v]=(0,a.useState)(!1),[y,j]=(0,a.useState)(null),[N,C]=(0,a.useState)(null);(0,a.useEffect)(()=>{(async()=>{try{let[e,r]=await Promise.all([fetch("/api/providers"),fetch("/api/provider-nodes")]),s=await e.json(),a=await r.json();e.ok&&t(s.connections||[]),r.ok&&i(a.nodes||[])}catch(e){console.log("Error fetching data:",e)}finally{c(!1)}})()},[]);let k=(t,r)=>{let s=e.filter(e=>e.provider===t&&e.authType===r),a=e=>{let t=e.rateLimitedUntil&&new Date(e.rateLimitedUntil).getTime()>Date.now();return"unavailable"!==e.testStatus||t?e.testStatus:"active"},i=s.filter(e=>{let t=a(e);return"active"===t||"success"===t}).length,l=s.filter(e=>{let t=a(e);return"error"===t||"expired"===t||"unavailable"===t}),n=l.length,o=s.length,d=l.sort((e,t)=>new Date(t.lastErrorAt||0)-new Date(e.lastErrorAt||0))[0];return{connected:i,error:n,total:o,errorCode:d?function(e){if(!e)return null;let t=e.lastErrorType;if("runtime_error"===t)return"RUNTIME";if("upstream_auth_error"===t||"auth_missing"===t||"token_refresh_failed"===t||"token_expired"===t)return"AUTH";if("upstream_rate_limited"===t)return"429";if("upstream_unavailable"===t)return"5XX";if("network_error"===t)return"NET";let r=Number(e.errorCode);if(Number.isFinite(r)&&r>=400)return String(r);let s=function(e){if(!e)return null;let t=e.match(/\b([45]\d{2})\b/);return t?t[1]:"ERR"}(e.lastError);if("401"===s||"403"===s)return"AUTH";if(s&&"ERR"!==s)return s;let a=(e.lastError||"").toLowerCase();return a.includes("runtime")||a.includes("not runnable")||a.includes("not installed")?"RUNTIME":a.includes("invalid api key")||a.includes("token invalid")||a.includes("revoked")||a.includes("unauthorized")?"AUTH":"ERR"}(d):null,errorTime:d?.lastErrorAt?function(e){if(!e)return"";let t=Math.floor((Date.now()-new Date(e).getTime())/6e4);if(t<1)return"just now";if(t<60)return`${t}m ago`;let r=Math.floor(t/60);if(r<24)return`${r}h ago`;let s=Math.floor(r/24);return`${s}d ago`}(d.lastErrorAt):null}},T=async(e,t=null)=>{if(!y){j("provider"===e?t:e),C(null);try{let r=await fetch("/api/providers/test-batch",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mode:e,providerId:t})}),s=await r.json();C(s)}catch(e){C({error:"Test request failed"})}finally{j(null)}}},w=r.filter(e=>"openai-compatible"===e.type).map(e=>({id:e.id,name:e.name||"OpenAI Compatible",color:"#10A37F",textIcon:"OC",apiType:e.apiType})),A=r.filter(e=>"anthropic-compatible"===e.type).map(e=>({id:e.id,name:e.name||"Anthropic Compatible",color:"#D97757",textIcon:"AC"}));return l?(0,s.jsxs)("div",{className:"flex flex-col gap-8",children:[(0,s.jsx)(n.Qv,{}),(0,s.jsx)(n.Qv,{})]}):(0,s.jsxs)("div",{className:"flex flex-col gap-6",children:[(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between",children:[(0,s.jsx)("h2",{className:"text-xl font-semibold",children:"OAuth Providers"}),(0,s.jsxs)("button",{onClick:()=>T("oauth"),disabled:!!y,className:`flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-xs font-medium border transition-colors ${"oauth"===y?"bg-primary/20 border-primary/40 text-primary animate-pulse":"bg-bg-subtle border-border text-text-muted hover:text-text-primary hover:border-primary/40"}`,title:"Test all OAuth connections",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"oauth"===y?"sync":"play_arrow"}),"oauth"===y?"Testing...":"Test All"]})]}),(0,s.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4",children:Object.entries(o.zN).map(([e,t])=>(0,s.jsx)(x,{providerId:e,provider:t,stats:k(e,"oauth")},e))})]}),(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between",children:[(0,s.jsx)("h2",{className:"text-xl font-semibold",children:"Free Providers"}),(0,s.jsxs)("button",{onClick:()=>T("free"),disabled:!!y,className:`flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-xs font-medium border transition-colors ${"free"===y?"bg-primary/20 border-primary/40 text-primary animate-pulse":"bg-bg-subtle border-border text-text-muted hover:text-text-primary hover:border-primary/40"}`,title:"Test all Free connections",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"free"===y?"sync":"play_arrow"}),"free"===y?"Testing...":"Test All"]})]}),(0,s.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4",children:Object.entries(d.IS).map(([e,t])=>(0,s.jsx)(x,{providerId:e,provider:t,stats:k(e,"oauth")},e))})]}),(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between",children:[(0,s.jsx)("h2",{className:"text-xl font-semibold",children:"API Key Providers"}),(0,s.jsxs)("button",{onClick:()=>T("apikey"),disabled:!!y,className:`flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-xs font-medium border transition-colors ${"apikey"===y?"bg-primary/20 border-primary/40 text-primary animate-pulse":"bg-bg-subtle border-border text-text-muted hover:text-text-primary hover:border-primary/40"}`,title:"Test all API Key connections",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"apikey"===y?"sync":"play_arrow"}),"apikey"===y?"Testing...":"Test All"]})]}),(0,s.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4",children:Object.entries(o.fg).map(([e,t])=>(0,s.jsx)(u,{providerId:e,provider:t,stats:k(e,"apikey")},e))})]}),(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between",children:[(0,s.jsx)("h2",{className:"text-xl font-semibold",children:"API Key Compatible Providers"}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(w.length>0||A.length>0)&&(0,s.jsxs)("button",{onClick:()=>T("compatible"),disabled:!!y,className:`flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-xs font-medium border transition-colors ${"compatible"===y?"bg-primary/20 border-primary/40 text-primary animate-pulse":"bg-bg-subtle border-border text-text-muted hover:text-text-primary hover:border-primary/40"}`,title:"Test all Compatible connections",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"compatible"===y?"sync":"play_arrow"}),"compatible"===y?"Testing...":"Test All"]}),(0,s.jsx)(n.$n,{size:"sm",icon:"add",onClick:()=>v(!0),children:"Add Anthropic Compatible"}),(0,s.jsx)(n.$n,{size:"sm",variant:"secondary",icon:"add",onClick:()=>m(!0),className:"!bg-white !text-black hover:!bg-gray-100",children:"Add OpenAI Compatible"})]})]}),0===w.length&&0===A.length?(0,s.jsxs)("div",{className:"text-center py-8 border border-dashed border-border rounded-xl",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-[32px] text-text-muted mb-2",children:"extension"}),(0,s.jsx)("p",{className:"text-text-muted text-sm",children:"No compatible providers added yet"}),(0,s.jsx)("p",{className:"text-text-muted text-xs mt-1",children:"Use the buttons above to add OpenAI or Anthropic compatible endpoints"})]}):(0,s.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4",children:[...w,...A].map(e=>(0,s.jsx)(u,{providerId:e.id,provider:e,stats:k(e.id,"apikey")},e.id))})]}),(0,s.jsx)(h,{isOpen:p,onClose:()=>m(!1),onCreated:e=>{i(t=>[...t,e]),m(!1)}}),(0,s.jsx)(b,{isOpen:g,onClose:()=>v(!1),onCreated:e=>{i(t=>[...t,e]),v(!1)}}),N&&(0,s.jsxs)("div",{className:"fixed inset-0 z-50 flex items-start justify-center pt-[10vh]",onClick:()=>C(null),children:[(0,s.jsx)("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm"}),(0,s.jsxs)("div",{className:"relative bg-bg-primary border border-border rounded-xl w-full max-w-[600px] max-h-[80vh] overflow-y-auto shadow-2xl",onClick:e=>e.stopPropagation(),children:[(0,s.jsxs)("div",{className:"sticky top-0 z-10 flex items-center justify-between px-5 py-3 border-b border-border bg-bg-primary/95 backdrop-blur-sm rounded-t-xl",children:[(0,s.jsx)("h3",{className:"font-semibold",children:"Test Results"}),(0,s.jsx)("button",{onClick:()=>C(null),className:"p-1 rounded-lg hover:bg-bg-subtle text-text-muted hover:text-text-primary transition-colors",children:(0,s.jsx)("span",{className:"material-symbols-outlined text-lg",children:"close"})})]}),(0,s.jsx)("div",{className:"p-5",children:(0,s.jsx)(f,{results:N})})]})]})]})}function x({providerId:e,provider:t,stats:r}){let{connected:l,error:o,errorCode:d,errorTime:m}=r,[x,u]=(0,a.useState)(!1);return(0,s.jsx)(c,{href:`/dashboard/providers/${e}`,className:"group",children:(0,s.jsx)(n.Zp,{padding:"xs",className:"h-full hover:bg-black/[0.01] dark:hover:bg-white/[0.01] transition-colors cursor-pointer",children:(0,s.jsxs)("div",{className:"flex items-center justify-between",children:[(0,s.jsxs)("div",{className:"flex items-center gap-3",children:[(0,s.jsx)("div",{className:"size-8 rounded-lg flex items-center justify-center",style:{backgroundColor:`${t.color}15`},children:x?(0,s.jsx)("span",{className:"text-xs font-bold",style:{color:t.color},children:t.textIcon||t.id.slice(0,2).toUpperCase()}):(0,s.jsx)(i.default,{src:`/providers/${t.id}.png`,alt:t.name,width:30,height:30,className:"object-contain rounded-lg max-w-[32px] max-h-[32px]",sizes:"32px",onError:()=>u(!0)})}),(0,s.jsxs)("div",{children:[(0,s.jsx)("h3",{className:"font-semibold",children:t.name}),(0,s.jsxs)("div",{className:"flex items-center gap-2 text-xs flex-wrap",children:[p(l,o,d),m&&(0,s.jsxs)("span",{className:"text-text-muted",children:["• ",m]})]})]})]}),(0,s.jsx)("span",{className:"material-symbols-outlined text-text-muted opacity-0 group-hover:opacity-100 transition-opacity",children:"chevron_right"})]})})})}function u({providerId:e,provider:t,stats:r}){let{connected:l,error:o,errorCode:m,errorTime:x}=r,u=e.startsWith(d.JH),h=e.startsWith(d.DI),[b,f]=(0,a.useState)(!1);return(0,s.jsx)(c,{href:`/dashboard/providers/${e}`,className:"group",children:(0,s.jsx)(n.Zp,{padding:"xs",className:"h-full hover:bg-black/[0.01] dark:hover:bg-white/[0.01] transition-colors cursor-pointer",children:(0,s.jsxs)("div",{className:"flex items-center justify-between",children:[(0,s.jsxs)("div",{className:"flex items-center gap-3",children:[(0,s.jsx)("div",{className:"size-8 rounded-lg flex items-center justify-center",style:{backgroundColor:`${t.color}15`},children:b?(0,s.jsx)("span",{className:"text-xs font-bold",style:{color:t.color},children:t.textIcon||t.id.slice(0,2).toUpperCase()}):(0,s.jsx)(i.default,{src:u?"responses"===t.apiType?"/providers/oai-r.png":"/providers/oai-cc.png":h?"/providers/anthropic-m.png":`/providers/${t.id}.png`,alt:t.name,width:30,height:30,className:"object-contain rounded-lg max-w-[30px] max-h-[30px]",sizes:"30px",onError:()=>f(!0)})}),(0,s.jsxs)("div",{children:[(0,s.jsx)("h3",{className:"font-semibold",children:t.name}),(0,s.jsxs)("div",{className:"flex items-center gap-2 text-xs flex-wrap",children:[p(l,o,m),u&&(0,s.jsx)(n.Ex,{variant:"default",size:"sm",children:"responses"===t.apiType?"Responses":"Chat"}),h&&(0,s.jsx)(n.Ex,{variant:"default",size:"sm",children:"Messages"}),x&&(0,s.jsxs)("span",{className:"text-text-muted",children:["• ",x]})]})]})]}),(0,s.jsx)("span",{className:"material-symbols-outlined text-text-muted opacity-0 group-hover:opacity-100 transition-opacity",children:"chevron_right"})]})})})}function h({isOpen:e,onClose:t,onCreated:r}){let[i,l]=(0,a.useState)({name:"",prefix:"",apiType:"chat",baseUrl:"https://api.openai.com/v1"}),[o,d]=(0,a.useState)(!1),[c,p]=(0,a.useState)(""),[m,x]=(0,a.useState)(!1),[u,h]=(0,a.useState)(null);(0,a.useEffect)(()=>{l(e=>({...e,baseUrl:"https://api.openai.com/v1"}))},[i.apiType]);let b=async()=>{if(i.name.trim()&&i.prefix.trim()&&i.baseUrl.trim()){d(!0);try{let e=await fetch("/api/provider-nodes",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:i.name,prefix:i.prefix,apiType:i.apiType,baseUrl:i.baseUrl,type:"openai-compatible"})}),t=await e.json();e.ok&&(r(t.node),l({name:"",prefix:"",apiType:"chat",baseUrl:"https://api.openai.com/v1"}),p(""),h(null))}catch(e){console.log("Error creating OpenAI Compatible node:",e)}finally{d(!1)}}},f=async()=>{x(!0);try{let e=await fetch("/api/provider-nodes/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:i.baseUrl,apiKey:c,type:"openai-compatible"})}),t=await e.json();h(t.valid?"success":"failed")}catch{h("failed")}finally{x(!1)}};return(0,s.jsx)(n.aF,{isOpen:e,title:"Add OpenAI Compatible",onClose:t,children:(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,s.jsx)(n.pd,{label:"Name",value:i.name,onChange:e=>l({...i,name:e.target.value}),placeholder:"OpenAI Compatible (Prod)",hint:"Required. A friendly label for this node."}),(0,s.jsx)(n.pd,{label:"Prefix",value:i.prefix,onChange:e=>l({...i,prefix:e.target.value}),placeholder:"oc-prod",hint:"Required. Used as the provider prefix for model IDs."}),(0,s.jsx)(n.l6,{label:"API Type",options:[{value:"chat",label:"Chat Completions"},{value:"responses",label:"Responses API"}],value:i.apiType,onChange:e=>l({...i,apiType:e.target.value})}),(0,s.jsx)(n.pd,{label:"Base URL",value:i.baseUrl,onChange:e=>l({...i,baseUrl:e.target.value}),placeholder:"https://api.openai.com/v1",hint:"Use the base URL (ending in /v1) for your OpenAI-compatible API."}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(n.pd,{label:"API Key (for Check)",type:"password",value:c,onChange:e=>p(e.target.value),className:"flex-1"}),(0,s.jsx)("div",{className:"pt-6",children:(0,s.jsx)(n.$n,{onClick:f,disabled:!c||m||!i.baseUrl.trim(),variant:"secondary",children:m?"Checking...":"Check"})})]}),u&&(0,s.jsx)(n.Ex,{variant:"success"===u?"success":"error",children:"success"===u?"Valid":"Invalid"}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(n.$n,{onClick:b,fullWidth:!0,disabled:!i.name.trim()||!i.prefix.trim()||!i.baseUrl.trim()||o,children:o?"Creating...":"Create"}),(0,s.jsx)(n.$n,{onClick:t,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})})}function b({isOpen:e,onClose:t,onCreated:r}){let[i,l]=(0,a.useState)({name:"",prefix:"",baseUrl:"https://api.anthropic.com/v1"}),[o,d]=(0,a.useState)(!1),[c,p]=(0,a.useState)(""),[m,x]=(0,a.useState)(!1),[u,h]=(0,a.useState)(null);(0,a.useEffect)(()=>{e&&(h(null),p(""))},[e]);let b=async()=>{if(i.name.trim()&&i.prefix.trim()&&i.baseUrl.trim()){d(!0);try{let e=await fetch("/api/provider-nodes",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:i.name,prefix:i.prefix,baseUrl:i.baseUrl,type:"anthropic-compatible"})}),t=await e.json();e.ok&&(r(t.node),l({name:"",prefix:"",baseUrl:"https://api.anthropic.com/v1"}),p(""),h(null))}catch(e){console.log("Error creating Anthropic Compatible node:",e)}finally{d(!1)}}},f=async()=>{x(!0);try{let e=await fetch("/api/provider-nodes/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:i.baseUrl,apiKey:c,type:"anthropic-compatible"})}),t=await e.json();h(t.valid?"success":"failed")}catch{h("failed")}finally{x(!1)}};return(0,s.jsx)(n.aF,{isOpen:e,title:"Add Anthropic Compatible",onClose:t,children:(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,s.jsx)(n.pd,{label:"Name",value:i.name,onChange:e=>l({...i,name:e.target.value}),placeholder:"Anthropic Compatible (Prod)",hint:"Required. A friendly label for this node."}),(0,s.jsx)(n.pd,{label:"Prefix",value:i.prefix,onChange:e=>l({...i,prefix:e.target.value}),placeholder:"ac-prod",hint:"Required. Used as the provider prefix for model IDs."}),(0,s.jsx)(n.pd,{label:"Base URL",value:i.baseUrl,onChange:e=>l({...i,baseUrl:e.target.value}),placeholder:"https://api.anthropic.com/v1",hint:"Use the base URL (ending in /v1) for your Anthropic-compatible API. The system will append /messages."}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(n.pd,{label:"API Key (for Check)",type:"password",value:c,onChange:e=>p(e.target.value),className:"flex-1"}),(0,s.jsx)("div",{className:"pt-6",children:(0,s.jsx)(n.$n,{onClick:f,disabled:!c||m||!i.baseUrl.trim(),variant:"secondary",children:m?"Checking...":"Check"})})]}),u&&(0,s.jsx)(n.Ex,{variant:"success"===u?"success":"error",children:"success"===u?"Valid":"Invalid"}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(n.$n,{onClick:b,fullWidth:!0,disabled:!i.name.trim()||!i.prefix.trim()||!i.baseUrl.trim()||o,children:o?"Creating...":"Create"}),(0,s.jsx)(n.$n,{onClick:t,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})})}function f({results:e}){if(e.error&&!e.results)return(0,s.jsxs)("div",{className:"text-center py-6",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-red-500 text-[32px] mb-2 block",children:"error"}),(0,s.jsx)("p",{className:"text-sm text-red-400",children:e.error})]});let{summary:t,mode:r}=e,a=e.results||[];return(0,s.jsxs)("div",{className:"flex flex-col gap-3",children:[t&&(0,s.jsxs)("div",{className:"flex items-center gap-3 text-xs mb-1",children:[(0,s.jsxs)("span",{className:"text-text-muted",children:[{oauth:"OAuth",free:"Free",apikey:"API Key",provider:"Provider",all:"All"}[r]||r," Test"]}),(0,s.jsxs)("span",{className:"px-2 py-0.5 rounded bg-emerald-500/15 text-emerald-400 font-medium",children:[t.passed," passed"]}),t.failed>0&&(0,s.jsxs)("span",{className:"px-2 py-0.5 rounded bg-red-500/15 text-red-400 font-medium",children:[t.failed," failed"]}),(0,s.jsxs)("span",{className:"text-text-muted ml-auto",children:[t.total," tested"]})]}),a.map((e,t)=>(0,s.jsxs)("div",{className:"flex items-center gap-2 text-xs px-3 py-2 rounded-lg bg-black/[0.03] dark:bg-white/[0.03]",children:[(0,s.jsx)("span",{className:`material-symbols-outlined text-[16px] ${e.valid?"text-emerald-500":"text-red-500"}`,children:e.valid?"check_circle":"error"}),(0,s.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,s.jsx)("span",{className:"font-medium",children:e.connectionName}),(0,s.jsxs)("span",{className:"text-text-muted ml-1.5",children:["(",e.provider,")"]})]}),void 0!==e.latencyMs&&(0,s.jsxs)("span",{className:"text-text-muted font-mono tabular-nums",children:[e.latencyMs,"ms"]}),(0,s.jsx)("span",{className:`text-[10px] uppercase font-bold px-1.5 py-0.5 rounded ${e.valid?"bg-emerald-500/15 text-emerald-400":"bg-red-500/15 text-red-400"}`,children:e.valid?"OK":e.diagnosis?.type||"ERROR"})]},e.connectionId||t)),0===a.length&&(0,s.jsx)("div",{className:"text-center py-4 text-text-muted text-sm",children:"No active connections found for this group."})]})}x.propTypes={providerId:l.string.isRequired,provider:l.shape({id:l.string.isRequired,name:l.string.isRequired,color:l.string,textIcon:l.string}).isRequired,stats:l.shape({connected:l.number,error:l.number,errorCode:l.string,errorTime:l.string}).isRequired},u.propTypes={providerId:l.string.isRequired,provider:l.shape({id:l.string.isRequired,name:l.string.isRequired,color:l.string,textIcon:l.string,apiType:l.string}).isRequired,stats:l.shape({connected:l.number,error:l.number,errorCode:l.string,errorTime:l.string}).isRequired},h.propTypes={isOpen:l.bool.isRequired,onClose:l.func.isRequired,onCreated:l.func.isRequired},b.propTypes={isOpen:l.bool.isRequired,onClose:l.func.isRequired,onCreated:l.func.isRequired},f.propTypes={results:l.shape({mode:l.string,results:l.array,summary:l.shape({total:l.number,passed:l.number,failed:l.number}),error:l.string}).isRequired}},96105:(e,t,r)=>{Promise.resolve().then(r.bind(r,11200))}},e=>{e.O(0,[8500,600,8013,7896,1525,8441,3794,7358],()=>e(e.s=96105)),_N_E=e.O()}]);
@@ -0,0 +1 @@
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[2791],{17618:(e,t,s)=>{"use strict";s.r(t),s.d(t,{default:()=>$});var a=s(95155),l=s(12115),r=s(61592),i=s(81172),n=s(71525);function d(){let[e,t]=(0,l.useState)([]),[s,r]=(0,l.useState)(!1),[i,d]=(0,l.useState)(!1),[c,o]=(0,l.useState)({type:"",message:""}),[m,x]=(0,l.useState)(null),[u,p]=(0,l.useState)(null),[h,b]=(0,l.useState)(!1),[g,j]=(0,l.useState)({type:"",message:""}),[f,v]=(0,l.useState)({driver:"sqlite",dbPath:"~/.omniroute/storage.sqlite",sizeBytes:0,retentionDays:90,lastBackupAt:null}),y=async()=>{r(!0);try{let e=await fetch("/api/db-backups"),s=await e.json();t(s.backups||[])}catch(e){console.error("Failed to fetch backups:",e)}finally{r(!1)}},N=async()=>{try{let e=await fetch("/api/storage/health");if(!e.ok)return;let t=await e.json();v(e=>({...e,...t}))}catch(e){console.error("Failed to fetch storage health:",e)}},w=async()=>{b(!0),j({type:"",message:""});try{let e=await fetch("/api/db-backups",{method:"PUT"}),t=await e.json();e.ok?(t.filename?j({type:"success",message:`Backup created: ${t.filename}`}):j({type:"info",message:t.message||"No changes since last backup"}),await N(),i&&await y()):j({type:"error",message:t.error||"Backup failed"})}catch{j({type:"error",message:"An error occurred"})}finally{b(!1)}},k=async e=>{x(e),o({type:"",message:""});try{let t=await fetch("/api/db-backups",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({backupId:e})}),s=await t.json();t.ok?(o({type:"success",message:`Restored! ${s.connectionCount} connections, ${s.nodeCount} nodes, ${s.comboCount} combos, ${s.apiKeyCount} API keys.`}),await y(),await N()):o({type:"error",message:s.error||"Restore failed"})}catch{o({type:"error",message:"An error occurred during restore"})}finally{x(null),p(null)}};(0,l.useEffect)(()=>{N()},[]);let C=e=>e&&0!==e?e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(1)} MB`:"0 B";return(0,a.jsxs)(n.Zp,{children:[(0,a.jsxs)("div",{className:"flex items-center gap-3 mb-4",children:[(0,a.jsx)("div",{className:"p-2 rounded-lg bg-green-500/10 text-green-500",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[20px]","aria-hidden":"true",children:"database"})}),(0,a.jsxs)("div",{className:"flex-1",children:[(0,a.jsx)("h3",{className:"text-lg font-semibold",children:"System & Storage"}),(0,a.jsx)("p",{className:"text-xs text-text-muted",children:"All data stored locally on your machine"})]}),(0,a.jsx)(n.Ex,{variant:"success",size:"sm",children:f.driver||"json"})]}),(0,a.jsxs)("div",{className:"grid grid-cols-2 gap-3 mb-4",children:[(0,a.jsxs)("div",{className:"p-3 rounded-lg bg-bg border border-border",children:[(0,a.jsx)("p",{className:"text-[11px] text-text-muted uppercase tracking-wide mb-1",children:"Database Path"}),(0,a.jsx)("p",{className:"text-sm font-mono text-text-main break-all",children:f.dbPath||"~/.omniroute/storage.sqlite"})]}),(0,a.jsxs)("div",{className:"p-3 rounded-lg bg-bg border border-border",children:[(0,a.jsx)("p",{className:"text-[11px] text-text-muted uppercase tracking-wide mb-1",children:"Database Size"}),(0,a.jsx)("p",{className:"text-sm font-mono text-text-main",children:C(f.sizeBytes)})]})]}),(0,a.jsxs)("div",{className:"flex items-center justify-between p-3 rounded-lg bg-bg border border-border mb-4",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[16px] text-amber-500","aria-hidden":"true",children:"schedule"}),(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"text-sm font-medium",children:"Last Backup"}),(0,a.jsx)("p",{className:"text-xs text-text-muted",children:f.lastBackupAt?`${new Date(f.lastBackupAt).toLocaleString("pt-BR")} (${(e=>{if(!e)return null;let t=Math.floor((new Date-new Date(e))/6e4);if(t<1)return"just now";if(t<60)return`${t}m ago`;let s=Math.floor(t/60);if(s<24)return`${s}h ago`;let a=Math.floor(s/24);return`${a}d ago`})(f.lastBackupAt)})`:"No backup yet"})]})]}),(0,a.jsxs)(n.$n,{variant:"outline",size:"sm",onClick:w,loading:h,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1","aria-hidden":"true",children:"backup"}),"Backup Now"]})]}),g.message&&(0,a.jsx)("div",{className:`p-3 rounded-lg mb-4 text-sm ${"success"===g.type?"bg-green-500/10 text-green-500 border border-green-500/20":"info"===g.type?"bg-blue-500/10 text-blue-500 border border-blue-500/20":"bg-red-500/10 text-red-500 border border-red-500/20"}`,role:"alert",children:(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[16px]","aria-hidden":"true",children:"success"===g.type?"check_circle":"info"===g.type?"info":"error"}),g.message]})}),(0,a.jsxs)("div",{className:"pt-3 border-t border-border/50",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between mb-3",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px] text-amber-500","aria-hidden":"true",children:"restore"}),(0,a.jsx)("p",{className:"font-medium",children:"Backup & Restore"})]}),(0,a.jsx)(n.$n,{variant:"outline",size:"sm",onClick:()=>{d(!i),i||0!==e.length||y()},children:i?"Hide":"View Backups"})]}),(0,a.jsx)("p",{className:"text-xs text-text-muted mb-3",children:"Database snapshots are created automatically before restore and every 15 minutes when data changes. Retention: 24 hourly + 30 daily backups with smart rotation."}),c.message&&(0,a.jsx)("div",{className:`p-3 rounded-lg mb-3 text-sm ${"success"===c.type?"bg-green-500/10 text-green-500 border border-green-500/20":"bg-red-500/10 text-red-500 border border-red-500/20"}`,role:"alert",children:(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[16px]","aria-hidden":"true",children:"success"===c.type?"check_circle":"error"}),c.message]})}),i&&(0,a.jsx)("div",{className:"flex flex-col gap-2",children:s?(0,a.jsxs)("div",{className:"flex items-center justify-center py-6 text-text-muted",children:[(0,a.jsx)("span",{className:"material-symbols-outlined animate-spin text-[20px] mr-2","aria-hidden":"true",children:"progress_activity"}),"Loading backups..."]}):0===e.length?(0,a.jsxs)("div",{className:"text-center py-6 text-text-muted text-sm",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[32px] mb-2 block opacity-40","aria-hidden":"true",children:"folder_off"}),"No backups available yet. Backups will be created automatically when data changes."]}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"flex items-center justify-between mb-1",children:[(0,a.jsxs)("span",{className:"text-xs text-text-muted",children:[e.length," backup(s) available"]}),(0,a.jsxs)("button",{onClick:y,className:"text-xs text-primary hover:underline flex items-center gap-1",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]","aria-hidden":"true",children:"refresh"}),"Refresh"]})]}),e.map(e=>(0,a.jsxs)("div",{className:"flex items-center justify-between p-3 rounded-lg bg-black/[0.02] dark:bg-white/[0.02] border border-border/50 hover:border-border transition-colors",children:[(0,a.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2 mb-1",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[16px] text-amber-500","aria-hidden":"true",children:"description"}),(0,a.jsx)("span",{className:"text-sm font-medium truncate",children:new Date(e.createdAt).toLocaleString("pt-BR")}),(0,a.jsx)(n.Ex,{variant:"pre-restore"===e.reason?"warning":"manual"===e.reason?"success":"default",size:"sm",children:e.reason})]}),(0,a.jsxs)("div",{className:"flex items-center gap-3 text-xs text-text-muted ml-6",children:[(0,a.jsxs)("span",{children:[e.connectionCount," connection(s)"]}),(0,a.jsx)("span",{children:"•"}),(0,a.jsx)("span",{children:C(e.size)})]})]}),(0,a.jsx)("div",{className:"flex items-center gap-2 ml-3",children:u===e.id?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("span",{className:"text-xs text-amber-500 font-medium",children:"Confirm?"}),(0,a.jsx)(n.$n,{variant:"primary",size:"sm",onClick:()=>k(e.id),loading:m===e.id,className:"!bg-amber-500 hover:!bg-amber-600",children:"Yes"}),(0,a.jsx)(n.$n,{variant:"outline",size:"sm",onClick:()=>p(null),children:"No"})]}):(0,a.jsxs)(n.$n,{variant:"outline",size:"sm",onClick:()=>p(e.id),children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1","aria-hidden":"true",children:"restore"}),"Restore"]})})]},e.id))]})})]})]})}let c=[{value:"disabled",label:"Disabled",icon:"block"},{value:"blacklist",label:"Blacklist",icon:"do_not_disturb"},{value:"whitelist",label:"Whitelist",icon:"verified_user"},{value:"whitelist-priority",label:"WL Priority",icon:"priority_high"}];function o(){let[e,t]=(0,l.useState)({enabled:!1,mode:"blacklist",blacklist:[],whitelist:[],tempBans:[]}),[s,r]=(0,l.useState)(!0),[i,d]=(0,l.useState)(""),[o,m]=(0,l.useState)("blacklist");(0,l.useEffect)(()=>{x()},[]);let x=async()=>{try{let e=await fetch("/api/settings/ip-filter");e.ok&&t(await e.json())}catch{}finally{r(!1)}},u=async e=>{try{let s=await fetch("/api/settings/ip-filter",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});s.ok&&t(await s.json())}catch{}},p=()=>{i.trim()&&(u({["blacklist"===o?"addBlacklist":"addWhitelist"]:i.trim()}),d(""))},h=(e,t)=>{u({["blacklist"===t?"removeBlacklist":"removeWhitelist"]:e})},b=e.enabled?e.mode:"disabled";return(0,a.jsxs)(n.Zp,{children:[(0,a.jsxs)("div",{className:"flex items-center gap-3 mb-5",children:[(0,a.jsx)("div",{className:"p-2 rounded-lg bg-red-500/10 text-red-500",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[20px]","aria-hidden":"true",children:"security"})}),(0,a.jsxs)("div",{className:"flex-1",children:[(0,a.jsx)("h3",{className:"text-lg font-semibold",children:"IP Access Control"}),(0,a.jsx)("p",{className:"text-sm text-text-muted",children:"Block or allow specific IP addresses"})]})]}),(0,a.jsx)("div",{className:"grid grid-cols-4 gap-2 mb-5",children:c.map(e=>(0,a.jsxs)("button",{onClick:()=>{var t;"disabled"===(t=e.value)?u({enabled:!1}):u({enabled:!0,mode:t})},disabled:s,className:`flex flex-col items-center gap-1.5 p-3 rounded-lg border text-center transition-all ${b===e.value?"border-red-500/50 bg-red-500/5 ring-1 ring-red-500/20":"border-border/50 hover:border-border hover:bg-surface/30"}`,children:[(0,a.jsx)("span",{className:`material-symbols-outlined text-[20px] ${b===e.value?"text-red-400":"text-text-muted"}`,children:e.icon}),(0,a.jsx)("span",{className:`text-xs font-medium ${b===e.value?"text-red-400":"text-text-muted"}`,children:e.label})]},e.value))}),e.enabled&&(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,a.jsxs)("div",{className:"flex gap-2 items-end",children:[(0,a.jsx)("div",{className:"flex-1",children:(0,a.jsx)(n.pd,{label:"Add IP Address",placeholder:"192.168.1.0/24 or 10.0.*.*",value:i,onChange:e=>d(e.target.value),onKeyDown:e=>"Enter"===e.key&&p()})}),(0,a.jsxs)("div",{className:"flex gap-1 pb-[2px]",children:[(0,a.jsx)(n.$n,{size:"sm",variant:"blacklist"===o?"danger":"secondary",onClick:()=>{m("blacklist"),i.trim()&&p()},children:"+ Block"}),(0,a.jsx)(n.$n,{size:"sm",variant:"whitelist"===o?"primary":"secondary",onClick:()=>{m("whitelist"),i.trim()&&p()},children:"+ Allow"})]})]}),e.blacklist.length>0&&(0,a.jsxs)("div",{children:[(0,a.jsxs)("p",{className:"text-xs font-semibold text-text-muted uppercase tracking-wider mb-2",children:["Blocked (",e.blacklist.length,")"]}),(0,a.jsx)("div",{className:"flex flex-wrap gap-1.5",children:e.blacklist.map(e=>(0,a.jsxs)("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 rounded-md text-xs font-mono bg-red-500/10 text-red-400 border border-red-500/20",children:[e,(0,a.jsx)("button",{onClick:()=>h(e,"blacklist"),className:"hover:text-red-300",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"close"})})]},e))})]}),e.whitelist.length>0&&(0,a.jsxs)("div",{children:[(0,a.jsxs)("p",{className:"text-xs font-semibold text-text-muted uppercase tracking-wider mb-2",children:["Allowed (",e.whitelist.length,")"]}),(0,a.jsx)("div",{className:"flex flex-wrap gap-1.5",children:e.whitelist.map(e=>(0,a.jsxs)("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 rounded-md text-xs font-mono bg-emerald-500/10 text-emerald-400 border border-emerald-500/20",children:[e,(0,a.jsx)("button",{onClick:()=>h(e,"whitelist"),className:"hover:text-emerald-300",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"close"})})]},e))})]}),e.tempBans.length>0&&(0,a.jsxs)("div",{children:[(0,a.jsxs)("p",{className:"text-xs font-semibold text-text-muted uppercase tracking-wider mb-2",children:["Temporary Bans (",e.tempBans.length,")"]}),(0,a.jsx)("div",{className:"flex flex-col gap-1.5",children:e.tempBans.map(e=>(0,a.jsxs)("div",{className:"flex items-center justify-between px-3 py-2 rounded-lg bg-orange-500/5 border border-orange-500/20 text-sm",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"font-mono text-xs text-orange-400",children:e.ip}),(0,a.jsxs)("span",{className:"text-xs text-text-muted",children:["— ",e.reason]})]}),(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsxs)("span",{className:"text-xs text-text-muted tabular-nums",children:[Math.ceil(e.remainingMs/6e4),"m left"]}),(0,a.jsx)("button",{onClick:()=>u({removeBan:e.ip}),className:"text-text-muted hover:text-orange-400",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"delete"})})]})]},e.ip))})]})]})]})}function m(){let[e,t]=(0,l.useState)({requireLogin:!1,hasPassword:!1}),[s,r]=(0,l.useState)(!0),[i,d]=(0,l.useState)({current:"",new:"",confirm:""}),[c,m]=(0,l.useState)({type:"",message:""}),[x,u]=(0,l.useState)(!1);(0,l.useEffect)(()=>{fetch("/api/settings").then(e=>e.json()).then(e=>{t(e),r(!1)}).catch(()=>r(!1))},[]);let p=async e=>{try{(await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({requireLogin:e})})).ok&&t(t=>({...t,requireLogin:e}))}catch(e){console.error("Failed to update require login:",e)}},h=async e=>{if(e.preventDefault(),i.new!==i.confirm)return void m({type:"error",message:"Passwords do not match"});u(!0),m({type:"",message:""});try{let e=await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({currentPassword:i.current,newPassword:i.new})}),t=await e.json();e.ok?(m({type:"success",message:"Password updated successfully"}),d({current:"",new:"",confirm:""})):m({type:"error",message:t.error||"Failed to update password"})}catch{m({type:"error",message:"An error occurred"})}finally{u(!1)}};return(0,a.jsxs)("div",{className:"flex flex-col gap-6",children:[(0,a.jsxs)(n.Zp,{children:[(0,a.jsxs)("div",{className:"flex items-center gap-3 mb-4",children:[(0,a.jsx)("div",{className:"p-2 rounded-lg bg-primary/10 text-primary",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[20px]","aria-hidden":"true",children:"shield"})}),(0,a.jsx)("h3",{className:"text-lg font-semibold",children:"Security"})]}),(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"font-medium",children:"Require login"}),(0,a.jsx)("p",{className:"text-sm text-text-muted",children:"When ON, dashboard requires password. When OFF, access without login."})]}),(0,a.jsx)(n.lM,{checked:!0===e.requireLogin,onChange:()=>p(!e.requireLogin),disabled:s})]}),!0===e.requireLogin&&(0,a.jsxs)("form",{onSubmit:h,className:"flex flex-col gap-4 pt-4 border-t border-border/50",children:[e.hasPassword&&(0,a.jsx)(n.pd,{label:"Current Password",type:"password",placeholder:"Enter current password",value:i.current,onChange:e=>d({...i,current:e.target.value}),required:!0}),(0,a.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[(0,a.jsx)(n.pd,{label:"New Password",type:"password",placeholder:"Enter new password",value:i.new,onChange:e=>d({...i,new:e.target.value}),required:!0}),(0,a.jsx)(n.pd,{label:"Confirm New Password",type:"password",placeholder:"Confirm new password",value:i.confirm,onChange:e=>d({...i,confirm:e.target.value}),required:!0})]}),c.message&&(0,a.jsx)("p",{className:`text-sm ${"error"===c.type?"text-red-500":"text-green-500"}`,children:c.message}),(0,a.jsx)("div",{className:"pt-2",children:(0,a.jsx)(n.$n,{type:"submit",variant:"primary",loading:x,children:e.hasPassword?"Update Password":"Set Password"})})]})]})]}),(0,a.jsx)(o,{})]})}let x=[{value:"fill-first",label:"Fill First",desc:"Use accounts in priority order",icon:"vertical_align_top"},{value:"round-robin",label:"Round Robin",desc:"Cycle through all accounts",icon:"loop"},{value:"p2c",label:"P2C",desc:"Pick 2 random, use the healthier one",icon:"balance"}];function u(){let[e,t]=(0,l.useState)({fallbackStrategy:"fill-first"}),[s,r]=(0,l.useState)(!0),[i,d]=(0,l.useState)([]),[c,o]=(0,l.useState)(""),[m,u]=(0,l.useState)("");(0,l.useEffect)(()=>{fetch("/api/settings").then(e=>e.json()).then(e=>{t(e),d(e.wildcardAliases||[]),r(!1)}).catch(()=>r(!1))},[]);let p=async e=>{try{(await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})).ok&&t(t=>({...t,...e}))}catch(e){console.error("Failed to update settings:",e)}},h=async()=>{if(!c.trim()||!m.trim())return;let e=[...i,{pattern:c.trim(),target:m.trim()}];await p({wildcardAliases:e}),d(e),o(""),u("")},b=async e=>{let t=i.filter((t,s)=>s!==e);await p({wildcardAliases:t}),d(t)};return(0,a.jsxs)("div",{className:"flex flex-col gap-6",children:[(0,a.jsxs)(n.Zp,{children:[(0,a.jsxs)("div",{className:"flex items-center gap-3 mb-4",children:[(0,a.jsx)("div",{className:"p-2 rounded-lg bg-blue-500/10 text-blue-500",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[20px]","aria-hidden":"true",children:"route"})}),(0,a.jsx)("h3",{className:"text-lg font-semibold",children:"Routing Strategy"})]}),(0,a.jsx)("div",{className:"grid grid-cols-3 gap-2 mb-4",children:x.map(t=>(0,a.jsxs)("button",{onClick:()=>p({fallbackStrategy:t.value}),disabled:s,className:`flex flex-col items-center gap-2 p-4 rounded-lg border text-center transition-all ${e.fallbackStrategy===t.value?"border-blue-500/50 bg-blue-500/5 ring-1 ring-blue-500/20":"border-border/50 hover:border-border hover:bg-surface/30"}`,children:[(0,a.jsx)("span",{className:`material-symbols-outlined text-[24px] ${e.fallbackStrategy===t.value?"text-blue-400":"text-text-muted"}`,children:t.icon}),(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:`text-sm font-medium ${e.fallbackStrategy===t.value?"text-blue-400":""}`,children:t.label}),(0,a.jsx)("p",{className:"text-xs text-text-muted mt-0.5",children:t.desc})]})]},t.value))}),"round-robin"===e.fallbackStrategy&&(0,a.jsxs)("div",{className:"flex items-center justify-between pt-3 border-t border-border/30",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"text-sm font-medium",children:"Sticky Limit"}),(0,a.jsx)("p",{className:"text-xs text-text-muted",children:"Calls per account before switching"})]}),(0,a.jsx)(n.pd,{type:"number",min:"1",max:"10",value:e.stickyRoundRobinLimit||3,onChange:e=>p({stickyRoundRobinLimit:parseInt(e.target.value)}),disabled:s,className:"w-20 text-center"})]}),(0,a.jsxs)("p",{className:"text-xs text-text-muted italic pt-3 border-t border-border/30 mt-3",children:["round-robin"===e.fallbackStrategy&&`Distributing requests across accounts with ${e.stickyRoundRobinLimit||3} calls per account.`,"fill-first"===e.fallbackStrategy&&"Using accounts in priority order (Fill First).","p2c"===e.fallbackStrategy&&"Power of Two Choices: picks 2 random accounts and routes to the healthier one."]})]}),(0,a.jsxs)(n.Zp,{children:[(0,a.jsxs)("div",{className:"flex items-center gap-3 mb-4",children:[(0,a.jsx)("div",{className:"p-2 rounded-lg bg-purple-500/10 text-purple-500",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[20px]","aria-hidden":"true",children:"alt_route"})}),(0,a.jsxs)("div",{children:[(0,a.jsx)("h3",{className:"text-lg font-semibold",children:"Model Aliases"}),(0,a.jsx)("p",{className:"text-sm text-text-muted",children:"Wildcard patterns to remap model names • Use * and ?"})]})]}),i.length>0&&(0,a.jsx)("div",{className:"flex flex-col gap-1.5 mb-4",children:i.map((e,t)=>(0,a.jsxs)("div",{className:"flex items-center justify-between px-3 py-2 rounded-lg bg-surface/30 border border-border/20",children:[(0,a.jsxs)("div",{className:"flex items-center gap-3 text-sm",children:[(0,a.jsx)("span",{className:"font-mono text-purple-400",children:e.pattern}),(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px] text-text-muted",children:"arrow_forward"}),(0,a.jsx)("span",{className:"font-mono text-text-main",children:e.target})]}),(0,a.jsx)("button",{onClick:()=>b(t),className:"text-text-muted hover:text-red-400 transition-colors",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"close"})})]},t))}),(0,a.jsxs)("div",{className:"flex gap-2 items-end",children:[(0,a.jsx)("div",{className:"flex-1",children:(0,a.jsx)(n.pd,{label:"Pattern",placeholder:"claude-sonnet-*",value:c,onChange:e=>o(e.target.value)})}),(0,a.jsx)("div",{className:"flex-1",children:(0,a.jsx)(n.pd,{label:"Target Model",placeholder:"claude-sonnet-4-20250514",value:m,onChange:e=>u(e.target.value)})}),(0,a.jsx)(n.$n,{size:"sm",variant:"primary",onClick:h,className:"mb-[2px]",children:"+ Add"})]})]})]})}function p(){let[e,t]=(0,l.useState)({strategy:"priority",maxRetries:1,retryDelayMs:2e3,timeoutMs:12e4,healthCheckEnabled:!0,healthCheckTimeoutMs:3e3,maxComboDepth:3,trackMetrics:!0}),[s,i]=(0,l.useState)({}),[d,c]=(0,l.useState)(""),[o,m]=(0,l.useState)(!1);(0,l.useEffect)(()=>{fetch("/api/settings/combo-defaults").then(e=>e.json()).then(e=>{e.comboDefaults&&t(e.comboDefaults),e.providerOverrides&&i(e.providerOverrides)}).catch(e=>console.error("Failed to fetch combo defaults:",e))},[]);let x=async()=>{m(!0);try{await fetch("/api/settings/combo-defaults",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({comboDefaults:e,providerOverrides:s})})}catch(e){console.error("Failed to save combo defaults:",e)}finally{m(!1)}},u=()=>{let e=d.trim().toLowerCase();e&&!s[e]&&(i(t=>({...t,[e]:{maxRetries:1,timeoutMs:12e4}})),c(""))};return(0,a.jsxs)(n.Zp,{children:[(0,a.jsxs)("div",{className:"flex items-center gap-3 mb-4",children:[(0,a.jsx)("div",{className:"p-2 rounded-lg bg-amber-500/10 text-amber-500",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[20px]","aria-hidden":"true",children:"tune"})}),(0,a.jsx)("h3",{className:"text-lg font-semibold",children:"Combo Defaults"}),(0,a.jsx)("span",{className:"text-xs text-text-muted ml-auto",children:"Global combo configuration"})]}),(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"font-medium text-sm",children:"Default Strategy"}),(0,a.jsx)("p",{className:"text-xs text-text-muted",children:"Applied to new combos without explicit strategy"})]}),(0,a.jsx)("div",{role:"tablist","aria-label":"Combo strategy",className:"inline-flex p-0.5 rounded-md bg-black/5 dark:bg-white/5",children:["priority","weighted","round-robin"].map(s=>(0,a.jsx)("button",{role:"tab","aria-selected":e.strategy===s,onClick:()=>t(e=>({...e,strategy:s})),className:(0,r.cn)("px-3 py-1 rounded text-xs font-medium transition-all capitalize",e.strategy===s?"bg-white dark:bg-white/10 text-text-main shadow-sm":"text-text-muted hover:text-text-main"),children:"round-robin"===s?"Round-Robin":s},s))})]}),(0,a.jsx)("div",{className:"grid grid-cols-2 gap-3 pt-3 border-t border-border/50",children:[{key:"maxRetries",label:"Max Retries",min:0,max:5},{key:"retryDelayMs",label:"Retry Delay (ms)",min:500,max:1e4,step:500},{key:"timeoutMs",label:"Timeout (ms)",min:5e3,max:3e5,step:5e3},{key:"maxComboDepth",label:"Max Nesting Depth",min:1,max:10}].map(({key:s,label:l,min:r,max:i,step:d})=>(0,a.jsx)(n.pd,{label:l,type:"number",min:r,max:i,step:d||1,value:e[s]??"",onChange:e=>t(t=>({...t,[s]:parseInt(e.target.value)||0})),className:"text-sm"},s))}),"round-robin"===e.strategy&&(0,a.jsxs)("div",{className:"grid grid-cols-2 gap-3 pt-3 border-t border-border/50",children:[(0,a.jsx)(n.pd,{label:"Concurrency / Model",type:"number",min:1,max:20,value:e.concurrencyPerModel??"",placeholder:"3",onChange:e=>t(t=>({...t,concurrencyPerModel:parseInt(e.target.value)||0})),className:"text-sm"}),(0,a.jsx)(n.pd,{label:"Queue Timeout (ms)",type:"number",min:1e3,max:12e4,step:1e3,value:e.queueTimeoutMs??"",placeholder:"30000",onChange:e=>t(t=>({...t,queueTimeoutMs:parseInt(e.target.value)||0})),className:"text-sm"})]}),(0,a.jsxs)("div",{className:"flex flex-col gap-3 pt-3 border-t border-border/50",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"font-medium text-sm",children:"Health Check"}),(0,a.jsx)("p",{className:"text-xs text-text-muted",children:"Pre-check provider availability"})]}),(0,a.jsx)(n.lM,{checked:!1!==e.healthCheckEnabled,onChange:()=>t(e=>({...e,healthCheckEnabled:!e.healthCheckEnabled}))})]}),(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"font-medium text-sm",children:"Track Metrics"}),(0,a.jsx)("p",{className:"text-xs text-text-muted",children:"Record per-combo request metrics"})]}),(0,a.jsx)(n.lM,{checked:!1!==e.trackMetrics,onChange:()=>t(e=>({...e,trackMetrics:!e.trackMetrics}))})]})]}),(0,a.jsxs)("div",{className:"pt-3 border-t border-border/50",children:[(0,a.jsx)("p",{className:"font-medium text-sm mb-2",children:"Provider Overrides"}),(0,a.jsx)("p",{className:"text-xs text-text-muted mb-3",children:"Override timeout and retries per provider. Provider settings override global defaults."}),Object.entries(s).map(([e,t])=>(0,a.jsxs)("div",{className:"flex items-center gap-2 mb-2 p-2 rounded-lg bg-black/[0.02] dark:bg-white/[0.02]",children:[(0,a.jsx)("span",{className:"text-xs font-mono font-medium min-w-[80px]",children:e}),(0,a.jsx)(n.pd,{type:"number",min:"0",max:"5",value:t.maxRetries??1,onChange:t=>i(s=>({...s,[e]:{...s[e],maxRetries:parseInt(t.target.value)||0}})),className:"text-xs w-16","aria-label":`${e} max retries`}),(0,a.jsx)("span",{className:"text-[10px] text-text-muted",children:"retries"}),(0,a.jsx)(n.pd,{type:"number",min:"5000",max:"300000",step:"5000",value:t.timeoutMs??12e4,onChange:t=>i(s=>({...s,[e]:{...s[e],timeoutMs:parseInt(t.target.value)||12e4}})),className:"text-xs w-24","aria-label":`${e} timeout ms`}),(0,a.jsx)("span",{className:"text-[10px] text-text-muted",children:"ms"}),(0,a.jsx)("button",{onClick:()=>{i(t=>{let s={...t};return delete s[e],s})},className:"ml-auto text-red-400 hover:text-red-500 transition-colors","aria-label":`Remove ${e} override`,children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[16px]","aria-hidden":"true",children:"close"})})]},e)),(0,a.jsxs)("div",{className:"flex items-center gap-2 mt-2",children:[(0,a.jsx)(n.pd,{type:"text",placeholder:"e.g. google, openai...",value:d,onChange:e=>c(e.target.value),onKeyDown:e=>"Enter"===e.key&&u(),className:"text-xs flex-1","aria-label":"New provider name"}),(0,a.jsx)(n.$n,{variant:"outline",size:"sm",onClick:u,disabled:!d.trim(),children:"Add"})]})]}),(0,a.jsx)("div",{className:"pt-3 border-t border-border/50",children:(0,a.jsx)(n.$n,{variant:"primary",size:"sm",onClick:x,loading:o,children:"Save Combo Defaults"})})]})]})}function h(){let[e,t]=(0,l.useState)(!1),[s,r]=(0,l.useState)(null),i=async()=>{try{let e=await fetch("/api/settings/proxy?level=global");if(e.ok){let t=await e.json();r(t.proxy||null)}}catch{}};return(0,l.useEffect)(()=>{i()},[]),(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(n.Zp,{className:"p-0 overflow-hidden",children:(0,a.jsxs)("div",{className:"p-6",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2 mb-4",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-xl text-primary","aria-hidden":"true",children:"vpn_lock"}),(0,a.jsx)("h2",{className:"text-lg font-bold",children:"Global Proxy"})]}),(0,a.jsx)("p",{className:"text-sm text-text-muted mb-4",children:"Configure a global outbound proxy for all API calls. Individual providers, combos, and keys can override this."}),(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[s?(0,a.jsx)("div",{className:"flex items-center gap-2",children:(0,a.jsxs)("span",{className:"px-2.5 py-1 rounded text-xs font-bold uppercase bg-emerald-500/15 text-emerald-400 border border-emerald-500/30",children:[s.type,"://",s.host,":",s.port]})}):(0,a.jsx)("span",{className:"text-sm text-text-muted",children:"No global proxy configured"}),(0,a.jsx)(n.$n,{size:"sm",variant:s?"secondary":"primary",icon:"settings",onClick:()=>{i(),t(!0)},children:s?"Edit":"Configure"})]})]})}),(0,a.jsx)(n.KN,{isOpen:e,onClose:()=>t(!1),level:"global",levelLabel:"Global",onSaved:i})]})}var b=s(2946);function g(){let{theme:e,setTheme:t,isDark:s}=(0,b.D)();return(0,a.jsxs)(n.Zp,{children:[(0,a.jsxs)("div",{className:"flex items-center gap-3 mb-4",children:[(0,a.jsx)("div",{className:"p-2 rounded-lg bg-purple-500/10 text-purple-500",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[20px]","aria-hidden":"true",children:"palette"})}),(0,a.jsx)("h3",{className:"text-lg font-semibold",children:"Appearance"})]}),(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"font-medium",children:"Dark Mode"}),(0,a.jsx)("p",{className:"text-sm text-text-muted",children:"Switch between light and dark themes"})]}),(0,a.jsx)(n.lM,{checked:s,onChange:()=>t(s?"light":"dark")})]}),(0,a.jsx)("div",{className:"pt-4 border-t border-border",children:(0,a.jsx)("div",{role:"tablist","aria-label":"Theme selection",className:"inline-flex p-1 rounded-lg bg-black/5 dark:bg-white/5",children:["light","dark","system"].map(s=>(0,a.jsxs)("button",{role:"tab","aria-selected":e===s,onClick:()=>t(s),className:(0,r.cn)("flex items-center gap-2 px-4 py-2 rounded-md font-medium transition-all",e===s?"bg-white dark:bg-white/10 text-text-main shadow-sm":"text-text-muted hover:text-text-main"),children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[20px]","aria-hidden":"true",children:"light"===s?"light_mode":"dark"===s?"dark_mode":"contrast"}),(0,a.jsx)("span",{className:"capitalize",children:s})]},s))})})]})]})}let j=[{value:"passthrough",label:"Passthrough",desc:"No changes — client controls thinking budget",icon:"arrow_forward"},{value:"auto",label:"Auto",desc:"Strip all thinking config — let provider decide",icon:"auto_awesome"},{value:"custom",label:"Custom",desc:"Set a fixed token budget for all requests",icon:"tune"},{value:"adaptive",label:"Adaptive",desc:"Scale budget based on request complexity",icon:"trending_up"}],f=[{value:"none",label:"None (0 tokens)"},{value:"low",label:"Low (1K tokens)"},{value:"medium",label:"Medium (10K tokens)"},{value:"high",label:"High (128K tokens)"}];function v(){let[e,t]=(0,l.useState)({mode:"passthrough",customBudget:10240,effortLevel:"medium"}),[s,r]=(0,l.useState)(!0),[i,d]=(0,l.useState)(!1),[c,o]=(0,l.useState)("");(0,l.useEffect)(()=>{fetch("/api/settings/thinking-budget").then(e=>e.json()).then(e=>{t(e),r(!1)}).catch(()=>r(!1))},[]);let m=async s=>{let a={...e,...s};t(a),d(!0),o("");try{(await fetch("/api/settings/thinking-budget",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)})).ok?(o("saved"),setTimeout(()=>o(""),2e3)):o("error")}catch{o("error")}finally{d(!1)}};return(0,a.jsxs)(n.Zp,{children:[(0,a.jsxs)("div",{className:"flex items-center gap-3 mb-5",children:[(0,a.jsx)("div",{className:"p-2 rounded-lg bg-violet-500/10 text-violet-500",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[20px]","aria-hidden":"true",children:"psychology"})}),(0,a.jsxs)("div",{children:[(0,a.jsx)("h3",{className:"text-lg font-semibold",children:"Thinking Budget"}),(0,a.jsx)("p",{className:"text-sm text-text-muted",children:"Control AI reasoning token usage across all requests"})]}),"saved"===c&&(0,a.jsxs)("span",{className:"ml-auto text-xs font-medium text-emerald-500 flex items-center gap-1",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"check_circle"})," Saved"]})]}),(0,a.jsx)("div",{className:"grid grid-cols-2 gap-2 mb-5",children:j.map(t=>(0,a.jsxs)("button",{onClick:()=>m({mode:t.value}),disabled:s||i,className:`flex items-start gap-3 p-3 rounded-lg border text-left transition-all ${e.mode===t.value?"border-violet-500/50 bg-violet-500/5 ring-1 ring-violet-500/20":"border-border/50 hover:border-border hover:bg-surface/30"}`,children:[(0,a.jsx)("span",{className:`material-symbols-outlined text-[20px] mt-0.5 ${e.mode===t.value?"text-violet-500":"text-text-muted"}`,children:t.icon}),(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsx)("p",{className:`text-sm font-medium ${e.mode===t.value?"text-violet-400":""}`,children:t.label}),(0,a.jsx)("p",{className:"text-xs text-text-muted mt-0.5 leading-relaxed",children:t.desc})]})]},t.value))}),"custom"===e.mode&&(0,a.jsxs)("div",{className:"p-4 rounded-lg bg-surface/30 border border-border/30 mb-4",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between mb-3",children:[(0,a.jsx)("p",{className:"text-sm font-medium",children:"Token Budget"}),(0,a.jsxs)("span",{className:"text-sm font-mono tabular-nums text-violet-400",children:[e.customBudget.toLocaleString()," tokens"]})]}),(0,a.jsx)("input",{type:"range",min:"0",max:"131072",step:"1024",value:e.customBudget,onChange:e=>m({customBudget:parseInt(e.target.value)}),className:"w-full accent-violet-500"}),(0,a.jsxs)("div",{className:"flex justify-between text-xs text-text-muted mt-1",children:[(0,a.jsx)("span",{children:"Off"}),(0,a.jsx)("span",{children:"1K"}),(0,a.jsx)("span",{children:"10K"}),(0,a.jsx)("span",{children:"64K"}),(0,a.jsx)("span",{children:"128K"})]})]}),"adaptive"===e.mode&&(0,a.jsxs)("div",{className:"p-4 rounded-lg bg-surface/30 border border-border/30",children:[(0,a.jsx)("p",{className:"text-sm font-medium mb-3",children:"Base Effort Level"}),(0,a.jsx)("p",{className:"text-xs text-text-muted mb-3",children:"Adaptive mode scales from this base level based on message count, tool usage, and prompt length."}),(0,a.jsx)("div",{className:"grid grid-cols-4 gap-2",children:f.map(t=>(0,a.jsx)("button",{onClick:()=>m({effortLevel:t.value}),disabled:s||i,className:`px-3 py-2 rounded-lg text-xs font-medium border transition-all ${e.effortLevel===t.value?"border-violet-500/50 bg-violet-500/10 text-violet-400":"border-border/50 text-text-muted hover:border-border"}`,children:t.value.charAt(0).toUpperCase()+t.value.slice(1)},t.value))})]})]})}function y(){let[e,t]=(0,l.useState)({enabled:!1,prompt:""}),[s,r]=(0,l.useState)(!0),[i,d]=(0,l.useState)(""),[c,o]=(0,l.useState)(null);(0,l.useEffect)(()=>{fetch("/api/settings/system-prompt").then(e=>e.json()).then(e=>{t(e),r(!1)}).catch(()=>r(!1))},[]);let m=async s=>{let a={...e,...s};t(a),d("");try{(await fetch("/api/settings/system-prompt",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)})).ok&&(d("saved"),setTimeout(()=>d(""),2e3))}catch{d("error")}};return(0,a.jsxs)(n.Zp,{children:[(0,a.jsxs)("div",{className:"flex items-center gap-3 mb-5",children:[(0,a.jsx)("div",{className:"p-2 rounded-lg bg-amber-500/10 text-amber-500",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[20px]","aria-hidden":"true",children:"edit_note"})}),(0,a.jsxs)("div",{className:"flex-1",children:[(0,a.jsx)("h3",{className:"text-lg font-semibold",children:"Global System Prompt"}),(0,a.jsx)("p",{className:"text-sm text-text-muted",children:"Injected into all requests at proxy level"})]}),(0,a.jsxs)("div",{className:"flex items-center gap-3",children:["saved"===i&&(0,a.jsxs)("span",{className:"text-xs font-medium text-emerald-500 flex items-center gap-1",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"check_circle"})," Saved"]}),(0,a.jsx)(n.lM,{checked:e.enabled,onChange:()=>m({enabled:!e.enabled}),disabled:s})]})]}),e.enabled&&(0,a.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,a.jsxs)("div",{className:"relative",children:[(0,a.jsx)("textarea",{value:e.prompt,onChange:e=>{var s;return s=e.target.value,void(t(e=>({...e,prompt:s})),c&&clearTimeout(c),o(setTimeout(()=>{m({prompt:s})},800)))},placeholder:"Enter system prompt to inject into all requests...",rows:5,className:"w-full px-4 py-3 rounded-lg border border-border/50 bg-surface/30 text-sm placeholder:text-text-muted/50 resize-y min-h-[120px] focus:outline-none focus:ring-1 focus:ring-amber-500/30 focus:border-amber-500/50 transition-colors",disabled:s}),(0,a.jsxs)("div",{className:"absolute bottom-2 right-3 text-xs text-text-muted/60 tabular-nums",children:[e.prompt.length," chars"]})]}),(0,a.jsxs)("p",{className:"text-xs text-text-muted/70 flex items-center gap-1.5",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"info"}),"This prompt is prepended to the system message of every request. Use for global instructions, safety guidelines, or response formatting rules. Send ",(0,a.jsx)("code",{className:"px-1 py-0.5 rounded bg-surface/50",children:"_skipSystemPrompt: true"})," in a request to bypass."]})]})]})}let N=["input","output","cached","reasoning","cache_creation"],w={input:"Input",output:"Output",cached:"Cached",reasoning:"Reasoning",cache_creation:"Cache Write"};function k(){let[e,t]=(0,l.useState)({}),[s,r]=(0,l.useState)({}),[i,d]=(0,l.useState)(!0),[c,o]=(0,l.useState)(!1),[m,x]=(0,l.useState)(""),[u,p]=(0,l.useState)(null),[h,b]=(0,l.useState)(new Set),[g,j]=(0,l.useState)(""),[f,v]=(0,l.useState)(new Set);(0,l.useEffect)(()=>{y()},[]);let y=async()=>{d(!0);try{let[e,s]=await Promise.all([fetch("/api/pricing/models"),fetch("/api/pricing")]);e.ok&&t(await e.json()),s.ok&&r(await s.json())}catch(e){console.error("Failed to load pricing data:",e)}finally{d(!1)}},N=(0,l.useMemo)(()=>Object.entries(e).map(([e,t])=>({alias:e,...t,pricedModels:s[e]?Object.keys(s[e]).length:0})).sort((e,t)=>t.modelCount-e.modelCount),[e,s]),w=(0,l.useMemo)(()=>{if(!g.trim())return N;let e=g.toLowerCase();return N.filter(t=>t.alias.toLowerCase().includes(e)||t.id.toLowerCase().includes(e)||t.models.some(t=>t.id.toLowerCase().includes(e)||t.name.toLowerCase().includes(e)))},[N,g]),k=(0,l.useMemo)(()=>{let e=N.reduce((e,t)=>e+t.modelCount,0),t=Object.values(s).reduce((e,t)=>e+Object.keys(t).length,0);return{providers:N.length,totalModels:e,pricedCount:t}},[N,s]),S=(0,l.useCallback)(e=>{b(t=>{let s=new Set(t);return s.has(e)?s.delete(e):s.add(e),s})},[]),P=(0,l.useCallback)((e,t,s,a)=>{let l=parseFloat(a);isNaN(l)||l<0||(r(a=>{let r={...a};return r[e]||(r[e]={}),r[e][t]||(r[e][t]={input:0,output:0,cached:0,reasoning:0,cache_creation:0}),r[e][t]={...r[e][t],[s]:l},r}),v(t=>new Set(t).add(e)))},[]),$=(0,l.useCallback)(async e=>{o(!0),x("");try{let t=s[e]||{},a=await fetch("/api/pricing",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({[e]:t})});if(a.ok)x(`✅ ${e.toUpperCase()} saved`),v(t=>{let s=new Set(t);return s.delete(e),s}),setTimeout(()=>x(""),3e3);else{let e=await a.json();x(`❌ Error: ${e.error}`)}}catch(e){x(`❌ Save failed: ${e.message}`)}finally{o(!1)}},[s]),M=(0,l.useCallback)(async e=>{if(confirm(`Reset all pricing for ${e.toUpperCase()} to defaults?`))try{let t=await fetch(`/api/pricing?provider=${e}`,{method:"DELETE"});if(t.ok){let s=await t.json();r(s),x(`🔄 ${e.toUpperCase()} reset to defaults`),v(t=>{let s=new Set(t);return s.delete(e),s}),setTimeout(()=>x(""),3e3)}}catch(e){x(`❌ Reset failed: ${e.message}`)}},[]),T=(0,l.useCallback)(e=>{p(t=>t===e?null:e)},[]),A=(0,l.useMemo)(()=>u?w.filter(e=>e.alias===u):w,[w,u]);return i?(0,a.jsx)("div",{className:"flex items-center justify-center py-16",children:(0,a.jsx)("div",{className:"text-text-muted animate-pulse",children:"Loading pricing data..."})}):(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,a.jsxs)("div",{className:"flex items-start justify-between flex-wrap gap-4",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("h2",{className:"text-xl font-bold",children:"Model Pricing"}),(0,a.jsxs)("p",{className:"text-text-muted text-sm mt-1",children:["Configure cost rates per model • All rates in"," ",(0,a.jsx)("strong",{children:"$/1M tokens"})]})]}),(0,a.jsxs)("div",{className:"flex gap-3 text-sm",children:[(0,a.jsxs)("div",{className:"bg-bg-subtle rounded-lg px-3 py-2 text-center",children:[(0,a.jsx)("div",{className:"text-text-muted text-xs font-semibold",children:"Providers"}),(0,a.jsx)("div",{className:"text-lg font-bold",children:k.providers})]}),(0,a.jsxs)("div",{className:"bg-bg-subtle rounded-lg px-3 py-2 text-center",children:[(0,a.jsx)("div",{className:"text-text-muted text-xs font-semibold",children:"Registry"}),(0,a.jsx)("div",{className:"text-lg font-bold",children:k.totalModels})]}),(0,a.jsxs)("div",{className:"bg-bg-subtle rounded-lg px-3 py-2 text-center",children:[(0,a.jsx)("div",{className:"text-text-muted text-xs font-semibold",children:"Priced"}),(0,a.jsx)("div",{className:"text-lg font-bold text-success",children:k.pricedCount})]})]})]}),m&&(0,a.jsx)("div",{className:"px-3 py-2 rounded-lg bg-bg-subtle border border-border text-sm",children:m}),(0,a.jsxs)("div",{className:"flex gap-3 items-center flex-wrap",children:[(0,a.jsxs)("div",{className:"relative flex-1 min-w-[200px]",children:[(0,a.jsx)("span",{className:"material-symbols-outlined absolute left-3 top-1/2 -translate-y-1/2 text-text-muted text-lg",children:"search"}),(0,a.jsx)("input",{type:"text",placeholder:"Search providers or models...",value:g,onChange:e=>j(e.target.value),className:"w-full pl-10 pr-3 py-2 bg-bg-base border border-border rounded-lg focus:outline-none focus:border-primary text-sm"})]}),u&&(0,a.jsxs)("button",{onClick:()=>p(null),className:"px-3 py-2 text-xs bg-primary/10 text-primary border border-primary/20 rounded-lg hover:bg-primary/20 transition-colors flex items-center gap-1",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:"close"}),u.toUpperCase()," — Show All"]})]}),(0,a.jsx)("div",{className:"flex flex-wrap gap-1.5",children:N.map(e=>(0,a.jsxs)("button",{onClick:()=>T(e.alias),className:`px-2.5 py-1 rounded-md text-xs font-medium transition-all ${u===e.alias?"bg-primary text-white shadow-sm":f.has(e.alias)?"bg-yellow-500/15 text-yellow-400 border border-yellow-500/30":"bg-bg-subtle text-text-muted hover:bg-bg-hover border border-transparent"}`,children:[e.alias.toUpperCase()," ",(0,a.jsxs)("span",{className:"opacity-60",children:["(",e.modelCount,")"]})]},e.alias))}),(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[A.map(e=>(0,a.jsx)(C,{provider:e,pricingData:s[e.alias]||{},isExpanded:h.has(e.alias),isEdited:f.has(e.alias),onToggle:()=>S(e.alias),onPricingChange:(t,s,a)=>P(e.alias,t,s,a),onSave:()=>$(e.alias),onReset:()=>M(e.alias),saving:c},e.alias)),0===A.length&&(0,a.jsx)("div",{className:"text-center py-12 text-text-muted",children:"No providers match your search."})]}),(0,a.jsxs)(n.Zp,{className:"p-4 mt-2",children:[(0,a.jsxs)("h3",{className:"text-sm font-semibold mb-2",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-sm align-middle mr-1",children:"info"}),"How Pricing Works"]}),(0,a.jsxs)("div",{className:"text-xs text-text-muted space-y-1",children:[(0,a.jsxs)("p",{children:[(0,a.jsx)("strong",{children:"Input"}),": tokens sent to the model •"," ",(0,a.jsx)("strong",{children:"Output"}),": tokens generated •"," ",(0,a.jsx)("strong",{children:"Cached"}),": reused input (~50% of input rate) •"," ",(0,a.jsx)("strong",{children:"Reasoning"}),": thinking tokens (falls back to Output) •"," ",(0,a.jsx)("strong",{children:"Cache Write"}),": creating cache entries (falls back to Input)"]}),(0,a.jsx)("p",{children:"Cost = (input \xd7 input_rate) + (output \xd7 output_rate) + (cached \xd7 cached_rate) per million tokens."})]})]})]})}function C({provider:e,pricingData:t,isExpanded:s,isEdited:l,onToggle:r,onPricingChange:i,onSave:n,onReset:d,saving:c}){let o=Object.keys(t).length,m="oauth"===e.authType?"OAuth":"apikey"===e.authType?"API Key":e.authType;return(0,a.jsxs)("div",{className:`border rounded-lg overflow-hidden transition-colors ${l?"border-yellow-500/40 bg-yellow-500/5":"border-border"}`,children:[(0,a.jsxs)("button",{onClick:r,className:"w-full flex items-center justify-between px-4 py-3 hover:bg-bg-hover/50 transition-colors text-left",children:[(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[(0,a.jsx)("span",{className:`material-symbols-outlined text-lg transition-transform ${s?"rotate-90":""}`,children:"chevron_right"}),(0,a.jsxs)("div",{children:[(0,a.jsx)("span",{className:"font-semibold text-sm",children:e.id.charAt(0).toUpperCase()+e.id.slice(1)}),(0,a.jsxs)("span",{className:"text-text-muted text-xs ml-2",children:["(",e.alias.toUpperCase(),")"]})]}),(0,a.jsx)("span",{className:"px-1.5 py-0.5 bg-bg-subtle text-text-muted text-[10px] rounded uppercase font-semibold",children:m}),(0,a.jsx)("span",{className:"px-1.5 py-0.5 bg-bg-subtle text-text-muted text-[10px] rounded uppercase font-semibold",children:e.format})]}),(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[l&&(0,a.jsx)("span",{className:"text-yellow-500 text-xs font-medium",children:"unsaved"}),(0,a.jsxs)("span",{className:"text-text-muted text-xs",children:[o,"/",e.modelCount," priced"]}),(0,a.jsx)("div",{className:"w-16 h-1.5 bg-bg-subtle rounded-full overflow-hidden",children:(0,a.jsx)("div",{className:"h-full bg-primary rounded-full transition-all",style:{width:`${e.modelCount>0?Math.round(o/e.modelCount*100):0}%`}})})]})]}),s&&(0,a.jsxs)("div",{className:"border-t border-border",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between px-4 py-2 bg-bg-subtle/50",children:[(0,a.jsxs)("span",{className:"text-xs text-text-muted",children:[e.modelCount," models •"," ",o," with pricing configured"]}),(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("button",{onClick:e=>{e.stopPropagation(),d()},className:"px-2.5 py-1 text-[11px] text-red-400 hover:bg-red-500/10 rounded border border-red-500/20 transition-colors",children:"Reset Defaults"}),(0,a.jsx)("button",{onClick:e=>{e.stopPropagation(),n()},disabled:c||!l,className:"px-2.5 py-1 text-[11px] bg-primary text-white rounded hover:bg-primary/90 transition-colors disabled:opacity-40",children:c?"Saving...":"Save Provider"})]})]}),(0,a.jsx)("div",{className:"overflow-x-auto",children:(0,a.jsxs)("table",{className:"w-full text-sm",children:[(0,a.jsx)("thead",{className:"text-[11px] text-text-muted uppercase bg-bg-subtle/30",children:(0,a.jsxs)("tr",{children:[(0,a.jsx)("th",{className:"px-4 py-2 text-left font-semibold",children:"Model"}),N.map(e=>(0,a.jsx)("th",{className:"px-2 py-2 text-right font-semibold w-24",children:w[e]},e))]})}),(0,a.jsx)("tbody",{className:"divide-y divide-border/50",children:e.models.map(e=>(0,a.jsx)(S,{model:e,pricing:t[e.id],onPricingChange:(t,s)=>i(e.id,t,s)},e.id))})]})})]})]})}function S({model:e,pricing:t,onPricingChange:s}){let l=t&&Object.values(t).some(e=>e>0);return(0,a.jsxs)("tr",{className:"hover:bg-bg-hover/30 group",children:[(0,a.jsx)("td",{className:"px-4 py-1.5",children:(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:`w-1.5 h-1.5 rounded-full ${l?"bg-success":"bg-text-muted/30"}`}),(0,a.jsx)("span",{className:"font-medium text-xs",children:e.name}),e.custom&&(0,a.jsx)("span",{className:"px-1 py-0.5 text-[8px] font-bold bg-blue-500/15 text-blue-400 border border-blue-500/20 rounded uppercase",children:"custom"}),(0,a.jsx)("span",{className:"text-text-muted text-[10px] opacity-0 group-hover:opacity-100 transition-opacity",children:e.id})]})}),N.map(e=>(0,a.jsx)("td",{className:"px-2 py-1.5",children:(0,a.jsx)("input",{type:"number",step:"0.01",min:"0",value:t?.[e]||0,onChange:t=>s(e,t.target.value),className:"w-full px-2 py-1 text-right text-xs bg-transparent border border-transparent hover:border-border focus:border-primary focus:bg-bg-base rounded transition-colors outline-none tabular-nums"})},e))]})}let P=[{id:"general",label:"General",icon:"settings"},{id:"ai",label:"AI",icon:"smart_toy"},{id:"security",label:"Security",icon:"shield"},{id:"routing",label:"Routing",icon:"route"},{id:"pricing",label:"Pricing",icon:"payments"},{id:"advanced",label:"Advanced",icon:"tune"}];function $(){let[e,t]=(0,l.useState)("general");return(0,a.jsx)("div",{className:"max-w-2xl mx-auto",children:(0,a.jsxs)("div",{className:"flex flex-col gap-6",children:[(0,a.jsx)("div",{role:"tablist","aria-label":"Settings sections",className:"inline-flex items-center p-1 rounded-lg bg-black/5 dark:bg-white/5 self-start",children:P.map(s=>(0,a.jsxs)("button",{role:"tab","aria-selected":e===s.id,tabIndex:e===s.id?0:-1,onClick:()=>t(s.id),className:(0,r.cn)("flex items-center gap-2 px-4 py-2 rounded-md font-medium transition-all text-sm",e===s.id?"bg-white dark:bg-white/10 text-text-main shadow-sm":"text-text-muted hover:text-text-main"),children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]","aria-hidden":"true",children:s.icon}),(0,a.jsx)("span",{className:"hidden sm:inline",children:s.label})]},s.id))}),(0,a.jsxs)("div",{role:"tabpanel","aria-label":P.find(t=>t.id===e)?.label,children:["general"===e&&(0,a.jsx)(a.Fragment,{children:(0,a.jsxs)("div",{className:"flex flex-col gap-6",children:[(0,a.jsx)(d,{}),(0,a.jsx)(g,{})]})}),"ai"===e&&(0,a.jsxs)("div",{className:"flex flex-col gap-6",children:[(0,a.jsx)(v,{}),(0,a.jsx)(y,{})]}),"security"===e&&(0,a.jsx)(m,{}),"routing"===e&&(0,a.jsxs)("div",{className:"flex flex-col gap-6",children:[(0,a.jsx)(u,{}),(0,a.jsx)(p,{})]}),"pricing"===e&&(0,a.jsx)(k,{}),"advanced"===e&&(0,a.jsx)(h,{})]}),(0,a.jsxs)("div",{className:"text-center text-sm text-text-muted py-4",children:[(0,a.jsxs)("p",{children:[i.vQ.name," v",i.vQ.version]}),(0,a.jsx)("p",{className:"mt-1",children:"Local Mode — All data stored on your machine"})]})]})})}},21680:(e,t,s)=>{Promise.resolve().then(s.bind(s,17618))}},e=>{e.O(0,[8500,600,8013,7896,1525,8441,3794,7358],()=>e(e.s=21680)),_N_E=e.O()}]);
@@ -0,0 +1 @@
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[410],{25287:(e,t,a)=>{Promise.resolve().then(a.bind(a,45448))},45448:(e,t,a)=>{"use strict";a.r(t),a.d(t,{default:()=>d});var c=a(95155),n=a(12115),i=a(73321),s=a(67578);let r={cc:{"claude-opus-4-5-20251101":{input:15,output:75,cached:7.5,reasoning:75,cache_creation:15},"claude-sonnet-4-5-20250929":{input:3,output:15,cached:1.5,reasoning:15,cache_creation:3},"claude-haiku-4-5-20251001":{input:.5,output:2.5,cached:.25,reasoning:2.5,cache_creation:.5}},cx:{"gpt-5.2-codex":{input:5,output:20,cached:2.5,reasoning:30,cache_creation:5},"gpt-5.2":{input:5,output:20,cached:2.5,reasoning:30,cache_creation:5},"gpt-5.1-codex-max":{input:8,output:32,cached:4,reasoning:48,cache_creation:8},"gpt-5.1-codex":{input:4,output:16,cached:2,reasoning:24,cache_creation:4},"gpt-5.1-codex-mini":{input:1.5,output:6,cached:.75,reasoning:9,cache_creation:1.5},"gpt-5.1":{input:4,output:16,cached:2,reasoning:24,cache_creation:4},"gpt-5-codex":{input:3,output:12,cached:1.5,reasoning:18,cache_creation:3},"gpt-5-codex-mini":{input:1,output:4,cached:.5,reasoning:6,cache_creation:1}},gc:{"gemini-3-flash-preview":{input:.5,output:3,cached:.03,reasoning:4.5,cache_creation:.5},"gemini-3-pro-preview":{input:2,output:12,cached:.25,reasoning:18,cache_creation:2},"gemini-2.5-pro":{input:2,output:12,cached:.25,reasoning:18,cache_creation:2},"gemini-2.5-flash":{input:.3,output:2.5,cached:.03,reasoning:3.75,cache_creation:.3},"gemini-2.5-flash-lite":{input:.15,output:1.25,cached:.015,reasoning:1.875,cache_creation:.15}},qw:{"qwen3-coder-plus":{input:1,output:4,cached:.5,reasoning:6,cache_creation:1},"qwen3-coder-flash":{input:.5,output:2,cached:.25,reasoning:3,cache_creation:.5},"vision-model":{input:1.5,output:6,cached:.75,reasoning:9,cache_creation:1.5}},if:{"qwen3-coder-plus":{input:1,output:4,cached:.5,reasoning:6,cache_creation:1},"kimi-k2":{input:1,output:4,cached:.5,reasoning:6,cache_creation:1},"kimi-k2-thinking":{input:1.5,output:6,cached:.75,reasoning:9,cache_creation:1.5},"deepseek-r1":{input:.75,output:3,cached:.375,reasoning:4.5,cache_creation:.75},"deepseek-v3.2-chat":{input:.5,output:2,cached:.25,reasoning:3,cache_creation:.5},"deepseek-v3.2-reasoner":{input:.75,output:3,cached:.375,reasoning:4.5,cache_creation:.75},"minimax-m2":{input:.5,output:2,cached:.25,reasoning:3,cache_creation:.5},"glm-4.6":{input:.5,output:2,cached:.25,reasoning:3,cache_creation:.5},"glm-4.7":{input:.75,output:3,cached:.375,reasoning:4.5,cache_creation:.75}},ag:{"gemini-3-pro-low":{input:2,output:12,cached:.25,reasoning:18,cache_creation:2},"gemini-3-pro-high":{input:4,output:18,cached:.5,reasoning:27,cache_creation:4},"gemini-3-flash":{input:.5,output:3,cached:.03,reasoning:4.5,cache_creation:.5},"gemini-2.5-flash":{input:.3,output:2.5,cached:.03,reasoning:3.75,cache_creation:.3},"claude-sonnet-4-5":{input:3,output:15,cached:.3,reasoning:22.5,cache_creation:3},"claude-sonnet-4-5-thinking":{input:3,output:15,cached:.3,reasoning:22.5,cache_creation:3},"claude-opus-4-5-thinking":{input:5,output:25,cached:.5,reasoning:37.5,cache_creation:5}},gh:{"gpt-5":{input:3,output:12,cached:1.5,reasoning:18,cache_creation:3},"gpt-5-mini":{input:.75,output:3,cached:.375,reasoning:4.5,cache_creation:.75},"gpt-5.1-codex":{input:4,output:16,cached:2,reasoning:24,cache_creation:4},"gpt-5.1-codex-max":{input:8,output:32,cached:4,reasoning:48,cache_creation:8},"gpt-4.1":{input:2.5,output:10,cached:1.25,reasoning:15,cache_creation:2.5},"claude-4.5-sonnet":{input:3,output:15,cached:.3,reasoning:22.5,cache_creation:3},"claude-4.5-opus":{input:5,output:25,cached:.5,reasoning:37.5,cache_creation:5},"claude-4.5-haiku":{input:.5,output:2.5,cached:.05,reasoning:3.75,cache_creation:.5},"gemini-3-pro":{input:2,output:12,cached:.25,reasoning:18,cache_creation:2},"gemini-3-flash":{input:.5,output:3,cached:.03,reasoning:4.5,cache_creation:.5},"gemini-2.5-pro":{input:2,output:12,cached:.25,reasoning:18,cache_creation:2},"grok-code-fast-1":{input:.5,output:2,cached:.25,reasoning:3,cache_creation:.5}},openai:{"gpt-4o":{input:2.5,output:10,cached:1.25,reasoning:15,cache_creation:2.5},"gpt-4o-mini":{input:.15,output:.6,cached:.075,reasoning:.9,cache_creation:.15},"gpt-4-turbo":{input:10,output:30,cached:5,reasoning:45,cache_creation:10},o1:{input:15,output:60,cached:7.5,reasoning:90,cache_creation:15},"o1-mini":{input:3,output:12,cached:1.5,reasoning:18,cache_creation:3}},anthropic:{"claude-sonnet-4-20250514":{input:3,output:15,cached:1.5,reasoning:15,cache_creation:3},"claude-opus-4-20250514":{input:15,output:75,cached:7.5,reasoning:112.5,cache_creation:15},"claude-3-5-sonnet-20241022":{input:3,output:15,cached:1.5,reasoning:15,cache_creation:3}},gemini:{"gemini-3-pro-preview":{input:2,output:12,cached:.25,reasoning:18,cache_creation:2},"gemini-2.5-pro":{input:2,output:12,cached:.25,reasoning:18,cache_creation:2},"gemini-2.5-flash":{input:.3,output:2.5,cached:.03,reasoning:3.75,cache_creation:.3},"gemini-2.5-flash-lite":{input:.15,output:1.25,cached:.015,reasoning:1.875,cache_creation:.15}},openrouter:{auto:{input:2,output:8,cached:1,reasoning:12,cache_creation:2}},glm:{"glm-4.7":{input:.75,output:3,cached:.375,reasoning:4.5,cache_creation:.75},"glm-4.6":{input:.5,output:2,cached:.25,reasoning:3,cache_creation:.5},"glm-4.6v":{input:.75,output:3,cached:.375,reasoning:4.5,cache_creation:.75}},kimi:{"kimi-latest":{input:1,output:4,cached:.5,reasoning:6,cache_creation:1}},minimax:{"MiniMax-M2.1":{input:.5,output:2,cached:.25,reasoning:3,cache_creation:.5}}};function o({isOpen:e,onClose:t,onSave:a}){let[i,s]=(0,n.useState)({}),[o,d]=(0,n.useState)(!0),[l,u]=(0,n.useState)(!1);(0,n.useEffect)(()=>{e&&p()},[e]);let p=async()=>{d(!0);try{let e=await fetch("/api/pricing");if(e.ok){let t=await e.json();s(t)}else s(r)}catch(e){console.error("Failed to load pricing:",e),s(r)}finally{d(!1)}},h=async()=>{u(!0);try{let e=await fetch("/api/pricing",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)});if(e.ok)a?.(),t();else{let t=await e.json();alert(`Failed to save pricing: ${t.error}`)}}catch(e){console.error("Failed to save pricing:",e),alert("Failed to save pricing")}finally{u(!1)}},x=async()=>{if(confirm("Reset all pricing to defaults? This cannot be undone."))try{(await fetch("/api/pricing",{method:"DELETE"})).ok&&s(r)}catch(e){console.error("Failed to reset pricing:",e),alert("Failed to reset pricing")}};if(!e)return null;let m=Object.keys(i).sort(),g=["input","output","cached","reasoning","cache_creation"];return(0,c.jsx)("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:(0,c.jsxs)("div",{className:"bg-bg-base border border-border rounded-lg shadow-xl max-w-6xl w-full max-h-[90vh] overflow-hidden flex flex-col",children:[(0,c.jsxs)("div",{className:"p-4 border-b border-border flex items-center justify-between",children:[(0,c.jsx)("h2",{className:"text-xl font-semibold",children:"Pricing Configuration"}),(0,c.jsx)("button",{onClick:t,className:"text-text-muted hover:text-text text-2xl leading-none",children:"\xd7"})]}),(0,c.jsx)("div",{className:"flex-1 overflow-auto p-4",children:o?(0,c.jsx)("div",{className:"text-center py-8 text-text-muted",children:"Loading pricing data..."}):(0,c.jsxs)("div",{className:"space-y-6",children:[(0,c.jsxs)("div",{className:"bg-bg-subtle border border-border rounded-lg p-3 text-sm",children:[(0,c.jsx)("p",{className:"font-medium mb-1",children:"Pricing Rates Format"}),(0,c.jsxs)("p",{className:"text-text-muted",children:["All rates are in ",(0,c.jsx)("strong",{children:"dollars per million tokens"})," ($/1M tokens). Example: Input rate of 2.50 means $2.50 per 1,000,000 input tokens."]})]}),m.map(e=>{let t=Object.keys(i[e]).sort();return(0,c.jsxs)("div",{className:"border border-border rounded-lg overflow-hidden",children:[(0,c.jsx)("div",{className:"bg-bg-subtle px-4 py-2 font-semibold text-sm",children:e.toUpperCase()}),(0,c.jsx)("div",{className:"overflow-x-auto",children:(0,c.jsxs)("table",{className:"w-full text-sm",children:[(0,c.jsx)("thead",{className:"bg-bg-hover text-text-muted uppercase text-xs",children:(0,c.jsxs)("tr",{children:[(0,c.jsx)("th",{className:"px-3 py-2 text-left",children:"Model"}),(0,c.jsx)("th",{className:"px-3 py-2 text-right",children:"Input"}),(0,c.jsx)("th",{className:"px-3 py-2 text-right",children:"Output"}),(0,c.jsx)("th",{className:"px-3 py-2 text-right",children:"Cached"}),(0,c.jsx)("th",{className:"px-3 py-2 text-right",children:"Reasoning"}),(0,c.jsx)("th",{className:"px-3 py-2 text-right",children:"Cache Creation"})]})}),(0,c.jsx)("tbody",{className:"divide-y divide-border",children:t.map(t=>(0,c.jsxs)("tr",{className:"hover:bg-bg-subtle/50",children:[(0,c.jsx)("td",{className:"px-3 py-2 font-medium",children:t}),g.map(a=>(0,c.jsx)("td",{className:"px-3 py-2",children:(0,c.jsx)("input",{type:"number",step:"0.01",min:"0",value:i[e][t][a]||0,onChange:c=>{let n;!isNaN(n=parseFloat(c.target.value))&&!(n<0)&&s(c=>{let i={...c};return i[e]||(i[e]={}),i[e][t]||(i[e][t]={}),i[e][t][a]=n,i})},className:"w-20 px-2 py-1 text-right bg-bg-base border border-border rounded focus:outline-none focus:border-primary"})},a))]},t))})]})})]},e)}),0===m.length&&(0,c.jsx)("div",{className:"text-center py-8 text-text-muted",children:"No pricing data available"})]})}),(0,c.jsxs)("div",{className:"p-4 border-t border-border flex items-center justify-between gap-2",children:[(0,c.jsx)("button",{onClick:x,className:"px-4 py-2 text-sm text-red-500 hover:bg-red-500/10 rounded border border-red-500/20 transition-colors",disabled:l,children:"Reset to Defaults"}),(0,c.jsxs)("div",{className:"flex gap-2",children:[(0,c.jsx)("button",{onClick:t,className:"px-4 py-2 text-sm text-text-muted hover:text-text border border-border rounded transition-colors",disabled:l,children:"Cancel"}),(0,c.jsx)("button",{onClick:h,className:"px-4 py-2 text-sm bg-primary text-white rounded hover:bg-primary/90 transition-colors disabled:opacity-50",disabled:l,children:l?"Saving...":"Save Changes"})]})]})]})})}function d(){(0,i.useRouter)();let[e,t]=(0,n.useState)(!1),[a,r]=(0,n.useState)(null),[d,l]=(0,n.useState)(!0);(0,n.useEffect)(()=>{u()},[]);let u=async()=>{l(!0);try{let e=await fetch("/api/pricing");if(e.ok){let t=await e.json();r(t)}}catch(e){console.error("Failed to load pricing:",e)}finally{l(!1)}};return(0,c.jsxs)("div",{className:"max-w-6xl mx-auto p-6 space-y-6",children:[(0,c.jsxs)("div",{className:"flex items-center justify-between",children:[(0,c.jsxs)("div",{children:[(0,c.jsx)("h1",{className:"text-3xl font-bold",children:"Pricing Settings"}),(0,c.jsx)("p",{className:"text-text-muted mt-1",children:"Configure pricing rates for cost tracking and calculations"})]}),(0,c.jsx)("button",{onClick:()=>t(!0),className:"px-4 py-2 bg-primary text-white rounded hover:bg-primary/90 transition-colors",children:"Edit Pricing"})]}),(0,c.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[(0,c.jsxs)(s.default,{className:"p-4",children:[(0,c.jsx)("div",{className:"text-text-muted text-sm uppercase font-semibold",children:"Total Models"}),(0,c.jsx)("div",{className:"text-2xl font-bold mt-1",children:d?"...":(()=>{if(!a)return 0;let e=0;for(let t in a)e+=Object.keys(a[t]).length;return e})()})]}),(0,c.jsxs)(s.default,{className:"p-4",children:[(0,c.jsx)("div",{className:"text-text-muted text-sm uppercase font-semibold",children:"Providers"}),(0,c.jsx)("div",{className:"text-2xl font-bold mt-1",children:d?"...":(!a?[]:Object.keys(a).sort()).length})]}),(0,c.jsxs)(s.default,{className:"p-4",children:[(0,c.jsx)("div",{className:"text-text-muted text-sm uppercase font-semibold",children:"Status"}),(0,c.jsx)("div",{className:"text-2xl font-bold mt-1 text-success",children:d?"...":"Active"})]})]}),(0,c.jsxs)(s.default,{className:"p-6",children:[(0,c.jsx)("h2",{className:"text-xl font-semibold mb-4",children:"How Pricing Works"}),(0,c.jsxs)("div",{className:"space-y-3 text-sm text-text-muted",children:[(0,c.jsxs)("p",{children:[(0,c.jsx)("strong",{children:"Cost Calculation:"})," Costs are calculated based on token usage and pricing rates. Each request's cost is determined by: (input_tokens \xd7 input_rate) + (output_tokens \xd7 output_rate) + (cached_tokens \xd7 cached_rate)"]}),(0,c.jsxs)("p",{children:[(0,c.jsx)("strong",{children:"Pricing Format:"})," All rates are in"," ",(0,c.jsx)("strong",{children:"dollars per million tokens"})," ($/1M tokens). Example: An input rate of 2.50 means $2.50 per 1,000,000 input tokens."]}),(0,c.jsx)("p",{children:(0,c.jsx)("strong",{children:"Token Types:"})}),(0,c.jsxs)("ul",{className:"list-disc list-inside ml-4 space-y-1",children:[(0,c.jsxs)("li",{children:[(0,c.jsx)("strong",{children:"Input:"})," Standard prompt tokens"]}),(0,c.jsxs)("li",{children:[(0,c.jsx)("strong",{children:"Output:"})," Completion/response tokens"]}),(0,c.jsxs)("li",{children:[(0,c.jsx)("strong",{children:"Cached:"})," Cached input tokens (typically 50% of input rate)"]}),(0,c.jsxs)("li",{children:[(0,c.jsx)("strong",{children:"Reasoning:"})," Special reasoning/thinking tokens (fallback to output rate)"]}),(0,c.jsxs)("li",{children:[(0,c.jsx)("strong",{children:"Cache Creation:"})," Tokens used to create cache entries (fallback to input rate)"]})]}),(0,c.jsxs)("p",{children:[(0,c.jsx)("strong",{children:"Custom Pricing:"})," You can override default pricing for specific models. Reset to defaults anytime to restore standard rates."]})]})]}),(0,c.jsxs)(s.default,{className:"p-6",children:[(0,c.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,c.jsx)("h2",{className:"text-xl font-semibold",children:"Current Pricing Overview"}),(0,c.jsx)("button",{onClick:()=>t(!0),className:"text-primary hover:underline text-sm",children:"View Full Details"})]}),d?(0,c.jsx)("div",{className:"text-center py-4 text-text-muted",children:"Loading pricing data..."}):a?(0,c.jsxs)("div",{className:"space-y-3",children:[Object.keys(a).slice(0,5).map(e=>(0,c.jsxs)("div",{className:"text-sm",children:[(0,c.jsxs)("span",{className:"font-semibold",children:[e.toUpperCase(),":"]})," ",(0,c.jsxs)("span",{className:"text-text-muted",children:[Object.keys(a[e]).length," models"]})]},e)),Object.keys(a).length>5&&(0,c.jsxs)("div",{className:"text-sm text-text-muted",children:["+ ",Object.keys(a).length-5," more providers"]})]}):(0,c.jsx)("div",{className:"text-text-muted",children:"No pricing data available"})]}),e&&(0,c.jsx)(o,{isOpen:e,onClose:()=>t(!1),onSave:()=>{u()}})]})}},61592:(e,t,a)=>{"use strict";function c(...e){return e.filter(Boolean).join(" ").replace(/\s+/g," ").trim()}a.d(t,{cn:()=>c})},67578:(e,t,a)=>{"use strict";a.d(t,{default:()=>i});var c=a(95155),n=a(61592);function i({children:e,title:t,subtitle:a,icon:i,action:s,padding:r="md",hover:o=!1,className:d,...l}){return(0,c.jsxs)("div",{className:(0,n.cn)("bg-surface","border border-black/5 dark:border-white/5","rounded-lg shadow-sm",o&&"hover:shadow-md hover:border-primary/30 transition-all cursor-pointer",{none:"",xs:"p-3",sm:"p-4",md:"p-6",lg:"p-8"}[r],d),...l,children:[(t||s)&&(0,c.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,c.jsxs)("div",{className:"flex items-center gap-3",children:[i&&(0,c.jsx)("div",{className:"p-2 rounded-lg bg-bg text-text-muted",children:(0,c.jsx)("span",{className:"material-symbols-outlined text-[20px]",children:i})}),(0,c.jsxs)("div",{children:[t&&(0,c.jsx)("h3",{className:"text-text-main font-semibold",children:t}),a&&(0,c.jsx)("p",{className:"text-sm text-text-muted",children:a})]})]}),s]}),e]})}i.Section=function({children:e,className:t,...a}){return(0,c.jsx)("div",{className:(0,n.cn)("p-4 rounded-lg","bg-black/[0.02] dark:bg-white/[0.02]","border border-black/5 dark:border-white/5",t),...a,children:e})},i.Row=function({children:e,className:t,...a}){return(0,c.jsx)("div",{className:(0,n.cn)("p-3 -mx-3 px-3 transition-colors","border-b border-black/5 dark:border-white/5 last:border-b-0","hover:bg-black/[0.02] dark:hover:bg-white/[0.02]",t),...a,children:e})},i.ListItem=function({children:e,actions:t,className:a,...i}){return(0,c.jsxs)("div",{className:(0,n.cn)("group flex items-center justify-between p-3 -mx-3 px-3","border-b border-black/[0.03] dark:border-white/[0.03] last:border-b-0","hover:bg-black/[0.02] dark:hover:bg-white/[0.02]","transition-colors",a),...i,children:[(0,c.jsx)("div",{className:"flex-1 min-w-0",children:e}),t&&(0,c.jsx)("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 focus-within:opacity-100 transition-opacity",children:t})]})}},73321:(e,t,a)=>{"use strict";var c=a(74645);a.o(c,"useParams")&&a.d(t,{useParams:function(){return c.useParams}}),a.o(c,"usePathname")&&a.d(t,{usePathname:function(){return c.usePathname}}),a.o(c,"useRouter")&&a.d(t,{useRouter:function(){return c.useRouter}}),a.o(c,"useSearchParams")&&a.d(t,{useSearchParams:function(){return c.useSearchParams}})}},e=>{e.O(0,[8441,3794,7358],()=>e(e.s=25287)),_N_E=e.O()}]);