ktrouter 1.2.5 → 1.2.7
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/BUILD_ID +1 -1
- package/app/.next/app-path-routes-manifest.json +7 -7
- package/app/.next/build-manifest.json +3 -3
- package/app/.next/required-server-files.json +3 -3
- package/app/.next/server/app/(dashboard)/dashboard/basic-chat/page.js +2 -2
- package/app/.next/server/app/(dashboard)/dashboard/basic-chat/page.js.nft.json +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/basic-chat/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/cli-tools/[toolId]/page.js +2 -2
- package/app/.next/server/app/(dashboard)/dashboard/cli-tools/[toolId]/page.js.nft.json +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/cli-tools/[toolId]/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/cli-tools/page.js +2 -2
- package/app/.next/server/app/(dashboard)/dashboard/cli-tools/page.js.nft.json +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/cli-tools/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/combos/page.js +2 -2
- package/app/.next/server/app/(dashboard)/dashboard/combos/page.js.nft.json +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/combos/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/console-log/page.js +2 -2
- package/app/.next/server/app/(dashboard)/dashboard/console-log/page.js.nft.json +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/console-log/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/endpoint/page.js +2 -2
- package/app/.next/server/app/(dashboard)/dashboard/endpoint/page.js.nft.json +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/endpoint/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/media-providers/[kind]/[id]/page.js +2 -2
- package/app/.next/server/app/(dashboard)/dashboard/media-providers/[kind]/[id]/page.js.nft.json +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/media-providers/[kind]/[id]/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/media-providers/[kind]/page.js +2 -2
- package/app/.next/server/app/(dashboard)/dashboard/media-providers/[kind]/page.js.nft.json +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/media-providers/[kind]/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/media-providers/combo/[id]/page.js +3 -3
- package/app/.next/server/app/(dashboard)/dashboard/media-providers/combo/[id]/page.js.nft.json +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/media-providers/combo/[id]/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/media-providers/web/page.js +2 -2
- package/app/.next/server/app/(dashboard)/dashboard/media-providers/web/page.js.nft.json +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/media-providers/web/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/mitm/page.js +2 -2
- package/app/.next/server/app/(dashboard)/dashboard/mitm/page.js.nft.json +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/mitm/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/page.js +2 -2
- package/app/.next/server/app/(dashboard)/dashboard/page.js.nft.json +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/profile/page.js +2 -2
- package/app/.next/server/app/(dashboard)/dashboard/profile/page.js.nft.json +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/profile/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/providers/[id]/page.js +3 -3
- package/app/.next/server/app/(dashboard)/dashboard/providers/[id]/page.js.nft.json +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/providers/[id]/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/providers/new/page.js +2 -2
- package/app/.next/server/app/(dashboard)/dashboard/providers/new/page.js.nft.json +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/providers/new/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/providers/page.js +2 -2
- package/app/.next/server/app/(dashboard)/dashboard/providers/page.js.nft.json +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/providers/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/proxy-pools/page.js +2 -2
- package/app/.next/server/app/(dashboard)/dashboard/proxy-pools/page.js.nft.json +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/proxy-pools/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/quota/page.js +2 -2
- package/app/.next/server/app/(dashboard)/dashboard/quota/page.js.nft.json +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/quota/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/skills/page.js +2 -2
- package/app/.next/server/app/(dashboard)/dashboard/skills/page.js.nft.json +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/skills/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/translator/page.js +2 -2
- package/app/.next/server/app/(dashboard)/dashboard/translator/page.js.nft.json +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/translator/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/usage/page.js +2 -2
- package/app/.next/server/app/(dashboard)/dashboard/usage/page.js.nft.json +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/usage/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/_global-error/page.js +3 -3
- package/app/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/_global-error.html +1 -1
- package/app/.next/server/app/_global-error.rsc +1 -1
- package/app/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/app/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
- package/app/.next/server/app/_global-error.segments/_global-error.segment.rsc +1 -1
- package/app/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
- package/app/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
- package/app/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/app/.next/server/app/_not-found/page.js +2 -2
- package/app/.next/server/app/_not-found/page.js.nft.json +1 -1
- package/app/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/_not-found.html +1 -1
- package/app/.next/server/app/_not-found.rsc +3 -3
- package/app/.next/server/app/_not-found.segments/_full.segment.rsc +3 -3
- package/app/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
- package/app/.next/server/app/_not-found.segments/_index.segment.rsc +3 -3
- package/app/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
- package/app/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
- package/app/.next/server/app/_not-found.segments/_tree.segment.rsc +1 -1
- package/app/.next/server/app/api/auth/login/route.js +1 -1
- package/app/.next/server/app/api/auth/login/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/auth/logout/route.js +1 -1
- package/app/.next/server/app/api/auth/logout/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/auth/oidc/callback/route.js +1 -1
- package/app/.next/server/app/api/auth/oidc/callback/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/auth/oidc/start/route.js +1 -1
- package/app/.next/server/app/api/auth/oidc/start/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/auth/oidc/test/route.js +1 -1
- package/app/.next/server/app/api/auth/oidc/test/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/auth/status/route.js +1 -1
- package/app/.next/server/app/api/auth/status/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/cli-tools/all-statuses/route.js +4 -4
- package/app/.next/server/app/api/cli-tools/all-statuses/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/cli-tools/antigravity-mitm/alias/route.js +2 -2
- package/app/.next/server/app/api/cli-tools/antigravity-mitm/alias/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/cli-tools/antigravity-mitm/route.js +1 -1
- package/app/.next/server/app/api/cli-tools/antigravity-mitm/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/cli-tools/claude-settings/route.js +2 -2
- package/app/.next/server/app/api/cli-tools/claude-settings/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/cli-tools/cline-settings/route.js +2 -2
- package/app/.next/server/app/api/cli-tools/cline-settings/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/cli-tools/codex-settings/route.js +1 -1
- package/app/.next/server/app/api/cli-tools/codex-settings/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/cli-tools/copilot-settings/route.js +2 -2
- package/app/.next/server/app/api/cli-tools/copilot-settings/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/cli-tools/cowork-mcp-registry/route.js +2 -2
- package/app/.next/server/app/api/cli-tools/cowork-mcp-registry/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/cli-tools/cowork-mcp-tools/route.js +2 -2
- package/app/.next/server/app/api/cli-tools/cowork-mcp-tools/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/cli-tools/cowork-settings/route.js +2 -2
- package/app/.next/server/app/api/cli-tools/cowork-settings/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/cli-tools/deepseek-tui-settings/route.js +3 -3
- package/app/.next/server/app/api/cli-tools/deepseek-tui-settings/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/cli-tools/droid-settings/route.js +2 -2
- package/app/.next/server/app/api/cli-tools/droid-settings/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/cli-tools/hermes-settings/route.js +2 -2
- package/app/.next/server/app/api/cli-tools/hermes-settings/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/cli-tools/jcode-settings/route.js +2 -2
- package/app/.next/server/app/api/cli-tools/jcode-settings/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/cli-tools/kilo-settings/route.js +2 -2
- package/app/.next/server/app/api/cli-tools/kilo-settings/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/cli-tools/openclaw-settings/route.js +2 -2
- package/app/.next/server/app/api/cli-tools/openclaw-settings/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/cli-tools/opencode-settings/route.js +2 -2
- package/app/.next/server/app/api/cli-tools/opencode-settings/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/cloud/auth/route.js +1 -1
- package/app/.next/server/app/api/cloud/auth/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/cloud/credentials/update/route.js +1 -1
- package/app/.next/server/app/api/cloud/credentials/update/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/cloud/model/resolve/route.js +1 -1
- package/app/.next/server/app/api/cloud/model/resolve/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/cloud/models/alias/route.js +1 -1
- package/app/.next/server/app/api/cloud/models/alias/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/combos/[id]/route.js +1 -1
- package/app/.next/server/app/api/combos/[id]/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/combos/route.js +1 -1
- package/app/.next/server/app/api/combos/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/health/route.js +1 -1
- package/app/.next/server/app/api/health/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/init/route.js +1 -1
- package/app/.next/server/app/api/init/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/keys/[id]/route.js +1 -1
- package/app/.next/server/app/api/keys/[id]/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/keys/route.js +1 -1
- package/app/.next/server/app/api/keys/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/locale/route.js +1 -1
- package/app/.next/server/app/api/locale/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/mcp/[plugin]/message/route.js +1 -1
- package/app/.next/server/app/api/mcp/[plugin]/message/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/mcp/[plugin]/sse/route.js +2 -2
- package/app/.next/server/app/api/mcp/[plugin]/sse/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/media/download/route.js +1 -1
- package/app/.next/server/app/api/media/download/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/media-providers/tts/deepgram/voices/route.js +1 -1
- package/app/.next/server/app/api/media-providers/tts/deepgram/voices/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/media-providers/tts/elevenlabs/voices/route.js +1 -1
- package/app/.next/server/app/api/media-providers/tts/elevenlabs/voices/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/media-providers/tts/inworld/voices/route.js +1 -1
- package/app/.next/server/app/api/media-providers/tts/inworld/voices/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/media-providers/tts/minimax/voices/route.js +1 -1
- package/app/.next/server/app/api/media-providers/tts/minimax/voices/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/media-providers/tts/voices/route.js +1 -1
- package/app/.next/server/app/api/media-providers/tts/voices/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/models/alias/route.js +1 -1
- package/app/.next/server/app/api/models/alias/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/models/availability/route.js +1 -1
- package/app/.next/server/app/api/models/availability/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/models/custom/route.js +1 -1
- package/app/.next/server/app/api/models/custom/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/models/disabled/route.js +1 -1
- package/app/.next/server/app/api/models/disabled/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/models/route.js +1 -1
- package/app/.next/server/app/api/models/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/models/test/route.js +1 -1
- package/app/.next/server/app/api/models/test/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/oauth/[provider]/[action]/route.js +1 -1
- package/app/.next/server/app/api/oauth/[provider]/[action]/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/oauth/codex/import/route.js +1 -1
- package/app/.next/server/app/api/oauth/codex/import/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/oauth/cursor/auto-import/route.js +2 -2
- package/app/.next/server/app/api/oauth/cursor/auto-import/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/oauth/cursor/import/route.js +1 -1
- package/app/.next/server/app/api/oauth/cursor/import/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/oauth/gitlab/pat/route.js +1 -1
- package/app/.next/server/app/api/oauth/gitlab/pat/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/oauth/iflow/cookie/route.js +1 -1
- package/app/.next/server/app/api/oauth/iflow/cookie/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/oauth/kiro/auto-import/route.js +1 -1
- package/app/.next/server/app/api/oauth/kiro/auto-import/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/oauth/kiro/browser-login/route.js +2 -2
- package/app/.next/server/app/api/oauth/kiro/browser-login/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/oauth/kiro/import/route.js +1 -1
- package/app/.next/server/app/api/oauth/kiro/import/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/oauth/kiro/social-authorize/route.js +1 -1
- package/app/.next/server/app/api/oauth/kiro/social-authorize/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/oauth/kiro/social-exchange/route.js +1 -1
- package/app/.next/server/app/api/oauth/kiro/social-exchange/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/pricing/route.js +1 -1
- package/app/.next/server/app/api/pricing/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/provider-nodes/[id]/route.js +1 -1
- package/app/.next/server/app/api/provider-nodes/[id]/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/provider-nodes/route.js +1 -1
- package/app/.next/server/app/api/provider-nodes/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/provider-nodes/validate/route.js +1 -1
- package/app/.next/server/app/api/provider-nodes/validate/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/providers/[id]/models/route.js +1 -1
- package/app/.next/server/app/api/providers/[id]/models/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/providers/[id]/route.js +1 -1
- package/app/.next/server/app/api/providers/[id]/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/providers/[id]/sync-models/route.js +1 -1
- package/app/.next/server/app/api/providers/[id]/sync-models/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/providers/[id]/test/route.js +1 -1
- package/app/.next/server/app/api/providers/[id]/test/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/providers/[id]/test-models/route.js +1 -1
- package/app/.next/server/app/api/providers/[id]/test-models/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/providers/client/route.js +1 -1
- package/app/.next/server/app/api/providers/client/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/providers/export/route.js +1 -1
- package/app/.next/server/app/api/providers/export/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/providers/import/route.js +1 -1
- package/app/.next/server/app/api/providers/import/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/providers/kilo/free-models/route.js +1 -1
- package/app/.next/server/app/api/providers/kilo/free-models/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/providers/route.js +1 -1
- package/app/.next/server/app/api/providers/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/providers/suggested-models/route.js +1 -1
- package/app/.next/server/app/api/providers/suggested-models/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/providers/test-batch/route.js +1 -1
- package/app/.next/server/app/api/providers/test-batch/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/providers/validate/route.js +1 -1
- package/app/.next/server/app/api/providers/validate/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/proxy-pools/[id]/route.js +1 -1
- package/app/.next/server/app/api/proxy-pools/[id]/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/proxy-pools/[id]/test/route.js +1 -1
- package/app/.next/server/app/api/proxy-pools/[id]/test/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/proxy-pools/route.js +1 -1
- package/app/.next/server/app/api/proxy-pools/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/proxy-pools/vercel-deploy/route.js +2 -2
- package/app/.next/server/app/api/proxy-pools/vercel-deploy/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/settings/database/route.js +1 -1
- package/app/.next/server/app/api/settings/database/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/settings/proxy-test/route.js +1 -1
- package/app/.next/server/app/api/settings/proxy-test/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/settings/require-login/route.js +1 -1
- package/app/.next/server/app/api/settings/require-login/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/settings/route.js +1 -1
- package/app/.next/server/app/api/settings/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/shutdown/route.js +1 -1
- package/app/.next/server/app/api/shutdown/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/tags/route.js +1 -1
- package/app/.next/server/app/api/tags/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/translator/console-logs/route.js +1 -1
- package/app/.next/server/app/api/translator/console-logs/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/translator/console-logs/stream/route.js +2 -2
- package/app/.next/server/app/api/translator/console-logs/stream/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/translator/load/route.js +1 -1
- package/app/.next/server/app/api/translator/load/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/translator/save/route.js +1 -1
- package/app/.next/server/app/api/translator/save/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/translator/send/route.js +1 -1
- package/app/.next/server/app/api/translator/send/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/translator/translate/route.js +1 -1
- package/app/.next/server/app/api/translator/translate/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/update/check/route.js +1 -1
- package/app/.next/server/app/api/update/check/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/usage/[connectionId]/route.js +1 -1
- package/app/.next/server/app/api/usage/[connectionId]/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/usage/chart/route.js +1 -1
- package/app/.next/server/app/api/usage/chart/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/usage/history/route.js +1 -1
- package/app/.next/server/app/api/usage/history/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/usage/providers/route.js +1 -1
- package/app/.next/server/app/api/usage/providers/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/usage/request-details/route.js +1 -1
- package/app/.next/server/app/api/usage/request-details/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/usage/request-logs/route.js +1 -1
- package/app/.next/server/app/api/usage/request-logs/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/usage/stats/route.js +1 -1
- package/app/.next/server/app/api/usage/stats/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/usage/stream/route.js +2 -2
- package/app/.next/server/app/api/usage/stream/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/v1/api/chat/route.js +1 -1
- package/app/.next/server/app/api/v1/api/chat/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/v1/audio/speech/route.js +1 -1
- package/app/.next/server/app/api/v1/audio/speech/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/v1/audio/transcriptions/route.js +1 -1
- package/app/.next/server/app/api/v1/audio/transcriptions/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/v1/audio/voices/route.js +1 -1
- package/app/.next/server/app/api/v1/audio/voices/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/v1/chat/completions/route.js +1 -1
- package/app/.next/server/app/api/v1/chat/completions/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/v1/chatgpt-web/image/[id]/route.js +1 -1
- package/app/.next/server/app/api/v1/chatgpt-web/image/[id]/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/v1/embeddings/route.js +1 -1
- package/app/.next/server/app/api/v1/embeddings/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/v1/images/generations/route.js +2 -2
- package/app/.next/server/app/api/v1/images/generations/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/v1/messages/count_tokens/route.js +1 -1
- package/app/.next/server/app/api/v1/messages/count_tokens/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/v1/messages/route.js +1 -1
- package/app/.next/server/app/api/v1/messages/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/v1/models/[kind]/route.js +1 -1
- package/app/.next/server/app/api/v1/models/[kind]/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/v1/models/info/route.js +1 -1
- package/app/.next/server/app/api/v1/models/info/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/v1/models/route.js +1 -1
- package/app/.next/server/app/api/v1/models/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/v1/responses/compact/route.js +1 -1
- package/app/.next/server/app/api/v1/responses/compact/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/v1/responses/route.js +1 -1
- package/app/.next/server/app/api/v1/responses/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/v1/route.js +1 -1
- package/app/.next/server/app/api/v1/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/v1/search/route.js +1 -1
- package/app/.next/server/app/api/v1/search/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/v1/video/generations/route.js +1 -1
- package/app/.next/server/app/api/v1/video/generations/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/v1/web/fetch/route.js +1 -1
- package/app/.next/server/app/api/v1/web/fetch/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/v1beta/models/[...path]/route.js +1 -1
- package/app/.next/server/app/api/v1beta/models/[...path]/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/v1beta/models/route.js +1 -1
- package/app/.next/server/app/api/v1beta/models/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/callback/page.js +2 -2
- package/app/.next/server/app/callback/page.js.nft.json +1 -1
- package/app/.next/server/app/callback/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/callback.html +1 -1
- package/app/.next/server/app/callback.rsc +4 -4
- package/app/.next/server/app/callback.segments/_full.segment.rsc +4 -4
- package/app/.next/server/app/callback.segments/_head.segment.rsc +1 -1
- package/app/.next/server/app/callback.segments/_index.segment.rsc +3 -3
- package/app/.next/server/app/callback.segments/_tree.segment.rsc +1 -1
- package/app/.next/server/app/callback.segments/callback/__PAGE__.segment.rsc +2 -2
- package/app/.next/server/app/callback.segments/callback.segment.rsc +1 -1
- package/app/.next/server/app/dashboard/basic-chat.html +1 -1
- package/app/.next/server/app/dashboard/basic-chat.rsc +5 -5
- package/app/.next/server/app/dashboard/basic-chat.segments/!KGRhc2hib2FyZCk/dashboard/basic-chat/__PAGE__.segment.rsc +2 -2
- package/app/.next/server/app/dashboard/basic-chat.segments/!KGRhc2hib2FyZCk/dashboard/basic-chat.segment.rsc +1 -1
- package/app/.next/server/app/dashboard/basic-chat.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
- package/app/.next/server/app/dashboard/basic-chat.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
- package/app/.next/server/app/dashboard/basic-chat.segments/_full.segment.rsc +5 -5
- package/app/.next/server/app/dashboard/basic-chat.segments/_head.segment.rsc +1 -1
- package/app/.next/server/app/dashboard/basic-chat.segments/_index.segment.rsc +3 -3
- package/app/.next/server/app/dashboard/basic-chat.segments/_tree.segment.rsc +1 -1
- package/app/.next/server/app/dashboard/cli-tools.html +1 -1
- package/app/.next/server/app/dashboard/cli-tools.rsc +5 -5
- package/app/.next/server/app/dashboard/cli-tools.segments/!KGRhc2hib2FyZCk/dashboard/cli-tools/__PAGE__.segment.rsc +2 -2
- package/app/.next/server/app/dashboard/cli-tools.segments/!KGRhc2hib2FyZCk/dashboard/cli-tools.segment.rsc +1 -1
- package/app/.next/server/app/dashboard/cli-tools.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
- package/app/.next/server/app/dashboard/cli-tools.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
- package/app/.next/server/app/dashboard/cli-tools.segments/_full.segment.rsc +5 -5
- package/app/.next/server/app/dashboard/cli-tools.segments/_head.segment.rsc +1 -1
- package/app/.next/server/app/dashboard/cli-tools.segments/_index.segment.rsc +3 -3
- package/app/.next/server/app/dashboard/cli-tools.segments/_tree.segment.rsc +1 -1
- package/app/.next/server/app/dashboard/combos.html +1 -1
- package/app/.next/server/app/dashboard/combos.rsc +5 -5
- package/app/.next/server/app/dashboard/combos.segments/!KGRhc2hib2FyZCk/dashboard/combos/__PAGE__.segment.rsc +2 -2
- package/app/.next/server/app/dashboard/combos.segments/!KGRhc2hib2FyZCk/dashboard/combos.segment.rsc +1 -1
- package/app/.next/server/app/dashboard/combos.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
- package/app/.next/server/app/dashboard/combos.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
- package/app/.next/server/app/dashboard/combos.segments/_full.segment.rsc +5 -5
- package/app/.next/server/app/dashboard/combos.segments/_head.segment.rsc +1 -1
- package/app/.next/server/app/dashboard/combos.segments/_index.segment.rsc +3 -3
- package/app/.next/server/app/dashboard/combos.segments/_tree.segment.rsc +1 -1
- package/app/.next/server/app/dashboard/endpoint.html +1 -1
- package/app/.next/server/app/dashboard/endpoint.rsc +5 -5
- package/app/.next/server/app/dashboard/endpoint.segments/!KGRhc2hib2FyZCk/dashboard/endpoint/__PAGE__.segment.rsc +2 -2
- package/app/.next/server/app/dashboard/endpoint.segments/!KGRhc2hib2FyZCk/dashboard/endpoint.segment.rsc +1 -1
- package/app/.next/server/app/dashboard/endpoint.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
- package/app/.next/server/app/dashboard/endpoint.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
- package/app/.next/server/app/dashboard/endpoint.segments/_full.segment.rsc +5 -5
- package/app/.next/server/app/dashboard/endpoint.segments/_head.segment.rsc +1 -1
- package/app/.next/server/app/dashboard/endpoint.segments/_index.segment.rsc +3 -3
- package/app/.next/server/app/dashboard/endpoint.segments/_tree.segment.rsc +1 -1
- package/app/.next/server/app/dashboard/media-providers/web.html +1 -1
- package/app/.next/server/app/dashboard/media-providers/web.rsc +5 -5
- package/app/.next/server/app/dashboard/media-providers/web.segments/!KGRhc2hib2FyZCk/dashboard/media-providers/web/__PAGE__.segment.rsc +2 -2
- package/app/.next/server/app/dashboard/media-providers/web.segments/!KGRhc2hib2FyZCk/dashboard/media-providers/web.segment.rsc +1 -1
- package/app/.next/server/app/dashboard/media-providers/web.segments/!KGRhc2hib2FyZCk/dashboard/media-providers.segment.rsc +1 -1
- package/app/.next/server/app/dashboard/media-providers/web.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
- package/app/.next/server/app/dashboard/media-providers/web.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
- package/app/.next/server/app/dashboard/media-providers/web.segments/_full.segment.rsc +5 -5
- package/app/.next/server/app/dashboard/media-providers/web.segments/_head.segment.rsc +1 -1
- package/app/.next/server/app/dashboard/media-providers/web.segments/_index.segment.rsc +3 -3
- package/app/.next/server/app/dashboard/media-providers/web.segments/_tree.segment.rsc +1 -1
- package/app/.next/server/app/dashboard/mitm.html +1 -1
- package/app/.next/server/app/dashboard/mitm.rsc +5 -5
- package/app/.next/server/app/dashboard/mitm.segments/!KGRhc2hib2FyZCk/dashboard/mitm/__PAGE__.segment.rsc +2 -2
- package/app/.next/server/app/dashboard/mitm.segments/!KGRhc2hib2FyZCk/dashboard/mitm.segment.rsc +1 -1
- package/app/.next/server/app/dashboard/mitm.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
- package/app/.next/server/app/dashboard/mitm.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
- package/app/.next/server/app/dashboard/mitm.segments/_full.segment.rsc +5 -5
- package/app/.next/server/app/dashboard/mitm.segments/_head.segment.rsc +1 -1
- package/app/.next/server/app/dashboard/mitm.segments/_index.segment.rsc +3 -3
- package/app/.next/server/app/dashboard/mitm.segments/_tree.segment.rsc +1 -1
- package/app/.next/server/app/dashboard/profile.html +1 -1
- package/app/.next/server/app/dashboard/profile.rsc +5 -5
- package/app/.next/server/app/dashboard/profile.segments/!KGRhc2hib2FyZCk/dashboard/profile/__PAGE__.segment.rsc +2 -2
- package/app/.next/server/app/dashboard/profile.segments/!KGRhc2hib2FyZCk/dashboard/profile.segment.rsc +1 -1
- package/app/.next/server/app/dashboard/profile.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
- package/app/.next/server/app/dashboard/profile.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
- package/app/.next/server/app/dashboard/profile.segments/_full.segment.rsc +5 -5
- package/app/.next/server/app/dashboard/profile.segments/_head.segment.rsc +1 -1
- package/app/.next/server/app/dashboard/profile.segments/_index.segment.rsc +3 -3
- package/app/.next/server/app/dashboard/profile.segments/_tree.segment.rsc +1 -1
- package/app/.next/server/app/dashboard/providers/new.html +1 -1
- package/app/.next/server/app/dashboard/providers/new.rsc +5 -5
- package/app/.next/server/app/dashboard/providers/new.segments/!KGRhc2hib2FyZCk/dashboard/providers/new/__PAGE__.segment.rsc +2 -2
- package/app/.next/server/app/dashboard/providers/new.segments/!KGRhc2hib2FyZCk/dashboard/providers/new.segment.rsc +1 -1
- package/app/.next/server/app/dashboard/providers/new.segments/!KGRhc2hib2FyZCk/dashboard/providers.segment.rsc +1 -1
- package/app/.next/server/app/dashboard/providers/new.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
- package/app/.next/server/app/dashboard/providers/new.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
- package/app/.next/server/app/dashboard/providers/new.segments/_full.segment.rsc +5 -5
- package/app/.next/server/app/dashboard/providers/new.segments/_head.segment.rsc +1 -1
- package/app/.next/server/app/dashboard/providers/new.segments/_index.segment.rsc +3 -3
- package/app/.next/server/app/dashboard/providers/new.segments/_tree.segment.rsc +1 -1
- package/app/.next/server/app/dashboard/providers.html +1 -1
- package/app/.next/server/app/dashboard/providers.rsc +5 -5
- package/app/.next/server/app/dashboard/providers.segments/!KGRhc2hib2FyZCk/dashboard/providers/__PAGE__.segment.rsc +2 -2
- package/app/.next/server/app/dashboard/providers.segments/!KGRhc2hib2FyZCk/dashboard/providers.segment.rsc +1 -1
- package/app/.next/server/app/dashboard/providers.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
- package/app/.next/server/app/dashboard/providers.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
- package/app/.next/server/app/dashboard/providers.segments/_full.segment.rsc +5 -5
- package/app/.next/server/app/dashboard/providers.segments/_head.segment.rsc +1 -1
- package/app/.next/server/app/dashboard/providers.segments/_index.segment.rsc +3 -3
- package/app/.next/server/app/dashboard/providers.segments/_tree.segment.rsc +1 -1
- package/app/.next/server/app/dashboard/proxy-pools.html +1 -1
- package/app/.next/server/app/dashboard/proxy-pools.rsc +5 -5
- package/app/.next/server/app/dashboard/proxy-pools.segments/!KGRhc2hib2FyZCk/dashboard/proxy-pools/__PAGE__.segment.rsc +2 -2
- package/app/.next/server/app/dashboard/proxy-pools.segments/!KGRhc2hib2FyZCk/dashboard/proxy-pools.segment.rsc +1 -1
- package/app/.next/server/app/dashboard/proxy-pools.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
- package/app/.next/server/app/dashboard/proxy-pools.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
- package/app/.next/server/app/dashboard/proxy-pools.segments/_full.segment.rsc +5 -5
- package/app/.next/server/app/dashboard/proxy-pools.segments/_head.segment.rsc +1 -1
- package/app/.next/server/app/dashboard/proxy-pools.segments/_index.segment.rsc +3 -3
- package/app/.next/server/app/dashboard/proxy-pools.segments/_tree.segment.rsc +1 -1
- package/app/.next/server/app/dashboard/quota.html +2 -2
- package/app/.next/server/app/dashboard/quota.rsc +6 -6
- package/app/.next/server/app/dashboard/quota.segments/!KGRhc2hib2FyZCk/dashboard/quota/__PAGE__.segment.rsc +3 -3
- package/app/.next/server/app/dashboard/quota.segments/!KGRhc2hib2FyZCk/dashboard/quota.segment.rsc +1 -1
- package/app/.next/server/app/dashboard/quota.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
- package/app/.next/server/app/dashboard/quota.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
- package/app/.next/server/app/dashboard/quota.segments/_full.segment.rsc +6 -6
- package/app/.next/server/app/dashboard/quota.segments/_head.segment.rsc +1 -1
- package/app/.next/server/app/dashboard/quota.segments/_index.segment.rsc +3 -3
- package/app/.next/server/app/dashboard/quota.segments/_tree.segment.rsc +1 -1
- package/app/.next/server/app/dashboard/settings/pricing/page.js +2 -2
- package/app/.next/server/app/dashboard/settings/pricing/page.js.nft.json +1 -1
- package/app/.next/server/app/dashboard/settings/pricing/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/dashboard/settings/pricing.html +1 -1
- package/app/.next/server/app/dashboard/settings/pricing.rsc +4 -4
- package/app/.next/server/app/dashboard/settings/pricing.segments/_full.segment.rsc +4 -4
- package/app/.next/server/app/dashboard/settings/pricing.segments/_head.segment.rsc +1 -1
- package/app/.next/server/app/dashboard/settings/pricing.segments/_index.segment.rsc +3 -3
- package/app/.next/server/app/dashboard/settings/pricing.segments/_tree.segment.rsc +1 -1
- package/app/.next/server/app/dashboard/settings/pricing.segments/dashboard/settings/pricing/__PAGE__.segment.rsc +2 -2
- package/app/.next/server/app/dashboard/settings/pricing.segments/dashboard/settings/pricing.segment.rsc +1 -1
- package/app/.next/server/app/dashboard/settings/pricing.segments/dashboard/settings.segment.rsc +1 -1
- package/app/.next/server/app/dashboard/settings/pricing.segments/dashboard.segment.rsc +1 -1
- package/app/.next/server/app/dashboard/skills.html +1 -1
- package/app/.next/server/app/dashboard/skills.rsc +5 -5
- package/app/.next/server/app/dashboard/skills.segments/!KGRhc2hib2FyZCk/dashboard/skills/__PAGE__.segment.rsc +2 -2
- package/app/.next/server/app/dashboard/skills.segments/!KGRhc2hib2FyZCk/dashboard/skills.segment.rsc +1 -1
- package/app/.next/server/app/dashboard/skills.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
- package/app/.next/server/app/dashboard/skills.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
- package/app/.next/server/app/dashboard/skills.segments/_full.segment.rsc +5 -5
- package/app/.next/server/app/dashboard/skills.segments/_head.segment.rsc +1 -1
- package/app/.next/server/app/dashboard/skills.segments/_index.segment.rsc +3 -3
- package/app/.next/server/app/dashboard/skills.segments/_tree.segment.rsc +1 -1
- package/app/.next/server/app/dashboard/translator.html +1 -1
- package/app/.next/server/app/dashboard/translator.rsc +5 -5
- package/app/.next/server/app/dashboard/translator.segments/!KGRhc2hib2FyZCk/dashboard/translator/__PAGE__.segment.rsc +2 -2
- package/app/.next/server/app/dashboard/translator.segments/!KGRhc2hib2FyZCk/dashboard/translator.segment.rsc +1 -1
- package/app/.next/server/app/dashboard/translator.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
- package/app/.next/server/app/dashboard/translator.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
- package/app/.next/server/app/dashboard/translator.segments/_full.segment.rsc +5 -5
- package/app/.next/server/app/dashboard/translator.segments/_head.segment.rsc +1 -1
- package/app/.next/server/app/dashboard/translator.segments/_index.segment.rsc +3 -3
- package/app/.next/server/app/dashboard/translator.segments/_tree.segment.rsc +1 -1
- package/app/.next/server/app/dashboard/usage.html +1 -1
- package/app/.next/server/app/dashboard/usage.rsc +5 -5
- package/app/.next/server/app/dashboard/usage.segments/!KGRhc2hib2FyZCk/dashboard/usage/__PAGE__.segment.rsc +2 -2
- package/app/.next/server/app/dashboard/usage.segments/!KGRhc2hib2FyZCk/dashboard/usage.segment.rsc +1 -1
- package/app/.next/server/app/dashboard/usage.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
- package/app/.next/server/app/dashboard/usage.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
- package/app/.next/server/app/dashboard/usage.segments/_full.segment.rsc +5 -5
- package/app/.next/server/app/dashboard/usage.segments/_head.segment.rsc +1 -1
- package/app/.next/server/app/dashboard/usage.segments/_index.segment.rsc +3 -3
- package/app/.next/server/app/dashboard/usage.segments/_tree.segment.rsc +1 -1
- package/app/.next/server/app/dashboard.html +1 -1
- package/app/.next/server/app/dashboard.rsc +5 -5
- package/app/.next/server/app/dashboard.segments/!KGRhc2hib2FyZCk/dashboard/__PAGE__.segment.rsc +2 -2
- package/app/.next/server/app/dashboard.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
- package/app/.next/server/app/dashboard.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
- package/app/.next/server/app/dashboard.segments/_full.segment.rsc +5 -5
- package/app/.next/server/app/dashboard.segments/_head.segment.rsc +1 -1
- package/app/.next/server/app/dashboard.segments/_index.segment.rsc +3 -3
- package/app/.next/server/app/dashboard.segments/_tree.segment.rsc +1 -1
- package/app/.next/server/app/favicon.ico/route.js +1 -1
- package/app/.next/server/app/index.html +1 -1
- package/app/.next/server/app/index.rsc +3 -3
- package/app/.next/server/app/index.segments/__PAGE__.segment.rsc +1 -1
- package/app/.next/server/app/index.segments/_full.segment.rsc +3 -3
- package/app/.next/server/app/index.segments/_head.segment.rsc +1 -1
- package/app/.next/server/app/index.segments/_index.segment.rsc +3 -3
- package/app/.next/server/app/index.segments/_tree.segment.rsc +1 -1
- package/app/.next/server/app/landing/page.js +2 -2
- package/app/.next/server/app/landing/page.js.nft.json +1 -1
- package/app/.next/server/app/landing/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/landing.html +1 -1
- package/app/.next/server/app/landing.rsc +4 -4
- package/app/.next/server/app/landing.segments/_full.segment.rsc +4 -4
- package/app/.next/server/app/landing.segments/_head.segment.rsc +1 -1
- package/app/.next/server/app/landing.segments/_index.segment.rsc +3 -3
- package/app/.next/server/app/landing.segments/_tree.segment.rsc +1 -1
- package/app/.next/server/app/landing.segments/landing/__PAGE__.segment.rsc +2 -2
- package/app/.next/server/app/landing.segments/landing.segment.rsc +1 -1
- package/app/.next/server/app/login/page.js +2 -2
- package/app/.next/server/app/login/page.js.nft.json +1 -1
- package/app/.next/server/app/login/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/login.html +1 -1
- package/app/.next/server/app/login.rsc +4 -4
- package/app/.next/server/app/login.segments/_full.segment.rsc +4 -4
- package/app/.next/server/app/login.segments/_head.segment.rsc +1 -1
- package/app/.next/server/app/login.segments/_index.segment.rsc +3 -3
- package/app/.next/server/app/login.segments/_tree.segment.rsc +1 -1
- package/app/.next/server/app/login.segments/login/__PAGE__.segment.rsc +2 -2
- package/app/.next/server/app/login.segments/login.segment.rsc +1 -1
- package/app/.next/server/app/manifest.webmanifest/route.js +2 -2
- package/app/.next/server/app/manifest.webmanifest/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/page.js +2 -2
- package/app/.next/server/app/page.js.nft.json +1 -1
- package/app/.next/server/app/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app-paths-manifest.json +7 -7
- package/app/.next/server/chunks/2029.js +1 -1
- package/app/.next/server/chunks/2304.js +1 -0
- package/app/.next/server/chunks/3110.js +1 -1
- package/app/.next/server/chunks/319.js +3 -3
- package/app/.next/server/chunks/4746.js +1 -1
- package/app/.next/server/chunks/4820.js +1 -1
- package/app/.next/server/chunks/5718.js +1 -1
- package/app/.next/server/chunks/5802.js +1 -0
- package/app/.next/server/chunks/6084.js +1 -1
- package/app/.next/server/chunks/6942.js +1 -0
- package/app/.next/server/chunks/7482.js +2 -2
- package/app/.next/server/middleware-build-manifest.js +1 -1
- package/app/.next/server/middleware.js +3 -3
- package/app/.next/server/pages/404.html +1 -1
- package/app/.next/server/pages/500.html +1 -1
- package/app/.next/server/server-reference-manifest.js +1 -1
- package/app/.next/server/server-reference-manifest.json +1 -1
- package/app/{.next-cli-build/static/chunks/1321-3eebd6a4eea851e4.js → .next/static/chunks/1321-5cf5c97b5c73875b.js} +1 -1
- package/app/.next/static/chunks/app/(dashboard)/dashboard/basic-chat/page-2fb4c939acddfbb7.js +1 -0
- package/app/.next/static/chunks/app/(dashboard)/dashboard/cli-tools/[toolId]/{page-05b0777df2a6420f.js → page-fed21a827a4bb3e7.js} +1 -1
- package/app/.next/static/chunks/app/(dashboard)/dashboard/cli-tools/{page-2f0c02b6169a110a.js → page-c17f2e0c1008c507.js} +1 -1
- package/app/.next/static/chunks/app/(dashboard)/dashboard/combos/page-3521b273155b28c0.js +1 -0
- package/app/.next/static/chunks/app/(dashboard)/dashboard/console-log/page-d476a9617cd07062.js +1 -0
- package/app/.next/static/chunks/app/(dashboard)/dashboard/endpoint/page-b66b5afde6f6a8a5.js +1 -0
- package/app/.next/static/chunks/app/(dashboard)/dashboard/media-providers/[kind]/[id]/{page-0069897df5ad4c14.js → page-fa4d84f79b182d78.js} +2 -2
- package/app/.next/static/chunks/app/(dashboard)/dashboard/media-providers/[kind]/page-08083cca61db2020.js +1 -0
- package/app/.next/static/chunks/app/(dashboard)/dashboard/media-providers/combo/[id]/{page-8c377a4332874fe4.js → page-0925a35716913fa5.js} +2 -2
- package/app/.next/static/chunks/app/(dashboard)/dashboard/media-providers/web/page-ec62ab7bfc6288d4.js +1 -0
- package/app/.next/static/chunks/app/(dashboard)/dashboard/mitm/{page-320c432152003c09.js → page-0150e438137c5974.js} +1 -1
- package/app/.next/static/chunks/app/(dashboard)/dashboard/page-b66b5afde6f6a8a5.js +1 -0
- package/app/.next/static/chunks/app/(dashboard)/dashboard/profile/page-542f33955bbdaad5.js +1 -0
- package/app/.next/static/chunks/app/(dashboard)/dashboard/providers/[id]/{page-990f7a655b170757.js → page-40a2f75a78baf92d.js} +1 -1
- package/app/.next/static/chunks/app/(dashboard)/dashboard/providers/new/{page-54886878afdbc216.js → page-bdefb6c8f88f7f2e.js} +1 -1
- package/app/.next/static/chunks/app/(dashboard)/dashboard/providers/page-e3ff638f08712caa.js +1 -0
- package/app/{.next-cli-build/static/chunks/app/(dashboard)/dashboard/proxy-pools/page-da705aa383019f4b.js → .next/static/chunks/app/(dashboard)/dashboard/proxy-pools/page-a3f6ab12fd089a24.js} +2 -2
- package/app/.next/static/chunks/app/(dashboard)/dashboard/quota/{page-1ad16b0309e214ac.js → page-98547bd1da2000d0.js} +1 -1
- package/app/.next/static/chunks/app/(dashboard)/dashboard/skills/page-fd227f3b40d28088.js +1 -0
- package/app/.next/static/chunks/app/(dashboard)/dashboard/translator/page-669d0d0a27c5572f.js +1 -0
- package/app/.next/static/chunks/app/(dashboard)/dashboard/usage/page-4bfb66364f9fce07.js +1 -0
- package/app/.next/static/chunks/app/(dashboard)/{layout-297b038d45f7d6bb.js → layout-868ed721c4f248da.js} +1 -1
- package/app/.next/static/chunks/app/_not-found/page-c3191fbf953a8992.js +1 -0
- package/app/.next/static/chunks/app/callback/page-b5d488ece23e40fe.js +1 -0
- package/app/.next/static/chunks/app/dashboard/settings/pricing/page-356efde6ea2aec77.js +1 -0
- package/app/{.next-cli-build/static/chunks/app/landing/page-2461168fb59fbc7f.js → .next/static/chunks/app/landing/page-c97c44ade7f2bd7a.js} +1 -1
- package/app/.next/static/chunks/app/layout-6abe63d2f76d785d.js +1 -0
- package/app/.next/static/chunks/app/login/{page-ce242826dfda53f2.js → page-4b8cdc668f7c1188.js} +1 -1
- package/app/.next/static/chunks/{main-app-914c450e94817d03.js → main-app-a489faab3ab40ebd.js} +1 -1
- package/app/.next/static/chunks/next/dist/client/components/builtin/global-error-50a8299adf165450.js +1 -0
- package/app/{.next/static/chunks/1321-3eebd6a4eea851e4.js → .next-cli-build/static/chunks/1321-5cf5c97b5c73875b.js} +1 -1
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/basic-chat/page-2fb4c939acddfbb7.js +1 -0
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/cli-tools/[toolId]/{page-05b0777df2a6420f.js → page-fed21a827a4bb3e7.js} +1 -1
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/cli-tools/{page-2f0c02b6169a110a.js → page-c17f2e0c1008c507.js} +1 -1
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/combos/page-3521b273155b28c0.js +1 -0
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/console-log/page-d476a9617cd07062.js +1 -0
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/endpoint/page-b66b5afde6f6a8a5.js +1 -0
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/media-providers/[kind]/[id]/{page-0069897df5ad4c14.js → page-fa4d84f79b182d78.js} +2 -2
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/media-providers/[kind]/page-08083cca61db2020.js +1 -0
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/media-providers/combo/[id]/{page-8c377a4332874fe4.js → page-0925a35716913fa5.js} +2 -2
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/media-providers/web/page-ec62ab7bfc6288d4.js +1 -0
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/mitm/{page-320c432152003c09.js → page-0150e438137c5974.js} +1 -1
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/page-b66b5afde6f6a8a5.js +1 -0
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/profile/page-542f33955bbdaad5.js +1 -0
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/providers/[id]/{page-990f7a655b170757.js → page-40a2f75a78baf92d.js} +1 -1
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/providers/new/{page-54886878afdbc216.js → page-bdefb6c8f88f7f2e.js} +1 -1
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/providers/page-e3ff638f08712caa.js +1 -0
- package/app/{.next/static/chunks/app/(dashboard)/dashboard/proxy-pools/page-da705aa383019f4b.js → .next-cli-build/static/chunks/app/(dashboard)/dashboard/proxy-pools/page-a3f6ab12fd089a24.js} +2 -2
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/quota/{page-1ad16b0309e214ac.js → page-98547bd1da2000d0.js} +1 -1
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/skills/page-fd227f3b40d28088.js +1 -0
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/translator/page-669d0d0a27c5572f.js +1 -0
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/usage/page-4bfb66364f9fce07.js +1 -0
- package/app/.next-cli-build/static/chunks/app/(dashboard)/{layout-297b038d45f7d6bb.js → layout-868ed721c4f248da.js} +1 -1
- package/app/.next-cli-build/static/chunks/app/_not-found/page-c3191fbf953a8992.js +1 -0
- package/app/.next-cli-build/static/chunks/app/callback/page-b5d488ece23e40fe.js +1 -0
- package/app/.next-cli-build/static/chunks/app/dashboard/settings/pricing/page-356efde6ea2aec77.js +1 -0
- package/app/{.next/static/chunks/app/landing/page-2461168fb59fbc7f.js → .next-cli-build/static/chunks/app/landing/page-c97c44ade7f2bd7a.js} +1 -1
- package/app/.next-cli-build/static/chunks/app/layout-6abe63d2f76d785d.js +1 -0
- package/app/.next-cli-build/static/chunks/app/login/{page-ce242826dfda53f2.js → page-4b8cdc668f7c1188.js} +1 -1
- package/app/.next-cli-build/static/chunks/{main-app-914c450e94817d03.js → main-app-a489faab3ab40ebd.js} +1 -1
- package/app/.next-cli-build/static/chunks/next/dist/client/components/builtin/global-error-50a8299adf165450.js +1 -0
- package/app/package.json +1 -1
- package/app/server.js +1 -1
- package/app/src/mitm/server.js +31 -31
- package/package.json +1 -1
- package/app/.next/server/chunks/1526.js +0 -1
- package/app/.next/server/chunks/250.js +0 -1
- package/app/.next/server/chunks/6750.js +0 -1
- package/app/.next/static/chunks/app/(dashboard)/dashboard/basic-chat/page-a0a8d98397b7ca72.js +0 -1
- package/app/.next/static/chunks/app/(dashboard)/dashboard/combos/page-75c3e40efcd0c885.js +0 -1
- package/app/.next/static/chunks/app/(dashboard)/dashboard/console-log/page-0e6ef3c2c5a8f3cc.js +0 -1
- package/app/.next/static/chunks/app/(dashboard)/dashboard/endpoint/page-6887eb40c91902b7.js +0 -1
- package/app/.next/static/chunks/app/(dashboard)/dashboard/media-providers/[kind]/page-50845ea95967abce.js +0 -1
- package/app/.next/static/chunks/app/(dashboard)/dashboard/media-providers/web/page-f6ef4eef0f416702.js +0 -1
- package/app/.next/static/chunks/app/(dashboard)/dashboard/page-6887eb40c91902b7.js +0 -1
- package/app/.next/static/chunks/app/(dashboard)/dashboard/profile/page-138e1c46accc056f.js +0 -1
- package/app/.next/static/chunks/app/(dashboard)/dashboard/providers/page-7348a53c1dd3d2f9.js +0 -1
- package/app/.next/static/chunks/app/(dashboard)/dashboard/skills/page-d3877492b08af072.js +0 -1
- package/app/.next/static/chunks/app/(dashboard)/dashboard/translator/page-e38a8c16b9fd9a18.js +0 -1
- package/app/.next/static/chunks/app/(dashboard)/dashboard/usage/page-a9e59eed3cf5a601.js +0 -1
- package/app/.next/static/chunks/app/_not-found/page-5c2a1336b39b2dde.js +0 -1
- package/app/.next/static/chunks/app/callback/page-48be92cc88223eb6.js +0 -1
- package/app/.next/static/chunks/app/dashboard/settings/pricing/page-06a8d864ae01d4a7.js +0 -1
- package/app/.next/static/chunks/app/layout-707bc0af2cad348a.js +0 -1
- package/app/.next/static/chunks/next/dist/client/components/builtin/global-error-d8ee3c482864b9da.js +0 -1
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/basic-chat/page-a0a8d98397b7ca72.js +0 -1
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/combos/page-75c3e40efcd0c885.js +0 -1
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/console-log/page-0e6ef3c2c5a8f3cc.js +0 -1
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/endpoint/page-6887eb40c91902b7.js +0 -1
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/media-providers/[kind]/page-50845ea95967abce.js +0 -1
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/media-providers/web/page-f6ef4eef0f416702.js +0 -1
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/page-6887eb40c91902b7.js +0 -1
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/profile/page-138e1c46accc056f.js +0 -1
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/providers/page-7348a53c1dd3d2f9.js +0 -1
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/skills/page-d3877492b08af072.js +0 -1
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/translator/page-e38a8c16b9fd9a18.js +0 -1
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/usage/page-a9e59eed3cf5a601.js +0 -1
- package/app/.next-cli-build/static/chunks/app/_not-found/page-5c2a1336b39b2dde.js +0 -1
- package/app/.next-cli-build/static/chunks/app/callback/page-48be92cc88223eb6.js +0 -1
- package/app/.next-cli-build/static/chunks/app/dashboard/settings/pricing/page-06a8d864ae01d4a7.js +0 -1
- package/app/.next-cli-build/static/chunks/app/layout-707bc0af2cad348a.js +0 -1
- package/app/.next-cli-build/static/chunks/next/dist/client/components/builtin/global-error-d8ee3c482864b9da.js +0 -1
- /package/app/.next/static/{7BTBL5GpW-v0RH8JGKfcn → 4cXtjNOGDIFnJc3uCEKRa}/_buildManifest.js +0 -0
- /package/app/.next/static/{7BTBL5GpW-v0RH8JGKfcn → 4cXtjNOGDIFnJc3uCEKRa}/_ssgManifest.js +0 -0
- /package/app/.next-cli-build/static/{7BTBL5GpW-v0RH8JGKfcn → 4cXtjNOGDIFnJc3uCEKRa}/_buildManifest.js +0 -0
- /package/app/.next-cli-build/static/{7BTBL5GpW-v0RH8JGKfcn → 4cXtjNOGDIFnJc3uCEKRa}/_ssgManifest.js +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[3471],{64561:(e,t,s)=>{"use strict";s.r(t),s.d(t,{default:()=>d});var a=s(95155),r=s(12115),o=s(35497),i=s(1620),l=s(31474),n=s(90620);function d(){let{theme:e,setTheme:t,isDark:s}=(0,i.D)(),[d,c]=(0,r.useState)({fallbackStrategy:"fill-first"}),[m,x]=(0,r.useState)(!0),[p,u]=(0,r.useState)({current:"",new:"",confirm:""}),[h,b]=(0,r.useState)({type:"",message:""}),[g,y]=(0,r.useState)(!1),[f,j]=(0,r.useState)(!1),[N,w]=(0,r.useState)({type:"",message:""}),[v,C]=(0,r.useState)({authMode:"password",oidcIssuerUrl:"",oidcClientId:"",oidcScopes:"openid profile email",oidcLoginLabel:"Sign in with OIDC"}),[k,S]=(0,r.useState)(""),[P,O]=(0,r.useState)({type:"",message:""}),[I,L]=(0,r.useState)(!1),[R,D]=(0,r.useState)(!1),[U,T]=(0,r.useState)({type:"",message:""}),[A,M]=(0,r.useState)("/api/auth/oidc/callback"),[E,$]=(0,r.useState)(!1),F=(0,r.useRef)(null),[q,J]=(0,r.useState)({outboundProxyEnabled:!1,outboundProxyUrl:"",outboundNoProxy:""}),[H,_]=(0,r.useState)({type:"",message:""}),[K,Z]=(0,r.useState)(!1),[B,z]=(0,r.useState)(!1);(0,r.useEffect)(()=>{fetch("/api/settings").then(e=>e.json()).then(e=>{c(e),C({authMode:e?.authMode||"password",oidcIssuerUrl:e?.oidcIssuerUrl||"",oidcClientId:e?.oidcClientId||"",oidcScopes:e?.oidcScopes||"openid profile email",oidcLoginLabel:e?.oidcLoginLabel||"Sign in with OIDC"}),S(""),(e?.authMode==="oidc"||e?.authMode==="both")&&$(!0),J({outboundProxyEnabled:e?.outboundProxyEnabled===!0,outboundProxyUrl:e?.outboundProxyUrl||"",outboundNoProxy:e?.outboundNoProxy||""}),x(!1)}).catch(e=>{console.error("Failed to fetch settings:",e),x(!1)})},[]),(0,r.useEffect)(()=>{M(`${window.location.origin}/api/auth/oidc/callback`)},[]);let Q=async e=>{if(e.preventDefault(),!0===d.outboundProxyEnabled){Z(!0),_({type:"",message:""});try{let e=await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({outboundProxyUrl:q.outboundProxyUrl,outboundNoProxy:q.outboundNoProxy})}),t=await e.json();e.ok?(c(e=>({...e,...t})),_({type:"success",message:"Proxy settings applied"})):_({type:"error",message:t.error||"Failed to update proxy settings"})}catch(e){_({type:"error",message:"An error occurred"})}finally{Z(!1)}}},W=async()=>{if(!0!==d.outboundProxyEnabled)return;let e=(q.outboundProxyUrl||"").trim();if(!e)return void _({type:"error",message:"Please enter a Proxy URL to test"});z(!0),_({type:"",message:""});try{let t=await fetch("/api/settings/proxy-test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({proxyUrl:e})}),s=await t.json();t.ok&&s?.ok?_({type:"success",message:`Proxy test OK (${s.status}) in ${s.elapsedMs}ms`}):_({type:"error",message:s?.error||"Proxy test failed"})}catch(e){_({type:"error",message:"An error occurred"})}finally{z(!1)}},G=async e=>{Z(!0),_({type:"",message:""});try{let t=await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({outboundProxyEnabled:e})}),s=await t.json();t.ok?(c(e=>({...e,...s})),J(e=>({...e,outboundProxyEnabled:s?.outboundProxyEnabled===!0})),_({type:"success",message:e?"Proxy enabled":"Proxy disabled"})):_({type:"error",message:s.error||"Failed to update proxy settings"})}catch(e){_({type:"error",message:"An error occurred"})}finally{Z(!1)}},V=async e=>{if(e.preventDefault(),p.new!==p.confirm)return void b({type:"error",message:"Passwords do not match"});y(!0),b({type:"",message:""});try{let e=await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({currentPassword:p.current,newPassword:p.new})}),t=await e.json();e.ok?(b({type:"success",message:"Password updated successfully"}),u({current:"",new:"",confirm:""})):b({type:"error",message:t.error||"Failed to update password"})}catch(e){b({type:"error",message:"An error occurred"})}finally{y(!1)}},Y=async e=>{try{(await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({fallbackStrategy:e})})).ok&&c(t=>({...t,fallbackStrategy:e}))}catch(e){console.error("Failed to update settings:",e)}},X=async e=>{try{(await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({comboStrategy:e})})).ok&&c(t=>({...t,comboStrategy:e}))}catch(e){console.error("Failed to update combo strategy:",e)}},ee=async e=>{let t=parseInt(e);if(!isNaN(t)&&!(t<1))try{(await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({stickyRoundRobinLimit:t})})).ok&&c(e=>({...e,stickyRoundRobinLimit:t}))}catch(e){console.error("Failed to update sticky limit:",e)}},et=async e=>{let t=parseInt(e);if(!isNaN(t)&&!(t<1))try{(await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({comboStickyRoundRobinLimit:t})})).ok&&c(e=>({...e,comboStickyRoundRobinLimit:t}))}catch(e){console.error("Failed to update combo sticky limit:",e)}},es=async e=>{try{(await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({requireLogin:e})})).ok&&c(t=>({...t,requireLogin:e}))}catch(e){console.error("Failed to update require login:",e)}},ea=(e,t)=>{C(s=>({...s,[e]:t}))},er=async(e=v.authMode||"password")=>{let t=v.oidcIssuerUrl.trim(),s=v.oidcClientId.trim(),a=v.oidcScopes.trim(),r=v.oidcLoginLabel.trim(),o=k.trim();if("password"!==e&&(!t||!s||!o)&&!d.oidcConfigured)return void O({type:"error",message:"Issuer URL, client ID, and client secret are required to enable OIDC."});L(!0),O({type:"",message:""}),T({type:"",message:""});try{let i={authMode:e,oidcIssuerUrl:t,oidcClientId:s,oidcScopes:a||"openid profile email",oidcLoginLabel:r||"Sign in with OIDC"};o&&(i.oidcClientSecret=o);let l=await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)}),n=await l.json();l.ok?(c(e=>({...e,...n})),C({authMode:n?.authMode||e,oidcIssuerUrl:n?.oidcIssuerUrl||t,oidcClientId:n?.oidcClientId||s,oidcScopes:n?.oidcScopes||a||"openid profile email",oidcLoginLabel:n?.oidcLoginLabel||r||"Sign in with OIDC"}),S(""),O({type:"success",message:"oidc"===e?"OIDC login enabled":"both"===e?"Password and OIDC login enabled":"OIDC settings saved"})):O({type:"error",message:n.error||"Failed to save OIDC settings"})}catch(e){O({type:"error",message:"An error occurred"})}finally{L(!1)}},eo=async()=>{let e=v.oidcIssuerUrl.trim(),t=v.oidcClientId.trim(),s=v.oidcScopes.trim(),a=k.trim();if(!e||!t)return void T({type:"error",message:"Issuer URL and client ID are required to test the connection."});D(!0),O({type:"",message:""}),T({type:"",message:""});try{let r=await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({authMode:v.authMode||d.authMode||"password",oidcIssuerUrl:e,oidcClientId:t,oidcScopes:s||"openid profile email",oidcLoginLabel:v.oidcLoginLabel.trim()||"Sign in with OIDC",...a?{oidcClientSecret:a}:{}})}),o=await r.json().catch(()=>({}));if(!r.ok)return void T({type:"error",message:o.error||"Failed to save OIDC settings before testing"});let i=await fetch("/api/auth/oidc/test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({issuerUrl:o.oidcIssuerUrl||e,clientId:o.oidcClientId||t,scopes:o.oidcScopes||s||"openid profile email"})}),l=await i.json().catch(()=>({}));if(i.ok&&l?.ok){let e=l.clientSecretTested?!0===l.clientSecretValid?`Connection OK. Discovery loaded from ${l.issuerUrl}. Client secret validated too.`:`Connection OK. Discovery loaded from ${l.issuerUrl}. Client secret was not checked.`:`Connection OK. Discovery loaded from ${l.issuerUrl}.`;T({type:"success",message:e})}else T({type:"error",message:l.error||"OIDC connection test failed"})}catch(e){T({type:"error",message:"An error occurred"})}finally{D(!1)}},ei=async e=>{try{(await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({enableObservability:e})})).ok&&c(t=>({...t,enableObservability:e}))}catch(e){console.error("Failed to update enableObservability:",e)}},el=async()=>{try{let e=await fetch("/api/settings");if(!e.ok)return;let t=await e.json();c(t)}catch(e){console.error("Failed to reload settings:",e)}},en=async()=>{j(!0),w({type:"",message:""});try{let e=await fetch("/api/settings/database");if(!e.ok){let t=await e.json().catch(()=>({}));throw Error(t.error||"Failed to export database")}let t=await e.json(),s=JSON.stringify(t,null,2),a=new Blob([s],{type:"application/json"}),r=URL.createObjectURL(a),o=document.createElement("a"),i=new Date().toISOString().replace(/[.:]/g,"-");o.href=r,o.download=`ktrouter-backup-${i}.json`,document.body.appendChild(o),o.click(),document.body.removeChild(o),URL.revokeObjectURL(r),w({type:"success",message:"Database backup downloaded"})}catch(e){w({type:"error",message:e.message||"Failed to export database"})}finally{j(!1)}},ed=async e=>{let t=e.target.files?.[0];if(t){j(!0),w({type:"",message:""});try{let e=await t.text(),s=JSON.parse(e),a=await fetch("/api/settings/database",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)}),r=await a.json().catch(()=>({}));if(!a.ok)throw Error(r.error||"Failed to import database");await el(),w({type:"success",message:"Database imported successfully"})}catch(e){w({type:"error",message:e.message||"Invalid backup file"})}finally{F.current&&(F.current.value=""),j(!1)}}},ec=!0===d.enableObservability;return(0,a.jsx)("div",{className:"max-w-2xl mx-auto px-4 sm:px-0",children:(0,a.jsxs)("div",{className:"flex flex-col gap-6",children:[(0,a.jsxs)(o.Zp,{children:[(0,a.jsxs)("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4 mb-4",children:[(0,a.jsxs)("div",{className:"flex items-center gap-3 sm:gap-4",children:[(0,a.jsx)("div",{className:"size-10 sm:size-12 rounded-lg bg-green-500/10 text-green-500 flex items-center justify-center shrink-0",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-xl sm:text-2xl",children:"computer"})}),(0,a.jsxs)("div",{children:[(0,a.jsx)("h2",{className:"text-lg sm:text-xl font-semibold",children:"Local Mode"}),(0,a.jsx)("p",{className:"text-sm text-text-muted",children:"Running on your machine"})]})]}),(0,a.jsx)("div",{className:"inline-flex p-1 rounded-lg bg-black/5 dark:bg-white/5 w-full sm:w-auto",children:["light","dark","system"].map(s=>(0,a.jsxs)("button",{type:"button",onClick:()=>t(s),className:(0,l.cn)("flex items-center justify-center gap-1 sm:gap-1.5 px-2 sm:px-3 py-1.5 rounded-md font-medium transition-all flex-1 sm:flex-initial",e===s?"bg-white dark:bg-white/10 text-text-main shadow-sm":"text-text-muted hover:text-text-main"),children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"light"===s?"light_mode":"dark"===s?"dark_mode":"contrast"}),(0,a.jsx)("span",{className:"capitalize text-xs sm:text-sm",children:s})]},s))})]}),(0,a.jsxs)("div",{className:"flex flex-col gap-3 pt-4 border-t border-border",children:[(0,a.jsx)("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between p-3 rounded-lg bg-bg border border-border gap-2",children:(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"font-medium text-sm sm:text-base",children:"Database Location"}),(0,a.jsx)("p",{className:"text-xs sm:text-sm text-text-muted font-mono break-all",children:"~/.ktrouter/db/data.sqlite"})]})}),(0,a.jsxs)("div",{className:"flex flex-col sm:flex-row gap-2",children:[(0,a.jsx)(o.$n,{variant:"secondary",icon:"download",onClick:en,loading:f,className:"w-full sm:w-auto",children:"Download Backup"}),(0,a.jsx)(o.$n,{variant:"outline",icon:"upload",onClick:()=>F.current?.click(),disabled:f,className:"w-full sm:w-auto",children:"Import Backup"}),(0,a.jsx)("input",{ref:F,type:"file",accept:"application/json,.json",className:"hidden",onChange:ed})]}),N.message&&(0,a.jsx)("p",{className:`text-sm ${"error"===N.type?"text-red-500":"text-green-600 dark:text-green-400"}`,children:N.message})]})]}),(0,a.jsxs)(o.Zp,{children:[(0,a.jsxs)("div",{className:"flex items-center gap-3 mb-4",children:[(0,a.jsx)("div",{className:"p-2 rounded-lg bg-primary/10 text-primary shrink-0",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[20px]",children:"shield"})}),(0,a.jsx)("h3",{className:"text-base sm:text-lg font-semibold",children:"Security"})]}),(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,a.jsxs)("div",{className:"flex items-start sm:items-center justify-between gap-4",children:[(0,a.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,a.jsx)("p",{className:"font-medium text-sm sm:text-base",children:"Require login"}),(0,a.jsx)("p",{className:"text-xs sm:text-sm text-text-muted",children:"When ON, dashboard requires password. When OFF, access without login."})]}),(0,a.jsx)(o.lM,{checked:!0===d.requireLogin,onChange:()=>es(!d.requireLogin),disabled:m})]}),!0===d.requireLogin&&(0,a.jsxs)("form",{onSubmit:V,className:"flex flex-col gap-4 pt-4 border-t border-border/50",children:[d.hasPassword&&(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,a.jsx)("label",{className:"text-xs sm:text-sm font-medium",children:"Current Password"}),(0,a.jsx)(o.pd,{type:"password",placeholder:"Enter current password",value:p.current,onChange:e=>u({...p,current:e.target.value}),required:!0})]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,a.jsx)("label",{className:"text-xs sm:text-sm font-medium",children:"New Password"}),(0,a.jsx)(o.pd,{type:"password",placeholder:"Enter new password",value:p.new,onChange:e=>u({...p,new:e.target.value}),required:!0})]}),(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,a.jsx)("label",{className:"text-xs sm:text-sm font-medium",children:"Confirm New Password"}),(0,a.jsx)(o.pd,{type:"password",placeholder:"Confirm new password",value:p.confirm,onChange:e=>u({...p,confirm:e.target.value}),required:!0})]})]}),h.message&&(0,a.jsx)("p",{className:`text-xs sm:text-sm ${"error"===h.type?"text-red-500":"text-green-500"}`,children:h.message}),(0,a.jsx)("div",{className:"pt-2",children:(0,a.jsx)(o.$n,{type:"submit",variant:"primary",loading:g,className:"w-full sm:w-auto",children:d.hasPassword?"Update Password":"Set Password"})})]})]})]}),(0,a.jsxs)(o.Zp,{children:[(0,a.jsxs)("button",{type:"button",onClick:()=>$(e=>!e),className:"w-full flex items-center gap-3 text-left",children:[(0,a.jsx)("div",{className:"p-2 rounded-lg bg-indigo-500/10 text-indigo-500 shrink-0",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[20px]",children:"lock_open"})}),(0,a.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,a.jsx)("h3",{className:"text-base sm:text-lg font-semibold",children:"OIDC Dashboard Login"}),(0,a.jsx)("p",{className:"text-xs text-text-muted",children:"oidc"===d.authMode?"OIDC active":"both"===d.authMode?"Password + OIDC active":"Optional SSO via Authentik/Keycloak/Google"})]}),(0,a.jsx)("span",{className:"material-symbols-outlined text-text-muted shrink-0",children:E?"expand_less":"expand_more"})]}),E&&(0,a.jsxs)("div",{className:"flex flex-col gap-4 mt-4",children:[(0,a.jsx)("p",{className:"text-xs sm:text-sm text-text-muted",children:"Use Authentik or any OIDC provider to sign in to the dashboard. You can enable password-only, OIDC-only, or both for the dashboard; model API access still uses API keys."}),(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,a.jsx)("label",{className:"font-medium text-sm sm:text-base",children:"Auth Mode"}),(0,a.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-2",children:[{value:"password",title:"Password only",desc:"Keep the legacy password login."},{value:"oidc",title:"OIDC only",desc:"Require OIDC for dashboard access."},{value:"both",title:"Both",desc:"Allow either password or OIDC."}].map(e=>{let t=v.authMode===e.value;return(0,a.jsxs)("button",{type:"button",onClick:()=>ea("authMode",e.value),className:(0,l.cn)("text-left rounded-lg border p-3 transition-colors",t?"border-primary bg-primary/5":"border-border bg-bg hover:bg-black/5 dark:hover:bg-white/5"),disabled:m||I,children:[(0,a.jsx)("p",{className:"font-medium text-sm sm:text-base",children:e.title}),(0,a.jsx)("p",{className:"text-xs sm:text-sm text-text-muted mt-1",children:e.desc})]},e.value)})})]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-4",children:[(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,a.jsx)("label",{className:"font-medium text-sm sm:text-base",children:"Issuer URL"}),(0,a.jsx)(o.pd,{placeholder:"https://auth.example.com/application/o/ktrouter/",value:v.oidcIssuerUrl,onChange:e=>ea("oidcIssuerUrl",e.target.value),disabled:m||I})]}),(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,a.jsx)("label",{className:"font-medium text-sm sm:text-base",children:"Client ID"}),(0,a.jsx)(o.pd,{placeholder:"ktrouter-dashboard",value:v.oidcClientId,onChange:e=>ea("oidcClientId",e.target.value),disabled:m||I})]}),(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,a.jsx)("label",{className:"font-medium text-sm sm:text-base",children:"Client Secret"}),(0,a.jsx)(o.pd,{type:"password",placeholder:"Leave blank to keep existing secret",value:k,onChange:e=>S(e.target.value),disabled:m||I}),(0,a.jsx)("p",{className:"text-xs sm:text-sm text-text-muted",children:"This value is write-only after saving."})]}),(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,a.jsx)("label",{className:"font-medium text-sm sm:text-base",children:"Scopes"}),(0,a.jsx)(o.pd,{placeholder:"openid profile email",value:v.oidcScopes,onChange:e=>ea("oidcScopes",e.target.value),disabled:m||I})]}),(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,a.jsx)("label",{className:"font-medium text-sm sm:text-base",children:"Login Button Label"}),(0,a.jsx)(o.pd,{placeholder:"Sign in with OIDC",value:v.oidcLoginLabel,onChange:e=>ea("oidcLoginLabel",e.target.value),disabled:m||I})]})]}),(0,a.jsxs)("div",{className:"rounded-lg border border-border bg-bg p-3 text-xs sm:text-sm text-text-muted",children:[(0,a.jsx)("p",{className:"font-medium text-text-main mb-1",children:"Redirect URI"}),(0,a.jsx)("code",{className:"block break-all font-mono",children:A})]}),(0,a.jsxs)("div",{className:"flex flex-col sm:flex-row gap-2 pt-2 border-t border-border/50",children:[(0,a.jsx)(o.$n,{type:"button",variant:"primary",loading:I,onClick:()=>er(),className:"w-full sm:w-auto",children:"Save auth mode"}),(0,a.jsx)(o.$n,{type:"button",variant:"outline",loading:R,onClick:eo,className:"w-full sm:w-auto",children:"Test connection"})]}),U.message&&(0,a.jsx)("p",{className:`text-xs sm:text-sm ${"error"===U.type?"text-red-500":"text-green-500"}`,children:U.message}),P.message&&(0,a.jsx)("p",{className:`text-xs sm:text-sm ${"error"===P.type?"text-red-500":"text-green-500"}`,children:P.message}),"oidc"===d.authMode&&(0,a.jsx)("p",{className:"text-xs sm:text-sm text-amber-600 dark:text-amber-400",children:"OIDC login is currently active. Password login is disabled until you switch back."}),"both"===d.authMode&&(0,a.jsx)("p",{className:"text-xs sm:text-sm text-amber-600 dark:text-amber-400",children:"Password and OIDC login are both active."})]})]}),(0,a.jsxs)(o.Zp,{children:[(0,a.jsxs)("div",{className:"flex items-center gap-3 mb-4",children:[(0,a.jsx)("div",{className:"p-2 rounded-lg bg-blue-500/10 text-blue-500 shrink-0",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[20px]",children:"route"})}),(0,a.jsx)("h3",{className:"text-base sm:text-lg font-semibold",children:"Routing Strategy"})]}),(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,a.jsxs)("div",{className:"flex items-start sm:items-center justify-between gap-4",children:[(0,a.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,a.jsx)("p",{className:"font-medium text-sm sm:text-base",children:"Round Robin"}),(0,a.jsx)("p",{className:"text-xs sm:text-sm text-text-muted",children:"Cycle through accounts to distribute load"})]}),(0,a.jsx)(o.lM,{checked:"round-robin"===d.fallbackStrategy,onChange:()=>Y("round-robin"===d.fallbackStrategy?"fill-first":"round-robin"),disabled:m})]}),"round-robin"===d.fallbackStrategy&&(0,a.jsxs)("div",{className:"flex items-start sm:items-center justify-between gap-4 pt-2 border-t border-border/50",children:[(0,a.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,a.jsx)("p",{className:"font-medium text-sm sm:text-base",children:"Sticky Limit"}),(0,a.jsx)("p",{className:"text-xs sm:text-sm text-text-muted",children:"Calls per account before switching"})]}),(0,a.jsx)(o.pd,{type:"number",min:"1",max:"10",value:d.stickyRoundRobinLimit||3,onChange:e=>ee(e.target.value),disabled:m,className:"w-16 sm:w-20 text-center shrink-0"})]}),(0,a.jsxs)("div",{className:"flex items-start sm:items-center justify-between gap-4 pt-4 border-t border-border/50",children:[(0,a.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,a.jsx)("p",{className:"font-medium text-sm sm:text-base",children:"Combo Round Robin"}),(0,a.jsx)("p",{className:"text-xs sm:text-sm text-text-muted",children:"Cycle through providers in combos instead of always starting with first"})]}),(0,a.jsx)(o.lM,{checked:"round-robin"===d.comboStrategy,onChange:()=>X("round-robin"===d.comboStrategy?"fallback":"round-robin"),disabled:m})]}),"round-robin"===d.comboStrategy&&(0,a.jsxs)("div",{className:"flex items-center justify-between pt-2 border-t border-border/50",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"font-medium",children:"Combo Sticky Limit"}),(0,a.jsx)("p",{className:"text-sm text-text-muted",children:"Calls per combo model before switching"})]}),(0,a.jsx)(o.pd,{type:"number",min:"1",max:"100",value:d.comboStickyRoundRobinLimit||1,onChange:e=>et(e.target.value),disabled:m,className:"w-20 text-center"})]}),(0,a.jsxs)("p",{className:"text-xs text-text-muted italic pt-2 border-t border-border/50",children:["round-robin"===d.fallbackStrategy?`Currently distributing requests across all available accounts with ${d.stickyRoundRobinLimit||3} calls per account.`:"Currently using accounts in priority order (Fill First).","round-robin"===d.comboStrategy?` Combos rotate after ${d.comboStickyRoundRobinLimit||1} call${1===(d.comboStickyRoundRobinLimit||1)?"":"s"} per model.`:" Combos always start with their first model."]})]})]}),(0,a.jsxs)(o.Zp,{children:[(0,a.jsxs)("div",{className:"flex items-center gap-3 mb-4",children:[(0,a.jsx)("div",{className:"p-2 rounded-lg bg-purple-500/10 text-purple-500 shrink-0",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[20px]",children:"wifi"})}),(0,a.jsx)("h3",{className:"text-base sm:text-lg font-semibold",children:"Network"})]}),(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,a.jsxs)("div",{className:"flex items-start sm:items-center justify-between gap-4",children:[(0,a.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,a.jsx)("p",{className:"font-medium text-sm sm:text-base",children:"Outbound Proxy"}),(0,a.jsx)("p",{className:"text-xs sm:text-sm text-text-muted",children:"Enable proxy for OAuth + provider outbound requests."})]}),(0,a.jsx)(o.lM,{checked:!0===d.outboundProxyEnabled,onChange:()=>G(!0!==d.outboundProxyEnabled),disabled:m||K})]}),!0===d.outboundProxyEnabled&&(0,a.jsxs)("form",{onSubmit:Q,className:"flex flex-col gap-4 pt-2 border-t border-border/50",children:[(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,a.jsx)("label",{className:"font-medium text-sm sm:text-base",children:"Proxy URL"}),(0,a.jsx)(o.pd,{placeholder:"http://127.0.0.1:7897",value:q.outboundProxyUrl,onChange:e=>J(t=>({...t,outboundProxyUrl:e.target.value})),disabled:m||K}),(0,a.jsx)("p",{className:"text-xs sm:text-sm text-text-muted",children:"Leave empty to inherit existing env proxy (if any)."})]}),(0,a.jsxs)("div",{className:"flex flex-col gap-2 pt-2 border-t border-border/50",children:[(0,a.jsx)("label",{className:"font-medium text-sm sm:text-base",children:"No Proxy"}),(0,a.jsx)(o.pd,{placeholder:"localhost,127.0.0.1",value:q.outboundNoProxy,onChange:e=>J(t=>({...t,outboundNoProxy:e.target.value})),disabled:m||K}),(0,a.jsx)("p",{className:"text-xs sm:text-sm text-text-muted",children:"Comma-separated hostnames/domains to bypass the proxy."})]}),(0,a.jsxs)("div",{className:"pt-2 border-t border-border/50 flex flex-col sm:flex-row items-stretch sm:items-center gap-2",children:[(0,a.jsx)(o.$n,{type:"button",variant:"secondary",loading:B,disabled:m||K,onClick:W,className:"w-full sm:w-auto",children:"Test proxy URL"}),(0,a.jsx)(o.$n,{type:"submit",variant:"primary",loading:K,className:"w-full sm:w-auto",children:"Apply"})]})]}),H.message&&(0,a.jsx)("p",{className:`text-xs sm:text-sm ${"error"===H.type?"text-red-500":"text-green-500"} pt-2 border-t border-border/50`,children:H.message})]})]}),(0,a.jsxs)(o.Zp,{children:[(0,a.jsxs)("div",{className:"flex items-center gap-3 mb-4",children:[(0,a.jsx)("div",{className:"p-2 rounded-lg bg-orange-500/10 text-orange-500 shrink-0",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[20px]",children:"monitoring"})}),(0,a.jsx)("h3",{className:"text-base sm:text-lg font-semibold",children:"Observability"})]}),(0,a.jsxs)("div",{className:"flex items-start sm:items-center justify-between gap-4",children:[(0,a.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,a.jsx)("p",{className:"font-medium text-sm sm:text-base",children:"Enable Observability"}),(0,a.jsx)("p",{className:"text-xs sm:text-sm text-text-muted",children:"Record request details for inspection in the logs view"})]}),(0,a.jsx)(o.lM,{checked:ec,onChange:ei,disabled:m})]})]}),(0,a.jsxs)("div",{className:"text-center text-xs sm:text-sm text-text-muted py-4",children:[(0,a.jsxs)("p",{children:[n.vQ.name," v",n.vQ.version]}),(0,a.jsx)("p",{className:"mt-1",children:"Local Mode - All data stored on your machine"})]})]})})}},94213:(e,t,s)=>{Promise.resolve().then(s.bind(s,64561))}},e=>{e.O(0,[2574,3862,2194,698,1321,5497,8441,3794,7358],()=>e(e.s=94213)),_N_E=e.O()}]);
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[2134],{17721:(e,t,s)=>{"use strict";s.r(t),s.d(t,{default:()=>S});var a=s(95155),i=s(12115),l=s(73321),r=s(98500),n=s.n(r),o=s(5772),d=s(35497),c=s(52679),p=s(28777),m=s(11059);let x=new Map;async function u(e){if(!e?.url||!e?.type)return[];let t=x.get(e.url);if(t&&Date.now()<t.expiresAt)return t.data;try{let t=new URLSearchParams({url:e.url,type:e.type}),s=await fetch(`/api/providers/suggested-models?${t}`);if(!s.ok)return[];let a=(await s.json()).data??[];return x.set(e.url,{data:a,expiresAt:Date.now()+6e5}),a}catch{return[]}}var h=s(14051),f=s.n(h);function g({model:e,fullModel:t,alias:s,copied:i,onCopy:l,testStatus:r,isCustom:n,isFree:o,onDeleteAlias:d,onTest:c,isTesting:p,onDisable:m}){let x="ok"===r?"#22c55e":"error"===r?"#ef4444":void 0;return(0,a.jsx)("div",{className:`group min-w-0 max-w-full rounded-lg border px-3 py-2 ${"ok"===r?"border-green-500/40":"error"===r?"border-red-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",style:x?{color:x}:void 0,children:"ok"===r?"check_circle":"error"===r?"cancel":"smart_toy"}),(0,a.jsxs)("div",{className:"flex min-w-0 flex-1 flex-col gap-1",children:[(0,a.jsx)("code",{className:"max-w-[72vw] truncate rounded bg-sidebar px-1.5 py-0.5 font-mono text-xs text-text-muted sm:max-w-[360px]",children:t}),e.name&&(0,a.jsx)("span",{className:"truncate pl-1 text-[9px] italic text-text-muted/70",children:e.name})]}),c&&(0,a.jsxs)("div",{className:"relative shrink-0 group/btn",children:[(0,a.jsx)("button",{onClick:c,disabled:p,className:`rounded p-0.5 text-text-muted transition-opacity hover:bg-sidebar hover:text-primary ${p?"opacity-100":"opacity-100 sm:opacity-0 sm:group-hover:opacity-100"}`,children:(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",style:p?{animation:"spin 1s linear infinite"}:void 0,children:p?"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:p?"Testing...":"Test"})]}),(0,a.jsxs)("div",{className:"relative shrink-0 group/btn",children:[(0,a.jsx)("button",{onClick:()=>l(t,`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:"ml-auto 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"})}):m?(0,a.jsx)("button",{onClick:m,className:"ml-auto 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 y({modelId:e,fullModel:t,copied:s,onCopy:i,onDeleteAlias:l,onTest:r,testStatus:n,isTesting:o}){let d="ok"===n?"#22c55e":"error"===n?"#ef4444":void 0;return(0,a.jsxs)("div",{className:`flex items-center gap-3 p-3 rounded-lg border ${"ok"===n?"border-green-500/40":"error"===n?"border-red-500/40":"border-border"} hover:bg-sidebar/50`,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-base text-text-muted",style:d?{color:d}:void 0,children:"ok"===n?"check_circle":"error"===n?"cancel":"smart_toy"}),(0,a.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,a.jsx)("p",{className:"text-sm font-medium truncate",children:e}),(0,a.jsxs)("div",{className:"flex items-center gap-1 mt-1",children:[(0,a.jsx)("code",{className:"text-xs text-text-muted font-mono bg-sidebar px-1.5 py-0.5 rounded",children:t}),(0,a.jsxs)("div",{className:"relative group/btn",children:[(0,a.jsx)("button",{onClick:()=>i(t,`model-${e}`),className:"p-0.5 hover:bg-sidebar rounded text-text-muted hover:text-primary",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:s===`model-${e}`?"check":"content_copy"})}),(0,a.jsx)("span",{className:"pointer-events-none absolute top-5 left-1/2 -translate-x-1/2 text-[10px] text-text-muted whitespace-nowrap opacity-0 group-hover/btn:opacity-100 transition-opacity",children:s===`model-${e}`?"Copied!":"Copy"})]}),r&&(0,a.jsxs)("div",{className:"relative group/btn",children:[(0,a.jsx)("button",{onClick:r,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:l,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 b({providerStorageAlias:e,providerDisplayAlias:t,modelAliases:s,copied:l,onCopy:r,onSetAlias:n,onDeleteAlias:o,connections:c,isAnthropic:p}){let[m,x]=(0,i.useState)(""),[u,h]=(0,i.useState)(!1),[f,g]=(0,i.useState)(!1),[v,j]=(0,i.useState)(null),[N,w]=(0,i.useState)({}),k=async t=>{if(!v){j(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();w(e=>({...e,[t]:a.ok?"ok":"error"}))}catch{w(e=>({...e,[t]:"error"}))}finally{j(null)}}},C=Object.entries(s).filter(([,t])=>t.startsWith(`${e}/`)).map(([t,s])=>({modelId:s.replace(`${e}/`,""),fullModel:s,alias:t})),S=a=>{let i,l=`${e}/${a}`;if(Object.values(s).includes(l))return null;let r=(i=a.split("/"))[i.length-1];if(!s[r])return r;let n=`${t}-${r}`;return s[n]?null:n},A=async()=>{if(!m.trim()||u)return;let t=m.trim(),s=S(t);if(!s)return void alert("All suggested aliases already exist. Please choose a different model or remove conflicting aliases.");h(!0);try{await n(t,s,e),x("")}catch(e){console.log("Error adding model:",e)}finally{h(!1)}},$=async()=>{if(f)return;let t=c.find(e=>!1!==e.isActive);if(t){g(!0);try{let s=await fetch(`/api/providers/${t.id}/models`),a=await s.json();if(!s.ok)return void alert(a.error||"Failed to import models");let i=a.models||[];if(0===i.length)return void alert("No models returned from /models.");let l=0;for(let t of i){let s=t.id||t.name||t.model;if(!s)continue;let a=S(s);a&&(await n(s,a,e),l+=1)}0===l&&alert("No new models were added.")}catch(e){console.log("Error importing models:",e)}finally{g(!1)}}},T=c.some(e=>!1!==e.isActive);return(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,a.jsxs)("p",{className:"text-sm text-text-muted",children:["Add ",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:m,onChange:e=>x(e.target.value),onKeyDown:e=>"Enter"===e.key&&A(),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)(d.$n,{size:"sm",icon:"add",onClick:A,disabled:!m.trim()||u,children:u?"Adding...":"Add"}),(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",icon:"download",onClick:$,disabled:!T||f,children:f?"Importing...":"Import from /models"})]}),!T&&(0,a.jsx)("p",{className:"text-xs text-text-muted",children:"Add a connection to enable importing models."}),C.length>0&&(0,a.jsx)("div",{className:"flex flex-col gap-3",children:C.map(({modelId:e,fullModel:s,alias:i})=>(0,a.jsx)(y,{modelId:e,fullModel:`${t}/${e}`,copied:l,onCopy:r,onDeleteAlias:()=>o(i),onTest:c.length>0?()=>k(e):void 0,testStatus:N[e],isTesting:v===e},s))})]})}function v({until:e}){let[t,s]=(0,i.useState)("");return((0,i.useEffect)(()=>{let t=()=>{let t=new Date(e).getTime()-Date.now();if(t<=0)return void s("");let a=Math.floor(t/1e3);if(a<60)s(`${a}s`);else if(a<3600)s(`${Math.floor(a/60)}m ${a%60}s`);else{let e=Math.floor(a/3600),t=Math.floor(a%3600/60);s(`${e}h ${t}m`)}};t();let a=setInterval(t,1e3);return()=>clearInterval(a)},[e]),t)?(0,a.jsxs)("span",{className:"text-xs text-orange-500 font-mono",children:["⏱ ",t]}):null}function j({connection:e,proxyPools:t,isOAuth:s,isFirst:l,isLast:r,onMoveUp:n,onMoveDown:o,onToggleActive:c,onUpdateProxy:p,onEdit:m,onDelete:x,oneByOneStatus:u=null}){let[h,f]=(0,i.useState)(!1),[g,y]=(0,i.useState)(!1),b=(0,i.useRef)(null),N=new Map((t||[]).map(e=>[e.id,e])),w=e.providerSpecificData?.proxyPoolId||null,k=w?N.get(w):null,C=e.providerSpecificData?.connectionProxyEnabled===!0&&!!e.providerSpecificData?.connectionProxyUrl,S=!!w||C,A=k?`Pool: ${k.name}`:w?`Pool: ${w} (inactive/missing)`:C?`Legacy: ${e.providerSpecificData?.connectionProxyUrl}`:"",$="";if(k?.proxyUrl||e.providerSpecificData?.connectionProxyUrl){let t=k?.proxyUrl||e.providerSpecificData?.connectionProxyUrl;try{let e=new URL(t);$=`${e.protocol}//${e.hostname}${e.port?`:${e.port}`:""}`}catch{$=t}}let T=k?.noProxy||e.providerSpecificData?.connectionNoProxy||"",O="default";k?.isActive===!0?O="success":(w||C)&&(O="error"),(0,i.useEffect)(()=>{if(!h)return;let e=e=>{b.current&&!b.current.contains(e.target)&&f(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[h]);let P=async e=>{y(!0);try{await p("__none__"===e?null:e)}finally{y(!1),f(!1)}},I=e.authType||(s?"oauth":"apikey"),E="oauth"===I,R="cookie"===I,D=e=>"string"==typeof e&&/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e),U=E?D(e.email)?e.email:D(e.name)?e.name:e.name||e.email||e.displayName||"OAuth Account":e.name||e.email||e.displayName||"API Key",[_,q]=(0,i.useState)(!1),z=Object.entries(e).filter(([e])=>e.startsWith("modelLock_")).map(([,e])=>e).filter(e=>!!e).sort()[0]||null;(0,i.useEffect)(()=>{let t=()=>{q(!!Object.entries(e).filter(([e])=>e.startsWith("modelLock_")).map(([,e])=>e).filter(e=>e&&new Date(e).getTime()>Date.now()).sort()[0])};t();let s=z?setInterval(t,1e3):null;return()=>{s&&clearInterval(s)}},[z]);let M="unavailable"!==e.testStatus||_?e.testStatus:"active",K=()=>u?"queued"===u.state?"queued":"testing"===u.state?"testing":"success"===u.state?"success":"failed"===u.state?"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:n,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:o,disabled:r,className:`p-0.5 rounded ${r?"text-text-muted/30 cursor-not-allowed":"hover:bg-sidebar text-text-muted hover:text-primary"}`,children:(0,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:R?"cookie":E?"lock":"key"}),(0,a.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,a.jsx)("p",{className:"text-sm font-medium truncate",children:U}),(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)(d.Ex,{variant:!1===e.isActive?"default":"active"===M||"success"===M?"success":"error"===M||"expired"===M||"unavailable"===M?"error":"default",size:"sm",dot:!0,children:!1===e.isActive?"disabled":M||"Unknown"}),(0,a.jsx)(d.Ex,{variant:"default",size:"sm",children:E?"OAuth":R?"Cookie":"API Key"}),S&&(0,a.jsx)(d.Ex,{variant:O,size:"sm",children:"Proxy"}),_&&!1!==e.isActive&&(0,a.jsx)(v,{until:z}),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:e.lastError}),(0,a.jsxs)("span",{className:"text-xs text-text-muted",children:["#",e.priority]}),e.globalPriority&&(0,a.jsxs)("span",{className:"text-xs text-text-muted",children:["Auto: ",e.globalPriority]}),K()&&(0,a.jsx)(d.Ex,{variant:u?"success"===u.state?"success":"failed"===u.state?"error":"testing"===u.state?"primary":"default":"default",size:"sm",title:u?.error||void 0,children:K()})]}),S&&(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:A,children:A}),$&&(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:$}),T&&(0,a.jsxs)("span",{className:"max-w-full truncate text-[11px] text-text-muted sm:max-w-[320px]",title:T,children:["no_proxy: ",T]})]})]})]}),(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:[(t||[]).length>0&&(0,a.jsxs)("div",{className:"relative",ref:b,children:[(0,a.jsxs)("button",{onClick:()=>f(e=>!e),className:`flex w-full flex-col items-center rounded px-2 py-1 transition-colors hover:bg-black/5 dark:hover:bg-white/5 ${S?"text-primary":"text-text-muted hover:text-primary"}`,disabled:g,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:g?"progress_activity":"lan"}),(0,a.jsx)("span",{className:"text-[10px] leading-tight",children:"Proxy"})]}),h&&(0,a.jsxs)("div",{className:"absolute right-0 top-full z-50 mt-1 max-w-[78vw] min-w-[160px] rounded-lg border border-border bg-bg py-1 shadow-lg",children:[(0,a.jsx)("button",{onClick:()=>P("__none__"),className:`w-full text-left px-3 py-1.5 text-sm hover:bg-black/5 dark:hover:bg-white/5 ${!w?"text-primary font-medium":"text-text-main"}`,children:"None"}),(t||[]).map(e=>(0,a.jsx)("button",{onClick:()=>P(e.id),className:`w-full text-left px-3 py-1.5 text-sm hover:bg-black/5 dark:hover:bg-white/5 ${w===e.id?"text-primary font-medium":"text-text-main"}`,children:e.name},e.id))]})]}),(0,a.jsxs)("button",{onClick:()=>window.open(`/api/providers/export?connectionId=${e.id}`,"_blank"),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",title:"Export this connection as JSON",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"download"}),(0,a.jsx)("span",{className:"text-[10px] leading-tight",children:"Export"})]}),(0,a.jsxs)("button",{onClick:m,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)(d.lM,{size:"sm",checked:e.isActive??!0,onChange:c,title:e.isActive??!0?"Disable connection":"Enable connection"})]})]})}g.propTypes={model:f().shape({id:f().string.isRequired}).isRequired,fullModel:f().string.isRequired,alias:f().string,copied:f().string,onCopy:f().func.isRequired,testStatus:f().oneOf(["ok","error"]),isCustom:f().bool,isFree:f().bool,onDeleteAlias:f().func,onTest:f().func,isTesting:f().bool,onDisable:f().func},f().string.isRequired,f().string.isRequired,f().string,f().func.isRequired,f().func.isRequired,f().func,f().oneOf(["ok","error"]),f().bool,f().string.isRequired,f().object.isRequired,f().string,f().func.isRequired,f().func.isRequired,f().func.isRequired,b.propTypes={providerStorageAlias:f().string.isRequired,providerDisplayAlias:f().string.isRequired,modelAliases:f().object.isRequired,copied:f().string,onCopy:f().func.isRequired,onSetAlias:f().func.isRequired,onDeleteAlias:f().func.isRequired,connections:f().arrayOf(f().shape({id:f().string,isActive:f().bool})).isRequired,isAnthropic:f().bool},v.propTypes={until:f().string.isRequired},j.propTypes={connection:f().shape({id:f().string,name:f().string,email:f().string,displayName:f().string,authType:f().string,modelLockUntil:f().string,testStatus:f().string,isActive:f().bool,lastError:f().string,priority:f().number,globalPriority:f().number}).isRequired,proxyPools:f().arrayOf(f().shape({id:f().string,name:f().string,proxyUrl:f().string,noProxy:f().string,isActive:f().bool})),isOAuth:f().bool.isRequired,isFirst:f().bool.isRequired,isLast:f().bool.isRequired,onMoveUp:f().func.isRequired,onMoveDown:f().func.isRequired,onToggleActive:f().func.isRequired,onUpdateProxy:f().func,onEdit:f().func.isRequired,onDelete:f().func.isRequired,oneByOneStatus:f().shape({state:f().string,error:f().string})};let N=`name1|sk-key1
|
|
2
2
|
name2|sk-key2
|
|
3
|
-
sk-key-only-auto-named`;function w({isOpen:e,provider:t,providerName:s,isCompatible:l,isAnthropic:r,authType:n,authHint:o,website:p,proxyPools:m,error:x,onSave:u,onBulkDone:h,onClose:f}){let g="__none__",y="ollama-local"===t,b="cookie"===n,v="xai"===t&&!b,j=b?"Cookie Value":"API Key",k=!y&&!b,C="azure"===t,S="cloudflare-ai"===t,A=c.Q2?.[t]?.regions||null,$=c.Q2?.[t]?.defaultRegion||A?.[0]?.id||"",[T,O]=(0,i.useState)({name:"",apiKey:"",defaultModel:"",priority:1,proxyPoolId:g,ollamaHostUrl:""}),[P,I]=(0,i.useState)({azureEndpoint:"",apiVersion:"2024-10-01-preview",deployment:"",organization:""}),[E,R]=(0,i.useState)({accountId:""}),[D,U]=(0,i.useState)($),[_,q]=(0,i.useState)(!1),[z,M]=(0,i.useState)(null),[K,F]=(0,i.useState)(""),[L,J]=(0,i.useState)(!1),[W,V]=(0,i.useState)("single"),[B,H]=(0,i.useState)(""),[G,Q]=(0,i.useState)(null),Z=()=>y&&T.ollamaHostUrl.trim()?{baseUrl:T.ollamaHostUrl.trim()}:C?{azureEndpoint:P.azureEndpoint,apiVersion:P.apiVersion,deployment:P.deployment,organization:P.organization}:S?{accountId:E.accountId}:A&&D?{region:D}:void 0,X=()=>{let e=Z()||{};return T.proxyPoolId!==g&&(e.proxyPoolId=T.proxyPoolId),Object.keys(e).length>0?e:void 0},Y=async()=>{let e=T.apiKey.trim();q(!0),F("");try{let s=await fetch("/api/providers/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:t,apiKey:e,providerSpecificData:X()})}),a=await s.json();M(a.valid?"success":"failed"),F(a.valid?"":a.error||"Validation failed")}catch{M("failed"),F("Validation request failed")}finally{q(!1)}},ee=async()=>{if(!t)return;let e=T.apiKey.trim();if((y||e)&&(!k||T.name.trim())&&(!l||T.defaultModel.trim())){J(!0);try{let a=!1;if(!b)try{q(!0),M(null),F("");let s=await fetch("/api/providers/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:t,apiKey:e,providerSpecificData:X()})}),i=await s.json();a=!!i.valid,M(a?"success":"failed"),F(a?"":i.error||"Validation failed")}catch{M("failed"),F("Validation request failed")}finally{q(!1)}await u({name:T.name.trim()||(y?"Ollama Local":s||t),apiKey:e,defaultModel:l?T.defaultModel.trim():void 0,priority:T.priority,proxyPoolId:T.proxyPoolId===g?null:T.proxyPoolId,testStatus:a?"active":"unknown",providerSpecificData:Z()})}finally{J(!1)}}},et=async()=>{let e=B.split("\n").map(e=>e.trim()).filter(Boolean);if(!e.length)return;J(!0),Q(null);let s=0,a=0;for(let i=0;i<e.length;i++){let l=e[i].split("|"),r=l.length>=2?l.slice(1).join("|").trim():l[0].trim(),n=l.length>=2?l[0].trim():"Key",o=`${n} ${i+1}`;try{(await fetch("/api/providers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:t,apiKey:r,name:o,priority:1,testStatus:"unknown"})})).ok?s++:a++}catch{a++}}J(!1),Q({success:s,failed:a}),s>0&&h&&h()};return t?(0,a.jsx)(d.aF,{isOpen:e,title:`Add ${s||t} ${j}`,onClose:f,children:(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(d.$n,{size:"sm",variant:"single"===W?"primary":"ghost",onClick:()=>{V("single"),Q(null)},children:"Single"}),(0,a.jsx)(d.$n,{size:"sm",variant:"bulk"===W?"primary":"ghost",onClick:()=>{V("bulk"),Q(null)},children:"Bulk Add"})]}),"bulk"===W&&(0,a.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,a.jsxs)("p",{className:"text-xs text-text-muted",children:["One key per line. Format: ",(0,a.jsx)("code",{children:"name|apiKey"})," or just ",(0,a.jsx)("code",{children:"apiKey"})," (auto-named by index)."]}),(0,a.jsx)("textarea",{className:"w-full rounded border border-accent/30 bg-sidebar p-2 text-sm font-mono resize-y min-h-[140px] focus:outline-none focus:ring-1 focus:ring-primary",placeholder:N,value:B,onChange:e=>H(e.target.value)}),G&&(0,a.jsxs)("div",{className:`text-sm font-medium ${G.failed>0?"text-yellow-400":"text-green-400"}`,children:["✓ ",G.success," added",G.failed>0?`, ✗ ${G.failed} failed`:""]}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(d.$n,{onClick:et,fullWidth:!0,disabled:L||!B.trim(),children:L?"Adding...":"Add All Keys"}),(0,a.jsx)(d.$n,{onClick:f,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]}),"single"===W&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(d.pd,{label:"Name",value:T.name,onChange:e=>O({...T,name:e.target.value}),placeholder:y?"Ollama Local":"Production Key"}),y&&(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(d.pd,{label:"Ollama Host URL",value:T.ollamaHostUrl,onChange:e=>O({...T,ollamaHostUrl:e.target.value}),placeholder:"http://localhost:11434",className:"flex-1"}),(0,a.jsx)("div",{className:"pt-6",children:(0,a.jsx)(d.$n,{onClick:Y,disabled:_||L,variant:"secondary",children:_?"Checking...":"Check"})})]}),!y&&(0,a.jsxs)("div",{className:"flex items-start gap-2",children:[(0,a.jsx)(d.pd,{label:j,type:b?"text":"password",value:T.apiKey,onChange:e=>O({...T,apiKey:e.target.value}),placeholder:b?"eyJhbGciOi...":v?"xai-...":"",className:"flex-1"}),(0,a.jsx)("div",{className:"pt-6",children:(0,a.jsx)(d.$n,{onClick:Y,disabled:!T.apiKey.trim()||_||L,variant:"secondary",children:_?"Checking...":"Check"})})]}),v&&(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."}),b&&o&&(0,a.jsxs)("p",{className:"text-xs text-text-muted",children:[o,p&&(0,a.jsxs)(a.Fragment,{children:[" ",(0,a.jsxs)("a",{href:p,target:"_blank",rel:"noopener noreferrer",className:"text-primary underline",children:["Open ",p.replace(/^https?:\/\//,"")]})]})]}),A&&(0,a.jsx)(d.l6,{label:"Region",value:D,onChange:e=>U(e.target.value),options:A.map(e=>({value:e.id,label:e.label}))}),l&&(0,a.jsx)(d.pd,{label:"Default Model",value:T.defaultModel,onChange:e=>O({...T,defaultModel:e.target.value}),placeholder:r?"claude-3-5-sonnet-latest":"gpt-4o-mini"}),y&&(0,a.jsxs)("p",{className:"text-xs text-text-muted",children:["Leave blank to use ",(0,a.jsx)("code",{children:"http://localhost:11434"}),". For remote Ollama, enter the full host URL (e.g. ",(0,a.jsx)("code",{children:"http://192.168.1.10:11434"}),")."]}),z&&(0,a.jsx)(d.Ex,{variant:"success"===z?"success":"error",children:"success"===z?"Valid":"Invalid"}),K&&(0,a.jsx)("p",{className:"text-xs text-red-500 break-words",children:K}),x&&(0,a.jsx)("p",{className:"text-xs text-red-500 break-words",children:x}),l&&(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."}),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:"Cloudflare Workers AI"}),(0,a.jsx)(d.pd,{label:"Account ID",value:E.accountId,onChange:e=>R({...E,accountId:e.target.value}),placeholder:"abc123def456..."}),(0,a.jsxs)("p",{className:"text-xs text-text-muted mt-2",children:["Find your Account ID in the right sidebar of ",(0,a.jsx)("a",{href:"https://dash.cloudflare.com",target:"_blank",rel:"noopener noreferrer",className:"text-primary underline",children:"dash.cloudflare.com"})]})]}),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:"Azure OpenAI Configuration"}),(0,a.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,a.jsx)(d.pd,{label:"Azure Endpoint",value:P.azureEndpoint,onChange:e=>I({...P,azureEndpoint:e.target.value}),placeholder:"https://your-resource.openai.azure.com"}),(0,a.jsx)(d.pd,{label:"Deployment Name",value:P.deployment,onChange:e=>I({...P,deployment:e.target.value}),placeholder:"gpt-4"}),(0,a.jsx)(d.pd,{label:"API Version",value:P.apiVersion,onChange:e=>I({...P,apiVersion:e.target.value}),placeholder:"2024-10-01-preview"}),(0,a.jsx)(d.pd,{label:"Organization",value:P.organization,onChange:e=>I({...P,organization:e.target.value}),placeholder:"Organization ID"})]})]}),(0,a.jsx)(d.pd,{label:"Priority",type:"number",value:T.priority,onChange:e=>O({...T,priority:Number.parseInt(e.target.value)||1})}),(0,a.jsx)(d.l6,{label:"Proxy Pool",value:T.proxyPoolId,onChange:e=>O({...T,proxyPoolId:e.target.value}),options:[{value:g,label:"None"},...(m||[]).map(e=>({value:e.id,label:e.name}))],placeholder:"None"}),0===(m||[]).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)(d.$n,{onClick:ee,fullWidth:!0,disabled:L||!y&&!T.apiKey.trim()||k&&!T.name.trim()||l&&!T.defaultModel.trim()||C&&(!P.azureEndpoint||!P.deployment||!P.organization)||S&&!E.accountId,children:L?"Saving...":"Save"}),(0,a.jsx)(d.$n,{onClick:f,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})]})}):null}function k({isOpen:e,node:t,onSave:s,onClose:l,isAnthropic:r}){let[n,o]=(0,i.useState)({name:"",prefix:"",apiType:"chat",baseUrl:"https://api.openai.com/v1"}),[c,p]=(0,i.useState)(!1),[m,x]=(0,i.useState)(""),[u,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||(r?"https://api.anthropic.com/v1":"https://api.openai.com/v1")})},[t,r]);let v=async()=>{if(n.name.trim()&&n.prefix.trim()&&n.baseUrl.trim()){p(!0);try{let e={name:n.name,prefix:n.prefix,baseUrl:n.baseUrl};r||(e.apiType=n.apiType),await s(e)}finally{p(!1)}}},j=async()=>{g(!0);try{let e=await fetch("/api/provider-nodes/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:n.baseUrl,apiKey:m,type:r?"anthropic-compatible":"openai-compatible",modelId:u.trim()||void 0})}),t=await e.json();b(t.valid?"success":"failed")}catch{b("failed")}finally{g(!1)}};return t?(0,a.jsx)(d.aF,{isOpen:e,title:`Edit ${r?"Anthropic":"OpenAI"} Compatible`,onClose:l,children:(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,a.jsx)(d.pd,{label:"Name",value:n.name,onChange:e=>o({...n,name:e.target.value}),placeholder:`${r?"Anthropic":"OpenAI"} Compatible (Prod)`,hint:"Required. A friendly label for this node."}),(0,a.jsx)(d.pd,{label:"Prefix",value:n.prefix,onChange:e=>o({...n,prefix:e.target.value}),placeholder:r?"ac-prod":"oc-prod",hint:"Required. Used as the provider prefix for model IDs."}),!r&&(0,a.jsx)(d.l6,{label:"API Type",options:[{value:"chat",label:"Chat Completions"},{value:"responses",label:"Responses API"}],value:n.apiType,onChange:e=>o({...n,apiType:e.target.value})}),(0,a.jsx)(d.pd,{label:"Base URL",value:n.baseUrl,onChange:e=>o({...n,baseUrl:e.target.value}),placeholder:r?"https://api.anthropic.com/v1":"https://api.openai.com/v1",hint:`Use the base URL (ending in /v1) for your ${r?"Anthropic":"OpenAI"}-compatible API.`}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(d.pd,{label:"API Key (for Check)",type:"password",value:m,onChange:e=>x(e.target.value),className:"flex-1"}),(0,a.jsx)("div",{className:"pt-6",children:(0,a.jsx)(d.$n,{onClick:j,disabled:!m||f||!n.baseUrl.trim(),variant:"secondary",children:f?"Checking...":"Check"})})]}),(0,a.jsx)(d.pd,{label:"Model ID (optional)",value:u,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)(d.Ex,{variant:"success"===y?"success":"error",children:"success"===y?"Valid":"Invalid"}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(d.$n,{onClick:v,fullWidth:!0,disabled:!n.name.trim()||!n.prefix.trim()||!n.baseUrl.trim()||c,children:c?"Saving...":"Save"}),(0,a.jsx)(d.$n,{onClick:l,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})}):null}function C({isOpen:e,providerAlias:t,providerDisplayAlias:s,onSave:l,onClose:r}){let[n,o]=(0,i.useState)(""),[c,p]=(0,i.useState)(null),[m,x]=(0,i.useState)(""),[u,h]=(0,i.useState)(!1);(0,i.useEffect)(()=>{e&&(o(""),p(null),x(""))},[e]);let f=e=>{let s=`${t}/`;return e.startsWith(s)?e.slice(s.length):e},g=async()=>{let e=f(n.trim());if(e){p("testing"),x("");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();p(a.ok?"ok":"error"),x(a.error||"")}catch(e){p("error"),x(e.message)}}},y=async()=>{let e=f(n.trim());if(e&&!u){h(!0);try{await l(e)}finally{h(!1)}}};return(0,a.jsx)(d.aF,{isOpen:e,onClose:r,title:"Add Custom Model",children:(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"text-sm font-medium mb-1.5 block",children:"Model ID"}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)("input",{type:"text",value:n,onChange:e=>{o(e.target.value),p(null),x("")},onKeyDown:e=>{"Enter"===e.key&&g()},placeholder:"e.g. claude-opus-4-5",className:"flex-1 px-3 py-2 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary",autoFocus:!0}),(0,a.jsx)(d.$n,{variant:"secondary",icon:"science",loading:"testing"===c,onClick:g,disabled:!n.trim()||"testing"===c,children:"testing"===c?"Testing...":"Test"})]}),(0,a.jsxs)("p",{className:"text-xs text-text-muted mt-1",children:["Sent to provider as: ",(0,a.jsx)("code",{className:"font-mono bg-sidebar px-1 rounded",children:f(n.trim())||"model-id"})]})]}),"ok"===c&&(0,a.jsxs)("div",{className:"flex items-center gap-2 text-sm text-green-600",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-base",children:"check_circle"}),"Model is reachable"]}),"error"===c&&(0,a.jsxs)("div",{className:"flex items-start gap-2 text-sm text-red-500",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-base shrink-0",children:"cancel"}),(0,a.jsx)("span",{children:m||"Model not reachable"})]}),(0,a.jsxs)("div",{className:"flex gap-2 pt-1",children:[(0,a.jsx)(d.$n,{onClick:r,variant:"ghost",fullWidth:!0,size:"sm",children:"Cancel"}),(0,a.jsx)(d.$n,{onClick:y,fullWidth:!0,size:"sm",disabled:!n.trim()||u,children:u?"Adding...":"Add Model"})]})]})})}function S(){let e,t=(0,l.useParams)(),s=(0,l.useRouter)(),r=t.id,[x,h]=(0,i.useState)([]),[f,y]=(0,i.useState)(!0),[v,N]=(0,i.useState)(null),[S,A]=(0,i.useState)([]),[$,T]=(0,i.useState)(!1),[O,P]=(0,i.useState)(!1),[I,E]=(0,i.useState)(!1),[R,D]=(0,i.useState)(""),[U,_]=(0,i.useState)(!1),[q,z]=(0,i.useState)(!1),[M,K]=(0,i.useState)(!1),[F,L]=(0,i.useState)(null),[J,W]=(0,i.useState)({}),[V,B]=(0,i.useState)(!1),[H,G]=(0,i.useState)({}),[Q,Z]=(0,i.useState)(""),[X,Y]=(0,i.useState)(null),[ee,et]=(0,i.useState)(!1),[es,ea]=(0,i.useState)([]),[ei,el]=(0,i.useState)("__none__"),[er,en]=(0,i.useState)(!1),[eo,ed]=(0,i.useState)(null),[ec,ep]=(0,i.useState)(""),[em,ex]=(0,i.useState)("auto"),[eu,eh]=(0,i.useState)([]),[ef,eg]=(0,i.useState)([]),[ey,eb]=(0,i.useState)([]),[ev,ej]=(0,i.useState)(null),[eN,ew]=(0,i.useState)(!1),ek=(0,i.useRef)(null),[eC,eS]=(0,i.useState)(!1),[eA,e$]=(0,i.useState)(!1),[eT,eO]=(0,i.useState)(null),[eP,eI]=(0,i.useState)({}),[eE,eR]=(0,i.useState)(null),eD=(0,i.useRef)(!1),{copied:eU,copy:e_}=(0,m.C)(),eq=async e=>{let t=e.target.files?.[0];if(t){ew(!0);try{let e=await t.text(),s=JSON.parse(e),a=await fetch("/api/providers/import",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)}),i=await a.json();if(a.ok){let e=await fetch("/api/providers");if(e.ok){let t=await e.json();h((t.connections||[]).filter(e=>e.provider===r))}D("")}else D(i.error||"Import failed")}catch(e){D(e.message||"Import failed")}finally{ew(!1),ek.current&&(ek.current.value="")}}},ez=v?{id:v.id,name:v.name||("anthropic-compatible"===v.type?"Anthropic Compatible":"OpenAI Compatible"),color:"anthropic-compatible"===v.type?"#D97757":"#10A37F",textIcon:"anthropic-compatible"===v.type?"AC":"OC",apiType:v.apiType,baseUrl:v.baseUrl,type:v.type}:c.zN[r]||c.fg[r]||c.IS[r]||c.nJ[r]||c.br[r],eM=ez?.authModes||[],eK=!!c.zN[r]||!!c.IS[r]||eM.includes("oauth"),eF=!!c.fg[r]||eM.includes("apikey"),eL=!!c.IS[r]?.noAuth,eJ=(0,p.KC)(r),eW=(0,c.wG)(r),eV=(0,c.mq)(r),eB=(0,c.gb)(r),eH=eV||eB,eG=!eH&&eK&&eF,eQ="xai"===r?"Grok Build OAuth":"OAuth",eZ="xai"===r?"xAI API Key":"API Key";c.Q2[r]?.thinkingConfig||c.s9.extended;let eX=eH?r:eW,eY=eH?v?.prefix||r:eW,e0=()=>{T(!0)},e1=()=>{D(""),E(!0)},e2=(0,i.useCallback)(async()=>{try{let e=await fetch(`/api/models/disabled?providerAlias=${encodeURIComponent(eX)}`,{cache:"no-store"}),t=await e.json();e.ok&&eb(t.ids||[])}catch(e){console.log("Error fetching disabled models:",e)}},[eX]),e5=async e=>{try{(await fetch("/api/models/disabled",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerAlias:eX,ids:[e]})})).ok&&await e2()}catch(e){console.log("Error disabling model:",e)}},e3=async e=>{try{(await fetch(`/api/models/disabled?providerAlias=${encodeURIComponent(eX)}&id=${encodeURIComponent(e)}`,{method:"DELETE"})).ok&&await e2()}catch(e){console.log("Error enabling model:",e)}},e4=async e=>{e.length&&ej({title:"Disable All Models",message:`Disable all ${e.length} model(s)?`,onConfirm:async()=>{ej(null);try{(await fetch("/api/models/disabled",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerAlias:eX,ids:e})})).ok&&await e2()}catch(e){console.log("Error disabling all models:",e)}}})},e6=async()=>{try{(await fetch(`/api/models/disabled?providerAlias=${encodeURIComponent(eX)}`,{method:"DELETE"})).ok&&await e2()}catch(e){console.log("Error enabling all models:",e)}},e7=(0,i.useCallback)(async()=>{try{let e=await fetch("/api/models/alias"),t=await e.json();e.ok&&W(t.aliases||{})}catch(e){console.log("Error fetching aliases:",e)}},[]);(0,i.useEffect)(()=>{"kilocode"===r&&fetch("/api/providers/kilo/free-models").then(e=>e.json()).then(e=>{e.models?.length&&eg(e.models)}).catch(()=>{})},[r]);let e8=(0,i.useCallback)(async()=>{try{let[e,t,s,a]=await Promise.all([fetch("/api/providers",{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(),l=await t.json(),n=await s.json(),o=a.ok?await a.json():{};if(e.ok){let e=(i.connections||[]).filter(e=>e.provider===r);h(e)}s.ok&&A(n.proxyPools||[]);let d=(o.providerStrategies||{})[r]||{};ed(d.fallbackStrategy||null),ep(null!=d.stickyRoundRobinLimit?String(d.stickyRoundRobinLimit):"1");let c=(o.providerThinking||{})[r]||{};if(ex(c.mode||"auto"),t.ok){let e=(l.nodes||[]).find(e=>e.id===r)||null;if(!e&&eH)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===r)||null))break}N(e)}}catch(e){console.log("Error fetching connections:",e)}finally{y(!1)}},[r,eH]),e9=async e=>{try{let t=await fetch(`/api/provider-nodes/${r}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),s=await t.json();t.ok&&(N(s.node),await e8(),z(!1))}catch(e){console.log("Error updating provider node:",e)}},te=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 l={...a};0===Object.keys(i).length?delete l[r]:l[r]=i,await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerStrategies:l})})}catch(e){console.log("Error saving provider strategy:",e)}};(0,i.useEffect)(()=>{e8(),e7(),e2()},[e8,e7,e2]),(0,i.useEffect)(()=>{let e=(c.zN[r]||c.fg[r]||c.IS[r]||c.nJ[r])?.modelsFetcher;e&&u(e).then(eh)},[r]);let tt=async(e,t,s=eW)=>{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 e7();else{let t=await e.json();alert(t.error||"Failed to set alias")}}catch(e){console.log("Error setting alias:",e)}},ts=async e=>{try{(await fetch(`/api/models/alias?alias=${encodeURIComponent(e)}`,{method:"DELETE"})).ok&&await e7()}catch(e){console.log("Error deleting alias:",e)}},ta=async()=>{if(eC||0===x.length)return;let e=Object.fromEntries(x.map(e=>[e.id,{state:"queued",error:null}]));eD.current=!1,eS(!0),e$(!1),eO(null),eI(e),eR({total:x.length,completed:0,passed:0,failed:0,stopped:!1});let t=0,s=0;try{for(let e=0;e<x.length;e+=1){if(eD.current){eR({total:x.length,completed:e,passed:t,failed:s,stopped:!0});break}let a=x[e];eO(a.id),eI(e=>({...e,[a.id]:{state:"testing",error:null}}));try{let e=await fetch(`/api/providers/${a.id}/test`,{method:"POST"}),i=await e.json(),l=e.ok&&!!i.valid,r=l?null:i.error||"Test failed";l?t+=1:s+=1,eI(e=>({...e,[a.id]:{state:l?"success":"failed",error:r}})),h(e=>e.map(e=>e.id===a.id?{...e,testStatus:l?"active":"error",lastError:r,lastErrorAt:l?null:new Date().toISOString()}:e))}catch(e){s+=1,eI(t=>({...t,[a.id]:{state:"failed",error:e.message||"Test failed"}})),h(t=>t.map(t=>t.id===a.id?{...t,testStatus:"error",lastError:e.message||"Test failed",lastErrorAt:new Date().toISOString()}:t))}eR({total:x.length,completed:e+1,passed:t,failed:s,stopped:!1}),e<x.length-1&&await new Promise(e=>setTimeout(e,1e3))}}finally{eO(null),eS(!1),e$(!1),eD.current=!1,await e8()}},ti=async e=>{ej({title:"Delete Connection",message:"Delete this connection?",onConfirm:async()=>{ej(null);try{(await fetch(`/api/providers/${e}`,{method:"DELETE"})).ok&&h(x.filter(t=>t.id!==e))}catch(e){console.log("Error deleting connection:",e)}}})},tl=()=>{e8(),T(!1)},tr=async e=>{D("");try{let t=await fetch("/api/providers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:r,...e})}),s=null;try{s=await t.json()}catch{s=null}if(t.ok){await e8(),E(!1);return}D(s?.error||"Failed to save connection")}catch(e){console.log("Error saving connection:",e),D("Failed to save connection")}},tn=async e=>{try{(await fetch(`/api/providers/${F.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})).ok&&(await e8(),_(!1))}catch(e){console.log("Error updating connection:",e)}},to=async(e,t)=>{try{(await fetch(`/api/providers/${e}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({isActive:t})})).ok&&h(s=>s.map(s=>s.id===e?{...s,isActive:t}:s))}catch(e){console.log("Error updating connection status:",e)}},td=async(e,t)=>{let s=[...x];[s[e],s[t]]=[s[t],s[e]],h(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 e8()}},tc=x.filter(e=>es.includes(e.id));x.length>0&&(es.length,x.length),(0,i.useEffect)(()=>{ea(e=>e.filter(e=>x.some(t=>t.id===e)))},[x]),(()=>{if(0===tc.length)return;let e=new Set(tc.map(e=>e.providerSpecificData?.proxyPoolId||"__none__"));if(1===e.size){let t=[...e][0];if("__none__"===t)return;let s=S.find(e=>e.id===t);return s?.name}})();let tp=()=>{er||K(!1)},tm=async e=>{en(!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 e8(),K(!1)}finally{en(!1)}},tx=e=>tm(x.map(t=>({connectionId:t.id,proxyPoolId:e}))),tu=(0,a.jsx)("div",{className:"flex min-w-0 flex-col divide-y divide-black/[0.03] dark:divide-white/[0.03]",children:x.map((e,t)=>(0,a.jsx)("div",{className:"flex min-w-0 items-stretch",children:(0,a.jsx)("div",{className:"flex-1 min-w-0",children:(0,a.jsx)(j,{connection:e,proxyPools:S,isOAuth:eK,isFirst:0===t,isLast:t===x.length-1,onMoveUp:()=>td(t,t-1),onMoveDown:()=>td(t,t+1),onToggleActive:t=>to(e.id,t),onUpdateProxy:async t=>{try{(await fetch(`/api/providers/${e.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({proxyPoolId:t||null})})).ok&&h(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:()=>{L(e),_(!0)},onDelete:()=>ti(e.id),oneByOneStatus:eP[e.id]||null})})},e.id))}),th=S.filter(e=>!0===e.isActive),tf=(0,a.jsx)(d.aF,{isOpen:M,onClose:tp,title:`Apply Proxy (${x.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=S.filter(e=>!0===e.isActive);return 0===e.length?void alert("No active proxy pools available."):tm(x.map((t,s)=>({connectionId:t.id,proxyPoolId:e[s%e.length].id})))},disabled:er||0===th.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:()=>tx(null),disabled:er,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)"})]}),S.map(e=>(0,a.jsxs)("button",{onClick:()=>tx(e.id),disabled:er||!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))]}),er&&(0,a.jsx)("p",{className:"text-xs text-text-muted",children:"Applying..."}),(0,a.jsx)(d.$n,{onClick:tp,variant:"ghost",fullWidth:!0,disabled:er,children:"Cancel"})]})}),tg=async e=>{if(!X){Y(e);try{let t=await fetch("/api/models/test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:`${eX}/${e}`})}),s=await t.json();G(t=>({...t,[e]:s.ok?"ok":"error"})),Z(s.ok?"":s.error||"Model not reachable")}catch{G(t=>({...t,[e]:"error"})),Z("Network error")}finally{Y(null)}}};return f?(0,a.jsxs)("div",{className:"flex flex-col gap-8",children:[(0,a.jsx)(d.Qv,{}),(0,a.jsx)(d.Qv,{})]}):ez?(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:`${ez.color}15`},children:V?(0,a.jsx)("span",{className:"text-sm font-bold",style:{color:ez.color},children:ez.textIcon||ez.id.slice(0,2).toUpperCase()}):(0,a.jsx)(o.default,{src:eV&&ez.apiType?"responses"===ez.apiType?"/providers/oai-r.png":"/providers/oai-cc.png":eB?"/providers/anthropic-m.png":`/providers/${ez.id}.png`,alt:ez.name,width:48,height:48,className:"max-h-12 max-w-12 rounded-lg object-contain",sizes:"48px",onError:()=>B(!0)})}),(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsxs)("div",{className:"flex items-center gap-3 flex-wrap",children:[(0,a.jsx)("h1",{className:"truncate text-2xl font-semibold tracking-tight sm:text-3xl",children:ez.name}),(ez.notice?.apiKeyUrl||ez.notice?.signupUrl||ez.website)&&(0,a.jsxs)("a",{href:ez.notice?.apiKeyUrl||ez.notice?.signupUrl||ez.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"}),ez.notice?.apiKeyUrl?"Get API Key":"Sign up / Learn more"]})]}),(0,a.jsxs)("p",{className:"text-text-muted",children:[x.length," connection",1===x.length?"":"s"]})]})]})]}),ez.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:ez.deprecationNotice})]}),ez.notice?.text&&!ez.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:ez.notice.text}),ez.notice.apiKeyUrl&&(0,a.jsx)("a",{href:ez.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 →"})]}),eH&&v&&(0,a.jsx)(d.Zp,{children:(0,a.jsxs)("div",{className:"mb-4 flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsx)("h2",{className:"text-lg font-semibold",children:eB?"Anthropic Compatible Details":"OpenAI Compatible Details"}),(0,a.jsxs)("p",{className:"break-all text-sm text-text-muted",children:[eB?"Messages API":"responses"===v.apiType?"Responses API":"Chat Completions"," \xb7 ",(v.baseUrl||"").replace(/\/$/,""),"/",eB?"messages":"responses"===v.apiType?"responses":"chat/completions"]})]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-2 sm:flex sm:items-center",children:[(0,a.jsx)(d.$n,{size:"sm",icon:"add",onClick:()=>{D(""),E(!0)},className:"w-full sm:w-auto",children:"Add API Key"}),(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",icon:"edit",onClick:()=>z(!0),className:"w-full sm:w-auto",children:"Edit"}),(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",icon:"delete",onClick:async()=>{ej({title:"Delete Compatible Node",message:`Delete this ${eB?"Anthropic":"OpenAI"} Compatible node?`,onConfirm:async()=>{ej(null);try{(await fetch(`/api/provider-nodes/${r}`,{method:"DELETE"})).ok&&s.push("/dashboard/providers")}catch(e){console.log("Error deleting provider node:",e)}}})},className:"w-full sm:w-auto",children:"Delete"})]})]})}),eL?(0,a.jsx)(d.gw,{providerId:r}):(0,a.jsxs)(d.Zp,{children:[(0,a.jsxs)("div",{className:"mb-4 flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[(0,a.jsx)("h2",{className:"text-lg font-semibold",children:"Connections"}),(0,a.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:gap-4",children:[x.length>0&&S.length>0&&(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",icon:"lan",onClick:()=>K(!0),children:"Apply Proxy"}),x.length>0&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",icon:"sync",onClick:ta,disabled:eC,children:eC?"Testing...":"Test One-by-One"}),eC&&(0,a.jsx)(d.$n,{size:"sm",variant:"ghost",icon:"stop",onClick:()=>{eC&&(eD.current=!0,e$(!0))},disabled:eA,children:eA?"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:"Round Robin"}),(0,a.jsx)(d.lM,{checked:"round-robin"===eo,onChange:e=>{let t=e?"round-robin":null,s=e?ec||"1":ec;e&&!ec&&ep("1"),ed(t),te(t,s)}}),"round-robin"===eo&&(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:ec,onChange:e=>{var t;ep(t=e.target.value),te("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"})]})]})]})]}),(0,a.jsxs)("div",{className:"flex flex-wrap gap-2 mb-3",children:[eG?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(d.$n,{size:"sm",icon:"lock",onClick:e0,children:eQ}),(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",icon:"key",onClick:e1,children:eZ})]}):(0,a.jsx)(d.$n,{size:"sm",icon:"add",onClick:()=>{eK?e0():e1()},children:"Add"}),(0,a.jsx)("input",{ref:ek,type:"file",accept:"application/json",className:"hidden",onChange:eq}),(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",icon:"upload",onClick:()=>ek.current?.click(),disabled:eN,children:eN?"Importing...":"Import"}),(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",icon:"download",onClick:()=>window.open(`/api/providers/export?provider=${r}`,"_blank"),disabled:0===x.length,children:"Export All"})]}),0===x.length?(0,a.jsx)("div",{className:"flex items-center gap-3",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:eK?"lock":"key"})}),(0,a.jsx)("p",{className:"text-sm text-text-muted",children:"No connections yet"})]})}):(0,a.jsxs)(a.Fragment,{children:[eE&&(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: ",eE.total]}),(0,a.jsxs)("span",{children:["Completed: ",eE.completed]}),(0,a.jsxs)("span",{children:["Passed: ",eE.passed]}),(0,a.jsxs)("span",{children:["Failed: ",eE.failed]}),eE.stopped&&(0,a.jsx)("span",{className:"text-amber-600 dark:text-amber-400",children:"Stopped"}),eC&&eT&&(0,a.jsxs)("span",{children:["Running: ",x.find(e=>e.id===eT)?.name||eT]})]})}),tu]})]}),(0,a.jsxs)(d.Zp,{children:[(0,a.jsxs)("div",{className:"mb-4 flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between",children:[(0,a.jsx)("h2",{className:"text-lg font-semibold",children:"Available Models"}),!eH&&(e=[...eJ,...ef.filter(e=>!eJ.some(t=>t.id===e.id))].filter(e=>!e.type||"llm"===e.type).map(e=>e.id).filter(e=>!ey.includes(e)),(0,a.jsxs)("div",{className:"flex gap-2",children:[ey.length>0&&(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",icon:"restart_alt",onClick:e6,children:"Active All"}),e.length>0&&(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",icon:"block",onClick:()=>e4(e),children:"Disable All"})]}))]}),!!Q&&(0,a.jsx)("p",{className:"text-xs text-red-500 mb-3 break-words",children:Q}),(()=>{let e,t,s;if(eH)return(0,a.jsx)(b,{providerStorageAlias:eX,providerDisplayAlias:eY,modelAliases:J,copied:eU,onCopy:e_,onSetAlias:tt,onDeleteAlias:ts,connections:x,isAnthropic:eB});let i=[...eJ,...ef.filter(e=>!eJ.some(t=>t.id===e.id))].filter(e=>!e.type||"llm"===e.type),l=new Set(ey),n=i.filter(e=>!l.has(e.id)),o=i.filter(e=>l.has(e.id)),d=Object.entries(J).filter(([e,t])=>{let s=`${eX}/`;if(!t.startsWith(s))return!1;let a=t.slice(s.length);return ez.passthroughModels?!eJ.some(e=>e.id===a):!eJ.some(e=>e.id===a)&&e===a}).map(([e,t])=>({id:t.slice(`${eX}/`.length),alias:e,fullModel:t}));return(0,a.jsxs)("div",{className:"flex flex-wrap gap-3",children:[d.map(e=>(0,a.jsx)(g,{model:{id:e.id},fullModel:`${eY}/${e.id}`,alias:e.alias,copied:eU,onCopy:e_,onSetAlias:()=>{},onDeleteAlias:()=>ts(e.alias),testStatus:H[e.id],onTest:x.length>0||eL?()=>tg(e.id):void 0,isTesting:X===e.id,isCustom:!0,isFree:!1},e.id)),n.map(e=>{let t=`${eX}/${e.id}`,s=`${r}/${e.id}`,i=Object.entries(J).find(([,e])=>e===t||e===s)?.[0];return(0,a.jsx)(g,{model:e,fullModel:`${eY}/${e.id}`,alias:i,copied:eU,onCopy:e_,onSetAlias:t=>tt(e.id,t,eX),onDeleteAlias:()=>ts(i),testStatus:H[e.id],onTest:x.length>0||eL?()=>tg(e.id):void 0,isTesting:X===e.id,isFree:e.isFree,onDisable:()=>e5(e.id)},e.id)}),(0,a.jsxs)("button",{onClick:()=>et(!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"]}),eu.length>0&&(e=new Set(Object.values(J)),t=new Set(eJ.map(e=>e.id)),0===(s=eu.filter(s=>!e.has(`${eX}/${s.id}`)&&!t.has(s.id))).length?null:(0,a.jsxs)("div",{className:"w-full mt-2",children:[(0,a.jsx)("p",{className:"text-xs text-text-muted mb-2",children:"Suggested free models (≥200k context):"}),(0,a.jsx)("div",{className:"flex flex-wrap gap-2",children:s.map(e=>(0,a.jsxs)("button",{onClick:async()=>{let t=e.id.split("/").pop();await tt(e.id,t,eX)},className:"flex items-center gap-1 px-2.5 py-1.5 rounded-lg border border-black/10 dark:border-white/10 text-xs text-text-muted hover:text-primary hover:border-primary/40 hover:bg-primary/5 transition-colors",title:`${e.name} \xb7 ${(e.contextLength/1e3).toFixed(0)}k ctx`,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[13px]",children:"add"}),e.id.split("/").pop()]},e.id))})]})),o.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 (",o.length,"):"]}),(0,a.jsx)("div",{className:"flex flex-wrap gap-2",children:o.map(e=>(0,a.jsxs)("button",{onClick:()=>e3(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))})]})]})})()]}),tf,"kiro"===r?(0,a.jsx)(d.Mh,{isOpen:$,providerInfo:ez,onSuccess:tl,onClose:()=>T(!1)}):"codex"===r?(0,a.jsx)(d.K3,{isOpen:$,providerInfo:ez,onSuccess:tl,onClose:()=>T(!1)}):"cursor"===r?(0,a.jsx)(d.G9,{isOpen:$,onSuccess:tl,onClose:()=>T(!1)}):"gitlab"===r?(0,a.jsx)(d.vj,{isOpen:$,providerInfo:ez,onSuccess:tl,onClose:()=>T(!1)}):(0,a.jsx)(d.LF,{isOpen:$,provider:r,providerInfo:ez,onSuccess:tl,onClose:()=>T(!1)}),"iflow"===r&&(0,a.jsx)(d.vE,{isOpen:O,onSuccess:()=>{e8(),P(!1)},onClose:()=>P(!1)}),(0,a.jsx)(w,{isOpen:I,provider:r,providerName:ez.name,isCompatible:eH,isAnthropic:eB,authType:ez?.authType,authHint:ez?.authHint,website:ez?.website,proxyPools:S,error:R,onSave:tr,onBulkDone:e8,onClose:()=>{D(""),E(!1)}}),(0,a.jsx)(d.wI,{isOpen:U,connection:F,proxyPools:S,onSave:tn,onClose:()=>_(!1)}),eH&&(0,a.jsx)(k,{isOpen:q,node:v,onSave:e9,onClose:()=>z(!1),isAnthropic:eB}),!eH&&(0,a.jsx)(C,{isOpen:ee,providerAlias:eX,providerDisplayAlias:eY,onSave:async e=>{let t=ez?.passthroughModels?e.split("/").pop():e;await tt(e,t,eX),et(!1)},onClose:()=>et(!1)}),(0,a.jsx)(d.uo,{isOpen:!!ev,onClose:()=>ej(null),onConfirm:ev?.onConfirm,title:ev?.title||"Confirm",message:ev?.message,variant:"danger"})]}):(0,a.jsxs)("div",{className:"text-center py-20",children:[(0,a.jsx)("p",{className:"text-text-muted",children:"Provider not found"}),(0,a.jsx)(n(),{href:"/dashboard/providers",className:"text-primary mt-4 inline-block",children:"Back to Providers"})]})}w.propTypes={isOpen:f().bool.isRequired,provider:f().string,providerName:f().string,isCompatible:f().bool,isAnthropic:f().bool,authType:f().string,authHint:f().string,website:f().string,proxyPools:f().arrayOf(f().shape({id:f().string,name:f().string})),error:f().string,onSave:f().func.isRequired,onBulkDone:f().func,onClose:f().func.isRequired},k.propTypes={isOpen:f().bool.isRequired,node:f().shape({id:f().string,name:f().string,prefix:f().string,apiType:f().string,baseUrl:f().string}),onSave:f().func.isRequired,onClose:f().func.isRequired,isAnthropic:f().bool},C.propTypes={isOpen:f().bool.isRequired,providerAlias:f().string.isRequired,providerDisplayAlias:f().string.isRequired,onSave:f().func.isRequired,onClose:f().func.isRequired}},26435:(e,t,s)=>{Promise.resolve().then(s.bind(s,17721))}},e=>{e.O(0,[2574,3862,2194,698,5772,1321,5497,8441,3794,7358],()=>e(e.s=26435)),_N_E=e.O()}]);
|
|
3
|
+
sk-key-only-auto-named`;function w({isOpen:e,provider:t,providerName:s,isCompatible:l,isAnthropic:r,authType:n,authHint:o,website:p,proxyPools:m,error:x,onSave:u,onBulkDone:h,onClose:f}){let g="__none__",y="ollama-local"===t,b="cookie"===n,v="xai"===t&&!b,j=b?"Cookie Value":"API Key",k=!y&&!b,C="azure"===t,S="cloudflare-ai"===t,A=c.Q2?.[t]?.regions||null,$=c.Q2?.[t]?.defaultRegion||A?.[0]?.id||"",[T,O]=(0,i.useState)({name:"",apiKey:"",defaultModel:"",priority:1,proxyPoolId:g,ollamaHostUrl:""}),[P,I]=(0,i.useState)({azureEndpoint:"",apiVersion:"2024-10-01-preview",deployment:"",organization:""}),[E,R]=(0,i.useState)({accountId:""}),[D,U]=(0,i.useState)($),[_,q]=(0,i.useState)(!1),[z,M]=(0,i.useState)(null),[K,F]=(0,i.useState)(""),[L,J]=(0,i.useState)(!1),[W,V]=(0,i.useState)("single"),[B,H]=(0,i.useState)(""),[G,Q]=(0,i.useState)(null),Z=()=>y&&T.ollamaHostUrl.trim()?{baseUrl:T.ollamaHostUrl.trim()}:C?{azureEndpoint:P.azureEndpoint,apiVersion:P.apiVersion,deployment:P.deployment,organization:P.organization}:S?{accountId:E.accountId}:A&&D?{region:D}:void 0,X=()=>{let e=Z()||{};return T.proxyPoolId!==g&&(e.proxyPoolId=T.proxyPoolId),Object.keys(e).length>0?e:void 0},Y=async()=>{let e=T.apiKey.trim();q(!0),F("");try{let s=await fetch("/api/providers/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:t,apiKey:e,providerSpecificData:X()})}),a=await s.json();M(a.valid?"success":"failed"),F(a.valid?"":a.error||"Validation failed")}catch{M("failed"),F("Validation request failed")}finally{q(!1)}},ee=async()=>{if(!t)return;let e=T.apiKey.trim();if((y||e)&&(!k||T.name.trim())&&(!l||T.defaultModel.trim())){J(!0);try{let a=!1;if(!b)try{q(!0),M(null),F("");let s=await fetch("/api/providers/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:t,apiKey:e,providerSpecificData:X()})}),i=await s.json();a=!!i.valid,M(a?"success":"failed"),F(a?"":i.error||"Validation failed")}catch{M("failed"),F("Validation request failed")}finally{q(!1)}await u({name:T.name.trim()||(y?"Ollama Local":s||t),apiKey:e,defaultModel:l?T.defaultModel.trim():void 0,priority:T.priority,proxyPoolId:T.proxyPoolId===g?null:T.proxyPoolId,testStatus:a?"active":"unknown",providerSpecificData:Z()})}finally{J(!1)}}},et=async()=>{let e=B.split("\n").map(e=>e.trim()).filter(Boolean);if(!e.length)return;J(!0),Q(null);let s=0,a=0;for(let i=0;i<e.length;i++){let l=e[i].split("|"),r=l.length>=2?l.slice(1).join("|").trim():l[0].trim(),n=l.length>=2?l[0].trim():"Key",o=`${n} ${i+1}`;try{(await fetch("/api/providers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:t,apiKey:r,name:o,priority:1,testStatus:"unknown"})})).ok?s++:a++}catch{a++}}J(!1),Q({success:s,failed:a}),s>0&&h&&h()};return t?(0,a.jsx)(d.aF,{isOpen:e,title:`Add ${s||t} ${j}`,onClose:f,children:(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(d.$n,{size:"sm",variant:"single"===W?"primary":"ghost",onClick:()=>{V("single"),Q(null)},children:"Single"}),(0,a.jsx)(d.$n,{size:"sm",variant:"bulk"===W?"primary":"ghost",onClick:()=>{V("bulk"),Q(null)},children:"Bulk Add"})]}),"bulk"===W&&(0,a.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,a.jsxs)("p",{className:"text-xs text-text-muted",children:["One key per line. Format: ",(0,a.jsx)("code",{children:"name|apiKey"})," or just ",(0,a.jsx)("code",{children:"apiKey"})," (auto-named by index)."]}),(0,a.jsx)("textarea",{className:"w-full rounded border border-accent/30 bg-sidebar p-2 text-sm font-mono resize-y min-h-[140px] focus:outline-none focus:ring-1 focus:ring-primary",placeholder:N,value:B,onChange:e=>H(e.target.value)}),G&&(0,a.jsxs)("div",{className:`text-sm font-medium ${G.failed>0?"text-yellow-400":"text-green-400"}`,children:["✓ ",G.success," added",G.failed>0?`, ✗ ${G.failed} failed`:""]}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(d.$n,{onClick:et,fullWidth:!0,disabled:L||!B.trim(),children:L?"Adding...":"Add All Keys"}),(0,a.jsx)(d.$n,{onClick:f,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]}),"single"===W&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(d.pd,{label:"Name",value:T.name,onChange:e=>O({...T,name:e.target.value}),placeholder:y?"Ollama Local":"Production Key"}),y&&(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(d.pd,{label:"Ollama Host URL",value:T.ollamaHostUrl,onChange:e=>O({...T,ollamaHostUrl:e.target.value}),placeholder:"http://localhost:11434",className:"flex-1"}),(0,a.jsx)("div",{className:"pt-6",children:(0,a.jsx)(d.$n,{onClick:Y,disabled:_||L,variant:"secondary",children:_?"Checking...":"Check"})})]}),!y&&(0,a.jsxs)("div",{className:"flex items-start gap-2",children:[(0,a.jsx)(d.pd,{label:j,type:b?"text":"password",value:T.apiKey,onChange:e=>O({...T,apiKey:e.target.value}),placeholder:b?"eyJhbGciOi...":v?"xai-...":"",className:"flex-1"}),(0,a.jsx)("div",{className:"pt-6",children:(0,a.jsx)(d.$n,{onClick:Y,disabled:!T.apiKey.trim()||_||L,variant:"secondary",children:_?"Checking...":"Check"})})]}),v&&(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."}),b&&o&&(0,a.jsxs)("p",{className:"text-xs text-text-muted",children:[o,p&&(0,a.jsxs)(a.Fragment,{children:[" ",(0,a.jsxs)("a",{href:p,target:"_blank",rel:"noopener noreferrer",className:"text-primary underline",children:["Open ",p.replace(/^https?:\/\//,"")]})]})]}),A&&(0,a.jsx)(d.l6,{label:"Region",value:D,onChange:e=>U(e.target.value),options:A.map(e=>({value:e.id,label:e.label}))}),l&&(0,a.jsx)(d.pd,{label:"Default Model",value:T.defaultModel,onChange:e=>O({...T,defaultModel:e.target.value}),placeholder:r?"claude-3-5-sonnet-latest":"gpt-4o-mini"}),y&&(0,a.jsxs)("p",{className:"text-xs text-text-muted",children:["Leave blank to use ",(0,a.jsx)("code",{children:"http://localhost:11434"}),". For remote Ollama, enter the full host URL (e.g. ",(0,a.jsx)("code",{children:"http://192.168.1.10:11434"}),")."]}),z&&(0,a.jsx)(d.Ex,{variant:"success"===z?"success":"error",children:"success"===z?"Valid":"Invalid"}),K&&(0,a.jsx)("p",{className:"text-xs text-red-500 break-words",children:K}),x&&(0,a.jsx)("p",{className:"text-xs text-red-500 break-words",children:x}),l&&(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."}),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:"Cloudflare Workers AI"}),(0,a.jsx)(d.pd,{label:"Account ID",value:E.accountId,onChange:e=>R({...E,accountId:e.target.value}),placeholder:"abc123def456..."}),(0,a.jsxs)("p",{className:"text-xs text-text-muted mt-2",children:["Find your Account ID in the right sidebar of ",(0,a.jsx)("a",{href:"https://dash.cloudflare.com",target:"_blank",rel:"noopener noreferrer",className:"text-primary underline",children:"dash.cloudflare.com"})]})]}),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:"Azure OpenAI Configuration"}),(0,a.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,a.jsx)(d.pd,{label:"Azure Endpoint",value:P.azureEndpoint,onChange:e=>I({...P,azureEndpoint:e.target.value}),placeholder:"https://your-resource.openai.azure.com"}),(0,a.jsx)(d.pd,{label:"Deployment Name",value:P.deployment,onChange:e=>I({...P,deployment:e.target.value}),placeholder:"gpt-4"}),(0,a.jsx)(d.pd,{label:"API Version",value:P.apiVersion,onChange:e=>I({...P,apiVersion:e.target.value}),placeholder:"2024-10-01-preview"}),(0,a.jsx)(d.pd,{label:"Organization",value:P.organization,onChange:e=>I({...P,organization:e.target.value}),placeholder:"Organization ID"})]})]}),(0,a.jsx)(d.pd,{label:"Priority",type:"number",value:T.priority,onChange:e=>O({...T,priority:Number.parseInt(e.target.value)||1})}),(0,a.jsx)(d.l6,{label:"Proxy Pool",value:T.proxyPoolId,onChange:e=>O({...T,proxyPoolId:e.target.value}),options:[{value:g,label:"None"},...(m||[]).map(e=>({value:e.id,label:e.name}))],placeholder:"None"}),0===(m||[]).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)(d.$n,{onClick:ee,fullWidth:!0,disabled:L||!y&&!T.apiKey.trim()||k&&!T.name.trim()||l&&!T.defaultModel.trim()||C&&(!P.azureEndpoint||!P.deployment||!P.organization)||S&&!E.accountId,children:L?"Saving...":"Save"}),(0,a.jsx)(d.$n,{onClick:f,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})]})}):null}function k({isOpen:e,node:t,onSave:s,onClose:l,isAnthropic:r}){let[n,o]=(0,i.useState)({name:"",prefix:"",apiType:"chat",baseUrl:"https://api.openai.com/v1"}),[c,p]=(0,i.useState)(!1),[m,x]=(0,i.useState)(""),[u,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||(r?"https://api.anthropic.com/v1":"https://api.openai.com/v1")})},[t,r]);let v=async()=>{if(n.name.trim()&&n.prefix.trim()&&n.baseUrl.trim()){p(!0);try{let e={name:n.name,prefix:n.prefix,baseUrl:n.baseUrl};r||(e.apiType=n.apiType),await s(e)}finally{p(!1)}}},j=async()=>{g(!0);try{let e=await fetch("/api/provider-nodes/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:n.baseUrl,apiKey:m,type:r?"anthropic-compatible":"openai-compatible",modelId:u.trim()||void 0})}),t=await e.json();b(t.valid?"success":"failed")}catch{b("failed")}finally{g(!1)}};return t?(0,a.jsx)(d.aF,{isOpen:e,title:`Edit ${r?"Anthropic":"OpenAI"} Compatible`,onClose:l,children:(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,a.jsx)(d.pd,{label:"Name",value:n.name,onChange:e=>o({...n,name:e.target.value}),placeholder:`${r?"Anthropic":"OpenAI"} Compatible (Prod)`,hint:"Required. A friendly label for this node."}),(0,a.jsx)(d.pd,{label:"Prefix",value:n.prefix,onChange:e=>o({...n,prefix:e.target.value}),placeholder:r?"ac-prod":"oc-prod",hint:"Required. Used as the provider prefix for model IDs."}),!r&&(0,a.jsx)(d.l6,{label:"API Type",options:[{value:"chat",label:"Chat Completions"},{value:"responses",label:"Responses API"}],value:n.apiType,onChange:e=>o({...n,apiType:e.target.value})}),(0,a.jsx)(d.pd,{label:"Base URL",value:n.baseUrl,onChange:e=>o({...n,baseUrl:e.target.value}),placeholder:r?"https://api.anthropic.com/v1":"https://api.openai.com/v1",hint:`Use the base URL (ending in /v1) for your ${r?"Anthropic":"OpenAI"}-compatible API.`}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(d.pd,{label:"API Key (for Check)",type:"password",value:m,onChange:e=>x(e.target.value),className:"flex-1"}),(0,a.jsx)("div",{className:"pt-6",children:(0,a.jsx)(d.$n,{onClick:j,disabled:!m||f||!n.baseUrl.trim(),variant:"secondary",children:f?"Checking...":"Check"})})]}),(0,a.jsx)(d.pd,{label:"Model ID (optional)",value:u,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)(d.Ex,{variant:"success"===y?"success":"error",children:"success"===y?"Valid":"Invalid"}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(d.$n,{onClick:v,fullWidth:!0,disabled:!n.name.trim()||!n.prefix.trim()||!n.baseUrl.trim()||c,children:c?"Saving...":"Save"}),(0,a.jsx)(d.$n,{onClick:l,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})}):null}function C({isOpen:e,providerAlias:t,providerDisplayAlias:s,onSave:l,onClose:r}){let[n,o]=(0,i.useState)(""),[c,p]=(0,i.useState)(null),[m,x]=(0,i.useState)(""),[u,h]=(0,i.useState)(!1);(0,i.useEffect)(()=>{e&&(o(""),p(null),x(""))},[e]);let f=e=>{let s=`${t}/`;return e.startsWith(s)?e.slice(s.length):e},g=async()=>{let e=f(n.trim());if(e){p("testing"),x("");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();p(a.ok?"ok":"error"),x(a.error||"")}catch(e){p("error"),x(e.message)}}},y=async()=>{let e=f(n.trim());if(e&&!u){h(!0);try{await l(e)}finally{h(!1)}}};return(0,a.jsx)(d.aF,{isOpen:e,onClose:r,title:"Add Custom Model",children:(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"text-sm font-medium mb-1.5 block",children:"Model ID"}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)("input",{type:"text",value:n,onChange:e=>{o(e.target.value),p(null),x("")},onKeyDown:e=>{"Enter"===e.key&&g()},placeholder:"e.g. claude-opus-4-5",className:"flex-1 px-3 py-2 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary",autoFocus:!0}),(0,a.jsx)(d.$n,{variant:"secondary",icon:"science",loading:"testing"===c,onClick:g,disabled:!n.trim()||"testing"===c,children:"testing"===c?"Testing...":"Test"})]}),(0,a.jsxs)("p",{className:"text-xs text-text-muted mt-1",children:["Sent to provider as: ",(0,a.jsx)("code",{className:"font-mono bg-sidebar px-1 rounded",children:f(n.trim())||"model-id"})]})]}),"ok"===c&&(0,a.jsxs)("div",{className:"flex items-center gap-2 text-sm text-green-600",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-base",children:"check_circle"}),"Model is reachable"]}),"error"===c&&(0,a.jsxs)("div",{className:"flex items-start gap-2 text-sm text-red-500",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-base shrink-0",children:"cancel"}),(0,a.jsx)("span",{children:m||"Model not reachable"})]}),(0,a.jsxs)("div",{className:"flex gap-2 pt-1",children:[(0,a.jsx)(d.$n,{onClick:r,variant:"ghost",fullWidth:!0,size:"sm",children:"Cancel"}),(0,a.jsx)(d.$n,{onClick:y,fullWidth:!0,size:"sm",disabled:!n.trim()||u,children:u?"Adding...":"Add Model"})]})]})})}function S(){let e,t=(0,l.useParams)(),s=(0,l.useRouter)(),r=t.id,[x,h]=(0,i.useState)([]),[f,y]=(0,i.useState)(!0),[v,N]=(0,i.useState)(null),[S,A]=(0,i.useState)([]),[$,T]=(0,i.useState)(!1),[O,P]=(0,i.useState)(!1),[I,E]=(0,i.useState)(!1),[R,D]=(0,i.useState)(""),[U,_]=(0,i.useState)(!1),[q,z]=(0,i.useState)(!1),[M,K]=(0,i.useState)(!1),[F,L]=(0,i.useState)(null),[J,W]=(0,i.useState)({}),[V,B]=(0,i.useState)(!1),[H,G]=(0,i.useState)({}),[Q,Z]=(0,i.useState)(""),[X,Y]=(0,i.useState)(null),[ee,et]=(0,i.useState)(!1),[es,ea]=(0,i.useState)([]),[ei,el]=(0,i.useState)("__none__"),[er,en]=(0,i.useState)(!1),[eo,ed]=(0,i.useState)(null),[ec,ep]=(0,i.useState)(""),[em,ex]=(0,i.useState)("auto"),[eu,eh]=(0,i.useState)([]),[ef,eg]=(0,i.useState)([]),[ey,eb]=(0,i.useState)([]),[ev,ej]=(0,i.useState)(null),[eN,ew]=(0,i.useState)(!1),ek=(0,i.useRef)(null),[eC,eS]=(0,i.useState)(!1),[eA,e$]=(0,i.useState)(!1),[eT,eO]=(0,i.useState)(null),[eP,eI]=(0,i.useState)({}),[eE,eR]=(0,i.useState)(null),eD=(0,i.useRef)(!1),{copied:eU,copy:e_}=(0,m.C)(),eq=async e=>{let t=e.target.files?.[0];if(t){ew(!0);try{let e=await t.text(),s=JSON.parse(e),a=await fetch("/api/providers/import",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)}),i=await a.json();if(a.ok){let e=await fetch("/api/providers");if(e.ok){let t=await e.json();h((t.connections||[]).filter(e=>e.provider===r))}D("")}else D(i.error||"Import failed")}catch(e){D(e.message||"Import failed")}finally{ew(!1),ek.current&&(ek.current.value="")}}},ez=v?{id:v.id,name:v.name||("anthropic-compatible"===v.type?"Anthropic Compatible":"OpenAI Compatible"),color:"anthropic-compatible"===v.type?"#D97757":"#10A37F",textIcon:"anthropic-compatible"===v.type?"AC":"OC",apiType:v.apiType,baseUrl:v.baseUrl,type:v.type}:c.zN[r]||c.fg[r]||c.IS[r]||c.nJ[r]||c.br[r],eM=ez?.authModes||[],eK=!!c.zN[r]||!!c.IS[r]||eM.includes("oauth"),eF=!!c.fg[r]||eM.includes("apikey"),eL=!!c.IS[r]?.noAuth,eJ=(0,p.KC)(r),eW=(0,c.wG)(r),eV=(0,c.mq)(r),eB=(0,c.gb)(r),eH=eV||eB,eG=!eH&&eK&&eF,eQ="xai"===r?"Grok Build OAuth":"OAuth",eZ="xai"===r?"xAI API Key":"API Key";c.Q2[r]?.thinkingConfig||c.s9.extended;let eX=eH?r:eW,eY=eH?v?.prefix||r:eW,e0=()=>{T(!0)},e1=()=>{D(""),E(!0)},e2=(0,i.useCallback)(async()=>{try{let e=await fetch(`/api/models/disabled?providerAlias=${encodeURIComponent(eX)}`,{cache:"no-store"}),t=await e.json();e.ok&&eb(t.ids||[])}catch(e){console.log("Error fetching disabled models:",e)}},[eX]),e5=async e=>{try{(await fetch("/api/models/disabled",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerAlias:eX,ids:[e]})})).ok&&await e2()}catch(e){console.log("Error disabling model:",e)}},e3=async e=>{try{(await fetch(`/api/models/disabled?providerAlias=${encodeURIComponent(eX)}&id=${encodeURIComponent(e)}`,{method:"DELETE"})).ok&&await e2()}catch(e){console.log("Error enabling model:",e)}},e4=async e=>{e.length&&ej({title:"Disable All Models",message:`Disable all ${e.length} model(s)?`,onConfirm:async()=>{ej(null);try{(await fetch("/api/models/disabled",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerAlias:eX,ids:e})})).ok&&await e2()}catch(e){console.log("Error disabling all models:",e)}}})},e6=async()=>{try{(await fetch(`/api/models/disabled?providerAlias=${encodeURIComponent(eX)}`,{method:"DELETE"})).ok&&await e2()}catch(e){console.log("Error enabling all models:",e)}},e7=(0,i.useCallback)(async()=>{try{let e=await fetch("/api/models/alias"),t=await e.json();e.ok&&W(t.aliases||{})}catch(e){console.log("Error fetching aliases:",e)}},[]);(0,i.useEffect)(()=>{"kilocode"===r&&fetch("/api/providers/kilo/free-models").then(e=>e.json()).then(e=>{e.models?.length&&eg(e.models)}).catch(()=>{})},[r]);let e8=(0,i.useCallback)(async()=>{try{let[e,t,s,a]=await Promise.all([fetch("/api/providers",{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(),l=await t.json(),n=await s.json(),o=a.ok?await a.json():{};if(e.ok){let e=(i.connections||[]).filter(e=>e.provider===r);h(e)}s.ok&&A(n.proxyPools||[]);let d=(o.providerStrategies||{})[r]||{};ed(d.fallbackStrategy||null),ep(null!=d.stickyRoundRobinLimit?String(d.stickyRoundRobinLimit):"1");let c=(o.providerThinking||{})[r]||{};if(ex(c.mode||"auto"),t.ok){let e=(l.nodes||[]).find(e=>e.id===r)||null;if(!e&&eH)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===r)||null))break}N(e)}}catch(e){console.log("Error fetching connections:",e)}finally{y(!1)}},[r,eH]),e9=async e=>{try{let t=await fetch(`/api/provider-nodes/${r}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),s=await t.json();t.ok&&(N(s.node),await e8(),z(!1))}catch(e){console.log("Error updating provider node:",e)}},te=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 l={...a};0===Object.keys(i).length?delete l[r]:l[r]=i,await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerStrategies:l})})}catch(e){console.log("Error saving provider strategy:",e)}};(0,i.useEffect)(()=>{e8(),e7(),e2()},[e8,e7,e2]),(0,i.useEffect)(()=>{let e=(c.zN[r]||c.fg[r]||c.IS[r]||c.nJ[r])?.modelsFetcher;e&&u(e).then(eh)},[r]);let tt=async(e,t,s=eW)=>{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 e7();else{let t=await e.json();alert(t.error||"Failed to set alias")}}catch(e){console.log("Error setting alias:",e)}},ts=async e=>{try{(await fetch(`/api/models/alias?alias=${encodeURIComponent(e)}`,{method:"DELETE"})).ok&&await e7()}catch(e){console.log("Error deleting alias:",e)}},ta=async()=>{if(eC||0===x.length)return;let e=Object.fromEntries(x.map(e=>[e.id,{state:"queued",error:null}]));eD.current=!1,eS(!0),e$(!1),eO(null),eI(e),eR({total:x.length,completed:0,passed:0,failed:0,stopped:!1});let t=0,s=0;try{for(let e=0;e<x.length;e+=1){if(eD.current){eR({total:x.length,completed:e,passed:t,failed:s,stopped:!0});break}let a=x[e];eO(a.id),eI(e=>({...e,[a.id]:{state:"testing",error:null}}));try{let e=await fetch(`/api/providers/${a.id}/test`,{method:"POST"}),i=await e.json(),l=e.ok&&!!i.valid,r=l?null:i.error||"Test failed";l?t+=1:s+=1,eI(e=>({...e,[a.id]:{state:l?"success":"failed",error:r}})),h(e=>e.map(e=>e.id===a.id?{...e,testStatus:l?"active":"error",lastError:r,lastErrorAt:l?null:new Date().toISOString()}:e))}catch(e){s+=1,eI(t=>({...t,[a.id]:{state:"failed",error:e.message||"Test failed"}})),h(t=>t.map(t=>t.id===a.id?{...t,testStatus:"error",lastError:e.message||"Test failed",lastErrorAt:new Date().toISOString()}:t))}eR({total:x.length,completed:e+1,passed:t,failed:s,stopped:!1}),e<x.length-1&&await new Promise(e=>setTimeout(e,1e3))}}finally{eO(null),eS(!1),e$(!1),eD.current=!1,await e8()}},ti=async e=>{ej({title:"Delete Connection",message:"Delete this connection?",onConfirm:async()=>{ej(null);try{(await fetch(`/api/providers/${e}`,{method:"DELETE"})).ok&&h(x.filter(t=>t.id!==e))}catch(e){console.log("Error deleting connection:",e)}}})},tl=()=>{e8(),T(!1)},tr=async e=>{D("");try{let t=await fetch("/api/providers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:r,...e})}),s=null;try{s=await t.json()}catch{s=null}if(t.ok){await e8(),E(!1);return}D(s?.error||"Failed to save connection")}catch(e){console.log("Error saving connection:",e),D("Failed to save connection")}},tn=async e=>{try{(await fetch(`/api/providers/${F.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})).ok&&(await e8(),_(!1))}catch(e){console.log("Error updating connection:",e)}},to=async(e,t)=>{try{(await fetch(`/api/providers/${e}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({isActive:t})})).ok&&h(s=>s.map(s=>s.id===e?{...s,isActive:t}:s))}catch(e){console.log("Error updating connection status:",e)}},td=async(e,t)=>{let s=[...x];[s[e],s[t]]=[s[t],s[e]],h(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 e8()}},tc=x.filter(e=>es.includes(e.id));x.length>0&&(es.length,x.length),(0,i.useEffect)(()=>{ea(e=>e.filter(e=>x.some(t=>t.id===e)))},[x]),(()=>{if(0===tc.length)return;let e=new Set(tc.map(e=>e.providerSpecificData?.proxyPoolId||"__none__"));if(1===e.size){let t=[...e][0];if("__none__"===t)return;let s=S.find(e=>e.id===t);return s?.name}})();let tp=()=>{er||K(!1)},tm=async e=>{en(!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 e8(),K(!1)}finally{en(!1)}},tx=e=>tm(x.map(t=>({connectionId:t.id,proxyPoolId:e}))),tu=(0,a.jsx)("div",{className:"flex min-w-0 flex-col divide-y divide-black/[0.03] dark:divide-white/[0.03]",children:x.map((e,t)=>(0,a.jsx)("div",{className:"flex min-w-0 items-stretch",children:(0,a.jsx)("div",{className:"flex-1 min-w-0",children:(0,a.jsx)(j,{connection:e,proxyPools:S,isOAuth:eK,isFirst:0===t,isLast:t===x.length-1,onMoveUp:()=>td(t,t-1),onMoveDown:()=>td(t,t+1),onToggleActive:t=>to(e.id,t),onUpdateProxy:async t=>{try{(await fetch(`/api/providers/${e.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({proxyPoolId:t||null})})).ok&&h(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:()=>{L(e),_(!0)},onDelete:()=>ti(e.id),oneByOneStatus:eP[e.id]||null})})},e.id))}),th=S.filter(e=>!0===e.isActive),tf=(0,a.jsx)(d.aF,{isOpen:M,onClose:tp,title:`Apply Proxy (${x.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=S.filter(e=>!0===e.isActive);return 0===e.length?void alert("No active proxy pools available."):tm(x.map((t,s)=>({connectionId:t.id,proxyPoolId:e[s%e.length].id})))},disabled:er||0===th.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:()=>tx(null),disabled:er,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)"})]}),S.map(e=>(0,a.jsxs)("button",{onClick:()=>tx(e.id),disabled:er||!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))]}),er&&(0,a.jsx)("p",{className:"text-xs text-text-muted",children:"Applying..."}),(0,a.jsx)(d.$n,{onClick:tp,variant:"ghost",fullWidth:!0,disabled:er,children:"Cancel"})]})}),tg=async e=>{if(!X){Y(e);try{let t=await fetch("/api/models/test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:`${eX}/${e}`})}),s=await t.json();G(t=>({...t,[e]:s.ok?"ok":"error"})),Z(s.ok?"":s.error||"Model not reachable")}catch{G(t=>({...t,[e]:"error"})),Z("Network error")}finally{Y(null)}}};return f?(0,a.jsxs)("div",{className:"flex flex-col gap-8",children:[(0,a.jsx)(d.Qv,{}),(0,a.jsx)(d.Qv,{})]}):ez?(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:`${ez.color}15`},children:V?(0,a.jsx)("span",{className:"text-sm font-bold",style:{color:ez.color},children:ez.textIcon||ez.id.slice(0,2).toUpperCase()}):(0,a.jsx)(o.default,{src:eV&&ez.apiType?"responses"===ez.apiType?"/providers/oai-r.png":"/providers/oai-cc.png":eB?"/providers/anthropic-m.png":`/providers/${ez.id}.png`,alt:ez.name,width:48,height:48,className:"max-h-12 max-w-12 rounded-lg object-contain",sizes:"48px",onError:()=>B(!0)})}),(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsxs)("div",{className:"flex items-center gap-3 flex-wrap",children:[(0,a.jsx)("h1",{className:"truncate text-2xl font-semibold tracking-tight sm:text-3xl",children:ez.name}),(ez.notice?.apiKeyUrl||ez.notice?.signupUrl||ez.website)&&(0,a.jsxs)("a",{href:ez.notice?.apiKeyUrl||ez.notice?.signupUrl||ez.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"}),ez.notice?.apiKeyUrl?"Get API Key":"Sign up / Learn more"]})]}),(0,a.jsxs)("p",{className:"text-text-muted",children:[x.length," connection",1===x.length?"":"s"]})]})]})]}),ez.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:ez.deprecationNotice})]}),ez.notice?.text&&!ez.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:ez.notice.text}),ez.notice.apiKeyUrl&&(0,a.jsx)("a",{href:ez.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 →"})]}),eH&&v&&(0,a.jsx)(d.Zp,{children:(0,a.jsxs)("div",{className:"mb-4 flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsx)("h2",{className:"text-lg font-semibold",children:eB?"Anthropic Compatible Details":"OpenAI Compatible Details"}),(0,a.jsxs)("p",{className:"break-all text-sm text-text-muted",children:[eB?"Messages API":"responses"===v.apiType?"Responses API":"Chat Completions"," \xb7 ",(v.baseUrl||"").replace(/\/$/,""),"/",eB?"messages":"responses"===v.apiType?"responses":"chat/completions"]})]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-2 sm:flex sm:items-center",children:[(0,a.jsx)(d.$n,{size:"sm",icon:"add",onClick:()=>{D(""),E(!0)},className:"w-full sm:w-auto",children:"Add API Key"}),(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",icon:"edit",onClick:()=>z(!0),className:"w-full sm:w-auto",children:"Edit"}),(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",icon:"delete",onClick:async()=>{ej({title:"Delete Compatible Node",message:`Delete this ${eB?"Anthropic":"OpenAI"} Compatible node?`,onConfirm:async()=>{ej(null);try{(await fetch(`/api/provider-nodes/${r}`,{method:"DELETE"})).ok&&s.push("/dashboard/providers")}catch(e){console.log("Error deleting provider node:",e)}}})},className:"w-full sm:w-auto",children:"Delete"})]})]})}),eL?(0,a.jsx)(d.gw,{providerId:r}):(0,a.jsxs)(d.Zp,{children:[(0,a.jsxs)("div",{className:"mb-4 flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[(0,a.jsx)("h2",{className:"text-lg font-semibold",children:"Connections"}),(0,a.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:gap-4",children:[x.length>0&&S.length>0&&(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",icon:"lan",onClick:()=>K(!0),children:"Apply Proxy"}),x.length>0&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",icon:"sync",onClick:ta,disabled:eC,children:eC?"Testing...":"Test One-by-One"}),eC&&(0,a.jsx)(d.$n,{size:"sm",variant:"ghost",icon:"stop",onClick:()=>{eC&&(eD.current=!0,e$(!0))},disabled:eA,children:eA?"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:"Round Robin"}),(0,a.jsx)(d.lM,{checked:"round-robin"===eo,onChange:e=>{let t=e?"round-robin":null,s=e?ec||"1":ec;e&&!ec&&ep("1"),ed(t),te(t,s)}}),"round-robin"===eo&&(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:ec,onChange:e=>{var t;ep(t=e.target.value),te("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"})]})]})]})]}),(0,a.jsxs)("div",{className:"flex flex-wrap gap-2 mb-3",children:[eG?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(d.$n,{size:"sm",icon:"lock",onClick:e0,children:eQ}),(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",icon:"key",onClick:e1,children:eZ})]}):(0,a.jsx)(d.$n,{size:"sm",icon:"add",onClick:()=>{eK?e0():e1()},children:"Add"}),(0,a.jsx)("input",{ref:ek,type:"file",accept:"application/json",className:"hidden",onChange:eq}),(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",icon:"upload",onClick:()=>ek.current?.click(),disabled:eN,children:eN?"Importing...":"Import"}),(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",icon:"download",onClick:()=>window.open(`/api/providers/export?provider=${r}`,"_blank"),disabled:0===x.length,children:"Export All"})]}),0===x.length?(0,a.jsx)("div",{className:"flex items-center gap-3",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:eK?"lock":"key"})}),(0,a.jsx)("p",{className:"text-sm text-text-muted",children:"No connections yet"})]})}):(0,a.jsxs)(a.Fragment,{children:[eE&&(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: ",eE.total]}),(0,a.jsxs)("span",{children:["Completed: ",eE.completed]}),(0,a.jsxs)("span",{children:["Passed: ",eE.passed]}),(0,a.jsxs)("span",{children:["Failed: ",eE.failed]}),eE.stopped&&(0,a.jsx)("span",{className:"text-amber-600 dark:text-amber-400",children:"Stopped"}),eC&&eT&&(0,a.jsxs)("span",{children:["Running: ",x.find(e=>e.id===eT)?.name||eT]})]})}),tu]})]}),(0,a.jsxs)(d.Zp,{children:[(0,a.jsxs)("div",{className:"mb-4 flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between",children:[(0,a.jsx)("h2",{className:"text-lg font-semibold",children:"Available Models"}),!eH&&(e=[...eJ,...ef.filter(e=>!eJ.some(t=>t.id===e.id))].filter(e=>!e.type||"llm"===e.type).map(e=>e.id).filter(e=>!ey.includes(e)),(0,a.jsxs)("div",{className:"flex gap-2",children:[ey.length>0&&(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",icon:"restart_alt",onClick:e6,children:"Active All"}),e.length>0&&(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",icon:"block",onClick:()=>e4(e),children:"Disable All"})]}))]}),!!Q&&(0,a.jsx)("p",{className:"text-xs text-red-500 mb-3 break-words",children:Q}),(()=>{let e,t,s;if(eH)return(0,a.jsx)(b,{providerStorageAlias:eX,providerDisplayAlias:eY,modelAliases:J,copied:eU,onCopy:e_,onSetAlias:tt,onDeleteAlias:ts,connections:x,isAnthropic:eB});let i=[...eJ,...ef.filter(e=>!eJ.some(t=>t.id===e.id))].filter(e=>!e.type||"llm"===e.type),l=new Set(ey),n=i.filter(e=>!l.has(e.id)),o=i.filter(e=>l.has(e.id)),d=Object.entries(J).filter(([e,t])=>{let s=`${eX}/`;if(!t.startsWith(s))return!1;let a=t.slice(s.length);return ez.passthroughModels?!eJ.some(e=>e.id===a):!eJ.some(e=>e.id===a)&&e===a}).map(([e,t])=>({id:t.slice(`${eX}/`.length),alias:e,fullModel:t}));return(0,a.jsxs)("div",{className:"flex flex-wrap gap-3",children:[d.map(e=>(0,a.jsx)(g,{model:{id:e.id},fullModel:`${eY}/${e.id}`,alias:e.alias,copied:eU,onCopy:e_,onSetAlias:()=>{},onDeleteAlias:()=>ts(e.alias),testStatus:H[e.id],onTest:x.length>0||eL?()=>tg(e.id):void 0,isTesting:X===e.id,isCustom:!0,isFree:!1},e.id)),n.map(e=>{let t=`${eX}/${e.id}`,s=`${r}/${e.id}`,i=Object.entries(J).find(([,e])=>e===t||e===s)?.[0];return(0,a.jsx)(g,{model:e,fullModel:`${eY}/${e.id}`,alias:i,copied:eU,onCopy:e_,onSetAlias:t=>tt(e.id,t,eX),onDeleteAlias:()=>ts(i),testStatus:H[e.id],onTest:x.length>0||eL?()=>tg(e.id):void 0,isTesting:X===e.id,isFree:e.isFree,onDisable:()=>e5(e.id)},e.id)}),(0,a.jsxs)("button",{onClick:()=>et(!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"]}),eu.length>0&&(e=new Set(Object.values(J)),t=new Set(eJ.map(e=>e.id)),0===(s=eu.filter(s=>!e.has(`${eX}/${s.id}`)&&!t.has(s.id))).length?null:(0,a.jsxs)("div",{className:"w-full mt-2",children:[(0,a.jsx)("p",{className:"text-xs text-text-muted mb-2",children:"Suggested free models (≥200k context):"}),(0,a.jsx)("div",{className:"flex flex-wrap gap-2",children:s.map(e=>(0,a.jsxs)("button",{onClick:async()=>{let t=e.id.split("/").pop();await tt(e.id,t,eX)},className:"flex items-center gap-1 px-2.5 py-1.5 rounded-lg border border-black/10 dark:border-white/10 text-xs text-text-muted hover:text-primary hover:border-primary/40 hover:bg-primary/5 transition-colors",title:`${e.name} \xb7 ${(e.contextLength/1e3).toFixed(0)}k ctx`,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[13px]",children:"add"}),e.id.split("/").pop()]},e.id))})]})),o.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 (",o.length,"):"]}),(0,a.jsx)("div",{className:"flex flex-wrap gap-2",children:o.map(e=>(0,a.jsxs)("button",{onClick:()=>e3(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))})]})]})})()]}),tf,"kiro"===r?(0,a.jsx)(d.Mh,{isOpen:$,providerInfo:ez,onSuccess:tl,onClose:()=>T(!1)}):"codex"===r?(0,a.jsx)(d.K3,{isOpen:$,providerInfo:ez,onSuccess:tl,onClose:()=>T(!1)}):"cursor"===r?(0,a.jsx)(d.G9,{isOpen:$,onSuccess:tl,onClose:()=>T(!1)}):"gitlab"===r?(0,a.jsx)(d.vj,{isOpen:$,providerInfo:ez,onSuccess:tl,onClose:()=>T(!1)}):(0,a.jsx)(d.LF,{isOpen:$,provider:r,providerInfo:ez,onSuccess:tl,onClose:()=>T(!1)}),"iflow"===r&&(0,a.jsx)(d.vE,{isOpen:O,onSuccess:()=>{e8(),P(!1)},onClose:()=>P(!1)}),(0,a.jsx)(w,{isOpen:I,provider:r,providerName:ez.name,isCompatible:eH,isAnthropic:eB,authType:ez?.authType,authHint:ez?.authHint,website:ez?.website,proxyPools:S,error:R,onSave:tr,onBulkDone:e8,onClose:()=>{D(""),E(!1)}}),(0,a.jsx)(d.wI,{isOpen:U,connection:F,proxyPools:S,onSave:tn,onClose:()=>_(!1)}),eH&&(0,a.jsx)(k,{isOpen:q,node:v,onSave:e9,onClose:()=>z(!1),isAnthropic:eB}),!eH&&(0,a.jsx)(C,{isOpen:ee,providerAlias:eX,providerDisplayAlias:eY,onSave:async e=>{let t=ez?.passthroughModels?e.split("/").pop():e;await tt(e,t,eX),et(!1)},onClose:()=>et(!1)}),(0,a.jsx)(d.uo,{isOpen:!!ev,onClose:()=>ej(null),onConfirm:ev?.onConfirm,title:ev?.title||"Confirm",message:ev?.message,variant:"danger"})]}):(0,a.jsxs)("div",{className:"text-center py-20",children:[(0,a.jsx)("p",{className:"text-text-muted",children:"Provider not found"}),(0,a.jsx)(n(),{href:"/dashboard/providers",className:"text-primary mt-4 inline-block",children:"Back to Providers"})]})}w.propTypes={isOpen:f().bool.isRequired,provider:f().string,providerName:f().string,isCompatible:f().bool,isAnthropic:f().bool,authType:f().string,authHint:f().string,website:f().string,proxyPools:f().arrayOf(f().shape({id:f().string,name:f().string})),error:f().string,onSave:f().func.isRequired,onBulkDone:f().func,onClose:f().func.isRequired},k.propTypes={isOpen:f().bool.isRequired,node:f().shape({id:f().string,name:f().string,prefix:f().string,apiType:f().string,baseUrl:f().string}),onSave:f().func.isRequired,onClose:f().func.isRequired,isAnthropic:f().bool},C.propTypes={isOpen:f().bool.isRequired,providerAlias:f().string.isRequired,providerDisplayAlias:f().string.isRequired,onSave:f().func.isRequired,onClose:f().func.isRequired}},31325:(e,t,s)=>{Promise.resolve().then(s.bind(s,17721))}},e=>{e.O(0,[2574,3862,2194,698,5772,1321,5497,8441,3794,7358],()=>e(e.s=31325)),_N_E=e.O()}]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[9089],{15615:(e,r,t)=>{"use strict";t.r(r),t.d(r,{default:()=>u});var a=t(95155),s=t(12115),i=t(73321),l=t(98500),d=t.n(l),o=t(35497),n=t(90620);let c=Object.values(n.Q2).map(e=>({value:e.id,label:e.name})),p=Object.values(n.MA).map(e=>({value:e.id,label:e.name}));function u(){let e=(0,i.useRouter)(),[r,t]=(0,s.useState)(!1),[l,u]=(0,s.useState)({provider:"",authMethod:"api_key",apiKey:"",displayName:"",isActive:!0}),[h,m]=(0,s.useState)({}),x=(e,r)=>{u(t=>({...t,[e]:r})),h[e]&&m(r=>({...r,[e]:null}))},b=async r=>{let a;if(r.preventDefault(),a={},l.provider||(a.provider="Please select a provider"),"api_key"!==l.authMethod||l.apiKey||(a.apiKey="API Key is required"),m(a),0===Object.keys(a).length){t(!0);try{let r=await fetch("/api/providers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(l)});if(r.ok)e.push("/dashboard/providers");else{let e=await r.json();m({submit:e.error||"Failed to create provider"})}}catch(e){m({submit:"An error occurred. Please try again."})}finally{t(!1)}}},v=n.Q2[l.provider];return(0,a.jsxs)("div",{className:"max-w-2xl mx-auto",children:[(0,a.jsxs)("div",{className:"mb-8",children:[(0,a.jsxs)(d(),{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.jsx)("h1",{className:"text-3xl font-semibold tracking-tight",children:"Add New Provider"}),(0,a.jsx)("p",{className:"text-text-muted mt-2",children:"Configure a new AI provider to use with your applications."})]}),(0,a.jsx)(o.Zp,{children:(0,a.jsxs)("form",{onSubmit:b,className:"flex flex-col gap-6",children:[(0,a.jsx)(o.l6,{label:"Provider",options:c,value:l.provider,onChange:e=>x("provider",e.target.value),placeholder:"Select a provider",error:h.provider,required:!0}),v&&(0,a.jsxs)(o.Zp.Section,{className:"flex items-center gap-3",children:[(0,a.jsx)("div",{className:"size-10 rounded-lg flex items-center justify-center bg-bg border border-border",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-xl",style:{color:v.color},children:v.icon})}),(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"font-medium",children:v.name}),(0,a.jsx)("p",{className:"text-sm text-text-muted",children:"Selected provider"})]})]}),(0,a.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,a.jsxs)("label",{className:"text-sm font-medium",children:["Authentication Method ",(0,a.jsx)("span",{className:"text-red-500",children:"*"})]}),(0,a.jsx)("div",{className:"flex gap-3",children:p.map(e=>(0,a.jsxs)("button",{type:"button",onClick:()=>x("authMethod",e.value),className:`flex-1 flex items-center justify-center gap-2 p-4 rounded-lg border transition-all ${l.authMethod===e.value?"border-primary bg-primary/5 text-primary":"border-border hover:border-primary/50"}`,children:[(0,a.jsx)("span",{className:"material-symbols-outlined",children:"api_key"===e.value?"key":"lock"}),(0,a.jsx)("span",{className:"font-medium",children:e.label})]},e.value))})]}),"api_key"===l.authMethod&&(0,a.jsx)(o.pd,{label:"API Key",type:"password",placeholder:"Enter your API key",value:l.apiKey,onChange:e=>x("apiKey",e.target.value),error:h.apiKey,hint:"Your API key will be encrypted and stored securely.",required:!0}),"oauth2"===l.authMethod&&(0,a.jsxs)(o.Zp.Section,{children:[(0,a.jsx)("p",{className:"text-sm text-text-muted mb-4",children:"Connect your account using OAuth2 authentication."}),(0,a.jsx)(o.$n,{type:"button",variant:"secondary",icon:"link",children:"Connect with OAuth2"})]}),(0,a.jsx)(o.pd,{label:"Display Name",placeholder:"e.g., Production API, Dev Environment",value:l.displayName,onChange:e=>x("displayName",e.target.value),hint:"Optional. A friendly name to identify this configuration."}),(0,a.jsx)(o.lM,{checked:l.isActive,onChange:e=>x("isActive",e),label:"Active",description:"Enable this provider for use in your applications"}),h.submit&&(0,a.jsx)("div",{className:"p-4 rounded-lg bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 text-red-600 dark:text-red-400 text-sm",children:h.submit}),(0,a.jsxs)("div",{className:"flex gap-3 pt-4 border-t border-border",children:[(0,a.jsx)(d(),{href:"/dashboard/providers",className:"flex-1",children:(0,a.jsx)(o.$n,{type:"button",variant:"ghost",fullWidth:!0,children:"Cancel"})}),(0,a.jsx)(o.$n,{type:"submit",loading:r,fullWidth:!0,className:"flex-1",children:"Create Provider"})]})]})})]})}},
|
|
1
|
+
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[9089],{15615:(e,r,t)=>{"use strict";t.r(r),t.d(r,{default:()=>u});var a=t(95155),s=t(12115),i=t(73321),l=t(98500),d=t.n(l),o=t(35497),n=t(90620);let c=Object.values(n.Q2).map(e=>({value:e.id,label:e.name})),p=Object.values(n.MA).map(e=>({value:e.id,label:e.name}));function u(){let e=(0,i.useRouter)(),[r,t]=(0,s.useState)(!1),[l,u]=(0,s.useState)({provider:"",authMethod:"api_key",apiKey:"",displayName:"",isActive:!0}),[h,m]=(0,s.useState)({}),x=(e,r)=>{u(t=>({...t,[e]:r})),h[e]&&m(r=>({...r,[e]:null}))},b=async r=>{let a;if(r.preventDefault(),a={},l.provider||(a.provider="Please select a provider"),"api_key"!==l.authMethod||l.apiKey||(a.apiKey="API Key is required"),m(a),0===Object.keys(a).length){t(!0);try{let r=await fetch("/api/providers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(l)});if(r.ok)e.push("/dashboard/providers");else{let e=await r.json();m({submit:e.error||"Failed to create provider"})}}catch(e){m({submit:"An error occurred. Please try again."})}finally{t(!1)}}},v=n.Q2[l.provider];return(0,a.jsxs)("div",{className:"max-w-2xl mx-auto",children:[(0,a.jsxs)("div",{className:"mb-8",children:[(0,a.jsxs)(d(),{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.jsx)("h1",{className:"text-3xl font-semibold tracking-tight",children:"Add New Provider"}),(0,a.jsx)("p",{className:"text-text-muted mt-2",children:"Configure a new AI provider to use with your applications."})]}),(0,a.jsx)(o.Zp,{children:(0,a.jsxs)("form",{onSubmit:b,className:"flex flex-col gap-6",children:[(0,a.jsx)(o.l6,{label:"Provider",options:c,value:l.provider,onChange:e=>x("provider",e.target.value),placeholder:"Select a provider",error:h.provider,required:!0}),v&&(0,a.jsxs)(o.Zp.Section,{className:"flex items-center gap-3",children:[(0,a.jsx)("div",{className:"size-10 rounded-lg flex items-center justify-center bg-bg border border-border",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-xl",style:{color:v.color},children:v.icon})}),(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"font-medium",children:v.name}),(0,a.jsx)("p",{className:"text-sm text-text-muted",children:"Selected provider"})]})]}),(0,a.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,a.jsxs)("label",{className:"text-sm font-medium",children:["Authentication Method ",(0,a.jsx)("span",{className:"text-red-500",children:"*"})]}),(0,a.jsx)("div",{className:"flex gap-3",children:p.map(e=>(0,a.jsxs)("button",{type:"button",onClick:()=>x("authMethod",e.value),className:`flex-1 flex items-center justify-center gap-2 p-4 rounded-lg border transition-all ${l.authMethod===e.value?"border-primary bg-primary/5 text-primary":"border-border hover:border-primary/50"}`,children:[(0,a.jsx)("span",{className:"material-symbols-outlined",children:"api_key"===e.value?"key":"lock"}),(0,a.jsx)("span",{className:"font-medium",children:e.label})]},e.value))})]}),"api_key"===l.authMethod&&(0,a.jsx)(o.pd,{label:"API Key",type:"password",placeholder:"Enter your API key",value:l.apiKey,onChange:e=>x("apiKey",e.target.value),error:h.apiKey,hint:"Your API key will be encrypted and stored securely.",required:!0}),"oauth2"===l.authMethod&&(0,a.jsxs)(o.Zp.Section,{children:[(0,a.jsx)("p",{className:"text-sm text-text-muted mb-4",children:"Connect your account using OAuth2 authentication."}),(0,a.jsx)(o.$n,{type:"button",variant:"secondary",icon:"link",children:"Connect with OAuth2"})]}),(0,a.jsx)(o.pd,{label:"Display Name",placeholder:"e.g., Production API, Dev Environment",value:l.displayName,onChange:e=>x("displayName",e.target.value),hint:"Optional. A friendly name to identify this configuration."}),(0,a.jsx)(o.lM,{checked:l.isActive,onChange:e=>x("isActive",e),label:"Active",description:"Enable this provider for use in your applications"}),h.submit&&(0,a.jsx)("div",{className:"p-4 rounded-lg bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 text-red-600 dark:text-red-400 text-sm",children:h.submit}),(0,a.jsxs)("div",{className:"flex gap-3 pt-4 border-t border-border",children:[(0,a.jsx)(d(),{href:"/dashboard/providers",className:"flex-1",children:(0,a.jsx)(o.$n,{type:"button",variant:"ghost",fullWidth:!0,children:"Cancel"})}),(0,a.jsx)(o.$n,{type:"submit",loading:r,fullWidth:!0,className:"flex-1",children:"Create Provider"})]})]})})]})}},23854:(e,r,t)=>{Promise.resolve().then(t.bind(t,15615))}},e=>{e.O(0,[2574,3862,2194,698,1321,5497,8441,3794,7358],()=>e(e.s=23854)),_N_E=e.O()}]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[8460],{13288:(e,t,s)=>{Promise.resolve().then(s.bind(s,52154))},52154:(e,t,s)=>{"use strict";s.r(t),s.d(t,{default:()=>b});var r=s(95155),a=s(12115),l=s(14051),i=s.n(l),n=s(35497),o=s(57250),d=s(90620),c=s(52679),p=s(98500),m=s.n(p),x=s(65921),u=s(38003);let h={available:{icon:"check_circle",color:"#22c55e",label:"Available"},cooldown:{icon:"schedule",color:"#f59e0b",label:"Cooldown"},unavailable:{icon:"error",color:"#ef4444",label:"Unavailable"},unknown:{icon:"help",color:"#6b7280",label:"Unknown"}};function f(){let[e,t]=(0,a.useState)(null),[s,l]=(0,a.useState)(!0),[i,o]=(0,a.useState)(!1),[d,c]=(0,a.useState)(null),p=(0,a.useRef)(null),m=(0,x.i)(),u=(0,a.useCallback)(async()=>{try{let e=await fetch("/api/models/availability");if(e.ok){let s=await e.json();t(s)}}catch{}finally{l(!1)}},[]);(0,a.useEffect)(()=>{u();let e=setInterval(u,3e4);return()=>clearInterval(e)},[u]),(0,a.useEffect)(()=>{let e=e=>{p.current&&!p.current.contains(e.target)&&o(!1)};return i&&document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[i]);let f=async(e,t)=>{c(`${e}:${t}`);try{(await fetch("/api/models/availability",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"clearCooldown",provider:e,model:t})})).ok?(m.success(`Cooldown cleared for ${t}`),await u()):m.error("Failed to clear cooldown")}catch{m.error("Failed to clear cooldown")}finally{c(null)}};if(s)return null;let g=e?.models||[],b=0===(e?.unavailableCount||g.filter(e=>"available"!==e.status).length),v={};return g.forEach(e=>{if("available"===e.status)return;let t=e.provider||"unknown";v[t]||(v[t]=[]),v[t].push(e)}),(0,r.jsx)("div",{className:"relative",ref:p,children:i&&(0,r.jsxs)("div",{className:"absolute top-full right-0 mt-2 w-80 bg-surface border border-border rounded-xl shadow-2xl z-50 overflow-hidden",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border bg-bg",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-[16px]",style:{color:b?"#22c55e":"#f59e0b"},children:b?"verified":"warning"}),(0,r.jsx)("span",{className:"text-sm font-semibold text-text-main",children:"Model Status"})]}),(0,r.jsx)("button",{onClick:u,className:"p-1 rounded-lg hover:bg-surface text-text-muted hover:text-text-main transition-colors",title:"Refresh",children:(0,r.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"refresh"})})]}),(0,r.jsx)("div",{className:"px-4 py-3 max-h-60 overflow-y-auto",children:b?(0,r.jsx)("p",{className:"text-sm text-text-muted text-center py-2",children:"All models are responding normally."}):(0,r.jsx)("div",{className:"flex flex-col gap-2.5",children:Object.entries(v).map(([e,t])=>(0,r.jsxs)("div",{children:[(0,r.jsx)("p",{className:"text-xs font-semibold text-text-main mb-1.5 capitalize",children:e}),(0,r.jsx)("div",{className:"flex flex-col gap-1",children:t.map(e=>{let t=h[e.status]||h.unknown,s=d===`${e.provider}:${e.model}`;return(0,r.jsxs)("div",{className:"flex items-center justify-between px-2.5 py-1.5 rounded-lg bg-surface/30",children:[(0,r.jsxs)("div",{className:"flex items-center gap-1.5 min-w-0",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-[14px] shrink-0",style:{color:t.color},children:t.icon}),(0,r.jsx)("span",{className:"font-mono text-xs text-text-main truncate",children:e.model})]}),"cooldown"===e.status&&(0,r.jsx)(n.$n,{size:"sm",variant:"ghost",onClick:()=>f(e.provider,e.model),disabled:s,className:"text-[10px] px-1.5! py-0.5! ml-2",children:s?"...":"Clear"})]},`${e.provider}-${e.model}`)})})]},e))})})]})})}function g(e,t,s){let a=[];if(e>0&&a.push((0,r.jsxs)(n.Ex,{variant:"success",size:"sm",dot:!0,children:[e," Connected"]},"connected")),t>0){let e=s?`${t} Error (${s})`:`${t} Error`;a.push((0,r.jsx)(n.Ex,{variant:"error",size:"sm",dot:!0,children:e},"error"))}return 0===a.length?(0,r.jsx)("span",{className:"text-text-muted",children:"No connections"}):a}function b(){let[e,t]=(0,a.useState)([]),[s,l]=(0,a.useState)([]),[i,o]=(0,a.useState)(!0),[p,m]=(0,a.useState)(!1),h=(0,a.useRef)(null),g=async e=>{let s=e.target.files?.[0];if(s){m(!0);try{let e=await s.text(),r=JSON.parse(e),a=await fetch("/api/providers/import",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)}),l=await a.json();if(a.ok){R.success(`Imported ${l.imported}, skipped ${l.skipped}`);let e=await fetch("/api/providers");if(e.ok){let s=await e.json();t(s.connections||[])}}else R.error(l.error||"Import failed")}catch(e){R.error(e.message||"Import failed")}finally{m(!1),h.current&&(h.current.value="")}}},[b,C]=(0,a.useState)(!1),[k,T]=(0,a.useState)(!1),[A,I]=(0,a.useState)(!1),[S,$]=(0,a.useState)(null),[O,E]=(0,a.useState)(null),R=(0,x.i)(),U=(0,u.C)(e=>e.query),P=(0,u.C)(e=>e.register),_=(0,u.C)(e=>e.unregister);(0,a.useEffect)(()=>(P("Search providers..."),()=>_()),[P,_]);let z=e=>!U.trim()||e.toLowerCase().includes(U.trim().toLowerCase()),q=(e,t)=>[...e].sort(([e,s],[r,a])=>{let l=D(e,t),i=D(r,t),n=+(l.connected>0),o=+(i.connected>0);return n!==o?o-n:(s.name||"").localeCompare(a.name||"")});(0,a.useEffect)(()=>{(async()=>{try{let[e,s]=await Promise.all([fetch("/api/providers"),fetch("/api/provider-nodes")]),r=await e.json(),a=await s.json();e.ok&&t(r.connections||[]),s.ok&&l(a.nodes||[])}catch(e){console.log("Error fetching data:",e)}finally{o(!1)}})()},[]);let D=(t,s)=>{let r=e.filter(e=>e.provider===t&&e.authType===s),a=e=>{let t=Object.entries(e).some(([e,t])=>e.startsWith("modelLock_")&&t&&new Date(t).getTime()>Date.now());return"unavailable"!==e.testStatus||t?e.testStatus:"active"},l=r.filter(e=>{let t=a(e);return"active"===t||"success"===t}).length,i=r.filter(e=>{let t=a(e);return"error"===t||"expired"===t||"unavailable"===t}),n=i.length,o=r.length,d=o>0&&r.every(e=>!1===e.isActive),c=i.sort((e,t)=>new Date(t.lastErrorAt||0)-new Date(e.lastErrorAt||0))[0];return{connected:l,error:n,total:o,errorCode:c?function(e){if(!e)return null;let t=e.lastErrorType;if("runtime_error"===t)return"RUNTIME";if("upstream_auth_error"===t||"auth_missing"===t||"token_refresh_failed"===t||"token_expired"===t)return"AUTH";if("upstream_rate_limited"===t)return"429";if("upstream_unavailable"===t)return"5XX";if("network_error"===t)return"NET";let s=Number(e.errorCode);if(Number.isFinite(s)&&s>=400)return String(s);let r=function(e){if(!e)return null;let t=e.match(/\b([45]\d{2})\b/);return t?t[1]:"ERR"}(e.lastError);if("401"===r||"403"===r)return"AUTH";if(r&&"ERR"!==r)return r;let a=(e.lastError||"").toLowerCase();return a.includes("runtime")||a.includes("not runnable")||a.includes("not installed")?"RUNTIME":a.includes("invalid api key")||a.includes("token invalid")||a.includes("revoked")||a.includes("unauthorized")?"AUTH":"ERR"}(c):null,errorTime:c?.lastErrorAt?function(e){if(!e)return"";let t=Math.floor((Date.now()-new Date(e).getTime())/6e4);if(t<1)return"just now";if(t<60)return`${t}m ago`;let s=Math.floor(t/60);if(s<24)return`${s}h ago`;let r=Math.floor(s/24);return`${r}d ago`}(c.lastErrorAt):null,allDisabled:d}},F=async(s,r,a)=>{let l=e.filter(e=>e.provider===s&&e.authType===r);t(e=>e.map(e=>e.provider===s&&e.authType===r?{...e,isActive:a}:e)),await Promise.allSettled(l.map(e=>fetch(`/api/providers/${e.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({isActive:a})})))},M=async(e,t=null)=>{if(!S){$("provider"===e?t:e),E(null);try{let s=await fetch("/api/providers/test-batch",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mode:e,providerId:t})}),r=await s.json();if(E(r),r.summary){let{passed:e,failed:t,total:s}=r.summary;0===t?R.success(`All ${s} tests passed`):R.warning(`${e}/${s} passed, ${t} failed`)}}catch(e){E({error:"Test request failed"}),R.error("Provider test failed")}finally{$(null)}}},J=s.filter(e=>"openai-compatible"===e.type).map(e=>({id:e.id,name:e.name||"OpenAI Compatible",color:"#10A37F",textIcon:"OC",apiType:e.apiType})).filter(e=>z(e.name)),K=s.filter(e=>"anthropic-compatible"===e.type).map(e=>({id:e.id,name:e.name||"Anthropic Compatible",color:"#D97757",textIcon:"AC"})).filter(e=>z(e.name)),L=Object.entries(d.zN).filter(([,e])=>z(e.name)),W=Object.entries(c.IS).filter(([,e])=>z(e.name)),H=Object.entries(c.nJ).filter(([,e])=>z(e.name)),B=q(Object.entries(d.fg).filter(([,e])=>(e.serviceKinds??["llm"]).includes("llm")&&z(e.name)),"apikey"),Q=q(Object.entries(c.br).filter(([,e])=>(e.serviceKinds??["llm"]).includes("llm")&&z(e.name)),"cookie"),V=!!U.trim(),X=V||b?B:B.slice(0,20),Z=B.length-20;if(i)return(0,r.jsxs)("div",{className:"flex flex-col gap-8",children:[(0,r.jsx)(n.Qv,{}),(0,r.jsx)(n.Qv,{})]});let G=L.length>0||W.length>0||H.length>0||B.length>0||Q.length>0||J.length>0||K.length>0;return(0,r.jsxs)("div",{className:"flex min-w-0 flex-col gap-6 px-1 sm:px-0",children:[!G&&(0,r.jsxs)("div",{className:"text-center py-8 border border-dashed border-border rounded-xl",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-[32px] text-text-muted mb-2",children:"search_off"}),(0,r.jsx)("p",{className:"text-text-muted text-sm",children:"No providers match your search"})]}),(0,r.jsxs)("div",{className:"flex flex-wrap items-center justify-end gap-2",children:[(0,r.jsx)("input",{ref:h,type:"file",accept:"application/json",className:"hidden",onChange:g}),(0,r.jsx)(n.$n,{size:"sm",variant:"secondary",icon:"upload",onClick:()=>h.current?.click(),disabled:p,children:p?"Importing...":"Import"}),(0,r.jsx)(n.$n,{size:"sm",variant:"secondary",icon:"download",onClick:()=>{window.open("/api/providers/export","_blank")},children:"Export"})]}),(0,r.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,r.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[(0,r.jsxs)("h2",{className:"text-lg sm:text-xl font-semibold flex items-center gap-2 leading-tight",children:["Custom Providers (OpenAI/Anthropic Compatible)"," "]}),(0,r.jsxs)("div",{className:"grid grid-cols-1 gap-2 sm:flex sm:w-auto",children:[(0,r.jsx)(n.$n,{size:"sm",icon:"add",onClick:()=>I(!0),className:"w-full sm:w-auto",children:"Add Anthropic Compatible"}),(0,r.jsx)(n.$n,{size:"sm",variant:"secondary",icon:"add",onClick:()=>T(!0),className:"w-full !bg-white !text-black hover:!bg-gray-100 sm:w-auto",children:"Add OpenAI Compatible"})]})]}),0===J.length&&0===K.length?(0,r.jsxs)("div",{className:"flex items-center justify-center gap-2 py-2 border border-dashed border-border rounded-xl text-text-muted text-sm",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"extension"}),(0,r.jsx)("span",{children:"No custom providers — use buttons above to add OpenAI/Anthropic compatible endpoints"})]}):(0,r.jsx)("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2 sm:gap-4 lg:grid-cols-3 xl:grid-cols-4",children:[...J,...K].map(e=>(0,r.jsx)(y,{providerId:e.id,provider:e,stats:D(e.id,"apikey"),authType:"compatible",onToggle:t=>F(e.id,"apikey",t)},e.id))})]}),L.length>0&&(0,r.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,r.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[(0,r.jsx)("h2",{className:"text-lg sm:text-xl font-semibold flex items-center gap-2 leading-tight",children:"OAuth Providers"}),(0,r.jsxs)("div",{className:"flex w-full flex-col gap-2 sm:w-auto sm:flex-row sm:items-center",children:[(0,r.jsx)(f,{}),(0,r.jsxs)("button",{onClick:()=>M("oauth"),disabled:!!S,className:`flex w-full items-center justify-center gap-1.5 rounded-lg border px-3 py-2 text-xs font-medium transition-colors sm:w-auto sm:py-1.5 ${"oauth"===S?"bg-primary/20 border-primary/40 text-primary animate-pulse":"bg-bg border-border text-text-muted hover:text-text-main hover:border-primary/40"}`,title:"Test all OAuth connections","aria-label":"Test all OAuth connections",children:[(0,r.jsx)("span",{className:`material-symbols-outlined text-[14px]${"oauth"===S?" animate-spin":""}`,children:"play_arrow"}),"oauth"===S?"Testing...":"Test All"]})]})]}),(0,r.jsx)("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2 sm:gap-4 lg:grid-cols-3 xl:grid-cols-4",children:L.map(([e,t])=>(0,r.jsx)(v,{providerId:e,provider:t,stats:D(e,"oauth"),authType:"oauth",onToggle:t=>F(e,"oauth",t)},e))})]}),(W.length>0||H.length>0)&&(0,r.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,r.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[(0,r.jsx)("h2",{className:"text-lg sm:text-xl font-semibold flex items-center gap-2 leading-tight",children:"Free Tier Providers"}),(0,r.jsxs)("button",{onClick:()=>M("free"),disabled:!!S,className:`flex w-full items-center justify-center gap-1.5 rounded-lg border px-3 py-2 text-xs font-medium transition-colors sm:w-auto sm:py-1.5 ${"free"===S?"bg-primary/20 border-primary/40 text-primary animate-pulse":"bg-bg border-border text-text-muted hover:text-text-main hover:border-primary/40"}`,title:"Test all Free connections","aria-label":"Test all Free provider connections",children:[(0,r.jsx)("span",{className:`material-symbols-outlined text-[14px]${"free"===S?" animate-spin":""}`,children:"play_arrow"}),"free"===S?"Testing...":"Test All"]})]}),(0,r.jsxs)("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2 sm:gap-4 lg:grid-cols-3 xl:grid-cols-4",children:[W.map(([e,t])=>(0,r.jsx)(v,{providerId:e,provider:t,stats:D(e,"oauth"),authType:"free",onToggle:t=>F(e,"oauth",t)},e)),H.map(([e,t])=>(0,r.jsx)(y,{providerId:e,provider:t,stats:D(e,"apikey"),authType:"apikey",onToggle:t=>F(e,"apikey",t)},e))]})]}),B.length>0&&(0,r.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,r.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[(0,r.jsxs)("h2",{className:"text-lg sm:text-xl font-semibold flex items-center gap-2 leading-tight",children:["API Key Providers"," "]}),(0,r.jsxs)("button",{onClick:()=>M("apikey"),disabled:!!S,className:`flex w-full items-center justify-center gap-1.5 rounded-lg border px-3 py-2 text-xs font-medium transition-colors sm:w-auto sm:py-1.5 ${"apikey"===S?"bg-primary/20 border-primary/40 text-primary animate-pulse":"bg-bg border-border text-text-muted hover:text-text-main hover:border-primary/40"}`,title:"Test all API Key connections","aria-label":"Test all API Key connections",children:[(0,r.jsx)("span",{className:`material-symbols-outlined text-[14px]${"apikey"===S?" animate-spin":""}`,children:"play_arrow"}),"apikey"===S?"Testing...":"Test All"]})]}),(0,r.jsx)("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2 sm:gap-4 lg:grid-cols-3 xl:grid-cols-4",children:X.map(([e,t])=>(0,r.jsx)(y,{providerId:e,provider:t,stats:D(e,"apikey"),authType:"apikey",onToggle:t=>F(e,"apikey",t)},e))}),!V&&!b&&Z>0&&(0,r.jsxs)("button",{onClick:()=>C(!0),className:"flex w-full items-center justify-center gap-1.5 rounded-lg border border-dashed border-primary/40 px-3 py-2.5 text-sm font-medium text-primary transition-colors hover:border-primary hover:bg-primary/5",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"expand_more"}),"Show all ",B.length," providers"]})]}),Q.length>0&&(0,r.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,r.jsx)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:(0,r.jsxs)("h2",{className:"text-lg sm:text-xl font-semibold flex items-center gap-2 leading-tight",children:["Web Cookie Providers"," "]})}),(0,r.jsx)("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2 sm:gap-4 lg:grid-cols-3 xl:grid-cols-4",children:Q.map(([e,t])=>(0,r.jsx)(y,{providerId:e,provider:t,stats:D(e,"cookie"),authType:"cookie",onToggle:t=>F(e,"cookie",t)},e))})]}),(0,r.jsx)(j,{isOpen:k,onClose:()=>T(!1),onCreated:e=>{l(t=>[...t,e]),T(!1)}}),(0,r.jsx)(N,{isOpen:A,onClose:()=>I(!1),onCreated:e=>{l(t=>[...t,e]),I(!1)}}),O&&(0,r.jsxs)("div",{className:"fixed inset-0 z-50 flex items-start justify-center px-3 pt-[6vh] sm:pt-[10vh]",onClick:()=>E(null),children:[(0,r.jsx)("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm"}),(0,r.jsxs)("div",{className:"relative bg-surface border border-border rounded-xl w-full max-w-[600px] max-h-[86vh] sm:max-h-[80vh] overflow-y-auto shadow-2xl",onClick:e=>e.stopPropagation(),children:[(0,r.jsxs)("div",{className:"sticky top-0 z-10 flex items-center justify-between px-5 py-3 border-b border-border bg-surface/95 backdrop-blur-sm rounded-t-xl",children:[(0,r.jsx)("h3",{className:"font-semibold",children:"Test Results"}),(0,r.jsx)("button",{onClick:()=>E(null),className:"p-1 rounded-lg hover:bg-bg text-text-muted hover:text-text-main transition-colors","aria-label":"Close test results",children:(0,r.jsx)("span",{className:"material-symbols-outlined text-lg",children:"close"})})]}),(0,r.jsx)("div",{className:"p-5",children:(0,r.jsx)(w,{results:O})})]})]})]})}function v({providerId:e,provider:t,stats:s,authType:a,onToggle:l}){let{connected:i,error:d,errorCode:c,errorTime:p,allDisabled:x}=s,u=!!t.noAuth;return(0,r.jsx)(m(),{href:`/dashboard/providers/${e}`,className:"group min-w-0",children:(0,r.jsx)(n.Zp,{padding:"xs",className:`h-full hover:bg-black/[0.01] dark:hover:bg-white/[0.01] transition-colors cursor-pointer ${x?"opacity-50":""}`,children:(0,r.jsxs)("div",{className:"flex min-w-0 items-center justify-between gap-3",children:[(0,r.jsxs)("div",{className:"flex min-w-0 items-center gap-3",children:[(0,r.jsx)("div",{className:"size-8 shrink-0 rounded-lg flex items-center justify-center",style:{backgroundColor:`${t.color?.length>7?t.color:t.color+"15"}`},children:(0,r.jsx)(o.A,{src:`/providers/${t.id}.png`,alt:t.name,size:30,className:"object-contain rounded-lg max-w-[32px] max-h-[32px]",fallbackText:t.textIcon||t.id.slice(0,2).toUpperCase(),fallbackColor:t.color})}),(0,r.jsxs)("div",{className:"min-w-0",children:[(0,r.jsx)("h3",{className:"truncate font-semibold",children:t.name}),(0,r.jsx)("div",{className:"flex min-w-0 items-center gap-1.5 text-xs flex-wrap",children:x?(0,r.jsx)(n.Ex,{variant:"default",size:"sm",children:(0,r.jsxs)("span",{className:"flex items-center gap-1",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-[12px]",children:"pause_circle"}),"Disabled"]})}):u?(0,r.jsx)(n.Ex,{variant:"success",size:"sm",dot:!0,children:"Ready"}):(0,r.jsxs)(r.Fragment,{children:[g(i,d,c),p&&(0,r.jsx)("span",{className:"text-text-muted",children:p})]})})]})]}),(0,r.jsx)("div",{className:"flex shrink-0 items-center gap-2",children:s.total>0&&(0,r.jsx)("div",{className:"opacity-100 transition-opacity sm:opacity-0 sm:group-hover:opacity-100",onClick:e=>{e.preventDefault(),e.stopPropagation(),l(!!x)},children:(0,r.jsx)(n.lM,{size:"sm",checked:!x,onChange:()=>{},title:x?"Enable provider":"Disable provider"})})})]})})})}function y({providerId:e,provider:t,stats:s,authType:a,onToggle:l}){let{connected:i,error:d,errorCode:p,errorTime:x,allDisabled:u}=s,h=e.startsWith(c.JH),f=e.startsWith(c.DI);return(0,r.jsx)(m(),{href:`/dashboard/providers/${e}`,className:"group min-w-0",children:(0,r.jsx)(n.Zp,{padding:"xs",className:`h-full hover:bg-black/[0.01] dark:hover:bg-white/[0.01] transition-colors cursor-pointer ${u?"opacity-50":""}`,children:(0,r.jsxs)("div",{className:"flex min-w-0 items-center justify-between gap-3",children:[(0,r.jsxs)("div",{className:"flex min-w-0 items-center gap-3",children:[(0,r.jsx)("div",{className:"size-8 shrink-0 rounded-lg flex items-center justify-center",style:{backgroundColor:`${t.color?.length>7?t.color:t.color+"15"}`},children:(0,r.jsx)(o.A,{src:h?"responses"===t.apiType?"/providers/oai-r.png":"/providers/oai-cc.png":f?"/providers/anthropic-m.png":`/providers/${t.id}.png`,alt:t.name,size:30,className:"object-contain rounded-lg max-w-[30px] max-h-[30px]",fallbackText:t.textIcon||t.id.slice(0,2).toUpperCase(),fallbackColor:t.color})}),(0,r.jsxs)("div",{className:"min-w-0",children:[(0,r.jsx)("h3",{className:"truncate font-semibold",children:t.name}),(0,r.jsx)("div",{className:"flex min-w-0 items-center gap-1.5 text-xs flex-wrap",children:u?(0,r.jsx)(n.Ex,{variant:"default",size:"sm",children:(0,r.jsxs)("span",{className:"flex items-center gap-1",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-[12px]",children:"pause_circle"}),"Disabled"]})}):(0,r.jsxs)(r.Fragment,{children:[g(i,d,p),h&&(0,r.jsx)(n.Ex,{variant:"default",size:"sm",children:"responses"===t.apiType?"Responses":"Chat"}),f&&(0,r.jsx)(n.Ex,{variant:"default",size:"sm",children:"Messages"}),x&&(0,r.jsx)("span",{className:"text-text-muted",children:x})]})})]})]}),(0,r.jsx)("div",{className:"flex shrink-0 items-center gap-2",children:s.total>0&&(0,r.jsx)("div",{className:"opacity-100 transition-opacity sm:opacity-0 sm:group-hover:opacity-100",onClick:e=>{e.preventDefault(),e.stopPropagation(),l(!!u)},children:(0,r.jsx)(n.lM,{size:"sm",checked:!u,onChange:()=>{},title:u?"Enable provider":"Disable provider"})})})]})})})}function j({isOpen:e,onClose:t,onCreated:s}){let[l,i]=(0,a.useState)({name:"",prefix:"",apiType:"chat",baseUrl:"https://api.openai.com/v1"}),[o,d]=(0,a.useState)(!1),[c,p]=(0,a.useState)(""),[m,x]=(0,a.useState)(""),[u,h]=(0,a.useState)(!1),[f,g]=(0,a.useState)(null);(0,a.useEffect)(()=>{i(e=>({...e,baseUrl:"https://api.openai.com/v1"}))},[l.apiType]);let b=async()=>{if(l.name.trim()&&l.prefix.trim()&&l.baseUrl.trim()){d(!0);try{let e=await fetch("/api/provider-nodes",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:l.name,prefix:l.prefix,apiType:l.apiType,baseUrl:l.baseUrl,type:"openai-compatible"})}),t=await e.json();e.ok&&(s(t.node),i({name:"",prefix:"",apiType:"chat",baseUrl:"https://api.openai.com/v1"}),p(""),g(null))}catch(e){console.log("Error creating OpenAI Compatible node:",e)}finally{d(!1)}}},v=async()=>{h(!0);try{let e=await fetch("/api/provider-nodes/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:l.baseUrl,apiKey:c,type:"openai-compatible",modelId:m.trim()||void 0})}),t=await e.json();g(t)}catch{g({valid:!1,error:"Network error"})}finally{h(!1)}};return(0,r.jsx)(n.aF,{isOpen:e,title:"Add OpenAI Compatible",onClose:t,children:(0,r.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,r.jsx)(n.pd,{label:"Name",value:l.name,onChange:e=>i({...l,name:e.target.value}),placeholder:"OpenAI Compatible (Prod)",hint:"Required. A friendly label for this node."}),(0,r.jsx)(n.pd,{label:"Prefix",value:l.prefix,onChange:e=>i({...l,prefix:e.target.value}),placeholder:"oc-prod",hint:"Required. Used as the provider prefix for model IDs."}),(0,r.jsx)(n.l6,{label:"API Type",options:[{value:"chat",label:"Chat Completions"},{value:"responses",label:"Responses API"}],value:l.apiType,onChange:e=>i({...l,apiType:e.target.value})}),(0,r.jsx)(n.pd,{label:"Base URL",value:l.baseUrl,onChange:e=>i({...l,baseUrl:e.target.value}),placeholder:"https://api.openai.com/v1",hint:"Use the base URL (ending in /v1) for your OpenAI-compatible API."}),(0,r.jsx)(n.pd,{label:"API Key (for Check)",type:"password",value:c,onChange:e=>p(e.target.value)}),(0,r.jsx)(n.pd,{label:"Model ID (optional)",value:m,onChange:e=>x(e.target.value),placeholder:"e.g. gpt-4, claude-3-opus",hint:"If provider lacks /models endpoint, enter a model ID to validate via chat/completions instead."}),(0,r.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center",children:[(0,r.jsx)(n.$n,{onClick:v,disabled:!c||u||!l.baseUrl.trim(),variant:"secondary",className:"w-full sm:w-auto",children:u?"Checking...":"Check"}),(()=>{if(!f)return null;let{valid:e,error:t,method:s}=f;return e?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(n.Ex,{variant:"success",children:"Valid"}),"chat"===s&&(0,r.jsx)("span",{className:"text-sm text-text-muted",children:"(via inference test)"})]}):(0,r.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,r.jsx)(n.Ex,{variant:"error",children:"Invalid"}),t&&(0,r.jsx)("span",{className:"text-sm text-red-500",children:t})]})})()]}),(0,r.jsxs)("div",{className:"flex flex-col gap-2 sm:flex-row",children:[(0,r.jsx)(n.$n,{onClick:b,fullWidth:!0,disabled:!l.name.trim()||!l.prefix.trim()||!l.baseUrl.trim()||o,children:o?"Creating...":"Create"}),(0,r.jsx)(n.$n,{onClick:t,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})})}function N({isOpen:e,onClose:t,onCreated:s}){let[l,i]=(0,a.useState)({name:"",prefix:"",baseUrl:"https://api.anthropic.com/v1"}),[o,d]=(0,a.useState)(!1),[c,p]=(0,a.useState)(""),[m,x]=(0,a.useState)(""),[u,h]=(0,a.useState)(!1),[f,g]=(0,a.useState)(null);(0,a.useEffect)(()=>{e&&(g(null),p(""),x(""))},[e]);let b=async()=>{if(l.name.trim()&&l.prefix.trim()&&l.baseUrl.trim()){d(!0);try{let e=await fetch("/api/provider-nodes",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:l.name,prefix:l.prefix,baseUrl:l.baseUrl,type:"anthropic-compatible"})}),t=await e.json();e.ok&&(s(t.node),i({name:"",prefix:"",baseUrl:"https://api.anthropic.com/v1"}),p(""),g(null))}catch(e){console.log("Error creating Anthropic Compatible node:",e)}finally{d(!1)}}},v=async()=>{h(!0);try{let e=await fetch("/api/provider-nodes/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:l.baseUrl,apiKey:c,type:"anthropic-compatible",modelId:m.trim()||void 0})}),t=await e.json();g(t)}catch{g({valid:!1,error:"Network error"})}finally{h(!1)}};return(0,r.jsx)(n.aF,{isOpen:e,title:"Add Anthropic Compatible",onClose:t,children:(0,r.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,r.jsx)(n.pd,{label:"Name",value:l.name,onChange:e=>i({...l,name:e.target.value}),placeholder:"Anthropic Compatible (Prod)",hint:"Required. A friendly label for this node."}),(0,r.jsx)(n.pd,{label:"Prefix",value:l.prefix,onChange:e=>i({...l,prefix:e.target.value}),placeholder:"ac-prod",hint:"Required. Used as the provider prefix for model IDs."}),(0,r.jsx)(n.pd,{label:"Base URL",value:l.baseUrl,onChange:e=>i({...l,baseUrl:e.target.value}),placeholder:"https://api.anthropic.com/v1",hint:"Use the base URL (ending in /v1) for your Anthropic-compatible API. The system will append /messages."}),(0,r.jsx)(n.pd,{label:"API Key (for Check)",type:"password",value:c,onChange:e=>p(e.target.value)}),(0,r.jsx)(n.pd,{label:"Model ID (optional)",value:m,onChange:e=>x(e.target.value),placeholder:"e.g. claude-3-opus",hint:"If provider lacks /models endpoint, enter a model ID to validate via chat/completions instead."}),(0,r.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center",children:[(0,r.jsx)(n.$n,{onClick:v,disabled:!c||u||!l.baseUrl.trim(),variant:"secondary",className:"w-full sm:w-auto",children:u?"Checking...":"Check"}),(()=>{if(!f)return null;let{valid:e,error:t,method:s}=f;return e?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(n.Ex,{variant:"success",children:"Valid"}),"chat"===s&&(0,r.jsx)("span",{className:"text-sm text-text-muted",children:"(via inference test)"})]}):(0,r.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,r.jsx)(n.Ex,{variant:"error",children:"Invalid"}),t&&(0,r.jsx)("span",{className:"text-sm text-red-500",children:t})]})})()]}),(0,r.jsxs)("div",{className:"flex flex-col gap-2 sm:flex-row",children:[(0,r.jsx)(n.$n,{onClick:b,fullWidth:!0,disabled:!l.name.trim()||!l.prefix.trim()||!l.baseUrl.trim()||o,children:o?"Creating...":"Create"}),(0,r.jsx)(n.$n,{onClick:t,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})})}function w({results:e}){if(e.error&&!e.results)return(0,r.jsxs)("div",{className:"text-center py-6",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-red-500 text-[32px] mb-2 block",children:"error"}),(0,r.jsx)("p",{className:"text-sm text-red-400",children:e.error})]});let{summary:t,mode:s}=e,a=e.results||[];return(0,r.jsxs)("div",{className:"flex min-w-0 flex-col gap-3",children:[t&&(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-2 text-xs mb-1 sm:gap-3",children:[(0,r.jsxs)("span",{className:"text-text-muted",children:[{oauth:"OAuth",free:"Free",apikey:"API Key",provider:"Provider",all:"All"}[s]||s," Test"]}),(0,r.jsxs)("span",{className:"px-2 py-0.5 rounded bg-emerald-500/15 text-emerald-400 font-medium",children:[t.passed," passed"]}),t.failed>0&&(0,r.jsxs)("span",{className:"px-2 py-0.5 rounded bg-red-500/15 text-red-400 font-medium",children:[t.failed," failed"]}),(0,r.jsxs)("span",{className:"text-text-muted sm:ml-auto",children:[t.total," tested"]})]}),a.map((e,t)=>(0,r.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-2 rounded-lg bg-black/[0.03] px-3 py-2 text-xs dark:bg-white/[0.03] sm:flex-nowrap",children:[(0,r.jsx)("span",{className:`material-symbols-outlined text-[16px] ${e.valid?"text-emerald-500":"text-red-500"}`,children:e.valid?"check_circle":"error"}),(0,r.jsxs)("div",{className:"min-w-0 flex-[1_1_160px]",children:[(0,r.jsx)("span",{className:"block truncate font-medium sm:inline",children:e.connectionName}),(0,r.jsxs)("span",{className:"block truncate text-text-muted sm:ml-1.5 sm:inline",children:["(",e.provider,")"]})]}),void 0!==e.latencyMs&&(0,r.jsxs)("span",{className:"shrink-0 text-text-muted font-mono tabular-nums",children:[e.latencyMs,"ms"]}),(0,r.jsx)("span",{className:`shrink-0 text-[10px] uppercase font-bold px-1.5 py-0.5 rounded ${e.valid?"bg-emerald-500/15 text-emerald-400":"bg-red-500/15 text-red-400"}`,children:e.valid?"OK":e.diagnosis?.type||"ERROR"})]},e.connectionId||t)),0===a.length&&(0,r.jsx)("div",{className:"text-center py-4 text-text-muted text-sm",children:"No active connections found for this group."})]})}v.propTypes={providerId:i().string.isRequired,provider:i().shape({id:i().string.isRequired,name:i().string.isRequired,color:i().string,textIcon:i().string}).isRequired,stats:i().shape({connected:i().number,error:i().number,errorCode:i().string,errorTime:i().string}).isRequired,authType:i().string,onToggle:i().func},y.propTypes={providerId:i().string.isRequired,provider:i().shape({id:i().string.isRequired,name:i().string.isRequired,color:i().string,textIcon:i().string,apiType:i().string}).isRequired,stats:i().shape({connected:i().number,error:i().number,errorCode:i().string,errorTime:i().string}).isRequired,authType:i().string,onToggle:i().func},j.propTypes={isOpen:i().bool.isRequired,onClose:i().func.isRequired,onCreated:i().func.isRequired},N.propTypes={isOpen:i().bool.isRequired,onClose:i().func.isRequired,onCreated:i().func.isRequired},w.propTypes={results:i().shape({mode:i().string,results:i().array,summary:i().shape({total:i().number,passed:i().number,failed:i().number}),error:i().string}).isRequired}}},e=>{e.O(0,[2574,3862,2194,698,1321,5497,8441,3794,7358],()=>e(e.s=13288)),_N_E=e.O()}]);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[6812],{
|
|
1
|
+
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[6812],{29500:(e,t,r)=>{Promise.resolve().then(r.bind(r,57076))},57076:(e,t,r)=>{"use strict";r.r(t),r.d(t,{default:()=>n});var s=r(95155),l=r(12115),a=r(35497),i=r(65921);function o(e={}){return{name:e.name||"",proxyUrl:e.proxyUrl||"",noProxy:e.noProxy||"",isActive:!1!==e.isActive,strictProxy:!0===e.strictProxy}}function n(){let[e,t]=(0,l.useState)([]),[r,n]=(0,l.useState)(!0),[c,d]=(0,l.useState)(!1),[x,p]=(0,l.useState)(!1),[m,h]=(0,l.useState)(!1),[u,y]=(0,l.useState)(null),[f,g]=(0,l.useState)(o()),[v,j]=(0,l.useState)(""),[b,k]=(0,l.useState)({vercelToken:"",projectName:"vercel-relay"}),[N,w]=(0,l.useState)(!1),[P,C]=(0,l.useState)(!1),[$,S]=(0,l.useState)(!1),[A,E]=(0,l.useState)(null),[T,U]=(0,l.useState)([]),[D,I]=(0,l.useState)(!1),[O,z]=(0,l.useState)({current:0,total:0}),[F,_]=(0,l.useState)(!1),[V,L]=(0,l.useState)(null),R=(0,i.i)(),W=(0,l.useCallback)(async()=>{try{let e=await fetch("/api/proxy-pools?includeUsage=true",{cache:"no-store"}),r=await e.json();e.ok&&t(r.proxyPools||[])}catch(e){console.log("Error fetching proxy pools:",e)}finally{n(!1)}},[]);(0,l.useEffect)(()=>{W()},[W]);let B=()=>{y(null),g(o())},J=()=>{B(),d(!0)},M=()=>{d(!1),B()},q=async()=>{let e={name:f.name.trim(),proxyUrl:f.proxyUrl.trim(),noProxy:f.noProxy.trim(),isActive:!0===f.isActive,strictProxy:!0===f.strictProxy};if(e.name&&e.proxyUrl){w(!0);try{let t=!!u,r=await fetch(t?`/api/proxy-pools/${u.id}`:"/api/proxy-pools",{method:t?"PUT":"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(r.ok)await W(),M(),R.success(u?"Proxy pool updated":"Proxy pool created");else{let e=await r.json();R.error(e.error||"Failed to save proxy pool")}}catch(e){console.log("Error saving proxy pool:",e)}finally{w(!1)}}},G=async e=>{L({title:"Delete Proxy Pool",message:`Delete proxy pool "${e.name}"?`,onConfirm:async()=>{L(null);try{let r=await fetch(`/api/proxy-pools/${e.id}`,{method:"DELETE"});if(r.ok){t(t=>t.filter(t=>t.id!==e.id)),R.success("Proxy pool deleted");return}let s=await r.json();409===r.status?R.warning(`Cannot delete: ${s.boundConnectionCount||0} connection(s) are still using this pool.`):R.error(s.error||"Failed to delete proxy pool")}catch(e){console.log("Error deleting proxy pool:",e),R.error("Failed to delete proxy pool")}}})},H=async e=>{E(e);try{let t=await fetch(`/api/proxy-pools/${e}/test`,{method:"POST"}),r=await t.json();if(!t.ok)return void R.error(r.error||"Failed to test proxy");await W(),R.success(r.ok?"Proxy test passed":"Proxy test failed")}catch(e){console.log("Error testing proxy pool:",e),R.error("Failed to test proxy")}finally{E(null)}},Q=async e=>{let r=!e.isActive;t(t=>t.map(t=>t.id===e.id?{...t,isActive:r}:t));try{(await fetch(`/api/proxy-pools/${e.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({isActive:r})})).ok||(t(t=>t.map(t=>t.id===e.id?{...t,isActive:e.isActive}:t)),R.error("Failed to update active state"))}catch(r){console.log("Error toggling active:",r),t(t=>t.map(t=>t.id===e.id?{...t,isActive:e.isActive}:t))}},K=e.length>0&&T.length===e.length,Y=()=>U([]),Z=async t=>{let r=T.length>0?T:e.map(e=>e.id);if(0!==r.length){_(!0);try{let e=0,s=0;for(let l of r)try{(await fetch(`/api/proxy-pools/${l}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({isActive:t})})).ok?e+=1:s+=1}catch{s+=1}await W(),R.success(`${t?"Activated":"Deactivated"} ${e}${s?`, failed ${s}`:""}`)}finally{_(!1)}}},X=async()=>{0!==T.length&&L({title:"Delete Proxy Pools",message:`Delete ${T.length} proxy pool(s)?`,onConfirm:async()=>{L(null),_(!0);try{let e=0,t=0,r=0;for(let s of T)try{let l=await fetch(`/api/proxy-pools/${s}`,{method:"DELETE"});l.ok?e+=1:409===l.status?t+=1:r+=1}catch{r+=1}await W(),Y(),R.success(`Deleted ${e}${t?`, ${t} bound`:""}${r?`, ${r} failed`:""}`)}finally{_(!1)}}})},ee=async()=>{let t=T.length>0?e.filter(e=>T.includes(e.id)):e;if(0===t.length)return;I(!0),z({current:0,total:t.length});let r=0,s=[],l=0,a=[...t],i=async()=>{for(;a.length>0;){let e=a.shift();if(!e)break;try{let t=await fetch(`/api/proxy-pools/${e.id}/test`,{method:"POST"}),l=await t.json();t.ok&&l.ok?r+=1:s.push(e.id)}catch{s.push(e.id)}finally{z({current:l+=1,total:t.length})}}};await Promise.all(Array.from({length:Math.min(10,t.length)},i)),await W(),I(!1),z({current:0,total:0}),s.length>0?L({title:"Disable Dead Proxies",message:`Alive: ${r}, Dead: ${s.length}.
|
|
2
2
|
|
|
3
3
|
Disable ${s.length} dead proxies?`,onConfirm:async()=>{L(null),_(!0);try{for(let e of s)try{await fetch(`/api/proxy-pools/${e}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({isActive:!1})})}catch{}await W(),R.success(`Disabled ${s.length} dead proxies`)}finally{_(!1)}}}):R.success(`Health check done. Alive: ${r}, Dead: ${s.length}`)};(0,l.useEffect)(()=>{U(t=>t.filter(t=>e.some(e=>e.id===t)))},[e]);let et=()=>{P||p(!1)},er=()=>{$||h(!1)},es=async()=>{if(b.vercelToken.trim()){S(!0);try{let e=await fetch("/api/proxy-pools/vercel-deploy",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(b)}),t=await e.json();e.ok?(await W(),er(),R.success(`Deployed: ${t.deployUrl}`)):R.error(t.error||"Deploy failed")}catch(e){console.log("Error deploying Vercel relay:",e),R.error("Deploy failed")}finally{S(!1)}}},el=async()=>{let t=v.split(/\r?\n/).map(e=>e.trim()).filter(Boolean);if(0===t.length)return void R.warning("Please paste at least one proxy line.");let r=[],s=[];if(t.forEach((e,t)=>{try{let s=(e=>{let t=e.trim();if(!t)return null;if(t.includes("://")){let e=new URL(t),r=e.port?`${e.hostname}:${e.port}`:e.hostname;return{proxyUrl:e.toString(),name:`Imported ${r}`}}let r=t.split(":");if(4===r.length){let[e,t,s,l]=r;if(!e||!t||!s||!l)throw Error("Invalid host:port:user:pass format");return{proxyUrl:new URL(`http://${encodeURIComponent(s)}:${encodeURIComponent(l)}@${e}:${t}`).toString(),name:`Imported ${e}:${t}`}}throw Error("Unsupported format")})(e);s&&r.push({...s,lineNumber:t+1})}catch(e){s.push(`Line ${t+1}: ${e.message}`)}}),s.length>0)return void R.error(`Invalid proxy format:
|
|
4
|
-
${s.join("\n")}`);C(!0);try{let t=new Set(e.map(e=>`${(e.proxyUrl||"").trim()}|||${(e.noProxy||"").trim()}`)),s=0,l=0,a=0;for(let e of r){let r=`${e.proxyUrl}|||`;if(t.has(r)){l+=1;continue}(await fetch("/api/proxy-pools",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:e.name,proxyUrl:e.proxyUrl,noProxy:"",isActive:!0})})).ok?(s+=1,t.add(r)):a+=1}await W(),p(!1),R.success(`Batch import completed: Created ${s}, Skipped ${l}, Failed ${a}`)}catch(e){console.log("Error batch importing proxies:",e),R.error("Batch import failed")}finally{C(!1)}},ea=(0,l.useMemo)(()=>e.filter(e=>!0===e.isActive).length,[e]);return r?(0,s.jsxs)("div",{className:"mx-auto flex w-full max-w-5xl flex-col gap-4 px-1 sm:gap-6 sm:px-0",children:[(0,s.jsx)(a.Qv,{}),(0,s.jsx)(a.Qv,{})]}):(0,s.jsxs)("div",{className:"mx-auto flex w-full max-w-5xl flex-col gap-4 px-1 sm:gap-6 sm:px-0",children:[(0,s.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsx)("h1",{className:"text-xl font-semibold sm:text-2xl",children:"Proxy Pools"}),(0,s.jsx)("p",{className:"text-sm text-text-muted mt-1",children:"Manage reusable per-connection proxies and bind them to provider connections."})]}),(0,s.jsxs)("div",{className:"grid grid-cols-1 gap-2 sm:flex sm:items-center",children:[(0,s.jsx)(a.$n,{size:"sm",variant:"secondary",icon:"cloud_upload",onClick:()=>{k({vercelToken:"",projectName:"vercel-relay"}),h(!0)},children:"Vercel Relay"}),(0,s.jsx)(a.$n,{size:"sm",variant:"secondary",icon:"upload",onClick:()=>{j(""),p(!0)},children:"Batch Import"}),(0,s.jsx)(a.$n,{size:"sm",icon:"add",onClick:J,children:"Add Proxy Pool"})]})]}),(0,s.jsxs)(a.Zp,{children:[(0,s.jsxs)("div",{className:"mb-4 flex flex-wrap items-center gap-2",children:[e.length>0&&(0,s.jsxs)("label",{className:"flex items-center gap-1.5 text-xs text-text-muted cursor-pointer",children:[(0,s.jsx)("input",{type:"checkbox",checked:K,onChange:()=>U(K?[]:e.map(e=>e.id)),className:"size-4 rounded border-black/20 dark:border-white/20"}),K?"Unselect all":"Select all"]}),(0,s.jsxs)(a.Ex,{variant:"default",children:["Total: ",e.length]}),(0,s.jsxs)(a.Ex,{variant:"success",children:["Active: ",ea]})]}),(T.length>0||D)&&(0,s.jsxs)("div",{className:"mb-4 flex flex-wrap items-center gap-2 rounded-lg border border-primary/30 bg-primary/5 px-3 py-2",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-[18px] text-primary",children:"checklist"}),(0,s.jsx)("span",{className:"text-xs font-medium text-primary",children:T.length>0?`${T.length} selected`:"All pools"}),(0,s.jsxs)("div",{className:"ml-auto flex flex-wrap items-center gap-2",children:[(0,s.jsx)(a.$n,{size:"sm",icon:D?"progress_activity":"health_and_safety",onClick:ee,disabled:D||F||0===e.length,children:D?`Checking ${O.current}/${O.total}`:"Health Check"}),T.length>0&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(a.$n,{size:"sm",variant:"secondary",icon:"toggle_on",onClick:()=>Z(!0),disabled:F||D,children:"Activate"}),(0,s.jsx)(a.$n,{size:"sm",variant:"secondary",icon:"toggle_off",onClick:()=>Z(!1),disabled:F||D,children:"Deactivate"}),(0,s.jsx)(a.$n,{size:"sm",variant:"secondary",icon:"delete",onClick:X,disabled:F||D,children:"Delete"}),(0,s.jsx)(a.$n,{size:"sm",variant:"ghost",onClick:Y,disabled:F||D,children:"Clear"})]})]})]}),0===e.length?(0,s.jsxs)("div",{className:"text-center py-10",children:[(0,s.jsx)("p",{className:"text-text-main font-medium mb-1",children:"No proxy pool entries yet"}),(0,s.jsx)("p",{className:"text-sm text-text-muted mb-4",children:"Create a proxy pool entry, then assign it to connections."}),(0,s.jsx)(a.$n,{icon:"add",onClick:J,children:"Add Proxy Pool"})]}):(0,s.jsx)("div",{className:"flex flex-col divide-y divide-black/[0.04] dark:divide-white/[0.05]",children:e.map(e=>{var t;return(0,s.jsxs)("div",{className:"flex flex-col gap-3 py-3 sm:flex-row sm:items-center sm:justify-between",children:[(0,s.jsxs)("div",{className:"flex items-start gap-3 min-w-0 flex-1",children:[(0,s.jsx)("input",{type:"checkbox",checked:T.includes(e.id),onChange:()=>{let t;return t=e.id,U(e=>e.includes(t)?e.filter(e=>e!==t):[...e,t])},className:"mt-1 size-4 shrink-0 rounded border-black/20 dark:border-white/20"}),(0,s.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[(0,s.jsx)("p",{className:"min-w-0 max-w-full truncate text-sm font-medium sm:max-w-[18rem]",children:e.name}),(0,s.jsx)(a.Ex,{variant:"active"===(t=e.testStatus)?"success":"error"===t?"error":"default",size:"sm",dot:!0,children:e.testStatus||"unknown"}),(0,s.jsx)(a.Ex,{variant:e.isActive?"success":"default",size:"sm",children:e.isActive?"active":"inactive"}),"vercel"===e.type&&(0,s.jsx)(a.Ex,{variant:"default",size:"sm",children:"vercel relay"}),(0,s.jsxs)(a.Ex,{variant:"default",size:"sm",children:[e.boundConnectionCount||0," bound"]})]}),(0,s.jsx)("p",{className:"text-xs text-text-muted truncate mt-1",children:e.proxyUrl}),e.noProxy?(0,s.jsxs)("p",{className:"text-xs text-text-muted truncate",children:["No proxy: ",e.noProxy]}):null,(0,s.jsxs)("p",{className:"text-[11px] text-text-muted mt-1",children:["Last tested: ",function(e){if(!e)return"Never";let t=new Date(e);return Number.isNaN(t.getTime())?"Never":t.toLocaleString()}(e.lastTestedAt),e.lastError?` \xb7 ${e.lastError}`:""]})]})]}),(0,s.jsxs)("div",{className:"flex items-center justify-end gap-1",children:[(0,s.jsx)(a.lM,{size:"sm",checked:!0===e.isActive,onChange:()=>Q(e),title:e.isActive?"Disable":"Enable"}),(0,s.jsx)("button",{onClick:()=>H(e.id),className:"p-2 rounded hover:bg-black/5 dark:hover:bg-white/5 text-text-muted hover:text-primary",title:"Test proxy",disabled:A===e.id,children:(0,s.jsx)("span",{className:"material-symbols-outlined text-[18px]",style:A===e.id?{animation:"spin 1s linear infinite"}:void 0,children:A===e.id?"progress_activity":"science"})}),(0,s.jsx)("button",{onClick:()=>{y(e),g(o(e)),d(!0)},className:"p-2 rounded hover:bg-black/5 dark:hover:bg-white/5 text-text-muted hover:text-primary",title:"Edit",children:(0,s.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"edit"})}),(0,s.jsx)("button",{onClick:()=>G(e),className:"p-2 rounded hover:bg-red-500/10 text-red-500",title:"Delete",children:(0,s.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"delete"})})]})]},e.id)})})]}),(0,s.jsx)(a.aF,{isOpen:x,title:"Batch Import Proxies",onClose:et,children:(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"text-sm font-medium text-text-main mb-1 block",children:"Paste Proxy List (One per line)"}),(0,s.jsx)("textarea",{value:v,onChange:e=>j(e.target.value),placeholder:"http://user:pass@127.0.0.1:7897\n127.0.0.1:7897:user:pass",className:"w-full min-h-[180px] py-2 px-3 text-sm text-text-main bg-white dark:bg-white/5 border border-black/10 dark:border-white/10 rounded-md focus:ring-1 focus:ring-primary/30 focus:border-primary/50 focus:outline-none transition-all"}),(0,s.jsx)("p",{className:"text-xs text-text-muted mt-1",children:"Supported formats: protocol://user:pass@host:port, host:port:user:pass"})]}),(0,s.jsxs)("div",{className:"grid grid-cols-1 gap-2 sm:grid-cols-2",children:[(0,s.jsx)(a.$n,{fullWidth:!0,onClick:el,disabled:!v.trim()||P,children:P?"Importing...":"Import"}),(0,s.jsx)(a.$n,{fullWidth:!0,variant:"ghost",onClick:et,disabled:P,children:"Cancel"})]})]})}),(0,s.jsx)(a.aF,{isOpen:m,title:"Deploy Vercel Relay",onClose:er,children:(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,s.jsxs)("div",{className:"rounded-lg bg-blue-500/5 border border-blue-500/10 p-3 flex flex-col gap-1.5",children:[(0,s.jsx)("p",{className:"text-sm text-text-main font-medium",children:"What is Vercel Relay?"}),(0,s.jsx)("p",{className:"text-xs text-text-muted",children:"Deploys an edge relay function to Vercel. All AI provider requests will be forwarded through Vercel's edge network, masking your real IP from providers."}),(0,s.jsxs)("ul",{className:"text-xs text-text-muted list-disc pl-4 space-y-0.5",children:[(0,s.jsx)("li",{children:"Your IP is replaced by Vercel's dynamic edge IPs (hundreds of IPs across 20+ global regions)"}),(0,s.jsx)("li",{children:"Vercel serves millions of apps — providers can't block Vercel IPs without affecting legitimate traffic"}),(0,s.jsx)("li",{children:"Free tier: 100GB bandwidth/month, 500K edge invocations"}),(0,s.jsx)("li",{children:"Deploy multiple relays on different accounts for more IP diversity"})]})]}),(0,s.jsx)(a.pd,{label:"Vercel API Token",value:b.vercelToken,onChange:e=>k(t=>({...t,vercelToken:e.target.value})),placeholder:"your-vercel-api-token",hint:(0,s.jsxs)(s.Fragment,{children:["Token is used once for deployment and not stored. ",(0,s.jsx)("a",{href:"https://vercel.com/account/tokens",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"Get token →"})]}),type:"password"}),(0,s.jsx)(a.pd,{label:"Project Name",value:b.projectName,onChange:e=>k(t=>({...t,projectName:e.target.value})),placeholder:"my-relay",hint:"Unique name for your Vercel project. Leave empty for auto-generated name."}),(0,s.jsxs)("div",{className:"grid grid-cols-1 gap-2 sm:grid-cols-2",children:[(0,s.jsx)(a.$n,{fullWidth:!0,onClick:es,disabled:!b.vercelToken.trim()||$,children:$?"Deploying... (may take ~1 min)":"Deploy"}),(0,s.jsx)(a.$n,{fullWidth:!0,variant:"ghost",onClick:er,disabled:$,children:"Cancel"})]})]})}),(0,s.jsx)(a.aF,{isOpen:c,title:u?"Edit Proxy Pool":"Add Proxy Pool",onClose:M,children:(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,s.jsx)(a.pd,{label:"Name",value:f.name,onChange:e=>g(t=>({...t,name:e.target.value})),placeholder:"Office Proxy"}),(0,s.jsx)(a.pd,{label:"Proxy URL",value:f.proxyUrl,onChange:e=>g(t=>({...t,proxyUrl:e.target.value})),placeholder:"http://127.0.0.1:7897"}),(0,s.jsx)(a.pd,{label:"No Proxy",value:f.noProxy,onChange:e=>g(t=>({...t,noProxy:e.target.value})),placeholder:"localhost,127.0.0.1,.internal",hint:"Comma-separated hosts/domains to bypass proxy"}),(0,s.jsxs)("div",{className:"flex flex-col gap-3 rounded-lg border border-border/50 p-3 sm:flex-row sm:items-center sm:justify-between",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"font-medium text-sm",children:"Active"}),(0,s.jsx)("p",{className:"text-xs text-text-muted",children:"Inactive pools are ignored by runtime resolution."})]}),(0,s.jsx)(a.lM,{checked:!0===f.isActive,onChange:()=>g(e=>({...e,isActive:!e.isActive})),disabled:N})]}),(0,s.jsxs)("div",{className:"flex flex-col gap-3 rounded-lg border border-border/50 p-3 sm:flex-row sm:items-center sm:justify-between",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"font-medium text-sm",children:"Strict Proxy"}),(0,s.jsx)("p",{className:"text-xs text-text-muted",children:"Fail request if proxy is unreachable instead of falling back to direct."})]}),(0,s.jsx)(a.lM,{checked:!0===f.strictProxy,onChange:()=>g(e=>({...e,strictProxy:!e.strictProxy})),disabled:N})]}),(0,s.jsxs)("div",{className:"grid grid-cols-1 gap-2 sm:grid-cols-2",children:[(0,s.jsx)(a.$n,{fullWidth:!0,onClick:q,disabled:!f.name.trim()||!f.proxyUrl.trim()||N,children:N?"Saving...":"Save"}),(0,s.jsx)(a.$n,{fullWidth:!0,variant:"ghost",onClick:M,disabled:N,children:"Cancel"})]})]})}),(0,s.jsx)(a.uo,{isOpen:!!V,onClose:()=>L(null),onConfirm:V?.onConfirm,title:V?.title||"Confirm",message:V?.message,variant:"danger"})]})}}},e=>{e.O(0,[2574,3862,2194,698,1321,5497,8441,3794,7358],()=>e(e.s=32118)),_N_E=e.O()}]);
|
|
4
|
+
${s.join("\n")}`);C(!0);try{let t=new Set(e.map(e=>`${(e.proxyUrl||"").trim()}|||${(e.noProxy||"").trim()}`)),s=0,l=0,a=0;for(let e of r){let r=`${e.proxyUrl}|||`;if(t.has(r)){l+=1;continue}(await fetch("/api/proxy-pools",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:e.name,proxyUrl:e.proxyUrl,noProxy:"",isActive:!0})})).ok?(s+=1,t.add(r)):a+=1}await W(),p(!1),R.success(`Batch import completed: Created ${s}, Skipped ${l}, Failed ${a}`)}catch(e){console.log("Error batch importing proxies:",e),R.error("Batch import failed")}finally{C(!1)}},ea=(0,l.useMemo)(()=>e.filter(e=>!0===e.isActive).length,[e]);return r?(0,s.jsxs)("div",{className:"mx-auto flex w-full max-w-5xl flex-col gap-4 px-1 sm:gap-6 sm:px-0",children:[(0,s.jsx)(a.Qv,{}),(0,s.jsx)(a.Qv,{})]}):(0,s.jsxs)("div",{className:"mx-auto flex w-full max-w-5xl flex-col gap-4 px-1 sm:gap-6 sm:px-0",children:[(0,s.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsx)("h1",{className:"text-xl font-semibold sm:text-2xl",children:"Proxy Pools"}),(0,s.jsx)("p",{className:"text-sm text-text-muted mt-1",children:"Manage reusable per-connection proxies and bind them to provider connections."})]}),(0,s.jsxs)("div",{className:"grid grid-cols-1 gap-2 sm:flex sm:items-center",children:[(0,s.jsx)(a.$n,{size:"sm",variant:"secondary",icon:"cloud_upload",onClick:()=>{k({vercelToken:"",projectName:"vercel-relay"}),h(!0)},children:"Vercel Relay"}),(0,s.jsx)(a.$n,{size:"sm",variant:"secondary",icon:"upload",onClick:()=>{j(""),p(!0)},children:"Batch Import"}),(0,s.jsx)(a.$n,{size:"sm",icon:"add",onClick:J,children:"Add Proxy Pool"})]})]}),(0,s.jsxs)(a.Zp,{children:[(0,s.jsxs)("div",{className:"mb-4 flex flex-wrap items-center gap-2",children:[e.length>0&&(0,s.jsxs)("label",{className:"flex items-center gap-1.5 text-xs text-text-muted cursor-pointer",children:[(0,s.jsx)("input",{type:"checkbox",checked:K,onChange:()=>U(K?[]:e.map(e=>e.id)),className:"size-4 rounded border-black/20 dark:border-white/20"}),K?"Unselect all":"Select all"]}),(0,s.jsxs)(a.Ex,{variant:"default",children:["Total: ",e.length]}),(0,s.jsxs)(a.Ex,{variant:"success",children:["Active: ",ea]})]}),(T.length>0||D)&&(0,s.jsxs)("div",{className:"mb-4 flex flex-wrap items-center gap-2 rounded-lg border border-primary/30 bg-primary/5 px-3 py-2",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-[18px] text-primary",children:"checklist"}),(0,s.jsx)("span",{className:"text-xs font-medium text-primary",children:T.length>0?`${T.length} selected`:"All pools"}),(0,s.jsxs)("div",{className:"ml-auto flex flex-wrap items-center gap-2",children:[(0,s.jsx)(a.$n,{size:"sm",icon:D?"progress_activity":"health_and_safety",onClick:ee,disabled:D||F||0===e.length,children:D?`Checking ${O.current}/${O.total}`:"Health Check"}),T.length>0&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(a.$n,{size:"sm",variant:"secondary",icon:"toggle_on",onClick:()=>Z(!0),disabled:F||D,children:"Activate"}),(0,s.jsx)(a.$n,{size:"sm",variant:"secondary",icon:"toggle_off",onClick:()=>Z(!1),disabled:F||D,children:"Deactivate"}),(0,s.jsx)(a.$n,{size:"sm",variant:"secondary",icon:"delete",onClick:X,disabled:F||D,children:"Delete"}),(0,s.jsx)(a.$n,{size:"sm",variant:"ghost",onClick:Y,disabled:F||D,children:"Clear"})]})]})]}),0===e.length?(0,s.jsxs)("div",{className:"text-center py-10",children:[(0,s.jsx)("p",{className:"text-text-main font-medium mb-1",children:"No proxy pool entries yet"}),(0,s.jsx)("p",{className:"text-sm text-text-muted mb-4",children:"Create a proxy pool entry, then assign it to connections."}),(0,s.jsx)(a.$n,{icon:"add",onClick:J,children:"Add Proxy Pool"})]}):(0,s.jsx)("div",{className:"flex flex-col divide-y divide-black/[0.04] dark:divide-white/[0.05]",children:e.map(e=>{var t;return(0,s.jsxs)("div",{className:"flex flex-col gap-3 py-3 sm:flex-row sm:items-center sm:justify-between",children:[(0,s.jsxs)("div",{className:"flex items-start gap-3 min-w-0 flex-1",children:[(0,s.jsx)("input",{type:"checkbox",checked:T.includes(e.id),onChange:()=>{let t;return t=e.id,U(e=>e.includes(t)?e.filter(e=>e!==t):[...e,t])},className:"mt-1 size-4 shrink-0 rounded border-black/20 dark:border-white/20"}),(0,s.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[(0,s.jsx)("p",{className:"min-w-0 max-w-full truncate text-sm font-medium sm:max-w-[18rem]",children:e.name}),(0,s.jsx)(a.Ex,{variant:"active"===(t=e.testStatus)?"success":"error"===t?"error":"default",size:"sm",dot:!0,children:e.testStatus||"unknown"}),(0,s.jsx)(a.Ex,{variant:e.isActive?"success":"default",size:"sm",children:e.isActive?"active":"inactive"}),"vercel"===e.type&&(0,s.jsx)(a.Ex,{variant:"default",size:"sm",children:"vercel relay"}),(0,s.jsxs)(a.Ex,{variant:"default",size:"sm",children:[e.boundConnectionCount||0," bound"]})]}),(0,s.jsx)("p",{className:"text-xs text-text-muted truncate mt-1",children:e.proxyUrl}),e.noProxy?(0,s.jsxs)("p",{className:"text-xs text-text-muted truncate",children:["No proxy: ",e.noProxy]}):null,(0,s.jsxs)("p",{className:"text-[11px] text-text-muted mt-1",children:["Last tested: ",function(e){if(!e)return"Never";let t=new Date(e);return Number.isNaN(t.getTime())?"Never":t.toLocaleString()}(e.lastTestedAt),e.lastError?` \xb7 ${e.lastError}`:""]})]})]}),(0,s.jsxs)("div",{className:"flex items-center justify-end gap-1",children:[(0,s.jsx)(a.lM,{size:"sm",checked:!0===e.isActive,onChange:()=>Q(e),title:e.isActive?"Disable":"Enable"}),(0,s.jsx)("button",{onClick:()=>H(e.id),className:"p-2 rounded hover:bg-black/5 dark:hover:bg-white/5 text-text-muted hover:text-primary",title:"Test proxy",disabled:A===e.id,children:(0,s.jsx)("span",{className:"material-symbols-outlined text-[18px]",style:A===e.id?{animation:"spin 1s linear infinite"}:void 0,children:A===e.id?"progress_activity":"science"})}),(0,s.jsx)("button",{onClick:()=>{y(e),g(o(e)),d(!0)},className:"p-2 rounded hover:bg-black/5 dark:hover:bg-white/5 text-text-muted hover:text-primary",title:"Edit",children:(0,s.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"edit"})}),(0,s.jsx)("button",{onClick:()=>G(e),className:"p-2 rounded hover:bg-red-500/10 text-red-500",title:"Delete",children:(0,s.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"delete"})})]})]},e.id)})})]}),(0,s.jsx)(a.aF,{isOpen:x,title:"Batch Import Proxies",onClose:et,children:(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"text-sm font-medium text-text-main mb-1 block",children:"Paste Proxy List (One per line)"}),(0,s.jsx)("textarea",{value:v,onChange:e=>j(e.target.value),placeholder:"http://user:pass@127.0.0.1:7897\n127.0.0.1:7897:user:pass",className:"w-full min-h-[180px] py-2 px-3 text-sm text-text-main bg-white dark:bg-white/5 border border-black/10 dark:border-white/10 rounded-md focus:ring-1 focus:ring-primary/30 focus:border-primary/50 focus:outline-none transition-all"}),(0,s.jsx)("p",{className:"text-xs text-text-muted mt-1",children:"Supported formats: protocol://user:pass@host:port, host:port:user:pass"})]}),(0,s.jsxs)("div",{className:"grid grid-cols-1 gap-2 sm:grid-cols-2",children:[(0,s.jsx)(a.$n,{fullWidth:!0,onClick:el,disabled:!v.trim()||P,children:P?"Importing...":"Import"}),(0,s.jsx)(a.$n,{fullWidth:!0,variant:"ghost",onClick:et,disabled:P,children:"Cancel"})]})]})}),(0,s.jsx)(a.aF,{isOpen:m,title:"Deploy Vercel Relay",onClose:er,children:(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,s.jsxs)("div",{className:"rounded-lg bg-blue-500/5 border border-blue-500/10 p-3 flex flex-col gap-1.5",children:[(0,s.jsx)("p",{className:"text-sm text-text-main font-medium",children:"What is Vercel Relay?"}),(0,s.jsx)("p",{className:"text-xs text-text-muted",children:"Deploys an edge relay function to Vercel. All AI provider requests will be forwarded through Vercel's edge network, masking your real IP from providers."}),(0,s.jsxs)("ul",{className:"text-xs text-text-muted list-disc pl-4 space-y-0.5",children:[(0,s.jsx)("li",{children:"Your IP is replaced by Vercel's dynamic edge IPs (hundreds of IPs across 20+ global regions)"}),(0,s.jsx)("li",{children:"Vercel serves millions of apps — providers can't block Vercel IPs without affecting legitimate traffic"}),(0,s.jsx)("li",{children:"Free tier: 100GB bandwidth/month, 500K edge invocations"}),(0,s.jsx)("li",{children:"Deploy multiple relays on different accounts for more IP diversity"})]})]}),(0,s.jsx)(a.pd,{label:"Vercel API Token",value:b.vercelToken,onChange:e=>k(t=>({...t,vercelToken:e.target.value})),placeholder:"your-vercel-api-token",hint:(0,s.jsxs)(s.Fragment,{children:["Token is used once for deployment and not stored. ",(0,s.jsx)("a",{href:"https://vercel.com/account/tokens",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"Get token →"})]}),type:"password"}),(0,s.jsx)(a.pd,{label:"Project Name",value:b.projectName,onChange:e=>k(t=>({...t,projectName:e.target.value})),placeholder:"my-relay",hint:"Unique name for your Vercel project. Leave empty for auto-generated name."}),(0,s.jsxs)("div",{className:"grid grid-cols-1 gap-2 sm:grid-cols-2",children:[(0,s.jsx)(a.$n,{fullWidth:!0,onClick:es,disabled:!b.vercelToken.trim()||$,children:$?"Deploying... (may take ~1 min)":"Deploy"}),(0,s.jsx)(a.$n,{fullWidth:!0,variant:"ghost",onClick:er,disabled:$,children:"Cancel"})]})]})}),(0,s.jsx)(a.aF,{isOpen:c,title:u?"Edit Proxy Pool":"Add Proxy Pool",onClose:M,children:(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,s.jsx)(a.pd,{label:"Name",value:f.name,onChange:e=>g(t=>({...t,name:e.target.value})),placeholder:"Office Proxy"}),(0,s.jsx)(a.pd,{label:"Proxy URL",value:f.proxyUrl,onChange:e=>g(t=>({...t,proxyUrl:e.target.value})),placeholder:"http://127.0.0.1:7897"}),(0,s.jsx)(a.pd,{label:"No Proxy",value:f.noProxy,onChange:e=>g(t=>({...t,noProxy:e.target.value})),placeholder:"localhost,127.0.0.1,.internal",hint:"Comma-separated hosts/domains to bypass proxy"}),(0,s.jsxs)("div",{className:"flex flex-col gap-3 rounded-lg border border-border/50 p-3 sm:flex-row sm:items-center sm:justify-between",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"font-medium text-sm",children:"Active"}),(0,s.jsx)("p",{className:"text-xs text-text-muted",children:"Inactive pools are ignored by runtime resolution."})]}),(0,s.jsx)(a.lM,{checked:!0===f.isActive,onChange:()=>g(e=>({...e,isActive:!e.isActive})),disabled:N})]}),(0,s.jsxs)("div",{className:"flex flex-col gap-3 rounded-lg border border-border/50 p-3 sm:flex-row sm:items-center sm:justify-between",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"font-medium text-sm",children:"Strict Proxy"}),(0,s.jsx)("p",{className:"text-xs text-text-muted",children:"Fail request if proxy is unreachable instead of falling back to direct."})]}),(0,s.jsx)(a.lM,{checked:!0===f.strictProxy,onChange:()=>g(e=>({...e,strictProxy:!e.strictProxy})),disabled:N})]}),(0,s.jsxs)("div",{className:"grid grid-cols-1 gap-2 sm:grid-cols-2",children:[(0,s.jsx)(a.$n,{fullWidth:!0,onClick:q,disabled:!f.name.trim()||!f.proxyUrl.trim()||N,children:N?"Saving...":"Save"}),(0,s.jsx)(a.$n,{fullWidth:!0,variant:"ghost",onClick:M,disabled:N,children:"Cancel"})]})]})}),(0,s.jsx)(a.uo,{isOpen:!!V,onClose:()=>L(null),onConfirm:V?.onConfirm,title:V?.title||"Confirm",message:V?.message,variant:"danger"})]})}}},e=>{e.O(0,[2574,3862,2194,698,1321,5497,8441,3794,7358],()=>e(e.s=29500)),_N_E=e.O()}]);
|