zevairouter 1.1.3 → 1.1.4
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 +5 -0
- package/cli/app/.next-cli-build/BUILD_ID +1 -1
- package/cli/app/.next-cli-build/app-path-routes-manifest.json +7 -7
- package/cli/app/.next-cli-build/build-manifest.json +2 -2
- package/cli/app/.next-cli-build/prerender-manifest.json +3 -3
- package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/automation/page_client-reference-manifest.js +1 -1
- package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/basic-chat/page_client-reference-manifest.js +1 -1
- package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/cli-tools/[toolId]/page_client-reference-manifest.js +1 -1
- package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/cli-tools/page_client-reference-manifest.js +1 -1
- package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/combos/page_client-reference-manifest.js +1 -1
- package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/console-log/page_client-reference-manifest.js +1 -1
- package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/context/page_client-reference-manifest.js +1 -1
- package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/endpoint/page_client-reference-manifest.js +1 -1
- package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/[kind]/[id]/page_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 +2 -2
- package/cli/app/.next-cli-build/server/app/api/cli-tools/claude-settings/route.js +2 -2
- package/cli/app/.next-cli-build/server/app/api/cli-tools/cline-settings/route.js +1 -1
- package/cli/app/.next-cli-build/server/app/api/cli-tools/codex-settings/route.js +1 -1
- package/cli/app/.next-cli-build/server/app/api/cli-tools/copilot-settings/route.js +2 -2
- package/cli/app/.next-cli-build/server/app/api/cli-tools/cowork-mcp-registry/route.js +1 -1
- package/cli/app/.next-cli-build/server/app/api/cli-tools/cowork-mcp-tools/route.js +2 -2
- package/cli/app/.next-cli-build/server/app/api/cli-tools/cowork-settings/route.js +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 +1 -1
- package/cli/app/.next-cli-build/server/app/api/cli-tools/grok-build-settings/route.js +1 -1
- package/cli/app/.next-cli-build/server/app/api/cli-tools/hermes-settings/route.js +1 -1
- package/cli/app/.next-cli-build/server/app/api/cli-tools/jcode-settings/route.js +2 -2
- package/cli/app/.next-cli-build/server/app/api/cli-tools/kilo-settings/route.js +2 -2
- package/cli/app/.next-cli-build/server/app/api/cli-tools/openclaw-settings/route.js +2 -2
- package/cli/app/.next-cli-build/server/app/api/cli-tools/opencode-settings/route.js +2 -2
- package/cli/app/.next-cli-build/server/app/api/media-providers/tts/elevenlabs/voices/route.js +1 -1
- package/cli/app/.next-cli-build/server/app/api/media-providers/tts/voices/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/providers/route.js +1 -1
- package/cli/app/.next-cli-build/server/app/api/terminal/session/[id]/input/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/terminal/session/[id]/resize/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/terminal/session/[id]/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/terminal/session/[id]/stream/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/terminal/session/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/translator/console-logs/route.js +1 -1
- package/cli/app/.next-cli-build/server/app/api/translator/console-logs/stream/route.js +1 -1
- package/cli/app/.next-cli-build/server/app/api/tunnel/tailscale-install/route.js +2 -2
- package/cli/app/.next-cli-build/server/app/api/version/route.js +1 -1
- package/cli/app/.next-cli-build/server/app/callback/page_client-reference-manifest.js +1 -1
- package/cli/app/.next-cli-build/server/app/callback.html +1 -1
- package/cli/app/.next-cli-build/server/app/callback.rsc +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 +7 -7
- package/cli/app/.next-cli-build/server/chunks/1131.js +1 -1
- package/cli/app/.next-cli-build/server/chunks/1350.js +1 -1
- package/cli/app/.next-cli-build/server/chunks/3949.js +1 -1
- package/cli/app/.next-cli-build/server/chunks/4827.js +1 -1
- package/cli/app/.next-cli-build/server/chunks/5330.js +1 -1
- package/cli/app/.next-cli-build/server/chunks/7319.js +4 -4
- package/cli/app/.next-cli-build/server/chunks/7582.js +1 -1
- package/cli/app/.next-cli-build/server/chunks/7634.js +1 -1
- package/cli/app/.next-cli-build/server/chunks/8306.js +1 -1
- package/cli/app/.next-cli-build/server/chunks/8371.js +1 -1
- package/cli/app/.next-cli-build/server/chunks/8895.js +2 -2
- package/cli/app/.next-cli-build/server/chunks/9489.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/{620-efc89e1a3218d121.js → 620-5098dbbc8e01fd60.js} +1 -1
- package/cli/app/.worktrees/antigravity-adaptive-connect/.next-cli-build/standalone/src/lib/terminal/ptyBridge.py +163 -0
- package/cli/app/.worktrees/antigravity-adaptive-connect/cli/app/src/lib/terminal/ptyBridge.py +163 -0
- package/cli/app/.worktrees/antigravity-adaptive-connect/src/lib/terminal/ptyBridge.py +163 -0
- package/cli/app/CHANGELOG.md +5 -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/{ovgrVe3rKmV4t4z_SEd8D → 1jAByy1IYXFprQnQiLqY7}/_buildManifest.js +0 -0
- /package/cli/app/.next-cli-build/static/{ovgrVe3rKmV4t4z_SEd8D → 1jAByy1IYXFprQnQiLqY7}/_ssgManifest.js +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";exports.id=8371,exports.ids=[3662,8371],exports.modules={3662:(a,b,c)=>{c.d(b,{EQ:()=>f,LY:()=>d,O:()=>e,fh:()=>h,t2:()=>i,wf:()=>g});let d={400:{type:"invalid_request_error",code:"bad_request"},401:{type:"authentication_error",code:"invalid_api_key"},402:{type:"billing_error",code:"payment_required"},403:{type:"permission_error",code:"permission_denied"},404:{type:"invalid_request_error",code:"model_not_found"},406:{type:"invalid_request_error",code:"model_not_supported"},429:{type:"rate_limit_error",code:"rate_limit_exceeded"},500:{type:"server_error",code:"internal_server_error"},502:{type:"server_error",code:"bad_gateway"},503:{type:"server_error",code:"service_unavailable"},504:{type:"server_error",code:"gateway_timeout"}},e={400:"Bad request",401:"Invalid API key provided",402:"Payment required",403:"Access forbidden by upstream provider.",404:"Model not found",406:"Model not supported",429:"Rate limit exceeded",500:"Internal server error",502:"Bad gateway - upstream provider error",503:"Service temporarily unavailable",504:"Gateway timeout"},f={base:2e3,max:3e5,maxLevel:15},g=3e4,h=6048e5,i=[{text:"no credentials",cooldownMs:12e4},{text:"request not allowed",cooldownMs:5e3},{text:"improperly formed request",cooldownMs:12e4},{text:"rate limit",backoff:!0},{text:"too many requests",backoff:!0},{text:"quota exceeded",backoff:!0},{text:"capacity",backoff:!0},{text:"overloaded",backoff:!0},{status:401,cooldownMs:12e4},{status:402,cooldownMs:12e4},{status:403,cooldownMs:12e4},{status:404,cooldownMs:12e4},{status:408,cooldownMs:5e3},{status:409,cooldownMs:5e3},{status:429,backoff:!0}]},39609:(a,b,c)=>{c.d(b,{proxyAwareFetch:()=>s});var d=c(47774),e=c(27910),f=c(41004);let g=globalThis.fetch,h=new Map,i=new Map,j=["cloudcode-pa.googleapis.com","daily-cloudcode-pa.googleapis.com","api.individual.githubcopilot.com","q.us-east-1.amazonaws.com","codewhisperer.us-east-1.amazonaws.com","api2.cursor.sh"],k=["8.8.8.8","8.8.4.4"];function l(){let a=Error("Request aborted");return a.name="AbortError",a}function m(a){return null==a?"":String(a).trim()}async function n(a,b=null){let d,e=i.get(a);if(e&&Date.now()<e.expiry)return e.ip;if(b?.aborted)throw l();try{let e=await Promise.resolve().then(c.t.bind(c,14985,23)),{promisify:g}=await Promise.resolve().then(c.t.bind(c,28354,23)),h=new e.Resolver;h.setServers(k);let j=g(h.resolve4.bind(h)),m=b?await Promise.race([j(a),new Promise((a,c)=>{d=()=>{h.cancel?.(),c(l())},b.addEventListener("abort",d,{once:!0})})]):await j(a);return i.set(a,{ip:m[0],expiry:Date.now()+f.v1.dnsCacheTtlMs}),m[0]}catch(c){if(b?.aborted||c?.name==="AbortError")throw l();return console.warn(`[ProxyFetch] DNS resolve failed for ${a}:`,c.message),null}finally{d&&b?.removeEventListener?.("abort",d)}}function o(a,b){let c,d=m(b);if(!d)return!1;try{c=new URL(a).hostname.toLowerCase()}catch{return!1}return d.split(",").map(a=>a.trim().toLowerCase()).filter(Boolean).some(a=>"*"===a||(a.startsWith(".")?c.endsWith(a)||c===a.slice(1):c===a||c.endsWith(`.${a}`)))}function p(a){let b=m(a);if(!b)return null;try{return new URL(b),b}catch{return`http://${b}`}}async function q(a){let b=p(a);if(!b)return null;if(!h.has(b)){h.size>=f.v1.proxyDispatchersMaxSize&&h.delete(h.keys().next().value);let{ProxyAgent:a}=await Promise.resolve().then(c.t.bind(c,47774,19));h.set(b,new a({uri:b}))}return h.get(b)}async function r(a,b,d){let f=await Promise.resolve().then(c.t.bind(c,55591,23)),g=await Promise.resolve().then(c.t.bind(c,91645,23)),h=f.default??f,i=g.default??g;return new Promise((c,f)=>{let g=new i.Socket,j=d.signal,k=null,m=null,n=!1,o=()=>j?.removeEventListener?.("abort",q),p=a=>{n||(n=!0,o(),f(a))},q=()=>{let a=l();m?.destroy?.(a),k?.destroy?.(a),g.destroy(a),p(a)};j?.aborted?q():(j?.addEventListener?.("abort",q,{once:!0}),g.connect(443,b,()=>{if(n||j?.aborted)return;let b={socket:g,servername:a.hostname,path:a.pathname+a.search,method:d.method||"POST",headers:{...d.headers,Host:a.hostname}};(k=h.request(b,a=>{m=a,n=!0,a.once("close",o);let b={ok:a.statusCode>=200&&a.statusCode<300,status:a.statusCode,statusText:a.statusMessage,headers:new Map(Object.entries(a.headers)),body:e.Readable.toWeb(a),text:async()=>{let b=[];for await(let c of a)b.push(c);return Buffer.concat(b).toString()},json:async()=>JSON.parse(await b.text())};c(b)})).on("error",a=>p(a)),d.body&&k.write("string"==typeof d.body?d.body:JSON.stringify(d.body)),k.end()}),g.on("error",a=>p(a)))})}async function s(a,b={},c=null){let e="string"==typeof a?a:a.toString(),f=m(c?.vercelRelayUrl);if(f){let a=new URL(e),c={...b.headers,"x-relay-target":`${a.protocol}//${a.host}`,"x-relay-path":`${a.pathname}${a.search}`};return g(f,{...b,headers:c})}let h=function(a,b){if(b?.enabled!==!0&&b?.connectionProxyEnabled!==!0)return null;let c=m(b?.url??b?.connectionProxyUrl);if(!c)return null;let d=m(b?.noProxy??b?.connectionNoProxy);return d&&o(a,d)?null:p(c)}(e,c),i=h?null:p(function(a){let b;if(o(a,process.env.NO_PROXY||process.env.no_proxy))return null;try{b=new URL(a).protocol}catch{return null}return"https:"===b?process.env.HTTPS_PROXY||process.env.https_proxy||process.env.ALL_PROXY||process.env.all_proxy:process.env.HTTP_PROXY||process.env.http_proxy||process.env.ALL_PROXY||process.env.all_proxy}(e)),k=h||i;if(function(a){try{let b=new URL(a).hostname;return j.some(a=>b.includes(a))}catch{return!1}}(e)){if(k)try{let c=await q(k);return await (0,d.hd)(a,{...b,dispatcher:c})}catch(a){if(b.signal?.aborted||a?.name==="AbortError")throw a;if(c?.strictProxy===!0)throw Error("[ProxyFetch] Required proxy request failed");throw Error("[ProxyFetch] Proxy request failed for protected upstream")}let f=new URL(e),h=await n(f.hostname,b.signal);return h?r(f,h,b):g(a,b)}if(k)try{let c=await q(k);return await (0,d.hd)(a,{...b,dispatcher:c})}catch(a){if(b.signal?.aborted||a?.name==="AbortError")throw a;if(c?.strictProxy===!0)throw Error(`[ProxyFetch] Proxy required but failed (strictProxy=true): ${a.message}`);if(c?.singleTransportAttempt===!0)throw Error("[ProxyFetch] Proxy request failed for single-attempt upstream");console.warn(`[ProxyFetch] Proxy failed, falling back to direct: ${a.message}`)}return g(a,b)}async function t(a,b={}){return s(a,b,null)}globalThis.fetch!==t&&(globalThis.fetch=t)},41004:(a,b,c)=>{c.d(b,{C8:()=>t,DR:()=>s,MB:()=>l,P4:()=>m,SA:()=>q,SI:()=>j,Uc:()=>o,Z1:()=>g,cI:()=>r,eo:()=>p,gx:()=>d,iL:()=>i,pH:()=>n,v1:()=>e,vx:()=>k,xM:()=>h,zA:()=>f}),c(3662);let d={BAD_REQUEST:400,UNAUTHORIZED:401,PAYMENT_REQUIRED:402,FORBIDDEN:403,NOT_FOUND:404,NOT_ACCEPTABLE:406,REQUEST_TIMEOUT:408,PAYLOAD_TOO_LARGE:413,RATE_LIMITED:429,SERVER_ERROR:500,BAD_GATEWAY:502,SERVICE_UNAVAILABLE:503,GATEWAY_TIMEOUT:504},e={sessionTtlMs:72e5,sessionCleanupIntervalMs:18e5,dnsCacheTtlMs:3e5,proxyDispatchersMaxSize:20};function f(a,b,c=process.env){let d=c?.[a];if("string"!=typeof d||!/^\d+$/.test(d))return b;let e=Number(d);return Number.isSafeInteger(e)&&e>=1e3&&e<=9e5?e:b}let g=f("STREAM_FIRST_CHUNK_TIMEOUT_MS",6e4),h=f("STREAM_STALL_TIMEOUT_MS",6e4),i=f("ANTIGRAVITY_THINKING_FIRST_CHUNK_TIMEOUT_MS",24e4),j=f("ANTIGRAVITY_THINKING_STALL_TIMEOUT_MS",12e4),k=f("STREAM_CONNECT_TIMEOUT_MS",15e3),l=f("STREAM_ABSOLUTE_TIMEOUT_MS",3e5),m=f("ANTIGRAVITY_THINKING_ABSOLUTE_TIMEOUT_MS",6e5),n=k,o=64e3,p=32e3,q="x-zevai-token-saver",r={429:{attempts:0,delayMs:0},502:{attempts:3,delayMs:3e3},503:{attempts:3,delayMs:2e3},504:{attempts:2,delayMs:3e3}};function s(a){return null==a?{attempts:0,delayMs:2e3}:"number"==typeof a?{attempts:a,delayMs:2e3}:{attempts:a.attempts||0,delayMs:null!=a.delayMs?a.delayMs:2e3}}let t=["Please write a 5-10 word title for the following conversation:"]},48371:(a,b,c)=>{c.d(b,{xM:()=>az,t9:()=>aH,TK:()=>aG,cO:()=>i.cO,VU:()=>a5});var d=c(55511),e=c(73024),f=c.n(e),g=c(76760),h=c.n(g),i=c(13868),j=c(71998),k=c(89718),l=c(20116),m=c(90715),n=c(92990),o=c(39609);let p=globalThis.fetch,q=new Set(["ECONNABORTED","ECONNREFUSED","ECONNRESET","EHOSTUNREACH","ENETDOWN","ENETUNREACH","ENOTFOUND","EPIPE","ETIMEDOUT"]),r=new Set(["TIMEOUT","CANCELED","FINISHED","BANNED"]),s=new Map([["A TIMEOUT","TIMEOUT"],["CANCELLED","CANCELED"],["IS CANCELED","CANCELED"],["IS CANCELLED","CANCELED"],["COMPLETE","FINISHED"],["COMPLETED","FINISHED"],["IS COMPLETE","FINISHED"],["IS COMPLETED","FINISHED"],["NUMBER BANNED, WHEN NUMBER ALREADY USED","BANNED"]]);class t extends Error{constructor(a,{status:b,body:c,source:d=null,orderStatus:e=null}={}){super(a),this.name="FiveSimError",this.status=b,this.body=c,this.source=d,this.orderStatus=e,this.isUpstreamTerminal="upstream"===d&&r.has(e)}}class u extends t{constructor(a,{source:b="local_deadline",orderStatus:c=null}={}){super(`5sim order ${a} timed out waiting for SMS`,{source:b,orderStatus:c}),this.name="FiveSimTimeoutError",this.orderId=a}}class v extends t{constructor(a,b){super(`5sim request to ${a} timed out after ${b}ms`),this.name="FiveSimRequestTimeoutError",this.code="FIVESIM_REQUEST_TIMEOUT",this.path=a,this.timeoutMs=b}}class w extends t{constructor(a){super(a),this.name="FiveSimUnknownOutcomeError",this.code="FIVESIM_BUY_OUTCOME_UNKNOWN",this.outcomeUnknown=!0}}class x extends t{constructor(a,b,{source:c="caller",orderStatus:d=null}={}){super(`5sim order ${a} cancelled: ${b}`,{source:c,orderStatus:d}),this.name="FiveSimCancelledError",this.orderId=a}}class y extends t{constructor(a,{source:b="downstream",orderStatus:c=null}={}){super(`5sim order ${a} number was already used (banned)`,{source:b,orderStatus:c}),this.name="FiveSimBannedError",this.orderId=a}}class z{constructor({apiKey:a,proxyOptions:b=null,fetchImpl:c=null}={}){if(!a||"string"!=typeof a||!a.trim())throw new t("5sim API key is required");this.apiKey=a.trim(),this.proxyOptions=b,this.fetchImpl="function"==typeof c?c:null}_headers(a={}){return{Authorization:`Bearer ${this.apiKey}`,Accept:"application/json",...a}}async _get(a,{headers:b,timeoutMs:c=15e3,signal:d,...e}={}){let f,g=`https://5sim.net/v1${a}`,h=this.fetchImpl||(this.proxyOptions?.enabled?o.proxyAwareFetch:p),i=Number.isFinite(c)&&c>0?new AbortController:null,j=i?.signal||null,k=i?setTimeout(()=>i.abort(),c):null;k?.unref?.();let l=function(a){let b=a.filter(Boolean);if(0===b.length)return null;if(1===b.length)return b[0];if("function"==typeof AbortSignal.any)return AbortSignal.any(b);let c=new AbortController;for(let a of b){if(a.aborted){c.abort(a.reason);break}a.addEventListener("abort",()=>c.abort(a.reason),{once:!0})}return c.signal}([d,j]),m=b=>{if(d?.aborted){let c=new t(`5sim request to ${a} was aborted`);return c.code="FIVESIM_REQUEST_ABORTED",c.cause=b,c}if(j?.aborted){let d=new v(a,c);return d.cause=b,d}return b};try{let c;try{f=await h(g,{method:"GET",headers:this._headers(b),...e,...l?{signal:l}:{}},this.proxyOptions)}catch(a){throw m(a)}try{c=await f.text()}catch(a){throw m(a)}if(!f.ok)throw new t(`5sim request to ${a} failed (HTTP ${f.status}): ${c.slice(0,200)}`,{status:f.status,body:c});try{return JSON.parse(c)}catch{if(c&&!c.startsWith("{"))throw new t(`5sim ${a} returned non-JSON: ${c.slice(0,200)}`,{status:f.status,body:c});return null}}finally{k&&clearTimeout(k)}}async buyNumber({country:a="hongkong",operator:b="any",product:c="codebuddy",allowProductFallback:d=!1,responseTimeoutMs:e=2e4,lateAbortTimeoutMs:f=45e3,signal:g=null}={}){if(g?.aborted){let a=new t("5sim purchase cancelled before the request started");throw a.code="FIVESIM_REQUEST_ABORTED",a}let h="codebuddy"===c&&d?["codebuddy","other"]:[c],i=null;for(let c of h){let j=`/user/buy/activation/${encodeURIComponent(a)}/${encodeURIComponent(b)}/${encodeURIComponent(c)}`;try{let a,b=Math.max(Number(f)||45e3,(Number(e)||2e4)+1e3),c=this._get(j,{timeoutMs:b});try{a=await B(c,e,g)}catch(a){throw a?.code==="FIVESIM_BUY_OUTCOME_UNKNOWN"&&c.then(a=>a?.id?this.cancelOrder(a.id):null).catch(()=>null),a}if(!a||!a.id||!a.phone)throw a?.id&&this.cancelOrder(a.id).catch(()=>null),new t(`5sim buyNumber returned unexpected shape: ${JSON.stringify(a).slice(0,200)}`,{body:a});return a}catch(e){i=e;let a=e?.status,b=String(e?.body||e?.message||"").toLowerCase();if(!(d&&"codebuddy"===c&&h.includes("other")&&(400===a||404===a||b.includes("no free")||b.includes("not enough")||b.includes("no product"))))throw e}}throw i||new t("5sim buyNumber failed for all product candidates")}async checkOrder(a,b={}){return this._get(`/user/check/${a}`,b)}async pollCode(a,{timeoutMs:b=9e5,intervalMs:c=6e3,signal:d}={}){let e=Number(c),f=Number.isFinite(e)?Math.max(5e3,e):6e3,g=Number(b),h=Number.isFinite(g)&&g>0?g:9e5,i=Date.now()+h,j=0,k=()=>Math.max(0,i-Date.now()),l=async()=>{let b=k();if(b<=0)throw new u(a);try{await function(a,b=null){return b?.aborted?Promise.reject(b.reason||Error("Aborted")):new Promise((c,d)=>{let e=()=>b?.removeEventListener("abort",g),f=setTimeout(()=>{e(),c()},a),g=()=>{clearTimeout(f),e(),d(b.reason||Error("Aborted"))};b?.addEventListener("abort",g,{once:!0})})}(Math.min(f,b),d)}catch(b){if(d?.aborted)throw new x(a,"aborted by caller");throw b}};for(;k()>0;){let b;if(d?.aborted)throw new x(a,"aborted by caller");let c=Math.min(15e3,k());if(c<=0)break;try{b=await this.checkOrder(a,{signal:d,timeoutMs:c})}catch(b){if(d?.aborted||b?.code==="FIVESIM_REQUEST_ABORTED")throw new x(a,"aborted by caller");if(b instanceof v||function(a){if(a instanceof t)return 408===a.status||429===a.status||a.status>=500;if(a instanceof TypeError)return!0;let b=a?.code||a?.cause?.code;return q.has(b)}(b)){if(0>=k())throw new u(a);if(++j>5)throw b;await l();continue}throw b}if(j=0,Array.isArray(b.sms)&&b.sms.length>0){let a=A(b.sms[b.sms.length-1]);if(a)return a}let e=function(a){if("string"!=typeof a)return null;let b=a.trim().replace(/\s+/g," ").toUpperCase();return s.get(b)||b||null}(b.status);if(r.has(e)){let c={source:"upstream",orderStatus:e};if("TIMEOUT"===e)throw new u(a,c);if("BANNED"===e)throw new y(a,c);if("CANCELED"===e)throw new x(a,e,c);if("FINISHED"===e){let d=function(a){if(!Array.isArray(a))return null;for(let b=a.length-1;b>=0;b--){let c=A(a[b]);if(c)return c}return null}(b.sms);if(d)return d;throw new t(`5sim order ${a} completed but no SMS code found`,{body:b,...c})}}await l()}throw new u(a)}async finishOrder(a){try{return await this._get(`/user/finish/${a}`),!0}catch(b){return console.warn(`[5sim] finishOrder(${a}) failed (best-effort): ${b.message}`),!1}}async cancelOrder(a){try{return await this._get(`/user/cancel/${a}`),!0}catch(b){return console.warn(`[5sim] cancelOrder(${a}) failed (best-effort): ${b.message}`),!1}}async banOrder(a){try{return await this._get(`/user/ban/${a}`),!0}catch(b){return console.warn(`[5sim] banOrder(${a}) failed (best-effort): ${b.message}`),!1}}async getBalance(){try{let a=await this._get("/user/profile");return{balance:a?.balance??null,rating:a?.rating??null}}catch(a){return console.warn(`[5sim] getBalance failed: ${a.message}`),{balance:null,rating:null}}}}function A(a){return a?a.code&&/\d{4,8}/.test(String(a.code))?String(a.code).match(/\d{4,8}/)[0]:a.text?function(a){if(!a)return null;let b=String(a).match(/\b(\d{4,8})\b/);return b?b[1]:null}(a.text):null:null}async function B(a,b,c=null){let d=Number(b)||2e4,e=null,f=null,g=new Promise((a,b)=>{let g=a=>b(new w(`5sim buy request ${a}; purchase outcome is unknown and any late successful order will be cancelled automatically`));e=setTimeout(()=>{g(`did not answer within ${d}ms`)},d),e.unref?.(),f=()=>g("was interrupted by the caller"),c?.aborted?f():c?.addEventListener("abort",f,{once:!0})});try{return await Promise.race([a,g])}finally{e&&clearTimeout(e),f&&c?.removeEventListener("abort",f)}}let C=["https://www.codebuddy.cn/login/"],D=["text=手机号","div:has-text('手机号')","span:has-text('手机号')","[class*='phone']:has-text('手机号')","div.kc-phone-tab:has-text('手机号')"],E=["text=手机号","text=其他登录方式","text=微信","#phone-iframe",".login-phone-box"],F=[".t-dialog :text-is('同意')","[role='dialog'] :text-is('同意')","button:text-is('同意并继续')","button:text-is('同意')"],G="#phone-iframe",H="#phoneNumber",I=".kc-country-selector",J=".kc-country-option",K=".kc-country-code-text",L="#code",M=".code-btn",N=['iframe[src*="captcha"]','iframe[src*="tcaptcha"]',"#tcaptcha","#tcaptcha_transform",".nc_iconfont",".nc_wrapper",'[class*="captcha"]','[id*="captcha"]',"text=滑块","text=拖动"],O=["#input-error",".pf-c-form__helper-text.pf-m-error",".kc-feedback-text"],P=new Set(["login_risk_state"]),Q=["账号访问受限","安全策略限制","访问受限","account restricted","access restricted"];function R(a="Tencent risk policy rejected the post-OTP session"){return{status:"failed_restricted",error:`Account restricted after OTP (${a}). Use a different residential CN/HK proxy with concurrency 1; do not retry this number on the same egress IP.`}}async function S(a){let b=a.locator("input.btn-lg.code-btn").first(),c=null;try{await b.waitFor({state:"visible",timeout:5e3}),c=b}catch{let b=a.locator(M).first();try{await b.waitFor({state:"visible",timeout:5e3}),c=b}catch{c=null}}if(!c)return{ok:!1,reason:"missing"};let d=await c.click().then(()=>!0).catch(()=>!1);return{ok:d,reason:d?null:"click_failed"}}async function T(a){for(let b of F){let c=a.locator(b);if(!c)continue;if("function"==typeof c.count&&"function"==typeof c.nth){let a=await c.count().catch(()=>0);for(let b=0;b<a;b+=1){let a=c.nth(b);if(await a.isVisible().catch(()=>!1))return a}continue}let d="function"==typeof c.first?c.first():c;if(d&&await d.isVisible().catch(()=>!1))return d}if("function"==typeof a.getByText){let b=a.getByText("同意",{exact:!0}),c="function"==typeof b.count?await b.count().catch(()=>0):0;for(let a=0;a<c;a+=1){let c=b.nth(a);if(await c.isVisible().catch(()=>!1))return c}}return null}function U(a){if(a?.aborted)throw a.reason||Object.assign(Error("Job cancelled"),{code:"JOB_CANCELLED"})}async function V(a,{timeoutMs:b=3e3,signal:c=null}={}){let d=Date.now()+b;for(;Date.now()<d;){U(c);let b=await T(a);if(b)return b;await a.waitForTimeout(100).catch(()=>new Promise(a=>setTimeout(a,100)))}return null}function W(a){let b=String(a||"");return/\/auth\/realms\/[^/]+\/(?:protocol\/openid-connect\/auth|login-actions\/)/i.test(b)}async function X(a,{visibleOnly:b=!0}={}){if(!a||"function"!=typeof a.locator)return!1;let c=a.locator(H);if(!c)return!1;let d="function"==typeof c.first?c.first():c;return!!d&&"function"==typeof d.isVisible&&(b?d.isVisible().catch(()=>!1):"function"==typeof d.count?d.count().then(a=>a>0).catch(()=>!1):d.isVisible().catch(()=>!1))}async function Y(a,b=null){if(!a||a===b||"function"!=typeof a.frameElement)return!0;try{let b=await a.frameElement();return await b.isVisible()}catch{return!1}}async function Z(a){let b="function"==typeof a.mainFrame?a.mainFrame():null,c=b||a;if(W(a.url?.())&&await X(c))return c;let d=a.locator(G);if("function"==typeof d.count&&"function"==typeof d.nth){let a=await d.count().catch(()=>0);for(let b=0;b<a;b+=1){let a=d.nth(b);if(!await a.isVisible().catch(()=>!1))continue;let c=await a.elementHandle().catch(()=>null),e=c?await c.contentFrame().catch(()=>null):null;if(e&&await X(e))return e}}for(let c of"function"==typeof a.frames?a.frames():[])if(c!==b&&W(c.url?.())&&await X(c)&&await Y(c,b))return c;return null}async function $(a,{timeoutMs:b=3e3,signal:c=null}={}){let d=Date.now()+b;for(;Date.now()<d;){U(c);let b=await Z(a);if(b)return b===("function"==typeof a.mainFrame?a.mainFrame():a)||b===a?"page":"iframe";await a.waitForTimeout(100).catch(()=>new Promise(a=>setTimeout(a,100)))}return null}async function _(a,{timeoutMs:b=25e3,reportStep:c,signal:d=null}={}){let e=Date.now()+b;for(;Date.now()<e;){U(d);let e=await T(a);if(e&&await e.click({timeout:Math.min(3e3,b)}).then(()=>!0).catch(()=>!1)){c?.("cn_consent_dismissed","Privacy consent accepted before login SPA readiness"),await a.waitForTimeout(300).catch(()=>null);continue}if(await Z(a))return!0;for(let b of E)if(await a.locator(b).first().isVisible().catch(()=>!1))return!0;await a.waitForTimeout(100).catch(()=>new Promise(a=>setTimeout(a,100)))}return!1}async function aa(a,b,{reportStep:c,consentTimeoutMs:d=3e3,signal:e=null}={}){U(e);let f=await b.click({timeout:d}).then(()=>!0).catch(()=>!1);await a.waitForTimeout(250).catch(()=>null);let g=await V(a,{timeoutMs:d,signal:e});if(!g)return f;if(!await g.click({timeout:d}).then(()=>!0).catch(()=>!1)||(c?.("cn_consent_dismissed","Service agreement accepted after opening phone login"),await a.waitForTimeout(300).catch(()=>null),!(await ad(a,{timeoutMs:d,signal:e})).ok))return!1;let h=await $(a,{timeoutMs:d,signal:e});if("page"===h)return c?.("cn_phone_page_ready","Consent redirected directly to the Keycloak phone form"),!0;if(!h){let b=await ao(a,D,{timeout:d,signal:e});return!!b&&b.click({timeout:d}).then(()=>!0).catch(()=>!1)}return!0}let ab=["我已阅读并同意","已阅读并同意","阅读并同意"];async function ac(a,{timeoutMs:b=3e3,signal:c=null}={}){let d=a.locator(".t-checkbox");if(!d)return null;if("function"!=typeof d.count||"function"!=typeof d.nth){let a="function"==typeof d.last?d.last():d;return await a.isVisible({timeout:b}).catch(()=>!1)?a:null}let e=Date.now()+b;for(;;){if(U(c),"function"==typeof d.filter)for(let a of ab){let b=d.filter({hasText:a}),c=b&&"function"==typeof b.count?await b.count().catch(()=>0):0;for(let a=0;a<c;a+=1){let c=b.nth(a);if(await c.isVisible().catch(()=>!1))return c}}let b=await d.count().catch(()=>0);for(let a=b-1;a>=0;a-=1){let b=d.nth(a);if(await b.isVisible().catch(()=>!1))return b}if(Date.now()>=e)return null;await a.waitForTimeout(100).catch(()=>new Promise(a=>setTimeout(a,100)))}}async function ad(a,{timeoutMs:b=3e3,signal:c=null}={}){U(c);let d=await ac(a,{timeoutMs:b,signal:c});if(!d)return{ok:!0,present:!1,changed:!1};let e=d.locator("input").first(),f=async()=>{if(!0===await e.isChecked().catch(()=>null))return!0;let a=await d.getAttribute("class").catch(()=>"");return!!/(?:^|\s)t-is-checked(?:\s|$)/.test(String(a||""))};if(await f())return{ok:!0,present:!0,changed:!1};if(!await d.click().then(()=>!0).catch(()=>!1))return{ok:!1,present:!0,changed:!1};if(!await f()){let d=await V(a,{timeoutMs:b,signal:c});if(d){if(!await d.click({timeout:b}).then(()=>!0).catch(()=>!1))return{ok:!1,present:!0,changed:!0};await a.waitForTimeout(200).catch(()=>null)}}let g=Date.now()+b;for(;Date.now()<g;){if(U(c),await f())return{ok:!0,present:!0,changed:!0};await a.waitForTimeout(100).catch(()=>new Promise(a=>setTimeout(a,100)))}return{ok:!1,present:!0,changed:!0}}function ae(a){return a?.isUpstreamTerminal===!0||["FiveSimTimeoutError","FiveSimBannedError","FiveSimCancelledError"].includes(a?.name)}async function af(a){let b=a.locator(M).first(),c=await b.evaluate(a=>({disabled:!!a.disabled,ariaDisabled:"true"===a.getAttribute("aria-disabled"),label:String(a.value||a.textContent||"").trim()})).catch(()=>null);if(!c)return{ok:!1,state:null};let d=/(?:^\d+$|\d+\s*(?:s|sec|\u79d2)|\u91cd\u65b0|\u5df2\u53d1\u9001|resend|sent)/i.test(c.label);return{ok:!!(c.disabled||c.ariaDisabled||d),state:c}}async function ag(a,b,{timeoutMs:c,signal:d=null,returnOnCaptcha:e=!0}={}){let f=Date.now()+c;for(;Date.now()<f;){U(d);let c=await aw(a,b,250),f=await af(b),g=f.ok?await aw(a,b,250):c;if(c||g){if(e)return{ok:!1,reason:"captcha",needsManual:!0,state:f.state};if(f.ok)return f}else if(f.ok)return f;await b.waitForTimeout(250).catch(()=>new Promise(a=>setTimeout(a,250)))}return{ok:!1,reason:"not_acknowledged",state:null}}async function ah(a,b,{acknowledgementTimeoutMs:c=8e3,manualCaptchaTimeoutMs:d=12e4,onManualRequired:e=null,onManualResolved:f=null,reportStep:g=null,signal:h=null}={}){let i=await ag(a,b,{timeoutMs:c,signal:h}),j=await av(b);if(j)return{ok:!1,reason:"form_error",error:j,state:null};if(i.ok)return i;if("captcha"!==i.reason)return{ok:!1,reason:"not_acknowledged",state:i.state};if(g?.("cn_sms_captcha_detected","Captcha appeared before Tencent accepted the SMS request; waiting for manual completion"),"function"!=typeof e)return{ok:!1,reason:"captcha",needsManual:!0,state:null};await e({phase:"sms_request",captcha:!0}),i=await ag(a,b,{timeoutMs:d,signal:h,returnOnCaptcha:!1});let k=await av(b);return k?{ok:!1,reason:"form_error",error:k,needsManual:!0,state:i.state}:i.ok?(await f?.({phase:"sms_request",captcha:!0}),g?.("cn_sms_captcha_resolved","Captcha completed; Tencent accepted the SMS request"),{...i,resumedFromCaptcha:!0}):{ok:!1,reason:"captcha_timeout",error:null,needsManual:!0,state:null}}async function ai(a,{timeoutMs:b,signal:c=null}={}){let d=null,e=null,f=new Promise((a,c)=>{d=setTimeout(()=>c(Error("Timed out waiting for SMS code")),b),d.unref?.()}),g=c?new Promise((a,b)=>{e=()=>b(c.reason||Object.assign(Error("Job cancelled"),{code:"JOB_CANCELLED"})),c.aborted?e():c.addEventListener("abort",e,{once:!0})}):null;try{return await Promise.race([a,f,...g?[g]:[]])}finally{d&&clearTimeout(d),e&&c?.removeEventListener("abort",e)}}async function aj({page:a,phone:b,resolvePhone:c,pollSmsPromise:d,waitForSms:e,onStep:f,onManualRequired:g,onManualResolved:h,phoneFormatter:i=a=>a,timeouts:j={},signal:k=null,isCancelled:l=null}){let m=j.nav??3e4,n=j.action??15e3,o=j.codeWait??9e5,p=j.postSubmit??1e4,q=(a,b)=>f?.(a,b),r=()=>{if(k?.aborted){if(k.reason?.code==="CN_ACCOUNT_HARD_TIMEOUT")throw k.reason;let a=Error("Job cancelled");throw a.code="JOB_CANCELLED",a}if("function"==typeof l&&l()){let a=Error("Job cancelled");throw a.code="JOB_CANCELLED",a}};try{var s;let f,j;q("cn_opening_login_page","Opening CodeBuddy CN login page"),r();try{a.setDefaultNavigationTimeout(m),a.setDefaultTimeout(n)}catch{}try{await a.context().route("**/*",a=>{var b,c;let d,e=a.request();return(b=e.url(),c=e.resourceType(),d=String(b||""),/googletagmanager|googleadservices|google-analytics|doubleclick|facebook|hotjar|clarity\.ms|hm\.baidu|google\.com\/rmkt/i.test(d)||"media"===c||"image"===c&&!/captcha|tcaptcha|challenge|verify|qrcode/i.test(d))?a.abort():a.continue()})}catch{}let l=null,t=[];for(let b=1;b<=2;b++){r();try{let c=C[(b-1)%C.length];q("cn_nav_attempt",`Navigation attempt ${b}/2 → ${c}`),b>1&&(await a.context().clearCookies().catch(()=>{}),await a.waitForTimeout(800)),await a.goto(c,{waitUntil:"commit",timeout:m}),r(),await a.waitForFunction(()=>"loading"!==document.readyState,{timeout:1e4}).catch(()=>{}),r();let d=await _(a,{timeoutMs:25e3,reportStep:q,signal:k});if(r(),!d){let b=await a.locator("body").innerText().catch(()=>""),d=await a.evaluate(()=>document.documentElement?.outerHTML?.length||0).catch(()=>0),e=a.url();q("cn_spa_not_ready",`SPA not ready after 25s (url=${e}, body=${String(b).slice(0,80)}, html=${d})`),!b&&d<200?(q("cn_proxy_empty_page","Empty page body — proxy may be blocking codebuddy.cn"),t.push({code:"proxy_empty",detail:`empty page via ${c} (html=${d})`})):t.push({code:"spa_timeout",detail:`SPA not ready url=${e} html=${d}`});continue}q("cn_spa_ready","Login SPA ready"),q("cn_selecting_phone_tab","Selecting phone-number tab");let e=await ao(a,D,{timeout:12e3,signal:k});if(e){if(!await aa(a,e,{reportStep:q,signal:k})){q("cn_phone_tab_failed","Could not open phone login after service agreement"),t.push({code:"phone_tab_failed",detail:"phone tab or post-click consent could not be completed"});continue}q("cn_phone_tab_selected","Phone tab selected"),await a.waitForTimeout(800)}else q("cn_phone_tab_not_found","Phone tab not found — checking if iframe already present");if(q("cn_waiting_for_phone_form","Waiting for Keycloak phone form to load"),await $(a,{timeoutMs:18e3,signal:k}),l=await ak(a)){if(await l.waitForSelector(H,{state:"visible",timeout:15e3}).then(()=>!0).catch(()=>!1)){q("cn_phone_form_ready","Keycloak phone form + #phoneNumber ready");break}q("cn_phone_form_empty","Keycloak form found but #phoneNumber not visible yet"),t.push({code:"phone_form_empty",detail:"Keycloak phone form found but #phoneNumber not visible"}),l=null}else q("cn_phone_form_missing",`No Keycloak phone form (attempt ${b}/2)`),t.push({code:"phone_form_missing",detail:"SPA loaded but neither iframe nor top-level Keycloak phone form appeared"})}catch(e){if(["JOB_CANCELLED","CN_ACCOUNT_HARD_TIMEOUT"].includes(e?.code))throw e;let a=String(e?.message||e||"");q("cn_nav_retry",`Navigation attempt ${b}/2 failed: ${a.slice(0,120)}`);let c=/timeout|exceeded|ETIMEDOUT|net::ERR/i.test(a),d=/ERR_PROXY|ERR_TUNNEL|ERR_CONNECTION|NS_ERROR_PROXY|proxy/i.test(a);t.push({code:d?"proxy_network":c?"nav_timeout":"nav_error",detail:a.slice(0,160)})}}if(!l)return{status:"failed",error:function(a=[],b=2){let c=a.map(a=>a.code),d=a[a.length-1],e="Fix: use a live residential CN proxy (proxyPoolMode=single), concurrency 1, then retry. 5sim is not charged until the form loads.";return c.includes("proxy_empty")||c.includes("proxy_network")?`CodeBuddy CN login page empty/blocked via proxy after ${b} attempts (${d?.detail||"proxy blackhole"}). ${e}`:c.includes("nav_timeout")?`CodeBuddy CN navigation timed out after ${b} attempts (${d?.detail||"goto timeout"}). Proxy is too slow or dead. ${e}`:c.includes("spa_timeout")?`CodeBuddy CN SPA did not boot after ${b} attempts (${d?.detail||"no login UI"}). Proxy/CDN may be filtering JS. ${e}`:c.includes("phone_tab_failed")?`CodeBuddy CN consent/phone transition did not complete after ${b} attempts (${d?.detail||"phone form transition failed"}). The Tencent page may have changed or loaded incompletely; inspect the live preview before retrying. No 5sim number was purchased.`:c.includes("iframe_missing")||c.includes("iframe_empty")||c.includes("phone_form_missing")||c.includes("phone_form_empty")?`CodeBuddy CN page opened but the Keycloak phone form never became ready after ${b} attempts (${d?.detail||"no phone form"}). Site layout change or half-loaded SPA — retry with another CN exit IP. ${e}`:c.includes("nav_error")&&d?.detail?`CodeBuddy CN phone form failed after ${b} attempts: ${d.detail}. ${e}`:`Could not load CodeBuddy CN phone form after ${b} attempts (${d?.code||"unknown"}: ${d?.detail||"proxy/SPA"}). ${e}`}(t,2)};await l.waitForSelector("#kc-form-login",{timeout:n}).catch(()=>{}),await l.waitForSelector(H,{state:"visible",timeout:n}).catch(()=>{});let u=b;if("function"==typeof c&&(q("cn_ordering_after_form","Login form ready — ordering 5sim number now (not before nav)"),u=await c()),!u)return{status:"failed",error:"No phone number available (resolvePhone/phone missing)"};let v=i(u),{countryCode:w,localNumber:x}=(s=v,(!(j=String(s).replace(/[\s\-()]/g,"")).startsWith("+")&&/^\d+$/.test(j)&&(j="+"+j),j.startsWith("+852"))?{countryCode:"+852",localNumber:j.slice(4)}:j.startsWith("+86")?{countryCode:"+86",localNumber:j.slice(3)}:j.startsWith("+1")?{countryCode:"+1",localNumber:j.slice(2)}:{countryCode:"",localNumber:j.replace(/^\+/,"")});if(q("cn_selecting_country",`Selecting country code ${w} for phone ${v}`),!await an(l,w,n,q))return{status:"failed",error:`Could not select country code ${w||"(unknown)"} for ${v}`};q("cn_entering_phone",`Entering phone number: ${x}`);let y=l.locator(H).first();try{await y.waitFor({state:"visible",timeout:n})}catch{return{status:"failed",error:"Could not find the phone number input (#phoneNumber) inside the iframe"}}if(!await ap(y,x))return{status:"failed",error:"Phone number input did not retain the expected value"};q("cn_phone_entered",`Phone number entered: ${x}`);let z=await am(l,Math.min(n,2e3));if(w&&z&&z!==w){q("cn_country_reset_after_phone",`Country code reverted to ${z} after phone input; restoring ${w}`);let a=await an(l,w,n,q),b=a&&await ap(y,x);if(!a||!b)return{status:"failed",error:`Country code reverted to ${z} and could not be restored to ${w}`};q("cn_country_and_phone_restored",`Country ${w} and phone number restored`)}let A=await ad(a,{signal:k});if(!A.ok)return{status:"failed",error:"Could not keep the service agreement checkbox checked"};A.present&&q("cn_agreement_checked",A.changed?"Agreement checkbox checked":"Agreement checkbox already checked"),q("cn_clicking_send_code","Clicking send SMS code button");let B=await S(l);if("missing"===B.reason)return{status:"failed",error:"Could not find the send-SMS-code button (.code-btn) inside the iframe"};if(!B.ok)return{status:"failed",error:"Could not click the send-SMS-code button (.code-btn) inside the iframe"};q("cn_send_code_clicked","Send code button clicked");let E=await ah(a,l,{manualCaptchaTimeoutMs:Math.min(o,12e4),onManualRequired:g,onManualResolved:h,reportStep:q,signal:k});if("form_error"===E.reason){if(E.needsManual)return{status:"needs_manual",error:`Form error after the captcha was handed over: ${E.error}. Finish the login in the open browser session.`,captcha:!0};return{status:"failed",error:`Form error after sending code: ${E.error}`}}if("captcha"===E.reason)return{status:"needs_manual",error:"A captcha blocked the SMS request. Complete it in the existing browser session.",captcha:!0};if("captcha_timeout"===E.reason)return{status:"needs_manual",error:"Captcha was not completed before the SMS-request manual-assist timeout. Finish it in the open browser session.",captcha:!0};if(!E.ok)return{status:"failed",error:"Tencent did not acknowledge the SMS-code request (no disabled/countdown state)"};q("cn_send_code_acknowledged","Tencent accepted the SMS-code request"),q("cn_waiting_for_sms","Waiting for SMS verification code from 5sim (timer starts now)");try{let a;if("function"==typeof e)a=Promise.resolve().then(()=>e());else if(d)a=d;else throw Error("No waitForSms/pollSmsPromise provided");f=await ai(a,{timeoutMs:o,signal:k})}catch(a){if(ae(a))throw a;return(k?.aborted||a?.code==="JOB_CANCELLED")&&r(),{status:"failed",error:`Failed to receive SMS code: ${a.message}`}}if(!f)return{status:"failed",error:"Received empty SMS code from 5sim"};q("cn_sms_received","SMS code received"),q("cn_entering_code","Entering SMS verification code");let F=l.locator(L).first();try{await F.waitFor({state:"visible",timeout:n})}catch{return{status:"failed",error:"Could not find the verification code input (#code) inside the iframe"}}if(!await ap(F,f))return{status:"failed",error:"Verification code input did not retain the expected value"};q("cn_code_entered","Verification code entered");let G=1200+Math.floor(1800*Math.random());q("cn_pre_submit_pause",`Waiting ${G}ms before submit (humanize)`),await a.waitForTimeout(G);let I=Math.max(p,12e3);q("cn_submitting","Submitting the registration form once");let J=await ak(a);if(!J)return{status:"failed",error:"Lost phone iframe before submit"};let K=await as(J,n);if(!K.ok)return{status:"failed",error:"Could not submit the Keycloak login form"};if(q("cn_submitted",`Registration form submitted once via ${K.method}`),await a.waitForLoadState("domcontentloaded",{timeout:5e3}).catch(()=>{}),await a.waitForTimeout(1800),J=await ak(a)||J,await au(a,J))return q("cn_account_restricted","Account restricted after the OTP submit"),R("restriction message detected");if(q("cn_checking_captcha","Checking for captcha"),await aw(a,J,3e3))return q("cn_captcha_detected","Captcha appeared during registration - manual assist needed"),{status:"needs_manual",error:"A captcha appeared during registration. Complete it in the existing browser session.",captcha:!0};let M=await av(J);if(M)return{status:"failed",error:`Form error after submit: ${M}`};q("cn_waiting_session",`Waiting up to ${Math.round(I/1e3)}s for Keycloak session cookies`);let N=await ar(a,{timeoutMs:I,reportStep:q,alsoCheckFrame:()=>ak(a),signal:k});if(N.ok)return q("cn_session_cookies",`Keycloak session cookies present (${N.cookie}) - registration success`),{status:"success"};if("restricted"===N.reason||function(a=[]){return a.some(a=>P.has(a?.name))}(N.cookies))return q("cn_account_restricted","Restriction detected while waiting for the login session"),R("restriction evidence detected during session handoff");if(J=await ak(a)||J,await aw(a,J,2e3))return q("cn_captcha_detected","Captcha appeared while waiting for the login session"),{status:"needs_manual",error:"A captcha appeared while establishing the login session. Complete it in the existing browser.",captcha:!0};let O=await at(a);return q("cn_success_unconfirmed",`No Keycloak session after submit — ${O.summary}`),{status:"needs_manual",error:`Login submit finished but no Keycloak session yet (${O.summary}). Complete login in the headed browser or retry with a fresh China proxy.`}}catch(a){if((k?.aborted||"function"==typeof l&&l())&&r(),ae(a)||a?.code==="JOB_CANCELLED"||a?.code==="CN_ACCOUNT_HARD_TIMEOUT")throw a;return q("cn_automation_error",`Phone registration automation error: ${a.message}`),{status:"failed",error:a.message||"Unexpected error during phone registration"}}}async function ak(a){let b=await Z(a);if(b)return b;try{let b=a.locator(G),c="function"==typeof b.count?await b.count().catch(()=>0):0;for(let a=0;a<c;a+=1){let c=b.nth(a);if(!await c.isVisible().catch(()=>!1))continue;let d=await c.elementHandle().catch(()=>null),e=d?await d.contentFrame().catch(()=>null):null;if(e&&W(e.url()))return e}}catch{}let c="function"==typeof a.mainFrame?a.mainFrame():null;if(c&&W(a.url?.()))return c;for(let b of"function"==typeof a.frames?a.frames():[])if(W(b.url())&&await Y(b,c))return b;return null}function al(a){return String(a||"").replace(/\s+/g,"").match(/\+\d{1,4}/)?.[0]||""}async function am(a,b=1500){for(let c of[K,I]){let d=al(await a.locator(c).first().textContent({timeout:b}).catch(()=>""));if(d)return d}return""}async function an(a,b,c,d){if(!b)return!1;let e=Math.min(Math.max(Number(c)||15e3,2e4),3e4),f=Date.now()+e,g=()=>Math.max(0,f-Date.now()),h=a=>Math.max(250,Math.min(a,g())),i=async()=>{let b=a.locator(I).first();await b.waitFor({state:"visible",timeout:h(5e3)}),await b.click({timeout:h(3e3)}).catch(()=>{}),await a.locator(J).first().waitFor({state:"visible",timeout:h(3e3)}).catch(()=>{})},j=async()=>await am(a,h(1500))===b||(await a.locator(K).filter({hasText:b}).first().waitFor({state:"visible",timeout:h(2e3)}).catch(()=>null),await am(a,h(1e3))===b),k=async(a,b)=>{if(!await a.isVisible({timeout:h(1500)}).catch(()=>!1))return!1;let c=await a.textContent({timeout:h(1500)}).catch(()=>b);return"function"==typeof a.scrollIntoViewIfNeeded&&await a.scrollIntoViewIfNeeded({timeout:h(1500)}).catch(()=>null),!!await a.click({timeout:h(2e3)}).then(()=>!0).catch(()=>!1)&&!!await j()&&(d?.("cn_country_selected",`Country selected: ${String(c||b).trim()}`),!0)},l=async c=>{let d=a.locator(J);if("function"==typeof d.allTextContents&&"function"==typeof d.nth){let a=await d.allTextContents().catch(()=>[]),c=a.findIndex(a=>al(a)===b);if(c>=0&&await k(d.nth(c),a[c]))return!0}for(let d of[b,...c]){if(0>=g())break;for(let b of[a.locator(`${J}:has-text(${JSON.stringify(d)})`).first(),a.locator(J).filter({hasText:d}).first(),a.getByText(d,{exact:!0}).first(),a.getByText(d,{exact:!1}).first()]){if(0>=g())return!1;if(await k(b,d))return!0}}return!1},m=async()=>{let c=await am(a,h(3e3));if(c===b)return d?.("cn_country_already_selected",`Country code already ${b}`),!0;let e={"+852":["中国香港","香港","Hong Kong","+852"],"+86":["中国大陆","中国","China","+86"],"+853":["中国澳门","澳门","Macau","+853"],"+886":["中国台湾","台湾","Taiwan","+886"]}[b]||[b];d?.("cn_opening_country_dropdown",`Opening country dropdown (current: ${c}, target: ${b})`);for(let c=1;c<=2;c+=1){if(await i(),await l(e))return!0;if(c>=2||6e3>=g())break;d?.("cn_country_dropdown_retry",`Country ${b} not selectable yet; reopening the dropdown (${g()}ms left)`),await a.locator("body").click({timeout:h(1e3)}).catch(()=>{})}return d?.("cn_country_not_found",`Country code ${b} not found in dropdown`),await a.locator("body").click({timeout:h(1e3)}).catch(()=>{}),!1},n=null;try{return await Promise.race([m(),new Promise((a,b)=>{n=setTimeout(()=>b(Error(`selectCountry timed out after ${e}ms`)),e),n.unref?.()})])}catch(a){return d?.("cn_country_select_error",`Country selection error: ${a.message}`),!1}finally{n&&clearTimeout(n)}}async function ao(a,b,{timeout:c=1e4,signal:d=null}={}){let e=Date.now()+c;for(;Date.now()<e;){for(let c of(U(d),b)){let b=a.locator(c).first();if(await b.isVisible().catch(()=>!1))return b}let c=e-Date.now();if(c<=0)break;await a.waitForTimeout(Math.min(100,c)).catch(()=>new Promise(a=>setTimeout(a,Math.min(100,c))))}return null}async function ap(a,b){let c=String(b??""),d=async()=>await a.inputValue().catch(()=>null)===c;try{if(await a.click(),await a.fill(""),await a.fill(c),await d())return!0}catch{}try{return await a.click(),await a.press("ControlOrMeta+a"),await a.type(c,{delay:50}),d()}catch{return!1}}let aq=["KEYCLOAK_IDENTITY","KEYCLOAK_SESSION","KEYCLOAK_IDENTITY_LEGACY","KEYCLOAK_SESSION_LEGACY"];async function ar(a,{timeoutMs:b=2e4,reportStep:c,alsoCheckFrame:d,signal:e=null}={}){let f=Date.now()+b,g=0;for(;Date.now()<f;){U(e);let b=await a.context().cookies().catch(()=>[]),h=function(a=[]){for(let b of aq)if(a.some(a=>a.name===b))return b;let b=a.find(a=>a.name.startsWith("KEYCLOAK_")&&!/locale|theme|restart/i.test(a.name));return b?.name||null}(b);if(h)return{ok:!0,cookie:h,cookies:b};try{let c=a.url();if(c&&!c.includes("/login")&&!c.includes("/auth/realms")){let a=b.find(a=>/^(access_token|cb_token|codebuddy)/i.test(a.name)||"token"===a.name&&a.domain?.includes("codebuddy"));if(a)return{ok:!0,cookie:a.name,cookies:b}}}catch{}let i=d?await d().catch(()=>null):null;if(await au(a,i))return{ok:!1,cookies:b,reason:"restricted"};if(i){let a=await av(i);if(a)return{ok:!1,cookies:b,reason:`form_error:${a}`}}if(c&&Date.now()-g>4e3){g=Date.now();let a=Math.max(0,Math.round((f-Date.now())/1e3));c("cn_waiting_session",`Still waiting for Keycloak session… ${a}s left`)}await a.waitForTimeout(500)}return U(e),{ok:!1,cookies:await a.context().cookies().catch(()=>[])}}async function as(a,b=15e3){let c=a.locator("#kc-login").first();try{return await c.waitFor({state:"visible",timeout:b}),await c.click({timeout:5e3}),{ok:!0,method:"click"}}catch{}try{return await a.evaluate(()=>{let a=document.querySelector("#kc-form-login")||document.querySelector("form");if(!a)return!1;if("function"==typeof a.requestSubmit){let b=a.querySelector("#kc-login")||a.querySelector('[type="submit"]');b?a.requestSubmit(b):a.requestSubmit()}else a.submit();return!0})?{ok:!0,method:"requestSubmit"}:{ok:!1,method:null}}catch{let b=await a.locator(L).first().press("Enter").then(()=>!0).catch(()=>!1);return{ok:b,method:b?"enter":null}}}async function at(a){let b="";try{b=a.url()}catch{b="(unknown)"}let c=(await a.context().cookies().catch(()=>[])).map(a=>a.name).slice(0,20).join(",")||"(none)",d="";try{d=await a.evaluate(()=>(document.body?.innerText||"").replace(/\s+/g," ").trim().slice(0,120))}catch{d=""}let e=await ak(a),f="no-iframe";if(e)try{f=(await e.url()).slice(0,80)}catch{f="iframe-detached"}return{summary:`url=${b.slice(0,60)} cookies=[${c}] frame=${f}${d?` text="${d}"`:""}`,url:b,cookieNames:c,bodySnippet:d}}async function au(a,b){for(let c of[b,a])if(c)try{let a=await c.evaluate(()=>document.body?.innerText||"");if(function(a){let b=String(a||"").toLowerCase();return Q.some(a=>b.includes(a.toLowerCase()))}(a))return!0}catch{}return!1}async function av(a){for(let b of O)try{let c=a.locator(b).first();if(await c.isVisible({timeout:1500}).catch(()=>!1)){let a=await c.textContent().catch(()=>""),b=String(a).trim();if(b&&b.length>1)return b}}catch{}try{let b=await a.evaluate(()=>(document.body?.innerText||"").replace(/\s+/g," ").trim());for(let a of["验证码错误","验证码已过期","验证码无效","请输入正确的验证码","手机号格式","发送过于频繁"])if(b.includes(a)){let c=b.indexOf(a);return b.slice(Math.max(0,c-10),c+a.length+40).trim()}let c=b.match(/\b(?:invalid|incorrect|expired|wrong)\s+(?:\w+\s+){0,2}?(?:code|verification|password|credentials|phone(?:\s+number)?|username)\b/i)||b.match(/\b(?:code|verification\s+code|phone\s+number|credentials)\s+(?:is|was|are|were)\s+(?:\w+\s+){0,2}?(?:invalid|incorrect|expired|wrong)\b/i);if(c){let a=c.index??b.indexOf(c[0]);return b.slice(Math.max(0,a-10),a+c[0].length+40).trim()}}catch{}return null}async function aw(a,b,c=5e3){for(let b of N)try{let d=a.locator(b).first();if(await d.isVisible({timeout:Math.min(c,2e3)}).catch(()=>!1))return!0}catch{}if(b)for(let a of N)try{let d=b.locator(a).first();if(await d.isVisible({timeout:Math.min(c,2e3)}).catch(()=>!1))return!0}catch{}return!1}var ax=c(40891),ay=c(75949);let az=200,aA=Number.parseInt(process.env.ZEVAI_CN_ACCOUNT_TIMEOUT_MS||"",10)||3e5,aB="CN_API_KEY_OUTCOME_UNKNOWN",aC="CN_API_KEY_AUTOMATIC_RETRY_STOPPED",aD="CN_ACCOUNT_RESTRICTED",aE=new Set(["KEYCLOAK_IDENTITY","KEYCLOAK_SESSION","KEYCLOAK_IDENTITY_LEGACY","KEYCLOAK_SESSION_LEGACY"]),aF=new Set(["CN","HK"]),aG=new Set(["hongkong"]),aH="hongkong",aI=new Set(["queued","running","needs_manual"]),aJ=new Set(["queued","running","needs_manual"]);function aK(a){return String(a||"").trim()}function aL(a,b,c){return a.manualSession={context:b,page:c,opened:!1,openedAt:null},a.manualSession}function aM(){try{let{totalMemGb:a}=(0,l.si)();return Number.isFinite(a)&&a>0&&a<3}catch{return!1}}function aN(a){return!!a?.proxyUrls?.length&&["manual","all","single"].includes(a?.proxyPoolMode)}async function aO(a,{timeoutMs:b=6e3,rounds:c=3,retryDelayMs:d=350,sleepImpl:e=a=>new Promise(b=>setTimeout(b,a))}={}){let f=null;try{f=a?.request||null}catch{f=null}if(!f||"function"!=typeof f.get)return{ok:!1,ip:null,ips:[],samples:0,error:"context request unavailable"};let g=[],h=null,i=Math.max(1,Math.min(5,Number.parseInt(c,10)||1));for(let a=1;a<=i;a+=1){for(let c of ay.PROXY_EGRESS_ECHO_URLS){g.push(c);let d=null;try{var j;if(d=await f.get(c,{timeout:b,failOnStatusCode:!1,headers:{Accept:"text/plain, application/json;q=0.9, */*;q=0.1","Cache-Control":"no-cache"}}),200>d.status()||d.status()>=300){h=`HTTP ${d.status()}`;continue}let e=(j=await d.text().catch(()=>""),(0,ay.parseProxyEgressIp)(j));if(!e){h="exit-IP response was not recognized";continue}return{ok:!0,ip:e,ips:[e],samples:1,attempts:g.length,attemptedUrls:g,rounds:a,unstable:!1,error:null}}catch(a){h=a?.name==="TimeoutError"?`timed out after ${b}ms`:"request failed"}finally{"function"==typeof d?.dispose&&await Promise.resolve(d.dispose()).catch(()=>null)}}a<i&&d>0&&await e(Math.min(2e3,d*a))}return{ok:!1,ip:null,ips:[],samples:0,attempts:g.length,attemptedUrls:g,rounds:i,unstable:!1,error:h||"all exit-IP services failed"}}function aP(a,b=null){if(a?.unstable)throw Object.assign(Error("Manual proxy rotated between exit IPs during preflight; no phone number was purchased"),{code:"CN_PROXY_EGRESS_UNSTABLE"});if(!a?.ok||!a?.ip)throw Object.assign(Error(`Manual proxy exit IP could not be verified (${a?.error||"no response"}); no phone number was purchased`),{code:"CN_PROXY_EGRESS_UNVERIFIED"});if(b&&a.ip!==b)throw Object.assign(Error("Manual proxy browser exit IP changed before the 5sim purchase; no phone number was purchased"),{code:"CN_PROXY_EGRESS_CHANGED"});return a.ip}async function aQ(a,{timeoutMs:b,message:c,code:d,onTimeout:e,onLateResolve:f}){let g=Promise.resolve(a),h=null,i=!1,j=new Promise((a,f)=>{"function"==typeof(h=setTimeout(()=>{i=!0;try{"function"==typeof e&&e()}catch{}f(Object.assign(Error(c),{code:d}))},b)).unref&&h.unref()});try{return await Promise.race([g,j])}finally{h&&clearTimeout(h),i&&"function"==typeof f&&g.then(f).catch(()=>null)}}function aR(a,b="API key request"){let c=Number(a?.status);if(429===c)throw Object.assign(Error(`${b} was rate limited (HTTP 429); automatic POST retries stopped`),{code:aC});if(Number.isFinite(c)&&c>=500)throw Object.assign(Error(`${b} returned HTTP ${c}; creation outcome may be unknown and automatic POST retries stopped`),{code:aB});return a}function aS(a){let b=`${a?.text||""} ${a?.data?._raw||""} ${a?.url||""}`;return/<!doctype html|<html|login-pf|\/auth\/realms\//i.test(b)}function aT(a=[]){let b=a instanceof Set?a:new Set(Array.from(a,a=>"string"==typeof a?a:a?.name));return[...aE].some(a=>b.has(a))}function aU(a){let b=a?.data;if(!b||"object"!=typeof b)return null;let c=[b?.data?.accounts,b?.accounts,b?.data?.list,b?.list,b?.data?.result,b?.result,b?.data?.items,b?.items,Array.isArray(b?.data)?b.data:null,Array.isArray(b)?b:null],d=null;for(let a of c)if(Array.isArray(a)){if(a.length>0)return a;d=a}return d}function aV(a){let b=a?.data?.code,c=a?.data?.status??a?.data?.statusCode,d=!!a?.data?.error||a?.data?.success===!1||a?.data?.ok===!1||Number.isFinite(Number(c))&&Number(c)>=400;return a?.status===200&&!aS(a)&&a?.data!==null&&"object"==typeof a?.data&&a.data?._notJson!==!0&&!d&&(void 0===b||0===b||200===b)&&null!==aU(a)}function aW(a,b=[]){let c=b instanceof Set?b:new Set(b),d=`${a?.text||""} ${a?.data?._raw||""}`;return!!/账号访问受限|安全策略限制|访问受限|account restricted|access restricted/i.test(d)||!!c.has("login_risk_state")&&(aS(a)||a?.status===0||a?.status===401||a?.status===403)}async function aX({context:a,page:b,timeoutMs:c=1e4}){let d={Accept:"application/json, text/plain, */*","x-requested-with":"XMLHttpRequest","X-Domain":"www.codebuddy.cn","X-Product":"SaaS"},e=null;try{e=a?.request||null}catch{e=null}if(e&&"function"==typeof e.get)try{let a=await e.get("https://www.codebuddy.cn/console/accounts",{headers:d,timeout:c,failOnStatusCode:!1}),b=await a.text().catch(()=>"");return function(a,b,c={}){let d=String(b||""),e=null;try{e=d?JSON.parse(d):null}catch{e={_raw:d.slice(0,240),_notJson:!0}}return{status:Number(a)||0,data:e,text:d.slice(0,240),...c}}(a.status(),b,{source:"context-request",url:a.url(),contentType:a.headers()?.["content-type"]||""})}catch{}return aQ(b.evaluate(async({requestTimeoutMs:a,requestHeaders:b})=>{let c=new AbortController,d=setTimeout(()=>c.abort(),a);try{let a=window.location.hostname||"www.codebuddy.cn",d="www.codebuddy.cn"===a?`${window.location.origin}`:"https://www.codebuddy.cn",e=await fetch(`${d}/console/accounts`,{credentials:"include",signal:c.signal,headers:b}),f=await e.text().catch(()=>""),g=null;try{g=f?JSON.parse(f):null}catch{g={_raw:String(f||"").slice(0,240),_notJson:!0}}return{status:e.status,data:g,text:String(f||"").slice(0,240),source:"page-fetch",url:e.url,contentType:e.headers.get("content-type")||""}}catch(a){return{status:0,timedOut:a?.name==="AbortError",error:a?.message||String(a),source:"page-fetch"}}finally{clearTimeout(d)}},{requestTimeoutMs:c,requestHeaders:d}),{timeoutMs:c,message:`Console account probe timed out after ${c/1e3}s`,code:"CN_CONSOLE_PROBE_TIMEOUT"}).catch(a=>({status:0,timedOut:a?.code==="CN_CONSOLE_PROBE_TIMEOUT",error:a?.message||String(a),source:"page-fetch"}))}async function aY(a){if(!a||"function"!=typeof a.close)return!0;try{return await aQ(Promise.resolve().then(()=>a.close()),{timeoutMs:5e3,message:"Browser resource close timed out after 5s",code:"CN_RESOURCE_CLOSE_TIMEOUT"}),!0}catch{return!1}}async function aZ(a,b){if(await aY(a)||!b?.browser)return;let c=b.browser;b.browser=null,await (0,ay.forceCloseBrowser)(c).catch(()=>null)}async function a$(a){try{return await aQ(Promise.resolve().then(a),{timeoutMs:12e3,message:"5sim order settlement timed out after 12s",code:"CN_FIVESIM_SETTLE_TIMEOUT"})}catch{return!1}}async function a_({fiveSimClient:a,fiveSimOrderId:b,smsReceived:c=!1,error:d=null}={}){return a&&b?d?.isUpstreamTerminal===!0?{action:"none",ok:!0,reason:"upstream_terminal",orderStatus:d.orderStatus||null}:c?{action:"finish",ok:!0===await a$(()=>a.finishOrder(b))}:d instanceof y?{action:"ban",ok:!0===await a$(()=>a.banOrder(b))}:{action:"cancel",ok:!0===await a$(()=>a.cancelOrder(b))}:{action:"none",ok:!0,reason:"no_order"}}async function a0({apiKey:a,phone:b,region:d,fiveSimOrderId:e,account:f}){let{createProviderConnection:g}=await Promise.resolve().then(c.bind(c,71998)),h={provider:"codebuddy-cn",authType:"apikey",apiKey:a,accessToken:a,name:b||`5sim-${e}`,email:b||`5sim-${e}`,providerSpecificData:{domain:"www.codebuddy.cn",phoneNumber:b,fiveSimOrderId:e,region:d,automation:"5sim-phone-bulk"},testStatus:"active"};return{connection:await g(h)}}class a1 extends i.Q6{constructor({browserLauncher:a,requestDeviceCodeFn:b=ax.cT,pollToken:d=ax.ZV,fetchLoginAccountFn:e=ax.w8,saveConnection:g=a0,fiveSimClientFactory:i=a2,phoneAutomation:j=aj,phoneFormatter:k=aK,pollIntervalMs:l=n.ne.pollInterval,storageName:m="codebuddy-cn-bulk-import"}={}){super({browserLauncher:a||(async a=>{let{forceCloseBrowser:b,launchBulkImportBrowser:d}=await Promise.resolve().then(c.bind(c,75949)),e=Array.isArray(a?.proxyUrls)&&a.proxyUrls.length?a.proxyUrls[0]:null;return aQ(d({engine:a?.engine||"cloakbrowser",proxyUrl:e,headless:!1,windowSize:{width:1280,height:900},requireProxyGeoip:!!e}),{timeoutMs:9e4,message:"CloakBrowser launch timed out after 90s",code:"CN_BROWSER_LAUNCH_TIMEOUT",onLateResolve:a=>b(a)})}),storageName:m}),this.latestJobId&&this.readPersistedJob(this.latestJobId)||(this.latestJobId=function(a){try{let b=f().readdirSync(a).filter(a=>a.endsWith(".json")&&"meta.json"!==a).map(b=>{let c=h().join(a,b);try{let a=JSON.parse(f().readFileSync(c,"utf8"));if(!a?.jobId)return null;let b=Date.parse(a.createdAt||""),d=Number.isFinite(b)?b:f().statSync(c).mtimeMs;return{jobId:a.jobId,sortTime:d}}catch{return null}}).filter(Boolean).sort((a,b)=>b.sortTime-a.sortTime);return b[0]?.jobId||null}catch{return null}}(this.storageDir),this.latestJobId&&this.persistLatestJobId(this.latestJobId)),this.requestDeviceCode=b,this.pollToken=d,this.fetchLoginAccount=e,this.saveConnection=g,this.fiveSimClientFactory=i,this.phoneAutomation=j,this.phoneFormatter=k,this.pollIntervalMs=l}async startJob({count:a,concurrency:b,proxyPoolMode:c,proxyPoolId:e,manualProxyUrl:f,region:g}){let h=Number.parseInt(a,10);if(!Number.isFinite(h)||h<1)throw Object.assign(Error("At least one account is required (count >= 1)"),{error:"At least one account is required (count >= 1)"});if(h>az)throw Object.assign(Error(`Count exceeds maximum of ${az}`),{error:`Count exceeds maximum of ${az}`});this.latestJobId&&!this.jobs.has(this.latestJobId)&&this.getJob(this.latestJobId);let k=[...this.jobs.values()].find(a=>a&&("running"===a.status||"queued"===a.status||"needs_manual"===a.status)&&!a.cancelRequested);if(k)throw Object.assign(Error(`Another CodeBuddy CN job is still active (${k.jobId}). Cancel it or wait before starting again.`),{error:`Another CodeBuddy CN job is still active (${k.jobId}). Cancel it or wait before starting again.`});let m=aG.has(g)?g:aH,n=[],o="string"==typeof f?f.trim():"";if(o){if(!/^(https?|socks4|socks5):\/\/.+/i.test(o))throw Object.assign(Error("manualProxyUrl must be a valid proxy URL (http://, https://, socks4://, or socks5://)"),{error:"manualProxyUrl must be a valid proxy URL (http://, https://, socks4://, or socks5://)"});n=[o]}else if("all"===c)n=(await (0,j.ui)({isActive:!0})).map(a=>a.proxyUrl).filter(Boolean);else if("single"===c&&e){let a=await (0,j.hr)(e);a?.isActive&&a?.proxyUrl&&(n=[a.proxyUrl])}o||function(a,b){if(!["all","single"].includes(a)||b.length>0)return;let c="single"===a?"Selected proxy is missing or inactive; no automation was started":"No active proxies are available in the selected pool; no automation was started";throw Object.assign(Error(c),{error:c,code:"CN_PROXY_SELECTION_EMPTY"})}(c,n);let p=(0,d.randomUUID)(),q=(0,i.kF)(),r={jobId:p,status:"running",concurrency:function(a,{manualProxy:b=!1,processBoundProxy:c=!1}={}){return b||c?1:function(a){if(aM(),(0,l.uT)(a))return Math.min(1,Math.max(1,(0,l.q)()));let b=Number.parseInt(a,10);return Number.isFinite(b)?Math.min(1,Math.max(1,b)):1}(a)}(b,{manualProxy:!!o,processBoundProxy:n.length>0}),proxyPoolMode:o?"manual":c||"none",proxyUrls:n,region:m,createdAt:q,startedAt:q,finishedAt:null,error:null,cancelRequested:!1,browser:null,nextIndex:0,manualFollowups:new Set,persistPromise:Promise.resolve(),lastPreview:null,lastPreviewCapturedAt:0,accounts:Array.from({length:h},(a,b)=>({line:b+1,region:m,phone:null,fiveSimOrderId:null,fiveSimActivationId:null,fingerprintSeed:(0,d.randomUUID)(),proxyUrl:null,egressIp:null,proxyTimezone:null,proxyLocale:null,abortController:new AbortController,status:"queued",error:null,connectionId:null,workerId:null,manualSession:null,runtimeSession:null,currentStep:"queued",updatedAt:q,logs:[(0,i.hn)("queued","Queued and waiting for an available worker")]}))};return this.jobs.set(p,r),this.latestJobId=p,this.persistLatestJobId(p),await this.persistJobSnapshot(r,{forcePreview:!1}),this.runJob(p),a4(r)}buildPersistedSnapshot(a){return a4(a,{preview:a.lastPreview||null})}terminalizeInterruptedSnapshot(a){if(!a||!aI.has(a.status))return a;let b="CodeBuddy CN job was interrupted by a service restart. Browser and OTP sessions cannot be resumed safely; start a new job.",c=(a.accounts||[]).map(a=>{if(!aJ.has(a.status))return a;let c=(0,i.hn)("failed",b,"error");return{...a,status:"failed",error:b,currentStep:"failed",updatedAt:c.at,manualSessionAvailable:!1,logs:[...a.logs||[],c].slice(-40)}}),d={...a,status:"failed",error:a.error||b,finishedAt:a.finishedAt||(0,i.kF)(),accounts:c,summary:a3(c),preview:null};return this.writePersistedJob(a.jobId,d),d}getJob(a){let b=this.jobs.get(a);if(b)return a4(b);let c=this.readPersistedJob(a);return c?this.terminalizeInterruptedSnapshot(c):null}async getJobWithPreview(a){let b=this.jobs.get(a);return b?(await this.persistJobSnapshot(b,{forcePreview:!1}),a4(b,{preview:b.lastPreview||null})):this.getJob(a)}async processAccount(a,b,c){if(a.cancelRequested)return void this.finalizeAccount(b,"cancelled",{error:"Job cancelled"});if(!a.browser){this.setAccountStep(b,"recovering_browser","Relaunching CodeBuddy CN browser after a prior worker failure");try{let b=Promise.resolve().then(()=>this.browserLauncher(a));a.browser=await aQ(b,{timeoutMs:9e4,message:"CodeBuddy CN browser recovery timed out after 90s",code:"CN_BROWSER_RECOVERY_TIMEOUT",onLateResolve:a=>(0,ay.forceCloseBrowser)(a)})}catch(c){this.finalizeAccount(b,"failed",{error:c?.message||"CodeBuddy CN browser recovery failed",step:"browser_recovery_failed",message:c?.message||"CodeBuddy CN browser recovery failed"}),await this.persistJobSnapshot(a,{forcePreview:!0});return}if(a.cancelRequested){let c=a.browser;a.browser=null,await (0,ay.forceCloseBrowser)(c).catch(()=>null),this.finalizeAccount(b,"cancelled",{error:"Job cancelled"});return}}let d=null,e=null,f=!1,g=null,h=!1,j=null;try{let c;this.setAccountStep(b,"reading_settings","Reading 5sim API key from settings"),await this.persistJobSnapshot(a,{forcePreview:!0});let l=(await (0,k.mt)()).fiveSimApiKey;if(!l||!l.trim()){this.finalizeAccount(b,"failed",{error:"5sim API key not configured. Set it in the automation modal or dashboard settings.",step:"failed",message:"5sim API key not configured"}),await this.persistJobSnapshot(a,{forcePreview:!0});return}d=this.fiveSimClientFactory({apiKey:l,proxyOptions:null}),this.setAccountStep(b,"creating_browser","Creating browser context (before 5sim order)"),await this.persistJobSnapshot(a,{forcePreview:!0}),h=!0;let m=(0,i.go)(a.browser,b.proxyUrl,{profile:"codebuddy-cn",region:a.region||"hongkong",fingerprintSeed:b.fingerprintSeed,lowMemory:aM(),nativeCloakProfile:aN(a)&&!!b.proxyUrl}),n=await aQ(m,{timeoutMs:3e4,message:"Browser context creation timed out after 30s",code:"CN_CONTEXT_TIMEOUT",onLateResolve:a=>Promise.resolve(a?.context?.close?.()).catch(()=>null)});g=n.context;let o=n.page;b.runtimeSession={context:g,page:o},h=!1;let p=(0,ay.getCloakProxyProfile)(a.browser);if(b.proxyUrl&&(!function(a){let b=String(a?.countryCode||"").trim().toUpperCase();if(!(!b||aF.has(b)))throw Object.assign(Error(`CodeBuddy CN requires a CN/HK residential exit; detected ${b}. No phone number was purchased.`),{code:"CN_PROXY_REGION_UNSUPPORTED",countryCode:b})}(p),b.proxyTimezone=p?.timezone||null,b.proxyLocale=p?.locale||null),"manual"===a.proxyPoolMode&&b.proxyUrl){this.setAccountStep(b,"checking_proxy_egress","Verifying pasted proxy exit IP before opening the registration form"),await this.persistJobSnapshot(a,{forcePreview:!1});let c=await aO(g);b.egressIp=j=aP(c),b.proxyTimezone=p?.timezone||null,b.proxyLocale=p?.locale||null,this.setAccountStep(b,"proxy_egress_ready",`Manual proxy verified: ${j} (${c.samples} checks, ${b.proxyTimezone||"timezone unknown"}, ${b.proxyLocale||"locale unknown"})`),await this.persistJobSnapshot(a,{forcePreview:!1})}if(a.cancelRequested)throw Error("Job cancelled before ordering phone number");this.setAccountStep(b,"registering","Running phone registration on CodeBuddy CN"),await this.persistJobSnapshot(a,{forcePreview:!0});try{o.setDefaultTimeout(2e4),o.setDefaultNavigationTimeout(45e3)}catch{}let q=null,r=null,s=new Promise((a,b)=>{r=b}),t=()=>{q&&clearTimeout(q),q=setTimeout(()=>{let a=Object.assign(Error(`CodeBuddy CN account hard timeout after ${Math.round(aA/1e3)}s (browser will be force-closed)`),{code:"CN_ACCOUNT_HARD_TIMEOUT"});b.abortController&&!b.abortController.signal.aborted&&b.abortController.abort(a),r(a)},aA),"function"==typeof q.unref&&q.unref()};t();try{c=await Promise.race([this.phoneAutomation({page:o,signal:b.abortController?.signal,isCancelled:()=>!0===a.cancelRequested,resolvePhone:async()=>{if(a.cancelRequested)throw Error("Job cancelled before ordering phone number");if("manual"===a.proxyPoolMode&&b.proxyUrl){this.setAccountStep(b,"rechecking_proxy_egress","Registration form is ready — confirming the pasted proxy stayed sticky"),await this.persistJobSnapshot(a,{forcePreview:!1});let c=await aO(g);aP(c,j),this.setAccountStep(b,"proxy_egress_confirmed",`Manual proxy remained on ${j}; safe to purchase one phone number`),await this.persistJobSnapshot(a,{forcePreview:!1})}this.setAccountStep(b,"ordering_number",`Form ready — ordering ${a.region} phone from 5sim (single buy)`),await this.persistJobSnapshot(a,{forcePreview:!0});let c=await d.buyNumber({country:a.region,product:"codebuddy",allowProductFallback:!1,signal:b.abortController?.signal});return e=c.id,b.phone=c.phone,b.fiveSimOrderId=c.id,b.fiveSimActivationId=c.id,this.setAccountStep(b,"number_ordered",`Phone number ordered: ${c.phone} (1 buy, no re-order)`),await this.persistJobSnapshot(a,{forcePreview:!0}),c.phone},waitForSms:async()=>{if(!e)throw Error("Cannot poll SMS — no 5sim order id");this.setAccountStep(b,"sms_poll_started","SMS poll started (full 90s window after send-code)"),await this.persistJobSnapshot(a,{forcePreview:!1});let c=await d.pollCode(e,{timeoutMs:9e4,signal:b.abortController?.signal});return f=!0,c},onManualRequired:async({phase:c}={})=>{if("sms_request"===c){if(b.abortController?.signal.aborted||a.cancelRequested)throw b.abortController?.signal.reason||Object.assign(Error("Job cancelled"),{code:"JOB_CANCELLED"});t(),aL(b,g,o),this.finalizeAccount(b,"needs_manual",{error:"Captcha blocked the SMS request; complete it in the existing browser",step:"awaiting_sms_captcha",message:"Open the manual session and complete the SMS-request captcha"}),await this.persistJobSnapshot(a,{forcePreview:!0})}},onManualResolved:async({phase:c}={})=>{if("sms_request"===c){if(a.cancelRequested)throw Object.assign(Error("Job cancelled"),{code:"JOB_CANCELLED"});b.manualSession=null,b.status="running",b.error=null,this.setAccountStep(b,"sms_captcha_completed","SMS-request captcha completed; automation resumed"),await this.persistJobSnapshot(a,{forcePreview:!0})}},onStep:(c,d)=>{this.setAccountStep(b,c,d),this.persistJobSnapshot(a,{forcePreview:!1})},phoneFormatter:this.phoneFormatter}),s])}finally{q&&clearTimeout(q)}if(a.cancelRequested||b.abortController?.signal.aborted){let a=b.abortController?.signal.reason;if(a?.code==="CN_ACCOUNT_HARD_TIMEOUT")throw a;throw Object.assign(Error("Job cancelled"),{code:"JOB_CANCELLED"})}if(String(c.status||"").startsWith("failed")){let h=c.error||"Phone registration failed before submit",i=c.status||"failed";this.finalizeAccount(b,i,{error:h,step:i,message:h}),d&&e&&(f?await a$(()=>d.finishOrder(e)):await a$(()=>d.cancelOrder(e))),b.manualSession=null,b.runtimeSession=null,await aZ(g,a),await this.persistJobSnapshot(a,{forcePreview:!0});return}if("needs_manual"===c.status){aL(b,g,o),this.finalizeAccount(b,"needs_manual",{error:c.error||"Manual completion is required",step:"awaiting_manual",message:c.error||"Complete the existing CodeBuddy login session manually"});let h=!1;d&&e&&f&&(await a$(()=>d.finishOrder(e)),h=!0),await this.persistJobSnapshot(a,{forcePreview:!0}),await this.runCnManualFollowup(a,b,b.workerId,g,o,d,e,null,{smsReceived:f,orderSettled:h});return}if("success"!==c.status)throw Error(`Unexpected phone automation status: ${c.status||"unknown"}`);await this.captureApiKey(a,b,g,o,d,e);return}catch(o){let c=o?.isUpstreamTerminal===!0,i=o instanceof u&&!c,j=o instanceof u&&o?.orderStatus==="TIMEOUT",k=o instanceof y,l=a.cancelRequested||o?.code==="JOB_CANCELLED",m=await a_({fiveSimClient:d,fiveSimOrderId:e,smsReceived:f,error:o}),n=l?"Job cancelled":i?"SMS OTP not received within 90s":j?"5sim marked the order as TIMEOUT before an SMS arrived":k?"5sim marked the phone number as BANNED before an SMS arrived":o.message||"Unexpected CodeBuddy CN bulk import failure";if(i&&"cancel"===m.action&&m.ok&&(n+="; order cancelled for refund"),"none"===m.action||m.ok||(n+=`; 5sim ${m.action} could not be confirmed for order ${e} - check 5sim manually`),this.finalizeAccount(b,l?"cancelled":"failed",{error:n,step:l?"cancelled":i?"sms_timeout":j?"sms_order_timeout":k?"sms_number_banned":"failed",message:n}),b.manualSession=null,b.runtimeSession=null,await aZ(g,a),(o?.code==="CN_ACCOUNT_HARD_TIMEOUT"||o?.code==="CN_CONTEXT_TIMEOUT"||h||a.cancelRequested)&&a.browser){let b=a.browser;a.browser=null,await (0,ay.forceCloseBrowser)(b).catch(()=>null)}await this.persistJobSnapshot(a,{forcePreview:!0})}}async captureApiKey(a,b,c,d,e,f){let g="personal-edition-user-id",h=null,i=async(a,{timeout:b=12e3,interval:c=150}={})=>{let d=Date.now()+b;for(;Date.now()<d;){try{if(await a())return!0}catch{}await new Promise(a=>setTimeout(a,c))}return!1};try{this.setAccountStep(b,"waiting_session","Establishing CodeBuddy console session (probe APIs, not just cookies)"),await this.persistJobSnapshot(a,{forcePreview:!0});let j=async()=>{let a=await c.cookies().catch(()=>[]);return{cookies:a,names:new Set(a.map(a=>a.name)),list:a.map(a=>a.name)}},k=a=>a.has("AUTH_SESSION_ID")||a.has("session")||a.has("qcloud_uid")||a.has("qcmainCSRFToken")||a.has("x_host_key_access"),l=()=>aX({context:c,page:d}),m=async(a=2500)=>{let b=!1,c=null;try{await Promise.race([d.waitForLoadState("domcontentloaded",{timeout:a}).catch(()=>null),i(async()=>{if(b)return!0;let a=await j();return aT(a.names)},{timeout:a,interval:200}),new Promise(b=>{c=setTimeout(b,a)})])}finally{b=!0,c&&clearTimeout(c)}},n=async a=>{let b=Date.now();try{await d.goto(a,{waitUntil:"commit",timeout:18e3});let c=18e3-(Date.now()-b);return c>0&&await m(Math.min(2500,c)),!0}catch{return!1}},o=["https://www.codebuddy.cn/","https://www.codebuddy.cn/console","https://www.codebuddy.cn/console/","https://www.codebuddy.cn/profile","https://www.codebuddy.cn/profile/keys"],p=null,q=null,r=!1,s="",t=null,u=0;for(let c=0;c<6;c+=1){if(a.cancelRequested)throw Error("Job cancelled while establishing session");let e=await j(),f=aT(e.names),g=k(e.names),h=o[Math.min(c,o.length-1)];c<3||c%2==0||!g?(this.setAccountStep(b,"waiting_session",`OIDC handoff ${c+1}/6 → ${h.replace("https://www.codebuddy.cn","")} (${f?"KEYCLOAK":g?"soft-session":"weak"})`),await this.persistJobSnapshot(a,{forcePreview:!1}),await n(h)):await new Promise(a=>setTimeout(a,300)),/^https:\/\/www\.codebuddy\.cn(?:[/:]|$)/i.test(d.url?.()||"")||await n("https://www.codebuddy.cn/console"),q=await l(),p=aU(q),(q?.status>0||q?.text||q?.data)&&(t=q),s=JSON.stringify(q?.data??q?.text??q?.error??null).slice(0,180);let i=aS(q),m=aV(q),v=await j();if(!aT(v.names)&&aW(q,v.names)?u+=1:u=0,u>=2)throw Object.assign(Error(`Tencent restricted the post-OTP session (${u} console probes returned login/risk evidence; source=${q?.source||"unknown"})`),{code:aD});if(m&&Array.isArray(p)&&p.length>0){r=!0,this.setAccountStep(b,"session_ready",`Console session accepted (HTTP 200, ${p.length} account(s)${f?", KEYCLOAK ok":", soft session"})`),await this.persistJobSnapshot(a,{forcePreview:!0});break}if(g&&m&&Array.isArray(p)&&0===p.length&&c>=3){this.setAccountStep(b,"session_soft","Console HTTP 200 but 0 accounts — trying personal API key with soft session (cookies ok)"),await this.persistJobSnapshot(a,{forcePreview:!0}),r=!0;break}this.setAccountStep(b,"resolving_enterprise",`Console not ready (HTTP ${q?.status||0}, accounts=${Array.isArray(p)?p.length:"unrecognized"}${i?", login HTML":""}, source=${q?.source||"unknown"}) — ${c+1}/6 body=${s.slice(0,80)}`),await this.persistJobSnapshot(a,{forcePreview:!1})}if(!r){let a=await j(),b=t||q,c=aW(b,a.names)||a.names.has("login_risk_state")&&u>0;throw Object.assign(Error(c?`Tencent restricted the post-OTP session (HTTP ${b?.status||0}; login_risk_state present; source=${b?.source||"unknown"})`:`Console accounts unavailable after login (HTTP ${b?.status||0}; cookies: ${a.list.slice(0,18).join(",")||"(none)"}; body=${s.slice(0,120)}; probeError=${q?.error||"none"}) — session not accepted for API key`),{code:c?aD:"CN_CONSOLE_SESSION_UNAVAILABLE"})}let v=g;if(Array.isArray(p)&&p.length>0){let a=p.find(a=>a?.lastLogin)||p[0];a?.type&&"personal"!==a.type&&a.enterpriseId?v=a.enterpriseId:a?.enterpriseId&&a?.type!=="personal"&&(v=a.enterpriseId)}this.setAccountStep(b,"creating_api_key",`Creating API key (enterprise=${v}, accounts=${p.length})`),await this.persistJobSnapshot(a,{forcePreview:!0});let w=`zevai-router-${b.workerId||"account"}-${Date.now()}`,x=async a=>d.evaluate(async({enterpriseId:a,keyName:b,timeoutMs:c})=>{let d=new AbortController,e=setTimeout(()=>d.abort(),c);try{let c=window.location.hostname||"www.codebuddy.cn",e="www.codebuddy.cn"===c?window.location.origin:"https://www.codebuddy.cn",f=await fetch(`${e}/console/api/client/v1/api-keys`,{method:"POST",credentials:"include",signal:d.signal,headers:{"Content-Type":"application/json",Accept:"application/json, text/plain, */*","x-requested-with":"XMLHttpRequest","X-Domain":"www.codebuddy.cn","X-Product":"SaaS"},body:JSON.stringify({name:b,expire_in_days:365,user_enterprise_id:a})}),g=await f.text().catch(()=>""),h=null;try{h=g?JSON.parse(g):null}catch{h={_raw:String(g||"").slice(0,200)}}return{ok:f.ok,status:f.status,data:h}}catch(a){return{ok:!1,status:0,outcomeUnknown:!0,timedOut:a?.name==="AbortError",error:a?.message||String(a)}}finally{clearTimeout(e)}},{enterpriseId:a,keyName:w,timeoutMs:6e4}),y=async(c,d)=>{let e,f=Date.now(),g=null,h=setInterval(()=>{if(g)return;let c=Math.max(5,Math.round((Date.now()-f)/1e3));this.setAccountStep(b,"creating_api_key",`${d} — waiting for CodeBuddy (${c}s)`),g=this.persistJobSnapshot(a,{forcePreview:!1}).catch(()=>null).finally(()=>{g=null})},5e3);"function"==typeof h.unref&&h.unref();try{e=await aQ(x(c),{timeoutMs:6e4,message:"API key request timed out after 60s; creation outcome is unknown",code:aB})}catch(a){if(a?.code===aB)throw a;throw Object.assign(Error(`API key request lost its response; creation outcome is unknown: ${a?.message||String(a)}`),{code:aB})}finally{clearInterval(h),g&&await g.catch(()=>null)}if(e?.outcomeUnknown){let a=e.timedOut?"timed out after 60s":`lost its response (${e.error||"network error"})`;throw Object.assign(Error(`API key request ${a}; creation outcome is unknown`),{code:aB})}return aR(e,d)};if(!await n("https://www.codebuddy.cn/profile/keys"))throw Object.assign(Error("Keys page navigation timed out after 18s"),{code:"CN_CONSOLE_NAV_TIMEOUT"});let z=await y(v,"Creating API key");z?.status===400&&v!==g&&(this.setAccountStep(b,"retrying_api_key","Retrying with personal-edition enterprise id"),await this.persistJobSnapshot(a,{forcePreview:!1}),z=await y(g,"Retrying personal API key"));let A=a=>a?.ok===!1&&(401===a.status||403===a.status);for(let c=1;c<=2&&A(z);c+=1){for(let d of(this.setAccountStep(b,"retrying_api_key",`API key 401/403 — OIDC re-handoff round ${c}/2 (waiting strong session)`),await this.persistJobSnapshot(a,{forcePreview:!0}),["https://www.codebuddy.cn/","https://www.codebuddy.cn/console","https://www.codebuddy.cn/profile/keys"]))await n(d);await i(async()=>{let a=await j();return aT(a.names)},{timeout:8e3*c,interval:300}).catch(()=>null),z=await y(g,`Retrying API key after OIDC handoff ${c}/2`)}let B=z?.data?.code;if(!z||!z.ok||!z.data||0!==B&&200!==B&&void 0!==B){let a="string"==typeof z?.data?._raw?z.data._raw.replace(/\s+/g," ").slice(0,120):null,b=a&&/openresty|nginx|Authorization Required/i.test(a)?" [edge proxy blocked — session half-baked]":"";throw Error(`API key creation failed (HTTP ${z?.status??"no-response"}, code=${B??"n/a"})${b}: ${JSON.stringify(z?.data??null).slice(0,200)}`)}let C=z.data?.data||z.data,D=C?.apiKey||C?.key||C?.token||C?.secret||C?.api_key||("string"==typeof C?C:null)||z.data.apiKey||z.data.key||z.data.token||z.data.secret;if(!D||"string"!=typeof D)throw Object.assign(Error(`API key response did not contain a key field; creation outcome is unknown: ${JSON.stringify(z.data).slice(0,300)}`),{code:aB});h=D,this.setAccountStep(b,"api_key_created","API key created successfully"),await this.persistJobSnapshot(a,{forcePreview:!0}),this.setAccountStep(b,"saving_connection","Saving CodeBuddy CN connection"),await this.persistJobSnapshot(a,{forcePreview:!0});let{connection:E}=await this.saveConnection({apiKey:D,phone:b.phone,region:b.region,fiveSimOrderId:f,account:b});await a$(()=>e.finishOrder(f)),this.finalizeAccount(b,"success",{connectionId:E.id,step:"connection_saved",message:`CodeBuddy CN connection saved (phone: ${b.phone})`}),b.runtimeSession=null,await aZ(c,a),await this.persistJobSnapshot(a,{forcePreview:!0})}catch(m){let g=m?.code===aD,i=m?.code===aB,j=m?.code===aC,k=i||j;if(g){this.finalizeAccount(b,"failed_restricted",{error:`${m.message}. Use a different residential CN/HK proxy with concurrency 1.`,step:"failed_restricted",message:"Tencent restricted the post-OTP session; API-key capture was not attempted"}),await a$(()=>e.finishOrder(f)),b.runtimeSession=null,await aZ(c,a),await this.persistJobSnapshot(a,{forcePreview:!0});return}let l=i?`${m.message}. Check the CodeBuddy keys page before creating another key.`:m.message;if(k||aL(b,c,d),this.finalizeAccount(b,"needs_manual",{error:`Registration succeeded but API key capture failed: ${l}`,step:i?"api_key_outcome_unknown":j?"api_key_retry_stopped":"awaiting_manual",message:i?"Registration done; API key request outcome is unknown. Check existing keys before retrying.":j?"Registration done; API key request was rate limited. Automatic POST retries stopped.":h?`API key captured; retrying local connection save without creating another key: ${m.message}`:`Registration done, API key capture failed: ${m.message}`}),await a$(()=>e.finishOrder(f)),await this.persistJobSnapshot(a,{forcePreview:!0}),k){b.runtimeSession=null,await aZ(c,a);return}await this.runCnManualFollowup(a,b,b.workerId,c,d,e,f,h)}}async runCnManualFollowup(a,b,c,d,e,f,g,h=null,{smsReceived:i=!0,orderSettled:j=!0}={}){let k=(async()=>{let c=!1,l=async()=>{let c=b.manualSession,e=c?.context||d,f=c?.headedBrowser||null;await aZ(e,a),f&&await (0,ay.forceCloseBrowser)(f).catch(()=>null)};try{this.setAccountStep(b,"manual_waiting","Waiting for operator to complete in headed browser"),await this.persistJobSnapshot(a,{forcePreview:!0});let f=aM()?18e4:48e4,i=Date.now()+f,j="string"==typeof h&&h?h:null,k=!!j;for(;!k&&Date.now()<i&&!a.cancelRequested;){let a=await d.cookies().catch(()=>[]);if(aT(a)){k=!0;break}let b=await aX({context:d,page:e}).catch(()=>null);if(aV(b)){k=!0;break}await new Promise(a=>setTimeout(a,1e4))}if(a.cancelRequested){this.finalizeAccount(b,"cancelled",{error:"Job cancelled",step:"cancelled",message:"Job cancelled while waiting for manual completion"}),await this.persistJobSnapshot(a,{forcePreview:!0});return}if(!k)throw Error("Manual assist timed out — CodeBuddy login was not authenticated");if(!j){this.setAccountStep(b,"manual_authenticated","Manual login authenticated; creating one API key"),await this.persistJobSnapshot(a,{forcePreview:!0}),await e.goto("https://www.codebuddy.cn/profile/keys",{waitUntil:"commit",timeout:18e3});let c=`zevai-router-manual-${b.workerId||"account"}-${Date.now()}`,d=await aQ(e.evaluate(async({keyName:a,timeoutMs:b})=>{let c=new AbortController,d=setTimeout(()=>c.abort(),b);try{let b=await fetch("https://www.codebuddy.cn/console/api/client/v1/api-keys",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json, text/plain, */*","x-requested-with":"XMLHttpRequest","X-Domain":"www.codebuddy.cn","X-Product":"SaaS"},credentials:"include",signal:c.signal,body:JSON.stringify({name:a,expire_in_days:365,user_enterprise_id:"personal-edition-user-id"})}),d=await b.json().catch(()=>null);return{ok:b.ok,status:b.status,data:d}}catch(a){return{ok:!1,status:0,outcomeUnknown:!0,error:a?.message||String(a)}}finally{clearTimeout(d)}},{keyName:c,timeoutMs:6e4}),{timeoutMs:6e4,message:"Manual API key request timed out; creation outcome is unknown",code:aB});if(d?.outcomeUnknown)throw Object.assign(Error(`Manual API key request lost its response; creation outcome is unknown: ${d.error||"network error"}`),{code:aB});if(aR(d,"Manual API key request"),!d?.ok)throw Error(`Manual API key request failed (HTTP ${d?.status||0}); it was not retried`);let f=d.data?.data||d.data;if(!(j=f?.apiKey||f?.key||f?.token||f?.secret||f?.api_key||("string"==typeof f?f:null))||"string"!=typeof j)throw Object.assign(Error("Manual API key response was successful but did not contain the key; creation outcome is unknown"),{code:aB})}this.setAccountStep(b,"saving_connection","Saving CodeBuddy CN connection (manual)"),await this.persistJobSnapshot(a,{forcePreview:!0});let{connection:l}=await this.saveConnection({apiKey:j,phone:b.phone,region:b.region,fiveSimOrderId:g,account:b});this.finalizeAccount(b,"success",{connectionId:l.id,step:"connection_saved",message:`CodeBuddy CN connection saved via manual assist (phone: ${b.phone||"N/A"})`}),c=!0,await this.persistJobSnapshot(a,{forcePreview:!0})}catch(c){if(a.cancelRequested)this.finalizeAccount(b,"cancelled",{error:"Job cancelled",step:"cancelled",message:"Job cancelled while waiting for manual completion"});else c?.code===aB||c?.code===aC?this.finalizeAccount(b,"needs_manual",{error:`${c.message}. Check existing CodeBuddy keys before retrying manually.`,step:c?.code===aB?"api_key_outcome_unknown":"api_key_retry_stopped",message:"Manual API key POST retries stopped"}):this.finalizeAccount(b,"failed",{error:c.message||"Manual assist flow failed",step:"failed",message:c.message||"Manual assist flow failed"});await this.persistJobSnapshot(a,{forcePreview:!0})}finally{if(!j&&f&&g){let a=c||i?"finishOrder":"cancelOrder";await a$(()=>f[a](g))||this.setAccountStep(b,"fivesim_settle_failed",`5sim ${a} could not be confirmed for order ${g} - check 5sim manually`,"warn")}await l(),b.manualSession=null,b.runtimeSession=null,a.manualFollowups.delete(k),await this.persistJobSnapshot(a,{forcePreview:!0})}})();return a.manualFollowups.add(k),k}async runWorker(a,b){if(!aN(a))return super.runWorker(a,b);for(;!a.cancelRequested;){let c=this.dequeueAccount(a,b);if(!c)return;if(!a.browser)try{a.browser=await this.browserLauncher({...a,proxyUrls:c.proxyUrl?[c.proxyUrl]:a.proxyUrls})}catch(b){this.finalizeAccount(c,"failed",{error:b?.message||"Manual proxy browser launch failed",step:"failed",message:b?.message||"Manual proxy browser launch failed"}),await this.persistJobSnapshot(a,{forcePreview:!0});continue}try{await this.processAccount(a,c,b)}catch(b){"running"===c.status&&(this.finalizeAccount(c,"failed",{error:b?.message||"Unexpected manual proxy worker failure",step:"failed",message:b?.message||"Unexpected manual proxy worker failure"}),await this.persistJobSnapshot(a,{forcePreview:!0}))}finally{if(a.manualFollowups.size>0&&await Promise.allSettled([...a.manualFollowups]),a.browser){let b=a.browser;a.browser=null,await (0,ay.forceCloseBrowser)(b).catch(()=>null)}}}}shouldPrelaunchBrowser(a){return!aN(a)}cancelJob(a){let b=this.jobs.get(a);if(!b)return null;for(let a of(b.cancelRequested=!0,b.accounts)){a.abortController&&!a.abortController.signal.aborted&&a.abortController.abort();let b=a.manualSession,c=a.runtimeSession,d=new Set([b?.context,c?.context].filter(Boolean)),e=new Set([b?.headedBrowser,b?.ownedBrowser].filter(Boolean));Promise.allSettled([...[...d].map(a=>aY(a)),...[...e].map(a=>(0,ay.forceCloseBrowser)(a))]),a.runtimeSession=null,a.manualSession=null,aJ.has(a.status)&&this.finalizeAccount(a,"cancelled",{error:"Job cancelled",step:"cancelled",message:"Job cancelled by user"})}if(b.browser){let a=b.browser;b.browser=null,(0,ay.forceCloseBrowser)(a).catch(()=>null)}return aI.has(b.status)&&(b.status="cancelled",b.finishedAt=b.finishedAt||(0,i.kF)()),this.persistJobSnapshot(b,{forcePreview:!0}),a4(b)}}function a2({apiKey:a,proxyOptions:b}){return new z({apiKey:a,proxyOptions:b})}function a3(a=[]){let b={total:a.length,queued:0,running:0,completed:0,success:0,failed:0,needs_manual:0,cancelled:0};for(let c of a){let a=c.status||"queued";"success"===a?(b.success+=1,b.completed+=1):a.startsWith("failed")?(b.failed+=1,b.completed+=1):"needs_manual"===a?b.needs_manual+=1:"cancelled"===a?(b.cancelled+=1,b.completed+=1):"running"===a?b.running+=1:b.queued+=1}return b}function a4(a,b={}){return a?{jobId:a.jobId,status:a.status,summary:a3(a.accounts),concurrency:a.concurrency,proxyPoolMode:a.proxyPoolMode,region:a.region,createdAt:a.createdAt,startedAt:a.startedAt,finishedAt:a.finishedAt,error:(0,m.yr)(a.error),cancelRequested:a.cancelRequested,accounts:(a.accounts||[]).map(a=>({line:a.line,region:a.region,phone:a.phone,fiveSimOrderId:a.fiveSimOrderId,proxyUrl:a.proxyUrl?function(a){if(!a)return null;let b=String(a),c=()=>b.length>20?`${b.slice(0,10)}***${b.slice(-10)}`:"***";try{let a=new URL(b);if(!/^(https?|socks4|socks5):$/.test(a.protocol))return c();return(0,m.Eq)(b)}catch{return c()}}(a.proxyUrl):null,egressIp:a.egressIp||null,proxyTimezone:a.proxyTimezone||null,proxyLocale:a.proxyLocale||null,status:a.status,error:(0,m.yr)(a.error),connectionId:a.connectionId,workerId:a.workerId,manualSessionAvailable:!!a.manualSession,currentStep:a.currentStep,updatedAt:a.updatedAt,logs:(a.logs||[]).map(a=>({...a,message:(0,m.yr)(a.message)}))})),preview:void 0!==b.preview?b.preview:a.lastPreview||null,...b}:null}function a5(){return(!globalThis.__codeBuddyCnBulkImportSingleton&&(globalThis.__codeBuddyCnBulkImportSingleton={manager:new a1}),globalThis.__codeBuddyCnBulkImportSingleton).manager}}};
|
|
1
|
+
"use strict";exports.id=8371,exports.ids=[3662,8371],exports.modules={3662:(a,b,c)=>{c.d(b,{EQ:()=>f,LY:()=>d,O:()=>e,fh:()=>h,t2:()=>i,wf:()=>g});let d={400:{type:"invalid_request_error",code:"bad_request"},401:{type:"authentication_error",code:"invalid_api_key"},402:{type:"billing_error",code:"payment_required"},403:{type:"permission_error",code:"permission_denied"},404:{type:"invalid_request_error",code:"model_not_found"},406:{type:"invalid_request_error",code:"model_not_supported"},429:{type:"rate_limit_error",code:"rate_limit_exceeded"},500:{type:"server_error",code:"internal_server_error"},502:{type:"server_error",code:"bad_gateway"},503:{type:"server_error",code:"service_unavailable"},504:{type:"server_error",code:"gateway_timeout"}},e={400:"Bad request",401:"Invalid API key provided",402:"Payment required",403:"Access forbidden by upstream provider.",404:"Model not found",406:"Model not supported",429:"Rate limit exceeded",500:"Internal server error",502:"Bad gateway - upstream provider error",503:"Service temporarily unavailable",504:"Gateway timeout"},f={base:2e3,max:3e5,maxLevel:15},g=3e4,h=6048e5,i=[{text:"no credentials",cooldownMs:12e4},{text:"request not allowed",cooldownMs:5e3},{text:"improperly formed request",cooldownMs:12e4},{text:"rate limit",backoff:!0},{text:"too many requests",backoff:!0},{text:"quota exceeded",backoff:!0},{text:"capacity",backoff:!0},{text:"overloaded",backoff:!0},{status:401,cooldownMs:12e4},{status:402,cooldownMs:12e4},{status:403,cooldownMs:12e4},{status:404,cooldownMs:12e4},{status:408,cooldownMs:5e3},{status:409,cooldownMs:5e3},{status:429,backoff:!0}]},39609:(a,b,c)=>{c.d(b,{proxyAwareFetch:()=>s});var d=c(47774),e=c(27910),f=c(41004);let g=globalThis.fetch,h=new Map,i=new Map,j=["cloudcode-pa.googleapis.com","daily-cloudcode-pa.googleapis.com","api.individual.githubcopilot.com","q.us-east-1.amazonaws.com","codewhisperer.us-east-1.amazonaws.com","api2.cursor.sh"],k=["8.8.8.8","8.8.4.4"];function l(){let a=Error("Request aborted");return a.name="AbortError",a}function m(a){return null==a?"":String(a).trim()}async function n(a,b=null){let d,e=i.get(a);if(e&&Date.now()<e.expiry)return e.ip;if(b?.aborted)throw l();try{let e=await Promise.resolve().then(c.t.bind(c,14985,23)),{promisify:g}=await Promise.resolve().then(c.t.bind(c,28354,23)),h=new e.Resolver;h.setServers(k);let j=g(h.resolve4.bind(h)),m=b?await Promise.race([j(a),new Promise((a,c)=>{d=()=>{h.cancel?.(),c(l())},b.addEventListener("abort",d,{once:!0})})]):await j(a);return i.set(a,{ip:m[0],expiry:Date.now()+f.v1.dnsCacheTtlMs}),m[0]}catch(c){if(b?.aborted||c?.name==="AbortError")throw l();return console.warn(`[ProxyFetch] DNS resolve failed for ${a}:`,c.message),null}finally{d&&b?.removeEventListener?.("abort",d)}}function o(a,b){let c,d=m(b);if(!d)return!1;try{c=new URL(a).hostname.toLowerCase()}catch{return!1}return d.split(",").map(a=>a.trim().toLowerCase()).filter(Boolean).some(a=>"*"===a||(a.startsWith(".")?c.endsWith(a)||c===a.slice(1):c===a||c.endsWith(`.${a}`)))}function p(a){let b=m(a);if(!b)return null;try{return new URL(b),b}catch{return`http://${b}`}}async function q(a){let b=p(a);if(!b)return null;if(!h.has(b)){h.size>=f.v1.proxyDispatchersMaxSize&&h.delete(h.keys().next().value);let{ProxyAgent:a}=await Promise.resolve().then(c.t.bind(c,47774,19));h.set(b,new a({uri:b}))}return h.get(b)}async function r(a,b,d){let f=await Promise.resolve().then(c.t.bind(c,55591,23)),g=await Promise.resolve().then(c.t.bind(c,91645,23)),h=f.default??f,i=g.default??g;return new Promise((c,f)=>{let g=new i.Socket,j=d.signal,k=null,m=null,n=!1,o=()=>j?.removeEventListener?.("abort",q),p=a=>{n||(n=!0,o(),f(a))},q=()=>{!function({upstreamResponse:a,request:b,socket:c,rejectOnce:d}){let e=l();d?.(e),a?.destroy?.(),b?.destroy?.(),c?.destroy?.()}({upstreamResponse:m,request:k,socket:g,rejectOnce:p})};j?.aborted?q():(j?.addEventListener?.("abort",q,{once:!0}),g.connect(443,b,()=>{if(n||j?.aborted)return;let b={socket:g,servername:a.hostname,path:a.pathname+a.search,method:d.method||"POST",headers:{...d.headers,Host:a.hostname}};(k=h.request(b,a=>{m=a,n=!0,a.once("close",o);let b={ok:a.statusCode>=200&&a.statusCode<300,status:a.statusCode,statusText:a.statusMessage,headers:new Map(Object.entries(a.headers)),body:e.Readable.toWeb(a),text:async()=>{let b=[];for await(let c of a)b.push(c);return Buffer.concat(b).toString()},json:async()=>JSON.parse(await b.text())};c(b)})).on("error",a=>p(a)),d.body&&k.write("string"==typeof d.body?d.body:JSON.stringify(d.body)),k.end()}),g.on("error",a=>p(a)))})}async function s(a,b={},c=null){let e="string"==typeof a?a:a.toString(),f=m(c?.vercelRelayUrl);if(f){let a=new URL(e),c={...b.headers,"x-relay-target":`${a.protocol}//${a.host}`,"x-relay-path":`${a.pathname}${a.search}`};return g(f,{...b,headers:c})}let h=function(a,b){if(b?.enabled!==!0&&b?.connectionProxyEnabled!==!0)return null;let c=m(b?.url??b?.connectionProxyUrl);if(!c)return null;let d=m(b?.noProxy??b?.connectionNoProxy);return d&&o(a,d)?null:p(c)}(e,c),i=h?null:p(function(a){let b;if(o(a,process.env.NO_PROXY||process.env.no_proxy))return null;try{b=new URL(a).protocol}catch{return null}return"https:"===b?process.env.HTTPS_PROXY||process.env.https_proxy||process.env.ALL_PROXY||process.env.all_proxy:process.env.HTTP_PROXY||process.env.http_proxy||process.env.ALL_PROXY||process.env.all_proxy}(e)),k=h||i;if(function(a){try{let b=new URL(a).hostname;return j.some(a=>b.includes(a))}catch{return!1}}(e)){if(k)try{let c=await q(k);return await (0,d.hd)(a,{...b,dispatcher:c})}catch(a){if(b.signal?.aborted||a?.name==="AbortError")throw a;if(c?.strictProxy===!0)throw Error("[ProxyFetch] Required proxy request failed");throw Error("[ProxyFetch] Proxy request failed for protected upstream")}let f=new URL(e),h=await n(f.hostname,b.signal);return h?r(f,h,b):g(a,b)}if(k)try{let c=await q(k);return await (0,d.hd)(a,{...b,dispatcher:c})}catch(a){if(b.signal?.aborted||a?.name==="AbortError")throw a;if(c?.strictProxy===!0)throw Error(`[ProxyFetch] Proxy required but failed (strictProxy=true): ${a.message}`);if(c?.singleTransportAttempt===!0)throw Error("[ProxyFetch] Proxy request failed for single-attempt upstream");console.warn(`[ProxyFetch] Proxy failed, falling back to direct: ${a.message}`)}return g(a,b)}async function t(a,b={}){return s(a,b,null)}globalThis.fetch!==t&&(globalThis.fetch=t)},41004:(a,b,c)=>{c.d(b,{C8:()=>u,DR:()=>t,MB:()=>m,P4:()=>n,SA:()=>r,SI:()=>k,Uc:()=>p,Z1:()=>g,cI:()=>s,eo:()=>q,gx:()=>d,iL:()=>j,pH:()=>o,sb:()=>i,v1:()=>e,vx:()=>l,xM:()=>h,zA:()=>f}),c(3662);let d={BAD_REQUEST:400,UNAUTHORIZED:401,PAYMENT_REQUIRED:402,FORBIDDEN:403,NOT_FOUND:404,NOT_ACCEPTABLE:406,REQUEST_TIMEOUT:408,PAYLOAD_TOO_LARGE:413,RATE_LIMITED:429,SERVER_ERROR:500,BAD_GATEWAY:502,SERVICE_UNAVAILABLE:503,GATEWAY_TIMEOUT:504},e={sessionTtlMs:72e5,sessionCleanupIntervalMs:18e5,dnsCacheTtlMs:3e5,proxyDispatchersMaxSize:20};function f(a,b,c=process.env){let d=c?.[a];if("string"!=typeof d||!/^\d+$/.test(d))return b;let e=Number(d);return Number.isSafeInteger(e)&&e>=1e3&&e<=9e5?e:b}let g=f("STREAM_FIRST_CHUNK_TIMEOUT_MS",6e4),h=f("STREAM_STALL_TIMEOUT_MS",6e4),i=f("ANTIGRAVITY_THINKING_CONNECT_TIMEOUT_MS",6e4),j=f("ANTIGRAVITY_THINKING_FIRST_CHUNK_TIMEOUT_MS",24e4),k=f("ANTIGRAVITY_THINKING_STALL_TIMEOUT_MS",12e4),l=f("STREAM_CONNECT_TIMEOUT_MS",15e3),m=f("STREAM_ABSOLUTE_TIMEOUT_MS",3e5),n=f("ANTIGRAVITY_THINKING_ABSOLUTE_TIMEOUT_MS",6e5),o=l,p=64e3,q=32e3,r="x-zevai-token-saver",s={429:{attempts:0,delayMs:0},502:{attempts:3,delayMs:3e3},503:{attempts:3,delayMs:2e3},504:{attempts:2,delayMs:3e3}};function t(a){return null==a?{attempts:0,delayMs:2e3}:"number"==typeof a?{attempts:a,delayMs:2e3}:{attempts:a.attempts||0,delayMs:null!=a.delayMs?a.delayMs:2e3}}let u=["Please write a 5-10 word title for the following conversation:"]},48371:(a,b,c)=>{c.d(b,{xM:()=>az,t9:()=>aH,TK:()=>aG,cO:()=>i.cO,VU:()=>a5});var d=c(55511),e=c(73024),f=c.n(e),g=c(76760),h=c.n(g),i=c(13868),j=c(71998),k=c(89718),l=c(20116),m=c(90715),n=c(92990),o=c(39609);let p=globalThis.fetch,q=new Set(["ECONNABORTED","ECONNREFUSED","ECONNRESET","EHOSTUNREACH","ENETDOWN","ENETUNREACH","ENOTFOUND","EPIPE","ETIMEDOUT"]),r=new Set(["TIMEOUT","CANCELED","FINISHED","BANNED"]),s=new Map([["A TIMEOUT","TIMEOUT"],["CANCELLED","CANCELED"],["IS CANCELED","CANCELED"],["IS CANCELLED","CANCELED"],["COMPLETE","FINISHED"],["COMPLETED","FINISHED"],["IS COMPLETE","FINISHED"],["IS COMPLETED","FINISHED"],["NUMBER BANNED, WHEN NUMBER ALREADY USED","BANNED"]]);class t extends Error{constructor(a,{status:b,body:c,source:d=null,orderStatus:e=null}={}){super(a),this.name="FiveSimError",this.status=b,this.body=c,this.source=d,this.orderStatus=e,this.isUpstreamTerminal="upstream"===d&&r.has(e)}}class u extends t{constructor(a,{source:b="local_deadline",orderStatus:c=null}={}){super(`5sim order ${a} timed out waiting for SMS`,{source:b,orderStatus:c}),this.name="FiveSimTimeoutError",this.orderId=a}}class v extends t{constructor(a,b){super(`5sim request to ${a} timed out after ${b}ms`),this.name="FiveSimRequestTimeoutError",this.code="FIVESIM_REQUEST_TIMEOUT",this.path=a,this.timeoutMs=b}}class w extends t{constructor(a){super(a),this.name="FiveSimUnknownOutcomeError",this.code="FIVESIM_BUY_OUTCOME_UNKNOWN",this.outcomeUnknown=!0}}class x extends t{constructor(a,b,{source:c="caller",orderStatus:d=null}={}){super(`5sim order ${a} cancelled: ${b}`,{source:c,orderStatus:d}),this.name="FiveSimCancelledError",this.orderId=a}}class y extends t{constructor(a,{source:b="downstream",orderStatus:c=null}={}){super(`5sim order ${a} number was already used (banned)`,{source:b,orderStatus:c}),this.name="FiveSimBannedError",this.orderId=a}}class z{constructor({apiKey:a,proxyOptions:b=null,fetchImpl:c=null}={}){if(!a||"string"!=typeof a||!a.trim())throw new t("5sim API key is required");this.apiKey=a.trim(),this.proxyOptions=b,this.fetchImpl="function"==typeof c?c:null}_headers(a={}){return{Authorization:`Bearer ${this.apiKey}`,Accept:"application/json",...a}}async _get(a,{headers:b,timeoutMs:c=15e3,signal:d,...e}={}){let f,g=`https://5sim.net/v1${a}`,h=this.fetchImpl||(this.proxyOptions?.enabled?o.proxyAwareFetch:p),i=Number.isFinite(c)&&c>0?new AbortController:null,j=i?.signal||null,k=i?setTimeout(()=>i.abort(),c):null;k?.unref?.();let l=function(a){let b=a.filter(Boolean);if(0===b.length)return null;if(1===b.length)return b[0];if("function"==typeof AbortSignal.any)return AbortSignal.any(b);let c=new AbortController;for(let a of b){if(a.aborted){c.abort(a.reason);break}a.addEventListener("abort",()=>c.abort(a.reason),{once:!0})}return c.signal}([d,j]),m=b=>{if(d?.aborted){let c=new t(`5sim request to ${a} was aborted`);return c.code="FIVESIM_REQUEST_ABORTED",c.cause=b,c}if(j?.aborted){let d=new v(a,c);return d.cause=b,d}return b};try{let c;try{f=await h(g,{method:"GET",headers:this._headers(b),...e,...l?{signal:l}:{}},this.proxyOptions)}catch(a){throw m(a)}try{c=await f.text()}catch(a){throw m(a)}if(!f.ok)throw new t(`5sim request to ${a} failed (HTTP ${f.status}): ${c.slice(0,200)}`,{status:f.status,body:c});try{return JSON.parse(c)}catch{if(c&&!c.startsWith("{"))throw new t(`5sim ${a} returned non-JSON: ${c.slice(0,200)}`,{status:f.status,body:c});return null}}finally{k&&clearTimeout(k)}}async buyNumber({country:a="hongkong",operator:b="any",product:c="codebuddy",allowProductFallback:d=!1,responseTimeoutMs:e=2e4,lateAbortTimeoutMs:f=45e3,signal:g=null}={}){if(g?.aborted){let a=new t("5sim purchase cancelled before the request started");throw a.code="FIVESIM_REQUEST_ABORTED",a}let h="codebuddy"===c&&d?["codebuddy","other"]:[c],i=null;for(let c of h){let j=`/user/buy/activation/${encodeURIComponent(a)}/${encodeURIComponent(b)}/${encodeURIComponent(c)}`;try{let a,b=Math.max(Number(f)||45e3,(Number(e)||2e4)+1e3),c=this._get(j,{timeoutMs:b});try{a=await B(c,e,g)}catch(a){throw a?.code==="FIVESIM_BUY_OUTCOME_UNKNOWN"&&c.then(a=>a?.id?this.cancelOrder(a.id):null).catch(()=>null),a}if(!a||!a.id||!a.phone)throw a?.id&&this.cancelOrder(a.id).catch(()=>null),new t(`5sim buyNumber returned unexpected shape: ${JSON.stringify(a).slice(0,200)}`,{body:a});return a}catch(e){i=e;let a=e?.status,b=String(e?.body||e?.message||"").toLowerCase();if(!(d&&"codebuddy"===c&&h.includes("other")&&(400===a||404===a||b.includes("no free")||b.includes("not enough")||b.includes("no product"))))throw e}}throw i||new t("5sim buyNumber failed for all product candidates")}async checkOrder(a,b={}){return this._get(`/user/check/${a}`,b)}async pollCode(a,{timeoutMs:b=9e5,intervalMs:c=6e3,signal:d}={}){let e=Number(c),f=Number.isFinite(e)?Math.max(5e3,e):6e3,g=Number(b),h=Number.isFinite(g)&&g>0?g:9e5,i=Date.now()+h,j=0,k=()=>Math.max(0,i-Date.now()),l=async()=>{let b=k();if(b<=0)throw new u(a);try{await function(a,b=null){return b?.aborted?Promise.reject(b.reason||Error("Aborted")):new Promise((c,d)=>{let e=()=>b?.removeEventListener("abort",g),f=setTimeout(()=>{e(),c()},a),g=()=>{clearTimeout(f),e(),d(b.reason||Error("Aborted"))};b?.addEventListener("abort",g,{once:!0})})}(Math.min(f,b),d)}catch(b){if(d?.aborted)throw new x(a,"aborted by caller");throw b}};for(;k()>0;){let b;if(d?.aborted)throw new x(a,"aborted by caller");let c=Math.min(15e3,k());if(c<=0)break;try{b=await this.checkOrder(a,{signal:d,timeoutMs:c})}catch(b){if(d?.aborted||b?.code==="FIVESIM_REQUEST_ABORTED")throw new x(a,"aborted by caller");if(b instanceof v||function(a){if(a instanceof t)return 408===a.status||429===a.status||a.status>=500;if(a instanceof TypeError)return!0;let b=a?.code||a?.cause?.code;return q.has(b)}(b)){if(0>=k())throw new u(a);if(++j>5)throw b;await l();continue}throw b}if(j=0,Array.isArray(b.sms)&&b.sms.length>0){let a=A(b.sms[b.sms.length-1]);if(a)return a}let e=function(a){if("string"!=typeof a)return null;let b=a.trim().replace(/\s+/g," ").toUpperCase();return s.get(b)||b||null}(b.status);if(r.has(e)){let c={source:"upstream",orderStatus:e};if("TIMEOUT"===e)throw new u(a,c);if("BANNED"===e)throw new y(a,c);if("CANCELED"===e)throw new x(a,e,c);if("FINISHED"===e){let d=function(a){if(!Array.isArray(a))return null;for(let b=a.length-1;b>=0;b--){let c=A(a[b]);if(c)return c}return null}(b.sms);if(d)return d;throw new t(`5sim order ${a} completed but no SMS code found`,{body:b,...c})}}await l()}throw new u(a)}async finishOrder(a){try{return await this._get(`/user/finish/${a}`),!0}catch(b){return console.warn(`[5sim] finishOrder(${a}) failed (best-effort): ${b.message}`),!1}}async cancelOrder(a){try{return await this._get(`/user/cancel/${a}`),!0}catch(b){return console.warn(`[5sim] cancelOrder(${a}) failed (best-effort): ${b.message}`),!1}}async banOrder(a){try{return await this._get(`/user/ban/${a}`),!0}catch(b){return console.warn(`[5sim] banOrder(${a}) failed (best-effort): ${b.message}`),!1}}async getBalance(){try{let a=await this._get("/user/profile");return{balance:a?.balance??null,rating:a?.rating??null}}catch(a){return console.warn(`[5sim] getBalance failed: ${a.message}`),{balance:null,rating:null}}}}function A(a){return a?a.code&&/\d{4,8}/.test(String(a.code))?String(a.code).match(/\d{4,8}/)[0]:a.text?function(a){if(!a)return null;let b=String(a).match(/\b(\d{4,8})\b/);return b?b[1]:null}(a.text):null:null}async function B(a,b,c=null){let d=Number(b)||2e4,e=null,f=null,g=new Promise((a,b)=>{let g=a=>b(new w(`5sim buy request ${a}; purchase outcome is unknown and any late successful order will be cancelled automatically`));e=setTimeout(()=>{g(`did not answer within ${d}ms`)},d),e.unref?.(),f=()=>g("was interrupted by the caller"),c?.aborted?f():c?.addEventListener("abort",f,{once:!0})});try{return await Promise.race([a,g])}finally{e&&clearTimeout(e),f&&c?.removeEventListener("abort",f)}}let C=["https://www.codebuddy.cn/login/"],D=["text=手机号","div:has-text('手机号')","span:has-text('手机号')","[class*='phone']:has-text('手机号')","div.kc-phone-tab:has-text('手机号')"],E=["text=手机号","text=其他登录方式","text=微信","#phone-iframe",".login-phone-box"],F=[".t-dialog :text-is('同意')","[role='dialog'] :text-is('同意')","button:text-is('同意并继续')","button:text-is('同意')"],G="#phone-iframe",H="#phoneNumber",I=".kc-country-selector",J=".kc-country-option",K=".kc-country-code-text",L="#code",M=".code-btn",N=['iframe[src*="captcha"]','iframe[src*="tcaptcha"]',"#tcaptcha","#tcaptcha_transform",".nc_iconfont",".nc_wrapper",'[class*="captcha"]','[id*="captcha"]',"text=滑块","text=拖动"],O=["#input-error",".pf-c-form__helper-text.pf-m-error",".kc-feedback-text"],P=new Set(["login_risk_state"]),Q=["账号访问受限","安全策略限制","访问受限","account restricted","access restricted"];function R(a="Tencent risk policy rejected the post-OTP session"){return{status:"failed_restricted",error:`Account restricted after OTP (${a}). Use a different residential CN/HK proxy with concurrency 1; do not retry this number on the same egress IP.`}}async function S(a){let b=a.locator("input.btn-lg.code-btn").first(),c=null;try{await b.waitFor({state:"visible",timeout:5e3}),c=b}catch{let b=a.locator(M).first();try{await b.waitFor({state:"visible",timeout:5e3}),c=b}catch{c=null}}if(!c)return{ok:!1,reason:"missing"};let d=await c.click().then(()=>!0).catch(()=>!1);return{ok:d,reason:d?null:"click_failed"}}async function T(a){for(let b of F){let c=a.locator(b);if(!c)continue;if("function"==typeof c.count&&"function"==typeof c.nth){let a=await c.count().catch(()=>0);for(let b=0;b<a;b+=1){let a=c.nth(b);if(await a.isVisible().catch(()=>!1))return a}continue}let d="function"==typeof c.first?c.first():c;if(d&&await d.isVisible().catch(()=>!1))return d}if("function"==typeof a.getByText){let b=a.getByText("同意",{exact:!0}),c="function"==typeof b.count?await b.count().catch(()=>0):0;for(let a=0;a<c;a+=1){let c=b.nth(a);if(await c.isVisible().catch(()=>!1))return c}}return null}function U(a){if(a?.aborted)throw a.reason||Object.assign(Error("Job cancelled"),{code:"JOB_CANCELLED"})}async function V(a,{timeoutMs:b=3e3,signal:c=null}={}){let d=Date.now()+b;for(;Date.now()<d;){U(c);let b=await T(a);if(b)return b;await a.waitForTimeout(100).catch(()=>new Promise(a=>setTimeout(a,100)))}return null}function W(a){let b=String(a||"");return/\/auth\/realms\/[^/]+\/(?:protocol\/openid-connect\/auth|login-actions\/)/i.test(b)}async function X(a,{visibleOnly:b=!0}={}){if(!a||"function"!=typeof a.locator)return!1;let c=a.locator(H);if(!c)return!1;let d="function"==typeof c.first?c.first():c;return!!d&&"function"==typeof d.isVisible&&(b?d.isVisible().catch(()=>!1):"function"==typeof d.count?d.count().then(a=>a>0).catch(()=>!1):d.isVisible().catch(()=>!1))}async function Y(a,b=null){if(!a||a===b||"function"!=typeof a.frameElement)return!0;try{let b=await a.frameElement();return await b.isVisible()}catch{return!1}}async function Z(a){let b="function"==typeof a.mainFrame?a.mainFrame():null,c=b||a;if(W(a.url?.())&&await X(c))return c;let d=a.locator(G);if("function"==typeof d.count&&"function"==typeof d.nth){let a=await d.count().catch(()=>0);for(let b=0;b<a;b+=1){let a=d.nth(b);if(!await a.isVisible().catch(()=>!1))continue;let c=await a.elementHandle().catch(()=>null),e=c?await c.contentFrame().catch(()=>null):null;if(e&&await X(e))return e}}for(let c of"function"==typeof a.frames?a.frames():[])if(c!==b&&W(c.url?.())&&await X(c)&&await Y(c,b))return c;return null}async function $(a,{timeoutMs:b=3e3,signal:c=null}={}){let d=Date.now()+b;for(;Date.now()<d;){U(c);let b=await Z(a);if(b)return b===("function"==typeof a.mainFrame?a.mainFrame():a)||b===a?"page":"iframe";await a.waitForTimeout(100).catch(()=>new Promise(a=>setTimeout(a,100)))}return null}async function _(a,{timeoutMs:b=25e3,reportStep:c,signal:d=null}={}){let e=Date.now()+b;for(;Date.now()<e;){U(d);let e=await T(a);if(e&&await e.click({timeout:Math.min(3e3,b)}).then(()=>!0).catch(()=>!1)){c?.("cn_consent_dismissed","Privacy consent accepted before login SPA readiness"),await a.waitForTimeout(300).catch(()=>null);continue}if(await Z(a))return!0;for(let b of E)if(await a.locator(b).first().isVisible().catch(()=>!1))return!0;await a.waitForTimeout(100).catch(()=>new Promise(a=>setTimeout(a,100)))}return!1}async function aa(a,b,{reportStep:c,consentTimeoutMs:d=3e3,signal:e=null}={}){U(e);let f=await b.click({timeout:d}).then(()=>!0).catch(()=>!1);await a.waitForTimeout(250).catch(()=>null);let g=await V(a,{timeoutMs:d,signal:e});if(!g)return f;if(!await g.click({timeout:d}).then(()=>!0).catch(()=>!1)||(c?.("cn_consent_dismissed","Service agreement accepted after opening phone login"),await a.waitForTimeout(300).catch(()=>null),!(await ad(a,{timeoutMs:d,signal:e})).ok))return!1;let h=await $(a,{timeoutMs:d,signal:e});if("page"===h)return c?.("cn_phone_page_ready","Consent redirected directly to the Keycloak phone form"),!0;if(!h){let b=await ao(a,D,{timeout:d,signal:e});return!!b&&b.click({timeout:d}).then(()=>!0).catch(()=>!1)}return!0}let ab=["我已阅读并同意","已阅读并同意","阅读并同意"];async function ac(a,{timeoutMs:b=3e3,signal:c=null}={}){let d=a.locator(".t-checkbox");if(!d)return null;if("function"!=typeof d.count||"function"!=typeof d.nth){let a="function"==typeof d.last?d.last():d;return await a.isVisible({timeout:b}).catch(()=>!1)?a:null}let e=Date.now()+b;for(;;){if(U(c),"function"==typeof d.filter)for(let a of ab){let b=d.filter({hasText:a}),c=b&&"function"==typeof b.count?await b.count().catch(()=>0):0;for(let a=0;a<c;a+=1){let c=b.nth(a);if(await c.isVisible().catch(()=>!1))return c}}let b=await d.count().catch(()=>0);for(let a=b-1;a>=0;a-=1){let b=d.nth(a);if(await b.isVisible().catch(()=>!1))return b}if(Date.now()>=e)return null;await a.waitForTimeout(100).catch(()=>new Promise(a=>setTimeout(a,100)))}}async function ad(a,{timeoutMs:b=3e3,signal:c=null}={}){U(c);let d=await ac(a,{timeoutMs:b,signal:c});if(!d)return{ok:!0,present:!1,changed:!1};let e=d.locator("input").first(),f=async()=>{if(!0===await e.isChecked().catch(()=>null))return!0;let a=await d.getAttribute("class").catch(()=>"");return!!/(?:^|\s)t-is-checked(?:\s|$)/.test(String(a||""))};if(await f())return{ok:!0,present:!0,changed:!1};if(!await d.click().then(()=>!0).catch(()=>!1))return{ok:!1,present:!0,changed:!1};if(!await f()){let d=await V(a,{timeoutMs:b,signal:c});if(d){if(!await d.click({timeout:b}).then(()=>!0).catch(()=>!1))return{ok:!1,present:!0,changed:!0};await a.waitForTimeout(200).catch(()=>null)}}let g=Date.now()+b;for(;Date.now()<g;){if(U(c),await f())return{ok:!0,present:!0,changed:!0};await a.waitForTimeout(100).catch(()=>new Promise(a=>setTimeout(a,100)))}return{ok:!1,present:!0,changed:!0}}function ae(a){return a?.isUpstreamTerminal===!0||["FiveSimTimeoutError","FiveSimBannedError","FiveSimCancelledError"].includes(a?.name)}async function af(a){let b=a.locator(M).first(),c=await b.evaluate(a=>({disabled:!!a.disabled,ariaDisabled:"true"===a.getAttribute("aria-disabled"),label:String(a.value||a.textContent||"").trim()})).catch(()=>null);if(!c)return{ok:!1,state:null};let d=/(?:^\d+$|\d+\s*(?:s|sec|\u79d2)|\u91cd\u65b0|\u5df2\u53d1\u9001|resend|sent)/i.test(c.label);return{ok:!!(c.disabled||c.ariaDisabled||d),state:c}}async function ag(a,b,{timeoutMs:c,signal:d=null,returnOnCaptcha:e=!0}={}){let f=Date.now()+c;for(;Date.now()<f;){U(d);let c=await aw(a,b,250),f=await af(b),g=f.ok?await aw(a,b,250):c;if(c||g){if(e)return{ok:!1,reason:"captcha",needsManual:!0,state:f.state};if(f.ok)return f}else if(f.ok)return f;await b.waitForTimeout(250).catch(()=>new Promise(a=>setTimeout(a,250)))}return{ok:!1,reason:"not_acknowledged",state:null}}async function ah(a,b,{acknowledgementTimeoutMs:c=8e3,manualCaptchaTimeoutMs:d=12e4,onManualRequired:e=null,onManualResolved:f=null,reportStep:g=null,signal:h=null}={}){let i=await ag(a,b,{timeoutMs:c,signal:h}),j=await av(b);if(j)return{ok:!1,reason:"form_error",error:j,state:null};if(i.ok)return i;if("captcha"!==i.reason)return{ok:!1,reason:"not_acknowledged",state:i.state};if(g?.("cn_sms_captcha_detected","Captcha appeared before Tencent accepted the SMS request; waiting for manual completion"),"function"!=typeof e)return{ok:!1,reason:"captcha",needsManual:!0,state:null};await e({phase:"sms_request",captcha:!0}),i=await ag(a,b,{timeoutMs:d,signal:h,returnOnCaptcha:!1});let k=await av(b);return k?{ok:!1,reason:"form_error",error:k,needsManual:!0,state:i.state}:i.ok?(await f?.({phase:"sms_request",captcha:!0}),g?.("cn_sms_captcha_resolved","Captcha completed; Tencent accepted the SMS request"),{...i,resumedFromCaptcha:!0}):{ok:!1,reason:"captcha_timeout",error:null,needsManual:!0,state:null}}async function ai(a,{timeoutMs:b,signal:c=null}={}){let d=null,e=null,f=new Promise((a,c)=>{d=setTimeout(()=>c(Error("Timed out waiting for SMS code")),b),d.unref?.()}),g=c?new Promise((a,b)=>{e=()=>b(c.reason||Object.assign(Error("Job cancelled"),{code:"JOB_CANCELLED"})),c.aborted?e():c.addEventListener("abort",e,{once:!0})}):null;try{return await Promise.race([a,f,...g?[g]:[]])}finally{d&&clearTimeout(d),e&&c?.removeEventListener("abort",e)}}async function aj({page:a,phone:b,resolvePhone:c,pollSmsPromise:d,waitForSms:e,onStep:f,onManualRequired:g,onManualResolved:h,phoneFormatter:i=a=>a,timeouts:j={},signal:k=null,isCancelled:l=null}){let m=j.nav??3e4,n=j.action??15e3,o=j.codeWait??9e5,p=j.postSubmit??1e4,q=(a,b)=>f?.(a,b),r=()=>{if(k?.aborted){if(k.reason?.code==="CN_ACCOUNT_HARD_TIMEOUT")throw k.reason;let a=Error("Job cancelled");throw a.code="JOB_CANCELLED",a}if("function"==typeof l&&l()){let a=Error("Job cancelled");throw a.code="JOB_CANCELLED",a}};try{var s;let f,j;q("cn_opening_login_page","Opening CodeBuddy CN login page"),r();try{a.setDefaultNavigationTimeout(m),a.setDefaultTimeout(n)}catch{}try{await a.context().route("**/*",a=>{var b,c;let d,e=a.request();return(b=e.url(),c=e.resourceType(),d=String(b||""),/googletagmanager|googleadservices|google-analytics|doubleclick|facebook|hotjar|clarity\.ms|hm\.baidu|google\.com\/rmkt/i.test(d)||"media"===c||"image"===c&&!/captcha|tcaptcha|challenge|verify|qrcode/i.test(d))?a.abort():a.continue()})}catch{}let l=null,t=[];for(let b=1;b<=2;b++){r();try{let c=C[(b-1)%C.length];q("cn_nav_attempt",`Navigation attempt ${b}/2 → ${c}`),b>1&&(await a.context().clearCookies().catch(()=>{}),await a.waitForTimeout(800)),await a.goto(c,{waitUntil:"commit",timeout:m}),r(),await a.waitForFunction(()=>"loading"!==document.readyState,{timeout:1e4}).catch(()=>{}),r();let d=await _(a,{timeoutMs:25e3,reportStep:q,signal:k});if(r(),!d){let b=await a.locator("body").innerText().catch(()=>""),d=await a.evaluate(()=>document.documentElement?.outerHTML?.length||0).catch(()=>0),e=a.url();q("cn_spa_not_ready",`SPA not ready after 25s (url=${e}, body=${String(b).slice(0,80)}, html=${d})`),!b&&d<200?(q("cn_proxy_empty_page","Empty page body — proxy may be blocking codebuddy.cn"),t.push({code:"proxy_empty",detail:`empty page via ${c} (html=${d})`})):t.push({code:"spa_timeout",detail:`SPA not ready url=${e} html=${d}`});continue}q("cn_spa_ready","Login SPA ready"),q("cn_selecting_phone_tab","Selecting phone-number tab");let e=await ao(a,D,{timeout:12e3,signal:k});if(e){if(!await aa(a,e,{reportStep:q,signal:k})){q("cn_phone_tab_failed","Could not open phone login after service agreement"),t.push({code:"phone_tab_failed",detail:"phone tab or post-click consent could not be completed"});continue}q("cn_phone_tab_selected","Phone tab selected"),await a.waitForTimeout(800)}else q("cn_phone_tab_not_found","Phone tab not found — checking if iframe already present");if(q("cn_waiting_for_phone_form","Waiting for Keycloak phone form to load"),await $(a,{timeoutMs:18e3,signal:k}),l=await ak(a)){if(await l.waitForSelector(H,{state:"visible",timeout:15e3}).then(()=>!0).catch(()=>!1)){q("cn_phone_form_ready","Keycloak phone form + #phoneNumber ready");break}q("cn_phone_form_empty","Keycloak form found but #phoneNumber not visible yet"),t.push({code:"phone_form_empty",detail:"Keycloak phone form found but #phoneNumber not visible"}),l=null}else q("cn_phone_form_missing",`No Keycloak phone form (attempt ${b}/2)`),t.push({code:"phone_form_missing",detail:"SPA loaded but neither iframe nor top-level Keycloak phone form appeared"})}catch(e){if(["JOB_CANCELLED","CN_ACCOUNT_HARD_TIMEOUT"].includes(e?.code))throw e;let a=String(e?.message||e||"");q("cn_nav_retry",`Navigation attempt ${b}/2 failed: ${a.slice(0,120)}`);let c=/timeout|exceeded|ETIMEDOUT|net::ERR/i.test(a),d=/ERR_PROXY|ERR_TUNNEL|ERR_CONNECTION|NS_ERROR_PROXY|proxy/i.test(a);t.push({code:d?"proxy_network":c?"nav_timeout":"nav_error",detail:a.slice(0,160)})}}if(!l)return{status:"failed",error:function(a=[],b=2){let c=a.map(a=>a.code),d=a[a.length-1],e="Fix: use a live residential CN proxy (proxyPoolMode=single), concurrency 1, then retry. 5sim is not charged until the form loads.";return c.includes("proxy_empty")||c.includes("proxy_network")?`CodeBuddy CN login page empty/blocked via proxy after ${b} attempts (${d?.detail||"proxy blackhole"}). ${e}`:c.includes("nav_timeout")?`CodeBuddy CN navigation timed out after ${b} attempts (${d?.detail||"goto timeout"}). Proxy is too slow or dead. ${e}`:c.includes("spa_timeout")?`CodeBuddy CN SPA did not boot after ${b} attempts (${d?.detail||"no login UI"}). Proxy/CDN may be filtering JS. ${e}`:c.includes("phone_tab_failed")?`CodeBuddy CN consent/phone transition did not complete after ${b} attempts (${d?.detail||"phone form transition failed"}). The Tencent page may have changed or loaded incompletely; inspect the live preview before retrying. No 5sim number was purchased.`:c.includes("iframe_missing")||c.includes("iframe_empty")||c.includes("phone_form_missing")||c.includes("phone_form_empty")?`CodeBuddy CN page opened but the Keycloak phone form never became ready after ${b} attempts (${d?.detail||"no phone form"}). Site layout change or half-loaded SPA — retry with another CN exit IP. ${e}`:c.includes("nav_error")&&d?.detail?`CodeBuddy CN phone form failed after ${b} attempts: ${d.detail}. ${e}`:`Could not load CodeBuddy CN phone form after ${b} attempts (${d?.code||"unknown"}: ${d?.detail||"proxy/SPA"}). ${e}`}(t,2)};await l.waitForSelector("#kc-form-login",{timeout:n}).catch(()=>{}),await l.waitForSelector(H,{state:"visible",timeout:n}).catch(()=>{});let u=b;if("function"==typeof c&&(q("cn_ordering_after_form","Login form ready — ordering 5sim number now (not before nav)"),u=await c()),!u)return{status:"failed",error:"No phone number available (resolvePhone/phone missing)"};let v=i(u),{countryCode:w,localNumber:x}=(s=v,(!(j=String(s).replace(/[\s\-()]/g,"")).startsWith("+")&&/^\d+$/.test(j)&&(j="+"+j),j.startsWith("+852"))?{countryCode:"+852",localNumber:j.slice(4)}:j.startsWith("+86")?{countryCode:"+86",localNumber:j.slice(3)}:j.startsWith("+1")?{countryCode:"+1",localNumber:j.slice(2)}:{countryCode:"",localNumber:j.replace(/^\+/,"")});if(q("cn_selecting_country",`Selecting country code ${w} for phone ${v}`),!await an(l,w,n,q))return{status:"failed",error:`Could not select country code ${w||"(unknown)"} for ${v}`};q("cn_entering_phone",`Entering phone number: ${x}`);let y=l.locator(H).first();try{await y.waitFor({state:"visible",timeout:n})}catch{return{status:"failed",error:"Could not find the phone number input (#phoneNumber) inside the iframe"}}if(!await ap(y,x))return{status:"failed",error:"Phone number input did not retain the expected value"};q("cn_phone_entered",`Phone number entered: ${x}`);let z=await am(l,Math.min(n,2e3));if(w&&z&&z!==w){q("cn_country_reset_after_phone",`Country code reverted to ${z} after phone input; restoring ${w}`);let a=await an(l,w,n,q),b=a&&await ap(y,x);if(!a||!b)return{status:"failed",error:`Country code reverted to ${z} and could not be restored to ${w}`};q("cn_country_and_phone_restored",`Country ${w} and phone number restored`)}let A=await ad(a,{signal:k});if(!A.ok)return{status:"failed",error:"Could not keep the service agreement checkbox checked"};A.present&&q("cn_agreement_checked",A.changed?"Agreement checkbox checked":"Agreement checkbox already checked"),q("cn_clicking_send_code","Clicking send SMS code button");let B=await S(l);if("missing"===B.reason)return{status:"failed",error:"Could not find the send-SMS-code button (.code-btn) inside the iframe"};if(!B.ok)return{status:"failed",error:"Could not click the send-SMS-code button (.code-btn) inside the iframe"};q("cn_send_code_clicked","Send code button clicked");let E=await ah(a,l,{manualCaptchaTimeoutMs:Math.min(o,12e4),onManualRequired:g,onManualResolved:h,reportStep:q,signal:k});if("form_error"===E.reason){if(E.needsManual)return{status:"needs_manual",error:`Form error after the captcha was handed over: ${E.error}. Finish the login in the open browser session.`,captcha:!0};return{status:"failed",error:`Form error after sending code: ${E.error}`}}if("captcha"===E.reason)return{status:"needs_manual",error:"A captcha blocked the SMS request. Complete it in the existing browser session.",captcha:!0};if("captcha_timeout"===E.reason)return{status:"needs_manual",error:"Captcha was not completed before the SMS-request manual-assist timeout. Finish it in the open browser session.",captcha:!0};if(!E.ok)return{status:"failed",error:"Tencent did not acknowledge the SMS-code request (no disabled/countdown state)"};q("cn_send_code_acknowledged","Tencent accepted the SMS-code request"),q("cn_waiting_for_sms","Waiting for SMS verification code from 5sim (timer starts now)");try{let a;if("function"==typeof e)a=Promise.resolve().then(()=>e());else if(d)a=d;else throw Error("No waitForSms/pollSmsPromise provided");f=await ai(a,{timeoutMs:o,signal:k})}catch(a){if(ae(a))throw a;return(k?.aborted||a?.code==="JOB_CANCELLED")&&r(),{status:"failed",error:`Failed to receive SMS code: ${a.message}`}}if(!f)return{status:"failed",error:"Received empty SMS code from 5sim"};q("cn_sms_received","SMS code received"),q("cn_entering_code","Entering SMS verification code");let F=l.locator(L).first();try{await F.waitFor({state:"visible",timeout:n})}catch{return{status:"failed",error:"Could not find the verification code input (#code) inside the iframe"}}if(!await ap(F,f))return{status:"failed",error:"Verification code input did not retain the expected value"};q("cn_code_entered","Verification code entered");let G=1200+Math.floor(1800*Math.random());q("cn_pre_submit_pause",`Waiting ${G}ms before submit (humanize)`),await a.waitForTimeout(G);let I=Math.max(p,12e3);q("cn_submitting","Submitting the registration form once");let J=await ak(a);if(!J)return{status:"failed",error:"Lost phone iframe before submit"};let K=await as(J,n);if(!K.ok)return{status:"failed",error:"Could not submit the Keycloak login form"};if(q("cn_submitted",`Registration form submitted once via ${K.method}`),await a.waitForLoadState("domcontentloaded",{timeout:5e3}).catch(()=>{}),await a.waitForTimeout(1800),J=await ak(a)||J,await au(a,J))return q("cn_account_restricted","Account restricted after the OTP submit"),R("restriction message detected");if(q("cn_checking_captcha","Checking for captcha"),await aw(a,J,3e3))return q("cn_captcha_detected","Captcha appeared during registration - manual assist needed"),{status:"needs_manual",error:"A captcha appeared during registration. Complete it in the existing browser session.",captcha:!0};let M=await av(J);if(M)return{status:"failed",error:`Form error after submit: ${M}`};q("cn_waiting_session",`Waiting up to ${Math.round(I/1e3)}s for Keycloak session cookies`);let N=await ar(a,{timeoutMs:I,reportStep:q,alsoCheckFrame:()=>ak(a),signal:k});if(N.ok)return q("cn_session_cookies",`Keycloak session cookies present (${N.cookie}) - registration success`),{status:"success"};if("restricted"===N.reason||function(a=[]){return a.some(a=>P.has(a?.name))}(N.cookies))return q("cn_account_restricted","Restriction detected while waiting for the login session"),R("restriction evidence detected during session handoff");if(J=await ak(a)||J,await aw(a,J,2e3))return q("cn_captcha_detected","Captcha appeared while waiting for the login session"),{status:"needs_manual",error:"A captcha appeared while establishing the login session. Complete it in the existing browser.",captcha:!0};let O=await at(a);return q("cn_success_unconfirmed",`No Keycloak session after submit — ${O.summary}`),{status:"needs_manual",error:`Login submit finished but no Keycloak session yet (${O.summary}). Complete login in the headed browser or retry with a fresh China proxy.`}}catch(a){if((k?.aborted||"function"==typeof l&&l())&&r(),ae(a)||a?.code==="JOB_CANCELLED"||a?.code==="CN_ACCOUNT_HARD_TIMEOUT")throw a;return q("cn_automation_error",`Phone registration automation error: ${a.message}`),{status:"failed",error:a.message||"Unexpected error during phone registration"}}}async function ak(a){let b=await Z(a);if(b)return b;try{let b=a.locator(G),c="function"==typeof b.count?await b.count().catch(()=>0):0;for(let a=0;a<c;a+=1){let c=b.nth(a);if(!await c.isVisible().catch(()=>!1))continue;let d=await c.elementHandle().catch(()=>null),e=d?await d.contentFrame().catch(()=>null):null;if(e&&W(e.url()))return e}}catch{}let c="function"==typeof a.mainFrame?a.mainFrame():null;if(c&&W(a.url?.()))return c;for(let b of"function"==typeof a.frames?a.frames():[])if(W(b.url())&&await Y(b,c))return b;return null}function al(a){return String(a||"").replace(/\s+/g,"").match(/\+\d{1,4}/)?.[0]||""}async function am(a,b=1500){for(let c of[K,I]){let d=al(await a.locator(c).first().textContent({timeout:b}).catch(()=>""));if(d)return d}return""}async function an(a,b,c,d){if(!b)return!1;let e=Math.min(Math.max(Number(c)||15e3,2e4),3e4),f=Date.now()+e,g=()=>Math.max(0,f-Date.now()),h=a=>Math.max(250,Math.min(a,g())),i=async()=>{let b=a.locator(I).first();await b.waitFor({state:"visible",timeout:h(5e3)}),await b.click({timeout:h(3e3)}).catch(()=>{}),await a.locator(J).first().waitFor({state:"visible",timeout:h(3e3)}).catch(()=>{})},j=async()=>await am(a,h(1500))===b||(await a.locator(K).filter({hasText:b}).first().waitFor({state:"visible",timeout:h(2e3)}).catch(()=>null),await am(a,h(1e3))===b),k=async(a,b)=>{if(!await a.isVisible({timeout:h(1500)}).catch(()=>!1))return!1;let c=await a.textContent({timeout:h(1500)}).catch(()=>b);return"function"==typeof a.scrollIntoViewIfNeeded&&await a.scrollIntoViewIfNeeded({timeout:h(1500)}).catch(()=>null),!!await a.click({timeout:h(2e3)}).then(()=>!0).catch(()=>!1)&&!!await j()&&(d?.("cn_country_selected",`Country selected: ${String(c||b).trim()}`),!0)},l=async c=>{let d=a.locator(J);if("function"==typeof d.allTextContents&&"function"==typeof d.nth){let a=await d.allTextContents().catch(()=>[]),c=a.findIndex(a=>al(a)===b);if(c>=0&&await k(d.nth(c),a[c]))return!0}for(let d of[b,...c]){if(0>=g())break;for(let b of[a.locator(`${J}:has-text(${JSON.stringify(d)})`).first(),a.locator(J).filter({hasText:d}).first(),a.getByText(d,{exact:!0}).first(),a.getByText(d,{exact:!1}).first()]){if(0>=g())return!1;if(await k(b,d))return!0}}return!1},m=async()=>{let c=await am(a,h(3e3));if(c===b)return d?.("cn_country_already_selected",`Country code already ${b}`),!0;let e={"+852":["中国香港","香港","Hong Kong","+852"],"+86":["中国大陆","中国","China","+86"],"+853":["中国澳门","澳门","Macau","+853"],"+886":["中国台湾","台湾","Taiwan","+886"]}[b]||[b];d?.("cn_opening_country_dropdown",`Opening country dropdown (current: ${c}, target: ${b})`);for(let c=1;c<=2;c+=1){if(await i(),await l(e))return!0;if(c>=2||6e3>=g())break;d?.("cn_country_dropdown_retry",`Country ${b} not selectable yet; reopening the dropdown (${g()}ms left)`),await a.locator("body").click({timeout:h(1e3)}).catch(()=>{})}return d?.("cn_country_not_found",`Country code ${b} not found in dropdown`),await a.locator("body").click({timeout:h(1e3)}).catch(()=>{}),!1},n=null;try{return await Promise.race([m(),new Promise((a,b)=>{n=setTimeout(()=>b(Error(`selectCountry timed out after ${e}ms`)),e),n.unref?.()})])}catch(a){return d?.("cn_country_select_error",`Country selection error: ${a.message}`),!1}finally{n&&clearTimeout(n)}}async function ao(a,b,{timeout:c=1e4,signal:d=null}={}){let e=Date.now()+c;for(;Date.now()<e;){for(let c of(U(d),b)){let b=a.locator(c).first();if(await b.isVisible().catch(()=>!1))return b}let c=e-Date.now();if(c<=0)break;await a.waitForTimeout(Math.min(100,c)).catch(()=>new Promise(a=>setTimeout(a,Math.min(100,c))))}return null}async function ap(a,b){let c=String(b??""),d=async()=>await a.inputValue().catch(()=>null)===c;try{if(await a.click(),await a.fill(""),await a.fill(c),await d())return!0}catch{}try{return await a.click(),await a.press("ControlOrMeta+a"),await a.type(c,{delay:50}),d()}catch{return!1}}let aq=["KEYCLOAK_IDENTITY","KEYCLOAK_SESSION","KEYCLOAK_IDENTITY_LEGACY","KEYCLOAK_SESSION_LEGACY"];async function ar(a,{timeoutMs:b=2e4,reportStep:c,alsoCheckFrame:d,signal:e=null}={}){let f=Date.now()+b,g=0;for(;Date.now()<f;){U(e);let b=await a.context().cookies().catch(()=>[]),h=function(a=[]){for(let b of aq)if(a.some(a=>a.name===b))return b;let b=a.find(a=>a.name.startsWith("KEYCLOAK_")&&!/locale|theme|restart/i.test(a.name));return b?.name||null}(b);if(h)return{ok:!0,cookie:h,cookies:b};try{let c=a.url();if(c&&!c.includes("/login")&&!c.includes("/auth/realms")){let a=b.find(a=>/^(access_token|cb_token|codebuddy)/i.test(a.name)||"token"===a.name&&a.domain?.includes("codebuddy"));if(a)return{ok:!0,cookie:a.name,cookies:b}}}catch{}let i=d?await d().catch(()=>null):null;if(await au(a,i))return{ok:!1,cookies:b,reason:"restricted"};if(i){let a=await av(i);if(a)return{ok:!1,cookies:b,reason:`form_error:${a}`}}if(c&&Date.now()-g>4e3){g=Date.now();let a=Math.max(0,Math.round((f-Date.now())/1e3));c("cn_waiting_session",`Still waiting for Keycloak session… ${a}s left`)}await a.waitForTimeout(500)}return U(e),{ok:!1,cookies:await a.context().cookies().catch(()=>[])}}async function as(a,b=15e3){let c=a.locator("#kc-login").first();try{return await c.waitFor({state:"visible",timeout:b}),await c.click({timeout:5e3}),{ok:!0,method:"click"}}catch{}try{return await a.evaluate(()=>{let a=document.querySelector("#kc-form-login")||document.querySelector("form");if(!a)return!1;if("function"==typeof a.requestSubmit){let b=a.querySelector("#kc-login")||a.querySelector('[type="submit"]');b?a.requestSubmit(b):a.requestSubmit()}else a.submit();return!0})?{ok:!0,method:"requestSubmit"}:{ok:!1,method:null}}catch{let b=await a.locator(L).first().press("Enter").then(()=>!0).catch(()=>!1);return{ok:b,method:b?"enter":null}}}async function at(a){let b="";try{b=a.url()}catch{b="(unknown)"}let c=(await a.context().cookies().catch(()=>[])).map(a=>a.name).slice(0,20).join(",")||"(none)",d="";try{d=await a.evaluate(()=>(document.body?.innerText||"").replace(/\s+/g," ").trim().slice(0,120))}catch{d=""}let e=await ak(a),f="no-iframe";if(e)try{f=(await e.url()).slice(0,80)}catch{f="iframe-detached"}return{summary:`url=${b.slice(0,60)} cookies=[${c}] frame=${f}${d?` text="${d}"`:""}`,url:b,cookieNames:c,bodySnippet:d}}async function au(a,b){for(let c of[b,a])if(c)try{let a=await c.evaluate(()=>document.body?.innerText||"");if(function(a){let b=String(a||"").toLowerCase();return Q.some(a=>b.includes(a.toLowerCase()))}(a))return!0}catch{}return!1}async function av(a){for(let b of O)try{let c=a.locator(b).first();if(await c.isVisible({timeout:1500}).catch(()=>!1)){let a=await c.textContent().catch(()=>""),b=String(a).trim();if(b&&b.length>1)return b}}catch{}try{let b=await a.evaluate(()=>(document.body?.innerText||"").replace(/\s+/g," ").trim());for(let a of["验证码错误","验证码已过期","验证码无效","请输入正确的验证码","手机号格式","发送过于频繁"])if(b.includes(a)){let c=b.indexOf(a);return b.slice(Math.max(0,c-10),c+a.length+40).trim()}let c=b.match(/\b(?:invalid|incorrect|expired|wrong)\s+(?:\w+\s+){0,2}?(?:code|verification|password|credentials|phone(?:\s+number)?|username)\b/i)||b.match(/\b(?:code|verification\s+code|phone\s+number|credentials)\s+(?:is|was|are|were)\s+(?:\w+\s+){0,2}?(?:invalid|incorrect|expired|wrong)\b/i);if(c){let a=c.index??b.indexOf(c[0]);return b.slice(Math.max(0,a-10),a+c[0].length+40).trim()}}catch{}return null}async function aw(a,b,c=5e3){for(let b of N)try{let d=a.locator(b).first();if(await d.isVisible({timeout:Math.min(c,2e3)}).catch(()=>!1))return!0}catch{}if(b)for(let a of N)try{let d=b.locator(a).first();if(await d.isVisible({timeout:Math.min(c,2e3)}).catch(()=>!1))return!0}catch{}return!1}var ax=c(40891),ay=c(75949);let az=200,aA=Number.parseInt(process.env.ZEVAI_CN_ACCOUNT_TIMEOUT_MS||"",10)||3e5,aB="CN_API_KEY_OUTCOME_UNKNOWN",aC="CN_API_KEY_AUTOMATIC_RETRY_STOPPED",aD="CN_ACCOUNT_RESTRICTED",aE=new Set(["KEYCLOAK_IDENTITY","KEYCLOAK_SESSION","KEYCLOAK_IDENTITY_LEGACY","KEYCLOAK_SESSION_LEGACY"]),aF=new Set(["CN","HK"]),aG=new Set(["hongkong"]),aH="hongkong",aI=new Set(["queued","running","needs_manual"]),aJ=new Set(["queued","running","needs_manual"]);function aK(a){return String(a||"").trim()}function aL(a,b,c){return a.manualSession={context:b,page:c,opened:!1,openedAt:null},a.manualSession}function aM(){try{let{totalMemGb:a}=(0,l.si)();return Number.isFinite(a)&&a>0&&a<3}catch{return!1}}function aN(a){return!!a?.proxyUrls?.length&&["manual","all","single"].includes(a?.proxyPoolMode)}async function aO(a,{timeoutMs:b=6e3,rounds:c=3,retryDelayMs:d=350,sleepImpl:e=a=>new Promise(b=>setTimeout(b,a))}={}){let f=null;try{f=a?.request||null}catch{f=null}if(!f||"function"!=typeof f.get)return{ok:!1,ip:null,ips:[],samples:0,error:"context request unavailable"};let g=[],h=null,i=Math.max(1,Math.min(5,Number.parseInt(c,10)||1));for(let a=1;a<=i;a+=1){for(let c of ay.PROXY_EGRESS_ECHO_URLS){g.push(c);let d=null;try{var j;if(d=await f.get(c,{timeout:b,failOnStatusCode:!1,headers:{Accept:"text/plain, application/json;q=0.9, */*;q=0.1","Cache-Control":"no-cache"}}),200>d.status()||d.status()>=300){h=`HTTP ${d.status()}`;continue}let e=(j=await d.text().catch(()=>""),(0,ay.parseProxyEgressIp)(j));if(!e){h="exit-IP response was not recognized";continue}return{ok:!0,ip:e,ips:[e],samples:1,attempts:g.length,attemptedUrls:g,rounds:a,unstable:!1,error:null}}catch(a){h=a?.name==="TimeoutError"?`timed out after ${b}ms`:"request failed"}finally{"function"==typeof d?.dispose&&await Promise.resolve(d.dispose()).catch(()=>null)}}a<i&&d>0&&await e(Math.min(2e3,d*a))}return{ok:!1,ip:null,ips:[],samples:0,attempts:g.length,attemptedUrls:g,rounds:i,unstable:!1,error:h||"all exit-IP services failed"}}function aP(a,b=null){if(a?.unstable)throw Object.assign(Error("Manual proxy rotated between exit IPs during preflight; no phone number was purchased"),{code:"CN_PROXY_EGRESS_UNSTABLE"});if(!a?.ok||!a?.ip)throw Object.assign(Error(`Manual proxy exit IP could not be verified (${a?.error||"no response"}); no phone number was purchased`),{code:"CN_PROXY_EGRESS_UNVERIFIED"});if(b&&a.ip!==b)throw Object.assign(Error("Manual proxy browser exit IP changed before the 5sim purchase; no phone number was purchased"),{code:"CN_PROXY_EGRESS_CHANGED"});return a.ip}async function aQ(a,{timeoutMs:b,message:c,code:d,onTimeout:e,onLateResolve:f}){let g=Promise.resolve(a),h=null,i=!1,j=new Promise((a,f)=>{"function"==typeof(h=setTimeout(()=>{i=!0;try{"function"==typeof e&&e()}catch{}f(Object.assign(Error(c),{code:d}))},b)).unref&&h.unref()});try{return await Promise.race([g,j])}finally{h&&clearTimeout(h),i&&"function"==typeof f&&g.then(f).catch(()=>null)}}function aR(a,b="API key request"){let c=Number(a?.status);if(429===c)throw Object.assign(Error(`${b} was rate limited (HTTP 429); automatic POST retries stopped`),{code:aC});if(Number.isFinite(c)&&c>=500)throw Object.assign(Error(`${b} returned HTTP ${c}; creation outcome may be unknown and automatic POST retries stopped`),{code:aB});return a}function aS(a){let b=`${a?.text||""} ${a?.data?._raw||""} ${a?.url||""}`;return/<!doctype html|<html|login-pf|\/auth\/realms\//i.test(b)}function aT(a=[]){let b=a instanceof Set?a:new Set(Array.from(a,a=>"string"==typeof a?a:a?.name));return[...aE].some(a=>b.has(a))}function aU(a){let b=a?.data;if(!b||"object"!=typeof b)return null;let c=[b?.data?.accounts,b?.accounts,b?.data?.list,b?.list,b?.data?.result,b?.result,b?.data?.items,b?.items,Array.isArray(b?.data)?b.data:null,Array.isArray(b)?b:null],d=null;for(let a of c)if(Array.isArray(a)){if(a.length>0)return a;d=a}return d}function aV(a){let b=a?.data?.code,c=a?.data?.status??a?.data?.statusCode,d=!!a?.data?.error||a?.data?.success===!1||a?.data?.ok===!1||Number.isFinite(Number(c))&&Number(c)>=400;return a?.status===200&&!aS(a)&&a?.data!==null&&"object"==typeof a?.data&&a.data?._notJson!==!0&&!d&&(void 0===b||0===b||200===b)&&null!==aU(a)}function aW(a,b=[]){let c=b instanceof Set?b:new Set(b),d=`${a?.text||""} ${a?.data?._raw||""}`;return!!/账号访问受限|安全策略限制|访问受限|account restricted|access restricted/i.test(d)||!!c.has("login_risk_state")&&(aS(a)||a?.status===0||a?.status===401||a?.status===403)}async function aX({context:a,page:b,timeoutMs:c=1e4}){let d={Accept:"application/json, text/plain, */*","x-requested-with":"XMLHttpRequest","X-Domain":"www.codebuddy.cn","X-Product":"SaaS"},e=null;try{e=a?.request||null}catch{e=null}if(e&&"function"==typeof e.get)try{let a=await e.get("https://www.codebuddy.cn/console/accounts",{headers:d,timeout:c,failOnStatusCode:!1}),b=await a.text().catch(()=>"");return function(a,b,c={}){let d=String(b||""),e=null;try{e=d?JSON.parse(d):null}catch{e={_raw:d.slice(0,240),_notJson:!0}}return{status:Number(a)||0,data:e,text:d.slice(0,240),...c}}(a.status(),b,{source:"context-request",url:a.url(),contentType:a.headers()?.["content-type"]||""})}catch{}return aQ(b.evaluate(async({requestTimeoutMs:a,requestHeaders:b})=>{let c=new AbortController,d=setTimeout(()=>c.abort(),a);try{let a=window.location.hostname||"www.codebuddy.cn",d="www.codebuddy.cn"===a?`${window.location.origin}`:"https://www.codebuddy.cn",e=await fetch(`${d}/console/accounts`,{credentials:"include",signal:c.signal,headers:b}),f=await e.text().catch(()=>""),g=null;try{g=f?JSON.parse(f):null}catch{g={_raw:String(f||"").slice(0,240),_notJson:!0}}return{status:e.status,data:g,text:String(f||"").slice(0,240),source:"page-fetch",url:e.url,contentType:e.headers.get("content-type")||""}}catch(a){return{status:0,timedOut:a?.name==="AbortError",error:a?.message||String(a),source:"page-fetch"}}finally{clearTimeout(d)}},{requestTimeoutMs:c,requestHeaders:d}),{timeoutMs:c,message:`Console account probe timed out after ${c/1e3}s`,code:"CN_CONSOLE_PROBE_TIMEOUT"}).catch(a=>({status:0,timedOut:a?.code==="CN_CONSOLE_PROBE_TIMEOUT",error:a?.message||String(a),source:"page-fetch"}))}async function aY(a){if(!a||"function"!=typeof a.close)return!0;try{return await aQ(Promise.resolve().then(()=>a.close()),{timeoutMs:5e3,message:"Browser resource close timed out after 5s",code:"CN_RESOURCE_CLOSE_TIMEOUT"}),!0}catch{return!1}}async function aZ(a,b){if(await aY(a)||!b?.browser)return;let c=b.browser;b.browser=null,await (0,ay.forceCloseBrowser)(c).catch(()=>null)}async function a$(a){try{return await aQ(Promise.resolve().then(a),{timeoutMs:12e3,message:"5sim order settlement timed out after 12s",code:"CN_FIVESIM_SETTLE_TIMEOUT"})}catch{return!1}}async function a_({fiveSimClient:a,fiveSimOrderId:b,smsReceived:c=!1,error:d=null}={}){return a&&b?d?.isUpstreamTerminal===!0?{action:"none",ok:!0,reason:"upstream_terminal",orderStatus:d.orderStatus||null}:c?{action:"finish",ok:!0===await a$(()=>a.finishOrder(b))}:d instanceof y?{action:"ban",ok:!0===await a$(()=>a.banOrder(b))}:{action:"cancel",ok:!0===await a$(()=>a.cancelOrder(b))}:{action:"none",ok:!0,reason:"no_order"}}async function a0({apiKey:a,phone:b,region:d,fiveSimOrderId:e,account:f}){let{createProviderConnection:g}=await Promise.resolve().then(c.bind(c,71998)),h={provider:"codebuddy-cn",authType:"apikey",apiKey:a,accessToken:a,name:b||`5sim-${e}`,email:b||`5sim-${e}`,providerSpecificData:{domain:"www.codebuddy.cn",phoneNumber:b,fiveSimOrderId:e,region:d,automation:"5sim-phone-bulk"},testStatus:"active"};return{connection:await g(h)}}class a1 extends i.Q6{constructor({browserLauncher:a,requestDeviceCodeFn:b=ax.cT,pollToken:d=ax.ZV,fetchLoginAccountFn:e=ax.w8,saveConnection:g=a0,fiveSimClientFactory:i=a2,phoneAutomation:j=aj,phoneFormatter:k=aK,pollIntervalMs:l=n.ne.pollInterval,storageName:m="codebuddy-cn-bulk-import"}={}){super({browserLauncher:a||(async a=>{let{forceCloseBrowser:b,launchBulkImportBrowser:d}=await Promise.resolve().then(c.bind(c,75949)),e=Array.isArray(a?.proxyUrls)&&a.proxyUrls.length?a.proxyUrls[0]:null;return aQ(d({engine:a?.engine||"cloakbrowser",proxyUrl:e,headless:!1,windowSize:{width:1280,height:900},requireProxyGeoip:!!e}),{timeoutMs:9e4,message:"CloakBrowser launch timed out after 90s",code:"CN_BROWSER_LAUNCH_TIMEOUT",onLateResolve:a=>b(a)})}),storageName:m}),this.latestJobId&&this.readPersistedJob(this.latestJobId)||(this.latestJobId=function(a){try{let b=f().readdirSync(a).filter(a=>a.endsWith(".json")&&"meta.json"!==a).map(b=>{let c=h().join(a,b);try{let a=JSON.parse(f().readFileSync(c,"utf8"));if(!a?.jobId)return null;let b=Date.parse(a.createdAt||""),d=Number.isFinite(b)?b:f().statSync(c).mtimeMs;return{jobId:a.jobId,sortTime:d}}catch{return null}}).filter(Boolean).sort((a,b)=>b.sortTime-a.sortTime);return b[0]?.jobId||null}catch{return null}}(this.storageDir),this.latestJobId&&this.persistLatestJobId(this.latestJobId)),this.requestDeviceCode=b,this.pollToken=d,this.fetchLoginAccount=e,this.saveConnection=g,this.fiveSimClientFactory=i,this.phoneAutomation=j,this.phoneFormatter=k,this.pollIntervalMs=l}async startJob({count:a,concurrency:b,proxyPoolMode:c,proxyPoolId:e,manualProxyUrl:f,region:g}){let h=Number.parseInt(a,10);if(!Number.isFinite(h)||h<1)throw Object.assign(Error("At least one account is required (count >= 1)"),{error:"At least one account is required (count >= 1)"});if(h>az)throw Object.assign(Error(`Count exceeds maximum of ${az}`),{error:`Count exceeds maximum of ${az}`});this.latestJobId&&!this.jobs.has(this.latestJobId)&&this.getJob(this.latestJobId);let k=[...this.jobs.values()].find(a=>a&&("running"===a.status||"queued"===a.status||"needs_manual"===a.status)&&!a.cancelRequested);if(k)throw Object.assign(Error(`Another CodeBuddy CN job is still active (${k.jobId}). Cancel it or wait before starting again.`),{error:`Another CodeBuddy CN job is still active (${k.jobId}). Cancel it or wait before starting again.`});let m=aG.has(g)?g:aH,n=[],o="string"==typeof f?f.trim():"";if(o){if(!/^(https?|socks4|socks5):\/\/.+/i.test(o))throw Object.assign(Error("manualProxyUrl must be a valid proxy URL (http://, https://, socks4://, or socks5://)"),{error:"manualProxyUrl must be a valid proxy URL (http://, https://, socks4://, or socks5://)"});n=[o]}else if("all"===c)n=(await (0,j.ui)({isActive:!0})).map(a=>a.proxyUrl).filter(Boolean);else if("single"===c&&e){let a=await (0,j.hr)(e);a?.isActive&&a?.proxyUrl&&(n=[a.proxyUrl])}o||function(a,b){if(!["all","single"].includes(a)||b.length>0)return;let c="single"===a?"Selected proxy is missing or inactive; no automation was started":"No active proxies are available in the selected pool; no automation was started";throw Object.assign(Error(c),{error:c,code:"CN_PROXY_SELECTION_EMPTY"})}(c,n);let p=(0,d.randomUUID)(),q=(0,i.kF)(),r={jobId:p,status:"running",concurrency:function(a,{manualProxy:b=!1,processBoundProxy:c=!1}={}){return b||c?1:function(a){if(aM(),(0,l.uT)(a))return Math.min(1,Math.max(1,(0,l.q)()));let b=Number.parseInt(a,10);return Number.isFinite(b)?Math.min(1,Math.max(1,b)):1}(a)}(b,{manualProxy:!!o,processBoundProxy:n.length>0}),proxyPoolMode:o?"manual":c||"none",proxyUrls:n,region:m,createdAt:q,startedAt:q,finishedAt:null,error:null,cancelRequested:!1,browser:null,nextIndex:0,manualFollowups:new Set,persistPromise:Promise.resolve(),lastPreview:null,lastPreviewCapturedAt:0,accounts:Array.from({length:h},(a,b)=>({line:b+1,region:m,phone:null,fiveSimOrderId:null,fiveSimActivationId:null,fingerprintSeed:(0,d.randomUUID)(),proxyUrl:null,egressIp:null,proxyTimezone:null,proxyLocale:null,abortController:new AbortController,status:"queued",error:null,connectionId:null,workerId:null,manualSession:null,runtimeSession:null,currentStep:"queued",updatedAt:q,logs:[(0,i.hn)("queued","Queued and waiting for an available worker")]}))};return this.jobs.set(p,r),this.latestJobId=p,this.persistLatestJobId(p),await this.persistJobSnapshot(r,{forcePreview:!1}),this.runJob(p),a4(r)}buildPersistedSnapshot(a){return a4(a,{preview:a.lastPreview||null})}terminalizeInterruptedSnapshot(a){if(!a||!aI.has(a.status))return a;let b="CodeBuddy CN job was interrupted by a service restart. Browser and OTP sessions cannot be resumed safely; start a new job.",c=(a.accounts||[]).map(a=>{if(!aJ.has(a.status))return a;let c=(0,i.hn)("failed",b,"error");return{...a,status:"failed",error:b,currentStep:"failed",updatedAt:c.at,manualSessionAvailable:!1,logs:[...a.logs||[],c].slice(-40)}}),d={...a,status:"failed",error:a.error||b,finishedAt:a.finishedAt||(0,i.kF)(),accounts:c,summary:a3(c),preview:null};return this.writePersistedJob(a.jobId,d),d}getJob(a){let b=this.jobs.get(a);if(b)return a4(b);let c=this.readPersistedJob(a);return c?this.terminalizeInterruptedSnapshot(c):null}async getJobWithPreview(a){let b=this.jobs.get(a);return b?(await this.persistJobSnapshot(b,{forcePreview:!1}),a4(b,{preview:b.lastPreview||null})):this.getJob(a)}async processAccount(a,b,c){if(a.cancelRequested)return void this.finalizeAccount(b,"cancelled",{error:"Job cancelled"});if(!a.browser){this.setAccountStep(b,"recovering_browser","Relaunching CodeBuddy CN browser after a prior worker failure");try{let b=Promise.resolve().then(()=>this.browserLauncher(a));a.browser=await aQ(b,{timeoutMs:9e4,message:"CodeBuddy CN browser recovery timed out after 90s",code:"CN_BROWSER_RECOVERY_TIMEOUT",onLateResolve:a=>(0,ay.forceCloseBrowser)(a)})}catch(c){this.finalizeAccount(b,"failed",{error:c?.message||"CodeBuddy CN browser recovery failed",step:"browser_recovery_failed",message:c?.message||"CodeBuddy CN browser recovery failed"}),await this.persistJobSnapshot(a,{forcePreview:!0});return}if(a.cancelRequested){let c=a.browser;a.browser=null,await (0,ay.forceCloseBrowser)(c).catch(()=>null),this.finalizeAccount(b,"cancelled",{error:"Job cancelled"});return}}let d=null,e=null,f=!1,g=null,h=!1,j=null;try{let c;this.setAccountStep(b,"reading_settings","Reading 5sim API key from settings"),await this.persistJobSnapshot(a,{forcePreview:!0});let l=(await (0,k.mt)()).fiveSimApiKey;if(!l||!l.trim()){this.finalizeAccount(b,"failed",{error:"5sim API key not configured. Set it in the automation modal or dashboard settings.",step:"failed",message:"5sim API key not configured"}),await this.persistJobSnapshot(a,{forcePreview:!0});return}d=this.fiveSimClientFactory({apiKey:l,proxyOptions:null}),this.setAccountStep(b,"creating_browser","Creating browser context (before 5sim order)"),await this.persistJobSnapshot(a,{forcePreview:!0}),h=!0;let m=(0,i.go)(a.browser,b.proxyUrl,{profile:"codebuddy-cn",region:a.region||"hongkong",fingerprintSeed:b.fingerprintSeed,lowMemory:aM(),nativeCloakProfile:aN(a)&&!!b.proxyUrl}),n=await aQ(m,{timeoutMs:3e4,message:"Browser context creation timed out after 30s",code:"CN_CONTEXT_TIMEOUT",onLateResolve:a=>Promise.resolve(a?.context?.close?.()).catch(()=>null)});g=n.context;let o=n.page;b.runtimeSession={context:g,page:o},h=!1;let p=(0,ay.getCloakProxyProfile)(a.browser);if(b.proxyUrl&&(!function(a){let b=String(a?.countryCode||"").trim().toUpperCase();if(!(!b||aF.has(b)))throw Object.assign(Error(`CodeBuddy CN requires a CN/HK residential exit; detected ${b}. No phone number was purchased.`),{code:"CN_PROXY_REGION_UNSUPPORTED",countryCode:b})}(p),b.proxyTimezone=p?.timezone||null,b.proxyLocale=p?.locale||null),"manual"===a.proxyPoolMode&&b.proxyUrl){this.setAccountStep(b,"checking_proxy_egress","Verifying pasted proxy exit IP before opening the registration form"),await this.persistJobSnapshot(a,{forcePreview:!1});let c=await aO(g);b.egressIp=j=aP(c),b.proxyTimezone=p?.timezone||null,b.proxyLocale=p?.locale||null,this.setAccountStep(b,"proxy_egress_ready",`Manual proxy verified: ${j} (${c.samples} checks, ${b.proxyTimezone||"timezone unknown"}, ${b.proxyLocale||"locale unknown"})`),await this.persistJobSnapshot(a,{forcePreview:!1})}if(a.cancelRequested)throw Error("Job cancelled before ordering phone number");this.setAccountStep(b,"registering","Running phone registration on CodeBuddy CN"),await this.persistJobSnapshot(a,{forcePreview:!0});try{o.setDefaultTimeout(2e4),o.setDefaultNavigationTimeout(45e3)}catch{}let q=null,r=null,s=new Promise((a,b)=>{r=b}),t=()=>{q&&clearTimeout(q),q=setTimeout(()=>{let a=Object.assign(Error(`CodeBuddy CN account hard timeout after ${Math.round(aA/1e3)}s (browser will be force-closed)`),{code:"CN_ACCOUNT_HARD_TIMEOUT"});b.abortController&&!b.abortController.signal.aborted&&b.abortController.abort(a),r(a)},aA),"function"==typeof q.unref&&q.unref()};t();try{c=await Promise.race([this.phoneAutomation({page:o,signal:b.abortController?.signal,isCancelled:()=>!0===a.cancelRequested,resolvePhone:async()=>{if(a.cancelRequested)throw Error("Job cancelled before ordering phone number");if("manual"===a.proxyPoolMode&&b.proxyUrl){this.setAccountStep(b,"rechecking_proxy_egress","Registration form is ready — confirming the pasted proxy stayed sticky"),await this.persistJobSnapshot(a,{forcePreview:!1});let c=await aO(g);aP(c,j),this.setAccountStep(b,"proxy_egress_confirmed",`Manual proxy remained on ${j}; safe to purchase one phone number`),await this.persistJobSnapshot(a,{forcePreview:!1})}this.setAccountStep(b,"ordering_number",`Form ready — ordering ${a.region} phone from 5sim (single buy)`),await this.persistJobSnapshot(a,{forcePreview:!0});let c=await d.buyNumber({country:a.region,product:"codebuddy",allowProductFallback:!1,signal:b.abortController?.signal});return e=c.id,b.phone=c.phone,b.fiveSimOrderId=c.id,b.fiveSimActivationId=c.id,this.setAccountStep(b,"number_ordered",`Phone number ordered: ${c.phone} (1 buy, no re-order)`),await this.persistJobSnapshot(a,{forcePreview:!0}),c.phone},waitForSms:async()=>{if(!e)throw Error("Cannot poll SMS — no 5sim order id");this.setAccountStep(b,"sms_poll_started","SMS poll started (full 90s window after send-code)"),await this.persistJobSnapshot(a,{forcePreview:!1});let c=await d.pollCode(e,{timeoutMs:9e4,signal:b.abortController?.signal});return f=!0,c},onManualRequired:async({phase:c}={})=>{if("sms_request"===c){if(b.abortController?.signal.aborted||a.cancelRequested)throw b.abortController?.signal.reason||Object.assign(Error("Job cancelled"),{code:"JOB_CANCELLED"});t(),aL(b,g,o),this.finalizeAccount(b,"needs_manual",{error:"Captcha blocked the SMS request; complete it in the existing browser",step:"awaiting_sms_captcha",message:"Open the manual session and complete the SMS-request captcha"}),await this.persistJobSnapshot(a,{forcePreview:!0})}},onManualResolved:async({phase:c}={})=>{if("sms_request"===c){if(a.cancelRequested)throw Object.assign(Error("Job cancelled"),{code:"JOB_CANCELLED"});b.manualSession=null,b.status="running",b.error=null,this.setAccountStep(b,"sms_captcha_completed","SMS-request captcha completed; automation resumed"),await this.persistJobSnapshot(a,{forcePreview:!0})}},onStep:(c,d)=>{this.setAccountStep(b,c,d),this.persistJobSnapshot(a,{forcePreview:!1})},phoneFormatter:this.phoneFormatter}),s])}finally{q&&clearTimeout(q)}if(a.cancelRequested||b.abortController?.signal.aborted){let a=b.abortController?.signal.reason;if(a?.code==="CN_ACCOUNT_HARD_TIMEOUT")throw a;throw Object.assign(Error("Job cancelled"),{code:"JOB_CANCELLED"})}if(String(c.status||"").startsWith("failed")){let h=c.error||"Phone registration failed before submit",i=c.status||"failed";this.finalizeAccount(b,i,{error:h,step:i,message:h}),d&&e&&(f?await a$(()=>d.finishOrder(e)):await a$(()=>d.cancelOrder(e))),b.manualSession=null,b.runtimeSession=null,await aZ(g,a),await this.persistJobSnapshot(a,{forcePreview:!0});return}if("needs_manual"===c.status){aL(b,g,o),this.finalizeAccount(b,"needs_manual",{error:c.error||"Manual completion is required",step:"awaiting_manual",message:c.error||"Complete the existing CodeBuddy login session manually"});let h=!1;d&&e&&f&&(await a$(()=>d.finishOrder(e)),h=!0),await this.persistJobSnapshot(a,{forcePreview:!0}),await this.runCnManualFollowup(a,b,b.workerId,g,o,d,e,null,{smsReceived:f,orderSettled:h});return}if("success"!==c.status)throw Error(`Unexpected phone automation status: ${c.status||"unknown"}`);await this.captureApiKey(a,b,g,o,d,e);return}catch(o){let c=o?.isUpstreamTerminal===!0,i=o instanceof u&&!c,j=o instanceof u&&o?.orderStatus==="TIMEOUT",k=o instanceof y,l=a.cancelRequested||o?.code==="JOB_CANCELLED",m=await a_({fiveSimClient:d,fiveSimOrderId:e,smsReceived:f,error:o}),n=l?"Job cancelled":i?"SMS OTP not received within 90s":j?"5sim marked the order as TIMEOUT before an SMS arrived":k?"5sim marked the phone number as BANNED before an SMS arrived":o.message||"Unexpected CodeBuddy CN bulk import failure";if(i&&"cancel"===m.action&&m.ok&&(n+="; order cancelled for refund"),"none"===m.action||m.ok||(n+=`; 5sim ${m.action} could not be confirmed for order ${e} - check 5sim manually`),this.finalizeAccount(b,l?"cancelled":"failed",{error:n,step:l?"cancelled":i?"sms_timeout":j?"sms_order_timeout":k?"sms_number_banned":"failed",message:n}),b.manualSession=null,b.runtimeSession=null,await aZ(g,a),(o?.code==="CN_ACCOUNT_HARD_TIMEOUT"||o?.code==="CN_CONTEXT_TIMEOUT"||h||a.cancelRequested)&&a.browser){let b=a.browser;a.browser=null,await (0,ay.forceCloseBrowser)(b).catch(()=>null)}await this.persistJobSnapshot(a,{forcePreview:!0})}}async captureApiKey(a,b,c,d,e,f){let g="personal-edition-user-id",h=null,i=async(a,{timeout:b=12e3,interval:c=150}={})=>{let d=Date.now()+b;for(;Date.now()<d;){try{if(await a())return!0}catch{}await new Promise(a=>setTimeout(a,c))}return!1};try{this.setAccountStep(b,"waiting_session","Establishing CodeBuddy console session (probe APIs, not just cookies)"),await this.persistJobSnapshot(a,{forcePreview:!0});let j=async()=>{let a=await c.cookies().catch(()=>[]);return{cookies:a,names:new Set(a.map(a=>a.name)),list:a.map(a=>a.name)}},k=a=>a.has("AUTH_SESSION_ID")||a.has("session")||a.has("qcloud_uid")||a.has("qcmainCSRFToken")||a.has("x_host_key_access"),l=()=>aX({context:c,page:d}),m=async(a=2500)=>{let b=!1,c=null;try{await Promise.race([d.waitForLoadState("domcontentloaded",{timeout:a}).catch(()=>null),i(async()=>{if(b)return!0;let a=await j();return aT(a.names)},{timeout:a,interval:200}),new Promise(b=>{c=setTimeout(b,a)})])}finally{b=!0,c&&clearTimeout(c)}},n=async a=>{let b=Date.now();try{await d.goto(a,{waitUntil:"commit",timeout:18e3});let c=18e3-(Date.now()-b);return c>0&&await m(Math.min(2500,c)),!0}catch{return!1}},o=["https://www.codebuddy.cn/","https://www.codebuddy.cn/console","https://www.codebuddy.cn/console/","https://www.codebuddy.cn/profile","https://www.codebuddy.cn/profile/keys"],p=null,q=null,r=!1,s="",t=null,u=0;for(let c=0;c<6;c+=1){if(a.cancelRequested)throw Error("Job cancelled while establishing session");let e=await j(),f=aT(e.names),g=k(e.names),h=o[Math.min(c,o.length-1)];c<3||c%2==0||!g?(this.setAccountStep(b,"waiting_session",`OIDC handoff ${c+1}/6 → ${h.replace("https://www.codebuddy.cn","")} (${f?"KEYCLOAK":g?"soft-session":"weak"})`),await this.persistJobSnapshot(a,{forcePreview:!1}),await n(h)):await new Promise(a=>setTimeout(a,300)),/^https:\/\/www\.codebuddy\.cn(?:[/:]|$)/i.test(d.url?.()||"")||await n("https://www.codebuddy.cn/console"),q=await l(),p=aU(q),(q?.status>0||q?.text||q?.data)&&(t=q),s=JSON.stringify(q?.data??q?.text??q?.error??null).slice(0,180);let i=aS(q),m=aV(q),v=await j();if(!aT(v.names)&&aW(q,v.names)?u+=1:u=0,u>=2)throw Object.assign(Error(`Tencent restricted the post-OTP session (${u} console probes returned login/risk evidence; source=${q?.source||"unknown"})`),{code:aD});if(m&&Array.isArray(p)&&p.length>0){r=!0,this.setAccountStep(b,"session_ready",`Console session accepted (HTTP 200, ${p.length} account(s)${f?", KEYCLOAK ok":", soft session"})`),await this.persistJobSnapshot(a,{forcePreview:!0});break}if(g&&m&&Array.isArray(p)&&0===p.length&&c>=3){this.setAccountStep(b,"session_soft","Console HTTP 200 but 0 accounts — trying personal API key with soft session (cookies ok)"),await this.persistJobSnapshot(a,{forcePreview:!0}),r=!0;break}this.setAccountStep(b,"resolving_enterprise",`Console not ready (HTTP ${q?.status||0}, accounts=${Array.isArray(p)?p.length:"unrecognized"}${i?", login HTML":""}, source=${q?.source||"unknown"}) — ${c+1}/6 body=${s.slice(0,80)}`),await this.persistJobSnapshot(a,{forcePreview:!1})}if(!r){let a=await j(),b=t||q,c=aW(b,a.names)||a.names.has("login_risk_state")&&u>0;throw Object.assign(Error(c?`Tencent restricted the post-OTP session (HTTP ${b?.status||0}; login_risk_state present; source=${b?.source||"unknown"})`:`Console accounts unavailable after login (HTTP ${b?.status||0}; cookies: ${a.list.slice(0,18).join(",")||"(none)"}; body=${s.slice(0,120)}; probeError=${q?.error||"none"}) — session not accepted for API key`),{code:c?aD:"CN_CONSOLE_SESSION_UNAVAILABLE"})}let v=g;if(Array.isArray(p)&&p.length>0){let a=p.find(a=>a?.lastLogin)||p[0];a?.type&&"personal"!==a.type&&a.enterpriseId?v=a.enterpriseId:a?.enterpriseId&&a?.type!=="personal"&&(v=a.enterpriseId)}this.setAccountStep(b,"creating_api_key",`Creating API key (enterprise=${v}, accounts=${p.length})`),await this.persistJobSnapshot(a,{forcePreview:!0});let w=`zevai-router-${b.workerId||"account"}-${Date.now()}`,x=async a=>d.evaluate(async({enterpriseId:a,keyName:b,timeoutMs:c})=>{let d=new AbortController,e=setTimeout(()=>d.abort(),c);try{let c=window.location.hostname||"www.codebuddy.cn",e="www.codebuddy.cn"===c?window.location.origin:"https://www.codebuddy.cn",f=await fetch(`${e}/console/api/client/v1/api-keys`,{method:"POST",credentials:"include",signal:d.signal,headers:{"Content-Type":"application/json",Accept:"application/json, text/plain, */*","x-requested-with":"XMLHttpRequest","X-Domain":"www.codebuddy.cn","X-Product":"SaaS"},body:JSON.stringify({name:b,expire_in_days:365,user_enterprise_id:a})}),g=await f.text().catch(()=>""),h=null;try{h=g?JSON.parse(g):null}catch{h={_raw:String(g||"").slice(0,200)}}return{ok:f.ok,status:f.status,data:h}}catch(a){return{ok:!1,status:0,outcomeUnknown:!0,timedOut:a?.name==="AbortError",error:a?.message||String(a)}}finally{clearTimeout(e)}},{enterpriseId:a,keyName:w,timeoutMs:6e4}),y=async(c,d)=>{let e,f=Date.now(),g=null,h=setInterval(()=>{if(g)return;let c=Math.max(5,Math.round((Date.now()-f)/1e3));this.setAccountStep(b,"creating_api_key",`${d} — waiting for CodeBuddy (${c}s)`),g=this.persistJobSnapshot(a,{forcePreview:!1}).catch(()=>null).finally(()=>{g=null})},5e3);"function"==typeof h.unref&&h.unref();try{e=await aQ(x(c),{timeoutMs:6e4,message:"API key request timed out after 60s; creation outcome is unknown",code:aB})}catch(a){if(a?.code===aB)throw a;throw Object.assign(Error(`API key request lost its response; creation outcome is unknown: ${a?.message||String(a)}`),{code:aB})}finally{clearInterval(h),g&&await g.catch(()=>null)}if(e?.outcomeUnknown){let a=e.timedOut?"timed out after 60s":`lost its response (${e.error||"network error"})`;throw Object.assign(Error(`API key request ${a}; creation outcome is unknown`),{code:aB})}return aR(e,d)};if(!await n("https://www.codebuddy.cn/profile/keys"))throw Object.assign(Error("Keys page navigation timed out after 18s"),{code:"CN_CONSOLE_NAV_TIMEOUT"});let z=await y(v,"Creating API key");z?.status===400&&v!==g&&(this.setAccountStep(b,"retrying_api_key","Retrying with personal-edition enterprise id"),await this.persistJobSnapshot(a,{forcePreview:!1}),z=await y(g,"Retrying personal API key"));let A=a=>a?.ok===!1&&(401===a.status||403===a.status);for(let c=1;c<=2&&A(z);c+=1){for(let d of(this.setAccountStep(b,"retrying_api_key",`API key 401/403 — OIDC re-handoff round ${c}/2 (waiting strong session)`),await this.persistJobSnapshot(a,{forcePreview:!0}),["https://www.codebuddy.cn/","https://www.codebuddy.cn/console","https://www.codebuddy.cn/profile/keys"]))await n(d);await i(async()=>{let a=await j();return aT(a.names)},{timeout:8e3*c,interval:300}).catch(()=>null),z=await y(g,`Retrying API key after OIDC handoff ${c}/2`)}let B=z?.data?.code;if(!z||!z.ok||!z.data||0!==B&&200!==B&&void 0!==B){let a="string"==typeof z?.data?._raw?z.data._raw.replace(/\s+/g," ").slice(0,120):null,b=a&&/openresty|nginx|Authorization Required/i.test(a)?" [edge proxy blocked — session half-baked]":"";throw Error(`API key creation failed (HTTP ${z?.status??"no-response"}, code=${B??"n/a"})${b}: ${JSON.stringify(z?.data??null).slice(0,200)}`)}let C=z.data?.data||z.data,D=C?.apiKey||C?.key||C?.token||C?.secret||C?.api_key||("string"==typeof C?C:null)||z.data.apiKey||z.data.key||z.data.token||z.data.secret;if(!D||"string"!=typeof D)throw Object.assign(Error(`API key response did not contain a key field; creation outcome is unknown: ${JSON.stringify(z.data).slice(0,300)}`),{code:aB});h=D,this.setAccountStep(b,"api_key_created","API key created successfully"),await this.persistJobSnapshot(a,{forcePreview:!0}),this.setAccountStep(b,"saving_connection","Saving CodeBuddy CN connection"),await this.persistJobSnapshot(a,{forcePreview:!0});let{connection:E}=await this.saveConnection({apiKey:D,phone:b.phone,region:b.region,fiveSimOrderId:f,account:b});await a$(()=>e.finishOrder(f)),this.finalizeAccount(b,"success",{connectionId:E.id,step:"connection_saved",message:`CodeBuddy CN connection saved (phone: ${b.phone})`}),b.runtimeSession=null,await aZ(c,a),await this.persistJobSnapshot(a,{forcePreview:!0})}catch(m){let g=m?.code===aD,i=m?.code===aB,j=m?.code===aC,k=i||j;if(g){this.finalizeAccount(b,"failed_restricted",{error:`${m.message}. Use a different residential CN/HK proxy with concurrency 1.`,step:"failed_restricted",message:"Tencent restricted the post-OTP session; API-key capture was not attempted"}),await a$(()=>e.finishOrder(f)),b.runtimeSession=null,await aZ(c,a),await this.persistJobSnapshot(a,{forcePreview:!0});return}let l=i?`${m.message}. Check the CodeBuddy keys page before creating another key.`:m.message;if(k||aL(b,c,d),this.finalizeAccount(b,"needs_manual",{error:`Registration succeeded but API key capture failed: ${l}`,step:i?"api_key_outcome_unknown":j?"api_key_retry_stopped":"awaiting_manual",message:i?"Registration done; API key request outcome is unknown. Check existing keys before retrying.":j?"Registration done; API key request was rate limited. Automatic POST retries stopped.":h?`API key captured; retrying local connection save without creating another key: ${m.message}`:`Registration done, API key capture failed: ${m.message}`}),await a$(()=>e.finishOrder(f)),await this.persistJobSnapshot(a,{forcePreview:!0}),k){b.runtimeSession=null,await aZ(c,a);return}await this.runCnManualFollowup(a,b,b.workerId,c,d,e,f,h)}}async runCnManualFollowup(a,b,c,d,e,f,g,h=null,{smsReceived:i=!0,orderSettled:j=!0}={}){let k=(async()=>{let c=!1,l=async()=>{let c=b.manualSession,e=c?.context||d,f=c?.headedBrowser||null;await aZ(e,a),f&&await (0,ay.forceCloseBrowser)(f).catch(()=>null)};try{this.setAccountStep(b,"manual_waiting","Waiting for operator to complete in headed browser"),await this.persistJobSnapshot(a,{forcePreview:!0});let f=aM()?18e4:48e4,i=Date.now()+f,j="string"==typeof h&&h?h:null,k=!!j;for(;!k&&Date.now()<i&&!a.cancelRequested;){let a=await d.cookies().catch(()=>[]);if(aT(a)){k=!0;break}let b=await aX({context:d,page:e}).catch(()=>null);if(aV(b)){k=!0;break}await new Promise(a=>setTimeout(a,1e4))}if(a.cancelRequested){this.finalizeAccount(b,"cancelled",{error:"Job cancelled",step:"cancelled",message:"Job cancelled while waiting for manual completion"}),await this.persistJobSnapshot(a,{forcePreview:!0});return}if(!k)throw Error("Manual assist timed out — CodeBuddy login was not authenticated");if(!j){this.setAccountStep(b,"manual_authenticated","Manual login authenticated; creating one API key"),await this.persistJobSnapshot(a,{forcePreview:!0}),await e.goto("https://www.codebuddy.cn/profile/keys",{waitUntil:"commit",timeout:18e3});let c=`zevai-router-manual-${b.workerId||"account"}-${Date.now()}`,d=await aQ(e.evaluate(async({keyName:a,timeoutMs:b})=>{let c=new AbortController,d=setTimeout(()=>c.abort(),b);try{let b=await fetch("https://www.codebuddy.cn/console/api/client/v1/api-keys",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json, text/plain, */*","x-requested-with":"XMLHttpRequest","X-Domain":"www.codebuddy.cn","X-Product":"SaaS"},credentials:"include",signal:c.signal,body:JSON.stringify({name:a,expire_in_days:365,user_enterprise_id:"personal-edition-user-id"})}),d=await b.json().catch(()=>null);return{ok:b.ok,status:b.status,data:d}}catch(a){return{ok:!1,status:0,outcomeUnknown:!0,error:a?.message||String(a)}}finally{clearTimeout(d)}},{keyName:c,timeoutMs:6e4}),{timeoutMs:6e4,message:"Manual API key request timed out; creation outcome is unknown",code:aB});if(d?.outcomeUnknown)throw Object.assign(Error(`Manual API key request lost its response; creation outcome is unknown: ${d.error||"network error"}`),{code:aB});if(aR(d,"Manual API key request"),!d?.ok)throw Error(`Manual API key request failed (HTTP ${d?.status||0}); it was not retried`);let f=d.data?.data||d.data;if(!(j=f?.apiKey||f?.key||f?.token||f?.secret||f?.api_key||("string"==typeof f?f:null))||"string"!=typeof j)throw Object.assign(Error("Manual API key response was successful but did not contain the key; creation outcome is unknown"),{code:aB})}this.setAccountStep(b,"saving_connection","Saving CodeBuddy CN connection (manual)"),await this.persistJobSnapshot(a,{forcePreview:!0});let{connection:l}=await this.saveConnection({apiKey:j,phone:b.phone,region:b.region,fiveSimOrderId:g,account:b});this.finalizeAccount(b,"success",{connectionId:l.id,step:"connection_saved",message:`CodeBuddy CN connection saved via manual assist (phone: ${b.phone||"N/A"})`}),c=!0,await this.persistJobSnapshot(a,{forcePreview:!0})}catch(c){if(a.cancelRequested)this.finalizeAccount(b,"cancelled",{error:"Job cancelled",step:"cancelled",message:"Job cancelled while waiting for manual completion"});else c?.code===aB||c?.code===aC?this.finalizeAccount(b,"needs_manual",{error:`${c.message}. Check existing CodeBuddy keys before retrying manually.`,step:c?.code===aB?"api_key_outcome_unknown":"api_key_retry_stopped",message:"Manual API key POST retries stopped"}):this.finalizeAccount(b,"failed",{error:c.message||"Manual assist flow failed",step:"failed",message:c.message||"Manual assist flow failed"});await this.persistJobSnapshot(a,{forcePreview:!0})}finally{if(!j&&f&&g){let a=c||i?"finishOrder":"cancelOrder";await a$(()=>f[a](g))||this.setAccountStep(b,"fivesim_settle_failed",`5sim ${a} could not be confirmed for order ${g} - check 5sim manually`,"warn")}await l(),b.manualSession=null,b.runtimeSession=null,a.manualFollowups.delete(k),await this.persistJobSnapshot(a,{forcePreview:!0})}})();return a.manualFollowups.add(k),k}async runWorker(a,b){if(!aN(a))return super.runWorker(a,b);for(;!a.cancelRequested;){let c=this.dequeueAccount(a,b);if(!c)return;if(!a.browser)try{a.browser=await this.browserLauncher({...a,proxyUrls:c.proxyUrl?[c.proxyUrl]:a.proxyUrls})}catch(b){this.finalizeAccount(c,"failed",{error:b?.message||"Manual proxy browser launch failed",step:"failed",message:b?.message||"Manual proxy browser launch failed"}),await this.persistJobSnapshot(a,{forcePreview:!0});continue}try{await this.processAccount(a,c,b)}catch(b){"running"===c.status&&(this.finalizeAccount(c,"failed",{error:b?.message||"Unexpected manual proxy worker failure",step:"failed",message:b?.message||"Unexpected manual proxy worker failure"}),await this.persistJobSnapshot(a,{forcePreview:!0}))}finally{if(a.manualFollowups.size>0&&await Promise.allSettled([...a.manualFollowups]),a.browser){let b=a.browser;a.browser=null,await (0,ay.forceCloseBrowser)(b).catch(()=>null)}}}}shouldPrelaunchBrowser(a){return!aN(a)}cancelJob(a){let b=this.jobs.get(a);if(!b)return null;for(let a of(b.cancelRequested=!0,b.accounts)){a.abortController&&!a.abortController.signal.aborted&&a.abortController.abort();let b=a.manualSession,c=a.runtimeSession,d=new Set([b?.context,c?.context].filter(Boolean)),e=new Set([b?.headedBrowser,b?.ownedBrowser].filter(Boolean));Promise.allSettled([...[...d].map(a=>aY(a)),...[...e].map(a=>(0,ay.forceCloseBrowser)(a))]),a.runtimeSession=null,a.manualSession=null,aJ.has(a.status)&&this.finalizeAccount(a,"cancelled",{error:"Job cancelled",step:"cancelled",message:"Job cancelled by user"})}if(b.browser){let a=b.browser;b.browser=null,(0,ay.forceCloseBrowser)(a).catch(()=>null)}return aI.has(b.status)&&(b.status="cancelled",b.finishedAt=b.finishedAt||(0,i.kF)()),this.persistJobSnapshot(b,{forcePreview:!0}),a4(b)}}function a2({apiKey:a,proxyOptions:b}){return new z({apiKey:a,proxyOptions:b})}function a3(a=[]){let b={total:a.length,queued:0,running:0,completed:0,success:0,failed:0,needs_manual:0,cancelled:0};for(let c of a){let a=c.status||"queued";"success"===a?(b.success+=1,b.completed+=1):a.startsWith("failed")?(b.failed+=1,b.completed+=1):"needs_manual"===a?b.needs_manual+=1:"cancelled"===a?(b.cancelled+=1,b.completed+=1):"running"===a?b.running+=1:b.queued+=1}return b}function a4(a,b={}){return a?{jobId:a.jobId,status:a.status,summary:a3(a.accounts),concurrency:a.concurrency,proxyPoolMode:a.proxyPoolMode,region:a.region,createdAt:a.createdAt,startedAt:a.startedAt,finishedAt:a.finishedAt,error:(0,m.yr)(a.error),cancelRequested:a.cancelRequested,accounts:(a.accounts||[]).map(a=>({line:a.line,region:a.region,phone:a.phone,fiveSimOrderId:a.fiveSimOrderId,proxyUrl:a.proxyUrl?function(a){if(!a)return null;let b=String(a),c=()=>b.length>20?`${b.slice(0,10)}***${b.slice(-10)}`:"***";try{let a=new URL(b);if(!/^(https?|socks4|socks5):$/.test(a.protocol))return c();return(0,m.Eq)(b)}catch{return c()}}(a.proxyUrl):null,egressIp:a.egressIp||null,proxyTimezone:a.proxyTimezone||null,proxyLocale:a.proxyLocale||null,status:a.status,error:(0,m.yr)(a.error),connectionId:a.connectionId,workerId:a.workerId,manualSessionAvailable:!!a.manualSession,currentStep:a.currentStep,updatedAt:a.updatedAt,logs:(a.logs||[]).map(a=>({...a,message:(0,m.yr)(a.message)}))})),preview:void 0!==b.preview?b.preview:a.lastPreview||null,...b}:null}function a5(){return(!globalThis.__codeBuddyCnBulkImportSingleton&&(globalThis.__codeBuddyCnBulkImportSingleton={manager:new a1}),globalThis.__codeBuddyCnBulkImportSingleton).manager}}};
|