zevairouter 1.1.39 → 1.1.40
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.
- package/CHANGELOG.md +6 -0
- package/README.md +13 -2
- package/cli/app/.next-cli-build/BUILD_ID +1 -1
- package/cli/app/.next-cli-build/app-path-routes-manifest.json +7 -7
- package/cli/app/.next-cli-build/build-manifest.json +2 -2
- package/cli/app/.next-cli-build/prerender-manifest.json +3 -3
- package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/automation/page_client-reference-manifest.js +1 -1
- package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/basic-chat/page_client-reference-manifest.js +1 -1
- package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/cli-tools/[toolId]/page_client-reference-manifest.js +1 -1
- package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/cli-tools/page_client-reference-manifest.js +1 -1
- package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/combos/page_client-reference-manifest.js +1 -1
- package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/console-log/page_client-reference-manifest.js +1 -1
- package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/context/page_client-reference-manifest.js +1 -1
- package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/endpoint/page_client-reference-manifest.js +1 -1
- package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/[kind]/[id]/page.js +9 -9
- package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/[kind]/[id]/page_client-reference-manifest.js +1 -1
- package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/[kind]/page_client-reference-manifest.js +1 -1
- package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/combo/[id]/page_client-reference-manifest.js +1 -1
- package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/web/page_client-reference-manifest.js +1 -1
- package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/mitm/page_client-reference-manifest.js +1 -1
- package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/page_client-reference-manifest.js +1 -1
- package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/playground/page_client-reference-manifest.js +1 -1
- package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/profile/page_client-reference-manifest.js +1 -1
- package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/[id]/page_client-reference-manifest.js +1 -1
- package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/new/page_client-reference-manifest.js +1 -1
- package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/page_client-reference-manifest.js +1 -1
- package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/proxy-pools/page_client-reference-manifest.js +1 -1
- package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/pxpipe/page_client-reference-manifest.js +1 -1
- package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/quota/page_client-reference-manifest.js +1 -1
- package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/settings/pricing/page_client-reference-manifest.js +1 -1
- package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/skills/page_client-reference-manifest.js +1 -1
- package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/terminal/page_client-reference-manifest.js +1 -1
- package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/token-saver/page_client-reference-manifest.js +1 -1
- package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/translator/page_client-reference-manifest.js +1 -1
- package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/usage/page_client-reference-manifest.js +1 -1
- package/cli/app/.next-cli-build/server/app/_global-error/page_client-reference-manifest.js +1 -1
- package/cli/app/.next-cli-build/server/app/_global-error.html +1 -1
- package/cli/app/.next-cli-build/server/app/_global-error.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/cli/app/.next-cli-build/server/app/_not-found.html +1 -1
- package/cli/app/.next-cli-build/server/app/_not-found.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/_not-found.segments/_full.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/_not-found.segments/_tree.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/api/cli-tools/all-statuses/route.js +4 -4
- package/cli/app/.next-cli-build/server/app/api/cli-tools/antigravity-mitm/alias/route.js +2 -2
- package/cli/app/.next-cli-build/server/app/api/cli-tools/claude-settings/route.js +2 -2
- package/cli/app/.next-cli-build/server/app/api/cli-tools/cline-settings/route.js +1 -1
- package/cli/app/.next-cli-build/server/app/api/cli-tools/codex-settings/route.js +1 -1
- package/cli/app/.next-cli-build/server/app/api/cli-tools/copilot-settings/route.js +2 -2
- package/cli/app/.next-cli-build/server/app/api/cli-tools/cowork-mcp-registry/route.js +1 -1
- package/cli/app/.next-cli-build/server/app/api/cli-tools/cowork-mcp-tools/route.js +2 -2
- package/cli/app/.next-cli-build/server/app/api/cli-tools/cowork-settings/route.js +2 -2
- package/cli/app/.next-cli-build/server/app/api/cli-tools/deepseek-tui-settings/route.js +3 -3
- package/cli/app/.next-cli-build/server/app/api/cli-tools/droid-settings/route.js +1 -1
- package/cli/app/.next-cli-build/server/app/api/cli-tools/grok-build-settings/route.js +1 -1
- package/cli/app/.next-cli-build/server/app/api/cli-tools/hermes-settings/route.js +1 -1
- package/cli/app/.next-cli-build/server/app/api/cli-tools/jcode-settings/route.js +2 -2
- package/cli/app/.next-cli-build/server/app/api/cli-tools/kilo-settings/route.js +2 -2
- package/cli/app/.next-cli-build/server/app/api/cli-tools/omp-settings/route.js +2 -2
- package/cli/app/.next-cli-build/server/app/api/cli-tools/openclaw-settings/route.js +2 -2
- package/cli/app/.next-cli-build/server/app/api/cli-tools/opencode-settings/route.js +2 -2
- package/cli/app/.next-cli-build/server/app/api/models/route.js +1 -1
- package/cli/app/.next-cli-build/server/app/api/providers/route.js +1 -1
- package/cli/app/.next-cli-build/server/app/api/translator/console-logs/route.js +1 -1
- package/cli/app/.next-cli-build/server/app/api/translator/console-logs/stream/route.js +1 -1
- package/cli/app/.next-cli-build/server/app/api/tunnel/tailscale-install/route.js +2 -2
- package/cli/app/.next-cli-build/server/app/api/version/route.js +1 -1
- package/cli/app/.next-cli-build/server/app/callback/page_client-reference-manifest.js +1 -1
- package/cli/app/.next-cli-build/server/app/callback.html +1 -1
- package/cli/app/.next-cli-build/server/app/callback.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/callback.segments/_full.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/callback.segments/_tree.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/callback.segments/callback/__PAGE__.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/automation.html +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/automation.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/automation.segments/!KGRhc2hib2FyZCk/dashboard/automation/__PAGE__.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/automation.segments/_full.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/automation.segments/_tree.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/basic-chat.html +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/basic-chat.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/basic-chat.segments/!KGRhc2hib2FyZCk/dashboard/basic-chat/__PAGE__.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/basic-chat.segments/_full.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/basic-chat.segments/_tree.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/cli-tools.html +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/cli-tools.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/cli-tools.segments/!KGRhc2hib2FyZCk/dashboard/cli-tools/__PAGE__.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/cli-tools.segments/_full.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/cli-tools.segments/_tree.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/combos.html +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/combos.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/combos.segments/!KGRhc2hib2FyZCk/dashboard/combos/__PAGE__.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/combos.segments/_full.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/combos.segments/_tree.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/context.html +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/context.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/context.segments/!KGRhc2hib2FyZCk/dashboard/context/__PAGE__.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/context.segments/_full.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/context.segments/_tree.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/endpoint.html +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/endpoint.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/endpoint.segments/!KGRhc2hib2FyZCk/dashboard/endpoint/__PAGE__.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/endpoint.segments/_full.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/endpoint.segments/_tree.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/media-providers/web.html +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/media-providers/web.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/media-providers/web.segments/!KGRhc2hib2FyZCk/dashboard/media-providers/web/__PAGE__.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/media-providers/web.segments/_full.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/media-providers/web.segments/_tree.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/mitm.html +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/mitm.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/mitm.segments/!KGRhc2hib2FyZCk/dashboard/mitm/__PAGE__.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/mitm.segments/_full.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/mitm.segments/_tree.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/playground.html +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/playground.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/playground.segments/!KGRhc2hib2FyZCk/dashboard/playground/__PAGE__.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/playground.segments/_full.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/playground.segments/_tree.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/profile.html +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/profile.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/profile.segments/!KGRhc2hib2FyZCk/dashboard/profile/__PAGE__.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/profile.segments/_full.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/profile.segments/_tree.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/providers/new.html +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/providers/new.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/providers/new.segments/!KGRhc2hib2FyZCk/dashboard/providers/new/__PAGE__.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/providers/new.segments/_full.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/providers/new.segments/_tree.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/providers.html +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/providers.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/providers.segments/!KGRhc2hib2FyZCk/dashboard/providers/__PAGE__.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/providers.segments/_full.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/providers.segments/_tree.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/proxy-pools.html +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/proxy-pools.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/proxy-pools.segments/!KGRhc2hib2FyZCk/dashboard/proxy-pools/__PAGE__.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/proxy-pools.segments/_full.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/proxy-pools.segments/_tree.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/pxpipe.html +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/pxpipe.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/pxpipe.segments/!KGRhc2hib2FyZCk/dashboard/pxpipe/__PAGE__.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/pxpipe.segments/_full.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/pxpipe.segments/_tree.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/quota.html +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/quota.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/quota.segments/!KGRhc2hib2FyZCk/dashboard/quota/__PAGE__.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/quota.segments/_full.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/quota.segments/_tree.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/settings/pricing.html +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/settings/pricing.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/!KGRhc2hib2FyZCk/dashboard/settings/pricing/__PAGE__.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/_full.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/_tree.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/skills.html +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/skills.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/skills.segments/!KGRhc2hib2FyZCk/dashboard/skills/__PAGE__.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/skills.segments/_full.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/skills.segments/_tree.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/token-saver.html +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/token-saver.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/token-saver.segments/!KGRhc2hib2FyZCk/dashboard/token-saver/__PAGE__.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/token-saver.segments/_full.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/token-saver.segments/_tree.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/translator.html +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/translator.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/translator.segments/!KGRhc2hib2FyZCk/dashboard/translator/__PAGE__.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/translator.segments/_full.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/translator.segments/_tree.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/usage.html +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/usage.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/usage.segments/!KGRhc2hib2FyZCk/dashboard/usage/__PAGE__.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/usage.segments/_full.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/usage.segments/_tree.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard.html +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard.segments/!KGRhc2hib2FyZCk/dashboard/__PAGE__.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard.segments/_full.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard.segments/_tree.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/index.html +1 -1
- package/cli/app/.next-cli-build/server/app/index.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/index.segments/__PAGE__.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/index.segments/_full.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/index.segments/_tree.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/landing/page_client-reference-manifest.js +1 -1
- package/cli/app/.next-cli-build/server/app/landing.html +1 -1
- package/cli/app/.next-cli-build/server/app/landing.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/landing.segments/_full.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/landing.segments/_tree.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/landing.segments/landing/__PAGE__.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/login/page_client-reference-manifest.js +1 -1
- package/cli/app/.next-cli-build/server/app/login.html +1 -1
- package/cli/app/.next-cli-build/server/app/login.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/login.segments/_full.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/login.segments/_tree.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/login.segments/login/__PAGE__.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/page_client-reference-manifest.js +1 -1
- package/cli/app/.next-cli-build/server/app-paths-manifest.json +7 -7
- package/cli/app/.next-cli-build/server/chunks/1131.js +1 -1
- package/cli/app/.next-cli-build/server/chunks/1350.js +1 -1
- package/cli/app/.next-cli-build/server/chunks/3949.js +1 -1
- package/cli/app/.next-cli-build/server/chunks/4827.js +1 -1
- package/cli/app/.next-cli-build/server/chunks/5949.js +2 -2
- package/cli/app/.next-cli-build/server/chunks/7319.js +1 -1
- package/cli/app/.next-cli-build/server/chunks/7634.js +1 -1
- package/cli/app/.next-cli-build/server/chunks/8306.js +1 -1
- package/cli/app/.next-cli-build/server/middleware-build-manifest.js +1 -1
- package/cli/app/.next-cli-build/server/pages/404.html +1 -1
- package/cli/app/.next-cli-build/server/pages/500.html +1 -1
- package/cli/app/.next-cli-build/server/preview-props.json +3 -3
- package/cli/app/.next-cli-build/server/server-reference-manifest.js +1 -1
- package/cli/app/.next-cli-build/server/server-reference-manifest.json +1 -1
- package/cli/app/.next-cli-build/static/chunks/{620-ce5fcff5dd642409.js → 620-66edeaf7464b2af3.js} +1 -1
- package/cli/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/media-providers/[kind]/[id]/page-9e3c0c1e23790a02.js +58 -0
- package/cli/app/CHANGELOG.md +6 -0
- package/cli/app/package.json +2 -1
- package/cli/package.json +1 -1
- package/package.json +2 -1
- package/scripts/flow-vps-setup.sh +270 -0
- package/cli/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/media-providers/[kind]/[id]/page-d580298598ba5275.js +0 -58
- /package/cli/app/.next-cli-build/static/{uMEc8emk95_G6PL07z_6I → UOQlernibgn9uJ8E3huEs}/_buildManifest.js +0 -0
- /package/cli/app/.next-cli-build/static/{uMEc8emk95_G6PL07z_6I → UOQlernibgn9uJ8E3huEs}/_ssgManifest.js +0 -0
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# One-command Google Flow setup for a headless Ubuntu/Debian VPS running ZevaiRouter.
|
|
3
|
+
#
|
|
4
|
+
# sudo bash "$(npm root -g)/zevairouter/scripts/flow-vps-setup.sh"
|
|
5
|
+
#
|
|
6
|
+
# Installs real Google Chrome, Xvfb, x11vnc, ffmpeg and gflow-cli for a
|
|
7
|
+
# dedicated non-root user, applies ZevaiRouter's gflow patch, and runs the gflow
|
|
8
|
+
# daemon on 127.0.0.1 with a 6-hourly session renew. It also installs:
|
|
9
|
+
# flow-login <profile> log one Google account in through a VNC window
|
|
10
|
+
# gflow-as-<user> lets a root-run router list that user's gflow profiles
|
|
11
|
+
# Safe to re-run: the daemon token, logged-in accounts and existing files are kept.
|
|
12
|
+
#
|
|
13
|
+
# Optional environment:
|
|
14
|
+
# FLOW_USER=flow system user that owns Chrome profiles
|
|
15
|
+
# FLOW_DISPLAY=98 Xvfb display number
|
|
16
|
+
# FLOW_DAEMON_PORT=8077 gflow daemon port (127.0.0.1 only)
|
|
17
|
+
# FLOW_VNC_PORT=5998 VNC port used by flow-login (127.0.0.1 only)
|
|
18
|
+
# FLOW_GFLOW_SPEC="gflow-cli>=0.88,<0.90" gflow-cli versions the patch supports
|
|
19
|
+
# FLOW_SKIP_ROUTER_ENV=1 do not touch /etc/zevairouter/zevairouter.env
|
|
20
|
+
|
|
21
|
+
set -Eeuo pipefail
|
|
22
|
+
|
|
23
|
+
FLOW_USER="${FLOW_USER:-flow}"
|
|
24
|
+
FLOW_DISPLAY="${FLOW_DISPLAY:-98}"
|
|
25
|
+
FLOW_DAEMON_PORT="${FLOW_DAEMON_PORT:-8077}"
|
|
26
|
+
FLOW_VNC_PORT="${FLOW_VNC_PORT:-5998}"
|
|
27
|
+
FLOW_GFLOW_SPEC="${FLOW_GFLOW_SPEC:-gflow-cli>=0.88,<0.90}"
|
|
28
|
+
FLOW_SKIP_ROUTER_ENV="${FLOW_SKIP_ROUTER_ENV:-0}"
|
|
29
|
+
ROUTER_ENV=/etc/zevairouter/zevairouter.env
|
|
30
|
+
|
|
31
|
+
ok() { printf ' OK %s\n' "$*"; }
|
|
32
|
+
warn() { printf ' WARN %s\n' "$*" >&2; }
|
|
33
|
+
fail() { printf ' ERROR %s\n' "$*" >&2; exit 1; }
|
|
34
|
+
log() { printf '\n=== %s ===\n' "$*"; }
|
|
35
|
+
have() { command -v "$1" >/dev/null 2>&1; }
|
|
36
|
+
|
|
37
|
+
[ "$(uname -s 2>/dev/null || true)" = Linux ] || fail "flow-vps-setup.sh supports Linux only"
|
|
38
|
+
[ "$(id -u)" -eq 0 ] || fail "run as root: sudo bash $0"
|
|
39
|
+
have apt-get || fail "Ubuntu/Debian with apt-get is required"
|
|
40
|
+
have systemctl && [ -d /run/systemd/system ] || fail "systemd is required"
|
|
41
|
+
[[ "$FLOW_USER" =~ ^[a-z_][a-z0-9_-]{0,31}$ ]] || fail "FLOW_USER must be a valid user name"
|
|
42
|
+
for n in FLOW_DISPLAY FLOW_DAEMON_PORT FLOW_VNC_PORT; do
|
|
43
|
+
[[ "${!n}" =~ ^[0-9]+$ ]] || fail "$n must be a number"
|
|
44
|
+
done
|
|
45
|
+
[ "$(dpkg --print-architecture)" = amd64 ] || fail "Google Chrome for Linux needs an amd64 (x86_64) VPS"
|
|
46
|
+
|
|
47
|
+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
48
|
+
PATCH_SCRIPT="$SCRIPT_DIR/gflow-reply-capture.py"
|
|
49
|
+
[ -f "$PATCH_SCRIPT" ] || fail "missing $PATCH_SCRIPT (run this from an installed zevairouter package)"
|
|
50
|
+
|
|
51
|
+
# Units and helper commands get a suffix for any user other than the default,
|
|
52
|
+
# so a second setup on the same host never overwrites the first.
|
|
53
|
+
if [ "$FLOW_USER" = flow ]; then UNIT=gflow; SUFFIX=""; else UNIT="gflow-$FLOW_USER"; SUFFIX="-$FLOW_USER"; fi
|
|
54
|
+
HOME_DIR="/home/$FLOW_USER"
|
|
55
|
+
RUNUSER="$(command -v runuser)"
|
|
56
|
+
LOGIN_BIN="/usr/local/bin/flow-login$SUFFIX"
|
|
57
|
+
WRAPPER_BIN="/usr/local/bin/gflow-as-$FLOW_USER"
|
|
58
|
+
|
|
59
|
+
log "System packages"
|
|
60
|
+
export DEBIAN_FRONTEND=noninteractive
|
|
61
|
+
apt-get update -qq
|
|
62
|
+
apt-get install -y -qq curl ca-certificates openssl xvfb x11vnc xdotool ffmpeg >/dev/null
|
|
63
|
+
if ! have google-chrome; then
|
|
64
|
+
chrome_deb="$(mktemp --suffix=.deb)"
|
|
65
|
+
curl --proto '=https' --tlsv1.2 -fsSL -o "$chrome_deb" \
|
|
66
|
+
https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
|
|
67
|
+
apt-get install -y -qq "$chrome_deb" >/dev/null
|
|
68
|
+
rm -f "$chrome_deb"
|
|
69
|
+
fi
|
|
70
|
+
ok "$(google-chrome --version)"
|
|
71
|
+
|
|
72
|
+
log "User $FLOW_USER"
|
|
73
|
+
id "$FLOW_USER" >/dev/null 2>&1 || useradd --create-home --shell /bin/bash "$FLOW_USER"
|
|
74
|
+
install -d -o "$FLOW_USER" -g "$FLOW_USER" -m 700 "$HOME_DIR/.gflow-agent"
|
|
75
|
+
install -d -o "$FLOW_USER" -g "$FLOW_USER" -m 755 "$HOME_DIR/gflow-out"
|
|
76
|
+
as_user() { (cd "$HOME_DIR" && "$RUNUSER" -u "$FLOW_USER" -- /usr/bin/env HOME="$HOME_DIR" PATH="$HOME_DIR/.local/bin:/usr/bin:/bin" "$@"); }
|
|
77
|
+
ok "$(id "$FLOW_USER")"
|
|
78
|
+
|
|
79
|
+
log "gflow-cli"
|
|
80
|
+
if [ ! -x "$HOME_DIR/.local/bin/uv" ]; then
|
|
81
|
+
as_user bash -c 'curl --proto "=https" --tlsv1.2 -LsSf https://astral.sh/uv/install.sh | sh' >/dev/null
|
|
82
|
+
fi
|
|
83
|
+
if [ ! -x "$HOME_DIR/.local/bin/gflow" ]; then
|
|
84
|
+
as_user uv tool install "$FLOW_GFLOW_SPEC" >/dev/null
|
|
85
|
+
fi
|
|
86
|
+
GFLOW_PY="$(as_user uv tool dir)/gflow-cli/bin/python"
|
|
87
|
+
[ -x "$GFLOW_PY" ] || fail "gflow-cli python not found at $GFLOW_PY"
|
|
88
|
+
as_user "$GFLOW_PY" "$PATCH_SCRIPT"
|
|
89
|
+
ok "$(as_user gflow --version)"
|
|
90
|
+
|
|
91
|
+
TOKEN_FILE="$HOME_DIR/.gflow-agent/token"
|
|
92
|
+
if [ ! -s "$TOKEN_FILE" ]; then
|
|
93
|
+
(umask 077; openssl rand -hex 32 > "$TOKEN_FILE")
|
|
94
|
+
chown "$FLOW_USER:$FLOW_USER" "$TOKEN_FILE"
|
|
95
|
+
ok "created daemon token"
|
|
96
|
+
else
|
|
97
|
+
ok "kept existing daemon token"
|
|
98
|
+
fi
|
|
99
|
+
|
|
100
|
+
log "systemd services"
|
|
101
|
+
cat > "/etc/systemd/system/$UNIT-xvfb.service" <<EOF
|
|
102
|
+
[Unit]
|
|
103
|
+
Description=Xvfb display :$FLOW_DISPLAY for gflow (headed Chrome)
|
|
104
|
+
After=network.target
|
|
105
|
+
|
|
106
|
+
[Service]
|
|
107
|
+
User=$FLOW_USER
|
|
108
|
+
ExecStart=/usr/bin/Xvfb :$FLOW_DISPLAY -screen 0 1280x900x24 -nolisten tcp
|
|
109
|
+
Restart=always
|
|
110
|
+
RestartSec=3
|
|
111
|
+
|
|
112
|
+
[Install]
|
|
113
|
+
WantedBy=multi-user.target
|
|
114
|
+
EOF
|
|
115
|
+
cat > "/etc/systemd/system/$UNIT-daemon.service" <<EOF
|
|
116
|
+
[Unit]
|
|
117
|
+
Description=gflow MCP daemon (Google Flow via headed Chrome on Xvfb)
|
|
118
|
+
Requires=$UNIT-xvfb.service
|
|
119
|
+
After=$UNIT-xvfb.service network-online.target
|
|
120
|
+
|
|
121
|
+
[Service]
|
|
122
|
+
User=$FLOW_USER
|
|
123
|
+
WorkingDirectory=$HOME_DIR
|
|
124
|
+
Environment=DISPLAY=:$FLOW_DISPLAY
|
|
125
|
+
Environment=HOME=$HOME_DIR
|
|
126
|
+
Environment=PATH=$HOME_DIR/.local/bin:/usr/bin:/bin
|
|
127
|
+
Environment=GFLOW_CLI_OUTPUT_DIR=$HOME_DIR/gflow-out
|
|
128
|
+
Environment=GFLOW_CLI_LEASE_WAIT_SECONDS=600
|
|
129
|
+
Environment=GFLOW_CLI_BROWSER_WINDOW_POSITION=0,0
|
|
130
|
+
ExecStartPre=-$GFLOW_PY $PATCH_SCRIPT
|
|
131
|
+
ExecStart=/bin/bash -c 'export GFLOW_DAEMON_TOKEN="\$(cat $TOKEN_FILE)"; exec $HOME_DIR/.local/bin/gflow serve --port $FLOW_DAEMON_PORT --host 127.0.0.1'
|
|
132
|
+
Restart=always
|
|
133
|
+
RestartSec=5
|
|
134
|
+
|
|
135
|
+
[Install]
|
|
136
|
+
WantedBy=multi-user.target
|
|
137
|
+
EOF
|
|
138
|
+
cat > "/etc/systemd/system/$UNIT-renew.service" <<EOF
|
|
139
|
+
[Unit]
|
|
140
|
+
Description=Refresh all gflow Google sessions for $FLOW_USER
|
|
141
|
+
|
|
142
|
+
[Service]
|
|
143
|
+
Type=oneshot
|
|
144
|
+
User=$FLOW_USER
|
|
145
|
+
WorkingDirectory=$HOME_DIR
|
|
146
|
+
Environment=DISPLAY=:$FLOW_DISPLAY
|
|
147
|
+
Environment=HOME=$HOME_DIR
|
|
148
|
+
Environment=PATH=$HOME_DIR/.local/bin:/usr/bin:/bin
|
|
149
|
+
ExecStart=$HOME_DIR/.local/bin/gflow auth renew --all
|
|
150
|
+
EOF
|
|
151
|
+
cat > "/etc/systemd/system/$UNIT-renew.timer" <<EOF
|
|
152
|
+
[Unit]
|
|
153
|
+
Description=Refresh gflow sessions for $FLOW_USER every 6 hours
|
|
154
|
+
|
|
155
|
+
[Timer]
|
|
156
|
+
OnBootSec=10min
|
|
157
|
+
OnUnitActiveSec=6h
|
|
158
|
+
Persistent=true
|
|
159
|
+
|
|
160
|
+
[Install]
|
|
161
|
+
WantedBy=timers.target
|
|
162
|
+
EOF
|
|
163
|
+
systemctl daemon-reload
|
|
164
|
+
systemctl enable --now "$UNIT-xvfb.service" "$UNIT-renew.timer" >/dev/null 2>&1
|
|
165
|
+
systemctl enable "$UNIT-daemon.service" >/dev/null 2>&1
|
|
166
|
+
systemctl restart "$UNIT-daemon.service"
|
|
167
|
+
|
|
168
|
+
log "Helper commands"
|
|
169
|
+
cat > "$WRAPPER_BIN" <<EOF
|
|
170
|
+
#!/bin/sh
|
|
171
|
+
# Runs gflow as $FLOW_USER so a root-run ZevaiRouter can list its profiles.
|
|
172
|
+
# gflow reads ./.env from its working directory, so run it from that home.
|
|
173
|
+
cd $HOME_DIR || exit 1
|
|
174
|
+
exec $RUNUSER -u $FLOW_USER -- /usr/bin/env HOME=$HOME_DIR PATH=$HOME_DIR/.local/bin:/usr/bin:/bin $HOME_DIR/.local/bin/gflow "\$@"
|
|
175
|
+
EOF
|
|
176
|
+
chmod 755 "$WRAPPER_BIN"
|
|
177
|
+
|
|
178
|
+
cat > "$LOGIN_BIN" <<EOF
|
|
179
|
+
#!/bin/bash
|
|
180
|
+
# Log one Google account into gflow on this headless VPS: flow-login$SUFFIX <profile>
|
|
181
|
+
# Opens a password-protected VNC on 127.0.0.1:$FLOW_VNC_PORT only (reach it through
|
|
182
|
+
# an SSH tunnel), runs gflow auth login on display :$FLOW_DISPLAY, then closes VNC.
|
|
183
|
+
set -euo pipefail
|
|
184
|
+
PROFILE="\${1:-}"
|
|
185
|
+
if [[ ! "\$PROFILE" =~ ^[A-Za-z0-9._-]{1,64}\$ ]]; then
|
|
186
|
+
echo "usage: flow-login$SUFFIX <profile-name> (letters, digits, . _ -)" >&2
|
|
187
|
+
exit 2
|
|
188
|
+
fi
|
|
189
|
+
[ "\$(id -u)" -eq 0 ] || { echo "run as root" >&2; exit 1; }
|
|
190
|
+
VPS_IP="\${FLOW_LOGIN_HOST:-\$(curl -s -m 5 https://api.ipify.org 2>/dev/null || true)}"
|
|
191
|
+
VPS_IP="\${VPS_IP:-<this-vps-ip>}"
|
|
192
|
+
PASS=\$(openssl rand -hex 4)
|
|
193
|
+
$RUNUSER -u $FLOW_USER -- mkdir -p $HOME_DIR/.vnc
|
|
194
|
+
$RUNUSER -u $FLOW_USER -- x11vnc -storepasswd "\$PASS" $HOME_DIR/.vnc/passwd >/dev/null 2>&1
|
|
195
|
+
cleanup() {
|
|
196
|
+
pkill -u $FLOW_USER -f "x11vnc -display :$FLOW_DISPLAY " 2>/dev/null || true
|
|
197
|
+
rm -f $HOME_DIR/.vnc/passwd
|
|
198
|
+
}
|
|
199
|
+
trap cleanup EXIT
|
|
200
|
+
$RUNUSER -u $FLOW_USER -- x11vnc -display :$FLOW_DISPLAY -localhost -rfbport $FLOW_VNC_PORT -forever -shared \\
|
|
201
|
+
-rfbauth $HOME_DIR/.vnc/passwd -quiet -bg -o /tmp/flow-vnc-$FLOW_USER.log >/dev/null
|
|
202
|
+
cat <<MSG
|
|
203
|
+
|
|
204
|
+
1. On your computer, in a second terminal (Windows PowerShell or macOS Terminal):
|
|
205
|
+
ssh -L $FLOW_VNC_PORT:127.0.0.1:$FLOW_VNC_PORT root@\${VPS_IP}
|
|
206
|
+
2. Open a VNC viewer at 127.0.0.1:$FLOW_VNC_PORT (password: \${PASS})
|
|
207
|
+
macOS: Finder > Go > Connect to Server > vnc://127.0.0.1:$FLOW_VNC_PORT
|
|
208
|
+
Windows: TigerVNC or RealVNC Viewer
|
|
209
|
+
3. In the Chrome window, sign in to Flow until the editor opens.
|
|
210
|
+
Chrome closes by itself when the session is saved.
|
|
211
|
+
|
|
212
|
+
MSG
|
|
213
|
+
cd $HOME_DIR
|
|
214
|
+
$RUNUSER -u $FLOW_USER -- /usr/bin/env HOME=$HOME_DIR DISPLAY=:$FLOW_DISPLAY \\
|
|
215
|
+
PATH=$HOME_DIR/.local/bin:/usr/bin:/bin \\
|
|
216
|
+
GFLOW_CLI_BROWSER_WINDOW_POSITION=0,0 GFLOW_CLI_AUTH_LOGIN_TIMEOUT=1800 \\
|
|
217
|
+
bash -c '
|
|
218
|
+
( while sleep 2; do
|
|
219
|
+
for w in \$(xdotool search --onlyvisible --class google-chrome 2>/dev/null); do
|
|
220
|
+
xdotool windowmove "\$w" 0 0 windowsize "\$w" 1280 900
|
|
221
|
+
done
|
|
222
|
+
done ) & FIT=\$!
|
|
223
|
+
gflow auth login --profile "\$1" --browser chrome; RC=\$?
|
|
224
|
+
kill "\$FIT" 2>/dev/null
|
|
225
|
+
exit "\$RC"
|
|
226
|
+
' _ "\$PROFILE"
|
|
227
|
+
echo
|
|
228
|
+
echo "Done. In the ZevaiRouter dashboard: Providers > Google Flow > Import local profiles."
|
|
229
|
+
EOF
|
|
230
|
+
chmod 755 "$LOGIN_BIN"
|
|
231
|
+
ok "$LOGIN_BIN"
|
|
232
|
+
ok "$WRAPPER_BIN"
|
|
233
|
+
|
|
234
|
+
if [ "$FLOW_SKIP_ROUTER_ENV" != 1 ] && [ -f "$ROUTER_ENV" ]; then
|
|
235
|
+
if grep -q '^GFLOW_BIN=' "$ROUTER_ENV"; then
|
|
236
|
+
ok "router already has $(grep '^GFLOW_BIN=' "$ROUTER_ENV")"
|
|
237
|
+
else
|
|
238
|
+
printf 'GFLOW_BIN=%s\n' "$WRAPPER_BIN" >> "$ROUTER_ENV"
|
|
239
|
+
ok "set GFLOW_BIN in $ROUTER_ENV"
|
|
240
|
+
if systemctl is-active --quiet zevairouter; then
|
|
241
|
+
systemctl restart zevairouter
|
|
242
|
+
ok "restarted zevairouter"
|
|
243
|
+
fi
|
|
244
|
+
fi
|
|
245
|
+
fi
|
|
246
|
+
|
|
247
|
+
log "Check"
|
|
248
|
+
for _ in $(seq 1 30); do
|
|
249
|
+
(exec 3<>"/dev/tcp/127.0.0.1/$FLOW_DAEMON_PORT") 2>/dev/null && break
|
|
250
|
+
sleep 1
|
|
251
|
+
done
|
|
252
|
+
if (exec 3<>"/dev/tcp/127.0.0.1/$FLOW_DAEMON_PORT") 2>/dev/null; then
|
|
253
|
+
ok "gflow daemon listening on 127.0.0.1:$FLOW_DAEMON_PORT"
|
|
254
|
+
else
|
|
255
|
+
warn "gflow daemon is not listening yet: journalctl -u $UNIT-daemon -n 50"
|
|
256
|
+
fi
|
|
257
|
+
|
|
258
|
+
cat <<EOF
|
|
259
|
+
|
|
260
|
+
Google Flow is ready on this VPS.
|
|
261
|
+
|
|
262
|
+
Daemon URL: http://127.0.0.1:$FLOW_DAEMON_PORT/mcp
|
|
263
|
+
Daemon token: $(cat "$TOKEN_FILE")
|
|
264
|
+
(shown again any time with: cat $TOKEN_FILE)
|
|
265
|
+
|
|
266
|
+
Add a Google account:
|
|
267
|
+
1. ssh root@<this-vps-ip> $(basename "$LOGIN_BIN") akun1
|
|
268
|
+
2. Dashboard > Providers > Google Flow > Import local profiles,
|
|
269
|
+
paste the daemon URL and token above, then Import.
|
|
270
|
+
EOF
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[182],{7651:(e,t,r)=>{"use strict";r.r(t),r.d(t,{default:()=>q});var s=r(95155),a=r(73321),o=r(98500),l=r.n(o),n=r(12115),i=r(35497),d=r(57250),c=r(52679),u=r(28777),m=r(11059),p=r(14051),x=r.n(p),h=r(81277),b=r(66430),f=r(40728);function g({until:e}){let[t,r]=(0,n.useState)("");return((0,n.useEffect)(()=>{let t=()=>{let t=new Date(e).getTime()-Date.now();if(t<=0)return void r("");let s=Math.floor(t/1e3);s<60?r(`${s}s`):s<3600?r(`${Math.floor(s/60)}m ${s%60}s`):r(`${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 y({connection:e,proxyPools:t,isOAuth:r,isFirst:a,isLast:o,onMoveUp:l,onMoveDown:d,onToggleActive:c,onUpdateProxy:u,onEdit:m,onDelete:p}){let[x,b]=(0,n.useState)(!1),[f,v]=(0,n.useState)(!1),j=(0,n.useRef)(null),w=new Map((t||[]).map(e=>[e.id,e])),N=e.providerSpecificData?.proxyPoolId||null,k=N?w.get(N):null,C=e.providerSpecificData?.connectionProxyEnabled===!0&&!!e.providerSpecificData?.connectionProxyUrl,S=!!N||C,_=k?`Pool: ${k.name}`:N?`Pool: ${N} (inactive/missing)`:C?`Legacy: ${e.providerSpecificData?.connectionProxyUrl}`:"",$="",E=k?.proxyUrl||e.providerSpecificData?.connectionProxyUrl;if(E)try{let e=new URL(E);$=`${e.protocol}//${e.hostname}${e.port?`:${e.port}`:""}`}catch{$=E}let T=k?.noProxy||e.providerSpecificData?.connectionNoProxy||"",R=k?.isActive===!0?"success":N||C?"error":"default",O=(0,h.c)(e),I=null!==O;(0,n.useEffect)(()=>{if(!x)return;let e=e=>{j.current&&!j.current.contains(e.target)&&b(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[x]);let P="unavailable"!==e.testStatus||I?e.testStatus:"active",A=r?e.name||e.email||e.displayName||"OAuth Account":e.name,D=async e=>{v(!0);try{await u("__none__"===e?null:e)}finally{v(!1),b(!1)}};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:d,disabled:o,className:`p-0.5 rounded ${o?"text-text-muted/30 cursor-not-allowed":"hover:bg-sidebar text-text-muted hover:text-primary"}`,children:(0,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:r?"lock":"key"}),(0,s.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,s.jsx)("p",{className:"text-sm font-medium truncate",children:A}),(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-2 mt-1",children:[(0,s.jsx)(i.Ex,{variant:!1===e.isActive?"default":"active"===P||"success"===P?"success":"error"===P||"expired"===P||"unavailable"===P?"error":"default",size:"sm",dot:!0,children:!1===e.isActive?"disabled":P||"Unknown"}),S&&(0,s.jsx)(i.Ex,{variant:R,size:"sm",children:"Proxy"}),I&&!1!==e.isActive&&(0,s.jsx)(g,{until:O}),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]})]}),S&&(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:_,children:_}),$&&(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:$}),T&&(0,s.jsxs)("span",{className:"text-[11px] text-text-muted truncate max-w-[320px]",title:T,children:["no_proxy: ",T]})]})]})]}),(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:[(t||[]).length>0&&(0,s.jsxs)("div",{className:"relative",ref:j,children:[(0,s.jsxs)("button",{onClick:()=>b(e=>!e),className:`flex flex-col items-center px-2 py-1 rounded hover:bg-black/5 dark:hover:bg-white/5 transition-colors ${S?"text-primary":"text-text-muted hover:text-primary"}`,disabled:f,children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:f?"progress_activity":"lan"}),(0,s.jsx)("span",{className:"text-[10px] leading-tight",children:"Proxy"})]}),x&&(0,s.jsxs)("div",{className:"absolute right-0 top-full mt-1 z-50 bg-bg border border-border rounded-lg shadow-lg py-1 min-w-[160px]",children:[(0,s.jsx)("button",{onClick:()=>D("__none__"),className:`w-full text-left px-3 py-1.5 text-sm hover:bg-black/5 dark:hover:bg-white/5 ${!N?"text-primary font-medium":"text-text-main"}`,children:"None"}),(t||[]).map(e=>(0,s.jsx)("button",{onClick:()=>D(e.id),className:`w-full text-left px-3 py-1.5 text-sm hover:bg-black/5 dark:hover:bg-white/5 ${N===e.id?"text-primary font-medium":"text-text-main"}`,children:e.name},e.id))]})]}),(0,s.jsxs)("button",{onClick:m,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:p,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)(i.lM,{size:"sm",checked:e.isActive??!0,onChange:c,title:e.isActive??!0?"Disable":"Enable"})]})]})}function v({isOpen:e,provider:t,providerName:r,proxyPools:a,onSave:o,onClose:l}){let d="__none__",c="flow"===t,[u,m]=(0,n.useState)({name:"",apiKey:"",priority:1,proxyPoolId:d,flowProfile:"",flowBaseUrl:"http://127.0.0.1:8077/mcp",flowI2vReady:!1}),[p,x]=(0,n.useState)(!1),[h,b]=(0,n.useState)(null),[f,g]=(0,n.useState)(!1),y=c?{profile:u.flowProfile.trim(),baseUrl:u.flowBaseUrl.trim(),i2vReady:u.flowI2vReady}:void 0,j=async()=>{x(!0);try{let e=await fetch("/api/providers/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:t,apiKey:u.apiKey,providerSpecificData:y})}),r=await e.json();b(r.valid?"success":"failed")}catch{b("failed")}finally{x(!1)}},w=async()=>{if(t&&u.apiKey&&(!c||u.flowProfile.trim())){g(!0);try{let e=!1;try{x(!0),b(null);let r=await fetch("/api/providers/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:t,apiKey:u.apiKey,providerSpecificData:y})});e=!!(await r.json()).valid,b(e?"success":"failed")}catch{b("failed")}finally{x(!1)}await o({name:u.name,apiKey:u.apiKey,priority:u.priority,proxyPoolId:c||u.proxyPoolId===d?null:u.proxyPoolId,testStatus:e?"active":"unknown",providerSpecificData:y})}finally{g(!1)}}};return t?(0,s.jsx)(i.aF,{isOpen:e,title:c?"Add Google Flow Account":`Add ${r||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:c?"Account name":"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:u.name,onChange:e=>m({...u,name:e.target.value}),placeholder:c?"Google account email":"Production Key"})]}),c&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"text-xs text-text-muted mb-1 block",children:"gflow profile"}),(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 font-mono",value:u.flowProfile,onChange:e=>m({...u,flowProfile:e.target.value}),placeholder:"from: gflow auth list"})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"text-xs text-text-muted mb-1 block",children:"Daemon URL"}),(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 font-mono",value:u.flowBaseUrl,onChange:e=>m({...u,flowBaseUrl:e.target.value})})]}),(0,s.jsxs)("label",{className:"flex items-start gap-2 text-sm text-text-main",children:[(0,s.jsx)("input",{type:"checkbox",checked:u.flowI2vReady,onChange:e=>m({...u,flowI2vReady:e.target.checked}),className:"mt-1"}),(0,s.jsxs)("span",{children:["I2V upload consent confirmed ",(0,s.jsx)("span",{className:"block text-xs text-text-muted",children:"Required for 20–60s videos. Enable after accepting Google's image-rights dialog once for this profile."})]})]})]}),(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:c?"Daemon token":"API Key"}),(0,s.jsx)("input",{type:"password",className:"w-full px-3 py-2 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary",value:u.apiKey,onChange:e=>m({...u,apiKey:e.target.value})})]}),(0,s.jsx)("div",{className:"pt-6",children:(0,s.jsx)(i.$n,{onClick:j,disabled:!u.apiKey||c&&!u.flowProfile.trim()||p||f,variant:"secondary",children:p?"Checking...":"Check"})})]}),h&&(0,s.jsx)(i.Ex,{variant:"success"===h?"success":"error",children:"success"===h?"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",className:"w-full px-3 py-2 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary",value:u.priority,onChange:e=>m({...u,priority:Number.parseInt(e.target.value)||1})})]}),!c&&(0,s.jsx)(i.l6,{label:"Proxy Pool",value:u.proxyPoolId,onChange:e=>m({...u,proxyPoolId:e.target.value}),options:[{value:d,label:"None"},...(a||[]).map(e=>({value:e.id,label:e.name}))]}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(i.$n,{onClick:w,fullWidth:!0,disabled:!u.name||!u.apiKey||c&&!u.flowProfile.trim()||f,children:f?"Saving...":"Save"}),(0,s.jsx)(i.$n,{onClick:l,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})}):null}function j({isOpen:e,onImported:t,onClose:r}){let[a,o]=(0,n.useState)(""),[l,d]=(0,n.useState)("http://127.0.0.1:8077/mcp"),[c,u]=(0,n.useState)(!1),[m,p]=(0,n.useState)(!1),[x,h]=(0,n.useState)(null),[b,f]=(0,n.useState)(""),g=async()=>{if(a.trim()){p(!0),f(""),h(null);try{let e=await fetch("/api/providers/flow/import",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({daemonToken:a,baseUrl:l,i2vReady:c})}),r=await e.json();if(!e.ok)throw Error(r.error||"Flow profile import failed");h(r),o(""),await t()}catch(e){f(e?.message||"Flow profile import failed")}finally{p(!1)}}};return e?(0,s.jsx)(i.aF,{isOpen:!0,title:"Import local gflow profiles",onClose:r,children:(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,s.jsxs)("p",{className:"text-sm text-text-muted",children:["Imports profile names from ",(0,s.jsx)("code",{children:"gflow auth list"}),". Google cookies stay inside gflow and are never copied into zevairouter."]}),(0,s.jsx)(i.pd,{label:"Daemon URL",value:l,onChange:e=>d(e.target.value),placeholder:"http://127.0.0.1:8077/mcp"}),(0,s.jsx)(i.pd,{label:"Daemon token",type:"password",value:a,onChange:e=>o(e.target.value),placeholder:"GFLOW_DAEMON_TOKEN",required:!0}),(0,s.jsxs)("label",{className:"flex items-start gap-2 text-sm text-text-main",children:[(0,s.jsx)("input",{type:"checkbox",checked:c,onChange:e=>u(e.target.checked),className:"mt-1"}),(0,s.jsxs)("span",{children:["I2V upload consent confirmed for every imported profile ",(0,s.jsx)("span",{className:"block text-xs text-text-muted",children:"Enable only after each account accepted Google's image-rights dialog. Required for 20–60s videos."})]})]}),x&&(0,s.jsxs)("div",{className:"rounded-lg border border-green-500/30 bg-green-500/10 p-3 text-sm",children:["Imported ",x.imported?.length||0," profile(s); validated ",(0,s.jsx)("code",{children:x.validatedProfile}),".",(x.skipped?.length||0)>0&&(0,s.jsxs)("div",{className:"mt-1 text-text-muted",children:["Skipped ",x.skipped.length," profile(s) without saved cookies."]})]}),b&&(0,s.jsx)("p",{className:"text-sm text-red-500 break-words",children:b}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(i.$n,{onClick:g,fullWidth:!0,disabled:!a.trim()||m,children:m?"Importing...":"Import profiles"}),(0,s.jsx)(i.$n,{onClick:r,variant:"ghost",fullWidth:!0,children:x?"Done":"Cancel"})]})]})}):null}function w({providerId:e,isOAuth:t}){let[r,a]=(0,n.useState)([]),[o,l]=(0,n.useState)([]),[d,c]=(0,n.useState)(!0),[u,m]=(0,n.useState)(""),[p,x]=(0,n.useState)(!1),[h,g]=(0,n.useState)(!1),[N,k]=(0,n.useState)(!1),[C,S]=(0,n.useState)(null),[_,$]=(0,n.useState)(null),[E,T]=(0,n.useState)("1"),R=(0,n.useRef)(null),O=(0,n.useRef)("1"),[I,P]=(0,n.useState)(null),A=async e=>{if(!e.ok)return null;try{return await e.json()}catch{return null}},D=(0,n.useCallback)(async()=>{try{let[t,r,s]=await Promise.all([(0,b.b7)("providers:list",f.t7),fetch("/api/proxy-pools?isActive=true",{cache:"no-store"}),fetch("/api/settings",{cache:"no-store"})]),o=await A(r),n=await A(s)||{},i=null===t,d=null===o;i||a((t.connections||[]).filter(t=>t.provider===e)),d||l(o.proxyPools||[]),i||d?m("Connection data could not be loaded. Check that the server is running, then retry."):m("");let c=(n.providerStrategies||{})[e]||{};$(c.fallbackStrategy||null),T(null!=c.stickyRoundRobinLimit?String(c.stickyRoundRobinLimit):"1"),O.current=null!=c.stickyRoundRobinLimit?String(c.stickyRoundRobinLimit):"1"}catch(e){console.log("ConnectionsCard fetch error:",e),m("Connection data could not be loaded. Check that the server is running, then retry.")}finally{c(!1)}},[e]);(0,n.useEffect)(()=>{D()},[D]);let L=async(t,r)=>{try{let s=await fetch("/api/settings",{cache:"no-store"}),a=(s.ok?await s.json():{}).providerStrategies||{},o={};t&&(o.fallbackStrategy=t),"round-robin"===t&&""!==r&&(o.stickyRoundRobinLimit=Number(r)||3);let l={...a};0===Object.keys(o).length?delete l[e]:l[e]=o,await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerStrategies:l})})}catch(e){console.log("saveStrategy error:",e)}},M=async(e,t)=>{let s=[...r];[s[e],s[t]]=[s[t],s[e]],a(s);try{let[r,a]=await Promise.all([fetch(`/api/providers/${s[e].id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({priority:e+1})}),fetch(`/api/providers/${s[t].id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({priority:t+1})})]);r.ok&&a.ok?(0,b.au)("providers:list"):await D()}catch{await D()}},U=async e=>{P({title:"Delete Connection",message:"Delete this connection?",onConfirm:async()=>{P(null);try{(await fetch(`/api/providers/${e}`,{method:"DELETE"})).ok&&(a(t=>t.filter(t=>t.id!==e)),(0,b.au)("providers:list"))}catch(e){console.log("delete error:",e)}}})},K=async(e,t)=>{try{(await fetch(`/api/providers/${e}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({isActive:t})})).ok&&(a(r=>r.map(r=>r.id===e?{...r,isActive:t}:r)),(0,b.au)("providers:list"))}catch(e){console.log("toggle error:",e)}},B=async(e,t)=>{try{(await fetch(`/api/providers/${e}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({proxyPoolId:t||null})})).ok&&(a(r=>r.map(r=>r.id===e?{...r,providerSpecificData:{...r.providerSpecificData,proxyPoolId:t||null}}:r)),(0,b.au)("providers:list"))}catch(e){console.log("proxy error:",e)}},F=async t=>{try{(await fetch("/api/providers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:e,...t})})).ok&&((0,b.au)("providers:list"),await D(),x(!1))}catch(e){console.log("save apikey error:",e)}},q=async e=>{try{(await fetch(`/api/providers/${C.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})).ok&&((0,b.au)("providers:list"),await D(),g(!1))}catch(e){console.log("update connection error:",e)}};return d?(0,s.jsx)(i.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)(i.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 flex-wrap items-center gap-2",children:["flow"===e&&(0,s.jsx)(i.$n,{size:"sm",variant:"secondary",icon:"download",onClick:()=>k(!0),children:"Import local profiles"}),(0,s.jsx)("span",{className:"text-xs text-text-muted font-medium",children:"Round Robin"}),(0,s.jsx)(i.lM,{checked:"round-robin"===_,onChange:e=>{let t=e?"round-robin":null;$(t),e&&!E&&T("1");let r=e?E||"1":E;O.current=r,R.current&&(clearTimeout(R.current),R.current=null),L(t,r)}}),"round-robin"===_&&(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:E,onChange:e=>{T(e.target.value),O.current=e.target.value,R.current&&clearTimeout(R.current),R.current=setTimeout(()=>{L("round-robin",O.current)},500)},className:"w-16 px-2 py-1 text-xs border border-border rounded-md bg-background focus:outline-none focus:border-primary"})]})]})]}),u&&(0,s.jsxs)("div",{className:"mb-4 flex flex-col gap-2 rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-600 dark:border-red-800 dark:bg-red-900/20 dark:text-red-400 sm:flex-row sm:items-center sm:justify-between",children:[(0,s.jsx)("span",{children:u}),(0,s.jsx)(i.$n,{size:"sm",variant:"secondary",icon:"refresh",onClick:()=>{c(!0),D()},children:"Retry"})]}),0!==r.length||u?r.length>0&&(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:r.map((e,a)=>(0,s.jsx)(y,{connection:e,proxyPools:o,isOAuth:t,isFirst:0===a,isLast:a===r.length-1,onMoveUp:()=>M(a,a-1),onMoveDown:()=>M(a,a+1),onToggleActive:t=>K(e.id,t),onUpdateProxy:t=>B(e.id,t),onEdit:()=>{S(e),g(!0)},onDelete:()=>U(e.id)},e.id))}),(0,s.jsx)("div",{className:"mt-4 flex justify-stretch sm:justify-start",children:(0,s.jsx)(i.$n,{size:"sm",icon:"add",onClick:()=>x(!0),children:"Add"})})]}):(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.jsxs)("div",{className:"flex gap-2",children:["flow"===e&&(0,s.jsx)(i.$n,{size:"sm",variant:"secondary",icon:"download",onClick:()=>k(!0),children:"Import local profiles"}),(0,s.jsx)(i.$n,{size:"sm",icon:"add",onClick:()=>x(!0),children:"Add manually"})]})]})]}),p&&(0,s.jsx)(v,{isOpen:!0,provider:e,proxyPools:o,onSave:F,onClose:()=>x(!1)}),"flow"===e&&N&&(0,s.jsx)(j,{isOpen:!0,onImported:async()=>{(0,b.au)("providers:list"),await D()},onClose:()=>k(!1)}),h&&C&&(0,s.jsx)(i.wI,{isOpen:!0,connection:C,proxyPools:o,onSave:q,onClose:()=>g(!1)}),I&&(0,s.jsx)(i.uo,{isOpen:!0,onClose:()=>P(null),onConfirm:I.onConfirm,title:I.title||"Confirm",message:I.message,variant:"danger"})]})}function N({model:e,fullModel:t,copied:r,onCopy:a,testStatus:o,isCustom:l,isFree:n,onDeleteAlias:i,onTest:d,isTesting:c}){let u="ok"===o?"#22c55e":"error"===o?"#ef4444":void 0;return(0,s.jsx)("div",{className:`group px-3 py-2 rounded-lg border ${"ok"===o?"border-green-500/40":"error"===o?"border-red-500/40":"border-border"} hover:bg-sidebar/50`,children:(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-base",style:u?{color:u}:void 0,children:"ok"===o?"check_circle":"error"===o?"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:()=>a(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:r===`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:r===`model-${e.id}`?"Copied!":"Copy"})]}),n&&(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"}),l&&(0,s.jsx)("button",{onClick:i,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:r}){let[a,o]=(0,n.useState)(""),l=()=>{a.trim()&&(t(a.trim()),o(""))};return(0,s.jsx)(i.aF,{isOpen:e,title:"Add Custom Model",onClose:r,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:a,onChange:e=>o(e.target.value),onKeyDown:e=>"Enter"===e.key&&l(),placeholder:"e.g. tts-1-hd",autoFocus:!0})]}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(i.$n,{onClick:l,fullWidth:!0,disabled:!a.trim(),children:"Add"}),(0,s.jsx)(i.$n,{onClick:r,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})})}function C({providerId:e,kindFilter:t,providerAliasOverride:r}){let{copied:a,copy:o}=(0,m.C)(),[l,d]=(0,n.useState)({}),[p,x]=(0,n.useState)([]),[h,g]=(0,n.useState)({}),[y,v]=(0,n.useState)(()=>new Set),[j,w]=(0,n.useState)({}),[S,_]=(0,n.useState)(!1),[$,E]=(0,n.useState)([]),T=r||(0,c.wG)(e),R=t||"llm",O=(0,n.useCallback)(async()=>{try{let[t,r,s]=await Promise.all([(0,b.b7)("models:aliases",f.QF),(0,b.b7)("providers:list",f.t7),(0,b.b7)("models:custom",f.Mi)]);d(t.aliases||{}),E((r.connections||[]).filter(t=>t.provider===e)),x(s.models||[])}catch(e){console.log("ModelsCard fetch error:",e)}},[e]);(0,n.useEffect)(()=>{O()},[O]);let I=async(e,t)=>{let r=`${T}/${e}`;try{(await fetch("/api/models/alias",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:r,alias:t})})).ok&&((0,b.au)("models:aliases"),await O())}catch(e){console.log("set alias error:",e)}},P=async e=>{try{(await fetch(`/api/models/alias?alias=${encodeURIComponent(e)}`,{method:"DELETE"})).ok&&((0,b.au)("models:aliases"),await O())}catch(e){console.log("delete alias error:",e)}},A=async e=>{try{(await fetch("/api/models/custom",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerAlias:T,id:e,type:R})})).ok&&((0,b.au)("models:custom"),await O(),window.dispatchEvent(new CustomEvent("customModelChanged")))}catch(e){console.log("add custom model error:",e)}},D=async e=>{try{let t=new URLSearchParams({providerAlias:T,id:e,type:R});(await fetch(`/api/models/custom?${t}`,{method:"DELETE"})).ok&&((0,b.au)("models:custom"),await O(),window.dispatchEvent(new CustomEvent("customModelChanged")))}catch(e){console.log("delete custom model error:",e)}},L=async e=>{v(t=>new Set(t).add(e));try{let r=await fetch("/api/models/test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:`${T}/${e}`,kind:t})}),s=await r.json();g(t=>({...t,[e]:s.ok?"ok":"error"})),w(t=>({...t,[e]:s.ok?"":s.error||"Model not reachable"}))}catch{g(t=>({...t,[e]:"error"})),w(t=>({...t,[e]:"Network error"}))}finally{v(t=>{let r=new Set(t);return r.delete(e),r})}},M=(0,u.KC)(e),U=t?M.filter(e=>e.kinds?e.kinds.includes(t):(e.type||"llm")===t):M,K=p.filter(e=>e.providerAlias===T&&(e.type||"llm")===R&&!U.some(t=>t.id===e.id)),B=(0,n.useMemo)(()=>{let e={};for(let[t,r]of Object.entries(l))r in e||(e[r]=t);return e},[l]);return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)(i.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()}`:""]})}),Object.values(j).some(Boolean)&&(0,s.jsx)("div",{className:"mb-3 space-y-1",children:Object.entries(j).filter(([,e])=>!!e).map(([e,t])=>(0,s.jsxs)("p",{className:"break-words text-xs text-red-500",children:[e,": ",t]},e))}),(0,s.jsxs)("div",{className:"flex flex-wrap gap-3",children:[U.map(e=>{let t=B[`${T}/${e.id}`];return(0,s.jsx)(N,{model:e,fullModel:`${T}/${e.id}`,alias:t,copied:a,onCopy:o,onSetAlias:t=>I(e.id,t),onDeleteAlias:()=>P(t),testStatus:h[e.id],onTest:$.length>0?()=>L(e.id):void 0,isTesting:y.has(e.id),isFree:e.isFree},e.id)}),K.map(e=>(0,s.jsx)(N,{model:{id:e.id,name:e.name},fullModel:`${T}/${e.id}`,copied:a,onCopy:o,onSetAlias:()=>{},onDeleteAlias:()=>D(e.id),testStatus:h[e.id],onTest:$.length>0?()=>L(e.id):void 0,isTesting:y.has(e.id),isCustom:!0},`${e.id}-${e.type}`)),(0,s.jsxs)("button",{onClick:()=>_(!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:S,onSave:async e=>{await A(e),_(!1)},onClose:()=>_(!1)})]})}g.propTypes={until:x().string.isRequired},y.propTypes={connection:x().shape({id:x().string,name:x().string,email:x().string,displayName:x().string,testStatus:x().string,isActive:x().bool,lastError:x().string,priority:x().number}).isRequired,proxyPools:x().array,isOAuth:x().bool.isRequired,isFirst:x().bool.isRequired,isLast:x().bool.isRequired,onMoveUp:x().func.isRequired,onMoveDown:x().func.isRequired,onToggleActive:x().func.isRequired,onUpdateProxy:x().func,onEdit:x().func.isRequired,onDelete:x().func.isRequired},v.propTypes={isOpen:x().bool.isRequired,provider:x().string,providerName:x().string,proxyPools:x().array,onSave:x().func.isRequired,onClose:x().func.isRequired},j.propTypes={isOpen:x().bool.isRequired,onImported:x().func.isRequired,onClose:x().func.isRequired},w.propTypes={providerId:x().string.isRequired,isOAuth:x().bool},N.propTypes={model:x().shape({id:x().string.isRequired}).isRequired,fullModel:x().string.isRequired,copied:x().string,onCopy:x().func.isRequired,testStatus:x().oneOf(["ok","error"]),isCustom:x().bool,isFree:x().bool,onDeleteAlias:x().func,onTest:x().func,isTesting:x().bool},k.propTypes={isOpen:x().bool.isRequired,onSave:x().func.isRequired,onClose:x().func.isRequired},C.propTypes={providerId:x().string.isRequired,kindFilter:x().string,providerAliasOverride:x().string};let S={"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 _=r(717),$=r(91781),E=r(62199);let T=new Set(["done","failed","completed","error","expired","cancelled"]),R=new Set(["failed","error","expired","cancelled"]);async function O({requestId:e,connectionId:t,signal:r,fetchImpl:s=fetch,pollIntervalMs:a=3e3,timeoutMs:o=6e5,onProgress:l}){if(!e)throw Error("Video response did not include a request id");let n=(0,E.x)(String(e));if(!n)throw Error("Video response included an invalid request id");let i=Date.now()+o;for(;Date.now()<=i;){if(r?.aborted)throw new DOMException("Video polling aborted","AbortError");let e={Accept:"application/json"};t&&(e["x-connection-id"]=t);let o=await s(n,{method:"GET",headers:e,signal:r}),i=await o.json().catch(()=>({}));if(o.ok){let e=String(i?.status||"pending").toLowerCase();if(l?.({status:e,progress:i?.progress}),R.has(e)){let e=i?.error?.message||i?.error||"Video generation failed";throw Error("string"==typeof e?e:JSON.stringify(e))}if(T.has(e))return i}else if(429!==o.status&&503!==o.status){let e=i?.error?.message||i?.error||`Video polling failed (HTTP ${o.status})`;throw Error("string"==typeof e?e:JSON.stringify(e))}await function(e,t){return new Promise((r,s)=>{let a=()=>{clearTimeout(o),s(new DOMException("Video polling aborted","AbortError"))},o=setTimeout(()=>{t?.removeEventListener("abort",a),r()},e);t?.addEventListener("abort",a,{once:!0})})}(a,r)}throw Error("Timed out while waiting for the video job")}function I({label:e,children:t}){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)("span",{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:t})]})}let P=`// Audio will appear here after running.
|
|
2
|
-
// Example JSON response (response_format=json):
|
|
3
|
-
{
|
|
4
|
-
"format": "mp3",
|
|
5
|
-
"audio": "//NExAANaAIIAUAAANNNNNNNN..." // base64 encoded MP3
|
|
6
|
-
}`,A=`{
|
|
7
|
-
"object": "list",
|
|
8
|
-
"data": [{
|
|
9
|
-
"object": "embedding",
|
|
10
|
-
"index": 0,
|
|
11
|
-
"embedding": [0.002301, -0.019212, 0.004815, -0.031249, ...]
|
|
12
|
-
}],
|
|
13
|
-
"model": "...",
|
|
14
|
-
"usage": { "prompt_tokens": 9, "total_tokens": 9 }
|
|
15
|
-
}`,D="https://pub-1fb693cb11cc46b2b2f656f51e015a2c.r2.dev/dog.png";function L(e){let t="string"==typeof e?e.trim():"";return t?/^(data:image\/|https?:\/\/)/i.test(t)?t:`data:image/png;base64,${t}`:""}let M={webSearch:{inputLabel:"Query",inputPlaceholder:"What is the latest news about AI?",defaultInput:"What is the latest news about AI?",bodyKey:"query",defaultResponse:`{
|
|
16
|
-
"results": [
|
|
17
|
-
{ "title": "...", "url": "...", "snippet": "..." }
|
|
18
|
-
]
|
|
19
|
-
}`,extraFields:[{key:"search_type",label:"Type",type:"select",default:"web",options:["web","news"]},{key:"max_results",label:"Max results",type:"number",default:5,min:1,max:100},{key:"country",label:"Country",type:"text",default:""},{key:"language",label:"Language",type:"text",default:""}]},webFetch:{inputLabel:"URL",inputPlaceholder:"https://example.com",defaultInput:"https://example.com",bodyKey:"url",defaultResponse:`{
|
|
20
|
-
"content": "...",
|
|
21
|
-
"title": "...",
|
|
22
|
-
"url": "..."
|
|
23
|
-
}`,extraFields:[{key:"format",label:"Format",type:"select",default:"markdown",options:["markdown","text","html"]},{key:"max_characters",label:"Max chars",type:"number",default:0,min:0}]},image:{inputLabel:"Prompt",inputPlaceholder:"A cute cat wearing a hat",defaultInput:"A cute cat wearing a hat",bodyKey:"prompt",defaultResponse:`{
|
|
24
|
-
"data": [
|
|
25
|
-
{ "url": "...", "b64_json": "..." }
|
|
26
|
-
]
|
|
27
|
-
}`,extraFields:[{key:"n",label:"n",type:"number",default:1,min:1,max:4},{key:"size",label:"Size",type:"select",default:"auto",options:["auto","1024x1024","1024x1536","1536x1024","1024x1792","1792x1024"]},{key:"quality",label:"Quality",type:"select",default:"auto",options:["auto","low","medium","high","standard","hd"]},{key:"background",label:"Background",type:"select",default:"auto",options:["auto","transparent","opaque"]},{key:"style",label:"Style",type:"select",default:"",options:["","vivid","natural"]},{key:"response_format",label:"Format",type:"select",default:"",options:["","url","b64_json"]},{key:"image_detail",label:"Image Detail",type:"select",default:"high",options:["auto","low","high","original"]},{key:"output_format",label:"Codec",type:"select",default:"png",options:["png","jpeg","webp"]}]},imageToText:{inputLabel:"Image URL",inputPlaceholder:"https://example.com/image.png",defaultInput:"https://upload.wikimedia.org/wikipedia/commons/thumb/3/3a/Cat03.jpg/1200px-Cat03.jpg",bodyKey:"url",extraBody:{prompt:"Describe this image in detail"},defaultResponse:`{
|
|
28
|
-
"text": "A cat sitting on a windowsill...",
|
|
29
|
-
"model": "..."
|
|
30
|
-
}`},video:{inputLabel:"Prompt",inputPlaceholder:"A serene lake at sunset",defaultInput:"A serene lake at sunset",bodyKey:"prompt",defaultResponse:`{
|
|
31
|
-
"request_id": "...",
|
|
32
|
-
"status": "pending"
|
|
33
|
-
}`,extraFields:[{key:"duration",label:"Duration",type:"number",default:"",min:1,max:30},{key:"aspect_ratio",label:"Aspect ratio",type:"select",default:"",options:["","16:9","9:16","1:1"]},{key:"resolution",label:"Resolution",type:"select",default:"",options:["","480p","720p","1080p"]}]},music:{inputLabel:"Prompt",inputPlaceholder:"A calm piano melody",defaultInput:"A calm piano melody",bodyKey:"prompt",defaultResponse:`{
|
|
34
|
-
"data": [
|
|
35
|
-
{ "url": "...", "format": "mp3" }
|
|
36
|
-
]
|
|
37
|
-
}`}};function U({providerId:e,customAlias:t}){let r=(0,c.gC)(e),a=r?t||e:(0,c.wG)(e),o=r?[]:(0,u.KC)(e).filter(e=>"embedding"===e.type),[l,d]=(0,n.useState)(o[0]?.id??""),[p,x]=(0,n.useState)("The quick brown fox jumps over the lazy dog"),[h,b]=(0,n.useState)(""),[f,g]=(0,n.useState)(""),[y,v]=(0,n.useState)(!1),[j,w]=(0,n.useState)(""),[N,k]=(0,n.useState)(""),[C,S]=(0,n.useState)(null),[_,$]=(0,n.useState)(!1),[T,R]=(0,n.useState)(""),{copied:O,copy:P}=(0,m.C)(),{copied:D,copy:L}=(0,m.C)();(0,n.useEffect)(()=>{w(window.location.origin),fetch("/api/tunnel/status").then(e=>e.json()).then(e=>{e.publicUrl&&k(e.publicUrl)}).catch(()=>{})},[]);let M=y?N:j,K=l?`${a}/${l}`:"",B=()=>{let e={model:K,input:p.trim()},t=Number(h);return h&&Number.isFinite(t)&&t>0&&(e.dimensions=t),e},F=`curl -X POST ${M}/v1/embeddings \\
|
|
38
|
-
-H "Content-Type: application/json" \\
|
|
39
|
-
-H "Authorization: Bearer ${f||"YOUR_KEY"}" \\
|
|
40
|
-
-d '${JSON.stringify(B())}'`,q=async()=>{if(!p.trim()||!K)return;$(!0),R(""),S(null);let e=Date.now();try{let t={"Content-Type":"application/json"};f&&(t.Authorization=`Bearer ${f}`);let r=await fetch((0,E.O)("/v1/embeddings"),{method:"POST",headers:t,body:JSON.stringify(B())}),s=Date.now()-e,a=await r.json().catch(()=>null);if(!r.ok)return void R(a?.error?.message||a?.error||`HTTP ${r.status}`);if(null==a)return void R("Invalid response from server");S({data:a,latencyMs:s})}catch(e){R(e.message||"Network error")}finally{$(!1)}},J=C?JSON.stringify(C.data,null,2):"";return(0,s.jsxs)(i.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)(I,{label:"Model",children:r?(0,s.jsx)("input",{value:l,onChange:e=>d(e.target.value),placeholder:"e.g. voyage-3, embed-english-v3.0, text-embedding-3-small",className:"w-full px-3 py-1.5 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary font-mono"}):(0,s.jsx)("select",{value:l,onChange:e=>d(e.target.value),className:"w-full px-3 py-1.5 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary",children:o.map(e=>(0,s.jsx)("option",{value:e.id,children:e.name||e.id},e.id))})}),(0,s.jsx)(I,{label:"Endpoint",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)("input",{value:M,onChange:e=>y?k(e.target.value):w(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"}),N&&(0,s.jsxs)("button",{onClick:()=>v(e=>!e),title:y?"Using tunnel":"Using local",className:`flex items-center gap-1 text-xs px-2 py-1.5 rounded-lg border shrink-0 transition-colors ${y?"border-primary/40 bg-primary/10 text-primary":"border-border text-text-muted hover:text-primary"}`,children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"wifi_tethering"}),"Tunnel"]})]})}),(0,s.jsx)(I,{label:"API Key",children:(0,s.jsx)("input",{type:"password",value:f,onChange:e=>g(e.target.value),placeholder:"sk-...",className:"w-full px-3 py-1.5 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary font-mono"})}),(0,s.jsx)(I,{label:"Input",children:(0,s.jsxs)("div",{className:"relative",children:[(0,s.jsx)("input",{value:p,onChange:e=>x(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"}),p&&(0,s.jsx)("button",{type:"button",onClick:()=>x(""),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]",children:"close"})})]})}),(0,s.jsx)(I,{label:"Dimensions",children:(0,s.jsx)("input",{type:"number",min:"1",value:h,onChange:e=>b(e.target.value),placeholder:"optional, e.g. 512, 1024 (leave empty for default)",className:"w-full px-3 py-1.5 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary"})}),(0,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:()=>P(F),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:O?"check":"content_copy"}),O?"Copied":"Copy"]}),(0,s.jsxs)("button",{onClick:q,disabled:_||!p.trim()||!K,className:"flex w-full sm:w-auto items-center justify-center gap-1.5 px-3 py-1 rounded-lg bg-primary text-white text-xs font-medium hover:bg-primary/90 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-[14px]",style:_?{animation:"spin 1s linear infinite"}:void 0,children:"play_arrow"}),_?"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:F})]}),T&&(0,s.jsx)("p",{className:"text-xs text-red-500 break-words",children:T}),(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 ",C&&(0,s.jsxs)("span",{className:"font-normal normal-case",children:["⚡ ",C.latencyMs,"ms"]})]}),C&&(0,s.jsxs)("button",{onClick:()=>L(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:D?"check":"content_copy"}),D?"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 A;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)})(C?.data)})]})]})]})}function K({providerId:e}){let t,r=(0,c.wG)(e),a=S[e]||S["edge-tts"],[o,l]=(0,n.useState)(a.defaultVoiceId||""),[d,p]=(0,n.useState)(""),[x,h]=(0,n.useState)(a.defaultVoiceId||""),[b,f]=(0,n.useState)([]),[g,y]=(0,n.useState)(""),[v,j]=(0,n.useState)(()=>{let t=c.Q2[e]?.ttsConfig?.models;if(t?.length)return t[0].id;if(a.hasModelSelector&&a.modelKey){let e=(0,u.KC)(a.modelKey);return e?.[0]?.id||""}return""}),[w,N]=(0,n.useState)("Hello, this is a text to speech test."),[k,C]=(0,n.useState)(!1),[T,R]=(0,n.useState)(""),[O,A]=(0,n.useState)(""),[D,L]=(0,n.useState)("mp3"),[M,U]=(0,n.useState)(""),[B,F]=(0,n.useState)(null),[q,J]=(0,n.useState)(!1),[V,z]=(0,n.useState)(""),[H,G]=(0,n.useState)(null),{copied:W,copy:Q}=(0,m.C)(),Y=(0,n.useRef)("");(0,n.useEffect)(()=>()=>{if(Y.current)try{URL.revokeObjectURL(Y.current)}catch{}},[]);let[Z,X]=(0,n.useState)(!1),[ee,et]=(0,n.useState)([]),[er,es]=(0,n.useState)(!1),[ea,eo]=(0,n.useState)(""),[el,en]=(0,n.useState)(""),[ei,ed]=(0,n.useState)({}),[ec,eu]=(0,n.useState)("");(0,n.useEffect)(()=>{if(R(window.location.origin),fetch("/api/tunnel/status").then(e=>e.json()).then(e=>{e.publicUrl&&A(e.publicUrl)}).catch(()=>{}),"hardcoded"===a.voiceSource){let t=a.hasModelSelector&&a.modelKey&&(0,u.KC)(a.modelKey)?.[0]?.id||"",r=a.voicesPerModel&&t?(0,_.jY)(e,t)||[]:(0,u.KC)(a.voiceKey||e).filter(e=>"tts"===e.type);if(r.length)if(a.hasBrowseButton){let e=r.find(e=>"en"===e.id)||r[0];y(e.id),l(e.id),p(e.name),f([{id:e.id,name:e.name}])}else f(r),l(r[0].id),p(r[0].name||r[0].id)}},[e]),(0,n.useEffect)(()=>{if(!a.voicesPerModel||!v)return;let t=(0,_.jY)(e,v)||[];f(t),t.length&&(l(t[0].id),p(t[0].name||t[0].id))},[v]);let em=async()=>{if(X(!0),eo(""),en(""),!ee.length){es(!0);try{if("hardcoded"===a.voiceSource){let t=a.voiceKey||e,r=(0,u.KC)(t).filter(e=>"tts"===e.type),s={};for(let e of r)s[e.id]||(s[e.id]={code:e.id,name:e.name,voices:[{id:e.id,name:e.name}]});ed(s),et(Object.values(s).sort((e,t)=>e.name.localeCompare(t.name)))}else{let t=a.apiEndpoint?a.apiEndpoint:`/api/media-providers/tts/voices?provider=${"local-device"===e?"local-device":"edge-tts"}`,r=await fetch(t),s=await r.json();if(s.error)return void en(s.error);et(s.languages||[]),ed(s.byLang||{})}}catch(e){en(e.message)}finally{es(!1)}}},ep=ea?ee.filter(e=>e.name.toLowerCase().includes(ea.toLowerCase())||e.code.toLowerCase().includes(ea.toLowerCase())):ee,ex=k?O:T,eh=a.hasVoiceIdInput&&x||o,eb=a.hasModelSelector&&v&&eh?`${r}/${v}/${eh}`:a.hasModelSelector&&v?`${r}/${v}`:eh?`${r}/${eh}`:"",ef=(t={model:eb,input:w},a.hasLanguageHint&&ec&&(t.language=ec),t),eg=`curl -X POST ${ex}/v1/audio/speech${"json"===D?"?response_format=json":""} \\
|
|
41
|
-
-H "Content-Type: application/json" \\
|
|
42
|
-
-H "Authorization: Bearer YOUR_KEY" \\
|
|
43
|
-
-d '${JSON.stringify(ef)}' \\
|
|
44
|
-
${"json"===D?"":"--output speech.mp3"}`,ey=async()=>{if(!w.trim()||!eb)return;if(J(!0),z(""),Y.current){try{URL.revokeObjectURL(Y.current)}catch{}Y.current=""}U(""),F(null);let e=Date.now();try{let t=(0,E.O)(`/v1/audio/speech${"json"===D?"?response_format=json":""}`),r=await fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...ef,input:w.trim()})});if(G(Date.now()-e),!r.ok){let e=await r.json().catch(()=>({}));z(e?.error?.message||e?.error||`HTTP ${r.status}`);return}if("json"===D){let e=await r.json().catch(()=>null);if(!e||"string"!=typeof e.audio||!e.audio)return void z(e?.error?.message||e?.error||"TTS response did not include audio data");F(e);let t=await fetch(`data:audio/mp3;base64,${e.audio}`).then(e=>e.blob()),s=URL.createObjectURL(t);Y.current=s,U(s)}else{let e=await r.blob(),t=URL.createObjectURL(e);Y.current=t,U(t)}}catch(e){z(e.message||"Network error")}finally{J(!1)}};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)(i.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)(I,{label:"Endpoint",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.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:[ex,"/v1/audio/speech"]}),O&&(0,s.jsxs)("button",{onClick:()=>C(e=>!e),title:k?"Using tunnel":"Using local",className:`flex items-center gap-1 text-xs px-2 py-1.5 rounded-lg border shrink-0 transition-colors ${k?"border-primary/40 bg-primary/10 text-primary":"border-border text-text-muted hover:text-primary"}`,children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"wifi_tethering"}),"Tunnel"]})]})}),(0,s.jsx)(I,{label:"API Key",children:(0,s.jsx)("span",{className:"px-3 py-1.5 text-sm font-mono text-text-main bg-sidebar rounded-lg truncate block",children:(0,s.jsx)("span",{className:"text-text-muted italic",children:"Dashboard session (server-side)"})})}),a.hasModelSelector&&(a.modelKey||c.Q2[e]?.ttsConfig?.models?.length)&&(0,s.jsx)(I,{label:"Model",children:(0,s.jsx)("select",{value:v,onChange:e=>j(e.target.value),className:"w-full px-3 py-1.5 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary",children:((c.Q2[e]?.ttsConfig?.models?.length?c.Q2[e].ttsConfig.models:(0,u.KC)(a.modelKey))||[]).map(e=>(0,s.jsx)("option",{value:e.id,children:e.name||e.id},e.id))})}),a.hasLanguageHint&&(0,s.jsx)(I,{label:"Language",children:(0,s.jsxs)("select",{value:ec,onChange:e=>eu(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"}),$.I.map(e=>(0,s.jsx)("option",{value:e.name,children:e.name},e.id))]})}),a.hasBrowseButton&&(0,s.jsx)(I,{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:em,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:ee.find(e=>e.code===g)?.name||g}):(0,s.jsx)("span",{className:"text-text-muted",children:"No language selected"})}),(0,s.jsxs)("button",{onClick:em,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"]})]})}),b.length>0&&(0,s.jsx)(I,{label:"Voice",children:(0,s.jsx)("div",{className:"flex flex-wrap gap-1.5",children:b.map(e=>(0,s.jsxs)("button",{onClick:()=>{l(e.id),p(e.name),a.hasVoiceIdInput&&h(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))})}),a.hasVoiceIdInput&&(0,s.jsx)(I,{label:"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",{value:x,onChange:e=>{h(e.target.value),l(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"}),x&&(0,s.jsx)("button",{type:"button",onClick:()=>{h(""),l("")},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]",children:"close"})})]})})}),a.hasLanguageDropdown&&(0,s.jsx)(I,{label:"Language",children:(0,s.jsx)("select",{value:o,onChange:t=>{let r=(0,u.KC)(e).filter(e=>"tts"===e.type).find(e=>e.id===t.target.value);l(t.target.value),p(r?.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,u.KC)(e).filter(e=>"tts"===e.type).map(e=>(0,s.jsx)("option",{value:e.id,children:e.name||e.id},e.id))})}),(0,s.jsx)(I,{label:"Input",children:(0,s.jsxs)("div",{className:"relative",children:[(0,s.jsx)("input",{value:w,onChange:e=>N(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"}),w&&(0,s.jsx)("button",{type:"button",onClick:()=>N(""),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]",children:"close"})})]})}),(0,s.jsx)(I,{label:"Output Format",children:(0,s.jsxs)("select",{value:D,onChange:e=>L(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:()=>Q(eg),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:W?"check":"content_copy"}),W?"Copied":"Copy"]}),(0,s.jsxs)("button",{onClick:ey,disabled:q||!w.trim()||!eb,className:"flex w-full sm:w-auto items-center justify-center gap-1.5 px-3 py-1 rounded-lg bg-primary text-white text-xs font-medium hover:bg-primary/90 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-[14px]",style:q?{animation:"spin 1s linear infinite"}:void 0,children:"play_arrow"}),q?"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:eg})]}),V&&(0,s.jsx)("p",{className:"text-xs text-red-500 break-words",children:V}),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 ",H&&(0,s.jsxs)("span",{className:"font-normal normal-case",children:["⚡ ",H,"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"}),B&&(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:B.format,audio:B.audio?`${B.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})]})]})]}),Z&&(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:()=>X(!1),children:(0,s.jsxs)("div",{className:"border border-border rounded-xl shadow-2xl w-full max-w-md mx-4 flex flex-col max-h-[80vh]",style:{backgroundColor:"var(--color-bg)",isolation:"isolate"},onClick:e=>e.stopPropagation(),children:[(0,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",{className:"text-sm font-semibold",children:"Select Language"}),(0,s.jsx)("button",{onClick:()=>X(!1),className:"text-text-muted hover:text-primary transition-colors",children:(0,s.jsx)("span",{className:"material-symbols-outlined text-[20px]",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,value:ea,onChange:e=>eo(e.target.value),placeholder:"Search language...",className:"w-full px-3 py-1.5 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary"})}),(0,s.jsxs)("div",{className:"overflow-y-auto flex-1 p-2",children:[el&&(0,s.jsx)("p",{className:"text-xs text-red-500 px-2 py-1",children:el}),er?(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:[ep.map(e=>(0,s.jsxs)("button",{onClick:()=>{let t;return X(!1),y(e.code),void(f(t=ei[e.code]?.voices||[]),t.length&&(l(t[0].id),p(t[0].name),a.hasVoiceIdInput&&h(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===ep.length&&(0,s.jsx)("p",{className:"text-xs text-text-muted px-2 py-3",children:"No languages found."})]})]})]})})]})}function B({providerId:e,kind:t}){var r;let a=(0,c.wG)(e),o=(0,c.rs)(a)===e?a:e,l=c.rj.find(e=>e.id===t),d=M[t],p=d||{},x=(0,u.KC)(e).filter(e=>e.type===t),h=new Set(["image","video","music","imageToText"]).has(t),b=h&&0===x.length,[f,g]=(0,n.useState)(x[0]?.id??""),y=x.find(e=>e.id===f),v=!!y?.capabilities?.includes("edit"),j=!!y?.capabilities?.includes("mask"),[w,N]=(0,n.useState)(p.defaultInput||""),[k,C]=(0,n.useState)(""),[S,_]=(0,n.useState)(""),[$,T]=(0,n.useState)(()=>(p.extraFields||[]).reduce((e,t)=>(e[t.key]=t.default??"",e),{})),[R,P]=(0,n.useState)(!1),[A,U]=(0,n.useState)(""),[K,F]=(0,n.useState)(""),[q,J]=(0,n.useState)(null),[V,z]=(0,n.useState)(null),[H,G]=(0,n.useState)(null),[W,Q]=(0,n.useState)("json"),[Y,Z]=(0,n.useState)(""),[X,ee]=(0,n.useState)(!1),[et,er]=(0,n.useState)(""),[es,ea]=(0,n.useState)([]),[eo,el]=(0,n.useState)(""),{copied:en,copy:ei}=(0,m.C)(),{copied:ed,copy:ec}=(0,m.C)(),eu=(0,n.useRef)(null);if((0,n.useEffect)(()=>()=>{eu.current?.abort()},[]),(0,n.useEffect)(()=>{U(window.location.origin),fetch("/api/tunnel/status").then(e=>e.json()).then(e=>{e.publicUrl&&F(e.publicUrl)}).catch(()=>{}),fetch("/api/providers/client").then(e=>e.json()).then(t=>{ea((t.connections||[]).filter(t=>t.provider===e&&!1!==t.isActive))}).catch(()=>{})},[e]),!l||!d)return null;let em=R?K:A,ep=l.endpoint.path,ex=h?f?`${o}/${f}`:b?"":o:o,eh="cloudflare-ai"!==e?{}:"@cf/runwayml/stable-diffusion-v1-5-img2img"===f?{image:D}:"@cf/runwayml/stable-diffusion-v1-5-inpainting"===f?{image:D,mask_image:"https://pub-1fb693cb11cc46b2b2f656f51e015a2c.r2.dev/dog-mask.png"}:{},eb=k.trim()||eh.image||"",ef=S.trim()||eh.mask_image||"",eg=L(eb),ey=L(ef),ev=Object.entries($).reduce((e,[t,r])=>(""===r||null==r||"number"==typeof r&&Number.isNaN(r)||(e[t]=r),e),{}),ej={model:ex,[d.bodyKey]:w,...d.extraBody,...ev,...v&&eb?{image:eb}:{},...j&&ef?{mask_image:ef}:{}},ew="image"===t&&"binary"===W,eN="image"===t&&"codex"===e&&!ew,ek=`${ep}${ew?"?response_format=binary":""}`,eC=(0,E.O)(ek),eS=`-H "Content-Type: application/json" \\
|
|
45
|
-
-H "Authorization: Bearer YOUR_KEY"${eo?` \\
|
|
46
|
-
-H "x-connection-id: ${eo}"`:""}${eN?` \\
|
|
47
|
-
-H "Accept: text/event-stream"`:""}`,e_=`curl -X ${l.endpoint.method} ${em}${ek} \\
|
|
48
|
-
${eS.replace(/\\\n /g,"\\\n ")} \\
|
|
49
|
-
-d '${JSON.stringify(ej)}'${ew?" \\\n --output image.png":""}`,e$=async()=>{if(!eC)return void er("Not supported by this router build");if(!w.trim()||!ex)return;if(ee(!0),er(""),J(null),z(null),G(null),Y){try{URL.revokeObjectURL(Y)}catch{}Z("")}let e=Date.now();try{let r={"Content-Type":"application/json"};eo&&(r["x-connection-id"]=eo),eN&&(r.Accept="text/event-stream");let s={...ej,model:ex},a=await fetch(eC,{method:l.endpoint.method,headers:r,body:JSON.stringify(s)});if(!a.ok){let e=await a.json().catch(()=>({}));er(e?.error?.message||e?.error||`HTTP ${a.status}`);return}let o=a.headers.get("content-type")||"";if(o.startsWith("image/")){let t=await a.blob(),r=URL.createObjectURL(t);Z(r),J({data:{binary:!0,mime:o,size:t.size},latencyMs:Date.now()-e});return}if(o.includes("text/event-stream")&&a.body){let t=new AbortController;eu.current=t;let r=a.body.getReader(),s=()=>{r.cancel().catch(()=>{})};t.signal.addEventListener("abort",s,{once:!0});let o=new TextDecoder,l="",n=null,i=null;try{for(;;){let e;if(t.signal.aborted)return;let{done:s,value:a}=await r.read();if(s)break;for(l+=o.decode(a,{stream:!0});-1!==(e=l.indexOf("\n\n"));){let t=l.slice(0,e);l=l.slice(e+2);let r=null,s="";for(let e of t.split("\n"))e.startsWith("event:")?r=e.slice(6).trim():e.startsWith("data:")&&(s+=e.slice(5).trim());if(r)try{let e=s?JSON.parse(s):{};"progress"===r?z(e):"partial_image"===r?G(e):"done"===r?n=e:"error"===r&&(i=e?.message||"Stream error")}catch{}}}}catch(e){if(t.signal.aborted)return;throw e}finally{t.signal.removeEventListener("abort",s),eu.current===t&&(eu.current=null)}let d=Date.now()-e;if(i)return void er(i);n&&J({data:n,latencyMs:d})}else{let r=await a.json();if("video"===t&&r?.request_id){let t=new AbortController;eu.current=t;let s=a.headers.get("x-zevai-connection-id")||a.headers.get("x-connection-id")||eo;try{let a=await O({requestId:String(r.request_id),connectionId:s,signal:t.signal,timeoutMs:18e5,onProgress:({status:e,progress:t})=>{z({stage:e,percent:t})}});J({data:{...r,...a,request_id:r.request_id},latencyMs:Date.now()-e})}finally{eu.current===t&&(eu.current=null)}return}let s=Date.now()-e;J({data:r,latencyMs:s})}}catch(e){if(e?.name==="AbortError")return;er(e.message||"Network error")}finally{ee(!1)}},eE=e=>{if(!e||"object"!=typeof e)return e;if(Array.isArray(e))return e.map(eE);let t={};for(let[r,s]of Object.entries(e))t[r]="b64_json"===r&&"string"==typeof s&&s.length>100?`<${s.length} chars base64>`:eE(s);return t},eT=q?JSON.stringify(eE(q.data),null,2):"",eR="video"===t?(r=q?.data,r?.video?.url||r?.video?.file_output?.public_url||r?.data?.[0]?.url||""):"";return(0,s.jsxs)(i.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:[x.length>0?(0,s.jsx)(I,{label:"Model",children:(0,s.jsx)("select",{value:f,onChange:e=>g(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:x.map(e=>(0,s.jsx)("option",{value:e.id,children:e.name||e.id},e.id))})}):b?(0,s.jsx)(I,{label:"Model",children:(0,s.jsx)("input",{value:f,onChange:e=>g(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)(I,{label:"Endpoint",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.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:[em,ep]}),K&&(0,s.jsxs)("button",{onClick:()=>P(e=>!e),title:R?"Using tunnel":"Using local",className:`flex items-center gap-1 text-xs px-2 py-1.5 rounded-lg border shrink-0 transition-colors ${R?"border-primary/40 bg-primary/10 text-primary":"border-border text-text-muted hover:text-primary"}`,children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"wifi_tethering"}),"Tunnel"]})]})}),(0,s.jsx)(I,{label:"API Key",children:(0,s.jsx)("span",{className:"px-3 py-1.5 text-sm font-mono text-text-main bg-sidebar rounded-lg truncate block",children:(0,s.jsx)("span",{className:"text-text-muted italic",children:"Dashboard session (server-side)"})})}),es.length>0&&(0,s.jsx)(I,{label:"Connection",children:(0,s.jsxs)("select",{value:eo,onChange:e=>el(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)"}),es.map(e=>{let t=e.providerSpecificData?.chatgptPlanType,r=e.email||e.name||e.id.slice(0,8);return(0,s.jsxs)("option",{value:e.id,children:[r,t?` [${t}]`:""]},e.id)})]})}),(0,s.jsx)(I,{label:d.inputLabel,children:(0,s.jsxs)("div",{className:"relative",children:[(0,s.jsx)("input",{value:w,onChange:e=>N(e.target.value),placeholder:d.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"}),w&&(0,s.jsx)("button",{type:"button",onClick:()=>N(""),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]",children:"close"})})]})}),v&&(0,s.jsx)(I,{label:"Ref Image (URL)",children:(0,s.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,s.jsxs)("div",{className:"relative",children:[(0,s.jsx)("input",{value:k,onChange:e=>C(e.target.value),placeholder:eh.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"}),k&&(0,s.jsx)("button",{type:"button",onClick:()=>C(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-text-muted hover:text-primary transition-colors",children:(0,s.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"close"})})]}),eg&&(0,s.jsx)("img",{src:eg,alt:"Reference",className:"max-h-40 rounded-lg border border-border object-contain bg-sidebar",onError:e=>{e.currentTarget.style.display="none"},onLoad:e=>{e.currentTarget.style.display="block"}})]})}),j&&(0,s.jsx)(I,{label:"Mask (URL)",children:(0,s.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,s.jsxs)("div",{className:"relative",children:[(0,s.jsx)("input",{value:S,onChange:e=>_(e.target.value),placeholder:eh.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"}),S&&(0,s.jsx)("button",{type:"button",onClick:()=>_(""),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]",children:"close"})})]}),ey&&(0,s.jsx)("img",{src:ey,alt:"Mask",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"}})]})}),(d.extraFields||[]).filter(e=>0===x.length||Array.isArray(y?.params)&&y.params.includes(e.key)).map(e=>(0,s.jsx)(I,{label:e.label,children:"select"===e.type?(0,s.jsx)("select",{value:$[e.key]??"",onChange:t=>T(r=>({...r,[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",{type:"text",value:$[e.key]??"",placeholder:e.placeholder,onChange:t=>T(r=>({...r,[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",{type:"number",value:$[e.key]??"",min:e.min,max:e.max,onChange:t=>T(r=>({...r,[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)(I,{label:"Output Format",children:(0,s.jsxs)("select",{value:W,onChange:e=>Q(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:[eC&&(0,s.jsxs)("button",{onClick:()=>ei(e_),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:en?"check":"content_copy"}),en?"Copied":"Copy"]}),(0,s.jsxs)("button",{onClick:e$,disabled:!eC||X||!w.trim()||!ex,title:eC?void 0:"Not supported by this router build",className:"flex w-full sm:w-auto items-center justify-center gap-1.5 px-3 py-1 rounded-lg bg-primary text-white text-xs font-medium hover:bg-primary/90 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-[14px]",style:X?{animation:"spin 1s linear infinite"}:void 0,children:"play_arrow"}),eC?X?"Running...":"Run":"Unavailable"]})]})]}),eC?(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:e_}):(0,s.jsx)("div",{className:"rounded-lg border border-border bg-sidebar px-3 py-2.5 text-xs text-text-muted",children:"Not supported by this router build"})]}),(X||V)&&eN&&(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:X?{animation:"spin 1s linear infinite"}:void 0,children:X?"progress_activity":"check_circle"}),(0,s.jsxs)("span",{className:"text-xs text-text-muted",children:[V?.stage||"starting",!X&&V?.bytesReceived?` \xb7 ${(V.bytesReceived/1024).toFixed(1)} KB`:""]})]}),(X||V)&&"video"===t&&(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:X?{animation:"spin 1s linear infinite"}:void 0,children:X?"progress_activity":"check_circle"}),(0,s.jsxs)("span",{className:"text-xs text-text-muted",children:[V?.stage||"submitting",Number.isFinite(V?.percent)?` \xb7 ${V.percent}%`:""]})]}),H?.b64_json&&!q&&(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)("img",{src:`data:image/png;base64,${H.b64_json}`,alt:"Partial",className:"max-w-full rounded-lg border border-border mt-1.5 opacity-80"})]}),et&&(0,s.jsx)("p",{className:"text-xs text-red-500 break-words",children:et}),(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 ",q&&(0,s.jsxs)("span",{className:"font-normal normal-case",children:["⚡ ",q.latencyMs,"ms"]})]}),q&&(0,s.jsxs)("button",{onClick:()=>ec(eT),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:ed?"check":"content_copy"}),ed?"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:q?eT:d.defaultResponse}),"image"===t&&(Y||q?.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:Y||(q?.data?.data?.[0]?.b64_json?`data:image/png;base64,${q.data.data[0].b64_json}`:q?.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)("img",{src:Y||(q?.data?.data?.[0]?.b64_json?`data:image/png;base64,${q.data.data[0].b64_json}`:q?.data?.data?.[0]?.url),alt:"Generated",className:"max-w-full rounded-lg border border-border"})]}),eR&&(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:eR,download:"video.mp4",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)("video",{controls:!0,src:eR,className:"max-w-full rounded-lg border border-border bg-black"})]})]})]})]})}function F({providerId:e}){let t=(0,c.wG)(e),r=(0,u.KC)(e).filter(e=>"stt"===e.type),[a,o]=(0,n.useState)([]),l=[...r,...a],[d,p]=(0,n.useState)(r[0]?.id??""),x=l.find(e=>e.id===d),h=Array.isArray(x?.params)?x.params:[],[b,f]=(0,n.useState)(null),[g,y]=(0,n.useState)(""),[v,j]=(0,n.useState)(""),[w,N]=(0,n.useState)("json"),[k,C]=(0,n.useState)(""),[S,_]=(0,n.useState)(!1),[$,T]=(0,n.useState)(""),[R,O]=(0,n.useState)(""),[P,A]=(0,n.useState)(null),[D,L]=(0,n.useState)(null),[M,U]=(0,n.useState)(!1),[K,B]=(0,n.useState)(""),{copied:q,copy:J}=(0,m.C)(),{copied:V,copy:z}=(0,m.C)();(0,n.useEffect)(()=>{T(window.location.origin),fetch("/api/tunnel/status").then(e=>e.json()).then(e=>{e.publicUrl&&O(e.publicUrl)}).catch(()=>{});let e=()=>{fetch("/api/models/custom",{cache:"no-store"}).then(e=>e.json()).then(e=>{o((e.models||[]).filter(e=>"stt"===e.type&&e.providerAlias===t))}).catch(()=>{})};return e(),window.addEventListener("focus",e),window.addEventListener("customModelChanged",e),()=>{window.removeEventListener("focus",e),window.removeEventListener("customModelChanged",e)}},[t]);let H=S?R:$,G=d?`${t}/${d}`:"",W=`curl -X POST ${H}/v1/audio/transcriptions \\
|
|
50
|
-
-H "Authorization: Bearer YOUR_KEY" \\
|
|
51
|
-
-F "file=@${b?.name||"audio.mp3"}" \\
|
|
52
|
-
-F "model=${G}"${h.includes("language")&&g?` \\
|
|
53
|
-
-F "language=${g}"`:""}${h.includes("response_format")?` \\
|
|
54
|
-
-F "response_format=${w}"`:""}${h.includes("temperature")&&k?` \\
|
|
55
|
-
-F "temperature=${k}"`:""}${h.includes("prompt")&&v?` \\
|
|
56
|
-
-F "prompt=${v}"`:""}`,Q=async()=>{if(!b||!G)return;U(!0),B(""),A(null);let e=Date.now();try{let t=new FormData;t.append("file",b),t.append("model",G),h.includes("language")&&g&&t.append("language",g),h.includes("response_format")&&t.append("response_format",w),h.includes("temperature")&&k&&t.append("temperature",k),h.includes("prompt")&&v&&t.append("prompt",v);let r=await fetch((0,E.O)("/v1/audio/transcriptions"),{method:"POST",body:t});L(Date.now()-e);let s=(r.headers.get("content-type")||"").includes("application/json")?await r.json():await r.text();if(!r.ok)return void B(s?.error?.message||s?.error||s||`HTTP ${r.status}`);A(s)}catch(e){B(e.message||"Network error")}finally{U(!1)}},Y="string"==typeof P?P:P?JSON.stringify(P,null,2):`{
|
|
57
|
-
"text": "Hello world..."
|
|
58
|
-
}`;return(0,s.jsxs)(i.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:[l.length>0?(0,s.jsx)(I,{label:"Model",children:(0,s.jsx)("select",{value:d,onChange:e=>p(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)(I,{label:"Model",children:(0,s.jsx)("input",{value:d,onChange:e=>p(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)(I,{label:"Endpoint",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.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:[H,"/v1/audio/transcriptions"]}),R&&(0,s.jsxs)("button",{onClick:()=>_(e=>!e),title:S?"Using tunnel":"Using local",className:`flex items-center gap-1 text-xs px-2 py-1.5 rounded-lg border shrink-0 transition-colors ${S?"border-primary/40 bg-primary/10 text-primary":"border-border text-text-muted hover:text-primary"}`,children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"wifi_tethering"}),"Tunnel"]})]})}),(0,s.jsx)(I,{label:"API Key",children:(0,s.jsx)("span",{className:"px-3 py-1.5 text-sm font-mono text-text-main bg-sidebar rounded-lg truncate block",children:(0,s.jsx)("span",{className:"text-text-muted italic",children:"Dashboard session (server-side)"})})}),(0,s.jsx)(I,{label:"Audio File",children:(0,s.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,s.jsx)("input",{type:"file",accept:"audio/*,video/mp4,.m4a,.mp3,.wav,.ogg,.flac,.webm,.opus",onChange:e=>f(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"}),b&&(0,s.jsxs)("span",{className:"text-xs text-text-muted font-mono",children:[b.name," \xb7 ",(b.size/1024).toFixed(1)," KB"]})]})}),h.includes("language")&&(0,s.jsx)(I,{label:"Language",children:(0,s.jsx)("input",{value:g,onChange:e=>y(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"})}),h.includes("prompt")&&(0,s.jsx)(I,{label:"Prompt",children:(0,s.jsx)("input",{value:v,onChange:e=>j(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"})}),h.includes("temperature")&&(0,s.jsx)(I,{label:"Temperature",children:(0,s.jsx)("input",{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"})}),h.includes("response_format")&&(0,s.jsx)(I,{label:"Response Format",children:(0,s.jsxs)("select",{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:()=>J(W),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:q?"check":"content_copy"}),q?"Copied":"Copy"]}),(0,s.jsxs)("button",{onClick:Q,disabled:M||!b||!G,className:"flex w-full sm:w-auto items-center justify-center gap-1.5 px-3 py-1 rounded-lg bg-primary text-white text-xs font-medium hover:bg-primary/90 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-[14px]",style:M?{animation:"spin 1s linear infinite"}:void 0,children:"play_arrow"}),M?"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:W})]}),K&&(0,s.jsx)("p",{className:"text-xs text-red-500 break-words",children:K}),(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 ",P&&D&&(0,s.jsxs)("span",{className:"font-normal normal-case",children:["⚡ ",D,"ms"]})]}),P&&(0,s.jsxs)("button",{onClick:()=>z(Y),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:V?"check":"content_copy"}),V?"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:Y})]})]})]})}function q(){let{kind:e,id:t}=(0,a.useParams)(),r=(0,a.useRouter)(),o=c.rj.find(t=>t.id===e),u=(0,c.gC)(t)&&"embedding"===e,[m,p]=(0,n.useState)(null),[x,h]=(0,n.useState)(u),[b,f]=(0,n.useState)(!1),[g,y]=(0,n.useState)(!1),v=async()=>{if(confirm("Delete this Custom Embedding node?")){y(!0);try{let s=await fetch(`/api/provider-nodes/${t}`,{method:"DELETE"});if(s.ok)return void r.push(`/dashboard/media-providers/${e}`);let a=await s.json().catch(()=>({}));alert(a.error||"Failed to delete custom embedding node")}catch{alert("Failed to delete custom embedding node")}y(!1)}};if((0,n.useEffect)(()=>{if(!u)return;let e=!1;return fetch("/api/provider-nodes",{cache:"no-store"}).then(e=>e.json()).then(r=>{e||(p((r.nodes||[]).find(e=>e.id===t)||null),h(!1))}).catch(()=>{e||h(!1)}),()=>{e=!0}},[t,u]),!o)return(0,a.notFound)();let j=c.Q2[t],N=u?m?{id:t,name:m.name||"Custom Embedding",color:"#6366F1",textIcon:"CE"}:null:j;if(!u&&!j||u&&!x&&!m)return(0,a.notFound)();if(u&&x)return(0,s.jsx)("div",{className:"text-text-muted text-sm py-12 text-center",children:"Loading..."});let k=u?["embedding"]:N.serviceKinds??["llm"];return u||k.includes(e)?(0,s.jsxs)("div",{className:"flex flex-col gap-8",children:[(0,s.jsxs)("div",{children:[(0,s.jsxs)(l(),{href:`/dashboard/media-providers/${e}`,className:"inline-flex items-center gap-1 text-sm text-text-muted hover:text-primary transition-colors mb-4",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-lg",children:"arrow_back"}),o.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:`${N.color}15`},children:(0,s.jsx)(d.A,{src:`/providers/${N.id}.png`,alt:N.name,size:48,className:"object-contain rounded-lg max-w-[48px] max-h-[48px]",fallbackText:N.textIcon||N.id.slice(0,2).toUpperCase(),fallbackColor:N.color})}),(0,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:N.name}),!u&&N.notice?.apiKeyUrl&&(0,s.jsxs)("a",{href:N.notice.apiKeyUrl,target:"_blank",rel:"noopener noreferrer",className:"text-xs text-primary hover:underline inline-flex items-center gap-1",children:[(0,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:[u&&(0,s.jsxs)(i.Ex,{variant:"default",size:"sm",children:["Custom \xb7 ",m?.prefix]}),k.map(t=>(0,s.jsx)(i.Ex,{variant:t===e?"primary":"default",size:"sm",children:t.toUpperCase()},t))]})]}),u&&(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)(i.$n,{size:"sm",variant:"secondary",icon:"edit",onClick:()=>f(!0),children:"Edit"}),(0,s.jsx)(i.$n,{size:"sm",variant:"secondary",icon:"delete",onClick:v,disabled:g,children:g?"Deleting...":"Delete"})]})]})]}),!u&&N.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:N.kindNotice[e]})]}),!u&&N.notice?.text&&!N.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:N.notice.text}),N.notice.apiKeyUrl&&(0,s.jsx)("a",{href:N.notice.apiKeyUrl,target:"_blank",rel:"noopener noreferrer",className:"inline-flex justify-center rounded bg-blue-500 px-2 py-1 text-xs font-medium text-white transition-colors hover:bg-blue-600 sm:py-0.5",children:"Get API Key →"})]}),!u&&N.noAuth?(0,s.jsx)(i.gw,{providerId:t}):(0,s.jsx)(w,{providerId:t,isOAuth:!1}),"tts"!==e&&"webSearch"!==e&&"webFetch"!==e&&(0,s.jsx)(C,{providerId:t,kindFilter:e,providerAliasOverride:u?m?.prefix:void 0}),!u&&(N.searchConfig||N.fetchConfig||N.ttsConfig||N.sttConfig||N.embeddingConfig||N.searchViaChat)&&(0,s.jsx)(i.Wx,{config:"webFetch"===e?N.fetchConfig:"tts"===e?N.ttsConfig:"stt"===e?N.sttConfig:"embedding"===e?N.embeddingConfig:N.searchConfig||{mode:"chat-completions",defaultModel:N.searchViaChat?.defaultModel,pricingUrl:N.searchViaChat?.pricingUrl,freeTier:N.searchViaChat?.freeTier},provider:N,title:`${o.label} Config`}),"embedding"===e&&(0,s.jsx)(U,{providerId:t,customAlias:m?.prefix}),"tts"===e&&(0,s.jsx)(K,{providerId:t}),"stt"===e&&!u&&(0,s.jsx)(F,{providerId:t}),!u&&M[e]&&(0,s.jsx)(B,{providerId:t,kind:e}),u&&(0,s.jsx)(i.x0,{isOpen:b,node:m,onClose:()=>f(!1),onSaved:e=>{p(e),f(!1)}})]}):(0,a.notFound)()}},54909:(e,t,r)=>{Promise.resolve().then(r.bind(r,7651))},62199:(e,t,r)=>{"use strict";r.d(t,{O:()=>a,x:()=>o});let s=Object.freeze({"/v1/embeddings":"embeddings","/v1/images/generations":"images","/v1/audio/speech":"speech","/v1/audio/transcriptions":"transcriptions","/v1/search":"search","/v1/web/fetch":"fetch","/v1/videos/generations":"videos"});function a(e){if("string"!=typeof e)return null;let t=e.indexOf("?"),r=-1===t?e:e.slice(0,t),a=-1===t?"":e.slice(t),o=s[r];return o?`/api/dashboard/media/${o}${a}`:null}function o(e){return"string"==typeof e&&e.trim()?`/api/dashboard/media/videos/${encodeURIComponent(e.trim())}`:null}},70217:(e,t,r)=>{"use strict";r.d(t,{BU:()=>u,G9:()=>n,d4:()=>d,gJ:()=>s,i2:()=>c});let s=[{id:"all",label:"All"},{id:"active",label:"Active",keys:["active"]},{id:"errors",label:"Errors",keys:["connection_error","auth_error","quota_exhausted","rate_limited","banned","cooldown","unknown"]},{id:"connection",label:"Connection",keys:["connection_error"]},{id:"auth",label:"Auth",keys:["auth_error"]},{id:"limit",label:"Limit",keys:["rate_limited","cooldown"]},{id:"exhausted",label:"Exhausted",keys:["quota_exhausted"]},{id:"banned",label:"Banned",keys:["banned"]},{id:"disabled",label:"Disabled",keys:["disabled"]}],a={active:{label:"active",severity:"success",terminal:!1},disabled:{label:"disabled",severity:"default",terminal:!1},connection_error:{label:"connection error",severity:"error",terminal:!1},auth_error:{label:"auth error",severity:"error",terminal:!0},quota_exhausted:{label:"exhausted",severity:"error",terminal:!0},rate_limited:{label:"rate limited",severity:"warning",terminal:!1},banned:{label:"banned",severity:"error",terminal:!0},cooldown:{label:"cooldown",severity:"warning",terminal:!1},unknown:{label:"unknown",severity:"default",terminal:!1}},o={policy_suspended:"banned",account_validation_required:"auth_error",credential_rejected:"auth_error",reauth_required:"auth_error",authentication:"auth_error",entitlement_or_quota:"quota_exhausted",rate_limited:"rate_limited",permission_denied:"auth_error",upstream_transient:"connection_error"};function l(e){if(!e)return"";if("string"==typeof e)return e.toLowerCase();try{return JSON.stringify(e).toLowerCase()}catch{return String(e).toLowerCase()}}function n(e={},t=Date.now()){let r=Object.entries(e).filter(([e])=>e.startsWith("modelLock_")).map(([,e])=>new Date(e).getTime()).filter(e=>Number.isFinite(e)&&e>t);return r.length>0?new Date(Math.min(...r)).toISOString():null}function i(e,t=""){let r=a[e]||a.unknown;return{key:e,...r,reason:t}}function d(e={}){var t;let r=(t=e).quarantinedAt?i(o[l(t.failureClass)]||"unknown",t.quarantineReason||t.lastError||"Connection is quarantined"):null;if(r)return r;if(!1===e.isActive)return i("disabled","Connection is disabled");if(function(e={}){return null!==n(e)}(e))return i("cooldown","Model cooldown is active");if(function(e){if(!e)return!1;let t=new Date(e).getTime();return Number.isFinite(t)&&t>Date.now()}(e.rateLimitedUntil))return i("rate_limited","Rate limit cooldown is active");let s=l(e.testStatus||e.status),a=l(e.lastErrorType||e.errorType),c=l(e.errorCode||e.statusCode),u=l(e.lastError||e.error),m=`${s} ${a} ${c} ${u}`.trim();return!m||["active","success","ok"].includes(s)?i("active",""):m.includes("ban")||m.includes("suspend")||m.includes("restricted")?i("banned",e.lastError||"Account appears restricted"):m.includes("exhaust")||m.includes("quota exceeded")||m.includes("insufficient_quota")||m.includes("payment required")||"402"===c?i("quota_exhausted",e.lastError||"Quota exhausted"):a.includes("rate_limited")||m.includes("rate limit")||m.includes("too many requests")||"429"===c?i("rate_limited",e.lastError||"Rate limited"):a.includes("auth")||a.includes("token")||m.includes("unauthorized")||m.includes("invalid api key")||m.includes("token invalid")||m.includes("token expired")||m.includes("revoked")||"401"===c||"403"===c?i("auth_error",e.lastError||"Authentication failed"):a.includes("network")||m.includes("network")||m.includes("timeout")||m.includes("fetch failed")||m.includes("econn")||m.includes("dns")||m.includes("proxy")?i("connection_error",e.lastError||"Connection failed"):["error","expired","unavailable","failed"].includes(s)?i("connection_error",e.lastError||e.testStatus||"Connection failed"):i("unknown",e.lastError||e.testStatus||"")}function c(e,t){if(!t||"all"===t)return!0;let r=s.find(e=>e.id===t);return!r||r.keys.includes(d(e).key)}function u(e){return e?.severity==="success"?"success":e?.severity==="error"?"error":"default"}},81277:(e,t,r)=>{"use strict";r.d(t,{c:()=>o});var s=r(12115),a=r(70217);function o(e={}){let[t,r]=(0,s.useState)(null),l=JSON.stringify(Object.entries(e).filter(([e])=>e.startsWith("modelLock_")).sort(([e],[t])=>e.localeCompare(t)));return(0,s.useEffect)(()=>(function(e,t,r={}){let s=r.now||Date.now,o=r.setTimer||globalThis.setTimeout,l=r.clearTimer||globalThis.clearTimeout,n=!1,i=null,d=()=>{if(i=null,n)return;let r=s(),l=(0,a.G9)(e,r);t(l),l&&(i=o(d,Math.min(Math.max(1,new Date(l).getTime()-r+1),0x7fffffff)))};return i=o(d,0),()=>{n=!0,null!==i&&l(i),i=null}})(Object.fromEntries(JSON.parse(l)),r),[l]),t}}},e=>{e.O(0,[2574,3862,3745,3339,620,5497,8441,3794,7358],()=>e(e.s=54909)),_N_E=e.O()}]);
|
|
File without changes
|
|
File without changes
|