@rabbi696/ezrouter 0.5.69 → 0.5.71

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 (316) hide show
  1. package/app/.next-cli-build/BUILD_ID +1 -1
  2. package/app/.next-cli-build/app-path-routes-manifest.json +15 -15
  3. package/app/.next-cli-build/build-manifest.json +2 -2
  4. package/app/.next-cli-build/server/app/(dashboard)/dashboard/basic-chat/page_client-reference-manifest.js +1 -1
  5. package/app/.next-cli-build/server/app/(dashboard)/dashboard/cli-tools/[toolId]/page_client-reference-manifest.js +1 -1
  6. package/app/.next-cli-build/server/app/(dashboard)/dashboard/cli-tools/page_client-reference-manifest.js +1 -1
  7. package/app/.next-cli-build/server/app/(dashboard)/dashboard/combos/page_client-reference-manifest.js +1 -1
  8. package/app/.next-cli-build/server/app/(dashboard)/dashboard/console-log/page_client-reference-manifest.js +1 -1
  9. package/app/.next-cli-build/server/app/(dashboard)/dashboard/convoy/page_client-reference-manifest.js +1 -1
  10. package/app/.next-cli-build/server/app/(dashboard)/dashboard/endpoint/page_client-reference-manifest.js +1 -1
  11. package/app/.next-cli-build/server/app/(dashboard)/dashboard/error-log/page_client-reference-manifest.js +1 -1
  12. package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/[kind]/[id]/page_client-reference-manifest.js +1 -1
  13. package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/[kind]/page_client-reference-manifest.js +1 -1
  14. package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/combo/[id]/page_client-reference-manifest.js +1 -1
  15. package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/web/page_client-reference-manifest.js +1 -1
  16. package/app/.next-cli-build/server/app/(dashboard)/dashboard/mitm/page_client-reference-manifest.js +1 -1
  17. package/app/.next-cli-build/server/app/(dashboard)/dashboard/page_client-reference-manifest.js +1 -1
  18. package/app/.next-cli-build/server/app/(dashboard)/dashboard/profile/page_client-reference-manifest.js +1 -1
  19. package/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/[id]/page.js +1 -1
  20. package/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/[id]/page_client-reference-manifest.js +1 -1
  21. package/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/new/page_client-reference-manifest.js +1 -1
  22. package/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/page.js +1 -1
  23. package/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/page_client-reference-manifest.js +1 -1
  24. package/app/.next-cli-build/server/app/(dashboard)/dashboard/proxy-pools/page_client-reference-manifest.js +1 -1
  25. package/app/.next-cli-build/server/app/(dashboard)/dashboard/pxpipe/page_client-reference-manifest.js +1 -1
  26. package/app/.next-cli-build/server/app/(dashboard)/dashboard/quota/page_client-reference-manifest.js +1 -1
  27. package/app/.next-cli-build/server/app/(dashboard)/dashboard/routing-health/page_client-reference-manifest.js +1 -1
  28. package/app/.next-cli-build/server/app/(dashboard)/dashboard/skills/page_client-reference-manifest.js +1 -1
  29. package/app/.next-cli-build/server/app/(dashboard)/dashboard/token-saver/page_client-reference-manifest.js +1 -1
  30. package/app/.next-cli-build/server/app/(dashboard)/dashboard/translator/page_client-reference-manifest.js +1 -1
  31. package/app/.next-cli-build/server/app/(dashboard)/dashboard/usage/page_client-reference-manifest.js +1 -1
  32. package/app/.next-cli-build/server/app/_global-error/page_client-reference-manifest.js +1 -1
  33. package/app/.next-cli-build/server/app/_global-error.html +1 -1
  34. package/app/.next-cli-build/server/app/_global-error.rsc +1 -1
  35. package/app/.next-cli-build/server/app/_global-error.segments/_full.segment.rsc +1 -1
  36. package/app/.next-cli-build/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
  37. package/app/.next-cli-build/server/app/_global-error.segments/_global-error.segment.rsc +1 -1
  38. package/app/.next-cli-build/server/app/_global-error.segments/_head.segment.rsc +1 -1
  39. package/app/.next-cli-build/server/app/_global-error.segments/_index.segment.rsc +1 -1
  40. package/app/.next-cli-build/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  41. package/app/.next-cli-build/server/app/_not-found/page_client-reference-manifest.js +1 -1
  42. package/app/.next-cli-build/server/app/_not-found.html +1 -1
  43. package/app/.next-cli-build/server/app/_not-found.rsc +3 -3
  44. package/app/.next-cli-build/server/app/_not-found.segments/_full.segment.rsc +3 -3
  45. package/app/.next-cli-build/server/app/_not-found.segments/_head.segment.rsc +1 -1
  46. package/app/.next-cli-build/server/app/_not-found.segments/_index.segment.rsc +3 -3
  47. package/app/.next-cli-build/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
  48. package/app/.next-cli-build/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
  49. package/app/.next-cli-build/server/app/_not-found.segments/_tree.segment.rsc +1 -1
  50. package/app/.next-cli-build/server/app/api/models/route.js +1 -1
  51. package/app/.next-cli-build/server/app/api/providers/route.js +1 -1
  52. package/app/.next-cli-build/server/app/api/translator/console-logs/route.js +1 -1
  53. package/app/.next-cli-build/server/app/api/translator/console-logs/stream/route.js +1 -1
  54. package/app/.next-cli-build/server/app/api/version/route.js +1 -1
  55. package/app/.next-cli-build/server/app/callback/page_client-reference-manifest.js +1 -1
  56. package/app/.next-cli-build/server/app/callback.html +1 -1
  57. package/app/.next-cli-build/server/app/callback.rsc +3 -3
  58. package/app/.next-cli-build/server/app/callback.segments/_full.segment.rsc +3 -3
  59. package/app/.next-cli-build/server/app/callback.segments/_head.segment.rsc +1 -1
  60. package/app/.next-cli-build/server/app/callback.segments/_index.segment.rsc +3 -3
  61. package/app/.next-cli-build/server/app/callback.segments/_tree.segment.rsc +1 -1
  62. package/app/.next-cli-build/server/app/callback.segments/callback/__PAGE__.segment.rsc +1 -1
  63. package/app/.next-cli-build/server/app/callback.segments/callback.segment.rsc +1 -1
  64. package/app/.next-cli-build/server/app/dashboard/basic-chat.html +1 -1
  65. package/app/.next-cli-build/server/app/dashboard/basic-chat.rsc +5 -5
  66. package/app/.next-cli-build/server/app/dashboard/basic-chat.segments/!KGRhc2hib2FyZCk/dashboard/basic-chat/__PAGE__.segment.rsc +2 -2
  67. package/app/.next-cli-build/server/app/dashboard/basic-chat.segments/!KGRhc2hib2FyZCk/dashboard/basic-chat.segment.rsc +1 -1
  68. package/app/.next-cli-build/server/app/dashboard/basic-chat.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  69. package/app/.next-cli-build/server/app/dashboard/basic-chat.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  70. package/app/.next-cli-build/server/app/dashboard/basic-chat.segments/_full.segment.rsc +5 -5
  71. package/app/.next-cli-build/server/app/dashboard/basic-chat.segments/_head.segment.rsc +1 -1
  72. package/app/.next-cli-build/server/app/dashboard/basic-chat.segments/_index.segment.rsc +3 -3
  73. package/app/.next-cli-build/server/app/dashboard/basic-chat.segments/_tree.segment.rsc +1 -1
  74. package/app/.next-cli-build/server/app/dashboard/cli-tools.html +1 -1
  75. package/app/.next-cli-build/server/app/dashboard/cli-tools.rsc +5 -5
  76. package/app/.next-cli-build/server/app/dashboard/cli-tools.segments/!KGRhc2hib2FyZCk/dashboard/cli-tools/__PAGE__.segment.rsc +2 -2
  77. package/app/.next-cli-build/server/app/dashboard/cli-tools.segments/!KGRhc2hib2FyZCk/dashboard/cli-tools.segment.rsc +1 -1
  78. package/app/.next-cli-build/server/app/dashboard/cli-tools.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  79. package/app/.next-cli-build/server/app/dashboard/cli-tools.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  80. package/app/.next-cli-build/server/app/dashboard/cli-tools.segments/_full.segment.rsc +5 -5
  81. package/app/.next-cli-build/server/app/dashboard/cli-tools.segments/_head.segment.rsc +1 -1
  82. package/app/.next-cli-build/server/app/dashboard/cli-tools.segments/_index.segment.rsc +3 -3
  83. package/app/.next-cli-build/server/app/dashboard/cli-tools.segments/_tree.segment.rsc +1 -1
  84. package/app/.next-cli-build/server/app/dashboard/combos.html +1 -1
  85. package/app/.next-cli-build/server/app/dashboard/combos.rsc +5 -5
  86. package/app/.next-cli-build/server/app/dashboard/combos.segments/!KGRhc2hib2FyZCk/dashboard/combos/__PAGE__.segment.rsc +2 -2
  87. package/app/.next-cli-build/server/app/dashboard/combos.segments/!KGRhc2hib2FyZCk/dashboard/combos.segment.rsc +1 -1
  88. package/app/.next-cli-build/server/app/dashboard/combos.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  89. package/app/.next-cli-build/server/app/dashboard/combos.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  90. package/app/.next-cli-build/server/app/dashboard/combos.segments/_full.segment.rsc +5 -5
  91. package/app/.next-cli-build/server/app/dashboard/combos.segments/_head.segment.rsc +1 -1
  92. package/app/.next-cli-build/server/app/dashboard/combos.segments/_index.segment.rsc +3 -3
  93. package/app/.next-cli-build/server/app/dashboard/combos.segments/_tree.segment.rsc +1 -1
  94. package/app/.next-cli-build/server/app/dashboard/convoy.html +1 -1
  95. package/app/.next-cli-build/server/app/dashboard/convoy.rsc +5 -5
  96. package/app/.next-cli-build/server/app/dashboard/convoy.segments/!KGRhc2hib2FyZCk/dashboard/convoy/__PAGE__.segment.rsc +2 -2
  97. package/app/.next-cli-build/server/app/dashboard/convoy.segments/!KGRhc2hib2FyZCk/dashboard/convoy.segment.rsc +1 -1
  98. package/app/.next-cli-build/server/app/dashboard/convoy.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  99. package/app/.next-cli-build/server/app/dashboard/convoy.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  100. package/app/.next-cli-build/server/app/dashboard/convoy.segments/_full.segment.rsc +5 -5
  101. package/app/.next-cli-build/server/app/dashboard/convoy.segments/_head.segment.rsc +1 -1
  102. package/app/.next-cli-build/server/app/dashboard/convoy.segments/_index.segment.rsc +3 -3
  103. package/app/.next-cli-build/server/app/dashboard/convoy.segments/_tree.segment.rsc +1 -1
  104. package/app/.next-cli-build/server/app/dashboard/endpoint.html +1 -1
  105. package/app/.next-cli-build/server/app/dashboard/endpoint.rsc +5 -5
  106. package/app/.next-cli-build/server/app/dashboard/endpoint.segments/!KGRhc2hib2FyZCk/dashboard/endpoint/__PAGE__.segment.rsc +2 -2
  107. package/app/.next-cli-build/server/app/dashboard/endpoint.segments/!KGRhc2hib2FyZCk/dashboard/endpoint.segment.rsc +1 -1
  108. package/app/.next-cli-build/server/app/dashboard/endpoint.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  109. package/app/.next-cli-build/server/app/dashboard/endpoint.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  110. package/app/.next-cli-build/server/app/dashboard/endpoint.segments/_full.segment.rsc +5 -5
  111. package/app/.next-cli-build/server/app/dashboard/endpoint.segments/_head.segment.rsc +1 -1
  112. package/app/.next-cli-build/server/app/dashboard/endpoint.segments/_index.segment.rsc +3 -3
  113. package/app/.next-cli-build/server/app/dashboard/endpoint.segments/_tree.segment.rsc +1 -1
  114. package/app/.next-cli-build/server/app/dashboard/media-providers/web.html +1 -1
  115. package/app/.next-cli-build/server/app/dashboard/media-providers/web.rsc +5 -5
  116. package/app/.next-cli-build/server/app/dashboard/media-providers/web.segments/!KGRhc2hib2FyZCk/dashboard/media-providers/web/__PAGE__.segment.rsc +2 -2
  117. package/app/.next-cli-build/server/app/dashboard/media-providers/web.segments/!KGRhc2hib2FyZCk/dashboard/media-providers/web.segment.rsc +1 -1
  118. package/app/.next-cli-build/server/app/dashboard/media-providers/web.segments/!KGRhc2hib2FyZCk/dashboard/media-providers.segment.rsc +1 -1
  119. package/app/.next-cli-build/server/app/dashboard/media-providers/web.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  120. package/app/.next-cli-build/server/app/dashboard/media-providers/web.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  121. package/app/.next-cli-build/server/app/dashboard/media-providers/web.segments/_full.segment.rsc +5 -5
  122. package/app/.next-cli-build/server/app/dashboard/media-providers/web.segments/_head.segment.rsc +1 -1
  123. package/app/.next-cli-build/server/app/dashboard/media-providers/web.segments/_index.segment.rsc +3 -3
  124. package/app/.next-cli-build/server/app/dashboard/media-providers/web.segments/_tree.segment.rsc +1 -1
  125. package/app/.next-cli-build/server/app/dashboard/mitm.html +1 -1
  126. package/app/.next-cli-build/server/app/dashboard/mitm.rsc +5 -5
  127. package/app/.next-cli-build/server/app/dashboard/mitm.segments/!KGRhc2hib2FyZCk/dashboard/mitm/__PAGE__.segment.rsc +2 -2
  128. package/app/.next-cli-build/server/app/dashboard/mitm.segments/!KGRhc2hib2FyZCk/dashboard/mitm.segment.rsc +1 -1
  129. package/app/.next-cli-build/server/app/dashboard/mitm.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  130. package/app/.next-cli-build/server/app/dashboard/mitm.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  131. package/app/.next-cli-build/server/app/dashboard/mitm.segments/_full.segment.rsc +5 -5
  132. package/app/.next-cli-build/server/app/dashboard/mitm.segments/_head.segment.rsc +1 -1
  133. package/app/.next-cli-build/server/app/dashboard/mitm.segments/_index.segment.rsc +3 -3
  134. package/app/.next-cli-build/server/app/dashboard/mitm.segments/_tree.segment.rsc +1 -1
  135. package/app/.next-cli-build/server/app/dashboard/profile.html +1 -1
  136. package/app/.next-cli-build/server/app/dashboard/profile.rsc +5 -5
  137. package/app/.next-cli-build/server/app/dashboard/profile.segments/!KGRhc2hib2FyZCk/dashboard/profile/__PAGE__.segment.rsc +2 -2
  138. package/app/.next-cli-build/server/app/dashboard/profile.segments/!KGRhc2hib2FyZCk/dashboard/profile.segment.rsc +1 -1
  139. package/app/.next-cli-build/server/app/dashboard/profile.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  140. package/app/.next-cli-build/server/app/dashboard/profile.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  141. package/app/.next-cli-build/server/app/dashboard/profile.segments/_full.segment.rsc +5 -5
  142. package/app/.next-cli-build/server/app/dashboard/profile.segments/_head.segment.rsc +1 -1
  143. package/app/.next-cli-build/server/app/dashboard/profile.segments/_index.segment.rsc +3 -3
  144. package/app/.next-cli-build/server/app/dashboard/profile.segments/_tree.segment.rsc +1 -1
  145. package/app/.next-cli-build/server/app/dashboard/providers/new.html +1 -1
  146. package/app/.next-cli-build/server/app/dashboard/providers/new.rsc +5 -5
  147. package/app/.next-cli-build/server/app/dashboard/providers/new.segments/!KGRhc2hib2FyZCk/dashboard/providers/new/__PAGE__.segment.rsc +2 -2
  148. package/app/.next-cli-build/server/app/dashboard/providers/new.segments/!KGRhc2hib2FyZCk/dashboard/providers/new.segment.rsc +1 -1
  149. package/app/.next-cli-build/server/app/dashboard/providers/new.segments/!KGRhc2hib2FyZCk/dashboard/providers.segment.rsc +1 -1
  150. package/app/.next-cli-build/server/app/dashboard/providers/new.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  151. package/app/.next-cli-build/server/app/dashboard/providers/new.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  152. package/app/.next-cli-build/server/app/dashboard/providers/new.segments/_full.segment.rsc +5 -5
  153. package/app/.next-cli-build/server/app/dashboard/providers/new.segments/_head.segment.rsc +1 -1
  154. package/app/.next-cli-build/server/app/dashboard/providers/new.segments/_index.segment.rsc +3 -3
  155. package/app/.next-cli-build/server/app/dashboard/providers/new.segments/_tree.segment.rsc +1 -1
  156. package/app/.next-cli-build/server/app/dashboard/providers.html +1 -1
  157. package/app/.next-cli-build/server/app/dashboard/providers.rsc +5 -5
  158. package/app/.next-cli-build/server/app/dashboard/providers.segments/!KGRhc2hib2FyZCk/dashboard/providers/__PAGE__.segment.rsc +2 -2
  159. package/app/.next-cli-build/server/app/dashboard/providers.segments/!KGRhc2hib2FyZCk/dashboard/providers.segment.rsc +1 -1
  160. package/app/.next-cli-build/server/app/dashboard/providers.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  161. package/app/.next-cli-build/server/app/dashboard/providers.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  162. package/app/.next-cli-build/server/app/dashboard/providers.segments/_full.segment.rsc +5 -5
  163. package/app/.next-cli-build/server/app/dashboard/providers.segments/_head.segment.rsc +1 -1
  164. package/app/.next-cli-build/server/app/dashboard/providers.segments/_index.segment.rsc +3 -3
  165. package/app/.next-cli-build/server/app/dashboard/providers.segments/_tree.segment.rsc +1 -1
  166. package/app/.next-cli-build/server/app/dashboard/proxy-pools.html +1 -1
  167. package/app/.next-cli-build/server/app/dashboard/proxy-pools.rsc +5 -5
  168. package/app/.next-cli-build/server/app/dashboard/proxy-pools.segments/!KGRhc2hib2FyZCk/dashboard/proxy-pools/__PAGE__.segment.rsc +2 -2
  169. package/app/.next-cli-build/server/app/dashboard/proxy-pools.segments/!KGRhc2hib2FyZCk/dashboard/proxy-pools.segment.rsc +1 -1
  170. package/app/.next-cli-build/server/app/dashboard/proxy-pools.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  171. package/app/.next-cli-build/server/app/dashboard/proxy-pools.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  172. package/app/.next-cli-build/server/app/dashboard/proxy-pools.segments/_full.segment.rsc +5 -5
  173. package/app/.next-cli-build/server/app/dashboard/proxy-pools.segments/_head.segment.rsc +1 -1
  174. package/app/.next-cli-build/server/app/dashboard/proxy-pools.segments/_index.segment.rsc +3 -3
  175. package/app/.next-cli-build/server/app/dashboard/proxy-pools.segments/_tree.segment.rsc +1 -1
  176. package/app/.next-cli-build/server/app/dashboard/pxpipe.html +1 -1
  177. package/app/.next-cli-build/server/app/dashboard/pxpipe.rsc +5 -5
  178. package/app/.next-cli-build/server/app/dashboard/pxpipe.segments/!KGRhc2hib2FyZCk/dashboard/pxpipe/__PAGE__.segment.rsc +2 -2
  179. package/app/.next-cli-build/server/app/dashboard/pxpipe.segments/!KGRhc2hib2FyZCk/dashboard/pxpipe.segment.rsc +1 -1
  180. package/app/.next-cli-build/server/app/dashboard/pxpipe.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  181. package/app/.next-cli-build/server/app/dashboard/pxpipe.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  182. package/app/.next-cli-build/server/app/dashboard/pxpipe.segments/_full.segment.rsc +5 -5
  183. package/app/.next-cli-build/server/app/dashboard/pxpipe.segments/_head.segment.rsc +1 -1
  184. package/app/.next-cli-build/server/app/dashboard/pxpipe.segments/_index.segment.rsc +3 -3
  185. package/app/.next-cli-build/server/app/dashboard/pxpipe.segments/_tree.segment.rsc +1 -1
  186. package/app/.next-cli-build/server/app/dashboard/quota.html +2 -2
  187. package/app/.next-cli-build/server/app/dashboard/quota.rsc +6 -6
  188. package/app/.next-cli-build/server/app/dashboard/quota.segments/!KGRhc2hib2FyZCk/dashboard/quota/__PAGE__.segment.rsc +3 -3
  189. package/app/.next-cli-build/server/app/dashboard/quota.segments/!KGRhc2hib2FyZCk/dashboard/quota.segment.rsc +1 -1
  190. package/app/.next-cli-build/server/app/dashboard/quota.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  191. package/app/.next-cli-build/server/app/dashboard/quota.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  192. package/app/.next-cli-build/server/app/dashboard/quota.segments/_full.segment.rsc +6 -6
  193. package/app/.next-cli-build/server/app/dashboard/quota.segments/_head.segment.rsc +1 -1
  194. package/app/.next-cli-build/server/app/dashboard/quota.segments/_index.segment.rsc +3 -3
  195. package/app/.next-cli-build/server/app/dashboard/quota.segments/_tree.segment.rsc +1 -1
  196. package/app/.next-cli-build/server/app/dashboard/routing-health.html +1 -1
  197. package/app/.next-cli-build/server/app/dashboard/routing-health.rsc +5 -5
  198. package/app/.next-cli-build/server/app/dashboard/routing-health.segments/!KGRhc2hib2FyZCk/dashboard/routing-health/__PAGE__.segment.rsc +2 -2
  199. package/app/.next-cli-build/server/app/dashboard/routing-health.segments/!KGRhc2hib2FyZCk/dashboard/routing-health.segment.rsc +1 -1
  200. package/app/.next-cli-build/server/app/dashboard/routing-health.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  201. package/app/.next-cli-build/server/app/dashboard/routing-health.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  202. package/app/.next-cli-build/server/app/dashboard/routing-health.segments/_full.segment.rsc +5 -5
  203. package/app/.next-cli-build/server/app/dashboard/routing-health.segments/_head.segment.rsc +1 -1
  204. package/app/.next-cli-build/server/app/dashboard/routing-health.segments/_index.segment.rsc +3 -3
  205. package/app/.next-cli-build/server/app/dashboard/routing-health.segments/_tree.segment.rsc +1 -1
  206. package/app/.next-cli-build/server/app/dashboard/settings/pricing/page_client-reference-manifest.js +1 -1
  207. package/app/.next-cli-build/server/app/dashboard/settings/pricing.html +1 -1
  208. package/app/.next-cli-build/server/app/dashboard/settings/pricing.rsc +3 -3
  209. package/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/_full.segment.rsc +3 -3
  210. package/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/_head.segment.rsc +1 -1
  211. package/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/_index.segment.rsc +3 -3
  212. package/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/_tree.segment.rsc +1 -1
  213. package/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/dashboard/settings/pricing/__PAGE__.segment.rsc +1 -1
  214. package/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/dashboard/settings/pricing.segment.rsc +1 -1
  215. package/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/dashboard/settings.segment.rsc +1 -1
  216. package/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/dashboard.segment.rsc +1 -1
  217. package/app/.next-cli-build/server/app/dashboard/skills.html +1 -1
  218. package/app/.next-cli-build/server/app/dashboard/skills.rsc +5 -5
  219. package/app/.next-cli-build/server/app/dashboard/skills.segments/!KGRhc2hib2FyZCk/dashboard/skills/__PAGE__.segment.rsc +2 -2
  220. package/app/.next-cli-build/server/app/dashboard/skills.segments/!KGRhc2hib2FyZCk/dashboard/skills.segment.rsc +1 -1
  221. package/app/.next-cli-build/server/app/dashboard/skills.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  222. package/app/.next-cli-build/server/app/dashboard/skills.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  223. package/app/.next-cli-build/server/app/dashboard/skills.segments/_full.segment.rsc +5 -5
  224. package/app/.next-cli-build/server/app/dashboard/skills.segments/_head.segment.rsc +1 -1
  225. package/app/.next-cli-build/server/app/dashboard/skills.segments/_index.segment.rsc +3 -3
  226. package/app/.next-cli-build/server/app/dashboard/skills.segments/_tree.segment.rsc +1 -1
  227. package/app/.next-cli-build/server/app/dashboard/token-saver.html +1 -1
  228. package/app/.next-cli-build/server/app/dashboard/token-saver.rsc +5 -5
  229. package/app/.next-cli-build/server/app/dashboard/token-saver.segments/!KGRhc2hib2FyZCk/dashboard/token-saver/__PAGE__.segment.rsc +2 -2
  230. package/app/.next-cli-build/server/app/dashboard/token-saver.segments/!KGRhc2hib2FyZCk/dashboard/token-saver.segment.rsc +1 -1
  231. package/app/.next-cli-build/server/app/dashboard/token-saver.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  232. package/app/.next-cli-build/server/app/dashboard/token-saver.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  233. package/app/.next-cli-build/server/app/dashboard/token-saver.segments/_full.segment.rsc +5 -5
  234. package/app/.next-cli-build/server/app/dashboard/token-saver.segments/_head.segment.rsc +1 -1
  235. package/app/.next-cli-build/server/app/dashboard/token-saver.segments/_index.segment.rsc +3 -3
  236. package/app/.next-cli-build/server/app/dashboard/token-saver.segments/_tree.segment.rsc +1 -1
  237. package/app/.next-cli-build/server/app/dashboard/translator.html +1 -1
  238. package/app/.next-cli-build/server/app/dashboard/translator.rsc +5 -5
  239. package/app/.next-cli-build/server/app/dashboard/translator.segments/!KGRhc2hib2FyZCk/dashboard/translator/__PAGE__.segment.rsc +2 -2
  240. package/app/.next-cli-build/server/app/dashboard/translator.segments/!KGRhc2hib2FyZCk/dashboard/translator.segment.rsc +1 -1
  241. package/app/.next-cli-build/server/app/dashboard/translator.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  242. package/app/.next-cli-build/server/app/dashboard/translator.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  243. package/app/.next-cli-build/server/app/dashboard/translator.segments/_full.segment.rsc +5 -5
  244. package/app/.next-cli-build/server/app/dashboard/translator.segments/_head.segment.rsc +1 -1
  245. package/app/.next-cli-build/server/app/dashboard/translator.segments/_index.segment.rsc +3 -3
  246. package/app/.next-cli-build/server/app/dashboard/translator.segments/_tree.segment.rsc +1 -1
  247. package/app/.next-cli-build/server/app/dashboard/usage.html +1 -1
  248. package/app/.next-cli-build/server/app/dashboard/usage.rsc +5 -5
  249. package/app/.next-cli-build/server/app/dashboard/usage.segments/!KGRhc2hib2FyZCk/dashboard/usage/__PAGE__.segment.rsc +2 -2
  250. package/app/.next-cli-build/server/app/dashboard/usage.segments/!KGRhc2hib2FyZCk/dashboard/usage.segment.rsc +1 -1
  251. package/app/.next-cli-build/server/app/dashboard/usage.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  252. package/app/.next-cli-build/server/app/dashboard/usage.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  253. package/app/.next-cli-build/server/app/dashboard/usage.segments/_full.segment.rsc +5 -5
  254. package/app/.next-cli-build/server/app/dashboard/usage.segments/_head.segment.rsc +1 -1
  255. package/app/.next-cli-build/server/app/dashboard/usage.segments/_index.segment.rsc +3 -3
  256. package/app/.next-cli-build/server/app/dashboard/usage.segments/_tree.segment.rsc +1 -1
  257. package/app/.next-cli-build/server/app/dashboard.html +1 -1
  258. package/app/.next-cli-build/server/app/dashboard.rsc +5 -5
  259. package/app/.next-cli-build/server/app/dashboard.segments/!KGRhc2hib2FyZCk/dashboard/__PAGE__.segment.rsc +2 -2
  260. package/app/.next-cli-build/server/app/dashboard.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  261. package/app/.next-cli-build/server/app/dashboard.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  262. package/app/.next-cli-build/server/app/dashboard.segments/_full.segment.rsc +5 -5
  263. package/app/.next-cli-build/server/app/dashboard.segments/_head.segment.rsc +1 -1
  264. package/app/.next-cli-build/server/app/dashboard.segments/_index.segment.rsc +3 -3
  265. package/app/.next-cli-build/server/app/dashboard.segments/_tree.segment.rsc +1 -1
  266. package/app/.next-cli-build/server/app/index.html +1 -1
  267. package/app/.next-cli-build/server/app/index.rsc +3 -3
  268. package/app/.next-cli-build/server/app/index.segments/__PAGE__.segment.rsc +1 -1
  269. package/app/.next-cli-build/server/app/index.segments/_full.segment.rsc +3 -3
  270. package/app/.next-cli-build/server/app/index.segments/_head.segment.rsc +1 -1
  271. package/app/.next-cli-build/server/app/index.segments/_index.segment.rsc +3 -3
  272. package/app/.next-cli-build/server/app/index.segments/_tree.segment.rsc +1 -1
  273. package/app/.next-cli-build/server/app/landing/page_client-reference-manifest.js +1 -1
  274. package/app/.next-cli-build/server/app/landing.html +1 -1
  275. package/app/.next-cli-build/server/app/landing.rsc +3 -3
  276. package/app/.next-cli-build/server/app/landing.segments/_full.segment.rsc +3 -3
  277. package/app/.next-cli-build/server/app/landing.segments/_head.segment.rsc +1 -1
  278. package/app/.next-cli-build/server/app/landing.segments/_index.segment.rsc +3 -3
  279. package/app/.next-cli-build/server/app/landing.segments/_tree.segment.rsc +1 -1
  280. package/app/.next-cli-build/server/app/landing.segments/landing/__PAGE__.segment.rsc +1 -1
  281. package/app/.next-cli-build/server/app/landing.segments/landing.segment.rsc +1 -1
  282. package/app/.next-cli-build/server/app/login/page_client-reference-manifest.js +1 -1
  283. package/app/.next-cli-build/server/app/login.html +1 -1
  284. package/app/.next-cli-build/server/app/login.rsc +4 -4
  285. package/app/.next-cli-build/server/app/login.segments/_full.segment.rsc +4 -4
  286. package/app/.next-cli-build/server/app/login.segments/_head.segment.rsc +1 -1
  287. package/app/.next-cli-build/server/app/login.segments/_index.segment.rsc +3 -3
  288. package/app/.next-cli-build/server/app/login.segments/_tree.segment.rsc +1 -1
  289. package/app/.next-cli-build/server/app/login.segments/login/__PAGE__.segment.rsc +2 -2
  290. package/app/.next-cli-build/server/app/login.segments/login.segment.rsc +1 -1
  291. package/app/.next-cli-build/server/app/page_client-reference-manifest.js +1 -1
  292. package/app/.next-cli-build/server/app-paths-manifest.json +15 -15
  293. package/app/.next-cli-build/server/chunks/412.js +1 -1
  294. package/app/.next-cli-build/server/chunks/4843.js +1 -1
  295. package/app/.next-cli-build/server/chunks/5767.js +1 -1
  296. package/app/.next-cli-build/server/chunks/7591.js +1 -1
  297. package/app/.next-cli-build/server/chunks/7775.js +1 -1
  298. package/app/.next-cli-build/server/chunks/7889.js +1 -1
  299. package/app/.next-cli-build/server/chunks/8327.js +1 -1
  300. package/app/.next-cli-build/server/chunks/921.js +1 -1
  301. package/app/.next-cli-build/server/chunks/9212.js +1 -1
  302. package/app/.next-cli-build/server/chunks/9356.js +1 -1
  303. package/app/.next-cli-build/server/middleware-build-manifest.js +1 -1
  304. package/app/.next-cli-build/server/pages/404.html +1 -1
  305. package/app/.next-cli-build/server/pages/500.html +1 -1
  306. package/app/.next-cli-build/static/chunks/{1321-930f84897ead6c2c.js → 1321-075e69c1029a3be9.js} +1 -1
  307. package/app/.next-cli-build/static/chunks/{5497-93fc7728cdff1521.js → 5497-b8180f32d8b8d12d.js} +1 -1
  308. package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/providers/[id]/{page-b5741659c03ca56b.js → page-f767dcc53bb237c6.js} +1 -1
  309. package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/providers/page-d8b0749a7237200c.js +1 -0
  310. package/app/CHANGELOG.md +4 -2
  311. package/app/package.json +1 -1
  312. package/app/public/CHANGELOG.md +4 -2
  313. package/package.json +1 -1
  314. package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/providers/page-842dac87c3271933.js +0 -1
  315. /package/app/.next-cli-build/static/{-oFClfdQrsC_KzLfqx9kb → SMVZ1Q84_Ws1e4PoYXFub}/_buildManifest.js +0 -0
  316. /package/app/.next-cli-build/static/{-oFClfdQrsC_KzLfqx9kb → SMVZ1Q84_Ws1e4PoYXFub}/_ssgManifest.js +0 -0
@@ -11,4 +11,4 @@ pt-only-auto-named`:q,[G,V]=(0,s.useState)("single"),[Q,Z]=(0,s.useState)(""),[Y
11
11
  "idToken": "eyJhbGc...",
12
12
  "email": "user@example.com"
13
13
  }
14
- ]`;function B({isOpen:e,onClose:t,onSuccess:a}){let[l,r]=(0,s.useState)(""),[n,o]=(0,s.useState)(!1),[d,m]=(0,s.useState)(""),[p,u]=(0,s.useState)(null),x=()=>{n||(r(""),m(""),u(null),t())},h=async()=>{var e;let t;m(""),u(null);let i=l.trim();if(!i)return;try{t=JSON.parse(i)}catch(e){m(`${(0,N.Tl)("Invalid JSON")}: ${e.message}`);return}let s=Array.isArray(e=t)?e:e&&"object"==typeof e?Array.isArray(e.accounts)?e.accounts:[e]:null;if(!s||0===s.length)return void m((0,N.Tl)("No accounts found in input"));o(!0);try{let e=await fetch("/api/oauth/codex/bulk-import",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({accounts:s})}),t=await e.json();if(!e.ok)return void m(t?.error||`Request failed: ${e.status}`);u(t),t.success>0&&"function"==typeof a&&a()}catch(e){m(e.message||(0,N.Tl)("Request failed"))}finally{o(!1)}},f=p?.results?.filter(e=>!e.ok)||[];return(0,i.jsx)(c.aF,{isOpen:e,title:(0,N.Tl)("Bulk Add Codex Accounts"),onClose:x,children:(0,i.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,i.jsx)("p",{className:"text-xs text-text-muted",children:(0,N.Tl)("Paste an array of codex account JSON objects. Each must include accessToken (and ideally refreshToken, idToken).")}),(0,i.jsx)("textarea",{className:"w-full rounded border border-accent/30 bg-sidebar p-2 text-sm font-mono resize-y min-h-[240px] focus:outline-none focus:ring-1 focus:ring-primary",placeholder:H,value:l,onChange:e=>r(e.target.value),disabled:n}),d&&(0,i.jsx)("p",{className:"text-xs text-red-500 break-words",children:d}),p&&(0,i.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,i.jsxs)("div",{className:`text-sm font-medium ${p.failed>0?"text-yellow-400":"text-green-400"}`,children:["✓ ",p.success," ",(0,N.Tl)("added"),p.failed>0?`, ✗ ${p.failed} ${(0,N.Tl)("failed")}`:""]}),f.length>0&&(0,i.jsx)("ul",{className:"rounded border border-accent/20 bg-sidebar/50 p-2 text-xs font-mono max-h-40 overflow-y-auto",children:f.map(e=>(0,i.jsxs)("li",{className:"text-red-400",children:["[",e.index,"] ",e.error]},e.index))})]}),(0,i.jsxs)("div",{className:"flex gap-2",children:[(0,i.jsx)(c.$n,{onClick:h,fullWidth:!0,disabled:n||!l.trim(),children:n?(0,N.Tl)("Importing..."):(0,N.Tl)("Import All")}),(0,i.jsx)(c.$n,{onClick:x,variant:"ghost",fullWidth:!0,disabled:n,children:(0,N.Tl)("Close")})]})]})})}B.propTypes={isOpen:$().bool.isRequired,onClose:$().func.isRequired,onSuccess:$().func};let W={claude:"claudeAutoPing",codex:"codexAutoPing"},G=[{value:"auto",label:"Retry: Auto"},{value:"15",label:"Retry: 15s"},{value:"30",label:"Retry: 30s"},{value:"60",label:"Retry: 1m"},{value:"120",label:"Retry: 2m"},{value:"300",label:"Retry: 5m"},{value:"600",label:"Retry: 10m"},{value:"1800",label:"Retry: 30m"},{value:"3600",label:"Retry: 1h"}];function V(){let e,t=(0,l.useParams)(),a=(0,l.useRouter)(),r=t.id,{getCaps:u}=(0,k.y)(),[x,h]=(0,s.useState)([]),[f,g]=(0,s.useState)(1),[y,b]=(0,s.useState)(10),[v,C]=(0,s.useState)(!0),[T,$]=(0,s.useState)(null),[I,E]=(0,s.useState)([]),[R,D]=(0,s.useState)(!1),[_,q]=(0,s.useState)(!1),[M,K]=(0,s.useState)(!1),[L,H]=(0,s.useState)(""),[V,Q]=(0,s.useState)(!1),[Z,Y]=(0,s.useState)(!1),[X,ee]=(0,s.useState)(!1),[et,ea]=(0,s.useState)(!1),[ei,es]=(0,s.useState)(null),[el,er]=(0,s.useState)({}),[en,eo]=(0,s.useState)([]),[ed,ec]=(0,s.useState)(!1),[em,ep]=(0,s.useState)({}),[eu,ex]=(0,s.useState)(""),[eh,ef]=(0,s.useState)(()=>new Set),[eg,ey]=(0,s.useState)(!1),[eb,ev]=(0,s.useState)([]),[ej,ew]=(0,s.useState)("__none__"),[ek,eN]=(0,s.useState)(!1),[eC,eS]=(0,s.useState)(null),[eA,eT]=(0,s.useState)(""),[e$,eP]=(0,s.useState)("auto"),[eI,eO]=(0,s.useState)("auto"),[eE,eR]=(0,s.useState)(""),[eD,e_]=(0,s.useState)({enabled:!1,connections:{}}),[eU,eq]=(0,s.useState)([]),[ez,eM]=(0,s.useState)([]),[eK,eL]=(0,s.useState)([]),[eF,eJ]=(0,s.useState)([]),[eH,eB]=(0,s.useState)(null),[eW,eG]=(0,s.useState)(!1),[eV,eQ]=(0,s.useState)(!1),[eZ,eY]=(0,s.useState)(!1),[eX,e0]=(0,s.useState)(null),[e1,e2]=(0,s.useState)({}),[e5,e3]=(0,s.useState)(null),e4=(0,s.useRef)(!1),[e6,e8]=(0,s.useState)(!1),{copied:e7,copy:e9}=(0,w.C)(),te="ag_risk_confirmed",tt=()=>{D(!0)},ta=()=>{"antigravity"===r&&"true"!==window.localStorage.getItem(te)?eG(!0):tn?tt():(H(""),K(!0))},ti=()=>{H(""),K(!0)},ts=()=>{tn?ta():ti()},tl=T?{id:T.id,name:T.name||("anthropic-compatible"===T.type?"Anthropic Compatible":"OpenAI Compatible"),color:"anthropic-compatible"===T.type?"#D97757":"#10A37F",textIcon:"anthropic-compatible"===T.type?"AC":"OC",apiType:T.apiType,baseUrl:T.baseUrl,type:T.type}:m.zN[r]||m.fg[r]||m.IS[r]||m.nJ[r]||m.br[r],tr=tl?.authModes||[],tn=!!m.zN[r]||!!m.IS[r]||tr.includes("oauth"),to=!!m.fg[r]||tr.includes("apikey"),td=!!m.IS[r]?.noAuth,tc=(0,p.KC)(r),tm="cursor"===r&&ez.length>0?ez:tc,tp=(0,m.wG)(r),tu=(0,m.mq)(r),tx=(0,m.gb)(r),th=tu||tx,tf=!th&&tn&&to,tg="xai"===r?"Grok Build OAuth":"grok-cli"===r?"Grok CLI Device Login":"kimi"===r?"Kimi Coding OAuth":"OAuth",ty="xai"===r?"xAI API Key":"kimi"===r?"Kimi API Key":"API Key",tb=e=>{if(!e$||"auto"===e$)return null;let t=j(r,e);return t&&t.includes(e$)?e$:null},tv=th?r:tp,tj=(()=>{let e=new Set,t=new Set,a=a=>{if(!a||t.has(a))return;t.add(a);let i=j(r,a);i&&i.forEach(t=>{"none"!==t&&e.add(t)})};for(let e of tm)a(e.id);for(let e of eK)a(e.id);for(let e of en)e.providerAlias===tv&&"llm"===(e.kind||e.type||"llm")&&a(e.id);return e.size?["auto",...e]:null})(),tw=th?T?.prefix||r:tp,tk=(0,s.useCallback)(async()=>{try{let e=await fetch(`/api/models/disabled?providerAlias=${encodeURIComponent(tv)}`,{cache:"no-store"}),t=await e.json();e.ok&&eJ(t.ids||[])}catch(e){console.log("Error fetching disabled models:",e)}},[tv]),tN=async e=>{try{(await fetch("/api/models/disabled",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerAlias:tv,ids:[e]})})).ok&&await tk()}catch(e){console.log("Error disabling model:",e)}},tC=async e=>{try{(await fetch(`/api/models/disabled?providerAlias=${encodeURIComponent(tv)}&id=${encodeURIComponent(e)}`,{method:"DELETE"})).ok&&await tk()}catch(e){console.log("Error enabling model:",e)}},tS=async e=>{e.length&&eB({title:"Disable All Models",message:`Disable all ${e.length} model(s)?`,onConfirm:async()=>{eB(null);try{(await fetch("/api/models/disabled",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerAlias:tv,ids:e})})).ok&&await tk()}catch(e){console.log("Error disabling all models:",e)}}})},tA=async()=>{try{(await fetch(`/api/models/disabled?providerAlias=${encodeURIComponent(tv)}`,{method:"DELETE"})).ok&&await tk()}catch(e){console.log("Error enabling all models:",e)}},tT=(0,s.useCallback)(async()=>{try{let e=await fetch("/api/models/alias"),t=await e.json();e.ok&&er(t.aliases||{})}catch(e){console.log("Error fetching aliases:",e)}},[]),t$=(0,s.useCallback)(async()=>{try{let e=await fetch("/api/models/custom",{cache:"no-store"}),t=await e.json();e.ok&&eo(t.models||[])}catch(e){console.log("Error fetching custom models:",e)}},[]);(0,s.useEffect)(()=>{"kilocode"===r&&fetch("/api/providers/kilo/free-models").then(e=>e.json()).then(e=>{e.models?.length&&eL(e.models)}).catch(()=>{})},[r]);let tP=(0,s.useCallback)(async()=>{try{let[e,t,a,i]=await Promise.all([fetch(`/api/providers?provider=${encodeURIComponent(r)}`,{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"})]),s=await e.json(),l=await t.json(),n=await a.json(),o=i.ok?await i.json():{};e.ok&&h(s.connections||[]),a.ok&&E(n.proxyPools||[]);let d=(o.providerStrategies||{})[r]||{};eS(d.fallbackStrategy||null),eT(null!=d.stickyRoundRobinLimit?String(d.stickyRoundRobinLimit):"1");let c=(o.providerThinking||{})[r]||{};eP(c.mode||"auto");let m=(o.retryDelayByProvider||{})[r];eO(null!=m&&"auto"!==m?String(m):"auto");let p=(o.rpmByProvider||{})[r];eR(null!=p?String(p):"");let u=W[r],x=u&&o[u]||{};if(e_({enabled:!0===x.enabled,connections:x.connections||{}}),t.ok){let e=(l.nodes||[]).find(e=>e.id===r)||null;if(!e&&th)for(let t=0;t<3;t+=1){await new Promise(e=>setTimeout(e,150));let t=await fetch("/api/provider-nodes",{cache:"no-store"});if(t.ok&&(e=((await t.json()).nodes||[]).find(e=>e.id===r)||null))break}$(e)}}catch(e){console.log("Error fetching connections:",e)}finally{C(!1)}},[r,th]),tI=async e=>{try{let t=await fetch(`/api/provider-nodes/${r}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),a=await t.json();t.ok&&($(a.node),await tP(),ee(!1))}catch(e){console.log("Error updating provider node:",e)}},tO=async(e,t)=>{try{let a=await fetch("/api/settings",{cache:"no-store"}),i=(a.ok?await a.json():{}).providerStrategies||{},s={};e&&(s.fallbackStrategy=e),"round-robin"===e&&""!==t&&(s.stickyRoundRobinLimit=Number(t)||3);let l={...i};0===Object.keys(s).length?delete l[r]:l[r]=s,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)}},tE=async e=>{try{let t=await fetch("/api/settings",{cache:"no-store"}),a={...(t.ok?await t.json():{}).providerThinking||{}};e&&"auto"!==e?a[r]={mode:e}:delete a[r],await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerThinking:a})})}catch(e){console.log("Error saving thinking config:",e)}},tR=async e=>{try{let t=await fetch("/api/settings",{cache:"no-store"}),a={...(t.ok?await t.json():{}).retryDelayByProvider||{}};e&&"auto"!==e?a[r]=Number(e):delete a[r],await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({retryDelayByProvider:a})})}catch(e){console.log("Error saving retry delay:",e)}},tD=async e=>{try{let t=await fetch("/api/settings",{cache:"no-store"}),a={...(t.ok?await t.json():{}).rpmByProvider||{}},i=String(e??"").trim();""===i?delete a[r]:a[r]=Math.max(0,Number(i)||0),await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({rpmByProvider:a})})}catch(e){console.log("Error saving RPM limit:",e)}},t_=async e=>{let t=W[r];if(t){e_(e);try{await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({[t]:e})})}catch(e){console.log("Error saving auto-ping config:",e)}}};(0,s.useEffect)(()=>{tP(),tT(),t$(),tk()},[tP,tT,t$,tk]),(0,s.useEffect)(()=>{if("cursor"!==r)return void eM([]);let e=x.find(e=>!1!==e.isActive);if(!e?.id)return void eM([]);let t=!1;return fetch(`/api/providers/${e.id}/models`,{cache:"no-store"}).then(async e=>({ok:e.ok,data:await e.json()})).then(({ok:e,data:a})=>{!t&&e&&Array.isArray(a.models)&&a.models.length>0&&eM(a.models)}).catch(()=>{}),()=>{t=!0}},[r,x]),(0,s.useEffect)(()=>{let e=(m.zN[r]||m.fg[r]||m.IS[r]||m.nJ[r])?.modelsFetcher;e&&S(e).then(eq)},[r]);let tU=async(e,t,a=tp)=>{let i=`${a}/${e}`;try{let e=await fetch("/api/models/alias",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:i,alias:t})});if(e.ok)await tT();else{let t=await e.json();alert(t.error||"Failed to set alias")}}catch(e){console.log("Error setting alias:",e)}},tq=async e=>{try{(await fetch(`/api/models/alias?alias=${encodeURIComponent(e)}`,{method:"DELETE"})).ok&&await tT()}catch(e){console.log("Error deleting alias:",e)}},tz=async(e,t="llm",a=tv)=>{try{let i=await fetch("/api/models/custom",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerAlias:a,id:e,type:t})});if(i.ok)await t$(),window.dispatchEvent(new CustomEvent("customModelChanged"));else{let e=await i.json();alert(e.error||"Failed to add custom model")}}catch(e){console.log("Error adding custom model:",e)}},tM=async(e,t="llm",a=tv)=>{try{let i=new URLSearchParams({providerAlias:a,id:e,type:t});(await fetch(`/api/models/custom?${i}`,{method:"DELETE"})).ok&&(await t$(),window.dispatchEvent(new CustomEvent("customModelChanged")))}catch(e){console.log("Error deleting custom model:",e)}},tK=async()=>{if(e6)return;let e=x.find(e=>!1!==e.isActive);if(!e)return void alert((0,N.Tl)("Please add an active Qoder connection first"));e8(!0);try{let t=await fetch(`/api/providers/${e.id}/models`),a=await t.json();if(!t.ok)return void alert(a.error||(0,N.Tl)("Failed to fetch models"));let i=a.models||[];if(0===i.length)return void alert((0,N.Tl)("No models returned"));let s=0;for(let e of i){let t=e.id||e.name;if(!t)continue;let a=t.replace(/^qoder\//,"");en.some(e=>e.providerAlias===tv&&e.id===a&&"llm"===(e.kind||e.type||"llm"))||Object.values(el).includes(`${tv}/${a}`)||(await tz(a,"llm",tv),s+=1)}0===s?alert((0,N.Tl)("All models already exist, no new models added")):alert((0,N.Tl)("Successfully added")+` ${s} `+(0,N.Tl)("models"))}catch(e){console.log("Error importing Qoder models:",e),alert((0,N.Tl)("Error fetching models")+": "+e.message)}finally{e8(!1)}},tL=async()=>{if(eV||0===x.length)return;let e=Object.fromEntries(x.map(e=>[e.id,{state:"queued",error:null}]));e4.current=!1,eQ(!0),eY(!1),e0(null),e2(e),e3({total:x.length,completed:0,passed:0,failed:0,stopped:!1});let t=0,a=0;try{for(let e=0;e<x.length;e+=1){if(e4.current){e3({total:x.length,completed:e,passed:t,failed:a,stopped:!0});break}let i=x[e];e0(i.id),e2(e=>({...e,[i.id]:{state:"testing",error:null}}));try{let e=await fetch(`/api/providers/${i.id}/test`,{method:"POST"}),s=await e.json(),l=!!s.valid;l?t+=1:a+=1,e2(e=>({...e,[i.id]:{state:l?"success":"failed",error:l?null:s.error||null}}))}catch(e){a+=1,e2(t=>({...t,[i.id]:{state:"failed",error:e.message||"Test failed"}}))}e3({total:x.length,completed:e+1,passed:t,failed:a,stopped:!1}),e<x.length-1&&await new Promise(e=>setTimeout(e,1e3))}}finally{e0(null),eQ(!1),eY(!1),e4.current=!1}},tF=async e=>{eB({title:"Delete Connection",message:"Delete this connection?",onConfirm:async()=>{eB(null);try{(await fetch(`/api/providers/${e}`,{method:"DELETE"})).ok&&h(t=>t.filter(t=>t.id!==e))}catch(e){console.log("Error deleting connection:",e)}}})},tJ=()=>{tP(),D(!1)},tH=async e=>{H("");try{let t=await fetch("/api/providers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:r,...e})}),a=null;try{a=await t.json()}catch{a=null}if(t.ok){await tP(),K(!1);return}H(a?.error||"Failed to save connection")}catch(e){console.log("Error saving connection:",e),H("Failed to save connection")}},tB=async e=>{try{(await fetch(`/api/providers/${ei.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})).ok&&(await tP(),Y(!1))}catch(e){console.log("Error updating connection:",e)}},tW=async(e,t)=>{try{(await fetch(`/api/providers/${e}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({isActive:t})})).ok&&h(a=>a.map(a=>a.id===e?{...a,isActive:t}:a))}catch(e){console.log("Error updating connection status:",e)}},tG=async(e,t)=>{let a=[...x];[a[e],a[t]]=[a[t],a[e]],h(a);try{await Promise.all([fetch(`/api/providers/${a[e].id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({priority:e})}),fetch(`/api/providers/${a[t].id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({priority:t})})])}catch(e){console.log("Error swapping priority:",e),await tP()}},tV=x.filter(e=>eb.includes(e.id));(0,s.useEffect)(()=>{ev(e=>e.filter(e=>x.some(t=>t.id===e)))},[x]),(()=>{if(0===tV.length)return;let e=new Set(tV.map(e=>e.providerSpecificData?.proxyPoolId||"__none__"));if(1===e.size){let t=[...e][0];if("__none__"===t)return;let a=I.find(e=>e.id===t);return a?.name}})();let tQ=()=>{ek||ea(!1)},tZ=async e=>{eN(!0);try{let t=0;for(let{connectionId:a,proxyPoolId:i}of e)try{(await fetch(`/api/providers/${a}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({proxyPoolId:i})})).ok||(t+=1)}catch(e){console.log("Error applying proxy for",a,e),t+=1}t>0&&alert(`Updated with ${t} failed request(s).`),await tP(),ea(!1)}finally{eN(!1)}},tY=e=>tZ(x.map(t=>({connectionId:t.id,proxyPoolId:e}))),{currentPage:tX,items:t0,start:t1}=function(e=[],t=1,a=10){let i=Array.isArray(e)?e:[],s=Number.isFinite(a)&&a>=1?Math.floor(a):10,l=i.length,r=Math.max(1,Math.ceil(l/s)),n=Math.floor(Number(t)),o=Math.min(Number.isFinite(n)&&n>0?n:1,r),d=(o-1)*s,c=i.slice(d,d+s);return{currentPage:o,totalPages:r,totalItems:l,start:d,items:c,pageSize:s}}(x,f,y),t2=new Set(t0.map(e=>e.id)),t5=t0.length>0&&t0.every(e=>eb.includes(e.id)),t3=(0,i.jsxs)("div",{className:"flex min-w-0 flex-col divide-y divide-black/[0.03] dark:divide-white/[0.03]",children:[t0.map((e,t)=>{let a,s=t1+t;return(0,i.jsxs)("div",{className:"flex min-w-0 items-stretch",children:[(0,i.jsx)("div",{className:"flex shrink-0 items-center pl-1 sm:pl-2",children:(0,i.jsx)("input",{type:"checkbox",checked:(a=e.id,eb.includes(a)),onChange:()=>{var t;return t=e.id,void ev(e=>e.includes(t)?e.filter(e=>e!==t):[...e,t])},className:"h-4 w-4 rounded border-gray-300 text-primary focus:ring-primary"})}),(0,i.jsx)("div",{className:"flex-1 min-w-0",children:(0,i.jsx)(U,{connection:e,proxyPools:I,isOAuth:tn,isFirst:0===s,isLast:s===x.length-1,onMoveUp:()=>tG(s,s-1),onMoveDown:()=>tG(s,s+1),onToggleActive:t=>tW(e.id,t),autoPing:W[r]&&"oauth"===e.authType?{on:!0===eD.connections[e.id],onToggle:t=>{var a;return a=e.id,void t_({...eD,connections:{...eD.connections,[a]:t}})},provider:r}:null,onUpdateProxy:async t=>{try{(await fetch(`/api/providers/${e.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({proxyPoolId:t||null})})).ok&&h(a=>a.map(a=>a.id===e.id?{...a,providerSpecificData:{...a.providerSpecificData,proxyPoolId:t||null}}:a))}catch(e){console.log("Error updating proxy:",e)}},onEdit:()=>{es(e),Y(!0)},onReconnect:()=>{"iflow"===r?q(!0):D(!0)},onDelete:()=>tF(e.id),oneByOneStatus:e1[e.id]||null})})]},e.id)}),x.length>10&&(0,i.jsx)(Pagination,{currentPage:tX,pageSize:y,totalItems:x.length,onPageChange:g,onPageSizeChange:e=>{b(e),g(1)},allowCustomPageSize:!0,maxPageSize:200})]}),t4=I.filter(e=>!0===e.isActive),t6=(0,i.jsx)(c.aF,{isOpen:et,onClose:tQ,title:`Apply Proxy (${x.length} connections)`,children:(0,i.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,i.jsxs)("div",{className:"flex flex-col",children:[(0,i.jsxs)("button",{onClick:()=>{let e=I.filter(e=>!0===e.isActive);return 0===e.length?void alert("No active proxy pools available."):tZ(x.map((t,a)=>({connectionId:t.id,proxyPoolId:e[a%e.length].id})))},disabled:ek||0===t4.length,className:"flex items-center gap-2 rounded-lg px-3 py-2 text-left transition-colors hover:bg-black/[0.04] dark:hover:bg-white/[0.04] disabled:cursor-not-allowed disabled:opacity-50",children:[(0,i.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[18px]",children:"sync_alt"}),(0,i.jsx)("span",{className:"text-sm text-text-main",children:"One-to-one (rotate)"})]}),(0,i.jsxs)("button",{onClick:()=>tY(null),disabled:ek,className:"flex items-center gap-2 rounded-lg px-3 py-2 text-left transition-colors hover:bg-black/[0.04] dark:hover:bg-white/[0.04] disabled:cursor-not-allowed disabled:opacity-50",children:[(0,i.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[18px]",children:"link_off"}),(0,i.jsx)("span",{className:"text-sm text-text-main",children:"None (unbind all)"})]}),I.map(e=>(0,i.jsxs)("button",{onClick:()=>tY(e.id),disabled:ek||!0!==e.isActive,className:"flex items-center gap-2 rounded-lg px-3 py-2 text-left transition-colors hover:bg-black/[0.04] dark:hover:bg-white/[0.04] disabled:cursor-not-allowed disabled:opacity-50",children:[(0,i.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[18px]",children:"lan"}),(0,i.jsx)("span",{className:"truncate text-sm text-text-main",children:e.name}),!0!==e.isActive&&(0,i.jsx)("span",{className:"text-[10px] text-text-muted",children:"(inactive)"})]},e.id))]}),ek&&(0,i.jsx)("p",{className:"text-xs text-text-muted",children:"Applying..."}),(0,i.jsx)(c.$n,{onClick:tQ,variant:"ghost",fullWidth:!0,disabled:ek,children:"Cancel"})]})}),t8=async e=>{if(!eh.has(e)){ef(t=>new Set(t).add(e));try{let t=await fetch("/api/models/test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:`${tv}/${e}`})}),a=await t.json();ep(t=>({...t,[e]:a.ok?"ok":"error"})),ex(a.ok?"":a.error||"Model not reachable")}catch{ep(t=>({...t,[e]:"error"})),ex("Network error")}finally{ef(t=>{let a=new Set(t);return a.delete(e),a})}}};if(v)return(0,i.jsxs)("div",{className:"flex flex-col gap-8",children:[(0,i.jsx)(c.Qv,{}),(0,i.jsx)(c.Qv,{})]});if(!tl)return(0,i.jsxs)("div",{className:"text-center py-20",children:[(0,i.jsx)("p",{className:"text-text-muted",children:"Provider not found"}),(0,i.jsx)(n(),{href:"/dashboard/providers",className:"text-primary mt-4 inline-block",children:"Back to Providers"})]});let t7=()=>tu&&tl.apiType?"responses"===tl.apiType?"/providers/oai-r.png":"/providers/oai-cc.png":tx?"/providers/anthropic-m.png":(0,d.HY)(tl.id);return(0,i.jsxs)("div",{className:"flex min-w-0 flex-col gap-6 px-1 sm:gap-8 sm:px-0",children:[(0,i.jsxs)("div",{className:"min-w-0",children:[(0,i.jsxs)(n(),{href:"/dashboard/providers",className:"inline-flex items-center gap-1 text-sm text-text-muted hover:text-primary transition-colors mb-4",children:[(0,i.jsx)("span",{className:"material-symbols-outlined text-lg",children:"arrow_back"}),"Back to Providers"]}),(0,i.jsxs)("div",{className:"flex min-w-0 items-center gap-3 sm:gap-4",children:[(0,i.jsx)("div",{className:"flex size-12 shrink-0 items-center justify-center rounded-lg",style:{backgroundColor:`${tl.color}15`},children:ed||!t7()?(0,i.jsx)("span",{className:"text-sm font-bold",style:{color:tl.color},children:tl.textIcon||tl.id.slice(0,2).toUpperCase()}):(0,i.jsx)(o.default,{src:t7(),alt:tl.name,width:48,height:48,className:"max-h-12 max-w-12 rounded-lg object-contain",sizes:"48px",onError:()=>{(0,d.Kw)(tl.id),ec(!0)},loading:"lazy",decoding:"async"})}),(0,i.jsxs)("div",{className:"min-w-0",children:[(0,i.jsxs)("div",{className:"flex items-center gap-3 flex-wrap",children:[(0,i.jsx)("h1",{className:"truncate text-2xl font-semibold tracking-tight sm:text-3xl",children:tl.name}),(tl.notice?.apiKeyUrl||tl.notice?.signupUrl||tl.website)&&(0,i.jsxs)("a",{href:tl.notice?.apiKeyUrl||tl.notice?.signupUrl||tl.website,target:"_blank",rel:"noopener noreferrer",className:"text-xs text-primary hover:underline inline-flex items-center gap-1",children:[(0,i.jsx)("span",{className:"material-symbols-outlined text-sm",children:"open_in_new"}),tl.notice?.apiKeyUrl?"Get API Key":"Sign up / Learn more"]})]}),(0,i.jsxs)("p",{className:"text-text-muted",children:[x.length," connection",1===x.length?"":"s"]})]}),(0,i.jsxs)("div",{className:"ml-auto flex shrink-0 items-center gap-2",children:[(0,i.jsx)("span",{className:"hidden text-xs text-text-muted sm:inline",children:"RPM / account"}),(0,i.jsx)("input",{type:"number",min:"0",value:eE,placeholder:String(m.W[r]||0),onChange:e=>eR(e.target.value),onBlur:e=>tD(e.target.value),title:"Max requests per minute per account. Accounts over the cap are skipped before a request is sent, so the provider never sees a 429. Blank = provider default, 0 = unlimited.",className:"w-16 rounded-md border border-border bg-background px-2 py-1 text-xs focus:border-primary focus:outline-none"}),(0,i.jsx)("span",{className:"hidden text-xs text-text-muted sm:inline",children:"Retry delay"}),(0,i.jsx)("select",{value:eI,onChange:e=>{var t;eO(t=e.target.value),tR(t)},title:"Cooldown after a rate-limit/error when the provider reports no reset time of its own. Auto = honor the provider's reported delay, else built-in backoff.",className:"rounded-md border border-border bg-background px-2 py-1 text-xs focus:border-primary focus:outline-none",children:G.map(e=>(0,i.jsx)("option",{value:e.value,children:e.label},e.value))})]})]})]}),tl.deprecated&&(0,i.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 rounded-lg bg-yellow-500/10 border border-yellow-500/30",children:[(0,i.jsx)("span",{className:"material-symbols-outlined text-[16px] text-yellow-500 mt-0.5 shrink-0",children:"warning"}),(0,i.jsx)("p",{className:"text-xs text-red-600 dark:text-yellow-400 leading-relaxed",children:tl.deprecationNotice})]}),tl.notice?.text&&!tl.deprecated&&(0,i.jsxs)("div",{className:"flex flex-col gap-2 rounded-lg border border-blue-500/30 bg-blue-500/10 px-3 py-2 sm:flex-row sm:items-center",children:[(0,i.jsx)("span",{className:"material-symbols-outlined text-[16px] text-blue-500 shrink-0",children:"info"}),(0,i.jsx)("p",{className:"min-w-0 flex-1 text-xs leading-relaxed text-blue-600 dark:text-blue-400",children:tl.notice.text}),tl.notice.apiKeyUrl&&(0,i.jsx)("a",{href:tl.notice.apiKeyUrl,target:"_blank",rel:"noopener noreferrer",className:"inline-flex justify-center rounded bg-blue-500 px-2 py-1 text-xs font-medium text-white transition-colors hover:bg-blue-600 sm:py-0.5",children:"Get API Key →"})]}),th&&T&&(0,i.jsx)(c.Zp,{children:(0,i.jsxs)("div",{className:"mb-4 flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[(0,i.jsxs)("div",{className:"min-w-0",children:[(0,i.jsx)("h2",{className:"text-lg font-semibold",children:tx?"Anthropic Compatible Details":"OpenAI Compatible Details"}),(0,i.jsxs)("p",{className:"break-all text-sm text-text-muted",children:[tx?"Messages API":"responses"===T.apiType?"Responses API":"Chat Completions"," \xb7 ",(T.baseUrl||"").replace(/\/$/,""),"/",tx?"messages":"responses"===T.apiType?"responses":"chat/completions"]})]}),(0,i.jsxs)("div",{className:"grid grid-cols-1 gap-2 sm:flex sm:items-center",children:[(0,i.jsx)(c.$n,{size:"sm",icon:"add",onClick:()=>{H(""),K(!0)},className:"w-full sm:w-auto",children:"Add API Key"}),(0,i.jsx)(c.$n,{size:"sm",variant:"secondary",icon:"edit",onClick:()=>ee(!0),className:"w-full sm:w-auto",children:"Edit"}),(0,i.jsx)(c.$n,{size:"sm",variant:"secondary",icon:"delete",onClick:async()=>{eB({title:"Delete Compatible Node",message:`Delete this ${tx?"Anthropic":"OpenAI"} Compatible node?`,onConfirm:async()=>{eB(null);try{(await fetch(`/api/provider-nodes/${r}`,{method:"DELETE"})).ok&&a.push("/dashboard/providers")}catch(e){console.log("Error deleting provider node:",e)}}})},className:"w-full sm:w-auto",children:"Delete"})]})]})}),td?(0,i.jsx)(c.gw,{providerId:r}):(0,i.jsxs)(c.Zp,{children:[(0,i.jsxs)("div",{className:"mb-4 flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[(0,i.jsx)("h2",{className:"text-lg font-semibold",children:"Connections"}),(0,i.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:gap-4",children:[x.length>0&&I.length>0&&(0,i.jsx)(c.$n,{size:"sm",variant:"secondary",icon:"lan",onClick:()=>ea(!0),children:"Apply Proxy"}),x.length>0&&(0,i.jsxs)(i.Fragment,{children:[eb.length>0&&(0,i.jsxs)(c.$n,{size:"sm",variant:"danger",icon:"delete",onClick:()=>{let e=eb.length;0!==e&&eB({title:`Delete ${e} Connection${e>1?"s":""}`,message:`Delete ${e} connection${e>1?"s":""}? This cannot be undone.`,onConfirm:async()=>{eB(null);let e=0,t=[...eb];for(let a of t)try{(await fetch(`/api/providers/${a}`,{method:"DELETE"})).ok||(e+=1)}catch(t){console.log("Error deleting connection:",t),e+=1}h(e=>e.filter(e=>!t.includes(e.id))),ev([]),e>0&&alert(`Deleted ${t.length-e} connection(s), ${e} failed.`)}})},children:["Delete Selected (",eb.length,")"]}),(0,i.jsx)(c.$n,{size:"sm",variant:"secondary",icon:"sync",onClick:tL,disabled:eV,children:eV?"Testing Connection One-by-One...":"Test Connection One-by-One"}),eV&&(0,i.jsx)(c.$n,{size:"sm",variant:"ghost",icon:"stop",onClick:()=>{eV&&(e4.current=!0,eY(!0))},disabled:eZ,children:eZ?"Stopping...":"Stop"})]}),(0,i.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,i.jsx)("span",{className:"text-xs text-text-muted font-medium",children:"Round Robin"}),(0,i.jsx)(c.lM,{checked:"round-robin"===eC,onChange:e=>{let t=e?"round-robin":null,a=e?eA||"1":eA;e&&!eA&&eT("1"),eS(t),tO(t,a)}}),"round-robin"===eC&&(0,i.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,i.jsx)("span",{className:"text-xs text-text-muted",children:"Sticky:"}),(0,i.jsx)("input",{type:"number",min:1,value:eA,onChange:e=>{var t;eT(t=e.target.value),tO("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===x.length?(0,i.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[(0,i.jsxs)("div",{className:"flex items-center gap-3",children:[(0,i.jsx)("div",{className:"inline-flex items-center justify-center w-9 h-9 rounded-full bg-primary/10 text-primary shrink-0",children:(0,i.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:tn?"lock":"key"})}),(0,i.jsxs)("div",{className:"min-w-0",children:[(0,i.jsx)("p",{className:"text-sm text-text-muted",children:"No connections yet"}),tf&&(0,i.jsxs)("p",{className:"text-xs text-text-muted",children:["Choose ",tg," or ",ty,"."]})]})]}),(0,i.jsx)("div",{className:"flex gap-2",children:tf?(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(c.$n,{size:"sm",icon:"lock",variant:"secondary",onClick:ta,children:tg}),(0,i.jsx)(c.$n,{size:"sm",icon:"key",onClick:ti,children:ty})]}):(0,i.jsxs)(i.Fragment,{children:[!th&&"iflow"===r&&(0,i.jsx)(c.$n,{size:"sm",icon:"cookie",variant:"secondary",onClick:()=>q(!0),children:"Cookie"}),"codex"===r&&(0,i.jsx)(c.$n,{size:"sm",icon:"playlist_add",variant:"secondary",onClick:()=>Q(!0),children:(0,N.Tl)("Bulk Add")}),(0,i.jsx)(c.$n,{size:"sm",icon:"add",onClick:ts,children:th?"Add API Key":"iflow"===r?"OAuth":"Add Connection"})]})})]}):(0,i.jsxs)(i.Fragment,{children:[e5&&(0,i.jsx)("div",{className:"mb-4 rounded-lg border border-black/10 bg-black/[0.02] px-3 py-2 text-xs text-text-muted dark:border-white/10 dark:bg-white/[0.03]",children:(0,i.jsxs)("div",{className:"flex flex-wrap items-center gap-3",children:[(0,i.jsxs)("span",{children:["Total: ",e5.total]}),(0,i.jsxs)("span",{children:["Completed: ",e5.completed]}),(0,i.jsxs)("span",{children:["Passed: ",e5.passed]}),(0,i.jsxs)("span",{children:["Failed: ",e5.failed]}),e5.stopped&&(0,i.jsx)("span",{className:"text-amber-600 dark:text-amber-400",children:"Stopped"}),eV&&eX&&(0,i.jsxs)("span",{children:["Running: ",x.find(e=>e.id===eX)?.name||eX]})]})}),x.length>0&&(0,i.jsx)("div",{className:"mb-3 flex items-center gap-2 border-b border-black/[0.03] pb-2 dark:border-white/[0.03]",children:(0,i.jsxs)("label",{className:"flex cursor-pointer items-center gap-1.5 text-xs text-text-muted hover:text-primary",children:[(0,i.jsx)("input",{type:"checkbox",checked:t5,onChange:()=>{t5?ev(e=>e.filter(e=>!t2.has(e))):ev(e=>{let t=new Set(e);for(let e of t2)t.add(e);return[...t]})},className:"h-3.5 w-3.5 rounded border-gray-300 text-primary focus:ring-primary"}),"Select All"]})}),t3,!th&&(0,i.jsxs)("div",{className:"mt-4 grid grid-cols-1 gap-2 sm:flex",children:["iflow"===r&&(0,i.jsx)(c.$n,{size:"sm",icon:"cookie",variant:"secondary",onClick:()=>q(!0),title:"Add connection using browser cookie",className:"w-full sm:w-auto",children:"Cookie"}),"codex"===r&&(0,i.jsx)(c.$n,{size:"sm",icon:"playlist_add",variant:"secondary",onClick:()=>Q(!0),title:(0,N.Tl)("Bulk import codex accounts from JSON"),className:"w-full sm:w-auto",children:(0,N.Tl)("Bulk Add")}),tf?(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(c.$n,{size:"sm",icon:"lock",variant:"secondary",onClick:ta,className:"w-full sm:w-auto",children:tg}),(0,i.jsx)(c.$n,{size:"sm",icon:"key",onClick:ti,className:"w-full sm:w-auto",children:ty})]}):(0,i.jsx)(c.$n,{size:"sm",icon:"add",onClick:ts,className:"w-full sm:w-auto",children:"Add"})]})]})]}),(0,i.jsxs)(c.Zp,{children:[(0,i.jsxs)("div",{className:"mb-4 flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between",children:[(0,i.jsxs)("div",{className:"flex items-center gap-3",children:[(0,i.jsx)("h2",{className:"text-lg font-semibold",children:"Available Models"}),tj&&(0,i.jsx)("select",{value:e$,onChange:e=>{var t;eP(t=e.target.value),tE(t)},title:"Appends (level) suffix to copied model names",className:"rounded-md border border-border bg-background px-2 py-1 text-xs focus:border-primary focus:outline-none",children:tj.map(e=>(0,i.jsx)("option",{value:e,children:`Thinking: ${e.charAt(0).toUpperCase()+e.slice(1)}`},e))})]}),!th&&(e=[...tm,...eK.filter(e=>!tm.some(t=>t.id===e.id))].filter(e=>{let t=(0,p.CP)(e);return!t||"llm"===t}).map(e=>e.id).filter(e=>!eF.includes(e)),(0,i.jsxs)("div",{className:"flex gap-2",children:[eF.length>0&&(0,i.jsx)(c.$n,{size:"sm",variant:"secondary",icon:"restart_alt",onClick:tA,children:"Active All"}),e.length>0&&(0,i.jsx)(c.$n,{size:"sm",variant:"secondary",icon:"block",onClick:()=>tS(e),children:"Disable All"})]}))]}),!!eu&&(0,i.jsx)("p",{className:"text-xs text-red-500 mb-3 break-words",children:eu}),(()=>{let e,t,a;if(th)return(0,i.jsx)(O,{providerStorageAlias:tv,providerDisplayAlias:tw,modelAliases:el,customModels:en,copied:e7,onCopy:e9,onSetAlias:tU,onDeleteAlias:tq,onAddCustomModel:e=>tz(e,"llm",tv),onDeleteCustomModel:e=>tM(e,"llm",tv),connections:x,isAnthropic:tx});let s=[...tm,...eK.filter(e=>!tm.some(t=>t.id===e.id))].filter(e=>{let t=(0,p.CP)(e);return!t||"llm"===t}),l=new Set(eF),n=s.filter(e=>!l.has(e.id)),o=s.filter(e=>l.has(e.id)),d=A({customModels:en,modelAliases:el,providerAlias:tv,builtInModels:tm,type:"llm"});return(0,i.jsxs)("div",{className:"flex flex-wrap gap-3",children:[d.map(e=>(0,i.jsx)(P,{model:{id:e.id,name:e.name},fullModel:`${tw}/${e.id}`,alias:e.alias,copied:e7,onCopy:e9,onSetAlias:()=>{},onDeleteAlias:()=>{"custom"===e.source?tM(e.id,"llm",tv):tq(e.alias)},testStatus:em[e.id],onTest:x.length>0||td?()=>t8(e.id):void 0,isTesting:eh.has(e.id),isCustom:!0,isFree:!1,caps:u(`${r}/${e.id}`),thinkingSuffix:tb(e.id)},`${e.source}-${e.fullModel}`)),n.map(e=>{let t=`${tv}/${e.id}`,a=`${r}/${e.id}`,s=Object.entries(el).find(([,e])=>e===t||e===a)?.[0];return(0,i.jsx)(P,{model:e,fullModel:`${tw}/${e.id}`,alias:s,copied:e7,onCopy:e9,onSetAlias:t=>tU(e.id,t,tv),onDeleteAlias:()=>tq(s),testStatus:em[e.id],onTest:x.length>0||td?()=>t8(e.id):void 0,isTesting:eh.has(e.id),isFree:e.isFree,onDisable:()=>tN(e.id),caps:u(`${r}/${e.id}`),thinkingSuffix:tb(e.id)},e.id)}),(0,i.jsxs)("button",{onClick:()=>ey(!0),className:"flex w-full items-center justify-center gap-1.5 rounded-lg border border-dashed border-primary/40 px-3 py-2 text-xs text-primary transition-colors hover:border-primary hover:bg-primary/5 sm:w-auto",children:[(0,i.jsx)("span",{className:"material-symbols-outlined text-sm",children:"add"}),"Add Model"]}),"qoder"===r&&x.some(e=>!1!==e.isActive)&&(0,i.jsxs)("button",{onClick:tK,disabled:e6,className:"flex w-full items-center justify-center gap-1.5 rounded-lg border border-dashed border-blue-500/40 px-3 py-2 text-xs text-blue-600 dark:text-blue-400 transition-colors hover:border-blue-500 hover:bg-blue-500/5 sm:w-auto disabled:opacity-50 disabled:cursor-not-allowed",children:[(0,i.jsx)("span",{className:"material-symbols-outlined text-sm",style:e6?{animation:"spin 1s linear infinite"}:void 0,children:e6?"progress_activity":"download"}),e6?(0,N.Tl)("Fetching..."):(0,N.Tl)("Fetch Qoder Models")]}),eU.length>0&&(e=new Set([...Object.values(el),...d.map(e=>e.fullModel)]),t=new Set(tm.map(e=>e.id)),0===(a=eU.filter(a=>!e.has(`${tv}/${a.id}`)&&!t.has(a.id))).length?null:(0,i.jsxs)("div",{className:"w-full mt-2",children:[(0,i.jsx)("p",{className:"text-xs text-text-muted mb-2",children:"Suggested free models (≥200k context):"}),(0,i.jsx)("div",{className:"flex flex-wrap gap-2",children:a.map(e=>(0,i.jsxs)("button",{onClick:async()=>{await tz(e.id,"llm",tv)},className:"flex items-center gap-1 px-2.5 py-1.5 rounded-lg border border-black/10 dark:border-white/10 text-xs text-text-muted hover:text-primary hover:border-primary/40 hover:bg-primary/5 transition-colors",title:`${e.name} \xb7 ${(e.contextLength/1e3).toFixed(0)}k ctx`,children:[(0,i.jsx)("span",{className:"material-symbols-outlined text-[13px]",children:"add"}),e.id.split("/").pop()]},e.id))})]})),o.length>0&&(0,i.jsxs)("div",{className:"w-full mt-2",children:[(0,i.jsxs)("p",{className:"text-xs text-text-muted mb-2",children:["Disabled models (",o.length,"):"]}),(0,i.jsx)("div",{className:"flex flex-wrap gap-2",children:o.map(e=>(0,i.jsxs)("button",{onClick:()=>tC(e.id),className:"flex items-center gap-1 px-2.5 py-1.5 rounded-lg border border-dashed border-black/10 dark:border-white/10 text-xs text-text-muted hover:text-primary hover:border-primary/40 hover:bg-primary/5 transition-colors",title:"Restore model",children:[(0,i.jsx)("span",{className:"material-symbols-outlined text-[13px]",children:"add"}),e.id]},e.id))})]})]})})()]}),t6,"kiro"===r?(0,i.jsx)(c.Mh,{isOpen:R,providerInfo:tl,onSuccess:tJ,onClose:()=>D(!1)}):"cursor"===r?(0,i.jsx)(c.G9,{isOpen:R,onSuccess:tJ,onClose:()=>D(!1)}):"gitlab"===r?(0,i.jsx)(c.vj,{isOpen:R,providerInfo:tl,onSuccess:tJ,onClose:()=>D(!1)}):(0,i.jsx)(c.LF,{isOpen:R,provider:r,providerInfo:tl,onSuccess:tJ,onClose:()=>D(!1)}),"iflow"===r&&(0,i.jsx)(c.vE,{isOpen:_,onSuccess:()=>{tP(),q(!1)},onClose:()=>q(!1)}),(0,i.jsx)(z,{isOpen:M,provider:r,providerName:tl.name,isCompatible:th,isAnthropic:tx,authType:tl?.authType,authHint:tl?.authHint,website:tl?.website,proxyPools:I,error:L,existingNames:x.map(e=>e.name).filter(Boolean),onSave:tH,onBulkDone:tP,onClose:()=>{H(""),K(!1)}}),(0,i.jsx)(c.wI,{isOpen:Z,connection:ei,proxyPools:I,onSave:tB,onClose:()=>Y(!1)}),th&&(0,i.jsx)(F,{isOpen:X,node:T,onSave:tI,onClose:()=>ee(!1),isAnthropic:tx}),!th&&(0,i.jsx)(J,{isOpen:eg,providerAlias:tv,providerDisplayAlias:tw,onSave:async e=>{await tz(e,"llm",tv),ey(!1)},onClose:()=>ey(!1)}),"codex"===r&&(0,i.jsx)(B,{isOpen:V,onClose:()=>Q(!1),onSuccess:tP}),(0,i.jsx)(c.uo,{isOpen:eW,onClose:()=>eG(!1),onConfirm:()=>{(window.localStorage.setItem(te,"true"),eG(!1),tn)?tt():ti()},title:"Risk Notice",message:tl?.deprecationNotice,confirmText:"I Understand, Continue",cancelText:"Cancel",variant:"danger"}),(0,i.jsx)(c.uo,{isOpen:!!eH,onClose:()=>eB(null),onConfirm:eH?.onConfirm,title:eH?.title||"Confirm",message:eH?.message,variant:"danger"})]})}},85295:(e,t,a)=>{Promise.resolve().then(a.bind(a,80035))}},e=>{e.O(0,[8010,5772,8105,1321,801,5497,8441,3794,7358],()=>e(e.s=85295)),_N_E=e.O()}]);
14
+ ]`;function B({isOpen:e,onClose:t,onSuccess:a}){let[l,r]=(0,s.useState)(""),[n,o]=(0,s.useState)(!1),[d,m]=(0,s.useState)(""),[p,u]=(0,s.useState)(null),x=()=>{n||(r(""),m(""),u(null),t())},h=async()=>{var e;let t;m(""),u(null);let i=l.trim();if(!i)return;try{t=JSON.parse(i)}catch(e){m(`${(0,N.Tl)("Invalid JSON")}: ${e.message}`);return}let s=Array.isArray(e=t)?e:e&&"object"==typeof e?Array.isArray(e.accounts)?e.accounts:[e]:null;if(!s||0===s.length)return void m((0,N.Tl)("No accounts found in input"));o(!0);try{let e=await fetch("/api/oauth/codex/bulk-import",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({accounts:s})}),t=await e.json();if(!e.ok)return void m(t?.error||`Request failed: ${e.status}`);u(t),t.success>0&&"function"==typeof a&&a()}catch(e){m(e.message||(0,N.Tl)("Request failed"))}finally{o(!1)}},f=p?.results?.filter(e=>!e.ok)||[];return(0,i.jsx)(c.aF,{isOpen:e,title:(0,N.Tl)("Bulk Add Codex Accounts"),onClose:x,children:(0,i.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,i.jsx)("p",{className:"text-xs text-text-muted",children:(0,N.Tl)("Paste an array of codex account JSON objects. Each must include accessToken (and ideally refreshToken, idToken).")}),(0,i.jsx)("textarea",{className:"w-full rounded border border-accent/30 bg-sidebar p-2 text-sm font-mono resize-y min-h-[240px] focus:outline-none focus:ring-1 focus:ring-primary",placeholder:H,value:l,onChange:e=>r(e.target.value),disabled:n}),d&&(0,i.jsx)("p",{className:"text-xs text-red-500 break-words",children:d}),p&&(0,i.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,i.jsxs)("div",{className:`text-sm font-medium ${p.failed>0?"text-yellow-400":"text-green-400"}`,children:["✓ ",p.success," ",(0,N.Tl)("added"),p.failed>0?`, ✗ ${p.failed} ${(0,N.Tl)("failed")}`:""]}),f.length>0&&(0,i.jsx)("ul",{className:"rounded border border-accent/20 bg-sidebar/50 p-2 text-xs font-mono max-h-40 overflow-y-auto",children:f.map(e=>(0,i.jsxs)("li",{className:"text-red-400",children:["[",e.index,"] ",e.error]},e.index))})]}),(0,i.jsxs)("div",{className:"flex gap-2",children:[(0,i.jsx)(c.$n,{onClick:h,fullWidth:!0,disabled:n||!l.trim(),children:n?(0,N.Tl)("Importing..."):(0,N.Tl)("Import All")}),(0,i.jsx)(c.$n,{onClick:x,variant:"ghost",fullWidth:!0,disabled:n,children:(0,N.Tl)("Close")})]})]})})}B.propTypes={isOpen:$().bool.isRequired,onClose:$().func.isRequired,onSuccess:$().func};let W={claude:"claudeAutoPing",codex:"codexAutoPing"},G=[{value:"auto",label:"Retry: Auto"},{value:"15",label:"Retry: 15s"},{value:"30",label:"Retry: 30s"},{value:"60",label:"Retry: 1m"},{value:"120",label:"Retry: 2m"},{value:"300",label:"Retry: 5m"},{value:"600",label:"Retry: 10m"},{value:"1800",label:"Retry: 30m"},{value:"3600",label:"Retry: 1h"}];function V(){let e,t=(0,l.useParams)(),a=(0,l.useRouter)(),r=t.id,{getCaps:u}=(0,k.y)(),[x,h]=(0,s.useState)([]),[f,g]=(0,s.useState)(1),[y,b]=(0,s.useState)(10),[v,C]=(0,s.useState)(!0),[T,$]=(0,s.useState)(null),[I,E]=(0,s.useState)([]),[R,D]=(0,s.useState)(!1),[_,q]=(0,s.useState)(!1),[M,K]=(0,s.useState)(!1),[L,H]=(0,s.useState)(""),[V,Q]=(0,s.useState)(!1),[Z,Y]=(0,s.useState)(!1),[X,ee]=(0,s.useState)(!1),[et,ea]=(0,s.useState)(!1),[ei,es]=(0,s.useState)(null),[el,er]=(0,s.useState)({}),[en,eo]=(0,s.useState)([]),[ed,ec]=(0,s.useState)(!1),[em,ep]=(0,s.useState)({}),[eu,ex]=(0,s.useState)(""),[eh,ef]=(0,s.useState)(()=>new Set),[eg,ey]=(0,s.useState)(!1),[eb,ev]=(0,s.useState)([]),[ej,ew]=(0,s.useState)("__none__"),[ek,eN]=(0,s.useState)(!1),[eC,eS]=(0,s.useState)(null),[eA,eT]=(0,s.useState)(""),[e$,eP]=(0,s.useState)("auto"),[eI,eO]=(0,s.useState)("auto"),[eE,eR]=(0,s.useState)(""),[eD,e_]=(0,s.useState)({enabled:!1,connections:{}}),[eU,eq]=(0,s.useState)([]),[ez,eM]=(0,s.useState)([]),[eK,eL]=(0,s.useState)([]),[eF,eJ]=(0,s.useState)([]),[eH,eB]=(0,s.useState)(null),[eW,eG]=(0,s.useState)(!1),[eV,eQ]=(0,s.useState)(!1),[eZ,eY]=(0,s.useState)(!1),[eX,e0]=(0,s.useState)(null),[e1,e2]=(0,s.useState)({}),[e5,e3]=(0,s.useState)(null),e4=(0,s.useRef)(!1),[e6,e8]=(0,s.useState)(!1),{copied:e7,copy:e9}=(0,w.C)(),te="ag_risk_confirmed",tt=()=>{D(!0)},ta=()=>{"antigravity"===r&&"true"!==window.localStorage.getItem(te)?eG(!0):tn?tt():(H(""),K(!0))},ti=()=>{H(""),K(!0)},ts=()=>{tn?ta():ti()},tl=T?{id:T.id,name:T.name||("anthropic-compatible"===T.type?"Anthropic Compatible":"OpenAI Compatible"),color:"anthropic-compatible"===T.type?"#D97757":"#10A37F",textIcon:"anthropic-compatible"===T.type?"AC":"OC",apiType:T.apiType,baseUrl:T.baseUrl,type:T.type}:m.zN[r]||m.fg[r]||m.IS[r]||m.nJ[r]||m.br[r],tr=tl?.authModes||[],tn=!!m.zN[r]||!!m.IS[r]||tr.includes("oauth"),to=!!m.fg[r]||tr.includes("apikey"),td=!!m.IS[r]?.noAuth,tc=(0,p.KC)(r),tm="cursor"===r&&ez.length>0?ez:tc,tp=(0,m.wG)(r),tu=(0,m.mq)(r),tx=(0,m.gb)(r),th=tu||tx,tf=!th&&tn&&to,tg="xai"===r?"Grok Build OAuth":"grok-cli"===r?"Grok CLI Device Login":"kimi"===r?"Kimi Coding OAuth":"OAuth",ty="xai"===r?"xAI API Key":"kimi"===r?"Kimi API Key":"API Key",tb=e=>{if(!e$||"auto"===e$)return null;let t=j(r,e);return t&&t.includes(e$)?e$:null},tv=th?r:tp,tj=(()=>{let e=new Set,t=new Set,a=a=>{if(!a||t.has(a))return;t.add(a);let i=j(r,a);i&&i.forEach(t=>{"none"!==t&&e.add(t)})};for(let e of tm)a(e.id);for(let e of eK)a(e.id);for(let e of en)e.providerAlias===tv&&"llm"===(e.kind||e.type||"llm")&&a(e.id);return e.size?["auto",...e]:null})(),tw=th?T?.prefix||r:tp,tk=(0,s.useCallback)(async()=>{try{let e=await fetch(`/api/models/disabled?providerAlias=${encodeURIComponent(tv)}`,{cache:"no-store"}),t=await e.json();e.ok&&eJ(t.ids||[])}catch(e){console.log("Error fetching disabled models:",e)}},[tv]),tN=async e=>{try{(await fetch("/api/models/disabled",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerAlias:tv,ids:[e]})})).ok&&await tk()}catch(e){console.log("Error disabling model:",e)}},tC=async e=>{try{(await fetch(`/api/models/disabled?providerAlias=${encodeURIComponent(tv)}&id=${encodeURIComponent(e)}`,{method:"DELETE"})).ok&&await tk()}catch(e){console.log("Error enabling model:",e)}},tS=async e=>{e.length&&eB({title:"Disable All Models",message:`Disable all ${e.length} model(s)?`,onConfirm:async()=>{eB(null);try{(await fetch("/api/models/disabled",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerAlias:tv,ids:e})})).ok&&await tk()}catch(e){console.log("Error disabling all models:",e)}}})},tA=async()=>{try{(await fetch(`/api/models/disabled?providerAlias=${encodeURIComponent(tv)}`,{method:"DELETE"})).ok&&await tk()}catch(e){console.log("Error enabling all models:",e)}},tT=(0,s.useCallback)(async()=>{try{let e=await fetch("/api/models/alias"),t=await e.json();e.ok&&er(t.aliases||{})}catch(e){console.log("Error fetching aliases:",e)}},[]),t$=(0,s.useCallback)(async()=>{try{let e=await fetch("/api/models/custom",{cache:"no-store"}),t=await e.json();e.ok&&eo(t.models||[])}catch(e){console.log("Error fetching custom models:",e)}},[]);(0,s.useEffect)(()=>{"kilocode"===r&&fetch("/api/providers/kilo/free-models").then(e=>e.json()).then(e=>{e.models?.length&&eL(e.models)}).catch(()=>{})},[r]);let tP=(0,s.useCallback)(async()=>{try{let[e,t,a,i]=await Promise.all([fetch(`/api/providers?provider=${encodeURIComponent(r)}`,{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"})]),s=await e.json(),l=await t.json(),n=await a.json(),o=i.ok?await i.json():{};e.ok&&h(s.connections||[]),a.ok&&E(n.proxyPools||[]);let d=(o.providerStrategies||{})[r]||{};eS(d.fallbackStrategy||null),eT(null!=d.stickyRoundRobinLimit?String(d.stickyRoundRobinLimit):"1");let c=(o.providerThinking||{})[r]||{};eP(c.mode||"auto");let m=(o.retryDelayByProvider||{})[r];eO(null!=m&&"auto"!==m?String(m):"auto");let p=(o.rpmByProvider||{})[r];eR(null!=p?String(p):"");let u=W[r],x=u&&o[u]||{};if(e_({enabled:!0===x.enabled,connections:x.connections||{}}),t.ok){let e=(l.nodes||[]).find(e=>e.id===r)||null;if(!e&&th)for(let t=0;t<3;t+=1){await new Promise(e=>setTimeout(e,150));let t=await fetch("/api/provider-nodes",{cache:"no-store"});if(t.ok&&(e=((await t.json()).nodes||[]).find(e=>e.id===r)||null))break}$(e)}}catch(e){console.log("Error fetching connections:",e)}finally{C(!1)}},[r,th]),tI=async e=>{try{let t=await fetch(`/api/provider-nodes/${r}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),a=await t.json();t.ok&&($(a.node),await tP(),ee(!1))}catch(e){console.log("Error updating provider node:",e)}},tO=async(e,t)=>{try{let a=await fetch("/api/settings",{cache:"no-store"}),i=(a.ok?await a.json():{}).providerStrategies||{},s={};e&&(s.fallbackStrategy=e),"round-robin"===e&&""!==t&&(s.stickyRoundRobinLimit=Number(t)||3);let l={...i};0===Object.keys(s).length?delete l[r]:l[r]=s,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)}},tE=async e=>{try{let t=await fetch("/api/settings",{cache:"no-store"}),a={...(t.ok?await t.json():{}).providerThinking||{}};e&&"auto"!==e?a[r]={mode:e}:delete a[r],await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerThinking:a})})}catch(e){console.log("Error saving thinking config:",e)}},tR=async e=>{try{let t=await fetch("/api/settings",{cache:"no-store"}),a={...(t.ok?await t.json():{}).retryDelayByProvider||{}};e&&"auto"!==e?a[r]=Number(e):delete a[r],await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({retryDelayByProvider:a})})}catch(e){console.log("Error saving retry delay:",e)}},tD=async e=>{try{let t=await fetch("/api/settings",{cache:"no-store"}),a={...(t.ok?await t.json():{}).rpmByProvider||{}},i=String(e??"").trim();""===i?delete a[r]:a[r]=Math.max(0,Number(i)||0),await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({rpmByProvider:a})})}catch(e){console.log("Error saving RPM limit:",e)}},t_=async e=>{let t=W[r];if(t){e_(e);try{await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({[t]:e})})}catch(e){console.log("Error saving auto-ping config:",e)}}};(0,s.useEffect)(()=>{tP(),tT(),t$(),tk()},[tP,tT,t$,tk]),(0,s.useEffect)(()=>{if("cursor"!==r)return void eM([]);let e=x.find(e=>!1!==e.isActive);if(!e?.id)return void eM([]);let t=!1;return fetch(`/api/providers/${e.id}/models`,{cache:"no-store"}).then(async e=>({ok:e.ok,data:await e.json()})).then(({ok:e,data:a})=>{!t&&e&&Array.isArray(a.models)&&a.models.length>0&&eM(a.models)}).catch(()=>{}),()=>{t=!0}},[r,x]),(0,s.useEffect)(()=>{let e=(m.zN[r]||m.fg[r]||m.IS[r]||m.nJ[r])?.modelsFetcher;e&&S(e).then(eq)},[r]);let tU=async(e,t,a=tp)=>{let i=`${a}/${e}`;try{let e=await fetch("/api/models/alias",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:i,alias:t})});if(e.ok)await tT();else{let t=await e.json();alert(t.error||"Failed to set alias")}}catch(e){console.log("Error setting alias:",e)}},tq=async e=>{try{(await fetch(`/api/models/alias?alias=${encodeURIComponent(e)}`,{method:"DELETE"})).ok&&await tT()}catch(e){console.log("Error deleting alias:",e)}},tz=async(e,t="llm",a=tv)=>{try{let i=await fetch("/api/models/custom",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerAlias:a,id:e,type:t})});if(i.ok)await t$(),window.dispatchEvent(new CustomEvent("customModelChanged"));else{let e=await i.json();alert(e.error||"Failed to add custom model")}}catch(e){console.log("Error adding custom model:",e)}},tM=async(e,t="llm",a=tv)=>{try{let i=new URLSearchParams({providerAlias:a,id:e,type:t});(await fetch(`/api/models/custom?${i}`,{method:"DELETE"})).ok&&(await t$(),window.dispatchEvent(new CustomEvent("customModelChanged")))}catch(e){console.log("Error deleting custom model:",e)}},tK=async()=>{if(e6)return;let e=x.find(e=>!1!==e.isActive);if(!e)return void alert((0,N.Tl)("Please add an active Qoder connection first"));e8(!0);try{let t=await fetch(`/api/providers/${e.id}/models`),a=await t.json();if(!t.ok)return void alert(a.error||(0,N.Tl)("Failed to fetch models"));let i=a.models||[];if(0===i.length)return void alert((0,N.Tl)("No models returned"));let s=0;for(let e of i){let t=e.id||e.name;if(!t)continue;let a=t.replace(/^qoder\//,"");en.some(e=>e.providerAlias===tv&&e.id===a&&"llm"===(e.kind||e.type||"llm"))||Object.values(el).includes(`${tv}/${a}`)||(await tz(a,"llm",tv),s+=1)}0===s?alert((0,N.Tl)("All models already exist, no new models added")):alert((0,N.Tl)("Successfully added")+` ${s} `+(0,N.Tl)("models"))}catch(e){console.log("Error importing Qoder models:",e),alert((0,N.Tl)("Error fetching models")+": "+e.message)}finally{e8(!1)}},tL=async()=>{if(eV||0===x.length)return;let e=Object.fromEntries(x.map(e=>[e.id,{state:"queued",error:null}]));e4.current=!1,eQ(!0),eY(!1),e0(null),e2(e),e3({total:x.length,completed:0,passed:0,failed:0,stopped:!1});let t=0,a=0;try{for(let e=0;e<x.length;e+=1){if(e4.current){e3({total:x.length,completed:e,passed:t,failed:a,stopped:!0});break}let i=x[e];e0(i.id),e2(e=>({...e,[i.id]:{state:"testing",error:null}}));try{let e=await fetch(`/api/providers/${i.id}/test`,{method:"POST"}),s=await e.json(),l=!!s.valid;l?t+=1:a+=1,e2(e=>({...e,[i.id]:{state:l?"success":"failed",error:l?null:s.error||null}}))}catch(e){a+=1,e2(t=>({...t,[i.id]:{state:"failed",error:e.message||"Test failed"}}))}e3({total:x.length,completed:e+1,passed:t,failed:a,stopped:!1}),e<x.length-1&&await new Promise(e=>setTimeout(e,1e3))}}finally{e0(null),eQ(!1),eY(!1),e4.current=!1}},tF=async e=>{eB({title:"Delete Connection",message:"Delete this connection?",onConfirm:async()=>{eB(null);try{(await fetch(`/api/providers/${e}`,{method:"DELETE"})).ok&&h(t=>t.filter(t=>t.id!==e))}catch(e){console.log("Error deleting connection:",e)}}})},tJ=()=>{tP(),D(!1)},tH=async e=>{H("");try{let t=await fetch("/api/providers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:r,...e})}),a=null;try{a=await t.json()}catch{a=null}if(t.ok){await tP(),K(!1);return}H(a?.error||"Failed to save connection")}catch(e){console.log("Error saving connection:",e),H("Failed to save connection")}},tB=async e=>{try{(await fetch(`/api/providers/${ei.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})).ok&&(await tP(),Y(!1))}catch(e){console.log("Error updating connection:",e)}},tW=async(e,t)=>{try{(await fetch(`/api/providers/${e}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({isActive:t})})).ok&&h(a=>a.map(a=>a.id===e?{...a,isActive:t}:a))}catch(e){console.log("Error updating connection status:",e)}},tG=async(e,t)=>{let a=[...x];[a[e],a[t]]=[a[t],a[e]],h(a);try{await Promise.all([fetch(`/api/providers/${a[e].id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({priority:e})}),fetch(`/api/providers/${a[t].id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({priority:t})})])}catch(e){console.log("Error swapping priority:",e),await tP()}},tV=x.filter(e=>eb.includes(e.id));(0,s.useEffect)(()=>{ev(e=>e.filter(e=>x.some(t=>t.id===e)))},[x]),(()=>{if(0===tV.length)return;let e=new Set(tV.map(e=>e.providerSpecificData?.proxyPoolId||"__none__"));if(1===e.size){let t=[...e][0];if("__none__"===t)return;let a=I.find(e=>e.id===t);return a?.name}})();let tQ=()=>{ek||ea(!1)},tZ=async e=>{eN(!0);try{let t=0;for(let{connectionId:a,proxyPoolId:i}of e)try{(await fetch(`/api/providers/${a}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({proxyPoolId:i})})).ok||(t+=1)}catch(e){console.log("Error applying proxy for",a,e),t+=1}t>0&&alert(`Updated with ${t} failed request(s).`),await tP(),ea(!1)}finally{eN(!1)}},tY=e=>tZ(x.map(t=>({connectionId:t.id,proxyPoolId:e}))),{currentPage:tX,items:t0,start:t1}=function(e=[],t=1,a=10){let i=Array.isArray(e)?e:[],s=Number.isFinite(a)&&a>=1?Math.floor(a):10,l=i.length,r=Math.max(1,Math.ceil(l/s)),n=Math.floor(Number(t)),o=Math.min(Number.isFinite(n)&&n>0?n:1,r),d=(o-1)*s,c=i.slice(d,d+s);return{currentPage:o,totalPages:r,totalItems:l,start:d,items:c,pageSize:s}}(x,f,y),t2=new Set(t0.map(e=>e.id)),t5=t0.length>0&&t0.every(e=>eb.includes(e.id)),t3=(0,i.jsxs)("div",{className:"flex min-w-0 flex-col divide-y divide-black/[0.03] dark:divide-white/[0.03]",children:[t0.map((e,t)=>{let a,s=t1+t;return(0,i.jsxs)("div",{className:"flex min-w-0 items-stretch",children:[(0,i.jsx)("div",{className:"flex shrink-0 items-center pl-1 sm:pl-2",children:(0,i.jsx)("input",{type:"checkbox",checked:(a=e.id,eb.includes(a)),onChange:()=>{var t;return t=e.id,void ev(e=>e.includes(t)?e.filter(e=>e!==t):[...e,t])},className:"h-4 w-4 rounded border-gray-300 text-primary focus:ring-primary"})}),(0,i.jsx)("div",{className:"flex-1 min-w-0",children:(0,i.jsx)(U,{connection:e,proxyPools:I,isOAuth:tn,isFirst:0===s,isLast:s===x.length-1,onMoveUp:()=>tG(s,s-1),onMoveDown:()=>tG(s,s+1),onToggleActive:t=>tW(e.id,t),autoPing:W[r]&&"oauth"===e.authType?{on:!0===eD.connections[e.id],onToggle:t=>{var a;return a=e.id,void t_({...eD,connections:{...eD.connections,[a]:t}})},provider:r}:null,onUpdateProxy:async t=>{try{(await fetch(`/api/providers/${e.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({proxyPoolId:t||null})})).ok&&h(a=>a.map(a=>a.id===e.id?{...a,providerSpecificData:{...a.providerSpecificData,proxyPoolId:t||null}}:a))}catch(e){console.log("Error updating proxy:",e)}},onEdit:()=>{es(e),Y(!0)},onReconnect:()=>{"iflow"===r?q(!0):D(!0)},onDelete:()=>tF(e.id),oneByOneStatus:e1[e.id]||null})})]},e.id)}),x.length>10&&(0,i.jsx)(c.dK,{currentPage:tX,pageSize:y,totalItems:x.length,onPageChange:g,onPageSizeChange:e=>{b(e),g(1)},allowCustomPageSize:!0,maxPageSize:200})]}),t4=I.filter(e=>!0===e.isActive),t6=(0,i.jsx)(c.aF,{isOpen:et,onClose:tQ,title:`Apply Proxy (${x.length} connections)`,children:(0,i.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,i.jsxs)("div",{className:"flex flex-col",children:[(0,i.jsxs)("button",{onClick:()=>{let e=I.filter(e=>!0===e.isActive);return 0===e.length?void alert("No active proxy pools available."):tZ(x.map((t,a)=>({connectionId:t.id,proxyPoolId:e[a%e.length].id})))},disabled:ek||0===t4.length,className:"flex items-center gap-2 rounded-lg px-3 py-2 text-left transition-colors hover:bg-black/[0.04] dark:hover:bg-white/[0.04] disabled:cursor-not-allowed disabled:opacity-50",children:[(0,i.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[18px]",children:"sync_alt"}),(0,i.jsx)("span",{className:"text-sm text-text-main",children:"One-to-one (rotate)"})]}),(0,i.jsxs)("button",{onClick:()=>tY(null),disabled:ek,className:"flex items-center gap-2 rounded-lg px-3 py-2 text-left transition-colors hover:bg-black/[0.04] dark:hover:bg-white/[0.04] disabled:cursor-not-allowed disabled:opacity-50",children:[(0,i.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[18px]",children:"link_off"}),(0,i.jsx)("span",{className:"text-sm text-text-main",children:"None (unbind all)"})]}),I.map(e=>(0,i.jsxs)("button",{onClick:()=>tY(e.id),disabled:ek||!0!==e.isActive,className:"flex items-center gap-2 rounded-lg px-3 py-2 text-left transition-colors hover:bg-black/[0.04] dark:hover:bg-white/[0.04] disabled:cursor-not-allowed disabled:opacity-50",children:[(0,i.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[18px]",children:"lan"}),(0,i.jsx)("span",{className:"truncate text-sm text-text-main",children:e.name}),!0!==e.isActive&&(0,i.jsx)("span",{className:"text-[10px] text-text-muted",children:"(inactive)"})]},e.id))]}),ek&&(0,i.jsx)("p",{className:"text-xs text-text-muted",children:"Applying..."}),(0,i.jsx)(c.$n,{onClick:tQ,variant:"ghost",fullWidth:!0,disabled:ek,children:"Cancel"})]})}),t8=async e=>{if(!eh.has(e)){ef(t=>new Set(t).add(e));try{let t=await fetch("/api/models/test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:`${tv}/${e}`})}),a=await t.json();ep(t=>({...t,[e]:a.ok?"ok":"error"})),ex(a.ok?"":a.error||"Model not reachable")}catch{ep(t=>({...t,[e]:"error"})),ex("Network error")}finally{ef(t=>{let a=new Set(t);return a.delete(e),a})}}};if(v)return(0,i.jsxs)("div",{className:"flex flex-col gap-8",children:[(0,i.jsx)(c.Qv,{}),(0,i.jsx)(c.Qv,{})]});if(!tl)return(0,i.jsxs)("div",{className:"text-center py-20",children:[(0,i.jsx)("p",{className:"text-text-muted",children:"Provider not found"}),(0,i.jsx)(n(),{href:"/dashboard/providers",className:"text-primary mt-4 inline-block",children:"Back to Providers"})]});let t7=()=>tu&&tl.apiType?"responses"===tl.apiType?"/providers/oai-r.png":"/providers/oai-cc.png":tx?"/providers/anthropic-m.png":(0,d.HY)(tl.id);return(0,i.jsxs)("div",{className:"flex min-w-0 flex-col gap-6 px-1 sm:gap-8 sm:px-0",children:[(0,i.jsxs)("div",{className:"min-w-0",children:[(0,i.jsxs)(n(),{href:"/dashboard/providers",className:"inline-flex items-center gap-1 text-sm text-text-muted hover:text-primary transition-colors mb-4",children:[(0,i.jsx)("span",{className:"material-symbols-outlined text-lg",children:"arrow_back"}),"Back to Providers"]}),(0,i.jsxs)("div",{className:"flex min-w-0 items-center gap-3 sm:gap-4",children:[(0,i.jsx)("div",{className:"flex size-12 shrink-0 items-center justify-center rounded-lg",style:{backgroundColor:`${tl.color}15`},children:ed||!t7()?(0,i.jsx)("span",{className:"text-sm font-bold",style:{color:tl.color},children:tl.textIcon||tl.id.slice(0,2).toUpperCase()}):(0,i.jsx)(o.default,{src:t7(),alt:tl.name,width:48,height:48,className:"max-h-12 max-w-12 rounded-lg object-contain",sizes:"48px",onError:()=>{(0,d.Kw)(tl.id),ec(!0)},loading:"lazy",decoding:"async"})}),(0,i.jsxs)("div",{className:"min-w-0",children:[(0,i.jsxs)("div",{className:"flex items-center gap-3 flex-wrap",children:[(0,i.jsx)("h1",{className:"truncate text-2xl font-semibold tracking-tight sm:text-3xl",children:tl.name}),(tl.notice?.apiKeyUrl||tl.notice?.signupUrl||tl.website)&&(0,i.jsxs)("a",{href:tl.notice?.apiKeyUrl||tl.notice?.signupUrl||tl.website,target:"_blank",rel:"noopener noreferrer",className:"text-xs text-primary hover:underline inline-flex items-center gap-1",children:[(0,i.jsx)("span",{className:"material-symbols-outlined text-sm",children:"open_in_new"}),tl.notice?.apiKeyUrl?"Get API Key":"Sign up / Learn more"]})]}),(0,i.jsxs)("p",{className:"text-text-muted",children:[x.length," connection",1===x.length?"":"s"]})]}),(0,i.jsxs)("div",{className:"ml-auto flex shrink-0 items-center gap-2",children:[(0,i.jsx)("span",{className:"hidden text-xs text-text-muted sm:inline",children:"RPM / account"}),(0,i.jsx)("input",{type:"number",min:"0",value:eE,placeholder:String(m.W[r]||0),onChange:e=>eR(e.target.value),onBlur:e=>tD(e.target.value),title:"Max requests per minute per account. Accounts over the cap are skipped before a request is sent, so the provider never sees a 429. Blank = provider default, 0 = unlimited.",className:"w-16 rounded-md border border-border bg-background px-2 py-1 text-xs focus:border-primary focus:outline-none"}),(0,i.jsx)("span",{className:"hidden text-xs text-text-muted sm:inline",children:"Retry delay"}),(0,i.jsx)("select",{value:eI,onChange:e=>{var t;eO(t=e.target.value),tR(t)},title:"Cooldown after a rate-limit/error when the provider reports no reset time of its own. Auto = honor the provider's reported delay, else built-in backoff.",className:"rounded-md border border-border bg-background px-2 py-1 text-xs focus:border-primary focus:outline-none",children:G.map(e=>(0,i.jsx)("option",{value:e.value,children:e.label},e.value))})]})]})]}),tl.deprecated&&(0,i.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 rounded-lg bg-yellow-500/10 border border-yellow-500/30",children:[(0,i.jsx)("span",{className:"material-symbols-outlined text-[16px] text-yellow-500 mt-0.5 shrink-0",children:"warning"}),(0,i.jsx)("p",{className:"text-xs text-red-600 dark:text-yellow-400 leading-relaxed",children:tl.deprecationNotice})]}),tl.notice?.text&&!tl.deprecated&&(0,i.jsxs)("div",{className:"flex flex-col gap-2 rounded-lg border border-blue-500/30 bg-blue-500/10 px-3 py-2 sm:flex-row sm:items-center",children:[(0,i.jsx)("span",{className:"material-symbols-outlined text-[16px] text-blue-500 shrink-0",children:"info"}),(0,i.jsx)("p",{className:"min-w-0 flex-1 text-xs leading-relaxed text-blue-600 dark:text-blue-400",children:tl.notice.text}),tl.notice.apiKeyUrl&&(0,i.jsx)("a",{href:tl.notice.apiKeyUrl,target:"_blank",rel:"noopener noreferrer",className:"inline-flex justify-center rounded bg-blue-500 px-2 py-1 text-xs font-medium text-white transition-colors hover:bg-blue-600 sm:py-0.5",children:"Get API Key →"})]}),th&&T&&(0,i.jsx)(c.Zp,{children:(0,i.jsxs)("div",{className:"mb-4 flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[(0,i.jsxs)("div",{className:"min-w-0",children:[(0,i.jsx)("h2",{className:"text-lg font-semibold",children:tx?"Anthropic Compatible Details":"OpenAI Compatible Details"}),(0,i.jsxs)("p",{className:"break-all text-sm text-text-muted",children:[tx?"Messages API":"responses"===T.apiType?"Responses API":"Chat Completions"," \xb7 ",(T.baseUrl||"").replace(/\/$/,""),"/",tx?"messages":"responses"===T.apiType?"responses":"chat/completions"]})]}),(0,i.jsxs)("div",{className:"grid grid-cols-1 gap-2 sm:flex sm:items-center",children:[(0,i.jsx)(c.$n,{size:"sm",icon:"add",onClick:()=>{H(""),K(!0)},className:"w-full sm:w-auto",children:"Add API Key"}),(0,i.jsx)(c.$n,{size:"sm",variant:"secondary",icon:"edit",onClick:()=>ee(!0),className:"w-full sm:w-auto",children:"Edit"}),(0,i.jsx)(c.$n,{size:"sm",variant:"secondary",icon:"delete",onClick:async()=>{eB({title:"Delete Compatible Node",message:`Delete this ${tx?"Anthropic":"OpenAI"} Compatible node?`,onConfirm:async()=>{eB(null);try{(await fetch(`/api/provider-nodes/${r}`,{method:"DELETE"})).ok&&a.push("/dashboard/providers")}catch(e){console.log("Error deleting provider node:",e)}}})},className:"w-full sm:w-auto",children:"Delete"})]})]})}),td?(0,i.jsx)(c.gw,{providerId:r}):(0,i.jsxs)(c.Zp,{children:[(0,i.jsxs)("div",{className:"mb-4 flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[(0,i.jsx)("h2",{className:"text-lg font-semibold",children:"Connections"}),(0,i.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:gap-4",children:[x.length>0&&I.length>0&&(0,i.jsx)(c.$n,{size:"sm",variant:"secondary",icon:"lan",onClick:()=>ea(!0),children:"Apply Proxy"}),x.length>0&&(0,i.jsxs)(i.Fragment,{children:[eb.length>0&&(0,i.jsxs)(c.$n,{size:"sm",variant:"danger",icon:"delete",onClick:()=>{let e=eb.length;0!==e&&eB({title:`Delete ${e} Connection${e>1?"s":""}`,message:`Delete ${e} connection${e>1?"s":""}? This cannot be undone.`,onConfirm:async()=>{eB(null);let e=0,t=[...eb];for(let a of t)try{(await fetch(`/api/providers/${a}`,{method:"DELETE"})).ok||(e+=1)}catch(t){console.log("Error deleting connection:",t),e+=1}h(e=>e.filter(e=>!t.includes(e.id))),ev([]),e>0&&alert(`Deleted ${t.length-e} connection(s), ${e} failed.`)}})},children:["Delete Selected (",eb.length,")"]}),(0,i.jsx)(c.$n,{size:"sm",variant:"secondary",icon:"sync",onClick:tL,disabled:eV,children:eV?"Testing Connection One-by-One...":"Test Connection One-by-One"}),eV&&(0,i.jsx)(c.$n,{size:"sm",variant:"ghost",icon:"stop",onClick:()=>{eV&&(e4.current=!0,eY(!0))},disabled:eZ,children:eZ?"Stopping...":"Stop"})]}),(0,i.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,i.jsx)("span",{className:"text-xs text-text-muted font-medium",children:"Round Robin"}),(0,i.jsx)(c.lM,{checked:"round-robin"===eC,onChange:e=>{let t=e?"round-robin":null,a=e?eA||"1":eA;e&&!eA&&eT("1"),eS(t),tO(t,a)}}),"round-robin"===eC&&(0,i.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,i.jsx)("span",{className:"text-xs text-text-muted",children:"Sticky:"}),(0,i.jsx)("input",{type:"number",min:1,value:eA,onChange:e=>{var t;eT(t=e.target.value),tO("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===x.length?(0,i.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[(0,i.jsxs)("div",{className:"flex items-center gap-3",children:[(0,i.jsx)("div",{className:"inline-flex items-center justify-center w-9 h-9 rounded-full bg-primary/10 text-primary shrink-0",children:(0,i.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:tn?"lock":"key"})}),(0,i.jsxs)("div",{className:"min-w-0",children:[(0,i.jsx)("p",{className:"text-sm text-text-muted",children:"No connections yet"}),tf&&(0,i.jsxs)("p",{className:"text-xs text-text-muted",children:["Choose ",tg," or ",ty,"."]})]})]}),(0,i.jsx)("div",{className:"flex gap-2",children:tf?(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(c.$n,{size:"sm",icon:"lock",variant:"secondary",onClick:ta,children:tg}),(0,i.jsx)(c.$n,{size:"sm",icon:"key",onClick:ti,children:ty})]}):(0,i.jsxs)(i.Fragment,{children:[!th&&"iflow"===r&&(0,i.jsx)(c.$n,{size:"sm",icon:"cookie",variant:"secondary",onClick:()=>q(!0),children:"Cookie"}),"codex"===r&&(0,i.jsx)(c.$n,{size:"sm",icon:"playlist_add",variant:"secondary",onClick:()=>Q(!0),children:(0,N.Tl)("Bulk Add")}),(0,i.jsx)(c.$n,{size:"sm",icon:"add",onClick:ts,children:th?"Add API Key":"iflow"===r?"OAuth":"Add Connection"})]})})]}):(0,i.jsxs)(i.Fragment,{children:[e5&&(0,i.jsx)("div",{className:"mb-4 rounded-lg border border-black/10 bg-black/[0.02] px-3 py-2 text-xs text-text-muted dark:border-white/10 dark:bg-white/[0.03]",children:(0,i.jsxs)("div",{className:"flex flex-wrap items-center gap-3",children:[(0,i.jsxs)("span",{children:["Total: ",e5.total]}),(0,i.jsxs)("span",{children:["Completed: ",e5.completed]}),(0,i.jsxs)("span",{children:["Passed: ",e5.passed]}),(0,i.jsxs)("span",{children:["Failed: ",e5.failed]}),e5.stopped&&(0,i.jsx)("span",{className:"text-amber-600 dark:text-amber-400",children:"Stopped"}),eV&&eX&&(0,i.jsxs)("span",{children:["Running: ",x.find(e=>e.id===eX)?.name||eX]})]})}),x.length>0&&(0,i.jsx)("div",{className:"mb-3 flex items-center gap-2 border-b border-black/[0.03] pb-2 dark:border-white/[0.03]",children:(0,i.jsxs)("label",{className:"flex cursor-pointer items-center gap-1.5 text-xs text-text-muted hover:text-primary",children:[(0,i.jsx)("input",{type:"checkbox",checked:t5,onChange:()=>{t5?ev(e=>e.filter(e=>!t2.has(e))):ev(e=>{let t=new Set(e);for(let e of t2)t.add(e);return[...t]})},className:"h-3.5 w-3.5 rounded border-gray-300 text-primary focus:ring-primary"}),"Select All"]})}),t3,!th&&(0,i.jsxs)("div",{className:"mt-4 grid grid-cols-1 gap-2 sm:flex",children:["iflow"===r&&(0,i.jsx)(c.$n,{size:"sm",icon:"cookie",variant:"secondary",onClick:()=>q(!0),title:"Add connection using browser cookie",className:"w-full sm:w-auto",children:"Cookie"}),"codex"===r&&(0,i.jsx)(c.$n,{size:"sm",icon:"playlist_add",variant:"secondary",onClick:()=>Q(!0),title:(0,N.Tl)("Bulk import codex accounts from JSON"),className:"w-full sm:w-auto",children:(0,N.Tl)("Bulk Add")}),tf?(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(c.$n,{size:"sm",icon:"lock",variant:"secondary",onClick:ta,className:"w-full sm:w-auto",children:tg}),(0,i.jsx)(c.$n,{size:"sm",icon:"key",onClick:ti,className:"w-full sm:w-auto",children:ty})]}):(0,i.jsx)(c.$n,{size:"sm",icon:"add",onClick:ts,className:"w-full sm:w-auto",children:"Add"})]})]})]}),(0,i.jsxs)(c.Zp,{children:[(0,i.jsxs)("div",{className:"mb-4 flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between",children:[(0,i.jsxs)("div",{className:"flex items-center gap-3",children:[(0,i.jsx)("h2",{className:"text-lg font-semibold",children:"Available Models"}),tj&&(0,i.jsx)("select",{value:e$,onChange:e=>{var t;eP(t=e.target.value),tE(t)},title:"Appends (level) suffix to copied model names",className:"rounded-md border border-border bg-background px-2 py-1 text-xs focus:border-primary focus:outline-none",children:tj.map(e=>(0,i.jsx)("option",{value:e,children:`Thinking: ${e.charAt(0).toUpperCase()+e.slice(1)}`},e))})]}),!th&&(e=[...tm,...eK.filter(e=>!tm.some(t=>t.id===e.id))].filter(e=>{let t=(0,p.CP)(e);return!t||"llm"===t}).map(e=>e.id).filter(e=>!eF.includes(e)),(0,i.jsxs)("div",{className:"flex gap-2",children:[eF.length>0&&(0,i.jsx)(c.$n,{size:"sm",variant:"secondary",icon:"restart_alt",onClick:tA,children:"Active All"}),e.length>0&&(0,i.jsx)(c.$n,{size:"sm",variant:"secondary",icon:"block",onClick:()=>tS(e),children:"Disable All"})]}))]}),!!eu&&(0,i.jsx)("p",{className:"text-xs text-red-500 mb-3 break-words",children:eu}),(()=>{let e,t,a;if(th)return(0,i.jsx)(O,{providerStorageAlias:tv,providerDisplayAlias:tw,modelAliases:el,customModels:en,copied:e7,onCopy:e9,onSetAlias:tU,onDeleteAlias:tq,onAddCustomModel:e=>tz(e,"llm",tv),onDeleteCustomModel:e=>tM(e,"llm",tv),connections:x,isAnthropic:tx});let s=[...tm,...eK.filter(e=>!tm.some(t=>t.id===e.id))].filter(e=>{let t=(0,p.CP)(e);return!t||"llm"===t}),l=new Set(eF),n=s.filter(e=>!l.has(e.id)),o=s.filter(e=>l.has(e.id)),d=A({customModels:en,modelAliases:el,providerAlias:tv,builtInModels:tm,type:"llm"});return(0,i.jsxs)("div",{className:"flex flex-wrap gap-3",children:[d.map(e=>(0,i.jsx)(P,{model:{id:e.id,name:e.name},fullModel:`${tw}/${e.id}`,alias:e.alias,copied:e7,onCopy:e9,onSetAlias:()=>{},onDeleteAlias:()=>{"custom"===e.source?tM(e.id,"llm",tv):tq(e.alias)},testStatus:em[e.id],onTest:x.length>0||td?()=>t8(e.id):void 0,isTesting:eh.has(e.id),isCustom:!0,isFree:!1,caps:u(`${r}/${e.id}`),thinkingSuffix:tb(e.id)},`${e.source}-${e.fullModel}`)),n.map(e=>{let t=`${tv}/${e.id}`,a=`${r}/${e.id}`,s=Object.entries(el).find(([,e])=>e===t||e===a)?.[0];return(0,i.jsx)(P,{model:e,fullModel:`${tw}/${e.id}`,alias:s,copied:e7,onCopy:e9,onSetAlias:t=>tU(e.id,t,tv),onDeleteAlias:()=>tq(s),testStatus:em[e.id],onTest:x.length>0||td?()=>t8(e.id):void 0,isTesting:eh.has(e.id),isFree:e.isFree,onDisable:()=>tN(e.id),caps:u(`${r}/${e.id}`),thinkingSuffix:tb(e.id)},e.id)}),(0,i.jsxs)("button",{onClick:()=>ey(!0),className:"flex w-full items-center justify-center gap-1.5 rounded-lg border border-dashed border-primary/40 px-3 py-2 text-xs text-primary transition-colors hover:border-primary hover:bg-primary/5 sm:w-auto",children:[(0,i.jsx)("span",{className:"material-symbols-outlined text-sm",children:"add"}),"Add Model"]}),"qoder"===r&&x.some(e=>!1!==e.isActive)&&(0,i.jsxs)("button",{onClick:tK,disabled:e6,className:"flex w-full items-center justify-center gap-1.5 rounded-lg border border-dashed border-blue-500/40 px-3 py-2 text-xs text-blue-600 dark:text-blue-400 transition-colors hover:border-blue-500 hover:bg-blue-500/5 sm:w-auto disabled:opacity-50 disabled:cursor-not-allowed",children:[(0,i.jsx)("span",{className:"material-symbols-outlined text-sm",style:e6?{animation:"spin 1s linear infinite"}:void 0,children:e6?"progress_activity":"download"}),e6?(0,N.Tl)("Fetching..."):(0,N.Tl)("Fetch Qoder Models")]}),eU.length>0&&(e=new Set([...Object.values(el),...d.map(e=>e.fullModel)]),t=new Set(tm.map(e=>e.id)),0===(a=eU.filter(a=>!e.has(`${tv}/${a.id}`)&&!t.has(a.id))).length?null:(0,i.jsxs)("div",{className:"w-full mt-2",children:[(0,i.jsx)("p",{className:"text-xs text-text-muted mb-2",children:"Suggested free models (≥200k context):"}),(0,i.jsx)("div",{className:"flex flex-wrap gap-2",children:a.map(e=>(0,i.jsxs)("button",{onClick:async()=>{await tz(e.id,"llm",tv)},className:"flex items-center gap-1 px-2.5 py-1.5 rounded-lg border border-black/10 dark:border-white/10 text-xs text-text-muted hover:text-primary hover:border-primary/40 hover:bg-primary/5 transition-colors",title:`${e.name} \xb7 ${(e.contextLength/1e3).toFixed(0)}k ctx`,children:[(0,i.jsx)("span",{className:"material-symbols-outlined text-[13px]",children:"add"}),e.id.split("/").pop()]},e.id))})]})),o.length>0&&(0,i.jsxs)("div",{className:"w-full mt-2",children:[(0,i.jsxs)("p",{className:"text-xs text-text-muted mb-2",children:["Disabled models (",o.length,"):"]}),(0,i.jsx)("div",{className:"flex flex-wrap gap-2",children:o.map(e=>(0,i.jsxs)("button",{onClick:()=>tC(e.id),className:"flex items-center gap-1 px-2.5 py-1.5 rounded-lg border border-dashed border-black/10 dark:border-white/10 text-xs text-text-muted hover:text-primary hover:border-primary/40 hover:bg-primary/5 transition-colors",title:"Restore model",children:[(0,i.jsx)("span",{className:"material-symbols-outlined text-[13px]",children:"add"}),e.id]},e.id))})]})]})})()]}),t6,"kiro"===r?(0,i.jsx)(c.Mh,{isOpen:R,providerInfo:tl,onSuccess:tJ,onClose:()=>D(!1)}):"cursor"===r?(0,i.jsx)(c.G9,{isOpen:R,onSuccess:tJ,onClose:()=>D(!1)}):"gitlab"===r?(0,i.jsx)(c.vj,{isOpen:R,providerInfo:tl,onSuccess:tJ,onClose:()=>D(!1)}):(0,i.jsx)(c.LF,{isOpen:R,provider:r,providerInfo:tl,onSuccess:tJ,onClose:()=>D(!1)}),"iflow"===r&&(0,i.jsx)(c.vE,{isOpen:_,onSuccess:()=>{tP(),q(!1)},onClose:()=>q(!1)}),(0,i.jsx)(z,{isOpen:M,provider:r,providerName:tl.name,isCompatible:th,isAnthropic:tx,authType:tl?.authType,authHint:tl?.authHint,website:tl?.website,proxyPools:I,error:L,existingNames:x.map(e=>e.name).filter(Boolean),onSave:tH,onBulkDone:tP,onClose:()=>{H(""),K(!1)}}),(0,i.jsx)(c.wI,{isOpen:Z,connection:ei,proxyPools:I,onSave:tB,onClose:()=>Y(!1)}),th&&(0,i.jsx)(F,{isOpen:X,node:T,onSave:tI,onClose:()=>ee(!1),isAnthropic:tx}),!th&&(0,i.jsx)(J,{isOpen:eg,providerAlias:tv,providerDisplayAlias:tw,onSave:async e=>{await tz(e,"llm",tv),ey(!1)},onClose:()=>ey(!1)}),"codex"===r&&(0,i.jsx)(B,{isOpen:V,onClose:()=>Q(!1),onSuccess:tP}),(0,i.jsx)(c.uo,{isOpen:eW,onClose:()=>eG(!1),onConfirm:()=>{(window.localStorage.setItem(te,"true"),eG(!1),tn)?tt():ti()},title:"Risk Notice",message:tl?.deprecationNotice,confirmText:"I Understand, Continue",cancelText:"Cancel",variant:"danger"}),(0,i.jsx)(c.uo,{isOpen:!!eH,onClose:()=>eB(null),onConfirm:eH?.onConfirm,title:eH?.title||"Confirm",message:eH?.message,variant:"danger"})]})}},85295:(e,t,a)=>{Promise.resolve().then(a.bind(a,80035))}},e=>{e.O(0,[8010,5772,8105,1321,801,5497,8441,3794,7358],()=>e(e.s=85295)),_N_E=e.O()}]);
@@ -0,0 +1 @@
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[8460],{28915:(e,t,r)=>{"use strict";r.d(t,{E2:()=>s,gs:()=>a});function s(e){if(!e)return null;let t=e.match(/\b([45]\d{2})\b/);return t?t[1]:"ERR"}function a(e){if(!e)return"";let t=Math.floor((Date.now()-new Date(e).getTime())/6e4);if(t<1)return"just now";if(t<60)return`${t}m ago`;let r=Math.floor(t/60);if(r<24)return`${r}h ago`;let s=Math.floor(r/24);return`${s}d ago`}r(8247)},69671:(e,t,r)=>{Promise.resolve().then(r.bind(r,71720))},71720:(e,t,r)=>{"use strict";r.r(t),r.d(t,{default:()=>A});var s=r(95155),a=r(12115),l=r(14051),i=r.n(l),n=r(35497),o=r(57250),d=r(8247),c=r(90620),p=r(88105),m=r(98500),u=r.n(m),x=r(28915),h=r(65921),f=r(38003),g=r(73006);let b={available:{icon:"check_circle",color:"#22c55e",label:"Available"},cooldown:{icon:"schedule",color:"#f59e0b",label:"Cooldown"},unavailable:{icon:"error",color:"#ef4444",label:"Unavailable"},unknown:{icon:"help",color:"#6b7280",label:"Unknown"}};function y(){let[e,t]=(0,a.useState)(null),[r,l]=(0,a.useState)(!0),[i,o]=(0,a.useState)(!1),[d,c]=(0,a.useState)(null),p=(0,a.useRef)(null),m=(0,h.i)(),u=(0,a.useCallback)(async()=>{try{let e=await fetch("/api/models/availability");if(e.ok){let r=await e.json();t(r)}}catch{}finally{l(!1)}},[]);(0,a.useEffect)(()=>{u();let e=setInterval(u,3e4);return()=>clearInterval(e)},[u]),(0,a.useEffect)(()=>{let e=e=>{p.current&&!p.current.contains(e.target)&&o(!1)};return i&&document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[i]);let x=async(e,t)=>{c(`${e}:${t}`);try{(await fetch("/api/models/availability",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"clearCooldown",provider:e,model:t})})).ok?(m.success(`Cooldown cleared for ${t}`),await u()):m.error("Failed to clear cooldown")}catch{m.error("Failed to clear cooldown")}finally{c(null)}};if(r)return null;let f=e?.models||[],g=0===(e?.unavailableCount||f.filter(e=>"available"!==e.status).length),y={};return f.forEach(e=>{if("available"===e.status)return;let t=e.provider||"unknown";y[t]||(y[t]=[]),y[t].push(e)}),(0,s.jsx)("div",{className:"relative",ref:p,children:i&&(0,s.jsxs)("div",{className:"absolute top-full right-0 mt-2 w-80 bg-surface border border-border rounded-xl shadow-2xl z-50 overflow-hidden",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border bg-bg",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-[16px]",style:{color:g?"#22c55e":"#f59e0b"},children:g?"verified":"warning"}),(0,s.jsx)("span",{className:"text-sm font-semibold text-text-main",children:"Model Status"})]}),(0,s.jsx)("button",{onClick:u,className:"p-1 rounded-lg hover:bg-surface text-text-muted hover:text-text-main transition-colors",title:"Refresh",children:(0,s.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"refresh"})})]}),(0,s.jsx)("div",{className:"px-4 py-3 max-h-60 overflow-y-auto",children:g?(0,s.jsx)("p",{className:"text-sm text-text-muted text-center py-2",children:"All models are responding normally."}):(0,s.jsx)("div",{className:"flex flex-col gap-2.5",children:Object.entries(y).map(([e,t])=>(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"text-xs font-semibold text-text-main mb-1.5 capitalize",children:e}),(0,s.jsx)("div",{className:"flex flex-col gap-1",children:t.map(e=>{let t=b[e.status]||b.unknown,r=d===`${e.provider}:${e.model}`;return(0,s.jsxs)("div",{className:"flex items-center justify-between px-2.5 py-1.5 rounded-lg bg-surface/30",children:[(0,s.jsxs)("div",{className:"flex items-center gap-1.5 min-w-0",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-[14px] shrink-0",style:{color:t.color},children:t.icon}),(0,s.jsx)("span",{className:"font-mono text-xs text-text-main truncate",children:e.model})]}),"cooldown"===e.status&&(0,s.jsx)(n.$n,{size:"sm",variant:"ghost",onClick:()=>x(e.provider,e.model),disabled:r,className:"text-[10px] px-1.5! py-0.5! ml-2",children:r?"...":"Clear"})]},`${e.provider}-${e.model}`)})})]},e))})})]})})}let v={openai:{title:"Add OpenAI Compatible",type:"openai-compatible",defaultBaseUrl:"https://api.openai.com/v1",namePlaceholder:"OpenAI Compatible (Prod)",prefixPlaceholder:"oc-prod",baseUrlHint:"Use the base URL (ending in /v1) for your OpenAI-compatible API.",modelIdPlaceholder:"e.g. gpt-4, claude-3-opus",errorLabel:"OpenAI Compatible",hasApiType:!0},anthropic:{title:"Add Anthropic Compatible",type:"anthropic-compatible",defaultBaseUrl:"https://api.anthropic.com/v1",namePlaceholder:"Anthropic Compatible (Prod)",prefixPlaceholder:"ac-prod",baseUrlHint:"Use the base URL (ending in /v1) for your Anthropic-compatible API. The system will append /messages.",modelIdPlaceholder:"e.g. claude-3-opus",errorLabel:"Anthropic Compatible",hasApiType:!1}},j=[{value:"chat",label:"Chat Completions"},{value:"responses",label:"Responses API"}],N=[{value:"default",label:"Default"},{value:"claude-cli",label:"Claude CLI"},{value:"codex-cli",label:"Codex CLI"},{value:"openclaw",label:"OpenClaw"},{value:"custom",label:"Custom Headers"}],w=new Set(["authorization","x-api-key","api-key","cookie"]);function k(e){let t=String(e||"").trim();if(!t)return{headers:{}};try{let e;if(t.startsWith("{")){let r=JSON.parse(t);if(!r||"object"!=typeof r||Array.isArray(r))return{error:"Use a JSON object or Header: value lines."};e=Object.entries(r)}else for(let r of(e=[],t.split(/\r?\n/))){let t=r.trim();if(!t||t.startsWith("#"))continue;let s=t.indexOf(":");if(s<=0)return{error:"Each custom header line must use Header: value."};e.push([t.slice(0,s),t.slice(s+1)])}let r={};for(let[t,s]of e){let e=String(t||"").trim(),a=String(s||"").trim();!e||!a||w.has(e.toLowerCase())||(r[e]=a)}return{headers:r}}catch{return{error:"Use valid JSON or Header: value lines."}}}function C({variant:e,isOpen:t,onClose:r,onCreated:l}){let i=v[e],o=()=>({name:"",prefix:"",...i.hasApiType?{apiType:"chat"}:{},baseUrl:i.defaultBaseUrl,clientIdentityProfile:"default",clientIdentityHeadersText:""}),[d,c]=(0,a.useState)(o),[p,m]=(0,a.useState)(!1),[u,x]=(0,a.useState)(""),[h,f]=(0,a.useState)(""),[g,b]=(0,a.useState)(!1),[y,w]=(0,a.useState)(null);(0,a.useEffect)(()=>{i.hasApiType?c(e=>({...e,baseUrl:i.defaultBaseUrl})):t&&(w(null),x(""),f(""))},[i.hasApiType?d.apiType:t]);let T=async()=>{if(!d.name.trim()||!d.prefix.trim()||!d.baseUrl.trim())return;let e="custom"===d.clientIdentityProfile?k(d.clientIdentityHeadersText):{headers:{}};if(e.error)return void w({valid:!1,error:e.error});m(!0);try{let t=await fetch("/api/provider-nodes",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:d.name,prefix:d.prefix,...i.hasApiType?{apiType:d.apiType}:{},baseUrl:d.baseUrl,type:i.type,clientIdentityProfile:d.clientIdentityProfile,clientIdentityHeaders:e.headers})}),r=await t.json();t.ok&&(l(r.node),c(o()),x(""),w(null))}catch(e){console.log(`Error creating ${i.errorLabel} node:`,e)}finally{m(!1)}},A=async()=>{let e="custom"===d.clientIdentityProfile?k(d.clientIdentityHeadersText):{headers:{}};if(e.error)return void w({valid:!1,error:e.error});b(!0);try{let t=await fetch("/api/provider-nodes/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:d.baseUrl,apiKey:u,type:i.type,modelId:h.trim()||void 0,clientIdentityProfile:d.clientIdentityProfile,clientIdentityHeaders:e.headers})}),r=await t.json();w(r)}catch{w({valid:!1,error:"Network error"})}finally{b(!1)}};return(0,s.jsx)(n.aF,{isOpen:t,title:i.title,onClose:r,children:(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,s.jsx)(n.pd,{label:"Name",value:d.name,onChange:e=>c({...d,name:e.target.value}),placeholder:i.namePlaceholder,hint:"Required. A friendly label for this node."}),(0,s.jsx)(n.pd,{label:"Prefix",value:d.prefix,onChange:e=>c({...d,prefix:e.target.value}),placeholder:i.prefixPlaceholder,hint:"Required. Used as the provider prefix for model IDs."}),i.hasApiType&&(0,s.jsx)(n.l6,{label:"API Type",options:j,value:d.apiType,onChange:e=>c({...d,apiType:e.target.value})}),(0,s.jsx)(n.pd,{label:"Base URL",value:d.baseUrl,onChange:e=>c({...d,baseUrl:e.target.value}),placeholder:i.defaultBaseUrl,hint:i.baseUrlHint}),(0,s.jsx)(n.l6,{label:"Client Identity",options:N,value:d.clientIdentityProfile,onChange:e=>c({...d,clientIdentityProfile:e.target.value}),hint:"Optional. Adds client fingerprint headers for compatible gateways."}),"custom"===d.clientIdentityProfile&&(0,s.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,s.jsx)("label",{className:"text-sm font-medium text-text-main",children:"Custom Headers"}),(0,s.jsx)("textarea",{value:d.clientIdentityHeadersText,onChange:e=>c({...d,clientIdentityHeadersText:e.target.value}),placeholder:'{\n "User-Agent": "custom/1.0"\n}',rows:5,className:"w-full resize-y rounded-[10px] border border-transparent bg-surface-2 px-3 py-2.5 text-[16px] text-text-main placeholder-text-muted/70 transition-all duration-150 focus:border-brand-500/40 focus:outline-none focus:ring-2 focus:ring-brand-500/30 sm:text-sm"}),(0,s.jsx)("p",{className:"text-xs text-text-muted",children:"JSON object or Header: value lines. Auth headers are ignored."})]}),(0,s.jsx)(n.pd,{label:"API Key (for Check)",type:"password",value:u,onChange:e=>x(e.target.value)}),(0,s.jsx)(n.pd,{label:"Model ID (optional)",value:h,onChange:e=>f(e.target.value),placeholder:i.modelIdPlaceholder,hint:"If provider lacks /models endpoint, enter a model ID to validate via chat/completions instead."}),(0,s.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center",children:[(0,s.jsx)(n.$n,{onClick:A,disabled:!u||g||!d.baseUrl.trim(),variant:"secondary",className:"w-full sm:w-auto",children:g?"Checking...":"Check"}),(()=>{if(!y)return null;let{valid:e,error:t,method:r}=y;return e?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(n.Ex,{variant:"success",children:"Valid"}),"chat"===r&&(0,s.jsx)("span",{className:"text-sm text-text-muted",children:"(via inference test)"})]}):(0,s.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,s.jsx)(n.Ex,{variant:"error",children:"Invalid"}),t&&(0,s.jsx)("span",{className:"text-sm text-red-500",children:t})]})})()]}),(0,s.jsxs)("div",{className:"flex flex-col gap-2 sm:flex-row",children:[(0,s.jsx)(n.$n,{onClick:T,fullWidth:!0,disabled:!d.name.trim()||!d.prefix.trim()||!d.baseUrl.trim()||p,children:p?"Creating...":"Create"}),(0,s.jsx)(n.$n,{onClick:r,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})})}function T(e,t,r){let a=[];if(e>0&&a.push((0,s.jsxs)(n.Ex,{variant:"success",size:"sm",dot:!0,children:[e," Connected"]},"connected")),t>0){let e=r?`${t} Error (${r})`:`${t} Error`;a.push((0,s.jsx)(n.Ex,{variant:"error",size:"sm",dot:!0,children:e},"error"))}return 0===a.length?(0,s.jsx)("span",{className:"text-text-muted",children:"No connections"}):a}function A(){let[e,t]=(0,a.useState)([]),[r,l]=(0,a.useState)([]),[i,o]=(0,a.useState)(!0),[d,m]=(0,a.useState)(!1),[u,b]=(0,a.useState)(!1),[v,j]=(0,a.useState)(!1),[N,w]=(0,a.useState)(null),[k,T]=(0,a.useState)(null),A=(0,h.i)(),E=(0,f.C)(e=>e.query),S=(0,f.C)(e=>e.register),$=(0,f.C)(e=>e.unregister);(0,a.useEffect)(()=>(S("Search providers..."),()=>$()),[S,$]);let U=e=>!E.trim()||e.toLowerCase().includes(E.trim().toLowerCase()),R=(e,t)=>[...e].sort(([e,r],[s,a])=>{let l=r.priority??999,i=a.priority??999;if(l!==i)return l-i;let n=_(e,t),o=_(s,t),d=+(n.connected>0),c=+(o.connected>0);return d!==c?c-d:(r.name||"").localeCompare(a.name||"")});(0,a.useEffect)(()=>{(async()=>{try{let[e,r]=await Promise.all([fetch("/api/providers"),fetch("/api/provider-nodes")]),s=await e.json(),a=await r.json();e.ok&&t(s.connections||[]),r.ok&&l(a.nodes||[])}catch(e){console.log("Error fetching data:",e)}finally{o(!1)}})()},[]);let _=(t,r)=>{let s=Array.isArray(r)?r:r?[r]:null,a=e.filter(e=>e.provider===t&&(!!(!s||s.includes("all")||s.includes("freeTier")||s.includes("free")||s.includes("apikey")&&("apikey"===e.authType||"api_key"===e.authType))||s.includes(e.authType))),l=e=>{let t=Object.entries(e).some(([e,t])=>e.startsWith("modelLock_")&&t&&new Date(t).getTime()>Date.now());return"unavailable"!==e.testStatus||t?e.testStatus:"active"},i=a.filter(e=>{let t=l(e);return"active"===t||"success"===t}).length,n=a.filter(e=>{let t=l(e);return"error"===t||"expired"===t||"unavailable"===t}),o=n.length,d=a.length,c=d>0&&a.every(e=>!1===e.isActive),p=n.sort((e,t)=>new Date(t.lastErrorAt||0)-new Date(e.lastErrorAt||0))[0];return{connected:i,error:o,total:d,errorCode:p?function(e){if(!e)return null;let t=e.lastErrorType;if("runtime_error"===t)return"RUNTIME";if("upstream_auth_error"===t||"auth_missing"===t||"token_refresh_failed"===t||"token_expired"===t)return"AUTH";if("upstream_rate_limited"===t)return"429";if("upstream_unavailable"===t)return"5XX";if("network_error"===t)return"NET";let r=Number(e.errorCode);if(Number.isFinite(r)&&r>=400)return String(r);let s=(0,x.E2)(e.lastError);if("401"===s||"403"===s)return"AUTH";if(s&&"ERR"!==s)return s;let a=(e.lastError||"").toLowerCase();return a.includes("runtime")||a.includes("not runnable")||a.includes("not installed")?"RUNTIME":a.includes("invalid api key")||a.includes("token invalid")||a.includes("revoked")||a.includes("unauthorized")?"AUTH":"ERR"}(p):null,errorTime:p?.lastErrorAt?(0,x.gs)(p.lastErrorAt):null,allDisabled:c}},z=async(r,s,a)=>{let l=Array.isArray(s)?s:s?[s]:null,i=e=>e.provider===r&&(!!(!l||l.includes("all")||l.includes("freeTier")||l.includes("free")||l.includes("apikey")&&("apikey"===e.authType||"api_key"===e.authType))||l.includes(e.authType)),n=e.filter(i);t(e=>e.map(e=>i(e)?{...e,isActive:a}:e)),await Promise.allSettled(n.map(e=>fetch(`/api/providers/${e.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({isActive:a})})))},H=async(e,t=null)=>{if(!N){w("provider"===e?t:e),T(null);try{let r=await fetch("/api/providers/test-batch",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mode:e,providerId:t})}),s=await r.json();if(T(s),s.summary){let{passed:e,failed:t,total:r}=s.summary;0===t?A.success(`All ${r} tests passed`):A.warning(`${e}/${r} passed, ${t} failed`)}}catch(e){T({error:"Test request failed"}),A.error("Provider test failed")}finally{w(null)}}},q=r.filter(e=>"openai-compatible"===e.type).map(e=>({id:e.id,name:e.name||"OpenAI Compatible",color:"#10A37F",textIcon:"OC",apiType:e.apiType})).filter(e=>U(e.name)),D=r.filter(e=>"anthropic-compatible"===e.type).map(e=>({id:e.id,name:e.name||"Anthropic Compatible",color:"#D97757",textIcon:"AC"})).filter(e=>U(e.name)),L=R(Object.entries(c.zN).filter(([,e])=>!e.hidden&&U(e.name)),"oauth"),M=Object.entries(p.IS).filter(([,e])=>!e.hidden&&U(e.name)).sort(([,e],[,t])=>!!t.noAuth-!!e.noAuth),F=R(Object.entries(p.nJ).filter(([,e])=>!e.hidden&&U(e.name)&&(e.serviceKinds??["llm"]).includes("llm")),"freeTier").sort(([,e],[,t])=>!!t.noAuth-!!e.noAuth),J=Object.entries(c.fg).filter(([,e])=>!e.hidden&&(e.serviceKinds??["llm"]).includes("llm")&&U(e.name)).sort(([e,t],[r,s])=>{let a=_(e,"apikey").total>0?0:1,l=_(r,"apikey").total>0?0:1;return a!==l?a-l:(t.name||"").localeCompare(s.name||"")}),K=!!E.trim(),W=K||d?J:J.slice(0,20),B=J.length-20;if(i)return(0,s.jsxs)("div",{className:"flex flex-col gap-8",children:[(0,s.jsx)(n.Qv,{}),(0,s.jsx)(n.Qv,{})]});let Q=L.length>0||M.length>0||F.length>0||J.length>0||q.length>0||D.length>0;return(0,s.jsxs)("div",{className:"flex min-w-0 flex-col gap-6 px-1 sm:px-0",children:[!Q&&(0,s.jsxs)("div",{className:"text-center py-8 border border-dashed border-border rounded-xl",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-[32px] text-text-muted mb-2",children:"search_off"}),(0,s.jsx)("p",{className:"text-text-muted text-sm",children:"No providers match your search"})]}),(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,s.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[(0,s.jsxs)("h2",{className:"text-lg sm:text-xl font-semibold flex items-center gap-2 leading-tight",children:["Custom Providers (OpenAI/Anthropic Compatible)"," "]}),(0,s.jsxs)("div",{className:"grid grid-cols-1 gap-2 sm:flex sm:w-auto",children:[(0,s.jsx)(n.$n,{size:"sm",icon:"add",onClick:()=>j(!0),className:"w-full sm:w-auto",children:"Add Anthropic Compatible"}),(0,s.jsx)(n.$n,{size:"sm",variant:"secondary",icon:"add",onClick:()=>b(!0),className:"w-full !bg-white !text-black hover:!bg-gray-100 sm:w-auto",children:"Add OpenAI Compatible"})]})]}),0===q.length&&0===D.length?(0,s.jsxs)("div",{className:"flex items-center justify-center gap-2 py-2 border border-dashed border-border rounded-xl text-text-muted text-sm",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"extension"}),(0,s.jsx)("span",{children:"No custom providers — use buttons above to add OpenAI/Anthropic compatible endpoints"})]}):(0,s.jsx)("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2 sm:gap-4 lg:grid-cols-3 xl:grid-cols-4",children:[...q,...D].map(e=>(0,s.jsx)(P,{providerId:e.id,provider:e,stats:_(e.id,"apikey"),authType:"compatible",onToggle:t=>z(e.id,"apikey",t)},e.id))})]}),L.length>0&&(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,s.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[(0,s.jsx)("h2",{className:"text-lg sm:text-xl font-semibold flex items-center gap-2 leading-tight",children:"OAuth Providers"}),(0,s.jsxs)("div",{className:"flex w-full flex-col gap-2 sm:w-auto sm:flex-row sm:items-center",children:[(0,s.jsx)(y,{}),(0,s.jsxs)("button",{onClick:()=>H("oauth"),disabled:!!N,className:`flex w-full items-center justify-center gap-1.5 rounded-lg border px-3 py-2 text-xs font-medium transition-colors sm:w-auto sm:py-1.5 ${"oauth"===N?"bg-primary/20 border-primary/40 text-primary animate-pulse":"bg-bg border-border text-text-muted hover:text-text-main hover:border-primary/40"}`,title:"Test all OAuth connections","aria-label":"Test all OAuth connections",children:[(0,s.jsx)("span",{className:`material-symbols-outlined text-[14px]${"oauth"===N?" animate-spin":""}`,children:"play_arrow"}),"oauth"===N?"Testing...":"Test All"]})]})]}),(0,s.jsx)("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2 sm:gap-4 lg:grid-cols-3 xl:grid-cols-4",children:L.map(([e,t])=>(0,s.jsx)(I,{providerId:e,provider:t,stats:_(e,"oauth"),authType:"oauth",onToggle:t=>z(e,"oauth",t)},e))})]}),(M.length>0||F.length>0)&&(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,s.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[(0,s.jsx)("h2",{className:"text-lg sm:text-xl font-semibold flex items-center gap-2 leading-tight",children:"Free Tier Providers"}),(0,s.jsxs)("button",{onClick:()=>H("free"),disabled:!!N,className:`flex w-full items-center justify-center gap-1.5 rounded-lg border px-3 py-2 text-xs font-medium transition-colors sm:w-auto sm:py-1.5 ${"free"===N?"bg-primary/20 border-primary/40 text-primary animate-pulse":"bg-bg border-border text-text-muted hover:text-text-main hover:border-primary/40"}`,title:"Test all Free connections","aria-label":"Test all Free provider connections",children:[(0,s.jsx)("span",{className:`material-symbols-outlined text-[14px]${"free"===N?" animate-spin":""}`,children:"play_arrow"}),"free"===N?"Testing...":"Test All"]})]}),(0,s.jsxs)("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2 sm:gap-4 lg:grid-cols-3 xl:grid-cols-4",children:[M.map(([e,t])=>{let r="kiro"===e?["oauth","apikey","api_key"]:"oauth";return(0,s.jsx)(I,{providerId:e,provider:t,stats:_(e,r),authType:"free",onToggle:t=>z(e,r,t)},e)}),F.map(([e,t])=>{let r=!!t.hasOAuth||"oauth"===t.authType||(t.authModes||[]).includes("oauth"),a=r?I:P,l=["oauth","apikey","api_key","cookie"];return(0,s.jsx)(a,{providerId:e,provider:t,stats:_(e,l),authType:r?"oauth":"apikey",onToggle:t=>z(e,l,t)},e)})]})]}),J.length>0&&(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,s.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[(0,s.jsxs)("h2",{className:"text-lg sm:text-xl font-semibold flex items-center gap-2 leading-tight",children:["API Key Providers"," "]}),(0,s.jsxs)("button",{onClick:()=>H("apikey"),disabled:!!N,className:`flex w-full items-center justify-center gap-1.5 rounded-lg border px-3 py-2 text-xs font-medium transition-colors sm:w-auto sm:py-1.5 ${"apikey"===N?"bg-primary/20 border-primary/40 text-primary animate-pulse":"bg-bg border-border text-text-muted hover:text-text-main hover:border-primary/40"}`,title:"Test all API Key connections","aria-label":"Test all API Key connections",children:[(0,s.jsx)("span",{className:`material-symbols-outlined text-[14px]${"apikey"===N?" animate-spin":""}`,children:"play_arrow"}),"apikey"===N?"Testing...":"Test All"]})]}),(0,s.jsx)("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2 sm:gap-4 lg:grid-cols-3 xl:grid-cols-4",children:W.map(([e,t])=>(0,s.jsx)(P,{providerId:e,provider:t,stats:_(e,"apikey"),authType:"apikey",onToggle:t=>z(e,"apikey",t)},e))}),!K&&!d&&B>0&&(0,s.jsxs)("button",{onClick:()=>m(!0),className:"flex w-full items-center justify-center gap-1.5 rounded-lg border border-dashed border-primary/40 px-3 py-2.5 text-sm font-medium text-primary transition-colors hover:border-primary hover:bg-primary/5",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"expand_more"}),(0,g.Tl)("Show all")," ",J.length," ",(0,g.Tl)("providers")]})]}),(0,s.jsx)(C,{variant:"openai",isOpen:u,onClose:()=>b(!1),onCreated:e=>{l(t=>[...t,e]),b(!1)}}),(0,s.jsx)(C,{variant:"anthropic",isOpen:v,onClose:()=>j(!1),onCreated:e=>{l(t=>[...t,e]),j(!1)}}),k&&(0,s.jsxs)("div",{className:"fixed inset-0 z-50 flex items-start justify-center px-3 pt-[6vh] sm:pt-[10vh]",onClick:()=>T(null),children:[(0,s.jsx)("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm"}),(0,s.jsxs)("div",{className:"relative bg-surface border border-border rounded-xl w-full max-w-[600px] max-h-[86vh] sm:max-h-[80vh] overflow-y-auto shadow-2xl",onClick:e=>e.stopPropagation(),children:[(0,s.jsxs)("div",{className:"sticky top-0 z-10 flex items-center justify-between px-5 py-3 border-b border-border bg-surface/95 backdrop-blur-sm rounded-t-xl",children:[(0,s.jsx)("h3",{className:"font-semibold",children:"Test Results"}),(0,s.jsx)("button",{onClick:()=>T(null),className:"p-1 rounded-lg hover:bg-bg text-text-muted hover:text-text-main transition-colors","aria-label":"Close test results",children:(0,s.jsx)("span",{className:"material-symbols-outlined text-lg",children:"close"})})]}),(0,s.jsx)("div",{className:"p-5",children:(0,s.jsx)(O,{results:k})})]})]})]})}function I({providerId:e,provider:t,stats:r,authType:a,onToggle:l}){let{connected:i,error:d,errorCode:c,errorTime:p,allDisabled:m}=r,x=!!t.noAuth;return(0,s.jsx)(u(),{href:`/dashboard/providers/${e}`,className:"group min-w-0",children:(0,s.jsx)(n.Zp,{padding:"xs",className:`h-full hover:bg-black/[0.01] dark:hover:bg-white/[0.01] transition-colors cursor-pointer ${m?"opacity-50":""}`,children:(0,s.jsxs)("div",{className:"flex min-w-0 items-center justify-between gap-3",children:[(0,s.jsxs)("div",{className:"flex min-w-0 items-center gap-3",children:[(0,s.jsx)("div",{className:"size-8 shrink-0 rounded-lg flex items-center justify-center",style:{backgroundColor:`${t.color?.length>7?t.color:t.color+"15"}`},children:(0,s.jsx)(o.A,{src:`/providers/${t.id}.png`,alt:t.name,size:30,className:"object-contain rounded-lg max-w-[32px] max-h-[32px]",fallbackText:t.textIcon||t.id.slice(0,2).toUpperCase(),fallbackColor:t.color})}),(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsx)("h3",{className:"truncate font-semibold",children:t.name}),(0,s.jsx)("div",{className:"flex min-w-0 items-center gap-1.5 text-xs flex-wrap",children:m?(0,s.jsx)(n.Ex,{variant:"default",size:"sm",children:(0,s.jsxs)("span",{className:"flex items-center gap-1",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-[12px]",children:"pause_circle"}),"Disabled"]})}):x?(0,s.jsx)(n.Ex,{variant:"success",size:"sm",dot:!0,children:"Ready"}):(0,s.jsxs)(s.Fragment,{children:[T(i,d,c),p&&(0,s.jsx)("span",{className:"text-text-muted",children:p})]})})]})]}),(0,s.jsx)("div",{className:"flex shrink-0 items-center gap-2",children:r.total>0&&(0,s.jsx)("div",{className:"opacity-100 transition-opacity sm:opacity-0 sm:group-hover:opacity-100",onClick:e=>{e.preventDefault(),e.stopPropagation(),l(!!m)},children:(0,s.jsx)(n.lM,{size:"sm",checked:!m,onChange:()=>{},title:m?"Enable provider":"Disable provider"})})})]})})})}function P({providerId:e,provider:t,stats:r,authType:a,onToggle:l}){let{connected:i,error:c,errorCode:m,errorTime:x,allDisabled:h}=r,f=e.startsWith(p.JH),g=e.startsWith(p.DI);return(0,s.jsx)(u(),{href:`/dashboard/providers/${e}`,className:"group min-w-0",children:(0,s.jsx)(n.Zp,{padding:"xs",className:`h-full hover:bg-black/[0.01] dark:hover:bg-white/[0.01] transition-colors cursor-pointer ${h?"opacity-50":""}`,children:(0,s.jsxs)("div",{className:"flex min-w-0 items-center justify-between gap-3",children:[(0,s.jsxs)("div",{className:"flex min-w-0 items-center gap-3",children:[(0,s.jsx)("div",{className:"size-8 shrink-0 rounded-lg flex items-center justify-center",style:{backgroundColor:`${t.color?.length>7?t.color:t.color+"15"}`},children:(0,s.jsx)(o.A,{src:f&&t.apiType?"responses"===t.apiType?"/providers/oai-r.png":"/providers/oai-cc.png":g?"/providers/anthropic-m.png":(0,d.HY)(t.id),alt:t.name,size:30,className:"object-contain rounded-lg max-w-[30px] max-h-[30px]",fallbackText:t.textIcon||t.id.slice(0,2).toUpperCase(),fallbackColor:t.color})}),(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsx)("h3",{className:"truncate font-semibold",children:t.name}),(0,s.jsx)("div",{className:"flex min-w-0 items-center gap-1.5 text-xs flex-wrap",children:h?(0,s.jsx)(n.Ex,{variant:"default",size:"sm",children:(0,s.jsxs)("span",{className:"flex items-center gap-1",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-[12px]",children:"pause_circle"}),"Disabled"]})}):(0,s.jsxs)(s.Fragment,{children:[T(i,c,m),f&&(0,s.jsx)(n.Ex,{variant:"default",size:"sm",children:"responses"===t.apiType?"Responses":"Chat"}),g&&(0,s.jsx)(n.Ex,{variant:"default",size:"sm",children:"Messages"}),x&&(0,s.jsx)("span",{className:"text-text-muted",children:x})]})})]})]}),(0,s.jsx)("div",{className:"flex shrink-0 items-center gap-2",children:r.total>0&&(0,s.jsx)("div",{className:"opacity-100 transition-opacity sm:opacity-0 sm:group-hover:opacity-100",onClick:e=>{e.preventDefault(),e.stopPropagation(),l(!!h)},children:(0,s.jsx)(n.lM,{size:"sm",checked:!h,onChange:()=>{},title:h?"Enable provider":"Disable provider"})})})]})})})}function O({results:e}){if(e.error&&!e.results)return(0,s.jsxs)("div",{className:"text-center py-6",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-red-500 text-[32px] mb-2 block",children:"error"}),(0,s.jsx)("p",{className:"text-sm text-red-400",children:e.error})]});let{summary:t,mode:r}=e,a=e.results||[];return(0,s.jsxs)("div",{className:"flex min-w-0 flex-col gap-3",children:[t&&(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-2 text-xs mb-1 sm:gap-3",children:[(0,s.jsxs)("span",{className:"text-text-muted",children:[{oauth:"OAuth",free:"Free",apikey:"API Key",provider:"Provider",all:"All"}[r]||r," Test"]}),(0,s.jsxs)("span",{className:"px-2 py-0.5 rounded bg-emerald-500/15 text-emerald-400 font-medium",children:[t.passed," passed"]}),t.failed>0&&(0,s.jsxs)("span",{className:"px-2 py-0.5 rounded bg-red-500/15 text-red-400 font-medium",children:[t.failed," failed"]}),(0,s.jsxs)("span",{className:"text-text-muted sm:ml-auto",children:[t.total," tested"]})]}),a.map((e,t)=>(0,s.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-2 rounded-lg bg-black/[0.03] px-3 py-2 text-xs dark:bg-white/[0.03] sm:flex-nowrap",children:[(0,s.jsx)("span",{className:`material-symbols-outlined text-[16px] ${e.valid?"text-emerald-500":"text-red-500"}`,children:e.valid?"check_circle":"error"}),(0,s.jsxs)("div",{className:"min-w-0 flex-[1_1_160px]",children:[(0,s.jsx)("span",{className:"block truncate font-medium sm:inline",children:e.connectionName}),(0,s.jsxs)("span",{className:"block truncate text-text-muted sm:ml-1.5 sm:inline",children:["(",e.provider,")"]})]}),void 0!==e.latencyMs&&(0,s.jsxs)("span",{className:"shrink-0 text-text-muted font-mono tabular-nums",children:[e.latencyMs,"ms"]}),(0,s.jsx)("span",{className:`shrink-0 text-[10px] uppercase font-bold px-1.5 py-0.5 rounded ${e.valid?"bg-emerald-500/15 text-emerald-400":"bg-red-500/15 text-red-400"}`,children:e.valid?"OK":e.diagnosis?.type||"ERROR"})]},e.connectionId||t)),0===a.length&&(0,s.jsx)("div",{className:"text-center py-4 text-text-muted text-sm",children:"No active connections found for this group."})]})}C.propTypes={variant:i().oneOf(["openai","anthropic"]).isRequired,isOpen:i().bool.isRequired,onClose:i().func.isRequired,onCreated:i().func.isRequired},I.propTypes={providerId:i().string.isRequired,provider:i().shape({id:i().string.isRequired,name:i().string.isRequired,color:i().string,textIcon:i().string}).isRequired,stats:i().shape({connected:i().number,error:i().number,errorCode:i().string,errorTime:i().string}).isRequired,authType:i().string,onToggle:i().func},P.propTypes={providerId:i().string.isRequired,provider:i().shape({id:i().string.isRequired,name:i().string.isRequired,color:i().string,textIcon:i().string,apiType:i().string}).isRequired,stats:i().shape({connected:i().number,error:i().number,errorCode:i().string,errorTime:i().string}).isRequired,authType:i().string,onToggle:i().func},O.propTypes={results:i().shape({mode:i().string,results:i().array,summary:i().shape({total:i().number,passed:i().number,failed:i().number}),error:i().string}).isRequired}}},e=>{e.O(0,[8010,8105,1321,801,5497,8441,3794,7358],()=>e(e.s=69671)),_N_E=e.O()}]);
package/app/CHANGELOG.md CHANGED
@@ -17,8 +17,10 @@
17
17
  - Updated Skills dashboard display name to `EzRouter (Entry)`.
18
18
 
19
19
  ## Fixes
20
- - **Provider Details & Accounts**:
21
- - Fixed template string syntax in `src/app/(dashboard)/dashboard/providers/[id]/page.js` (`fetchConnections` was sending literal string `"${encodeURIComponent(providerId)}"` instead of evaluating `providerId`, causing 0 accounts to show in provider connection list).
20
+ - **Provider Details & Pagination**:
21
+ - Restored `Pagination` import in `src/app/(dashboard)/dashboard/providers/[id]/page.js`, fixing runtime render crash when a provider has >10 accounts (e.g. Antigravity with 11 accounts).
22
+ - Fixed `getProviderStats` and `freeTierEntries` in `src/app/(dashboard)/dashboard/providers/page.js` to dynamically match all valid connection types (`oauth`, `apikey`, `api_key`, `cookie`), ensuring accurate account counts on overview cards.
23
+ - Fixed template string syntax in `src/app/(dashboard)/dashboard/providers/[id]/page.js` (`fetchConnections` was sending literal string `"${encodeURIComponent(providerId)}"` instead of evaluating `providerId`).
22
24
  - **CLI Tools & Media Combo Configurations**:
23
25
  - Updated legacy hardcoded port `20128` fallbacks to dynamic `window.location.origin` / `20126` in Media Combo details, DeepSeek TUI, Hermes, Grok Build, OpenClaw, JCode, and CLI tools cards.
24
26
  - Updated JCode settings route to recognize both port 20126 and 20128 configurations.
package/app/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ezrouter-app",
3
- "version": "0.5.69",
3
+ "version": "0.5.71",
4
4
  "description": "9Router web dashboard",
5
5
  "private": true,
6
6
  "scripts": {
@@ -17,8 +17,10 @@
17
17
  - Updated Skills dashboard display name to `EzRouter (Entry)`.
18
18
 
19
19
  ## Fixes
20
- - **Provider Details & Accounts**:
21
- - Fixed template string syntax in `src/app/(dashboard)/dashboard/providers/[id]/page.js` (`fetchConnections` was sending literal string `"${encodeURIComponent(providerId)}"` instead of evaluating `providerId`, causing 0 accounts to show in provider connection list).
20
+ - **Provider Details & Pagination**:
21
+ - Restored `Pagination` import in `src/app/(dashboard)/dashboard/providers/[id]/page.js`, fixing runtime render crash when a provider has >10 accounts (e.g. Antigravity with 11 accounts).
22
+ - Fixed `getProviderStats` and `freeTierEntries` in `src/app/(dashboard)/dashboard/providers/page.js` to dynamically match all valid connection types (`oauth`, `apikey`, `api_key`, `cookie`), ensuring accurate account counts on overview cards.
23
+ - Fixed template string syntax in `src/app/(dashboard)/dashboard/providers/[id]/page.js` (`fetchConnections` was sending literal string `"${encodeURIComponent(providerId)}"` instead of evaluating `providerId`).
22
24
  - **CLI Tools & Media Combo Configurations**:
23
25
  - Updated legacy hardcoded port `20128` fallbacks to dynamic `window.location.origin` / `20126` in Media Combo details, DeepSeek TUI, Hermes, Grok Build, OpenClaw, JCode, and CLI tools cards.
24
26
  - Updated JCode settings route to recognize both port 20126 and 20128 configurations.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rabbi696/ezrouter",
3
- "version": "0.5.69",
3
+ "version": "0.5.71",
4
4
  "description": "EzRouter CLI - Start and manage EzRouter server (default port 20126)",
5
5
  "bin": {
6
6
  "ezrouter": "./cli.js"
@@ -1 +0,0 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[8460],{28915:(e,t,r)=>{"use strict";r.d(t,{E2:()=>s,gs:()=>a});function s(e){if(!e)return null;let t=e.match(/\b([45]\d{2})\b/);return t?t[1]:"ERR"}function a(e){if(!e)return"";let t=Math.floor((Date.now()-new Date(e).getTime())/6e4);if(t<1)return"just now";if(t<60)return`${t}m ago`;let r=Math.floor(t/60);if(r<24)return`${r}h ago`;let s=Math.floor(r/24);return`${s}d ago`}r(8247)},69671:(e,t,r)=>{Promise.resolve().then(r.bind(r,71720))},71720:(e,t,r)=>{"use strict";r.r(t),r.d(t,{default:()=>A});var s=r(95155),a=r(12115),l=r(14051),i=r.n(l),n=r(35497),o=r(57250),d=r(8247),c=r(90620),m=r(88105),p=r(98500),x=r.n(p),u=r(28915),h=r(65921),f=r(38003),g=r(73006);let b={available:{icon:"check_circle",color:"#22c55e",label:"Available"},cooldown:{icon:"schedule",color:"#f59e0b",label:"Cooldown"},unavailable:{icon:"error",color:"#ef4444",label:"Unavailable"},unknown:{icon:"help",color:"#6b7280",label:"Unknown"}};function y(){let[e,t]=(0,a.useState)(null),[r,l]=(0,a.useState)(!0),[i,o]=(0,a.useState)(!1),[d,c]=(0,a.useState)(null),m=(0,a.useRef)(null),p=(0,h.i)(),x=(0,a.useCallback)(async()=>{try{let e=await fetch("/api/models/availability");if(e.ok){let r=await e.json();t(r)}}catch{}finally{l(!1)}},[]);(0,a.useEffect)(()=>{x();let e=setInterval(x,3e4);return()=>clearInterval(e)},[x]),(0,a.useEffect)(()=>{let e=e=>{m.current&&!m.current.contains(e.target)&&o(!1)};return i&&document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[i]);let u=async(e,t)=>{c(`${e}:${t}`);try{(await fetch("/api/models/availability",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"clearCooldown",provider:e,model:t})})).ok?(p.success(`Cooldown cleared for ${t}`),await x()):p.error("Failed to clear cooldown")}catch{p.error("Failed to clear cooldown")}finally{c(null)}};if(r)return null;let f=e?.models||[],g=0===(e?.unavailableCount||f.filter(e=>"available"!==e.status).length),y={};return f.forEach(e=>{if("available"===e.status)return;let t=e.provider||"unknown";y[t]||(y[t]=[]),y[t].push(e)}),(0,s.jsx)("div",{className:"relative",ref:m,children:i&&(0,s.jsxs)("div",{className:"absolute top-full right-0 mt-2 w-80 bg-surface border border-border rounded-xl shadow-2xl z-50 overflow-hidden",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border bg-bg",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-[16px]",style:{color:g?"#22c55e":"#f59e0b"},children:g?"verified":"warning"}),(0,s.jsx)("span",{className:"text-sm font-semibold text-text-main",children:"Model Status"})]}),(0,s.jsx)("button",{onClick:x,className:"p-1 rounded-lg hover:bg-surface text-text-muted hover:text-text-main transition-colors",title:"Refresh",children:(0,s.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"refresh"})})]}),(0,s.jsx)("div",{className:"px-4 py-3 max-h-60 overflow-y-auto",children:g?(0,s.jsx)("p",{className:"text-sm text-text-muted text-center py-2",children:"All models are responding normally."}):(0,s.jsx)("div",{className:"flex flex-col gap-2.5",children:Object.entries(y).map(([e,t])=>(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"text-xs font-semibold text-text-main mb-1.5 capitalize",children:e}),(0,s.jsx)("div",{className:"flex flex-col gap-1",children:t.map(e=>{let t=b[e.status]||b.unknown,r=d===`${e.provider}:${e.model}`;return(0,s.jsxs)("div",{className:"flex items-center justify-between px-2.5 py-1.5 rounded-lg bg-surface/30",children:[(0,s.jsxs)("div",{className:"flex items-center gap-1.5 min-w-0",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-[14px] shrink-0",style:{color:t.color},children:t.icon}),(0,s.jsx)("span",{className:"font-mono text-xs text-text-main truncate",children:e.model})]}),"cooldown"===e.status&&(0,s.jsx)(n.$n,{size:"sm",variant:"ghost",onClick:()=>u(e.provider,e.model),disabled:r,className:"text-[10px] px-1.5! py-0.5! ml-2",children:r?"...":"Clear"})]},`${e.provider}-${e.model}`)})})]},e))})})]})})}let v={openai:{title:"Add OpenAI Compatible",type:"openai-compatible",defaultBaseUrl:"https://api.openai.com/v1",namePlaceholder:"OpenAI Compatible (Prod)",prefixPlaceholder:"oc-prod",baseUrlHint:"Use the base URL (ending in /v1) for your OpenAI-compatible API.",modelIdPlaceholder:"e.g. gpt-4, claude-3-opus",errorLabel:"OpenAI Compatible",hasApiType:!0},anthropic:{title:"Add Anthropic Compatible",type:"anthropic-compatible",defaultBaseUrl:"https://api.anthropic.com/v1",namePlaceholder:"Anthropic Compatible (Prod)",prefixPlaceholder:"ac-prod",baseUrlHint:"Use the base URL (ending in /v1) for your Anthropic-compatible API. The system will append /messages.",modelIdPlaceholder:"e.g. claude-3-opus",errorLabel:"Anthropic Compatible",hasApiType:!1}},j=[{value:"chat",label:"Chat Completions"},{value:"responses",label:"Responses API"}],N=[{value:"default",label:"Default"},{value:"claude-cli",label:"Claude CLI"},{value:"codex-cli",label:"Codex CLI"},{value:"openclaw",label:"OpenClaw"},{value:"custom",label:"Custom Headers"}],w=new Set(["authorization","x-api-key","api-key","cookie"]);function C(e){let t=String(e||"").trim();if(!t)return{headers:{}};try{let e;if(t.startsWith("{")){let r=JSON.parse(t);if(!r||"object"!=typeof r||Array.isArray(r))return{error:"Use a JSON object or Header: value lines."};e=Object.entries(r)}else for(let r of(e=[],t.split(/\r?\n/))){let t=r.trim();if(!t||t.startsWith("#"))continue;let s=t.indexOf(":");if(s<=0)return{error:"Each custom header line must use Header: value."};e.push([t.slice(0,s),t.slice(s+1)])}let r={};for(let[t,s]of e){let e=String(t||"").trim(),a=String(s||"").trim();!e||!a||w.has(e.toLowerCase())||(r[e]=a)}return{headers:r}}catch{return{error:"Use valid JSON or Header: value lines."}}}function k({variant:e,isOpen:t,onClose:r,onCreated:l}){let i=v[e],o=()=>({name:"",prefix:"",...i.hasApiType?{apiType:"chat"}:{},baseUrl:i.defaultBaseUrl,clientIdentityProfile:"default",clientIdentityHeadersText:""}),[d,c]=(0,a.useState)(o),[m,p]=(0,a.useState)(!1),[x,u]=(0,a.useState)(""),[h,f]=(0,a.useState)(""),[g,b]=(0,a.useState)(!1),[y,w]=(0,a.useState)(null);(0,a.useEffect)(()=>{i.hasApiType?c(e=>({...e,baseUrl:i.defaultBaseUrl})):t&&(w(null),u(""),f(""))},[i.hasApiType?d.apiType:t]);let T=async()=>{if(!d.name.trim()||!d.prefix.trim()||!d.baseUrl.trim())return;let e="custom"===d.clientIdentityProfile?C(d.clientIdentityHeadersText):{headers:{}};if(e.error)return void w({valid:!1,error:e.error});p(!0);try{let t=await fetch("/api/provider-nodes",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:d.name,prefix:d.prefix,...i.hasApiType?{apiType:d.apiType}:{},baseUrl:d.baseUrl,type:i.type,clientIdentityProfile:d.clientIdentityProfile,clientIdentityHeaders:e.headers})}),r=await t.json();t.ok&&(l(r.node),c(o()),u(""),w(null))}catch(e){console.log(`Error creating ${i.errorLabel} node:`,e)}finally{p(!1)}},A=async()=>{let e="custom"===d.clientIdentityProfile?C(d.clientIdentityHeadersText):{headers:{}};if(e.error)return void w({valid:!1,error:e.error});b(!0);try{let t=await fetch("/api/provider-nodes/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:d.baseUrl,apiKey:x,type:i.type,modelId:h.trim()||void 0,clientIdentityProfile:d.clientIdentityProfile,clientIdentityHeaders:e.headers})}),r=await t.json();w(r)}catch{w({valid:!1,error:"Network error"})}finally{b(!1)}};return(0,s.jsx)(n.aF,{isOpen:t,title:i.title,onClose:r,children:(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,s.jsx)(n.pd,{label:"Name",value:d.name,onChange:e=>c({...d,name:e.target.value}),placeholder:i.namePlaceholder,hint:"Required. A friendly label for this node."}),(0,s.jsx)(n.pd,{label:"Prefix",value:d.prefix,onChange:e=>c({...d,prefix:e.target.value}),placeholder:i.prefixPlaceholder,hint:"Required. Used as the provider prefix for model IDs."}),i.hasApiType&&(0,s.jsx)(n.l6,{label:"API Type",options:j,value:d.apiType,onChange:e=>c({...d,apiType:e.target.value})}),(0,s.jsx)(n.pd,{label:"Base URL",value:d.baseUrl,onChange:e=>c({...d,baseUrl:e.target.value}),placeholder:i.defaultBaseUrl,hint:i.baseUrlHint}),(0,s.jsx)(n.l6,{label:"Client Identity",options:N,value:d.clientIdentityProfile,onChange:e=>c({...d,clientIdentityProfile:e.target.value}),hint:"Optional. Adds client fingerprint headers for compatible gateways."}),"custom"===d.clientIdentityProfile&&(0,s.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,s.jsx)("label",{className:"text-sm font-medium text-text-main",children:"Custom Headers"}),(0,s.jsx)("textarea",{value:d.clientIdentityHeadersText,onChange:e=>c({...d,clientIdentityHeadersText:e.target.value}),placeholder:'{\n "User-Agent": "custom/1.0"\n}',rows:5,className:"w-full resize-y rounded-[10px] border border-transparent bg-surface-2 px-3 py-2.5 text-[16px] text-text-main placeholder-text-muted/70 transition-all duration-150 focus:border-brand-500/40 focus:outline-none focus:ring-2 focus:ring-brand-500/30 sm:text-sm"}),(0,s.jsx)("p",{className:"text-xs text-text-muted",children:"JSON object or Header: value lines. Auth headers are ignored."})]}),(0,s.jsx)(n.pd,{label:"API Key (for Check)",type:"password",value:x,onChange:e=>u(e.target.value)}),(0,s.jsx)(n.pd,{label:"Model ID (optional)",value:h,onChange:e=>f(e.target.value),placeholder:i.modelIdPlaceholder,hint:"If provider lacks /models endpoint, enter a model ID to validate via chat/completions instead."}),(0,s.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center",children:[(0,s.jsx)(n.$n,{onClick:A,disabled:!x||g||!d.baseUrl.trim(),variant:"secondary",className:"w-full sm:w-auto",children:g?"Checking...":"Check"}),(()=>{if(!y)return null;let{valid:e,error:t,method:r}=y;return e?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(n.Ex,{variant:"success",children:"Valid"}),"chat"===r&&(0,s.jsx)("span",{className:"text-sm text-text-muted",children:"(via inference test)"})]}):(0,s.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,s.jsx)(n.Ex,{variant:"error",children:"Invalid"}),t&&(0,s.jsx)("span",{className:"text-sm text-red-500",children:t})]})})()]}),(0,s.jsxs)("div",{className:"flex flex-col gap-2 sm:flex-row",children:[(0,s.jsx)(n.$n,{onClick:T,fullWidth:!0,disabled:!d.name.trim()||!d.prefix.trim()||!d.baseUrl.trim()||m,children:m?"Creating...":"Create"}),(0,s.jsx)(n.$n,{onClick:r,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})})}function T(e,t,r){let a=[];if(e>0&&a.push((0,s.jsxs)(n.Ex,{variant:"success",size:"sm",dot:!0,children:[e," Connected"]},"connected")),t>0){let e=r?`${t} Error (${r})`:`${t} Error`;a.push((0,s.jsx)(n.Ex,{variant:"error",size:"sm",dot:!0,children:e},"error"))}return 0===a.length?(0,s.jsx)("span",{className:"text-text-muted",children:"No connections"}):a}function A(){let[e,t]=(0,a.useState)([]),[r,l]=(0,a.useState)([]),[i,o]=(0,a.useState)(!0),[d,p]=(0,a.useState)(!1),[x,b]=(0,a.useState)(!1),[v,j]=(0,a.useState)(!1),[N,w]=(0,a.useState)(null),[C,T]=(0,a.useState)(null),A=(0,h.i)(),E=(0,f.C)(e=>e.query),S=(0,f.C)(e=>e.register),$=(0,f.C)(e=>e.unregister);(0,a.useEffect)(()=>(S("Search providers..."),()=>$()),[S,$]);let U=e=>!E.trim()||e.toLowerCase().includes(E.trim().toLowerCase()),R=(e,t)=>[...e].sort(([e,r],[s,a])=>{let l=r.priority??999,i=a.priority??999;if(l!==i)return l-i;let n=_(e,t),o=_(s,t),d=+(n.connected>0),c=+(o.connected>0);return d!==c?c-d:(r.name||"").localeCompare(a.name||"")});(0,a.useEffect)(()=>{(async()=>{try{let[e,r]=await Promise.all([fetch("/api/providers"),fetch("/api/provider-nodes")]),s=await e.json(),a=await r.json();e.ok&&t(s.connections||[]),r.ok&&l(a.nodes||[])}catch(e){console.log("Error fetching data:",e)}finally{o(!1)}})()},[]);let _=(t,r)=>{let s=Array.isArray(r)?r:[r],a=e.filter(e=>e.provider===t&&s.includes(e.authType)),l=e=>{let t=Object.entries(e).some(([e,t])=>e.startsWith("modelLock_")&&t&&new Date(t).getTime()>Date.now());return"unavailable"!==e.testStatus||t?e.testStatus:"active"},i=a.filter(e=>{let t=l(e);return"active"===t||"success"===t}).length,n=a.filter(e=>{let t=l(e);return"error"===t||"expired"===t||"unavailable"===t}),o=n.length,d=a.length,c=d>0&&a.every(e=>!1===e.isActive),m=n.sort((e,t)=>new Date(t.lastErrorAt||0)-new Date(e.lastErrorAt||0))[0];return{connected:i,error:o,total:d,errorCode:m?function(e){if(!e)return null;let t=e.lastErrorType;if("runtime_error"===t)return"RUNTIME";if("upstream_auth_error"===t||"auth_missing"===t||"token_refresh_failed"===t||"token_expired"===t)return"AUTH";if("upstream_rate_limited"===t)return"429";if("upstream_unavailable"===t)return"5XX";if("network_error"===t)return"NET";let r=Number(e.errorCode);if(Number.isFinite(r)&&r>=400)return String(r);let s=(0,u.E2)(e.lastError);if("401"===s||"403"===s)return"AUTH";if(s&&"ERR"!==s)return s;let a=(e.lastError||"").toLowerCase();return a.includes("runtime")||a.includes("not runnable")||a.includes("not installed")?"RUNTIME":a.includes("invalid api key")||a.includes("token invalid")||a.includes("revoked")||a.includes("unauthorized")?"AUTH":"ERR"}(m):null,errorTime:m?.lastErrorAt?(0,u.gs)(m.lastErrorAt):null,allDisabled:c}},z=async(r,s,a)=>{let l=Array.isArray(s)?s:[s],i=e=>e.provider===r&&l.includes(e.authType),n=e.filter(i);t(e=>e.map(e=>i(e)?{...e,isActive:a}:e)),await Promise.allSettled(n.map(e=>fetch(`/api/providers/${e.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({isActive:a})})))},H=async(e,t=null)=>{if(!N){w("provider"===e?t:e),T(null);try{let r=await fetch("/api/providers/test-batch",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mode:e,providerId:t})}),s=await r.json();if(T(s),s.summary){let{passed:e,failed:t,total:r}=s.summary;0===t?A.success(`All ${r} tests passed`):A.warning(`${e}/${r} passed, ${t} failed`)}}catch(e){T({error:"Test request failed"}),A.error("Provider test failed")}finally{w(null)}}},q=r.filter(e=>"openai-compatible"===e.type).map(e=>({id:e.id,name:e.name||"OpenAI Compatible",color:"#10A37F",textIcon:"OC",apiType:e.apiType})).filter(e=>U(e.name)),D=r.filter(e=>"anthropic-compatible"===e.type).map(e=>({id:e.id,name:e.name||"Anthropic Compatible",color:"#D97757",textIcon:"AC"})).filter(e=>U(e.name)),L=R(Object.entries(c.zN).filter(([,e])=>!e.hidden&&U(e.name)),"oauth"),F=Object.entries(m.IS).filter(([,e])=>!e.hidden&&U(e.name)).sort(([,e],[,t])=>!!t.noAuth-!!e.noAuth),M=R(Object.entries(m.nJ).filter(([,e])=>!e.hidden&&U(e.name)&&(e.serviceKinds??["llm"]).includes("llm")),"freeTier").sort(([,e],[,t])=>!!t.noAuth-!!e.noAuth),J=Object.entries(c.fg).filter(([,e])=>!e.hidden&&(e.serviceKinds??["llm"]).includes("llm")&&U(e.name)).sort(([e,t],[r,s])=>{let a=_(e,"apikey").total>0?0:1,l=_(r,"apikey").total>0?0:1;return a!==l?a-l:(t.name||"").localeCompare(s.name||"")}),K=!!E.trim(),W=K||d?J:J.slice(0,20),B=J.length-20;if(i)return(0,s.jsxs)("div",{className:"flex flex-col gap-8",children:[(0,s.jsx)(n.Qv,{}),(0,s.jsx)(n.Qv,{})]});let Q=L.length>0||F.length>0||M.length>0||J.length>0||q.length>0||D.length>0;return(0,s.jsxs)("div",{className:"flex min-w-0 flex-col gap-6 px-1 sm:px-0",children:[!Q&&(0,s.jsxs)("div",{className:"text-center py-8 border border-dashed border-border rounded-xl",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-[32px] text-text-muted mb-2",children:"search_off"}),(0,s.jsx)("p",{className:"text-text-muted text-sm",children:"No providers match your search"})]}),(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,s.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[(0,s.jsxs)("h2",{className:"text-lg sm:text-xl font-semibold flex items-center gap-2 leading-tight",children:["Custom Providers (OpenAI/Anthropic Compatible)"," "]}),(0,s.jsxs)("div",{className:"grid grid-cols-1 gap-2 sm:flex sm:w-auto",children:[(0,s.jsx)(n.$n,{size:"sm",icon:"add",onClick:()=>j(!0),className:"w-full sm:w-auto",children:"Add Anthropic Compatible"}),(0,s.jsx)(n.$n,{size:"sm",variant:"secondary",icon:"add",onClick:()=>b(!0),className:"w-full !bg-white !text-black hover:!bg-gray-100 sm:w-auto",children:"Add OpenAI Compatible"})]})]}),0===q.length&&0===D.length?(0,s.jsxs)("div",{className:"flex items-center justify-center gap-2 py-2 border border-dashed border-border rounded-xl text-text-muted text-sm",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"extension"}),(0,s.jsx)("span",{children:"No custom providers — use buttons above to add OpenAI/Anthropic compatible endpoints"})]}):(0,s.jsx)("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2 sm:gap-4 lg:grid-cols-3 xl:grid-cols-4",children:[...q,...D].map(e=>(0,s.jsx)(P,{providerId:e.id,provider:e,stats:_(e.id,"apikey"),authType:"compatible",onToggle:t=>z(e.id,"apikey",t)},e.id))})]}),L.length>0&&(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,s.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[(0,s.jsx)("h2",{className:"text-lg sm:text-xl font-semibold flex items-center gap-2 leading-tight",children:"OAuth Providers"}),(0,s.jsxs)("div",{className:"flex w-full flex-col gap-2 sm:w-auto sm:flex-row sm:items-center",children:[(0,s.jsx)(y,{}),(0,s.jsxs)("button",{onClick:()=>H("oauth"),disabled:!!N,className:`flex w-full items-center justify-center gap-1.5 rounded-lg border px-3 py-2 text-xs font-medium transition-colors sm:w-auto sm:py-1.5 ${"oauth"===N?"bg-primary/20 border-primary/40 text-primary animate-pulse":"bg-bg border-border text-text-muted hover:text-text-main hover:border-primary/40"}`,title:"Test all OAuth connections","aria-label":"Test all OAuth connections",children:[(0,s.jsx)("span",{className:`material-symbols-outlined text-[14px]${"oauth"===N?" animate-spin":""}`,children:"play_arrow"}),"oauth"===N?"Testing...":"Test All"]})]})]}),(0,s.jsx)("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2 sm:gap-4 lg:grid-cols-3 xl:grid-cols-4",children:L.map(([e,t])=>(0,s.jsx)(I,{providerId:e,provider:t,stats:_(e,"oauth"),authType:"oauth",onToggle:t=>z(e,"oauth",t)},e))})]}),(F.length>0||M.length>0)&&(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,s.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[(0,s.jsx)("h2",{className:"text-lg sm:text-xl font-semibold flex items-center gap-2 leading-tight",children:"Free Tier Providers"}),(0,s.jsxs)("button",{onClick:()=>H("free"),disabled:!!N,className:`flex w-full items-center justify-center gap-1.5 rounded-lg border px-3 py-2 text-xs font-medium transition-colors sm:w-auto sm:py-1.5 ${"free"===N?"bg-primary/20 border-primary/40 text-primary animate-pulse":"bg-bg border-border text-text-muted hover:text-text-main hover:border-primary/40"}`,title:"Test all Free connections","aria-label":"Test all Free provider connections",children:[(0,s.jsx)("span",{className:`material-symbols-outlined text-[14px]${"free"===N?" animate-spin":""}`,children:"play_arrow"}),"free"===N?"Testing...":"Test All"]})]}),(0,s.jsxs)("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2 sm:gap-4 lg:grid-cols-3 xl:grid-cols-4",children:[F.map(([e,t])=>{let r="kiro"===e?["oauth","apikey","api_key"]:"oauth";return(0,s.jsx)(I,{providerId:e,provider:t,stats:_(e,r),authType:"free",onToggle:t=>z(e,r,t)},e)}),M.map(([e,t])=>(0,s.jsx)(P,{providerId:e,provider:t,stats:_(e,"apikey"),authType:"apikey",onToggle:t=>z(e,"apikey",t)},e))]})]}),J.length>0&&(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,s.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[(0,s.jsxs)("h2",{className:"text-lg sm:text-xl font-semibold flex items-center gap-2 leading-tight",children:["API Key Providers"," "]}),(0,s.jsxs)("button",{onClick:()=>H("apikey"),disabled:!!N,className:`flex w-full items-center justify-center gap-1.5 rounded-lg border px-3 py-2 text-xs font-medium transition-colors sm:w-auto sm:py-1.5 ${"apikey"===N?"bg-primary/20 border-primary/40 text-primary animate-pulse":"bg-bg border-border text-text-muted hover:text-text-main hover:border-primary/40"}`,title:"Test all API Key connections","aria-label":"Test all API Key connections",children:[(0,s.jsx)("span",{className:`material-symbols-outlined text-[14px]${"apikey"===N?" animate-spin":""}`,children:"play_arrow"}),"apikey"===N?"Testing...":"Test All"]})]}),(0,s.jsx)("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2 sm:gap-4 lg:grid-cols-3 xl:grid-cols-4",children:W.map(([e,t])=>(0,s.jsx)(P,{providerId:e,provider:t,stats:_(e,"apikey"),authType:"apikey",onToggle:t=>z(e,"apikey",t)},e))}),!K&&!d&&B>0&&(0,s.jsxs)("button",{onClick:()=>p(!0),className:"flex w-full items-center justify-center gap-1.5 rounded-lg border border-dashed border-primary/40 px-3 py-2.5 text-sm font-medium text-primary transition-colors hover:border-primary hover:bg-primary/5",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"expand_more"}),(0,g.Tl)("Show all")," ",J.length," ",(0,g.Tl)("providers")]})]}),(0,s.jsx)(k,{variant:"openai",isOpen:x,onClose:()=>b(!1),onCreated:e=>{l(t=>[...t,e]),b(!1)}}),(0,s.jsx)(k,{variant:"anthropic",isOpen:v,onClose:()=>j(!1),onCreated:e=>{l(t=>[...t,e]),j(!1)}}),C&&(0,s.jsxs)("div",{className:"fixed inset-0 z-50 flex items-start justify-center px-3 pt-[6vh] sm:pt-[10vh]",onClick:()=>T(null),children:[(0,s.jsx)("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm"}),(0,s.jsxs)("div",{className:"relative bg-surface border border-border rounded-xl w-full max-w-[600px] max-h-[86vh] sm:max-h-[80vh] overflow-y-auto shadow-2xl",onClick:e=>e.stopPropagation(),children:[(0,s.jsxs)("div",{className:"sticky top-0 z-10 flex items-center justify-between px-5 py-3 border-b border-border bg-surface/95 backdrop-blur-sm rounded-t-xl",children:[(0,s.jsx)("h3",{className:"font-semibold",children:"Test Results"}),(0,s.jsx)("button",{onClick:()=>T(null),className:"p-1 rounded-lg hover:bg-bg text-text-muted hover:text-text-main transition-colors","aria-label":"Close test results",children:(0,s.jsx)("span",{className:"material-symbols-outlined text-lg",children:"close"})})]}),(0,s.jsx)("div",{className:"p-5",children:(0,s.jsx)(O,{results:C})})]})]})]})}function I({providerId:e,provider:t,stats:r,authType:a,onToggle:l}){let{connected:i,error:d,errorCode:c,errorTime:m,allDisabled:p}=r,u=!!t.noAuth;return(0,s.jsx)(x(),{href:`/dashboard/providers/${e}`,className:"group min-w-0",children:(0,s.jsx)(n.Zp,{padding:"xs",className:`h-full hover:bg-black/[0.01] dark:hover:bg-white/[0.01] transition-colors cursor-pointer ${p?"opacity-50":""}`,children:(0,s.jsxs)("div",{className:"flex min-w-0 items-center justify-between gap-3",children:[(0,s.jsxs)("div",{className:"flex min-w-0 items-center gap-3",children:[(0,s.jsx)("div",{className:"size-8 shrink-0 rounded-lg flex items-center justify-center",style:{backgroundColor:`${t.color?.length>7?t.color:t.color+"15"}`},children:(0,s.jsx)(o.A,{src:`/providers/${t.id}.png`,alt:t.name,size:30,className:"object-contain rounded-lg max-w-[32px] max-h-[32px]",fallbackText:t.textIcon||t.id.slice(0,2).toUpperCase(),fallbackColor:t.color})}),(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsx)("h3",{className:"truncate font-semibold",children:t.name}),(0,s.jsx)("div",{className:"flex min-w-0 items-center gap-1.5 text-xs flex-wrap",children:p?(0,s.jsx)(n.Ex,{variant:"default",size:"sm",children:(0,s.jsxs)("span",{className:"flex items-center gap-1",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-[12px]",children:"pause_circle"}),"Disabled"]})}):u?(0,s.jsx)(n.Ex,{variant:"success",size:"sm",dot:!0,children:"Ready"}):(0,s.jsxs)(s.Fragment,{children:[T(i,d,c),m&&(0,s.jsx)("span",{className:"text-text-muted",children:m})]})})]})]}),(0,s.jsx)("div",{className:"flex shrink-0 items-center gap-2",children:r.total>0&&(0,s.jsx)("div",{className:"opacity-100 transition-opacity sm:opacity-0 sm:group-hover:opacity-100",onClick:e=>{e.preventDefault(),e.stopPropagation(),l(!!p)},children:(0,s.jsx)(n.lM,{size:"sm",checked:!p,onChange:()=>{},title:p?"Enable provider":"Disable provider"})})})]})})})}function P({providerId:e,provider:t,stats:r,authType:a,onToggle:l}){let{connected:i,error:c,errorCode:p,errorTime:u,allDisabled:h}=r,f=e.startsWith(m.JH),g=e.startsWith(m.DI);return(0,s.jsx)(x(),{href:`/dashboard/providers/${e}`,className:"group min-w-0",children:(0,s.jsx)(n.Zp,{padding:"xs",className:`h-full hover:bg-black/[0.01] dark:hover:bg-white/[0.01] transition-colors cursor-pointer ${h?"opacity-50":""}`,children:(0,s.jsxs)("div",{className:"flex min-w-0 items-center justify-between gap-3",children:[(0,s.jsxs)("div",{className:"flex min-w-0 items-center gap-3",children:[(0,s.jsx)("div",{className:"size-8 shrink-0 rounded-lg flex items-center justify-center",style:{backgroundColor:`${t.color?.length>7?t.color:t.color+"15"}`},children:(0,s.jsx)(o.A,{src:f&&t.apiType?"responses"===t.apiType?"/providers/oai-r.png":"/providers/oai-cc.png":g?"/providers/anthropic-m.png":(0,d.HY)(t.id),alt:t.name,size:30,className:"object-contain rounded-lg max-w-[30px] max-h-[30px]",fallbackText:t.textIcon||t.id.slice(0,2).toUpperCase(),fallbackColor:t.color})}),(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsx)("h3",{className:"truncate font-semibold",children:t.name}),(0,s.jsx)("div",{className:"flex min-w-0 items-center gap-1.5 text-xs flex-wrap",children:h?(0,s.jsx)(n.Ex,{variant:"default",size:"sm",children:(0,s.jsxs)("span",{className:"flex items-center gap-1",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-[12px]",children:"pause_circle"}),"Disabled"]})}):(0,s.jsxs)(s.Fragment,{children:[T(i,c,p),f&&(0,s.jsx)(n.Ex,{variant:"default",size:"sm",children:"responses"===t.apiType?"Responses":"Chat"}),g&&(0,s.jsx)(n.Ex,{variant:"default",size:"sm",children:"Messages"}),u&&(0,s.jsx)("span",{className:"text-text-muted",children:u})]})})]})]}),(0,s.jsx)("div",{className:"flex shrink-0 items-center gap-2",children:r.total>0&&(0,s.jsx)("div",{className:"opacity-100 transition-opacity sm:opacity-0 sm:group-hover:opacity-100",onClick:e=>{e.preventDefault(),e.stopPropagation(),l(!!h)},children:(0,s.jsx)(n.lM,{size:"sm",checked:!h,onChange:()=>{},title:h?"Enable provider":"Disable provider"})})})]})})})}function O({results:e}){if(e.error&&!e.results)return(0,s.jsxs)("div",{className:"text-center py-6",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-red-500 text-[32px] mb-2 block",children:"error"}),(0,s.jsx)("p",{className:"text-sm text-red-400",children:e.error})]});let{summary:t,mode:r}=e,a=e.results||[];return(0,s.jsxs)("div",{className:"flex min-w-0 flex-col gap-3",children:[t&&(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-2 text-xs mb-1 sm:gap-3",children:[(0,s.jsxs)("span",{className:"text-text-muted",children:[{oauth:"OAuth",free:"Free",apikey:"API Key",provider:"Provider",all:"All"}[r]||r," Test"]}),(0,s.jsxs)("span",{className:"px-2 py-0.5 rounded bg-emerald-500/15 text-emerald-400 font-medium",children:[t.passed," passed"]}),t.failed>0&&(0,s.jsxs)("span",{className:"px-2 py-0.5 rounded bg-red-500/15 text-red-400 font-medium",children:[t.failed," failed"]}),(0,s.jsxs)("span",{className:"text-text-muted sm:ml-auto",children:[t.total," tested"]})]}),a.map((e,t)=>(0,s.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-2 rounded-lg bg-black/[0.03] px-3 py-2 text-xs dark:bg-white/[0.03] sm:flex-nowrap",children:[(0,s.jsx)("span",{className:`material-symbols-outlined text-[16px] ${e.valid?"text-emerald-500":"text-red-500"}`,children:e.valid?"check_circle":"error"}),(0,s.jsxs)("div",{className:"min-w-0 flex-[1_1_160px]",children:[(0,s.jsx)("span",{className:"block truncate font-medium sm:inline",children:e.connectionName}),(0,s.jsxs)("span",{className:"block truncate text-text-muted sm:ml-1.5 sm:inline",children:["(",e.provider,")"]})]}),void 0!==e.latencyMs&&(0,s.jsxs)("span",{className:"shrink-0 text-text-muted font-mono tabular-nums",children:[e.latencyMs,"ms"]}),(0,s.jsx)("span",{className:`shrink-0 text-[10px] uppercase font-bold px-1.5 py-0.5 rounded ${e.valid?"bg-emerald-500/15 text-emerald-400":"bg-red-500/15 text-red-400"}`,children:e.valid?"OK":e.diagnosis?.type||"ERROR"})]},e.connectionId||t)),0===a.length&&(0,s.jsx)("div",{className:"text-center py-4 text-text-muted text-sm",children:"No active connections found for this group."})]})}k.propTypes={variant:i().oneOf(["openai","anthropic"]).isRequired,isOpen:i().bool.isRequired,onClose:i().func.isRequired,onCreated:i().func.isRequired},I.propTypes={providerId:i().string.isRequired,provider:i().shape({id:i().string.isRequired,name:i().string.isRequired,color:i().string,textIcon:i().string}).isRequired,stats:i().shape({connected:i().number,error:i().number,errorCode:i().string,errorTime:i().string}).isRequired,authType:i().string,onToggle:i().func},P.propTypes={providerId:i().string.isRequired,provider:i().shape({id:i().string.isRequired,name:i().string.isRequired,color:i().string,textIcon:i().string,apiType:i().string}).isRequired,stats:i().shape({connected:i().number,error:i().number,errorCode:i().string,errorTime:i().string}).isRequired,authType:i().string,onToggle:i().func},O.propTypes={results:i().shape({mode:i().string,results:i().array,summary:i().shape({total:i().number,passed:i().number,failed:i().number}),error:i().string}).isRequired}}},e=>{e.O(0,[8010,8105,1321,801,5497,8441,3794,7358],()=>e(e.s=69671)),_N_E=e.O()}]);