@fudrouter/fsrouter 0.6.72 → 0.6.74

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 (314) hide show
  1. package/dist/lib/headroom/detect.js +97 -7
  2. package/dist/lib/headroom/process.js +136 -4
  3. package/dist/open-sse/config/appConstants.js +23 -79
  4. package/dist/open-sse/config/cliFingerprints.js +1 -1
  5. package/dist/open-sse/config/errorConfig.js +0 -11
  6. package/dist/open-sse/config/grokCli.js +10 -0
  7. package/dist/open-sse/config/kiroConstants.js +99 -46
  8. package/dist/open-sse/config/runtimeConfig.js +2 -0
  9. package/dist/open-sse/config/ttsModels.js +2 -0
  10. package/dist/open-sse/executors/antigravity.js +250 -164
  11. package/dist/open-sse/executors/base.js +16 -11
  12. package/dist/open-sse/executors/codex.js +269 -1108
  13. package/dist/open-sse/executors/commandCode.js +1 -1
  14. package/dist/open-sse/executors/commandcode.js +10 -4
  15. package/dist/open-sse/executors/cursor.js +96 -203
  16. package/dist/open-sse/executors/default.js +146 -244
  17. package/dist/open-sse/executors/github.js +128 -73
  18. package/dist/open-sse/executors/grok-cli.js +527 -94
  19. package/dist/open-sse/executors/grok-web.js +5 -7
  20. package/dist/open-sse/executors/index.js +12 -0
  21. package/dist/open-sse/executors/kiro.js +150 -61
  22. package/dist/open-sse/executors/opencode-go.js +12 -4
  23. package/dist/open-sse/executors/opencode.js +1 -1
  24. package/dist/open-sse/executors/perplexity-web.js +20 -96
  25. package/dist/open-sse/executors/qoder.js +28 -18
  26. package/dist/open-sse/executors/vertex.js +53 -7
  27. package/dist/open-sse/executors/xiaomi-tokenplan.js +6 -5
  28. package/dist/open-sse/handlers/chatCore/nonStreamingHandler.js +97 -85
  29. package/dist/open-sse/handlers/chatCore/requestDetail.js +32 -8
  30. package/dist/open-sse/handlers/chatCore/sseToJsonHandler.js +13 -7
  31. package/dist/open-sse/handlers/chatCore/streamingHandler.js +74 -25
  32. package/dist/open-sse/handlers/chatCore.js +35 -41
  33. package/dist/open-sse/handlers/embeddingProviders/index.js +1 -0
  34. package/dist/open-sse/handlers/embeddingProviders/openai.js +8 -16
  35. package/dist/open-sse/handlers/imageProviders/blackForestLabs.js +2 -21
  36. package/dist/open-sse/handlers/imageProviders/cloudflareAi.js +2 -30
  37. package/dist/open-sse/handlers/imageProviders/codex.js +2 -20
  38. package/dist/open-sse/handlers/imageProviders/comfyui.js +5 -18
  39. package/dist/open-sse/handlers/imageProviders/falAi.js +2 -22
  40. package/dist/open-sse/handlers/imageProviders/gemini.js +2 -16
  41. package/dist/open-sse/handlers/imageProviders/huggingface.js +2 -17
  42. package/dist/open-sse/handlers/imageProviders/index.js +3 -4
  43. package/dist/open-sse/handlers/imageProviders/leonardo.js +1 -1
  44. package/dist/open-sse/handlers/imageProviders/nanobanana.js +4 -23
  45. package/dist/open-sse/handlers/imageProviders/openai.js +15 -43
  46. package/dist/open-sse/handlers/imageProviders/runwayml.js +2 -26
  47. package/dist/open-sse/handlers/imageProviders/sdwebui.js +4 -20
  48. package/dist/open-sse/handlers/imageProviders/stabilityAi.js +2 -26
  49. package/dist/open-sse/handlers/imageProviders/weavy.js +1 -1
  50. package/dist/open-sse/handlers/search/chatSearch.js +60 -14
  51. package/dist/open-sse/handlers/ttsProviders/gemini.js +14 -3
  52. package/dist/open-sse/handlers/ttsProviders/index.js +4 -2
  53. package/dist/open-sse/handlers/ttsProviders/openai.js +4 -1
  54. package/dist/open-sse/handlers/ttsProviders/openrouter.js +7 -4
  55. package/dist/open-sse/handlers/videoCore.js +166 -0
  56. package/dist/open-sse/handlers/videoProviders/weavy.js +1 -1
  57. package/dist/open-sse/mcp-server/catalog.js +1 -1
  58. package/dist/open-sse/mcp-server/server.js +2 -2
  59. package/dist/open-sse/mcp-server/tools/advancedTools.js +2 -2
  60. package/dist/open-sse/mcp-server/tools/agentSkillTools.js +1 -1
  61. package/dist/open-sse/mcp-server/tools/compressionTools.js +4 -4
  62. package/dist/open-sse/mcp-server/tools/gamificationTools.js +10 -10
  63. package/dist/open-sse/mcp-server/tools/githubSkillTools.js +1 -1
  64. package/dist/open-sse/mcp-server/tools/memoryTools.js +3 -3
  65. package/dist/open-sse/mcp-server/tools/notionTools.js +2 -2
  66. package/dist/open-sse/mcp-server/tools/obsidianTools.js +2 -2
  67. package/dist/open-sse/mcp-server/tools/pickFastestModel.js +1 -1
  68. package/dist/open-sse/mcp-server/tools/pluginTools.js +4 -4
  69. package/dist/open-sse/mcp-server/tools/skillTools.js +2 -2
  70. package/dist/open-sse/providers/capabilities.js +24 -4
  71. package/dist/open-sse/providers/registry/alicode-intl.js +1 -1
  72. package/dist/open-sse/providers/registry/anthropic.js +1 -8
  73. package/dist/open-sse/providers/registry/codex.js +0 -9
  74. package/dist/open-sse/providers/registry/cohere.js +0 -2
  75. package/dist/open-sse/providers/registry/gemini.js +0 -2
  76. package/dist/open-sse/providers/registry/github.js +9 -6
  77. package/dist/open-sse/providers/registry/grok-cli.js +28 -18
  78. package/dist/open-sse/providers/registry/index.js +74 -80
  79. package/dist/open-sse/providers/registry/kiro.js +12 -0
  80. package/dist/open-sse/providers/registry/mistral.js +0 -3
  81. package/dist/open-sse/providers/registry/openai.js +0 -3
  82. package/dist/open-sse/providers/registry/perplexity.js +0 -2
  83. package/dist/open-sse/providers/registry/xai.js +5 -3
  84. package/dist/open-sse/rtk/autodetect.js +10 -2
  85. package/dist/open-sse/rtk/caveman.js +2 -93
  86. package/dist/open-sse/rtk/cavemanPrompts.js +34 -2
  87. package/dist/open-sse/rtk/constants.js +7 -2
  88. package/dist/open-sse/rtk/headroom.js +133 -0
  89. package/dist/open-sse/rtk/ponytail.js +1 -1
  90. package/dist/open-sse/rtk/registry.js +2 -0
  91. package/dist/open-sse/services/accountFallback.js +0 -108
  92. package/dist/open-sse/services/combo/quotaExhaustionCutoff.js +2 -2
  93. package/dist/open-sse/services/combo/quotaShareStrategy.js +1 -1
  94. package/dist/open-sse/services/combo/resolveAutoStrategy.js +1 -1
  95. package/dist/open-sse/services/combo/sessionStickiness.js +1 -1
  96. package/dist/open-sse/services/combo/targetSorters.js +2 -2
  97. package/dist/open-sse/services/combo/validateQuality.js +1 -1
  98. package/dist/open-sse/services/comboConfig.js +1 -1
  99. package/dist/open-sse/services/emergencyFallback.js +1 -1
  100. package/dist/open-sse/services/grokCliModels.js +127 -0
  101. package/dist/open-sse/services/model.js +7 -1
  102. package/dist/open-sse/services/provider.js +1 -1
  103. package/dist/open-sse/services/proxyAutoSelector.js +1 -1
  104. package/dist/open-sse/services/tokenRefresh/providers.js +3 -3
  105. package/dist/open-sse/services/usage/codex.js +148 -214
  106. package/dist/open-sse/services/usage/grok-cli.js +61 -7
  107. package/dist/open-sse/services/usage/misc.js +0 -19
  108. package/dist/open-sse/services/usage.js +0 -2
  109. package/dist/open-sse/translator/concerns/paramSupport.js +2 -2
  110. package/dist/open-sse/translator/concerns/thinkingUnified.js +6 -0
  111. package/dist/open-sse/translator/index.js +97 -59
  112. package/dist/open-sse/translator/request/claude-to-kiro.js +67 -40
  113. package/dist/open-sse/translator/request/openai-responses.js +1 -0
  114. package/dist/open-sse/translator/request/openai-to-commandcode.js +0 -4
  115. package/dist/open-sse/translator/request/openai-to-kiro.js +49 -20
  116. package/dist/open-sse/translator/response/commandcode-to-openai.js +0 -4
  117. package/dist/open-sse/utils/bypassHandler.js +18 -3
  118. package/dist/open-sse/utils/claudeCloaking.js +15 -5
  119. package/dist/open-sse/utils/cursorImages.js +1 -1
  120. package/dist/open-sse/utils/error.js +0 -17
  121. package/dist/open-sse/utils/keepaliveThreshold.js +4 -4
  122. package/dist/open-sse/utils/kiroSessionReplay.js +125 -0
  123. package/dist/open-sse/utils/noThinkingAlias.js +1 -1
  124. package/dist/open-sse/utils/proxyFetch.js +0 -1
  125. package/dist/open-sse/utils/reasoningContentInjector.js +4 -7
  126. package/dist/open-sse/utils/responsesStatePolicy.js +1 -1
  127. package/dist/open-sse/utils/responsesStreamHelpers.js +1 -0
  128. package/dist/open-sse/utils/sessionManager.js +49 -22
  129. package/dist/open-sse/utils/stream.js +54 -77
  130. package/dist/open-sse/utils/streamHandler.js +19 -15
  131. package/dist/open-sse/utils/streamHelpers.js +2 -17
  132. package/dist/open-sse/utils/usageTracking.js +103 -12
  133. package/dist/routes/headroom/extras/route.js +58 -0
  134. package/dist/routes/headroom/restart/route.js +33 -0
  135. package/open-sse/config/appConstants.js +23 -79
  136. package/open-sse/config/errorConfig.js +0 -11
  137. package/open-sse/config/grokCli.js +10 -0
  138. package/open-sse/config/kiroConstants.js +99 -46
  139. package/open-sse/config/runtimeConfig.js +2 -0
  140. package/open-sse/config/ttsModels.js +2 -0
  141. package/open-sse/executors/antigravity.js +250 -164
  142. package/open-sse/executors/base.js +16 -11
  143. package/open-sse/executors/codex.js +269 -1108
  144. package/open-sse/executors/commandcode.js +10 -4
  145. package/open-sse/executors/cursor.js +96 -203
  146. package/open-sse/executors/default.js +146 -244
  147. package/open-sse/executors/github.js +128 -73
  148. package/open-sse/executors/grok-cli.js +527 -94
  149. package/open-sse/executors/grok-web.js +5 -7
  150. package/open-sse/executors/index.js +12 -0
  151. package/open-sse/executors/kiro.js +150 -61
  152. package/open-sse/executors/opencode-go.js +12 -4
  153. package/open-sse/executors/opencode.js +1 -1
  154. package/open-sse/executors/perplexity-web.js +20 -96
  155. package/open-sse/executors/qoder.js +28 -18
  156. package/open-sse/executors/vertex.js +53 -7
  157. package/open-sse/executors/xiaomi-tokenplan.js +6 -5
  158. package/open-sse/handlers/chatCore/nonStreamingHandler.js +97 -85
  159. package/open-sse/handlers/chatCore/requestDetail.js +32 -8
  160. package/open-sse/handlers/chatCore/sseToJsonHandler.js +13 -7
  161. package/open-sse/handlers/chatCore/streamingHandler.js +74 -25
  162. package/open-sse/handlers/chatCore.js +35 -41
  163. package/open-sse/handlers/embeddingProviders/index.js +1 -0
  164. package/open-sse/handlers/embeddingProviders/openai.js +8 -16
  165. package/open-sse/handlers/imageProviders/blackForestLabs.js +2 -21
  166. package/open-sse/handlers/imageProviders/cloudflareAi.js +2 -30
  167. package/open-sse/handlers/imageProviders/codex.js +2 -20
  168. package/open-sse/handlers/imageProviders/comfyui.js +5 -18
  169. package/open-sse/handlers/imageProviders/falAi.js +2 -22
  170. package/open-sse/handlers/imageProviders/gemini.js +2 -16
  171. package/open-sse/handlers/imageProviders/huggingface.js +2 -17
  172. package/open-sse/handlers/imageProviders/index.js +3 -4
  173. package/open-sse/handlers/imageProviders/leonardo.js +1 -1
  174. package/open-sse/handlers/imageProviders/nanobanana.js +4 -23
  175. package/open-sse/handlers/imageProviders/openai.js +15 -43
  176. package/open-sse/handlers/imageProviders/runwayml.js +2 -26
  177. package/open-sse/handlers/imageProviders/sdwebui.js +4 -20
  178. package/open-sse/handlers/imageProviders/stabilityAi.js +2 -26
  179. package/open-sse/handlers/imageProviders/weavy.js +1 -1
  180. package/open-sse/handlers/search/chatSearch.js +60 -14
  181. package/open-sse/handlers/ttsProviders/gemini.js +14 -3
  182. package/open-sse/handlers/ttsProviders/index.js +4 -2
  183. package/open-sse/handlers/ttsProviders/openai.js +4 -1
  184. package/open-sse/handlers/ttsProviders/openrouter.js +7 -4
  185. package/open-sse/handlers/videoCore.js +166 -0
  186. package/open-sse/handlers/videoProviders/weavy.js +1 -1
  187. package/open-sse/mcp-server/audit.js +1 -1
  188. package/open-sse/mcp-server/catalog.js +2 -2
  189. package/open-sse/mcp-server/descriptionCompressor.js +1 -1
  190. package/open-sse/mcp-server/mcpCallerIdentity.js +1 -1
  191. package/open-sse/mcp-server/schemas/tools.js +1 -1
  192. package/open-sse/mcp-server/server.js +4 -4
  193. package/open-sse/mcp-server/tools/advancedTools.js +5 -5
  194. package/open-sse/mcp-server/tools/agentSkillTools.js +1 -1
  195. package/open-sse/mcp-server/tools/compressionTools.js +4 -4
  196. package/open-sse/mcp-server/tools/gamificationTools.js +10 -10
  197. package/open-sse/mcp-server/tools/githubSkillTools.js +1 -1
  198. package/open-sse/mcp-server/tools/memoryTools.js +3 -3
  199. package/open-sse/mcp-server/tools/notionTools.js +2 -2
  200. package/open-sse/mcp-server/tools/obsidianTools.js +2 -2
  201. package/open-sse/mcp-server/tools/pickFastestModel.js +3 -3
  202. package/open-sse/mcp-server/tools/pluginTools.js +4 -4
  203. package/open-sse/mcp-server/tools/skillTools.js +2 -2
  204. package/open-sse/providers/capabilities.js +24 -4
  205. package/open-sse/providers/registry/alicode-intl.js +1 -1
  206. package/open-sse/providers/registry/anthropic.js +1 -8
  207. package/open-sse/providers/registry/codex.js +0 -9
  208. package/open-sse/providers/registry/cohere.js +0 -2
  209. package/open-sse/providers/registry/gemini.js +0 -2
  210. package/open-sse/providers/registry/github.js +9 -6
  211. package/open-sse/providers/registry/grok-cli.js +28 -18
  212. package/open-sse/providers/registry/index.js +74 -80
  213. package/open-sse/providers/registry/kiro.js +12 -0
  214. package/open-sse/providers/registry/mistral.js +0 -3
  215. package/open-sse/providers/registry/openai.js +0 -3
  216. package/open-sse/providers/registry/perplexity.js +0 -2
  217. package/open-sse/providers/registry/xai.js +5 -3
  218. package/open-sse/rtk/autodetect.js +10 -2
  219. package/open-sse/rtk/caveman.js +2 -93
  220. package/open-sse/rtk/cavemanPrompts.js +34 -2
  221. package/open-sse/rtk/constants.js +7 -2
  222. package/open-sse/rtk/headroom.js +133 -0
  223. package/open-sse/rtk/ponytail.js +1 -1
  224. package/open-sse/rtk/registry.js +2 -0
  225. package/open-sse/services/accountFallback.js +0 -108
  226. package/open-sse/services/combo/quotaExhaustionCutoff.js +2 -2
  227. package/open-sse/services/combo/quotaShareStrategy.js +1 -1
  228. package/open-sse/services/combo/resolveAutoStrategy.js +1 -1
  229. package/open-sse/services/combo/sessionStickiness.js +1 -1
  230. package/open-sse/services/combo/shadowRouting.js +1 -1
  231. package/open-sse/services/combo/targetSorters.js +4 -4
  232. package/open-sse/services/combo/validateQuality.js +1 -1
  233. package/open-sse/services/evalRouting.js +1 -1
  234. package/open-sse/services/grokCliModels.js +127 -0
  235. package/open-sse/services/model.js +7 -1
  236. package/open-sse/services/modelCapabilities.js +1 -1
  237. package/open-sse/services/modelFamilyFallback.js +1 -1
  238. package/open-sse/services/provider.js +1 -1
  239. package/open-sse/services/providerCooldownTracker.js +1 -1
  240. package/open-sse/services/rateLimitManager.js +1 -1
  241. package/open-sse/services/tokenRefresh/providers.js +3 -3
  242. package/open-sse/services/usage/codex.js +148 -214
  243. package/open-sse/services/usage/grok-cli.js +61 -7
  244. package/open-sse/services/usage/misc.js +0 -19
  245. package/open-sse/services/usage.js +0 -2
  246. package/open-sse/translator/concerns/paramSupport.js +2 -2
  247. package/open-sse/translator/concerns/thinkingUnified.js +6 -0
  248. package/open-sse/translator/index.js +97 -59
  249. package/open-sse/translator/request/claude-to-kiro.js +67 -40
  250. package/open-sse/translator/request/openai-responses.js +1 -0
  251. package/open-sse/translator/request/openai-to-commandcode.js +0 -4
  252. package/open-sse/translator/request/openai-to-kiro.js +49 -20
  253. package/open-sse/translator/response/commandcode-to-openai.js +0 -4
  254. package/open-sse/utils/bypassHandler.js +18 -3
  255. package/open-sse/utils/claudeCloaking.js +15 -5
  256. package/open-sse/utils/error.js +0 -17
  257. package/open-sse/utils/kiroSessionReplay.js +125 -0
  258. package/open-sse/utils/logger.js +1 -1
  259. package/open-sse/utils/proxyFetch.js +0 -1
  260. package/open-sse/utils/reasoningContentInjector.js +4 -7
  261. package/open-sse/utils/responsesStreamHelpers.js +1 -0
  262. package/open-sse/utils/sessionManager.js +49 -22
  263. package/open-sse/utils/stream.js +54 -77
  264. package/open-sse/utils/streamHandler.js +19 -15
  265. package/open-sse/utils/streamHelpers.js +2 -17
  266. package/open-sse/utils/usageTracking.js +103 -12
  267. package/package.json +4 -7
  268. package/public/assets/EndpointPageClient.C2WMTYy0.js +6 -0
  269. package/public/assets/{Loading.Bj-WGl4k.js → Loading.BHPtQ9vj.js} +1 -1
  270. package/public/assets/{NoAuthProxyCard.qAv57b-0.js → NoAuthProxyCard.BDcXaWvM.js} +1 -1
  271. package/public/assets/index.Be3gbrBl.js +89 -0
  272. package/public/assets/index.COMgQZYj.css +1 -0
  273. package/public/assets/{page.CbkENBd5.js → page.-lpNgYAw.js} +1 -1
  274. package/public/assets/{page.CssmrzTT.js → page.11hpNKmq.js} +1 -1
  275. package/public/assets/{page.C72FTTJr.js → page.B-LxsnqU.js} +1 -1
  276. package/public/assets/{page.sOFOrxqq.js → page.B-dzeIUC.js} +1 -1
  277. package/public/assets/{page.CsxWmPoI.js → page.B-nBR75u.js} +1 -1
  278. package/public/assets/{page.Dx_GRRdT.js → page.B3QqvLep.js} +1 -1
  279. package/public/assets/{page.DPyOkPVo.js → page.B8xdkCWA.js} +1 -1
  280. package/public/assets/{page.DUI8kqOY.js → page.BFb7yUd8.js} +1 -1
  281. package/public/assets/page.BbPPdoas.js +1 -0
  282. package/public/assets/page.BdS20a1O.js +1 -0
  283. package/public/assets/{page.DibhF7f-.js → page.BfmI9KYe.js} +1 -1
  284. package/public/assets/{page.DX4Nno6M.js → page.BgGJovOg.js} +1 -1
  285. package/public/assets/{page.BnmTC5jG.js → page.C0gBvR4O.js} +1 -1
  286. package/public/assets/{page.D5gj98Oe.js → page.C6bYizL7.js} +1 -1
  287. package/public/assets/{page.vla5Mzki.js → page.C8sLEMa6.js} +1 -1
  288. package/public/assets/{page.CXd_R9yU.js → page.CCNsZBXp.js} +1 -1
  289. package/public/assets/{page.CQlVGoXg.js → page.CF_YSLwP.js} +1 -1
  290. package/public/assets/{page.BbO1pspY.js → page.CPTtRDxw.js} +1 -1
  291. package/public/assets/{page.D1oKew1j.js → page.CdMmlUEm.js} +1 -1
  292. package/public/assets/{page.DxMDTbSx.js → page.Cged1bOZ.js} +1 -1
  293. package/public/assets/{page.Cj5h09Zo.js → page.Ch647dVk.js} +1 -1
  294. package/public/assets/{page.DVIHRbxB.js → page.CpvXDkQF.js} +1 -1
  295. package/public/assets/{page.i4KDuWcM.js → page.CrBl7f8N.js} +1 -1
  296. package/public/assets/{page.BSLJ4tx5.js → page.CrP7niA2.js} +1 -1
  297. package/public/assets/{page.CnTop8Zt.js → page.CvUFZzXr.js} +1 -1
  298. package/public/assets/{page.O2ddJYoT.js → page.CyUqJPmx.js} +1 -1
  299. package/public/assets/{page.DBhu4Arl.js → page.D8Rp8fFR.js} +1 -1
  300. package/public/assets/{page.CPZav1_c.js → page.Df9qtrdG.js} +1 -1
  301. package/public/assets/{page.Qkkv8roc.js → page.DiL4Gwqe.js} +1 -1
  302. package/public/assets/{page.BdmJ3yY3.js → page.Dl1apZE2.js} +1 -1
  303. package/public/assets/{page.1qjqvrwX.js → page.HV0w1d5C.js} +1 -1
  304. package/public/assets/{page.ChX1NqmC.js → page.N1x4YL8_.js} +1 -1
  305. package/public/assets/{page.Dh5f0XJC.js → page.P2Ny5veR.js} +1 -1
  306. package/public/assets/{page.CSs3-gdt.js → page.fOOCr18J.js} +1 -1
  307. package/public/assets/{page.Ir7KvKcF.js → page.sUIPWIiF.js} +1 -1
  308. package/public/assets/{page.CzlQTyAL.js → page.tE7PpWYW.js} +1 -1
  309. package/public/assets/{page.DzZLqI5Q.js → page.uziaGZsT.js} +1 -1
  310. package/public/index.html +2 -2
  311. package/public/assets/EndpointPageClient.LyNNvZ4z.js +0 -6
  312. package/public/assets/index.BuPfZebu.css +0 -1
  313. package/public/assets/index.CShjRV_B.js +0 -89
  314. package/public/assets/page.DD_czjjP.js +0 -1
@@ -1 +1 @@
1
- import{h as et,j as e,U as tt,P as Ae}from"./index.CShjRV_B.js";import{b as c}from"./router.Cjj1--8t.js";import{C as rt}from"./Loading.Bj-WGl4k.js";import{C as ce,T as st,E as nt}from"./NoAuthProxyCard.qAv57b-0.js";import"./zustand.akaTi5uX.js";function at(s){if(!s)return"-";try{const u=(typeof s=="string"?new Date(s):s)-new Date;if(u<=0)return"-";const l=Math.ceil(u/(1e3*60));if(l<60)return`${l}m`;const a=Math.floor(l/60),x=l%60;if(a<24)return`${a}h ${x}m`;const h=Math.floor(a/24),p=a%24;return`${h}d ${p}h ${x}m`}catch{return"-"}}function $e(s,n){return!n||n===0?0:!s||s<0?100:s>=n?0:Math.round((n-s)/n*100)}function it(s){return(s==null?void 0:s.remaining)!==void 0?Math.max(0,Math.round(s.remaining)):(s==null?void 0:s.remainingPercentage)!==void 0?Math.round(s.remainingPercentage):$e(s==null?void 0:s.used,s==null?void 0:s.total)}function ot(s,n){if(!n||typeof n!="object")return[];const o=[];try{switch(s.toLowerCase()){case"github":n.quotas&&Object.entries(n.quotas).forEach(([l,a])=>{o.push({name:l,used:a.used||0,total:a.total||0,resetAt:a.resetAt||null})});break;case"antigravity":n.quotas&&Object.entries(n.quotas).forEach(([l,a])=>{o.push({name:a.displayName||l,modelKey:l,used:a.used||0,total:a.total||0,resetAt:a.resetAt||null,remainingPercentage:a.remainingPercentage})});break;case"codex":if(n.quotas){const l={session:"Session (5h)",weekly:"Weekly (7d)",code_review:"Code Review",code_review_weekly:"Code Review Weekly",spark:"Spark",spark_weekly:"Spark Weekly"};Object.entries(n.quotas).forEach(([a,x])=>{o.push({name:x.displayName||l[a]||a,used:x.used||0,total:x.total||0,remaining:x.remaining,resetAt:x.resetAt||null})})}n.bankedResetCredits!==void 0&&n.bankedResetCredits>0&&o.push({name:"Banked Reset Credits",used:0,total:n.bankedResetCredits,remaining:n.bankedResetCredits,resetAt:null});break;case"kiro":n.quotas&&Object.entries(n.quotas).forEach(([l,a])=>{o.push({name:l,used:a.used||0,total:a.total||0,resetAt:a.resetAt||null})});break;case"qoder":n.quotas&&Object.entries(n.quotas).forEach(([l,a])=>{l==="organization"&&(!a||(Number(a.total)||0)===0)||o.push({name:l==="user"?"Personal":l==="organization"?"Organization":l,used:a.used||0,total:a.total||0,unit:a.unit,resetAt:a.resetAt||null})});break;case"claude":n.message?o.push({name:"error",used:0,total:0,resetAt:null,message:n.message}):n.quotas&&Object.entries(n.quotas).forEach(([l,a])=>{o.push({name:l,used:a.used||0,total:a.total||0,resetAt:a.resetAt||null})});break;case"leonardo":n.quotas&&Object.entries(n.quotas).forEach(([l,a])=>{o.push({name:l==="tokens"?"Tokens":l,used:a.used||0,total:a.total||0,resetAt:a.resetAt||null,unit:a.unit||null,remaining:a.remaining!==void 0?a.remaining:null})});break;case"weavy":n.quotas&&Object.entries(n.quotas).forEach(([l,a])=>{o.push({name:l==="tokens"?"tokens":l,used:a.used||0,total:a.total||0,resetAt:a.resetAt||null,unit:a.unit||null,remaining:a.remaining!==void 0?a.remaining:null})});break;case"cloudflare-ai":n.quotas&&Object.entries(n.quotas).forEach(([l,a])=>{o.push({name:l,used:a.used||0,total:a.total||0,resetAt:a.resetAt||null,unit:a.unit||"neurons"})});break;default:n.quotas&&Object.entries(n.quotas).forEach(([l,a])=>{o.push({name:l,used:a.used||0,total:a.total||0,resetAt:a.resetAt||null,unit:a.unit||null,remaining:a.remaining!==void 0?a.remaining:null})})}}catch(l){return console.error(`Error parsing quota data for ${s}:`,l),[]}const u=et(s);if(u.length>0){const l=new Map(u.map((a,x)=>[a.id,x]));o.sort((a,x)=>{const h=a.modelKey||a.name,p=x.modelKey||x.name,U=l.get(h)??999,G=l.get(p)??999;return U-G})}return o}const W=10;function lt(s){if(!s)return null;try{const n=new Date(s),o=new Date,u=new Date(o.getFullYear(),o.getMonth(),o.getDate()),l=new Date(u);l.setDate(l.getDate()+1);let a="";n>=u&&n<l?a="Today":n>=l&&n<new Date(l.getTime()+1440*60*1e3)?a="Tomorrow":a=n.toLocaleDateString("en-US",{month:"short",day:"numeric"});const x=n.toLocaleTimeString("en-US",{hour:"numeric",minute:"2-digit",hour12:!0});return`${a}, ${x}`}catch{return null}}function ct(s){return s>70?{text:"text-green-600 dark:text-green-400",bg:"bg-green-500",bgLight:"bg-green-500/10",emoji:"🟢"}:s>=30?{text:"text-yellow-600 dark:text-yellow-400",bg:"bg-yellow-500",bgLight:"bg-yellow-500/10",emoji:"🟡"}:{text:"text-red-600 dark:text-red-400",bg:"bg-red-500",bgLight:"bg-red-500/10",emoji:"🔴"}}function dt(s,n){return n==="remaining-asc"?[...s].sort((o,u)=>o.remaining-u.remaining||o.name.localeCompare(u.name)):n==="remaining-desc"?[...s].sort((o,u)=>u.remaining-o.remaining||o.name.localeCompare(u.name)):s}function ut({quotas:s=[],compact:n=!1,sortMode:o="default",showSortLabel:u=!1}){const[l,a]=c.useState(1),x=c.useMemo(()=>s.map((m,f)=>({...m,index:f,remaining:it(m)})),[s]),h=c.useMemo(()=>dt(x,o),[x,o]),p=Math.max(1,Math.ceil(h.length/W));if(c.useEffect(()=>{a(1)},[o,s]),c.useEffect(()=>{a(m=>Math.min(m,p))},[p]),!s||s.length===0)return null;const U=h.slice((l-1)*W,l*W),G=h.length===0?0:(l-1)*W+1,V=Math.min(l*W,h.length),b=n?"py-1 px-1.5":"py-2 px-3",q=n?"text-[11px]":"text-sm",v=n?"text-[11px]":"text-sm",J=n?"text-[10px] leading-tight":"text-xs";return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"text-[10px] text-text-muted",children:[h.length," quota",h.length>1?"s":""]}),u&&e.jsx("div",{className:"rounded-md border border-black/10 bg-black/[0.02] px-2 py-1 text-[10px] text-text-muted dark:border-white/10 dark:bg-white/[0.03]",children:"Sorted by account remaining"})]}),e.jsx("div",{className:"overflow-x-auto",children:e.jsx("table",{className:"w-full table-fixed text-left",children:e.jsx("tbody",{children:U.map(m=>{var B;const f=ct(m.remaining),I=at(m.resetAt),D=lt(m.resetAt),te=((B=m.name)==null?void 0:B.toLowerCase())==="tokens"?Math.max(0,m.total-m.used):m.used;return e.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:[e.jsx("td",{className:`${b} w-[30%]`,children:e.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[e.jsx("span",{className:"text-[10px] shrink-0",children:f.emoji}),e.jsx("span",{className:`${q} font-medium text-text-primary truncate`,children:m.name})]})}),e.jsx("td",{className:`${b} w-[45%]`,children:e.jsxs("div",{className:n?"space-y-1":"space-y-1.5",children:[e.jsx("div",{className:`${n?"h-1":"h-1.5"} rounded-full overflow-hidden border ${f.bgLight} ${m.remaining===0?"border-black/10 dark:border-white/10":"border-transparent"}`,children:e.jsx("div",{className:`h-full transition-all duration-300 ${f.bg}`,style:{width:`${Math.min(m.remaining,100)}%`}})}),e.jsxs("div",{className:`flex items-center justify-between ${n?"text-[10px]":"text-xs"}`,children:[e.jsxs("span",{className:"text-text-muted",children:[te.toLocaleString()," / ",m.total>0?m.total.toLocaleString():"∞"]}),e.jsxs("span",{className:`font-medium ${f.text}`,children:[m.remaining,"%"]})]})]})}),e.jsx("td",{className:`${b} w-[25%]`,children:I!=="-"||D?n?e.jsx("div",{className:`${v} text-text-primary font-medium truncate`,title:D||"",children:I!=="-"?`in ${I}`:D}):e.jsxs("div",{className:"space-y-0.5",children:[I!=="-"&&e.jsxs("div",{className:`${v} text-text-primary font-medium`,children:["in ",I]}),D&&e.jsx("div",{className:`${J} text-text-muted`,children:D})]}):e.jsx("div",{className:`${v} text-text-muted italic`,children:"N/A"})})]},`${m.name}-${m.index}`)})})})}),p>1&&e.jsxs("div",{className:"rounded-md border border-black/10 bg-black/[0.02] px-2 py-1.5 dark:border-white/10 dark:bg-white/[0.03]",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 text-[10px] text-text-muted",children:[e.jsxs("span",{children:["Showing ",G,"-",V," of ",h.length]}),e.jsxs("span",{children:["Page ",l," / ",p]})]}),e.jsxs("div",{className:"mt-1.5 flex items-center justify-end gap-1",children:[e.jsx("button",{type:"button",onClick:()=>a(m=>Math.max(1,m-1)),disabled:l===1,className:"flex h-6 items-center rounded-md border border-black/10 px-2 text-[10px] text-text-primary transition-colors hover:bg-black/5 disabled:cursor-not-allowed disabled:opacity-40 dark:border-white/10 dark:hover:bg-white/5",children:"Prev"}),e.jsx("button",{type:"button",onClick:()=>a(m=>Math.min(p,m+1)),disabled:l===p,className:"flex h-6 items-center rounded-md border border-black/10 px-2 text-[10px] text-text-primary transition-colors hover:bg-black/5 disabled:cursor-not-allowed disabled:opacity-40 dark:border-white/10 dark:hover:bg-white/5",children:"Next"})]})]})]})}function X(s){const n=o=>typeof o=="string"&&/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(o);return n(s.email)?s.email:(n(s.name),s.name)}function mt(s,n,o){if(!o)return s;const u=l=>{var x;const a=(((x=n[l.id])==null?void 0:x.quotas)||[]).map(h=>h.resetAt?new Date(h.resetAt).getTime():Number.POSITIVE_INFINITY).filter(h=>Number.isFinite(h));return a.length>0?Math.min(...a):Number.POSITIVE_INFINITY};return[...s].sort((l,a)=>{const x=u(l)-u(a);return x!==0?x:(l.provider||"").localeCompare(a.provider||"")||(X(l)||"").localeCompare(X(a)||"")})}function Pe(s){const n={};return s.forEach(o=>{n[o.id]=!0}),n}function Z(s,n){const o=new Set(n.map(u=>u.id));return Object.fromEntries(Object.entries(s).filter(([u])=>o.has(u)))}function xt(s){if(!s.total)return{start:0,end:0};const n=(s.page-1)*s.pageSize+1,o=Math.min(s.page*s.pageSize,s.total);return{start:n,end:o}}function ht(s,n,o){return s.eligibleConnections?s.providerFilteredConnections?{icon:"filter_alt_off",title:"No Accounts On This Page",description:"Try moving to another page or refreshing the current filters."}:{icon:"filter_alt_off",title:"No Accounts Match Current Filters",description:n==="all"?"Try changing the account status filter to see more quota trackers.":`No ${o==="inactive"?"turned off":o==="active"?"active":"matching"} accounts found for ${n}.`}:{icon:"cloud_off",title:"No Providers Connected",description:"Connect to providers with OAuth to track your API quota limits and usage."}}function pt(s){const{start:n,end:o}=xt(s);return`Showing ${n}-${o} of ${s.total}`}function bt(s,n){return s||{page:1,pageSize:n,total:0,totalPages:1}}function gt(s,n=0){return s||{eligibleConnections:n,providerFilteredConnections:n}}function de(s,n){return s!==n}function ft(s,n){return(s==null?void 0:s.page)||n}function yt(s){return s||[]}async function ue(s,n){return await s(n)}const he="quotaCacheData";function Me(){if(typeof window>"u")return{};try{const s=window.localStorage.getItem(he);return s?JSON.parse(s):{}}catch(s){return console.error("Error reading quota cache:",s),{}}}function Te(s,n){if(!(typeof window>"u"))try{const o=Me();o[s]={...n,cachedAt:new Date().toISOString()},window.localStorage.setItem(he,JSON.stringify(o))}catch(o){console.error("Error writing quota cache:",o)}}const Oe=6e4,vt=5,Ie="quotaAutoRefresh",wt=[{value:"all",label:"All accounts"},{value:"active",label:"Active"},{value:"inactive",label:"Turned off"}],kt=[{value:"default",label:"Default order"},{value:"remaining-asc",label:"Least credits first"},{value:"remaining-desc",label:"Most credits first"},{value:"balance-asc",label:"Saldo Terendah (Lowest Balance)"},{value:"balance-desc",label:"Saldo Tertinggi (Highest Balance)"}],me=20,De=[10,20,50,100],xe=500;function jt(){const[s,n]=c.useState([]),[o,u]=c.useState({}),[l,a]=c.useState({}),[x,h]=c.useState({}),[p,U]=c.useState(!0),[G,V]=c.useState(null),[b,q]=c.useState(!1),[v,J]=c.useState(!1),[pe,m]=c.useState(60),[f,I]=c.useState(!0),[D,ee]=c.useState(null),[te,B]=c.useState(null),[_e,re]=c.useState(!1),[R,se]=c.useState(null),[Re,Le]=c.useState([]),[A,ne]=c.useState("all"),[Fe,be]=c.useState([]),[L,ge]=c.useState("all"),[P,fe]=c.useState("default"),[F,ze]=c.useState(!1),[Nt,St]=c.useState(!1),[Y,ye]=c.useState(!1),[w,C]=c.useState(1),[$,ae]=c.useState(me),[ie,Q]=c.useState(String(me)),[E,ve]=c.useState({page:1,pageSize:me,total:0,totalPages:1}),[k,we]=c.useState({eligibleConnections:0,providerFilteredConnections:0}),T=c.useRef(null),O=c.useRef(null),j=c.useCallback(async(t=w)=>{try{let r="priority";F?r="expiring":P==="remaining-asc"?r="usage-asc":P==="remaining-desc"?r="usage-desc":P==="balance-asc"?r="balance-asc":P==="balance-desc"&&(r="balance-desc");const i=new URLSearchParams({page:String(t),pageSize:String($),accountStatus:L,sort:r});A!=="all"&&i.set("provider",A);const d=await fetch(`/api/providers/client?${i.toString()}`);if(!d.ok)throw new Error("Failed to fetch connections");const N=await d.json(),g=N.connections||[],y=bt(N.pagination,$),S=gt(N.totals,g.length);return n(g),be(yt(N.providerOptions)),ve(y),we(S),C(ft(N.pagination,t)),g}catch(r){return console.error("Error fetching connections:",r),n([]),be([]),ve({page:1,pageSize:$,total:0,totalPages:1}),we({eligibleConnections:0,providerFilteredConnections:0}),[]}},[L,F,w,$,A,P]),M=c.useCallback(async(t,r)=>{a(i=>({...i,[t]:!0})),h(i=>({...i,[t]:null}));try{const i=await fetch(`/api/usage/${t}`);if(!i.ok){const S=(await i.json().catch(()=>({}))).error||i.statusText;if(i.status===404)return;if(i.status===401){const _={quotas:[],message:S};u(H=>({...H,[t]:_})),Te(t,_);return}throw new Error(`HTTP ${i.status}: ${S}`)}const d=await i.json(),g={quotas:ot(r,d),plan:d.plan||null,message:d.message||null,raw:d};u(y=>({...y,[t]:g})),Te(t,g)}catch(i){h(d=>({...d,[t]:i.message||"Failed to fetch quota"}))}finally{a(i=>({...i,[t]:!1}))}},[]),Ue=c.useCallback(async(t,r)=>{await M(t,r),V(new Date)},[M]),Qe=c.useCallback(async t=>{if(confirm("Delete this connection?")){ee(t);try{if((await fetch(`/api/providers/${t}`,{method:"DELETE"})).ok){if(u(i=>{const d={...i};return delete d[t],d}),a(i=>{const d={...i};return delete d[t],d}),h(i=>{const d={...i};return delete d[t],d}),typeof window<"u")try{const i=Me();i[t]&&(delete i[t],window.localStorage.setItem(he,JSON.stringify(i)))}catch(i){console.error("Error deleting cache entry:",i)}await ue(j,w)}}catch(r){console.error("Error deleting connection:",r)}finally{ee(null)}}},[j,w]),He=c.useCallback(async(t,r)=>{B(t);try{(await fetch(`/api/providers/${t}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({isActive:r})})).ok&&(u(d=>({...d})),await ue(j,w))}catch(i){console.error("Error updating connection status:",i)}finally{B(null)}},[j,w]),Ve=c.useCallback(async t=>{if(!(R!=null&&R.id))return;const r=R.id,i=R.provider;try{(await fetch(`/api/providers/${r}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})).ok&&(await j(),re(!1),se(null),tt.includes(i)&&await M(r,i))}catch(d){console.error("Error saving connection:",d)}},[R,j,M]);c.useEffect(()=>{let t=!1;return fetch("/api/proxy-pools?isActive=true",{cache:"no-store"}).then(r=>r.json()).then(r=>{!t&&(r!=null&&r.proxyPools)&&Le(r.proxyPools)}).catch(()=>{}),()=>{t=!0}},[]);const K=c.useCallback(async()=>{if(!v){J(!0),m(60);try{const t=await j(w);a(Pe(t)),h(r=>Z(r,t)),u(r=>Z(r,t)),await Promise.all(t.map(r=>M(r.id,r.provider))),V(new Date)}catch(t){console.error("Error refreshing all providers:",t)}finally{J(!1)}}},[v,j,M,w]);c.useEffect(()=>{if(!b)return;(async()=>{I(!0);const r=await j(w);I(!1),a(Pe(r)),h(i=>Z(i,r)),u(i=>Z(i,r)),await Promise.all(r.map(i=>M(i.id,i.provider))),V(new Date)})()},[j,M,w,b]);const ke="quotaProviderFilter",je="quotaAccountFilter",Ne="quotaSortMode";c.useEffect(()=>{if(typeof window>"u")return;const t=window.localStorage.getItem(Ie);U(t===null?!0:t==="true");const r=window.localStorage.getItem(ke);r&&ne(r);const i=window.localStorage.getItem(je);i&&ge(i);const d=window.localStorage.getItem(Ne);d&&fe(d),q(!0)},[]),c.useEffect(()=>{typeof window>"u"||!b||window.localStorage.setItem(Ie,String(p))},[p,b]),c.useEffect(()=>{typeof window>"u"||!b||window.localStorage.setItem(ke,A)},[A,b]),c.useEffect(()=>{typeof window>"u"||!b||window.localStorage.setItem(je,L)},[L,b]),c.useEffect(()=>{typeof window>"u"||!b||window.localStorage.setItem(Ne,P)},[P,b]),c.useEffect(()=>{if(!b||!p){T.current&&(clearInterval(T.current),T.current=null),O.current&&(clearInterval(O.current),O.current=null);return}return T.current=setInterval(()=>{K()},Oe),O.current=setInterval(()=>{m(t=>t<=1?60:t-1)},1e3),()=>{T.current&&clearInterval(T.current),O.current&&clearInterval(O.current)}},[p,K,b]),c.useEffect(()=>{const t=()=>{document.hidden?(T.current&&(clearInterval(T.current),T.current=null),O.current&&(clearInterval(O.current),O.current=null)):p&&b&&(T.current=setInterval(K,Oe),O.current=setInterval(()=>{m(r=>r<=1?60:r-1)},1e3))};return document.addEventListener("visibilitychange",t),()=>{document.removeEventListener("visibilitychange",t)}},[p,K,b]);const z=c.useMemo(()=>mt(s,o,F),[s,o,F]),Se=t=>{var i;const r=(i=o[t.id])==null?void 0:i.quotas;return r!=null&&r.length?r.some(d=>!d.total||d.total<=0?!1:$e(d.used,d.total)<=vt):!1},Ce=t=>{const r=o[t.id];return r&&r.message==="Account disabled (Credits exhausted)"},oe=c.useCallback(async(t,r)=>{if(!(!t.length||Y)){ye(!0);try{await Promise.all(t.map(i=>fetch(`/api/providers/${i}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({isActive:r})}))),await ue(j,w)}catch(i){console.error("Error bulk toggling connections:",i)}finally{ye(!1)}}},[Y,j,w]),Be=()=>{const t=z.filter(r=>(r.isActive??!0)&&Se(r)).map(r=>r.id);oe(t,!1)},Ye=()=>{const t=z.filter(r=>(r.isActive??!0)&&Ce(r)).map(r=>r.id);oe(t,!1)},Ke=()=>{const t=z.filter(r=>!(r.isActive??!0)&&!Se(r)&&!Ce(r)).map(r=>r.id);oe(t,!0)},{totalCredits:We,providerStats:Ge,exhaustedCount:Ee}=c.useMemo(()=>{var N;let t=0;const r={};let i=0;z.forEach(g=>{const y=o[g.id];if(y&&y.message==="Account disabled (Credits exhausted)"&&(i+=1),!y)return;const S=g.provider;r[S]||(r[S]={accounts:0,credits:0}),r[S].accounts+=1,y.quotas&&y.quotas.forEach(_=>{let H=typeof _.remaining=="number"&&Number.isFinite(_.remaining)?_.remaining:Math.max(0,(_.total||0)-(_.used||0));Number.isFinite(H)&&H>0&&S!=="cloudflare-ai"&&(t+=H,r[S].credits+=H)})});const d=((N=k==null?void 0:k.providerCounts)==null?void 0:N["cloudflare-ai"])||0;if(d>0){const g=(k==null?void 0:k.cloudflareAi)!==void 0?Math.max(0,k.cloudflareAi.total-k.cloudflareAi.used):d*1e4;r["cloudflare-ai"]||(r["cloudflare-ai"]={accounts:d,credits:0}),r["cloudflare-ai"].accounts=d,r["cloudflare-ai"].credits=g,t+=g}return{totalCredits:t,providerStats:r,exhaustedCount:i}},[o,z,k]),Je=k.eligibleConnections>0,Ze=z.length>0,le=ht(k,A,L),Xe=pt(E),qe=!De.includes($);return!f&&!Je?e.jsx(ce,{padding:"lg",children:e.jsxs("div",{className:"text-center py-12",children:[e.jsx("span",{className:"material-symbols-outlined text-[64px] text-text-muted opacity-20",children:"cloud_off"}),e.jsx("h3",{className:"mt-4 text-lg font-semibold text-text-primary",children:"No Providers Connected"}),e.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.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-sm font-medium text-text-primary px-1",children:[e.jsxs("div",{className:"flex items-center gap-1.5 bg-black/5 dark:bg-white/10 px-2.5 py-1 rounded-md",title:"Total active accounts on this page",children:[e.jsx("span",{className:"material-symbols-outlined text-[16px] text-text-muted",children:"group"}),e.jsxs("span",{children:[k.providerFilteredConnections," Accounts"]})]}),e.jsxs("div",{className:"flex items-center gap-1.5 bg-primary/10 px-2.5 py-1 rounded-md",title:"Total credits across these accounts",children:[e.jsx("span",{className:"material-symbols-outlined text-[16px] text-primary",children:"database"}),e.jsxs("span",{className:"text-primary",children:[Math.floor(We)," Credits"]})]}),Ee>0&&e.jsxs("div",{className:"flex items-center gap-1.5 bg-red-500/10 px-2.5 py-1 rounded-md",title:"Total exhausted accounts",children:[e.jsx("span",{className:"material-symbols-outlined text-[16px] text-red-500",children:"warning"}),e.jsxs("span",{className:"text-red-500",children:[Ee," Exhausted"]})]}),e.jsx("div",{className:"flex flex-wrap items-center gap-1 ml-2",children:Object.entries(Ge).map(([t,r])=>e.jsxs("div",{className:"flex items-center gap-1 bg-black/5 dark:bg-white/5 px-2 py-0.5 rounded text-xs text-text-muted border border-black/10 dark:border-white/10",title:`${r.accounts} accounts`,children:[e.jsx("span",{className:"capitalize",children:t}),": ",e.jsx("span",{className:"font-semibold text-text-primary",children:Math.floor(r.credits)})]},t))})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-1 justify-end",children:[e.jsxs("div",{className:"flex flex-wrap gap-1",children:[e.jsxs("button",{type:"button",onClick:()=>{de(A,"all")&&C(1),ne("all")},className:`flex h-8 items-center gap-1.5 rounded-lg px-2.5 text-xs font-medium transition-colors ${A==="all"?"bg-primary/15 text-primary border border-primary/30":"bg-black/5 text-text-muted border border-transparent hover:bg-black/10 dark:bg-white/5 dark:hover:bg-white/10"}`,children:[e.jsx("span",{className:"material-symbols-outlined text-[14px]",children:"apps"}),e.jsx("span",{children:"All"})]}),Fe.map(t=>e.jsxs("button",{type:"button",onClick:()=>{de(A,t)&&C(1),ne(t)},className:`flex h-8 items-center gap-1.5 rounded-lg px-2.5 text-xs font-medium transition-colors ${A===t?"bg-primary/15 text-primary border border-primary/30":"bg-black/5 text-text-muted border border-transparent hover:bg-black/10 dark:bg-white/5 dark:hover:bg-white/10"}`,children:[e.jsx(Ae,{src:t==="codebuddy"||t==="cb"?"/providers/codebuddy.svg":`/providers/${t}.png`,alt:t,size:16,className:"size-4 rounded object-contain",fallbackText:t.slice(0,2).toUpperCase()}),e.jsx("span",{className:"capitalize",children:t})]},t))]}),e.jsx("select",{value:L,onChange:t=>{const r=t.target.value;de(L,r)&&C(1),ge(r)},className:"h-8 rounded-lg border border-black/10 bg-black/[0.02] px-2 text-xs text-text-primary outline-none transition-colors hover:bg-black/5 dark:border-white/10 dark:bg-white/[0.03] dark:hover:bg-white/10","aria-label":"Filter accounts by status",children:wt.map(t=>e.jsx("option",{value:t.value,children:t.label},t.value))}),e.jsx("select",{value:P,onChange:t=>fe(t.target.value),className:"h-8 rounded-lg border border-black/10 bg-black/[0.02] px-2 text-xs text-text-primary outline-none transition-colors hover:bg-black/5 dark:border-white/10 dark:bg-white/[0.03] dark:hover:bg-white/10","aria-label":"Sort quotas by remaining",children:kt.map(t=>e.jsx("option",{value:t.value,children:t.label},t.value))}),e.jsxs("button",{type:"button",onClick:()=>ze(t=>!t),"aria-pressed":F,className:`flex h-8 shrink-0 items-center gap-1 rounded-lg border px-2 text-xs transition-colors ${F?"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:[e.jsx("span",{className:"material-symbols-outlined text-[14px]",children:"hourglass_top"}),e.jsx("span",{className:"hidden sm:inline",children:"Expiring first"})]}),e.jsxs("button",{type:"button",onClick:Be,disabled:Y,className:"flex h-8 shrink-0 items-center gap-1 rounded-lg border border-red-500/30 px-2 text-xs text-red-500 transition-colors hover:bg-red-500/10 disabled:opacity-50",title:"Disable connections with depleted quota on the current page",children:[e.jsx("span",{className:"material-symbols-outlined text-[14px]",children:"block"}),e.jsx("span",{className:"hidden sm:inline",children:"Turn off Empty"})]}),e.jsxs("button",{type:"button",onClick:Ye,disabled:Y,className:"flex h-8 shrink-0 items-center gap-1 rounded-lg border border-red-500/30 px-2 text-xs text-red-500 transition-colors hover:bg-red-500/10 disabled:opacity-50",title:"Disable connections that are exhausted",children:[e.jsx("span",{className:"material-symbols-outlined text-[14px]",children:"block"}),e.jsx("span",{className:"hidden sm:inline",children:"Disable Exhausted"})]}),e.jsxs("button",{type:"button",onClick:Ke,disabled:Y,className:"flex h-8 shrink-0 items-center gap-1 rounded-lg border border-emerald-500/30 px-2 text-xs text-emerald-500 transition-colors hover:bg-emerald-500/10 disabled:opacity-50",title:"Enable connections that still have quota on the current page",children:[e.jsx("span",{className:"material-symbols-outlined text-[14px]",children:"check_circle"}),e.jsx("span",{className:"hidden sm:inline",children:"Turn on Available"})]}),e.jsxs("button",{onClick:()=>U(t=>!t),className:"flex h-8 shrink-0 items-center gap-1 rounded-lg border border-black/10 px-2 text-xs transition-colors hover:bg-black/5 dark:border-white/10 dark:hover:bg-white/5",title:p?"Disable auto-refresh":"Enable auto-refresh",children:[e.jsx("span",{className:`material-symbols-outlined text-[14px] ${p?"text-primary":"text-text-muted"}`,children:p?"toggle_on":"toggle_off"}),e.jsx("span",{className:"hidden text-text-primary sm:inline",children:"Auto-refresh"}),p&&e.jsxs("span",{className:"text-[10px] text-text-muted tabular-nums",children:["(",pe,"s)"]})]}),e.jsx("button",{type:"button",onClick:K,disabled:v,className:"flex h-8 shrink-0 items-center gap-1 rounded-lg border border-black/10 px-2 text-xs text-text-primary transition-colors hover:bg-black/5 dark:border-white/10 dark:hover:bg-white/5 disabled:opacity-50",title:"Refresh all",children:e.jsx("span",{className:`material-symbols-outlined text-[14px] ${v?"animate-spin":""}`,children:"refresh"})})]})]}),(F||P!=="default")&&e.jsx("div",{className:"rounded-xl border border-amber-500/20 bg-amber-500/10 px-3 py-2 text-xs text-amber-700 dark:text-amber-300 mb-3",children:"Sorting currently reorders accounts inside the current page. Cross-page ordering still follows backend pagination. Try increasing the page size to sort across more accounts."}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:!f&&!Ze?e.jsx("div",{className:"col-span-1 md:col-span-2",children:e.jsx(ce,{padding:"lg",children:e.jsxs("div",{className:"text-center py-12",children:[e.jsx("span",{className:"material-symbols-outlined text-[64px] text-text-muted opacity-20",children:le.icon}),e.jsx("h3",{className:"mt-4 text-lg font-semibold text-text-primary",children:le.title}),e.jsx("p",{className:"mt-2 text-sm text-text-muted max-w-md mx-auto",children:le.description})]})})}):z.map(t=>{var y;const r=o[t.id],i=l[t.id],d=x[t.id],N=t.isActive===!1,g=D===t.id||te===t.id;return e.jsxs(ce,{padding:"none",className:`min-w-0 ${N?"opacity-60":""}`,children:[e.jsx("div",{className:"px-3 py-2 border-b border-black/10 dark:border-white/10",children:e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx("div",{className:"w-8 h-8 shrink-0 rounded-md flex items-center justify-center overflow-hidden",children:e.jsx(Ae,{src:t.provider==="codebuddy"||t.provider==="cb"?"/providers/codebuddy.svg":`/providers/${t.provider}.png`,alt:t.provider,size:32,className:"object-contain",fallbackText:((y=t.provider)==null?void 0:y.slice(0,2).toUpperCase())||"PR"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("h3",{className:"text-sm font-semibold text-text-primary capitalize truncate",children:t.provider}),X(t)?e.jsx("p",{className:"text-xs text-text-muted truncate",children:X(t)}):null]})]}),e.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[e.jsx("button",{type:"button",onClick:()=>Ue(t.id,t.provider),disabled:i||g,"aria-label":"Refresh quota",className:"p-1.5 rounded-lg hover:bg-black/5 dark:hover:bg-white/5 transition-colors disabled:opacity-50",title:"Refresh quota",children:e.jsx("span",{className:`material-symbols-outlined text-[18px] text-text-muted ${i?"animate-spin":""}`,children:"refresh"})}),e.jsx("button",{type:"button",onClick:()=>{se(t),re(!0)},disabled:g,"aria-label":"Edit connection",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:e.jsx("span",{className:"material-symbols-outlined text-[18px]",children:"edit"})}),e.jsx("button",{type:"button",onClick:()=>Qe(t.id),disabled:g,"aria-label":"Delete connection",className:"p-1.5 rounded-lg hover:bg-red-500/10 text-red-500 transition-colors disabled:opacity-50",title:"Delete connection",children:e.jsx("span",{className:`material-symbols-outlined text-[18px] ${D===t.id?"animate-pulse":""}`,children:"delete"})}),e.jsx("div",{className:"inline-flex items-center pl-0.5",title:t.isActive??!0?"Disable connection":"Enable connection",children:e.jsx(st,{size:"sm",checked:t.isActive??!0,disabled:g,onChange:S=>He(t.id,S)})})]})]})}),e.jsx("div",{className:"px-2 py-1.5",children:i?e.jsx("div",{className:"text-center py-5 text-text-muted",children:e.jsx("span",{className:"material-symbols-outlined text-[28px] animate-spin",children:"progress_activity"})}):d?e.jsxs("div",{className:"text-center py-5",children:[e.jsx("span",{className:"material-symbols-outlined text-[28px] text-red-500",children:"error"}),e.jsx("p",{className:"mt-1.5 text-xs text-text-muted",children:d})]}):r!=null&&r.message?e.jsx("div",{className:"text-center py-5",children:e.jsx("p",{className:"text-xs text-text-muted",children:r.message})}):e.jsx(ut,{quotas:r==null?void 0:r.quotas,compact:!0,sortMode:"default",showSortLabel:t.provider==="codex"&&P!=="default"})})]},t.id)})}),e.jsx("div",{className:"rounded-xl border border-black/10 bg-black/[0.02] px-3 py-2 dark:border-white/10 dark:bg-white/[0.03]",children:e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsx("span",{className:"text-xs text-text-muted",children:Xe}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs("select",{value:qe?"custom":String($),onChange:t=>{const r=t.target.value;if(r==="custom")return;const i=Number.parseInt(r,10);Number.isFinite(i)&&(C(1),ae(i),Q(String(i)))},className:"h-8 rounded-lg border border-black/10 bg-black/[0.02] px-2 text-xs text-text-primary outline-none transition-colors hover:bg-black/5 dark:border-white/10 dark:bg-white/[0.03] dark:hover:bg-white/10","aria-label":"Accounts per page",children:[De.map(t=>e.jsxs("option",{value:String(t),children:[t," / page"]},t)),e.jsx("option",{value:"500",children:"500 / page"}),e.jsx("option",{value:"1000",children:"1000 / page"}),e.jsx("option",{value:"custom",children:"Custom"})]}),e.jsx("input",{type:"number",min:"1",max:String(xe),inputMode:"numeric",value:ie,onChange:t=>Q(t.target.value),onBlur:()=>{const t=Number.parseInt(ie,10);if(!Number.isFinite(t)){Q(String($));return}const r=Math.min(xe,Math.max(1,t));C(1),ae(r),Q(String(r))},onKeyDown:t=>{if(t.key!=="Enter")return;const r=Number.parseInt(ie,10);if(!Number.isFinite(r)){Q(String($));return}const i=Math.min(xe,Math.max(1,r));C(1),ae(i),Q(String(i))},className:"h-8 w-20 rounded-lg border border-black/10 bg-black/[0.02] px-2 text-xs text-text-primary outline-none transition-colors hover:bg-black/5 dark:border-white/10 dark:bg-white/[0.03] dark:hover:bg-white/10","aria-label":"Custom accounts per page",placeholder:"Custom"}),e.jsxs("span",{className:"text-xs text-text-muted",children:["Page ",E.page," / ",E.totalPages]})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("button",{suppressHydrationWarning:!0,type:"button",onClick:()=>C(1),disabled:E.page<=1||f||v,className:"flex h-8 items-center rounded-lg border border-black/10 px-3 text-xs text-text-primary transition-colors hover:bg-black/5 disabled:cursor-not-allowed disabled:opacity-40 dark:border-white/10 dark:hover:bg-white/5",children:"First Page"}),e.jsx("button",{suppressHydrationWarning:!0,type:"button",onClick:()=>C(t=>Math.max(1,t-1)),disabled:E.page<=1||f||v,className:"flex h-8 w-8 items-center justify-center rounded-lg border border-black/10 text-text-primary transition-colors hover:bg-black/5 disabled:cursor-not-allowed disabled:opacity-40 dark:border-white/10 dark:hover:bg-white/5","aria-label":"Previous accounts page",children:e.jsx("span",{className:"material-symbols-outlined text-[16px]",children:"chevron_left"})}),e.jsx("button",{suppressHydrationWarning:!0,type:"button",onClick:()=>C(t=>Math.min(E.totalPages,t+1)),disabled:E.page>=E.totalPages||f||v,className:"flex h-8 w-8 items-center justify-center rounded-lg border border-black/10 text-text-primary transition-colors hover:bg-black/5 disabled:cursor-not-allowed disabled:opacity-40 dark:border-white/10 dark:hover:bg-white/5","aria-label":"Next accounts page",children:e.jsx("span",{className:"material-symbols-outlined text-[16px]",children:"chevron_right"})}),e.jsx("button",{suppressHydrationWarning:!0,type:"button",onClick:()=>C(E.totalPages),disabled:E.page>=E.totalPages||f||v,className:"flex h-8 items-center rounded-lg border border-black/10 px-3 text-xs text-text-primary transition-colors hover:bg-black/5 disabled:cursor-not-allowed disabled:opacity-40 dark:border-white/10 dark:hover:bg-white/5",children:"Last Page"})]})]})}),e.jsx(nt,{isOpen:_e,connection:R,proxyPools:Re,onSave:Ve,onClose:()=>{re(!1),se(null)}})]})}function Ot(){return e.jsx(c.Suspense,{fallback:e.jsx(rt,{}),children:e.jsx(jt,{})})}export{Ot as default};
1
+ import{h as et,j as e,U as tt,P as Ae}from"./index.Be3gbrBl.js";import{b as c}from"./router.Cjj1--8t.js";import{C as rt}from"./Loading.BHPtQ9vj.js";import{C as ce,T as st,E as nt}from"./NoAuthProxyCard.BDcXaWvM.js";import"./zustand.akaTi5uX.js";function at(s){if(!s)return"-";try{const u=(typeof s=="string"?new Date(s):s)-new Date;if(u<=0)return"-";const l=Math.ceil(u/(1e3*60));if(l<60)return`${l}m`;const a=Math.floor(l/60),x=l%60;if(a<24)return`${a}h ${x}m`;const h=Math.floor(a/24),p=a%24;return`${h}d ${p}h ${x}m`}catch{return"-"}}function $e(s,n){return!n||n===0?0:!s||s<0?100:s>=n?0:Math.round((n-s)/n*100)}function it(s){return(s==null?void 0:s.remaining)!==void 0?Math.max(0,Math.round(s.remaining)):(s==null?void 0:s.remainingPercentage)!==void 0?Math.round(s.remainingPercentage):$e(s==null?void 0:s.used,s==null?void 0:s.total)}function ot(s,n){if(!n||typeof n!="object")return[];const o=[];try{switch(s.toLowerCase()){case"github":n.quotas&&Object.entries(n.quotas).forEach(([l,a])=>{o.push({name:l,used:a.used||0,total:a.total||0,resetAt:a.resetAt||null})});break;case"antigravity":n.quotas&&Object.entries(n.quotas).forEach(([l,a])=>{o.push({name:a.displayName||l,modelKey:l,used:a.used||0,total:a.total||0,resetAt:a.resetAt||null,remainingPercentage:a.remainingPercentage})});break;case"codex":if(n.quotas){const l={session:"Session (5h)",weekly:"Weekly (7d)",code_review:"Code Review",code_review_weekly:"Code Review Weekly",spark:"Spark",spark_weekly:"Spark Weekly"};Object.entries(n.quotas).forEach(([a,x])=>{o.push({name:x.displayName||l[a]||a,used:x.used||0,total:x.total||0,remaining:x.remaining,resetAt:x.resetAt||null})})}n.bankedResetCredits!==void 0&&n.bankedResetCredits>0&&o.push({name:"Banked Reset Credits",used:0,total:n.bankedResetCredits,remaining:n.bankedResetCredits,resetAt:null});break;case"kiro":n.quotas&&Object.entries(n.quotas).forEach(([l,a])=>{o.push({name:l,used:a.used||0,total:a.total||0,resetAt:a.resetAt||null})});break;case"qoder":n.quotas&&Object.entries(n.quotas).forEach(([l,a])=>{l==="organization"&&(!a||(Number(a.total)||0)===0)||o.push({name:l==="user"?"Personal":l==="organization"?"Organization":l,used:a.used||0,total:a.total||0,unit:a.unit,resetAt:a.resetAt||null})});break;case"claude":n.message?o.push({name:"error",used:0,total:0,resetAt:null,message:n.message}):n.quotas&&Object.entries(n.quotas).forEach(([l,a])=>{o.push({name:l,used:a.used||0,total:a.total||0,resetAt:a.resetAt||null})});break;case"leonardo":n.quotas&&Object.entries(n.quotas).forEach(([l,a])=>{o.push({name:l==="tokens"?"Tokens":l,used:a.used||0,total:a.total||0,resetAt:a.resetAt||null,unit:a.unit||null,remaining:a.remaining!==void 0?a.remaining:null})});break;case"weavy":n.quotas&&Object.entries(n.quotas).forEach(([l,a])=>{o.push({name:l==="tokens"?"tokens":l,used:a.used||0,total:a.total||0,resetAt:a.resetAt||null,unit:a.unit||null,remaining:a.remaining!==void 0?a.remaining:null})});break;case"cloudflare-ai":n.quotas&&Object.entries(n.quotas).forEach(([l,a])=>{o.push({name:l,used:a.used||0,total:a.total||0,resetAt:a.resetAt||null,unit:a.unit||"neurons"})});break;default:n.quotas&&Object.entries(n.quotas).forEach(([l,a])=>{o.push({name:l,used:a.used||0,total:a.total||0,resetAt:a.resetAt||null,unit:a.unit||null,remaining:a.remaining!==void 0?a.remaining:null})})}}catch(l){return console.error(`Error parsing quota data for ${s}:`,l),[]}const u=et(s);if(u.length>0){const l=new Map(u.map((a,x)=>[a.id,x]));o.sort((a,x)=>{const h=a.modelKey||a.name,p=x.modelKey||x.name,U=l.get(h)??999,G=l.get(p)??999;return U-G})}return o}const W=10;function lt(s){if(!s)return null;try{const n=new Date(s),o=new Date,u=new Date(o.getFullYear(),o.getMonth(),o.getDate()),l=new Date(u);l.setDate(l.getDate()+1);let a="";n>=u&&n<l?a="Today":n>=l&&n<new Date(l.getTime()+1440*60*1e3)?a="Tomorrow":a=n.toLocaleDateString("en-US",{month:"short",day:"numeric"});const x=n.toLocaleTimeString("en-US",{hour:"numeric",minute:"2-digit",hour12:!0});return`${a}, ${x}`}catch{return null}}function ct(s){return s>70?{text:"text-green-600 dark:text-green-400",bg:"bg-green-500",bgLight:"bg-green-500/10",emoji:"🟢"}:s>=30?{text:"text-yellow-600 dark:text-yellow-400",bg:"bg-yellow-500",bgLight:"bg-yellow-500/10",emoji:"🟡"}:{text:"text-red-600 dark:text-red-400",bg:"bg-red-500",bgLight:"bg-red-500/10",emoji:"🔴"}}function dt(s,n){return n==="remaining-asc"?[...s].sort((o,u)=>o.remaining-u.remaining||o.name.localeCompare(u.name)):n==="remaining-desc"?[...s].sort((o,u)=>u.remaining-o.remaining||o.name.localeCompare(u.name)):s}function ut({quotas:s=[],compact:n=!1,sortMode:o="default",showSortLabel:u=!1}){const[l,a]=c.useState(1),x=c.useMemo(()=>s.map((m,f)=>({...m,index:f,remaining:it(m)})),[s]),h=c.useMemo(()=>dt(x,o),[x,o]),p=Math.max(1,Math.ceil(h.length/W));if(c.useEffect(()=>{a(1)},[o,s]),c.useEffect(()=>{a(m=>Math.min(m,p))},[p]),!s||s.length===0)return null;const U=h.slice((l-1)*W,l*W),G=h.length===0?0:(l-1)*W+1,V=Math.min(l*W,h.length),b=n?"py-1 px-1.5":"py-2 px-3",q=n?"text-[11px]":"text-sm",v=n?"text-[11px]":"text-sm",J=n?"text-[10px] leading-tight":"text-xs";return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"text-[10px] text-text-muted",children:[h.length," quota",h.length>1?"s":""]}),u&&e.jsx("div",{className:"rounded-md border border-black/10 bg-black/[0.02] px-2 py-1 text-[10px] text-text-muted dark:border-white/10 dark:bg-white/[0.03]",children:"Sorted by account remaining"})]}),e.jsx("div",{className:"overflow-x-auto",children:e.jsx("table",{className:"w-full table-fixed text-left",children:e.jsx("tbody",{children:U.map(m=>{var B;const f=ct(m.remaining),I=at(m.resetAt),D=lt(m.resetAt),te=((B=m.name)==null?void 0:B.toLowerCase())==="tokens"?Math.max(0,m.total-m.used):m.used;return e.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:[e.jsx("td",{className:`${b} w-[30%]`,children:e.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[e.jsx("span",{className:"text-[10px] shrink-0",children:f.emoji}),e.jsx("span",{className:`${q} font-medium text-text-primary truncate`,children:m.name})]})}),e.jsx("td",{className:`${b} w-[45%]`,children:e.jsxs("div",{className:n?"space-y-1":"space-y-1.5",children:[e.jsx("div",{className:`${n?"h-1":"h-1.5"} rounded-full overflow-hidden border ${f.bgLight} ${m.remaining===0?"border-black/10 dark:border-white/10":"border-transparent"}`,children:e.jsx("div",{className:`h-full transition-all duration-300 ${f.bg}`,style:{width:`${Math.min(m.remaining,100)}%`}})}),e.jsxs("div",{className:`flex items-center justify-between ${n?"text-[10px]":"text-xs"}`,children:[e.jsxs("span",{className:"text-text-muted",children:[te.toLocaleString()," / ",m.total>0?m.total.toLocaleString():"∞"]}),e.jsxs("span",{className:`font-medium ${f.text}`,children:[m.remaining,"%"]})]})]})}),e.jsx("td",{className:`${b} w-[25%]`,children:I!=="-"||D?n?e.jsx("div",{className:`${v} text-text-primary font-medium truncate`,title:D||"",children:I!=="-"?`in ${I}`:D}):e.jsxs("div",{className:"space-y-0.5",children:[I!=="-"&&e.jsxs("div",{className:`${v} text-text-primary font-medium`,children:["in ",I]}),D&&e.jsx("div",{className:`${J} text-text-muted`,children:D})]}):e.jsx("div",{className:`${v} text-text-muted italic`,children:"N/A"})})]},`${m.name}-${m.index}`)})})})}),p>1&&e.jsxs("div",{className:"rounded-md border border-black/10 bg-black/[0.02] px-2 py-1.5 dark:border-white/10 dark:bg-white/[0.03]",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 text-[10px] text-text-muted",children:[e.jsxs("span",{children:["Showing ",G,"-",V," of ",h.length]}),e.jsxs("span",{children:["Page ",l," / ",p]})]}),e.jsxs("div",{className:"mt-1.5 flex items-center justify-end gap-1",children:[e.jsx("button",{type:"button",onClick:()=>a(m=>Math.max(1,m-1)),disabled:l===1,className:"flex h-6 items-center rounded-md border border-black/10 px-2 text-[10px] text-text-primary transition-colors hover:bg-black/5 disabled:cursor-not-allowed disabled:opacity-40 dark:border-white/10 dark:hover:bg-white/5",children:"Prev"}),e.jsx("button",{type:"button",onClick:()=>a(m=>Math.min(p,m+1)),disabled:l===p,className:"flex h-6 items-center rounded-md border border-black/10 px-2 text-[10px] text-text-primary transition-colors hover:bg-black/5 disabled:cursor-not-allowed disabled:opacity-40 dark:border-white/10 dark:hover:bg-white/5",children:"Next"})]})]})]})}function X(s){const n=o=>typeof o=="string"&&/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(o);return n(s.email)?s.email:(n(s.name),s.name)}function mt(s,n,o){if(!o)return s;const u=l=>{var x;const a=(((x=n[l.id])==null?void 0:x.quotas)||[]).map(h=>h.resetAt?new Date(h.resetAt).getTime():Number.POSITIVE_INFINITY).filter(h=>Number.isFinite(h));return a.length>0?Math.min(...a):Number.POSITIVE_INFINITY};return[...s].sort((l,a)=>{const x=u(l)-u(a);return x!==0?x:(l.provider||"").localeCompare(a.provider||"")||(X(l)||"").localeCompare(X(a)||"")})}function Pe(s){const n={};return s.forEach(o=>{n[o.id]=!0}),n}function Z(s,n){const o=new Set(n.map(u=>u.id));return Object.fromEntries(Object.entries(s).filter(([u])=>o.has(u)))}function xt(s){if(!s.total)return{start:0,end:0};const n=(s.page-1)*s.pageSize+1,o=Math.min(s.page*s.pageSize,s.total);return{start:n,end:o}}function ht(s,n,o){return s.eligibleConnections?s.providerFilteredConnections?{icon:"filter_alt_off",title:"No Accounts On This Page",description:"Try moving to another page or refreshing the current filters."}:{icon:"filter_alt_off",title:"No Accounts Match Current Filters",description:n==="all"?"Try changing the account status filter to see more quota trackers.":`No ${o==="inactive"?"turned off":o==="active"?"active":"matching"} accounts found for ${n}.`}:{icon:"cloud_off",title:"No Providers Connected",description:"Connect to providers with OAuth to track your API quota limits and usage."}}function pt(s){const{start:n,end:o}=xt(s);return`Showing ${n}-${o} of ${s.total}`}function bt(s,n){return s||{page:1,pageSize:n,total:0,totalPages:1}}function gt(s,n=0){return s||{eligibleConnections:n,providerFilteredConnections:n}}function de(s,n){return s!==n}function ft(s,n){return(s==null?void 0:s.page)||n}function yt(s){return s||[]}async function ue(s,n){return await s(n)}const he="quotaCacheData";function Me(){if(typeof window>"u")return{};try{const s=window.localStorage.getItem(he);return s?JSON.parse(s):{}}catch(s){return console.error("Error reading quota cache:",s),{}}}function Te(s,n){if(!(typeof window>"u"))try{const o=Me();o[s]={...n,cachedAt:new Date().toISOString()},window.localStorage.setItem(he,JSON.stringify(o))}catch(o){console.error("Error writing quota cache:",o)}}const Oe=6e4,vt=5,Ie="quotaAutoRefresh",wt=[{value:"all",label:"All accounts"},{value:"active",label:"Active"},{value:"inactive",label:"Turned off"}],kt=[{value:"default",label:"Default order"},{value:"remaining-asc",label:"Least credits first"},{value:"remaining-desc",label:"Most credits first"},{value:"balance-asc",label:"Saldo Terendah (Lowest Balance)"},{value:"balance-desc",label:"Saldo Tertinggi (Highest Balance)"}],me=20,De=[10,20,50,100],xe=500;function jt(){const[s,n]=c.useState([]),[o,u]=c.useState({}),[l,a]=c.useState({}),[x,h]=c.useState({}),[p,U]=c.useState(!0),[G,V]=c.useState(null),[b,q]=c.useState(!1),[v,J]=c.useState(!1),[pe,m]=c.useState(60),[f,I]=c.useState(!0),[D,ee]=c.useState(null),[te,B]=c.useState(null),[_e,re]=c.useState(!1),[R,se]=c.useState(null),[Re,Le]=c.useState([]),[A,ne]=c.useState("all"),[Fe,be]=c.useState([]),[L,ge]=c.useState("all"),[P,fe]=c.useState("default"),[F,ze]=c.useState(!1),[Nt,St]=c.useState(!1),[Y,ye]=c.useState(!1),[w,C]=c.useState(1),[$,ae]=c.useState(me),[ie,Q]=c.useState(String(me)),[E,ve]=c.useState({page:1,pageSize:me,total:0,totalPages:1}),[k,we]=c.useState({eligibleConnections:0,providerFilteredConnections:0}),T=c.useRef(null),O=c.useRef(null),j=c.useCallback(async(t=w)=>{try{let r="priority";F?r="expiring":P==="remaining-asc"?r="usage-asc":P==="remaining-desc"?r="usage-desc":P==="balance-asc"?r="balance-asc":P==="balance-desc"&&(r="balance-desc");const i=new URLSearchParams({page:String(t),pageSize:String($),accountStatus:L,sort:r});A!=="all"&&i.set("provider",A);const d=await fetch(`/api/providers/client?${i.toString()}`);if(!d.ok)throw new Error("Failed to fetch connections");const N=await d.json(),g=N.connections||[],y=bt(N.pagination,$),S=gt(N.totals,g.length);return n(g),be(yt(N.providerOptions)),ve(y),we(S),C(ft(N.pagination,t)),g}catch(r){return console.error("Error fetching connections:",r),n([]),be([]),ve({page:1,pageSize:$,total:0,totalPages:1}),we({eligibleConnections:0,providerFilteredConnections:0}),[]}},[L,F,w,$,A,P]),M=c.useCallback(async(t,r)=>{a(i=>({...i,[t]:!0})),h(i=>({...i,[t]:null}));try{const i=await fetch(`/api/usage/${t}`);if(!i.ok){const S=(await i.json().catch(()=>({}))).error||i.statusText;if(i.status===404)return;if(i.status===401){const _={quotas:[],message:S};u(H=>({...H,[t]:_})),Te(t,_);return}throw new Error(`HTTP ${i.status}: ${S}`)}const d=await i.json(),g={quotas:ot(r,d),plan:d.plan||null,message:d.message||null,raw:d};u(y=>({...y,[t]:g})),Te(t,g)}catch(i){h(d=>({...d,[t]:i.message||"Failed to fetch quota"}))}finally{a(i=>({...i,[t]:!1}))}},[]),Ue=c.useCallback(async(t,r)=>{await M(t,r),V(new Date)},[M]),Qe=c.useCallback(async t=>{if(confirm("Delete this connection?")){ee(t);try{if((await fetch(`/api/providers/${t}`,{method:"DELETE"})).ok){if(u(i=>{const d={...i};return delete d[t],d}),a(i=>{const d={...i};return delete d[t],d}),h(i=>{const d={...i};return delete d[t],d}),typeof window<"u")try{const i=Me();i[t]&&(delete i[t],window.localStorage.setItem(he,JSON.stringify(i)))}catch(i){console.error("Error deleting cache entry:",i)}await ue(j,w)}}catch(r){console.error("Error deleting connection:",r)}finally{ee(null)}}},[j,w]),He=c.useCallback(async(t,r)=>{B(t);try{(await fetch(`/api/providers/${t}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({isActive:r})})).ok&&(u(d=>({...d})),await ue(j,w))}catch(i){console.error("Error updating connection status:",i)}finally{B(null)}},[j,w]),Ve=c.useCallback(async t=>{if(!(R!=null&&R.id))return;const r=R.id,i=R.provider;try{(await fetch(`/api/providers/${r}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})).ok&&(await j(),re(!1),se(null),tt.includes(i)&&await M(r,i))}catch(d){console.error("Error saving connection:",d)}},[R,j,M]);c.useEffect(()=>{let t=!1;return fetch("/api/proxy-pools?isActive=true",{cache:"no-store"}).then(r=>r.json()).then(r=>{!t&&(r!=null&&r.proxyPools)&&Le(r.proxyPools)}).catch(()=>{}),()=>{t=!0}},[]);const K=c.useCallback(async()=>{if(!v){J(!0),m(60);try{const t=await j(w);a(Pe(t)),h(r=>Z(r,t)),u(r=>Z(r,t)),await Promise.all(t.map(r=>M(r.id,r.provider))),V(new Date)}catch(t){console.error("Error refreshing all providers:",t)}finally{J(!1)}}},[v,j,M,w]);c.useEffect(()=>{if(!b)return;(async()=>{I(!0);const r=await j(w);I(!1),a(Pe(r)),h(i=>Z(i,r)),u(i=>Z(i,r)),await Promise.all(r.map(i=>M(i.id,i.provider))),V(new Date)})()},[j,M,w,b]);const ke="quotaProviderFilter",je="quotaAccountFilter",Ne="quotaSortMode";c.useEffect(()=>{if(typeof window>"u")return;const t=window.localStorage.getItem(Ie);U(t===null?!0:t==="true");const r=window.localStorage.getItem(ke);r&&ne(r);const i=window.localStorage.getItem(je);i&&ge(i);const d=window.localStorage.getItem(Ne);d&&fe(d),q(!0)},[]),c.useEffect(()=>{typeof window>"u"||!b||window.localStorage.setItem(Ie,String(p))},[p,b]),c.useEffect(()=>{typeof window>"u"||!b||window.localStorage.setItem(ke,A)},[A,b]),c.useEffect(()=>{typeof window>"u"||!b||window.localStorage.setItem(je,L)},[L,b]),c.useEffect(()=>{typeof window>"u"||!b||window.localStorage.setItem(Ne,P)},[P,b]),c.useEffect(()=>{if(!b||!p){T.current&&(clearInterval(T.current),T.current=null),O.current&&(clearInterval(O.current),O.current=null);return}return T.current=setInterval(()=>{K()},Oe),O.current=setInterval(()=>{m(t=>t<=1?60:t-1)},1e3),()=>{T.current&&clearInterval(T.current),O.current&&clearInterval(O.current)}},[p,K,b]),c.useEffect(()=>{const t=()=>{document.hidden?(T.current&&(clearInterval(T.current),T.current=null),O.current&&(clearInterval(O.current),O.current=null)):p&&b&&(T.current=setInterval(K,Oe),O.current=setInterval(()=>{m(r=>r<=1?60:r-1)},1e3))};return document.addEventListener("visibilitychange",t),()=>{document.removeEventListener("visibilitychange",t)}},[p,K,b]);const z=c.useMemo(()=>mt(s,o,F),[s,o,F]),Se=t=>{var i;const r=(i=o[t.id])==null?void 0:i.quotas;return r!=null&&r.length?r.some(d=>!d.total||d.total<=0?!1:$e(d.used,d.total)<=vt):!1},Ce=t=>{const r=o[t.id];return r&&r.message==="Account disabled (Credits exhausted)"},oe=c.useCallback(async(t,r)=>{if(!(!t.length||Y)){ye(!0);try{await Promise.all(t.map(i=>fetch(`/api/providers/${i}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({isActive:r})}))),await ue(j,w)}catch(i){console.error("Error bulk toggling connections:",i)}finally{ye(!1)}}},[Y,j,w]),Be=()=>{const t=z.filter(r=>(r.isActive??!0)&&Se(r)).map(r=>r.id);oe(t,!1)},Ye=()=>{const t=z.filter(r=>(r.isActive??!0)&&Ce(r)).map(r=>r.id);oe(t,!1)},Ke=()=>{const t=z.filter(r=>!(r.isActive??!0)&&!Se(r)&&!Ce(r)).map(r=>r.id);oe(t,!0)},{totalCredits:We,providerStats:Ge,exhaustedCount:Ee}=c.useMemo(()=>{var N;let t=0;const r={};let i=0;z.forEach(g=>{const y=o[g.id];if(y&&y.message==="Account disabled (Credits exhausted)"&&(i+=1),!y)return;const S=g.provider;r[S]||(r[S]={accounts:0,credits:0}),r[S].accounts+=1,y.quotas&&y.quotas.forEach(_=>{let H=typeof _.remaining=="number"&&Number.isFinite(_.remaining)?_.remaining:Math.max(0,(_.total||0)-(_.used||0));Number.isFinite(H)&&H>0&&S!=="cloudflare-ai"&&(t+=H,r[S].credits+=H)})});const d=((N=k==null?void 0:k.providerCounts)==null?void 0:N["cloudflare-ai"])||0;if(d>0){const g=(k==null?void 0:k.cloudflareAi)!==void 0?Math.max(0,k.cloudflareAi.total-k.cloudflareAi.used):d*1e4;r["cloudflare-ai"]||(r["cloudflare-ai"]={accounts:d,credits:0}),r["cloudflare-ai"].accounts=d,r["cloudflare-ai"].credits=g,t+=g}return{totalCredits:t,providerStats:r,exhaustedCount:i}},[o,z,k]),Je=k.eligibleConnections>0,Ze=z.length>0,le=ht(k,A,L),Xe=pt(E),qe=!De.includes($);return!f&&!Je?e.jsx(ce,{padding:"lg",children:e.jsxs("div",{className:"text-center py-12",children:[e.jsx("span",{className:"material-symbols-outlined text-[64px] text-text-muted opacity-20",children:"cloud_off"}),e.jsx("h3",{className:"mt-4 text-lg font-semibold text-text-primary",children:"No Providers Connected"}),e.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.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-sm font-medium text-text-primary px-1",children:[e.jsxs("div",{className:"flex items-center gap-1.5 bg-black/5 dark:bg-white/10 px-2.5 py-1 rounded-md",title:"Total active accounts on this page",children:[e.jsx("span",{className:"material-symbols-outlined text-[16px] text-text-muted",children:"group"}),e.jsxs("span",{children:[k.providerFilteredConnections," Accounts"]})]}),e.jsxs("div",{className:"flex items-center gap-1.5 bg-primary/10 px-2.5 py-1 rounded-md",title:"Total credits across these accounts",children:[e.jsx("span",{className:"material-symbols-outlined text-[16px] text-primary",children:"database"}),e.jsxs("span",{className:"text-primary",children:[Math.floor(We)," Credits"]})]}),Ee>0&&e.jsxs("div",{className:"flex items-center gap-1.5 bg-red-500/10 px-2.5 py-1 rounded-md",title:"Total exhausted accounts",children:[e.jsx("span",{className:"material-symbols-outlined text-[16px] text-red-500",children:"warning"}),e.jsxs("span",{className:"text-red-500",children:[Ee," Exhausted"]})]}),e.jsx("div",{className:"flex flex-wrap items-center gap-1 ml-2",children:Object.entries(Ge).map(([t,r])=>e.jsxs("div",{className:"flex items-center gap-1 bg-black/5 dark:bg-white/5 px-2 py-0.5 rounded text-xs text-text-muted border border-black/10 dark:border-white/10",title:`${r.accounts} accounts`,children:[e.jsx("span",{className:"capitalize",children:t}),": ",e.jsx("span",{className:"font-semibold text-text-primary",children:Math.floor(r.credits)})]},t))})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-1 justify-end",children:[e.jsxs("div",{className:"flex flex-wrap gap-1",children:[e.jsxs("button",{type:"button",onClick:()=>{de(A,"all")&&C(1),ne("all")},className:`flex h-8 items-center gap-1.5 rounded-lg px-2.5 text-xs font-medium transition-colors ${A==="all"?"bg-primary/15 text-primary border border-primary/30":"bg-black/5 text-text-muted border border-transparent hover:bg-black/10 dark:bg-white/5 dark:hover:bg-white/10"}`,children:[e.jsx("span",{className:"material-symbols-outlined text-[14px]",children:"apps"}),e.jsx("span",{children:"All"})]}),Fe.map(t=>e.jsxs("button",{type:"button",onClick:()=>{de(A,t)&&C(1),ne(t)},className:`flex h-8 items-center gap-1.5 rounded-lg px-2.5 text-xs font-medium transition-colors ${A===t?"bg-primary/15 text-primary border border-primary/30":"bg-black/5 text-text-muted border border-transparent hover:bg-black/10 dark:bg-white/5 dark:hover:bg-white/10"}`,children:[e.jsx(Ae,{src:t==="codebuddy"||t==="cb"?"/providers/codebuddy.svg":`/providers/${t}.png`,alt:t,size:16,className:"size-4 rounded object-contain",fallbackText:t.slice(0,2).toUpperCase()}),e.jsx("span",{className:"capitalize",children:t})]},t))]}),e.jsx("select",{value:L,onChange:t=>{const r=t.target.value;de(L,r)&&C(1),ge(r)},className:"h-8 rounded-lg border border-black/10 bg-black/[0.02] px-2 text-xs text-text-primary outline-none transition-colors hover:bg-black/5 dark:border-white/10 dark:bg-white/[0.03] dark:hover:bg-white/10","aria-label":"Filter accounts by status",children:wt.map(t=>e.jsx("option",{value:t.value,children:t.label},t.value))}),e.jsx("select",{value:P,onChange:t=>fe(t.target.value),className:"h-8 rounded-lg border border-black/10 bg-black/[0.02] px-2 text-xs text-text-primary outline-none transition-colors hover:bg-black/5 dark:border-white/10 dark:bg-white/[0.03] dark:hover:bg-white/10","aria-label":"Sort quotas by remaining",children:kt.map(t=>e.jsx("option",{value:t.value,children:t.label},t.value))}),e.jsxs("button",{type:"button",onClick:()=>ze(t=>!t),"aria-pressed":F,className:`flex h-8 shrink-0 items-center gap-1 rounded-lg border px-2 text-xs transition-colors ${F?"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:[e.jsx("span",{className:"material-symbols-outlined text-[14px]",children:"hourglass_top"}),e.jsx("span",{className:"hidden sm:inline",children:"Expiring first"})]}),e.jsxs("button",{type:"button",onClick:Be,disabled:Y,className:"flex h-8 shrink-0 items-center gap-1 rounded-lg border border-red-500/30 px-2 text-xs text-red-500 transition-colors hover:bg-red-500/10 disabled:opacity-50",title:"Disable connections with depleted quota on the current page",children:[e.jsx("span",{className:"material-symbols-outlined text-[14px]",children:"block"}),e.jsx("span",{className:"hidden sm:inline",children:"Turn off Empty"})]}),e.jsxs("button",{type:"button",onClick:Ye,disabled:Y,className:"flex h-8 shrink-0 items-center gap-1 rounded-lg border border-red-500/30 px-2 text-xs text-red-500 transition-colors hover:bg-red-500/10 disabled:opacity-50",title:"Disable connections that are exhausted",children:[e.jsx("span",{className:"material-symbols-outlined text-[14px]",children:"block"}),e.jsx("span",{className:"hidden sm:inline",children:"Disable Exhausted"})]}),e.jsxs("button",{type:"button",onClick:Ke,disabled:Y,className:"flex h-8 shrink-0 items-center gap-1 rounded-lg border border-emerald-500/30 px-2 text-xs text-emerald-500 transition-colors hover:bg-emerald-500/10 disabled:opacity-50",title:"Enable connections that still have quota on the current page",children:[e.jsx("span",{className:"material-symbols-outlined text-[14px]",children:"check_circle"}),e.jsx("span",{className:"hidden sm:inline",children:"Turn on Available"})]}),e.jsxs("button",{onClick:()=>U(t=>!t),className:"flex h-8 shrink-0 items-center gap-1 rounded-lg border border-black/10 px-2 text-xs transition-colors hover:bg-black/5 dark:border-white/10 dark:hover:bg-white/5",title:p?"Disable auto-refresh":"Enable auto-refresh",children:[e.jsx("span",{className:`material-symbols-outlined text-[14px] ${p?"text-primary":"text-text-muted"}`,children:p?"toggle_on":"toggle_off"}),e.jsx("span",{className:"hidden text-text-primary sm:inline",children:"Auto-refresh"}),p&&e.jsxs("span",{className:"text-[10px] text-text-muted tabular-nums",children:["(",pe,"s)"]})]}),e.jsx("button",{type:"button",onClick:K,disabled:v,className:"flex h-8 shrink-0 items-center gap-1 rounded-lg border border-black/10 px-2 text-xs text-text-primary transition-colors hover:bg-black/5 dark:border-white/10 dark:hover:bg-white/5 disabled:opacity-50",title:"Refresh all",children:e.jsx("span",{className:`material-symbols-outlined text-[14px] ${v?"animate-spin":""}`,children:"refresh"})})]})]}),(F||P!=="default")&&e.jsx("div",{className:"rounded-xl border border-amber-500/20 bg-amber-500/10 px-3 py-2 text-xs text-amber-700 dark:text-amber-300 mb-3",children:"Sorting currently reorders accounts inside the current page. Cross-page ordering still follows backend pagination. Try increasing the page size to sort across more accounts."}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:!f&&!Ze?e.jsx("div",{className:"col-span-1 md:col-span-2",children:e.jsx(ce,{padding:"lg",children:e.jsxs("div",{className:"text-center py-12",children:[e.jsx("span",{className:"material-symbols-outlined text-[64px] text-text-muted opacity-20",children:le.icon}),e.jsx("h3",{className:"mt-4 text-lg font-semibold text-text-primary",children:le.title}),e.jsx("p",{className:"mt-2 text-sm text-text-muted max-w-md mx-auto",children:le.description})]})})}):z.map(t=>{var y;const r=o[t.id],i=l[t.id],d=x[t.id],N=t.isActive===!1,g=D===t.id||te===t.id;return e.jsxs(ce,{padding:"none",className:`min-w-0 ${N?"opacity-60":""}`,children:[e.jsx("div",{className:"px-3 py-2 border-b border-black/10 dark:border-white/10",children:e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx("div",{className:"w-8 h-8 shrink-0 rounded-md flex items-center justify-center overflow-hidden",children:e.jsx(Ae,{src:t.provider==="codebuddy"||t.provider==="cb"?"/providers/codebuddy.svg":`/providers/${t.provider}.png`,alt:t.provider,size:32,className:"object-contain",fallbackText:((y=t.provider)==null?void 0:y.slice(0,2).toUpperCase())||"PR"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("h3",{className:"text-sm font-semibold text-text-primary capitalize truncate",children:t.provider}),X(t)?e.jsx("p",{className:"text-xs text-text-muted truncate",children:X(t)}):null]})]}),e.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[e.jsx("button",{type:"button",onClick:()=>Ue(t.id,t.provider),disabled:i||g,"aria-label":"Refresh quota",className:"p-1.5 rounded-lg hover:bg-black/5 dark:hover:bg-white/5 transition-colors disabled:opacity-50",title:"Refresh quota",children:e.jsx("span",{className:`material-symbols-outlined text-[18px] text-text-muted ${i?"animate-spin":""}`,children:"refresh"})}),e.jsx("button",{type:"button",onClick:()=>{se(t),re(!0)},disabled:g,"aria-label":"Edit connection",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:e.jsx("span",{className:"material-symbols-outlined text-[18px]",children:"edit"})}),e.jsx("button",{type:"button",onClick:()=>Qe(t.id),disabled:g,"aria-label":"Delete connection",className:"p-1.5 rounded-lg hover:bg-red-500/10 text-red-500 transition-colors disabled:opacity-50",title:"Delete connection",children:e.jsx("span",{className:`material-symbols-outlined text-[18px] ${D===t.id?"animate-pulse":""}`,children:"delete"})}),e.jsx("div",{className:"inline-flex items-center pl-0.5",title:t.isActive??!0?"Disable connection":"Enable connection",children:e.jsx(st,{size:"sm",checked:t.isActive??!0,disabled:g,onChange:S=>He(t.id,S)})})]})]})}),e.jsx("div",{className:"px-2 py-1.5",children:i?e.jsx("div",{className:"text-center py-5 text-text-muted",children:e.jsx("span",{className:"material-symbols-outlined text-[28px] animate-spin",children:"progress_activity"})}):d?e.jsxs("div",{className:"text-center py-5",children:[e.jsx("span",{className:"material-symbols-outlined text-[28px] text-red-500",children:"error"}),e.jsx("p",{className:"mt-1.5 text-xs text-text-muted",children:d})]}):r!=null&&r.message?e.jsx("div",{className:"text-center py-5",children:e.jsx("p",{className:"text-xs text-text-muted",children:r.message})}):e.jsx(ut,{quotas:r==null?void 0:r.quotas,compact:!0,sortMode:"default",showSortLabel:t.provider==="codex"&&P!=="default"})})]},t.id)})}),e.jsx("div",{className:"rounded-xl border border-black/10 bg-black/[0.02] px-3 py-2 dark:border-white/10 dark:bg-white/[0.03]",children:e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsx("span",{className:"text-xs text-text-muted",children:Xe}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs("select",{value:qe?"custom":String($),onChange:t=>{const r=t.target.value;if(r==="custom")return;const i=Number.parseInt(r,10);Number.isFinite(i)&&(C(1),ae(i),Q(String(i)))},className:"h-8 rounded-lg border border-black/10 bg-black/[0.02] px-2 text-xs text-text-primary outline-none transition-colors hover:bg-black/5 dark:border-white/10 dark:bg-white/[0.03] dark:hover:bg-white/10","aria-label":"Accounts per page",children:[De.map(t=>e.jsxs("option",{value:String(t),children:[t," / page"]},t)),e.jsx("option",{value:"500",children:"500 / page"}),e.jsx("option",{value:"1000",children:"1000 / page"}),e.jsx("option",{value:"custom",children:"Custom"})]}),e.jsx("input",{type:"number",min:"1",max:String(xe),inputMode:"numeric",value:ie,onChange:t=>Q(t.target.value),onBlur:()=>{const t=Number.parseInt(ie,10);if(!Number.isFinite(t)){Q(String($));return}const r=Math.min(xe,Math.max(1,t));C(1),ae(r),Q(String(r))},onKeyDown:t=>{if(t.key!=="Enter")return;const r=Number.parseInt(ie,10);if(!Number.isFinite(r)){Q(String($));return}const i=Math.min(xe,Math.max(1,r));C(1),ae(i),Q(String(i))},className:"h-8 w-20 rounded-lg border border-black/10 bg-black/[0.02] px-2 text-xs text-text-primary outline-none transition-colors hover:bg-black/5 dark:border-white/10 dark:bg-white/[0.03] dark:hover:bg-white/10","aria-label":"Custom accounts per page",placeholder:"Custom"}),e.jsxs("span",{className:"text-xs text-text-muted",children:["Page ",E.page," / ",E.totalPages]})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("button",{suppressHydrationWarning:!0,type:"button",onClick:()=>C(1),disabled:E.page<=1||f||v,className:"flex h-8 items-center rounded-lg border border-black/10 px-3 text-xs text-text-primary transition-colors hover:bg-black/5 disabled:cursor-not-allowed disabled:opacity-40 dark:border-white/10 dark:hover:bg-white/5",children:"First Page"}),e.jsx("button",{suppressHydrationWarning:!0,type:"button",onClick:()=>C(t=>Math.max(1,t-1)),disabled:E.page<=1||f||v,className:"flex h-8 w-8 items-center justify-center rounded-lg border border-black/10 text-text-primary transition-colors hover:bg-black/5 disabled:cursor-not-allowed disabled:opacity-40 dark:border-white/10 dark:hover:bg-white/5","aria-label":"Previous accounts page",children:e.jsx("span",{className:"material-symbols-outlined text-[16px]",children:"chevron_left"})}),e.jsx("button",{suppressHydrationWarning:!0,type:"button",onClick:()=>C(t=>Math.min(E.totalPages,t+1)),disabled:E.page>=E.totalPages||f||v,className:"flex h-8 w-8 items-center justify-center rounded-lg border border-black/10 text-text-primary transition-colors hover:bg-black/5 disabled:cursor-not-allowed disabled:opacity-40 dark:border-white/10 dark:hover:bg-white/5","aria-label":"Next accounts page",children:e.jsx("span",{className:"material-symbols-outlined text-[16px]",children:"chevron_right"})}),e.jsx("button",{suppressHydrationWarning:!0,type:"button",onClick:()=>C(E.totalPages),disabled:E.page>=E.totalPages||f||v,className:"flex h-8 items-center rounded-lg border border-black/10 px-3 text-xs text-text-primary transition-colors hover:bg-black/5 disabled:cursor-not-allowed disabled:opacity-40 dark:border-white/10 dark:hover:bg-white/5",children:"Last Page"})]})]})}),e.jsx(nt,{isOpen:_e,connection:R,proxyPools:Re,onSave:Ve,onClose:()=>{re(!1),se(null)}})]})}function Ot(){return e.jsx(c.Suspense,{fallback:e.jsx(rt,{}),children:e.jsx(jt,{})})}export{Ot as default};
@@ -1 +1 @@
1
- import{j as e}from"./index.CShjRV_B.js";import{b as s}from"./router.Cjj1--8t.js";import"./zustand.akaTi5uX.js";function u(){const[a,o]=s.useState(""),[l,r]=s.useState(null),[n,c]=s.useState(!1),i=async()=>{c(!0);try{const t=await fetch("/api/web/fetch",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:a})});r(await t.json())}catch(t){r({error:t.message})}c(!1)};return e.jsxs("div",{className:"space-y-6 p-6",children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Web Fetch"}),e.jsx("p",{className:"text-text-muted",children:"Fetch web content via Firecrawl, Jina, Tavily, or TinyFish"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{className:"flex-1 p-3 rounded-lg border",placeholder:"https://example.com",value:a,onChange:t=>o(t.target.value)}),e.jsx("button",{onClick:i,disabled:n,className:"px-4 py-2 bg-primary text-white rounded-lg",children:n?"Fetching...":"Fetch"})]}),l&&e.jsx("pre",{className:"p-4 bg-black/5 rounded-lg text-sm overflow-auto max-h-96",children:JSON.stringify(l,null,2)})]})}export{u as default};
1
+ import{j as e}from"./index.Be3gbrBl.js";import{b as s}from"./router.Cjj1--8t.js";import"./zustand.akaTi5uX.js";function u(){const[a,o]=s.useState(""),[l,r]=s.useState(null),[n,c]=s.useState(!1),i=async()=>{c(!0);try{const t=await fetch("/api/web/fetch",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:a})});r(await t.json())}catch(t){r({error:t.message})}c(!1)};return e.jsxs("div",{className:"space-y-6 p-6",children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Web Fetch"}),e.jsx("p",{className:"text-text-muted",children:"Fetch web content via Firecrawl, Jina, Tavily, or TinyFish"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{className:"flex-1 p-3 rounded-lg border",placeholder:"https://example.com",value:a,onChange:t=>o(t.target.value)}),e.jsx("button",{onClick:i,disabled:n,className:"px-4 py-2 bg-primary text-white rounded-lg",children:n?"Fetching...":"Fetch"})]}),l&&e.jsx("pre",{className:"p-4 bg-black/5 rounded-lg text-sm overflow-auto max-h-96",children:JSON.stringify(l,null,2)})]})}export{u as default};
@@ -1 +1 @@
1
- import{j as e,P as i,u as d}from"./index.CShjRV_B.js";import{b as l,d as n}from"./router.Cjj1--8t.js";import"./zustand.akaTi5uX.js";function c(){const[t,r]=l.useState(!1),s=n();return e.jsxs("nav",{className:"fixed top-0 z-50 w-full bg-[#181411]/80 backdrop-blur-md border-b border-[#3a2f27]",children:[e.jsxs("div",{className:"max-w-7xl mx-auto px-6 h-16 flex items-center justify-between",children:[e.jsxs("button",{type:"button",className:"flex items-center gap-3 cursor-pointer bg-transparent border-none p-0",onClick:()=>s("/"),"aria-label":"Navigate to home",children:[e.jsx("img",{src:"/logo_fsrouter.png",alt:"FSRouter v2",className:"size-8 rounded object-cover"}),e.jsx("h2",{className:"text-white text-xl font-bold tracking-tight",children:"FSRouter"})]}),e.jsxs("div",{className:"hidden md:flex items-center gap-8",children:[e.jsx("a",{className:"text-gray-300 hover:text-white text-sm font-medium transition-colors",href:"#features",children:"Features"}),e.jsx("a",{className:"text-gray-300 hover:text-white text-sm font-medium transition-colors",href:"#how-it-works",children:"How it Works"}),e.jsx("a",{className:"text-gray-300 hover:text-white text-sm font-medium transition-colors",href:"https://github.com/nexusrouters/fsrouter#readme",target:"_blank",rel:"noopener noreferrer",children:"Docs"}),e.jsxs("a",{className:"text-gray-300 hover:text-white text-sm font-medium transition-colors flex items-center gap-1",href:"https://github.com/nexusrouters/fsrouter",target:"_blank",rel:"noopener noreferrer",children:["GitHub ",e.jsx("span",{className:"material-symbols-outlined text-[14px]",children:"open_in_new"})]})]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("button",{onClick:()=>s("/dashboard"),className:"hidden sm:flex h-9 items-center justify-center rounded-lg px-4 bg-[#f97815] hover:bg-[#e0650a] transition-all text-[#181411] text-sm font-bold shadow-[0_0_15px_rgba(249,120,21,0.4)] hover:shadow-[0_0_20px_rgba(249,120,21,0.6)]",children:"Get Started"}),e.jsx("button",{className:"md:hidden text-white",onClick:()=>r(!t),children:e.jsx("span",{className:"material-symbols-outlined",children:t?"close":"menu"})})]})]}),t&&e.jsx("div",{className:"md:hidden border-t border-[#3a2f27] bg-[#181411]/95 backdrop-blur-md",children:e.jsxs("div",{className:"flex flex-col gap-4 p-6",children:[e.jsx("a",{className:"text-gray-300 hover:text-white text-sm font-medium transition-colors",href:"#features",onClick:()=>r(!1),children:"Features"}),e.jsx("a",{className:"text-gray-300 hover:text-white text-sm font-medium transition-colors",href:"#how-it-works",onClick:()=>r(!1),children:"How it Works"}),e.jsx("a",{className:"text-gray-300 hover:text-white text-sm font-medium transition-colors",href:"https://github.com/nexusrouters/fsrouter#readme",target:"_blank",rel:"noopener noreferrer",children:"Docs"}),e.jsx("a",{className:"text-gray-300 hover:text-white text-sm font-medium transition-colors",href:"https://github.com/nexusrouters/fsrouter",target:"_blank",rel:"noopener noreferrer",children:"GitHub"}),e.jsx("button",{onClick:()=>s("/dashboard"),className:"h-9 rounded-lg bg-[#f97815] hover:bg-[#e0650a] text-[#181411] text-sm font-bold",children:"Get Started"})]})})]})}function x(){return e.jsxs("section",{className:"relative pt-32 pb-20 px-6 min-h-[90vh] flex flex-col items-center justify-center overflow-hidden",children:[e.jsx("div",{className:"absolute top-0 left-1/2 -translate-x-1/2 w-[1000px] h-[500px] bg-[#f97815]/10 rounded-full blur-[120px] pointer-events-none"}),e.jsxs("div",{className:"relative z-10 max-w-4xl w-full text-center flex flex-col items-center gap-8",children:[e.jsxs("div",{className:"inline-flex items-center gap-2 rounded-full border border-[#3a2f27] bg-[#23180f]/50 px-3 py-1 text-xs font-medium text-[#f97815]",children:[e.jsx("span",{className:"flex h-2 w-2 rounded-full bg-[#f97815] animate-pulse"}),"v1.0 is now live"]}),e.jsxs("h1",{className:"text-5xl md:text-7xl font-black leading-[1.1] tracking-tight",children:["One Endpoint for ",e.jsx("br",{}),e.jsx("span",{className:"text-[#f97815]",children:"All AI Providers"})]}),e.jsx("p",{className:"text-lg md:text-xl text-gray-400 max-w-2xl mx-auto font-light",children:"AI endpoint proxy with web dashboard - A JavaScript port of CLIProxyAPI. Works seamlessly with Claude Code, OpenAI Codex, Cline, RooCode, and other CLI tools."}),e.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-4 w-full",children:[e.jsxs("button",{className:"h-12 px-8 rounded-lg bg-[#f97815] hover:bg-[#e0650a] text-[#181411] text-base font-bold transition-all shadow-[0_0_15px_rgba(249,120,21,0.4)] flex items-center gap-2",children:[e.jsx("span",{className:"material-symbols-outlined",children:"rocket_launch"}),"Get Started"]}),e.jsxs("a",{href:"https://github.com/nexusrouters/fsrouter",target:"_blank",rel:"noopener noreferrer",className:"h-12 px-8 rounded-lg border border-[#3a2f27] bg-[#23180f] hover:bg-[#3a2f27] text-white text-base font-bold transition-all flex items-center gap-2",children:[e.jsx("span",{className:"material-symbols-outlined",children:"code"}),"View on GitHub"]})]})]})]})}const m=[{id:"claude",name:"Claude Code",image:"/providers/claude.png"},{id:"codex",name:"OpenAI Codex",image:"/providers/codex.png"},{id:"cline",name:"Cline",image:"/providers/cline.png"},{id:"cursor",name:"Cursor",image:"/providers/cursor.png"}],o=[{id:"openai",name:"OpenAI",color:"bg-emerald-500",textColor:"text-white"},{id:"anthropic",name:"Anthropic",color:"bg-orange-400",textColor:"text-white"},{id:"gemini",name:"Gemini",color:"bg-blue-500",textColor:"text-white"},{id:"github",name:"GitHub Copilot",color:"bg-gray-700",textColor:"text-white"}];function h(){const[t,r]=l.useState(0);return l.useEffect(()=>{const s=setInterval(()=>{r(a=>(a+1)%o.length)},2e3);return()=>clearInterval(s)},[]),e.jsxs("div",{className:"mt-16 w-full max-w-4xl relative h-[360px] hidden md:flex items-center justify-center animate-[float_6s_ease-in-out_infinite]",children:[e.jsxs("div",{className:"relative z-20 w-32 h-32 rounded-full bg-[#23180f] border-2 border-[#f97815] shadow-[0_0_40px_rgba(249,120,21,0.3)] flex flex-col items-center justify-center gap-1 group cursor-pointer hover:scale-105 transition-transform duration-500",children:[e.jsx("span",{className:"material-symbols-outlined text-4xl text-[#f97815]",children:"hub"}),e.jsx("span",{className:"text-xs font-bold text-white tracking-widest uppercase",children:"FSRouter"}),e.jsx("div",{className:"absolute inset-0 rounded-full border border-[#f97815]/30 animate-ping opacity-20"})]}),e.jsx("div",{className:"absolute left-0 top-1/2 -translate-y-1/2 flex flex-col gap-7",children:m.map(s=>e.jsx("div",{className:"flex items-center gap-3 opacity-70 hover:opacity-100 transition-opacity group",children:e.jsx("div",{className:"w-16 h-16 rounded-2xl bg-[#23180f] border border-[#3a2f27] flex items-center justify-center overflow-hidden p-2 hover:border-[#f97815]/50 transition-all hover:scale-105",children:e.jsx(i,{src:s.image,alt:s.name,size:48,className:"object-contain rounded-xl max-w-[48px] max-h-[48px]",fallbackText:s.name.slice(0,2).toUpperCase()})})},s.id))}),e.jsxs("svg",{className:"absolute inset-0 w-full h-full z-10 pointer-events-none stroke-yellow-700",xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("path",{className:"animate-[dash_2s_linear_infinite]",d:"M 60 50 C 250 70, 250 180, 360 180",fill:"none",strokeDasharray:"5,5",strokeWidth:"2"}),e.jsx("path",{className:"animate-[dash_2s_linear_infinite]",d:"M 60 140 C 250 140, 250 180, 360 180",fill:"none",strokeDasharray:"5,5",strokeWidth:"2"}),e.jsx("path",{className:"animate-[dash_2s_linear_infinite]",d:"M 60 210 C 250 210, 250 180, 360 180",fill:"none",strokeDasharray:"5,5",strokeWidth:"2"}),e.jsx("path",{className:"animate-[dash_2s_linear_infinite]",d:"M 60 300 C 250 280, 250 180, 360 180",fill:"none",strokeDasharray:"5,5",strokeWidth:"2"})]}),e.jsxs("svg",{className:"absolute inset-0 w-full h-full z-10 pointer-events-none",xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("path",{d:"M 440 180 C 550 180, 550 50, 740 50",fill:"none",stroke:t===0?"#f97815":"rgb(75, 85, 99)",strokeWidth:t===0?"3":"2",className:t===0?"animate-pulse":""}),e.jsx("path",{d:"M 440 180 C 550 180, 550 130, 740 130",fill:"none",stroke:t===1?"#f97815":"rgb(75, 85, 99)",strokeWidth:t===1?"3":"2",className:t===1?"animate-pulse":""}),e.jsx("path",{d:"M 440 180 C 550 180, 550 230, 740 230",fill:"none",stroke:t===2?"#f97815":"rgb(75, 85, 99)",strokeWidth:t===2?"3":"2",className:t===2?"animate-pulse":""}),e.jsx("path",{d:"M 440 180 C 550 180, 550 310, 740 310",fill:"none",stroke:t===3?"#f97815":"rgb(75, 85, 99)",strokeWidth:t===3?"3":"2",className:t===3?"animate-pulse":""})]}),e.jsx("div",{className:"absolute right-0 top-0 bottom-0 flex flex-col justify-between py-6",children:o.map((s,a)=>e.jsx("div",{className:`px-4 py-2 rounded-lg ${s.color} ${s.textColor} flex items-center justify-center font-bold text-xs shadow-lg hover:scale-110 transition-all cursor-help min-w-[140px] ${t===a?"ring-4 ring-[#f97815]/50 scale-110":""}`,title:s.name,children:s.name},s.id))}),e.jsx("div",{className:"md:hidden mt-8 w-full p-4 rounded-lg bg-[#23180f] border border-[#3a2f27]",children:e.jsx("p",{className:"text-sm text-center text-gray-400",children:"Interactive diagram visible on desktop"})})]})}function u(){return e.jsx("section",{className:"py-24 border-y border-[#3a2f27] bg-[#23180f]/30",id:"how-it-works",children:e.jsxs("div",{className:"max-w-7xl mx-auto px-6",children:[e.jsxs("div",{className:"mb-16",children:[e.jsx("h2",{className:"text-3xl md:text-4xl font-bold mb-4",children:"How FSRouter Works"}),e.jsx("p",{className:"text-gray-400 max-w-xl text-lg",children:"Data flows seamlessly from your application through our intelligent routing layer to the best provider for the job."})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-8 relative",children:[e.jsx("div",{className:"hidden md:block absolute top-12 left-[16%] right-[16%] h-[2px] bg-linear-to-r from-gray-700 via-[#f97815] to-gray-700 -z-10"}),e.jsxs("div",{className:"flex flex-col gap-6 relative group",children:[e.jsx("div",{className:"w-24 h-24 rounded-2xl bg-[#181411] border border-[#3a2f27] flex items-center justify-center shadow-xl group-hover:border-gray-500 transition-colors z-10 mx-auto md:mx-0",children:e.jsx("span",{className:"material-symbols-outlined text-4xl text-gray-300",children:"terminal"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-xl font-bold mb-2",children:"1. CLI & SDKs"}),e.jsx("p",{className:"text-sm text-gray-400",children:"Your requests start from your favorite tools or our unified SDK. Just change the base URL."})]})]}),e.jsxs("div",{className:"flex flex-col gap-6 relative group md:items-center md:text-center",children:[e.jsx("div",{className:"w-24 h-24 rounded-2xl bg-[#181411] border-2 border-[#f97815] flex items-center justify-center shadow-[0_0_30px_rgba(249,120,21,0.2)] z-10 mx-auto",children:e.jsx("span",{className:"material-symbols-outlined text-4xl text-[#f97815] animate-pulse",children:"hub"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-xl font-bold mb-2 text-[#f97815]",children:"2. FSRouter Hub"}),e.jsx("p",{className:"text-sm text-gray-400",children:"Our engine analyzes the prompt, checks provider health, and routes for lowest latency or cost."})]})]}),e.jsxs("div",{className:"flex flex-col gap-6 relative group md:items-end md:text-right",children:[e.jsx("div",{className:"w-24 h-24 rounded-2xl bg-[#181411] border border-[#3a2f27] flex items-center justify-center shadow-xl group-hover:border-gray-500 transition-colors z-10 mx-auto md:mx-0",children:e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsx("div",{className:"w-6 h-6 rounded bg-white/10"}),e.jsx("div",{className:"w-6 h-6 rounded bg-white/10"}),e.jsx("div",{className:"w-6 h-6 rounded bg-white/10"}),e.jsx("div",{className:"w-6 h-6 rounded bg-white/10"})]})}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-xl font-bold mb-2",children:"3. AI Providers"}),e.jsx("p",{className:"text-sm text-gray-400",children:"The request is fulfilled by OpenAI, Anthropic, Gemini, or others instantly."})]})]})]})]})})}const f=[{icon:"link",title:"Unified Endpoint",desc:"Access all providers via a single standard API URL.",colors:{border:"hover:border-blue-500/50",bg:"hover:bg-blue-500/5",iconBg:"bg-blue-500/10",iconText:"text-blue-500",titleHover:"group-hover:text-blue-400"}},{icon:"bolt",title:"Easy Setup",desc:"Get up and running in minutes with npx command.",colors:{border:"hover:border-orange-500/50",bg:"hover:bg-orange-500/5",iconBg:"bg-orange-500/10",iconText:"text-orange-500",titleHover:"group-hover:text-orange-400"}},{icon:"shield_with_heart",title:"Model Fallback",desc:"Automatically switch providers on failure or high latency.",colors:{border:"hover:border-rose-500/50",bg:"hover:bg-rose-500/5",iconBg:"bg-rose-500/10",iconText:"text-rose-500",titleHover:"group-hover:text-rose-400"}},{icon:"monitoring",title:"Usage Tracking",desc:"Detailed analytics and cost monitoring across all models.",colors:{border:"hover:border-purple-500/50",bg:"hover:bg-purple-500/5",iconBg:"bg-purple-500/10",iconText:"text-purple-500",titleHover:"group-hover:text-purple-400"}},{icon:"key",title:"OAuth & API Keys",desc:"Securely manage credentials in one vault.",colors:{border:"hover:border-amber-500/50",bg:"hover:bg-amber-500/5",iconBg:"bg-amber-500/10",iconText:"text-amber-500",titleHover:"group-hover:text-amber-400"}},{icon:"cloud_sync",title:"Cloud Sync",desc:"Sync your configurations across devices instantly.",colors:{border:"hover:border-sky-500/50",bg:"hover:bg-sky-500/5",iconBg:"bg-sky-500/10",iconText:"text-sky-500",titleHover:"group-hover:text-sky-400"}},{icon:"terminal",title:"CLI Support",desc:"Works with Claude Code, Codex, Cline, Cursor, and more.",colors:{border:"hover:border-emerald-500/50",bg:"hover:bg-emerald-500/5",iconBg:"bg-emerald-500/10",iconText:"text-emerald-500",titleHover:"group-hover:text-emerald-400"}},{icon:"dashboard",title:"Dashboard",desc:"Visual dashboard for real-time traffic analysis.",colors:{border:"hover:border-fuchsia-500/50",bg:"hover:bg-fuchsia-500/5",iconBg:"bg-fuchsia-500/10",iconText:"text-fuchsia-500",titleHover:"group-hover:text-fuchsia-400"}}];function g(){return e.jsx("section",{className:"py-24 px-6",id:"features",children:e.jsxs("div",{className:"max-w-7xl mx-auto",children:[e.jsxs("div",{className:"mb-16",children:[e.jsx("h2",{className:"text-3xl md:text-4xl font-bold mb-4",children:"Powerful Features"}),e.jsx("p",{className:"text-gray-400 max-w-xl text-lg",children:"Everything you need to manage your AI infrastructure in one place, built for scale."})]}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4",children:f.map(t=>e.jsxs("div",{className:`p-6 rounded-xl bg-[#23180f] border border-[#3a2f27] ${t.colors.border} ${t.colors.bg} transition-all duration-300 group`,children:[e.jsx("div",{className:`w-10 h-10 rounded-lg ${t.colors.iconBg} flex items-center justify-center mb-4 ${t.colors.iconText} group-hover:scale-110 transition-transform duration-300`,children:e.jsx("span",{className:"material-symbols-outlined",children:t.icon})}),e.jsx("h3",{className:`text-lg font-bold mb-2 ${t.colors.titleHover} transition-colors`,children:t.title}),e.jsx("p",{className:"text-sm text-gray-400 leading-relaxed",children:t.desc})]},t.title))})]})})}function b(){const{copied:t,copy:r}=d(),s=a=>{r(a,"landing")};return e.jsx("section",{className:"py-24 px-6 bg-[#120f0d]",children:e.jsx("div",{className:"max-w-7xl mx-auto",children:e.jsxs("div",{className:"flex flex-col lg:flex-row gap-16 items-start",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("h2",{className:"text-3xl md:text-4xl font-bold mb-6",children:"Get Started in 30 Seconds"}),e.jsx("p",{className:"text-gray-400 text-lg mb-8",children:"Install FSRouter, configure your providers via web dashboard, and start routing AI requests."}),e.jsxs("div",{className:"flex flex-col gap-6",children:[e.jsxs("div",{className:"flex gap-4",children:[e.jsx("div",{className:"flex-none w-8 h-8 rounded-full bg-[#f97815]/20 text-[#f97815] flex items-center justify-center font-bold",children:"1"}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-bold text-lg",children:"Install FSRouter"}),e.jsx("p",{className:"text-sm text-gray-500 mt-1",children:"Run npx command to start the server instantly"})]})]}),e.jsxs("div",{className:"flex gap-4",children:[e.jsx("div",{className:"flex-none w-8 h-8 rounded-full bg-[#f97815]/20 text-[#f97815] flex items-center justify-center font-bold",children:"2"}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-bold text-lg",children:"Open Dashboard"}),e.jsx("p",{className:"text-sm text-gray-500 mt-1",children:"Configure providers and API keys via web interface"})]})]}),e.jsxs("div",{className:"flex gap-4",children:[e.jsx("div",{className:"flex-none w-8 h-8 rounded-full bg-[#f97815]/20 text-[#f97815] flex items-center justify-center font-bold",children:"3"}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-bold text-lg",children:"Route Requests"}),e.jsx("p",{className:"text-sm text-gray-500 mt-1",children:"Point your CLI tools to http://localhost:20128"})]})]})]})]}),e.jsx("div",{className:"flex-1 w-full",children:e.jsxs("div",{className:"rounded-xl overflow-hidden bg-[#1e1e1e] border border-[#3a2f27] shadow-2xl",children:[e.jsxs("div",{className:"flex items-center gap-2 px-4 py-3 bg-[#252526] border-b border-gray-700",children:[e.jsx("div",{className:"w-3 h-3 rounded-full bg-red-500"}),e.jsx("div",{className:"w-3 h-3 rounded-full bg-yellow-500"}),e.jsx("div",{className:"w-3 h-3 rounded-full bg-green-500"}),e.jsx("div",{className:"ml-2 text-xs text-gray-500 font-mono",children:"terminal"})]}),e.jsxs("div",{className:"p-6 font-mono text-sm leading-relaxed overflow-x-auto",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-4 group cursor-pointer",onClick:()=>s("npx fsrouter"),children:[e.jsx("span",{className:"text-green-400",children:"$"}),e.jsx("span",{className:"text-white",children:"npx fsrouter"}),e.jsx("span",{className:"ml-auto text-gray-500 text-xs opacity-0 group-hover:opacity-100",children:t==="landing"?"✓ Copied":"Copy"})]}),e.jsxs("div",{className:"text-gray-400 mb-6",children:[e.jsx("span",{className:"text-[#f97815]",children:">"})," Starting FSRouter...",e.jsx("br",{}),e.jsx("span",{className:"text-[#f97815]",children:">"})," Server running on ",e.jsx("span",{className:"text-blue-400",children:"http://localhost:20128"}),e.jsx("br",{}),e.jsx("span",{className:"text-[#f97815]",children:">"})," Dashboard: ",e.jsx("span",{className:"text-blue-400",children:"http://localhost:20128/dashboard"}),e.jsx("br",{}),e.jsx("span",{className:"text-green-400",children:">"})," Ready to route! ✓"]}),e.jsx("div",{className:"text-xs text-gray-500 mb-2 border-t border-gray-700 pt-4",children:"📝 Configure providers in dashboard or use environment variables"}),e.jsxs("div",{className:"text-gray-400 text-xs",children:[e.jsx("span",{className:"text-purple-400",children:"Data Location:"}),e.jsx("br",{}),e.jsx("span",{className:"text-gray-500",children:" macOS/Linux:"})," ~/.fsrouter/db/data.sqlite",e.jsx("br",{}),e.jsx("span",{className:"text-gray-500",children:" Windows:"})," %APPDATA%/fsrouter/db/data.sqlite"]})]})]})})]})})})}function p(){return e.jsx("footer",{className:"border-t border-[#3a2f27] bg-[#120f0d] pt-16 pb-8 px-6",children:e.jsxs("div",{className:"max-w-7xl mx-auto",children:[e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 lg:grid-cols-5 gap-8 mb-16",children:[e.jsxs("div",{className:"col-span-2 lg:col-span-2",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-6",children:[e.jsx("div",{className:"size-6 rounded bg-[#f97815] flex items-center justify-center text-white",children:e.jsx("span",{className:"material-symbols-outlined text-[16px]",children:"hub"})}),e.jsx("h3",{className:"text-white text-lg font-bold",children:"FSRouter"})]}),e.jsx("p",{className:"text-gray-500 text-sm max-w-xs mb-6",children:"The unified endpoint for AI generation. Connect, route, and manage your AI providers with ease."}),e.jsx("div",{className:"flex gap-4",children:e.jsx("a",{className:"text-gray-400 hover:text-white transition-colors",href:"https://github.com/nexusrouters/fsrouter",target:"_blank",rel:"noopener noreferrer",children:e.jsx("span",{className:"material-symbols-outlined",children:"code"})})})]}),e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsx("h4",{className:"font-bold text-white",children:"Product"}),e.jsx("a",{className:"text-gray-400 hover:text-[#f97815] text-sm transition-colors",href:"#features",children:"Features"}),e.jsx("a",{className:"text-gray-400 hover:text-[#f97815] text-sm transition-colors",href:"/dashboard",children:"Dashboard"}),e.jsx("a",{className:"text-gray-400 hover:text-[#f97815] text-sm transition-colors",href:"https://github.com/nexusrouters/fsrouter",target:"_blank",rel:"noopener noreferrer",children:"Changelog"})]}),e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsx("h4",{className:"font-bold text-white",children:"Resources"}),e.jsx("a",{className:"text-gray-400 hover:text-[#f97815] text-sm transition-colors",href:"https://github.com/nexusrouters/fsrouter#readme",target:"_blank",rel:"noopener noreferrer",children:"Documentation"}),e.jsx("a",{className:"text-gray-400 hover:text-[#f97815] text-sm transition-colors",href:"https://github.com/nexusrouters/fsrouter",target:"_blank",rel:"noopener noreferrer",children:"GitHub"}),e.jsx("a",{className:"text-gray-400 hover:text-[#f97815] text-sm transition-colors",href:"https://www.npmjs.com/package/fsrouter",target:"_blank",rel:"noopener noreferrer",children:"NPM"})]}),e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsx("h4",{className:"font-bold text-white",children:"Legal"}),e.jsx("a",{className:"text-gray-400 hover:text-[#f97815] text-sm transition-colors",href:"https://github.com/nexusrouters/fsrouter/blob/main/LICENSE",target:"_blank",rel:"noopener noreferrer",children:"MIT License"})]})]}),e.jsxs("div",{className:"border-t border-[#3a2f27] pt-8 flex flex-col md:flex-row justify-between items-center gap-4",children:[e.jsx("p",{className:"text-gray-600 text-sm",children:"© 2025 FSRouter. All rights reserved."}),e.jsxs("div",{className:"flex gap-6",children:[e.jsx("a",{className:"text-gray-600 hover:text-white text-sm transition-colors",href:"https://github.com/nexusrouters/fsrouter",target:"_blank",rel:"noopener noreferrer",children:"GitHub"}),e.jsx("a",{className:"text-gray-600 hover:text-white text-sm transition-colors",href:"https://www.npmjs.com/package/fsrouter",target:"_blank",rel:"noopener noreferrer",children:"NPM"})]})]})]})})}function w(){const t=n();return e.jsxs("div",{className:"relative text-white font-sans overflow-x-hidden antialiased selection:bg-[#f97815] selection:text-white",children:[e.jsxs("div",{className:"fixed inset-0 z-0 overflow-hidden pointer-events-none bg-[#181411]",children:[e.jsx("div",{className:"absolute inset-0 opacity-[0.06]",style:{backgroundImage:"linear-gradient(to right, #f97815 1px, transparent 1px), linear-gradient(to bottom, #f97815 1px, transparent 1px)",backgroundSize:"50px 50px"}}),e.jsx("div",{className:"absolute top-0 left-1/4 w-[700px] h-[700px] bg-[#f97815]/12 rounded-full blur-[130px] animate-blob"}),e.jsx("div",{className:"absolute top-1/3 right-1/4 w-[600px] h-[600px] bg-purple-500/10 rounded-full blur-[130px] animate-blob",style:{animationDelay:"2s",animationDuration:"22s"}}),e.jsx("div",{className:"absolute bottom-0 left-1/2 w-[650px] h-[650px] bg-blue-500/8 rounded-full blur-[130px] animate-blob",style:{animationDelay:"4s",animationDuration:"25s"}}),e.jsx("div",{className:"absolute inset-0",style:{background:"radial-gradient(circle at center, transparent 0%, rgba(24, 20, 17, 0.4) 100%)"}})]}),e.jsxs("div",{className:"relative z-10",children:[e.jsx(c,{}),e.jsxs("main",{children:[e.jsxs("div",{className:"relative",children:[e.jsx(x,{}),e.jsx("div",{className:"flex justify-center pb-20",children:e.jsx(h,{})})]}),e.jsx(b,{}),e.jsx(u,{}),e.jsx(g,{}),e.jsxs("section",{className:"py-32 px-6 relative overflow-hidden",children:[e.jsx("div",{className:"absolute inset-0 bg-linear-to-t from-[#f97815]/5 to-transparent pointer-events-none"}),e.jsxs("div",{className:"max-w-4xl mx-auto text-center relative z-10",children:[e.jsx("h2",{className:"text-4xl md:text-5xl font-black mb-6",children:"Ready to Simplify Your AI Infrastructure?"}),e.jsx("p",{className:"text-xl text-gray-400 mb-10 max-w-2xl mx-auto",children:"Join developers who are streamlining their AI integrations with FSRouter. Open source and free to start."}),e.jsxs("div",{className:"flex flex-col sm:flex-row items-center justify-center gap-4",children:[e.jsx("button",{onClick:()=>t("/dashboard"),className:"w-full sm:w-auto h-14 px-10 rounded-lg bg-[#f97815] hover:bg-[#e0650a] text-[#181411] text-lg font-bold transition-all shadow-[0_0_20px_rgba(249,120,21,0.5)]",children:"Start Free"}),e.jsx("button",{onClick:()=>window.open("https://github.com/nexusrouters/fsrouter#readme","_blank"),className:"w-full sm:w-auto h-14 px-10 rounded-lg border border-[#3a2f27] hover:bg-[#23180f] text-white text-lg font-bold transition-all",children:"Read Documentation"})]})]})]})]}),e.jsx(p,{})]})]})}export{w as default};
1
+ import{j as e,P as i,u as d}from"./index.Be3gbrBl.js";import{b as l,d as n}from"./router.Cjj1--8t.js";import"./zustand.akaTi5uX.js";function c(){const[t,r]=l.useState(!1),s=n();return e.jsxs("nav",{className:"fixed top-0 z-50 w-full bg-[#181411]/80 backdrop-blur-md border-b border-[#3a2f27]",children:[e.jsxs("div",{className:"max-w-7xl mx-auto px-6 h-16 flex items-center justify-between",children:[e.jsxs("button",{type:"button",className:"flex items-center gap-3 cursor-pointer bg-transparent border-none p-0",onClick:()=>s("/"),"aria-label":"Navigate to home",children:[e.jsx("img",{src:"/logo_fsrouter.png",alt:"FSRouter v2",className:"size-8 rounded object-cover"}),e.jsx("h2",{className:"text-white text-xl font-bold tracking-tight",children:"FSRouter"})]}),e.jsxs("div",{className:"hidden md:flex items-center gap-8",children:[e.jsx("a",{className:"text-gray-300 hover:text-white text-sm font-medium transition-colors",href:"#features",children:"Features"}),e.jsx("a",{className:"text-gray-300 hover:text-white text-sm font-medium transition-colors",href:"#how-it-works",children:"How it Works"}),e.jsx("a",{className:"text-gray-300 hover:text-white text-sm font-medium transition-colors",href:"https://github.com/nexusrouters/fsrouter#readme",target:"_blank",rel:"noopener noreferrer",children:"Docs"}),e.jsxs("a",{className:"text-gray-300 hover:text-white text-sm font-medium transition-colors flex items-center gap-1",href:"https://github.com/nexusrouters/fsrouter",target:"_blank",rel:"noopener noreferrer",children:["GitHub ",e.jsx("span",{className:"material-symbols-outlined text-[14px]",children:"open_in_new"})]})]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("button",{onClick:()=>s("/dashboard"),className:"hidden sm:flex h-9 items-center justify-center rounded-lg px-4 bg-[#f97815] hover:bg-[#e0650a] transition-all text-[#181411] text-sm font-bold shadow-[0_0_15px_rgba(249,120,21,0.4)] hover:shadow-[0_0_20px_rgba(249,120,21,0.6)]",children:"Get Started"}),e.jsx("button",{className:"md:hidden text-white",onClick:()=>r(!t),children:e.jsx("span",{className:"material-symbols-outlined",children:t?"close":"menu"})})]})]}),t&&e.jsx("div",{className:"md:hidden border-t border-[#3a2f27] bg-[#181411]/95 backdrop-blur-md",children:e.jsxs("div",{className:"flex flex-col gap-4 p-6",children:[e.jsx("a",{className:"text-gray-300 hover:text-white text-sm font-medium transition-colors",href:"#features",onClick:()=>r(!1),children:"Features"}),e.jsx("a",{className:"text-gray-300 hover:text-white text-sm font-medium transition-colors",href:"#how-it-works",onClick:()=>r(!1),children:"How it Works"}),e.jsx("a",{className:"text-gray-300 hover:text-white text-sm font-medium transition-colors",href:"https://github.com/nexusrouters/fsrouter#readme",target:"_blank",rel:"noopener noreferrer",children:"Docs"}),e.jsx("a",{className:"text-gray-300 hover:text-white text-sm font-medium transition-colors",href:"https://github.com/nexusrouters/fsrouter",target:"_blank",rel:"noopener noreferrer",children:"GitHub"}),e.jsx("button",{onClick:()=>s("/dashboard"),className:"h-9 rounded-lg bg-[#f97815] hover:bg-[#e0650a] text-[#181411] text-sm font-bold",children:"Get Started"})]})})]})}function x(){return e.jsxs("section",{className:"relative pt-32 pb-20 px-6 min-h-[90vh] flex flex-col items-center justify-center overflow-hidden",children:[e.jsx("div",{className:"absolute top-0 left-1/2 -translate-x-1/2 w-[1000px] h-[500px] bg-[#f97815]/10 rounded-full blur-[120px] pointer-events-none"}),e.jsxs("div",{className:"relative z-10 max-w-4xl w-full text-center flex flex-col items-center gap-8",children:[e.jsxs("div",{className:"inline-flex items-center gap-2 rounded-full border border-[#3a2f27] bg-[#23180f]/50 px-3 py-1 text-xs font-medium text-[#f97815]",children:[e.jsx("span",{className:"flex h-2 w-2 rounded-full bg-[#f97815] animate-pulse"}),"v1.0 is now live"]}),e.jsxs("h1",{className:"text-5xl md:text-7xl font-black leading-[1.1] tracking-tight",children:["One Endpoint for ",e.jsx("br",{}),e.jsx("span",{className:"text-[#f97815]",children:"All AI Providers"})]}),e.jsx("p",{className:"text-lg md:text-xl text-gray-400 max-w-2xl mx-auto font-light",children:"AI endpoint proxy with web dashboard - A JavaScript port of CLIProxyAPI. Works seamlessly with Claude Code, OpenAI Codex, Cline, RooCode, and other CLI tools."}),e.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-4 w-full",children:[e.jsxs("button",{className:"h-12 px-8 rounded-lg bg-[#f97815] hover:bg-[#e0650a] text-[#181411] text-base font-bold transition-all shadow-[0_0_15px_rgba(249,120,21,0.4)] flex items-center gap-2",children:[e.jsx("span",{className:"material-symbols-outlined",children:"rocket_launch"}),"Get Started"]}),e.jsxs("a",{href:"https://github.com/nexusrouters/fsrouter",target:"_blank",rel:"noopener noreferrer",className:"h-12 px-8 rounded-lg border border-[#3a2f27] bg-[#23180f] hover:bg-[#3a2f27] text-white text-base font-bold transition-all flex items-center gap-2",children:[e.jsx("span",{className:"material-symbols-outlined",children:"code"}),"View on GitHub"]})]})]})]})}const m=[{id:"claude",name:"Claude Code",image:"/providers/claude.png"},{id:"codex",name:"OpenAI Codex",image:"/providers/codex.png"},{id:"cline",name:"Cline",image:"/providers/cline.png"},{id:"cursor",name:"Cursor",image:"/providers/cursor.png"}],o=[{id:"openai",name:"OpenAI",color:"bg-emerald-500",textColor:"text-white"},{id:"anthropic",name:"Anthropic",color:"bg-orange-400",textColor:"text-white"},{id:"gemini",name:"Gemini",color:"bg-blue-500",textColor:"text-white"},{id:"github",name:"GitHub Copilot",color:"bg-gray-700",textColor:"text-white"}];function h(){const[t,r]=l.useState(0);return l.useEffect(()=>{const s=setInterval(()=>{r(a=>(a+1)%o.length)},2e3);return()=>clearInterval(s)},[]),e.jsxs("div",{className:"mt-16 w-full max-w-4xl relative h-[360px] hidden md:flex items-center justify-center animate-[float_6s_ease-in-out_infinite]",children:[e.jsxs("div",{className:"relative z-20 w-32 h-32 rounded-full bg-[#23180f] border-2 border-[#f97815] shadow-[0_0_40px_rgba(249,120,21,0.3)] flex flex-col items-center justify-center gap-1 group cursor-pointer hover:scale-105 transition-transform duration-500",children:[e.jsx("span",{className:"material-symbols-outlined text-4xl text-[#f97815]",children:"hub"}),e.jsx("span",{className:"text-xs font-bold text-white tracking-widest uppercase",children:"FSRouter"}),e.jsx("div",{className:"absolute inset-0 rounded-full border border-[#f97815]/30 animate-ping opacity-20"})]}),e.jsx("div",{className:"absolute left-0 top-1/2 -translate-y-1/2 flex flex-col gap-7",children:m.map(s=>e.jsx("div",{className:"flex items-center gap-3 opacity-70 hover:opacity-100 transition-opacity group",children:e.jsx("div",{className:"w-16 h-16 rounded-2xl bg-[#23180f] border border-[#3a2f27] flex items-center justify-center overflow-hidden p-2 hover:border-[#f97815]/50 transition-all hover:scale-105",children:e.jsx(i,{src:s.image,alt:s.name,size:48,className:"object-contain rounded-xl max-w-[48px] max-h-[48px]",fallbackText:s.name.slice(0,2).toUpperCase()})})},s.id))}),e.jsxs("svg",{className:"absolute inset-0 w-full h-full z-10 pointer-events-none stroke-yellow-700",xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("path",{className:"animate-[dash_2s_linear_infinite]",d:"M 60 50 C 250 70, 250 180, 360 180",fill:"none",strokeDasharray:"5,5",strokeWidth:"2"}),e.jsx("path",{className:"animate-[dash_2s_linear_infinite]",d:"M 60 140 C 250 140, 250 180, 360 180",fill:"none",strokeDasharray:"5,5",strokeWidth:"2"}),e.jsx("path",{className:"animate-[dash_2s_linear_infinite]",d:"M 60 210 C 250 210, 250 180, 360 180",fill:"none",strokeDasharray:"5,5",strokeWidth:"2"}),e.jsx("path",{className:"animate-[dash_2s_linear_infinite]",d:"M 60 300 C 250 280, 250 180, 360 180",fill:"none",strokeDasharray:"5,5",strokeWidth:"2"})]}),e.jsxs("svg",{className:"absolute inset-0 w-full h-full z-10 pointer-events-none",xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("path",{d:"M 440 180 C 550 180, 550 50, 740 50",fill:"none",stroke:t===0?"#f97815":"rgb(75, 85, 99)",strokeWidth:t===0?"3":"2",className:t===0?"animate-pulse":""}),e.jsx("path",{d:"M 440 180 C 550 180, 550 130, 740 130",fill:"none",stroke:t===1?"#f97815":"rgb(75, 85, 99)",strokeWidth:t===1?"3":"2",className:t===1?"animate-pulse":""}),e.jsx("path",{d:"M 440 180 C 550 180, 550 230, 740 230",fill:"none",stroke:t===2?"#f97815":"rgb(75, 85, 99)",strokeWidth:t===2?"3":"2",className:t===2?"animate-pulse":""}),e.jsx("path",{d:"M 440 180 C 550 180, 550 310, 740 310",fill:"none",stroke:t===3?"#f97815":"rgb(75, 85, 99)",strokeWidth:t===3?"3":"2",className:t===3?"animate-pulse":""})]}),e.jsx("div",{className:"absolute right-0 top-0 bottom-0 flex flex-col justify-between py-6",children:o.map((s,a)=>e.jsx("div",{className:`px-4 py-2 rounded-lg ${s.color} ${s.textColor} flex items-center justify-center font-bold text-xs shadow-lg hover:scale-110 transition-all cursor-help min-w-[140px] ${t===a?"ring-4 ring-[#f97815]/50 scale-110":""}`,title:s.name,children:s.name},s.id))}),e.jsx("div",{className:"md:hidden mt-8 w-full p-4 rounded-lg bg-[#23180f] border border-[#3a2f27]",children:e.jsx("p",{className:"text-sm text-center text-gray-400",children:"Interactive diagram visible on desktop"})})]})}function u(){return e.jsx("section",{className:"py-24 border-y border-[#3a2f27] bg-[#23180f]/30",id:"how-it-works",children:e.jsxs("div",{className:"max-w-7xl mx-auto px-6",children:[e.jsxs("div",{className:"mb-16",children:[e.jsx("h2",{className:"text-3xl md:text-4xl font-bold mb-4",children:"How FSRouter Works"}),e.jsx("p",{className:"text-gray-400 max-w-xl text-lg",children:"Data flows seamlessly from your application through our intelligent routing layer to the best provider for the job."})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-8 relative",children:[e.jsx("div",{className:"hidden md:block absolute top-12 left-[16%] right-[16%] h-[2px] bg-linear-to-r from-gray-700 via-[#f97815] to-gray-700 -z-10"}),e.jsxs("div",{className:"flex flex-col gap-6 relative group",children:[e.jsx("div",{className:"w-24 h-24 rounded-2xl bg-[#181411] border border-[#3a2f27] flex items-center justify-center shadow-xl group-hover:border-gray-500 transition-colors z-10 mx-auto md:mx-0",children:e.jsx("span",{className:"material-symbols-outlined text-4xl text-gray-300",children:"terminal"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-xl font-bold mb-2",children:"1. CLI & SDKs"}),e.jsx("p",{className:"text-sm text-gray-400",children:"Your requests start from your favorite tools or our unified SDK. Just change the base URL."})]})]}),e.jsxs("div",{className:"flex flex-col gap-6 relative group md:items-center md:text-center",children:[e.jsx("div",{className:"w-24 h-24 rounded-2xl bg-[#181411] border-2 border-[#f97815] flex items-center justify-center shadow-[0_0_30px_rgba(249,120,21,0.2)] z-10 mx-auto",children:e.jsx("span",{className:"material-symbols-outlined text-4xl text-[#f97815] animate-pulse",children:"hub"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-xl font-bold mb-2 text-[#f97815]",children:"2. FSRouter Hub"}),e.jsx("p",{className:"text-sm text-gray-400",children:"Our engine analyzes the prompt, checks provider health, and routes for lowest latency or cost."})]})]}),e.jsxs("div",{className:"flex flex-col gap-6 relative group md:items-end md:text-right",children:[e.jsx("div",{className:"w-24 h-24 rounded-2xl bg-[#181411] border border-[#3a2f27] flex items-center justify-center shadow-xl group-hover:border-gray-500 transition-colors z-10 mx-auto md:mx-0",children:e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsx("div",{className:"w-6 h-6 rounded bg-white/10"}),e.jsx("div",{className:"w-6 h-6 rounded bg-white/10"}),e.jsx("div",{className:"w-6 h-6 rounded bg-white/10"}),e.jsx("div",{className:"w-6 h-6 rounded bg-white/10"})]})}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-xl font-bold mb-2",children:"3. AI Providers"}),e.jsx("p",{className:"text-sm text-gray-400",children:"The request is fulfilled by OpenAI, Anthropic, Gemini, or others instantly."})]})]})]})]})})}const f=[{icon:"link",title:"Unified Endpoint",desc:"Access all providers via a single standard API URL.",colors:{border:"hover:border-blue-500/50",bg:"hover:bg-blue-500/5",iconBg:"bg-blue-500/10",iconText:"text-blue-500",titleHover:"group-hover:text-blue-400"}},{icon:"bolt",title:"Easy Setup",desc:"Get up and running in minutes with npx command.",colors:{border:"hover:border-orange-500/50",bg:"hover:bg-orange-500/5",iconBg:"bg-orange-500/10",iconText:"text-orange-500",titleHover:"group-hover:text-orange-400"}},{icon:"shield_with_heart",title:"Model Fallback",desc:"Automatically switch providers on failure or high latency.",colors:{border:"hover:border-rose-500/50",bg:"hover:bg-rose-500/5",iconBg:"bg-rose-500/10",iconText:"text-rose-500",titleHover:"group-hover:text-rose-400"}},{icon:"monitoring",title:"Usage Tracking",desc:"Detailed analytics and cost monitoring across all models.",colors:{border:"hover:border-purple-500/50",bg:"hover:bg-purple-500/5",iconBg:"bg-purple-500/10",iconText:"text-purple-500",titleHover:"group-hover:text-purple-400"}},{icon:"key",title:"OAuth & API Keys",desc:"Securely manage credentials in one vault.",colors:{border:"hover:border-amber-500/50",bg:"hover:bg-amber-500/5",iconBg:"bg-amber-500/10",iconText:"text-amber-500",titleHover:"group-hover:text-amber-400"}},{icon:"cloud_sync",title:"Cloud Sync",desc:"Sync your configurations across devices instantly.",colors:{border:"hover:border-sky-500/50",bg:"hover:bg-sky-500/5",iconBg:"bg-sky-500/10",iconText:"text-sky-500",titleHover:"group-hover:text-sky-400"}},{icon:"terminal",title:"CLI Support",desc:"Works with Claude Code, Codex, Cline, Cursor, and more.",colors:{border:"hover:border-emerald-500/50",bg:"hover:bg-emerald-500/5",iconBg:"bg-emerald-500/10",iconText:"text-emerald-500",titleHover:"group-hover:text-emerald-400"}},{icon:"dashboard",title:"Dashboard",desc:"Visual dashboard for real-time traffic analysis.",colors:{border:"hover:border-fuchsia-500/50",bg:"hover:bg-fuchsia-500/5",iconBg:"bg-fuchsia-500/10",iconText:"text-fuchsia-500",titleHover:"group-hover:text-fuchsia-400"}}];function g(){return e.jsx("section",{className:"py-24 px-6",id:"features",children:e.jsxs("div",{className:"max-w-7xl mx-auto",children:[e.jsxs("div",{className:"mb-16",children:[e.jsx("h2",{className:"text-3xl md:text-4xl font-bold mb-4",children:"Powerful Features"}),e.jsx("p",{className:"text-gray-400 max-w-xl text-lg",children:"Everything you need to manage your AI infrastructure in one place, built for scale."})]}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4",children:f.map(t=>e.jsxs("div",{className:`p-6 rounded-xl bg-[#23180f] border border-[#3a2f27] ${t.colors.border} ${t.colors.bg} transition-all duration-300 group`,children:[e.jsx("div",{className:`w-10 h-10 rounded-lg ${t.colors.iconBg} flex items-center justify-center mb-4 ${t.colors.iconText} group-hover:scale-110 transition-transform duration-300`,children:e.jsx("span",{className:"material-symbols-outlined",children:t.icon})}),e.jsx("h3",{className:`text-lg font-bold mb-2 ${t.colors.titleHover} transition-colors`,children:t.title}),e.jsx("p",{className:"text-sm text-gray-400 leading-relaxed",children:t.desc})]},t.title))})]})})}function b(){const{copied:t,copy:r}=d(),s=a=>{r(a,"landing")};return e.jsx("section",{className:"py-24 px-6 bg-[#120f0d]",children:e.jsx("div",{className:"max-w-7xl mx-auto",children:e.jsxs("div",{className:"flex flex-col lg:flex-row gap-16 items-start",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("h2",{className:"text-3xl md:text-4xl font-bold mb-6",children:"Get Started in 30 Seconds"}),e.jsx("p",{className:"text-gray-400 text-lg mb-8",children:"Install FSRouter, configure your providers via web dashboard, and start routing AI requests."}),e.jsxs("div",{className:"flex flex-col gap-6",children:[e.jsxs("div",{className:"flex gap-4",children:[e.jsx("div",{className:"flex-none w-8 h-8 rounded-full bg-[#f97815]/20 text-[#f97815] flex items-center justify-center font-bold",children:"1"}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-bold text-lg",children:"Install FSRouter"}),e.jsx("p",{className:"text-sm text-gray-500 mt-1",children:"Run npx command to start the server instantly"})]})]}),e.jsxs("div",{className:"flex gap-4",children:[e.jsx("div",{className:"flex-none w-8 h-8 rounded-full bg-[#f97815]/20 text-[#f97815] flex items-center justify-center font-bold",children:"2"}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-bold text-lg",children:"Open Dashboard"}),e.jsx("p",{className:"text-sm text-gray-500 mt-1",children:"Configure providers and API keys via web interface"})]})]}),e.jsxs("div",{className:"flex gap-4",children:[e.jsx("div",{className:"flex-none w-8 h-8 rounded-full bg-[#f97815]/20 text-[#f97815] flex items-center justify-center font-bold",children:"3"}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-bold text-lg",children:"Route Requests"}),e.jsx("p",{className:"text-sm text-gray-500 mt-1",children:"Point your CLI tools to http://localhost:20128"})]})]})]})]}),e.jsx("div",{className:"flex-1 w-full",children:e.jsxs("div",{className:"rounded-xl overflow-hidden bg-[#1e1e1e] border border-[#3a2f27] shadow-2xl",children:[e.jsxs("div",{className:"flex items-center gap-2 px-4 py-3 bg-[#252526] border-b border-gray-700",children:[e.jsx("div",{className:"w-3 h-3 rounded-full bg-red-500"}),e.jsx("div",{className:"w-3 h-3 rounded-full bg-yellow-500"}),e.jsx("div",{className:"w-3 h-3 rounded-full bg-green-500"}),e.jsx("div",{className:"ml-2 text-xs text-gray-500 font-mono",children:"terminal"})]}),e.jsxs("div",{className:"p-6 font-mono text-sm leading-relaxed overflow-x-auto",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-4 group cursor-pointer",onClick:()=>s("npx fsrouter"),children:[e.jsx("span",{className:"text-green-400",children:"$"}),e.jsx("span",{className:"text-white",children:"npx fsrouter"}),e.jsx("span",{className:"ml-auto text-gray-500 text-xs opacity-0 group-hover:opacity-100",children:t==="landing"?"✓ Copied":"Copy"})]}),e.jsxs("div",{className:"text-gray-400 mb-6",children:[e.jsx("span",{className:"text-[#f97815]",children:">"})," Starting FSRouter...",e.jsx("br",{}),e.jsx("span",{className:"text-[#f97815]",children:">"})," Server running on ",e.jsx("span",{className:"text-blue-400",children:"http://localhost:20128"}),e.jsx("br",{}),e.jsx("span",{className:"text-[#f97815]",children:">"})," Dashboard: ",e.jsx("span",{className:"text-blue-400",children:"http://localhost:20128/dashboard"}),e.jsx("br",{}),e.jsx("span",{className:"text-green-400",children:">"})," Ready to route! ✓"]}),e.jsx("div",{className:"text-xs text-gray-500 mb-2 border-t border-gray-700 pt-4",children:"📝 Configure providers in dashboard or use environment variables"}),e.jsxs("div",{className:"text-gray-400 text-xs",children:[e.jsx("span",{className:"text-purple-400",children:"Data Location:"}),e.jsx("br",{}),e.jsx("span",{className:"text-gray-500",children:" macOS/Linux:"})," ~/.fsrouter/db/data.sqlite",e.jsx("br",{}),e.jsx("span",{className:"text-gray-500",children:" Windows:"})," %APPDATA%/fsrouter/db/data.sqlite"]})]})]})})]})})})}function p(){return e.jsx("footer",{className:"border-t border-[#3a2f27] bg-[#120f0d] pt-16 pb-8 px-6",children:e.jsxs("div",{className:"max-w-7xl mx-auto",children:[e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 lg:grid-cols-5 gap-8 mb-16",children:[e.jsxs("div",{className:"col-span-2 lg:col-span-2",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-6",children:[e.jsx("div",{className:"size-6 rounded bg-[#f97815] flex items-center justify-center text-white",children:e.jsx("span",{className:"material-symbols-outlined text-[16px]",children:"hub"})}),e.jsx("h3",{className:"text-white text-lg font-bold",children:"FSRouter"})]}),e.jsx("p",{className:"text-gray-500 text-sm max-w-xs mb-6",children:"The unified endpoint for AI generation. Connect, route, and manage your AI providers with ease."}),e.jsx("div",{className:"flex gap-4",children:e.jsx("a",{className:"text-gray-400 hover:text-white transition-colors",href:"https://github.com/nexusrouters/fsrouter",target:"_blank",rel:"noopener noreferrer",children:e.jsx("span",{className:"material-symbols-outlined",children:"code"})})})]}),e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsx("h4",{className:"font-bold text-white",children:"Product"}),e.jsx("a",{className:"text-gray-400 hover:text-[#f97815] text-sm transition-colors",href:"#features",children:"Features"}),e.jsx("a",{className:"text-gray-400 hover:text-[#f97815] text-sm transition-colors",href:"/dashboard",children:"Dashboard"}),e.jsx("a",{className:"text-gray-400 hover:text-[#f97815] text-sm transition-colors",href:"https://github.com/nexusrouters/fsrouter",target:"_blank",rel:"noopener noreferrer",children:"Changelog"})]}),e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsx("h4",{className:"font-bold text-white",children:"Resources"}),e.jsx("a",{className:"text-gray-400 hover:text-[#f97815] text-sm transition-colors",href:"https://github.com/nexusrouters/fsrouter#readme",target:"_blank",rel:"noopener noreferrer",children:"Documentation"}),e.jsx("a",{className:"text-gray-400 hover:text-[#f97815] text-sm transition-colors",href:"https://github.com/nexusrouters/fsrouter",target:"_blank",rel:"noopener noreferrer",children:"GitHub"}),e.jsx("a",{className:"text-gray-400 hover:text-[#f97815] text-sm transition-colors",href:"https://www.npmjs.com/package/fsrouter",target:"_blank",rel:"noopener noreferrer",children:"NPM"})]}),e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsx("h4",{className:"font-bold text-white",children:"Legal"}),e.jsx("a",{className:"text-gray-400 hover:text-[#f97815] text-sm transition-colors",href:"https://github.com/nexusrouters/fsrouter/blob/main/LICENSE",target:"_blank",rel:"noopener noreferrer",children:"MIT License"})]})]}),e.jsxs("div",{className:"border-t border-[#3a2f27] pt-8 flex flex-col md:flex-row justify-between items-center gap-4",children:[e.jsx("p",{className:"text-gray-600 text-sm",children:"© 2025 FSRouter. All rights reserved."}),e.jsxs("div",{className:"flex gap-6",children:[e.jsx("a",{className:"text-gray-600 hover:text-white text-sm transition-colors",href:"https://github.com/nexusrouters/fsrouter",target:"_blank",rel:"noopener noreferrer",children:"GitHub"}),e.jsx("a",{className:"text-gray-600 hover:text-white text-sm transition-colors",href:"https://www.npmjs.com/package/fsrouter",target:"_blank",rel:"noopener noreferrer",children:"NPM"})]})]})]})})}function w(){const t=n();return e.jsxs("div",{className:"relative text-white font-sans overflow-x-hidden antialiased selection:bg-[#f97815] selection:text-white",children:[e.jsxs("div",{className:"fixed inset-0 z-0 overflow-hidden pointer-events-none bg-[#181411]",children:[e.jsx("div",{className:"absolute inset-0 opacity-[0.06]",style:{backgroundImage:"linear-gradient(to right, #f97815 1px, transparent 1px), linear-gradient(to bottom, #f97815 1px, transparent 1px)",backgroundSize:"50px 50px"}}),e.jsx("div",{className:"absolute top-0 left-1/4 w-[700px] h-[700px] bg-[#f97815]/12 rounded-full blur-[130px] animate-blob"}),e.jsx("div",{className:"absolute top-1/3 right-1/4 w-[600px] h-[600px] bg-purple-500/10 rounded-full blur-[130px] animate-blob",style:{animationDelay:"2s",animationDuration:"22s"}}),e.jsx("div",{className:"absolute bottom-0 left-1/2 w-[650px] h-[650px] bg-blue-500/8 rounded-full blur-[130px] animate-blob",style:{animationDelay:"4s",animationDuration:"25s"}}),e.jsx("div",{className:"absolute inset-0",style:{background:"radial-gradient(circle at center, transparent 0%, rgba(24, 20, 17, 0.4) 100%)"}})]}),e.jsxs("div",{className:"relative z-10",children:[e.jsx(c,{}),e.jsxs("main",{children:[e.jsxs("div",{className:"relative",children:[e.jsx(x,{}),e.jsx("div",{className:"flex justify-center pb-20",children:e.jsx(h,{})})]}),e.jsx(b,{}),e.jsx(u,{}),e.jsx(g,{}),e.jsxs("section",{className:"py-32 px-6 relative overflow-hidden",children:[e.jsx("div",{className:"absolute inset-0 bg-linear-to-t from-[#f97815]/5 to-transparent pointer-events-none"}),e.jsxs("div",{className:"max-w-4xl mx-auto text-center relative z-10",children:[e.jsx("h2",{className:"text-4xl md:text-5xl font-black mb-6",children:"Ready to Simplify Your AI Infrastructure?"}),e.jsx("p",{className:"text-xl text-gray-400 mb-10 max-w-2xl mx-auto",children:"Join developers who are streamlining their AI integrations with FSRouter. Open source and free to start."}),e.jsxs("div",{className:"flex flex-col sm:flex-row items-center justify-center gap-4",children:[e.jsx("button",{onClick:()=>t("/dashboard"),className:"w-full sm:w-auto h-14 px-10 rounded-lg bg-[#f97815] hover:bg-[#e0650a] text-[#181411] text-lg font-bold transition-all shadow-[0_0_20px_rgba(249,120,21,0.5)]",children:"Start Free"}),e.jsx("button",{onClick:()=>window.open("https://github.com/nexusrouters/fsrouter#readme","_blank"),className:"w-full sm:w-auto h-14 px-10 rounded-lg border border-[#3a2f27] hover:bg-[#23180f] text-white text-lg font-bold transition-all",children:"Read Documentation"})]})]})]})]}),e.jsx(p,{})]})]})}export{w as default};
@@ -1 +1 @@
1
- import{J as m,j as e,B as p}from"./index.CShjRV_B.js";import{b as l}from"./router.Cjj1--8t.js";import{C as f}from"./NoAuthProxyCard.qAv57b-0.js";import"./zustand.akaTi5uX.js";const g={LOG:"text-green-400",INFO:"text-blue-400",WARN:"text-yellow-400",ERROR:"text-red-400",DEBUG:"text-purple-400"};function h(n){var s;const o=n.match(/\[(\w+)\]/g),u=o?(s=o[1])==null?void 0:s.replace(/\[|\]/g,""):null,c=g[u]||"text-green-400";return e.jsx("span",{className:c,children:n})}function j(){const[n,o]=l.useState([]),[u,c]=l.useState(!1),s=l.useRef(null),d=async()=>{try{await fetch("/api/translator/console-logs",{method:"DELETE"})}catch(t){console.error("Failed to clear console logs:",t)}};return l.useEffect(()=>{const t=new EventSource("/api/translator/console-logs/stream");return t.onopen=()=>c(!0),t.onmessage=a=>{const r=JSON.parse(a.data);r.type==="init"?o(r.logs.slice(-200)):r.type==="line"?o(x=>{const i=[...x,r.line];return i.length>m.maxLines?i.slice(-200):i}):r.type==="clear"&&o([])},t.onerror=()=>c(!1),()=>t.close()},[]),l.useEffect(()=>{s.current&&(s.current.scrollTop=s.current.scrollHeight)},[n]),e.jsx("div",{className:"",children:e.jsxs(f,{children:[e.jsx("div",{className:"flex items-center justify-end px-4 pt-3 pb-2",children:e.jsx(p,{size:"sm",variant:"outline",icon:"delete",onClick:d,children:"Clear"})}),e.jsx("div",{ref:s,className:"bg-black rounded-b-lg p-4 text-xs font-mono h-[calc(100vh-220px)] overflow-y-auto",children:n.length===0?e.jsx("span",{className:"text-text-muted",children:"No console logs yet."}):e.jsx("div",{className:"space-y-0.5",children:n.map((t,a)=>e.jsx("div",{children:h(t)},a))})})]})})}const N="force-dynamic";function O(){return e.jsx(j,{})}export{O as default,N as dynamic};
1
+ import{J as m,j as e,B as p}from"./index.Be3gbrBl.js";import{b as l}from"./router.Cjj1--8t.js";import{C as f}from"./NoAuthProxyCard.BDcXaWvM.js";import"./zustand.akaTi5uX.js";const g={LOG:"text-green-400",INFO:"text-blue-400",WARN:"text-yellow-400",ERROR:"text-red-400",DEBUG:"text-purple-400"};function h(n){var s;const o=n.match(/\[(\w+)\]/g),u=o?(s=o[1])==null?void 0:s.replace(/\[|\]/g,""):null,c=g[u]||"text-green-400";return e.jsx("span",{className:c,children:n})}function j(){const[n,o]=l.useState([]),[u,c]=l.useState(!1),s=l.useRef(null),d=async()=>{try{await fetch("/api/translator/console-logs",{method:"DELETE"})}catch(t){console.error("Failed to clear console logs:",t)}};return l.useEffect(()=>{const t=new EventSource("/api/translator/console-logs/stream");return t.onopen=()=>c(!0),t.onmessage=a=>{const r=JSON.parse(a.data);r.type==="init"?o(r.logs.slice(-200)):r.type==="line"?o(x=>{const i=[...x,r.line];return i.length>m.maxLines?i.slice(-200):i}):r.type==="clear"&&o([])},t.onerror=()=>c(!1),()=>t.close()},[]),l.useEffect(()=>{s.current&&(s.current.scrollTop=s.current.scrollHeight)},[n]),e.jsx("div",{className:"",children:e.jsxs(f,{children:[e.jsx("div",{className:"flex items-center justify-end px-4 pt-3 pb-2",children:e.jsx(p,{size:"sm",variant:"outline",icon:"delete",onClick:d,children:"Clear"})}),e.jsx("div",{ref:s,className:"bg-black rounded-b-lg p-4 text-xs font-mono h-[calc(100vh-220px)] overflow-y-auto",children:n.length===0?e.jsx("span",{className:"text-text-muted",children:"No console logs yet."}):e.jsx("div",{className:"space-y-0.5",children:n.map((t,a)=>e.jsx("div",{children:h(t)},a))})})]})})}const N="force-dynamic";function O(){return e.jsx(j,{})}export{O as default,N as dynamic};
@@ -1 +1 @@
1
- import{j as s,B as Be,k as je,l as Ie,h as Le}from"./index.CShjRV_B.js";import{b as d}from"./router.Cjj1--8t.js";import{B as qe}from"./NoAuthProxyCard.qAv57b-0.js";import"./zustand.akaTi5uX.js";const O={sessions:"basic-chat.sessions",activeSessionId:"basic-chat.activeSessionId",activeProviderId:"basic-chat.activeProviderId",draft:"basic-chat.draft"};function J(){var e;return(e=globalThis.crypto)!=null&&e.randomUUID?globalThis.crypto.randomUUID():`chat_${Date.now()}_${Math.random().toString(16).slice(2)}`}function Fe(e,a){try{return JSON.parse(e)}catch{return a}}function S(e){if(typeof e=="string")return e;if(e==null)return"";if(Array.isArray(e))return e.map(S).filter(Boolean).join(" ");if(typeof e=="object"){if(typeof e.message=="string")return e.message;if(typeof e.error=="string")return e.error;try{return JSON.stringify(e)}catch{return String(e)}}return String(e)}function He(e=""){return String(e).replace(/[-_]/g," ").replace(/\b\w/g,a=>a.toUpperCase()).trim()||"Unknown"}function Je(e){if(!e)return"Now";const a=new Date(e).getTime();if(Number.isNaN(a))return"Now";const m=Math.max(1,Math.round((Date.now()-a)/6e4));if(m<60)return`${m}m`;const u=Math.round(m/60);return u<24?`${u}h`:`${Math.round(u/24)}d`}function Ne(e=""){const a=S(e).replace(/\s+/g," ").trim();return a?a.length>52?`${a.slice(0,52).trimEnd()}…`:a:"New chat"}function Ke(e){const a=S(e.content).trim(),m=Array.isArray(e.attachments)?e.attachments:[];if(m.length===0)return a;const u=[];a&&u.push({type:"text",text:a});for(const w of m)w!=null&&w.dataUrl&&u.push({type:"image_url",image_url:{url:w.dataUrl}});return u.length>0?u:a}function We(e){var w,A;if(!e||typeof e!="object")return"";const a=(w=e.choices)==null?void 0:w[0];return[((a==null?void 0:a.delta)||{}).content,(A=a==null?void 0:a.message)==null?void 0:A.content,e.output_text,e.text].map(S).filter(Boolean)[0]||""}async function Ye(e){return await new Promise((a,m)=>{const u=new FileReader;u.onload=()=>a(String(u.result||"")),u.onerror=()=>m(u.error||new Error("Failed to read file")),u.readAsDataURL(e)})}function Ve(e){return{...e,messages:Array.isArray(e.messages)?e.messages.map(a=>({...a})):[]}}function de(e){return(e==null?void 0:e.name)||He((e==null?void 0:e.provider)||(e==null?void 0:e.id)||"provider")}function Ge(e,a){return e!=null&&e.id?{id:`${a.provider}/${e.id}`,requestModel:`${a.provider}/${e.id}`,name:e.name||e.id,providerId:a.provider,providerName:de(a),source:"static"}:null}function Qe(e,a){const m=typeof e=="string"?e:(e==null?void 0:e.id)||(e==null?void 0:e.name)||(e==null?void 0:e.model)||"";if(!m)return null;const u=typeof e=="string"?e:(e==null?void 0:e.name)||(e==null?void 0:e.displayName)||m;let w=m;return(je(a.provider)||Ie(a.provider))&&!m.includes("/")&&(w=`${a.provider}/${m}`),{id:w,requestModel:w,name:u,providerId:a.provider,providerName:de(a),source:"live"}}function Xe(e){return Array.isArray(e==null?void 0:e.models)?e.models:Array.isArray(e==null?void 0:e.data)?e.data:Array.isArray(e==null?void 0:e.results)?e.results:Array.isArray(e)?e:[]}function Ze(e){const a=new Map;for(const m of e)m!=null&&m.id&&(a.has(m.id)||a.set(m.id,m));return Array.from(a.values())}function et(){const[e,a]=d.useState([]),[m,u]=d.useState(!0),[w,A]=d.useState(""),[h,D]=d.useState(()=>{if(typeof window>"u")return[];try{const t=Fe(globalThis.localStorage.getItem(O.sessions),[]);return Array.isArray(t)?t.map(r=>({...r,messages:Array.isArray(r.messages)?r.messages:[]})):[]}catch{return[]}}),[g,M]=d.useState(()=>typeof window>"u"?"":globalThis.localStorage.getItem(O.activeSessionId)||""),[R,P]=d.useState(()=>typeof window>"u"?"":globalThis.localStorage.getItem(O.activeProviderId)||""),[I,U]=d.useState(""),[_,ce]=d.useState(()=>typeof window>"u"?"":globalThis.localStorage.getItem(O.draft)||""),[z,Q]=d.useState([]),[me,ue]=d.useState(!1),[Se,pe]=d.useState(""),[fe,X]=d.useState(""),[K,Ae]=d.useState(!1),[Me,Z]=d.useState(!1),[De,ee]=d.useState(!1),xe=d.useRef(null),B=d.useRef(null),te=d.useRef(!1),se=d.useRef(null),re=d.useRef(null);d.useEffect(()=>{Ae(!0)},[]),d.useEffect(()=>{let t=!1;async function r(){u(!0),A("");try{const n=await(await fetch("/api/providers",{cache:"no-store"})).json().catch(()=>({})),o=Array.isArray(n.connections)?n.connections.filter(c=>(c==null?void 0:c.isActive)!==!1):[];if(o.length===0){t||(a([]),A("No providers connected yet."));return}const x=new Map;for(const c of o){const p=c.provider||c.id,b=de(c),$=je(p)?"openai-compatible":Ie(p)?"anthropic-compatible":p;x.has(p)||x.set(p,{providerId:p,providerName:b,providerType:$,connections:[],models:[]});const N=x.get(p);N.providerName=N.providerName||b,N.providerType=N.providerType||$,N.connections.push(c);const W=Le(p).map(Y=>Ge(Y,c)).filter(Boolean);N.models.push(...W)}const k=await Promise.all(o.map(async c=>{try{const p=await fetch(`/api/providers/${c.id}/models`,{cache:"no-store"}),b=await p.json().catch(()=>({}));if(!p.ok)return{connection:c,models:[]};const $=Xe(b).map(N=>Qe(N,c)).filter(Boolean);return{connection:c,models:$}}catch{return{connection:c,models:[]}}}));for(const c of k){const p=c.connection.provider||c.connection.id,b=x.get(p);b&&b.models.push(...c.models)}const q=Array.from(x.values()).map(c=>({...c,models:Ze(c.models).sort((p,b)=>p.name.localeCompare(b.name))})).filter(c=>c.models.length>0).sort((c,p)=>c.providerName.localeCompare(p.providerName));t||(a(q),q.length===0&&A("Providers connected but no models available."))}catch(i){t||(A(S(i==null?void 0:i.message)||"Failed to load providers/models."),a([]))}finally{t||u(!1)}}return r(),()=>{t=!0}},[]),d.useEffect(()=>{const t=r=>{se.current&&!se.current.contains(r.target)&&Z(!1),re.current&&!re.current.contains(r.target)&&ee(!1)};return document.addEventListener("mousedown",t),()=>document.removeEventListener("mousedown",t)},[]);const y=d.useMemo(()=>{const t=new Map;for(const r of e)for(const i of r.models)t.set(i.id,{...i,providerId:r.providerId,providerName:r.providerName});return t},[e]),E=d.useMemo(()=>e.find(t=>t.providerId===R)||e[0]||null,[e,R]),v=d.useMemo(()=>{var t;if(I&&y.has(I))return y.get(I);if(g){const r=h.find(i=>i.id===g);if(r!=null&&r.modelId&&y.has(r.modelId))return y.get(r.modelId)}return((t=E==null?void 0:E.models)==null?void 0:t[0])||null},[I,y,E,h,g]),ie=d.useMemo(()=>h.find(t=>t.id===g)||null,[h,g]),he=(ie==null?void 0:ie.messages)||[],ge=d.useMemo(()=>[...h].sort((t,r)=>new Date(r.updatedAt).getTime()-new Date(t.updatedAt).getTime()),[h]),ae=!me&&!!v&&(_.trim().length>0||z.length>0);d.useEffect(()=>{if(K)try{globalThis.localStorage.setItem(O.sessions,JSON.stringify(h)),globalThis.localStorage.setItem(O.activeSessionId,g),globalThis.localStorage.setItem(O.activeProviderId,R),globalThis.localStorage.setItem(O.draft,_)}catch{}},[K,h,g,R,_]),d.useEffect(()=>{if(!K||m||te.current||e.length===0)return;const t=e.find(n=>n.providerId===R)||e[0],r=I&&y.has(I)?y.get(I):t.models[0];if(h.length>0){const n=h.find(x=>x.id===g)||h[0],o=n!=null&&n.modelId&&y.has(n.modelId)?y.get(n.modelId):r;te.current=!0,M(n.id),P((o==null?void 0:o.providerId)||t.providerId),U((o==null?void 0:o.id)||r.id);return}const i={id:J(),title:"New chat",providerId:t.providerId,providerName:t.providerName,modelId:r.id,modelName:r.name,createdAt:new Date().toISOString(),updatedAt:new Date().toISOString(),messages:[]};te.current=!0,D([i]),M(i.id),P(t.providerId),U(r.id)},[K,m,e,y,h,g,R,I]);const L=(t,r)=>{D(i=>i.map(n=>n.id===t?r(Ve(n)):n))},ne=t=>t?{id:J(),title:"New chat",providerId:t.providerId,providerName:t.providerName,modelId:t.id,modelName:t.name,createdAt:new Date().toISOString(),updatedAt:new Date().toISOString(),messages:[]}:null,ke=t=>{const r=h.find(i=>i.id===t);r&&(M(t),P(r.providerId||R),U(r.modelId||I),ee(!1))},Te=()=>{if(!g)return;const t=h.filter(i=>i.id!==g),r=t[0]||null;D(t),r?(M(r.id),P(r.providerId),U(r.modelId)):(M(""),P(""),U(""))},Ce=t=>{const r=y.get(t);if(!r)return;const i=h.find(n=>n.id===g);if(i&&i.messages.length>0){const n=ne(r);if(!n)return;D(o=>[n,...o]),M(n.id)}else if(i)D(n=>n.map(o=>o.id===i.id?{...o,providerId:r.providerId,providerName:r.providerName,modelId:r.id,modelName:r.name}:o)),M(i.id);else{const n=ne(r);if(!n)return;D(o=>[n,...o]),M(n.id)}P(r.providerId),U(r.id),Z(!1)},Oe=async t=>{const r=Array.from(t.target.files||[]);if(r.length===0)return;const i=r.filter(o=>o.type.startsWith("image/"));if(i.length===0){t.target.value="";return}const n=await Promise.all(i.map(async o=>({id:J(),name:o.name,type:o.type,size:o.size,dataUrl:await Ye(o)})));Q(o=>[...o,...n]),t.target.value=""},Re=t=>{Q(r=>r.filter(i=>i.id!==t))},Ee=()=>{var t;(t=B.current)==null||t.abort()},$e=(t,r)=>{const i=Ne(r);L(t,n=>({...n,title:n.title==="New chat"?i:n.title,updatedAt:new Date().toISOString()}))},we=async()=>{var p,b,$,N,W,Y;const t=v||((p=E==null?void 0:E.models)==null?void 0:p[0])||null;if(!t)return;const r=_.trim();if(!r&&z.length===0)return;let i=g,n=h.find(l=>l.id===i);if(!n){if(n=ne(t),!n)return;i=n.id,D(l=>[n,...l]),M(i)}const o={id:J(),role:"user",content:r,attachments:z.map(l=>({id:l.id,name:l.name,type:l.type,dataUrl:l.dataUrl})),createdAt:new Date().toISOString()},x=J(),k={id:x,role:"assistant",content:"",createdAt:new Date().toISOString(),status:"streaming"},q=[...n.messages||[],o,k];D(l=>l.map(j=>j.id===i?{...j,providerId:t.providerId,providerName:t.providerName,modelId:t.id,modelName:t.name,messages:q,updatedAt:new Date().toISOString(),title:j.title==="New chat"?Ne(r):j.title}:j)),ce(""),Q([]),ue(!0),pe(x),X(""),(b=B.current)==null||b.abort(),B.current=new AbortController;const c=q.filter(l=>!(l.role==="assistant"&&l.id===x)).map(l=>({role:l.role,content:l.role==="user"?Ke(l):l.content}));try{const l=await fetch("/api/dashboard/chat/completions",{method:"POST",headers:{"Content-Type":"application/json",Accept:"text/event-stream"},body:JSON.stringify({model:t.requestModel||t.id,messages:c,stream:!0}),signal:B.current.signal});if(!l.ok){const f=await l.json().catch(()=>({}));throw new Error(S(f.error||f.message||`Request failed (${l.status})`))}const j=($=l.body)==null?void 0:$.getReader();if(!j){const f=await l.json().catch(()=>({})),C=S(((Y=(W=(N=f==null?void 0:f.choices)==null?void 0:N[0])==null?void 0:W.message)==null?void 0:Y.content)||(f==null?void 0:f.output_text)||(f==null?void 0:f.error)||(f==null?void 0:f.message)||"");L(i,F=>({...F,messages:F.messages.map(H=>H.id===x?{...H,content:C,status:"done"}:H),updatedAt:new Date().toISOString()}));return}const V=new TextDecoder;let T="",G="";for(;;){const{value:f,done:C}=await j.read();if(C)break;T+=V.decode(f,{stream:!0});const F=T.split(/\r?\n/);T=F.pop()||"";for(const H of F){const ve=H.trim();if(!ve.startsWith("data:"))continue;const oe=ve.slice(5).trim();if(!(!oe||oe==="[DONE]"))try{const ze=JSON.parse(oe),be=We(ze);if(!be)continue;G+=be,X(G),L(i,ye=>({...ye,messages:ye.messages.map(le=>le.id===x?{...le,content:G,status:"streaming"}:le),updatedAt:new Date().toISOString()}))}catch{}}}L(i,f=>({...f,messages:f.messages.map(C=>C.id===x?{...C,content:G||C.content,status:"done"}:C),updatedAt:new Date().toISOString()})),$e(i,r)}catch(l){if(l.name!=="AbortError"){const j=S((l==null?void 0:l.message)||l);L(i,V=>({...V,messages:V.messages.map(T=>T.id===x?{...T,content:T.content||`Error: ${j}`,status:"error"}:T),updatedAt:new Date().toISOString()})),A(j||"Failed to send message.")}}finally{ue(!1),pe(""),X(""),B.current=null}},Pe=t=>{t.key==="Enter"&&!t.shiftKey&&(t.preventDefault(),ae&&we())},Ue=v?`${v.name}`:"Select model",_e=v?v.requestModel:"Choose from connected providers";return s.jsx("div",{className:"relative flex-1 flex flex-col h-full min-h-0 min-w-0 bg-[#212121] text-white overflow-hidden",children:s.jsxs("div",{className:"relative mx-auto flex flex-1 h-full min-h-0 w-full max-w-4xl flex-col",children:[s.jsxs("div",{className:"flex shrink-0 items-center justify-between gap-3 px-4 py-3 lg:px-6",children:[s.jsxs("div",{ref:se,className:"relative",children:[s.jsx("button",{type:"button",onClick:()=>Z(t=>!t),className:"flex items-center gap-3 rounded-2xl border border-white/10 bg-white/5 px-4 py-3 text-left transition hover:bg-white/8",children:s.jsxs("div",{className:"min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-sm font-semibold text-white",children:Ue}),s.jsx("span",{className:"material-symbols-outlined text-[18px] text-white/70",children:"expand_more"})]}),s.jsx("p",{className:"truncate text-xs text-white/55",children:_e})]})}),Me?s.jsxs("div",{className:"absolute left-0 top-[calc(100%+10px)] z-30 w-[min(520px,calc(100vw-2rem))] overflow-hidden rounded-[20px] border border-white/10 bg-[#262626] shadow-2xl shadow-black/50",children:[s.jsxs("div",{className:"border-b border-white/10 px-4 py-3",children:[s.jsx("p",{className:"text-xs uppercase tracking-[0.22em] text-white/45",children:"Models"}),s.jsx("p",{className:"text-sm text-white/75",children:"Only from connected providers"})]}),s.jsx("div",{className:"max-h-[60vh] overflow-y-auto p-2 custom-scrollbar",children:e.map(t=>s.jsxs("div",{className:"mb-2 rounded-[16px] border border-white/10 bg-black/20 p-2",children:[s.jsxs("div",{className:"flex items-center justify-between px-2 py-2",children:[s.jsx("p",{className:"text-sm font-semibold text-white",children:t.providerName}),s.jsx(qe,{size:"sm",variant:"default",children:t.models.length})]}),s.jsx("div",{className:"grid gap-2 sm:grid-cols-2",children:t.models.map(r=>{const i=r.id===I;return s.jsx("button",{type:"button",onClick:()=>Ce(r.id),className:`rounded-[14px] border px-3 py-3 text-left transition ${i?"border-blue-400/40 bg-blue-500/15":"border-white/10 bg-white/5 hover:bg-white/8"}`,children:s.jsxs("div",{className:"flex items-start justify-between gap-3",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("p",{className:"truncate text-sm font-medium text-white",children:r.name}),s.jsx("p",{className:"truncate text-[11px] text-white/45",children:r.requestModel})]}),i?s.jsx("span",{className:"material-symbols-outlined text-[18px] text-blue-300",children:"check_circle"}):null]})},r.id)})})]},t.providerId))})]}):null]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("button",{type:"button",onClick:()=>ee(t=>!t),className:"rounded-2xl border border-white/10 bg-white/5 px-4 py-3 text-sm text-white/80 transition hover:bg-white/8",children:"History"}),s.jsx(Be,{variant:"ghost",size:"sm",icon:"delete",onClick:Te,disabled:!g||h.length===0,children:"Clear"})]})]}),De?s.jsxs("div",{ref:re,className:"absolute right-4 top-[72px] z-20 w-[min(360px,calc(100vw-2rem))] rounded-[20px] border border-white/10 bg-[#262626] p-2 shadow-2xl shadow-black/50 lg:right-6",children:[s.jsx("div",{className:"px-3 py-2",children:s.jsx("p",{className:"text-xs uppercase tracking-[0.22em] text-white/45",children:"Recent chats"})}),s.jsx("div",{className:"max-h-[48vh] space-y-2 overflow-y-auto p-1 custom-scrollbar",children:ge.length===0?s.jsx("div",{className:"rounded-[16px] border border-dashed border-white/10 bg-white/5 p-4 text-sm text-white/55",children:"No conversations yet."}):ge.map(t=>{var n;const r=t.id===g,i=[...t.messages||[]].reverse().find(o=>o.role==="user")||((n=t.messages)==null?void 0:n[0]);return s.jsx("button",{type:"button",onClick:()=>ke(t.id),className:`w-full rounded-[16px] border px-3 py-3 text-left transition ${r?"border-blue-400/40 bg-blue-500/15":"border-white/10 bg-white/5 hover:bg-white/8"}`,children:s.jsxs("div",{className:"flex items-start justify-between gap-3",children:[s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("p",{className:"truncate text-sm font-medium text-white",children:t.title}),s.jsx("p",{className:"mt-1 truncate text-xs text-white/50",children:S(i==null?void 0:i.content)||"Empty chat"})]}),s.jsx("span",{className:"text-[10px] text-white/40 shrink-0",children:Je(t.updatedAt)})]})},t.id)})})]}):null,w?s.jsx("div",{className:"mt-4 rounded-[18px] border border-rose-500/20 bg-rose-500/10 px-4 py-3 text-rose-100",children:s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx("span",{className:"material-symbols-outlined text-[20px]",children:"error"}),s.jsx("p",{className:"text-sm leading-6",children:w})]})}):null,s.jsxs("div",{className:"flex flex-1 flex-col min-h-0",children:[s.jsxs("div",{className:"flex-1 overflow-y-auto py-4 custom-scrollbar",children:[he.length===0?s.jsx("div",{className:"flex min-h-[50vh] items-center justify-center px-4 text-center",children:s.jsxs("div",{className:"max-w-xl space-y-4",children:[s.jsx("div",{className:"mx-auto flex size-16 items-center justify-center rounded-[20px] border border-white/10 bg-white/5 text-white/80",children:s.jsx("span",{className:"material-symbols-outlined text-[30px]",children:"chat"})}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("h2",{className:"text-2xl font-semibold text-white",children:"Start a conversation"}),s.jsx("p",{className:"text-sm leading-6 text-white/60",children:"Simple chat interface to interact with any AI model from connected providers. Select a model and start chatting!"})]})]})}):null,s.jsx("div",{className:"mx-auto flex w-full max-w-3xl flex-col gap-4 px-4",children:he.map(t=>{var x;const r=t.role==="user",i=t.role==="assistant",n=i&&t.id===Se&&t.status==="streaming",o=S(t.content)||(i?fe:"");return s.jsx("div",{className:`flex w-full ${r?"justify-end":"justify-start"} mb-6`,children:s.jsxs("div",{className:`max-w-[min(88%,42rem)] ${r?"rounded-3xl bg-[#2f2f2f] px-5 py-3.5 text-white":"text-white/90"}`,children:[s.jsx("div",{className:"mb-1 flex items-center justify-between gap-3",children:s.jsx("span",{className:"text-xs font-semibold",children:r?"You":(v==null?void 0:v.name)||"Assistant"})}),(x=t.attachments)!=null&&x.length?s.jsx("div",{className:"mb-3 grid grid-cols-2 gap-2 sm:grid-cols-3 mt-2",children:t.attachments.map(k=>s.jsx("a",{href:k.dataUrl,target:"_blank",rel:"noreferrer",className:"overflow-hidden rounded-[18px] border border-white/10 bg-black/20",children:s.jsx("img",{src:k.dataUrl,alt:k.name,className:"h-28 w-full object-cover"})},k.id))}):null,s.jsxs("div",{className:"whitespace-pre-wrap break-words text-[15px] leading-7",children:[o,i&&n&&!fe?s.jsx("span",{className:"inline-block animate-pulse",children:"▋"}):null]})]})},t.id)})})]}),s.jsxs("div",{className:"shrink-0 pt-2",children:[z.length>0?s.jsx("div",{className:"mx-auto mb-3 flex w-full max-w-3xl flex-wrap gap-2 px-4",children:z.map(t=>s.jsxs("div",{className:"flex items-center gap-2 rounded-full border border-white/10 bg-white/5 px-3 py-2",children:[s.jsx("span",{className:"text-xs text-white/80 max-w-[12rem] truncate",children:t.name}),s.jsx("button",{type:"button",onClick:()=>Re(t.id),className:"text-white/55 hover:text-white","aria-label":"Remove attachment",children:s.jsx("span",{className:"material-symbols-outlined text-[18px]",children:"close"})})]},t.id))}):null,s.jsx("div",{className:"mx-auto w-full max-w-3xl px-4 pb-2",children:s.jsxs("div",{className:"rounded-[26px] bg-[#2f2f2f] px-3 pt-3 pb-2 shadow-[0_0_15px_rgba(0,0,0,0.10)] ring-1 ring-white/5",children:[s.jsx("textarea",{value:_,onChange:t=>ce(t.target.value),onKeyDown:Pe,placeholder:"Message AI",rows:1,className:"w-full resize-none bg-transparent px-2 text-[15px] leading-6 text-white outline-none placeholder:text-white/40 custom-scrollbar max-h-[25vh] overflow-y-auto"}),s.jsxs("div",{className:"mt-2 flex items-center justify-between gap-3",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("button",{type:"button",onClick:()=>{var t;return(t=xe.current)==null?void 0:t.click()},disabled:!v||m,className:"p-2 text-white/50 hover:text-white transition rounded-full hover:bg-white/5",children:s.jsx("span",{className:"material-symbols-outlined text-[20px]",children:"attach_file"})}),s.jsx("input",{ref:xe,type:"file",accept:"image/*",multiple:!0,className:"hidden",onChange:Oe}),s.jsx("span",{className:"text-xs font-medium text-white/30 truncate max-w-[120px]",children:v?v.name:"No model"})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[me?s.jsx("button",{type:"button",onClick:Ee,className:"p-2 text-white bg-white/10 hover:bg-white/20 transition rounded-full h-8 w-8 flex items-center justify-center",children:s.jsx("span",{className:"material-symbols-outlined text-[16px]",children:"stop"})}):null,s.jsx("button",{onClick:we,disabled:!ae,className:`h-8 w-8 rounded-full flex items-center justify-center transition ${ae?"bg-white text-black hover:opacity-90":"bg-white/10 text-white/30 cursor-not-allowed"}`,children:s.jsx("span",{className:"material-symbols-outlined text-[16px]",children:"arrow_upward"})})]})]})]})})]}),s.jsx("p",{className:"mx-auto mt-2 max-w-3xl px-4 pb-4 text-center text-[11px] text-white/30",children:"Model list is filtered from connected providers."})]})]})})}function at(){return s.jsx(et,{})}export{at as default};
1
+ import{j as s,B as Be,k as je,l as Ie,h as Le}from"./index.Be3gbrBl.js";import{b as d}from"./router.Cjj1--8t.js";import{B as qe}from"./NoAuthProxyCard.BDcXaWvM.js";import"./zustand.akaTi5uX.js";const O={sessions:"basic-chat.sessions",activeSessionId:"basic-chat.activeSessionId",activeProviderId:"basic-chat.activeProviderId",draft:"basic-chat.draft"};function J(){var e;return(e=globalThis.crypto)!=null&&e.randomUUID?globalThis.crypto.randomUUID():`chat_${Date.now()}_${Math.random().toString(16).slice(2)}`}function Fe(e,a){try{return JSON.parse(e)}catch{return a}}function S(e){if(typeof e=="string")return e;if(e==null)return"";if(Array.isArray(e))return e.map(S).filter(Boolean).join(" ");if(typeof e=="object"){if(typeof e.message=="string")return e.message;if(typeof e.error=="string")return e.error;try{return JSON.stringify(e)}catch{return String(e)}}return String(e)}function He(e=""){return String(e).replace(/[-_]/g," ").replace(/\b\w/g,a=>a.toUpperCase()).trim()||"Unknown"}function Je(e){if(!e)return"Now";const a=new Date(e).getTime();if(Number.isNaN(a))return"Now";const m=Math.max(1,Math.round((Date.now()-a)/6e4));if(m<60)return`${m}m`;const u=Math.round(m/60);return u<24?`${u}h`:`${Math.round(u/24)}d`}function Ne(e=""){const a=S(e).replace(/\s+/g," ").trim();return a?a.length>52?`${a.slice(0,52).trimEnd()}…`:a:"New chat"}function Ke(e){const a=S(e.content).trim(),m=Array.isArray(e.attachments)?e.attachments:[];if(m.length===0)return a;const u=[];a&&u.push({type:"text",text:a});for(const w of m)w!=null&&w.dataUrl&&u.push({type:"image_url",image_url:{url:w.dataUrl}});return u.length>0?u:a}function We(e){var w,A;if(!e||typeof e!="object")return"";const a=(w=e.choices)==null?void 0:w[0];return[((a==null?void 0:a.delta)||{}).content,(A=a==null?void 0:a.message)==null?void 0:A.content,e.output_text,e.text].map(S).filter(Boolean)[0]||""}async function Ye(e){return await new Promise((a,m)=>{const u=new FileReader;u.onload=()=>a(String(u.result||"")),u.onerror=()=>m(u.error||new Error("Failed to read file")),u.readAsDataURL(e)})}function Ve(e){return{...e,messages:Array.isArray(e.messages)?e.messages.map(a=>({...a})):[]}}function de(e){return(e==null?void 0:e.name)||He((e==null?void 0:e.provider)||(e==null?void 0:e.id)||"provider")}function Ge(e,a){return e!=null&&e.id?{id:`${a.provider}/${e.id}`,requestModel:`${a.provider}/${e.id}`,name:e.name||e.id,providerId:a.provider,providerName:de(a),source:"static"}:null}function Qe(e,a){const m=typeof e=="string"?e:(e==null?void 0:e.id)||(e==null?void 0:e.name)||(e==null?void 0:e.model)||"";if(!m)return null;const u=typeof e=="string"?e:(e==null?void 0:e.name)||(e==null?void 0:e.displayName)||m;let w=m;return(je(a.provider)||Ie(a.provider))&&!m.includes("/")&&(w=`${a.provider}/${m}`),{id:w,requestModel:w,name:u,providerId:a.provider,providerName:de(a),source:"live"}}function Xe(e){return Array.isArray(e==null?void 0:e.models)?e.models:Array.isArray(e==null?void 0:e.data)?e.data:Array.isArray(e==null?void 0:e.results)?e.results:Array.isArray(e)?e:[]}function Ze(e){const a=new Map;for(const m of e)m!=null&&m.id&&(a.has(m.id)||a.set(m.id,m));return Array.from(a.values())}function et(){const[e,a]=d.useState([]),[m,u]=d.useState(!0),[w,A]=d.useState(""),[h,D]=d.useState(()=>{if(typeof window>"u")return[];try{const t=Fe(globalThis.localStorage.getItem(O.sessions),[]);return Array.isArray(t)?t.map(r=>({...r,messages:Array.isArray(r.messages)?r.messages:[]})):[]}catch{return[]}}),[g,M]=d.useState(()=>typeof window>"u"?"":globalThis.localStorage.getItem(O.activeSessionId)||""),[R,P]=d.useState(()=>typeof window>"u"?"":globalThis.localStorage.getItem(O.activeProviderId)||""),[I,U]=d.useState(""),[_,ce]=d.useState(()=>typeof window>"u"?"":globalThis.localStorage.getItem(O.draft)||""),[z,Q]=d.useState([]),[me,ue]=d.useState(!1),[Se,pe]=d.useState(""),[fe,X]=d.useState(""),[K,Ae]=d.useState(!1),[Me,Z]=d.useState(!1),[De,ee]=d.useState(!1),xe=d.useRef(null),B=d.useRef(null),te=d.useRef(!1),se=d.useRef(null),re=d.useRef(null);d.useEffect(()=>{Ae(!0)},[]),d.useEffect(()=>{let t=!1;async function r(){u(!0),A("");try{const n=await(await fetch("/api/providers",{cache:"no-store"})).json().catch(()=>({})),o=Array.isArray(n.connections)?n.connections.filter(c=>(c==null?void 0:c.isActive)!==!1):[];if(o.length===0){t||(a([]),A("No providers connected yet."));return}const x=new Map;for(const c of o){const p=c.provider||c.id,b=de(c),$=je(p)?"openai-compatible":Ie(p)?"anthropic-compatible":p;x.has(p)||x.set(p,{providerId:p,providerName:b,providerType:$,connections:[],models:[]});const N=x.get(p);N.providerName=N.providerName||b,N.providerType=N.providerType||$,N.connections.push(c);const W=Le(p).map(Y=>Ge(Y,c)).filter(Boolean);N.models.push(...W)}const k=await Promise.all(o.map(async c=>{try{const p=await fetch(`/api/providers/${c.id}/models`,{cache:"no-store"}),b=await p.json().catch(()=>({}));if(!p.ok)return{connection:c,models:[]};const $=Xe(b).map(N=>Qe(N,c)).filter(Boolean);return{connection:c,models:$}}catch{return{connection:c,models:[]}}}));for(const c of k){const p=c.connection.provider||c.connection.id,b=x.get(p);b&&b.models.push(...c.models)}const q=Array.from(x.values()).map(c=>({...c,models:Ze(c.models).sort((p,b)=>p.name.localeCompare(b.name))})).filter(c=>c.models.length>0).sort((c,p)=>c.providerName.localeCompare(p.providerName));t||(a(q),q.length===0&&A("Providers connected but no models available."))}catch(i){t||(A(S(i==null?void 0:i.message)||"Failed to load providers/models."),a([]))}finally{t||u(!1)}}return r(),()=>{t=!0}},[]),d.useEffect(()=>{const t=r=>{se.current&&!se.current.contains(r.target)&&Z(!1),re.current&&!re.current.contains(r.target)&&ee(!1)};return document.addEventListener("mousedown",t),()=>document.removeEventListener("mousedown",t)},[]);const y=d.useMemo(()=>{const t=new Map;for(const r of e)for(const i of r.models)t.set(i.id,{...i,providerId:r.providerId,providerName:r.providerName});return t},[e]),E=d.useMemo(()=>e.find(t=>t.providerId===R)||e[0]||null,[e,R]),v=d.useMemo(()=>{var t;if(I&&y.has(I))return y.get(I);if(g){const r=h.find(i=>i.id===g);if(r!=null&&r.modelId&&y.has(r.modelId))return y.get(r.modelId)}return((t=E==null?void 0:E.models)==null?void 0:t[0])||null},[I,y,E,h,g]),ie=d.useMemo(()=>h.find(t=>t.id===g)||null,[h,g]),he=(ie==null?void 0:ie.messages)||[],ge=d.useMemo(()=>[...h].sort((t,r)=>new Date(r.updatedAt).getTime()-new Date(t.updatedAt).getTime()),[h]),ae=!me&&!!v&&(_.trim().length>0||z.length>0);d.useEffect(()=>{if(K)try{globalThis.localStorage.setItem(O.sessions,JSON.stringify(h)),globalThis.localStorage.setItem(O.activeSessionId,g),globalThis.localStorage.setItem(O.activeProviderId,R),globalThis.localStorage.setItem(O.draft,_)}catch{}},[K,h,g,R,_]),d.useEffect(()=>{if(!K||m||te.current||e.length===0)return;const t=e.find(n=>n.providerId===R)||e[0],r=I&&y.has(I)?y.get(I):t.models[0];if(h.length>0){const n=h.find(x=>x.id===g)||h[0],o=n!=null&&n.modelId&&y.has(n.modelId)?y.get(n.modelId):r;te.current=!0,M(n.id),P((o==null?void 0:o.providerId)||t.providerId),U((o==null?void 0:o.id)||r.id);return}const i={id:J(),title:"New chat",providerId:t.providerId,providerName:t.providerName,modelId:r.id,modelName:r.name,createdAt:new Date().toISOString(),updatedAt:new Date().toISOString(),messages:[]};te.current=!0,D([i]),M(i.id),P(t.providerId),U(r.id)},[K,m,e,y,h,g,R,I]);const L=(t,r)=>{D(i=>i.map(n=>n.id===t?r(Ve(n)):n))},ne=t=>t?{id:J(),title:"New chat",providerId:t.providerId,providerName:t.providerName,modelId:t.id,modelName:t.name,createdAt:new Date().toISOString(),updatedAt:new Date().toISOString(),messages:[]}:null,ke=t=>{const r=h.find(i=>i.id===t);r&&(M(t),P(r.providerId||R),U(r.modelId||I),ee(!1))},Te=()=>{if(!g)return;const t=h.filter(i=>i.id!==g),r=t[0]||null;D(t),r?(M(r.id),P(r.providerId),U(r.modelId)):(M(""),P(""),U(""))},Ce=t=>{const r=y.get(t);if(!r)return;const i=h.find(n=>n.id===g);if(i&&i.messages.length>0){const n=ne(r);if(!n)return;D(o=>[n,...o]),M(n.id)}else if(i)D(n=>n.map(o=>o.id===i.id?{...o,providerId:r.providerId,providerName:r.providerName,modelId:r.id,modelName:r.name}:o)),M(i.id);else{const n=ne(r);if(!n)return;D(o=>[n,...o]),M(n.id)}P(r.providerId),U(r.id),Z(!1)},Oe=async t=>{const r=Array.from(t.target.files||[]);if(r.length===0)return;const i=r.filter(o=>o.type.startsWith("image/"));if(i.length===0){t.target.value="";return}const n=await Promise.all(i.map(async o=>({id:J(),name:o.name,type:o.type,size:o.size,dataUrl:await Ye(o)})));Q(o=>[...o,...n]),t.target.value=""},Re=t=>{Q(r=>r.filter(i=>i.id!==t))},Ee=()=>{var t;(t=B.current)==null||t.abort()},$e=(t,r)=>{const i=Ne(r);L(t,n=>({...n,title:n.title==="New chat"?i:n.title,updatedAt:new Date().toISOString()}))},we=async()=>{var p,b,$,N,W,Y;const t=v||((p=E==null?void 0:E.models)==null?void 0:p[0])||null;if(!t)return;const r=_.trim();if(!r&&z.length===0)return;let i=g,n=h.find(l=>l.id===i);if(!n){if(n=ne(t),!n)return;i=n.id,D(l=>[n,...l]),M(i)}const o={id:J(),role:"user",content:r,attachments:z.map(l=>({id:l.id,name:l.name,type:l.type,dataUrl:l.dataUrl})),createdAt:new Date().toISOString()},x=J(),k={id:x,role:"assistant",content:"",createdAt:new Date().toISOString(),status:"streaming"},q=[...n.messages||[],o,k];D(l=>l.map(j=>j.id===i?{...j,providerId:t.providerId,providerName:t.providerName,modelId:t.id,modelName:t.name,messages:q,updatedAt:new Date().toISOString(),title:j.title==="New chat"?Ne(r):j.title}:j)),ce(""),Q([]),ue(!0),pe(x),X(""),(b=B.current)==null||b.abort(),B.current=new AbortController;const c=q.filter(l=>!(l.role==="assistant"&&l.id===x)).map(l=>({role:l.role,content:l.role==="user"?Ke(l):l.content}));try{const l=await fetch("/api/dashboard/chat/completions",{method:"POST",headers:{"Content-Type":"application/json",Accept:"text/event-stream"},body:JSON.stringify({model:t.requestModel||t.id,messages:c,stream:!0}),signal:B.current.signal});if(!l.ok){const f=await l.json().catch(()=>({}));throw new Error(S(f.error||f.message||`Request failed (${l.status})`))}const j=($=l.body)==null?void 0:$.getReader();if(!j){const f=await l.json().catch(()=>({})),C=S(((Y=(W=(N=f==null?void 0:f.choices)==null?void 0:N[0])==null?void 0:W.message)==null?void 0:Y.content)||(f==null?void 0:f.output_text)||(f==null?void 0:f.error)||(f==null?void 0:f.message)||"");L(i,F=>({...F,messages:F.messages.map(H=>H.id===x?{...H,content:C,status:"done"}:H),updatedAt:new Date().toISOString()}));return}const V=new TextDecoder;let T="",G="";for(;;){const{value:f,done:C}=await j.read();if(C)break;T+=V.decode(f,{stream:!0});const F=T.split(/\r?\n/);T=F.pop()||"";for(const H of F){const ve=H.trim();if(!ve.startsWith("data:"))continue;const oe=ve.slice(5).trim();if(!(!oe||oe==="[DONE]"))try{const ze=JSON.parse(oe),be=We(ze);if(!be)continue;G+=be,X(G),L(i,ye=>({...ye,messages:ye.messages.map(le=>le.id===x?{...le,content:G,status:"streaming"}:le),updatedAt:new Date().toISOString()}))}catch{}}}L(i,f=>({...f,messages:f.messages.map(C=>C.id===x?{...C,content:G||C.content,status:"done"}:C),updatedAt:new Date().toISOString()})),$e(i,r)}catch(l){if(l.name!=="AbortError"){const j=S((l==null?void 0:l.message)||l);L(i,V=>({...V,messages:V.messages.map(T=>T.id===x?{...T,content:T.content||`Error: ${j}`,status:"error"}:T),updatedAt:new Date().toISOString()})),A(j||"Failed to send message.")}}finally{ue(!1),pe(""),X(""),B.current=null}},Pe=t=>{t.key==="Enter"&&!t.shiftKey&&(t.preventDefault(),ae&&we())},Ue=v?`${v.name}`:"Select model",_e=v?v.requestModel:"Choose from connected providers";return s.jsx("div",{className:"relative flex-1 flex flex-col h-full min-h-0 min-w-0 bg-[#212121] text-white overflow-hidden",children:s.jsxs("div",{className:"relative mx-auto flex flex-1 h-full min-h-0 w-full max-w-4xl flex-col",children:[s.jsxs("div",{className:"flex shrink-0 items-center justify-between gap-3 px-4 py-3 lg:px-6",children:[s.jsxs("div",{ref:se,className:"relative",children:[s.jsx("button",{type:"button",onClick:()=>Z(t=>!t),className:"flex items-center gap-3 rounded-2xl border border-white/10 bg-white/5 px-4 py-3 text-left transition hover:bg-white/8",children:s.jsxs("div",{className:"min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-sm font-semibold text-white",children:Ue}),s.jsx("span",{className:"material-symbols-outlined text-[18px] text-white/70",children:"expand_more"})]}),s.jsx("p",{className:"truncate text-xs text-white/55",children:_e})]})}),Me?s.jsxs("div",{className:"absolute left-0 top-[calc(100%+10px)] z-30 w-[min(520px,calc(100vw-2rem))] overflow-hidden rounded-[20px] border border-white/10 bg-[#262626] shadow-2xl shadow-black/50",children:[s.jsxs("div",{className:"border-b border-white/10 px-4 py-3",children:[s.jsx("p",{className:"text-xs uppercase tracking-[0.22em] text-white/45",children:"Models"}),s.jsx("p",{className:"text-sm text-white/75",children:"Only from connected providers"})]}),s.jsx("div",{className:"max-h-[60vh] overflow-y-auto p-2 custom-scrollbar",children:e.map(t=>s.jsxs("div",{className:"mb-2 rounded-[16px] border border-white/10 bg-black/20 p-2",children:[s.jsxs("div",{className:"flex items-center justify-between px-2 py-2",children:[s.jsx("p",{className:"text-sm font-semibold text-white",children:t.providerName}),s.jsx(qe,{size:"sm",variant:"default",children:t.models.length})]}),s.jsx("div",{className:"grid gap-2 sm:grid-cols-2",children:t.models.map(r=>{const i=r.id===I;return s.jsx("button",{type:"button",onClick:()=>Ce(r.id),className:`rounded-[14px] border px-3 py-3 text-left transition ${i?"border-blue-400/40 bg-blue-500/15":"border-white/10 bg-white/5 hover:bg-white/8"}`,children:s.jsxs("div",{className:"flex items-start justify-between gap-3",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("p",{className:"truncate text-sm font-medium text-white",children:r.name}),s.jsx("p",{className:"truncate text-[11px] text-white/45",children:r.requestModel})]}),i?s.jsx("span",{className:"material-symbols-outlined text-[18px] text-blue-300",children:"check_circle"}):null]})},r.id)})})]},t.providerId))})]}):null]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("button",{type:"button",onClick:()=>ee(t=>!t),className:"rounded-2xl border border-white/10 bg-white/5 px-4 py-3 text-sm text-white/80 transition hover:bg-white/8",children:"History"}),s.jsx(Be,{variant:"ghost",size:"sm",icon:"delete",onClick:Te,disabled:!g||h.length===0,children:"Clear"})]})]}),De?s.jsxs("div",{ref:re,className:"absolute right-4 top-[72px] z-20 w-[min(360px,calc(100vw-2rem))] rounded-[20px] border border-white/10 bg-[#262626] p-2 shadow-2xl shadow-black/50 lg:right-6",children:[s.jsx("div",{className:"px-3 py-2",children:s.jsx("p",{className:"text-xs uppercase tracking-[0.22em] text-white/45",children:"Recent chats"})}),s.jsx("div",{className:"max-h-[48vh] space-y-2 overflow-y-auto p-1 custom-scrollbar",children:ge.length===0?s.jsx("div",{className:"rounded-[16px] border border-dashed border-white/10 bg-white/5 p-4 text-sm text-white/55",children:"No conversations yet."}):ge.map(t=>{var n;const r=t.id===g,i=[...t.messages||[]].reverse().find(o=>o.role==="user")||((n=t.messages)==null?void 0:n[0]);return s.jsx("button",{type:"button",onClick:()=>ke(t.id),className:`w-full rounded-[16px] border px-3 py-3 text-left transition ${r?"border-blue-400/40 bg-blue-500/15":"border-white/10 bg-white/5 hover:bg-white/8"}`,children:s.jsxs("div",{className:"flex items-start justify-between gap-3",children:[s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("p",{className:"truncate text-sm font-medium text-white",children:t.title}),s.jsx("p",{className:"mt-1 truncate text-xs text-white/50",children:S(i==null?void 0:i.content)||"Empty chat"})]}),s.jsx("span",{className:"text-[10px] text-white/40 shrink-0",children:Je(t.updatedAt)})]})},t.id)})})]}):null,w?s.jsx("div",{className:"mt-4 rounded-[18px] border border-rose-500/20 bg-rose-500/10 px-4 py-3 text-rose-100",children:s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx("span",{className:"material-symbols-outlined text-[20px]",children:"error"}),s.jsx("p",{className:"text-sm leading-6",children:w})]})}):null,s.jsxs("div",{className:"flex flex-1 flex-col min-h-0",children:[s.jsxs("div",{className:"flex-1 overflow-y-auto py-4 custom-scrollbar",children:[he.length===0?s.jsx("div",{className:"flex min-h-[50vh] items-center justify-center px-4 text-center",children:s.jsxs("div",{className:"max-w-xl space-y-4",children:[s.jsx("div",{className:"mx-auto flex size-16 items-center justify-center rounded-[20px] border border-white/10 bg-white/5 text-white/80",children:s.jsx("span",{className:"material-symbols-outlined text-[30px]",children:"chat"})}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("h2",{className:"text-2xl font-semibold text-white",children:"Start a conversation"}),s.jsx("p",{className:"text-sm leading-6 text-white/60",children:"Simple chat interface to interact with any AI model from connected providers. Select a model and start chatting!"})]})]})}):null,s.jsx("div",{className:"mx-auto flex w-full max-w-3xl flex-col gap-4 px-4",children:he.map(t=>{var x;const r=t.role==="user",i=t.role==="assistant",n=i&&t.id===Se&&t.status==="streaming",o=S(t.content)||(i?fe:"");return s.jsx("div",{className:`flex w-full ${r?"justify-end":"justify-start"} mb-6`,children:s.jsxs("div",{className:`max-w-[min(88%,42rem)] ${r?"rounded-3xl bg-[#2f2f2f] px-5 py-3.5 text-white":"text-white/90"}`,children:[s.jsx("div",{className:"mb-1 flex items-center justify-between gap-3",children:s.jsx("span",{className:"text-xs font-semibold",children:r?"You":(v==null?void 0:v.name)||"Assistant"})}),(x=t.attachments)!=null&&x.length?s.jsx("div",{className:"mb-3 grid grid-cols-2 gap-2 sm:grid-cols-3 mt-2",children:t.attachments.map(k=>s.jsx("a",{href:k.dataUrl,target:"_blank",rel:"noreferrer",className:"overflow-hidden rounded-[18px] border border-white/10 bg-black/20",children:s.jsx("img",{src:k.dataUrl,alt:k.name,className:"h-28 w-full object-cover"})},k.id))}):null,s.jsxs("div",{className:"whitespace-pre-wrap break-words text-[15px] leading-7",children:[o,i&&n&&!fe?s.jsx("span",{className:"inline-block animate-pulse",children:"▋"}):null]})]})},t.id)})})]}),s.jsxs("div",{className:"shrink-0 pt-2",children:[z.length>0?s.jsx("div",{className:"mx-auto mb-3 flex w-full max-w-3xl flex-wrap gap-2 px-4",children:z.map(t=>s.jsxs("div",{className:"flex items-center gap-2 rounded-full border border-white/10 bg-white/5 px-3 py-2",children:[s.jsx("span",{className:"text-xs text-white/80 max-w-[12rem] truncate",children:t.name}),s.jsx("button",{type:"button",onClick:()=>Re(t.id),className:"text-white/55 hover:text-white","aria-label":"Remove attachment",children:s.jsx("span",{className:"material-symbols-outlined text-[18px]",children:"close"})})]},t.id))}):null,s.jsx("div",{className:"mx-auto w-full max-w-3xl px-4 pb-2",children:s.jsxs("div",{className:"rounded-[26px] bg-[#2f2f2f] px-3 pt-3 pb-2 shadow-[0_0_15px_rgba(0,0,0,0.10)] ring-1 ring-white/5",children:[s.jsx("textarea",{value:_,onChange:t=>ce(t.target.value),onKeyDown:Pe,placeholder:"Message AI",rows:1,className:"w-full resize-none bg-transparent px-2 text-[15px] leading-6 text-white outline-none placeholder:text-white/40 custom-scrollbar max-h-[25vh] overflow-y-auto"}),s.jsxs("div",{className:"mt-2 flex items-center justify-between gap-3",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("button",{type:"button",onClick:()=>{var t;return(t=xe.current)==null?void 0:t.click()},disabled:!v||m,className:"p-2 text-white/50 hover:text-white transition rounded-full hover:bg-white/5",children:s.jsx("span",{className:"material-symbols-outlined text-[20px]",children:"attach_file"})}),s.jsx("input",{ref:xe,type:"file",accept:"image/*",multiple:!0,className:"hidden",onChange:Oe}),s.jsx("span",{className:"text-xs font-medium text-white/30 truncate max-w-[120px]",children:v?v.name:"No model"})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[me?s.jsx("button",{type:"button",onClick:Ee,className:"p-2 text-white bg-white/10 hover:bg-white/20 transition rounded-full h-8 w-8 flex items-center justify-center",children:s.jsx("span",{className:"material-symbols-outlined text-[16px]",children:"stop"})}):null,s.jsx("button",{onClick:we,disabled:!ae,className:`h-8 w-8 rounded-full flex items-center justify-center transition ${ae?"bg-white text-black hover:opacity-90":"bg-white/10 text-white/30 cursor-not-allowed"}`,children:s.jsx("span",{className:"material-symbols-outlined text-[16px]",children:"arrow_upward"})})]})]})]})})]}),s.jsx("p",{className:"mx-auto mt-2 max-w-3xl px-4 pb-4 text-center text-[11px] text-white/30",children:"Model list is filtered from connected providers."})]})]})})}function at(){return s.jsx(et,{})}export{at as default};