9router 0.4.12 → 0.4.14

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 (455) hide show
  1. package/app/.next/BUILD_ID +1 -1
  2. package/app/.next/app-path-routes-manifest.json +7 -7
  3. package/app/.next/build-manifest.json +2 -2
  4. package/app/.next/routes-manifest.json +3 -3
  5. package/app/.next/server/app/(dashboard)/dashboard/basic-chat/page.js +2 -2
  6. package/app/.next/server/app/(dashboard)/dashboard/basic-chat/page_client-reference-manifest.js +1 -1
  7. package/app/.next/server/app/(dashboard)/dashboard/cli-tools/page.js +2 -2
  8. package/app/.next/server/app/(dashboard)/dashboard/cli-tools/page.js.nft.json +1 -1
  9. package/app/.next/server/app/(dashboard)/dashboard/cli-tools/page_client-reference-manifest.js +1 -1
  10. package/app/.next/server/app/(dashboard)/dashboard/combos/page.js +2 -2
  11. package/app/.next/server/app/(dashboard)/dashboard/combos/page_client-reference-manifest.js +1 -1
  12. package/app/.next/server/app/(dashboard)/dashboard/console-log/page.js +2 -2
  13. package/app/.next/server/app/(dashboard)/dashboard/console-log/page_client-reference-manifest.js +1 -1
  14. package/app/.next/server/app/(dashboard)/dashboard/endpoint/page.js +2 -2
  15. package/app/.next/server/app/(dashboard)/dashboard/endpoint/page_client-reference-manifest.js +1 -1
  16. package/app/.next/server/app/(dashboard)/dashboard/media-providers/[kind]/[id]/page.js +5 -5
  17. package/app/.next/server/app/(dashboard)/dashboard/media-providers/[kind]/[id]/page_client-reference-manifest.js +1 -1
  18. package/app/.next/server/app/(dashboard)/dashboard/media-providers/[kind]/page.js +2 -2
  19. package/app/.next/server/app/(dashboard)/dashboard/media-providers/[kind]/page_client-reference-manifest.js +1 -1
  20. package/app/.next/server/app/(dashboard)/dashboard/media-providers/combo/[id]/page.js +5 -0
  21. package/app/.next/server/app/(dashboard)/dashboard/media-providers/combo/[id]/page.js.nft.json +1 -0
  22. package/app/.next/server/app/(dashboard)/dashboard/media-providers/combo/[id]/page_client-reference-manifest.js +1 -0
  23. package/app/.next/server/app/(dashboard)/dashboard/media-providers/web/page.js +2 -2
  24. package/app/.next/server/app/(dashboard)/dashboard/media-providers/web/page_client-reference-manifest.js +1 -1
  25. package/app/.next/server/app/(dashboard)/dashboard/mitm/page.js +2 -2
  26. package/app/.next/server/app/(dashboard)/dashboard/mitm/page.js.nft.json +1 -1
  27. package/app/.next/server/app/(dashboard)/dashboard/mitm/page_client-reference-manifest.js +1 -1
  28. package/app/.next/server/app/(dashboard)/dashboard/page.js +2 -2
  29. package/app/.next/server/app/(dashboard)/dashboard/page_client-reference-manifest.js +1 -1
  30. package/app/.next/server/app/(dashboard)/dashboard/profile/page.js +2 -2
  31. package/app/.next/server/app/(dashboard)/dashboard/profile/page_client-reference-manifest.js +1 -1
  32. package/app/.next/server/app/(dashboard)/dashboard/providers/[id]/page.js +2 -2
  33. package/app/.next/server/app/(dashboard)/dashboard/providers/[id]/page_client-reference-manifest.js +1 -1
  34. package/app/.next/server/app/(dashboard)/dashboard/providers/new/page.js +2 -2
  35. package/app/.next/server/app/(dashboard)/dashboard/providers/new/page_client-reference-manifest.js +1 -1
  36. package/app/.next/server/app/(dashboard)/dashboard/providers/page.js +2 -2
  37. package/app/.next/server/app/(dashboard)/dashboard/providers/page_client-reference-manifest.js +1 -1
  38. package/app/.next/server/app/(dashboard)/dashboard/proxy-pools/page.js +3 -3
  39. package/app/.next/server/app/(dashboard)/dashboard/proxy-pools/page_client-reference-manifest.js +1 -1
  40. package/app/.next/server/app/(dashboard)/dashboard/quota/page.js +2 -2
  41. package/app/.next/server/app/(dashboard)/dashboard/quota/page_client-reference-manifest.js +1 -1
  42. package/app/.next/server/app/(dashboard)/dashboard/translator/page.js +2 -2
  43. package/app/.next/server/app/(dashboard)/dashboard/translator/page_client-reference-manifest.js +1 -1
  44. package/app/.next/server/app/(dashboard)/dashboard/usage/page.js +2 -2
  45. package/app/.next/server/app/(dashboard)/dashboard/usage/page_client-reference-manifest.js +1 -1
  46. package/app/.next/server/app/_global-error/page.js +3 -3
  47. package/app/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
  48. package/app/.next/server/app/_global-error.html +1 -1
  49. package/app/.next/server/app/_global-error.rsc +1 -1
  50. package/app/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  51. package/app/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
  52. package/app/.next/server/app/_global-error.segments/_global-error.segment.rsc +1 -1
  53. package/app/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  54. package/app/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  55. package/app/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  56. package/app/.next/server/app/_not-found/page.js +2 -2
  57. package/app/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  58. package/app/.next/server/app/_not-found.html +1 -1
  59. package/app/.next/server/app/_not-found.rsc +4 -4
  60. package/app/.next/server/app/_not-found.segments/_full.segment.rsc +4 -4
  61. package/app/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
  62. package/app/.next/server/app/_not-found.segments/_index.segment.rsc +4 -4
  63. package/app/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
  64. package/app/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
  65. package/app/.next/server/app/_not-found.segments/_tree.segment.rsc +2 -2
  66. package/app/.next/server/app/api/auth/login/route.js +1 -1
  67. package/app/.next/server/app/api/auth/logout/route.js +1 -1
  68. package/app/.next/server/app/api/cli-tools/antigravity-mitm/alias/route.js +2 -2
  69. package/app/.next/server/app/api/cli-tools/antigravity-mitm/route.js +1 -1
  70. package/app/.next/server/app/api/cli-tools/claude-settings/route.js +2 -2
  71. package/app/.next/server/app/api/cli-tools/codex-settings/route.js +2 -2
  72. package/app/.next/server/app/api/cli-tools/copilot-settings/route.js +2 -2
  73. package/app/.next/server/app/api/cli-tools/droid-settings/route.js +2 -2
  74. package/app/.next/server/app/api/cli-tools/hermes-settings/route.js +2 -2
  75. package/app/.next/server/app/api/cli-tools/openclaw-settings/route.js +2 -2
  76. package/app/.next/server/app/api/cli-tools/opencode-settings/route.js +2 -2
  77. package/app/.next/server/app/api/cloud/auth/route.js +1 -1
  78. package/app/.next/server/app/api/cloud/credentials/update/route.js +1 -1
  79. package/app/.next/server/app/api/cloud/model/resolve/route.js +1 -1
  80. package/app/.next/server/app/api/cloud/models/alias/route.js +1 -1
  81. package/app/.next/server/app/api/combos/[id]/route.js +1 -1
  82. package/app/.next/server/app/api/combos/[id]/route.js.nft.json +1 -1
  83. package/app/.next/server/app/api/combos/route.js +1 -1
  84. package/app/.next/server/app/api/health/route.js +1 -1
  85. package/app/.next/server/app/api/init/route.js +1 -1
  86. package/app/.next/server/app/api/keys/[id]/route.js +1 -1
  87. package/app/.next/server/app/api/keys/route.js +1 -1
  88. package/app/.next/server/app/api/locale/route.js +1 -1
  89. package/app/.next/server/app/api/media-providers/tts/deepgram/voices/route.js +1 -1
  90. package/app/.next/server/app/api/media-providers/tts/elevenlabs/voices/route.js +1 -1
  91. package/app/.next/server/app/api/media-providers/tts/inworld/voices/route.js +1 -1
  92. package/app/.next/server/app/api/media-providers/tts/voices/route.js +1 -1
  93. package/app/.next/server/app/api/models/alias/route.js +1 -1
  94. package/app/.next/server/app/api/models/availability/route.js +1 -1
  95. package/app/.next/server/app/api/models/custom/route.js +1 -1
  96. package/app/.next/server/app/api/models/route.js +1 -1
  97. package/app/.next/server/app/api/models/test/route.js +1 -1
  98. package/app/.next/server/app/api/oauth/[provider]/[action]/route.js +1 -1
  99. package/app/.next/server/app/api/oauth/cursor/auto-import/route.js +2 -2
  100. package/app/.next/server/app/api/oauth/cursor/import/route.js +1 -1
  101. package/app/.next/server/app/api/oauth/gitlab/pat/route.js +1 -1
  102. package/app/.next/server/app/api/oauth/iflow/cookie/route.js +1 -1
  103. package/app/.next/server/app/api/oauth/kiro/auto-import/route.js +1 -1
  104. package/app/.next/server/app/api/oauth/kiro/import/route.js +1 -1
  105. package/app/.next/server/app/api/oauth/kiro/social-authorize/route.js +1 -1
  106. package/app/.next/server/app/api/oauth/kiro/social-exchange/route.js +1 -1
  107. package/app/.next/server/app/api/pricing/route.js +1 -1
  108. package/app/.next/server/app/api/provider-nodes/[id]/route.js +1 -1
  109. package/app/.next/server/app/api/provider-nodes/route.js +1 -1
  110. package/app/.next/server/app/api/provider-nodes/validate/route.js +1 -1
  111. package/app/.next/server/app/api/providers/[id]/models/route.js +1 -1
  112. package/app/.next/server/app/api/providers/[id]/models/route.js.nft.json +1 -1
  113. package/app/.next/server/app/api/providers/[id]/route.js +1 -1
  114. package/app/.next/server/app/api/providers/[id]/test/route.js +1 -1
  115. package/app/.next/server/app/api/providers/[id]/test-models/route.js +1 -1
  116. package/app/.next/server/app/api/providers/client/route.js +1 -1
  117. package/app/.next/server/app/api/providers/kilo/free-models/route.js +1 -1
  118. package/app/.next/server/app/api/providers/route.js +1 -1
  119. package/app/.next/server/app/api/providers/suggested-models/route.js +1 -1
  120. package/app/.next/server/app/api/providers/test-batch/route.js +1 -1
  121. package/app/.next/server/app/api/providers/validate/route.js +1 -1
  122. package/app/.next/server/app/api/proxy-pools/[id]/route.js +1 -1
  123. package/app/.next/server/app/api/proxy-pools/[id]/test/route.js +1 -1
  124. package/app/.next/server/app/api/proxy-pools/route.js +1 -1
  125. package/app/.next/server/app/api/proxy-pools/vercel-deploy/route.js +2 -2
  126. package/app/.next/server/app/api/settings/database/route.js +1 -1
  127. package/app/.next/server/app/api/settings/proxy-test/route.js +1 -1
  128. package/app/.next/server/app/api/settings/require-login/route.js +1 -1
  129. package/app/.next/server/app/api/settings/route.js +1 -1
  130. package/app/.next/server/app/api/settings/route.js.nft.json +1 -1
  131. package/app/.next/server/app/api/shutdown/route.js +1 -1
  132. package/app/.next/server/app/api/tags/route.js +1 -1
  133. package/app/.next/server/app/api/translator/console-logs/route.js +1 -1
  134. package/app/.next/server/app/api/translator/console-logs/stream/route.js +4 -4
  135. package/app/.next/server/app/api/translator/load/route.js +1 -1
  136. package/app/.next/server/app/api/translator/save/route.js +1 -1
  137. package/app/.next/server/app/api/translator/send/route.js +1 -1
  138. package/app/.next/server/app/api/translator/translate/route.js +1 -1
  139. package/app/.next/server/app/api/translator/translate/route.js.nft.json +1 -1
  140. package/app/.next/server/app/api/tunnel/disable/route.js +1 -1
  141. package/app/.next/server/app/api/tunnel/enable/route.js +1 -1
  142. package/app/.next/server/app/api/tunnel/status/route.js +1 -1
  143. package/app/.next/server/app/api/tunnel/tailscale-check/route.js +12 -14
  144. package/app/.next/server/app/api/tunnel/tailscale-disable/route.js +1 -1
  145. package/app/.next/server/app/api/tunnel/tailscale-enable/route.js +1 -1
  146. package/app/.next/server/app/api/tunnel/tailscale-install/route.js +2 -2
  147. package/app/.next/server/app/api/tunnel/tailscale-login/route.js +12 -14
  148. package/app/.next/server/app/api/tunnel/tailscale-start-daemon/route.js +2 -2
  149. package/app/.next/server/app/api/usage/[connectionId]/route.js +1 -1
  150. package/app/.next/server/app/api/usage/chart/route.js +1 -1
  151. package/app/.next/server/app/api/usage/history/route.js +1 -1
  152. package/app/.next/server/app/api/usage/providers/route.js +1 -1
  153. package/app/.next/server/app/api/usage/request-details/route.js +1 -1
  154. package/app/.next/server/app/api/usage/request-logs/route.js +1 -1
  155. package/app/.next/server/app/api/usage/stats/route.js +1 -1
  156. package/app/.next/server/app/api/usage/stream/route.js +2 -2
  157. package/app/.next/server/app/api/v1/api/chat/route.js +1 -1
  158. package/app/.next/server/app/api/v1/api/chat/route.js.nft.json +1 -1
  159. package/app/.next/server/app/api/v1/audio/speech/route.js +1 -1
  160. package/app/.next/server/app/api/v1/audio/speech/route.js.nft.json +1 -1
  161. package/app/.next/server/app/api/v1/chat/completions/route.js +1 -1
  162. package/app/.next/server/app/api/v1/chat/completions/route.js.nft.json +1 -1
  163. package/app/.next/server/app/api/v1/embeddings/route.js +1 -1
  164. package/app/.next/server/app/api/v1/embeddings/route.js.nft.json +1 -1
  165. package/app/.next/server/app/api/v1/images/generations/route.js +2 -2
  166. package/app/.next/server/app/api/v1/images/generations/route.js.nft.json +1 -1
  167. package/app/.next/server/app/api/v1/messages/count_tokens/route.js +1 -1
  168. package/app/.next/server/app/api/v1/messages/route.js +1 -1
  169. package/app/.next/server/app/api/v1/messages/route.js.nft.json +1 -1
  170. package/app/.next/server/app/api/v1/models/route.js +1 -1
  171. package/app/.next/server/app/api/v1/models/route.js.nft.json +1 -1
  172. package/app/.next/server/app/api/v1/responses/compact/route.js +1 -1
  173. package/app/.next/server/app/api/v1/responses/compact/route.js.nft.json +1 -1
  174. package/app/.next/server/app/api/v1/responses/route.js +1 -1
  175. package/app/.next/server/app/api/v1/responses/route.js.nft.json +1 -1
  176. package/app/.next/server/app/api/v1/route.js +1 -1
  177. package/app/.next/server/app/api/v1/route.js.nft.json +1 -1
  178. package/app/.next/server/app/api/v1/search/route.js +1 -1
  179. package/app/.next/server/app/api/v1/search/route.js.nft.json +1 -1
  180. package/app/.next/server/app/api/v1/web/fetch/route.js +1 -1
  181. package/app/.next/server/app/api/v1/web/fetch/route.js.nft.json +1 -1
  182. package/app/.next/server/app/api/v1beta/models/[...path]/route.js +1 -1
  183. package/app/.next/server/app/api/v1beta/models/[...path]/route.js.nft.json +1 -1
  184. package/app/.next/server/app/api/v1beta/models/route.js +1 -1
  185. package/app/.next/server/app/api/version/route.js +1 -1
  186. package/app/.next/server/app/api/version/update/route.js +1 -1
  187. package/app/.next/server/app/callback/page.js +2 -2
  188. package/app/.next/server/app/callback/page_client-reference-manifest.js +1 -1
  189. package/app/.next/server/app/callback.html +1 -1
  190. package/app/.next/server/app/callback.rsc +4 -4
  191. package/app/.next/server/app/callback.segments/_full.segment.rsc +4 -4
  192. package/app/.next/server/app/callback.segments/_head.segment.rsc +1 -1
  193. package/app/.next/server/app/callback.segments/_index.segment.rsc +4 -4
  194. package/app/.next/server/app/callback.segments/_tree.segment.rsc +2 -2
  195. package/app/.next/server/app/callback.segments/callback/__PAGE__.segment.rsc +1 -1
  196. package/app/.next/server/app/callback.segments/callback.segment.rsc +1 -1
  197. package/app/.next/server/app/dashboard/basic-chat.html +1 -1
  198. package/app/.next/server/app/dashboard/basic-chat.rsc +6 -6
  199. package/app/.next/server/app/dashboard/basic-chat.segments/!KGRhc2hib2FyZCk/dashboard/basic-chat/__PAGE__.segment.rsc +2 -2
  200. package/app/.next/server/app/dashboard/basic-chat.segments/!KGRhc2hib2FyZCk/dashboard/basic-chat.segment.rsc +1 -1
  201. package/app/.next/server/app/dashboard/basic-chat.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  202. package/app/.next/server/app/dashboard/basic-chat.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  203. package/app/.next/server/app/dashboard/basic-chat.segments/_full.segment.rsc +6 -6
  204. package/app/.next/server/app/dashboard/basic-chat.segments/_head.segment.rsc +1 -1
  205. package/app/.next/server/app/dashboard/basic-chat.segments/_index.segment.rsc +4 -4
  206. package/app/.next/server/app/dashboard/basic-chat.segments/_tree.segment.rsc +2 -2
  207. package/app/.next/server/app/dashboard/cli-tools.html +1 -1
  208. package/app/.next/server/app/dashboard/cli-tools.rsc +6 -6
  209. package/app/.next/server/app/dashboard/cli-tools.segments/!KGRhc2hib2FyZCk/dashboard/cli-tools/__PAGE__.segment.rsc +2 -2
  210. package/app/.next/server/app/dashboard/cli-tools.segments/!KGRhc2hib2FyZCk/dashboard/cli-tools.segment.rsc +1 -1
  211. package/app/.next/server/app/dashboard/cli-tools.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  212. package/app/.next/server/app/dashboard/cli-tools.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  213. package/app/.next/server/app/dashboard/cli-tools.segments/_full.segment.rsc +6 -6
  214. package/app/.next/server/app/dashboard/cli-tools.segments/_head.segment.rsc +1 -1
  215. package/app/.next/server/app/dashboard/cli-tools.segments/_index.segment.rsc +4 -4
  216. package/app/.next/server/app/dashboard/cli-tools.segments/_tree.segment.rsc +2 -2
  217. package/app/.next/server/app/dashboard/combos.html +1 -1
  218. package/app/.next/server/app/dashboard/combos.rsc +6 -6
  219. package/app/.next/server/app/dashboard/combos.segments/!KGRhc2hib2FyZCk/dashboard/combos/__PAGE__.segment.rsc +2 -2
  220. package/app/.next/server/app/dashboard/combos.segments/!KGRhc2hib2FyZCk/dashboard/combos.segment.rsc +1 -1
  221. package/app/.next/server/app/dashboard/combos.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  222. package/app/.next/server/app/dashboard/combos.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  223. package/app/.next/server/app/dashboard/combos.segments/_full.segment.rsc +6 -6
  224. package/app/.next/server/app/dashboard/combos.segments/_head.segment.rsc +1 -1
  225. package/app/.next/server/app/dashboard/combos.segments/_index.segment.rsc +4 -4
  226. package/app/.next/server/app/dashboard/combos.segments/_tree.segment.rsc +2 -2
  227. package/app/.next/server/app/dashboard/endpoint.html +1 -1
  228. package/app/.next/server/app/dashboard/endpoint.rsc +6 -6
  229. package/app/.next/server/app/dashboard/endpoint.segments/!KGRhc2hib2FyZCk/dashboard/endpoint/__PAGE__.segment.rsc +2 -2
  230. package/app/.next/server/app/dashboard/endpoint.segments/!KGRhc2hib2FyZCk/dashboard/endpoint.segment.rsc +1 -1
  231. package/app/.next/server/app/dashboard/endpoint.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  232. package/app/.next/server/app/dashboard/endpoint.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  233. package/app/.next/server/app/dashboard/endpoint.segments/_full.segment.rsc +6 -6
  234. package/app/.next/server/app/dashboard/endpoint.segments/_head.segment.rsc +1 -1
  235. package/app/.next/server/app/dashboard/endpoint.segments/_index.segment.rsc +4 -4
  236. package/app/.next/server/app/dashboard/endpoint.segments/_tree.segment.rsc +2 -2
  237. package/app/.next/server/app/dashboard/media-providers/web.html +1 -1
  238. package/app/.next/server/app/dashboard/media-providers/web.rsc +6 -6
  239. package/app/.next/server/app/dashboard/media-providers/web.segments/!KGRhc2hib2FyZCk/dashboard/media-providers/web/__PAGE__.segment.rsc +2 -2
  240. package/app/.next/server/app/dashboard/media-providers/web.segments/!KGRhc2hib2FyZCk/dashboard/media-providers/web.segment.rsc +1 -1
  241. package/app/.next/server/app/dashboard/media-providers/web.segments/!KGRhc2hib2FyZCk/dashboard/media-providers.segment.rsc +1 -1
  242. package/app/.next/server/app/dashboard/media-providers/web.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  243. package/app/.next/server/app/dashboard/media-providers/web.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  244. package/app/.next/server/app/dashboard/media-providers/web.segments/_full.segment.rsc +6 -6
  245. package/app/.next/server/app/dashboard/media-providers/web.segments/_head.segment.rsc +1 -1
  246. package/app/.next/server/app/dashboard/media-providers/web.segments/_index.segment.rsc +4 -4
  247. package/app/.next/server/app/dashboard/media-providers/web.segments/_tree.segment.rsc +2 -2
  248. package/app/.next/server/app/dashboard/mitm.html +1 -1
  249. package/app/.next/server/app/dashboard/mitm.rsc +6 -6
  250. package/app/.next/server/app/dashboard/mitm.segments/!KGRhc2hib2FyZCk/dashboard/mitm/__PAGE__.segment.rsc +2 -2
  251. package/app/.next/server/app/dashboard/mitm.segments/!KGRhc2hib2FyZCk/dashboard/mitm.segment.rsc +1 -1
  252. package/app/.next/server/app/dashboard/mitm.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  253. package/app/.next/server/app/dashboard/mitm.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  254. package/app/.next/server/app/dashboard/mitm.segments/_full.segment.rsc +6 -6
  255. package/app/.next/server/app/dashboard/mitm.segments/_head.segment.rsc +1 -1
  256. package/app/.next/server/app/dashboard/mitm.segments/_index.segment.rsc +4 -4
  257. package/app/.next/server/app/dashboard/mitm.segments/_tree.segment.rsc +2 -2
  258. package/app/.next/server/app/dashboard/profile.html +1 -1
  259. package/app/.next/server/app/dashboard/profile.rsc +6 -6
  260. package/app/.next/server/app/dashboard/profile.segments/!KGRhc2hib2FyZCk/dashboard/profile/__PAGE__.segment.rsc +2 -2
  261. package/app/.next/server/app/dashboard/profile.segments/!KGRhc2hib2FyZCk/dashboard/profile.segment.rsc +1 -1
  262. package/app/.next/server/app/dashboard/profile.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  263. package/app/.next/server/app/dashboard/profile.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  264. package/app/.next/server/app/dashboard/profile.segments/_full.segment.rsc +6 -6
  265. package/app/.next/server/app/dashboard/profile.segments/_head.segment.rsc +1 -1
  266. package/app/.next/server/app/dashboard/profile.segments/_index.segment.rsc +4 -4
  267. package/app/.next/server/app/dashboard/profile.segments/_tree.segment.rsc +2 -2
  268. package/app/.next/server/app/dashboard/providers/new.html +1 -1
  269. package/app/.next/server/app/dashboard/providers/new.rsc +6 -6
  270. package/app/.next/server/app/dashboard/providers/new.segments/!KGRhc2hib2FyZCk/dashboard/providers/new/__PAGE__.segment.rsc +2 -2
  271. package/app/.next/server/app/dashboard/providers/new.segments/!KGRhc2hib2FyZCk/dashboard/providers/new.segment.rsc +1 -1
  272. package/app/.next/server/app/dashboard/providers/new.segments/!KGRhc2hib2FyZCk/dashboard/providers.segment.rsc +1 -1
  273. package/app/.next/server/app/dashboard/providers/new.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  274. package/app/.next/server/app/dashboard/providers/new.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  275. package/app/.next/server/app/dashboard/providers/new.segments/_full.segment.rsc +6 -6
  276. package/app/.next/server/app/dashboard/providers/new.segments/_head.segment.rsc +1 -1
  277. package/app/.next/server/app/dashboard/providers/new.segments/_index.segment.rsc +4 -4
  278. package/app/.next/server/app/dashboard/providers/new.segments/_tree.segment.rsc +2 -2
  279. package/app/.next/server/app/dashboard/providers.html +1 -1
  280. package/app/.next/server/app/dashboard/providers.rsc +6 -6
  281. package/app/.next/server/app/dashboard/providers.segments/!KGRhc2hib2FyZCk/dashboard/providers/__PAGE__.segment.rsc +2 -2
  282. package/app/.next/server/app/dashboard/providers.segments/!KGRhc2hib2FyZCk/dashboard/providers.segment.rsc +1 -1
  283. package/app/.next/server/app/dashboard/providers.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  284. package/app/.next/server/app/dashboard/providers.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  285. package/app/.next/server/app/dashboard/providers.segments/_full.segment.rsc +6 -6
  286. package/app/.next/server/app/dashboard/providers.segments/_head.segment.rsc +1 -1
  287. package/app/.next/server/app/dashboard/providers.segments/_index.segment.rsc +4 -4
  288. package/app/.next/server/app/dashboard/providers.segments/_tree.segment.rsc +2 -2
  289. package/app/.next/server/app/dashboard/proxy-pools.html +1 -1
  290. package/app/.next/server/app/dashboard/proxy-pools.rsc +6 -6
  291. package/app/.next/server/app/dashboard/proxy-pools.segments/!KGRhc2hib2FyZCk/dashboard/proxy-pools/__PAGE__.segment.rsc +2 -2
  292. package/app/.next/server/app/dashboard/proxy-pools.segments/!KGRhc2hib2FyZCk/dashboard/proxy-pools.segment.rsc +1 -1
  293. package/app/.next/server/app/dashboard/proxy-pools.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  294. package/app/.next/server/app/dashboard/proxy-pools.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  295. package/app/.next/server/app/dashboard/proxy-pools.segments/_full.segment.rsc +6 -6
  296. package/app/.next/server/app/dashboard/proxy-pools.segments/_head.segment.rsc +1 -1
  297. package/app/.next/server/app/dashboard/proxy-pools.segments/_index.segment.rsc +4 -4
  298. package/app/.next/server/app/dashboard/proxy-pools.segments/_tree.segment.rsc +2 -2
  299. package/app/.next/server/app/dashboard/quota.html +2 -2
  300. package/app/.next/server/app/dashboard/quota.rsc +7 -7
  301. package/app/.next/server/app/dashboard/quota.segments/!KGRhc2hib2FyZCk/dashboard/quota/__PAGE__.segment.rsc +3 -3
  302. package/app/.next/server/app/dashboard/quota.segments/!KGRhc2hib2FyZCk/dashboard/quota.segment.rsc +1 -1
  303. package/app/.next/server/app/dashboard/quota.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  304. package/app/.next/server/app/dashboard/quota.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  305. package/app/.next/server/app/dashboard/quota.segments/_full.segment.rsc +7 -7
  306. package/app/.next/server/app/dashboard/quota.segments/_head.segment.rsc +1 -1
  307. package/app/.next/server/app/dashboard/quota.segments/_index.segment.rsc +4 -4
  308. package/app/.next/server/app/dashboard/quota.segments/_tree.segment.rsc +2 -2
  309. package/app/.next/server/app/dashboard/settings/pricing/page.js +2 -2
  310. package/app/.next/server/app/dashboard/settings/pricing/page_client-reference-manifest.js +1 -1
  311. package/app/.next/server/app/dashboard/settings/pricing.html +1 -1
  312. package/app/.next/server/app/dashboard/settings/pricing.rsc +5 -5
  313. package/app/.next/server/app/dashboard/settings/pricing.segments/_full.segment.rsc +5 -5
  314. package/app/.next/server/app/dashboard/settings/pricing.segments/_head.segment.rsc +1 -1
  315. package/app/.next/server/app/dashboard/settings/pricing.segments/_index.segment.rsc +4 -4
  316. package/app/.next/server/app/dashboard/settings/pricing.segments/_tree.segment.rsc +2 -2
  317. package/app/.next/server/app/dashboard/settings/pricing.segments/dashboard/settings/pricing/__PAGE__.segment.rsc +2 -2
  318. package/app/.next/server/app/dashboard/settings/pricing.segments/dashboard/settings/pricing.segment.rsc +1 -1
  319. package/app/.next/server/app/dashboard/settings/pricing.segments/dashboard/settings.segment.rsc +1 -1
  320. package/app/.next/server/app/dashboard/settings/pricing.segments/dashboard.segment.rsc +1 -1
  321. package/app/.next/server/app/dashboard/translator.html +1 -1
  322. package/app/.next/server/app/dashboard/translator.rsc +6 -6
  323. package/app/.next/server/app/dashboard/translator.segments/!KGRhc2hib2FyZCk/dashboard/translator/__PAGE__.segment.rsc +2 -2
  324. package/app/.next/server/app/dashboard/translator.segments/!KGRhc2hib2FyZCk/dashboard/translator.segment.rsc +1 -1
  325. package/app/.next/server/app/dashboard/translator.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  326. package/app/.next/server/app/dashboard/translator.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  327. package/app/.next/server/app/dashboard/translator.segments/_full.segment.rsc +6 -6
  328. package/app/.next/server/app/dashboard/translator.segments/_head.segment.rsc +1 -1
  329. package/app/.next/server/app/dashboard/translator.segments/_index.segment.rsc +4 -4
  330. package/app/.next/server/app/dashboard/translator.segments/_tree.segment.rsc +2 -2
  331. package/app/.next/server/app/dashboard/usage.html +1 -1
  332. package/app/.next/server/app/dashboard/usage.rsc +6 -6
  333. package/app/.next/server/app/dashboard/usage.segments/!KGRhc2hib2FyZCk/dashboard/usage/__PAGE__.segment.rsc +2 -2
  334. package/app/.next/server/app/dashboard/usage.segments/!KGRhc2hib2FyZCk/dashboard/usage.segment.rsc +1 -1
  335. package/app/.next/server/app/dashboard/usage.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  336. package/app/.next/server/app/dashboard/usage.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  337. package/app/.next/server/app/dashboard/usage.segments/_full.segment.rsc +6 -6
  338. package/app/.next/server/app/dashboard/usage.segments/_head.segment.rsc +1 -1
  339. package/app/.next/server/app/dashboard/usage.segments/_index.segment.rsc +4 -4
  340. package/app/.next/server/app/dashboard/usage.segments/_tree.segment.rsc +2 -2
  341. package/app/.next/server/app/dashboard.html +1 -1
  342. package/app/.next/server/app/dashboard.rsc +6 -6
  343. package/app/.next/server/app/dashboard.segments/!KGRhc2hib2FyZCk/dashboard/__PAGE__.segment.rsc +2 -2
  344. package/app/.next/server/app/dashboard.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  345. package/app/.next/server/app/dashboard.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  346. package/app/.next/server/app/dashboard.segments/_full.segment.rsc +6 -6
  347. package/app/.next/server/app/dashboard.segments/_head.segment.rsc +1 -1
  348. package/app/.next/server/app/dashboard.segments/_index.segment.rsc +4 -4
  349. package/app/.next/server/app/dashboard.segments/_tree.segment.rsc +2 -2
  350. package/app/.next/server/app/favicon.ico/route.js +1 -1
  351. package/app/.next/server/app/index.html +1 -1
  352. package/app/.next/server/app/index.rsc +4 -4
  353. package/app/.next/server/app/index.segments/__PAGE__.segment.rsc +1 -1
  354. package/app/.next/server/app/index.segments/_full.segment.rsc +4 -4
  355. package/app/.next/server/app/index.segments/_head.segment.rsc +1 -1
  356. package/app/.next/server/app/index.segments/_index.segment.rsc +4 -4
  357. package/app/.next/server/app/index.segments/_tree.segment.rsc +2 -2
  358. package/app/.next/server/app/landing/page.js +2 -2
  359. package/app/.next/server/app/landing/page_client-reference-manifest.js +1 -1
  360. package/app/.next/server/app/landing.html +1 -1
  361. package/app/.next/server/app/landing.rsc +4 -4
  362. package/app/.next/server/app/landing.segments/_full.segment.rsc +4 -4
  363. package/app/.next/server/app/landing.segments/_head.segment.rsc +1 -1
  364. package/app/.next/server/app/landing.segments/_index.segment.rsc +4 -4
  365. package/app/.next/server/app/landing.segments/_tree.segment.rsc +2 -2
  366. package/app/.next/server/app/landing.segments/landing/__PAGE__.segment.rsc +1 -1
  367. package/app/.next/server/app/landing.segments/landing.segment.rsc +1 -1
  368. package/app/.next/server/app/login/page.js +2 -2
  369. package/app/.next/server/app/login/page_client-reference-manifest.js +1 -1
  370. package/app/.next/server/app/login.html +1 -1
  371. package/app/.next/server/app/login.rsc +5 -5
  372. package/app/.next/server/app/login.segments/_full.segment.rsc +5 -5
  373. package/app/.next/server/app/login.segments/_head.segment.rsc +1 -1
  374. package/app/.next/server/app/login.segments/_index.segment.rsc +4 -4
  375. package/app/.next/server/app/login.segments/_tree.segment.rsc +2 -2
  376. package/app/.next/server/app/login.segments/login/__PAGE__.segment.rsc +2 -2
  377. package/app/.next/server/app/login.segments/login.segment.rsc +1 -1
  378. package/app/.next/server/app/manifest.webmanifest/route.js +2 -2
  379. package/app/.next/server/app/page.js +2 -2
  380. package/app/.next/server/app/page_client-reference-manifest.js +1 -1
  381. package/app/.next/server/app-paths-manifest.json +7 -7
  382. package/app/.next/server/chunks/1574.js +2 -2
  383. package/app/.next/server/chunks/1578.js +1 -1
  384. package/app/.next/server/chunks/2049.js +1 -1
  385. package/app/.next/server/chunks/21.js +1 -1
  386. package/app/.next/server/chunks/2141.js +1 -1
  387. package/app/.next/server/chunks/253.js +1 -1
  388. package/app/.next/server/chunks/2692.js +23 -0
  389. package/app/.next/server/chunks/450.js +2 -2
  390. package/app/.next/server/chunks/4627.js +1 -0
  391. package/app/.next/server/chunks/5053.js +2 -2
  392. package/app/.next/server/chunks/5339.js +1 -1
  393. package/app/.next/server/chunks/7171.js +1 -0
  394. package/app/.next/server/chunks/7770.js +1 -1
  395. package/app/.next/server/chunks/8035.js +1 -1
  396. package/app/.next/server/chunks/8146.js +1 -0
  397. package/app/.next/server/chunks/8193.js +1 -1
  398. package/app/.next/server/chunks/8202.js +5 -5
  399. package/app/.next/server/chunks/8513.js +13 -15
  400. package/app/.next/server/chunks/8565.js +1 -0
  401. package/app/.next/server/middleware-build-manifest.js +1 -1
  402. package/app/.next/server/middleware.js +4 -4
  403. package/app/.next/server/pages/404.html +1 -1
  404. package/app/.next/server/pages/500.html +1 -1
  405. package/app/.next/static/{twJQz13yvhkiPdQu-x4vH → 8WV1D5wSJM-rFNitgNW2w}/_buildManifest.js +1 -1
  406. package/app/.next/static/chunks/3116-d22342478579cb3e.js +23 -0
  407. package/app/.next/static/chunks/4156-e75862e66f88fee7.js +7 -0
  408. package/app/.next/static/chunks/505-c07518036138961d.js +1 -0
  409. package/app/.next/static/chunks/8035-5249f70deade9acb.js +3 -0
  410. package/app/.next/static/chunks/app/(dashboard)/dashboard/cli-tools/page-2709902f127ecc7a.js +1 -0
  411. package/app/.next/static/chunks/app/(dashboard)/dashboard/combos/page-24f203d25ad3f861.js +1 -0
  412. package/app/.next/static/chunks/app/(dashboard)/dashboard/media-providers/[kind]/[id]/page-99e1297a29f0994e.js +53 -0
  413. package/app/.next/static/chunks/app/(dashboard)/dashboard/media-providers/[kind]/page-5cb5ae93c4288788.js +1 -0
  414. package/app/.next/static/chunks/app/(dashboard)/dashboard/media-providers/combo/[id]/page-d994f22741fa26ed.js +4 -0
  415. package/app/.next/static/chunks/app/(dashboard)/dashboard/media-providers/web/page-617c9cc320c9aced.js +1 -0
  416. package/app/.next/static/chunks/app/(dashboard)/dashboard/mitm/page-862c58ef97db3add.js +1 -0
  417. package/app/.next/static/chunks/app/(dashboard)/dashboard/providers/[id]/{page-22e6b2c60c4849ad.js → page-20eb7b59c080e8f7.js} +1 -1
  418. package/app/.next/static/chunks/app/(dashboard)/dashboard/proxy-pools/page-2501132754f3396f.js +2 -0
  419. package/app/.next/static/chunks/app/(dashboard)/dashboard/quota/page-af74897e85d9d248.js +1 -0
  420. package/app/.next/static/chunks/app/(dashboard)/dashboard/usage/page-92b9dd8c50ab5e50.js +1 -0
  421. package/app/.next/static/chunks/app/dashboard/settings/pricing/page-77a73529baba955b.js +1 -0
  422. package/app/.next/static/chunks/app/login/page-2f45309b2d2ca209.js +1 -0
  423. package/app/.next/static/css/0b4644e922cfb228.css +1 -0
  424. package/app/package.json +1 -1
  425. package/app/public/i18n/literals/zh-CN.json +404 -127
  426. package/app/public/providers/cloudflare-ai.png +0 -0
  427. package/app/public/providers/nebius.png +0 -0
  428. package/app/src/mitm/server.js +34 -31
  429. package/cli.js +6 -0
  430. package/package.json +1 -1
  431. package/app/.next/server/app/(dashboard)/dashboard/media-providers/web/combo/[id]/page.js +0 -5
  432. package/app/.next/server/app/(dashboard)/dashboard/media-providers/web/combo/[id]/page.js.nft.json +0 -1
  433. package/app/.next/server/app/(dashboard)/dashboard/media-providers/web/combo/[id]/page_client-reference-manifest.js +0 -1
  434. package/app/.next/server/chunks/1301.js +0 -1
  435. package/app/.next/server/chunks/5221.js +0 -1
  436. package/app/.next/server/chunks/6560.js +0 -1
  437. package/app/.next/server/chunks/6762.js +0 -23
  438. package/app/.next/static/chunks/4156-3dd571c503014372.js +0 -7
  439. package/app/.next/static/chunks/4380-7f3ec9a5adb060e2.js +0 -23
  440. package/app/.next/static/chunks/505-61eefa51ae7fae57.js +0 -1
  441. package/app/.next/static/chunks/8035-be13431b81f6e555.js +0 -3
  442. package/app/.next/static/chunks/app/(dashboard)/dashboard/cli-tools/page-3d80412b21111041.js +0 -1
  443. package/app/.next/static/chunks/app/(dashboard)/dashboard/combos/page-3390652c042161bf.js +0 -1
  444. package/app/.next/static/chunks/app/(dashboard)/dashboard/media-providers/[kind]/[id]/page-51ab2246cec930f0.js +0 -53
  445. package/app/.next/static/chunks/app/(dashboard)/dashboard/media-providers/[kind]/page-1cd57da85dc9a5a0.js +0 -1
  446. package/app/.next/static/chunks/app/(dashboard)/dashboard/media-providers/web/combo/[id]/page-55f152f000244dfd.js +0 -4
  447. package/app/.next/static/chunks/app/(dashboard)/dashboard/media-providers/web/page-c02c96576b763028.js +0 -1
  448. package/app/.next/static/chunks/app/(dashboard)/dashboard/mitm/page-ef2689a6b468da49.js +0 -1
  449. package/app/.next/static/chunks/app/(dashboard)/dashboard/proxy-pools/page-7447209d1946170b.js +0 -2
  450. package/app/.next/static/chunks/app/(dashboard)/dashboard/quota/page-7d10d891e789f63e.js +0 -1
  451. package/app/.next/static/chunks/app/(dashboard)/dashboard/usage/page-17d9ef16d4d56317.js +0 -1
  452. package/app/.next/static/chunks/app/dashboard/settings/pricing/page-d9a2df5b3f666b3b.js +0 -1
  453. package/app/.next/static/chunks/app/login/page-2424ce8673ecf5cb.js +0 -1
  454. package/app/.next/static/css/06f471e66daf399e.css +0 -1
  455. /package/app/.next/static/{twJQz13yvhkiPdQu-x4vH → 8WV1D5wSJM-rFNitgNW2w}/_ssgManifest.js +0 -0
@@ -1,3 +0,0 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[8035],{64795:(e,t,s)=>{"use strict";s.d(t,{default:()=>m});var a=s(73365),l=s(1521),r=s(86447),n=s.n(r),i=s(74156),o=s(96459);let c=[{icon:"public",title:"Access Anywhere",desc:"Use your API from any network"},{icon:"group",title:"Share Endpoint",desc:"Share URL with team members"},{icon:"code",title:"Use in Cursor/Cline",desc:"Connect AI tools remotely"},{icon:"lock",title:"Encrypted",desc:"End-to-end TLS via Cloudflare"}],d=[{id:"lite",label:"Lite",desc:"Drop filler, keep grammar"},{id:"full",label:"Full",desc:"Drop articles, fragments OK"},{id:"ultra",label:"Ultra",desc:"Telegraphic, max compression"}];function m({machineId:e}){let[t,s]=(0,l.useState)([]),[r,n]=(0,l.useState)(!0),[b,g]=(0,l.useState)(!1),[y,f]=(0,l.useState)(""),[j,k]=(0,l.useState)(null),[w,v]=(0,l.useState)(!1),[N,C]=(0,l.useState)(!0),[S,T]=(0,l.useState)(!0),[_,P]=(0,l.useState)(!1),[E,$]=(0,l.useState)(!0),[A,U]=(0,l.useState)(!1),[D,O]=(0,l.useState)("full"),[F,I]=(0,l.useState)(!0),[L,W]=(0,l.useState)(!1),[R,q]=(0,l.useState)(""),[K,J]=(0,l.useState)(""),[M,z]=(0,l.useState)(!1),[H,Z]=(0,l.useState)(""),[B,Q]=(0,l.useState)(null),[V,G]=(0,l.useState)(!1),[X,Y]=(0,l.useState)(!1),[ee,et]=(0,l.useState)(!1),[es,ea]=(0,l.useState)(""),[el,er]=(0,l.useState)(!1),[en,ei]=(0,l.useState)(""),[eo,ec]=(0,l.useState)(null),[ed,em]=(0,l.useState)(null),[ex,eh]=(0,l.useState)(!1),[eu,ep]=(0,l.useState)([]),[eb,eg]=(0,l.useState)(""),[ey,ef]=(0,l.useState)(!1),[ej,ek]=(0,l.useState)(!1),[ew,ev]=(0,l.useState)(!1),eN=(0,l.useRef)(null),[eC,eS]=(0,l.useState)(new Set),{copied:eT,copy:e_}=(0,o.C)();(0,l.useEffect)(()=>{eN.current&&(eN.current.scrollTop=eN.current.scrollHeight)},[eu]),(0,l.useEffect)(()=>{eD(),eP()},[]);let eP=async()=>{I(!0);try{let[e,t]=await Promise.all([fetch("/api/settings"),fetch("/api/tunnel/status")]);if(e.ok){let t=await e.json();v(t.requireApiKey||!1),C(!1!==t.requireLogin),T(t.hasPassword||!1),P(t.tunnelDashboardAccess||!1),$(!1!==t.rtkEnabled),U(!!t.cavemanEnabled),O(t.cavemanLevel||"full")}if(t.ok){let e=await t.json(),s=e.tunnel?.enabled||!1,a=e.tunnel?.tunnelUrl||"",l=e.tunnel?.publicUrl||"";q(a),J(l);let r=e.tailscale?.enabled||!1,n=e.tailscale?.tunnelUrl||"";if(ea(n),r&&n){er(!0),ei("Checking Tailscale...");let e=`${n}/api/health`;try{let t=await fetch(e,{mode:"no-cors",cache:"no-store"});if(t.ok||"opaque"===t.type)et(!0);else{let e=await eR(n);et(e),e||ec({type:"warning",message:"Tailscale not reachable."})}}catch{let e=await eR(n);et(e),e||ec({type:"warning",message:"Tailscale not reachable."})}finally{er(!1),ei("")}}else et(r);if(s&&(l||a)){let e=`${l||a}/api/health`;try{(await fetch(e,{cache:"no-store"})).ok?W(!0):eO(l||a)}catch{eO(l||a)}}else W(s)}}catch(e){console.log("Error loading settings:",e)}finally{I(!1)}},eE=async e=>{try{(await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({tunnelDashboardAccess:e})})).ok&&P(e)}catch(e){console.log("Error updating tunnelDashboardAccess:",e)}},e$=async e=>{try{(await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({requireApiKey:e})})).ok&&v(e)}catch(e){console.log("Error updating requireApiKey:",e)}},eA=async e=>{try{(await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({rtkEnabled:e})})).ok&&$(e)}catch(e){console.log("Error updating rtkEnabled:",e)}},eU=async e=>{try{await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}catch(e){console.log("Error updating setting:",e)}},eD=async()=>{try{let e=await fetch("/api/keys"),t=await e.json();e.ok&&s(t.keys||[])}catch(e){console.log("Error fetching data:",e)}finally{n(!1)}},eO=async e=>{z(!0),Z("Waiting for tunnel ready...");let t=`${e}/api/health`,s=Date.now();for(;Date.now()-s<3e5;){await new Promise(e=>setTimeout(e,2e3));try{let e=await fetch(t,{mode:"no-cors",cache:"no-store"});if(e.ok||"opaque"===e.type)return W(!0),z(!1),Z(""),!0}catch{}if((Date.now()-s)%1e4<2e3)try{let e=await fetch("/api/tunnel/status");if(e.ok){let t=await e.json();if(!t.tunnel?.enabled)return Q({type:"error",message:"Tunnel process stopped unexpectedly."}),z(!1),Z(""),!1}}catch{}}return Q({type:"error",message:"Tunnel created but not reachable. Please try again."}),z(!1),Z(""),!1},eF=async()=>{G(!1),z(!0),Q(null),Z("Creating tunnel...");let e=!0;(async()=>{for(;e;){try{let t=await fetch("/api/tunnel/status");if(t.ok){let s=await t.json();s.download?.downloading?Z(`Downloading cloudflared... ${s.download.progress}%`):e&&Z("Creating tunnel...")}}catch{}await new Promise(e=>setTimeout(e,1e3))}})();try{let t=await fetch("/api/tunnel/enable",{method:"POST"});e=!1;let s=await t.json();if(!t.ok)return void Q({type:"error",message:s.error||"Failed to enable tunnel"});let a=s.publicUrl||s.tunnelUrl;if(!a)return void Q({type:"error",message:"No tunnel URL returned"});q(s.tunnelUrl||""),J(s.publicUrl||""),await eO(a)}catch(e){Q({type:"error",message:e.message})}finally{e=!1,z(!1),Z("")}},eI=async()=>{z(!0),Q(null);try{let e=await fetch("/api/tunnel/disable",{method:"POST"}),t=await e.json();e.ok?(W(!1),q(""),J(""),Y(!1),Q({type:"success",message:"Tunnel disabled"})):Q({type:"error",message:t.error||"Failed to disable tunnel"})}catch(e){Q({type:"error",message:e.message})}finally{z(!1)}},eL=async()=>{em(null);try{let e=await fetch("/api/tunnel/tailscale-check");if(e.ok){let t=await e.json();return em(t.installed),t}}catch{}return em(!1),{installed:!1}},eW=async()=>{eh(!0),ec(null),ep([]);try{let e=await fetch("/api/tunnel/tailscale-install",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sudoPassword:eb})});eg("");let t=e.body.getReader(),s=new TextDecoder,a="";for(;;){let{done:e,value:l}=await t.read();if(e)break;let r=(a+=s.decode(l,{stream:!0})).split("\n\n");for(let e of(a=r.pop()||"",r)){let t=e.split("\n"),s="progress",a=null;for(let e of t)if(e.startsWith("event: ")&&(s=e.slice(7).trim()),e.startsWith("data: "))try{a=JSON.parse(e.slice(6))}catch{}if(a)if("progress"===s)ep(e=>[...e.slice(-50),a.message]);else if("done"===s){em(!0),eh(!1);return}else"error"===s&&ec({type:"error",message:a.error||"Install failed"})}}}catch(e){ec({type:"error",message:e.message})}finally{eh(!1)}},eR=async e=>{ei("Waiting for Tailscale ready...");let t=`${e}/api/health`,s=Date.now();for(;Date.now()-s<3e5;){await new Promise(e=>setTimeout(e,2e3));try{let e=await fetch(t,{mode:"no-cors",cache:"no-store"});if(e.ok||"opaque"===e.type)return!0}catch{}}return!1},eq=async e=>{let t=e||null;ek(!1),ef(!0),er(!0),ec(null),ei("Connecting...");try{let e=await fetch("/api/tunnel/tailscale-enable",{method:"POST"}),s=await e.json();if(e.ok&&s.success){t&&t.close(),ea(s.tunnelUrl||""),await eR(s.tunnelUrl)?(et(!0),ec(null)):(et(!0),ec({type:"warning",message:"Connected but not reachable yet."}));return}if(s.needsLogin&&s.authUrl){t?t.location.href=s.authUrl:window.open(s.authUrl,"tailscale_auth","width=600,height=700"),ei("Waiting for login...");for(let e=0;e<40;e++){await new Promise(e=>setTimeout(e,3e3));try{let e=await fetch("/api/tunnel/tailscale-check");if(e.ok&&(await e.json()).loggedIn){ei("Starting funnel...");let e=await fetch("/api/tunnel/tailscale-enable",{method:"POST"}),s=await e.json();e.ok&&s.success?(t&&t.close(),ea(s.tunnelUrl||""),await eR(s.tunnelUrl)?(et(!0),ec(null)):(et(!0),ec({type:"warning",message:"Connected but not reachable yet."}))):s.funnelNotEnabled&&s.enableUrl?await eK(s.enableUrl,t):ec({type:"error",message:s.error||"Failed to start funnel"});return}}catch{}}ec({type:"error",message:"Login timed out. Please try again."});return}if(s.funnelNotEnabled&&s.enableUrl)return void await eK(s.enableUrl,t);t&&t.close(),ec({type:"error",message:s.error||"Failed to connect"})}catch(e){t&&t.close(),ec({type:"error",message:e.message})}finally{er(!1),ef(!1),ei("")}},eK=async(e,t)=>{t?t.location.href=e:window.open(e,"tailscale_auth","width=600,height=700"),ei("Enable Funnel in browser, waiting...");for(let e=0;e<40;e++){await new Promise(e=>setTimeout(e,3e3));try{let e=await fetch("/api/tunnel/tailscale-enable",{method:"POST"}),s=await e.json();if(e.ok&&s.success){t&&t.close(),ea(s.tunnelUrl||""),await eR(s.tunnelUrl)?(et(!0),ec(null)):(et(!0),ec({type:"warning",message:"Connected but not reachable yet."}));return}if(s.funnelNotEnabled)continue;if(s.error)return void ec({type:"error",message:s.error})}catch{}}ec({type:"error",message:"Timed out waiting for Funnel to be enabled."})},eJ=async()=>{er(!0),ec(null);try{let e=await fetch("/api/tunnel/tailscale-disable",{method:"POST"}),t=await e.json();e.ok?(et(!1),ea(""),ev(!1),ec({type:"success",message:"Tailscale disabled"})):ec({type:"error",message:t.error||"Failed to disable Tailscale"})}catch(e){ec({type:"error",message:e.message})}finally{er(!1)}},eM=async()=>{ec(null),ep([]),ek(!0),await eL()},ez=async()=>{if(y.trim())try{let e=await fetch("/api/keys",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:y})}),t=await e.json();e.ok&&(k(t.key),await eD(),f(""),g(!1))}catch(e){console.log("Error creating key:",e)}},eH=async e=>{if(confirm("Delete this API key?"))try{(await fetch(`/api/keys/${e}`,{method:"DELETE"})).ok&&(s(t.filter(t=>t.id!==e)),eS(t=>{let s=new Set(t);return s.delete(e),s}))}catch(e){console.log("Error deleting key:",e)}},eZ=async(e,t)=>{try{(await fetch(`/api/keys/${e}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({isActive:t})})).ok&&s(s=>s.map(s=>s.id===e?{...s,isActive:t}:s))}catch(e){console.log("Error toggling key:",e)}},[eB,eQ]=(0,l.useState)("/v1");return((0,l.useEffect)(()=>{eQ(`${window.location.origin}/v1`)},[]),r)?(0,a.jsxs)("div",{className:"flex flex-col gap-8",children:[(0,a.jsx)(i.Qv,{}),(0,a.jsx)(i.Qv,{})]}):(0,a.jsxs)("div",{className:"flex flex-col gap-8",children:[(0,a.jsxs)(i.Zp,{children:[(0,a.jsx)("h2",{className:"text-lg font-semibold mb-4",children:"API Endpoint"}),(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,a.jsx)(x,{label:"Local",url:eB,copyId:"local_url",copied:eT,onCopy:e_}),(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:`text-xs font-mono px-1.5 py-0.5 rounded shrink-0 min-w-[68px] text-center ${L?"bg-orange-100 dark:bg-orange-900/30 text-orange-600 dark:text-orange-400":"bg-sidebar text-text-muted"}`,children:"Tunnel"}),L&&!M?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(i.pd,{value:`${K||R}/v1`,readOnly:!0,className:"flex-1 font-mono text-sm"}),(0,a.jsx)("button",{onClick:()=>e_(`${K||R}/v1`,"tunnel_url"),className:"p-2 hover:bg-black/5 dark:hover:bg-white/5 rounded text-text-muted hover:text-primary transition-colors shrink-0",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"tunnel_url"===eT?"check":"content_copy"})}),(0,a.jsx)("button",{onClick:()=>Y(!0),className:"p-2 hover:bg-red-500/10 rounded text-red-500 transition-colors shrink-0",title:"Disable Tunnel",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"power_settings_new"})})]}):M?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"flex-1 flex items-center gap-2 px-3 py-1.5 rounded border border-border bg-input text-sm text-text-muted",children:[(0,a.jsx)("span",{className:"material-symbols-outlined animate-spin text-sm",children:"progress_activity"}),H||"Creating tunnel..."]}),(0,a.jsx)("button",{onClick:()=>{z(!1),Z("")},className:"p-2 hover:bg-red-500/10 rounded text-red-500 transition-colors shrink-0",title:"Stop",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"power_settings_new"})})]}):B?.type==="error"?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"flex-1 flex items-center gap-2 px-3 py-1.5 rounded border border-red-300 dark:border-red-800 bg-red-500/5 text-sm text-red-600 dark:text-red-400",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:"error"}),B.message]}),(0,a.jsx)(i.$n,{size:"sm",icon:"cloud_upload",onClick:()=>G(!0),children:"Enable"})]}):F?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"flex-1 flex items-center gap-2 px-3 py-1.5 rounded border border-border bg-input text-sm text-text-muted",children:[(0,a.jsx)("span",{className:"material-symbols-outlined animate-spin text-sm",children:"progress_activity"}),"Checking..."]}),(0,a.jsx)("button",{onClick:()=>I(!1),className:"p-2 hover:bg-red-500/10 rounded text-red-500 transition-colors shrink-0",title:"Stop",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"power_settings_new"})})]}):(0,a.jsx)(i.$n,{size:"sm",icon:"cloud_upload",onClick:()=>{w?G(!0):Q({type:"error",message:'Security required: Enable "Require API key" before activating the tunnel.'})},className:"bg-linear-to-r from-primary to-blue-500 hover:from-primary-hover hover:to-blue-600 text-white!",children:"Enable"})]}),(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:`text-xs font-mono px-1.5 py-0.5 rounded shrink-0 min-w-[68px] text-center ${ee?"bg-purple-100 dark:bg-purple-900/30 text-purple-600 dark:text-purple-400":"bg-sidebar text-text-muted"}`,children:"Tailscale"}),ee&&!el?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(i.pd,{value:`${es}/v1`,readOnly:!0,className:"flex-1 font-mono text-sm"}),(0,a.jsx)("button",{onClick:()=>e_(`${es}/v1`,"ts_url"),className:"p-2 hover:bg-black/5 dark:hover:bg-white/5 rounded text-text-muted hover:text-primary transition-colors shrink-0",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"ts_url"===eT?"check":"content_copy"})}),(0,a.jsx)("button",{onClick:()=>ev(!0),className:"p-2 hover:bg-red-500/10 rounded text-red-500 transition-colors shrink-0",title:"Disable Tailscale",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"power_settings_new"})})]}):el||ey?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"flex-1 flex items-center gap-2 px-3 py-1.5 rounded border border-border bg-input text-sm text-text-muted",children:[(0,a.jsx)("span",{className:"material-symbols-outlined animate-spin text-sm",children:"progress_activity"}),en||"Connecting..."]}),(0,a.jsx)("button",{onClick:()=>{er(!1),ef(!1),ei("")},className:"p-2 hover:bg-red-500/10 rounded text-red-500 transition-colors shrink-0",title:"Stop",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"power_settings_new"})})]}):eo?.type==="error"?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"flex-1 flex items-center gap-2 px-3 py-1.5 rounded border border-red-300 dark:border-red-800 bg-red-500/5 text-sm text-red-600 dark:text-red-400",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:"error"}),eo.message]}),(0,a.jsx)(i.$n,{size:"sm",icon:"vpn_lock",onClick:eM,children:"Enable"})]}):(0,a.jsx)(i.$n,{size:"sm",icon:"vpn_lock",onClick:eM,className:"bg-linear-to-r from-indigo-500 to-purple-500 hover:from-indigo-600 hover:to-purple-600 text-white!",children:"Enable"})]})]}),(L||ee)&&(0,a.jsxs)("div",{className:"mt-4 flex flex-col gap-2",children:[!w&&(0,a.jsx)(p,{message:"Require API key is disabled — your endpoint is publicly accessible without authentication.",action:{label:"Enable",href:"#require-api-key"}}),(!N||!S)&&(0,a.jsx)(p,{message:N?"Dashboard uses the default password — change it in Profile settings.":"Require login is disabled — anyone can access your dashboard via tunnel.",action:{label:N?"Change password":"Enable",href:"/dashboard/profile"}})]}),(L||ee)&&(0,a.jsxs)("div",{className:"mt-4 pt-4 border-t border-border flex items-center gap-3",children:[(0,a.jsx)(i.lM,{checked:_,onChange:()=>eE(!_)}),(0,a.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,a.jsx)("p",{className:"font-medium text-sm",children:"Allow dashboard access via tunnel"}),(0,a.jsx)(u,{text:"When enabled, the dashboard can be accessed through your tunnel or Tailscale URL (login still required). When disabled, dashboard access via tunnel/Tailscale is completely blocked."})]})]})]}),(0,a.jsxs)(i.Zp,{id:"rtk",children:[(0,a.jsx)("div",{className:"flex items-center justify-between mb-2",children:(0,a.jsx)("h2",{className:"text-lg font-semibold",children:"Token Saver"})}),(0,a.jsxs)("div",{className:"flex items-center justify-between pt-2 pb-4 border-b border-border",children:[(0,a.jsxs)("div",{className:"pr-4",children:[(0,a.jsxs)("p",{className:"font-medium",children:["Compress tool output"," ",(0,a.jsx)("a",{href:"https://github.com/rtk-ai/rtk",target:"_blank",rel:"noreferrer",className:"text-xs font-normal text-primary underline hover:opacity-80",children:"(RTK)"})]}),(0,a.jsx)("p",{className:"text-sm text-text-muted",children:"Auto-compress tool output (git diff/grep/ls/tree/logs) before sending to LLM (60-90% fewer input tokens on common dev commands). Disable if you see issues."})]}),(0,a.jsx)(i.lM,{checked:E,onChange:()=>eA(!E)})]}),(0,a.jsxs)("div",{className:"flex items-center justify-between pt-4",children:[(0,a.jsxs)("div",{className:"pr-4",children:[(0,a.jsxs)("p",{className:"font-medium",children:["Compress LLM output"," ",(0,a.jsx)("a",{href:"https://github.com/JuliusBrussee/caveman",target:"_blank",rel:"noreferrer",className:"text-xs font-normal text-primary underline hover:opacity-80",children:"(Caveman)"})]}),(0,a.jsx)("p",{className:"text-sm text-text-muted",children:"Inject a terse-style instruction into the system prompt so the LLM replies shorter (~65% fewer output tokens on average, up to 87%). Code, errors and warnings stay exact."})]}),(0,a.jsx)(i.lM,{checked:A,onChange:()=>{var e;U(e=!A),eU({cavemanEnabled:e})}})]}),A&&(0,a.jsx)("div",{className:"mt-3 flex items-center gap-2",children:d.map(e=>(0,a.jsx)("button",{onClick:()=>{var t;O(t=e.id),eU({cavemanLevel:t})},className:`px-3 py-1.5 rounded text-xs font-medium border transition-colors ${D===e.id?"bg-primary text-white border-primary":"bg-transparent border-border text-text-muted hover:bg-black/5 dark:hover:bg-white/5"}`,title:e.desc,children:e.label},e.id))})]}),(0,a.jsxs)(i.Zp,{id:"require-api-key",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,a.jsx)("h2",{className:"text-lg font-semibold",children:"API Keys"}),(0,a.jsx)(i.$n,{icon:"add",onClick:()=>g(!0),children:"Create Key"})]}),(0,a.jsxs)("div",{className:"flex items-center justify-between pb-4 mb-4 border-b border-border",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"font-medium",children:"Require API key"}),(0,a.jsx)("p",{className:"text-sm text-text-muted",children:"Requests without a valid key will be rejected"})]}),(0,a.jsx)(i.lM,{checked:w,onChange:()=>e$(!w)})]}),0===t.length?(0,a.jsxs)("div",{className:"text-center py-12",children:[(0,a.jsx)("div",{className:"inline-flex items-center justify-center w-16 h-16 rounded-full bg-primary/10 text-primary mb-4",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[32px]",children:"vpn_key"})}),(0,a.jsx)("p",{className:"text-text-main font-medium mb-1",children:"No API keys yet"}),(0,a.jsx)("p",{className:"text-sm text-text-muted mb-4",children:"Create your first API key to get started"}),(0,a.jsx)(i.$n,{icon:"add",onClick:()=>g(!0),children:"Create Key"})]}):(0,a.jsx)("div",{className:"flex flex-col",children:t.map(e=>{var t;return(0,a.jsxs)("div",{className:`group flex items-center justify-between py-3 border-b border-black/[0.03] dark:border-white/[0.03] last:border-b-0 ${!1===e.isActive?"opacity-60":""}`,children:[(0,a.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,a.jsx)("p",{className:"text-sm font-medium",children:e.name}),(0,a.jsxs)("div",{className:"flex items-center gap-2 mt-1",children:[(0,a.jsx)("code",{className:"text-xs text-text-muted font-mono",children:eC.has(e.id)?e.key:(t=e.key)?t.length>8?t.slice(0,8)+"...":t:""}),(0,a.jsx)("button",{onClick:()=>{var t;return t=e.id,void eS(e=>{let s=new Set(e);return s.has(t)?s.delete(t):s.add(t),s})},className:"p-1 hover:bg-black/5 dark:hover:bg-white/5 rounded text-text-muted hover:text-primary opacity-0 group-hover:opacity-100 transition-all",title:eC.has(e.id)?"Hide key":"Show key",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:eC.has(e.id)?"visibility_off":"visibility"})}),(0,a.jsx)("button",{onClick:()=>e_(e.key,e.id),className:"p-1 hover:bg-black/5 dark:hover:bg-white/5 rounded text-text-muted hover:text-primary opacity-0 group-hover:opacity-100 transition-all",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:eT===e.id?"check":"content_copy"})})]}),(0,a.jsxs)("p",{className:"text-xs text-text-muted mt-1",children:["Created ",new Date(e.createdAt).toLocaleDateString()]}),!1===e.isActive&&(0,a.jsx)("p",{className:"text-xs text-orange-500 mt-1",children:"Paused"})]}),(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)(i.lM,{size:"sm",checked:e.isActive??!0,onChange:t=>{e.isActive&&!t?confirm(`Pause API key "${e.name}"?
2
-
3
- This key will stop working immediately but can be resumed later.`)&&eZ(e.id,t):eZ(e.id,t)},title:e.isActive?"Pause key":"Resume key"}),(0,a.jsx)("button",{onClick:()=>eH(e.id),className:"p-2 hover:bg-red-500/10 rounded text-red-500 opacity-0 group-hover:opacity-100 transition-all",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"delete"})})]})]},e.id)})})]}),(0,a.jsx)(i.aF,{isOpen:b,title:"Create API Key",onClose:()=>{g(!1),f("")},children:(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,a.jsx)(i.pd,{label:"Key Name",value:y,onChange:e=>f(e.target.value),placeholder:"Production Key"}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(i.$n,{onClick:ez,fullWidth:!0,disabled:!y.trim(),children:"Create"}),(0,a.jsx)(i.$n,{onClick:()=>{g(!1),f("")},variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})}),(0,a.jsx)(i.aF,{isOpen:!!j,title:"API Key Created",onClose:()=>k(null),children:(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,a.jsxs)("div",{className:"bg-yellow-50 dark:bg-yellow-900/20 border border-yellow-200 dark:border-yellow-800 rounded-lg p-4",children:[(0,a.jsx)("p",{className:"text-sm text-yellow-800 dark:text-yellow-200 mb-2 font-medium",children:"Save this key now!"}),(0,a.jsx)("p",{className:"text-sm text-yellow-700 dark:text-yellow-300",children:"This is the only time you will see this key. Store it securely."})]}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(i.pd,{value:j||"",readOnly:!0,className:"flex-1 font-mono text-sm"}),(0,a.jsx)(i.$n,{variant:"secondary",icon:"created_key"===eT?"check":"content_copy",onClick:()=>e_(j,"created_key"),children:"created_key"===eT?"Copied!":"Copy"})]}),(0,a.jsx)(i.$n,{onClick:()=>k(null),fullWidth:!0,children:"Done"})]})}),(0,a.jsx)(i.aF,{isOpen:V,title:"Enable Tunnel",onClose:()=>G(!1),children:(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,a.jsx)("div",{className:"bg-blue-50 dark:bg-blue-900/20 border border-blue-200 dark:border-blue-800 rounded-lg p-4",children:(0,a.jsxs)("div",{className:"flex items-start gap-3",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-blue-600 dark:text-blue-400",children:"cloud_upload"}),(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"text-sm text-blue-800 dark:text-blue-200 font-medium mb-1",children:"Cloudflare Tunnel"}),(0,a.jsx)("p",{className:"text-sm text-blue-700 dark:text-blue-300",children:"Expose your local 9Router to the internet. No port forwarding, no static IP needed. Share endpoint URL with your team or use it in Cursor, Cline, and other AI tools from anywhere."})]})]})}),(0,a.jsx)("div",{className:"grid grid-cols-2 gap-3",children:c.map(e=>(0,a.jsxs)("div",{className:"flex flex-col items-center text-center p-3 rounded-lg bg-sidebar/50",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-xl text-primary mb-1",children:e.icon}),(0,a.jsx)("p",{className:"text-xs font-semibold",children:e.title}),(0,a.jsx)("p",{className:"text-xs text-text-muted",children:e.desc})]},e.title))}),(0,a.jsx)("p",{className:"text-xs text-text-muted",children:"Requires outbound port 7844 (TCP/UDP). Connection may take 10-30s."}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(i.$n,{onClick:eF,fullWidth:!0,className:"bg-linear-to-r from-primary to-blue-500 hover:from-primary-hover hover:to-blue-600 text-white!",children:"Start Tunnel"}),(0,a.jsx)(i.$n,{onClick:()=>G(!1),variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})}),(0,a.jsx)(i.aF,{isOpen:X,title:"Disable Tunnel",onClose:()=>!M&&Y(!1),children:(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,a.jsx)("p",{className:"text-sm text-text-muted",children:"The Cloudflare tunnel will be disconnected. Remote access via tunnel URL will stop working."}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(i.$n,{onClick:eI,fullWidth:!0,disabled:M,className:"bg-red-500! hover:bg-red-600! text-white!",children:M?"Disabling...":"Disable"}),(0,a.jsx)(i.$n,{onClick:()=>Y(!1),variant:"ghost",fullWidth:!0,disabled:M,children:"Cancel"})]})]})}),(0,a.jsx)(i.aF,{isOpen:ej,title:"Tailscale Funnel",onClose:()=>{ex||(ek(!1),eg(""),ec(null))},children:(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[null===ed&&(0,a.jsxs)("p",{className:"text-sm text-text-muted flex items-center gap-2",children:[(0,a.jsx)("span",{className:"material-symbols-outlined animate-spin text-sm",children:"progress_activity"}),"Checking..."]}),!1===ed&&!ex&&(0,a.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,a.jsx)("p",{className:"text-sm text-text-muted",children:"Tailscale is not installed. Install it to enable Funnel."}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(i.$n,{onClick:eW,fullWidth:!0,className:"bg-linear-to-r from-indigo-500 to-purple-500 hover:from-indigo-600 hover:to-purple-600 text-white!",children:"Install Tailscale"}),(0,a.jsx)(i.$n,{onClick:()=>ek(!1),variant:"ghost",fullWidth:!0,children:"Cancel"})]})]}),ex&&(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2 text-sm text-text-muted",children:[(0,a.jsx)("span",{className:"material-symbols-outlined animate-spin text-sm",children:"progress_activity"}),"Installing Tailscale..."]}),eu.length>0&&(0,a.jsx)("div",{ref:eN,className:"bg-black/5 dark:bg-white/5 rounded p-2 max-h-40 overflow-y-auto font-mono text-xs text-text-muted",children:eu.map((e,t)=>(0,a.jsx)("div",{children:e},t))})]}),!0===ed&&!ex&&(0,a.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2 text-sm text-green-600 dark:text-green-400",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"check_circle"}),"Tailscale installed"]}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(i.$n,{onClick:()=>{let e=window.open("","tailscale_auth","width=600,height=700");e&&e.document.write("<p style='font-family:sans-serif;text-align:center;margin-top:40px'>Connecting to Tailscale...</p>"),eq(e)},fullWidth:!0,className:"bg-linear-to-r from-indigo-500 to-purple-500 hover:from-indigo-600 hover:to-purple-600 text-white!",children:"Connect"}),(0,a.jsx)(i.$n,{onClick:()=>ek(!1),variant:"ghost",fullWidth:!0,children:"Cancel"})]})]}),eo&&(0,a.jsx)(h,{status:eo})]})}),(0,a.jsx)(i.aF,{isOpen:ew,title:"Disable Tailscale",onClose:()=>!el&&ev(!1),children:(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,a.jsx)("p",{className:"text-sm text-text-muted",children:"Tailscale Funnel will be stopped. Remote access via Tailscale URL will stop working."}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(i.$n,{onClick:eJ,fullWidth:!0,disabled:el,className:"bg-red-500! hover:bg-red-600! text-white!",children:el?"Disabling...":"Disable"}),(0,a.jsx)(i.$n,{onClick:()=>ev(!1),variant:"ghost",fullWidth:!0,disabled:el,children:"Cancel"})]})]})})]})}function x({label:e,url:t,copyId:s,copied:l,onCopy:r,badge:n,actions:o}){return(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:`text-xs font-mono px-1.5 py-0.5 rounded shrink-0 min-w-[68px] text-center ${"CF"===n?"bg-orange-100 dark:bg-orange-900/30 text-orange-600 dark:text-orange-400":"TS"===n?"bg-purple-100 dark:bg-purple-900/30 text-purple-600 dark:text-purple-400":"bg-sidebar text-text-muted"}`,children:e}),(0,a.jsx)(i.pd,{value:t,readOnly:!0,className:"flex-1 font-mono text-sm"}),(0,a.jsx)("button",{onClick:()=>r(t,s),className:"p-2 hover:bg-black/5 dark:hover:bg-white/5 rounded text-text-muted hover:text-primary transition-colors shrink-0",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:l===s?"check":"content_copy"})}),o]})}function h({status:e,className:t=""}){return(0,a.jsx)("div",{className:`p-2 rounded text-sm ${t} ${"success"===e.type?"bg-green-500/10 text-green-600 dark:text-green-400":"warning"===e.type?"bg-yellow-500/10 text-yellow-600 dark:text-yellow-400":"info"===e.type?"bg-blue-500/10 text-blue-600 dark:text-blue-400":"bg-red-500/10 text-red-600 dark:text-red-400"}`,children:e.message.split(/(https?:\/\/[^\s]+)/g).map((e,t)=>/^https?:\/\//.test(e)?(0,a.jsx)("a",{href:e,target:"_blank",rel:"noreferrer",className:"underline font-medium",children:e},t):e)})}function u({text:e}){return(0,a.jsxs)("span",{className:"relative group inline-flex items-center",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px] text-text-muted cursor-help",children:"help"}),(0,a.jsx)("span",{className:"pointer-events-none absolute left-5 top-1/2 -translate-y-1/2 z-50 w-64 rounded bg-gray-900 dark:bg-gray-800 text-white text-xs px-2.5 py-1.5 opacity-0 group-hover:opacity-100 transition-opacity shadow-lg",children:e})]})}function p({message:e,action:t}){return(0,a.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 rounded-lg bg-amber-500/10 border border-amber-500/20 text-amber-700 dark:text-amber-400",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[16px] shrink-0 mt-0.5",children:"warning"}),(0,a.jsx)("p",{className:"text-xs flex-1",children:e}),t&&(0,a.jsx)("a",{href:t.href,className:"text-xs font-medium underline shrink-0 hover:opacity-80",onClick:t.href.startsWith("#")?e=>{e.preventDefault(),document.getElementById(t.href.slice(1))?.scrollIntoView({behavior:"smooth"})}:void 0,children:t.label})]})}m.propTypes={machineId:n().string.isRequired}},78035:(e,t,s)=>{Promise.resolve().then(s.bind(s,64795))}}]);
@@ -1 +0,0 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[2326],{46772:(e,t,s)=>{"use strict";s.d(t,{default:()=>u});var a=s(73365),i=s(1521),l=s(74156),o=s(97990),r=s(69633),c=s(7127);let n=s(89651).env.NEXT_PUBLIC_CLOUD_URL,d={claude:"/api/cli-tools/claude-settings",codex:"/api/cli-tools/codex-settings",opencode:"/api/cli-tools/opencode-settings",droid:"/api/cli-tools/droid-settings",openclaw:"/api/cli-tools/openclaw-settings",hermes:"/api/cli-tools/hermes-settings"};function u({machineId:e}){let t,s,x,[p,h]=(0,i.useState)([]),[v,m]=(0,i.useState)(!0),[g,f]=(0,i.useState)(null),[j,b]=(0,i.useState)({}),[w,E]=(0,i.useState)(!1),[y,P]=(0,i.useState)(!1),[S,N]=(0,i.useState)(""),[k,C]=(0,i.useState)([]),[_,O]=(0,i.useState)({});(0,i.useEffect)(()=>{T(),M(),I(),A()},[]);let A=async()=>{try{let e=await Promise.all(Object.entries(d).map(async([e,t])=>{try{let s=await fetch(t),a=await s.json();return[e,a]}catch{return[e,null]}}));O(Object.fromEntries(e))}catch(e){console.log("Error fetching tool statuses:",e)}},M=async()=>{try{let[e,t]=await Promise.all([fetch("/api/settings"),fetch("/api/tunnel/status")]);if(e.ok){let t=await e.json();E(t.cloudEnabled||!1)}if(t.ok){let e=await t.json();P(e.enabled||!1),N(e.publicUrl||"")}}catch(e){console.log("Error loading settings:",e)}},I=async()=>{try{let e=await fetch("/api/keys");if(e.ok){let t=await e.json();C(t.keys||[])}}catch(e){console.log("Error fetching API keys:",e)}},T=async()=>{try{let e=await fetch("/api/providers"),t=await e.json();e.ok&&h(t.connections||[])}catch(e){console.log("Error fetching connections:",e)}finally{m(!1)}},U=()=>p.filter(e=>!1!==e.isActive),L=(0,i.useCallback)((e,t,s)=>{b(a=>a[e]?.[t]===s?a:{...a,[e]:{...a[e],[t]:s}})},[]);if(v)return(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,a.jsx)(l.Qv,{}),(0,a.jsx)(l.Qv,{}),(0,a.jsx)(l.Qv,{})]});let $=(t=U(),s=[],x=new Set,t.forEach(e=>{let t=r.Xg[e.provider]||e.provider;(0,r.KC)(e.provider).forEach(a=>{let i=`${t}/${a.id}`;x.has(i)||(x.add(i),s.push({value:i,label:`${t}/${a.id}`,provider:e.provider,alias:t,connectionName:e.name,modelId:a.id}))})}),s).length>0,Q=Object.entries(o.dM),R=Object.entries(o.wn);return(0,a.jsxs)("div",{className:"mx-auto flex w-full max-w-5xl flex-col gap-6 px-1 sm:px-0",children:[(0,a.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,a.jsx)("h1",{className:"text-xl font-semibold text-text-main sm:text-2xl",children:"CLI Tools"}),(0,a.jsx)("p",{className:"text-sm text-text-muted",children:"Configure local coding tools to use your 9Router providers."})]}),(0,a.jsx)("div",{className:"grid gap-3 sm:gap-4",children:Q.map(([e,t])=>((e,t)=>{let s={tool:t,isExpanded:g===e,onToggle:()=>f(g===e?null:e),baseUrl:y&&S?S:w&&n?n:window.location.origin,apiKeys:k};switch(e){case"claude":return(0,a.jsx)(c.Tk,{...s,activeProviders:U(),modelMappings:j[e]||{},onModelMappingChange:(t,s)=>L(e,t,s),hasActiveProviders:$,cloudEnabled:w,initialStatus:_.claude},e);case"codex":return(0,a.jsx)(c.Ah,{...s,activeProviders:U(),cloudEnabled:w,initialStatus:_.codex},e);case"opencode":return(0,a.jsx)(c.qO,{...s,activeProviders:U(),cloudEnabled:w,initialStatus:_.opencode},e);case"droid":return(0,a.jsx)(c.ZM,{...s,activeProviders:U(),hasActiveProviders:$,cloudEnabled:w,initialStatus:_.droid},e);case"openclaw":return(0,a.jsx)(c.yZ,{...s,activeProviders:U(),hasActiveProviders:$,cloudEnabled:w,initialStatus:_.openclaw},e);case"hermes":return(0,a.jsx)(c.RF,{...s,activeProviders:U(),hasActiveProviders:$,cloudEnabled:w,initialStatus:_.hermes},e);default:return(0,a.jsx)(c.a7,{toolId:e,...s,activeProviders:U(),cloudEnabled:w,tunnelEnabled:y},e)}})(e,t))}),(0,a.jsxs)("div",{className:"grid gap-3 sm:gap-4",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2 px-1",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px] text-primary",children:"security"}),(0,a.jsx)("h2",{className:"text-sm font-semibold text-text-main",children:"MITM Tools"})]}),R.map(([e,t])=>(0,a.jsx)(c.gY,{tool:t},e))]})]})}},71438:(e,t,s)=>{Promise.resolve().then(s.bind(s,46772))}},e=>{e.O(0,[7848,4335,6795,8872,505,4156,4380,2347,5158,7358],()=>e(e.s=71438)),_N_E=e.O()}]);
@@ -1 +0,0 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[3649],{37175:(e,t,s)=>{"use strict";s.r(t),s.d(t,{default:()=>i});var a=s(73365),l=s(1521),o=s(74156),r=s(96459);s(82495);let n=/^[a-zA-Z0-9_.\-]+$/;function i(){let[e,t]=(0,l.useState)([]),[s,n]=(0,l.useState)(!0),[i,d]=(0,l.useState)(!1),[x,h]=(0,l.useState)(null),[p,u]=(0,l.useState)([]),[b,f]=(0,l.useState)({}),{copied:g,copy:j}=(0,r.C)();(0,l.useEffect)(()=>{y()},[]);let y=async()=>{try{let[e,s,a]=await Promise.all([fetch("/api/combos"),fetch("/api/providers"),fetch("/api/settings")]),l=await e.json(),o=await s.json(),r=a.ok?await a.json():{};e.ok&&t(l.combos||[]),s.ok&&u(o.connections||[]),f(r.comboStrategies||{})}catch(e){console.log("Error fetching data:",e)}finally{n(!1)}},v=async e=>{try{let t=await fetch("/api/combos",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(t.ok)await y(),d(!1);else{let e=await t.json();alert(e.error||"Failed to create combo")}}catch(e){console.log("Error creating combo:",e)}},w=async(e,t)=>{try{let s=await fetch(`/api/combos/${e}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(s.ok)await y(),h(null);else{let e=await s.json();alert(e.error||"Failed to update combo")}}catch(e){console.log("Error updating combo:",e)}},N=async s=>{if(confirm("Delete this combo?"))try{(await fetch(`/api/combos/${s}`,{method:"DELETE"})).ok&&t(e.filter(e=>e.id!==s))}catch(e){console.log("Error deleting combo:",e)}},k=async(e,t)=>{try{let s={...b};t?s[e]={fallbackStrategy:"round-robin"}:delete s[e],await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({comboStrategies:s})}),f(s)}catch(e){console.log("Error updating combo strategy:",e)}};return s?(0,a.jsxs)("div",{className:"flex flex-col gap-6",children:[(0,a.jsx)(o.Qv,{}),(0,a.jsx)(o.Qv,{})]}):(0,a.jsxs)("div",{className:"flex min-w-0 flex-col gap-6 px-1 sm:px-0",children:[(0,a.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsx)("h1",{className:"text-2xl font-semibold",children:"Combos"}),(0,a.jsx)("p",{className:"text-sm text-text-muted mt-1",children:"Create model combos with fallback support"})]}),(0,a.jsx)(o.$n,{icon:"add",onClick:()=>d(!0),className:"w-full sm:w-auto",children:"Create Combo"})]}),0===e.length?(0,a.jsx)(o.Zp,{children:(0,a.jsxs)("div",{className:"text-center py-12",children:[(0,a.jsx)("div",{className:"inline-flex items-center justify-center w-16 h-16 rounded-full bg-primary/10 text-primary mb-4",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[32px]",children:"layers"})}),(0,a.jsx)("p",{className:"text-text-main font-medium mb-1",children:"No combos yet"}),(0,a.jsx)("p",{className:"text-sm text-text-muted mb-4",children:"Create model combos with fallback support"}),(0,a.jsx)(o.$n,{icon:"add",onClick:()=>d(!0),className:"w-full sm:w-auto",children:"Create Combo"})]})}):(0,a.jsx)("div",{className:"flex flex-col gap-4",children:e.map(e=>(0,a.jsx)(c,{combo:e,copied:g,onCopy:j,onEdit:()=>h(e),onDelete:()=>N(e.id),roundRobinEnabled:b[e.name]?.fallbackStrategy==="round-robin",onToggleRoundRobin:t=>k(e.name,t)},e.id))}),(0,a.jsx)(m,{isOpen:i,onClose:()=>d(!1),onSave:v,activeProviders:p},"create"),(0,a.jsx)(m,{isOpen:!!x,combo:x,onClose:()=>h(null),onSave:e=>w(x.id,e),activeProviders:p},x?.id||"new")]})}function c({combo:e,copied:t,onCopy:s,onEdit:l,onDelete:r,roundRobinEnabled:n,onToggleRoundRobin:i}){return(0,a.jsx)(o.Zp,{padding:"sm",className:"group",children:(0,a.jsxs)("div",{className:"flex min-w-0 flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[(0,a.jsxs)("div",{className:"flex min-w-0 flex-1 items-start gap-3 sm:items-center",children:[(0,a.jsx)("div",{className:"size-8 rounded-lg bg-primary/10 flex items-center justify-center shrink-0",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-primary text-[18px]",children:"layers"})}),(0,a.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,a.jsx)("code",{className:"block truncate font-mono text-sm font-medium",children:e.name}),(0,a.jsxs)("div",{className:"mt-1 flex min-w-0 flex-wrap items-center gap-1",children:[0===e.models.length?(0,a.jsx)("span",{className:"text-xs text-text-muted italic",children:"No models"}):e.models.slice(0,3).map((e,t)=>(0,a.jsx)("code",{className:"max-w-full truncate rounded bg-black/5 px-1.5 py-0.5 font-mono text-[10px] text-text-muted dark:bg-white/5 sm:max-w-[220px]",children:e},t)),e.models.length>3&&(0,a.jsxs)("span",{className:"text-[10px] text-text-muted",children:["+",e.models.length-3," more"]})]})]})]}),(0,a.jsxs)("div",{className:"flex w-full flex-col gap-2 sm:w-auto sm:flex-row sm:items-center sm:gap-3 sm:shrink-0",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between gap-1.5 rounded-lg bg-black/[0.02] px-2 py-1.5 dark:bg-white/[0.02] sm:justify-start sm:bg-transparent sm:px-0 sm:py-0 sm:dark:bg-transparent",children:[(0,a.jsx)("span",{className:"text-xs text-text-muted font-medium",children:"Round Robin"}),(0,a.jsx)(o.lM,{size:"sm",checked:n,onChange:i})]}),(0,a.jsxs)("div",{className:"grid grid-cols-3 gap-1 sm:flex",children:[(0,a.jsxs)("button",{onClick:t=>{t.stopPropagation(),s(e.name,`combo-${e.id}`)},className:"flex flex-col items-center rounded px-2 py-1 text-text-muted transition-colors hover:bg-black/5 hover:text-primary dark:hover:bg-white/5",title:"Copy combo name",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:t===`combo-${e.id}`?"check":"content_copy"}),(0,a.jsx)("span",{className:"text-[10px] leading-tight",children:"Copy"})]}),(0,a.jsxs)("button",{onClick:l,className:"flex flex-col items-center rounded px-2 py-1 text-text-muted transition-colors hover:bg-black/5 hover:text-primary dark:hover:bg-white/5",title:"Edit",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"edit"}),(0,a.jsx)("span",{className:"text-[10px] leading-tight",children:"Edit"})]}),(0,a.jsxs)("button",{onClick:r,className:"flex flex-col items-center rounded px-2 py-1 text-red-500 transition-colors hover:bg-red-500/10",title:"Delete",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"delete"}),(0,a.jsx)("span",{className:"text-[10px] leading-tight",children:"Delete"})]})]})]})]})})}function d({index:e,model:t,isFirst:s,isLast:o,onEdit:r,onMoveUp:n,onMoveDown:i,onRemove:c}){let[m,x]=(0,l.useState)(!1),[h,p]=(0,l.useState)(t),u=()=>{let e=h.trim();e&&e!==t?r(e):p(t),x(!1)};return(0,a.jsxs)("div",{className:"group flex min-w-0 items-center gap-1.5 rounded-md bg-black/[0.02] px-2 py-1 transition-colors hover:bg-black/[0.04] dark:bg-white/[0.02] dark:hover:bg-white/[0.04]",children:[(0,a.jsx)("span",{className:"text-[10px] font-medium text-text-muted w-3 text-center shrink-0",children:e+1}),m?(0,a.jsx)("input",{autoFocus:!0,value:h,onChange:e=>p(e.target.value),onBlur:u,onKeyDown:e=>{"Enter"===e.key&&u(),"Escape"===e.key&&(p(t),x(!1))},className:"min-w-0 flex-1 rounded border border-primary/40 bg-white px-1.5 py-0.5 font-mono text-xs text-text-main outline-none dark:bg-black/20"}):(0,a.jsx)("div",{className:"min-w-0 flex-1 cursor-text truncate rounded px-1.5 py-0.5 font-mono text-xs text-text-main hover:bg-black/5 dark:hover:bg-white/5",onClick:()=>x(!0),title:"Click to edit",children:t}),(0,a.jsxs)("div",{className:"flex shrink-0 items-center gap-0.5",children:[(0,a.jsx)("button",{onClick:n,disabled:s,className:`p-0.5 rounded ${s?"text-text-muted/20 cursor-not-allowed":"text-text-muted hover:text-primary hover:bg-black/5 dark:hover:bg-white/5"}`,title:"Move up",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[12px]",children:"arrow_upward"})}),(0,a.jsx)("button",{onClick:i,disabled:o,className:`p-0.5 rounded ${o?"text-text-muted/20 cursor-not-allowed":"text-text-muted hover:text-primary hover:bg-black/5 dark:hover:bg-white/5"}`,title:"Move down",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[12px]",children:"arrow_downward"})})]}),(0,a.jsx)("button",{onClick:c,className:"p-0.5 hover:bg-red-500/10 rounded text-text-muted hover:text-red-500 transition-all",title:"Remove",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[12px]",children:"close"})})]})}function m({isOpen:e,combo:t,onClose:s,onSave:r,activeProviders:i,kindFilter:c=null}){let[x,h]=(0,l.useState)(t?.name||""),[p,u]=(0,l.useState)(t?.models||[]),[b,f]=(0,l.useState)(!1),[g,j]=(0,l.useState)(!1),[y,v]=(0,l.useState)(""),[w,N]=(0,l.useState)({}),k=async()=>{try{let e=await fetch("/api/models/alias");if(!e.ok)return;let t=await e.json();N(t.aliases||{})}catch(e){console.error("Error fetching modal data:",e)}};(0,l.useEffect)(()=>{e&&k()},[e]);let C=e=>e.trim()?n.test(e)?(v(""),!0):(v("Only letters, numbers, -, _ and . allowed"),!1):(v("Name is required"),!1),S=async()=>{C(x)&&(j(!0),await r({name:x.trim(),models:p}),j(!1))},E=!!t;return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(o.aF,{isOpen:e,onClose:s,title:E?"Edit Combo":"Create Combo",children:(0,a.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)(o.pd,{label:"Combo Name",value:x,onChange:e=>{let t=e.target.value;h(t),t?C(t):v("")},placeholder:"my-combo",error:y}),(0,a.jsx)("p",{className:"text-[10px] text-text-muted mt-0.5",children:"Only letters, numbers, -, _ and . allowed"})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"text-sm font-medium mb-1.5 block",children:"Models"}),0===p.length?(0,a.jsxs)("div",{className:"text-center py-4 border border-dashed border-black/10 dark:border-white/10 rounded-lg bg-black/[0.01] dark:bg-white/[0.01]",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-text-muted text-xl mb-1",children:"layers"}),(0,a.jsx)("p",{className:"text-xs text-text-muted",children:"No models added yet"})]}):(0,a.jsx)("div",{className:"flex max-h-[55vh] min-w-0 flex-col gap-1 overflow-y-auto sm:max-h-[350px]",children:p.map((e,t)=>(0,a.jsx)(d,{index:t,model:e,isFirst:0===t,isLast:t===p.length-1,onEdit:e=>{let s=[...p];s[t]=e,u(s)},onMoveUp:()=>(e=>{if(0===e)return;let t=[...p];[t[e-1],t[e]]=[t[e],t[e-1]],u(t)})(t),onMoveDown:()=>(e=>{if(e===p.length-1)return;let t=[...p];[t[e],t[e+1]]=[t[e+1],t[e]],u(t)})(t),onRemove:()=>{u(p.filter((e,s)=>s!==t))}},t))}),(0,a.jsxs)("button",{onClick:()=>f(!0),className:"w-full mt-2 py-2 border border-dashed border-black/10 dark:border-white/10 rounded-lg text-xs text-primary font-medium hover:text-primary hover:border-primary/50 transition-colors flex items-center justify-center gap-1",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"add"}),"Add Model"]})]}),(0,a.jsxs)("div",{className:"flex flex-col gap-2 pt-1 sm:flex-row",children:[(0,a.jsx)(o.$n,{onClick:s,variant:"ghost",fullWidth:!0,size:"sm",children:"Cancel"}),(0,a.jsx)(o.$n,{onClick:S,fullWidth:!0,size:"sm",disabled:!x.trim()||!!y||g,children:g?"Saving...":E?"Save":"Create"})]})]})}),(0,a.jsx)(o.rq,{isOpen:b,onClose:()=>f(!1),onSelect:e=>{p.includes(e.value)||u([...p,e.value])},activeProviders:i,modelAliases:w,title:"Add Model to Combo",kindFilter:c})]})}},73540:(e,t,s)=>{Promise.resolve().then(s.bind(s,37175))}},e=>{e.O(0,[7848,4335,6795,505,4156,2347,5158,7358],()=>e(e.s=73540)),_N_E=e.O()}]);
@@ -1,53 +0,0 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[182],{597:(e,t,s)=>{Promise.resolve().then(s.bind(s,38596))},38596:(e,t,s)=>{"use strict";s.r(t),s.d(t,{default:()=>T});var a=s(73365),r=s(29717),o=s(99568),l=s.n(o),i=s(1521),n=s(74156),d=s(68266),c=s(82495),p=s(69633),x=s(96459),u=s(86447),m=s.n(u);function h({until:e}){let[t,s]=(0,i.useState)("");return((0,i.useEffect)(()=>{let t=()=>{let t=new Date(e).getTime()-Date.now();if(t<=0)return void s("");let a=Math.floor(t/1e3);a<60?s(`${a}s`):a<3600?s(`${Math.floor(a/60)}m ${a%60}s`):s(`${Math.floor(a/3600)}h ${Math.floor(a%3600/60)}m`)};t();let a=setInterval(t,1e3);return()=>clearInterval(a)},[e]),t)?(0,a.jsxs)("span",{className:"text-xs text-orange-500 font-mono",children:["⏱ ",t]}):null}function b({connection:e,proxyPools:t,isOAuth:s,isFirst:r,isLast:o,onMoveUp:l,onMoveDown:d,onToggleActive:c,onUpdateProxy:p,onEdit:x,onDelete:u}){let[m,g]=(0,i.useState)(!1),[y,f]=(0,i.useState)(!1),[j,v]=(0,i.useState)(!1),N=(0,i.useRef)(null),w=new Map((t||[]).map(e=>[e.id,e])),k=e.providerSpecificData?.proxyPoolId||null,S=k?w.get(k):null,C=e.providerSpecificData?.connectionProxyEnabled===!0&&!!e.providerSpecificData?.connectionProxyUrl,$=!!k||C,P=S?`Pool: ${S.name}`:k?`Pool: ${k} (inactive/missing)`:C?`Legacy: ${e.providerSpecificData?.connectionProxyUrl}`:"",A="",R=S?.proxyUrl||e.providerSpecificData?.connectionProxyUrl;if(R)try{let e=new URL(R);A=`${e.protocol}//${e.hostname}${e.port?`:${e.port}`:""}`}catch{A=R}let T=S?.noProxy||e.providerSpecificData?.connectionNoProxy||"",I=S?.isActive===!0?"success":k||C?"error":"default",_=Object.entries(e).filter(([e])=>e.startsWith("modelLock_")).map(([,e])=>e).filter(Boolean).sort()[0]||null;(0,i.useEffect)(()=>{let t=()=>{v(!!Object.entries(e).filter(([e])=>e.startsWith("modelLock_")).map(([,e])=>e).filter(e=>e&&new Date(e).getTime()>Date.now()).sort()[0])};t();let s=_?setInterval(t,1e3):null;return()=>{s&&clearInterval(s)}},[_]),(0,i.useEffect)(()=>{if(!m)return;let e=e=>{N.current&&!N.current.contains(e.target)&&g(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[m]);let O="unavailable"!==e.testStatus||j?e.testStatus:"active",E=s?e.name||e.email||e.displayName||"OAuth Account":e.name,K=async e=>{f(!0);try{await p("__none__"===e?null:e)}finally{f(!1),g(!1)}};return(0,a.jsxs)("div",{className:`group flex items-center justify-between p2 rounded-lg hover:bg-black/[0.02] dark:hover:bg-white/[0.02] transition-colors ${!1===e.isActive?"opacity-60":""}`,children:[(0,a.jsxs)("div",{className:"flex items-center gap-3 flex-1 min-w-0",children:[(0,a.jsxs)("div",{className:"flex flex-col",children:[(0,a.jsx)("button",{onClick:l,disabled:r,className:`p-0.5 rounded ${r?"text-text-muted/30 cursor-not-allowed":"hover:bg-sidebar text-text-muted hover:text-primary"}`,children:(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:"keyboard_arrow_up"})}),(0,a.jsx)("button",{onClick:d,disabled:o,className:`p-0.5 rounded ${o?"text-text-muted/30 cursor-not-allowed":"hover:bg-sidebar text-text-muted hover:text-primary"}`,children:(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:"keyboard_arrow_down"})})]}),(0,a.jsx)("span",{className:"material-symbols-outlined text-base text-text-muted",children:s?"lock":"key"}),(0,a.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,a.jsx)("p",{className:"text-sm font-medium truncate",children:E}),(0,a.jsxs)("div",{className:"flex items-center gap-2 mt-1 flex-wrap",children:[(0,a.jsx)(n.Ex,{variant:!1===e.isActive?"default":"active"===O||"success"===O?"success":"error"===O||"expired"===O||"unavailable"===O?"error":"default",size:"sm",dot:!0,children:!1===e.isActive?"disabled":O||"Unknown"}),$&&(0,a.jsx)(n.Ex,{variant:I,size:"sm",children:"Proxy"}),j&&!1!==e.isActive&&(0,a.jsx)(h,{until:_}),e.lastError&&!1!==e.isActive&&(0,a.jsx)("span",{className:"text-xs text-red-500 truncate max-w-[300px]",title:e.lastError,children:e.lastError}),(0,a.jsxs)("span",{className:"text-xs text-text-muted",children:["#",e.priority]})]}),$&&(0,a.jsxs)("div",{className:"mt-1 flex items-center gap-2 flex-wrap",children:[(0,a.jsx)("span",{className:"text-[11px] text-text-muted truncate max-w-[420px]",title:P,children:P}),A&&(0,a.jsx)("code",{className:"text-[10px] font-mono bg-black/5 dark:bg-white/5 px-1 py-0.5 rounded text-text-muted",children:A}),T&&(0,a.jsxs)("span",{className:"text-[11px] text-text-muted truncate max-w-[320px]",title:T,children:["no_proxy: ",T]})]})]})]}),(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsxs)("div",{className:"flex gap-1",children:[(t||[]).length>0&&(0,a.jsxs)("div",{className:"relative",ref:N,children:[(0,a.jsxs)("button",{onClick:()=>g(e=>!e),className:`flex flex-col items-center px-2 py-1 rounded hover:bg-black/5 dark:hover:bg-white/5 transition-colors ${$?"text-primary":"text-text-muted hover:text-primary"}`,disabled:y,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:y?"progress_activity":"lan"}),(0,a.jsx)("span",{className:"text-[10px] leading-tight",children:"Proxy"})]}),m&&(0,a.jsxs)("div",{className:"absolute right-0 top-full mt-1 z-50 bg-bg border border-border rounded-lg shadow-lg py-1 min-w-[160px]",children:[(0,a.jsx)("button",{onClick:()=>K("__none__"),className:`w-full text-left px-3 py-1.5 text-sm hover:bg-black/5 dark:hover:bg-white/5 ${!k?"text-primary font-medium":"text-text-main"}`,children:"None"}),(t||[]).map(e=>(0,a.jsx)("button",{onClick:()=>K(e.id),className:`w-full text-left px-3 py-1.5 text-sm hover:bg-black/5 dark:hover:bg-white/5 ${k===e.id?"text-primary font-medium":"text-text-main"}`,children:e.name},e.id))]})]}),(0,a.jsxs)("button",{onClick:x,className:"flex flex-col items-center px-2 py-1 rounded hover:bg-black/5 dark:hover:bg-white/5 text-text-muted hover:text-primary",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"edit"}),(0,a.jsx)("span",{className:"text-[10px] leading-tight",children:"Edit"})]}),(0,a.jsxs)("button",{onClick:u,className:"flex flex-col items-center px-2 py-1 rounded hover:bg-red-500/10 text-red-500",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"delete"}),(0,a.jsx)("span",{className:"text-[10px] leading-tight",children:"Delete"})]})]}),(0,a.jsx)(n.lM,{size:"sm",checked:e.isActive??!0,onChange:c,title:e.isActive??!0?"Disable":"Enable"})]})]})}function g({isOpen:e,provider:t,providerName:s,proxyPools:r,onSave:o,onClose:l}){let d="__none__",[c,p]=(0,i.useState)({name:"",apiKey:"",priority:1,proxyPoolId:d}),[x,u]=(0,i.useState)(!1),[m,h]=(0,i.useState)(null),[b,y]=(0,i.useState)(!1),f=async()=>{u(!0);try{let e=await fetch("/api/providers/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:t,apiKey:c.apiKey})}),s=await e.json();h(s.valid?"success":"failed")}catch{h("failed")}finally{u(!1)}},j=async()=>{if(t&&c.apiKey){y(!0);try{let e=!1;try{u(!0),h(null);let s=await fetch("/api/providers/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:t,apiKey:c.apiKey})});e=!!(await s.json()).valid,h(e?"success":"failed")}catch{h("failed")}finally{u(!1)}await o({name:c.name,apiKey:c.apiKey,priority:c.priority,proxyPoolId:c.proxyPoolId===d?null:c.proxyPoolId,testStatus:e?"active":"unknown"})}finally{y(!1)}}};return t?(0,a.jsx)(n.aF,{isOpen:e,title:`Add ${s||t} API Key`,onClose:l,children:(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"text-xs text-text-muted mb-1 block",children:"Name"}),(0,a.jsx)("input",{className:"w-full px-3 py-2 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary",value:c.name,onChange:e=>p({...c,name:e.target.value}),placeholder:"Production Key"})]}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsxs)("div",{className:"flex-1",children:[(0,a.jsx)("label",{className:"text-xs text-text-muted mb-1 block",children:"API Key"}),(0,a.jsx)("input",{type:"password",className:"w-full px-3 py-2 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary",value:c.apiKey,onChange:e=>p({...c,apiKey:e.target.value})})]}),(0,a.jsx)("div",{className:"pt-6",children:(0,a.jsx)(n.$n,{onClick:f,disabled:!c.apiKey||x||b,variant:"secondary",children:x?"Checking...":"Check"})})]}),m&&(0,a.jsx)(n.Ex,{variant:"success"===m?"success":"error",children:"success"===m?"Valid":"Invalid"}),(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"text-xs text-text-muted mb-1 block",children:"Priority"}),(0,a.jsx)("input",{type:"number",className:"w-full px-3 py-2 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary",value:c.priority,onChange:e=>p({...c,priority:Number.parseInt(e.target.value)||1})})]}),(0,a.jsx)(n.l6,{label:"Proxy Pool",value:c.proxyPoolId,onChange:e=>p({...c,proxyPoolId:e.target.value}),options:[{value:d,label:"None"},...(r||[]).map(e=>({value:e.id,label:e.name}))]}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(n.$n,{onClick:j,fullWidth:!0,disabled:!c.name||!c.apiKey||b,children:b?"Saving...":"Save"}),(0,a.jsx)(n.$n,{onClick:l,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})}):null}function y({providerId:e,isOAuth:t}){let[s,r]=(0,i.useState)([]),[o,l]=(0,i.useState)([]),[d,c]=(0,i.useState)(!0),[p,x]=(0,i.useState)(!1),[u,m]=(0,i.useState)(!1),[h,f]=(0,i.useState)(null),[j,v]=(0,i.useState)(null),[N,w]=(0,i.useState)("1"),k=(0,i.useCallback)(async()=>{try{let[t,s,a]=await Promise.all([fetch("/api/providers",{cache:"no-store"}),fetch("/api/proxy-pools?isActive=true",{cache:"no-store"}),fetch("/api/settings",{cache:"no-store"})]),o=await t.json(),i=await s.json(),n=a.ok?await a.json():{};t.ok&&r((o.connections||[]).filter(t=>t.provider===e)),s.ok&&l(i.proxyPools||[]);let d=(n.providerStrategies||{})[e]||{};v(d.fallbackStrategy||null),w(null!=d.stickyRoundRobinLimit?String(d.stickyRoundRobinLimit):"1")}catch(e){console.log("ConnectionsCard fetch error:",e)}finally{c(!1)}},[e]);(0,i.useEffect)(()=>{k()},[k]);let S=async(t,s)=>{try{let a=await fetch("/api/settings",{cache:"no-store"}),r=(a.ok?await a.json():{}).providerStrategies||{},o={};t&&(o.fallbackStrategy=t),"round-robin"===t&&""!==s&&(o.stickyRoundRobinLimit=Number(s)||3);let l={...r};0===Object.keys(o).length?delete l[e]:l[e]=o,await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerStrategies:l})})}catch(e){console.log("saveStrategy error:",e)}},C=async(e,t)=>{let a=[...s];[a[e],a[t]]=[a[t],a[e]],r(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{await k()}},$=async e=>{if(confirm("Delete this connection?"))try{(await fetch(`/api/providers/${e}`,{method:"DELETE"})).ok&&r(t=>t.filter(t=>t.id!==e))}catch(e){console.log("delete error:",e)}},P=async(e,t)=>{try{(await fetch(`/api/providers/${e}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({isActive:t})})).ok&&r(s=>s.map(s=>s.id===e?{...s,isActive:t}:s))}catch(e){console.log("toggle error:",e)}},A=async(e,t)=>{try{(await fetch(`/api/providers/${e}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({proxyPoolId:t||null})})).ok&&r(s=>s.map(s=>s.id===e?{...s,providerSpecificData:{...s.providerSpecificData,proxyPoolId:t||null}}:s))}catch(e){console.log("proxy error:",e)}},R=async t=>{try{(await fetch("/api/providers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:e,...t})})).ok&&(await k(),x(!1))}catch(e){console.log("save apikey error:",e)}},T=async e=>{try{(await fetch(`/api/providers/${h.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})).ok&&(await k(),m(!1))}catch(e){console.log("update connection error:",e)}};return d?(0,a.jsx)(n.Zp,{children:(0,a.jsx)("div",{className:"h-20 animate-pulse bg-black/5 rounded-lg"})}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)(n.Zp,{children:[(0,a.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,a.jsx)("h2",{className:"text-lg font-semibold",children:"Connections"}),(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"text-xs text-text-muted font-medium",children:"Round Robin"}),(0,a.jsx)(n.lM,{checked:"round-robin"===j,onChange:e=>{let t=e?"round-robin":null;v(t),e&&!N&&w("1"),S(t,e?N||"1":N)}}),"round-robin"===j&&(0,a.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,a.jsx)("span",{className:"text-xs text-text-muted",children:"Sticky:"}),(0,a.jsx)("input",{type:"number",min:1,value:N,onChange:e=>{w(e.target.value),S("round-robin",e.target.value)},className:"w-14 px-2 py-1 text-xs border border-border rounded-md bg-background focus:outline-none focus:border-primary"})]})]})]}),0===s.length?(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsx)("p",{className:"text-sm text-text-muted",children:"No connections yet"}),(0,a.jsx)(n.$n,{size:"sm",icon:"add",onClick:()=>x(!0),children:"Add Connection"})]}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("div",{className:"flex flex-col divide-y divide-black/[0.03] dark:divide-white/[0.03]",children:s.map((e,r)=>(0,a.jsx)(b,{connection:e,proxyPools:o,isOAuth:t,isFirst:0===r,isLast:r===s.length-1,onMoveUp:()=>C(r,r-1),onMoveDown:()=>C(r,r+1),onToggleActive:t=>P(e.id,t),onUpdateProxy:t=>A(e.id,t),onEdit:()=>{f(e),m(!0)},onDelete:()=>$(e.id)},e.id))}),(0,a.jsx)("div",{className:"mt-4",children:(0,a.jsx)(n.$n,{size:"sm",icon:"add",onClick:()=>x(!0),children:"Add"})})]})]}),(0,a.jsx)(g,{isOpen:p,provider:e,proxyPools:o,onSave:R,onClose:()=>x(!1)}),(0,a.jsx)(n.wI,{isOpen:u,connection:h,proxyPools:o,onSave:T,onClose:()=>m(!1)})]})}function f({model:e,fullModel:t,copied:s,onCopy:r,testStatus:o,isCustom:l,isFree:i,onDeleteAlias:n,onTest:d,isTesting:c}){let p="ok"===o?"#22c55e":"error"===o?"#ef4444":void 0;return(0,a.jsx)("div",{className:`group px-3 py-2 rounded-lg border ${"ok"===o?"border-green-500/40":"error"===o?"border-red-500/40":"border-border"} hover:bg-sidebar/50`,children:(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-base",style:p?{color:p}:void 0,children:"ok"===o?"check_circle":"error"===o?"cancel":"smart_toy"}),(0,a.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,a.jsx)("code",{className:"text-xs text-text-muted font-mono bg-sidebar px-1.5 py-0.5 rounded",children:t}),e.name&&(0,a.jsx)("span",{className:"text-[9px] text-text-muted/70 italic pl-1",children:e.name})]}),d&&(0,a.jsxs)("div",{className:"relative group/btn",children:[(0,a.jsx)("button",{onClick:d,disabled:c,className:`p-0.5 hover:bg-sidebar rounded text-text-muted hover:text-primary transition-opacity ${c?"opacity-100":"opacity-0 group-hover:opacity-100"}`,children:(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",style:c?{animation:"spin 1s linear infinite"}:void 0,children:c?"progress_activity":"science"})}),(0,a.jsx)("span",{className:"pointer-events-none absolute mt-1 top-5 left-1/2 -translate-x-1/2 text-[10px] text-text-muted whitespace-nowrap opacity-0 group-hover/btn:opacity-100 transition-opacity",children:c?"Testing...":"Test"})]}),(0,a.jsxs)("div",{className:"relative group/btn",children:[(0,a.jsx)("button",{onClick:()=>r(t,`model-${e.id}`),className:"p-0.5 hover:bg-sidebar rounded text-text-muted hover:text-primary",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:s===`model-${e.id}`?"check":"content_copy"})}),(0,a.jsx)("span",{className:"pointer-events-none absolute mt-1 top-5 left-1/2 -translate-x-1/2 text-[10px] text-text-muted whitespace-nowrap opacity-0 group-hover/btn:opacity-100 transition-opacity",children:s===`model-${e.id}`?"Copied!":"Copy"})]}),i&&(0,a.jsx)("span",{className:"text-[10px] font-bold text-green-500 bg-green-500/10 px-1.5 py-0.5 rounded",children:"FREE"}),l&&(0,a.jsx)("button",{onClick:n,className:"p-0.5 hover:bg-red-500/10 rounded text-text-muted hover:text-red-500 opacity-0 group-hover:opacity-100 transition-opacity ml-auto",title:"Remove custom model",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:"close"})})]})})}function j({isOpen:e,onSave:t,onClose:s}){let[r,o]=(0,i.useState)(""),l=()=>{r.trim()&&(t(r.trim()),o(""))};return(0,a.jsx)(n.aF,{isOpen:e,title:"Add Custom Model",onClose:s,children:(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"text-xs text-text-muted mb-1 block",children:"Model ID"}),(0,a.jsx)("input",{className:"w-full px-3 py-2 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary",value:r,onChange:e=>o(e.target.value),onKeyDown:e=>"Enter"===e.key&&l(),placeholder:"e.g. tts-1-hd",autoFocus:!0})]}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(n.$n,{onClick:l,fullWidth:!0,disabled:!r.trim(),children:"Add"}),(0,a.jsx)(n.$n,{onClick:s,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})})}function v({providerId:e,kindFilter:t,providerAliasOverride:s}){let{copied:r,copy:o}=(0,x.C)(),[l,d]=(0,i.useState)({}),[u,m]=(0,i.useState)([]),[h,b]=(0,i.useState)({}),[g,y]=(0,i.useState)(null),[N,w]=(0,i.useState)(""),[k,S]=(0,i.useState)(!1),[C,$]=(0,i.useState)([]),P=s||(0,c.wG)(e),A=t||"llm",R=(0,i.useCallback)(async()=>{try{let[t,s,a]=await Promise.all([fetch("/api/models/alias"),fetch("/api/providers",{cache:"no-store"}),fetch("/api/models/custom",{cache:"no-store"})]),r=await t.json(),o=await s.json(),l=await a.json();t.ok&&d(r.aliases||{}),s.ok&&$((o.connections||[]).filter(t=>t.provider===e)),a.ok&&m(l.models||[])}catch(e){console.log("ModelsCard fetch error:",e)}},[e]);(0,i.useEffect)(()=>{R()},[R]);let T=async(e,t)=>{let s=`${P}/${e}`;try{(await fetch("/api/models/alias",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:s,alias:t})})).ok&&await R()}catch(e){console.log("set alias error:",e)}},I=async e=>{try{(await fetch(`/api/models/alias?alias=${encodeURIComponent(e)}`,{method:"DELETE"})).ok&&await R()}catch(e){console.log("delete alias error:",e)}},_=async e=>{try{(await fetch("/api/models/custom",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerAlias:P,id:e,type:A})})).ok&&await R()}catch(e){console.log("add custom model error:",e)}},O=async e=>{try{let t=new URLSearchParams({providerAlias:P,id:e,type:A});(await fetch(`/api/models/custom?${t}`,{method:"DELETE"})).ok&&await R()}catch(e){console.log("delete custom model error:",e)}},E=async e=>{if(!g){y(e);try{let s=await fetch("/api/models/test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:`${P}/${e}`,kind:t})}),a=await s.json();b(t=>({...t,[e]:a.ok?"ok":"error"})),w(a.ok?"":a.error||"Model not reachable")}catch{b(t=>({...t,[e]:"error"})),w("Network error")}finally{y(null)}}},K=(0,p.KC)(e),M=t?K.filter(e=>e.kinds?e.kinds.includes(t):(e.type||"llm")===t):K,U=u.filter(e=>e.providerAlias===P&&(e.type||"llm")===A&&!M.some(t=>t.id===e.id));return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)(n.Zp,{children:[(0,a.jsx)("div",{className:"flex items-center justify-between mb-4",children:(0,a.jsxs)("h2",{className:"text-lg font-semibold",children:["Models",t?` — ${t.toUpperCase()}`:""]})}),N&&(0,a.jsx)("p",{className:"text-xs text-red-500 mb-3 break-words",children:N}),(0,a.jsxs)("div",{className:"flex flex-wrap gap-3",children:[M.map(e=>{let t=`${P}/${e.id}`,s=Object.entries(l).find(([,e])=>e===t)?.[0];return(0,a.jsx)(f,{model:e,fullModel:`${P}/${e.id}`,alias:s,copied:r,onCopy:o,onSetAlias:t=>T(e.id,t),onDeleteAlias:()=>I(s),testStatus:h[e.id],onTest:C.length>0?()=>E(e.id):void 0,isTesting:g===e.id,isFree:e.isFree},e.id)}),U.map(e=>(0,a.jsx)(f,{model:{id:e.id,name:e.name},fullModel:`${P}/${e.id}`,copied:r,onCopy:o,onSetAlias:()=>{},onDeleteAlias:()=>O(e.id),testStatus:h[e.id],onTest:C.length>0?()=>E(e.id):void 0,isTesting:g===e.id,isCustom:!0},`${e.id}-${e.type}`)),(0,a.jsxs)("button",{onClick:()=>S(!0),className:"flex items-center gap-1.5 px-3 py-2 rounded-lg border border-dashed border-black/15 dark:border-white/15 text-xs text-text-muted hover:text-primary hover:border-primary/40 transition-colors",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:"add"}),"Add Model"]})]})]}),(0,a.jsx)(j,{isOpen:k,onSave:async e=>{await _(e),S(!1)},onClose:()=>S(!1)})]})}h.propTypes={until:m().string.isRequired},b.propTypes={connection:m().shape({id:m().string,name:m().string,email:m().string,displayName:m().string,testStatus:m().string,isActive:m().bool,lastError:m().string,priority:m().number}).isRequired,proxyPools:m().array,isOAuth:m().bool.isRequired,isFirst:m().bool.isRequired,isLast:m().bool.isRequired,onMoveUp:m().func.isRequired,onMoveDown:m().func.isRequired,onToggleActive:m().func.isRequired,onUpdateProxy:m().func,onEdit:m().func.isRequired,onDelete:m().func.isRequired},g.propTypes={isOpen:m().bool.isRequired,provider:m().string,providerName:m().string,proxyPools:m().array,onSave:m().func.isRequired,onClose:m().func.isRequired},y.propTypes={providerId:m().string.isRequired,isOAuth:m().bool},f.propTypes={model:m().shape({id:m().string.isRequired}).isRequired,fullModel:m().string.isRequired,copied:m().string,onCopy:m().func.isRequired,testStatus:m().oneOf(["ok","error"]),isCustom:m().bool,isFree:m().bool,onDeleteAlias:m().func,onTest:m().func,isTesting:m().bool},j.propTypes={isOpen:m().bool.isRequired,onSave:m().func.isRequired,onClose:m().func.isRequired},v.propTypes={providerId:m().string.isRequired,kindFilter:m().string,providerAliasOverride:m().string};let N={"google-tts":{hasLanguageDropdown:!1,hasModelSelector:!1,hasBrowseButton:!0,voiceSource:"hardcoded"},openai:{hasLanguageDropdown:!1,hasModelSelector:!0,hasBrowseButton:!1,voiceSource:"hardcoded",modelKey:"openai-tts-models",voiceKey:"openai-tts-voices",voicesPerModel:!0},openrouter:{hasLanguageDropdown:!1,hasModelSelector:!0,hasBrowseButton:!1,voiceSource:"hardcoded",modelKey:"openrouter-tts-models",voiceKey:"openrouter-tts-voices",voicesPerModel:!0},elevenlabs:{hasLanguageDropdown:!1,hasModelSelector:!0,hasBrowseButton:!0,hasVoiceIdInput:!0,voiceSource:"api-language",modelKey:"elevenlabs-tts-models",apiEndpoint:"/api/media-providers/tts/elevenlabs/voices"},"edge-tts":{hasLanguageDropdown:!1,hasModelSelector:!1,hasBrowseButton:!0,voiceSource:"api-language"},"local-device":{hasLanguageDropdown:!1,hasModelSelector:!1,hasBrowseButton:!0,voiceSource:"api-language"},nvidia:{hasModelSelector:!0,hasBrowseButton:!1,hasVoiceIdInput:!0,voiceSource:"config"},hyperbolic:{hasModelSelector:!0,hasBrowseButton:!1,voiceSource:"config"},deepgram:{hasModelSelector:!1,hasBrowseButton:!0,voiceSource:"api-language",apiEndpoint:"/api/media-providers/tts/deepgram/voices"},huggingface:{hasModelSelector:!0,hasBrowseButton:!1,voiceSource:"config"},cartesia:{hasModelSelector:!0,hasBrowseButton:!1,hasVoiceIdInput:!0,voiceSource:"config"},playht:{hasModelSelector:!0,hasBrowseButton:!1,hasVoiceIdInput:!0,voiceSource:"config"},coqui:{hasModelSelector:!0,hasBrowseButton:!1,hasVoiceIdInput:!0,voiceSource:"config"},tortoise:{hasModelSelector:!0,hasBrowseButton:!1,hasVoiceIdInput:!0,voiceSource:"config"},inworld:{hasModelSelector:!0,hasBrowseButton:!0,hasVoiceIdInput:!0,voiceSource:"api-language",modelKey:"inworld-tts-models",apiEndpoint:"/api/media-providers/tts/inworld/voices"},qwen:{hasModelSelector:!0,hasBrowseButton:!1,hasVoiceIdInput:!0,voiceSource:"config"}};var w=s(36698);function k({label:e,children:t}){return(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[(0,a.jsx)("span",{className:"text-xs text-text-muted w-20 shrink-0",children:e}),(0,a.jsx)("div",{className:"flex-1",children:t})]})}let S=`// Audio will appear here after running.
2
- // Example JSON response (response_format=json):
3
- {
4
- "format": "mp3",
5
- "audio": "//NExAANaAIIAUAAANNNNNNNN..." // base64 encoded MP3
6
- }`,C=`{
7
- "object": "list",
8
- "data": [{
9
- "object": "embedding",
10
- "index": 0,
11
- "embedding": [0.002301, -0.019212, 0.004815, -0.031249, ...]
12
- }],
13
- "model": "...",
14
- "usage": { "prompt_tokens": 9, "total_tokens": 9 }
15
- }`,$={webSearch:{inputLabel:"Query",inputPlaceholder:"What is the latest news about AI?",defaultInput:"What is the latest news about AI?",bodyKey:"query",defaultResponse:`{
16
- "results": [
17
- { "title": "...", "url": "...", "snippet": "..." }
18
- ]
19
- }`,extraFields:[{key:"search_type",label:"Type",type:"select",default:"web",options:["web","news"]},{key:"max_results",label:"Max results",type:"number",default:5,min:1,max:100},{key:"country",label:"Country",type:"text",default:""},{key:"language",label:"Language",type:"text",default:""}]},webFetch:{inputLabel:"URL",inputPlaceholder:"https://example.com",defaultInput:"https://example.com",bodyKey:"url",defaultResponse:`{
20
- "content": "...",
21
- "title": "...",
22
- "url": "..."
23
- }`,extraFields:[{key:"format",label:"Format",type:"select",default:"markdown",options:["markdown","text","html"]},{key:"max_characters",label:"Max chars",type:"number",default:0,min:0}]},image:{inputLabel:"Prompt",inputPlaceholder:"A cute cat wearing a hat",defaultInput:"A cute cat wearing a hat",bodyKey:"prompt",defaultResponse:`{
24
- "data": [
25
- { "url": "...", "b64_json": "..." }
26
- ]
27
- }`,extraFields:[{key:"n",label:"n",type:"number",default:1,min:1,max:4},{key:"size",label:"Size",type:"select",default:"auto",options:["auto","1024x1024","1024x1536","1536x1024","1024x1792","1792x1024"]},{key:"quality",label:"Quality",type:"select",default:"auto",options:["auto","low","medium","high","standard","hd"]},{key:"background",label:"Background",type:"select",default:"auto",options:["auto","transparent","opaque"]},{key:"style",label:"Style",type:"select",default:"",options:["","vivid","natural"]},{key:"response_format",label:"Format",type:"select",default:"",options:["","url","b64_json"]},{key:"image_detail",label:"Image Detail",type:"select",default:"high",options:["auto","low","high","original"]},{key:"output_format",label:"Codec",type:"select",default:"png",options:["png","jpeg","webp"]}]},imageToText:{inputLabel:"Image URL",inputPlaceholder:"https://example.com/image.png",defaultInput:"https://upload.wikimedia.org/wikipedia/commons/thumb/3/3a/Cat03.jpg/1200px-Cat03.jpg",bodyKey:"url",extraBody:{prompt:"Describe this image in detail"},defaultResponse:`{
28
- "text": "A cat sitting on a windowsill...",
29
- "model": "..."
30
- }`},stt:{inputLabel:"Audio URL",inputPlaceholder:"https://example.com/audio.mp3",defaultInput:"",bodyKey:"url",defaultResponse:`{
31
- "text": "Hello world...",
32
- "model": "..."
33
- }`},video:{inputLabel:"Prompt",inputPlaceholder:"A serene lake at sunset",defaultInput:"A serene lake at sunset",bodyKey:"prompt",defaultResponse:`{
34
- "data": [
35
- { "url": "..." }
36
- ]
37
- }`},music:{inputLabel:"Prompt",inputPlaceholder:"A calm piano melody",defaultInput:"A calm piano melody",bodyKey:"prompt",defaultResponse:`{
38
- "data": [
39
- { "url": "...", "format": "mp3" }
40
- ]
41
- }`}};function P({providerId:e,customAlias:t}){let s=(0,c.gC)(e),r=s?t||e:(0,c.wG)(e),o=s?[]:(0,p.KC)(e).filter(e=>"embedding"===e.type),[l,d]=(0,i.useState)(o[0]?.id??""),[u,m]=(0,i.useState)("The quick brown fox jumps over the lazy dog"),[h,b]=(0,i.useState)(""),[g,y]=(0,i.useState)(""),[f,j]=(0,i.useState)(!1),[v,N]=(0,i.useState)(""),[w,S]=(0,i.useState)(""),[$,A]=(0,i.useState)(null),[R,T]=(0,i.useState)(!1),[I,_]=(0,i.useState)(""),{copied:O,copy:E}=(0,x.C)(),{copied:K,copy:M}=(0,x.C)();(0,i.useEffect)(()=>{N(window.location.origin),fetch("/api/keys").then(e=>e.json()).then(e=>{y((e.keys||[]).find(e=>!1!==e.isActive)?.key||"")}).catch(()=>{}),fetch("/api/tunnel/status").then(e=>e.json()).then(e=>{e.publicUrl&&S(e.publicUrl)}).catch(()=>{})},[]);let U=f?w:v,L=l?`${r}/${l}`:"",D=()=>{let e={model:L,input:u.trim()},t=Number(h);return h&&Number.isFinite(t)&&t>0&&(e.dimensions=t),e},B=`curl -X POST ${U}/v1/embeddings \\
42
- -H "Content-Type: application/json" \\
43
- -H "Authorization: Bearer ${g||"YOUR_KEY"}" \\
44
- -d '${JSON.stringify(D())}'`,F=async()=>{if(!u.trim()||!L)return;T(!0),_(""),A(null);let e=Date.now();try{let t={"Content-Type":"application/json"};g&&(t.Authorization=`Bearer ${g}`);let s=await fetch("/api/v1/embeddings",{method:"POST",headers:t,body:JSON.stringify(D())}),a=Date.now()-e,r=await s.json();if(!s.ok)return void _(r?.error?.message||r?.error||`HTTP ${s.status}`);A({data:r,latencyMs:a})}catch(e){_(e.message||"Network error")}finally{T(!1)}},q=$?JSON.stringify($.data,null,2):"";return(0,a.jsxs)(n.Zp,{children:[(0,a.jsx)("h2",{className:"text-lg font-semibold mb-4",children:"Example"}),(0,a.jsxs)("div",{className:"flex flex-col gap-2.5",children:[(0,a.jsx)(k,{label:"Model",children:s?(0,a.jsx)("input",{value:l,onChange:e=>d(e.target.value),placeholder:"e.g. voyage-3, embed-english-v3.0, text-embedding-3-small",className:"w-full px-3 py-1.5 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary font-mono"}):(0,a.jsx)("select",{value:l,onChange:e=>d(e.target.value),className:"w-full px-3 py-1.5 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary",children:o.map(e=>(0,a.jsx)("option",{value:e.id,children:e.name||e.id},e.id))})}),(0,a.jsx)(k,{label:"Endpoint",children:(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("input",{value:U,onChange:e=>f?S(e.target.value):N(e.target.value),className:"flex-1 px-3 py-1.5 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary font-mono",placeholder:"http://localhost:3000"}),w&&(0,a.jsxs)("button",{onClick:()=>j(e=>!e),title:f?"Using tunnel":"Using local",className:`flex items-center gap-1 text-xs px-2 py-1.5 rounded-lg border shrink-0 transition-colors ${f?"border-primary/40 bg-primary/10 text-primary":"border-border text-text-muted hover:text-primary"}`,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"wifi_tethering"}),"Tunnel"]})]})}),(0,a.jsx)(k,{label:"API Key",children:(0,a.jsx)("input",{type:"password",value:g,onChange:e=>y(e.target.value),placeholder:"sk-...",className:"w-full px-3 py-1.5 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary font-mono"})}),(0,a.jsx)(k,{label:"Input",children:(0,a.jsxs)("div",{className:"relative",children:[(0,a.jsx)("input",{value:u,onChange:e=>m(e.target.value),className:"w-full px-3 py-1.5 pr-7 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary"}),u&&(0,a.jsx)("button",{type:"button",onClick:()=>m(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-text-muted hover:text-primary transition-colors",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"close"})})]})}),(0,a.jsx)(k,{label:"Dimensions",children:(0,a.jsx)("input",{type:"number",min:"1",value:h,onChange:e=>b(e.target.value),placeholder:"optional, e.g. 512, 1024 (leave empty for default)",className:"w-full px-3 py-1.5 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary"})}),(0,a.jsxs)("div",{className:"mt-1",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between mb-1.5",children:[(0,a.jsx)("span",{className:"text-xs font-semibold text-text-muted uppercase tracking-wider",children:"Request"}),(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsxs)("button",{onClick:()=>E(B),className:"flex items-center gap-1 text-xs text-text-muted hover:text-primary transition-colors",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:O?"check":"content_copy"}),O?"Copied":"Copy"]}),(0,a.jsxs)("button",{onClick:F,disabled:R||!u.trim()||!L,className:"flex items-center gap-1.5 px-3 py-1 rounded-lg bg-primary text-white text-xs font-medium hover:bg-primary/90 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",style:R?{animation:"spin 1s linear infinite"}:void 0,children:"play_arrow"}),R?"Running...":"Run"]})]})]}),(0,a.jsx)("pre",{className:"bg-sidebar rounded-lg px-3 py-2.5 text-xs font-mono text-text-main overflow-x-auto whitespace-pre",children:B})]}),I&&(0,a.jsx)("p",{className:"text-xs text-red-500 break-words",children:I}),(0,a.jsxs)("div",{children:[(0,a.jsxs)("div",{className:"flex items-center justify-between mb-1.5",children:[(0,a.jsxs)("span",{className:"text-xs font-semibold text-text-muted uppercase tracking-wider",children:["Response ",$&&(0,a.jsxs)("span",{className:"font-normal normal-case",children:["⚡ ",$.latencyMs,"ms"]})]}),$&&(0,a.jsxs)("button",{onClick:()=>M(q),className:"flex items-center gap-1 text-xs text-text-muted hover:text-primary transition-colors",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:K?"check":"content_copy"}),K?"Copied":"Copy"]})]}),(0,a.jsx)("pre",{className:"bg-sidebar rounded-lg px-3 py-2.5 text-xs font-mono text-text-main overflow-x-auto whitespace-pre opacity-70",children:(e=>{if(!e)return C;let t=JSON.parse(JSON.stringify(e));return(t.data||[]).forEach(e=>{Array.isArray(e.embedding)&&e.embedding.length>4&&(e.embedding=[...e.embedding.slice(0,4).map(e=>parseFloat(e.toFixed(6))),`... (${e.embedding.length} dims)`])}),JSON.stringify(t,null,2)})($?.data)})]})]})]})}function A({providerId:e}){let t=(0,c.wG)(e),s=N[e]||N["edge-tts"],[r,o]=(0,i.useState)(""),[l,d]=(0,i.useState)(""),[u,m]=(0,i.useState)(""),[h,b]=(0,i.useState)([]),[g,y]=(0,i.useState)(""),[f,j]=(0,i.useState)(()=>{let t=c.Q2[e]?.ttsConfig?.models;if(t?.length)return t[0].id;if(s.hasModelSelector&&s.modelKey){let e=(0,p.KC)(s.modelKey);return e?.[0]?.id||""}return""}),[v,C]=(0,i.useState)("Hello, this is a text to speech test."),[$,P]=(0,i.useState)(""),[R,T]=(0,i.useState)(!1),[I,_]=(0,i.useState)(""),[O,E]=(0,i.useState)(""),[K,M]=(0,i.useState)("mp3"),[U,L]=(0,i.useState)(""),[D,B]=(0,i.useState)(null),[F,q]=(0,i.useState)(!1),[J,z]=(0,i.useState)(""),[V,H]=(0,i.useState)(null),{copied:W,copy:G}=(0,x.C)(),[Q,Y]=(0,i.useState)(!1),[Z,X]=(0,i.useState)([]),[ee,et]=(0,i.useState)(!1),[es,ea]=(0,i.useState)(""),[er,eo]=(0,i.useState)(""),[el,ei]=(0,i.useState)({});(0,i.useEffect)(()=>{if(_(window.location.origin),fetch("/api/keys").then(e=>e.json()).then(e=>{P((e.keys||[]).find(e=>!1!==e.isActive)?.key||"")}).catch(()=>{}),fetch("/api/tunnel/status").then(e=>e.json()).then(e=>{e.publicUrl&&E(e.publicUrl)}).catch(()=>{}),"hardcoded"===s.voiceSource){let t=s.hasModelSelector&&s.modelKey&&(0,p.KC)(s.modelKey)?.[0]?.id||"",a=s.voicesPerModel&&t?(0,w.jY)(e,t)||[]:(0,p.KC)(s.voiceKey||e).filter(e=>"tts"===e.type);if(a.length)if(s.hasBrowseButton){let e=a.find(e=>"en"===e.id)||a[0];y(e.id),o(e.id),d(e.name),b([{id:e.id,name:e.name}])}else b(a),o(a[0].id),d(a[0].name||a[0].id)}},[e]),(0,i.useEffect)(()=>{if(!s.voicesPerModel||!f)return;let t=(0,w.jY)(e,f)||[];b(t),t.length&&(o(t[0].id),d(t[0].name||t[0].id))},[f]);let en=async()=>{if(Y(!0),ea(""),eo(""),!Z.length){et(!0);try{if("hardcoded"===s.voiceSource){let t=s.voiceKey||e,a=(0,p.KC)(t).filter(e=>"tts"===e.type),r={};for(let e of a)r[e.id]||(r[e.id]={code:e.id,name:e.name,voices:[{id:e.id,name:e.name}]});ei(r),X(Object.values(r).sort((e,t)=>e.name.localeCompare(t.name)))}else{let t=s.apiEndpoint?s.apiEndpoint:`/api/media-providers/tts/voices?provider=${"local-device"===e?"local-device":"edge-tts"}`,a=await fetch(t),r=await a.json();if(r.error)return void eo(r.error);X(r.languages||[]),ei(r.byLang||{})}}catch(e){eo(e.message)}finally{et(!1)}}},ed=es?Z.filter(e=>e.name.toLowerCase().includes(es.toLowerCase())||e.code.toLowerCase().includes(es.toLowerCase())):Z,ec=R?O:I,ep=s.hasVoiceIdInput&&u||r,ex=s.hasModelSelector&&f&&ep?`${t}/${f}/${ep}`:s.hasModelSelector&&f?`${t}/${f}`:ep?`${t}/${ep}`:"",eu=`curl -X POST ${ec}/v1/audio/speech${"json"===K?"?response_format=json":""} \\
45
- -H "Content-Type: application/json" \\
46
- -H "Authorization: Bearer ${$||"YOUR_KEY"}" \\
47
- -d '{"model": "${ex}", "input": "${v}"}' \\
48
- ${"json"===K?"":"--output speech.mp3"}`,em=async()=>{if(!v.trim()||!ex)return;q(!0),z(""),L(""),B(null);let e=Date.now();try{let t={"Content-Type":"application/json"};$&&(t.Authorization=`Bearer ${$}`);let s=`/api/v1/audio/speech${"json"===K?"?response_format=json":""}`,a=await fetch(s,{method:"POST",headers:t,body:JSON.stringify({model:ex,input:v.trim()})});if(H(Date.now()-e),!a.ok){let e=await a.json().catch(()=>({}));z(e?.error?.message||e?.error||`HTTP ${a.status}`);return}if("json"===K){let e=await a.json();B(e);let t=await fetch(`data:audio/mp3;base64,${e.audio}`).then(e=>e.blob());L(URL.createObjectURL(t))}else{let e=await a.blob();L(URL.createObjectURL(e))}}catch(e){z(e.message||"Network error")}finally{q(!1)}};return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)(n.Zp,{children:[(0,a.jsx)("h2",{className:"text-lg font-semibold mb-4",children:"Example"}),(0,a.jsxs)("div",{className:"flex flex-col gap-2.5",children:[(0,a.jsx)(k,{label:"Endpoint",children:(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsxs)("span",{className:"flex-1 px-3 py-1.5 text-sm font-mono text-text-main bg-sidebar rounded-lg truncate",children:[ec,"/v1/audio/speech"]}),O&&(0,a.jsxs)("button",{onClick:()=>T(e=>!e),title:R?"Using tunnel":"Using local",className:`flex items-center gap-1 text-xs px-2 py-1.5 rounded-lg border shrink-0 transition-colors ${R?"border-primary/40 bg-primary/10 text-primary":"border-border text-text-muted hover:text-primary"}`,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"wifi_tethering"}),"Tunnel"]})]})}),(0,a.jsx)(k,{label:"API Key",children:(0,a.jsx)("span",{className:"px-3 py-1.5 text-sm font-mono text-text-main bg-sidebar rounded-lg truncate block",children:$?`${$.slice(0,8)}${"•".repeat(Math.min(20,$.length-8))}`:(0,a.jsx)("span",{className:"text-text-muted italic",children:"No key configured"})})}),s.hasModelSelector&&(s.modelKey||c.Q2[e]?.ttsConfig?.models?.length)&&(0,a.jsx)(k,{label:"Model",children:(0,a.jsx)("select",{value:f,onChange:e=>j(e.target.value),className:"w-full px-3 py-1.5 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary",children:((c.Q2[e]?.ttsConfig?.models?.length?c.Q2[e].ttsConfig.models:(0,p.KC)(s.modelKey))||[]).map(e=>(0,a.jsx)("option",{value:e.id,children:e.name||e.id},e.id))})}),s.hasBrowseButton&&(0,a.jsx)(k,{label:"Language",children:(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("button",{onClick:en,className:"flex-1 px-3 py-1.5 text-sm border border-border rounded-lg bg-background font-mono truncate text-left hover:border-primary/40 transition-colors",children:g?(0,a.jsx)("span",{className:"text-text-main",children:Z.find(e=>e.code===g)?.name||g}):(0,a.jsx)("span",{className:"text-text-muted",children:"No language selected"})}),(0,a.jsxs)("button",{onClick:en,className:"flex items-center gap-1 text-xs px-2.5 py-1.5 rounded-lg border border-border text-text-muted hover:text-primary hover:border-primary/40 transition-colors shrink-0",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"language"}),"Select language"]})]})}),h.length>0&&(0,a.jsx)(k,{label:"Voice",children:(0,a.jsx)("div",{className:"flex flex-wrap gap-1.5",children:h.map(e=>(0,a.jsxs)("button",{onClick:()=>{o(e.id),d(e.name),s.hasVoiceIdInput&&m(e.id)},className:`px-2.5 py-1 rounded-full text-xs border transition-colors ${r===e.id?"bg-primary/15 border-primary/40 text-primary font-medium":"border-border text-text-muted hover:text-primary hover:border-primary/40"}`,children:[e.name,e.gender?` \xb7 ${e.gender[0].toUpperCase()}`:"",!0===e.free_users_allowed&&(0,a.jsx)("span",{className:"ml-1.5 px-1 py-0.5 text-[9px] font-semibold rounded bg-green-500/15 text-green-600 border border-green-500/20",children:"Free"}),!1===e.free_users_allowed&&(0,a.jsx)("span",{className:"ml-1.5 px-1 py-0.5 text-[9px] font-semibold rounded bg-amber-500/15 text-amber-600 border border-amber-500/20",children:"Paid"})]},e.id))})}),s.hasVoiceIdInput&&(0,a.jsx)(k,{label:"Voice ID",children:(0,a.jsx)("div",{className:"flex flex-col gap-1",children:(0,a.jsxs)("div",{className:"relative",children:[(0,a.jsx)("input",{value:u,onChange:e=>{m(e.target.value),o(e.target.value)},placeholder:"e.g. CwhRBWXzGAHq8TQ4Fs17",className:"w-full px-3 py-1.5 pr-7 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary font-mono"}),u&&(0,a.jsx)("button",{type:"button",onClick:()=>{m(""),o("")},className:"absolute right-2 top-1/2 -translate-y-1/2 text-text-muted hover:text-primary transition-colors",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"close"})})]})})}),s.hasLanguageDropdown&&(0,a.jsx)(k,{label:"Language",children:(0,a.jsx)("select",{value:r,onChange:t=>{let s=(0,p.KC)(e).filter(e=>"tts"===e.type).find(e=>e.id===t.target.value);o(t.target.value),d(s?.name||t.target.value)},className:"w-full px-3 py-1.5 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary",children:(0,p.KC)(e).filter(e=>"tts"===e.type).map(e=>(0,a.jsx)("option",{value:e.id,children:e.name||e.id},e.id))})}),(0,a.jsx)(k,{label:"Input",children:(0,a.jsxs)("div",{className:"relative",children:[(0,a.jsx)("input",{value:v,onChange:e=>C(e.target.value),className:"w-full px-3 py-1.5 pr-7 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary"}),v&&(0,a.jsx)("button",{type:"button",onClick:()=>C(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-text-muted hover:text-primary transition-colors",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"close"})})]})}),(0,a.jsx)(k,{label:"Output Format",children:(0,a.jsxs)("select",{value:K,onChange:e=>M(e.target.value),className:"w-full px-3 py-1.5 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary",children:[(0,a.jsx)("option",{value:"mp3",children:"MP3 (Binary)"}),(0,a.jsx)("option",{value:"json",children:"JSON (Base64)"})]})}),(0,a.jsxs)("div",{className:"mt-1",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between mb-1.5",children:[(0,a.jsx)("span",{className:"text-xs font-semibold text-text-muted uppercase tracking-wider",children:"Request"}),(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsxs)("button",{onClick:()=>G(eu),className:"flex items-center gap-1 text-xs text-text-muted hover:text-primary transition-colors",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:W?"check":"content_copy"}),W?"Copied":"Copy"]}),(0,a.jsxs)("button",{onClick:em,disabled:F||!v.trim()||!ex,className:"flex items-center gap-1.5 px-3 py-1 rounded-lg bg-primary text-white text-xs font-medium hover:bg-primary/90 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",style:F?{animation:"spin 1s linear infinite"}:void 0,children:"play_arrow"}),F?"Generating...":"Run"]})]})]}),(0,a.jsx)("pre",{className:"bg-sidebar rounded-lg px-3 py-2.5 text-xs font-mono text-text-main overflow-x-auto whitespace-pre",children:eu})]}),J&&(0,a.jsx)("p",{className:"text-xs text-red-500 break-words",children:J}),U?(0,a.jsxs)("div",{children:[(0,a.jsxs)("div",{className:"flex items-center justify-between mb-1.5",children:[(0,a.jsxs)("span",{className:"text-xs font-semibold text-text-muted uppercase tracking-wider",children:["Response ",V&&(0,a.jsxs)("span",{className:"font-normal normal-case",children:["⚡ ",V,"ms"]})]}),(0,a.jsxs)("a",{href:U,download:"speech.mp3",className:"flex items-center gap-1 text-xs text-text-muted hover:text-primary transition-colors",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"download"}),"Download"]})]}),(0,a.jsx)("audio",{controls:!0,src:U,className:"w-full"}),D&&(0,a.jsxs)("div",{className:"mt-3",children:[(0,a.jsx)("div",{className:"flex items-center justify-between mb-1.5",children:(0,a.jsx)("span",{className:"text-xs font-semibold text-text-muted uppercase tracking-wider",children:"JSON Response"})}),(0,a.jsx)("pre",{className:"bg-sidebar rounded-lg px-3 py-2.5 text-xs font-mono text-text-main overflow-x-auto whitespace-pre-wrap break-all",children:JSON.stringify({format:D.format,audio:D.audio?`${D.audio.substring(0,100)}...`:""},null,2)})]})]}):(0,a.jsxs)("div",{children:[(0,a.jsx)("span",{className:"text-xs font-semibold text-text-muted uppercase tracking-wider",children:"Response"}),(0,a.jsx)("pre",{className:"mt-1.5 bg-sidebar rounded-lg px-3 py-2.5 text-xs font-mono text-text-main overflow-x-auto whitespace-pre opacity-50",children:S})]})]})]}),Q&&(0,a.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center",style:{backgroundColor:"rgba(0,0,0,0.6)",backdropFilter:"blur(2px)"},onClick:()=>Y(!1),children:(0,a.jsxs)("div",{className:"border border-border rounded-xl shadow-2xl w-full max-w-md mx-4 flex flex-col max-h-[80vh]",style:{backgroundColor:"var(--color-bg)",isolation:"isolate"},onClick:e=>e.stopPropagation(),children:[(0,a.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border shrink-0 rounded-t-xl",children:[(0,a.jsx)("h3",{className:"text-sm font-semibold",children:"Select Language"}),(0,a.jsx)("button",{onClick:()=>Y(!1),className:"text-text-muted hover:text-primary transition-colors",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[20px]",children:"close"})})]}),(0,a.jsx)("div",{className:"px-4 py-2.5 border-b border-border shrink-0",children:(0,a.jsx)("input",{autoFocus:!0,value:es,onChange:e=>ea(e.target.value),placeholder:"Search language...",className:"w-full px-3 py-1.5 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary"})}),(0,a.jsxs)("div",{className:"overflow-y-auto flex-1 p-2",children:[er&&(0,a.jsx)("p",{className:"text-xs text-red-500 px-2 py-1",children:er}),ee?(0,a.jsx)("p",{className:"text-xs text-text-muted px-2 py-3",children:"Loading..."}):(0,a.jsxs)("div",{className:"flex flex-col gap-0.5",children:[ed.map(e=>(0,a.jsxs)("button",{onClick:()=>{let t;return Y(!1),y(e.code),void(b(t=el[e.code]?.voices||[]),t.length&&(o(t[0].id),d(t[0].name),s.hasVoiceIdInput&&m(t[0].id)))},className:`flex items-center justify-between w-full px-3 py-2 rounded-lg text-left hover:bg-sidebar transition-colors ${g===e.code?"bg-primary/10 text-primary":""}`,children:[(0,a.jsx)("span",{className:"text-sm",children:e.name}),(0,a.jsxs)("div",{className:"flex items-center gap-2 shrink-0",children:[(0,a.jsxs)("span",{className:"text-xs text-text-muted",children:[e.voices.length," voices"]}),g===e.code&&(0,a.jsx)("span",{className:"material-symbols-outlined text-[16px] text-primary",children:"check"})]})]},e.code)),0===ed.length&&(0,a.jsx)("p",{className:"text-xs text-text-muted px-2 py-3",children:"No languages found."})]})]})]})})]})}function R({providerId:e,kind:t}){let s=(0,c.wG)(e),r=c.rj.find(e=>e.id===t),o=$[t],l=o||{},d=(0,p.KC)(e).filter(e=>e.type===t),[u,m]=(0,i.useState)(d[0]?.id??""),h=d.find(e=>e.id===u),b=!!h?.capabilities?.includes("edit"),[g,y]=(0,i.useState)(l.defaultInput||""),[f,j]=(0,i.useState)(""),[v,N]=(0,i.useState)(()=>(l.extraFields||[]).reduce((e,t)=>(e[t.key]=t.default??"",e),{})),[w,S]=(0,i.useState)(""),[C,P]=(0,i.useState)(!1),[A,T]=(0,i.useState)(""),[I,_]=(0,i.useState)(""),[O,E]=(0,i.useState)(null),[K,M]=(0,i.useState)(null),[U,L]=(0,i.useState)(null),[D,B]=(0,i.useState)("json"),[F,q]=(0,i.useState)(""),[J,z]=(0,i.useState)(!1),[V,H]=(0,i.useState)(""),[W,G]=(0,i.useState)([]),[Q,Y]=(0,i.useState)(""),{copied:Z,copy:X}=(0,x.C)(),{copied:ee,copy:et}=(0,x.C)();if((0,i.useEffect)(()=>{T(window.location.origin),fetch("/api/keys").then(e=>e.json()).then(e=>{S((e.keys||[]).find(e=>!1!==e.isActive)?.key||"")}).catch(()=>{}),fetch("/api/tunnel/status").then(e=>e.json()).then(e=>{e.publicUrl&&_(e.publicUrl)}).catch(()=>{}),fetch("/api/providers/client").then(e=>e.json()).then(t=>{G((t.connections||[]).filter(t=>t.provider===e&&!1!==t.isActive))}).catch(()=>{})},[e]),!r||!o)return null;let es=C?I:A,ea=r.endpoint.path,er=0===d.length?s:u?`${s}/${u}`:"",eo=Object.entries(v).reduce((e,[t,s])=>(""===s||null==s||"number"==typeof s&&Number.isNaN(s)||(e[t]=s),e),{}),el={model:er,[o.bodyKey]:g,...o.extraBody,...eo,...b&&f.trim()?{image:f.trim()}:{}},ei="image"===t&&"binary"===D,en="image"===t&&"codex"===e&&!ei,ed=`${ea}${ei?"?response_format=binary":""}`,ec=`-H "Content-Type: application/json" \\
49
- -H "Authorization: Bearer ${w||"YOUR_KEY"}"${Q?` \\
50
- -H "x-connection-id: ${Q}"`:""}${en?` \\
51
- -H "Accept: text/event-stream"`:""}`,ep=`curl -X ${r.endpoint.method} ${es}${ed} \\
52
- ${ec.replace(/\\\n /g,"\\\n ")} \\
53
- -d '${JSON.stringify(el)}'${ei?" \\\n --output image.png":""}`,ex=async()=>{if(!g.trim()||!er)return;if(z(!0),H(""),E(null),M(null),L(null),F){try{URL.revokeObjectURL(F)}catch{}q("")}let e=Date.now();try{let t={"Content-Type":"application/json"};w&&(t.Authorization=`Bearer ${w}`),Q&&(t["x-connection-id"]=Q),en&&(t.Accept="text/event-stream");let s={...el,model:er},a=await fetch(`/api${ed}`,{method:r.endpoint.method,headers:t,body:JSON.stringify(s)});if(!a.ok){let e=await a.json().catch(()=>({}));H(e?.error?.message||e?.error||`HTTP ${a.status}`);return}let o=a.headers.get("content-type")||"";if(o.startsWith("image/")){let t=await a.blob(),s=URL.createObjectURL(t);q(s),E({data:{binary:!0,mime:o,size:t.size},latencyMs:Date.now()-e});return}if(o.includes("text/event-stream")&&a.body){let t=a.body.getReader(),s=new TextDecoder,r="",o=null,l=null;for(;;){let e,{done:a,value:i}=await t.read();if(a)break;for(r+=s.decode(i,{stream:!0});-1!==(e=r.indexOf("\n\n"));){let t=r.slice(0,e);r=r.slice(e+2);let s=null,a="";for(let e of t.split("\n"))e.startsWith("event:")?s=e.slice(6).trim():e.startsWith("data:")&&(a+=e.slice(5).trim());if(s)try{let e=a?JSON.parse(a):{};"progress"===s?M(e):"partial_image"===s?L(e):"done"===s?o=e:"error"===s&&(l=e?.message||"Stream error")}catch{}}}let i=Date.now()-e;if(l)return void H(l);o&&E({data:o,latencyMs:i})}else{let t=await a.json(),s=Date.now()-e;E({data:t,latencyMs:s})}}catch(e){H(e.message||"Network error")}finally{z(!1)}},eu=e=>{if(!e||"object"!=typeof e)return e;if(Array.isArray(e))return e.map(eu);let t={};for(let[s,a]of Object.entries(e))t[s]="b64_json"===s&&"string"==typeof a&&a.length>100?`<${a.length} chars base64>`:eu(a);return t},em=O?JSON.stringify(eu(O.data),null,2):"";return(0,a.jsxs)(n.Zp,{children:[(0,a.jsx)("h2",{className:"text-lg font-semibold mb-4",children:"Example"}),(0,a.jsxs)("div",{className:"flex flex-col gap-2.5",children:[d.length>0&&(0,a.jsx)(k,{label:"Model",children:(0,a.jsx)("select",{value:u,onChange:e=>m(e.target.value),className:"w-full px-3 py-1.5 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary",children:d.map(e=>(0,a.jsx)("option",{value:e.id,children:e.name||e.id},e.id))})}),(0,a.jsx)(k,{label:"Endpoint",children:(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsxs)("span",{className:"flex-1 px-3 py-1.5 text-sm font-mono text-text-main bg-sidebar rounded-lg truncate",children:[es,ea]}),I&&(0,a.jsxs)("button",{onClick:()=>P(e=>!e),title:C?"Using tunnel":"Using local",className:`flex items-center gap-1 text-xs px-2 py-1.5 rounded-lg border shrink-0 transition-colors ${C?"border-primary/40 bg-primary/10 text-primary":"border-border text-text-muted hover:text-primary"}`,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"wifi_tethering"}),"Tunnel"]})]})}),(0,a.jsx)(k,{label:"API Key",children:(0,a.jsx)("span",{className:"px-3 py-1.5 text-sm font-mono text-text-main bg-sidebar rounded-lg truncate block",children:w?`${w.slice(0,8)}${"•".repeat(Math.min(20,w.length-8))}`:(0,a.jsx)("span",{className:"text-text-muted italic",children:"No key configured"})})}),W.length>0&&(0,a.jsx)(k,{label:"Connection",children:(0,a.jsxs)("select",{value:Q,onChange:e=>Y(e.target.value),className:"w-full px-3 py-1.5 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary",children:[(0,a.jsx)("option",{value:"",children:"Auto (by priority)"}),W.map(e=>{let t=e.providerSpecificData?.chatgptPlanType,s=e.email||e.name||e.id.slice(0,8);return(0,a.jsxs)("option",{value:e.id,children:[s,t?` [${t}]`:""]},e.id)})]})}),(0,a.jsx)(k,{label:o.inputLabel,children:(0,a.jsxs)("div",{className:"relative",children:[(0,a.jsx)("input",{value:g,onChange:e=>y(e.target.value),placeholder:o.inputPlaceholder,className:"w-full px-3 py-1.5 pr-7 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary"}),g&&(0,a.jsx)("button",{type:"button",onClick:()=>y(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-text-muted hover:text-primary transition-colors",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"close"})})]})}),b&&(0,a.jsx)(k,{label:"Ref Image (URL)",children:(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,a.jsxs)("div",{className:"relative",children:[(0,a.jsx)("input",{value:f,onChange:e=>j(e.target.value),placeholder:"https://example.com/source.png",className:"w-full px-3 py-1.5 pr-7 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary"}),f&&(0,a.jsx)("button",{type:"button",onClick:()=>j(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-text-muted hover:text-primary transition-colors",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"close"})})]}),f.trim()&&(0,a.jsx)("img",{src:f.trim(),alt:"Reference",className:"max-h-40 rounded-lg border border-border object-contain bg-sidebar",onError:e=>{e.currentTarget.style.display="none"},onLoad:e=>{e.currentTarget.style.display="block"}})]})}),(o.extraFields||[]).filter(e=>0===d.length||Array.isArray(h?.params)&&h.params.includes(e.key)).map(e=>(0,a.jsx)(k,{label:e.label,children:"select"===e.type?(0,a.jsx)("select",{value:v[e.key]??"",onChange:t=>N(s=>({...s,[e.key]:t.target.value})),className:"w-full px-3 py-1.5 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary",children:(e.options||[]).map(e=>(0,a.jsx)("option",{value:e,children:""===e?"(default)":e},e))}):"text"===e.type?(0,a.jsx)("input",{type:"text",value:v[e.key]??"",placeholder:e.placeholder,onChange:t=>N(s=>({...s,[e.key]:t.target.value})),className:"w-full px-3 py-1.5 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary"}):(0,a.jsx)("input",{type:"number",value:v[e.key]??"",min:e.min,max:e.max,onChange:t=>N(s=>({...s,[e.key]:""===t.target.value?"":Number(t.target.value)})),className:"w-full px-3 py-1.5 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary"})},e.key)),"image"===t&&(0,a.jsx)(k,{label:"Output Format",children:(0,a.jsxs)("select",{value:D,onChange:e=>B(e.target.value),className:"w-full px-3 py-1.5 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary",children:[(0,a.jsx)("option",{value:"json",children:"JSON (Base64)"}),(0,a.jsx)("option",{value:"binary",children:"Binary File"})]})}),(0,a.jsxs)("div",{className:"mt-1",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between mb-1.5",children:[(0,a.jsx)("span",{className:"text-xs font-semibold text-text-muted uppercase tracking-wider",children:"Request"}),(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsxs)("button",{onClick:()=>X(ep),className:"flex items-center gap-1 text-xs text-text-muted hover:text-primary transition-colors",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:Z?"check":"content_copy"}),Z?"Copied":"Copy"]}),(0,a.jsxs)("button",{onClick:ex,disabled:J||!g.trim()||!er,className:"flex items-center gap-1.5 px-3 py-1 rounded-lg bg-primary text-white text-xs font-medium hover:bg-primary/90 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",style:J?{animation:"spin 1s linear infinite"}:void 0,children:"play_arrow"}),J?"Running...":"Run"]})]})]}),(0,a.jsx)("pre",{className:"bg-sidebar rounded-lg px-3 py-2.5 text-xs font-mono text-text-main overflow-x-auto whitespace-pre",children:ep})]}),(J||K)&&en&&(0,a.jsxs)("div",{className:"flex items-center gap-3 px-3 py-2 rounded-lg bg-sidebar border border-border",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[16px] text-primary",style:J?{animation:"spin 1s linear infinite"}:void 0,children:J?"progress_activity":"check_circle"}),(0,a.jsxs)("span",{className:"text-xs text-text-muted",children:[K?.stage||"starting",!J&&K?.bytesReceived?` \xb7 ${(K.bytesReceived/1024).toFixed(1)} KB`:""]})]}),U?.b64_json&&!O&&(0,a.jsxs)("div",{children:[(0,a.jsx)("span",{className:"text-xs font-semibold text-text-muted uppercase tracking-wider",children:"Partial preview"}),(0,a.jsx)("img",{src:`data:image/png;base64,${U.b64_json}`,alt:"Partial",className:"max-w-full rounded-lg border border-border mt-1.5 opacity-80"})]}),V&&(0,a.jsx)("p",{className:"text-xs text-red-500 break-words",children:V}),(0,a.jsxs)("div",{children:[(0,a.jsxs)("div",{className:"flex items-center justify-between mb-1.5",children:[(0,a.jsxs)("span",{className:"text-xs font-semibold text-text-muted uppercase tracking-wider",children:["Response ",O&&(0,a.jsxs)("span",{className:"font-normal normal-case",children:["⚡ ",O.latencyMs,"ms"]})]}),O&&(0,a.jsxs)("button",{onClick:()=>et(em),className:"flex items-center gap-1 text-xs text-text-muted hover:text-primary transition-colors",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:ee?"check":"content_copy"}),ee?"Copied":"Copy"]})]}),(0,a.jsx)("pre",{className:"bg-sidebar rounded-lg px-3 py-2.5 text-xs font-mono text-text-main overflow-x-auto whitespace-pre opacity-70",children:O?em:o.defaultResponse}),"image"===t&&(F||O?.data?.data?.[0])&&(0,a.jsxs)("div",{className:"mt-2",children:[(0,a.jsx)("div",{className:"flex items-center justify-end mb-1.5",children:(0,a.jsxs)("a",{href:F||(O?.data?.data?.[0]?.b64_json?`data:image/png;base64,${O.data.data[0].b64_json}`:O?.data?.data?.[0]?.url||""),download:"image.png",className:"flex items-center gap-1 text-xs text-text-muted hover:text-primary transition-colors",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"download"}),"Download"]})}),(0,a.jsx)("img",{src:F||(O?.data?.data?.[0]?.b64_json?`data:image/png;base64,${O.data.data[0].b64_json}`:O?.data?.data?.[0]?.url),alt:"Generated",className:"max-w-full rounded-lg border border-border"})]})]})]})]})}function T(){let{kind:e,id:t}=(0,r.useParams)(),s=(0,r.useRouter)(),o=c.rj.find(t=>t.id===e),p=(0,c.gC)(t)&&"embedding"===e,x=async()=>{if(confirm("Delete this Custom Embedding node?"))try{(await fetch(`/api/provider-nodes/${t}`,{method:"DELETE"})).ok&&s.push(`/dashboard/media-providers/${e}`)}catch(e){console.log("Error deleting custom embedding node:",e)}},[u,m]=(0,i.useState)(null),[h,b]=(0,i.useState)(p),[g,f]=(0,i.useState)(!1);if((0,i.useEffect)(()=>{if(!p)return;let e=!1;return fetch("/api/provider-nodes",{cache:"no-store"}).then(e=>e.json()).then(s=>{e||(m((s.nodes||[]).find(e=>e.id===t)||null),b(!1))}).catch(()=>{e||b(!1)}),()=>{e=!0}},[t,p]),!o)return(0,r.notFound)();let j=c.Q2[t],N=p?u?{id:t,name:u.name||"Custom Embedding",color:"#6366F1",textIcon:"CE"}:null:j;if(!p&&!j||p&&!h&&!u)return(0,r.notFound)();if(p&&h)return(0,a.jsx)("div",{className:"text-text-muted text-sm py-12 text-center",children:"Loading..."});let w=p?["embedding"]:N.serviceKinds??["llm"];return p||w.includes(e)?(0,a.jsxs)("div",{className:"flex flex-col gap-8",children:[(0,a.jsxs)("div",{children:[(0,a.jsxs)(l(),{href:`/dashboard/media-providers/${e}`,className:"inline-flex items-center gap-1 text-sm text-text-muted hover:text-primary transition-colors mb-4",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-lg",children:"arrow_back"}),o.label]}),(0,a.jsxs)("div",{className:"flex items-center gap-4",children:[(0,a.jsx)("div",{className:"size-12 rounded-lg flex items-center justify-center shrink-0",style:{backgroundColor:`${N.color}15`},children:(0,a.jsx)(d.A,{src:`/providers/${N.id}.png`,alt:N.name,size:48,className:"object-contain rounded-lg max-w-[48px] max-h-[48px]",fallbackText:N.textIcon||N.id.slice(0,2).toUpperCase(),fallbackColor:N.color})}),(0,a.jsxs)("div",{className:"flex-1",children:[(0,a.jsxs)("div",{className:"flex items-center gap-3 flex-wrap",children:[(0,a.jsx)("h1",{className:"text-3xl font-semibold tracking-tight",children:N.name}),!p&&N.notice?.apiKeyUrl&&(0,a.jsxs)("a",{href:N.notice.apiKeyUrl,target:"_blank",rel:"noopener noreferrer",className:"text-xs text-primary hover:underline inline-flex items-center gap-1",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:"open_in_new"}),"Get API Key"]})]}),(0,a.jsxs)("div",{className:"flex items-center gap-1.5 mt-1 flex-wrap",children:[p&&(0,a.jsxs)(n.Ex,{variant:"default",size:"sm",children:["Custom \xb7 ",u?.prefix]}),w.map(t=>(0,a.jsx)(n.Ex,{variant:t===e?"primary":"default",size:"sm",children:t.toUpperCase()},t))]})]}),p&&(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)(n.$n,{size:"sm",variant:"secondary",icon:"edit",onClick:()=>f(!0),children:"Edit"}),(0,a.jsx)(n.$n,{size:"sm",variant:"secondary",icon:"delete",onClick:x,children:"Delete"})]})]})]}),!p&&N.kindNotice?.[e]&&(0,a.jsxs)("div",{className:"flex items-start gap-3 px-4 py-3 rounded-lg bg-amber-500/10 border border-amber-500/30 text-amber-700 dark:text-amber-400",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[20px] mt-0.5",children:"warning"}),(0,a.jsx)("p",{className:"text-sm",children:N.kindNotice[e]})]}),!p&&N.notice?.text&&!N.deprecated&&(0,a.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,a.jsx)("span",{className:"material-symbols-outlined text-[16px] text-blue-500 shrink-0",children:"info"}),(0,a.jsx)("p",{className:"min-w-0 flex-1 text-xs leading-relaxed text-blue-600 dark:text-blue-400",children:N.notice.text}),N.notice.apiKeyUrl&&(0,a.jsx)("a",{href:N.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 →"})]}),!p&&N.noAuth?(0,a.jsx)(n.gw,{providerId:t}):(0,a.jsx)(y,{providerId:t,isOAuth:!1}),"tts"!==e&&"webSearch"!==e&&"webFetch"!==e&&(0,a.jsx)(v,{providerId:t,kindFilter:e,providerAliasOverride:p?u?.prefix:void 0}),!p&&(N.searchConfig||N.fetchConfig||N.ttsConfig||N.embeddingConfig||N.searchViaChat)&&(0,a.jsx)(n.Wx,{config:"webFetch"===e?N.fetchConfig:"tts"===e?N.ttsConfig:"embedding"===e?N.embeddingConfig:N.searchConfig||{mode:"chat-completions",defaultModel:N.searchViaChat?.defaultModel,pricingUrl:N.searchViaChat?.pricingUrl,freeTier:N.searchViaChat?.freeTier},provider:N,title:`${o.label} Config`}),"embedding"===e&&(0,a.jsx)(P,{providerId:t,customAlias:u?.prefix}),"tts"===e&&(0,a.jsx)(A,{providerId:t}),!p&&$[e]&&(0,a.jsx)(R,{providerId:t,kind:e}),p&&(0,a.jsx)(n.x0,{isOpen:g,node:u,onClose:()=>f(!1),onSaved:e=>{m(e),f(!1)}})]}):(0,r.notFound)()}}},e=>{e.O(0,[7848,4335,6795,505,4156,2347,5158,7358],()=>e(e.s=597)),_N_E=e.O()}]);
@@ -1 +0,0 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[6620],{20021:(e,s,t)=>{Promise.resolve().then(t.bind(t,47432))},47432:(e,s,t)=>{"use strict";t.r(s),t.d(s,{default:()=>h});var r=t(73365),i=t(29717),n=t(99568),d=t.n(n),a=t(1521),c=t(74156),o=t(68266),l=t(82495);function x(e){let s=Object.entries(e).some(([e,s])=>e.startsWith("modelLock_")&&s&&new Date(s).getTime()>Date.now());return"unavailable"!==e.testStatus||s?e.testStatus:"active"}function m({provider:e,kind:s,connections:t,isCustom:i}){let n=l.Q2[e.id],a=!!n?.noAuth,h=t.filter(s=>s.provider===e.id),u=h.filter(e=>{let s=x(e);return"active"===s||"success"===s}).length,p=h.filter(e=>{let s=x(e);return"error"===s||"expired"===s||"unavailable"===s}).length,f=h.length,v=f>0&&h.every(e=>!1===e.isActive);return(0,r.jsx)(d(),{href:`/dashboard/media-providers/${s}/${e.id}`,className:"group",children:(0,r.jsx)(c.Zp,{padding:"xs",className:`h-full hover:bg-black/[0.01] dark:hover:bg-white/[0.01] transition-colors cursor-pointer ${v?"opacity-50":""}`,children:(0,r.jsxs)("div",{className:"flex items-center gap-3",children:[(0,r.jsx)("div",{className:"size-8 rounded-lg flex items-center justify-center shrink-0",style:{backgroundColor:`${e.color?.length>7?e.color:(e.color??"#888")+"15"}`},children:(0,r.jsx)(o.A,{src:`/providers/${e.id}.png`,alt:e.name,size:30,className:"object-contain rounded-lg max-w-[30px] max-h-[30px]",fallbackText:e.textIcon||e.id.slice(0,2).toUpperCase(),fallbackColor:e.color})}),(0,r.jsxs)("div",{children:[(0,r.jsx)("h3",{className:"font-semibold text-sm",children:e.name}),(0,r.jsxs)("div",{className:"flex items-center gap-2 mt-0.5 flex-wrap",children:[i&&(0,r.jsx)(c.Ex,{variant:"default",size:"sm",children:"Custom"}),a?(0,r.jsx)(c.Ex,{variant:"success",size:"sm",children:"Ready"}):v?(0,r.jsx)(c.Ex,{variant:"default",size:"sm",children:"Disabled"}):0===f?(0,r.jsx)("span",{className:"text-xs text-text-muted",children:"No connections"}):(0,r.jsxs)(r.Fragment,{children:[u>0&&(0,r.jsxs)(c.Ex,{variant:"success",size:"sm",dot:!0,children:[u," Connected"]}),p>0&&(0,r.jsxs)(c.Ex,{variant:"error",size:"sm",dot:!0,children:[p," Error"]}),0===u&&0===p&&(0,r.jsxs)(c.Ex,{variant:"default",size:"sm",children:[f," Added"]})]})]})]})]})})})}function h(){let{kind:e}=(0,i.useParams)(),s=(0,i.useRouter)(),[t,n]=(0,a.useState)([]),[d,o]=(0,a.useState)([]),[x,h]=(0,a.useState)(!1);(0,a.useEffect)(()=>{("webSearch"===e||"webFetch"===e)&&s.replace("/dashboard/media-providers/web")},[e,s]);let u=l.rj.find(s=>s.id===e),p="embedding"===e;if((0,a.useEffect)(()=>{u&&(fetch("/api/providers",{cache:"no-store"}).then(e=>e.json()).then(e=>n(e.connections||[])).catch(()=>{}),p&&fetch("/api/provider-nodes",{cache:"no-store"}).then(e=>e.json()).then(e=>o((e.nodes||[]).filter(e=>"custom-embedding"===e.type))).catch(()=>{}))},[p,u]),!u)return(0,i.notFound)();let f=(0,l.o5)(e),v=d.map(e=>({id:e.id,name:e.name||"Custom Embedding",color:"#6366F1",textIcon:"CE"})),j=[...f,...v];return(0,r.jsxs)("div",{className:"flex flex-col gap-6",children:[p&&(0,r.jsx)("div",{className:"flex items-center justify-end",children:(0,r.jsx)(c.$n,{size:"sm",icon:"add",onClick:()=>h(!0),children:"Add Custom Embedding"})}),0===j.length?(0,r.jsxs)("div",{className:"text-center py-12 border border-dashed border-border rounded-xl text-text-muted text-sm",children:["No providers support ",(0,r.jsx)("strong",{children:u.label})," yet."]}):(0,r.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4",children:[f.map(s=>(0,r.jsx)(m,{provider:s,kind:e,connections:t},s.id)),v.map(s=>(0,r.jsx)(m,{provider:s,kind:e,connections:t,isCustom:!0},s.id))]}),p&&(0,r.jsx)(c.x0,{isOpen:x,onClose:()=>h(!1),onCreated:e=>{o(s=>[...s,e]),h(!1)}})]})}}},e=>{e.O(0,[7848,4335,6795,505,4156,2347,5158,7358],()=>e(e.s=20021)),_N_E=e.O()}]);
@@ -1,4 +0,0 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[4701],{13648:(e,t,s)=>{Promise.resolve().then(s.bind(s,83307))},83307:(e,t,s)=>{"use strict";s.r(t),s.d(t,{default:()=>b});var a=s(73365),r=s(29717),n=s(1521),l=s(99568),i=s.n(l),o=s(74156),c=s(68266),d=s(82495);let m=/^[a-zA-Z0-9_.\-]+$/,x={webSearch:"Web Search",webFetch:"Web Fetch"},h={webSearch:"/v1/search",webFetch:"/v1/web/fetch"},u={webSearch:e=>({model:e,query:"What is the latest news about AI?",search_type:"web",max_results:5}),webFetch:e=>({model:e,url:"https://example.com",format:"markdown"})};function p({isOpen:e,onClose:t,onPick:s,kind:r,currentIds:n,connections:l}){let i=new Set((l||[]).filter(e=>{if(!1===e.isActive)return!1;let t=e.testStatus;return"active"===t||"success"===t||"unavailable"===t}).map(e=>e.provider)),m=(r?(0,d.o5)(r):[]).filter(e=>e.noAuth||i.has(e.id));return(0,a.jsx)(o.aF,{isOpen:e,onClose:t,title:`Add ${x[r]||""} Provider`,size:"md",children:0===m.length?(0,a.jsxs)("div",{className:"text-center py-6 text-sm text-text-muted",children:["No connected providers available. Add a connection first in the ",x[r]," section."]}):(0,a.jsx)("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-2 max-h-[400px] overflow-y-auto",children:m.map(e=>{let r=n.includes(e.id);return(0,a.jsxs)("button",{disabled:r,onClick:()=>{s(e.id),t()},className:`flex items-center gap-2 p-2 rounded-lg border transition-colors ${r?"border-border opacity-40 cursor-not-allowed":"border-border hover:border-primary/50 hover:bg-primary/5 cursor-pointer"}`,children:[(0,a.jsx)(c.A,{src:`/providers/${e.id}.png`,alt:e.name,size:24,className:"object-contain rounded shrink-0",fallbackText:e.textIcon||e.id.slice(0,2).toUpperCase(),fallbackColor:e.color}),(0,a.jsx)("span",{className:"text-xs font-medium truncate text-left",children:e.name}),r&&(0,a.jsx)("span",{className:"text-[9px] text-text-muted ml-auto",children:"added"})]},e.id)})})})}function b(){let{id:e}=(0,r.useParams)(),t=(0,r.useRouter)(),[s,l]=(0,n.useState)(null),[b,f]=(0,n.useState)(!0),[j,g]=(0,n.useState)(""),[w,v]=(0,n.useState)(""),[N,y]=(0,n.useState)([]),[k,S]=(0,n.useState)(!1),[C,$]=(0,n.useState)(!1),[_,O]=(0,n.useState)([]),[A,T]=(0,n.useState)(!1),[P,E]=(0,n.useState)(""),[z,R]=(0,n.useState)(""),[F,J]=(0,n.useState)([]),U=async()=>{try{let[t,s,a,r,n]=await Promise.all([fetch(`/api/combos/${e}`,{cache:"no-store"}),fetch("/api/settings",{cache:"no-store"}),fetch("/api/usage/logs",{cache:"no-store"}),fetch("/api/keys",{cache:"no-store"}),fetch("/api/providers",{cache:"no-store"})]);if(r.ok){let e=await r.json();R((e.keys||[]).find(e=>!1!==e.isActive)?.key||"")}if(n.ok&&J((await n.json()).connections||[]),!t.ok){l(null),f(!1);return}let i=await t.json();l(i),g(i.name),y(i.models||[]);let o=s.ok?await s.json():{};S(o.comboStrategies?.[i.name]?.fallbackStrategy==="round-robin");let c=a.ok?await a.json():[];O(c.filter(e=>"string"==typeof e&&e.includes(i.name)).slice(0,50))}catch{}f(!1)};(0,n.useEffect)(()=>{U()},[e]);let Z=e=>e.trim()?m.test(e)?(v(""),!0):(v("Only letters, numbers, -, _ and ."),!1):(v("Name is required"),!1),I=async t=>{let s=await fetch(`/api/combos/${e}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});return!!s.ok||(alert((await s.json()).error||"Failed to save"),!1)},W=async()=>{!Z(j)||j===s.name||await I({name:j})&&await U()},q=async e=>{let t=[...N,e];y(t),await I({models:t})},B=async e=>{let t=N.filter((t,s)=>s!==e);y(t),await I({models:t})},D=async(e,t)=>{let s=[...N],a=e+t;a<0||a>=s.length||([s[e],s[a]]=[s[a],s[e]],y(s),await I({models:s}))},H=async e=>{S(e);let t=await fetch("/api/settings",{cache:"no-store"}),a={...(t.ok?await t.json():{}).comboStrategies||{}};e?a[s.name]={fallbackStrategy:"round-robin"}:delete a[s.name],await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({comboStrategies:a})})},L=async()=>{!confirm(`Delete combo "${s.name}"?`)||(await fetch(`/api/combos/${e}`,{method:"DELETE"})).ok&&t.push("/dashboard/media-providers/web")},M=async()=>{T(!0),E("");try{let e=h[s.kind],t=u[s.kind](s.name),a={"Content-Type":"application/json"};z&&(a.Authorization=`Bearer ${z}`);let r=await fetch(`/api${e}`,{method:"POST",headers:a,body:JSON.stringify(t)}),n=await r.json().catch(()=>({}));E(JSON.stringify(n,null,2))}catch(e){E(`Error: ${e.message}`)}T(!1)};if(b)return(0,a.jsx)("div",{className:"text-text-muted text-sm",children:"Loading..."});if(!s)return(0,r.notFound)();let Y=x[s.kind]||"Web",K=h[s.kind],Q=s.kind?u[s.kind](s.name):null,X=K?`curl -X POST http://localhost:20128${K} \\
2
- -H "Content-Type: application/json" \\
3
- -H "Authorization: Bearer ${z||"YOUR_KEY"}" \\
4
- -d '${JSON.stringify(Q)}'`:"";return(0,a.jsxs)("div",{className:"flex flex-col gap-6",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between gap-4",children:[(0,a.jsxs)("div",{className:"flex items-center gap-3 min-w-0",children:[(0,a.jsx)(i(),{href:"/dashboard/media-providers/web",className:"text-text-muted hover:text-primary",children:(0,a.jsx)("span",{className:"material-symbols-outlined",children:"arrow_back"})}),(0,a.jsx)("div",{className:"size-10 rounded-lg bg-primary/10 flex items-center justify-center",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-primary",children:"layers"})}),(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsxs)("p",{className:"text-xs text-text-muted",children:[Y," Combo"]}),(0,a.jsx)("code",{className:"text-lg font-semibold font-mono",children:s.name})]})]}),(0,a.jsx)(o.$n,{variant:"outline",icon:"delete",onClick:L,className:"text-red-500 border-red-200 hover:bg-red-50",children:"Delete"})]}),(0,a.jsxs)(o.Zp,{children:[(0,a.jsx)("h2",{className:"text-lg font-semibold mb-3",children:"Settings"}),(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)(o.pd,{label:"Combo Name",value:j,onChange:e=>{g(e.target.value),Z(e.target.value)},onBlur:W,error:w}),(0,a.jsx)("p",{className:"text-[10px] text-text-muted mt-0.5",children:"Only letters, numbers, -, _ and ."})]}),(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"text-sm font-medium",children:"Round Robin"}),(0,a.jsx)("p",{className:"text-xs text-text-muted",children:"Rotate providers across requests instead of strict fallback order."})]}),(0,a.jsx)(o.lM,{checked:k,onChange:H})]})]})]}),(0,a.jsxs)(o.Zp,{children:[(0,a.jsxs)("div",{className:"flex items-center justify-between mb-3",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("h2",{className:"text-lg font-semibold",children:"Providers"}),(0,a.jsx)("p",{className:"text-xs text-text-muted",children:"Tried in order (top-down) or rotated when round-robin is on."})]}),(0,a.jsx)(o.$n,{size:"sm",icon:"add",onClick:()=>$(!0),children:"Add Provider"})]}),0===N.length?(0,a.jsx)("div",{className:"text-center py-6 border border-dashed border-border rounded-lg text-text-muted text-sm",children:"No providers yet."}):(0,a.jsx)("div",{className:"flex flex-col gap-2",children:N.map((e,t)=>{let s=d.Q2[e];return(0,a.jsxs)("div",{className:"flex items-center gap-3 p-2 rounded-lg bg-black/[0.02] dark:bg-white/[0.02]",children:[(0,a.jsx)("span",{className:"text-xs text-text-muted w-5 text-center",children:t+1}),(0,a.jsx)(c.A,{src:`/providers/${e}.png`,alt:s?.name||e,size:24,className:"object-contain rounded shrink-0",fallbackText:s?.textIcon||e.slice(0,2).toUpperCase(),fallbackColor:s?.color}),(0,a.jsx)("span",{className:"text-sm font-medium flex-1 truncate",children:s?.name||e}),(0,a.jsxs)("div",{className:"flex items-center gap-0.5",children:[(0,a.jsx)("button",{onClick:()=>D(t,-1),disabled:0===t,className:`p-1 rounded ${0===t?"text-text-muted/20":"text-text-muted hover:text-primary hover:bg-black/5"}`,title:"Move up",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"arrow_upward"})}),(0,a.jsx)("button",{onClick:()=>D(t,1),disabled:t===N.length-1,className:`p-1 rounded ${t===N.length-1?"text-text-muted/20":"text-text-muted hover:text-primary hover:bg-black/5"}`,title:"Move down",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"arrow_downward"})}),(0,a.jsx)("button",{onClick:()=>B(t),className:"p-1 rounded text-text-muted hover:text-red-500 hover:bg-red-500/10",title:"Remove",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"close"})})]})]},`${e}-${t}`)})})]}),s.kind&&(0,a.jsxs)(o.Zp,{children:[(0,a.jsxs)("div",{className:"flex items-center justify-between mb-3",children:[(0,a.jsx)("h2",{className:"text-lg font-semibold",children:"Test Example"}),(0,a.jsx)(o.$n,{size:"sm",icon:"play_arrow",onClick:M,disabled:A||0===N.length,children:A?"Running...":"Run"})]}),(0,a.jsx)("pre",{className:"text-xs font-mono bg-black/[0.03] dark:bg-white/[0.03] p-3 rounded-lg overflow-x-auto whitespace-pre-wrap break-all",children:X}),P&&(0,a.jsx)("pre",{className:"mt-3 text-xs font-mono bg-black/[0.03] dark:bg-white/[0.03] p-3 rounded-lg overflow-auto max-h-[300px]",children:P})]}),(0,a.jsxs)(o.Zp,{children:[(0,a.jsx)("h2",{className:"text-lg font-semibold mb-3",children:"Usage Logs"}),0===_.length?(0,a.jsx)("p",{className:"text-xs text-text-muted italic",children:"No usage yet."}):(0,a.jsx)("pre",{className:"text-[11px] font-mono bg-black/[0.03] dark:bg-white/[0.03] p-3 rounded-lg overflow-auto max-h-[400px] whitespace-pre-wrap",children:_.join("\n")})]}),(0,a.jsx)(p,{isOpen:C,onClose:()=>$(!1),onPick:q,kind:s.kind,currentIds:N,connections:F})]})}}},e=>{e.O(0,[7848,4335,6795,505,4156,2347,5158,7358],()=>e(e.s=13648)),_N_E=e.O()}]);
@@ -1 +0,0 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[9260],{51181:(e,s,t)=>{Promise.resolve().then(t.bind(t,69640))},69640:(e,s,t)=>{"use strict";t.r(s),t.d(s,{default:()=>p});var r=t(73365),a=t(99568),i=t.n(a),l=t(1521),c=t(29717),o=t(74156),n=t(68266),d=t(82495);function m(e){let s=Object.entries(e).some(([e,s])=>e.startsWith("modelLock_")&&s&&new Date(s).getTime()>Date.now());return"unavailable"!==e.testStatus||s?e.testStatus:"active"}function x({provider:e,kind:s,connections:t}){let a=d.Q2[e.id],l=!!a?.noAuth,c=t.filter(s=>s.provider===e.id),h=c.filter(e=>{let s=m(e);return"active"===s||"success"===s}).length,b=c.filter(e=>{let s=m(e);return"error"===s||"expired"===s||"unavailable"===s}).length,p=c.length,u=p>0&&c.every(e=>!1===e.isActive);return(0,r.jsx)(i(),{href:`/dashboard/media-providers/${s}/${e.id}`,className:"group",children:(0,r.jsx)(o.Zp,{padding:"xs",className:`h-full hover:bg-black/[0.01] dark:hover:bg-white/[0.01] transition-colors cursor-pointer ${u?"opacity-50":""}`,children:(0,r.jsxs)("div",{className:"flex items-center gap-3",children:[(0,r.jsx)("div",{className:"size-8 rounded-lg flex items-center justify-center shrink-0",style:{backgroundColor:`${e.color?.length>7?e.color:(e.color??"#888")+"15"}`},children:(0,r.jsx)(n.A,{src:`/providers/${e.id}.png`,alt:e.name,size:30,className:"object-contain rounded-lg max-w-[30px] max-h-[30px]",fallbackText:e.textIcon||e.id.slice(0,2).toUpperCase(),fallbackColor:e.color})}),(0,r.jsxs)("div",{children:[(0,r.jsx)("h3",{className:"font-semibold text-sm",children:e.name}),(0,r.jsx)("div",{className:"flex items-center gap-2 mt-0.5 flex-wrap",children:l?(0,r.jsx)(o.Ex,{variant:"success",size:"sm",children:"Ready"}):u?(0,r.jsx)(o.Ex,{variant:"default",size:"sm",children:"Disabled"}):0===p?(0,r.jsx)("span",{className:"text-xs text-text-muted",children:"No connections"}):(0,r.jsxs)(r.Fragment,{children:[h>0&&(0,r.jsxs)(o.Ex,{variant:"success",size:"sm",dot:!0,children:[h," Connected"]}),b>0&&(0,r.jsxs)(o.Ex,{variant:"error",size:"sm",dot:!0,children:[b," Error"]}),0===h&&0===b&&(0,r.jsxs)(o.Ex,{variant:"default",size:"sm",children:[p," Added"]})]})})]})]})})})}function h({combos:e}){return 0===e.length?(0,r.jsx)("p",{className:"text-xs text-text-muted italic",children:"No combos yet."}):(0,r.jsx)("div",{className:"flex flex-col gap-2",children:e.map(e=>(0,r.jsx)(i(),{href:`/dashboard/media-providers/web/combo/${e.id}`,children:(0,r.jsx)(o.Zp,{padding:"xs",className:"hover:bg-black/[0.02] dark:hover:bg-white/[0.02] transition-colors cursor-pointer",children:(0,r.jsxs)("div",{className:"flex items-center gap-3",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-primary text-[18px]",children:"layers"}),(0,r.jsx)("code",{className:"text-sm font-mono font-medium flex-1 truncate",children:e.name}),(0,r.jsxs)("div",{className:"flex items-center gap-1 shrink-0",children:[e.models.slice(0,6).map((e,s)=>{let t=d.Q2[e];return(0,r.jsx)("div",{title:t?.name||e,className:"size-5 rounded flex items-center justify-center",style:{backgroundColor:`${t?.color??"#888"}15`},children:(0,r.jsx)(n.A,{src:`/providers/${e}.png`,alt:t?.name||e,size:18,className:"object-contain rounded max-w-[18px] max-h-[18px]",fallbackText:t?.textIcon||e.slice(0,2).toUpperCase(),fallbackColor:t?.color})},`${e}-${s}`)}),e.models.length>6&&(0,r.jsxs)("span",{className:"text-[10px] text-text-muted ml-1",children:["+",e.models.length-6]})]}),(0,r.jsx)("span",{className:"text-[11px] text-text-muted shrink-0",children:e.models.length}),(0,r.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[16px]",children:"chevron_right"})]})})},e.id))})}function b({title:e,icon:s,kind:t,providers:a,connections:i,combos:l,onCreateCombo:c}){return(0,r.jsxs)("div",{children:[(0,r.jsxs)("div",{className:"flex items-center justify-between mb-3",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-primary",children:s}),(0,r.jsx)("h2",{className:"text-base font-semibold",children:e}),(0,r.jsxs)("span",{className:"text-xs text-text-muted",children:["(",a.length," providers \xb7 ",l.length," combos)"]})]}),(0,r.jsx)(o.$n,{size:"sm",icon:"add",onClick:c,children:"Create Combo"})]}),l.length>0&&(0,r.jsx)("div",{className:"mb-4",children:(0,r.jsx)(h,{combos:l})}),0===a.length?(0,r.jsx)("div",{className:"text-center py-8 border border-dashed border-border rounded-xl text-text-muted text-sm",children:"No providers."}):(0,r.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4",children:a.map(e=>(0,r.jsx)(x,{provider:e,kind:t,connections:i},e.id))})]})}function p(){let e=(0,c.useRouter)(),[s,t]=(0,l.useState)([]),[a,i]=(0,l.useState)([]),o=async()=>{try{let[e,s]=await Promise.all([fetch("/api/providers",{cache:"no-store"}),fetch("/api/combos",{cache:"no-store"})]);e.ok&&t((await e.json()).connections||[]),s.ok&&i((await s.json()).combos||[])}catch{}};(0,l.useEffect)(()=>{o()},[]);let n=(0,d.o5)("webSearch"),m=(0,d.o5)("webFetch"),x=a.filter(e=>"webSearch"===e.kind),h=a.filter(e=>"webFetch"===e.kind),p=async s=>{let t="webSearch"===s?"search-combo":"fetch-combo",r=t,i=1,l=new Set(a.map(e=>e.name));for(;l.has(r);)r=`${t}-${i++}`;let c=await fetch("/api/combos",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:r,models:[],kind:s})});if(c.ok){let s=await c.json();e.push(`/dashboard/media-providers/web/combo/${s.id}`)}else alert((await c.json()).error||"Failed to create combo")};return(0,r.jsxs)("div",{className:"flex flex-col gap-8",children:[(0,r.jsx)(b,{title:"Web Search",icon:"search",kind:"webSearch",providers:n,connections:s,combos:x,onCreateCombo:()=>p("webSearch")}),(0,r.jsx)("div",{className:"border-t border-border"}),(0,r.jsx)(b,{title:"Web Fetch",icon:"travel_explore",kind:"webFetch",providers:m,connections:s,combos:h,onCreateCombo:()=>p("webFetch")})]})}}},e=>{e.O(0,[7848,4335,6795,505,4156,2347,5158,7358],()=>e(e.s=51181)),_N_E=e.O()}]);
@@ -1 +0,0 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[6607],{71103:(e,t,s)=>{"use strict";s.d(t,{default:()=>d});var a=s(73365),i=s(1521),n=s(97990),l=s(69633),c=s(82495),o=s(7127);function d(){let[e,t]=(0,i.useState)([]),[s,d]=(0,i.useState)([]),[r,u]=(0,i.useState)({}),[h,x]=(0,i.useState)(!1),[p,f]=(0,i.useState)(null),[m,w]=(0,i.useState)({running:!1,certExists:!1,dnsStatus:{},hasCachedPassword:!1});(0,i.useEffect)(()=>{g(),v(),S(),j()},[]);let g=async()=>{try{let e=await fetch("/api/providers");if(e.ok){let s=await e.json();t(s.connections||[])}}catch{}},v=async()=>{try{let e=await fetch("/api/keys");if(e.ok){let t=await e.json();d(t.keys||[])}}catch{}},S=async()=>{try{let e=await fetch("/api/models/alias");if(e.ok){let t=await e.json();u(t.aliases||{})}}catch{}},j=async()=>{try{let e=await fetch("/api/settings");if(e.ok){let t=await e.json();x(t.cloudEnabled||!1)}}catch{}},y=()=>e.filter(e=>!1!==e.isActive),k=Object.entries(n.wn);return(0,a.jsxs)("div",{className:"mx-auto flex w-full max-w-5xl flex-col gap-6 px-1 sm:px-0",children:[(0,a.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,a.jsx)("h1",{className:"text-xl font-semibold text-text-main sm:text-2xl",children:"MITM"}),(0,a.jsx)("p",{className:"text-sm text-text-muted",children:"Route supported IDE traffic through 9Router with local DNS interception."})]}),(0,a.jsx)(o.tA,{apiKeys:s,cloudEnabled:h,onStatusChange:w}),(0,a.jsx)("div",{className:"grid gap-3 sm:gap-4",children:k.map(([e,t])=>(0,a.jsx)(o.kn,{tool:t,isExpanded:p===e,onToggle:()=>f(p===e?null:e),serverRunning:m.running,dnsActive:m.dnsStatus?.[e]||!1,hasCachedPassword:m.hasCachedPassword||!1,apiKeys:s,activeProviders:y(),hasActiveProviders:y().some(e=>(0,l.KC)(e.provider).length>0||(0,c.mq)(e.provider)||(0,c.gb)(e.provider)),modelAliases:r,cloudEnabled:h,onDnsChange:e=>w(t=>({...t,dnsStatus:e.dnsStatus??t.dnsStatus}))},e))})]})}},85999:(e,t,s)=>{Promise.resolve().then(s.bind(s,71103))}},e=>{e.O(0,[7848,4335,6795,8872,505,4156,4380,2347,5158,7358],()=>e(e.s=85999)),_N_E=e.O()}]);
@@ -1,2 +0,0 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[6812],{26491:(e,t,r)=>{Promise.resolve().then(r.bind(r,85148))},85148:(e,t,r)=>{"use strict";r.r(t),r.d(t,{default:()=>n});var s=r(73365),l=r(1521),o=r(74156),a=r(14793);function i(e={}){return{name:e.name||"",proxyUrl:e.proxyUrl||"",noProxy:e.noProxy||"",isActive:!1!==e.isActive,strictProxy:!0===e.strictProxy}}function n(){let[e,t]=(0,l.useState)([]),[r,n]=(0,l.useState)(!0),[c,d]=(0,l.useState)(!1),[x,p]=(0,l.useState)(!1),[m,h]=(0,l.useState)(!1),[u,y]=(0,l.useState)(null),[f,v]=(0,l.useState)(i()),[g,j]=(0,l.useState)(""),[b,N]=(0,l.useState)({vercelToken:"",projectName:"vercel-relay"}),[w,k]=(0,l.useState)(!1),[P,C]=(0,l.useState)(!1),[$,S]=(0,l.useState)(!1),[E,U]=(0,l.useState)(null),T=(0,a.i)(),A=(0,l.useCallback)(async()=>{try{let e=await fetch("/api/proxy-pools?includeUsage=true",{cache:"no-store"}),r=await e.json();e.ok&&t(r.proxyPools||[])}catch(e){console.log("Error fetching proxy pools:",e)}finally{n(!1)}},[]);(0,l.useEffect)(()=>{A()},[A]);let I=()=>{y(null),v(i())},O=()=>{I(),d(!0)},D=()=>{d(!1),I()},F=async()=>{let e={name:f.name.trim(),proxyUrl:f.proxyUrl.trim(),noProxy:f.noProxy.trim(),isActive:!0===f.isActive,strictProxy:!0===f.strictProxy};if(e.name&&e.proxyUrl){k(!0);try{let t=!!u,r=await fetch(t?`/api/proxy-pools/${u.id}`:"/api/proxy-pools",{method:t?"PUT":"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(r.ok)await A(),D(),T.success(u?"Proxy pool updated":"Proxy pool created");else{let e=await r.json();T.error(e.error||"Failed to save proxy pool")}}catch(e){console.log("Error saving proxy pool:",e)}finally{k(!1)}}},V=async e=>{if(confirm(`Delete proxy pool "${e.name}"?`))try{let r=await fetch(`/api/proxy-pools/${e.id}`,{method:"DELETE"});if(r.ok){t(t=>t.filter(t=>t.id!==e.id)),T.success("Proxy pool deleted");return}let s=await r.json();409===r.status?T.warning(`Cannot delete: ${s.boundConnectionCount||0} connection(s) are still using this pool.`):T.error(s.error||"Failed to delete proxy pool")}catch(e){console.log("Error deleting proxy pool:",e),T.error("Failed to delete proxy pool")}},L=async e=>{U(e);try{let t=await fetch(`/api/proxy-pools/${e}/test`,{method:"POST"}),r=await t.json();if(!t.ok)return void T.error(r.error||"Failed to test proxy");await A(),T.success(r.ok?"Proxy test passed":"Proxy test failed")}catch(e){console.log("Error testing proxy pool:",e),T.error("Failed to test proxy")}finally{U(null)}},_=()=>{P||p(!1)},R=()=>{$||h(!1)},W=async()=>{if(b.vercelToken.trim()){S(!0);try{let e=await fetch("/api/proxy-pools/vercel-deploy",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(b)}),t=await e.json();e.ok?(await A(),R(),T.success(`Deployed: ${t.deployUrl}`)):T.error(t.error||"Deploy failed")}catch(e){console.log("Error deploying Vercel relay:",e),T.error("Deploy failed")}finally{S(!1)}}},B=async()=>{let t=g.split(/\r?\n/).map(e=>e.trim()).filter(Boolean);if(0===t.length)return void T.warning("Please paste at least one proxy line.");let r=[],s=[];if(t.forEach((e,t)=>{try{let s=(e=>{let t=e.trim();if(!t)return null;if(t.includes("://")){let e=new URL(t),r=e.port?`${e.hostname}:${e.port}`:e.hostname;return{proxyUrl:e.toString(),name:`Imported ${r}`}}let r=t.split(":");if(4===r.length){let[e,t,s,l]=r;if(!e||!t||!s||!l)throw Error("Invalid host:port:user:pass format");return{proxyUrl:new URL(`http://${encodeURIComponent(s)}:${encodeURIComponent(l)}@${e}:${t}`).toString(),name:`Imported ${e}:${t}`}}throw Error("Unsupported format")})(e);s&&r.push({...s,lineNumber:t+1})}catch(e){s.push(`Line ${t+1}: ${e.message}`)}}),s.length>0)return void T.error(`Invalid proxy format:
2
- ${s.join("\n")}`);C(!0);try{let t=new Set(e.map(e=>`${(e.proxyUrl||"").trim()}|||${(e.noProxy||"").trim()}`)),s=0,l=0,o=0;for(let e of r){let r=`${e.proxyUrl}|||`;if(t.has(r)){l+=1;continue}(await fetch("/api/proxy-pools",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:e.name,proxyUrl:e.proxyUrl,noProxy:"",isActive:!0})})).ok?(s+=1,t.add(r)):o+=1}await A(),p(!1),T.success(`Batch import completed: Created ${s}, Skipped ${l}, Failed ${o}`)}catch(e){console.log("Error batch importing proxies:",e),T.error("Batch import failed")}finally{C(!1)}},z=(0,l.useMemo)(()=>e.filter(e=>!0===e.isActive).length,[e]);return r?(0,s.jsxs)("div",{className:"mx-auto flex w-full max-w-5xl flex-col gap-4 px-1 sm:gap-6 sm:px-0",children:[(0,s.jsx)(o.Qv,{}),(0,s.jsx)(o.Qv,{})]}):(0,s.jsxs)("div",{className:"mx-auto flex w-full max-w-5xl flex-col gap-4 px-1 sm:gap-6 sm:px-0",children:[(0,s.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsx)("h1",{className:"text-xl font-semibold sm:text-2xl",children:"Proxy Pools"}),(0,s.jsx)("p",{className:"text-sm text-text-muted mt-1",children:"Manage reusable per-connection proxies and bind them to provider connections."})]}),(0,s.jsxs)("div",{className:"grid grid-cols-1 gap-2 sm:flex sm:items-center",children:[(0,s.jsx)(o.$n,{variant:"secondary",icon:"cloud_upload",onClick:()=>{N({vercelToken:"",projectName:"vercel-relay"}),h(!0)},children:"Vercel Relay"}),(0,s.jsx)(o.$n,{variant:"secondary",icon:"upload",onClick:()=>{j(""),p(!0)},children:"Batch Import"}),(0,s.jsx)(o.$n,{icon:"add",onClick:O,children:"Add Proxy Pool"})]})]}),(0,s.jsxs)(o.Zp,{children:[(0,s.jsx)("div",{className:"mb-4 flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between",children:(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,s.jsxs)(o.Ex,{variant:"default",children:["Total: ",e.length]}),(0,s.jsxs)(o.Ex,{variant:"success",children:["Active: ",z]})]})}),0===e.length?(0,s.jsxs)("div",{className:"text-center py-10",children:[(0,s.jsx)("p",{className:"text-text-main font-medium mb-1",children:"No proxy pool entries yet"}),(0,s.jsx)("p",{className:"text-sm text-text-muted mb-4",children:"Create a proxy pool entry, then assign it to connections."}),(0,s.jsx)(o.$n,{icon:"add",onClick:O,children:"Add Proxy Pool"})]}):(0,s.jsx)("div",{className:"flex flex-col divide-y divide-black/[0.04] dark:divide-white/[0.05]",children:e.map(e=>{var t;return(0,s.jsxs)("div",{className:"group flex flex-col gap-3 py-3 sm:flex-row sm:items-center sm:justify-between",children:[(0,s.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[(0,s.jsx)("p",{className:"min-w-0 max-w-full truncate text-sm font-medium sm:max-w-[18rem]",children:e.name}),(0,s.jsx)(o.Ex,{variant:"active"===(t=e.testStatus)?"success":"error"===t?"error":"default",size:"sm",dot:!0,children:e.testStatus||"unknown"}),(0,s.jsx)(o.Ex,{variant:e.isActive?"success":"default",size:"sm",children:e.isActive?"active":"inactive"}),"vercel"===e.type&&(0,s.jsx)(o.Ex,{variant:"default",size:"sm",children:"vercel relay"}),(0,s.jsxs)(o.Ex,{variant:"default",size:"sm",children:[e.boundConnectionCount||0," bound"]})]}),(0,s.jsx)("p",{className:"text-xs text-text-muted truncate mt-1",children:e.proxyUrl}),e.noProxy?(0,s.jsxs)("p",{className:"text-xs text-text-muted truncate",children:["No proxy: ",e.noProxy]}):null,(0,s.jsxs)("p",{className:"text-[11px] text-text-muted mt-1",children:["Last tested: ",function(e){if(!e)return"Never";let t=new Date(e);return Number.isNaN(t.getTime())?"Never":t.toLocaleString()}(e.lastTestedAt),e.lastError?` \xb7 ${e.lastError}`:""]})]}),(0,s.jsxs)("div",{className:"flex items-center justify-end gap-1 opacity-100 transition-opacity sm:opacity-0 sm:group-hover:opacity-100",children:[(0,s.jsx)("button",{onClick:()=>L(e.id),className:"p-2 rounded hover:bg-black/5 dark:hover:bg-white/5 text-text-muted hover:text-primary",title:"Test proxy",disabled:E===e.id,children:(0,s.jsx)("span",{className:"material-symbols-outlined text-[18px]",style:E===e.id?{animation:"spin 1s linear infinite"}:void 0,children:E===e.id?"progress_activity":"science"})}),(0,s.jsx)("button",{onClick:()=>{y(e),v(i(e)),d(!0)},className:"p-2 rounded hover:bg-black/5 dark:hover:bg-white/5 text-text-muted hover:text-primary",title:"Edit",children:(0,s.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"edit"})}),(0,s.jsx)("button",{onClick:()=>V(e),className:"p-2 rounded hover:bg-red-500/10 text-red-500",title:"Delete",children:(0,s.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"delete"})})]})]},e.id)})})]}),(0,s.jsx)(o.aF,{isOpen:x,title:"Batch Import Proxies",onClose:_,children:(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"text-sm font-medium text-text-main mb-1 block",children:"Paste Proxy List (One per line)"}),(0,s.jsx)("textarea",{value:g,onChange:e=>j(e.target.value),placeholder:"http://user:pass@127.0.0.1:7897\n127.0.0.1:7897:user:pass",className:"w-full min-h-[180px] py-2 px-3 text-sm text-text-main bg-white dark:bg-white/5 border border-black/10 dark:border-white/10 rounded-md focus:ring-1 focus:ring-primary/30 focus:border-primary/50 focus:outline-none transition-all"}),(0,s.jsx)("p",{className:"text-xs text-text-muted mt-1",children:"Supported formats: protocol://user:pass@host:port, host:port:user:pass"})]}),(0,s.jsxs)("div",{className:"grid grid-cols-1 gap-2 sm:grid-cols-2",children:[(0,s.jsx)(o.$n,{fullWidth:!0,onClick:B,disabled:!g.trim()||P,children:P?"Importing...":"Import"}),(0,s.jsx)(o.$n,{fullWidth:!0,variant:"ghost",onClick:_,disabled:P,children:"Cancel"})]})]})}),(0,s.jsx)(o.aF,{isOpen:m,title:"Deploy Vercel Relay",onClose:R,children:(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,s.jsxs)("div",{className:"rounded-lg bg-blue-500/5 border border-blue-500/10 p-3 flex flex-col gap-1.5",children:[(0,s.jsx)("p",{className:"text-sm text-text-main font-medium",children:"What is Vercel Relay?"}),(0,s.jsx)("p",{className:"text-xs text-text-muted",children:"Deploys an edge relay function to Vercel. All AI provider requests will be forwarded through Vercel's edge network, masking your real IP from providers."}),(0,s.jsxs)("ul",{className:"text-xs text-text-muted list-disc pl-4 space-y-0.5",children:[(0,s.jsx)("li",{children:"Your IP is replaced by Vercel's dynamic edge IPs (hundreds of IPs across 20+ global regions)"}),(0,s.jsx)("li",{children:"Vercel serves millions of apps — providers can't block Vercel IPs without affecting legitimate traffic"}),(0,s.jsx)("li",{children:"Free tier: 100GB bandwidth/month, 500K edge invocations"}),(0,s.jsx)("li",{children:"Deploy multiple relays on different accounts for more IP diversity"})]})]}),(0,s.jsx)(o.pd,{label:"Vercel API Token",value:b.vercelToken,onChange:e=>N(t=>({...t,vercelToken:e.target.value})),placeholder:"your-vercel-api-token",hint:(0,s.jsxs)(s.Fragment,{children:["Token is used once for deployment and not stored. ",(0,s.jsx)("a",{href:"https://vercel.com/account/tokens",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"Get token →"})]}),type:"password"}),(0,s.jsx)(o.pd,{label:"Project Name",value:b.projectName,onChange:e=>N(t=>({...t,projectName:e.target.value})),placeholder:"my-relay",hint:"Unique name for your Vercel project. Leave empty for auto-generated name."}),(0,s.jsxs)("div",{className:"grid grid-cols-1 gap-2 sm:grid-cols-2",children:[(0,s.jsx)(o.$n,{fullWidth:!0,onClick:W,disabled:!b.vercelToken.trim()||$,children:$?"Deploying... (may take ~1 min)":"Deploy"}),(0,s.jsx)(o.$n,{fullWidth:!0,variant:"ghost",onClick:R,disabled:$,children:"Cancel"})]})]})}),(0,s.jsx)(o.aF,{isOpen:c,title:u?"Edit Proxy Pool":"Add Proxy Pool",onClose:D,children:(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,s.jsx)(o.pd,{label:"Name",value:f.name,onChange:e=>v(t=>({...t,name:e.target.value})),placeholder:"Office Proxy"}),(0,s.jsx)(o.pd,{label:"Proxy URL",value:f.proxyUrl,onChange:e=>v(t=>({...t,proxyUrl:e.target.value})),placeholder:"http://127.0.0.1:7897"}),(0,s.jsx)(o.pd,{label:"No Proxy",value:f.noProxy,onChange:e=>v(t=>({...t,noProxy:e.target.value})),placeholder:"localhost,127.0.0.1,.internal",hint:"Comma-separated hosts/domains to bypass proxy"}),(0,s.jsxs)("div",{className:"flex flex-col gap-3 rounded-lg border border-border/50 p-3 sm:flex-row sm:items-center sm:justify-between",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"font-medium text-sm",children:"Active"}),(0,s.jsx)("p",{className:"text-xs text-text-muted",children:"Inactive pools are ignored by runtime resolution."})]}),(0,s.jsx)(o.lM,{checked:!0===f.isActive,onChange:()=>v(e=>({...e,isActive:!e.isActive})),disabled:w})]}),(0,s.jsxs)("div",{className:"flex flex-col gap-3 rounded-lg border border-border/50 p-3 sm:flex-row sm:items-center sm:justify-between",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"font-medium text-sm",children:"Strict Proxy"}),(0,s.jsx)("p",{className:"text-xs text-text-muted",children:"Fail request if proxy is unreachable instead of falling back to direct."})]}),(0,s.jsx)(o.lM,{checked:!0===f.strictProxy,onChange:()=>v(e=>({...e,strictProxy:!e.strictProxy})),disabled:w})]}),(0,s.jsxs)("div",{className:"grid grid-cols-1 gap-2 sm:grid-cols-2",children:[(0,s.jsx)(o.$n,{fullWidth:!0,onClick:F,disabled:!f.name.trim()||!f.proxyUrl.trim()||w,children:w?"Saving...":"Save"}),(0,s.jsx)(o.$n,{fullWidth:!0,variant:"ghost",onClick:D,disabled:w,children:"Cancel"})]})]})})]})}}},e=>{e.O(0,[7848,4335,6795,505,4156,2347,5158,7358],()=>e(e.s=26491)),_N_E=e.O()}]);
@@ -1 +0,0 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[3826],{58944:(e,t,r)=>{Promise.resolve().then(r.bind(r,59295)),Promise.resolve().then(r.bind(r,91494))},59295:(e,t,r)=>{"use strict";r.d(t,{default:()=>h});var a=r(73365),s=r(1521),l=r(68266),n=r(94718);function i(e,t){return t&&0!==t?!e||e<0?100:e>=t?0:Math.round((t-e)/t*100):0}function o({quotas:e=[],compact:t=!1}){if(!e||0===e.length)return null;let r=t?"py-1.5 px-2":"py-2 px-3",s=t?"text-xs":"text-sm",l=t?"text-xs":"text-sm",n=t?"text-[10px] leading-tight":"text-xs";return(0,a.jsx)("div",{className:"overflow-x-auto",children:(0,a.jsx)("table",{className:"w-full table-fixed text-left",children:(0,a.jsx)("tbody",{children:e.map((e,o)=>{let c=void 0!==e.remainingPercentage?Math.round(e.remainingPercentage):i(e.used,e.total),d=c>70?{text:"text-green-600 dark:text-green-400",bg:"bg-green-500",bgLight:"bg-green-500/10",emoji:"\uD83D\uDFE2"}:c>=30?{text:"text-yellow-600 dark:text-yellow-400",bg:"bg-yellow-500",bgLight:"bg-yellow-500/10",emoji:"\uD83D\uDFE1"}:{text:"text-red-600 dark:text-red-400",bg:"bg-red-500",bgLight:"bg-red-500/10",emoji:"\uD83D\uDD34"},u=function(e){if(!e)return"-";try{let t="string"==typeof e?new Date(e):e,r=new Date,a=t-r;if(a<=0)return"-";let s=Math.ceil(a/6e4);if(s<60)return`${s}m`;let l=Math.floor(s/60),n=s%60;if(l<24)return`${l}h ${n}m`;let i=Math.floor(l/24);return`${i}d ${l%24}h ${n}m`}catch(e){return"-"}}(e.resetAt),m=function(e){if(!e)return null;try{let t=new Date(e),r=new Date,a=new Date(r.getFullYear(),r.getMonth(),r.getDate()),s=new Date(a);s.setDate(s.getDate()+1);let l="";l=t>=a&&t<s?"Today":t>=s&&t<new Date(s.getTime()+864e5)?"Tomorrow":t.toLocaleDateString("en-US",{month:"short",day:"numeric"});let n=t.toLocaleTimeString("en-US",{hour:"numeric",minute:"2-digit",hour12:!0});return`${l}, ${n}`}catch{return null}}(e.resetAt);return(0,a.jsxs)("tr",{className:"border-b border-black/5 dark:border-white/5 hover:bg-black/[0.02] dark:hover:bg-white/[0.02] transition-colors",children:[(0,a.jsx)("td",{className:`${r} w-[30%]`,children:(0,a.jsxs)("div",{className:"flex items-center gap-1.5 min-w-0",children:[(0,a.jsx)("span",{className:"text-[10px] shrink-0",children:d.emoji}),(0,a.jsx)("span",{className:`${s} font-medium text-text-primary truncate`,children:e.name})]})}),(0,a.jsx)("td",{className:`${r} w-[45%]`,children:(0,a.jsxs)("div",{className:t?"space-y-1":"space-y-1.5",children:[(0,a.jsx)("div",{className:`${t?"h-1":"h-1.5"} rounded-full overflow-hidden border ${d.bgLight} ${0===c?"border-black/10 dark:border-white/10":"border-transparent"}`,children:(0,a.jsx)("div",{className:`h-full transition-all duration-300 ${d.bg}`,style:{width:`${Math.min(c,100)}%`}})}),(0,a.jsxs)("div",{className:`flex items-center justify-between ${t?"text-[10px]":"text-xs"}`,children:[(0,a.jsxs)("span",{className:"text-text-muted",children:[e.used.toLocaleString()," / ",e.total>0?e.total.toLocaleString():"∞"]}),(0,a.jsxs)("span",{className:`font-medium ${d.text}`,children:[c,"%"]})]})]})}),(0,a.jsx)("td",{className:`${r} w-[25%]`,children:"-"!==u||m?(0,a.jsxs)("div",{className:"space-y-0.5",children:["-"!==u&&(0,a.jsxs)("div",{className:`${l} text-text-primary font-medium`,children:["in ",u]}),m&&(0,a.jsx)("div",{className:`${n} text-text-muted`,children:m})]}):(0,a.jsx)("div",{className:`${l} text-text-muted italic`,children:"N/A"})})]},o)})})})})}var c=r(14406),d=r(292),u=r(38230),m=r(74156),x=r(82495);function h(){let[e,t]=(0,s.useState)([]),[r,h]=(0,s.useState)({}),[p,b]=(0,s.useState)({}),[f,g]=(0,s.useState)({}),[v,y]=(0,s.useState)(!0),[j,w]=(0,s.useState)(null),[N,k]=(0,s.useState)(!1),[$,C]=(0,s.useState)(60),[A,E]=(0,s.useState)(!0),[S,q]=(0,s.useState)(null),[P,D]=(0,s.useState)(null),[L,T]=(0,s.useState)(!1),[O,z]=(0,s.useState)(null),[I,M]=(0,s.useState)([]),[_,F]=(0,s.useState)("all"),[U,R]=(0,s.useState)(!1),[K,J]=(0,s.useState)(!1),G=(0,s.useRef)(null),H=(0,s.useRef)(null),Y=(0,s.useCallback)(async()=>{try{let e=await fetch("/api/providers/client");if(!e.ok)throw Error("Failed to fetch connections");let r=(await e.json()).connections||[];return t(r),r}catch(e){return console.error("Error fetching connections:",e),t([]),[]}},[]),B=(0,s.useCallback)(async(e,t)=>{b(t=>({...t,[e]:!0})),g(t=>({...t,[e]:null}));try{console.log(`[ProviderLimits] Fetching quota for ${t} (${e})`);let r=await fetch(`/api/usage/${e}`);if(!r.ok){let a=(await r.json().catch(()=>({}))).error||r.statusText;if(404===r.status)return void console.warn(`[ProviderLimits] Connection not found for ${t}, skipping`);if(401===r.status){console.warn(`[ProviderLimits] Auth error for ${t}:`,a),h(t=>({...t,[e]:{quotas:[],message:a}}));return}throw Error(`HTTP ${r.status}: ${a}`)}let a=await r.json();console.log(`[ProviderLimits] Got quota for ${t}:`,a);let s=function(e,t){if(!t||"object"!=typeof t)return[];let r=[];try{switch(e.toLowerCase()){case"github":default:t.quotas&&Object.entries(t.quotas).forEach(([e,t])=>{r.push({name:e,used:t.used||0,total:t.total||0,resetAt:t.resetAt||null})});break;case"antigravity":t.quotas&&Object.entries(t.quotas).forEach(([e,t])=>{r.push({name:t.displayName||e,modelKey:e,used:t.used||0,total:t.total||0,resetAt:t.resetAt||null,remainingPercentage:t.remainingPercentage})});break;case"codex":t.quotas&&Object.entries(t.quotas).forEach(([e,t])=>{r.push({name:e,used:t.used||0,total:t.total||0,resetAt:t.resetAt||null})});break;case"kiro":t.quotas&&Object.entries(t.quotas).forEach(([e,t])=>{r.push({name:e,used:t.used||0,total:t.total||0,resetAt:t.resetAt||null})});break;case"claude":t.message?r.push({name:"error",used:0,total:0,resetAt:null,message:t.message}):t.quotas&&Object.entries(t.quotas).forEach(([e,t])=>{r.push({name:e,used:t.used||0,total:t.total||0,resetAt:t.resetAt||null})})}}catch(t){return console.error(`Error parsing quota data for ${e}:`,t),[]}let a=(0,n.KC)(e);if(a.length>0){let e=new Map(a.map((e,t)=>[e.id,t]));r.sort((t,r)=>{let a=t.modelKey||t.name,s=r.modelKey||r.name;return(e.get(a)??999)-(e.get(s)??999)})}return r}(t,a);h(t=>({...t,[e]:{quotas:s,plan:a.plan||null,message:a.message||null,raw:a}}))}catch(r){console.error(`[ProviderLimits] Error fetching quota for ${t} (${e}):`,r),g(t=>({...t,[e]:r.message||"Failed to fetch quota"}))}finally{b(t=>({...t,[e]:!1}))}},[]),Q=(0,s.useCallback)(async(e,t)=>{await B(e,t),w(new Date)},[B]),V=(0,s.useCallback)(async e=>{if(confirm("Delete this connection?")){q(e);try{(await fetch(`/api/providers/${e}`,{method:"DELETE"})).ok&&(t(t=>t.filter(t=>t.id!==e)),h(t=>{let r={...t};return delete r[e],r}),b(t=>{let r={...t};return delete r[e],r}),g(t=>{let r={...t};return delete r[e],r}))}catch(e){console.error("Error deleting connection:",e)}finally{q(null)}}},[]),W=(0,s.useCallback)(async(e,r)=>{D(e);try{(await fetch(`/api/providers/${e}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({isActive:r})})).ok&&t(t=>t.map(t=>t.id===e?{...t,isActive:r}:t))}catch(e){console.error("Error updating connection status:",e)}finally{D(null)}},[]),X=(0,s.useCallback)(async e=>{if(!O?.id)return;let t=O.id,r=O.provider;try{(await fetch(`/api/providers/${t}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})).ok&&(await Y(),T(!1),z(null),x.wb.includes(r)&&await B(t,r))}catch(e){console.error("Error saving connection:",e)}},[O,Y,B]);(0,s.useEffect)(()=>{let e=!1;return fetch("/api/proxy-pools?isActive=true",{cache:"no-store"}).then(e=>e.json()).then(t=>{!e&&t?.proxyPools&&M(t.proxyPools)}).catch(()=>{}),()=>{e=!0}},[]);let Z=(0,s.useCallback)(async()=>{if(!N){k(!0),C(60);try{let e=(await Y()).filter(e=>x.wb.includes(e.provider)&&"oauth"===e.authType);await Promise.all(e.map(e=>B(e.id,e.provider))),w(new Date)}catch(e){console.error("Error refreshing all providers:",e)}finally{k(!1)}}},[N,Y,B]);(0,s.useEffect)(()=>{(async()=>{E(!0);let e=await Y();E(!1);let t=e.filter(e=>x.wb.includes(e.provider)&&"oauth"===e.authType),r={};t.forEach(e=>{r[e.id]=!0}),b(r),await Promise.all(t.map(e=>B(e.id,e.provider))),w(new Date)})()},[]),(0,s.useEffect)(()=>{if(!v){G.current&&(clearInterval(G.current),G.current=null),H.current&&(clearInterval(H.current),H.current=null);return}return G.current=setInterval(()=>{Z()},6e4),H.current=setInterval(()=>{C(e=>e<=1?60:e-1)},1e3),()=>{G.current&&clearInterval(G.current),H.current&&clearInterval(H.current)}},[v,Z]),(0,s.useEffect)(()=>{let e=()=>{document.hidden?(G.current&&(clearInterval(G.current),G.current=null),H.current&&(clearInterval(H.current),H.current=null)):v&&(G.current=setInterval(Z,6e4),H.current=setInterval(()=>{C(e=>e<=1?60:e-1)},1e3))};return document.addEventListener("visibilitychange",e),()=>{document.removeEventListener("visibilitychange",e)}},[v,Z]);let ee=(0,s.useCallback)(()=>{if(!j)return"Never";let e=Math.floor((new Date-j)/6e4),t=Math.floor(e/60),r=Math.floor(t/24);return r>0?`${r}d ago`:t>0?`${t}h ago`:e>0?`${e}m ago`:"Just now"},[j]),et=e.filter(e=>x.wb.includes(e.provider)&&"oauth"===e.authType),er=et.filter(e=>"all"===_||e.provider===_),ea=e=>{let t=(r[e.id]?.quotas||[]).map(e=>e.resetAt?new Date(e.resetAt).getTime():1/0).filter(e=>Number.isFinite(e));return t.length>0?Math.min(...t):1/0},es=[...er].sort((e,t)=>{if(U){let r=ea(e)-ea(t);if(0!==r)return r}let r=x.wb.indexOf(e.provider),a=x.wb.indexOf(t.provider);return r!==a?r-a:e.provider.localeCompare(t.provider)}),el=Array.from(new Set(et.map(e=>e.provider))).sort(),en="all"===_?"All providers":_;return(es.length,Object.values(r).filter(e=>e?.quotas?.length>0).length,Object.values(r).reduce((e,t)=>t?.quotas?e+ +!!t.quotas.some(e=>30>i(e.used,e.total)&&e.total>0):e,0),A||0!==es.length)?(0,a.jsxs)("div",{className:"space-y-6",children:[(0,a.jsxs)("div",{className:"flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between",children:[(0,a.jsxs)("div",{className:"flex flex-col gap-1 sm:flex-row sm:items-center sm:gap-3",children:[(0,a.jsx)("h2",{className:"text-xl font-semibold text-text-primary",children:"Provider Limits"}),(0,a.jsxs)("span",{className:"text-sm text-text-muted",children:["Last updated: ",ee()]})]}),(0,a.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,a.jsxs)("div",{className:"relative",children:[(0,a.jsxs)("button",{type:"button",onClick:()=>J(e=>!e),className:"flex h-10 min-w-[116px] items-center justify-between gap-2 rounded-xl border border-black/10 bg-black/[0.02] px-3 text-sm text-text-primary transition-colors hover:bg-black/5 dark:border-white/10 dark:bg-white/[0.03] dark:hover:bg-white/10 sm:min-w-[180px]","aria-haspopup":"menu","aria-expanded":K,title:"Filter quota providers",children:[(0,a.jsxs)("span",{className:"flex min-w-0 items-center gap-2",children:["all"===_?(0,a.jsx)("span",{className:"material-symbols-outlined text-[20px] text-text-muted",children:"apps"}):(0,a.jsx)(l.A,{src:`/providers/${_}.png`,alt:_,size:22,className:"size-[22px] rounded-md object-contain",fallbackText:_.slice(0,2).toUpperCase()}),(0,a.jsx)("span",{className:"truncate capitalize hidden sm:inline",children:en})]}),(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px] text-text-muted",children:"expand_more"})]}),K&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("button",{type:"button",className:"fixed inset-0 z-30 bg-transparent","aria-label":"Close provider filter",onClick:()=>J(!1)}),(0,a.jsxs)("div",{className:"absolute left-0 z-40 mt-2 w-64 overflow-hidden rounded-2xl border border-black/10 bg-surface/95 p-1.5 shadow-xl shadow-black/10 backdrop-blur dark:border-white/10 dark:bg-surface/95 sm:w-72",children:[(0,a.jsxs)("button",{type:"button",onClick:()=>{F("all"),J(!1)},className:`flex w-full items-center gap-3 rounded-xl px-3 py-2.5 text-left text-sm transition-colors ${"all"===_?"bg-primary/10 text-primary":"text-text-primary hover:bg-black/5 dark:hover:bg-white/10"}`,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[22px]",children:"apps"}),(0,a.jsx)("span",{className:"font-medium",children:"All providers"}),"all"===_&&(0,a.jsx)("span",{className:"material-symbols-outlined ml-auto text-[20px]",children:"check"})]}),(0,a.jsx)("div",{className:"my-1 h-px bg-black/10 dark:bg-white/10"}),(0,a.jsx)("div",{className:"max-h-72 overflow-y-auto pr-1",children:el.map(e=>(0,a.jsxs)("button",{type:"button",onClick:()=>{F(e),J(!1)},className:`flex w-full items-center gap-3 rounded-xl px-3 py-2.5 text-left text-sm transition-colors ${_===e?"bg-primary/10 text-primary":"text-text-primary hover:bg-black/5 dark:hover:bg-white/10"}`,children:[(0,a.jsx)(l.A,{src:`/providers/${e}.png`,alt:e,size:24,className:"size-6 rounded-md object-contain",fallbackText:e.slice(0,2).toUpperCase()}),(0,a.jsx)("span",{className:"font-medium capitalize",children:e}),_===e&&(0,a.jsx)("span",{className:"material-symbols-outlined ml-auto text-[20px]",children:"check"})]},e))})]})]})]}),(0,a.jsxs)("button",{type:"button",onClick:()=>R(e=>!e),className:`flex shrink-0 items-center gap-1.5 rounded-lg border px-3 py-2 text-sm transition-colors ${U?"border-amber-500/40 bg-amber-500/10 text-amber-500":"border-black/10 text-text-primary hover:bg-black/5 dark:border-white/10 dark:hover:bg-white/5"}`,title:"Sort accounts by earliest quota reset time",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"hourglass_top"}),(0,a.jsx)("span",{className:"hidden sm:inline",children:"Expiring first"})]}),(0,a.jsxs)("button",{onClick:()=>y(e=>!e),className:"flex shrink-0 items-center gap-2 rounded-lg border border-black/10 px-3 py-2 transition-colors hover:bg-black/5 dark:border-white/10 dark:hover:bg-white/5",title:v?"Disable auto-refresh":"Enable auto-refresh",children:[(0,a.jsx)("span",{className:`material-symbols-outlined text-[18px] ${v?"text-primary":"text-text-muted"}`,children:v?"toggle_on":"toggle_off"}),(0,a.jsx)("span",{className:"hidden text-sm text-text-primary sm:inline",children:"Auto-refresh"}),v&&(0,a.jsxs)("span",{className:"text-xs text-text-muted",children:["(",$,"s)"]})]}),(0,a.jsx)(u.default,{variant:"secondary",size:"md",icon:"refresh",onClick:Z,disabled:N,loading:N,children:"Refresh All"})]})]}),(0,a.jsx)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:es.map(e=>{let t,s,n=r[e.id],i=p[e.id],u=f[e.id],m=!1===e.isActive,x=S===e.id||P===e.id;return(0,a.jsxs)(d.default,{padding:"none",className:`min-w-0 ${m?"opacity-60":""}`,children:[(0,a.jsx)("div",{className:"px-4 py-3 border-b border-black/10 dark:border-white/10",children:(0,a.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,a.jsx)("div",{className:"w-8 h-8 shrink-0 rounded-md flex items-center justify-center overflow-hidden",children:(0,a.jsx)(l.A,{src:`/providers/${e.provider}.png`,alt:e.provider,size:32,className:"object-contain",fallbackText:e.provider?.slice(0,2).toUpperCase()||"PR"})}),(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsx)("h3",{className:"text-sm font-semibold text-text-primary capitalize truncate",children:e.provider}),(s=(t=e=>"string"==typeof e&&/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e))(e.email)?e.email:(t(e.name),e.name))?(0,a.jsx)("p",{className:"text-xs text-text-muted truncate",children:s}):null]})]}),(0,a.jsxs)("div",{className:"flex items-center gap-1 shrink-0",children:[(0,a.jsx)("button",{type:"button",onClick:()=>Q(e.id,e.provider),disabled:i||x,className:"p-1.5 rounded-lg hover:bg-black/5 dark:hover:bg-white/5 transition-colors disabled:opacity-50",title:"Refresh quota",children:(0,a.jsx)("span",{className:`material-symbols-outlined text-[18px] text-text-muted ${i?"animate-spin":""}`,children:"refresh"})}),(0,a.jsx)("button",{type:"button",onClick:()=>{z(e),T(!0)},disabled:x,className:"p-1.5 rounded-lg hover:bg-black/5 dark:hover:bg-white/5 text-text-muted hover:text-primary transition-colors disabled:opacity-50",title:"Edit connection",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"edit"})}),(0,a.jsx)("button",{type:"button",onClick:()=>V(e.id),disabled:x,className:"p-1.5 rounded-lg hover:bg-red-500/10 text-red-500 transition-colors disabled:opacity-50",title:"Delete connection",children:(0,a.jsx)("span",{className:`material-symbols-outlined text-[18px] ${S===e.id?"animate-pulse":""}`,children:"delete"})}),(0,a.jsx)("div",{className:"inline-flex items-center pl-0.5",title:e.isActive??!0?"Disable connection":"Enable connection",children:(0,a.jsx)(c.default,{size:"sm",checked:e.isActive??!0,disabled:x,onChange:t=>W(e.id,t)})})]})]})}),(0,a.jsx)("div",{className:"px-3 py-3",children:i?(0,a.jsx)("div",{className:"text-center py-5 text-text-muted",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[28px] animate-spin",children:"progress_activity"})}):u?(0,a.jsxs)("div",{className:"text-center py-5",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[28px] text-red-500",children:"error"}),(0,a.jsx)("p",{className:"mt-1.5 text-xs text-text-muted",children:u})]}):n?.message?(0,a.jsx)("div",{className:"text-center py-5",children:(0,a.jsx)("p",{className:"text-xs text-text-muted",children:n.message})}):(0,a.jsx)(o,{quotas:n?.quotas,compact:!0})})]},e.id)})}),(0,a.jsx)(m.wI,{isOpen:L,connection:O,proxyPools:I,onSave:X,onClose:()=>{T(!1),z(null)}})]}):(0,a.jsx)(d.default,{padding:"lg",children:(0,a.jsxs)("div",{className:"text-center py-12",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[64px] text-text-muted opacity-20",children:"cloud_off"}),(0,a.jsx)("h3",{className:"mt-4 text-lg font-semibold text-text-primary",children:"No Providers Connected"}),(0,a.jsx)("p",{className:"mt-2 text-sm text-text-muted max-w-md mx-auto",children:"Connect to providers with OAuth to track your API quota limits and usage."})]})})}}},e=>{e.O(0,[7848,4335,6795,505,4156,2347,5158,7358],()=>e(e.s=58944)),_N_E=e.O()}]);
@@ -1 +0,0 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[2825],{33154:(e,t,s)=>{Promise.resolve().then(s.bind(s,83101))},83101:(e,t,s)=>{"use strict";s.r(t),s.d(t,{default:()=>v});var a=s(73365),l=s(1521),n=s(29717),r=s(74156),i=s(292),d=s(38230),o=s(87706);function c({isOpen:e,onClose:t,title:s,children:n,width:r="md",className:i}){let d={sm:"w-[400px]",md:"w-[500px]",lg:"w-[600px]",xl:"w-[800px]",full:"w-full"};return((0,l.useEffect)(()=>(e?document.body.style.overflow="hidden":document.body.style.overflow="",()=>{document.body.style.overflow=""}),[e]),(0,l.useEffect)(()=>{let s=s=>{"Escape"===s.key&&e&&t()};return document.addEventListener("keydown",s),()=>document.removeEventListener("keydown",s)},[e,t]),e)?(0,a.jsxs)("div",{className:"fixed inset-0 z-50",children:[(0,a.jsx)("div",{className:"absolute inset-0 bg-black/50 backdrop-blur-sm transition-opacity cursor-pointer",onClick:t,"aria-hidden":"true"}),(0,a.jsxs)("div",{className:(0,o.cn)("absolute right-0 top-0 h-full bg-surface shadow-2xl flex flex-col","animate-in slide-in-from-right duration-200","border-l border-black/10 dark:border-white/10",d[r]||d.md,i),children:[(0,a.jsxs)("div",{className:"flex items-center justify-between p-6 border-b border-black/5 dark:border-white/5 flex-shrink-0",children:[(0,a.jsx)("div",{className:"flex items-center gap-3",children:s&&(0,a.jsx)("h2",{className:"text-lg font-semibold text-text-main",children:s})}),(0,a.jsx)("button",{type:"button",onClick:t,className:"p-1.5 rounded-lg text-text-muted hover:bg-black/5 dark:hover:bg-white/5 transition-colors",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[20px]",children:"close"})})]}),(0,a.jsx)("div",{className:"flex-1 overflow-y-auto p-6",children:n})]})]}):null}function x({currentPage:e,pageSize:t,totalItems:s,onPageChange:l,onPageSizeChange:n,className:r}){let i=Math.ceil(s/t),c=s>0?(e-1)*t+1:0,m=Math.min(e*t,s),h=(()=>{let t=[],s=Math.max(1,e-2),a=Math.min(i,s+5-1);a-s+1<5&&(s=Math.max(1,a-5+1));for(let e=s;e<=a;e++)t.push(e);return t})();return(0,a.jsxs)("div",{className:(0,o.cn)("flex flex-col sm:flex-row items-center justify-between gap-4 py-4",r),children:[s>0&&(0,a.jsxs)("div",{className:"text-sm text-text-muted",children:["Showing ",(0,a.jsx)("span",{className:"font-medium text-text-main",children:c})," to"," ",(0,a.jsx)("span",{className:"font-medium text-text-main",children:m})," of"," ",(0,a.jsx)("span",{className:"font-medium text-text-main",children:s})," results"]}),(0,a.jsxs)("div",{className:"flex items-center gap-4",children:[n&&(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"text-sm text-text-muted",children:"Rows:"}),(0,a.jsx)("select",{value:t,onChange:e=>n(Number(e.target.value)),className:(0,o.cn)("h-9 rounded-lg border border-black/10 dark:border-white/10 bg-surface","text-sm text-text-main focus:outline-none focus:ring-2 focus:ring-primary/20","cursor-pointer"),children:[10,20,50].map(e=>(0,a.jsx)("option",{value:e,children:e},e))})]}),i>1&&(0,a.jsxs)("div",{className:"flex items-center gap-1",children:[(0,a.jsx)(d.default,{variant:"outline",size:"sm",onClick:()=>l(e-1),disabled:1===e,className:"w-9 px-0",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"chevron_left"})}),h[0]>1&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(d.default,{variant:"ghost",size:"sm",onClick:()=>l(1),className:"w-9 px-0",children:"1"}),h[0]>2&&(0,a.jsx)("span",{className:"text-text-muted px-1",children:"..."})]}),h.map(t=>(0,a.jsx)(d.default,{variant:e===t?"primary":"ghost",size:"sm",onClick:()=>l(t),className:"w-9 px-0",children:t},t)),h[h.length-1]<i&&(0,a.jsxs)(a.Fragment,{children:[h[h.length-1]<i-1&&(0,a.jsx)("span",{className:"text-text-muted px-1",children:"..."}),(0,a.jsx)(d.default,{variant:"ghost",size:"sm",onClick:()=>l(i),className:"w-9 px-0",children:i})]}),(0,a.jsx)(d.default,{variant:"outline",size:"sm",onClick:()=>l(e+1),disabled:e===i,className:"w-9 px-0",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"chevron_right"})})]})]})]})}var m=s(82495);let h=null,p=null;async function u(){if(h&&p)return{providerNameCache:h,providerNodesCache:p};let e=await fetch("/api/provider-nodes"),t=(await e.json()).nodes||[];for(let e of(p={},t))p[e.id]=e.name;return{providerNameCache:h={...m.Q2,...p},providerNodesCache:p}}function f(e,t){if(!e||!t)return e;let s=t[e];if("string"==typeof s)return s;if(s?.name)return s.name;let a=(0,m.zt)(e)||m.Q2[e];return a?.name||e}function b({title:e,children:t,defaultOpen:s=!1,icon:n=null}){let[r,i]=(0,l.useState)(s);return(0,a.jsxs)("div",{className:"border border-black/5 dark:border-white/5 rounded-lg overflow-hidden",children:[(0,a.jsxs)("button",{type:"button",onClick:()=>i(!r),className:"w-full flex items-center justify-between p-3 bg-black/[0.02] dark:bg-white/[0.02] hover:bg-black/[0.04] dark:hover:bg-white/[0.04] transition-colors",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[n&&(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px] text-text-muted",children:n}),(0,a.jsx)("span",{className:"font-semibold text-sm text-text-main",children:e})]}),(0,a.jsx)("span",{className:(0,o.cn)("material-symbols-outlined text-[20px] text-text-muted transition-transform duration-200",r?"rotate-90":""),children:"chevron_right"})]}),r&&(0,a.jsx)("div",{className:"p-4 border-t border-black/5 dark:border-white/5",children:t})]})}function g(e){let t=e?.prompt_tokens||e?.input_tokens||0,s=e?.cached_tokens||e?.cache_read_input_tokens||0;return t<s?s:t}function j(){let[e,t]=(0,l.useState)([]),[s,n]=(0,l.useState)({page:1,pageSize:20,totalItems:0,totalPages:0}),[r,m]=(0,l.useState)(!1),[h,p]=(0,l.useState)(null),[j,v]=(0,l.useState)(!1),[N,w]=(0,l.useState)([]),[k,y]=(0,l.useState)(null),[S,C]=(0,l.useState)({provider:"",startDate:"",endDate:""}),D=(0,l.useCallback)(async()=>{try{let e=await fetch("/api/usage/providers"),t=await e.json();w(t.providers||[]);let s=await u();y(s.providerNameCache)}catch(e){console.error("Failed to fetch providers:",e)}},[]),_=(0,l.useCallback)(async()=>{m(!0);try{let e=new URLSearchParams({page:s.page.toString(),pageSize:s.pageSize.toString()});S.provider&&e.append("provider",S.provider),S.startDate&&e.append("startDate",S.startDate),S.endDate&&e.append("endDate",S.endDate);let a=await fetch(`/api/usage/request-details?${e}`),l=await a.json();t(l.details||[]),n(e=>({...e,...l.pagination}))}catch(e){console.error("Failed to fetch request details:",e)}finally{m(!1)}},[s.page,s.pageSize,S]);return(0,l.useEffect)(()=>{D()},[D]),(0,l.useEffect)(()=>{_()},[_]),(0,a.jsxs)("div",{className:"flex min-w-0 flex-col gap-6",children:[(0,a.jsx)(i.default,{padding:"md",children:(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-4",children:[(0,a.jsxs)("div",{className:"flex min-w-0 flex-col gap-2",children:[(0,a.jsx)("label",{htmlFor:"provider-filter",className:"text-sm font-medium text-text-main",children:"Provider"}),(0,a.jsxs)("select",{id:"provider-filter",value:S.provider,onChange:e=>C({...S,provider:e.target.value}),className:(0,o.cn)("h-9 px-3 rounded-lg border border-black/10 dark:border-white/10 bg-surface","text-sm text-text-main focus:outline-none focus:ring-2 focus:ring-primary/20","w-full min-w-0 cursor-pointer"),children:[(0,a.jsx)("option",{value:"",children:"All Providers"}),N.map(e=>(0,a.jsx)("option",{value:e.id,children:e.name},e.id))]})]}),(0,a.jsxs)("div",{className:"flex min-w-0 flex-col gap-2",children:[(0,a.jsx)("label",{htmlFor:"start-date-filter",className:"text-sm font-medium text-text-main",children:"Start Date"}),(0,a.jsx)("input",{id:"start-date-filter",type:"datetime-local",value:S.startDate,onChange:e=>C({...S,startDate:e.target.value}),className:(0,o.cn)("h-9 px-3 rounded-lg border border-black/10 dark:border-white/10 bg-surface","w-full min-w-0 text-sm text-text-main focus:outline-none focus:ring-2 focus:ring-primary/20")})]}),(0,a.jsxs)("div",{className:"flex min-w-0 flex-col gap-2",children:[(0,a.jsx)("label",{htmlFor:"end-date-filter",className:"text-sm font-medium text-text-main",children:"End Date"}),(0,a.jsx)("input",{id:"end-date-filter",type:"datetime-local",value:S.endDate,onChange:e=>C({...S,endDate:e.target.value}),className:(0,o.cn)("h-9 px-3 rounded-lg border border-black/10 dark:border-white/10 bg-surface","w-full min-w-0 text-sm text-text-main focus:outline-none focus:ring-2 focus:ring-primary/20")})]}),(0,a.jsxs)("div",{className:"flex min-w-0 flex-col gap-2 sm:col-span-2 lg:col-span-1",children:[(0,a.jsx)("span",{className:"hidden text-sm font-medium text-text-main opacity-0 lg:block","aria-hidden":"true",children:"Clear"}),(0,a.jsx)(d.default,{variant:"ghost",onClick:()=>{C({provider:"",startDate:"",endDate:""})},disabled:!S.provider&&!S.startDate&&!S.endDate,className:"w-full",children:"Clear Filters"})]})]})}),(0,a.jsxs)(i.default,{padding:"none",children:[(0,a.jsx)("div",{className:"overflow-x-auto",children:(0,a.jsxs)("table",{className:"w-full min-w-[880px]",children:[(0,a.jsx)("thead",{children:(0,a.jsxs)("tr",{className:"border-b border-black/5 dark:border-white/5",children:[(0,a.jsx)("th",{className:"text-left p-4 text-sm font-semibold text-text-main",children:"Timestamp"}),(0,a.jsx)("th",{className:"text-left p-4 text-sm font-semibold text-text-main",children:"Model"}),(0,a.jsx)("th",{className:"text-left p-4 text-sm font-semibold text-text-main",children:"Provider"}),(0,a.jsx)("th",{className:"text-right p-4 text-sm font-semibold text-text-main",children:"Input Tokens"}),(0,a.jsx)("th",{className:"text-right p-4 text-sm font-semibold text-text-main",children:"Output Tokens"}),(0,a.jsx)("th",{className:"text-left p-4 text-sm font-semibold text-text-main",children:"Latency"}),(0,a.jsx)("th",{className:"text-center p-4 text-sm font-semibold text-text-main",children:"Action"})]})}),(0,a.jsx)("tbody",{children:r?(0,a.jsx)("tr",{children:(0,a.jsx)("td",{colSpan:"7",className:"p-8 text-center text-text-muted",children:(0,a.jsxs)("div",{className:"flex items-center justify-center gap-2",children:[(0,a.jsx)("span",{className:"material-symbols-outlined animate-spin text-[20px]",children:"progress_activity"}),"Loading..."]})})}):0===e.length?(0,a.jsx)("tr",{children:(0,a.jsx)("td",{colSpan:"7",className:"p-8 text-center text-text-muted",children:"No request details found"})}):e.map((e,t)=>(0,a.jsxs)("tr",{className:"border-b border-black/5 dark:border-white/5 last:border-b-0 hover:bg-black/[0.02] dark:hover:bg-white/[0.02] transition-colors",children:[(0,a.jsx)("td",{className:"whitespace-nowrap p-4 text-sm text-text-main",children:new Date(e.timestamp).toLocaleString()}),(0,a.jsx)("td",{className:"max-w-[260px] truncate p-4 font-mono text-sm text-text-main",children:e.model}),(0,a.jsx)("td",{className:"max-w-[180px] truncate p-4 text-sm text-text-main",children:(0,a.jsx)("span",{className:"font-medium",children:f(e.provider,k)})}),(0,a.jsx)("td",{className:"p-4 text-sm text-text-main text-right font-mono",children:g(e.tokens).toLocaleString()}),(0,a.jsx)("td",{className:"p-4 text-sm text-text-main text-right font-mono",children:e.tokens?.completion_tokens?.toLocaleString()||0}),(0,a.jsx)("td",{className:"p-4 text-sm text-text-muted",children:(0,a.jsxs)("div",{className:"flex flex-col gap-0.5",children:[(0,a.jsxs)("div",{children:["TTFT: ",(0,a.jsxs)("span",{className:"font-mono",children:[e.latency?.ttft||0,"ms"]})]}),(0,a.jsxs)("div",{children:["Total: ",(0,a.jsxs)("span",{className:"font-mono",children:[e.latency?.total||0,"ms"]})]})]})}),(0,a.jsx)("td",{className:"p-4 text-center",children:(0,a.jsx)(d.default,{variant:"outline",size:"sm",onClick:()=>{p(e),v(!0)},children:"Detail"})})]},`${e.id}-${t}`))})]})}),!r&&e.length>0&&(0,a.jsx)("div",{className:"border-t border-black/5 dark:border-white/5",children:(0,a.jsx)(x,{currentPage:s.page,pageSize:s.pageSize,totalItems:s.totalItems,onPageChange:e=>{n(t=>({...t,page:e}))},onPageSizeChange:e=>{n(t=>({...t,pageSize:e,page:1}))}})})]}),(0,a.jsx)(c,{isOpen:j,onClose:()=>v(!1),title:"Request Details",width:"lg",children:h&&(0,a.jsxs)("div",{className:"space-y-6",children:[(0,a.jsxs)("div",{className:"grid min-w-0 grid-cols-1 gap-4 text-sm sm:grid-cols-2",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("span",{className:"text-text-muted",children:"ID:"})," ",(0,a.jsx)("span",{className:"break-all font-mono text-text-main",children:h.id})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("span",{className:"text-text-muted",children:"Timestamp:"})," ",(0,a.jsx)("span",{className:"text-text-main",children:new Date(h.timestamp).toLocaleString()})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("span",{className:"text-text-muted",children:"Provider:"})," ",(0,a.jsx)("span",{className:"text-text-main font-medium",children:f(h.provider,k)})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("span",{className:"text-text-muted",children:"Model:"})," ",(0,a.jsx)("span",{className:"text-text-main font-mono",children:h.model})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("span",{className:"text-text-muted",children:"Status:"})," ",(0,a.jsx)("span",{className:(0,o.cn)("font-medium","success"===h.status?"text-green-600":"text-red-600"),children:h.status})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("span",{className:"text-text-muted",children:"Latency:"})," ",(0,a.jsxs)("span",{className:"text-text-main font-mono",children:["TTFT ",h.latency?.ttft||0,"ms / Total ",h.latency?.total||0,"ms"]})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("span",{className:"text-text-muted",children:"Input Tokens:"})," ",(0,a.jsx)("span",{className:"text-text-main font-mono",children:g(h.tokens).toLocaleString()})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("span",{className:"text-text-muted",children:"Output Tokens:"})," ",(0,a.jsx)("span",{className:"text-text-main font-mono",children:h.tokens?.completion_tokens?.toLocaleString()||0})]})]}),(0,a.jsxs)("div",{className:"space-y-4",children:[(0,a.jsx)(b,{title:"1. Client Request (Input)",defaultOpen:!0,icon:"input",children:(0,a.jsx)("pre",{className:"max-h-[300px] max-w-full overflow-auto rounded-lg border border-black/5 bg-black/5 p-3 font-mono text-xs text-text-main dark:border-white/5 dark:bg-white/5 sm:p-4",children:JSON.stringify(h.request,null,2)})}),h.providerRequest&&(0,a.jsx)(b,{title:"2. Provider Request (Translated)",icon:"translate",children:(0,a.jsx)("pre",{className:"max-h-[300px] max-w-full overflow-auto rounded-lg border border-black/5 bg-black/5 p-3 font-mono text-xs text-text-main dark:border-white/5 dark:bg-white/5 sm:p-4",children:JSON.stringify(h.providerRequest,null,2)})}),h.providerResponse&&(0,a.jsx)(b,{title:"3. Provider Response (Raw)",icon:"data_object",children:(0,a.jsx)("pre",{className:"max-h-[300px] max-w-full overflow-auto rounded-lg border border-black/5 bg-black/5 p-3 font-mono text-xs text-text-main dark:border-white/5 dark:bg-white/5 sm:p-4",children:"object"==typeof h.providerResponse?JSON.stringify(h.providerResponse,null,2):h.providerResponse})}),(0,a.jsxs)(b,{title:"4. Client Response (Final)",defaultOpen:!0,icon:"output",children:[h.response?.thinking&&(0,a.jsxs)("div",{className:"mb-4",children:[(0,a.jsxs)("h4",{className:"font-semibold text-text-main mb-2 flex items-center gap-2 text-xs uppercase tracking-wide opacity-70",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"psychology"}),"Thinking Process"]}),(0,a.jsx)("pre",{className:"max-h-[200px] max-w-full overflow-auto rounded-lg border border-amber-200 bg-amber-50 p-3 font-mono text-xs text-amber-900 dark:border-amber-800 dark:bg-amber-950/30 dark:text-amber-100 sm:p-4",children:h.response.thinking})]}),(0,a.jsx)("h4",{className:"font-semibold text-text-main mb-2 text-xs uppercase tracking-wide opacity-70",children:"Content"}),(0,a.jsx)("pre",{className:"max-h-[300px] max-w-full overflow-auto rounded-lg border border-black/5 bg-black/5 p-3 font-mono text-xs text-text-main dark:border-white/5 dark:bg-white/5 sm:p-4",children:h.response?.content||"[No content]"})]})]})]})})]})}function v(){return(0,a.jsx)(l.Suspense,{fallback:(0,a.jsx)(r.Qv,{}),children:(0,a.jsx)(N,{})})}function N(){let e=(0,n.useSearchParams)(),t=(0,n.useRouter)(),[s,i]=(0,l.useState)(!1),d=e.get("tab"),o=d&&["overview","logs","details"].includes(d)?d:"overview";return(0,a.jsxs)("div",{className:"flex min-w-0 flex-col gap-6 px-1 sm:px-0",children:[(0,a.jsx)(r.Iz,{options:[{value:"overview",label:"Overview"},{value:"details",label:"Details"}],value:o,onChange:s=>{if(s===o)return;i(!0);let a=new URLSearchParams(e);a.set("tab",s),t.push(`/dashboard/usage?${a.toString()}`,{scroll:!1}),setTimeout(()=>i(!1),300)},className:"w-full sm:w-auto"}),s?(0,a.jsx)(r.Qv,{}):(0,a.jsxs)(a.Fragment,{children:["overview"===o&&(0,a.jsx)(l.Suspense,{fallback:(0,a.jsx)(r.Qv,{}),children:(0,a.jsx)(r.jK,{})}),"logs"===o&&(0,a.jsx)(r.gM,{}),"details"===o&&(0,a.jsx)(j,{})]})]})}}},e=>{e.O(0,[7848,4335,6795,505,4156,2347,5158,7358],()=>e(e.s=33154)),_N_E=e.O()}]);