switchboard-router 0.9.0 → 0.9.2

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 (381) hide show
  1. package/app/.next/static/chunks/{1321-ba836ca888fbad7c.js → 1321-4de88db4bd94a23c.js} +1 -1
  2. package/app/{.next-cli-build/static/chunks/3531-e8d13ec64699f527.js → .next/static/chunks/3531-936a1e7912d9876c.js} +8 -8
  3. package/app/.next/static/chunks/app/(dashboard)/dashboard/media-providers/[kind]/[id]/{page-995a96a01c24b126.js → page-772f246688672d59.js} +12 -12
  4. package/app/.next/static/chunks/app/(dashboard)/dashboard/providers/[id]/page-d8610d9b77a2cae4.js +10 -0
  5. package/app/.next/static/css/d89fdbc0e71b454e.css +1 -0
  6. package/app/.next-cli-build/BUILD_ID +1 -1
  7. package/app/.next-cli-build/app-path-routes-manifest.json +6 -6
  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.nft.json +1 -1
  19. package/app/.next-cli-build/server/app/(dashboard)/dashboard/combos/page_client-reference-manifest.js +1 -1
  20. package/app/.next-cli-build/server/app/(dashboard)/dashboard/combos/routing/page.js.nft.json +1 -1
  21. package/app/.next-cli-build/server/app/(dashboard)/dashboard/combos/routing/page_client-reference-manifest.js +1 -1
  22. package/app/.next-cli-build/server/app/(dashboard)/dashboard/console-log/page.js.nft.json +1 -1
  23. package/app/.next-cli-build/server/app/(dashboard)/dashboard/console-log/page_client-reference-manifest.js +1 -1
  24. package/app/.next-cli-build/server/app/(dashboard)/dashboard/endpoint/page.js.nft.json +1 -1
  25. package/app/.next-cli-build/server/app/(dashboard)/dashboard/endpoint/page_client-reference-manifest.js +1 -1
  26. package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/[kind]/[id]/page.js +1 -1
  27. package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/[kind]/[id]/page.js.nft.json +1 -1
  28. package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/[kind]/[id]/page_client-reference-manifest.js +1 -1
  29. package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/[kind]/page.js.nft.json +1 -1
  30. package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/[kind]/page_client-reference-manifest.js +1 -1
  31. package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/combo/[id]/page.js.nft.json +1 -1
  32. package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/combo/[id]/page_client-reference-manifest.js +1 -1
  33. package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/page.js.nft.json +1 -1
  34. package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/page_client-reference-manifest.js +1 -1
  35. package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/web/page.js.nft.json +1 -1
  36. package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/web/page_client-reference-manifest.js +1 -1
  37. package/app/.next-cli-build/server/app/(dashboard)/dashboard/mitm/page.js.nft.json +1 -1
  38. package/app/.next-cli-build/server/app/(dashboard)/dashboard/mitm/page_client-reference-manifest.js +1 -1
  39. package/app/.next-cli-build/server/app/(dashboard)/dashboard/page.js.nft.json +1 -1
  40. package/app/.next-cli-build/server/app/(dashboard)/dashboard/page_client-reference-manifest.js +1 -1
  41. package/app/.next-cli-build/server/app/(dashboard)/dashboard/profile/page.js.nft.json +1 -1
  42. package/app/.next-cli-build/server/app/(dashboard)/dashboard/profile/page_client-reference-manifest.js +1 -1
  43. package/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/[id]/page.js +2 -2
  44. package/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/[id]/page.js.nft.json +1 -1
  45. package/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/[id]/page_client-reference-manifest.js +1 -1
  46. package/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/new/page.js.nft.json +1 -1
  47. package/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/new/page_client-reference-manifest.js +1 -1
  48. package/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/page.js.nft.json +1 -1
  49. package/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/page_client-reference-manifest.js +1 -1
  50. package/app/.next-cli-build/server/app/(dashboard)/dashboard/pxpipe/page.js.nft.json +1 -1
  51. package/app/.next-cli-build/server/app/(dashboard)/dashboard/pxpipe/page_client-reference-manifest.js +1 -1
  52. package/app/.next-cli-build/server/app/(dashboard)/dashboard/quota/page.js.nft.json +1 -1
  53. package/app/.next-cli-build/server/app/(dashboard)/dashboard/quota/page_client-reference-manifest.js +1 -1
  54. package/app/.next-cli-build/server/app/(dashboard)/dashboard/skills/[id]/page.js.nft.json +1 -1
  55. package/app/.next-cli-build/server/app/(dashboard)/dashboard/skills/[id]/page_client-reference-manifest.js +1 -1
  56. package/app/.next-cli-build/server/app/(dashboard)/dashboard/skills/page.js.nft.json +1 -1
  57. package/app/.next-cli-build/server/app/(dashboard)/dashboard/skills/page_client-reference-manifest.js +1 -1
  58. package/app/.next-cli-build/server/app/(dashboard)/dashboard/token-saver/page.js.nft.json +1 -1
  59. package/app/.next-cli-build/server/app/(dashboard)/dashboard/token-saver/page_client-reference-manifest.js +1 -1
  60. package/app/.next-cli-build/server/app/(dashboard)/dashboard/translator/page.js.nft.json +1 -1
  61. package/app/.next-cli-build/server/app/(dashboard)/dashboard/translator/page_client-reference-manifest.js +1 -1
  62. package/app/.next-cli-build/server/app/(dashboard)/dashboard/usage/page.js.nft.json +1 -1
  63. package/app/.next-cli-build/server/app/(dashboard)/dashboard/usage/page_client-reference-manifest.js +1 -1
  64. package/app/.next-cli-build/server/app/_global-error/page.js.nft.json +1 -1
  65. package/app/.next-cli-build/server/app/_global-error/page_client-reference-manifest.js +1 -1
  66. package/app/.next-cli-build/server/app/_global-error.html +1 -1
  67. package/app/.next-cli-build/server/app/_global-error.rsc +1 -1
  68. package/app/.next-cli-build/server/app/_global-error.segments/_full.segment.rsc +1 -1
  69. package/app/.next-cli-build/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
  70. package/app/.next-cli-build/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  71. package/app/.next-cli-build/server/app/_not-found/page.js.nft.json +1 -1
  72. package/app/.next-cli-build/server/app/_not-found/page_client-reference-manifest.js +1 -1
  73. package/app/.next-cli-build/server/app/_not-found.html +1 -1
  74. package/app/.next-cli-build/server/app/_not-found.rsc +4 -4
  75. package/app/.next-cli-build/server/app/_not-found.segments/_full.segment.rsc +4 -4
  76. package/app/.next-cli-build/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +4 -4
  77. package/app/.next-cli-build/server/app/_not-found.segments/_tree.segment.rsc +2 -2
  78. package/app/.next-cli-build/server/app/api/agent-library/catalog/route.js.nft.json +1 -1
  79. package/app/.next-cli-build/server/app/api/agent-library/doctor/route.js.nft.json +1 -1
  80. package/app/.next-cli-build/server/app/api/agent-library/export/route.js.nft.json +1 -1
  81. package/app/.next-cli-build/server/app/api/agent-library/mcp/route.js.nft.json +1 -1
  82. package/app/.next-cli-build/server/app/api/agent-library/route.js.nft.json +1 -1
  83. package/app/.next-cli-build/server/app/api/agent-library/skills/route.js.nft.json +1 -1
  84. package/app/.next-cli-build/server/app/api/agent-library/sync/route.js.nft.json +1 -1
  85. package/app/.next-cli-build/server/app/api/agent-library/updates/route.js.nft.json +1 -1
  86. package/app/.next-cli-build/server/app/api/auth/status/route.js.nft.json +1 -1
  87. package/app/.next-cli-build/server/app/api/cli-tools/aider-settings/route.js +2 -2
  88. package/app/.next-cli-build/server/app/api/cli-tools/aider-settings/route.js.nft.json +1 -1
  89. package/app/.next-cli-build/server/app/api/cli-tools/all-statuses/route.js +10 -10
  90. package/app/.next-cli-build/server/app/api/cli-tools/all-statuses/route.js.nft.json +1 -1
  91. package/app/.next-cli-build/server/app/api/cli-tools/antigravity-mitm/alias/route.js +2 -2
  92. package/app/.next-cli-build/server/app/api/cli-tools/antigravity-mitm/alias/route.js.nft.json +1 -1
  93. package/app/.next-cli-build/server/app/api/cli-tools/antigravity-mitm/route.js +1 -1
  94. package/app/.next-cli-build/server/app/api/cli-tools/antigravity-mitm/route.js.nft.json +1 -1
  95. package/app/.next-cli-build/server/app/api/cli-tools/claude-full-catalog/route.js.nft.json +1 -1
  96. package/app/.next-cli-build/server/app/api/cli-tools/claude-picker-labels/route.js.nft.json +1 -1
  97. package/app/.next-cli-build/server/app/api/cli-tools/claude-settings/route.js +1 -1
  98. package/app/.next-cli-build/server/app/api/cli-tools/claude-settings/route.js.nft.json +1 -1
  99. package/app/.next-cli-build/server/app/api/cli-tools/cline-settings/route.js +2 -2
  100. package/app/.next-cli-build/server/app/api/cli-tools/cline-settings/route.js.nft.json +1 -1
  101. package/app/.next-cli-build/server/app/api/cli-tools/codex-settings/route.js +1 -1
  102. package/app/.next-cli-build/server/app/api/cli-tools/codex-settings/route.js.nft.json +1 -1
  103. package/app/.next-cli-build/server/app/api/cli-tools/cowork-mcp-registry/route.js +2 -2
  104. package/app/.next-cli-build/server/app/api/cli-tools/cowork-mcp-registry/route.js.nft.json +1 -1
  105. package/app/.next-cli-build/server/app/api/cli-tools/cowork-mcp-tools/route.js +1 -1
  106. package/app/.next-cli-build/server/app/api/cli-tools/cowork-mcp-tools/route.js.nft.json +1 -1
  107. package/app/.next-cli-build/server/app/api/cli-tools/cowork-settings/route.js +1 -1
  108. package/app/.next-cli-build/server/app/api/cli-tools/cowork-settings/route.js.nft.json +1 -1
  109. package/app/.next-cli-build/server/app/api/cli-tools/deepseek-tui-settings/route.js +1 -1
  110. package/app/.next-cli-build/server/app/api/cli-tools/deepseek-tui-settings/route.js.nft.json +1 -1
  111. package/app/.next-cli-build/server/app/api/cli-tools/droid-settings/route.js +2 -2
  112. package/app/.next-cli-build/server/app/api/cli-tools/droid-settings/route.js.nft.json +1 -1
  113. package/app/.next-cli-build/server/app/api/cli-tools/gemini-cli-settings/route.js +5 -5
  114. package/app/.next-cli-build/server/app/api/cli-tools/gemini-cli-settings/route.js.nft.json +1 -1
  115. package/app/.next-cli-build/server/app/api/cli-tools/grok-settings/route.js +5 -5
  116. package/app/.next-cli-build/server/app/api/cli-tools/grok-settings/route.js.nft.json +1 -1
  117. package/app/.next-cli-build/server/app/api/cli-tools/hermes-settings/route.js +3 -3
  118. package/app/.next-cli-build/server/app/api/cli-tools/hermes-settings/route.js.nft.json +1 -1
  119. package/app/.next-cli-build/server/app/api/cli-tools/jcode-settings/route.js +3 -3
  120. package/app/.next-cli-build/server/app/api/cli-tools/jcode-settings/route.js.nft.json +1 -1
  121. package/app/.next-cli-build/server/app/api/cli-tools/kilo-settings/route.js +2 -2
  122. package/app/.next-cli-build/server/app/api/cli-tools/kilo-settings/route.js.nft.json +1 -1
  123. package/app/.next-cli-build/server/app/api/cli-tools/openclaw-settings/route.js +2 -2
  124. package/app/.next-cli-build/server/app/api/cli-tools/openclaw-settings/route.js.nft.json +1 -1
  125. package/app/.next-cli-build/server/app/api/cli-tools/opencode-settings/route.js +2 -2
  126. package/app/.next-cli-build/server/app/api/cli-tools/opencode-settings/route.js.nft.json +1 -1
  127. package/app/.next-cli-build/server/app/api/cli-tools/pi-settings/route.js +1 -1
  128. package/app/.next-cli-build/server/app/api/cli-tools/pi-settings/route.js.nft.json +1 -1
  129. package/app/.next-cli-build/server/app/api/cli-tools/picker-labels/route.js.nft.json +1 -1
  130. package/app/.next-cli-build/server/app/api/combos/[id]/route.js +1 -1
  131. package/app/.next-cli-build/server/app/api/combos/[id]/route.js.nft.json +1 -1
  132. package/app/.next-cli-build/server/app/api/combos/route.js +1 -1
  133. package/app/.next-cli-build/server/app/api/combos/route.js.nft.json +1 -1
  134. package/app/.next-cli-build/server/app/api/headroom/extras/route.js.nft.json +1 -1
  135. package/app/.next-cli-build/server/app/api/headroom/proxy/[...path]/route.js.nft.json +1 -1
  136. package/app/.next-cli-build/server/app/api/headroom/restart/route.js.nft.json +1 -1
  137. package/app/.next-cli-build/server/app/api/headroom/start/route.js.nft.json +1 -1
  138. package/app/.next-cli-build/server/app/api/headroom/status/route.js.nft.json +1 -1
  139. package/app/.next-cli-build/server/app/api/headroom/stop/route.js.nft.json +1 -1
  140. package/app/.next-cli-build/server/app/api/health/route.js.nft.json +1 -1
  141. package/app/.next-cli-build/server/app/api/keys/[id]/route.js.nft.json +1 -1
  142. package/app/.next-cli-build/server/app/api/keys/route.js +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 +1 -1
  145. package/app/.next-cli-build/server/app/api/locale/route.js.nft.json +1 -1
  146. package/app/.next-cli-build/server/app/api/mcp/[plugin]/message/route.js.nft.json +1 -1
  147. package/app/.next-cli-build/server/app/api/mcp/[plugin]/sse/route.js.nft.json +1 -1
  148. package/app/.next-cli-build/server/app/api/media-providers/tts/deepgram/voices/route.js.nft.json +1 -1
  149. package/app/.next-cli-build/server/app/api/media-providers/tts/elevenlabs/voices/route.js.nft.json +1 -1
  150. package/app/.next-cli-build/server/app/api/media-providers/tts/inworld/voices/route.js.nft.json +1 -1
  151. package/app/.next-cli-build/server/app/api/media-providers/tts/minimax/voices/route.js.nft.json +1 -1
  152. package/app/.next-cli-build/server/app/api/media-providers/tts/voices/route.js.nft.json +1 -1
  153. package/app/.next-cli-build/server/app/api/mgmt/v1/combos/[id]/route.js +1 -1
  154. package/app/.next-cli-build/server/app/api/mgmt/v1/combos/[id]/route.js.nft.json +1 -1
  155. package/app/.next-cli-build/server/app/api/mgmt/v1/combos/[id]/strategy/route.js +1 -1
  156. package/app/.next-cli-build/server/app/api/mgmt/v1/combos/[id]/strategy/route.js.nft.json +1 -1
  157. package/app/.next-cli-build/server/app/api/mgmt/v1/combos/route.js +1 -1
  158. package/app/.next-cli-build/server/app/api/mgmt/v1/combos/route.js.nft.json +1 -1
  159. package/app/.next-cli-build/server/app/api/mgmt/v1/health/route.js.nft.json +1 -1
  160. package/app/.next-cli-build/server/app/api/mgmt/v1/metrics/route.js.nft.json +1 -1
  161. package/app/.next-cli-build/server/app/api/mgmt/v1/providers/route.js.nft.json +1 -1
  162. package/app/.next-cli-build/server/app/api/mgmt/v1/routing/route.js.nft.json +1 -1
  163. package/app/.next-cli-build/server/app/api/mgmt/v1/usage/route.js.nft.json +1 -1
  164. package/app/.next-cli-build/server/app/api/mgmt/v1/version/route.js.nft.json +1 -1
  165. package/app/.next-cli-build/server/app/api/models/alias/route.js +1 -1
  166. package/app/.next-cli-build/server/app/api/models/alias/route.js.nft.json +1 -1
  167. package/app/.next-cli-build/server/app/api/models/availability/route.js +1 -1
  168. package/app/.next-cli-build/server/app/api/models/availability/route.js.nft.json +1 -1
  169. package/app/.next-cli-build/server/app/api/models/custom/route.js +1 -1
  170. package/app/.next-cli-build/server/app/api/models/custom/route.js.nft.json +1 -1
  171. package/app/.next-cli-build/server/app/api/models/disabled/route.js +1 -1
  172. package/app/.next-cli-build/server/app/api/models/disabled/route.js.nft.json +1 -1
  173. package/app/.next-cli-build/server/app/api/models/route.js.nft.json +1 -1
  174. package/app/.next-cli-build/server/app/api/models/test/route.js +1 -1
  175. package/app/.next-cli-build/server/app/api/models/test/route.js.nft.json +1 -1
  176. package/app/.next-cli-build/server/app/api/oauth/[provider]/[action]/route.js +1 -1
  177. package/app/.next-cli-build/server/app/api/oauth/[provider]/[action]/route.js.nft.json +1 -1
  178. package/app/.next-cli-build/server/app/api/oauth/codex/bulk-import/route.js +1 -1
  179. package/app/.next-cli-build/server/app/api/oauth/codex/bulk-import/route.js.nft.json +1 -1
  180. package/app/.next-cli-build/server/app/api/oauth/codex/import-token/route.js +1 -1
  181. package/app/.next-cli-build/server/app/api/oauth/codex/import-token/route.js.nft.json +1 -1
  182. package/app/.next-cli-build/server/app/api/oauth/cursor/auto-import/route.js.nft.json +1 -1
  183. package/app/.next-cli-build/server/app/api/oauth/cursor/import/route.js +1 -1
  184. package/app/.next-cli-build/server/app/api/oauth/cursor/import/route.js.nft.json +1 -1
  185. package/app/.next-cli-build/server/app/api/oauth/gitlab/pat/route.js.nft.json +1 -1
  186. package/app/.next-cli-build/server/app/api/oauth/iflow/cookie/route.js +1 -1
  187. package/app/.next-cli-build/server/app/api/oauth/iflow/cookie/route.js.nft.json +1 -1
  188. package/app/.next-cli-build/server/app/api/oauth/kiro/api-key/route.js +1 -1
  189. package/app/.next-cli-build/server/app/api/oauth/kiro/api-key/route.js.nft.json +1 -1
  190. package/app/.next-cli-build/server/app/api/oauth/kiro/auto-import/route.js.nft.json +1 -1
  191. package/app/.next-cli-build/server/app/api/oauth/kiro/import/route.js +1 -1
  192. package/app/.next-cli-build/server/app/api/oauth/kiro/import/route.js.nft.json +1 -1
  193. package/app/.next-cli-build/server/app/api/oauth/kiro/import-cli-proxy/route.js +1 -1
  194. package/app/.next-cli-build/server/app/api/oauth/kiro/import-cli-proxy/route.js.nft.json +1 -1
  195. package/app/.next-cli-build/server/app/api/oauth/kiro/social-authorize/route.js.nft.json +1 -1
  196. package/app/.next-cli-build/server/app/api/oauth/kiro/social-exchange/route.js +1 -1
  197. package/app/.next-cli-build/server/app/api/oauth/kiro/social-exchange/route.js.nft.json +1 -1
  198. package/app/.next-cli-build/server/app/api/pricing/route.js +1 -1
  199. package/app/.next-cli-build/server/app/api/pricing/route.js.nft.json +1 -1
  200. package/app/.next-cli-build/server/app/api/provider-nodes/[id]/route.js +1 -1
  201. package/app/.next-cli-build/server/app/api/provider-nodes/[id]/route.js.nft.json +1 -1
  202. package/app/.next-cli-build/server/app/api/provider-nodes/route.js +1 -1
  203. package/app/.next-cli-build/server/app/api/provider-nodes/route.js.nft.json +1 -1
  204. package/app/.next-cli-build/server/app/api/provider-nodes/validate/route.js +1 -1
  205. package/app/.next-cli-build/server/app/api/provider-nodes/validate/route.js.nft.json +1 -1
  206. package/app/.next-cli-build/server/app/api/providers/[id]/model-probes/batch/route.js.nft.json +1 -1
  207. package/app/.next-cli-build/server/app/api/providers/[id]/model-probes/cache/route.js.nft.json +1 -1
  208. package/app/.next-cli-build/server/app/api/providers/[id]/model-probes/prepare/route.js.nft.json +1 -1
  209. package/app/.next-cli-build/server/app/api/providers/[id]/model-probes/remove-unavailable/route.js.nft.json +1 -1
  210. package/app/.next-cli-build/server/app/api/providers/[id]/model-probes/route.js.nft.json +1 -1
  211. package/app/.next-cli-build/server/app/api/providers/[id]/model-probes/verify/cancel/route.js.nft.json +1 -1
  212. package/app/.next-cli-build/server/app/api/providers/[id]/model-probes/verify/start/route.js.nft.json +1 -1
  213. package/app/.next-cli-build/server/app/api/providers/[id]/model-probes/verify/status/route.js.nft.json +1 -1
  214. package/app/.next-cli-build/server/app/api/providers/[id]/models/route.js +1 -1
  215. package/app/.next-cli-build/server/app/api/providers/[id]/models/route.js.nft.json +1 -1
  216. package/app/.next-cli-build/server/app/api/providers/[id]/route.js +1 -1
  217. package/app/.next-cli-build/server/app/api/providers/[id]/route.js.nft.json +1 -1
  218. package/app/.next-cli-build/server/app/api/providers/[id]/test/route.js.nft.json +1 -1
  219. package/app/.next-cli-build/server/app/api/providers/[id]/test-models/route.js.nft.json +1 -1
  220. package/app/.next-cli-build/server/app/api/providers/client/route.js +1 -1
  221. package/app/.next-cli-build/server/app/api/providers/client/route.js.nft.json +1 -1
  222. package/app/.next-cli-build/server/app/api/providers/kilo/free-models/route.js.nft.json +1 -1
  223. package/app/.next-cli-build/server/app/api/providers/route.js +1 -1
  224. package/app/.next-cli-build/server/app/api/providers/route.js.nft.json +1 -1
  225. package/app/.next-cli-build/server/app/api/providers/suggested-models/route.js.nft.json +1 -1
  226. package/app/.next-cli-build/server/app/api/providers/test-batch/route.js.nft.json +1 -1
  227. package/app/.next-cli-build/server/app/api/providers/validate/route.js.nft.json +1 -1
  228. package/app/.next-cli-build/server/app/api/pxpipe/health/route.js.nft.json +1 -1
  229. package/app/.next-cli-build/server/app/api/pxpipe/install/route.js.nft.json +1 -1
  230. package/app/.next-cli-build/server/app/api/pxpipe/logs/route.js.nft.json +1 -1
  231. package/app/.next-cli-build/server/app/api/pxpipe/restart/route.js.nft.json +1 -1
  232. package/app/.next-cli-build/server/app/api/pxpipe/start/route.js.nft.json +1 -1
  233. package/app/.next-cli-build/server/app/api/pxpipe/stats/route.js.nft.json +1 -1
  234. package/app/.next-cli-build/server/app/api/pxpipe/status/route.js.nft.json +1 -1
  235. package/app/.next-cli-build/server/app/api/pxpipe/stop/route.js.nft.json +1 -1
  236. package/app/.next-cli-build/server/app/api/routing/feedback/route.js +1 -1
  237. package/app/.next-cli-build/server/app/api/routing/feedback/route.js.nft.json +1 -1
  238. package/app/.next-cli-build/server/app/api/routing/insights/route.js.nft.json +1 -1
  239. package/app/.next-cli-build/server/app/api/routing/learn/route.js.nft.json +1 -1
  240. package/app/.next-cli-build/server/app/api/routing/stats/route.js.nft.json +1 -1
  241. package/app/.next-cli-build/server/app/api/routing/versions/promote/route.js.nft.json +1 -1
  242. package/app/.next-cli-build/server/app/api/routing/versions/rollback/route.js.nft.json +1 -1
  243. package/app/.next-cli-build/server/app/api/settings/database/route.js.nft.json +1 -1
  244. package/app/.next-cli-build/server/app/api/settings/proxy-test/route.js.nft.json +1 -1
  245. package/app/.next-cli-build/server/app/api/settings/route.js +1 -1
  246. package/app/.next-cli-build/server/app/api/settings/route.js.nft.json +1 -1
  247. package/app/.next-cli-build/server/app/api/shutdown/route.js.nft.json +1 -1
  248. package/app/.next-cli-build/server/app/api/skills/[id]/route.js.nft.json +1 -1
  249. package/app/.next-cli-build/server/app/api/tags/route.js.nft.json +1 -1
  250. package/app/.next-cli-build/server/app/api/token-saver/vault-stats/route.js.nft.json +1 -1
  251. package/app/.next-cli-build/server/app/api/translator/console-logs/route.js.nft.json +1 -1
  252. package/app/.next-cli-build/server/app/api/translator/console-logs/stream/route.js.nft.json +1 -1
  253. package/app/.next-cli-build/server/app/api/translator/load/route.js.nft.json +1 -1
  254. package/app/.next-cli-build/server/app/api/translator/save/route.js.nft.json +1 -1
  255. package/app/.next-cli-build/server/app/api/translator/send/route.js +1 -1
  256. package/app/.next-cli-build/server/app/api/translator/send/route.js.nft.json +1 -1
  257. package/app/.next-cli-build/server/app/api/translator/translate/route.js +1 -1
  258. package/app/.next-cli-build/server/app/api/translator/translate/route.js.nft.json +1 -1
  259. package/app/.next-cli-build/server/app/api/usage/[connectionId]/codex-reset-credits/route.js.nft.json +1 -1
  260. package/app/.next-cli-build/server/app/api/usage/[connectionId]/route.js.nft.json +1 -1
  261. package/app/.next-cli-build/server/app/api/usage/chart/route.js.nft.json +1 -1
  262. package/app/.next-cli-build/server/app/api/usage/history/route.js.nft.json +1 -1
  263. package/app/.next-cli-build/server/app/api/usage/logs/route.js.nft.json +1 -1
  264. package/app/.next-cli-build/server/app/api/usage/providers/route.js.nft.json +1 -1
  265. package/app/.next-cli-build/server/app/api/usage/request-details/route.js.nft.json +1 -1
  266. package/app/.next-cli-build/server/app/api/usage/request-logs/route.js.nft.json +1 -1
  267. package/app/.next-cli-build/server/app/api/usage/stats/route.js.nft.json +1 -1
  268. package/app/.next-cli-build/server/app/api/usage/stream/route.js.nft.json +1 -1
  269. package/app/.next-cli-build/server/app/api/v1/api/chat/route.js.nft.json +1 -1
  270. package/app/.next-cli-build/server/app/api/v1/audio/speech/route.js +1 -1
  271. package/app/.next-cli-build/server/app/api/v1/audio/speech/route.js.nft.json +1 -1
  272. package/app/.next-cli-build/server/app/api/v1/audio/transcriptions/route.js +1 -1
  273. package/app/.next-cli-build/server/app/api/v1/audio/transcriptions/route.js.nft.json +1 -1
  274. package/app/.next-cli-build/server/app/api/v1/audio/voices/route.js.nft.json +1 -1
  275. package/app/.next-cli-build/server/app/api/v1/chat/completions/route.js.nft.json +1 -1
  276. package/app/.next-cli-build/server/app/api/v1/embeddings/route.js.nft.json +1 -1
  277. package/app/.next-cli-build/server/app/api/v1/images/generations/route.js.nft.json +1 -1
  278. package/app/.next-cli-build/server/app/api/v1/messages/count_tokens/route.js.nft.json +1 -1
  279. package/app/.next-cli-build/server/app/api/v1/messages/route.js.nft.json +1 -1
  280. package/app/.next-cli-build/server/app/api/v1/models/[kind]/route.js.nft.json +1 -1
  281. package/app/.next-cli-build/server/app/api/v1/models/info/route.js.nft.json +1 -1
  282. package/app/.next-cli-build/server/app/api/v1/models/route.js.nft.json +1 -1
  283. package/app/.next-cli-build/server/app/api/v1/responses/compact/route.js.nft.json +1 -1
  284. package/app/.next-cli-build/server/app/api/v1/responses/route.js.nft.json +1 -1
  285. package/app/.next-cli-build/server/app/api/v1/route.js.nft.json +1 -1
  286. package/app/.next-cli-build/server/app/api/v1/search/route.js.nft.json +1 -1
  287. package/app/.next-cli-build/server/app/api/v1/videos/[id]/route.js.nft.json +1 -1
  288. package/app/.next-cli-build/server/app/api/v1/videos/edits/route.js.nft.json +1 -1
  289. package/app/.next-cli-build/server/app/api/v1/videos/extensions/route.js.nft.json +1 -1
  290. package/app/.next-cli-build/server/app/api/v1/videos/generations/route.js.nft.json +1 -1
  291. package/app/.next-cli-build/server/app/api/v1/web/fetch/route.js.nft.json +1 -1
  292. package/app/.next-cli-build/server/app/api/v1beta/models/[...path]/route.js +1 -1
  293. package/app/.next-cli-build/server/app/api/v1beta/models/[...path]/route.js.nft.json +1 -1
  294. package/app/.next-cli-build/server/app/api/v1beta/models/route.js.nft.json +1 -1
  295. package/app/.next-cli-build/server/app/api/version/route.js +1 -1
  296. package/app/.next-cli-build/server/app/api/version/route.js.nft.json +1 -1
  297. package/app/.next-cli-build/server/app/api/version/shutdown/route.js.nft.json +1 -1
  298. package/app/.next-cli-build/server/app/api/version/update/route.js.nft.json +1 -1
  299. package/app/.next-cli-build/server/app/callback/page.js.nft.json +1 -1
  300. package/app/.next-cli-build/server/app/callback/page_client-reference-manifest.js +1 -1
  301. package/app/.next-cli-build/server/app/callback.html +1 -1
  302. package/app/.next-cli-build/server/app/callback.rsc +4 -4
  303. package/app/.next-cli-build/server/app/callback.segments/_full.segment.rsc +4 -4
  304. package/app/.next-cli-build/server/app/callback.segments/_tree.segment.rsc +2 -2
  305. package/app/.next-cli-build/server/app/callback.segments/callback/__PAGE__.segment.rsc +4 -4
  306. package/app/.next-cli-build/server/app/dashboard/settings/pricing/page.js.nft.json +1 -1
  307. package/app/.next-cli-build/server/app/dashboard/settings/pricing/page_client-reference-manifest.js +1 -1
  308. package/app/.next-cli-build/server/app/dashboard/settings/pricing.html +1 -1
  309. package/app/.next-cli-build/server/app/dashboard/settings/pricing.rsc +4 -4
  310. package/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/_full.segment.rsc +4 -4
  311. package/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/_tree.segment.rsc +2 -2
  312. package/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/dashboard/settings/pricing/__PAGE__.segment.rsc +4 -4
  313. package/app/.next-cli-build/server/app/favicon.ico/route.js.nft.json +1 -1
  314. package/app/.next-cli-build/server/app/index.html +1 -1
  315. package/app/.next-cli-build/server/app/index.rsc +4 -4
  316. package/app/.next-cli-build/server/app/index.segments/__PAGE__.segment.rsc +4 -4
  317. package/app/.next-cli-build/server/app/index.segments/_full.segment.rsc +4 -4
  318. package/app/.next-cli-build/server/app/index.segments/_tree.segment.rsc +2 -2
  319. package/app/.next-cli-build/server/app/landing/page.js.nft.json +1 -1
  320. package/app/.next-cli-build/server/app/landing/page_client-reference-manifest.js +1 -1
  321. package/app/.next-cli-build/server/app/landing.html +1 -1
  322. package/app/.next-cli-build/server/app/landing.rsc +4 -4
  323. package/app/.next-cli-build/server/app/landing.segments/_full.segment.rsc +4 -4
  324. package/app/.next-cli-build/server/app/landing.segments/_tree.segment.rsc +2 -2
  325. package/app/.next-cli-build/server/app/landing.segments/landing/__PAGE__.segment.rsc +4 -4
  326. package/app/.next-cli-build/server/app/login/page.js.nft.json +1 -1
  327. package/app/.next-cli-build/server/app/login/page_client-reference-manifest.js +1 -1
  328. package/app/.next-cli-build/server/app/login.html +1 -1
  329. package/app/.next-cli-build/server/app/login.rsc +4 -4
  330. package/app/.next-cli-build/server/app/login.segments/_full.segment.rsc +4 -4
  331. package/app/.next-cli-build/server/app/login.segments/_tree.segment.rsc +2 -2
  332. package/app/.next-cli-build/server/app/login.segments/login/__PAGE__.segment.rsc +4 -4
  333. package/app/.next-cli-build/server/app/manifest.webmanifest/route.js.nft.json +1 -1
  334. package/app/.next-cli-build/server/app/page.js.nft.json +1 -1
  335. package/app/.next-cli-build/server/app/page_client-reference-manifest.js +1 -1
  336. package/app/.next-cli-build/server/app-paths-manifest.json +6 -6
  337. package/app/.next-cli-build/server/chunks/1350.js +1 -1
  338. package/app/.next-cli-build/server/chunks/194.js +1 -1
  339. package/app/.next-cli-build/server/chunks/369.js +2 -2
  340. package/app/.next-cli-build/server/chunks/3735.js +2 -2
  341. package/app/.next-cli-build/server/chunks/440.js +1 -1
  342. package/app/.next-cli-build/server/chunks/5616.js +1 -1
  343. package/app/.next-cli-build/server/chunks/5717.js +2 -2
  344. package/app/.next-cli-build/server/chunks/5781.js +1 -1
  345. package/app/.next-cli-build/server/chunks/6052.js +1 -1
  346. package/app/.next-cli-build/server/chunks/6274.js +1 -1
  347. package/app/.next-cli-build/server/chunks/6328.js +1 -1
  348. package/app/.next-cli-build/server/chunks/6395.js +1 -1
  349. package/app/.next-cli-build/server/chunks/646.js +17 -0
  350. package/app/.next-cli-build/server/chunks/6985.js +1 -1
  351. package/app/.next-cli-build/server/chunks/7454.js +1 -1
  352. package/app/.next-cli-build/server/chunks/869.js +1 -1
  353. package/app/.next-cli-build/server/chunks/8775.js +1 -1
  354. package/app/.next-cli-build/server/chunks/8998.js +8 -8
  355. package/app/.next-cli-build/server/middleware-build-manifest.js +1 -1
  356. package/app/.next-cli-build/server/middleware.js +2 -2
  357. package/app/.next-cli-build/server/pages/404.html +1 -1
  358. package/app/.next-cli-build/server/pages/500.html +1 -1
  359. package/app/.next-cli-build/server/server-reference-manifest.js +1 -1
  360. package/app/.next-cli-build/server/server-reference-manifest.json +1 -1
  361. package/app/.next-cli-build/static/chunks/{1321-ba836ca888fbad7c.js → 1321-4de88db4bd94a23c.js} +1 -1
  362. package/app/{.next/static/chunks/3531-e8d13ec64699f527.js → .next-cli-build/static/chunks/3531-936a1e7912d9876c.js} +8 -8
  363. package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/media-providers/[kind]/[id]/{page-995a96a01c24b126.js → page-772f246688672d59.js} +12 -12
  364. package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/providers/[id]/page-d8610d9b77a2cae4.js +10 -0
  365. package/app/.next-cli-build/static/css/d89fdbc0e71b454e.css +1 -0
  366. package/app/open-sse/identity/tls/bin/darwin/arm64/switchboard-claude-tls +0 -0
  367. package/app/open-sse/identity/tls/bin/darwin/x64/switchboard-claude-tls +0 -0
  368. package/app/open-sse/identity/tls/bin/linux/arm64/switchboard-claude-tls +0 -0
  369. package/app/open-sse/identity/tls/bin/linux/x64/switchboard-claude-tls +0 -0
  370. package/app/open-sse/identity/tls/bin/win32/arm64/switchboard-claude-tls.exe +0 -0
  371. package/app/open-sse/identity/tls/bin/win32/x64/switchboard-claude-tls.exe +0 -0
  372. package/app/package.json +5 -2
  373. package/package.json +1 -1
  374. package/app/.next/static/chunks/app/(dashboard)/dashboard/providers/[id]/page-b7ff5b3522a3bf1f.js +0 -10
  375. package/app/.next/static/css/23b999cda6943547.css +0 -1
  376. package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/providers/[id]/page-b7ff5b3522a3bf1f.js +0 -10
  377. package/app/.next-cli-build/static/css/23b999cda6943547.css +0 -1
  378. /package/app/.next/static/{87MOk9ZQAnrFin72qerKV → Fq0KReA64JGBdC8atypku}/_buildManifest.js +0 -0
  379. /package/app/.next/static/{87MOk9ZQAnrFin72qerKV → Fq0KReA64JGBdC8atypku}/_ssgManifest.js +0 -0
  380. /package/app/.next-cli-build/static/{87MOk9ZQAnrFin72qerKV → Fq0KReA64JGBdC8atypku}/_buildManifest.js +0 -0
  381. /package/app/.next-cli-build/static/{87MOk9ZQAnrFin72qerKV → Fq0KReA64JGBdC8atypku}/_ssgManifest.js +0 -0
@@ -1,4 +1,4 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[182],{17845:(e,t,a)=>{Promise.resolve().then(a.bind(a,41095))},41095:(e,t,a)=>{"use strict";a.r(t),a.d(t,{default:()=>D});var s=a(95155),r=a(73321),l=a(98500),o=a.n(l),i=a(12115),n=a(35497),d=a(57250),c=a(88105),m=a(70217),u=a(14051),p=a.n(u),x=a(65921),h=a(53578);function b({until:e}){let[t,a]=(0,i.useState)("");return((0,i.useEffect)(()=>{let t=()=>{let t=new Date(e).getTime()-Date.now();if(t<=0)return void a("");let s=Math.floor(t/1e3);s<60?a(`${s}s`):s<3600?a(`${Math.floor(s/60)}m ${s%60}s`):a(`${Math.floor(s/3600)}h ${Math.floor(s%3600/60)}m`)};t();let s=setInterval(t,1e3);return()=>clearInterval(s)},[e]),t)?(0,s.jsxs)("span",{className:"text-xs text-orange-500 font-mono",children:["⏱ ",t]}):null}function g({connection:e,isOAuth:t,isFirst:a,isLast:r,onMoveUp:l,onMoveDown:o,onToggleActive:d,onEdit:c,onDelete:u}){let[p,x]=(0,i.useState)(!1),h=e.providerSpecificData?.connectionProxyEnabled===!0&&!!e.providerSpecificData?.connectionProxyUrl,f=h?`Legacy: ${e.providerSpecificData?.connectionProxyUrl}`:"",y="",v=e.providerSpecificData?.connectionProxyUrl;if(v)try{let e=new URL(v);y=`${e.protocol}//${e.hostname}${e.port?`:${e.port}`:""}`}catch{y=v}let j=e.providerSpecificData?.connectionNoProxy||"",w=Object.entries(e).filter(([e])=>e.startsWith("modelLock_")).map(([,e])=>e).filter(Boolean).sort()[0]||null;(0,i.useEffect)(()=>{let t=()=>{x(!!Object.entries(e).filter(([e])=>e.startsWith("modelLock_")).map(([,e])=>e).filter(e=>e&&new Date(e).getTime()>Date.now()).sort()[0])};t();let a=w?setInterval(t,1e3):null;return()=>{a&&clearInterval(a)}},[e,w]);let N="unavailable"!==e.testStatus||p?e.testStatus:"active",k=t?e.name||e.email||e.displayName||"OAuth Account":e.name;return(0,s.jsxs)("div",{className:`group flex flex-col gap-3 p-2 rounded-lg sm:flex-row sm:items-center sm:justify-between hover:bg-black/[0.02] dark:hover:bg-white/[0.02] transition-colors ${!1===e.isActive?"opacity-60":""}`,children:[(0,s.jsxs)("div",{className:"flex w-full min-w-0 flex-1 items-start gap-3 sm:items-center",children:[(0,s.jsxs)("div",{className:"flex flex-col",children:[(0,s.jsx)("button",{onClick:l,disabled:a,className:`p-0.5 rounded ${a?"text-text-muted/30 cursor-not-allowed":"hover:bg-sidebar text-text-muted hover:text-primary"}`,children:(0,s.jsx)("span",{className:"material-symbols-outlined text-sm",children:"keyboard_arrow_up"})}),(0,s.jsx)("button",{onClick:o,disabled:r,className:`p-0.5 rounded ${r?"text-text-muted/30 cursor-not-allowed":"hover:bg-sidebar text-text-muted hover:text-primary"}`,children:(0,s.jsx)("span",{className:"material-symbols-outlined text-sm",children:"keyboard_arrow_down"})})]}),(0,s.jsx)("span",{className:"material-symbols-outlined text-base text-text-muted",children:t?"lock":"key"}),(0,s.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,s.jsx)("p",{className:"text-sm font-medium truncate",children:k}),(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-2 mt-1",children:[(0,s.jsx)(n.Ex,{variant:(0,m.g)(e.isActive,N),size:"sm",dot:!0,children:!1===e.isActive?"disabled":N||"Unknown"}),h&&(0,s.jsx)(n.Ex,{variant:"success",size:"sm",children:"Proxy"}),p&&!1!==e.isActive&&(0,s.jsx)(b,{until:w}),e.lastError&&!1!==e.isActive&&(0,s.jsx)("span",{className:"text-xs text-red-500 truncate max-w-[300px]",title:e.lastError,children:e.lastError}),(0,s.jsxs)("span",{className:"text-xs text-text-muted",children:["#",e.priority]})]}),h&&(0,s.jsxs)("div",{className:"mt-1 flex flex-wrap items-center gap-2",children:[(0,s.jsx)("span",{className:"text-[11px] text-text-muted truncate max-w-[420px]",title:f,children:f}),y&&(0,s.jsx)("code",{className:"text-[10px] font-mono bg-black/5 dark:bg-white/5 px-1 py-0.5 rounded text-text-muted",children:y}),j&&(0,s.jsxs)("span",{className:"text-[11px] text-text-muted truncate max-w-[320px]",title:j,children:["no_proxy: ",j]})]})]})]}),(0,s.jsxs)("div",{className:"flex w-full flex-wrap items-center justify-between gap-2 sm:w-auto sm:justify-end",children:[(0,s.jsxs)("div",{className:"flex flex-wrap gap-1",children:[(0,s.jsxs)("button",{onClick:c,className:"flex flex-col items-center px-2 py-1 rounded hover:bg-black/5 dark:hover:bg-white/5 text-text-muted hover:text-primary",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"edit"}),(0,s.jsx)("span",{className:"text-[10px] leading-tight",children:"Edit"})]}),(0,s.jsxs)("button",{onClick:u,className:"flex flex-col items-center px-2 py-1 rounded hover:bg-red-500/10 text-red-500",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"delete"}),(0,s.jsx)("span",{className:"text-[10px] leading-tight",children:"Delete"})]})]}),(0,s.jsx)(n.lM,{size:"sm",checked:e.isActive??!0,onChange:d,title:e.isActive??!0?"Disable":"Enable"})]})]})}function f({isOpen:e,provider:t,providerName:a,onSave:r,onClose:l}){let[o,d]=(0,i.useState)({name:"",apiKey:"",priority:1}),[c,m]=(0,i.useState)(!1),[u,p]=(0,i.useState)(null),[x,h]=(0,i.useState)(!1),b=o.name.trim().length>0,g=o.apiKey.trim().length>0,y=async()=>{let e=o.apiKey.trim();if(e){m(!0);try{let a=await fetch("/api/providers/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:t,apiKey:e})}),s=await a.json();p(s.valid?"success":"failed")}catch{p("failed")}finally{m(!1)}}},v=async()=>{let e=o.name.trim(),a=o.apiKey.trim();if(t&&e&&a){h(!0);try{let s=!1;try{m(!0),p(null);let e=await fetch("/api/providers/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:t,apiKey:a})});s=!!(await e.json()).valid,p(s?"success":"failed")}catch{p("failed")}finally{m(!1)}await r({name:e,apiKey:a,priority:o.priority,testStatus:s?"active":"unknown"})}finally{h(!1)}}};return t?(0,s.jsx)(n.aF,{isOpen:e,title:`Add ${a||t} API Key`,onClose:l,children:(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"text-xs text-text-muted mb-1 block",children:"Name"}),(0,s.jsx)("input",{className:"w-full px-3 py-2 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary",value:o.name,onChange:e=>d({...o,name:e.target.value}),placeholder:"Production Key"})]}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsxs)("div",{className:"flex-1",children:[(0,s.jsx)("label",{className:"text-xs text-text-muted mb-1 block",children:"API Key"}),(0,s.jsx)("input",{type:"password",autoComplete:"off",className:"w-full px-3 py-2 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary",value:o.apiKey,onChange:e=>d({...o,apiKey:e.target.value})})]}),(0,s.jsx)("div",{className:"pt-6",children:(0,s.jsx)(n.$n,{onClick:y,disabled:!g||c||x,variant:"secondary",children:c?"Checking...":"Check"})})]}),u&&(0,s.jsx)(n.Ex,{variant:"success"===u?"success":"error",children:"success"===u?"Valid":"Invalid"}),(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"text-xs text-text-muted mb-1 block",children:"Priority"}),(0,s.jsx)("input",{type:"number",min:1,className:"w-full px-3 py-2 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary",value:o.priority,onChange:e=>d({...o,priority:Number.parseInt(e.target.value)||1})})]}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(n.$n,{onClick:v,fullWidth:!0,disabled:!b||!g||x,children:x?"Saving...":"Save"}),(0,s.jsx)(n.$n,{onClick:l,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})}):null}function y({providerId:e,isOAuth:t}){let[a,r]=(0,i.useState)([]),[l,o]=(0,i.useState)(!0),[d,c]=(0,i.useState)(!1),[m,u]=(0,i.useState)(!1),[p,b]=(0,i.useState)(null),[v,j]=(0,i.useState)(null),[w,N]=(0,i.useState)("1"),[k,C]=(0,i.useState)(!1),[S,$]=(0,i.useState)("30"),[F,E]=(0,i.useState)(null),T=(0,x.i)(e=>e.error),A=(0,i.useCallback)(async()=>{try{let[t,a]=await Promise.all([fetch("/api/providers",{cache:"no-store"}),fetch("/api/settings",{cache:"no-store"})]);if(!t.ok||!a.ok)throw Error("Failed to load connections");let s=await t.json(),l=await a.json();r((s.connections||[]).filter(t=>t.provider===e));let o=(l.providerStrategies||{})[e]||{};j(o.fallbackStrategy||null),N(null!=o.stickyRoundRobinLimit?String(o.stickyRoundRobinLimit):"1");let i=o.accountScheduler||{};C(!0===i.enabled),$(String(Math.max(1,Math.round((i.sessionAffinityTtlSeconds||1800)/60))))}catch(e){T(e?.message||"Failed to load connections")}finally{o(!1)}},[T,e]);(0,i.useEffect)(()=>{A()},[A]);let R=async(t,a)=>{try{return await (0,h.T)(e,e=>{let s={...e};return t?s.fallbackStrategy=t:delete s.fallbackStrategy,"round-robin"===t&&""!==a?s.stickyRoundRobinLimit=Number(a)||3:t||delete s.stickyRoundRobinLimit,s}),!0}catch(e){return T(e?.message||"Failed to save provider strategy"),!1}},P=async(t,a)=>{let s=Math.min(1440,Math.max(1,Number.parseInt(a,10)||30));try{return await (0,h.T)(e,e=>({...e,accountScheduler:{...e.accountScheduler||{},enabled:t,sessionAffinityTtlSeconds:60*s}})),!0}catch(e){return T(e?.message||"Failed to save balanced scheduler"),!1}},I=async e=>{await P(e,S)&&C(e)},_=async e=>{await P(k,e)&&$(e)},M=async e=>{let t=e?"round-robin":null,a=e?w||"1":w;await R(t,a)&&(j(t),e&&!w&&N("1"))},O=async e=>{await R("round-robin",e)&&N(e)},L=async(e,t)=>{let s=[...a];[s[e],s[t]]=[s[t],s[e]],r(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){T(e?.message||"Failed to reorder connections"),await A()}},K=async e=>{let t=a.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{let t=await fetch(`/api/providers/${e}`,{method:"DELETE"});if(!t.ok)throw Error(`Failed to delete connection (${t.status})`);r(t=>t.filter(t=>t.id!==e))}catch(e){T("Failed to delete connection")}}})},B=async(e,t)=>{try{let a=await fetch(`/api/providers/${e}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({isActive:t})});if(!a.ok)throw Error(`Failed to toggle connection (${a.status})`);r(a=>a.map(a=>a.id===e?{...a,isActive:t}:a))}catch(e){T("Failed to toggle connection")}},D=async t=>{try{let a=await fetch("/api/providers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:e,...t})});if(!a.ok)throw Error(`Failed to save API key (${a.status})`);await A(),c(!1)}catch(e){T("Failed to save API key")}},U=async e=>{try{let t=await fetch(`/api/providers/${p.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!t.ok)throw Error(`Failed to update connection (${t.status})`);await A(),u(!1)}catch(e){T("Failed to update connection")}};return l?(0,s.jsx)(n.Zp,{children:(0,s.jsx)("div",{className:"h-20 animate-pulse bg-black/5 rounded-lg"})}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)(n.Zp,{children:[(0,s.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between mb-4",children:[(0,s.jsx)("h2",{className:"text-lg font-semibold",children:"Connections"}),(0,s.jsxs)("div",{className:"flex max-w-full flex-col gap-2",children:[(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,s.jsx)("span",{className:"text-xs text-text-muted font-medium",children:"Balanced scheduler"}),(0,s.jsx)(n.lM,{checked:k,onChange:I}),k&&(0,s.jsxs)("label",{className:"flex items-center gap-1.5 text-xs text-text-muted",children:["Affinity",(0,s.jsx)("input",{"aria-label":"Session affinity minutes",type:"number",min:1,max:1440,value:S,onChange:e=>_(e.target.value),className:"w-16 px-2 py-1 text-xs border border-border rounded-md bg-background focus:outline-none focus:border-primary"}),"min"]})]}),(0,s.jsx)("p",{className:"max-w-xl text-xs text-text-muted",children:"Process-local least-inflight scheduling with fresh quota signals. Sessions stay on one account and rebind on failure, cooldown, or a best-effort connection cap. Caps use observed in-flight counts, so simultaneous selections can briefly exceed them. Round Robin stays saved but inactive while this is on."}),(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-2",title:k?"Saved and used again when balanced scheduling is off":void 0,children:[(0,s.jsx)("span",{className:"text-xs text-text-muted font-medium",children:"Round Robin"}),(0,s.jsx)(n.lM,{checked:"round-robin"===v,disabled:k,title:k?"Saved and used again when balanced scheduling is off":void 0,onChange:M}),"round-robin"===v&&(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5",children:[(0,s.jsx)("span",{className:"text-xs text-text-muted",children:"Sticky:"}),(0,s.jsx)("input",{type:"number",min:1,value:w,disabled:k,title:k?"Saved and used again when balanced scheduling is off":void 0,onChange:e=>O(e.target.value),className:"w-16 px-2 py-1 text-xs border border-border rounded-md bg-background focus:outline-none focus:border-primary disabled:cursor-not-allowed disabled:opacity-50"})]})]})]})]}),0===a.length?(0,s.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[(0,s.jsx)("p",{className:"text-sm text-text-muted",children:"No connections yet"}),(0,s.jsx)(n.$n,{size:"sm",icon:"add",onClick:()=>c(!0),children:"Add Connection"})]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("div",{className:"flex flex-col divide-y divide-black/[0.03] dark:divide-white/[0.03]",children:a.map((e,r)=>(0,s.jsx)(g,{connection:e,isOAuth:t,isFirst:0===r,isLast:r===a.length-1,onMoveUp:()=>L(r,r-1),onMoveDown:()=>L(r,r+1),onToggleActive:t=>B(e.id,t),onEdit:()=>{b(e),u(!0)},onDelete:()=>K(e.id)},e.id))}),(0,s.jsx)("div",{className:"mt-4 flex justify-stretch sm:justify-start",children:(0,s.jsx)(n.$n,{size:"sm",icon:"add",onClick:()=>c(!0),children:"Add"})})]})]}),(0,s.jsx)(f,{isOpen:d,provider:e,onSave:D,onClose:()=>c(!1)}),(0,s.jsx)(n.wI,{isOpen:m,connection:p,onSave:U,onClose:()=>u(!1)}),(0,s.jsx)(n.uo,{isOpen:!!F,onClose:()=>E(null),onConfirm:F?.onConfirm,title:F?.title||"Confirm",message:F?.message,variant:"danger"})]})}b.propTypes={until:p().string.isRequired},g.propTypes={connection:p().shape({id:p().string,name:p().string,email:p().string,displayName:p().string,testStatus:p().string,isActive:p().bool,lastError:p().string,priority:p().number}).isRequired,isOAuth:p().bool.isRequired,isFirst:p().bool.isRequired,isLast:p().bool.isRequired,onMoveUp:p().func.isRequired,onMoveDown:p().func.isRequired,onToggleActive:p().func.isRequired,onEdit:p().func.isRequired,onDelete:p().func.isRequired},f.propTypes={isOpen:p().bool.isRequired,provider:p().string,providerName:p().string,onSave:p().func.isRequired,onClose:p().func.isRequired},y.propTypes={providerId:p().string.isRequired,isOAuth:p().bool};var v=a(28777),j=a(11059),w=a(78559);function N({model:e,fullModel:t,copied:a,onCopy:r,testStatus:l,isCustom:o,isFree:i,onDeleteAlias:n,onTest:d,isTesting:c}){let m="ok"===l?"#22c55e":"error"===l?"#ef4444":void 0;return(0,s.jsx)("div",{className:`group px-3 py-2 rounded-lg border ${"ok"===l?"border-green-500/40":"error"===l?"border-red-500/40":"border-border"} hover:bg-sidebar/50`,children:(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-base",style:m?{color:m}:void 0,children:"ok"===l?"check_circle":"error"===l?"cancel":"smart_toy"}),(0,s.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,s.jsx)("code",{className:"text-xs text-text-muted font-mono bg-sidebar px-1.5 py-0.5 rounded",children:t}),e.name&&(0,s.jsx)("span",{className:"text-[9px] text-text-muted/70 italic pl-1",children:e.name})]}),d&&(0,s.jsxs)("div",{className:"relative group/btn",children:[(0,s.jsx)("button",{onClick:d,disabled:c,className:`p-0.5 hover:bg-sidebar rounded text-text-muted hover:text-primary transition-opacity ${c?"opacity-100":"opacity-0 group-hover:opacity-100"}`,children:(0,s.jsx)("span",{className:"material-symbols-outlined text-sm",style:c?{animation:"spin 1s linear infinite"}:void 0,children:c?"progress_activity":"science"})}),(0,s.jsx)("span",{className:"pointer-events-none absolute mt-1 top-5 left-1/2 -translate-x-1/2 text-[10px] text-text-muted whitespace-nowrap opacity-0 group-hover/btn:opacity-100 transition-opacity",children:c?"Testing...":"Test"})]}),(0,s.jsxs)("div",{className:"relative group/btn",children:[(0,s.jsx)("button",{onClick:()=>r(t,`model-${e.id}`),className:"p-0.5 hover:bg-sidebar rounded text-text-muted hover:text-primary",children:(0,s.jsx)("span",{className:"material-symbols-outlined text-sm",children:a===`model-${e.id}`?"check":"content_copy"})}),(0,s.jsx)("span",{className:"pointer-events-none absolute mt-1 top-5 left-1/2 -translate-x-1/2 text-[10px] text-text-muted whitespace-nowrap opacity-0 group-hover/btn:opacity-100 transition-opacity",children:a===`model-${e.id}`?"Copied!":"Copy"})]}),i&&(0,s.jsx)("span",{className:"text-[10px] font-bold text-green-500 bg-green-500/10 px-1.5 py-0.5 rounded",children:"FREE"}),o&&(0,s.jsx)("button",{onClick:n,className:"p-0.5 hover:bg-red-500/10 rounded text-text-muted hover:text-red-500 opacity-0 group-hover:opacity-100 transition-opacity ml-auto",title:"Remove custom model",children:(0,s.jsx)("span",{className:"material-symbols-outlined text-sm",children:"close"})})]})})}function k({isOpen:e,onSave:t,onClose:a}){let[r,l]=(0,i.useState)(""),o=()=>{r.trim()&&(t(r.trim()),l(""))};return(0,s.jsx)(n.aF,{isOpen:e,title:"Add Custom Model",onClose:a,children:(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"text-xs text-text-muted mb-1 block",children:"Model ID"}),(0,s.jsx)("input",{className:"w-full px-3 py-2 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary",value:r,onChange:e=>l(e.target.value),onKeyDown:e=>"Enter"===e.key&&o(),placeholder:"e.g. tts-1-hd",autoFocus:!0})]}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(n.$n,{onClick:o,fullWidth:!0,disabled:!r.trim(),children:"Add"}),(0,s.jsx)(n.$n,{onClick:a,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})})}function C({providerId:e,kindFilter:t,providerAliasOverride:a}){let{copied:r,copy:l}=(0,j.C)(),[o,d]=(0,i.useState)({}),[m,u]=(0,i.useState)([]),[p,x]=(0,i.useState)({}),[h,b]=(0,i.useState)(null),[g,f]=(0,i.useState)(""),[y,S]=(0,i.useState)(!1),[$,F]=(0,i.useState)([]),E=a||(0,c.wG)(e),T=t||"llm",A=(0,i.useCallback)(async()=>{try{let[t,a,s]=await Promise.all([fetch("/api/models/alias"),fetch("/api/providers",{cache:"no-store"}),fetch("/api/models/custom",{cache:"no-store"})]),r=await t.json(),l=await a.json(),o=await s.json();t.ok&&d(r.aliases||{}),a.ok&&F((l.connections||[]).filter(t=>t.provider===e)),s.ok&&u(o.models||[])}catch(e){(0,w.s)("ModelsCard fetch error:",e)}},[e]);(0,i.useEffect)(()=>{A()},[A]);let R=async(e,t)=>{let a=`${E}/${e}`;try{(await fetch("/api/models/alias",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:a,alias:t})})).ok&&await A()}catch(e){(0,w.s)("set alias error:",e)}},P=async e=>{try{(await fetch(`/api/models/alias?alias=${encodeURIComponent(e)}`,{method:"DELETE"})).ok&&await A()}catch(e){(0,w.s)("delete alias error:",e)}},I=async e=>{try{(await fetch("/api/models/custom",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerAlias:E,id:e,type:T})})).ok&&(await A(),window.dispatchEvent(new CustomEvent("customModelChanged")))}catch(e){(0,w.s)("add custom model error:",e)}},_=async e=>{try{let t=new URLSearchParams({providerAlias:E,id:e,type:T});(await fetch(`/api/models/custom?${t}`,{method:"DELETE"})).ok&&(await A(),window.dispatchEvent(new CustomEvent("customModelChanged")))}catch(e){(0,w.s)("delete custom model error:",e)}},M=async e=>{if(!h){b(e);try{let a=await fetch("/api/models/test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:`${E}/${e}`,kind:t})}),s=await a.json();x(t=>({...t,[e]:s.ok?"ok":"error"})),f(s.ok?"":s.error||"Model not reachable")}catch{x(t=>({...t,[e]:"error"})),f("Network error")}finally{b(null)}}},O=(0,v.KC)(e),L=t?O.filter(e=>e.kinds?e.kinds.includes(t):(0,v.CP)(e,"llm")===t):O,K=m.filter(e=>e.providerAlias===E&&(0,v.CP)(e,"llm")===T&&!L.some(t=>t.id===e.id));return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)(n.Zp,{children:[(0,s.jsx)("div",{className:"flex items-center justify-between mb-4",children:(0,s.jsxs)("h2",{className:"text-lg font-semibold",children:["Models",t?` — ${t.toUpperCase()}`:""]})}),g&&(0,s.jsx)("p",{className:"text-xs text-red-500 mb-3 break-words",children:g}),(0,s.jsxs)("div",{className:"flex flex-wrap gap-3",children:[L.map(e=>{let t=`${E}/${e.id}`,a=Object.entries(o).find(([,e])=>e===t)?.[0];return(0,s.jsx)(N,{model:e,fullModel:`${E}/${e.id}`,alias:a,copied:r,onCopy:l,onSetAlias:t=>R(e.id,t),onDeleteAlias:()=>P(a),testStatus:p[e.id],onTest:$.length>0?()=>M(e.id):void 0,isTesting:h===e.id,isFree:e.isFree},e.id)}),K.map(e=>(0,s.jsx)(N,{model:{id:e.id,name:e.name},fullModel:`${E}/${e.id}`,copied:r,onCopy:l,onSetAlias:()=>{},onDeleteAlias:()=>_(e.id),testStatus:p[e.id],onTest:$.length>0?()=>M(e.id):void 0,isTesting:h===e.id,isCustom:!0},`${e.id}-${e.type}`)),(0,s.jsxs)("button",{onClick:()=>S(!0),className:"flex items-center gap-1.5 px-3 py-2 rounded-lg border border-dashed border-black/15 dark:border-white/15 text-xs text-text-muted hover:text-primary hover:border-primary/40 transition-colors",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-sm",children:"add"}),"Add Model"]})]})]}),(0,s.jsx)(k,{isOpen:y,onSave:async e=>{await I(e),S(!1)},onClose:()=>S(!1)})]})}function S({label:e,htmlFor:t,children:a}){return(0,s.jsxs)("div",{className:"flex min-w-0 flex-col gap-1.5 sm:flex-row sm:items-center sm:gap-3",children:[(0,s.jsx)(t?"label":"span",{htmlFor:t,className:"w-full text-xs font-medium text-text-muted sm:w-20 sm:shrink-0",children:e}),(0,s.jsx)("div",{className:"w-full min-w-0 flex-1",children:a})]})}N.propTypes={model:p().shape({id:p().string.isRequired}).isRequired,fullModel:p().string.isRequired,copied:p().string,onCopy:p().func.isRequired,testStatus:p().oneOf(["ok","error"]),isCustom:p().bool,isFree:p().bool,onDeleteAlias:p().func,onTest:p().func,isTesting:p().bool},k.propTypes={isOpen:p().bool.isRequired,onSave:p().func.isRequired,onClose:p().func.isRequired},C.propTypes={providerId:p().string.isRequired,kindFilter:p().string,providerAliasOverride:p().string};let $={webSearch:{inputLabel:"Query",inputPlaceholder:"What is the latest news about AI?",defaultInput:"What is the latest news about AI?",bodyKey:"query",defaultResponse:`{
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[182],{17845:(e,t,a)=>{Promise.resolve().then(a.bind(a,41095))},41095:(e,t,a)=>{"use strict";a.r(t),a.d(t,{default:()=>D});var s=a(95155),r=a(73321),l=a(98500),o=a.n(l),i=a(12115),n=a(35497),d=a(57250),c=a(88105),m=a(70217),u=a(14051),p=a.n(u),x=a(65921),h=a(53578);function b({until:e}){let[t,a]=(0,i.useState)("");return((0,i.useEffect)(()=>{let t=()=>{let t=new Date(e).getTime()-Date.now();if(t<=0)return void a("");let s=Math.floor(t/1e3);s<60?a(`${s}s`):s<3600?a(`${Math.floor(s/60)}m ${s%60}s`):a(`${Math.floor(s/3600)}h ${Math.floor(s%3600/60)}m`)};t();let s=setInterval(t,1e3);return()=>clearInterval(s)},[e]),t)?(0,s.jsxs)("span",{className:"text-xs text-orange-500 font-mono",children:["⏱ ",t]}):null}function f({connection:e,isOAuth:t,isFirst:a,isLast:r,onMoveUp:l,onMoveDown:o,onToggleActive:d,onEdit:c,onDelete:u}){let[p,x]=(0,i.useState)(!1),h=e.providerSpecificData?.connectionProxyEnabled===!0&&!!e.providerSpecificData?.connectionProxyUrl,g=h?`Legacy: ${e.providerSpecificData?.connectionProxyUrl}`:"",y="",v=e.providerSpecificData?.connectionProxyUrl;if(v)try{let e=new URL(v);y=`${e.protocol}//${e.hostname}${e.port?`:${e.port}`:""}`}catch{y=v}let j=e.providerSpecificData?.connectionNoProxy||"",w=Object.entries(e).filter(([e])=>e.startsWith("modelLock_")).map(([,e])=>e).filter(Boolean).sort()[0]||null;(0,i.useEffect)(()=>{let t=()=>{x(!!Object.entries(e).filter(([e])=>e.startsWith("modelLock_")).map(([,e])=>e).filter(e=>e&&new Date(e).getTime()>Date.now()).sort()[0])};t();let a=w?setInterval(t,1e3):null;return()=>{a&&clearInterval(a)}},[e,w]);let N="unavailable"!==e.testStatus||p?e.testStatus:"active",k=t?e.name||e.email||e.displayName||"OAuth Account":e.name;return(0,s.jsxs)("div",{className:`group flex flex-col gap-3 p-2 rounded-lg sm:flex-row sm:items-center sm:justify-between hover:bg-black/[0.02] dark:hover:bg-white/[0.02] transition-colors ${!1===e.isActive?"opacity-60":""}`,children:[(0,s.jsxs)("div",{className:"flex w-full min-w-0 flex-1 items-start gap-3 sm:items-center",children:[(0,s.jsxs)("div",{className:"flex flex-col",children:[(0,s.jsx)("button",{onClick:l,disabled:a,className:`p-0.5 rounded ${a?"text-text-muted/30 cursor-not-allowed":"hover:bg-sidebar text-text-muted hover:text-primary"}`,children:(0,s.jsx)("span",{className:"material-symbols-outlined text-sm",children:"keyboard_arrow_up"})}),(0,s.jsx)("button",{onClick:o,disabled:r,className:`p-0.5 rounded ${r?"text-text-muted/30 cursor-not-allowed":"hover:bg-sidebar text-text-muted hover:text-primary"}`,children:(0,s.jsx)("span",{className:"material-symbols-outlined text-sm",children:"keyboard_arrow_down"})})]}),(0,s.jsx)("span",{className:"material-symbols-outlined text-base text-text-muted",children:t?"lock":"key"}),(0,s.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,s.jsx)("p",{className:"text-sm font-medium truncate",children:k}),(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-2 mt-1",children:[(0,s.jsx)(n.Ex,{variant:(0,m.g)(e.isActive,N),size:"sm",dot:!0,children:!1===e.isActive?"disabled":N||"Unknown"}),h&&(0,s.jsx)(n.Ex,{variant:"success",size:"sm",children:"Proxy"}),p&&!1!==e.isActive&&(0,s.jsx)(b,{until:w}),e.lastError&&!1!==e.isActive&&(0,s.jsx)("span",{className:"text-xs text-red-500 truncate max-w-[300px]",title:e.lastError,children:e.lastError}),(0,s.jsxs)("span",{className:"text-xs text-text-muted",children:["#",e.priority]})]}),h&&(0,s.jsxs)("div",{className:"mt-1 flex flex-wrap items-center gap-2",children:[(0,s.jsx)("span",{className:"text-[11px] text-text-muted truncate max-w-[420px]",title:g,children:g}),y&&(0,s.jsx)("code",{className:"text-[10px] font-mono bg-black/5 dark:bg-white/5 px-1 py-0.5 rounded text-text-muted",children:y}),j&&(0,s.jsxs)("span",{className:"text-[11px] text-text-muted truncate max-w-[320px]",title:j,children:["no_proxy: ",j]})]})]})]}),(0,s.jsxs)("div",{className:"flex w-full flex-wrap items-center justify-between gap-2 sm:w-auto sm:justify-end",children:[(0,s.jsxs)("div",{className:"flex flex-wrap gap-1",children:[(0,s.jsxs)("button",{onClick:c,className:"flex flex-col items-center px-2 py-1 rounded hover:bg-black/5 dark:hover:bg-white/5 text-text-muted hover:text-primary",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"edit"}),(0,s.jsx)("span",{className:"text-[10px] leading-tight",children:"Edit"})]}),(0,s.jsxs)("button",{onClick:u,className:"flex flex-col items-center px-2 py-1 rounded hover:bg-red-500/10 text-red-500",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"delete"}),(0,s.jsx)("span",{className:"text-[10px] leading-tight",children:"Delete"})]})]}),(0,s.jsx)(n.lM,{size:"sm",checked:e.isActive??!0,onChange:d,title:e.isActive??!0?"Disable":"Enable"})]})]})}function g({isOpen:e,provider:t,providerName:a,onSave:r,onClose:l}){let[o,d]=(0,i.useState)({name:"",apiKey:"",priority:1}),[c,m]=(0,i.useState)(!1),[u,p]=(0,i.useState)(null),[x,h]=(0,i.useState)(!1),b=o.name.trim().length>0,f=o.apiKey.trim().length>0,y=async()=>{let e=o.apiKey.trim();if(e){m(!0);try{let a=await fetch("/api/providers/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:t,apiKey:e})}),s=await a.json();p(s.valid?"success":"failed")}catch{p("failed")}finally{m(!1)}}},v=async()=>{let e=o.name.trim(),a=o.apiKey.trim();if(t&&e&&a){h(!0);try{let s=!1;try{m(!0),p(null);let e=await fetch("/api/providers/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:t,apiKey:a})});s=!!(await e.json()).valid,p(s?"success":"failed")}catch{p("failed")}finally{m(!1)}await r({name:e,apiKey:a,priority:o.priority,testStatus:s?"active":"unknown"})}finally{h(!1)}}};return t?(0,s.jsx)(n.aF,{isOpen:e,title:`Add ${a||t} API Key`,onClose:l,children:(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"text-xs text-text-muted mb-1 block",children:"Name"}),(0,s.jsx)("input",{className:"w-full px-3 py-2 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary",value:o.name,onChange:e=>d({...o,name:e.target.value}),placeholder:"Production Key"})]}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsxs)("div",{className:"flex-1",children:[(0,s.jsx)("label",{className:"text-xs text-text-muted mb-1 block",children:"API Key"}),(0,s.jsx)("input",{type:"password",autoComplete:"off",className:"w-full px-3 py-2 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary",value:o.apiKey,onChange:e=>d({...o,apiKey:e.target.value})})]}),(0,s.jsx)("div",{className:"pt-6",children:(0,s.jsx)(n.$n,{onClick:y,disabled:!f||c||x,variant:"secondary",children:c?"Checking...":"Check"})})]}),u&&(0,s.jsx)(n.Ex,{variant:"success"===u?"success":"error",children:"success"===u?"Valid":"Invalid"}),(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"text-xs text-text-muted mb-1 block",children:"Priority"}),(0,s.jsx)("input",{type:"number",min:1,className:"w-full px-3 py-2 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary",value:o.priority,onChange:e=>d({...o,priority:Number.parseInt(e.target.value)||1})})]}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(n.$n,{onClick:v,fullWidth:!0,disabled:!b||!f||x,children:x?"Saving...":"Save"}),(0,s.jsx)(n.$n,{onClick:l,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})}):null}function y({providerId:e,isOAuth:t}){let[a,r]=(0,i.useState)([]),[l,o]=(0,i.useState)(!0),[d,c]=(0,i.useState)(!1),[m,u]=(0,i.useState)(!1),[p,b]=(0,i.useState)(null),[v,j]=(0,i.useState)(null),[w,N]=(0,i.useState)("1"),[k,C]=(0,i.useState)(!1),[S,$]=(0,i.useState)("30"),[F,E]=(0,i.useState)(null),A=(0,x.i)(e=>e.error),T=(0,i.useCallback)(async()=>{try{let[t,a]=await Promise.all([fetch("/api/providers",{cache:"no-store"}),fetch("/api/settings",{cache:"no-store"})]);if(!t.ok||!a.ok)throw Error("Failed to load connections");let s=await t.json(),l=await a.json();r((s.connections||[]).filter(t=>t.provider===e));let o=(l.providerStrategies||{})[e]||{};j(o.fallbackStrategy||null),N(null!=o.stickyRoundRobinLimit?String(o.stickyRoundRobinLimit):"1");let i=o.accountScheduler||{};C(!0===i.enabled),$(String(Math.max(1,Math.round((i.sessionAffinityTtlSeconds||1800)/60))))}catch(e){A(e?.message||"Failed to load connections")}finally{o(!1)}},[A,e]);(0,i.useEffect)(()=>{T()},[T]);let R=async(t,a)=>{try{return await (0,h.T)(e,e=>{let s={...e};return t?s.fallbackStrategy=t:delete s.fallbackStrategy,"round-robin"===t&&""!==a?s.stickyRoundRobinLimit=Number(a)||3:t||delete s.stickyRoundRobinLimit,s}),!0}catch(e){return A(e?.message||"Failed to save provider strategy"),!1}},P=async(t,a)=>{let s=Math.min(1440,Math.max(1,Number.parseInt(a,10)||30));try{return await (0,h.T)(e,e=>({...e,accountScheduler:{...e.accountScheduler||{},enabled:t,sessionAffinityTtlSeconds:60*s}})),!0}catch(e){return A(e?.message||"Failed to save balanced scheduler"),!1}},I=async e=>{await P(k,e)&&$(e)},_=async e=>{await R("round-robin",e)&&N(e)},O=async(e,t)=>{let s=[...a];[s[e],s[t]]=[s[t],s[e]],r(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){A(e?.message||"Failed to reorder connections"),await T()}},M=async e=>{let t=a.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{let t=await fetch(`/api/providers/${e}`,{method:"DELETE"});if(!t.ok)throw Error(`Failed to delete connection (${t.status})`);r(t=>t.filter(t=>t.id!==e))}catch(e){A("Failed to delete connection")}}})},L=async(e,t)=>{try{let a=await fetch(`/api/providers/${e}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({isActive:t})});if(!a.ok)throw Error(`Failed to toggle connection (${a.status})`);r(a=>a.map(a=>a.id===e?{...a,isActive:t}:a))}catch(e){A("Failed to toggle connection")}},K=async t=>{try{let a=await fetch("/api/providers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:e,...t})});if(!a.ok)throw Error(`Failed to save API key (${a.status})`);await T(),c(!1)}catch(e){A("Failed to save API key")}},B=async e=>{try{let t=await fetch(`/api/providers/${p.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!t.ok)throw Error(`Failed to update connection (${t.status})`);await T(),u(!1)}catch(e){A("Failed to update connection")}};if(l)return(0,s.jsx)(n.Zp,{children:(0,s.jsx)("div",{className:"h-20 animate-pulse bg-black/5 rounded-lg"})});let D=k?"balanced":"round-robin"===v?"round-robin":"fill-first",U=async e=>{"balanced"===e?await P(!0,S)&&C(!0):"round-robin"===e?(k&&(await P(!1,S),C(!1)),await R("round-robin",w||"1")&&j("round-robin")):(k&&(await P(!1,S),C(!1)),await R("fill-first","")&&j("fill-first"))};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)(n.Zp,{children:[(0,s.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between mb-4",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("h2",{className:"text-lg font-semibold",children:"Connections"}),(0,s.jsxs)("p",{className:"text-xs text-text-muted mt-0.5",children:["Manage accounts and selection strategy for ",e]})]}),a.length>1&&(0,s.jsxs)("div",{className:"flex flex-col gap-2 rounded-xl border border-border/40 bg-surface-2/40 p-3 text-xs",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,s.jsx)("span",{className:"font-semibold text-text-main",children:"Account Strategy"}),(0,s.jsxs)("div",{className:"inline-flex rounded-lg border border-border/60 bg-background/60 p-0.5",children:[(0,s.jsx)("button",{type:"button",onClick:()=>U("fill-first"),className:`rounded-md px-2 py-1 text-[11px] font-medium transition-all ${"fill-first"===D?"bg-primary text-black font-semibold shadow-xs":"text-text-muted hover:text-text-main"}`,children:"Fill-First"}),(0,s.jsx)("button",{type:"button",onClick:()=>U("round-robin"),className:`rounded-md px-2 py-1 text-[11px] font-medium transition-all ${"round-robin"===D?"bg-primary text-black font-semibold shadow-xs":"text-text-muted hover:text-text-main"}`,children:"Round Robin"}),(0,s.jsx)("button",{type:"button",onClick:()=>U("balanced"),className:`rounded-md px-2 py-1 text-[11px] font-medium transition-all ${"balanced"===D?"bg-primary text-black font-semibold shadow-xs":"text-text-muted hover:text-text-main"}`,children:"Balanced"})]})]}),"fill-first"===D&&(0,s.jsx)("p",{className:"max-w-md text-[11px] text-text-muted",children:"Routes all requests to top-priority connection first. Spills over to subsequent accounts on rate limit (429) or quota exhaustion."}),"round-robin"===D&&(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-2 text-[11px] text-text-muted",children:[(0,s.jsx)("span",{children:"Cycles evenly across accounts."}),(0,s.jsxs)("label",{className:"inline-flex items-center gap-1",children:["Sticky limit:",(0,s.jsx)("input",{type:"number",min:1,max:100,value:w,onChange:e=>_(e.target.value),className:"w-12 px-1.5 py-0.5 text-[11px] border border-border rounded bg-background focus:outline-none focus:border-primary"})]})]}),"balanced"===D&&(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-2 text-[11px] text-text-muted",children:[(0,s.jsx)("span",{children:"Least in-flight concurrency with session affinity."}),(0,s.jsxs)("label",{className:"inline-flex items-center gap-1",children:["Affinity:",(0,s.jsx)("input",{"aria-label":"Session affinity minutes",type:"number",min:1,max:1440,value:S,onChange:e=>I(e.target.value),className:"w-14 px-1.5 py-0.5 text-[11px] border border-border rounded bg-background focus:outline-none focus:border-primary"}),"min"]})]})]})]}),0===a.length?(0,s.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[(0,s.jsx)("p",{className:"text-sm text-text-muted",children:"No connections yet"}),(0,s.jsx)(n.$n,{size:"sm",icon:"add",onClick:()=>c(!0),children:"Add Connection"})]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("div",{className:"flex flex-col divide-y divide-black/[0.03] dark:divide-white/[0.03]",children:a.map((e,r)=>(0,s.jsx)(f,{connection:e,isOAuth:t,isFirst:0===r,isLast:r===a.length-1,onMoveUp:()=>O(r,r-1),onMoveDown:()=>O(r,r+1),onToggleActive:t=>L(e.id,t),onEdit:()=>{b(e),u(!0)},onDelete:()=>M(e.id)},e.id))}),(0,s.jsx)("div",{className:"mt-4 flex justify-stretch sm:justify-start",children:(0,s.jsx)(n.$n,{size:"sm",icon:"add",onClick:()=>c(!0),children:"Add"})})]})]}),(0,s.jsx)(g,{isOpen:d,provider:e,onSave:K,onClose:()=>c(!1)}),(0,s.jsx)(n.wI,{isOpen:m,connection:p,onSave:B,onClose:()=>u(!1)}),(0,s.jsx)(n.uo,{isOpen:!!F,onClose:()=>E(null),onConfirm:F?.onConfirm,title:F?.title||"Confirm",message:F?.message,variant:"danger"})]})}b.propTypes={until:p().string.isRequired},f.propTypes={connection:p().shape({id:p().string,name:p().string,email:p().string,displayName:p().string,testStatus:p().string,isActive:p().bool,lastError:p().string,priority:p().number}).isRequired,isOAuth:p().bool.isRequired,isFirst:p().bool.isRequired,isLast:p().bool.isRequired,onMoveUp:p().func.isRequired,onMoveDown:p().func.isRequired,onToggleActive:p().func.isRequired,onEdit:p().func.isRequired,onDelete:p().func.isRequired},g.propTypes={isOpen:p().bool.isRequired,provider:p().string,providerName:p().string,onSave:p().func.isRequired,onClose:p().func.isRequired},y.propTypes={providerId:p().string.isRequired,isOAuth:p().bool};var v=a(28777),j=a(11059),w=a(78559);function N({model:e,fullModel:t,copied:a,onCopy:r,testStatus:l,isCustom:o,isFree:i,onDeleteAlias:n,onTest:d,isTesting:c}){let m="ok"===l?"#22c55e":"error"===l?"#ef4444":void 0;return(0,s.jsx)("div",{className:`group px-3 py-2 rounded-lg border ${"ok"===l?"border-green-500/40":"error"===l?"border-red-500/40":"border-border"} hover:bg-sidebar/50`,children:(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-base",style:m?{color:m}:void 0,children:"ok"===l?"check_circle":"error"===l?"cancel":"smart_toy"}),(0,s.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,s.jsx)("code",{className:"text-xs text-text-muted font-mono bg-sidebar px-1.5 py-0.5 rounded",children:t}),e.name&&(0,s.jsx)("span",{className:"text-[9px] text-text-muted/70 italic pl-1",children:e.name})]}),d&&(0,s.jsxs)("div",{className:"relative group/btn",children:[(0,s.jsx)("button",{onClick:d,disabled:c,className:`p-0.5 hover:bg-sidebar rounded text-text-muted hover:text-primary transition-opacity ${c?"opacity-100":"opacity-0 group-hover:opacity-100"}`,children:(0,s.jsx)("span",{className:"material-symbols-outlined text-sm",style:c?{animation:"spin 1s linear infinite"}:void 0,children:c?"progress_activity":"science"})}),(0,s.jsx)("span",{className:"pointer-events-none absolute mt-1 top-5 left-1/2 -translate-x-1/2 text-[10px] text-text-muted whitespace-nowrap opacity-0 group-hover/btn:opacity-100 transition-opacity",children:c?"Testing...":"Test"})]}),(0,s.jsxs)("div",{className:"relative group/btn",children:[(0,s.jsx)("button",{onClick:()=>r(t,`model-${e.id}`),className:"p-0.5 hover:bg-sidebar rounded text-text-muted hover:text-primary",children:(0,s.jsx)("span",{className:"material-symbols-outlined text-sm",children:a===`model-${e.id}`?"check":"content_copy"})}),(0,s.jsx)("span",{className:"pointer-events-none absolute mt-1 top-5 left-1/2 -translate-x-1/2 text-[10px] text-text-muted whitespace-nowrap opacity-0 group-hover/btn:opacity-100 transition-opacity",children:a===`model-${e.id}`?"Copied!":"Copy"})]}),i&&(0,s.jsx)("span",{className:"text-[10px] font-bold text-green-500 bg-green-500/10 px-1.5 py-0.5 rounded",children:"FREE"}),o&&(0,s.jsx)("button",{onClick:n,className:"p-0.5 hover:bg-red-500/10 rounded text-text-muted hover:text-red-500 opacity-0 group-hover:opacity-100 transition-opacity ml-auto",title:"Remove custom model",children:(0,s.jsx)("span",{className:"material-symbols-outlined text-sm",children:"close"})})]})})}function k({isOpen:e,onSave:t,onClose:a}){let[r,l]=(0,i.useState)(""),o=()=>{r.trim()&&(t(r.trim()),l(""))};return(0,s.jsx)(n.aF,{isOpen:e,title:"Add Custom Model",onClose:a,children:(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"text-xs text-text-muted mb-1 block",children:"Model ID"}),(0,s.jsx)("input",{className:"w-full px-3 py-2 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary",value:r,onChange:e=>l(e.target.value),onKeyDown:e=>"Enter"===e.key&&o(),placeholder:"e.g. tts-1-hd",autoFocus:!0})]}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(n.$n,{onClick:o,fullWidth:!0,disabled:!r.trim(),children:"Add"}),(0,s.jsx)(n.$n,{onClick:a,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})})}function C({providerId:e,kindFilter:t,providerAliasOverride:a}){let{copied:r,copy:l}=(0,j.C)(),[o,d]=(0,i.useState)({}),[m,u]=(0,i.useState)([]),[p,x]=(0,i.useState)({}),[h,b]=(0,i.useState)(null),[f,g]=(0,i.useState)(""),[y,S]=(0,i.useState)(!1),[$,F]=(0,i.useState)([]),E=a||(0,c.wG)(e),A=t||"llm",T=(0,i.useCallback)(async()=>{try{let[t,a,s]=await Promise.all([fetch("/api/models/alias"),fetch("/api/providers",{cache:"no-store"}),fetch("/api/models/custom",{cache:"no-store"})]),r=await t.json(),l=await a.json(),o=await s.json();t.ok&&d(r.aliases||{}),a.ok&&F((l.connections||[]).filter(t=>t.provider===e)),s.ok&&u(o.models||[])}catch(e){(0,w.s)("ModelsCard fetch error:",e)}},[e]);(0,i.useEffect)(()=>{T()},[T]);let R=async(e,t)=>{let a=`${E}/${e}`;try{(await fetch("/api/models/alias",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:a,alias:t})})).ok&&await T()}catch(e){(0,w.s)("set alias error:",e)}},P=async e=>{try{(await fetch(`/api/models/alias?alias=${encodeURIComponent(e)}`,{method:"DELETE"})).ok&&await T()}catch(e){(0,w.s)("delete alias error:",e)}},I=async e=>{try{(await fetch("/api/models/custom",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerAlias:E,id:e,type:A})})).ok&&(await T(),window.dispatchEvent(new CustomEvent("customModelChanged")))}catch(e){(0,w.s)("add custom model error:",e)}},_=async e=>{try{let t=new URLSearchParams({providerAlias:E,id:e,type:A});(await fetch(`/api/models/custom?${t}`,{method:"DELETE"})).ok&&(await T(),window.dispatchEvent(new CustomEvent("customModelChanged")))}catch(e){(0,w.s)("delete custom model error:",e)}},O=async e=>{if(!h){b(e);try{let a=await fetch("/api/models/test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:`${E}/${e}`,kind:t})}),s=await a.json();x(t=>({...t,[e]:s.ok?"ok":"error"})),g(s.ok?"":s.error||"Model not reachable")}catch{x(t=>({...t,[e]:"error"})),g("Network error")}finally{b(null)}}},M=(0,v.KC)(e),L=t?M.filter(e=>e.kinds?e.kinds.includes(t):(0,v.CP)(e,"llm")===t):M,K=m.filter(e=>e.providerAlias===E&&(0,v.CP)(e,"llm")===A&&!L.some(t=>t.id===e.id));return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)(n.Zp,{children:[(0,s.jsx)("div",{className:"flex items-center justify-between mb-4",children:(0,s.jsxs)("h2",{className:"text-lg font-semibold",children:["Models",t?` — ${t.toUpperCase()}`:""]})}),f&&(0,s.jsx)("p",{className:"text-xs text-red-500 mb-3 break-words",children:f}),(0,s.jsxs)("div",{className:"flex flex-wrap gap-3",children:[L.map(e=>{let t=`${E}/${e.id}`,a=Object.entries(o).find(([,e])=>e===t)?.[0];return(0,s.jsx)(N,{model:e,fullModel:`${E}/${e.id}`,alias:a,copied:r,onCopy:l,onSetAlias:t=>R(e.id,t),onDeleteAlias:()=>P(a),testStatus:p[e.id],onTest:$.length>0?()=>O(e.id):void 0,isTesting:h===e.id,isFree:e.isFree},e.id)}),K.map(e=>(0,s.jsx)(N,{model:{id:e.id,name:e.name},fullModel:`${E}/${e.id}`,copied:r,onCopy:l,onSetAlias:()=>{},onDeleteAlias:()=>_(e.id),testStatus:p[e.id],onTest:$.length>0?()=>O(e.id):void 0,isTesting:h===e.id,isCustom:!0},`${e.id}-${e.type}`)),(0,s.jsxs)("button",{onClick:()=>S(!0),className:"flex items-center gap-1.5 px-3 py-2 rounded-lg border border-dashed border-black/15 dark:border-white/15 text-xs text-text-muted hover:text-primary hover:border-primary/40 transition-colors",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-sm",children:"add"}),"Add Model"]})]})]}),(0,s.jsx)(k,{isOpen:y,onSave:async e=>{await I(e),S(!1)},onClose:()=>S(!1)})]})}function S({label:e,htmlFor:t,children:a}){return(0,s.jsxs)("div",{className:"flex min-w-0 flex-col gap-1.5 sm:flex-row sm:items-center sm:gap-3",children:[(0,s.jsx)(t?"label":"span",{htmlFor:t,className:"w-full text-xs font-medium text-text-muted sm:w-20 sm:shrink-0",children:e}),(0,s.jsx)("div",{className:"w-full min-w-0 flex-1",children:a})]})}N.propTypes={model:p().shape({id:p().string.isRequired}).isRequired,fullModel:p().string.isRequired,copied:p().string,onCopy:p().func.isRequired,testStatus:p().oneOf(["ok","error"]),isCustom:p().bool,isFree:p().bool,onDeleteAlias:p().func,onTest:p().func,isTesting:p().bool},k.propTypes={isOpen:p().bool.isRequired,onSave:p().func.isRequired,onClose:p().func.isRequired},C.propTypes={providerId:p().string.isRequired,kindFilter:p().string,providerAliasOverride:p().string};let $={webSearch:{inputLabel:"Query",inputPlaceholder:"What is the latest news about AI?",defaultInput:"What is the latest news about AI?",bodyKey:"query",defaultResponse:`{
2
2
  "results": [
3
3
  { "title": "...", "url": "...", "snippet": "..." }
4
4
  ]
@@ -30,30 +30,30 @@
30
30
  }],
31
31
  "model": "...",
32
32
  "usage": { "prompt_tokens": 9, "total_tokens": 9 }
33
- }`;function E({providerId:e,customAlias:t}){let a=(0,c.gC)(e),r=a?t||e:(0,c.wG)(e),l=a?[]:(0,v.KC)(e).filter(e=>"embedding"===(0,v.CP)(e)),[o,d]=(0,i.useState)(l[0]?.id??""),[m,u]=(0,i.useState)("The quick brown fox jumps over the lazy dog"),[p,x]=(0,i.useState)(""),[h,b]=(0,i.useState)(""),[g,f]=(0,i.useState)(""),[y,w]=(0,i.useState)(null),[N,k]=(0,i.useState)(!1),[C,$]=(0,i.useState)(""),{copied:T,copy:A}=(0,j.C)(),{copied:R,copy:P}=(0,j.C)();(0,i.useEffect)(()=>{f(window.location.origin)},[]);let I=o?`${r}/${o}`:"",_=()=>{let e={model:I,input:m.trim()},t=Number(p);return p&&Number.isFinite(t)&&t>0&&(e.dimensions=t),e},M=`curl -X POST ${g}/v1/embeddings \\
33
+ }`;function E({providerId:e,customAlias:t}){let a=(0,c.gC)(e),r=a?t||e:(0,c.wG)(e),l=a?[]:(0,v.KC)(e).filter(e=>"embedding"===(0,v.CP)(e)),[o,d]=(0,i.useState)(l[0]?.id??""),[m,u]=(0,i.useState)("The quick brown fox jumps over the lazy dog"),[p,x]=(0,i.useState)(""),[h,b]=(0,i.useState)(""),[f,g]=(0,i.useState)(""),[y,w]=(0,i.useState)(null),[N,k]=(0,i.useState)(!1),[C,$]=(0,i.useState)(""),{copied:A,copy:T}=(0,j.C)(),{copied:R,copy:P}=(0,j.C)();(0,i.useEffect)(()=>{g(window.location.origin)},[]);let I=o?`${r}/${o}`:"",_=()=>{let e={model:I,input:m.trim()},t=Number(p);return p&&Number.isFinite(t)&&t>0&&(e.dimensions=t),e},O=`curl -X POST ${f}/v1/embeddings \\
34
34
  -H "Content-Type: application/json" \\
35
35
  -H "Authorization: Bearer ${h||"YOUR_KEY"}" \\
36
- -d '${JSON.stringify(_())}'`,O=async()=>{if(!m.trim()||!I||!h.trim())return;k(!0),$(""),w(null);let e=Date.now();try{let t={"Content-Type":"application/json"};h&&(t.Authorization=`Bearer ${h}`);let a=await fetch("/api/v1/embeddings",{method:"POST",headers:t,body:JSON.stringify(_())}),s=Date.now()-e,r=await a.json();if(!a.ok)return void $(r?.error?.message||r?.error||`HTTP ${a.status}`);w({data:r,latencyMs:s})}catch(e){$(e.message||"Network error")}finally{k(!1)}},L=y?JSON.stringify(y.data,null,2):"";return(0,s.jsxs)(n.Zp,{children:[(0,s.jsx)("h2",{className:"text-lg font-semibold mb-4",children:"Example"}),(0,s.jsxs)("div",{className:"flex flex-col gap-2.5",children:[(0,s.jsx)(S,{label:"Model",htmlFor:"embedding-example-model",children:a?(0,s.jsx)("input",{id:"embedding-example-model",value:o,onChange:e=>d(e.target.value),placeholder:"e.g. voyage-3, embed-english-v3.0, text-embedding-3-small",className:"w-full px-3 py-1.5 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary font-mono"}):(0,s.jsx)("select",{id:"embedding-example-model",value:o,onChange:e=>d(e.target.value),className:"w-full px-3 py-1.5 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary",children:l.map(e=>(0,s.jsx)("option",{value:e.id,children:e.name||e.id},e.id))})}),(0,s.jsx)(S,{label:"Endpoint",htmlFor:"embedding-example-endpoint",children:(0,s.jsx)("div",{className:"flex w-full flex-col gap-2 sm:w-auto sm:flex-row sm:items-center",children:(0,s.jsx)("input",{id:"embedding-example-endpoint",value:g,onChange:e=>f(e.target.value),className:"w-full min-w-0 flex-1 px-3 py-1.5 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary font-mono",placeholder:"http://localhost:3000"})})}),(0,s.jsx)(S,{label:"API Key",htmlFor:"embedding-example-key",children:(0,s.jsx)("input",{id:"embedding-example-key",type:"password",autoComplete:"off",value:h,onChange:e=>b(e.target.value),placeholder:"Paste a Switchboard client key secret (sk-...)",className:"w-full px-3 py-1.5 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary font-mono"})}),(0,s.jsx)(S,{label:"Input",htmlFor:"embedding-example-input",children:(0,s.jsxs)("div",{className:"relative",children:[(0,s.jsx)("input",{id:"embedding-example-input",value:m,onChange:e=>u(e.target.value),className:"w-full px-3 py-1.5 pr-7 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary"}),m&&(0,s.jsx)("button",{type:"button",onClick:()=>u(""),"aria-label":"Clear input",className:"absolute right-2 top-1/2 -translate-y-1/2 text-text-muted hover:text-primary transition-colors",children:(0,s.jsx)("span",{className:"material-symbols-outlined text-[14px]","aria-hidden":"true",children:"close"})})]})}),(0,s.jsx)(S,{label:"Dimensions",htmlFor:"embedding-example-dimensions",children:(0,s.jsx)("input",{id:"embedding-example-dimensions",type:"number",min:"1",value:p,onChange:e=>x(e.target.value),placeholder:"optional, e.g. 512, 1024 (leave empty for default)",className:"w-full px-3 py-1.5 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary"})}),(0,s.jsxs)("div",{className:"mt-1",children:[(0,s.jsxs)("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between mb-1.5",children:[(0,s.jsx)("span",{className:"text-xs font-semibold text-text-muted uppercase tracking-wider",children:"Request"}),(0,s.jsxs)("div",{className:"flex w-full flex-col gap-2 sm:w-auto sm:flex-row sm:items-center",children:[(0,s.jsxs)("button",{onClick:()=>A(M),className:"inline-flex items-center gap-1 text-xs text-text-muted hover:text-primary transition-colors",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:T?"check":"content_copy"}),T?"Copied":"Copy"]}),(0,s.jsxs)("button",{onClick:O,disabled:N||!m.trim()||!I||!h.trim(),className:"flex w-full sm:w-auto items-center justify-center gap-1.5 px-3 py-1 rounded-lg bg-primary text-on-primary text-xs font-medium hover:bg-primary/90 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-[14px]",style:N?{animation:"spin 1s linear infinite"}:void 0,children:"play_arrow"}),N?"Running...":"Run"]})]})]}),(0,s.jsx)("pre",{className:"bg-sidebar rounded-lg px-3 py-2.5 text-xs font-mono text-text-main overflow-x-auto whitespace-pre-wrap break-all",children:M})]}),C&&(0,s.jsx)("p",{role:"alert",className:"text-xs text-red-500 break-words",children:C}),(0,s.jsxs)("div",{children:[(0,s.jsxs)("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between mb-1.5",children:[(0,s.jsxs)("span",{className:"text-xs font-semibold text-text-muted uppercase tracking-wider",children:["Response ",y&&(0,s.jsxs)("span",{className:"font-normal normal-case",children:["⚡ ",y.latencyMs,"ms"]})]}),y&&(0,s.jsxs)("button",{onClick:()=>P(L),className:"inline-flex items-center gap-1 text-xs text-text-muted hover:text-primary transition-colors",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:R?"check":"content_copy"}),R?"Copied":"Copy"]})]}),(0,s.jsx)("pre",{className:"bg-sidebar rounded-lg px-3 py-2.5 text-xs font-mono text-text-main overflow-x-auto whitespace-pre-wrap break-all opacity-70",children:(e=>{if(!e)return F;let t=JSON.parse(JSON.stringify(e));return(t.data||[]).forEach(e=>{Array.isArray(e.embedding)&&e.embedding.length>4&&(e.embedding=[...e.embedding.slice(0,4).map(e=>parseFloat(e.toFixed(6))),`... (${e.embedding.length} dims)`])}),JSON.stringify(t,null,2)})(y?.data)})]})]})]})}let T={"google-tts":{hasLanguageDropdown:!1,hasModelSelector:!1,hasBrowseButton:!0,voiceSource:"hardcoded"},openai:{hasLanguageDropdown:!1,hasModelSelector:!0,hasBrowseButton:!1,voiceSource:"hardcoded",modelKey:"openai-tts-models",voiceKey:"openai-tts-voices",voicesPerModel:!0},openrouter:{hasLanguageDropdown:!1,hasModelSelector:!0,hasBrowseButton:!1,voiceSource:"hardcoded",modelKey:"openrouter-tts-models",voiceKey:"openrouter-tts-voices",voicesPerModel:!0},elevenlabs:{hasLanguageDropdown:!1,hasModelSelector:!0,hasBrowseButton:!0,hasVoiceIdInput:!0,voiceSource:"api-language",modelKey:"elevenlabs-tts-models",apiEndpoint:"/api/media-providers/tts/elevenlabs/voices"},"edge-tts":{hasLanguageDropdown:!1,hasModelSelector:!1,hasBrowseButton:!0,voiceSource:"api-language"},"local-device":{hasLanguageDropdown:!1,hasModelSelector:!1,hasBrowseButton:!0,voiceSource:"api-language"},nvidia:{hasModelSelector:!0,hasBrowseButton:!1,hasVoiceIdInput:!0,voiceSource:"config"},hyperbolic:{hasModelSelector:!0,hasBrowseButton:!1,voiceSource:"config"},deepgram:{hasModelSelector:!1,hasBrowseButton:!0,voiceSource:"api-language",apiEndpoint:"/api/media-providers/tts/deepgram/voices"},huggingface:{hasModelSelector:!0,hasBrowseButton:!1,voiceSource:"config"},cartesia:{hasModelSelector:!0,hasBrowseButton:!1,hasVoiceIdInput:!0,voiceSource:"config"},playht:{hasModelSelector:!0,hasBrowseButton:!1,hasVoiceIdInput:!0,voiceSource:"config"},coqui:{hasModelSelector:!0,hasBrowseButton:!1,hasVoiceIdInput:!0,voiceSource:"config"},tortoise:{hasModelSelector:!0,hasBrowseButton:!1,hasVoiceIdInput:!0,voiceSource:"config"},inworld:{hasModelSelector:!0,hasBrowseButton:!0,hasVoiceIdInput:!0,voiceSource:"api-language",modelKey:"inworld-tts-models",apiEndpoint:"/api/media-providers/tts/inworld/voices"},qwen:{hasModelSelector:!0,hasBrowseButton:!1,hasVoiceIdInput:!0,voiceSource:"config"},minimax:{hasModelSelector:!0,hasBrowseButton:!0,hasVoiceIdInput:!0,voiceSource:"api-language",apiEndpoint:"/api/media-providers/tts/minimax/voices",defaultVoiceId:"English_expressive_narrator"},"minimax-cn":{hasModelSelector:!0,hasBrowseButton:!0,hasVoiceIdInput:!0,voiceSource:"api-language",apiEndpoint:"/api/media-providers/tts/minimax/voices?provider=minimax-cn",defaultVoiceId:"English_expressive_narrator"},gemini:{hasLanguageDropdown:!1,hasLanguageHint:!0,hasModelSelector:!0,hasBrowseButton:!1,voiceSource:"hardcoded",modelKey:"gemini-tts-models",voiceKey:"gemini-tts-voices",voicesPerModel:!0}};var A=a(63935),R=a(14683);let P=`// Audio will appear here after running.
36
+ -d '${JSON.stringify(_())}'`,M=async()=>{if(!m.trim()||!I||!h.trim())return;k(!0),$(""),w(null);let e=Date.now();try{let t={"Content-Type":"application/json"};h&&(t.Authorization=`Bearer ${h}`);let a=await fetch("/api/v1/embeddings",{method:"POST",headers:t,body:JSON.stringify(_())}),s=Date.now()-e,r=await a.json();if(!a.ok)return void $(r?.error?.message||r?.error||`HTTP ${a.status}`);w({data:r,latencyMs:s})}catch(e){$(e.message||"Network error")}finally{k(!1)}},L=y?JSON.stringify(y.data,null,2):"";return(0,s.jsxs)(n.Zp,{children:[(0,s.jsx)("h2",{className:"text-lg font-semibold mb-4",children:"Example"}),(0,s.jsxs)("div",{className:"flex flex-col gap-2.5",children:[(0,s.jsx)(S,{label:"Model",htmlFor:"embedding-example-model",children:a?(0,s.jsx)("input",{id:"embedding-example-model",value:o,onChange:e=>d(e.target.value),placeholder:"e.g. voyage-3, embed-english-v3.0, text-embedding-3-small",className:"w-full px-3 py-1.5 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary font-mono"}):(0,s.jsx)("select",{id:"embedding-example-model",value:o,onChange:e=>d(e.target.value),className:"w-full px-3 py-1.5 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary",children:l.map(e=>(0,s.jsx)("option",{value:e.id,children:e.name||e.id},e.id))})}),(0,s.jsx)(S,{label:"Endpoint",htmlFor:"embedding-example-endpoint",children:(0,s.jsx)("div",{className:"flex w-full flex-col gap-2 sm:w-auto sm:flex-row sm:items-center",children:(0,s.jsx)("input",{id:"embedding-example-endpoint",value:f,onChange:e=>g(e.target.value),className:"w-full min-w-0 flex-1 px-3 py-1.5 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary font-mono",placeholder:"http://localhost:3000"})})}),(0,s.jsx)(S,{label:"API Key",htmlFor:"embedding-example-key",children:(0,s.jsx)("input",{id:"embedding-example-key",type:"password",autoComplete:"off",value:h,onChange:e=>b(e.target.value),placeholder:"Paste a Switchboard client key secret (sk-...)",className:"w-full px-3 py-1.5 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary font-mono"})}),(0,s.jsx)(S,{label:"Input",htmlFor:"embedding-example-input",children:(0,s.jsxs)("div",{className:"relative",children:[(0,s.jsx)("input",{id:"embedding-example-input",value:m,onChange:e=>u(e.target.value),className:"w-full px-3 py-1.5 pr-7 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary"}),m&&(0,s.jsx)("button",{type:"button",onClick:()=>u(""),"aria-label":"Clear input",className:"absolute right-2 top-1/2 -translate-y-1/2 text-text-muted hover:text-primary transition-colors",children:(0,s.jsx)("span",{className:"material-symbols-outlined text-[14px]","aria-hidden":"true",children:"close"})})]})}),(0,s.jsx)(S,{label:"Dimensions",htmlFor:"embedding-example-dimensions",children:(0,s.jsx)("input",{id:"embedding-example-dimensions",type:"number",min:"1",value:p,onChange:e=>x(e.target.value),placeholder:"optional, e.g. 512, 1024 (leave empty for default)",className:"w-full px-3 py-1.5 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary"})}),(0,s.jsxs)("div",{className:"mt-1",children:[(0,s.jsxs)("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between mb-1.5",children:[(0,s.jsx)("span",{className:"text-xs font-semibold text-text-muted uppercase tracking-wider",children:"Request"}),(0,s.jsxs)("div",{className:"flex w-full flex-col gap-2 sm:w-auto sm:flex-row sm:items-center",children:[(0,s.jsxs)("button",{onClick:()=>T(O),className:"inline-flex items-center gap-1 text-xs text-text-muted hover:text-primary transition-colors",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:A?"check":"content_copy"}),A?"Copied":"Copy"]}),(0,s.jsxs)("button",{onClick:M,disabled:N||!m.trim()||!I||!h.trim(),className:"flex w-full sm:w-auto items-center justify-center gap-1.5 px-3 py-1 rounded-lg bg-primary text-on-primary text-xs font-medium hover:bg-primary/90 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-[14px]",style:N?{animation:"spin 1s linear infinite"}:void 0,children:"play_arrow"}),N?"Running...":"Run"]})]})]}),(0,s.jsx)("pre",{className:"bg-sidebar rounded-lg px-3 py-2.5 text-xs font-mono text-text-main overflow-x-auto whitespace-pre-wrap break-all",children:O})]}),C&&(0,s.jsx)("p",{role:"alert",className:"text-xs text-red-500 break-words",children:C}),(0,s.jsxs)("div",{children:[(0,s.jsxs)("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between mb-1.5",children:[(0,s.jsxs)("span",{className:"text-xs font-semibold text-text-muted uppercase tracking-wider",children:["Response ",y&&(0,s.jsxs)("span",{className:"font-normal normal-case",children:["⚡ ",y.latencyMs,"ms"]})]}),y&&(0,s.jsxs)("button",{onClick:()=>P(L),className:"inline-flex items-center gap-1 text-xs text-text-muted hover:text-primary transition-colors",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:R?"check":"content_copy"}),R?"Copied":"Copy"]})]}),(0,s.jsx)("pre",{className:"bg-sidebar rounded-lg px-3 py-2.5 text-xs font-mono text-text-main overflow-x-auto whitespace-pre-wrap break-all opacity-70",children:(e=>{if(!e)return F;let t=JSON.parse(JSON.stringify(e));return(t.data||[]).forEach(e=>{Array.isArray(e.embedding)&&e.embedding.length>4&&(e.embedding=[...e.embedding.slice(0,4).map(e=>parseFloat(e.toFixed(6))),`... (${e.embedding.length} dims)`])}),JSON.stringify(t,null,2)})(y?.data)})]})]})]})}let A={"google-tts":{hasLanguageDropdown:!1,hasModelSelector:!1,hasBrowseButton:!0,voiceSource:"hardcoded"},openai:{hasLanguageDropdown:!1,hasModelSelector:!0,hasBrowseButton:!1,voiceSource:"hardcoded",modelKey:"openai-tts-models",voiceKey:"openai-tts-voices",voicesPerModel:!0},openrouter:{hasLanguageDropdown:!1,hasModelSelector:!0,hasBrowseButton:!1,voiceSource:"hardcoded",modelKey:"openrouter-tts-models",voiceKey:"openrouter-tts-voices",voicesPerModel:!0},elevenlabs:{hasLanguageDropdown:!1,hasModelSelector:!0,hasBrowseButton:!0,hasVoiceIdInput:!0,voiceSource:"api-language",modelKey:"elevenlabs-tts-models",apiEndpoint:"/api/media-providers/tts/elevenlabs/voices"},"edge-tts":{hasLanguageDropdown:!1,hasModelSelector:!1,hasBrowseButton:!0,voiceSource:"api-language"},"local-device":{hasLanguageDropdown:!1,hasModelSelector:!1,hasBrowseButton:!0,voiceSource:"api-language"},nvidia:{hasModelSelector:!0,hasBrowseButton:!1,hasVoiceIdInput:!0,voiceSource:"config"},hyperbolic:{hasModelSelector:!0,hasBrowseButton:!1,voiceSource:"config"},deepgram:{hasModelSelector:!1,hasBrowseButton:!0,voiceSource:"api-language",apiEndpoint:"/api/media-providers/tts/deepgram/voices"},huggingface:{hasModelSelector:!0,hasBrowseButton:!1,voiceSource:"config"},cartesia:{hasModelSelector:!0,hasBrowseButton:!1,hasVoiceIdInput:!0,voiceSource:"config"},playht:{hasModelSelector:!0,hasBrowseButton:!1,hasVoiceIdInput:!0,voiceSource:"config"},coqui:{hasModelSelector:!0,hasBrowseButton:!1,hasVoiceIdInput:!0,voiceSource:"config"},tortoise:{hasModelSelector:!0,hasBrowseButton:!1,hasVoiceIdInput:!0,voiceSource:"config"},inworld:{hasModelSelector:!0,hasBrowseButton:!0,hasVoiceIdInput:!0,voiceSource:"api-language",modelKey:"inworld-tts-models",apiEndpoint:"/api/media-providers/tts/inworld/voices"},qwen:{hasModelSelector:!0,hasBrowseButton:!1,hasVoiceIdInput:!0,voiceSource:"config"},minimax:{hasModelSelector:!0,hasBrowseButton:!0,hasVoiceIdInput:!0,voiceSource:"api-language",apiEndpoint:"/api/media-providers/tts/minimax/voices",defaultVoiceId:"English_expressive_narrator"},"minimax-cn":{hasModelSelector:!0,hasBrowseButton:!0,hasVoiceIdInput:!0,voiceSource:"api-language",apiEndpoint:"/api/media-providers/tts/minimax/voices?provider=minimax-cn",defaultVoiceId:"English_expressive_narrator"},gemini:{hasLanguageDropdown:!1,hasLanguageHint:!0,hasModelSelector:!0,hasBrowseButton:!1,voiceSource:"hardcoded",modelKey:"gemini-tts-models",voiceKey:"gemini-tts-voices",voicesPerModel:!0}};var T=a(63935),R=a(14683);let P=`// Audio will appear here after running.
37
37
  // Example JSON response (response_format=json):
38
38
  {
39
39
  "format": "mp3",
40
40
  "audio": "//NExAANaAIIAUAAANNNNNNNN..." // base64 encoded MP3
41
- }`;function I({providerId:e}){let t,a,r=(0,c.wG)(e),l=T[e]||T["edge-tts"],[o,d]=(0,i.useState)(l.defaultVoiceId||""),[m,u]=(0,i.useState)(""),[p,x]=(0,i.useState)(l.defaultVoiceId||""),[h,b]=(0,i.useState)([]),[g,f]=(0,i.useState)(""),[y,w]=(0,i.useState)(()=>{let t=c.Q2[e]?.ttsConfig?.models;if(t?.length)return t[0].id;if(l.hasModelSelector&&l.modelKey){let e=(0,v.KC)(l.modelKey);return e?.[0]?.id||""}return""}),[N,k]=(0,i.useState)("Hello, this is a text to speech test."),[C,$]=(0,i.useState)(""),[F,E]=(0,i.useState)(""),[_,M]=(0,i.useState)("mp3"),[O,L]=(0,i.useState)(""),[K,B]=(0,i.useState)(null),[D,U]=(0,i.useState)(!1),[q,z]=(0,i.useState)(""),[J,V]=(0,i.useState)(null),{copied:H,copy:W}=(0,j.C)(),[G,Y]=(0,i.useState)(!1),[Z,Q]=(0,i.useState)([]),[X,ee]=(0,i.useState)(!1),[et,ea]=(0,i.useState)(""),[es,er]=(0,i.useState)(""),[el,eo]=(0,i.useState)({}),[ei,en]=(0,i.useState)("");(0,i.useEffect)(()=>{if(E(window.location.origin),"hardcoded"===l.voiceSource){let t=l.hasModelSelector&&l.modelKey&&(0,v.KC)(l.modelKey)?.[0]?.id||"",a=l.voicesPerModel&&t?(0,A.jY)(e,t)||[]:(0,v.KC)(l.voiceKey||e).filter(e=>"tts"===(0,v.CP)(e));if(a.length)if(l.hasBrowseButton){let e=a.find(e=>"en"===e.id)||a[0];f(e.id),d(e.id),u(e.name),b([{id:e.id,name:e.name}])}else b(a),d(a[0].id),u(a[0].name||a[0].id)}},[l.hasBrowseButton,l.hasModelSelector,l.modelKey,l.voiceKey,l.voiceSource,l.voicesPerModel,e]),(0,i.useEffect)(()=>{if(!l.voicesPerModel||!y)return;let t=(0,A.jY)(e,y)||[];b(t),t.length&&(d(t[0].id),u(t[0].name||t[0].id))},[l.voicesPerModel,e,y]);let ed=async()=>{if(Y(!0),ea(""),er(""),!Z.length){ee(!0);try{if("hardcoded"===l.voiceSource){let t=l.voiceKey||e,a=(0,v.KC)(t).filter(e=>"tts"===(0,v.CP)(e)),s={};for(let e of a)s[e.id]||(s[e.id]={code:e.id,name:e.name,voices:[{id:e.id,name:e.name}]});eo(s),Q(Object.values(s).sort((e,t)=>e.name.localeCompare(t.name)))}else{let t=l.apiEndpoint?l.apiEndpoint:`/api/media-providers/tts/voices?provider=${"local-device"===e?"local-device":"edge-tts"}`,a=await fetch(t),s=await a.json();if(s.error)return void er(s.error);Q(s.languages||[]),eo(s.byLang||{})}}catch(e){er(e.message)}finally{ee(!1)}}},ec=et?Z.filter(e=>e.name.toLowerCase().includes(et.toLowerCase())||e.code.toLowerCase().includes(et.toLowerCase())):Z,em=l.hasVoiceIdInput&&p||o,eu=l.hasModelSelector&&y&&em?`${r}/${y}/${em}`:l.hasModelSelector&&y?`${r}/${y}`:em?`${r}/${em}`:"",ep=(t={model:eu,input:N},l.hasLanguageHint&&ei&&(t.language=ei),t),ex=`curl -X POST ${F}/v1/audio/speech${"json"===_?"?response_format=json":""} \\
41
+ }`;function I({providerId:e}){let t,a,r=(0,c.wG)(e),l=A[e]||A["edge-tts"],[o,d]=(0,i.useState)(l.defaultVoiceId||""),[m,u]=(0,i.useState)(""),[p,x]=(0,i.useState)(l.defaultVoiceId||""),[h,b]=(0,i.useState)([]),[f,g]=(0,i.useState)(""),[y,w]=(0,i.useState)(()=>{let t=c.Q2[e]?.ttsConfig?.models;if(t?.length)return t[0].id;if(l.hasModelSelector&&l.modelKey){let e=(0,v.KC)(l.modelKey);return e?.[0]?.id||""}return""}),[N,k]=(0,i.useState)("Hello, this is a text to speech test."),[C,$]=(0,i.useState)(""),[F,E]=(0,i.useState)(""),[_,O]=(0,i.useState)("mp3"),[M,L]=(0,i.useState)(""),[K,B]=(0,i.useState)(null),[D,U]=(0,i.useState)(!1),[q,z]=(0,i.useState)(""),[J,V]=(0,i.useState)(null),{copied:H,copy:W}=(0,j.C)(),[G,Y]=(0,i.useState)(!1),[Z,Q]=(0,i.useState)([]),[X,ee]=(0,i.useState)(!1),[et,ea]=(0,i.useState)(""),[es,er]=(0,i.useState)(""),[el,eo]=(0,i.useState)({}),[ei,en]=(0,i.useState)("");(0,i.useEffect)(()=>{if(E(window.location.origin),"hardcoded"===l.voiceSource){let t=l.hasModelSelector&&l.modelKey&&(0,v.KC)(l.modelKey)?.[0]?.id||"",a=l.voicesPerModel&&t?(0,T.jY)(e,t)||[]:(0,v.KC)(l.voiceKey||e).filter(e=>"tts"===(0,v.CP)(e));if(a.length)if(l.hasBrowseButton){let e=a.find(e=>"en"===e.id)||a[0];g(e.id),d(e.id),u(e.name),b([{id:e.id,name:e.name}])}else b(a),d(a[0].id),u(a[0].name||a[0].id)}},[l.hasBrowseButton,l.hasModelSelector,l.modelKey,l.voiceKey,l.voiceSource,l.voicesPerModel,e]),(0,i.useEffect)(()=>{if(!l.voicesPerModel||!y)return;let t=(0,T.jY)(e,y)||[];b(t),t.length&&(d(t[0].id),u(t[0].name||t[0].id))},[l.voicesPerModel,e,y]);let ed=async()=>{if(Y(!0),ea(""),er(""),!Z.length){ee(!0);try{if("hardcoded"===l.voiceSource){let t=l.voiceKey||e,a=(0,v.KC)(t).filter(e=>"tts"===(0,v.CP)(e)),s={};for(let e of a)s[e.id]||(s[e.id]={code:e.id,name:e.name,voices:[{id:e.id,name:e.name}]});eo(s),Q(Object.values(s).sort((e,t)=>e.name.localeCompare(t.name)))}else{let t=l.apiEndpoint?l.apiEndpoint:`/api/media-providers/tts/voices?provider=${"local-device"===e?"local-device":"edge-tts"}`,a=await fetch(t),s=await a.json();if(s.error)return void er(s.error);Q(s.languages||[]),eo(s.byLang||{})}}catch(e){er(e.message)}finally{ee(!1)}}},ec=et?Z.filter(e=>e.name.toLowerCase().includes(et.toLowerCase())||e.code.toLowerCase().includes(et.toLowerCase())):Z,em=l.hasVoiceIdInput&&p||o,eu=l.hasModelSelector&&y&&em?`${r}/${y}/${em}`:l.hasModelSelector&&y?`${r}/${y}`:em?`${r}/${em}`:"",ep=(t={model:eu,input:N},l.hasLanguageHint&&ei&&(t.language=ei),t),ex=`curl -X POST ${F}/v1/audio/speech${"json"===_?"?response_format=json":""} \\
42
42
  -H "Content-Type: application/json" \\
43
43
  -H "Authorization: Bearer ${C||"YOUR_KEY"}" \\
44
44
  -d '${JSON.stringify(ep)}' \\
45
- ${"json"===_?"":"--output speech.mp3"}`,eh=async()=>{if(!N.trim()||!eu||!C.trim())return;U(!0),z(""),L(""),B(null);let e=Date.now();try{let t={"Content-Type":"application/json"};C&&(t.Authorization=`Bearer ${C}`);let a=`/api/v1/audio/speech${"json"===_?"?response_format=json":""}`,s=await fetch(a,{method:"POST",headers:t,body:JSON.stringify({...ep,input:N.trim()})});if(V(Date.now()-e),!s.ok){let e=await s.json().catch(()=>({}));z(e?.error?.message||e?.error||`HTTP ${s.status}`);return}if("json"===_){let e=await s.json();B(e);let t=await fetch(`data:audio/mp3;base64,${e.audio}`).then(e=>e.blob());L(URL.createObjectURL(t))}else{let e=await s.blob();L(URL.createObjectURL(e))}}catch(e){z(e.message||"Network error")}finally{U(!1)}};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)(n.Zp,{children:[(0,s.jsx)("h2",{className:"text-lg font-semibold mb-4",children:"Example"}),(0,s.jsxs)("div",{className:"flex flex-col gap-2.5",children:[(0,s.jsx)(S,{label:"Endpoint",children:(0,s.jsx)("div",{className:"flex w-full flex-col gap-2 sm:w-auto sm:flex-row sm:items-center",children:(0,s.jsxs)("span",{className:"w-full min-w-0 flex-1 px-3 py-1.5 text-sm font-mono text-text-main bg-sidebar rounded-lg truncate",children:[F,"/v1/audio/speech"]})})}),(0,s.jsx)(S,{label:"API Key",htmlFor:"tts-example-key",children:(0,s.jsx)("input",{id:"tts-example-key",type:"password",autoComplete:"off",value:C,onChange:e=>$(e.target.value),placeholder:"Paste a Switchboard client key secret (sk-...)",className:"w-full px-3 py-1.5 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary font-mono"})}),l.hasModelSelector&&(l.modelKey||(0,v.KC)(e).some(e=>"tts"===(0,v.CP)(e)))&&(0,s.jsx)(S,{label:"Model",htmlFor:"tts-example-model",children:(0,s.jsx)("select",{id:"tts-example-model",value:y,onChange:e=>w(e.target.value),className:"w-full px-3 py-1.5 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary",children:((a=(0,v.KC)(e).filter(e=>"tts"===(0,v.CP)(e))).length?a:(0,v.KC)(l.modelKey)||[]).map(e=>(0,s.jsx)("option",{value:e.id,children:e.name||e.id},e.id))})}),l.hasLanguageHint&&(0,s.jsx)(S,{label:"Language",htmlFor:"tts-example-language-hint",children:(0,s.jsxs)("select",{id:"tts-example-language-hint",value:ei,onChange:e=>en(e.target.value),className:"w-full px-3 py-1.5 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary",children:[(0,s.jsx)("option",{value:"",children:"Auto-detect"}),R.I.map(e=>(0,s.jsx)("option",{value:e.name,children:e.name},e.id))]})}),l.hasBrowseButton&&(0,s.jsx)(S,{label:"Language",children:(0,s.jsxs)("div",{className:"flex w-full flex-col gap-2 sm:w-auto sm:flex-row sm:items-center",children:[(0,s.jsx)("button",{onClick:ed,"aria-haspopup":"dialog","aria-expanded":G,"aria-label":g?`Language: ${Z.find(e=>e.code===g)?.name||g}. Change language`:"Select language",className:"w-full min-w-0 flex-1 px-3 py-1.5 text-sm border border-border rounded-lg bg-background font-mono truncate text-left hover:border-primary/40 transition-colors",children:g?(0,s.jsx)("span",{className:"text-text-main",children:Z.find(e=>e.code===g)?.name||g}):(0,s.jsx)("span",{className:"text-text-muted",children:"No language selected"})}),(0,s.jsxs)("button",{onClick:ed,className:"flex w-full items-center justify-center gap-1 text-xs px-2.5 py-1.5 rounded-lg border border-border text-text-muted hover:text-primary hover:border-primary/40 transition-colors sm:w-auto sm:shrink-0",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"language"}),"Select language"]})]})}),h.length>0&&(0,s.jsx)(S,{label:"Voice",children:(0,s.jsx)("div",{className:"flex flex-wrap gap-1.5",children:h.map(e=>(0,s.jsxs)("button",{onClick:()=>{d(e.id),u(e.name),l.hasVoiceIdInput&&x(e.id)},className:`px-2.5 py-1 rounded-full text-xs border transition-colors ${o===e.id?"bg-primary/15 border-primary/40 text-primary font-medium":"border-border text-text-muted hover:text-primary hover:border-primary/40"}`,children:[e.name,e.gender?` \xb7 ${e.gender[0].toUpperCase()}`:"",!0===e.free_users_allowed&&(0,s.jsx)("span",{className:"ml-1.5 px-1 py-0.5 text-[9px] font-semibold rounded bg-green-500/15 text-green-600 border border-green-500/20",children:"Free"}),!1===e.free_users_allowed&&(0,s.jsx)("span",{className:"ml-1.5 px-1 py-0.5 text-[9px] font-semibold rounded bg-amber-500/15 text-amber-600 border border-amber-500/20",children:"Paid"})]},e.id))})}),l.hasVoiceIdInput&&(0,s.jsx)(S,{label:"Voice ID",htmlFor:"tts-example-voice-id",children:(0,s.jsx)("div",{className:"flex flex-col gap-1",children:(0,s.jsxs)("div",{className:"relative",children:[(0,s.jsx)("input",{id:"tts-example-voice-id",value:p,onChange:e=>{x(e.target.value),d(e.target.value)},placeholder:"e.g. CwhRBWXzGAHq8TQ4Fs17",className:"w-full px-3 py-1.5 pr-7 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary font-mono"}),p&&(0,s.jsx)("button",{type:"button",onClick:()=>{x(""),d("")},"aria-label":"Clear voice ID",className:"absolute right-2 top-1/2 -translate-y-1/2 text-text-muted hover:text-primary transition-colors",children:(0,s.jsx)("span",{className:"material-symbols-outlined text-[14px]","aria-hidden":"true",children:"close"})})]})})}),l.hasLanguageDropdown&&(0,s.jsx)(S,{label:"Language",htmlFor:"tts-example-language",children:(0,s.jsx)("select",{id:"tts-example-language",value:o,onChange:t=>{let a=(0,v.KC)(e).filter(e=>"tts"===(0,v.CP)(e)).find(e=>e.id===t.target.value);d(t.target.value),u(a?.name||t.target.value)},className:"w-full px-3 py-1.5 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary",children:(0,v.KC)(e).filter(e=>"tts"===(0,v.CP)(e)).map(e=>(0,s.jsx)("option",{value:e.id,children:e.name||e.id},e.id))})}),(0,s.jsx)(S,{label:"Input",htmlFor:"tts-example-input",children:(0,s.jsxs)("div",{className:"relative",children:[(0,s.jsx)("input",{id:"tts-example-input",value:N,onChange:e=>k(e.target.value),className:"w-full px-3 py-1.5 pr-7 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary"}),N&&(0,s.jsx)("button",{type:"button",onClick:()=>k(""),"aria-label":"Clear input",className:"absolute right-2 top-1/2 -translate-y-1/2 text-text-muted hover:text-primary transition-colors",children:(0,s.jsx)("span",{className:"material-symbols-outlined text-[14px]","aria-hidden":"true",children:"close"})})]})}),(0,s.jsx)(S,{label:"Output Format",htmlFor:"tts-example-format",children:(0,s.jsxs)("select",{id:"tts-example-format",value:_,onChange:e=>M(e.target.value),className:"w-full px-3 py-1.5 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary",children:[(0,s.jsx)("option",{value:"mp3",children:"MP3 (Binary)"}),(0,s.jsx)("option",{value:"json",children:"JSON (Base64)"})]})}),(0,s.jsxs)("div",{className:"mt-1",children:[(0,s.jsxs)("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between mb-1.5",children:[(0,s.jsx)("span",{className:"text-xs font-semibold text-text-muted uppercase tracking-wider",children:"Request"}),(0,s.jsxs)("div",{className:"flex w-full flex-col gap-2 sm:w-auto sm:flex-row sm:items-center",children:[(0,s.jsxs)("button",{onClick:()=>W(ex),className:"inline-flex items-center gap-1 text-xs text-text-muted hover:text-primary transition-colors",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:H?"check":"content_copy"}),H?"Copied":"Copy"]}),(0,s.jsxs)("button",{onClick:eh,disabled:D||!N.trim()||!eu||!C.trim(),className:"flex w-full sm:w-auto items-center justify-center gap-1.5 px-3 py-1 rounded-lg bg-primary text-on-primary text-xs font-medium hover:bg-primary/90 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-[14px]",style:D?{animation:"spin 1s linear infinite"}:void 0,children:"play_arrow"}),D?"Generating...":"Run"]})]})]}),(0,s.jsx)("pre",{className:"bg-sidebar rounded-lg px-3 py-2.5 text-xs font-mono text-text-main overflow-x-auto whitespace-pre-wrap break-all",children:ex})]}),q&&(0,s.jsx)("p",{role:"alert",className:"text-xs text-red-500 break-words",children:q}),O?(0,s.jsxs)("div",{children:[(0,s.jsxs)("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between mb-1.5",children:[(0,s.jsxs)("span",{className:"text-xs font-semibold text-text-muted uppercase tracking-wider",children:["Response ",J&&(0,s.jsxs)("span",{className:"font-normal normal-case",children:["⚡ ",J,"ms"]})]}),(0,s.jsxs)("a",{href:O,download:"speech.mp3",className:"inline-flex items-center gap-1 text-xs text-text-muted hover:text-primary transition-colors",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"download"}),"Download"]})]}),(0,s.jsx)("audio",{controls:!0,src:O,className:"w-full"}),K&&(0,s.jsxs)("div",{className:"mt-3",children:[(0,s.jsx)("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between mb-1.5",children:(0,s.jsx)("span",{className:"text-xs font-semibold text-text-muted uppercase tracking-wider",children:"JSON Response"})}),(0,s.jsx)("pre",{className:"bg-sidebar rounded-lg px-3 py-2.5 text-xs font-mono text-text-main overflow-x-auto whitespace-pre-wrap break-all",children:JSON.stringify({format:K.format,audio:K.audio?`${K.audio.substring(0,100)}...`:""},null,2)})]})]}):(0,s.jsxs)("div",{children:[(0,s.jsx)("span",{className:"text-xs font-semibold text-text-muted uppercase tracking-wider",children:"Response"}),(0,s.jsx)("pre",{className:"mt-1.5 bg-sidebar rounded-lg px-3 py-2.5 text-xs font-mono text-text-main overflow-x-auto whitespace-pre-wrap break-all opacity-50",children:P})]})]})]}),G&&(0,s.jsx)("div",{className:"fixed inset-0 z-50 flex items-end justify-center sm:items-center",style:{backgroundColor:"rgba(0,0,0,0.6)",backdropFilter:"blur(2px)"},onClick:()=>Y(!1),onKeyDown:e=>{"Escape"===e.key&&Y(!1)},children:(0,s.jsxs)("div",{role:"dialog","aria-modal":"true","aria-labelledby":"tts-language-modal-title",className:"border border-border rounded-xl shadow-2xl w-full max-w-md mx-4 flex flex-col max-h-[80vh]",style:{backgroundColor:"var(--color-bg)",isolation:"isolate"},onClick:e=>e.stopPropagation(),children:[(0,s.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border shrink-0 rounded-t-xl",children:[(0,s.jsx)("h3",{id:"tts-language-modal-title",className:"text-sm font-semibold","data-i18n":"Select Language",children:"Select Language"}),(0,s.jsx)("button",{onClick:()=>Y(!1),"aria-label":"Close language picker",className:"text-text-muted hover:text-primary transition-colors",children:(0,s.jsx)("span",{className:"material-symbols-outlined text-[20px]","aria-hidden":"true",children:"close"})})]}),(0,s.jsx)("div",{className:"px-4 py-2.5 border-b border-border shrink-0",children:(0,s.jsx)("input",{autoFocus:!0,type:"text","aria-label":"Search language",value:et,onChange:e=>ea(e.target.value),placeholder:"Search language...","data-i18n-placeholder":"Search language...",className:"w-full px-3 py-1.5 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary"})}),(0,s.jsxs)("div",{className:"overflow-y-auto flex-1 p-2",children:[es&&(0,s.jsx)("p",{className:"text-xs text-red-500 px-2 py-1",children:es}),X?(0,s.jsx)("p",{className:"text-xs text-text-muted px-2 py-3",children:"Loading..."}):(0,s.jsxs)("div",{className:"flex flex-col gap-0.5",children:[ec.map(e=>(0,s.jsxs)("button",{onClick:()=>{let t;return Y(!1),f(e.code),void(b(t=el[e.code]?.voices||[]),t.length&&(d(t[0].id),u(t[0].name),l.hasVoiceIdInput&&x(t[0].id)))},className:`flex items-center justify-between w-full px-3 py-2 rounded-lg text-left hover:bg-sidebar transition-colors ${g===e.code?"bg-primary/10 text-primary":""}`,children:[(0,s.jsx)("span",{className:"text-sm",children:e.name}),(0,s.jsxs)("div",{className:"flex items-center gap-2 shrink-0",children:[(0,s.jsxs)("span",{className:"text-xs text-text-muted",children:[e.voices.length," voices"]}),g===e.code&&(0,s.jsx)("span",{className:"material-symbols-outlined text-[16px] text-primary",children:"check"})]})]},e.code)),0===ec.length&&(0,s.jsx)("p",{className:"text-xs text-text-muted px-2 py-3",children:"No languages found."})]})]})]})})]})}var _=a(5772);let M="https://pub-1fb693cb11cc46b2b2f656f51e015a2c.r2.dev/dog.png";function O(e){let t="string"==typeof e?e.trim():"";return t?/^(data:image\/|https?:\/\/)/i.test(t)?t:`data:image/png;base64,${t}`:""}function L({providerId:e,kind:t}){let a=(0,c.wG)(e),r=(0,c.rs)(a)===e?a:e,l=c.rj.find(e=>e.id===t),o=$[t],d=o||{},m=(0,v.KC)(e).filter(e=>(0,v.CP)(e)===t),u=new Set(["image","video","music","imageToText"]).has(t),p=u&&0===m.length,[x,h]=(0,i.useState)(m[0]?.id??""),b=m.find(e=>e.id===x),g=!!b?.capabilities?.includes("edit"),f=!!b?.capabilities?.includes("mask"),[y,w]=(0,i.useState)(d.defaultInput||""),[N,k]=(0,i.useState)(""),[C,F]=(0,i.useState)(""),[E,T]=(0,i.useState)(()=>(d.extraFields||[]).reduce((e,t)=>(e[t.key]=t.default??"",e),{})),[A,R]=(0,i.useState)(""),[P,I]=(0,i.useState)(""),[K,B]=(0,i.useState)(null),[D,U]=(0,i.useState)(null),[q,z]=(0,i.useState)(null),[J,V]=(0,i.useState)("json"),[H,W]=(0,i.useState)(""),[G,Y]=(0,i.useState)(!1),[Z,Q]=(0,i.useState)(""),[X,ee]=(0,i.useState)([]),[et,ea]=(0,i.useState)(""),{copied:es,copy:er}=(0,j.C)(),{copied:el,copy:eo}=(0,j.C)();if((0,i.useEffect)(()=>{I(window.location.origin),fetch("/api/providers/client").then(e=>e.json()).then(t=>{ee((t.connections||[]).filter(t=>t.provider===e&&!1!==t.isActive))}).catch(()=>{})},[e]),!l||!o)return null;let ei=l.endpoint.path,en=u?x?`${r}/${x}`:p?"":r:r,ed="cloudflare-ai"!==e?{}:"@cf/runwayml/stable-diffusion-v1-5-img2img"===x?{image:M}:"@cf/runwayml/stable-diffusion-v1-5-inpainting"===x?{image:M,mask_image:"https://pub-1fb693cb11cc46b2b2f656f51e015a2c.r2.dev/dog-mask.png"}:{},ec=N.trim()||ed.image||"",em=C.trim()||ed.mask_image||"",eu=O(ec),ep=O(em),ex=Object.entries(E).reduce((e,[t,a])=>(""===a||null==a||"number"==typeof a&&Number.isNaN(a)||(e[t]=a),e),{}),eh={model:en,[o.bodyKey]:y,...o.extraBody,...ex,...g&&ec?{image:ec}:{},...f&&em?{mask_image:em}:{}},eb="image"===t&&"binary"===J,eg="image"===t&&"codex"===e&&!eb,ef=`${ei}${eb?"?response_format=binary":""}`,ey=`-H "Content-Type: application/json" \\
46
- -H "Authorization: Bearer ${A||"YOUR_KEY"}"${et?` \\
47
- -H "x-connection-id: ${et}"`:""}${eg?` \\
48
- -H "Accept: text/event-stream"`:""}`,ev=`curl -X ${l.endpoint.method} ${P}${ef} \\
45
+ ${"json"===_?"":"--output speech.mp3"}`,eh=async()=>{if(!N.trim()||!eu||!C.trim())return;U(!0),z(""),L(""),B(null);let e=Date.now();try{let t={"Content-Type":"application/json"};C&&(t.Authorization=`Bearer ${C}`);let a=`/api/v1/audio/speech${"json"===_?"?response_format=json":""}`,s=await fetch(a,{method:"POST",headers:t,body:JSON.stringify({...ep,input:N.trim()})});if(V(Date.now()-e),!s.ok){let e=await s.json().catch(()=>({}));z(e?.error?.message||e?.error||`HTTP ${s.status}`);return}if("json"===_){let e=await s.json();B(e);let t=await fetch(`data:audio/mp3;base64,${e.audio}`).then(e=>e.blob());L(URL.createObjectURL(t))}else{let e=await s.blob();L(URL.createObjectURL(e))}}catch(e){z(e.message||"Network error")}finally{U(!1)}};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)(n.Zp,{children:[(0,s.jsx)("h2",{className:"text-lg font-semibold mb-4",children:"Example"}),(0,s.jsxs)("div",{className:"flex flex-col gap-2.5",children:[(0,s.jsx)(S,{label:"Endpoint",children:(0,s.jsx)("div",{className:"flex w-full flex-col gap-2 sm:w-auto sm:flex-row sm:items-center",children:(0,s.jsxs)("span",{className:"w-full min-w-0 flex-1 px-3 py-1.5 text-sm font-mono text-text-main bg-sidebar rounded-lg truncate",children:[F,"/v1/audio/speech"]})})}),(0,s.jsx)(S,{label:"API Key",htmlFor:"tts-example-key",children:(0,s.jsx)("input",{id:"tts-example-key",type:"password",autoComplete:"off",value:C,onChange:e=>$(e.target.value),placeholder:"Paste a Switchboard client key secret (sk-...)",className:"w-full px-3 py-1.5 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary font-mono"})}),l.hasModelSelector&&(l.modelKey||(0,v.KC)(e).some(e=>"tts"===(0,v.CP)(e)))&&(0,s.jsx)(S,{label:"Model",htmlFor:"tts-example-model",children:(0,s.jsx)("select",{id:"tts-example-model",value:y,onChange:e=>w(e.target.value),className:"w-full px-3 py-1.5 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary",children:((a=(0,v.KC)(e).filter(e=>"tts"===(0,v.CP)(e))).length?a:(0,v.KC)(l.modelKey)||[]).map(e=>(0,s.jsx)("option",{value:e.id,children:e.name||e.id},e.id))})}),l.hasLanguageHint&&(0,s.jsx)(S,{label:"Language",htmlFor:"tts-example-language-hint",children:(0,s.jsxs)("select",{id:"tts-example-language-hint",value:ei,onChange:e=>en(e.target.value),className:"w-full px-3 py-1.5 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary",children:[(0,s.jsx)("option",{value:"",children:"Auto-detect"}),R.I.map(e=>(0,s.jsx)("option",{value:e.name,children:e.name},e.id))]})}),l.hasBrowseButton&&(0,s.jsx)(S,{label:"Language",children:(0,s.jsxs)("div",{className:"flex w-full flex-col gap-2 sm:w-auto sm:flex-row sm:items-center",children:[(0,s.jsx)("button",{onClick:ed,"aria-haspopup":"dialog","aria-expanded":G,"aria-label":f?`Language: ${Z.find(e=>e.code===f)?.name||f}. Change language`:"Select language",className:"w-full min-w-0 flex-1 px-3 py-1.5 text-sm border border-border rounded-lg bg-background font-mono truncate text-left hover:border-primary/40 transition-colors",children:f?(0,s.jsx)("span",{className:"text-text-main",children:Z.find(e=>e.code===f)?.name||f}):(0,s.jsx)("span",{className:"text-text-muted",children:"No language selected"})}),(0,s.jsxs)("button",{onClick:ed,className:"flex w-full items-center justify-center gap-1 text-xs px-2.5 py-1.5 rounded-lg border border-border text-text-muted hover:text-primary hover:border-primary/40 transition-colors sm:w-auto sm:shrink-0",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"language"}),"Select language"]})]})}),h.length>0&&(0,s.jsx)(S,{label:"Voice",children:(0,s.jsx)("div",{className:"flex flex-wrap gap-1.5",children:h.map(e=>(0,s.jsxs)("button",{onClick:()=>{d(e.id),u(e.name),l.hasVoiceIdInput&&x(e.id)},className:`px-2.5 py-1 rounded-full text-xs border transition-colors ${o===e.id?"bg-primary/15 border-primary/40 text-primary font-medium":"border-border text-text-muted hover:text-primary hover:border-primary/40"}`,children:[e.name,e.gender?` \xb7 ${e.gender[0].toUpperCase()}`:"",!0===e.free_users_allowed&&(0,s.jsx)("span",{className:"ml-1.5 px-1 py-0.5 text-[9px] font-semibold rounded bg-green-500/15 text-green-600 border border-green-500/20",children:"Free"}),!1===e.free_users_allowed&&(0,s.jsx)("span",{className:"ml-1.5 px-1 py-0.5 text-[9px] font-semibold rounded bg-amber-500/15 text-amber-600 border border-amber-500/20",children:"Paid"})]},e.id))})}),l.hasVoiceIdInput&&(0,s.jsx)(S,{label:"Voice ID",htmlFor:"tts-example-voice-id",children:(0,s.jsx)("div",{className:"flex flex-col gap-1",children:(0,s.jsxs)("div",{className:"relative",children:[(0,s.jsx)("input",{id:"tts-example-voice-id",value:p,onChange:e=>{x(e.target.value),d(e.target.value)},placeholder:"e.g. CwhRBWXzGAHq8TQ4Fs17",className:"w-full px-3 py-1.5 pr-7 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary font-mono"}),p&&(0,s.jsx)("button",{type:"button",onClick:()=>{x(""),d("")},"aria-label":"Clear voice ID",className:"absolute right-2 top-1/2 -translate-y-1/2 text-text-muted hover:text-primary transition-colors",children:(0,s.jsx)("span",{className:"material-symbols-outlined text-[14px]","aria-hidden":"true",children:"close"})})]})})}),l.hasLanguageDropdown&&(0,s.jsx)(S,{label:"Language",htmlFor:"tts-example-language",children:(0,s.jsx)("select",{id:"tts-example-language",value:o,onChange:t=>{let a=(0,v.KC)(e).filter(e=>"tts"===(0,v.CP)(e)).find(e=>e.id===t.target.value);d(t.target.value),u(a?.name||t.target.value)},className:"w-full px-3 py-1.5 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary",children:(0,v.KC)(e).filter(e=>"tts"===(0,v.CP)(e)).map(e=>(0,s.jsx)("option",{value:e.id,children:e.name||e.id},e.id))})}),(0,s.jsx)(S,{label:"Input",htmlFor:"tts-example-input",children:(0,s.jsxs)("div",{className:"relative",children:[(0,s.jsx)("input",{id:"tts-example-input",value:N,onChange:e=>k(e.target.value),className:"w-full px-3 py-1.5 pr-7 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary"}),N&&(0,s.jsx)("button",{type:"button",onClick:()=>k(""),"aria-label":"Clear input",className:"absolute right-2 top-1/2 -translate-y-1/2 text-text-muted hover:text-primary transition-colors",children:(0,s.jsx)("span",{className:"material-symbols-outlined text-[14px]","aria-hidden":"true",children:"close"})})]})}),(0,s.jsx)(S,{label:"Output Format",htmlFor:"tts-example-format",children:(0,s.jsxs)("select",{id:"tts-example-format",value:_,onChange:e=>O(e.target.value),className:"w-full px-3 py-1.5 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary",children:[(0,s.jsx)("option",{value:"mp3",children:"MP3 (Binary)"}),(0,s.jsx)("option",{value:"json",children:"JSON (Base64)"})]})}),(0,s.jsxs)("div",{className:"mt-1",children:[(0,s.jsxs)("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between mb-1.5",children:[(0,s.jsx)("span",{className:"text-xs font-semibold text-text-muted uppercase tracking-wider",children:"Request"}),(0,s.jsxs)("div",{className:"flex w-full flex-col gap-2 sm:w-auto sm:flex-row sm:items-center",children:[(0,s.jsxs)("button",{onClick:()=>W(ex),className:"inline-flex items-center gap-1 text-xs text-text-muted hover:text-primary transition-colors",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:H?"check":"content_copy"}),H?"Copied":"Copy"]}),(0,s.jsxs)("button",{onClick:eh,disabled:D||!N.trim()||!eu||!C.trim(),className:"flex w-full sm:w-auto items-center justify-center gap-1.5 px-3 py-1 rounded-lg bg-primary text-on-primary text-xs font-medium hover:bg-primary/90 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-[14px]",style:D?{animation:"spin 1s linear infinite"}:void 0,children:"play_arrow"}),D?"Generating...":"Run"]})]})]}),(0,s.jsx)("pre",{className:"bg-sidebar rounded-lg px-3 py-2.5 text-xs font-mono text-text-main overflow-x-auto whitespace-pre-wrap break-all",children:ex})]}),q&&(0,s.jsx)("p",{role:"alert",className:"text-xs text-red-500 break-words",children:q}),M?(0,s.jsxs)("div",{children:[(0,s.jsxs)("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between mb-1.5",children:[(0,s.jsxs)("span",{className:"text-xs font-semibold text-text-muted uppercase tracking-wider",children:["Response ",J&&(0,s.jsxs)("span",{className:"font-normal normal-case",children:["⚡ ",J,"ms"]})]}),(0,s.jsxs)("a",{href:M,download:"speech.mp3",className:"inline-flex items-center gap-1 text-xs text-text-muted hover:text-primary transition-colors",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"download"}),"Download"]})]}),(0,s.jsx)("audio",{controls:!0,src:M,className:"w-full"}),K&&(0,s.jsxs)("div",{className:"mt-3",children:[(0,s.jsx)("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between mb-1.5",children:(0,s.jsx)("span",{className:"text-xs font-semibold text-text-muted uppercase tracking-wider",children:"JSON Response"})}),(0,s.jsx)("pre",{className:"bg-sidebar rounded-lg px-3 py-2.5 text-xs font-mono text-text-main overflow-x-auto whitespace-pre-wrap break-all",children:JSON.stringify({format:K.format,audio:K.audio?`${K.audio.substring(0,100)}...`:""},null,2)})]})]}):(0,s.jsxs)("div",{children:[(0,s.jsx)("span",{className:"text-xs font-semibold text-text-muted uppercase tracking-wider",children:"Response"}),(0,s.jsx)("pre",{className:"mt-1.5 bg-sidebar rounded-lg px-3 py-2.5 text-xs font-mono text-text-main overflow-x-auto whitespace-pre-wrap break-all opacity-50",children:P})]})]})]}),G&&(0,s.jsx)("div",{className:"fixed inset-0 z-50 flex items-end justify-center sm:items-center",style:{backgroundColor:"rgba(0,0,0,0.6)",backdropFilter:"blur(2px)"},onClick:()=>Y(!1),onKeyDown:e=>{"Escape"===e.key&&Y(!1)},children:(0,s.jsxs)("div",{role:"dialog","aria-modal":"true","aria-labelledby":"tts-language-modal-title",className:"border border-border rounded-xl shadow-2xl w-full max-w-md mx-4 flex flex-col max-h-[80vh]",style:{backgroundColor:"var(--color-bg)",isolation:"isolate"},onClick:e=>e.stopPropagation(),children:[(0,s.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border shrink-0 rounded-t-xl",children:[(0,s.jsx)("h3",{id:"tts-language-modal-title",className:"text-sm font-semibold","data-i18n":"Select Language",children:"Select Language"}),(0,s.jsx)("button",{onClick:()=>Y(!1),"aria-label":"Close language picker",className:"text-text-muted hover:text-primary transition-colors",children:(0,s.jsx)("span",{className:"material-symbols-outlined text-[20px]","aria-hidden":"true",children:"close"})})]}),(0,s.jsx)("div",{className:"px-4 py-2.5 border-b border-border shrink-0",children:(0,s.jsx)("input",{autoFocus:!0,type:"text","aria-label":"Search language",value:et,onChange:e=>ea(e.target.value),placeholder:"Search language...","data-i18n-placeholder":"Search language...",className:"w-full px-3 py-1.5 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary"})}),(0,s.jsxs)("div",{className:"overflow-y-auto flex-1 p-2",children:[es&&(0,s.jsx)("p",{className:"text-xs text-red-500 px-2 py-1",children:es}),X?(0,s.jsx)("p",{className:"text-xs text-text-muted px-2 py-3",children:"Loading..."}):(0,s.jsxs)("div",{className:"flex flex-col gap-0.5",children:[ec.map(e=>(0,s.jsxs)("button",{onClick:()=>{let t;return Y(!1),g(e.code),void(b(t=el[e.code]?.voices||[]),t.length&&(d(t[0].id),u(t[0].name),l.hasVoiceIdInput&&x(t[0].id)))},className:`flex items-center justify-between w-full px-3 py-2 rounded-lg text-left hover:bg-sidebar transition-colors ${f===e.code?"bg-primary/10 text-primary":""}`,children:[(0,s.jsx)("span",{className:"text-sm",children:e.name}),(0,s.jsxs)("div",{className:"flex items-center gap-2 shrink-0",children:[(0,s.jsxs)("span",{className:"text-xs text-text-muted",children:[e.voices.length," voices"]}),f===e.code&&(0,s.jsx)("span",{className:"material-symbols-outlined text-[16px] text-primary",children:"check"})]})]},e.code)),0===ec.length&&(0,s.jsx)("p",{className:"text-xs text-text-muted px-2 py-3",children:"No languages found."})]})]})]})})]})}var _=a(5772);let O="https://pub-1fb693cb11cc46b2b2f656f51e015a2c.r2.dev/dog.png";function M(e){let t="string"==typeof e?e.trim():"";return t?/^(data:image\/|https?:\/\/)/i.test(t)?t:`data:image/png;base64,${t}`:""}function L({providerId:e,kind:t}){let a=(0,c.wG)(e),r=(0,c.rs)(a)===e?a:e,l=c.rj.find(e=>e.id===t),o=$[t],d=o||{},m=(0,v.KC)(e).filter(e=>(0,v.CP)(e)===t),u=new Set(["image","video","music","imageToText"]).has(t),p=u&&0===m.length,[x,h]=(0,i.useState)(m[0]?.id??""),b=m.find(e=>e.id===x),f=!!b?.capabilities?.includes("edit"),g=!!b?.capabilities?.includes("mask"),[y,w]=(0,i.useState)(d.defaultInput||""),[N,k]=(0,i.useState)(""),[C,F]=(0,i.useState)(""),[E,A]=(0,i.useState)(()=>(d.extraFields||[]).reduce((e,t)=>(e[t.key]=t.default??"",e),{})),[T,R]=(0,i.useState)(""),[P,I]=(0,i.useState)(""),[K,B]=(0,i.useState)(null),[D,U]=(0,i.useState)(null),[q,z]=(0,i.useState)(null),[J,V]=(0,i.useState)("json"),[H,W]=(0,i.useState)(""),[G,Y]=(0,i.useState)(!1),[Z,Q]=(0,i.useState)(""),[X,ee]=(0,i.useState)([]),[et,ea]=(0,i.useState)(""),{copied:es,copy:er}=(0,j.C)(),{copied:el,copy:eo}=(0,j.C)();if((0,i.useEffect)(()=>{I(window.location.origin),fetch("/api/providers/client").then(e=>e.json()).then(t=>{ee((t.connections||[]).filter(t=>t.provider===e&&!1!==t.isActive))}).catch(()=>{})},[e]),!l||!o)return null;let ei=l.endpoint.path,en=u?x?`${r}/${x}`:p?"":r:r,ed="cloudflare-ai"!==e?{}:"@cf/runwayml/stable-diffusion-v1-5-img2img"===x?{image:O}:"@cf/runwayml/stable-diffusion-v1-5-inpainting"===x?{image:O,mask_image:"https://pub-1fb693cb11cc46b2b2f656f51e015a2c.r2.dev/dog-mask.png"}:{},ec=N.trim()||ed.image||"",em=C.trim()||ed.mask_image||"",eu=M(ec),ep=M(em),ex=Object.entries(E).reduce((e,[t,a])=>(""===a||null==a||"number"==typeof a&&Number.isNaN(a)||(e[t]=a),e),{}),eh={model:en,[o.bodyKey]:y,...o.extraBody,...ex,...f&&ec?{image:ec}:{},...g&&em?{mask_image:em}:{}},eb="image"===t&&"binary"===J,ef="image"===t&&"codex"===e&&!eb,eg=`${ei}${eb?"?response_format=binary":""}`,ey=`-H "Content-Type: application/json" \\
46
+ -H "Authorization: Bearer ${T||"YOUR_KEY"}"${et?` \\
47
+ -H "x-connection-id: ${et}"`:""}${ef?` \\
48
+ -H "Accept: text/event-stream"`:""}`,ev=`curl -X ${l.endpoint.method} ${P}${eg} \\
49
49
  ${ey.replace(/\\\n /g,"\\\n ")} \\
50
- -d '${JSON.stringify(eh)}'${eb?" \\\n --output image.png":""}`,ej=async()=>{if(!y.trim()||!en||!A.trim())return;if(Y(!0),Q(""),B(null),U(null),z(null),H){try{URL.revokeObjectURL(H)}catch{}W("")}let e=Date.now();try{let t={"Content-Type":"application/json"};A&&(t.Authorization=`Bearer ${A}`),et&&(t["x-connection-id"]=et),eg&&(t.Accept="text/event-stream");let a={...eh,model:en},s=await fetch(`/api${ef}`,{method:l.endpoint.method,headers:t,body:JSON.stringify(a)});if(!s.ok){let e=await s.json().catch(()=>({}));Q(e?.error?.message||e?.error||`HTTP ${s.status}`);return}let r=s.headers.get("content-type")||"";if(r.startsWith("image/")){let t=await s.blob(),a=URL.createObjectURL(t);W(a),B({data:{binary:!0,mime:r,size:t.size},latencyMs:Date.now()-e});return}if(r.includes("text/event-stream")&&s.body){let t=s.body.getReader(),a=new TextDecoder,r="",l=null,o=null;for(;;){let e,{done:s,value:i}=await t.read();if(s)break;for(r+=a.decode(i,{stream:!0});-1!==(e=r.indexOf("\n\n"));){let t=r.slice(0,e);r=r.slice(e+2);let a=null,s="";for(let e of t.split("\n"))e.startsWith("event:")?a=e.slice(6).trim():e.startsWith("data:")&&(s+=e.slice(5).trim());if(a)try{let e=s?JSON.parse(s):{};"progress"===a?U(e):"partial_image"===a?z(e):"done"===a?l=e:"error"===a&&(o=e?.message||"Stream error")}catch{}}}let i=Date.now()-e;if(o)return void Q(o);l&&B({data:l,latencyMs:i})}else{let t=await s.json(),a=Date.now()-e;B({data:t,latencyMs:a})}}catch(e){Q(e.message||"Network error")}finally{Y(!1)}},ew=e=>{if(!e||"object"!=typeof e)return e;if(Array.isArray(e))return e.map(ew);let t={};for(let[a,s]of Object.entries(e))t[a]="b64_json"===a&&"string"==typeof s&&s.length>100?`<${s.length} chars base64>`:ew(s);return t},eN=K?JSON.stringify(ew(K.data),null,2):"";return(0,s.jsxs)(n.Zp,{children:[(0,s.jsx)("h2",{className:"text-lg font-semibold mb-4",children:"Example"}),(0,s.jsxs)("div",{className:"flex flex-col gap-2.5",children:[m.length>0?(0,s.jsx)(S,{label:"Model",htmlFor:"generic-example-model",children:(0,s.jsx)("select",{id:"generic-example-model",value:x,onChange:e=>h(e.target.value),className:"w-full px-3 py-1.5 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary",children:m.map(e=>(0,s.jsx)("option",{value:e.id,children:e.name||e.id},e.id))})}):p?(0,s.jsx)(S,{label:"Model",htmlFor:"generic-example-model",children:(0,s.jsx)("input",{id:"generic-example-model",value:x,onChange:e=>h(e.target.value),placeholder:"Enter model id (provider-specific)",className:"w-full px-3 py-1.5 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary font-mono"})}):null,(0,s.jsx)(S,{label:"Endpoint",children:(0,s.jsx)("div",{className:"flex w-full flex-col gap-2 sm:w-auto sm:flex-row sm:items-center",children:(0,s.jsxs)("span",{className:"w-full min-w-0 flex-1 px-3 py-1.5 text-sm font-mono text-text-main bg-sidebar rounded-lg truncate",children:[P,ei]})})}),(0,s.jsx)(S,{label:"API Key",htmlFor:"generic-example-key",children:(0,s.jsx)("input",{id:"generic-example-key",type:"password",autoComplete:"off",value:A,onChange:e=>R(e.target.value),placeholder:"Paste a Switchboard client key secret (sk-...)",className:"w-full px-3 py-1.5 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary font-mono"})}),X.length>0&&(0,s.jsx)(S,{label:"Connection",htmlFor:"generic-example-connection",children:(0,s.jsxs)("select",{id:"generic-example-connection",value:et,onChange:e=>ea(e.target.value),className:"w-full px-3 py-1.5 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary",children:[(0,s.jsx)("option",{value:"",children:"Auto (by priority)"}),X.map(e=>{let t=e.providerSpecificData?.chatgptPlanType,a=e.email||e.name||e.id.slice(0,8);return(0,s.jsxs)("option",{value:e.id,children:[a,t?` [${t}]`:""]},e.id)})]})}),(0,s.jsx)(S,{label:o.inputLabel,htmlFor:"generic-example-input",children:(0,s.jsxs)("div",{className:"relative",children:[(0,s.jsx)("input",{id:"generic-example-input",value:y,onChange:e=>w(e.target.value),placeholder:o.inputPlaceholder,className:"w-full px-3 py-1.5 pr-7 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary"}),y&&(0,s.jsx)("button",{type:"button",onClick:()=>w(""),"aria-label":`Clear ${o.inputLabel.toLowerCase()}`,className:"absolute right-2 top-1/2 -translate-y-1/2 text-text-muted hover:text-primary transition-colors",children:(0,s.jsx)("span",{className:"material-symbols-outlined text-[14px]","aria-hidden":"true",children:"close"})})]})}),g&&(0,s.jsx)(S,{label:"Ref Image (URL)",htmlFor:"generic-example-ref-image",children:(0,s.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,s.jsxs)("div",{className:"relative",children:[(0,s.jsx)("input",{id:"generic-example-ref-image",value:N,onChange:e=>k(e.target.value),placeholder:ed.image||"https://example.com/source.png",className:"w-full px-3 py-1.5 pr-7 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary"}),N&&(0,s.jsx)("button",{type:"button",onClick:()=>k(""),"aria-label":"Clear reference image URL",className:"absolute right-2 top-1/2 -translate-y-1/2 text-text-muted hover:text-primary transition-colors",children:(0,s.jsx)("span",{className:"material-symbols-outlined text-[14px]","aria-hidden":"true",children:"close"})})]}),eu&&(0,s.jsx)(_.default,{src:eu,alt:"Reference",width:640,height:320,unoptimized:!0,className:"max-h-40 rounded-lg border border-border object-contain bg-sidebar",onError:e=>{e.currentTarget.style.display="none"},onLoad:e=>{e.currentTarget.style.display="block"}})]})}),f&&(0,s.jsx)(S,{label:"Mask (URL)",htmlFor:"generic-example-mask",children:(0,s.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,s.jsxs)("div",{className:"relative",children:[(0,s.jsx)("input",{id:"generic-example-mask",value:C,onChange:e=>F(e.target.value),placeholder:ed.mask_image||"https://example.com/mask.png",className:"w-full px-3 py-1.5 pr-7 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary"}),C&&(0,s.jsx)("button",{type:"button",onClick:()=>F(""),"aria-label":"Clear mask image URL",className:"absolute right-2 top-1/2 -translate-y-1/2 text-text-muted hover:text-primary transition-colors",children:(0,s.jsx)("span",{className:"material-symbols-outlined text-[14px]","aria-hidden":"true",children:"close"})})]}),ep&&(0,s.jsx)(_.default,{src:ep,alt:"Mask",width:640,height:320,unoptimized:!0,className:"max-h-40 rounded-lg border border-border object-contain bg-sidebar",onError:e=>{e.currentTarget.style.display="none"},onLoad:e=>{e.currentTarget.style.display="block"}})]})}),(o.extraFields||[]).filter(e=>0===m.length||Array.isArray(b?.params)&&b.params.includes(e.key)).map(e=>(0,s.jsx)(S,{label:e.label,htmlFor:`generic-example-${e.key}`,children:"select"===e.type?(0,s.jsx)("select",{id:`generic-example-${e.key}`,value:E[e.key]??"",onChange:t=>T(a=>({...a,[e.key]:t.target.value})),className:"w-full px-3 py-1.5 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary",children:(e.options||[]).map(e=>(0,s.jsx)("option",{value:e,children:""===e?"(default)":e},e))}):"text"===e.type?(0,s.jsx)("input",{id:`generic-example-${e.key}`,type:"text",value:E[e.key]??"",placeholder:e.placeholder,onChange:t=>T(a=>({...a,[e.key]:t.target.value})),className:"w-full px-3 py-1.5 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary"}):(0,s.jsx)("input",{id:`generic-example-${e.key}`,type:"number",value:E[e.key]??"",min:e.min,max:e.max,onChange:t=>T(a=>({...a,[e.key]:""===t.target.value?"":Number(t.target.value)})),className:"w-full px-3 py-1.5 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary"})},e.key)),"image"===t&&(0,s.jsx)(S,{label:"Output Format",htmlFor:"generic-example-output-format",children:(0,s.jsxs)("select",{id:"generic-example-output-format",value:J,onChange:e=>V(e.target.value),className:"w-full px-3 py-1.5 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary",children:[(0,s.jsx)("option",{value:"json",children:"JSON (Base64)"}),(0,s.jsx)("option",{value:"binary",children:"Binary File"})]})}),(0,s.jsxs)("div",{className:"mt-1",children:[(0,s.jsxs)("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between mb-1.5",children:[(0,s.jsx)("span",{className:"text-xs font-semibold text-text-muted uppercase tracking-wider",children:"Request"}),(0,s.jsxs)("div",{className:"flex w-full flex-col gap-2 sm:w-auto sm:flex-row sm:items-center",children:[(0,s.jsxs)("button",{onClick:()=>er(ev),className:"inline-flex items-center gap-1 text-xs text-text-muted hover:text-primary transition-colors",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:es?"check":"content_copy"}),es?"Copied":"Copy"]}),(0,s.jsxs)("button",{onClick:ej,disabled:G||!y.trim()||!en||!A.trim(),className:"flex w-full sm:w-auto items-center justify-center gap-1.5 px-3 py-1 rounded-lg bg-primary text-on-primary text-xs font-medium hover:bg-primary/90 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-[14px]",style:G?{animation:"spin 1s linear infinite"}:void 0,children:"play_arrow"}),G?"Running...":"Run"]})]})]}),(0,s.jsx)("pre",{className:"bg-sidebar rounded-lg px-3 py-2.5 text-xs font-mono text-text-main overflow-x-auto whitespace-pre-wrap break-all",children:ev})]}),(G||D)&&eg&&(0,s.jsxs)("div",{className:"flex flex-col gap-2 px-3 py-2 rounded-lg bg-sidebar border border-border sm:flex-row sm:items-center sm:gap-3",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-[16px] text-primary",style:G?{animation:"spin 1s linear infinite"}:void 0,children:G?"progress_activity":"check_circle"}),(0,s.jsxs)("span",{className:"text-xs text-text-muted",children:[D?.stage||"starting",!G&&D?.bytesReceived?` \xb7 ${(D.bytesReceived/1024).toFixed(1)} KB`:""]})]}),q?.b64_json&&!K&&(0,s.jsxs)("div",{children:[(0,s.jsx)("span",{className:"text-xs font-semibold text-text-muted uppercase tracking-wider",children:"Partial preview"}),(0,s.jsx)(_.default,{src:`data:image/png;base64,${q.b64_json}`,alt:"Partial",width:1024,height:1024,unoptimized:!0,className:"max-w-full rounded-lg border border-border mt-1.5 opacity-80"})]}),Z&&(0,s.jsx)("p",{role:"alert",className:"text-xs text-red-500 break-words",children:Z}),(0,s.jsxs)("div",{children:[(0,s.jsxs)("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between mb-1.5",children:[(0,s.jsxs)("span",{className:"text-xs font-semibold text-text-muted uppercase tracking-wider",children:["Response ",K&&(0,s.jsxs)("span",{className:"font-normal normal-case",children:["⚡ ",K.latencyMs,"ms"]})]}),K&&(0,s.jsxs)("button",{onClick:()=>eo(eN),className:"inline-flex items-center gap-1 text-xs text-text-muted hover:text-primary transition-colors",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:el?"check":"content_copy"}),el?"Copied":"Copy"]})]}),(0,s.jsx)("pre",{className:"bg-sidebar rounded-lg px-3 py-2.5 text-xs font-mono text-text-main overflow-x-auto whitespace-pre-wrap break-all opacity-70",children:K?eN:o.defaultResponse}),"image"===t&&(H||K?.data?.data?.[0])&&(0,s.jsxs)("div",{className:"mt-2",children:[(0,s.jsx)("div",{className:"flex items-center justify-end mb-1.5",children:(0,s.jsxs)("a",{href:H||(K?.data?.data?.[0]?.b64_json?`data:image/png;base64,${K.data.data[0].b64_json}`:K?.data?.data?.[0]?.url||""),download:"image.png",className:"inline-flex items-center gap-1 text-xs text-text-muted hover:text-primary transition-colors",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"download"}),"Download"]})}),(0,s.jsx)(_.default,{src:H||(K?.data?.data?.[0]?.b64_json?`data:image/png;base64,${K.data.data[0].b64_json}`:K?.data?.data?.[0]?.url),alt:"Generated",width:1024,height:1024,unoptimized:!0,className:"max-w-full rounded-lg border border-border"})]})]})]})]})}function K({providerId:e}){let t=(0,c.wG)(e),a=(0,v.KC)(e).filter(e=>"stt"===(0,v.CP)(e)),[r,l]=(0,i.useState)([]),o=[...a,...r],[d,m]=(0,i.useState)(a[0]?.id??""),u=o.find(e=>e.id===d),p=Array.isArray(u?.params)?u.params:[],[x,h]=(0,i.useState)(null),[b,g]=(0,i.useState)(""),[f,y]=(0,i.useState)(""),[w,N]=(0,i.useState)("json"),[k,C]=(0,i.useState)(""),[$,F]=(0,i.useState)(""),[E,T]=(0,i.useState)(""),[A,R]=(0,i.useState)(null),[P,I]=(0,i.useState)(null),[_,M]=(0,i.useState)(!1),[O,L]=(0,i.useState)(""),{copied:B,copy:D}=(0,j.C)(),{copied:U,copy:q}=(0,j.C)();(0,i.useEffect)(()=>{T(window.location.origin);let e=()=>{fetch("/api/models/custom",{cache:"no-store"}).then(e=>e.json()).then(e=>{l((e.models||[]).filter(e=>"stt"===(0,v.CP)(e)&&e.providerAlias===t))}).catch(()=>{})};return e(),window.addEventListener("focus",e),window.addEventListener("customModelChanged",e),()=>{window.removeEventListener("focus",e),window.removeEventListener("customModelChanged",e)}},[t]);let z=d?`${t}/${d}`:"",J=`curl -X POST ${E}/v1/audio/transcriptions \\
50
+ -d '${JSON.stringify(eh)}'${eb?" \\\n --output image.png":""}`,ej=async()=>{if(!y.trim()||!en||!T.trim())return;if(Y(!0),Q(""),B(null),U(null),z(null),H){try{URL.revokeObjectURL(H)}catch{}W("")}let e=Date.now();try{let t={"Content-Type":"application/json"};T&&(t.Authorization=`Bearer ${T}`),et&&(t["x-connection-id"]=et),ef&&(t.Accept="text/event-stream");let a={...eh,model:en},s=await fetch(`/api${eg}`,{method:l.endpoint.method,headers:t,body:JSON.stringify(a)});if(!s.ok){let e=await s.json().catch(()=>({}));Q(e?.error?.message||e?.error||`HTTP ${s.status}`);return}let r=s.headers.get("content-type")||"";if(r.startsWith("image/")){let t=await s.blob(),a=URL.createObjectURL(t);W(a),B({data:{binary:!0,mime:r,size:t.size},latencyMs:Date.now()-e});return}if(r.includes("text/event-stream")&&s.body){let t=s.body.getReader(),a=new TextDecoder,r="",l=null,o=null;for(;;){let e,{done:s,value:i}=await t.read();if(s)break;for(r+=a.decode(i,{stream:!0});-1!==(e=r.indexOf("\n\n"));){let t=r.slice(0,e);r=r.slice(e+2);let a=null,s="";for(let e of t.split("\n"))e.startsWith("event:")?a=e.slice(6).trim():e.startsWith("data:")&&(s+=e.slice(5).trim());if(a)try{let e=s?JSON.parse(s):{};"progress"===a?U(e):"partial_image"===a?z(e):"done"===a?l=e:"error"===a&&(o=e?.message||"Stream error")}catch{}}}let i=Date.now()-e;if(o)return void Q(o);l&&B({data:l,latencyMs:i})}else{let t=await s.json(),a=Date.now()-e;B({data:t,latencyMs:a})}}catch(e){Q(e.message||"Network error")}finally{Y(!1)}},ew=e=>{if(!e||"object"!=typeof e)return e;if(Array.isArray(e))return e.map(ew);let t={};for(let[a,s]of Object.entries(e))t[a]="b64_json"===a&&"string"==typeof s&&s.length>100?`<${s.length} chars base64>`:ew(s);return t},eN=K?JSON.stringify(ew(K.data),null,2):"";return(0,s.jsxs)(n.Zp,{children:[(0,s.jsx)("h2",{className:"text-lg font-semibold mb-4",children:"Example"}),(0,s.jsxs)("div",{className:"flex flex-col gap-2.5",children:[m.length>0?(0,s.jsx)(S,{label:"Model",htmlFor:"generic-example-model",children:(0,s.jsx)("select",{id:"generic-example-model",value:x,onChange:e=>h(e.target.value),className:"w-full px-3 py-1.5 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary",children:m.map(e=>(0,s.jsx)("option",{value:e.id,children:e.name||e.id},e.id))})}):p?(0,s.jsx)(S,{label:"Model",htmlFor:"generic-example-model",children:(0,s.jsx)("input",{id:"generic-example-model",value:x,onChange:e=>h(e.target.value),placeholder:"Enter model id (provider-specific)",className:"w-full px-3 py-1.5 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary font-mono"})}):null,(0,s.jsx)(S,{label:"Endpoint",children:(0,s.jsx)("div",{className:"flex w-full flex-col gap-2 sm:w-auto sm:flex-row sm:items-center",children:(0,s.jsxs)("span",{className:"w-full min-w-0 flex-1 px-3 py-1.5 text-sm font-mono text-text-main bg-sidebar rounded-lg truncate",children:[P,ei]})})}),(0,s.jsx)(S,{label:"API Key",htmlFor:"generic-example-key",children:(0,s.jsx)("input",{id:"generic-example-key",type:"password",autoComplete:"off",value:T,onChange:e=>R(e.target.value),placeholder:"Paste a Switchboard client key secret (sk-...)",className:"w-full px-3 py-1.5 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary font-mono"})}),X.length>0&&(0,s.jsx)(S,{label:"Connection",htmlFor:"generic-example-connection",children:(0,s.jsxs)("select",{id:"generic-example-connection",value:et,onChange:e=>ea(e.target.value),className:"w-full px-3 py-1.5 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary",children:[(0,s.jsx)("option",{value:"",children:"Auto (by priority)"}),X.map(e=>{let t=e.providerSpecificData?.chatgptPlanType,a=e.email||e.name||e.id.slice(0,8);return(0,s.jsxs)("option",{value:e.id,children:[a,t?` [${t}]`:""]},e.id)})]})}),(0,s.jsx)(S,{label:o.inputLabel,htmlFor:"generic-example-input",children:(0,s.jsxs)("div",{className:"relative",children:[(0,s.jsx)("input",{id:"generic-example-input",value:y,onChange:e=>w(e.target.value),placeholder:o.inputPlaceholder,className:"w-full px-3 py-1.5 pr-7 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary"}),y&&(0,s.jsx)("button",{type:"button",onClick:()=>w(""),"aria-label":`Clear ${o.inputLabel.toLowerCase()}`,className:"absolute right-2 top-1/2 -translate-y-1/2 text-text-muted hover:text-primary transition-colors",children:(0,s.jsx)("span",{className:"material-symbols-outlined text-[14px]","aria-hidden":"true",children:"close"})})]})}),f&&(0,s.jsx)(S,{label:"Ref Image (URL)",htmlFor:"generic-example-ref-image",children:(0,s.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,s.jsxs)("div",{className:"relative",children:[(0,s.jsx)("input",{id:"generic-example-ref-image",value:N,onChange:e=>k(e.target.value),placeholder:ed.image||"https://example.com/source.png",className:"w-full px-3 py-1.5 pr-7 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary"}),N&&(0,s.jsx)("button",{type:"button",onClick:()=>k(""),"aria-label":"Clear reference image URL",className:"absolute right-2 top-1/2 -translate-y-1/2 text-text-muted hover:text-primary transition-colors",children:(0,s.jsx)("span",{className:"material-symbols-outlined text-[14px]","aria-hidden":"true",children:"close"})})]}),eu&&(0,s.jsx)(_.default,{src:eu,alt:"Reference",width:640,height:320,unoptimized:!0,className:"max-h-40 rounded-lg border border-border object-contain bg-sidebar",onError:e=>{e.currentTarget.style.display="none"},onLoad:e=>{e.currentTarget.style.display="block"}})]})}),g&&(0,s.jsx)(S,{label:"Mask (URL)",htmlFor:"generic-example-mask",children:(0,s.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,s.jsxs)("div",{className:"relative",children:[(0,s.jsx)("input",{id:"generic-example-mask",value:C,onChange:e=>F(e.target.value),placeholder:ed.mask_image||"https://example.com/mask.png",className:"w-full px-3 py-1.5 pr-7 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary"}),C&&(0,s.jsx)("button",{type:"button",onClick:()=>F(""),"aria-label":"Clear mask image URL",className:"absolute right-2 top-1/2 -translate-y-1/2 text-text-muted hover:text-primary transition-colors",children:(0,s.jsx)("span",{className:"material-symbols-outlined text-[14px]","aria-hidden":"true",children:"close"})})]}),ep&&(0,s.jsx)(_.default,{src:ep,alt:"Mask",width:640,height:320,unoptimized:!0,className:"max-h-40 rounded-lg border border-border object-contain bg-sidebar",onError:e=>{e.currentTarget.style.display="none"},onLoad:e=>{e.currentTarget.style.display="block"}})]})}),(o.extraFields||[]).filter(e=>0===m.length||Array.isArray(b?.params)&&b.params.includes(e.key)).map(e=>(0,s.jsx)(S,{label:e.label,htmlFor:`generic-example-${e.key}`,children:"select"===e.type?(0,s.jsx)("select",{id:`generic-example-${e.key}`,value:E[e.key]??"",onChange:t=>A(a=>({...a,[e.key]:t.target.value})),className:"w-full px-3 py-1.5 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary",children:(e.options||[]).map(e=>(0,s.jsx)("option",{value:e,children:""===e?"(default)":e},e))}):"text"===e.type?(0,s.jsx)("input",{id:`generic-example-${e.key}`,type:"text",value:E[e.key]??"",placeholder:e.placeholder,onChange:t=>A(a=>({...a,[e.key]:t.target.value})),className:"w-full px-3 py-1.5 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary"}):(0,s.jsx)("input",{id:`generic-example-${e.key}`,type:"number",value:E[e.key]??"",min:e.min,max:e.max,onChange:t=>A(a=>({...a,[e.key]:""===t.target.value?"":Number(t.target.value)})),className:"w-full px-3 py-1.5 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary"})},e.key)),"image"===t&&(0,s.jsx)(S,{label:"Output Format",htmlFor:"generic-example-output-format",children:(0,s.jsxs)("select",{id:"generic-example-output-format",value:J,onChange:e=>V(e.target.value),className:"w-full px-3 py-1.5 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary",children:[(0,s.jsx)("option",{value:"json",children:"JSON (Base64)"}),(0,s.jsx)("option",{value:"binary",children:"Binary File"})]})}),(0,s.jsxs)("div",{className:"mt-1",children:[(0,s.jsxs)("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between mb-1.5",children:[(0,s.jsx)("span",{className:"text-xs font-semibold text-text-muted uppercase tracking-wider",children:"Request"}),(0,s.jsxs)("div",{className:"flex w-full flex-col gap-2 sm:w-auto sm:flex-row sm:items-center",children:[(0,s.jsxs)("button",{onClick:()=>er(ev),className:"inline-flex items-center gap-1 text-xs text-text-muted hover:text-primary transition-colors",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:es?"check":"content_copy"}),es?"Copied":"Copy"]}),(0,s.jsxs)("button",{onClick:ej,disabled:G||!y.trim()||!en||!T.trim(),className:"flex w-full sm:w-auto items-center justify-center gap-1.5 px-3 py-1 rounded-lg bg-primary text-on-primary text-xs font-medium hover:bg-primary/90 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-[14px]",style:G?{animation:"spin 1s linear infinite"}:void 0,children:"play_arrow"}),G?"Running...":"Run"]})]})]}),(0,s.jsx)("pre",{className:"bg-sidebar rounded-lg px-3 py-2.5 text-xs font-mono text-text-main overflow-x-auto whitespace-pre-wrap break-all",children:ev})]}),(G||D)&&ef&&(0,s.jsxs)("div",{className:"flex flex-col gap-2 px-3 py-2 rounded-lg bg-sidebar border border-border sm:flex-row sm:items-center sm:gap-3",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-[16px] text-primary",style:G?{animation:"spin 1s linear infinite"}:void 0,children:G?"progress_activity":"check_circle"}),(0,s.jsxs)("span",{className:"text-xs text-text-muted",children:[D?.stage||"starting",!G&&D?.bytesReceived?` \xb7 ${(D.bytesReceived/1024).toFixed(1)} KB`:""]})]}),q?.b64_json&&!K&&(0,s.jsxs)("div",{children:[(0,s.jsx)("span",{className:"text-xs font-semibold text-text-muted uppercase tracking-wider",children:"Partial preview"}),(0,s.jsx)(_.default,{src:`data:image/png;base64,${q.b64_json}`,alt:"Partial",width:1024,height:1024,unoptimized:!0,className:"max-w-full rounded-lg border border-border mt-1.5 opacity-80"})]}),Z&&(0,s.jsx)("p",{role:"alert",className:"text-xs text-red-500 break-words",children:Z}),(0,s.jsxs)("div",{children:[(0,s.jsxs)("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between mb-1.5",children:[(0,s.jsxs)("span",{className:"text-xs font-semibold text-text-muted uppercase tracking-wider",children:["Response ",K&&(0,s.jsxs)("span",{className:"font-normal normal-case",children:["⚡ ",K.latencyMs,"ms"]})]}),K&&(0,s.jsxs)("button",{onClick:()=>eo(eN),className:"inline-flex items-center gap-1 text-xs text-text-muted hover:text-primary transition-colors",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:el?"check":"content_copy"}),el?"Copied":"Copy"]})]}),(0,s.jsx)("pre",{className:"bg-sidebar rounded-lg px-3 py-2.5 text-xs font-mono text-text-main overflow-x-auto whitespace-pre-wrap break-all opacity-70",children:K?eN:o.defaultResponse}),"image"===t&&(H||K?.data?.data?.[0])&&(0,s.jsxs)("div",{className:"mt-2",children:[(0,s.jsx)("div",{className:"flex items-center justify-end mb-1.5",children:(0,s.jsxs)("a",{href:H||(K?.data?.data?.[0]?.b64_json?`data:image/png;base64,${K.data.data[0].b64_json}`:K?.data?.data?.[0]?.url||""),download:"image.png",className:"inline-flex items-center gap-1 text-xs text-text-muted hover:text-primary transition-colors",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"download"}),"Download"]})}),(0,s.jsx)(_.default,{src:H||(K?.data?.data?.[0]?.b64_json?`data:image/png;base64,${K.data.data[0].b64_json}`:K?.data?.data?.[0]?.url),alt:"Generated",width:1024,height:1024,unoptimized:!0,className:"max-w-full rounded-lg border border-border"})]})]})]})]})}function K({providerId:e}){let t=(0,c.wG)(e),a=(0,v.KC)(e).filter(e=>"stt"===(0,v.CP)(e)),[r,l]=(0,i.useState)([]),o=[...a,...r],[d,m]=(0,i.useState)(a[0]?.id??""),u=o.find(e=>e.id===d),p=Array.isArray(u?.params)?u.params:[],[x,h]=(0,i.useState)(null),[b,f]=(0,i.useState)(""),[g,y]=(0,i.useState)(""),[w,N]=(0,i.useState)("json"),[k,C]=(0,i.useState)(""),[$,F]=(0,i.useState)(""),[E,A]=(0,i.useState)(""),[T,R]=(0,i.useState)(null),[P,I]=(0,i.useState)(null),[_,O]=(0,i.useState)(!1),[M,L]=(0,i.useState)(""),{copied:B,copy:D}=(0,j.C)(),{copied:U,copy:q}=(0,j.C)();(0,i.useEffect)(()=>{A(window.location.origin);let e=()=>{fetch("/api/models/custom",{cache:"no-store"}).then(e=>e.json()).then(e=>{l((e.models||[]).filter(e=>"stt"===(0,v.CP)(e)&&e.providerAlias===t))}).catch(()=>{})};return e(),window.addEventListener("focus",e),window.addEventListener("customModelChanged",e),()=>{window.removeEventListener("focus",e),window.removeEventListener("customModelChanged",e)}},[t]);let z=d?`${t}/${d}`:"",J=`curl -X POST ${E}/v1/audio/transcriptions \\
51
51
  -H "Authorization: Bearer ${$||"YOUR_KEY"}" \\
52
52
  -F "file=@${x?.name||"audio.mp3"}" \\
53
53
  -F "model=${z}"${p.includes("language")&&b?` \\
54
54
  -F "language=${b}"`:""}${p.includes("response_format")?` \\
55
55
  -F "response_format=${w}"`:""}${p.includes("temperature")&&k?` \\
56
- -F "temperature=${k}"`:""}${p.includes("prompt")&&f?` \\
57
- -F "prompt=${f}"`:""}`,V=async()=>{if(!x||!z||!$.trim())return;M(!0),L(""),R(null);let e=Date.now();try{let t=new FormData;t.append("file",x),t.append("model",z),p.includes("language")&&b&&t.append("language",b),p.includes("response_format")&&t.append("response_format",w),p.includes("temperature")&&k&&t.append("temperature",k),p.includes("prompt")&&f&&t.append("prompt",f);let a={};$&&(a.Authorization=`Bearer ${$}`);let s=await fetch("/api/v1/audio/transcriptions",{method:"POST",headers:a,body:t});I(Date.now()-e);let r=(s.headers.get("content-type")||"").includes("application/json")?await s.json():await s.text();if(!s.ok)return void L(r?.error?.message||r?.error||r||`HTTP ${s.status}`);R(r)}catch(e){L(e.message||"Network error")}finally{M(!1)}},H="string"==typeof A?A:A?JSON.stringify(A,null,2):`{
56
+ -F "temperature=${k}"`:""}${p.includes("prompt")&&g?` \\
57
+ -F "prompt=${g}"`:""}`,V=async()=>{if(!x||!z||!$.trim())return;O(!0),L(""),R(null);let e=Date.now();try{let t=new FormData;t.append("file",x),t.append("model",z),p.includes("language")&&b&&t.append("language",b),p.includes("response_format")&&t.append("response_format",w),p.includes("temperature")&&k&&t.append("temperature",k),p.includes("prompt")&&g&&t.append("prompt",g);let a={};$&&(a.Authorization=`Bearer ${$}`);let s=await fetch("/api/v1/audio/transcriptions",{method:"POST",headers:a,body:t});I(Date.now()-e);let r=(s.headers.get("content-type")||"").includes("application/json")?await s.json():await s.text();if(!s.ok)return void L(r?.error?.message||r?.error||r||`HTTP ${s.status}`);R(r)}catch(e){L(e.message||"Network error")}finally{O(!1)}},H="string"==typeof T?T:T?JSON.stringify(T,null,2):`{
58
58
  "text": "Hello world..."
59
- }`;return(0,s.jsxs)(n.Zp,{children:[(0,s.jsx)("h2",{className:"text-lg font-semibold mb-4",children:"Example"}),(0,s.jsxs)("div",{className:"flex flex-col gap-2.5",children:[o.length>0?(0,s.jsx)(S,{label:"Model",htmlFor:"stt-example-model",children:(0,s.jsx)("select",{id:"stt-example-model",value:d,onChange:e=>m(e.target.value),className:"w-full px-3 py-1.5 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary",children:o.map(e=>(0,s.jsx)("option",{value:e.id,children:e.name||e.id},e.id))})}):(0,s.jsx)(S,{label:"Model",htmlFor:"stt-example-model",children:(0,s.jsx)("input",{id:"stt-example-model",value:d,onChange:e=>m(e.target.value),placeholder:"Enter model id",className:"w-full px-3 py-1.5 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary font-mono"})}),(0,s.jsx)(S,{label:"Endpoint",children:(0,s.jsx)("div",{className:"flex w-full flex-col gap-2 sm:w-auto sm:flex-row sm:items-center",children:(0,s.jsxs)("span",{className:"w-full min-w-0 flex-1 px-3 py-1.5 text-sm font-mono text-text-main bg-sidebar rounded-lg truncate",children:[E,"/v1/audio/transcriptions"]})})}),(0,s.jsx)(S,{label:"API Key",htmlFor:"stt-example-key",children:(0,s.jsx)("input",{id:"stt-example-key",type:"password",autoComplete:"off",value:$,onChange:e=>F(e.target.value),placeholder:"Paste a Switchboard client key secret (sk-...)",className:"w-full px-3 py-1.5 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary font-mono"})}),(0,s.jsx)(S,{label:"Audio File",htmlFor:"stt-example-audio",children:(0,s.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,s.jsx)("input",{id:"stt-example-audio",type:"file",accept:"audio/*,video/mp4,.m4a,.mp3,.wav,.ogg,.flac,.webm,.opus",onChange:e=>h(e.target.files?.[0]||null),className:"w-full text-xs text-text-muted file:mr-2 file:py-1 file:px-2.5 file:rounded-lg file:border file:border-border file:bg-background file:text-text-main hover:file:bg-sidebar file:cursor-pointer"}),x&&(0,s.jsxs)("span",{className:"text-xs text-text-muted font-mono",children:[x.name," \xb7 ",(x.size/1024).toFixed(1)," KB"]})]})}),p.includes("language")&&(0,s.jsx)(S,{label:"Language",htmlFor:"stt-example-language",children:(0,s.jsx)("input",{id:"stt-example-language",value:b,onChange:e=>g(e.target.value),placeholder:"e.g. en, vi, ja (auto-detect if empty)",className:"w-full px-3 py-1.5 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary font-mono"})}),p.includes("prompt")&&(0,s.jsx)(S,{label:"Prompt",htmlFor:"stt-example-prompt",children:(0,s.jsx)("input",{id:"stt-example-prompt",value:f,onChange:e=>y(e.target.value),placeholder:"optional context to improve accuracy",className:"w-full px-3 py-1.5 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary"})}),p.includes("temperature")&&(0,s.jsx)(S,{label:"Temperature",htmlFor:"stt-example-temperature",children:(0,s.jsx)("input",{id:"stt-example-temperature",type:"number",step:"0.1",min:"0",max:"1",value:k,onChange:e=>C(e.target.value),placeholder:"0 - 1 (default 0)",className:"w-full px-3 py-1.5 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary"})}),p.includes("response_format")&&(0,s.jsx)(S,{label:"Response Format",htmlFor:"stt-example-format",children:(0,s.jsxs)("select",{id:"stt-example-format",value:w,onChange:e=>N(e.target.value),className:"w-full px-3 py-1.5 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary",children:[(0,s.jsx)("option",{value:"json",children:"json"}),(0,s.jsx)("option",{value:"text",children:"text"}),(0,s.jsx)("option",{value:"srt",children:"srt"}),(0,s.jsx)("option",{value:"verbose_json",children:"verbose_json"}),(0,s.jsx)("option",{value:"vtt",children:"vtt"})]})}),(0,s.jsxs)("div",{className:"mt-1",children:[(0,s.jsxs)("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between mb-1.5",children:[(0,s.jsx)("span",{className:"text-xs font-semibold text-text-muted uppercase tracking-wider",children:"Request"}),(0,s.jsxs)("div",{className:"flex w-full flex-col gap-2 sm:w-auto sm:flex-row sm:items-center",children:[(0,s.jsxs)("button",{onClick:()=>D(J),className:"inline-flex items-center gap-1 text-xs text-text-muted hover:text-primary transition-colors",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:B?"check":"content_copy"}),B?"Copied":"Copy"]}),(0,s.jsxs)("button",{onClick:V,disabled:_||!x||!z||!$.trim(),className:"flex w-full sm:w-auto items-center justify-center gap-1.5 px-3 py-1 rounded-lg bg-primary text-on-primary text-xs font-medium hover:bg-primary/90 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-[14px]",style:_?{animation:"spin 1s linear infinite"}:void 0,children:"play_arrow"}),_?"Transcribing...":"Run"]})]})]}),(0,s.jsx)("pre",{className:"bg-sidebar rounded-lg px-3 py-2.5 text-xs font-mono text-text-main overflow-x-auto whitespace-pre-wrap break-all",children:J})]}),O&&(0,s.jsx)("p",{role:"alert",className:"text-xs text-red-500 break-words",children:O}),(0,s.jsxs)("div",{children:[(0,s.jsxs)("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between mb-1.5",children:[(0,s.jsxs)("span",{className:"text-xs font-semibold text-text-muted uppercase tracking-wider",children:["Response ",A&&P&&(0,s.jsxs)("span",{className:"font-normal normal-case",children:["⚡ ",P,"ms"]})]}),A&&(0,s.jsxs)("button",{onClick:()=>q(H),className:"inline-flex items-center gap-1 text-xs text-text-muted hover:text-primary transition-colors",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:U?"check":"content_copy"}),U?"Copied":"Copy"]})]}),(0,s.jsx)("pre",{className:"bg-sidebar rounded-lg px-3 py-2.5 text-xs font-mono text-text-main overflow-x-auto whitespace-pre-wrap break-all opacity-70",children:H})]})]})]})}var B=a(77251);function D(){let{kind:e,id:t}=(0,r.useParams)(),a=(0,r.useRouter)(),l=c.rj.find(t=>t.id===e),m=(0,c.gC)(t)&&"embedding"===e,u=async()=>{if(await (0,B.l)({message:"Delete this Custom Embedding node?",confirmText:"Continue"}))try{(await fetch(`/api/provider-nodes/${t}`,{method:"DELETE"})).ok&&a.push(`/dashboard/media-providers/${e}`)}catch(e){(0,w.s)("Error deleting custom embedding node:",e)}},[p,x]=(0,i.useState)(null),[h,b]=(0,i.useState)(m),[g,f]=(0,i.useState)(!1);if((0,i.useEffect)(()=>{if(!m)return;let e=!1;return fetch("/api/provider-nodes",{cache:"no-store"}).then(e=>e.json()).then(a=>{e||(x((a.nodes||[]).find(e=>e.id===t)||null),b(!1))}).catch(()=>{e||b(!1)}),()=>{e=!0}},[t,m]),!l)return(0,r.notFound)();let v=c.Q2[t],j=m?p?{id:t,name:p.name||"Custom Embedding",color:"#6366F1",textIcon:"CE"}:null:v;if(!m&&!v||m&&!h&&!p)return(0,r.notFound)();if(m&&h)return(0,s.jsx)("div",{className:"text-text-muted text-sm py-12 text-center",children:"Loading..."});let N=m?["embedding"]:j.serviceKinds??["llm"];return m||N.includes(e)?(0,s.jsxs)("div",{className:"flex flex-col gap-8",children:[(0,s.jsxs)("div",{children:[(0,s.jsxs)(o(),{href:`/dashboard/media-providers/${e}`,className:"inline-flex items-center gap-1 text-sm text-text-muted hover:text-primary transition-colors mb-4",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-lg",children:"arrow_back"}),l.label]}),(0,s.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:gap-4",children:[(0,s.jsx)("div",{className:"size-12 rounded-lg flex items-center justify-center shrink-0",style:{backgroundColor:`${j.color}15`},children:(0,s.jsx)(d.A,{src:`/providers/${j.id}.png`,alt:j.name,size:48,className:"object-contain rounded-lg max-w-[48px] max-h-[48px]",fallbackText:j.textIcon||j.id.slice(0,2).toUpperCase(),fallbackColor:j.color})}),(0,s.jsxs)("div",{className:"flex-1",children:[(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-2 sm:gap-3",children:[(0,s.jsx)("h1",{className:"text-3xl font-semibold tracking-tight",children:j.name}),!m&&j.notice?.apiKeyUrl&&(0,s.jsxs)("a",{href:j.notice.apiKeyUrl,target:"_blank",rel:"noopener noreferrer",className:"text-xs text-primary hover:underline inline-flex items-center gap-1",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-sm",children:"open_in_new"}),"Get API Key"]})]}),(0,s.jsxs)("div",{className:"flex items-center gap-1.5 mt-1 flex-wrap",children:[m&&(0,s.jsxs)(n.Ex,{variant:"default",size:"sm",children:["Custom \xb7 ",p?.prefix]}),N.map(t=>(0,s.jsx)(n.Ex,{variant:t===e?"primary":"default",size:"sm",children:t.toUpperCase()},t))]})]}),m&&(0,s.jsxs)("div",{className:"flex w-full flex-col gap-2 sm:w-auto sm:flex-row sm:items-center",children:[(0,s.jsx)(n.$n,{size:"sm",variant:"secondary",icon:"edit",onClick:()=>f(!0),children:"Edit"}),(0,s.jsx)(n.$n,{size:"sm",variant:"secondary",icon:"delete",onClick:u,children:"Delete"})]})]})]}),!m&&j.kindNotice?.[e]&&(0,s.jsxs)("div",{className:"flex items-start gap-3 px-4 py-3 rounded-lg bg-amber-500/10 border border-amber-500/30 text-amber-700 dark:text-amber-400",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-[20px] mt-0.5",children:"warning"}),(0,s.jsx)("p",{className:"text-sm",children:j.kindNotice[e]})]}),!m&&j.notice?.text&&!j.deprecated&&(0,s.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,s.jsx)("span",{className:"material-symbols-outlined text-[16px] text-blue-500 shrink-0",children:"info"}),(0,s.jsx)("p",{className:"min-w-0 flex-1 text-xs leading-relaxed text-blue-600 dark:text-blue-400",children:j.notice.text}),j.notice.apiKeyUrl&&(0,s.jsx)("a",{href:j.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 →"})]}),!m&&j.noAuth?(0,s.jsx)(n.gw,{providerId:t}):(0,s.jsx)(y,{providerId:t,isOAuth:!1}),"tts"!==e&&"webSearch"!==e&&"webFetch"!==e&&(0,s.jsx)(C,{providerId:t,kindFilter:e,providerAliasOverride:m?p?.prefix:void 0}),!m&&(j.searchConfig||j.fetchConfig||j.ttsConfig||j.sttConfig||j.embeddingConfig||j.searchViaChat)&&(0,s.jsx)(n.Wx,{config:"webFetch"===e?j.fetchConfig:"tts"===e?j.ttsConfig:"stt"===e?j.sttConfig:"embedding"===e?j.embeddingConfig:j.searchConfig||{mode:"chat-completions",defaultModel:j.searchViaChat?.defaultModel,pricingUrl:j.searchViaChat?.pricingUrl,freeTier:j.searchViaChat?.freeTier},provider:j,title:`${l.label} Config`}),"embedding"===e&&(0,s.jsx)(E,{providerId:t,customAlias:p?.prefix}),"tts"===e&&(0,s.jsx)(I,{providerId:t}),"stt"===e&&!m&&(0,s.jsx)(K,{providerId:t}),!m&&$[e]&&(0,s.jsx)(L,{providerId:t,kind:e}),m&&(0,s.jsx)(n.x0,{isOpen:g,node:p,onClose:()=>f(!1),onSaved:e=>{x(e),f(!1)}})]}):(0,r.notFound)()}},53578:(e,t,a)=>{"use strict";async function s(e,t,a=fetch){let r=await a("/api/settings",{cache:"no-store"});if(!r.ok)throw Error(`Failed to load settings (${r.status})`);let l=(await r.json()).providerStrategies||{},o=t(l[e]||{}),i={...l};o&&Object.keys(o).length>0?i[e]=o:delete i[e];let n=await a("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerStrategies:i})});if(!n.ok)throw Error(`Failed to save settings (${n.status})`);return o}a.d(t,{T:()=>s})},70217:(e,t,a)=>{"use strict";function s(e,t){return!1===e?"default":"active"===t||"success"===t?"success":"error"===t||"expired"===t||"unavailable"===t?"error":"default"}a.d(t,{g:()=>s})}},e=>{e.O(0,[2574,3862,782,8500,594,1321,4707,5497,8441,3794,7358],()=>e(e.s=17845)),_N_E=e.O()}]);
59
+ }`;return(0,s.jsxs)(n.Zp,{children:[(0,s.jsx)("h2",{className:"text-lg font-semibold mb-4",children:"Example"}),(0,s.jsxs)("div",{className:"flex flex-col gap-2.5",children:[o.length>0?(0,s.jsx)(S,{label:"Model",htmlFor:"stt-example-model",children:(0,s.jsx)("select",{id:"stt-example-model",value:d,onChange:e=>m(e.target.value),className:"w-full px-3 py-1.5 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary",children:o.map(e=>(0,s.jsx)("option",{value:e.id,children:e.name||e.id},e.id))})}):(0,s.jsx)(S,{label:"Model",htmlFor:"stt-example-model",children:(0,s.jsx)("input",{id:"stt-example-model",value:d,onChange:e=>m(e.target.value),placeholder:"Enter model id",className:"w-full px-3 py-1.5 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary font-mono"})}),(0,s.jsx)(S,{label:"Endpoint",children:(0,s.jsx)("div",{className:"flex w-full flex-col gap-2 sm:w-auto sm:flex-row sm:items-center",children:(0,s.jsxs)("span",{className:"w-full min-w-0 flex-1 px-3 py-1.5 text-sm font-mono text-text-main bg-sidebar rounded-lg truncate",children:[E,"/v1/audio/transcriptions"]})})}),(0,s.jsx)(S,{label:"API Key",htmlFor:"stt-example-key",children:(0,s.jsx)("input",{id:"stt-example-key",type:"password",autoComplete:"off",value:$,onChange:e=>F(e.target.value),placeholder:"Paste a Switchboard client key secret (sk-...)",className:"w-full px-3 py-1.5 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary font-mono"})}),(0,s.jsx)(S,{label:"Audio File",htmlFor:"stt-example-audio",children:(0,s.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,s.jsx)("input",{id:"stt-example-audio",type:"file",accept:"audio/*,video/mp4,.m4a,.mp3,.wav,.ogg,.flac,.webm,.opus",onChange:e=>h(e.target.files?.[0]||null),className:"w-full text-xs text-text-muted file:mr-2 file:py-1 file:px-2.5 file:rounded-lg file:border file:border-border file:bg-background file:text-text-main hover:file:bg-sidebar file:cursor-pointer"}),x&&(0,s.jsxs)("span",{className:"text-xs text-text-muted font-mono",children:[x.name," \xb7 ",(x.size/1024).toFixed(1)," KB"]})]})}),p.includes("language")&&(0,s.jsx)(S,{label:"Language",htmlFor:"stt-example-language",children:(0,s.jsx)("input",{id:"stt-example-language",value:b,onChange:e=>f(e.target.value),placeholder:"e.g. en, vi, ja (auto-detect if empty)",className:"w-full px-3 py-1.5 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary font-mono"})}),p.includes("prompt")&&(0,s.jsx)(S,{label:"Prompt",htmlFor:"stt-example-prompt",children:(0,s.jsx)("input",{id:"stt-example-prompt",value:g,onChange:e=>y(e.target.value),placeholder:"optional context to improve accuracy",className:"w-full px-3 py-1.5 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary"})}),p.includes("temperature")&&(0,s.jsx)(S,{label:"Temperature",htmlFor:"stt-example-temperature",children:(0,s.jsx)("input",{id:"stt-example-temperature",type:"number",step:"0.1",min:"0",max:"1",value:k,onChange:e=>C(e.target.value),placeholder:"0 - 1 (default 0)",className:"w-full px-3 py-1.5 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary"})}),p.includes("response_format")&&(0,s.jsx)(S,{label:"Response Format",htmlFor:"stt-example-format",children:(0,s.jsxs)("select",{id:"stt-example-format",value:w,onChange:e=>N(e.target.value),className:"w-full px-3 py-1.5 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary",children:[(0,s.jsx)("option",{value:"json",children:"json"}),(0,s.jsx)("option",{value:"text",children:"text"}),(0,s.jsx)("option",{value:"srt",children:"srt"}),(0,s.jsx)("option",{value:"verbose_json",children:"verbose_json"}),(0,s.jsx)("option",{value:"vtt",children:"vtt"})]})}),(0,s.jsxs)("div",{className:"mt-1",children:[(0,s.jsxs)("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between mb-1.5",children:[(0,s.jsx)("span",{className:"text-xs font-semibold text-text-muted uppercase tracking-wider",children:"Request"}),(0,s.jsxs)("div",{className:"flex w-full flex-col gap-2 sm:w-auto sm:flex-row sm:items-center",children:[(0,s.jsxs)("button",{onClick:()=>D(J),className:"inline-flex items-center gap-1 text-xs text-text-muted hover:text-primary transition-colors",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:B?"check":"content_copy"}),B?"Copied":"Copy"]}),(0,s.jsxs)("button",{onClick:V,disabled:_||!x||!z||!$.trim(),className:"flex w-full sm:w-auto items-center justify-center gap-1.5 px-3 py-1 rounded-lg bg-primary text-on-primary text-xs font-medium hover:bg-primary/90 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-[14px]",style:_?{animation:"spin 1s linear infinite"}:void 0,children:"play_arrow"}),_?"Transcribing...":"Run"]})]})]}),(0,s.jsx)("pre",{className:"bg-sidebar rounded-lg px-3 py-2.5 text-xs font-mono text-text-main overflow-x-auto whitespace-pre-wrap break-all",children:J})]}),M&&(0,s.jsx)("p",{role:"alert",className:"text-xs text-red-500 break-words",children:M}),(0,s.jsxs)("div",{children:[(0,s.jsxs)("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between mb-1.5",children:[(0,s.jsxs)("span",{className:"text-xs font-semibold text-text-muted uppercase tracking-wider",children:["Response ",T&&P&&(0,s.jsxs)("span",{className:"font-normal normal-case",children:["⚡ ",P,"ms"]})]}),T&&(0,s.jsxs)("button",{onClick:()=>q(H),className:"inline-flex items-center gap-1 text-xs text-text-muted hover:text-primary transition-colors",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:U?"check":"content_copy"}),U?"Copied":"Copy"]})]}),(0,s.jsx)("pre",{className:"bg-sidebar rounded-lg px-3 py-2.5 text-xs font-mono text-text-main overflow-x-auto whitespace-pre-wrap break-all opacity-70",children:H})]})]})]})}var B=a(77251);function D(){let{kind:e,id:t}=(0,r.useParams)(),a=(0,r.useRouter)(),l=c.rj.find(t=>t.id===e),m=(0,c.gC)(t)&&"embedding"===e,u=async()=>{if(await (0,B.l)({message:"Delete this Custom Embedding node?",confirmText:"Continue"}))try{(await fetch(`/api/provider-nodes/${t}`,{method:"DELETE"})).ok&&a.push(`/dashboard/media-providers/${e}`)}catch(e){(0,w.s)("Error deleting custom embedding node:",e)}},[p,x]=(0,i.useState)(null),[h,b]=(0,i.useState)(m),[f,g]=(0,i.useState)(!1);if((0,i.useEffect)(()=>{if(!m)return;let e=!1;return fetch("/api/provider-nodes",{cache:"no-store"}).then(e=>e.json()).then(a=>{e||(x((a.nodes||[]).find(e=>e.id===t)||null),b(!1))}).catch(()=>{e||b(!1)}),()=>{e=!0}},[t,m]),!l)return(0,r.notFound)();let v=c.Q2[t],j=m?p?{id:t,name:p.name||"Custom Embedding",color:"#6366F1",textIcon:"CE"}:null:v;if(!m&&!v||m&&!h&&!p)return(0,r.notFound)();if(m&&h)return(0,s.jsx)("div",{className:"text-text-muted text-sm py-12 text-center",children:"Loading..."});let N=m?["embedding"]:j.serviceKinds??["llm"];return m||N.includes(e)?(0,s.jsxs)("div",{className:"flex flex-col gap-8",children:[(0,s.jsxs)("div",{children:[(0,s.jsxs)(o(),{href:`/dashboard/media-providers/${e}`,className:"inline-flex items-center gap-1 text-sm text-text-muted hover:text-primary transition-colors mb-4",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-lg",children:"arrow_back"}),l.label]}),(0,s.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:gap-4",children:[(0,s.jsx)("div",{className:"size-12 rounded-lg flex items-center justify-center shrink-0",style:{backgroundColor:`${j.color}15`},children:(0,s.jsx)(d.A,{src:`/providers/${j.id}.png`,alt:j.name,size:48,className:"object-contain rounded-lg max-w-[48px] max-h-[48px]",fallbackText:j.textIcon||j.id.slice(0,2).toUpperCase(),fallbackColor:j.color})}),(0,s.jsxs)("div",{className:"flex-1",children:[(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-2 sm:gap-3",children:[(0,s.jsx)("h1",{className:"text-3xl font-semibold tracking-tight",children:j.name}),!m&&j.notice?.apiKeyUrl&&(0,s.jsxs)("a",{href:j.notice.apiKeyUrl,target:"_blank",rel:"noopener noreferrer",className:"text-xs text-primary hover:underline inline-flex items-center gap-1",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-sm",children:"open_in_new"}),"Get API Key"]})]}),(0,s.jsxs)("div",{className:"flex items-center gap-1.5 mt-1 flex-wrap",children:[m&&(0,s.jsxs)(n.Ex,{variant:"default",size:"sm",children:["Custom \xb7 ",p?.prefix]}),N.map(t=>(0,s.jsx)(n.Ex,{variant:t===e?"primary":"default",size:"sm",children:t.toUpperCase()},t))]})]}),m&&(0,s.jsxs)("div",{className:"flex w-full flex-col gap-2 sm:w-auto sm:flex-row sm:items-center",children:[(0,s.jsx)(n.$n,{size:"sm",variant:"secondary",icon:"edit",onClick:()=>g(!0),children:"Edit"}),(0,s.jsx)(n.$n,{size:"sm",variant:"secondary",icon:"delete",onClick:u,children:"Delete"})]})]})]}),!m&&j.kindNotice?.[e]&&(0,s.jsxs)("div",{className:"flex items-start gap-3 px-4 py-3 rounded-lg bg-amber-500/10 border border-amber-500/30 text-amber-700 dark:text-amber-400",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-[20px] mt-0.5",children:"warning"}),(0,s.jsx)("p",{className:"text-sm",children:j.kindNotice[e]})]}),!m&&j.notice?.text&&!j.deprecated&&(0,s.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,s.jsx)("span",{className:"material-symbols-outlined text-[16px] text-blue-500 shrink-0",children:"info"}),(0,s.jsx)("p",{className:"min-w-0 flex-1 text-xs leading-relaxed text-blue-600 dark:text-blue-400",children:j.notice.text}),j.notice.apiKeyUrl&&(0,s.jsx)("a",{href:j.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 →"})]}),!m&&j.noAuth?(0,s.jsx)(n.gw,{providerId:t}):(0,s.jsx)(y,{providerId:t,isOAuth:!1}),"tts"!==e&&"webSearch"!==e&&"webFetch"!==e&&(0,s.jsx)(C,{providerId:t,kindFilter:e,providerAliasOverride:m?p?.prefix:void 0}),!m&&(j.searchConfig||j.fetchConfig||j.ttsConfig||j.sttConfig||j.embeddingConfig||j.searchViaChat)&&(0,s.jsx)(n.Wx,{config:"webFetch"===e?j.fetchConfig:"tts"===e?j.ttsConfig:"stt"===e?j.sttConfig:"embedding"===e?j.embeddingConfig:j.searchConfig||{mode:"chat-completions",defaultModel:j.searchViaChat?.defaultModel,pricingUrl:j.searchViaChat?.pricingUrl,freeTier:j.searchViaChat?.freeTier},provider:j,title:`${l.label} Config`}),"embedding"===e&&(0,s.jsx)(E,{providerId:t,customAlias:p?.prefix}),"tts"===e&&(0,s.jsx)(I,{providerId:t}),"stt"===e&&!m&&(0,s.jsx)(K,{providerId:t}),!m&&$[e]&&(0,s.jsx)(L,{providerId:t,kind:e}),m&&(0,s.jsx)(n.x0,{isOpen:f,node:p,onClose:()=>g(!1),onSaved:e=>{x(e),g(!1)}})]}):(0,r.notFound)()}},53578:(e,t,a)=>{"use strict";async function s(e,t,a=fetch){let r=await a("/api/settings",{cache:"no-store"});if(!r.ok)throw Error(`Failed to load settings (${r.status})`);let l=(await r.json()).providerStrategies||{},o=t(l[e]||{}),i={...l};o&&Object.keys(o).length>0?i[e]=o:delete i[e];let n=await a("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerStrategies:i})});if(!n.ok)throw Error(`Failed to save settings (${n.status})`);return o}a.d(t,{T:()=>s})},70217:(e,t,a)=>{"use strict";function s(e,t){return!1===e?"default":"active"===t||"success"===t?"success":"error"===t||"expired"===t||"unavailable"===t?"error":"default"}a.d(t,{g:()=>s})}},e=>{e.O(0,[2574,3862,782,8500,594,1321,4707,5497,8441,3794,7358],()=>e(e.s=17845)),_N_E=e.O()}]);