switchboard-router 0.9.31 → 0.9.32

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 (357) hide show
  1. package/app/{.next-cli-build/static/chunks/1321-6882bd1e6e21df5b.js → .next/static/chunks/1321-8a3603dbafbb81bb.js} +1 -1
  2. package/app/.next/static/chunks/979-04a907a12847a634.js +1 -0
  3. package/app/.next/static/chunks/app/(dashboard)/dashboard/combos/page-99d3be5c7da63d57.js +1 -0
  4. package/app/.next/static/chunks/app/(dashboard)/dashboard/combos/routing/{page-ef491ec5a2ccecfb.js → page-650dc0927f999aaf.js} +1 -1
  5. package/app/.next/static/chunks/app/(dashboard)/dashboard/providers/[id]/page-68344fb15a77b2c5.js +10 -0
  6. package/app/.next-cli-build/BUILD_ID +1 -1
  7. package/app/.next-cli-build/app-path-routes-manifest.json +9 -9
  8. package/app/.next-cli-build/build-manifest.json +2 -2
  9. package/app/.next-cli-build/prerender-manifest.json +3 -3
  10. package/app/.next-cli-build/server/app/(dashboard)/dashboard/agent-library/page.js.nft.json +1 -1
  11. package/app/.next-cli-build/server/app/(dashboard)/dashboard/agent-library/page_client-reference-manifest.js +1 -1
  12. package/app/.next-cli-build/server/app/(dashboard)/dashboard/basic-chat/page.js.nft.json +1 -1
  13. package/app/.next-cli-build/server/app/(dashboard)/dashboard/basic-chat/page_client-reference-manifest.js +1 -1
  14. package/app/.next-cli-build/server/app/(dashboard)/dashboard/cli-tools/[toolId]/page.js.nft.json +1 -1
  15. package/app/.next-cli-build/server/app/(dashboard)/dashboard/cli-tools/[toolId]/page_client-reference-manifest.js +1 -1
  16. package/app/.next-cli-build/server/app/(dashboard)/dashboard/cli-tools/page.js.nft.json +1 -1
  17. package/app/.next-cli-build/server/app/(dashboard)/dashboard/cli-tools/page_client-reference-manifest.js +1 -1
  18. package/app/.next-cli-build/server/app/(dashboard)/dashboard/combos/page.js +1 -1
  19. package/app/.next-cli-build/server/app/(dashboard)/dashboard/combos/page.js.nft.json +1 -1
  20. package/app/.next-cli-build/server/app/(dashboard)/dashboard/combos/page_client-reference-manifest.js +1 -1
  21. package/app/.next-cli-build/server/app/(dashboard)/dashboard/combos/routing/page.js +1 -1
  22. package/app/.next-cli-build/server/app/(dashboard)/dashboard/combos/routing/page.js.nft.json +1 -1
  23. package/app/.next-cli-build/server/app/(dashboard)/dashboard/combos/routing/page_client-reference-manifest.js +1 -1
  24. package/app/.next-cli-build/server/app/(dashboard)/dashboard/console-log/page.js.nft.json +1 -1
  25. package/app/.next-cli-build/server/app/(dashboard)/dashboard/console-log/page_client-reference-manifest.js +1 -1
  26. package/app/.next-cli-build/server/app/(dashboard)/dashboard/endpoint/page.js.nft.json +1 -1
  27. package/app/.next-cli-build/server/app/(dashboard)/dashboard/endpoint/page_client-reference-manifest.js +1 -1
  28. package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/[kind]/[id]/page.js.nft.json +1 -1
  29. package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/[kind]/[id]/page_client-reference-manifest.js +1 -1
  30. package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/[kind]/page.js.nft.json +1 -1
  31. package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/[kind]/page_client-reference-manifest.js +1 -1
  32. package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/combo/[id]/page.js.nft.json +1 -1
  33. package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/combo/[id]/page_client-reference-manifest.js +1 -1
  34. package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/page.js.nft.json +1 -1
  35. package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/page_client-reference-manifest.js +1 -1
  36. package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/web/page.js.nft.json +1 -1
  37. package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/web/page_client-reference-manifest.js +1 -1
  38. package/app/.next-cli-build/server/app/(dashboard)/dashboard/mitm/page.js.nft.json +1 -1
  39. package/app/.next-cli-build/server/app/(dashboard)/dashboard/mitm/page_client-reference-manifest.js +1 -1
  40. package/app/.next-cli-build/server/app/(dashboard)/dashboard/page.js.nft.json +1 -1
  41. package/app/.next-cli-build/server/app/(dashboard)/dashboard/page_client-reference-manifest.js +1 -1
  42. package/app/.next-cli-build/server/app/(dashboard)/dashboard/profile/page.js.nft.json +1 -1
  43. package/app/.next-cli-build/server/app/(dashboard)/dashboard/profile/page_client-reference-manifest.js +1 -1
  44. package/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/[id]/page.js +2 -2
  45. package/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/[id]/page.js.nft.json +1 -1
  46. package/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/[id]/page_client-reference-manifest.js +1 -1
  47. package/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/new/page.js.nft.json +1 -1
  48. package/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/new/page_client-reference-manifest.js +1 -1
  49. package/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/page.js.nft.json +1 -1
  50. package/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/page_client-reference-manifest.js +1 -1
  51. package/app/.next-cli-build/server/app/(dashboard)/dashboard/pxpipe/page.js.nft.json +1 -1
  52. package/app/.next-cli-build/server/app/(dashboard)/dashboard/pxpipe/page_client-reference-manifest.js +1 -1
  53. package/app/.next-cli-build/server/app/(dashboard)/dashboard/quota/page.js.nft.json +1 -1
  54. package/app/.next-cli-build/server/app/(dashboard)/dashboard/quota/page_client-reference-manifest.js +1 -1
  55. package/app/.next-cli-build/server/app/(dashboard)/dashboard/skills/[id]/page.js.nft.json +1 -1
  56. package/app/.next-cli-build/server/app/(dashboard)/dashboard/skills/[id]/page_client-reference-manifest.js +1 -1
  57. package/app/.next-cli-build/server/app/(dashboard)/dashboard/skills/page.js.nft.json +1 -1
  58. package/app/.next-cli-build/server/app/(dashboard)/dashboard/skills/page_client-reference-manifest.js +1 -1
  59. package/app/.next-cli-build/server/app/(dashboard)/dashboard/token-saver/page.js.nft.json +1 -1
  60. package/app/.next-cli-build/server/app/(dashboard)/dashboard/token-saver/page_client-reference-manifest.js +1 -1
  61. package/app/.next-cli-build/server/app/(dashboard)/dashboard/translator/page.js.nft.json +1 -1
  62. package/app/.next-cli-build/server/app/(dashboard)/dashboard/translator/page_client-reference-manifest.js +1 -1
  63. package/app/.next-cli-build/server/app/(dashboard)/dashboard/usage/page.js.nft.json +1 -1
  64. package/app/.next-cli-build/server/app/(dashboard)/dashboard/usage/page_client-reference-manifest.js +1 -1
  65. package/app/.next-cli-build/server/app/_global-error/page.js.nft.json +1 -1
  66. package/app/.next-cli-build/server/app/_global-error/page_client-reference-manifest.js +1 -1
  67. package/app/.next-cli-build/server/app/_global-error.html +1 -1
  68. package/app/.next-cli-build/server/app/_global-error.rsc +1 -1
  69. package/app/.next-cli-build/server/app/_global-error.segments/_full.segment.rsc +1 -1
  70. package/app/.next-cli-build/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
  71. package/app/.next-cli-build/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  72. package/app/.next-cli-build/server/app/_not-found/page.js.nft.json +1 -1
  73. package/app/.next-cli-build/server/app/_not-found/page_client-reference-manifest.js +1 -1
  74. package/app/.next-cli-build/server/app/_not-found.html +1 -1
  75. package/app/.next-cli-build/server/app/_not-found.rsc +3 -3
  76. package/app/.next-cli-build/server/app/_not-found.segments/_full.segment.rsc +3 -3
  77. package/app/.next-cli-build/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +3 -3
  78. package/app/.next-cli-build/server/app/_not-found.segments/_tree.segment.rsc +1 -1
  79. package/app/.next-cli-build/server/app/api/agent-library/catalog/route.js.nft.json +1 -1
  80. package/app/.next-cli-build/server/app/api/agent-library/doctor/route.js.nft.json +1 -1
  81. package/app/.next-cli-build/server/app/api/agent-library/export/route.js.nft.json +1 -1
  82. package/app/.next-cli-build/server/app/api/agent-library/mcp/route.js.nft.json +1 -1
  83. package/app/.next-cli-build/server/app/api/agent-library/route.js.nft.json +1 -1
  84. package/app/.next-cli-build/server/app/api/agent-library/skills/route.js.nft.json +1 -1
  85. package/app/.next-cli-build/server/app/api/agent-library/sync/route.js.nft.json +1 -1
  86. package/app/.next-cli-build/server/app/api/agent-library/updates/route.js.nft.json +1 -1
  87. package/app/.next-cli-build/server/app/api/auth/login/route.js.nft.json +1 -1
  88. package/app/.next-cli-build/server/app/api/auth/logout/route.js.nft.json +1 -1
  89. package/app/.next-cli-build/server/app/api/auth/status/route.js.nft.json +1 -1
  90. package/app/.next-cli-build/server/app/api/cli-tools/aider-settings/route.js +1 -1
  91. package/app/.next-cli-build/server/app/api/cli-tools/aider-settings/route.js.nft.json +1 -1
  92. package/app/.next-cli-build/server/app/api/cli-tools/all-statuses/route.js +5 -5
  93. package/app/.next-cli-build/server/app/api/cli-tools/all-statuses/route.js.nft.json +1 -1
  94. package/app/.next-cli-build/server/app/api/cli-tools/antigravity-mitm/alias/route.js +1 -1
  95. package/app/.next-cli-build/server/app/api/cli-tools/antigravity-mitm/alias/route.js.nft.json +1 -1
  96. package/app/.next-cli-build/server/app/api/cli-tools/antigravity-mitm/route.js.nft.json +1 -1
  97. package/app/.next-cli-build/server/app/api/cli-tools/claude-full-catalog/route.js.nft.json +1 -1
  98. package/app/.next-cli-build/server/app/api/cli-tools/claude-picker-labels/route.js.nft.json +1 -1
  99. package/app/.next-cli-build/server/app/api/cli-tools/claude-settings/route.js.nft.json +1 -1
  100. package/app/.next-cli-build/server/app/api/cli-tools/cline-settings/route.js +1 -1
  101. package/app/.next-cli-build/server/app/api/cli-tools/cline-settings/route.js.nft.json +1 -1
  102. package/app/.next-cli-build/server/app/api/cli-tools/codex-settings/route.js +1 -1
  103. package/app/.next-cli-build/server/app/api/cli-tools/codex-settings/route.js.nft.json +1 -1
  104. package/app/.next-cli-build/server/app/api/cli-tools/cowork-mcp-registry/route.js +1 -1
  105. package/app/.next-cli-build/server/app/api/cli-tools/cowork-mcp-registry/route.js.nft.json +1 -1
  106. package/app/.next-cli-build/server/app/api/cli-tools/cowork-mcp-tools/route.js +1 -1
  107. package/app/.next-cli-build/server/app/api/cli-tools/cowork-mcp-tools/route.js.nft.json +1 -1
  108. package/app/.next-cli-build/server/app/api/cli-tools/cowork-settings/route.js +1 -1
  109. package/app/.next-cli-build/server/app/api/cli-tools/cowork-settings/route.js.nft.json +1 -1
  110. package/app/.next-cli-build/server/app/api/cli-tools/deepseek-tui-settings/route.js +1 -1
  111. package/app/.next-cli-build/server/app/api/cli-tools/deepseek-tui-settings/route.js.nft.json +1 -1
  112. package/app/.next-cli-build/server/app/api/cli-tools/droid-settings/route.js +2 -2
  113. package/app/.next-cli-build/server/app/api/cli-tools/droid-settings/route.js.nft.json +1 -1
  114. package/app/.next-cli-build/server/app/api/cli-tools/gemini-cli-settings/route.js +2 -2
  115. package/app/.next-cli-build/server/app/api/cli-tools/gemini-cli-settings/route.js.nft.json +1 -1
  116. package/app/.next-cli-build/server/app/api/cli-tools/grok-settings/route.js +2 -2
  117. package/app/.next-cli-build/server/app/api/cli-tools/grok-settings/route.js.nft.json +1 -1
  118. package/app/.next-cli-build/server/app/api/cli-tools/hermes-settings/route.js +3 -3
  119. package/app/.next-cli-build/server/app/api/cli-tools/hermes-settings/route.js.nft.json +1 -1
  120. package/app/.next-cli-build/server/app/api/cli-tools/jcode-settings/route.js +2 -2
  121. package/app/.next-cli-build/server/app/api/cli-tools/jcode-settings/route.js.nft.json +1 -1
  122. package/app/.next-cli-build/server/app/api/cli-tools/kilo-settings/route.js +2 -2
  123. package/app/.next-cli-build/server/app/api/cli-tools/kilo-settings/route.js.nft.json +1 -1
  124. package/app/.next-cli-build/server/app/api/cli-tools/openclaw-settings/route.js +2 -2
  125. package/app/.next-cli-build/server/app/api/cli-tools/openclaw-settings/route.js.nft.json +1 -1
  126. package/app/.next-cli-build/server/app/api/cli-tools/opencode-settings/route.js +1 -1
  127. package/app/.next-cli-build/server/app/api/cli-tools/opencode-settings/route.js.nft.json +1 -1
  128. package/app/.next-cli-build/server/app/api/cli-tools/pi-settings/route.js +1 -1
  129. package/app/.next-cli-build/server/app/api/cli-tools/pi-settings/route.js.nft.json +1 -1
  130. package/app/.next-cli-build/server/app/api/cli-tools/picker-labels/route.js.nft.json +1 -1
  131. package/app/.next-cli-build/server/app/api/combos/[id]/route.js +1 -1
  132. package/app/.next-cli-build/server/app/api/combos/[id]/route.js.nft.json +1 -1
  133. package/app/.next-cli-build/server/app/api/combos/route.js +1 -1
  134. package/app/.next-cli-build/server/app/api/combos/route.js.nft.json +1 -1
  135. package/app/.next-cli-build/server/app/api/headroom/extras/route.js.nft.json +1 -1
  136. package/app/.next-cli-build/server/app/api/headroom/proxy/[...path]/route.js.nft.json +1 -1
  137. package/app/.next-cli-build/server/app/api/headroom/restart/route.js.nft.json +1 -1
  138. package/app/.next-cli-build/server/app/api/headroom/start/route.js.nft.json +1 -1
  139. package/app/.next-cli-build/server/app/api/headroom/status/route.js.nft.json +1 -1
  140. package/app/.next-cli-build/server/app/api/headroom/stop/route.js.nft.json +1 -1
  141. package/app/.next-cli-build/server/app/api/health/route.js.nft.json +1 -1
  142. package/app/.next-cli-build/server/app/api/keys/[id]/route.js.nft.json +1 -1
  143. package/app/.next-cli-build/server/app/api/keys/route.js.nft.json +1 -1
  144. package/app/.next-cli-build/server/app/api/locale/route.js.nft.json +1 -1
  145. package/app/.next-cli-build/server/app/api/mcp/[plugin]/message/route.js.nft.json +1 -1
  146. package/app/.next-cli-build/server/app/api/mcp/[plugin]/sse/route.js.nft.json +1 -1
  147. package/app/.next-cli-build/server/app/api/media-providers/tts/deepgram/voices/route.js.nft.json +1 -1
  148. package/app/.next-cli-build/server/app/api/media-providers/tts/elevenlabs/voices/route.js.nft.json +1 -1
  149. package/app/.next-cli-build/server/app/api/media-providers/tts/inworld/voices/route.js.nft.json +1 -1
  150. package/app/.next-cli-build/server/app/api/media-providers/tts/minimax/voices/route.js.nft.json +1 -1
  151. package/app/.next-cli-build/server/app/api/media-providers/tts/voices/route.js.nft.json +1 -1
  152. package/app/.next-cli-build/server/app/api/mgmt/v1/combos/[id]/route.js +1 -1
  153. package/app/.next-cli-build/server/app/api/mgmt/v1/combos/[id]/route.js.nft.json +1 -1
  154. package/app/.next-cli-build/server/app/api/mgmt/v1/combos/[id]/strategy/route.js +1 -1
  155. package/app/.next-cli-build/server/app/api/mgmt/v1/combos/[id]/strategy/route.js.nft.json +1 -1
  156. package/app/.next-cli-build/server/app/api/mgmt/v1/combos/route.js +1 -1
  157. package/app/.next-cli-build/server/app/api/mgmt/v1/combos/route.js.nft.json +1 -1
  158. package/app/.next-cli-build/server/app/api/mgmt/v1/health/route.js.nft.json +1 -1
  159. package/app/.next-cli-build/server/app/api/mgmt/v1/metrics/route.js.nft.json +1 -1
  160. package/app/.next-cli-build/server/app/api/mgmt/v1/providers/route.js.nft.json +1 -1
  161. package/app/.next-cli-build/server/app/api/mgmt/v1/routing/route.js.nft.json +1 -1
  162. package/app/.next-cli-build/server/app/api/mgmt/v1/usage/route.js.nft.json +1 -1
  163. package/app/.next-cli-build/server/app/api/mgmt/v1/version/route.js.nft.json +1 -1
  164. package/app/.next-cli-build/server/app/api/models/alias/route.js.nft.json +1 -1
  165. package/app/.next-cli-build/server/app/api/models/availability/route.js.nft.json +1 -1
  166. package/app/.next-cli-build/server/app/api/models/custom/route.js.nft.json +1 -1
  167. package/app/.next-cli-build/server/app/api/models/disabled/route.js.nft.json +1 -1
  168. package/app/.next-cli-build/server/app/api/models/route.js.nft.json +1 -1
  169. package/app/.next-cli-build/server/app/api/models/test/route.js.nft.json +1 -1
  170. package/app/.next-cli-build/server/app/api/oauth/[provider]/[action]/route.js.nft.json +1 -1
  171. package/app/.next-cli-build/server/app/api/oauth/codex/bulk-import/route.js.nft.json +1 -1
  172. package/app/.next-cli-build/server/app/api/oauth/codex/import-token/route.js.nft.json +1 -1
  173. package/app/.next-cli-build/server/app/api/oauth/cursor/auto-import/route.js.nft.json +1 -1
  174. package/app/.next-cli-build/server/app/api/oauth/cursor/import/route.js.nft.json +1 -1
  175. package/app/.next-cli-build/server/app/api/oauth/gitlab/pat/route.js.nft.json +1 -1
  176. package/app/.next-cli-build/server/app/api/oauth/iflow/cookie/route.js.nft.json +1 -1
  177. package/app/.next-cli-build/server/app/api/oauth/kiro/api-key/route.js.nft.json +1 -1
  178. package/app/.next-cli-build/server/app/api/oauth/kiro/auto-import/route.js.nft.json +1 -1
  179. package/app/.next-cli-build/server/app/api/oauth/kiro/import/route.js.nft.json +1 -1
  180. package/app/.next-cli-build/server/app/api/oauth/kiro/import-cli-proxy/route.js.nft.json +1 -1
  181. package/app/.next-cli-build/server/app/api/oauth/kiro/social-authorize/route.js.nft.json +1 -1
  182. package/app/.next-cli-build/server/app/api/oauth/kiro/social-exchange/route.js.nft.json +1 -1
  183. package/app/.next-cli-build/server/app/api/pricing/defaults/route.js.nft.json +1 -1
  184. package/app/.next-cli-build/server/app/api/pricing/route.js.nft.json +1 -1
  185. package/app/.next-cli-build/server/app/api/provider-nodes/[id]/route.js.nft.json +1 -1
  186. package/app/.next-cli-build/server/app/api/provider-nodes/route.js.nft.json +1 -1
  187. package/app/.next-cli-build/server/app/api/provider-nodes/validate/route.js.nft.json +1 -1
  188. package/app/.next-cli-build/server/app/api/providers/[id]/model-probes/batch/route.js.nft.json +1 -1
  189. package/app/.next-cli-build/server/app/api/providers/[id]/model-probes/cache/route.js.nft.json +1 -1
  190. package/app/.next-cli-build/server/app/api/providers/[id]/model-probes/prepare/route.js.nft.json +1 -1
  191. package/app/.next-cli-build/server/app/api/providers/[id]/model-probes/remove-unavailable/route.js.nft.json +1 -1
  192. package/app/.next-cli-build/server/app/api/providers/[id]/model-probes/route.js.nft.json +1 -1
  193. package/app/.next-cli-build/server/app/api/providers/[id]/model-probes/verify/cancel/route.js.nft.json +1 -1
  194. package/app/.next-cli-build/server/app/api/providers/[id]/model-probes/verify/start/route.js.nft.json +1 -1
  195. package/app/.next-cli-build/server/app/api/providers/[id]/model-probes/verify/status/route.js.nft.json +1 -1
  196. package/app/.next-cli-build/server/app/api/providers/[id]/models/route.js.nft.json +1 -1
  197. package/app/.next-cli-build/server/app/api/providers/[id]/route.js.nft.json +1 -1
  198. package/app/.next-cli-build/server/app/api/providers/[id]/test/route.js.nft.json +1 -1
  199. package/app/.next-cli-build/server/app/api/providers/[id]/test-models/route.js.nft.json +1 -1
  200. package/app/.next-cli-build/server/app/api/providers/client/route.js.nft.json +1 -1
  201. package/app/.next-cli-build/server/app/api/providers/kilo/free-models/route.js.nft.json +1 -1
  202. package/app/.next-cli-build/server/app/api/providers/route.js.nft.json +1 -1
  203. package/app/.next-cli-build/server/app/api/providers/suggested-models/route.js.nft.json +1 -1
  204. package/app/.next-cli-build/server/app/api/providers/test-batch/route.js.nft.json +1 -1
  205. package/app/.next-cli-build/server/app/api/providers/validate/route.js.nft.json +1 -1
  206. package/app/.next-cli-build/server/app/api/pxpipe/health/route.js.nft.json +1 -1
  207. package/app/.next-cli-build/server/app/api/pxpipe/install/route.js.nft.json +1 -1
  208. package/app/.next-cli-build/server/app/api/pxpipe/logs/route.js.nft.json +1 -1
  209. package/app/.next-cli-build/server/app/api/pxpipe/restart/route.js.nft.json +1 -1
  210. package/app/.next-cli-build/server/app/api/pxpipe/start/route.js.nft.json +1 -1
  211. package/app/.next-cli-build/server/app/api/pxpipe/stats/route.js.nft.json +1 -1
  212. package/app/.next-cli-build/server/app/api/pxpipe/status/route.js.nft.json +1 -1
  213. package/app/.next-cli-build/server/app/api/pxpipe/stop/route.js.nft.json +1 -1
  214. package/app/.next-cli-build/server/app/api/routing/feedback/route.js.nft.json +1 -1
  215. package/app/.next-cli-build/server/app/api/routing/insights/route.js.nft.json +1 -1
  216. package/app/.next-cli-build/server/app/api/routing/learn/route.js.nft.json +1 -1
  217. package/app/.next-cli-build/server/app/api/routing/stats/route.js.nft.json +1 -1
  218. package/app/.next-cli-build/server/app/api/routing/versions/promote/route.js.nft.json +1 -1
  219. package/app/.next-cli-build/server/app/api/routing/versions/rollback/route.js.nft.json +1 -1
  220. package/app/.next-cli-build/server/app/api/settings/database/route.js.nft.json +1 -1
  221. package/app/.next-cli-build/server/app/api/settings/proxy-test/route.js.nft.json +1 -1
  222. package/app/.next-cli-build/server/app/api/settings/route.js +1 -1
  223. package/app/.next-cli-build/server/app/api/settings/route.js.nft.json +1 -1
  224. package/app/.next-cli-build/server/app/api/shutdown/route.js.nft.json +1 -1
  225. package/app/.next-cli-build/server/app/api/skills/[id]/route.js.nft.json +1 -1
  226. package/app/.next-cli-build/server/app/api/tags/route.js.nft.json +1 -1
  227. package/app/.next-cli-build/server/app/api/token-saver/vault-stats/route.js.nft.json +1 -1
  228. package/app/.next-cli-build/server/app/api/translator/console-logs/route.js.nft.json +1 -1
  229. package/app/.next-cli-build/server/app/api/translator/console-logs/stream/route.js.nft.json +1 -1
  230. package/app/.next-cli-build/server/app/api/translator/load/route.js.nft.json +1 -1
  231. package/app/.next-cli-build/server/app/api/translator/save/route.js.nft.json +1 -1
  232. package/app/.next-cli-build/server/app/api/translator/send/route.js.nft.json +1 -1
  233. package/app/.next-cli-build/server/app/api/translator/translate/route.js.nft.json +1 -1
  234. package/app/.next-cli-build/server/app/api/usage/[connectionId]/codex-reset-credits/route.js.nft.json +1 -1
  235. package/app/.next-cli-build/server/app/api/usage/[connectionId]/route.js.nft.json +1 -1
  236. package/app/.next-cli-build/server/app/api/usage/chart/route.js.nft.json +1 -1
  237. package/app/.next-cli-build/server/app/api/usage/history/route.js.nft.json +1 -1
  238. package/app/.next-cli-build/server/app/api/usage/logs/route.js.nft.json +1 -1
  239. package/app/.next-cli-build/server/app/api/usage/providers/route.js.nft.json +1 -1
  240. package/app/.next-cli-build/server/app/api/usage/request-details/[id]/route.js.nft.json +1 -1
  241. package/app/.next-cli-build/server/app/api/usage/request-details/route.js.nft.json +1 -1
  242. package/app/.next-cli-build/server/app/api/usage/request-logs/route.js.nft.json +1 -1
  243. package/app/.next-cli-build/server/app/api/usage/stats/route.js.nft.json +1 -1
  244. package/app/.next-cli-build/server/app/api/usage/stream/route.js.nft.json +1 -1
  245. package/app/.next-cli-build/server/app/api/v1/api/chat/route.js +1 -1
  246. package/app/.next-cli-build/server/app/api/v1/api/chat/route.js.nft.json +1 -1
  247. package/app/.next-cli-build/server/app/api/v1/audio/speech/route.js +1 -1
  248. package/app/.next-cli-build/server/app/api/v1/audio/speech/route.js.nft.json +1 -1
  249. package/app/.next-cli-build/server/app/api/v1/audio/transcriptions/route.js.nft.json +1 -1
  250. package/app/.next-cli-build/server/app/api/v1/audio/voices/route.js.nft.json +1 -1
  251. package/app/.next-cli-build/server/app/api/v1/chat/completions/route.js +1 -1
  252. package/app/.next-cli-build/server/app/api/v1/chat/completions/route.js.nft.json +1 -1
  253. package/app/.next-cli-build/server/app/api/v1/embeddings/route.js.nft.json +1 -1
  254. package/app/.next-cli-build/server/app/api/v1/images/generations/route.js +2 -2
  255. package/app/.next-cli-build/server/app/api/v1/images/generations/route.js.nft.json +1 -1
  256. package/app/.next-cli-build/server/app/api/v1/messages/count_tokens/route.js.nft.json +1 -1
  257. package/app/.next-cli-build/server/app/api/v1/messages/route.js +1 -1
  258. package/app/.next-cli-build/server/app/api/v1/messages/route.js.nft.json +1 -1
  259. package/app/.next-cli-build/server/app/api/v1/models/[kind]/route.js.nft.json +1 -1
  260. package/app/.next-cli-build/server/app/api/v1/models/info/route.js +1 -1
  261. package/app/.next-cli-build/server/app/api/v1/models/info/route.js.nft.json +1 -1
  262. package/app/.next-cli-build/server/app/api/v1/models/route.js.nft.json +1 -1
  263. package/app/.next-cli-build/server/app/api/v1/responses/compact/route.js +1 -1
  264. package/app/.next-cli-build/server/app/api/v1/responses/compact/route.js.nft.json +1 -1
  265. package/app/.next-cli-build/server/app/api/v1/responses/route.js +1 -1
  266. package/app/.next-cli-build/server/app/api/v1/responses/route.js.nft.json +1 -1
  267. package/app/.next-cli-build/server/app/api/v1/route.js.nft.json +1 -1
  268. package/app/.next-cli-build/server/app/api/v1/search/route.js +1 -1
  269. package/app/.next-cli-build/server/app/api/v1/search/route.js.nft.json +1 -1
  270. package/app/.next-cli-build/server/app/api/v1/videos/[id]/route.js.nft.json +1 -1
  271. package/app/.next-cli-build/server/app/api/v1/videos/edits/route.js.nft.json +1 -1
  272. package/app/.next-cli-build/server/app/api/v1/videos/extensions/route.js.nft.json +1 -1
  273. package/app/.next-cli-build/server/app/api/v1/videos/generations/route.js.nft.json +1 -1
  274. package/app/.next-cli-build/server/app/api/v1/web/fetch/route.js +1 -1
  275. package/app/.next-cli-build/server/app/api/v1/web/fetch/route.js.nft.json +1 -1
  276. package/app/.next-cli-build/server/app/api/v1beta/models/[...path]/route.js +1 -1
  277. package/app/.next-cli-build/server/app/api/v1beta/models/[...path]/route.js.nft.json +1 -1
  278. package/app/.next-cli-build/server/app/api/v1beta/models/route.js.nft.json +1 -1
  279. package/app/.next-cli-build/server/app/api/version/route.js +1 -1
  280. package/app/.next-cli-build/server/app/api/version/route.js.nft.json +1 -1
  281. package/app/.next-cli-build/server/app/api/version/shutdown/route.js.nft.json +1 -1
  282. package/app/.next-cli-build/server/app/api/version/update/route.js.nft.json +1 -1
  283. package/app/.next-cli-build/server/app/callback/page.js.nft.json +1 -1
  284. package/app/.next-cli-build/server/app/callback/page_client-reference-manifest.js +1 -1
  285. package/app/.next-cli-build/server/app/callback.html +1 -1
  286. package/app/.next-cli-build/server/app/callback.rsc +3 -3
  287. package/app/.next-cli-build/server/app/callback.segments/_full.segment.rsc +3 -3
  288. package/app/.next-cli-build/server/app/callback.segments/_tree.segment.rsc +1 -1
  289. package/app/.next-cli-build/server/app/callback.segments/callback/__PAGE__.segment.rsc +3 -3
  290. package/app/.next-cli-build/server/app/dashboard/settings/pricing/page.js.nft.json +1 -1
  291. package/app/.next-cli-build/server/app/dashboard/settings/pricing/page_client-reference-manifest.js +1 -1
  292. package/app/.next-cli-build/server/app/dashboard/settings/pricing.html +1 -1
  293. package/app/.next-cli-build/server/app/dashboard/settings/pricing.rsc +3 -3
  294. package/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/_full.segment.rsc +3 -3
  295. package/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/_tree.segment.rsc +1 -1
  296. package/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/dashboard/settings/pricing/__PAGE__.segment.rsc +3 -3
  297. package/app/.next-cli-build/server/app/favicon.ico/route.js.nft.json +1 -1
  298. package/app/.next-cli-build/server/app/index.html +1 -1
  299. package/app/.next-cli-build/server/app/index.rsc +3 -3
  300. package/app/.next-cli-build/server/app/index.segments/__PAGE__.segment.rsc +3 -3
  301. package/app/.next-cli-build/server/app/index.segments/_full.segment.rsc +3 -3
  302. package/app/.next-cli-build/server/app/index.segments/_tree.segment.rsc +1 -1
  303. package/app/.next-cli-build/server/app/landing/page.js.nft.json +1 -1
  304. package/app/.next-cli-build/server/app/landing/page_client-reference-manifest.js +1 -1
  305. package/app/.next-cli-build/server/app/landing.html +1 -1
  306. package/app/.next-cli-build/server/app/landing.rsc +3 -3
  307. package/app/.next-cli-build/server/app/landing.segments/_full.segment.rsc +3 -3
  308. package/app/.next-cli-build/server/app/landing.segments/_tree.segment.rsc +1 -1
  309. package/app/.next-cli-build/server/app/landing.segments/landing/__PAGE__.segment.rsc +3 -3
  310. package/app/.next-cli-build/server/app/login/page.js.nft.json +1 -1
  311. package/app/.next-cli-build/server/app/login/page_client-reference-manifest.js +1 -1
  312. package/app/.next-cli-build/server/app/login.html +1 -1
  313. package/app/.next-cli-build/server/app/login.rsc +4 -4
  314. package/app/.next-cli-build/server/app/login.segments/_full.segment.rsc +4 -4
  315. package/app/.next-cli-build/server/app/login.segments/_tree.segment.rsc +1 -1
  316. package/app/.next-cli-build/server/app/login.segments/login/__PAGE__.segment.rsc +4 -4
  317. package/app/.next-cli-build/server/app/manifest.webmanifest/route.js.nft.json +1 -1
  318. package/app/.next-cli-build/server/app/page.js.nft.json +1 -1
  319. package/app/.next-cli-build/server/app/page_client-reference-manifest.js +1 -1
  320. package/app/.next-cli-build/server/app-paths-manifest.json +9 -9
  321. package/app/.next-cli-build/server/chunks/3423.js +1 -1
  322. package/app/.next-cli-build/server/chunks/403.js +1 -1
  323. package/app/.next-cli-build/server/chunks/519.js +1 -1
  324. package/app/.next-cli-build/server/chunks/5624.js +1 -0
  325. package/app/.next-cli-build/server/chunks/5717.js +2 -2
  326. package/app/.next-cli-build/server/chunks/7454.js +1 -1
  327. package/app/.next-cli-build/server/chunks/845.js +1 -0
  328. package/app/.next-cli-build/server/chunks/869.js +1 -1
  329. package/app/.next-cli-build/server/chunks/8998.js +1 -1
  330. package/app/.next-cli-build/server/chunks/9264.js +2 -2
  331. package/app/.next-cli-build/server/middleware-build-manifest.js +1 -1
  332. package/app/.next-cli-build/server/middleware.js +1 -1
  333. package/app/.next-cli-build/server/pages/404.html +1 -1
  334. package/app/.next-cli-build/server/pages/500.html +1 -1
  335. package/app/.next-cli-build/server/server-reference-manifest.js +1 -1
  336. package/app/.next-cli-build/server/server-reference-manifest.json +1 -1
  337. package/app/{.next/static/chunks/1321-6882bd1e6e21df5b.js → .next-cli-build/static/chunks/1321-8a3603dbafbb81bb.js} +1 -1
  338. package/app/.next-cli-build/static/chunks/979-04a907a12847a634.js +1 -0
  339. package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/combos/page-99d3be5c7da63d57.js +1 -0
  340. package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/combos/routing/{page-ef491ec5a2ccecfb.js → page-650dc0927f999aaf.js} +1 -1
  341. package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/providers/[id]/page-68344fb15a77b2c5.js +10 -0
  342. package/app/open-sse/identity/tls/bin/darwin/arm64/switchboard-claude-tls +0 -0
  343. package/app/open-sse/identity/tls/bin/darwin/x64/switchboard-claude-tls +0 -0
  344. package/app/open-sse/identity/tls/bin/linux/arm64/switchboard-claude-tls +0 -0
  345. package/app/open-sse/identity/tls/bin/linux/x64/switchboard-claude-tls +0 -0
  346. package/app/open-sse/identity/tls/bin/win32/arm64/switchboard-claude-tls.exe +0 -0
  347. package/app/open-sse/identity/tls/bin/win32/x64/switchboard-claude-tls.exe +0 -0
  348. package/app/package.json +3 -3
  349. package/package.json +3 -3
  350. package/app/.next/static/chunks/app/(dashboard)/dashboard/combos/page-aaae06cada500532.js +0 -1
  351. package/app/.next/static/chunks/app/(dashboard)/dashboard/providers/[id]/page-cb9292ca42b61d7d.js +0 -10
  352. package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/combos/page-aaae06cada500532.js +0 -1
  353. package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/providers/[id]/page-cb9292ca42b61d7d.js +0 -10
  354. /package/app/.next/static/{XtGHu6Ssc2Uu-DQPIVvn0 → e7Ha89rDlp2qPIlpARdsI}/_buildManifest.js +0 -0
  355. /package/app/.next/static/{XtGHu6Ssc2Uu-DQPIVvn0 → e7Ha89rDlp2qPIlpARdsI}/_ssgManifest.js +0 -0
  356. /package/app/.next-cli-build/static/{XtGHu6Ssc2Uu-DQPIVvn0 → e7Ha89rDlp2qPIlpARdsI}/_buildManifest.js +0 -0
  357. /package/app/.next-cli-build/static/{XtGHu6Ssc2Uu-DQPIVvn0 → e7Ha89rDlp2qPIlpARdsI}/_ssgManifest.js +0 -0
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "switchboard-router",
3
- "version": "0.9.31",
4
- "description": "Switchboard CLI \u2014 local AI routing gateway (install: npm i -g switchboard-router; run: switchboard)",
3
+ "version": "0.9.32",
4
+ "description": "Switchboard CLI — local AI routing gateway (install: npm i -g switchboard-router; run: switchboard)",
5
5
  "bin": {
6
6
  "switchboard": "./cli.js",
7
7
  "claude-switchboard": "./claude-switchboard.js"
@@ -37,7 +37,7 @@
37
37
  "react": "^19.2.7",
38
38
  "react-dom": "^19.2.7"
39
39
  },
40
- "comment_sqlite": "sql.js + better-sqlite3 are NOT bundled here. They are installed into ~/.switchboard/runtime/node_modules at runtime by cli.js (hooks/sqliteRuntime, self-healing on every start \u2014 the package deliberately ships NO postinstall so npm's allow-scripts guard never fires). This avoids Windows EBUSY errors when updating the global CLI, since native .node files no longer live under the locked install dir.",
40
+ "comment_sqlite": "sql.js + better-sqlite3 are NOT bundled here. They are installed into ~/.switchboard/runtime/node_modules at runtime by cli.js (hooks/sqliteRuntime, self-healing on every start — the package deliberately ships NO postinstall so npm's allow-scripts guard never fires). This avoids Windows EBUSY errors when updating the global CLI, since native .node files no longer live under the locked install dir.",
41
41
  "comment_systray": "System tray uses platform-specific optionalDependencies (esbuild pattern). npm installs only the matching binary for the user's OS/arch. Windows uses PowerShell NotifyIcon (zero binary). Runtime fallback (cli.js ensureTrayRuntime) downloads from GitHub releases if optionalDeps are skipped.",
42
42
  "optionalDependencies": {
43
43
  "impit-darwin-arm64": "0.14.3",
@@ -1 +0,0 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[3649],{35497:(e,t,a)=>{"use strict";a.d(t,{x0:()=>k.default,Ex:()=>d.default,$n:()=>l.default,nh:()=>M.default,Zp:()=>o.default,Qv:()=>n.CardSkeleton,CK:()=>p.default,uo:()=>i.ConfirmModal,G9:()=>j.default,wI:()=>N.default,vj:()=>v.default,vE:()=>y.default,pd:()=>s.default,Mh:()=>g.default,uR:()=>u.default,Nf:()=>h.default,aF:()=>i.default,rq:()=>x.default,gw:()=>w.default,LF:()=>m.default,Wx:()=>A.default,gM:()=>f.default,Iz:()=>C.default,l6:()=>r.default,lM:()=>c.default,m_:()=>S.default,jK:()=>b.default});var l=a(92542),s=a(11910),r=a(98),o=a(84588),i=a(81127),n=a(25086);a(56319);var d=a(56061),c=a(98542);a(61929),a(21110),a(92622),a(8823),a(92173);var m=a(90882),x=a(72908),u=a(28815),p=a(45455),h=a(28058),b=a(4809);a(21931),a(80752),a(40197);var f=a(23615);a(44736);var g=a(62899);a(94230);var j=a(30815),y=a(23936),v=a(95088),N=a(73579),k=a(96748),w=a(4823),C=a(28067),S=a(97677),A=a(51825),M=a(29366);a(76361),a(91450)},41483:(e,t,a)=>{"use strict";a.d(t,{default:()=>j});var l=a(95155),s=a(12115),r=a(44923),o=a(87256),i=a(39768),n=a(5020),d=a(35497),c=a(11059);a(88105);var m=a(65921),x=a(78559),u=a(47224);let p=/^[a-zA-Z0-9_.\-]+$/,h=[{key:"vision",label:"Vision",icon:"visibility",desc:"Images"},{key:"audioInput",label:"Audio",icon:"graphic_eq",desc:"Audio input"}],b={enabled:!0,roundRobin:!1,models:[]},f=Object.keys({vision:{...b},pdf:{...b},audioInput:{...b},videoInput:{...b}});function g(e){return Array.isArray(e)?{enabled:!0,roundRobin:!1,models:e.map(e=>e?.model||e).filter(Boolean)}:e&&"object"==typeof e?{enabled:!1!==e.enabled,roundRobin:!!e.roundRobin,models:Array.isArray(e.models)?e.models.filter(Boolean):[]}:{...b}}function j({initialData:e}){let t=(0,m.i)(e=>e.error),[a,r]=(0,s.useState)(()=>(e?.combos||[]).filter(e=>!e.kind||"llm"===e.kind)),[o,i]=(0,s.useState)(!e),[n,x]=(0,s.useState)(!1),[u,p]=(0,s.useState)(null),[h,b]=(0,s.useState)(e?.connections||[]),[v,N]=(0,s.useState)(e?.settings?.comboStrategies||{}),[k,w]=(0,s.useState)(e?.modelCaps||{}),[C,A]=(0,s.useState)(()=>{let t=e?.settings?.capacityAdapter||{},a={};for(let e of f)a[e]=g(t[e]);return a}),[F,E]=(0,s.useState)(null),{copied:O,copy:$}=(0,c.C)(),q=(0,s.useCallback)(async()=>{try{let[e,t,a,l]=await Promise.all([fetch("/api/combos"),fetch("/api/providers"),fetch("/api/settings"),fetch("/api/models")]);if(![e,t,a,l].every(e=>e.ok))throw Error("One or more combo resources failed to load");let s=await e.json(),o=await t.json(),i=await a.json();if(e.ok&&r((s.combos||[]).filter(e=>!e.kind||"llm"===e.kind)),t.ok&&b(o.connections||[]),l.ok){let e=await l.json(),t={};for(let a of e.models||[])a.caps&&(t[a.fullModel]=a.caps);w(t)}N(i.comboStrategies||{});let n=i.capacityAdapter||{},d={};for(let e of f)d[e]=g(n[e]);A(d)}catch(e){t("Failed to fetch combo data")}finally{i(!1)}},[t]);(0,s.useEffect)(()=>{e?.combos?i(!1):q()},[e,q]);let P=async e=>{try{let{strategy:a,capacityAutoSwitch:l,routerModel:s,objective:r,...o}=e,i=await fetch("/api/combos",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(o)});if(i.ok){let e=await i.json().catch(()=>({})),t=o.name?.trim()||e?.name;t&&(a||void 0!==l||s||r)&&await z(t,y(a,l,s,r)),await q(),x(!1)}else{let e=await i.json();t(e.error||"Failed to create combo")}}catch(e){t("Failed to create combo")}},D=async(e,a)=>{try{let{strategy:l,capacityAutoSwitch:s,routerModel:r,objective:o,...i}=a,n=u?.name,d=await fetch(`/api/combos/${e}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)});if(d.ok){let e=i.name?.trim()||n;if(n&&e&&n!==e&&N(t=>{let a={...t};return n in a&&(e in a||(a[e]=a[n]),delete a[n]),a}),e&&(l||void 0!==s)){let t,a=n&&n!==e?(t={...v},n in t&&(e in t||(t[e]=t[n]),delete t[n]),t):v;await z(e,y(l,s,r,o),a)}await q(),p(null)}else{let e=await d.json();t(e.error||"Failed to update combo")}}catch(e){t("Failed to update combo")}},_=async e=>{let l=a.find(t=>t.id===e);E({title:"Delete Combo",message:l?.name?`Delete combo “${l.name}”?`:"Delete this combo?",onConfirm:async()=>{E(null);try{let a=await fetch(`/api/combos/${e}`,{method:"DELETE"});if(a.ok)r(t=>t.filter(t=>t.id!==e)),l?.name&&N(e=>{if(!(l.name in e))return e;let t={...e};return delete t[l.name],t});else{let e=await a.json().catch(()=>({}));t(e.error||`Failed to delete combo (HTTP ${a.status})`)}}catch(e){t("Failed to delete combo")}}})},z=async(e,a,l=null)=>{try{let s={...l||v},r={...s[e]||{},...a};for(let e of Object.keys(r))(""===r[e]||null===r[e]||void 0===r[e])&&delete r[e];let o=r.fallbackStrategy||"fallback";"fallback"!==o||r.judgeModel||r.routerModel||r.objective||void 0!==r.learningEnabled||void 0!==r.freezeLearning||void 0!==r.explorationRate||!1===r.capacityAutoSwitch?(!r.fallbackStrategy&&void 0===a.fallbackStrategy&&s[e]?.fallbackStrategy&&(r.fallbackStrategy=s[e].fallbackStrategy),s[e]=r):delete s[e];let i=await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({comboStrategies:s})});if(!i.ok){let e=await i.json().catch(()=>({}));t(e.error||`Failed to update combo strategy (${i.status})`);return}N(s)}catch(e){throw t("Failed to update combo strategy"),e}},L=async e=>{A(e);try{(await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({capacityAdapter:e})})).ok||t("Failed to update capacity adapter")}catch(e){t("Failed to update capacity adapter")}};return o?(0,l.jsxs)("div",{className:"flex flex-col gap-6",children:[(0,l.jsx)(d.Qv,{}),(0,l.jsx)(d.Qv,{})]}):(0,l.jsxs)("div",{className:"flex min-w-0 flex-col gap-6 px-1 sm:px-0",children:[(0,l.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[(0,l.jsxs)("div",{className:"min-w-0 max-w-3xl",children:[(0,l.jsx)("h1",{className:"text-[17px] font-semibold text-text-main",children:"Combos"}),(0,l.jsx)("p",{className:"text-sm text-text-muted mt-1",children:"Group models under one name, then pick a strategy per combo:"}),(0,l.jsxs)("ul",{className:"text-sm text-text-muted mt-2 flex flex-col gap-1.5",children:[(0,l.jsxs)("li",{children:[(0,l.jsx)("span",{className:"font-medium text-text-main",children:"Fallback"})," ","— tries models in order (next on failure)"]}),(0,l.jsxs)("li",{children:[(0,l.jsx)("span",{className:"font-medium text-text-main",children:"Round Robin"})," ","— rotates models across requests to spread load"]}),(0,l.jsxs)("li",{children:[(0,l.jsx)("span",{className:"font-medium text-text-main",children:"Fusion"})," ","— queries all models in parallel, then a judge synthesizes one answer. Best quality, but costs the most: every request bills all panel models + the judge (N+1 calls)"]}),(0,l.jsxs)("li",{children:[(0,l.jsx)("span",{className:"font-medium text-text-main",children:"Auto"})," ","— a router model picks one worker from the pool each request (2 calls: router + worker); optional learning from outcomes"]}),(0,l.jsxs)("li",{children:[(0,l.jsx)("span",{className:"font-medium text-text-main",children:"Capacity auto-switch"})," ","— when enabled on a combo, sends image/PDF requests to a model that supports them first (works with Fallback, Round Robin, and Fusion)"]})]})]}),(0,l.jsx)(d.$n,{icon:"add",onClick:()=>x(!0),className:"w-full sm:w-auto whitespace-nowrap shrink-0",children:"Create Combo"})]}),0===a.length?(0,l.jsx)(d.Zp,{children:(0,l.jsxs)("div",{className:"text-center py-12",children:[(0,l.jsx)("div",{className:"inline-flex items-center justify-center w-16 h-16 rounded-full bg-primary/10 text-primary mb-4",children:(0,l.jsx)("span",{className:"material-symbols-outlined text-[32px]",children:"layers"})}),(0,l.jsx)("p",{className:"text-text-main font-medium mb-1",children:"No combos yet"}),(0,l.jsx)("p",{className:"text-sm text-text-muted mb-4 max-w-md mx-auto",children:"Create a named model group, choose Fallback / Round Robin / Fusion / Auto, and point clients at the combo name."}),(0,l.jsx)(d.$n,{icon:"add",onClick:()=>x(!0),className:"w-full sm:w-auto",children:"Create Combo"})]})}):(0,l.jsx)("div",{className:"flex flex-col gap-4",children:a.map(e=>(0,l.jsx)(S,{combo:e,modelCaps:k,activeProviders:h,copied:O,onCopy:$,onEdit:()=>p(e),onDelete:()=>_(e.id),strategy:v[e.name]||{},onSetStrategy:t=>z(e.name,t)},e.id))}),(0,l.jsx)(R,{capacityAdapter:C,onChange:L,activeProviders:h,getCaps:e=>k[e]||null}),(0,l.jsx)(M,{isOpen:n,onClose:()=>x(!1),onSave:P,activeProviders:h,modelCaps:k,initialStrategy:{fallbackStrategy:"fallback",capacityAutoSwitch:!0}},"create"),(0,l.jsx)(M,{isOpen:!!u,combo:u,onClose:()=>p(null),onSave:e=>D(u.id,e),activeProviders:h,modelCaps:k,initialStrategy:u?v[u.name]||{fallbackStrategy:"fallback"}:{}},u?.id||"new"),(0,l.jsx)(d.uo,{isOpen:!!F,onClose:()=>E(null),onConfirm:F?.onConfirm,title:F?.title||"Confirm",message:F?.message,variant:"danger"})]})}function y(e,t,a,l){let s=e||"fallback",r={fallbackStrategy:s,...void 0!==t?{capacityAutoSwitch:t}:{}};return"auto"===s?(a&&(r.routerModel=a),l&&(r.objective=l),r.judgeModel=""):("fusion"===s?r.routerModel="":(r.routerModel="",r.judgeModel=""),r.objective="",r.learningEnabled="",r.freezeLearning="",r.explorationRate=""),r}function v(e,t,a){let l=(e||[]).filter(e=>e&&e!==t);return l.length>0&&!l.some(e=>a[e]?.vision)}function N({models:e,routerModel:t}){let a=(e||[]).filter(e=>e&&e!==t);if(a.length<2)return null;let{cheap:s,frontier:r,disabled:o}=function(e){let t=(e||[]).filter(Boolean);if(t.length<=1)return{cheap:t.slice(),frontier:[],disabled:!0};let a=t.map(e=>({m:e,t:function(e){if(!e)return 4;let[t,...a]=e.split("/"),l=a.join("/")||t,s=(0,u.PS)(t,l);if(!s||"number"!=typeof s.input)return 4;let r="number"==typeof s.output?s.output:3*s.input,o=s.input+r;return o<2?0:o<10?1:o<30?2:o<80?3:4}(e)}));if(new Set(a.map(e=>e.t)).size<=1)return{cheap:t.slice(),frontier:[],disabled:!0};let l=a.filter(e=>e.t<=1).map(e=>e.m),s=a.filter(e=>e.t>=2).map(e=>e.m);if(!l.length||!s.length){let e=a.map((e,t)=>({...e,i:t})).sort((e,t)=>e.t-t.t||e.i-t.i),t=Math.ceil(e.length/2);l=e.slice(0,t).map(e=>e.m),s=e.slice(t).map(e=>e.m)}return{cheap:l,frontier:s,disabled:!1}}(a),i=e=>String(e).split("/").pop();return o?(0,l.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-1.5",children:[(0,l.jsx)("span",{className:"text-[11px] font-medium text-text-muted",children:"Tiers"}),(0,l.jsx)("span",{className:"text-[10px] text-text-subtle",title:"All workers share one cost tier — tiered routing is off",children:"single tier (tiering off)"})]}):(0,l.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-1.5",children:[(0,l.jsx)("span",{className:"text-[11px] font-medium text-text-muted",children:"Tiers"}),s.map(e=>(0,l.jsx)("span",{className:"rounded border border-emerald-500/30 bg-emerald-500/10 px-1.5 py-0.5 font-mono text-[10px] text-emerald-600 dark:text-emerald-400",title:`${e} — cheap tier`,children:i(e)},`c-${e}`)),(0,l.jsx)("span",{className:"material-symbols-outlined text-[12px] text-text-subtle",children:"arrow_forward"}),r.map(e=>(0,l.jsx)("span",{className:"rounded border border-amber-500/30 bg-amber-500/10 px-1.5 py-0.5 font-mono text-[10px] text-amber-600 dark:text-amber-400",title:`${e} — frontier tier`,children:i(e)},`f-${e}`))]})}let k=[{value:"fallback",label:"Fallback — try in order"},{value:"round-robin",label:"Round Robin — rotate load"},{value:"fusion",label:"Fusion — panel + judge (N+1)"},{value:"auto",label:"Auto — router picks 1 worker"}],w={fallback:"Tries models top-to-bottom; on failure uses the next.","round-robin":"Rotates models across requests to spread load.",fusion:"Calls every model, then a judge merges answers (bills N+1).",auto:"Router model chooses one worker each request (bills 2 calls)."},C=[{value:"quality",label:"Quality"},{value:"balanced",label:"Balanced"},{value:"economy",label:"Economy"},{value:"latency",label:"Latency"}];function S({combo:e,modelCaps:t={},activeProviders:a=[],copied:r,onCopy:o,onEdit:i,onDelete:n,strategy:c={},onSetStrategy:m}){let[x,u]=(0,s.useState)(!1),[p,h]=(0,s.useState)(!1),[b,f]=(0,s.useState)(!1),[g,j]=(0,s.useState)(!1),[y,A]=(0,s.useState)(""),M=c.fallbackStrategy||"fallback",R=c.judgeModel||"",F="auto"===M,E=c.routerModel||"",O=c.objective||"balanced",$=c.providerStrategy||"off",q=!1!==c.capacityAutoSwitch,P=Array.isArray(c.providerOrder)?c.providerOrder.join(", "):"",D=c.providerLatencyGuardMs??"",[_,z]=(0,s.useState)(P),[L,T]=(0,s.useState)(""===D?"":String(D));(0,s.useEffect)(()=>{z(P)},[P]),(0,s.useEffect)(()=>{T(""===D?"":String(D))},[D]);let I=()=>{let e=_.split(",").map(e=>e.trim()).filter(Boolean),t=Array.isArray(c.providerOrder)?c.providerOrder:[];e.join(",")!==t.join(",")&&m({providerOrder:e})},B=()=>{let e=""===L.trim()?void 0:Number(L)||void 0;e!==c.providerLatencyGuardMs&&m({providerLatencyGuardMs:e})};return(0,l.jsxs)(d.Zp,{padding:"sm",className:"group",children:[(0,l.jsxs)("div",{className:"flex min-w-0 flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[(0,l.jsxs)("div",{className:"flex min-w-0 flex-1 items-start gap-3 sm:items-center",children:[(0,l.jsx)("div",{className:"size-8 rounded-lg bg-primary/10 flex items-center justify-center shrink-0",children:(0,l.jsx)("span",{className:"material-symbols-outlined text-primary text-[18px]",children:"layers"})}),(0,l.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,l.jsx)("code",{className:"block truncate font-mono text-sm font-medium",children:e.name}),(0,l.jsx)("p",{className:"text-[10px] text-text-subtle mt-0.5",children:w[M]||""}),(0,l.jsxs)("div",{className:"mt-1 flex min-w-0 flex-wrap items-center gap-1",children:[0===e.models.length?(0,l.jsx)("span",{className:"text-xs text-text-muted italic",children:"No models"}):e.models.slice(0,3).map((e,a)=>(0,l.jsxs)("code",{className:"inline-flex items-center gap-1 rounded bg-black/5 px-1.5 py-0.5 font-mono text-xs text-text-muted dark:bg-white/5",children:[(0,l.jsx)("span",{children:e}),(0,l.jsx)(d.nh,{caps:t[e]})]},a)),e.models.length>3&&(0,l.jsxs)("span",{className:"text-[10px] text-text-muted",children:["+",e.models.length-3," more"]})]}),"fusion"===M&&(0,l.jsxs)("div",{className:"mt-2 flex min-w-0 flex-wrap items-center gap-1.5",children:[(0,l.jsx)("span",{className:"text-[11px] font-medium text-text-muted",children:"Judge"}),(0,l.jsxs)("button",{onClick:()=>u(!0),className:"inline-flex max-w-full items-center gap-1 rounded border border-dashed border-primary/40 px-1.5 py-0.5 font-mono text-[11px] text-primary hover:border-primary hover:bg-primary/5 transition-colors",title:"Pick the model that fuses panel answers",children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[13px]",children:"gavel"}),(0,l.jsx)("span",{className:"truncate",children:R||`Auto — ${e.models[0]||"first model"}`})]}),R&&(0,l.jsx)("button",{onClick:()=>m({judgeModel:""}),className:"p-0.5 rounded text-text-muted hover:text-red-500 hover:bg-red-500/10 transition-colors",title:"Reset judge to Auto",children:(0,l.jsx)("span",{className:"material-symbols-outlined text-[13px]",children:"close"})})]}),F&&(0,l.jsxs)("div",{className:"mt-2 flex min-w-0 flex-col gap-2",children:[(0,l.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-1.5",children:[(0,l.jsx)("span",{className:"text-[11px] font-medium text-text-muted",children:"Router"}),(0,l.jsxs)("button",{type:"button",onClick:()=>h(!0),className:"inline-flex max-w-full items-center gap-1 rounded border border-dashed border-primary/40 px-1.5 py-0.5 font-mono text-[11px] text-primary hover:border-primary hover:bg-primary/5 transition-colors",title:"Model that picks the worker each request — required for Auto",children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[13px]",children:"alt_route"}),(0,l.jsx)("span",{className:"truncate",children:E||"Select a router model (required)"})]})]}),E&&e.models?.includes(E)&&(0,l.jsxs)("p",{className:"text-[10px] text-amber-600 dark:text-amber-400 flex items-center gap-1",children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[12px]",children:"warning"}),"Router is also in the worker list — it is auto-excluded from the pool."]}),v(e.models,E,t)&&(0,l.jsxs)("p",{className:"text-[10px] text-amber-600 dark:text-amber-400 flex items-center gap-1",children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[12px]",children:"warning"}),"No vision-capable model — image requests will have images stripped"]}),(0,l.jsx)(N,{models:e.models,routerModel:E}),(0,l.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-1.5",children:[(0,l.jsx)("span",{className:"text-[11px] font-medium text-text-muted",children:"Objective"}),(0,l.jsx)("select",{value:O,onChange:e=>m({objective:e.target.value}),className:"rounded border border-border bg-surface-2 px-1.5 py-0.5 text-[11px] text-text-main",children:C.map(e=>(0,l.jsx)("option",{value:e.value,children:e.label},e.value))}),(0,l.jsxs)("label",{className:"inline-flex items-center gap-1 text-[11px] text-text-muted cursor-pointer",children:[(0,l.jsx)("input",{type:"checkbox",className:"rounded border-border",checked:!1!==c.learningEnabled,onChange:e=>m({learningEnabled:e.target.checked})}),"Learn"]}),(0,l.jsxs)("label",{className:"inline-flex items-center gap-1 text-[11px] text-text-muted cursor-pointer",title:"Keep routing on current learning version; block relearn",children:[(0,l.jsx)("input",{type:"checkbox",className:"rounded border-border",checked:!!c.freezeLearning,onChange:e=>m({freezeLearning:e.target.checked})}),"Freeze"]}),(0,l.jsxs)("label",{className:"inline-flex items-center gap-1 text-[11px] text-text-muted cursor-pointer",title:"Occasionally append a 1/2/3 feedback prompt to Auto chat replies (human chat only). Off by default.",children:[(0,l.jsx)("input",{type:"checkbox",className:"rounded border-border",checked:!!c.feedbackAsk,onChange:e=>m({feedbackAsk:e.target.checked})}),"Ask feedback"]}),(0,l.jsxs)("button",{type:"button",disabled:g||!!c.freezeLearning,onClick:async()=>{j(!0),A("");try{let t=await fetch("/api/routing/learn",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({comboName:e.name})}),a=await t.json();A(a.message||(a.ok?"Done":a.error||"Failed"))}catch(e){A(e.message||"Failed")}finally{j(!1)}},className:"inline-flex items-center gap-1 rounded border border-primary/40 bg-primary/10 px-2 py-0.5 text-[11px] font-medium text-primary hover:bg-primary/15 disabled:opacity-50",title:"Run learning optimizer on recent routing events",children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[13px]",children:"psychology"}),g?"Learning…":"Relearn now"]}),(0,l.jsx)("a",{href:`/dashboard/combos/routing?combo=${encodeURIComponent(e.name)}`,className:"inline-flex items-center gap-1 rounded border border-border px-2 py-0.5 text-[11px] text-text-muted hover:text-primary hover:border-primary/40",children:"Insights"})]}),(0,l.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-1.5",children:[(0,l.jsx)("span",{className:"text-[11px] font-medium text-text-muted",children:"Provider"}),(0,l.jsxs)("select",{value:$,onChange:e=>m({providerStrategy:e.target.value}),className:"rounded border border-border bg-surface-2 px-1.5 py-0.5 text-[11px] text-text-main",children:[(0,l.jsx)("option",{value:"off",children:"Off"}),(0,l.jsx)("option",{value:"priority",children:"Priority"}),(0,l.jsx)("option",{value:"round-robin",children:"Round robin"}),(0,l.jsx)("option",{value:"fastest",children:"Fastest"}),(0,l.jsx)("option",{value:"quota-first",children:"Quota first"})]}),"priority"===$&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)("input",{type:"text",value:_,onChange:e=>z(e.target.value),onBlur:I,onKeyDown:e=>{"Enter"===e.key&&I()},placeholder:"provider-a, provider-b",className:"w-40 rounded border border-border bg-surface-2 px-1.5 py-0.5 text-[11px] text-text-main"}),(0,l.jsx)("span",{className:"text-[10px] text-text-muted",children:"comma-separated provider names, highest priority first"})]}),(0,l.jsx)("input",{type:"number",min:"1",value:L,onChange:e=>T(e.target.value),onBlur:B,onKeyDown:e=>{"Enter"===e.key&&B()},placeholder:"20000",title:"Demote providers slower than this latency in milliseconds",className:"w-20 rounded border border-border bg-surface-2 px-1.5 py-0.5 text-[11px] text-text-main"})]}),"quota-first"===$&&(0,l.jsx)("p",{className:"text-[10px] text-text-muted",children:"Quota data currently available for Claude & Codex; other providers use availability (not rate-limited, lower recent use)."}),(0,l.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-2 text-[11px] text-text-muted",children:[(0,l.jsxs)("label",{className:"inline-flex items-center gap-1",children:["Window",(0,l.jsxs)("select",{value:c.learningWindowDays??14,onChange:e=>m({learningWindowDays:Number(e.target.value)||14}),className:"rounded border border-border bg-surface-2 px-1 py-0.5 text-[11px] text-text-main",children:[(0,l.jsx)("option",{value:7,children:"7d"}),(0,l.jsx)("option",{value:14,children:"14d"}),(0,l.jsx)("option",{value:30,children:"30d"})]})]}),(0,l.jsxs)("label",{className:"inline-flex items-center gap-1",title:"Epsilon-greedy exploration (capped at 20%)",children:["Explore",(0,l.jsx)("select",{value:Math.round((c.explorationRate??.05)*100),onChange:e=>m({explorationRate:Number(e.target.value)/100}),className:"rounded border border-border bg-surface-2 px-1 py-0.5 text-[11px] text-text-main",children:[0,5,10,15,20].map(e=>(0,l.jsxs)("option",{value:e,children:[e,"%"]},e))})]}),(0,l.jsxs)("label",{className:"inline-flex items-center gap-1",title:"0 = manual relearn only",children:["Auto-relearn",(0,l.jsxs)("select",{value:c.autoLearnIntervalHours??0,onChange:e=>m({autoLearnIntervalHours:Number(e.target.value)||0}),className:"rounded border border-border bg-surface-2 px-1 py-0.5 text-[11px] text-text-main",children:[(0,l.jsx)("option",{value:0,children:"off"}),(0,l.jsx)("option",{value:6,children:"6h"}),(0,l.jsx)("option",{value:12,children:"12h"}),(0,l.jsx)("option",{value:24,children:"24h"}),(0,l.jsx)("option",{value:72,children:"72h"})]})]}),(0,l.jsxs)("label",{className:"inline-flex items-center gap-1",title:"Capacity pre-filter before router (vision/PDF)",children:[(0,l.jsx)("input",{type:"checkbox",className:"rounded border-border",checked:!1!==c.capacityAutoSwitch,onChange:e=>m({capacityAutoSwitch:e.target.checked})}),"Heuristic first"]}),(0,l.jsxs)("label",{className:"inline-flex items-center gap-1",title:"Emit X-Auto-Router-* response headers (worker, cluster, score, skipped)",children:[(0,l.jsx)("input",{type:"checkbox",className:"rounded border-border",checked:!1!==c.emitAutoRouterHeaders,onChange:e=>m({emitAutoRouterHeaders:e.target.checked})}),"Route headers"]})]}),y?(0,l.jsx)("p",{className:"text-[11px] font-mono text-text-subtle",children:y}):(0,l.jsx)("p",{className:"text-[10px] text-text-subtle",children:"Worker pool = models list (router model excluded if listed). Every request re-routes. Router model is required — pick a connected account (a cheap, fast model such as Haiku works well)."})]})]})]}),(0,l.jsxs)("div",{className:"flex w-full flex-col gap-2 sm:w-auto sm:flex-row sm:items-center sm:gap-3 sm:shrink-0",children:[(0,l.jsxs)("div",{className:"w-full sm:w-[220px] flex flex-col gap-1.5",children:[(0,l.jsx)(d.l6,{options:k,value:M,onChange:e=>{let t=e.target.value;if("auto"===t&&!E){f(!0),h(!0);return}m({fallbackStrategy:t})},selectClassName:"py-1.5 text-xs"}),!F&&(0,l.jsxs)("label",{className:"inline-flex items-center gap-1.5 text-[10px] text-text-muted cursor-pointer",children:[(0,l.jsx)("input",{type:"checkbox",className:"rounded border-border",checked:q,onChange:e=>m({capacityAutoSwitch:e.target.checked})}),"Capacity auto-switch (vision/PDF first)"]})]}),(0,l.jsxs)("div",{className:"grid grid-cols-3 gap-1 sm:flex",children:[(0,l.jsxs)("button",{onClick:t=>{t.stopPropagation(),o(e.name,`combo-${e.id}`)},className:"flex flex-col items-center rounded px-2 py-1 text-text-muted transition-colors hover:bg-black/5 hover:text-primary dark:hover:bg-white/5",title:"Copy combo name",children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:r===`combo-${e.id}`?"check":"content_copy"}),(0,l.jsx)("span",{className:"text-[10px] leading-tight",children:"Copy"})]}),(0,l.jsxs)("button",{onClick:i,className:"flex flex-col items-center rounded px-2 py-1 text-text-muted transition-colors hover:bg-black/5 hover:text-primary dark:hover:bg-white/5",title:"Edit",children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"edit"}),(0,l.jsx)("span",{className:"text-[10px] leading-tight",children:"Edit"})]}),(0,l.jsxs)("button",{onClick:n,className:"flex flex-col items-center rounded px-2 py-1 text-red-500 transition-colors hover:bg-red-500/10",title:"Delete",children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"delete"}),(0,l.jsx)("span",{className:"text-[10px] leading-tight",children:"Delete"})]})]})]})]}),(0,l.jsx)(d.rq,{isOpen:x,onClose:()=>u(!1),onSelect:e=>{m({judgeModel:e?.value||""}),u(!1)},activeProviders:a,title:"Select Judge Model",addedModelValues:R?[R]:[],closeOnSelect:!0}),(0,l.jsx)(d.rq,{isOpen:p,onClose:()=>{f(!1),h(!1)},onSelect:e=>{let t=e?.value||"";b?(f(!1),t&&m({fallbackStrategy:"auto",routerModel:t})):m({routerModel:t}),h(!1)},activeProviders:a,title:"Select Router Model",addedModelValues:E?[E]:[],closeOnSelect:!0})]})}function A({id:e,index:t,model:a,learned:r=null,isFirst:n,isLast:d,onEdit:c,onMoveUp:m,onMoveDown:x,onRemove:u}){let{attributes:p,listeners:h,setNodeRef:b,transform:f,isDragging:g}=(0,o.gl)({id:e}),j={transform:i.Ks.Transform.toString(f),opacity:g?.4:1,zIndex:g?999:void 0},[y,v]=(0,s.useState)(!1),[N,k]=(0,s.useState)(a),w=()=>{let e=N.trim();e&&e!==a?c(e):k(a),v(!1)};return(0,l.jsxs)("div",{ref:b,style:j,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 ${g?"shadow-md ring-1 ring-primary/30":""}`,children:[(0,l.jsx)("button",{...p,...h,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:(0,l.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:[(0,l.jsx)("circle",{cx:"9",cy:"4",r:"2"}),(0,l.jsx)("circle",{cx:"15",cy:"4",r:"2"}),(0,l.jsx)("circle",{cx:"9",cy:"12",r:"2"}),(0,l.jsx)("circle",{cx:"15",cy:"12",r:"2"}),(0,l.jsx)("circle",{cx:"9",cy:"20",r:"2"}),(0,l.jsx)("circle",{cx:"15",cy:"20",r:"2"})]})}),(0,l.jsx)("span",{className:"text-[10px] font-medium text-text-muted w-3 text-center shrink-0",children:t+1}),y?(0,l.jsx)("input",{autoFocus:!0,value:N,onChange:e=>k(e.target.value),onBlur:w,onKeyDown:e=>{"Enter"===e.key&&w(),"Escape"===e.key&&(k(a),v(!1))},className:"min-w-0 flex-1 rounded border border-primary/40 bg-white px-1.5 py-0.5 font-mono text-xs text-text-main outline-none dark:bg-black/20"}):(0,l.jsx)("div",{role:"button",tabIndex:0,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 focus:outline-none focus-visible:ring-2 focus-visible:ring-primary/40",onClick:()=>v(!0),onKeyDown:e=>{("Enter"===e.key||" "===e.key)&&(e.preventDefault(),v(!0))},title:"Click to edit","aria-label":`Edit model ${a}`,children:a}),r&&r.n>=10&&(0,l.jsxs)("span",{className:"shrink-0 font-mono text-[10px] text-text-subtle",title:"Learned routing stats (all combos, last 14d)",children:["avg ",Math.round(r.avgScore)," \xb7 n=",r.n,r.bestCluster?` \xb7 best: ${r.bestCluster}`:""]}),(0,l.jsxs)("div",{className:"flex shrink-0 items-center gap-0.5",children:[(0,l.jsx)("button",{onClick:m,disabled:n,className:`p-0.5 rounded ${n?"text-text-muted/20 cursor-not-allowed":"text-text-muted hover:text-primary hover:bg-black/5 dark:hover:bg-white/5"}`,title:"Move up",children:(0,l.jsx)("span",{className:"material-symbols-outlined text-[12px]",children:"arrow_upward"})}),(0,l.jsx)("button",{onClick:x,disabled:d,className:`p-0.5 rounded ${d?"text-text-muted/20 cursor-not-allowed":"text-text-muted hover:text-primary hover:bg-black/5 dark:hover:bg-white/5"}`,title:"Move down",children:(0,l.jsx)("span",{className:"material-symbols-outlined text-[12px]",children:"arrow_downward"})})]}),(0,l.jsx)("button",{onClick:u,className:"p-0.5 hover:bg-red-500/10 rounded text-text-muted hover:text-red-500 transition-all",title:"Remove",children:(0,l.jsx)("span",{className:"material-symbols-outlined text-[12px]",children:"close"})})]})}function M({isOpen:e,combo:t,onClose:a,onSave:i,activeProviders:c,modelCaps:m={},kindFilter:u=null,initialStrategy:h={}}){let[b,f]=(0,s.useState)(t?.name||""),[g,j]=(0,s.useState)(t?.models||[]),[y,N]=(0,s.useState)(h.fallbackStrategy||"fallback"),[C,S]=(0,s.useState)(!1!==h.capacityAutoSwitch),[R,F]=(0,s.useState)(!1),[E,O]=(0,s.useState)(!1),[$,q]=(0,s.useState)(""),[P,D]=(0,s.useState)({}),[_,z]=(0,s.useState)({}),L=(0,r.FR)((0,r.MS)(r.AN,{activationConstraint:{distance:5}}),(0,r.MS)(r.uN,{coordinateGetter:o.JR})),T=g.map((e,t)=>({uid:`item-${t}`,model:e})),I=async()=>{try{let e=await fetch("/api/models/alias");if(e.ok){let t=await e.json();D(t.aliases||{})}}catch(e){(0,x.s)("Error fetching modal data:",e)}try{let e=await fetch("/api/routing/stats");if(!e.ok)throw Error("Failed to fetch learned routing stats");let t=await e.json(),a={};for(let e of t.global||[]){let t=Object.entries(e.clusters||{}),l=t.filter(([,e])=>e.n>=3),s=(l.length?l:t).reduce((e,t)=>{if(!e)return t;let[a,s]=e,[r,o]=t,i=l.length?s.avgScore:s.n,n=l.length?o.avgScore:o.n;return n>i||n===i&&r<a?t:e},null);a[e.worker]={avgScore:e.avgScore,n:e.n,bestCluster:s?s[0]:null}}z(a)}catch{z({})}};(0,s.useEffect)(()=>{e&&(f(t?.name||""),j(t?.models||[]),N(h.fallbackStrategy||"fallback"),S(!1!==h.capacityAutoSwitch),F(!1),O(!1),q(""),z({}),I())},[e,t?.id,t?.name]);let B=e=>e.trim()?p.test(e)?(q(""),!0):(q("Only letters, numbers, -, _ and . allowed"),!1):(q("Name is required"),!1),H=async()=>{if(B(b)){if(0===g.length)return void(0,x.s)("Add at least one model to the combo");if("auto"===y&&g.length<2)return void(0,x.s)("Auto strategy needs at least 2 models in the worker pool (plus a connected router account)");O(!0),await i({name:b.trim(),models:g,strategy:y,capacityAutoSwitch:"auto"===y||C}),O(!1)}},J=!!t;return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(d.aF,{isOpen:e,onClose:a,title:J?"Edit Combo":"Create Combo",children:(0,l.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,l.jsxs)("p",{className:"text-xs text-text-muted leading-relaxed",children:["Clients call this combo by name as the ",(0,l.jsx)("code",{className:"text-primary",children:"model"})," field. Strategy controls how models in the list are used."]}),(0,l.jsxs)("div",{children:[(0,l.jsx)(d.pd,{label:"Combo Name",value:b,onChange:e=>{let t=e.target.value;f(t),t?B(t):q("")},placeholder:"my-combo",error:$}),(0,l.jsx)("p",{className:"text-[10px] text-text-muted mt-0.5",children:"Only letters, numbers, -, _ and . allowed \xb7 use as model id in /v1"})]}),(0,l.jsxs)("div",{children:[(0,l.jsx)("label",{className:"text-sm font-medium mb-1.5 block",children:"Strategy"}),(0,l.jsx)(d.l6,{options:k,value:y,onChange:e=>N(e.target.value),selectClassName:"py-2 text-sm"}),(0,l.jsx)("p",{className:"text-[11px] text-text-muted mt-1.5",children:w[y]}),"auto"===y&&(0,l.jsxs)("p",{className:"text-[11px] text-amber-600 dark:text-amber-400 mt-1 flex items-center gap-1",children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[12px]",children:"info"}),"Auto requires a router model — select one on the combo card after saving."]}),"auto"!==y&&(0,l.jsxs)("label",{className:"mt-2 inline-flex items-center gap-2 text-xs text-text-muted cursor-pointer",children:[(0,l.jsx)("input",{type:"checkbox",className:"rounded border-border",checked:C,onChange:e=>S(e.target.checked)}),"Capacity auto-switch — prefer vision/PDF-capable models when the request needs them"]}),"auto"===y&&(0,l.jsx)("p",{className:"text-[11px] text-text-subtle mt-1.5 font-mono",children:"After create: set Router model on the combo card (must be a connected account). Workers = this model list (router excluded if listed)."}),"fusion"===y&&(0,l.jsx)("p",{className:"text-[11px] text-text-subtle mt-1.5 font-mono",children:"After create: optionally set Judge on the combo card (default = first model)."})]}),(0,l.jsxs)("div",{children:[(0,l.jsxs)("label",{className:"text-sm font-medium mb-1.5 block",children:["Models ","fallback"===y?"(order = priority)":"(pool)"]}),g.length>0&&v(g,null,m)&&(0,l.jsxs)("p",{className:"text-[10px] text-amber-600 dark:text-amber-400 flex items-center gap-1 mb-1",children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[12px]",children:"warning"}),"No vision-capable model — image requests will have images stripped"]}),0===g.length?(0,l.jsxs)("div",{className:"text-center py-4 border border-dashed border-black/10 dark:border-white/10 rounded-lg bg-black/[0.01] dark:bg-white/[0.01]",children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-text-muted text-xl mb-1",children:"layers"}),(0,l.jsx)("p",{className:"text-xs text-text-muted",children:"No models added yet"})]}):(0,l.jsx)(r.Mp,{sensors:L,collisionDetection:r.fp,onDragEnd:e=>{let{active:t,over:a}=e;if(a&&t.id!==a.id){let e=T.findIndex(e=>e.uid===t.id),l=T.findIndex(e=>e.uid===a.id);-1!==e&&-1!==l&&j(t=>(0,o.be)(t,e,l))}},modifiers:[n.FN,n.gj],children:(0,l.jsx)(o.gB,{items:T.map(e=>e.uid),strategy:o._G,children:(0,l.jsx)("div",{className:"flex max-h-[55vh] min-w-0 flex-col gap-1 overflow-y-auto sm:max-h-[350px]",children:T.map(({uid:e,model:t},a)=>(0,l.jsx)(A,{id:e,index:a,model:t,learned:_[t]||null,isFirst:0===a,isLast:a===T.length-1,onEdit:e=>{let t=[...g];t[a]=e,j(t)},onMoveUp:()=>(e=>{if(0===e)return;let t=[...g];[t[e-1],t[e]]=[t[e],t[e-1]],j(t)})(a),onMoveDown:()=>(e=>{if(e===g.length-1)return;let t=[...g];[t[e],t[e+1]]=[t[e+1],t[e]],j(t)})(a),onRemove:()=>{j(g.filter((e,t)=>t!==a))}},e))})})}),(0,l.jsxs)("button",{onClick:()=>F(!0),className:"w-full mt-2 py-2 border border-dashed border-black/10 dark:border-white/10 rounded-lg text-xs text-primary font-medium hover:text-primary hover:border-primary/50 transition-colors flex items-center justify-center gap-1",children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"add"}),"Add Model"]})]}),(0,l.jsxs)("div",{className:"flex flex-col gap-2 pt-1 sm:flex-row",children:[(0,l.jsx)(d.$n,{onClick:a,variant:"ghost",fullWidth:!0,size:"sm",children:"Cancel"}),(0,l.jsx)(d.$n,{onClick:H,fullWidth:!0,size:"sm",disabled:!b.trim()||!!$||E,children:E?"Saving...":J?"Save":"Create"})]})]})}),(0,l.jsx)(d.rq,{isOpen:R,onClose:()=>F(!1),onSelect:e=>{g.includes(e.value)||j([...g,e.value])},onDeselect:e=>{j(g.filter(t=>t!==e.value))},activeProviders:c,modelAliases:P,title:"Add Model to Combo",kindFilter:u,addedModelValues:g,closeOnSelect:!1})]})}function R({capacityAdapter:e,onChange:t,activeProviders:a,getCaps:s}){return(0,l.jsx)(d.Zp,{padding:"sm",children:(0,l.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,l.jsx)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:(0,l.jsxs)("div",{className:"min-w-0",children:[(0,l.jsx)("p",{className:"text-sm font-medium text-text-main",children:"Capacity Adapter"}),(0,l.jsx)("p",{className:"text-xs text-text-muted mt-0.5",children:"Request carries images or audio your model can't read? Auto-switches to a model in the pool below."}),(0,l.jsxs)("ul",{className:"mt-1.5 text-[11px] text-text-muted flex flex-col gap-0.5",children:[(0,l.jsxs)("li",{children:[(0,l.jsx)("span",{className:"font-medium text-text-main",children:"Vision"})," — images (png, jpg, webp, …)"]}),(0,l.jsxs)("li",{children:[(0,l.jsx)("span",{className:"font-medium text-text-main",children:"Audio"})," — audio input"]})]})]})}),(0,l.jsx)("div",{className:"flex flex-col gap-4",children:h.map(r=>(0,l.jsx)(F,{cap:r,entry:e[r.key]||b,onChange:a=>t({...e,[r.key]:a}),activeProviders:a,getCaps:s},r.key))})]})})}function F({cap:e,entry:t,onChange:a,activeProviders:r,getCaps:o}){let[i,n]=(0,s.useState)(!1),{enabled:c,roundRobin:m,models:x}=t,u=e=>a({...t,...e}),p=(e,t)=>{let a=e+t;if(a<0||a>=x.length)return;let l=[...x];[l[e],l[a]]=[l[a],l[e]],u({models:l})};return(0,l.jsxs)("div",{className:`group rounded-lg border border-black/5 p-3 ${!c?"opacity-50":""} dark:border-white/10`,children:[(0,l.jsxs)("div",{className:"flex min-w-0 flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[(0,l.jsxs)("div",{className:"flex min-w-0 flex-1 items-start gap-2.5 sm:items-center",children:[(0,l.jsx)(d.lM,{checked:c,onChange:e=>u({enabled:e}),"aria-label":`Enable ${e.label} adapter`}),(0,l.jsx)("div",{className:"size-8 rounded-lg bg-primary/10 flex items-center justify-center shrink-0",children:(0,l.jsx)("span",{className:"material-symbols-outlined text-primary text-[18px]",children:e.icon})}),(0,l.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,l.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,l.jsx)("code",{className:"font-mono text-sm font-medium text-text-main",children:e.label}),(0,l.jsxs)("span",{className:"text-[10px] text-text-muted",children:["— ",e.desc]})]}),(0,l.jsx)("div",{className:"mt-1 flex min-w-0 flex-wrap items-center gap-1",children:0===x.length?(0,l.jsx)("span",{className:"text-xs text-text-muted italic",children:"No models"}):x.map((e,t)=>(0,l.jsxs)("code",{className:"group/chip inline-flex items-center gap-1 rounded bg-black/5 px-1.5 py-0.5 font-mono text-xs text-text-muted dark:bg-white/5",children:[(0,l.jsx)("span",{children:e}),(0,l.jsx)(d.nh,{caps:o?.(e)}),(0,l.jsx)("button",{onClick:()=>p(t,-1),disabled:0===t,className:`leading-none opacity-0 group-hover/chip:opacity-100 ${0===t?"text-text-muted/20":"text-text-muted hover:text-primary"}`,children:(0,l.jsx)("span",{className:"material-symbols-outlined text-[12px]",children:"arrow_upward"})}),(0,l.jsx)("button",{onClick:()=>p(t,1),disabled:t===x.length-1,className:`leading-none opacity-0 group-hover/chip:opacity-100 ${t===x.length-1?"text-text-muted/20":"text-text-muted hover:text-primary"}`,children:(0,l.jsx)("span",{className:"material-symbols-outlined text-[12px]",children:"arrow_downward"})}),(0,l.jsx)("button",{onClick:()=>{let e;u({models:0===(e=x.filter((e,a)=>a!==t)).length?["oc/mimo-v2.5-free"]:e})},className:"leading-none opacity-0 group-hover/chip:opacity-100 text-text-muted hover:text-red-500",children:(0,l.jsx)("span",{className:"material-symbols-outlined text-[12px]",children:"close"})})]},`${e}-${t}`))})]})]}),(0,l.jsxs)("div",{className:"flex w-full flex-col gap-2 sm:w-auto sm:flex-row sm:items-center sm:gap-3 sm:shrink-0",children:[(0,l.jsxs)("label",{className:"flex items-center gap-1.5 text-xs text-text-muted cursor-pointer select-none",children:[(0,l.jsx)(d.lM,{checked:m,onChange:e=>u({roundRobin:e}),disabled:!c,"aria-label":`Round-robin ${e.label} adapter`}),(0,l.jsx)("span",{children:"Round"})]}),(0,l.jsx)(d.$n,{icon:"add",variant:"ghost",size:"sm",onClick:()=>n(!0),disabled:!c,title:`Add ${e.label} model`,children:"Add Model"})]})]}),i&&(0,l.jsx)(d.rq,{isOpen:i,onClose:()=>n(!1),onSelect:e=>{x.includes(e.value)||u({models:[...x,e.value]})},activeProviders:r,title:`Add ${e.label} Model`,addedModelValues:x,capFilter:e.key,closeOnSelect:!1})]})}},80063:(e,t,a)=>{Promise.resolve().then(a.bind(a,41483))}},e=>{e.O(0,[2574,3862,782,8500,594,7055,1321,4707,1330,8441,3794,7358],()=>e(e.s=80063)),_N_E=e.O()}]);
@@ -1,10 +0,0 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[2134],{7687:(e,t,s)=>{Promise.resolve().then(s.bind(s,42710))},35497:(e,t,s)=>{"use strict";s.d(t,{x0:()=>k.default,Ex:()=>d.default,$n:()=>a.default,nh:()=>A.default,Zp:()=>l.default,Qv:()=>o.CardSkeleton,CK:()=>x.default,uo:()=>n.ConfirmModal,G9:()=>y.default,wI:()=>w.default,vj:()=>j.default,vE:()=>v.default,pd:()=>i.default,Mh:()=>g.default,uR:()=>p.default,Nf:()=>h.default,aF:()=>n.default,rq:()=>u.default,gw:()=>N.default,LF:()=>m.default,Wx:()=>$.default,gM:()=>b.default,Iz:()=>C.default,l6:()=>r.default,lM:()=>c.default,m_:()=>S.default,jK:()=>f.default});var a=s(92542),i=s(11910),r=s(98),l=s(84588),n=s(81127),o=s(25086);s(56319);var d=s(56061),c=s(98542);s(61929),s(21110),s(92622),s(8823),s(92173);var m=s(90882),u=s(72908),p=s(28815),x=s(45455),h=s(28058),f=s(4809);s(21931),s(80752),s(40197);var b=s(23615);s(44736);var g=s(62899);s(94230);var y=s(30815),v=s(23936),j=s(95088),w=s(73579),k=s(96748),N=s(4823),C=s(28067),S=s(97677),$=s(51825),A=s(29366);s(76361),s(91450)},42710:(e,t,s)=>{"use strict";s.r(t),s.d(t,{default:()=>W});var a=s(95155),i=s(12115),r=s(73321),l=s(98500),n=s.n(l),o=s(5772),d=s(35497),c=s(88105),m=s(28777),u=s(16600),p=s(47224);let x=["none","low","medium","high"],h=["none","thinking"],f=["none","low","medium","high","max"],b={openai:["none","minimal","low","medium","high","xhigh"],"claude-adaptive":f,"claude-budget":["none","low","medium","high","xhigh","max"],"gemini-level":["minimal","low","medium","high"],"gemini-budget":x,zai:h,qwen:x,kimi:f,deepseek:["none","high","max"],minimax:h,hunyuan:x,step:x},g=[{pattern:"*codex*",levels:["low","medium","high","xhigh"]}];function y(e,t){let s=(0,u.nl)(e,t);if(!s.reasoning)return null;let a=g.find(e=>(0,p.gH)(e.pattern,t)),i=a?.levels||b[s.thinkingFormat]||x;return!1===s.thinkingCanDisable&&(i=i.filter(e=>"none"!==e)),i}var v=s(11059),j=s(929),w=s(73006);let k=new Map;async function N(e){if(!e?.url||!e?.type||e.requiresAuth)return[];let t=k.get(e.url);if(t&&Date.now()<t.expiresAt)return t.data;try{let t=new URLSearchParams({url:e.url,type:e.type}),s=await fetch(`/api/providers/suggested-models?${t}`);if(!s.ok)return[];let a=(await s.json()).data??[];return k.set(e.url,{data:a,expiresAt:Date.now()+6e5}),a}catch{return[]}}var C=s(81231),S=s(68501),$=s(14051),A=s.n($);function T({model:e,fullModel:t,alias:s,copied:i,onCopy:r,testStatus:l,isCustom:n,isFree:o,onDeleteAlias:c,onTest:m,isTesting:u,onDisable:p,caps:x,thinkingSuffix:h,latencyMs:f,probeState:b}){let g=h?`${t}(${h})`:t,y="ok"===l||"ok"===b,v="error"===l||"dead"===b,j="retry"===b||u||"testing"===b;return(0,a.jsx)("div",{className:`group relative min-w-0 max-w-full rounded-xl border bg-surface/50 p-3 transition-all hover:bg-surface/80 hover:shadow-soft ${y?"border-green-500/30 hover:border-green-500/50":v?"border-red-500/30 hover:border-red-500/50":j?"border-amber-500/30 hover:border-amber-500/50":"border-border/60 hover:border-primary/40"}`,children:(0,a.jsxs)("div",{className:"flex min-w-0 items-start justify-between gap-2.5",children:[(0,a.jsxs)("div",{className:"flex min-w-0 flex-1 items-start gap-2.5",children:[(0,a.jsx)("div",{className:"mt-0.5 flex size-7 shrink-0 items-center justify-center rounded-lg bg-surface-2 border border-border/40 text-text-muted",children:u||"testing"===b?(0,a.jsx)("span",{className:"material-symbols-outlined shrink-0 animate-spin text-[15px] text-primary",title:"Testing model...",children:"progress_activity"}):y?(0,a.jsx)("span",{className:"material-symbols-outlined shrink-0 text-[16px] text-green-500",title:"Model reachable",children:"check_circle"}):v?(0,a.jsx)("span",{className:"material-symbols-outlined shrink-0 text-[16px] text-red-500",title:"Model unavailable",children:"cancel"}):"retry"===b?(0,a.jsx)("span",{className:"material-symbols-outlined shrink-0 text-[16px] text-amber-500",title:"Retry later",children:"schedule"}):(0,a.jsx)("span",{className:"material-symbols-outlined shrink-0 text-[16px]","aria-hidden":"true",children:"smart_toy"})}),(0,a.jsxs)("div",{className:"flex min-w-0 flex-1 flex-col gap-1",children:[(0,a.jsxs)("div",{className:"flex items-center gap-1.5 flex-wrap",children:[(0,a.jsx)("code",{className:"max-w-[70vw] truncate rounded-md bg-surface-2 border border-border/40 px-2 py-0.5 font-mono text-xs font-medium text-text-main sm:max-w-[340px]",children:g}),n&&(0,a.jsx)("span",{className:"rounded bg-primary/10 px-1.5 py-0.5 text-[10px] font-medium text-primary",children:"Custom"})]}),(0,a.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-2 text-xs",children:[e.name&&(0,a.jsx)("span",{className:"truncate text-xs text-text-muted",children:e.name}),Number.isFinite(f)&&(0,a.jsxs)("span",{className:"inline-flex items-center gap-0.5 text-[11px] font-medium text-text-muted tabular-nums",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[12px] text-primary",children:"bolt"}),Math.round(f),"ms"]}),(0,a.jsx)(d.nh,{caps:x,colorOverride:"text-text-muted/80",size:13})]})]})]}),(0,a.jsxs)("div",{className:"flex items-center gap-1 shrink-0",children:[m&&(0,a.jsx)("button",{onClick:m,disabled:u,"aria-label":u?`Testing ${g}`:`Test ${g}`,title:u?"Testing...":"Test model",className:`rounded-lg p-1 text-text-muted transition-all hover:bg-surface-2 hover:text-primary ${u?"opacity-100":"opacity-70 group-hover:opacity-100"}`,children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[16px]","aria-hidden":"true",style:u?{animation:"spin 1s linear infinite"}:void 0,children:u?"progress_activity":"science"})}),(0,a.jsx)("button",{onClick:()=>r(g,`model-${e.id}`),"aria-label":i===`model-${e.id}`?`Copied ${g}`:`Copy ${g}`,title:i===`model-${e.id}`?"Copied!":"Copy model name",className:"rounded-lg p-1 text-text-muted transition-all hover:bg-surface-2 hover:text-primary opacity-70 group-hover:opacity-100",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[16px]","aria-hidden":"true",children:i===`model-${e.id}`?"check":"content_copy"})}),n?(0,a.jsx)("button",{onClick:c,className:"rounded-lg p-1 text-text-muted transition-all hover:bg-red-500/10 hover:text-red-400 opacity-60 hover:opacity-100","aria-label":`Remove custom model ${g}`,title:"Remove custom model",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[16px]","aria-hidden":"true",children:"close"})}):p?(0,a.jsx)("button",{onClick:p,className:"rounded-lg p-1 text-text-muted transition-all hover:bg-red-500/10 hover:text-red-400 opacity-60 hover:opacity-100","aria-label":`Disable ${g}`,title:"Disable this model",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[16px]","aria-hidden":"true",children:"close"})}):null]})]})})}T.propTypes={model:A().shape({id:A().string.isRequired}).isRequired,fullModel:A().string.isRequired,alias:A().string,copied:A().string,onCopy:A().func.isRequired,testStatus:A().oneOf(["ok","error"]),isCustom:A().bool,isFree:A().bool,onDeleteAlias:A().func,onTest:A().func,isTesting:A().bool,onDisable:A().func,caps:A().object,thinkingSuffix:A().string,latencyMs:A().number,probeState:A().string};var E=s(78559);function R({modelId:e,fullModel:t,copied:s,onCopy:i,onDeleteAlias:r,onTest:l,testStatus:n,isTesting:o}){let d="ok"===n?"#22c55e":"error"===n?"#ef4444":void 0;return(0,a.jsxs)("div",{className:`flex items-center gap-3 p-3 rounded-lg border ${"ok"===n?"border-green-500/40":"error"===n?"border-red-500/40":"border-border"} hover:bg-sidebar/50`,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-base text-text-muted",style:d?{color:d}:void 0,children:"ok"===n?"check_circle":"error"===n?"cancel":"smart_toy"}),(0,a.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,a.jsx)("p",{className:"text-sm font-medium truncate",children:e}),(0,a.jsxs)("div",{className:"flex items-center gap-1 mt-1",children:[(0,a.jsx)("code",{className:"text-xs text-text-muted font-mono bg-sidebar px-1.5 py-0.5 rounded",children:t}),(0,a.jsxs)("div",{className:"relative group/btn",children:[(0,a.jsx)("button",{onClick:()=>i(t,`model-${e}`),className:"p-0.5 hover:bg-sidebar rounded text-text-muted hover:text-primary",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:s===`model-${e}`?"check":"content_copy"})}),(0,a.jsx)("span",{className:"pointer-events-none absolute top-5 left-1/2 -translate-x-1/2 text-[10px] text-text-muted whitespace-nowrap opacity-0 group-hover/btn:opacity-100 transition-opacity",children:s===`model-${e}`?"Copied!":"Copy"})]}),l&&(0,a.jsxs)("div",{className:"relative group/btn",children:[(0,a.jsx)("button",{onClick:l,disabled:o,className:"p-0.5 hover:bg-sidebar rounded text-text-muted hover:text-primary transition-colors",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",style:o?{animation:"spin 1s linear infinite"}:void 0,children:o?"progress_activity":"science"})}),(0,a.jsx)("span",{className:"pointer-events-none absolute top-5 left-1/2 -translate-x-1/2 text-[10px] text-text-muted whitespace-nowrap opacity-0 group-hover/btn:opacity-100 transition-opacity",children:o?"Testing...":"Test"})]})]})]}),(0,a.jsx)("button",{onClick:r,className:"p-1 hover:bg-red-50 rounded text-red-500",title:"Remove model",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:"delete"})})]})}function O({providerStorageAlias:e,providerDisplayAlias:t,modelAliases:s,customModels:r,copied:l,onCopy:n,onDeleteAlias:o,onAddCustomModel:c,onDeleteCustomModel:m,onRefreshModels:u,connections:p,isAnthropic:x,disabledModelIds:h=[],onEnableModel:f}){let[b,g]=(0,i.useState)(""),[y,v]=(0,i.useState)(!1),[j,w]=(0,i.useState)(!1),[k,N]=(0,i.useState)(""),[S,$]=(0,i.useState)(null),[A,T]=(0,i.useState)({}),I=async t=>{if(!S){$(t);try{let s=await fetch("/api/models/test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:`${e}/${t}`})}),a=await s.json();T(e=>({...e,[t]:a.ok?"ok":"error"}))}catch{T(e=>({...e,[t]:"error"}))}finally{$(null)}}},D=(0,C.Iz)(h,e),M=[...D],P=(0,C.R3)({customModels:r,modelAliases:s,providerAlias:e,type:"llm"}),U=P.filter(t=>!(0,C.uJ)(D,t.id,e)),z=async()=>{if(!b.trim()||y)return;let t=b.trim();if(U.some(e=>e.id===t))return void(0,E.s)("Model already exists for this provider.");v(!0);try{if((0,C.uJ)(D,t,e)){let e=await f?.(t);if(!1===e)throw Error("Failed to enable removed model")}await c(t),g("")}catch(e){(0,E.s)("Error adding model:",e)}finally{v(!1)}},q=async()=>{if(j)return;let t=p.find(e=>!1!==e.isActive);if(t){w(!0),N("");try{let s=await fetch(`/api/providers/${t.id}/models`),a=await s.json().catch(()=>({}));if(!s.ok)return void(0,E.s)(a.error||"Failed to import models");let i=a.models||[];if(0===i.length)return void(0,E.s)("No models returned from /models.");let r=new Set(P.map(e=>e.id)),l=[],n=new Set;for(let t of i){let s=String(t.id||t.name||t.model||"").trim();!s||r.has(s)||n.has(s)||(0,C.uJ)(D,s,e)||(n.add(s),l.push({providerAlias:e,id:s,type:"llm",name:t.display_name||t.displayName||t.name||s}))}if(0===l.length)return void N("All models already in list");let o=await fetch("/api/models/custom",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({models:l})}),d=await o.json().catch(()=>({}));if(!o.ok){let e=0;for(let t of l)await c(t.id),e+=1;N(e?`Imported ${e} model(s)`:"No new models were added");return}N(`Imported ${d.added??l.length} model(s)`),"function"==typeof u?await u():window.dispatchEvent(new CustomEvent("customModelChanged"))}catch(e){(0,E.s)("Error importing models:",e),(0,E.s)(e?.message||"Import failed")}finally{w(!1)}}},_=p.some(e=>!1!==e.isActive);return(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,a.jsxs)("p",{className:"text-sm text-text-muted",children:["Add ",x?"Anthropic":"OpenAI","-compatible models manually or import them from the /models endpoint."]}),(0,a.jsxs)("div",{className:"flex items-end gap-2 flex-wrap",children:[(0,a.jsxs)("div",{className:"flex-1 min-w-[240px]",children:[(0,a.jsx)("label",{htmlFor:"new-compatible-model-input",className:"text-xs text-text-muted mb-1 block",children:"Model ID"}),(0,a.jsx)("input",{id:"new-compatible-model-input",type:"text",value:b,onChange:e=>g(e.target.value),onKeyDown:e=>"Enter"===e.key&&z(),placeholder:x?"claude-3-opus-20240229":"gpt-4o",className:"w-full px-3 py-2 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary"})]}),(0,a.jsx)(d.$n,{size:"sm",icon:"add",onClick:z,disabled:!b.trim()||y,children:y?"Adding...":"Add"}),(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",icon:"cloud_download",onClick:q,disabled:!_||j,children:j?"Importing...":"Import models"})]}),!_&&(0,a.jsx)("p",{className:"text-xs text-text-muted",children:"Add a connection to enable importing models."}),k&&(0,a.jsx)("p",{className:"text-xs text-text-muted",children:k}),U.length>0&&(0,a.jsx)("div",{className:"flex flex-col gap-3",children:U.map(({id:s,alias:i,source:r})=>(0,a.jsx)(R,{modelId:s,fullModel:`${t}/${s}`,copied:l,onCopy:n,onDeleteAlias:()=>"custom"===r?m(s):o(i),onTest:p.length>0?()=>I(s):void 0,testStatus:A[s],isTesting:S===s},`${r}-${e}/${s}`))}),M.length>0&&(0,a.jsxs)("details",{className:"rounded-lg border border-border bg-surface/30 p-3",children:[(0,a.jsxs)("summary",{className:"cursor-pointer text-sm font-medium text-text-main",children:["Removed models (",M.length,")"]}),(0,a.jsx)("p",{className:"mt-1 text-xs text-text-muted",children:"Enable a model to make it available for import and selection again."}),(0,a.jsx)("div",{className:"mt-3 flex max-h-56 flex-col gap-1.5 overflow-y-auto",children:M.map(e=>(0,a.jsxs)("div",{className:"flex items-center justify-between gap-3 rounded border border-border bg-background px-2 py-1.5",children:[(0,a.jsx)("code",{className:"min-w-0 flex-1 truncate text-xs",title:e,children:e}),(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",onClick:()=>f?.(e),children:"Enable"})]},e))})]})]})}A().string.isRequired,A().string.isRequired,A().string,A().func.isRequired,A().func.isRequired,A().func,A().oneOf(["ok","error"]),A().bool,A().string.isRequired,A().object.isRequired,A().arrayOf(A().object),A().string,A().func.isRequired,A().func.isRequired,A().func.isRequired,A().func.isRequired,O.propTypes={providerStorageAlias:A().string.isRequired,providerDisplayAlias:A().string.isRequired,modelAliases:A().object.isRequired,customModels:A().arrayOf(A().object),copied:A().string,onCopy:A().func.isRequired,onDeleteAlias:A().func.isRequired,onAddCustomModel:A().func.isRequired,onDeleteCustomModel:A().func.isRequired,onRefreshModels:A().func,connections:A().arrayOf(A().shape({id:A().string,isActive:A().bool})).isRequired,isAnthropic:A().bool,disabledModelIds:A().arrayOf(A().string),onEnableModel:A().func};var I=s(70217);function D({until:e}){let[t,s]=(0,i.useState)("");return((0,i.useEffect)(()=>{let t=()=>{let t=new Date(e).getTime()-Date.now();if(t<=0)return void s("");let a=Math.floor(t/1e3);if(a<60)s(`${a}s`);else if(a<3600)s(`${Math.floor(a/60)}m ${a%60}s`);else{let e=Math.floor(a/3600),t=Math.floor(a%3600/60);s(`${e}h ${t}m`)}};t();let a=setInterval(t,1e3);return()=>clearInterval(a)},[e]),t)?(0,a.jsxs)("span",{className:"text-xs text-orange-500 font-mono",children:["⏱ ",t]}):null}function M({connection:e,isOAuth:t,isFirst:s,isLast:r,onMoveUp:l,onMoveDown:n,onToggleActive:o,onEdit:c,onDelete:m,onAllowlistHost:u=null,oneByOneStatus:p=null,autoPing:x=null}){let h=e.authType||(t?"oauth":"apikey"),f="oauth"===h,b="cookie"===h,g=e.name?.trim()||e.email?.trim()||e.displayName?.trim()||(f?"OAuth Account":b?"Cookie Account":"API Key"),y=e.name?.trim()&&e.email?.trim()&&e.name.trim()!==e.email.trim()?e.email.trim():e.name?.trim()&&e.displayName?.trim()&&e.name.trim()!==e.displayName.trim()?e.displayName.trim():null,v=/SSRF blocked|Blocked URL: (private IP|internal host)/i.test(e.lastError||""),j=(e=>{if(!e)return null;let t=String(e).trim();try{let e=t.match(/\{[\s\S]*\}$/);if(e){let s=JSON.parse(e[0]),a=s?.error?.message||s?.message||s?.error;"string"==typeof a&&a.trim()&&(t=a.trim())}}catch{}return(t=t.replace(/^\[\d+\]:\s*/,""),/not have a valid license|license of this product|license required/i.test(t))?{type:"license",title:"License Required",message:"No active Gemini Code Assist or Antigravity license found for this Google account. Visit antigravity.google to activate, or reconnect.",action:f?"reconnect":null}:/invalid_grant|token expired|credentials expired|expired or revoked|session expired/i.test(t)?{type:"auth",title:"Session Expired",message:"OAuth token expired or was revoked. Please reconnect.",action:f?"reconnect":null}:/rate limit|quota|429|resource has been exhausted/i.test(t)?{type:"quota",title:"Rate Limited",message:t||"Upstream rate limit reached.",action:null}:v?{type:"ssrf",title:"Network Guard",message:"SSRF guard blocked local/private IP address.",action:"allowlist"}:{type:"error",title:"Error",message:t,action:f?"reconnect":null}})(e.lastError),w=e.providerSpecificData?.connectionProxyEnabled===!0&&!!e.providerSpecificData?.connectionProxyUrl,k=w?`Proxy: ${e.providerSpecificData?.connectionProxyUrl}`:"",N=x?.provider==="codex"?"Auto-starts the next 5h Codex window after reset by sending a tiny gpt-5.5 request. Consumes a small amount of quota.":"When your 5h quota runs out, auto-sends a request the moment it resets so a new window starts right away.",C="";if(e.providerSpecificData?.connectionProxyUrl){let t=e.providerSpecificData?.connectionProxyUrl;try{let e=new URL(t);C=`${e.protocol}//${e.hostname}${e.port?`:${e.port}`:""}`}catch{C=t}}let S=e.providerSpecificData?.connectionNoProxy||"",$=w?"success":"default",[A,T]=(0,i.useState)(!1),E=Object.entries(e).filter(([e])=>e.startsWith("modelLock_")).map(([,e])=>e).filter(e=>!!e).sort()[0]||null;(0,i.useEffect)(()=>{let t=()=>{T(!!Object.entries(e).filter(([e])=>e.startsWith("modelLock_")).map(([,e])=>e).filter(e=>e&&new Date(e).getTime()>Date.now()).sort()[0])};t();let s=E?setInterval(t,1e3):null;return()=>{s&&clearInterval(s)}},[e,E]);let R="unavailable"!==e.testStatus||A?e.testStatus:"active",O=()=>p?"queued"===p.state?"queued":"testing"===p.state?"testing":"success"===p.state?"success":"failed"===p.state?p.error?`failed: ${p.error}`:"failed":null:null;return(0,a.jsx)("div",{className:`group flex min-w-0 flex-col gap-3 rounded-xl border border-border/60 bg-surface/40 p-3 transition-all hover:border-border hover:bg-surface/70 ${!1===e.isActive?"opacity-60":""}`,children:(0,a.jsxs)("div",{className:"flex min-w-0 flex-1 flex-col gap-2",children:[(0,a.jsxs)("div",{className:"flex min-w-0 items-center justify-between gap-3",children:[(0,a.jsxs)("div",{className:"flex min-w-0 items-center gap-2.5",children:[(0,a.jsxs)("div",{className:"flex shrink-0 flex-col",children:[(0,a.jsx)("button",{onClick:l,disabled:s,"aria-label":`Move ${g} up`,title:`Move ${g} up`,className:`p-0.5 rounded ${s?"text-text-muted/30 cursor-not-allowed":"hover:bg-sidebar text-text-muted hover:text-primary"}`,children:(0,a.jsx)("span",{className:"material-symbols-outlined text-sm","aria-hidden":"true",children:"keyboard_arrow_up"})}),(0,a.jsx)("button",{onClick:n,disabled:r,"aria-label":`Move ${g} down`,title:`Move ${g} down`,className:`p-0.5 rounded ${r?"text-text-muted/30 cursor-not-allowed":"hover:bg-sidebar text-text-muted hover:text-primary"}`,children:(0,a.jsx)("span",{className:"material-symbols-outlined text-sm","aria-hidden":"true",children:"keyboard_arrow_down"})})]}),(0,a.jsx)("div",{className:"flex size-8 shrink-0 items-center justify-center rounded-lg bg-surface-2 border border-border/40 text-text-muted",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]","aria-hidden":"true",children:b?"cookie":f?"lock":"key"})}),(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsx)("p",{className:"text-sm font-medium text-text-main truncate",children:g}),y&&(0,a.jsx)("p",{className:"text-xs text-text-muted truncate",children:y})]})]}),(0,a.jsxs)("div",{className:"flex items-center gap-2 shrink-0",children:[(0,a.jsxs)("div",{className:"flex items-center gap-1",children:[x&&(0,a.jsx)(d.m_,{text:N,children:(0,a.jsxs)("button",{onClick:()=>x.onToggle(!x.on),className:`flex items-center gap-1 rounded-lg px-2 py-1 text-xs transition-colors hover:bg-white/5 ${x.on?"text-primary bg-primary/10 font-medium":"text-text-muted hover:text-primary"}`,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"bolt"}),(0,a.jsx)("span",{className:"hidden sm:inline text-xs",children:"Auto-ping"})]})}),(0,a.jsxs)("button",{onClick:c,className:"flex items-center gap-1 rounded-lg px-2.5 py-1 text-xs text-text-muted hover:bg-white/5 hover:text-primary transition-colors",title:"Edit connection",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"edit"}),(0,a.jsx)("span",{className:"hidden sm:inline",children:"Edit"})]}),(0,a.jsxs)("button",{onClick:m,className:"flex items-center gap-1 rounded-lg px-2.5 py-1 text-xs text-red-400 hover:bg-red-500/10 transition-colors",title:"Delete connection",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"delete"}),(0,a.jsx)("span",{className:"hidden sm:inline",children:"Delete"})]})]}),(0,a.jsx)("div",{className:"h-4 w-px bg-border/60 mx-1"}),(0,a.jsx)(d.lM,{size:"sm",checked:e.isActive??!0,onChange:o,title:e.isActive??!0?"Disable connection":"Enable connection"})]})]}),(0,a.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-1.5 pl-0 sm:pl-10",children:[(0,a.jsx)(d.Ex,{variant:(0,I.g)(e.isActive,R),size:"sm",dot:!0,children:!1===e.isActive?"disabled":R||"Unknown"}),(0,a.jsx)(d.Ex,{variant:"default",size:"sm",children:f?"OAuth":b?"Cookie":"API Key"}),w&&(0,a.jsx)(d.Ex,{variant:$,size:"sm",children:"Proxy"}),A&&!1!==e.isActive&&(0,a.jsx)(D,{until:E}),(0,a.jsxs)("span",{className:"text-xs text-text-muted",children:["#",e.priority]}),e.globalPriority&&(0,a.jsxs)("span",{className:"text-xs text-text-muted",children:["Auto: ",e.globalPriority]}),O()&&(0,a.jsx)(d.Ex,{variant:p?"success"===p.state?"success":"failed"===p.state?"error":"testing"===p.state?"primary":"default":"default",size:"sm",children:O()})]}),j&&!1!==e.isActive&&(0,a.jsxs)("div",{className:"mt-1.5 flex min-w-0 flex-col sm:flex-row sm:items-center justify-between gap-2 rounded-lg border border-red-500/25 bg-red-500/8 px-3 py-2 text-xs text-red-600 dark:text-red-400 sm:ml-10",children:[(0,a.jsxs)("div",{className:"flex min-w-0 items-start sm:items-center gap-2",children:[(0,a.jsx)("span",{className:"material-symbols-outlined shrink-0 text-[16px] text-red-500 mt-0.5 sm:mt-0",children:"license"===j.type?"workspace_premium":"auth"===j.type?"key_off":"error"}),(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsxs)("span",{className:"font-semibold",children:[j.title,": "]}),(0,a.jsx)("span",{className:"break-words",children:j.message})]})]}),"reconnect"===j.action&&(0,a.jsxs)("button",{onClick:c,className:"inline-flex shrink-0 items-center justify-center gap-1 rounded-md bg-red-500/15 hover:bg-red-500/25 px-2.5 py-1 text-xs font-medium text-red-600 dark:text-red-300 transition-colors",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"refresh"}),"Reconnect"]}),"allowlist"===j.action&&u&&(0,a.jsxs)("button",{onClick:u,className:"inline-flex shrink-0 items-center justify-center gap-1 rounded-md border border-amber-500/40 bg-amber-500/10 px-2.5 py-1 text-xs font-medium text-amber-600 dark:text-amber-300 hover:bg-amber-500/20 transition-colors",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"verified_user"}),"Add to allow list"]})]}),w&&(0,a.jsxs)("div",{className:"mt-1 flex items-center gap-2 flex-wrap sm:ml-10",children:[(0,a.jsx)("span",{className:"max-w-full truncate text-[11px] text-text-muted sm:max-w-[420px]",title:k,children:k}),C&&(0,a.jsx)("code",{className:"max-w-full truncate rounded bg-black/5 px-1 py-0.5 font-mono text-[10px] text-text-muted dark:bg-white/5 sm:max-w-[260px]",children:C}),S&&(0,a.jsxs)("span",{className:"max-w-full truncate text-[11px] text-text-muted sm:max-w-[320px]",title:S,children:["no_proxy: ",S]})]})]})})}D.propTypes={until:A().string.isRequired},M.propTypes={connection:A().shape({id:A().string,name:A().string,email:A().string,displayName:A().string,modelLockUntil:A().string,testStatus:A().string,isActive:A().bool,lastError:A().string,priority:A().number,globalPriority:A().number,providerSpecificData:A().object}).isRequired,isOAuth:A().bool.isRequired,isFirst:A().bool.isRequired,isLast:A().bool.isRequired,onMoveUp:A().func.isRequired,onMoveDown:A().func.isRequired,onToggleActive:A().func.isRequired,onEdit:A().func.isRequired,onDelete:A().func.isRequired,onAllowlistHost:A().func,oneByOneStatus:A().shape({state:A().string,error:A().string}),autoPing:A().shape({on:A().bool,onToggle:A().func,provider:A().string})};let P=`name1|sk-key1
2
- name2|sk-key2
3
- sk-key-only-auto-named`;function U({isOpen:e,provider:t,providerName:s,isCompatible:r,isAnthropic:l,authType:n,authHint:o,website:m,error:u,onSave:p,onBulkDone:x,onClose:h}){let f="ollama-local"===t,b=t.startsWith("selfhosted-"),g="cookie"===n,y="xai"===t&&!g,v=g?"Cookie Value":"API Key",j=g?"grok-web"===t?"sso=xxxxx... or just the raw value":"eyJhbGciOi...":y?"xai-...":"",w="azure"===t,k="cloudflare-ai"===t,N=c.Q2?.[t]?.regions||null,C=c.Q2?.[t]?.defaultRegion||N?.[0]?.id||"",[S,$]=(0,i.useState)({name:"",apiKey:"",defaultModel:"",priority:1,ollamaHostUrl:"",baseUrl:""}),[A,T]=(0,i.useState)({azureEndpoint:"",apiVersion:"2024-10-01-preview",deployment:"",organization:""}),[E,R]=(0,i.useState)({accountId:""}),[O,I]=(0,i.useState)(C),[D,M]=(0,i.useState)(!1),[z,q]=(0,i.useState)(null),[_,F]=(0,i.useState)(!1),[J,L]=(0,i.useState)("single"),[K,B]=(0,i.useState)(""),[H,V]=(0,i.useState)(null),W=S.name.trim().length>0,G=S.apiKey.trim().length>0,Q=()=>b?{baseUrl:S.baseUrl.trim()}:f&&S.ollamaHostUrl.trim()?{baseUrl:S.ollamaHostUrl.trim()}:w?{azureEndpoint:A.azureEndpoint,apiVersion:A.apiVersion,deployment:A.deployment,organization:A.organization}:k?{accountId:E.accountId}:N&&O?{region:O}:void 0,Z=async()=>{let e=S.apiKey.trim();if(e){M(!0);try{let s=await fetch("/api/providers/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:t,apiKey:e,providerSpecificData:Q()})}),a=await s.json();q(a.valid?"success":"failed")}catch{q("failed")}finally{M(!1)}}},X=async()=>{if(!t)return;let e=S.name.trim(),s=S.apiKey.trim();if((f||b||s)&&(!b||S.baseUrl.trim())&&(f||e)&&(!r||S.defaultModel.trim())){F(!0);try{let a=!1;try{M(!0),q(null);let e=await fetch("/api/providers/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:t,apiKey:s,providerSpecificData:Q()})});a=!!(await e.json()).valid,q(a?"success":"failed")}catch{q("failed")}finally{M(!1)}await p({name:e||(f?"Ollama Local":""),apiKey:s,defaultModel:r?S.defaultModel.trim():void 0,priority:S.priority,testStatus:a?"active":"unknown",providerSpecificData:Q()})}finally{F(!1)}}},Y=async()=>{let e=K.split("\n").map(e=>e.trim()).filter(Boolean);if(!e.length)return;F(!0),V(null);let s=0,a=0;for(let i=0;i<e.length;i++){let r=e[i].split("|"),l=r.length>=2?r.slice(1).join("|").trim():r[0].trim();if(!l){a++;continue}let n=r.length>=2&&r[0].trim()||"Key",o=`${n} ${i+1}`;try{(await fetch("/api/providers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:t,apiKey:l,name:o,priority:1,testStatus:"unknown"})})).ok?s++:a++}catch{a++}}F(!1),V({success:s,failed:a}),s>0&&x&&x()};return t?(0,a.jsx)(d.aF,{isOpen:e,title:`Add ${s||t} ${v}`,onClose:h,children:(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[!b&&(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(d.$n,{size:"sm",variant:"single"===J?"primary":"ghost",onClick:()=>{L("single"),V(null)},children:"Single"}),(0,a.jsx)(d.$n,{size:"sm",variant:"bulk"===J?"primary":"ghost",onClick:()=>{L("bulk"),V(null)},children:"Bulk Add"})]}),"bulk"===J&&!b&&(0,a.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,a.jsxs)("p",{className:"text-xs text-text-muted",children:["One key per line. Format: ",(0,a.jsx)("code",{children:"name|apiKey"})," or just ",(0,a.jsx)("code",{children:"apiKey"})," (auto-named by index)."]}),(0,a.jsx)("textarea",{className:"w-full rounded border border-accent/30 bg-sidebar p-2 text-sm font-mono resize-y min-h-[140px] focus:outline-none focus:ring-1 focus:ring-primary",placeholder:P,value:K,onChange:e=>B(e.target.value)}),H&&(0,a.jsxs)("div",{className:`text-sm font-medium ${H.failed>0?"text-yellow-400":"text-green-400"}`,children:["✓ ",H.success," added",H.failed>0?`, ✗ ${H.failed} failed`:""]}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(d.$n,{onClick:Y,fullWidth:!0,disabled:_||!K.trim(),children:_?"Adding...":"Add All Keys"}),(0,a.jsx)(d.$n,{onClick:h,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]}),("single"===J||b)&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(d.pd,{label:"Name",value:S.name,onChange:e=>$({...S,name:e.target.value}),placeholder:f?"Ollama Local":"Production Key"}),b&&(0,a.jsx)(d.pd,{label:"Base URL",value:S.baseUrl,onChange:e=>$({...S,baseUrl:e.target.value}),placeholder:"selfhosted-stt"===t?"http://localhost:8080/v1/audio/transcriptions":"selfhosted-tts"===t?"http://localhost:8880":"http://localhost:8080/v1"}),f&&(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(d.pd,{label:"Ollama Host URL",value:S.ollamaHostUrl,onChange:e=>$({...S,ollamaHostUrl:e.target.value}),placeholder:"http://localhost:11434",className:"flex-1"}),(0,a.jsx)("div",{className:"pt-6",children:(0,a.jsx)(d.$n,{onClick:Z,disabled:D||_,variant:"secondary",children:D?"Checking...":"Check"})})]}),!f&&(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(d.pd,{label:b?"API Key (optional)":v,type:g?"text":"password",autoComplete:"off",value:S.apiKey,onChange:e=>$({...S,apiKey:e.target.value}),placeholder:j,className:"flex-1"}),!b&&(0,a.jsx)("div",{className:"pt-6",children:(0,a.jsx)(d.$n,{onClick:Z,disabled:!S.apiKey||D||_,variant:"secondary",children:D?"Checking...":"Check"})})]}),y&&(0,a.jsx)("p",{className:"text-xs text-text-muted",children:"Use a direct xAI API key from console.x.ai. This is separate from Grok Build OAuth."}),g&&o&&(0,a.jsxs)("p",{className:"text-xs text-text-muted",children:[o,m&&(0,a.jsxs)(a.Fragment,{children:[" ",(0,a.jsxs)("a",{href:m,target:"_blank",rel:"noopener noreferrer",className:"text-primary underline",children:["Open ",m.replace(/^https?:\/\//,"")]})]})]}),N&&(0,a.jsx)(d.l6,{label:"Region",value:O,onChange:e=>I(e.target.value),options:N.map(e=>({value:e.id,label:e.label}))}),r&&(0,a.jsx)(d.pd,{label:"Default Model",value:S.defaultModel,onChange:e=>$({...S,defaultModel:e.target.value}),placeholder:l?"claude-3-5-sonnet-latest":"gpt-4o-mini"}),f&&(0,a.jsxs)("p",{className:"text-xs text-text-muted",children:["Leave blank to use ",(0,a.jsx)("code",{children:"http://localhost:11434"}),". For remote Ollama, enter the full host URL (e.g. ",(0,a.jsx)("code",{children:"http://192.168.1.10:11434"}),")."]}),z&&(0,a.jsx)(d.Ex,{variant:"success"===z?"success":"error",children:"success"===z?"Valid":"Invalid"}),u&&(0,a.jsx)("p",{className:"text-xs text-red-500 break-words",children:u}),r&&(0,a.jsx)("p",{className:"text-xs text-text-muted",children:"Enter the model ID exactly as your compatible endpoint expects it. This model will be saved as the connection default."}),k&&(0,a.jsxs)("div",{className:"bg-sidebar/50 p-4 rounded-lg border border-accent/20",children:[(0,a.jsx)("h3",{className:"font-semibold mb-3 text-sm",children:"Cloudflare Workers AI"}),(0,a.jsx)(d.pd,{label:"Account ID",value:E.accountId,onChange:e=>R({...E,accountId:e.target.value}),placeholder:"abc123def456..."}),(0,a.jsxs)("p",{className:"text-xs text-text-muted mt-2",children:["Find your Account ID in the right sidebar of ",(0,a.jsx)("a",{href:"https://dash.cloudflare.com",target:"_blank",rel:"noopener noreferrer",className:"text-primary underline",children:"dash.cloudflare.com"})]})]}),w&&(0,a.jsxs)("div",{className:"bg-sidebar/50 p-4 rounded-lg border border-accent/20",children:[(0,a.jsx)("h3",{className:"font-semibold mb-3 text-sm",children:"Azure OpenAI Configuration"}),(0,a.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,a.jsx)(d.pd,{label:"Azure Endpoint",value:A.azureEndpoint,onChange:e=>T({...A,azureEndpoint:e.target.value}),placeholder:"https://your-resource.openai.azure.com"}),(0,a.jsx)(d.pd,{label:"Deployment Name",value:A.deployment,onChange:e=>T({...A,deployment:e.target.value}),placeholder:"gpt-4"}),(0,a.jsx)(d.pd,{label:"API Version",value:A.apiVersion,onChange:e=>T({...A,apiVersion:e.target.value}),placeholder:"2024-10-01-preview"}),(0,a.jsx)(d.pd,{label:"Organization",value:A.organization,onChange:e=>T({...A,organization:e.target.value}),placeholder:"Organization ID"})]})]}),(0,a.jsx)(d.pd,{label:"Priority",type:"number",min:1,value:S.priority,onChange:e=>$({...S,priority:Number.parseInt(e.target.value)||1})}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(d.$n,{onClick:X,fullWidth:!0,disabled:_||!f&&!b&&(!W||!G)||b&&(!W||!S.baseUrl.trim())||r&&!S.defaultModel.trim()||w&&(!A.azureEndpoint||!A.deployment||!A.organization)||k&&!E.accountId,children:_?"Saving...":"Save"}),(0,a.jsx)(d.$n,{onClick:h,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})]})}):null}function z({isOpen:e,node:t,onSave:s,onClose:r,isAnthropic:l}){let[n,o]=(0,i.useState)({name:"",apiType:"chat",baseUrl:"https://api.openai.com/v1"}),[c,m]=(0,i.useState)(!1),[u,p]=(0,i.useState)(""),[x,h]=(0,i.useState)(""),[f,b]=(0,i.useState)(!1),[g,y]=(0,i.useState)(null),v=function(e){try{return["http:","https:"].includes(new URL(e).protocol)}catch{return!1}}(n.baseUrl.trim());(0,i.useEffect)(()=>{t&&(o({name:t.name||"",apiType:t.apiType||"chat",baseUrl:t.baseUrl||(l?"https://api.anthropic.com/v1":"https://api.openai.com/v1")}),y(null),p(""),h(""))},[t,l]);let j=async()=>{if(n.name.trim()&&v){m(!0);try{let e={name:n.name.trim(),baseUrl:n.baseUrl.trim()};l||(e.apiType=n.apiType),await s(e)}finally{m(!1)}}},w=async()=>{b(!0);try{let e=await fetch("/api/provider-nodes/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:n.baseUrl,apiKey:u,type:l?"anthropic-compatible":"openai-compatible",modelId:x.trim()||void 0})}),t=await e.json();y(t.valid?"success":"failed")}catch{y("failed")}finally{b(!1)}};return t?(0,a.jsx)(d.aF,{isOpen:e,title:`Edit ${l?"Anthropic":"OpenAI"} Compatible`,onClose:r,children:(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,a.jsx)(d.pd,{label:"Name",value:n.name,onChange:e=>o({...n,name:e.target.value}),placeholder:`${l?"Anthropic":"OpenAI"} Compatible`,hint:"Friendly label for this provider."}),!l&&(0,a.jsx)(d.l6,{label:"API Type",options:[{value:"chat",label:"Chat Completions"},{value:"responses",label:"Responses API"}],value:n.apiType,onChange:e=>o({...n,apiType:e.target.value})}),(0,a.jsx)(d.pd,{label:"Base URL",value:n.baseUrl,onChange:e=>o({...n,baseUrl:e.target.value}),placeholder:l?"https://api.anthropic.com/v1":"https://api.openai.com/v1",hint:`Base URL ending in /v1 for your ${l?"Anthropic":"OpenAI"}-compatible API.`}),t.prefix?(0,a.jsxs)("p",{className:"text-xs text-text-muted",children:["Model IDs use prefix ",(0,a.jsx)("code",{className:"bg-sidebar px-1 rounded font-mono",children:t.prefix})," ","(auto-assigned; stable so combos keep working)."]}):null,(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(d.pd,{label:"API Key (for Check)",type:"password",autoComplete:"off",value:u,onChange:e=>p(e.target.value),className:"flex-1"}),(0,a.jsx)("div",{className:"pt-6",children:(0,a.jsx)(d.$n,{onClick:w,disabled:!u||f||!v,variant:"secondary",children:f?"Checking...":"Check"})})]}),(0,a.jsx)(d.pd,{label:"Model ID (optional)",value:x,onChange:e=>h(e.target.value),placeholder:"e.g. my-model-id",hint:"If the provider has no /models endpoint, test with a model ID."}),g&&(0,a.jsx)(d.Ex,{variant:"success"===g?"success":"error",children:"success"===g?"Valid":"Invalid"}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(d.$n,{onClick:j,fullWidth:!0,disabled:!n.name.trim()||!v||c,children:c?"Saving...":"Save"}),(0,a.jsx)(d.$n,{onClick:r,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})}):null}function q({isOpen:e,providerAlias:t,providerDisplayAlias:s,onSave:r,onClose:l}){let[n,o]=(0,i.useState)(""),[c,m]=(0,i.useState)(null),[u,p]=(0,i.useState)(""),[x,h]=(0,i.useState)(!1);(0,i.useEffect)(()=>{e&&(o(""),m(null),p(""))},[e]);let f=e=>{let s=`${t}/`;return e.startsWith(s)?e.slice(s.length):e},b=async()=>{let e=f(n.trim());if(e){m("testing"),p("");try{let s=await fetch("/api/models/test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:`${t}/${e}`})}),a=await s.json();m(a.ok?"ok":"error"),p(a.error||"")}catch(e){m("error"),p(e.message)}}},g=async()=>{let e=f(n.trim());if(e&&!x){h(!0);try{await r(e)}finally{h(!1)}}};return(0,a.jsx)(d.aF,{isOpen:e,onClose:l,title:"Add Custom Model",children:(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"text-sm font-medium mb-1.5 block",children:"Model ID"}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)("input",{type:"text",value:n,onChange:e=>{o(e.target.value),m(null),p("")},onKeyDown:e=>{"Enter"===e.key&&b()},placeholder:"e.g. claude-opus-4-5",className:"flex-1 px-3 py-2 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary",autoFocus:!0}),(0,a.jsx)(d.$n,{variant:"secondary",icon:"science",loading:"testing"===c,onClick:b,disabled:!n.trim()||"testing"===c,children:"testing"===c?"Testing...":"Test"})]}),(0,a.jsxs)("p",{className:"text-xs text-text-muted mt-1",children:["Sent to provider as: ",(0,a.jsx)("code",{className:"font-mono bg-sidebar px-1 rounded",children:f(n.trim())||"model-id"})]})]}),"ok"===c&&(0,a.jsxs)("div",{className:"flex items-center gap-2 text-sm text-green-600",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-base",children:"check_circle"}),"Model is reachable"]}),"error"===c&&(0,a.jsxs)("div",{className:"flex items-start gap-2 text-sm text-red-500",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-base shrink-0",children:"cancel"}),(0,a.jsx)("span",{children:u||"Model not reachable"})]}),(0,a.jsxs)("div",{className:"flex gap-2 pt-1",children:[(0,a.jsx)(d.$n,{onClick:l,variant:"ghost",fullWidth:!0,size:"sm",children:"Cancel"}),(0,a.jsx)(d.$n,{onClick:g,fullWidth:!0,size:"sm",disabled:!n.trim()||x,children:x?"Adding...":"Add Model"})]})]})})}U.propTypes={isOpen:A().bool.isRequired,provider:A().string,providerName:A().string,isCompatible:A().bool,isAnthropic:A().bool,authType:A().string,authHint:A().string,website:A().string,error:A().string,onSave:A().func.isRequired,onBulkDone:A().func,onClose:A().func.isRequired},z.propTypes={isOpen:A().bool.isRequired,node:A().shape({id:A().string,name:A().string,prefix:A().string,apiType:A().string,baseUrl:A().string}),onSave:A().func.isRequired,onClose:A().func.isRequired,isAnthropic:A().bool},q.propTypes={isOpen:A().bool.isRequired,providerAlias:A().string.isRequired,providerDisplayAlias:A().string.isRequired,onSave:A().func.isRequired,onClose:A().func.isRequired};let _=`[
4
- {
5
- "accessToken": "eyJhbGc...",
6
- "refreshToken": "rt_...",
7
- "idToken": "eyJhbGc...",
8
- "email": "user@example.com"
9
- }
10
- ]`;function F({isOpen:e,onClose:t,onSuccess:s}){let[r,l]=(0,i.useState)(""),[n,o]=(0,i.useState)(!1),[c,m]=(0,i.useState)(""),[u,p]=(0,i.useState)(null),x=()=>{n||(l(""),m(""),p(null),t())},h=async()=>{var e;let t;m(""),p(null);let a=r.trim();if(!a)return;try{t=JSON.parse(a)}catch(e){m(`${(0,w.Tl)("Invalid JSON")}: ${e.message}`);return}let i=Array.isArray(e=t)?e:e&&"object"==typeof e?Array.isArray(e.accounts)?e.accounts:[e]:null;if(!i||0===i.length)return void m((0,w.Tl)("No accounts found in input"));o(!0);try{let e=await fetch("/api/oauth/codex/bulk-import",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({accounts:i})}),t=await e.json();if(!e.ok)return void m(t?.error||`Request failed: ${e.status}`);p(t),t.success>0&&"function"==typeof s&&s()}catch(e){m(e.message||(0,w.Tl)("Request failed"))}finally{o(!1)}},f=u?.results?.filter(e=>!e.ok)||[];return(0,a.jsx)(d.aF,{isOpen:e,title:(0,w.Tl)("Bulk Add Codex Accounts"),onClose:x,children:(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,a.jsx)("p",{className:"text-xs text-text-muted",children:(0,w.Tl)("Paste an array of codex account JSON objects. Each must include accessToken (and ideally refreshToken, idToken).")}),(0,a.jsx)("textarea",{className:"w-full rounded border border-accent/30 bg-sidebar p-2 text-sm font-mono resize-y min-h-[240px] focus:outline-none focus:ring-1 focus:ring-primary",placeholder:_,value:r,onChange:e=>l(e.target.value),disabled:n}),c&&(0,a.jsx)("p",{className:"text-xs text-red-500 break-words",children:c}),u&&(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,a.jsxs)("div",{className:`text-sm font-medium ${u.failed>0?"text-yellow-400":"text-green-400"}`,children:["✓ ",u.success," ",(0,w.Tl)("added"),u.failed>0?`, ✗ ${u.failed} ${(0,w.Tl)("failed")}`:""]}),f.length>0&&(0,a.jsx)("ul",{className:"rounded border border-accent/20 bg-sidebar/50 p-2 text-xs font-mono max-h-40 overflow-y-auto",children:f.map(e=>(0,a.jsxs)("li",{className:"text-red-400",children:["[",e.index,"] ",e.error]},e.index))})]}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(d.$n,{onClick:h,fullWidth:!0,disabled:n||!r.trim(),children:n?(0,w.Tl)("Importing..."):(0,w.Tl)("Import All")}),(0,a.jsx)(d.$n,{onClick:x,variant:"ghost",fullWidth:!0,disabled:n,children:(0,w.Tl)("Close")})]})]})})}F.propTypes={isOpen:A().bool.isRequired,onClose:A().func.isRequired,onSuccess:A().func};var J=s(77251);function L({connectionId:e,providerAlias:t,models:s,jobSnapshot:r,onComplete:l,onStarted:n,onClose:o}){let[c,m]=(0,i.useState)(4),[u,p]=(0,i.useState)(50),[x,h]=(0,i.useState)(Math.round(20)),[f,b]=(0,i.useState)(!1),[g,y]=(0,i.useState)(null),[v,j]=(0,i.useState)(null),[w,k]=(0,i.useState)(""),[N,C]=(0,i.useState)(""),[S,$]=(0,i.useState)(""),A=(0,i.useRef)({onComplete:l,onStarted:n}),T=(0,i.useRef)(null),E=(0,i.useRef)(e),R=(0,i.useRef)(null),O=s?.length||0,I=(0,i.useMemo)(()=>`max concurrency 16 \xb7 batch 200 \xb7 timeout ${60}s`,[]);function D(e){if(e){if("idle"===e.status){R.current=null,b(!1);return}if(y({done:e.done||0,total:e.total||0,ok:e.ok||0,dead:e.dead||0,retryable:e.retryable||0,skippedDead:e.skippedDead||0,skippedDup:e.skippedDup||0}),"running"===e.status&&(R.current=e.connectionId||E.current,T.current=null,b(!0)),e.currentRange&&C(`Probing ${e.currentRange.from}–${e.currentRange.to} of ${e.total}…`),e.error&&k(e.error),"done"===e.status||"cancelled"===e.status||"error"===e.status){R.current=null,b(!1);let t={ok:e.ok||0,dead:e.dead||0,retryable:e.retryable||0,tested:e.done||0,skippedDead:e.skippedDead||0,skippedDup:e.skippedDup||0,cancelled:"cancelled"===e.status,retryableAuthOnly:!0===e.retryableAuthOnly};j(t),C("cancelled"===e.status?"Cancelled (partial results saved).":"error"===e.status?"Stopped.":"Done.");let s=`${e.startedAt||"unknown"}:${e.status}`;T.current!==s&&(T.current=s,A.current.onComplete?.(t))}}}async function M(){if(f||!e||0===O)return;b(!0),k(""),j(null),C("Starting…");let a={concurrency:Math.max(1,Math.min(16,Number(c)||4)),batchSize:Math.max(1,Math.min(200,Number(u)||50)),timeoutMs:Math.max(1e3,Math.min(6e4,1e3*(Number(x)||20)))};R.current=e;try{let i=await fetch(`/api/providers/${e}/model-probes/verify/start`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({models:s,providerAlias:t,...a,timeoutMs:a.timeoutMs})}),r=await i.json().catch(()=>({}));if(E.current!==e){R.current=null,b(!1);return}if(!i.ok){R.current=null,k(r.error||"Failed to start"),b(!1);return}A.current.onStarted?.(r),D(r),"running"!==r.status&&b(!1)}catch(e){R.current=null,k(e?.message||"Verify failed"),b(!1)}}async function P(){let t=R.current||e;await fetch(`/api/providers/${t}/model-probes/verify/cancel`,{method:"POST"}).catch(()=>{})}async function U(s){if(!e)return;let a="retryable"===s,i=a?Number(v?.retryable||0):Number(v?.dead||0);if(!a||await (0,J.l)({title:"Remove retry-failed models?",message:`Review ${i} retryable result(s) and remove the eligible models? Timeouts, rate limits, network failures, and provider errors may be temporary. Credential failures are kept. Removed models can be enabled or imported again later.`,confirmText:"Remove eligible"})){$(s),k(""),C(`Removing ${a?"retry-failed":"dead"} models…`);try{let i=await fetch(`/api/providers/${e}/model-probes/remove-unavailable`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerAlias:t,kind:"llm",status:s})}),r=await i.json().catch(()=>({}));if(!i.ok)return void k(r.error||"Remove failed");let l=Number(r.removed||0),n=Number(r.kept||0),o=v?{...v,[a?"retryable":"dead"]:n,...a?{retryableAuthOnly:n>0}:{}}:v;j(o),C(`Removed ${l} ${a?"retry-failed":"dead"} model(s).`+(n>0?` Kept ${n} credential failure(s).`:"")),A.current.onComplete?.({...o||{},removed:l,kept:n,removedStatus:s})}catch(e){k(e?.message||"Remove failed")}finally{$("")}}}async function z(){if(!e)return;let t=await fetch(`/api/providers/${e}/model-probes/cache`,{method:"DELETE"}),s=await t.json().catch(()=>({}));t.ok?(C(`Cleared probe cache (${s.cleared||0} rows). Next verify will re-test everything.`),j(null),y(null),A.current.onComplete?.({cacheCleared:!0,cleared:s.cleared||0})):k(s.error||"Clear cache failed")}(0,i.useEffect)(()=>{A.current={onComplete:l,onStarted:n},E.current=e}),(0,i.useEffect)(()=>{D(r)},[r]);let q=g?.total?Math.min(100,Math.round(g.done/g.total*100)):0;return(0,a.jsxs)("div",{className:"mb-4 rounded-lg border border-border bg-sidebar/40 p-3 space-y-3",children:[(0,a.jsxs)("div",{className:"flex items-start justify-between gap-2",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("h3",{className:"text-sm font-semibold text-text-main",children:"Verify models"}),(0,a.jsxs)("p",{className:"text-[11px] text-text-muted mt-0.5",children:["Batch-ping availability and latency. Dead = permanently unavailable (missing, blocked, or deprecated) and can be removed; retry = transient (timeout/429/5xx). Known-dead models are skipped until you Clear cache. Caps: ",I,"."]})]}),o&&(0,a.jsx)("button",{type:"button",onClick:o,className:"p-1 text-text-muted hover:text-text-main rounded",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"close"})})]}),(0,a.jsxs)("div",{className:"flex flex-wrap gap-3 items-end",children:[(0,a.jsxs)("label",{className:"text-xs text-text-muted",children:["Concurrency",(0,a.jsx)("input",{type:"number",min:1,max:16,value:c,disabled:f,onChange:e=>m(e.target.value),className:"mt-1 block w-20 rounded-md border border-border bg-background px-2 py-1 text-xs"})]}),(0,a.jsxs)("label",{className:"text-xs text-text-muted",children:["Batch size",(0,a.jsx)("input",{type:"number",min:1,max:200,value:u,disabled:f,onChange:e=>p(e.target.value),className:"mt-1 block w-20 rounded-md border border-border bg-background px-2 py-1 text-xs"})]}),(0,a.jsxs)("label",{className:"text-xs text-text-muted",children:["Timeout (s)",(0,a.jsx)("input",{type:"number",min:1,max:60,value:x,disabled:f,onChange:e=>h(e.target.value),className:"mt-1 block w-20 rounded-md border border-border bg-background px-2 py-1 text-xs"})]}),(0,a.jsxs)("div",{className:"flex gap-2",children:[f?(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",icon:"stop",onClick:P,children:"Cancel"}):(0,a.jsx)(d.$n,{size:"sm",icon:"science",onClick:M,disabled:!e||0===O,children:"Start"}),(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",icon:"delete_sweep",onClick:z,disabled:f,children:"Clear cache"})]})]}),g&&(0,a.jsxs)("div",{className:"space-y-1",children:[(0,a.jsx)("div",{className:"h-1.5 w-full rounded-full bg-border overflow-hidden",children:(0,a.jsx)("div",{className:"h-full bg-primary transition-all",style:{width:`${q}%`}})}),(0,a.jsxs)("p",{className:"text-[11px] text-text-muted flex flex-wrap gap-x-2",children:[(0,a.jsxs)("span",{title:"Models probed this run",children:[g.done,"/",g.total," tested"]}),(0,a.jsxs)("span",{title:"Reachable",children:["\xb7 ok ",g.ok]}),(0,a.jsxs)("span",{title:"Permanently unavailable this run (missing, blocked, or deprecated)",children:["\xb7 dead ",g.dead]}),(0,a.jsxs)("span",{title:"Transient failure this run (timeout / 429 / 5xx / network); re-testable",children:["\xb7 retry ",g.retryable]}),g.skippedDead?(0,a.jsxs)("span",{title:"Not probed — cache already marks them dead. Clear cache to re-test.",children:["\xb7 skipped known-dead ",g.skippedDead]}):null,g.skippedDup?(0,a.jsxs)("span",{title:"Duplicate ids collapsed",children:["\xb7 dupes ",g.skippedDup]}):null]})]}),N&&(0,a.jsx)("p",{className:"text-xs text-text-muted",children:N}),w&&(0,a.jsx)("p",{className:"text-xs text-red-500 break-words",children:w}),v&&(0,a.jsxs)("div",{className:"flex flex-wrap items-center gap-2 pt-1",children:[(0,a.jsxs)("span",{className:"text-xs text-text-main",children:["Summary: ",v.ok," ok \xb7 ",v.dead," dead \xb7 ",v.retryable," retry",v.skippedDead?` \xb7 ${v.skippedDead} skipped known-dead`:"",v.cancelled?" \xb7 cancelled":""]}),v.dead>0&&(0,a.jsxs)(d.$n,{size:"sm",variant:"primary",icon:"delete_sweep",onClick:()=>U("dead"),disabled:f||!!S,loading:"dead"===S,children:["Remove ",v.dead," dead"]}),v.retryable>0&&!v.retryableAuthOnly&&(0,a.jsxs)(d.$n,{size:"sm",variant:"danger",icon:"delete_sweep",onClick:()=>U("retryable"),disabled:f||!!S,loading:"retryable"===S,children:["Remove ",v.retryable," retry failures"]})]})]})}L.propTypes={connectionId:A().string,providerAlias:A().string,models:A().arrayOf(A().object),jobSnapshot:A().object,onComplete:A().func,onStarted:A().func,onClose:A().func};var K=s(36861),B=s(48874),H=s(53578);let V={claude:"claudeAutoPing",codex:"codexAutoPing"};function W(){let e,t,s,l=(0,r.useParams)(),u=(0,r.useRouter)(),p=l.id,{getCaps:x}=(0,j.y)(),[h,f]=(0,i.useState)([]),[b,g]=(0,i.useState)([]),[k,$]=(0,i.useState)(!0),[A,R]=(0,i.useState)(null),[I,D]=(0,i.useState)(!1),[P,_]=(0,i.useState)(!1),[J,W]=(0,i.useState)(!1),[G,Q]=(0,i.useState)(""),[Z,X]=(0,i.useState)(!1),[Y,ee]=(0,i.useState)(!1),[et,es]=(0,i.useState)(!1),[ea,ei]=(0,i.useState)(null),[er,el]=(0,i.useState)({}),[en,eo]=(0,i.useState)([]),[ed,ec]=(0,i.useState)(!1),[em,eu]=(0,i.useState)({}),[ep,ex]=(0,i.useState)(""),[eh,ef]=(0,i.useState)(()=>new Set),[eb,eg]=(0,i.useState)(!1),[ey,ev]=(0,i.useState)(null),[ej,ew]=(0,i.useState)(""),[ek,eN]=(0,i.useState)(!1),[eC,eS]=(0,i.useState)("30"),[e$,eA]=(0,i.useState)("auto"),[eT,eE]=(0,i.useState)({enabled:!1,connections:{}}),[eR,eO]=(0,i.useState)([]),[eI,eD]=(0,i.useState)([]),[eM,eP]=(0,i.useState)([]),[eU,ez]=(0,i.useState)([]),[eq,e_]=(0,i.useState)(null),[eF,eJ]=(0,i.useState)(!1),[eL,eK]=(0,i.useState)(!1),[eB,eH]=(0,i.useState)(!1),[eV,eW]=(0,i.useState)(null),[eG,eQ]=(0,i.useState)({}),[eZ,eX]=(0,i.useState)(null),eY=(0,i.useRef)(!1),e0=(0,i.useRef)(null),e1=(0,i.useRef)(0),e2=(0,i.useRef)(0),[e5,e3]=(0,i.useState)(!1),[e4,e6]=(0,i.useState)(""),[e8,e7]=(0,i.useState)(!1),[e9,te]=(0,i.useState)(null),[tt,ts]=(0,i.useState)({}),[ta,ti]=(0,i.useState)({}),[tr,tl]=(0,i.useState)("all"),{copied:tn,copy:to}=(0,v.C)(),td="ag_risk_confirmed",tc=A?{id:A.id,name:A.name||("anthropic-compatible"===A.type?"Anthropic Compatible":"OpenAI Compatible"),color:"anthropic-compatible"===A.type?"#D97757":"#10A37F",textIcon:"anthropic-compatible"===A.type?"AC":"OC",apiType:A.apiType,baseUrl:A.baseUrl,type:A.type}:c.zN[p]||c.fg[p]||c.IS[p]||c.nJ[p]||c.br[p],tm=tc?.authModes||[],tu=!!c.zN[p]||!!c.IS[p]||tm.includes("oauth"),tp=!!c.fg[p]||tm.includes("apikey"),tx=!!c.IS[p]?.noAuth,th=(0,m.KC)(p),tf=(()=>{let e=new Map(th.map(e=>[e.id,e]));for(let t of eI)t?.id&&e.set(t.id,{...e.get(t.id),...t});return[...e.values()]})(),tb=(0,c.wG)(p),tg=(0,c.mq)(p),ty=(0,c.gb)(p),tv=tg||ty,tj=h.some(e=>!1!==e.isActive),tw=function({isCompatible:e,hasActiveConnection:t}){let s=!e,a=!e;return{showToolbar:s||t||a,showImport:s,showVerify:t,showBulkControls:a}}({isCompatible:tv,hasActiveConnection:tj}),tk=!tv&&tu&&tp,tN="xai"===p?"Grok Build OAuth":"OAuth",tC="xai"===p?"xAI API Key":"API Key",tS=()=>{D(!0)},t$=()=>{"antigravity"===p&&"true"!==window.localStorage.getItem(td)?eJ(!0):tu?tS():(Q(""),W(!0))},tA=()=>{Q(""),W(!0)},tT=()=>{tu?t$():tA()},tE=e=>{if(!e$||"auto"===e$)return null;let t=y(p,e);return t&&t.includes(e$)?e$:null},tR=(()=>{let e=new Set;for(let t of tf){let s=y(p,t.id);s&&s.forEach(t=>{"none"!==t&&e.add(t)})}return e.size?["auto",...e]:null})(),tO=tv?p:tb,tI=tv?A?.prefix||p:tb,tD=(0,C.Iz)(eU,tO),tM=e=>(0,C.uJ)(tD,e,tO),tP=(0,i.useCallback)(async()=>{try{let e=await fetch(`/api/models/disabled?providerAlias=${encodeURIComponent(tO)}`,{cache:"no-store"}),t=await e.json();e.ok&&ez(t.ids||[])}catch(e){(0,E.s)("Error fetching disabled models:",e)}},[tO]),tU=async e=>{try{await (0,B.x)("/api/models/disabled",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerAlias:tO,ids:[e]})}),await tP()}catch(e){(0,E.s)("Error disabling model:",e)}},tz=async e=>{try{return await (0,B.x)(`/api/models/disabled?providerAlias=${encodeURIComponent(tO)}&id=${encodeURIComponent(e)}`,{method:"DELETE"}),await tP(),!0}catch(e){return(0,E.s)("Error enabling model:",e),!1}},tq=async e=>{e.length&&e_({title:"Disable All Models",message:`Disable all ${e.length} model(s)?`,onConfirm:async()=>{e_(null);try{await (0,B.x)("/api/models/disabled",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerAlias:tO,ids:e})}),await tP()}catch(e){(0,E.s)("Error disabling all models:",e)}}})},t_=async()=>{try{await (0,B.x)(`/api/models/disabled?providerAlias=${encodeURIComponent(tO)}`,{method:"DELETE"}),await tP()}catch(e){(0,E.s)("Error enabling all models:",e)}},tF=(0,i.useCallback)(async()=>{try{let e=await fetch("/api/models/alias"),t=await e.json();e.ok&&el(t.aliases||{})}catch(e){(0,E.s)("Error fetching aliases:",e)}},[]),tJ=(0,i.useCallback)(async()=>{try{let e=await fetch("/api/models/custom",{cache:"no-store"}),t=await e.json();e.ok&&eo(t.models||[])}catch(e){(0,E.s)("Error fetching custom models:",e)}},[]);(0,i.useEffect)(()=>{"kilocode"===p&&fetch("/api/providers/kilo/free-models").then(e=>e.json()).then(e=>{e.models?.length&&eP(e.models)}).catch(()=>{})},[p]);let tL=(0,i.useCallback)(async()=>{try{let[e,t,s]=await Promise.all([fetch("/api/providers",{cache:"no-store"}),fetch("/api/provider-nodes",{cache:"no-store"}),fetch("/api/settings",{cache:"no-store"})]),a=await e.json(),i=await t.json(),r=s.ok?await s.json():{};if(e.ok){let e=(a.connections||[]).filter(e=>e.provider===p);f(e)}let l=(r.providerStrategies||{})[p]||{};ev(l.fallbackStrategy||null),ew(null!=l.stickyRoundRobinLimit?String(l.stickyRoundRobinLimit):"1");let n=l.accountScheduler||{};eN(!0===n.enabled),eS(String(Math.max(1,Math.round((n.sessionAffinityTtlSeconds||1800)/60))));let o=(r.providerThinking||{})[p]||{};eA(o.mode||"auto");let d=V[p],c=d&&r[d]||{};if(eE({enabled:!0===c.enabled,connections:c.connections||{}}),t.ok){let e=(i.nodes||[]).find(e=>e.id===p)||null;if(!e&&tv)for(let t=0;t<3;t+=1){await new Promise(e=>setTimeout(e,150));let t=await fetch("/api/provider-nodes",{cache:"no-store"});if(t.ok&&(e=((await t.json()).nodes||[]).find(e=>e.id===p)||null))break}R(e)}}catch(e){(0,E.s)("Error fetching connections:",e)}finally{$(!1)}},[p,tv]),tK=(0,i.useCallback)(async(e=null)=>{let t=++e2.current,s=e?h.find(t=>t.id===e&&!1!==t.isActive):h.find(e=>b.includes(e.id)&&!1!==e.isActive)||h.find(e=>!1!==e.isActive);if(!s){ti({}),ts({});return}try{let e=await fetch(`/api/providers/${s.id}/model-probes`,{cache:"no-store"});if(!e.ok)return;let a=await e.json().catch(()=>({})),i={},r={};for(let e of a.probes||[])i[e.modelId]="ok"===e.status?"ok":"dead"===e.status?"dead":"retry",null!=e.latencyMs&&(r[e.modelId]=e.latencyMs);if(t!==e2.current)return;ti(i),ts(r)}catch{}},[h,b]),tB=async e=>{try{let t=await fetch(`/api/provider-nodes/${p}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),s=await t.json();t.ok?(R(s.node),await tL(),es(!1)):(0,E.s)(s?.error||"Failed to update provider node")}catch(e){(0,E.s)("Error updating provider node:",e)}},tH=async(e,t)=>{try{return await (0,H.T)(p,s=>{let a={...s};return e?a.fallbackStrategy=e:delete a.fallbackStrategy,"round-robin"===e&&""!==t?a.stickyRoundRobinLimit=Number(t)||3:e||delete a.stickyRoundRobinLimit,a}),!0}catch(e){return(0,E.s)("Error saving provider strategy:",e),!1}},tV=async(e,t)=>{let s=Math.min(1440,Math.max(1,Number.parseInt(t,10)||30));try{return await (0,H.T)(p,t=>({...t,accountScheduler:{...t.accountScheduler||{},enabled:e,sessionAffinityTtlSeconds:60*s}})),!0}catch(e){return(0,E.s)("Error saving balanced scheduler:",e),!1}},tW=async e=>{let t=e?"round-robin":null,s=e?ej||"1":ej;await tH(t,s)&&(e&&!ej&&ew("1"),ev(t))},tG=async e=>{await tH("round-robin",e)&&ew(e)},tQ=async e=>{await tV(e,eC)&&eN(e)},tZ=async e=>{await tV(ek,e)&&eS(e)},tX=async e=>{try{let t=await fetch("/api/settings",{cache:"no-store"}),s={...(t.ok?await t.json():{}).providerThinking||{}};e&&"auto"!==e?s[p]={mode:e}:delete s[p],await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerThinking:s})})}catch(e){(0,E.s)("Error saving thinking config:",e)}},tY=async e=>{let t=V[p];if(t){eE(e);try{await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({[t]:e})})}catch(e){(0,E.s)("Error saving auto-ping config:",e)}}};(0,i.useEffect)(()=>{tL(),tF(),tJ(),tP()},[tL,tF,tJ,tP]),(0,i.useEffect)(()=>{tK()},[tK]),(0,i.useEffect)(()=>{if(tv)return;let e=h.find(e=>!1!==e.isActive);if(!e)return void eD([]);let t=!1;return fetch(`/api/providers/${e.id}/models`,{cache:"no-store"}).then(e=>e.json().catch(()=>({}))).then(e=>{!t&&Array.isArray(e.models)&&e.models.length>0&&eD(e.models)}).catch(()=>{}),()=>{t=!0}},[h,tv]),(0,i.useEffect)(()=>{let e=(c.zN[p]||c.fg[p]||c.IS[p]||c.nJ[p])?.modelsFetcher;e&&N(e).then(eO)},[p]);let t0=(0,i.useCallback)(e=>{let t=++e1.current;e0.current&&(clearTimeout(e0.current),e0.current=null);let s=async()=>{try{let a=await fetch(`/api/providers/${e}/model-probes/verify/status`,{cache:"no-store"}),i=await a.json().catch(()=>null);if(t!==e1.current)return;if(!a.ok||!i?.status)throw Error("Verify status temporarily unavailable");te(i&&i.status?i:null),i?.status==="running"?e0.current=setTimeout(s,1500):(e0.current=null,await tK(e))}catch{t===e1.current&&(e0.current=setTimeout(s,1500))}};e0.current=setTimeout(s,0)},[tK]);(0,i.useEffect)(()=>{let e=h.find(e=>b.includes(e.id)&&!1!==e.isActive)||h.find(e=>!1!==e.isActive);return e?(t0(e.id),()=>{e1.current+=1,e0.current&&(clearTimeout(e0.current),e0.current=null)}):void te(null)},[h,b,t0]);let t1=async(e,t,s=tb)=>{let a=`${s}/${e}`;try{let e=await fetch("/api/models/alias",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:a,alias:t})});if(e.ok)await tF();else{let t=await e.json();(0,E.s)(t.error||"Failed to set alias")}}catch(e){(0,E.s)("Error setting alias:",e)}},t2=async e=>{try{await (0,B.x)(`/api/models/alias?alias=${encodeURIComponent(e)}`,{method:"DELETE"}),await tF()}catch(e){(0,E.s)("Error deleting alias:",e)}},t5=async(e,t="llm",s=tO)=>{try{let a=await fetch("/api/models/custom",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerAlias:s,id:e,type:t})});if(a.ok)await tJ(),window.dispatchEvent(new CustomEvent("customModelChanged"));else{let e=await a.json();(0,E.s)(e.error||"Failed to add custom model")}}catch(e){(0,E.s)("Error adding custom model:",e)}},t3=async(e,t="llm",s=tO)=>{try{let a=new URLSearchParams({providerAlias:s,id:e,type:t});await (0,B.x)(`/api/models/custom?${a}`,{method:"DELETE"}),await tJ(),window.dispatchEvent(new CustomEvent("customModelChanged"))}catch(e){(0,E.s)("Error deleting custom model:",e)}},t4=async()=>{if(e5)return;let e=h.find(e=>b.includes(e.id)&&!1!==e.isActive)||h.find(e=>!1!==e.isActive);if(!e)return void(0,E.s)((0,w.Tl)("Add an active connection first"));e3(!0),e6("");try{let t=await fetch(`/api/providers/${e.id}/models`),s=await t.json().catch(()=>({}));if(!t.ok)return void(0,E.s)(s.error||(0,w.Tl)("Failed to fetch models"));let a=s.models||[];if(0===a.length)return void(0,E.s)(s.warning||(0,w.Tl)("No models returned"));let i=new Set;try{let t=await fetch(`/api/providers/${e.id}/model-probes`,{cache:"no-store"});for(let e of(await t.json().catch(()=>({}))).probes||[])"dead"===e.status&&i.add(e.modelId)}catch{}let r=0,l=new Set(tf.map(e=>e.id)),n=[],o=[],d=new Set;for(let e of a){let t=(0,S.R2)(e,tO);if(!t)continue;let{id:s,name:a,type:c}=t;if(i.has((0,K.v)(s,tO))){r+=1;continue}let m=`${c}|${s}`;if(d.has(m))continue;if(d.add(m),l.has(s)){tM(s)&&o.push(s);continue}if(en.some(e=>e.providerAlias===tO&&e.id===s&&(0,S.ki)(e.kind||e.type||"llm")===c))continue;let u=`${tO}/${s}`;Object.values(er).includes(u)||n.push({providerAlias:tO,id:s,type:c,name:a})}let c=0;if(o.length>0)try{for(let e of o)(await fetch(`/api/models/disabled?providerAlias=${encodeURIComponent(tO)}&id=${encodeURIComponent(e)}`,{method:"DELETE"})).ok&&(c+=1);await tP()}catch{}let m=0;if(n.length>0){let e=await fetch("/api/models/custom",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({models:n})}),t=await e.json().catch(()=>({}));if(!e.ok)return void(0,E.s)(t.error||(0,w.Tl)("Failed to save models"));m=t.added??n.length,await tJ(),window.dispatchEvent(new CustomEvent("customModelChanged"))}let u=n.filter(e=>"llm"!==e.type).length,p=[];if(m>0&&p.push(`${m} new`),c>0&&p.push(`${c} re-enabled`),0===p.length)e6((0,w.Tl)("All models already in list"));else{let e=`Imported ${p.join(" \xb7 ")} (${a.length} from provider)`;u>0&&(e+=" \xb7 non-chat types stored for media pages"),s.warning&&(e+=` \xb7 ${s.warning}`),e6(e)}if(r>0&&e6(e=>`${e} \xb7 ${r} skipped (known dead)`),m>0||c>0)try{let t=[...tf,...n.map(e=>({id:e.id,name:e.name,kind:e.type}))],s=await fetch(`/api/providers/${e.id}/model-probes/verify/start`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({models:t,providerAlias:tO})}),a=await s.json().catch(()=>({}));if(!s.ok)throw Error(a.error||"Failed to start auto-verify");te(a&&a.status?a:null),t0(e.id)}catch(e){e6(t=>`${t} \xb7 auto-verify failed: ${e?.message||e}`)}}catch(e){(0,E.s)("Error importing models:",e),(0,E.s)((0,w.Tl)("Error fetching models")+": "+(e?.message||e))}finally{e3(!1)}},t6=async()=>{if(eL||0===h.length)return;let e=Object.fromEntries(h.map(e=>[e.id,{state:"queued",error:null}]));eY.current=!1,eK(!0),eH(!1),eW(null),eQ(e),eX({total:h.length,completed:0,passed:0,failed:0,stopped:!1});let t=0,s=0;try{for(let e=0;e<h.length;e+=1){if(eY.current){eX({total:h.length,completed:e,passed:t,failed:s,stopped:!0});break}let a=h[e];eW(a.id),eQ(e=>({...e,[a.id]:{state:"testing",error:null}}));try{let e=await fetch(`/api/providers/${a.id}/test`,{method:"POST"}),i=await e.json(),r=!!i.valid;r?t+=1:s+=1,eQ(e=>({...e,[a.id]:{state:r?"success":"failed",error:r?null:i.error||null}}))}catch(e){s+=1,eQ(t=>({...t,[a.id]:{state:"failed",error:e.message||"Test failed"}}))}eX({total:h.length,completed:e+1,passed:t,failed:s,stopped:!1}),e<h.length-1&&await new Promise(e=>setTimeout(e,1e3))}}finally{eW(null),eK(!1),eH(!1),eY.current=!1}},t8=async e=>{let t=h.find(t=>t.id===e),s=t?.name?.trim()||t?.email?.trim()||e;e_({title:"Delete Connection",message:`Delete connection “${s}”?`,onConfirm:async()=>{e_(null);try{await (0,B.x)(`/api/providers/${e}`,{method:"DELETE"}),f(t=>t.filter(t=>t.id!==e))}catch(e){(0,E.s)("Error deleting connection:",e)}}})},t7=()=>{tL(),D(!1)},t9=async e=>{Q("");try{let t=await fetch("/api/providers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:p,...e})}),s=null;try{s=await t.json()}catch{s=null}if(t.ok){await tL(),W(!1);return}Q(s?.error||"Failed to save connection")}catch(e){(0,E.s)("Error saving connection:",e),Q("Failed to save connection")}},se=async e=>{try{await (0,B.x)(`/api/providers/${ea.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),await tL(),ee(!1)}catch(e){(0,E.s)("Error updating connection:",e)}},st=async(e,t)=>{try{await (0,B.x)(`/api/providers/${e}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({isActive:t})}),f(s=>s.map(s=>s.id===e?{...s,isActive:t}:s))}catch(e){(0,E.s)("Error updating connection status:",e)}},ss=async e=>{let t,s=e?.providerSpecificData?.baseUrl;if(s){try{t=new URL(s).hostname.toLowerCase().replace(/^\[|\]$/g,"")}catch{(0,E.s)("Cannot allow-list: invalid base URL",s);return}try{let e=await fetch("/api/settings",{cache:"no-store"});if(!e.ok)throw Error(`Failed to load settings (${e.status})`);let s=await e.json(),a=[...new Set([...s.ssrfAllowHosts||[],t])],i=await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({ssrfAllowHosts:a})});if(!i.ok)throw Error(`Failed to update allow list (${i.status})`);await tL()}catch(e){(0,E.s)("Error adding host to allow list:",e)}}},sa=async(e,t)=>{let s=[...h];[s[e],s[t]]=[s[t],s[e]],f(s);try{if((await Promise.all([fetch(`/api/providers/${s[e].id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({priority:e})}),fetch(`/api/providers/${s[t].id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({priority:t})})])).some(e=>!e.ok))throw Error("Failed to reorder connections")}catch(e){(0,E.s)("Error swapping priority:",e),await tL()}},si=h.length>0&&b.length===h.length,sr=(0,a.jsx)("div",{className:"flex min-w-0 flex-col divide-y divide-black/[0.03] dark:divide-white/[0.03]",children:h.map((e,t)=>(0,a.jsxs)("div",{className:"flex min-w-0 items-stretch",children:[(0,a.jsx)("div",{className:"flex shrink-0 items-center pl-1 sm:pl-2",children:(0,a.jsx)("input",{type:"checkbox",checked:b.includes(e.id),onChange:()=>{var t;return t=e.id,void g(e=>e.includes(t)?e.filter(e=>e!==t):[...e,t])},className:"h-4 w-4 rounded border-gray-300 text-primary focus:ring-primary"})}),(0,a.jsx)("div",{className:"flex-1 min-w-0",children:(0,a.jsx)(M,{connection:e,isOAuth:tu,isFirst:0===t,isLast:t===h.length-1,onMoveUp:()=>sa(t,t-1),onMoveDown:()=>sa(t,t+1),onToggleActive:t=>st(e.id,t),autoPing:V[p]&&"oauth"===e.authType?{on:!0===eT.connections[e.id],onToggle:t=>{var s;return s=e.id,void tY({...eT,connections:{...eT.connections,[s]:t}})},provider:p}:null,onEdit:()=>{ei(e),ee(!0)},onDelete:()=>t8(e.id),onAllowlistHost:()=>ss(e),oneByOneStatus:eG[e.id]||null})})]},e.id))}),sl=async e=>{if(!eh.has(e)){ef(t=>new Set(t).add(e));try{let t=await fetch("/api/models/test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:`${tO}/${e}`})}),s=await t.json();eu(t=>({...t,[e]:s.ok?"ok":"error"})),ex(s.ok?"":s.error||"Model not reachable")}catch{eu(t=>({...t,[e]:"error"})),ex("Network error")}finally{ef(t=>{let s=new Set(t);return s.delete(e),s})}}};return k?(0,a.jsxs)("div",{className:"flex flex-col gap-8",children:[(0,a.jsx)(d.Qv,{}),(0,a.jsx)(d.Qv,{})]}):tc?(0,a.jsxs)("div",{className:"flex min-w-0 flex-col gap-6 px-1 sm:gap-8 sm:px-0",children:[(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsxs)(n(),{href:"/dashboard/providers",className:"inline-flex items-center gap-1 text-sm text-text-muted hover:text-primary transition-colors mb-4",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-lg",children:"arrow_back"}),"Back to Providers"]}),(0,a.jsxs)("div",{className:"flex min-w-0 items-center gap-3 sm:gap-4",children:[(0,a.jsx)("div",{className:"flex size-12 shrink-0 items-center justify-center rounded-lg",style:{backgroundColor:`${tc.color}15`},children:ed?(0,a.jsx)("span",{className:"text-sm font-bold",style:{color:tc.color},children:tc.textIcon||tc.id.slice(0,2).toUpperCase()}):(0,a.jsx)(o.default,{src:tg&&tc.apiType?"responses"===tc.apiType?"/providers/oai-r.png":"/providers/oai-cc.png":ty?"/providers/anthropic-m.png":`/providers/${tc.id}.png`,alt:tc.name,width:48,height:48,className:"max-h-12 max-w-12 rounded-lg object-contain",sizes:"48px",onError:()=>ec(!0)})}),(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsxs)("div",{className:"flex items-center gap-3 flex-wrap",children:[(0,a.jsx)("h1",{className:"truncate text-2xl font-semibold tracking-tight sm:text-3xl",children:tc.name}),(tc.notice?.apiKeyUrl||tc.notice?.signupUrl||tc.website)&&(0,a.jsxs)("a",{href:tc.notice?.apiKeyUrl||tc.notice?.signupUrl||tc.website,target:"_blank",rel:"noopener noreferrer",className:"text-xs text-primary hover:underline inline-flex items-center gap-1",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:"open_in_new"}),tc.notice?.apiKeyUrl?"Get API Key":"Sign up / Learn more"]})]}),(0,a.jsxs)("p",{className:"text-text-muted",children:[h.length," connection",1===h.length?"":"s"]})]})]})]}),tc.deprecated&&(0,a.jsxs)("div",{className:"flex items-start gap-3 rounded-xl border border-amber-500/25 bg-amber-500/8 px-4 py-3 text-xs text-amber-600 dark:text-amber-400",children:[(0,a.jsx)("span",{className:"material-symbols-outlined shrink-0 text-base text-amber-500 mt-0.5",children:"warning"}),(0,a.jsx)("p",{className:"leading-relaxed font-normal",children:String(tc.deprecationNotice).replace(/^⚠️\s*⚠️?\s*/,"")})]}),tc.notice?.text&&!tc.deprecated&&(0,a.jsxs)("div",{className:"flex flex-col gap-2 rounded-lg border border-blue-500/30 bg-blue-500/10 px-3 py-2 sm:flex-row sm:items-center",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[16px] text-blue-500 shrink-0",children:"info"}),(0,a.jsx)("p",{className:"min-w-0 flex-1 text-xs leading-relaxed text-blue-600 dark:text-blue-400",children:tc.notice.text}),tc.notice.apiKeyUrl&&(0,a.jsx)("a",{href:tc.notice.apiKeyUrl,target:"_blank",rel:"noopener noreferrer",className:"inline-flex justify-center rounded bg-blue-500 px-2 py-1 text-xs font-medium text-white transition-colors hover:bg-blue-600 sm:py-0.5",children:"Get API Key →"})]}),tv&&A&&(0,a.jsx)(d.Zp,{children:(0,a.jsxs)("div",{className:"mb-4 flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsx)("h2",{className:"text-lg font-semibold",children:ty?"Anthropic Compatible Details":"OpenAI Compatible Details"}),(0,a.jsxs)("p",{className:"break-all text-sm text-text-muted",children:[ty?"Messages API":"responses"===A.apiType?"Responses API":"Chat Completions"," \xb7 ",(A.baseUrl||"").replace(/\/$/,""),"/",ty?"messages":"responses"===A.apiType?"responses":"chat/completions"]})]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-2 sm:flex sm:items-center",children:[(0,a.jsx)(d.$n,{size:"sm",icon:"add",onClick:()=>{Q(""),W(!0)},className:"w-full sm:w-auto",children:"Add API Key"}),(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",icon:"edit",onClick:()=>es(!0),className:"w-full sm:w-auto",children:"Edit"}),(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",icon:"delete",onClick:async()=>{e_({title:"Delete Compatible Node",message:`Delete this ${ty?"Anthropic":"OpenAI"} Compatible node?`,onConfirm:async()=>{e_(null);try{await (0,B.x)(`/api/provider-nodes/${p}`,{method:"DELETE"}),u.push("/dashboard/providers")}catch(e){(0,E.s)("Error deleting provider node:",e)}}})},className:"w-full sm:w-auto",children:"Delete"})]})]})}),tx?(0,a.jsx)(d.gw,{providerId:p}):(0,a.jsxs)(d.Zp,{children:[(0,a.jsxs)("div",{className:"mb-4 flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[(0,a.jsx)("h2",{className:"text-lg font-semibold",children:"Connections"}),(0,a.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:gap-4",children:[h.length>0&&(0,a.jsxs)(a.Fragment,{children:[b.length>0&&(0,a.jsxs)(d.$n,{size:"sm",variant:"danger",icon:"delete",onClick:()=>{let e=b.length;0!==e&&e_({title:`Delete ${e} Connection${e>1?"s":""}`,message:`Delete ${e} connection${e>1?"s":""}? This cannot be undone.`,onConfirm:async()=>{e_(null);let e=0,t=[...b],s=[];for(let a of t)try{(await fetch(`/api/providers/${a}`,{method:"DELETE"})).ok?s.push(a):e+=1}catch(t){(0,E.s)("Error deleting connection:",t),e+=1}f(e=>e.filter(e=>!s.includes(e.id))),g([]),e>0&&(0,E.s)(`Deleted ${t.length-e} connection(s), ${e} failed.`)}})},children:["Delete Selected (",b.length,")"]}),(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",icon:"sync",onClick:t6,disabled:eL,children:eL?"Testing Connection One-by-One...":"Test Connection One-by-One"}),eL&&(0,a.jsx)(d.$n,{size:"sm",variant:"ghost",icon:"stop",onClick:()=>{eL&&(eY.current=!0,eH(!0))},disabled:eB,children:eB?"Stopping...":"Stop"})]}),(0,a.jsxs)("div",{className:"flex flex-col gap-2 rounded-xl border border-border/60 bg-surface-2/40 p-3",children:[(0,a.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"text-xs font-medium text-text-main",children:"Balanced Scheduler"}),(0,a.jsx)(d.m_,{text:"Process-local least-inflight scheduling with fresh quota signals. Sessions stay on one account and rebind on failure, cooldown, or cap.",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[15px] text-text-muted cursor-help",children:"info"})})]}),(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[ek&&(0,a.jsxs)("label",{className:"flex items-center gap-1.5 text-xs text-text-muted",children:["Affinity",(0,a.jsx)("input",{"aria-label":"Session affinity minutes",type:"number",min:1,max:1440,value:eC,onChange:e=>tZ(e.target.value),className:"w-14 px-2 py-0.5 text-xs border border-border rounded-md bg-background text-text-main focus:outline-none focus:border-primary"}),(0,a.jsx)("span",{className:"text-[11px]",children:"min"})]}),(0,a.jsx)(d.lM,{checked:ek,onChange:tQ,"aria-label":"Balanced scheduler"})]})]}),(0,a.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-3 pt-2 border-t border-border/40",title:ek?"Saved and used again when balanced scheduling is off":void 0,children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"text-xs font-medium text-text-main",children:"Round Robin"}),(0,a.jsx)(d.m_,{text:"Cycles through connections sequentially in round-robin fashion.",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[15px] text-text-muted cursor-help",children:"info"})})]}),(0,a.jsxs)("div",{className:"flex items-center gap-3",children:["round-robin"===ey&&(0,a.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,a.jsx)("span",{className:"text-xs text-text-muted",children:"Sticky:"}),(0,a.jsx)("input",{type:"number",min:1,value:ej,onChange:e=>tG(e.target.value),placeholder:"1",disabled:ek,title:ek?"Saved and used again when balanced scheduling is off":void 0,className:"w-14 px-2 py-0.5 text-xs border border-border rounded-md bg-background text-text-main focus:outline-none focus:border-primary disabled:cursor-not-allowed disabled:opacity-50"})]}),(0,a.jsx)(d.lM,{checked:"round-robin"===ey,onChange:tW,"aria-label":"Round Robin",disabled:ek,title:ek?"Saved and used again when balanced scheduling is off":void 0})]})]})]})]})]}),0===h.length?(0,a.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[(0,a.jsx)("div",{className:"inline-flex items-center justify-center w-9 h-9 rounded-full bg-primary/10 text-primary shrink-0",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:tu?"lock":"key"})}),(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsx)("p",{className:"text-sm text-text-muted",children:"No connections yet"}),tk&&(0,a.jsxs)("p",{className:"text-xs text-text-muted",children:["Choose ",tN," or ",tC,"."]})]})]}),(0,a.jsx)("div",{className:"flex gap-2",children:tk?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(d.$n,{size:"sm",icon:"lock",variant:"secondary",onClick:t$,children:tN}),(0,a.jsx)(d.$n,{size:"sm",icon:"key",onClick:tA,children:tC})]}):(0,a.jsxs)(a.Fragment,{children:[!tv&&"iflow"===p&&(0,a.jsx)(d.$n,{size:"sm",icon:"cookie",variant:"secondary",onClick:()=>_(!0),children:"Cookie"}),"codex"===p&&(0,a.jsx)(d.$n,{size:"sm",icon:"playlist_add",variant:"secondary",onClick:()=>X(!0),children:(0,w.Tl)("Bulk Add")}),(0,a.jsx)(d.$n,{size:"sm",icon:"add",onClick:tT,children:tv?"Add API Key":"iflow"===p?"OAuth":"Add Connection"})]})})]}):(0,a.jsxs)(a.Fragment,{children:[eZ&&(0,a.jsx)("div",{className:"mb-4 rounded-lg border border-black/10 bg-black/[0.02] px-3 py-2 text-xs text-text-muted dark:border-white/10 dark:bg-white/[0.03]",children:(0,a.jsxs)("div",{className:"flex flex-wrap items-center gap-3",children:[(0,a.jsxs)("span",{children:["Total: ",eZ.total]}),(0,a.jsxs)("span",{children:["Completed: ",eZ.completed]}),(0,a.jsxs)("span",{children:["Passed: ",eZ.passed]}),(0,a.jsxs)("span",{children:["Failed: ",eZ.failed]}),eZ.stopped&&(0,a.jsx)("span",{className:"text-amber-600 dark:text-amber-400",children:"Stopped"}),eL&&eV&&(0,a.jsxs)("span",{children:["Running: ",h.find(e=>e.id===eV)?.name||eV]})]})}),h.length>0&&(0,a.jsx)("div",{className:"mb-3 flex items-center gap-2 border-b border-black/[0.03] pb-2 dark:border-white/[0.03]",children:(0,a.jsxs)("label",{className:"flex cursor-pointer items-center gap-1.5 text-xs text-text-muted hover:text-primary",children:[(0,a.jsx)("input",{type:"checkbox",checked:si,onChange:()=>{si?g([]):g(h.map(e=>e.id))},className:"h-3.5 w-3.5 rounded border-gray-300 text-primary focus:ring-primary"}),"Select All"]})}),sr,!tv&&(0,a.jsxs)("div",{className:"mt-4 grid grid-cols-1 gap-2 sm:flex",children:["iflow"===p&&(0,a.jsx)(d.$n,{size:"sm",icon:"cookie",variant:"secondary",onClick:()=>_(!0),title:"Add connection using browser cookie",className:"w-full sm:w-auto",children:"Cookie"}),"codex"===p&&(0,a.jsx)(d.$n,{size:"sm",icon:"playlist_add",variant:"secondary",onClick:()=>X(!0),title:(0,w.Tl)("Bulk import codex accounts from JSON"),className:"w-full sm:w-auto",children:(0,w.Tl)("Bulk Add")}),tk?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(d.$n,{size:"sm",icon:"lock",variant:"secondary",onClick:t$,className:"w-full sm:w-auto",children:tN}),(0,a.jsx)(d.$n,{size:"sm",icon:"key",onClick:tA,className:"w-full sm:w-auto",children:tC})]}):(0,a.jsx)(d.$n,{size:"sm",icon:"add",onClick:tT,className:"w-full sm:w-auto",children:"Add"})]})]})]}),(0,a.jsxs)(d.Zp,{children:[(0,a.jsxs)("div",{className:"mb-4 flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between",children:[(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[(0,a.jsx)("h2",{className:"text-lg font-semibold",children:"Available Models"}),tR&&(0,a.jsx)("select",{value:e$,onChange:e=>{var t;eA(t=e.target.value),tX(t)},title:"Appends (level) suffix to copied model names",className:"rounded-md border border-border bg-background px-2 py-1 text-xs focus:border-primary focus:outline-none",children:tR.map(e=>(0,a.jsx)("option",{value:e,children:`Thinking: ${e.charAt(0).toUpperCase()+e.slice(1)}`},e))})]}),tw.showToolbar&&(e=(tw.showBulkControls?[...tf,...eM.filter(e=>!tf.some(t=>t.id===e.id))].filter(e=>{let t=(0,m.CP)(e);return!t||"llm"===t}).map(e=>e.id):[]).filter(e=>!tM(e)),(0,a.jsxs)("div",{className:"flex flex-wrap gap-2",children:[tw.showImport&&(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",icon:e5?"progress_activity":"cloud_download",onClick:t4,disabled:e5||!tj,title:tj?"Import models from the active connection":"Add an active connection to import models",children:e5?"Importing...":"Import models"}),tw.showVerify&&(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",icon:e9?.status==="running"?"progress_activity":"science",onClick:()=>e7(e=>!e),children:e9?.status==="running"?`Verifying ${e9.done}/${e9.total}`:e8?"Hide verify":"Verify models"}),tw.showBulkControls&&eU.length>0&&(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",icon:"restart_alt",onClick:t_,children:"Active All"}),tw.showBulkControls&&e.length>0&&(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",icon:"block",onClick:()=>tq(e),children:"Disable All"})]}))]}),!!ep&&(0,a.jsx)("p",{className:"text-xs text-red-500 mb-3 break-words",children:ep}),e4&&(0,a.jsxs)("div",{className:"mb-3 flex items-center justify-between gap-2 rounded-xl border border-primary/30 bg-primary/10 px-3.5 py-2 text-xs font-medium text-text-main",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[16px] text-primary",children:"info"}),(0,a.jsx)("span",{children:e4})]}),(0,a.jsx)("button",{onClick:()=>e6(""),className:"text-text-muted hover:text-text-main p-0.5 rounded",title:"Dismiss",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:"close"})})]}),e8&&(t=h.find(e=>b.includes(e.id)&&!1!==e.isActive)||h.find(e=>!1!==e.isActive),s=[...(0,C.R3)({customModels:en,modelAliases:er,providerAlias:tO,builtInModels:tf,type:"llm"}).filter(e=>!tM(e.id)).map(e=>({id:e.id,name:e.name||e.id,kind:"llm"})),...tf.filter(e=>{let t=(0,m.CP)(e);return(!t||"llm"===t)&&!tM(e.id)}).map(e=>({id:e.id,name:e.name||e.id,kind:"llm"}))],(0,a.jsx)(L,{connectionId:t?.id,providerAlias:tO,models:s,jobSnapshot:e9,onClose:()=>e7(!1),onStarted:e=>{te(e&&e.status?e:null);let s=e?.connectionId||t?.id;s&&t0(s)},onComplete:async e=>{e?.removedStatus&&te(t=>t?{...t,dead:Number(e.dead??t.dead??0),retryable:Number(e.retryable??t.retryable??0),retryableAuthOnly:!0===e.retryableAuthOnly}:t),e?.removed>0&&await tJ(),e?.removed>0&&await tP(),(e?.removed>0||e?.cacheCleared)&&await tK(t?.id)}})),(()=>{let e,t,s;if(tv)return(0,a.jsx)(O,{providerStorageAlias:tO,providerDisplayAlias:tI,modelAliases:er,customModels:en,copied:tn,onCopy:to,onSetAlias:t1,onDeleteAlias:t2,onAddCustomModel:e=>t5(e,"llm",tO),onDeleteCustomModel:e=>t3(e,"llm",tO),onRefreshModels:tJ,connections:h,isAnthropic:ty,disabledModelIds:eU,onEnableModel:tz});let i=[...tf,...eM.filter(e=>!tf.some(t=>t.id===e.id))].filter(e=>{let t=(0,m.CP)(e);return!t||"llm"===t}),r=i.filter(e=>!tM(e.id)),l=i.filter(e=>tM(e.id)),n=(0,C.R3)({customModels:en,modelAliases:er,providerAlias:tO,builtInModels:tf,type:"llm"}),o=n.filter(e=>!tM(e.id)&&("all"===tr||(ta[(0,K.v)(e.id,tO)]||null)===tr)),d=r.filter(e=>"all"===tr||(ta[(0,K.v)(e.id,tO)]||null)===tr);return(0,a.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,a.jsx)("div",{className:"mb-2 flex flex-wrap items-center gap-1.5 text-xs",children:[{id:"all",label:"All",count:r.length+n.filter(e=>!tM(e.id)).length},{id:"ok",label:"Reachable",count:[...r,...n].filter(e=>!tM(e.id)&&("ok"===ta[(0,K.v)(e.id,tO)]||"ok"===em[e.id])).length},{id:"dead",label:"Dead",count:[...r,...n].filter(e=>!tM(e.id)&&("dead"===ta[(0,K.v)(e.id,tO)]||"error"===em[e.id])).length},{id:"retry",label:"Retry",count:[...r,...n].filter(e=>!tM(e.id)&&"retry"===ta[(0,K.v)(e.id,tO)]).length}].map(e=>(0,a.jsxs)("button",{onClick:()=>tl(e.id),className:`inline-flex items-center gap-1.5 rounded-lg px-2.5 py-1 text-xs font-medium transition-all ${tr===e.id?"bg-primary text-black font-semibold shadow-sm":"bg-surface-2/60 border border-border/40 text-text-muted hover:border-border hover:text-text-main"}`,children:[(0,a.jsx)("span",{children:e.label}),(0,a.jsx)("span",{className:`rounded-full px-1.5 py-0.2 text-[10px] tabular-nums ${tr===e.id?"bg-black/20 text-black font-bold":"bg-black/10 dark:bg-white/10 text-text-muted"}`,children:e.count})]},e.id))}),(0,a.jsxs)("div",{className:"flex flex-wrap gap-3",children:[o.map(e=>{let t=(0,K.v)(e.id,tO);return(0,a.jsx)(T,{model:{id:e.id,name:e.name},fullModel:`${tI}/${e.id}`,alias:e.alias,copied:tn,onCopy:to,onSetAlias:()=>{},onDeleteAlias:()=>{"custom"===e.source?t3(e.id,"llm",tO):t2(e.alias)},testStatus:em[e.id],onTest:h.length>0||tx?()=>sl(e.id):void 0,isTesting:eh.has(e.id),isCustom:!0,isFree:!1,caps:x(`${p}/${e.id}`),thinkingSuffix:tE(e.id),latencyMs:tt[e.id]??tt[t],probeState:e9?.status==="running"&&e9?.perModel?.[t]?e9.perModel[t]:ta[t]||null},`${e.source}-${e.fullModel}`)}),d.map(e=>{let t=`${tO}/${e.id}`,s=`${p}/${e.id}`,i=Object.entries(er).find(([,e])=>e===t||e===s)?.[0],r=(0,K.v)(e.id,tO);return(0,a.jsx)(T,{model:e,fullModel:`${tI}/${e.id}`,alias:i,copied:tn,onSetAlias:t=>t1(e.id,t,tO),onCopy:to,onDeleteAlias:()=>t2(i),testStatus:em[e.id],onTest:h.length>0||tx?()=>sl(e.id):void 0,isTesting:eh.has(e.id),isFree:e.isFree,onDisable:()=>tU(e.id),caps:x(`${p}/${e.id}`),thinkingSuffix:tE(e.id),latencyMs:tt[e.id]??tt[r],probeState:e9?.status==="running"&&e9?.perModel?.[r]?e9.perModel[r]:ta[r]||null},e.id)}),(0,a.jsxs)("button",{onClick:()=>eg(!0),className:"flex min-h-[58px] min-w-[200px] flex-1 items-center justify-center gap-2 rounded-xl border border-dashed border-primary/40 bg-primary/5 px-4 py-3 text-xs font-medium text-primary transition-all hover:border-primary hover:bg-primary/10 hover:shadow-soft sm:flex-none",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"add_circle"}),"Add Custom Model"]}),eR.length>0&&(e=new Set([...Object.values(er),...n.map(e=>e.fullModel)]),t=new Set(tf.map(e=>e.id)),0===(s=eR.filter(s=>!e.has(`${tO}/${s.id}`)&&!t.has(s.id))).length?null:(0,a.jsxs)("div",{className:"w-full mt-2",children:[(0,a.jsx)("p",{className:"text-xs text-text-muted mb-2",children:"Suggested free models (≥200k context):"}),(0,a.jsx)("div",{className:"flex flex-wrap gap-2",children:s.map(e=>(0,a.jsxs)("button",{onClick:async()=>{await t5(e.id,"llm",tO)},className:"flex items-center gap-1 px-2.5 py-1.5 rounded-lg border border-black/10 dark:border-white/10 text-xs text-text-muted hover:text-primary hover:border-primary/40 hover:bg-primary/5 transition-colors",title:`${e.name} \xb7 ${(e.contextLength/1e3).toFixed(0)}k ctx`,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[13px]",children:"add"}),e.id.split("/").pop()]},e.id))})]})),l.length>0&&(0,a.jsxs)("div",{className:"w-full mt-2",children:[(0,a.jsxs)("p",{className:"text-xs text-text-muted mb-2",children:["Disabled models (",l.length,"):"]}),(0,a.jsx)("div",{className:"flex flex-wrap gap-2",children:l.map(e=>(0,a.jsxs)("button",{onClick:()=>tz(e.id),className:"flex items-center gap-1 px-2.5 py-1.5 rounded-lg border border-dashed border-black/10 dark:border-white/10 text-xs text-text-muted hover:text-primary hover:border-primary/40 hover:bg-primary/5 transition-colors",title:"Restore model",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[13px]",children:"add"}),e.id]},e.id))})]})]})]})})()]}),"kiro"===p?(0,a.jsx)(d.Mh,{isOpen:I,providerInfo:tc,onSuccess:t7,onClose:()=>D(!1)}):"cursor"===p?(0,a.jsx)(d.G9,{isOpen:I,onSuccess:t7,onClose:()=>D(!1)}):"gitlab"===p?(0,a.jsx)(d.vj,{isOpen:I,providerInfo:tc,onSuccess:t7,onClose:()=>D(!1)}):(0,a.jsx)(d.LF,{isOpen:I,provider:p,providerInfo:tc,onSuccess:t7,onClose:()=>D(!1)}),"iflow"===p&&(0,a.jsx)(d.vE,{isOpen:P,onSuccess:()=>{tL(),_(!1)},onClose:()=>_(!1)}),(0,a.jsx)(U,{isOpen:J,provider:p,providerName:tc.name,isCompatible:tv,isAnthropic:ty,authType:tc?.authType,authHint:tc?.authHint,website:tc?.website,error:G,onSave:t9,onBulkDone:tL,onClose:()=>{Q(""),W(!1)}}),(0,a.jsx)(d.wI,{isOpen:Y,connection:ea,onSave:se,onClose:()=>ee(!1)}),tv&&(0,a.jsx)(z,{isOpen:et,node:A,onSave:tB,onClose:()=>es(!1),isAnthropic:ty}),!tv&&(0,a.jsx)(q,{isOpen:eb,providerAlias:tO,providerDisplayAlias:tI,onSave:async e=>{await t5(e,"llm",tO),eg(!1)},onClose:()=>eg(!1)}),"codex"===p&&(0,a.jsx)(F,{isOpen:Z,onClose:()=>X(!1),onSuccess:tL}),(0,a.jsx)(d.uo,{isOpen:eF,onClose:()=>eJ(!1),onConfirm:()=>{(window.localStorage.setItem(td,"true"),eJ(!1),tu)?tS():tA()},title:"Risk Notice",message:tc?.deprecationNotice,confirmText:"I Understand, Continue",cancelText:"Cancel",variant:"danger"}),(0,a.jsx)(d.uo,{isOpen:!!eq,onClose:()=>e_(null),onConfirm:eq?.onConfirm,title:eq?.title||"Confirm",message:eq?.message,variant:"danger"})]}):(0,a.jsxs)("div",{className:"text-center py-20",children:[(0,a.jsx)("p",{className:"text-text-muted",children:"Provider not found"}),(0,a.jsx)(n(),{href:"/dashboard/providers",className:"text-primary mt-4 inline-block",children:"Back to Providers"})]})}},48874:(e,t,s)=>{"use strict";async function a(e,t){let s=await fetch(e,{...t,headers:{"Content-Type":"application/json",...t?.headers||{}},credentials:"same-origin"}),a=null;try{a=await s.json()}catch{a=null}if(!s.ok){let e=a&&(a.error||a.message)||`Request failed (${s.status})`,t=Error("string"==typeof e?e:"Request failed");throw t.status=s.status,t.data=a,t}return a}s.d(t,{x:()=>a})},53578:(e,t,s)=>{"use strict";s.d(t,{T:()=>r});let a=Symbol("delete-provider-strategy"),i=Promise.resolve();async function r(e,t,s=fetch){let a=i.then(()=>l(e,t,s));return i=a.catch(()=>{}),a}async function l(e,t,s){let i=await s("/api/settings",{cache:"no-store"});if(!i.ok)throw Error(`Failed to load settings (${i.status})`);let r=(await i.json()).providerStrategies||{},l=r[e]||{},n=t(l);if(void 0===n)return console.warn(`[patchProviderStrategy] updater for "${e}" returned undefined; keeping previous entry`),l;let o={...r};n===a?delete o[e]:n&&Object.keys(n).length>0?o[e]=n:delete o[e];let d=await s("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerStrategies:o})});if(!d.ok)throw Error(`Failed to save settings (${d.status})`);return n===a?void 0:n}},70217:(e,t,s)=>{"use strict";function a(e){return"error"===e||"expired"===e||"unavailable"===e||"reauth_required"===e||"invalid"===e}function i(e,t){return!1===e?"default":"active"===t||"success"===t?"success":a(t)?"error":"default"}s.d(t,{g:()=>i,t:()=>a})}},e=>{e.O(0,[2574,3862,782,8500,594,1321,4707,1330,8441,3794,7358],()=>e(e.s=7687)),_N_E=e.O()}]);
@@ -1 +0,0 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[3649],{35497:(e,t,a)=>{"use strict";a.d(t,{x0:()=>k.default,Ex:()=>d.default,$n:()=>l.default,nh:()=>M.default,Zp:()=>o.default,Qv:()=>n.CardSkeleton,CK:()=>p.default,uo:()=>i.ConfirmModal,G9:()=>j.default,wI:()=>N.default,vj:()=>v.default,vE:()=>y.default,pd:()=>s.default,Mh:()=>g.default,uR:()=>u.default,Nf:()=>h.default,aF:()=>i.default,rq:()=>x.default,gw:()=>w.default,LF:()=>m.default,Wx:()=>A.default,gM:()=>f.default,Iz:()=>C.default,l6:()=>r.default,lM:()=>c.default,m_:()=>S.default,jK:()=>b.default});var l=a(92542),s=a(11910),r=a(98),o=a(84588),i=a(81127),n=a(25086);a(56319);var d=a(56061),c=a(98542);a(61929),a(21110),a(92622),a(8823),a(92173);var m=a(90882),x=a(72908),u=a(28815),p=a(45455),h=a(28058),b=a(4809);a(21931),a(80752),a(40197);var f=a(23615);a(44736);var g=a(62899);a(94230);var j=a(30815),y=a(23936),v=a(95088),N=a(73579),k=a(96748),w=a(4823),C=a(28067),S=a(97677),A=a(51825),M=a(29366);a(76361),a(91450)},41483:(e,t,a)=>{"use strict";a.d(t,{default:()=>j});var l=a(95155),s=a(12115),r=a(44923),o=a(87256),i=a(39768),n=a(5020),d=a(35497),c=a(11059);a(88105);var m=a(65921),x=a(78559),u=a(47224);let p=/^[a-zA-Z0-9_.\-]+$/,h=[{key:"vision",label:"Vision",icon:"visibility",desc:"Images"},{key:"audioInput",label:"Audio",icon:"graphic_eq",desc:"Audio input"}],b={enabled:!0,roundRobin:!1,models:[]},f=Object.keys({vision:{...b},pdf:{...b},audioInput:{...b},videoInput:{...b}});function g(e){return Array.isArray(e)?{enabled:!0,roundRobin:!1,models:e.map(e=>e?.model||e).filter(Boolean)}:e&&"object"==typeof e?{enabled:!1!==e.enabled,roundRobin:!!e.roundRobin,models:Array.isArray(e.models)?e.models.filter(Boolean):[]}:{...b}}function j({initialData:e}){let t=(0,m.i)(e=>e.error),[a,r]=(0,s.useState)(()=>(e?.combos||[]).filter(e=>!e.kind||"llm"===e.kind)),[o,i]=(0,s.useState)(!e),[n,x]=(0,s.useState)(!1),[u,p]=(0,s.useState)(null),[h,b]=(0,s.useState)(e?.connections||[]),[v,N]=(0,s.useState)(e?.settings?.comboStrategies||{}),[k,w]=(0,s.useState)(e?.modelCaps||{}),[C,A]=(0,s.useState)(()=>{let t=e?.settings?.capacityAdapter||{},a={};for(let e of f)a[e]=g(t[e]);return a}),[F,E]=(0,s.useState)(null),{copied:O,copy:$}=(0,c.C)(),q=(0,s.useCallback)(async()=>{try{let[e,t,a,l]=await Promise.all([fetch("/api/combos"),fetch("/api/providers"),fetch("/api/settings"),fetch("/api/models")]);if(![e,t,a,l].every(e=>e.ok))throw Error("One or more combo resources failed to load");let s=await e.json(),o=await t.json(),i=await a.json();if(e.ok&&r((s.combos||[]).filter(e=>!e.kind||"llm"===e.kind)),t.ok&&b(o.connections||[]),l.ok){let e=await l.json(),t={};for(let a of e.models||[])a.caps&&(t[a.fullModel]=a.caps);w(t)}N(i.comboStrategies||{});let n=i.capacityAdapter||{},d={};for(let e of f)d[e]=g(n[e]);A(d)}catch(e){t("Failed to fetch combo data")}finally{i(!1)}},[t]);(0,s.useEffect)(()=>{e?.combos?i(!1):q()},[e,q]);let P=async e=>{try{let{strategy:a,capacityAutoSwitch:l,routerModel:s,objective:r,...o}=e,i=await fetch("/api/combos",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(o)});if(i.ok){let e=await i.json().catch(()=>({})),t=o.name?.trim()||e?.name;t&&(a||void 0!==l||s||r)&&await z(t,y(a,l,s,r)),await q(),x(!1)}else{let e=await i.json();t(e.error||"Failed to create combo")}}catch(e){t("Failed to create combo")}},D=async(e,a)=>{try{let{strategy:l,capacityAutoSwitch:s,routerModel:r,objective:o,...i}=a,n=u?.name,d=await fetch(`/api/combos/${e}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)});if(d.ok){let e=i.name?.trim()||n;if(n&&e&&n!==e&&N(t=>{let a={...t};return n in a&&(e in a||(a[e]=a[n]),delete a[n]),a}),e&&(l||void 0!==s)){let t,a=n&&n!==e?(t={...v},n in t&&(e in t||(t[e]=t[n]),delete t[n]),t):v;await z(e,y(l,s,r,o),a)}await q(),p(null)}else{let e=await d.json();t(e.error||"Failed to update combo")}}catch(e){t("Failed to update combo")}},_=async e=>{let l=a.find(t=>t.id===e);E({title:"Delete Combo",message:l?.name?`Delete combo “${l.name}”?`:"Delete this combo?",onConfirm:async()=>{E(null);try{let a=await fetch(`/api/combos/${e}`,{method:"DELETE"});if(a.ok)r(t=>t.filter(t=>t.id!==e)),l?.name&&N(e=>{if(!(l.name in e))return e;let t={...e};return delete t[l.name],t});else{let e=await a.json().catch(()=>({}));t(e.error||`Failed to delete combo (HTTP ${a.status})`)}}catch(e){t("Failed to delete combo")}}})},z=async(e,a,l=null)=>{try{let s={...l||v},r={...s[e]||{},...a};for(let e of Object.keys(r))(""===r[e]||null===r[e]||void 0===r[e])&&delete r[e];let o=r.fallbackStrategy||"fallback";"fallback"!==o||r.judgeModel||r.routerModel||r.objective||void 0!==r.learningEnabled||void 0!==r.freezeLearning||void 0!==r.explorationRate||!1===r.capacityAutoSwitch?(!r.fallbackStrategy&&void 0===a.fallbackStrategy&&s[e]?.fallbackStrategy&&(r.fallbackStrategy=s[e].fallbackStrategy),s[e]=r):delete s[e];let i=await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({comboStrategies:s})});if(!i.ok){let e=await i.json().catch(()=>({}));t(e.error||`Failed to update combo strategy (${i.status})`);return}N(s)}catch(e){throw t("Failed to update combo strategy"),e}},L=async e=>{A(e);try{(await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({capacityAdapter:e})})).ok||t("Failed to update capacity adapter")}catch(e){t("Failed to update capacity adapter")}};return o?(0,l.jsxs)("div",{className:"flex flex-col gap-6",children:[(0,l.jsx)(d.Qv,{}),(0,l.jsx)(d.Qv,{})]}):(0,l.jsxs)("div",{className:"flex min-w-0 flex-col gap-6 px-1 sm:px-0",children:[(0,l.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[(0,l.jsxs)("div",{className:"min-w-0 max-w-3xl",children:[(0,l.jsx)("h1",{className:"text-[17px] font-semibold text-text-main",children:"Combos"}),(0,l.jsx)("p",{className:"text-sm text-text-muted mt-1",children:"Group models under one name, then pick a strategy per combo:"}),(0,l.jsxs)("ul",{className:"text-sm text-text-muted mt-2 flex flex-col gap-1.5",children:[(0,l.jsxs)("li",{children:[(0,l.jsx)("span",{className:"font-medium text-text-main",children:"Fallback"})," ","— tries models in order (next on failure)"]}),(0,l.jsxs)("li",{children:[(0,l.jsx)("span",{className:"font-medium text-text-main",children:"Round Robin"})," ","— rotates models across requests to spread load"]}),(0,l.jsxs)("li",{children:[(0,l.jsx)("span",{className:"font-medium text-text-main",children:"Fusion"})," ","— queries all models in parallel, then a judge synthesizes one answer. Best quality, but costs the most: every request bills all panel models + the judge (N+1 calls)"]}),(0,l.jsxs)("li",{children:[(0,l.jsx)("span",{className:"font-medium text-text-main",children:"Auto"})," ","— a router model picks one worker from the pool each request (2 calls: router + worker); optional learning from outcomes"]}),(0,l.jsxs)("li",{children:[(0,l.jsx)("span",{className:"font-medium text-text-main",children:"Capacity auto-switch"})," ","— when enabled on a combo, sends image/PDF requests to a model that supports them first (works with Fallback, Round Robin, and Fusion)"]})]})]}),(0,l.jsx)(d.$n,{icon:"add",onClick:()=>x(!0),className:"w-full sm:w-auto whitespace-nowrap shrink-0",children:"Create Combo"})]}),0===a.length?(0,l.jsx)(d.Zp,{children:(0,l.jsxs)("div",{className:"text-center py-12",children:[(0,l.jsx)("div",{className:"inline-flex items-center justify-center w-16 h-16 rounded-full bg-primary/10 text-primary mb-4",children:(0,l.jsx)("span",{className:"material-symbols-outlined text-[32px]",children:"layers"})}),(0,l.jsx)("p",{className:"text-text-main font-medium mb-1",children:"No combos yet"}),(0,l.jsx)("p",{className:"text-sm text-text-muted mb-4 max-w-md mx-auto",children:"Create a named model group, choose Fallback / Round Robin / Fusion / Auto, and point clients at the combo name."}),(0,l.jsx)(d.$n,{icon:"add",onClick:()=>x(!0),className:"w-full sm:w-auto",children:"Create Combo"})]})}):(0,l.jsx)("div",{className:"flex flex-col gap-4",children:a.map(e=>(0,l.jsx)(S,{combo:e,modelCaps:k,activeProviders:h,copied:O,onCopy:$,onEdit:()=>p(e),onDelete:()=>_(e.id),strategy:v[e.name]||{},onSetStrategy:t=>z(e.name,t)},e.id))}),(0,l.jsx)(R,{capacityAdapter:C,onChange:L,activeProviders:h,getCaps:e=>k[e]||null}),(0,l.jsx)(M,{isOpen:n,onClose:()=>x(!1),onSave:P,activeProviders:h,modelCaps:k,initialStrategy:{fallbackStrategy:"fallback",capacityAutoSwitch:!0}},"create"),(0,l.jsx)(M,{isOpen:!!u,combo:u,onClose:()=>p(null),onSave:e=>D(u.id,e),activeProviders:h,modelCaps:k,initialStrategy:u?v[u.name]||{fallbackStrategy:"fallback"}:{}},u?.id||"new"),(0,l.jsx)(d.uo,{isOpen:!!F,onClose:()=>E(null),onConfirm:F?.onConfirm,title:F?.title||"Confirm",message:F?.message,variant:"danger"})]})}function y(e,t,a,l){let s=e||"fallback",r={fallbackStrategy:s,...void 0!==t?{capacityAutoSwitch:t}:{}};return"auto"===s?(a&&(r.routerModel=a),l&&(r.objective=l),r.judgeModel=""):("fusion"===s?r.routerModel="":(r.routerModel="",r.judgeModel=""),r.objective="",r.learningEnabled="",r.freezeLearning="",r.explorationRate=""),r}function v(e,t,a){let l=(e||[]).filter(e=>e&&e!==t);return l.length>0&&!l.some(e=>a[e]?.vision)}function N({models:e,routerModel:t}){let a=(e||[]).filter(e=>e&&e!==t);if(a.length<2)return null;let{cheap:s,frontier:r,disabled:o}=function(e){let t=(e||[]).filter(Boolean);if(t.length<=1)return{cheap:t.slice(),frontier:[],disabled:!0};let a=t.map(e=>({m:e,t:function(e){if(!e)return 4;let[t,...a]=e.split("/"),l=a.join("/")||t,s=(0,u.PS)(t,l);if(!s||"number"!=typeof s.input)return 4;let r="number"==typeof s.output?s.output:3*s.input,o=s.input+r;return o<2?0:o<10?1:o<30?2:o<80?3:4}(e)}));if(new Set(a.map(e=>e.t)).size<=1)return{cheap:t.slice(),frontier:[],disabled:!0};let l=a.filter(e=>e.t<=1).map(e=>e.m),s=a.filter(e=>e.t>=2).map(e=>e.m);if(!l.length||!s.length){let e=a.map((e,t)=>({...e,i:t})).sort((e,t)=>e.t-t.t||e.i-t.i),t=Math.ceil(e.length/2);l=e.slice(0,t).map(e=>e.m),s=e.slice(t).map(e=>e.m)}return{cheap:l,frontier:s,disabled:!1}}(a),i=e=>String(e).split("/").pop();return o?(0,l.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-1.5",children:[(0,l.jsx)("span",{className:"text-[11px] font-medium text-text-muted",children:"Tiers"}),(0,l.jsx)("span",{className:"text-[10px] text-text-subtle",title:"All workers share one cost tier — tiered routing is off",children:"single tier (tiering off)"})]}):(0,l.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-1.5",children:[(0,l.jsx)("span",{className:"text-[11px] font-medium text-text-muted",children:"Tiers"}),s.map(e=>(0,l.jsx)("span",{className:"rounded border border-emerald-500/30 bg-emerald-500/10 px-1.5 py-0.5 font-mono text-[10px] text-emerald-600 dark:text-emerald-400",title:`${e} — cheap tier`,children:i(e)},`c-${e}`)),(0,l.jsx)("span",{className:"material-symbols-outlined text-[12px] text-text-subtle",children:"arrow_forward"}),r.map(e=>(0,l.jsx)("span",{className:"rounded border border-amber-500/30 bg-amber-500/10 px-1.5 py-0.5 font-mono text-[10px] text-amber-600 dark:text-amber-400",title:`${e} — frontier tier`,children:i(e)},`f-${e}`))]})}let k=[{value:"fallback",label:"Fallback — try in order"},{value:"round-robin",label:"Round Robin — rotate load"},{value:"fusion",label:"Fusion — panel + judge (N+1)"},{value:"auto",label:"Auto — router picks 1 worker"}],w={fallback:"Tries models top-to-bottom; on failure uses the next.","round-robin":"Rotates models across requests to spread load.",fusion:"Calls every model, then a judge merges answers (bills N+1).",auto:"Router model chooses one worker each request (bills 2 calls)."},C=[{value:"quality",label:"Quality"},{value:"balanced",label:"Balanced"},{value:"economy",label:"Economy"},{value:"latency",label:"Latency"}];function S({combo:e,modelCaps:t={},activeProviders:a=[],copied:r,onCopy:o,onEdit:i,onDelete:n,strategy:c={},onSetStrategy:m}){let[x,u]=(0,s.useState)(!1),[p,h]=(0,s.useState)(!1),[b,f]=(0,s.useState)(!1),[g,j]=(0,s.useState)(!1),[y,A]=(0,s.useState)(""),M=c.fallbackStrategy||"fallback",R=c.judgeModel||"",F="auto"===M,E=c.routerModel||"",O=c.objective||"balanced",$=c.providerStrategy||"off",q=!1!==c.capacityAutoSwitch,P=Array.isArray(c.providerOrder)?c.providerOrder.join(", "):"",D=c.providerLatencyGuardMs??"",[_,z]=(0,s.useState)(P),[L,T]=(0,s.useState)(""===D?"":String(D));(0,s.useEffect)(()=>{z(P)},[P]),(0,s.useEffect)(()=>{T(""===D?"":String(D))},[D]);let I=()=>{let e=_.split(",").map(e=>e.trim()).filter(Boolean),t=Array.isArray(c.providerOrder)?c.providerOrder:[];e.join(",")!==t.join(",")&&m({providerOrder:e})},B=()=>{let e=""===L.trim()?void 0:Number(L)||void 0;e!==c.providerLatencyGuardMs&&m({providerLatencyGuardMs:e})};return(0,l.jsxs)(d.Zp,{padding:"sm",className:"group",children:[(0,l.jsxs)("div",{className:"flex min-w-0 flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[(0,l.jsxs)("div",{className:"flex min-w-0 flex-1 items-start gap-3 sm:items-center",children:[(0,l.jsx)("div",{className:"size-8 rounded-lg bg-primary/10 flex items-center justify-center shrink-0",children:(0,l.jsx)("span",{className:"material-symbols-outlined text-primary text-[18px]",children:"layers"})}),(0,l.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,l.jsx)("code",{className:"block truncate font-mono text-sm font-medium",children:e.name}),(0,l.jsx)("p",{className:"text-[10px] text-text-subtle mt-0.5",children:w[M]||""}),(0,l.jsxs)("div",{className:"mt-1 flex min-w-0 flex-wrap items-center gap-1",children:[0===e.models.length?(0,l.jsx)("span",{className:"text-xs text-text-muted italic",children:"No models"}):e.models.slice(0,3).map((e,a)=>(0,l.jsxs)("code",{className:"inline-flex items-center gap-1 rounded bg-black/5 px-1.5 py-0.5 font-mono text-xs text-text-muted dark:bg-white/5",children:[(0,l.jsx)("span",{children:e}),(0,l.jsx)(d.nh,{caps:t[e]})]},a)),e.models.length>3&&(0,l.jsxs)("span",{className:"text-[10px] text-text-muted",children:["+",e.models.length-3," more"]})]}),"fusion"===M&&(0,l.jsxs)("div",{className:"mt-2 flex min-w-0 flex-wrap items-center gap-1.5",children:[(0,l.jsx)("span",{className:"text-[11px] font-medium text-text-muted",children:"Judge"}),(0,l.jsxs)("button",{onClick:()=>u(!0),className:"inline-flex max-w-full items-center gap-1 rounded border border-dashed border-primary/40 px-1.5 py-0.5 font-mono text-[11px] text-primary hover:border-primary hover:bg-primary/5 transition-colors",title:"Pick the model that fuses panel answers",children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[13px]",children:"gavel"}),(0,l.jsx)("span",{className:"truncate",children:R||`Auto — ${e.models[0]||"first model"}`})]}),R&&(0,l.jsx)("button",{onClick:()=>m({judgeModel:""}),className:"p-0.5 rounded text-text-muted hover:text-red-500 hover:bg-red-500/10 transition-colors",title:"Reset judge to Auto",children:(0,l.jsx)("span",{className:"material-symbols-outlined text-[13px]",children:"close"})})]}),F&&(0,l.jsxs)("div",{className:"mt-2 flex min-w-0 flex-col gap-2",children:[(0,l.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-1.5",children:[(0,l.jsx)("span",{className:"text-[11px] font-medium text-text-muted",children:"Router"}),(0,l.jsxs)("button",{type:"button",onClick:()=>h(!0),className:"inline-flex max-w-full items-center gap-1 rounded border border-dashed border-primary/40 px-1.5 py-0.5 font-mono text-[11px] text-primary hover:border-primary hover:bg-primary/5 transition-colors",title:"Model that picks the worker each request — required for Auto",children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[13px]",children:"alt_route"}),(0,l.jsx)("span",{className:"truncate",children:E||"Select a router model (required)"})]})]}),E&&e.models?.includes(E)&&(0,l.jsxs)("p",{className:"text-[10px] text-amber-600 dark:text-amber-400 flex items-center gap-1",children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[12px]",children:"warning"}),"Router is also in the worker list — it is auto-excluded from the pool."]}),v(e.models,E,t)&&(0,l.jsxs)("p",{className:"text-[10px] text-amber-600 dark:text-amber-400 flex items-center gap-1",children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[12px]",children:"warning"}),"No vision-capable model — image requests will have images stripped"]}),(0,l.jsx)(N,{models:e.models,routerModel:E}),(0,l.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-1.5",children:[(0,l.jsx)("span",{className:"text-[11px] font-medium text-text-muted",children:"Objective"}),(0,l.jsx)("select",{value:O,onChange:e=>m({objective:e.target.value}),className:"rounded border border-border bg-surface-2 px-1.5 py-0.5 text-[11px] text-text-main",children:C.map(e=>(0,l.jsx)("option",{value:e.value,children:e.label},e.value))}),(0,l.jsxs)("label",{className:"inline-flex items-center gap-1 text-[11px] text-text-muted cursor-pointer",children:[(0,l.jsx)("input",{type:"checkbox",className:"rounded border-border",checked:!1!==c.learningEnabled,onChange:e=>m({learningEnabled:e.target.checked})}),"Learn"]}),(0,l.jsxs)("label",{className:"inline-flex items-center gap-1 text-[11px] text-text-muted cursor-pointer",title:"Keep routing on current learning version; block relearn",children:[(0,l.jsx)("input",{type:"checkbox",className:"rounded border-border",checked:!!c.freezeLearning,onChange:e=>m({freezeLearning:e.target.checked})}),"Freeze"]}),(0,l.jsxs)("label",{className:"inline-flex items-center gap-1 text-[11px] text-text-muted cursor-pointer",title:"Occasionally append a 1/2/3 feedback prompt to Auto chat replies (human chat only). Off by default.",children:[(0,l.jsx)("input",{type:"checkbox",className:"rounded border-border",checked:!!c.feedbackAsk,onChange:e=>m({feedbackAsk:e.target.checked})}),"Ask feedback"]}),(0,l.jsxs)("button",{type:"button",disabled:g||!!c.freezeLearning,onClick:async()=>{j(!0),A("");try{let t=await fetch("/api/routing/learn",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({comboName:e.name})}),a=await t.json();A(a.message||(a.ok?"Done":a.error||"Failed"))}catch(e){A(e.message||"Failed")}finally{j(!1)}},className:"inline-flex items-center gap-1 rounded border border-primary/40 bg-primary/10 px-2 py-0.5 text-[11px] font-medium text-primary hover:bg-primary/15 disabled:opacity-50",title:"Run learning optimizer on recent routing events",children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[13px]",children:"psychology"}),g?"Learning…":"Relearn now"]}),(0,l.jsx)("a",{href:`/dashboard/combos/routing?combo=${encodeURIComponent(e.name)}`,className:"inline-flex items-center gap-1 rounded border border-border px-2 py-0.5 text-[11px] text-text-muted hover:text-primary hover:border-primary/40",children:"Insights"})]}),(0,l.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-1.5",children:[(0,l.jsx)("span",{className:"text-[11px] font-medium text-text-muted",children:"Provider"}),(0,l.jsxs)("select",{value:$,onChange:e=>m({providerStrategy:e.target.value}),className:"rounded border border-border bg-surface-2 px-1.5 py-0.5 text-[11px] text-text-main",children:[(0,l.jsx)("option",{value:"off",children:"Off"}),(0,l.jsx)("option",{value:"priority",children:"Priority"}),(0,l.jsx)("option",{value:"round-robin",children:"Round robin"}),(0,l.jsx)("option",{value:"fastest",children:"Fastest"}),(0,l.jsx)("option",{value:"quota-first",children:"Quota first"})]}),"priority"===$&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)("input",{type:"text",value:_,onChange:e=>z(e.target.value),onBlur:I,onKeyDown:e=>{"Enter"===e.key&&I()},placeholder:"provider-a, provider-b",className:"w-40 rounded border border-border bg-surface-2 px-1.5 py-0.5 text-[11px] text-text-main"}),(0,l.jsx)("span",{className:"text-[10px] text-text-muted",children:"comma-separated provider names, highest priority first"})]}),(0,l.jsx)("input",{type:"number",min:"1",value:L,onChange:e=>T(e.target.value),onBlur:B,onKeyDown:e=>{"Enter"===e.key&&B()},placeholder:"20000",title:"Demote providers slower than this latency in milliseconds",className:"w-20 rounded border border-border bg-surface-2 px-1.5 py-0.5 text-[11px] text-text-main"})]}),"quota-first"===$&&(0,l.jsx)("p",{className:"text-[10px] text-text-muted",children:"Quota data currently available for Claude & Codex; other providers use availability (not rate-limited, lower recent use)."}),(0,l.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-2 text-[11px] text-text-muted",children:[(0,l.jsxs)("label",{className:"inline-flex items-center gap-1",children:["Window",(0,l.jsxs)("select",{value:c.learningWindowDays??14,onChange:e=>m({learningWindowDays:Number(e.target.value)||14}),className:"rounded border border-border bg-surface-2 px-1 py-0.5 text-[11px] text-text-main",children:[(0,l.jsx)("option",{value:7,children:"7d"}),(0,l.jsx)("option",{value:14,children:"14d"}),(0,l.jsx)("option",{value:30,children:"30d"})]})]}),(0,l.jsxs)("label",{className:"inline-flex items-center gap-1",title:"Epsilon-greedy exploration (capped at 20%)",children:["Explore",(0,l.jsx)("select",{value:Math.round((c.explorationRate??.05)*100),onChange:e=>m({explorationRate:Number(e.target.value)/100}),className:"rounded border border-border bg-surface-2 px-1 py-0.5 text-[11px] text-text-main",children:[0,5,10,15,20].map(e=>(0,l.jsxs)("option",{value:e,children:[e,"%"]},e))})]}),(0,l.jsxs)("label",{className:"inline-flex items-center gap-1",title:"0 = manual relearn only",children:["Auto-relearn",(0,l.jsxs)("select",{value:c.autoLearnIntervalHours??0,onChange:e=>m({autoLearnIntervalHours:Number(e.target.value)||0}),className:"rounded border border-border bg-surface-2 px-1 py-0.5 text-[11px] text-text-main",children:[(0,l.jsx)("option",{value:0,children:"off"}),(0,l.jsx)("option",{value:6,children:"6h"}),(0,l.jsx)("option",{value:12,children:"12h"}),(0,l.jsx)("option",{value:24,children:"24h"}),(0,l.jsx)("option",{value:72,children:"72h"})]})]}),(0,l.jsxs)("label",{className:"inline-flex items-center gap-1",title:"Capacity pre-filter before router (vision/PDF)",children:[(0,l.jsx)("input",{type:"checkbox",className:"rounded border-border",checked:!1!==c.capacityAutoSwitch,onChange:e=>m({capacityAutoSwitch:e.target.checked})}),"Heuristic first"]}),(0,l.jsxs)("label",{className:"inline-flex items-center gap-1",title:"Emit X-Auto-Router-* response headers (worker, cluster, score, skipped)",children:[(0,l.jsx)("input",{type:"checkbox",className:"rounded border-border",checked:!1!==c.emitAutoRouterHeaders,onChange:e=>m({emitAutoRouterHeaders:e.target.checked})}),"Route headers"]})]}),y?(0,l.jsx)("p",{className:"text-[11px] font-mono text-text-subtle",children:y}):(0,l.jsx)("p",{className:"text-[10px] text-text-subtle",children:"Worker pool = models list (router model excluded if listed). Every request re-routes. Router model is required — pick a connected account (a cheap, fast model such as Haiku works well)."})]})]})]}),(0,l.jsxs)("div",{className:"flex w-full flex-col gap-2 sm:w-auto sm:flex-row sm:items-center sm:gap-3 sm:shrink-0",children:[(0,l.jsxs)("div",{className:"w-full sm:w-[220px] flex flex-col gap-1.5",children:[(0,l.jsx)(d.l6,{options:k,value:M,onChange:e=>{let t=e.target.value;if("auto"===t&&!E){f(!0),h(!0);return}m({fallbackStrategy:t})},selectClassName:"py-1.5 text-xs"}),!F&&(0,l.jsxs)("label",{className:"inline-flex items-center gap-1.5 text-[10px] text-text-muted cursor-pointer",children:[(0,l.jsx)("input",{type:"checkbox",className:"rounded border-border",checked:q,onChange:e=>m({capacityAutoSwitch:e.target.checked})}),"Capacity auto-switch (vision/PDF first)"]})]}),(0,l.jsxs)("div",{className:"grid grid-cols-3 gap-1 sm:flex",children:[(0,l.jsxs)("button",{onClick:t=>{t.stopPropagation(),o(e.name,`combo-${e.id}`)},className:"flex flex-col items-center rounded px-2 py-1 text-text-muted transition-colors hover:bg-black/5 hover:text-primary dark:hover:bg-white/5",title:"Copy combo name",children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:r===`combo-${e.id}`?"check":"content_copy"}),(0,l.jsx)("span",{className:"text-[10px] leading-tight",children:"Copy"})]}),(0,l.jsxs)("button",{onClick:i,className:"flex flex-col items-center rounded px-2 py-1 text-text-muted transition-colors hover:bg-black/5 hover:text-primary dark:hover:bg-white/5",title:"Edit",children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"edit"}),(0,l.jsx)("span",{className:"text-[10px] leading-tight",children:"Edit"})]}),(0,l.jsxs)("button",{onClick:n,className:"flex flex-col items-center rounded px-2 py-1 text-red-500 transition-colors hover:bg-red-500/10",title:"Delete",children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"delete"}),(0,l.jsx)("span",{className:"text-[10px] leading-tight",children:"Delete"})]})]})]})]}),(0,l.jsx)(d.rq,{isOpen:x,onClose:()=>u(!1),onSelect:e=>{m({judgeModel:e?.value||""}),u(!1)},activeProviders:a,title:"Select Judge Model",addedModelValues:R?[R]:[],closeOnSelect:!0}),(0,l.jsx)(d.rq,{isOpen:p,onClose:()=>{f(!1),h(!1)},onSelect:e=>{let t=e?.value||"";b?(f(!1),t&&m({fallbackStrategy:"auto",routerModel:t})):m({routerModel:t}),h(!1)},activeProviders:a,title:"Select Router Model",addedModelValues:E?[E]:[],closeOnSelect:!0})]})}function A({id:e,index:t,model:a,learned:r=null,isFirst:n,isLast:d,onEdit:c,onMoveUp:m,onMoveDown:x,onRemove:u}){let{attributes:p,listeners:h,setNodeRef:b,transform:f,isDragging:g}=(0,o.gl)({id:e}),j={transform:i.Ks.Transform.toString(f),opacity:g?.4:1,zIndex:g?999:void 0},[y,v]=(0,s.useState)(!1),[N,k]=(0,s.useState)(a),w=()=>{let e=N.trim();e&&e!==a?c(e):k(a),v(!1)};return(0,l.jsxs)("div",{ref:b,style:j,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 ${g?"shadow-md ring-1 ring-primary/30":""}`,children:[(0,l.jsx)("button",{...p,...h,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:(0,l.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:[(0,l.jsx)("circle",{cx:"9",cy:"4",r:"2"}),(0,l.jsx)("circle",{cx:"15",cy:"4",r:"2"}),(0,l.jsx)("circle",{cx:"9",cy:"12",r:"2"}),(0,l.jsx)("circle",{cx:"15",cy:"12",r:"2"}),(0,l.jsx)("circle",{cx:"9",cy:"20",r:"2"}),(0,l.jsx)("circle",{cx:"15",cy:"20",r:"2"})]})}),(0,l.jsx)("span",{className:"text-[10px] font-medium text-text-muted w-3 text-center shrink-0",children:t+1}),y?(0,l.jsx)("input",{autoFocus:!0,value:N,onChange:e=>k(e.target.value),onBlur:w,onKeyDown:e=>{"Enter"===e.key&&w(),"Escape"===e.key&&(k(a),v(!1))},className:"min-w-0 flex-1 rounded border border-primary/40 bg-white px-1.5 py-0.5 font-mono text-xs text-text-main outline-none dark:bg-black/20"}):(0,l.jsx)("div",{role:"button",tabIndex:0,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 focus:outline-none focus-visible:ring-2 focus-visible:ring-primary/40",onClick:()=>v(!0),onKeyDown:e=>{("Enter"===e.key||" "===e.key)&&(e.preventDefault(),v(!0))},title:"Click to edit","aria-label":`Edit model ${a}`,children:a}),r&&r.n>=10&&(0,l.jsxs)("span",{className:"shrink-0 font-mono text-[10px] text-text-subtle",title:"Learned routing stats (all combos, last 14d)",children:["avg ",Math.round(r.avgScore)," \xb7 n=",r.n,r.bestCluster?` \xb7 best: ${r.bestCluster}`:""]}),(0,l.jsxs)("div",{className:"flex shrink-0 items-center gap-0.5",children:[(0,l.jsx)("button",{onClick:m,disabled:n,className:`p-0.5 rounded ${n?"text-text-muted/20 cursor-not-allowed":"text-text-muted hover:text-primary hover:bg-black/5 dark:hover:bg-white/5"}`,title:"Move up",children:(0,l.jsx)("span",{className:"material-symbols-outlined text-[12px]",children:"arrow_upward"})}),(0,l.jsx)("button",{onClick:x,disabled:d,className:`p-0.5 rounded ${d?"text-text-muted/20 cursor-not-allowed":"text-text-muted hover:text-primary hover:bg-black/5 dark:hover:bg-white/5"}`,title:"Move down",children:(0,l.jsx)("span",{className:"material-symbols-outlined text-[12px]",children:"arrow_downward"})})]}),(0,l.jsx)("button",{onClick:u,className:"p-0.5 hover:bg-red-500/10 rounded text-text-muted hover:text-red-500 transition-all",title:"Remove",children:(0,l.jsx)("span",{className:"material-symbols-outlined text-[12px]",children:"close"})})]})}function M({isOpen:e,combo:t,onClose:a,onSave:i,activeProviders:c,modelCaps:m={},kindFilter:u=null,initialStrategy:h={}}){let[b,f]=(0,s.useState)(t?.name||""),[g,j]=(0,s.useState)(t?.models||[]),[y,N]=(0,s.useState)(h.fallbackStrategy||"fallback"),[C,S]=(0,s.useState)(!1!==h.capacityAutoSwitch),[R,F]=(0,s.useState)(!1),[E,O]=(0,s.useState)(!1),[$,q]=(0,s.useState)(""),[P,D]=(0,s.useState)({}),[_,z]=(0,s.useState)({}),L=(0,r.FR)((0,r.MS)(r.AN,{activationConstraint:{distance:5}}),(0,r.MS)(r.uN,{coordinateGetter:o.JR})),T=g.map((e,t)=>({uid:`item-${t}`,model:e})),I=async()=>{try{let e=await fetch("/api/models/alias");if(e.ok){let t=await e.json();D(t.aliases||{})}}catch(e){(0,x.s)("Error fetching modal data:",e)}try{let e=await fetch("/api/routing/stats");if(!e.ok)throw Error("Failed to fetch learned routing stats");let t=await e.json(),a={};for(let e of t.global||[]){let t=Object.entries(e.clusters||{}),l=t.filter(([,e])=>e.n>=3),s=(l.length?l:t).reduce((e,t)=>{if(!e)return t;let[a,s]=e,[r,o]=t,i=l.length?s.avgScore:s.n,n=l.length?o.avgScore:o.n;return n>i||n===i&&r<a?t:e},null);a[e.worker]={avgScore:e.avgScore,n:e.n,bestCluster:s?s[0]:null}}z(a)}catch{z({})}};(0,s.useEffect)(()=>{e&&(f(t?.name||""),j(t?.models||[]),N(h.fallbackStrategy||"fallback"),S(!1!==h.capacityAutoSwitch),F(!1),O(!1),q(""),z({}),I())},[e,t?.id,t?.name]);let B=e=>e.trim()?p.test(e)?(q(""),!0):(q("Only letters, numbers, -, _ and . allowed"),!1):(q("Name is required"),!1),H=async()=>{if(B(b)){if(0===g.length)return void(0,x.s)("Add at least one model to the combo");if("auto"===y&&g.length<2)return void(0,x.s)("Auto strategy needs at least 2 models in the worker pool (plus a connected router account)");O(!0),await i({name:b.trim(),models:g,strategy:y,capacityAutoSwitch:"auto"===y||C}),O(!1)}},J=!!t;return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(d.aF,{isOpen:e,onClose:a,title:J?"Edit Combo":"Create Combo",children:(0,l.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,l.jsxs)("p",{className:"text-xs text-text-muted leading-relaxed",children:["Clients call this combo by name as the ",(0,l.jsx)("code",{className:"text-primary",children:"model"})," field. Strategy controls how models in the list are used."]}),(0,l.jsxs)("div",{children:[(0,l.jsx)(d.pd,{label:"Combo Name",value:b,onChange:e=>{let t=e.target.value;f(t),t?B(t):q("")},placeholder:"my-combo",error:$}),(0,l.jsx)("p",{className:"text-[10px] text-text-muted mt-0.5",children:"Only letters, numbers, -, _ and . allowed \xb7 use as model id in /v1"})]}),(0,l.jsxs)("div",{children:[(0,l.jsx)("label",{className:"text-sm font-medium mb-1.5 block",children:"Strategy"}),(0,l.jsx)(d.l6,{options:k,value:y,onChange:e=>N(e.target.value),selectClassName:"py-2 text-sm"}),(0,l.jsx)("p",{className:"text-[11px] text-text-muted mt-1.5",children:w[y]}),"auto"===y&&(0,l.jsxs)("p",{className:"text-[11px] text-amber-600 dark:text-amber-400 mt-1 flex items-center gap-1",children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[12px]",children:"info"}),"Auto requires a router model — select one on the combo card after saving."]}),"auto"!==y&&(0,l.jsxs)("label",{className:"mt-2 inline-flex items-center gap-2 text-xs text-text-muted cursor-pointer",children:[(0,l.jsx)("input",{type:"checkbox",className:"rounded border-border",checked:C,onChange:e=>S(e.target.checked)}),"Capacity auto-switch — prefer vision/PDF-capable models when the request needs them"]}),"auto"===y&&(0,l.jsx)("p",{className:"text-[11px] text-text-subtle mt-1.5 font-mono",children:"After create: set Router model on the combo card (must be a connected account). Workers = this model list (router excluded if listed)."}),"fusion"===y&&(0,l.jsx)("p",{className:"text-[11px] text-text-subtle mt-1.5 font-mono",children:"After create: optionally set Judge on the combo card (default = first model)."})]}),(0,l.jsxs)("div",{children:[(0,l.jsxs)("label",{className:"text-sm font-medium mb-1.5 block",children:["Models ","fallback"===y?"(order = priority)":"(pool)"]}),g.length>0&&v(g,null,m)&&(0,l.jsxs)("p",{className:"text-[10px] text-amber-600 dark:text-amber-400 flex items-center gap-1 mb-1",children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[12px]",children:"warning"}),"No vision-capable model — image requests will have images stripped"]}),0===g.length?(0,l.jsxs)("div",{className:"text-center py-4 border border-dashed border-black/10 dark:border-white/10 rounded-lg bg-black/[0.01] dark:bg-white/[0.01]",children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-text-muted text-xl mb-1",children:"layers"}),(0,l.jsx)("p",{className:"text-xs text-text-muted",children:"No models added yet"})]}):(0,l.jsx)(r.Mp,{sensors:L,collisionDetection:r.fp,onDragEnd:e=>{let{active:t,over:a}=e;if(a&&t.id!==a.id){let e=T.findIndex(e=>e.uid===t.id),l=T.findIndex(e=>e.uid===a.id);-1!==e&&-1!==l&&j(t=>(0,o.be)(t,e,l))}},modifiers:[n.FN,n.gj],children:(0,l.jsx)(o.gB,{items:T.map(e=>e.uid),strategy:o._G,children:(0,l.jsx)("div",{className:"flex max-h-[55vh] min-w-0 flex-col gap-1 overflow-y-auto sm:max-h-[350px]",children:T.map(({uid:e,model:t},a)=>(0,l.jsx)(A,{id:e,index:a,model:t,learned:_[t]||null,isFirst:0===a,isLast:a===T.length-1,onEdit:e=>{let t=[...g];t[a]=e,j(t)},onMoveUp:()=>(e=>{if(0===e)return;let t=[...g];[t[e-1],t[e]]=[t[e],t[e-1]],j(t)})(a),onMoveDown:()=>(e=>{if(e===g.length-1)return;let t=[...g];[t[e],t[e+1]]=[t[e+1],t[e]],j(t)})(a),onRemove:()=>{j(g.filter((e,t)=>t!==a))}},e))})})}),(0,l.jsxs)("button",{onClick:()=>F(!0),className:"w-full mt-2 py-2 border border-dashed border-black/10 dark:border-white/10 rounded-lg text-xs text-primary font-medium hover:text-primary hover:border-primary/50 transition-colors flex items-center justify-center gap-1",children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"add"}),"Add Model"]})]}),(0,l.jsxs)("div",{className:"flex flex-col gap-2 pt-1 sm:flex-row",children:[(0,l.jsx)(d.$n,{onClick:a,variant:"ghost",fullWidth:!0,size:"sm",children:"Cancel"}),(0,l.jsx)(d.$n,{onClick:H,fullWidth:!0,size:"sm",disabled:!b.trim()||!!$||E,children:E?"Saving...":J?"Save":"Create"})]})]})}),(0,l.jsx)(d.rq,{isOpen:R,onClose:()=>F(!1),onSelect:e=>{g.includes(e.value)||j([...g,e.value])},onDeselect:e=>{j(g.filter(t=>t!==e.value))},activeProviders:c,modelAliases:P,title:"Add Model to Combo",kindFilter:u,addedModelValues:g,closeOnSelect:!1})]})}function R({capacityAdapter:e,onChange:t,activeProviders:a,getCaps:s}){return(0,l.jsx)(d.Zp,{padding:"sm",children:(0,l.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,l.jsx)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:(0,l.jsxs)("div",{className:"min-w-0",children:[(0,l.jsx)("p",{className:"text-sm font-medium text-text-main",children:"Capacity Adapter"}),(0,l.jsx)("p",{className:"text-xs text-text-muted mt-0.5",children:"Request carries images or audio your model can't read? Auto-switches to a model in the pool below."}),(0,l.jsxs)("ul",{className:"mt-1.5 text-[11px] text-text-muted flex flex-col gap-0.5",children:[(0,l.jsxs)("li",{children:[(0,l.jsx)("span",{className:"font-medium text-text-main",children:"Vision"})," — images (png, jpg, webp, …)"]}),(0,l.jsxs)("li",{children:[(0,l.jsx)("span",{className:"font-medium text-text-main",children:"Audio"})," — audio input"]})]})]})}),(0,l.jsx)("div",{className:"flex flex-col gap-4",children:h.map(r=>(0,l.jsx)(F,{cap:r,entry:e[r.key]||b,onChange:a=>t({...e,[r.key]:a}),activeProviders:a,getCaps:s},r.key))})]})})}function F({cap:e,entry:t,onChange:a,activeProviders:r,getCaps:o}){let[i,n]=(0,s.useState)(!1),{enabled:c,roundRobin:m,models:x}=t,u=e=>a({...t,...e}),p=(e,t)=>{let a=e+t;if(a<0||a>=x.length)return;let l=[...x];[l[e],l[a]]=[l[a],l[e]],u({models:l})};return(0,l.jsxs)("div",{className:`group rounded-lg border border-black/5 p-3 ${!c?"opacity-50":""} dark:border-white/10`,children:[(0,l.jsxs)("div",{className:"flex min-w-0 flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[(0,l.jsxs)("div",{className:"flex min-w-0 flex-1 items-start gap-2.5 sm:items-center",children:[(0,l.jsx)(d.lM,{checked:c,onChange:e=>u({enabled:e}),"aria-label":`Enable ${e.label} adapter`}),(0,l.jsx)("div",{className:"size-8 rounded-lg bg-primary/10 flex items-center justify-center shrink-0",children:(0,l.jsx)("span",{className:"material-symbols-outlined text-primary text-[18px]",children:e.icon})}),(0,l.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,l.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,l.jsx)("code",{className:"font-mono text-sm font-medium text-text-main",children:e.label}),(0,l.jsxs)("span",{className:"text-[10px] text-text-muted",children:["— ",e.desc]})]}),(0,l.jsx)("div",{className:"mt-1 flex min-w-0 flex-wrap items-center gap-1",children:0===x.length?(0,l.jsx)("span",{className:"text-xs text-text-muted italic",children:"No models"}):x.map((e,t)=>(0,l.jsxs)("code",{className:"group/chip inline-flex items-center gap-1 rounded bg-black/5 px-1.5 py-0.5 font-mono text-xs text-text-muted dark:bg-white/5",children:[(0,l.jsx)("span",{children:e}),(0,l.jsx)(d.nh,{caps:o?.(e)}),(0,l.jsx)("button",{onClick:()=>p(t,-1),disabled:0===t,className:`leading-none opacity-0 group-hover/chip:opacity-100 ${0===t?"text-text-muted/20":"text-text-muted hover:text-primary"}`,children:(0,l.jsx)("span",{className:"material-symbols-outlined text-[12px]",children:"arrow_upward"})}),(0,l.jsx)("button",{onClick:()=>p(t,1),disabled:t===x.length-1,className:`leading-none opacity-0 group-hover/chip:opacity-100 ${t===x.length-1?"text-text-muted/20":"text-text-muted hover:text-primary"}`,children:(0,l.jsx)("span",{className:"material-symbols-outlined text-[12px]",children:"arrow_downward"})}),(0,l.jsx)("button",{onClick:()=>{let e;u({models:0===(e=x.filter((e,a)=>a!==t)).length?["oc/mimo-v2.5-free"]:e})},className:"leading-none opacity-0 group-hover/chip:opacity-100 text-text-muted hover:text-red-500",children:(0,l.jsx)("span",{className:"material-symbols-outlined text-[12px]",children:"close"})})]},`${e}-${t}`))})]})]}),(0,l.jsxs)("div",{className:"flex w-full flex-col gap-2 sm:w-auto sm:flex-row sm:items-center sm:gap-3 sm:shrink-0",children:[(0,l.jsxs)("label",{className:"flex items-center gap-1.5 text-xs text-text-muted cursor-pointer select-none",children:[(0,l.jsx)(d.lM,{checked:m,onChange:e=>u({roundRobin:e}),disabled:!c,"aria-label":`Round-robin ${e.label} adapter`}),(0,l.jsx)("span",{children:"Round"})]}),(0,l.jsx)(d.$n,{icon:"add",variant:"ghost",size:"sm",onClick:()=>n(!0),disabled:!c,title:`Add ${e.label} model`,children:"Add Model"})]})]}),i&&(0,l.jsx)(d.rq,{isOpen:i,onClose:()=>n(!1),onSelect:e=>{x.includes(e.value)||u({models:[...x,e.value]})},activeProviders:r,title:`Add ${e.label} Model`,addedModelValues:x,capFilter:e.key,closeOnSelect:!1})]})}},80063:(e,t,a)=>{Promise.resolve().then(a.bind(a,41483))}},e=>{e.O(0,[2574,3862,782,8500,594,7055,1321,4707,1330,8441,3794,7358],()=>e(e.s=80063)),_N_E=e.O()}]);