@fudrouter/fsrouter 0.6.71 → 0.6.73

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 (439) hide show
  1. package/dist/open-sse/config/appConstants.js +23 -79
  2. package/dist/open-sse/config/cliFingerprints.js +1 -1
  3. package/dist/open-sse/config/errorConfig.js +0 -11
  4. package/dist/open-sse/config/grokCli.js +10 -0
  5. package/dist/open-sse/config/kiroConstants.js +99 -46
  6. package/dist/open-sse/config/runtimeConfig.js +2 -0
  7. package/dist/open-sse/config/ttsModels.js +2 -0
  8. package/dist/open-sse/executors/antigravity.js +250 -164
  9. package/dist/open-sse/executors/base.js +16 -11
  10. package/dist/open-sse/executors/codex.js +269 -1108
  11. package/dist/open-sse/executors/commandCode.js +1 -1
  12. package/dist/open-sse/executors/commandcode.js +10 -4
  13. package/dist/open-sse/executors/cursor.js +96 -203
  14. package/dist/open-sse/executors/default.js +146 -244
  15. package/dist/open-sse/executors/github.js +128 -73
  16. package/dist/open-sse/executors/grok-cli.js +527 -94
  17. package/dist/open-sse/executors/grok-web.js +5 -7
  18. package/dist/open-sse/executors/index.js +12 -0
  19. package/dist/open-sse/executors/kiro.js +150 -61
  20. package/dist/open-sse/executors/opencode-go.js +12 -4
  21. package/dist/open-sse/executors/opencode.js +1 -1
  22. package/dist/open-sse/executors/perplexity-web.js +20 -96
  23. package/dist/open-sse/executors/qoder.js +28 -18
  24. package/dist/open-sse/executors/vertex.js +53 -7
  25. package/dist/open-sse/executors/xiaomi-tokenplan.js +6 -5
  26. package/dist/open-sse/handlers/chatCore/nonStreamingHandler.js +97 -85
  27. package/dist/open-sse/handlers/chatCore/requestDetail.js +32 -8
  28. package/dist/open-sse/handlers/chatCore/sseToJsonHandler.js +13 -7
  29. package/dist/open-sse/handlers/chatCore/streamingHandler.js +74 -25
  30. package/dist/open-sse/handlers/chatCore.js +35 -41
  31. package/dist/open-sse/handlers/embeddingProviders/index.js +1 -0
  32. package/dist/open-sse/handlers/embeddingProviders/openai.js +8 -16
  33. package/dist/open-sse/handlers/imageProviders/blackForestLabs.js +2 -21
  34. package/dist/open-sse/handlers/imageProviders/cloudflareAi.js +2 -30
  35. package/dist/open-sse/handlers/imageProviders/codex.js +2 -20
  36. package/dist/open-sse/handlers/imageProviders/comfyui.js +5 -18
  37. package/dist/open-sse/handlers/imageProviders/falAi.js +2 -22
  38. package/dist/open-sse/handlers/imageProviders/gemini.js +2 -16
  39. package/dist/open-sse/handlers/imageProviders/huggingface.js +2 -17
  40. package/dist/open-sse/handlers/imageProviders/index.js +3 -4
  41. package/dist/open-sse/handlers/imageProviders/leonardo.js +1 -1
  42. package/dist/open-sse/handlers/imageProviders/nanobanana.js +4 -23
  43. package/dist/open-sse/handlers/imageProviders/openai.js +15 -43
  44. package/dist/open-sse/handlers/imageProviders/runwayml.js +2 -26
  45. package/dist/open-sse/handlers/imageProviders/sdwebui.js +4 -20
  46. package/dist/open-sse/handlers/imageProviders/stabilityAi.js +2 -26
  47. package/dist/open-sse/handlers/imageProviders/weavy.js +1 -1
  48. package/dist/open-sse/handlers/search/chatSearch.js +60 -14
  49. package/dist/open-sse/handlers/ttsProviders/gemini.js +14 -3
  50. package/dist/open-sse/handlers/ttsProviders/index.js +4 -2
  51. package/dist/open-sse/handlers/ttsProviders/openai.js +4 -1
  52. package/dist/open-sse/handlers/ttsProviders/openrouter.js +7 -4
  53. package/dist/open-sse/handlers/videoCore.js +166 -0
  54. package/dist/open-sse/handlers/videoProviders/weavy.js +1 -1
  55. package/dist/open-sse/mcp-server/catalog.js +1 -1
  56. package/dist/open-sse/mcp-server/server.js +2 -2
  57. package/dist/open-sse/mcp-server/tools/advancedTools.js +2 -2
  58. package/dist/open-sse/mcp-server/tools/agentSkillTools.js +1 -1
  59. package/dist/open-sse/mcp-server/tools/compressionTools.js +4 -4
  60. package/dist/open-sse/mcp-server/tools/gamificationTools.js +10 -10
  61. package/dist/open-sse/mcp-server/tools/githubSkillTools.js +1 -1
  62. package/dist/open-sse/mcp-server/tools/memoryTools.js +3 -3
  63. package/dist/open-sse/mcp-server/tools/notionTools.js +2 -2
  64. package/dist/open-sse/mcp-server/tools/obsidianTools.js +2 -2
  65. package/dist/open-sse/mcp-server/tools/pickFastestModel.js +1 -1
  66. package/dist/open-sse/mcp-server/tools/pluginTools.js +4 -4
  67. package/dist/open-sse/mcp-server/tools/skillTools.js +2 -2
  68. package/dist/open-sse/providers/capabilities.js +24 -4
  69. package/dist/open-sse/providers/registry/alicode-intl.js +1 -1
  70. package/dist/open-sse/providers/registry/anthropic.js +1 -8
  71. package/dist/open-sse/providers/registry/codex.js +0 -9
  72. package/dist/open-sse/providers/registry/cohere.js +0 -2
  73. package/dist/open-sse/providers/registry/gemini.js +0 -2
  74. package/dist/open-sse/providers/registry/github.js +9 -6
  75. package/dist/open-sse/providers/registry/grok-cli.js +28 -18
  76. package/dist/open-sse/providers/registry/index.js +74 -80
  77. package/dist/open-sse/providers/registry/kiro.js +12 -0
  78. package/dist/open-sse/providers/registry/mistral.js +0 -3
  79. package/dist/open-sse/providers/registry/openai.js +0 -3
  80. package/dist/open-sse/providers/registry/perplexity.js +0 -2
  81. package/dist/open-sse/providers/registry/xai.js +5 -3
  82. package/dist/open-sse/rtk/autodetect.js +10 -2
  83. package/dist/open-sse/rtk/caveman.js +2 -93
  84. package/dist/open-sse/rtk/cavemanPrompts.js +34 -2
  85. package/dist/open-sse/rtk/constants.js +7 -2
  86. package/dist/open-sse/rtk/headroom.js +133 -0
  87. package/dist/open-sse/rtk/ponytail.js +1 -1
  88. package/dist/open-sse/rtk/registry.js +2 -0
  89. package/dist/open-sse/services/accountFallback.js +0 -108
  90. package/dist/open-sse/services/combo/quotaExhaustionCutoff.js +2 -2
  91. package/dist/open-sse/services/combo/quotaShareStrategy.js +1 -1
  92. package/dist/open-sse/services/combo/resolveAutoStrategy.js +1 -1
  93. package/dist/open-sse/services/combo/sessionStickiness.js +1 -1
  94. package/dist/open-sse/services/combo/targetSorters.js +2 -2
  95. package/dist/open-sse/services/combo/validateQuality.js +1 -1
  96. package/dist/open-sse/services/comboConfig.js +1 -1
  97. package/dist/open-sse/services/emergencyFallback.js +1 -1
  98. package/dist/open-sse/services/grokCliModels.js +127 -0
  99. package/dist/open-sse/services/model.js +7 -1
  100. package/dist/open-sse/services/provider.js +1 -1
  101. package/dist/open-sse/services/proxyAutoSelector.js +1 -1
  102. package/dist/open-sse/services/tokenRefresh/providers.js +3 -3
  103. package/dist/open-sse/services/usage/codex.js +148 -214
  104. package/dist/open-sse/services/usage/grok-cli.js +61 -7
  105. package/dist/open-sse/services/usage/misc.js +0 -19
  106. package/dist/open-sse/services/usage.js +0 -2
  107. package/dist/open-sse/translator/concerns/paramSupport.js +2 -2
  108. package/dist/open-sse/translator/concerns/thinkingUnified.js +6 -0
  109. package/dist/open-sse/translator/index.js +97 -59
  110. package/dist/open-sse/translator/request/claude-to-kiro.js +67 -40
  111. package/dist/open-sse/translator/request/openai-responses.js +1 -0
  112. package/dist/open-sse/translator/request/openai-to-commandcode.js +0 -4
  113. package/dist/open-sse/translator/request/openai-to-kiro.js +49 -20
  114. package/dist/open-sse/translator/response/commandcode-to-openai.js +0 -4
  115. package/dist/open-sse/utils/bypassHandler.js +18 -3
  116. package/dist/open-sse/utils/claudeCloaking.js +15 -5
  117. package/dist/open-sse/utils/cursorImages.js +1 -1
  118. package/dist/open-sse/utils/error.js +0 -17
  119. package/dist/open-sse/utils/keepaliveThreshold.js +4 -4
  120. package/dist/open-sse/utils/kiroSessionReplay.js +125 -0
  121. package/dist/open-sse/utils/noThinkingAlias.js +1 -1
  122. package/dist/open-sse/utils/proxyFetch.js +0 -1
  123. package/dist/open-sse/utils/reasoningContentInjector.js +4 -7
  124. package/dist/open-sse/utils/responsesStatePolicy.js +1 -1
  125. package/dist/open-sse/utils/responsesStreamHelpers.js +1 -0
  126. package/dist/open-sse/utils/sessionManager.js +49 -22
  127. package/dist/open-sse/utils/stream.js +54 -77
  128. package/dist/open-sse/utils/streamHandler.js +19 -15
  129. package/dist/open-sse/utils/streamHelpers.js +2 -17
  130. package/dist/open-sse/utils/usageTracking.js +103 -12
  131. package/open-sse/config/appConstants.js +23 -79
  132. package/open-sse/config/errorConfig.js +0 -11
  133. package/open-sse/config/grokCli.js +10 -0
  134. package/open-sse/config/kiroConstants.js +99 -46
  135. package/open-sse/config/runtimeConfig.js +2 -0
  136. package/open-sse/config/ttsModels.js +2 -0
  137. package/open-sse/executors/antigravity.js +250 -164
  138. package/open-sse/executors/base.js +16 -11
  139. package/open-sse/executors/codex.js +269 -1108
  140. package/open-sse/executors/commandcode.js +10 -4
  141. package/open-sse/executors/cursor.js +96 -203
  142. package/open-sse/executors/default.js +146 -244
  143. package/open-sse/executors/github.js +128 -73
  144. package/open-sse/executors/grok-cli.js +527 -94
  145. package/open-sse/executors/grok-web.js +5 -7
  146. package/open-sse/executors/index.js +12 -0
  147. package/open-sse/executors/kiro.js +150 -61
  148. package/open-sse/executors/opencode-go.js +12 -4
  149. package/open-sse/executors/opencode.js +1 -1
  150. package/open-sse/executors/perplexity-web.js +20 -96
  151. package/open-sse/executors/qoder.js +28 -18
  152. package/open-sse/executors/vertex.js +53 -7
  153. package/open-sse/executors/xiaomi-tokenplan.js +6 -5
  154. package/open-sse/handlers/chatCore/nonStreamingHandler.js +97 -85
  155. package/open-sse/handlers/chatCore/requestDetail.js +32 -8
  156. package/open-sse/handlers/chatCore/sseToJsonHandler.js +13 -7
  157. package/open-sse/handlers/chatCore/streamingHandler.js +74 -25
  158. package/open-sse/handlers/chatCore.js +35 -41
  159. package/open-sse/handlers/embeddingProviders/index.js +1 -0
  160. package/open-sse/handlers/embeddingProviders/openai.js +8 -16
  161. package/open-sse/handlers/imageProviders/blackForestLabs.js +2 -21
  162. package/open-sse/handlers/imageProviders/cloudflareAi.js +2 -30
  163. package/open-sse/handlers/imageProviders/codex.js +2 -20
  164. package/open-sse/handlers/imageProviders/comfyui.js +5 -18
  165. package/open-sse/handlers/imageProviders/falAi.js +2 -22
  166. package/open-sse/handlers/imageProviders/gemini.js +2 -16
  167. package/open-sse/handlers/imageProviders/huggingface.js +2 -17
  168. package/open-sse/handlers/imageProviders/index.js +3 -4
  169. package/open-sse/handlers/imageProviders/leonardo.js +1 -1
  170. package/open-sse/handlers/imageProviders/nanobanana.js +4 -23
  171. package/open-sse/handlers/imageProviders/openai.js +15 -43
  172. package/open-sse/handlers/imageProviders/runwayml.js +2 -26
  173. package/open-sse/handlers/imageProviders/sdwebui.js +4 -20
  174. package/open-sse/handlers/imageProviders/stabilityAi.js +2 -26
  175. package/open-sse/handlers/imageProviders/weavy.js +1 -1
  176. package/open-sse/handlers/search/chatSearch.js +60 -14
  177. package/open-sse/handlers/ttsProviders/gemini.js +14 -3
  178. package/open-sse/handlers/ttsProviders/index.js +4 -2
  179. package/open-sse/handlers/ttsProviders/openai.js +4 -1
  180. package/open-sse/handlers/ttsProviders/openrouter.js +7 -4
  181. package/open-sse/handlers/videoCore.js +166 -0
  182. package/open-sse/handlers/videoProviders/weavy.js +1 -1
  183. package/open-sse/mcp-server/audit.js +1 -1
  184. package/open-sse/mcp-server/catalog.js +2 -2
  185. package/open-sse/mcp-server/descriptionCompressor.js +1 -1
  186. package/open-sse/mcp-server/mcpCallerIdentity.js +1 -1
  187. package/open-sse/mcp-server/schemas/tools.js +1 -1
  188. package/open-sse/mcp-server/server.js +4 -4
  189. package/open-sse/mcp-server/tools/advancedTools.js +5 -5
  190. package/open-sse/mcp-server/tools/agentSkillTools.js +1 -1
  191. package/open-sse/mcp-server/tools/compressionTools.js +4 -4
  192. package/open-sse/mcp-server/tools/gamificationTools.js +10 -10
  193. package/open-sse/mcp-server/tools/githubSkillTools.js +1 -1
  194. package/open-sse/mcp-server/tools/memoryTools.js +3 -3
  195. package/open-sse/mcp-server/tools/notionTools.js +2 -2
  196. package/open-sse/mcp-server/tools/obsidianTools.js +2 -2
  197. package/open-sse/mcp-server/tools/pickFastestModel.js +3 -3
  198. package/open-sse/mcp-server/tools/pluginTools.js +4 -4
  199. package/open-sse/mcp-server/tools/skillTools.js +2 -2
  200. package/open-sse/providers/capabilities.js +24 -4
  201. package/open-sse/providers/registry/alicode-intl.js +1 -1
  202. package/open-sse/providers/registry/anthropic.js +1 -8
  203. package/open-sse/providers/registry/codex.js +0 -9
  204. package/open-sse/providers/registry/cohere.js +0 -2
  205. package/open-sse/providers/registry/gemini.js +0 -2
  206. package/open-sse/providers/registry/github.js +9 -6
  207. package/open-sse/providers/registry/grok-cli.js +28 -18
  208. package/open-sse/providers/registry/index.js +74 -80
  209. package/open-sse/providers/registry/kiro.js +12 -0
  210. package/open-sse/providers/registry/mistral.js +0 -3
  211. package/open-sse/providers/registry/openai.js +0 -3
  212. package/open-sse/providers/registry/perplexity.js +0 -2
  213. package/open-sse/providers/registry/xai.js +5 -3
  214. package/open-sse/rtk/autodetect.js +10 -2
  215. package/open-sse/rtk/caveman.js +2 -93
  216. package/open-sse/rtk/cavemanPrompts.js +34 -2
  217. package/open-sse/rtk/constants.js +7 -2
  218. package/open-sse/rtk/headroom.js +133 -0
  219. package/open-sse/rtk/ponytail.js +1 -1
  220. package/open-sse/rtk/registry.js +2 -0
  221. package/open-sse/services/accountFallback.js +0 -108
  222. package/open-sse/services/combo/quotaExhaustionCutoff.js +2 -2
  223. package/open-sse/services/combo/quotaShareStrategy.js +1 -1
  224. package/open-sse/services/combo/resolveAutoStrategy.js +1 -1
  225. package/open-sse/services/combo/sessionStickiness.js +1 -1
  226. package/open-sse/services/combo/shadowRouting.js +1 -1
  227. package/open-sse/services/combo/targetSorters.js +4 -4
  228. package/open-sse/services/combo/validateQuality.js +1 -1
  229. package/open-sse/services/evalRouting.js +1 -1
  230. package/open-sse/services/grokCliModels.js +127 -0
  231. package/open-sse/services/model.js +7 -1
  232. package/open-sse/services/modelCapabilities.js +1 -1
  233. package/open-sse/services/modelFamilyFallback.js +1 -1
  234. package/open-sse/services/provider.js +1 -1
  235. package/open-sse/services/providerCooldownTracker.js +1 -1
  236. package/open-sse/services/rateLimitManager.js +1 -1
  237. package/open-sse/services/tokenRefresh/providers.js +3 -3
  238. package/open-sse/services/usage/codex.js +148 -214
  239. package/open-sse/services/usage/grok-cli.js +61 -7
  240. package/open-sse/services/usage/misc.js +0 -19
  241. package/open-sse/services/usage.js +0 -2
  242. package/open-sse/translator/concerns/paramSupport.js +2 -2
  243. package/open-sse/translator/concerns/thinkingUnified.js +6 -0
  244. package/open-sse/translator/index.js +97 -59
  245. package/open-sse/translator/request/claude-to-kiro.js +67 -40
  246. package/open-sse/translator/request/openai-responses.js +1 -0
  247. package/open-sse/translator/request/openai-to-commandcode.js +0 -4
  248. package/open-sse/translator/request/openai-to-kiro.js +49 -20
  249. package/open-sse/translator/response/commandcode-to-openai.js +0 -4
  250. package/open-sse/utils/bypassHandler.js +18 -3
  251. package/open-sse/utils/claudeCloaking.js +15 -5
  252. package/open-sse/utils/error.js +0 -17
  253. package/open-sse/utils/kiroSessionReplay.js +125 -0
  254. package/open-sse/utils/logger.js +1 -1
  255. package/open-sse/utils/proxyFetch.js +0 -1
  256. package/open-sse/utils/reasoningContentInjector.js +4 -7
  257. package/open-sse/utils/responsesStreamHelpers.js +1 -0
  258. package/open-sse/utils/sessionManager.js +49 -22
  259. package/open-sse/utils/stream.js +54 -77
  260. package/open-sse/utils/streamHandler.js +19 -15
  261. package/open-sse/utils/streamHelpers.js +2 -17
  262. package/open-sse/utils/usageTracking.js +103 -12
  263. package/package.json +4 -7
  264. package/public/assets/{EndpointPageClient.CGB3HjDe.js → EndpointPageClient.LyNNvZ4z.js} +3 -3
  265. package/public/assets/{Loading.BhEzHe-X.js → Loading.Bj-WGl4k.js} +1 -1
  266. package/public/assets/{NoAuthProxyCard.Buvt0BVH.js → NoAuthProxyCard.qAv57b-0.js} +1 -1
  267. package/public/assets/{index.B-zMpSp_.js → index.CShjRV_B.js} +41 -41
  268. package/public/assets/{page.BINfJPNt.js → page.1qjqvrwX.js} +1 -1
  269. package/public/assets/{page.CfDkX9XZ.js → page.BSLJ4tx5.js} +1 -1
  270. package/public/assets/{page.D6TULIkh.js → page.BbO1pspY.js} +1 -1
  271. package/public/assets/page.BdmJ3yY3.js +5 -0
  272. package/public/assets/{page.Amtgxj_r.js → page.BnmTC5jG.js} +1 -1
  273. package/public/assets/{page.3QwV1pLl.js → page.C72FTTJr.js} +1 -1
  274. package/public/assets/{page.CdbMx9XI.js → page.CPZav1_c.js} +1 -1
  275. package/public/assets/{page.BONoTspJ.js → page.CQlVGoXg.js} +1 -1
  276. package/public/assets/{page.DgnlzpNx.js → page.CSs3-gdt.js} +1 -1
  277. package/public/assets/{page.BV28PqHr.js → page.CXd_R9yU.js} +1 -1
  278. package/public/assets/{page.5Aj6RvuD.js → page.CbkENBd5.js} +1 -1
  279. package/public/assets/{page.BAjUiqtJ.js → page.ChX1NqmC.js} +1 -1
  280. package/public/assets/page.Cj5h09Zo.js +1 -0
  281. package/public/assets/{page.CB__T51y.js → page.CnTop8Zt.js} +1 -1
  282. package/public/assets/{page.BMf0BFTW.js → page.CssmrzTT.js} +1 -1
  283. package/public/assets/{page.CVu_9TAu.js → page.CsxWmPoI.js} +1 -1
  284. package/public/assets/{page.ClXnUNhb.js → page.CzlQTyAL.js} +1 -1
  285. package/public/assets/{page.DAgwiopx.js → page.D1oKew1j.js} +1 -1
  286. package/public/assets/{page.BIG_uMBA.js → page.D5gj98Oe.js} +1 -1
  287. package/public/assets/{page.BW6Rv-_k.js → page.DBhu4Arl.js} +1 -1
  288. package/public/assets/page.DD_czjjP.js +1 -0
  289. package/public/assets/{page.BmOXfa4k.js → page.DPyOkPVo.js} +1 -1
  290. package/public/assets/{page.CTdMdgI4.js → page.DUI8kqOY.js} +1 -1
  291. package/public/assets/{page.BdPGDnx0.js → page.DVIHRbxB.js} +1 -1
  292. package/public/assets/{page.B9r7QI90.js → page.DX4Nno6M.js} +1 -1
  293. package/public/assets/{page.BCPmNscX.js → page.Dh5f0XJC.js} +1 -1
  294. package/public/assets/{page.u7XFxplU.js → page.DibhF7f-.js} +1 -1
  295. package/public/assets/{page.CDVZIbSe.js → page.DxMDTbSx.js} +1 -1
  296. package/public/assets/{page.Bb3E5EzI.js → page.Dx_GRRdT.js} +1 -1
  297. package/public/assets/{page.DhcizW_i.js → page.DzZLqI5Q.js} +1 -1
  298. package/public/assets/{page.CF5pD5lz.js → page.Ir7KvKcF.js} +1 -1
  299. package/public/assets/{page.Bj0au_ka.js → page.O2ddJYoT.js} +3 -3
  300. package/public/assets/{page.DIrcssm-.js → page.Qkkv8roc.js} +1 -1
  301. package/public/assets/{page.CrzjUbZg.js → page.i4KDuWcM.js} +1 -1
  302. package/public/assets/{page.1gncE-Vr.js → page.sOFOrxqq.js} +1 -1
  303. package/public/assets/{page.DskvkVIF.js → page.vla5Mzki.js} +1 -1
  304. package/public/index.html +1 -1
  305. package/public/assets/EndpointPageClient.Cee8kfmV.js +0 -6
  306. package/public/assets/EndpointPageClient.DdAfxJoK.js +0 -6
  307. package/public/assets/EndpointPageClient.GpJ_FKds.js +0 -6
  308. package/public/assets/Loading.DFkQ-Ly9.js +0 -1
  309. package/public/assets/Loading.DaQG3sHF.js +0 -1
  310. package/public/assets/Loading.QMOYJhLu.js +0 -1
  311. package/public/assets/NoAuthProxyCard.C18iZ3Fk.js +0 -89
  312. package/public/assets/NoAuthProxyCard.DyEjms20.js +0 -89
  313. package/public/assets/NoAuthProxyCard.VRP7gDcs.js +0 -89
  314. package/public/assets/index.CoYbjSIL.js +0 -89
  315. package/public/assets/index.DQDDDpp7.js +0 -89
  316. package/public/assets/index.KMEObSAk.js +0 -89
  317. package/public/assets/page.A7FRfarX.js +0 -1
  318. package/public/assets/page.B1a01Vfg.js +0 -1
  319. package/public/assets/page.B7h6EPVo.js +0 -1
  320. package/public/assets/page.BBMJAyy7.js +0 -1
  321. package/public/assets/page.BBSUQskO.js +0 -64
  322. package/public/assets/page.BFENid_V.js +0 -31
  323. package/public/assets/page.BJzBUr1v.js +0 -2
  324. package/public/assets/page.BKM5Up2Y.js +0 -1
  325. package/public/assets/page.BLUEyope.js +0 -1
  326. package/public/assets/page.BMeBT03D.js +0 -5
  327. package/public/assets/page.BQwH91-m.js +0 -1
  328. package/public/assets/page.BRgXbpJe.js +0 -1
  329. package/public/assets/page.BXq7Sixg.js +0 -1
  330. package/public/assets/page.Bbf1xxJj.js +0 -1
  331. package/public/assets/page.BcuklMLO.js +0 -2
  332. package/public/assets/page.Bi5OEfgq.js +0 -1
  333. package/public/assets/page.Bi9gIWN0.js +0 -1
  334. package/public/assets/page.BiLGOe6j.js +0 -1
  335. package/public/assets/page.BicDCwTa.js +0 -1
  336. package/public/assets/page.Bjd38gaf.js +0 -1
  337. package/public/assets/page.Bqk4tX-5.js +0 -1
  338. package/public/assets/page.BrrSjbBJ.js +0 -1
  339. package/public/assets/page.BsUeE2Y_.js +0 -1
  340. package/public/assets/page.BthVvW1e.js +0 -64
  341. package/public/assets/page.BxAWh20c.js +0 -1
  342. package/public/assets/page.C-2GmPmS.js +0 -4
  343. package/public/assets/page.C27wrrub.js +0 -1
  344. package/public/assets/page.C3FwsCq_.js +0 -23
  345. package/public/assets/page.C4RMU4Xv.js +0 -23
  346. package/public/assets/page.C7SC9vwX.js +0 -1
  347. package/public/assets/page.C8gTAwsH.js +0 -5
  348. package/public/assets/page.CECQKY1y.js +0 -5
  349. package/public/assets/page.CEN8xgCA.js +0 -1
  350. package/public/assets/page.CHG9mx5l.js +0 -1
  351. package/public/assets/page.CMUOu9fe.js +0 -1
  352. package/public/assets/page.CRex977Y.js +0 -5
  353. package/public/assets/page.CUsb0F5t.js +0 -1
  354. package/public/assets/page.CXE5AWV3.js +0 -1
  355. package/public/assets/page.CXIP8Wzi.js +0 -4
  356. package/public/assets/page.CXOuLQhq.js +0 -1
  357. package/public/assets/page.CXPMjDX9.js +0 -1
  358. package/public/assets/page.CXPPlybJ.js +0 -6
  359. package/public/assets/page.CYfjd9SF.js +0 -1
  360. package/public/assets/page.CZtbttgE.js +0 -1
  361. package/public/assets/page.CbOSwuwi.js +0 -1
  362. package/public/assets/page.CbWWyTC4.js +0 -1
  363. package/public/assets/page.CfXJWUgA.js +0 -1
  364. package/public/assets/page.CfdTLncK.js +0 -1
  365. package/public/assets/page.ChqEg6y-.js +0 -1
  366. package/public/assets/page.CmbatQd6.js +0 -4
  367. package/public/assets/page.Cp7XaHGI.js +0 -1
  368. package/public/assets/page.CqR-Z0pY.js +0 -1
  369. package/public/assets/page.CsLBZFbk.js +0 -1
  370. package/public/assets/page.CyqTG9Kn.js +0 -2
  371. package/public/assets/page.CzKSjT-r.js +0 -1
  372. package/public/assets/page.D1S50DvR.js +0 -1
  373. package/public/assets/page.D3b1o69R.js +0 -5
  374. package/public/assets/page.D5B_p_2E.js +0 -31
  375. package/public/assets/page.D8X-8LSd.js +0 -2
  376. package/public/assets/page.DA2dX7iN.js +0 -1
  377. package/public/assets/page.DBNjxgJS.js +0 -6
  378. package/public/assets/page.DEBBy5qz.js +0 -1
  379. package/public/assets/page.DEOXc6iv.js +0 -6
  380. package/public/assets/page.DG46DZcu.js +0 -1
  381. package/public/assets/page.DGAKp9YS.js +0 -1
  382. package/public/assets/page.DGico7sP.js +0 -1
  383. package/public/assets/page.DHBHS2oS.js +0 -1
  384. package/public/assets/page.DKdtfq8E.js +0 -2
  385. package/public/assets/page.DKj8qFYb.js +0 -1
  386. package/public/assets/page.DNofNt4p.js +0 -1
  387. package/public/assets/page.DVdv-E5d.js +0 -1
  388. package/public/assets/page.Da-kutqN.js +0 -1
  389. package/public/assets/page.DaW7T6nt.js +0 -1
  390. package/public/assets/page.DhPzWwGm.js +0 -1
  391. package/public/assets/page.Dju6Kwa5.js +0 -1
  392. package/public/assets/page.Dlh3Q_rt.js +0 -1
  393. package/public/assets/page.DmNhmYKk.js +0 -64
  394. package/public/assets/page.Dmvhu2ua.js +0 -1
  395. package/public/assets/page.Dp30ZzXE.js +0 -1
  396. package/public/assets/page.DsY8qNEU.js +0 -1
  397. package/public/assets/page.DtGEStU7.js +0 -1
  398. package/public/assets/page.DuXsnK8A.js +0 -1
  399. package/public/assets/page.DwU6Ubqf.js +0 -1
  400. package/public/assets/page.FmrKiZlG.js +0 -2
  401. package/public/assets/page.GSAm83Cv.js +0 -6
  402. package/public/assets/page.IgH-AWcu.js +0 -1
  403. package/public/assets/page.Ii8wGSnt.js +0 -1
  404. package/public/assets/page.KtURQA9Q.js +0 -1
  405. package/public/assets/page.NFGJtdfx.js +0 -1
  406. package/public/assets/page.QPaIzKAa.js +0 -1
  407. package/public/assets/page.QuBXfL80.js +0 -1
  408. package/public/assets/page.S02TdGZT.js +0 -1
  409. package/public/assets/page.V3CmUOJF.js +0 -1
  410. package/public/assets/page.VClP2n2B.js +0 -1
  411. package/public/assets/page.Vo9Oe8DJ.js +0 -1
  412. package/public/assets/page.WIMFvXoG.js +0 -1
  413. package/public/assets/page.XUya1XZj.js +0 -23
  414. package/public/assets/page.XqKIvnmq.js +0 -31
  415. package/public/assets/page.aAUPKg0H.js +0 -1
  416. package/public/assets/page.aRQdaBbf.js +0 -1
  417. package/public/assets/page.e-Zxfi03.js +0 -1
  418. package/public/assets/page.e-cA5aB5.js +0 -6
  419. package/public/assets/page.eNXd9f58.js +0 -6
  420. package/public/assets/page.gj2B5h2d.js +0 -1
  421. package/public/assets/page.gvZgqycR.js +0 -1
  422. package/public/assets/page.jvowBQYJ.js +0 -1
  423. package/public/assets/page.k_WzlZwU.js +0 -5
  424. package/public/assets/page.qK1RUb_S.js +0 -1
  425. package/public/assets/page.ryYPRTww.js +0 -1
  426. package/public/assets/page.xm98_0dX.js +0 -5
  427. package/public/assets/page.yjCJ-4Uh.js +0 -1
  428. package/public/providers/agentrouter.webp +0 -0
  429. package/public/providers/codebuddy-cn.webp +0 -0
  430. package/public/providers/gigachat.webp +0 -0
  431. package/public/providers/heroku.webp +0 -0
  432. package/public/providers/kimchi.webp +0 -0
  433. package/public/providers/llamagate.webp +0 -0
  434. package/public/providers/mimo-free.webp +0 -0
  435. package/public/providers/nanogpt.webp +0 -0
  436. package/public/providers/nscale.webp +0 -0
  437. package/public/providers/ovhcloud.webp +0 -0
  438. package/public/providers/predibase.webp +0 -0
  439. package/public/providers/zcode.webp +0 -0
@@ -1,5 +0,0 @@
1
- import{u as kn,j as h,B as Je,C as In,M as An}from"./index.KMEObSAk.js";import{b as a,W as U,c as Te}from"./router.Cjj1--8t.js";import{C as Jt,I as Tn,M as On}from"./NoAuthProxyCard.DyEjms20.js";import{C as Lt}from"./Loading.DFkQ-Ly9.js";import"./zustand.akaTi5uX.js";function Ln(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return a.useMemo(()=>r=>{t.forEach(o=>o(r))},t)}const nt=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Se(e){const t=Object.prototype.toString.call(e);return t==="[object Window]"||t==="[object global]"}function bt(e){return"nodeType"in e}function X(e){var t,n;return e?Se(e)?e:bt(e)&&(t=(n=e.ownerDocument)==null?void 0:n.defaultView)!=null?t:window:window}function xt(e){const{Document:t}=X(e);return e instanceof t}function Ue(e){return Se(e)?!1:e instanceof X(e).HTMLElement}function Qt(e){return e instanceof X(e).SVGElement}function Re(e){return e?Se(e)?e.document:bt(e)?xt(e)?e:Ue(e)||Qt(e)?e.ownerDocument:document:document:document}const re=nt?a.useLayoutEffect:a.useEffect;function wt(e){const t=a.useRef(e);return re(()=>{t.current=e}),a.useCallback(function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return t.current==null?void 0:t.current(...r)},[])}function zn(){const e=a.useRef(null),t=a.useCallback((r,o)=>{e.current=setInterval(r,o)},[]),n=a.useCallback(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[]);return[t,n]}function Pe(e,t){t===void 0&&(t=[e]);const n=a.useRef(e);return re(()=>{n.current!==e&&(n.current=e)},t),n}function Xe(e,t){const n=a.useRef();return a.useMemo(()=>{const r=e(n.current);return n.current=r,r},[...t])}function Qe(e){const t=wt(e),n=a.useRef(null),r=a.useCallback(o=>{o!==n.current&&(t==null||t(o,n.current)),n.current=o},[]);return[n,r]}function ht(e){const t=a.useRef();return a.useEffect(()=>{t.current=e},[e]),t.current}let ct={};function We(e,t){return a.useMemo(()=>{if(t)return t;const n=ct[e]==null?0:ct[e]+1;return ct[e]=n,e+"-"+n},[e,t])}function Zt(e){return function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];return r.reduce((s,i)=>{const l=Object.entries(i);for(const[c,u]of l){const f=s[c];f!=null&&(s[c]=f+e*u)}return s},{...t})}}const De=Zt(1),Be=Zt(-1);function Pn(e){return"clientX"in e&&"clientY"in e}function yt(e){if(!e)return!1;const{KeyboardEvent:t}=X(e.target);return t&&e instanceof t}function Bn(e){if(!e)return!1;const{TouchEvent:t}=X(e.target);return t&&e instanceof t}function gt(e){if(Bn(e)){if(e.touches&&e.touches.length){const{clientX:t,clientY:n}=e.touches[0];return{x:t,y:n}}else if(e.changedTouches&&e.changedTouches.length){const{clientX:t,clientY:n}=e.changedTouches[0];return{x:t,y:n}}}return Pn(e)?{x:e.clientX,y:e.clientY}:null}const Fe=Object.freeze({Translate:{toString(e){if(!e)return;const{x:t,y:n}=e;return"translate3d("+(t?Math.round(t):0)+"px, "+(n?Math.round(n):0)+"px, 0)"}},Scale:{toString(e){if(!e)return;const{scaleX:t,scaleY:n}=e;return"scaleX("+t+") scaleY("+n+")"}},Transform:{toString(e){if(e)return[Fe.Translate.toString(e),Fe.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:t,duration:n,easing:r}=e;return t+" "+n+"ms "+r}}}),zt="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function Fn(e){return e.matches(zt)?e:e.querySelector(zt)}const $n={display:"none"};function Un(e){let{id:t,value:n}=e;return U.createElement("div",{id:t,style:$n},n)}function Xn(e){let{id:t,announcement:n,ariaLiveType:r="assertive"}=e;const o={position:"fixed",top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"};return U.createElement("div",{id:t,style:o,role:"status","aria-live":r,"aria-atomic":!0},n)}function Wn(){const[e,t]=a.useState("");return{announce:a.useCallback(r=>{r!=null&&t(r)},[]),announcement:e}}const en=a.createContext(null);function Yn(e){const t=a.useContext(en);a.useEffect(()=>{if(!t)throw new Error("useDndMonitor must be used within a children of <DndContext>");return t(e)},[e,t])}function Hn(){const[e]=a.useState(()=>new Set),t=a.useCallback(r=>(e.add(r),()=>e.delete(r)),[e]);return[a.useCallback(r=>{let{type:o,event:s}=r;e.forEach(i=>{var l;return(l=i[o])==null?void 0:l.call(i,s)})},[e]),t]}const Kn={draggable:`
2
- To pick up a draggable item, press the space bar.
3
- While dragging, use the arrow keys to move the item.
4
- Press space again to drop the item in its new position, or press escape to cancel.
5
- `},Vn={onDragStart(e){let{active:t}=e;return"Picked up draggable item "+t.id+"."},onDragOver(e){let{active:t,over:n}=e;return n?"Draggable item "+t.id+" was moved over droppable area "+n.id+".":"Draggable item "+t.id+" is no longer over a droppable area."},onDragEnd(e){let{active:t,over:n}=e;return n?"Draggable item "+t.id+" was dropped over droppable area "+n.id:"Draggable item "+t.id+" was dropped."},onDragCancel(e){let{active:t}=e;return"Dragging was cancelled. Draggable item "+t.id+" was dropped."}};function _n(e){let{announcements:t=Vn,container:n,hiddenTextDescribedById:r,screenReaderInstructions:o=Kn}=e;const{announce:s,announcement:i}=Wn(),l=We("DndLiveRegion"),[c,u]=a.useState(!1);if(a.useEffect(()=>{u(!0)},[]),Yn(a.useMemo(()=>({onDragStart(d){let{active:g}=d;s(t.onDragStart({active:g}))},onDragMove(d){let{active:g,over:p}=d;t.onDragMove&&s(t.onDragMove({active:g,over:p}))},onDragOver(d){let{active:g,over:p}=d;s(t.onDragOver({active:g,over:p}))},onDragEnd(d){let{active:g,over:p}=d;s(t.onDragEnd({active:g,over:p}))},onDragCancel(d){let{active:g,over:p}=d;s(t.onDragCancel({active:g,over:p}))}}),[s,t])),!c)return null;const f=U.createElement(U.Fragment,null,U.createElement(Un,{id:r,value:o.draggable}),U.createElement(Xn,{id:l,announcement:i}));return n?Te.createPortal(f,n):f}var L;(function(e){e.DragStart="dragStart",e.DragMove="dragMove",e.DragEnd="dragEnd",e.DragCancel="dragCancel",e.DragOver="dragOver",e.RegisterDroppable="registerDroppable",e.SetDroppableDisabled="setDroppableDisabled",e.UnregisterDroppable="unregisterDroppable"})(L||(L={}));function Ze(){}function Pt(e,t){return a.useMemo(()=>({sensor:e,options:t??{}}),[e,t])}function qn(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return a.useMemo(()=>[...t].filter(r=>r!=null),[...t])}const Z=Object.freeze({x:0,y:0});function tn(e,t){return Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2))}function nn(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return n-r}function Gn(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return r-n}function Bt(e){let{left:t,top:n,height:r,width:o}=e;return[{x:t,y:n},{x:t+o,y:n},{x:t,y:n+r},{x:t+o,y:n+r}]}function rn(e,t){if(!e||e.length===0)return null;const[n]=e;return n[t]}function Ft(e,t,n){return t===void 0&&(t=e.left),n===void 0&&(n=e.top),{x:t+e.width*.5,y:n+e.height*.5}}const Jn=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e;const o=Ft(t,t.left,t.top),s=[];for(const i of r){const{id:l}=i,c=n.get(l);if(c){const u=tn(Ft(c),o);s.push({id:l,data:{droppableContainer:i,value:u}})}}return s.sort(nn)},Qn=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e;const o=Bt(t),s=[];for(const i of r){const{id:l}=i,c=n.get(l);if(c){const u=Bt(c),f=o.reduce((g,p,R)=>g+tn(u[R],p),0),d=Number((f/4).toFixed(4));s.push({id:l,data:{droppableContainer:i,value:d}})}}return s.sort(nn)};function Zn(e,t){const n=Math.max(t.top,e.top),r=Math.max(t.left,e.left),o=Math.min(t.left+t.width,e.left+e.width),s=Math.min(t.top+t.height,e.top+e.height),i=o-r,l=s-n;if(r<o&&n<s){const c=t.width*t.height,u=e.width*e.height,f=i*l,d=f/(c+u-f);return Number(d.toFixed(4))}return 0}const er=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e;const o=[];for(const s of r){const{id:i}=s,l=n.get(i);if(l){const c=Zn(l,t);c>0&&o.push({id:i,data:{droppableContainer:s,value:c}})}}return o.sort(Gn)};function tr(e,t,n){return{...e,scaleX:t&&n?t.width/n.width:1,scaleY:t&&n?t.height/n.height:1}}function on(e,t){return e&&t?{x:e.left-t.left,y:e.top-t.top}:Z}function nr(e){return function(n){for(var r=arguments.length,o=new Array(r>1?r-1:0),s=1;s<r;s++)o[s-1]=arguments[s];return o.reduce((i,l)=>({...i,top:i.top+e*l.y,bottom:i.bottom+e*l.y,left:i.left+e*l.x,right:i.right+e*l.x}),{...n})}}const rr=nr(1);function or(e){if(e.startsWith("matrix3d(")){const t=e.slice(9,-1).split(/, /);return{x:+t[12],y:+t[13],scaleX:+t[0],scaleY:+t[5]}}else if(e.startsWith("matrix(")){const t=e.slice(7,-1).split(/, /);return{x:+t[4],y:+t[5],scaleX:+t[0],scaleY:+t[3]}}return null}function sr(e,t,n){const r=or(t);if(!r)return e;const{scaleX:o,scaleY:s,x:i,y:l}=r,c=e.left-i-(1-o)*parseFloat(n),u=e.top-l-(1-s)*parseFloat(n.slice(n.indexOf(" ")+1)),f=o?e.width/o:e.width,d=s?e.height/s:e.height;return{width:f,height:d,top:u,right:c+f,bottom:u+d,left:c}}const ir={ignoreTransform:!1};function Ee(e,t){t===void 0&&(t=ir);let n=e.getBoundingClientRect();if(t.ignoreTransform){const{transform:u,transformOrigin:f}=X(e).getComputedStyle(e);u&&(n=sr(n,u,f))}const{top:r,left:o,width:s,height:i,bottom:l,right:c}=n;return{top:r,left:o,width:s,height:i,bottom:l,right:c}}function $t(e){return Ee(e,{ignoreTransform:!0})}function ar(e){const t=e.innerWidth,n=e.innerHeight;return{top:0,left:0,right:t,bottom:n,width:t,height:n}}function lr(e,t){return t===void 0&&(t=X(e).getComputedStyle(e)),t.position==="fixed"}function cr(e,t){t===void 0&&(t=X(e).getComputedStyle(e));const n=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(o=>{const s=t[o];return typeof s=="string"?n.test(s):!1})}function rt(e,t){const n=[];function r(o){if(t!=null&&n.length>=t||!o)return n;if(xt(o)&&o.scrollingElement!=null&&!n.includes(o.scrollingElement))return n.push(o.scrollingElement),n;if(!Ue(o)||Qt(o)||n.includes(o))return n;const s=X(e).getComputedStyle(o);return o!==e&&cr(o,s)&&n.push(o),lr(o,s)?n:r(o.parentNode)}return e?r(e):n}function sn(e){const[t]=rt(e,1);return t??null}function ut(e){return!nt||!e?null:Se(e)?e:bt(e)?xt(e)||e===Re(e).scrollingElement?window:Ue(e)?e:null:null}function an(e){return Se(e)?e.scrollX:e.scrollLeft}function ln(e){return Se(e)?e.scrollY:e.scrollTop}function pt(e){return{x:an(e),y:ln(e)}}var z;(function(e){e[e.Forward=1]="Forward",e[e.Backward=-1]="Backward"})(z||(z={}));function cn(e){return!nt||!e?!1:e===document.scrollingElement}function un(e){const t={x:0,y:0},n=cn(e)?{height:window.innerHeight,width:window.innerWidth}:{height:e.clientHeight,width:e.clientWidth},r={x:e.scrollWidth-n.width,y:e.scrollHeight-n.height},o=e.scrollTop<=t.y,s=e.scrollLeft<=t.x,i=e.scrollTop>=r.y,l=e.scrollLeft>=r.x;return{isTop:o,isLeft:s,isBottom:i,isRight:l,maxScroll:r,minScroll:t}}const ur={x:.2,y:.2};function dr(e,t,n,r,o){let{top:s,left:i,right:l,bottom:c}=n;r===void 0&&(r=10),o===void 0&&(o=ur);const{isTop:u,isBottom:f,isLeft:d,isRight:g}=un(e),p={x:0,y:0},R={x:0,y:0},m={height:t.height*o.y,width:t.width*o.x};return!u&&s<=t.top+m.height?(p.y=z.Backward,R.y=r*Math.abs((t.top+m.height-s)/m.height)):!f&&c>=t.bottom-m.height&&(p.y=z.Forward,R.y=r*Math.abs((t.bottom-m.height-c)/m.height)),!g&&l>=t.right-m.width?(p.x=z.Forward,R.x=r*Math.abs((t.right-m.width-l)/m.width)):!d&&i<=t.left+m.width&&(p.x=z.Backward,R.x=r*Math.abs((t.left+m.width-i)/m.width)),{direction:p,speed:R}}function fr(e){if(e===document.scrollingElement){const{innerWidth:s,innerHeight:i}=window;return{top:0,left:0,right:s,bottom:i,width:s,height:i}}const{top:t,left:n,right:r,bottom:o}=e.getBoundingClientRect();return{top:t,left:n,right:r,bottom:o,width:e.clientWidth,height:e.clientHeight}}function dn(e){return e.reduce((t,n)=>De(t,pt(n)),Z)}function hr(e){return e.reduce((t,n)=>t+an(n),0)}function gr(e){return e.reduce((t,n)=>t+ln(n),0)}function pr(e,t){if(t===void 0&&(t=Ee),!e)return;const{top:n,left:r,bottom:o,right:s}=t(e);sn(e)&&(o<=0||s<=0||n>=window.innerHeight||r>=window.innerWidth)&&e.scrollIntoView({block:"center",inline:"center"})}const vr=[["x",["left","right"],hr],["y",["top","bottom"],gr]];class Ct{constructor(t,n){this.rect=void 0,this.width=void 0,this.height=void 0,this.top=void 0,this.bottom=void 0,this.right=void 0,this.left=void 0;const r=rt(n),o=dn(r);this.rect={...t},this.width=t.width,this.height=t.height;for(const[s,i,l]of vr)for(const c of i)Object.defineProperty(this,c,{get:()=>{const u=l(r),f=o[s]-u;return this.rect[c]+f},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class Oe{constructor(t){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(n=>{var r;return(r=this.target)==null?void 0:r.removeEventListener(...n)})},this.target=t}add(t,n,r){var o;(o=this.target)==null||o.addEventListener(t,n,r),this.listeners.push([t,n,r])}}function mr(e){const{EventTarget:t}=X(e);return e instanceof t?e:Re(e)}function dt(e,t){const n=Math.abs(e.x),r=Math.abs(e.y);return typeof t=="number"?Math.sqrt(n**2+r**2)>t:"x"in t&&"y"in t?n>t.x&&r>t.y:"x"in t?n>t.x:"y"in t?r>t.y:!1}var J;(function(e){e.Click="click",e.DragStart="dragstart",e.Keydown="keydown",e.ContextMenu="contextmenu",e.Resize="resize",e.SelectionChange="selectionchange",e.VisibilityChange="visibilitychange"})(J||(J={}));function Ut(e){e.preventDefault()}function br(e){e.stopPropagation()}var M;(function(e){e.Space="Space",e.Down="ArrowDown",e.Right="ArrowRight",e.Left="ArrowLeft",e.Up="ArrowUp",e.Esc="Escape",e.Enter="Enter",e.Tab="Tab"})(M||(M={}));const fn={start:[M.Space,M.Enter],cancel:[M.Esc],end:[M.Space,M.Enter,M.Tab]},xr=(e,t)=>{let{currentCoordinates:n}=t;switch(e.code){case M.Right:return{...n,x:n.x+25};case M.Left:return{...n,x:n.x-25};case M.Down:return{...n,y:n.y+25};case M.Up:return{...n,y:n.y-25}}};class Dt{constructor(t){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=t;const{event:{target:n}}=t;this.props=t,this.listeners=new Oe(Re(n)),this.windowListeners=new Oe(X(n)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(J.Resize,this.handleCancel),this.windowListeners.add(J.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(J.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:t,onStart:n}=this.props,r=t.node.current;r&&pr(r),n(Z)}handleKeyDown(t){if(yt(t)){const{active:n,context:r,options:o}=this.props,{keyboardCodes:s=fn,coordinateGetter:i=xr,scrollBehavior:l="smooth"}=o,{code:c}=t;if(s.end.includes(c)){this.handleEnd(t);return}if(s.cancel.includes(c)){this.handleCancel(t);return}const{collisionRect:u}=r.current,f=u?{x:u.left,y:u.top}:Z;this.referenceCoordinates||(this.referenceCoordinates=f);const d=i(t,{active:n,context:r.current,currentCoordinates:f});if(d){const g=Be(d,f),p={x:0,y:0},{scrollableAncestors:R}=r.current;for(const m of R){const x=t.code,{isTop:S,isRight:D,isLeft:y,isBottom:N,maxScroll:v,minScroll:w}=un(m),b=fr(m),E={x:Math.min(x===M.Right?b.right-b.width/2:b.right,Math.max(x===M.Right?b.left:b.left+b.width/2,d.x)),y:Math.min(x===M.Down?b.bottom-b.height/2:b.bottom,Math.max(x===M.Down?b.top:b.top+b.height/2,d.y))},T=x===M.Right&&!D||x===M.Left&&!y,O=x===M.Down&&!N||x===M.Up&&!S;if(T&&E.x!==d.x){const k=m.scrollLeft+g.x,W=x===M.Right&&k<=v.x||x===M.Left&&k>=w.x;if(W&&!g.y){m.scrollTo({left:k,behavior:l});return}W?p.x=m.scrollLeft-k:p.x=x===M.Right?m.scrollLeft-v.x:m.scrollLeft-w.x,p.x&&m.scrollBy({left:-p.x,behavior:l});break}else if(O&&E.y!==d.y){const k=m.scrollTop+g.y,W=x===M.Down&&k<=v.y||x===M.Up&&k>=w.y;if(W&&!g.x){m.scrollTo({top:k,behavior:l});return}W?p.y=m.scrollTop-k:p.y=x===M.Down?m.scrollTop-v.y:m.scrollTop-w.y,p.y&&m.scrollBy({top:-p.y,behavior:l});break}}this.handleMove(t,De(Be(d,this.referenceCoordinates),p))}}}handleMove(t,n){const{onMove:r}=this.props;t.preventDefault(),r(n)}handleEnd(t){const{onEnd:n}=this.props;t.preventDefault(),this.detach(),n()}handleCancel(t){const{onCancel:n}=this.props;t.preventDefault(),this.detach(),n()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}Dt.activators=[{eventName:"onKeyDown",handler:(e,t,n)=>{let{keyboardCodes:r=fn,onActivation:o}=t,{active:s}=n;const{code:i}=e.nativeEvent;if(r.start.includes(i)){const l=s.activatorNode.current;return l&&e.target!==l?!1:(e.preventDefault(),o==null||o({event:e.nativeEvent}),!0)}return!1}}];function Xt(e){return!!(e&&"distance"in e)}function Wt(e){return!!(e&&"delay"in e)}class St{constructor(t,n,r){var o;r===void 0&&(r=mr(t.event.target)),this.props=void 0,this.events=void 0,this.autoScrollEnabled=!0,this.document=void 0,this.activated=!1,this.initialCoordinates=void 0,this.timeoutId=null,this.listeners=void 0,this.documentListeners=void 0,this.windowListeners=void 0,this.props=t,this.events=n;const{event:s}=t,{target:i}=s;this.props=t,this.events=n,this.document=Re(i),this.documentListeners=new Oe(this.document),this.listeners=new Oe(r),this.windowListeners=new Oe(X(i)),this.initialCoordinates=(o=gt(s))!=null?o:Z,this.handleStart=this.handleStart.bind(this),this.handleMove=this.handleMove.bind(this),this.handleEnd=this.handleEnd.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.removeTextSelection=this.removeTextSelection.bind(this),this.attach()}attach(){const{events:t,props:{options:{activationConstraint:n,bypassActivationConstraint:r}}}=this;if(this.listeners.add(t.move.name,this.handleMove,{passive:!1}),this.listeners.add(t.end.name,this.handleEnd),t.cancel&&this.listeners.add(t.cancel.name,this.handleCancel),this.windowListeners.add(J.Resize,this.handleCancel),this.windowListeners.add(J.DragStart,Ut),this.windowListeners.add(J.VisibilityChange,this.handleCancel),this.windowListeners.add(J.ContextMenu,Ut),this.documentListeners.add(J.Keydown,this.handleKeydown),n){if(r!=null&&r({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(Wt(n)){this.timeoutId=setTimeout(this.handleStart,n.delay),this.handlePending(n);return}if(Xt(n)){this.handlePending(n);return}}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),this.timeoutId!==null&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handlePending(t,n){const{active:r,onPending:o}=this.props;o(r,t,this.initialCoordinates,n)}handleStart(){const{initialCoordinates:t}=this,{onStart:n}=this.props;t&&(this.activated=!0,this.documentListeners.add(J.Click,br,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(J.SelectionChange,this.removeTextSelection),n(t))}handleMove(t){var n;const{activated:r,initialCoordinates:o,props:s}=this,{onMove:i,options:{activationConstraint:l}}=s;if(!o)return;const c=(n=gt(t))!=null?n:Z,u=Be(o,c);if(!r&&l){if(Xt(l)){if(l.tolerance!=null&&dt(u,l.tolerance))return this.handleCancel();if(dt(u,l.distance))return this.handleStart()}if(Wt(l)&&dt(u,l.tolerance))return this.handleCancel();this.handlePending(l,u);return}t.cancelable&&t.preventDefault(),i(c)}handleEnd(){const{onAbort:t,onEnd:n}=this.props;this.detach(),this.activated||t(this.props.active),n()}handleCancel(){const{onAbort:t,onCancel:n}=this.props;this.detach(),this.activated||t(this.props.active),n()}handleKeydown(t){t.code===M.Esc&&this.handleCancel()}removeTextSelection(){var t;(t=this.document.getSelection())==null||t.removeAllRanges()}}const wr={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class Rt extends St{constructor(t){const{event:n}=t,r=Re(n.target);super(t,wr,r)}}Rt.activators=[{eventName:"onPointerDown",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return!n.isPrimary||n.button!==0?!1:(r==null||r({event:n}),!0)}}];const yr={move:{name:"mousemove"},end:{name:"mouseup"}};var vt;(function(e){e[e.RightClick=2]="RightClick"})(vt||(vt={}));class Cr extends St{constructor(t){super(t,yr,Re(t.event.target))}}Cr.activators=[{eventName:"onMouseDown",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return n.button===vt.RightClick?!1:(r==null||r({event:n}),!0)}}];const ft={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class Dr extends St{constructor(t){super(t,ft)}static setup(){return window.addEventListener(ft.move.name,t,{capture:!1,passive:!1}),function(){window.removeEventListener(ft.move.name,t)};function t(){}}}Dr.activators=[{eventName:"onTouchStart",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;const{touches:o}=n;return o.length>1?!1:(r==null||r({event:n}),!0)}}];var Le;(function(e){e[e.Pointer=0]="Pointer",e[e.DraggableRect=1]="DraggableRect"})(Le||(Le={}));var et;(function(e){e[e.TreeOrder=0]="TreeOrder",e[e.ReversedTreeOrder=1]="ReversedTreeOrder"})(et||(et={}));function Sr(e){let{acceleration:t,activator:n=Le.Pointer,canScroll:r,draggingRect:o,enabled:s,interval:i=5,order:l=et.TreeOrder,pointerCoordinates:c,scrollableAncestors:u,scrollableAncestorRects:f,delta:d,threshold:g}=e;const p=Er({delta:d,disabled:!s}),[R,m]=zn(),x=a.useRef({x:0,y:0}),S=a.useRef({x:0,y:0}),D=a.useMemo(()=>{switch(n){case Le.Pointer:return c?{top:c.y,bottom:c.y,left:c.x,right:c.x}:null;case Le.DraggableRect:return o}},[n,o,c]),y=a.useRef(null),N=a.useCallback(()=>{const w=y.current;if(!w)return;const b=x.current.x*S.current.x,E=x.current.y*S.current.y;w.scrollBy(b,E)},[]),v=a.useMemo(()=>l===et.TreeOrder?[...u].reverse():u,[l,u]);a.useEffect(()=>{if(!s||!u.length||!D){m();return}for(const w of v){if((r==null?void 0:r(w))===!1)continue;const b=u.indexOf(w),E=f[b];if(!E)continue;const{direction:T,speed:O}=dr(w,E,D,t,g);for(const k of["x","y"])p[k][T[k]]||(O[k]=0,T[k]=0);if(O.x>0||O.y>0){m(),y.current=w,R(N,i),x.current=O,S.current=T;return}}x.current={x:0,y:0},S.current={x:0,y:0},m()},[t,N,r,m,s,i,JSON.stringify(D),JSON.stringify(p),R,u,v,f,JSON.stringify(g)])}const Rr={x:{[z.Backward]:!1,[z.Forward]:!1},y:{[z.Backward]:!1,[z.Forward]:!1}};function Er(e){let{delta:t,disabled:n}=e;const r=ht(t);return Xe(o=>{if(n||!r||!o)return Rr;const s={x:Math.sign(t.x-r.x),y:Math.sign(t.y-r.y)};return{x:{[z.Backward]:o.x[z.Backward]||s.x===-1,[z.Forward]:o.x[z.Forward]||s.x===1},y:{[z.Backward]:o.y[z.Backward]||s.y===-1,[z.Forward]:o.y[z.Forward]||s.y===1}}},[n,t,r])}function Nr(e,t){const n=t!=null?e.get(t):void 0,r=n?n.node.current:null;return Xe(o=>{var s;return t==null?null:(s=r??o)!=null?s:null},[r,t])}function Mr(e,t){return a.useMemo(()=>e.reduce((n,r)=>{const{sensor:o}=r,s=o.activators.map(i=>({eventName:i.eventName,handler:t(i.handler,r)}));return[...n,...s]},[]),[e,t])}var $e;(function(e){e[e.Always=0]="Always",e[e.BeforeDragging=1]="BeforeDragging",e[e.WhileDragging=2]="WhileDragging"})($e||($e={}));var mt;(function(e){e.Optimized="optimized"})(mt||(mt={}));const Yt=new Map;function jr(e,t){let{dragging:n,dependencies:r,config:o}=t;const[s,i]=a.useState(null),{frequency:l,measure:c,strategy:u}=o,f=a.useRef(e),d=x(),g=Pe(d),p=a.useCallback(function(S){S===void 0&&(S=[]),!g.current&&i(D=>D===null?S:D.concat(S.filter(y=>!D.includes(y))))},[g]),R=a.useRef(null),m=Xe(S=>{if(d&&!n)return Yt;if(!S||S===Yt||f.current!==e||s!=null){const D=new Map;for(let y of e){if(!y)continue;if(s&&s.length>0&&!s.includes(y.id)&&y.rect.current){D.set(y.id,y.rect.current);continue}const N=y.node.current,v=N?new Ct(c(N),N):null;y.rect.current=v,v&&D.set(y.id,v)}return D}return S},[e,s,n,d,c]);return a.useEffect(()=>{f.current=e},[e]),a.useEffect(()=>{d||p()},[n,d]),a.useEffect(()=>{s&&s.length>0&&i(null)},[JSON.stringify(s)]),a.useEffect(()=>{d||typeof l!="number"||R.current!==null||(R.current=setTimeout(()=>{p(),R.current=null},l))},[l,d,p,...r]),{droppableRects:m,measureDroppableContainers:p,measuringScheduled:s!=null};function x(){switch(u){case $e.Always:return!1;case $e.BeforeDragging:return n;default:return!n}}}function hn(e,t){return Xe(n=>e?n||(typeof t=="function"?t(e):e):null,[t,e])}function kr(e,t){return hn(e,t)}function Ir(e){let{callback:t,disabled:n}=e;const r=wt(t),o=a.useMemo(()=>{if(n||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:s}=window;return new s(r)},[r,n]);return a.useEffect(()=>()=>o==null?void 0:o.disconnect(),[o]),o}function ot(e){let{callback:t,disabled:n}=e;const r=wt(t),o=a.useMemo(()=>{if(n||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:s}=window;return new s(r)},[n]);return a.useEffect(()=>()=>o==null?void 0:o.disconnect(),[o]),o}function Ar(e){return new Ct(Ee(e),e)}function Ht(e,t,n){t===void 0&&(t=Ar);const[r,o]=a.useState(null);function s(){o(c=>{if(!e)return null;if(e.isConnected===!1){var u;return(u=c??n)!=null?u:null}const f=t(e);return JSON.stringify(c)===JSON.stringify(f)?c:f})}const i=Ir({callback(c){if(e)for(const u of c){const{type:f,target:d}=u;if(f==="childList"&&d instanceof HTMLElement&&d.contains(e)){s();break}}}}),l=ot({callback:s});return re(()=>{s(),e?(l==null||l.observe(e),i==null||i.observe(document.body,{childList:!0,subtree:!0})):(l==null||l.disconnect(),i==null||i.disconnect())},[e]),r}function Tr(e){const t=hn(e);return on(e,t)}const Kt=[];function Or(e){const t=a.useRef(e),n=Xe(r=>e?r&&r!==Kt&&e&&t.current&&e.parentNode===t.current.parentNode?r:rt(e):Kt,[e]);return a.useEffect(()=>{t.current=e},[e]),n}function Lr(e){const[t,n]=a.useState(null),r=a.useRef(e),o=a.useCallback(s=>{const i=ut(s.target);i&&n(l=>l?(l.set(i,pt(i)),new Map(l)):null)},[]);return a.useEffect(()=>{const s=r.current;if(e!==s){i(s);const l=e.map(c=>{const u=ut(c);return u?(u.addEventListener("scroll",o,{passive:!0}),[u,pt(u)]):null}).filter(c=>c!=null);n(l.length?new Map(l):null),r.current=e}return()=>{i(e),i(s)};function i(l){l.forEach(c=>{const u=ut(c);u==null||u.removeEventListener("scroll",o)})}},[o,e]),a.useMemo(()=>e.length?t?Array.from(t.values()).reduce((s,i)=>De(s,i),Z):dn(e):Z,[e,t])}function Vt(e,t){t===void 0&&(t=[]);const n=a.useRef(null);return a.useEffect(()=>{n.current=null},t),a.useEffect(()=>{const r=e!==Z;r&&!n.current&&(n.current=e),!r&&n.current&&(n.current=null)},[e]),n.current?Be(e,n.current):Z}function zr(e){a.useEffect(()=>{if(!nt)return;const t=e.map(n=>{let{sensor:r}=n;return r.setup==null?void 0:r.setup()});return()=>{for(const n of t)n==null||n()}},e.map(t=>{let{sensor:n}=t;return n}))}function Pr(e,t){return a.useMemo(()=>e.reduce((n,r)=>{let{eventName:o,handler:s}=r;return n[o]=i=>{s(i,t)},n},{}),[e,t])}function gn(e){return a.useMemo(()=>e?ar(e):null,[e])}const _t=[];function Br(e,t){t===void 0&&(t=Ee);const[n]=e,r=gn(n?X(n):null),[o,s]=a.useState(_t);function i(){s(()=>e.length?e.map(c=>cn(c)?r:new Ct(t(c),c)):_t)}const l=ot({callback:i});return re(()=>{l==null||l.disconnect(),i(),e.forEach(c=>l==null?void 0:l.observe(c))},[e]),o}function Fr(e){if(!e)return null;if(e.children.length>1)return e;const t=e.children[0];return Ue(t)?t:e}function $r(e){let{measure:t}=e;const[n,r]=a.useState(null),o=a.useCallback(u=>{for(const{target:f}of u)if(Ue(f)){r(d=>{const g=t(f);return d?{...d,width:g.width,height:g.height}:g});break}},[t]),s=ot({callback:o}),i=a.useCallback(u=>{const f=Fr(u);s==null||s.disconnect(),f&&(s==null||s.observe(f)),r(f?t(f):null)},[t,s]),[l,c]=Qe(i);return a.useMemo(()=>({nodeRef:l,rect:n,setRef:c}),[n,l,c])}const Ur=[{sensor:Rt,options:{}},{sensor:Dt,options:{}}],Xr={current:{}},Ge={draggable:{measure:$t},droppable:{measure:$t,strategy:$e.WhileDragging,frequency:mt.Optimized},dragOverlay:{measure:Ee}};class ze extends Map{get(t){var n;return t!=null&&(n=super.get(t))!=null?n:void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(t=>{let{disabled:n}=t;return!n})}getNodeFor(t){var n,r;return(n=(r=this.get(t))==null?void 0:r.node.current)!=null?n:void 0}}const Wr={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new ze,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:Ze},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:Ge,measureDroppableContainers:Ze,windowRect:null,measuringScheduled:!1},Yr={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:Ze,draggableNodes:new Map,over:null,measureDroppableContainers:Ze},st=a.createContext(Yr),pn=a.createContext(Wr);function Hr(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new ze}}}function Kr(e,t){switch(t.type){case L.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:t.initialCoordinates,active:t.active}};case L.DragMove:return e.draggable.active==null?e:{...e,draggable:{...e.draggable,translate:{x:t.coordinates.x-e.draggable.initialCoordinates.x,y:t.coordinates.y-e.draggable.initialCoordinates.y}}};case L.DragEnd:case L.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case L.RegisterDroppable:{const{element:n}=t,{id:r}=n,o=new ze(e.droppable.containers);return o.set(r,n),{...e,droppable:{...e.droppable,containers:o}}}case L.SetDroppableDisabled:{const{id:n,key:r,disabled:o}=t,s=e.droppable.containers.get(n);if(!s||r!==s.key)return e;const i=new ze(e.droppable.containers);return i.set(n,{...s,disabled:o}),{...e,droppable:{...e.droppable,containers:i}}}case L.UnregisterDroppable:{const{id:n,key:r}=t,o=e.droppable.containers.get(n);if(!o||r!==o.key)return e;const s=new ze(e.droppable.containers);return s.delete(n),{...e,droppable:{...e.droppable,containers:s}}}default:return e}}function Vr(e){let{disabled:t}=e;const{active:n,activatorEvent:r,draggableNodes:o}=a.useContext(st),s=ht(r),i=ht(n==null?void 0:n.id);return a.useEffect(()=>{if(!t&&!r&&s&&i!=null){if(!yt(s)||document.activeElement===s.target)return;const l=o.get(i);if(!l)return;const{activatorNode:c,node:u}=l;if(!c.current&&!u.current)return;requestAnimationFrame(()=>{for(const f of[c.current,u.current]){if(!f)continue;const d=Fn(f);if(d){d.focus();break}}})}},[r,t,o,i,s]),null}function _r(e,t){let{transform:n,...r}=t;return e!=null&&e.length?e.reduce((o,s)=>s({transform:o,...r}),n):n}function qr(e){return a.useMemo(()=>({draggable:{...Ge.draggable,...e==null?void 0:e.draggable},droppable:{...Ge.droppable,...e==null?void 0:e.droppable},dragOverlay:{...Ge.dragOverlay,...e==null?void 0:e.dragOverlay}}),[e==null?void 0:e.draggable,e==null?void 0:e.droppable,e==null?void 0:e.dragOverlay])}function Gr(e){let{activeNode:t,measure:n,initialRect:r,config:o=!0}=e;const s=a.useRef(!1),{x:i,y:l}=typeof o=="boolean"?{x:o,y:o}:o;re(()=>{if(!i&&!l||!t){s.current=!1;return}if(s.current||!r)return;const u=t==null?void 0:t.node.current;if(!u||u.isConnected===!1)return;const f=n(u),d=on(f,r);if(i||(d.x=0),l||(d.y=0),s.current=!0,Math.abs(d.x)>0||Math.abs(d.y)>0){const g=sn(u);g&&g.scrollBy({top:d.y,left:d.x})}},[t,i,l,r,n])}const vn=a.createContext({...Z,scaleX:1,scaleY:1});var pe;(function(e){e[e.Uninitialized=0]="Uninitialized",e[e.Initializing=1]="Initializing",e[e.Initialized=2]="Initialized"})(pe||(pe={}));const Jr=a.memo(function(t){var n,r,o,s;let{id:i,accessibility:l,autoScroll:c=!0,children:u,sensors:f=Ur,collisionDetection:d=er,measuring:g,modifiers:p,...R}=t;const m=a.useReducer(Kr,void 0,Hr),[x,S]=m,[D,y]=Hn(),[N,v]=a.useState(pe.Uninitialized),w=N===pe.Initialized,{draggable:{active:b,nodes:E,translate:T},droppable:{containers:O}}=x,k=b!=null?E.get(b):null,W=a.useRef({initial:null,translated:null}),Y=a.useMemo(()=>{var B;return b!=null?{id:b,data:(B=k==null?void 0:k.data)!=null?B:Xr,rect:W}:null},[b,k]),H=a.useRef(null),[C,j]=a.useState(null),[A,oe]=a.useState(null),F=Pe(R,Object.values(R)),Q=We("DndDescribedBy",i),Ye=a.useMemo(()=>O.getEnabled(),[O]),$=qr(g),{droppableRects:se,measureDroppableContainers:ve,measuringScheduled:Ne}=jr(Ye,{dragging:w,dependencies:[T.x,T.y],config:$.droppable}),q=Nr(E,b),He=a.useMemo(()=>A?gt(A):null,[A]),ce=jn(),ie=kr(q,$.draggable.measure);Gr({activeNode:b!=null?E.get(b):null,config:ce.layoutShiftCompensation,initialRect:ie,measure:$.draggable.measure});const I=Ht(q,$.draggable.measure,ie),Me=Ht(q?q.parentElement:null),ee=a.useRef({activatorEvent:null,active:null,activeNode:q,collisionRect:null,collisions:null,droppableRects:se,draggableNodes:E,draggingNode:null,draggingNodeRect:null,droppableContainers:O,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),me=O.getNodeFor((n=ee.current.over)==null?void 0:n.id),ae=$r({measure:$.dragOverlay.measure}),be=(r=ae.nodeRef.current)!=null?r:q,xe=w?(o=ae.rect)!=null?o:I:null,Nt=!!(ae.nodeRef.current&&ae.rect),Mt=Tr(Nt?null:I),it=gn(be?X(be):null),ue=Or(w?me??q:null),Ke=Br(ue),Ve=_r(p,{transform:{x:T.x-Mt.x,y:T.y-Mt.y,scaleX:1,scaleY:1},activatorEvent:A,active:Y,activeNodeRect:I,containerNodeRect:Me,draggingNodeRect:xe,over:ee.current.over,overlayNodeRect:ae.rect,scrollableAncestors:ue,scrollableAncestorRects:Ke,windowRect:it}),jt=He?De(He,T):null,kt=Lr(ue),Cn=Vt(kt),Dn=Vt(kt,[I]),we=De(Ve,Cn),ye=xe?rr(xe,Ve):null,je=Y&&ye?d({active:Y,collisionRect:ye,droppableRects:se,droppableContainers:Ye,pointerCoordinates:jt}):null,It=rn(je,"id"),[de,At]=a.useState(null),Sn=Nt?Ve:De(Ve,Dn),Rn=tr(Sn,(s=de==null?void 0:de.rect)!=null?s:null,I),at=a.useRef(null),Tt=a.useCallback((B,K)=>{let{sensor:V,options:fe}=K;if(H.current==null)return;const G=E.get(H.current);if(!G)return;const _=B.nativeEvent,te=new V({active:H.current,activeNode:G,event:_,options:fe,context:ee,onAbort(P){if(!E.get(P))return;const{onDragAbort:ne}=F.current,le={id:P};ne==null||ne(le),D({type:"onDragAbort",event:le})},onPending(P,he,ne,le){if(!E.get(P))return;const{onDragPending:Ie}=F.current,ge={id:P,constraint:he,initialCoordinates:ne,offset:le};Ie==null||Ie(ge),D({type:"onDragPending",event:ge})},onStart(P){const he=H.current;if(he==null)return;const ne=E.get(he);if(!ne)return;const{onDragStart:le}=F.current,ke={activatorEvent:_,active:{id:he,data:ne.data,rect:W}};Te.unstable_batchedUpdates(()=>{le==null||le(ke),v(pe.Initializing),S({type:L.DragStart,initialCoordinates:P,active:he}),D({type:"onDragStart",event:ke}),j(at.current),oe(_)})},onMove(P){S({type:L.DragMove,coordinates:P})},onEnd:Ce(L.DragEnd),onCancel:Ce(L.DragCancel)});at.current=te;function Ce(P){return async function(){const{active:ne,collisions:le,over:ke,scrollAdjustedTranslate:Ie}=ee.current;let ge=null;if(ne&&Ie){const{cancelDrop:Ae}=F.current;ge={activatorEvent:_,active:ne,collisions:le,delta:Ie,over:ke},P===L.DragEnd&&typeof Ae=="function"&&await Promise.resolve(Ae(ge))&&(P=L.DragCancel)}H.current=null,Te.unstable_batchedUpdates(()=>{S({type:P}),v(pe.Uninitialized),At(null),j(null),oe(null),at.current=null;const Ae=P===L.DragEnd?"onDragEnd":"onDragCancel";if(ge){const lt=F.current[Ae];lt==null||lt(ge),D({type:Ae,event:ge})}})}}},[E]),En=a.useCallback((B,K)=>(V,fe)=>{const G=V.nativeEvent,_=E.get(fe);if(H.current!==null||!_||G.dndKit||G.defaultPrevented)return;const te={active:_};B(V,K.options,te)===!0&&(G.dndKit={capturedBy:K.sensor},H.current=fe,Tt(V,K))},[E,Tt]),Ot=Mr(f,En);zr(f),re(()=>{I&&N===pe.Initializing&&v(pe.Initialized)},[I,N]),a.useEffect(()=>{const{onDragMove:B}=F.current,{active:K,activatorEvent:V,collisions:fe,over:G}=ee.current;if(!K||!V)return;const _={active:K,activatorEvent:V,collisions:fe,delta:{x:we.x,y:we.y},over:G};Te.unstable_batchedUpdates(()=>{B==null||B(_),D({type:"onDragMove",event:_})})},[we.x,we.y]),a.useEffect(()=>{const{active:B,activatorEvent:K,collisions:V,droppableContainers:fe,scrollAdjustedTranslate:G}=ee.current;if(!B||H.current==null||!K||!G)return;const{onDragOver:_}=F.current,te=fe.get(It),Ce=te&&te.rect.current?{id:te.id,rect:te.rect.current,data:te.data,disabled:te.disabled}:null,P={active:B,activatorEvent:K,collisions:V,delta:{x:G.x,y:G.y},over:Ce};Te.unstable_batchedUpdates(()=>{At(Ce),_==null||_(P),D({type:"onDragOver",event:P})})},[It]),re(()=>{ee.current={activatorEvent:A,active:Y,activeNode:q,collisionRect:ye,collisions:je,droppableRects:se,draggableNodes:E,draggingNode:be,draggingNodeRect:xe,droppableContainers:O,over:de,scrollableAncestors:ue,scrollAdjustedTranslate:we},W.current={initial:xe,translated:ye}},[Y,q,je,ye,E,be,xe,se,O,de,ue,we]),Sr({...ce,delta:T,draggingRect:ye,pointerCoordinates:jt,scrollableAncestors:ue,scrollableAncestorRects:Ke});const Nn=a.useMemo(()=>({active:Y,activeNode:q,activeNodeRect:I,activatorEvent:A,collisions:je,containerNodeRect:Me,dragOverlay:ae,draggableNodes:E,droppableContainers:O,droppableRects:se,over:de,measureDroppableContainers:ve,scrollableAncestors:ue,scrollableAncestorRects:Ke,measuringConfiguration:$,measuringScheduled:Ne,windowRect:it}),[Y,q,I,A,je,Me,ae,E,O,se,de,ve,ue,Ke,$,Ne,it]),Mn=a.useMemo(()=>({activatorEvent:A,activators:Ot,active:Y,activeNodeRect:I,ariaDescribedById:{draggable:Q},dispatch:S,draggableNodes:E,over:de,measureDroppableContainers:ve}),[A,Ot,Y,I,S,Q,E,de,ve]);return U.createElement(en.Provider,{value:y},U.createElement(st.Provider,{value:Mn},U.createElement(pn.Provider,{value:Nn},U.createElement(vn.Provider,{value:Rn},u)),U.createElement(Vr,{disabled:(l==null?void 0:l.restoreFocus)===!1})),U.createElement(_n,{...l,hiddenTextDescribedById:Q}));function jn(){const B=(C==null?void 0:C.autoScrollEnabled)===!1,K=typeof c=="object"?c.enabled===!1:c===!1,V=w&&!B&&!K;return typeof c=="object"?{...c,enabled:V}:{enabled:V}}}),Qr=a.createContext(null),qt="button",Zr="Draggable";function eo(e){let{id:t,data:n,disabled:r=!1,attributes:o}=e;const s=We(Zr),{activators:i,activatorEvent:l,active:c,activeNodeRect:u,ariaDescribedById:f,draggableNodes:d,over:g}=a.useContext(st),{role:p=qt,roleDescription:R="draggable",tabIndex:m=0}=o??{},x=(c==null?void 0:c.id)===t,S=a.useContext(x?vn:Qr),[D,y]=Qe(),[N,v]=Qe(),w=Pr(i,t),b=Pe(n);re(()=>(d.set(t,{id:t,key:s,node:D,activatorNode:N,data:b}),()=>{const T=d.get(t);T&&T.key===s&&d.delete(t)}),[d,t]);const E=a.useMemo(()=>({role:p,tabIndex:m,"aria-disabled":r,"aria-pressed":x&&p===qt?!0:void 0,"aria-roledescription":R,"aria-describedby":f.draggable}),[r,p,m,x,R,f.draggable]);return{active:c,activatorEvent:l,activeNodeRect:u,attributes:E,isDragging:x,listeners:r?void 0:w,node:D,over:g,setNodeRef:y,setActivatorNodeRef:v,transform:S}}function to(){return a.useContext(pn)}const no="Droppable",ro={timeout:25};function oo(e){let{data:t,disabled:n=!1,id:r,resizeObserverConfig:o}=e;const s=We(no),{active:i,dispatch:l,over:c,measureDroppableContainers:u}=a.useContext(st),f=a.useRef({disabled:n}),d=a.useRef(!1),g=a.useRef(null),p=a.useRef(null),{disabled:R,updateMeasurementsFor:m,timeout:x}={...ro,...o},S=Pe(m??r),D=a.useCallback(()=>{if(!d.current){d.current=!0;return}p.current!=null&&clearTimeout(p.current),p.current=setTimeout(()=>{u(Array.isArray(S.current)?S.current:[S.current]),p.current=null},x)},[x]),y=ot({callback:D,disabled:R||!i}),N=a.useCallback((E,T)=>{y&&(T&&(y.unobserve(T),d.current=!1),E&&y.observe(E))},[y]),[v,w]=Qe(N),b=Pe(t);return a.useEffect(()=>{!y||!v.current||(y.disconnect(),d.current=!1,y.observe(v.current))},[v,y]),a.useEffect(()=>(l({type:L.RegisterDroppable,element:{id:r,key:s,disabled:n,node:v,rect:g,data:b}}),()=>l({type:L.UnregisterDroppable,key:s,id:r})),[r]),a.useEffect(()=>{n!==f.current.disabled&&(l({type:L.SetDroppableDisabled,id:r,key:s,disabled:n}),f.current.disabled=n)},[r,s,n,l]),{active:i,rect:g,isOver:(c==null?void 0:c.id)===r,node:v,over:c,setNodeRef:w}}function Et(e,t,n){const r=e.slice();return r.splice(n<0?r.length+n:n,0,r.splice(t,1)[0]),r}function so(e,t){return e.reduce((n,r,o)=>{const s=t.get(r);return s&&(n[o]=s),n},Array(e.length))}function _e(e){return e!==null&&e>=0}function io(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function ao(e){return typeof e=="boolean"?{draggable:e,droppable:e}:e}const mn=e=>{let{rects:t,activeIndex:n,overIndex:r,index:o}=e;const s=Et(t,r,n),i=t[o],l=s[o];return!l||!i?null:{x:l.left-i.left,y:l.top-i.top,scaleX:l.width/i.width,scaleY:l.height/i.height}},qe={scaleX:1,scaleY:1},lo=e=>{var t;let{activeIndex:n,activeNodeRect:r,index:o,rects:s,overIndex:i}=e;const l=(t=s[n])!=null?t:r;if(!l)return null;if(o===n){const u=s[i];return u?{x:0,y:n<i?u.top+u.height-(l.top+l.height):u.top-l.top,...qe}:null}const c=co(s,o,n);return o>n&&o<=i?{x:0,y:-l.height-c,...qe}:o<n&&o>=i?{x:0,y:l.height+c,...qe}:{x:0,y:0,...qe}};function co(e,t,n){const r=e[t],o=e[t-1],s=e[t+1];return r?n<t?o?r.top-(o.top+o.height):s?s.top-(r.top+r.height):0:s?s.top-(r.top+r.height):o?r.top-(o.top+o.height):0:0}const bn="Sortable",xn=U.createContext({activeIndex:-1,containerId:bn,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:mn,disabled:{draggable:!1,droppable:!1}});function uo(e){let{children:t,id:n,items:r,strategy:o=mn,disabled:s=!1}=e;const{active:i,dragOverlay:l,droppableRects:c,over:u,measureDroppableContainers:f}=to(),d=We(bn,n),g=l.rect!==null,p=a.useMemo(()=>r.map(w=>typeof w=="object"&&"id"in w?w.id:w),[r]),R=i!=null,m=i?p.indexOf(i.id):-1,x=u?p.indexOf(u.id):-1,S=a.useRef(p),D=!io(p,S.current),y=x!==-1&&m===-1||D,N=ao(s);re(()=>{D&&R&&f(p)},[D,p,R,f]),a.useEffect(()=>{S.current=p},[p]);const v=a.useMemo(()=>({activeIndex:m,containerId:d,disabled:N,disableTransforms:y,items:p,overIndex:x,useDragOverlay:g,sortedRects:so(p,c),strategy:o}),[m,d,N.draggable,N.droppable,y,p,x,c,g,o]);return U.createElement(xn.Provider,{value:v},t)}const fo=e=>{let{id:t,items:n,activeIndex:r,overIndex:o}=e;return Et(n,r,o).indexOf(t)},ho=e=>{let{containerId:t,isSorting:n,wasDragging:r,index:o,items:s,newIndex:i,previousItems:l,previousContainerId:c,transition:u}=e;return!u||!r||l!==s&&o===i?!1:n?!0:i!==o&&t===c},go={duration:200,easing:"ease"},wn="transform",po=Fe.Transition.toString({property:wn,duration:0,easing:"linear"}),vo={roleDescription:"sortable"};function mo(e){let{disabled:t,index:n,node:r,rect:o}=e;const[s,i]=a.useState(null),l=a.useRef(n);return re(()=>{if(!t&&n!==l.current&&r.current){const c=o.current;if(c){const u=Ee(r.current,{ignoreTransform:!0}),f={x:c.left-u.left,y:c.top-u.top,scaleX:c.width/u.width,scaleY:c.height/u.height};(f.x||f.y)&&i(f)}}n!==l.current&&(l.current=n)},[t,n,r,o]),a.useEffect(()=>{s&&i(null)},[s]),s}function bo(e){let{animateLayoutChanges:t=ho,attributes:n,disabled:r,data:o,getNewIndex:s=fo,id:i,strategy:l,resizeObserverConfig:c,transition:u=go}=e;const{items:f,containerId:d,activeIndex:g,disabled:p,disableTransforms:R,sortedRects:m,overIndex:x,useDragOverlay:S,strategy:D}=a.useContext(xn),y=xo(r,p),N=f.indexOf(i),v=a.useMemo(()=>({sortable:{containerId:d,index:N,items:f},...o}),[d,o,N,f]),w=a.useMemo(()=>f.slice(f.indexOf(i)),[f,i]),{rect:b,node:E,isOver:T,setNodeRef:O}=oo({id:i,data:v,disabled:y.droppable,resizeObserverConfig:{updateMeasurementsFor:w,...c}}),{active:k,activatorEvent:W,activeNodeRect:Y,attributes:H,setNodeRef:C,listeners:j,isDragging:A,over:oe,setActivatorNodeRef:F,transform:Q}=eo({id:i,data:v,attributes:{...vo,...n},disabled:y.draggable}),Ye=Ln(O,C),$=!!k,se=$&&!R&&_e(g)&&_e(x),ve=!S&&A,Ne=ve&&se?Q:null,He=se?Ne??(l??D)({rects:m,activeNodeRect:Y,activeIndex:g,overIndex:x,index:N}):null,ce=_e(g)&&_e(x)?s({id:i,items:f,activeIndex:g,overIndex:x}):N,ie=k==null?void 0:k.id,I=a.useRef({activeId:ie,items:f,newIndex:ce,containerId:d}),Me=f!==I.current.items,ee=t({active:k,containerId:d,isDragging:A,isSorting:$,id:i,index:N,items:f,newIndex:I.current.newIndex,previousItems:I.current.items,previousContainerId:I.current.containerId,transition:u,wasDragging:I.current.activeId!=null}),me=mo({disabled:!ee,index:N,node:E,rect:b});return a.useEffect(()=>{$&&I.current.newIndex!==ce&&(I.current.newIndex=ce),d!==I.current.containerId&&(I.current.containerId=d),f!==I.current.items&&(I.current.items=f)},[$,ce,d,f]),a.useEffect(()=>{if(ie===I.current.activeId)return;if(ie!=null&&I.current.activeId==null){I.current.activeId=ie;return}const be=setTimeout(()=>{I.current.activeId=ie},50);return()=>clearTimeout(be)},[ie]),{active:k,activeIndex:g,attributes:H,data:v,rect:b,index:N,newIndex:ce,items:f,isOver:T,isSorting:$,isDragging:A,listeners:j,node:E,overIndex:x,over:oe,setNodeRef:Ye,setActivatorNodeRef:F,setDroppableNodeRef:O,setDraggableNodeRef:C,transform:me??He,transition:ae()};function ae(){if(me||Me&&I.current.newIndex===N)return po;if(!(ve&&!yt(W)||!u)&&($||ee))return Fe.Transition.toString({...u,property:wn})}}function xo(e,t){var n,r;return typeof e=="boolean"?{draggable:e,droppable:!1}:{draggable:(n=e==null?void 0:e.draggable)!=null?n:t.draggable,droppable:(r=e==null?void 0:e.droppable)!=null?r:t.droppable}}function tt(e){if(!e)return!1;const t=e.data.current;return!!(t&&"sortable"in t&&typeof t.sortable=="object"&&"containerId"in t.sortable&&"items"in t.sortable&&"index"in t.sortable)}const wo=[M.Down,M.Right,M.Up,M.Left],yo=(e,t)=>{let{context:{active:n,collisionRect:r,droppableRects:o,droppableContainers:s,over:i,scrollableAncestors:l}}=t;if(wo.includes(e.code)){if(e.preventDefault(),!n||!r)return;const c=[];s.getEnabled().forEach(d=>{if(!d||d!=null&&d.disabled)return;const g=o.get(d.id);if(g)switch(e.code){case M.Down:r.top<g.top&&c.push(d);break;case M.Up:r.top>g.top&&c.push(d);break;case M.Left:r.left>g.left&&c.push(d);break;case M.Right:r.left<g.left&&c.push(d);break}});const u=Qn({collisionRect:r,droppableRects:o,droppableContainers:c});let f=rn(u,"id");if(f===(i==null?void 0:i.id)&&u.length>1&&(f=u[1].id),f!=null){const d=s.get(n.id),g=s.get(f),p=g?o.get(g.id):null,R=g==null?void 0:g.node.current;if(R&&p&&d&&g){const x=rt(R).some((w,b)=>l[b]!==w),S=yn(d,g),D=Co(d,g),y=x||!S?{x:0,y:0}:{x:D?r.width-p.width:0,y:D?r.height-p.height:0},N={x:p.left,y:p.top};return y.x&&y.y?N:Be(N,y)}}}};function yn(e,t){return!tt(e)||!tt(t)?!1:e.data.current.sortable.containerId===t.data.current.sortable.containerId}function Co(e,t){return!tt(e)||!tt(t)||!yn(e,t)?!1:e.data.current.sortable.index<t.data.current.sortable.index}function Do(e,t,n){const r={...e};return t.top+e.y<=n.top?r.y=n.top-t.top:t.bottom+e.y>=n.top+n.height&&(r.y=n.top+n.height-t.bottom),t.left+e.x<=n.left?r.x=n.left-t.left:t.right+e.x>=n.left+n.width&&(r.x=n.left+n.width-t.right),r}const So=e=>{let{containerNodeRect:t,draggingNodeRect:n,transform:r}=e;return!n||!t?r:Do(r,n,t)},Ro=e=>{let{transform:t}=e;return{...t,x:0}},Eo=/^[a-zA-Z0-9_.\-]+$/;function Oo(){const[e,t]=a.useState([]),[n,r]=a.useState(!0),[o,s]=a.useState(!1),[i,l]=a.useState(null),[c,u]=a.useState([]),[f,d]=a.useState({}),[g,p]=a.useState(null),{copied:R,copy:m}=kn();a.useEffect(()=>{x()},[]);const x=async()=>{try{const[v,w,b]=await Promise.all([fetch("/api/combos"),fetch("/api/providers"),fetch("/api/settings")]),E=await v.json(),T=await w.json(),O=b.ok?await b.json():{};v.ok&&t((E.combos||[]).filter(k=>!k.kind)),w.ok&&u(T.connections||[]),d(O.comboStrategies||{})}catch(v){console.log("Error fetching data:",v)}finally{r(!1)}},S=async v=>{try{const w=await fetch("/api/combos",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(v)});if(w.ok)await x(),s(!1);else{const b=await w.json();alert(b.error||"Failed to create combo")}}catch(w){console.log("Error creating combo:",w)}},D=async(v,w)=>{try{const b=await fetch(`/api/combos/${v}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(w)});if(b.ok)await x(),l(null);else{const E=await b.json();alert(E.error||"Failed to update combo")}}catch(b){console.log("Error updating combo:",b)}},y=async v=>{p({title:"Delete Combo",message:"Delete this combo?",onConfirm:async()=>{p(null);try{(await fetch(`/api/combos/${v}`,{method:"DELETE"})).ok&&t(e.filter(b=>b.id!==v))}catch(w){console.log("Error deleting combo:",w)}}})},N=async(v,w)=>{try{const b={...f};w&&w!=="fallback"?b[v]={fallbackStrategy:w}:delete b[v],await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({comboStrategies:b})}),d(b)}catch(b){console.log("Error updating combo strategy:",b)}};return n?h.jsxs("div",{className:"flex flex-col gap-6",children:[h.jsx(Lt,{}),h.jsx(Lt,{})]}):h.jsxs("div",{className:"flex min-w-0 flex-col gap-6 px-1 sm:px-0",children:[h.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[h.jsxs("div",{className:"min-w-0",children:[h.jsx("h1",{className:"text-2xl font-semibold",children:"Combos"}),h.jsx("p",{className:"text-sm text-text-muted mt-1",children:"Create model combos with fallback support"})]}),h.jsx(Je,{icon:"add",onClick:()=>s(!0),className:"w-full sm:w-auto",children:"Create Combo"})]}),e.length===0?h.jsx(Jt,{children:h.jsxs("div",{className:"text-center py-12",children:[h.jsx("div",{className:"inline-flex items-center justify-center w-16 h-16 rounded-full bg-primary/10 text-primary mb-4",children:h.jsx("span",{className:"material-symbols-outlined text-[32px]",children:"layers"})}),h.jsx("p",{className:"text-text-main font-medium mb-1",children:"No combos yet"}),h.jsx("p",{className:"text-sm text-text-muted mb-4",children:"Create model combos with fallback support"}),h.jsx(Je,{icon:"add",onClick:()=>s(!0),className:"w-full sm:w-auto",children:"Create Combo"})]})}):h.jsx("div",{className:"flex flex-col gap-4",children:e.map(v=>{var w;return h.jsx(No,{combo:v,copied:R,onCopy:m,onEdit:()=>l(v),onDelete:()=>y(v.id),currentStrategy:((w=f[v.name])==null?void 0:w.fallbackStrategy)||"fallback",onUpdateStrategy:b=>N(v.name,b)},v.id)})}),h.jsx(Gt,{isOpen:o,onClose:()=>s(!1),onSave:S,activeProviders:c},"create"),h.jsx(Gt,{isOpen:!!i,combo:i,onClose:()=>l(null),onSave:v=>D(i.id,v),activeProviders:c},(i==null?void 0:i.id)||"new"),h.jsx(In,{isOpen:!!g,onClose:()=>p(null),onConfirm:g==null?void 0:g.onConfirm,title:(g==null?void 0:g.title)||"Confirm",message:g==null?void 0:g.message,variant:"danger"})]})}function No({combo:e,copied:t,onCopy:n,onEdit:r,onDelete:o,currentStrategy:s,onUpdateStrategy:i}){return h.jsx(Jt,{padding:"sm",className:"group",children:h.jsxs("div",{className:"flex min-w-0 flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[h.jsxs("div",{className:"flex min-w-0 flex-1 items-start gap-3 sm:items-center",children:[h.jsx("div",{className:"size-8 rounded-lg bg-primary/10 flex items-center justify-center shrink-0",children:h.jsx("span",{className:"material-symbols-outlined text-primary text-[18px]",children:"layers"})}),h.jsxs("div",{className:"min-w-0 flex-1",children:[h.jsx("code",{className:"block truncate font-mono text-sm font-medium",children:e.name}),h.jsxs("div",{className:"mt-1 flex min-w-0 flex-wrap items-center gap-1",children:[e.models.length===0?h.jsx("span",{className:"text-xs text-text-muted italic",children:"No models"}):e.models.slice(0,3).map((l,c)=>h.jsx("code",{className:"max-w-full truncate rounded bg-black/5 px-1.5 py-0.5 font-mono text-[10px] text-text-muted dark:bg-white/5 sm:max-w-[220px]",children:l},c)),e.models.length>3&&h.jsxs("span",{className:"text-[10px] text-text-muted",children:["+",e.models.length-3," more"]})]})]})]}),h.jsxs("div",{className:"flex w-full flex-col gap-2 sm:w-auto sm:flex-row sm:items-center sm:gap-3 sm:shrink-0",children:[h.jsxs("div",{className:"flex items-center justify-between gap-1.5 rounded-lg bg-black/[0.02] px-2 py-1 dark:bg-white/[0.02] sm:justify-start sm:bg-transparent sm:px-0 sm:py-0 sm:dark:bg-transparent",children:[h.jsx("span",{className:"text-xs text-text-muted font-medium mr-1",children:"Strategy:"}),h.jsxs("select",{value:s,onChange:l=>i(l.target.value),className:"text-xs font-medium rounded border border-black/10 bg-transparent py-1 px-2 outline-none dark:border-white/10 dark:bg-black/20 text-text-main cursor-pointer",children:[h.jsx("option",{value:"fallback",className:"dark:bg-zinc-900",children:"Fallback (Priority)"}),h.jsx("option",{value:"round-robin",className:"dark:bg-zinc-900",children:"Round Robin"}),h.jsx("option",{value:"fusion",className:"dark:bg-zinc-900",children:"Fusion (Synthesis)"})]})]}),h.jsxs("div",{className:"grid grid-cols-3 gap-1 sm:flex",children:[h.jsxs("button",{onClick:l=>{l.stopPropagation(),n(e.name,`combo-${e.id}`)},className:"flex flex-col items-center rounded px-2 py-1 text-text-muted transition-colors hover:bg-black/5 hover:text-primary dark:hover:bg-white/5",title:"Copy combo name",children:[h.jsx("span",{className:"material-symbols-outlined text-[18px]",children:t===`combo-${e.id}`?"check":"content_copy"}),h.jsx("span",{className:"text-[10px] leading-tight",children:"Copy"})]}),h.jsxs("button",{onClick:r,className:"flex flex-col items-center rounded px-2 py-1 text-text-muted transition-colors hover:bg-black/5 hover:text-primary dark:hover:bg-white/5",title:"Edit",children:[h.jsx("span",{className:"material-symbols-outlined text-[18px]",children:"edit"}),h.jsx("span",{className:"text-[10px] leading-tight",children:"Edit"})]}),h.jsxs("button",{onClick:o,className:"flex flex-col items-center rounded px-2 py-1 text-red-500 transition-colors hover:bg-red-500/10",title:"Delete",children:[h.jsx("span",{className:"material-symbols-outlined text-[18px]",children:"delete"}),h.jsx("span",{className:"text-[10px] leading-tight",children:"Delete"})]})]})]})]})})}function Mo({id:e,index:t,model:n,isFirst:r,isLast:o,onEdit:s,onMoveUp:i,onMoveDown:l,onRemove:c}){const{attributes:u,listeners:f,setNodeRef:d,transform:g,isDragging:p}=bo({id:e}),R={transform:Fe.Transform.toString(g),opacity:p?.4:1,zIndex:p?999:void 0},[m,x]=a.useState(!1),[S,D]=a.useState(n),y=()=>{const v=S.trim();v&&v!==n?s(v):D(n),x(!1)},N=v=>{v.key==="Enter"&&y(),v.key==="Escape"&&(D(n),x(!1))};return h.jsxs("div",{ref:d,style:R,className:`group flex min-w-0 items-center gap-1.5 rounded-md px-2 py-1 bg-black/[0.02] hover:bg-black/[0.04] dark:bg-white/[0.02] dark:hover:bg-white/[0.04] transition-colors ${p?"shadow-md ring-1 ring-primary/30":""}`,children:[h.jsx("button",{...u,...f,type:"button",className:"cursor-grab touch-none p-0.5 rounded text-text-muted hover:text-primary active:cursor-grabbing shrink-0",title:"Drag to reorder",children:h.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:[h.jsx("circle",{cx:"9",cy:"4",r:"2"}),h.jsx("circle",{cx:"15",cy:"4",r:"2"}),h.jsx("circle",{cx:"9",cy:"12",r:"2"}),h.jsx("circle",{cx:"15",cy:"12",r:"2"}),h.jsx("circle",{cx:"9",cy:"20",r:"2"}),h.jsx("circle",{cx:"15",cy:"20",r:"2"})]})}),h.jsx("span",{className:"text-[10px] font-medium text-text-muted w-3 text-center shrink-0",children:t+1}),m?h.jsx("input",{autoFocus:!0,value:S,onChange:v=>D(v.target.value),onBlur:y,onKeyDown:N,className:"min-w-0 flex-1 rounded border border-primary/40 bg-white px-1.5 py-0.5 font-mono text-xs text-text-main outline-none dark:bg-black/20"}):h.jsx("div",{className:"min-w-0 flex-1 cursor-text truncate rounded px-1.5 py-0.5 font-mono text-xs text-text-main hover:bg-black/5 dark:hover:bg-white/5",onClick:()=>x(!0),title:"Click to edit",children:n}),h.jsxs("div",{className:"flex shrink-0 items-center gap-0.5",children:[h.jsx("button",{onClick:i,disabled:r,className:`p-0.5 rounded ${r?"text-text-muted/20 cursor-not-allowed":"text-text-muted hover:text-primary hover:bg-black/5 dark:hover:bg-white/5"}`,title:"Move up",children:h.jsx("span",{className:"material-symbols-outlined text-[12px]",children:"arrow_upward"})}),h.jsx("button",{onClick:l,disabled:o,className:`p-0.5 rounded ${o?"text-text-muted/20 cursor-not-allowed":"text-text-muted hover:text-primary hover:bg-black/5 dark:hover:bg-white/5"}`,title:"Move down",children:h.jsx("span",{className:"material-symbols-outlined text-[12px]",children:"arrow_downward"})})]}),h.jsx("button",{onClick:c,className:"p-0.5 hover:bg-red-500/10 rounded text-text-muted hover:text-red-500 transition-all",title:"Remove",children:h.jsx("span",{className:"material-symbols-outlined text-[12px]",children:"close"})})]})}function Gt({isOpen:e,combo:t,onClose:n,onSave:r,activeProviders:o,kindFilter:s=null}){const[i,l]=a.useState((t==null?void 0:t.name)||""),[c,u]=a.useState((t==null?void 0:t.models)||[]),[f,d]=a.useState(!1),[g,p]=a.useState(!1),[R,m]=a.useState(""),[x,S]=a.useState({}),D=qn(Pt(Rt,{activationConstraint:{distance:5}}),Pt(Dt,{coordinateGetter:yo})),y=c.map((C,j)=>({uid:`item-${j}`,model:C})),N=C=>{const{active:j,over:A}=C;if(A&&j.id!==A.id){const oe=y.findIndex(Q=>Q.uid===j.id),F=y.findIndex(Q=>Q.uid===A.id);oe!==-1&&F!==-1&&u(Q=>Et(Q,oe,F))}},v=async()=>{try{const C=await fetch("/api/models/alias");if(!C.ok)return;const j=await C.json();S(j.aliases||{})}catch(C){console.error("Error fetching modal data:",C)}};a.useEffect(()=>{e&&v()},[e]);const w=C=>C.trim()?Eo.test(C)?(m(""),!0):(m("Only letters, numbers, -, _ and . allowed"),!1):(m("Name is required"),!1),b=C=>{const j=C.target.value;l(j),j?w(j):m("")},E=C=>{c.includes(C.value)||u([...c,C.value])},T=C=>{u(c.filter(j=>j!==C.value))},O=C=>{u(c.filter((j,A)=>A!==C))},k=C=>{if(C===0)return;const j=[...c];[j[C-1],j[C]]=[j[C],j[C-1]],u(j)},W=C=>{if(C===c.length-1)return;const j=[...c];[j[C],j[C+1]]=[j[C+1],j[C]],u(j)},Y=async()=>{w(i)&&(p(!0),await r({name:i.trim(),models:c}),p(!1))},H=!!t;return h.jsxs(h.Fragment,{children:[h.jsx(An,{isOpen:e,onClose:n,title:H?"Edit Combo":"Create Combo",children:h.jsxs("div",{className:"flex flex-col gap-3",children:[h.jsxs("div",{children:[h.jsx(Tn,{label:"Combo Name",value:i,onChange:b,placeholder:"my-combo",error:R}),h.jsx("p",{className:"text-[10px] text-text-muted mt-0.5",children:"Only letters, numbers, -, _ and . allowed"})]}),h.jsxs("div",{children:[h.jsx("label",{className:"text-sm font-medium mb-1.5 block",children:"Models"}),c.length===0?h.jsxs("div",{className:"text-center py-4 border border-dashed border-black/10 dark:border-white/10 rounded-lg bg-black/[0.01] dark:bg-white/[0.01]",children:[h.jsx("span",{className:"material-symbols-outlined text-text-muted text-xl mb-1",children:"layers"}),h.jsx("p",{className:"text-xs text-text-muted",children:"No models added yet"})]}):h.jsx(Jr,{sensors:D,collisionDetection:Jn,onDragEnd:N,modifiers:[Ro,So],children:h.jsx(uo,{items:y.map(C=>C.uid),strategy:lo,children:h.jsx("div",{className:"flex max-h-[55vh] min-w-0 flex-col gap-1 overflow-y-auto sm:max-h-[350px]",children:y.map(({uid:C,model:j},A)=>h.jsx(Mo,{id:C,index:A,model:j,isFirst:A===0,isLast:A===y.length-1,onEdit:oe=>{const F=[...c];F[A]=oe,u(F)},onMoveUp:()=>k(A),onMoveDown:()=>W(A),onRemove:()=>O(A)},C))})})}),h.jsxs("button",{onClick:()=>d(!0),className:"w-full mt-2 py-2 border border-dashed border-black/10 dark:border-white/10 rounded-lg text-xs text-primary font-medium hover:text-primary hover:border-primary/50 transition-colors flex items-center justify-center gap-1",children:[h.jsx("span",{className:"material-symbols-outlined text-[16px]",children:"add"}),"Add Model"]})]}),h.jsxs("div",{className:"flex flex-col gap-2 pt-1 sm:flex-row",children:[h.jsx(Je,{onClick:n,variant:"ghost",fullWidth:!0,size:"sm",children:"Cancel"}),h.jsx(Je,{onClick:Y,fullWidth:!0,size:"sm",disabled:!i.trim()||!!R||g,children:g?"Saving...":H?"Save":"Create"})]})]})}),h.jsx(On,{isOpen:f,onClose:()=>d(!1),onSelect:E,onDeselect:T,activeProviders:o,modelAliases:x,title:"Add Model to Combo",kindFilter:s,addedModelValues:c,closeOnSelect:!1})]})}export{Oo as default};
@@ -1 +0,0 @@
1
- import{j as s,B as Be,k as je,l as Ie,h as Le}from"./index.B-zMpSp_.js";import{b as d}from"./router.Cjj1--8t.js";import{B as qe}from"./NoAuthProxyCard.VRP7gDcs.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 +0,0 @@
1
- import{j as e,L as Qe,x as Xe,y as ye,z as je,D as Ze,n as he,B as v,E as ge,C as es}from"./index.CoYbjSIL.js";import{b as o,c as ss,d as ts}from"./router.Cjj1--8t.js";import{C as T,T as C,I as m}from"./NoAuthProxyCard.Buvt0BVH.js";import"./zustand.akaTi5uX.js";function as(){if(typeof document>"u")return"en";const g=document.cookie.split(";").find(S=>S.trim().startsWith(`${ye}=`)),k=g?decodeURIComponent(g.split("=")[1]):"en";return je(k)}const oe=g=>({en:{name:"English",flag:"🇺🇸"},vi:{name:"Tiếng Việt",flag:"🇻🇳"},"zh-CN":{name:"简体中文",flag:"🇨🇳"},"zh-TW":{name:"繁體中文",flag:"🇹🇼"},ja:{name:"日本語",flag:"🇯🇵"},"pt-BR":{name:"Português (Brasil)",flag:"🇧🇷"},"pt-PT":{name:"Português (Portugal)",flag:"🇵🇹"},ko:{name:"한국어",flag:"🇰🇷"},es:{name:"Español",flag:"🇪🇸"},de:{name:"Deutsch",flag:"🇩🇪"},fr:{name:"Français",flag:"🇫🇷"},he:{name:"עברית",flag:"🇮🇱"},ar:{name:"العربية",flag:"🇸🇦"},ru:{name:"Русский",flag:"🇷🇺"},pl:{name:"Polski",flag:"🇵🇱"},cs:{name:"Čeština",flag:"🇨🇿"},nl:{name:"Nederlands",flag:"🇳🇱"},tr:{name:"Türkçe",flag:"🇹🇷"},uk:{name:"Українська",flag:"🇺🇦"},tl:{name:"Tagalog",flag:"🇵🇭"},id:{name:"Indonesia",flag:"🇮🇩"},th:{name:"ไทย",flag:"🇹🇭"},hi:{name:"हिन्दी",flag:"🇮🇳"},bn:{name:"বাংলা",flag:"🇧🇩"},ur:{name:"اردو",flag:"🇵🇰"},ro:{name:"Română",flag:"🇷🇴"},sv:{name:"Svenska",flag:"🇸🇪"},it:{name:"Italiano",flag:"🇮🇹"},el:{name:"Ελληνικά",flag:"🇬🇷"},hu:{name:"Magyar",flag:"🇭🇺"},fi:{name:"Suomi",flag:"🇫🇮"},da:{name:"Dansk",flag:"🇩🇰"},no:{name:"Norsk",flag:"🇳🇴"}})[g]||{name:g,flag:"🌐"};function os({className:g="",isOpen:k,onClose:S,hideTrigger:re=!1}){const[P,U]=o.useState("en"),[R,H]=o.useState(!1),[E,V]=o.useState(!1),F=o.useRef(null),r=typeof k=="boolean",x=r?k:E,i=c=>{r?!c&&S&&S(P):V(c)};o.useEffect(()=>{U(as())},[]),o.useEffect(()=>{function c(N){F.current&&!F.current.contains(N.target)&&i(!1)}if(x)return document.addEventListener("mousedown",c),()=>document.removeEventListener("mousedown",c)},[x]);const B=async c=>{if(!(c===P||R)){H(!0),i(!1);try{await fetch("/api/locale",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({locale:c})}),await Xe(),U(c)}catch(N){console.error("Failed to set locale:",N)}finally{H(!1)}}};return e.jsxs("div",{className:g,children:[!re&&e.jsxs("button",{onClick:()=>i(!x),disabled:R,className:"flex items-center gap-2 px-3 py-2 rounded-lg text-text-muted hover:text-text-main hover:bg-surface/60 transition-colors",title:"Language","data-i18n-skip":"true",children:[e.jsx("span",{className:"material-symbols-outlined text-[20px]",children:"language"}),e.jsx("span",{className:"text-sm font-medium",children:oe(P).name}),e.jsx("span",{className:"text-lg",children:oe(P).flag})]}),x&&ss.createPortal(e.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4","data-i18n-skip":"true",children:[e.jsx("div",{className:"absolute inset-0 bg-black/30 backdrop-blur-sm",onClick:()=>i(!1)}),e.jsxs("div",{ref:F,className:"relative w-full bg-surface border border-black/10 dark:border-white/10 rounded-xl shadow-2xl animate-in fade-in zoom-in-95 duration-200 max-w-2xl flex flex-col max-h-[80vh]",children:[e.jsxs("div",{className:"flex items-center justify-between p-3 border-b border-black/5 dark:border-white/5",children:[e.jsx("h2",{className:"text-lg font-semibold text-text-main",children:"Select Language"}),e.jsx("button",{onClick:()=>i(!1),className:"p-1.5 rounded-lg text-text-muted hover:bg-black/5 dark:hover:bg-white/5 transition-colors","aria-label":"Close",children:e.jsx("span",{className:"material-symbols-outlined text-[20px]",children:"close"})})]}),e.jsx("div",{className:"p-6 overflow-y-auto flex-1",children:e.jsx("div",{className:"grid grid-cols-[repeat(auto-fill,minmax(100px,1fr))] gap-2",children:Qe.map(c=>{const N=P===c,O=oe(c);return e.jsxs("button",{onClick:()=>B(c),disabled:R,className:`flex flex-col items-center justify-start gap-1 px-2 py-3 rounded-lg text-xs font-medium transition-colors w-full ${N?"bg-primary/15 text-primary ring-2 ring-primary":"text-text-main hover:bg-black/5 dark:hover:bg-white/5"} ${R?"opacity-70 cursor-wait":""}`,title:O.name,children:[e.jsx("span",{className:"text-2xl",children:O.flag}),e.jsx("span",{className:"text-center leading-tight line-clamp-2 h-8 flex items-center",children:O.name}),N&&e.jsx("span",{className:"material-symbols-outlined text-sm",children:"check"})]},c)})})})]})]}),document.body)]})}function rs(){if(typeof document>"u")return"en";const g=document.cookie.split(";").find(S=>S.trim().startsWith(`${ye}=`)),k=g?decodeURIComponent(g.split("=")[1]):"en";return je(k)}function ds(){const g=ts(),{theme:k,setTheme:S}=Ze(),[re,P]=o.useState("en"),[U,R]=o.useState(!1),[H,E]=o.useState(!1),[V,F]=o.useState(!1),[r,x]=o.useState({fallbackStrategy:"fill-first"}),[i,B]=o.useState(!0),[c,N]=o.useState({current:"",new:"",confirm:""}),[O,M]=o.useState({type:"",message:""}),[we,ie]=o.useState(!1),[le,W]=o.useState(!1),[Y,D]=o.useState({type:"",message:""}),[p,Q]=o.useState({authMode:"password",oidcIssuerUrl:"",oidcClientId:"",oidcScopes:"openid profile email",oidcLoginLabel:"Sign in with OIDC"}),[X,Z]=o.useState(""),[ee,A]=o.useState({type:"",message:""}),[L,ne]=o.useState(!1),[ve,ce]=o.useState(!1),[se,I]=o.useState({type:"",message:""}),[Ne,_e]=o.useState("/api/auth/oidc/callback"),[de,me]=o.useState(!1),z=o.useRef(null),[J,K]=o.useState({outboundProxyEnabled:!1,outboundProxyUrl:"",outboundNoProxy:""}),[te,y]=o.useState({type:"",message:""}),[$,G]=o.useState(!1),[ke,xe]=o.useState(!1),[l,j]=o.useState({codebuddy_auto_fsrouter:!1,codebuddy_leave_canva_team:!1,codebuddy_browser_headless:!0,codebuddy_proxy_enabled:!1,codebuddy_proxy_server:"",codebuddy_proxy_username:"",codebuddy_proxy_password:"",fsmail_base_url:"",fsmail_api_key:"",fsmail_default_domain:"",fsmail_webhook_secret:""}),[ae,f]=o.useState({type:"",message:""}),[w,ue]=o.useState(!1),[Ce,pe]=o.useState(!1),[Se,be]=o.useState(!1),[fe,Pe]=o.useState(!1);o.useEffect(()=>{P(rs())},[U]),o.useEffect(()=>{fetch("/api/settings").then(s=>s.json()).then(s=>{x(s),Q({authMode:(s==null?void 0:s.authMode)||"password",oidcIssuerUrl:(s==null?void 0:s.oidcIssuerUrl)||"",oidcClientId:(s==null?void 0:s.oidcClientId)||"",oidcScopes:(s==null?void 0:s.oidcScopes)||"openid profile email",oidcLoginLabel:(s==null?void 0:s.oidcLoginLabel)||"Sign in with OIDC"}),Z(""),((s==null?void 0:s.authMode)==="oidc"||(s==null?void 0:s.authMode)==="both")&&me(!0),K({outboundProxyEnabled:(s==null?void 0:s.outboundProxyEnabled)===!0,outboundProxyUrl:(s==null?void 0:s.outboundProxyUrl)||"",outboundNoProxy:(s==null?void 0:s.outboundNoProxy)||""}),j({codebuddy_auto_fsrouter:(s==null?void 0:s.codebuddy_auto_fsrouter)==="1",codebuddy_leave_canva_team:(s==null?void 0:s.codebuddy_leave_canva_team)==="1",codebuddy_browser_headless:(s==null?void 0:s.codebuddy_browser_headless)!=="0",codebuddy_proxy_enabled:(s==null?void 0:s.codebuddy_proxy_enabled)==="1",codebuddy_proxy_server:(s==null?void 0:s.codebuddy_proxy_server)||"",codebuddy_proxy_username:(s==null?void 0:s.codebuddy_proxy_username)||"",codebuddy_proxy_password:(s==null?void 0:s.codebuddy_proxy_password)||"",fsmail_base_url:(s==null?void 0:s.fsmail_base_url)||"",fsmail_api_key:(s==null?void 0:s.fsmail_api_key)||"",fsmail_default_domain:(s==null?void 0:s.fsmail_default_domain)||"",fsmail_webhook_secret:(s==null?void 0:s.fsmail_webhook_secret)||""}),B(!1)}).catch(s=>{console.error("Failed to fetch settings:",s),B(!1)})},[]),o.useEffect(()=>{typeof window<"u"&&_e(`${window.location.origin}/api/auth/oidc/callback`)},[]);const Oe=async s=>{ue(!0),f({type:"",message:""});try{const t=await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({codebuddy_auto_fsrouter:l.codebuddy_auto_fsrouter?"1":"0",codebuddy_leave_canva_team:l.codebuddy_leave_canva_team?"1":"0",codebuddy_browser_headless:l.codebuddy_browser_headless?"1":"0",codebuddy_proxy_enabled:l.codebuddy_proxy_enabled?"1":"0",codebuddy_proxy_server:l.codebuddy_proxy_server,codebuddy_proxy_username:l.codebuddy_proxy_username,codebuddy_proxy_password:l.codebuddy_proxy_password,fsmail_base_url:l.fsmail_base_url,fsmail_api_key:l.fsmail_api_key,fsmail_default_domain:l.fsmail_default_domain,fsmail_webhook_secret:l.fsmail_webhook_secret})}),a=await t.json();t.ok?(x(n=>({...n,...a})),f({type:"success",message:"Automation settings saved successfully."})):f({type:"error",message:a.error||"Failed to update automation settings"})}catch{f({type:"error",message:"An error occurred"})}finally{ue(!1)}},Le=async()=>{pe(!0),f({type:"",message:""});try{const s=await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({fsmail_base_url:l.fsmail_base_url,fsmail_api_key:l.fsmail_api_key,fsmail_default_domain:l.fsmail_default_domain,fsmail_webhook_secret:l.fsmail_webhook_secret})});if(!s.ok){const n=await s.json().catch(()=>({}));f({type:"error",message:n.error||"Failed to save settings before testing connection"});return}const t=await fetch("/api/automation/fsmail",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"test-connection"})}),a=await t.json().catch(()=>({}));t.ok?f({type:"success",message:"FSMail Connection Successful!"}):f({type:"error",message:a.error||"FSMail Connection Failed."})}catch(s){f({type:"error",message:s.message||"An error occurred"})}finally{pe(!1)}},Ie=async()=>{var s;be(!0),f({type:"",message:""});try{const t=await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({fsmail_base_url:l.fsmail_base_url,fsmail_api_key:l.fsmail_api_key,fsmail_default_domain:l.fsmail_default_domain,fsmail_webhook_secret:l.fsmail_webhook_secret})});if(!t.ok){const b=await t.json().catch(()=>({}));f({type:"error",message:b.error||"Failed to save settings before registering webhook"});return}const a=await fetch("/api/automation/fsmail",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"webhook-register"})}),n=await a.json().catch(()=>({}));a.ok?(f({type:"success",message:"FSMail Webhook Registered Successfully!"}),(s=n.webhook)!=null&&s.secret&&j(b=>({...b,fsmail_webhook_secret:n.webhook.secret}))):f({type:"error",message:n.error||"FSMail Webhook Registration Failed."})}catch(t){f({type:"error",message:t.message||"An error occurred"})}finally{be(!1)}},Te=async s=>{if(s.preventDefault(),r.outboundProxyEnabled===!0){G(!0),y({type:"",message:""});try{const t=await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({outboundProxyUrl:J.outboundProxyUrl,outboundNoProxy:J.outboundNoProxy})}),a=await t.json();t.ok?(x(n=>({...n,...a})),y({type:"success",message:"Proxy settings applied"})):y({type:"error",message:a.error||"Failed to update proxy settings"})}catch{y({type:"error",message:"An error occurred"})}finally{G(!1)}}},Re=async()=>{if(r.outboundProxyEnabled!==!0)return;const s=(J.outboundProxyUrl||"").trim();if(!s){y({type:"error",message:"Please enter a Proxy URL to test"});return}xe(!0),y({type:"",message:""});try{const t=await fetch("/api/settings/proxy-test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({proxyUrl:s})}),a=await t.json();t.ok&&(a!=null&&a.ok)?y({type:"success",message:`Proxy test OK (${a.status}) in ${a.elapsedMs}ms`}):y({type:"error",message:(a==null?void 0:a.error)||"Proxy test failed"})}catch{y({type:"error",message:"An error occurred"})}finally{xe(!1)}},Fe=async s=>{G(!0),y({type:"",message:""});try{const t=await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({outboundProxyEnabled:s})}),a=await t.json();t.ok?(x(n=>({...n,...a})),K(n=>({...n,outboundProxyEnabled:(a==null?void 0:a.outboundProxyEnabled)===!0})),y({type:"success",message:s?"Proxy enabled":"Proxy disabled"})):y({type:"error",message:a.error||"Failed to update proxy settings"})}catch{y({type:"error",message:"An error occurred"})}finally{G(!1)}},De=async s=>{if(s.preventDefault(),c.new!==c.confirm){M({type:"error",message:"Passwords do not match"});return}ie(!0),M({type:"",message:""});try{const t=await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({currentPassword:c.current,newPassword:c.new})}),a=await t.json();t.ok?(M({type:"success",message:"Password updated successfully"}),N({current:"",new:"",confirm:""})):M({type:"error",message:a.error||"Failed to update password"})}catch{M({type:"error",message:"An error occurred"})}finally{ie(!1)}},Ae=async s=>{try{(await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({fallbackStrategy:s})})).ok&&x(a=>({...a,fallbackStrategy:s}))}catch(t){console.error("Failed to update settings:",t)}},Ue=async s=>{try{(await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({comboStrategy:s})})).ok&&x(a=>({...a,comboStrategy:s}))}catch(t){console.error("Failed to update combo strategy:",t)}},Ee=async s=>{const t=parseInt(s);if(!(isNaN(t)||t<1))try{(await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({stickyRoundRobinLimit:t})})).ok&&x(n=>({...n,stickyRoundRobinLimit:t}))}catch(a){console.error("Failed to update sticky limit:",a)}},Me=async s=>{const t=parseInt(s);if(!(isNaN(t)||t<1))try{(await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({comboStickyRoundRobinLimit:t})})).ok&&x(n=>({...n,comboStickyRoundRobinLimit:t}))}catch(a){console.error("Failed to update combo sticky limit:",a)}},Je=async s=>{try{(await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({requireLogin:s})})).ok&&x(a=>({...a,requireLogin:s}))}catch(t){console.error("Failed to update require login:",t)}},q=(s,t)=>{Q(a=>({...a,[s]:t}))},$e=async(s=p.authMode||"password")=>{const t=p.oidcIssuerUrl.trim(),a=p.oidcClientId.trim(),n=p.oidcScopes.trim(),b=p.oidcLoginLabel.trim(),u=X.trim();if(s!=="password"&&(!t||!a||!u)&&!r.oidcConfigured){A({type:"error",message:"Issuer URL, client ID, and client secret are required to enable OIDC."});return}ne(!0),A({type:"",message:""}),I({type:"",message:""});try{const _={authMode:s,oidcIssuerUrl:t,oidcClientId:a,oidcScopes:n||"openid profile email",oidcLoginLabel:b||"Sign in with OIDC"};u&&(_.oidcClientSecret=u);const h=await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(_)}),d=await h.json();h.ok?(x(Ye=>({...Ye,...d})),Q({authMode:(d==null?void 0:d.authMode)||s,oidcIssuerUrl:(d==null?void 0:d.oidcIssuerUrl)||t,oidcClientId:(d==null?void 0:d.oidcClientId)||a,oidcScopes:(d==null?void 0:d.oidcScopes)||n||"openid profile email",oidcLoginLabel:(d==null?void 0:d.oidcLoginLabel)||b||"Sign in with OIDC"}),Z(""),A({type:"success",message:s==="oidc"?"OIDC login enabled":s==="both"?"Password and OIDC login enabled":"OIDC settings saved"})):A({type:"error",message:d.error||"Failed to save OIDC settings"})}catch{A({type:"error",message:"An error occurred"})}finally{ne(!1)}},qe=async()=>{const s=p.oidcIssuerUrl.trim(),t=p.oidcClientId.trim(),a=p.oidcScopes.trim(),n=X.trim();if(!s||!t){I({type:"error",message:"Issuer URL and client ID are required to test the connection."});return}ce(!0),A({type:"",message:""}),I({type:"",message:""});try{const b=await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({authMode:p.authMode||r.authMode||"password",oidcIssuerUrl:s,oidcClientId:t,oidcScopes:a||"openid profile email",oidcLoginLabel:p.oidcLoginLabel.trim()||"Sign in with OIDC",...n?{oidcClientSecret:n}:{}})}),u=await b.json().catch(()=>({}));if(!b.ok){I({type:"error",message:u.error||"Failed to save OIDC settings before testing"});return}const _=await fetch("/api/auth/oidc/test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({issuerUrl:u.oidcIssuerUrl||s,clientId:u.oidcClientId||t,scopes:u.oidcScopes||a||"openid profile email"})}),h=await _.json().catch(()=>({}));if(_.ok&&(h!=null&&h.ok)){const d=h.clientSecretTested?h.clientSecretValid===!0?`Connection OK. Discovery loaded from ${h.issuerUrl}. Client secret validated too.`:`Connection OK. Discovery loaded from ${h.issuerUrl}. Client secret was not checked.`:`Connection OK. Discovery loaded from ${h.issuerUrl}.`;I({type:"success",message:d})}else I({type:"error",message:h.error||"OIDC connection test failed"})}catch{I({type:"error",message:"An error occurred"})}finally{ce(!1)}},He=async s=>{try{(await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({enableObservability:s})})).ok&&x(a=>({...a,enableObservability:s}))}catch(t){console.error("Failed to update enableObservability:",t)}},Be=async()=>{try{const s=await fetch("/api/settings");if(!s.ok)return;const t=await s.json();x(t)}catch(s){console.error("Failed to reload settings:",s)}},We=async()=>{W(!0),D({type:"",message:""});try{const s=await fetch("/api/settings/database");if(!s.ok){const h=await s.json().catch(()=>({}));throw new Error(h.error||"Failed to export database")}const t=await s.json(),a=JSON.stringify(t,null,2),n=new Blob([a],{type:"application/json"}),b=URL.createObjectURL(n),u=document.createElement("a"),_=new Date().toISOString().replace(/[.:]/g,"-");u.href=b,u.download=`fsrouter-backup-${_}.json`,document.body.appendChild(u),u.click(),document.body.removeChild(u),URL.revokeObjectURL(b),D({type:"success",message:"Database backup downloaded"})}catch(s){D({type:"error",message:s.message||"Failed to export database"})}finally{W(!1)}},ze=async s=>{var a;const t=(a=s.target.files)==null?void 0:a[0];if(t){W(!0),D({type:"",message:""});try{const n=await t.text(),b=JSON.parse(n),u=await fetch("/api/settings/database",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(b)}),_=await u.json().catch(()=>({}));if(!u.ok)throw new Error(_.error||"Failed to import database");await Be(),D({type:"success",message:"Database imported successfully"})}catch(n){D({type:"error",message:n.message||"Invalid backup file"})}finally{z.current&&(z.current.value=""),W(!1)}}},Ke=r.enableObservability===!0,Ge=async()=>{F(!0);try{await fetch("/api/version/shutdown",{method:"POST"})}catch{}F(!1),E(!1)},Ve=async()=>{try{(await fetch("/api/auth/logout",{method:"POST"})).ok&&(localStorage.removeItem("9r_authed"),g("/login"),g(0))}catch(s){console.error("Failed to logout:",s)}};return e.jsxs("div",{className:"max-w-2xl mx-auto px-4 sm:px-0",children:[e.jsxs("div",{className:"flex flex-col gap-6",children:[e.jsxs(T,{children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4 mb-4",children:[e.jsxs("div",{className:"flex items-center gap-3 sm:gap-4",children:[e.jsx("div",{className:"size-10 sm:size-12 rounded-lg bg-green-500/10 text-green-500 flex items-center justify-center shrink-0",children:e.jsx("span",{className:"material-symbols-outlined text-xl sm:text-2xl",children:"computer"})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg sm:text-xl font-semibold",children:"Local Mode"}),e.jsx("p",{className:"text-sm text-text-muted",children:"Running on your machine"})]})]}),e.jsx("div",{className:"inline-flex p-1 rounded-lg bg-black/5 dark:bg-white/5 w-full sm:w-auto",children:["light","dark","system"].map(s=>e.jsxs("button",{type:"button",onClick:()=>S(s),className:he("flex items-center justify-center gap-1 sm:gap-1.5 px-2 sm:px-3 py-1.5 rounded-md font-medium transition-all flex-1 sm:flex-initial",k===s?"bg-white dark:bg-white/10 text-text-main shadow-sm":"text-text-muted hover:text-text-main"),children:[e.jsx("span",{className:"material-symbols-outlined text-[18px]",children:s==="light"?"light_mode":s==="dark"?"dark_mode":"contrast"}),e.jsx("span",{className:"capitalize text-xs sm:text-sm",children:s})]},s))})]}),e.jsxs("div",{className:"flex flex-col gap-3 pt-4 border-t border-border",children:[e.jsx("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between p-3 rounded-lg bg-bg border border-border gap-2",children:e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm sm:text-base",children:"Database Location"}),e.jsx("p",{className:"text-xs sm:text-sm text-text-muted font-mono break-all",children:"~/.fsrouter/db/data.sqlite"})]})}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-2",children:[e.jsx(v,{variant:"secondary",icon:"download",onClick:We,loading:le,className:"w-full sm:w-auto",children:"Download Backup"}),e.jsx(v,{variant:"outline",icon:"upload",onClick:()=>{var s;return(s=z.current)==null?void 0:s.click()},disabled:le,className:"w-full sm:w-auto",children:"Import Backup"}),e.jsx("input",{ref:z,type:"file",accept:"application/json,.json",className:"hidden",onChange:ze})]}),Y.message&&e.jsx("p",{className:`text-sm ${Y.type==="error"?"text-red-500":"text-green-600 dark:text-green-400"}`,children:Y.message})]})]}),e.jsxs(T,{children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[e.jsx("div",{className:"p-2 rounded-lg bg-primary/10 text-primary shrink-0",children:e.jsx("span",{className:"material-symbols-outlined text-[20px]",children:"shield"})}),e.jsx("h3",{className:"text-base sm:text-lg font-semibold",children:"Security"})]}),e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsxs("div",{className:"flex items-start sm:items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium text-sm sm:text-base",children:"Require login"}),e.jsx("p",{className:"text-xs sm:text-sm text-text-muted",children:"When ON, dashboard requires password. When OFF, access without login."})]}),e.jsx(C,{checked:r.requireLogin===!0,onChange:()=>Je(!r.requireLogin),disabled:i})]}),r.requireLogin===!0&&e.jsxs("form",{onSubmit:De,className:"flex flex-col gap-4 pt-4 border-t border-border/50",children:[r.hasPassword&&e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("label",{className:"text-xs sm:text-sm font-medium",children:"Current Password"}),e.jsx(m,{type:"password",placeholder:"Enter current password",value:c.current,onChange:s=>N({...c,current:s.target.value}),required:!0})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("label",{className:"text-xs sm:text-sm font-medium",children:"New Password"}),e.jsx(m,{type:"password",placeholder:"Enter new password",value:c.new,onChange:s=>N({...c,new:s.target.value}),required:!0})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("label",{className:"text-xs sm:text-sm font-medium",children:"Confirm New Password"}),e.jsx(m,{type:"password",placeholder:"Confirm new password",value:c.confirm,onChange:s=>N({...c,confirm:s.target.value}),required:!0})]})]}),O.message&&e.jsx("p",{className:`text-xs sm:text-sm ${O.type==="error"?"text-red-500":"text-green-500"}`,children:O.message}),e.jsx("div",{className:"pt-2",children:e.jsx(v,{type:"submit",variant:"primary",loading:we,className:"w-full sm:w-auto",children:r.hasPassword?"Update Password":"Set Password"})})]})]})]}),e.jsxs(T,{children:[e.jsxs("button",{type:"button",onClick:()=>me(s=>!s),className:"w-full flex items-center gap-3 text-left",children:[e.jsx("div",{className:"p-2 rounded-lg bg-indigo-500/10 text-indigo-500 shrink-0",children:e.jsx("span",{className:"material-symbols-outlined text-[20px]",children:"lock_open"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"text-base sm:text-lg font-semibold",children:"OIDC Dashboard Login"}),e.jsx("p",{className:"text-xs text-text-muted",children:r.authMode==="oidc"?"OIDC active":r.authMode==="both"?"Password + OIDC active":"Optional SSO via Authentik/Keycloak/Google"})]}),e.jsx("span",{className:"material-symbols-outlined text-text-muted shrink-0",children:de?"expand_less":"expand_more"})]}),de&&e.jsxs("div",{className:"flex flex-col gap-4 mt-4",children:[e.jsx("p",{className:"text-xs sm:text-sm text-text-muted",children:"Use Authentik or any OIDC provider to sign in to the dashboard. You can enable password-only, OIDC-only, or both for the dashboard; model API access still uses API keys."}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("label",{className:"font-medium text-sm sm:text-base",children:"Auth Mode"}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-2",children:[{value:"password",title:"Password only",desc:"Keep the legacy password login."},{value:"oidc",title:"OIDC only",desc:"Require OIDC for dashboard access."},{value:"both",title:"Both",desc:"Allow either password or OIDC."}].map(s=>{const t=p.authMode===s.value;return e.jsxs("button",{type:"button",onClick:()=>q("authMode",s.value),className:he("text-left rounded-lg border p-3 transition-colors",t?"border-primary bg-primary/5":"border-border bg-bg hover:bg-black/5 dark:hover:bg-white/5"),disabled:i||L,children:[e.jsx("p",{className:"font-medium text-sm sm:text-base",children:s.title}),e.jsx("p",{className:"text-xs sm:text-sm text-text-muted mt-1",children:s.desc})]},s.value)})})]}),e.jsxs("div",{className:"grid grid-cols-1 gap-4",children:[e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("label",{className:"font-medium text-sm sm:text-base",children:"Issuer URL"}),e.jsx(m,{placeholder:"https://auth.example.com/application/o/fsrouter/",value:p.oidcIssuerUrl,onChange:s=>q("oidcIssuerUrl",s.target.value),disabled:i||L})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("label",{className:"font-medium text-sm sm:text-base",children:"Client ID"}),e.jsx(m,{placeholder:"fsrouter-dashboard",value:p.oidcClientId,onChange:s=>q("oidcClientId",s.target.value),disabled:i||L})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("label",{className:"font-medium text-sm sm:text-base",children:"Client Secret"}),e.jsx(m,{type:"password",placeholder:"Leave blank to keep existing secret",value:X,onChange:s=>Z(s.target.value),disabled:i||L}),e.jsx("p",{className:"text-xs sm:text-sm text-text-muted",children:"This value is write-only after saving."})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("label",{className:"font-medium text-sm sm:text-base",children:"Scopes"}),e.jsx(m,{placeholder:"openid profile email",value:p.oidcScopes,onChange:s=>q("oidcScopes",s.target.value),disabled:i||L})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("label",{className:"font-medium text-sm sm:text-base",children:"Login Button Label"}),e.jsx(m,{placeholder:"Sign in with OIDC",value:p.oidcLoginLabel,onChange:s=>q("oidcLoginLabel",s.target.value),disabled:i||L})]})]}),e.jsxs("div",{className:"rounded-lg border border-border bg-bg p-3 text-xs sm:text-sm text-text-muted",children:[e.jsx("p",{className:"font-medium text-text-main mb-1",children:"Redirect URI"}),e.jsx("code",{className:"block break-all font-mono",children:Ne})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-2 pt-2 border-t border-border/50",children:[e.jsx(v,{type:"button",variant:"primary",loading:L,onClick:()=>$e(),className:"w-full sm:w-auto",children:"Save auth mode"}),e.jsx(v,{type:"button",variant:"outline",loading:ve,onClick:qe,className:"w-full sm:w-auto",children:"Test connection"})]}),se.message&&e.jsx("p",{className:`text-xs sm:text-sm ${se.type==="error"?"text-red-500":"text-green-500"}`,children:se.message}),ee.message&&e.jsx("p",{className:`text-xs sm:text-sm ${ee.type==="error"?"text-red-500":"text-green-500"}`,children:ee.message}),r.authMode==="oidc"&&e.jsx("p",{className:"text-xs sm:text-sm text-amber-600 dark:text-amber-400",children:"OIDC login is currently active. Password login is disabled until you switch back."}),r.authMode==="both"&&e.jsx("p",{className:"text-xs sm:text-sm text-amber-600 dark:text-amber-400",children:"Password and OIDC login are both active."})]})]}),e.jsxs(T,{children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[e.jsx("div",{className:"p-2 rounded-lg bg-blue-500/10 text-blue-500 shrink-0",children:e.jsx("span",{className:"material-symbols-outlined text-[20px]",children:"route"})}),e.jsx("h3",{className:"text-base sm:text-lg font-semibold",children:"Routing Strategy"})]}),e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsxs("div",{className:"flex items-start sm:items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium text-sm sm:text-base",children:"Round Robin"}),e.jsx("p",{className:"text-xs sm:text-sm text-text-muted",children:"Cycle through accounts to distribute load"})]}),e.jsx(C,{checked:r.fallbackStrategy==="round-robin",onChange:()=>Ae(r.fallbackStrategy==="round-robin"?"fill-first":"round-robin"),disabled:i})]}),r.fallbackStrategy==="round-robin"&&e.jsxs("div",{className:"flex items-start sm:items-center justify-between gap-4 pt-2 border-t border-border/50",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium text-sm sm:text-base",children:"Sticky Limit"}),e.jsx("p",{className:"text-xs sm:text-sm text-text-muted",children:"Calls per account before switching"})]}),e.jsx(m,{type:"number",min:"1",max:"10",value:r.stickyRoundRobinLimit||3,onChange:s=>Ee(s.target.value),disabled:i,className:"w-16 sm:w-20 text-center shrink-0"})]}),e.jsxs("div",{className:"flex items-start sm:items-center justify-between gap-4 pt-4 border-t border-border/50",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium text-sm sm:text-base",children:"Combo Round Robin"}),e.jsx("p",{className:"text-xs sm:text-sm text-text-muted",children:"Cycle through providers in combos instead of always starting with first"})]}),e.jsx(C,{checked:r.comboStrategy==="round-robin",onChange:()=>Ue(r.comboStrategy==="round-robin"?"fallback":"round-robin"),disabled:i})]}),r.comboStrategy==="round-robin"&&e.jsxs("div",{className:"flex items-center justify-between pt-2 border-t border-border/50",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:"Combo Sticky Limit"}),e.jsx("p",{className:"text-sm text-text-muted",children:"Calls per combo model before switching"})]}),e.jsx(m,{type:"number",min:"1",max:"100",value:r.comboStickyRoundRobinLimit||1,onChange:s=>Me(s.target.value),disabled:i,className:"w-20 text-center"})]}),e.jsxs("p",{className:"text-xs text-text-muted italic pt-2 border-t border-border/50",children:[r.fallbackStrategy==="round-robin"?`Currently distributing requests across all available accounts with ${r.stickyRoundRobinLimit||3} calls per account.`:"Currently using accounts in priority order (Fill First).",r.comboStrategy==="round-robin"?` Combos rotate after ${r.comboStickyRoundRobinLimit||1} call${(r.comboStickyRoundRobinLimit||1)===1?"":"s"} per model.`:" Combos always start with their first model."]})]})]}),e.jsxs(T,{children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[e.jsx("div",{className:"p-2 rounded-lg bg-purple-500/10 text-purple-500 shrink-0",children:e.jsx("span",{className:"material-symbols-outlined text-[20px]",children:"wifi"})}),e.jsx("h3",{className:"text-base sm:text-lg font-semibold",children:"Network"})]}),e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsxs("div",{className:"flex items-start sm:items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium text-sm sm:text-base",children:"Outbound Proxy"}),e.jsx("p",{className:"text-xs sm:text-sm text-text-muted",children:"Enable proxy for OAuth + provider outbound requests."})]}),e.jsx(C,{checked:r.outboundProxyEnabled===!0,onChange:()=>Fe(r.outboundProxyEnabled!==!0),disabled:i||$})]}),r.outboundProxyEnabled===!0&&e.jsxs("form",{onSubmit:Te,className:"flex flex-col gap-4 pt-2 border-t border-border/50",children:[e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("label",{className:"font-medium text-sm sm:text-base",children:"Proxy URL"}),e.jsx(m,{placeholder:"http://127.0.0.1:7897",value:J.outboundProxyUrl,onChange:s=>K(t=>({...t,outboundProxyUrl:s.target.value})),disabled:i||$}),e.jsx("p",{className:"text-xs sm:text-sm text-text-muted",children:"Leave empty to inherit existing env proxy (if any)."})]}),e.jsxs("div",{className:"flex flex-col gap-2 pt-2 border-t border-border/50",children:[e.jsx("label",{className:"font-medium text-sm sm:text-base",children:"No Proxy"}),e.jsx(m,{placeholder:"localhost,127.0.0.1",value:J.outboundNoProxy,onChange:s=>K(t=>({...t,outboundNoProxy:s.target.value})),disabled:i||$}),e.jsx("p",{className:"text-xs sm:text-sm text-text-muted",children:"Comma-separated hostnames/domains to bypass the proxy."})]}),e.jsxs("div",{className:"pt-2 border-t border-border/50 flex flex-col sm:flex-row items-stretch sm:items-center gap-2",children:[e.jsx(v,{type:"button",variant:"secondary",loading:ke,disabled:i||$,onClick:Re,className:"w-full sm:w-auto",children:"Test proxy URL"}),e.jsx(v,{type:"submit",variant:"primary",loading:$,className:"w-full sm:w-auto",children:"Apply"})]})]}),te.message&&e.jsx("p",{className:`text-xs sm:text-sm ${te.type==="error"?"text-red-500":"text-green-500"} pt-2 border-t border-border/50`,children:te.message})]})]}),e.jsxs(T,{children:[e.jsxs("button",{type:"button",onClick:()=>Pe(s=>!s),className:"w-full flex items-center gap-3 text-left focus:outline-none",children:[e.jsx("div",{className:"p-2 rounded-lg bg-emerald-500/10 text-emerald-500 shrink-0",children:e.jsx("span",{className:"material-symbols-outlined text-[20px]",children:"smart_toy"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"text-base sm:text-lg font-semibold",children:"Automation Settings"}),e.jsx("p",{className:"text-xs text-text-muted",children:"Manage CodeBuddy browser signup & FSMail temporary email configurations."})]}),e.jsx("span",{className:"material-symbols-outlined text-text-muted shrink-0",children:fe?"expand_less":"expand_more"})]}),fe&&e.jsxs("div",{className:"flex flex-col gap-4 mt-4",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("h4",{className:"font-semibold text-sm text-text-main flex items-center gap-1.5 border-b border-border/55 pb-1",children:[e.jsx("span",{className:"material-symbols-outlined text-[16px]",children:"smart_toy"}),"CodeBuddy API Gen Settings"]}),e.jsxs("div",{className:"flex items-start sm:items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium text-sm sm:text-base",children:"Headless Browser"}),e.jsx("p",{className:"text-xs sm:text-sm text-text-muted",children:"Run the automated signup browser in headless mode (no visual window)."})]}),e.jsx(C,{checked:l.codebuddy_browser_headless,onChange:s=>j(t=>({...t,codebuddy_browser_headless:s})),disabled:i||w})]}),e.jsxs("div",{className:"flex items-start sm:items-center justify-between gap-4 pt-2 border-t border-border/50",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium text-sm sm:text-base",children:"Auto Inject to fsrouter"}),e.jsx("p",{className:"text-xs sm:text-sm text-text-muted",children:"Automatically add newly generated CodeBuddy API keys to fsrouter connections."})]}),e.jsx(C,{checked:l.codebuddy_auto_fsrouter,onChange:s=>j(t=>({...t,codebuddy_auto_fsrouter:s})),disabled:i||w})]}),e.jsxs("div",{className:"flex items-start sm:items-center justify-between gap-4 pt-2 border-t border-border/50",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium text-sm sm:text-base",children:"Leave Canva Team after Leonardo Registration"}),e.jsx("p",{className:"text-xs sm:text-sm text-text-muted",children:"Automatically leave the Canva team after completing Leonardo registration to free up team invite slots."})]}),e.jsx(C,{checked:l.codebuddy_leave_canva_team,onChange:s=>j(t=>({...t,codebuddy_leave_canva_team:s})),disabled:i||w})]}),e.jsxs("div",{className:"flex items-start sm:items-center justify-between gap-4 pt-2 border-t border-border/50",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium text-sm sm:text-base",children:"Use Outbound Proxy"}),e.jsx("p",{className:"text-xs sm:text-sm text-text-muted",children:"Route the automation browser traffic through a proxy server."})]}),e.jsx(C,{checked:l.codebuddy_proxy_enabled,onChange:s=>j(t=>({...t,codebuddy_proxy_enabled:s})),disabled:i||w})]}),l.codebuddy_proxy_enabled&&e.jsxs("div",{className:"flex flex-col gap-3 pl-4 border-l-2 border-primary/20 pt-2",children:[e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx("label",{className:"text-xs font-medium text-text-main",children:"Proxy Server"}),e.jsx(m,{placeholder:"host:port (e.g. 127.0.0.1:8080)",value:l.codebuddy_proxy_server,onChange:s=>j(t=>({...t,codebuddy_proxy_server:s.target.value})),disabled:i||w})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx("label",{className:"text-xs font-medium text-text-main",children:"Proxy Username (Optional)"}),e.jsx(m,{placeholder:"username",value:l.codebuddy_proxy_username,onChange:s=>j(t=>({...t,codebuddy_proxy_username:s.target.value})),disabled:i||w})]}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx("label",{className:"text-xs font-medium text-text-main",children:"Proxy Password (Optional)"}),e.jsx(m,{type:"password",placeholder:"password",value:l.codebuddy_proxy_password,onChange:s=>j(t=>({...t,codebuddy_proxy_password:s.target.value})),disabled:i||w})]})]})]})]}),e.jsxs("div",{className:"space-y-4 pt-4 border-t border-border/55",children:[e.jsxs("h4",{className:"font-semibold text-sm text-text-main flex items-center gap-1.5 border-b border-border/55 pb-1",children:[e.jsx("span",{className:"material-symbols-outlined text-[16px]",children:"mail"}),"FSMail Temp Mail Settings"]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("label",{className:"font-medium text-sm sm:text-base",children:"Base URL"}),e.jsx(m,{placeholder:"https://fsmail.example.com",value:l.fsmail_base_url,onChange:s=>j(t=>({...t,fsmail_base_url:s.target.value})),disabled:i||w})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("label",{className:"font-medium text-sm sm:text-base",children:"API Key"}),e.jsx(m,{type:"password",placeholder:"FSMail API Key",value:l.fsmail_api_key,onChange:s=>j(t=>({...t,fsmail_api_key:s.target.value})),disabled:i||w})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("label",{className:"font-medium text-sm sm:text-base",children:"Default Domain"}),e.jsx(m,{placeholder:"example.com",value:l.fsmail_default_domain,onChange:s=>j(t=>({...t,fsmail_default_domain:s.target.value})),disabled:i||w})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("label",{className:"font-medium text-sm sm:text-base",children:"Webhook Secret"}),e.jsx(m,{type:"password",placeholder:"Leave empty to auto-generate",value:l.fsmail_webhook_secret,onChange:s=>j(t=>({...t,fsmail_webhook_secret:s.target.value})),disabled:i||w})]})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-2 pt-4 border-t border-border/50",children:[e.jsx(v,{type:"button",variant:"primary",loading:w,onClick:()=>Oe(),className:"w-full sm:w-auto",children:"Save Settings"}),e.jsx(v,{type:"button",variant:"secondary",loading:Ce,onClick:Le,className:"w-full sm:w-auto",children:"Test FSMail Connection"}),e.jsx(v,{type:"button",variant:"outline",loading:Se,onClick:Ie,className:"w-full sm:w-auto",children:"Register Webhook"})]}),ae.message&&e.jsx("p",{className:`text-xs sm:text-sm ${ae.type==="error"?"text-red-500":"text-green-500"} pt-2 border-t border-border/50`,children:ae.message})]})]}),e.jsxs(T,{children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[e.jsx("div",{className:"p-2 rounded-lg bg-orange-500/10 text-orange-500 shrink-0",children:e.jsx("span",{className:"material-symbols-outlined text-[20px]",children:"monitoring"})}),e.jsx("h3",{className:"text-base sm:text-lg font-semibold",children:"Observability"})]}),e.jsxs("div",{className:"flex items-start sm:items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium text-sm sm:text-base",children:"Enable Observability"}),e.jsx("p",{className:"text-xs sm:text-sm text-text-muted",children:"Record request details for inspection in the logs view"})]}),e.jsx(C,{checked:Ke,onChange:He,disabled:i})]})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-2",children:[e.jsx(v,{variant:"outline",fullWidth:!0,icon:"power_settings_new",onClick:()=>E(!0),className:"text-red-500 border-red-200 hover:bg-red-50 hover:border-red-300",children:"Shutdown"}),e.jsx(v,{variant:"outline",fullWidth:!0,icon:"logout",onClick:Ve,children:"Logout"})]}),e.jsxs("div",{className:"text-center text-xs sm:text-sm text-text-muted py-4",children:[e.jsxs("p",{children:[ge.name," v",ge.version]}),e.jsx("p",{className:"mt-1",children:"Local Mode - All data stored on your machine"})]})]}),e.jsx(os,{hideTrigger:!0,isOpen:U,onClose:s=>{R(!1),P(s)}}),e.jsx(es,{isOpen:H,onClose:()=>E(!1),onConfirm:Ge,title:"Close Proxy",message:"Are you sure you want to close the proxy server?",confirmText:"Close",cancelText:"Cancel",variant:"danger",loading:V})]})}export{ds as default};
@@ -1 +0,0 @@
1
- import{j as e,B as h}from"./index.DQDDDpp7.js";import{b as r}from"./router.Cjj1--8t.js";import"./NoAuthProxyCard.C18iZ3Fk.js";import"./zustand.akaTi5uX.js";function R(){const[l,s]=r.useState(!1),[c,a]=r.useState(""),[o,m]=r.useState(""),i=r.useRef(null),f=()=>{window.location.href="/api/db"},b=()=>{i.current&&i.current.click()},g=async n=>{const t=n.target.files[0];if(t){if(!t.name.endsWith(".fud")&&!t.name.endsWith(".json")){a("Format file tidak didukung. Harap gunakan file berekstensi .fud");return}if(!window.confirm("PERINGATAN: Memulihkan database akan MENIMPA semua data, pengaturan, dan provider saat ini! Server akan di-restart otomatis. Lanjutkan?")){n.target.value="";return}a(""),m(""),s(!0);try{const d=new FileReader;d.onload=async j=>{try{const x=j.target.result,k=JSON.parse(x),u=await fetch("/api/db",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(k)}),p=await u.json();u.ok&&p.success?(m("Restore berhasil! Server sedang merestart, harap tunggu beberapa saat..."),setTimeout(()=>{window.location.reload()},5e3)):(a(p.error||"Gagal melakukan restore."),s(!1))}catch{a("File backup corrupt atau tidak valid."),s(!1)}},d.readAsText(t)}catch{a("Gagal membaca file."),s(!1)}n.target.value=""}};return e.jsxs("div",{className:"max-w-4xl mx-auto p-4 space-y-6",children:[e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsxs("h1",{className:"text-2xl font-bold text-text-main flex items-center gap-2",children:[e.jsx("span",{className:"material-symbols-outlined text-[28px] text-primary",children:"backup"}),"Backup & Restore"]}),e.jsx("p",{className:"text-xs text-text-muted",children:"Amankan seluruh data FSRouter Anda ke dalam satu file .fud, atau pulihkan data dari file backup sebelumnya."})]}),c&&e.jsxs("div",{className:"p-4 bg-red-500/10 border border-red-500/20 text-red-500 text-sm rounded-lg flex items-center gap-2",children:[e.jsx("span",{className:"material-symbols-outlined text-sm",children:"error"}),c]}),o&&e.jsxs("div",{className:"p-4 bg-green-500/10 border border-green-500/20 text-green-500 text-sm rounded-lg flex items-center gap-2",children:[e.jsx("span",{className:"material-symbols-outlined text-sm",children:"check_circle"}),o]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"p-6 rounded-[14px] border border-border-subtle bg-surface flex flex-col gap-4",children:[e.jsxs("div",{className:"flex items-center gap-3 text-text-main",children:[e.jsx("div",{className:"size-10 rounded-full bg-blue-500/10 text-blue-500 flex items-center justify-center",children:e.jsx("span",{className:"material-symbols-outlined text-xl",children:"cloud_download"})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-sm font-semibold",children:"Buat Backup"}),e.jsx("p",{className:"text-[11px] text-text-muted",children:"Simpan data ke perangkat Anda"})]})]}),e.jsxs("div",{className:"text-xs text-text-muted leading-relaxed flex-1",children:[e.jsx("p",{className:"mb-2",children:"File backup (.fud) berisi keseluruhan state sistem:"}),e.jsxs("ul",{className:"list-disc list-inside space-y-1 ml-1",children:[e.jsx("li",{children:"Konfigurasi Providers & Endpoint"}),e.jsx("li",{children:"Riwayat Penggunaan & Limits"}),e.jsx("li",{children:"Akun Otomatis & FSmail"}),e.jsx("li",{children:"Proxy Pools & Identitas Perangkat"})]})]}),e.jsx(h,{variant:"primary",fullWidth:!0,onClick:f,icon:"download",children:"Download Backup (.fud)"})]}),e.jsxs("div",{className:"p-6 rounded-[14px] border border-border-subtle bg-surface flex flex-col gap-4",children:[e.jsxs("div",{className:"flex items-center gap-3 text-text-main",children:[e.jsx("div",{className:"size-10 rounded-full bg-amber-500/10 text-amber-500 flex items-center justify-center",children:e.jsx("span",{className:"material-symbols-outlined text-xl",children:"restore"})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-sm font-semibold",children:"Pulihkan Backup"}),e.jsx("p",{className:"text-[11px] text-text-muted",children:"Timpa data dari file .fud"})]})]}),e.jsxs("div",{className:"text-xs text-text-muted leading-relaxed flex-1",children:[e.jsx("p",{className:"mb-2 text-amber-500/90 font-medium",children:"Perhatian sebelum memulihkan:"}),e.jsx("p",{children:"Proses restore akan menghapus dan menimpa database yang berjalan saat ini dengan database yang ada di file backup. FSRouter akan melakukan restart layanan setelah proses restore selesai."})]}),e.jsx("input",{type:"file",accept:".fud,.json",ref:i,onChange:g,className:"hidden"}),e.jsx(h,{variant:"secondary",fullWidth:!0,onClick:b,disabled:l,icon:l?"sync":"upload",children:l?"Sedang Memulihkan...":"Pilih File & Restore"})]})]})]})}export{R as default};
@@ -1,5 +0,0 @@
1
- import{j as e,I as pe,v as fe,B as A,P as be,g as ge}from"./index.B-zMpSp_.js";import{h as je,d as we,b as c,L as ve}from"./router.Cjj1--8t.js";import{C as S,I as ye,T as Ne,M as ke}from"./NoAuthProxyCard.VRP7gDcs.js";import"./zustand.akaTi5uX.js";function Se(o){if(typeof o!="string")return{providerId:"",model:""};const g=o.indexOf("/");return g<0?{providerId:o,model:""}:{providerId:o.slice(0,g),model:o.slice(g+1)}}const Re=/^[a-zA-Z0-9_.\-]+$/,Ee={webSearch:"Web Search",webFetch:"Web Fetch",image:"Text to Image",tts:"Text To Speech"},V={webSearch:"/v1/search",webFetch:"/v1/web/fetch",image:"/v1/images/generations",tts:"/v1/audio/speech"},L={webSearch:o=>({model:o,query:"What is the latest news about AI?",search_type:"web",max_results:5}),webFetch:o=>({model:o,url:"https://example.com",format:"markdown"}),image:o=>({model:o,prompt:"A cute cat playing piano",n:1,size:"1024x1024"}),tts:o=>({model:o,input:"Hello, this is a test.",voice:"alloy"})};function X(o){return o==="webSearch"||o==="webFetch"?"/dashboard/media-providers/web":`/dashboard/media-providers/${o}`}function Le(){var K;const{id:o}=je(),g=we(),[r,P]=c.useState(null),[q,O]=c.useState(!0),[N,_]=c.useState(""),[G,R]=c.useState(""),[m,j]=c.useState([]),[Y,$]=c.useState(!1),[Z,I]=c.useState(!1),[M,Q]=c.useState([]),[D,B]=c.useState(!1),[l,w]=c.useState(null),[z,E]=c.useState(""),[U,ee]=c.useState(""),[te,se]=c.useState([]),[ae,ne]=c.useState({}),H=async()=>{var t,s,a;try{const[n,i,k,y,x,p]=await Promise.all([fetch(`/api/combos/${o}`,{cache:"no-store"}),fetch("/api/settings",{cache:"no-store"}),fetch("/api/usage/logs",{cache:"no-store"}),fetch("/api/keys",{cache:"no-store"}),fetch("/api/providers",{cache:"no-store"}),fetch("/api/models/alias",{cache:"no-store"})]);if(p.ok&&ne((await p.json()).aliases||{}),y.ok){const b=await y.json();ee(((t=(b.keys||[]).find(d=>d.isActive!==!1))==null?void 0:t.key)||"")}if(x.ok&&se((await x.json()).connections||[]),!n.ok){P(null),O(!1);return}const h=await n.json();P(h),_(h.name),j(h.models||[]);const f=i.ok?await i.json():{};$(((a=(s=f.comboStrategies)==null?void 0:s[h.name])==null?void 0:a.fallbackStrategy)==="round-robin");const u=k.ok?await k.json():[];Q(u.filter(b=>typeof b=="string"&&b.includes(h.name)).slice(0,50))}catch{}O(!1)};c.useEffect(()=>{H()},[o]);const F=t=>t.trim()?Re.test(t)?(R(""),!0):(R("Only letters, numbers, -, _ and ."),!1):(R("Name is required"),!1),v=async t=>{const s=await fetch(`/api/combos/${o}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!s.ok){const a=await s.json();return alert(a.error||"Failed to save"),!1}return!0},oe=async()=>{if(!F(N)||N===r.name)return;await v({name:N})&&await H()},re=async t=>{const s=(t==null?void 0:t.value)||t;if(!s||m.includes(s))return;const a=[...m,s];j(a),await v({models:a})},le=async t=>{const s=(t==null?void 0:t.value)||t;if(!s||!m.includes(s))return;const a=m.filter(n=>n!==s);j(a),await v({models:a})},ie=async t=>{const s=m.filter((a,n)=>n!==t);j(s),await v({models:s})},J=async(t,s)=>{const a=[...m],n=t+s;n<0||n>=a.length||([a[t],a[n]]=[a[n],a[t]],j(a),await v({models:a}))},ce=async t=>{$(t);const s=await fetch("/api/settings",{cache:"no-store"}),n={...(s.ok?await s.json():{}).comboStrategies||{}};t?n[r.name]={fallbackStrategy:"round-robin"}:delete n[r.name],await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({comboStrategies:n})})},de=async()=>{if(!confirm(`Delete combo "${r.name}"?`))return;(await fetch(`/api/combos/${o}`,{method:"DELETE"})).ok&&g(X(r.kind))},me=async()=>{var s,a,n;if(B(!0),w(null),E(""),l!=null&&l.audioUrl)try{URL.revokeObjectURL(l.audioUrl)}catch{}if((s=l==null?void 0:l.imageUrl)!=null&&s.startsWith("blob:"))try{URL.revokeObjectURL(l.imageUrl)}catch{}const t=Date.now();try{const i=V[r.kind],k=L[r.kind](r.name),y={"Content-Type":"application/json"};U&&(y.Authorization=`Bearer ${U}`);const x=await fetch(`/api${i}`,{method:"POST",headers:y,body:JSON.stringify(k)}),p=Date.now()-t;if(!x.ok){const d=await x.json().catch(()=>({}));E(((a=d==null?void 0:d.error)==null?void 0:a.message)||(d==null?void 0:d.error)||`HTTP ${x.status}`),w({json:JSON.stringify(d,null,2),latencyMs:p});return}const h=x.headers.get("content-type")||"";if(h.startsWith("image/")){const d=await x.blob();w({imageUrl:URL.createObjectURL(d),latencyMs:p});return}if(h.startsWith("audio/")||h==="application/octet-stream"){const d=await x.blob();w({audioUrl:URL.createObjectURL(d),latencyMs:p});return}const f=await x.json(),u=(n=f==null?void 0:f.data)==null?void 0:n[0],b=u!=null&&u.b64_json?`data:image/png;base64,${u.b64_json}`:(u==null?void 0:u.url)||"";w({json:JSON.stringify(C(f),null,2),imageUrl:b,latencyMs:p})}catch(i){E(i.message||"Network error")}B(!1)};function C(t){if(!t||typeof t!="object")return t;if(Array.isArray(t))return t.map(C);const s={};for(const[a,n]of Object.entries(t))s[a]=a==="b64_json"&&typeof n=="string"&&n.length>100?`<${n.length} chars base64>`:C(n);return s}if(q)return e.jsx("div",{className:"text-text-muted text-sm",children:"Loading..."});if(!r)return null;const W=Ee[r.kind]||((K=pe.find(t=>t.id===r.kind))==null?void 0:K.label)||"Combo",T=V[r.kind],xe=r.kind&&L[r.kind]?L[r.kind](r.name):null,he=T?`curl -X POST ${fe()}${T} \\
2
- -H "Content-Type: application/json" \\
3
- -H "Authorization: Bearer ${U||"YOUR_KEY"}" \\
4
- -d '${JSON.stringify(xe)}'`:"",ue=X(r.kind);return e.jsxs("div",{className:"flex flex-col gap-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 items-center gap-3 min-w-0",children:[e.jsx(ve,{to:ue,className:"text-text-muted hover:text-primary",children:e.jsx("span",{className:"material-symbols-outlined",children:"arrow_back"})}),e.jsx("div",{className:"size-10 rounded-lg bg-primary/10 flex items-center justify-center",children:e.jsx("span",{className:"material-symbols-outlined text-primary",children:"layers"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("p",{className:"text-xs text-text-muted",children:[W," Combo"]}),e.jsx("code",{className:"text-lg font-semibold font-mono",children:r.name})]})]}),e.jsx(A,{variant:"outline",icon:"delete",onClick:de,className:"text-red-500 border-red-200 hover:bg-red-50",children:"Delete"})]}),e.jsxs(S,{children:[e.jsx("h2",{className:"text-lg font-semibold mb-3",children:"Settings"}),e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsxs("div",{children:[e.jsx(ye,{label:"Combo Name",value:N,onChange:t=>{_(t.target.value),F(t.target.value)},onBlur:oe,error:G}),e.jsx("p",{className:"text-[10px] text-text-muted mt-0.5",children:"Only letters, numbers, -, _ and ."})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:"Round Robin"}),e.jsx("p",{className:"text-xs text-text-muted",children:"Rotate providers across requests instead of strict fallback order."})]}),e.jsx(Ne,{checked:Y,onChange:ce})]})]})]}),e.jsxs(S,{children:[e.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between mb-3",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold",children:"Providers"}),e.jsx("p",{className:"text-xs text-text-muted",children:"Tried in order (top-down) or rotated when round-robin is on."})]}),e.jsx(A,{size:"sm",icon:"add",onClick:()=>I(!0),children:"Add Provider"})]}),m.length===0?e.jsx("div",{className:"text-center py-6 border border-dashed border-border rounded-lg text-text-muted text-sm",children:"No providers yet."}):e.jsx("div",{className:"flex flex-col gap-2",children:m.map((t,s)=>{const{providerId:a,model:n}=Se(t),i=ge[a];return e.jsxs("div",{className:"flex items-center gap-3 p-2 rounded-lg bg-black/[0.02] dark:bg-white/[0.02]",children:[e.jsx("span",{className:"text-xs text-text-muted w-5 text-center",children:s+1}),e.jsx(be,{src:`/providers/${a}.png`,alt:(i==null?void 0:i.name)||a,size:24,className:"object-contain rounded shrink-0",fallbackText:(i==null?void 0:i.textIcon)||a.slice(0,2).toUpperCase(),fallbackColor:i==null?void 0:i.color}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"text-sm font-medium truncate",children:(i==null?void 0:i.name)||a}),n&&e.jsx("code",{className:"text-[10px] text-text-muted font-mono truncate block",children:n})]}),e.jsxs("div",{className:"flex items-center gap-0.5",children:[e.jsx("button",{onClick:()=>J(s,-1),disabled:s===0,className:`p-1 rounded ${s===0?"text-text-muted/20":"text-text-muted hover:text-primary hover:bg-black/5"}`,title:"Move up",children:e.jsx("span",{className:"material-symbols-outlined text-[16px]",children:"arrow_upward"})}),e.jsx("button",{onClick:()=>J(s,1),disabled:s===m.length-1,className:`p-1 rounded ${s===m.length-1?"text-text-muted/20":"text-text-muted hover:text-primary hover:bg-black/5"}`,title:"Move down",children:e.jsx("span",{className:"material-symbols-outlined text-[16px]",children:"arrow_downward"})}),e.jsx("button",{onClick:()=>ie(s),className:"p-1 rounded text-text-muted hover:text-red-500 hover:bg-red-500/10",title:"Remove",children:e.jsx("span",{className:"material-symbols-outlined text-[16px]",children:"close"})})]})]},`${t}-${s}`)})})]}),r.kind&&T&&e.jsxs(S,{children:[e.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between mb-3",children:[e.jsx("h2",{className:"text-lg font-semibold",children:"Test Example"}),e.jsx(A,{size:"sm",icon:"play_arrow",onClick:me,disabled:D||m.length===0,children:D?"Running...":"Run"})]}),e.jsx("pre",{className:"text-xs font-mono bg-black/[0.03] dark:bg-white/[0.03] p-3 rounded-lg overflow-x-auto whitespace-pre-wrap break-all",children:he}),z&&e.jsx("p",{className:"mt-3 text-xs text-red-500 break-words",children:z}),l&&e.jsxs("div",{className:"mt-3 flex flex-col gap-3",children:[l.latencyMs!=null&&e.jsxs("span",{className:"text-[11px] text-text-muted",children:["⚡ ",l.latencyMs,"ms"]}),l.imageUrl&&e.jsxs("div",{children:[e.jsx("div",{className:"flex items-center justify-end mb-1.5",children:e.jsxs("a",{href:l.imageUrl,download:"image.png",className:"inline-flex items-center gap-1 text-xs text-text-muted hover:text-primary transition-colors",children:[e.jsx("span",{className:"material-symbols-outlined text-[14px]",children:"download"}),"Download"]})}),e.jsx("img",{src:l.imageUrl,alt:"Generated",className:"max-w-full rounded-lg border border-border"})]}),l.audioUrl&&e.jsxs("div",{children:[e.jsx("div",{className:"flex items-center justify-end mb-1.5",children:e.jsxs("a",{href:l.audioUrl,download:"speech.mp3",className:"inline-flex items-center gap-1 text-xs text-text-muted hover:text-primary transition-colors",children:[e.jsx("span",{className:"material-symbols-outlined text-[14px]",children:"download"}),"Download"]})}),e.jsx("audio",{controls:!0,src:l.audioUrl,className:"w-full"})]}),l.json&&e.jsx("pre",{className:"text-xs font-mono bg-black/[0.03] dark:bg-white/[0.03] p-3 rounded-lg overflow-auto max-h-[300px] whitespace-pre-wrap break-all",children:l.json})]})]}),e.jsxs(S,{children:[e.jsx("h2",{className:"text-lg font-semibold mb-3",children:"Usage Logs"}),M.length===0?e.jsx("p",{className:"text-xs text-text-muted italic",children:"No usage yet."}):e.jsx("pre",{className:"text-[11px] font-mono bg-black/[0.03] dark:bg-white/[0.03] p-3 rounded-lg overflow-auto max-h-[400px] whitespace-pre-wrap",children:M.join(`
5
- `)})]}),e.jsx(ke,{isOpen:Z,onClose:()=>I(!1),onSelect:re,onDeselect:le,activeProviders:te,modelAliases:ae,title:`Add ${W} Model`,kindFilter:r.kind,addedModelValues:m,closeOnSelect:!1})]})}export{Le as default};
@@ -1 +0,0 @@
1
- import{j as a}from"./index.DQDDDpp7.js";import{b as e}from"./router.Cjj1--8t.js";import{g as m}from"./machine.CagOtseJ.js";import{A as c}from"./EndpointPageClient.CGB3HjDe.js";import"./zustand.akaTi5uX.js";import"./NoAuthProxyCard.C18iZ3Fk.js";import"./Loading.DaQG3sHF.js";function h(){const[i,s]=e.useState(null),[n,r]=e.useState(!0);return e.useEffect(()=>{let t=!0;return m().then(o=>{t&&(s(o),r(!1))}).catch(()=>{t&&r(!1)}),()=>{t=!1}},[]),n?a.jsx("div",{className:"text-text-muted text-sm py-12 text-center",children:"Loading..."}):a.jsx(c,{machineId:i})}export{h as default};
@@ -1 +0,0 @@
1
- import{j as e}from"./index.B-zMpSp_.js";import{b as n,f as h}from"./router.Cjj1--8t.js";import"./zustand.akaTi5uX.js";function u(){const[s]=h(),[a,l]=n.useState("processing");return n.useEffect(()=>{const r=s.get("code"),i=s.get("state"),o=s.get("error"),d=s.get("error_description"),c={code:r,state:i,error:o,errorDescription:d,fullUrl:window.location.href},m=[window.location.origin,"http://localhost:1455","http://localhost:51121"];if(window.opener)for(const t of m)try{window.opener.postMessage({type:"oauth_callback",data:c},t)}catch(x){console.log("postMessage failed:",x)}try{const t=new BroadcastChannel("oauth_callback");t.postMessage(c),t.close()}catch(t){console.log("BroadcastChannel failed:",t)}try{localStorage.setItem("oauth_callback",JSON.stringify({...c,timestamp:Date.now()}))}catch(t){console.log("localStorage failed:",t)}if(!(r||o)){setTimeout(()=>l("manual"),0);return}l("success"),setTimeout(()=>{window.close(),setTimeout(()=>l("done"),500)},1500)},[s]),e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-bg",children:e.jsxs("div",{className:"text-center p-8 max-w-md",children:[a==="processing"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-16 h-16 mx-auto mb-4 rounded-full bg-primary/10 flex items-center justify-center",children:e.jsx("span",{className:"material-symbols-outlined text-3xl text-primary animate-spin",children:"progress_activity"})}),e.jsx("h1",{className:"text-xl font-semibold mb-2",children:"Processing..."}),e.jsx("p",{className:"text-text-muted",children:"Please wait while we complete the authorization."})]}),(a==="success"||a==="done")&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-16 h-16 mx-auto mb-4 rounded-full bg-green-100 dark:bg-green-900/30 flex items-center justify-center",children:e.jsx("span",{className:"material-symbols-outlined text-3xl text-green-600",children:"check_circle"})}),e.jsx("h1",{className:"text-xl font-semibold mb-2",children:"Authorization Successful!"}),e.jsx("p",{className:"text-text-muted",children:a==="success"?"This window will close automatically...":"You can close this tab now."})]}),a==="manual"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-16 h-16 mx-auto mb-4 rounded-full bg-yellow-100 dark:bg-yellow-900/30 flex items-center justify-center",children:e.jsx("span",{className:"material-symbols-outlined text-3xl text-yellow-600",children:"info"})}),e.jsx("h1",{className:"text-xl font-semibold mb-2",children:"Copy This URL"}),e.jsx("p",{className:"text-text-muted mb-4",children:"Please copy the URL from the address bar and paste it in the application."}),e.jsx("div",{className:"bg-surface border border-border rounded-lg p-3 text-left",children:e.jsx("code",{className:"text-xs break-all",children:typeof window<"u"?window.location.href:""})})]})]})})}function b(){return e.jsx(n.Suspense,{fallback:e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-bg",children:e.jsxs("div",{className:"text-center p-8",children:[e.jsx("div",{className:"w-16 h-16 mx-auto mb-4 rounded-full bg-primary/10 flex items-center justify-center",children:e.jsx("span",{className:"material-symbols-outlined text-3xl text-primary animate-spin",children:"progress_activity"})}),e.jsx("p",{className:"text-text-muted",children:"Loading..."})]})}),children:e.jsx(u,{})})}export{b as default};