@rabbi696/ezrouter 0.6.27 → 0.6.29
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/app/.next-cli-build/BUILD_ID +1 -1
- package/app/.next-cli-build/app-path-routes-manifest.json +1 -1
- package/app/.next-cli-build/build-manifest.json +2 -2
- package/app/.next-cli-build/prerender-manifest.json +3 -3
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/basic-chat/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/cli-tools/[toolId]/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/cli-tools/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/combos/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/console-log/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/convoy/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/endpoint/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/error-log/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/ha/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/mcp-gateway/keys/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/mcp-gateway/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/mcp-gateway/servers/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/[kind]/[id]/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/[kind]/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/combo/[id]/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/web/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/mitm/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/models/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/profile/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/[id]/page.js +11 -11
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/[id]/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/new/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/proxy-pools/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/pxpipe/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/quota/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/routing-health/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/skills/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/token-saver/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/translator/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/usage/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/wakeup/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/_global-error/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/_global-error.html +1 -1
- package/app/.next-cli-build/server/app/_global-error.rsc +1 -1
- package/app/.next-cli-build/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/_global-error.segments/_global-error.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/_global-error.segments/_head.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/_global-error.segments/_index.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/_not-found.html +1 -1
- package/app/.next-cli-build/server/app/_not-found.rsc +3 -3
- package/app/.next-cli-build/server/app/_not-found.segments/_full.segment.rsc +3 -3
- package/app/.next-cli-build/server/app/_not-found.segments/_head.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/_not-found.segments/_index.segment.rsc +3 -3
- package/app/.next-cli-build/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/_not-found.segments/_tree.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/api/cli-tools/all-statuses/route.js +5 -5
- package/app/.next-cli-build/server/app/api/cli-tools/antigravity-mitm/alias/route.js +2 -2
- package/app/.next-cli-build/server/app/api/cli-tools/claude-settings/route.js +2 -2
- package/app/.next-cli-build/server/app/api/cli-tools/cline-settings/route.js +2 -2
- package/app/.next-cli-build/server/app/api/cli-tools/codewhale-settings/route.js +1 -1
- package/app/.next-cli-build/server/app/api/cli-tools/copilot-settings/route.js +2 -2
- package/app/.next-cli-build/server/app/api/cli-tools/cowork-mcp-registry/route.js +1 -1
- package/app/.next-cli-build/server/app/api/cli-tools/cowork-mcp-tools/route.js +1 -1
- package/app/.next-cli-build/server/app/api/cli-tools/cowork-settings/route.js +2 -2
- package/app/.next-cli-build/server/app/api/cli-tools/crush-settings/route.js +2 -2
- package/app/.next-cli-build/server/app/api/cli-tools/deepseek-tui-settings/route.js +2 -2
- package/app/.next-cli-build/server/app/api/cli-tools/devin-settings/route.js +1 -1
- package/app/.next-cli-build/server/app/api/cli-tools/droid-settings/route.js +1 -1
- package/app/.next-cli-build/server/app/api/cli-tools/forge-settings/route.js +1 -1
- package/app/.next-cli-build/server/app/api/cli-tools/grok-build-settings/route.js +1 -1
- package/app/.next-cli-build/server/app/api/cli-tools/hermes-settings/route.js +1 -1
- package/app/.next-cli-build/server/app/api/cli-tools/jcode-settings/route.js +2 -2
- package/app/.next-cli-build/server/app/api/cli-tools/kilo-settings/route.js +2 -2
- package/app/.next-cli-build/server/app/api/cli-tools/omp-settings/route.js +2 -2
- package/app/.next-cli-build/server/app/api/cli-tools/openclaw-settings/route.js +2 -2
- package/app/.next-cli-build/server/app/api/cli-tools/opencode-settings/route.js +2 -2
- package/app/.next-cli-build/server/app/api/cli-tools/pi-settings/route.js +2 -2
- package/app/.next-cli-build/server/app/api/cli-tools/smelt-settings/route.js +1 -1
- package/app/.next-cli-build/server/app/api/models/route.js +1 -1
- package/app/.next-cli-build/server/app/api/providers/route.js +1 -1
- package/app/.next-cli-build/server/app/api/translator/console-logs/route.js +1 -1
- package/app/.next-cli-build/server/app/api/translator/console-logs/stream/route.js +1 -1
- package/app/.next-cli-build/server/app/api/tunnel/tailscale-install/route.js +2 -2
- package/app/.next-cli-build/server/app/api/version/route.js +1 -1
- package/app/.next-cli-build/server/app/callback/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/callback.html +1 -1
- package/app/.next-cli-build/server/app/callback.rsc +3 -3
- package/app/.next-cli-build/server/app/callback.segments/_full.segment.rsc +3 -3
- package/app/.next-cli-build/server/app/callback.segments/_head.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/callback.segments/_index.segment.rsc +3 -3
- package/app/.next-cli-build/server/app/callback.segments/_tree.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/callback.segments/callback/__PAGE__.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/callback.segments/callback.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/dashboard/basic-chat.html +1 -1
- package/app/.next-cli-build/server/app/dashboard/basic-chat.rsc +5 -5
- package/app/.next-cli-build/server/app/dashboard/basic-chat.segments/!KGRhc2hib2FyZCk/dashboard/basic-chat/__PAGE__.segment.rsc +2 -2
- package/app/.next-cli-build/server/app/dashboard/basic-chat.segments/!KGRhc2hib2FyZCk/dashboard/basic-chat.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/dashboard/basic-chat.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/dashboard/basic-chat.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
- package/app/.next-cli-build/server/app/dashboard/basic-chat.segments/_full.segment.rsc +5 -5
- package/app/.next-cli-build/server/app/dashboard/basic-chat.segments/_head.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/dashboard/basic-chat.segments/_index.segment.rsc +3 -3
- package/app/.next-cli-build/server/app/dashboard/basic-chat.segments/_tree.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/dashboard/cli-tools.html +1 -1
- package/app/.next-cli-build/server/app/dashboard/cli-tools.rsc +5 -5
- package/app/.next-cli-build/server/app/dashboard/cli-tools.segments/!KGRhc2hib2FyZCk/dashboard/cli-tools/__PAGE__.segment.rsc +2 -2
- package/app/.next-cli-build/server/app/dashboard/cli-tools.segments/!KGRhc2hib2FyZCk/dashboard/cli-tools.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/dashboard/cli-tools.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/dashboard/cli-tools.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
- package/app/.next-cli-build/server/app/dashboard/cli-tools.segments/_full.segment.rsc +5 -5
- package/app/.next-cli-build/server/app/dashboard/cli-tools.segments/_head.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/dashboard/cli-tools.segments/_index.segment.rsc +3 -3
- package/app/.next-cli-build/server/app/dashboard/cli-tools.segments/_tree.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/dashboard/combos.html +1 -1
- package/app/.next-cli-build/server/app/dashboard/combos.rsc +5 -5
- package/app/.next-cli-build/server/app/dashboard/combos.segments/!KGRhc2hib2FyZCk/dashboard/combos/__PAGE__.segment.rsc +2 -2
- package/app/.next-cli-build/server/app/dashboard/combos.segments/!KGRhc2hib2FyZCk/dashboard/combos.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/dashboard/combos.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/dashboard/combos.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
- package/app/.next-cli-build/server/app/dashboard/combos.segments/_full.segment.rsc +5 -5
- package/app/.next-cli-build/server/app/dashboard/combos.segments/_head.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/dashboard/combos.segments/_index.segment.rsc +3 -3
- package/app/.next-cli-build/server/app/dashboard/combos.segments/_tree.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/dashboard/convoy.html +1 -1
- package/app/.next-cli-build/server/app/dashboard/convoy.rsc +5 -5
- package/app/.next-cli-build/server/app/dashboard/convoy.segments/!KGRhc2hib2FyZCk/dashboard/convoy/__PAGE__.segment.rsc +2 -2
- package/app/.next-cli-build/server/app/dashboard/convoy.segments/!KGRhc2hib2FyZCk/dashboard/convoy.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/dashboard/convoy.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/dashboard/convoy.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
- package/app/.next-cli-build/server/app/dashboard/convoy.segments/_full.segment.rsc +5 -5
- package/app/.next-cli-build/server/app/dashboard/convoy.segments/_head.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/dashboard/convoy.segments/_index.segment.rsc +3 -3
- package/app/.next-cli-build/server/app/dashboard/convoy.segments/_tree.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/dashboard/endpoint.html +1 -1
- package/app/.next-cli-build/server/app/dashboard/endpoint.rsc +5 -5
- package/app/.next-cli-build/server/app/dashboard/endpoint.segments/!KGRhc2hib2FyZCk/dashboard/endpoint/__PAGE__.segment.rsc +2 -2
- package/app/.next-cli-build/server/app/dashboard/endpoint.segments/!KGRhc2hib2FyZCk/dashboard/endpoint.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/dashboard/endpoint.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/dashboard/endpoint.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
- package/app/.next-cli-build/server/app/dashboard/endpoint.segments/_full.segment.rsc +5 -5
- package/app/.next-cli-build/server/app/dashboard/endpoint.segments/_head.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/dashboard/endpoint.segments/_index.segment.rsc +3 -3
- package/app/.next-cli-build/server/app/dashboard/endpoint.segments/_tree.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/dashboard/ha.html +1 -1
- package/app/.next-cli-build/server/app/dashboard/ha.rsc +4 -4
- package/app/.next-cli-build/server/app/dashboard/ha.segments/!KGRhc2hib2FyZCk/dashboard/ha/__PAGE__.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/dashboard/ha.segments/!KGRhc2hib2FyZCk/dashboard/ha.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/dashboard/ha.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/dashboard/ha.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
- package/app/.next-cli-build/server/app/dashboard/ha.segments/_full.segment.rsc +4 -4
- package/app/.next-cli-build/server/app/dashboard/ha.segments/_head.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/dashboard/ha.segments/_index.segment.rsc +3 -3
- package/app/.next-cli-build/server/app/dashboard/ha.segments/_tree.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/dashboard/mcp-gateway/keys.html +1 -1
- package/app/.next-cli-build/server/app/dashboard/mcp-gateway/keys.rsc +5 -5
- package/app/.next-cli-build/server/app/dashboard/mcp-gateway/keys.segments/!KGRhc2hib2FyZCk/dashboard/mcp-gateway/keys/__PAGE__.segment.rsc +2 -2
- package/app/.next-cli-build/server/app/dashboard/mcp-gateway/keys.segments/!KGRhc2hib2FyZCk/dashboard/mcp-gateway/keys.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/dashboard/mcp-gateway/keys.segments/!KGRhc2hib2FyZCk/dashboard/mcp-gateway.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/dashboard/mcp-gateway/keys.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/dashboard/mcp-gateway/keys.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
- package/app/.next-cli-build/server/app/dashboard/mcp-gateway/keys.segments/_full.segment.rsc +5 -5
- package/app/.next-cli-build/server/app/dashboard/mcp-gateway/keys.segments/_head.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/dashboard/mcp-gateway/keys.segments/_index.segment.rsc +3 -3
- package/app/.next-cli-build/server/app/dashboard/mcp-gateway/keys.segments/_tree.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/dashboard/mcp-gateway/servers.html +1 -1
- package/app/.next-cli-build/server/app/dashboard/mcp-gateway/servers.rsc +5 -5
- package/app/.next-cli-build/server/app/dashboard/mcp-gateway/servers.segments/!KGRhc2hib2FyZCk/dashboard/mcp-gateway/servers/__PAGE__.segment.rsc +2 -2
- package/app/.next-cli-build/server/app/dashboard/mcp-gateway/servers.segments/!KGRhc2hib2FyZCk/dashboard/mcp-gateway/servers.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/dashboard/mcp-gateway/servers.segments/!KGRhc2hib2FyZCk/dashboard/mcp-gateway.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/dashboard/mcp-gateway/servers.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/dashboard/mcp-gateway/servers.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
- package/app/.next-cli-build/server/app/dashboard/mcp-gateway/servers.segments/_full.segment.rsc +5 -5
- package/app/.next-cli-build/server/app/dashboard/mcp-gateway/servers.segments/_head.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/dashboard/mcp-gateway/servers.segments/_index.segment.rsc +3 -3
- package/app/.next-cli-build/server/app/dashboard/mcp-gateway/servers.segments/_tree.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/dashboard/mcp-gateway.html +1 -1
- package/app/.next-cli-build/server/app/dashboard/mcp-gateway.rsc +5 -5
- package/app/.next-cli-build/server/app/dashboard/mcp-gateway.segments/!KGRhc2hib2FyZCk/dashboard/mcp-gateway/__PAGE__.segment.rsc +2 -2
- package/app/.next-cli-build/server/app/dashboard/mcp-gateway.segments/!KGRhc2hib2FyZCk/dashboard/mcp-gateway.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/dashboard/mcp-gateway.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/dashboard/mcp-gateway.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
- package/app/.next-cli-build/server/app/dashboard/mcp-gateway.segments/_full.segment.rsc +5 -5
- package/app/.next-cli-build/server/app/dashboard/mcp-gateway.segments/_head.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/dashboard/mcp-gateway.segments/_index.segment.rsc +3 -3
- package/app/.next-cli-build/server/app/dashboard/mcp-gateway.segments/_tree.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/dashboard/media-providers/web.html +1 -1
- package/app/.next-cli-build/server/app/dashboard/media-providers/web.rsc +5 -5
- package/app/.next-cli-build/server/app/dashboard/media-providers/web.segments/!KGRhc2hib2FyZCk/dashboard/media-providers/web/__PAGE__.segment.rsc +2 -2
- package/app/.next-cli-build/server/app/dashboard/media-providers/web.segments/!KGRhc2hib2FyZCk/dashboard/media-providers/web.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/dashboard/media-providers/web.segments/!KGRhc2hib2FyZCk/dashboard/media-providers.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/dashboard/media-providers/web.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/dashboard/media-providers/web.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
- package/app/.next-cli-build/server/app/dashboard/media-providers/web.segments/_full.segment.rsc +5 -5
- package/app/.next-cli-build/server/app/dashboard/media-providers/web.segments/_head.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/dashboard/media-providers/web.segments/_index.segment.rsc +3 -3
- package/app/.next-cli-build/server/app/dashboard/media-providers/web.segments/_tree.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/dashboard/mitm.html +1 -1
- package/app/.next-cli-build/server/app/dashboard/mitm.rsc +5 -5
- package/app/.next-cli-build/server/app/dashboard/mitm.segments/!KGRhc2hib2FyZCk/dashboard/mitm/__PAGE__.segment.rsc +2 -2
- package/app/.next-cli-build/server/app/dashboard/mitm.segments/!KGRhc2hib2FyZCk/dashboard/mitm.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/dashboard/mitm.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/dashboard/mitm.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
- package/app/.next-cli-build/server/app/dashboard/mitm.segments/_full.segment.rsc +5 -5
- package/app/.next-cli-build/server/app/dashboard/mitm.segments/_head.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/dashboard/mitm.segments/_index.segment.rsc +3 -3
- package/app/.next-cli-build/server/app/dashboard/mitm.segments/_tree.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/dashboard/models.html +1 -1
- package/app/.next-cli-build/server/app/dashboard/models.rsc +5 -5
- package/app/.next-cli-build/server/app/dashboard/models.segments/!KGRhc2hib2FyZCk/dashboard/models/__PAGE__.segment.rsc +2 -2
- package/app/.next-cli-build/server/app/dashboard/models.segments/!KGRhc2hib2FyZCk/dashboard/models.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/dashboard/models.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/dashboard/models.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
- package/app/.next-cli-build/server/app/dashboard/models.segments/_full.segment.rsc +5 -5
- package/app/.next-cli-build/server/app/dashboard/models.segments/_head.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/dashboard/models.segments/_index.segment.rsc +3 -3
- package/app/.next-cli-build/server/app/dashboard/models.segments/_tree.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/dashboard/profile.html +1 -1
- package/app/.next-cli-build/server/app/dashboard/profile.rsc +5 -5
- package/app/.next-cli-build/server/app/dashboard/profile.segments/!KGRhc2hib2FyZCk/dashboard/profile/__PAGE__.segment.rsc +2 -2
- package/app/.next-cli-build/server/app/dashboard/profile.segments/!KGRhc2hib2FyZCk/dashboard/profile.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/dashboard/profile.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/dashboard/profile.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
- package/app/.next-cli-build/server/app/dashboard/profile.segments/_full.segment.rsc +5 -5
- package/app/.next-cli-build/server/app/dashboard/profile.segments/_head.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/dashboard/profile.segments/_index.segment.rsc +3 -3
- package/app/.next-cli-build/server/app/dashboard/profile.segments/_tree.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/dashboard/providers/new.html +1 -1
- package/app/.next-cli-build/server/app/dashboard/providers/new.rsc +5 -5
- package/app/.next-cli-build/server/app/dashboard/providers/new.segments/!KGRhc2hib2FyZCk/dashboard/providers/new/__PAGE__.segment.rsc +2 -2
- package/app/.next-cli-build/server/app/dashboard/providers/new.segments/!KGRhc2hib2FyZCk/dashboard/providers/new.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/dashboard/providers/new.segments/!KGRhc2hib2FyZCk/dashboard/providers.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/dashboard/providers/new.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/dashboard/providers/new.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
- package/app/.next-cli-build/server/app/dashboard/providers/new.segments/_full.segment.rsc +5 -5
- package/app/.next-cli-build/server/app/dashboard/providers/new.segments/_head.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/dashboard/providers/new.segments/_index.segment.rsc +3 -3
- package/app/.next-cli-build/server/app/dashboard/providers/new.segments/_tree.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/dashboard/providers.html +1 -1
- package/app/.next-cli-build/server/app/dashboard/providers.rsc +5 -5
- package/app/.next-cli-build/server/app/dashboard/providers.segments/!KGRhc2hib2FyZCk/dashboard/providers/__PAGE__.segment.rsc +2 -2
- package/app/.next-cli-build/server/app/dashboard/providers.segments/!KGRhc2hib2FyZCk/dashboard/providers.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/dashboard/providers.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/dashboard/providers.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
- package/app/.next-cli-build/server/app/dashboard/providers.segments/_full.segment.rsc +5 -5
- package/app/.next-cli-build/server/app/dashboard/providers.segments/_head.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/dashboard/providers.segments/_index.segment.rsc +3 -3
- package/app/.next-cli-build/server/app/dashboard/providers.segments/_tree.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/dashboard/proxy-pools.html +1 -1
- package/app/.next-cli-build/server/app/dashboard/proxy-pools.rsc +5 -5
- package/app/.next-cli-build/server/app/dashboard/proxy-pools.segments/!KGRhc2hib2FyZCk/dashboard/proxy-pools/__PAGE__.segment.rsc +2 -2
- package/app/.next-cli-build/server/app/dashboard/proxy-pools.segments/!KGRhc2hib2FyZCk/dashboard/proxy-pools.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/dashboard/proxy-pools.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/dashboard/proxy-pools.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
- package/app/.next-cli-build/server/app/dashboard/proxy-pools.segments/_full.segment.rsc +5 -5
- package/app/.next-cli-build/server/app/dashboard/proxy-pools.segments/_head.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/dashboard/proxy-pools.segments/_index.segment.rsc +3 -3
- package/app/.next-cli-build/server/app/dashboard/proxy-pools.segments/_tree.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/dashboard/pxpipe.html +1 -1
- package/app/.next-cli-build/server/app/dashboard/pxpipe.rsc +5 -5
- package/app/.next-cli-build/server/app/dashboard/pxpipe.segments/!KGRhc2hib2FyZCk/dashboard/pxpipe/__PAGE__.segment.rsc +2 -2
- package/app/.next-cli-build/server/app/dashboard/pxpipe.segments/!KGRhc2hib2FyZCk/dashboard/pxpipe.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/dashboard/pxpipe.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/dashboard/pxpipe.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
- package/app/.next-cli-build/server/app/dashboard/pxpipe.segments/_full.segment.rsc +5 -5
- package/app/.next-cli-build/server/app/dashboard/pxpipe.segments/_head.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/dashboard/pxpipe.segments/_index.segment.rsc +3 -3
- package/app/.next-cli-build/server/app/dashboard/pxpipe.segments/_tree.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/dashboard/quota.html +1 -1
- package/app/.next-cli-build/server/app/dashboard/quota.rsc +6 -6
- package/app/.next-cli-build/server/app/dashboard/quota.segments/!KGRhc2hib2FyZCk/dashboard/quota/__PAGE__.segment.rsc +3 -3
- package/app/.next-cli-build/server/app/dashboard/quota.segments/!KGRhc2hib2FyZCk/dashboard/quota.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/dashboard/quota.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/dashboard/quota.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
- package/app/.next-cli-build/server/app/dashboard/quota.segments/_full.segment.rsc +6 -6
- package/app/.next-cli-build/server/app/dashboard/quota.segments/_head.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/dashboard/quota.segments/_index.segment.rsc +3 -3
- package/app/.next-cli-build/server/app/dashboard/quota.segments/_tree.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/dashboard/routing-health.html +1 -1
- package/app/.next-cli-build/server/app/dashboard/routing-health.rsc +5 -5
- package/app/.next-cli-build/server/app/dashboard/routing-health.segments/!KGRhc2hib2FyZCk/dashboard/routing-health/__PAGE__.segment.rsc +2 -2
- package/app/.next-cli-build/server/app/dashboard/routing-health.segments/!KGRhc2hib2FyZCk/dashboard/routing-health.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/dashboard/routing-health.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/dashboard/routing-health.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
- package/app/.next-cli-build/server/app/dashboard/routing-health.segments/_full.segment.rsc +5 -5
- package/app/.next-cli-build/server/app/dashboard/routing-health.segments/_head.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/dashboard/routing-health.segments/_index.segment.rsc +3 -3
- package/app/.next-cli-build/server/app/dashboard/routing-health.segments/_tree.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/dashboard/settings/pricing/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/dashboard/settings/pricing.html +1 -1
- package/app/.next-cli-build/server/app/dashboard/settings/pricing.rsc +3 -3
- package/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/_full.segment.rsc +3 -3
- package/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/_head.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/_index.segment.rsc +3 -3
- package/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/_tree.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/dashboard/settings/pricing/__PAGE__.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/dashboard/settings/pricing.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/dashboard/settings.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/dashboard.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/dashboard/skills.html +1 -1
- package/app/.next-cli-build/server/app/dashboard/skills.rsc +5 -5
- package/app/.next-cli-build/server/app/dashboard/skills.segments/!KGRhc2hib2FyZCk/dashboard/skills/__PAGE__.segment.rsc +2 -2
- package/app/.next-cli-build/server/app/dashboard/skills.segments/!KGRhc2hib2FyZCk/dashboard/skills.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/dashboard/skills.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/dashboard/skills.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
- package/app/.next-cli-build/server/app/dashboard/skills.segments/_full.segment.rsc +5 -5
- package/app/.next-cli-build/server/app/dashboard/skills.segments/_head.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/dashboard/skills.segments/_index.segment.rsc +3 -3
- package/app/.next-cli-build/server/app/dashboard/skills.segments/_tree.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/dashboard/token-saver.html +1 -1
- package/app/.next-cli-build/server/app/dashboard/token-saver.rsc +5 -5
- package/app/.next-cli-build/server/app/dashboard/token-saver.segments/!KGRhc2hib2FyZCk/dashboard/token-saver/__PAGE__.segment.rsc +2 -2
- package/app/.next-cli-build/server/app/dashboard/token-saver.segments/!KGRhc2hib2FyZCk/dashboard/token-saver.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/dashboard/token-saver.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/dashboard/token-saver.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
- package/app/.next-cli-build/server/app/dashboard/token-saver.segments/_full.segment.rsc +5 -5
- package/app/.next-cli-build/server/app/dashboard/token-saver.segments/_head.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/dashboard/token-saver.segments/_index.segment.rsc +3 -3
- package/app/.next-cli-build/server/app/dashboard/token-saver.segments/_tree.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/dashboard/translator.html +1 -1
- package/app/.next-cli-build/server/app/dashboard/translator.rsc +5 -5
- package/app/.next-cli-build/server/app/dashboard/translator.segments/!KGRhc2hib2FyZCk/dashboard/translator/__PAGE__.segment.rsc +2 -2
- package/app/.next-cli-build/server/app/dashboard/translator.segments/!KGRhc2hib2FyZCk/dashboard/translator.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/dashboard/translator.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/dashboard/translator.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
- package/app/.next-cli-build/server/app/dashboard/translator.segments/_full.segment.rsc +5 -5
- package/app/.next-cli-build/server/app/dashboard/translator.segments/_head.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/dashboard/translator.segments/_index.segment.rsc +3 -3
- package/app/.next-cli-build/server/app/dashboard/translator.segments/_tree.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/dashboard/usage.html +1 -1
- package/app/.next-cli-build/server/app/dashboard/usage.rsc +5 -5
- package/app/.next-cli-build/server/app/dashboard/usage.segments/!KGRhc2hib2FyZCk/dashboard/usage/__PAGE__.segment.rsc +2 -2
- package/app/.next-cli-build/server/app/dashboard/usage.segments/!KGRhc2hib2FyZCk/dashboard/usage.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/dashboard/usage.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/dashboard/usage.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
- package/app/.next-cli-build/server/app/dashboard/usage.segments/_full.segment.rsc +5 -5
- package/app/.next-cli-build/server/app/dashboard/usage.segments/_head.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/dashboard/usage.segments/_index.segment.rsc +3 -3
- package/app/.next-cli-build/server/app/dashboard/usage.segments/_tree.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/dashboard/wakeup.html +1 -1
- package/app/.next-cli-build/server/app/dashboard/wakeup.rsc +4 -4
- package/app/.next-cli-build/server/app/dashboard/wakeup.segments/!KGRhc2hib2FyZCk/dashboard/wakeup/__PAGE__.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/dashboard/wakeup.segments/!KGRhc2hib2FyZCk/dashboard/wakeup.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/dashboard/wakeup.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/dashboard/wakeup.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
- package/app/.next-cli-build/server/app/dashboard/wakeup.segments/_full.segment.rsc +4 -4
- package/app/.next-cli-build/server/app/dashboard/wakeup.segments/_head.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/dashboard/wakeup.segments/_index.segment.rsc +3 -3
- package/app/.next-cli-build/server/app/dashboard/wakeup.segments/_tree.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/dashboard.html +1 -1
- package/app/.next-cli-build/server/app/dashboard.rsc +5 -5
- package/app/.next-cli-build/server/app/dashboard.segments/!KGRhc2hib2FyZCk/dashboard/__PAGE__.segment.rsc +2 -2
- package/app/.next-cli-build/server/app/dashboard.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/dashboard.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
- package/app/.next-cli-build/server/app/dashboard.segments/_full.segment.rsc +5 -5
- package/app/.next-cli-build/server/app/dashboard.segments/_head.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/dashboard.segments/_index.segment.rsc +3 -3
- package/app/.next-cli-build/server/app/dashboard.segments/_tree.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/index.html +1 -1
- package/app/.next-cli-build/server/app/index.rsc +3 -3
- package/app/.next-cli-build/server/app/index.segments/__PAGE__.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/index.segments/_full.segment.rsc +3 -3
- package/app/.next-cli-build/server/app/index.segments/_head.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/index.segments/_index.segment.rsc +3 -3
- package/app/.next-cli-build/server/app/index.segments/_tree.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/landing/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/landing.html +1 -1
- package/app/.next-cli-build/server/app/landing.rsc +3 -3
- package/app/.next-cli-build/server/app/landing.segments/_full.segment.rsc +3 -3
- package/app/.next-cli-build/server/app/landing.segments/_head.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/landing.segments/_index.segment.rsc +3 -3
- package/app/.next-cli-build/server/app/landing.segments/_tree.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/landing.segments/landing/__PAGE__.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/landing.segments/landing.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/login/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/login.html +1 -1
- package/app/.next-cli-build/server/app/login.rsc +4 -4
- package/app/.next-cli-build/server/app/login.segments/_full.segment.rsc +4 -4
- package/app/.next-cli-build/server/app/login.segments/_head.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/login.segments/_index.segment.rsc +3 -3
- package/app/.next-cli-build/server/app/login.segments/_tree.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/login.segments/login/__PAGE__.segment.rsc +2 -2
- package/app/.next-cli-build/server/app/login.segments/login.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app-paths-manifest.json +1 -1
- package/app/.next-cli-build/server/chunks/1757.js +1 -1
- package/app/.next-cli-build/server/chunks/2452.js +1 -1
- package/app/.next-cli-build/server/chunks/5461.js +1 -1
- package/app/.next-cli-build/server/chunks/5749.js +1 -1
- package/app/.next-cli-build/server/chunks/6038.js +1 -1
- package/app/.next-cli-build/server/chunks/6283.js +1 -1
- package/app/.next-cli-build/server/chunks/6328.js +1 -1
- package/app/.next-cli-build/server/chunks/6644.js +1 -1
- package/app/.next-cli-build/server/chunks/7775.js +1 -1
- package/app/.next-cli-build/server/chunks/8238.js +1 -1
- package/app/.next-cli-build/server/chunks/9900.js +1 -1
- package/app/.next-cli-build/server/middleware-build-manifest.js +1 -1
- package/app/.next-cli-build/server/next-font-manifest.js +1 -1
- package/app/.next-cli-build/server/next-font-manifest.json +1 -1
- package/app/.next-cli-build/server/pages/404.html +1 -1
- package/app/.next-cli-build/server/pages/500.html +1 -1
- package/app/.next-cli-build/server/server-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/server-reference-manifest.json +1 -1
- package/app/.next-cli-build/static/chunks/{1321-e213e7e1bf3a7765.js → 1321-88eef55748a0ed6d.js} +1 -1
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/media-providers/[kind]/[id]/{page-a0907899ceaf136b.js → page-b12366cd7a47c746.js} +11 -11
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/providers/[id]/{page-d08c7e6e5aac5fe2.js → page-04e7788a14f993ed.js} +4 -4
- package/app/CHANGELOG.md +23 -2
- package/app/package.json +1 -1
- package/app/public/CHANGELOG.md +23 -2
- package/package.json +1 -1
- /package/app/.next-cli-build/static/{QraJFuTUjRVVcGfufFpWk → yb9jsXtBeHMoPmMsOqYn_}/_buildManifest.js +0 -0
- /package/app/.next-cli-build/static/{QraJFuTUjRVVcGfufFpWk → yb9jsXtBeHMoPmMsOqYn_}/_ssgManifest.js +0 -0
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[2134],{9339:(e,t,s)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});var a={callServer:function(){return r.callServer},createServerReference:function(){return n.createServerReference},findSourceMapURL:function(){return l.findSourceMapURL}};for(var i in a)Object.defineProperty(t,i,{enumerable:!0,get:a[i]});let r=s(77304),l=s(4060),n=s(77197)},14558:(e,t,s)=>{"use strict";s.d(t,{A:()=>l});var a=s(95155),i=s(12115),r=s(97677);function l({connectionId:e,disabled:t=!1,onComplete:s}){let[n,o]=(0,i.useState)(!1),[d,c]=(0,i.useState)(null);async function m(){if(!n){if(d)return void c(null);o(!0);try{let t=await fetch("/api/wakeup",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"ping",connectionId:e})}),a=await t.json();if(!t.ok)throw Error(a.error||"Ping failed.");c(a),s&&Promise.resolve(s()).catch(()=>{})}catch(e){c({status:"failed",message:e.message})}finally{o(!1)}}}let u=n?"Pinging…":d?`${d.message} Click to reset.`:"Ping now — sends a small request. Consumes quota; does not change Auto-Ping.",p=d?"succeeded"===d.status?"text-green-600 dark:text-green-400":"text-red-600 dark:text-red-400":"text-text-muted hover:text-primary";return(0,a.jsx)(r.default,{text:u,children:(0,a.jsx)("button",{type:"button",onClick:m,disabled:n||t&&!d,"aria-label":u,"aria-busy":n,className:`flex h-8 w-8 items-center justify-center rounded-lg ${p} hover:bg-surface-2 disabled:cursor-not-allowed disabled:opacity-50`,children:(0,a.jsx)("span",{"aria-hidden":"true",style:{fontSize:n?20:32},className:`material-symbols-outlined ${n?"animate-spin":""}`,children:n?"progress_activity":"play_arrow"})})})}},25871:(e,t,s)=>{"use strict";s.d(t,{G:()=>n,e:()=>d});var a=s(12115);let i=null,r=null,l="pricingChanged";function n(){i=null,window.dispatchEvent(new CustomEvent(l))}function o(){return i?Promise.resolve(i):r||(r=fetch("/api/pricing").then(async e=>{if(!e.ok)throw Error(`pricing ${e.status}`);return e.json()}).then(e=>i=e||{}).catch(()=>({})).finally(()=>{r=null}))}function d(){let[e,t]=(0,a.useState)(()=>i||{});return(0,a.useEffect)(()=>{let e=!0;o().then(s=>{e&&t(s)});let s=()=>{o().then(s=>{e&&t(s)})};return window.addEventListener(l,s),()=>{e=!1,window.removeEventListener(l,s)}},[]),{getPricing:(0,a.useCallback)((t,s)=>t&&s&&e[t]?.[s]||null,[e])}}},64827:(e,t,s)=>{"use strict";function a(e){if(!e)return null;let t=null,s=Date.now();for(let[a,i]of Object.entries(e)){if(!a.startsWith("modelLock_")||!i)continue;let e=new Date(i).getTime();e<=s||(!t||e<t)&&(t=e)}return t?new Date(t).toISOString():null}s.d(t,{kJ:()=>a}),s(10904)},85295:(e,t,s)=>{Promise.resolve().then(s.bind(s,86822))},86822:(e,t,s)=>{"use strict";s.r(t),s.d(t,{default:()=>eC});var a=s(95155),i=s(12115),r=s(73321),l=s(98500),n=s.n(l),o=s(5772),d=s(8247),c=s(35497),m=s(88105),u=s(28777),p=s(57151),x=s(47224),h=s(40228),f=s(89523);let g=["none","low","medium","high"],y=["none","thinking"],b=["none","low","medium","high","max"],v=["none","low","medium","high","xhigh","max"],j={qoder:v,openai:["none","minimal","low","medium","high","xhigh"],"claude-adaptive":v,"claude-budget":v,"gemini-level":["minimal","low","medium","high"],"gemini-budget":g,zai:y,qwen:g,kimi:b,opencode:b,deepseek:["none","high","max"],minimax:y,hunyuan:g,step:g,nous:g,meta:["minimal","low","medium","high","xhigh"],ollama:b},w=["none","minimal","low","medium","high","xhigh","max"],k=["none","low","medium","high","max"],N=[{pattern:"*gemini-4*",levels:["low","medium","high"]},{pattern:"*claude*4.6*",levels:k},{pattern:"*claude*4-6*",levels:k},{provider:"codex",pattern:"*gpt-6*",levels:w},{provider:"codex",pattern:"*gpt-5.6-sol*",levels:[...w,"ultra"]},{provider:"codex",pattern:"*gpt-5.6-terra*",levels:[...w,"ultra"]},{provider:"codex",pattern:"*gpt-5.6-luna*",levels:w},{providers:["openai","codex"],pattern:"*gpt-5.6*",levels:["none","minimal","low","medium","high","xhigh","max","ultra"]},{pattern:"*codex*",levels:["low","medium","high","xhigh"]},{provider:"opencode",pattern:"*mimo*v2.6*",levels:["none","minimal","low","medium","high","xhigh","max"]},{pattern:"*mimo*v2.6*",levels:["none","low","medium","high","xhigh"]},{pattern:"*mimo*v2.5-pro*",levels:["none","low","medium","high","xhigh"]},{provider:"ollama",pattern:"*gpt-oss*",levels:["none","low","medium","high"]},{provider:"ollama-local",pattern:"*gpt-oss*",levels:["none","low","medium","high"]},{provider:"qoder",pattern:"*",levels:v},{provider:"codebuddy-cn",pattern:"deepseek-v4-pro",levels:["low","high","xhigh"]},{provider:"codebuddy-cn",pattern:"deepseek-v4.1-flash",levels:["low","high","max"]},{pattern:"*deepseek-v4.1-flash-free*",levels:["low","high","max"]},{pattern:"*deepseek-v4.*",levels:["none","low","medium","high","xhigh","max"]},{provider:"codebuddy-cn",pattern:"glm-5.3",levels:["low","high","max"]},{provider:"codebuddy-cn",pattern:"glm-5.3-flash",levels:["low","high","max"]},{provider:"codebuddy-cn",pattern:"glm-5.2",levels:["high","xhigh"]},{provider:"codebuddy-cn",pattern:"kimi-k2.8-preview",levels:["low","medium","high"]},{provider:"codebuddy-cn",pattern:"hy3",levels:["low","high"]},{provider:"codebuddy-cn",pattern:"hy4-preview",levels:["high"]},{provider:"codebuddy-intl",pattern:"deepseek-v4*",levels:["low","high","xhigh"]},{provider:"minimax-code",pattern:"MiniMax-M3.1*",levels:["low","medium","high","xhigh","max"]},{provider:"minimax-code",pattern:"MiniMax-M3",levels:["none","high"]},{provider:"minimax-code-global",pattern:"MiniMax-M3.1*",levels:["low","medium","high","xhigh","max"]},{provider:"minimax-code-global",pattern:"MiniMax-M3",levels:["none","high"]},{pattern:"*glm-5.3",levels:["low","high","max"]}];function C(e,t){if("kiro"===e&&null===function(e){if("string"!=typeof e)return null;let t=e.toLowerCase().replace(/-/g,".");if(/(?:^|[/.])gpt[/.]5[/.]6(?:[/.]|$)/.test(t))return"reasoning";if(!t.includes("claude"))return null;let s=function(e){if("string"!=typeof e)return null;let t=e.toLowerCase().replace(/-/g,".").match(/(?:^|[/.])claude(?:[/.][a-z]+)*[/.](\d+)(?:[/.](\d+))?(?:[/.]|$)/);return t?{major:Number(t[1]),minor:void 0===t[2]?null:Number(t[2])}:null}(e);if(!s)return null;let{major:a,minor:i}=s;return a<4||4===a&&(null===i||i<=5||null!==i&&i>=1e3)?null:"output_config"}(t))return null;let s=(0,p.nl)(e,t);if(!s.reasoning)return null;let a=String(t||"").replace(/\([^()]+\)\s*$/,""),i="codex"===e?(0,f.SM)("cx").find(e=>e.id===a)?.thinkingLevels:null,r=N.find(s=>(!s.providers||!e||s.providers.includes(e))&&(!s.provider||s.provider===e)&&(0,x.gH)(s.pattern,t)),l=(e?h.xq[e]?.thinkingFormat:null)||s.thinkingFormat,n=i||s.thinkingLevels||r?.levels||j[l]||g;return!1===s.thinkingCanDisable&&(n=n.filter(e=>"none"!==e)),n}var S=s(11059),A=s(929),T=s(73006);let $=new Map;async function O(e,t){if(e?.type==="static")return e.models||[];if(!e?.url||!e?.type)return[];let s="nous"===t||e.url?.includes("nousresearch")?"nous":e.type,a=`${e.url}#${s}`,i=$.get(a);if(i&&Date.now()<i.expiresAt)return i.data;try{let t=new URLSearchParams({url:e.url,type:s}),i=await fetch(`/api/providers/suggested-models?${t}`);if(!i.ok)return[];let r=(await i.json()).data??[];return $.set(a,{data:r,expiresAt:Date.now()+6e5}),r}catch{return[]}}function P({customModels:e=[],modelAliases:t={},providerAlias:s,builtInModels:a=[],type:i="llm",includeLegacyAliases:r=!0}){let l=new Set(a.map(e=>e.id)),n=new Set,o=[];for(let t of e){if(!t?.id||t.providerAlias!==s)continue;let e=t?.kind||t?.type||"llm";if(i&&e!==i||l.has(t.id))continue;let a=`${s}/${t.id}`;n.has(a)||(n.add(a),o.push({id:t.id,name:t.name||t.id,fullModel:a,source:"custom",type:e}))}if(!r)return o;let d=`${s}/`;for(let[e,s]of Object.entries(t||{})){if("string"!=typeof s||!s.startsWith(d))continue;let t=s.slice(d.length);!t||l.has(t)||n.has(s)||(n.add(s),o.push({id:t,alias:e,fullModel:s,source:"legacyAlias",type:i||"llm"}))}return o}var I=s(14051),E=s.n(I),R=s(25871),M=s(93725);function D({model:e,fullModel:t,alias:s,copied:i,onCopy:r,testStatus:l,isCustom:n,isFree:o,onDeleteAlias:d,onTest:m,isTesting:u,onDisable:p,caps:x,thinkingSuffix:h}){let{getPricing:f}=(0,R.e)(),g=h?`${t}(${h})`:t,y=t.includes("/")?t.slice(0,t.indexOf("/")):null,b=(0,M.M4)(x,f(y,e.id)),v="ok"===l?"#22c55e":"error"===l?"#ef4444":"slow"===l||"rate_limited"===l?"#f59e0b":void 0;return(0,a.jsx)("div",{className:`group w-full sm:w-auto min-w-0 max-w-full rounded-lg border px-3 py-2 ${"ok"===l?"border-green-500/40":"error"===l?"border-red-500/40":"slow"===l||"rate_limited"===l?"border-amber-500/40":"border-border"} hover:bg-sidebar/50`,children:(0,a.jsxs)("div",{className:"flex min-w-0 items-start gap-2 sm:items-center",children:[(0,a.jsx)("span",{className:"material-symbols-outlined shrink-0 text-base mt-0.5 sm:mt-0",style:v?{color:v}:void 0,children:"ok"===l?"check_circle":"error"===l?"cancel":"slow"===l||"rate_limited"===l?"warning":"smart_toy"}),(0,a.jsxs)("div",{className:"flex min-w-0 flex-1 flex-col gap-1",children:[(0,a.jsx)("code",{className:"w-fit max-w-full break-all rounded bg-sidebar px-1.5 py-0.5 font-mono text-xs text-text-muted sm:max-w-[360px] sm:truncate",children:g}),(0,a.jsxs)("span",{className:"flex min-w-0 items-center text-[9px] gap-1 pl-1",children:[e.name&&(0,a.jsx)("span",{className:"break-all sm:truncate text-[9px] italic text-text-muted/70",children:e.name}),(0,a.jsx)(c.nh,{caps:x,colorOverride:"text-text-muted/70",size:12}),b&&(0,a.jsx)("span",{className:"truncate text-[9px] text-text-muted/70",children:b})]})]}),(0,a.jsxs)("div",{className:"flex shrink-0 items-center gap-0.5 sm:gap-1",children:[m&&(0,a.jsxs)("div",{className:"relative shrink-0 group/btn",children:[(0,a.jsx)("button",{onClick:m,disabled:u,className:`rounded p-0.5 text-text-muted transition-opacity hover:bg-sidebar hover:text-primary ${u?"opacity-100":"opacity-100 sm:opacity-0 sm:group-hover:opacity-100"}`,children:(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",style:u?{animation:"spin 1s linear infinite"}:void 0,children:u?"progress_activity":"science"})}),(0,a.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:u?"Testing...":"Test"})]}),(0,a.jsxs)("div",{className:"relative shrink-0 group/btn",children:[(0,a.jsx)("button",{onClick:()=>r(g,`model-${e.id}`),className:"rounded p-0.5 text-text-muted hover:bg-sidebar hover:text-primary",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:i===`model-${e.id}`?"check":"content_copy"})}),(0,a.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:i===`model-${e.id}`?"Copied!":"Copy"})]}),n?(0,a.jsx)("button",{onClick:d,className:"rounded p-0.5 text-text-muted opacity-100 transition-opacity hover:bg-red-500/10 hover:text-red-500 sm:opacity-0 sm:group-hover:opacity-100",title:"Remove custom model",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:"close"})}):p?(0,a.jsx)("button",{onClick:p,className:"rounded p-0.5 text-text-muted opacity-100 transition-opacity hover:bg-red-500/10 hover:text-red-500 sm:opacity-0 sm:group-hover:opacity-100",title:"Disable this model",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:"close"})}):null]})]})})}function q({isOpen:e,onClose:t,connectionId:s,providerStorageAlias:r,existingIds:l,transformId:n,onImported:o}){let[d,m]=(0,i.useState)(!1),[u,p]=(0,i.useState)(""),[x,h]=(0,i.useState)(""),[f,g]=(0,i.useState)([]),[y,b]=(0,i.useState)(()=>new Set),[v,j]=(0,i.useState)(""),[w,k]=(0,i.useState)(!1),[N,C]=(0,i.useState)(null);(0,i.useEffect)(()=>{if(!e||!s)return;let t=!1;return m(!0),p(""),h(""),g([]),b(new Set),j(""),C(null),fetch(`/api/providers/${s}/models`,{cache:"no-store"}).then(async e=>({ok:e.ok,data:await e.json()})).then(({ok:e,data:s})=>{if(t)return;if(!e)return void p(s.error||"Failed to fetch models");let a=new Set,i=[];for(let e of s.models||[]){if(e?.kind&&!["llm","imageToText"].includes(e.kind))continue;let t=e?.id||e?.name||e?.model;"string"==typeof t&&t.trim()&&(n&&(t=n(t)),!t||a.has(t)||(a.add(t),i.push({id:t,name:e?.name&&e.name!==e.id&&e.name!==t?e.name:null})))}g(i),s.warning&&h(s.warning),0!==i.length||s.warning||h("Provider returned 0 models")}).catch(e=>{t||p(e.message||"Network error")}).finally(()=>{t||m(!1)}),()=>{t=!0}},[e,s,n]);let S=(0,i.useMemo)(()=>f.map(e=>({...e,added:l?.has(e.id)===!0})),[f,l]),A=(0,i.useMemo)(()=>{let e=v.trim().toLowerCase();return e?S.filter(t=>t.id.toLowerCase().includes(e)||(t.name||"").toLowerCase().includes(e)):S},[S,v]),T=A.filter(e=>!e.added),$=T.length>0&&T.every(e=>y.has(e.id)),O=async()=>{if(!w&&0!==y.size){k(!0),p("");try{let e=await fetch("/api/models/custom/bulk",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerAlias:r,type:"llm",ids:[...y]})}),t=await e.json();if(!e.ok)return void p(t.error||"Import failed");C(t),window.dispatchEvent(new CustomEvent("customModelChanged")),o?.()}catch(e){p(e.message||"Network error")}finally{k(!1)}}};return(0,a.jsx)(c.aF,{isOpen:e,title:"Import Models from Provider",onClose:t,children:(0,a.jsx)("div",{className:"flex flex-col gap-3",children:N?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("p",{className:"text-sm text-text-main",children:["Imported ",N.added," model",1===N.added?"":"s",N.skipped>0?`, ${N.skipped} already existed`:"","."]}),(0,a.jsx)(c.$n,{onClick:t,fullWidth:!0,children:"Done"})]}):(0,a.jsxs)(a.Fragment,{children:[u&&(0,a.jsx)("p",{className:"text-xs text-red-500 break-words",children:u}),x&&!u&&(0,a.jsx)("p",{className:"text-xs text-amber-600 dark:text-amber-400 break-words",children:x}),d?(0,a.jsxs)("p",{className:"text-sm text-text-muted py-6 text-center",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-sm align-middle mr-1",style:{animation:"spin 1s linear infinite"},children:"progress_activity"}),"Fetching models from provider..."]}):f.length>0&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("input",{type:"text",value:v,onChange:e=>j(e.target.value),placeholder:"Search models...",className:"w-full px-3 py-2 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary"}),(0,a.jsxs)("label",{className:"flex cursor-pointer items-center gap-1.5 text-xs text-text-muted hover:text-primary",children:[(0,a.jsx)("input",{type:"checkbox",checked:$,onChange:()=>{b(e=>{let t=new Set(e);if($)for(let e of T)t.delete(e.id);else for(let e of T)t.add(e.id);return t})},className:"h-3.5 w-3.5 rounded border-gray-300 text-primary focus:ring-primary"}),"Select All (",T.length," available",A.length!==S.length?`, ${A.length} shown`:"",")"]}),(0,a.jsxs)("div",{className:"flex max-h-72 flex-col gap-1 overflow-y-auto custom-scrollbar pr-1",children:[A.map(e=>(0,a.jsxs)("label",{className:`flex items-center gap-2 rounded-lg border px-2.5 py-1.5 text-xs ${e.added?"border-border opacity-50":"border-border hover:border-primary/40 cursor-pointer"}`,children:[(0,a.jsx)("input",{type:"checkbox",checked:e.added||y.has(e.id),disabled:e.added,onChange:()=>{var t;return t=e.id,void b(e=>{let s=new Set(e);return s.has(t)?s.delete(t):s.add(t),s})},className:"h-3.5 w-3.5 rounded border-gray-300 text-primary focus:ring-primary"}),(0,a.jsx)("span",{className:"min-w-0 flex-1 truncate font-mono",children:e.id}),e.name&&(0,a.jsx)("span",{className:"truncate text-text-muted/70 italic",children:e.name}),e.added&&(0,a.jsx)("span",{className:"shrink-0 text-[10px] text-text-muted",children:"added"})]},e.id)),0===A.length&&(0,a.jsx)("p",{className:"py-4 text-center text-xs text-text-muted",children:"No models match the search"})]}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(c.$n,{onClick:O,fullWidth:!0,disabled:0===y.size||w,children:w?"Importing...":`Import Selected (${y.size})`}),(0,a.jsx)(c.$n,{onClick:t,variant:"ghost",fullWidth:!0,disabled:w,children:"Cancel"})]})]}),!d&&0===f.length&&!u&&(0,a.jsx)(c.$n,{onClick:t,variant:"ghost",fullWidth:!0,children:"Close"})]})})})}function _({modelId:e,fullModel:t,copied:s,onCopy:i,onDeleteAlias:r,onTest:l,testStatus:n,isTesting:o}){let d="ok"===n?"#22c55e":"error"===n?"#ef4444":void 0;return(0,a.jsxs)("div",{className:`flex items-center gap-3 p-3 rounded-lg border ${"ok"===n?"border-green-500/50":"error"===n?"border-red-500/50":"border-border"} hover:bg-sidebar/50`,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-base text-text-muted",style:d?{color:d}:void 0,children:"ok"===n?"check_circle":"error"===n?"cancel":"smart_toy"}),(0,a.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,a.jsx)("p",{className:"text-sm font-medium truncate",children:e}),(0,a.jsxs)("div",{className:"flex items-center gap-1 mt-1",children:[(0,a.jsx)("code",{className:"text-xs text-text-muted font-mono bg-sidebar px-1.5 py-0.5 rounded",children:t}),(0,a.jsxs)("div",{className:"relative group/btn",children:[(0,a.jsx)("button",{onClick:()=>i(t,`model-${e}`),className:"p-0.5 hover:bg-sidebar rounded text-text-muted hover:text-primary",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:s===`model-${e}`?"check":"content_copy"})}),(0,a.jsx)("span",{className:"pointer-events-none absolute top-5 left-1/2 -translate-x-1/2 text-[10px] text-text-muted whitespace-nowrap opacity-0 group-hover/btn:opacity-100 transition-opacity",children:s===`model-${e}`?"Copied!":"Copy"})]}),l&&(0,a.jsxs)("div",{className:"relative group/btn",children:[(0,a.jsx)("button",{onClick:l,disabled:o,className:"p-0.5 hover:bg-sidebar rounded text-text-muted hover:text-primary transition-colors",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",style:o?{animation:"spin 1s linear infinite"}:void 0,children:o?"progress_activity":"science"})}),(0,a.jsx)("span",{className:"pointer-events-none absolute top-5 left-1/2 -translate-x-1/2 text-[10px] text-text-muted whitespace-nowrap opacity-0 group-hover/btn:opacity-100 transition-opacity",children:o?"Testing...":"Test"})]})]})]}),(0,a.jsx)("button",{onClick:r,className:"p-1 hover:bg-red-50 rounded text-red-500",title:"Remove model",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:"delete"})})]})}function z({providerStorageAlias:e,providerDisplayAlias:t,modelAliases:s,customModels:r,copied:l,onCopy:n,onDeleteAlias:o,onAddCustomModel:d,onDeleteCustomModel:m,connections:u,isAnthropic:p,onModelsChanged:x,importSupported:h=!1}){let[f,g]=(0,i.useState)(""),[y,b]=(0,i.useState)(!1),[v,j]=(0,i.useState)(!1),[w,k]=(0,i.useState)(null),[N,C]=(0,i.useState)({}),S=async t=>{if(!w){k(t);try{let s=await fetch("/api/models/test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:`${e}/${t}`})}),a=await s.json();C(e=>({...e,[t]:a.ok?"ok":"error"}))}catch{C(e=>({...e,[t]:"error"}))}finally{k(null)}}},A=P({customModels:r,modelAliases:s,providerAlias:e,type:"llm"}),T=async()=>{if(!f.trim()||y)return;let e=f.trim();if(A.some(t=>t.id===e))return void alert("Model already exists for this provider.");b(!0);try{await d(e),g("")}catch(e){console.log("Error adding model:",e)}finally{b(!1)}},$=u.find(e=>!1!==e.isActive)?.id||null,O=!!$&&!0===h,I=new Set(A.map(e=>e.id));return(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,a.jsxs)("p",{className:"text-sm text-text-muted",children:["Add ",p?"Anthropic":"OpenAI","-compatible models manually or import them from the /models endpoint."]}),(0,a.jsxs)("div",{className:"flex items-end gap-2 flex-wrap",children:[(0,a.jsxs)("div",{className:"flex-1 min-w-[240px]",children:[(0,a.jsx)("label",{htmlFor:"new-compatible-model-input",className:"text-xs text-text-muted mb-1 block",children:"Model ID"}),(0,a.jsx)("input",{id:"new-compatible-model-input",type:"text",value:f,onChange:e=>g(e.target.value),onKeyDown:e=>"Enter"===e.key&&T(),placeholder:p?"claude-3-opus-20240229":"gpt-4o",className:"w-full px-3 py-2 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary"})]}),(0,a.jsx)(c.$n,{size:"sm",icon:"add",onClick:T,disabled:!f.trim()||y,children:y?"Adding...":"Add"}),(0,a.jsx)(c.$n,{size:"sm",variant:"secondary",icon:"download",onClick:()=>j(!0),disabled:!O,children:"Import from /models"})]}),!O&&(0,a.jsx)("p",{className:"text-xs text-text-muted",children:$?"Set a Base URL on the active connection to enable importing models.":"Add a connection to enable importing models."}),A.length>0&&(0,a.jsx)("div",{className:"flex flex-col gap-3",children:A.map(({id:s,alias:i,source:r})=>(0,a.jsx)(_,{modelId:s,fullModel:`${t}/${s}`,copied:l,onCopy:n,onDeleteAlias:()=>"custom"===r?m(s):o(i),onTest:u.length>0?()=>S(s):void 0,testStatus:N[s],isTesting:w===s},`${r}-${e}/${s}`))}),(0,a.jsx)(q,{isOpen:v,onClose:()=>j(!1),connectionId:$,providerStorageAlias:e,existingIds:I,onImported:x})]})}function U({isOpen:e,onClose:t,providerId:s,providerAlias:r,connections:l,customModels:n,disabledModelIds:o,onSaved:d}){let[m,p]=(0,i.useState)([]),[x,h]=(0,i.useState)(()=>new Set),[f,g]=(0,i.useState)(""),[y,b]=(0,i.useState)(!0),[v,j]=(0,i.useState)(!1),[w,k]=(0,i.useState)(""),N=(0,i.useMemo)(()=>(l||[]).filter(e=>!1!==e.isActive&&e.id).map(e=>e.id),[l]);(0,i.useEffect)(()=>{if(!e)return;let t=!1;return(async()=>{let e=[];try{let t=await fetch(`/api/models/enabled?providerAlias=${encodeURIComponent(r)}`,{cache:"no-store"});t.ok&&(e=(await t.json()).ids||[])}catch{}let a=await Promise.all(N.map(async e=>{try{let t=await fetch(`/api/providers/${e}/models`,{cache:"no-store"});if(!t.ok)return[];let s=await t.json();return Array.isArray(s?.models)?s.models:[]}catch{return[]}}));if(t)return;let i=new Set,l=[],n=(e,t,s={})=>{let a=String(e??"").trim();!a||i.has(a)||(i.add(a),l.push({id:a,name:t||a,...s}))};for(let e of a)for(let t of e)n("string"==typeof t?t:t?.id,"string"==typeof t?t:t?.name||t?.id,{live:!0});for(let e of(0,u.KC)(s)||[]){let t=(0,u.CP)(e,"llm");t&&"llm"!==t||n(e.id,e.name)}for(let t of e)n(t,t,{stale:!0});let d=new Set(o||[]),c=e.length>0?e:l.filter(e=>!e.isCustom&&!d.has(e.id)).map(e=>e.id);p(l),h(new Set(c)),b(!1)})(),()=>{t=!0}},[e,s,r,N,o]);let C=(0,i.useMemo)(()=>(n||[]).filter(e=>e.providerAlias===r&&"llm"===(e.kind||e.type||"llm")).map(e=>({id:String(e.id).trim(),name:e.name||e.id})).filter(e=>e.id),[n,r]),S=(0,i.useMemo)(()=>{let e=f.trim().toLowerCase();return e?m.filter(t=>t.id.toLowerCase().includes(e)||t.name.toLowerCase().includes(e)):m},[m,f]),A=async()=>{j(!0),k("");try{let e=Array.from(x),s=await fetch("/api/models/enabled",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerAlias:r,ids:e})});if(!s.ok){let e=await s.json().catch(()=>({}));throw Error(e.error||`Failed to save (${s.status})`)}d?.(e),t()}catch(e){k(e?.message||"Failed to save visible models")}finally{j(!1)}};return(0,a.jsx)(c.aF,{isOpen:e,onClose:t,title:"Visible models",size:"lg",footer:null,children:(0,a.jsxs)("div",{className:"flex flex-col gap-3 p-4",children:[(0,a.jsxs)("div",{className:"flex items-start gap-2 rounded-lg border border-primary/20 bg-primary/8 px-2.5 py-2 text-xs text-text-muted",children:[(0,a.jsx)("span",{className:"material-symbols-outlined shrink-0 text-primary",style:{fontSize:"14px"},children:"info"}),(0,a.jsxs)("span",{children:["Only the checked models are exposed on ",(0,a.jsx)("code",{className:"font-mono",children:"/v1/models"}),". Leave everything unchecked to expose all of them. Custom models are always exposed."]})]}),(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsxs)("div",{className:"relative flex-1",children:[(0,a.jsx)("span",{className:"material-symbols-outlined absolute left-2.5 top-1/2 -translate-y-1/2 text-text-muted text-[16px]",children:"search"}),(0,a.jsx)("input",{type:"text",placeholder:"Search...",value:f,onChange:e=>g(e.target.value),className:"w-full rounded border border-border bg-surface py-1.5 pl-8 pr-3 text-xs focus:outline-none focus:ring-1 focus:ring-primary/50"})]}),(0,a.jsx)(c.$n,{variant:"ghost",size:"sm",onClick:()=>h(new Set(m.map(e=>e.id))),disabled:y||v,children:"Select all"}),(0,a.jsx)(c.$n,{variant:"ghost",size:"sm",onClick:()=>h(new Set),disabled:y||v,children:"Clear"})]}),w&&(0,a.jsx)("p",{className:"text-xs text-red-500 break-words",children:w}),y?(0,a.jsx)("p",{className:"py-6 text-center text-xs text-text-muted",children:"Loading models…"}):(0,a.jsxs)("div",{className:"max-h-[360px] overflow-y-auto rounded-lg border border-border",children:[S.map(e=>(0,a.jsxs)("label",{className:"flex cursor-pointer items-center gap-2 border-b border-border/50 px-3 py-2 last:border-b-0 hover:bg-sidebar/50",children:[(0,a.jsx)("input",{type:"checkbox",checked:x.has(e.id),onChange:()=>{var t;return t=e.id,void h(e=>{let s=new Set(e);return s.has(t)?s.delete(t):s.add(t),s})},className:"size-3.5 accent-primary cursor-pointer"}),(0,a.jsx)("span",{className:"truncate text-xs text-text-main",children:e.name}),(0,a.jsx)("code",{className:"truncate font-mono text-[11px] text-text-muted",children:e.id}),e.live&&!e.stale&&(0,a.jsx)("span",{className:"ml-auto shrink-0 rounded bg-primary/10 px-1.5 py-0.5 text-[10px] text-primary",children:"live"}),e.stale&&(0,a.jsx)("span",{className:"ml-auto shrink-0 rounded bg-amber-500/10 px-1.5 py-0.5 text-[10px] text-amber-600 dark:text-amber-400",children:"not in catalog"})]},e.id)),0===S.length&&(0,a.jsx)("p",{className:"py-6 text-center text-xs text-text-muted",children:"No models found"})]}),C.length>0&&(0,a.jsxs)("div",{className:"rounded-lg border border-border px-3 py-2",children:[(0,a.jsx)("p",{className:"mb-1 text-[11px] text-text-muted",children:"Always exposed (custom models)"}),(0,a.jsx)("div",{className:"flex flex-wrap gap-1.5",children:C.map(e=>(0,a.jsx)("span",{className:"rounded bg-sidebar px-1.5 py-0.5 font-mono text-[11px] text-text-muted",children:e.id},e.id))})]}),(0,a.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,a.jsx)("span",{className:"text-[11px] text-text-muted",children:0===x.size?"Nothing selected — all models stay visible.":`${x.size} of ${m.length} selected`}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(c.$n,{variant:"ghost",size:"sm",onClick:t,disabled:v,children:"Cancel"}),(0,a.jsx)(c.$n,{variant:"primary",size:"sm",onClick:A,loading:v,disabled:y,children:"Save"})]})]})]})})}D.propTypes={model:E().shape({id:E().string.isRequired}).isRequired,fullModel:E().string.isRequired,alias:E().string,copied:E().string,onCopy:E().func.isRequired,testStatus:E().oneOf(["ok","error","slow","rate_limited","not_tested"]),isCustom:E().bool,isFree:E().bool,onDeleteAlias:E().func,onTest:E().func,isTesting:E().bool,onDisable:E().func,caps:E().object,thinkingSuffix:E().string},E().string.isRequired,E().string.isRequired,E().string,E().func.isRequired,E().func.isRequired,E().func,E().oneOf(["ok","error"]),E().bool,E().string.isRequired,E().object.isRequired,E().arrayOf(E().object),E().string,E().func.isRequired,E().func.isRequired,E().func.isRequired,E().func.isRequired,q.propTypes={isOpen:E().bool.isRequired,onClose:E().func.isRequired,connectionId:E().string,providerStorageAlias:E().string.isRequired,existingIds:E().instanceOf(Set),transformId:E().func,onImported:E().func},_.propTypes={modelId:E().string.isRequired,fullModel:E().string.isRequired,copied:E().string,onCopy:E().func.isRequired,onDeleteAlias:E().func.isRequired,onTest:E().func,testStatus:E().string,isTesting:E().bool},z.propTypes={providerStorageAlias:E().string.isRequired,providerDisplayAlias:E().string.isRequired,modelAliases:E().object.isRequired,customModels:E().arrayOf(E().object),copied:E().string,onCopy:E().func.isRequired,onDeleteAlias:E().func.isRequired,onAddCustomModel:E().func.isRequired,onDeleteCustomModel:E().func.isRequired,connections:E().arrayOf(E().shape({id:E().string,isActive:E().bool})).isRequired,isAnthropic:E().bool,onModelsChanged:E().func,importSupported:E().bool},U.propTypes={isOpen:E().bool.isRequired,onClose:E().func.isRequired,providerId:E().string.isRequired,providerAlias:E().string.isRequired,connections:E().arrayOf(E().object),customModels:E().arrayOf(E().object),disabledModelIds:E().arrayOf(E().string),onSaved:E().func};var F=s(47650),L=s(70217);function J({until:e}){let[t,s]=(0,i.useState)("");return((0,i.useEffect)(()=>{let t=()=>{let t=new Date(e).getTime()-Date.now();if(t<=0)return void s("");let a=Math.floor(t/1e3);if(a<60)s(`${a}s`);else if(a<3600)s(`${Math.floor(a/60)}m ${a%60}s`);else{let e=Math.floor(a/3600),t=Math.floor(a%3600/60);s(`${e}h ${t}m`)}};t();let a=setInterval(t,1e3);return()=>clearInterval(a)},[e]),t)?(0,a.jsxs)("span",{className:"text-xs text-orange-500 font-mono",children:["⏱ ",t]}):null}J.propTypes={until:E().string.isRequired};var K=s(64827),H=s(14558),W=s(7462);let B=["invalid_grant","refresh_token_expired","reauth_required","unrecoverable_refresh_error","refresh_token_reused","refresh_token_invalidated"];function G(e){if(!e||"string"!=typeof e)return!1;let t=e.toLowerCase();return B.some(e=>t.includes(e))}function Q({connection:e,plan:t=null,proxyPools:s,isOAuth:r,isFirst:l,isLast:n,onMoveUp:o,onMoveDown:d,onToggleActive:m,onUpdateProxy:u,onEdit:p,onDelete:x,onReconnect:h=null,oneByOneStatus:f=null,autoPing:g=null,fastMode:y=null}){let[b,v]=(0,i.useState)(!1),j=(0,W.gr)(e.providerSpecificData?.quotaReserve),w=W.vP.filter(e=>j[e.id]).map(e=>`${e.label} ${j[e.id]}%`).join(" \xb7 "),[k,N]=(0,i.useState)(!1),[C,A]=(0,i.useState)(!1),T=(0,i.useRef)(null),$=(0,i.useRef)(null),[O,P]=(0,i.useState)(null),{copied:I,copy:E}=(0,S.C)(),R=`conn-id-${e.id}`,M=async()=>{if(y?.onToggle&&!C){A(!0);try{await y.onToggle(!y.on)}catch(e){console.error("Failed to toggle fast mode:",e)}finally{A(!1)}}},D=new Map((s||[]).map(e=>[e.id,e])),q=e.providerSpecificData?.proxyPoolId||null,_=q?D.get(q):null,z=e.providerSpecificData?.connectionProxyEnabled===!0&&!!e.providerSpecificData?.connectionProxyUrl,U=!!q||z,B=_?`Pool: ${_.name}`:q?`Pool: ${q} (inactive/missing)`:z?`Legacy: ${e.providerSpecificData?.connectionProxyUrl}`:"",V=(()=>{if(!g)return"";let e=[];return(g.reactiveOn&&e.push("On reset"),g.scheduleOn&&e.push(`Scheduled (${g.scheduleSummary||"active"})`),e.length>0)?`Auto-ping active: ${e.join(" + ")}. Click to configure.`:"codex"===g.provider?"Auto-starts the next 5h Codex window after reset or on schedule. Click to configure.":"Auto-starts a new window on quota reset or fixed schedule. Click to configure."})(),Z="";if(_?.proxyUrl||e.providerSpecificData?.connectionProxyUrl){let t=_?.proxyUrl||e.providerSpecificData?.connectionProxyUrl;try{let e=new URL(t);Z=`${e.protocol}//${e.hostname}${e.port?`:${e.port}`:""}`}catch{Z=t}}let X=_?.noProxy||e.providerSpecificData?.connectionNoProxy||"",Y="default";_?.isActive===!0?Y="success":(q||z)&&(Y="error"),(0,i.useEffect)(()=>{if(!b)return;let e=e=>{T.current?.contains(e.target)||$.current?.contains(e.target)||v(!1)},t=()=>v(!1);return document.addEventListener("mousedown",e),window.addEventListener("resize",t),document.addEventListener("scroll",t,!0),()=>{document.removeEventListener("mousedown",e),window.removeEventListener("resize",t),document.removeEventListener("scroll",t,!0)}},[b]);let ee=async e=>{N(!0);try{await u("__none__"===e?null:e)}finally{N(!1),v(!1)}},et=e.authType||(r?"oauth":"apikey"),es="oauth"===et,ea="cookie"===et,ei=e.name?.trim()||e.email?.trim()||e.displayName?.trim()||(es?"OAuth Account":ea?"Cookie Account":"API Key"),er=e.name?.trim()&&e.email?.trim()&&e.name.trim()!==e.email.trim()?e.email.trim():e.name?.trim()&&e.displayName?.trim()&&e.name.trim()!==e.displayName.trim()?e.displayName.trim():null,el=t?.trim(),en=e.providerSpecificData?.chatgptPlanType?.trim(),eo="codex"===e.provider?el&&"unknown"!==el.toLowerCase()?el:en:null,[ed,ec]=(0,i.useState)(!1),em=(0,K.kJ)(e);(0,i.useEffect)(()=>{let t=()=>{ec(!!(0,K.kJ)(e))};t();let s=em?setInterval(t,1e3):null;return()=>{s&&clearInterval(s)}},[em]);let eu="unavailable"!==e.testStatus||ed?e.testStatus:"active",ep=(es||ea)&&"unavailable"===e.testStatus&&function(e,t){if(401===e||403===e)return!0;if(!t||"string"!=typeof t)return!1;let s=t.toLowerCase();return s.includes("unauthorized")||s.includes("token")||s.includes("invalid api key")||s.includes("revoked")||s.includes("auth")||G(t)}(e.errorCode,e.lastError),ex=G(e.lastError)?"Auth expired — reconnect required":e.lastError,eh=()=>f?"queued"===f.state?"queued":"testing"===f.state?"testing":"success"===f.state?"success":"failed"===f.state?f.error?`failed: ${f.error}`:"failed":null:null;return(0,a.jsxs)("div",{className:`group flex min-w-0 flex-col gap-3 rounded-lg p-2 transition-colors hover:bg-black/[0.02] dark:hover:bg-white/[0.02] sm:flex-row sm:items-center sm:justify-between ${!1===e.isActive?"opacity-60":""}`,children:[(0,a.jsxs)("div",{className:"flex min-w-0 flex-1 items-start gap-2 sm:items-center sm:gap-3",children:[(0,a.jsxs)("div",{className:"flex shrink-0 flex-col",children:[(0,a.jsx)("button",{onClick:o,disabled:l,className:`p-0.5 rounded ${l?"text-text-muted/30 cursor-not-allowed":"hover:bg-sidebar text-text-muted hover:text-primary"}`,children:(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:"keyboard_arrow_up"})}),(0,a.jsx)("button",{onClick:d,disabled:n,className:`p-0.5 rounded ${n?"text-text-muted/30 cursor-not-allowed":"hover:bg-sidebar text-text-muted hover:text-primary"}`,children:(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:"keyboard_arrow_down"})})]}),(0,a.jsx)("span",{className:"material-symbols-outlined shrink-0 text-base text-text-muted",children:ea?"cookie":es?"lock":"key"}),(0,a.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,a.jsx)("p",{className:"text-sm font-medium truncate",children:ei}),er&&(0,a.jsx)("p",{className:"text-xs text-text-muted truncate",children:er}),(0,a.jsxs)("div",{className:"mt-1 flex min-w-0 flex-wrap items-center gap-1.5 sm:gap-2",children:[(0,a.jsx)(c.Ex,{variant:(0,L.g)(e.isActive,eu),size:"sm",dot:!0,children:!1===e.isActive?"disabled":eu||"Unknown"}),(0,a.jsx)(c.Ex,{variant:"default",size:"sm",children:es?"OAuth":ea?"Cookie":"API Key"}),eo&&"unknown"!==eo.toLowerCase()&&(0,a.jsx)(c.Ex,{variant:"primary",size:"sm",children:eo}),U&&(0,a.jsx)(c.Ex,{variant:Y,size:"sm",children:"Proxy"}),ed&&!1!==e.isActive&&(0,a.jsx)(J,{until:em}),e.lastError&&!1!==e.isActive&&(0,a.jsx)("span",{className:"max-w-full truncate text-xs text-red-500 sm:max-w-[300px]",title:e.lastError,children:ex}),(0,a.jsxs)("span",{className:"text-xs text-text-muted",children:["#",e.priority]}),(0,a.jsxs)("button",{type:"button",onClick:()=>E(e.id||"",R),title:"Copy connection ID — send it as the x-connection-id request header to pin requests to this account (falls back to other accounts when it is unavailable)",className:"flex items-center gap-0.5 rounded font-mono text-[11px] text-text-muted transition-colors hover:text-primary",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-xs",children:I===R?"check":"content_copy"}),I===R?"copied":`${(e.id||"").slice(0,8)}…`]}),w&&(0,a.jsx)(c.m_,{text:"Quota kept in reserve: requests move to the next account at this share",children:(0,a.jsx)(c.Ex,{variant:"default",size:"sm",icon:"savings",children:w})}),e.globalPriority&&(0,a.jsxs)("span",{className:"text-xs text-text-muted",children:["Auto: ",e.globalPriority]}),eh()&&(0,a.jsx)(c.Ex,{variant:f?"success"===f.state?"success":"failed"===f.state?"error":"testing"===f.state?"primary":"default":"default",size:"sm",children:eh()})]}),U&&(0,a.jsxs)("div",{className:"mt-1 flex items-center gap-2 flex-wrap",children:[(0,a.jsx)("span",{className:"max-w-full truncate text-[11px] text-text-muted sm:max-w-[420px]",title:B,children:B}),Z&&(0,a.jsx)("code",{className:"max-w-full truncate rounded bg-black/5 px-1 py-0.5 font-mono text-[10px] text-text-muted dark:bg-white/5 sm:max-w-[260px]",children:Z}),X&&(0,a.jsxs)("span",{className:"max-w-full truncate text-[11px] text-text-muted sm:max-w-[320px]",title:X,children:["no_proxy: ",X]})]})]})]}),(0,a.jsxs)("div",{className:"flex w-full items-center justify-between gap-2 sm:w-auto sm:justify-end",children:[(0,a.jsxs)("div",{className:"grid flex-1 grid-cols-3 gap-1 sm:flex sm:flex-none",children:[(s||[]).length>0&&(0,a.jsxs)("div",{children:[(0,a.jsxs)("button",{ref:$,onClick:()=>{if(b)return void v(!1);let e=$.current?.getBoundingClientRect();if(!e)return void v(!0);let t=((s?.length||0)+1)*34+8,a=window.innerHeight-e.bottom,i=a<t&&e.top>a;P({position:"fixed",right:window.innerWidth-e.right,...i?{bottom:window.innerHeight-e.top+4,maxHeight:Math.max(e.top-8,120)}:{top:e.bottom+4,maxHeight:Math.max(a-8,120)}}),v(!0)},className:`flex w-full flex-col items-center rounded px-2 py-1 transition-colors hover:bg-black/5 dark:hover:bg-white/5 ${U?"text-primary":"text-text-muted hover:text-primary"}`,disabled:k,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:k?"progress_activity":"lan"}),(0,a.jsx)("span",{className:"text-[10px] leading-tight",children:"Proxy"})]}),b&&(0,F.createPortal)((0,a.jsxs)("div",{ref:T,style:O,className:"z-50 max-w-[78vw] min-w-[160px] overflow-y-auto rounded-lg border border-border bg-bg py-1 shadow-lg",children:[(0,a.jsx)("button",{onClick:()=>ee("__none__"),className:`w-full text-left px-3 py-1.5 text-sm hover:bg-black/5 dark:hover:bg-white/5 ${!q?"text-primary font-medium":"text-text-main"}`,children:"None"}),(s||[]).map(e=>(0,a.jsx)("button",{onClick:()=>ee(e.id),className:`w-full text-left px-3 py-1.5 text-sm hover:bg-black/5 dark:hover:bg-white/5 ${q===e.id?"text-primary font-medium":"text-text-main"}`,children:e.name},e.id))]}),document.body)]}),y&&(0,a.jsx)(c.m_,{text:"codex"===e.provider?y.on?"Fast mode ON — Codex requests on this account use the priority tier. Click to disable.":"Force fast mode — Codex requests on this account use the priority tier.":"Uses the provider's faster processing mode for this account at a higher token cost. Off by default.",children:(0,a.jsxs)("button",{type:"button",role:"switch","aria-label":"Fast mode","aria-checked":y.on,disabled:C,onClick:M,className:`flex w-full flex-col items-center rounded px-2 py-1 transition-colors hover:bg-black/5 dark:hover:bg-white/5 disabled:opacity-50 ${y.on?"text-primary":"text-text-muted hover:text-primary"}`,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:C?"progress_activity":"speed"}),(0,a.jsx)("span",{className:"text-[10px] leading-tight",children:"Fast"})]})}),g&&(0,a.jsx)(c.m_,{text:V,children:(0,a.jsxs)("button",{onClick:g.onConfigure,className:`flex w-full flex-col items-center rounded px-2 py-1 transition-colors hover:bg-black/5 dark:hover:bg-white/5 ${g.isActive?"text-primary":"text-text-muted hover:text-primary"}`,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"bolt"}),(0,a.jsx)("span",{className:"text-[10px] leading-tight",children:"Auto-ping"})]})}),ep&&h&&(0,a.jsxs)("button",{onClick:()=>h(e),className:"flex flex-col items-center rounded px-2 py-1 text-amber-600 hover:bg-amber-500/10 dark:text-amber-400 dark:hover:bg-amber-500/20 transition-colors",title:"Reconnect account",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"lock_reset"}),(0,a.jsx)("span",{className:"text-[10px] leading-tight font-semibold",children:"Reconnect"})]}),g&&(0,a.jsx)(H.A,{connectionId:e.id,disabled:!1===e.isActive}),(0,a.jsxs)("button",{onClick:p,className:"flex flex-col items-center rounded px-2 py-1 text-text-muted hover:bg-black/5 hover:text-primary dark:hover:bg-white/5",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"edit"}),(0,a.jsx)("span",{className:"text-[10px] leading-tight",children:"Edit"})]}),(0,a.jsxs)("button",{onClick:x,className:"flex flex-col items-center rounded px-2 py-1 text-red-500 hover:bg-red-500/10",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"delete"}),(0,a.jsx)("span",{className:"text-[10px] leading-tight",children:"Delete"})]})]}),(0,a.jsx)(c.lM,{size:"sm",checked:e.isActive??!0,onChange:m,title:e.isActive??!0?"Disable connection":"Enable connection"})]})]})}Q.propTypes={connection:E().shape({id:E().string,name:E().string,email:E().string,displayName:E().string,modelLockUntil:E().string,testStatus:E().string,isActive:E().bool,lastError:E().string,priority:E().number,globalPriority:E().number}).isRequired,plan:E().string,proxyPools:E().arrayOf(E().shape({id:E().string,name:E().string,proxyUrl:E().string,noProxy:E().string,isActive:E().bool})),isOAuth:E().bool.isRequired,isFirst:E().bool.isRequired,isLast:E().bool.isRequired,onMoveUp:E().func.isRequired,onMoveDown:E().func.isRequired,onToggleActive:E().func.isRequired,onUpdateProxy:E().func,onEdit:E().func.isRequired,onDelete:E().func.isRequired,onReconnect:E().func,oneByOneStatus:E().shape({state:E().string,error:E().string}),autoPing:E().shape({isActive:E().bool,provider:E().string,reactiveOn:E().bool,scheduleOn:E().bool,scheduleSummary:E().string,onConfigure:E().func}),fastMode:E().shape({on:E().bool,onToggle:E().func})};var V=s(9339);let Z=(0,V.createServerReference)("405b7b833b5fbb4a342041e03e42294fe2a97a6aca",V.callServer,void 0,V.findSourceMapURL,"exportProviderKeys");function X({isOpen:e,providerId:t,providerName:s,onClose:r}){let[l,n]=(0,i.useState)([]),[o,d]=(0,i.useState)(!1),[m,u]=(0,i.useState)(null);(0,i.useEffect)(()=>{if(!e)return;let s=!1;return(async()=>{d(!0),u(null);try{let e=await Z(t);s||n(e.connections||[])}catch{s||n([])}finally{s||d(!1)}})(),()=>{s=!0}},[e,t]);let p=async e=>{try{await navigator.clipboard.writeText(e.key),u(e.id),setTimeout(()=>u(t=>t===e.id?null:t),1500)}catch{}},x=async()=>{let e=l.filter(e=>e.key).map(e=>`${e.name}: ${e.key}`).join("\n");try{await navigator.clipboard.writeText(e),u("__all__"),setTimeout(()=>u(e=>"__all__"===e?null:e),1500)}catch{}},h=l.filter(e=>e.key);return(0,a.jsx)(c.aF,{isOpen:e,title:`Export Keys — ${s||t}`,onClose:r,children:(0,a.jsxs)("div",{className:"flex flex-col gap-3",children:[o&&(0,a.jsx)("p",{className:"text-sm text-text-muted",children:"Loading…"}),!o&&0===h.length&&(0,a.jsx)("p",{className:"text-sm text-text-muted",children:"No keys stored for this provider."}),!o&&h.map(e=>(0,a.jsxs)("div",{className:"flex items-center gap-2 rounded-lg border border-border-subtle bg-sidebar px-3 py-2",children:[(0,a.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,a.jsx)("p",{className:"truncate text-xs text-text-muted",children:e.name}),(0,a.jsx)("p",{className:"break-all text-sm font-mono text-text-main",children:e.key})]}),(0,a.jsx)("button",{onClick:()=>p(e),title:"Copy key",className:`shrink-0 rounded p-1.5 hover:bg-black/5 dark:hover:bg-white/5 ${m===e.id?"text-green-500":"text-text-muted hover:text-primary"}`,children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:m===e.id?"check":"content_copy"})})]},e.id)),!o&&h.length>0&&(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(c.$n,{size:"sm",icon:"__all__"===m?"check":"content_copy",onClick:x,children:"__all__"===m?"Copied":"Copy All"}),(0,a.jsx)(c.$n,{size:"sm",variant:"ghost",onClick:r,children:"Close"})]})]})})}let Y=`name1|sk-key1
|
|
1
|
+
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[2134],{9339:(e,t,s)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});var a={callServer:function(){return r.callServer},createServerReference:function(){return n.createServerReference},findSourceMapURL:function(){return l.findSourceMapURL}};for(var i in a)Object.defineProperty(t,i,{enumerable:!0,get:a[i]});let r=s(77304),l=s(4060),n=s(77197)},14558:(e,t,s)=>{"use strict";s.d(t,{A:()=>l});var a=s(95155),i=s(12115),r=s(97677);function l({connectionId:e,disabled:t=!1,onComplete:s}){let[n,o]=(0,i.useState)(!1),[d,c]=(0,i.useState)(null);async function m(){if(!n){if(d)return void c(null);o(!0);try{let t=await fetch("/api/wakeup",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"ping",connectionId:e})}),a=await t.json();if(!t.ok)throw Error(a.error||"Ping failed.");c(a),s&&Promise.resolve(s()).catch(()=>{})}catch(e){c({status:"failed",message:e.message})}finally{o(!1)}}}let u=n?"Pinging…":d?`${d.message} Click to reset.`:"Ping now — sends a small request. Consumes quota; does not change Auto-Ping.",p=d?"succeeded"===d.status?"text-green-600 dark:text-green-400":"text-red-600 dark:text-red-400":"text-text-muted hover:text-primary";return(0,a.jsx)(r.default,{text:u,children:(0,a.jsx)("button",{type:"button",onClick:m,disabled:n||t&&!d,"aria-label":u,"aria-busy":n,className:`flex h-8 w-8 items-center justify-center rounded-lg ${p} hover:bg-surface-2 disabled:cursor-not-allowed disabled:opacity-50`,children:(0,a.jsx)("span",{"aria-hidden":"true",style:{fontSize:n?20:32},className:`material-symbols-outlined ${n?"animate-spin":""}`,children:n?"progress_activity":"play_arrow"})})})}},25871:(e,t,s)=>{"use strict";s.d(t,{G:()=>n,e:()=>d});var a=s(12115);let i=null,r=null,l="pricingChanged";function n(){i=null,window.dispatchEvent(new CustomEvent(l))}function o(){return i?Promise.resolve(i):r||(r=fetch("/api/pricing").then(async e=>{if(!e.ok)throw Error(`pricing ${e.status}`);return e.json()}).then(e=>i=e||{}).catch(()=>({})).finally(()=>{r=null}))}function d(){let[e,t]=(0,a.useState)(()=>i||{});return(0,a.useEffect)(()=>{let e=!0;o().then(s=>{e&&t(s)});let s=()=>{o().then(s=>{e&&t(s)})};return window.addEventListener(l,s),()=>{e=!1,window.removeEventListener(l,s)}},[]),{getPricing:(0,a.useCallback)((t,s)=>t&&s&&e[t]?.[s]||null,[e])}}},50136:(e,t,s)=>{"use strict";s.r(t),s.d(t,{default:()=>eC});var a=s(95155),i=s(12115),r=s(73321),l=s(98500),n=s.n(l),o=s(5772),d=s(8247),c=s(35497),m=s(88105),u=s(28777),p=s(57151),x=s(47224),h=s(40228),f=s(89523);let g=["none","low","medium","high"],y=["none","thinking"],b=["none","low","medium","high","max"],v=["none","low","medium","high","xhigh","max"],j={qoder:v,openai:["none","minimal","low","medium","high","xhigh"],"claude-adaptive":v,"claude-budget":v,"gemini-level":["minimal","low","medium","high"],"gemini-budget":g,zai:y,qwen:g,kimi:b,opencode:b,deepseek:["none","high","max"],minimax:y,hunyuan:g,step:g,nous:g,meta:["minimal","low","medium","high","xhigh"],ollama:b},w=["none","minimal","low","medium","high","xhigh","max"],k=["none","low","medium","high","max"],N=[{pattern:"*gemini-4*",levels:["low","medium","high"]},{pattern:"*claude*4.6*",levels:k},{pattern:"*claude*4-6*",levels:k},{provider:"codex",pattern:"*gpt-6*",levels:w},{provider:"codex",pattern:"*gpt-5.6-sol*",levels:[...w,"ultra"]},{provider:"codex",pattern:"*gpt-5.6-terra*",levels:[...w,"ultra"]},{provider:"codex",pattern:"*gpt-5.6-luna*",levels:w},{providers:["openai","codex"],pattern:"*gpt-5.6*",levels:["none","minimal","low","medium","high","xhigh","max","ultra"]},{pattern:"*codex*",levels:["low","medium","high","xhigh"]},{provider:"opencode",pattern:"*mimo*v2.6*",levels:["none","minimal","low","medium","high","xhigh","max"]},{pattern:"*mimo*v2.6*",levels:["none","low","medium","high","xhigh"]},{pattern:"*mimo*v2.5-pro*",levels:["none","low","medium","high","xhigh"]},{provider:"ollama",pattern:"*gpt-oss*",levels:["none","low","medium","high"]},{provider:"ollama-local",pattern:"*gpt-oss*",levels:["none","low","medium","high"]},{provider:"qoder",pattern:"*",levels:v},{provider:"codebuddy-cn",pattern:"deepseek-v4-pro",levels:["low","high","xhigh"]},{provider:"codebuddy-cn",pattern:"deepseek-v4.1-flash",levels:["low","high","max"]},{pattern:"*deepseek-v4.1-flash-free*",levels:["low","high","max"]},{pattern:"*deepseek-v4.*",levels:["none","low","medium","high","xhigh","max"]},{provider:"codebuddy-cn",pattern:"glm-5.3",levels:["low","high","max"]},{provider:"codebuddy-cn",pattern:"glm-5.3-flash",levels:["low","high","max"]},{provider:"codebuddy-cn",pattern:"glm-5.2",levels:["high","xhigh"]},{provider:"codebuddy-cn",pattern:"kimi-k2.8-preview",levels:["low","medium","high"]},{provider:"codebuddy-cn",pattern:"hy3",levels:["low","high"]},{provider:"codebuddy-cn",pattern:"hy4-preview",levels:["high"]},{provider:"codebuddy-intl",pattern:"deepseek-v4*",levels:["low","high","xhigh"]},{provider:"minimax-code",pattern:"MiniMax-M3.1*",levels:["low","medium","high","xhigh","max"]},{provider:"minimax-code",pattern:"MiniMax-M3",levels:["none","high"]},{provider:"minimax-code-global",pattern:"MiniMax-M3.1*",levels:["low","medium","high","xhigh","max"]},{provider:"minimax-code-global",pattern:"MiniMax-M3",levels:["none","high"]},{pattern:"*glm-5.3",levels:["low","high","max"]}];function C(e,t){if("kiro"===e&&null===function(e){if("string"!=typeof e)return null;let t=e.toLowerCase().replace(/-/g,".");if(/(?:^|[/.])gpt[/.]5[/.]6(?:[/.]|$)/.test(t))return"reasoning";if(!t.includes("claude"))return null;let s=function(e){if("string"!=typeof e)return null;let t=e.toLowerCase().replace(/-/g,".").match(/(?:^|[/.])claude(?:[/.][a-z]+)*[/.](\d+)(?:[/.](\d+))?(?:[/.]|$)/);return t?{major:Number(t[1]),minor:void 0===t[2]?null:Number(t[2])}:null}(e);if(!s)return null;let{major:a,minor:i}=s;return a<4||4===a&&(null===i||i<=5||null!==i&&i>=1e3)?null:"output_config"}(t))return null;let s=(0,p.nl)(e,t);if(!s.reasoning)return null;let a=String(t||"").replace(/\([^()]+\)\s*$/,""),i="codex"===e?(0,f.SM)("cx").find(e=>e.id===a)?.thinkingLevels:null,r=N.find(s=>(!s.providers||!e||s.providers.includes(e))&&(!s.provider||s.provider===e)&&(0,x.gH)(s.pattern,t)),l=(e?h.xq[e]?.thinkingFormat:null)||s.thinkingFormat,n=i||s.thinkingLevels||r?.levels||j[l]||g;return!1===s.thinkingCanDisable&&(n=n.filter(e=>"none"!==e)),n}var S=s(11059),A=s(929),T=s(73006);let $=new Map;async function O(e,t){if(e?.type==="static")return e.models||[];if(!e?.url||!e?.type)return[];let s="nous"===t||e.url?.includes("nousresearch")?"nous":e.type,a=`${e.url}#${s}`,i=$.get(a);if(i&&Date.now()<i.expiresAt)return i.data;try{let t=new URLSearchParams({url:e.url,type:s}),i=await fetch(`/api/providers/suggested-models?${t}`);if(!i.ok)return[];let r=(await i.json()).data??[];return $.set(a,{data:r,expiresAt:Date.now()+6e5}),r}catch{return[]}}function P({customModels:e=[],modelAliases:t={},providerAlias:s,builtInModels:a=[],type:i="llm",includeLegacyAliases:r=!0}){let l=new Set(a.map(e=>e.id)),n=new Set,o=[];for(let t of e){if(!t?.id||t.providerAlias!==s)continue;let e=t?.kind||t?.type||"llm";if(i&&e!==i||l.has(t.id))continue;let a=`${s}/${t.id}`;n.has(a)||(n.add(a),o.push({id:t.id,name:t.name||t.id,fullModel:a,source:"custom",type:e}))}if(!r)return o;let d=`${s}/`;for(let[e,s]of Object.entries(t||{})){if("string"!=typeof s||!s.startsWith(d))continue;let t=s.slice(d.length);!t||l.has(t)||n.has(s)||(n.add(s),o.push({id:t,alias:e,fullModel:s,source:"legacyAlias",type:i||"llm"}))}return o}var I=s(14051),E=s.n(I),R=s(25871),_=s(93725);function M({model:e,fullModel:t,alias:s,copied:i,onCopy:r,testStatus:l,isCustom:n,isFree:o,onDeleteAlias:d,onTest:m,isTesting:u,onDisable:p,caps:x,thinkingSuffix:h}){let{getPricing:f}=(0,R.e)(),g=h?`${t}(${h})`:t,y=t.includes("/")?t.slice(0,t.indexOf("/")):null,b=(0,_.M4)(x,f(y,e.id)),v="ok"===l?"#22c55e":"error"===l?"#ef4444":"slow"===l||"rate_limited"===l?"#f59e0b":void 0;return(0,a.jsx)("div",{className:`group w-full sm:w-auto min-w-0 max-w-full rounded-lg border px-3 py-2 ${"ok"===l?"border-green-500/40":"error"===l?"border-red-500/40":"slow"===l||"rate_limited"===l?"border-amber-500/40":"border-border"} hover:bg-sidebar/50`,children:(0,a.jsxs)("div",{className:"flex min-w-0 items-start gap-2 sm:items-center",children:[(0,a.jsx)("span",{className:"material-symbols-outlined shrink-0 text-base mt-0.5 sm:mt-0",style:v?{color:v}:void 0,children:"ok"===l?"check_circle":"error"===l?"cancel":"slow"===l||"rate_limited"===l?"warning":"smart_toy"}),(0,a.jsxs)("div",{className:"flex min-w-0 flex-1 flex-col gap-1",children:[(0,a.jsx)("code",{className:"w-fit max-w-full break-all rounded bg-sidebar px-1.5 py-0.5 font-mono text-xs text-text-muted sm:max-w-[360px] sm:truncate",children:g}),(0,a.jsxs)("span",{className:"flex min-w-0 items-center text-[9px] gap-1 pl-1",children:[e.name&&(0,a.jsx)("span",{className:"break-all sm:truncate text-[9px] italic text-text-muted/70",children:e.name}),(0,a.jsx)(c.nh,{caps:x,colorOverride:"text-text-muted/70",size:12}),b&&(0,a.jsx)("span",{className:"truncate text-[9px] text-text-muted/70",children:b})]})]}),(0,a.jsxs)("div",{className:"flex shrink-0 items-center gap-0.5 sm:gap-1",children:[m&&(0,a.jsxs)("div",{className:"relative shrink-0 group/btn",children:[(0,a.jsx)("button",{onClick:m,disabled:u,className:`rounded p-0.5 text-text-muted transition-opacity hover:bg-sidebar hover:text-primary ${u?"opacity-100":"opacity-100 sm:opacity-0 sm:group-hover:opacity-100"}`,children:(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",style:u?{animation:"spin 1s linear infinite"}:void 0,children:u?"progress_activity":"science"})}),(0,a.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:u?"Testing...":"Test"})]}),(0,a.jsxs)("div",{className:"relative shrink-0 group/btn",children:[(0,a.jsx)("button",{onClick:()=>r(g,`model-${e.id}`),className:"rounded p-0.5 text-text-muted hover:bg-sidebar hover:text-primary",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:i===`model-${e.id}`?"check":"content_copy"})}),(0,a.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:i===`model-${e.id}`?"Copied!":"Copy"})]}),n?(0,a.jsx)("button",{onClick:d,className:"rounded p-0.5 text-text-muted opacity-100 transition-opacity hover:bg-red-500/10 hover:text-red-500 sm:opacity-0 sm:group-hover:opacity-100",title:"Remove custom model",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:"close"})}):p?(0,a.jsx)("button",{onClick:p,className:"rounded p-0.5 text-text-muted opacity-100 transition-opacity hover:bg-red-500/10 hover:text-red-500 sm:opacity-0 sm:group-hover:opacity-100",title:"Disable this model",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:"close"})}):null]})]})})}function D({isOpen:e,onClose:t,connectionId:s,providerStorageAlias:r,existingIds:l,transformId:n,onImported:o}){let[d,m]=(0,i.useState)(!1),[u,p]=(0,i.useState)(""),[x,h]=(0,i.useState)(""),[f,g]=(0,i.useState)([]),[y,b]=(0,i.useState)(()=>new Set),[v,j]=(0,i.useState)(""),[w,k]=(0,i.useState)(!1),[N,C]=(0,i.useState)(null);(0,i.useEffect)(()=>{if(!e||!s)return;let t=!1;return m(!0),p(""),h(""),g([]),b(new Set),j(""),C(null),fetch(`/api/providers/${s}/models`,{cache:"no-store"}).then(async e=>({ok:e.ok,data:await e.json()})).then(({ok:e,data:s})=>{if(t)return;if(!e)return void p(s.error||"Failed to fetch models");let a=new Set,i=[];for(let e of s.models||[]){if(e?.kind&&!["llm","imageToText"].includes(e.kind))continue;let t=e?.id||e?.name||e?.model;"string"==typeof t&&t.trim()&&(n&&(t=n(t)),!t||a.has(t)||(a.add(t),i.push({id:t,name:e?.name&&e.name!==e.id&&e.name!==t?e.name:null})))}g(i),s.warning&&h(s.warning),0!==i.length||s.warning||h("Provider returned 0 models")}).catch(e=>{t||p(e.message||"Network error")}).finally(()=>{t||m(!1)}),()=>{t=!0}},[e,s,n]);let S=(0,i.useMemo)(()=>f.map(e=>({...e,added:l?.has(e.id)===!0})),[f,l]),A=(0,i.useMemo)(()=>{let e=v.trim().toLowerCase();return e?S.filter(t=>t.id.toLowerCase().includes(e)||(t.name||"").toLowerCase().includes(e)):S},[S,v]),T=A.filter(e=>!e.added),$=T.length>0&&T.every(e=>y.has(e.id)),O=async()=>{if(!w&&0!==y.size){k(!0),p("");try{let e=await fetch("/api/models/custom/bulk",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerAlias:r,type:"llm",ids:[...y]})}),t=await e.json();if(!e.ok)return void p(t.error||"Import failed");C(t),window.dispatchEvent(new CustomEvent("customModelChanged")),o?.()}catch(e){p(e.message||"Network error")}finally{k(!1)}}};return(0,a.jsx)(c.aF,{isOpen:e,title:"Import Models from Provider",onClose:t,children:(0,a.jsx)("div",{className:"flex flex-col gap-3",children:N?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("p",{className:"text-sm text-text-main",children:["Imported ",N.added," model",1===N.added?"":"s",N.skipped>0?`, ${N.skipped} already existed`:"","."]}),(0,a.jsx)(c.$n,{onClick:t,fullWidth:!0,children:"Done"})]}):(0,a.jsxs)(a.Fragment,{children:[u&&(0,a.jsx)("p",{className:"text-xs text-red-500 break-words",children:u}),x&&!u&&(0,a.jsx)("p",{className:"text-xs text-amber-600 dark:text-amber-400 break-words",children:x}),d?(0,a.jsxs)("p",{className:"text-sm text-text-muted py-6 text-center",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-sm align-middle mr-1",style:{animation:"spin 1s linear infinite"},children:"progress_activity"}),"Fetching models from provider..."]}):f.length>0&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("input",{type:"text",value:v,onChange:e=>j(e.target.value),placeholder:"Search models...",className:"w-full px-3 py-2 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary"}),(0,a.jsxs)("label",{className:"flex cursor-pointer items-center gap-1.5 text-xs text-text-muted hover:text-primary",children:[(0,a.jsx)("input",{type:"checkbox",checked:$,onChange:()=>{b(e=>{let t=new Set(e);if($)for(let e of T)t.delete(e.id);else for(let e of T)t.add(e.id);return t})},className:"h-3.5 w-3.5 rounded border-gray-300 text-primary focus:ring-primary"}),"Select All (",T.length," available",A.length!==S.length?`, ${A.length} shown`:"",")"]}),(0,a.jsxs)("div",{className:"flex max-h-72 flex-col gap-1 overflow-y-auto custom-scrollbar pr-1",children:[A.map(e=>(0,a.jsxs)("label",{className:`flex items-center gap-2 rounded-lg border px-2.5 py-1.5 text-xs ${e.added?"border-border opacity-50":"border-border hover:border-primary/40 cursor-pointer"}`,children:[(0,a.jsx)("input",{type:"checkbox",checked:e.added||y.has(e.id),disabled:e.added,onChange:()=>{var t;return t=e.id,void b(e=>{let s=new Set(e);return s.has(t)?s.delete(t):s.add(t),s})},className:"h-3.5 w-3.5 rounded border-gray-300 text-primary focus:ring-primary"}),(0,a.jsx)("span",{className:"min-w-0 flex-1 truncate font-mono",children:e.id}),e.name&&(0,a.jsx)("span",{className:"truncate text-text-muted/70 italic",children:e.name}),e.added&&(0,a.jsx)("span",{className:"shrink-0 text-[10px] text-text-muted",children:"added"})]},e.id)),0===A.length&&(0,a.jsx)("p",{className:"py-4 text-center text-xs text-text-muted",children:"No models match the search"})]}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(c.$n,{onClick:O,fullWidth:!0,disabled:0===y.size||w,children:w?"Importing...":`Import Selected (${y.size})`}),(0,a.jsx)(c.$n,{onClick:t,variant:"ghost",fullWidth:!0,disabled:w,children:"Cancel"})]})]}),!d&&0===f.length&&!u&&(0,a.jsx)(c.$n,{onClick:t,variant:"ghost",fullWidth:!0,children:"Close"})]})})})}function q({modelId:e,fullModel:t,copied:s,onCopy:i,onDeleteAlias:r,onTest:l,testStatus:n,isTesting:o}){let d="ok"===n?"#22c55e":"error"===n?"#ef4444":void 0;return(0,a.jsxs)("div",{className:`flex items-center gap-3 p-3 rounded-lg border ${"ok"===n?"border-green-500/50":"error"===n?"border-red-500/50":"border-border"} hover:bg-sidebar/50`,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-base text-text-muted",style:d?{color:d}:void 0,children:"ok"===n?"check_circle":"error"===n?"cancel":"smart_toy"}),(0,a.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,a.jsx)("p",{className:"text-sm font-medium truncate",children:e}),(0,a.jsxs)("div",{className:"flex items-center gap-1 mt-1",children:[(0,a.jsx)("code",{className:"text-xs text-text-muted font-mono bg-sidebar px-1.5 py-0.5 rounded",children:t}),(0,a.jsxs)("div",{className:"relative group/btn",children:[(0,a.jsx)("button",{onClick:()=>i(t,`model-${e}`),className:"p-0.5 hover:bg-sidebar rounded text-text-muted hover:text-primary",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:s===`model-${e}`?"check":"content_copy"})}),(0,a.jsx)("span",{className:"pointer-events-none absolute top-5 left-1/2 -translate-x-1/2 text-[10px] text-text-muted whitespace-nowrap opacity-0 group-hover/btn:opacity-100 transition-opacity",children:s===`model-${e}`?"Copied!":"Copy"})]}),l&&(0,a.jsxs)("div",{className:"relative group/btn",children:[(0,a.jsx)("button",{onClick:l,disabled:o,className:"p-0.5 hover:bg-sidebar rounded text-text-muted hover:text-primary transition-colors",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",style:o?{animation:"spin 1s linear infinite"}:void 0,children:o?"progress_activity":"science"})}),(0,a.jsx)("span",{className:"pointer-events-none absolute top-5 left-1/2 -translate-x-1/2 text-[10px] text-text-muted whitespace-nowrap opacity-0 group-hover/btn:opacity-100 transition-opacity",children:o?"Testing...":"Test"})]})]})]}),(0,a.jsx)("button",{onClick:r,className:"p-1 hover:bg-red-50 rounded text-red-500",title:"Remove model",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:"delete"})})]})}function z({providerStorageAlias:e,providerDisplayAlias:t,modelAliases:s,customModels:r,copied:l,onCopy:n,onDeleteAlias:o,onAddCustomModel:d,onDeleteCustomModel:m,connections:u,isAnthropic:p,onModelsChanged:x,importSupported:h=!1}){let[f,g]=(0,i.useState)(""),[y,b]=(0,i.useState)(!1),[v,j]=(0,i.useState)(!1),[w,k]=(0,i.useState)(null),[N,C]=(0,i.useState)({}),S=async t=>{if(!w){k(t);try{let s=await fetch("/api/models/test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:`${e}/${t}`})}),a=await s.json();C(e=>({...e,[t]:a.ok?"ok":"error"}))}catch{C(e=>({...e,[t]:"error"}))}finally{k(null)}}},A=P({customModels:r,modelAliases:s,providerAlias:e,type:"llm"}),T=async()=>{if(!f.trim()||y)return;let e=f.trim();if(A.some(t=>t.id===e))return void alert("Model already exists for this provider.");b(!0);try{await d(e),g("")}catch(e){console.log("Error adding model:",e)}finally{b(!1)}},$=u.find(e=>!1!==e.isActive)?.id||null,O=!!$&&!0===h,I=new Set(A.map(e=>e.id));return(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,a.jsxs)("p",{className:"text-sm text-text-muted",children:["Add ",p?"Anthropic":"OpenAI","-compatible models manually or import them from the /models endpoint."]}),(0,a.jsxs)("div",{className:"flex items-end gap-2 flex-wrap",children:[(0,a.jsxs)("div",{className:"flex-1 min-w-[240px]",children:[(0,a.jsx)("label",{htmlFor:"new-compatible-model-input",className:"text-xs text-text-muted mb-1 block",children:"Model ID"}),(0,a.jsx)("input",{id:"new-compatible-model-input",type:"text",value:f,onChange:e=>g(e.target.value),onKeyDown:e=>"Enter"===e.key&&T(),placeholder:p?"claude-3-opus-20240229":"gpt-4o",className:"w-full px-3 py-2 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary"})]}),(0,a.jsx)(c.$n,{size:"sm",icon:"add",onClick:T,disabled:!f.trim()||y,children:y?"Adding...":"Add"}),(0,a.jsx)(c.$n,{size:"sm",variant:"secondary",icon:"download",onClick:()=>j(!0),disabled:!O,children:"Import from /models"})]}),!O&&(0,a.jsx)("p",{className:"text-xs text-text-muted",children:$?"Set a Base URL on the active connection to enable importing models.":"Add a connection to enable importing models."}),A.length>0&&(0,a.jsx)("div",{className:"flex flex-col gap-3",children:A.map(({id:s,alias:i,source:r})=>(0,a.jsx)(q,{modelId:s,fullModel:`${t}/${s}`,copied:l,onCopy:n,onDeleteAlias:()=>"custom"===r?m(s):o(i),onTest:u.length>0?()=>S(s):void 0,testStatus:N[s],isTesting:w===s},`${r}-${e}/${s}`))}),(0,a.jsx)(D,{isOpen:v,onClose:()=>j(!1),connectionId:$,providerStorageAlias:e,existingIds:I,onImported:x})]})}function U({isOpen:e,onClose:t,providerId:s,providerAlias:r,connections:l,customModels:n,disabledModelIds:o,onSaved:d}){let[m,p]=(0,i.useState)([]),[x,h]=(0,i.useState)(()=>new Set),[f,g]=(0,i.useState)(""),[y,b]=(0,i.useState)(!0),[v,j]=(0,i.useState)(!1),[w,k]=(0,i.useState)(""),N=(0,i.useMemo)(()=>(l||[]).filter(e=>!1!==e.isActive&&e.id).map(e=>e.id),[l]);(0,i.useEffect)(()=>{if(!e)return;let t=!1;return(async()=>{let e=[];try{let t=await fetch(`/api/models/enabled?providerAlias=${encodeURIComponent(r)}`,{cache:"no-store"});t.ok&&(e=(await t.json()).ids||[])}catch{}let a=await Promise.all(N.map(async e=>{try{let t=await fetch(`/api/providers/${e}/models`,{cache:"no-store"});if(!t.ok)return[];let s=await t.json();return Array.isArray(s?.models)?s.models:[]}catch{return[]}}));if(t)return;let i=new Set,l=[],n=(e,t,s={})=>{let a=String(e??"").trim();!a||i.has(a)||(i.add(a),l.push({id:a,name:t||a,...s}))};for(let e of a)for(let t of e)n("string"==typeof t?t:t?.id,"string"==typeof t?t:t?.name||t?.id,{live:!0});for(let e of(0,u.KC)(s)||[]){let t=(0,u.CP)(e,"llm");t&&"llm"!==t||n(e.id,e.name)}for(let t of e)n(t,t,{stale:!0});let d=new Set(o||[]),c=e.length>0?e:l.filter(e=>!e.isCustom&&!d.has(e.id)).map(e=>e.id);p(l),h(new Set(c)),b(!1)})(),()=>{t=!0}},[e,s,r,N,o]);let C=(0,i.useMemo)(()=>(n||[]).filter(e=>e.providerAlias===r&&"llm"===(e.kind||e.type||"llm")).map(e=>({id:String(e.id).trim(),name:e.name||e.id})).filter(e=>e.id),[n,r]),S=(0,i.useMemo)(()=>{let e=f.trim().toLowerCase();return e?m.filter(t=>t.id.toLowerCase().includes(e)||t.name.toLowerCase().includes(e)):m},[m,f]),A=async()=>{j(!0),k("");try{let e=Array.from(x),s=await fetch("/api/models/enabled",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerAlias:r,ids:e})});if(!s.ok){let e=await s.json().catch(()=>({}));throw Error(e.error||`Failed to save (${s.status})`)}d?.(e),t()}catch(e){k(e?.message||"Failed to save visible models")}finally{j(!1)}};return(0,a.jsx)(c.aF,{isOpen:e,onClose:t,title:"Visible models",size:"lg",footer:null,children:(0,a.jsxs)("div",{className:"flex flex-col gap-3 p-4",children:[(0,a.jsxs)("div",{className:"flex items-start gap-2 rounded-lg border border-primary/20 bg-primary/8 px-2.5 py-2 text-xs text-text-muted",children:[(0,a.jsx)("span",{className:"material-symbols-outlined shrink-0 text-primary",style:{fontSize:"14px"},children:"info"}),(0,a.jsxs)("span",{children:["Only the checked models are exposed on ",(0,a.jsx)("code",{className:"font-mono",children:"/v1/models"}),". Leave everything unchecked to expose all of them. Custom models are always exposed."]})]}),(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsxs)("div",{className:"relative flex-1",children:[(0,a.jsx)("span",{className:"material-symbols-outlined absolute left-2.5 top-1/2 -translate-y-1/2 text-text-muted text-[16px]",children:"search"}),(0,a.jsx)("input",{type:"text",placeholder:"Search...",value:f,onChange:e=>g(e.target.value),className:"w-full rounded border border-border bg-surface py-1.5 pl-8 pr-3 text-xs focus:outline-none focus:ring-1 focus:ring-primary/50"})]}),(0,a.jsx)(c.$n,{variant:"ghost",size:"sm",onClick:()=>h(new Set(m.map(e=>e.id))),disabled:y||v,children:"Select all"}),(0,a.jsx)(c.$n,{variant:"ghost",size:"sm",onClick:()=>h(new Set),disabled:y||v,children:"Clear"})]}),w&&(0,a.jsx)("p",{className:"text-xs text-red-500 break-words",children:w}),y?(0,a.jsx)("p",{className:"py-6 text-center text-xs text-text-muted",children:"Loading models…"}):(0,a.jsxs)("div",{className:"max-h-[360px] overflow-y-auto rounded-lg border border-border",children:[S.map(e=>(0,a.jsxs)("label",{className:"flex cursor-pointer items-center gap-2 border-b border-border/50 px-3 py-2 last:border-b-0 hover:bg-sidebar/50",children:[(0,a.jsx)("input",{type:"checkbox",checked:x.has(e.id),onChange:()=>{var t;return t=e.id,void h(e=>{let s=new Set(e);return s.has(t)?s.delete(t):s.add(t),s})},className:"size-3.5 accent-primary cursor-pointer"}),(0,a.jsx)("span",{className:"truncate text-xs text-text-main",children:e.name}),(0,a.jsx)("code",{className:"truncate font-mono text-[11px] text-text-muted",children:e.id}),e.live&&!e.stale&&(0,a.jsx)("span",{className:"ml-auto shrink-0 rounded bg-primary/10 px-1.5 py-0.5 text-[10px] text-primary",children:"live"}),e.stale&&(0,a.jsx)("span",{className:"ml-auto shrink-0 rounded bg-amber-500/10 px-1.5 py-0.5 text-[10px] text-amber-600 dark:text-amber-400",children:"not in catalog"})]},e.id)),0===S.length&&(0,a.jsx)("p",{className:"py-6 text-center text-xs text-text-muted",children:"No models found"})]}),C.length>0&&(0,a.jsxs)("div",{className:"rounded-lg border border-border px-3 py-2",children:[(0,a.jsx)("p",{className:"mb-1 text-[11px] text-text-muted",children:"Always exposed (custom models)"}),(0,a.jsx)("div",{className:"flex flex-wrap gap-1.5",children:C.map(e=>(0,a.jsx)("span",{className:"rounded bg-sidebar px-1.5 py-0.5 font-mono text-[11px] text-text-muted",children:e.id},e.id))})]}),(0,a.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,a.jsx)("span",{className:"text-[11px] text-text-muted",children:0===x.size?"Nothing selected — all models stay visible.":`${x.size} of ${m.length} selected`}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(c.$n,{variant:"ghost",size:"sm",onClick:t,disabled:v,children:"Cancel"}),(0,a.jsx)(c.$n,{variant:"primary",size:"sm",onClick:A,loading:v,disabled:y,children:"Save"})]})]})]})})}M.propTypes={model:E().shape({id:E().string.isRequired}).isRequired,fullModel:E().string.isRequired,alias:E().string,copied:E().string,onCopy:E().func.isRequired,testStatus:E().oneOf(["ok","error","slow","rate_limited","not_tested"]),isCustom:E().bool,isFree:E().bool,onDeleteAlias:E().func,onTest:E().func,isTesting:E().bool,onDisable:E().func,caps:E().object,thinkingSuffix:E().string},E().string.isRequired,E().string.isRequired,E().string,E().func.isRequired,E().func.isRequired,E().func,E().oneOf(["ok","error"]),E().bool,E().string.isRequired,E().object.isRequired,E().arrayOf(E().object),E().string,E().func.isRequired,E().func.isRequired,E().func.isRequired,E().func.isRequired,D.propTypes={isOpen:E().bool.isRequired,onClose:E().func.isRequired,connectionId:E().string,providerStorageAlias:E().string.isRequired,existingIds:E().instanceOf(Set),transformId:E().func,onImported:E().func},q.propTypes={modelId:E().string.isRequired,fullModel:E().string.isRequired,copied:E().string,onCopy:E().func.isRequired,onDeleteAlias:E().func.isRequired,onTest:E().func,testStatus:E().string,isTesting:E().bool},z.propTypes={providerStorageAlias:E().string.isRequired,providerDisplayAlias:E().string.isRequired,modelAliases:E().object.isRequired,customModels:E().arrayOf(E().object),copied:E().string,onCopy:E().func.isRequired,onDeleteAlias:E().func.isRequired,onAddCustomModel:E().func.isRequired,onDeleteCustomModel:E().func.isRequired,connections:E().arrayOf(E().shape({id:E().string,isActive:E().bool})).isRequired,isAnthropic:E().bool,onModelsChanged:E().func,importSupported:E().bool},U.propTypes={isOpen:E().bool.isRequired,onClose:E().func.isRequired,providerId:E().string.isRequired,providerAlias:E().string.isRequired,connections:E().arrayOf(E().object),customModels:E().arrayOf(E().object),disabledModelIds:E().arrayOf(E().string),onSaved:E().func};var F=s(47650),L=s(70217);function J({until:e}){let[t,s]=(0,i.useState)("");return((0,i.useEffect)(()=>{let t=()=>{let t=new Date(e).getTime()-Date.now();if(t<=0)return void s("");let a=Math.floor(t/1e3);if(a<60)s(`${a}s`);else if(a<3600)s(`${Math.floor(a/60)}m ${a%60}s`);else{let e=Math.floor(a/3600),t=Math.floor(a%3600/60);s(`${e}h ${t}m`)}};t();let a=setInterval(t,1e3);return()=>clearInterval(a)},[e]),t)?(0,a.jsxs)("span",{className:"text-xs text-orange-500 font-mono",children:["⏱ ",t]}):null}J.propTypes={until:E().string.isRequired};var K=s(64827),H=s(14558),W=s(7462);let B=["invalid_grant","refresh_token_expired","reauth_required","unrecoverable_refresh_error","refresh_token_reused","refresh_token_invalidated"];function G(e){if(!e||"string"!=typeof e)return!1;let t=e.toLowerCase();return B.some(e=>t.includes(e))}function Q({connection:e,plan:t=null,proxyPools:s,isOAuth:r,isFirst:l,isLast:n,onMoveUp:o,onMoveDown:d,onToggleActive:m,onUpdateProxy:u,onEdit:p,onDelete:x,onReconnect:h=null,oneByOneStatus:f=null,autoPing:g=null,fastMode:y=null}){let[b,v]=(0,i.useState)(!1),j=(0,W.gr)(e.providerSpecificData?.quotaReserve),w=W.vP.filter(e=>j[e.id]).map(e=>`${e.label} ${j[e.id]}%`).join(" \xb7 "),[k,N]=(0,i.useState)(!1),[C,A]=(0,i.useState)(!1),T=(0,i.useRef)(null),$=(0,i.useRef)(null),[O,P]=(0,i.useState)(null),{copied:I,copy:E}=(0,S.C)(),R=`conn-id-${e.id}`,_=async()=>{if(y?.onToggle&&!C){A(!0);try{await y.onToggle(!y.on)}catch(e){console.error("Failed to toggle fast mode:",e)}finally{A(!1)}}},M=new Map((s||[]).map(e=>[e.id,e])),D=e.providerSpecificData?.proxyPoolId||null,q=D?M.get(D):null,z=e.providerSpecificData?.connectionProxyEnabled===!0&&!!e.providerSpecificData?.connectionProxyUrl,U=!!D||z,B=q?`Pool: ${q.name}`:D?`Pool: ${D} (inactive/missing)`:z?`Legacy: ${e.providerSpecificData?.connectionProxyUrl}`:"",V=(()=>{if(!g)return"";let e=[];return(g.reactiveOn&&e.push("On reset"),g.scheduleOn&&e.push(`Scheduled (${g.scheduleSummary||"active"})`),e.length>0)?`Auto-ping active: ${e.join(" + ")}. Click to configure.`:"codex"===g.provider?"Auto-starts the next 5h Codex window after reset or on schedule. Click to configure.":"Auto-starts a new window on quota reset or fixed schedule. Click to configure."})(),Z="";if(q?.proxyUrl||e.providerSpecificData?.connectionProxyUrl){let t=q?.proxyUrl||e.providerSpecificData?.connectionProxyUrl;try{let e=new URL(t);Z=`${e.protocol}//${e.hostname}${e.port?`:${e.port}`:""}`}catch{Z=t}}let X=q?.noProxy||e.providerSpecificData?.connectionNoProxy||"",Y="default";q?.isActive===!0?Y="success":(D||z)&&(Y="error"),(0,i.useEffect)(()=>{if(!b)return;let e=e=>{T.current?.contains(e.target)||$.current?.contains(e.target)||v(!1)},t=()=>v(!1);return document.addEventListener("mousedown",e),window.addEventListener("resize",t),document.addEventListener("scroll",t,!0),()=>{document.removeEventListener("mousedown",e),window.removeEventListener("resize",t),document.removeEventListener("scroll",t,!0)}},[b]);let ee=async e=>{N(!0);try{await u("__none__"===e?null:e)}finally{N(!1),v(!1)}},et=e.authType||(r?"oauth":"apikey"),es="oauth"===et,ea="cookie"===et,ei=e.name?.trim()||e.email?.trim()||e.displayName?.trim()||(es?"OAuth Account":ea?"Cookie Account":"API Key"),er=e.name?.trim()&&e.email?.trim()&&e.name.trim()!==e.email.trim()?e.email.trim():e.name?.trim()&&e.displayName?.trim()&&e.name.trim()!==e.displayName.trim()?e.displayName.trim():null,el=t?.trim(),en=e.providerSpecificData?.chatgptPlanType?.trim(),eo="codex"===e.provider?el&&"unknown"!==el.toLowerCase()?el:en:null,[ed,ec]=(0,i.useState)(!1),em=(0,K.kJ)(e);(0,i.useEffect)(()=>{let t=()=>{ec("unavailable"===e.testStatus?!!(0,K.kJ)(e):!!e.modelLock___all&&new Date(e.modelLock___all).getTime()>Date.now())};t();let s=em?setInterval(t,1e3):null;return()=>{s&&clearInterval(s)}},[em,e.testStatus,e.modelLock___all]);let eu="unavailable"!==e.testStatus||ed?e.testStatus:"active",ep=(es||ea)&&"unavailable"===e.testStatus&&function(e,t){if(401===e||403===e)return!0;if(!t||"string"!=typeof t)return!1;let s=t.toLowerCase();return s.includes("unauthorized")||s.includes("token")||s.includes("invalid api key")||s.includes("revoked")||s.includes("auth")||G(t)}(e.errorCode,e.lastError),ex=G(e.lastError)?"Auth expired — reconnect required":e.lastError,eh=()=>f?"queued"===f.state?"queued":"testing"===f.state?"testing":"success"===f.state?"success":"failed"===f.state?f.error?`failed: ${f.error}`:"failed":null:null;return(0,a.jsxs)("div",{className:`group flex min-w-0 flex-col gap-3 rounded-lg p-2 transition-colors hover:bg-black/[0.02] dark:hover:bg-white/[0.02] sm:flex-row sm:items-center sm:justify-between ${!1===e.isActive?"opacity-60":""}`,children:[(0,a.jsxs)("div",{className:"flex min-w-0 flex-1 items-start gap-2 sm:items-center sm:gap-3",children:[(0,a.jsxs)("div",{className:"flex shrink-0 flex-col",children:[(0,a.jsx)("button",{onClick:o,disabled:l,className:`p-0.5 rounded ${l?"text-text-muted/30 cursor-not-allowed":"hover:bg-sidebar text-text-muted hover:text-primary"}`,children:(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:"keyboard_arrow_up"})}),(0,a.jsx)("button",{onClick:d,disabled:n,className:`p-0.5 rounded ${n?"text-text-muted/30 cursor-not-allowed":"hover:bg-sidebar text-text-muted hover:text-primary"}`,children:(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:"keyboard_arrow_down"})})]}),(0,a.jsx)("span",{className:"material-symbols-outlined shrink-0 text-base text-text-muted",children:ea?"cookie":es?"lock":"key"}),(0,a.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,a.jsx)("p",{className:"text-sm font-medium truncate",children:ei}),er&&(0,a.jsx)("p",{className:"text-xs text-text-muted truncate",children:er}),(0,a.jsxs)("div",{className:"mt-1 flex min-w-0 flex-wrap items-center gap-1.5 sm:gap-2",children:[(0,a.jsx)(c.Ex,{variant:(0,L.g)(e.isActive,eu),size:"sm",dot:!0,children:!1===e.isActive?"disabled":eu||"Unknown"}),(0,a.jsx)(c.Ex,{variant:"default",size:"sm",children:es?"OAuth":ea?"Cookie":"API Key"}),eo&&"unknown"!==eo.toLowerCase()&&(0,a.jsx)(c.Ex,{variant:"primary",size:"sm",children:eo}),U&&(0,a.jsx)(c.Ex,{variant:Y,size:"sm",children:"Proxy"}),ed&&!1!==e.isActive&&(0,a.jsx)(J,{until:em}),e.lastError&&!1!==e.isActive&&(!e.lastErrorModel||ed||"active"!==eu)&&(0,a.jsx)("span",{className:"max-w-full truncate text-xs text-red-500 sm:max-w-[300px]",title:e.lastError,children:e.lastErrorModel?`[${e.lastErrorModel}] ${ex}`:ex}),(0,a.jsxs)("span",{className:"text-xs text-text-muted",children:["#",e.priority]}),(0,a.jsxs)("button",{type:"button",onClick:()=>E(e.id||"",R),title:"Copy connection ID — send it as the x-connection-id request header to pin requests to this account (falls back to other accounts when it is unavailable)",className:"flex items-center gap-0.5 rounded font-mono text-[11px] text-text-muted transition-colors hover:text-primary",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-xs",children:I===R?"check":"content_copy"}),I===R?"copied":`${(e.id||"").slice(0,8)}…`]}),w&&(0,a.jsx)(c.m_,{text:"Quota kept in reserve: requests move to the next account at this share",children:(0,a.jsx)(c.Ex,{variant:"default",size:"sm",icon:"savings",children:w})}),e.globalPriority&&(0,a.jsxs)("span",{className:"text-xs text-text-muted",children:["Auto: ",e.globalPriority]}),eh()&&(0,a.jsx)(c.Ex,{variant:f?"success"===f.state?"success":"failed"===f.state?"error":"testing"===f.state?"primary":"default":"default",size:"sm",children:eh()})]}),U&&(0,a.jsxs)("div",{className:"mt-1 flex items-center gap-2 flex-wrap",children:[(0,a.jsx)("span",{className:"max-w-full truncate text-[11px] text-text-muted sm:max-w-[420px]",title:B,children:B}),Z&&(0,a.jsx)("code",{className:"max-w-full truncate rounded bg-black/5 px-1 py-0.5 font-mono text-[10px] text-text-muted dark:bg-white/5 sm:max-w-[260px]",children:Z}),X&&(0,a.jsxs)("span",{className:"max-w-full truncate text-[11px] text-text-muted sm:max-w-[320px]",title:X,children:["no_proxy: ",X]})]})]})]}),(0,a.jsxs)("div",{className:"flex w-full items-center justify-between gap-2 sm:w-auto sm:justify-end",children:[(0,a.jsxs)("div",{className:"grid flex-1 grid-cols-3 gap-1 sm:flex sm:flex-none",children:[(s||[]).length>0&&(0,a.jsxs)("div",{children:[(0,a.jsxs)("button",{ref:$,onClick:()=>{if(b)return void v(!1);let e=$.current?.getBoundingClientRect();if(!e)return void v(!0);let t=((s?.length||0)+1)*34+8,a=window.innerHeight-e.bottom,i=a<t&&e.top>a;P({position:"fixed",right:window.innerWidth-e.right,...i?{bottom:window.innerHeight-e.top+4,maxHeight:Math.max(e.top-8,120)}:{top:e.bottom+4,maxHeight:Math.max(a-8,120)}}),v(!0)},className:`flex w-full flex-col items-center rounded px-2 py-1 transition-colors hover:bg-black/5 dark:hover:bg-white/5 ${U?"text-primary":"text-text-muted hover:text-primary"}`,disabled:k,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:k?"progress_activity":"lan"}),(0,a.jsx)("span",{className:"text-[10px] leading-tight",children:"Proxy"})]}),b&&(0,F.createPortal)((0,a.jsxs)("div",{ref:T,style:O,className:"z-50 max-w-[78vw] min-w-[160px] overflow-y-auto rounded-lg border border-border bg-bg py-1 shadow-lg",children:[(0,a.jsx)("button",{onClick:()=>ee("__none__"),className:`w-full text-left px-3 py-1.5 text-sm hover:bg-black/5 dark:hover:bg-white/5 ${!D?"text-primary font-medium":"text-text-main"}`,children:"None"}),(s||[]).map(e=>(0,a.jsx)("button",{onClick:()=>ee(e.id),className:`w-full text-left px-3 py-1.5 text-sm hover:bg-black/5 dark:hover:bg-white/5 ${D===e.id?"text-primary font-medium":"text-text-main"}`,children:e.name},e.id))]}),document.body)]}),y&&(0,a.jsx)(c.m_,{text:"codex"===e.provider?y.on?"Fast mode ON — Codex requests on this account use the priority tier. Click to disable.":"Force fast mode — Codex requests on this account use the priority tier.":"Uses the provider's faster processing mode for this account at a higher token cost. Off by default.",children:(0,a.jsxs)("button",{type:"button",role:"switch","aria-label":"Fast mode","aria-checked":y.on,disabled:C,onClick:_,className:`flex w-full flex-col items-center rounded px-2 py-1 transition-colors hover:bg-black/5 dark:hover:bg-white/5 disabled:opacity-50 ${y.on?"text-primary":"text-text-muted hover:text-primary"}`,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:C?"progress_activity":"speed"}),(0,a.jsx)("span",{className:"text-[10px] leading-tight",children:"Fast"})]})}),g&&(0,a.jsx)(c.m_,{text:V,children:(0,a.jsxs)("button",{onClick:g.onConfigure,className:`flex w-full flex-col items-center rounded px-2 py-1 transition-colors hover:bg-black/5 dark:hover:bg-white/5 ${g.isActive?"text-primary":"text-text-muted hover:text-primary"}`,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"bolt"}),(0,a.jsx)("span",{className:"text-[10px] leading-tight",children:"Auto-ping"})]})}),ep&&h&&(0,a.jsxs)("button",{onClick:()=>h(e),className:"flex flex-col items-center rounded px-2 py-1 text-amber-600 hover:bg-amber-500/10 dark:text-amber-400 dark:hover:bg-amber-500/20 transition-colors",title:"Reconnect account",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"lock_reset"}),(0,a.jsx)("span",{className:"text-[10px] leading-tight font-semibold",children:"Reconnect"})]}),g&&(0,a.jsx)(H.A,{connectionId:e.id,disabled:!1===e.isActive}),(0,a.jsxs)("button",{onClick:p,className:"flex flex-col items-center rounded px-2 py-1 text-text-muted hover:bg-black/5 hover:text-primary dark:hover:bg-white/5",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"edit"}),(0,a.jsx)("span",{className:"text-[10px] leading-tight",children:"Edit"})]}),(0,a.jsxs)("button",{onClick:x,className:"flex flex-col items-center rounded px-2 py-1 text-red-500 hover:bg-red-500/10",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"delete"}),(0,a.jsx)("span",{className:"text-[10px] leading-tight",children:"Delete"})]})]}),(0,a.jsx)(c.lM,{size:"sm",checked:e.isActive??!0,onChange:m,title:e.isActive??!0?"Disable connection":"Enable connection"})]})]})}Q.propTypes={connection:E().shape({id:E().string,name:E().string,email:E().string,displayName:E().string,modelLockUntil:E().string,testStatus:E().string,isActive:E().bool,lastError:E().string,priority:E().number,globalPriority:E().number}).isRequired,plan:E().string,proxyPools:E().arrayOf(E().shape({id:E().string,name:E().string,proxyUrl:E().string,noProxy:E().string,isActive:E().bool})),isOAuth:E().bool.isRequired,isFirst:E().bool.isRequired,isLast:E().bool.isRequired,onMoveUp:E().func.isRequired,onMoveDown:E().func.isRequired,onToggleActive:E().func.isRequired,onUpdateProxy:E().func,onEdit:E().func.isRequired,onDelete:E().func.isRequired,onReconnect:E().func,oneByOneStatus:E().shape({state:E().string,error:E().string}),autoPing:E().shape({isActive:E().bool,provider:E().string,reactiveOn:E().bool,scheduleOn:E().bool,scheduleSummary:E().string,onConfigure:E().func}),fastMode:E().shape({on:E().bool,onToggle:E().func})};var V=s(9339);let Z=(0,V.createServerReference)("40c12714b4cebbcde2cc84e8305c8fefe7063ec2c0",V.callServer,void 0,V.findSourceMapURL,"exportProviderKeys");function X({isOpen:e,providerId:t,providerName:s,onClose:r}){let[l,n]=(0,i.useState)([]),[o,d]=(0,i.useState)(!1),[m,u]=(0,i.useState)(null);(0,i.useEffect)(()=>{if(!e)return;let s=!1;return(async()=>{d(!0),u(null);try{let e=await Z(t);s||n(e.connections||[])}catch{s||n([])}finally{s||d(!1)}})(),()=>{s=!0}},[e,t]);let p=async e=>{try{await navigator.clipboard.writeText(e.key),u(e.id),setTimeout(()=>u(t=>t===e.id?null:t),1500)}catch{}},x=async()=>{let e=l.filter(e=>e.key).map(e=>`${e.name}: ${e.key}`).join("\n");try{await navigator.clipboard.writeText(e),u("__all__"),setTimeout(()=>u(e=>"__all__"===e?null:e),1500)}catch{}},h=l.filter(e=>e.key);return(0,a.jsx)(c.aF,{isOpen:e,title:`Export Keys — ${s||t}`,onClose:r,children:(0,a.jsxs)("div",{className:"flex flex-col gap-3",children:[o&&(0,a.jsx)("p",{className:"text-sm text-text-muted",children:"Loading…"}),!o&&0===h.length&&(0,a.jsx)("p",{className:"text-sm text-text-muted",children:"No keys stored for this provider."}),!o&&h.map(e=>(0,a.jsxs)("div",{className:"flex items-center gap-2 rounded-lg border border-border-subtle bg-sidebar px-3 py-2",children:[(0,a.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,a.jsx)("p",{className:"truncate text-xs text-text-muted",children:e.name}),(0,a.jsx)("p",{className:"break-all text-sm font-mono text-text-main",children:e.key})]}),(0,a.jsx)("button",{onClick:()=>p(e),title:"Copy key",className:`shrink-0 rounded p-1.5 hover:bg-black/5 dark:hover:bg-white/5 ${m===e.id?"text-green-500":"text-text-muted hover:text-primary"}`,children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:m===e.id?"check":"content_copy"})})]},e.id)),!o&&h.length>0&&(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(c.$n,{size:"sm",icon:"__all__"===m?"check":"content_copy",onClick:x,children:"__all__"===m?"Copied":"Copy All"}),(0,a.jsx)(c.$n,{size:"sm",variant:"ghost",onClick:r,children:"Close"})]})]})})}let Y=`name1|sk-key1
|
|
2
2
|
name2|sk-key2
|
|
3
|
-
sk-key-only-auto-named`,ee="__none__",et=()=>({name:"",apiKey:"",defaultModel:"",priority:1,proxyPoolId:ee,baseUrl:"",ollamaHostUrl:""}),es=()=>({azureEndpoint:"",apiVersion:"2024-10-01-preview",deployment:"",organization:""});function ea({isOpen:e,provider:t,providerName:s,isCompatible:r,isAnthropic:l,providerNode:n,authType:o,authHint:d,website:u,proxyPools:p,error:x,existingNames:h,onSave:f,onBulkDone:g,onClose:y}){let b="ollama-local"===t,v="cookie"===o,j="xai"===t&&!v,w=v?"Cookie Value":"qoder"===t||"qoder-cn"===t?"Personal Access Token (PAT)":"API Key",k=m.Q2?.[t]?.baseUrlField||null,N="azure"===t,C="cloudflare-ai"===t,S="vertex"===t||"vertex-partner"===t,A="bedrock"===t,T=m.Q2?.[t]?.apiKeyOptionalWith||null,$=m.Q2?.[t]?.regions||null,O=m.Q2?.[t]?.defaultRegion||$?.[0]?.id||"",[P,I]=(0,i.useState)(et),[E,R]=(0,i.useState)(es),[M
|
|
3
|
+
sk-key-only-auto-named`,ee="__none__",et=()=>({name:"",apiKey:"",defaultModel:"",priority:1,proxyPoolId:ee,baseUrl:"",ollamaHostUrl:""}),es=()=>({azureEndpoint:"",apiVersion:"2024-10-01-preview",deployment:"",organization:""});function ea({isOpen:e,provider:t,providerName:s,isCompatible:r,isAnthropic:l,providerNode:n,authType:o,authHint:d,website:u,proxyPools:p,error:x,existingNames:h,onSave:f,onBulkDone:g,onClose:y}){let b="ollama-local"===t,v="cookie"===o,j="xai"===t&&!v,w=v?"Cookie Value":"qoder"===t||"qoder-cn"===t?"Personal Access Token (PAT)":"API Key",k=m.Q2?.[t]?.baseUrlField||null,N="azure"===t,C="cloudflare-ai"===t,S="vertex"===t||"vertex-partner"===t,A="bedrock"===t,T=m.Q2?.[t]?.apiKeyOptionalWith||null,$=m.Q2?.[t]?.regions||null,O=m.Q2?.[t]?.defaultRegion||$?.[0]?.id||"",[P,I]=(0,i.useState)(et),[E,R]=(0,i.useState)(es),[_,M]=(0,i.useState)({accountId:""}),[D,q]=(0,i.useState)({location:"global",reasoningEffort:"high"}),[z,U]=(0,i.useState)({profile:"",region:"",accessKeyId:"",sessionToken:""}),[F,L]=(0,i.useState)(O),[J,K]=(0,i.useState)(!1),[H,W]=(0,i.useState)(null),[B,G]=(0,i.useState)(!1),Q=C?`name1|sk-key1|acc123456
|
|
4
4
|
name2|sk-key2|def789012
|
|
5
5
|
sk-key-only-auto-named`:"qoder"===t||"qoder-cn"===t?`name1|pt-xxxxx
|
|
6
6
|
name2|pt-yyyyy
|
|
7
|
-
pt-only-auto-named`:Y,[V,Z]=(0,i.useState)("single"),[X,ei]=(0,i.useState)(""),[er,el]=(0,i.useState)(null),en=()=>{I(et()),R(es()),D({accountId:""}),_({location:"global",reasoningEffort:"high"}),L(O),W(null),Z("single"),ei(""),el(null),y()},eo=()=>{if(r&&n)return{prefix:n.prefix,...n.apiType?{apiType:n.apiType}:{},baseUrl:n.baseUrl,nodeName:n.name,clientIdentityProfile:n.clientIdentityProfile||"default",clientIdentityHeaders:n.clientIdentityHeaders||{}};if(S)return{location:q.location||"global",reasoningEffort:q.reasoningEffort||"high"};if(A){let e={};return z.profile.trim()&&(e.profile=z.profile.trim()),z.region.trim()&&(e.region=z.region.trim()),z.accessKeyId.trim()&&(e.accessKeyId=z.accessKeyId.trim()),z.sessionToken.trim()&&(e.sessionToken=z.sessionToken.trim()),Object.keys(e).length?e:void 0}return function({hasBaseUrlField:e=!1,baseUrl:t="",isAzure:s=!1,azureData:a=null,isCloudflareAi:i=!1,cloudflareData:r=null,region:l="",hasRegions:n=!1}={}){if(e){let e=String(t||"").trim();return e?{baseUrl:e}:void 0}return s?{azureEndpoint:a?.azureEndpoint,apiVersion:a?.apiVersion,deployment:a?.deployment,organization:a?.organization}:i?{accountId:r?.accountId}:n&&l?{region:l}:void 0}({hasBaseUrlField:!!k,baseUrl:P.baseUrl,isAzure:N,azureData:E,isCloudflareAi:C,cloudflareData:M,region:F,hasRegions:!!$})},ed=()=>!!P.apiKey||!!(T&&eo()?.[T]),ec=async()=>{if(r&&!P.defaultModel.trim())return void W("failed");K(!0);try{let e=await fetch("/api/providers/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:t,apiKey:P.apiKey,defaultModel:r?P.defaultModel.trim():void 0,providerSpecificData:eo()})}),s=await e.json();W(s.valid?"success":"failed")}catch{W("failed")}finally{K(!1)}},em=async()=>{if(t&&(b||ed())&&(b||P.name)&&(!r||P.defaultModel.trim())){G(!0);try{let e=!1;try{K(!0),W(null);let s=await fetch("/api/providers/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:t,apiKey:P.apiKey,defaultModel:r?P.defaultModel.trim():void 0,providerSpecificData:eo()})});e=!!(await s.json()).valid,W(e?"success":"failed")}catch{W("failed")}finally{K(!1)}await f({name:P.name||(b?"Ollama Local":""),apiKey:P.apiKey,defaultModel:r?P.defaultModel.trim():void 0,priority:P.priority,proxyPoolId:P.proxyPoolId===ee?null:P.proxyPoolId,testStatus:e?"active":"unknown",providerSpecificData:eo()})&&en()}finally{G(!1)}}},eu=async()=>{let e=X.split("\n");if(!e.length)return;let s=function(e,t,s={}){let{isCloudflareAi:a=!1}=s,i=new Set((Array.isArray(t)?t:[]).map(e=>"string"==typeof e?e.toLowerCase():"")),r=[];for(let t of e){let e,s="string"==typeof t?t.trim():"";if(!s)continue;let l=function(e,t={}){let{isCloudflareAi:s=!1}=t,a=e.split("|");if(s&&a.length>=3){let e=a[0].trim();return{baseName:e||"Key",apiKey:a.slice(1,-1).join("|").trim(),providerSpecificData:{accountId:a[a.length-1].trim()}}}return a.length>=2?{baseName:a[0].trim()||"Key",apiKey:a.slice(1).join("|").trim()}:{baseName:"Key",apiKey:a[0].trim()}}(s,{isCloudflareAi:a});if(!l||!l.apiKey)continue;let n=l.baseName,o=1;for(;e=`${n} ${o}`,i.has(e.toLowerCase());)o+=1;i.add(e.toLowerCase());let d={name:e,apiKey:l.apiKey,skipped:!1};l.providerSpecificData&&(d.providerSpecificData=l.providerSpecificData),r.push(d)}return r}(e,h,{isCloudflareAi:C});if(!s.length)return;G(!0),el(null);let a=0,i=0;for(let e of s)try{let s=!1;try{let a=await fetch("/api/providers/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:t,apiKey:e.apiKey})});s=!!(await a.json().catch(()=>({}))).valid}catch{s=!1}(await fetch("/api/providers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:t,apiKey:e.apiKey,name:e.name,priority:1,testStatus:s?"active":"unknown",...e.providerSpecificData?{providerSpecificData:e.providerSpecificData}:{}})})).ok?a++:i++}catch{i++}G(!1),el({success:a,failed:i}),a>0&&g&&g()};return t?(0,a.jsx)(c.aF,{isOpen:e,title:`Add ${s||t} ${w}`,onClose:en,children:(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(c.$n,{size:"sm",variant:"single"===V?"primary":"ghost",onClick:()=>{Z("single"),el(null)},children:"Single"}),(0,a.jsx)(c.$n,{size:"sm",variant:"bulk"===V?"primary":"ghost",onClick:()=>{Z("bulk"),el(null)},children:"Bulk Add"})]}),"bulk"===V&&(0,a.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,a.jsx)("p",{className:"text-xs text-text-muted",children:C?(0,a.jsxs)(a.Fragment,{children:["One key per line. Format: ",(0,a.jsx)("code",{children:"name|apiKey|accountId"})," or just ",(0,a.jsx)("code",{children:"apiKey"})," (auto-named by index)."]}):"qoder"===t||"qoder-cn"===t?(0,a.jsxs)(a.Fragment,{children:["One PAT per line. Format: ",(0,a.jsx)("code",{children:"name|pt-..."})," or just ",(0,a.jsx)("code",{children:"pt-..."})," (auto-named by index)."]}):(0,a.jsxs)(a.Fragment,{children:["One key per line. Format: ",(0,a.jsx)("code",{children:"name|apiKey"})," or just ",(0,a.jsx)("code",{children:"apiKey"})," (auto-named by index)."]})}),(0,a.jsx)("textarea",{className:"w-full rounded border border-accent/30 bg-sidebar p-2 text-sm font-mono resize-y min-h-[140px] focus:outline-none focus:ring-1 focus:ring-primary",placeholder:Q,value:X,onChange:e=>ei(e.target.value)}),er&&(0,a.jsxs)("div",{className:`text-sm font-medium ${er.failed>0?"text-yellow-400":"text-green-400"}`,children:["✓ ",er.success," added",er.failed>0?`, ✗ ${er.failed} failed`:""]}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(c.$n,{onClick:eu,fullWidth:!0,disabled:B||!X.trim(),children:B?"Adding...":"Add All Keys"}),(0,a.jsx)(c.$n,{onClick:en,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]}),"single"===V&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(c.pd,{label:"Name",value:P.name,onChange:e=>I({...P,name:e.target.value}),placeholder:b?"Ollama Local":"Production Key"}),k&&(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(c.pd,{label:k.label,value:P.baseUrl,onChange:e=>I({...P,baseUrl:e.target.value}),placeholder:k.placeholder,hint:k.help,className:"flex-1"}),(0,a.jsx)("div",{className:"pt-6",children:(0,a.jsx)(c.$n,{onClick:ec,disabled:J||B,variant:"secondary",children:J?"Checking...":"Check"})})]}),!b&&(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(c.pd,{label:w,type:v?"text":"password",value:P.apiKey,onChange:e=>I({...P,apiKey:e.target.value}),placeholder:v?"grok-web"===t?"sso=xxxxx... or just the raw value":"eyJhbGciOi...":j?"xai-...":"qoder"===t||"qoder-cn"===t?"pt-...":"",className:"flex-1"}),(0,a.jsx)("div",{className:"pt-6",children:(0,a.jsx)(c.$n,{onClick:ec,disabled:!P.apiKey||J||B,variant:"secondary",children:J?"Checking...":"Check"})})]}),j&&(0,a.jsx)("p",{className:"text-xs text-text-muted",children:"Use a direct xAI API key from console.x.ai. This is separate from Grok Build OAuth."}),v&&d&&(0,a.jsxs)("p",{className:"text-xs text-text-muted",children:[d,u&&(0,a.jsxs)(a.Fragment,{children:[" ",(0,a.jsxs)("a",{href:u,target:"_blank",rel:"noopener noreferrer",className:"text-primary underline",children:["Open ",u.replace(/^https?:\/\//,"")]})]})]}),$&&(0,a.jsx)(c.l6,{label:"Region",value:F,onChange:e=>L(e.target.value),options:$.map(e=>({value:e.id,label:e.label}))}),r&&(0,a.jsx)(c.pd,{label:"Default Model",value:P.defaultModel,onChange:e=>I({...P,defaultModel:e.target.value}),placeholder:l?"claude-3-5-sonnet-latest":"gpt-4o-mini"}),b&&(0,a.jsxs)("p",{className:"text-xs text-text-muted",children:["Leave blank to use ",(0,a.jsx)("code",{children:"http://localhost:11434"}),". For remote Ollama, enter the full host URL (e.g. ",(0,a.jsx)("code",{children:"http://192.168.1.10:11434"}),")."]}),H&&(0,a.jsx)(c.Ex,{variant:"success"===H?"success":"error",children:"success"===H?"Valid":"Invalid"}),x&&(0,a.jsx)("p",{className:"text-xs text-red-500 break-words",children:x}),r&&(0,a.jsx)("p",{className:"text-xs text-text-muted",children:"Enter the model ID exactly as your compatible endpoint expects it. This model will be saved as the connection default."}),C&&(0,a.jsxs)("div",{className:"bg-sidebar/50 p-4 rounded-lg border border-accent/20",children:[(0,a.jsx)("h3",{className:"font-semibold mb-3 text-sm",children:"Cloudflare Workers AI"}),(0,a.jsx)(c.pd,{label:"Account ID",value:M.accountId,onChange:e=>D({...M,accountId:e.target.value}),placeholder:"abc123def456..."}),(0,a.jsxs)("p",{className:"text-xs text-text-muted mt-2",children:["Find your Account ID in the right sidebar of ",(0,a.jsx)("a",{href:"https://dash.cloudflare.com",target:"_blank",rel:"noopener noreferrer",className:"text-primary underline",children:"dash.cloudflare.com"})]})]}),S&&(0,a.jsxs)("div",{className:"bg-sidebar/50 p-4 rounded-lg border border-accent/20",children:[(0,a.jsx)("h3",{className:"font-semibold mb-3 text-sm",children:"Vertex AI Configuration"}),(0,a.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,a.jsx)(c.l6,{label:"Location",value:q.location,onChange:e=>_({...q,location:e.target.value}),options:[{value:"global",label:"global (recommended for Gemini 3.x)"},{value:"us-central1",label:"us-central1"},{value:"us-east4",label:"us-east4"},{value:"europe-west1",label:"europe-west1"},{value:"europe-west4",label:"europe-west4"},{value:"asia-east1",label:"asia-east1"},{value:"asia-northeast1",label:"asia-northeast1"}]}),(0,a.jsx)(c.l6,{label:"Reasoning Effort (default)",value:q.reasoningEffort,onChange:e=>_({...q,reasoningEffort:e.target.value}),options:[{value:"high",label:"high (32k tokens — default for Pro)"},{value:"medium",label:"medium (8k tokens)"},{value:"low",label:"low (1k tokens)"},{value:"",label:"none (let model decide)"}]}),(0,a.jsxs)("p",{className:"text-xs text-text-muted",children:["Location ",(0,a.jsx)("code",{children:"global"})," is required for Gemini 3.1 Pro Preview. Reasoning effort sets the default ",(0,a.jsx)("code",{children:"thinkingBudget"}),"; clients can override per-request via ",(0,a.jsx)("code",{children:"reasoning_effort"}),"."]})]})]}),A&&(0,a.jsxs)("div",{className:"bg-sidebar/50 p-4 rounded-lg border border-accent/20",children:[(0,a.jsx)("h3",{className:"font-semibold mb-3 text-sm",children:"AWS Bedrock Credentials"}),(0,a.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,a.jsx)(c.pd,{label:"AWS Profile (SSO — recommended)",value:z.profile,onChange:e=>U({...z,profile:e.target.value}),placeholder:"my-sso-profile"}),(0,a.jsx)(c.pd,{label:"Region",value:z.region,onChange:e=>U({...z,region:e.target.value}),placeholder:"us-east-1"})]}),(0,a.jsxs)("p",{className:"text-xs text-text-muted mt-2",children:["Set a profile from ",(0,a.jsx)("code",{children:"~/.aws/config"})," and leave the API key empty, then run"," ",(0,a.jsxs)("code",{children:["aws sso login --profile ",z.profile||"my-sso-profile"]}),". Credentials refresh automatically."]}),(0,a.jsxs)("div",{className:"flex flex-col gap-3 mt-4",children:[(0,a.jsx)(c.pd,{label:"Access Key ID (only for static keys)",value:z.accessKeyId,onChange:e=>U({...z,accessKeyId:e.target.value}),placeholder:"AKIA..."}),(0,a.jsx)(c.pd,{label:"Session Token (only for temporary ASIA… keys)",value:z.sessionToken,onChange:e=>U({...z,sessionToken:e.target.value}),placeholder:"FwoGZXIvYXdz..."})]}),(0,a.jsxs)("p",{className:"text-xs text-text-muted mt-2",children:["For static keys instead: put the AWS ",(0,a.jsx)("strong",{children:"secret"})," access key in the API Key field above and the access key id here. A profile, if set, takes precedence."]})]}),N&&(0,a.jsxs)("div",{className:"bg-sidebar/50 p-4 rounded-lg border border-accent/20",children:[(0,a.jsx)("h3",{className:"font-semibold mb-3 text-sm",children:"Azure OpenAI Configuration"}),(0,a.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,a.jsx)(c.pd,{label:"Azure Endpoint",value:E.azureEndpoint,onChange:e=>R({...E,azureEndpoint:e.target.value}),placeholder:"https://your-resource.openai.azure.com"}),(0,a.jsx)(c.pd,{label:"Deployment Name",value:E.deployment,onChange:e=>R({...E,deployment:e.target.value}),placeholder:"gpt-4"}),(0,a.jsx)(c.pd,{label:"API Version",value:E.apiVersion,onChange:e=>R({...E,apiVersion:e.target.value}),placeholder:"2024-10-01-preview"}),(0,a.jsx)(c.pd,{label:"Organization",value:E.organization,onChange:e=>R({...E,organization:e.target.value}),placeholder:"Organization ID"})]})]}),(0,a.jsx)(c.pd,{label:"Priority",type:"number",value:P.priority,onChange:e=>I({...P,priority:Number.parseInt(e.target.value)||1})}),(0,a.jsx)(c.l6,{label:"Proxy Pool",value:P.proxyPoolId,onChange:e=>I({...P,proxyPoolId:e.target.value}),options:[{value:ee,label:"None"},...(p||[]).map(e=>({value:e.id,label:e.name}))],placeholder:"None"}),0===(p||[]).length&&(0,a.jsx)("p",{className:"text-xs text-text-muted",children:"No active proxy pools available. Create one in Proxy Pools page first."}),(0,a.jsx)("p",{className:"text-xs text-text-muted",children:"Legacy manual proxy fields are still accepted by API for backward compatibility."}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(c.$n,{onClick:em,fullWidth:!0,disabled:B||!b&&(!P.name||!ed())||r&&!P.defaultModel.trim()||N&&(!E.azureEndpoint||!E.deployment||!E.organization)||C&&!M.accountId,children:B?"Saving...":"Save"}),(0,a.jsx)(c.$n,{onClick:en,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})]})}):null}ea.propTypes={isOpen:E().bool.isRequired,provider:E().string,providerName:E().string,isCompatible:E().bool,isAnthropic:E().bool,providerNode:E().shape({name:E().string,prefix:E().string,apiType:E().string,baseUrl:E().string,clientIdentityProfile:E().string,clientIdentityHeaders:E().object}),authType:E().string,authHint:E().string,website:E().string,proxyPools:E().arrayOf(E().shape({id:E().string,name:E().string})),error:E().string,existingNames:E().arrayOf(E().string),onSave:E().func.isRequired,onBulkDone:E().func,onClose:E().func.isRequired};let ei=[{value:"default",label:"Default"},{value:"claude-cli",label:"Claude CLI"},{value:"codex-cli",label:"Codex CLI"},{value:"openclaw",label:"OpenClaw"},{value:"custom",label:"Custom Headers"}],er=new Set(["authorization","x-api-key","api-key","cookie"]);function el(e){let t=String(e||"").trim();if(!t)return{headers:{}};try{let e;if(t.startsWith("{")){let s=JSON.parse(t);if(!s||"object"!=typeof s||Array.isArray(s))return{error:"Use a JSON object or Header: value lines."};e=Object.entries(s)}else for(let s of(e=[],t.split(/\r?\n/))){let t=s.trim();if(!t||t.startsWith("#"))continue;let a=t.indexOf(":");if(a<=0)return{error:"Each custom header line must use Header: value."};e.push([t.slice(0,a),t.slice(a+1)])}let s={};for(let[t,a]of e){let e=String(t||"").trim(),i=String(a||"").trim();!e||!i||er.has(e.toLowerCase())||(s[e]=i)}return{headers:s}}catch{return{error:"Use valid JSON or Header: value lines."}}}function en({isOpen:e,node:t,onSave:s,onClose:r,isAnthropic:l}){let[n,o]=(0,i.useState)({name:"",prefix:"",apiType:"chat",baseUrl:"https://api.openai.com/v1",clientIdentityProfile:"default",clientIdentityHeadersText:"",quotaEnabled:!1,quotaPath:"/credits"}),[d,m]=(0,i.useState)(!1),[u,p]=(0,i.useState)(""),[x,h]=(0,i.useState)(""),[f,g]=(0,i.useState)(!1),[y,b]=(0,i.useState)(null);(0,i.useEffect)(()=>{t&&o({name:t.name||"",prefix:t.prefix||"",apiType:t.apiType||"chat",baseUrl:t.baseUrl||(l?"https://api.anthropic.com/v1":"https://api.openai.com/v1"),clientIdentityProfile:t.clientIdentityProfile||"default",clientIdentityHeadersText:t.clientIdentityHeaders?JSON.stringify(t.clientIdentityHeaders,null,2):"",quotaEnabled:!0===t.quotaEnabled,quotaPath:t.quotaPath||"/credits"})},[t,l]);let v=async()=>{if(!n.name.trim()||!n.prefix.trim()||!n.baseUrl.trim())return;let e="custom"===n.clientIdentityProfile?el(n.clientIdentityHeadersText):{headers:{}};if(e.error)return void b("failed");m(!0);try{let t={name:n.name,prefix:n.prefix,baseUrl:n.baseUrl,clientIdentityProfile:n.clientIdentityProfile,clientIdentityHeaders:e.headers,quotaEnabled:n.quotaEnabled,quotaPath:n.quotaPath};l||(t.apiType=n.apiType),await s(t)}finally{m(!1)}},j=async()=>{let e="custom"===n.clientIdentityProfile?el(n.clientIdentityHeadersText):{headers:{}};if(e.error)return void b("failed");g(!0);try{let t=await fetch("/api/provider-nodes/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:n.baseUrl,apiKey:u,type:l?"anthropic-compatible":"openai-compatible",modelId:x.trim()||void 0,clientIdentityProfile:n.clientIdentityProfile,clientIdentityHeaders:e.headers})}),s=await t.json();b(s.valid?"success":"failed")}catch{b("failed")}finally{g(!1)}};return t?(0,a.jsx)(c.aF,{isOpen:e,title:`Edit ${l?"Anthropic":"OpenAI"} Compatible`,onClose:r,children:(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,a.jsx)(c.pd,{label:"Name",value:n.name,onChange:e=>o({...n,name:e.target.value}),placeholder:`${l?"Anthropic":"OpenAI"} Compatible (Prod)`,hint:"Required. A friendly label for this node."}),(0,a.jsx)(c.pd,{label:"Prefix",value:n.prefix,onChange:e=>o({...n,prefix:e.target.value}),placeholder:l?"ac-prod":"oc-prod",hint:"Required. Used as the provider prefix for model IDs."}),!l&&(0,a.jsx)(c.l6,{label:"API Type",options:[{value:"chat",label:"Chat Completions"},{value:"responses",label:"Responses API"}],value:n.apiType,onChange:e=>o({...n,apiType:e.target.value})}),(0,a.jsx)(c.pd,{label:"Base URL",value:n.baseUrl,onChange:e=>o({...n,baseUrl:e.target.value}),placeholder:l?"https://api.anthropic.com/v1":"https://api.openai.com/v1",hint:`Use the base URL (ending in /v1) for your ${l?"Anthropic":"OpenAI"}-compatible API.`}),(0,a.jsx)(c.l6,{label:"Client Identity",options:ei,value:n.clientIdentityProfile,onChange:e=>o({...n,clientIdentityProfile:e.target.value}),hint:"Optional. Adds client fingerprint headers for compatible gateways."}),"custom"===n.clientIdentityProfile&&(0,a.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,a.jsx)("label",{className:"text-sm font-medium text-text-main",children:"Custom Headers"}),(0,a.jsx)("textarea",{value:n.clientIdentityHeadersText,onChange:e=>o({...n,clientIdentityHeadersText:e.target.value}),placeholder:'{\n "User-Agent": "custom/1.0"\n}',rows:5,className:"w-full resize-y rounded-[10px] border border-transparent bg-surface-2 px-3 py-2.5 text-[16px] text-text-main placeholder-text-muted/70 transition-all duration-150 focus:border-brand-500/40 focus:outline-none focus:ring-2 focus:ring-brand-500/30 sm:text-sm"}),(0,a.jsx)("p",{className:"text-xs text-text-muted",children:"JSON object or Header: value lines. Auth headers are ignored."})]}),(0,a.jsx)(c.lM,{checked:n.quotaEnabled,onChange:e=>o({...n,quotaEnabled:e}),label:"Quota check",description:"Read remaining credits from the standard /credits endpoint."}),n.quotaEnabled&&(0,a.jsx)(c.pd,{label:"Quota path",value:n.quotaPath,onChange:e=>o({...n,quotaPath:e.target.value}),placeholder:"/credits",hint:'GET {Base URL}{Quota path} with Authorization: Bearer <API key>; response {"credits": 123.45}. Optional total/used drive the usage bar.'}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(c.pd,{label:"API Key (for Check)",type:"password",value:u,onChange:e=>p(e.target.value),className:"flex-1"}),(0,a.jsx)("div",{className:"pt-6",children:(0,a.jsx)(c.$n,{onClick:j,disabled:!u||f||!n.baseUrl.trim(),variant:"secondary",children:f?"Checking...":"Check"})})]}),(0,a.jsx)(c.pd,{label:"Model ID (optional)",value:x,onChange:e=>h(e.target.value),placeholder:"e.g. my-model-id",hint:"If provider lacks /models endpoint, enter a model ID to validate via chat/completions instead."}),y&&(0,a.jsx)(c.Ex,{variant:"success"===y?"success":"error",children:"success"===y?"Valid":"Invalid"}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(c.$n,{onClick:v,fullWidth:!0,disabled:!n.name.trim()||!n.prefix.trim()||!n.baseUrl.trim()||d,children:d?"Saving...":"Save"}),(0,a.jsx)(c.$n,{onClick:r,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})}):null}en.propTypes={isOpen:E().bool.isRequired,node:E().shape({id:E().string,name:E().string,prefix:E().string,apiType:E().string,baseUrl:E().string,clientIdentityProfile:E().string,clientIdentityHeaders:E().object}),onSave:E().func.isRequired,onClose:E().func.isRequired,isAnthropic:E().bool};let eo=()=>Object.fromEntries(Object.keys(u.bs).map(e=>[e,!1]));function ed({isOpen:e,providerAlias:t,providerDisplayAlias:s,notice:r,onSave:l,onClose:n}){let[o,d]=(0,i.useState)(""),[m,p]=(0,i.useState)(eo),[x,h]=(0,i.useState)(null),[f,g]=(0,i.useState)(""),[y,b]=(0,i.useState)(!1),[v,j]=(0,i.useState)("");(0,i.useEffect)(()=>{e&&(d(""),p(eo()),j(""),h(null),g(""))},[e]);let w=e=>{let s=`${t}/`;return e.startsWith(s)?e.slice(s.length):e},k=async()=>{let e=w(o.trim());if(e){h("testing"),g("");try{let s=await fetch("/api/models/test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:`${t}/${e}`})}),a=await s.json();h(a.ok?"ok":"error"),g(a.error||"")}catch(e){h("error"),g(e.message)}}},N=async()=>{let e=w(o.trim());if(e&&!y){b(!0);try{await l(e,m,m.stt?v:null)}finally{b(!1)}}};return(0,a.jsx)(c.aF,{isOpen:e,onClose:n,title:"Add Custom Model",children:(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[r&&(0,a.jsxs)("div",{className:"flex items-start gap-2 text-xs text-text-muted bg-sidebar rounded-lg p-3",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-base shrink-0",children:"info"}),(0,a.jsx)("span",{children:r})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"text-sm font-medium mb-1.5 block",children:"Model ID"}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)("input",{type:"text",value:o,onChange:e=>{d(e.target.value),h(null),g("")},onKeyDown:e=>{"Enter"===e.key&&k()},placeholder:"e.g. claude-opus-4-5",className:"flex-1 px-3 py-2 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary",autoFocus:!0}),(0,a.jsx)(c.$n,{variant:"secondary",icon:"science",loading:"testing"===x,onClick:k,disabled:!o.trim()||"testing"===x,children:"testing"===x?"Testing...":"Test"})]}),(0,a.jsxs)("p",{className:"text-xs text-text-muted mt-1",children:["Sent to provider as: ",(0,a.jsx)("code",{className:"font-mono bg-sidebar px-1 rounded",children:w(o.trim())||"model-id"})]})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"text-sm font-medium mb-1.5 block",children:"Capabilities"}),(0,a.jsx)("div",{className:"flex flex-wrap gap-4",children:Object.entries(u.bs).map(([e,t])=>(0,a.jsx)(c.lM,{checked:!!m[e],onChange:t=>p(s=>({...s,[e]:t})),label:t.label,description:t.desc,size:"sm"},e))})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)(c.lM,{checked:!!m.stt,onChange:e=>{p(t=>({...t,stt:e})),e||j("")},label:"Speech to text",description:"Transcribes audio via /v1/audio/transcriptions",size:"sm"}),m.stt&&(0,a.jsx)("div",{className:"mt-3",children:(0,a.jsx)(c.l6,{label:"Transport",value:v,onChange:e=>j(e.target.value),placeholder:"Provider default (REST)",options:u.vp.map(e=>({value:e,label:u.qw[e].label})),hint:"Realtime transport marker for the STT dispatcher. Empty keeps the provider's REST format."})})]}),"ok"===x&&(0,a.jsxs)("div",{className:"flex items-center gap-2 text-sm text-green-600",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-base",children:"check_circle"}),"Model is reachable"]}),"error"===x&&(0,a.jsxs)("div",{className:"flex items-start gap-2 text-sm text-red-500",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-base shrink-0",children:"cancel"}),(0,a.jsx)("span",{children:f||"Model not reachable"})]}),(0,a.jsxs)("div",{className:"flex gap-2 pt-1",children:[(0,a.jsx)(c.$n,{onClick:n,variant:"ghost",fullWidth:!0,size:"sm",children:"Cancel"}),(0,a.jsx)(c.$n,{onClick:N,fullWidth:!0,size:"sm",disabled:!o.trim()||y,children:y?"Adding...":"Add Model"})]})]})})}ed.propTypes={isOpen:E().bool.isRequired,providerAlias:E().string.isRequired,providerDisplayAlias:E().string.isRequired,notice:E().string,onSave:E().func.isRequired,onClose:E().func.isRequired};let ec=`[
|
|
7
|
+
pt-only-auto-named`:Y,[V,Z]=(0,i.useState)("single"),[X,ei]=(0,i.useState)(""),[er,el]=(0,i.useState)(null),en=()=>{I(et()),R(es()),M({accountId:""}),q({location:"global",reasoningEffort:"high"}),L(O),W(null),Z("single"),ei(""),el(null),y()},eo=()=>{if(r&&n)return{prefix:n.prefix,...n.apiType?{apiType:n.apiType}:{},baseUrl:n.baseUrl,nodeName:n.name,clientIdentityProfile:n.clientIdentityProfile||"default",clientIdentityHeaders:n.clientIdentityHeaders||{}};if(S)return{location:D.location||"global",reasoningEffort:D.reasoningEffort||"high"};if(A){let e={};return z.profile.trim()&&(e.profile=z.profile.trim()),z.region.trim()&&(e.region=z.region.trim()),z.accessKeyId.trim()&&(e.accessKeyId=z.accessKeyId.trim()),z.sessionToken.trim()&&(e.sessionToken=z.sessionToken.trim()),Object.keys(e).length?e:void 0}return function({hasBaseUrlField:e=!1,baseUrl:t="",isAzure:s=!1,azureData:a=null,isCloudflareAi:i=!1,cloudflareData:r=null,region:l="",hasRegions:n=!1}={}){if(e){let e=String(t||"").trim();return e?{baseUrl:e}:void 0}return s?{azureEndpoint:a?.azureEndpoint,apiVersion:a?.apiVersion,deployment:a?.deployment,organization:a?.organization}:i?{accountId:r?.accountId}:n&&l?{region:l}:void 0}({hasBaseUrlField:!!k,baseUrl:P.baseUrl,isAzure:N,azureData:E,isCloudflareAi:C,cloudflareData:_,region:F,hasRegions:!!$})},ed=()=>!!P.apiKey||!!(T&&eo()?.[T]),ec=async()=>{if(r&&!P.defaultModel.trim())return void W("failed");K(!0);try{let e=await fetch("/api/providers/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:t,apiKey:P.apiKey,defaultModel:r?P.defaultModel.trim():void 0,providerSpecificData:eo()})}),s=await e.json();W(s.valid?"success":"failed")}catch{W("failed")}finally{K(!1)}},em=async()=>{if(t&&(b||ed())&&(b||P.name)&&(!r||P.defaultModel.trim())){G(!0);try{let e=!1;try{K(!0),W(null);let s=await fetch("/api/providers/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:t,apiKey:P.apiKey,defaultModel:r?P.defaultModel.trim():void 0,providerSpecificData:eo()})});e=!!(await s.json()).valid,W(e?"success":"failed")}catch{W("failed")}finally{K(!1)}await f({name:P.name||(b?"Ollama Local":""),apiKey:P.apiKey,defaultModel:r?P.defaultModel.trim():void 0,priority:P.priority,proxyPoolId:P.proxyPoolId===ee?null:P.proxyPoolId,testStatus:e?"active":"unknown",providerSpecificData:eo()})&&en()}finally{G(!1)}}},eu=async()=>{let e=X.split("\n");if(!e.length)return;let s=function(e,t,s={}){let{isCloudflareAi:a=!1}=s,i=new Set((Array.isArray(t)?t:[]).map(e=>"string"==typeof e?e.toLowerCase():"")),r=[];for(let t of e){let e,s="string"==typeof t?t.trim():"";if(!s)continue;let l=function(e,t={}){let{isCloudflareAi:s=!1}=t,a=e.split("|");if(s&&a.length>=3){let e=a[0].trim();return{baseName:e||"Key",apiKey:a.slice(1,-1).join("|").trim(),providerSpecificData:{accountId:a[a.length-1].trim()}}}return a.length>=2?{baseName:a[0].trim()||"Key",apiKey:a.slice(1).join("|").trim()}:{baseName:"Key",apiKey:a[0].trim()}}(s,{isCloudflareAi:a});if(!l||!l.apiKey)continue;let n=l.baseName,o=1;for(;e=`${n} ${o}`,i.has(e.toLowerCase());)o+=1;i.add(e.toLowerCase());let d={name:e,apiKey:l.apiKey,skipped:!1};l.providerSpecificData&&(d.providerSpecificData=l.providerSpecificData),r.push(d)}return r}(e,h,{isCloudflareAi:C});if(!s.length)return;G(!0),el(null);let a=0,i=0;for(let e of s)try{let s=!1;try{let a=await fetch("/api/providers/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:t,apiKey:e.apiKey})});s=!!(await a.json().catch(()=>({}))).valid}catch{s=!1}(await fetch("/api/providers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:t,apiKey:e.apiKey,name:e.name,priority:1,testStatus:s?"active":"unknown",...e.providerSpecificData?{providerSpecificData:e.providerSpecificData}:{}})})).ok?a++:i++}catch{i++}G(!1),el({success:a,failed:i}),a>0&&g&&g()};return t?(0,a.jsx)(c.aF,{isOpen:e,title:`Add ${s||t} ${w}`,onClose:en,children:(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(c.$n,{size:"sm",variant:"single"===V?"primary":"ghost",onClick:()=>{Z("single"),el(null)},children:"Single"}),(0,a.jsx)(c.$n,{size:"sm",variant:"bulk"===V?"primary":"ghost",onClick:()=>{Z("bulk"),el(null)},children:"Bulk Add"})]}),"bulk"===V&&(0,a.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,a.jsx)("p",{className:"text-xs text-text-muted",children:C?(0,a.jsxs)(a.Fragment,{children:["One key per line. Format: ",(0,a.jsx)("code",{children:"name|apiKey|accountId"})," or just ",(0,a.jsx)("code",{children:"apiKey"})," (auto-named by index)."]}):"qoder"===t||"qoder-cn"===t?(0,a.jsxs)(a.Fragment,{children:["One PAT per line. Format: ",(0,a.jsx)("code",{children:"name|pt-..."})," or just ",(0,a.jsx)("code",{children:"pt-..."})," (auto-named by index)."]}):(0,a.jsxs)(a.Fragment,{children:["One key per line. Format: ",(0,a.jsx)("code",{children:"name|apiKey"})," or just ",(0,a.jsx)("code",{children:"apiKey"})," (auto-named by index)."]})}),(0,a.jsx)("textarea",{className:"w-full rounded border border-accent/30 bg-sidebar p-2 text-sm font-mono resize-y min-h-[140px] focus:outline-none focus:ring-1 focus:ring-primary",placeholder:Q,value:X,onChange:e=>ei(e.target.value)}),er&&(0,a.jsxs)("div",{className:`text-sm font-medium ${er.failed>0?"text-yellow-400":"text-green-400"}`,children:["✓ ",er.success," added",er.failed>0?`, ✗ ${er.failed} failed`:""]}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(c.$n,{onClick:eu,fullWidth:!0,disabled:B||!X.trim(),children:B?"Adding...":"Add All Keys"}),(0,a.jsx)(c.$n,{onClick:en,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]}),"single"===V&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(c.pd,{label:"Name",value:P.name,onChange:e=>I({...P,name:e.target.value}),placeholder:b?"Ollama Local":"Production Key"}),k&&(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(c.pd,{label:k.label,value:P.baseUrl,onChange:e=>I({...P,baseUrl:e.target.value}),placeholder:k.placeholder,hint:k.help,className:"flex-1"}),(0,a.jsx)("div",{className:"pt-6",children:(0,a.jsx)(c.$n,{onClick:ec,disabled:J||B,variant:"secondary",children:J?"Checking...":"Check"})})]}),!b&&(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(c.pd,{label:w,type:v?"text":"password",value:P.apiKey,onChange:e=>I({...P,apiKey:e.target.value}),placeholder:v?"grok-web"===t?"sso=xxxxx... or just the raw value":"eyJhbGciOi...":j?"xai-...":"qoder"===t||"qoder-cn"===t?"pt-...":"",className:"flex-1"}),(0,a.jsx)("div",{className:"pt-6",children:(0,a.jsx)(c.$n,{onClick:ec,disabled:!P.apiKey||J||B,variant:"secondary",children:J?"Checking...":"Check"})})]}),j&&(0,a.jsx)("p",{className:"text-xs text-text-muted",children:"Use a direct xAI API key from console.x.ai. This is separate from Grok Build OAuth."}),v&&d&&(0,a.jsxs)("p",{className:"text-xs text-text-muted",children:[d,u&&(0,a.jsxs)(a.Fragment,{children:[" ",(0,a.jsxs)("a",{href:u,target:"_blank",rel:"noopener noreferrer",className:"text-primary underline",children:["Open ",u.replace(/^https?:\/\//,"")]})]})]}),$&&(0,a.jsx)(c.l6,{label:"Region",value:F,onChange:e=>L(e.target.value),options:$.map(e=>({value:e.id,label:e.label}))}),r&&(0,a.jsx)(c.pd,{label:"Default Model",value:P.defaultModel,onChange:e=>I({...P,defaultModel:e.target.value}),placeholder:l?"claude-3-5-sonnet-latest":"gpt-4o-mini"}),b&&(0,a.jsxs)("p",{className:"text-xs text-text-muted",children:["Leave blank to use ",(0,a.jsx)("code",{children:"http://localhost:11434"}),". For remote Ollama, enter the full host URL (e.g. ",(0,a.jsx)("code",{children:"http://192.168.1.10:11434"}),")."]}),H&&(0,a.jsx)(c.Ex,{variant:"success"===H?"success":"error",children:"success"===H?"Valid":"Invalid"}),x&&(0,a.jsx)("p",{className:"text-xs text-red-500 break-words",children:x}),r&&(0,a.jsx)("p",{className:"text-xs text-text-muted",children:"Enter the model ID exactly as your compatible endpoint expects it. This model will be saved as the connection default."}),C&&(0,a.jsxs)("div",{className:"bg-sidebar/50 p-4 rounded-lg border border-accent/20",children:[(0,a.jsx)("h3",{className:"font-semibold mb-3 text-sm",children:"Cloudflare Workers AI"}),(0,a.jsx)(c.pd,{label:"Account ID",value:_.accountId,onChange:e=>M({..._,accountId:e.target.value}),placeholder:"abc123def456..."}),(0,a.jsxs)("p",{className:"text-xs text-text-muted mt-2",children:["Find your Account ID in the right sidebar of ",(0,a.jsx)("a",{href:"https://dash.cloudflare.com",target:"_blank",rel:"noopener noreferrer",className:"text-primary underline",children:"dash.cloudflare.com"})]})]}),S&&(0,a.jsxs)("div",{className:"bg-sidebar/50 p-4 rounded-lg border border-accent/20",children:[(0,a.jsx)("h3",{className:"font-semibold mb-3 text-sm",children:"Vertex AI Configuration"}),(0,a.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,a.jsx)(c.l6,{label:"Location",value:D.location,onChange:e=>q({...D,location:e.target.value}),options:[{value:"global",label:"global (recommended for Gemini 3.x)"},{value:"us-central1",label:"us-central1"},{value:"us-east4",label:"us-east4"},{value:"europe-west1",label:"europe-west1"},{value:"europe-west4",label:"europe-west4"},{value:"asia-east1",label:"asia-east1"},{value:"asia-northeast1",label:"asia-northeast1"}]}),(0,a.jsx)(c.l6,{label:"Reasoning Effort (default)",value:D.reasoningEffort,onChange:e=>q({...D,reasoningEffort:e.target.value}),options:[{value:"high",label:"high (32k tokens — default for Pro)"},{value:"medium",label:"medium (8k tokens)"},{value:"low",label:"low (1k tokens)"},{value:"",label:"none (let model decide)"}]}),(0,a.jsxs)("p",{className:"text-xs text-text-muted",children:["Location ",(0,a.jsx)("code",{children:"global"})," is required for Gemini 3.1 Pro Preview. Reasoning effort sets the default ",(0,a.jsx)("code",{children:"thinkingBudget"}),"; clients can override per-request via ",(0,a.jsx)("code",{children:"reasoning_effort"}),"."]})]})]}),A&&(0,a.jsxs)("div",{className:"bg-sidebar/50 p-4 rounded-lg border border-accent/20",children:[(0,a.jsx)("h3",{className:"font-semibold mb-3 text-sm",children:"AWS Bedrock Credentials"}),(0,a.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,a.jsx)(c.pd,{label:"AWS Profile (SSO — recommended)",value:z.profile,onChange:e=>U({...z,profile:e.target.value}),placeholder:"my-sso-profile"}),(0,a.jsx)(c.pd,{label:"Region",value:z.region,onChange:e=>U({...z,region:e.target.value}),placeholder:"us-east-1"})]}),(0,a.jsxs)("p",{className:"text-xs text-text-muted mt-2",children:["Set a profile from ",(0,a.jsx)("code",{children:"~/.aws/config"})," and leave the API key empty, then run"," ",(0,a.jsxs)("code",{children:["aws sso login --profile ",z.profile||"my-sso-profile"]}),". Credentials refresh automatically."]}),(0,a.jsxs)("div",{className:"flex flex-col gap-3 mt-4",children:[(0,a.jsx)(c.pd,{label:"Access Key ID (only for static keys)",value:z.accessKeyId,onChange:e=>U({...z,accessKeyId:e.target.value}),placeholder:"AKIA..."}),(0,a.jsx)(c.pd,{label:"Session Token (only for temporary ASIA… keys)",value:z.sessionToken,onChange:e=>U({...z,sessionToken:e.target.value}),placeholder:"FwoGZXIvYXdz..."})]}),(0,a.jsxs)("p",{className:"text-xs text-text-muted mt-2",children:["For static keys instead: put the AWS ",(0,a.jsx)("strong",{children:"secret"})," access key in the API Key field above and the access key id here. A profile, if set, takes precedence."]})]}),N&&(0,a.jsxs)("div",{className:"bg-sidebar/50 p-4 rounded-lg border border-accent/20",children:[(0,a.jsx)("h3",{className:"font-semibold mb-3 text-sm",children:"Azure OpenAI Configuration"}),(0,a.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,a.jsx)(c.pd,{label:"Azure Endpoint",value:E.azureEndpoint,onChange:e=>R({...E,azureEndpoint:e.target.value}),placeholder:"https://your-resource.openai.azure.com"}),(0,a.jsx)(c.pd,{label:"Deployment Name",value:E.deployment,onChange:e=>R({...E,deployment:e.target.value}),placeholder:"gpt-4"}),(0,a.jsx)(c.pd,{label:"API Version",value:E.apiVersion,onChange:e=>R({...E,apiVersion:e.target.value}),placeholder:"2024-10-01-preview"}),(0,a.jsx)(c.pd,{label:"Organization",value:E.organization,onChange:e=>R({...E,organization:e.target.value}),placeholder:"Organization ID"})]})]}),(0,a.jsx)(c.pd,{label:"Priority",type:"number",value:P.priority,onChange:e=>I({...P,priority:Number.parseInt(e.target.value)||1})}),(0,a.jsx)(c.l6,{label:"Proxy Pool",value:P.proxyPoolId,onChange:e=>I({...P,proxyPoolId:e.target.value}),options:[{value:ee,label:"None"},...(p||[]).map(e=>({value:e.id,label:e.name}))],placeholder:"None"}),0===(p||[]).length&&(0,a.jsx)("p",{className:"text-xs text-text-muted",children:"No active proxy pools available. Create one in Proxy Pools page first."}),(0,a.jsx)("p",{className:"text-xs text-text-muted",children:"Legacy manual proxy fields are still accepted by API for backward compatibility."}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(c.$n,{onClick:em,fullWidth:!0,disabled:B||!b&&(!P.name||!ed())||r&&!P.defaultModel.trim()||N&&(!E.azureEndpoint||!E.deployment||!E.organization)||C&&!_.accountId,children:B?"Saving...":"Save"}),(0,a.jsx)(c.$n,{onClick:en,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})]})}):null}ea.propTypes={isOpen:E().bool.isRequired,provider:E().string,providerName:E().string,isCompatible:E().bool,isAnthropic:E().bool,providerNode:E().shape({name:E().string,prefix:E().string,apiType:E().string,baseUrl:E().string,clientIdentityProfile:E().string,clientIdentityHeaders:E().object}),authType:E().string,authHint:E().string,website:E().string,proxyPools:E().arrayOf(E().shape({id:E().string,name:E().string})),error:E().string,existingNames:E().arrayOf(E().string),onSave:E().func.isRequired,onBulkDone:E().func,onClose:E().func.isRequired};let ei=[{value:"default",label:"Default"},{value:"claude-cli",label:"Claude CLI"},{value:"codex-cli",label:"Codex CLI"},{value:"openclaw",label:"OpenClaw"},{value:"custom",label:"Custom Headers"}],er=new Set(["authorization","x-api-key","api-key","cookie"]);function el(e){let t=String(e||"").trim();if(!t)return{headers:{}};try{let e;if(t.startsWith("{")){let s=JSON.parse(t);if(!s||"object"!=typeof s||Array.isArray(s))return{error:"Use a JSON object or Header: value lines."};e=Object.entries(s)}else for(let s of(e=[],t.split(/\r?\n/))){let t=s.trim();if(!t||t.startsWith("#"))continue;let a=t.indexOf(":");if(a<=0)return{error:"Each custom header line must use Header: value."};e.push([t.slice(0,a),t.slice(a+1)])}let s={};for(let[t,a]of e){let e=String(t||"").trim(),i=String(a||"").trim();!e||!i||er.has(e.toLowerCase())||(s[e]=i)}return{headers:s}}catch{return{error:"Use valid JSON or Header: value lines."}}}function en({isOpen:e,node:t,onSave:s,onClose:r,isAnthropic:l}){let[n,o]=(0,i.useState)({name:"",prefix:"",apiType:"chat",baseUrl:"https://api.openai.com/v1",clientIdentityProfile:"default",clientIdentityHeadersText:"",quotaEnabled:!1,quotaPath:"/credits"}),[d,m]=(0,i.useState)(!1),[u,p]=(0,i.useState)(""),[x,h]=(0,i.useState)(""),[f,g]=(0,i.useState)(!1),[y,b]=(0,i.useState)(null);(0,i.useEffect)(()=>{t&&o({name:t.name||"",prefix:t.prefix||"",apiType:t.apiType||"chat",baseUrl:t.baseUrl||(l?"https://api.anthropic.com/v1":"https://api.openai.com/v1"),clientIdentityProfile:t.clientIdentityProfile||"default",clientIdentityHeadersText:t.clientIdentityHeaders?JSON.stringify(t.clientIdentityHeaders,null,2):"",quotaEnabled:!0===t.quotaEnabled,quotaPath:t.quotaPath||"/credits"})},[t,l]);let v=async()=>{if(!n.name.trim()||!n.prefix.trim()||!n.baseUrl.trim())return;let e="custom"===n.clientIdentityProfile?el(n.clientIdentityHeadersText):{headers:{}};if(e.error)return void b("failed");m(!0);try{let t={name:n.name,prefix:n.prefix,baseUrl:n.baseUrl,clientIdentityProfile:n.clientIdentityProfile,clientIdentityHeaders:e.headers,quotaEnabled:n.quotaEnabled,quotaPath:n.quotaPath};l||(t.apiType=n.apiType),await s(t)}finally{m(!1)}},j=async()=>{let e="custom"===n.clientIdentityProfile?el(n.clientIdentityHeadersText):{headers:{}};if(e.error)return void b("failed");g(!0);try{let t=await fetch("/api/provider-nodes/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:n.baseUrl,apiKey:u,type:l?"anthropic-compatible":"openai-compatible",modelId:x.trim()||void 0,clientIdentityProfile:n.clientIdentityProfile,clientIdentityHeaders:e.headers})}),s=await t.json();b(s.valid?"success":"failed")}catch{b("failed")}finally{g(!1)}};return t?(0,a.jsx)(c.aF,{isOpen:e,title:`Edit ${l?"Anthropic":"OpenAI"} Compatible`,onClose:r,children:(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,a.jsx)(c.pd,{label:"Name",value:n.name,onChange:e=>o({...n,name:e.target.value}),placeholder:`${l?"Anthropic":"OpenAI"} Compatible (Prod)`,hint:"Required. A friendly label for this node."}),(0,a.jsx)(c.pd,{label:"Prefix",value:n.prefix,onChange:e=>o({...n,prefix:e.target.value}),placeholder:l?"ac-prod":"oc-prod",hint:"Required. Used as the provider prefix for model IDs."}),!l&&(0,a.jsx)(c.l6,{label:"API Type",options:[{value:"chat",label:"Chat Completions"},{value:"responses",label:"Responses API"}],value:n.apiType,onChange:e=>o({...n,apiType:e.target.value})}),(0,a.jsx)(c.pd,{label:"Base URL",value:n.baseUrl,onChange:e=>o({...n,baseUrl:e.target.value}),placeholder:l?"https://api.anthropic.com/v1":"https://api.openai.com/v1",hint:`Use the base URL (ending in /v1) for your ${l?"Anthropic":"OpenAI"}-compatible API.`}),(0,a.jsx)(c.l6,{label:"Client Identity",options:ei,value:n.clientIdentityProfile,onChange:e=>o({...n,clientIdentityProfile:e.target.value}),hint:"Optional. Adds client fingerprint headers for compatible gateways."}),"custom"===n.clientIdentityProfile&&(0,a.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,a.jsx)("label",{className:"text-sm font-medium text-text-main",children:"Custom Headers"}),(0,a.jsx)("textarea",{value:n.clientIdentityHeadersText,onChange:e=>o({...n,clientIdentityHeadersText:e.target.value}),placeholder:'{\n "User-Agent": "custom/1.0"\n}',rows:5,className:"w-full resize-y rounded-[10px] border border-transparent bg-surface-2 px-3 py-2.5 text-[16px] text-text-main placeholder-text-muted/70 transition-all duration-150 focus:border-brand-500/40 focus:outline-none focus:ring-2 focus:ring-brand-500/30 sm:text-sm"}),(0,a.jsx)("p",{className:"text-xs text-text-muted",children:"JSON object or Header: value lines. Auth headers are ignored."})]}),(0,a.jsx)(c.lM,{checked:n.quotaEnabled,onChange:e=>o({...n,quotaEnabled:e}),label:"Quota check",description:"Read remaining credits from the standard /credits endpoint."}),n.quotaEnabled&&(0,a.jsx)(c.pd,{label:"Quota path",value:n.quotaPath,onChange:e=>o({...n,quotaPath:e.target.value}),placeholder:"/credits",hint:'GET {Base URL}{Quota path} with Authorization: Bearer <API key>; response {"credits": 123.45}. Optional total/used drive the usage bar.'}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(c.pd,{label:"API Key (for Check)",type:"password",value:u,onChange:e=>p(e.target.value),className:"flex-1"}),(0,a.jsx)("div",{className:"pt-6",children:(0,a.jsx)(c.$n,{onClick:j,disabled:!u||f||!n.baseUrl.trim(),variant:"secondary",children:f?"Checking...":"Check"})})]}),(0,a.jsx)(c.pd,{label:"Model ID (optional)",value:x,onChange:e=>h(e.target.value),placeholder:"e.g. my-model-id",hint:"If provider lacks /models endpoint, enter a model ID to validate via chat/completions instead."}),y&&(0,a.jsx)(c.Ex,{variant:"success"===y?"success":"error",children:"success"===y?"Valid":"Invalid"}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(c.$n,{onClick:v,fullWidth:!0,disabled:!n.name.trim()||!n.prefix.trim()||!n.baseUrl.trim()||d,children:d?"Saving...":"Save"}),(0,a.jsx)(c.$n,{onClick:r,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})}):null}en.propTypes={isOpen:E().bool.isRequired,node:E().shape({id:E().string,name:E().string,prefix:E().string,apiType:E().string,baseUrl:E().string,clientIdentityProfile:E().string,clientIdentityHeaders:E().object}),onSave:E().func.isRequired,onClose:E().func.isRequired,isAnthropic:E().bool};let eo=()=>Object.fromEntries(Object.keys(u.bs).map(e=>[e,!1]));function ed({isOpen:e,providerAlias:t,providerDisplayAlias:s,notice:r,onSave:l,onClose:n}){let[o,d]=(0,i.useState)(""),[m,p]=(0,i.useState)(eo),[x,h]=(0,i.useState)(null),[f,g]=(0,i.useState)(""),[y,b]=(0,i.useState)(!1),[v,j]=(0,i.useState)("");(0,i.useEffect)(()=>{e&&(d(""),p(eo()),j(""),h(null),g(""))},[e]);let w=e=>{let s=`${t}/`;return e.startsWith(s)?e.slice(s.length):e},k=async()=>{let e=w(o.trim());if(e){h("testing"),g("");try{let s=await fetch("/api/models/test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:`${t}/${e}`})}),a=await s.json();h(a.ok?"ok":"error"),g(a.error||"")}catch(e){h("error"),g(e.message)}}},N=async()=>{let e=w(o.trim());if(e&&!y){b(!0);try{await l(e,m,m.stt?v:null)}finally{b(!1)}}};return(0,a.jsx)(c.aF,{isOpen:e,onClose:n,title:"Add Custom Model",children:(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[r&&(0,a.jsxs)("div",{className:"flex items-start gap-2 text-xs text-text-muted bg-sidebar rounded-lg p-3",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-base shrink-0",children:"info"}),(0,a.jsx)("span",{children:r})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"text-sm font-medium mb-1.5 block",children:"Model ID"}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)("input",{type:"text",value:o,onChange:e=>{d(e.target.value),h(null),g("")},onKeyDown:e=>{"Enter"===e.key&&k()},placeholder:"e.g. claude-opus-4-5",className:"flex-1 px-3 py-2 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary",autoFocus:!0}),(0,a.jsx)(c.$n,{variant:"secondary",icon:"science",loading:"testing"===x,onClick:k,disabled:!o.trim()||"testing"===x,children:"testing"===x?"Testing...":"Test"})]}),(0,a.jsxs)("p",{className:"text-xs text-text-muted mt-1",children:["Sent to provider as: ",(0,a.jsx)("code",{className:"font-mono bg-sidebar px-1 rounded",children:w(o.trim())||"model-id"})]})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"text-sm font-medium mb-1.5 block",children:"Capabilities"}),(0,a.jsx)("div",{className:"flex flex-wrap gap-4",children:Object.entries(u.bs).map(([e,t])=>(0,a.jsx)(c.lM,{checked:!!m[e],onChange:t=>p(s=>({...s,[e]:t})),label:t.label,description:t.desc,size:"sm"},e))})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)(c.lM,{checked:!!m.stt,onChange:e=>{p(t=>({...t,stt:e})),e||j("")},label:"Speech to text",description:"Transcribes audio via /v1/audio/transcriptions",size:"sm"}),m.stt&&(0,a.jsx)("div",{className:"mt-3",children:(0,a.jsx)(c.l6,{label:"Transport",value:v,onChange:e=>j(e.target.value),placeholder:"Provider default (REST)",options:u.vp.map(e=>({value:e,label:u.qw[e].label})),hint:"Realtime transport marker for the STT dispatcher. Empty keeps the provider's REST format."})})]}),"ok"===x&&(0,a.jsxs)("div",{className:"flex items-center gap-2 text-sm text-green-600",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-base",children:"check_circle"}),"Model is reachable"]}),"error"===x&&(0,a.jsxs)("div",{className:"flex items-start gap-2 text-sm text-red-500",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-base shrink-0",children:"cancel"}),(0,a.jsx)("span",{children:f||"Model not reachable"})]}),(0,a.jsxs)("div",{className:"flex gap-2 pt-1",children:[(0,a.jsx)(c.$n,{onClick:n,variant:"ghost",fullWidth:!0,size:"sm",children:"Cancel"}),(0,a.jsx)(c.$n,{onClick:N,fullWidth:!0,size:"sm",disabled:!o.trim()||y,children:y?"Adding...":"Add Model"})]})]})})}ed.propTypes={isOpen:E().bool.isRequired,providerAlias:E().string.isRequired,providerDisplayAlias:E().string.isRequired,notice:E().string,onSave:E().func.isRequired,onClose:E().func.isRequired};let ec=`[
|
|
8
8
|
{
|
|
9
9
|
"accessToken": "eyJhbGc...",
|
|
10
10
|
"refreshToken": "rt_...",
|
|
@@ -24,4 +24,4 @@ pt-only-auto-named`:Y,[V,Z]=(0,i.useState)("single"),[X,ei]=(0,i.useState)(""),[
|
|
|
24
24
|
"id_token": "eyJ0eXAiOiJKV1QiLCJhbGci...",
|
|
25
25
|
"email": "account2@example.com"
|
|
26
26
|
}
|
|
27
|
-
]`;function ep(e){let t,s=e.trim();if(!s)return[];try{t=JSON.parse(s)}catch(e){try{let e=s;e.startsWith("[")||((e=e.replace(/\}\s*,\s*\{/g,"},{").replace(/\}\s*\{/g,"},{")).endsWith(",")&&(e=e.slice(0,-1)),e=`[${e}]`),t=JSON.parse(e)}catch{throw e}}if(Array.isArray(t))return t;if(t&&"object"==typeof t)return Array.isArray(t.accounts)?t.accounts:[t];throw Error("Input must be a JSON object or array of objects")}function ex({isOpen:e,onClose:t,onSuccess:s}){let[r,l]=(0,i.useState)(""),[n,o]=(0,i.useState)(!1),[d,m]=(0,i.useState)(""),[u,p]=(0,i.useState)(null),[x,h]=(0,i.useState)(!1),[f,g]=(0,i.useState)(null),y=(0,i.useRef)(null),b=()=>{n||(l(""),m(""),p(null),g(null),h(!1),t())},v=async e=>{if(!e||0===e.length)return;m("");let t=Array.from(e).filter(e=>e.name.endsWith(".json")||"application/json"===e.type||""===e.type);if(0===t.length)return void m((0,T.Tl)("Please select valid .json files"));try{let e=[];for(let s of t){let t=await s.text(),a=ep(t);Array.isArray(a)?e.push(...a):a&&e.push(a)}if(0===e.length)return void m((0,T.Tl)("No accounts found in selected files"));l(JSON.stringify(e,null,2)),g({filesCount:t.length,accountsCount:e.length})}catch(e){m(`${(0,T.Tl)("Error reading files")}: ${e.message}`)}},j=async()=>{let e;m(""),p(null);try{e=ep(r)}catch(e){m(`${(0,T.Tl)("Invalid JSON")}: ${e.message}`);return}if(!e||0===e.length)return void m((0,T.Tl)("No accounts found in input"));o(!0);try{let t=await fetch("/api/oauth/grok-cli/bulk-import",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({accounts:e})}),a=await t.json();if(!t.ok)return void m(a?.error||`Request failed: ${t.status}`);p(a),a.success>0&&"function"==typeof s&&s()}catch(e){m(e.message||(0,T.Tl)("Request failed"))}finally{o(!1)}},w=u?.results?.filter(e=>!e.ok)||[];return(0,a.jsx)(c.aF,{isOpen:e,title:(0,T.Tl)("Bulk Add Grok CLI Accounts"),onClose:b,children:(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,a.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[(0,a.jsx)("p",{className:"text-xs text-text-muted",children:(0,T.Tl)("Upload multiple .json files or paste JSON array / object.")}),(0,a.jsx)("input",{ref:y,type:"file",accept:".json,application/json",multiple:!0,className:"hidden",onChange:e=>{v(e.target.files),e.target&&(e.target.value="")}}),(0,a.jsx)(c.$n,{type:"button",size:"sm",variant:"secondary",icon:"upload_file",onClick:()=>y.current?.click(),disabled:n,children:(0,T.Tl)("Upload JSON Files")})]}),(0,a.jsxs)("div",{onDragOver:e=>{e.preventDefault(),h(!0)},onDragLeave:e=>{e.preventDefault(),h(!1)},onDrop:e=>{e.preventDefault(),h(!1),e.dataTransfer?.files?.length>0&&v(e.dataTransfer.files)},className:`relative rounded border transition-colors ${x?"border-primary bg-primary/10 ring-2 ring-primary/30":"border-accent/30 bg-sidebar"}`,children:[(0,a.jsx)("textarea",{className:"w-full rounded bg-transparent p-2.5 text-sm font-mono resize-y min-h-[240px] focus:outline-none focus:ring-1 focus:ring-primary",placeholder:eu,value:r,onChange:e=>{l(e.target.value),g(null)},disabled:n}),x&&(0,a.jsxs)("div",{className:"absolute inset-0 flex flex-col items-center justify-center bg-sidebar/90 rounded pointer-events-none backdrop-blur-xs",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-3xl text-primary mb-1",children:"upload_file"}),(0,a.jsx)("span",{className:"text-sm font-medium text-primary",children:(0,T.Tl)("Drop .json files here")})]})]}),f&&(0,a.jsxs)("div",{className:"flex items-center gap-1.5 text-xs text-green-400 font-medium bg-green-500/10 border border-green-500/20 px-2.5 py-1.5 rounded",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:"check_circle"}),(0,a.jsxs)("span",{children:[(0,T.Tl)("Loaded")," ",f.accountsCount," ",(0,T.Tl)("account(s) from")," ",f.filesCount," ",(0,T.Tl)("file(s)")]})]}),d&&(0,a.jsx)("p",{className:"text-xs text-red-500 break-words",children:d}),u&&u.failed>0&&(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,a.jsxs)("div",{className:"text-sm font-medium text-yellow-400",children:["✗ ",u.failed," ",(0,T.Tl)("failed")]}),w.length>0&&(0,a.jsx)("ul",{className:"rounded border border-accent/20 bg-sidebar/50 p-2 text-xs font-mono max-h-40 overflow-y-auto",children:w.map(e=>(0,a.jsxs)("li",{className:"text-red-400",children:["[",e.index,"] ",e.error]},e.index))})]}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(c.$n,{onClick:j,fullWidth:!0,disabled:n||!r.trim(),children:n?(0,T.Tl)("Importing..."):(0,T.Tl)("Import All")}),(0,a.jsx)(c.$n,{onClick:b,variant:"ghost",fullWidth:!0,disabled:n,children:(0,T.Tl)("Close")})]})]})})}var eh=s(65921);let ef=["host","content-length","content-type","connection","transfer-encoding","authorization","cookie"],eg=/^[A-Za-z0-9-]+$/;function ey({providerId:e}){let t=(0,eh.i)(),[s,r]=(0,i.useState)(!1),[l,n]=(0,i.useState)([{name:"",value:""}]),[o,d]=(0,i.useState)({}),[m,u]=(0,i.useState)(!1),[p,x]=(0,i.useState)(!1);(0,i.useEffect)(()=>{let t=!1;return fetch(`/api/providers/${e}/overrides`,{cache:"no-store"}).then(e=>e.ok?e.json():null).then(e=>{if(t||!e)return;let s=e.builtinHeaders||{},a=Object.entries({...s,...e.headers||{}}).map(([e,t])=>({name:e,value:t}));d(s),n(a.length?a:[{name:"",value:""}]),u(Object.keys(e.headers||{}).length>0)}).catch(()=>{}),()=>{t=!0}},[e]);let h=(e,t,s)=>{n(a=>a.map((a,i)=>i===e?{...a,[t]:s}:a))},f=(0,i.useCallback)(async()=>{let s={};for(let e of l.filter(e=>e.name.trim())){let a=e.name.trim();if(!eg.test(a))return void t.error(`Invalid header name: ${a}`);if(ef.includes(a.toLowerCase()))return void t.error(`Header ${a} cannot be overridden`);if(a in s)return void t.error(`Duplicate header name: ${a}`);e.value!==o[a]&&(s[a]=e.value)}x(!0);try{let a=await fetch(`/api/providers/${e}/overrides`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({headers:s})});if(!a.ok){let e=await a.json().catch(()=>({}));t.error(e.error||"Failed to save");return}u(Object.keys(s).length>0),t.success("Custom headers saved")}finally{x(!1)}},[l,o,e,t]);return 0!==Object.keys(o).length||m?(0,a.jsxs)(c.Zp,{padding:"xs",children:[(0,a.jsxs)("button",{type:"button",onClick:()=>r(e=>!e),className:"flex w-full items-center justify-between text-left",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-primary text-[20px]",children:"tune"}),(0,a.jsx)("span",{className:"text-sm font-semibold",children:"Custom Headers"}),m&&(0,a.jsx)(c.Ex,{variant:"success",size:"sm",children:"Active"})]}),(0,a.jsx)("span",{className:"material-symbols-outlined text-text-muted",children:s?"expand_less":"expand_more"})]}),s&&(0,a.jsxs)("div",{className:"mt-3 border-t border-border pt-3",children:[(0,a.jsx)("div",{className:"flex flex-col gap-2",children:l.map((e,t)=>{let s=e.name.trim()in o&&e.value!==o[e.name.trim()];return(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("input",{value:e.name,onChange:e=>h(t,"name",e.target.value),placeholder:"Header-Name",spellCheck:!1,className:"w-44 rounded-md border border-border bg-background px-2 py-1.5 text-sm focus:border-primary focus:outline-none"}),(0,a.jsx)("input",{value:e.value,onChange:e=>h(t,"value",e.target.value),placeholder:"Value",spellCheck:!1,title:s?"Overridden":e.name.trim()in o?"Registry default":"",className:`min-w-0 flex-1 rounded-md border bg-background px-2 py-1.5 text-sm focus:border-primary focus:outline-none ${s?"border-amber-400/60":"border-border"}`}),(0,a.jsx)("button",{type:"button",title:"Remove header",onClick:()=>n(e=>e.length>1?e.filter((e,s)=>s!==t):[{name:"",value:""}]),className:"shrink-0 text-text-muted hover:text-red-500",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"delete"})})]},t)})}),(0,a.jsxs)("div",{className:"mt-3 flex items-center justify-between gap-2",children:[(0,a.jsxs)("button",{type:"button",onClick:()=>n(e=>[...e,{name:"",value:""}]),className:"flex items-center gap-1 text-xs text-primary hover:underline",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"add"}),"Add header"]}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)("button",{type:"button",disabled:p,onClick:()=>{n(Object.entries(o).map(([e,t])=>({name:e,value:t})))},className:"rounded-md border border-border px-3 py-1.5 text-xs hover:bg-black/[0.03] dark:hover:bg-white/[0.03] disabled:opacity-50",children:"Reset"}),(0,a.jsx)("button",{type:"button",disabled:p,onClick:f,className:"rounded-md bg-primary px-3 py-1.5 text-xs font-medium text-white hover:opacity-90 disabled:opacity-50",children:p?"Saving...":"Save"})]})]})]})]}):null}ey.propTypes={providerId:E().string.isRequired};var eb=s(97132),ev=s(93195);let ej=[{value:"fill-first",label:"Fallback — try in order"},{value:"round-robin",label:"Round Robin — rotate"},{value:"cache-affinity",label:"Cache Affinity — prompt cache sticky"}],ew={claude:"claudeAutoPing",codex:"codexAutoPing"},ek=[{value:"auto",label:"Retry: Auto"},{value:"15",label:"Retry: 15s"},{value:"30",label:"Retry: 30s"},{value:"60",label:"Retry: 1m"},{value:"120",label:"Retry: 2m"},{value:"300",label:"Retry: 5m"},{value:"600",label:"Retry: 10m"},{value:"1800",label:"Retry: 30m"},{value:"3600",label:"Retry: 1h"}];function eN(e){return new Promise(t=>setTimeout(t,e))}function eC(){let e,t,s,l,p,x,h=(0,r.useParams)(),f=(0,r.useRouter)(),g=h.id,{getCaps:y}=(0,A.yU)(),[b,v]=(0,i.useState)([]),[j,w]=(0,i.useState)(1),[k,N]=(0,i.useState)(10),[$,I]=(0,i.useState)(!0),[E,R]=(0,i.useState)(null),[M,_]=(0,i.useState)([]),[F,L]=(0,i.useState)(!1),[J,K]=(0,i.useState)(!1),[H,W]=(0,i.useState)(!1),[B,G]=(0,i.useState)(!1),[V,Z]=(0,i.useState)(""),[Y,ee]=(0,i.useState)(!1),[et,es]=(0,i.useState)(!1),[ei,er]=(0,i.useState)(!1),[el,eo]=(0,i.useState)(!1),[ec,eu]=(0,i.useState)(!1),[ep,eh]=(0,i.useState)(!1),[ef,eg]=(0,i.useState)(null),[eC,eS]=(0,i.useState)({}),[eA,eT]=(0,i.useState)([]),[e$,eO]=(0,i.useState)(!1),[eP,eI]=(0,i.useState)({}),[eE,eR]=(0,i.useState)(""),[eM,eD]=(0,i.useState)(()=>new Set),[eq,e_]=(0,i.useState)(!1),[ez,eU]=(0,i.useState)([]),[eF,eL]=(0,i.useState)("__none__"),[eJ,eK]=(0,i.useState)(!1),[eH,eW]=(0,i.useState)(null),[eB,eG]=(0,i.useState)("fill-first"),[eQ,eV]=(0,i.useState)(""),[eZ,eX]=(0,i.useState)("auto"),[eY,e0]=(0,i.useState)("auto"),[e1,e5]=(0,i.useState)(""),[e2,e3]=(0,i.useState)({enabled:!1,connections:{},schedules:{}}),[e4,e6]=(0,i.useState)(null),[e8,e9]=(0,i.useState)([]),[e7,te]=(0,i.useState)([]),[tt,ts]=(0,i.useState)(null),[ta,ti]=(0,i.useState)([]),[tr,tl]=(0,i.useState)([]),[tn,to]=(0,i.useState)([]),[td,tc]=(0,i.useState)(!1),[tm,tu]=(0,i.useState)(null),[tp,tx]=(0,i.useState)(!1),[th,tf]=(0,i.useState)(!1),[tg,ty]=(0,i.useState)(!1),[tb,tv]=(0,i.useState)(null),[tj,tw]=(0,i.useState)({}),[tk,tN]=(0,i.useState)(null),tC=(0,i.useRef)(!1),[tS,tA]=(0,i.useState)(!1),[tT,t$]=(0,i.useState)(!1),[tO,tP]=(0,i.useState)(!1),[tI,tE]=(0,i.useState)(!1),[tR,tM]=(0,i.useState)(null),[tD,tq]=(0,i.useState)(!1),[t_,tz]=(0,i.useState)(!1),[tU,tF]=(0,i.useState)(null),[tL,tJ]=(0,i.useState)(!1),[tK,tH]=(0,i.useState)(!1),[tW,tB]=(0,i.useState)(null),[tG,tQ]=(0,i.useState)({}),[tV,tZ]=(0,i.useState)(null),tX=(0,i.useRef)(!1),{copied:tY,copy:t0}=(0,S.C)(),t1="ag_risk_confirmed",t5=()=>{L(!0)},t2=()=>{"antigravity"===g&&"true"!==window.localStorage.getItem(t1)?tx(!0):"xiaomi-mimo"===g?K(!0):t9?t5():(Z(""),G(!0))},t3=()=>{Z(""),G(!0)},t4=()=>{t9?t2():t3()},t6=E?{id:E.id,name:E.name||("anthropic-compatible"===E.type?"Anthropic Compatible":"OpenAI Compatible"),color:"anthropic-compatible"===E.type?"#D97757":"#10A37F",textIcon:"anthropic-compatible"===E.type?"AC":"OC",apiType:E.apiType,baseUrl:E.baseUrl,type:E.type}:m.zN[g]||m.fg[g]||m.IS[g]||m.nJ[g]||m.br[g],t8=t6?.authModes||[],t9=!!m.zN[g]||!!m.IS[g]||t8.includes("oauth"),t7=!!m.fg[g]||t8.includes("apikey"),se=!!m.IS[g]?.noAuth,st=(0,u.KC)(g),ss=("cursor"===g||"zed"===g)&&e7.length>0?e7:st,sa=(0,m.wG)(g),si=(0,m.mq)(g),sr=(0,m.gb)(g),sl=si||sr,sn=!sl&&t9&&t7,so="xai"===g?"Grok Build OAuth":"grok-cli"===g?"Grok CLI Device Login":"kimi"===g?"Kimi Coding OAuth":"OAuth",sd="xai"===g?"xAI API Key":"kimi"===g?"Kimi API Key":"qoder"===g||"qoder-cn"===g?"PAT":"API Key",sc=e=>{if(!eZ||"auto"===eZ)return null;let t=C(g,e);return t&&t.includes(eZ)?eZ:null},sm=sl?g:sa,su=(()=>{let e=new Set,t=new Set,s=s=>{if(!s||t.has(s))return;t.add(s);let a=C(g,s);a&&a.forEach(t=>{"none"!==t&&e.add(t)})};for(let e of ss)s(e.id);for(let e of ta)s(e.id);for(let e of eA)e.providerAlias===sm&&"llm"===(e.kind||e.type||"llm")&&s(e.id);return e.size?["auto",...e]:null})(),sp=sl?E?.prefix||g:sa,sx=(()=>{let e=new Set;for(let t of ss)e.add(t.id);for(let t of ta)e.add(t.id);for(let t of eA)t.providerAlias===sm&&"llm"===(t.kind||t.type||"llm")&&e.add(t.id);for(let t of Object.values(eC))"string"==typeof t&&t.startsWith(`${sm}/`)&&e.add(t.slice(sm.length+1));return e})(),sh=(0,i.useCallback)(async()=>{try{let e=await fetch(`/api/models/disabled?providerAlias=${encodeURIComponent(sm)}`,{cache:"no-store"}),t=await e.json();e.ok&&tl(t.ids||[])}catch(e){console.log("Error fetching disabled models:",e)}},[sm]),sf=(0,i.useCallback)(async()=>{try{let e=await fetch(`/api/models/enabled?providerAlias=${encodeURIComponent(sm)}`,{cache:"no-store"}),t=await e.json();e.ok&&to(t.ids||[])}catch(e){console.log("Error fetching enabled models:",e)}},[sm]),sg=async e=>{try{(await fetch("/api/models/disabled",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerAlias:sm,ids:[e]})})).ok&&await sh()}catch(e){console.log("Error disabling model:",e)}},sy=async e=>{try{(await fetch(`/api/models/disabled?providerAlias=${encodeURIComponent(sm)}&id=${encodeURIComponent(e)}`,{method:"DELETE"})).ok&&await sh()}catch(e){console.log("Error enabling model:",e)}},sb=async e=>{e.length&&tu({title:"Disable All Models",message:`Disable all ${e.length} model(s)?`,onConfirm:async()=>{tu(null);try{(await fetch("/api/models/disabled",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerAlias:sm,ids:e})})).ok&&await sh()}catch(e){console.log("Error disabling all models:",e)}}})},sv=async e=>{e.length&&tu({title:(0,T.Tl)("Disable Failed Models"),message:`${e.length} model(s) failed testing. Disable them?`,onConfirm:async()=>{tu(null);try{(await fetch("/api/models/disabled",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerAlias:sm,ids:e})})).ok&&await sh()}catch(e){console.log("Error disabling failed models:",e)}}})},sj=async()=>{try{(await fetch(`/api/models/disabled?providerAlias=${encodeURIComponent(sm)}`,{method:"DELETE"})).ok&&await sh()}catch(e){console.log("Error enabling all models:",e)}},sw=(0,i.useCallback)(async()=>{try{let e=await fetch("/api/models/alias"),t=await e.json();e.ok&&eS(t.aliases||{})}catch(e){console.log("Error fetching aliases:",e)}},[]),sk=(0,i.useCallback)(async()=>{try{let e=await fetch("/api/models/custom",{cache:"no-store"}),t=await e.json();e.ok&&eT(t.models||[])}catch(e){console.log("Error fetching custom models:",e)}},[]);(0,i.useEffect)(()=>{"kilocode"===g&&fetch("/api/providers/kilo/free-models").then(e=>e.json()).then(e=>{e.models?.length&&ti(e.models)}).catch(()=>{})},[g]);let sN=(0,i.useCallback)(async()=>{try{let[e,t,s,a]=await Promise.all([fetch(`/api/providers?provider=${encodeURIComponent(g)}`,{cache:"no-store"}),fetch("/api/provider-nodes",{cache:"no-store"}),fetch("/api/proxy-pools?isActive=true",{cache:"no-store"}),fetch("/api/settings",{cache:"no-store"})]),i=await e.json(),r=await t.json(),l=await s.json(),n=a.ok?await a.json():{};e.ok&&v(i.connections||[]),s.ok&&_(l.proxyPools||[]);let o=(n.providerStrategies||{})[g]||{};eW(o.fallbackStrategy||null),eG("round-robin"===n.fallbackStrategy?"round-robin":"fill-first"),eV(null!=o.stickyRoundRobinLimit?String(o.stickyRoundRobinLimit):"1");let d=(n.providerThinking||{})[g]||{};eX(d.mode||"auto");let c=(n.retryDelayByProvider||{})[g];e0(null!=c&&"auto"!==c?String(c):"auto");let m=(n.rpmByProvider||{})[g];e5(null!=m?String(m):"");let u=ew[g],p=u&&n[u]||{};if(e3({enabled:!0===p.enabled,connections:p.connections||{},schedules:p.schedules||{}}),tq(!0===n.codexFastMode),t.ok){let e=(r.nodes||[]).find(e=>e.id===g)||null;if(!e&&sl)for(let t=0;t<3;t+=1){await new Promise(e=>setTimeout(e,150));let t=await fetch("/api/provider-nodes",{cache:"no-store"});if(t.ok&&(e=((await t.json()).nodes||[]).find(e=>e.id===g)||null))break}R(e)}}catch(e){console.log("Error fetching connections:",e)}finally{I(!1)}},[g,sl]),sC=async e=>{try{let t=await fetch(`/api/provider-nodes/${g}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),s=await t.json();t.ok&&(R(s.node),await sN(),eu(!1))}catch(e){console.log("Error updating provider node:",e)}},sS=async(e,t)=>{try{let s=await fetch("/api/settings",{cache:"no-store"}),a=(s.ok?await s.json():{}).providerStrategies||{},i={};e&&(i.fallbackStrategy=e),"round-robin"===e&&""!==t&&(i.stickyRoundRobinLimit=Number(t)||3);let r={...a};0===Object.keys(i).length?delete r[g]:r[g]=i,await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerStrategies:r})})}catch(e){console.log("Error saving provider strategy:",e)}},sA=async e=>{try{let t=await fetch("/api/settings",{cache:"no-store"}),s={...(t.ok?await t.json():{}).providerThinking||{}};e&&"auto"!==e?s[g]={mode:e}:delete s[g],await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerThinking:s})})}catch(e){console.log("Error saving thinking config:",e)}},sT=async e=>{try{let t=await fetch("/api/settings",{cache:"no-store"}),s={...(t.ok?await t.json():{}).retryDelayByProvider||{}};e&&"auto"!==e?s[g]=Number(e):delete s[g],await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({retryDelayByProvider:s})})}catch(e){console.log("Error saving retry delay:",e)}},s$=async e=>{try{let t=await fetch("/api/settings",{cache:"no-store"}),s={...(t.ok?await t.json():{}).rpmByProvider||{}},a=String(e??"").trim();""===a?delete s[g]:s[g]=Math.max(0,Number(a)||0),await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({rpmByProvider:s})})}catch(e){console.log("Error saving RPM limit:",e)}},sO=async e=>{let t=ew[g];if(t){e3(e);try{await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({[t]:e})})}catch(e){console.log("Error saving auto-ping config:",e)}}},sP=async e=>{tq(e),tz(!0),tF(null);try{let t=await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({codexFastMode:e})});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error||"Failed to update fast mode setting")}}catch(t){console.log("Error saving codex fast mode setting:",t),tq(!e),tF(t.message||"Failed to update fast mode setting")}finally{tz(!1)}};(0,i.useEffect)(()=>{sN(),sw(),sk(),sh(),sf()},[sN,sw,sk,sh,sf]),(0,i.useEffect)(()=>{if("cursor"!==g&&"zed"!==g)return void te([]);let e=b.find(e=>!1!==e.isActive);if(!e?.id){te([]),"zed"===g&&ts(null);return}let t=!1;return"zed"===g&&ts(null),fetch(`/api/providers/${e.id}/models`,{cache:"no-store"}).then(async e=>({ok:e.ok,data:await e.json().catch(()=>null)})).then(({ok:e,data:s})=>{if(!t){if(e&&Array.isArray(s?.models)&&s.models.length>0){te(s.models),"zed"===g&&s?.warning&&ts(s.warning);return}"zed"===g&&(te([]),ts(s?.warning||s?.error||"Zed returned no live models."))}}).catch(()=>{t||"zed"!==g||(te([]),ts("Failed to reach the Zed model catalog."))}),()=>{t=!0}},[g,b]),(0,i.useEffect)(()=>{let e=(m.zN[g]||m.fg[g]||m.IS[g]||m.nJ[g])?.modelsFetcher;e&&O(e,g).then(e9)},[g]);let sI=b.find(e=>!1!==e.isActive)?.id||null,sE=tR===sI&&null!==sI;(0,i.useEffect)(()=>{if(!sI)return;let e=!1;return fetch(`/api/providers/${sI}/models?check=1`).then(e=>e.json()).then(t=>{e||tM(!0===t.supported?sI:null)}).catch(()=>{}),()=>{e=!0}},[sI]);let sR=async(e,t,s=sa)=>{let a=`${s}/${e}`;try{let e=await fetch("/api/models/alias",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:a,alias:t})});if(e.ok)await sw();else{let t=await e.json();alert(t.error||"Failed to set alias")}}catch(e){console.log("Error setting alias:",e)}},sM=async e=>{try{(await fetch(`/api/models/alias?alias=${encodeURIComponent(e)}`,{method:"DELETE"})).ok&&await sw()}catch(e){console.log("Error deleting alias:",e)}},sD=async(e,t="llm",s=sm,a,i)=>{try{let r=await fetch("/api/models/custom",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerAlias:s,id:e,type:t,...a?{caps:a}:{},...i?{transport:i}:{}})}),l=await r.json().catch(()=>({}));r.ok?(!1===l.added&&alert("Model already exists (duplicate). Check built-in or custom list."),await sk(),window.dispatchEvent(new CustomEvent("customModelChanged"))):alert(l.error||"Failed to add custom model")}catch(e){console.log("Error adding custom model:",e),alert(e.message||"Failed to add custom model")}},sq=async(e,t="llm",s=sm)=>{try{let a=new URLSearchParams({providerAlias:s,id:e,type:t});(await fetch(`/api/models/custom?${a}`,{method:"DELETE"})).ok&&(await sk(),window.dispatchEvent(new CustomEvent("customModelChanged")))}catch(e){console.log("Error deleting custom model:",e)}},s_=async()=>{if(tS)return;let e=b.find(e=>!1!==e.isActive);if(!e)return void alert((0,T.Tl)("Please add an active Qoder connection first"));tA(!0);try{let t=await fetch(`/api/providers/${e.id}/models`),s=await t.json();if(!t.ok)return void alert(s.error||(0,T.Tl)("Failed to fetch models"));let a=s.models||[];if(0===a.length)return void alert((0,T.Tl)("No models returned"));let i=0;for(let e of a){let t=e.id||e.name;if(!t)continue;let s=t.replace(/^(qoder-cn|qoder)\//,"");eA.some(e=>e.providerAlias===sm&&e.id===s&&"llm"===(e.kind||e.type||"llm"))||Object.values(eC).includes(`${sm}/${s}`)||(await sD(s,"llm",sm),i+=1)}0===i?alert((0,T.Tl)("All models already exist, no new models added")):alert((0,T.Tl)("Successfully added")+` ${i} `+(0,T.Tl)("models"))}catch(e){console.log("Error importing Qoder models:",e),alert((0,T.Tl)("Error fetching models")+": "+e.message)}finally{tA(!1)}},sz=async()=>{if(tT)return;let e=b.find(e=>!1!==e.isActive);if(!e)return void alert((0,T.Tl)("Please add an active Cline connection first"));t$(!0);try{let t=await fetch(`/api/providers/${e.id}/models`),s=await t.json();if(!t.ok)return void alert(s.error||(0,T.Tl)("Failed to fetch models"));let a=s.models||[];if(0===a.length)return void alert((0,T.Tl)("No models returned"));let i=0;for(let e of a){let t=e.id||e.name;t&&(eA.some(e=>e.providerAlias===sm&&e.id===t&&"llm"===(e.kind||e.type||"llm"))||Object.values(eC).includes(`${sm}/${t}`)||(await sD(t,"llm",sm),i+=1))}0===i?alert((0,T.Tl)("All models already exist, no new models added")):alert((0,T.Tl)("Successfully added")+` ${i} `+(0,T.Tl)("models"))}catch(e){console.log("Error importing Cline models:",e),alert((0,T.Tl)("Error fetching models")+": "+e.message)}finally{t$(!1)}},sU=async()=>{if(th||0===b.length)return;let e=Object.fromEntries(b.map(e=>[e.id,{state:"queued",error:null}]));tC.current=!1,tf(!0),ty(!1),tv(null),tw(e),tN({total:b.length,completed:0,passed:0,failed:0,stopped:!1});let t=0,s=0;try{for(let e=0;e<b.length;e+=1){if(tC.current){tN({total:b.length,completed:e,passed:t,failed:s,stopped:!0});break}let a=b[e];tv(a.id),tw(e=>({...e,[a.id]:{state:"testing",error:null}}));try{let e=await fetch(`/api/providers/${a.id}/test`,{method:"POST"}),i=await e.json(),r=!!i.valid;r?t+=1:s+=1,tw(e=>({...e,[a.id]:{state:r?"success":"failed",error:r?null:i.error||null}}))}catch(e){s+=1,tw(t=>({...t,[a.id]:{state:"failed",error:e.message||"Test failed"}}))}tN({total:b.length,completed:e+1,passed:t,failed:s,stopped:!1}),e<b.length-1&&await eN(1e3)}}finally{tv(null),tf(!1),ty(!1),tC.current=!1}},sF=async()=>{if(tL)return;if(!b.some(e=>!1!==e.isActive)&&!se)return void alert((0,T.Tl)("No active connection available for testing"));let e=[...ss,...ta.filter(e=>!ss.some(t=>t.id===e.id))].filter(e=>{let t=(0,u.CP)(e);return!t||"llm"===t}),t=new Set(tr),s=e.filter(e=>!t.has(e.id));if(0===s.length)return void alert((0,T.Tl)("No enabled models to test"));tX.current=!1,tJ(!0),tH(!1),tB(null),tQ({}),tZ({total:s.length,completed:0,passed:0,failed:0,stopped:!1});let a=0,i=0,r=[];try{for(let e=0;e<s.length;e+=1){if(tX.current){tZ({total:s.length,completed:e,passed:a,failed:i,stopped:!0});break}let t=s[e];tB(t.id),tQ(e=>({...e,[t.id]:{state:"testing",error:null}}));try{let e=await fetch("/api/models/test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:`${sm}/${t.id}`})}),s=await e.json(),l=e.ok&&!0===s.ok;l?a+=1:(i+=1,r.push(t.id)),tQ(e=>({...e,[t.id]:{state:l?"passed":"failed",error:l?null:s.error||"Model not reachable"}})),eI(e=>({...e,[t.id]:l?"ok":"error"})),eR(l?"":s.error||"Model not reachable")}catch(e){i+=1,r.push(t.id),tQ(s=>({...s,[t.id]:{state:"failed",error:e.message||"Test failed"}})),eI(e=>({...e,[t.id]:"error"})),eR(e.message||"Network error")}tZ({total:s.length,completed:e+1,passed:a,failed:i,stopped:!1}),e<s.length-1&&await eN(1e3)}}finally{let e=tX.current;tB(null),tJ(!1),tH(!1),tX.current=!1,r.length>0?tu({title:(0,T.Tl)("Disable Failed Models"),message:`${r.length} model(s) failed testing. Disable them?`,onConfirm:async()=>{tu(null);try{(await fetch("/api/models/disabled",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerAlias:sm,ids:r})})).ok&&await sh()}catch(e){console.log("Error disabling failed models:",e)}}}):e||alert((0,T.Tl)("All models passed testing!"))}},sL=async e=>{tu({title:"Delete Connection",message:"Delete this connection?",onConfirm:async()=>{tu(null);try{(await fetch(`/api/providers/${e}`,{method:"DELETE"})).ok&&v(t=>t.filter(t=>t.id!==e))}catch(e){console.log("Error deleting connection:",e)}}})},sJ=()=>{sN(),L(!1)},sK=async e=>{Z("");try{let t=await fetch("/api/providers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:g,...e})}),s=null;try{s=await t.json()}catch{s=null}if(t.ok)return await sN(),!0;Z(s?.error||"Failed to save connection")}catch(e){console.log("Error saving connection:",e),Z("Failed to save connection")}return!1},sH=async e=>{try{(await fetch(`/api/providers/${ef.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})).ok&&(await sN(),eo(!1))}catch(e){console.log("Error updating connection:",e)}},sW=async(e,t)=>{try{(await fetch(`/api/providers/${e}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({isActive:t})})).ok&&v(s=>s.map(s=>s.id===e?{...s,isActive:t}:s))}catch(e){console.log("Error updating connection status:",e)}},sB=async(e,t)=>{let s=await fetch(`/api/providers/${e}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerSpecificData:{fastMode:t}})}),a=await s.json();if(!s.ok)throw Error(a.error||"Failed to save fast mode");v(s=>s.map(s=>s.id===e?{...s,providerSpecificData:{...s.providerSpecificData,fastMode:t}}:s))},sG=async(e,t)=>{let s=[...b];[s[e],s[t]]=[s[t],s[e]],v(s);try{await Promise.all([fetch(`/api/providers/${s[e].id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({priority:e})}),fetch(`/api/providers/${s[t].id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({priority:t})})])}catch(e){console.log("Error swapping priority:",e),await sN()}},sQ=b.filter(e=>ez.includes(e.id));(0,i.useEffect)(()=>{eU(e=>e.filter(e=>b.some(t=>t.id===e)))},[b]),(()=>{if(0===sQ.length)return;let e=new Set(sQ.map(e=>e.providerSpecificData?.proxyPoolId||"__none__"));if(1===e.size){let t=[...e][0];if("__none__"===t)return;let s=M.find(e=>e.id===t);return s?.name}})();let sV=()=>{eJ||eh(!1)},sZ=async e=>{eK(!0);try{let t=0;for(let{connectionId:s,proxyPoolId:a}of e)try{(await fetch(`/api/providers/${s}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({proxyPoolId:a})})).ok||(t+=1)}catch(e){console.log("Error applying proxy for",s,e),t+=1}t>0&&alert(`Updated with ${t} failed request(s).`),await sN(),eh(!1)}finally{eK(!1)}},sX=e=>sZ(b.map(t=>({connectionId:t.id,proxyPoolId:e}))),{currentPage:sY,items:s0,start:s1}=function(e=[],t=1,s=10){let a=Array.isArray(e)?e:[],i=Number.isFinite(s)&&s>=1?Math.floor(s):10,r=a.length,l=Math.max(1,Math.ceil(r/i)),n=Math.floor(Number(t)),o=Math.min(Number.isFinite(n)&&n>0?n:1,l),d=(o-1)*i,c=a.slice(d,d+i);return{currentPage:o,totalPages:l,totalItems:r,start:d,items:c,pageSize:i}}(b,j,k),s5=new Set(s0.map(e=>e.id)),s2=s0.length>0&&s0.every(e=>ez.includes(e.id)),s3=(0,a.jsxs)("div",{className:"flex min-w-0 flex-col divide-y divide-black/[0.03] dark:divide-white/[0.03]",children:[s0.map((e,t)=>{let s,i=s1+t;return(0,a.jsxs)("div",{className:"flex min-w-0 items-stretch",children:[(0,a.jsx)("div",{className:"flex shrink-0 items-center pl-1 sm:pl-2",children:(0,a.jsx)("input",{type:"checkbox",checked:(s=e.id,ez.includes(s)),onChange:()=>{var t;return t=e.id,void eU(e=>e.includes(t)?e.filter(e=>e!==t):[...e,t])},className:"h-4 w-4 rounded border-gray-300 text-primary focus:ring-primary"})}),(0,a.jsx)("div",{className:"flex-1 min-w-0",children:(0,a.jsx)(Q,{connection:e,proxyPools:M,isOAuth:t9,isFirst:0===i,isLast:i===b.length-1,onMoveUp:()=>sG(i,i-1),onMoveDown:()=>sG(i,i+1),onToggleActive:t=>sW(e.id,t),fastMode:t6?.fastMode?{on:e.providerSpecificData?.fastMode===!0,onToggle:t=>sB(e.id,t)}:null,autoPing:ew[g]&&"oauth"===e.authType?{isActive:!0===e2.connections[e.id]||e2.schedules?.[e.id]?.enabled===!0,reactiveOn:!0===e2.connections[e.id],provider:g,scheduleOn:e2.schedules?.[e.id]?.enabled===!0,scheduleSummary:(0,ev.JW)(e2.schedules?.[e.id]).join(" / "),onConfigure:()=>e6(e)}:null,onUpdateProxy:async t=>{try{(await fetch(`/api/providers/${e.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({proxyPoolId:t||null})})).ok&&v(s=>s.map(s=>s.id===e.id?{...s,providerSpecificData:{...s.providerSpecificData,proxyPoolId:t||null}}:s))}catch(e){console.log("Error updating proxy:",e)}},onEdit:()=>{eg(e),eo(!0)},onReconnect:()=>{"iflow"===g?W(!0):L(!0)},onDelete:()=>sL(e.id),oneByOneStatus:tj[e.id]||null})})]},e.id)}),b.length>10&&(0,a.jsx)(c.dK,{currentPage:sY,pageSize:k,totalItems:b.length,onPageChange:w,onPageSizeChange:e=>{N(e),w(1)},allowCustomPageSize:!0,maxPageSize:200})]}),s4=M.filter(e=>!0===e.isActive),s6=(0,a.jsx)(c.aF,{isOpen:ep,onClose:sV,title:`Apply Proxy (${b.length} connections)`,children:(0,a.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,a.jsxs)("div",{className:"flex flex-col",children:[(0,a.jsxs)("button",{onClick:()=>{let e=M.filter(e=>!0===e.isActive);return 0===e.length?void alert("No active proxy pools available."):sZ(b.map((t,s)=>({connectionId:t.id,proxyPoolId:e[s%e.length].id})))},disabled:eJ||0===s4.length,className:"flex items-center gap-2 rounded-lg px-3 py-2 text-left transition-colors hover:bg-black/[0.04] dark:hover:bg-white/[0.04] disabled:cursor-not-allowed disabled:opacity-50",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[18px]",children:"sync_alt"}),(0,a.jsx)("span",{className:"text-sm text-text-main",children:"One-to-one (rotate)"})]}),(0,a.jsxs)("button",{onClick:()=>sX(null),disabled:eJ,className:"flex items-center gap-2 rounded-lg px-3 py-2 text-left transition-colors hover:bg-black/[0.04] dark:hover:bg-white/[0.04] disabled:cursor-not-allowed disabled:opacity-50",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[18px]",children:"link_off"}),(0,a.jsx)("span",{className:"text-sm text-text-main",children:"None (unbind all)"})]}),M.map(e=>(0,a.jsxs)("button",{onClick:()=>sX(e.id),disabled:eJ||!0!==e.isActive,className:"flex items-center gap-2 rounded-lg px-3 py-2 text-left transition-colors hover:bg-black/[0.04] dark:hover:bg-white/[0.04] disabled:cursor-not-allowed disabled:opacity-50",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[18px]",children:"lan"}),(0,a.jsx)("span",{className:"truncate text-sm text-text-main",children:e.name}),!0!==e.isActive&&(0,a.jsx)("span",{className:"text-[10px] text-text-muted",children:"(inactive)"})]},e.id))]}),eJ&&(0,a.jsx)("p",{className:"text-xs text-text-muted",children:"Applying..."}),(0,a.jsx)(c.$n,{onClick:sV,variant:"ghost",fullWidth:!0,disabled:eJ,children:"Cancel"})]})}),s8=async e=>{if(!eM.has(e)){eD(t=>new Set(t).add(e));try{let t=await fetch("/api/models/test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:`${sm}/${e}`})}),s=await t.json();eI(t=>({...t,[e]:s.ok?"ok":"error"})),eR(s.ok?"":s.error||"Model not reachable")}catch{eI(t=>({...t,[e]:"error"})),eR("Network error")}finally{eD(t=>{let s=new Set(t);return s.delete(e),s})}}};if($)return(0,a.jsxs)("div",{className:"flex flex-col gap-8",children:[(0,a.jsx)(c.Qv,{}),(0,a.jsx)(c.Qv,{})]});if(!t6)return(0,a.jsxs)("div",{className:"text-center py-20",children:[(0,a.jsx)("p",{className:"text-text-muted",children:"Provider not found"}),(0,a.jsx)(n(),{href:"/dashboard/providers",className:"text-primary mt-4 inline-block",children:"Back to Providers"})]});let s9=()=>si&&t6.apiType?"responses"===t6.apiType?"/providers/oai-r.png":"/providers/oai-cc.png":sr?"/providers/anthropic-m.png":(0,d.HY)(t6.id);return(0,a.jsxs)("div",{className:"flex min-w-0 flex-col gap-6 px-1 sm:gap-8 sm:px-0",children:[(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsxs)(n(),{href:"/dashboard/providers",className:"inline-flex items-center gap-1 text-sm text-text-muted hover:text-primary transition-colors mb-4",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-lg",children:"arrow_back"}),"Back to Providers"]}),(0,a.jsxs)("div",{className:"flex min-w-0 items-center gap-3 sm:gap-4",children:[(0,a.jsx)("div",{className:"flex size-12 shrink-0 items-center justify-center rounded-lg",style:{backgroundColor:`${t6.color}15`},children:e$||!s9()?(0,a.jsx)("span",{className:"text-sm font-bold",style:{color:t6.color},children:t6.textIcon||t6.id.slice(0,2).toUpperCase()}):(0,a.jsx)(o.default,{src:s9(),alt:t6.name,width:48,height:48,className:"max-h-12 max-w-12 rounded-lg object-contain",sizes:"48px",onError:()=>{(0,d.Kw)(t6.id),eO(!0)},loading:"lazy",decoding:"async"})}),(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsxs)("div",{className:"flex items-center gap-3 flex-wrap",children:[(0,a.jsx)("h1",{className:"truncate text-2xl font-semibold tracking-tight sm:text-3xl",children:t6.name}),(t6.notice?.apiKeyUrl||t6.notice?.signupUrl||t6.website)&&(0,a.jsxs)("a",{href:t6.notice?.apiKeyUrl||t6.notice?.signupUrl||t6.website,target:"_blank",rel:"noopener noreferrer",className:"text-xs text-primary hover:underline inline-flex items-center gap-1",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:"open_in_new"}),t6.notice?.apiKeyUrl?"Get API Key":"Sign up / Learn more"]})]}),(0,a.jsxs)("p",{className:"text-text-muted",children:[b.length," connection",1===b.length?"":"s"]})]}),(0,a.jsxs)("div",{className:"ml-auto flex shrink-0 items-center gap-2",children:[(0,a.jsx)("span",{className:"hidden text-xs text-text-muted sm:inline",children:"RPM / account"}),(0,a.jsx)("input",{type:"number",min:"0",value:e1,placeholder:String(m.W[g]||0),onChange:e=>e5(e.target.value),onBlur:e=>s$(e.target.value),title:"Max requests per minute per account. Accounts over the cap are skipped before a request is sent, so the provider never sees a 429. Blank = provider default, 0 = unlimited.",className:"w-16 rounded-md border border-border bg-background px-2 py-1 text-xs focus:border-primary focus:outline-none"}),(0,a.jsx)("span",{className:"hidden text-xs text-text-muted sm:inline",children:"Retry delay"}),(0,a.jsx)("select",{value:eY,onChange:e=>{var t;e0(t=e.target.value),sT(t)},title:"Cooldown after a rate-limit/error when the provider reports no reset time of its own. Auto = honor the provider's reported delay, else built-in backoff.",className:"rounded-md border border-border bg-background px-2 py-1 text-xs focus:border-primary focus:outline-none",children:ek.map(e=>(0,a.jsx)("option",{value:e.value,children:e.label},e.value))})]})]})]}),t6.deprecated&&(0,a.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 rounded-lg bg-yellow-500/10 border border-yellow-500/30",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[16px] text-yellow-500 mt-0.5 shrink-0",children:"warning"}),(0,a.jsx)("p",{className:"text-xs text-red-600 dark:text-yellow-400 leading-relaxed",children:t6.deprecationNotice})]}),t6.notice?.text&&!t6.deprecated&&(0,a.jsxs)("div",{className:"flex flex-col gap-2 rounded-lg border border-blue-500/30 bg-blue-500/10 px-3 py-2 sm:flex-row sm:items-center",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[16px] text-blue-500 shrink-0",children:"info"}),(0,a.jsx)("p",{className:"min-w-0 flex-1 text-xs leading-relaxed text-blue-600 dark:text-blue-400",children:t6.notice.text}),t6.notice.apiKeyUrl&&(0,a.jsx)("a",{href:t6.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 →"})]}),sl&&E&&(0,a.jsx)(c.Zp,{children:(0,a.jsxs)("div",{className:"mb-4 flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsx)("h2",{className:"text-lg font-semibold",children:sr?"Anthropic Compatible Details":"OpenAI Compatible Details"}),(0,a.jsxs)("p",{className:"break-all text-sm text-text-muted",children:[sr?"Messages API":"responses"===E.apiType?"Responses API":"Chat Completions"," \xb7 ",(E.baseUrl||"").replace(/\/$/,""),"/",sr?"messages":"responses"===E.apiType?"responses":"chat/completions"]})]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-2 sm:flex sm:items-center",children:[(0,a.jsx)(c.$n,{size:"sm",icon:"add",onClick:()=>{Z(""),G(!0)},className:"w-full sm:w-auto",children:"Add API Key"}),(0,a.jsx)(c.$n,{size:"sm",icon:"download",variant:"secondary",onClick:()=>es(!0),className:"w-full sm:w-auto",children:"Export Keys"}),(0,a.jsx)(c.$n,{size:"sm",variant:"secondary",icon:"edit",onClick:()=>eu(!0),className:"w-full sm:w-auto",children:"Edit"}),(0,a.jsx)(c.$n,{size:"sm",variant:"secondary",icon:"delete",onClick:async()=>{tu({title:"Delete Compatible Node",message:`Delete this ${sr?"Anthropic":"OpenAI"} Compatible node?`,onConfirm:async()=>{tu(null);try{(await fetch(`/api/provider-nodes/${g}`,{method:"DELETE"})).ok&&f.push("/dashboard/providers")}catch(e){console.log("Error deleting provider node:",e)}}})},className:"w-full sm:w-auto",children:"Delete"})]})]})}),se?(0,a.jsx)(c.gw,{providerId:g}):(0,a.jsxs)(c.Zp,{children:[(0,a.jsxs)("div",{className:"mb-4 flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[(0,a.jsx)("h2",{className:"text-lg font-semibold",children:"Connections"}),(0,a.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:gap-4",children:[b.length>0&&M.length>0&&(0,a.jsx)(c.$n,{size:"sm",variant:"secondary",icon:"lan",onClick:()=>eh(!0),children:"Apply Proxy"}),b.length>0&&(0,a.jsxs)(a.Fragment,{children:[ez.length>0&&(0,a.jsxs)(c.$n,{size:"sm",variant:"danger",icon:"delete",onClick:()=>{let e=ez.length;0!==e&&tu({title:`Delete ${e} Connection${e>1?"s":""}`,message:`Delete ${e} connection${e>1?"s":""}? This cannot be undone.`,onConfirm:async()=>{tu(null);let e=0,t=[...ez];for(let s of t)try{(await fetch(`/api/providers/${s}`,{method:"DELETE"})).ok||(e+=1)}catch(t){console.log("Error deleting connection:",t),e+=1}v(e=>e.filter(e=>!t.includes(e.id))),eU([]),e>0&&alert(`Deleted ${t.length-e} connection(s), ${e} failed.`)}})},children:["Delete Selected (",ez.length,")"]}),(0,a.jsx)(c.$n,{size:"sm",variant:"secondary",icon:"sync",onClick:sU,disabled:th,children:th?"Testing Connection One-by-One...":"Test Connection One-by-One"}),th&&(0,a.jsx)(c.$n,{size:"sm",variant:"ghost",icon:"stop",onClick:()=>{th&&(tC.current=!0,ty(!0))},disabled:tg,children:tg?"Stopping...":"Stop"})]}),(0,a.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,a.jsx)("span",{className:"text-xs text-text-muted font-medium",children:"Strategy"}),(0,a.jsx)("div",{className:"w-[230px]",children:(0,a.jsx)(c.l6,{options:ej,value:eH||eB,onChange:e=>{var t;let s,a,i;return s=(t=e.target.value)===eB?null:t,i=(a="round-robin"===t)?eQ||"1":eQ,void(a&&!eQ&&eV("1"),eW(s),sS(s,i))},selectClassName:"py-1.5 text-xs"})}),"round-robin"===(eH||eB)&&(0,a.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,a.jsx)("span",{className:"text-xs text-text-muted",children:"Sticky:"}),(0,a.jsx)("input",{type:"number",min:1,value:eQ,onChange:e=>{var t;eV(t=e.target.value),sS("round-robin",t)},placeholder:"1",className:"w-14 px-2 py-1 text-xs border border-border rounded-md bg-background focus:outline-none focus:border-primary"})]})]}),"codex"===g&&(0,a.jsx)(c.lM,{checked:tD,onChange:sP,disabled:t_,label:"Fast inference",description:"Use the priority tier for Codex models (all accounts). Per-account override lives on each connection row and quota card."}),"codex"===g&&tU&&(0,a.jsx)("span",{className:"text-xs text-red-500",role:"alert",children:tU})]})]}),(0,a.jsxs)("p",{className:"mb-4 -mt-1 text-xs text-text-muted",children:["Tip: pin requests to a specific account by sending the ",(0,a.jsx)("code",{children:"x-connection-id"})," request header with a connection ID — click the ID chip on a connection to copy it. When the pinned account is unavailable, EzRouter falls back to the other accounts automatically."]}),0===b.length?(0,a.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[(0,a.jsx)("div",{className:"inline-flex items-center justify-center w-9 h-9 rounded-full bg-primary/10 text-primary shrink-0",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:t9?"lock":"key"})}),(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsx)("p",{className:"text-sm text-text-muted",children:"No connections yet"}),sn&&(0,a.jsxs)("p",{className:"text-xs text-text-muted",children:["Choose ",so," or ",sd,"."]})]})]}),(0,a.jsx)("div",{className:"flex gap-2",children:sn?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(c.$n,{size:"sm",icon:"lock",variant:"secondary",onClick:t2,children:so}),(0,a.jsx)(c.$n,{size:"sm",icon:"key",onClick:t3,children:sd})]}):(0,a.jsxs)(a.Fragment,{children:[!sl&&"iflow"===g&&(0,a.jsx)(c.$n,{size:"sm",icon:"cookie",variant:"secondary",onClick:()=>W(!0),children:"Cookie"}),"codex"===g&&(0,a.jsx)(c.$n,{size:"sm",icon:"playlist_add",variant:"secondary",onClick:()=>ee(!0),children:(0,T.Tl)("Bulk Add")}),"grok-cli"===g&&(0,a.jsx)(c.$n,{size:"sm",icon:"playlist_add",variant:"secondary",onClick:()=>er(!0),children:(0,T.Tl)("Bulk Add")}),(0,a.jsx)(c.$n,{size:"sm",icon:"add",onClick:t4,children:sl?"Add API Key":"iflow"===g?"OAuth":"Add Connection"})]})})]}):(0,a.jsxs)(a.Fragment,{children:[tk&&(0,a.jsx)("div",{className:"mb-4 rounded-lg border border-black/10 bg-black/[0.02] px-3 py-2 text-xs text-text-muted dark:border-white/10 dark:bg-white/[0.03]",children:(0,a.jsxs)("div",{className:"flex flex-wrap items-center gap-3",children:[(0,a.jsxs)("span",{children:["Total: ",tk.total]}),(0,a.jsxs)("span",{children:["Completed: ",tk.completed]}),(0,a.jsxs)("span",{children:["Passed: ",tk.passed]}),(0,a.jsxs)("span",{children:["Failed: ",tk.failed]}),tk.stopped&&(0,a.jsx)("span",{className:"text-amber-600 dark:text-amber-400",children:"Stopped"}),th&&tb&&(0,a.jsxs)("span",{children:["Running: ",b.find(e=>e.id===tb)?.name||tb]})]})}),b.length>0&&(0,a.jsx)("div",{className:"mb-3 flex items-center gap-2 border-b border-black/[0.03] pb-2 dark:border-white/[0.03]",children:(0,a.jsxs)("label",{className:"flex cursor-pointer items-center gap-1.5 text-xs text-text-muted hover:text-primary",children:[(0,a.jsx)("input",{type:"checkbox",checked:s2,onChange:()=>{s2?eU(e=>e.filter(e=>!s5.has(e))):eU(e=>{let t=new Set(e);for(let e of s5)t.add(e);return[...t]})},className:"h-3.5 w-3.5 rounded border-gray-300 text-primary focus:ring-primary"}),"Select All"]})}),s3,!sl&&(0,a.jsxs)("div",{className:"mt-4 grid grid-cols-1 gap-2 sm:flex",children:["iflow"===g&&(0,a.jsx)(c.$n,{size:"sm",icon:"cookie",variant:"secondary",onClick:()=>W(!0),title:"Add connection using browser cookie",className:"w-full sm:w-auto",children:"Cookie"}),"codex"===g&&(0,a.jsx)(c.$n,{size:"sm",icon:"playlist_add",variant:"secondary",onClick:()=>ee(!0),title:(0,T.Tl)("Bulk import codex accounts from JSON"),className:"w-full sm:w-auto",children:(0,T.Tl)("Bulk Add")}),"grok-cli"===g&&(0,a.jsx)(c.$n,{size:"sm",icon:"playlist_add",variant:"secondary",onClick:()=>er(!0),title:(0,T.Tl)("Bulk import Grok CLI accounts from JSON"),className:"w-full sm:w-auto",children:(0,T.Tl)("Bulk Add")}),b.length>0&&(0,a.jsx)(c.$n,{size:"sm",icon:"download",variant:"secondary",onClick:()=>es(!0),className:"w-full sm:w-auto",children:"Export Keys"}),sn?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(c.$n,{size:"sm",icon:"lock",variant:"secondary",onClick:t2,className:"w-full sm:w-auto",children:so}),(0,a.jsx)(c.$n,{size:"sm",icon:"key",onClick:t3,className:"w-full sm:w-auto",children:sd})]}):(0,a.jsx)(c.$n,{size:"sm",icon:"add",onClick:t4,className:"w-full sm:w-auto",children:"Add"})]})]})]}),(0,a.jsx)(ey,{providerId:g}),(0,a.jsxs)(c.Zp,{children:[(0,a.jsxs)("div",{className:"mb-4 flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between",children:[(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[(0,a.jsx)("h2",{className:"text-lg font-semibold",children:"Available Models"}),su&&(0,a.jsx)("select",{value:eZ,onChange:e=>{var t;eX(t=e.target.value),sA(t)},title:"Appends (level) suffix to copied model names",className:"rounded-md border border-border bg-background px-2 py-1 text-xs focus:border-primary focus:outline-none",children:su.map(e=>(0,a.jsx)("option",{value:e,children:`Thinking: ${e.charAt(0).toUpperCase()+e.slice(1)}`},e))})]}),!sl&&(t=(e=[...ss,...ta.filter(e=>!ss.some(t=>t.id===e.id))].filter(e=>{let t=(0,u.CP)(e);return!t||"llm"===t}).map(e=>e.id).filter(e=>!tr.includes(e))).filter(e=>tG[e]?.state==="failed"||"error"===eP[e]),(0,a.jsxs)("div",{className:"flex gap-2",children:[tr.length>0&&(0,a.jsx)(c.$n,{size:"sm",variant:"secondary",icon:"restart_alt",onClick:sj,children:"Active All"}),t.length>0&&(0,a.jsxs)(c.$n,{size:"sm",variant:"danger",icon:"block",onClick:()=>sv(t),children:[(0,T.Tl)("Disable Failed")," (",t.length,")"]}),e.length>0&&(0,a.jsx)(c.$n,{size:"sm",variant:tL?"secondary":"primary",icon:tL?"stop":"play_circle",onClick:tL?()=>{tL&&(tX.current=!0,tH(!0))}:sF,disabled:!b.some(e=>!1!==e.isActive)&&!se,className:"flex items-center gap-1.5",children:tL?tK?(0,T.Tl)("Stopping..."):(0,T.Tl)("Testing..."):(0,T.Tl)("Test All")}),e.length>0&&(0,a.jsx)(c.$n,{size:"sm",variant:"secondary",icon:"block",onClick:()=>sb(e),children:"Disable All"})]}))]}),!!eE&&(0,a.jsxs)("div",{className:"mb-3",children:[(0,a.jsx)("p",{className:"text-xs text-red-500 break-words",children:eE}),/RegionError|hosted in China|regionNotAllowed/i.test(eE)&&(l=(s="string"==typeof eE?eE:JSON.stringify(eE)).match(/https:\/\/opencode\.ai\/workspace\/[^\s"')]+/),p=s.match(/wrk_[0-9A-Za-z]+/),x=l?l[0].endsWith("/go")?l[0]:`${l[0]}/go`:p?`https://opencode.ai/workspace/${p[0]}/go`:"https://opencode.ai",(0,a.jsx)("div",{className:"mt-1.5",children:(0,a.jsxs)("a",{href:x,target:"_blank",rel:"noreferrer",className:"inline-flex items-center gap-1 rounded-md bg-amber-500/10 px-2 py-0.5 text-xs font-medium text-amber-600 hover:bg-amber-500/20 dark:text-amber-400 transition-colors",children:[(0,a.jsx)("span",{children:"Allow China-hosted models"}),(0,a.jsx)("span",{className:"material-symbols-outlined text-[13px]",children:"open_in_new"})]})}))]}),"zed"===g&&!!tt&&(0,a.jsx)("p",{className:"text-xs text-red-500 mb-3 break-words",children:tt}),(0,a.jsxs)("div",{className:"mb-3 flex flex-wrap items-center gap-2",children:[(0,a.jsxs)("button",{onClick:()=>tc(!0),className:"flex items-center gap-1.5 rounded-lg border border-border px-3 py-1.5 text-xs text-text-main transition-colors hover:border-primary/40 hover:bg-primary/5",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:"visibility"}),"Visible models",tn.length>0?` (${tn.length})`:""]}),(0,a.jsx)("span",{className:"text-[11px] text-text-muted",children:tn.length>0?`Only these ${tn.length} models are exposed on /v1/models`:"All models are exposed on /v1/models"})]}),(()=>{let e,t,s;if(sl)return(0,a.jsx)(z,{providerStorageAlias:sm,providerDisplayAlias:sp,modelAliases:eC,customModels:eA,copied:tY,onCopy:t0,onSetAlias:sR,onDeleteAlias:sM,onAddCustomModel:e=>sD(e,"llm",sm),onDeleteCustomModel:e=>sq(e,"llm",sm),connections:b,isAnthropic:sr,onModelsChanged:sk,importSupported:sE});let i=[...ss,...ta.filter(e=>!ss.some(t=>t.id===e.id))].filter(e=>{let t=(0,u.CP)(e);return!t||"llm"===t}),r=new Set(tr),l=i.filter(e=>!r.has(e.id)),n=i.filter(e=>r.has(e.id)),o=P({customModels:eA,modelAliases:eC,providerAlias:sm,builtInModels:ss,type:"llm"});return(0,a.jsxs)("div",{className:"flex flex-wrap gap-3",children:[o.map(e=>(0,a.jsx)(D,{model:{id:e.id,name:e.name},fullModel:`${sp}/${e.id}`,alias:e.alias,copied:tY,onCopy:t0,onSetAlias:()=>{},onDeleteAlias:()=>{"custom"===e.source?sq(e.id,"llm",sm):sM(e.alias)},testStatus:eP[e.id],onTest:b.length>0||se?()=>s8(e.id):void 0,isTesting:eM.has(e.id),isCustom:!0,isFree:!1,caps:y(`${g}/${e.id}`),thinkingSuffix:sc(e.id)},`${e.source}-${e.fullModel}`)),l.map(e=>{let t=e.id.startsWith(`${sm}/`)?e.id.slice(sm.length+1):e.id,s=`${sm}/${t}`,i=`${g}/${t}`,r=Object.entries(eC).find(([,e])=>e===s||e===i)?.[0];return(0,a.jsx)(D,{model:e,fullModel:`${sp}/${t}`,alias:r,copied:tY,onCopy:t0,onSetAlias:e=>sR(t,e,sm),onDeleteAlias:()=>sM(r),testStatus:eP[t]||eP[e.id],onTest:b.length>0||se?()=>s8(t):void 0,isTesting:eM.has(t)||eM.has(e.id),isFree:e.isFree,onDisable:()=>sg(t),caps:y(`${g}/${t}`),thinkingSuffix:sc(t)},e.id)}),(0,a.jsxs)("button",{onClick:()=>e_(!0),className:"flex w-full items-center justify-center gap-1.5 rounded-lg border border-dashed border-primary/40 px-3 py-2 text-xs text-primary transition-colors hover:border-primary hover:bg-primary/5 sm:w-auto",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:"add"}),"Add Model"]}),("qoder"===g||"qoder-cn"===g)&&b.some(e=>!1!==e.isActive)&&(0,a.jsxs)("button",{onClick:s_,disabled:tS,className:"flex w-full items-center justify-center gap-1.5 rounded-lg border border-dashed border-blue-500/40 px-3 py-2 text-xs text-blue-600 dark:text-blue-400 transition-colors hover:border-blue-500 hover:bg-blue-500/5 sm:w-auto disabled:opacity-50 disabled:cursor-not-allowed",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",style:tS?{animation:"spin 1s linear infinite"}:void 0,children:tS?"progress_activity":"download"}),tS?(0,T.Tl)("Fetching..."):(0,T.Tl)("Fetch Qoder Models")]}),("cline"===g||"clinepass"===g)&&b.some(e=>!1!==e.isActive)&&(0,a.jsxs)("button",{onClick:sz,disabled:tT,className:"flex w-full items-center justify-center gap-1.5 rounded-lg border border-dashed border-blue-500/40 px-3 py-2 text-xs text-blue-600 dark:text-blue-400 transition-colors hover:border-blue-500 hover:bg-blue-500/5 sm:w-auto disabled:opacity-50 disabled:cursor-not-allowed",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",style:tT?{animation:"spin 1s linear infinite"}:void 0,children:tT?"progress_activity":"download"}),tT?(0,T.Tl)("Fetching..."):(0,T.Tl)("Import from /models")]}),sE&&sI&&!["qoder","qoder-cn","cline","clinepass"].includes(g)&&(0,a.jsxs)("button",{onClick:()=>tE(!0),className:"flex w-full items-center justify-center gap-1.5 rounded-lg border border-dashed border-blue-500/40 px-3 py-2 text-xs text-blue-600 dark:text-blue-400 transition-colors hover:border-blue-500 hover:bg-blue-500/5 sm:w-auto",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:"download"}),(0,T.Tl)("Import Models")]}),e8.length>0&&(e=new Set([...Object.values(eC),...o.map(e=>e.fullModel)]),t=new Set(ss.map(e=>e.id)),0===(s=e8.filter(s=>{let a=s.id.replace(/^nous\//,"");return!e.has(`${sm}/${a}`)&&!t.has(a)&&!t.has(s.id)})).length?null:(0,a.jsxs)("div",{className:"w-full mt-2",children:[(0,a.jsx)("p",{className:"text-xs text-text-muted mb-2",children:"nous"===g?(0,T.Tl)("Suggested models (≥200k context):"):(0,T.Tl)("Suggested free models (≥200k context):")}),(0,a.jsx)("div",{className:"flex flex-wrap gap-2",children:s.map(e=>{let t=e.id.replace(/^nous\//,"");return(0,a.jsxs)("button",{onClick:async()=>{await sD(t,"llm",sm)},className:"flex items-center gap-1 px-2.5 py-1.5 rounded-lg border border-black/10 dark:border-white/10 text-xs text-text-muted hover:text-primary hover:border-primary/40 hover:bg-primary/5 transition-colors",title:`${e.name} \xb7 ${(e.contextLength/1e3).toFixed(0)}k ctx`,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[13px]",children:"add"}),t.split("/").pop()]},e.id)})})]})),n.length>0&&(0,a.jsxs)("div",{className:"w-full mt-2",children:[(0,a.jsxs)("p",{className:"text-xs text-text-muted mb-2",children:["Disabled models (",n.length,"):"]}),(0,a.jsx)("div",{className:"flex flex-wrap gap-2",children:n.map(e=>(0,a.jsxs)("button",{onClick:()=>sy(e.id),className:"flex items-center gap-1 px-2.5 py-1.5 rounded-lg border border-dashed border-black/10 dark:border-white/10 text-xs text-text-muted hover:text-primary hover:border-primary/40 hover:bg-primary/5 transition-colors",title:"Restore model",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[13px]",children:"add"}),e.id]},e.id))})]})]})})()]}),s6,"kiro"===g?(0,a.jsx)(c.Mh,{isOpen:F,providerInfo:t6,onSuccess:sJ,onClose:()=>L(!1)}):"cursor"===g?(0,a.jsx)(c.G9,{isOpen:F,onSuccess:sJ,onClose:()=>L(!1)}):"zed"===g?(0,a.jsx)(c.TE,{isOpen:F,providerInfo:t6,onSuccess:sJ,onClose:()=>L(!1)}):"gitlab"===g?(0,a.jsx)(c.vj,{isOpen:F,providerInfo:t6,onSuccess:sJ,onClose:()=>L(!1)}):(0,a.jsx)(c.LF,{isOpen:F,provider:g,providerInfo:t6,onSuccess:sJ,onClose:()=>L(!1)}),(0,a.jsx)(c.LH,{isOpen:J,onSuccess:sJ,onClose:()=>K(!1)}),"iflow"===g&&(0,a.jsx)(c.vE,{isOpen:H,onSuccess:()=>{sN(),W(!1)},onClose:()=>W(!1)}),B&&(0,a.jsx)(ea,{isOpen:B,provider:g,providerName:t6.name,isCompatible:sl,isAnthropic:sr,authType:t6?.authType,authHint:t6?.authHint,website:t6?.website,proxyPools:M,error:V,existingNames:b.map(e=>e.name).filter(Boolean),onSave:sK,onBulkDone:sN,onClose:()=>{Z(""),G(!1)}}),(0,a.jsx)(X,{isOpen:et,providerId:g,providerName:t6.name,onClose:()=>es(!1)}),(0,a.jsx)(c.wI,{isOpen:el,connection:ef,proxyPools:M,onSave:sH,onClose:()=>eo(!1)}),sl&&(0,a.jsx)(en,{isOpen:ec,node:E,onSave:sC,onClose:()=>eu(!1),isAnthropic:sr}),!sl&&(0,a.jsx)(ed,{isOpen:eq,providerAlias:sm,providerDisplayAlias:sp,onSave:async(e,t,s)=>{await sD(e,t?.stt?"stt":"llm",sm,t,s),e_(!1)},onClose:()=>e_(!1)}),td&&(0,a.jsx)(U,{isOpen:!0,onClose:()=>tc(!1),providerId:g,providerAlias:sm,connections:b,customModels:eA,disabledModelIds:tr,onSaved:e=>{to(e),sh()}}),(0,a.jsx)(q,{isOpen:tI,onClose:()=>tE(!1),connectionId:sI,providerStorageAlias:sm,existingIds:sx,onImported:sk}),"codex"===g&&(0,a.jsx)(em,{isOpen:Y,onClose:()=>ee(!1),onSuccess:sN}),"grok-cli"===g&&(0,a.jsx)(ex,{isOpen:ei,onClose:()=>er(!1),onSuccess:sN}),e4&&(0,a.jsx)(eb.A,{isOpen:!!e4,onClose:()=>e6(null),connection:e4,reactive:!0===e2.connections[e4.id],schedule:e2.schedules?.[e4.id]||null,onSave:e=>((e,{reactive:t,schedule:s})=>{sO({...e2,connections:{...e2.connections,[e]:t},schedules:{...e2.schedules,[e]:s}})})(e4.id,e)}),(0,a.jsx)(c.uo,{isOpen:tp,onClose:()=>tx(!1),onConfirm:()=>{(window.localStorage.setItem(t1,"true"),tx(!1),t9)?t5():t3()},title:"Risk Notice",message:t6?.deprecationNotice,confirmText:"I Understand, Continue",cancelText:"Cancel",variant:"danger"}),(0,a.jsx)(c.uo,{isOpen:!!tm,onClose:()=>tu(null),onConfirm:tm?.onConfirm,title:tm?.title||"Confirm",message:tm?.message,variant:"danger"})]})}},93195:(e,t,s)=>{"use strict";function a(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone||"UTC"}catch{return"UTC"}}s.d(t,{JW:()=>o,Vm:()=>a,fB:()=>r,gy:()=>i,nz:()=>l});let i={anchor:"09:30",timezone:a(),windowHours:5,slotsPerDay:3};function r(e){let t=/^(\d{1,2}):(\d{2})$/.exec(String(e||"").trim());if(!t)return null;let s=Number(t[1]),a=Number(t[2]);return s>23||a>59?null:{hour:s,minute:a}}function l(e){return Math.max(1,Math.floor(24/e))}function n(e,t,s,a){let i="number"==typeof e?e:Number(e);return Number.isFinite(i)?Math.min(a,Math.max(s,i)):t}function o(e){let t=function(e){if(!e||!0!==e.enabled)return null;let t=r(e.anchor)||r(i.anchor),s=`${String(t.hour).padStart(2,"0")}:${String(t.minute).padStart(2,"0")}`,a=!function(e){if(!e||"string"!=typeof e)return!1;try{return new Intl.DateTimeFormat("en-US",{timeZone:e}),!0}catch{return!1}}(e.timezone)?i.timezone:e.timezone,o=n(e.windowHours,i.windowHours,.5,24),d=Math.round(n(e.slotsPerDay,i.slotsPerDay,1,l(o)));return{enabled:!0,anchor:s,timezone:a,windowHours:o,slotsPerDay:d}}(e);if(!t)return[];let{hour:s,minute:a}=r(t.anchor),o=60*s+a;return Array.from({length:t.slotsPerDay},(e,s)=>{let a=Math.round(o+s*t.windowHours*60)%1440;return`${String(Math.floor(a/60)).padStart(2,"0")}:${String(a%60).padStart(2,"0")}`})}},93725:(e,t,s)=>{"use strict";function a(e){return"number"!=typeof e||!Number.isFinite(e)||e<=0?null:e>=1e6?`${+(e/1e6).toFixed(1)}M`:e>=1e3?`${Math.round(e/1e3)}k`:String(e)}function i(e){if("number"!=typeof e||!Number.isFinite(e))return null;if(0===e)return"0";let t=Math.abs(e);return(t>=1?e.toFixed(2):t>=.01?e.toFixed(3):e.toFixed(4)).replace(/\.?0+$/,"")}function r(e,t){let s=[],r=a(e?.contextWindow);r&&s.push(`${r} ctx`);let l=a(e?.maxOutput);l&&s.push(`${l} out`);let n=i(t?.input),o=i(t?.output);return(null!==n||null!==o)&&s.push(`$${n??"?"}/$${o??"?"}`),s.length>0?s.join(" \xb7 "):null}s.d(t,{M4:()=>r})},97132:(e,t,s)=>{"use strict";s.d(t,{A:()=>m});var a=s(95155),i=s(12115),r=s(14051),l=s.n(r),n=s(35497),o=s(31474),d=s(93195);let c=[{value:"off",label:"Off",icon:"block"},{value:"reset",label:"On reset",icon:"bolt"},{value:"schedule",label:"Schedule",icon:"schedule"}];function m({isOpen:e,onClose:t,onSave:s,connection:r,reactive:l=!1,schedule:u=null}){let[p,x]=(0,i.useState)(()=>({mode:u?.enabled===!0?"schedule":!0===l?"reset":"off",anchor:u?.anchor||d.gy.anchor,timezone:(0,d.Vm)(),windowHours:String(u?.windowHours??d.gy.windowHours),slotsPerDay:String(u?.slotsPerDay??d.gy.slotsPerDay)})),h=Number(p.windowHours),f=Number(p.slotsPerDay),g=!!(0,d.fB)(p.anchor),y=Number.isFinite(h)&&h>=.5&&h<=24,b=y?(0,d.nz)(h):24,v=Number.isInteger(f)&&f>=1&&f<=b,j=g&&y&&v,w="schedule"!==p.mode||j,k=j?(0,d.JW)({enabled:!0,...p,windowHours:h,slotsPerDay:f}):[],N=k.length&&y?(()=>{let{hour:e,minute:t}=(0,d.fB)(p.anchor),s=Math.round(60*e+t+f*h*60)%1440;return`${String(Math.floor(s/60)).padStart(2,"0")}:${String(s%60).padStart(2,"0")}`})():"",C=e=>x(t=>({...t,...e}));return(0,a.jsx)(n.aF,{isOpen:e,onClose:t,title:"Auto-ping settings",size:"lg",footer:(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(n.$n,{variant:"secondary",onClick:t,children:"Cancel"}),(0,a.jsx)(n.$n,{onClick:()=>{w&&(s({reactive:"reset"===p.mode,schedule:"schedule"===p.mode?{enabled:!0,anchor:p.anchor,timezone:p.timezone,windowHours:h,slotsPerDay:f}:{enabled:!1}}),t())},disabled:!w,children:"Save"})]}),children:(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,a.jsxs)("p",{className:"text-sm text-text-muted",children:["Configure automated quota pings",r?.name?` for ${r.name}`:""," — pick one mode."]}),(0,a.jsx)("div",{className:"grid grid-cols-3 gap-1 rounded-[10px] bg-surface-2 p-1",children:c.map(e=>{let t=p.mode===e.value;return(0,a.jsxs)("button",{type:"button",onClick:()=>C({mode:e.value}),className:(0,o.cn)("flex h-9 items-center justify-center gap-1.5 rounded-[8px] px-3 text-sm font-medium transition-all",t?"bg-surface text-text-main shadow-sm":"text-text-muted hover:text-text-main"),children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[15px] leading-none",children:e.icon}),(0,a.jsx)("span",{children:e.label})]},e.value)})}),"reset"===p.mode&&(0,a.jsx)("p",{className:"text-xs text-text-muted",children:"Pings right after the 5h quota window resets, so a new window starts immediately."}),"schedule"===p.mode&&(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,a.jsx)("p",{className:"text-xs text-text-muted",children:"Pings at fixed local times so the 5h windows align with your workday."}),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-4 sm:grid-cols-3",children:[(0,a.jsx)(n.pd,{label:"Anchor time",type:"time",value:p.anchor,onChange:e=>C({anchor:e.target.value}),error:g?"":"Use HH:MM",inputClassName:"ring-1 ring-black/10 dark:ring-white/15"}),(0,a.jsx)(n.pd,{label:"Window (hours)",type:"number",min:"0.5",max:"24",step:"0.5",value:p.windowHours,onChange:e=>C({windowHours:e.target.value}),error:y?"":"0.5 – 24",inputClassName:"ring-1 ring-black/10 dark:ring-white/15"}),(0,a.jsx)(n.pd,{label:"Pings per day",type:"number",min:"1",max:String(b),step:"1",value:p.slotsPerDay,onChange:e=>C({slotsPerDay:e.target.value}),error:v?"":`1 – ${b}`,hint:v?`Max ${b}`:"",inputClassName:"ring-1 ring-black/10 dark:ring-white/15"})]}),k.length>0&&(0,a.jsxs)("div",{className:"rounded-[10px] bg-surface-2 px-3 py-2.5",children:[(0,a.jsxs)("p",{className:"text-xs font-medium uppercase tracking-wide text-text-muted",children:["Daily slots (",p.timezone,")"]}),(0,a.jsx)("p",{className:"mt-1 text-sm font-medium text-text-main",children:k.join(" → ")}),(0,a.jsxs)("p",{className:"mt-1 text-xs text-text-muted",children:["Covers ",k[0]," – ",N,", then pauses until ",k[0]," next day."]})]})]})]})})}m.propTypes={isOpen:l().bool.isRequired,onClose:l().func.isRequired,onSave:l().func.isRequired,connection:l().object,reactive:l().bool,schedule:l().object}}},e=>{e.O(0,[763,5772,8105,801,1321,5497,8441,3794,7358],()=>e(e.s=85295)),_N_E=e.O()}]);
|
|
27
|
+
]`;function ep(e){let t,s=e.trim();if(!s)return[];try{t=JSON.parse(s)}catch(e){try{let e=s;e.startsWith("[")||((e=e.replace(/\}\s*,\s*\{/g,"},{").replace(/\}\s*\{/g,"},{")).endsWith(",")&&(e=e.slice(0,-1)),e=`[${e}]`),t=JSON.parse(e)}catch{throw e}}if(Array.isArray(t))return t;if(t&&"object"==typeof t)return Array.isArray(t.accounts)?t.accounts:[t];throw Error("Input must be a JSON object or array of objects")}function ex({isOpen:e,onClose:t,onSuccess:s}){let[r,l]=(0,i.useState)(""),[n,o]=(0,i.useState)(!1),[d,m]=(0,i.useState)(""),[u,p]=(0,i.useState)(null),[x,h]=(0,i.useState)(!1),[f,g]=(0,i.useState)(null),y=(0,i.useRef)(null),b=()=>{n||(l(""),m(""),p(null),g(null),h(!1),t())},v=async e=>{if(!e||0===e.length)return;m("");let t=Array.from(e).filter(e=>e.name.endsWith(".json")||"application/json"===e.type||""===e.type);if(0===t.length)return void m((0,T.Tl)("Please select valid .json files"));try{let e=[];for(let s of t){let t=await s.text(),a=ep(t);Array.isArray(a)?e.push(...a):a&&e.push(a)}if(0===e.length)return void m((0,T.Tl)("No accounts found in selected files"));l(JSON.stringify(e,null,2)),g({filesCount:t.length,accountsCount:e.length})}catch(e){m(`${(0,T.Tl)("Error reading files")}: ${e.message}`)}},j=async()=>{let e;m(""),p(null);try{e=ep(r)}catch(e){m(`${(0,T.Tl)("Invalid JSON")}: ${e.message}`);return}if(!e||0===e.length)return void m((0,T.Tl)("No accounts found in input"));o(!0);try{let t=await fetch("/api/oauth/grok-cli/bulk-import",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({accounts:e})}),a=await t.json();if(!t.ok)return void m(a?.error||`Request failed: ${t.status}`);p(a),a.success>0&&"function"==typeof s&&s()}catch(e){m(e.message||(0,T.Tl)("Request failed"))}finally{o(!1)}},w=u?.results?.filter(e=>!e.ok)||[];return(0,a.jsx)(c.aF,{isOpen:e,title:(0,T.Tl)("Bulk Add Grok CLI Accounts"),onClose:b,children:(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,a.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[(0,a.jsx)("p",{className:"text-xs text-text-muted",children:(0,T.Tl)("Upload multiple .json files or paste JSON array / object.")}),(0,a.jsx)("input",{ref:y,type:"file",accept:".json,application/json",multiple:!0,className:"hidden",onChange:e=>{v(e.target.files),e.target&&(e.target.value="")}}),(0,a.jsx)(c.$n,{type:"button",size:"sm",variant:"secondary",icon:"upload_file",onClick:()=>y.current?.click(),disabled:n,children:(0,T.Tl)("Upload JSON Files")})]}),(0,a.jsxs)("div",{onDragOver:e=>{e.preventDefault(),h(!0)},onDragLeave:e=>{e.preventDefault(),h(!1)},onDrop:e=>{e.preventDefault(),h(!1),e.dataTransfer?.files?.length>0&&v(e.dataTransfer.files)},className:`relative rounded border transition-colors ${x?"border-primary bg-primary/10 ring-2 ring-primary/30":"border-accent/30 bg-sidebar"}`,children:[(0,a.jsx)("textarea",{className:"w-full rounded bg-transparent p-2.5 text-sm font-mono resize-y min-h-[240px] focus:outline-none focus:ring-1 focus:ring-primary",placeholder:eu,value:r,onChange:e=>{l(e.target.value),g(null)},disabled:n}),x&&(0,a.jsxs)("div",{className:"absolute inset-0 flex flex-col items-center justify-center bg-sidebar/90 rounded pointer-events-none backdrop-blur-xs",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-3xl text-primary mb-1",children:"upload_file"}),(0,a.jsx)("span",{className:"text-sm font-medium text-primary",children:(0,T.Tl)("Drop .json files here")})]})]}),f&&(0,a.jsxs)("div",{className:"flex items-center gap-1.5 text-xs text-green-400 font-medium bg-green-500/10 border border-green-500/20 px-2.5 py-1.5 rounded",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:"check_circle"}),(0,a.jsxs)("span",{children:[(0,T.Tl)("Loaded")," ",f.accountsCount," ",(0,T.Tl)("account(s) from")," ",f.filesCount," ",(0,T.Tl)("file(s)")]})]}),d&&(0,a.jsx)("p",{className:"text-xs text-red-500 break-words",children:d}),u&&u.failed>0&&(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,a.jsxs)("div",{className:"text-sm font-medium text-yellow-400",children:["✗ ",u.failed," ",(0,T.Tl)("failed")]}),w.length>0&&(0,a.jsx)("ul",{className:"rounded border border-accent/20 bg-sidebar/50 p-2 text-xs font-mono max-h-40 overflow-y-auto",children:w.map(e=>(0,a.jsxs)("li",{className:"text-red-400",children:["[",e.index,"] ",e.error]},e.index))})]}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(c.$n,{onClick:j,fullWidth:!0,disabled:n||!r.trim(),children:n?(0,T.Tl)("Importing..."):(0,T.Tl)("Import All")}),(0,a.jsx)(c.$n,{onClick:b,variant:"ghost",fullWidth:!0,disabled:n,children:(0,T.Tl)("Close")})]})]})})}var eh=s(65921);let ef=["host","content-length","content-type","connection","transfer-encoding","authorization","cookie"],eg=/^[A-Za-z0-9-]+$/;function ey({providerId:e}){let t=(0,eh.i)(),[s,r]=(0,i.useState)(!1),[l,n]=(0,i.useState)([{name:"",value:""}]),[o,d]=(0,i.useState)({}),[m,u]=(0,i.useState)(!1),[p,x]=(0,i.useState)(!1);(0,i.useEffect)(()=>{let t=!1;return fetch(`/api/providers/${e}/overrides`,{cache:"no-store"}).then(e=>e.ok?e.json():null).then(e=>{if(t||!e)return;let s=e.builtinHeaders||{},a=Object.entries({...s,...e.headers||{}}).map(([e,t])=>({name:e,value:t}));d(s),n(a.length?a:[{name:"",value:""}]),u(Object.keys(e.headers||{}).length>0)}).catch(()=>{}),()=>{t=!0}},[e]);let h=(e,t,s)=>{n(a=>a.map((a,i)=>i===e?{...a,[t]:s}:a))},f=(0,i.useCallback)(async()=>{let s={};for(let e of l.filter(e=>e.name.trim())){let a=e.name.trim();if(!eg.test(a))return void t.error(`Invalid header name: ${a}`);if(ef.includes(a.toLowerCase()))return void t.error(`Header ${a} cannot be overridden`);if(a in s)return void t.error(`Duplicate header name: ${a}`);e.value!==o[a]&&(s[a]=e.value)}x(!0);try{let a=await fetch(`/api/providers/${e}/overrides`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({headers:s})});if(!a.ok){let e=await a.json().catch(()=>({}));t.error(e.error||"Failed to save");return}u(Object.keys(s).length>0),t.success("Custom headers saved")}finally{x(!1)}},[l,o,e,t]);return 0!==Object.keys(o).length||m?(0,a.jsxs)(c.Zp,{padding:"xs",children:[(0,a.jsxs)("button",{type:"button",onClick:()=>r(e=>!e),className:"flex w-full items-center justify-between text-left",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-primary text-[20px]",children:"tune"}),(0,a.jsx)("span",{className:"text-sm font-semibold",children:"Custom Headers"}),m&&(0,a.jsx)(c.Ex,{variant:"success",size:"sm",children:"Active"})]}),(0,a.jsx)("span",{className:"material-symbols-outlined text-text-muted",children:s?"expand_less":"expand_more"})]}),s&&(0,a.jsxs)("div",{className:"mt-3 border-t border-border pt-3",children:[(0,a.jsx)("div",{className:"flex flex-col gap-2",children:l.map((e,t)=>{let s=e.name.trim()in o&&e.value!==o[e.name.trim()];return(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("input",{value:e.name,onChange:e=>h(t,"name",e.target.value),placeholder:"Header-Name",spellCheck:!1,className:"w-44 rounded-md border border-border bg-background px-2 py-1.5 text-sm focus:border-primary focus:outline-none"}),(0,a.jsx)("input",{value:e.value,onChange:e=>h(t,"value",e.target.value),placeholder:"Value",spellCheck:!1,title:s?"Overridden":e.name.trim()in o?"Registry default":"",className:`min-w-0 flex-1 rounded-md border bg-background px-2 py-1.5 text-sm focus:border-primary focus:outline-none ${s?"border-amber-400/60":"border-border"}`}),(0,a.jsx)("button",{type:"button",title:"Remove header",onClick:()=>n(e=>e.length>1?e.filter((e,s)=>s!==t):[{name:"",value:""}]),className:"shrink-0 text-text-muted hover:text-red-500",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"delete"})})]},t)})}),(0,a.jsxs)("div",{className:"mt-3 flex items-center justify-between gap-2",children:[(0,a.jsxs)("button",{type:"button",onClick:()=>n(e=>[...e,{name:"",value:""}]),className:"flex items-center gap-1 text-xs text-primary hover:underline",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"add"}),"Add header"]}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)("button",{type:"button",disabled:p,onClick:()=>{n(Object.entries(o).map(([e,t])=>({name:e,value:t})))},className:"rounded-md border border-border px-3 py-1.5 text-xs hover:bg-black/[0.03] dark:hover:bg-white/[0.03] disabled:opacity-50",children:"Reset"}),(0,a.jsx)("button",{type:"button",disabled:p,onClick:f,className:"rounded-md bg-primary px-3 py-1.5 text-xs font-medium text-white hover:opacity-90 disabled:opacity-50",children:p?"Saving...":"Save"})]})]})]})]}):null}ey.propTypes={providerId:E().string.isRequired};var eb=s(97132),ev=s(93195);let ej=[{value:"fill-first",label:"Fallback — try in order"},{value:"round-robin",label:"Round Robin — rotate"},{value:"cache-affinity",label:"Cache Affinity — prompt cache sticky"}],ew={claude:"claudeAutoPing",codex:"codexAutoPing"},ek=[{value:"auto",label:"Retry: Auto"},{value:"15",label:"Retry: 15s"},{value:"30",label:"Retry: 30s"},{value:"60",label:"Retry: 1m"},{value:"120",label:"Retry: 2m"},{value:"300",label:"Retry: 5m"},{value:"600",label:"Retry: 10m"},{value:"1800",label:"Retry: 30m"},{value:"3600",label:"Retry: 1h"}];function eN(e){return new Promise(t=>setTimeout(t,e))}function eC(){let e,t,s,l,p,x,h=(0,r.useParams)(),f=(0,r.useRouter)(),g=h.id,{getCaps:y}=(0,A.yU)(),[b,v]=(0,i.useState)([]),[j,w]=(0,i.useState)(1),[k,N]=(0,i.useState)(10),[$,I]=(0,i.useState)(!0),[E,R]=(0,i.useState)(null),[_,q]=(0,i.useState)([]),[F,L]=(0,i.useState)(!1),[J,K]=(0,i.useState)(!1),[H,W]=(0,i.useState)(!1),[B,G]=(0,i.useState)(!1),[V,Z]=(0,i.useState)(""),[Y,ee]=(0,i.useState)(!1),[et,es]=(0,i.useState)(!1),[ei,er]=(0,i.useState)(!1),[el,eo]=(0,i.useState)(!1),[ec,eu]=(0,i.useState)(!1),[ep,eh]=(0,i.useState)(!1),[ef,eg]=(0,i.useState)(null),[eC,eS]=(0,i.useState)({}),[eA,eT]=(0,i.useState)([]),[e$,eO]=(0,i.useState)(!1),[eP,eI]=(0,i.useState)({}),[eE,eR]=(0,i.useState)(""),[e_,eM]=(0,i.useState)(()=>new Set),[eD,eq]=(0,i.useState)(!1),[ez,eU]=(0,i.useState)([]),[eF,eL]=(0,i.useState)("__none__"),[eJ,eK]=(0,i.useState)(!1),[eH,eW]=(0,i.useState)(null),[eB,eG]=(0,i.useState)("fill-first"),[eQ,eV]=(0,i.useState)(""),[eZ,eX]=(0,i.useState)("auto"),[eY,e0]=(0,i.useState)("auto"),[e1,e5]=(0,i.useState)(""),[e2,e3]=(0,i.useState)({enabled:!1,connections:{},schedules:{}}),[e4,e6]=(0,i.useState)(null),[e8,e9]=(0,i.useState)([]),[e7,te]=(0,i.useState)([]),[tt,ts]=(0,i.useState)(null),[ta,ti]=(0,i.useState)([]),[tr,tl]=(0,i.useState)([]),[tn,to]=(0,i.useState)([]),[td,tc]=(0,i.useState)(!1),[tm,tu]=(0,i.useState)(null),[tp,tx]=(0,i.useState)(!1),[th,tf]=(0,i.useState)(!1),[tg,ty]=(0,i.useState)(!1),[tb,tv]=(0,i.useState)(null),[tj,tw]=(0,i.useState)({}),[tk,tN]=(0,i.useState)(null),tC=(0,i.useRef)(!1),[tS,tA]=(0,i.useState)(!1),[tT,t$]=(0,i.useState)(!1),[tO,tP]=(0,i.useState)(!1),[tI,tE]=(0,i.useState)(!1),[tR,t_]=(0,i.useState)(null),[tM,tD]=(0,i.useState)(!1),[tq,tz]=(0,i.useState)(!1),[tU,tF]=(0,i.useState)(null),[tL,tJ]=(0,i.useState)(!1),[tK,tH]=(0,i.useState)(!1),[tW,tB]=(0,i.useState)(null),[tG,tQ]=(0,i.useState)({}),[tV,tZ]=(0,i.useState)(null),tX=(0,i.useRef)(!1),{copied:tY,copy:t0}=(0,S.C)(),t1="ag_risk_confirmed",t5=()=>{L(!0)},t2=()=>{"antigravity"===g&&"true"!==window.localStorage.getItem(t1)?tx(!0):"xiaomi-mimo"===g?K(!0):t9?t5():(Z(""),G(!0))},t3=()=>{Z(""),G(!0)},t4=()=>{t9?t2():t3()},t6=E?{id:E.id,name:E.name||("anthropic-compatible"===E.type?"Anthropic Compatible":"OpenAI Compatible"),color:"anthropic-compatible"===E.type?"#D97757":"#10A37F",textIcon:"anthropic-compatible"===E.type?"AC":"OC",apiType:E.apiType,baseUrl:E.baseUrl,type:E.type}:m.zN[g]||m.fg[g]||m.IS[g]||m.nJ[g]||m.br[g],t8=t6?.authModes||[],t9=!!m.zN[g]||!!m.IS[g]||t8.includes("oauth"),t7=!!m.fg[g]||t8.includes("apikey"),se=!!m.IS[g]?.noAuth,st=(0,u.KC)(g),ss=("cursor"===g||"zed"===g)&&e7.length>0?e7:st,sa=(0,m.wG)(g),si=(0,m.mq)(g),sr=(0,m.gb)(g),sl=si||sr,sn=!sl&&t9&&t7,so="xai"===g?"Grok Build OAuth":"grok-cli"===g?"Grok CLI Device Login":"kimi"===g?"Kimi Coding OAuth":"OAuth",sd="xai"===g?"xAI API Key":"kimi"===g?"Kimi API Key":"qoder"===g||"qoder-cn"===g?"PAT":"API Key",sc=e=>{if(!eZ||"auto"===eZ)return null;let t=C(g,e);return t&&t.includes(eZ)?eZ:null},sm=sl?g:sa,su=(()=>{let e=new Set,t=new Set,s=s=>{if(!s||t.has(s))return;t.add(s);let a=C(g,s);a&&a.forEach(t=>{"none"!==t&&e.add(t)})};for(let e of ss)s(e.id);for(let e of ta)s(e.id);for(let e of eA)e.providerAlias===sm&&"llm"===(e.kind||e.type||"llm")&&s(e.id);return e.size?["auto",...e]:null})(),sp=sl?E?.prefix||g:sa,sx=(()=>{let e=new Set;for(let t of ss)e.add(t.id);for(let t of ta)e.add(t.id);for(let t of eA)t.providerAlias===sm&&"llm"===(t.kind||t.type||"llm")&&e.add(t.id);for(let t of Object.values(eC))"string"==typeof t&&t.startsWith(`${sm}/`)&&e.add(t.slice(sm.length+1));return e})(),sh=(0,i.useCallback)(async()=>{try{let e=await fetch(`/api/models/disabled?providerAlias=${encodeURIComponent(sm)}`,{cache:"no-store"}),t=await e.json();e.ok&&tl(t.ids||[])}catch(e){console.log("Error fetching disabled models:",e)}},[sm]),sf=(0,i.useCallback)(async()=>{try{let e=await fetch(`/api/models/enabled?providerAlias=${encodeURIComponent(sm)}`,{cache:"no-store"}),t=await e.json();e.ok&&to(t.ids||[])}catch(e){console.log("Error fetching enabled models:",e)}},[sm]),sg=async e=>{try{(await fetch("/api/models/disabled",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerAlias:sm,ids:[e]})})).ok&&await sh()}catch(e){console.log("Error disabling model:",e)}},sy=async e=>{try{(await fetch(`/api/models/disabled?providerAlias=${encodeURIComponent(sm)}&id=${encodeURIComponent(e)}`,{method:"DELETE"})).ok&&await sh()}catch(e){console.log("Error enabling model:",e)}},sb=async e=>{e.length&&tu({title:"Disable All Models",message:`Disable all ${e.length} model(s)?`,onConfirm:async()=>{tu(null);try{(await fetch("/api/models/disabled",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerAlias:sm,ids:e})})).ok&&await sh()}catch(e){console.log("Error disabling all models:",e)}}})},sv=async e=>{e.length&&tu({title:(0,T.Tl)("Disable Failed Models"),message:`${e.length} model(s) failed testing. Disable them?`,onConfirm:async()=>{tu(null);try{(await fetch("/api/models/disabled",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerAlias:sm,ids:e})})).ok&&await sh()}catch(e){console.log("Error disabling failed models:",e)}}})},sj=async()=>{try{(await fetch(`/api/models/disabled?providerAlias=${encodeURIComponent(sm)}`,{method:"DELETE"})).ok&&await sh()}catch(e){console.log("Error enabling all models:",e)}},sw=(0,i.useCallback)(async()=>{try{let e=await fetch("/api/models/alias"),t=await e.json();e.ok&&eS(t.aliases||{})}catch(e){console.log("Error fetching aliases:",e)}},[]),sk=(0,i.useCallback)(async()=>{try{let e=await fetch("/api/models/custom",{cache:"no-store"}),t=await e.json();e.ok&&eT(t.models||[])}catch(e){console.log("Error fetching custom models:",e)}},[]);(0,i.useEffect)(()=>{"kilocode"===g&&fetch("/api/providers/kilo/free-models").then(e=>e.json()).then(e=>{e.models?.length&&ti(e.models)}).catch(()=>{})},[g]);let sN=(0,i.useCallback)(async()=>{try{let[e,t,s,a]=await Promise.all([fetch(`/api/providers?provider=${encodeURIComponent(g)}`,{cache:"no-store"}),fetch("/api/provider-nodes",{cache:"no-store"}),fetch("/api/proxy-pools?isActive=true",{cache:"no-store"}),fetch("/api/settings",{cache:"no-store"})]),i=await e.json(),r=await t.json(),l=await s.json(),n=a.ok?await a.json():{};e.ok&&v(i.connections||[]),s.ok&&q(l.proxyPools||[]);let o=(n.providerStrategies||{})[g]||{};eW(o.fallbackStrategy||null),eG("round-robin"===n.fallbackStrategy?"round-robin":"fill-first"),eV(null!=o.stickyRoundRobinLimit?String(o.stickyRoundRobinLimit):"1");let d=(n.providerThinking||{})[g]||{};eX(d.mode||"auto");let c=(n.retryDelayByProvider||{})[g];e0(null!=c&&"auto"!==c?String(c):"auto");let m=(n.rpmByProvider||{})[g];e5(null!=m?String(m):"");let u=ew[g],p=u&&n[u]||{};if(e3({enabled:!0===p.enabled,connections:p.connections||{},schedules:p.schedules||{}}),tD(!0===n.codexFastMode),t.ok){let e=(r.nodes||[]).find(e=>e.id===g)||null;if(!e&&sl)for(let t=0;t<3;t+=1){await new Promise(e=>setTimeout(e,150));let t=await fetch("/api/provider-nodes",{cache:"no-store"});if(t.ok&&(e=((await t.json()).nodes||[]).find(e=>e.id===g)||null))break}R(e)}}catch(e){console.log("Error fetching connections:",e)}finally{I(!1)}},[g,sl]),sC=async e=>{try{let t=await fetch(`/api/provider-nodes/${g}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),s=await t.json();t.ok&&(R(s.node),await sN(),eu(!1))}catch(e){console.log("Error updating provider node:",e)}},sS=async(e,t)=>{try{let s=await fetch("/api/settings",{cache:"no-store"}),a=(s.ok?await s.json():{}).providerStrategies||{},i={};e&&(i.fallbackStrategy=e),"round-robin"===e&&""!==t&&(i.stickyRoundRobinLimit=Number(t)||3);let r={...a};0===Object.keys(i).length?delete r[g]:r[g]=i,await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerStrategies:r})})}catch(e){console.log("Error saving provider strategy:",e)}},sA=async e=>{try{let t=await fetch("/api/settings",{cache:"no-store"}),s={...(t.ok?await t.json():{}).providerThinking||{}};e&&"auto"!==e?s[g]={mode:e}:delete s[g],await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerThinking:s})})}catch(e){console.log("Error saving thinking config:",e)}},sT=async e=>{try{let t=await fetch("/api/settings",{cache:"no-store"}),s={...(t.ok?await t.json():{}).retryDelayByProvider||{}};e&&"auto"!==e?s[g]=Number(e):delete s[g],await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({retryDelayByProvider:s})})}catch(e){console.log("Error saving retry delay:",e)}},s$=async e=>{try{let t=await fetch("/api/settings",{cache:"no-store"}),s={...(t.ok?await t.json():{}).rpmByProvider||{}},a=String(e??"").trim();""===a?delete s[g]:s[g]=Math.max(0,Number(a)||0),await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({rpmByProvider:s})})}catch(e){console.log("Error saving RPM limit:",e)}},sO=async e=>{let t=ew[g];if(t){e3(e);try{await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({[t]:e})})}catch(e){console.log("Error saving auto-ping config:",e)}}},sP=async e=>{tD(e),tz(!0),tF(null);try{let t=await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({codexFastMode:e})});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error||"Failed to update fast mode setting")}}catch(t){console.log("Error saving codex fast mode setting:",t),tD(!e),tF(t.message||"Failed to update fast mode setting")}finally{tz(!1)}};(0,i.useEffect)(()=>{sN(),sw(),sk(),sh(),sf()},[sN,sw,sk,sh,sf]),(0,i.useEffect)(()=>{if("cursor"!==g&&"zed"!==g)return void te([]);let e=b.find(e=>!1!==e.isActive);if(!e?.id){te([]),"zed"===g&&ts(null);return}let t=!1;return"zed"===g&&ts(null),fetch(`/api/providers/${e.id}/models`,{cache:"no-store"}).then(async e=>({ok:e.ok,data:await e.json().catch(()=>null)})).then(({ok:e,data:s})=>{if(!t){if(e&&Array.isArray(s?.models)&&s.models.length>0){te(s.models),"zed"===g&&s?.warning&&ts(s.warning);return}"zed"===g&&(te([]),ts(s?.warning||s?.error||"Zed returned no live models."))}}).catch(()=>{t||"zed"!==g||(te([]),ts("Failed to reach the Zed model catalog."))}),()=>{t=!0}},[g,b]),(0,i.useEffect)(()=>{let e=(m.zN[g]||m.fg[g]||m.IS[g]||m.nJ[g])?.modelsFetcher;e&&O(e,g).then(e9)},[g]);let sI=b.find(e=>!1!==e.isActive)?.id||null,sE=tR===sI&&null!==sI;(0,i.useEffect)(()=>{if(!sI)return;let e=!1;return fetch(`/api/providers/${sI}/models?check=1`).then(e=>e.json()).then(t=>{e||t_(!0===t.supported?sI:null)}).catch(()=>{}),()=>{e=!0}},[sI]);let sR=async(e,t,s=sa)=>{let a=`${s}/${e}`;try{let e=await fetch("/api/models/alias",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:a,alias:t})});if(e.ok)await sw();else{let t=await e.json();alert(t.error||"Failed to set alias")}}catch(e){console.log("Error setting alias:",e)}},s_=async e=>{try{(await fetch(`/api/models/alias?alias=${encodeURIComponent(e)}`,{method:"DELETE"})).ok&&await sw()}catch(e){console.log("Error deleting alias:",e)}},sM=async(e,t="llm",s=sm,a,i)=>{try{let r=await fetch("/api/models/custom",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerAlias:s,id:e,type:t,...a?{caps:a}:{},...i?{transport:i}:{}})}),l=await r.json().catch(()=>({}));r.ok?(!1===l.added&&alert("Model already exists (duplicate). Check built-in or custom list."),await sk(),window.dispatchEvent(new CustomEvent("customModelChanged"))):alert(l.error||"Failed to add custom model")}catch(e){console.log("Error adding custom model:",e),alert(e.message||"Failed to add custom model")}},sD=async(e,t="llm",s=sm)=>{try{let a=new URLSearchParams({providerAlias:s,id:e,type:t});(await fetch(`/api/models/custom?${a}`,{method:"DELETE"})).ok&&(await sk(),window.dispatchEvent(new CustomEvent("customModelChanged")))}catch(e){console.log("Error deleting custom model:",e)}},sq=async()=>{if(tS)return;let e=b.find(e=>!1!==e.isActive);if(!e)return void alert((0,T.Tl)("Please add an active Qoder connection first"));tA(!0);try{let t=await fetch(`/api/providers/${e.id}/models`),s=await t.json();if(!t.ok)return void alert(s.error||(0,T.Tl)("Failed to fetch models"));let a=s.models||[];if(0===a.length)return void alert((0,T.Tl)("No models returned"));let i=0;for(let e of a){let t=e.id||e.name;if(!t)continue;let s=t.replace(/^(qoder-cn|qoder)\//,"");eA.some(e=>e.providerAlias===sm&&e.id===s&&"llm"===(e.kind||e.type||"llm"))||Object.values(eC).includes(`${sm}/${s}`)||(await sM(s,"llm",sm),i+=1)}0===i?alert((0,T.Tl)("All models already exist, no new models added")):alert((0,T.Tl)("Successfully added")+` ${i} `+(0,T.Tl)("models"))}catch(e){console.log("Error importing Qoder models:",e),alert((0,T.Tl)("Error fetching models")+": "+e.message)}finally{tA(!1)}},sz=async()=>{if(tT)return;let e=b.find(e=>!1!==e.isActive);if(!e)return void alert((0,T.Tl)("Please add an active Cline connection first"));t$(!0);try{let t=await fetch(`/api/providers/${e.id}/models`),s=await t.json();if(!t.ok)return void alert(s.error||(0,T.Tl)("Failed to fetch models"));let a=s.models||[];if(0===a.length)return void alert((0,T.Tl)("No models returned"));let i=0;for(let e of a){let t=e.id||e.name;t&&(eA.some(e=>e.providerAlias===sm&&e.id===t&&"llm"===(e.kind||e.type||"llm"))||Object.values(eC).includes(`${sm}/${t}`)||(await sM(t,"llm",sm),i+=1))}0===i?alert((0,T.Tl)("All models already exist, no new models added")):alert((0,T.Tl)("Successfully added")+` ${i} `+(0,T.Tl)("models"))}catch(e){console.log("Error importing Cline models:",e),alert((0,T.Tl)("Error fetching models")+": "+e.message)}finally{t$(!1)}},sU=async()=>{if(th||0===b.length)return;let e=Object.fromEntries(b.map(e=>[e.id,{state:"queued",error:null}]));tC.current=!1,tf(!0),ty(!1),tv(null),tw(e),tN({total:b.length,completed:0,passed:0,failed:0,stopped:!1});let t=0,s=0;try{for(let e=0;e<b.length;e+=1){if(tC.current){tN({total:b.length,completed:e,passed:t,failed:s,stopped:!0});break}let a=b[e];tv(a.id),tw(e=>({...e,[a.id]:{state:"testing",error:null}}));try{let e=await fetch(`/api/providers/${a.id}/test`,{method:"POST"}),i=await e.json(),r=!!i.valid;r?t+=1:s+=1,tw(e=>({...e,[a.id]:{state:r?"success":"failed",error:r?null:i.error||null}}))}catch(e){s+=1,tw(t=>({...t,[a.id]:{state:"failed",error:e.message||"Test failed"}}))}tN({total:b.length,completed:e+1,passed:t,failed:s,stopped:!1}),e<b.length-1&&await eN(1e3)}}finally{tv(null),tf(!1),ty(!1),tC.current=!1}},sF=async()=>{if(tL)return;if(!b.some(e=>!1!==e.isActive)&&!se)return void alert((0,T.Tl)("No active connection available for testing"));let e=[...ss,...ta.filter(e=>!ss.some(t=>t.id===e.id))].filter(e=>{let t=(0,u.CP)(e);return!t||"llm"===t}),t=new Set(tr),s=e.filter(e=>!t.has(e.id));if(0===s.length)return void alert((0,T.Tl)("No enabled models to test"));tX.current=!1,tJ(!0),tH(!1),tB(null),tQ({}),tZ({total:s.length,completed:0,passed:0,failed:0,stopped:!1});let a=0,i=0,r=[];try{for(let e=0;e<s.length;e+=1){if(tX.current){tZ({total:s.length,completed:e,passed:a,failed:i,stopped:!0});break}let t=s[e];tB(t.id),tQ(e=>({...e,[t.id]:{state:"testing",error:null}}));try{let e=await fetch("/api/models/test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:`${sm}/${t.id}`})}),s=await e.json(),l=e.ok&&!0===s.ok;l?a+=1:(i+=1,r.push(t.id)),tQ(e=>({...e,[t.id]:{state:l?"passed":"failed",error:l?null:s.error||"Model not reachable"}})),eI(e=>({...e,[t.id]:l?"ok":"error"})),eR(l?"":s.error||"Model not reachable")}catch(e){i+=1,r.push(t.id),tQ(s=>({...s,[t.id]:{state:"failed",error:e.message||"Test failed"}})),eI(e=>({...e,[t.id]:"error"})),eR(e.message||"Network error")}tZ({total:s.length,completed:e+1,passed:a,failed:i,stopped:!1}),e<s.length-1&&await eN(1e3)}}finally{let e=tX.current;tB(null),tJ(!1),tH(!1),tX.current=!1,r.length>0?tu({title:(0,T.Tl)("Disable Failed Models"),message:`${r.length} model(s) failed testing. Disable them?`,onConfirm:async()=>{tu(null);try{(await fetch("/api/models/disabled",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerAlias:sm,ids:r})})).ok&&await sh()}catch(e){console.log("Error disabling failed models:",e)}}}):e||alert((0,T.Tl)("All models passed testing!"))}},sL=async e=>{tu({title:"Delete Connection",message:"Delete this connection?",onConfirm:async()=>{tu(null);try{(await fetch(`/api/providers/${e}`,{method:"DELETE"})).ok&&v(t=>t.filter(t=>t.id!==e))}catch(e){console.log("Error deleting connection:",e)}}})},sJ=()=>{sN(),L(!1)},sK=async e=>{Z("");try{let t=await fetch("/api/providers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:g,...e})}),s=null;try{s=await t.json()}catch{s=null}if(t.ok)return await sN(),!0;Z(s?.error||"Failed to save connection")}catch(e){console.log("Error saving connection:",e),Z("Failed to save connection")}return!1},sH=async e=>{try{(await fetch(`/api/providers/${ef.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})).ok&&(await sN(),eo(!1))}catch(e){console.log("Error updating connection:",e)}},sW=async(e,t)=>{try{(await fetch(`/api/providers/${e}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({isActive:t})})).ok&&v(s=>s.map(s=>s.id===e?{...s,isActive:t}:s))}catch(e){console.log("Error updating connection status:",e)}},sB=async(e,t)=>{let s=await fetch(`/api/providers/${e}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerSpecificData:{fastMode:t}})}),a=await s.json();if(!s.ok)throw Error(a.error||"Failed to save fast mode");v(s=>s.map(s=>s.id===e?{...s,providerSpecificData:{...s.providerSpecificData,fastMode:t}}:s))},sG=async(e,t)=>{let s=[...b];[s[e],s[t]]=[s[t],s[e]],v(s);try{await Promise.all([fetch(`/api/providers/${s[e].id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({priority:e})}),fetch(`/api/providers/${s[t].id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({priority:t})})])}catch(e){console.log("Error swapping priority:",e),await sN()}},sQ=b.filter(e=>ez.includes(e.id));(0,i.useEffect)(()=>{eU(e=>e.filter(e=>b.some(t=>t.id===e)))},[b]),(()=>{if(0===sQ.length)return;let e=new Set(sQ.map(e=>e.providerSpecificData?.proxyPoolId||"__none__"));if(1===e.size){let t=[...e][0];if("__none__"===t)return;let s=_.find(e=>e.id===t);return s?.name}})();let sV=()=>{eJ||eh(!1)},sZ=async e=>{eK(!0);try{let t=0;for(let{connectionId:s,proxyPoolId:a}of e)try{(await fetch(`/api/providers/${s}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({proxyPoolId:a})})).ok||(t+=1)}catch(e){console.log("Error applying proxy for",s,e),t+=1}t>0&&alert(`Updated with ${t} failed request(s).`),await sN(),eh(!1)}finally{eK(!1)}},sX=e=>sZ(b.map(t=>({connectionId:t.id,proxyPoolId:e}))),{currentPage:sY,items:s0,start:s1}=function(e=[],t=1,s=10){let a=Array.isArray(e)?e:[],i=Number.isFinite(s)&&s>=1?Math.floor(s):10,r=a.length,l=Math.max(1,Math.ceil(r/i)),n=Math.floor(Number(t)),o=Math.min(Number.isFinite(n)&&n>0?n:1,l),d=(o-1)*i,c=a.slice(d,d+i);return{currentPage:o,totalPages:l,totalItems:r,start:d,items:c,pageSize:i}}(b,j,k),s5=new Set(s0.map(e=>e.id)),s2=s0.length>0&&s0.every(e=>ez.includes(e.id)),s3=(0,a.jsxs)("div",{className:"flex min-w-0 flex-col divide-y divide-black/[0.03] dark:divide-white/[0.03]",children:[s0.map((e,t)=>{let s,i=s1+t;return(0,a.jsxs)("div",{className:"flex min-w-0 items-stretch",children:[(0,a.jsx)("div",{className:"flex shrink-0 items-center pl-1 sm:pl-2",children:(0,a.jsx)("input",{type:"checkbox",checked:(s=e.id,ez.includes(s)),onChange:()=>{var t;return t=e.id,void eU(e=>e.includes(t)?e.filter(e=>e!==t):[...e,t])},className:"h-4 w-4 rounded border-gray-300 text-primary focus:ring-primary"})}),(0,a.jsx)("div",{className:"flex-1 min-w-0",children:(0,a.jsx)(Q,{connection:e,proxyPools:_,isOAuth:t9,isFirst:0===i,isLast:i===b.length-1,onMoveUp:()=>sG(i,i-1),onMoveDown:()=>sG(i,i+1),onToggleActive:t=>sW(e.id,t),fastMode:t6?.fastMode?{on:e.providerSpecificData?.fastMode===!0,onToggle:t=>sB(e.id,t)}:null,autoPing:ew[g]&&"oauth"===e.authType?{isActive:!0===e2.connections[e.id]||e2.schedules?.[e.id]?.enabled===!0,reactiveOn:!0===e2.connections[e.id],provider:g,scheduleOn:e2.schedules?.[e.id]?.enabled===!0,scheduleSummary:(0,ev.JW)(e2.schedules?.[e.id]).join(" / "),onConfigure:()=>e6(e)}:null,onUpdateProxy:async t=>{try{(await fetch(`/api/providers/${e.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({proxyPoolId:t||null})})).ok&&v(s=>s.map(s=>s.id===e.id?{...s,providerSpecificData:{...s.providerSpecificData,proxyPoolId:t||null}}:s))}catch(e){console.log("Error updating proxy:",e)}},onEdit:()=>{eg(e),eo(!0)},onReconnect:()=>{"iflow"===g?W(!0):L(!0)},onDelete:()=>sL(e.id),oneByOneStatus:tj[e.id]||null})})]},e.id)}),b.length>10&&(0,a.jsx)(c.dK,{currentPage:sY,pageSize:k,totalItems:b.length,onPageChange:w,onPageSizeChange:e=>{N(e),w(1)},allowCustomPageSize:!0,maxPageSize:200})]}),s4=_.filter(e=>!0===e.isActive),s6=(0,a.jsx)(c.aF,{isOpen:ep,onClose:sV,title:`Apply Proxy (${b.length} connections)`,children:(0,a.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,a.jsxs)("div",{className:"flex flex-col",children:[(0,a.jsxs)("button",{onClick:()=>{let e=_.filter(e=>!0===e.isActive);return 0===e.length?void alert("No active proxy pools available."):sZ(b.map((t,s)=>({connectionId:t.id,proxyPoolId:e[s%e.length].id})))},disabled:eJ||0===s4.length,className:"flex items-center gap-2 rounded-lg px-3 py-2 text-left transition-colors hover:bg-black/[0.04] dark:hover:bg-white/[0.04] disabled:cursor-not-allowed disabled:opacity-50",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[18px]",children:"sync_alt"}),(0,a.jsx)("span",{className:"text-sm text-text-main",children:"One-to-one (rotate)"})]}),(0,a.jsxs)("button",{onClick:()=>sX(null),disabled:eJ,className:"flex items-center gap-2 rounded-lg px-3 py-2 text-left transition-colors hover:bg-black/[0.04] dark:hover:bg-white/[0.04] disabled:cursor-not-allowed disabled:opacity-50",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[18px]",children:"link_off"}),(0,a.jsx)("span",{className:"text-sm text-text-main",children:"None (unbind all)"})]}),_.map(e=>(0,a.jsxs)("button",{onClick:()=>sX(e.id),disabled:eJ||!0!==e.isActive,className:"flex items-center gap-2 rounded-lg px-3 py-2 text-left transition-colors hover:bg-black/[0.04] dark:hover:bg-white/[0.04] disabled:cursor-not-allowed disabled:opacity-50",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[18px]",children:"lan"}),(0,a.jsx)("span",{className:"truncate text-sm text-text-main",children:e.name}),!0!==e.isActive&&(0,a.jsx)("span",{className:"text-[10px] text-text-muted",children:"(inactive)"})]},e.id))]}),eJ&&(0,a.jsx)("p",{className:"text-xs text-text-muted",children:"Applying..."}),(0,a.jsx)(c.$n,{onClick:sV,variant:"ghost",fullWidth:!0,disabled:eJ,children:"Cancel"})]})}),s8=async e=>{if(!e_.has(e)){eM(t=>new Set(t).add(e));try{let t=await fetch("/api/models/test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:`${sm}/${e}`})}),s=await t.json();eI(t=>({...t,[e]:s.ok?"ok":"error"})),eR(s.ok?"":s.error||"Model not reachable")}catch{eI(t=>({...t,[e]:"error"})),eR("Network error")}finally{eM(t=>{let s=new Set(t);return s.delete(e),s})}}};if($)return(0,a.jsxs)("div",{className:"flex flex-col gap-8",children:[(0,a.jsx)(c.Qv,{}),(0,a.jsx)(c.Qv,{})]});if(!t6)return(0,a.jsxs)("div",{className:"text-center py-20",children:[(0,a.jsx)("p",{className:"text-text-muted",children:"Provider not found"}),(0,a.jsx)(n(),{href:"/dashboard/providers",className:"text-primary mt-4 inline-block",children:"Back to Providers"})]});let s9=()=>si&&t6.apiType?"responses"===t6.apiType?"/providers/oai-r.png":"/providers/oai-cc.png":sr?"/providers/anthropic-m.png":(0,d.HY)(t6.id);return(0,a.jsxs)("div",{className:"flex min-w-0 flex-col gap-6 px-1 sm:gap-8 sm:px-0",children:[(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsxs)(n(),{href:"/dashboard/providers",className:"inline-flex items-center gap-1 text-sm text-text-muted hover:text-primary transition-colors mb-4",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-lg",children:"arrow_back"}),"Back to Providers"]}),(0,a.jsxs)("div",{className:"flex min-w-0 items-center gap-3 sm:gap-4",children:[(0,a.jsx)("div",{className:"flex size-12 shrink-0 items-center justify-center rounded-lg",style:{backgroundColor:`${t6.color}15`},children:e$||!s9()?(0,a.jsx)("span",{className:"text-sm font-bold",style:{color:t6.color},children:t6.textIcon||t6.id.slice(0,2).toUpperCase()}):(0,a.jsx)(o.default,{src:s9(),alt:t6.name,width:48,height:48,className:"max-h-12 max-w-12 rounded-lg object-contain",sizes:"48px",onError:()=>{(0,d.Kw)(t6.id),eO(!0)},loading:"lazy",decoding:"async"})}),(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsxs)("div",{className:"flex items-center gap-3 flex-wrap",children:[(0,a.jsx)("h1",{className:"truncate text-2xl font-semibold tracking-tight sm:text-3xl",children:t6.name}),(t6.notice?.apiKeyUrl||t6.notice?.signupUrl||t6.website)&&(0,a.jsxs)("a",{href:t6.notice?.apiKeyUrl||t6.notice?.signupUrl||t6.website,target:"_blank",rel:"noopener noreferrer",className:"text-xs text-primary hover:underline inline-flex items-center gap-1",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:"open_in_new"}),t6.notice?.apiKeyUrl?"Get API Key":"Sign up / Learn more"]})]}),(0,a.jsxs)("p",{className:"text-text-muted",children:[b.length," connection",1===b.length?"":"s"]})]}),(0,a.jsxs)("div",{className:"ml-auto flex shrink-0 items-center gap-2",children:[(0,a.jsx)("span",{className:"hidden text-xs text-text-muted sm:inline",children:"RPM / account"}),(0,a.jsx)("input",{type:"number",min:"0",value:e1,placeholder:String(m.W[g]||0),onChange:e=>e5(e.target.value),onBlur:e=>s$(e.target.value),title:"Max requests per minute per account. Accounts over the cap are skipped before a request is sent, so the provider never sees a 429. Blank = provider default, 0 = unlimited.",className:"w-16 rounded-md border border-border bg-background px-2 py-1 text-xs focus:border-primary focus:outline-none"}),(0,a.jsx)("span",{className:"hidden text-xs text-text-muted sm:inline",children:"Retry delay"}),(0,a.jsx)("select",{value:eY,onChange:e=>{var t;e0(t=e.target.value),sT(t)},title:"Cooldown after a rate-limit/error when the provider reports no reset time of its own. Auto = honor the provider's reported delay, else built-in backoff.",className:"rounded-md border border-border bg-background px-2 py-1 text-xs focus:border-primary focus:outline-none",children:ek.map(e=>(0,a.jsx)("option",{value:e.value,children:e.label},e.value))})]})]})]}),t6.deprecated&&(0,a.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 rounded-lg bg-yellow-500/10 border border-yellow-500/30",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[16px] text-yellow-500 mt-0.5 shrink-0",children:"warning"}),(0,a.jsx)("p",{className:"text-xs text-red-600 dark:text-yellow-400 leading-relaxed",children:t6.deprecationNotice})]}),t6.notice?.text&&!t6.deprecated&&(0,a.jsxs)("div",{className:"flex flex-col gap-2 rounded-lg border border-blue-500/30 bg-blue-500/10 px-3 py-2 sm:flex-row sm:items-center",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[16px] text-blue-500 shrink-0",children:"info"}),(0,a.jsx)("p",{className:"min-w-0 flex-1 text-xs leading-relaxed text-blue-600 dark:text-blue-400",children:t6.notice.text}),t6.notice.apiKeyUrl&&(0,a.jsx)("a",{href:t6.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 →"})]}),sl&&E&&(0,a.jsx)(c.Zp,{children:(0,a.jsxs)("div",{className:"mb-4 flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsx)("h2",{className:"text-lg font-semibold",children:sr?"Anthropic Compatible Details":"OpenAI Compatible Details"}),(0,a.jsxs)("p",{className:"break-all text-sm text-text-muted",children:[sr?"Messages API":"responses"===E.apiType?"Responses API":"Chat Completions"," \xb7 ",(E.baseUrl||"").replace(/\/$/,""),"/",sr?"messages":"responses"===E.apiType?"responses":"chat/completions"]})]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-2 sm:flex sm:items-center",children:[(0,a.jsx)(c.$n,{size:"sm",icon:"add",onClick:()=>{Z(""),G(!0)},className:"w-full sm:w-auto",children:"Add API Key"}),(0,a.jsx)(c.$n,{size:"sm",icon:"download",variant:"secondary",onClick:()=>es(!0),className:"w-full sm:w-auto",children:"Export Keys"}),(0,a.jsx)(c.$n,{size:"sm",variant:"secondary",icon:"edit",onClick:()=>eu(!0),className:"w-full sm:w-auto",children:"Edit"}),(0,a.jsx)(c.$n,{size:"sm",variant:"secondary",icon:"delete",onClick:async()=>{tu({title:"Delete Compatible Node",message:`Delete this ${sr?"Anthropic":"OpenAI"} Compatible node?`,onConfirm:async()=>{tu(null);try{(await fetch(`/api/provider-nodes/${g}`,{method:"DELETE"})).ok&&f.push("/dashboard/providers")}catch(e){console.log("Error deleting provider node:",e)}}})},className:"w-full sm:w-auto",children:"Delete"})]})]})}),se?(0,a.jsx)(c.gw,{providerId:g}):(0,a.jsxs)(c.Zp,{children:[(0,a.jsxs)("div",{className:"mb-4 flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[(0,a.jsx)("h2",{className:"text-lg font-semibold",children:"Connections"}),(0,a.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:gap-4",children:[b.length>0&&_.length>0&&(0,a.jsx)(c.$n,{size:"sm",variant:"secondary",icon:"lan",onClick:()=>eh(!0),children:"Apply Proxy"}),b.length>0&&(0,a.jsxs)(a.Fragment,{children:[ez.length>0&&(0,a.jsxs)(c.$n,{size:"sm",variant:"danger",icon:"delete",onClick:()=>{let e=ez.length;0!==e&&tu({title:`Delete ${e} Connection${e>1?"s":""}`,message:`Delete ${e} connection${e>1?"s":""}? This cannot be undone.`,onConfirm:async()=>{tu(null);let e=0,t=[...ez];for(let s of t)try{(await fetch(`/api/providers/${s}`,{method:"DELETE"})).ok||(e+=1)}catch(t){console.log("Error deleting connection:",t),e+=1}v(e=>e.filter(e=>!t.includes(e.id))),eU([]),e>0&&alert(`Deleted ${t.length-e} connection(s), ${e} failed.`)}})},children:["Delete Selected (",ez.length,")"]}),(0,a.jsx)(c.$n,{size:"sm",variant:"secondary",icon:"sync",onClick:sU,disabled:th,children:th?"Testing Connection One-by-One...":"Test Connection One-by-One"}),th&&(0,a.jsx)(c.$n,{size:"sm",variant:"ghost",icon:"stop",onClick:()=>{th&&(tC.current=!0,ty(!0))},disabled:tg,children:tg?"Stopping...":"Stop"})]}),(0,a.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,a.jsx)("span",{className:"text-xs text-text-muted font-medium",children:"Strategy"}),(0,a.jsx)("div",{className:"w-[230px]",children:(0,a.jsx)(c.l6,{options:ej,value:eH||eB,onChange:e=>{var t;let s,a,i;return s=(t=e.target.value)===eB?null:t,i=(a="round-robin"===t)?eQ||"1":eQ,void(a&&!eQ&&eV("1"),eW(s),sS(s,i))},selectClassName:"py-1.5 text-xs"})}),"round-robin"===(eH||eB)&&(0,a.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,a.jsx)("span",{className:"text-xs text-text-muted",children:"Sticky:"}),(0,a.jsx)("input",{type:"number",min:1,value:eQ,onChange:e=>{var t;eV(t=e.target.value),sS("round-robin",t)},placeholder:"1",className:"w-14 px-2 py-1 text-xs border border-border rounded-md bg-background focus:outline-none focus:border-primary"})]})]}),"codex"===g&&(0,a.jsx)(c.lM,{checked:tM,onChange:sP,disabled:tq,label:"Fast inference",description:"Use the priority tier for Codex models (all accounts). Per-account override lives on each connection row and quota card."}),"codex"===g&&tU&&(0,a.jsx)("span",{className:"text-xs text-red-500",role:"alert",children:tU})]})]}),(0,a.jsxs)("p",{className:"mb-4 -mt-1 text-xs text-text-muted",children:["Tip: pin requests to a specific account by sending the ",(0,a.jsx)("code",{children:"x-connection-id"})," request header with a connection ID — click the ID chip on a connection to copy it. When the pinned account is unavailable, EzRouter falls back to the other accounts automatically."]}),0===b.length?(0,a.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[(0,a.jsx)("div",{className:"inline-flex items-center justify-center w-9 h-9 rounded-full bg-primary/10 text-primary shrink-0",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:t9?"lock":"key"})}),(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsx)("p",{className:"text-sm text-text-muted",children:"No connections yet"}),sn&&(0,a.jsxs)("p",{className:"text-xs text-text-muted",children:["Choose ",so," or ",sd,"."]})]})]}),(0,a.jsx)("div",{className:"flex gap-2",children:sn?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(c.$n,{size:"sm",icon:"lock",variant:"secondary",onClick:t2,children:so}),(0,a.jsx)(c.$n,{size:"sm",icon:"key",onClick:t3,children:sd})]}):(0,a.jsxs)(a.Fragment,{children:[!sl&&"iflow"===g&&(0,a.jsx)(c.$n,{size:"sm",icon:"cookie",variant:"secondary",onClick:()=>W(!0),children:"Cookie"}),"codex"===g&&(0,a.jsx)(c.$n,{size:"sm",icon:"playlist_add",variant:"secondary",onClick:()=>ee(!0),children:(0,T.Tl)("Bulk Add")}),"grok-cli"===g&&(0,a.jsx)(c.$n,{size:"sm",icon:"playlist_add",variant:"secondary",onClick:()=>er(!0),children:(0,T.Tl)("Bulk Add")}),(0,a.jsx)(c.$n,{size:"sm",icon:"add",onClick:t4,children:sl?"Add API Key":"iflow"===g?"OAuth":"Add Connection"})]})})]}):(0,a.jsxs)(a.Fragment,{children:[tk&&(0,a.jsx)("div",{className:"mb-4 rounded-lg border border-black/10 bg-black/[0.02] px-3 py-2 text-xs text-text-muted dark:border-white/10 dark:bg-white/[0.03]",children:(0,a.jsxs)("div",{className:"flex flex-wrap items-center gap-3",children:[(0,a.jsxs)("span",{children:["Total: ",tk.total]}),(0,a.jsxs)("span",{children:["Completed: ",tk.completed]}),(0,a.jsxs)("span",{children:["Passed: ",tk.passed]}),(0,a.jsxs)("span",{children:["Failed: ",tk.failed]}),tk.stopped&&(0,a.jsx)("span",{className:"text-amber-600 dark:text-amber-400",children:"Stopped"}),th&&tb&&(0,a.jsxs)("span",{children:["Running: ",b.find(e=>e.id===tb)?.name||tb]})]})}),b.length>0&&(0,a.jsx)("div",{className:"mb-3 flex items-center gap-2 border-b border-black/[0.03] pb-2 dark:border-white/[0.03]",children:(0,a.jsxs)("label",{className:"flex cursor-pointer items-center gap-1.5 text-xs text-text-muted hover:text-primary",children:[(0,a.jsx)("input",{type:"checkbox",checked:s2,onChange:()=>{s2?eU(e=>e.filter(e=>!s5.has(e))):eU(e=>{let t=new Set(e);for(let e of s5)t.add(e);return[...t]})},className:"h-3.5 w-3.5 rounded border-gray-300 text-primary focus:ring-primary"}),"Select All"]})}),s3,!sl&&(0,a.jsxs)("div",{className:"mt-4 grid grid-cols-1 gap-2 sm:flex",children:["iflow"===g&&(0,a.jsx)(c.$n,{size:"sm",icon:"cookie",variant:"secondary",onClick:()=>W(!0),title:"Add connection using browser cookie",className:"w-full sm:w-auto",children:"Cookie"}),"codex"===g&&(0,a.jsx)(c.$n,{size:"sm",icon:"playlist_add",variant:"secondary",onClick:()=>ee(!0),title:(0,T.Tl)("Bulk import codex accounts from JSON"),className:"w-full sm:w-auto",children:(0,T.Tl)("Bulk Add")}),"grok-cli"===g&&(0,a.jsx)(c.$n,{size:"sm",icon:"playlist_add",variant:"secondary",onClick:()=>er(!0),title:(0,T.Tl)("Bulk import Grok CLI accounts from JSON"),className:"w-full sm:w-auto",children:(0,T.Tl)("Bulk Add")}),b.length>0&&(0,a.jsx)(c.$n,{size:"sm",icon:"download",variant:"secondary",onClick:()=>es(!0),className:"w-full sm:w-auto",children:"Export Keys"}),sn?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(c.$n,{size:"sm",icon:"lock",variant:"secondary",onClick:t2,className:"w-full sm:w-auto",children:so}),(0,a.jsx)(c.$n,{size:"sm",icon:"key",onClick:t3,className:"w-full sm:w-auto",children:sd})]}):(0,a.jsx)(c.$n,{size:"sm",icon:"add",onClick:t4,className:"w-full sm:w-auto",children:"Add"})]})]})]}),(0,a.jsx)(ey,{providerId:g}),(0,a.jsxs)(c.Zp,{children:[(0,a.jsxs)("div",{className:"mb-4 flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between",children:[(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[(0,a.jsx)("h2",{className:"text-lg font-semibold",children:"Available Models"}),su&&(0,a.jsx)("select",{value:eZ,onChange:e=>{var t;eX(t=e.target.value),sA(t)},title:"Appends (level) suffix to copied model names",className:"rounded-md border border-border bg-background px-2 py-1 text-xs focus:border-primary focus:outline-none",children:su.map(e=>(0,a.jsx)("option",{value:e,children:`Thinking: ${e.charAt(0).toUpperCase()+e.slice(1)}`},e))})]}),!sl&&(t=(e=[...ss,...ta.filter(e=>!ss.some(t=>t.id===e.id))].filter(e=>{let t=(0,u.CP)(e);return!t||"llm"===t}).map(e=>e.id).filter(e=>!tr.includes(e))).filter(e=>tG[e]?.state==="failed"||"error"===eP[e]),(0,a.jsxs)("div",{className:"flex gap-2",children:[tr.length>0&&(0,a.jsx)(c.$n,{size:"sm",variant:"secondary",icon:"restart_alt",onClick:sj,children:"Active All"}),t.length>0&&(0,a.jsxs)(c.$n,{size:"sm",variant:"danger",icon:"block",onClick:()=>sv(t),children:[(0,T.Tl)("Disable Failed")," (",t.length,")"]}),e.length>0&&(0,a.jsx)(c.$n,{size:"sm",variant:tL?"secondary":"primary",icon:tL?"stop":"play_circle",onClick:tL?()=>{tL&&(tX.current=!0,tH(!0))}:sF,disabled:!b.some(e=>!1!==e.isActive)&&!se,className:"flex items-center gap-1.5",children:tL?tK?(0,T.Tl)("Stopping..."):(0,T.Tl)("Testing..."):(0,T.Tl)("Test All")}),e.length>0&&(0,a.jsx)(c.$n,{size:"sm",variant:"secondary",icon:"block",onClick:()=>sb(e),children:"Disable All"})]}))]}),!!eE&&(0,a.jsxs)("div",{className:"mb-3",children:[(0,a.jsx)("p",{className:"text-xs text-red-500 break-words",children:eE}),/RegionError|hosted in China|regionNotAllowed/i.test(eE)&&(l=(s="string"==typeof eE?eE:JSON.stringify(eE)).match(/https:\/\/opencode\.ai\/workspace\/[^\s"')]+/),p=s.match(/wrk_[0-9A-Za-z]+/),x=l?l[0].endsWith("/go")?l[0]:`${l[0]}/go`:p?`https://opencode.ai/workspace/${p[0]}/go`:"https://opencode.ai",(0,a.jsx)("div",{className:"mt-1.5",children:(0,a.jsxs)("a",{href:x,target:"_blank",rel:"noreferrer",className:"inline-flex items-center gap-1 rounded-md bg-amber-500/10 px-2 py-0.5 text-xs font-medium text-amber-600 hover:bg-amber-500/20 dark:text-amber-400 transition-colors",children:[(0,a.jsx)("span",{children:"Allow China-hosted models"}),(0,a.jsx)("span",{className:"material-symbols-outlined text-[13px]",children:"open_in_new"})]})}))]}),"zed"===g&&!!tt&&(0,a.jsx)("p",{className:"text-xs text-red-500 mb-3 break-words",children:tt}),(0,a.jsxs)("div",{className:"mb-3 flex flex-wrap items-center gap-2",children:[(0,a.jsxs)("button",{onClick:()=>tc(!0),className:"flex items-center gap-1.5 rounded-lg border border-border px-3 py-1.5 text-xs text-text-main transition-colors hover:border-primary/40 hover:bg-primary/5",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:"visibility"}),"Visible models",tn.length>0?` (${tn.length})`:""]}),(0,a.jsx)("span",{className:"text-[11px] text-text-muted",children:tn.length>0?`Only these ${tn.length} models are exposed on /v1/models`:"All models are exposed on /v1/models"})]}),(()=>{let e,t,s;if(sl)return(0,a.jsx)(z,{providerStorageAlias:sm,providerDisplayAlias:sp,modelAliases:eC,customModels:eA,copied:tY,onCopy:t0,onSetAlias:sR,onDeleteAlias:s_,onAddCustomModel:e=>sM(e,"llm",sm),onDeleteCustomModel:e=>sD(e,"llm",sm),connections:b,isAnthropic:sr,onModelsChanged:sk,importSupported:sE});let i=[...ss,...ta.filter(e=>!ss.some(t=>t.id===e.id))].filter(e=>{let t=(0,u.CP)(e);return!t||"llm"===t}),r=new Set(tr),l=i.filter(e=>!r.has(e.id)),n=i.filter(e=>r.has(e.id)),o=P({customModels:eA,modelAliases:eC,providerAlias:sm,builtInModels:ss,type:"llm"});return(0,a.jsxs)("div",{className:"flex flex-wrap gap-3",children:[o.map(e=>(0,a.jsx)(M,{model:{id:e.id,name:e.name},fullModel:`${sp}/${e.id}`,alias:e.alias,copied:tY,onCopy:t0,onSetAlias:()=>{},onDeleteAlias:()=>{"custom"===e.source?sD(e.id,"llm",sm):s_(e.alias)},testStatus:eP[e.id],onTest:b.length>0||se?()=>s8(e.id):void 0,isTesting:e_.has(e.id),isCustom:!0,isFree:!1,caps:y(`${g}/${e.id}`),thinkingSuffix:sc(e.id)},`${e.source}-${e.fullModel}`)),l.map(e=>{let t=e.id.startsWith(`${sm}/`)?e.id.slice(sm.length+1):e.id,s=`${sm}/${t}`,i=`${g}/${t}`,r=Object.entries(eC).find(([,e])=>e===s||e===i)?.[0];return(0,a.jsx)(M,{model:e,fullModel:`${sp}/${t}`,alias:r,copied:tY,onCopy:t0,onSetAlias:e=>sR(t,e,sm),onDeleteAlias:()=>s_(r),testStatus:eP[t]||eP[e.id],onTest:b.length>0||se?()=>s8(t):void 0,isTesting:e_.has(t)||e_.has(e.id),isFree:e.isFree,onDisable:()=>sg(t),caps:y(`${g}/${t}`),thinkingSuffix:sc(t)},e.id)}),(0,a.jsxs)("button",{onClick:()=>eq(!0),className:"flex w-full items-center justify-center gap-1.5 rounded-lg border border-dashed border-primary/40 px-3 py-2 text-xs text-primary transition-colors hover:border-primary hover:bg-primary/5 sm:w-auto",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:"add"}),"Add Model"]}),("qoder"===g||"qoder-cn"===g)&&b.some(e=>!1!==e.isActive)&&(0,a.jsxs)("button",{onClick:sq,disabled:tS,className:"flex w-full items-center justify-center gap-1.5 rounded-lg border border-dashed border-blue-500/40 px-3 py-2 text-xs text-blue-600 dark:text-blue-400 transition-colors hover:border-blue-500 hover:bg-blue-500/5 sm:w-auto disabled:opacity-50 disabled:cursor-not-allowed",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",style:tS?{animation:"spin 1s linear infinite"}:void 0,children:tS?"progress_activity":"download"}),tS?(0,T.Tl)("Fetching..."):(0,T.Tl)("Fetch Qoder Models")]}),("cline"===g||"clinepass"===g)&&b.some(e=>!1!==e.isActive)&&(0,a.jsxs)("button",{onClick:sz,disabled:tT,className:"flex w-full items-center justify-center gap-1.5 rounded-lg border border-dashed border-blue-500/40 px-3 py-2 text-xs text-blue-600 dark:text-blue-400 transition-colors hover:border-blue-500 hover:bg-blue-500/5 sm:w-auto disabled:opacity-50 disabled:cursor-not-allowed",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",style:tT?{animation:"spin 1s linear infinite"}:void 0,children:tT?"progress_activity":"download"}),tT?(0,T.Tl)("Fetching..."):(0,T.Tl)("Import from /models")]}),sE&&sI&&!["qoder","qoder-cn","cline","clinepass"].includes(g)&&(0,a.jsxs)("button",{onClick:()=>tE(!0),className:"flex w-full items-center justify-center gap-1.5 rounded-lg border border-dashed border-blue-500/40 px-3 py-2 text-xs text-blue-600 dark:text-blue-400 transition-colors hover:border-blue-500 hover:bg-blue-500/5 sm:w-auto",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:"download"}),(0,T.Tl)("Import Models")]}),e8.length>0&&(e=new Set([...Object.values(eC),...o.map(e=>e.fullModel)]),t=new Set(ss.map(e=>e.id)),0===(s=e8.filter(s=>{let a=s.id.replace(/^nous\//,"");return!e.has(`${sm}/${a}`)&&!t.has(a)&&!t.has(s.id)})).length?null:(0,a.jsxs)("div",{className:"w-full mt-2",children:[(0,a.jsx)("p",{className:"text-xs text-text-muted mb-2",children:"nous"===g?(0,T.Tl)("Suggested models (≥200k context):"):(0,T.Tl)("Suggested free models (≥200k context):")}),(0,a.jsx)("div",{className:"flex flex-wrap gap-2",children:s.map(e=>{let t=e.id.replace(/^nous\//,"");return(0,a.jsxs)("button",{onClick:async()=>{await sM(t,"llm",sm)},className:"flex items-center gap-1 px-2.5 py-1.5 rounded-lg border border-black/10 dark:border-white/10 text-xs text-text-muted hover:text-primary hover:border-primary/40 hover:bg-primary/5 transition-colors",title:`${e.name} \xb7 ${(e.contextLength/1e3).toFixed(0)}k ctx`,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[13px]",children:"add"}),t.split("/").pop()]},e.id)})})]})),n.length>0&&(0,a.jsxs)("div",{className:"w-full mt-2",children:[(0,a.jsxs)("p",{className:"text-xs text-text-muted mb-2",children:["Disabled models (",n.length,"):"]}),(0,a.jsx)("div",{className:"flex flex-wrap gap-2",children:n.map(e=>(0,a.jsxs)("button",{onClick:()=>sy(e.id),className:"flex items-center gap-1 px-2.5 py-1.5 rounded-lg border border-dashed border-black/10 dark:border-white/10 text-xs text-text-muted hover:text-primary hover:border-primary/40 hover:bg-primary/5 transition-colors",title:"Restore model",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[13px]",children:"add"}),e.id]},e.id))})]})]})})()]}),s6,"kiro"===g?(0,a.jsx)(c.Mh,{isOpen:F,providerInfo:t6,onSuccess:sJ,onClose:()=>L(!1)}):"cursor"===g?(0,a.jsx)(c.G9,{isOpen:F,onSuccess:sJ,onClose:()=>L(!1)}):"zed"===g?(0,a.jsx)(c.TE,{isOpen:F,providerInfo:t6,onSuccess:sJ,onClose:()=>L(!1)}):"gitlab"===g?(0,a.jsx)(c.vj,{isOpen:F,providerInfo:t6,onSuccess:sJ,onClose:()=>L(!1)}):(0,a.jsx)(c.LF,{isOpen:F,provider:g,providerInfo:t6,onSuccess:sJ,onClose:()=>L(!1)}),(0,a.jsx)(c.LH,{isOpen:J,onSuccess:sJ,onClose:()=>K(!1)}),"iflow"===g&&(0,a.jsx)(c.vE,{isOpen:H,onSuccess:()=>{sN(),W(!1)},onClose:()=>W(!1)}),B&&(0,a.jsx)(ea,{isOpen:B,provider:g,providerName:t6.name,isCompatible:sl,isAnthropic:sr,authType:t6?.authType,authHint:t6?.authHint,website:t6?.website,proxyPools:_,error:V,existingNames:b.map(e=>e.name).filter(Boolean),onSave:sK,onBulkDone:sN,onClose:()=>{Z(""),G(!1)}}),(0,a.jsx)(X,{isOpen:et,providerId:g,providerName:t6.name,onClose:()=>es(!1)}),(0,a.jsx)(c.wI,{isOpen:el,connection:ef,proxyPools:_,onSave:sH,onClose:()=>eo(!1)}),sl&&(0,a.jsx)(en,{isOpen:ec,node:E,onSave:sC,onClose:()=>eu(!1),isAnthropic:sr}),!sl&&(0,a.jsx)(ed,{isOpen:eD,providerAlias:sm,providerDisplayAlias:sp,onSave:async(e,t,s)=>{await sM(e,t?.stt?"stt":"llm",sm,t,s),eq(!1)},onClose:()=>eq(!1)}),td&&(0,a.jsx)(U,{isOpen:!0,onClose:()=>tc(!1),providerId:g,providerAlias:sm,connections:b,customModels:eA,disabledModelIds:tr,onSaved:e=>{to(e),sh()}}),(0,a.jsx)(D,{isOpen:tI,onClose:()=>tE(!1),connectionId:sI,providerStorageAlias:sm,existingIds:sx,onImported:sk}),"codex"===g&&(0,a.jsx)(em,{isOpen:Y,onClose:()=>ee(!1),onSuccess:sN}),"grok-cli"===g&&(0,a.jsx)(ex,{isOpen:ei,onClose:()=>er(!1),onSuccess:sN}),e4&&(0,a.jsx)(eb.A,{isOpen:!!e4,onClose:()=>e6(null),connection:e4,reactive:!0===e2.connections[e4.id],schedule:e2.schedules?.[e4.id]||null,onSave:e=>((e,{reactive:t,schedule:s})=>{sO({...e2,connections:{...e2.connections,[e]:t},schedules:{...e2.schedules,[e]:s}})})(e4.id,e)}),(0,a.jsx)(c.uo,{isOpen:tp,onClose:()=>tx(!1),onConfirm:()=>{(window.localStorage.setItem(t1,"true"),tx(!1),t9)?t5():t3()},title:"Risk Notice",message:t6?.deprecationNotice,confirmText:"I Understand, Continue",cancelText:"Cancel",variant:"danger"}),(0,a.jsx)(c.uo,{isOpen:!!tm,onClose:()=>tu(null),onConfirm:tm?.onConfirm,title:tm?.title||"Confirm",message:tm?.message,variant:"danger"})]})}},64827:(e,t,s)=>{"use strict";function a(e){if(!e)return null;let t=null,s=Date.now();for(let[a,i]of Object.entries(e)){if(!a.startsWith("modelLock_")||!i)continue;let e=new Date(i).getTime();e<=s||(!t||e<t)&&(t=e)}return t?new Date(t).toISOString():null}s.d(t,{kJ:()=>a}),s(10904)},85295:(e,t,s)=>{Promise.resolve().then(s.bind(s,50136))},93195:(e,t,s)=>{"use strict";function a(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone||"UTC"}catch{return"UTC"}}s.d(t,{JW:()=>o,Vm:()=>a,fB:()=>r,gy:()=>i,nz:()=>l});let i={anchor:"09:30",timezone:a(),windowHours:5,slotsPerDay:3};function r(e){let t=/^(\d{1,2}):(\d{2})$/.exec(String(e||"").trim());if(!t)return null;let s=Number(t[1]),a=Number(t[2]);return s>23||a>59?null:{hour:s,minute:a}}function l(e){return Math.max(1,Math.floor(24/e))}function n(e,t,s,a){let i="number"==typeof e?e:Number(e);return Number.isFinite(i)?Math.min(a,Math.max(s,i)):t}function o(e){let t=function(e){if(!e||!0!==e.enabled)return null;let t=r(e.anchor)||r(i.anchor),s=`${String(t.hour).padStart(2,"0")}:${String(t.minute).padStart(2,"0")}`,a=!function(e){if(!e||"string"!=typeof e)return!1;try{return new Intl.DateTimeFormat("en-US",{timeZone:e}),!0}catch{return!1}}(e.timezone)?i.timezone:e.timezone,o=n(e.windowHours,i.windowHours,.5,24),d=Math.round(n(e.slotsPerDay,i.slotsPerDay,1,l(o)));return{enabled:!0,anchor:s,timezone:a,windowHours:o,slotsPerDay:d}}(e);if(!t)return[];let{hour:s,minute:a}=r(t.anchor),o=60*s+a;return Array.from({length:t.slotsPerDay},(e,s)=>{let a=Math.round(o+s*t.windowHours*60)%1440;return`${String(Math.floor(a/60)).padStart(2,"0")}:${String(a%60).padStart(2,"0")}`})}},93725:(e,t,s)=>{"use strict";function a(e){return"number"!=typeof e||!Number.isFinite(e)||e<=0?null:e>=1e6?`${+(e/1e6).toFixed(1)}M`:e>=1e3?`${Math.round(e/1e3)}k`:String(e)}function i(e){if("number"!=typeof e||!Number.isFinite(e))return null;if(0===e)return"0";let t=Math.abs(e);return(t>=1?e.toFixed(2):t>=.01?e.toFixed(3):e.toFixed(4)).replace(/\.?0+$/,"")}function r(e,t){let s=[],r=a(e?.contextWindow);r&&s.push(`${r} ctx`);let l=a(e?.maxOutput);l&&s.push(`${l} out`);let n=i(t?.input),o=i(t?.output);return(null!==n||null!==o)&&s.push(`$${n??"?"}/$${o??"?"}`),s.length>0?s.join(" \xb7 "):null}s.d(t,{M4:()=>r})},97132:(e,t,s)=>{"use strict";s.d(t,{A:()=>m});var a=s(95155),i=s(12115),r=s(14051),l=s.n(r),n=s(35497),o=s(31474),d=s(93195);let c=[{value:"off",label:"Off",icon:"block"},{value:"reset",label:"On reset",icon:"bolt"},{value:"schedule",label:"Schedule",icon:"schedule"}];function m({isOpen:e,onClose:t,onSave:s,connection:r,reactive:l=!1,schedule:u=null}){let[p,x]=(0,i.useState)(()=>({mode:u?.enabled===!0?"schedule":!0===l?"reset":"off",anchor:u?.anchor||d.gy.anchor,timezone:(0,d.Vm)(),windowHours:String(u?.windowHours??d.gy.windowHours),slotsPerDay:String(u?.slotsPerDay??d.gy.slotsPerDay)})),h=Number(p.windowHours),f=Number(p.slotsPerDay),g=!!(0,d.fB)(p.anchor),y=Number.isFinite(h)&&h>=.5&&h<=24,b=y?(0,d.nz)(h):24,v=Number.isInteger(f)&&f>=1&&f<=b,j=g&&y&&v,w="schedule"!==p.mode||j,k=j?(0,d.JW)({enabled:!0,...p,windowHours:h,slotsPerDay:f}):[],N=k.length&&y?(()=>{let{hour:e,minute:t}=(0,d.fB)(p.anchor),s=Math.round(60*e+t+f*h*60)%1440;return`${String(Math.floor(s/60)).padStart(2,"0")}:${String(s%60).padStart(2,"0")}`})():"",C=e=>x(t=>({...t,...e}));return(0,a.jsx)(n.aF,{isOpen:e,onClose:t,title:"Auto-ping settings",size:"lg",footer:(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(n.$n,{variant:"secondary",onClick:t,children:"Cancel"}),(0,a.jsx)(n.$n,{onClick:()=>{w&&(s({reactive:"reset"===p.mode,schedule:"schedule"===p.mode?{enabled:!0,anchor:p.anchor,timezone:p.timezone,windowHours:h,slotsPerDay:f}:{enabled:!1}}),t())},disabled:!w,children:"Save"})]}),children:(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,a.jsxs)("p",{className:"text-sm text-text-muted",children:["Configure automated quota pings",r?.name?` for ${r.name}`:""," — pick one mode."]}),(0,a.jsx)("div",{className:"grid grid-cols-3 gap-1 rounded-[10px] bg-surface-2 p-1",children:c.map(e=>{let t=p.mode===e.value;return(0,a.jsxs)("button",{type:"button",onClick:()=>C({mode:e.value}),className:(0,o.cn)("flex h-9 items-center justify-center gap-1.5 rounded-[8px] px-3 text-sm font-medium transition-all",t?"bg-surface text-text-main shadow-sm":"text-text-muted hover:text-text-main"),children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[15px] leading-none",children:e.icon}),(0,a.jsx)("span",{children:e.label})]},e.value)})}),"reset"===p.mode&&(0,a.jsx)("p",{className:"text-xs text-text-muted",children:"Pings right after the 5h quota window resets, so a new window starts immediately."}),"schedule"===p.mode&&(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,a.jsx)("p",{className:"text-xs text-text-muted",children:"Pings at fixed local times so the 5h windows align with your workday."}),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-4 sm:grid-cols-3",children:[(0,a.jsx)(n.pd,{label:"Anchor time",type:"time",value:p.anchor,onChange:e=>C({anchor:e.target.value}),error:g?"":"Use HH:MM",inputClassName:"ring-1 ring-black/10 dark:ring-white/15"}),(0,a.jsx)(n.pd,{label:"Window (hours)",type:"number",min:"0.5",max:"24",step:"0.5",value:p.windowHours,onChange:e=>C({windowHours:e.target.value}),error:y?"":"0.5 – 24",inputClassName:"ring-1 ring-black/10 dark:ring-white/15"}),(0,a.jsx)(n.pd,{label:"Pings per day",type:"number",min:"1",max:String(b),step:"1",value:p.slotsPerDay,onChange:e=>C({slotsPerDay:e.target.value}),error:v?"":`1 – ${b}`,hint:v?`Max ${b}`:"",inputClassName:"ring-1 ring-black/10 dark:ring-white/15"})]}),k.length>0&&(0,a.jsxs)("div",{className:"rounded-[10px] bg-surface-2 px-3 py-2.5",children:[(0,a.jsxs)("p",{className:"text-xs font-medium uppercase tracking-wide text-text-muted",children:["Daily slots (",p.timezone,")"]}),(0,a.jsx)("p",{className:"mt-1 text-sm font-medium text-text-main",children:k.join(" → ")}),(0,a.jsxs)("p",{className:"mt-1 text-xs text-text-muted",children:["Covers ",k[0]," – ",N,", then pauses until ",k[0]," next day."]})]})]})]})})}m.propTypes={isOpen:l().bool.isRequired,onClose:l().func.isRequired,onSave:l().func.isRequired,connection:l().object,reactive:l().bool,schedule:l().object}}},e=>{e.O(0,[763,5772,8105,801,1321,5497,8441,3794,7358],()=>e(e.s=85295)),_N_E=e.O()}]);
|