9router 0.3.49 → 0.3.50

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 (333) hide show
  1. package/app/.next/BUILD_ID +1 -1
  2. package/app/.next/app-path-routes-manifest.json +41 -41
  3. package/app/.next/build-manifest.json +2 -2
  4. package/app/.next/server/app/(dashboard)/dashboard/cli-tools/page_client-reference-manifest.js +1 -1
  5. package/app/.next/server/app/(dashboard)/dashboard/combos/page_client-reference-manifest.js +1 -1
  6. package/app/.next/server/app/(dashboard)/dashboard/console-log/page_client-reference-manifest.js +1 -1
  7. package/app/.next/server/app/(dashboard)/dashboard/endpoint/page_client-reference-manifest.js +1 -1
  8. package/app/.next/server/app/(dashboard)/dashboard/mitm/page_client-reference-manifest.js +1 -1
  9. package/app/.next/server/app/(dashboard)/dashboard/page_client-reference-manifest.js +1 -1
  10. package/app/.next/server/app/(dashboard)/dashboard/profile/page_client-reference-manifest.js +1 -1
  11. package/app/.next/server/app/(dashboard)/dashboard/providers/[id]/page.js +1 -1
  12. package/app/.next/server/app/(dashboard)/dashboard/providers/[id]/page_client-reference-manifest.js +1 -1
  13. package/app/.next/server/app/(dashboard)/dashboard/providers/new/page_client-reference-manifest.js +1 -1
  14. package/app/.next/server/app/(dashboard)/dashboard/providers/page_client-reference-manifest.js +1 -1
  15. package/app/.next/server/app/(dashboard)/dashboard/proxy-pools/page_client-reference-manifest.js +1 -1
  16. package/app/.next/server/app/(dashboard)/dashboard/quota/page_client-reference-manifest.js +1 -1
  17. package/app/.next/server/app/(dashboard)/dashboard/translator/page_client-reference-manifest.js +1 -1
  18. package/app/.next/server/app/(dashboard)/dashboard/usage/page_client-reference-manifest.js +1 -1
  19. package/app/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
  20. package/app/.next/server/app/_global-error.html +2 -2
  21. package/app/.next/server/app/_global-error.rsc +1 -1
  22. package/app/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  23. package/app/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
  24. package/app/.next/server/app/_global-error.segments/_global-error.segment.rsc +1 -1
  25. package/app/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  26. package/app/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  27. package/app/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  28. package/app/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  29. package/app/.next/server/app/_not-found.html +1 -1
  30. package/app/.next/server/app/_not-found.rsc +3 -3
  31. package/app/.next/server/app/_not-found.segments/_full.segment.rsc +3 -3
  32. package/app/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
  33. package/app/.next/server/app/_not-found.segments/_index.segment.rsc +3 -3
  34. package/app/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
  35. package/app/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
  36. package/app/.next/server/app/_not-found.segments/_tree.segment.rsc +1 -1
  37. package/app/.next/server/app/api/auth/login/route.js +1 -1
  38. package/app/.next/server/app/api/auth/login/route.js.nft.json +1 -1
  39. package/app/.next/server/app/api/auth/login/route_client-reference-manifest.js +1 -1
  40. package/app/.next/server/app/api/auth/logout/route_client-reference-manifest.js +1 -1
  41. package/app/.next/server/app/api/cli-tools/antigravity-mitm/alias/route_client-reference-manifest.js +1 -1
  42. package/app/.next/server/app/api/cli-tools/antigravity-mitm/route_client-reference-manifest.js +1 -1
  43. package/app/.next/server/app/api/cli-tools/claude-settings/route_client-reference-manifest.js +1 -1
  44. package/app/.next/server/app/api/cli-tools/codex-settings/route_client-reference-manifest.js +1 -1
  45. package/app/.next/server/app/api/cli-tools/copilot-settings/route_client-reference-manifest.js +1 -1
  46. package/app/.next/server/app/api/cli-tools/droid-settings/route_client-reference-manifest.js +1 -1
  47. package/app/.next/server/app/api/cli-tools/openclaw-settings/route_client-reference-manifest.js +1 -1
  48. package/app/.next/server/app/api/cli-tools/opencode-settings/route_client-reference-manifest.js +1 -1
  49. package/app/.next/server/app/api/cloud/auth/route_client-reference-manifest.js +1 -1
  50. package/app/.next/server/app/api/cloud/credentials/update/route_client-reference-manifest.js +1 -1
  51. package/app/.next/server/app/api/cloud/model/resolve/route_client-reference-manifest.js +1 -1
  52. package/app/.next/server/app/api/cloud/models/alias/route_client-reference-manifest.js +1 -1
  53. package/app/.next/server/app/api/combos/[id]/route_client-reference-manifest.js +1 -1
  54. package/app/.next/server/app/api/combos/route_client-reference-manifest.js +1 -1
  55. package/app/.next/server/app/api/init/route_client-reference-manifest.js +1 -1
  56. package/app/.next/server/app/api/keys/[id]/route_client-reference-manifest.js +1 -1
  57. package/app/.next/server/app/api/keys/route_client-reference-manifest.js +1 -1
  58. package/app/.next/server/app/api/locale/route_client-reference-manifest.js +1 -1
  59. package/app/.next/server/app/api/models/alias/route_client-reference-manifest.js +1 -1
  60. package/app/.next/server/app/api/models/route.js +1 -1
  61. package/app/.next/server/app/api/models/route_client-reference-manifest.js +1 -1
  62. package/app/.next/server/app/api/models/test/route_client-reference-manifest.js +1 -1
  63. package/app/.next/server/app/api/oauth/[provider]/[action]/route.js.nft.json +1 -1
  64. package/app/.next/server/app/api/oauth/[provider]/[action]/route_client-reference-manifest.js +1 -1
  65. package/app/.next/server/app/api/oauth/cursor/auto-import/route_client-reference-manifest.js +1 -1
  66. package/app/.next/server/app/api/oauth/cursor/import/route_client-reference-manifest.js +1 -1
  67. package/app/.next/server/app/api/oauth/iflow/cookie/route_client-reference-manifest.js +1 -1
  68. package/app/.next/server/app/api/oauth/kiro/auto-import/route_client-reference-manifest.js +1 -1
  69. package/app/.next/server/app/api/oauth/kiro/import/route_client-reference-manifest.js +1 -1
  70. package/app/.next/server/app/api/oauth/kiro/social-authorize/route_client-reference-manifest.js +1 -1
  71. package/app/.next/server/app/api/oauth/kiro/social-exchange/route_client-reference-manifest.js +1 -1
  72. package/app/.next/server/app/api/pricing/route_client-reference-manifest.js +1 -1
  73. package/app/.next/server/app/api/provider-nodes/[id]/route_client-reference-manifest.js +1 -1
  74. package/app/.next/server/app/api/provider-nodes/route.js +1 -1
  75. package/app/.next/server/app/api/provider-nodes/route_client-reference-manifest.js +1 -1
  76. package/app/.next/server/app/api/provider-nodes/validate/route_client-reference-manifest.js +1 -1
  77. package/app/.next/server/app/api/providers/[id]/models/route.js +1 -1
  78. package/app/.next/server/app/api/providers/[id]/models/route.js.nft.json +1 -1
  79. package/app/.next/server/app/api/providers/[id]/models/route_client-reference-manifest.js +1 -1
  80. package/app/.next/server/app/api/providers/[id]/route_client-reference-manifest.js +1 -1
  81. package/app/.next/server/app/api/providers/[id]/test/route_client-reference-manifest.js +1 -1
  82. package/app/.next/server/app/api/providers/[id]/test-models/route.js +1 -1
  83. package/app/.next/server/app/api/providers/[id]/test-models/route_client-reference-manifest.js +1 -1
  84. package/app/.next/server/app/api/providers/client/route_client-reference-manifest.js +1 -1
  85. package/app/.next/server/app/api/providers/route.js +1 -1
  86. package/app/.next/server/app/api/providers/route_client-reference-manifest.js +1 -1
  87. package/app/.next/server/app/api/providers/test-batch/route_client-reference-manifest.js +1 -1
  88. package/app/.next/server/app/api/providers/validate/route.js +1 -1
  89. package/app/.next/server/app/api/providers/validate/route_client-reference-manifest.js +1 -1
  90. package/app/.next/server/app/api/proxy-pools/[id]/route_client-reference-manifest.js +1 -1
  91. package/app/.next/server/app/api/proxy-pools/[id]/test/route_client-reference-manifest.js +1 -1
  92. package/app/.next/server/app/api/proxy-pools/route_client-reference-manifest.js +1 -1
  93. package/app/.next/server/app/api/settings/database/route_client-reference-manifest.js +1 -1
  94. package/app/.next/server/app/api/settings/proxy-test/route_client-reference-manifest.js +1 -1
  95. package/app/.next/server/app/api/settings/require-login/route_client-reference-manifest.js +1 -1
  96. package/app/.next/server/app/api/settings/route_client-reference-manifest.js +1 -1
  97. package/app/.next/server/app/api/shutdown/route_client-reference-manifest.js +1 -1
  98. package/app/.next/server/app/api/tags/route_client-reference-manifest.js +1 -1
  99. package/app/.next/server/app/api/translator/console-logs/route.js +1 -1
  100. package/app/.next/server/app/api/translator/console-logs/route_client-reference-manifest.js +1 -1
  101. package/app/.next/server/app/api/translator/console-logs/stream/route.js +2 -2
  102. package/app/.next/server/app/api/translator/console-logs/stream/route_client-reference-manifest.js +1 -1
  103. package/app/.next/server/app/api/translator/load/route_client-reference-manifest.js +1 -1
  104. package/app/.next/server/app/api/translator/save/route_client-reference-manifest.js +1 -1
  105. package/app/.next/server/app/api/translator/send/route.js.nft.json +1 -1
  106. package/app/.next/server/app/api/translator/send/route_client-reference-manifest.js +1 -1
  107. package/app/.next/server/app/api/translator/translate/route.js +1 -1
  108. package/app/.next/server/app/api/translator/translate/route.js.nft.json +1 -1
  109. package/app/.next/server/app/api/translator/translate/route_client-reference-manifest.js +1 -1
  110. package/app/.next/server/app/api/tunnel/disable/route_client-reference-manifest.js +1 -1
  111. package/app/.next/server/app/api/tunnel/enable/route_client-reference-manifest.js +1 -1
  112. package/app/.next/server/app/api/tunnel/status/route_client-reference-manifest.js +1 -1
  113. package/app/.next/server/app/api/usage/[connectionId]/route.js.nft.json +1 -1
  114. package/app/.next/server/app/api/usage/[connectionId]/route_client-reference-manifest.js +1 -1
  115. package/app/.next/server/app/api/usage/chart/route_client-reference-manifest.js +1 -1
  116. package/app/.next/server/app/api/usage/history/route_client-reference-manifest.js +1 -1
  117. package/app/.next/server/app/api/usage/providers/route.js +1 -1
  118. package/app/.next/server/app/api/usage/providers/route_client-reference-manifest.js +1 -1
  119. package/app/.next/server/app/api/usage/request-details/route_client-reference-manifest.js +1 -1
  120. package/app/.next/server/app/api/usage/request-logs/route_client-reference-manifest.js +1 -1
  121. package/app/.next/server/app/api/usage/stats/route_client-reference-manifest.js +1 -1
  122. package/app/.next/server/app/api/usage/stream/route_client-reference-manifest.js +1 -1
  123. package/app/.next/server/app/api/v1/api/chat/route.js.nft.json +1 -1
  124. package/app/.next/server/app/api/v1/api/chat/route_client-reference-manifest.js +1 -1
  125. package/app/.next/server/app/api/v1/chat/completions/route.js.nft.json +1 -1
  126. package/app/.next/server/app/api/v1/chat/completions/route_client-reference-manifest.js +1 -1
  127. package/app/.next/server/app/api/v1/embeddings/route.js.nft.json +1 -1
  128. package/app/.next/server/app/api/v1/embeddings/route_client-reference-manifest.js +1 -1
  129. package/app/.next/server/app/api/v1/messages/count_tokens/route_client-reference-manifest.js +1 -1
  130. package/app/.next/server/app/api/v1/messages/route.js.nft.json +1 -1
  131. package/app/.next/server/app/api/v1/messages/route_client-reference-manifest.js +1 -1
  132. package/app/.next/server/app/api/v1/models/route.js +1 -1
  133. package/app/.next/server/app/api/v1/models/route_client-reference-manifest.js +1 -1
  134. package/app/.next/server/app/api/v1/responses/route.js.nft.json +1 -1
  135. package/app/.next/server/app/api/v1/responses/route_client-reference-manifest.js +1 -1
  136. package/app/.next/server/app/api/v1/route_client-reference-manifest.js +1 -1
  137. package/app/.next/server/app/api/v1beta/models/[...path]/route.js.nft.json +1 -1
  138. package/app/.next/server/app/api/v1beta/models/[...path]/route_client-reference-manifest.js +1 -1
  139. package/app/.next/server/app/api/v1beta/models/route.js +1 -1
  140. package/app/.next/server/app/api/v1beta/models/route_client-reference-manifest.js +1 -1
  141. package/app/.next/server/app/api/version/route.js +1 -1
  142. package/app/.next/server/app/api/version/route_client-reference-manifest.js +1 -1
  143. package/app/.next/server/app/callback/page_client-reference-manifest.js +1 -1
  144. package/app/.next/server/app/callback.html +1 -1
  145. package/app/.next/server/app/callback.rsc +3 -3
  146. package/app/.next/server/app/callback.segments/_full.segment.rsc +3 -3
  147. package/app/.next/server/app/callback.segments/_head.segment.rsc +1 -1
  148. package/app/.next/server/app/callback.segments/_index.segment.rsc +3 -3
  149. package/app/.next/server/app/callback.segments/_tree.segment.rsc +1 -1
  150. package/app/.next/server/app/callback.segments/callback/__PAGE__.segment.rsc +1 -1
  151. package/app/.next/server/app/callback.segments/callback.segment.rsc +1 -1
  152. package/app/.next/server/app/dashboard/cli-tools.html +1 -1
  153. package/app/.next/server/app/dashboard/cli-tools.rsc +5 -5
  154. package/app/.next/server/app/dashboard/cli-tools.segments/!KGRhc2hib2FyZCk/dashboard/cli-tools/__PAGE__.segment.rsc +2 -2
  155. package/app/.next/server/app/dashboard/cli-tools.segments/!KGRhc2hib2FyZCk/dashboard/cli-tools.segment.rsc +1 -1
  156. package/app/.next/server/app/dashboard/cli-tools.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  157. package/app/.next/server/app/dashboard/cli-tools.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  158. package/app/.next/server/app/dashboard/cli-tools.segments/_full.segment.rsc +5 -5
  159. package/app/.next/server/app/dashboard/cli-tools.segments/_head.segment.rsc +1 -1
  160. package/app/.next/server/app/dashboard/cli-tools.segments/_index.segment.rsc +3 -3
  161. package/app/.next/server/app/dashboard/cli-tools.segments/_tree.segment.rsc +1 -1
  162. package/app/.next/server/app/dashboard/combos.html +1 -1
  163. package/app/.next/server/app/dashboard/combos.rsc +5 -5
  164. package/app/.next/server/app/dashboard/combos.segments/!KGRhc2hib2FyZCk/dashboard/combos/__PAGE__.segment.rsc +2 -2
  165. package/app/.next/server/app/dashboard/combos.segments/!KGRhc2hib2FyZCk/dashboard/combos.segment.rsc +1 -1
  166. package/app/.next/server/app/dashboard/combos.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  167. package/app/.next/server/app/dashboard/combos.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  168. package/app/.next/server/app/dashboard/combos.segments/_full.segment.rsc +5 -5
  169. package/app/.next/server/app/dashboard/combos.segments/_head.segment.rsc +1 -1
  170. package/app/.next/server/app/dashboard/combos.segments/_index.segment.rsc +3 -3
  171. package/app/.next/server/app/dashboard/combos.segments/_tree.segment.rsc +1 -1
  172. package/app/.next/server/app/dashboard/endpoint.html +1 -1
  173. package/app/.next/server/app/dashboard/endpoint.rsc +5 -5
  174. package/app/.next/server/app/dashboard/endpoint.segments/!KGRhc2hib2FyZCk/dashboard/endpoint/__PAGE__.segment.rsc +2 -2
  175. package/app/.next/server/app/dashboard/endpoint.segments/!KGRhc2hib2FyZCk/dashboard/endpoint.segment.rsc +1 -1
  176. package/app/.next/server/app/dashboard/endpoint.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  177. package/app/.next/server/app/dashboard/endpoint.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  178. package/app/.next/server/app/dashboard/endpoint.segments/_full.segment.rsc +5 -5
  179. package/app/.next/server/app/dashboard/endpoint.segments/_head.segment.rsc +1 -1
  180. package/app/.next/server/app/dashboard/endpoint.segments/_index.segment.rsc +3 -3
  181. package/app/.next/server/app/dashboard/endpoint.segments/_tree.segment.rsc +1 -1
  182. package/app/.next/server/app/dashboard/mitm.html +1 -1
  183. package/app/.next/server/app/dashboard/mitm.rsc +5 -5
  184. package/app/.next/server/app/dashboard/mitm.segments/!KGRhc2hib2FyZCk/dashboard/mitm/__PAGE__.segment.rsc +2 -2
  185. package/app/.next/server/app/dashboard/mitm.segments/!KGRhc2hib2FyZCk/dashboard/mitm.segment.rsc +1 -1
  186. package/app/.next/server/app/dashboard/mitm.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  187. package/app/.next/server/app/dashboard/mitm.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  188. package/app/.next/server/app/dashboard/mitm.segments/_full.segment.rsc +5 -5
  189. package/app/.next/server/app/dashboard/mitm.segments/_head.segment.rsc +1 -1
  190. package/app/.next/server/app/dashboard/mitm.segments/_index.segment.rsc +3 -3
  191. package/app/.next/server/app/dashboard/mitm.segments/_tree.segment.rsc +1 -1
  192. package/app/.next/server/app/dashboard/profile.html +1 -1
  193. package/app/.next/server/app/dashboard/profile.rsc +5 -5
  194. package/app/.next/server/app/dashboard/profile.segments/!KGRhc2hib2FyZCk/dashboard/profile/__PAGE__.segment.rsc +2 -2
  195. package/app/.next/server/app/dashboard/profile.segments/!KGRhc2hib2FyZCk/dashboard/profile.segment.rsc +1 -1
  196. package/app/.next/server/app/dashboard/profile.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  197. package/app/.next/server/app/dashboard/profile.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  198. package/app/.next/server/app/dashboard/profile.segments/_full.segment.rsc +5 -5
  199. package/app/.next/server/app/dashboard/profile.segments/_head.segment.rsc +1 -1
  200. package/app/.next/server/app/dashboard/profile.segments/_index.segment.rsc +3 -3
  201. package/app/.next/server/app/dashboard/profile.segments/_tree.segment.rsc +1 -1
  202. package/app/.next/server/app/dashboard/providers/new.html +1 -1
  203. package/app/.next/server/app/dashboard/providers/new.rsc +5 -5
  204. package/app/.next/server/app/dashboard/providers/new.segments/!KGRhc2hib2FyZCk/dashboard/providers/new/__PAGE__.segment.rsc +2 -2
  205. package/app/.next/server/app/dashboard/providers/new.segments/!KGRhc2hib2FyZCk/dashboard/providers/new.segment.rsc +1 -1
  206. package/app/.next/server/app/dashboard/providers/new.segments/!KGRhc2hib2FyZCk/dashboard/providers.segment.rsc +1 -1
  207. package/app/.next/server/app/dashboard/providers/new.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  208. package/app/.next/server/app/dashboard/providers/new.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  209. package/app/.next/server/app/dashboard/providers/new.segments/_full.segment.rsc +5 -5
  210. package/app/.next/server/app/dashboard/providers/new.segments/_head.segment.rsc +1 -1
  211. package/app/.next/server/app/dashboard/providers/new.segments/_index.segment.rsc +3 -3
  212. package/app/.next/server/app/dashboard/providers/new.segments/_tree.segment.rsc +1 -1
  213. package/app/.next/server/app/dashboard/providers.html +1 -1
  214. package/app/.next/server/app/dashboard/providers.rsc +5 -5
  215. package/app/.next/server/app/dashboard/providers.segments/!KGRhc2hib2FyZCk/dashboard/providers/__PAGE__.segment.rsc +2 -2
  216. package/app/.next/server/app/dashboard/providers.segments/!KGRhc2hib2FyZCk/dashboard/providers.segment.rsc +1 -1
  217. package/app/.next/server/app/dashboard/providers.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  218. package/app/.next/server/app/dashboard/providers.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  219. package/app/.next/server/app/dashboard/providers.segments/_full.segment.rsc +5 -5
  220. package/app/.next/server/app/dashboard/providers.segments/_head.segment.rsc +1 -1
  221. package/app/.next/server/app/dashboard/providers.segments/_index.segment.rsc +3 -3
  222. package/app/.next/server/app/dashboard/providers.segments/_tree.segment.rsc +1 -1
  223. package/app/.next/server/app/dashboard/proxy-pools.html +1 -1
  224. package/app/.next/server/app/dashboard/proxy-pools.rsc +5 -5
  225. package/app/.next/server/app/dashboard/proxy-pools.segments/!KGRhc2hib2FyZCk/dashboard/proxy-pools/__PAGE__.segment.rsc +2 -2
  226. package/app/.next/server/app/dashboard/proxy-pools.segments/!KGRhc2hib2FyZCk/dashboard/proxy-pools.segment.rsc +1 -1
  227. package/app/.next/server/app/dashboard/proxy-pools.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  228. package/app/.next/server/app/dashboard/proxy-pools.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  229. package/app/.next/server/app/dashboard/proxy-pools.segments/_full.segment.rsc +5 -5
  230. package/app/.next/server/app/dashboard/proxy-pools.segments/_head.segment.rsc +1 -1
  231. package/app/.next/server/app/dashboard/proxy-pools.segments/_index.segment.rsc +3 -3
  232. package/app/.next/server/app/dashboard/proxy-pools.segments/_tree.segment.rsc +1 -1
  233. package/app/.next/server/app/dashboard/quota.html +2 -2
  234. package/app/.next/server/app/dashboard/quota.rsc +6 -6
  235. package/app/.next/server/app/dashboard/quota.segments/!KGRhc2hib2FyZCk/dashboard/quota/__PAGE__.segment.rsc +3 -3
  236. package/app/.next/server/app/dashboard/quota.segments/!KGRhc2hib2FyZCk/dashboard/quota.segment.rsc +1 -1
  237. package/app/.next/server/app/dashboard/quota.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  238. package/app/.next/server/app/dashboard/quota.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  239. package/app/.next/server/app/dashboard/quota.segments/_full.segment.rsc +6 -6
  240. package/app/.next/server/app/dashboard/quota.segments/_head.segment.rsc +1 -1
  241. package/app/.next/server/app/dashboard/quota.segments/_index.segment.rsc +3 -3
  242. package/app/.next/server/app/dashboard/quota.segments/_tree.segment.rsc +1 -1
  243. package/app/.next/server/app/dashboard/settings/pricing/page_client-reference-manifest.js +1 -1
  244. package/app/.next/server/app/dashboard/settings/pricing.html +1 -1
  245. package/app/.next/server/app/dashboard/settings/pricing.rsc +3 -3
  246. package/app/.next/server/app/dashboard/settings/pricing.segments/_full.segment.rsc +3 -3
  247. package/app/.next/server/app/dashboard/settings/pricing.segments/_head.segment.rsc +1 -1
  248. package/app/.next/server/app/dashboard/settings/pricing.segments/_index.segment.rsc +3 -3
  249. package/app/.next/server/app/dashboard/settings/pricing.segments/_tree.segment.rsc +1 -1
  250. package/app/.next/server/app/dashboard/settings/pricing.segments/dashboard/settings/pricing/__PAGE__.segment.rsc +1 -1
  251. package/app/.next/server/app/dashboard/settings/pricing.segments/dashboard/settings/pricing.segment.rsc +1 -1
  252. package/app/.next/server/app/dashboard/settings/pricing.segments/dashboard/settings.segment.rsc +1 -1
  253. package/app/.next/server/app/dashboard/settings/pricing.segments/dashboard.segment.rsc +1 -1
  254. package/app/.next/server/app/dashboard/translator.html +1 -1
  255. package/app/.next/server/app/dashboard/translator.rsc +5 -5
  256. package/app/.next/server/app/dashboard/translator.segments/!KGRhc2hib2FyZCk/dashboard/translator/__PAGE__.segment.rsc +2 -2
  257. package/app/.next/server/app/dashboard/translator.segments/!KGRhc2hib2FyZCk/dashboard/translator.segment.rsc +1 -1
  258. package/app/.next/server/app/dashboard/translator.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  259. package/app/.next/server/app/dashboard/translator.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  260. package/app/.next/server/app/dashboard/translator.segments/_full.segment.rsc +5 -5
  261. package/app/.next/server/app/dashboard/translator.segments/_head.segment.rsc +1 -1
  262. package/app/.next/server/app/dashboard/translator.segments/_index.segment.rsc +3 -3
  263. package/app/.next/server/app/dashboard/translator.segments/_tree.segment.rsc +1 -1
  264. package/app/.next/server/app/dashboard/usage.html +1 -1
  265. package/app/.next/server/app/dashboard/usage.rsc +5 -5
  266. package/app/.next/server/app/dashboard/usage.segments/!KGRhc2hib2FyZCk/dashboard/usage/__PAGE__.segment.rsc +2 -2
  267. package/app/.next/server/app/dashboard/usage.segments/!KGRhc2hib2FyZCk/dashboard/usage.segment.rsc +1 -1
  268. package/app/.next/server/app/dashboard/usage.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  269. package/app/.next/server/app/dashboard/usage.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  270. package/app/.next/server/app/dashboard/usage.segments/_full.segment.rsc +5 -5
  271. package/app/.next/server/app/dashboard/usage.segments/_head.segment.rsc +1 -1
  272. package/app/.next/server/app/dashboard/usage.segments/_index.segment.rsc +3 -3
  273. package/app/.next/server/app/dashboard/usage.segments/_tree.segment.rsc +1 -1
  274. package/app/.next/server/app/dashboard.html +1 -1
  275. package/app/.next/server/app/dashboard.rsc +5 -5
  276. package/app/.next/server/app/dashboard.segments/!KGRhc2hib2FyZCk/dashboard/__PAGE__.segment.rsc +2 -2
  277. package/app/.next/server/app/dashboard.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  278. package/app/.next/server/app/dashboard.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  279. package/app/.next/server/app/dashboard.segments/_full.segment.rsc +5 -5
  280. package/app/.next/server/app/dashboard.segments/_head.segment.rsc +1 -1
  281. package/app/.next/server/app/dashboard.segments/_index.segment.rsc +3 -3
  282. package/app/.next/server/app/dashboard.segments/_tree.segment.rsc +1 -1
  283. package/app/.next/server/app/index.html +1 -1
  284. package/app/.next/server/app/index.rsc +3 -3
  285. package/app/.next/server/app/index.segments/__PAGE__.segment.rsc +1 -1
  286. package/app/.next/server/app/index.segments/_full.segment.rsc +3 -3
  287. package/app/.next/server/app/index.segments/_head.segment.rsc +1 -1
  288. package/app/.next/server/app/index.segments/_index.segment.rsc +3 -3
  289. package/app/.next/server/app/index.segments/_tree.segment.rsc +1 -1
  290. package/app/.next/server/app/landing/page_client-reference-manifest.js +1 -1
  291. package/app/.next/server/app/landing.html +1 -1
  292. package/app/.next/server/app/landing.rsc +3 -3
  293. package/app/.next/server/app/landing.segments/_full.segment.rsc +3 -3
  294. package/app/.next/server/app/landing.segments/_head.segment.rsc +1 -1
  295. package/app/.next/server/app/landing.segments/_index.segment.rsc +3 -3
  296. package/app/.next/server/app/landing.segments/_tree.segment.rsc +1 -1
  297. package/app/.next/server/app/landing.segments/landing/__PAGE__.segment.rsc +1 -1
  298. package/app/.next/server/app/landing.segments/landing.segment.rsc +1 -1
  299. package/app/.next/server/app/login/page_client-reference-manifest.js +1 -1
  300. package/app/.next/server/app/login.html +1 -1
  301. package/app/.next/server/app/login.rsc +4 -4
  302. package/app/.next/server/app/login.segments/_full.segment.rsc +4 -4
  303. package/app/.next/server/app/login.segments/_head.segment.rsc +1 -1
  304. package/app/.next/server/app/login.segments/_index.segment.rsc +3 -3
  305. package/app/.next/server/app/login.segments/_tree.segment.rsc +1 -1
  306. package/app/.next/server/app/login.segments/login/__PAGE__.segment.rsc +2 -2
  307. package/app/.next/server/app/login.segments/login.segment.rsc +1 -1
  308. package/app/.next/server/app/manifest.webmanifest/route.js.nft.json +1 -1
  309. package/app/.next/server/app/manifest.webmanifest/route_client-reference-manifest.js +1 -1
  310. package/app/.next/server/app/page_client-reference-manifest.js +1 -1
  311. package/app/.next/server/app-paths-manifest.json +41 -41
  312. package/app/.next/server/chunks/1114.js +1 -1
  313. package/app/.next/server/chunks/1424.js +1 -1
  314. package/app/.next/server/chunks/318.js +2 -2
  315. package/app/.next/server/chunks/3832.js +1 -1
  316. package/app/.next/server/chunks/4292.js +1 -0
  317. package/app/.next/server/chunks/5297.js +1 -1
  318. package/app/.next/server/chunks/5833.js +1 -0
  319. package/app/.next/server/chunks/8590.js +1 -1
  320. package/app/.next/server/chunks/8895.js +1 -1
  321. package/app/.next/server/pages/404.html +1 -1
  322. package/app/.next/server/pages/500.html +2 -2
  323. package/app/.next/static/chunks/2652-378fd4fa14847021.js +1 -0
  324. package/app/.next/static/chunks/{5497-612d09a8bc2fb0ac.js → 5497-a9786b3cb8e5e696.js} +1 -1
  325. package/app/.next/static/chunks/app/(dashboard)/dashboard/providers/[id]/{page-04d1ffb5358d8fb2.js → page-4ebc425afc0a221a.js} +1 -1
  326. package/app/.next/static/chunks/app/{layout-facb48b90c716570.js → layout-23ec5f07962f68a0.js} +1 -1
  327. package/app/package.json +1 -1
  328. package/app/public/providers/vertex-partner.png +0 -0
  329. package/app/public/providers/vertex.png +0 -0
  330. package/package.json +1 -1
  331. package/app/.next/static/chunks/2652-67b8cc047a3efcc9.js +0 -1
  332. /package/app/.next/static/{I7Z75b-mEq-yr9pvEanD- → TmbP5kTzKgsDGgHcZeGnv}/_buildManifest.js +0 -0
  333. /package/app/.next/static/{I7Z75b-mEq-yr9pvEanD- → TmbP5kTzKgsDGgHcZeGnv}/_ssgManifest.js +0 -0
@@ -4,4 +4,4 @@
4
4
  `,children:e.name},e.id)})})]}),Object.entries(k).map(([e,t])=>(0,r.jsxs)("div",{children:[(0,r.jsxs)("div",{className:"flex items-center gap-1.5 mb-1.5 sticky top-0 bg-surface py-0.5",children:[(0,r.jsx)("div",{className:"w-2 h-2 rounded-full",style:{backgroundColor:t.color}}),(0,r.jsx)("span",{className:"text-xs font-medium text-primary",children:t.name}),(0,r.jsxs)("span",{className:"text-[10px] text-text-muted",children:["(",t.models.length,")"]})]}),(0,r.jsx)("div",{className:"flex flex-wrap gap-1.5",children:t.models.map(e=>{let t=l===e.value,s=e.isPlaceholder;return(0,r.jsx)("button",{onClick:()=>C(e),title:s?"Select to pre-fill, then edit model ID in the input":void 0,className:`
5
5
  px-2 py-1 rounded-xl text-xs font-medium transition-all border hover:cursor-pointer
6
6
  ${s?"border-dashed border-border text-text-muted hover:border-primary/50 hover:text-primary bg-surface italic":t?"bg-primary text-white border-primary":"bg-surface border-border text-text-main hover:border-primary/50 hover:bg-primary/5"}
7
- `,children:s?(0,r.jsxs)("span",{className:"flex items-center gap-1",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-[11px]",children:"edit"}),e.name]}):e.isCustom?(0,r.jsxs)("span",{className:"flex items-center gap-1",children:[e.name,(0,r.jsx)("span",{className:"text-[9px] opacity-60 font-normal",children:"custom"})]}):e.name},e.id)})})]},e)),0===Object.keys(k).length&&0===w.length&&(0,r.jsxs)("div",{className:"text-center py-4 text-text-muted",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-2xl mb-1 block",children:"search_off"}),(0,r.jsx)("p",{className:"text-xs",children:"No models found"})]})]})]})}m.propTypes={isOpen:n().bool.isRequired,onClose:n().func.isRequired,onSelect:n().func.isRequired,selectedModel:n().string,activeProviders:n().arrayOf(n().shape({provider:n().string.isRequired})),title:n().string,modelAliases:n().object}},73006:(e,t,s)=>{s.d(t,{FE:()=>x,Tl:()=>d,wn:()=>u});var r=s(93308);let a={},l=r.Xn,n=[];function i(){if("u"<typeof document)return r.Xn;let e=document.cookie.split(";").find(e=>e.trim().startsWith(`${r.CL}=`)),t=e?decodeURIComponent(e.split("=")[1]):r.Xn;return(0,r.QC)(t)}async function o(e){if("en"===e){a={};return}try{let t=await fetch(`/i18n/literals/${e}.json`);a=await t.json()}catch(e){console.error("Failed to load translations:",e),a={}}}function d(e){if(!e||"string"!=typeof e)return e;let t=e.trim();return t&&"en"!==l&&a[t]||e}function c(e){if(!e.nodeValue||!e.nodeValue.trim())return;let t=e.parentElement;if(!t)return;let s=t;for(;s;){if(s.hasAttribute&&s.hasAttribute("data-i18n-skip"))return;s=s.parentElement}if(["script","style","code","pre","colgroup","table","thead","tbody","tfoot","tr","select","datalist","optgroup"].includes(t.tagName?.toLowerCase()))return;e._originalText||(e._originalText=e.nodeValue);let r=d(e._originalText);r!==e.nodeValue&&(e.nodeValue=r)}function m(e){let t;if(!e)return;let s=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,null,!1),r=[];for(;t=s.nextNode();)r.push(t);r.forEach(c)}async function x(){l=i(),await o(l),m(document.body),new MutationObserver(e=>{e.forEach(e=>{e.addedNodes.forEach(e=>{e.nodeType===Node.ELEMENT_NODE?m(e):e.nodeType===Node.TEXT_NODE&&c(e)})})}).observe(document.body,{childList:!0,subtree:!0})}async function u(){l=i(),await o(l),n.forEach(e=>e()),m(document.body)}},74891:(e,t,s)=>{s.d(t,{default:()=>h});var r=s(95155),a=s(73321),l=s(12115),n=s(98500),i=s.n(n),o=s(5772),d=s(14051),c=s.n(d),m=s(35497),x=s(90620),u=s(73006);function h({onMenuClick:e,showMenuButton:t=!0}){let s=(0,a.usePathname)(),n=(0,a.useRouter)(),{title:d,description:c,breadcrumbs:h}=(0,l.useMemo)(()=>(e=>{if(!e)return{title:"",description:"",breadcrumbs:[]};let t=e.match(/\/providers\/([^/]+)$/);if(t){let e=t[1],s=x.zN[e]||x.fg[e];if(s)return{title:s.name,description:"",breadcrumbs:[{label:"Providers",href:"/dashboard/providers"},{label:s.name,image:`/providers/${s.id}.png`}]}}return e.includes("/providers")?{title:"Providers",description:"Manage your AI provider connections",breadcrumbs:[]}:e.includes("/combos")?{title:"Combos",description:"Model combos with fallback",breadcrumbs:[]}:e.includes("/usage")?{title:"Usage & Analytics",description:"Monitor your API usage, token consumption, and request logs",breadcrumbs:[]}:e.includes("/mitm")?{title:"MITM Proxy",description:"Intercept CLI tool traffic and route through 9Router",breadcrumbs:[]}:e.includes("/cli-tools")?{title:"CLI Tools",description:"Configure CLI tools",breadcrumbs:[]}:e.includes("/endpoint")?{title:"Endpoint",description:"API endpoint configuration",breadcrumbs:[]}:e.includes("/profile")?{title:"Settings",description:"Manage your preferences",breadcrumbs:[]}:e.includes("/translator")?{title:"Translator",description:"Debug translation flow between formats",breadcrumbs:[]}:e.includes("/console-log")?{title:"Console Log",description:"Live server console output",breadcrumbs:[]}:"/dashboard"===e?{title:"Endpoint",description:"API endpoint configuration",breadcrumbs:[]}:{title:"",description:"",breadcrumbs:[]}})(s),[s]),p=async()=>{try{(await fetch("/api/auth/logout",{method:"POST"})).ok&&(n.push("/login"),n.refresh())}catch(e){console.error("Failed to logout:",e)}};return(0,r.jsxs)("header",{className:"flex items-center justify-between px-8 py-5 border-b border-black/5 dark:border-white/5 bg-bg/80 backdrop-blur-xl z-10 sticky top-0",children:[(0,r.jsx)("div",{className:"flex items-center gap-3 lg:hidden",children:t&&(0,r.jsx)("button",{onClick:e,className:"text-text-main hover:text-primary transition-colors",children:(0,r.jsx)("span",{className:"material-symbols-outlined",children:"menu"})})}),(0,r.jsx)("div",{className:"hidden lg:flex flex-col",children:h.length>0?(0,r.jsx)("div",{className:"flex items-center gap-2",children:h.map((e,t)=>(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[t>0&&(0,r.jsx)("span",{className:"material-symbols-outlined text-text-muted text-base",children:"chevron_right"}),e.href?(0,r.jsx)(i(),{href:e.href,className:"text-text-muted hover:text-primary transition-colors",children:e.label}):(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[e.image&&(0,r.jsx)(o.default,{src:e.image,alt:e.label,width:28,height:28,className:"object-contain rounded max-w-[28px] max-h-[28px]",sizes:"28px",onError:e=>{e.currentTarget.style.display="none"}}),(0,r.jsx)("h1",{className:"text-2xl font-semibold text-text-main tracking-tight",children:(0,u.Tl)(e.label)})]})]},`${e.label}-${e.href||"current"}`))}):d?(0,r.jsxs)("div",{children:[(0,r.jsx)("h1",{className:"text-2xl font-semibold text-text-main tracking-tight",children:(0,u.Tl)(d)}),c&&(0,r.jsx)("p",{className:"text-sm text-text-muted",children:(0,u.Tl)(c)})]}):null}),(0,r.jsxs)("div",{className:"flex items-center gap-3 ml-auto",children:[(0,r.jsx)(m.c5,{}),(0,r.jsx)(m.UW,{}),(0,r.jsx)("button",{onClick:p,className:"flex items-center justify-center p-2 rounded-lg text-text-muted hover:text-red-500 hover:bg-red-500/10 transition-all",title:"Logout",children:(0,r.jsx)("span",{className:"material-symbols-outlined",children:"logout"})})]})]})}h.propTypes={onMenuClick:c().func,showMenuButton:c().bool}},81127:(e,t,s)=>{s.d(t,{ConfirmModal:()=>o,default:()=>i});var r=s(95155),a=s(12115),l=s(31474),n=s(92542);function i({isOpen:e,onClose:t,title:s,children:n,footer:i,size:o="md",closeOnOverlay:d=!0,showCloseButton:c=!0,className:m}){return((0,a.useEffect)(()=>(e?document.body.style.overflow="hidden":document.body.style.overflow="",()=>{document.body.style.overflow=""}),[e]),(0,a.useEffect)(()=>{let s=s=>{"Escape"===s.key&&e&&t()};return document.addEventListener("keydown",s),()=>document.removeEventListener("keydown",s)},[e,t]),e)?(0,r.jsxs)("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",children:[(0,r.jsx)("div",{className:"absolute inset-0 bg-black/30 backdrop-blur-sm",onClick:d?t:void 0}),(0,r.jsxs)("div",{className:(0,l.cn)("relative w-full bg-surface","border border-black/10 dark:border-white/10","rounded-xl shadow-2xl","animate-in fade-in zoom-in-95 duration-200",{sm:"max-w-sm",md:"max-w-md",lg:"max-w-lg",xl:"max-w-xl",full:"max-w-4xl"}[o],m),children:[(s||c)&&(0,r.jsxs)("div",{className:"flex items-center justify-between p-6 border-b border-black/5 dark:border-white/5",children:[(0,r.jsxs)("div",{className:"flex items-center",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 mr-4",children:[(0,r.jsx)("div",{className:"w-3 h-3 rounded-full bg-[#FF5F56]"}),(0,r.jsx)("div",{className:"w-3 h-3 rounded-full bg-[#FFBD2E]"}),(0,r.jsx)("div",{className:"w-3 h-3 rounded-full bg-[#27C93F]"})]}),s&&(0,r.jsx)("h2",{className:"text-lg font-semibold text-text-main",children:s})]}),c&&(0,r.jsx)("button",{onClick:t,className:"p-1.5 rounded-lg text-text-muted hover:bg-black/5 dark:hover:bg-white/5 transition-colors",children:(0,r.jsx)("span",{className:"material-symbols-outlined text-[20px]",children:"close"})})]}),(0,r.jsx)("div",{className:"p-6 max-h-[calc(80vh-140px)] overflow-y-auto",children:n}),i&&(0,r.jsx)("div",{className:"flex items-center justify-end gap-3 p-6 border-t border-black/5 dark:border-white/5",children:i})]})]}):null}function o({isOpen:e,onClose:t,onConfirm:s,title:a="Confirm",message:l,confirmText:o="Confirm",cancelText:d="Cancel",variant:c="danger",loading:m=!1}){return(0,r.jsx)(i,{isOpen:e,onClose:t,title:a,size:"sm",footer:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(n.default,{variant:"ghost",onClick:t,disabled:m,children:d}),(0,r.jsx)(n.default,{variant:c,onClick:s,loading:m,children:o})]}),children:(0,r.jsx)("p",{className:"text-text-muted",children:l})})}},84588:(e,t,s)=>{s.d(t,{default:()=>l});var r=s(95155),a=s(31474);function l({children:e,title:t,subtitle:s,icon:l,action:n,padding:i="md",hover:o=!1,className:d,...c}){return(0,r.jsxs)("div",{className:(0,a.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"}[i],d),...c,children:[(t||n)&&(0,r.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,r.jsxs)("div",{className:"flex items-center gap-3",children:[l&&(0,r.jsx)("div",{className:"p-2 rounded-lg bg-bg text-text-muted",children:(0,r.jsx)("span",{className:"material-symbols-outlined text-[20px]",children:l})}),(0,r.jsxs)("div",{children:[t&&(0,r.jsx)("h3",{className:"text-text-main font-semibold",children:t}),s&&(0,r.jsx)("p",{className:"text-sm text-text-muted",children:s})]})]}),n]}),e]})}l.Section=function({children:e,className:t,...s}){return(0,r.jsx)("div",{className:(0,a.cn)("p-4 rounded-lg","bg-black/[0.02] dark:bg-white/[0.02]","border border-black/5 dark:border-white/5",t),...s,children:e})},l.Row=function({children:e,className:t,...s}){return(0,r.jsx)("div",{className:(0,a.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),...s,children:e})},l.ListItem=function({children:e,actions:t,className:s,...l}){return(0,r.jsxs)("div",{className:(0,a.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",s),...l,children:[(0,r.jsx)("div",{className:"flex-1 min-w-0",children:e}),t&&(0,r.jsx)("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:t})]})}},90085:(e,t,s)=>{s.d(t,{A:()=>i});var r=s(1934),a=s(31692),l=s(90620);function n(e){let t=document.documentElement,s=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light";"dark"===("system"===e?s:e)?t.classList.add("dark"):t.classList.remove("dark")}let i=(0,r.v)((0,a.Zr)((e,t)=>({theme:l.B2.defaultTheme,setTheme:t=>{e({theme:t}),n(t)},toggleTheme:()=>{let s="dark"===t().theme?"light":"dark";e({theme:s}),n(s)},initTheme:()=>{n(t().theme)}}),{name:l.B2.storageKey}))},90620:(e,t,s)=>{s.d(t,{Q2:()=>r.Q2,fg:()=>r.fg,vQ:()=>a,MA:()=>r.MA,UY:()=>n,zN:()=>r.zN,B2:()=>l});var r=s(52679);s(28777);let a={name:"Endpoint Proxy",description:"AI Infrastructure Management",version:"0.3.49"},l={storageKey:"theme",defaultTheme:"system"},n={maxLines:200,pollIntervalMs:1e3}},90882:(e,t,s)=>{s.d(t,{default:()=>d});var r=s(95155),a=s(12115),l=s(14051),n=s.n(l),i=s(35497),o=s(11059);function d({isOpen:e,provider:t,providerInfo:s,onSuccess:l,onClose:n}){let[d,c]=(0,a.useState)("waiting"),[m,x]=(0,a.useState)(null),[u,h]=(0,a.useState)(""),[p,f]=(0,a.useState)(null),[b,g]=(0,a.useState)(!1),[j,y]=(0,a.useState)(null),[v,N]=(0,a.useState)(!1),w=(0,a.useRef)(null),k=(0,a.useRef)(!1),{copied:C,copy:S}=(0,o.C)(),[T,M]=(0,a.useState)(!1),[$,R]=(0,a.useState)("/callback?code=..."),E=(0,a.useRef)(!1);(0,a.useEffect)(()=>{M("localhost"===window.location.hostname||"127.0.0.1"===window.location.hostname),R(`${window.location.origin}/callback?code=...`)},[]);let L=(0,a.useCallback)(async(e,s)=>{if(m)try{let r=await fetch(`/api/oauth/${t}/exchange`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({code:e,redirectUri:m.redirectUri,codeVerifier:m.codeVerifier,state:s})}),a=await r.json();if(!r.ok)throw Error(a.error);c("success"),l?.()}catch(e){f(e.message),c("error")}},[m,t,l]),O=(0,a.useCallback)(async(e,s,r,a)=>{k.current=!1,N(!0);for(let n=0;n<60;n++){if(k.current){console.log("[OAuthModal] Polling aborted"),N(!1);return}if(await new Promise(e=>setTimeout(e,1e3*r)),k.current){console.log("[OAuthModal] Polling aborted after sleep"),N(!1);return}try{let n=await fetch(`/api/oauth/${t}/poll`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({deviceCode:e,codeVerifier:s,extraData:a})}),i=await n.json();if(i.success){k.current=!0,c("success"),N(!1),l?.();return}if("expired_token"===i.error||"access_denied"===i.error)throw Error(i.errorDescription||i.error);"slow_down"===i.error&&(r=Math.min(r+5,30))}catch(e){f(e.message),c("error"),N(!1);return}}f("Authorization timeout"),c("error"),N(!1)},[t,l]),I=(0,a.useCallback)(async()=>{if(t)try{let e;if(f(null),["github","qwen","kiro","kimi-coding","kilocode"].includes(t)){g(!0),c("waiting");let e=await fetch(`/api/oauth/${t}/device-code`),s=await e.json();if(!e.ok)throw Error(s.error);y(s);let r=s.verification_uri_complete||s.verification_uri;r&&window.open(r,"_blank");let a="kiro"===t?{_clientId:s._clientId,_clientSecret:s._clientSecret}:null;O(s.device_code,s.codeVerifier,s.interval||5,a);return}if("codex"===t)e="http://localhost:1455/auth/callback";else{let t=window.location.port||("https:"===window.location.protocol?"443":"80");e=`http://localhost:${t}/callback`}let s=await fetch(`/api/oauth/${t}/authorize?redirect_uri=${encodeURIComponent(e)}`),r=await s.json();if(!s.ok)throw Error(r.error);x({...r,redirectUri:e}),"codex"!==t&&T?(c("waiting"),w.current=window.open(r.authUrl,"oauth_popup","width=600,height=700"),w.current||c("input")):(c("input"),window.open(r.authUrl,"_blank"))}catch(e){f(e.message),c("error")}},[t,T,O]);(0,a.useEffect)(()=>{e&&t?(x(null),h(""),f(null),g(!1),y(null),N(!1),k.current=!1,I()):e||(k.current=!0)},[e,t,I]),(0,a.useEffect)(()=>{let e;if(!m)return;E.current=!1;let t=async e=>{if(E.current)return;let{code:t,state:s,error:r,errorDescription:a}=e;if(r){E.current=!0,f(a||r),c("error");return}t&&(E.current=!0,await L(t,s))},s=e=>{let s=e.origin.includes("localhost")||e.origin.includes("127.0.0.1"),r=e.origin===window.location.origin;(s||r)&&e.data?.type==="oauth_callback"&&t(e.data.data)};window.addEventListener("message",s);try{(e=new BroadcastChannel("oauth_callback")).onmessage=e=>t(e.data)}catch(e){console.log("BroadcastChannel not supported")}let r=e=>{if("oauth_callback"===e.key&&e.newValue)try{let s=JSON.parse(e.newValue);t(s),localStorage.removeItem("oauth_callback")}catch(e){console.log("Failed to parse localStorage data")}};window.addEventListener("storage",r);try{let e=localStorage.getItem("oauth_callback");if(e){let s=JSON.parse(e);s.timestamp&&Date.now()-s.timestamp<3e4&&t(s),localStorage.removeItem("oauth_callback")}}catch{}return()=>{window.removeEventListener("message",s),window.removeEventListener("storage",r),e&&e.close()}},[m,L]);let z=async()=>{try{f(null);let e=new URL(u),t=e.searchParams.get("code"),s=e.searchParams.get("state"),r=e.searchParams.get("error");if(r)throw Error(e.searchParams.get("error_description")||r);if(!t)throw Error("No authorization code found in URL");await L(t,s)}catch(e){f(e.message),c("error")}},P=(0,a.useCallback)(()=>{n()},[n]);return t&&s?(0,r.jsx)(i.aF,{isOpen:e,title:`Connect ${s.name}`,onClose:P,size:"lg",children:(0,r.jsxs)("div",{className:"flex flex-col gap-4",children:["waiting"===d&&!b&&(0,r.jsxs)("div",{className:"text-center py-6",children:[(0,r.jsx)("div",{className:"size-16 mx-auto mb-4 rounded-full bg-primary/10 flex items-center justify-center",children:(0,r.jsx)("span",{className:"material-symbols-outlined text-3xl text-primary animate-spin",children:"progress_activity"})}),(0,r.jsx)("h3",{className:"text-lg font-semibold mb-2",children:"Waiting for Authorization"}),(0,r.jsx)("p",{className:"text-sm text-text-muted mb-4",children:"Complete the authorization in the popup window."}),(0,r.jsx)(i.$n,{variant:"ghost",onClick:()=>c("input"),children:"Popup blocked? Enter URL manually"})]}),"waiting"===d&&b&&j&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"text-center py-4",children:[(0,r.jsx)("p",{className:"text-sm text-text-muted mb-4",children:"Visit the URL below and enter the code:"}),(0,r.jsxs)("div",{className:"bg-sidebar p-4 rounded-lg mb-4",children:[(0,r.jsx)("p",{className:"text-xs text-text-muted mb-1",children:"Verification URL"}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("code",{className:"flex-1 text-sm break-all",children:j.verification_uri}),(0,r.jsx)(i.$n,{size:"sm",variant:"ghost",icon:"verify_url"===C?"check":"content_copy",onClick:()=>S(j.verification_uri,"verify_url")})]})]}),(0,r.jsxs)("div",{className:"bg-primary/10 p-4 rounded-lg",children:[(0,r.jsx)("p",{className:"text-xs text-text-muted mb-1",children:"Your Code"}),(0,r.jsxs)("div",{className:"flex items-center justify-center gap-2",children:[(0,r.jsx)("p",{className:"text-2xl font-mono font-bold text-primary",children:j.user_code}),(0,r.jsx)(i.$n,{size:"sm",variant:"ghost",icon:"user_code"===C?"check":"content_copy",onClick:()=>S(j.user_code,"user_code")})]})]})]}),v&&(0,r.jsxs)("div",{className:"flex items-center justify-center gap-2 text-sm text-text-muted",children:[(0,r.jsx)("span",{className:"material-symbols-outlined animate-spin",children:"progress_activity"}),"Waiting for authorization..."]})]}),"input"===d&&!b&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("p",{className:"text-sm font-medium mb-2",children:"Step 1: Open this URL in your browser"}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)(i.pd,{value:m?.authUrl||"",readOnly:!0,className:"flex-1 font-mono text-xs"}),(0,r.jsx)(i.$n,{variant:"secondary",icon:"auth_url"===C?"check":"content_copy",onClick:()=>S(m?.authUrl,"auth_url"),children:"Copy"})]})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("p",{className:"text-sm font-medium mb-2",children:"Step 2: Paste the callback URL here"}),(0,r.jsx)("p",{className:"text-xs text-text-muted mb-2",children:"After authorization, copy the full URL from your browser."}),(0,r.jsx)(i.pd,{value:u,onChange:e=>h(e.target.value),placeholder:$,className:"font-mono text-xs"})]})]}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)(i.$n,{onClick:z,fullWidth:!0,disabled:!u,children:"Connect"}),(0,r.jsx)(i.$n,{onClick:P,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]}),"success"===d&&(0,r.jsxs)("div",{className:"text-center py-6",children:[(0,r.jsx)("div",{className:"size-16 mx-auto mb-4 rounded-full bg-green-100 dark:bg-green-900/30 flex items-center justify-center",children:(0,r.jsx)("span",{className:"material-symbols-outlined text-3xl text-green-600",children:"check_circle"})}),(0,r.jsx)("h3",{className:"text-lg font-semibold mb-2",children:"Connected Successfully!"}),(0,r.jsxs)("p",{className:"text-sm text-text-muted mb-4",children:["Your ",s.name," account has been connected."]}),(0,r.jsx)(i.$n,{onClick:P,fullWidth:!0,children:"Done"})]}),"error"===d&&(0,r.jsxs)("div",{className:"text-center py-6",children:[(0,r.jsx)("div",{className:"size-16 mx-auto mb-4 rounded-full bg-red-100 dark:bg-red-900/30 flex items-center justify-center",children:(0,r.jsx)("span",{className:"material-symbols-outlined text-3xl text-red-600",children:"error"})}),(0,r.jsx)("h3",{className:"text-lg font-semibold mb-2",children:"Connection Failed"}),(0,r.jsx)("p",{className:"text-sm text-red-600 mb-4",children:p}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)(i.$n,{onClick:I,variant:"secondary",fullWidth:!0,children:"Try Again"}),(0,r.jsx)(i.$n,{onClick:P,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})]})}):null}d.propTypes={isOpen:n().bool.isRequired,provider:n().string,providerInfo:n().shape({name:n().string}),onSuccess:n().func,onClose:n().func.isRequired}},91450:(e,t,s)=>{s.d(t,{default:()=>i});var r=s(95155),a=s(14051),l=s.n(a),n=s(38587);function i({children:e}){return(0,r.jsxs)("div",{className:"min-h-screen flex flex-col relative bg-bg transition-colors duration-500 overflow-x-hidden selection:bg-primary/20 selection:text-primary",children:[(0,r.jsx)("div",{className:"fixed top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-[800px] h-[800px] bg-primary/5 dark:bg-primary/5 rounded-full blur-[100px] pointer-events-none z-0"}),(0,r.jsx)("div",{className:"fixed bottom-0 right-0 w-[600px] h-[600px] bg-orange-200/20 dark:bg-orange-900/10 rounded-full blur-[120px] pointer-events-none z-0 translate-y-1/3 translate-x-1/3"}),(0,r.jsx)("div",{className:"absolute top-6 right-6 z-20",children:(0,r.jsx)(n.default,{variant:"card"})}),(0,r.jsx)("main",{className:"flex-1 flex flex-col items-center justify-center p-4 sm:p-6 z-10 w-full h-full",children:e})]})}i.propTypes={children:l().node.isRequired}},92173:(e,t,s)=>{s.d(t,{default:()=>c});var r=s(95155),a=s(98500),l=s.n(a),n=s(90620);let i=[{label:"Features",href:"#features"},{label:"Pricing",href:"#pricing"},{label:"Changelog",href:"#"}],o=[{label:"Documentation",href:"#"},{label:"API Reference",href:"#"},{label:"Help Center",href:"#"}],d=[{label:"About",href:"#"},{label:"Blog",href:"#"},{label:"Contact",href:"#"}];function c(){return(0,r.jsx)("footer",{className:"bg-bg border-t border-border pt-16 pb-12",children:(0,r.jsxs)("div",{className:"container mx-auto px-4 sm:px-6 lg:px-8",children:[(0,r.jsxs)("div",{className:"grid grid-cols-2 md:grid-cols-4 lg:grid-cols-5 gap-10 mb-12",children:[(0,r.jsxs)("div",{className:"col-span-2 lg:col-span-2",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 mb-6",children:[(0,r.jsx)("div",{className:"size-6 text-primary",children:(0,r.jsx)("svg",{className:"w-full h-full",fill:"currentColor",viewBox:"0 0 48 48",children:(0,r.jsx)("path",{clipRule:"evenodd",d:"M12.0799 24L4 19.2479L9.95537 8.75216L18.04 13.4961L18.0446 4H29.9554L29.96 13.4961L38.0446 8.75216L44 19.2479L35.92 24L44 28.7521L38.0446 39.2479L29.96 34.5039L29.9554 44H18.0446L18.04 34.5039L9.95537 39.2479L4 28.7521L12.0799 24Z",fillRule:"evenodd"})})}),(0,r.jsx)("span",{className:"text-xl font-bold text-text-main",children:n.vQ.name})]}),(0,r.jsx)("p",{className:"text-text-muted mb-6 max-w-sm font-light",children:"The unified interface for modern AI infrastructure. Secure, observable, and scalable."}),(0,r.jsxs)("div",{className:"flex gap-4",children:[(0,r.jsx)("a",{href:"#",className:"text-gray-400 hover:text-primary transition-colors","aria-label":"Twitter",children:(0,r.jsx)("svg",{className:"w-5 h-5",fill:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{d:"M22.46 6c-.77.35-1.6.58-2.46.69.88-.53 1.56-1.37 1.88-2.38-.83.5-1.75.85-2.72 1.05C18.37 4.5 17.26 4 16 4c-2.35 0-4.27 1.92-4.27 4.29 0 .34.04.67.11.98C8.28 9.09 5.11 7.38 3 4.79c-.37.63-.58 1.37-.58 2.15 0 1.49.75 2.81 1.91 3.56-.71 0-1.37-.2-1.95-.5v.03c0 2.08 1.48 3.82 3.44 4.21a4.22 4.22 0 0 1-1.93.07 4.28 4.28 0 0 0 4 2.98 8.521 8.521 0 0 1-5.33 1.84c-.34 0-.68-.02-1.02-.06C3.44 20.29 5.7 21 8.12 21 16 21 20.33 14.46 20.33 8.79c0-.19 0-.37-.01-.56.84-.6 1.56-1.36 2.14-2.23z"})})}),(0,r.jsx)("a",{href:"#",className:"text-gray-400 hover:text-primary transition-colors","aria-label":"GitHub",children:(0,r.jsx)("svg",{className:"w-5 h-5",fill:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{d:"M12 2C6.477 2 2 6.484 2 12.017c0 4.425 2.865 8.18 6.839 9.504.5.092.682-.217.682-.483 0-.237-.008-.868-.013-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.029-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0 1 12 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.202 2.398.1 2.651.64.7 1.028 1.595 1.028 2.688 0 3.848-2.339 4.695-4.566 4.943.359.309.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.019 10.019 0 0 0 22 12.017C22 6.484 17.522 2 12 2z"})})})]})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("h4",{className:"font-semibold text-text-main mb-4",children:"Product"}),(0,r.jsx)("ul",{className:"flex flex-col gap-3 text-sm text-text-muted font-light",children:i.map(e=>(0,r.jsx)("li",{children:(0,r.jsx)(l(),{href:e.href,className:"hover:text-primary transition-colors",children:e.label})},e.label))})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("h4",{className:"font-semibold text-text-main mb-4",children:"Resources"}),(0,r.jsx)("ul",{className:"flex flex-col gap-3 text-sm text-text-muted font-light",children:o.map(e=>(0,r.jsx)("li",{children:(0,r.jsx)(l(),{href:e.href,className:"hover:text-primary transition-colors",children:e.label})},e.label))})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("h4",{className:"font-semibold text-text-main mb-4",children:"Company"}),(0,r.jsx)("ul",{className:"flex flex-col gap-3 text-sm text-text-muted font-light",children:d.map(e=>(0,r.jsx)("li",{children:(0,r.jsx)(l(),{href:e.href,className:"hover:text-primary transition-colors",children:e.label})},e.label))})]})]}),(0,r.jsxs)("div",{className:"border-t border-border pt-8 flex flex-col md:flex-row justify-between items-center gap-4",children:[(0,r.jsxs)("p",{className:"text-sm text-text-muted",children:["\xa9 ",new Date().getFullYear()," ",n.vQ.name," Inc. All rights reserved."]}),(0,r.jsxs)("div",{className:"flex gap-6 text-sm text-text-muted",children:[(0,r.jsx)(l(),{href:"#",className:"hover:text-primary transition-colors",children:"Privacy Policy"}),(0,r.jsx)(l(),{href:"#",className:"hover:text-primary transition-colors",children:"Terms of Service"})]})]})]})})}},92542:(e,t,s)=>{s.d(t,{default:()=>i});var r=s(95155),a=s(31474);let l={primary:"bg-gradient-to-b from-primary to-primary-hover text-white shadow-sm",secondary:"bg-white dark:bg-white/10 border border-black/10 dark:border-white/10 text-text-main hover:bg-black/5 dark:hover:bg-white/5",outline:"border border-black/15 dark:border-white/15 text-text-main hover:bg-black/5",ghost:"text-text-muted hover:bg-black/5 dark:hover:bg-white/5 hover:text-text-main",danger:"bg-red-500 text-white hover:bg-red-600 shadow-sm"},n={sm:"h-7 px-3 text-xs rounded-md",md:"h-9 px-4 text-sm rounded-lg",lg:"h-11 px-6 text-sm rounded-lg"};function i({children:e,variant:t="primary",size:s="md",icon:i,iconRight:o,disabled:d=!1,loading:c=!1,fullWidth:m=!1,className:x,...u}){return(0,r.jsxs)("button",{className:(0,a.cn)("inline-flex items-center justify-center gap-2 font-medium transition-all duration-200 cursor-pointer","active:scale-[0.99] disabled:opacity-50 disabled:cursor-not-allowed disabled:active:scale-100",l[t],n[s],m&&"w-full",x),disabled:d||c,...u,children:[c?(0,r.jsx)("span",{className:"material-symbols-outlined animate-spin text-[18px]",children:"progress_activity"}):i?(0,r.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:i}):null,e,o&&!c&&(0,r.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:o})]})}},92622:(e,t,s)=>{s.d(t,{default:()=>b});var r=s(95155),a=s(12115),l=s(14051),n=s.n(l),i=s(98500),o=s.n(i),d=s(73321),c=s(31474),m=s(90620),x=s(92542),u=s(81127);let h=[{href:"/dashboard/endpoint",label:"Endpoint",icon:"api"},{href:"/dashboard/providers",label:"Providers",icon:"dns"},{href:"/dashboard/proxy-pools",label:"Proxy Pools",icon:"lan"},{href:"/dashboard/combos",label:"Combos",icon:"layers"},{href:"/dashboard/usage",label:"Usage",icon:"bar_chart"},{href:"/dashboard/quota",label:"Quota Tracker",icon:"data_usage"},{href:"/dashboard/mitm",label:"MITM",icon:"security"},{href:"/dashboard/cli-tools",label:"CLI Tools",icon:"terminal"}],p=[{href:"/dashboard/console-log",label:"Console Log",icon:"terminal"}],f=[{href:"/dashboard/profile",label:"Settings",icon:"settings"}];function b({onClose:e}){let t=(0,d.usePathname)(),[s,l]=(0,a.useState)(!1),[n,i]=(0,a.useState)(!1),[b,g]=(0,a.useState)(!1),[j,y]=(0,a.useState)(null),[v,N]=(0,a.useState)(!1);(0,a.useEffect)(()=>{fetch("/api/settings").then(e=>e.json()).then(e=>{e.enableTranslator&&N(!0)}).catch(()=>{})},[]),(0,a.useEffect)(()=>{fetch("/api/version").then(e=>e.json()).then(e=>{e.hasUpdate&&y(e)}).catch(()=>{})},[]);let w=e=>"/dashboard/endpoint"===e?"/dashboard"===t||t.startsWith("/dashboard/endpoint"):t.startsWith(e),k=async()=>{i(!0);try{await fetch("/api/shutdown",{method:"POST"})}catch(e){}i(!1),l(!1),g(!0)};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("aside",{className:"flex w-72 flex-col border-r border-black/5 dark:border-white/5 bg-vibrancy backdrop-blur-xl transition-colors duration-300",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 px-6 pt-5 pb-2",children:[(0,r.jsx)("div",{className:"w-3 h-3 rounded-full bg-[#FF5F56]"}),(0,r.jsx)("div",{className:"w-3 h-3 rounded-full bg-[#FFBD2E]"}),(0,r.jsx)("div",{className:"w-3 h-3 rounded-full bg-[#27C93F]"})]}),(0,r.jsxs)("div",{className:"px-6 py-4 flex flex-col gap-2",children:[(0,r.jsxs)(o(),{href:"/dashboard",className:"flex items-center gap-3",children:[(0,r.jsx)("div",{className:"flex items-center justify-center size-9 rounded bg-linear-to-br from-[#f97815] to-[#c2590a]",children:(0,r.jsx)("span",{className:"material-symbols-outlined text-white text-[20px]",children:"hub"})}),(0,r.jsxs)("div",{className:"flex flex-col",children:[(0,r.jsx)("h1",{className:"text-lg font-semibold tracking-tight text-text-main",children:m.vQ.name}),(0,r.jsxs)("span",{className:"text-xs text-text-muted",children:["v",m.vQ.version]})]})]}),j&&(0,r.jsxs)("div",{className:"flex flex-col gap-0.5",children:[(0,r.jsxs)("span",{className:"text-xs font-semibold text-green-600 dark:text-amber-500",children:["↑ New version available: v",j.latestVersion]}),(0,r.jsx)("code",{className:"text-[10px] text-green-600/80 dark:text-amber-400/70 font-mono select-all",children:"npm install -g 9router@latest"})]})]}),(0,r.jsxs)("nav",{className:"flex-1 px-4 py-2 space-y-1 overflow-y-auto custom-scrollbar",children:[h.map(t=>(0,r.jsxs)(o(),{href:t.href,onClick:e,className:(0,c.cn)("flex items-center gap-3 px-4 py-2 rounded-lg transition-all group",w(t.href)?"bg-primary/10 text-primary":"text-text-muted hover:bg-surface/50 hover:text-text-main"),children:[(0,r.jsx)("span",{className:(0,c.cn)("material-symbols-outlined text-[18px]",w(t.href)?"fill-1":"group-hover:text-primary transition-colors"),children:t.icon}),(0,r.jsx)("span",{className:"text-sm font-medium",children:t.label})]},t.href)),(0,r.jsxs)("div",{className:"pt-4 mt-2",children:[(0,r.jsx)("p",{className:"px-4 text-xs font-semibold text-text-muted/60 uppercase tracking-wider mb-2",children:"Debug"}),v&&(0,r.jsxs)(o(),{href:"/dashboard/translator",onClick:e,className:(0,c.cn)("flex items-center gap-3 px-4 py-2 rounded-lg transition-all group",w("/dashboard/translator")?"bg-primary/10 text-primary":"text-text-muted hover:bg-surface/50 hover:text-text-main"),children:[(0,r.jsx)("span",{className:(0,c.cn)("material-symbols-outlined text-[18px]",w("/dashboard/translator")?"fill-1":"group-hover:text-primary transition-colors"),children:"translate"}),(0,r.jsx)("span",{className:"text-sm font-medium",children:"Translator"})]}),p.map(t=>(0,r.jsxs)(o(),{href:t.href,onClick:e,className:(0,c.cn)("flex items-center gap-3 px-4 py-2 rounded-lg transition-all group",w(t.href)?"bg-primary/10 text-primary":"text-text-muted hover:bg-surface/50 hover:text-text-main"),children:[(0,r.jsx)("span",{className:(0,c.cn)("material-symbols-outlined text-[18px]",w(t.href)?"fill-1":"group-hover:text-primary transition-colors"),children:t.icon}),(0,r.jsx)("span",{className:"text-sm font-medium",children:t.label})]},t.href))]}),(0,r.jsxs)("div",{className:"pt-4 mt-2",children:[(0,r.jsx)("p",{className:"px-4 text-xs font-semibold text-text-muted/60 uppercase tracking-wider mb-2",children:"System"}),f.map(t=>(0,r.jsxs)(o(),{href:t.href,onClick:e,className:(0,c.cn)("flex items-center gap-3 px-4 py-2 rounded-lg transition-all group",w(t.href)?"bg-primary/10 text-primary":"text-text-muted hover:bg-surface/50 hover:text-text-main"),children:[(0,r.jsx)("span",{className:(0,c.cn)("material-symbols-outlined text-[18px]",w(t.href)?"fill-1":"group-hover:text-primary transition-colors"),children:t.icon}),(0,r.jsx)("span",{className:"text-sm font-medium",children:t.label})]},t.href))]})]}),(0,r.jsxs)("div",{className:"p-3 border-t border-black/5 dark:border-white/5",children:[(0,r.jsxs)("div",{className:"flex items-start gap-2 p-2 rounded-lg bg-surface/50 mb-2",children:[(0,r.jsx)("div",{className:"flex items-center justify-center size-6 rounded-md bg-blue-500/10 text-blue-500 shrink-0 mt-0.5",children:(0,r.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"info"})}),(0,r.jsx)("div",{className:"flex flex-col",children:(0,r.jsx)("span",{className:"text-xs font-medium text-text-main leading-relaxed",children:"Service is running in terminal. You can close this web page. Shutdown will stop the service."})})]}),(0,r.jsx)(x.default,{variant:"outline",fullWidth:!0,icon:"power_settings_new",onClick:()=>l(!0),className:"text-red-500 border-red-200 hover:bg-red-50 hover:border-red-300",children:"Shutdown"})]})]}),(0,r.jsx)(u.ConfirmModal,{isOpen:s,onClose:()=>l(!1),onConfirm:k,title:"Close Proxy",message:"Are you sure you want to close the proxy server?",confirmText:"Close",cancelText:"Cancel",variant:"danger",loading:n}),b&&(0,r.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/80 backdrop-blur-sm",children:(0,r.jsxs)("div",{className:"text-center p-8",children:[(0,r.jsx)("div",{className:"flex items-center justify-center size-16 rounded-full bg-red-500/20 text-red-500 mx-auto mb-4",children:(0,r.jsx)("span",{className:"material-symbols-outlined text-[32px]",children:"power_off"})}),(0,r.jsx)("h2",{className:"text-xl font-semibold text-white mb-2",children:"Server Disconnected"}),(0,r.jsx)("p",{className:"text-text-muted mb-6",children:"The proxy server has been stopped."}),(0,r.jsx)(x.default,{variant:"secondary",onClick:()=>globalThis.location.reload(),children:"Reload Page"})]})})]})}b.propTypes={onClose:n().func}},93308:(e,t,s)=>{s.d(t,{CL:()=>l,QC:()=>n,Xn:()=>a,YZ:()=>r});let r=["en","vi","zh-CN"],a="en",l="locale";function n(e){return"zh"===e||"zh-CN"===e?"zh-CN":"en"===e?"en":"vi"===e?"vi":a}},94230:(e,t,s)=>{s.d(t,{default:()=>d});var r=s(95155),a=s(12115),l=s(14051),n=s.n(l),i=s(35497),o=s(11059);function d({isOpen:e,provider:t,onSuccess:s,onClose:l}){let[n,d]=(0,a.useState)("loading"),[c,m]=(0,a.useState)(""),[x,u]=(0,a.useState)(null),[h,p]=(0,a.useState)(""),[f,b]=(0,a.useState)(null),{copied:g,copy:j}=(0,o.C)();(0,a.useEffect)(()=>{e&&t&&(async()=>{try{b(null),d("loading");let e=await fetch(`/api/oauth/kiro/social-authorize?provider=${t}`),s=await e.json();if(!e.ok)throw Error(s.error);u(s),m(s.authUrl),d("input"),window.open(s.authUrl,"_blank")}catch(e){b(e.message),d("error")}})()},[e,t]);let y=async()=>{try{let e;b(null);try{e=new URL(h)}catch(e){throw Error("Invalid callback URL format")}let r=e.searchParams.get("code");e.searchParams.get("state");let a=e.searchParams.get("error");if(a)throw Error(e.searchParams.get("error_description")||a);if(!r)throw Error("No authorization code found in URL");let l=await fetch("/api/oauth/kiro/social-exchange",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({code:r,codeVerifier:x.codeVerifier,provider:t})}),n=await l.json();if(!l.ok)throw Error(n.error);d("success"),s?.()}catch(e){b(e.message),d("error")}},v="google"===t?"Google":"GitHub";return(0,r.jsx)(i.aF,{isOpen:e,title:`Connect Kiro via ${v}`,onClose:l,size:"lg",children:(0,r.jsxs)("div",{className:"flex flex-col gap-4",children:["loading"===n&&(0,r.jsxs)("div",{className:"text-center py-6",children:[(0,r.jsx)("div",{className:"size-16 mx-auto mb-4 rounded-full bg-primary/10 flex items-center justify-center",children:(0,r.jsx)("span",{className:"material-symbols-outlined text-3xl text-primary animate-spin",children:"progress_activity"})}),(0,r.jsx)("h3",{className:"text-lg font-semibold mb-2",children:"Initializing..."}),(0,r.jsxs)("p",{className:"text-sm text-text-muted",children:["Setting up ",v," authentication"]})]}),"input"===n&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("p",{className:"text-sm font-medium mb-2",children:"Step 1: Open this URL in your browser"}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)(i.pd,{value:c,readOnly:!0,className:"flex-1 font-mono text-xs"}),(0,r.jsx)(i.$n,{variant:"secondary",icon:"auth_url"===g?"check":"content_copy",onClick:()=>j(c,"auth_url"),children:"Copy"})]})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("p",{className:"text-sm font-medium mb-2",children:"Step 2: Paste the callback URL here"}),(0,r.jsx)("p",{className:"text-xs text-text-muted mb-2",children:"After authorization, copy the full URL from your browser address bar."}),(0,r.jsx)(i.pd,{value:h,onChange:e=>p(e.target.value),placeholder:"kiro://kiro.kiroAgent/authenticate-success?code=...",className:"font-mono text-xs"})]})]}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)(i.$n,{onClick:y,fullWidth:!0,disabled:!h,children:"Connect"}),(0,r.jsx)(i.$n,{onClick:l,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]}),"success"===n&&(0,r.jsxs)("div",{className:"text-center py-6",children:[(0,r.jsx)("div",{className:"size-16 mx-auto mb-4 rounded-full bg-green-100 dark:bg-green-900/30 flex items-center justify-center",children:(0,r.jsx)("span",{className:"material-symbols-outlined text-3xl text-green-600",children:"check_circle"})}),(0,r.jsx)("h3",{className:"text-lg font-semibold mb-2",children:"Connected Successfully!"}),(0,r.jsxs)("p",{className:"text-sm text-text-muted mb-4",children:["Your Kiro account via ",v," has been connected."]}),(0,r.jsx)(i.$n,{onClick:l,fullWidth:!0,children:"Done"})]}),"error"===n&&(0,r.jsxs)("div",{className:"text-center py-6",children:[(0,r.jsx)("div",{className:"size-16 mx-auto mb-4 rounded-full bg-red-100 dark:bg-red-900/30 flex items-center justify-center",children:(0,r.jsx)("span",{className:"material-symbols-outlined text-3xl text-red-600",children:"error"})}),(0,r.jsx)("h3",{className:"text-lg font-semibold mb-2",children:"Connection Failed"}),(0,r.jsx)("p",{className:"text-sm text-red-600 mb-4",children:f}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)(i.$n,{onClick:()=>d("input"),variant:"secondary",fullWidth:!0,children:"Try Again"}),(0,r.jsx)(i.$n,{onClick:l,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})]})})}d.propTypes={isOpen:n().bool.isRequired,provider:n().oneOf(["google","github"]).isRequired,onSuccess:n().func,onClose:n().func.isRequired}},97677:(e,t,s)=>{s.d(t,{default:()=>a});var r=s(95155);function a({text:e,children:t,position:s="top"}){return(0,r.jsxs)("div",{className:"relative inline-flex group",children:[t,(0,r.jsx)("div",{className:`pointer-events-none absolute ${{top:"bottom-full left-1/2 -translate-x-1/2 mb-1.5",bottom:"top-full left-1/2 -translate-x-1/2 mt-1.5",left:"right-full top-1/2 -translate-y-1/2 mr-1.5",right:"left-full top-1/2 -translate-y-1/2 ml-1.5"}[s]} z-50 w-max max-w-56 rounded px-2 py-1 text-[11px] leading-snug bg-gray-900 text-white opacity-0 group-hover:opacity-100 transition-opacity duration-150 whitespace-normal`,children:e})]})}},98542:(e,t,s)=>{s.d(t,{default:()=>l});var r=s(95155),a=s(31474);function l({checked:e=!1,onChange:t,label:s,description:l,disabled:n=!1,size:i="md",className:o}){let d={sm:{track:"w-8 h-4",thumb:"size-3",translate:"translate-x-4"},md:{track:"w-11 h-6",thumb:"size-5",translate:"translate-x-5"},lg:{track:"w-14 h-7",thumb:"size-6",translate:"translate-x-7"}};return(0,r.jsxs)("div",{className:(0,a.cn)("flex items-center gap-3",n&&"opacity-50 cursor-not-allowed",o),children:[(0,r.jsx)("button",{type:"button",role:"switch","aria-checked":e,disabled:n,onClick:()=>{!n&&t&&t(!e)},className:(0,a.cn)("relative inline-flex shrink-0 cursor-pointer rounded-full","transition-colors duration-200 ease-in-out","focus:outline-none focus:ring-1 focus:ring-primary/30",e?"bg-primary":"bg-black/10 dark:bg-white/20",d[i].track,n&&"cursor-not-allowed"),children:(0,r.jsx)("span",{className:(0,a.cn)("pointer-events-none inline-block rounded-full bg-white shadow-sm","transform transition duration-200 ease-in-out",e?d[i].translate:"translate-x-0.5",d[i].thumb,"mt-0.5")})}),(s||l)&&(0,r.jsxs)("div",{className:"flex flex-col",children:[s&&(0,r.jsx)("span",{className:"text-sm font-medium text-text-main",children:s}),l&&(0,r.jsx)("span",{className:"text-xs text-text-muted",children:l})]})]})}}}]);
7
+ `,children:s?(0,r.jsxs)("span",{className:"flex items-center gap-1",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-[11px]",children:"edit"}),e.name]}):e.isCustom?(0,r.jsxs)("span",{className:"flex items-center gap-1",children:[e.name,(0,r.jsx)("span",{className:"text-[9px] opacity-60 font-normal",children:"custom"})]}):e.name},e.id)})})]},e)),0===Object.keys(k).length&&0===w.length&&(0,r.jsxs)("div",{className:"text-center py-4 text-text-muted",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-2xl mb-1 block",children:"search_off"}),(0,r.jsx)("p",{className:"text-xs",children:"No models found"})]})]})]})}m.propTypes={isOpen:n().bool.isRequired,onClose:n().func.isRequired,onSelect:n().func.isRequired,selectedModel:n().string,activeProviders:n().arrayOf(n().shape({provider:n().string.isRequired})),title:n().string,modelAliases:n().object}},73006:(e,t,s)=>{s.d(t,{FE:()=>x,Tl:()=>d,wn:()=>u});var r=s(93308);let a={},l=r.Xn,n=[];function i(){if("u"<typeof document)return r.Xn;let e=document.cookie.split(";").find(e=>e.trim().startsWith(`${r.CL}=`)),t=e?decodeURIComponent(e.split("=")[1]):r.Xn;return(0,r.QC)(t)}async function o(e){if("en"===e){a={};return}try{let t=await fetch(`/i18n/literals/${e}.json`);a=await t.json()}catch(e){console.error("Failed to load translations:",e),a={}}}function d(e){if(!e||"string"!=typeof e)return e;let t=e.trim();return t&&"en"!==l&&a[t]||e}function c(e){if(!e.nodeValue||!e.nodeValue.trim())return;let t=e.parentElement;if(!t)return;let s=t;for(;s;){if(s.hasAttribute&&s.hasAttribute("data-i18n-skip"))return;s=s.parentElement}if(["script","style","code","pre","colgroup","table","thead","tbody","tfoot","tr","select","datalist","optgroup"].includes(t.tagName?.toLowerCase()))return;e._originalText||(e._originalText=e.nodeValue);let r=d(e._originalText);r!==e.nodeValue&&(e.nodeValue=r)}function m(e){let t;if(!e)return;let s=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,null,!1),r=[];for(;t=s.nextNode();)r.push(t);r.forEach(c)}async function x(){l=i(),await o(l),m(document.body),new MutationObserver(e=>{e.forEach(e=>{e.addedNodes.forEach(e=>{e.nodeType===Node.ELEMENT_NODE?m(e):e.nodeType===Node.TEXT_NODE&&c(e)})})}).observe(document.body,{childList:!0,subtree:!0})}async function u(){l=i(),await o(l),n.forEach(e=>e()),m(document.body)}},74891:(e,t,s)=>{s.d(t,{default:()=>h});var r=s(95155),a=s(73321),l=s(12115),n=s(98500),i=s.n(n),o=s(5772),d=s(14051),c=s.n(d),m=s(35497),x=s(90620),u=s(73006);function h({onMenuClick:e,showMenuButton:t=!0}){let s=(0,a.usePathname)(),n=(0,a.useRouter)(),{title:d,description:c,breadcrumbs:h}=(0,l.useMemo)(()=>(e=>{if(!e)return{title:"",description:"",breadcrumbs:[]};let t=e.match(/\/providers\/([^/]+)$/);if(t){let e=t[1],s=x.zN[e]||x.fg[e];if(s)return{title:s.name,description:"",breadcrumbs:[{label:"Providers",href:"/dashboard/providers"},{label:s.name,image:`/providers/${s.id}.png`}]}}return e.includes("/providers")?{title:"Providers",description:"Manage your AI provider connections",breadcrumbs:[]}:e.includes("/combos")?{title:"Combos",description:"Model combos with fallback",breadcrumbs:[]}:e.includes("/usage")?{title:"Usage & Analytics",description:"Monitor your API usage, token consumption, and request logs",breadcrumbs:[]}:e.includes("/mitm")?{title:"MITM Proxy",description:"Intercept CLI tool traffic and route through 9Router",breadcrumbs:[]}:e.includes("/cli-tools")?{title:"CLI Tools",description:"Configure CLI tools",breadcrumbs:[]}:e.includes("/endpoint")?{title:"Endpoint",description:"API endpoint configuration",breadcrumbs:[]}:e.includes("/profile")?{title:"Settings",description:"Manage your preferences",breadcrumbs:[]}:e.includes("/translator")?{title:"Translator",description:"Debug translation flow between formats",breadcrumbs:[]}:e.includes("/console-log")?{title:"Console Log",description:"Live server console output",breadcrumbs:[]}:"/dashboard"===e?{title:"Endpoint",description:"API endpoint configuration",breadcrumbs:[]}:{title:"",description:"",breadcrumbs:[]}})(s),[s]),p=async()=>{try{(await fetch("/api/auth/logout",{method:"POST"})).ok&&(n.push("/login"),n.refresh())}catch(e){console.error("Failed to logout:",e)}};return(0,r.jsxs)("header",{className:"flex items-center justify-between px-8 py-5 border-b border-black/5 dark:border-white/5 bg-bg/80 backdrop-blur-xl z-10 sticky top-0",children:[(0,r.jsx)("div",{className:"flex items-center gap-3 lg:hidden",children:t&&(0,r.jsx)("button",{onClick:e,className:"text-text-main hover:text-primary transition-colors",children:(0,r.jsx)("span",{className:"material-symbols-outlined",children:"menu"})})}),(0,r.jsx)("div",{className:"hidden lg:flex flex-col",children:h.length>0?(0,r.jsx)("div",{className:"flex items-center gap-2",children:h.map((e,t)=>(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[t>0&&(0,r.jsx)("span",{className:"material-symbols-outlined text-text-muted text-base",children:"chevron_right"}),e.href?(0,r.jsx)(i(),{href:e.href,className:"text-text-muted hover:text-primary transition-colors",children:e.label}):(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[e.image&&(0,r.jsx)(o.default,{src:e.image,alt:e.label,width:28,height:28,className:"object-contain rounded max-w-[28px] max-h-[28px]",sizes:"28px",onError:e=>{e.currentTarget.style.display="none"}}),(0,r.jsx)("h1",{className:"text-2xl font-semibold text-text-main tracking-tight",children:(0,u.Tl)(e.label)})]})]},`${e.label}-${e.href||"current"}`))}):d?(0,r.jsxs)("div",{children:[(0,r.jsx)("h1",{className:"text-2xl font-semibold text-text-main tracking-tight",children:(0,u.Tl)(d)}),c&&(0,r.jsx)("p",{className:"text-sm text-text-muted",children:(0,u.Tl)(c)})]}):null}),(0,r.jsxs)("div",{className:"flex items-center gap-3 ml-auto",children:[(0,r.jsx)(m.c5,{}),(0,r.jsx)(m.UW,{}),(0,r.jsx)("button",{onClick:p,className:"flex items-center justify-center p-2 rounded-lg text-text-muted hover:text-red-500 hover:bg-red-500/10 transition-all",title:"Logout",children:(0,r.jsx)("span",{className:"material-symbols-outlined",children:"logout"})})]})]})}h.propTypes={onMenuClick:c().func,showMenuButton:c().bool}},81127:(e,t,s)=>{s.d(t,{ConfirmModal:()=>o,default:()=>i});var r=s(95155),a=s(12115),l=s(31474),n=s(92542);function i({isOpen:e,onClose:t,title:s,children:n,footer:i,size:o="md",closeOnOverlay:d=!0,showCloseButton:c=!0,className:m}){return((0,a.useEffect)(()=>(e?document.body.style.overflow="hidden":document.body.style.overflow="",()=>{document.body.style.overflow=""}),[e]),(0,a.useEffect)(()=>{let s=s=>{"Escape"===s.key&&e&&t()};return document.addEventListener("keydown",s),()=>document.removeEventListener("keydown",s)},[e,t]),e)?(0,r.jsxs)("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",children:[(0,r.jsx)("div",{className:"absolute inset-0 bg-black/30 backdrop-blur-sm",onClick:d?t:void 0}),(0,r.jsxs)("div",{className:(0,l.cn)("relative w-full bg-surface","border border-black/10 dark:border-white/10","rounded-xl shadow-2xl","animate-in fade-in zoom-in-95 duration-200",{sm:"max-w-sm",md:"max-w-md",lg:"max-w-lg",xl:"max-w-xl",full:"max-w-4xl"}[o],m),children:[(s||c)&&(0,r.jsxs)("div",{className:"flex items-center justify-between p-6 border-b border-black/5 dark:border-white/5",children:[(0,r.jsxs)("div",{className:"flex items-center",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 mr-4",children:[(0,r.jsx)("div",{className:"w-3 h-3 rounded-full bg-[#FF5F56]"}),(0,r.jsx)("div",{className:"w-3 h-3 rounded-full bg-[#FFBD2E]"}),(0,r.jsx)("div",{className:"w-3 h-3 rounded-full bg-[#27C93F]"})]}),s&&(0,r.jsx)("h2",{className:"text-lg font-semibold text-text-main",children:s})]}),c&&(0,r.jsx)("button",{onClick:t,className:"p-1.5 rounded-lg text-text-muted hover:bg-black/5 dark:hover:bg-white/5 transition-colors",children:(0,r.jsx)("span",{className:"material-symbols-outlined text-[20px]",children:"close"})})]}),(0,r.jsx)("div",{className:"p-6 max-h-[calc(80vh-140px)] overflow-y-auto",children:n}),i&&(0,r.jsx)("div",{className:"flex items-center justify-end gap-3 p-6 border-t border-black/5 dark:border-white/5",children:i})]})]}):null}function o({isOpen:e,onClose:t,onConfirm:s,title:a="Confirm",message:l,confirmText:o="Confirm",cancelText:d="Cancel",variant:c="danger",loading:m=!1}){return(0,r.jsx)(i,{isOpen:e,onClose:t,title:a,size:"sm",footer:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(n.default,{variant:"ghost",onClick:t,disabled:m,children:d}),(0,r.jsx)(n.default,{variant:c,onClick:s,loading:m,children:o})]}),children:(0,r.jsx)("p",{className:"text-text-muted",children:l})})}},84588:(e,t,s)=>{s.d(t,{default:()=>l});var r=s(95155),a=s(31474);function l({children:e,title:t,subtitle:s,icon:l,action:n,padding:i="md",hover:o=!1,className:d,...c}){return(0,r.jsxs)("div",{className:(0,a.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"}[i],d),...c,children:[(t||n)&&(0,r.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,r.jsxs)("div",{className:"flex items-center gap-3",children:[l&&(0,r.jsx)("div",{className:"p-2 rounded-lg bg-bg text-text-muted",children:(0,r.jsx)("span",{className:"material-symbols-outlined text-[20px]",children:l})}),(0,r.jsxs)("div",{children:[t&&(0,r.jsx)("h3",{className:"text-text-main font-semibold",children:t}),s&&(0,r.jsx)("p",{className:"text-sm text-text-muted",children:s})]})]}),n]}),e]})}l.Section=function({children:e,className:t,...s}){return(0,r.jsx)("div",{className:(0,a.cn)("p-4 rounded-lg","bg-black/[0.02] dark:bg-white/[0.02]","border border-black/5 dark:border-white/5",t),...s,children:e})},l.Row=function({children:e,className:t,...s}){return(0,r.jsx)("div",{className:(0,a.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),...s,children:e})},l.ListItem=function({children:e,actions:t,className:s,...l}){return(0,r.jsxs)("div",{className:(0,a.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",s),...l,children:[(0,r.jsx)("div",{className:"flex-1 min-w-0",children:e}),t&&(0,r.jsx)("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:t})]})}},90085:(e,t,s)=>{s.d(t,{A:()=>i});var r=s(1934),a=s(31692),l=s(90620);function n(e){let t=document.documentElement,s=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light";"dark"===("system"===e?s:e)?t.classList.add("dark"):t.classList.remove("dark")}let i=(0,r.v)((0,a.Zr)((e,t)=>({theme:l.B2.defaultTheme,setTheme:t=>{e({theme:t}),n(t)},toggleTheme:()=>{let s="dark"===t().theme?"light":"dark";e({theme:s}),n(s)},initTheme:()=>{n(t().theme)}}),{name:l.B2.storageKey}))},90620:(e,t,s)=>{s.d(t,{Q2:()=>r.Q2,fg:()=>r.fg,vQ:()=>a,MA:()=>r.MA,UY:()=>n,zN:()=>r.zN,B2:()=>l});var r=s(52679);s(28777);let a={name:"Endpoint Proxy",description:"AI Infrastructure Management",version:"0.3.50"},l={storageKey:"theme",defaultTheme:"system"},n={maxLines:200,pollIntervalMs:1e3}},90882:(e,t,s)=>{s.d(t,{default:()=>d});var r=s(95155),a=s(12115),l=s(14051),n=s.n(l),i=s(35497),o=s(11059);function d({isOpen:e,provider:t,providerInfo:s,onSuccess:l,onClose:n}){let[d,c]=(0,a.useState)("waiting"),[m,x]=(0,a.useState)(null),[u,h]=(0,a.useState)(""),[p,f]=(0,a.useState)(null),[b,g]=(0,a.useState)(!1),[j,y]=(0,a.useState)(null),[v,N]=(0,a.useState)(!1),w=(0,a.useRef)(null),k=(0,a.useRef)(!1),{copied:C,copy:S}=(0,o.C)(),[T,M]=(0,a.useState)(!1),[$,R]=(0,a.useState)("/callback?code=..."),E=(0,a.useRef)(!1);(0,a.useEffect)(()=>{M("localhost"===window.location.hostname||"127.0.0.1"===window.location.hostname),R(`${window.location.origin}/callback?code=...`)},[]);let L=(0,a.useCallback)(async(e,s)=>{if(m)try{let r=await fetch(`/api/oauth/${t}/exchange`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({code:e,redirectUri:m.redirectUri,codeVerifier:m.codeVerifier,state:s})}),a=await r.json();if(!r.ok)throw Error(a.error);c("success"),l?.()}catch(e){f(e.message),c("error")}},[m,t,l]),O=(0,a.useCallback)(async(e,s,r,a)=>{k.current=!1,N(!0);for(let n=0;n<60;n++){if(k.current){console.log("[OAuthModal] Polling aborted"),N(!1);return}if(await new Promise(e=>setTimeout(e,1e3*r)),k.current){console.log("[OAuthModal] Polling aborted after sleep"),N(!1);return}try{let n=await fetch(`/api/oauth/${t}/poll`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({deviceCode:e,codeVerifier:s,extraData:a})}),i=await n.json();if(i.success){k.current=!0,c("success"),N(!1),l?.();return}if("expired_token"===i.error||"access_denied"===i.error)throw Error(i.errorDescription||i.error);"slow_down"===i.error&&(r=Math.min(r+5,30))}catch(e){f(e.message),c("error"),N(!1);return}}f("Authorization timeout"),c("error"),N(!1)},[t,l]),I=(0,a.useCallback)(async()=>{if(t)try{let e;if(f(null),["github","qwen","kiro","kimi-coding","kilocode"].includes(t)){g(!0),c("waiting");let e=await fetch(`/api/oauth/${t}/device-code`),s=await e.json();if(!e.ok)throw Error(s.error);y(s);let r=s.verification_uri_complete||s.verification_uri;r&&window.open(r,"_blank");let a="kiro"===t?{_clientId:s._clientId,_clientSecret:s._clientSecret}:null;O(s.device_code,s.codeVerifier,s.interval||5,a);return}if("codex"===t)e="http://localhost:1455/auth/callback";else{let t=window.location.port||("https:"===window.location.protocol?"443":"80");e=`http://localhost:${t}/callback`}let s=await fetch(`/api/oauth/${t}/authorize?redirect_uri=${encodeURIComponent(e)}`),r=await s.json();if(!s.ok)throw Error(r.error);x({...r,redirectUri:e}),"codex"!==t&&T?(c("waiting"),w.current=window.open(r.authUrl,"oauth_popup","width=600,height=700"),w.current||c("input")):(c("input"),window.open(r.authUrl,"_blank"))}catch(e){f(e.message),c("error")}},[t,T,O]);(0,a.useEffect)(()=>{e&&t?(x(null),h(""),f(null),g(!1),y(null),N(!1),k.current=!1,I()):e||(k.current=!0)},[e,t,I]),(0,a.useEffect)(()=>{let e;if(!m)return;E.current=!1;let t=async e=>{if(E.current)return;let{code:t,state:s,error:r,errorDescription:a}=e;if(r){E.current=!0,f(a||r),c("error");return}t&&(E.current=!0,await L(t,s))},s=e=>{let s=e.origin.includes("localhost")||e.origin.includes("127.0.0.1"),r=e.origin===window.location.origin;(s||r)&&e.data?.type==="oauth_callback"&&t(e.data.data)};window.addEventListener("message",s);try{(e=new BroadcastChannel("oauth_callback")).onmessage=e=>t(e.data)}catch(e){console.log("BroadcastChannel not supported")}let r=e=>{if("oauth_callback"===e.key&&e.newValue)try{let s=JSON.parse(e.newValue);t(s),localStorage.removeItem("oauth_callback")}catch(e){console.log("Failed to parse localStorage data")}};window.addEventListener("storage",r);try{let e=localStorage.getItem("oauth_callback");if(e){let s=JSON.parse(e);s.timestamp&&Date.now()-s.timestamp<3e4&&t(s),localStorage.removeItem("oauth_callback")}}catch{}return()=>{window.removeEventListener("message",s),window.removeEventListener("storage",r),e&&e.close()}},[m,L]);let z=async()=>{try{f(null);let e=new URL(u),t=e.searchParams.get("code"),s=e.searchParams.get("state"),r=e.searchParams.get("error");if(r)throw Error(e.searchParams.get("error_description")||r);if(!t)throw Error("No authorization code found in URL");await L(t,s)}catch(e){f(e.message),c("error")}},P=(0,a.useCallback)(()=>{n()},[n]);return t&&s?(0,r.jsx)(i.aF,{isOpen:e,title:`Connect ${s.name}`,onClose:P,size:"lg",children:(0,r.jsxs)("div",{className:"flex flex-col gap-4",children:["waiting"===d&&!b&&(0,r.jsxs)("div",{className:"text-center py-6",children:[(0,r.jsx)("div",{className:"size-16 mx-auto mb-4 rounded-full bg-primary/10 flex items-center justify-center",children:(0,r.jsx)("span",{className:"material-symbols-outlined text-3xl text-primary animate-spin",children:"progress_activity"})}),(0,r.jsx)("h3",{className:"text-lg font-semibold mb-2",children:"Waiting for Authorization"}),(0,r.jsx)("p",{className:"text-sm text-text-muted mb-4",children:"Complete the authorization in the popup window."}),(0,r.jsx)(i.$n,{variant:"ghost",onClick:()=>c("input"),children:"Popup blocked? Enter URL manually"})]}),"waiting"===d&&b&&j&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"text-center py-4",children:[(0,r.jsx)("p",{className:"text-sm text-text-muted mb-4",children:"Visit the URL below and enter the code:"}),(0,r.jsxs)("div",{className:"bg-sidebar p-4 rounded-lg mb-4",children:[(0,r.jsx)("p",{className:"text-xs text-text-muted mb-1",children:"Verification URL"}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("code",{className:"flex-1 text-sm break-all",children:j.verification_uri}),(0,r.jsx)(i.$n,{size:"sm",variant:"ghost",icon:"verify_url"===C?"check":"content_copy",onClick:()=>S(j.verification_uri,"verify_url")})]})]}),(0,r.jsxs)("div",{className:"bg-primary/10 p-4 rounded-lg",children:[(0,r.jsx)("p",{className:"text-xs text-text-muted mb-1",children:"Your Code"}),(0,r.jsxs)("div",{className:"flex items-center justify-center gap-2",children:[(0,r.jsx)("p",{className:"text-2xl font-mono font-bold text-primary",children:j.user_code}),(0,r.jsx)(i.$n,{size:"sm",variant:"ghost",icon:"user_code"===C?"check":"content_copy",onClick:()=>S(j.user_code,"user_code")})]})]})]}),v&&(0,r.jsxs)("div",{className:"flex items-center justify-center gap-2 text-sm text-text-muted",children:[(0,r.jsx)("span",{className:"material-symbols-outlined animate-spin",children:"progress_activity"}),"Waiting for authorization..."]})]}),"input"===d&&!b&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("p",{className:"text-sm font-medium mb-2",children:"Step 1: Open this URL in your browser"}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)(i.pd,{value:m?.authUrl||"",readOnly:!0,className:"flex-1 font-mono text-xs"}),(0,r.jsx)(i.$n,{variant:"secondary",icon:"auth_url"===C?"check":"content_copy",onClick:()=>S(m?.authUrl,"auth_url"),children:"Copy"})]})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("p",{className:"text-sm font-medium mb-2",children:"Step 2: Paste the callback URL here"}),(0,r.jsx)("p",{className:"text-xs text-text-muted mb-2",children:"After authorization, copy the full URL from your browser."}),(0,r.jsx)(i.pd,{value:u,onChange:e=>h(e.target.value),placeholder:$,className:"font-mono text-xs"})]})]}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)(i.$n,{onClick:z,fullWidth:!0,disabled:!u,children:"Connect"}),(0,r.jsx)(i.$n,{onClick:P,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]}),"success"===d&&(0,r.jsxs)("div",{className:"text-center py-6",children:[(0,r.jsx)("div",{className:"size-16 mx-auto mb-4 rounded-full bg-green-100 dark:bg-green-900/30 flex items-center justify-center",children:(0,r.jsx)("span",{className:"material-symbols-outlined text-3xl text-green-600",children:"check_circle"})}),(0,r.jsx)("h3",{className:"text-lg font-semibold mb-2",children:"Connected Successfully!"}),(0,r.jsxs)("p",{className:"text-sm text-text-muted mb-4",children:["Your ",s.name," account has been connected."]}),(0,r.jsx)(i.$n,{onClick:P,fullWidth:!0,children:"Done"})]}),"error"===d&&(0,r.jsxs)("div",{className:"text-center py-6",children:[(0,r.jsx)("div",{className:"size-16 mx-auto mb-4 rounded-full bg-red-100 dark:bg-red-900/30 flex items-center justify-center",children:(0,r.jsx)("span",{className:"material-symbols-outlined text-3xl text-red-600",children:"error"})}),(0,r.jsx)("h3",{className:"text-lg font-semibold mb-2",children:"Connection Failed"}),(0,r.jsx)("p",{className:"text-sm text-red-600 mb-4",children:p}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)(i.$n,{onClick:I,variant:"secondary",fullWidth:!0,children:"Try Again"}),(0,r.jsx)(i.$n,{onClick:P,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})]})}):null}d.propTypes={isOpen:n().bool.isRequired,provider:n().string,providerInfo:n().shape({name:n().string}),onSuccess:n().func,onClose:n().func.isRequired}},91450:(e,t,s)=>{s.d(t,{default:()=>i});var r=s(95155),a=s(14051),l=s.n(a),n=s(38587);function i({children:e}){return(0,r.jsxs)("div",{className:"min-h-screen flex flex-col relative bg-bg transition-colors duration-500 overflow-x-hidden selection:bg-primary/20 selection:text-primary",children:[(0,r.jsx)("div",{className:"fixed top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-[800px] h-[800px] bg-primary/5 dark:bg-primary/5 rounded-full blur-[100px] pointer-events-none z-0"}),(0,r.jsx)("div",{className:"fixed bottom-0 right-0 w-[600px] h-[600px] bg-orange-200/20 dark:bg-orange-900/10 rounded-full blur-[120px] pointer-events-none z-0 translate-y-1/3 translate-x-1/3"}),(0,r.jsx)("div",{className:"absolute top-6 right-6 z-20",children:(0,r.jsx)(n.default,{variant:"card"})}),(0,r.jsx)("main",{className:"flex-1 flex flex-col items-center justify-center p-4 sm:p-6 z-10 w-full h-full",children:e})]})}i.propTypes={children:l().node.isRequired}},92173:(e,t,s)=>{s.d(t,{default:()=>c});var r=s(95155),a=s(98500),l=s.n(a),n=s(90620);let i=[{label:"Features",href:"#features"},{label:"Pricing",href:"#pricing"},{label:"Changelog",href:"#"}],o=[{label:"Documentation",href:"#"},{label:"API Reference",href:"#"},{label:"Help Center",href:"#"}],d=[{label:"About",href:"#"},{label:"Blog",href:"#"},{label:"Contact",href:"#"}];function c(){return(0,r.jsx)("footer",{className:"bg-bg border-t border-border pt-16 pb-12",children:(0,r.jsxs)("div",{className:"container mx-auto px-4 sm:px-6 lg:px-8",children:[(0,r.jsxs)("div",{className:"grid grid-cols-2 md:grid-cols-4 lg:grid-cols-5 gap-10 mb-12",children:[(0,r.jsxs)("div",{className:"col-span-2 lg:col-span-2",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 mb-6",children:[(0,r.jsx)("div",{className:"size-6 text-primary",children:(0,r.jsx)("svg",{className:"w-full h-full",fill:"currentColor",viewBox:"0 0 48 48",children:(0,r.jsx)("path",{clipRule:"evenodd",d:"M12.0799 24L4 19.2479L9.95537 8.75216L18.04 13.4961L18.0446 4H29.9554L29.96 13.4961L38.0446 8.75216L44 19.2479L35.92 24L44 28.7521L38.0446 39.2479L29.96 34.5039L29.9554 44H18.0446L18.04 34.5039L9.95537 39.2479L4 28.7521L12.0799 24Z",fillRule:"evenodd"})})}),(0,r.jsx)("span",{className:"text-xl font-bold text-text-main",children:n.vQ.name})]}),(0,r.jsx)("p",{className:"text-text-muted mb-6 max-w-sm font-light",children:"The unified interface for modern AI infrastructure. Secure, observable, and scalable."}),(0,r.jsxs)("div",{className:"flex gap-4",children:[(0,r.jsx)("a",{href:"#",className:"text-gray-400 hover:text-primary transition-colors","aria-label":"Twitter",children:(0,r.jsx)("svg",{className:"w-5 h-5",fill:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{d:"M22.46 6c-.77.35-1.6.58-2.46.69.88-.53 1.56-1.37 1.88-2.38-.83.5-1.75.85-2.72 1.05C18.37 4.5 17.26 4 16 4c-2.35 0-4.27 1.92-4.27 4.29 0 .34.04.67.11.98C8.28 9.09 5.11 7.38 3 4.79c-.37.63-.58 1.37-.58 2.15 0 1.49.75 2.81 1.91 3.56-.71 0-1.37-.2-1.95-.5v.03c0 2.08 1.48 3.82 3.44 4.21a4.22 4.22 0 0 1-1.93.07 4.28 4.28 0 0 0 4 2.98 8.521 8.521 0 0 1-5.33 1.84c-.34 0-.68-.02-1.02-.06C3.44 20.29 5.7 21 8.12 21 16 21 20.33 14.46 20.33 8.79c0-.19 0-.37-.01-.56.84-.6 1.56-1.36 2.14-2.23z"})})}),(0,r.jsx)("a",{href:"#",className:"text-gray-400 hover:text-primary transition-colors","aria-label":"GitHub",children:(0,r.jsx)("svg",{className:"w-5 h-5",fill:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{d:"M12 2C6.477 2 2 6.484 2 12.017c0 4.425 2.865 8.18 6.839 9.504.5.092.682-.217.682-.483 0-.237-.008-.868-.013-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.029-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0 1 12 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.202 2.398.1 2.651.64.7 1.028 1.595 1.028 2.688 0 3.848-2.339 4.695-4.566 4.943.359.309.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.019 10.019 0 0 0 22 12.017C22 6.484 17.522 2 12 2z"})})})]})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("h4",{className:"font-semibold text-text-main mb-4",children:"Product"}),(0,r.jsx)("ul",{className:"flex flex-col gap-3 text-sm text-text-muted font-light",children:i.map(e=>(0,r.jsx)("li",{children:(0,r.jsx)(l(),{href:e.href,className:"hover:text-primary transition-colors",children:e.label})},e.label))})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("h4",{className:"font-semibold text-text-main mb-4",children:"Resources"}),(0,r.jsx)("ul",{className:"flex flex-col gap-3 text-sm text-text-muted font-light",children:o.map(e=>(0,r.jsx)("li",{children:(0,r.jsx)(l(),{href:e.href,className:"hover:text-primary transition-colors",children:e.label})},e.label))})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("h4",{className:"font-semibold text-text-main mb-4",children:"Company"}),(0,r.jsx)("ul",{className:"flex flex-col gap-3 text-sm text-text-muted font-light",children:d.map(e=>(0,r.jsx)("li",{children:(0,r.jsx)(l(),{href:e.href,className:"hover:text-primary transition-colors",children:e.label})},e.label))})]})]}),(0,r.jsxs)("div",{className:"border-t border-border pt-8 flex flex-col md:flex-row justify-between items-center gap-4",children:[(0,r.jsxs)("p",{className:"text-sm text-text-muted",children:["\xa9 ",new Date().getFullYear()," ",n.vQ.name," Inc. All rights reserved."]}),(0,r.jsxs)("div",{className:"flex gap-6 text-sm text-text-muted",children:[(0,r.jsx)(l(),{href:"#",className:"hover:text-primary transition-colors",children:"Privacy Policy"}),(0,r.jsx)(l(),{href:"#",className:"hover:text-primary transition-colors",children:"Terms of Service"})]})]})]})})}},92542:(e,t,s)=>{s.d(t,{default:()=>i});var r=s(95155),a=s(31474);let l={primary:"bg-gradient-to-b from-primary to-primary-hover text-white shadow-sm",secondary:"bg-white dark:bg-white/10 border border-black/10 dark:border-white/10 text-text-main hover:bg-black/5 dark:hover:bg-white/5",outline:"border border-black/15 dark:border-white/15 text-text-main hover:bg-black/5",ghost:"text-text-muted hover:bg-black/5 dark:hover:bg-white/5 hover:text-text-main",danger:"bg-red-500 text-white hover:bg-red-600 shadow-sm"},n={sm:"h-7 px-3 text-xs rounded-md",md:"h-9 px-4 text-sm rounded-lg",lg:"h-11 px-6 text-sm rounded-lg"};function i({children:e,variant:t="primary",size:s="md",icon:i,iconRight:o,disabled:d=!1,loading:c=!1,fullWidth:m=!1,className:x,...u}){return(0,r.jsxs)("button",{className:(0,a.cn)("inline-flex items-center justify-center gap-2 font-medium transition-all duration-200 cursor-pointer","active:scale-[0.99] disabled:opacity-50 disabled:cursor-not-allowed disabled:active:scale-100",l[t],n[s],m&&"w-full",x),disabled:d||c,...u,children:[c?(0,r.jsx)("span",{className:"material-symbols-outlined animate-spin text-[18px]",children:"progress_activity"}):i?(0,r.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:i}):null,e,o&&!c&&(0,r.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:o})]})}},92622:(e,t,s)=>{s.d(t,{default:()=>b});var r=s(95155),a=s(12115),l=s(14051),n=s.n(l),i=s(98500),o=s.n(i),d=s(73321),c=s(31474),m=s(90620),x=s(92542),u=s(81127);let h=[{href:"/dashboard/endpoint",label:"Endpoint",icon:"api"},{href:"/dashboard/providers",label:"Providers",icon:"dns"},{href:"/dashboard/proxy-pools",label:"Proxy Pools",icon:"lan"},{href:"/dashboard/combos",label:"Combos",icon:"layers"},{href:"/dashboard/usage",label:"Usage",icon:"bar_chart"},{href:"/dashboard/quota",label:"Quota Tracker",icon:"data_usage"},{href:"/dashboard/mitm",label:"MITM",icon:"security"},{href:"/dashboard/cli-tools",label:"CLI Tools",icon:"terminal"}],p=[{href:"/dashboard/console-log",label:"Console Log",icon:"terminal"}],f=[{href:"/dashboard/profile",label:"Settings",icon:"settings"}];function b({onClose:e}){let t=(0,d.usePathname)(),[s,l]=(0,a.useState)(!1),[n,i]=(0,a.useState)(!1),[b,g]=(0,a.useState)(!1),[j,y]=(0,a.useState)(null),[v,N]=(0,a.useState)(!1);(0,a.useEffect)(()=>{fetch("/api/settings").then(e=>e.json()).then(e=>{e.enableTranslator&&N(!0)}).catch(()=>{})},[]),(0,a.useEffect)(()=>{fetch("/api/version").then(e=>e.json()).then(e=>{e.hasUpdate&&y(e)}).catch(()=>{})},[]);let w=e=>"/dashboard/endpoint"===e?"/dashboard"===t||t.startsWith("/dashboard/endpoint"):t.startsWith(e),k=async()=>{i(!0);try{await fetch("/api/shutdown",{method:"POST"})}catch(e){}i(!1),l(!1),g(!0)};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("aside",{className:"flex w-72 flex-col border-r border-black/5 dark:border-white/5 bg-vibrancy backdrop-blur-xl transition-colors duration-300",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 px-6 pt-5 pb-2",children:[(0,r.jsx)("div",{className:"w-3 h-3 rounded-full bg-[#FF5F56]"}),(0,r.jsx)("div",{className:"w-3 h-3 rounded-full bg-[#FFBD2E]"}),(0,r.jsx)("div",{className:"w-3 h-3 rounded-full bg-[#27C93F]"})]}),(0,r.jsxs)("div",{className:"px-6 py-4 flex flex-col gap-2",children:[(0,r.jsxs)(o(),{href:"/dashboard",className:"flex items-center gap-3",children:[(0,r.jsx)("div",{className:"flex items-center justify-center size-9 rounded bg-linear-to-br from-[#f97815] to-[#c2590a]",children:(0,r.jsx)("span",{className:"material-symbols-outlined text-white text-[20px]",children:"hub"})}),(0,r.jsxs)("div",{className:"flex flex-col",children:[(0,r.jsx)("h1",{className:"text-lg font-semibold tracking-tight text-text-main",children:m.vQ.name}),(0,r.jsxs)("span",{className:"text-xs text-text-muted",children:["v",m.vQ.version]})]})]}),j&&(0,r.jsxs)("div",{className:"flex flex-col gap-0.5",children:[(0,r.jsxs)("span",{className:"text-xs font-semibold text-green-600 dark:text-amber-500",children:["↑ New version available: v",j.latestVersion]}),(0,r.jsx)("code",{className:"text-[10px] text-green-600/80 dark:text-amber-400/70 font-mono select-all",children:"npm install -g 9router@latest"})]})]}),(0,r.jsxs)("nav",{className:"flex-1 px-4 py-2 space-y-1 overflow-y-auto custom-scrollbar",children:[h.map(t=>(0,r.jsxs)(o(),{href:t.href,onClick:e,className:(0,c.cn)("flex items-center gap-3 px-4 py-2 rounded-lg transition-all group",w(t.href)?"bg-primary/10 text-primary":"text-text-muted hover:bg-surface/50 hover:text-text-main"),children:[(0,r.jsx)("span",{className:(0,c.cn)("material-symbols-outlined text-[18px]",w(t.href)?"fill-1":"group-hover:text-primary transition-colors"),children:t.icon}),(0,r.jsx)("span",{className:"text-sm font-medium",children:t.label})]},t.href)),(0,r.jsxs)("div",{className:"pt-4 mt-2",children:[(0,r.jsx)("p",{className:"px-4 text-xs font-semibold text-text-muted/60 uppercase tracking-wider mb-2",children:"Debug"}),v&&(0,r.jsxs)(o(),{href:"/dashboard/translator",onClick:e,className:(0,c.cn)("flex items-center gap-3 px-4 py-2 rounded-lg transition-all group",w("/dashboard/translator")?"bg-primary/10 text-primary":"text-text-muted hover:bg-surface/50 hover:text-text-main"),children:[(0,r.jsx)("span",{className:(0,c.cn)("material-symbols-outlined text-[18px]",w("/dashboard/translator")?"fill-1":"group-hover:text-primary transition-colors"),children:"translate"}),(0,r.jsx)("span",{className:"text-sm font-medium",children:"Translator"})]}),p.map(t=>(0,r.jsxs)(o(),{href:t.href,onClick:e,className:(0,c.cn)("flex items-center gap-3 px-4 py-2 rounded-lg transition-all group",w(t.href)?"bg-primary/10 text-primary":"text-text-muted hover:bg-surface/50 hover:text-text-main"),children:[(0,r.jsx)("span",{className:(0,c.cn)("material-symbols-outlined text-[18px]",w(t.href)?"fill-1":"group-hover:text-primary transition-colors"),children:t.icon}),(0,r.jsx)("span",{className:"text-sm font-medium",children:t.label})]},t.href))]}),(0,r.jsxs)("div",{className:"pt-4 mt-2",children:[(0,r.jsx)("p",{className:"px-4 text-xs font-semibold text-text-muted/60 uppercase tracking-wider mb-2",children:"System"}),f.map(t=>(0,r.jsxs)(o(),{href:t.href,onClick:e,className:(0,c.cn)("flex items-center gap-3 px-4 py-2 rounded-lg transition-all group",w(t.href)?"bg-primary/10 text-primary":"text-text-muted hover:bg-surface/50 hover:text-text-main"),children:[(0,r.jsx)("span",{className:(0,c.cn)("material-symbols-outlined text-[18px]",w(t.href)?"fill-1":"group-hover:text-primary transition-colors"),children:t.icon}),(0,r.jsx)("span",{className:"text-sm font-medium",children:t.label})]},t.href))]})]}),(0,r.jsxs)("div",{className:"p-3 border-t border-black/5 dark:border-white/5",children:[(0,r.jsxs)("div",{className:"flex items-start gap-2 p-2 rounded-lg bg-surface/50 mb-2",children:[(0,r.jsx)("div",{className:"flex items-center justify-center size-6 rounded-md bg-blue-500/10 text-blue-500 shrink-0 mt-0.5",children:(0,r.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"info"})}),(0,r.jsx)("div",{className:"flex flex-col",children:(0,r.jsx)("span",{className:"text-xs font-medium text-text-main leading-relaxed",children:"Service is running in terminal. You can close this web page. Shutdown will stop the service."})})]}),(0,r.jsx)(x.default,{variant:"outline",fullWidth:!0,icon:"power_settings_new",onClick:()=>l(!0),className:"text-red-500 border-red-200 hover:bg-red-50 hover:border-red-300",children:"Shutdown"})]})]}),(0,r.jsx)(u.ConfirmModal,{isOpen:s,onClose:()=>l(!1),onConfirm:k,title:"Close Proxy",message:"Are you sure you want to close the proxy server?",confirmText:"Close",cancelText:"Cancel",variant:"danger",loading:n}),b&&(0,r.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/80 backdrop-blur-sm",children:(0,r.jsxs)("div",{className:"text-center p-8",children:[(0,r.jsx)("div",{className:"flex items-center justify-center size-16 rounded-full bg-red-500/20 text-red-500 mx-auto mb-4",children:(0,r.jsx)("span",{className:"material-symbols-outlined text-[32px]",children:"power_off"})}),(0,r.jsx)("h2",{className:"text-xl font-semibold text-white mb-2",children:"Server Disconnected"}),(0,r.jsx)("p",{className:"text-text-muted mb-6",children:"The proxy server has been stopped."}),(0,r.jsx)(x.default,{variant:"secondary",onClick:()=>globalThis.location.reload(),children:"Reload Page"})]})})]})}b.propTypes={onClose:n().func}},93308:(e,t,s)=>{s.d(t,{CL:()=>l,QC:()=>n,Xn:()=>a,YZ:()=>r});let r=["en","vi","zh-CN"],a="en",l="locale";function n(e){return"zh"===e||"zh-CN"===e?"zh-CN":"en"===e?"en":"vi"===e?"vi":a}},94230:(e,t,s)=>{s.d(t,{default:()=>d});var r=s(95155),a=s(12115),l=s(14051),n=s.n(l),i=s(35497),o=s(11059);function d({isOpen:e,provider:t,onSuccess:s,onClose:l}){let[n,d]=(0,a.useState)("loading"),[c,m]=(0,a.useState)(""),[x,u]=(0,a.useState)(null),[h,p]=(0,a.useState)(""),[f,b]=(0,a.useState)(null),{copied:g,copy:j}=(0,o.C)();(0,a.useEffect)(()=>{e&&t&&(async()=>{try{b(null),d("loading");let e=await fetch(`/api/oauth/kiro/social-authorize?provider=${t}`),s=await e.json();if(!e.ok)throw Error(s.error);u(s),m(s.authUrl),d("input"),window.open(s.authUrl,"_blank")}catch(e){b(e.message),d("error")}})()},[e,t]);let y=async()=>{try{let e;b(null);try{e=new URL(h)}catch(e){throw Error("Invalid callback URL format")}let r=e.searchParams.get("code");e.searchParams.get("state");let a=e.searchParams.get("error");if(a)throw Error(e.searchParams.get("error_description")||a);if(!r)throw Error("No authorization code found in URL");let l=await fetch("/api/oauth/kiro/social-exchange",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({code:r,codeVerifier:x.codeVerifier,provider:t})}),n=await l.json();if(!l.ok)throw Error(n.error);d("success"),s?.()}catch(e){b(e.message),d("error")}},v="google"===t?"Google":"GitHub";return(0,r.jsx)(i.aF,{isOpen:e,title:`Connect Kiro via ${v}`,onClose:l,size:"lg",children:(0,r.jsxs)("div",{className:"flex flex-col gap-4",children:["loading"===n&&(0,r.jsxs)("div",{className:"text-center py-6",children:[(0,r.jsx)("div",{className:"size-16 mx-auto mb-4 rounded-full bg-primary/10 flex items-center justify-center",children:(0,r.jsx)("span",{className:"material-symbols-outlined text-3xl text-primary animate-spin",children:"progress_activity"})}),(0,r.jsx)("h3",{className:"text-lg font-semibold mb-2",children:"Initializing..."}),(0,r.jsxs)("p",{className:"text-sm text-text-muted",children:["Setting up ",v," authentication"]})]}),"input"===n&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("p",{className:"text-sm font-medium mb-2",children:"Step 1: Open this URL in your browser"}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)(i.pd,{value:c,readOnly:!0,className:"flex-1 font-mono text-xs"}),(0,r.jsx)(i.$n,{variant:"secondary",icon:"auth_url"===g?"check":"content_copy",onClick:()=>j(c,"auth_url"),children:"Copy"})]})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("p",{className:"text-sm font-medium mb-2",children:"Step 2: Paste the callback URL here"}),(0,r.jsx)("p",{className:"text-xs text-text-muted mb-2",children:"After authorization, copy the full URL from your browser address bar."}),(0,r.jsx)(i.pd,{value:h,onChange:e=>p(e.target.value),placeholder:"kiro://kiro.kiroAgent/authenticate-success?code=...",className:"font-mono text-xs"})]})]}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)(i.$n,{onClick:y,fullWidth:!0,disabled:!h,children:"Connect"}),(0,r.jsx)(i.$n,{onClick:l,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]}),"success"===n&&(0,r.jsxs)("div",{className:"text-center py-6",children:[(0,r.jsx)("div",{className:"size-16 mx-auto mb-4 rounded-full bg-green-100 dark:bg-green-900/30 flex items-center justify-center",children:(0,r.jsx)("span",{className:"material-symbols-outlined text-3xl text-green-600",children:"check_circle"})}),(0,r.jsx)("h3",{className:"text-lg font-semibold mb-2",children:"Connected Successfully!"}),(0,r.jsxs)("p",{className:"text-sm text-text-muted mb-4",children:["Your Kiro account via ",v," has been connected."]}),(0,r.jsx)(i.$n,{onClick:l,fullWidth:!0,children:"Done"})]}),"error"===n&&(0,r.jsxs)("div",{className:"text-center py-6",children:[(0,r.jsx)("div",{className:"size-16 mx-auto mb-4 rounded-full bg-red-100 dark:bg-red-900/30 flex items-center justify-center",children:(0,r.jsx)("span",{className:"material-symbols-outlined text-3xl text-red-600",children:"error"})}),(0,r.jsx)("h3",{className:"text-lg font-semibold mb-2",children:"Connection Failed"}),(0,r.jsx)("p",{className:"text-sm text-red-600 mb-4",children:f}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)(i.$n,{onClick:()=>d("input"),variant:"secondary",fullWidth:!0,children:"Try Again"}),(0,r.jsx)(i.$n,{onClick:l,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})]})})}d.propTypes={isOpen:n().bool.isRequired,provider:n().oneOf(["google","github"]).isRequired,onSuccess:n().func,onClose:n().func.isRequired}},97677:(e,t,s)=>{s.d(t,{default:()=>a});var r=s(95155);function a({text:e,children:t,position:s="top"}){return(0,r.jsxs)("div",{className:"relative inline-flex group",children:[t,(0,r.jsx)("div",{className:`pointer-events-none absolute ${{top:"bottom-full left-1/2 -translate-x-1/2 mb-1.5",bottom:"top-full left-1/2 -translate-x-1/2 mt-1.5",left:"right-full top-1/2 -translate-y-1/2 mr-1.5",right:"left-full top-1/2 -translate-y-1/2 ml-1.5"}[s]} z-50 w-max max-w-56 rounded px-2 py-1 text-[11px] leading-snug bg-gray-900 text-white opacity-0 group-hover:opacity-100 transition-opacity duration-150 whitespace-normal`,children:e})]})}},98542:(e,t,s)=>{s.d(t,{default:()=>l});var r=s(95155),a=s(31474);function l({checked:e=!1,onChange:t,label:s,description:l,disabled:n=!1,size:i="md",className:o}){let d={sm:{track:"w-8 h-4",thumb:"size-3",translate:"translate-x-4"},md:{track:"w-11 h-6",thumb:"size-5",translate:"translate-x-5"},lg:{track:"w-14 h-7",thumb:"size-6",translate:"translate-x-7"}};return(0,r.jsxs)("div",{className:(0,a.cn)("flex items-center gap-3",n&&"opacity-50 cursor-not-allowed",o),children:[(0,r.jsx)("button",{type:"button",role:"switch","aria-checked":e,disabled:n,onClick:()=>{!n&&t&&t(!e)},className:(0,a.cn)("relative inline-flex shrink-0 cursor-pointer rounded-full","transition-colors duration-200 ease-in-out","focus:outline-none focus:ring-1 focus:ring-primary/30",e?"bg-primary":"bg-black/10 dark:bg-white/20",d[i].track,n&&"cursor-not-allowed"),children:(0,r.jsx)("span",{className:(0,a.cn)("pointer-events-none inline-block rounded-full bg-white shadow-sm","transform transition duration-200 ease-in-out",e?d[i].translate:"translate-x-0.5",d[i].thumb,"mt-0.5")})}),(s||l)&&(0,r.jsxs)("div",{className:"flex flex-col",children:[s&&(0,r.jsx)("span",{className:"text-sm font-medium text-text-main",children:s}),l&&(0,r.jsx)("span",{className:"text-xs text-text-muted",children:l})]})]})}}}]);
@@ -1 +1 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[2134],{52397:(e,t,i)=>{Promise.resolve().then(i.bind(i,97162))},97162:(e,t,i)=>{"use strict";i.r(t),i.d(t,{default:()=>h});var s=i(95155),a=i(12115),r=i(14051),l=i.n(r),o=i(73321),n=i(98500),d=i.n(n),c=i(5772),p=i(35497),m=i(52679),x=i(28777),u=i(11059);function h(){let e=(0,o.useParams)(),t=(0,o.useRouter)(),i=e.id,[r,l]=(0,a.useState)([]),[n,h]=(0,a.useState)(!0),[g,b]=(0,a.useState)(null),[S,A]=(0,a.useState)([]),[$,P]=(0,a.useState)(!1),[T,O]=(0,a.useState)(!1),[E,R]=(0,a.useState)(!1),[_,I]=(0,a.useState)(!1),[D,q]=(0,a.useState)(!1),[U,K]=(0,a.useState)(!1),[M,L]=(0,a.useState)(null),[z,J]=(0,a.useState)({}),[F,W]=(0,a.useState)(!1),[V,B]=(0,a.useState)({}),[Z,G]=(0,a.useState)(""),[Q,H]=(0,a.useState)(null),[X,Y]=(0,a.useState)(!1),[ee,et]=(0,a.useState)([]),[ei,es]=(0,a.useState)("__none__"),[ea,er]=(0,a.useState)(!1),[el,eo]=(0,a.useState)(null),[en,ed]=(0,a.useState)(""),{copied:ec,copy:ep}=(0,u.C)(),em=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}:m.zN[i]||m.fg[i]||m.IS[i],ex=!!m.zN[i]||!!m.IS[i],eu=(0,x.KC)(i),eh=(0,m.wG)(i),ey=(0,m.mq)(i),ef=(0,m.gb)(i),eg=ey||ef,ev=eg?i:eh,eb=eg?g?.prefix||i:eh,ej=(0,a.useCallback)(async()=>{try{let e=await fetch("/api/models/alias"),t=await e.json();e.ok&&J(t.aliases||{})}catch(e){console.log("Error fetching aliases:",e)}},[]),eN=(0,a.useCallback)(async()=>{try{let[e,t,s,a]=await Promise.all([fetch("/api/providers",{cache:"no-store"}),fetch("/api/provider-nodes",{cache:"no-store"}),fetch("/api/proxy-pools?isActive=true",{cache:"no-store"}),fetch("/api/settings",{cache:"no-store"})]),r=await e.json(),o=await t.json(),n=await s.json(),d=a.ok?await a.json():{};if(e.ok){let e=(r.connections||[]).filter(e=>e.provider===i);l(e)}s.ok&&A(n.proxyPools||[]);let c=(d.providerStrategies||{})[i]||{};if(eo(c.fallbackStrategy||null),ed(null!=c.stickyRoundRobinLimit?String(c.stickyRoundRobinLimit):"1"),t.ok){let e=(o.nodes||[]).find(e=>e.id===i)||null;if(!e&&eg)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}b(e)}}catch(e){console.log("Error fetching connections:",e)}finally{h(!1)}},[i,eg]),ek=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&&(b(s.node),await eN(),q(!1))}catch(e){console.log("Error updating provider node:",e)}},eC=async(e,t)=>{try{let s=await fetch("/api/settings",{cache:"no-store"}),a=(s.ok?await s.json():{}).providerStrategies||{},r={};e&&(r.fallbackStrategy=e),"round-robin"===e&&""!==t&&(r.stickyRoundRobinLimit=Number(t)||3);let l={...a};0===Object.keys(r).length?delete l[i]:l[i]=r,await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerStrategies:l})})}catch(e){console.log("Error saving provider strategy:",e)}};(0,a.useEffect)(()=>{eN(),ej()},[eN,ej]);let ew=async(e,t,i=eh)=>{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 ej();else{let t=await e.json();alert(t.error||"Failed to set alias")}}catch(e){console.log("Error setting alias:",e)}},eS=async e=>{try{(await fetch(`/api/models/alias?alias=${encodeURIComponent(e)}`,{method:"DELETE"})).ok&&await ej()}catch(e){console.log("Error deleting alias:",e)}},eA=async e=>{if(confirm("Delete this connection?"))try{(await fetch(`/api/providers/${e}`,{method:"DELETE"})).ok&&l(r.filter(t=>t.id!==e))}catch(e){console.log("Error deleting connection:",e)}},e$=()=>{eN(),P(!1)},eP=async e=>{try{(await fetch("/api/providers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:i,...e})})).ok&&(await eN(),R(!1))}catch(e){console.log("Error saving connection:",e)}},eT=async e=>{try{(await fetch(`/api/providers/${M.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})).ok&&(await eN(),I(!1))}catch(e){console.log("Error updating connection:",e)}},eO=async(e,t)=>{try{(await fetch(`/api/providers/${e}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({isActive:t})})).ok&&l(i=>i.map(i=>i.id===e?{...i,isActive:t}:i))}catch(e){console.log("Error updating connection status:",e)}},eE=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 eN()}catch(e){console.log("Error swapping priority:",e)}},eR=r.filter(e=>ee.includes(e.id));r.length>0&&(ee.length,r.length),(0,a.useEffect)(()=>{et(e=>e.filter(e=>r.some(t=>t.id===e)))},[r]);let e_=(()=>{if(0===eR.length)return"";let e=new Set(eR.map(e=>e.providerSpecificData?.proxyPoolId||"__none__"));if(1===e.size){let t=[...e][0];if("__none__"===t)return"All selected currently unbound";let i=S.find(e=>e.id===t);return`All selected currently bound to ${i?.name||t}`}return"Selected connections have mixed proxy bindings"})(),eI=()=>{ea||K(!1)},eD=async()=>{if(0===ee.length)return;let e="__none__"===ei?null:ei;er(!0);try{let t=[];for(let i of ee)try{let s=await fetch(`/api/providers/${i}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({proxyPoolId:e})});t.push(s.ok)}catch(e){console.log("Error applying bulk proxy pool for",i,e),t.push(!1)}let i=t.filter(e=>!e).length;i>0&&alert(`Updated with ${i} failed request(s).`),await eN(),et([]),es("__none__"),K(!1)}catch(e){console.log("Error applying bulk proxy pool:",e)}finally{er(!1)}},eq=(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)("div",{className:"flex items-stretch",children:(0,s.jsx)("div",{className:"flex-1 min-w-0",children:(0,s.jsx)(j,{connection:e,proxyPools:S,isOAuth:ex,isFirst:0===t,isLast:t===r.length-1,onMoveUp:()=>eE(e,r[t-1]),onMoveDown:()=>eE(e,r[t+1]),onToggleActive:t=>eO(e.id,t),onUpdateProxy:async t=>{try{(await fetch(`/api/providers/${e.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({proxyPoolId:t||null})})).ok&&l(i=>i.map(i=>i.id===e.id?{...i,providerSpecificData:{...i.providerSpecificData,proxyPoolId:t||null}}:i))}catch(e){console.log("Error updating proxy:",e)}},onEdit:()=>{L(e),I(!0)},onDelete:()=>eA(e.id)})})},e.id))}),eU=[{value:"__none__",label:"None"},...S.map(e=>({value:e.id,label:e.name}))],eK=0===ee.length?"Select one or more connections, then click Proxy Action.":e_,eM=ee.length>0&&!ea,eL=(0,s.jsx)(p.aF,{isOpen:U,onClose:eI,title:`Proxy Action (${ee.length} selected)`,children:(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,s.jsx)(p.l6,{label:"Proxy Pool",value:ei,onChange:e=>es(e.target.value),options:eU,placeholder:"None"}),(0,s.jsx)("p",{className:"text-xs text-text-muted",children:eK}),(0,s.jsx)("p",{className:"text-xs text-text-muted",children:"Selecting None will unbind selected connections from proxy pool."}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(p.$n,{onClick:eD,fullWidth:!0,disabled:!eM,children:ea?"Applying...":"Apply"}),(0,s.jsx)(p.$n,{onClick:eI,variant:"ghost",fullWidth:!0,disabled:ea,children:"Cancel"})]})]})}),ez=async e=>{if(!Q){H(e);try{let t=await fetch("/api/models/test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:`${ev}/${e}`})}),i=await t.json();B(t=>({...t,[e]:i.ok?"ok":"error"})),G(i.ok?"":i.error||"Model not reachable")}catch{B(t=>({...t,[e]:"error"})),G("Network error")}finally{H(null)}}};return n?(0,s.jsxs)("div",{className:"flex flex-col gap-8",children:[(0,s.jsx)(p.Qv,{}),(0,s.jsx)(p.Qv,{})]}):em?(0,s.jsxs)("div",{className:"flex flex-col gap-8",children:[(0,s.jsxs)("div",{children:[(0,s.jsxs)(d(),{href:"/dashboard/providers",className:"inline-flex items-center gap-1 text-sm text-text-muted hover:text-primary transition-colors mb-4",children:[(0,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:`${em.color}15`},children:F?(0,s.jsx)("span",{className:"text-sm font-bold",style:{color:em.color},children:em.textIcon||em.id.slice(0,2).toUpperCase()}):(0,s.jsx)(c.default,{src:ey&&em.apiType?"responses"===em.apiType?"/providers/oai-r.png":"/providers/oai-cc.png":ef?"/providers/anthropic-m.png":`/providers/${em.id}.png`,alt:em.name,width:48,height:48,className:"object-contain rounded-lg max-w-[48px] max-h-[48px]",sizes:"48px",onError:()=>W(!0)})}),(0,s.jsxs)("div",{children:[(0,s.jsx)("h1",{className:"text-3xl font-semibold tracking-tight",children:em.name}),(0,s.jsxs)("p",{className:"text-text-muted",children:[r.length," connection",1===r.length?"":"s"]})]})]})]}),eg&&g&&(0,s.jsxs)(p.Zp,{children:[(0,s.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("h2",{className:"text-lg font-semibold",children:ef?"Anthropic Compatible Details":"OpenAI Compatible Details"}),(0,s.jsxs)("p",{className:"text-sm text-text-muted",children:[ef?"Messages API":"responses"===g.apiType?"Responses API":"Chat Completions"," \xb7 ",(g.baseUrl||"").replace(/\/$/,""),"/",ef?"messages":"responses"===g.apiType?"responses":"chat/completions"]})]}),(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)(p.$n,{size:"sm",icon:"add",onClick:()=>R(!0),disabled:r.length>0,children:"Add"}),(0,s.jsx)(p.$n,{size:"sm",variant:"secondary",icon:"edit",onClick:()=>q(!0),children:"Edit"}),(0,s.jsx)(p.$n,{size:"sm",variant:"secondary",icon:"delete",onClick:async()=>{if(confirm(`Delete this ${ef?"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)(p.Zp,{children:[(0,s.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,s.jsx)("h2",{className:"text-lg font-semibold",children:"Connections"}),(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("span",{className:"text-xs text-text-muted font-medium",children:"Round Robin"}),(0,s.jsx)(p.lM,{checked:"round-robin"===el,onChange:e=>{let t=e?"round-robin":null,i=e?en||"1":en;e&&!en&&ed("1"),eo(t),eC(t,i)}}),"round-robin"===el&&(0,s.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,s.jsx)("span",{className:"text-xs text-text-muted",children:"Sticky:"}),(0,s.jsx)("input",{type:"number",min:1,value:en,onChange:e=>{var t;ed(t=e.target.value),eC("round-robin",t)},placeholder:"1",className:"w-14 px-2 py-1 text-xs border border-border rounded-md bg-background focus:outline-none focus:border-primary"})]})]})]}),0===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:ex?"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"}),!eg&&(0,s.jsxs)("div",{className:"flex gap-2 justify-center",children:["iflow"===i&&(0,s.jsx)(p.$n,{icon:"cookie",variant:"secondary",onClick:()=>O(!0),children:"Cookie Auth"}),(0,s.jsx)(p.$n,{icon:"add",onClick:()=>ex?P(!0):R(!0),children:"iflow"===i?"OAuth":"Add Connection"})]})]}):(0,s.jsxs)(s.Fragment,{children:[eq,!eg&&(0,s.jsxs)("div",{className:"flex gap-2 mt-4",children:["iflow"===i&&(0,s.jsx)(p.$n,{size:"sm",icon:"cookie",variant:"secondary",onClick:()=>O(!0),title:"Add connection using browser cookie",children:"Cookie"}),(0,s.jsx)(p.$n,{size:"sm",icon:"add",onClick:()=>ex?P(!0):R(!0),children:"Add"})]})]})]}),(0,s.jsxs)(p.Zp,{children:[(0,s.jsx)("div",{className:"flex items-center justify-between mb-4",children:(0,s.jsx)("h2",{className:"text-lg font-semibold",children:em.passthroughModels?"Model Aliases":"Available Models"})}),!!Z&&(0,s.jsx)("p",{className:"text-xs text-red-500 mb-3 break-words",children:Z}),(()=>{if(eg)return(0,s.jsx)(v,{providerStorageAlias:ev,providerDisplayAlias:eb,modelAliases:z,copied:ec,onCopy:ep,onSetAlias:ew,onDeleteAlias:eS,connections:r,isAnthropic:ef});if(em.passthroughModels)return(0,s.jsx)(f,{providerAlias:eh,modelAliases:z,copied:ec,onCopy:ep,onSetAlias:ew,onDeleteAlias:eS});let e=Object.entries(z).filter(([e,t])=>{let i=`${ev}/`;if(!t.startsWith(i))return!1;let s=t.slice(i.length);return!eu.some(e=>e.id===s)&&e===s}).map(([e,t])=>({id:t.slice(`${ev}/`.length),alias:e,fullModel:t}));return(0,s.jsxs)("div",{className:"flex flex-wrap gap-3",children:[eu.map(e=>{let t=`${ev}/${e.id}`,a=`${i}/${e.id}`,l=Object.entries(z).find(([,e])=>e===t||e===a)?.[0];return(0,s.jsx)(y,{model:e,fullModel:`${eb}/${e.id}`,alias:l,copied:ec,onCopy:ep,onSetAlias:t=>ew(e.id,t,ev),onDeleteAlias:()=>eS(l),testStatus:V[e.id],onTest:r.length>0?()=>ez(e.id):void 0,isTesting:Q===e.id},e.id)}),e.map(e=>(0,s.jsx)(y,{model:{id:e.id},fullModel:`${eb}/${e.id}`,alias:e.alias,copied:ec,onCopy:ep,onSetAlias:()=>{},onDeleteAlias:()=>eS(e.alias),testStatus:V[e.id],onTest:r.length>0?()=>ez(e.id):void 0,isTesting:Q===e.id,isCustom:!0},e.id)),(0,s.jsxs)("button",{onClick:()=>Y(!0),className:"flex items-center gap-1.5 px-3 py-2 rounded-lg border border-dashed border-black/15 dark:border-white/15 text-xs text-text-muted hover:text-primary hover:border-primary/40 transition-colors",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-sm",children:"add"}),"Add Model"]})]})})()]}),eL,"kiro"===i?(0,s.jsx)(p.Mh,{isOpen:$,providerInfo:em,onSuccess:e$,onClose:()=>P(!1)}):"cursor"===i?(0,s.jsx)(p.G9,{isOpen:$,onSuccess:e$,onClose:()=>P(!1)}):(0,s.jsx)(p.LF,{isOpen:$,provider:i,providerInfo:em,onSuccess:e$,onClose:()=>P(!1)}),"iflow"===i&&(0,s.jsx)(p.vE,{isOpen:T,onSuccess:()=>{eN(),O(!1)},onClose:()=>O(!1)}),(0,s.jsx)(N,{isOpen:E,provider:i,providerName:em.name,isCompatible:eg,isAnthropic:ef,proxyPools:S,onSave:eP,onClose:()=>R(!1)}),(0,s.jsx)(k,{isOpen:_,connection:M,proxyPools:S,onSave:eT,onClose:()=>I(!1)}),eg&&(0,s.jsx)(C,{isOpen:D,node:g,onSave:ek,onClose:()=>q(!1),isAnthropic:ef}),!eg&&!em?.passthroughModels&&(0,s.jsx)(w,{isOpen:X,providerAlias:ev,providerDisplayAlias:eb,onSave:async e=>{await ew(e,e,ev),Y(!1)},onClose:()=>Y(!1)})]}):(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)(d(),{href:"/dashboard/providers",className:"text-primary mt-4 inline-block",children:"Back to Providers"})]})}function y({model:e,fullModel:t,alias:i,copied:a,onCopy:r,testStatus:l,isCustom:o,onDeleteAlias:n,onTest:d,isTesting:c}){let p="ok"===l?"#22c55e":"error"===l?"#ef4444":void 0;return(0,s.jsx)("div",{className:`group px-3 py-2 rounded-lg border ${"ok"===l?"border-green-500/40":"error"===l?"border-red-500/40":"border-border"} hover:bg-sidebar/50`,children:(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-base",style:p?{color:p}:void 0,children:"ok"===l?"check_circle":"error"===l?"cancel":"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}),d&&(0,s.jsx)("button",{onClick:d,disabled:c,className:`p-0.5 hover:bg-sidebar rounded text-text-muted hover:text-primary transition-opacity ${c?"opacity-100":"opacity-0 group-hover:opacity-100"}`,title:"Test model",children:(0,s.jsx)("span",{className:"material-symbols-outlined text-sm",style:c?{animation:"spin 1s linear infinite"}:void 0,children:c?"progress_activity":"science"})}),(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"})}),o&&(0,s.jsx)("button",{onClick:n,className:"p-0.5 hover:bg-red-500/10 rounded text-text-muted hover:text-red-500 opacity-0 group-hover:opacity-100 transition-opacity ml-auto",title:"Remove custom model",children:(0,s.jsx)("span",{className:"material-symbols-outlined text-sm",children:"close"})})]})})}function f({providerAlias:e,modelAliases:t,copied:i,onCopy:r,onSetAlias:l,onDeleteAlias:o}){let[n,d]=(0,a.useState)(""),[c,m]=(0,a.useState)(!1),x=Object.entries(t).filter(([,t])=>t.startsWith(`${e}/`)).map(([t,i])=>({modelId:i.replace(`${e}/`,""),fullModel:i,alias:t})),u=async()=>{let e;if(!n.trim()||c)return;let i=n.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),d("")}catch(e){console.log("Error adding model:",e)}finally{m(!1)}};return(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,s.jsx)("p",{className:"text-sm text-text-muted",children:"OpenRouter supports any model. Add models and create aliases for quick access."}),(0,s.jsxs)("div",{className:"flex items-end gap-2",children:[(0,s.jsxs)("div",{className:"flex-1",children:[(0,s.jsx)("label",{htmlFor:"new-model-input",className:"text-xs text-text-muted mb-1 block",children:"Model ID (from OpenRouter)"}),(0,s.jsx)("input",{id:"new-model-input",type:"text",value:n,onChange:e=>d(e.target.value),onKeyDown:e=>"Enter"===e.key&&u(),placeholder:"anthropic/claude-3-opus",className:"w-full px-3 py-2 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary"})]}),(0,s.jsx)(p.$n,{size:"sm",icon:"add",onClick:u,disabled:!n.trim()||c,children:c?"Adding...":"Add"})]}),x.length>0&&(0,s.jsx)("div",{className:"flex flex-col gap-3",children:x.map(({modelId:e,fullModel:t,alias:a})=>(0,s.jsx)(g,{modelId:e,fullModel:t,copied:i,onCopy:r,onDeleteAlias:()=>o(a)},t))})]})}function g({modelId:e,fullModel:t,copied:i,onCopy:a,onDeleteAlias:r,onTest:l,testStatus:o,isTesting:n}){let d="ok"===o?"#22c55e":"error"===o?"#ef4444":void 0;return(0,s.jsxs)("div",{className:`flex items-center gap-3 p-3 rounded-lg border ${"ok"===o?"border-green-500/40":"error"===o?"border-red-500/40":"border-border"} hover:bg-sidebar/50`,children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-base text-text-muted",style:d?{color:d}:void 0,children:"ok"===o?"check_circle":"error"===o?"cancel":"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"})}),l&&(0,s.jsx)("button",{onClick:l,disabled:n,className:"p-0.5 hover:bg-sidebar rounded text-text-muted hover:text-primary transition-colors",title:"Test model",children:(0,s.jsx)("span",{className:"material-symbols-outlined text-sm",style:n?{animation:"spin 1s linear infinite"}:void 0,children:n?"progress_activity":"science"})})]})]}),(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 v({providerStorageAlias:e,providerDisplayAlias:t,modelAliases:i,copied:r,onCopy:l,onSetAlias:o,onDeleteAlias:n,connections:d,isAnthropic:c}){let[m,x]=(0,a.useState)(""),[u,h]=(0,a.useState)(!1),[y,f]=(0,a.useState)(!1),[v,b]=(0,a.useState)(null),[j,N]=(0,a.useState)({}),k=async t=>{if(!v){b(t);try{let i=await fetch("/api/models/test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:`${e}/${t}`})}),s=await i.json();N(e=>({...e,[t]:s.ok?"ok":"error"}))}catch{N(e=>({...e,[t]:"error"}))}finally{b(null)}}},C=Object.entries(i).filter(([,t])=>t.startsWith(`${e}/`)).map(([t,i])=>({modelId:i.replace(`${e}/`,""),fullModel:i,alias:t})),w=e=>{let s,a=(s=e.split("/"))[s.length-1];if(!i[a])return a;let r=`${t}-${a}`;return i[r]?null:r},S=async()=>{if(!m.trim()||u)return;let t=m.trim(),i=w(t);if(!i)return void alert("All suggested aliases already exist. Please choose a different model or remove conflicting aliases.");h(!0);try{await o(t,i,e),x("")}catch(e){console.log("Error adding model:",e)}finally{h(!1)}},A=async()=>{if(y)return;let t=d.find(e=>!1!==e.isActive);if(t){f(!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=w(i);s&&(await o(i,s,e),r+=1)}0===r&&alert("No new models were added.")}catch(e){console.log("Error importing models:",e)}finally{f(!1)}}},$=d.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 ",c?"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=>x(e.target.value),onKeyDown:e=>"Enter"===e.key&&S(),placeholder:c?"claude-3-opus-20240229":"gpt-4o",className:"w-full px-3 py-2 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary"})]}),(0,s.jsx)(p.$n,{size:"sm",icon:"add",onClick:S,disabled:!m.trim()||u,children:u?"Adding...":"Add"}),(0,s.jsx)(p.$n,{size:"sm",variant:"secondary",icon:"download",onClick:A,disabled:!$||y,children:y?"Importing...":"Import from /models"})]}),!$&&(0,s.jsx)("p",{className:"text-xs text-text-muted",children:"Add a connection to enable importing models."}),C.length>0&&(0,s.jsx)("div",{className:"flex flex-col gap-3",children:C.map(({modelId:e,fullModel:i,alias:a})=>(0,s.jsx)(g,{modelId:e,fullModel:`${t}/${e}`,copied:r,onCopy:l,onDeleteAlias:()=>n(a),onTest:d.length>0?()=>k(e):void 0,testStatus:j[e],isTesting:v===e},i))})]})}function b({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}function j({connection:e,proxyPools:t,isOAuth:i,isFirst:r,isLast:l,onMoveUp:o,onMoveDown:n,onToggleActive:d,onUpdateProxy:c,onEdit:m,onDelete:x}){let[u,h]=(0,a.useState)(!1),[y,f]=(0,a.useState)(!1),g=(0,a.useRef)(null),v=new Map((t||[]).map(e=>[e.id,e])),j=e.providerSpecificData?.proxyPoolId||null,N=j?v.get(j):null,k=e.providerSpecificData?.connectionProxyEnabled===!0&&!!e.providerSpecificData?.connectionProxyUrl,C=!!j||k,w=N?`Pool: ${N.name}`:j?`Pool: ${j} (inactive/missing)`:k?`Legacy: ${e.providerSpecificData?.connectionProxyUrl}`:"",S="";if(N?.proxyUrl||e.providerSpecificData?.connectionProxyUrl){let t=N?.proxyUrl||e.providerSpecificData?.connectionProxyUrl;try{let e=new URL(t);S=`${e.protocol}//${e.hostname}${e.port?`:${e.port}`:""}`}catch{S=t}}let A=N?.noProxy||e.providerSpecificData?.connectionNoProxy||"",$="default";N?.isActive===!0?$="success":(j||k)&&($="error"),(0,a.useEffect)(()=>{if(!u)return;let e=e=>{g.current&&!g.current.contains(e.target)&&h(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[u]);let P=async e=>{f(!0);try{await c("__none__"===e?null:e)}finally{f(!1),h(!1)}},T=i?e.name||e.email||e.displayName||"OAuth Account":e.name,[O,E]=(0,a.useState)(!1),R=Object.entries(e).filter(([e])=>e.startsWith("modelLock_")).map(([,e])=>e).filter(e=>!!e).sort()[0]||null;(0,a.useEffect)(()=>{let t=()=>{E(!!Object.entries(e).filter(([e])=>e.startsWith("modelLock_")).map(([,e])=>e).filter(e=>e&&new Date(e).getTime()>Date.now()).sort()[0])};t();let i=R?setInterval(t,1e3):null;return()=>{i&&clearInterval(i)}},[R]);let _="unavailable"!==e.testStatus||O?e.testStatus:"active";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:o,disabled:r,className:`p-0.5 rounded ${r?"text-text-muted/30 cursor-not-allowed":"hover:bg-sidebar text-text-muted hover:text-primary"}`,children:(0,s.jsx)("span",{className:"material-symbols-outlined text-sm",children:"keyboard_arrow_up"})}),(0,s.jsx)("button",{onClick:n,disabled:l,className:`p-0.5 rounded ${l?"text-text-muted/30 cursor-not-allowed":"hover:bg-sidebar text-text-muted hover:text-primary"}`,children:(0,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:i?"lock":"key"}),(0,s.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,s.jsx)("p",{className:"text-sm font-medium truncate",children:T}),(0,s.jsxs)("div",{className:"flex items-center gap-2 mt-1",children:[(0,s.jsx)(p.Ex,{variant:!1===e.isActive?"default":"active"===_||"success"===_?"success":"error"===_||"expired"===_||"unavailable"===_?"error":"default",size:"sm",dot:!0,children:!1===e.isActive?"disabled":_||"Unknown"}),C&&(0,s.jsx)(p.Ex,{variant:$,size:"sm",children:"Proxy"}),O&&!1!==e.isActive&&(0,s.jsx)(b,{until:R}),e.lastError&&!1!==e.isActive&&(0,s.jsx)("span",{className:"text-xs text-red-500 truncate max-w-[300px]",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]})]}),C&&(0,s.jsxs)("div",{className:"mt-1 flex items-center gap-2 flex-wrap",children:[(0,s.jsx)("span",{className:"text-[11px] text-text-muted truncate max-w-[420px]",title:w,children:w}),S&&(0,s.jsx)("code",{className:"text-[10px] font-mono bg-black/5 dark:bg-white/5 px-1 py-0.5 rounded text-text-muted",children:S}),A&&(0,s.jsxs)("span",{className:"text-[11px] text-text-muted truncate max-w-[320px]",title:A,children:["no_proxy: ",A]})]})]})]}),(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsxs)("div",{className:"flex gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[(t||[]).length>0&&(0,s.jsxs)("div",{className:"relative",ref:g,children:[(0,s.jsxs)("button",{onClick:()=>h(e=>!e),className:`flex flex-col items-center px-2 py-1 rounded hover:bg-black/5 dark:hover:bg-white/5 transition-colors ${C?"text-primary":"text-text-muted hover:text-primary"}`,disabled:y,children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:y?"progress_activity":"lan"}),(0,s.jsx)("span",{className:"text-[10px] leading-tight",children:"Proxy"})]}),u&&(0,s.jsxs)("div",{className:"absolute right-0 top-full mt-1 z-50 bg-bg border border-border rounded-lg shadow-lg py-1 min-w-[160px]",children:[(0,s.jsx)("button",{onClick:()=>P("__none__"),className:`w-full text-left px-3 py-1.5 text-sm hover:bg-black/5 dark:hover:bg-white/5 ${!j?"text-primary font-medium":"text-text-main"}`,children:"None"}),(t||[]).map(e=>(0,s.jsx)("button",{onClick:()=>P(e.id),className:`w-full text-left px-3 py-1.5 text-sm hover:bg-black/5 dark:hover:bg-white/5 ${j===e.id?"text-primary font-medium":"text-text-main"}`,children:e.name},e.id))]})]}),(0,s.jsxs)("button",{onClick:m,className:"flex flex-col items-center px-2 py-1 rounded hover:bg-black/5 dark:hover:bg-white/5 text-text-muted hover:text-primary",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"edit"}),(0,s.jsx)("span",{className:"text-[10px] leading-tight",children:"Edit"})]}),(0,s.jsxs)("button",{onClick:x,className:"flex flex-col items-center px-2 py-1 rounded hover:bg-red-500/10 text-red-500",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"delete"}),(0,s.jsx)("span",{className:"text-[10px] leading-tight",children:"Delete"})]})]}),(0,s.jsx)(p.lM,{size:"sm",checked:e.isActive??!0,onChange:d,title:e.isActive??!0?"Disable connection":"Enable connection"})]})]})}function N({isOpen:e,provider:t,providerName:i,isCompatible:r,isAnthropic:l,proxyPools:o,onSave:n,onClose:d}){let c="__none__",[m,x]=(0,a.useState)({name:"",apiKey:"",priority:1,proxyPoolId:c}),[u,h]=(0,a.useState)(!1),[y,f]=(0,a.useState)(null),[g,v]=(0,a.useState)(!1),b=async()=>{h(!0);try{let e=await fetch("/api/providers/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:t,apiKey:m.apiKey})}),i=await e.json();f(i.valid?"success":"failed")}catch{f("failed")}finally{h(!1)}},j=async()=>{if(t&&m.apiKey){v(!0);try{let e=!1;try{h(!0),f(null);let i=await fetch("/api/providers/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:t,apiKey:m.apiKey})});e=!!(await i.json()).valid,f(e?"success":"failed")}catch{f("failed")}finally{h(!1)}await n({name:m.name,apiKey:m.apiKey,priority:m.priority,proxyPoolId:m.proxyPoolId===c?null:m.proxyPoolId,testStatus:e?"active":"unknown"})}finally{v(!1)}}};return t?(0,s.jsx)(p.aF,{isOpen:e,title:`Add ${i||t} API Key`,onClose:d,children:(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,s.jsx)(p.pd,{label:"Name",value:m.name,onChange:e=>x({...m,name:e.target.value}),placeholder:"Production Key"}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(p.pd,{label:"API Key",type:"password",value:m.apiKey,onChange:e=>x({...m,apiKey:e.target.value}),className:"flex-1"}),(0,s.jsx)("div",{className:"pt-6",children:(0,s.jsx)(p.$n,{onClick:b,disabled:!m.apiKey||u||g,variant:"secondary",children:u?"Checking...":"Check"})})]}),y&&(0,s.jsx)(p.Ex,{variant:"success"===y?"success":"error",children:"success"===y?"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)(p.pd,{label:"Priority",type:"number",value:m.priority,onChange:e=>x({...m,priority:Number.parseInt(e.target.value)||1})}),(0,s.jsx)(p.l6,{label:"Proxy Pool",value:m.proxyPoolId,onChange:e=>x({...m,proxyPoolId:e.target.value}),options:[{value:c,label:"None"},...(o||[]).map(e=>({value:e.id,label:e.name}))],placeholder:"None"}),0===(o||[]).length&&(0,s.jsx)("p",{className:"text-xs text-text-muted",children:"No active proxy pools available. Create one in Proxy Pools page first."}),(0,s.jsx)("p",{className:"text-xs text-text-muted",children:"Legacy manual proxy fields are still accepted by API for backward compatibility."}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(p.$n,{onClick:j,fullWidth:!0,disabled:!m.name||!m.apiKey||g,children:g?"Saving...":"Save"}),(0,s.jsx)(p.$n,{onClick:d,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})}):null}function k({isOpen:e,connection:t,proxyPools:i,onSave:r,onClose:l}){let[o,n]=(0,a.useState)({name:"",priority:1,apiKey:""}),[d,c]=(0,a.useState)(!1),[x,u]=(0,a.useState)(null),[h,y]=(0,a.useState)(!1),[f,g]=(0,a.useState)(null),[v,b]=(0,a.useState)(!1);(0,a.useEffect)(()=>{t&&(n({name:t.name||"",priority:t.priority||1,apiKey:""}),u(null),g(null))},[t]);let j=async()=>{if(t?.provider){c(!0),u(null);try{let e=await fetch(`/api/providers/${t.id}/test`,{method:"POST"}),i=await e.json();u(i.valid?"success":"failed")}catch{u("failed")}finally{c(!1)}}},N=async()=>{if(t?.provider&&o.apiKey){y(!0),g(null);try{let e=await fetch("/api/providers/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:t.provider,apiKey:o.apiKey})}),i=await e.json();g(i.valid?"success":"failed")}catch{g("failed")}finally{y(!1)}}},k=async()=>{b(!0);try{let e={name:o.name,priority:o.priority};if(!C&&o.apiKey){e.apiKey=o.apiKey;let i="success"===f;if(!i)try{y(!0),g(null);let e=await fetch("/api/providers/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:t.provider,apiKey:o.apiKey})});i=!!(await e.json()).valid,g(i?"success":"failed")}catch{g("failed")}finally{y(!1)}i&&(e.testStatus="active",e.lastError=null,e.lastErrorAt=null)}await r(e)}finally{b(!1)}};if(!t)return null;let C="oauth"===t.authType,w=(0,m.mq)(t.provider)||(0,m.gb)(t.provider);return(0,s.jsx)(p.aF,{isOpen:e,title:"Edit Connection",onClose:l,children:(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,s.jsx)(p.pd,{label:"Name",value:o.name,onChange:e=>n({...o,name:e.target.value}),placeholder: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})]}),(0,s.jsx)(p.pd,{label:"Priority",type:"number",value:o.priority,onChange:e=>n({...o,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)(p.pd,{label:"API Key",type:"password",value:o.apiKey,onChange:e=>n({...o,apiKey:e.target.value}),placeholder:"Enter new API key",hint:"Leave blank to keep the current API key.",className:"flex-1"}),(0,s.jsx)("div",{className:"pt-6",children:(0,s.jsx)(p.$n,{onClick:N,disabled:!o.apiKey||h||v,variant:"secondary",children:h?"Checking...":"Check"})})]}),f&&(0,s.jsx)(p.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)(p.$n,{onClick:j,variant:"secondary",disabled:d,children:d?"Testing...":"Test Connection"}),x&&(0,s.jsx)(p.Ex,{variant:"success"===x?"success":"error",children:"success"===x?"Valid":"Failed"})]}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(p.$n,{onClick:k,fullWidth:!0,disabled:v,children:v?"Saving...":"Save"}),(0,s.jsx)(p.$n,{onClick:l,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})})}function C({isOpen:e,node:t,onSave:i,onClose:r,isAnthropic:l}){let[o,n]=(0,a.useState)({name:"",prefix:"",apiType:"chat",baseUrl:"https://api.openai.com/v1"}),[d,c]=(0,a.useState)(!1),[m,x]=(0,a.useState)(""),[u,h]=(0,a.useState)(!1),[y,f]=(0,a.useState)(null);(0,a.useEffect)(()=>{t&&n({name:t.name||"",prefix:t.prefix||"",apiType:t.apiType||"chat",baseUrl:t.baseUrl||(l?"https://api.anthropic.com/v1":"https://api.openai.com/v1")})},[t,l]);let g=async()=>{if(o.name.trim()&&o.prefix.trim()&&o.baseUrl.trim()){c(!0);try{let e={name:o.name,prefix:o.prefix,baseUrl:o.baseUrl};l||(e.apiType=o.apiType),await i(e)}finally{c(!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:o.baseUrl,apiKey:m,type:l?"anthropic-compatible":"openai-compatible"})}),t=await e.json();f(t.valid?"success":"failed")}catch{f("failed")}finally{h(!1)}};return t?(0,s.jsx)(p.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)(p.pd,{label:"Name",value:o.name,onChange:e=>n({...o,name:e.target.value}),placeholder:`${l?"Anthropic":"OpenAI"} Compatible (Prod)`,hint:"Required. A friendly label for this node."}),(0,s.jsx)(p.pd,{label:"Prefix",value:o.prefix,onChange:e=>n({...o,prefix:e.target.value}),placeholder:l?"ac-prod":"oc-prod",hint:"Required. Used as the provider prefix for model IDs."}),!l&&(0,s.jsx)(p.l6,{label:"API Type",options:[{value:"chat",label:"Chat Completions"},{value:"responses",label:"Responses API"}],value:o.apiType,onChange:e=>n({...o,apiType:e.target.value})}),(0,s.jsx)(p.pd,{label:"Base URL",value:o.baseUrl,onChange:e=>n({...o,baseUrl:e.target.value}),placeholder:l?"https://api.anthropic.com/v1":"https://api.openai.com/v1",hint:`Use the base URL (ending in /v1) for your ${l?"Anthropic":"OpenAI"}-compatible API.`}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(p.pd,{label:"API Key (for Check)",type:"password",value:m,onChange:e=>x(e.target.value),className:"flex-1"}),(0,s.jsx)("div",{className:"pt-6",children:(0,s.jsx)(p.$n,{onClick:v,disabled:!m||u||!o.baseUrl.trim(),variant:"secondary",children:u?"Checking...":"Check"})})]}),y&&(0,s.jsx)(p.Ex,{variant:"success"===y?"success":"error",children:"success"===y?"Valid":"Invalid"}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(p.$n,{onClick:g,fullWidth:!0,disabled:!o.name.trim()||!o.prefix.trim()||!o.baseUrl.trim()||d,children:d?"Saving...":"Save"}),(0,s.jsx)(p.$n,{onClick:r,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})}):null}function w({isOpen:e,providerAlias:t,providerDisplayAlias:i,onSave:r,onClose:l}){let[o,n]=(0,a.useState)(""),[d,c]=(0,a.useState)(null),[m,x]=(0,a.useState)(""),[u,h]=(0,a.useState)(!1);(0,a.useEffect)(()=>{e&&(n(""),c(null),x(""))},[e]);let y=async()=>{if(o.trim()){c("testing"),x("");try{let e=await fetch("/api/models/test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:`${t}/${o.trim()}`})}),i=await e.json();c(i.ok?"ok":"error"),x(i.error||"")}catch(e){c("error"),x(e.message)}}},f=async()=>{if(o.trim()&&!u){h(!0);try{await r(o.trim())}finally{h(!1)}}};return(0,s.jsx)(p.aF,{isOpen:e,onClose:l,title:"Add Custom Model",children:(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"text-sm font-medium mb-1.5 block",children:"Model ID"}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)("input",{type:"text",value:o,onChange:e=>{n(e.target.value),c(null),x("")},onKeyDown:e=>{"Enter"===e.key&&y()},placeholder:"e.g. claude-opus-4-5",className:"flex-1 px-3 py-2 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary",autoFocus:!0}),(0,s.jsx)(p.$n,{variant:"secondary",icon:"science",loading:"testing"===d,onClick:y,disabled:!o.trim()||"testing"===d,children:"testing"===d?"Testing...":"Test"})]}),(0,s.jsxs)("p",{className:"text-xs text-text-muted mt-1",children:["Sent to provider as: ",(0,s.jsx)("code",{className:"font-mono bg-sidebar px-1 rounded",children:o.trim()||"model-id"})]})]}),"ok"===d&&(0,s.jsxs)("div",{className:"flex items-center gap-2 text-sm text-green-600",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-base",children:"check_circle"}),"Model is reachable"]}),"error"===d&&(0,s.jsxs)("div",{className:"flex items-start gap-2 text-sm text-red-500",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-base shrink-0",children:"cancel"}),(0,s.jsx)("span",{children:m||"Model not reachable"})]}),(0,s.jsxs)("div",{className:"flex gap-2 pt-1",children:[(0,s.jsx)(p.$n,{onClick:l,variant:"ghost",fullWidth:!0,size:"sm",children:"Cancel"}),(0,s.jsx)(p.$n,{onClick:f,fullWidth:!0,size:"sm",disabled:!o.trim()||u,children:u?"Adding...":"Add Model"})]})]})})}y.propTypes={model:l().shape({id:l().string.isRequired}).isRequired,fullModel:l().string.isRequired,alias:l().string,copied:l().string,onCopy:l().func.isRequired,testStatus:l().oneOf(["ok","error"]),isCustom:l().bool,onDeleteAlias:l().func,onTest:l().func,isTesting:l().bool},f.propTypes={providerAlias:l().string.isRequired,modelAliases:l().object.isRequired,copied:l().string,onCopy:l().func.isRequired,onSetAlias:l().func.isRequired,onDeleteAlias:l().func.isRequired},g.propTypes={modelId:l().string.isRequired,fullModel:l().string.isRequired,copied:l().string,onCopy:l().func.isRequired,onDeleteAlias:l().func.isRequired,onTest:l().func,testStatus:l().oneOf(["ok","error"]),isTesting:l().bool},v.propTypes={providerStorageAlias:l().string.isRequired,providerDisplayAlias:l().string.isRequired,modelAliases:l().object.isRequired,copied:l().string,onCopy:l().func.isRequired,onSetAlias:l().func.isRequired,onDeleteAlias:l().func.isRequired,connections:l().arrayOf(l().shape({id:l().string,isActive:l().bool})).isRequired,isAnthropic:l().bool},b.propTypes={until:l().string.isRequired},j.propTypes={connection:l().shape({id:l().string,name:l().string,email:l().string,displayName:l().string,modelLockUntil:l().string,testStatus:l().string,isActive:l().bool,lastError:l().string,priority:l().number,globalPriority:l().number}).isRequired,proxyPools:l().arrayOf(l().shape({id:l().string,name:l().string,proxyUrl:l().string,noProxy:l().string,isActive:l().bool})),isOAuth:l().bool.isRequired,isFirst:l().bool.isRequired,isLast:l().bool.isRequired,onMoveUp:l().func.isRequired,onMoveDown:l().func.isRequired,onToggleActive:l().func.isRequired,onUpdateProxy:l().func,onEdit:l().func.isRequired,onDelete:l().func.isRequired},N.propTypes={isOpen:l().bool.isRequired,provider:l().string,providerName:l().string,isCompatible:l().bool,isAnthropic:l().bool,proxyPools:l().arrayOf(l().shape({id:l().string,name:l().string})),onSave:l().func.isRequired,onClose:l().func.isRequired},k.propTypes={isOpen:l().bool.isRequired,connection:l().shape({id:l().string,name:l().string,email:l().string,priority:l().number,authType:l().string,provider:l().string,providerSpecificData:l().object}),proxyPools:l().arrayOf(l().shape({id:l().string,name:l().string})),onSave:l().func.isRequired,onClose:l().func.isRequired},C.propTypes={isOpen:l().bool.isRequired,node:l().shape({id:l().string,name:l().string,prefix:l().string,apiType:l().string,baseUrl:l().string}),onSave:l().func.isRequired,onClose:l().func.isRequired,isAnthropic:l().bool},w.propTypes={isOpen:l().bool.isRequired,providerAlias:l().string.isRequired,providerDisplayAlias:l().string.isRequired,onSave:l().func.isRequired,onClose:l().func.isRequired}}},e=>{e.O(0,[5370,4335,5772,619,2652,5497,8441,3794,7358],()=>e(e.s=52397)),_N_E=e.O()}]);
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[2134],{52397:(e,t,i)=>{Promise.resolve().then(i.bind(i,97162))},97162:(e,t,i)=>{"use strict";i.r(t),i.d(t,{default:()=>h});var s=i(95155),a=i(12115),r=i(14051),o=i.n(r),l=i(73321),n=i(98500),d=i.n(n),c=i(5772),p=i(35497),m=i(52679),x=i(28777),u=i(11059);function h(){let e=(0,l.useParams)(),t=(0,l.useRouter)(),i=e.id,[r,o]=(0,a.useState)([]),[n,h]=(0,a.useState)(!0),[g,b]=(0,a.useState)(null),[S,A]=(0,a.useState)([]),[$,P]=(0,a.useState)(!1),[T,O]=(0,a.useState)(!1),[E,R]=(0,a.useState)(!1),[_,I]=(0,a.useState)(!1),[D,q]=(0,a.useState)(!1),[U,K]=(0,a.useState)(!1),[M,L]=(0,a.useState)(null),[z,J]=(0,a.useState)({}),[F,W]=(0,a.useState)(!1),[V,B]=(0,a.useState)({}),[Z,G]=(0,a.useState)(""),[Q,H]=(0,a.useState)(null),[X,Y]=(0,a.useState)(!1),[ee,et]=(0,a.useState)([]),[ei,es]=(0,a.useState)("__none__"),[ea,er]=(0,a.useState)(!1),[eo,el]=(0,a.useState)(null),[en,ed]=(0,a.useState)(""),{copied:ec,copy:ep}=(0,u.C)(),em=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}:m.zN[i]||m.fg[i]||m.IS[i],ex=!!m.zN[i]||!!m.IS[i],eu=(0,x.KC)(i),eh=(0,m.wG)(i),ey=(0,m.mq)(i),ef=(0,m.gb)(i),eg=ey||ef,ev=eg?i:eh,eb=eg?g?.prefix||i:eh,ej=(0,a.useCallback)(async()=>{try{let e=await fetch("/api/models/alias"),t=await e.json();e.ok&&J(t.aliases||{})}catch(e){console.log("Error fetching aliases:",e)}},[]),eN=(0,a.useCallback)(async()=>{try{let[e,t,s,a]=await Promise.all([fetch("/api/providers",{cache:"no-store"}),fetch("/api/provider-nodes",{cache:"no-store"}),fetch("/api/proxy-pools?isActive=true",{cache:"no-store"}),fetch("/api/settings",{cache:"no-store"})]),r=await e.json(),l=await t.json(),n=await s.json(),d=a.ok?await a.json():{};if(e.ok){let e=(r.connections||[]).filter(e=>e.provider===i);o(e)}s.ok&&A(n.proxyPools||[]);let c=(d.providerStrategies||{})[i]||{};if(el(c.fallbackStrategy||null),ed(null!=c.stickyRoundRobinLimit?String(c.stickyRoundRobinLimit):"1"),t.ok){let e=(l.nodes||[]).find(e=>e.id===i)||null;if(!e&&eg)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}b(e)}}catch(e){console.log("Error fetching connections:",e)}finally{h(!1)}},[i,eg]),ek=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&&(b(s.node),await eN(),q(!1))}catch(e){console.log("Error updating provider node:",e)}},eC=async(e,t)=>{try{let s=await fetch("/api/settings",{cache:"no-store"}),a=(s.ok?await s.json():{}).providerStrategies||{},r={};e&&(r.fallbackStrategy=e),"round-robin"===e&&""!==t&&(r.stickyRoundRobinLimit=Number(t)||3);let o={...a};0===Object.keys(r).length?delete o[i]:o[i]=r,await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerStrategies:o})})}catch(e){console.log("Error saving provider strategy:",e)}};(0,a.useEffect)(()=>{eN(),ej()},[eN,ej]);let ew=async(e,t,i=eh)=>{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 ej();else{let t=await e.json();alert(t.error||"Failed to set alias")}}catch(e){console.log("Error setting alias:",e)}},eS=async e=>{try{(await fetch(`/api/models/alias?alias=${encodeURIComponent(e)}`,{method:"DELETE"})).ok&&await ej()}catch(e){console.log("Error deleting alias:",e)}},eA=async e=>{if(confirm("Delete this connection?"))try{(await fetch(`/api/providers/${e}`,{method:"DELETE"})).ok&&o(r.filter(t=>t.id!==e))}catch(e){console.log("Error deleting connection:",e)}},e$=()=>{eN(),P(!1)},eP=async e=>{try{(await fetch("/api/providers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:i,...e})})).ok&&(await eN(),R(!1))}catch(e){console.log("Error saving connection:",e)}},eT=async e=>{try{(await fetch(`/api/providers/${M.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})).ok&&(await eN(),I(!1))}catch(e){console.log("Error updating connection:",e)}},eO=async(e,t)=>{try{(await fetch(`/api/providers/${e}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({isActive:t})})).ok&&o(i=>i.map(i=>i.id===e?{...i,isActive:t}:i))}catch(e){console.log("Error updating connection status:",e)}},eE=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 eN()}catch(e){console.log("Error swapping priority:",e)}},eR=r.filter(e=>ee.includes(e.id));r.length>0&&(ee.length,r.length),(0,a.useEffect)(()=>{et(e=>e.filter(e=>r.some(t=>t.id===e)))},[r]);let e_=(()=>{if(0===eR.length)return"";let e=new Set(eR.map(e=>e.providerSpecificData?.proxyPoolId||"__none__"));if(1===e.size){let t=[...e][0];if("__none__"===t)return"All selected currently unbound";let i=S.find(e=>e.id===t);return`All selected currently bound to ${i?.name||t}`}return"Selected connections have mixed proxy bindings"})(),eI=()=>{ea||K(!1)},eD=async()=>{if(0===ee.length)return;let e="__none__"===ei?null:ei;er(!0);try{let t=[];for(let i of ee)try{let s=await fetch(`/api/providers/${i}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({proxyPoolId:e})});t.push(s.ok)}catch(e){console.log("Error applying bulk proxy pool for",i,e),t.push(!1)}let i=t.filter(e=>!e).length;i>0&&alert(`Updated with ${i} failed request(s).`),await eN(),et([]),es("__none__"),K(!1)}catch(e){console.log("Error applying bulk proxy pool:",e)}finally{er(!1)}},eq=(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)("div",{className:"flex items-stretch",children:(0,s.jsx)("div",{className:"flex-1 min-w-0",children:(0,s.jsx)(j,{connection:e,proxyPools:S,isOAuth:ex,isFirst:0===t,isLast:t===r.length-1,onMoveUp:()=>eE(e,r[t-1]),onMoveDown:()=>eE(e,r[t+1]),onToggleActive:t=>eO(e.id,t),onUpdateProxy:async t=>{try{(await fetch(`/api/providers/${e.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({proxyPoolId:t||null})})).ok&&o(i=>i.map(i=>i.id===e.id?{...i,providerSpecificData:{...i.providerSpecificData,proxyPoolId:t||null}}:i))}catch(e){console.log("Error updating proxy:",e)}},onEdit:()=>{L(e),I(!0)},onDelete:()=>eA(e.id)})})},e.id))}),eU=[{value:"__none__",label:"None"},...S.map(e=>({value:e.id,label:e.name}))],eK=0===ee.length?"Select one or more connections, then click Proxy Action.":e_,eM=ee.length>0&&!ea,eL=(0,s.jsx)(p.aF,{isOpen:U,onClose:eI,title:`Proxy Action (${ee.length} selected)`,children:(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,s.jsx)(p.l6,{label:"Proxy Pool",value:ei,onChange:e=>es(e.target.value),options:eU,placeholder:"None"}),(0,s.jsx)("p",{className:"text-xs text-text-muted",children:eK}),(0,s.jsx)("p",{className:"text-xs text-text-muted",children:"Selecting None will unbind selected connections from proxy pool."}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(p.$n,{onClick:eD,fullWidth:!0,disabled:!eM,children:ea?"Applying...":"Apply"}),(0,s.jsx)(p.$n,{onClick:eI,variant:"ghost",fullWidth:!0,disabled:ea,children:"Cancel"})]})]})}),ez=async e=>{if(!Q){H(e);try{let t=await fetch("/api/models/test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:`${ev}/${e}`})}),i=await t.json();B(t=>({...t,[e]:i.ok?"ok":"error"})),G(i.ok?"":i.error||"Model not reachable")}catch{B(t=>({...t,[e]:"error"})),G("Network error")}finally{H(null)}}};return n?(0,s.jsxs)("div",{className:"flex flex-col gap-8",children:[(0,s.jsx)(p.Qv,{}),(0,s.jsx)(p.Qv,{})]}):em?(0,s.jsxs)("div",{className:"flex flex-col gap-8",children:[(0,s.jsxs)("div",{children:[(0,s.jsxs)(d(),{href:"/dashboard/providers",className:"inline-flex items-center gap-1 text-sm text-text-muted hover:text-primary transition-colors mb-4",children:[(0,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:`${em.color}15`},children:F?(0,s.jsx)("span",{className:"text-sm font-bold",style:{color:em.color},children:em.textIcon||em.id.slice(0,2).toUpperCase()}):(0,s.jsx)(c.default,{src:ey&&em.apiType?"responses"===em.apiType?"/providers/oai-r.png":"/providers/oai-cc.png":ef?"/providers/anthropic-m.png":`/providers/${em.id}.png`,alt:em.name,width:48,height:48,className:"object-contain rounded-lg max-w-[48px] max-h-[48px]",sizes:"48px",onError:()=>W(!0)})}),(0,s.jsxs)("div",{children:[(0,s.jsx)("h1",{className:"text-3xl font-semibold tracking-tight",children:em.name}),(0,s.jsxs)("p",{className:"text-text-muted",children:[r.length," connection",1===r.length?"":"s"]})]})]})]}),eg&&g&&(0,s.jsxs)(p.Zp,{children:[(0,s.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("h2",{className:"text-lg font-semibold",children:ef?"Anthropic Compatible Details":"OpenAI Compatible Details"}),(0,s.jsxs)("p",{className:"text-sm text-text-muted",children:[ef?"Messages API":"responses"===g.apiType?"Responses API":"Chat Completions"," \xb7 ",(g.baseUrl||"").replace(/\/$/,""),"/",ef?"messages":"responses"===g.apiType?"responses":"chat/completions"]})]}),(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)(p.$n,{size:"sm",icon:"add",onClick:()=>R(!0),disabled:r.length>0,children:"Add"}),(0,s.jsx)(p.$n,{size:"sm",variant:"secondary",icon:"edit",onClick:()=>q(!0),children:"Edit"}),(0,s.jsx)(p.$n,{size:"sm",variant:"secondary",icon:"delete",onClick:async()=>{if(confirm(`Delete this ${ef?"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)(p.Zp,{children:[(0,s.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,s.jsx)("h2",{className:"text-lg font-semibold",children:"Connections"}),(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("span",{className:"text-xs text-text-muted font-medium",children:"Round Robin"}),(0,s.jsx)(p.lM,{checked:"round-robin"===eo,onChange:e=>{let t=e?"round-robin":null,i=e?en||"1":en;e&&!en&&ed("1"),el(t),eC(t,i)}}),"round-robin"===eo&&(0,s.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,s.jsx)("span",{className:"text-xs text-text-muted",children:"Sticky:"}),(0,s.jsx)("input",{type:"number",min:1,value:en,onChange:e=>{var t;ed(t=e.target.value),eC("round-robin",t)},placeholder:"1",className:"w-14 px-2 py-1 text-xs border border-border rounded-md bg-background focus:outline-none focus:border-primary"})]})]})]}),0===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:ex?"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"}),!eg&&(0,s.jsxs)("div",{className:"flex gap-2 justify-center",children:["iflow"===i&&(0,s.jsx)(p.$n,{icon:"cookie",variant:"secondary",onClick:()=>O(!0),children:"Cookie Auth"}),(0,s.jsx)(p.$n,{icon:"add",onClick:()=>ex?P(!0):R(!0),children:"iflow"===i?"OAuth":"Add Connection"})]})]}):(0,s.jsxs)(s.Fragment,{children:[eq,!eg&&(0,s.jsxs)("div",{className:"flex gap-2 mt-4",children:["iflow"===i&&(0,s.jsx)(p.$n,{size:"sm",icon:"cookie",variant:"secondary",onClick:()=>O(!0),title:"Add connection using browser cookie",children:"Cookie"}),(0,s.jsx)(p.$n,{size:"sm",icon:"add",onClick:()=>ex?P(!0):R(!0),children:"Add"})]})]})]}),(0,s.jsxs)(p.Zp,{children:[(0,s.jsx)("div",{className:"flex items-center justify-between mb-4",children:(0,s.jsx)("h2",{className:"text-lg font-semibold",children:em.passthroughModels?"Model Aliases":"Available Models"})}),!!Z&&(0,s.jsx)("p",{className:"text-xs text-red-500 mb-3 break-words",children:Z}),(()=>{if(eg)return(0,s.jsx)(v,{providerStorageAlias:ev,providerDisplayAlias:eb,modelAliases:z,copied:ec,onCopy:ep,onSetAlias:ew,onDeleteAlias:eS,connections:r,isAnthropic:ef});if(em.passthroughModels)return(0,s.jsx)(f,{providerAlias:eh,modelAliases:z,copied:ec,onCopy:ep,onSetAlias:ew,onDeleteAlias:eS});let e=Object.entries(z).filter(([e,t])=>{let i=`${ev}/`;if(!t.startsWith(i))return!1;let s=t.slice(i.length);return!eu.some(e=>e.id===s)&&e===s}).map(([e,t])=>({id:t.slice(`${ev}/`.length),alias:e,fullModel:t}));return(0,s.jsxs)("div",{className:"flex flex-wrap gap-3",children:[eu.map(e=>{let t=`${ev}/${e.id}`,a=`${i}/${e.id}`,o=Object.entries(z).find(([,e])=>e===t||e===a)?.[0];return(0,s.jsx)(y,{model:e,fullModel:`${eb}/${e.id}`,alias:o,copied:ec,onCopy:ep,onSetAlias:t=>ew(e.id,t,ev),onDeleteAlias:()=>eS(o),testStatus:V[e.id],onTest:r.length>0?()=>ez(e.id):void 0,isTesting:Q===e.id},e.id)}),e.map(e=>(0,s.jsx)(y,{model:{id:e.id},fullModel:`${eb}/${e.id}`,alias:e.alias,copied:ec,onCopy:ep,onSetAlias:()=>{},onDeleteAlias:()=>eS(e.alias),testStatus:V[e.id],onTest:r.length>0?()=>ez(e.id):void 0,isTesting:Q===e.id,isCustom:!0},e.id)),(0,s.jsxs)("button",{onClick:()=>Y(!0),className:"flex items-center gap-1.5 px-3 py-2 rounded-lg border border-dashed border-black/15 dark:border-white/15 text-xs text-text-muted hover:text-primary hover:border-primary/40 transition-colors",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-sm",children:"add"}),"Add Model"]})]})})()]}),eL,"kiro"===i?(0,s.jsx)(p.Mh,{isOpen:$,providerInfo:em,onSuccess:e$,onClose:()=>P(!1)}):"cursor"===i?(0,s.jsx)(p.G9,{isOpen:$,onSuccess:e$,onClose:()=>P(!1)}):(0,s.jsx)(p.LF,{isOpen:$,provider:i,providerInfo:em,onSuccess:e$,onClose:()=>P(!1)}),"iflow"===i&&(0,s.jsx)(p.vE,{isOpen:T,onSuccess:()=>{eN(),O(!1)},onClose:()=>O(!1)}),(0,s.jsx)(N,{isOpen:E,provider:i,providerName:em.name,isCompatible:eg,isAnthropic:ef,proxyPools:S,onSave:eP,onClose:()=>R(!1)}),(0,s.jsx)(k,{isOpen:_,connection:M,proxyPools:S,onSave:eT,onClose:()=>I(!1)}),eg&&(0,s.jsx)(C,{isOpen:D,node:g,onSave:ek,onClose:()=>q(!1),isAnthropic:ef}),!eg&&!em?.passthroughModels&&(0,s.jsx)(w,{isOpen:X,providerAlias:ev,providerDisplayAlias:eb,onSave:async e=>{await ew(e,e,ev),Y(!1)},onClose:()=>Y(!1)})]}):(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)(d(),{href:"/dashboard/providers",className:"text-primary mt-4 inline-block",children:"Back to Providers"})]})}function y({model:e,fullModel:t,alias:i,copied:a,onCopy:r,testStatus:o,isCustom:l,onDeleteAlias:n,onTest:d,isTesting:c}){let p="ok"===o?"#22c55e":"error"===o?"#ef4444":void 0;return(0,s.jsx)("div",{className:`group px-3 py-2 rounded-lg border ${"ok"===o?"border-green-500/40":"error"===o?"border-red-500/40":"border-border"} hover:bg-sidebar/50`,children:(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-base",style:p?{color:p}:void 0,children:"ok"===o?"check_circle":"error"===o?"cancel":"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}),d&&(0,s.jsx)("button",{onClick:d,disabled:c,className:`p-0.5 hover:bg-sidebar rounded text-text-muted hover:text-primary transition-opacity ${c?"opacity-100":"opacity-0 group-hover:opacity-100"}`,title:"Test model",children:(0,s.jsx)("span",{className:"material-symbols-outlined text-sm",style:c?{animation:"spin 1s linear infinite"}:void 0,children:c?"progress_activity":"science"})}),(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"})}),l&&(0,s.jsx)("button",{onClick:n,className:"p-0.5 hover:bg-red-500/10 rounded text-text-muted hover:text-red-500 opacity-0 group-hover:opacity-100 transition-opacity ml-auto",title:"Remove custom model",children:(0,s.jsx)("span",{className:"material-symbols-outlined text-sm",children:"close"})})]})})}function f({providerAlias:e,modelAliases:t,copied:i,onCopy:r,onSetAlias:o,onDeleteAlias:l}){let[n,d]=(0,a.useState)(""),[c,m]=(0,a.useState)(!1),x=Object.entries(t).filter(([,t])=>t.startsWith(`${e}/`)).map(([t,i])=>({modelId:i.replace(`${e}/`,""),fullModel:i,alias:t})),u=async()=>{let e;if(!n.trim()||c)return;let i=n.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 o(i,s),d("")}catch(e){console.log("Error adding model:",e)}finally{m(!1)}};return(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,s.jsx)("p",{className:"text-sm text-text-muted",children:"OpenRouter supports any model. Add models and create aliases for quick access."}),(0,s.jsxs)("div",{className:"flex items-end gap-2",children:[(0,s.jsxs)("div",{className:"flex-1",children:[(0,s.jsx)("label",{htmlFor:"new-model-input",className:"text-xs text-text-muted mb-1 block",children:"Model ID (from OpenRouter)"}),(0,s.jsx)("input",{id:"new-model-input",type:"text",value:n,onChange:e=>d(e.target.value),onKeyDown:e=>"Enter"===e.key&&u(),placeholder:"anthropic/claude-3-opus",className:"w-full px-3 py-2 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary"})]}),(0,s.jsx)(p.$n,{size:"sm",icon:"add",onClick:u,disabled:!n.trim()||c,children:c?"Adding...":"Add"})]}),x.length>0&&(0,s.jsx)("div",{className:"flex flex-col gap-3",children:x.map(({modelId:e,fullModel:t,alias:a})=>(0,s.jsx)(g,{modelId:e,fullModel:t,copied:i,onCopy:r,onDeleteAlias:()=>l(a)},t))})]})}function g({modelId:e,fullModel:t,copied:i,onCopy:a,onDeleteAlias:r,onTest:o,testStatus:l,isTesting:n}){let d="ok"===l?"#22c55e":"error"===l?"#ef4444":void 0;return(0,s.jsxs)("div",{className:`flex items-center gap-3 p-3 rounded-lg border ${"ok"===l?"border-green-500/40":"error"===l?"border-red-500/40":"border-border"} hover:bg-sidebar/50`,children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-base text-text-muted",style:d?{color:d}:void 0,children:"ok"===l?"check_circle":"error"===l?"cancel":"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"})}),o&&(0,s.jsx)("button",{onClick:o,disabled:n,className:"p-0.5 hover:bg-sidebar rounded text-text-muted hover:text-primary transition-colors",title:"Test model",children:(0,s.jsx)("span",{className:"material-symbols-outlined text-sm",style:n?{animation:"spin 1s linear infinite"}:void 0,children:n?"progress_activity":"science"})})]})]}),(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 v({providerStorageAlias:e,providerDisplayAlias:t,modelAliases:i,copied:r,onCopy:o,onSetAlias:l,onDeleteAlias:n,connections:d,isAnthropic:c}){let[m,x]=(0,a.useState)(""),[u,h]=(0,a.useState)(!1),[y,f]=(0,a.useState)(!1),[v,b]=(0,a.useState)(null),[j,N]=(0,a.useState)({}),k=async t=>{if(!v){b(t);try{let i=await fetch("/api/models/test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:`${e}/${t}`})}),s=await i.json();N(e=>({...e,[t]:s.ok?"ok":"error"}))}catch{N(e=>({...e,[t]:"error"}))}finally{b(null)}}},C=Object.entries(i).filter(([,t])=>t.startsWith(`${e}/`)).map(([t,i])=>({modelId:i.replace(`${e}/`,""),fullModel:i,alias:t})),w=e=>{let s,a=(s=e.split("/"))[s.length-1];if(!i[a])return a;let r=`${t}-${a}`;return i[r]?null:r},S=async()=>{if(!m.trim()||u)return;let t=m.trim(),i=w(t);if(!i)return void alert("All suggested aliases already exist. Please choose a different model or remove conflicting aliases.");h(!0);try{await l(t,i,e),x("")}catch(e){console.log("Error adding model:",e)}finally{h(!1)}},A=async()=>{if(y)return;let t=d.find(e=>!1!==e.isActive);if(t){f(!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=w(i);s&&(await l(i,s,e),r+=1)}0===r&&alert("No new models were added.")}catch(e){console.log("Error importing models:",e)}finally{f(!1)}}},$=d.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 ",c?"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=>x(e.target.value),onKeyDown:e=>"Enter"===e.key&&S(),placeholder:c?"claude-3-opus-20240229":"gpt-4o",className:"w-full px-3 py-2 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary"})]}),(0,s.jsx)(p.$n,{size:"sm",icon:"add",onClick:S,disabled:!m.trim()||u,children:u?"Adding...":"Add"}),(0,s.jsx)(p.$n,{size:"sm",variant:"secondary",icon:"download",onClick:A,disabled:!$||y,children:y?"Importing...":"Import from /models"})]}),!$&&(0,s.jsx)("p",{className:"text-xs text-text-muted",children:"Add a connection to enable importing models."}),C.length>0&&(0,s.jsx)("div",{className:"flex flex-col gap-3",children:C.map(({modelId:e,fullModel:i,alias:a})=>(0,s.jsx)(g,{modelId:e,fullModel:`${t}/${e}`,copied:r,onCopy:o,onDeleteAlias:()=>n(a),onTest:d.length>0?()=>k(e):void 0,testStatus:j[e],isTesting:v===e},i))})]})}function b({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}function j({connection:e,proxyPools:t,isOAuth:i,isFirst:r,isLast:o,onMoveUp:l,onMoveDown:n,onToggleActive:d,onUpdateProxy:c,onEdit:m,onDelete:x}){let[u,h]=(0,a.useState)(!1),[y,f]=(0,a.useState)(!1),g=(0,a.useRef)(null),v=new Map((t||[]).map(e=>[e.id,e])),j=e.providerSpecificData?.proxyPoolId||null,N=j?v.get(j):null,k=e.providerSpecificData?.connectionProxyEnabled===!0&&!!e.providerSpecificData?.connectionProxyUrl,C=!!j||k,w=N?`Pool: ${N.name}`:j?`Pool: ${j} (inactive/missing)`:k?`Legacy: ${e.providerSpecificData?.connectionProxyUrl}`:"",S="";if(N?.proxyUrl||e.providerSpecificData?.connectionProxyUrl){let t=N?.proxyUrl||e.providerSpecificData?.connectionProxyUrl;try{let e=new URL(t);S=`${e.protocol}//${e.hostname}${e.port?`:${e.port}`:""}`}catch{S=t}}let A=N?.noProxy||e.providerSpecificData?.connectionNoProxy||"",$="default";N?.isActive===!0?$="success":(j||k)&&($="error"),(0,a.useEffect)(()=>{if(!u)return;let e=e=>{g.current&&!g.current.contains(e.target)&&h(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[u]);let P=async e=>{f(!0);try{await c("__none__"===e?null:e)}finally{f(!1),h(!1)}},T=i?e.name||e.email||e.displayName||"OAuth Account":e.name,[O,E]=(0,a.useState)(!1),R=Object.entries(e).filter(([e])=>e.startsWith("modelLock_")).map(([,e])=>e).filter(e=>!!e).sort()[0]||null;(0,a.useEffect)(()=>{let t=()=>{E(!!Object.entries(e).filter(([e])=>e.startsWith("modelLock_")).map(([,e])=>e).filter(e=>e&&new Date(e).getTime()>Date.now()).sort()[0])};t();let i=R?setInterval(t,1e3):null;return()=>{i&&clearInterval(i)}},[R]);let _="unavailable"!==e.testStatus||O?e.testStatus:"active";return(0,s.jsxs)("div",{className:`group flex items-center justify-between p-3 rounded-lg hover:bg-black/[0.02] dark:hover:bg-white/[0.02] transition-colors ${!1===e.isActive?"opacity-60":""}`,children:[(0,s.jsxs)("div",{className:"flex items-center gap-3 flex-1 min-w-0",children:[(0,s.jsxs)("div",{className:"flex flex-col",children:[(0,s.jsx)("button",{onClick:l,disabled:r,className:`p-0.5 rounded ${r?"text-text-muted/30 cursor-not-allowed":"hover:bg-sidebar text-text-muted hover:text-primary"}`,children:(0,s.jsx)("span",{className:"material-symbols-outlined text-sm",children:"keyboard_arrow_up"})}),(0,s.jsx)("button",{onClick:n,disabled:o,className:`p-0.5 rounded ${o?"text-text-muted/30 cursor-not-allowed":"hover:bg-sidebar text-text-muted hover:text-primary"}`,children:(0,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:i?"lock":"key"}),(0,s.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,s.jsx)("p",{className:"text-sm font-medium truncate",children:T}),(0,s.jsxs)("div",{className:"flex items-center gap-2 mt-1",children:[(0,s.jsx)(p.Ex,{variant:!1===e.isActive?"default":"active"===_||"success"===_?"success":"error"===_||"expired"===_||"unavailable"===_?"error":"default",size:"sm",dot:!0,children:!1===e.isActive?"disabled":_||"Unknown"}),C&&(0,s.jsx)(p.Ex,{variant:$,size:"sm",children:"Proxy"}),O&&!1!==e.isActive&&(0,s.jsx)(b,{until:R}),e.lastError&&!1!==e.isActive&&(0,s.jsx)("span",{className:"text-xs text-red-500 truncate max-w-[300px]",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]})]}),C&&(0,s.jsxs)("div",{className:"mt-1 flex items-center gap-2 flex-wrap",children:[(0,s.jsx)("span",{className:"text-[11px] text-text-muted truncate max-w-[420px]",title:w,children:w}),S&&(0,s.jsx)("code",{className:"text-[10px] font-mono bg-black/5 dark:bg-white/5 px-1 py-0.5 rounded text-text-muted",children:S}),A&&(0,s.jsxs)("span",{className:"text-[11px] text-text-muted truncate max-w-[320px]",title:A,children:["no_proxy: ",A]})]})]})]}),(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsxs)("div",{className:"flex gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[(t||[]).length>0&&(0,s.jsxs)("div",{className:"relative",ref:g,children:[(0,s.jsxs)("button",{onClick:()=>h(e=>!e),className:`flex flex-col items-center px-2 py-1 rounded hover:bg-black/5 dark:hover:bg-white/5 transition-colors ${C?"text-primary":"text-text-muted hover:text-primary"}`,disabled:y,children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:y?"progress_activity":"lan"}),(0,s.jsx)("span",{className:"text-[10px] leading-tight",children:"Proxy"})]}),u&&(0,s.jsxs)("div",{className:"absolute right-0 top-full mt-1 z-50 bg-bg border border-border rounded-lg shadow-lg py-1 min-w-[160px]",children:[(0,s.jsx)("button",{onClick:()=>P("__none__"),className:`w-full text-left px-3 py-1.5 text-sm hover:bg-black/5 dark:hover:bg-white/5 ${!j?"text-primary font-medium":"text-text-main"}`,children:"None"}),(t||[]).map(e=>(0,s.jsx)("button",{onClick:()=>P(e.id),className:`w-full text-left px-3 py-1.5 text-sm hover:bg-black/5 dark:hover:bg-white/5 ${j===e.id?"text-primary font-medium":"text-text-main"}`,children:e.name},e.id))]})]}),(0,s.jsxs)("button",{onClick:m,className:"flex flex-col items-center px-2 py-1 rounded hover:bg-black/5 dark:hover:bg-white/5 text-text-muted hover:text-primary",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"edit"}),(0,s.jsx)("span",{className:"text-[10px] leading-tight",children:"Edit"})]}),(0,s.jsxs)("button",{onClick:x,className:"flex flex-col items-center px-2 py-1 rounded hover:bg-red-500/10 text-red-500",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"delete"}),(0,s.jsx)("span",{className:"text-[10px] leading-tight",children:"Delete"})]})]}),(0,s.jsx)(p.lM,{size:"sm",checked:e.isActive??!0,onChange:d,title:e.isActive??!0?"Disable connection":"Enable connection"})]})]})}function N({isOpen:e,provider:t,providerName:i,isCompatible:r,isAnthropic:o,proxyPools:l,onSave:n,onClose:d}){let c="__none__",[m,x]=(0,a.useState)({name:"",apiKey:"",priority:1,proxyPoolId:c}),[u,h]=(0,a.useState)(!1),[y,f]=(0,a.useState)(null),[g,v]=(0,a.useState)(!1),b=async()=>{h(!0);try{let e=await fetch("/api/providers/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:t,apiKey:m.apiKey})}),i=await e.json();f(i.valid?"success":"failed")}catch{f("failed")}finally{h(!1)}},j=async()=>{if(t&&m.apiKey){v(!0);try{let e=!1;try{h(!0),f(null);let i=await fetch("/api/providers/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:t,apiKey:m.apiKey})});e=!!(await i.json()).valid,f(e?"success":"failed")}catch{f("failed")}finally{h(!1)}await n({name:m.name,apiKey:m.apiKey,priority:m.priority,proxyPoolId:m.proxyPoolId===c?null:m.proxyPoolId,testStatus:e?"active":"unknown",providerSpecificData:void 0})}finally{v(!1)}}};return t?(0,s.jsx)(p.aF,{isOpen:e,title:`Add ${i||t} API Key`,onClose:d,children:(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,s.jsx)(p.pd,{label:"Name",value:m.name,onChange:e=>x({...m,name:e.target.value}),placeholder:"Production Key"}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(p.pd,{label:"API Key",type:"password",value:m.apiKey,onChange:e=>x({...m,apiKey:e.target.value}),className:"flex-1"}),(0,s.jsx)("div",{className:"pt-6",children:(0,s.jsx)(p.$n,{onClick:b,disabled:!m.apiKey||u||g,variant:"secondary",children:u?"Checking...":"Check"})})]}),y&&(0,s.jsx)(p.Ex,{variant:"success"===y?"success":"error",children:"success"===y?"Valid":"Invalid"}),r&&(0,s.jsx)("p",{className:"text-xs text-text-muted",children:o?`Validation checks ${i||"Anthropic Compatible"} by verifying the API key.`:`Validation checks ${i||"OpenAI Compatible"} via /models on your base URL.`}),(0,s.jsx)(p.pd,{label:"Priority",type:"number",value:m.priority,onChange:e=>x({...m,priority:Number.parseInt(e.target.value)||1})}),(0,s.jsx)(p.l6,{label:"Proxy Pool",value:m.proxyPoolId,onChange:e=>x({...m,proxyPoolId:e.target.value}),options:[{value:c,label:"None"},...(l||[]).map(e=>({value:e.id,label:e.name}))],placeholder:"None"}),0===(l||[]).length&&(0,s.jsx)("p",{className:"text-xs text-text-muted",children:"No active proxy pools available. Create one in Proxy Pools page first."}),(0,s.jsx)("p",{className:"text-xs text-text-muted",children:"Legacy manual proxy fields are still accepted by API for backward compatibility."}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(p.$n,{onClick:j,fullWidth:!0,disabled:!m.name||!m.apiKey||g,children:g?"Saving...":"Save"}),(0,s.jsx)(p.$n,{onClick:d,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})}):null}function k({isOpen:e,connection:t,proxyPools:i,onSave:r,onClose:o}){let[l,n]=(0,a.useState)({name:"",priority:1,apiKey:""}),[d,c]=(0,a.useState)(!1),[x,u]=(0,a.useState)(null),[h,y]=(0,a.useState)(!1),[f,g]=(0,a.useState)(null),[v,b]=(0,a.useState)(!1);(0,a.useEffect)(()=>{t&&(n({name:t.name||"",priority:t.priority||1,apiKey:""}),u(null),g(null))},[t]);let j=async()=>{if(t?.provider){c(!0),u(null);try{let e=await fetch(`/api/providers/${t.id}/test`,{method:"POST"}),i=await e.json();u(i.valid?"success":"failed")}catch{u("failed")}finally{c(!1)}}},N=async()=>{if(t?.provider&&l.apiKey){y(!0),g(null);try{let e=await fetch("/api/providers/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:t.provider,apiKey:l.apiKey})}),i=await e.json();g(i.valid?"success":"failed")}catch{g("failed")}finally{y(!1)}}},k=async()=>{b(!0);try{let e={name:l.name,priority:l.priority};if(!C&&l.apiKey){e.apiKey=l.apiKey;let i="success"===f;if(!i)try{y(!0),g(null);let e=await fetch("/api/providers/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:t.provider,apiKey:l.apiKey})});i=!!(await e.json()).valid,g(i?"success":"failed")}catch{g("failed")}finally{y(!1)}i&&(e.testStatus="active",e.lastError=null,e.lastErrorAt=null)}await r(e)}finally{b(!1)}};if(!t)return null;let C="oauth"===t.authType,w=(0,m.mq)(t.provider)||(0,m.gb)(t.provider);return(0,s.jsx)(p.aF,{isOpen:e,title:"Edit Connection",onClose:o,children:(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,s.jsx)(p.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})]}),(0,s.jsx)(p.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)(p.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)(p.$n,{onClick:N,disabled:!l.apiKey||h||v,variant:"secondary",children:h?"Checking...":"Check"})})]}),f&&(0,s.jsx)(p.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)(p.$n,{onClick:j,variant:"secondary",disabled:d,children:d?"Testing...":"Test Connection"}),x&&(0,s.jsx)(p.Ex,{variant:"success"===x?"success":"error",children:"success"===x?"Valid":"Failed"})]}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(p.$n,{onClick:k,fullWidth:!0,disabled:v,children:v?"Saving...":"Save"}),(0,s.jsx)(p.$n,{onClick:o,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})})}function C({isOpen:e,node:t,onSave:i,onClose:r,isAnthropic:o}){let[l,n]=(0,a.useState)({name:"",prefix:"",apiType:"chat",baseUrl:"https://api.openai.com/v1"}),[d,c]=(0,a.useState)(!1),[m,x]=(0,a.useState)(""),[u,h]=(0,a.useState)(!1),[y,f]=(0,a.useState)(null);(0,a.useEffect)(()=>{t&&n({name:t.name||"",prefix:t.prefix||"",apiType:t.apiType||"chat",baseUrl:t.baseUrl||(o?"https://api.anthropic.com/v1":"https://api.openai.com/v1")})},[t,o]);let g=async()=>{if(l.name.trim()&&l.prefix.trim()&&l.baseUrl.trim()){c(!0);try{let e={name:l.name,prefix:l.prefix,baseUrl:l.baseUrl};o||(e.apiType=l.apiType),await i(e)}finally{c(!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:l.baseUrl,apiKey:m,type:o?"anthropic-compatible":"openai-compatible"})}),t=await e.json();f(t.valid?"success":"failed")}catch{f("failed")}finally{h(!1)}};return t?(0,s.jsx)(p.aF,{isOpen:e,title:`Edit ${o?"Anthropic":"OpenAI"} Compatible`,onClose:r,children:(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,s.jsx)(p.pd,{label:"Name",value:l.name,onChange:e=>n({...l,name:e.target.value}),placeholder:`${o?"Anthropic":"OpenAI"} Compatible (Prod)`,hint:"Required. A friendly label for this node."}),(0,s.jsx)(p.pd,{label:"Prefix",value:l.prefix,onChange:e=>n({...l,prefix:e.target.value}),placeholder:o?"ac-prod":"oc-prod",hint:"Required. Used as the provider prefix for model IDs."}),!o&&(0,s.jsx)(p.l6,{label:"API Type",options:[{value:"chat",label:"Chat Completions"},{value:"responses",label:"Responses API"}],value:l.apiType,onChange:e=>n({...l,apiType:e.target.value})}),(0,s.jsx)(p.pd,{label:"Base URL",value:l.baseUrl,onChange:e=>n({...l,baseUrl:e.target.value}),placeholder:o?"https://api.anthropic.com/v1":"https://api.openai.com/v1",hint:`Use the base URL (ending in /v1) for your ${o?"Anthropic":"OpenAI"}-compatible API.`}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(p.pd,{label:"API Key (for Check)",type:"password",value:m,onChange:e=>x(e.target.value),className:"flex-1"}),(0,s.jsx)("div",{className:"pt-6",children:(0,s.jsx)(p.$n,{onClick:v,disabled:!m||u||!l.baseUrl.trim(),variant:"secondary",children:u?"Checking...":"Check"})})]}),y&&(0,s.jsx)(p.Ex,{variant:"success"===y?"success":"error",children:"success"===y?"Valid":"Invalid"}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(p.$n,{onClick:g,fullWidth:!0,disabled:!l.name.trim()||!l.prefix.trim()||!l.baseUrl.trim()||d,children:d?"Saving...":"Save"}),(0,s.jsx)(p.$n,{onClick:r,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})}):null}function w({isOpen:e,providerAlias:t,providerDisplayAlias:i,onSave:r,onClose:o}){let[l,n]=(0,a.useState)(""),[d,c]=(0,a.useState)(null),[m,x]=(0,a.useState)(""),[u,h]=(0,a.useState)(!1);(0,a.useEffect)(()=>{e&&(n(""),c(null),x(""))},[e]);let y=async()=>{if(l.trim()){c("testing"),x("");try{let e=await fetch("/api/models/test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:`${t}/${l.trim()}`})}),i=await e.json();c(i.ok?"ok":"error"),x(i.error||"")}catch(e){c("error"),x(e.message)}}},f=async()=>{if(l.trim()&&!u){h(!0);try{await r(l.trim())}finally{h(!1)}}};return(0,s.jsx)(p.aF,{isOpen:e,onClose:o,title:"Add Custom Model",children:(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"text-sm font-medium mb-1.5 block",children:"Model ID"}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)("input",{type:"text",value:l,onChange:e=>{n(e.target.value),c(null),x("")},onKeyDown:e=>{"Enter"===e.key&&y()},placeholder:"e.g. claude-opus-4-5",className:"flex-1 px-3 py-2 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary",autoFocus:!0}),(0,s.jsx)(p.$n,{variant:"secondary",icon:"science",loading:"testing"===d,onClick:y,disabled:!l.trim()||"testing"===d,children:"testing"===d?"Testing...":"Test"})]}),(0,s.jsxs)("p",{className:"text-xs text-text-muted mt-1",children:["Sent to provider as: ",(0,s.jsx)("code",{className:"font-mono bg-sidebar px-1 rounded",children:l.trim()||"model-id"})]})]}),"ok"===d&&(0,s.jsxs)("div",{className:"flex items-center gap-2 text-sm text-green-600",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-base",children:"check_circle"}),"Model is reachable"]}),"error"===d&&(0,s.jsxs)("div",{className:"flex items-start gap-2 text-sm text-red-500",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-base shrink-0",children:"cancel"}),(0,s.jsx)("span",{children:m||"Model not reachable"})]}),(0,s.jsxs)("div",{className:"flex gap-2 pt-1",children:[(0,s.jsx)(p.$n,{onClick:o,variant:"ghost",fullWidth:!0,size:"sm",children:"Cancel"}),(0,s.jsx)(p.$n,{onClick:f,fullWidth:!0,size:"sm",disabled:!l.trim()||u,children:u?"Adding...":"Add Model"})]})]})})}y.propTypes={model:o().shape({id:o().string.isRequired}).isRequired,fullModel:o().string.isRequired,alias:o().string,copied:o().string,onCopy:o().func.isRequired,testStatus:o().oneOf(["ok","error"]),isCustom:o().bool,onDeleteAlias:o().func,onTest:o().func,isTesting:o().bool},f.propTypes={providerAlias:o().string.isRequired,modelAliases:o().object.isRequired,copied:o().string,onCopy:o().func.isRequired,onSetAlias:o().func.isRequired,onDeleteAlias:o().func.isRequired},g.propTypes={modelId:o().string.isRequired,fullModel:o().string.isRequired,copied:o().string,onCopy:o().func.isRequired,onDeleteAlias:o().func.isRequired,onTest:o().func,testStatus:o().oneOf(["ok","error"]),isTesting:o().bool},v.propTypes={providerStorageAlias:o().string.isRequired,providerDisplayAlias:o().string.isRequired,modelAliases:o().object.isRequired,copied:o().string,onCopy:o().func.isRequired,onSetAlias:o().func.isRequired,onDeleteAlias:o().func.isRequired,connections:o().arrayOf(o().shape({id:o().string,isActive:o().bool})).isRequired,isAnthropic:o().bool},b.propTypes={until:o().string.isRequired},j.propTypes={connection:o().shape({id:o().string,name:o().string,email:o().string,displayName:o().string,modelLockUntil:o().string,testStatus:o().string,isActive:o().bool,lastError:o().string,priority:o().number,globalPriority:o().number}).isRequired,proxyPools:o().arrayOf(o().shape({id:o().string,name:o().string,proxyUrl:o().string,noProxy:o().string,isActive:o().bool})),isOAuth:o().bool.isRequired,isFirst:o().bool.isRequired,isLast:o().bool.isRequired,onMoveUp:o().func.isRequired,onMoveDown:o().func.isRequired,onToggleActive:o().func.isRequired,onUpdateProxy:o().func,onEdit:o().func.isRequired,onDelete:o().func.isRequired},N.propTypes={isOpen:o().bool.isRequired,provider:o().string,providerName:o().string,isCompatible:o().bool,isAnthropic:o().bool,proxyPools:o().arrayOf(o().shape({id:o().string,name:o().string})),onSave:o().func.isRequired,onClose:o().func.isRequired},k.propTypes={isOpen:o().bool.isRequired,connection:o().shape({id:o().string,name:o().string,email:o().string,priority:o().number,authType:o().string,provider:o().string,providerSpecificData:o().object}),proxyPools:o().arrayOf(o().shape({id:o().string,name:o().string})),onSave:o().func.isRequired,onClose:o().func.isRequired},C.propTypes={isOpen:o().bool.isRequired,node:o().shape({id:o().string,name:o().string,prefix:o().string,apiType:o().string,baseUrl:o().string}),onSave:o().func.isRequired,onClose:o().func.isRequired,isAnthropic:o().bool},w.propTypes={isOpen:o().bool.isRequired,providerAlias:o().string.isRequired,providerDisplayAlias:o().string.isRequired,onSave:o().func.isRequired,onClose:o().func.isRequired}}},e=>{e.O(0,[5370,4335,5772,619,2652,5497,8441,3794,7358],()=>e(e.s=52397)),_N_E=e.O()}]);
@@ -1 +1 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[7177],{1934:(e,t,r)=>{"use strict";r.d(t,{v:()=>i});var n=r(12115);let a=e=>{let t,r=new Set,n=(e,n)=>{let a="function"==typeof e?e(t):e;if(!Object.is(a,t)){let e=t;t=(null!=n?n:"object"!=typeof a||null===a)?a:Object.assign({},t,a),r.forEach(r=>r(t,e))}},a=()=>t,o={setState:n,getState:a,getInitialState:()=>i,subscribe:e=>(r.add(e),()=>r.delete(e))},i=t=e(n,a,o);return o},o=e=>{let t=e?a(e):a,r=e=>(function(e,t=e=>e){let r=n.useSyncExternalStore(e.subscribe,n.useCallback(()=>t(e.getState()),[e,t]),n.useCallback(()=>t(e.getInitialState()),[e,t]));return n.useDebugValue(r),r})(t,e);return Object.assign(r,t),r},i=e=>e?o(e):o},21110:(e,t,r)=>{"use strict";r.d(t,{ThemeProvider:()=>i});var n=r(95155),a=r(12115),o=r(90085);function i({children:e}){let{initTheme:t}=(0,o.A)();return(0,a.useEffect)(()=>{t()},[t]),(0,n.jsx)(n.Fragment,{children:e})}},28777:(e,t,r)=>{"use strict";r.d(t,{KC:()=>n.KC,Xg:()=>n.Xg});var n=r(45564);Object.entries(r(52679).Q2).filter(([,e])=>e.passthroughModels).map(([e])=>e),Object.entries(n.vq).flatMap(([e,t])=>t.map(t=>({provider:e,model:t.id,name:t.name})))},31692:(e,t,r)=>{"use strict";r.d(t,{Zr:()=>a});let n=e=>t=>{try{let r=e(t);if(r instanceof Promise)return r;return{then:e=>n(e)(r),catch(e){return this}}}catch(e){return{then(e){return this},catch:t=>n(t)(e)}}},a=(e,t)=>(r,a,o)=>{let i,s={storage:function(e,t){let r;try{r=e()}catch(e){return}return{getItem:e=>{var t;let n=e=>null===e?null:JSON.parse(e,void 0),a=null!=(t=r.getItem(e))?t:null;return a instanceof Promise?a.then(n):n(a)},setItem:(e,t)=>r.setItem(e,JSON.stringify(t,void 0)),removeItem:e=>r.removeItem(e)}}(()=>window.localStorage),partialize:e=>e,version:0,merge:(e,t)=>({...t,...e}),...t},u=!1,l=0,c=new Set,d=new Set,m=s.storage;if(!m)return e((...e)=>{console.warn(`[zustand persist middleware] Unable to update item '${s.name}', the given storage is currently unavailable.`),r(...e)},a,o);let f=()=>{let e=s.partialize({...a()});return m.setItem(s.name,{state:e,version:s.version})},h=o.setState;o.setState=(e,t)=>(h(e,t),f());let p=e((...e)=>(r(...e),f()),a,o);o.getInitialState=()=>p;let v=()=>{var e,t;if(!m)return;let o=++l;u=!1,c.forEach(e=>{var t;return e(null!=(t=a())?t:p)});let h=(null==(t=s.onRehydrateStorage)?void 0:t.call(s,null!=(e=a())?e:p))||void 0;return n(m.getItem.bind(m))(s.name).then(e=>{if(e)if("number"!=typeof e.version||e.version===s.version)return[!1,e.state];else{if(s.migrate){let t=s.migrate(e.state,e.version);return t instanceof Promise?t.then(e=>[!0,e]):[!0,t]}console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}return[!1,void 0]}).then(e=>{var t;if(o!==l)return;let[n,u]=e;if(r(i=s.merge(u,null!=(t=a())?t:p),!0),n)return f()}).then(()=>{o===l&&(null==h||h(i,void 0),i=a(),u=!0,d.forEach(e=>e(i)))}).catch(e=>{o===l&&(null==h||h(void 0,e))})};return o.persist={setOptions:e=>{s={...s,...e},e.storage&&(m=e.storage)},clearStorage:()=>{null==m||m.removeItem(s.name)},getOptions:()=>s,rehydrate:()=>v(),hasHydrated:()=>u,onHydrate:e=>(c.add(e),()=>{c.delete(e)}),onFinishHydration:e=>(d.add(e),()=>{d.delete(e)})},s.skipHydration||v(),i||p}},35154:e=>{e.exports={style:{fontFamily:"'Inter', 'Inter Fallback'",fontStyle:"normal"},className:"__className_f367f3",variable:"__variable_f367f3"}},51743:()=>{},54642:e=>{var t;"u">typeof __nccwpck_require__&&(__nccwpck_require__.ab="//"),(t={}).endianness=function(){return"LE"},t.hostname=function(){return"u">typeof location?location.hostname:""},t.loadavg=function(){return[]},t.uptime=function(){return 0},t.freemem=function(){return Number.MAX_VALUE},t.totalmem=function(){return Number.MAX_VALUE},t.cpus=function(){return[]},t.type=function(){return"Browser"},t.release=function(){return"u">typeof navigator?navigator.appVersion:""},t.networkInterfaces=t.getNetworkInterfaces=function(){return{}},t.arch=function(){return"javascript"},t.platform=function(){return"browser"},t.tmpdir=t.tmpDir=function(){return"/tmp"},t.EOL="\n",t.homedir=function(){return"/"},e.exports=t},64206:(e,t,r)=>{Promise.resolve().then(r.t.bind(r,35154,23)),Promise.resolve().then(r.t.bind(r,51743,23)),Promise.resolve().then(r.bind(r,94635)),Promise.resolve().then(r.bind(r,21110))},73006:(e,t,r)=>{"use strict";r.d(t,{FE:()=>m,Tl:()=>l,wn:()=>f});var n=r(93308);let a={},o=n.Xn,i=[];function s(){if("u"<typeof document)return n.Xn;let e=document.cookie.split(";").find(e=>e.trim().startsWith(`${n.CL}=`)),t=e?decodeURIComponent(e.split("=")[1]):n.Xn;return(0,n.QC)(t)}async function u(e){if("en"===e){a={};return}try{let t=await fetch(`/i18n/literals/${e}.json`);a=await t.json()}catch(e){console.error("Failed to load translations:",e),a={}}}function l(e){if(!e||"string"!=typeof e)return e;let t=e.trim();return t&&"en"!==o&&a[t]||e}function c(e){if(!e.nodeValue||!e.nodeValue.trim())return;let t=e.parentElement;if(!t)return;let r=t;for(;r;){if(r.hasAttribute&&r.hasAttribute("data-i18n-skip"))return;r=r.parentElement}if(["script","style","code","pre","colgroup","table","thead","tbody","tfoot","tr","select","datalist","optgroup"].includes(t.tagName?.toLowerCase()))return;e._originalText||(e._originalText=e.nodeValue);let n=l(e._originalText);n!==e.nodeValue&&(e.nodeValue=n)}function d(e){let t;if(!e)return;let r=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,null,!1),n=[];for(;t=r.nextNode();)n.push(t);n.forEach(c)}async function m(){o=s(),await u(o),d(document.body),new MutationObserver(e=>{e.forEach(e=>{e.addedNodes.forEach(e=>{e.nodeType===Node.ELEMENT_NODE?d(e):e.nodeType===Node.TEXT_NODE&&c(e)})})}).observe(document.body,{childList:!0,subtree:!0})}async function f(){o=s(),await u(o),i.forEach(e=>e()),d(document.body)}},73321:(e,t,r)=>{"use strict";var n=r(74645);r.o(n,"useParams")&&r.d(t,{useParams:function(){return n.useParams}}),r.o(n,"usePathname")&&r.d(t,{usePathname:function(){return n.usePathname}}),r.o(n,"useRouter")&&r.d(t,{useRouter:function(){return n.useRouter}}),r.o(n,"useSearchParams")&&r.d(t,{useSearchParams:function(){return n.useSearchParams}})},90085:(e,t,r)=>{"use strict";r.d(t,{A:()=>s});var n=r(1934),a=r(31692),o=r(90620);function i(e){let t=document.documentElement,r=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light";"dark"===("system"===e?r:e)?t.classList.add("dark"):t.classList.remove("dark")}let s=(0,n.v)((0,a.Zr)((e,t)=>({theme:o.B2.defaultTheme,setTheme:t=>{e({theme:t}),i(t)},toggleTheme:()=>{let r="dark"===t().theme?"light":"dark";e({theme:r}),i(r)},initTheme:()=>{i(t().theme)}}),{name:o.B2.storageKey}))},90620:(e,t,r)=>{"use strict";r.d(t,{Q2:()=>n.Q2,fg:()=>n.fg,vQ:()=>a,MA:()=>n.MA,UY:()=>i,zN:()=>n.zN,B2:()=>o});var n=r(52679);r(28777);let a={name:"Endpoint Proxy",description:"AI Infrastructure Management",version:"0.3.49"},o={storageKey:"theme",defaultTheme:"system"},i={maxLines:200,pollIntervalMs:1e3}},93308:(e,t,r)=>{"use strict";r.d(t,{CL:()=>o,QC:()=>i,Xn:()=>a,YZ:()=>n});let n=["en","vi","zh-CN"],a="en",o="locale";function i(e){return"zh"===e||"zh-CN"===e?"zh-CN":"en"===e?"en":"vi"===e?"vi":a}},94635:(e,t,r)=>{"use strict";r.d(t,{RuntimeI18nProvider:()=>s});var n=r(95155),a=r(12115),o=r(73321),i=r(73006);function s({children:e}){let t=(0,o.usePathname)();return(0,a.useEffect)(()=>{(0,i.FE)()},[]),(0,a.useEffect)(()=>{t&&requestAnimationFrame(()=>{requestAnimationFrame(()=>{(0,i.wn)()})})},[t]),(0,n.jsx)(n.Fragment,{children:e})}}},e=>{e.O(0,[6930,2652,8441,3794,7358],()=>e(e.s=64206)),_N_E=e.O()}]);
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[7177],{1934:(e,t,r)=>{"use strict";r.d(t,{v:()=>i});var n=r(12115);let a=e=>{let t,r=new Set,n=(e,n)=>{let a="function"==typeof e?e(t):e;if(!Object.is(a,t)){let e=t;t=(null!=n?n:"object"!=typeof a||null===a)?a:Object.assign({},t,a),r.forEach(r=>r(t,e))}},a=()=>t,o={setState:n,getState:a,getInitialState:()=>i,subscribe:e=>(r.add(e),()=>r.delete(e))},i=t=e(n,a,o);return o},o=e=>{let t=e?a(e):a,r=e=>(function(e,t=e=>e){let r=n.useSyncExternalStore(e.subscribe,n.useCallback(()=>t(e.getState()),[e,t]),n.useCallback(()=>t(e.getInitialState()),[e,t]));return n.useDebugValue(r),r})(t,e);return Object.assign(r,t),r},i=e=>e?o(e):o},21110:(e,t,r)=>{"use strict";r.d(t,{ThemeProvider:()=>i});var n=r(95155),a=r(12115),o=r(90085);function i({children:e}){let{initTheme:t}=(0,o.A)();return(0,a.useEffect)(()=>{t()},[t]),(0,n.jsx)(n.Fragment,{children:e})}},28777:(e,t,r)=>{"use strict";r.d(t,{KC:()=>n.KC,Xg:()=>n.Xg});var n=r(45564);Object.entries(r(52679).Q2).filter(([,e])=>e.passthroughModels).map(([e])=>e),Object.entries(n.vq).flatMap(([e,t])=>t.map(t=>({provider:e,model:t.id,name:t.name})))},31692:(e,t,r)=>{"use strict";r.d(t,{Zr:()=>a});let n=e=>t=>{try{let r=e(t);if(r instanceof Promise)return r;return{then:e=>n(e)(r),catch(e){return this}}}catch(e){return{then(e){return this},catch:t=>n(t)(e)}}},a=(e,t)=>(r,a,o)=>{let i,s={storage:function(e,t){let r;try{r=e()}catch(e){return}return{getItem:e=>{var t;let n=e=>null===e?null:JSON.parse(e,void 0),a=null!=(t=r.getItem(e))?t:null;return a instanceof Promise?a.then(n):n(a)},setItem:(e,t)=>r.setItem(e,JSON.stringify(t,void 0)),removeItem:e=>r.removeItem(e)}}(()=>window.localStorage),partialize:e=>e,version:0,merge:(e,t)=>({...t,...e}),...t},u=!1,l=0,c=new Set,d=new Set,m=s.storage;if(!m)return e((...e)=>{console.warn(`[zustand persist middleware] Unable to update item '${s.name}', the given storage is currently unavailable.`),r(...e)},a,o);let f=()=>{let e=s.partialize({...a()});return m.setItem(s.name,{state:e,version:s.version})},h=o.setState;o.setState=(e,t)=>(h(e,t),f());let p=e((...e)=>(r(...e),f()),a,o);o.getInitialState=()=>p;let v=()=>{var e,t;if(!m)return;let o=++l;u=!1,c.forEach(e=>{var t;return e(null!=(t=a())?t:p)});let h=(null==(t=s.onRehydrateStorage)?void 0:t.call(s,null!=(e=a())?e:p))||void 0;return n(m.getItem.bind(m))(s.name).then(e=>{if(e)if("number"!=typeof e.version||e.version===s.version)return[!1,e.state];else{if(s.migrate){let t=s.migrate(e.state,e.version);return t instanceof Promise?t.then(e=>[!0,e]):[!0,t]}console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}return[!1,void 0]}).then(e=>{var t;if(o!==l)return;let[n,u]=e;if(r(i=s.merge(u,null!=(t=a())?t:p),!0),n)return f()}).then(()=>{o===l&&(null==h||h(i,void 0),i=a(),u=!0,d.forEach(e=>e(i)))}).catch(e=>{o===l&&(null==h||h(void 0,e))})};return o.persist={setOptions:e=>{s={...s,...e},e.storage&&(m=e.storage)},clearStorage:()=>{null==m||m.removeItem(s.name)},getOptions:()=>s,rehydrate:()=>v(),hasHydrated:()=>u,onHydrate:e=>(c.add(e),()=>{c.delete(e)}),onFinishHydration:e=>(d.add(e),()=>{d.delete(e)})},s.skipHydration||v(),i||p}},35154:e=>{e.exports={style:{fontFamily:"'Inter', 'Inter Fallback'",fontStyle:"normal"},className:"__className_f367f3",variable:"__variable_f367f3"}},51743:()=>{},54642:e=>{var t;"u">typeof __nccwpck_require__&&(__nccwpck_require__.ab="//"),(t={}).endianness=function(){return"LE"},t.hostname=function(){return"u">typeof location?location.hostname:""},t.loadavg=function(){return[]},t.uptime=function(){return 0},t.freemem=function(){return Number.MAX_VALUE},t.totalmem=function(){return Number.MAX_VALUE},t.cpus=function(){return[]},t.type=function(){return"Browser"},t.release=function(){return"u">typeof navigator?navigator.appVersion:""},t.networkInterfaces=t.getNetworkInterfaces=function(){return{}},t.arch=function(){return"javascript"},t.platform=function(){return"browser"},t.tmpdir=t.tmpDir=function(){return"/tmp"},t.EOL="\n",t.homedir=function(){return"/"},e.exports=t},64206:(e,t,r)=>{Promise.resolve().then(r.t.bind(r,35154,23)),Promise.resolve().then(r.t.bind(r,51743,23)),Promise.resolve().then(r.bind(r,94635)),Promise.resolve().then(r.bind(r,21110))},73006:(e,t,r)=>{"use strict";r.d(t,{FE:()=>m,Tl:()=>l,wn:()=>f});var n=r(93308);let a={},o=n.Xn,i=[];function s(){if("u"<typeof document)return n.Xn;let e=document.cookie.split(";").find(e=>e.trim().startsWith(`${n.CL}=`)),t=e?decodeURIComponent(e.split("=")[1]):n.Xn;return(0,n.QC)(t)}async function u(e){if("en"===e){a={};return}try{let t=await fetch(`/i18n/literals/${e}.json`);a=await t.json()}catch(e){console.error("Failed to load translations:",e),a={}}}function l(e){if(!e||"string"!=typeof e)return e;let t=e.trim();return t&&"en"!==o&&a[t]||e}function c(e){if(!e.nodeValue||!e.nodeValue.trim())return;let t=e.parentElement;if(!t)return;let r=t;for(;r;){if(r.hasAttribute&&r.hasAttribute("data-i18n-skip"))return;r=r.parentElement}if(["script","style","code","pre","colgroup","table","thead","tbody","tfoot","tr","select","datalist","optgroup"].includes(t.tagName?.toLowerCase()))return;e._originalText||(e._originalText=e.nodeValue);let n=l(e._originalText);n!==e.nodeValue&&(e.nodeValue=n)}function d(e){let t;if(!e)return;let r=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,null,!1),n=[];for(;t=r.nextNode();)n.push(t);n.forEach(c)}async function m(){o=s(),await u(o),d(document.body),new MutationObserver(e=>{e.forEach(e=>{e.addedNodes.forEach(e=>{e.nodeType===Node.ELEMENT_NODE?d(e):e.nodeType===Node.TEXT_NODE&&c(e)})})}).observe(document.body,{childList:!0,subtree:!0})}async function f(){o=s(),await u(o),i.forEach(e=>e()),d(document.body)}},73321:(e,t,r)=>{"use strict";var n=r(74645);r.o(n,"useParams")&&r.d(t,{useParams:function(){return n.useParams}}),r.o(n,"usePathname")&&r.d(t,{usePathname:function(){return n.usePathname}}),r.o(n,"useRouter")&&r.d(t,{useRouter:function(){return n.useRouter}}),r.o(n,"useSearchParams")&&r.d(t,{useSearchParams:function(){return n.useSearchParams}})},90085:(e,t,r)=>{"use strict";r.d(t,{A:()=>s});var n=r(1934),a=r(31692),o=r(90620);function i(e){let t=document.documentElement,r=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light";"dark"===("system"===e?r:e)?t.classList.add("dark"):t.classList.remove("dark")}let s=(0,n.v)((0,a.Zr)((e,t)=>({theme:o.B2.defaultTheme,setTheme:t=>{e({theme:t}),i(t)},toggleTheme:()=>{let r="dark"===t().theme?"light":"dark";e({theme:r}),i(r)},initTheme:()=>{i(t().theme)}}),{name:o.B2.storageKey}))},90620:(e,t,r)=>{"use strict";r.d(t,{Q2:()=>n.Q2,fg:()=>n.fg,vQ:()=>a,MA:()=>n.MA,UY:()=>i,zN:()=>n.zN,B2:()=>o});var n=r(52679);r(28777);let a={name:"Endpoint Proxy",description:"AI Infrastructure Management",version:"0.3.50"},o={storageKey:"theme",defaultTheme:"system"},i={maxLines:200,pollIntervalMs:1e3}},93308:(e,t,r)=>{"use strict";r.d(t,{CL:()=>o,QC:()=>i,Xn:()=>a,YZ:()=>n});let n=["en","vi","zh-CN"],a="en",o="locale";function i(e){return"zh"===e||"zh-CN"===e?"zh-CN":"en"===e?"en":"vi"===e?"vi":a}},94635:(e,t,r)=>{"use strict";r.d(t,{RuntimeI18nProvider:()=>s});var n=r(95155),a=r(12115),o=r(73321),i=r(73006);function s({children:e}){let t=(0,o.usePathname)();return(0,a.useEffect)(()=>{(0,i.FE)()},[]),(0,a.useEffect)(()=>{t&&requestAnimationFrame(()=>{requestAnimationFrame(()=>{(0,i.wn)()})})},[t]),(0,n.jsx)(n.Fragment,{children:e})}}},e=>{e.O(0,[6930,2652,8441,3794,7358],()=>e(e.s=64206)),_N_E=e.O()}]);
package/app/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "9router-app",
3
- "version": "0.3.49",
3
+ "version": "0.3.50",
4
4
  "description": "9Router web dashboard",
5
5
  "private": true,
6
6
  "scripts": {
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "9router",
3
- "version": "0.3.49",
3
+ "version": "0.3.50",
4
4
  "description": "9Router CLI - Start and manage 9Router server",
5
5
  "bin": {
6
6
  "9router": "./cli.js"