zevairouter 1.0.259 → 1.0.261
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +11 -0
- package/cli/app/.next-cli-build/BUILD_ID +1 -1
- package/cli/app/.next-cli-build/app-path-routes-manifest.json +14 -14
- package/cli/app/.next-cli-build/build-manifest.json +2 -2
- package/cli/app/.next-cli-build/prerender-manifest.json +3 -3
- package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/automation/page_client-reference-manifest.js +1 -1
- package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/basic-chat/page_client-reference-manifest.js +1 -1
- package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/cli-tools/[toolId]/page_client-reference-manifest.js +1 -1
- package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/cli-tools/page_client-reference-manifest.js +1 -1
- package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/combos/page_client-reference-manifest.js +1 -1
- package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/console-log/page_client-reference-manifest.js +1 -1
- package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/context/page_client-reference-manifest.js +1 -1
- package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/endpoint/page_client-reference-manifest.js +1 -1
- package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/[kind]/[id]/page_client-reference-manifest.js +1 -1
- package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/[kind]/page_client-reference-manifest.js +1 -1
- package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/combo/[id]/page_client-reference-manifest.js +1 -1
- package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/web/page_client-reference-manifest.js +1 -1
- package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/mitm/page_client-reference-manifest.js +1 -1
- package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/page_client-reference-manifest.js +1 -1
- package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/playground/page_client-reference-manifest.js +1 -1
- package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/profile/page_client-reference-manifest.js +1 -1
- package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/[id]/page_client-reference-manifest.js +1 -1
- package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/new/page_client-reference-manifest.js +1 -1
- package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/page_client-reference-manifest.js +1 -1
- package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/proxy-pools/page_client-reference-manifest.js +1 -1
- package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/pxpipe/page_client-reference-manifest.js +1 -1
- package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/quota/page_client-reference-manifest.js +1 -1
- package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/settings/pricing/page_client-reference-manifest.js +1 -1
- package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/skills/page_client-reference-manifest.js +1 -1
- package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/terminal/page_client-reference-manifest.js +1 -1
- package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/token-saver/page_client-reference-manifest.js +1 -1
- package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/translator/page_client-reference-manifest.js +1 -1
- package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/usage/page_client-reference-manifest.js +1 -1
- package/cli/app/.next-cli-build/server/app/_global-error/page_client-reference-manifest.js +1 -1
- package/cli/app/.next-cli-build/server/app/_global-error.html +1 -1
- package/cli/app/.next-cli-build/server/app/_global-error.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/_global-error.segments/_global-error.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/_global-error.segments/_head.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/_global-error.segments/_index.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/cli/app/.next-cli-build/server/app/_not-found.html +1 -1
- package/cli/app/.next-cli-build/server/app/_not-found.rsc +3 -3
- package/cli/app/.next-cli-build/server/app/_not-found.segments/_full.segment.rsc +3 -3
- package/cli/app/.next-cli-build/server/app/_not-found.segments/_head.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/_not-found.segments/_index.segment.rsc +3 -3
- package/cli/app/.next-cli-build/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/_not-found.segments/_tree.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/api/cli-tools/all-statuses/route.js +4 -4
- package/cli/app/.next-cli-build/server/app/api/cli-tools/antigravity-mitm/alias/route.js +1 -1
- package/cli/app/.next-cli-build/server/app/api/cli-tools/claude-settings/route.js +2 -2
- package/cli/app/.next-cli-build/server/app/api/cli-tools/cline-settings/route.js +2 -2
- package/cli/app/.next-cli-build/server/app/api/cli-tools/codex-settings/route.js +1 -1
- package/cli/app/.next-cli-build/server/app/api/cli-tools/copilot-settings/route.js +2 -2
- package/cli/app/.next-cli-build/server/app/api/cli-tools/cowork-mcp-registry/route.js +1 -1
- package/cli/app/.next-cli-build/server/app/api/cli-tools/cowork-mcp-tools/route.js +1 -1
- package/cli/app/.next-cli-build/server/app/api/cli-tools/cowork-settings/route.js +1 -1
- package/cli/app/.next-cli-build/server/app/api/cli-tools/deepseek-tui-settings/route.js +2 -2
- package/cli/app/.next-cli-build/server/app/api/cli-tools/droid-settings/route.js +2 -2
- package/cli/app/.next-cli-build/server/app/api/cli-tools/grok-build-settings/route.js +3 -3
- package/cli/app/.next-cli-build/server/app/api/cli-tools/hermes-settings/route.js +1 -1
- package/cli/app/.next-cli-build/server/app/api/cli-tools/jcode-settings/route.js +2 -2
- package/cli/app/.next-cli-build/server/app/api/cli-tools/kilo-settings/route.js +2 -2
- package/cli/app/.next-cli-build/server/app/api/cli-tools/openclaw-settings/route.js +2 -2
- package/cli/app/.next-cli-build/server/app/api/cli-tools/opencode-settings/route.js +1 -1
- package/cli/app/.next-cli-build/server/app/api/combos/[id]/route.js +1 -1
- package/cli/app/.next-cli-build/server/app/api/dashboard/chat/completions/route.js +1 -1
- package/cli/app/.next-cli-build/server/app/api/dashboard/media/[operation]/route.js +1 -1
- package/cli/app/.next-cli-build/server/app/api/init/route.js +1 -1
- package/cli/app/.next-cli-build/server/app/api/models/route.js +1 -1
- package/cli/app/.next-cli-build/server/app/api/oauth/[provider]/[action]/route.js +1 -1
- package/cli/app/.next-cli-build/server/app/api/oauth/antigravity/bulk-import/[jobId]/cancel/route.js +1 -1
- package/cli/app/.next-cli-build/server/app/api/oauth/antigravity/bulk-import/[jobId]/manual/[workerId]/route.js +1 -1
- package/cli/app/.next-cli-build/server/app/api/oauth/antigravity/bulk-import/[jobId]/route.js +1 -1
- package/cli/app/.next-cli-build/server/app/api/oauth/antigravity/bulk-import/latest/route.js +1 -1
- package/cli/app/.next-cli-build/server/app/api/oauth/antigravity/bulk-import/route.js +1 -1
- package/cli/app/.next-cli-build/server/app/api/oauth/codex/import-token/route.js +1 -1
- package/cli/app/.next-cli-build/server/app/api/providers/[id]/test/route.js +1 -1
- package/cli/app/.next-cli-build/server/app/api/providers/client/route.js +1 -1
- package/cli/app/.next-cli-build/server/app/api/providers/route.js +1 -1
- package/cli/app/.next-cli-build/server/app/api/providers/test-batch/route.js +1 -1
- package/cli/app/.next-cli-build/server/app/api/pxpipe/logs/route.js +3 -0
- package/cli/app/.next-cli-build/server/app/api/pxpipe/logs/route.js.nft.json +1 -0
- package/cli/app/.next-cli-build/server/app/api/pxpipe/logs/route_client-reference-manifest.js +1 -0
- package/cli/app/.next-cli-build/server/app/api/settings/route.js +1 -1
- package/cli/app/.next-cli-build/server/app/api/translator/console-logs/route.js +1 -1
- package/cli/app/.next-cli-build/server/app/api/translator/console-logs/stream/route.js +1 -1
- package/cli/app/.next-cli-build/server/app/api/translator/send/route.js +1 -1
- package/cli/app/.next-cli-build/server/app/api/tunnel/tailscale-install/route.js +2 -2
- package/cli/app/.next-cli-build/server/app/api/usage/[connectionId]/codex-reset-credits/route.js +1 -1
- package/cli/app/.next-cli-build/server/app/api/usage/[connectionId]/route.js +1 -1
- package/cli/app/.next-cli-build/server/app/api/usage/aggregate/route.js +1 -1
- package/cli/app/.next-cli-build/server/app/api/usage/logs/route.js +1 -0
- package/cli/app/.next-cli-build/server/app/api/usage/logs/route.js.nft.json +1 -0
- package/cli/app/.next-cli-build/server/app/api/usage/logs/route_client-reference-manifest.js +1 -0
- package/cli/app/.next-cli-build/server/app/api/v1/api/chat/route.js +1 -1
- package/cli/app/.next-cli-build/server/app/api/v1/audio/speech/route.js +1 -1
- package/cli/app/.next-cli-build/server/app/api/v1/chat/completions/route.js +1 -1
- package/cli/app/.next-cli-build/server/app/api/v1/embeddings/route.js +1 -1
- package/cli/app/.next-cli-build/server/app/api/v1/images/generations/route.js +1 -1
- package/cli/app/.next-cli-build/server/app/api/v1/messages/route.js +1 -1
- package/cli/app/.next-cli-build/server/app/api/v1/models/[kind]/route.js +1 -1
- package/cli/app/.next-cli-build/server/app/api/v1/models/route.js +1 -1
- package/cli/app/.next-cli-build/server/app/api/v1/responses/compact/route.js +1 -1
- package/cli/app/.next-cli-build/server/app/api/v1/responses/route.js +1 -1
- package/cli/app/.next-cli-build/server/app/api/v1/route.js +1 -1
- package/cli/app/.next-cli-build/server/app/api/v1/search/route.js +1 -1
- package/cli/app/.next-cli-build/server/app/api/v1/web/fetch/route.js +1 -1
- package/cli/app/.next-cli-build/server/app/api/v1beta/models/[...path]/route.js +1 -1
- package/cli/app/.next-cli-build/server/app/api/version/route.js +1 -1
- package/cli/app/.next-cli-build/server/app/callback/page_client-reference-manifest.js +1 -1
- package/cli/app/.next-cli-build/server/app/callback.html +1 -1
- package/cli/app/.next-cli-build/server/app/callback.rsc +3 -3
- package/cli/app/.next-cli-build/server/app/callback.segments/_full.segment.rsc +3 -3
- package/cli/app/.next-cli-build/server/app/callback.segments/_head.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/callback.segments/_index.segment.rsc +3 -3
- package/cli/app/.next-cli-build/server/app/callback.segments/_tree.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/callback.segments/callback/__PAGE__.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/callback.segments/callback.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/automation.html +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/automation.rsc +5 -5
- package/cli/app/.next-cli-build/server/app/dashboard/automation.segments/!KGRhc2hib2FyZCk/dashboard/automation/__PAGE__.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/automation.segments/!KGRhc2hib2FyZCk/dashboard/automation.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/automation.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/automation.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/automation.segments/_full.segment.rsc +5 -5
- package/cli/app/.next-cli-build/server/app/dashboard/automation.segments/_head.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/automation.segments/_index.segment.rsc +3 -3
- package/cli/app/.next-cli-build/server/app/dashboard/automation.segments/_tree.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/basic-chat.html +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/basic-chat.rsc +5 -5
- package/cli/app/.next-cli-build/server/app/dashboard/basic-chat.segments/!KGRhc2hib2FyZCk/dashboard/basic-chat/__PAGE__.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/basic-chat.segments/!KGRhc2hib2FyZCk/dashboard/basic-chat.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/basic-chat.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/basic-chat.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/basic-chat.segments/_full.segment.rsc +5 -5
- package/cli/app/.next-cli-build/server/app/dashboard/basic-chat.segments/_head.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/basic-chat.segments/_index.segment.rsc +3 -3
- package/cli/app/.next-cli-build/server/app/dashboard/basic-chat.segments/_tree.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/cli-tools.html +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/cli-tools.rsc +5 -5
- package/cli/app/.next-cli-build/server/app/dashboard/cli-tools.segments/!KGRhc2hib2FyZCk/dashboard/cli-tools/__PAGE__.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/cli-tools.segments/!KGRhc2hib2FyZCk/dashboard/cli-tools.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/cli-tools.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/cli-tools.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/cli-tools.segments/_full.segment.rsc +5 -5
- package/cli/app/.next-cli-build/server/app/dashboard/cli-tools.segments/_head.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/cli-tools.segments/_index.segment.rsc +3 -3
- package/cli/app/.next-cli-build/server/app/dashboard/cli-tools.segments/_tree.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/combos.html +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/combos.rsc +5 -5
- package/cli/app/.next-cli-build/server/app/dashboard/combos.segments/!KGRhc2hib2FyZCk/dashboard/combos/__PAGE__.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/combos.segments/!KGRhc2hib2FyZCk/dashboard/combos.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/combos.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/combos.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/combos.segments/_full.segment.rsc +5 -5
- package/cli/app/.next-cli-build/server/app/dashboard/combos.segments/_head.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/combos.segments/_index.segment.rsc +3 -3
- package/cli/app/.next-cli-build/server/app/dashboard/combos.segments/_tree.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/context.html +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/context.rsc +5 -5
- package/cli/app/.next-cli-build/server/app/dashboard/context.segments/!KGRhc2hib2FyZCk/dashboard/context/__PAGE__.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/context.segments/!KGRhc2hib2FyZCk/dashboard/context.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/context.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/context.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/context.segments/_full.segment.rsc +5 -5
- package/cli/app/.next-cli-build/server/app/dashboard/context.segments/_head.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/context.segments/_index.segment.rsc +3 -3
- package/cli/app/.next-cli-build/server/app/dashboard/context.segments/_tree.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/endpoint.html +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/endpoint.rsc +5 -5
- package/cli/app/.next-cli-build/server/app/dashboard/endpoint.segments/!KGRhc2hib2FyZCk/dashboard/endpoint/__PAGE__.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/endpoint.segments/!KGRhc2hib2FyZCk/dashboard/endpoint.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/endpoint.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/endpoint.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/endpoint.segments/_full.segment.rsc +5 -5
- package/cli/app/.next-cli-build/server/app/dashboard/endpoint.segments/_head.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/endpoint.segments/_index.segment.rsc +3 -3
- package/cli/app/.next-cli-build/server/app/dashboard/endpoint.segments/_tree.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/media-providers/web.html +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/media-providers/web.rsc +5 -5
- package/cli/app/.next-cli-build/server/app/dashboard/media-providers/web.segments/!KGRhc2hib2FyZCk/dashboard/media-providers/web/__PAGE__.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/media-providers/web.segments/!KGRhc2hib2FyZCk/dashboard/media-providers/web.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/media-providers/web.segments/!KGRhc2hib2FyZCk/dashboard/media-providers.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/media-providers/web.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/media-providers/web.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/media-providers/web.segments/_full.segment.rsc +5 -5
- package/cli/app/.next-cli-build/server/app/dashboard/media-providers/web.segments/_head.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/media-providers/web.segments/_index.segment.rsc +3 -3
- package/cli/app/.next-cli-build/server/app/dashboard/media-providers/web.segments/_tree.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/mitm.html +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/mitm.rsc +5 -5
- package/cli/app/.next-cli-build/server/app/dashboard/mitm.segments/!KGRhc2hib2FyZCk/dashboard/mitm/__PAGE__.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/mitm.segments/!KGRhc2hib2FyZCk/dashboard/mitm.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/mitm.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/mitm.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/mitm.segments/_full.segment.rsc +5 -5
- package/cli/app/.next-cli-build/server/app/dashboard/mitm.segments/_head.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/mitm.segments/_index.segment.rsc +3 -3
- package/cli/app/.next-cli-build/server/app/dashboard/mitm.segments/_tree.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/playground.html +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/playground.rsc +5 -5
- package/cli/app/.next-cli-build/server/app/dashboard/playground.segments/!KGRhc2hib2FyZCk/dashboard/playground/__PAGE__.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/playground.segments/!KGRhc2hib2FyZCk/dashboard/playground.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/playground.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/playground.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/playground.segments/_full.segment.rsc +5 -5
- package/cli/app/.next-cli-build/server/app/dashboard/playground.segments/_head.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/playground.segments/_index.segment.rsc +3 -3
- package/cli/app/.next-cli-build/server/app/dashboard/playground.segments/_tree.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/profile.html +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/profile.rsc +5 -5
- package/cli/app/.next-cli-build/server/app/dashboard/profile.segments/!KGRhc2hib2FyZCk/dashboard/profile/__PAGE__.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/profile.segments/!KGRhc2hib2FyZCk/dashboard/profile.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/profile.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/profile.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/profile.segments/_full.segment.rsc +5 -5
- package/cli/app/.next-cli-build/server/app/dashboard/profile.segments/_head.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/profile.segments/_index.segment.rsc +3 -3
- package/cli/app/.next-cli-build/server/app/dashboard/profile.segments/_tree.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/providers/new.html +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/providers/new.rsc +5 -5
- package/cli/app/.next-cli-build/server/app/dashboard/providers/new.segments/!KGRhc2hib2FyZCk/dashboard/providers/new/__PAGE__.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/providers/new.segments/!KGRhc2hib2FyZCk/dashboard/providers/new.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/providers/new.segments/!KGRhc2hib2FyZCk/dashboard/providers.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/providers/new.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/providers/new.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/providers/new.segments/_full.segment.rsc +5 -5
- package/cli/app/.next-cli-build/server/app/dashboard/providers/new.segments/_head.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/providers/new.segments/_index.segment.rsc +3 -3
- package/cli/app/.next-cli-build/server/app/dashboard/providers/new.segments/_tree.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/providers.html +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/providers.rsc +5 -5
- package/cli/app/.next-cli-build/server/app/dashboard/providers.segments/!KGRhc2hib2FyZCk/dashboard/providers/__PAGE__.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/providers.segments/!KGRhc2hib2FyZCk/dashboard/providers.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/providers.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/providers.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/providers.segments/_full.segment.rsc +5 -5
- package/cli/app/.next-cli-build/server/app/dashboard/providers.segments/_head.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/providers.segments/_index.segment.rsc +3 -3
- package/cli/app/.next-cli-build/server/app/dashboard/providers.segments/_tree.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/proxy-pools.html +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/proxy-pools.rsc +5 -5
- package/cli/app/.next-cli-build/server/app/dashboard/proxy-pools.segments/!KGRhc2hib2FyZCk/dashboard/proxy-pools/__PAGE__.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/proxy-pools.segments/!KGRhc2hib2FyZCk/dashboard/proxy-pools.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/proxy-pools.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/proxy-pools.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/proxy-pools.segments/_full.segment.rsc +5 -5
- package/cli/app/.next-cli-build/server/app/dashboard/proxy-pools.segments/_head.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/proxy-pools.segments/_index.segment.rsc +3 -3
- package/cli/app/.next-cli-build/server/app/dashboard/proxy-pools.segments/_tree.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/pxpipe.html +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/pxpipe.rsc +5 -5
- package/cli/app/.next-cli-build/server/app/dashboard/pxpipe.segments/!KGRhc2hib2FyZCk/dashboard/pxpipe/__PAGE__.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/pxpipe.segments/!KGRhc2hib2FyZCk/dashboard/pxpipe.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/pxpipe.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/pxpipe.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/pxpipe.segments/_full.segment.rsc +5 -5
- package/cli/app/.next-cli-build/server/app/dashboard/pxpipe.segments/_head.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/pxpipe.segments/_index.segment.rsc +3 -3
- package/cli/app/.next-cli-build/server/app/dashboard/pxpipe.segments/_tree.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/quota.html +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/quota.rsc +6 -6
- package/cli/app/.next-cli-build/server/app/dashboard/quota.segments/!KGRhc2hib2FyZCk/dashboard/quota/__PAGE__.segment.rsc +3 -3
- package/cli/app/.next-cli-build/server/app/dashboard/quota.segments/!KGRhc2hib2FyZCk/dashboard/quota.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/quota.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/quota.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/quota.segments/_full.segment.rsc +6 -6
- package/cli/app/.next-cli-build/server/app/dashboard/quota.segments/_head.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/quota.segments/_index.segment.rsc +3 -3
- package/cli/app/.next-cli-build/server/app/dashboard/quota.segments/_tree.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/settings/pricing.html +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/settings/pricing.rsc +4 -4
- package/cli/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/!KGRhc2hib2FyZCk/dashboard/settings/pricing/__PAGE__.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/!KGRhc2hib2FyZCk/dashboard/settings/pricing.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/!KGRhc2hib2FyZCk/dashboard/settings.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/_full.segment.rsc +4 -4
- package/cli/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/_head.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/_index.segment.rsc +3 -3
- package/cli/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/_tree.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/skills.html +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/skills.rsc +5 -5
- package/cli/app/.next-cli-build/server/app/dashboard/skills.segments/!KGRhc2hib2FyZCk/dashboard/skills/__PAGE__.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/skills.segments/!KGRhc2hib2FyZCk/dashboard/skills.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/skills.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/skills.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/skills.segments/_full.segment.rsc +5 -5
- package/cli/app/.next-cli-build/server/app/dashboard/skills.segments/_head.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/skills.segments/_index.segment.rsc +3 -3
- package/cli/app/.next-cli-build/server/app/dashboard/skills.segments/_tree.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/token-saver.html +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/token-saver.rsc +5 -5
- package/cli/app/.next-cli-build/server/app/dashboard/token-saver.segments/!KGRhc2hib2FyZCk/dashboard/token-saver/__PAGE__.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/token-saver.segments/!KGRhc2hib2FyZCk/dashboard/token-saver.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/token-saver.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/token-saver.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/token-saver.segments/_full.segment.rsc +5 -5
- package/cli/app/.next-cli-build/server/app/dashboard/token-saver.segments/_head.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/token-saver.segments/_index.segment.rsc +3 -3
- package/cli/app/.next-cli-build/server/app/dashboard/token-saver.segments/_tree.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/translator.html +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/translator.rsc +5 -5
- package/cli/app/.next-cli-build/server/app/dashboard/translator.segments/!KGRhc2hib2FyZCk/dashboard/translator/__PAGE__.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/translator.segments/!KGRhc2hib2FyZCk/dashboard/translator.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/translator.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/translator.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/translator.segments/_full.segment.rsc +5 -5
- package/cli/app/.next-cli-build/server/app/dashboard/translator.segments/_head.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/translator.segments/_index.segment.rsc +3 -3
- package/cli/app/.next-cli-build/server/app/dashboard/translator.segments/_tree.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/usage.html +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/usage.rsc +5 -5
- package/cli/app/.next-cli-build/server/app/dashboard/usage.segments/!KGRhc2hib2FyZCk/dashboard/usage/__PAGE__.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/usage.segments/!KGRhc2hib2FyZCk/dashboard/usage.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/usage.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/usage.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/usage.segments/_full.segment.rsc +5 -5
- package/cli/app/.next-cli-build/server/app/dashboard/usage.segments/_head.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/usage.segments/_index.segment.rsc +3 -3
- package/cli/app/.next-cli-build/server/app/dashboard/usage.segments/_tree.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard.html +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard.rsc +5 -5
- package/cli/app/.next-cli-build/server/app/dashboard.segments/!KGRhc2hib2FyZCk/dashboard/__PAGE__.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard.segments/_full.segment.rsc +5 -5
- package/cli/app/.next-cli-build/server/app/dashboard.segments/_head.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard.segments/_index.segment.rsc +3 -3
- package/cli/app/.next-cli-build/server/app/dashboard.segments/_tree.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/index.html +1 -1
- package/cli/app/.next-cli-build/server/app/index.rsc +3 -3
- package/cli/app/.next-cli-build/server/app/index.segments/__PAGE__.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/index.segments/_full.segment.rsc +3 -3
- package/cli/app/.next-cli-build/server/app/index.segments/_head.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/index.segments/_index.segment.rsc +3 -3
- package/cli/app/.next-cli-build/server/app/index.segments/_tree.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/landing/page_client-reference-manifest.js +1 -1
- package/cli/app/.next-cli-build/server/app/landing.html +1 -1
- package/cli/app/.next-cli-build/server/app/landing.rsc +4 -4
- package/cli/app/.next-cli-build/server/app/landing.segments/_full.segment.rsc +4 -4
- package/cli/app/.next-cli-build/server/app/landing.segments/_head.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/landing.segments/_index.segment.rsc +3 -3
- package/cli/app/.next-cli-build/server/app/landing.segments/_tree.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/landing.segments/landing/__PAGE__.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/landing.segments/landing.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/login/page_client-reference-manifest.js +1 -1
- package/cli/app/.next-cli-build/server/app/login.html +1 -1
- package/cli/app/.next-cli-build/server/app/login.rsc +4 -4
- package/cli/app/.next-cli-build/server/app/login.segments/_full.segment.rsc +4 -4
- package/cli/app/.next-cli-build/server/app/login.segments/_head.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/login.segments/_index.segment.rsc +3 -3
- package/cli/app/.next-cli-build/server/app/login.segments/_tree.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/login.segments/login/__PAGE__.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/login.segments/login.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/page_client-reference-manifest.js +1 -1
- package/cli/app/.next-cli-build/server/app-paths-manifest.json +14 -14
- package/cli/app/.next-cli-build/server/chunks/1131.js +1 -1
- package/cli/app/.next-cli-build/server/chunks/1350.js +1 -1
- package/cli/app/.next-cli-build/server/chunks/3949.js +1 -1
- package/cli/app/.next-cli-build/server/chunks/4827.js +1 -1
- package/cli/app/.next-cli-build/server/chunks/4897.js +1 -1
- package/cli/app/.next-cli-build/server/chunks/6306.js +1 -1
- package/cli/app/.next-cli-build/server/chunks/7319.js +1 -1
- package/cli/app/.next-cli-build/server/chunks/7634.js +1 -1
- package/cli/app/.next-cli-build/server/chunks/8255.js +1 -1
- package/cli/app/.next-cli-build/server/chunks/8306.js +1 -1
- package/cli/app/.next-cli-build/server/chunks/891.js +1 -1
- package/cli/app/.next-cli-build/server/middleware-build-manifest.js +1 -1
- package/cli/app/.next-cli-build/server/pages/404.html +1 -1
- package/cli/app/.next-cli-build/server/pages/500.html +1 -1
- package/cli/app/.next-cli-build/server/server-reference-manifest.js +1 -1
- package/cli/app/.next-cli-build/server/server-reference-manifest.json +1 -1
- package/cli/app/.next-cli-build/static/chunks/{5497-0e1cdd657e997e26.js → 5497-58cf38baa1268b48.js} +1 -1
- package/cli/app/.next-cli-build/static/chunks/{620-a967fa09a99a1d76.js → 620-b9e1367e0c6f111d.js} +1 -1
- package/cli/app/.next-cli-build/static/chunks/app/api/pxpipe/logs/route-7f1163bd918d92ca.js +1 -0
- package/cli/app/.next-cli-build/static/chunks/app/api/usage/logs/route-7f1163bd918d92ca.js +1 -0
- package/cli/app/.next-cli-build/static/chunks/app/layout-697386c34f0b7bd3.js +1 -0
- package/cli/app/CHANGELOG.md +11 -0
- package/cli/app/package.json +1 -1
- package/cli/package.json +1 -1
- package/package.json +1 -1
- package/cli/app/.next-cli-build/static/chunks/app/layout-f01c49fcec50ff21.js +0 -1
- /package/cli/app/.next-cli-build/static/{v7xOjuW9eyRdslqZipu9l → sHt757a_EIQEUc1fFflTV}/_buildManifest.js +0 -0
- /package/cli/app/.next-cli-build/static/{v7xOjuW9eyRdslqZipu9l → sHt757a_EIQEUc1fFflTV}/_ssgManifest.js +0 -0
package/cli/app/.next-cli-build/static/chunks/{5497-0e1cdd657e997e26.js → 5497-58cf38baa1268b48.js}
RENAMED
|
@@ -4,4 +4,4 @@
|
|
|
4
4
|
`,children:[g.includes(e.name)&&(0,s.jsx)("span",{className:"material-symbols-outlined leading-none",style:{fontSize:"10px"},children:"check"}),e.name]},e.id)})})]}),Object.entries(M).map(([e,t])=>(0,s.jsxs)("div",{children:[(0,s.jsxs)("div",{className:"flex items-center gap-1.5 mb-1.5 sticky top-0 bg-surface py-0.5",children:[(0,s.jsx)(o.A,{src:`/providers/${e}.png`,alt:t.name,size:14,fallbackText:(t.name||e).slice(0,2).toUpperCase(),fallbackColor:t.color}),(0,s.jsx)("span",{className:"text-xs font-medium text-primary",children:t.name}),(0,s.jsxs)("span",{className:"text-[10px] text-text-muted",children:["(",t.models.length,")"]})]}),(0,s.jsx)("div",{className:"flex flex-wrap gap-1.5",children:t.models.map(e=>{let t=n===e.value,r=e.isPlaceholder;return(0,s.jsx)("button",{onClick:()=>q(e),title:r?"Select to pre-fill, then edit model ID in the input":void 0,className:`
|
|
5
5
|
px-2 py-1 rounded-xl text-xs font-medium transition-all border hover:cursor-pointer
|
|
6
6
|
${r?"border-dashed border-border text-text-muted hover:border-primary/50 hover:text-primary bg-surface italic":t?"bg-primary text-white border-primary":g.includes(e.value)?"bg-primary border-primary text-white hover:bg-primary-hover":"bg-surface border-border text-text-main hover:border-primary/50 hover:bg-primary/5"}
|
|
7
|
-
`,children:(0,s.jsxs)("span",{className:"flex items-center gap-1",children:[g.includes(e.value)&&!r&&(0,s.jsx)("span",{className:"material-symbols-outlined leading-none",style:{fontSize:"10px"},children:"check"}),r?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-[11px]",children:"edit"}),e.name]}):e.isCustom?(0,s.jsxs)(s.Fragment,{children:[e.name,(0,s.jsx)("span",{className:"text-[9px] opacity-60 font-normal",children:"custom"})]}):e.name]})},e.value)})})]},e)),0===Object.keys(M).length&&0===L.length&&(0,s.jsxs)("div",{className:"text-center py-4 text-text-muted",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-2xl mb-1 block",children:"search_off"}),(0,s.jsx)("p",{className:"text-xs",children:"No models found"})]})]})]})}x.propTypes={isOpen:n().bool.isRequired,onClose:n().func.isRequired,onSelect:n().func.isRequired,onDeselect:n().func,selectedModel:n().string,activeProviders:n().arrayOf(n().shape({provider:n().string.isRequired})),title:n().string,modelAliases:n().object,kindFilter:n().string,addedModelValues:n().arrayOf(n().string),closeOnSelect:n().bool}},73006:(e,t,r)=>{r.d(t,{FE:()=>p,Tl:()=>d,kk:()=>c,oQ:()=>m,wn:()=>h});var s=r(93308);let a={},l=s.Xn,n=[];function i(){if("u"<typeof document)return s.Xn;let e=document.cookie.split(";").find(e=>e.trim().startsWith(`${s.CL}=`)),t=e?decodeURIComponent(e.split("=")[1]):s.Xn;return(0,s.QC)(t)}async function o(e){if("en"===e){a={};return}try{let t=await fetch(`/i18n/literals/${e}.json`);a=await t.json()}catch(e){console.error("Failed to load translations:",e),a={}}}function d(e){if(!e||"string"!=typeof e)return e;let t=e.trim();return t&&"en"!==l&&a[t]||e}function c(){return l}function m(e){return n.push(e),()=>{n=n.filter(t=>t!==e)}}function u(e){if(!e.nodeValue||!e.nodeValue.trim())return;let t=e.parentElement;if(!t)return;let r=t;for(;r;){if(r.hasAttribute&&r.hasAttribute("data-i18n-skip"))return;r=r.parentElement}if(["script","style","code","pre","colgroup","table","thead","tbody","tfoot","tr","select","datalist","optgroup"].includes(t.tagName?.toLowerCase()))return;e._originalText||(e._originalText=e.nodeValue);let s=d(e._originalText);s!==e.nodeValue&&(e.nodeValue=s)}function x(e){let t;if(!e)return;let r=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,null,!1),s=[];for(;t=r.nextNode();)s.push(t);s.forEach(u)}async function p(){l=i(),await o(l),x(document.body),new MutationObserver(e=>{e.forEach(e=>{e.addedNodes.forEach(e=>{e.nodeType===Node.ELEMENT_NODE?x(e):e.nodeType===Node.TEXT_NODE&&u(e)})})}).observe(document.body,{childList:!0,subtree:!0})}async function h(){l=i(),await o(l),n.forEach(e=>e()),x(document.body)}},73579:(e,t,r)=>{r.d(t,{default:()=>u});var s=r(95155),a=r(12115),l=r(14051),n=r.n(l),i=r(81127),o=r(11910),d=r(92542),c=r(56061),m=r(52679);function u({isOpen:e,connection:t,proxyPools:r,onSave:l,onClose:n}){let[x,p]=(0,a.useState)({name:"",priority:1,apiKey:""}),[h,b]=(0,a.useState)({azureEndpoint:"",apiVersion:"2024-10-01-preview",deployment:"",organization:""}),[f,g]=(0,a.useState)({accountId:""}),[j,v]=(0,a.useState)({spaceId:"",spaceViewId:"",userId:"",clientVersion:"",cell:""}),[y,N]=(0,a.useState)(!1),[k,w]=(0,a.useState)(null),[C,S]=(0,a.useState)(!1),[I,T]=(0,a.useState)(null),[$,A]=(0,a.useState)(!1);(0,a.useEffect)(()=>{t&&(p({name:t.name||"",priority:t.priority||1,apiKey:""}),"azure"===t.provider&&t.providerSpecificData?b({azureEndpoint:t.providerSpecificData.azureEndpoint||"",apiVersion:t.providerSpecificData.apiVersion||"2024-10-01-preview",deployment:t.providerSpecificData.deployment||"",organization:t.providerSpecificData.organization||""}):b({azureEndpoint:"",apiVersion:"2024-10-01-preview",deployment:"",organization:""}),"cloudflare-ai"===t.provider&&t.providerSpecificData?g({accountId:t.providerSpecificData.accountId||""}):g({accountId:""}),"notion-ai"===t.provider&&t.providerSpecificData?v({spaceId:t.providerSpecificData.spaceId||"",spaceViewId:t.providerSpecificData.spaceViewId||"",userId:t.providerSpecificData.userId||t.providerSpecificData.notionUserId||"",clientVersion:t.providerSpecificData.clientVersion||"",cell:t.providerSpecificData.cell||""}):v({spaceId:"",spaceViewId:"",userId:"",clientVersion:"",cell:""}),w(null),T(null))},[t]);let P=t?.authType==="oauth",O=t?.provider==="azure",R=t?.provider==="cloudflare-ai",E=t?.provider==="notion-ai",_=!!t&&((0,m.mq)(t.provider)||(0,m.gb)(t.provider)),z=()=>{let e=Object.entries({spaceId:j.spaceId.trim(),spaceViewId:j.spaceViewId.trim(),userId:j.userId.trim(),clientVersion:j.clientVersion.trim(),cell:j.cell.trim()}).filter(([,e])=>e);return e.length>0?Object.fromEntries(e):void 0},L=async()=>{if(t?.provider){N(!0),w(null);try{let e=await fetch(`/api/providers/${t.id}/test`,{method:"POST"}),r=await e.json();w(r.valid?"success":"failed")}catch{w("failed")}finally{N(!1)}}},M=async()=>{if(t?.provider&&x.apiKey){S(!0),T(null);try{let e=await fetch("/api/providers/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:t.provider,apiKey:x.apiKey,...O?{providerSpecificData:h}:{},...R?{providerSpecificData:f}:{},...E?{providerSpecificData:z()}:{}})}),r=await e.json();T(r.valid?"success":"failed")}catch{T("failed")}finally{S(!1)}}},q=async()=>{if(t&&(P||!x.apiKey||"failed"!==I||window.confirm("The API key failed validation. Save it anyway?"))){A(!0);try{let e={name:x.name,priority:x.priority};if(!P&&x.apiKey){e.apiKey=x.apiKey;let r="success"===I;if(!r)try{S(!0),T(null);let e=await fetch("/api/providers/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:t.provider,apiKey:x.apiKey,...O?{providerSpecificData:h}:{},...R?{providerSpecificData:f}:{},...E?{providerSpecificData:z()}:{}})});r=!!(await e.json()).valid,T(r?"success":"failed")}catch{T("failed")}finally{S(!1)}r&&(e.testStatus="active",e.lastError=null,e.lastErrorAt=null)}O&&(e.providerSpecificData={azureEndpoint:h.azureEndpoint,apiVersion:h.apiVersion,deployment:h.deployment,organization:h.organization}),R&&(e.providerSpecificData={accountId:f.accountId}),E&&(e.providerSpecificData=z()),await l(e)}finally{A(!1)}}};return t?(0,s.jsx)(i.default,{isOpen:e,title:"Edit Connection",onClose:n,children:(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,s.jsx)(o.default,{label:"Name",value:x.name,onChange:e=>p({...x,name:e.target.value}),placeholder:P?"Account name":"Production Key"}),P&&t.email&&(0,s.jsxs)("div",{className:"bg-sidebar/50 p-3 rounded-lg",children:[(0,s.jsx)("p",{className:"text-sm text-text-muted mb-1",children:"Email"}),(0,s.jsx)("p",{className:"font-medium",children:t.email})]}),(0,s.jsx)(o.default,{label:"Priority",type:"number",value:x.priority,onChange:e=>p({...x,priority:Number.parseInt(e.target.value,10)||1})}),!P&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(o.default,{label:"cookie"===t.authType?"Cookie Value":"API Key",type:"cookie"===t.authType?"text":"password",value:x.apiKey,onChange:e=>p({...x,apiKey:e.target.value}),placeholder:"cookie"===t.authType?"Paste a new session cookie or cookie-export JSON":"Enter new API key",hint:"cookie"===t.authType?"Leave blank to keep the current cookie.":"Leave blank to keep the current API key.",className:"flex-1"}),(0,s.jsx)("div",{className:"pt-6",children:(0,s.jsx)(d.default,{onClick:M,disabled:!x.apiKey||C||$,variant:"secondary",children:C?"Checking...":"Check"})})]}),I&&(0,s.jsx)(c.default,{variant:"success"===I?"success":"error",children:"success"===I?"Valid":"Invalid"})]}),E&&(0,s.jsxs)("div",{className:"flex flex-col gap-3 rounded-lg border border-accent/20 bg-sidebar/50 p-4",children:[(0,s.jsx)("h3",{className:"text-sm font-semibold",children:"Notion workspace metadata (optional)"}),(0,s.jsx)("p",{className:"text-xs leading-relaxed text-text-muted",children:"Space ID and User ID are optional. The router resolves them from Notion's authenticated getSpaces endpoint; enter them only to override discovery."}),(0,s.jsx)(o.default,{label:"Space ID (optional)",value:j.spaceId,onChange:e=>v({...j,spaceId:e.target.value}),placeholder:"Auto-resolved from Notion"}),(0,s.jsx)(o.default,{label:"User ID (optional)",value:j.userId,onChange:e=>v({...j,userId:e.target.value}),placeholder:"Auto-resolved from Notion"}),(0,s.jsx)(o.default,{label:"Space View ID (optional)",value:j.spaceViewId,onChange:e=>v({...j,spaceViewId:e.target.value}),placeholder:"Leave blank to use Space ID"}),(0,s.jsx)(o.default,{label:"Notion client version (optional)",value:j.clientVersion,onChange:e=>v({...j,clientVersion:e.target.value}),placeholder:"Copy from the browser request if required"}),(0,s.jsx)(o.default,{label:"Cell (optional)",value:j.cell,onChange:e=>v({...j,cell:e.target.value}),placeholder:"Copy x-notion-cell if your request has it"})]}),O&&(0,s.jsxs)("div",{className:"bg-sidebar/50 p-4 rounded-lg border border-accent/20",children:[(0,s.jsx)("h3",{className:"font-semibold mb-3 text-sm",children:"Azure OpenAI Configuration"}),(0,s.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,s.jsx)(o.default,{label:"Azure Endpoint",value:h.azureEndpoint,onChange:e=>b({...h,azureEndpoint:e.target.value}),placeholder:"https://your-resource.openai.azure.com",hint:"Your Azure OpenAI resource endpoint URL"}),(0,s.jsx)(o.default,{label:"Deployment Name",value:h.deployment,onChange:e=>b({...h,deployment:e.target.value}),placeholder:"gpt-4",hint:"The deployment name in your Azure resource"}),(0,s.jsx)(o.default,{label:"API Version",value:h.apiVersion,onChange:e=>b({...h,apiVersion:e.target.value}),placeholder:"2024-10-01-preview",hint:"Azure OpenAI API version to use"}),(0,s.jsx)(o.default,{label:"Organization",value:h.organization,onChange:e=>b({...h,organization:e.target.value}),placeholder:"Organization ID",hint:"Required for billing"})]})]}),!_&&!O&&!R&&(0,s.jsxs)("div",{className:"flex items-center gap-3",children:[(0,s.jsx)(d.default,{onClick:L,variant:"secondary",disabled:y,children:y?"Testing...":"Test Connection"}),k&&(0,s.jsx)(c.default,{variant:"success"===k?"success":"error",children:"success"===k?"Valid":"Failed"})]}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(d.default,{onClick:q,fullWidth:!0,disabled:$,children:$?"Saving...":"Save"}),(0,s.jsx)(d.default,{onClick:n,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})}):null}u.propTypes={isOpen:n().bool.isRequired,connection:n().shape({id:n().string,name:n().string,email:n().string,priority:n().number,authType:n().string,provider:n().string,providerSpecificData:n().object}),proxyPools:n().arrayOf(n().shape({id:n().string,name:n().string})),onSave:n().func.isRequired,onClose:n().func.isRequired}},80752:(e,t,r)=>{r.d(t,{default:()=>m});var s=r(95155),a=r(12115),l=r(14051),n=r.n(l),i=r(1620),o=r(40197),d=r(81127);function c({icon:e,label:t,onClick:r,trailing:a,danger:l}){return(0,s.jsxs)("button",{onClick:r,className:`flex items-center gap-3 w-full px-4 py-2.5 text-sm transition-colors ${l?"text-red-500 hover:bg-red-500/10":"text-text-main hover:bg-black/5 dark:hover:bg-white/5"}`,children:[(0,s.jsx)("span",{className:`material-symbols-outlined text-[20px] ${l?"":"text-text-muted"}`,children:e}),(0,s.jsx)("span",{className:"flex-1 text-left",children:t}),a&&(0,s.jsx)("span",{className:"text-base",children:a})]})}function m({onLogout:e}){let[t,r]=(0,a.useState)(!1),[l,n]=(0,a.useState)(!1),[u,x]=(0,a.useState)(!1),[p,h]=(0,a.useState)(!1),{toggleTheme:b,isDark:f}=(0,i.D)(),g=(0,a.useRef)(null),j=async()=>{h(!0);try{await fetch("/api/version/shutdown",{method:"POST"})}catch(e){}};return(0,a.useEffect)(()=>{let e=e=>{g.current&&!g.current.contains(e.target)&&r(!1)};if(t)return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[t]),(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:"relative",ref:g,children:[(0,s.jsx)("button",{onClick:()=>r(e=>!e),className:"flex size-11 items-center justify-center rounded-xl text-text-muted transition-all hover:bg-black/5 hover:text-text-main dark:hover:bg-white/5 sm:size-10 sm:rounded-lg",title:"Menu","aria-label":"Open dashboard menu",children:(0,s.jsx)("span",{className:"material-symbols-outlined",children:"grid_view"})}),t&&(0,s.jsxs)("div",{className:"absolute right-0 top-full mt-2 w-60 bg-surface border border-black/10 dark:border-white/10 rounded-xl shadow-2xl z-50 animate-in fade-in zoom-in-95 duration-150 overflow-hidden py-1",children:[(0,s.jsx)(c,{icon:"history",label:"Change Log",onClick:()=>{r(!1),n(!0)}}),(0,s.jsx)(c,{icon:f?"light_mode":"dark_mode",label:"Theme",onClick:()=>{b(),r(!1)}}),(0,s.jsx)(c,{icon:"power_settings_new",label:"Shutdown",danger:!0,onClick:()=>{r(!1),x(!0)}}),(0,s.jsx)(c,{icon:"logout",label:"Logout",danger:!0,onClick:()=>{r(!1),e()}})]})]}),(0,s.jsx)(o.default,{isOpen:l,onClose:()=>n(!1)}),(0,s.jsx)(d.ConfirmModal,{isOpen:u,onClose:()=>{p||x(!1)},onConfirm:j,title:"Close Proxy",message:"Are you sure you want to close the proxy server?",confirmText:"Close",cancelText:"Cancel",variant:"danger",loading:p})]})}c.propTypes={icon:n().string.isRequired,label:n().string.isRequired,onClick:n().func.isRequired,trailing:n().node,danger:n().bool},m.propTypes={onLogout:n().func.isRequired}},81127:(e,t,r)=>{r.d(t,{ConfirmModal:()=>d,default:()=>o});var s=r(95155),a=r(12115),l=r(31474),n=r(92542),i=r(97677);function o({isOpen:e,onClose:t,title:r,children:n,footer:d,size:c="md",closeOnOverlay:m=!0,showTrafficLights:u=!0,className:x}){let p=(0,a.useId)(),h=(0,a.useRef)(null),b=(0,a.useRef)(null),f=(0,a.useRef)(t),g='button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';return((0,a.useEffect)(()=>{f.current=t},[t]),(0,a.useEffect)(()=>{if(!e)return;let t=document.body.style.overflow;b.current=document.activeElement,document.body.style.overflow="hidden";let r=h.current,s=r?.querySelector('input:not([disabled]):not([type="hidden"]):not([type="button"]):not([type="submit"]):not([type="checkbox"]):not([type="radio"]), textarea:not([disabled]), select:not([disabled])')||r?.querySelector(g);(s||r)?.focus();let a=e=>{if("Escape"===e.key)return void f.current?.();if("Tab"!==e.key||!r)return;let t=[...r.querySelectorAll(g)];if(!t.length){e.preventDefault(),r.focus();return}let s=t[0],a=t[t.length-1];e.shiftKey&&document.activeElement===s?(e.preventDefault(),a.focus()):e.shiftKey||document.activeElement!==a||(e.preventDefault(),s.focus())};return document.addEventListener("keydown",a),()=>{document.body.style.overflow=t,document.removeEventListener("keydown",a),b.current?.focus?.()}},[e]),e)?(0,s.jsxs)("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",children:[(0,s.jsx)("div",{className:"absolute inset-0 bg-black/50 backdrop-blur-[2px] fade-in",onClick:m?t:void 0}),(0,s.jsxs)("div",{ref:h,role:"dialog","aria-modal":"true","aria-labelledby":r?p:void 0,"aria-label":r?void 0:"Dialog",tabIndex:-1,className:(0,l.cn)("relative w-full max-h-[calc(100dvh-2rem)] overflow-hidden bg-surface","border border-border-subtle","rounded-[14px] shadow-[var(--shadow-elev)]","fade-in",{sm:"max-w-sm",md:"max-w-md",lg:"max-w-lg",xl:"max-w-xl",full:"max-w-4xl"}[c],x),children:[(r||u)&&(0,s.jsxs)("div",{className:"flex items-center justify-between p-2 border-b border-border-subtle",children:[(0,s.jsxs)("div",{className:"flex items-center",children:[u&&(0,s.jsxs)("div",{className:"hidden md:flex items-center gap-2 mr-4 ml-2",children:[(0,s.jsx)(i.default,{text:"Close",position:"top",color:"#FF5F56",children:(0,s.jsx)("button",{onClick:t,"aria-label":"Close",title:"Close",className:"w-4 h-4 rounded-full bg-[#FF5F56] hover:brightness-90 transition-all cursor-pointer flex items-center justify-center group/dot",children:(0,s.jsx)("span",{className:"text-[9px] font-bold text-white opacity-0 group-hover/dot:opacity-100 transition-opacity leading-none",children:"✕"})})}),(0,s.jsx)("div",{className:"w-4 h-4 rounded-full bg-[#3a3a3a]/20 dark:bg-white/15 cursor-not-allowed"}),(0,s.jsx)("div",{className:"w-4 h-4 rounded-full bg-[#3a3a3a]/20 dark:bg-white/15 cursor-not-allowed"})]}),r&&(0,s.jsx)("h2",{id:p,className:"text-lg font-semibold text-text-main",children:r})]}),(0,s.jsx)("button",{onClick:t,"aria-label":"Close",className:"md:hidden p-1.5 rounded-[10px] text-text-muted hover:bg-surface-2 hover:text-text-main transition-colors",children:(0,s.jsx)("span",{"aria-hidden":"true",className:"material-symbols-outlined text-[20px]",children:"close"})})]}),(0,s.jsx)("div",{className:"p-6 max-h-[calc(85vh-100px)] overflow-y-auto custom-scrollbar",children:n}),d&&(0,s.jsx)("div",{className:"flex items-center justify-end gap-3 p-6 border-t border-border-subtle",children:d})]})]}):null}function d({isOpen:e,onClose:t,onConfirm:r,title:a="Confirm",message:l,confirmText:i="Confirm",cancelText:c="Cancel",variant:m="danger",loading:u=!1}){return(0,s.jsx)(o,{isOpen:e,onClose:t,title:a,size:"sm",footer:(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(n.default,{variant:"ghost",onClick:t,disabled:u,children:c}),(0,s.jsx)(n.default,{variant:m,onClick:r,loading:u,children:i})]}),children:(0,s.jsx)("p",{className:"text-text-muted",children:l})})}},84588:(e,t,r)=>{r.d(t,{default:()=>l});var s=r(95155),a=r(31474);function l({children:e,title:t,subtitle:r,icon:n,action:i,padding:o="md",hover:d=!1,elev:c=!1,className:m,...u}){return(0,s.jsxs)("div",{className:(0,a.cn)("card-3d border border-border-subtle rounded-[14px] transition-[border-color,box-shadow,transform] duration-200",c&&"card-3d-elev",d&&"hover:-translate-y-0.5 hover:border-brand-500/30 hover:shadow-[var(--shadow-warm)] cursor-pointer",{none:"",xs:"p-3",sm:"p-4",md:"p-6",lg:"p-8"}[o],m),...u,children:[(t||i)&&(0,s.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,s.jsxs)("div",{className:"flex items-center gap-3",children:[n&&(0,s.jsx)("div",{className:"p-2 rounded-[10px] bg-bg text-text-muted",children:(0,s.jsx)("span",{className:"material-symbols-outlined text-[20px]",children:n})}),(0,s.jsxs)("div",{children:[t&&(0,s.jsx)("h3",{className:"text-text-main font-semibold",children:t}),r&&(0,s.jsx)("p",{className:"text-sm text-text-muted",children:r})]})]}),i]}),e]})}l.Section=function({children:e,className:t,...r}){return(0,s.jsx)("div",{className:(0,a.cn)("p-4 rounded-[10px]","bg-bg border border-border-subtle",t),...r,children:e})},l.Row=function({children:e,className:t,...r}){return(0,s.jsx)("div",{className:(0,a.cn)("p-3 -mx-3 px-3 transition-colors","border-b border-border-subtle last:border-b-0","hover:bg-surface-2/50",t),...r,children:e})},l.ListItem=function({children:e,actions:t,className:r,...l}){return(0,s.jsxs)("div",{className:(0,a.cn)("group flex items-center justify-between p-3 -mx-3 px-3","border-b border-border-subtle last:border-b-0","hover:bg-surface-2/50 transition-colors",r),...l,children:[(0,s.jsx)("div",{className:"flex-1 min-w-0",children:e}),t&&(0,s.jsx)("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:t})]})}},90085:(e,t,r)=>{r.d(t,{A:()=>i});var s=r(1934),a=r(31692),l=r(90620);function n(e){let t=document.documentElement,r=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light";"dark"===("system"===e?r:e)?t.classList.add("dark"):t.classList.remove("dark")}let i=(0,s.v)((0,a.Zr)((e,t)=>({theme:l.B2.defaultTheme,setTheme:t=>{e({theme:t}),n(t)},toggleTheme:()=>{let r="dark"===t().theme?"light":"dark";e({theme:r}),n(r)},initTheme:()=>{n(t().theme)}}),{name:l.B2.storageKey}))},90882:(e,t,r)=>{r.d(t,{default:()=>d});var s=r(95155),a=r(12115),l=r(14051),n=r.n(l),i=r(35497),o=r(11059);function d({isOpen:e,provider:t,providerInfo:r,onSuccess:l,onClose:n,oauthMeta:c,idcConfig:m}){let[u,x]=(0,a.useState)("waiting"),[p,h]=(0,a.useState)(null),[b,f]=(0,a.useState)(""),[g,j]=(0,a.useState)(null),[v,y]=(0,a.useState)(!1),[N,k]=(0,a.useState)(null),[w,C]=(0,a.useState)(!1),S=(0,a.useRef)(null),I=(0,a.useRef)(0),{copied:T,copy:$}=(0,o.C)(),[A,P]=(0,a.useState)(!1),[O,R]=(0,a.useState)("/callback?code=..."),E=(0,a.useRef)(!1);(0,a.useEffect)(()=>{P("localhost"===window.location.hostname||"127.0.0.1"===window.location.hostname),R(`${window.location.origin}/callback?code=...`)},[]);let _=(0,a.useCallback)(async(e,r)=>{if(p)try{let s=await fetch(`/api/oauth/${t}/exchange`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({code:e,redirectUri:p.redirectUri,codeVerifier:p.codeVerifier,state:r,...c?{meta:c}:{}})}),a=await s.json();if(!s.ok)throw Error(a.error);x("success"),l?.()}catch(e){j(e.message),x("error")}},[p,t,l,c]),z=(0,a.useCallback)(async e=>{if(p?.state)try{let t=await fetch("/api/oauth/xai/manual-code",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({code:e,state:p.state})}),r=await t.json();if(!t.ok)throw Error(r.error);x("success"),l?.()}catch(e){j(e.message),x("error")}},[p,l]),L=(0,a.useCallback)(async(e,r,s,a,n)=>{let i=++I.current,o=()=>I.current===i;C(!0);let d=Date.now()+(Number.isFinite(n)&&n>0?n:12e4);for(;Date.now()<d;){if(!o())return void console.log("[OAuthModal] Polling aborted");if(await new Promise(e=>setTimeout(e,1e3*s)),!o())return void console.log("[OAuthModal] Polling aborted after sleep");try{let n=await fetch(`/api/oauth/${t}/poll`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({deviceCode:e,codeVerifier:r,extraData:a})}),i=await n.json();if(!o())return;if(i.success){I.current++,x("success"),C(!1),l?.();return}if("expired_token"===i.error||"access_denied"===i.error)throw Error(i.errorDescription||i.error);"slow_down"===i.error&&(s=Math.min(s+5,30))}catch(e){if(!o())return;j(e.message),x("error"),C(!1);return}}o()&&(j("Authorization timeout"),x("error"),C(!1))},[t,l]),M=(0,a.useCallback)(async()=>{if(t)try{let e;j(null);let r=window.location.hostname.toLowerCase(),s="codex"===t&&"localhost"!==r&&"127.0.0.1"!==r&&"::1"!==r;if(["github","qwen","kiro","kimi","kimi-coding","kilocode","codebuddy","codebuddy-cn","qoder","grok-cli",...s?["codex"]:[]].includes(t)){y(!0),x("waiting");let e=new URL(`/api/oauth/${t}/device-code`,window.location.origin);"kiro"===t&&m?.startUrl&&(e.searchParams.set("start_url",m.startUrl),m.region&&e.searchParams.set("region",m.region),e.searchParams.set("auth_method","idc"));let r=await fetch(e.toString()),s=await r.json();if(!r.ok)throw Error(s.error);k(s);let a=s.verification_uri_complete||s.verification_uri;a&&window.open(a,"_blank","noopener,noreferrer");let l="codex"===t?{_codexUserCode:s.user_code}:"kiro"===t?{_clientId:s._clientId,_clientSecret:s._clientSecret,_region:s._region,_authMethod:s._authMethod,_startUrl:s._startUrl}:"qoder"===t?{_qoderNonce:s._qoderNonce,_qoderMachineId:s._qoderMachineId,_qoderVerifier:s.codeVerifier}:null;L(s.device_code,s.codeVerifier,s.interval||5,l,Number.isFinite(s.expires_in)&&s.expires_in>0?1e3*s.expires_in:void 0);return}if(["trae","windsurf","zed"].includes(t)){let e=await fetch(`/api/oauth/${t}/start-proxy`),r=await e.json();if(!e.ok||!r.success||!r.callbackUrl)throw Error(r.reason||r.error||`Failed to start ${t} callback server`);let s=new URL(`/api/oauth/${t}/authorize`,window.location.origin);s.searchParams.set("redirect_uri",r.callbackUrl);let a=await fetch(s.toString()),l=await a.json();if(!a.ok)throw Error(l.error);let n={state:l.state};l.codeVerifier&&(n.codeVerifier=l.codeVerifier),await fetch(`/api/oauth/${t}/register-session`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)}),h({...l,proxyProvider:t}),x("waiting"),S.current=window.open(l.authUrl,"oauth_popup","width=600,height=700"),S.current||x("input");return}let a=window.location.port||("https:"===window.location.protocol?"443":"80");e="codex"===t?"http://localhost:1455/auth/callback":"xai"===t?"http://127.0.0.1:56121/callback":`http://localhost:${a}/callback`;let l=new URL(`/api/oauth/${t}/authorize`,window.location.origin);l.searchParams.set("redirect_uri",e),c&&Object.entries(c).forEach(([e,t])=>{t&&l.searchParams.set(e,t)});let n=await fetch(l.toString()),i=await n.json();if(!n.ok)throw Error(i.error);let o=!1,d=!1;if("codex"===t)try{let t=await fetch("/api/oauth/codex/start-proxy",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({appPort:a,state:i.state,codeVerifier:i.codeVerifier,redirectUri:e})}),r=await t.json();o=r.success,d=!!r.serverSide}catch{o=!1}let u=!1,p=!1;if("xai"===t)try{let t=await fetch("/api/oauth/xai/start-proxy",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({appPort:a,state:i.state,codeVerifier:i.codeVerifier,redirectUri:e})}),r=await t.json();if(u=r.success,p=!!r.serverSide,!u&&"port_busy"===r.reason)throw Error("Port 56121 in use; close the conflicting process and retry")}catch(e){if(e?.message)throw e;u=!1}h({...i,redirectUri:e,codexServerSide:d,xaiServerSide:p}),"codex"===t&&o||"xai"===t&&u||A&&"codex"!==t&&"xai"!==t?(x("waiting"),S.current=window.open(i.authUrl,"oauth_popup","width=600,height=700"),S.current||x("input")):(x("input"),window.open(i.authUrl,"_blank","noopener,noreferrer"))}catch(e){j(e.message),x("error")}},[t,A,L,c,m]);(0,a.useEffect)(()=>{e&&t?(h(null),f(""),j(null),y(!1),k(null),C(!1),M()):!e&&(I.current++,"codex"===t?fetch("/api/oauth/codex/stop-proxy",{method:"POST"}).catch(()=>{}):"xai"===t?fetch("/api/oauth/xai/stop-proxy",{method:"POST"}).catch(()=>{}):["trae","windsurf","zed"].includes(t)&&fetch(`/api/oauth/${t}/stop-proxy`).catch(()=>{}))},[e,t,M]),(0,a.useEffect)(()=>{let e=p?.codexServerSide?"codex":p?.xaiServerSide?"xai":p?.proxyProvider||null;if(!e||!p?.state||E.current)return;let t=!1,r=null,s=0,a=async()=>{if(!t&&!E.current){s+=1;try{let r=await fetch(`/api/oauth/${e}/poll-status?state=${encodeURIComponent(p.state)}`),s=await r.json();if(t||E.current)return;if("done"===s.status){E.current=!0,x("success"),l?.();return}if("error"===s.status){E.current=!0,j(s.error||"Authentication failed"),x("error");return}}catch{}if(s>=200){E.current=!0,j("Authentication timeout"),x("error");return}r=setTimeout(a,1500)}};return r=setTimeout(a,1500),()=>{t=!0,r&&clearTimeout(r)}},[p,l]),(0,a.useEffect)(()=>{let e;if(!p)return;E.current=!1;let t=async e=>{if(E.current)return;let{code:t,state:r,error:s,errorDescription:a}=e;if(s){E.current=!0,j(a||s),x("error");return}t&&(E.current=!0,await _(t,r))},r=e=>{let r=e.origin.includes("localhost")||e.origin.includes("127.0.0.1"),s=e.origin===window.location.origin;(r||s)&&e.data?.type==="oauth_callback"&&t(e.data.data)};window.addEventListener("message",r);try{(e=new BroadcastChannel("oauth_callback")).onmessage=e=>t(e.data)}catch(e){console.log("BroadcastChannel not supported")}let s=e=>{if("oauth_callback"===e.key&&e.newValue)try{let r=JSON.parse(e.newValue);t(r),localStorage.removeItem("oauth_callback")}catch(e){console.log("Failed to parse localStorage data")}};window.addEventListener("storage",s);try{let e=localStorage.getItem("oauth_callback");if(e){let r=JSON.parse(e);r.timestamp&&Date.now()-r.timestamp<3e4&&t(r),localStorage.removeItem("oauth_callback")}}catch{}return()=>{window.removeEventListener("message",r),window.removeEventListener("storage",s),e&&e.close()}},[p,_]);let q=async()=>{try{j(null);let e=b.trim();if(e.startsWith("eyJ")&&e.includes("."))return void await _(e,null);if("xai"===t&&e&&!e.includes("://")&&!e.includes("?")&&!e.includes("code="))return void await z(e);if("kimchi"===t&&e&&!e.includes("://")&&!e.includes("?"))return void await _(e,null);let r=new URL(e),s=r.searchParams.get("code"),a=r.searchParams.get("token"),l=r.searchParams.get("state"),n=r.searchParams.get("error");if(n)throw Error(r.searchParams.get("error_description")||n);if(!s&&!a)throw Error("xai"===t?"Paste the callback URL or copied xAI code":"kimchi"===t?"No Kimchi token found in URL":"No authorization code found in URL");await _(a||s,l)}catch(e){j(e.message),x("error")}},D=(0,a.useCallback)(()=>{"codex"===t?fetch("/api/oauth/codex/stop-proxy",{method:"POST"}).catch(()=>{}):"xai"===t&&fetch("/api/oauth/xai/stop-proxy",{method:"POST"}).catch(()=>{}),n()},[n,t]);if(!t||!r)return null;let U="xai"===t,F="kimchi"===t,W=N?.verification_uri_complete||N?.verification_uri||"",B=U?"Connect Grok Build OAuth":`Connect ${r.name}`,K=U?"http://127.0.0.1:56121/callback?code=... or copied code":F?`${O.replace("code=...","token=...")} or copied token`:O;return(0,s.jsx)(i.aF,{isOpen:e,title:B,onClose:D,size:"lg",children:(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:[("waiting"===u||"input"===u)&&!v&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 border border-border rounded-lg bg-sidebar/50",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-base text-primary animate-spin",children:"progress_activity"}),(0,s.jsx)("span",{className:"text-sm",children:U?"Waiting for Grok Build OAuth…":"Waiting for popup authorization…"})]}),(0,s.jsxs)("div",{className:"flex items-center gap-3 my-1",children:[(0,s.jsx)("div",{className:"flex-1 h-px bg-border"}),(0,s.jsx)("span",{className:"text-xs text-text-muted uppercase tracking-wider",children:"Or paste callback URL manually"}),(0,s.jsx)("div",{className:"flex-1 h-px bg-border"})]}),(0,s.jsxs)("div",{className:"space-y-4",children:[(0,s.jsxs)("div",{children:[(0,s.jsxs)("p",{className:"text-sm font-medium mb-2",children:["Step 1: Open this ",U?"Grok Build OAuth URL":"URL"," in your browser"]}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(i.pd,{value:p?.authUrl||"",readOnly:!0,className:"flex-1 font-mono text-xs"}),(0,s.jsx)(i.$n,{variant:"secondary",icon:"auth_url"===T?"check":"content_copy",onClick:()=>$(p?.authUrl,"auth_url"),disabled:!p?.authUrl,children:"Copy"})]})]}),(0,s.jsxs)("div",{children:[(0,s.jsxs)("p",{className:"text-sm font-medium mb-2",children:["Step 2: Paste the ","xai"===t?"callback URL or copied code":"kimchi"===t?"callback URL or token":"callback URL"," here"]}),(0,s.jsx)("p",{className:"text-xs text-text-muted mb-2",children:"xai"===t?"If xAI shows a code instead of redirecting, paste that code here.":"kimchi"===t?"After authorization, paste the callback URL (with token=…) or the raw Kimchi token.":"After authorization, copy the full URL from your browser."}),(0,s.jsx)(i.pd,{value:b,onChange:e=>f(e.target.value),placeholder:K,className:"font-mono text-xs"})]})]}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(i.$n,{onClick:q,fullWidth:!0,disabled:!b,children:"Connect"}),(0,s.jsx)(i.$n,{onClick:D,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]}),"waiting"===u&&v&&N&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:"text-center py-4",children:[(0,s.jsx)("p",{className:"text-sm text-text-muted mb-4",children:"Visit the login URL below and authorize:"}),(0,s.jsxs)("div",{className:"bg-sidebar p-4 rounded-lg mb-4",children:[(0,s.jsx)("p",{className:"text-xs text-text-muted mb-1",children:"Login URL"}),(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("code",{className:"flex-1 text-sm break-all",children:W}),(0,s.jsx)(i.$n,{size:"sm",variant:"ghost",icon:"login_url"===T?"check":"content_copy",onClick:()=>$(W,"login_url"),disabled:!W}),(0,s.jsx)(i.$n,{size:"sm",variant:"ghost",icon:"open_in_new",onClick:()=>window.open(W,"_blank","noopener,noreferrer"),disabled:!W,children:"Open"})]})]}),(0,s.jsxs)("div",{className:"bg-primary/10 p-4 rounded-lg",children:[(0,s.jsx)("p",{className:"text-xs text-text-muted mb-1",children:"Your Code"}),(0,s.jsxs)("div",{className:"flex items-center justify-center gap-2",children:[(0,s.jsx)("p",{className:"text-2xl font-mono font-bold text-primary",children:N.user_code}),(0,s.jsx)(i.$n,{size:"sm",variant:"ghost",icon:"user_code"===T?"check":"content_copy",onClick:()=>$(N.user_code,"user_code")})]})]})]}),w&&(0,s.jsxs)("div",{className:"flex items-center justify-center gap-2 text-sm text-text-muted",children:[(0,s.jsx)("span",{className:"material-symbols-outlined animate-spin",children:"progress_activity"}),"Waiting for authorization..."]})]}),"success"===u&&(0,s.jsxs)("div",{className:"text-center py-6",children:[(0,s.jsx)("div",{className:"size-16 mx-auto mb-4 rounded-full bg-green-100 dark:bg-green-900/30 flex items-center justify-center",children:(0,s.jsx)("span",{className:"material-symbols-outlined text-3xl text-green-600",children:"check_circle"})}),(0,s.jsx)("h3",{className:"text-lg font-semibold mb-2",children:"Connected Successfully!"}),(0,s.jsxs)("p",{className:"text-sm text-text-muted mb-4",children:["Your ",r.name," account has been connected."]}),(0,s.jsx)(i.$n,{onClick:D,fullWidth:!0,children:"Done"})]}),"error"===u&&(0,s.jsxs)("div",{className:"text-center py-6",children:[(0,s.jsx)("div",{className:"size-16 mx-auto mb-4 rounded-full bg-red-100 dark:bg-red-900/30 flex items-center justify-center",children:(0,s.jsx)("span",{className:"material-symbols-outlined text-3xl text-red-600",children:"error"})}),(0,s.jsx)("h3",{className:"text-lg font-semibold mb-2",children:"Connection Failed"}),(0,s.jsx)("p",{className:"text-sm text-red-600 mb-4",children:g}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(i.$n,{onClick:M,variant:"secondary",fullWidth:!0,children:"Try Again"}),(0,s.jsx)(i.$n,{onClick:D,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})]})})}d.propTypes={isOpen:n().bool.isRequired,provider:n().string,providerInfo:n().shape({name:n().string}),onSuccess:n().func,onClose:n().func.isRequired,oauthMeta:n().object,idcConfig:n().shape({startUrl:n().string,region:n().string})}},91450:(e,t,r)=>{r.d(t,{default:()=>i});var s=r(95155),a=r(14051),l=r.n(a),n=r(38587);function i({children:e}){return(0,s.jsxs)("div",{className:"min-h-screen flex flex-col relative bg-bg transition-colors duration-500 overflow-x-hidden selection:bg-primary/20 selection:text-primary",children:[(0,s.jsx)("div",{className:"fixed top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-[800px] h-[800px] bg-primary/5 dark:bg-primary/5 rounded-full blur-[100px] pointer-events-none z-0"}),(0,s.jsx)("div",{className:"fixed bottom-0 right-0 w-[600px] h-[600px] bg-orange-200/20 dark:bg-orange-900/10 rounded-full blur-[120px] pointer-events-none z-0 translate-y-1/3 translate-x-1/3"}),(0,s.jsx)("div",{className:"absolute top-6 right-6 z-20",children:(0,s.jsx)(n.default,{variant:"card"})}),(0,s.jsx)("main",{className:"flex-1 flex flex-col items-center justify-center p-4 sm:p-6 z-10 w-full h-full",children:e})]})}i.propTypes={children:l().node.isRequired}},92173:(e,t,r)=>{r.d(t,{default:()=>c});var s=r(95155),a=r(98500),l=r.n(a),n=r(90620);let i=[{label:"Features",href:"#features"},{label:"Pricing",href:"#pricing"},{label:"Changelog",href:"#"}],o=[{label:"Documentation",href:"#"},{label:"API Reference",href:"#"},{label:"Help Center",href:"#"}],d=[{label:"About",href:"#"},{label:"Blog",href:"#"},{label:"Contact",href:"#"}];function c(){return(0,s.jsx)("footer",{className:"bg-bg border-t border-border pt-16 pb-12",children:(0,s.jsxs)("div",{className:"container mx-auto px-4 sm:px-6 lg:px-8",children:[(0,s.jsxs)("div",{className:"grid grid-cols-2 md:grid-cols-4 lg:grid-cols-5 gap-10 mb-12",children:[(0,s.jsxs)("div",{className:"col-span-2 lg:col-span-2",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2 mb-6",children:[(0,s.jsx)("div",{className:"size-6 text-primary",children:(0,s.jsx)("svg",{className:"w-full h-full",fill:"currentColor",viewBox:"0 0 48 48",children:(0,s.jsx)("path",{clipRule:"evenodd",d:"M12.0799 24L4 19.2479L9.95537 8.75216L18.04 13.4961L18.0446 4H29.9554L29.96 13.4961L38.0446 8.75216L44 19.2479L35.92 24L44 28.7521L38.0446 39.2479L29.96 34.5039L29.9554 44H18.0446L18.04 34.5039L9.95537 39.2479L4 28.7521L12.0799 24Z",fillRule:"evenodd"})})}),(0,s.jsx)("span",{className:"text-xl font-bold text-text-main",children:n.vQ.name})]}),(0,s.jsx)("p",{className:"text-text-muted mb-6 max-w-sm font-light",children:"The unified interface for modern AI infrastructure. Secure, observable, and scalable."}),(0,s.jsxs)("div",{className:"flex gap-4",children:[(0,s.jsx)("a",{href:"#",className:"text-gray-400 hover:text-primary transition-colors","aria-label":"Twitter",children:(0,s.jsx)("svg",{className:"w-5 h-5",fill:"currentColor",viewBox:"0 0 24 24",children:(0,s.jsx)("path",{d:"M22.46 6c-.77.35-1.6.58-2.46.69.88-.53 1.56-1.37 1.88-2.38-.83.5-1.75.85-2.72 1.05C18.37 4.5 17.26 4 16 4c-2.35 0-4.27 1.92-4.27 4.29 0 .34.04.67.11.98C8.28 9.09 5.11 7.38 3 4.79c-.37.63-.58 1.37-.58 2.15 0 1.49.75 2.81 1.91 3.56-.71 0-1.37-.2-1.95-.5v.03c0 2.08 1.48 3.82 3.44 4.21a4.22 4.22 0 0 1-1.93.07 4.28 4.28 0 0 0 4 2.98 8.521 8.521 0 0 1-5.33 1.84c-.34 0-.68-.02-1.02-.06C3.44 20.29 5.7 21 8.12 21 16 21 20.33 14.46 20.33 8.79c0-.19 0-.37-.01-.56.84-.6 1.56-1.36 2.14-2.23z"})})}),(0,s.jsx)("a",{href:"#",className:"text-gray-400 hover:text-primary transition-colors","aria-label":"GitHub",children:(0,s.jsx)("svg",{className:"w-5 h-5",fill:"currentColor",viewBox:"0 0 24 24",children:(0,s.jsx)("path",{d:"M12 2C6.477 2 2 6.484 2 12.017c0 4.425 2.865 8.18 6.839 9.504.5.092.682-.217.682-.483 0-.237-.008-.868-.013-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.029-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0 1 12 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.202 2.398.1 2.651.64.7 1.028 1.595 1.028 2.688 0 3.848-2.339 4.695-4.566 4.943.359.309.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.019 10.019 0 0 0 22 12.017C22 6.484 17.522 2 12 2z"})})})]})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("h4",{className:"font-semibold text-text-main mb-4",children:"Product"}),(0,s.jsx)("ul",{className:"flex flex-col gap-3 text-sm text-text-muted font-light",children:i.map(e=>(0,s.jsx)("li",{children:(0,s.jsx)(l(),{href:e.href,className:"hover:text-primary transition-colors",children:e.label})},e.label))})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("h4",{className:"font-semibold text-text-main mb-4",children:"Resources"}),(0,s.jsx)("ul",{className:"flex flex-col gap-3 text-sm text-text-muted font-light",children:o.map(e=>(0,s.jsx)("li",{children:(0,s.jsx)(l(),{href:e.href,className:"hover:text-primary transition-colors",children:e.label})},e.label))})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("h4",{className:"font-semibold text-text-main mb-4",children:"Company"}),(0,s.jsx)("ul",{className:"flex flex-col gap-3 text-sm text-text-muted font-light",children:d.map(e=>(0,s.jsx)("li",{children:(0,s.jsx)(l(),{href:e.href,className:"hover:text-primary transition-colors",children:e.label})},e.label))})]})]}),(0,s.jsxs)("div",{className:"border-t border-border pt-8 flex flex-col md:flex-row justify-between items-center gap-4",children:[(0,s.jsxs)("p",{className:"text-sm text-text-muted",children:["\xa9 ",new Date().getFullYear()," ",n.vQ.name," Inc. All rights reserved."]}),(0,s.jsxs)("div",{className:"flex gap-6 text-sm text-text-muted",children:[(0,s.jsx)(l(),{href:"#",className:"hover:text-primary transition-colors",children:"Privacy Policy"}),(0,s.jsx)(l(),{href:"#",className:"hover:text-primary transition-colors",children:"Terms of Service"})]})]})]})})}},92542:(e,t,r)=>{r.d(t,{default:()=>i});var s=r(95155),a=r(31474);let l={primary:"bg-brand-500 hover:bg-brand-600 text-white shadow-sm disabled:bg-surface-3 disabled:text-text-muted",secondary:"bg-surface-2 hover:bg-surface-3 text-text-main border border-border disabled:opacity-50",outline:"border border-border text-text-main hover:bg-surface-2 hover:border-brand-500/40",ghost:"text-text-muted hover:bg-surface-2 hover:text-text-main",danger:"bg-red-500 hover:bg-red-600 text-white shadow-sm disabled:bg-surface-3 disabled:text-text-muted",success:"bg-green-600 hover:bg-green-700 text-white shadow-sm disabled:bg-surface-3 disabled:text-text-muted"},n={sm:"h-10 px-3 text-xs rounded-[8px] sm:h-7",md:"h-11 px-4 text-sm rounded-[10px] sm:h-9",lg:"h-12 px-6 text-sm rounded-[10px] sm:h-11"};function i({children:e,variant:t="primary",size:r="md",icon:o,iconRight:d,disabled:c=!1,loading:m=!1,fullWidth:u=!1,className:x,...p}){return(0,s.jsxs)("button",{className:(0,a.cn)("inline-flex items-center justify-center gap-2 font-semibold transition-all duration-150 ease-out cursor-pointer","active:scale-[0.97] disabled:opacity-50 disabled:cursor-not-allowed disabled:active:scale-100",l[t],n[r],u&&"w-full",x),disabled:c||m,"aria-busy":m||void 0,...p,children:[m?(0,s.jsx)("span",{"aria-hidden":"true",className:"material-symbols-outlined animate-spin text-[18px]",children:"progress_activity"}):o?(0,s.jsx)("span",{"aria-hidden":"true",className:"material-symbols-outlined text-[18px]",children:o}):null,e,d&&!m&&(0,s.jsx)("span",{"aria-hidden":"true",className:"material-symbols-outlined text-[18px]",children:d})]})}},92622:(e,t,r)=>{r.d(t,{default:()=>S});var s=r(95155),a=r(12115),l=r(14051),n=r.n(l),i=r(98500),o=r.n(i),d=r(73321),c=r(31474),m=r(90620),u=r(52679),x=r(11059),p=r(92542),h=r(81127);let b=["embedding","image","tts","stt"],f="/dashboard/media-providers/web",g=[{href:"/dashboard/endpoint",label:"Endpoint",icon:"terminal"},{href:"/dashboard/providers",label:"Providers",icon:"dns"},{href:"/dashboard/playground",label:"Playground",icon:"forum"},{href:"/dashboard/usage",label:"Usage",icon:"bar_chart"},{href:"/dashboard/quota",label:"Quota Tracker",icon:"data_usage"}],j=[{href:"/dashboard/combos",label:"Combos",icon:"layers"},{href:"/dashboard/cli-tools",label:"CLI Tools",icon:"handyman"},{href:"/dashboard/mitm",label:"MITM",icon:"security"},{href:"/dashboard/automation",label:"Automation",icon:"automation"},{href:"/dashboard/token-saver",label:"Token Saver",icon:"savings"},{href:"/dashboard/terminal",label:"Terminal",icon:"terminal"}],v=[{href:"/dashboard/console-log",label:"Console Log",icon:"receipt_long"},{href:"/dashboard/translator",label:"Translator",icon:"translate"}],y=[{href:"/dashboard/proxy-pools",label:"Proxy Pools",icon:"lan"},{href:"/dashboard/context",label:"Context Inject",icon:"psychology"},{href:"/dashboard/skills",label:"Agent Skills",icon:"extension"}],N="group relative flex min-h-11 items-center gap-3 rounded-xl border border-transparent px-3 py-2 transition-all duration-200 lg:min-h-9 lg:py-1",k="border-primary/15 bg-linear-to-r from-primary/15 to-primary/5 text-primary shadow-[0_12px_26px_-22px_rgba(229,106,74,0.9)]",w="text-text-muted hover:border-border-subtle hover:bg-surface-2 hover:text-text-main";function C(e){return(0,c.cn)("material-symbols-outlined flex size-7 shrink-0 items-center justify-center rounded-lg text-[18px] transition-all duration-200",e?"fill-1 bg-primary text-white shadow-[0_7px_16px_-8px_rgba(229,106,74,0.9)]":"group-hover:bg-primary/10 group-hover:text-primary")}function S({onClose:e}){let t=(0,d.usePathname)(),r=j.some(e=>t===e.href||t.startsWith(`${e.href}/`)),[l,n]=(0,a.useState)(!1),[i,T]=(0,a.useState)(!0),[$,A]=(0,a.useState)(!1),[P,O]=(0,a.useState)(null),[R,E]=(0,a.useState)(!1),[_,z]=(0,a.useState)(!1),[L,M]=(0,a.useState)(0),[q,D]=(0,a.useState)(!1),{copied:U,copy:F}=(0,x.C)(2e3),W=(0,a.useRef)(null),B=m.h0.installCmdLatest;(0,a.useEffect)(()=>()=>{W.current&&(clearInterval(W.current),W.current=null)},[]),(0,a.useEffect)(()=>{let e=!1;return fetch("/api/settings").then(e=>e.json()).then(t=>{!e&&t.enableTranslator&&D(!0)}).catch(()=>{}),()=>{e=!0}},[]),(0,a.useEffect)(()=>{let e=!1;return fetch("/api/version",{cache:"no-store"}).then(e=>e.json()).then(t=>{e||(t?.hasUpdate?O(t):O(null))}).catch(()=>{}),()=>{e=!0}},[]),(0,a.useEffect)(()=>{r&&T(!0)},[r]);let K=e=>"/dashboard/endpoint"===e?"/dashboard"===t||t.startsWith("/dashboard/endpoint"):t.startsWith(e),V=async()=>{if(!await F(B))return;let e=m.h0.shutdownCountdownSec;M(e),W.current&&clearInterval(W.current),W.current=setInterval(()=>{M(e-=1),e<=0&&(clearInterval(W.current),W.current=null,fetch("/api/version/shutdown",{method:"POST"}).catch(()=>{}),A(!0))},1e3)};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("aside",{className:"relative flex min-h-full w-[min(18rem,86vw)] flex-col overflow-hidden border-r border-border-subtle bg-vibrancy shadow-[8px_0_30px_-28px_rgba(0,0,0,0.45)] backdrop-blur-xl transition-colors duration-300 after:pointer-events-none after:absolute after:inset-y-0 after:right-0 after:w-px after:bg-linear-to-b after:from-transparent after:via-primary/25 after:to-transparent lg:w-72",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2 px-6 pt-5 pb-2",children:[(0,s.jsx)("div",{className:"w-3 h-3 rounded-full bg-[#FF5F56]"}),(0,s.jsx)("div",{className:"w-3 h-3 rounded-full bg-[#FFBD2E]"}),(0,s.jsx)("div",{className:"w-3 h-3 rounded-full bg-[#27C93F]"})]}),(0,s.jsxs)("div",{className:"flex flex-col gap-2 border-b border-border-subtle/70 px-6 py-4",children:[(0,s.jsxs)(o(),{href:"/dashboard",className:"flex items-center gap-3",children:[(0,s.jsx)("div",{className:"flex items-center justify-center size-9 rounded-[10px] bg-gradient-to-br from-[#FF9A52] via-[#F56A2A] to-[#D94716] shadow-[var(--shadow-warm)] ring-1 ring-white/20",children:(0,s.jsx)("svg",{viewBox:"0 0 32 32",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"w-6 h-6",children:(0,s.jsx)("path",{d:"M9 10H23L9 22H23",stroke:"white",strokeWidth:"3.25",strokeLinecap:"round",strokeLinejoin:"round"})})}),(0,s.jsxs)("div",{className:"flex flex-col",children:[(0,s.jsx)("h1",{className:"text-lg font-semibold tracking-tight text-text-main",children:m.vQ.name}),(0,s.jsxs)("span",{className:"text-xs text-text-muted",children:["v",m.vQ.version]})]})]}),P&&(0,s.jsxs)("div",{className:"flex flex-col gap-1.5 rounded p-1 -m-1",children:[(0,s.jsxs)("span",{className:"text-xs font-semibold text-green-600 dark:text-amber-500",children:["↑ New version available: v",P.latestVersion]}),(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("button",{onClick:()=>E(!0),className:"px-2 py-1 rounded bg-green-600 hover:bg-green-700 dark:bg-amber-500 dark:hover:bg-amber-600 text-white text-[11px] font-semibold transition-colors cursor-pointer",children:"Update now"}),(0,s.jsx)("button",{onClick:()=>F(B),title:"Copy install command",className:"flex-1 text-left hover:opacity-80 transition-opacity cursor-pointer min-w-0",children:(0,s.jsx)("code",{className:"block text-[10px] text-green-600/80 dark:text-amber-400/70 font-mono truncate",children:U?"✓ copied!":B})})]})]})]}),(0,s.jsxs)("nav",{"aria-label":"Main navigation",className:"flex-1 px-4 py-2 space-y-0.5 overflow-y-auto custom-scrollbar",children:[(0,s.jsx)("p",{className:"px-3 pt-1 pb-1 text-[10px] font-semibold uppercase tracking-[0.14em] text-text-muted/55",children:"Core"}),g.map(t=>(0,s.jsxs)(o(),{href:t.href,onClick:e,"aria-current":K(t.href)?"page":void 0,className:(0,c.cn)(N,K(t.href)?k:w),children:[(0,s.jsx)("span",{className:C(K(t.href)),children:t.icon}),(0,s.jsx)("span",{className:"text-[13px] font-medium",children:t.label})]},t.href)),(0,s.jsxs)("div",{className:"pt-3 mt-1 space-y-0.5",children:[(0,s.jsxs)("button",{type:"button",onClick:()=>T(e=>!e),className:(0,c.cn)("group flex min-h-11 w-full items-center gap-2 rounded-xl px-3 py-2 transition-all lg:min-h-9 lg:py-1",r?"text-primary":"text-text-muted hover:bg-surface-2 hover:text-text-main"),"aria-expanded":i,children:[(0,s.jsx)("p",{className:"flex-1 text-left text-[10px] font-semibold uppercase tracking-[0.14em] text-text-muted/55",children:"Advanced"}),(0,s.jsx)("span",{className:"text-[10px] font-medium text-text-subtle tabular-nums",children:j.length}),(0,s.jsx)("span",{className:(0,c.cn)("material-symbols-outlined text-[14px] transition-transform",i&&"rotate-180"),children:"expand_more"})]}),i&&j.map(t=>(0,s.jsxs)(o(),{href:t.href,onClick:e,className:(0,c.cn)(N,K(t.href)?k:w),children:[(0,s.jsx)("span",{className:C(K(t.href)),children:t.icon}),(0,s.jsx)("span",{className:"text-[13px] font-medium",children:t.label})]},t.href))]}),(0,s.jsxs)("div",{className:"pt-3 mt-2 space-y-0.5",children:[(0,s.jsx)("p",{className:"px-3 text-[10px] font-semibold text-text-muted/55 uppercase tracking-[0.14em] mb-1",children:"System"}),(0,s.jsxs)("button",{type:"button",onClick:()=>n(e=>!e),className:(0,c.cn)(N,"w-full",t.startsWith("/dashboard/media-providers")?k:w),children:[(0,s.jsx)("span",{className:C(t.startsWith("/dashboard/media-providers")),children:"perm_media"}),(0,s.jsx)("span",{className:"text-[13px] font-medium flex-1 text-left",children:"Media Providers"}),(0,s.jsx)("span",{className:(0,c.cn)("material-symbols-outlined text-[14px] transition-transform",l&&"rotate-180"),children:"expand_more"})]}),l&&(0,s.jsxs)("div",{className:"pl-4",children:[u.rj.filter(e=>b.includes(e.id)).map(r=>(0,s.jsxs)(o(),{href:`/dashboard/media-providers/${r.id}`,onClick:e,className:(0,c.cn)(N,"px-4",t.startsWith(`/dashboard/media-providers/${r.id}`)?k:w),children:[(0,s.jsx)("span",{className:(0,c.cn)(C(t.startsWith(`/dashboard/media-providers/${r.id}`)),"text-[16px]"),children:r.icon}),(0,s.jsx)("span",{className:"text-sm",children:r.label})]},r.id)),(0,s.jsxs)(o(),{href:f,onClick:e,className:(0,c.cn)(N,"px-4",t.startsWith(f)?k:w),children:[(0,s.jsx)("span",{className:(0,c.cn)(C(t.startsWith(f)),"text-[16px]"),children:"travel_explore"}),(0,s.jsx)("span",{className:"text-sm",children:"Web Fetch & Search"})]},"web")]}),y.map(t=>(0,s.jsxs)(o(),{href:t.href,onClick:e,className:(0,c.cn)(N,K(t.href)?k:w),children:[(0,s.jsx)("span",{className:C(K(t.href)),children:t.icon}),(0,s.jsx)("span",{className:"text-[13px] font-medium",children:t.label})]},t.href)),v.map(t=>"/dashboard/translator"!==t.href||q?(0,s.jsxs)(o(),{href:t.href,onClick:e,className:(0,c.cn)(N,K(t.href)?k:w),children:[(0,s.jsx)("span",{className:C(K(t.href)),children:t.icon}),(0,s.jsx)("span",{className:"text-[13px] font-medium",children:t.label})]},t.href):null),(0,s.jsxs)(o(),{href:"/dashboard/profile",onClick:e,className:(0,c.cn)(N,K("/dashboard/profile")?k:w),children:[(0,s.jsx)("span",{className:C(K("/dashboard/profile")),children:"settings"}),(0,s.jsx)("span",{className:"text-[13px] font-medium",children:"Settings"})]})]})]})]}),(0,s.jsx)(h.ConfirmModal,{isOpen:R,onClose:()=>E(!1),onConfirm:()=>{E(!1),z(!0)},title:"Update ZevaiRouter",message:`Show install command for v${P?.latestVersion||""}? You can copy it and shutdown to install manually.`,confirmText:"Show Command",cancelText:"Cancel",variant:"primary"}),($||_)&&(0,s.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/80 backdrop-blur-sm p-6",children:_?(0,s.jsx)(I,{latestVersion:P?.latestVersion,installCmd:B,copied:U,onCopyAndShutdown:V,onCancel:()=>{W.current&&(clearInterval(W.current),W.current=null),z(!1),M(0)},countdown:L,isDisconnected:$}):(0,s.jsxs)("div",{className:"text-center p-8",children:[(0,s.jsx)("div",{className:"flex items-center justify-center size-16 rounded-full bg-red-500/20 text-red-500 mx-auto mb-4",children:(0,s.jsx)("span",{className:"material-symbols-outlined text-[32px]",children:"power_off"})}),(0,s.jsx)("h2",{className:"text-xl font-semibold text-white mb-2",children:"Server Disconnected"}),(0,s.jsx)("p",{className:"text-text-muted mb-6",children:"The proxy server has been stopped."}),(0,s.jsx)(p.default,{variant:"secondary",onClick:()=>globalThis.location.reload(),children:"Reload Page"})]})})]})}function I({latestVersion:e,installCmd:t,copied:r,onCopyAndShutdown:a,onCancel:l,countdown:n,isDisconnected:i}){let o=n>0;return(0,s.jsxs)("div",{className:"w-full max-w-lg rounded-xl bg-neutral-900/95 border border-white/10 p-6 text-white",children:[(0,s.jsxs)("div",{className:"flex items-center gap-3 mb-4",children:[(0,s.jsx)("div",{className:"flex items-center justify-center size-11 rounded-full bg-amber-500/20 text-amber-400",children:(0,s.jsx)("span",{className:"material-symbols-outlined text-[24px]",children:"content_copy"})}),(0,s.jsxs)("div",{children:[(0,s.jsxs)("h2",{className:"text-lg font-semibold",children:["Update ZevaiRouter",e?` to v${e}`:""]}),(0,s.jsx)("p",{className:"text-xs text-white/60",children:i?"Server stopped. Paste the command into a terminal to install.":o?`Command copied. Server will stop in ${n}s...`:"Click the button below to copy the install command and shutdown."})]})]}),(0,s.jsx)("p",{className:"text-sm text-white/80 mb-2",children:"Install command:"}),(0,s.jsx)("div",{className:"w-full px-3 py-2 rounded bg-white/5 mb-4",children:(0,s.jsx)("code",{className:"text-xs font-mono text-amber-400 break-all",children:t})}),(0,s.jsxs)("ol",{className:"text-xs text-white/70 space-y-1 list-decimal list-inside mb-4",children:[(0,s.jsxs)("li",{children:["Click ",(0,s.jsx)("strong",{children:"Copy & Shutdown"})," below."]}),(0,s.jsx)("li",{children:"Paste the command into your terminal and press Enter."}),(0,s.jsxs)("li",{children:["Run ",(0,s.jsx)("code",{className:"px-1 rounded bg-white/10 text-green-400",children:"zevai"})," again after install."]})]}),i?(0,s.jsx)(p.default,{variant:"secondary",fullWidth:!0,onClick:()=>globalThis.location.reload(),children:"Reload Page"}):(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(p.default,{variant:"secondary",onClick:l,disabled:o,children:"Cancel"}),(0,s.jsx)(p.default,{variant:"primary",fullWidth:!0,onClick:a,disabled:o,children:r?"✓ Copied — shutting down...":o?`Shutting down in ${n}s`:"Copy & Shutdown"})]})]})}S.propTypes={onClose:n().func},I.propTypes={latestVersion:n().string,installCmd:n().string.isRequired,copied:n().bool,onCopyAndShutdown:n().func.isRequired,onCancel:n().func.isRequired,countdown:n().number,isDisconnected:n().bool}},93308:(e,t,r)=>{r.d(t,{CL:()=>l,QC:()=>n,Xn:()=>a,YZ:()=>s});let s=["en","vi","zh-CN","zh-TW","ja","pt-BR","pt-PT","ko","es","de","fr","he","ar","ru","pl","cs","nl","tr","uk","tl","id","th","hi","bn","ur","ro","sv","it","el","hu","fi","da","no"],a="en",l="locale";function n(e){return"zh"===e||"zh-CN"===e?"zh-CN":"en"===e?"en":"vi"===e?"vi":"zh-TW"===e?"zh-TW":"ja"===e?"ja":"pt-BR"===e?"pt-BR":"pt-PT"===e?"pt-PT":"ko"===e?"ko":"es"===e?"es":"de"===e?"de":"fr"===e?"fr":"he"===e?"he":"ar"===e?"ar":"ru"===e?"ru":"pl"===e?"pl":"cs"===e?"cs":"nl"===e?"nl":"tr"===e?"tr":"uk"===e?"uk":"tl"===e?"tl":"id"===e?"id":"th"===e?"th":"hi"===e?"hi":"bn"===e?"bn":"ur"===e?"ur":"ro"===e?"ro":"sv"===e?"sv":"it"===e?"it":"el"===e?"el":"hu"===e?"hu":"fi"===e?"fi":"da"===e?"da":"no"===e?"no":a}},94230:(e,t,r)=>{r.d(t,{default:()=>d});var s=r(95155),a=r(12115),l=r(14051),n=r.n(l),i=r(35497),o=r(11059);function d({isOpen:e,provider:t,onSuccess:r,onClose:l}){let[n,c]=(0,a.useState)("loading"),[m,u]=(0,a.useState)(""),[x,p]=(0,a.useState)(null),[h,b]=(0,a.useState)(""),[f,g]=(0,a.useState)(null),{copied:j,copy:v}=(0,o.C)();(0,a.useEffect)(()=>{e&&t&&(async()=>{try{g(null),c("loading");let e=await fetch(`/api/oauth/kiro/social-authorize?provider=${t}`),r=await e.json();if(!e.ok)throw Error(r.error);p(r),u(r.authUrl),c("input"),window.open(r.authUrl,"_blank","noopener,noreferrer")}catch(e){g(e.message),c("error")}})()},[e,t]);let y=async()=>{try{let e;g(null);try{e=new URL(h)}catch(e){throw Error("Invalid callback URL format")}let s=e.searchParams.get("code");e.searchParams.get("state");let a=e.searchParams.get("error");if(a)throw Error(e.searchParams.get("error_description")||a);if(!s)throw Error("No authorization code found in URL");let l=await fetch("/api/oauth/kiro/social-exchange",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({code:s,codeVerifier:x.codeVerifier,provider:t})}),n=await l.json();if(!l.ok)throw Error(n.error);c("success"),r?.()}catch(e){g(e.message),c("error")}},N="google"===t?"Google":"GitHub";return(0,s.jsx)(i.aF,{isOpen:e,title:`Connect Kiro via ${N}`,onClose:l,size:"lg",children:(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:["loading"===n&&(0,s.jsxs)("div",{className:"text-center py-6",children:[(0,s.jsx)("div",{className:"size-16 mx-auto mb-4 rounded-full bg-primary/10 flex items-center justify-center",children:(0,s.jsx)("span",{className:"material-symbols-outlined text-3xl text-primary animate-spin",children:"progress_activity"})}),(0,s.jsx)("h3",{className:"text-lg font-semibold mb-2",children:"Initializing..."}),(0,s.jsxs)("p",{className:"text-sm text-text-muted",children:["Setting up ",N," authentication"]})]}),"input"===n&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:"space-y-4",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"text-sm font-medium mb-2",children:"Step 1: Open this URL in your browser"}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(i.pd,{value:m,readOnly:!0,className:"flex-1 font-mono text-xs"}),(0,s.jsx)(i.$n,{variant:"secondary",icon:"auth_url"===j?"check":"content_copy",onClick:()=>v(m,"auth_url"),children:"Copy"})]})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"text-sm font-medium mb-2",children:"Step 2: Paste the callback URL here"}),(0,s.jsx)("p",{className:"text-xs text-text-muted mb-2",children:"After authorization, copy the full URL from your browser address bar."}),(0,s.jsx)(i.pd,{value:h,onChange:e=>b(e.target.value),placeholder:"kiro://kiro.kiroAgent/authenticate-success?code=...",className:"font-mono text-xs"})]})]}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(i.$n,{onClick:y,fullWidth:!0,disabled:!h,children:"Connect"}),(0,s.jsx)(i.$n,{onClick:l,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]}),"success"===n&&(0,s.jsxs)("div",{className:"text-center py-6",children:[(0,s.jsx)("div",{className:"size-16 mx-auto mb-4 rounded-full bg-green-100 dark:bg-green-900/30 flex items-center justify-center",children:(0,s.jsx)("span",{className:"material-symbols-outlined text-3xl text-green-600",children:"check_circle"})}),(0,s.jsx)("h3",{className:"text-lg font-semibold mb-2",children:"Connected Successfully!"}),(0,s.jsxs)("p",{className:"text-sm text-text-muted mb-4",children:["Your Kiro account via ",N," has been connected."]}),(0,s.jsx)(i.$n,{onClick:l,fullWidth:!0,children:"Done"})]}),"error"===n&&(0,s.jsxs)("div",{className:"text-center py-6",children:[(0,s.jsx)("div",{className:"size-16 mx-auto mb-4 rounded-full bg-red-100 dark:bg-red-900/30 flex items-center justify-center",children:(0,s.jsx)("span",{className:"material-symbols-outlined text-3xl text-red-600",children:"error"})}),(0,s.jsx)("h3",{className:"text-lg font-semibold mb-2",children:"Connection Failed"}),(0,s.jsx)("p",{className:"text-sm text-red-600 mb-4",children:f}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(i.$n,{onClick:()=>c("input"),variant:"secondary",fullWidth:!0,children:"Try Again"}),(0,s.jsx)(i.$n,{onClick:l,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})]})})}d.propTypes={isOpen:n().bool.isRequired,provider:n().oneOf(["google","github"]).isRequired,onSuccess:n().func,onClose:n().func.isRequired}},95088:(e,t,r)=>{r.d(t,{default:()=>d});var s=r(95155),a=r(12115),l=r(14051),n=r.n(l),i=r(35497);let o="https://gitlab.com";function d({isOpen:e,providerInfo:t,onSuccess:r,onClose:l}){let n,[c,m]=(0,a.useState)(null),[u,x]=(0,a.useState)(o),[p,h]=(0,a.useState)(""),[b,f]=(0,a.useState)(""),[g,j]=(0,a.useState)(""),[v,y]=(0,a.useState)(!1),[N,k]=(0,a.useState)(null),[w,C]=(0,a.useState)(!1),[S,I]=(0,a.useState)(null),T=()=>{m(null),x(o),h(""),f(""),j(""),k(null),y(!1),C(!1),I(null),l()},$=async()=>{if(!g.trim())return void k("Personal Access Token is required");y(!0),k(null);try{let e=await fetch("/api/oauth/gitlab/pat",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({token:g.trim(),baseUrl:u.trim()||o})}),t=await e.json();if(!e.ok)throw Error(t.error||"Authentication failed");r?.(),T()}catch(e){k(e.message)}finally{y(!1)}};return e?w&&S?(0,s.jsx)(i.LF,{isOpen:!0,provider:"gitlab",providerInfo:t,oauthMeta:S,onSuccess:()=>{r?.(),T()},onClose:()=>{C(!1),I(null)}}):(0,s.jsx)(i.aF,{isOpen:e,title:"Connect GitLab Duo",onClose:T,size:"lg",children:(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:[!c&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("p",{className:"text-sm text-text-muted",children:"Choose how to authenticate with GitLab Duo:"}),(0,s.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,s.jsxs)("button",{onClick:()=>m("oauth"),className:"flex flex-col items-center gap-2 p-4 rounded-lg border border-border hover:border-primary hover:bg-primary/5 transition-colors text-left",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-2xl text-primary",children:"lock_open"}),(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"text-sm font-medium",children:"OAuth App"}),(0,s.jsx)("p",{className:"text-xs text-text-muted",children:"Use a GitLab OAuth application"})]})]}),(0,s.jsxs)("button",{onClick:()=>m("pat"),className:"flex flex-col items-center gap-2 p-4 rounded-lg border border-border hover:border-primary hover:bg-primary/5 transition-colors text-left",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-2xl text-primary",children:"key"}),(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"text-sm font-medium",children:"Personal Access Token"}),(0,s.jsx)("p",{className:"text-xs text-text-muted",children:"Use a GitLab PAT with api scope"})]})]})]})]}),"oauth"===c&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("p",{className:"text-xs text-text-muted",children:["Create an OAuth app at"," ",(0,s.jsx)("a",{href:`${u.trim()||o}/-/profile/applications`,target:"_blank",rel:"noreferrer",className:"text-primary underline",children:"GitLab Applications"})," ","with redirect URI"," ",(0,s.jsx)("code",{className:"bg-sidebar px-1 rounded text-xs",children:(n=window.location.port||("https:"===window.location.protocol?"443":"80"),`http://localhost:${n}/callback`)})]}),(0,s.jsx)(i.pd,{label:"GitLab Base URL",value:u,onChange:e=>x(e.target.value),placeholder:o}),(0,s.jsx)(i.pd,{label:"Client ID",value:p,onChange:e=>h(e.target.value),placeholder:"Your OAuth application client ID"}),(0,s.jsx)(i.pd,{label:"Client Secret (optional for PKCE)",value:b,onChange:e=>f(e.target.value),placeholder:"Leave empty for public PKCE app"}),N&&(0,s.jsx)("p",{className:"text-sm text-red-500",children:N}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(i.$n,{onClick:()=>{p.trim()?(k(null),I({baseUrl:u.trim()||o,clientId:p.trim(),clientSecret:b.trim()}),C(!0)):k("Client ID is required")},fullWidth:!0,disabled:!p.trim(),children:"Authorize"}),(0,s.jsx)(i.$n,{onClick:()=>{m(null),k(null)},variant:"ghost",fullWidth:!0,children:"Back"})]})]}),"pat"===c&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("p",{className:"text-xs text-text-muted",children:["Create a PAT at"," ",(0,s.jsx)("a",{href:`${u.trim()||o}/-/user_settings/personal_access_tokens`,target:"_blank",rel:"noreferrer",className:"text-primary underline",children:"GitLab Access Tokens"})," ","with scopes: ",(0,s.jsx)("code",{className:"bg-sidebar px-1 rounded text-xs",children:"api"}),","," ",(0,s.jsx)("code",{className:"bg-sidebar px-1 rounded text-xs",children:"read_user"}),", and"," ",(0,s.jsx)("code",{className:"bg-sidebar px-1 rounded text-xs",children:"ai_features"}),"."]}),(0,s.jsx)(i.pd,{label:"GitLab Base URL",value:u,onChange:e=>x(e.target.value),placeholder:o}),(0,s.jsx)(i.pd,{label:"Personal Access Token",value:g,onChange:e=>j(e.target.value),placeholder:"glpat-xxxxxxxxxxxxxxxxxxxx",type:"password"}),N&&(0,s.jsx)("p",{className:"text-sm text-red-500",children:N}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(i.$n,{onClick:$,fullWidth:!0,disabled:!g.trim()||v,loading:v,children:"Connect"}),(0,s.jsx)(i.$n,{onClick:()=>{m(null),k(null)},variant:"ghost",fullWidth:!0,children:"Back"})]})]})]})}):null}d.propTypes={isOpen:n().bool.isRequired,providerInfo:n().shape({name:n().string}),onSuccess:n().func,onClose:n().func.isRequired}},96371:(e,t,r)=>{r.d(t,{default:()=>et});var s=r(95155),a=r(12115),l=r(73321),n=r(52679),i=r(56061),o=r(84588),d=r(14051),c=r.n(d);let m=e=>new Intl.NumberFormat().format(e||0);function u({stats:e}){let t,r=e.totalCachedTokens||0,a=e.totalPromptTokens>0?Math.min(100,r/e.totalPromptTokens*100):0,l=[{label:"Requests",value:m(e.totalRequests),icon:"send",valueClass:"text-text-main",iconClass:"bg-primary/[0.08] text-primary",detail:"All routed calls"},{label:"Input Tokens",value:m(e.totalPromptTokens),icon:"input",valueClass:"text-primary",iconClass:"bg-primary/[0.08] text-primary",detail:"Prompt and context"},{label:"Cached Tokens",value:m(r),icon:"database",valueClass:"text-info",iconClass:"bg-info/[0.08] text-info",detail:r>0?`${a.toFixed(1)}% cache rate`:"No cache hits yet"},{label:"Output Tokens",value:m(e.totalCompletionTokens),icon:"output",valueClass:"text-success",iconClass:"bg-success/[0.08] text-success",detail:"Generated responses"},{label:"Est. Cost",value:`~${(t=e.totalCost,`$${(t||0).toFixed(2)}`)}`,icon:"payments",valueClass:"text-warning",iconClass:"bg-warning/[0.08] text-warning",detail:"Estimated, not billing",className:"col-span-2 sm:col-span-1"}];return(0,s.jsx)("div",{className:"grid min-w-0 grid-cols-2 gap-3 md:grid-cols-3 xl:grid-cols-5",children:l.map(e=>(0,s.jsxs)(o.default,{padding:"none",className:`relative flex min-h-[104px] min-w-0 flex-col overflow-hidden p-3.5 sm:min-h-[112px] sm:p-4 ${e.className||""}`,children:[(0,s.jsxs)("div",{className:"flex items-start justify-between gap-2",children:[(0,s.jsx)("span",{className:"pt-0.5 text-xs font-semibold text-text-muted",children:e.label}),(0,s.jsx)("span",{className:`material-symbols-outlined flex size-7 shrink-0 items-center justify-center rounded-md text-[16px] ${e.iconClass}`,children:e.icon})]}),(0,s.jsx)("span",{className:`mt-1 truncate text-[22px] font-semibold tracking-[-0.02em] sm:text-2xl ${e.valueClass}`,children:e.value}),(0,s.jsx)("span",{className:"mt-auto text-[11px] leading-[1.3] text-text-muted",children:e.detail})]},e.label))})}u.propTypes={stats:c().object.isRequired};let x=e=>new Intl.NumberFormat().format(e||0),p=e=>`$${(e||0).toFixed(2)}`;function h(e){if(!e)return"Never";let t=Math.floor((Date.now()-new Date(e))/6e4);return t<1?"Just now":t<60?`${t}m ago`:t<1440?`${Math.floor(t/60)}h ago`:new Date(e).toLocaleDateString()}function b({field:e,currentSort:t,currentOrder:r}){return t!==e?(0,s.jsx)("span",{className:"ml-1 opacity-20",children:"↕"}):(0,s.jsx)("span",{className:"ml-1",children:"asc"===r?"↑":"↓"})}function f({item:e,viewMode:t,isSummary:r=!1}){if("tokens"===t){let t=e.cachedTokens;return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("td",{className:"px-6 py-3 text-right text-text-muted",children:r&&void 0===e.promptTokens?"—":x(e.promptTokens)}),(0,s.jsx)("td",{className:"px-6 py-3 text-right text-info",children:null==t?"—":x(t)}),(0,s.jsx)("td",{className:"px-6 py-3 text-right text-text-muted",children:r&&void 0===e.completionTokens?"—":x(e.completionTokens)}),(0,s.jsx)("td",{className:"px-6 py-3 text-right font-medium",children:x(e.totalTokens)})]})}return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("td",{className:"px-6 py-3 text-right text-text-muted",children:r&&void 0===e.inputCost?"—":p(e.inputCost)}),(0,s.jsx)("td",{className:"px-6 py-3 text-right text-text-muted",children:r&&void 0===e.outputCost?"—":p(e.outputCost)}),(0,s.jsx)("td",{className:"px-6 py-3 text-right font-medium text-warning",children:p(e.totalCost||e.cost)})]})}function g({title:e,columns:t,groupedData:r,tableType:l,sortBy:n,sortOrder:i,onToggleSort:d,viewMode:c,storageKey:m,renderDetailCells:u,renderSummaryCells:x,emptyMessage:p}){let[h,j]=(0,a.useState)(new Set);(0,a.useEffect)(()=>{try{let e=localStorage.getItem(m);e&&j(new Set(JSON.parse(e)))}catch(e){console.error(`Failed to load ${m}:`,e)}},[m]),(0,a.useEffect)(()=>{try{localStorage.setItem(m,JSON.stringify([...h]))}catch(e){console.error(`Failed to save ${m}:`,e)}},[h,m]);let v=(0,a.useCallback)(e=>{j(t=>{let r=new Set(t);return r.has(e)?r.delete(e):r.add(e),r})},[]),y=(0,a.useMemo)(()=>"tokens"===c?[{field:"promptTokens",label:"Input Tokens"},{field:"cachedTokens",label:"Cached"},{field:"completionTokens",label:"Output Tokens"},{field:"totalTokens",label:"Total Tokens"}]:[{field:"promptTokens",label:"Input Cost"},{field:"completionTokens",label:"Output Cost"},{field:"cost",label:"Total Cost"}],[c]),N=t.length+y.length;return(0,s.jsxs)(o.default,{className:"overflow-hidden",children:[(0,s.jsx)("div",{className:"p-4 border-b border-border bg-bg-subtle/50",children:(0,s.jsx)("h3",{className:"font-semibold",children:e})}),(0,s.jsx)("div",{className:"overflow-x-auto",children:(0,s.jsxs)("table",{className:"w-full text-sm text-left",children:[(0,s.jsx)("thead",{className:"bg-bg-subtle/30 text-text-muted uppercase text-xs",children:(0,s.jsxs)("tr",{children:[t.map(e=>(0,s.jsxs)("th",{className:`px-6 py-3 cursor-pointer hover:bg-bg-subtle/50 ${"right"===e.align?"text-right":""}`,onClick:()=>d(l,e.field),onKeyDown:t=>{("Enter"===t.key||" "===t.key)&&(t.preventDefault(),d(l,e.field))},role:"button",tabIndex:0,"aria-sort":n===e.field?"asc"===i?"ascending":"descending":void 0,children:[e.label," ",(0,s.jsx)(b,{field:e.field,currentSort:n,currentOrder:i})]},e.field)),y.map(e=>(0,s.jsxs)("th",{className:"px-6 py-3 text-right cursor-pointer hover:bg-bg-subtle/50",onClick:()=>d(l,e.field),onKeyDown:t=>{("Enter"===t.key||" "===t.key)&&(t.preventDefault(),d(l,e.field))},role:"button",tabIndex:0,"aria-sort":n===e.field?"asc"===i?"ascending":"descending":void 0,children:[e.label," ",(0,s.jsx)(b,{field:e.field,currentSort:n,currentOrder:i})]},e.field))]})}),(0,s.jsxs)("tbody",{className:"divide-y divide-border",children:[r.map(e=>(0,s.jsxs)(a.Fragment,{children:[(0,s.jsxs)("tr",{className:"group-summary cursor-pointer hover:bg-bg-subtle/50 transition-colors",onClick:()=>v(e.groupKey),children:[(0,s.jsx)("td",{className:"px-6 py-3",children:(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("span",{className:`material-symbols-outlined text-[18px] text-text-muted transition-transform ${h.has(e.groupKey)?"rotate-90":""}`,children:"chevron_right"}),(0,s.jsx)("span",{className:`font-medium transition-colors ${e.summary.pending>0?"text-primary":""}`,children:e.groupKey})]})}),x(e),(0,s.jsx)(f,{item:e.summary,viewMode:c,isSummary:!0})]}),h.has(e.groupKey)&&e.items.map(e=>(0,s.jsxs)("tr",{className:"group-detail hover:bg-bg-subtle/20 transition-colors",children:[u(e),(0,s.jsx)(f,{item:e,viewMode:c})]},`detail-${e.key}`))]},e.groupKey)),0===r.length&&(0,s.jsx)("tr",{children:(0,s.jsx)("td",{colSpan:N,className:"px-6 py-8 text-center text-text-muted",children:p})})]})]})})]})}b.propTypes={field:c().string.isRequired,currentSort:c().string.isRequired,currentOrder:c().string.isRequired},f.propTypes={item:c().object.isRequired,viewMode:c().string.isRequired,isSummary:c().bool},g.propTypes={title:c().string.isRequired,columns:c().arrayOf(c().shape({field:c().string.isRequired,label:c().string.isRequired,align:c().string})).isRequired,groupedData:c().array.isRequired,tableType:c().string.isRequired,sortBy:c().string.isRequired,sortOrder:c().string.isRequired,onToggleSort:c().func.isRequired,viewMode:c().string.isRequired,storageKey:c().string.isRequired,renderDetailCells:c().func.isRequired,renderSummaryCells:c().func.isRequired,emptyMessage:c().string.isRequired};var j=r(6793),v=r(81750);r(53255);var y=r(57250);function N({id:e,sourceX:t,sourceY:r,targetX:a,targetY:l,sourcePosition:n,targetPosition:i,data:o,style:d,markerEnd:c}){let[m]=(0,j.Fp)({sourceX:t,sourceY:r,targetX:a,targetY:l,sourcePosition:n,targetPosition:i}),u=o?.state;if("active"!==u&&"error"!==u&&"last"!==u)return(0,s.jsx)(v.tE,{id:e,path:m,style:d,markerEnd:c});let x="error"===u?"#ef4444":"last"===u?"#f59e0b":"#4ade80",p="error"===u?"#fca5a5":"last"===u?"#fcd34d":"#22d3ee",h=`topo-turb-${e}`;return(0,s.jsxs)("g",{className:"topology-edge-kame",children:[(0,s.jsx)("defs",{children:(0,s.jsxs)("filter",{id:h,x:"-30%",y:"-30%",width:"160%",height:"160%",children:[(0,s.jsx)("feTurbulence",{type:"fractalNoise",baseFrequency:"0.9",numOctaves:"2",seed:"2",result:"noise",children:(0,s.jsx)("animate",{attributeName:"baseFrequency",values:"0.8;1.4;0.8",dur:"0.25s",repeatCount:"indefinite"})}),(0,s.jsx)("feDisplacementMap",{in:"SourceGraphic",in2:"noise",scale:"3.5",xChannelSelector:"R",yChannelSelector:"G"})]})}),(0,s.jsx)("path",{d:m,fill:"none",stroke:p,strokeWidth:"10",strokeLinecap:"round",opacity:"0.25",filter:`url(#${h})`,className:"topology-edge-halo"}),(0,s.jsx)("path",{d:m,fill:"none",stroke:x,strokeWidth:"5",strokeLinecap:"round",opacity:"0.7",filter:`url(#${h})`,className:"topology-edge-plasma"}),(0,s.jsx)(v.tE,{id:e,path:m,style:{...d,stroke:"#f8fafc",strokeWidth:2.2,opacity:.95},markerEnd:c}),Array.from({length:5},(e,t)=>(0,s.jsx)("circle",{r:2.4-.25*t,fill:t%2==0?"#ffffff":p,children:(0,s.jsx)("animateMotion",{dur:`${.4+.08*t}s`,repeatCount:"indefinite",path:m,begin:`${.09*t}s`})},`p${t}`)),Array.from({length:3},(e,t)=>(0,s.jsxs)("circle",{r:"1.6",fill:x,children:[(0,s.jsx)("animate",{attributeName:"opacity",values:"0;1;0",dur:`${.6+.2*t}s`,repeatCount:"indefinite",begin:`${.2*t}s`}),(0,s.jsx)("animateMotion",{dur:`${1.1+.3*t}s`,repeatCount:"indefinite",path:m,begin:`${.25*t}s`})]},`s${t}`))]})}N.propTypes={id:c().string.isRequired,sourceX:c().number.isRequired,sourceY:c().number.isRequired,targetX:c().number.isRequired,targetY:c().number.isRequired,sourcePosition:c().string,targetPosition:c().string,data:c().object,style:c().object,markerEnd:c().string};let k={padding:.14,duration:200};function w(e){return n.Q2[e]||{color:"#6b7280",name:e}}function C(e){return`/providers/${e}.png`}function S({data:e}){let{label:t,color:r,imageUrl:a,textIcon:l,active:n}=e;return(0,s.jsxs)("div",{className:"flex items-center gap-2 rounded-lg border bg-surface px-3 py-2 transition-all duration-300",style:{borderColor:n?r:"var(--color-border)",boxShadow:n?`0 0 12px ${r}30`:"none",minWidth:"140px"},children:[(0,s.jsx)(v.h7,{type:"target",position:j.yX.Top,id:"top",className:"!bg-transparent !border-0 !w-0 !h-0"}),(0,s.jsx)(v.h7,{type:"target",position:j.yX.Bottom,id:"bottom",className:"!bg-transparent !border-0 !w-0 !h-0"}),(0,s.jsx)(v.h7,{type:"target",position:j.yX.Left,id:"left",className:"!bg-transparent !border-0 !w-0 !h-0"}),(0,s.jsx)(v.h7,{type:"target",position:j.yX.Right,id:"right",className:"!bg-transparent !border-0 !w-0 !h-0"}),(0,s.jsx)("div",{className:"flex size-7 shrink-0 items-center justify-center rounded-md",style:{backgroundColor:`${r}15`},children:(0,s.jsx)(y.A,{src:a,alt:t,size:20,className:"size-5 rounded-sm object-contain",fallbackText:l,fallbackColor:r})}),(0,s.jsx)("span",{className:"truncate text-sm font-medium",style:{color:n?r:"var(--color-text)"},children:t}),n&&(0,s.jsxs)("span",{className:"relative flex h-2 w-2 shrink-0",children:[(0,s.jsx)("span",{className:"animate-ping absolute inline-flex h-full w-full rounded-full opacity-75",style:{backgroundColor:r}}),(0,s.jsx)("span",{className:"relative inline-flex rounded-full h-2 w-2",style:{backgroundColor:r}})]})]})}function I({data:e}){return(0,s.jsxs)("div",{className:"flex min-w-[118px] items-center justify-center rounded-lg border border-primary bg-primary/[0.06] px-4 py-2.5 shadow-sm",children:[(0,s.jsx)(v.h7,{type:"source",position:j.yX.Top,id:"top",className:"!bg-transparent !border-0 !w-0 !h-0"}),(0,s.jsx)(v.h7,{type:"source",position:j.yX.Bottom,id:"bottom",className:"!bg-transparent !border-0 !w-0 !h-0"}),(0,s.jsx)(v.h7,{type:"source",position:j.yX.Left,id:"left",className:"!bg-transparent !border-0 !w-0 !h-0"}),(0,s.jsx)(v.h7,{type:"source",position:j.yX.Right,id:"right",className:"!bg-transparent !border-0 !w-0 !h-0"}),(0,s.jsx)("img",{src:"/favicon.svg",alt:"ZevaiRouter",className:"mr-2 size-5"}),(0,s.jsx)("span",{className:"text-xs font-semibold text-primary",children:"ZevaiRouter"}),e.activeCount>0&&(0,s.jsx)("span",{className:"ml-2 rounded-full bg-primary px-1.5 py-0.5 text-[10px] font-semibold text-white",children:e.activeCount})]})}S.propTypes={data:c().object.isRequired},I.propTypes={data:c().object.isRequired};let T={provider:S,router:I},$={topology:N};function A({provider:e,status:t}){let r=w(e.provider),a=(r.name!==e.provider?r.name:null)||e.name||e.provider,l={active:{label:"Live traffic",color:"text-success",dot:"bg-success"},error:{label:"Last request failed",color:"text-error",dot:"bg-error"},last:{label:"Last route",color:"text-warning",dot:"bg-warning"},available:{label:"Available",color:"text-text-muted",dot:"bg-text-subtle"}}[t];return(0,s.jsxs)("div",{className:"flex min-h-14 items-center gap-3 rounded-xl border border-border-subtle bg-surface px-3 py-2.5",children:[(0,s.jsx)("div",{className:"flex size-9 shrink-0 items-center justify-center rounded-lg ring-1 ring-black/[0.04] dark:ring-white/[0.06]",style:{backgroundColor:`${r.color||"#6b7280"}15`},children:(0,s.jsx)(y.A,{src:C(e.provider),alt:"",size:26,className:"max-h-[26px] max-w-[26px] rounded-md object-contain",fallbackText:r.textIcon||(e.provider||"?").slice(0,2).toUpperCase(),fallbackColor:r.color})}),(0,s.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,s.jsx)("p",{className:"truncate text-sm font-semibold text-text-main",children:a}),(0,s.jsxs)("p",{className:`mt-0.5 flex items-center gap-1.5 text-[11px] font-medium ${l.color}`,children:[(0,s.jsx)("span",{className:`size-1.5 shrink-0 rounded-full ${l.dot} ${"active"===t?"animate-pulse":""}`}),l.label]})]}),(0,s.jsx)("span",{"aria-hidden":"true",className:"material-symbols-outlined text-[18px] text-text-subtle",children:"arrow_forward"})]})}function P({providers:e=[],activeRequests:t=[],lastProvider:r="",errorProvider:l=""}){let n=(0,a.useMemo)(()=>t.map(e=>e.provider?.toLowerCase()).filter(Boolean).sort().join(","),[t]),i=r?.toLowerCase()||"",o=l?.toLowerCase()||"",d=(0,a.useMemo)(()=>new Set(n?n.split(","):[]),[n]),c=(0,a.useMemo)(()=>new Set(i?[i]:[]),[i]),m=(0,a.useMemo)(()=>new Set(o?[o]:[]),[o]),u=(0,a.useRef)({}),[x,p]=(0,a.useState)(0),[h,b]=(0,a.useState)(!1),[f,g]=(0,a.useState)(!1);(0,a.useEffect)(()=>{let e=window.matchMedia("(min-width: 640px)"),t=()=>b(e.matches);return t(),e.addEventListener("change",t),()=>e.removeEventListener("change",t)},[]),(0,a.useEffect)(()=>{let e=u.current,t=Date.now();for(let r of d)e[r]||(e[r]=t);for(let t of Object.keys(e))d.has(t)||delete e[t]},[d]),(0,a.useEffect)(()=>{if(0===d.size)return;let e=setInterval(()=>p(e=>e+1),1e3);return()=>clearInterval(e)},[d]);let j=(0,a.useMemo)(()=>{let e=Date.now(),t=new Set;for(let r of d){let s=u.current[r];(!s||e-s<6e4)&&t.add(r)}return t},[d,x]),{nodes:y,edges:N}=(0,a.useMemo)(()=>(function(e,t,r,s){let a=e.length,l=Math.max(270,180*a/(2*Math.PI)),n=Math.max(150,.52*l);if(0===a)return{nodes:[{id:"router",type:"router",position:{x:0,y:0},data:{activeCount:0},draggable:!1}],edges:[]};let i=[],o=[];return i.push({id:"router",type:"router",position:{x:-59,y:-20},data:{activeCount:t.size},draggable:!1}),e.forEach((e,d)=>{let c,m,u=w(e.provider),x=t.has(e.provider?.toLowerCase()),p=!x&&r.has(e.provider?.toLowerCase()),h=!x&&s.has(e.provider?.toLowerCase()),b=`provider-${e.provider}`,f={label:(u.name!==e.provider?u.name:null)||e.name||e.provider,color:u.color||"#6b7280",imageUrl:C(e.provider),textIcon:u.textIcon||(e.provider||"?").slice(0,2).toUpperCase(),active:x},g=-Math.PI/2+2*Math.PI*d/a,j=l*Math.cos(g),v=n*Math.sin(g);Math.abs(g+Math.PI/2)<Math.PI/4||Math.abs(g-3*Math.PI/2)<Math.PI/4?(c="top",m="bottom"):Math.abs(g-Math.PI/2)<Math.PI/4?(c="bottom",m="top"):j>0?(c="right",m="left"):(c="left",m="right"),i.push({id:b,type:"provider",position:{x:j-80,y:v-22},data:f,draggable:!1});o.push({id:`e-${b}`,type:"topology",source:"router",sourceHandle:c,target:b,targetHandle:m,data:{state:h?"error":x?"active":p?"last":"idle"},style:(u.color,h?{stroke:"#ef4444",strokeWidth:2.5,opacity:.9}:x?{stroke:"#4ade80",strokeWidth:2.5,opacity:.9}:p?{stroke:"#f59e0b",strokeWidth:2,opacity:.7}:{stroke:"var(--color-border)",strokeWidth:1,opacity:.3})})}),{nodes:i,edges:o}})(e,j,c,m),[e,j,c,m]),S=(0,a.useMemo)(()=>{let t={active:0,error:1,last:2,available:3};return e.map(e=>{let t=e.provider?.toLowerCase();return{provider:e,status:j.has(t)?"active":m.has(t)?"error":c.has(t)?"last":"available"}}).sort((e,r)=>{let s=t[e.status]-t[r.status];if(0!==s)return s;let a=w(e.provider.provider).name||e.provider.name||e.provider.provider,l=w(r.provider.provider).name||r.provider.name||r.provider.provider;return a.localeCompare(l)})},[e,j,m,c]),I=f?S:S.slice(0,6),O=(0,a.useMemo)(()=>e.map(e=>e.provider).sort().join(","),[e]),R=(0,a.useRef)(null),E=(0,a.useRef)(null),_=(0,a.useCallback)(e=>{R.current=e,setTimeout(()=>e.fitView(k),50)},[]);return(0,a.useEffect)(()=>{let e=E.current;if(!e)return;let t=new ResizeObserver(()=>{R.current&&R.current.fitView(k)});return t.observe(e),()=>t.disconnect()},[h]),(0,a.useEffect)(()=>{if(R.current){let e=setTimeout(()=>R.current.fitView(k),50);return()=>clearTimeout(e)}},[y.length]),(0,s.jsxs)("div",{ref:h?E:void 0,className:"flex w-full min-w-0 flex-col overflow-hidden rounded-[14px] border border-border-subtle bg-surface/94 shadow-[0_14px_34px_-26px_rgba(15,23,42,0.28)] sm:h-[440px]",children:[(0,s.jsxs)("div",{className:"flex shrink-0 items-center justify-between border-b border-border-subtle bg-surface/75 px-4 py-3.5",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-[17px] text-primary",children:"route"}),(0,s.jsx)("span",{className:"text-xs font-semibold text-text-main",children:"Routing map"})]}),(0,s.jsxs)("span",{className:"text-[11px] font-medium text-text-muted",children:[e.length," ",1===e.length?"provider":"providers"]})]}),(0,s.jsx)("div",{className:"min-h-0 flex-1 bg-bg/35",children:0===e.length?(0,s.jsx)("div",{className:"flex min-h-56 items-center justify-center text-sm text-text-muted sm:h-full sm:min-h-0",children:"No providers connected"}):h?(0,s.jsx)(v.Gc,{nodes:y,edges:N,nodeTypes:T,edgeTypes:$,fitView:!0,fitViewOptions:k,minZoom:.1,maxZoom:2,onInit:_,proOptions:{hideAttribution:!0},panOnDrag:!0,zoomOnScroll:!0,zoomOnPinch:!0,zoomOnDoubleClick:!0,preventScrolling:!1,nodesDraggable:!1,nodesConnectable:!1,elementsSelectable:!1,children:(0,s.jsx)(v.H2,{showInteractive:!1,className:"react-flow-controls-custom"})},O):(0,s.jsxs)("div",{className:"p-3",children:[(0,s.jsxs)("div",{className:"mb-3 flex items-center gap-3 rounded-xl border border-primary/20 bg-primary/[0.06] px-3 py-3",children:[(0,s.jsx)("span",{className:"flex size-10 shrink-0 items-center justify-center rounded-xl bg-primary/10 ring-1 ring-primary/15",children:(0,s.jsx)("img",{src:"/favicon.svg",alt:"",className:"size-6"})}),(0,s.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,s.jsx)("p",{className:"text-sm font-semibold text-primary",children:"ZevaiRouter"}),(0,s.jsx)("p",{className:"mt-0.5 text-[11px] text-text-muted",children:"Routes requests to healthy providers"})]}),j.size>0&&(0,s.jsxs)("span",{className:"rounded-full bg-success/10 px-2 py-1 text-[10px] font-semibold text-success",children:[j.size," live"]})]}),(0,s.jsx)("div",{className:"ml-7 h-3 w-px bg-border","aria-hidden":"true"}),(0,s.jsx)("div",{className:"space-y-2",children:I.map(({provider:e,status:t})=>(0,s.jsx)(A,{provider:e,status:t},e.provider))}),S.length>6&&(0,s.jsxs)("button",{type:"button",onClick:()=>g(e=>!e),className:"mt-3 flex h-11 w-full items-center justify-center gap-1.5 rounded-xl border border-border bg-surface text-xs font-medium text-text-main transition-colors hover:border-primary/30 hover:text-primary","aria-expanded":f,children:[f?"Show fewer providers":`Show ${S.length-6} more providers`,(0,s.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:f?"expand_less":"expand_more"})]})]})})]})}A.propTypes={provider:c().shape({provider:c().string.isRequired,name:c().string}).isRequired,status:c().oneOf(["active","error","last","available"]).isRequired},P.propTypes={providers:c().arrayOf(c().shape({id:c().string,provider:c().string,name:c().string})),activeRequests:c().arrayOf(c().shape({provider:c().string,model:c().string,account:c().string})),lastProvider:c().string,errorProvider:c().string};var O=r(21742),R=r(63346),E=r(28408),_=r(32539),z=r(59656),L=r(55433),M=r(40968);let q=e=>e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:String(e||0),D=e=>`$${(e||0).toFixed(4)}`,U={today:"Today","24h":"Last 24 hours","7d":"Last 7 days","30d":"Last 30 days","60d":"Last 60 days"};function F({period:e="7d"}){let[t,r]=(0,a.useState)([]),[l,n]=(0,a.useState)(!0),[i,d]=(0,a.useState)(null),[c,m]=(0,a.useState)("tokens"),u=(0,a.useRef)({sequence:0,controller:null}),x=(0,a.useCallback)(async()=>{u.current.controller?.abort();let t=new AbortController,s=u.current.sequence+1;u.current={sequence:s,controller:t},n(!0),d(null);try{let a=await fetch(`/api/usage/chart?period=${e}`,{signal:t.signal});if(s!==u.current.sequence)return;if(!a.ok)throw Error(`HTTP ${a.status}`);let l=await a.json();r(l)}catch(e){if(e?.name==="AbortError"||s!==u.current.sequence)return;console.error("Failed to fetch chart data:",e),d("Failed to load chart data")}finally{s===u.current.sequence&&n(!1)}},[e]);(0,a.useEffect)(()=>(x(),()=>{u.current.controller?.abort(),u.current.sequence+=1}),[x]);let p=t.some(e=>e.tokens>0||e.cost>0);return(0,s.jsxs)(o.default,{className:"flex min-w-0 flex-col gap-5 p-4 sm:p-5",children:[(0,s.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"text-sm font-semibold text-text-main",children:"Usage trend"}),(0,s.jsxs)("p",{className:"mt-0.5 text-[11px] text-text-muted",children:[U[e]||e," \xb7 routed traffic over time"]})]}),(0,s.jsxs)("div",{className:"grid w-full grid-cols-2 items-center gap-1 rounded-lg border border-border bg-bg-subtle p-1 sm:w-auto",children:[(0,s.jsx)("button",{type:"button",onClick:()=>m("tokens"),className:`rounded-md px-3 py-1 text-sm font-medium transition-colors ${"tokens"===c?"bg-primary text-white shadow-sm":"text-text-muted hover:bg-bg-hover hover:text-text"}`,children:"Tokens"}),(0,s.jsx)("button",{type:"button",onClick:()=>m("cost"),className:`rounded-md px-3 py-1 text-sm font-medium transition-colors ${"cost"===c?"bg-primary text-white shadow-sm":"text-text-muted hover:bg-bg-hover hover:text-text"}`,children:"Cost"})]})]}),l?(0,s.jsx)("div",{className:"h-48 flex items-center justify-center text-text-muted text-sm",children:"Loading..."}):i?(0,s.jsxs)("div",{className:"h-48 flex flex-col items-center justify-center gap-2 text-text-muted text-sm",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-[24px] text-red-500",children:"error"}),(0,s.jsx)("p",{children:i}),(0,s.jsx)("button",{type:"button",onClick:x,className:"rounded-lg border border-border px-3 py-1 text-xs font-medium text-text-main transition-colors hover:bg-bg-hover",children:"Retry"})]}):p?(0,s.jsx)(O.u,{width:"100%",height:220,children:(0,s.jsxs)(R.Q,{data:t,margin:{top:4,right:8,left:0,bottom:0},children:[(0,s.jsxs)("defs",{children:[(0,s.jsxs)("linearGradient",{id:"gradTokens",x1:"0",y1:"0",x2:"0",y2:"1",children:[(0,s.jsx)("stop",{offset:"5%",stopColor:"#6366f1",stopOpacity:.25}),(0,s.jsx)("stop",{offset:"95%",stopColor:"#6366f1",stopOpacity:0})]}),(0,s.jsxs)("linearGradient",{id:"gradCost",x1:"0",y1:"0",x2:"0",y2:"1",children:[(0,s.jsx)("stop",{offset:"5%",stopColor:"#f59e0b",stopOpacity:.25}),(0,s.jsx)("stop",{offset:"95%",stopColor:"#f59e0b",stopOpacity:0})]})]}),(0,s.jsx)(E.d,{strokeDasharray:"3 3",strokeOpacity:.1}),(0,s.jsx)(_.W,{dataKey:"label",tick:{fontSize:10,fill:"currentColor",fillOpacity:.5},tickLine:!1,axisLine:!1,interval:"preserveStartEnd"}),(0,s.jsx)(z.h,{tick:{fontSize:10,fill:"currentColor",fillOpacity:.5},tickLine:!1,axisLine:!1,tickFormatter:"tokens"===c?q:D,width:50}),(0,s.jsx)(L.m,{contentStyle:{backgroundColor:"var(--color-bg)",border:"1px solid var(--color-border)",borderRadius:"8px",fontSize:"12px"},formatter:(e,t)=>"tokens"===t?[q(e),"Tokens"]:[D(e),"Cost"]}),"tokens"===c?(0,s.jsx)(M.Gk,{type:"monotone",dataKey:"tokens",stroke:"#6366f1",strokeWidth:2,fill:"url(#gradTokens)",dot:!1,activeDot:{r:4}}):(0,s.jsx)(M.Gk,{type:"monotone",dataKey:"cost",stroke:"#f59e0b",strokeWidth:2,fill:"url(#gradCost)",dot:!1,activeDot:{r:4}})]})}):(0,s.jsx)("div",{className:"h-48 flex items-center justify-center text-text-muted text-sm",children:"No data for this period"})]})}function W(e){let t=n.Q2[e];return!t?.serviceKinds||t.serviceKinds.includes("llm")}function B({timestamp:e}){let t,[,r]=(0,a.useState)(0);return(0,a.useEffect)(()=>{let e=setInterval(()=>r(e=>e+1),1e3);return()=>clearInterval(e)},[]),(0,s.jsx)("time",{dateTime:e,title:new Date(e).toLocaleString(),children:(t=Math.max(0,Math.floor((Date.now()-new Date(e))/1e3)))<60?`${t}s ago`:t<3600?`${Math.floor(t/60)}m ago`:t<86400?`${Math.floor(t/3600)}h ago`:`${Math.floor(t/86400)}d ago`})}F.propTypes={period:c().string};let K={live:{label:"Live",title:"Usage stream connected",className:"bg-success/10 text-success",dotClassName:"bg-success animate-pulse"},reconnecting:{label:"Reconnecting",title:"Usage stream disconnected; reconnecting automatically",className:"bg-warning/10 text-warning",dotClassName:"bg-warning animate-pulse"},connecting:{label:"Connecting",title:"Connecting to the live usage stream",className:"bg-primary/10 text-primary",dotClassName:"bg-primary animate-pulse"}};function V({requests:e=[],streamStatus:t="connecting"}){let r=K[t]||K.connecting;return(0,s.jsxs)(o.default,{className:"flex h-[420px] min-w-0 flex-col overflow-hidden sm:h-[440px]",padding:"none",children:[(0,s.jsxs)("div",{className:"flex shrink-0 items-center justify-between border-b border-border-subtle bg-surface/75 px-4 py-3.5",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-[17px] text-primary",children:"monitor_heart"}),(0,s.jsx)("span",{className:"text-xs font-semibold text-text-main",children:"Recent requests"})]}),(0,s.jsxs)("span",{className:`inline-flex items-center gap-1.5 rounded-full px-2 py-1 text-[10px] font-semibold ${r.className}`,title:r.title,children:[(0,s.jsx)("span",{"aria-hidden":"true",className:`size-1.5 rounded-full ${r.dotClassName}`}),r.label]})]}),e.length?(0,s.jsx)("div",{className:"flex-1 overflow-x-auto overflow-y-auto px-4 pb-3",children:(0,s.jsxs)("table",{className:"w-full min-w-[300px] border-collapse text-xs",children:[(0,s.jsx)("thead",{className:"sticky top-0 z-10 bg-surface/95 backdrop-blur-sm",children:(0,s.jsxs)("tr",{className:"border-b border-border",children:[(0,s.jsx)("th",{className:"w-2 py-1.5 text-left font-semibold text-text-muted",children:(0,s.jsx)("span",{className:"sr-only",children:"Status"})}),(0,s.jsx)("th",{className:"py-1.5 text-left font-semibold text-text-muted",children:"Model"}),(0,s.jsx)("th",{className:"py-1.5 text-right font-semibold text-text-muted whitespace-nowrap",children:"In / Out"}),(0,s.jsx)("th",{className:"py-1.5 text-right font-semibold text-text-muted",children:"When"})]})}),(0,s.jsx)("tbody",{className:"divide-y divide-border/50",children:e.map((e,t)=>{let r=function(e){if(!e)return!0;let t=String(e).trim().toLowerCase();return"ok"===t||"success"===t||"succeeded"===t||/^2\d\d(?:\s|$)/.test(t)}(e.status),a=r?"Succeeded":"Failed",l=n.Q2[e.provider]?.name||n.IS[e.provider]?.name||e.provider||"Unknown provider";return(0,s.jsxs)("tr",{className:"transition-colors hover:bg-bg-subtle",children:[(0,s.jsx)("td",{className:"py-1.5",title:a,children:(0,s.jsx)("span",{role:"img","aria-label":a,className:`block size-1.5 rounded-full ${r?"bg-success":"bg-error"}`})}),(0,s.jsxs)("td",{className:"min-w-0 py-1.5 pr-2",children:[(0,s.jsx)("div",{className:"max-w-[132px] truncate font-mono",title:e.model,children:e.model}),(0,s.jsx)("div",{className:"mt-0.5 max-w-[132px] truncate text-[10px] font-medium text-text-subtle",title:l,children:l})]}),(0,s.jsxs)("td",{className:"py-1.5 text-right font-mono tabular-nums whitespace-nowrap",children:[(0,s.jsxs)("span",{className:"text-primary",children:[x(e.promptTokens),"↑"]})," ",(0,s.jsxs)("span",{className:"text-success",children:[x(e.completionTokens),"↓"]})]}),(0,s.jsx)("td",{className:"py-1.5 text-right text-text-muted whitespace-nowrap",children:(0,s.jsx)(B,{timestamp:e.timestamp})})]},`${e.timestamp}-${e.model}-${e.provider}-${e.promptTokens}-${e.completionTokens}-${t}`)})})]})}):(0,s.jsx)("div",{className:"flex-1 flex items-center justify-center text-text-muted text-sm",children:"No requests yet."})]})}function J(e,t={},r,s){return Object.entries(e||{}).map(([e,r])=>{let s=(r.promptTokens||0)+(r.completionTokens||0),a=r.cost||0,l=s>0?(r.promptTokens||0)*(a/s):0,n=s>0?(r.completionTokens||0)*(a/s):0;return{...r,key:e,totalTokens:s,totalCost:a,inputCost:l,outputCost:n,pending:t[e]||0}}).sort((e,t)=>{let a=e[r],l=t[r];return("string"==typeof a&&(a=a.toLowerCase()),"string"==typeof l&&(l=l.toLowerCase()),a<l)?"asc"===s?-1:1:a>l?"asc"===s?1:-1:0})}function G(e,t){if(!Array.isArray(e))return[];let r={};return e.forEach(e=>{let s=function(e,t){switch(t){case"rawModel":return e.rawModel||"Unknown Model";case"accountName":return e.accountName||(e.connectionId?`Account ${e.connectionId.slice(0,8)}...`:"Unknown Account");case"keyName":return e.keyName||"Unknown Key";case"endpoint":return e.endpoint||"Unknown Endpoint";default:return e[t]||"Unknown"}}(e,t);r[s]||(r[s]={groupKey:s,summary:{requests:0,promptTokens:0,completionTokens:0,cachedTokens:0,totalTokens:0,cost:0,inputCost:0,outputCost:0,lastUsed:null,pending:0},items:[]});let a=r[s].summary;a.requests+=e.requests||0,a.promptTokens+=e.promptTokens||0,a.completionTokens+=e.completionTokens||0,a.cachedTokens+=e.cachedTokens||0,a.totalTokens+=e.totalTokens||0,a.cost+=e.cost||0,a.inputCost+=e.inputCost||0,a.outputCost+=e.outputCost||0,a.pending+=e.pending||0,e.lastUsed&&(!a.lastUsed||new Date(e.lastUsed)>new Date(a.lastUsed))&&(a.lastUsed=e.lastUsed),r[s].items.push(e)}),Object.values(r)}let H=[{field:"rawModel",label:"Model"},{field:"provider",label:"Provider"},{field:"requests",label:"Requests",align:"right"},{field:"lastUsed",label:"Last Used",align:"right"}],Q=[{field:"accountName",label:"Account"},{field:"rawModel",label:"Model"},{field:"provider",label:"Provider"},{field:"requests",label:"Requests",align:"right"},{field:"lastUsed",label:"Last Used",align:"right"}],X=[{field:"keyName",label:"API Key Name"},{field:"rawModel",label:"Model"},{field:"provider",label:"Provider"},{field:"requests",label:"Requests",align:"right"},{field:"lastUsed",label:"Last Used",align:"right"}],Z=[{field:"endpoint",label:"Endpoint"},{field:"rawModel",label:"Model"},{field:"provider",label:"Provider"},{field:"requests",label:"Requests",align:"right"},{field:"lastUsed",label:"Last Used",align:"right"}],Y=[{value:"model",label:"Usage by Model"},{value:"account",label:"Usage by Account"},{value:"apiKey",label:"Usage by API Key"},{value:"endpoint",label:"Usage by Endpoint"}],ee=[{value:"today",label:"Today"},{value:"24h",label:"24h"},{value:"7d",label:"7D"},{value:"30d",label:"30D"},{value:"60d",label:"60D"}];function et({period:e,setPeriod:t,hidePeriodSelector:r=!1}={}){let o=(0,l.useRouter)(),d=(0,l.useSearchParams)(),c=d.get("sortBy")||"rawModel",m=d.get("sortOrder")||"asc",[p,b]=(0,a.useState)(null),[f,j]=(0,a.useState)(!0),[v,y]=(0,a.useState)(!1),[N,k]=(0,a.useState)(!1),[w,C]=(0,a.useState)("model"),[S,I]=(0,a.useState)("costs"),[T,$]=(0,a.useState)([]),[A,O]=(0,a.useState)("connecting"),[R,E]=(0,a.useState)("today"),_=(0,a.useRef)(!0),z=(0,a.useRef)({sequence:0,controller:null}),L=e??R,M=t??E;(0,a.useEffect)(()=>{fetch("/api/providers").then(e=>e.ok?e.json():null).then(e=>{let t=new Set;$([...(e?.connections||[]).filter(e=>!(!1===e.isActive||!W(e.provider)||t.has(e.provider))&&(t.add(e.provider),!0)),...Object.values(n.IS).filter(e=>e.noAuth&&!t.has(e.id)&&W(e.id)).map(e=>({provider:e.id,name:e.name}))])}).catch(()=>{})},[]),(0,a.useEffect)(()=>{z.current.controller?.abort();let e=new AbortController,t=z.current.sequence+1,r=!0===z.current.hasData;return z.current={sequence:t,controller:e,hasData:r},_.current?(_.current=!1,j(!0)):y(!0),fetch(`/api/usage/stats?period=${L}`,{signal:e.signal}).then(e=>e.ok?e.json():null).then(e=>{t===z.current.sequence&&(e?(b(t=>({...t,...e})),k(!1),z.current.hasData=!0):k(!0))}).catch(e=>{e?.name==="AbortError"||t===z.current.sequence&&k(!0)}).finally(()=>{t===z.current.sequence&&(j(!1),y(!1))}),()=>{z.current.controller?.abort(),z.current.sequence+=1}},[L]),(0,a.useEffect)(()=>{let e=new EventSource("/api/usage/stream");return e.onopen=()=>O("live"),e.onmessage=e=>{try{let t=JSON.parse(e.data);b(e=>e?{...e,activeRequests:t.activeRequests,recentRequests:t.recentRequests,errorProvider:t.errorProvider,pending:t.pending}:e),z.current.hasData&&j(!1)}catch(e){console.error("[SSE CLIENT] parse error:",e)}},e.onerror=()=>{O("reconnecting"),z.current.hasData&&j(!1)},()=>e.close()},[]);let q=(0,a.useCallback)((e,t)=>{let r=new URLSearchParams(d.toString());r.get("sortBy")===t?r.set("sortOrder","asc"===r.get("sortOrder")?"desc":"asc"):(r.set("sortBy",t),r.set("sortOrder","asc")),o.replace(`?${r.toString()}`,{scroll:!1})},[d,o]),D=(0,a.useMemo)(()=>{if(!p)return null;switch(w){case"model":{let e=p.pending?.byModel||{};return{columns:H,groupedData:G(J(p.byModel,e,c,m),"rawModel"),storageKey:"usage-stats:expanded-models",emptyMessage:"No usage recorded yet.",renderSummaryCells:e=>(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("td",{className:"px-6 py-3 text-text-muted",children:"—"}),(0,s.jsx)("td",{className:"px-6 py-3 text-right",children:x(e.summary.requests)}),(0,s.jsx)("td",{className:"px-6 py-3 text-right text-text-muted whitespace-nowrap",children:h(e.summary.lastUsed)})]}),renderDetailCells:e=>(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("td",{className:`px-6 py-3 font-medium transition-colors ${e.pending>0?"text-primary":""}`,children:e.rawModel}),(0,s.jsx)("td",{className:"px-6 py-3",children:(0,s.jsx)(i.default,{variant:e.pending>0?"primary":"neutral",size:"sm",children:e.provider})}),(0,s.jsx)("td",{className:"px-6 py-3 text-right",children:x(e.requests)}),(0,s.jsx)("td",{className:"px-6 py-3 text-right text-text-muted whitespace-nowrap",children:h(e.lastUsed)})]})}}case"account":{let e={};return p?.pending?.byAccount&&Object.entries(p.byAccount||{}).forEach(([t,r])=>{e[t]=function(e={},t={}){let r=t[e.connectionId];if(!r)return 0;let s=e.providerId||e.provider;return r[s?`${e.rawModel} (${s})`:e.rawModel]||0}(r,p.pending.byAccount)}),{columns:Q,groupedData:G(J(p.byAccount,e,c,m),"accountName"),storageKey:"usage-stats:expanded-accounts",emptyMessage:"No account-specific usage recorded yet.",renderSummaryCells:e=>(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("td",{className:"px-6 py-3 text-text-muted",children:"—"}),(0,s.jsx)("td",{className:"px-6 py-3 text-text-muted",children:"—"}),(0,s.jsx)("td",{className:"px-6 py-3 text-right",children:x(e.summary.requests)}),(0,s.jsx)("td",{className:"px-6 py-3 text-right text-text-muted whitespace-nowrap",children:h(e.summary.lastUsed)})]}),renderDetailCells:e=>(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("td",{className:`px-6 py-3 font-medium transition-colors ${e.pending>0?"text-primary":""}`,children:e.accountName||`Account ${e.connectionId?.slice(0,8)}...`}),(0,s.jsx)("td",{className:`px-6 py-3 font-medium transition-colors ${e.pending>0?"text-primary":""}`,children:e.rawModel}),(0,s.jsx)("td",{className:"px-6 py-3",children:(0,s.jsx)(i.default,{variant:e.pending>0?"primary":"neutral",size:"sm",children:e.provider})}),(0,s.jsx)("td",{className:"px-6 py-3 text-right",children:x(e.requests)}),(0,s.jsx)("td",{className:"px-6 py-3 text-right text-text-muted whitespace-nowrap",children:h(e.lastUsed)})]})}}case"apiKey":return{columns:X,groupedData:G(J(p.byApiKey,{},c,m),"keyName"),storageKey:"usage-stats:expanded-apikeys",emptyMessage:"No API key usage recorded yet.",renderSummaryCells:e=>(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("td",{className:"px-6 py-3 text-text-muted",children:"—"}),(0,s.jsx)("td",{className:"px-6 py-3 text-text-muted",children:"—"}),(0,s.jsx)("td",{className:"px-6 py-3 text-right",children:x(e.summary.requests)}),(0,s.jsx)("td",{className:"px-6 py-3 text-right text-text-muted whitespace-nowrap",children:h(e.summary.lastUsed)})]}),renderDetailCells:e=>(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("td",{className:"px-6 py-3 font-medium",children:e.keyName}),(0,s.jsx)("td",{className:"px-6 py-3",children:e.rawModel}),(0,s.jsx)("td",{className:"px-6 py-3",children:(0,s.jsx)(i.default,{variant:"neutral",size:"sm",children:e.provider})}),(0,s.jsx)("td",{className:"px-6 py-3 text-right",children:x(e.requests)}),(0,s.jsx)("td",{className:"px-6 py-3 text-right text-text-muted whitespace-nowrap",children:h(e.lastUsed)})]})};default:return{columns:Z,groupedData:G(J(p.byEndpoint,{},c,m),"endpoint"),storageKey:"usage-stats:expanded-endpoints",emptyMessage:"No endpoint usage recorded yet.",renderSummaryCells:e=>(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("td",{className:"px-6 py-3 text-text-muted",children:"—"}),(0,s.jsx)("td",{className:"px-6 py-3 text-text-muted",children:"—"}),(0,s.jsx)("td",{className:"px-6 py-3 text-right",children:x(e.summary.requests)}),(0,s.jsx)("td",{className:"px-6 py-3 text-right text-text-muted whitespace-nowrap",children:h(e.summary.lastUsed)})]}),renderDetailCells:e=>(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("td",{className:"px-6 py-3 font-medium font-mono text-sm",children:e.endpoint}),(0,s.jsx)("td",{className:"px-6 py-3",children:e.rawModel}),(0,s.jsx)("td",{className:"px-6 py-3",children:(0,s.jsx)(i.default,{variant:"neutral",size:"sm",children:e.provider})}),(0,s.jsx)("td",{className:"px-6 py-3 text-right",children:x(e.requests)}),(0,s.jsx)("td",{className:"px-6 py-3 text-right text-text-muted whitespace-nowrap",children:h(e.lastUsed)})]})}}},[p,w,c,m]);if(!p&&!f&&N)return(0,s.jsx)("div",{className:"text-text-muted",children:"Failed to load usage statistics."});let U=(0,s.jsx)("div",{className:"flex items-center justify-center py-12 text-text-muted",children:(0,s.jsx)("span",{className:"material-symbols-outlined text-[32px] animate-spin",children:"progress_activity"})});return(0,s.jsxs)("div",{className:"flex min-w-0 flex-col gap-6 lg:gap-7",children:[!r&&(0,s.jsxs)("div",{className:"flex w-full items-center gap-2 sm:w-auto sm:self-end",children:[(0,s.jsx)("div",{className:"grid flex-1 grid-cols-5 items-center gap-1 rounded-lg border border-border bg-bg-subtle p-1 sm:flex sm:flex-none",children:ee.map(e=>(0,s.jsx)("button",{onClick:()=>M(e.value),disabled:v,className:`rounded-md px-3 py-1 text-sm font-medium transition-colors ${L===e.value?"bg-primary text-white shadow-sm":"text-text-muted hover:bg-bg-hover hover:text-text"}`,children:e.label},e.value))}),v&&(0,s.jsx)("span",{className:"material-symbols-outlined text-[16px] text-text-muted animate-spin",children:"progress_activity"})]}),N&&!v&&(0,s.jsx)("div",{className:"rounded-xl border border-red-500/20 bg-red-500/10 px-3 py-2 text-xs text-red-700 dark:text-red-300",role:"alert",children:"Couldn't load statistics for this period — showing the last data available. Try switching the period again."}),f?U:(0,s.jsx)(u,{stats:p}),f?U:(0,s.jsxs)("div",{className:"grid min-w-0 grid-cols-1 items-stretch gap-4 lg:grid-cols-[minmax(0,3fr)_minmax(340px,2fr)]",children:[(0,s.jsx)(P,{providers:T,activeRequests:p.activeRequests||[],lastProvider:p.recentRequests?.[0]?.provider||"",errorProvider:p.errorProvider||""}),(0,s.jsx)(V,{requests:p.recentRequests||[],streamStatus:A})]}),f?U:(0,s.jsx)(F,{period:L}),(0,s.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,s.jsxs)("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between",children:[(0,s.jsx)("select",{value:w,onChange:e=>C(e.target.value),className:"w-full rounded-lg border border-border bg-surface px-3 py-1.5 text-sm font-medium text-text-main focus:outline-none focus:ring-2 focus:ring-primary/50 sm:w-auto",style:{colorScheme:"auto"},children:Y.map(e=>(0,s.jsx)("option",{value:e.value,children:e.label},e.value))}),(0,s.jsxs)("div",{className:"grid grid-cols-2 items-center gap-1 rounded-lg border border-border bg-bg-subtle p-1 sm:flex",children:[(0,s.jsx)("button",{onClick:()=>I("costs"),className:`px-3 py-1 rounded-md text-sm font-medium transition-colors ${"costs"===S?"bg-primary text-white shadow-sm":"text-text-muted hover:text-text hover:bg-bg-hover"}`,children:"Costs"}),(0,s.jsx)("button",{onClick:()=>I("tokens"),className:`px-3 py-1 rounded-md text-sm font-medium transition-colors ${"tokens"===S?"bg-primary text-white shadow-sm":"text-text-muted hover:text-text hover:bg-bg-hover"}`,children:"Tokens"})]})]}),f?U:D&&(0,s.jsx)(g,{title:"",columns:D.columns,groupedData:D.groupedData,tableType:w,sortBy:c,sortOrder:m,onToggleSort:q,viewMode:S,storageKey:D.storageKey,renderSummaryCells:D.renderSummaryCells,renderDetailCells:D.renderDetailCells,emptyMessage:D.emptyMessage})]})]})}},96748:(e,t,r)=>{r.d(t,{default:()=>d});var s=r(95155),a=r(12115),l=r(14051),n=r.n(l),i=r(35497);let o="https://api.openai.com/v1";function d({isOpen:e,onClose:t,onCreated:r,onSaved:l,node:n}){let c=!!n,[m,u]=(0,a.useState)({name:"",prefix:"",baseUrl:o}),[x,p]=(0,a.useState)(!1),[h,b]=(0,a.useState)(""),[f,g]=(0,a.useState)(""),[j,v]=(0,a.useState)(!1),[y,N]=(0,a.useState)(null);(0,a.useEffect)(()=>{e&&(N(null),b(""),g(""),c?u({name:n.name||"",prefix:n.prefix||"",baseUrl:n.baseUrl||o}):u({name:"",prefix:"",baseUrl:o}))},[e,c,n]);let k=async()=>{if(m.name.trim()&&m.prefix.trim()&&m.baseUrl.trim()){p(!0);try{let e=c?`/api/provider-nodes/${n.id}`:"/api/provider-nodes",t=c?"PUT":"POST",s={name:m.name,prefix:m.prefix,baseUrl:m.baseUrl};c||(s.type="custom-embedding");let a=await fetch(e,{method:t,headers:{"Content-Type":"application/json"},body:JSON.stringify(s)}),i=await a.json();a.ok&&(c?l?.(i.node):r?.(i.node))}catch(e){console.log("Error saving custom embedding node:",e)}finally{p(!1)}}},w=async()=>{v(!0);try{let e=await fetch("/api/provider-nodes/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:m.baseUrl,apiKey:h,type:"custom-embedding",modelId:f.trim()||void 0})}),t=await e.json();N(t)}catch{N({valid:!1,error:"Network error"})}finally{v(!1)}};return(0,s.jsx)(i.aF,{isOpen:e,title:c?"Edit Custom Embedding":"Add Custom Embedding",onClose:t,children:(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,s.jsx)(i.pd,{label:"Name",value:m.name,onChange:e=>u({...m,name:e.target.value}),placeholder:"Voyage AI",hint:"Required. A friendly label for this embedding provider."}),(0,s.jsx)(i.pd,{label:"Prefix",value:m.prefix,onChange:e=>u({...m,prefix:e.target.value}),placeholder:"voyage",hint:"Required. Used as the provider prefix for model IDs (e.g. voyage/voyage-3)."}),(0,s.jsx)(i.pd,{label:"Base URL",value:m.baseUrl,onChange:e=>u({...m,baseUrl:e.target.value}),placeholder:"https://api.voyageai.com/v1",hint:"Most embedding APIs are OpenAI-compatible: Voyage, Cohere, Jina, Mistral, Together..."}),(0,s.jsx)(i.pd,{label:"API Key (for Check)",type:"password",value:h,onChange:e=>b(e.target.value)}),(0,s.jsx)(i.pd,{label:"Model ID (for Check)",value:f,onChange:e=>g(e.target.value),placeholder:"e.g. voyage-3, embed-english-v3.0, text-embedding-3-small",hint:"Required for validation. Will send a test embeddings request."}),(0,s.jsxs)("div",{className:"flex items-center gap-3",children:[(0,s.jsx)(i.$n,{onClick:w,disabled:!h||!f.trim()||j||!m.baseUrl.trim(),variant:"secondary",children:j?"Checking...":"Check"}),(()=>{if(!y)return null;let{valid:e,error:t,dimensions:r}=y;return e?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(i.Ex,{variant:"success",children:"Valid"}),r&&(0,s.jsxs)("span",{className:"text-sm text-text-muted",children:[r," dims"]})]}):(0,s.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,s.jsx)(i.Ex,{variant:"error",children:"Invalid"}),t&&(0,s.jsx)("span",{className:"text-sm text-red-500",children:t})]})})()]}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(i.$n,{onClick:k,fullWidth:!0,disabled:!m.name.trim()||!m.prefix.trim()||!m.baseUrl.trim()||x,children:x?c?"Saving...":"Creating...":c?"Save":"Create"}),(0,s.jsx)(i.$n,{onClick:t,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})})}d.propTypes={isOpen:n().bool.isRequired,onClose:n().func.isRequired,onCreated:n().func,onSaved:n().func,node:n().shape({id:n().string,name:n().string,prefix:n().string,baseUrl:n().string})}},97677:(e,t,r)=>{r.d(t,{default:()=>a});var s=r(95155);function a({text:e,children:t,position:r="top",color:l}){let n=l?"":"bg-gray-900";return(0,s.jsxs)("div",{className:"relative inline-flex group",children:[t,(0,s.jsx)("div",{className:`pointer-events-none absolute ${{top:"bottom-full left-1/2 -translate-x-1/2 mb-1.5",bottom:"top-full left-1/2 -translate-x-1/2 mt-1.5",left:"right-full top-1/2 -translate-y-1/2 mr-1.5",right:"left-full top-1/2 -translate-y-1/2 ml-1.5"}[r]} z-50 w-max max-w-56 rounded px-2 py-1 text-[11px] leading-snug ${n} text-white opacity-0 group-hover:opacity-100 transition-opacity duration-150 whitespace-normal`,style:l?{backgroundColor:l}:{},children:e})]})}},98542:(e,t,r)=>{r.d(t,{default:()=>n});var s=r(95155),a=r(12115),l=r(31474);function n({checked:e=!1,onChange:t,label:r,description:i,disabled:o=!1,size:d="md",className:c,busy:m=!1,touchTarget:u=!1,...x}){let p=(0,a.useId)(),h=(0,a.useId)(),b={sm:{track:"w-8 h-4",thumb:"size-3",translate:"translate-x-4"},md:{track:"w-11 h-6",thumb:"size-5",translate:"translate-x-5"},lg:{track:"w-14 h-7",thumb:"size-6",translate:"translate-x-7"}},f=()=>{o||m||!t||t(!e)},g=(0,s.jsx)("span",{className:(0,l.cn)("pointer-events-none inline-block rounded-full bg-white shadow-sm","transform transition duration-200 ease-in-out",e?b[d].translate:"translate-x-0.5",b[d].thumb,"mt-0.5")});return(0,s.jsxs)("div",{className:(0,l.cn)("flex items-center gap-3",o&&"opacity-50 cursor-not-allowed",c),children:[(0,s.jsx)("button",{type:"button",role:"switch","aria-checked":e,"aria-busy":m||void 0,"aria-labelledby":r?p:void 0,"aria-describedby":i?h:void 0,"aria-label":r?void 0:x["aria-label"],disabled:o||m,onClick:f,...x,className:(0,l.cn)("relative inline-flex shrink-0 cursor-pointer","transition-colors duration-200 ease-in-out","focus:outline-none focus:ring-2 focus:ring-brand-500/30",u?"size-11 items-center justify-center rounded-xl sm:size-8 sm:rounded-lg":"rounded-full",!u&&(e?"bg-brand-500":"bg-surface-3"),!u&&b[d].track,o&&"cursor-not-allowed"),children:u?(0,s.jsx)("span",{className:(0,l.cn)("relative inline-flex shrink-0 rounded-full",e?"bg-brand-500":"bg-surface-3",b[d].track),children:g}):g}),(r||i)&&(0,s.jsxs)("div",{className:"flex flex-col",children:[r&&(0,s.jsx)("label",{id:p,onClick:f,className:"text-sm font-medium text-text-main cursor-pointer",children:r}),i&&(0,s.jsx)("span",{id:h,className:"text-xs text-text-muted",children:i})]})]})}}}]);
|
|
7
|
+
`,children:(0,s.jsxs)("span",{className:"flex items-center gap-1",children:[g.includes(e.value)&&!r&&(0,s.jsx)("span",{className:"material-symbols-outlined leading-none",style:{fontSize:"10px"},children:"check"}),r?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-[11px]",children:"edit"}),e.name]}):e.isCustom?(0,s.jsxs)(s.Fragment,{children:[e.name,(0,s.jsx)("span",{className:"text-[9px] opacity-60 font-normal",children:"custom"})]}):e.name]})},e.value)})})]},e)),0===Object.keys(M).length&&0===L.length&&(0,s.jsxs)("div",{className:"text-center py-4 text-text-muted",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-2xl mb-1 block",children:"search_off"}),(0,s.jsx)("p",{className:"text-xs",children:"No models found"})]})]})]})}x.propTypes={isOpen:n().bool.isRequired,onClose:n().func.isRequired,onSelect:n().func.isRequired,onDeselect:n().func,selectedModel:n().string,activeProviders:n().arrayOf(n().shape({provider:n().string.isRequired})),title:n().string,modelAliases:n().object,kindFilter:n().string,addedModelValues:n().arrayOf(n().string),closeOnSelect:n().bool}},73006:(e,t,r)=>{r.d(t,{FE:()=>h,Tl:()=>c,kk:()=>m,oQ:()=>u,wn:()=>b});var s=r(93308);let a={},l=s.Xn,n=[];function i(e){if("u"<typeof document)return;let t=document.documentElement,r=(0,s.il)(e);t.lang!==e&&(t.lang=e),t.dir!==r&&(t.dir=r)}function o(){if("u"<typeof document)return s.Xn;let e=document.cookie.split(";").find(e=>e.trim().startsWith(`${s.CL}=`)),t=e?decodeURIComponent(e.split("=")[1]):s.Xn;return(0,s.QC)(t)}async function d(e){if("en"===e){a={};return}try{let t=await fetch(`/i18n/literals/${e}.json`);a=await t.json()}catch(e){console.error("Failed to load translations:",e),a={}}}function c(e){if(!e||"string"!=typeof e)return e;let t=e.trim();return t&&"en"!==l&&a[t]||e}function m(){return l}function u(e){return n.push(e),()=>{n=n.filter(t=>t!==e)}}function x(e){if(!e.nodeValue||!e.nodeValue.trim())return;let t=e.parentElement;if(!t)return;let r=t;for(;r;){if(r.hasAttribute&&r.hasAttribute("data-i18n-skip"))return;r=r.parentElement}if(["script","style","code","pre","colgroup","table","thead","tbody","tfoot","tr","select","datalist","optgroup"].includes(t.tagName?.toLowerCase()))return;e._originalText||(e._originalText=e.nodeValue);let s=c(e._originalText);s!==e.nodeValue&&(e.nodeValue=s)}function p(e){let t;if(!e)return;let r=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,null,!1),s=[];for(;t=r.nextNode();)s.push(t);s.forEach(x)}async function h(){i(l=o()),await d(l),p(document.body),new MutationObserver(e=>{e.forEach(e=>{e.addedNodes.forEach(e=>{e.nodeType===Node.ELEMENT_NODE?p(e):e.nodeType===Node.TEXT_NODE&&x(e)})})}).observe(document.body,{childList:!0,subtree:!0})}async function b(){i(l=o()),await d(l),n.forEach(e=>e()),p(document.body)}},73579:(e,t,r)=>{r.d(t,{default:()=>u});var s=r(95155),a=r(12115),l=r(14051),n=r.n(l),i=r(81127),o=r(11910),d=r(92542),c=r(56061),m=r(52679);function u({isOpen:e,connection:t,proxyPools:r,onSave:l,onClose:n}){let[x,p]=(0,a.useState)({name:"",priority:1,apiKey:""}),[h,b]=(0,a.useState)({azureEndpoint:"",apiVersion:"2024-10-01-preview",deployment:"",organization:""}),[f,g]=(0,a.useState)({accountId:""}),[j,v]=(0,a.useState)({spaceId:"",spaceViewId:"",userId:"",clientVersion:"",cell:""}),[y,N]=(0,a.useState)(!1),[k,w]=(0,a.useState)(null),[C,S]=(0,a.useState)(!1),[I,T]=(0,a.useState)(null),[$,A]=(0,a.useState)(!1);(0,a.useEffect)(()=>{t&&(p({name:t.name||"",priority:t.priority||1,apiKey:""}),"azure"===t.provider&&t.providerSpecificData?b({azureEndpoint:t.providerSpecificData.azureEndpoint||"",apiVersion:t.providerSpecificData.apiVersion||"2024-10-01-preview",deployment:t.providerSpecificData.deployment||"",organization:t.providerSpecificData.organization||""}):b({azureEndpoint:"",apiVersion:"2024-10-01-preview",deployment:"",organization:""}),"cloudflare-ai"===t.provider&&t.providerSpecificData?g({accountId:t.providerSpecificData.accountId||""}):g({accountId:""}),"notion-ai"===t.provider&&t.providerSpecificData?v({spaceId:t.providerSpecificData.spaceId||"",spaceViewId:t.providerSpecificData.spaceViewId||"",userId:t.providerSpecificData.userId||t.providerSpecificData.notionUserId||"",clientVersion:t.providerSpecificData.clientVersion||"",cell:t.providerSpecificData.cell||""}):v({spaceId:"",spaceViewId:"",userId:"",clientVersion:"",cell:""}),w(null),T(null))},[t]);let P=t?.authType==="oauth",O=t?.provider==="azure",R=t?.provider==="cloudflare-ai",E=t?.provider==="notion-ai",_=!!t&&((0,m.mq)(t.provider)||(0,m.gb)(t.provider)),z=()=>{let e=Object.entries({spaceId:j.spaceId.trim(),spaceViewId:j.spaceViewId.trim(),userId:j.userId.trim(),clientVersion:j.clientVersion.trim(),cell:j.cell.trim()}).filter(([,e])=>e);return e.length>0?Object.fromEntries(e):void 0},L=async()=>{if(t?.provider){N(!0),w(null);try{let e=await fetch(`/api/providers/${t.id}/test`,{method:"POST"}),r=await e.json();w(r.valid?"success":"failed")}catch{w("failed")}finally{N(!1)}}},M=async()=>{if(t?.provider&&x.apiKey){S(!0),T(null);try{let e=await fetch("/api/providers/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:t.provider,apiKey:x.apiKey,...O?{providerSpecificData:h}:{},...R?{providerSpecificData:f}:{},...E?{providerSpecificData:z()}:{}})}),r=await e.json();T(r.valid?"success":"failed")}catch{T("failed")}finally{S(!1)}}},q=async()=>{if(t&&(P||!x.apiKey||"failed"!==I||window.confirm("The API key failed validation. Save it anyway?"))){A(!0);try{let e={name:x.name,priority:x.priority};if(!P&&x.apiKey){e.apiKey=x.apiKey;let r="success"===I;if(!r)try{S(!0),T(null);let e=await fetch("/api/providers/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:t.provider,apiKey:x.apiKey,...O?{providerSpecificData:h}:{},...R?{providerSpecificData:f}:{},...E?{providerSpecificData:z()}:{}})});r=!!(await e.json()).valid,T(r?"success":"failed")}catch{T("failed")}finally{S(!1)}r&&(e.testStatus="active",e.lastError=null,e.lastErrorAt=null)}O&&(e.providerSpecificData={azureEndpoint:h.azureEndpoint,apiVersion:h.apiVersion,deployment:h.deployment,organization:h.organization}),R&&(e.providerSpecificData={accountId:f.accountId}),E&&(e.providerSpecificData=z()),await l(e)}finally{A(!1)}}};return t?(0,s.jsx)(i.default,{isOpen:e,title:"Edit Connection",onClose:n,children:(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,s.jsx)(o.default,{label:"Name",value:x.name,onChange:e=>p({...x,name:e.target.value}),placeholder:P?"Account name":"Production Key"}),P&&t.email&&(0,s.jsxs)("div",{className:"bg-sidebar/50 p-3 rounded-lg",children:[(0,s.jsx)("p",{className:"text-sm text-text-muted mb-1",children:"Email"}),(0,s.jsx)("p",{className:"font-medium",children:t.email})]}),(0,s.jsx)(o.default,{label:"Priority",type:"number",value:x.priority,onChange:e=>p({...x,priority:Number.parseInt(e.target.value,10)||1})}),!P&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(o.default,{label:"cookie"===t.authType?"Cookie Value":"API Key",type:"cookie"===t.authType?"text":"password",value:x.apiKey,onChange:e=>p({...x,apiKey:e.target.value}),placeholder:"cookie"===t.authType?"Paste a new session cookie or cookie-export JSON":"Enter new API key",hint:"cookie"===t.authType?"Leave blank to keep the current cookie.":"Leave blank to keep the current API key.",className:"flex-1"}),(0,s.jsx)("div",{className:"pt-6",children:(0,s.jsx)(d.default,{onClick:M,disabled:!x.apiKey||C||$,variant:"secondary",children:C?"Checking...":"Check"})})]}),I&&(0,s.jsx)(c.default,{variant:"success"===I?"success":"error",children:"success"===I?"Valid":"Invalid"})]}),E&&(0,s.jsxs)("div",{className:"flex flex-col gap-3 rounded-lg border border-accent/20 bg-sidebar/50 p-4",children:[(0,s.jsx)("h3",{className:"text-sm font-semibold",children:"Notion workspace metadata (optional)"}),(0,s.jsx)("p",{className:"text-xs leading-relaxed text-text-muted",children:"Space ID and User ID are optional. The router resolves them from Notion's authenticated getSpaces endpoint; enter them only to override discovery."}),(0,s.jsx)(o.default,{label:"Space ID (optional)",value:j.spaceId,onChange:e=>v({...j,spaceId:e.target.value}),placeholder:"Auto-resolved from Notion"}),(0,s.jsx)(o.default,{label:"User ID (optional)",value:j.userId,onChange:e=>v({...j,userId:e.target.value}),placeholder:"Auto-resolved from Notion"}),(0,s.jsx)(o.default,{label:"Space View ID (optional)",value:j.spaceViewId,onChange:e=>v({...j,spaceViewId:e.target.value}),placeholder:"Leave blank to use Space ID"}),(0,s.jsx)(o.default,{label:"Notion client version (optional)",value:j.clientVersion,onChange:e=>v({...j,clientVersion:e.target.value}),placeholder:"Copy from the browser request if required"}),(0,s.jsx)(o.default,{label:"Cell (optional)",value:j.cell,onChange:e=>v({...j,cell:e.target.value}),placeholder:"Copy x-notion-cell if your request has it"})]}),O&&(0,s.jsxs)("div",{className:"bg-sidebar/50 p-4 rounded-lg border border-accent/20",children:[(0,s.jsx)("h3",{className:"font-semibold mb-3 text-sm",children:"Azure OpenAI Configuration"}),(0,s.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,s.jsx)(o.default,{label:"Azure Endpoint",value:h.azureEndpoint,onChange:e=>b({...h,azureEndpoint:e.target.value}),placeholder:"https://your-resource.openai.azure.com",hint:"Your Azure OpenAI resource endpoint URL"}),(0,s.jsx)(o.default,{label:"Deployment Name",value:h.deployment,onChange:e=>b({...h,deployment:e.target.value}),placeholder:"gpt-4",hint:"The deployment name in your Azure resource"}),(0,s.jsx)(o.default,{label:"API Version",value:h.apiVersion,onChange:e=>b({...h,apiVersion:e.target.value}),placeholder:"2024-10-01-preview",hint:"Azure OpenAI API version to use"}),(0,s.jsx)(o.default,{label:"Organization",value:h.organization,onChange:e=>b({...h,organization:e.target.value}),placeholder:"Organization ID",hint:"Required for billing"})]})]}),!_&&!O&&!R&&(0,s.jsxs)("div",{className:"flex items-center gap-3",children:[(0,s.jsx)(d.default,{onClick:L,variant:"secondary",disabled:y,children:y?"Testing...":"Test Connection"}),k&&(0,s.jsx)(c.default,{variant:"success"===k?"success":"error",children:"success"===k?"Valid":"Failed"})]}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(d.default,{onClick:q,fullWidth:!0,disabled:$,children:$?"Saving...":"Save"}),(0,s.jsx)(d.default,{onClick:n,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})}):null}u.propTypes={isOpen:n().bool.isRequired,connection:n().shape({id:n().string,name:n().string,email:n().string,priority:n().number,authType:n().string,provider:n().string,providerSpecificData:n().object}),proxyPools:n().arrayOf(n().shape({id:n().string,name:n().string})),onSave:n().func.isRequired,onClose:n().func.isRequired}},80752:(e,t,r)=>{r.d(t,{default:()=>m});var s=r(95155),a=r(12115),l=r(14051),n=r.n(l),i=r(1620),o=r(40197),d=r(81127);function c({icon:e,label:t,onClick:r,trailing:a,danger:l}){return(0,s.jsxs)("button",{onClick:r,className:`flex items-center gap-3 w-full px-4 py-2.5 text-sm transition-colors ${l?"text-red-500 hover:bg-red-500/10":"text-text-main hover:bg-black/5 dark:hover:bg-white/5"}`,children:[(0,s.jsx)("span",{className:`material-symbols-outlined text-[20px] ${l?"":"text-text-muted"}`,children:e}),(0,s.jsx)("span",{className:"flex-1 text-left",children:t}),a&&(0,s.jsx)("span",{className:"text-base",children:a})]})}function m({onLogout:e}){let[t,r]=(0,a.useState)(!1),[l,n]=(0,a.useState)(!1),[u,x]=(0,a.useState)(!1),[p,h]=(0,a.useState)(!1),{toggleTheme:b,isDark:f}=(0,i.D)(),g=(0,a.useRef)(null),j=async()=>{h(!0);try{await fetch("/api/version/shutdown",{method:"POST"})}catch(e){}};return(0,a.useEffect)(()=>{let e=e=>{g.current&&!g.current.contains(e.target)&&r(!1)};if(t)return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[t]),(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:"relative",ref:g,children:[(0,s.jsx)("button",{onClick:()=>r(e=>!e),className:"flex size-11 items-center justify-center rounded-xl text-text-muted transition-all hover:bg-black/5 hover:text-text-main dark:hover:bg-white/5 sm:size-10 sm:rounded-lg",title:"Menu","aria-label":"Open dashboard menu",children:(0,s.jsx)("span",{className:"material-symbols-outlined",children:"grid_view"})}),t&&(0,s.jsxs)("div",{className:"absolute right-0 top-full mt-2 w-60 bg-surface border border-black/10 dark:border-white/10 rounded-xl shadow-2xl z-50 animate-in fade-in zoom-in-95 duration-150 overflow-hidden py-1",children:[(0,s.jsx)(c,{icon:"history",label:"Change Log",onClick:()=>{r(!1),n(!0)}}),(0,s.jsx)(c,{icon:f?"light_mode":"dark_mode",label:"Theme",onClick:()=>{b(),r(!1)}}),(0,s.jsx)(c,{icon:"power_settings_new",label:"Shutdown",danger:!0,onClick:()=>{r(!1),x(!0)}}),(0,s.jsx)(c,{icon:"logout",label:"Logout",danger:!0,onClick:()=>{r(!1),e()}})]})]}),(0,s.jsx)(o.default,{isOpen:l,onClose:()=>n(!1)}),(0,s.jsx)(d.ConfirmModal,{isOpen:u,onClose:()=>{p||x(!1)},onConfirm:j,title:"Close Proxy",message:"Are you sure you want to close the proxy server?",confirmText:"Close",cancelText:"Cancel",variant:"danger",loading:p})]})}c.propTypes={icon:n().string.isRequired,label:n().string.isRequired,onClick:n().func.isRequired,trailing:n().node,danger:n().bool},m.propTypes={onLogout:n().func.isRequired}},81127:(e,t,r)=>{r.d(t,{ConfirmModal:()=>d,default:()=>o});var s=r(95155),a=r(12115),l=r(31474),n=r(92542),i=r(97677);function o({isOpen:e,onClose:t,title:r,children:n,footer:d,size:c="md",closeOnOverlay:m=!0,showTrafficLights:u=!0,className:x}){let p=(0,a.useId)(),h=(0,a.useRef)(null),b=(0,a.useRef)(null),f=(0,a.useRef)(t),g='button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';return((0,a.useEffect)(()=>{f.current=t},[t]),(0,a.useEffect)(()=>{if(!e)return;let t=document.body.style.overflow;b.current=document.activeElement,document.body.style.overflow="hidden";let r=h.current,s=r?.querySelector('input:not([disabled]):not([type="hidden"]):not([type="button"]):not([type="submit"]):not([type="checkbox"]):not([type="radio"]), textarea:not([disabled]), select:not([disabled])')||r?.querySelector(g);(s||r)?.focus();let a=e=>{if("Escape"===e.key)return void f.current?.();if("Tab"!==e.key||!r)return;let t=[...r.querySelectorAll(g)];if(!t.length){e.preventDefault(),r.focus();return}let s=t[0],a=t[t.length-1];e.shiftKey&&document.activeElement===s?(e.preventDefault(),a.focus()):e.shiftKey||document.activeElement!==a||(e.preventDefault(),s.focus())};return document.addEventListener("keydown",a),()=>{document.body.style.overflow=t,document.removeEventListener("keydown",a),b.current?.focus?.()}},[e]),e)?(0,s.jsxs)("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",children:[(0,s.jsx)("div",{className:"absolute inset-0 bg-black/50 backdrop-blur-[2px] fade-in",onClick:m?t:void 0}),(0,s.jsxs)("div",{ref:h,role:"dialog","aria-modal":"true","aria-labelledby":r?p:void 0,"aria-label":r?void 0:"Dialog",tabIndex:-1,className:(0,l.cn)("relative w-full max-h-[calc(100dvh-2rem)] overflow-hidden bg-surface","border border-border-subtle","rounded-[14px] shadow-[var(--shadow-elev)]","fade-in",{sm:"max-w-sm",md:"max-w-md",lg:"max-w-lg",xl:"max-w-xl",full:"max-w-4xl"}[c],x),children:[(r||u)&&(0,s.jsxs)("div",{className:"flex items-center justify-between p-2 border-b border-border-subtle",children:[(0,s.jsxs)("div",{className:"flex items-center",children:[u&&(0,s.jsxs)("div",{className:"hidden md:flex items-center gap-2 mr-4 ml-2",children:[(0,s.jsx)(i.default,{text:"Close",position:"top",color:"#FF5F56",children:(0,s.jsx)("button",{onClick:t,"aria-label":"Close",title:"Close",className:"w-4 h-4 rounded-full bg-[#FF5F56] hover:brightness-90 transition-all cursor-pointer flex items-center justify-center group/dot",children:(0,s.jsx)("span",{className:"text-[9px] font-bold text-white opacity-0 group-hover/dot:opacity-100 transition-opacity leading-none",children:"✕"})})}),(0,s.jsx)("div",{className:"w-4 h-4 rounded-full bg-[#3a3a3a]/20 dark:bg-white/15 cursor-not-allowed"}),(0,s.jsx)("div",{className:"w-4 h-4 rounded-full bg-[#3a3a3a]/20 dark:bg-white/15 cursor-not-allowed"})]}),r&&(0,s.jsx)("h2",{id:p,className:"text-lg font-semibold text-text-main",children:r})]}),(0,s.jsx)("button",{onClick:t,"aria-label":"Close",className:"md:hidden p-1.5 rounded-[10px] text-text-muted hover:bg-surface-2 hover:text-text-main transition-colors",children:(0,s.jsx)("span",{"aria-hidden":"true",className:"material-symbols-outlined text-[20px]",children:"close"})})]}),(0,s.jsx)("div",{className:"p-6 max-h-[calc(85vh-100px)] overflow-y-auto custom-scrollbar",children:n}),d&&(0,s.jsx)("div",{className:"flex items-center justify-end gap-3 p-6 border-t border-border-subtle",children:d})]})]}):null}function d({isOpen:e,onClose:t,onConfirm:r,title:a="Confirm",message:l,confirmText:i="Confirm",cancelText:c="Cancel",variant:m="danger",loading:u=!1}){return(0,s.jsx)(o,{isOpen:e,onClose:t,title:a,size:"sm",footer:(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(n.default,{variant:"ghost",onClick:t,disabled:u,children:c}),(0,s.jsx)(n.default,{variant:m,onClick:r,loading:u,children:i})]}),children:(0,s.jsx)("p",{className:"text-text-muted",children:l})})}},84588:(e,t,r)=>{r.d(t,{default:()=>l});var s=r(95155),a=r(31474);function l({children:e,title:t,subtitle:r,icon:n,action:i,padding:o="md",hover:d=!1,elev:c=!1,className:m,...u}){return(0,s.jsxs)("div",{className:(0,a.cn)("card-3d border border-border-subtle rounded-[14px] transition-[border-color,box-shadow,transform] duration-200",c&&"card-3d-elev",d&&"hover:-translate-y-0.5 hover:border-brand-500/30 hover:shadow-[var(--shadow-warm)] cursor-pointer",{none:"",xs:"p-3",sm:"p-4",md:"p-6",lg:"p-8"}[o],m),...u,children:[(t||i)&&(0,s.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,s.jsxs)("div",{className:"flex items-center gap-3",children:[n&&(0,s.jsx)("div",{className:"p-2 rounded-[10px] bg-bg text-text-muted",children:(0,s.jsx)("span",{className:"material-symbols-outlined text-[20px]",children:n})}),(0,s.jsxs)("div",{children:[t&&(0,s.jsx)("h3",{className:"text-text-main font-semibold",children:t}),r&&(0,s.jsx)("p",{className:"text-sm text-text-muted",children:r})]})]}),i]}),e]})}l.Section=function({children:e,className:t,...r}){return(0,s.jsx)("div",{className:(0,a.cn)("p-4 rounded-[10px]","bg-bg border border-border-subtle",t),...r,children:e})},l.Row=function({children:e,className:t,...r}){return(0,s.jsx)("div",{className:(0,a.cn)("p-3 -mx-3 px-3 transition-colors","border-b border-border-subtle last:border-b-0","hover:bg-surface-2/50",t),...r,children:e})},l.ListItem=function({children:e,actions:t,className:r,...l}){return(0,s.jsxs)("div",{className:(0,a.cn)("group flex items-center justify-between p-3 -mx-3 px-3","border-b border-border-subtle last:border-b-0","hover:bg-surface-2/50 transition-colors",r),...l,children:[(0,s.jsx)("div",{className:"flex-1 min-w-0",children:e}),t&&(0,s.jsx)("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:t})]})}},90085:(e,t,r)=>{r.d(t,{A:()=>i});var s=r(1934),a=r(31692),l=r(90620);function n(e){let t=document.documentElement,r=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light";"dark"===("system"===e?r:e)?t.classList.add("dark"):t.classList.remove("dark")}let i=(0,s.v)((0,a.Zr)((e,t)=>({theme:l.B2.defaultTheme,setTheme:t=>{e({theme:t}),n(t)},toggleTheme:()=>{let r="dark"===t().theme?"light":"dark";e({theme:r}),n(r)},initTheme:()=>{n(t().theme)}}),{name:l.B2.storageKey}))},90882:(e,t,r)=>{r.d(t,{default:()=>d});var s=r(95155),a=r(12115),l=r(14051),n=r.n(l),i=r(35497),o=r(11059);function d({isOpen:e,provider:t,providerInfo:r,onSuccess:l,onClose:n,oauthMeta:c,idcConfig:m}){let[u,x]=(0,a.useState)("waiting"),[p,h]=(0,a.useState)(null),[b,f]=(0,a.useState)(""),[g,j]=(0,a.useState)(null),[v,y]=(0,a.useState)(!1),[N,k]=(0,a.useState)(null),[w,C]=(0,a.useState)(!1),S=(0,a.useRef)(null),I=(0,a.useRef)(0),{copied:T,copy:$}=(0,o.C)(),[A,P]=(0,a.useState)(!1),[O,R]=(0,a.useState)("/callback?code=..."),E=(0,a.useRef)(!1);(0,a.useEffect)(()=>{P("localhost"===window.location.hostname||"127.0.0.1"===window.location.hostname),R(`${window.location.origin}/callback?code=...`)},[]);let _=(0,a.useCallback)(async(e,r)=>{if(p)try{let s=await fetch(`/api/oauth/${t}/exchange`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({code:e,redirectUri:p.redirectUri,codeVerifier:p.codeVerifier,state:r,...c?{meta:c}:{}})}),a=await s.json();if(!s.ok)throw Error(a.error);x("success"),l?.()}catch(e){j(e.message),x("error")}},[p,t,l,c]),z=(0,a.useCallback)(async e=>{if(p?.state)try{let t=await fetch("/api/oauth/xai/manual-code",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({code:e,state:p.state})}),r=await t.json();if(!t.ok)throw Error(r.error);x("success"),l?.()}catch(e){j(e.message),x("error")}},[p,l]),L=(0,a.useCallback)(async(e,r,s,a,n)=>{let i=++I.current,o=()=>I.current===i;C(!0);let d=Date.now()+(Number.isFinite(n)&&n>0?n:12e4);for(;Date.now()<d;){if(!o())return void console.log("[OAuthModal] Polling aborted");if(await new Promise(e=>setTimeout(e,1e3*s)),!o())return void console.log("[OAuthModal] Polling aborted after sleep");try{let n=await fetch(`/api/oauth/${t}/poll`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({deviceCode:e,codeVerifier:r,extraData:a})}),i=await n.json();if(!o())return;if(i.success){I.current++,x("success"),C(!1),l?.();return}if("expired_token"===i.error||"access_denied"===i.error)throw Error(i.errorDescription||i.error);"slow_down"===i.error&&(s=Math.min(s+5,30))}catch(e){if(!o())return;j(e.message),x("error"),C(!1);return}}o()&&(j("Authorization timeout"),x("error"),C(!1))},[t,l]),M=(0,a.useCallback)(async()=>{if(t)try{let e;j(null);let r=window.location.hostname.toLowerCase(),s="codex"===t&&"localhost"!==r&&"127.0.0.1"!==r&&"::1"!==r;if(["github","qwen","kiro","kimi","kimi-coding","kilocode","codebuddy","codebuddy-cn","qoder","grok-cli",...s?["codex"]:[]].includes(t)){y(!0),x("waiting");let e=new URL(`/api/oauth/${t}/device-code`,window.location.origin);"kiro"===t&&m?.startUrl&&(e.searchParams.set("start_url",m.startUrl),m.region&&e.searchParams.set("region",m.region),e.searchParams.set("auth_method","idc"));let r=await fetch(e.toString()),s=await r.json();if(!r.ok)throw Error(s.error);k(s);let a=s.verification_uri_complete||s.verification_uri;a&&window.open(a,"_blank","noopener,noreferrer");let l="codex"===t?{_codexUserCode:s.user_code}:"kiro"===t?{_clientId:s._clientId,_clientSecret:s._clientSecret,_region:s._region,_authMethod:s._authMethod,_startUrl:s._startUrl}:"qoder"===t?{_qoderNonce:s._qoderNonce,_qoderMachineId:s._qoderMachineId,_qoderVerifier:s.codeVerifier}:null;L(s.device_code,s.codeVerifier,s.interval||5,l,Number.isFinite(s.expires_in)&&s.expires_in>0?1e3*s.expires_in:void 0);return}if(["trae","windsurf","zed"].includes(t)){let e=await fetch(`/api/oauth/${t}/start-proxy`),r=await e.json();if(!e.ok||!r.success||!r.callbackUrl)throw Error(r.reason||r.error||`Failed to start ${t} callback server`);let s=new URL(`/api/oauth/${t}/authorize`,window.location.origin);s.searchParams.set("redirect_uri",r.callbackUrl);let a=await fetch(s.toString()),l=await a.json();if(!a.ok)throw Error(l.error);let n={state:l.state};l.codeVerifier&&(n.codeVerifier=l.codeVerifier),await fetch(`/api/oauth/${t}/register-session`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)}),h({...l,proxyProvider:t}),x("waiting"),S.current=window.open(l.authUrl,"oauth_popup","width=600,height=700"),S.current||x("input");return}let a=window.location.port||("https:"===window.location.protocol?"443":"80");e="codex"===t?"http://localhost:1455/auth/callback":"xai"===t?"http://127.0.0.1:56121/callback":`http://localhost:${a}/callback`;let l=new URL(`/api/oauth/${t}/authorize`,window.location.origin);l.searchParams.set("redirect_uri",e),c&&Object.entries(c).forEach(([e,t])=>{t&&l.searchParams.set(e,t)});let n=await fetch(l.toString()),i=await n.json();if(!n.ok)throw Error(i.error);let o=!1,d=!1;if("codex"===t)try{let t=await fetch("/api/oauth/codex/start-proxy",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({appPort:a,state:i.state,codeVerifier:i.codeVerifier,redirectUri:e})}),r=await t.json();o=r.success,d=!!r.serverSide}catch{o=!1}let u=!1,p=!1;if("xai"===t)try{let t=await fetch("/api/oauth/xai/start-proxy",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({appPort:a,state:i.state,codeVerifier:i.codeVerifier,redirectUri:e})}),r=await t.json();if(u=r.success,p=!!r.serverSide,!u&&"port_busy"===r.reason)throw Error("Port 56121 in use; close the conflicting process and retry")}catch(e){if(e?.message)throw e;u=!1}h({...i,redirectUri:e,codexServerSide:d,xaiServerSide:p}),"codex"===t&&o||"xai"===t&&u||A&&"codex"!==t&&"xai"!==t?(x("waiting"),S.current=window.open(i.authUrl,"oauth_popup","width=600,height=700"),S.current||x("input")):(x("input"),window.open(i.authUrl,"_blank","noopener,noreferrer"))}catch(e){j(e.message),x("error")}},[t,A,L,c,m]);(0,a.useEffect)(()=>{e&&t?(h(null),f(""),j(null),y(!1),k(null),C(!1),M()):!e&&(I.current++,"codex"===t?fetch("/api/oauth/codex/stop-proxy",{method:"POST"}).catch(()=>{}):"xai"===t?fetch("/api/oauth/xai/stop-proxy",{method:"POST"}).catch(()=>{}):["trae","windsurf","zed"].includes(t)&&fetch(`/api/oauth/${t}/stop-proxy`).catch(()=>{}))},[e,t,M]),(0,a.useEffect)(()=>{let e=p?.codexServerSide?"codex":p?.xaiServerSide?"xai":p?.proxyProvider||null;if(!e||!p?.state||E.current)return;let t=!1,r=null,s=0,a=async()=>{if(!t&&!E.current){s+=1;try{let r=await fetch(`/api/oauth/${e}/poll-status?state=${encodeURIComponent(p.state)}`),s=await r.json();if(t||E.current)return;if("done"===s.status){E.current=!0,x("success"),l?.();return}if("error"===s.status){E.current=!0,j(s.error||"Authentication failed"),x("error");return}}catch{}if(s>=200){E.current=!0,j("Authentication timeout"),x("error");return}r=setTimeout(a,1500)}};return r=setTimeout(a,1500),()=>{t=!0,r&&clearTimeout(r)}},[p,l]),(0,a.useEffect)(()=>{let e;if(!p)return;E.current=!1;let t=async e=>{if(E.current)return;let{code:t,state:r,error:s,errorDescription:a}=e;if(s){E.current=!0,j(a||s),x("error");return}t&&(E.current=!0,await _(t,r))},r=e=>{let r=e.origin.includes("localhost")||e.origin.includes("127.0.0.1"),s=e.origin===window.location.origin;(r||s)&&e.data?.type==="oauth_callback"&&t(e.data.data)};window.addEventListener("message",r);try{(e=new BroadcastChannel("oauth_callback")).onmessage=e=>t(e.data)}catch(e){console.log("BroadcastChannel not supported")}let s=e=>{if("oauth_callback"===e.key&&e.newValue)try{let r=JSON.parse(e.newValue);t(r),localStorage.removeItem("oauth_callback")}catch(e){console.log("Failed to parse localStorage data")}};window.addEventListener("storage",s);try{let e=localStorage.getItem("oauth_callback");if(e){let r=JSON.parse(e);r.timestamp&&Date.now()-r.timestamp<3e4&&t(r),localStorage.removeItem("oauth_callback")}}catch{}return()=>{window.removeEventListener("message",r),window.removeEventListener("storage",s),e&&e.close()}},[p,_]);let q=async()=>{try{j(null);let e=b.trim();if(e.startsWith("eyJ")&&e.includes("."))return void await _(e,null);if("xai"===t&&e&&!e.includes("://")&&!e.includes("?")&&!e.includes("code="))return void await z(e);if("kimchi"===t&&e&&!e.includes("://")&&!e.includes("?"))return void await _(e,null);let r=new URL(e),s=r.searchParams.get("code"),a=r.searchParams.get("token"),l=r.searchParams.get("state"),n=r.searchParams.get("error");if(n)throw Error(r.searchParams.get("error_description")||n);if(!s&&!a)throw Error("xai"===t?"Paste the callback URL or copied xAI code":"kimchi"===t?"No Kimchi token found in URL":"No authorization code found in URL");await _(a||s,l)}catch(e){j(e.message),x("error")}},D=(0,a.useCallback)(()=>{"codex"===t?fetch("/api/oauth/codex/stop-proxy",{method:"POST"}).catch(()=>{}):"xai"===t&&fetch("/api/oauth/xai/stop-proxy",{method:"POST"}).catch(()=>{}),n()},[n,t]);if(!t||!r)return null;let U="xai"===t,F="kimchi"===t,W=N?.verification_uri_complete||N?.verification_uri||"",B=U?"Connect Grok Build OAuth":`Connect ${r.name}`,K=U?"http://127.0.0.1:56121/callback?code=... or copied code":F?`${O.replace("code=...","token=...")} or copied token`:O;return(0,s.jsx)(i.aF,{isOpen:e,title:B,onClose:D,size:"lg",children:(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:[("waiting"===u||"input"===u)&&!v&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 border border-border rounded-lg bg-sidebar/50",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-base text-primary animate-spin",children:"progress_activity"}),(0,s.jsx)("span",{className:"text-sm",children:U?"Waiting for Grok Build OAuth…":"Waiting for popup authorization…"})]}),(0,s.jsxs)("div",{className:"flex items-center gap-3 my-1",children:[(0,s.jsx)("div",{className:"flex-1 h-px bg-border"}),(0,s.jsx)("span",{className:"text-xs text-text-muted uppercase tracking-wider",children:"Or paste callback URL manually"}),(0,s.jsx)("div",{className:"flex-1 h-px bg-border"})]}),(0,s.jsxs)("div",{className:"space-y-4",children:[(0,s.jsxs)("div",{children:[(0,s.jsxs)("p",{className:"text-sm font-medium mb-2",children:["Step 1: Open this ",U?"Grok Build OAuth URL":"URL"," in your browser"]}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(i.pd,{value:p?.authUrl||"",readOnly:!0,className:"flex-1 font-mono text-xs"}),(0,s.jsx)(i.$n,{variant:"secondary",icon:"auth_url"===T?"check":"content_copy",onClick:()=>$(p?.authUrl,"auth_url"),disabled:!p?.authUrl,children:"Copy"})]})]}),(0,s.jsxs)("div",{children:[(0,s.jsxs)("p",{className:"text-sm font-medium mb-2",children:["Step 2: Paste the ","xai"===t?"callback URL or copied code":"kimchi"===t?"callback URL or token":"callback URL"," here"]}),(0,s.jsx)("p",{className:"text-xs text-text-muted mb-2",children:"xai"===t?"If xAI shows a code instead of redirecting, paste that code here.":"kimchi"===t?"After authorization, paste the callback URL (with token=…) or the raw Kimchi token.":"After authorization, copy the full URL from your browser."}),(0,s.jsx)(i.pd,{value:b,onChange:e=>f(e.target.value),placeholder:K,className:"font-mono text-xs"})]})]}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(i.$n,{onClick:q,fullWidth:!0,disabled:!b,children:"Connect"}),(0,s.jsx)(i.$n,{onClick:D,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]}),"waiting"===u&&v&&N&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:"text-center py-4",children:[(0,s.jsx)("p",{className:"text-sm text-text-muted mb-4",children:"Visit the login URL below and authorize:"}),(0,s.jsxs)("div",{className:"bg-sidebar p-4 rounded-lg mb-4",children:[(0,s.jsx)("p",{className:"text-xs text-text-muted mb-1",children:"Login URL"}),(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("code",{className:"flex-1 text-sm break-all",children:W}),(0,s.jsx)(i.$n,{size:"sm",variant:"ghost",icon:"login_url"===T?"check":"content_copy",onClick:()=>$(W,"login_url"),disabled:!W}),(0,s.jsx)(i.$n,{size:"sm",variant:"ghost",icon:"open_in_new",onClick:()=>window.open(W,"_blank","noopener,noreferrer"),disabled:!W,children:"Open"})]})]}),(0,s.jsxs)("div",{className:"bg-primary/10 p-4 rounded-lg",children:[(0,s.jsx)("p",{className:"text-xs text-text-muted mb-1",children:"Your Code"}),(0,s.jsxs)("div",{className:"flex items-center justify-center gap-2",children:[(0,s.jsx)("p",{className:"text-2xl font-mono font-bold text-primary",children:N.user_code}),(0,s.jsx)(i.$n,{size:"sm",variant:"ghost",icon:"user_code"===T?"check":"content_copy",onClick:()=>$(N.user_code,"user_code")})]})]})]}),w&&(0,s.jsxs)("div",{className:"flex items-center justify-center gap-2 text-sm text-text-muted",children:[(0,s.jsx)("span",{className:"material-symbols-outlined animate-spin",children:"progress_activity"}),"Waiting for authorization..."]})]}),"success"===u&&(0,s.jsxs)("div",{className:"text-center py-6",children:[(0,s.jsx)("div",{className:"size-16 mx-auto mb-4 rounded-full bg-green-100 dark:bg-green-900/30 flex items-center justify-center",children:(0,s.jsx)("span",{className:"material-symbols-outlined text-3xl text-green-600",children:"check_circle"})}),(0,s.jsx)("h3",{className:"text-lg font-semibold mb-2",children:"Connected Successfully!"}),(0,s.jsxs)("p",{className:"text-sm text-text-muted mb-4",children:["Your ",r.name," account has been connected."]}),(0,s.jsx)(i.$n,{onClick:D,fullWidth:!0,children:"Done"})]}),"error"===u&&(0,s.jsxs)("div",{className:"text-center py-6",children:[(0,s.jsx)("div",{className:"size-16 mx-auto mb-4 rounded-full bg-red-100 dark:bg-red-900/30 flex items-center justify-center",children:(0,s.jsx)("span",{className:"material-symbols-outlined text-3xl text-red-600",children:"error"})}),(0,s.jsx)("h3",{className:"text-lg font-semibold mb-2",children:"Connection Failed"}),(0,s.jsx)("p",{className:"text-sm text-red-600 mb-4",children:g}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(i.$n,{onClick:M,variant:"secondary",fullWidth:!0,children:"Try Again"}),(0,s.jsx)(i.$n,{onClick:D,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})]})})}d.propTypes={isOpen:n().bool.isRequired,provider:n().string,providerInfo:n().shape({name:n().string}),onSuccess:n().func,onClose:n().func.isRequired,oauthMeta:n().object,idcConfig:n().shape({startUrl:n().string,region:n().string})}},91450:(e,t,r)=>{r.d(t,{default:()=>i});var s=r(95155),a=r(14051),l=r.n(a),n=r(38587);function i({children:e}){return(0,s.jsxs)("div",{className:"min-h-screen flex flex-col relative bg-bg transition-colors duration-500 overflow-x-hidden selection:bg-primary/20 selection:text-primary",children:[(0,s.jsx)("div",{className:"fixed top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-[800px] h-[800px] bg-primary/5 dark:bg-primary/5 rounded-full blur-[100px] pointer-events-none z-0"}),(0,s.jsx)("div",{className:"fixed bottom-0 right-0 w-[600px] h-[600px] bg-orange-200/20 dark:bg-orange-900/10 rounded-full blur-[120px] pointer-events-none z-0 translate-y-1/3 translate-x-1/3"}),(0,s.jsx)("div",{className:"absolute top-6 right-6 z-20",children:(0,s.jsx)(n.default,{variant:"card"})}),(0,s.jsx)("main",{className:"flex-1 flex flex-col items-center justify-center p-4 sm:p-6 z-10 w-full h-full",children:e})]})}i.propTypes={children:l().node.isRequired}},92173:(e,t,r)=>{r.d(t,{default:()=>c});var s=r(95155),a=r(98500),l=r.n(a),n=r(90620);let i=[{label:"Features",href:"#features"},{label:"Pricing",href:"#pricing"},{label:"Changelog",href:"#"}],o=[{label:"Documentation",href:"#"},{label:"API Reference",href:"#"},{label:"Help Center",href:"#"}],d=[{label:"About",href:"#"},{label:"Blog",href:"#"},{label:"Contact",href:"#"}];function c(){return(0,s.jsx)("footer",{className:"bg-bg border-t border-border pt-16 pb-12",children:(0,s.jsxs)("div",{className:"container mx-auto px-4 sm:px-6 lg:px-8",children:[(0,s.jsxs)("div",{className:"grid grid-cols-2 md:grid-cols-4 lg:grid-cols-5 gap-10 mb-12",children:[(0,s.jsxs)("div",{className:"col-span-2 lg:col-span-2",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2 mb-6",children:[(0,s.jsx)("div",{className:"size-6 text-primary",children:(0,s.jsx)("svg",{className:"w-full h-full",fill:"currentColor",viewBox:"0 0 48 48",children:(0,s.jsx)("path",{clipRule:"evenodd",d:"M12.0799 24L4 19.2479L9.95537 8.75216L18.04 13.4961L18.0446 4H29.9554L29.96 13.4961L38.0446 8.75216L44 19.2479L35.92 24L44 28.7521L38.0446 39.2479L29.96 34.5039L29.9554 44H18.0446L18.04 34.5039L9.95537 39.2479L4 28.7521L12.0799 24Z",fillRule:"evenodd"})})}),(0,s.jsx)("span",{className:"text-xl font-bold text-text-main",children:n.vQ.name})]}),(0,s.jsx)("p",{className:"text-text-muted mb-6 max-w-sm font-light",children:"The unified interface for modern AI infrastructure. Secure, observable, and scalable."}),(0,s.jsxs)("div",{className:"flex gap-4",children:[(0,s.jsx)("a",{href:"#",className:"text-gray-400 hover:text-primary transition-colors","aria-label":"Twitter",children:(0,s.jsx)("svg",{className:"w-5 h-5",fill:"currentColor",viewBox:"0 0 24 24",children:(0,s.jsx)("path",{d:"M22.46 6c-.77.35-1.6.58-2.46.69.88-.53 1.56-1.37 1.88-2.38-.83.5-1.75.85-2.72 1.05C18.37 4.5 17.26 4 16 4c-2.35 0-4.27 1.92-4.27 4.29 0 .34.04.67.11.98C8.28 9.09 5.11 7.38 3 4.79c-.37.63-.58 1.37-.58 2.15 0 1.49.75 2.81 1.91 3.56-.71 0-1.37-.2-1.95-.5v.03c0 2.08 1.48 3.82 3.44 4.21a4.22 4.22 0 0 1-1.93.07 4.28 4.28 0 0 0 4 2.98 8.521 8.521 0 0 1-5.33 1.84c-.34 0-.68-.02-1.02-.06C3.44 20.29 5.7 21 8.12 21 16 21 20.33 14.46 20.33 8.79c0-.19 0-.37-.01-.56.84-.6 1.56-1.36 2.14-2.23z"})})}),(0,s.jsx)("a",{href:"#",className:"text-gray-400 hover:text-primary transition-colors","aria-label":"GitHub",children:(0,s.jsx)("svg",{className:"w-5 h-5",fill:"currentColor",viewBox:"0 0 24 24",children:(0,s.jsx)("path",{d:"M12 2C6.477 2 2 6.484 2 12.017c0 4.425 2.865 8.18 6.839 9.504.5.092.682-.217.682-.483 0-.237-.008-.868-.013-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.029-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0 1 12 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.202 2.398.1 2.651.64.7 1.028 1.595 1.028 2.688 0 3.848-2.339 4.695-4.566 4.943.359.309.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.019 10.019 0 0 0 22 12.017C22 6.484 17.522 2 12 2z"})})})]})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("h4",{className:"font-semibold text-text-main mb-4",children:"Product"}),(0,s.jsx)("ul",{className:"flex flex-col gap-3 text-sm text-text-muted font-light",children:i.map(e=>(0,s.jsx)("li",{children:(0,s.jsx)(l(),{href:e.href,className:"hover:text-primary transition-colors",children:e.label})},e.label))})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("h4",{className:"font-semibold text-text-main mb-4",children:"Resources"}),(0,s.jsx)("ul",{className:"flex flex-col gap-3 text-sm text-text-muted font-light",children:o.map(e=>(0,s.jsx)("li",{children:(0,s.jsx)(l(),{href:e.href,className:"hover:text-primary transition-colors",children:e.label})},e.label))})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("h4",{className:"font-semibold text-text-main mb-4",children:"Company"}),(0,s.jsx)("ul",{className:"flex flex-col gap-3 text-sm text-text-muted font-light",children:d.map(e=>(0,s.jsx)("li",{children:(0,s.jsx)(l(),{href:e.href,className:"hover:text-primary transition-colors",children:e.label})},e.label))})]})]}),(0,s.jsxs)("div",{className:"border-t border-border pt-8 flex flex-col md:flex-row justify-between items-center gap-4",children:[(0,s.jsxs)("p",{className:"text-sm text-text-muted",children:["\xa9 ",new Date().getFullYear()," ",n.vQ.name," Inc. All rights reserved."]}),(0,s.jsxs)("div",{className:"flex gap-6 text-sm text-text-muted",children:[(0,s.jsx)(l(),{href:"#",className:"hover:text-primary transition-colors",children:"Privacy Policy"}),(0,s.jsx)(l(),{href:"#",className:"hover:text-primary transition-colors",children:"Terms of Service"})]})]})]})})}},92542:(e,t,r)=>{r.d(t,{default:()=>i});var s=r(95155),a=r(31474);let l={primary:"bg-brand-500 hover:bg-brand-600 text-white shadow-sm disabled:bg-surface-3 disabled:text-text-muted",secondary:"bg-surface-2 hover:bg-surface-3 text-text-main border border-border disabled:opacity-50",outline:"border border-border text-text-main hover:bg-surface-2 hover:border-brand-500/40",ghost:"text-text-muted hover:bg-surface-2 hover:text-text-main",danger:"bg-red-500 hover:bg-red-600 text-white shadow-sm disabled:bg-surface-3 disabled:text-text-muted",success:"bg-green-600 hover:bg-green-700 text-white shadow-sm disabled:bg-surface-3 disabled:text-text-muted"},n={sm:"h-10 px-3 text-xs rounded-[8px] sm:h-7",md:"h-11 px-4 text-sm rounded-[10px] sm:h-9",lg:"h-12 px-6 text-sm rounded-[10px] sm:h-11"};function i({children:e,variant:t="primary",size:r="md",icon:o,iconRight:d,disabled:c=!1,loading:m=!1,fullWidth:u=!1,className:x,...p}){return(0,s.jsxs)("button",{className:(0,a.cn)("inline-flex items-center justify-center gap-2 font-semibold transition-all duration-150 ease-out cursor-pointer","active:scale-[0.97] disabled:opacity-50 disabled:cursor-not-allowed disabled:active:scale-100",l[t],n[r],u&&"w-full",x),disabled:c||m,"aria-busy":m||void 0,...p,children:[m?(0,s.jsx)("span",{"aria-hidden":"true",className:"material-symbols-outlined animate-spin text-[18px]",children:"progress_activity"}):o?(0,s.jsx)("span",{"aria-hidden":"true",className:"material-symbols-outlined text-[18px]",children:o}):null,e,d&&!m&&(0,s.jsx)("span",{"aria-hidden":"true",className:"material-symbols-outlined text-[18px]",children:d})]})}},92622:(e,t,r)=>{r.d(t,{default:()=>S});var s=r(95155),a=r(12115),l=r(14051),n=r.n(l),i=r(98500),o=r.n(i),d=r(73321),c=r(31474),m=r(90620),u=r(52679),x=r(11059),p=r(92542),h=r(81127);let b=["embedding","image","tts","stt"],f="/dashboard/media-providers/web",g=[{href:"/dashboard/endpoint",label:"Endpoint",icon:"terminal"},{href:"/dashboard/providers",label:"Providers",icon:"dns"},{href:"/dashboard/playground",label:"Playground",icon:"forum"},{href:"/dashboard/usage",label:"Usage",icon:"bar_chart"},{href:"/dashboard/quota",label:"Quota Tracker",icon:"data_usage"}],j=[{href:"/dashboard/combos",label:"Combos",icon:"layers"},{href:"/dashboard/cli-tools",label:"CLI Tools",icon:"handyman"},{href:"/dashboard/mitm",label:"MITM",icon:"security"},{href:"/dashboard/automation",label:"Automation",icon:"automation"},{href:"/dashboard/token-saver",label:"Token Saver",icon:"savings"},{href:"/dashboard/terminal",label:"Terminal",icon:"terminal"}],v=[{href:"/dashboard/console-log",label:"Console Log",icon:"receipt_long"},{href:"/dashboard/translator",label:"Translator",icon:"translate"}],y=[{href:"/dashboard/proxy-pools",label:"Proxy Pools",icon:"lan"},{href:"/dashboard/context",label:"Context Inject",icon:"psychology"},{href:"/dashboard/skills",label:"Agent Skills",icon:"extension"}],N="group relative flex min-h-11 items-center gap-3 rounded-xl border border-transparent px-3 py-2 transition-all duration-200 lg:min-h-9 lg:py-1",k="border-primary/15 bg-linear-to-r from-primary/15 to-primary/5 text-primary shadow-[0_12px_26px_-22px_rgba(229,106,74,0.9)]",w="text-text-muted hover:border-border-subtle hover:bg-surface-2 hover:text-text-main";function C(e){return(0,c.cn)("material-symbols-outlined flex size-7 shrink-0 items-center justify-center rounded-lg text-[18px] transition-all duration-200",e?"fill-1 bg-primary text-white shadow-[0_7px_16px_-8px_rgba(229,106,74,0.9)]":"group-hover:bg-primary/10 group-hover:text-primary")}function S({onClose:e}){let t=(0,d.usePathname)(),r=j.some(e=>t===e.href||t.startsWith(`${e.href}/`)),[l,n]=(0,a.useState)(!1),[i,T]=(0,a.useState)(!0),[$,A]=(0,a.useState)(!1),[P,O]=(0,a.useState)(null),[R,E]=(0,a.useState)(!1),[_,z]=(0,a.useState)(!1),[L,M]=(0,a.useState)(0),[q,D]=(0,a.useState)(!1),{copied:U,copy:F}=(0,x.C)(2e3),W=(0,a.useRef)(null),B=m.h0.installCmdLatest;(0,a.useEffect)(()=>()=>{W.current&&(clearInterval(W.current),W.current=null)},[]),(0,a.useEffect)(()=>{let e=!1;return fetch("/api/settings").then(e=>e.json()).then(t=>{!e&&t.enableTranslator&&D(!0)}).catch(()=>{}),()=>{e=!0}},[]),(0,a.useEffect)(()=>{let e=!1;return fetch("/api/version",{cache:"no-store"}).then(e=>e.json()).then(t=>{e||(t?.hasUpdate?O(t):O(null))}).catch(()=>{}),()=>{e=!0}},[]),(0,a.useEffect)(()=>{r&&T(!0)},[r]);let K=e=>"/dashboard/endpoint"===e?"/dashboard"===t||t.startsWith("/dashboard/endpoint"):t.startsWith(e),V=async()=>{if(!await F(B))return;let e=m.h0.shutdownCountdownSec;M(e),W.current&&clearInterval(W.current),W.current=setInterval(()=>{M(e-=1),e<=0&&(clearInterval(W.current),W.current=null,fetch("/api/version/shutdown",{method:"POST"}).catch(()=>{}),A(!0))},1e3)};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("aside",{className:"relative flex min-h-full w-[min(18rem,86vw)] flex-col overflow-hidden border-r border-border-subtle bg-vibrancy shadow-[8px_0_30px_-28px_rgba(0,0,0,0.45)] backdrop-blur-xl transition-colors duration-300 after:pointer-events-none after:absolute after:inset-y-0 after:right-0 after:w-px after:bg-linear-to-b after:from-transparent after:via-primary/25 after:to-transparent lg:w-72",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2 px-6 pt-5 pb-2",children:[(0,s.jsx)("div",{className:"w-3 h-3 rounded-full bg-[#FF5F56]"}),(0,s.jsx)("div",{className:"w-3 h-3 rounded-full bg-[#FFBD2E]"}),(0,s.jsx)("div",{className:"w-3 h-3 rounded-full bg-[#27C93F]"})]}),(0,s.jsxs)("div",{className:"flex flex-col gap-2 border-b border-border-subtle/70 px-6 py-4",children:[(0,s.jsxs)(o(),{href:"/dashboard",className:"flex items-center gap-3",children:[(0,s.jsx)("div",{className:"flex items-center justify-center size-9 rounded-[10px] bg-gradient-to-br from-[#FF9A52] via-[#F56A2A] to-[#D94716] shadow-[var(--shadow-warm)] ring-1 ring-white/20",children:(0,s.jsx)("svg",{viewBox:"0 0 32 32",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"w-6 h-6",children:(0,s.jsx)("path",{d:"M9 10H23L9 22H23",stroke:"white",strokeWidth:"3.25",strokeLinecap:"round",strokeLinejoin:"round"})})}),(0,s.jsxs)("div",{className:"flex flex-col",children:[(0,s.jsx)("h1",{className:"text-lg font-semibold tracking-tight text-text-main",children:m.vQ.name}),(0,s.jsxs)("span",{className:"text-xs text-text-muted",children:["v",m.vQ.version]})]})]}),P&&(0,s.jsxs)("div",{className:"flex flex-col gap-1.5 rounded p-1 -m-1",children:[(0,s.jsxs)("span",{className:"text-xs font-semibold text-green-600 dark:text-amber-500",children:["↑ New version available: v",P.latestVersion]}),(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("button",{onClick:()=>E(!0),className:"px-2 py-1 rounded bg-green-600 hover:bg-green-700 dark:bg-amber-500 dark:hover:bg-amber-600 text-white text-[11px] font-semibold transition-colors cursor-pointer",children:"Update now"}),(0,s.jsx)("button",{onClick:()=>F(B),title:"Copy install command",className:"flex-1 text-left hover:opacity-80 transition-opacity cursor-pointer min-w-0",children:(0,s.jsx)("code",{className:"block text-[10px] text-green-600/80 dark:text-amber-400/70 font-mono truncate",children:U?"✓ copied!":B})})]})]})]}),(0,s.jsxs)("nav",{"aria-label":"Main navigation",className:"flex-1 px-4 py-2 space-y-0.5 overflow-y-auto custom-scrollbar",children:[(0,s.jsx)("p",{className:"px-3 pt-1 pb-1 text-[10px] font-semibold uppercase tracking-[0.14em] text-text-muted/55",children:"Core"}),g.map(t=>(0,s.jsxs)(o(),{href:t.href,onClick:e,"aria-current":K(t.href)?"page":void 0,className:(0,c.cn)(N,K(t.href)?k:w),children:[(0,s.jsx)("span",{className:C(K(t.href)),children:t.icon}),(0,s.jsx)("span",{className:"text-[13px] font-medium",children:t.label})]},t.href)),(0,s.jsxs)("div",{className:"pt-3 mt-1 space-y-0.5",children:[(0,s.jsxs)("button",{type:"button",onClick:()=>T(e=>!e),className:(0,c.cn)("group flex min-h-11 w-full items-center gap-2 rounded-xl px-3 py-2 transition-all lg:min-h-9 lg:py-1",r?"text-primary":"text-text-muted hover:bg-surface-2 hover:text-text-main"),"aria-expanded":i,children:[(0,s.jsx)("p",{className:"flex-1 text-left text-[10px] font-semibold uppercase tracking-[0.14em] text-text-muted/55",children:"Advanced"}),(0,s.jsx)("span",{className:"text-[10px] font-medium text-text-subtle tabular-nums",children:j.length}),(0,s.jsx)("span",{className:(0,c.cn)("material-symbols-outlined text-[14px] transition-transform",i&&"rotate-180"),children:"expand_more"})]}),i&&j.map(t=>(0,s.jsxs)(o(),{href:t.href,onClick:e,className:(0,c.cn)(N,K(t.href)?k:w),children:[(0,s.jsx)("span",{className:C(K(t.href)),children:t.icon}),(0,s.jsx)("span",{className:"text-[13px] font-medium",children:t.label})]},t.href))]}),(0,s.jsxs)("div",{className:"pt-3 mt-2 space-y-0.5",children:[(0,s.jsx)("p",{className:"px-3 text-[10px] font-semibold text-text-muted/55 uppercase tracking-[0.14em] mb-1",children:"System"}),(0,s.jsxs)("button",{type:"button",onClick:()=>n(e=>!e),className:(0,c.cn)(N,"w-full",t.startsWith("/dashboard/media-providers")?k:w),children:[(0,s.jsx)("span",{className:C(t.startsWith("/dashboard/media-providers")),children:"perm_media"}),(0,s.jsx)("span",{className:"text-[13px] font-medium flex-1 text-left",children:"Media Providers"}),(0,s.jsx)("span",{className:(0,c.cn)("material-symbols-outlined text-[14px] transition-transform",l&&"rotate-180"),children:"expand_more"})]}),l&&(0,s.jsxs)("div",{className:"pl-4",children:[u.rj.filter(e=>b.includes(e.id)).map(r=>(0,s.jsxs)(o(),{href:`/dashboard/media-providers/${r.id}`,onClick:e,className:(0,c.cn)(N,"px-4",t.startsWith(`/dashboard/media-providers/${r.id}`)?k:w),children:[(0,s.jsx)("span",{className:(0,c.cn)(C(t.startsWith(`/dashboard/media-providers/${r.id}`)),"text-[16px]"),children:r.icon}),(0,s.jsx)("span",{className:"text-sm",children:r.label})]},r.id)),(0,s.jsxs)(o(),{href:f,onClick:e,className:(0,c.cn)(N,"px-4",t.startsWith(f)?k:w),children:[(0,s.jsx)("span",{className:(0,c.cn)(C(t.startsWith(f)),"text-[16px]"),children:"travel_explore"}),(0,s.jsx)("span",{className:"text-sm",children:"Web Fetch & Search"})]},"web")]}),y.map(t=>(0,s.jsxs)(o(),{href:t.href,onClick:e,className:(0,c.cn)(N,K(t.href)?k:w),children:[(0,s.jsx)("span",{className:C(K(t.href)),children:t.icon}),(0,s.jsx)("span",{className:"text-[13px] font-medium",children:t.label})]},t.href)),v.map(t=>"/dashboard/translator"!==t.href||q?(0,s.jsxs)(o(),{href:t.href,onClick:e,className:(0,c.cn)(N,K(t.href)?k:w),children:[(0,s.jsx)("span",{className:C(K(t.href)),children:t.icon}),(0,s.jsx)("span",{className:"text-[13px] font-medium",children:t.label})]},t.href):null),(0,s.jsxs)(o(),{href:"/dashboard/profile",onClick:e,className:(0,c.cn)(N,K("/dashboard/profile")?k:w),children:[(0,s.jsx)("span",{className:C(K("/dashboard/profile")),children:"settings"}),(0,s.jsx)("span",{className:"text-[13px] font-medium",children:"Settings"})]})]})]})]}),(0,s.jsx)(h.ConfirmModal,{isOpen:R,onClose:()=>E(!1),onConfirm:()=>{E(!1),z(!0)},title:"Update ZevaiRouter",message:`Show install command for v${P?.latestVersion||""}? You can copy it and shutdown to install manually.`,confirmText:"Show Command",cancelText:"Cancel",variant:"primary"}),($||_)&&(0,s.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/80 backdrop-blur-sm p-6",children:_?(0,s.jsx)(I,{latestVersion:P?.latestVersion,installCmd:B,copied:U,onCopyAndShutdown:V,onCancel:()=>{W.current&&(clearInterval(W.current),W.current=null),z(!1),M(0)},countdown:L,isDisconnected:$}):(0,s.jsxs)("div",{className:"text-center p-8",children:[(0,s.jsx)("div",{className:"flex items-center justify-center size-16 rounded-full bg-red-500/20 text-red-500 mx-auto mb-4",children:(0,s.jsx)("span",{className:"material-symbols-outlined text-[32px]",children:"power_off"})}),(0,s.jsx)("h2",{className:"text-xl font-semibold text-white mb-2",children:"Server Disconnected"}),(0,s.jsx)("p",{className:"text-text-muted mb-6",children:"The proxy server has been stopped."}),(0,s.jsx)(p.default,{variant:"secondary",onClick:()=>globalThis.location.reload(),children:"Reload Page"})]})})]})}function I({latestVersion:e,installCmd:t,copied:r,onCopyAndShutdown:a,onCancel:l,countdown:n,isDisconnected:i}){let o=n>0;return(0,s.jsxs)("div",{className:"w-full max-w-lg rounded-xl bg-neutral-900/95 border border-white/10 p-6 text-white",children:[(0,s.jsxs)("div",{className:"flex items-center gap-3 mb-4",children:[(0,s.jsx)("div",{className:"flex items-center justify-center size-11 rounded-full bg-amber-500/20 text-amber-400",children:(0,s.jsx)("span",{className:"material-symbols-outlined text-[24px]",children:"content_copy"})}),(0,s.jsxs)("div",{children:[(0,s.jsxs)("h2",{className:"text-lg font-semibold",children:["Update ZevaiRouter",e?` to v${e}`:""]}),(0,s.jsx)("p",{className:"text-xs text-white/60",children:i?"Server stopped. Paste the command into a terminal to install.":o?`Command copied. Server will stop in ${n}s...`:"Click the button below to copy the install command and shutdown."})]})]}),(0,s.jsx)("p",{className:"text-sm text-white/80 mb-2",children:"Install command:"}),(0,s.jsx)("div",{className:"w-full px-3 py-2 rounded bg-white/5 mb-4",children:(0,s.jsx)("code",{className:"text-xs font-mono text-amber-400 break-all",children:t})}),(0,s.jsxs)("ol",{className:"text-xs text-white/70 space-y-1 list-decimal list-inside mb-4",children:[(0,s.jsxs)("li",{children:["Click ",(0,s.jsx)("strong",{children:"Copy & Shutdown"})," below."]}),(0,s.jsx)("li",{children:"Paste the command into your terminal and press Enter."}),(0,s.jsxs)("li",{children:["Run ",(0,s.jsx)("code",{className:"px-1 rounded bg-white/10 text-green-400",children:"zevai"})," again after install."]})]}),i?(0,s.jsx)(p.default,{variant:"secondary",fullWidth:!0,onClick:()=>globalThis.location.reload(),children:"Reload Page"}):(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(p.default,{variant:"secondary",onClick:l,disabled:o,children:"Cancel"}),(0,s.jsx)(p.default,{variant:"primary",fullWidth:!0,onClick:a,disabled:o,children:r?"✓ Copied — shutting down...":o?`Shutting down in ${n}s`:"Copy & Shutdown"})]})]})}S.propTypes={onClose:n().func},I.propTypes={latestVersion:n().string,installCmd:n().string.isRequired,copied:n().bool,onCopyAndShutdown:n().func.isRequired,onCancel:n().func.isRequired,countdown:n().number,isDisconnected:n().bool}},93308:(e,t,r)=>{r.d(t,{CL:()=>l,QC:()=>o,Xn:()=>a,YZ:()=>s,il:()=>i});let s=["en","vi","zh-CN","zh-TW","ja","pt-BR","pt-PT","ko","es","de","fr","he","ar","ru","pl","cs","nl","tr","uk","tl","id","th","hi","bn","ur","ro","sv","it","el","hu","fi","da","no"],a="en",l="locale",n=["ar","he","ur"];function i(e){return n.includes(o(e))?"rtl":"ltr"}function o(e){return"zh"===e||"zh-CN"===e?"zh-CN":"en"===e?"en":"vi"===e?"vi":"zh-TW"===e?"zh-TW":"ja"===e?"ja":"pt-BR"===e?"pt-BR":"pt-PT"===e?"pt-PT":"ko"===e?"ko":"es"===e?"es":"de"===e?"de":"fr"===e?"fr":"he"===e?"he":"ar"===e?"ar":"ru"===e?"ru":"pl"===e?"pl":"cs"===e?"cs":"nl"===e?"nl":"tr"===e?"tr":"uk"===e?"uk":"tl"===e?"tl":"id"===e?"id":"th"===e?"th":"hi"===e?"hi":"bn"===e?"bn":"ur"===e?"ur":"ro"===e?"ro":"sv"===e?"sv":"it"===e?"it":"el"===e?"el":"hu"===e?"hu":"fi"===e?"fi":"da"===e?"da":"no"===e?"no":a}},94230:(e,t,r)=>{r.d(t,{default:()=>d});var s=r(95155),a=r(12115),l=r(14051),n=r.n(l),i=r(35497),o=r(11059);function d({isOpen:e,provider:t,onSuccess:r,onClose:l}){let[n,c]=(0,a.useState)("loading"),[m,u]=(0,a.useState)(""),[x,p]=(0,a.useState)(null),[h,b]=(0,a.useState)(""),[f,g]=(0,a.useState)(null),{copied:j,copy:v}=(0,o.C)();(0,a.useEffect)(()=>{e&&t&&(async()=>{try{g(null),c("loading");let e=await fetch(`/api/oauth/kiro/social-authorize?provider=${t}`),r=await e.json();if(!e.ok)throw Error(r.error);p(r),u(r.authUrl),c("input"),window.open(r.authUrl,"_blank","noopener,noreferrer")}catch(e){g(e.message),c("error")}})()},[e,t]);let y=async()=>{try{let e;g(null);try{e=new URL(h)}catch(e){throw Error("Invalid callback URL format")}let s=e.searchParams.get("code");e.searchParams.get("state");let a=e.searchParams.get("error");if(a)throw Error(e.searchParams.get("error_description")||a);if(!s)throw Error("No authorization code found in URL");let l=await fetch("/api/oauth/kiro/social-exchange",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({code:s,codeVerifier:x.codeVerifier,provider:t})}),n=await l.json();if(!l.ok)throw Error(n.error);c("success"),r?.()}catch(e){g(e.message),c("error")}},N="google"===t?"Google":"GitHub";return(0,s.jsx)(i.aF,{isOpen:e,title:`Connect Kiro via ${N}`,onClose:l,size:"lg",children:(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:["loading"===n&&(0,s.jsxs)("div",{className:"text-center py-6",children:[(0,s.jsx)("div",{className:"size-16 mx-auto mb-4 rounded-full bg-primary/10 flex items-center justify-center",children:(0,s.jsx)("span",{className:"material-symbols-outlined text-3xl text-primary animate-spin",children:"progress_activity"})}),(0,s.jsx)("h3",{className:"text-lg font-semibold mb-2",children:"Initializing..."}),(0,s.jsxs)("p",{className:"text-sm text-text-muted",children:["Setting up ",N," authentication"]})]}),"input"===n&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:"space-y-4",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"text-sm font-medium mb-2",children:"Step 1: Open this URL in your browser"}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(i.pd,{value:m,readOnly:!0,className:"flex-1 font-mono text-xs"}),(0,s.jsx)(i.$n,{variant:"secondary",icon:"auth_url"===j?"check":"content_copy",onClick:()=>v(m,"auth_url"),children:"Copy"})]})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"text-sm font-medium mb-2",children:"Step 2: Paste the callback URL here"}),(0,s.jsx)("p",{className:"text-xs text-text-muted mb-2",children:"After authorization, copy the full URL from your browser address bar."}),(0,s.jsx)(i.pd,{value:h,onChange:e=>b(e.target.value),placeholder:"kiro://kiro.kiroAgent/authenticate-success?code=...",className:"font-mono text-xs"})]})]}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(i.$n,{onClick:y,fullWidth:!0,disabled:!h,children:"Connect"}),(0,s.jsx)(i.$n,{onClick:l,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]}),"success"===n&&(0,s.jsxs)("div",{className:"text-center py-6",children:[(0,s.jsx)("div",{className:"size-16 mx-auto mb-4 rounded-full bg-green-100 dark:bg-green-900/30 flex items-center justify-center",children:(0,s.jsx)("span",{className:"material-symbols-outlined text-3xl text-green-600",children:"check_circle"})}),(0,s.jsx)("h3",{className:"text-lg font-semibold mb-2",children:"Connected Successfully!"}),(0,s.jsxs)("p",{className:"text-sm text-text-muted mb-4",children:["Your Kiro account via ",N," has been connected."]}),(0,s.jsx)(i.$n,{onClick:l,fullWidth:!0,children:"Done"})]}),"error"===n&&(0,s.jsxs)("div",{className:"text-center py-6",children:[(0,s.jsx)("div",{className:"size-16 mx-auto mb-4 rounded-full bg-red-100 dark:bg-red-900/30 flex items-center justify-center",children:(0,s.jsx)("span",{className:"material-symbols-outlined text-3xl text-red-600",children:"error"})}),(0,s.jsx)("h3",{className:"text-lg font-semibold mb-2",children:"Connection Failed"}),(0,s.jsx)("p",{className:"text-sm text-red-600 mb-4",children:f}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(i.$n,{onClick:()=>c("input"),variant:"secondary",fullWidth:!0,children:"Try Again"}),(0,s.jsx)(i.$n,{onClick:l,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})]})})}d.propTypes={isOpen:n().bool.isRequired,provider:n().oneOf(["google","github"]).isRequired,onSuccess:n().func,onClose:n().func.isRequired}},95088:(e,t,r)=>{r.d(t,{default:()=>d});var s=r(95155),a=r(12115),l=r(14051),n=r.n(l),i=r(35497);let o="https://gitlab.com";function d({isOpen:e,providerInfo:t,onSuccess:r,onClose:l}){let n,[c,m]=(0,a.useState)(null),[u,x]=(0,a.useState)(o),[p,h]=(0,a.useState)(""),[b,f]=(0,a.useState)(""),[g,j]=(0,a.useState)(""),[v,y]=(0,a.useState)(!1),[N,k]=(0,a.useState)(null),[w,C]=(0,a.useState)(!1),[S,I]=(0,a.useState)(null),T=()=>{m(null),x(o),h(""),f(""),j(""),k(null),y(!1),C(!1),I(null),l()},$=async()=>{if(!g.trim())return void k("Personal Access Token is required");y(!0),k(null);try{let e=await fetch("/api/oauth/gitlab/pat",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({token:g.trim(),baseUrl:u.trim()||o})}),t=await e.json();if(!e.ok)throw Error(t.error||"Authentication failed");r?.(),T()}catch(e){k(e.message)}finally{y(!1)}};return e?w&&S?(0,s.jsx)(i.LF,{isOpen:!0,provider:"gitlab",providerInfo:t,oauthMeta:S,onSuccess:()=>{r?.(),T()},onClose:()=>{C(!1),I(null)}}):(0,s.jsx)(i.aF,{isOpen:e,title:"Connect GitLab Duo",onClose:T,size:"lg",children:(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:[!c&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("p",{className:"text-sm text-text-muted",children:"Choose how to authenticate with GitLab Duo:"}),(0,s.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,s.jsxs)("button",{onClick:()=>m("oauth"),className:"flex flex-col items-center gap-2 p-4 rounded-lg border border-border hover:border-primary hover:bg-primary/5 transition-colors text-left",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-2xl text-primary",children:"lock_open"}),(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"text-sm font-medium",children:"OAuth App"}),(0,s.jsx)("p",{className:"text-xs text-text-muted",children:"Use a GitLab OAuth application"})]})]}),(0,s.jsxs)("button",{onClick:()=>m("pat"),className:"flex flex-col items-center gap-2 p-4 rounded-lg border border-border hover:border-primary hover:bg-primary/5 transition-colors text-left",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-2xl text-primary",children:"key"}),(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"text-sm font-medium",children:"Personal Access Token"}),(0,s.jsx)("p",{className:"text-xs text-text-muted",children:"Use a GitLab PAT with api scope"})]})]})]})]}),"oauth"===c&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("p",{className:"text-xs text-text-muted",children:["Create an OAuth app at"," ",(0,s.jsx)("a",{href:`${u.trim()||o}/-/profile/applications`,target:"_blank",rel:"noreferrer",className:"text-primary underline",children:"GitLab Applications"})," ","with redirect URI"," ",(0,s.jsx)("code",{className:"bg-sidebar px-1 rounded text-xs",children:(n=window.location.port||("https:"===window.location.protocol?"443":"80"),`http://localhost:${n}/callback`)})]}),(0,s.jsx)(i.pd,{label:"GitLab Base URL",value:u,onChange:e=>x(e.target.value),placeholder:o}),(0,s.jsx)(i.pd,{label:"Client ID",value:p,onChange:e=>h(e.target.value),placeholder:"Your OAuth application client ID"}),(0,s.jsx)(i.pd,{label:"Client Secret (optional for PKCE)",value:b,onChange:e=>f(e.target.value),placeholder:"Leave empty for public PKCE app"}),N&&(0,s.jsx)("p",{className:"text-sm text-red-500",children:N}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(i.$n,{onClick:()=>{p.trim()?(k(null),I({baseUrl:u.trim()||o,clientId:p.trim(),clientSecret:b.trim()}),C(!0)):k("Client ID is required")},fullWidth:!0,disabled:!p.trim(),children:"Authorize"}),(0,s.jsx)(i.$n,{onClick:()=>{m(null),k(null)},variant:"ghost",fullWidth:!0,children:"Back"})]})]}),"pat"===c&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("p",{className:"text-xs text-text-muted",children:["Create a PAT at"," ",(0,s.jsx)("a",{href:`${u.trim()||o}/-/user_settings/personal_access_tokens`,target:"_blank",rel:"noreferrer",className:"text-primary underline",children:"GitLab Access Tokens"})," ","with scopes: ",(0,s.jsx)("code",{className:"bg-sidebar px-1 rounded text-xs",children:"api"}),","," ",(0,s.jsx)("code",{className:"bg-sidebar px-1 rounded text-xs",children:"read_user"}),", and"," ",(0,s.jsx)("code",{className:"bg-sidebar px-1 rounded text-xs",children:"ai_features"}),"."]}),(0,s.jsx)(i.pd,{label:"GitLab Base URL",value:u,onChange:e=>x(e.target.value),placeholder:o}),(0,s.jsx)(i.pd,{label:"Personal Access Token",value:g,onChange:e=>j(e.target.value),placeholder:"glpat-xxxxxxxxxxxxxxxxxxxx",type:"password"}),N&&(0,s.jsx)("p",{className:"text-sm text-red-500",children:N}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(i.$n,{onClick:$,fullWidth:!0,disabled:!g.trim()||v,loading:v,children:"Connect"}),(0,s.jsx)(i.$n,{onClick:()=>{m(null),k(null)},variant:"ghost",fullWidth:!0,children:"Back"})]})]})]})}):null}d.propTypes={isOpen:n().bool.isRequired,providerInfo:n().shape({name:n().string}),onSuccess:n().func,onClose:n().func.isRequired}},96371:(e,t,r)=>{r.d(t,{default:()=>et});var s=r(95155),a=r(12115),l=r(73321),n=r(52679),i=r(56061),o=r(84588),d=r(14051),c=r.n(d);let m=e=>new Intl.NumberFormat().format(e||0);function u({stats:e}){let t,r=e.totalCachedTokens||0,a=e.totalPromptTokens>0?Math.min(100,r/e.totalPromptTokens*100):0,l=[{label:"Requests",value:m(e.totalRequests),icon:"send",valueClass:"text-text-main",iconClass:"bg-primary/[0.08] text-primary",detail:"All routed calls"},{label:"Input Tokens",value:m(e.totalPromptTokens),icon:"input",valueClass:"text-primary",iconClass:"bg-primary/[0.08] text-primary",detail:"Prompt and context"},{label:"Cached Tokens",value:m(r),icon:"database",valueClass:"text-info",iconClass:"bg-info/[0.08] text-info",detail:r>0?`${a.toFixed(1)}% cache rate`:"No cache hits yet"},{label:"Output Tokens",value:m(e.totalCompletionTokens),icon:"output",valueClass:"text-success",iconClass:"bg-success/[0.08] text-success",detail:"Generated responses"},{label:"Est. Cost",value:`~${(t=e.totalCost,`$${(t||0).toFixed(2)}`)}`,icon:"payments",valueClass:"text-warning",iconClass:"bg-warning/[0.08] text-warning",detail:"Estimated, not billing",className:"col-span-2 sm:col-span-1"}];return(0,s.jsx)("div",{className:"grid min-w-0 grid-cols-2 gap-3 md:grid-cols-3 xl:grid-cols-5",children:l.map(e=>(0,s.jsxs)(o.default,{padding:"none",className:`relative flex min-h-[104px] min-w-0 flex-col overflow-hidden p-3.5 sm:min-h-[112px] sm:p-4 ${e.className||""}`,children:[(0,s.jsxs)("div",{className:"flex items-start justify-between gap-2",children:[(0,s.jsx)("span",{className:"pt-0.5 text-xs font-semibold text-text-muted",children:e.label}),(0,s.jsx)("span",{className:`material-symbols-outlined flex size-7 shrink-0 items-center justify-center rounded-md text-[16px] ${e.iconClass}`,children:e.icon})]}),(0,s.jsx)("span",{className:`mt-1 truncate text-[22px] font-semibold tracking-[-0.02em] sm:text-2xl ${e.valueClass}`,children:e.value}),(0,s.jsx)("span",{className:"mt-auto text-[11px] leading-[1.3] text-text-muted",children:e.detail})]},e.label))})}u.propTypes={stats:c().object.isRequired};let x=e=>new Intl.NumberFormat().format(e||0),p=e=>`$${(e||0).toFixed(2)}`;function h(e){if(!e)return"Never";let t=Math.floor((Date.now()-new Date(e))/6e4);return t<1?"Just now":t<60?`${t}m ago`:t<1440?`${Math.floor(t/60)}h ago`:new Date(e).toLocaleDateString()}function b({field:e,currentSort:t,currentOrder:r}){return t!==e?(0,s.jsx)("span",{className:"ml-1 opacity-20",children:"↕"}):(0,s.jsx)("span",{className:"ml-1",children:"asc"===r?"↑":"↓"})}function f({item:e,viewMode:t,isSummary:r=!1}){if("tokens"===t){let t=e.cachedTokens;return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("td",{className:"px-6 py-3 text-right text-text-muted",children:r&&void 0===e.promptTokens?"—":x(e.promptTokens)}),(0,s.jsx)("td",{className:"px-6 py-3 text-right text-info",children:null==t?"—":x(t)}),(0,s.jsx)("td",{className:"px-6 py-3 text-right text-text-muted",children:r&&void 0===e.completionTokens?"—":x(e.completionTokens)}),(0,s.jsx)("td",{className:"px-6 py-3 text-right font-medium",children:x(e.totalTokens)})]})}return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("td",{className:"px-6 py-3 text-right text-text-muted",children:r&&void 0===e.inputCost?"—":p(e.inputCost)}),(0,s.jsx)("td",{className:"px-6 py-3 text-right text-text-muted",children:r&&void 0===e.outputCost?"—":p(e.outputCost)}),(0,s.jsx)("td",{className:"px-6 py-3 text-right font-medium text-warning",children:p(e.totalCost||e.cost)})]})}function g({title:e,columns:t,groupedData:r,tableType:l,sortBy:n,sortOrder:i,onToggleSort:d,viewMode:c,storageKey:m,renderDetailCells:u,renderSummaryCells:x,emptyMessage:p}){let[h,j]=(0,a.useState)(new Set);(0,a.useEffect)(()=>{try{let e=localStorage.getItem(m);e&&j(new Set(JSON.parse(e)))}catch(e){console.error(`Failed to load ${m}:`,e)}},[m]),(0,a.useEffect)(()=>{try{localStorage.setItem(m,JSON.stringify([...h]))}catch(e){console.error(`Failed to save ${m}:`,e)}},[h,m]);let v=(0,a.useCallback)(e=>{j(t=>{let r=new Set(t);return r.has(e)?r.delete(e):r.add(e),r})},[]),y=(0,a.useMemo)(()=>"tokens"===c?[{field:"promptTokens",label:"Input Tokens"},{field:"cachedTokens",label:"Cached"},{field:"completionTokens",label:"Output Tokens"},{field:"totalTokens",label:"Total Tokens"}]:[{field:"promptTokens",label:"Input Cost"},{field:"completionTokens",label:"Output Cost"},{field:"cost",label:"Total Cost"}],[c]),N=t.length+y.length;return(0,s.jsxs)(o.default,{className:"overflow-hidden",children:[(0,s.jsx)("div",{className:"p-4 border-b border-border bg-bg-subtle/50",children:(0,s.jsx)("h3",{className:"font-semibold",children:e})}),(0,s.jsx)("div",{className:"overflow-x-auto",children:(0,s.jsxs)("table",{className:"w-full text-sm text-left",children:[(0,s.jsx)("thead",{className:"bg-bg-subtle/30 text-text-muted uppercase text-xs",children:(0,s.jsxs)("tr",{children:[t.map(e=>(0,s.jsxs)("th",{className:`px-6 py-3 cursor-pointer hover:bg-bg-subtle/50 ${"right"===e.align?"text-right":""}`,onClick:()=>d(l,e.field),onKeyDown:t=>{("Enter"===t.key||" "===t.key)&&(t.preventDefault(),d(l,e.field))},role:"button",tabIndex:0,"aria-sort":n===e.field?"asc"===i?"ascending":"descending":void 0,children:[e.label," ",(0,s.jsx)(b,{field:e.field,currentSort:n,currentOrder:i})]},e.field)),y.map(e=>(0,s.jsxs)("th",{className:"px-6 py-3 text-right cursor-pointer hover:bg-bg-subtle/50",onClick:()=>d(l,e.field),onKeyDown:t=>{("Enter"===t.key||" "===t.key)&&(t.preventDefault(),d(l,e.field))},role:"button",tabIndex:0,"aria-sort":n===e.field?"asc"===i?"ascending":"descending":void 0,children:[e.label," ",(0,s.jsx)(b,{field:e.field,currentSort:n,currentOrder:i})]},e.field))]})}),(0,s.jsxs)("tbody",{className:"divide-y divide-border",children:[r.map(e=>(0,s.jsxs)(a.Fragment,{children:[(0,s.jsxs)("tr",{className:"group-summary cursor-pointer hover:bg-bg-subtle/50 transition-colors",onClick:()=>v(e.groupKey),children:[(0,s.jsx)("td",{className:"px-6 py-3",children:(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("span",{className:`material-symbols-outlined text-[18px] text-text-muted transition-transform ${h.has(e.groupKey)?"rotate-90":""}`,children:"chevron_right"}),(0,s.jsx)("span",{className:`font-medium transition-colors ${e.summary.pending>0?"text-primary":""}`,children:e.groupKey})]})}),x(e),(0,s.jsx)(f,{item:e.summary,viewMode:c,isSummary:!0})]}),h.has(e.groupKey)&&e.items.map(e=>(0,s.jsxs)("tr",{className:"group-detail hover:bg-bg-subtle/20 transition-colors",children:[u(e),(0,s.jsx)(f,{item:e,viewMode:c})]},`detail-${e.key}`))]},e.groupKey)),0===r.length&&(0,s.jsx)("tr",{children:(0,s.jsx)("td",{colSpan:N,className:"px-6 py-8 text-center text-text-muted",children:p})})]})]})})]})}b.propTypes={field:c().string.isRequired,currentSort:c().string.isRequired,currentOrder:c().string.isRequired},f.propTypes={item:c().object.isRequired,viewMode:c().string.isRequired,isSummary:c().bool},g.propTypes={title:c().string.isRequired,columns:c().arrayOf(c().shape({field:c().string.isRequired,label:c().string.isRequired,align:c().string})).isRequired,groupedData:c().array.isRequired,tableType:c().string.isRequired,sortBy:c().string.isRequired,sortOrder:c().string.isRequired,onToggleSort:c().func.isRequired,viewMode:c().string.isRequired,storageKey:c().string.isRequired,renderDetailCells:c().func.isRequired,renderSummaryCells:c().func.isRequired,emptyMessage:c().string.isRequired};var j=r(6793),v=r(81750);r(53255);var y=r(57250);function N({id:e,sourceX:t,sourceY:r,targetX:a,targetY:l,sourcePosition:n,targetPosition:i,data:o,style:d,markerEnd:c}){let[m]=(0,j.Fp)({sourceX:t,sourceY:r,targetX:a,targetY:l,sourcePosition:n,targetPosition:i}),u=o?.state;if("active"!==u&&"error"!==u&&"last"!==u)return(0,s.jsx)(v.tE,{id:e,path:m,style:d,markerEnd:c});let x="error"===u?"#ef4444":"last"===u?"#f59e0b":"#4ade80",p="error"===u?"#fca5a5":"last"===u?"#fcd34d":"#22d3ee",h=`topo-turb-${e}`;return(0,s.jsxs)("g",{className:"topology-edge-kame",children:[(0,s.jsx)("defs",{children:(0,s.jsxs)("filter",{id:h,x:"-30%",y:"-30%",width:"160%",height:"160%",children:[(0,s.jsx)("feTurbulence",{type:"fractalNoise",baseFrequency:"0.9",numOctaves:"2",seed:"2",result:"noise",children:(0,s.jsx)("animate",{attributeName:"baseFrequency",values:"0.8;1.4;0.8",dur:"0.25s",repeatCount:"indefinite"})}),(0,s.jsx)("feDisplacementMap",{in:"SourceGraphic",in2:"noise",scale:"3.5",xChannelSelector:"R",yChannelSelector:"G"})]})}),(0,s.jsx)("path",{d:m,fill:"none",stroke:p,strokeWidth:"10",strokeLinecap:"round",opacity:"0.25",filter:`url(#${h})`,className:"topology-edge-halo"}),(0,s.jsx)("path",{d:m,fill:"none",stroke:x,strokeWidth:"5",strokeLinecap:"round",opacity:"0.7",filter:`url(#${h})`,className:"topology-edge-plasma"}),(0,s.jsx)(v.tE,{id:e,path:m,style:{...d,stroke:"#f8fafc",strokeWidth:2.2,opacity:.95},markerEnd:c}),Array.from({length:5},(e,t)=>(0,s.jsx)("circle",{r:2.4-.25*t,fill:t%2==0?"#ffffff":p,children:(0,s.jsx)("animateMotion",{dur:`${.4+.08*t}s`,repeatCount:"indefinite",path:m,begin:`${.09*t}s`})},`p${t}`)),Array.from({length:3},(e,t)=>(0,s.jsxs)("circle",{r:"1.6",fill:x,children:[(0,s.jsx)("animate",{attributeName:"opacity",values:"0;1;0",dur:`${.6+.2*t}s`,repeatCount:"indefinite",begin:`${.2*t}s`}),(0,s.jsx)("animateMotion",{dur:`${1.1+.3*t}s`,repeatCount:"indefinite",path:m,begin:`${.25*t}s`})]},`s${t}`))]})}N.propTypes={id:c().string.isRequired,sourceX:c().number.isRequired,sourceY:c().number.isRequired,targetX:c().number.isRequired,targetY:c().number.isRequired,sourcePosition:c().string,targetPosition:c().string,data:c().object,style:c().object,markerEnd:c().string};let k={padding:.14,duration:200};function w(e){return n.Q2[e]||{color:"#6b7280",name:e}}function C(e){return`/providers/${e}.png`}function S({data:e}){let{label:t,color:r,imageUrl:a,textIcon:l,active:n}=e;return(0,s.jsxs)("div",{className:"flex items-center gap-2 rounded-lg border bg-surface px-3 py-2 transition-all duration-300",style:{borderColor:n?r:"var(--color-border)",boxShadow:n?`0 0 12px ${r}30`:"none",minWidth:"140px"},children:[(0,s.jsx)(v.h7,{type:"target",position:j.yX.Top,id:"top",className:"!bg-transparent !border-0 !w-0 !h-0"}),(0,s.jsx)(v.h7,{type:"target",position:j.yX.Bottom,id:"bottom",className:"!bg-transparent !border-0 !w-0 !h-0"}),(0,s.jsx)(v.h7,{type:"target",position:j.yX.Left,id:"left",className:"!bg-transparent !border-0 !w-0 !h-0"}),(0,s.jsx)(v.h7,{type:"target",position:j.yX.Right,id:"right",className:"!bg-transparent !border-0 !w-0 !h-0"}),(0,s.jsx)("div",{className:"flex size-7 shrink-0 items-center justify-center rounded-md",style:{backgroundColor:`${r}15`},children:(0,s.jsx)(y.A,{src:a,alt:t,size:20,className:"size-5 rounded-sm object-contain",fallbackText:l,fallbackColor:r})}),(0,s.jsx)("span",{className:"truncate text-sm font-medium",style:{color:n?r:"var(--color-text)"},children:t}),n&&(0,s.jsxs)("span",{className:"relative flex h-2 w-2 shrink-0",children:[(0,s.jsx)("span",{className:"animate-ping absolute inline-flex h-full w-full rounded-full opacity-75",style:{backgroundColor:r}}),(0,s.jsx)("span",{className:"relative inline-flex rounded-full h-2 w-2",style:{backgroundColor:r}})]})]})}function I({data:e}){return(0,s.jsxs)("div",{className:"flex min-w-[118px] items-center justify-center rounded-lg border border-primary bg-primary/[0.06] px-4 py-2.5 shadow-sm",children:[(0,s.jsx)(v.h7,{type:"source",position:j.yX.Top,id:"top",className:"!bg-transparent !border-0 !w-0 !h-0"}),(0,s.jsx)(v.h7,{type:"source",position:j.yX.Bottom,id:"bottom",className:"!bg-transparent !border-0 !w-0 !h-0"}),(0,s.jsx)(v.h7,{type:"source",position:j.yX.Left,id:"left",className:"!bg-transparent !border-0 !w-0 !h-0"}),(0,s.jsx)(v.h7,{type:"source",position:j.yX.Right,id:"right",className:"!bg-transparent !border-0 !w-0 !h-0"}),(0,s.jsx)("img",{src:"/favicon.svg",alt:"ZevaiRouter",className:"mr-2 size-5"}),(0,s.jsx)("span",{className:"text-xs font-semibold text-primary",children:"ZevaiRouter"}),e.activeCount>0&&(0,s.jsx)("span",{className:"ml-2 rounded-full bg-primary px-1.5 py-0.5 text-[10px] font-semibold text-white",children:e.activeCount})]})}S.propTypes={data:c().object.isRequired},I.propTypes={data:c().object.isRequired};let T={provider:S,router:I},$={topology:N};function A({provider:e,status:t}){let r=w(e.provider),a=(r.name!==e.provider?r.name:null)||e.name||e.provider,l={active:{label:"Live traffic",color:"text-success",dot:"bg-success"},error:{label:"Last request failed",color:"text-error",dot:"bg-error"},last:{label:"Last route",color:"text-warning",dot:"bg-warning"},available:{label:"Available",color:"text-text-muted",dot:"bg-text-subtle"}}[t];return(0,s.jsxs)("div",{className:"flex min-h-14 items-center gap-3 rounded-xl border border-border-subtle bg-surface px-3 py-2.5",children:[(0,s.jsx)("div",{className:"flex size-9 shrink-0 items-center justify-center rounded-lg ring-1 ring-black/[0.04] dark:ring-white/[0.06]",style:{backgroundColor:`${r.color||"#6b7280"}15`},children:(0,s.jsx)(y.A,{src:C(e.provider),alt:"",size:26,className:"max-h-[26px] max-w-[26px] rounded-md object-contain",fallbackText:r.textIcon||(e.provider||"?").slice(0,2).toUpperCase(),fallbackColor:r.color})}),(0,s.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,s.jsx)("p",{className:"truncate text-sm font-semibold text-text-main",children:a}),(0,s.jsxs)("p",{className:`mt-0.5 flex items-center gap-1.5 text-[11px] font-medium ${l.color}`,children:[(0,s.jsx)("span",{className:`size-1.5 shrink-0 rounded-full ${l.dot} ${"active"===t?"animate-pulse":""}`}),l.label]})]}),(0,s.jsx)("span",{"aria-hidden":"true",className:"material-symbols-outlined text-[18px] text-text-subtle",children:"arrow_forward"})]})}function P({providers:e=[],activeRequests:t=[],lastProvider:r="",errorProvider:l=""}){let n=(0,a.useMemo)(()=>t.map(e=>e.provider?.toLowerCase()).filter(Boolean).sort().join(","),[t]),i=r?.toLowerCase()||"",o=l?.toLowerCase()||"",d=(0,a.useMemo)(()=>new Set(n?n.split(","):[]),[n]),c=(0,a.useMemo)(()=>new Set(i?[i]:[]),[i]),m=(0,a.useMemo)(()=>new Set(o?[o]:[]),[o]),u=(0,a.useRef)({}),[x,p]=(0,a.useState)(0),[h,b]=(0,a.useState)(!1),[f,g]=(0,a.useState)(!1);(0,a.useEffect)(()=>{let e=window.matchMedia("(min-width: 640px)"),t=()=>b(e.matches);return t(),e.addEventListener("change",t),()=>e.removeEventListener("change",t)},[]),(0,a.useEffect)(()=>{let e=u.current,t=Date.now();for(let r of d)e[r]||(e[r]=t);for(let t of Object.keys(e))d.has(t)||delete e[t]},[d]),(0,a.useEffect)(()=>{if(0===d.size)return;let e=setInterval(()=>p(e=>e+1),1e3);return()=>clearInterval(e)},[d]);let j=(0,a.useMemo)(()=>{let e=Date.now(),t=new Set;for(let r of d){let s=u.current[r];(!s||e-s<6e4)&&t.add(r)}return t},[d,x]),{nodes:y,edges:N}=(0,a.useMemo)(()=>(function(e,t,r,s){let a=e.length,l=Math.max(270,180*a/(2*Math.PI)),n=Math.max(150,.52*l);if(0===a)return{nodes:[{id:"router",type:"router",position:{x:0,y:0},data:{activeCount:0},draggable:!1}],edges:[]};let i=[],o=[];return i.push({id:"router",type:"router",position:{x:-59,y:-20},data:{activeCount:t.size},draggable:!1}),e.forEach((e,d)=>{let c,m,u=w(e.provider),x=t.has(e.provider?.toLowerCase()),p=!x&&r.has(e.provider?.toLowerCase()),h=!x&&s.has(e.provider?.toLowerCase()),b=`provider-${e.provider}`,f={label:(u.name!==e.provider?u.name:null)||e.name||e.provider,color:u.color||"#6b7280",imageUrl:C(e.provider),textIcon:u.textIcon||(e.provider||"?").slice(0,2).toUpperCase(),active:x},g=-Math.PI/2+2*Math.PI*d/a,j=l*Math.cos(g),v=n*Math.sin(g);Math.abs(g+Math.PI/2)<Math.PI/4||Math.abs(g-3*Math.PI/2)<Math.PI/4?(c="top",m="bottom"):Math.abs(g-Math.PI/2)<Math.PI/4?(c="bottom",m="top"):j>0?(c="right",m="left"):(c="left",m="right"),i.push({id:b,type:"provider",position:{x:j-80,y:v-22},data:f,draggable:!1});o.push({id:`e-${b}`,type:"topology",source:"router",sourceHandle:c,target:b,targetHandle:m,data:{state:h?"error":x?"active":p?"last":"idle"},style:(u.color,h?{stroke:"#ef4444",strokeWidth:2.5,opacity:.9}:x?{stroke:"#4ade80",strokeWidth:2.5,opacity:.9}:p?{stroke:"#f59e0b",strokeWidth:2,opacity:.7}:{stroke:"var(--color-border)",strokeWidth:1,opacity:.3})})}),{nodes:i,edges:o}})(e,j,c,m),[e,j,c,m]),S=(0,a.useMemo)(()=>{let t={active:0,error:1,last:2,available:3};return e.map(e=>{let t=e.provider?.toLowerCase();return{provider:e,status:j.has(t)?"active":m.has(t)?"error":c.has(t)?"last":"available"}}).sort((e,r)=>{let s=t[e.status]-t[r.status];if(0!==s)return s;let a=w(e.provider.provider).name||e.provider.name||e.provider.provider,l=w(r.provider.provider).name||r.provider.name||r.provider.provider;return a.localeCompare(l)})},[e,j,m,c]),I=f?S:S.slice(0,6),O=(0,a.useMemo)(()=>e.map(e=>e.provider).sort().join(","),[e]),R=(0,a.useRef)(null),E=(0,a.useRef)(null),_=(0,a.useCallback)(e=>{R.current=e,setTimeout(()=>e.fitView(k),50)},[]);return(0,a.useEffect)(()=>{let e=E.current;if(!e)return;let t=new ResizeObserver(()=>{R.current&&R.current.fitView(k)});return t.observe(e),()=>t.disconnect()},[h]),(0,a.useEffect)(()=>{if(R.current){let e=setTimeout(()=>R.current.fitView(k),50);return()=>clearTimeout(e)}},[y.length]),(0,s.jsxs)("div",{ref:h?E:void 0,className:"flex w-full min-w-0 flex-col overflow-hidden rounded-[14px] border border-border-subtle bg-surface/94 shadow-[0_14px_34px_-26px_rgba(15,23,42,0.28)] sm:h-[440px]",children:[(0,s.jsxs)("div",{className:"flex shrink-0 items-center justify-between border-b border-border-subtle bg-surface/75 px-4 py-3.5",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-[17px] text-primary",children:"route"}),(0,s.jsx)("span",{className:"text-xs font-semibold text-text-main",children:"Routing map"})]}),(0,s.jsxs)("span",{className:"text-[11px] font-medium text-text-muted",children:[e.length," ",1===e.length?"provider":"providers"]})]}),(0,s.jsx)("div",{className:"min-h-0 flex-1 bg-bg/35",children:0===e.length?(0,s.jsx)("div",{className:"flex min-h-56 items-center justify-center text-sm text-text-muted sm:h-full sm:min-h-0",children:"No providers connected"}):h?(0,s.jsx)(v.Gc,{nodes:y,edges:N,nodeTypes:T,edgeTypes:$,fitView:!0,fitViewOptions:k,minZoom:.1,maxZoom:2,onInit:_,proOptions:{hideAttribution:!0},panOnDrag:!0,zoomOnScroll:!0,zoomOnPinch:!0,zoomOnDoubleClick:!0,preventScrolling:!1,nodesDraggable:!1,nodesConnectable:!1,elementsSelectable:!1,children:(0,s.jsx)(v.H2,{showInteractive:!1,className:"react-flow-controls-custom"})},O):(0,s.jsxs)("div",{className:"p-3",children:[(0,s.jsxs)("div",{className:"mb-3 flex items-center gap-3 rounded-xl border border-primary/20 bg-primary/[0.06] px-3 py-3",children:[(0,s.jsx)("span",{className:"flex size-10 shrink-0 items-center justify-center rounded-xl bg-primary/10 ring-1 ring-primary/15",children:(0,s.jsx)("img",{src:"/favicon.svg",alt:"",className:"size-6"})}),(0,s.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,s.jsx)("p",{className:"text-sm font-semibold text-primary",children:"ZevaiRouter"}),(0,s.jsx)("p",{className:"mt-0.5 text-[11px] text-text-muted",children:"Routes requests to healthy providers"})]}),j.size>0&&(0,s.jsxs)("span",{className:"rounded-full bg-success/10 px-2 py-1 text-[10px] font-semibold text-success",children:[j.size," live"]})]}),(0,s.jsx)("div",{className:"ml-7 h-3 w-px bg-border","aria-hidden":"true"}),(0,s.jsx)("div",{className:"space-y-2",children:I.map(({provider:e,status:t})=>(0,s.jsx)(A,{provider:e,status:t},e.provider))}),S.length>6&&(0,s.jsxs)("button",{type:"button",onClick:()=>g(e=>!e),className:"mt-3 flex h-11 w-full items-center justify-center gap-1.5 rounded-xl border border-border bg-surface text-xs font-medium text-text-main transition-colors hover:border-primary/30 hover:text-primary","aria-expanded":f,children:[f?"Show fewer providers":`Show ${S.length-6} more providers`,(0,s.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:f?"expand_less":"expand_more"})]})]})})]})}A.propTypes={provider:c().shape({provider:c().string.isRequired,name:c().string}).isRequired,status:c().oneOf(["active","error","last","available"]).isRequired},P.propTypes={providers:c().arrayOf(c().shape({id:c().string,provider:c().string,name:c().string})),activeRequests:c().arrayOf(c().shape({provider:c().string,model:c().string,account:c().string})),lastProvider:c().string,errorProvider:c().string};var O=r(21742),R=r(63346),E=r(28408),_=r(32539),z=r(59656),L=r(55433),M=r(40968);let q=e=>e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:String(e||0),D=e=>`$${(e||0).toFixed(4)}`,U={today:"Today","24h":"Last 24 hours","7d":"Last 7 days","30d":"Last 30 days","60d":"Last 60 days"};function F({period:e="7d"}){let[t,r]=(0,a.useState)([]),[l,n]=(0,a.useState)(!0),[i,d]=(0,a.useState)(null),[c,m]=(0,a.useState)("tokens"),u=(0,a.useRef)({sequence:0,controller:null}),x=(0,a.useCallback)(async()=>{u.current.controller?.abort();let t=new AbortController,s=u.current.sequence+1;u.current={sequence:s,controller:t},n(!0),d(null);try{let a=await fetch(`/api/usage/chart?period=${e}`,{signal:t.signal});if(s!==u.current.sequence)return;if(!a.ok)throw Error(`HTTP ${a.status}`);let l=await a.json();r(l)}catch(e){if(e?.name==="AbortError"||s!==u.current.sequence)return;console.error("Failed to fetch chart data:",e),d("Failed to load chart data")}finally{s===u.current.sequence&&n(!1)}},[e]);(0,a.useEffect)(()=>(x(),()=>{u.current.controller?.abort(),u.current.sequence+=1}),[x]);let p=t.some(e=>e.tokens>0||e.cost>0);return(0,s.jsxs)(o.default,{className:"flex min-w-0 flex-col gap-5 p-4 sm:p-5",children:[(0,s.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"text-sm font-semibold text-text-main",children:"Usage trend"}),(0,s.jsxs)("p",{className:"mt-0.5 text-[11px] text-text-muted",children:[U[e]||e," \xb7 routed traffic over time"]})]}),(0,s.jsxs)("div",{className:"grid w-full grid-cols-2 items-center gap-1 rounded-lg border border-border bg-bg-subtle p-1 sm:w-auto",children:[(0,s.jsx)("button",{type:"button",onClick:()=>m("tokens"),className:`rounded-md px-3 py-1 text-sm font-medium transition-colors ${"tokens"===c?"bg-primary text-white shadow-sm":"text-text-muted hover:bg-bg-hover hover:text-text"}`,children:"Tokens"}),(0,s.jsx)("button",{type:"button",onClick:()=>m("cost"),className:`rounded-md px-3 py-1 text-sm font-medium transition-colors ${"cost"===c?"bg-primary text-white shadow-sm":"text-text-muted hover:bg-bg-hover hover:text-text"}`,children:"Cost"})]})]}),l?(0,s.jsx)("div",{className:"h-48 flex items-center justify-center text-text-muted text-sm",children:"Loading..."}):i?(0,s.jsxs)("div",{className:"h-48 flex flex-col items-center justify-center gap-2 text-text-muted text-sm",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-[24px] text-red-500",children:"error"}),(0,s.jsx)("p",{children:i}),(0,s.jsx)("button",{type:"button",onClick:x,className:"rounded-lg border border-border px-3 py-1 text-xs font-medium text-text-main transition-colors hover:bg-bg-hover",children:"Retry"})]}):p?(0,s.jsx)(O.u,{width:"100%",height:220,children:(0,s.jsxs)(R.Q,{data:t,margin:{top:4,right:8,left:0,bottom:0},children:[(0,s.jsxs)("defs",{children:[(0,s.jsxs)("linearGradient",{id:"gradTokens",x1:"0",y1:"0",x2:"0",y2:"1",children:[(0,s.jsx)("stop",{offset:"5%",stopColor:"#6366f1",stopOpacity:.25}),(0,s.jsx)("stop",{offset:"95%",stopColor:"#6366f1",stopOpacity:0})]}),(0,s.jsxs)("linearGradient",{id:"gradCost",x1:"0",y1:"0",x2:"0",y2:"1",children:[(0,s.jsx)("stop",{offset:"5%",stopColor:"#f59e0b",stopOpacity:.25}),(0,s.jsx)("stop",{offset:"95%",stopColor:"#f59e0b",stopOpacity:0})]})]}),(0,s.jsx)(E.d,{strokeDasharray:"3 3",strokeOpacity:.1}),(0,s.jsx)(_.W,{dataKey:"label",tick:{fontSize:10,fill:"currentColor",fillOpacity:.5},tickLine:!1,axisLine:!1,interval:"preserveStartEnd"}),(0,s.jsx)(z.h,{tick:{fontSize:10,fill:"currentColor",fillOpacity:.5},tickLine:!1,axisLine:!1,tickFormatter:"tokens"===c?q:D,width:50}),(0,s.jsx)(L.m,{contentStyle:{backgroundColor:"var(--color-bg)",border:"1px solid var(--color-border)",borderRadius:"8px",fontSize:"12px"},formatter:(e,t)=>"tokens"===t?[q(e),"Tokens"]:[D(e),"Cost"]}),"tokens"===c?(0,s.jsx)(M.Gk,{type:"monotone",dataKey:"tokens",stroke:"#6366f1",strokeWidth:2,fill:"url(#gradTokens)",dot:!1,activeDot:{r:4}}):(0,s.jsx)(M.Gk,{type:"monotone",dataKey:"cost",stroke:"#f59e0b",strokeWidth:2,fill:"url(#gradCost)",dot:!1,activeDot:{r:4}})]})}):(0,s.jsx)("div",{className:"h-48 flex items-center justify-center text-text-muted text-sm",children:"No data for this period"})]})}function W(e){let t=n.Q2[e];return!t?.serviceKinds||t.serviceKinds.includes("llm")}function B({timestamp:e}){let t,[,r]=(0,a.useState)(0);return(0,a.useEffect)(()=>{let e=setInterval(()=>r(e=>e+1),1e3);return()=>clearInterval(e)},[]),(0,s.jsx)("time",{dateTime:e,title:new Date(e).toLocaleString(),children:(t=Math.max(0,Math.floor((Date.now()-new Date(e))/1e3)))<60?`${t}s ago`:t<3600?`${Math.floor(t/60)}m ago`:t<86400?`${Math.floor(t/3600)}h ago`:`${Math.floor(t/86400)}d ago`})}F.propTypes={period:c().string};let K={live:{label:"Live",title:"Usage stream connected",className:"bg-success/10 text-success",dotClassName:"bg-success animate-pulse"},reconnecting:{label:"Reconnecting",title:"Usage stream disconnected; reconnecting automatically",className:"bg-warning/10 text-warning",dotClassName:"bg-warning animate-pulse"},connecting:{label:"Connecting",title:"Connecting to the live usage stream",className:"bg-primary/10 text-primary",dotClassName:"bg-primary animate-pulse"}};function V({requests:e=[],streamStatus:t="connecting"}){let r=K[t]||K.connecting;return(0,s.jsxs)(o.default,{className:"flex h-[420px] min-w-0 flex-col overflow-hidden sm:h-[440px]",padding:"none",children:[(0,s.jsxs)("div",{className:"flex shrink-0 items-center justify-between border-b border-border-subtle bg-surface/75 px-4 py-3.5",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-[17px] text-primary",children:"monitor_heart"}),(0,s.jsx)("span",{className:"text-xs font-semibold text-text-main",children:"Recent requests"})]}),(0,s.jsxs)("span",{className:`inline-flex items-center gap-1.5 rounded-full px-2 py-1 text-[10px] font-semibold ${r.className}`,title:r.title,children:[(0,s.jsx)("span",{"aria-hidden":"true",className:`size-1.5 rounded-full ${r.dotClassName}`}),r.label]})]}),e.length?(0,s.jsx)("div",{className:"flex-1 overflow-x-auto overflow-y-auto px-4 pb-3",children:(0,s.jsxs)("table",{className:"w-full min-w-[300px] border-collapse text-xs",children:[(0,s.jsx)("thead",{className:"sticky top-0 z-10 bg-surface/95 backdrop-blur-sm",children:(0,s.jsxs)("tr",{className:"border-b border-border",children:[(0,s.jsx)("th",{className:"w-2 py-1.5 text-left font-semibold text-text-muted",children:(0,s.jsx)("span",{className:"sr-only",children:"Status"})}),(0,s.jsx)("th",{className:"py-1.5 text-left font-semibold text-text-muted",children:"Model"}),(0,s.jsx)("th",{className:"py-1.5 text-right font-semibold text-text-muted whitespace-nowrap",children:"In / Out"}),(0,s.jsx)("th",{className:"py-1.5 text-right font-semibold text-text-muted",children:"When"})]})}),(0,s.jsx)("tbody",{className:"divide-y divide-border/50",children:e.map((e,t)=>{let r=function(e){if(!e)return!0;let t=String(e).trim().toLowerCase();return"ok"===t||"success"===t||"succeeded"===t||/^2\d\d(?:\s|$)/.test(t)}(e.status),a=r?"Succeeded":"Failed",l=n.Q2[e.provider]?.name||n.IS[e.provider]?.name||e.provider||"Unknown provider";return(0,s.jsxs)("tr",{className:"transition-colors hover:bg-bg-subtle",children:[(0,s.jsx)("td",{className:"py-1.5",title:a,children:(0,s.jsx)("span",{role:"img","aria-label":a,className:`block size-1.5 rounded-full ${r?"bg-success":"bg-error"}`})}),(0,s.jsxs)("td",{className:"min-w-0 py-1.5 pr-2",children:[(0,s.jsx)("div",{className:"max-w-[132px] truncate font-mono",title:e.model,children:e.model}),(0,s.jsx)("div",{className:"mt-0.5 max-w-[132px] truncate text-[10px] font-medium text-text-subtle",title:l,children:l})]}),(0,s.jsxs)("td",{className:"py-1.5 text-right font-mono tabular-nums whitespace-nowrap",children:[(0,s.jsxs)("span",{className:"text-primary",children:[x(e.promptTokens),"↑"]})," ",(0,s.jsxs)("span",{className:"text-success",children:[x(e.completionTokens),"↓"]})]}),(0,s.jsx)("td",{className:"py-1.5 text-right text-text-muted whitespace-nowrap",children:(0,s.jsx)(B,{timestamp:e.timestamp})})]},`${e.timestamp}-${e.model}-${e.provider}-${e.promptTokens}-${e.completionTokens}-${t}`)})})]})}):(0,s.jsx)("div",{className:"flex-1 flex items-center justify-center text-text-muted text-sm",children:"No requests yet."})]})}function J(e,t={},r,s){return Object.entries(e||{}).map(([e,r])=>{let s=(r.promptTokens||0)+(r.completionTokens||0),a=r.cost||0,l=s>0?(r.promptTokens||0)*(a/s):0,n=s>0?(r.completionTokens||0)*(a/s):0;return{...r,key:e,totalTokens:s,totalCost:a,inputCost:l,outputCost:n,pending:t[e]||0}}).sort((e,t)=>{let a=e[r],l=t[r];return("string"==typeof a&&(a=a.toLowerCase()),"string"==typeof l&&(l=l.toLowerCase()),a<l)?"asc"===s?-1:1:a>l?"asc"===s?1:-1:0})}function G(e,t){if(!Array.isArray(e))return[];let r={};return e.forEach(e=>{let s=function(e,t){switch(t){case"rawModel":return e.rawModel||"Unknown Model";case"accountName":return e.accountName||(e.connectionId?`Account ${e.connectionId.slice(0,8)}...`:"Unknown Account");case"keyName":return e.keyName||"Unknown Key";case"endpoint":return e.endpoint||"Unknown Endpoint";default:return e[t]||"Unknown"}}(e,t);r[s]||(r[s]={groupKey:s,summary:{requests:0,promptTokens:0,completionTokens:0,cachedTokens:0,totalTokens:0,cost:0,inputCost:0,outputCost:0,lastUsed:null,pending:0},items:[]});let a=r[s].summary;a.requests+=e.requests||0,a.promptTokens+=e.promptTokens||0,a.completionTokens+=e.completionTokens||0,a.cachedTokens+=e.cachedTokens||0,a.totalTokens+=e.totalTokens||0,a.cost+=e.cost||0,a.inputCost+=e.inputCost||0,a.outputCost+=e.outputCost||0,a.pending+=e.pending||0,e.lastUsed&&(!a.lastUsed||new Date(e.lastUsed)>new Date(a.lastUsed))&&(a.lastUsed=e.lastUsed),r[s].items.push(e)}),Object.values(r)}let H=[{field:"rawModel",label:"Model"},{field:"provider",label:"Provider"},{field:"requests",label:"Requests",align:"right"},{field:"lastUsed",label:"Last Used",align:"right"}],Q=[{field:"accountName",label:"Account"},{field:"rawModel",label:"Model"},{field:"provider",label:"Provider"},{field:"requests",label:"Requests",align:"right"},{field:"lastUsed",label:"Last Used",align:"right"}],X=[{field:"keyName",label:"API Key Name"},{field:"rawModel",label:"Model"},{field:"provider",label:"Provider"},{field:"requests",label:"Requests",align:"right"},{field:"lastUsed",label:"Last Used",align:"right"}],Z=[{field:"endpoint",label:"Endpoint"},{field:"rawModel",label:"Model"},{field:"provider",label:"Provider"},{field:"requests",label:"Requests",align:"right"},{field:"lastUsed",label:"Last Used",align:"right"}],Y=[{value:"model",label:"Usage by Model"},{value:"account",label:"Usage by Account"},{value:"apiKey",label:"Usage by API Key"},{value:"endpoint",label:"Usage by Endpoint"}],ee=[{value:"today",label:"Today"},{value:"24h",label:"24h"},{value:"7d",label:"7D"},{value:"30d",label:"30D"},{value:"60d",label:"60D"}];function et({period:e,setPeriod:t,hidePeriodSelector:r=!1}={}){let o=(0,l.useRouter)(),d=(0,l.useSearchParams)(),c=d.get("sortBy")||"rawModel",m=d.get("sortOrder")||"asc",[p,b]=(0,a.useState)(null),[f,j]=(0,a.useState)(!0),[v,y]=(0,a.useState)(!1),[N,k]=(0,a.useState)(!1),[w,C]=(0,a.useState)("model"),[S,I]=(0,a.useState)("costs"),[T,$]=(0,a.useState)([]),[A,O]=(0,a.useState)("connecting"),[R,E]=(0,a.useState)("today"),_=(0,a.useRef)(!0),z=(0,a.useRef)({sequence:0,controller:null}),L=e??R,M=t??E;(0,a.useEffect)(()=>{fetch("/api/providers").then(e=>e.ok?e.json():null).then(e=>{let t=new Set;$([...(e?.connections||[]).filter(e=>!(!1===e.isActive||!W(e.provider)||t.has(e.provider))&&(t.add(e.provider),!0)),...Object.values(n.IS).filter(e=>e.noAuth&&!t.has(e.id)&&W(e.id)).map(e=>({provider:e.id,name:e.name}))])}).catch(()=>{})},[]),(0,a.useEffect)(()=>{z.current.controller?.abort();let e=new AbortController,t=z.current.sequence+1,r=!0===z.current.hasData;return z.current={sequence:t,controller:e,hasData:r},_.current?(_.current=!1,j(!0)):y(!0),fetch(`/api/usage/stats?period=${L}`,{signal:e.signal}).then(e=>e.ok?e.json():null).then(e=>{t===z.current.sequence&&(e?(b(t=>({...t,...e})),k(!1),z.current.hasData=!0):k(!0))}).catch(e=>{e?.name==="AbortError"||t===z.current.sequence&&k(!0)}).finally(()=>{t===z.current.sequence&&(j(!1),y(!1))}),()=>{z.current.controller?.abort(),z.current.sequence+=1}},[L]),(0,a.useEffect)(()=>{let e=new EventSource("/api/usage/stream");return e.onopen=()=>O("live"),e.onmessage=e=>{try{let t=JSON.parse(e.data);b(e=>e?{...e,activeRequests:t.activeRequests,recentRequests:t.recentRequests,errorProvider:t.errorProvider,pending:t.pending}:e),z.current.hasData&&j(!1)}catch(e){console.error("[SSE CLIENT] parse error:",e)}},e.onerror=()=>{O("reconnecting"),z.current.hasData&&j(!1)},()=>e.close()},[]);let q=(0,a.useCallback)((e,t)=>{let r=new URLSearchParams(d.toString());r.get("sortBy")===t?r.set("sortOrder","asc"===r.get("sortOrder")?"desc":"asc"):(r.set("sortBy",t),r.set("sortOrder","asc")),o.replace(`?${r.toString()}`,{scroll:!1})},[d,o]),D=(0,a.useMemo)(()=>{if(!p)return null;switch(w){case"model":{let e=p.pending?.byModel||{};return{columns:H,groupedData:G(J(p.byModel,e,c,m),"rawModel"),storageKey:"usage-stats:expanded-models",emptyMessage:"No usage recorded yet.",renderSummaryCells:e=>(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("td",{className:"px-6 py-3 text-text-muted",children:"—"}),(0,s.jsx)("td",{className:"px-6 py-3 text-right",children:x(e.summary.requests)}),(0,s.jsx)("td",{className:"px-6 py-3 text-right text-text-muted whitespace-nowrap",children:h(e.summary.lastUsed)})]}),renderDetailCells:e=>(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("td",{className:`px-6 py-3 font-medium transition-colors ${e.pending>0?"text-primary":""}`,children:e.rawModel}),(0,s.jsx)("td",{className:"px-6 py-3",children:(0,s.jsx)(i.default,{variant:e.pending>0?"primary":"neutral",size:"sm",children:e.provider})}),(0,s.jsx)("td",{className:"px-6 py-3 text-right",children:x(e.requests)}),(0,s.jsx)("td",{className:"px-6 py-3 text-right text-text-muted whitespace-nowrap",children:h(e.lastUsed)})]})}}case"account":{let e={};return p?.pending?.byAccount&&Object.entries(p.byAccount||{}).forEach(([t,r])=>{e[t]=function(e={},t={}){let r=t[e.connectionId];if(!r)return 0;let s=e.providerId||e.provider;return r[s?`${e.rawModel} (${s})`:e.rawModel]||0}(r,p.pending.byAccount)}),{columns:Q,groupedData:G(J(p.byAccount,e,c,m),"accountName"),storageKey:"usage-stats:expanded-accounts",emptyMessage:"No account-specific usage recorded yet.",renderSummaryCells:e=>(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("td",{className:"px-6 py-3 text-text-muted",children:"—"}),(0,s.jsx)("td",{className:"px-6 py-3 text-text-muted",children:"—"}),(0,s.jsx)("td",{className:"px-6 py-3 text-right",children:x(e.summary.requests)}),(0,s.jsx)("td",{className:"px-6 py-3 text-right text-text-muted whitespace-nowrap",children:h(e.summary.lastUsed)})]}),renderDetailCells:e=>(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("td",{className:`px-6 py-3 font-medium transition-colors ${e.pending>0?"text-primary":""}`,children:e.accountName||`Account ${e.connectionId?.slice(0,8)}...`}),(0,s.jsx)("td",{className:`px-6 py-3 font-medium transition-colors ${e.pending>0?"text-primary":""}`,children:e.rawModel}),(0,s.jsx)("td",{className:"px-6 py-3",children:(0,s.jsx)(i.default,{variant:e.pending>0?"primary":"neutral",size:"sm",children:e.provider})}),(0,s.jsx)("td",{className:"px-6 py-3 text-right",children:x(e.requests)}),(0,s.jsx)("td",{className:"px-6 py-3 text-right text-text-muted whitespace-nowrap",children:h(e.lastUsed)})]})}}case"apiKey":return{columns:X,groupedData:G(J(p.byApiKey,{},c,m),"keyName"),storageKey:"usage-stats:expanded-apikeys",emptyMessage:"No API key usage recorded yet.",renderSummaryCells:e=>(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("td",{className:"px-6 py-3 text-text-muted",children:"—"}),(0,s.jsx)("td",{className:"px-6 py-3 text-text-muted",children:"—"}),(0,s.jsx)("td",{className:"px-6 py-3 text-right",children:x(e.summary.requests)}),(0,s.jsx)("td",{className:"px-6 py-3 text-right text-text-muted whitespace-nowrap",children:h(e.summary.lastUsed)})]}),renderDetailCells:e=>(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("td",{className:"px-6 py-3 font-medium",children:e.keyName}),(0,s.jsx)("td",{className:"px-6 py-3",children:e.rawModel}),(0,s.jsx)("td",{className:"px-6 py-3",children:(0,s.jsx)(i.default,{variant:"neutral",size:"sm",children:e.provider})}),(0,s.jsx)("td",{className:"px-6 py-3 text-right",children:x(e.requests)}),(0,s.jsx)("td",{className:"px-6 py-3 text-right text-text-muted whitespace-nowrap",children:h(e.lastUsed)})]})};default:return{columns:Z,groupedData:G(J(p.byEndpoint,{},c,m),"endpoint"),storageKey:"usage-stats:expanded-endpoints",emptyMessage:"No endpoint usage recorded yet.",renderSummaryCells:e=>(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("td",{className:"px-6 py-3 text-text-muted",children:"—"}),(0,s.jsx)("td",{className:"px-6 py-3 text-text-muted",children:"—"}),(0,s.jsx)("td",{className:"px-6 py-3 text-right",children:x(e.summary.requests)}),(0,s.jsx)("td",{className:"px-6 py-3 text-right text-text-muted whitespace-nowrap",children:h(e.summary.lastUsed)})]}),renderDetailCells:e=>(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("td",{className:"px-6 py-3 font-medium font-mono text-sm",children:e.endpoint}),(0,s.jsx)("td",{className:"px-6 py-3",children:e.rawModel}),(0,s.jsx)("td",{className:"px-6 py-3",children:(0,s.jsx)(i.default,{variant:"neutral",size:"sm",children:e.provider})}),(0,s.jsx)("td",{className:"px-6 py-3 text-right",children:x(e.requests)}),(0,s.jsx)("td",{className:"px-6 py-3 text-right text-text-muted whitespace-nowrap",children:h(e.lastUsed)})]})}}},[p,w,c,m]);if(!p&&!f&&N)return(0,s.jsx)("div",{className:"text-text-muted",children:"Failed to load usage statistics."});let U=(0,s.jsx)("div",{className:"flex items-center justify-center py-12 text-text-muted",children:(0,s.jsx)("span",{className:"material-symbols-outlined text-[32px] animate-spin",children:"progress_activity"})});return(0,s.jsxs)("div",{className:"flex min-w-0 flex-col gap-6 lg:gap-7",children:[!r&&(0,s.jsxs)("div",{className:"flex w-full items-center gap-2 sm:w-auto sm:self-end",children:[(0,s.jsx)("div",{className:"grid flex-1 grid-cols-5 items-center gap-1 rounded-lg border border-border bg-bg-subtle p-1 sm:flex sm:flex-none",children:ee.map(e=>(0,s.jsx)("button",{onClick:()=>M(e.value),disabled:v,className:`rounded-md px-3 py-1 text-sm font-medium transition-colors ${L===e.value?"bg-primary text-white shadow-sm":"text-text-muted hover:bg-bg-hover hover:text-text"}`,children:e.label},e.value))}),v&&(0,s.jsx)("span",{className:"material-symbols-outlined text-[16px] text-text-muted animate-spin",children:"progress_activity"})]}),N&&!v&&(0,s.jsx)("div",{className:"rounded-xl border border-red-500/20 bg-red-500/10 px-3 py-2 text-xs text-red-700 dark:text-red-300",role:"alert",children:"Couldn't load statistics for this period — showing the last data available. Try switching the period again."}),f?U:(0,s.jsx)(u,{stats:p}),f?U:(0,s.jsxs)("div",{className:"grid min-w-0 grid-cols-1 items-stretch gap-4 lg:grid-cols-[minmax(0,3fr)_minmax(340px,2fr)]",children:[(0,s.jsx)(P,{providers:T,activeRequests:p.activeRequests||[],lastProvider:p.recentRequests?.[0]?.provider||"",errorProvider:p.errorProvider||""}),(0,s.jsx)(V,{requests:p.recentRequests||[],streamStatus:A})]}),f?U:(0,s.jsx)(F,{period:L}),(0,s.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,s.jsxs)("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between",children:[(0,s.jsx)("select",{value:w,onChange:e=>C(e.target.value),className:"w-full rounded-lg border border-border bg-surface px-3 py-1.5 text-sm font-medium text-text-main focus:outline-none focus:ring-2 focus:ring-primary/50 sm:w-auto",style:{colorScheme:"auto"},children:Y.map(e=>(0,s.jsx)("option",{value:e.value,children:e.label},e.value))}),(0,s.jsxs)("div",{className:"grid grid-cols-2 items-center gap-1 rounded-lg border border-border bg-bg-subtle p-1 sm:flex",children:[(0,s.jsx)("button",{onClick:()=>I("costs"),className:`px-3 py-1 rounded-md text-sm font-medium transition-colors ${"costs"===S?"bg-primary text-white shadow-sm":"text-text-muted hover:text-text hover:bg-bg-hover"}`,children:"Costs"}),(0,s.jsx)("button",{onClick:()=>I("tokens"),className:`px-3 py-1 rounded-md text-sm font-medium transition-colors ${"tokens"===S?"bg-primary text-white shadow-sm":"text-text-muted hover:text-text hover:bg-bg-hover"}`,children:"Tokens"})]})]}),f?U:D&&(0,s.jsx)(g,{title:"",columns:D.columns,groupedData:D.groupedData,tableType:w,sortBy:c,sortOrder:m,onToggleSort:q,viewMode:S,storageKey:D.storageKey,renderSummaryCells:D.renderSummaryCells,renderDetailCells:D.renderDetailCells,emptyMessage:D.emptyMessage})]})]})}},96748:(e,t,r)=>{r.d(t,{default:()=>d});var s=r(95155),a=r(12115),l=r(14051),n=r.n(l),i=r(35497);let o="https://api.openai.com/v1";function d({isOpen:e,onClose:t,onCreated:r,onSaved:l,node:n}){let c=!!n,[m,u]=(0,a.useState)({name:"",prefix:"",baseUrl:o}),[x,p]=(0,a.useState)(!1),[h,b]=(0,a.useState)(""),[f,g]=(0,a.useState)(""),[j,v]=(0,a.useState)(!1),[y,N]=(0,a.useState)(null);(0,a.useEffect)(()=>{e&&(N(null),b(""),g(""),c?u({name:n.name||"",prefix:n.prefix||"",baseUrl:n.baseUrl||o}):u({name:"",prefix:"",baseUrl:o}))},[e,c,n]);let k=async()=>{if(m.name.trim()&&m.prefix.trim()&&m.baseUrl.trim()){p(!0);try{let e=c?`/api/provider-nodes/${n.id}`:"/api/provider-nodes",t=c?"PUT":"POST",s={name:m.name,prefix:m.prefix,baseUrl:m.baseUrl};c||(s.type="custom-embedding");let a=await fetch(e,{method:t,headers:{"Content-Type":"application/json"},body:JSON.stringify(s)}),i=await a.json();a.ok&&(c?l?.(i.node):r?.(i.node))}catch(e){console.log("Error saving custom embedding node:",e)}finally{p(!1)}}},w=async()=>{v(!0);try{let e=await fetch("/api/provider-nodes/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:m.baseUrl,apiKey:h,type:"custom-embedding",modelId:f.trim()||void 0})}),t=await e.json();N(t)}catch{N({valid:!1,error:"Network error"})}finally{v(!1)}};return(0,s.jsx)(i.aF,{isOpen:e,title:c?"Edit Custom Embedding":"Add Custom Embedding",onClose:t,children:(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,s.jsx)(i.pd,{label:"Name",value:m.name,onChange:e=>u({...m,name:e.target.value}),placeholder:"Voyage AI",hint:"Required. A friendly label for this embedding provider."}),(0,s.jsx)(i.pd,{label:"Prefix",value:m.prefix,onChange:e=>u({...m,prefix:e.target.value}),placeholder:"voyage",hint:"Required. Used as the provider prefix for model IDs (e.g. voyage/voyage-3)."}),(0,s.jsx)(i.pd,{label:"Base URL",value:m.baseUrl,onChange:e=>u({...m,baseUrl:e.target.value}),placeholder:"https://api.voyageai.com/v1",hint:"Most embedding APIs are OpenAI-compatible: Voyage, Cohere, Jina, Mistral, Together..."}),(0,s.jsx)(i.pd,{label:"API Key (for Check)",type:"password",value:h,onChange:e=>b(e.target.value)}),(0,s.jsx)(i.pd,{label:"Model ID (for Check)",value:f,onChange:e=>g(e.target.value),placeholder:"e.g. voyage-3, embed-english-v3.0, text-embedding-3-small",hint:"Required for validation. Will send a test embeddings request."}),(0,s.jsxs)("div",{className:"flex items-center gap-3",children:[(0,s.jsx)(i.$n,{onClick:w,disabled:!h||!f.trim()||j||!m.baseUrl.trim(),variant:"secondary",children:j?"Checking...":"Check"}),(()=>{if(!y)return null;let{valid:e,error:t,dimensions:r}=y;return e?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(i.Ex,{variant:"success",children:"Valid"}),r&&(0,s.jsxs)("span",{className:"text-sm text-text-muted",children:[r," dims"]})]}):(0,s.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,s.jsx)(i.Ex,{variant:"error",children:"Invalid"}),t&&(0,s.jsx)("span",{className:"text-sm text-red-500",children:t})]})})()]}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(i.$n,{onClick:k,fullWidth:!0,disabled:!m.name.trim()||!m.prefix.trim()||!m.baseUrl.trim()||x,children:x?c?"Saving...":"Creating...":c?"Save":"Create"}),(0,s.jsx)(i.$n,{onClick:t,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})})}d.propTypes={isOpen:n().bool.isRequired,onClose:n().func.isRequired,onCreated:n().func,onSaved:n().func,node:n().shape({id:n().string,name:n().string,prefix:n().string,baseUrl:n().string})}},97677:(e,t,r)=>{r.d(t,{default:()=>a});var s=r(95155);function a({text:e,children:t,position:r="top",color:l}){let n=l?"":"bg-gray-900";return(0,s.jsxs)("div",{className:"relative inline-flex group",children:[t,(0,s.jsx)("div",{className:`pointer-events-none absolute ${{top:"bottom-full left-1/2 -translate-x-1/2 mb-1.5",bottom:"top-full left-1/2 -translate-x-1/2 mt-1.5",left:"right-full top-1/2 -translate-y-1/2 mr-1.5",right:"left-full top-1/2 -translate-y-1/2 ml-1.5"}[r]} z-50 w-max max-w-56 rounded px-2 py-1 text-[11px] leading-snug ${n} text-white opacity-0 group-hover:opacity-100 transition-opacity duration-150 whitespace-normal`,style:l?{backgroundColor:l}:{},children:e})]})}},98542:(e,t,r)=>{r.d(t,{default:()=>n});var s=r(95155),a=r(12115),l=r(31474);function n({checked:e=!1,onChange:t,label:r,description:i,disabled:o=!1,size:d="md",className:c,busy:m=!1,touchTarget:u=!1,...x}){let p=(0,a.useId)(),h=(0,a.useId)(),b={sm:{track:"w-8 h-4",thumb:"size-3",translate:"translate-x-4"},md:{track:"w-11 h-6",thumb:"size-5",translate:"translate-x-5"},lg:{track:"w-14 h-7",thumb:"size-6",translate:"translate-x-7"}},f=()=>{o||m||!t||t(!e)},g=(0,s.jsx)("span",{className:(0,l.cn)("pointer-events-none inline-block rounded-full bg-white shadow-sm","transform transition duration-200 ease-in-out",e?b[d].translate:"translate-x-0.5",b[d].thumb,"mt-0.5")});return(0,s.jsxs)("div",{className:(0,l.cn)("flex items-center gap-3",o&&"opacity-50 cursor-not-allowed",c),children:[(0,s.jsx)("button",{type:"button",role:"switch","aria-checked":e,"aria-busy":m||void 0,"aria-labelledby":r?p:void 0,"aria-describedby":i?h:void 0,"aria-label":r?void 0:x["aria-label"],disabled:o||m,onClick:f,...x,className:(0,l.cn)("relative inline-flex shrink-0 cursor-pointer","transition-colors duration-200 ease-in-out","focus:outline-none focus:ring-2 focus:ring-brand-500/30",u?"size-11 items-center justify-center rounded-xl sm:size-8 sm:rounded-lg":"rounded-full",!u&&(e?"bg-brand-500":"bg-surface-3"),!u&&b[d].track,o&&"cursor-not-allowed"),children:u?(0,s.jsx)("span",{className:(0,l.cn)("relative inline-flex shrink-0 rounded-full",e?"bg-brand-500":"bg-surface-3",b[d].track),children:g}):g}),(r||i)&&(0,s.jsxs)("div",{className:"flex flex-col",children:[r&&(0,s.jsx)("label",{id:p,onClick:f,className:"text-sm font-medium text-text-main cursor-pointer",children:r}),i&&(0,s.jsx)("span",{id:h,className:"text-xs text-text-muted",children:i})]})]})}}}]);
|