omniroute 2.3.0 → 2.3.2
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/README.md +93 -2
- package/app/.next/BUILD_ID +1 -1
- package/app/.next/app-path-routes-manifest.json +38 -38
- package/app/.next/build-manifest.json +2 -2
- package/app/.next/prerender-manifest.json +3 -3
- package/app/.next/server/app/(dashboard)/dashboard/a2a/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/agents/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/analytics/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/api-manager/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/audit-log/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/auto-combo/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/cli-tools/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/combos/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/costs/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/endpoint/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/health/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/limits/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/logs/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/mcp/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/media/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/onboarding/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/playground/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/profile/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/providers/[id]/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/providers/new/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/providers/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/settings/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/settings/pricing/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/translator/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/usage/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/.well-known/agent.json/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/400/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/401/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/403/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/408/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/429/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/500/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/502/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/503/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/_global-error.html +2 -2
- package/app/.next/server/app/_global-error.rsc +1 -1
- package/app/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/app/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
- package/app/.next/server/app/_global-error.segments/_global-error.segment.rsc +1 -1
- package/app/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
- package/app/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
- package/app/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/app/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/a2a/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/a2a/status/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/a2a/tasks/[id]/cancel/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/a2a/tasks/[id]/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/a2a/tasks/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/acp/agents/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/auth/login/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/auth/logout/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/auth/status/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/cache/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/cache/stats/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/cli-tools/antigravity-mitm/alias/route.js +2 -2
- package/app/.next/server/app/api/cli-tools/antigravity-mitm/alias/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/cli-tools/antigravity-mitm/route.js +2 -2
- package/app/.next/server/app/api/cli-tools/antigravity-mitm/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/cli-tools/backups/route.js +1 -1
- package/app/.next/server/app/api/cli-tools/backups/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/cli-tools/claude-settings/route.js +2 -2
- package/app/.next/server/app/api/cli-tools/claude-settings/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/cli-tools/cline-settings/route.js +1 -1
- package/app/.next/server/app/api/cli-tools/cline-settings/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/cli-tools/codex-profiles/route.js +2 -2
- package/app/.next/server/app/api/cli-tools/codex-profiles/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/cli-tools/codex-settings/route.js +2 -2
- package/app/.next/server/app/api/cli-tools/codex-settings/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/cli-tools/droid-settings/route.js +1 -1
- package/app/.next/server/app/api/cli-tools/droid-settings/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/cli-tools/guide-settings/[toolId]/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/cli-tools/kilo-settings/route.js +1 -1
- package/app/.next/server/app/api/cli-tools/kilo-settings/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/cli-tools/openclaw/auto-order/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/cli-tools/openclaw-settings/route.js +2 -2
- package/app/.next/server/app/api/cli-tools/openclaw-settings/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/cli-tools/runtime/[toolId]/route.js +2 -2
- package/app/.next/server/app/api/cli-tools/runtime/[toolId]/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/cli-tools/status/route.js +1 -1
- package/app/.next/server/app/api/cli-tools/status/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/cloud/auth/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/cloud/credentials/update/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/cloud/model/resolve/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/cloud/models/alias/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/combos/[id]/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/combos/auto/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/combos/metrics/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/combos/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/combos/test/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/compliance/audit-log/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/db-backups/export/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/db-backups/exportAll/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/db-backups/import/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/db-backups/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/evals/[suiteId]/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/evals/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/fallback/chains/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/init/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/keys/[id]/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/keys/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/logs/console/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/mcp/audit/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/mcp/audit/stats/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/mcp/sse/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/mcp/status/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/mcp/stream/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/mcp/tools/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/models/alias/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/models/availability/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/models/catalog/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/models/openrouter-catalog/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/models/route.js +1 -1
- package/app/.next/server/app/api/models/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/monitoring/health/route.js +1 -1
- package/app/.next/server/app/api/monitoring/health/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/oauth/[provider]/[action]/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/oauth/cursor/auto-import/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/oauth/cursor/import/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/oauth/kiro/auto-import/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/oauth/kiro/import/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/oauth/kiro/social-authorize/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/oauth/kiro/social-exchange/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/policies/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/pricing/defaults/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/pricing/models/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/pricing/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/provider-metrics/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/provider-models/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/provider-nodes/[id]/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/provider-nodes/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/provider-nodes/validate/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/providers/[id]/models/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/providers/[id]/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/providers/[id]/test/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/providers/client/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/providers/route.js +1 -1
- package/app/.next/server/app/api/providers/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/providers/test-batch/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/providers/validate/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/rate-limit/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/rate-limits/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/resilience/reset/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/resilience/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/restart/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/sessions/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/settings/background-degradation/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/settings/combo-defaults/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/settings/ip-filter/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/settings/model-aliases/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/settings/proxy/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/settings/proxy/test/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/settings/require-login/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/settings/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/settings/system-prompt/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/settings/thinking-budget/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/shutdown/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/storage/health/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/sync/cloud/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/sync/initialize/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/tags/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/telemetry/summary/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/token-health/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/translator/detect/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/translator/history/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/translator/load/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/translator/save/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/translator/send/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/translator/translate/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/usage/[connectionId]/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/usage/analytics/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/usage/budget/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/usage/call-logs/[id]/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/usage/call-logs/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/usage/history/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/usage/logs/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/usage/proxy-logs/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/usage/quota/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/usage/request-logs/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/v1/api/chat/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/v1/audio/speech/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/v1/audio/transcriptions/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/v1/chat/completions/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/v1/embeddings/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/v1/images/generations/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/v1/messages/count_tokens/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/v1/messages/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/v1/models/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/v1/moderations/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/v1/music/generations/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/v1/providers/[provider]/chat/completions/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/v1/providers/[provider]/embeddings/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/v1/providers/[provider]/images/generations/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/v1/rerank/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/v1/responses/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/v1/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/v1/videos/generations/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/v1beta/models/[...path]/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/v1beta/models/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/callback/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/docs/page.js +1 -1
- package/app/.next/server/app/docs/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/forbidden/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/forgot-password/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/landing/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/login/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/maintenance/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/offline/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/privacy/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/status/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/terms/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app-paths-manifest.json +38 -38
- package/app/.next/server/chunks/2767.js +2 -2
- package/app/.next/server/chunks/3596.js +1 -1
- package/app/.next/server/chunks/3648.js +1 -1
- package/app/.next/server/chunks/3922.js +1 -1
- package/app/.next/server/chunks/7544.js +1 -1
- package/app/.next/server/chunks/7669.js +1 -1
- package/app/.next/server/chunks/786.js +1 -1
- package/app/.next/server/chunks/7889.js +1 -1
- package/app/.next/server/chunks/8907.js +1 -1
- package/app/.next/server/instrumentation.js +1 -1
- package/app/.next/server/middleware.js +1 -1
- package/app/.next/server/pages/500.html +2 -2
- package/app/.next/server/server-reference-manifest.js +1 -1
- package/app/.next/server/server-reference-manifest.json +1 -1
- package/app/.next/static/chunks/5846-84577ede994ae924.js +2 -0
- package/app/.next/static/chunks/{647-f03a498577a57cbc.js → 647-fc2670cfd0a58a58.js} +1 -1
- package/app/package.json +2 -1
- package/bin/omniroute.mjs +12 -21
- package/package.json +2 -1
- package/scripts/native-binary-compat.mjs +163 -0
- package/scripts/postinstall.mjs +77 -43
- package/app/.next/static/chunks/5846-72235a59cf209a08.js +0 -2
- /package/app/.next/static/{gBOP3qQEjwMgOGHsaEdmb → 7FD4jyAisteodGBKMWbqD}/_buildManifest.js +0 -0
- /package/app/.next/static/{gBOP3qQEjwMgOGHsaEdmb → 7FD4jyAisteodGBKMWbqD}/_ssgManifest.js +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";exports.id=786,exports.ids=[786,2180],exports.modules={786:(a,b,c)=>{let d,e;c.d(b,{startBackgroundRefresh:()=>av});var f=c(29021),g=c(33873);let h=["clientId","clientSecret","tokenUrl","authUrl","refreshUrl"],i=0,j=null;var k=c(84335);parseInt(process.env.FETCH_TIMEOUT_MS||"120000",10),parseInt(process.env.STREAM_IDLE_TIMEOUT_MS||"60000",10);let l=(0,k.Z0)();!function(a){let b;if(j&&Date.now()-i<6e4)return;let c=(b=process.env.DATA_DIR||(0,g.join)(process.cwd(),"data"),(0,g.join)(b,"provider-credentials.json"));if(!(0,f.existsSync)(c))return j||console.log("[CREDENTIALS] No external credentials file found, using defaults."),j=a,i=Date.now();try{let b=(0,f.readFileSync)(c,"utf-8"),d=JSON.parse(b),e=0;for(let[b,c]of Object.entries(d)){if(!a[b]){console.log(`[CREDENTIALS] Warning: unknown provider "${b}" in credentials file, skipping.`);continue}if(!c||"object"!=typeof c){console.log(`[CREDENTIALS] Warning: provider "${b}" value must be an object, got ${typeof c}. Skipping.`);continue}for(let d of h)void 0!==c[d]&&(a[b][d]=c[d],e++)}let g=null!==j;console.log(`[CREDENTIALS] ${g?"Reloaded":"Loaded"} external credentials: ${e} field(s) from ${c}`)}catch(a){console.log(`[CREDENTIALS] Error reading credentials file: ${a.message}. Using defaults.`)}j=a,i=Date.now()}(l);function m(a){return"number"==typeof a&&isFinite(a)?a:void 0}let n={quotaApiUrl:"https://cloudcode-pa.googleapis.com/v1internal:fetchAvailableModels",loadProjectApiUrl:"https://cloudcode-pa.googleapis.com/v1internal:loadCodeAssist",tokenUrl:"https://oauth2.googleapis.com/token",get clientId(){return l.antigravity.clientId},get clientSecret(){return l.antigravity.clientSecret},userAgent:"antigravity/1.11.3 Darwin/arm64"},o="2023-06-01";function p(a){return a&&"object"==typeof a&&!Array.isArray(a)?a:{}}function q(a,b=0){let c="number"==typeof a?a:"string"==typeof a&&a.trim().length>0?Number(a):NaN;return Number.isFinite(c)?c:b}function r(a,b,c){let d=p(a);return d[b]??d[c]??null}async function s(a){let{provider:b,accessToken:c,providerSpecificData:d}=a;switch(b){case"github":return await u(c,d);case"gemini-cli":return await w(c);case"antigravity":return await y(c,void 0);case"claude":return await B(c);case"codex":return await D(c,d);case"kiro":return await E(c,d);case"kimi-coding":return await G(c);case"qwen":return await H(c,d);case"iflow":return await I(c);default:return{message:`Usage API not implemented for ${b}`}}}function t(a){if(!a)return null;try{if(a instanceof Date)return a.toISOString();if("number"==typeof a||"string"==typeof a)return new Date(a).toISOString();return null}catch(b){return console.warn(`Failed to parse reset time: ${a}`,b),null}}async function u(a,b){try{if(!a)throw Error("No GitHub access token available. Please re-authorize the connection.");let b=await fetch("https://api.github.com/copilot_internal/user",{headers:{Authorization:`token ${a}`,Accept:"application/json","X-GitHub-Api-Version":"2022-11-28","User-Agent":"GitHubCopilotChat/0.26.7","Editor-Version":"vscode/1.100.0","Editor-Plugin-Version":"copilot-chat/0.26.7"}});if(!b.ok){let a=await b.text();throw Error(`GitHub API error: ${a}`)}let c=await b.json();if(c.quota_snapshots){let a=c.quota_snapshots,b=t(c.quota_reset_date);return{plan:c.copilot_plan,resetDate:c.quota_reset_date,quotas:{chat:{...v(a.chat),resetAt:b},completions:{...v(a.completions),resetAt:b},premium_interactions:{...v(a.premium_interactions),resetAt:b}}}}if(c.monthly_quotas||c.limited_user_quotas){let a=c.monthly_quotas||{},b=c.limited_user_quotas||{},d=t(c.limited_user_reset_date);return{plan:c.copilot_plan||c.access_type_sku,resetDate:c.limited_user_reset_date,quotas:{chat:{used:b.chat||0,total:a.chat||0,unlimited:!1,resetAt:d},completions:{used:b.completions||0,total:a.completions||0,unlimited:!1,resetAt:d}}}}return{message:"GitHub Copilot connected. Unable to parse quota data."}}catch(a){throw Error(`Failed to fetch GitHub usage: ${a.message}`)}}function v(a){return a?{used:a.entitlement-a.remaining,total:a.entitlement,remaining:a.remaining,unlimited:a.unlimited||!1}:{used:0,total:0,unlimited:!0}}async function w(a){try{if(!(await fetch("https://cloudresourcemanager.googleapis.com/v1/projects?filter=lifecycleState:ACTIVE",{headers:{Authorization:`Bearer ${a}`,Accept:"application/json"}})).ok)return{message:"Gemini CLI uses Google Cloud quotas. Check Google Cloud Console for details."};return{message:"Gemini CLI connected. Usage tracked via Google Cloud Console."}}catch(a){return{message:"Unable to fetch Gemini usage. Check Google Cloud Console."}}}let x=new Map;async function y(a,b){try{let b=await z(a),c=b?.cloudaicompanionProject||null,d=await fetch(n.quotaApiUrl,{method:"POST",headers:{Authorization:`Bearer ${a}`,"User-Agent":n.userAgent,"Content-Type":"application/json"},body:JSON.stringify(c?{project:c}:{})});if(403===d.status)return{message:"Antigravity access forbidden. Check subscription."};if(!d.ok)throw Error(`Antigravity API error: ${d.status}`);let e=await d.json(),f=p(e),g=p(f.models),h={};if(Object.keys(g).length>0){let a=["claude-opus-4-6-thinking","claude-sonnet-4-6","gemini-3.1-pro-high","gemini-3.1-pro-low","gemini-3-flash","gpt-oss-120b-medium"];for(let[b,c]of Object.entries(g)){let d=p(c),e=p(d.quotaInfo);if(0===Object.keys(e).length||!0===d.isInternal||!a.includes(b))continue;let f=q(e.remainingFraction,0),g=100*f,i=Math.round(1e3*f),j=1e3-i;h[b]={used:j,total:1e3,resetAt:t(e.resetTime),remainingPercentage:g,unlimited:!1,displayName:"string"==typeof d.displayName?d.displayName:b}}}return{plan:function(a){if(!a||0===Object.keys(a).length)return"Free";let b="";if(Array.isArray(a.allowedTiers)){for(let c of a.allowedTiers)if(c.isDefault&&c.id){b=c.id.trim().toUpperCase();break}}if(b||(b=(a.currentTier?.id||"").toUpperCase()),b){if(b.includes("ULTRA"))return"Ultra";if(b.includes("PRO"))return"Pro";if(b.includes("ENTERPRISE"))return"Enterprise";if(b.includes("BUSINESS")||b.includes("STANDARD"))return"Business";if(b.includes("FREE")||b.includes("INDIVIDUAL")||b.includes("LEGACY"))return"Free"}let c=a.currentTier?.name||a.currentTier?.displayName||a.subscriptionType||a.tier||"",d=c.toUpperCase();return d.includes("ULTRA")?"Ultra":d.includes("PRO")?"Pro":d.includes("ENTERPRISE")?"Enterprise":d.includes("STANDARD")||d.includes("BUSINESS")?"Business":d.includes("INDIVIDUAL")||d.includes("FREE")||a.currentTier?.upgradeSubscriptionType?"Free":c?c.charAt(0).toUpperCase()+c.slice(1).toLowerCase():"Free"}(b),quotas:h,subscriptionInfo:b}}catch(a){return{message:`Antigravity error: ${a.message}`}}}async function z(a){let b=a.substring(0,16),c=x.get(b);if(c&&Date.now()-c.fetchedAt<3e5)return c.data;let d=await A(a);return x.set(b,{data:d,fetchedAt:Date.now()}),d}async function A(a){try{let b=await fetch(n.loadProjectApiUrl,{method:"POST",headers:{Authorization:`Bearer ${a}`,"Content-Type":"application/json","User-Agent":"google-api-nodejs-client/9.15.1","X-Goog-Api-Client":"google-cloud-sdk vscode_cloudshelleditor/0.1","Client-Metadata":JSON.stringify({ideType:"IDE_UNSPECIFIED",platform:"PLATFORM_UNSPECIFIED",pluginType:"GEMINI"})},body:JSON.stringify({metadata:{ideType:"IDE_UNSPECIFIED",platform:"PLATFORM_UNSPECIFIED",pluginType:"GEMINI"}})});if(!b.ok)return null;return await b.json()}catch{return null}}async function B(a){try{let b=await fetch("https://api.anthropic.com/api/oauth/usage",{method:"GET",headers:{Authorization:`Bearer ${a}`,"anthropic-beta":"oauth-2025-04-20","anthropic-version":o}});if(b.ok){let a=await b.json(),c={},d=a=>a&&"object"==typeof a&&void 0!==m(a.utilization),e=a=>{let b=m(a.utilization),c=Math.max(0,100-b);return{used:b,total:100,remaining:c,resetAt:t(a.resets_at),remainingPercentage:c,unlimited:!1}};for(let[b,f]of(d(a.five_hour)&&(c["session (5h)"]=e(a.five_hour)),d(a.seven_day)&&(c["weekly (7d)"]=e(a.seven_day)),Object.entries(a))){let a=p(f);if(b.startsWith("seven_day_")&&"seven_day"!==b&&d(a)){let d=b.replace("seven_day_","");c[`weekly ${d} (7d)`]=e(a)}}return{plan:"Claude Code",quotas:c,extraUsage:a.extra_usage??null}}return console.warn(`[Claude Usage] OAuth endpoint returned ${b.status}, falling back to legacy`),await C(a)}catch(a){return{message:`Claude connected. Unable to fetch usage: ${a.message}`}}}async function C(a){try{let b=await fetch("https://api.anthropic.com/v1/settings",{method:"GET",headers:{Authorization:`Bearer ${a}`,"anthropic-version":o}});if(b.ok){let c=await b.json();if(c.organization_id){let b=await fetch("https://api.anthropic.com/v1/organizations/{org_id}/usage".replace("{org_id}",c.organization_id),{method:"GET",headers:{Authorization:`Bearer ${a}`,"anthropic-version":o}});if(b.ok){let a=await b.json();return{plan:c.plan||"Unknown",organization:c.organization_name,quotas:a}}}return{plan:c.plan||"Unknown",organization:c.organization_name,message:"Claude connected. Usage details require admin access."}}return{message:"Claude connected. Usage API requires admin permissions."}}catch(a){return{message:`Claude connected. Unable to fetch usage: ${a.message}`}}}async function D(a,b={}){try{let c="string"==typeof b.workspaceId?b.workspaceId:null,d={Authorization:`Bearer ${a}`,"Content-Type":"application/json",Accept:"application/json"};c&&(d["chatgpt-account-id"]=c);let e=await fetch("https://chatgpt.com/backend-api/wham/usage",{method:"GET",headers:d});if(!e.ok)throw Error(`Codex API error: ${e.status}`);let f=await e.json(),g=p(r(f,"rate_limit","rateLimit")),h=p(r(g,"primary_window","primaryWindow")),i=p(r(g,"secondary_window","secondaryWindow")),j=a=>{let b=q(r(a,"reset_at","resetAt"),0),c=q(r(a,"reset_after_seconds","resetAfterSeconds"),0);return b>0?t(1e3*b):c>0?t(Date.now()+1e3*c):null},k={};if(Object.keys(h).length>0){let a=q(r(h,"used_percent","usedPercent"),0);k.session={used:a,total:100,remaining:100-a,resetAt:j(h),unlimited:!1}}if(Object.keys(i).length>0){let a=q(r(i,"used_percent","usedPercent"),0);k.weekly={used:a,total:100,remaining:100-a,resetAt:j(i),unlimited:!1}}let l=p(r(f,"code_review_rate_limit","codeReviewRateLimit")),m=p(r(l,"primary_window","primaryWindow")),n=r(m,"used_percent","usedPercent"),o=r(m,"remaining_count","remainingCount");if(null!==n||null!==o){let a=q(n,0);k.code_review={used:a,total:100,remaining:100-a,resetAt:j(m),unlimited:!1}}return{plan:String(r(f,"plan_type","planType")||"unknown"),limitReached:!!r(g,"limit_reached","limitReached"),quotas:k}}catch(a){throw Error(`Failed to fetch Codex usage: ${a.message}`)}}async function E(a,b){try{let c=b?.profileArn;if(!c)return{message:"Kiro connected. Profile ARN not available for quota tracking."};let d=await fetch("https://codewhisperer.us-east-1.amazonaws.com",{method:"POST",headers:{Authorization:`Bearer ${a}`,"Content-Type":"application/x-amz-json-1.0","x-amz-target":"AmazonCodeWhispererService.GetUsageLimits",Accept:"application/json"},body:JSON.stringify({origin:"AI_EDITOR",profileArn:c,resourceType:"AGENTIC_REQUEST"})});if(!d.ok){let a=await d.text();throw Error(`Kiro API error (${d.status}): ${a}`)}let e=await d.json(),f=e.usageBreakdownList||[],g={},h=t(e.nextDateReset||e.resetDate);return f.forEach(a=>{let b=a.resourceType?.toLowerCase()||"unknown",c=a.currentUsageWithPrecision||0,d=a.usageLimitWithPrecision||0;if(g[b]={used:c,total:d,remaining:d-c,resetAt:h,unlimited:!1},a.freeTrialInfo){let c=a.freeTrialInfo.currentUsageWithPrecision||0,d=a.freeTrialInfo.usageLimitWithPrecision||0;g[`${b}_freetrial`]={used:c,total:d,remaining:d-c,resetAt:h,unlimited:!1}}}),{plan:e.subscriptionInfo?.subscriptionTitle||"Kiro",quotas:g}}catch(a){throw Error(`Failed to fetch Kiro usage: ${a.message}`)}}function F(a){return a?({LEVEL_BASIC:"Moderato",LEVEL_INTERMEDIATE:"Allegretto",LEVEL_ADVANCED:"Allegro",LEVEL_STANDARD:"Vivace"})[a]||a.replace("LEVEL_","").toLowerCase():""}async function G(a){let b="kimi-usage-"+Date.now(),c="u">typeof process?`${process.platform} ${process.arch}`:"unknown";try{let d,e=await fetch("https://api.kimi.com/coding/v1/usages",{method:"GET",headers:{Authorization:`Bearer ${a}`,"Content-Type":"application/json","X-Msh-Platform":"omniroute","X-Msh-Version":"2.1.2","X-Msh-Device-Model":c,"X-Msh-Device-Id":b}}),f=await e.text();if(!e.ok)return{plan:"Kimi Coding",message:`Kimi Coding connected. API Error ${e.status}: ${f.slice(0,100)}`};try{d=JSON.parse(f)}catch{return{plan:"Kimi Coding",message:"Kimi Coding connected. Invalid JSON response from API."}}let g={},h=p(d),i=p(h.usage),j=q(i.limit||i.Limit,0),k=q(i.used||i.Used,0),l=q(i.remaining||i.Remaining,0),n=i.resetTime||i.ResetTime||i.reset_at||i.resetAt;j>0&&(g.Weekly={used:k,total:j,remaining:l,remainingPercentage:j>0?l/j*100:0,resetAt:t(n),unlimited:!1});let o=Array.isArray(h.limits)?h.limits:[];for(let a=0;a<o.length;a++){let b=p(o[a]);p(b.window);let c=p(b.detail),d=q(c.limit||c.Limit,0),e=q(c.remaining||c.Remaining,0),f=c.resetTime||c.reset_at||c.resetAt;d>0&&(g.Ratelimit={used:d-e,total:d,remaining:e,remainingPercentage:d>0?e/d*100:0,resetAt:t(f),unlimited:!1})}let r=a=>a&&"object"==typeof a&&void 0!==m(a.utilization),s=a=>{let b=m(a.utilization);return{used:100-b,total:100,remaining:b,resetAt:t(a.resets_at),remainingPercentage:b,unlimited:!1}};for(let[a,b]of(r(h.five_hour)&&(g["session (5h)"]=s(h.five_hour)),r(h.seven_day)&&(g["weekly (7d)"]=s(h.seven_day)),Object.entries(h))){let c=p(b);if(a.startsWith("seven_day_")&&"seven_day"!==a&&r(c)){let b=a.replace("seven_day_","");g[`weekly ${b} (7d)`]=s(c)}}if(Object.keys(g).length>0){let a=h.user?.membership?.level;return{plan:F(a)||"Kimi Coding",quotas:g}}let u=h.user?.membership?.level;return{plan:F(u)||"Kimi Coding",message:"Kimi Coding connected. Usage tracked per request."}}catch(a){return{message:`Kimi Coding connected. Unable to fetch usage: ${a.message}`}}}async function H(a,b){try{if(!b?.resourceUrl)return{message:"Qwen connected. No resource URL available."};return{message:"Qwen connected. Usage tracked per request."}}catch(a){return{message:"Unable to fetch Qwen usage."}}}async function I(a){try{return{message:"iFlow connected. Usage tracked per request."}}catch(a){return{message:"Unable to fetch iFlow usage."}}}var J=c(44488);c(15367);var K=c(55511);let L="enc:v1:",M=null;function N(a){if(!a||"string"!=typeof a||!a.startsWith(L))return a;let b=function(){if(null!==M)return M;let a=process.env.STORAGE_ENCRYPTION_KEY;return a?M=(0,K.scryptSync)(a,"omniroute-field-encryption-v1",32):null}();if(!b)return console.warn("[Encryption] Found encrypted data but STORAGE_ENCRYPTION_KEY is not set. Cannot decrypt."),a;let c=a.slice(L.length).split(":");if(3!==c.length)return console.error("[Encryption] Malformed encrypted value"),a;let[d,e,f]=c;try{let a=Buffer.from(d,"hex"),c=Buffer.from(f,"hex"),g=(0,K.createDecipheriv)("aes-256-gcm",b,a);g.setAuthTag(c);let h=g.update(e,"hex","utf8");return h+=g.final("utf8")}catch(b){return console.error("[Encryption] Decryption failed:",b instanceof Error?b.message:String(b)),a}}async function O(a){var b;let c=(0,J.getDbInstance)().prepare("SELECT * FROM provider_connections WHERE id = ?").get(a);return c?(b=(0,J.G6)((0,J.kB)(c)))&&process.env.STORAGE_ENCRYPTION_KEY?{...b,apiKey:N(b.apiKey),accessToken:N(b.accessToken),refreshToken:N(b.refreshToken),idToken:N(b.idToken)}:b:null}var P=c(94781);c(82180);let Q=new Map,R=new Map,S=new Map,T=new Map;(0,P.D)(function(){Q.clear(),R.clear(),T.clear(),T.clear(),S.clear()});var U=c(13922),V=c(16698),W=c(3433),X=c(37481);let Y=Symbol.for("omniroute.proxyDispatcher.cache"),Z=new Set(["http:","https:","socks5:"]);function $(a){try{let b=a.match(/:\/\/(?:[^@]*@)?[^:/\s]+:(\d+)/);if(b){let a=Number(b[1]);if(Number.isInteger(a)&&a>=1&&a<=65535)return String(a)}}catch{}return null}function _(a){return"https:"===a||"wss:"===a?"443":"socks5:"===a?"1080":"8080"}function aa(a,b){if(!a)return _(b);let c=Number(a);if(!Number.isInteger(c)||c<1||c>65535)throw Error("[ProxyDispatcher] Invalid proxy port");return String(c)}function ab(){return"true"===process.env.ENABLE_SOCKS5_PROXY}function ac(a,b="proxy",{allowSocks5:c=ab()}={}){var d;let e,f,g=$(a);try{e=new URL(a)}catch{throw Error(`[ProxyDispatcher] Invalid ${b} URL`)}if(!Z.has(e.protocol))throw Error(`[ProxyDispatcher] Unsupported ${b} protocol: ${e.protocol.replace(":","")}`);if("socks5:"===e.protocol&&!c)throw Error("[ProxyDispatcher] SOCKS5 proxy is disabled (set ENABLE_SOCKS5_PROXY=true to enable)");if(!e.hostname)throw Error(`[ProxyDispatcher] Invalid ${b} host`);let h=g||aa(e.port,e.protocol);return f=(d=e).username?`${d.username}${d.password?`:${d.password}`:""}@`:"",`${d.protocol}//${f}${d.hostname}:${h}`}function ad(a,{allowSocks5:b=ab()}={}){if(!a)return null;if("string"==typeof a)return ac(a,"context proxy",{allowSocks5:b});if("object"!=typeof a||Array.isArray(a))throw Error("[ProxyDispatcher] Invalid context proxy config");let c=String(a.type||"http").toLowerCase(),d=`${c}:`;if(!Z.has(d))throw Error(`[ProxyDispatcher] Unsupported context proxy protocol: ${c}`);if("socks5:"===d&&!b)throw Error("[ProxyDispatcher] SOCKS5 proxy is disabled (set ENABLE_SOCKS5_PROXY=true to enable)");if(!a.host)throw Error("[ProxyDispatcher] Context proxy host is required");let e=aa(a.port,d),f=a.username?`${encodeURIComponent(a.username)}:${a.password?encodeURIComponent(a.password):""}@`:"";return ac(`${c}://${f}${a.host}:${e}`,"context proxy",{allowSocks5:b})}try{let a=c(17181);d="function"==typeof a.createSession?a.createSession:null}catch{d=null}class ae{constructor(){this.session=null,this.available=!!d}async getSession(){if(!this.available)return null;if(this.session)return this.session;let a=process.env.HTTPS_PROXY||process.env.https_proxy||process.env.HTTP_PROXY||process.env.http_proxy||process.env.ALL_PROXY||process.env.all_proxy||void 0,b={browser:"chrome_124",os:"macos"};return a&&(b.proxy=a,console.log(`[TlsClient] Using proxy: ${a}`)),this.session=await d(b),console.log("[TlsClient] Session created (Chrome 124 TLS fingerprint)"),this.session}async fetch(a,b={}){let c=await this.getSession();if(!c)throw Error("wreq-js not available");let d={method:(b.method||"GET").toUpperCase(),headers:function(a){if(!a)return;if(a instanceof Headers)return Object.fromEntries(a.entries());if(Array.isArray(a))return Object.fromEntries(a.map(([a,b])=>[a,String(b)]));let b={};for(let[c,d]of Object.entries(a))"string"==typeof d&&(b[c]=d);return b}(b.headers),body:b.body,redirect:"manual"===b.redirect?"manual":"follow"};return b.signal&&(d.signal=b.signal),await c.fetch(a,d)}async exit(){this.session&&(await this.session.close(),this.session=null)}}let af=new ae,ag=new V.AsyncLocalStorage,ah="u">typeof caches&&"object"==typeof caches,ai=Symbol.for("omniroute.proxyFetch.state"),aj=((e=globalThis)[ai]||(e[ai]={originalFetch:globalThis.fetch,proxyContext:new V.AsyncLocalStorage,isPatched:!1}),e[ai]),ak=aj.originalFetch,al=aj.proxyContext;async function am(a,b){if("function"!=typeof b)throw TypeError("runWithProxyContext requires a callback function");let c=a?ad(a):null;return al.run(a||null,async()=>{let a,d,e;return c&&console.log(`[ProxyFetch] Applied request proxy context: ${(a=$(c),d=new URL(c),e=a||d.port||_(d.protocol),`${d.protocol}//${d.hostname}:${e}`)}`),b()})}async function an(a,b={}){let c;if(b?.dispatcher)return ak(a,b);let d="string"==typeof a?a:a&&"string"==typeof a.url?a.url:String(a);try{c=function(a){let b=al.getStore();if(b)return{source:"context",proxyUrl:ad(b)};let c=function(a){let b;if(function(a){let b,c=process.env.NO_PROXY||process.env.no_proxy;if(!c)return!1;try{b=new URL(a)}catch{return!1}let d=b.hostname.toLowerCase(),e=b.port||("https:"===b.protocol?"443":"80");return c.split(",").map(a=>a.trim().toLowerCase()).filter(Boolean).some(a=>{if("*"===a)return!0;let[b,c]=a.split(":");return(!c||c===e)&&!!b&&(b.startsWith(".")?d.endsWith(b)||d===b.slice(1):d===b||d.endsWith(`.${b}`))})}(a))return null;try{b=new URL(a).protocol}catch{return null}let c="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;return c?ac(c,"environment proxy"):null}(a);return c?{source:"env",proxyUrl:c}:{source:"direct",proxyUrl:null}}(d)}catch(b){let a=b instanceof Error?b.message:String(b);throw console.error(`[ProxyFetch] Proxy configuration error: ${a}`),b}let{source:e,proxyUrl:f}=c;if(!f){if("true"===process.env.ENABLE_TLS_FINGERPRINT&&af.available)try{let a=ag.getStore();return a&&(a.used=!0),await af.fetch(d,{...b,headers:b.headers})}catch(c){let a=c instanceof Error?c.message:String(c);console.warn(`[ProxyFetch] TLS fingerprint failed, falling back to native fetch: ${a}`);let b=ag.getStore();b&&(b.used=!1)}return ak(a,b)}try{let c=function(a){let b,c=ac(a,"proxy dispatcher"),d=((b=globalThis)[Y]||(b[Y]=new Map),b[Y]),e=d.get(c);if(e)return e;let f=new URL(c),g=$(c)||aa(f.port,f.protocol);if("socks5:"===f.protocol){let a={type:5,host:f.hostname,port:Number(g)};f.username&&(a.userId=decodeURIComponent(f.username)),f.password&&(a.password=decodeURIComponent(f.password)),e=(0,X.vI)(a)}else e=new W.ProxyAgent(c);return d.set(c,e),e}(f);return await ak(a,{...b,dispatcher:c})}catch(b){let a=b instanceof Error?b.message:String(b);throw console.error(`[ProxyFetch] Proxy request failed (${e}, fail-closed): ${a}`),b}}ah||aj.isPatched||(globalThis.fetch=an,aj.isPatched=!0);let ao=new Map,ap=null,aq=!1;function ar(a){let b=new Date(a).getTime();return Number.isNaN(b)?null:b}let as=new Set;async function at(a){if(!as.has(a.connectionId)){as.add(a.connectionId);try{var b,c,d;let e,f,g,h=await O(a.connectionId);if(!h||"oauth"!==h.authType||!h.isActive)return void ao.delete(a.connectionId);let i=await (0,U.YD)(a.connectionId),j=await am(i?.proxy||null,()=>s(h));j?.quotas&&(b=a.connectionId,c=a.provider,d=j.quotas,f=function(a){let b={};for(let[c,d]of Object.entries(a))d&&"object"==typeof d&&(b[c]={remainingPercentage:m(d.remainingPercentage)??(d.total>0?Math.round((d.total-(d.used||0))/d.total*100):0),resetAt:d.resetAt||null});return b}(d),g=(e=Object.values(f),0!==e.length&&e.every(a=>a.remainingPercentage<=0)),ao.set(b,{connectionId:b,provider:c,quotas:f,fetchedAt:Date.now(),exhausted:g,nextResetAt:g?function(a){let b=null,c=1/0;for(let d of Object.values(a)){if(!d.resetAt)continue;let a=ar(d.resetAt);null!==a&&a<c&&(c=a,b=d.resetAt)}return b}(f):null}))}catch(b){console.warn(`[QuotaCache] Refresh failed for ${a.connectionId.slice(0,8)}:`,b?.message||b)}finally{as.delete(a.connectionId)}}}async function au(){if(!aq){aq=!0;try{let a=Date.now(),b=[...ao.values()].filter(b=>(function(a,b){let c=b-a.fetchedAt;if(a.exhausted&&a.nextResetAt){let c=ar(a.nextResetAt);if(null!==c&&c<=b)return!0}return c>=3e5})(b,a));for(let a=0;a<b.length;a+=5){let c=b.slice(a,a+5);await Promise.allSettled(c.map(at))}}finally{aq=!1}}}function av(){ap||(ap=setInterval(au,6e4),ap?.unref?.())}},1303:function(a,b,c){var d=this&&this.__createBinding||(Object.create?function(a,b,c,d){void 0===d&&(d=c);var e=Object.getOwnPropertyDescriptor(b,c);(!e||("get"in e?!b.__esModule:e.writable||e.configurable))&&(e={enumerable:!0,get:function(){return b[c]}}),Object.defineProperty(a,d,e)}:function(a,b,c,d){void 0===d&&(d=c),a[d]=b[c]}),e=this&&this.__exportStar||function(a,b){for(var c in a)"default"===c||Object.prototype.hasOwnProperty.call(b,c)||d(b,a,c)};Object.defineProperty(b,"__esModule",{value:!0}),e(c(5355),b)},1712:(a,b,c)=>{let d=c(34589),{Readable:e}=c(57075),{RequestAbortedError:f,NotSupportedError:g,InvalidArgumentError:h,AbortError:i}=c(61448),j=c(84285),{ReadableStreamFrom:k}=c(84285),l=Symbol("kConsume"),m=Symbol("kReading"),n=Symbol("kBody"),o=Symbol("kAbort"),p=Symbol("kContentType"),q=Symbol("kContentLength"),r=Symbol("kUsed"),s=Symbol("kBytesRead"),t=()=>{};class u extends e{constructor({resume:a,abort:b,contentType:c="",contentLength:d,highWaterMark:e=65536}){super({autoDestroy:!0,read:a,highWaterMark:e}),this._readableState.dataEmitted=!1,this[o]=b,this[l]=null,this[s]=0,this[n]=null,this[r]=!1,this[p]=c,this[q]=Number.isFinite(d)?d:null,this[m]=!1}_destroy(a,b){a||this._readableState.endEmitted||(a=new f),a&&this[o](),this[r]?b(a):setImmediate(b,a)}on(a,b){return("data"===a||"readable"===a)&&(this[m]=!0,this[r]=!0),super.on(a,b)}addListener(a,b){return this.on(a,b)}off(a,b){let c=super.off(a,b);return("data"===a||"readable"===a)&&(this[m]=this.listenerCount("data")>0||this.listenerCount("readable")>0),c}removeListener(a,b){return this.off(a,b)}push(a){return a&&(this[s]+=a.length,this[l])?(z(this[l],a),!this[m]||super.push(a)):super.push(a)}text(){return v(this,"text")}json(){return v(this,"json")}blob(){return v(this,"blob")}bytes(){return v(this,"bytes")}arrayBuffer(){return v(this,"arrayBuffer")}async formData(){throw new g}get bodyUsed(){return j.isDisturbed(this)}get body(){return!this[n]&&(this[n]=k(this),this[l]&&(this[n].getReader(),d(this[n].locked))),this[n]}dump(a){let b=a?.signal;if(null!=b&&("object"!=typeof b||!("aborted"in b)))return Promise.reject(new h("signal must be an AbortSignal"));let c=a?.limit&&Number.isFinite(a.limit)?a.limit:131072;return b?.aborted?Promise.reject(b.reason??new i):this._readableState.closeEmitted?Promise.resolve(null):new Promise((a,d)=>{if((this[q]&&this[q]>c||this[s]>c)&&this.destroy(new i),b){let c=()=>{this.destroy(b.reason??new i)};b.addEventListener("abort",c),this.on("close",function(){b.removeEventListener("abort",c),b.aborted?d(b.reason??new i):a(null)})}else this.on("close",a);this.on("error",t).on("data",()=>{this[s]>c&&this.destroy()}).resume()})}setEncoding(a){return Buffer.isEncoding(a)&&(this._readableState.encoding=a),this}}function v(a,b){return d(!a[l]),new Promise((c,d)=>{if(j.isDisturbed(a)||a[n]?.locked===!0||null!==a[l]){let b=a._readableState;b.destroyed&&!1===b.closeEmitted?a.on("error",d).on("close",()=>{d(TypeError("unusable"))}):d(b.errored??TypeError("unusable"))}else queueMicrotask(()=>{a[l]={type:b,stream:a,resolve:c,reject:d,length:0,body:[]},a.on("error",function(a){A(this[l],a)}).on("close",function(){null!==this[l].body&&A(this[l],new f)}),function(a){if(null===a.body)return;let{_readableState:b}=a.stream;if(b.bufferIndex){let c=b.bufferIndex,d=b.buffer.length;for(let e=c;e<d;e++)z(a,b.buffer[e])}else for(let c of b.buffer)z(a,c);for(b.endEmitted?y(this[l],this._readableState.encoding):a.stream.on("end",function(){y(this[l],this._readableState.encoding)}),a.stream.resume();null!=a.stream.read(););}(a[l])})})}function w(a,b,c){if(0===a.length||0===b)return"";let d=1===a.length?a[0]:Buffer.concat(a,b),e=d.length,f=3*(e>2&&239===d[0]&&187===d[1]&&191===d[2]);return c&&"utf8"!==c&&"utf-8"!==c?d.subarray(f,e).toString(c):d.utf8Slice(f,e)}function x(a,b){if(0===a.length||0===b)return new Uint8Array(0);if(1===a.length)return new Uint8Array(a[0]);let c=new Uint8Array(Buffer.allocUnsafeSlow(b).buffer),d=0;for(let b=0;b<a.length;++b){let e=a[b];c.set(e,d),d+=e.length}return c}function y(a,b){let{type:c,body:d,resolve:e,stream:f,length:g}=a;try{"text"===c?e(w(d,g,b)):"json"===c?e(JSON.parse(w(d,g,b))):"arrayBuffer"===c?e(x(d,g).buffer):"blob"===c?e(new Blob(d,{type:f[p]})):"bytes"===c&&e(x(d,g)),A(a)}catch(a){f.destroy(a)}}function z(a,b){a.length+=b.length,a.body.push(b)}function A(a,b){null!==a.body&&(b?a.reject(b):a.resolve(),a.type=null,a.stream=null,a.resolve=null,a.reject=null,a.length=0,a.body=null)}a.exports={Readable:u,chunksDecode:w}},2721:(a,b)=>{Object.defineProperty(b,"__esModule",{value:!0}),b.isInSubnet=function(a){return!(this.subnetMask<a.subnetMask)&&this.mask(a.subnetMask)===a.mask()},b.isCorrect=function(a){return function(){return this.addressMinusSuffix===this.correctForm()&&(this.subnetMask===a&&!this.parsedSubnet||this.parsedSubnet===String(this.subnetMask))}},b.numberToPaddedHex=c,b.stringToPaddedHex=function(a){return c(parseInt(a,10))},b.testBit=function(a,b){let{length:c}=a;if(b>c)return!1;let d=c-b;return"1"===a.substring(d,d+1)};function c(a){return a.toString(16).padStart(2,"0")}},2887:(a,b,c)=>{let{iteratorMixin:d}=c(42425),{kEnumerableProperty:e}=c(84285),{webidl:f}=c(32984),g=c(57975);class h{#a=[];constructor(a){if(f.util.markAsUncloneable(this),void 0!==a)throw f.errors.conversionFailed({prefix:"FormData constructor",argument:"Argument 1",types:["undefined"]})}append(a,b,c){f.brandCheck(this,h);let d="FormData.append";f.argumentLengthCheck(arguments,2,d),a=f.converters.USVString(a),3==arguments.length||f.is.Blob(b)?(b=f.converters.Blob(b,d,"value"),void 0!==c&&(c=f.converters.USVString(c))):b=f.converters.USVString(b);let e=k(a,b,c);this.#a.push(e)}delete(a){f.brandCheck(this,h),f.argumentLengthCheck(arguments,1,"FormData.delete"),a=f.converters.USVString(a),this.#a=this.#a.filter(b=>b.name!==a)}get(a){f.brandCheck(this,h),f.argumentLengthCheck(arguments,1,"FormData.get"),a=f.converters.USVString(a);let b=this.#a.findIndex(b=>b.name===a);return -1===b?null:this.#a[b].value}getAll(a){return f.brandCheck(this,h),f.argumentLengthCheck(arguments,1,"FormData.getAll"),a=f.converters.USVString(a),this.#a.filter(b=>b.name===a).map(a=>a.value)}has(a){return f.brandCheck(this,h),f.argumentLengthCheck(arguments,1,"FormData.has"),a=f.converters.USVString(a),-1!==this.#a.findIndex(b=>b.name===a)}set(a,b,c){f.brandCheck(this,h);let d="FormData.set";f.argumentLengthCheck(arguments,2,d),a=f.converters.USVString(a),3==arguments.length||f.is.Blob(b)?(b=f.converters.Blob(b,d,"value"),void 0!==c&&(c=f.converters.USVString(c))):b=f.converters.USVString(b);let e=k(a,b,c),g=this.#a.findIndex(b=>b.name===a);-1!==g?this.#a=[...this.#a.slice(0,g),e,...this.#a.slice(g+1).filter(b=>b.name!==a)]:this.#a.push(e)}[g.inspect.custom](a,b){let c=this.#a.reduce((a,b)=>(a[b.name]?Array.isArray(a[b.name])?a[b.name].push(b.value):a[b.name]=[a[b.name],b.value]:a[b.name]=b.value,a),{__proto__:null});b.depth??=a,b.colors??=!0;let d=g.formatWithOptions(b,c);return`FormData ${d.slice(d.indexOf("]")+2)}`}static getFormDataState(a){return a.#a}static setFormDataState(a,b){a.#a=b}}let{getFormDataState:i,setFormDataState:j}=h;function k(a,b,c){if("string"==typeof b);else if(f.is.File(b)||(b=new File([b],"blob",{type:b.type})),void 0!==c){let a={type:b.type,lastModified:b.lastModified};b=new File([b],c,a)}return{name:a,value:b}}Reflect.deleteProperty(h,"getFormDataState"),Reflect.deleteProperty(h,"setFormDataState"),d("FormData",h,i,"name","value"),Object.defineProperties(h.prototype,{append:e,delete:e,get:e,getAll:e,has:e,set:e,[Symbol.toStringTag]:{value:"FormData",configurable:!0}}),f.is.FormData=f.util.MakeTypeAssertion(h),a.exports={FormData:h,makeEntry:k,setFormDataState:j}},3433:(a,b,c)=>{let d=c(40106),e=c(7344),f=c(35689),g=c(61330),h=c(34441),i=c(37417),j=c(48841),k=c(43086),l=c(95095),m=c(53552),n=c(61448),o=c(84285),{InvalidArgumentError:p}=n,q=c(99528),r=c(55285),s=c(66498),{MockCallHistory:t,MockCallHistoryLog:u}=c(43904),v=c(43249),w=c(86625),x=c(89512),y=c(28998),z=c(31825),{getGlobalDispatcher:A,setGlobalDispatcher:B}=c(59970),C=c(83204),D=c(67519);Object.assign(e.prototype,q),a.exports.Dispatcher=e,a.exports.Client=d,a.exports.Pool=f,a.exports.BalancedPool=g,a.exports.RoundRobinPool=h,a.exports.Agent=i,a.exports.ProxyAgent=j,a.exports.EnvHttpProxyAgent=k,a.exports.RetryAgent=l,a.exports.H2CClient=m,a.exports.RetryHandler=z,a.exports.DecoratorHandler=C,a.exports.RedirectHandler=D,a.exports.interceptors={redirect:c(70707),responseError:c(47335),retry:c(78075),dump:c(87085),dns:c(27060),cache:c(19431),decompress:c(37858),deduplicate:c(90249)},a.exports.cacheStores={MemoryCacheStore:c(38650)};let E=c(20579);function F(a){return(b,c,d)=>{if("function"==typeof c&&(d=c,c=null),!b||"string"!=typeof b&&"object"!=typeof b&&!(b instanceof URL))throw new p("invalid url");if(null!=c&&"object"!=typeof c)throw new p("invalid opts");if(c&&null!=c.path){if("string"!=typeof c.path)throw new p("invalid opts.path");let a=c.path;c.path.startsWith("/")||(a=`/${a}`),b=new URL(o.parseOrigin(b).origin+a)}else c||(c="object"==typeof b?b:{}),b=o.parseURL(b);let{agent:e,dispatcher:f=A()}=c;if(e)throw new p("unsupported opts.agent. Did you mean opts.client?");return a.call(f,{...c,origin:b.origin,path:b.search?`${b.pathname}${b.search}`:b.pathname,method:c.method||(c.body?"PUT":"GET")},d)}}a.exports.cacheStores.SqliteCacheStore=E,a.exports.buildConnector=r,a.exports.errors=n,a.exports.util={parseHeaders:o.parseHeaders,headerNameToString:o.headerNameToString},a.exports.setGlobalDispatcher=B,a.exports.getGlobalDispatcher=A;let G=c(76403).fetch,H=__filename;a.exports.fetch=function(b,c){return G(b,c).catch(b=>{throw H?!function a(b,c){if(!b||"object"!=typeof b)return;let d="string"==typeof b.stack?b.stack:"",e=c.replace(/\\/g,"/");if(d&&(d.includes(c)||d.includes(e)))return;let f={};if(Error.captureStackTrace(f,a),!f.stack)return;let g=f.stack.split("\n").slice(1).join("\n");b.stack=d?`${d}
|
|
1
|
+
"use strict";exports.id=786,exports.ids=[786,2180],exports.modules={786:(a,b,c)=>{let d,e;c.d(b,{startBackgroundRefresh:()=>av});var f=c(29021),g=c(33873);let h=["clientId","clientSecret","tokenUrl","authUrl","refreshUrl"],i=0,j=null;var k=c(84335);parseInt(process.env.FETCH_TIMEOUT_MS||"120000",10),parseInt(process.env.STREAM_IDLE_TIMEOUT_MS||"60000",10);let l=(0,k.Z0)();!function(a){let b;if(j&&Date.now()-i<6e4)return;let c=(b=process.env.DATA_DIR||(0,g.join)(process.cwd(),"data"),(0,g.join)(b,"provider-credentials.json"));if(!(0,f.existsSync)(c))return j||console.log("[CREDENTIALS] No external credentials file found, using defaults."),j=a,i=Date.now();try{let b=(0,f.readFileSync)(c,"utf-8"),d=JSON.parse(b),e=0;for(let[b,c]of Object.entries(d)){if(!a[b]){console.log(`[CREDENTIALS] Warning: unknown provider "${b}" in credentials file, skipping.`);continue}if(!c||"object"!=typeof c){console.log(`[CREDENTIALS] Warning: provider "${b}" value must be an object, got ${typeof c}. Skipping.`);continue}for(let d of h)void 0!==c[d]&&(a[b][d]=c[d],e++)}let g=null!==j;console.log(`[CREDENTIALS] ${g?"Reloaded":"Loaded"} external credentials: ${e} field(s) from ${c}`)}catch(a){console.log(`[CREDENTIALS] Error reading credentials file: ${a.message}. Using defaults.`)}j=a,i=Date.now()}(l);function m(a){return"number"==typeof a&&isFinite(a)?a:void 0}let n={quotaApiUrl:"https://cloudcode-pa.googleapis.com/v1internal:fetchAvailableModels",loadProjectApiUrl:"https://cloudcode-pa.googleapis.com/v1internal:loadCodeAssist",tokenUrl:"https://oauth2.googleapis.com/token",get clientId(){return l.antigravity.clientId},get clientSecret(){return l.antigravity.clientSecret},userAgent:"antigravity/1.11.3 Darwin/arm64"},o="2023-06-01";function p(a){return a&&"object"==typeof a&&!Array.isArray(a)?a:{}}function q(a,b=0){let c="number"==typeof a?a:"string"==typeof a&&a.trim().length>0?Number(a):NaN;return Number.isFinite(c)?c:b}function r(a,b,c){let d=p(a);return d[b]??d[c]??null}async function s(a){let{provider:b,accessToken:c,providerSpecificData:d}=a;switch(b){case"github":return await u(c,d);case"gemini-cli":return await w(c);case"antigravity":return await y(c,void 0);case"claude":return await B(c);case"codex":return await D(c,d);case"kiro":return await E(c,d);case"kimi-coding":return await G(c);case"qwen":return await H(c,d);case"iflow":return await I(c);default:return{message:`Usage API not implemented for ${b}`}}}function t(a){if(!a)return null;try{if(a instanceof Date)return a.toISOString();if("number"==typeof a||"string"==typeof a)return new Date(a).toISOString();return null}catch(b){return console.warn(`Failed to parse reset time: ${a}`,b),null}}async function u(a,b){try{if(!a)throw Error("No GitHub access token available. Please re-authorize the connection.");let b=await fetch("https://api.github.com/copilot_internal/user",{headers:{Authorization:`token ${a}`,Accept:"application/json","X-GitHub-Api-Version":"2022-11-28","User-Agent":"GitHubCopilotChat/0.26.7","Editor-Version":"vscode/1.100.0","Editor-Plugin-Version":"copilot-chat/0.26.7"}});if(!b.ok){let a=await b.text();throw Error(`GitHub API error: ${a}`)}let c=await b.json();if(c.quota_snapshots){let a=c.quota_snapshots,b=t(c.quota_reset_date);return{plan:c.copilot_plan,resetDate:c.quota_reset_date,quotas:{chat:{...v(a.chat),resetAt:b},completions:{...v(a.completions),resetAt:b},premium_interactions:{...v(a.premium_interactions),resetAt:b}}}}if(c.monthly_quotas||c.limited_user_quotas){let a=c.monthly_quotas||{},b=c.limited_user_quotas||{},d=t(c.limited_user_reset_date);return{plan:c.copilot_plan||c.access_type_sku,resetDate:c.limited_user_reset_date,quotas:{chat:{used:b.chat||0,total:a.chat||0,unlimited:!1,resetAt:d},completions:{used:b.completions||0,total:a.completions||0,unlimited:!1,resetAt:d}}}}return{message:"GitHub Copilot connected. Unable to parse quota data."}}catch(a){throw Error(`Failed to fetch GitHub usage: ${a.message}`)}}function v(a){return a?{used:a.entitlement-a.remaining,total:a.entitlement,remaining:a.remaining,unlimited:a.unlimited||!1}:{used:0,total:0,unlimited:!0}}async function w(a){try{if(!(await fetch("https://cloudresourcemanager.googleapis.com/v1/projects?filter=lifecycleState:ACTIVE",{headers:{Authorization:`Bearer ${a}`,Accept:"application/json"}})).ok)return{message:"Gemini CLI uses Google Cloud quotas. Check Google Cloud Console for details."};return{message:"Gemini CLI connected. Usage tracked via Google Cloud Console."}}catch(a){return{message:"Unable to fetch Gemini usage. Check Google Cloud Console."}}}let x=new Map;async function y(a,b){try{let b=await z(a),c=b?.cloudaicompanionProject||null,d=await fetch(n.quotaApiUrl,{method:"POST",headers:{Authorization:`Bearer ${a}`,"User-Agent":n.userAgent,"Content-Type":"application/json"},body:JSON.stringify(c?{project:c}:{})});if(403===d.status)return{message:"Antigravity access forbidden. Check subscription."};if(!d.ok)throw Error(`Antigravity API error: ${d.status}`);let e=await d.json(),f=p(e),g=p(f.models),h={};if(Object.keys(g).length>0){let a=["claude-opus-4-6-thinking","claude-sonnet-4-6","gemini-3.1-pro-high","gemini-3.1-pro-low","gemini-3-flash","gpt-oss-120b-medium"];for(let[b,c]of Object.entries(g)){let d=p(c),e=p(d.quotaInfo);if(0===Object.keys(e).length||!0===d.isInternal||!a.includes(b))continue;let f=q(e.remainingFraction,0),g=100*f,i=Math.round(1e3*f),j=1e3-i;h[b]={used:j,total:1e3,resetAt:t(e.resetTime),remainingPercentage:g,unlimited:!1,displayName:"string"==typeof d.displayName?d.displayName:b}}}return{plan:function(a){if(!a||0===Object.keys(a).length)return"Free";let b="";if(Array.isArray(a.allowedTiers)){for(let c of a.allowedTiers)if(c.isDefault&&c.id){b=c.id.trim().toUpperCase();break}}if(b||(b=(a.currentTier?.id||"").toUpperCase()),b){if(b.includes("ULTRA"))return"Ultra";if(b.includes("PRO"))return"Pro";if(b.includes("ENTERPRISE"))return"Enterprise";if(b.includes("BUSINESS")||b.includes("STANDARD"))return"Business";if(b.includes("FREE")||b.includes("INDIVIDUAL")||b.includes("LEGACY"))return"Free"}let c=a.currentTier?.name||a.currentTier?.displayName||a.subscriptionType||a.tier||"",d=c.toUpperCase();return d.includes("ULTRA")?"Ultra":d.includes("PRO")?"Pro":d.includes("ENTERPRISE")?"Enterprise":d.includes("STANDARD")||d.includes("BUSINESS")?"Business":d.includes("INDIVIDUAL")||d.includes("FREE")||a.currentTier?.upgradeSubscriptionType?"Free":c?c.charAt(0).toUpperCase()+c.slice(1).toLowerCase():"Free"}(b),quotas:h,subscriptionInfo:b}}catch(a){return{message:`Antigravity error: ${a.message}`}}}async function z(a){let b=a.substring(0,16),c=x.get(b);if(c&&Date.now()-c.fetchedAt<3e5)return c.data;let d=await A(a);return x.set(b,{data:d,fetchedAt:Date.now()}),d}async function A(a){try{let b=await fetch(n.loadProjectApiUrl,{method:"POST",headers:{Authorization:`Bearer ${a}`,"Content-Type":"application/json","User-Agent":"google-api-nodejs-client/9.15.1","X-Goog-Api-Client":"google-cloud-sdk vscode_cloudshelleditor/0.1","Client-Metadata":JSON.stringify({ideType:"IDE_UNSPECIFIED",platform:"PLATFORM_UNSPECIFIED",pluginType:"GEMINI"})},body:JSON.stringify({metadata:{ideType:"IDE_UNSPECIFIED",platform:"PLATFORM_UNSPECIFIED",pluginType:"GEMINI"}})});if(!b.ok)return null;return await b.json()}catch{return null}}async function B(a){try{let b=await fetch("https://api.anthropic.com/api/oauth/usage",{method:"GET",headers:{Authorization:`Bearer ${a}`,"anthropic-beta":"oauth-2025-04-20","anthropic-version":o}});if(b.ok){let a=await b.json(),c={},d=a=>a&&"object"==typeof a&&void 0!==m(a.utilization),e=a=>{let b=m(a.utilization),c=Math.max(0,100-b);return{used:b,total:100,remaining:c,resetAt:t(a.resets_at),remainingPercentage:c,unlimited:!1}};for(let[b,f]of(d(a.five_hour)&&(c["session (5h)"]=e(a.five_hour)),d(a.seven_day)&&(c["weekly (7d)"]=e(a.seven_day)),Object.entries(a))){let a=p(f);if(b.startsWith("seven_day_")&&"seven_day"!==b&&d(a)){let d=b.replace("seven_day_","");c[`weekly ${d} (7d)`]=e(a)}}return{plan:"Claude Code",quotas:c,extraUsage:a.extra_usage??null}}return console.warn(`[Claude Usage] OAuth endpoint returned ${b.status}, falling back to legacy`),await C(a)}catch(a){return{message:`Claude connected. Unable to fetch usage: ${a.message}`}}}async function C(a){try{let b=await fetch("https://api.anthropic.com/v1/settings",{method:"GET",headers:{Authorization:`Bearer ${a}`,"anthropic-version":o}});if(b.ok){let c=await b.json();if(c.organization_id){let b=await fetch("https://api.anthropic.com/v1/organizations/{org_id}/usage".replace("{org_id}",c.organization_id),{method:"GET",headers:{Authorization:`Bearer ${a}`,"anthropic-version":o}});if(b.ok){let a=await b.json();return{plan:c.plan||"Unknown",organization:c.organization_name,quotas:a}}}return{plan:c.plan||"Unknown",organization:c.organization_name,message:"Claude connected. Usage details require admin access."}}return{message:"Claude connected. Usage API requires admin permissions."}}catch(a){return{message:`Claude connected. Unable to fetch usage: ${a.message}`}}}async function D(a,b={}){try{let c="string"==typeof b.workspaceId?b.workspaceId:null,d={Authorization:`Bearer ${a}`,"Content-Type":"application/json",Accept:"application/json"};c&&(d["chatgpt-account-id"]=c);let e=await fetch("https://chatgpt.com/backend-api/wham/usage",{method:"GET",headers:d});if(!e.ok)throw Error(`Codex API error: ${e.status}`);let f=await e.json(),g=p(r(f,"rate_limit","rateLimit")),h=p(r(g,"primary_window","primaryWindow")),i=p(r(g,"secondary_window","secondaryWindow")),j=a=>{let b=q(r(a,"reset_at","resetAt"),0),c=q(r(a,"reset_after_seconds","resetAfterSeconds"),0);return b>0?t(1e3*b):c>0?t(Date.now()+1e3*c):null},k={};if(Object.keys(h).length>0){let a=q(r(h,"used_percent","usedPercent"),0);k.session={used:a,total:100,remaining:100-a,resetAt:j(h),unlimited:!1}}if(Object.keys(i).length>0){let a=q(r(i,"used_percent","usedPercent"),0);k.weekly={used:a,total:100,remaining:100-a,resetAt:j(i),unlimited:!1}}let l=p(r(f,"code_review_rate_limit","codeReviewRateLimit")),m=p(r(l,"primary_window","primaryWindow")),n=r(m,"used_percent","usedPercent"),o=r(m,"remaining_count","remainingCount");if(null!==n||null!==o){let a=q(n,0);k.code_review={used:a,total:100,remaining:100-a,resetAt:j(m),unlimited:!1}}return{plan:String(r(f,"plan_type","planType")||"unknown"),limitReached:!!r(g,"limit_reached","limitReached"),quotas:k}}catch(a){throw Error(`Failed to fetch Codex usage: ${a.message}`)}}async function E(a,b){try{let c=b?.profileArn;if(!c)return{message:"Kiro connected. Profile ARN not available for quota tracking."};let d=await fetch("https://codewhisperer.us-east-1.amazonaws.com",{method:"POST",headers:{Authorization:`Bearer ${a}`,"Content-Type":"application/x-amz-json-1.0","x-amz-target":"AmazonCodeWhispererService.GetUsageLimits",Accept:"application/json"},body:JSON.stringify({origin:"AI_EDITOR",profileArn:c,resourceType:"AGENTIC_REQUEST"})});if(!d.ok){let a=await d.text();throw Error(`Kiro API error (${d.status}): ${a}`)}let e=await d.json(),f=e.usageBreakdownList||[],g={},h=t(e.nextDateReset||e.resetDate);return f.forEach(a=>{let b=a.resourceType?.toLowerCase()||"unknown",c=a.currentUsageWithPrecision||0,d=a.usageLimitWithPrecision||0;if(g[b]={used:c,total:d,remaining:d-c,resetAt:h,unlimited:!1},a.freeTrialInfo){let c=a.freeTrialInfo.currentUsageWithPrecision||0,d=a.freeTrialInfo.usageLimitWithPrecision||0;g[`${b}_freetrial`]={used:c,total:d,remaining:d-c,resetAt:h,unlimited:!1}}}),{plan:e.subscriptionInfo?.subscriptionTitle||"Kiro",quotas:g}}catch(a){throw Error(`Failed to fetch Kiro usage: ${a.message}`)}}function F(a){return a?({LEVEL_BASIC:"Moderato",LEVEL_INTERMEDIATE:"Allegretto",LEVEL_ADVANCED:"Allegro",LEVEL_STANDARD:"Vivace"})[a]||a.replace("LEVEL_","").toLowerCase():""}async function G(a){let b="kimi-usage-"+Date.now(),c="u">typeof process?`${process.platform} ${process.arch}`:"unknown";try{let d,e=await fetch("https://api.kimi.com/coding/v1/usages",{method:"GET",headers:{Authorization:`Bearer ${a}`,"Content-Type":"application/json","X-Msh-Platform":"omniroute","X-Msh-Version":"2.1.2","X-Msh-Device-Model":c,"X-Msh-Device-Id":b}}),f=await e.text();if(!e.ok)return{plan:"Kimi Coding",message:`Kimi Coding connected. API Error ${e.status}: ${f.slice(0,100)}`};try{d=JSON.parse(f)}catch{return{plan:"Kimi Coding",message:"Kimi Coding connected. Invalid JSON response from API."}}let g={},h=p(d),i=p(h.usage),j=q(i.limit||i.Limit,0),k=q(i.used||i.Used,0),l=q(i.remaining||i.Remaining,0),n=i.resetTime||i.ResetTime||i.reset_at||i.resetAt;j>0&&(g.Weekly={used:k,total:j,remaining:l,remainingPercentage:j>0?l/j*100:0,resetAt:t(n),unlimited:!1});let o=Array.isArray(h.limits)?h.limits:[];for(let a=0;a<o.length;a++){let b=p(o[a]);p(b.window);let c=p(b.detail),d=q(c.limit||c.Limit,0),e=q(c.remaining||c.Remaining,0),f=c.resetTime||c.reset_at||c.resetAt;d>0&&(g.Ratelimit={used:d-e,total:d,remaining:e,remainingPercentage:d>0?e/d*100:0,resetAt:t(f),unlimited:!1})}let r=a=>a&&"object"==typeof a&&void 0!==m(a.utilization),s=a=>{let b=m(a.utilization);return{used:100-b,total:100,remaining:b,resetAt:t(a.resets_at),remainingPercentage:b,unlimited:!1}};for(let[a,b]of(r(p(h.five_hour))&&(g["session (5h)"]=s(p(h.five_hour))),r(p(h.seven_day))&&(g["weekly (7d)"]=s(p(h.seven_day))),Object.entries(h))){let c=p(b);if(a.startsWith("seven_day_")&&"seven_day"!==a&&r(c)){let b=a.replace("seven_day_","");g[`weekly ${b} (7d)`]=s(c)}}if(Object.keys(g).length>0){let a=p(h.user),b=p(a.membership).level;return{plan:F(b)||"Kimi Coding",quotas:g}}let u=p(h.user),v=p(u.membership).level;return{plan:F(v)||"Kimi Coding",message:"Kimi Coding connected. Usage tracked per request."}}catch(a){return{message:`Kimi Coding connected. Unable to fetch usage: ${a.message}`}}}async function H(a,b){try{if(!b?.resourceUrl)return{message:"Qwen connected. No resource URL available."};return{message:"Qwen connected. Usage tracked per request."}}catch(a){return{message:"Unable to fetch Qwen usage."}}}async function I(a){try{return{message:"iFlow connected. Usage tracked per request."}}catch(a){return{message:"Unable to fetch iFlow usage."}}}var J=c(44488);c(15367);var K=c(55511);let L="enc:v1:",M=null;function N(a){if(!a||"string"!=typeof a||!a.startsWith(L))return a;let b=function(){if(null!==M)return M;let a=process.env.STORAGE_ENCRYPTION_KEY;return a?M=(0,K.scryptSync)(a,"omniroute-field-encryption-v1",32):null}();if(!b)return console.warn("[Encryption] Found encrypted data but STORAGE_ENCRYPTION_KEY is not set. Cannot decrypt."),a;let c=a.slice(L.length).split(":");if(3!==c.length)return console.error("[Encryption] Malformed encrypted value"),a;let[d,e,f]=c;try{let a=Buffer.from(d,"hex"),c=Buffer.from(f,"hex"),g=(0,K.createDecipheriv)("aes-256-gcm",b,a);g.setAuthTag(c);let h=g.update(e,"hex","utf8");return h+=g.final("utf8")}catch(b){return console.error("[Encryption] Decryption failed:",b instanceof Error?b.message:String(b)),a}}async function O(a){var b;let c=(0,J.getDbInstance)().prepare("SELECT * FROM provider_connections WHERE id = ?").get(a);return c?(b=(0,J.G6)((0,J.kB)(c)))&&process.env.STORAGE_ENCRYPTION_KEY?{...b,apiKey:N(b.apiKey),accessToken:N(b.accessToken),refreshToken:N(b.refreshToken),idToken:N(b.idToken)}:b:null}var P=c(94781);c(82180);let Q=new Map,R=new Map,S=new Map,T=new Map;(0,P.D)(function(){Q.clear(),R.clear(),T.clear(),T.clear(),S.clear()});var U=c(13922),V=c(16698),W=c(3433),X=c(37481);let Y=Symbol.for("omniroute.proxyDispatcher.cache"),Z=new Set(["http:","https:","socks5:"]);function $(a){try{let b=a.match(/:\/\/(?:[^@]*@)?[^:/\s]+:(\d+)/);if(b){let a=Number(b[1]);if(Number.isInteger(a)&&a>=1&&a<=65535)return String(a)}}catch{}return null}function _(a){return"https:"===a||"wss:"===a?"443":"socks5:"===a?"1080":"8080"}function aa(a,b){if(!a)return _(b);let c=Number(a);if(!Number.isInteger(c)||c<1||c>65535)throw Error("[ProxyDispatcher] Invalid proxy port");return String(c)}function ab(){return"true"===process.env.ENABLE_SOCKS5_PROXY}function ac(a,b="proxy",{allowSocks5:c=ab()}={}){var d;let e,f,g=$(a);try{e=new URL(a)}catch{throw Error(`[ProxyDispatcher] Invalid ${b} URL`)}if(!Z.has(e.protocol))throw Error(`[ProxyDispatcher] Unsupported ${b} protocol: ${e.protocol.replace(":","")}`);if("socks5:"===e.protocol&&!c)throw Error("[ProxyDispatcher] SOCKS5 proxy is disabled (set ENABLE_SOCKS5_PROXY=true to enable)");if(!e.hostname)throw Error(`[ProxyDispatcher] Invalid ${b} host`);let h=g||aa(e.port,e.protocol);return f=(d=e).username?`${d.username}${d.password?`:${d.password}`:""}@`:"",`${d.protocol}//${f}${d.hostname}:${h}`}function ad(a,{allowSocks5:b=ab()}={}){if(!a)return null;if("string"==typeof a)return ac(a,"context proxy",{allowSocks5:b});if("object"!=typeof a||Array.isArray(a))throw Error("[ProxyDispatcher] Invalid context proxy config");let c=String(a.type||"http").toLowerCase(),d=`${c}:`;if(!Z.has(d))throw Error(`[ProxyDispatcher] Unsupported context proxy protocol: ${c}`);if("socks5:"===d&&!b)throw Error("[ProxyDispatcher] SOCKS5 proxy is disabled (set ENABLE_SOCKS5_PROXY=true to enable)");if(!a.host)throw Error("[ProxyDispatcher] Context proxy host is required");let e=aa(a.port,d),f=a.username?`${encodeURIComponent(a.username)}:${a.password?encodeURIComponent(a.password):""}@`:"";return ac(`${c}://${f}${a.host}:${e}`,"context proxy",{allowSocks5:b})}try{let a=c(17181);d="function"==typeof a.createSession?a.createSession:null}catch{d=null}class ae{constructor(){this.session=null,this.available=!!d}async getSession(){if(!this.available)return null;if(this.session)return this.session;let a=process.env.HTTPS_PROXY||process.env.https_proxy||process.env.HTTP_PROXY||process.env.http_proxy||process.env.ALL_PROXY||process.env.all_proxy||void 0,b={browser:"chrome_124",os:"macos"};return a&&(b.proxy=a,console.log(`[TlsClient] Using proxy: ${a}`)),this.session=await d(b),console.log("[TlsClient] Session created (Chrome 124 TLS fingerprint)"),this.session}async fetch(a,b={}){let c=await this.getSession();if(!c)throw Error("wreq-js not available");let d={method:(b.method||"GET").toUpperCase(),headers:function(a){if(!a)return;if(a instanceof Headers)return Object.fromEntries(a.entries());if(Array.isArray(a))return Object.fromEntries(a.map(([a,b])=>[a,String(b)]));let b={};for(let[c,d]of Object.entries(a))"string"==typeof d&&(b[c]=d);return b}(b.headers),body:b.body,redirect:"manual"===b.redirect?"manual":"follow"};return b.signal&&(d.signal=b.signal),await c.fetch(a,d)}async exit(){this.session&&(await this.session.close(),this.session=null)}}let af=new ae,ag=new V.AsyncLocalStorage,ah="u">typeof caches&&"object"==typeof caches,ai=Symbol.for("omniroute.proxyFetch.state"),aj=((e=globalThis)[ai]||(e[ai]={originalFetch:globalThis.fetch,proxyContext:new V.AsyncLocalStorage,isPatched:!1}),e[ai]),ak=aj.originalFetch,al=aj.proxyContext;async function am(a,b){if("function"!=typeof b)throw TypeError("runWithProxyContext requires a callback function");let c=a?ad(a):null;return al.run(a||null,async()=>{let a,d,e;return c&&console.log(`[ProxyFetch] Applied request proxy context: ${(a=$(c),d=new URL(c),e=a||d.port||_(d.protocol),`${d.protocol}//${d.hostname}:${e}`)}`),b()})}async function an(a,b={}){let c;if(b?.dispatcher)return ak(a,b);let d="string"==typeof a?a:a&&"string"==typeof a.url?a.url:String(a);try{c=function(a){let b=al.getStore();if(b)return{source:"context",proxyUrl:ad(b)};let c=function(a){let b;if(function(a){let b,c=process.env.NO_PROXY||process.env.no_proxy;if(!c)return!1;try{b=new URL(a)}catch{return!1}let d=b.hostname.toLowerCase(),e=b.port||("https:"===b.protocol?"443":"80");return c.split(",").map(a=>a.trim().toLowerCase()).filter(Boolean).some(a=>{if("*"===a)return!0;let[b,c]=a.split(":");return(!c||c===e)&&!!b&&(b.startsWith(".")?d.endsWith(b)||d===b.slice(1):d===b||d.endsWith(`.${b}`))})}(a))return null;try{b=new URL(a).protocol}catch{return null}let c="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;return c?ac(c,"environment proxy"):null}(a);return c?{source:"env",proxyUrl:c}:{source:"direct",proxyUrl:null}}(d)}catch(b){let a=b instanceof Error?b.message:String(b);throw console.error(`[ProxyFetch] Proxy configuration error: ${a}`),b}let{source:e,proxyUrl:f}=c;if(!f){if("true"===process.env.ENABLE_TLS_FINGERPRINT&&af.available)try{let a=ag.getStore();return a&&(a.used=!0),await af.fetch(d,{...b,headers:b.headers})}catch(c){let a=c instanceof Error?c.message:String(c);console.warn(`[ProxyFetch] TLS fingerprint failed, falling back to native fetch: ${a}`);let b=ag.getStore();b&&(b.used=!1)}return ak(a,b)}try{let c=function(a){let b,c=ac(a,"proxy dispatcher"),d=((b=globalThis)[Y]||(b[Y]=new Map),b[Y]),e=d.get(c);if(e)return e;let f=new URL(c),g=$(c)||aa(f.port,f.protocol);if("socks5:"===f.protocol){let a={type:5,host:f.hostname,port:Number(g)};f.username&&(a.userId=decodeURIComponent(f.username)),f.password&&(a.password=decodeURIComponent(f.password)),e=(0,X.vI)(a)}else e=new W.ProxyAgent(c);return d.set(c,e),e}(f);return await ak(a,{...b,dispatcher:c})}catch(b){let a=b instanceof Error?b.message:String(b);throw console.error(`[ProxyFetch] Proxy request failed (${e}, fail-closed): ${a}`),b}}ah||aj.isPatched||(globalThis.fetch=an,aj.isPatched=!0);let ao=new Map,ap=null,aq=!1;function ar(a){let b=new Date(a).getTime();return Number.isNaN(b)?null:b}let as=new Set;async function at(a){if(!as.has(a.connectionId)){as.add(a.connectionId);try{var b,c,d;let e,f,g,h=await O(a.connectionId);if(!h||"oauth"!==h.authType||!h.isActive)return void ao.delete(a.connectionId);let i=await (0,U.YD)(a.connectionId),j=await am(i?.proxy||null,()=>s(h));j?.quotas&&(b=a.connectionId,c=a.provider,d=j.quotas,f=function(a){let b={};for(let[c,d]of Object.entries(a))d&&"object"==typeof d&&(b[c]={remainingPercentage:m(d.remainingPercentage)??(d.total>0?Math.round((d.total-(d.used||0))/d.total*100):0),resetAt:d.resetAt||null});return b}(d),g=(e=Object.values(f),0!==e.length&&e.every(a=>a.remainingPercentage<=0)),ao.set(b,{connectionId:b,provider:c,quotas:f,fetchedAt:Date.now(),exhausted:g,nextResetAt:g?function(a){let b=null,c=1/0;for(let d of Object.values(a)){if(!d.resetAt)continue;let a=ar(d.resetAt);null!==a&&a<c&&(c=a,b=d.resetAt)}return b}(f):null}))}catch(b){console.warn(`[QuotaCache] Refresh failed for ${a.connectionId.slice(0,8)}:`,b?.message||b)}finally{as.delete(a.connectionId)}}}async function au(){if(!aq){aq=!0;try{let a=Date.now(),b=[...ao.values()].filter(b=>(function(a,b){let c=b-a.fetchedAt;if(a.exhausted&&a.nextResetAt){let c=ar(a.nextResetAt);if(null!==c&&c<=b)return!0}return c>=3e5})(b,a));for(let a=0;a<b.length;a+=5){let c=b.slice(a,a+5);await Promise.allSettled(c.map(at))}}finally{aq=!1}}}function av(){ap||(ap=setInterval(au,6e4),ap?.unref?.())}},1303:function(a,b,c){var d=this&&this.__createBinding||(Object.create?function(a,b,c,d){void 0===d&&(d=c);var e=Object.getOwnPropertyDescriptor(b,c);(!e||("get"in e?!b.__esModule:e.writable||e.configurable))&&(e={enumerable:!0,get:function(){return b[c]}}),Object.defineProperty(a,d,e)}:function(a,b,c,d){void 0===d&&(d=c),a[d]=b[c]}),e=this&&this.__exportStar||function(a,b){for(var c in a)"default"===c||Object.prototype.hasOwnProperty.call(b,c)||d(b,a,c)};Object.defineProperty(b,"__esModule",{value:!0}),e(c(5355),b)},1712:(a,b,c)=>{let d=c(34589),{Readable:e}=c(57075),{RequestAbortedError:f,NotSupportedError:g,InvalidArgumentError:h,AbortError:i}=c(61448),j=c(84285),{ReadableStreamFrom:k}=c(84285),l=Symbol("kConsume"),m=Symbol("kReading"),n=Symbol("kBody"),o=Symbol("kAbort"),p=Symbol("kContentType"),q=Symbol("kContentLength"),r=Symbol("kUsed"),s=Symbol("kBytesRead"),t=()=>{};class u extends e{constructor({resume:a,abort:b,contentType:c="",contentLength:d,highWaterMark:e=65536}){super({autoDestroy:!0,read:a,highWaterMark:e}),this._readableState.dataEmitted=!1,this[o]=b,this[l]=null,this[s]=0,this[n]=null,this[r]=!1,this[p]=c,this[q]=Number.isFinite(d)?d:null,this[m]=!1}_destroy(a,b){a||this._readableState.endEmitted||(a=new f),a&&this[o](),this[r]?b(a):setImmediate(b,a)}on(a,b){return("data"===a||"readable"===a)&&(this[m]=!0,this[r]=!0),super.on(a,b)}addListener(a,b){return this.on(a,b)}off(a,b){let c=super.off(a,b);return("data"===a||"readable"===a)&&(this[m]=this.listenerCount("data")>0||this.listenerCount("readable")>0),c}removeListener(a,b){return this.off(a,b)}push(a){return a&&(this[s]+=a.length,this[l])?(z(this[l],a),!this[m]||super.push(a)):super.push(a)}text(){return v(this,"text")}json(){return v(this,"json")}blob(){return v(this,"blob")}bytes(){return v(this,"bytes")}arrayBuffer(){return v(this,"arrayBuffer")}async formData(){throw new g}get bodyUsed(){return j.isDisturbed(this)}get body(){return!this[n]&&(this[n]=k(this),this[l]&&(this[n].getReader(),d(this[n].locked))),this[n]}dump(a){let b=a?.signal;if(null!=b&&("object"!=typeof b||!("aborted"in b)))return Promise.reject(new h("signal must be an AbortSignal"));let c=a?.limit&&Number.isFinite(a.limit)?a.limit:131072;return b?.aborted?Promise.reject(b.reason??new i):this._readableState.closeEmitted?Promise.resolve(null):new Promise((a,d)=>{if((this[q]&&this[q]>c||this[s]>c)&&this.destroy(new i),b){let c=()=>{this.destroy(b.reason??new i)};b.addEventListener("abort",c),this.on("close",function(){b.removeEventListener("abort",c),b.aborted?d(b.reason??new i):a(null)})}else this.on("close",a);this.on("error",t).on("data",()=>{this[s]>c&&this.destroy()}).resume()})}setEncoding(a){return Buffer.isEncoding(a)&&(this._readableState.encoding=a),this}}function v(a,b){return d(!a[l]),new Promise((c,d)=>{if(j.isDisturbed(a)||a[n]?.locked===!0||null!==a[l]){let b=a._readableState;b.destroyed&&!1===b.closeEmitted?a.on("error",d).on("close",()=>{d(TypeError("unusable"))}):d(b.errored??TypeError("unusable"))}else queueMicrotask(()=>{a[l]={type:b,stream:a,resolve:c,reject:d,length:0,body:[]},a.on("error",function(a){A(this[l],a)}).on("close",function(){null!==this[l].body&&A(this[l],new f)}),function(a){if(null===a.body)return;let{_readableState:b}=a.stream;if(b.bufferIndex){let c=b.bufferIndex,d=b.buffer.length;for(let e=c;e<d;e++)z(a,b.buffer[e])}else for(let c of b.buffer)z(a,c);for(b.endEmitted?y(this[l],this._readableState.encoding):a.stream.on("end",function(){y(this[l],this._readableState.encoding)}),a.stream.resume();null!=a.stream.read(););}(a[l])})})}function w(a,b,c){if(0===a.length||0===b)return"";let d=1===a.length?a[0]:Buffer.concat(a,b),e=d.length,f=3*(e>2&&239===d[0]&&187===d[1]&&191===d[2]);return c&&"utf8"!==c&&"utf-8"!==c?d.subarray(f,e).toString(c):d.utf8Slice(f,e)}function x(a,b){if(0===a.length||0===b)return new Uint8Array(0);if(1===a.length)return new Uint8Array(a[0]);let c=new Uint8Array(Buffer.allocUnsafeSlow(b).buffer),d=0;for(let b=0;b<a.length;++b){let e=a[b];c.set(e,d),d+=e.length}return c}function y(a,b){let{type:c,body:d,resolve:e,stream:f,length:g}=a;try{"text"===c?e(w(d,g,b)):"json"===c?e(JSON.parse(w(d,g,b))):"arrayBuffer"===c?e(x(d,g).buffer):"blob"===c?e(new Blob(d,{type:f[p]})):"bytes"===c&&e(x(d,g)),A(a)}catch(a){f.destroy(a)}}function z(a,b){a.length+=b.length,a.body.push(b)}function A(a,b){null!==a.body&&(b?a.reject(b):a.resolve(),a.type=null,a.stream=null,a.resolve=null,a.reject=null,a.length=0,a.body=null)}a.exports={Readable:u,chunksDecode:w}},2721:(a,b)=>{Object.defineProperty(b,"__esModule",{value:!0}),b.isInSubnet=function(a){return!(this.subnetMask<a.subnetMask)&&this.mask(a.subnetMask)===a.mask()},b.isCorrect=function(a){return function(){return this.addressMinusSuffix===this.correctForm()&&(this.subnetMask===a&&!this.parsedSubnet||this.parsedSubnet===String(this.subnetMask))}},b.numberToPaddedHex=c,b.stringToPaddedHex=function(a){return c(parseInt(a,10))},b.testBit=function(a,b){let{length:c}=a;if(b>c)return!1;let d=c-b;return"1"===a.substring(d,d+1)};function c(a){return a.toString(16).padStart(2,"0")}},2887:(a,b,c)=>{let{iteratorMixin:d}=c(42425),{kEnumerableProperty:e}=c(84285),{webidl:f}=c(32984),g=c(57975);class h{#a=[];constructor(a){if(f.util.markAsUncloneable(this),void 0!==a)throw f.errors.conversionFailed({prefix:"FormData constructor",argument:"Argument 1",types:["undefined"]})}append(a,b,c){f.brandCheck(this,h);let d="FormData.append";f.argumentLengthCheck(arguments,2,d),a=f.converters.USVString(a),3==arguments.length||f.is.Blob(b)?(b=f.converters.Blob(b,d,"value"),void 0!==c&&(c=f.converters.USVString(c))):b=f.converters.USVString(b);let e=k(a,b,c);this.#a.push(e)}delete(a){f.brandCheck(this,h),f.argumentLengthCheck(arguments,1,"FormData.delete"),a=f.converters.USVString(a),this.#a=this.#a.filter(b=>b.name!==a)}get(a){f.brandCheck(this,h),f.argumentLengthCheck(arguments,1,"FormData.get"),a=f.converters.USVString(a);let b=this.#a.findIndex(b=>b.name===a);return -1===b?null:this.#a[b].value}getAll(a){return f.brandCheck(this,h),f.argumentLengthCheck(arguments,1,"FormData.getAll"),a=f.converters.USVString(a),this.#a.filter(b=>b.name===a).map(a=>a.value)}has(a){return f.brandCheck(this,h),f.argumentLengthCheck(arguments,1,"FormData.has"),a=f.converters.USVString(a),-1!==this.#a.findIndex(b=>b.name===a)}set(a,b,c){f.brandCheck(this,h);let d="FormData.set";f.argumentLengthCheck(arguments,2,d),a=f.converters.USVString(a),3==arguments.length||f.is.Blob(b)?(b=f.converters.Blob(b,d,"value"),void 0!==c&&(c=f.converters.USVString(c))):b=f.converters.USVString(b);let e=k(a,b,c),g=this.#a.findIndex(b=>b.name===a);-1!==g?this.#a=[...this.#a.slice(0,g),e,...this.#a.slice(g+1).filter(b=>b.name!==a)]:this.#a.push(e)}[g.inspect.custom](a,b){let c=this.#a.reduce((a,b)=>(a[b.name]?Array.isArray(a[b.name])?a[b.name].push(b.value):a[b.name]=[a[b.name],b.value]:a[b.name]=b.value,a),{__proto__:null});b.depth??=a,b.colors??=!0;let d=g.formatWithOptions(b,c);return`FormData ${d.slice(d.indexOf("]")+2)}`}static getFormDataState(a){return a.#a}static setFormDataState(a,b){a.#a=b}}let{getFormDataState:i,setFormDataState:j}=h;function k(a,b,c){if("string"==typeof b);else if(f.is.File(b)||(b=new File([b],"blob",{type:b.type})),void 0!==c){let a={type:b.type,lastModified:b.lastModified};b=new File([b],c,a)}return{name:a,value:b}}Reflect.deleteProperty(h,"getFormDataState"),Reflect.deleteProperty(h,"setFormDataState"),d("FormData",h,i,"name","value"),Object.defineProperties(h.prototype,{append:e,delete:e,get:e,getAll:e,has:e,set:e,[Symbol.toStringTag]:{value:"FormData",configurable:!0}}),f.is.FormData=f.util.MakeTypeAssertion(h),a.exports={FormData:h,makeEntry:k,setFormDataState:j}},3433:(a,b,c)=>{let d=c(40106),e=c(7344),f=c(35689),g=c(61330),h=c(34441),i=c(37417),j=c(48841),k=c(43086),l=c(95095),m=c(53552),n=c(61448),o=c(84285),{InvalidArgumentError:p}=n,q=c(99528),r=c(55285),s=c(66498),{MockCallHistory:t,MockCallHistoryLog:u}=c(43904),v=c(43249),w=c(86625),x=c(89512),y=c(28998),z=c(31825),{getGlobalDispatcher:A,setGlobalDispatcher:B}=c(59970),C=c(83204),D=c(67519);Object.assign(e.prototype,q),a.exports.Dispatcher=e,a.exports.Client=d,a.exports.Pool=f,a.exports.BalancedPool=g,a.exports.RoundRobinPool=h,a.exports.Agent=i,a.exports.ProxyAgent=j,a.exports.EnvHttpProxyAgent=k,a.exports.RetryAgent=l,a.exports.H2CClient=m,a.exports.RetryHandler=z,a.exports.DecoratorHandler=C,a.exports.RedirectHandler=D,a.exports.interceptors={redirect:c(70707),responseError:c(47335),retry:c(78075),dump:c(87085),dns:c(27060),cache:c(19431),decompress:c(37858),deduplicate:c(90249)},a.exports.cacheStores={MemoryCacheStore:c(38650)};let E=c(20579);function F(a){return(b,c,d)=>{if("function"==typeof c&&(d=c,c=null),!b||"string"!=typeof b&&"object"!=typeof b&&!(b instanceof URL))throw new p("invalid url");if(null!=c&&"object"!=typeof c)throw new p("invalid opts");if(c&&null!=c.path){if("string"!=typeof c.path)throw new p("invalid opts.path");let a=c.path;c.path.startsWith("/")||(a=`/${a}`),b=new URL(o.parseOrigin(b).origin+a)}else c||(c="object"==typeof b?b:{}),b=o.parseURL(b);let{agent:e,dispatcher:f=A()}=c;if(e)throw new p("unsupported opts.agent. Did you mean opts.client?");return a.call(f,{...c,origin:b.origin,path:b.search?`${b.pathname}${b.search}`:b.pathname,method:c.method||(c.body?"PUT":"GET")},d)}}a.exports.cacheStores.SqliteCacheStore=E,a.exports.buildConnector=r,a.exports.errors=n,a.exports.util={parseHeaders:o.parseHeaders,headerNameToString:o.headerNameToString},a.exports.setGlobalDispatcher=B,a.exports.getGlobalDispatcher=A;let G=c(76403).fetch,H=__filename;a.exports.fetch=function(b,c){return G(b,c).catch(b=>{throw H?!function a(b,c){if(!b||"object"!=typeof b)return;let d="string"==typeof b.stack?b.stack:"",e=c.replace(/\\/g,"/");if(d&&(d.includes(c)||d.includes(e)))return;let f={};if(Error.captureStackTrace(f,a),!f.stack)return;let g=f.stack.split("\n").slice(1).join("\n");b.stack=d?`${d}
|
|
2
2
|
${g}`:f.stack}(b,H):b&&"object"==typeof b&&Error.captureStackTrace(b,a.exports.fetch),b})},a.exports.Headers=c(28665).Headers,a.exports.Response=c(78196).Response,a.exports.Request=c(12600).Request,a.exports.FormData=c(2887).FormData;let{setGlobalOrigin:I,getGlobalOrigin:J}=c(79412);a.exports.setGlobalOrigin=I,a.exports.getGlobalOrigin=J;let{CacheStorage:K}=c(49166),{kConstruct:L}=c(49176);a.exports.caches=new K(L);let{deleteCookie:M,getCookies:N,getSetCookies:O,setCookie:P,parseCookie:Q}=c(70106);a.exports.deleteCookie=M,a.exports.getCookies=N,a.exports.getSetCookies=O,a.exports.setCookie=P,a.exports.parseCookie=Q;let{parseMIMEType:R,serializeAMimeType:S}=c(16537);a.exports.parseMIMEType=R,a.exports.serializeAMimeType=S;let{CloseEvent:T,ErrorEvent:U,MessageEvent:V}=c(51753),{WebSocket:W,ping:X}=c(52039);a.exports.WebSocket=W,a.exports.CloseEvent=T,a.exports.ErrorEvent=U,a.exports.MessageEvent=V,a.exports.ping=X,a.exports.WebSocketStream=c(42430).WebSocketStream,a.exports.WebSocketError=c(87404).WebSocketError,a.exports.request=F(q.request),a.exports.stream=F(q.stream),a.exports.pipeline=F(q.pipeline),a.exports.connect=F(q.connect),a.exports.upgrade=F(q.upgrade),a.exports.MockClient=s,a.exports.MockCallHistory=t,a.exports.MockCallHistoryLog=u,a.exports.MockPool=w,a.exports.MockAgent=v,a.exports.SnapshotAgent=x,a.exports.mockErrors=y;let{EventSource:Y}=c(53732);a.exports.EventSource=Y,a.exports.install=function(){globalThis.fetch=a.exports.fetch,globalThis.Headers=a.exports.Headers,globalThis.Response=a.exports.Response,globalThis.Request=a.exports.Request,globalThis.FormData=a.exports.FormData,globalThis.WebSocket=a.exports.WebSocket,globalThis.CloseEvent=a.exports.CloseEvent,globalThis.ErrorEvent=a.exports.ErrorEvent,globalThis.MessageEvent=a.exports.MessageEvent,globalThis.EventSource=a.exports.EventSource}},4654:(a,b,c)=>{let{uid:d,states:e,sentCloseFrameState:f,emptyBuffer:g,opcodes:h}=c(39645),{parseExtensions:i,isClosed:j,isClosing:k,isEstablished:l,isConnecting:m,validateCloseCodeAndReason:n}=c(94050),{makeRequest:o}=c(12600),{fetching:p}=c(76403),{Headers:q,getHeadersList:r}=c(28665),{getDecodeSplit:s}=c(42425),{WebsocketFrameSend:t}=c(45221),u=c(34589),{runtimeFeatures:v}=c(56758),w=v.has("crypto")?c(77598):null,x=!1;function y(a,b,c,d=!1){if(b??=null,c??="",d&&n(b,c),j(a.readyState)||k(a.readyState));else if(l(a.readyState))if(a.closeState.has(f.SENT)||a.closeState.has(f.RECEIVED))a.readyState=e.CLOSING;else{let d=new t;0!==c.length&&null===b&&(b=1e3),u(null===b||Number.isInteger(b)),null===b&&0===c.length?d.frameData=g:null!==b&&null===c?(d.frameData=Buffer.allocUnsafe(2),d.frameData.writeUInt16BE(b,0)):null!==b&&null!==c?(d.frameData=Buffer.allocUnsafe(2+Buffer.byteLength(c)),d.frameData.writeUInt16BE(b,0),d.frameData.write(c,2,"utf-8")):d.frameData=g,a.socket.write(d.createFrame(h.CLOSE)),a.closeState.add(f.SENT),a.readyState=e.CLOSING}else z(a),a.readyState=e.CLOSING}function z(a,b,c,d){l(a.readyState)&&y(a,b,c,!1),a.controller.abort(),m(a.readyState)?a.onSocketClose():a.socket?.destroyed===!1&&a.socket.destroy()}a.exports={establishWebSocketConnection:function(a,b,c,e,f){a.protocol="ws:"===a.protocol?"http:":"https:";let g=o({urlList:[a],client:c,serviceWorkers:"none",referrer:"no-referrer",mode:"websocket",credentials:"include",cache:"no-store",redirect:"error",useURLCredentials:!0});f.headers&&(g.headersList=r(new q(f.headers)));let h=w.randomBytes(16).toString("base64");for(let a of(g.headersList.append("sec-websocket-key",h,!0),g.headersList.append("sec-websocket-version","13",!0),b))g.headersList.append("sec-websocket-protocol",a,!0);return g.headersList.append("sec-websocket-extensions","permessage-deflate; client_max_window_bits",!0),p({request:g,useParallelQueue:!0,dispatcher:f.dispatcher,processResponse(a){let c;if("error"===a.type||101!==a.status){if(a.socket?.session==null)return void z(e,1002,"Received network error or non-101 status code.",a.error);if(200!==a.status)return void z(e,1002,"Received network error or non-200 status code.",a.error)}if(!1===x&&a.socket?.session!=null&&(process.emitWarning("WebSocket over HTTP2 is experimental, and subject to change.","ExperimentalWarning"),x=!0),0!==b.length&&!a.headersList.get("Sec-WebSocket-Protocol"))return void z(e,1002,"Server did not respond with sent protocols.");if(null==a.socket.session&&a.headersList.get("Upgrade")?.toLowerCase()!=="websocket")return void z(e,1002,'Server did not set Upgrade header to "websocket".');if(null==a.socket.session&&a.headersList.get("Connection")?.toLowerCase()!=="upgrade")return void z(e,1002,'Server did not set Connection header to "upgrade".');if(a.headersList.get("Sec-WebSocket-Accept")!==w.hash("sha1",h+d,"base64"))return void z(e,1002,"Incorrect hash received in Sec-WebSocket-Accept header.");let f=a.headersList.get("Sec-WebSocket-Extensions");if(null!==f&&!(c=i(f)).has("permessage-deflate"))return void z(e,1002,"Sec-WebSocket-Extensions header does not match.");let j=a.headersList.get("Sec-WebSocket-Protocol");null===j||s("sec-websocket-protocol",g.headersList).includes(j)?(a.socket.on("data",e.onSocketData),a.socket.on("close",e.onSocketClose),a.socket.on("error",e.onSocketError),e.wasEverConnected=!0,e.onConnectionEstablished(a,c)):z(e,1002,"Protocol was not set in the opening handshake.")}})},failWebsocketConnection:z,closeWebSocketConnection:y}},5318:(a,b,c)=>{let d=c(7344),e=c(72638),{ClientDestroyedError:f,ClientClosedError:g,InvalidArgumentError:h}=c(61448),{kDestroy:i,kClose:j,kClosed:k,kDestroyed:l,kDispatch:m}=c(49176),n=Symbol("onDestroyed"),o=Symbol("onClosed");class p extends d{[l]=!1;[n]=null;[k]=!1;[o]=null;get destroyed(){return this[l]}get closed(){return this[k]}close(a){if(void 0===a)return new Promise((a,b)=>{this.close((c,d)=>c?b(c):a(d))});if("function"!=typeof a)throw new h("invalid callback");if(this[l]){let b=new f;queueMicrotask(()=>a(b,null));return}if(this[k])return void(this[o]?this[o].push(a):queueMicrotask(()=>a(null,null)));this[k]=!0,this[o]??=[],this[o].push(a);let b=()=>{let a=this[o];this[o]=null;for(let b=0;b<a.length;b++)a[b](null,null)};this[j]().then(()=>this.destroy()).then(()=>queueMicrotask(b))}destroy(a,b){if("function"==typeof a&&(b=a,a=null),void 0===b)return new Promise((b,c)=>{this.destroy(a,(a,d)=>a?c(a):b(d))});if("function"!=typeof b)throw new h("invalid callback");if(this[l])return void(this[n]?this[n].push(b):queueMicrotask(()=>b(null,null)));a||(a=new f),this[l]=!0,this[n]??=[],this[n].push(b);let c=()=>{let a=this[n];this[n]=null;for(let b=0;b<a.length;b++)a[b](null,null)};this[i](a).then(()=>queueMicrotask(c))}dispatch(a,b){if(!b||"object"!=typeof b)throw new h("handler must be an object");b=e.unwrap(b);try{if(!a||"object"!=typeof a)throw new h("opts must be an object.");if(this[l]||this[n])throw new f;if(this[k])throw new g;return this[m](a,b)}catch(a){if("function"!=typeof b.onError)throw a;return b.onError(a),!1}}}a.exports=p},5355:function(a,b,c){var d=this&&this.__awaiter||function(a,b,c,d){return new(c||(c=Promise))(function(e,f){function g(a){try{i(d.next(a))}catch(a){f(a)}}function h(a){try{i(d.throw(a))}catch(a){f(a)}}function i(a){var b;a.done?e(a.value):((b=a.value)instanceof c?b:new c(function(a){a(b)})).then(g,h)}i((d=d.apply(a,b||[])).next())})};Object.defineProperty(b,"__esModule",{value:!0}),b.SocksClientError=b.SocksClient=void 0;let e=c(94735),f=c(91645),g=c(69691),h=c(66640),i=c(91624),j=c(20146),k=c(39153);Object.defineProperty(b,"SocksClientError",{enumerable:!0,get:function(){return k.SocksClientError}});let l=c(51274);class m extends e.EventEmitter{constructor(a){super(),this.options=Object.assign({},a),(0,i.validateSocksClientOptions)(a),this.setState(h.SocksClientState.Created)}static createConnection(a,b){return new Promise((c,d)=>{try{(0,i.validateSocksClientOptions)(a,["connect"])}catch(a){if("function"==typeof b)return b(a),c(a);return d(a)}let e=new m(a);e.connect(a.existing_socket),e.once("established",a=>{e.removeAllListeners(),"function"==typeof b&&b(null,a),c(a)}),e.once("error",a=>{e.removeAllListeners(),"function"==typeof b?(b(a),c(a)):d(a)})})}static createConnectionChain(a,b){return new Promise((c,e)=>d(this,void 0,void 0,function*(){try{(0,i.validateSocksClientChainOptions)(a)}catch(a){if("function"==typeof b)return b(a),c(a);return e(a)}a.randomizeChain&&(0,k.shuffleArray)(a.proxies);try{let d;for(let b=0;b<a.proxies.length;b++){let c=a.proxies[b],e=b===a.proxies.length-1?a.destination:{host:a.proxies[b+1].host||a.proxies[b+1].ipaddress,port:a.proxies[b+1].port},f=yield m.createConnection({command:"connect",proxy:c,destination:e,existing_socket:d});d=d||f.socket}"function"==typeof b&&b(null,{socket:d}),c({socket:d})}catch(a){"function"==typeof b?(b(a),c(a)):e(a)}}))}static createUDPFrame(a){let b=new g.SmartBuffer;return b.writeUInt16BE(0),b.writeUInt8(a.frameNumber||0),f.isIPv4(a.remoteHost.host)?(b.writeUInt8(h.Socks5HostType.IPv4),b.writeUInt32BE((0,i.ipv4ToInt32)(a.remoteHost.host))):f.isIPv6(a.remoteHost.host)?(b.writeUInt8(h.Socks5HostType.IPv6),b.writeBuffer((0,i.ipToBuffer)(a.remoteHost.host))):(b.writeUInt8(h.Socks5HostType.Hostname),b.writeUInt8(Buffer.byteLength(a.remoteHost.host)),b.writeString(a.remoteHost.host)),b.writeUInt16BE(a.remoteHost.port),b.writeBuffer(a.data),b.toBuffer()}static parseUDPFrame(a){let b=g.SmartBuffer.fromBuffer(a);b.readOffset=2;let c=b.readUInt8(),d=b.readUInt8();return{frameNumber:c,remoteHost:{host:d===h.Socks5HostType.IPv4?(0,i.int32ToIpv4)(b.readUInt32BE()):d===h.Socks5HostType.IPv6?l.Address6.fromByteArray(Array.from(b.readBuffer(16))).canonicalForm():b.readString(b.readUInt8()),port:b.readUInt16BE()},data:b.readBuffer()}}setState(a){this.state!==h.SocksClientState.Error&&(this.state=a)}connect(a){this.onDataReceived=a=>this.onDataReceivedHandler(a),this.onClose=()=>this.onCloseHandler(),this.onError=a=>this.onErrorHandler(a),this.onConnect=()=>this.onConnectHandler();let b=setTimeout(()=>this.onEstablishedTimeout(),this.options.timeout||h.DEFAULT_TIMEOUT);b.unref&&"function"==typeof b.unref&&b.unref(),a?this.socket=a:this.socket=new f.Socket,this.socket.once("close",this.onClose),this.socket.once("error",this.onError),this.socket.once("connect",this.onConnect),this.socket.on("data",this.onDataReceived),this.setState(h.SocksClientState.Connecting),this.receiveBuffer=new j.ReceiveBuffer,a?this.socket.emit("connect"):(this.socket.connect(this.getSocketOptions()),void 0!==this.options.set_tcp_nodelay&&null!==this.options.set_tcp_nodelay&&this.socket.setNoDelay(!!this.options.set_tcp_nodelay)),this.prependOnceListener("established",a=>{setImmediate(()=>{if(this.receiveBuffer.length>0){let b=this.receiveBuffer.get(this.receiveBuffer.length);a.socket.emit("data",b)}a.socket.resume()})})}getSocketOptions(){return Object.assign(Object.assign({},this.options.socket_options),{host:this.options.proxy.host||this.options.proxy.ipaddress,port:this.options.proxy.port})}onEstablishedTimeout(){this.state!==h.SocksClientState.Established&&this.state!==h.SocksClientState.BoundWaitingForConnection&&this.closeSocket(h.ERRORS.ProxyConnectionTimedOut)}onConnectHandler(){this.setState(h.SocksClientState.Connected),4===this.options.proxy.type?this.sendSocks4InitialHandshake():this.sendSocks5InitialHandshake(),this.setState(h.SocksClientState.SentInitialHandshake)}onDataReceivedHandler(a){this.receiveBuffer.append(a),this.processData()}processData(){for(;this.state!==h.SocksClientState.Established&&this.state!==h.SocksClientState.Error&&this.receiveBuffer.length>=this.nextRequiredPacketBufferSize;)if(this.state===h.SocksClientState.SentInitialHandshake)4===this.options.proxy.type?this.handleSocks4FinalHandshakeResponse():this.handleInitialSocks5HandshakeResponse();else if(this.state===h.SocksClientState.SentAuthentication)this.handleInitialSocks5AuthenticationHandshakeResponse();else if(this.state===h.SocksClientState.SentFinalHandshake)this.handleSocks5FinalHandshakeResponse();else if(this.state===h.SocksClientState.BoundWaitingForConnection)4===this.options.proxy.type?this.handleSocks4IncomingConnectionResponse():this.handleSocks5IncomingConnectionResponse();else{this.closeSocket(h.ERRORS.InternalError);break}}onCloseHandler(){this.closeSocket(h.ERRORS.SocketClosed)}onErrorHandler(a){this.closeSocket(a.message)}removeInternalSocketHandlers(){this.socket.pause(),this.socket.removeListener("data",this.onDataReceived),this.socket.removeListener("close",this.onClose),this.socket.removeListener("error",this.onError),this.socket.removeListener("connect",this.onConnect)}closeSocket(a){this.state!==h.SocksClientState.Error&&(this.setState(h.SocksClientState.Error),this.socket.destroy(),this.removeInternalSocketHandlers(),this.emit("error",new k.SocksClientError(a,this.options)))}sendSocks4InitialHandshake(){let a=this.options.proxy.userId||"",b=new g.SmartBuffer;b.writeUInt8(4),b.writeUInt8(h.SocksCommand[this.options.command]),b.writeUInt16BE(this.options.destination.port),f.isIPv4(this.options.destination.host)?(b.writeBuffer((0,i.ipToBuffer)(this.options.destination.host)),b.writeStringNT(a)):(b.writeUInt8(0),b.writeUInt8(0),b.writeUInt8(0),b.writeUInt8(1),b.writeStringNT(a),b.writeStringNT(this.options.destination.host)),this.nextRequiredPacketBufferSize=h.SOCKS_INCOMING_PACKET_SIZES.Socks4Response,this.socket.write(b.toBuffer())}handleSocks4FinalHandshakeResponse(){let a=this.receiveBuffer.get(8);if(a[1]!==h.Socks4Response.Granted)this.closeSocket(`${h.ERRORS.Socks4ProxyRejectedConnection} - (${h.Socks4Response[a[1]]})`);else if(h.SocksCommand[this.options.command]===h.SocksCommand.bind){let b=g.SmartBuffer.fromBuffer(a);b.readOffset=2;let c={port:b.readUInt16BE(),host:(0,i.int32ToIpv4)(b.readUInt32BE())};"0.0.0.0"===c.host&&(c.host=this.options.proxy.ipaddress),this.setState(h.SocksClientState.BoundWaitingForConnection),this.emit("bound",{remoteHost:c,socket:this.socket})}else this.setState(h.SocksClientState.Established),this.removeInternalSocketHandlers(),this.emit("established",{socket:this.socket})}handleSocks4IncomingConnectionResponse(){let a=this.receiveBuffer.get(8);if(a[1]!==h.Socks4Response.Granted)this.closeSocket(`${h.ERRORS.Socks4ProxyRejectedIncomingBoundConnection} - (${h.Socks4Response[a[1]]})`);else{let b=g.SmartBuffer.fromBuffer(a);b.readOffset=2;let c={port:b.readUInt16BE(),host:(0,i.int32ToIpv4)(b.readUInt32BE())};this.setState(h.SocksClientState.Established),this.removeInternalSocketHandlers(),this.emit("established",{remoteHost:c,socket:this.socket})}}sendSocks5InitialHandshake(){let a=new g.SmartBuffer,b=[h.Socks5Auth.NoAuth];for(let c of((this.options.proxy.userId||this.options.proxy.password)&&b.push(h.Socks5Auth.UserPass),void 0!==this.options.proxy.custom_auth_method&&b.push(this.options.proxy.custom_auth_method),a.writeUInt8(5),a.writeUInt8(b.length),b))a.writeUInt8(c);this.nextRequiredPacketBufferSize=h.SOCKS_INCOMING_PACKET_SIZES.Socks5InitialHandshakeResponse,this.socket.write(a.toBuffer()),this.setState(h.SocksClientState.SentInitialHandshake)}handleInitialSocks5HandshakeResponse(){let a=this.receiveBuffer.get(2);5!==a[0]?this.closeSocket(h.ERRORS.InvalidSocks5IntiailHandshakeSocksVersion):a[1]===h.SOCKS5_NO_ACCEPTABLE_AUTH?this.closeSocket(h.ERRORS.InvalidSocks5InitialHandshakeNoAcceptedAuthType):a[1]===h.Socks5Auth.NoAuth?(this.socks5ChosenAuthType=h.Socks5Auth.NoAuth,this.sendSocks5CommandRequest()):a[1]===h.Socks5Auth.UserPass?(this.socks5ChosenAuthType=h.Socks5Auth.UserPass,this.sendSocks5UserPassAuthentication()):a[1]===this.options.proxy.custom_auth_method?(this.socks5ChosenAuthType=this.options.proxy.custom_auth_method,this.sendSocks5CustomAuthentication()):this.closeSocket(h.ERRORS.InvalidSocks5InitialHandshakeUnknownAuthType)}sendSocks5UserPassAuthentication(){let a=this.options.proxy.userId||"",b=this.options.proxy.password||"",c=new g.SmartBuffer;c.writeUInt8(1),c.writeUInt8(Buffer.byteLength(a)),c.writeString(a),c.writeUInt8(Buffer.byteLength(b)),c.writeString(b),this.nextRequiredPacketBufferSize=h.SOCKS_INCOMING_PACKET_SIZES.Socks5UserPassAuthenticationResponse,this.socket.write(c.toBuffer()),this.setState(h.SocksClientState.SentAuthentication)}sendSocks5CustomAuthentication(){return d(this,void 0,void 0,function*(){this.nextRequiredPacketBufferSize=this.options.proxy.custom_auth_response_size,this.socket.write((yield this.options.proxy.custom_auth_request_handler())),this.setState(h.SocksClientState.SentAuthentication)})}handleSocks5CustomAuthHandshakeResponse(a){return d(this,void 0,void 0,function*(){return yield this.options.proxy.custom_auth_response_handler(a)})}handleSocks5AuthenticationNoAuthHandshakeResponse(a){return d(this,void 0,void 0,function*(){return 0===a[1]})}handleSocks5AuthenticationUserPassHandshakeResponse(a){return d(this,void 0,void 0,function*(){return 0===a[1]})}handleInitialSocks5AuthenticationHandshakeResponse(){return d(this,void 0,void 0,function*(){this.setState(h.SocksClientState.ReceivedAuthenticationResponse);let a=!1;this.socks5ChosenAuthType===h.Socks5Auth.NoAuth?a=yield this.handleSocks5AuthenticationNoAuthHandshakeResponse(this.receiveBuffer.get(2)):this.socks5ChosenAuthType===h.Socks5Auth.UserPass?a=yield this.handleSocks5AuthenticationUserPassHandshakeResponse(this.receiveBuffer.get(2)):this.socks5ChosenAuthType===this.options.proxy.custom_auth_method&&(a=yield this.handleSocks5CustomAuthHandshakeResponse(this.receiveBuffer.get(this.options.proxy.custom_auth_response_size))),a?this.sendSocks5CommandRequest():this.closeSocket(h.ERRORS.Socks5AuthenticationFailed)})}sendSocks5CommandRequest(){let a=new g.SmartBuffer;a.writeUInt8(5),a.writeUInt8(h.SocksCommand[this.options.command]),a.writeUInt8(0),f.isIPv4(this.options.destination.host)?(a.writeUInt8(h.Socks5HostType.IPv4),a.writeBuffer((0,i.ipToBuffer)(this.options.destination.host))):f.isIPv6(this.options.destination.host)?(a.writeUInt8(h.Socks5HostType.IPv6),a.writeBuffer((0,i.ipToBuffer)(this.options.destination.host))):(a.writeUInt8(h.Socks5HostType.Hostname),a.writeUInt8(this.options.destination.host.length),a.writeString(this.options.destination.host)),a.writeUInt16BE(this.options.destination.port),this.nextRequiredPacketBufferSize=h.SOCKS_INCOMING_PACKET_SIZES.Socks5ResponseHeader,this.socket.write(a.toBuffer()),this.setState(h.SocksClientState.SentFinalHandshake)}handleSocks5FinalHandshakeResponse(){let a=this.receiveBuffer.peek(5);if(5!==a[0]||a[1]!==h.Socks5Response.Granted)this.closeSocket(`${h.ERRORS.InvalidSocks5FinalHandshakeRejected} - ${h.Socks5Response[a[1]]}`);else{let b,c,d=a[3];if(d===h.Socks5HostType.IPv4){let a=h.SOCKS_INCOMING_PACKET_SIZES.Socks5ResponseIPv4;if(this.receiveBuffer.length<a){this.nextRequiredPacketBufferSize=a;return}c=g.SmartBuffer.fromBuffer(this.receiveBuffer.get(a).slice(4)),"0.0.0.0"===(b={host:(0,i.int32ToIpv4)(c.readUInt32BE()),port:c.readUInt16BE()}).host&&(b.host=this.options.proxy.ipaddress)}else if(d===h.Socks5HostType.Hostname){let d=a[4],e=h.SOCKS_INCOMING_PACKET_SIZES.Socks5ResponseHostname(d);if(this.receiveBuffer.length<e){this.nextRequiredPacketBufferSize=e;return}b={host:(c=g.SmartBuffer.fromBuffer(this.receiveBuffer.get(e).slice(5))).readString(d),port:c.readUInt16BE()}}else if(d===h.Socks5HostType.IPv6){let a=h.SOCKS_INCOMING_PACKET_SIZES.Socks5ResponseIPv6;if(this.receiveBuffer.length<a){this.nextRequiredPacketBufferSize=a;return}c=g.SmartBuffer.fromBuffer(this.receiveBuffer.get(a).slice(4)),b={host:l.Address6.fromByteArray(Array.from(c.readBuffer(16))).canonicalForm(),port:c.readUInt16BE()}}this.setState(h.SocksClientState.ReceivedFinalResponse),h.SocksCommand[this.options.command]===h.SocksCommand.connect?(this.setState(h.SocksClientState.Established),this.removeInternalSocketHandlers(),this.emit("established",{remoteHost:b,socket:this.socket})):h.SocksCommand[this.options.command]===h.SocksCommand.bind?(this.setState(h.SocksClientState.BoundWaitingForConnection),this.nextRequiredPacketBufferSize=h.SOCKS_INCOMING_PACKET_SIZES.Socks5ResponseHeader,this.emit("bound",{remoteHost:b,socket:this.socket})):h.SocksCommand[this.options.command]===h.SocksCommand.associate&&(this.setState(h.SocksClientState.Established),this.removeInternalSocketHandlers(),this.emit("established",{remoteHost:b,socket:this.socket}))}}handleSocks5IncomingConnectionResponse(){let a=this.receiveBuffer.peek(5);if(5!==a[0]||a[1]!==h.Socks5Response.Granted)this.closeSocket(`${h.ERRORS.Socks5ProxyRejectedIncomingBoundConnection} - ${h.Socks5Response[a[1]]}`);else{let b,c,d=a[3];if(d===h.Socks5HostType.IPv4){let a=h.SOCKS_INCOMING_PACKET_SIZES.Socks5ResponseIPv4;if(this.receiveBuffer.length<a){this.nextRequiredPacketBufferSize=a;return}c=g.SmartBuffer.fromBuffer(this.receiveBuffer.get(a).slice(4)),"0.0.0.0"===(b={host:(0,i.int32ToIpv4)(c.readUInt32BE()),port:c.readUInt16BE()}).host&&(b.host=this.options.proxy.ipaddress)}else if(d===h.Socks5HostType.Hostname){let d=a[4],e=h.SOCKS_INCOMING_PACKET_SIZES.Socks5ResponseHostname(d);if(this.receiveBuffer.length<e){this.nextRequiredPacketBufferSize=e;return}b={host:(c=g.SmartBuffer.fromBuffer(this.receiveBuffer.get(e).slice(5))).readString(d),port:c.readUInt16BE()}}else if(d===h.Socks5HostType.IPv6){let a=h.SOCKS_INCOMING_PACKET_SIZES.Socks5ResponseIPv6;if(this.receiveBuffer.length<a){this.nextRequiredPacketBufferSize=a;return}c=g.SmartBuffer.fromBuffer(this.receiveBuffer.get(a).slice(4)),b={host:l.Address6.fromByteArray(Array.from(c.readBuffer(16))).canonicalForm(),port:c.readUInt16BE()}}this.setState(h.SocksClientState.Established),this.removeInternalSocketHandlers(),this.emit("established",{remoteHost:b,socket:this.socket})}}get socksClientOptions(){return Object.assign({},this.options)}}b.SocksClient=m},5623:(a,b)=>{Object.defineProperty(b,"__esModule",{value:!0}),b.AddressError=void 0;class c extends Error{constructor(a,b){super(a),this.name="AddressError",this.parseMessage=b}}b.AddressError=c},5831:(a,b,c)=>{let{collectASequenceOfCodePointsFast:d}=c(70745),{maxNameValuePairSize:e,maxAttributeValueSize:f}=c(29653),{isCTLExcludingHtab:g}=c(84698),h=c(34589),{unescape:i}=c(41792);function j(a,b={}){if(0===a.length)return b;h(";"===a[0]);let c="";(a=a.slice(1)).includes(";")?(c=d(";",a,{position:0}),a=a.slice(c.length)):(c=a,a="");let e="",g="";if(c.includes("=")){let a={position:0};e=d("=",c,a),g=c.slice(a.position+1)}else e=c;if(e=e.trim(),(g=g.trim()).length>f)return j(a,b);let i=e.toLowerCase();if("expires"===i)b.expires=new Date(g);else if("max-age"===i){let c=g.charCodeAt(0);if((c<48||c>57)&&"-"!==g[0]||!/^\d+$/.test(g))return j(a,b);b.maxAge=Number(g)}else if("domain"===i){let a=g;"."===a[0]&&(a=a.slice(1)),b.domain=a=a.toLowerCase()}else if("path"===i)b.path=0===g.length||"/"!==g[0]?"/":g;else if("secure"===i)b.secure=!0;else if("httponly"===i)b.httpOnly=!0;else if("samesite"===i){let a="Default",c=g.toLowerCase();c.includes("none")&&(a="None"),c.includes("strict")&&(a="Strict"),c.includes("lax")&&(a="Lax"),b.sameSite=a}else b.unparsed??=[],b.unparsed.push(`${e}=${g}`);return j(a,b)}a.exports={parseSetCookie:function(a){if(g(a))return null;let b="",c="",f="",h="";if(a.includes(";")){let e={position:0};b=d(";",a,e),c=a.slice(e.position)}else b=a;if(b.includes("=")){let a={position:0};f=d("=",b,a),h=b.slice(a.position+1)}else h=b;return(f=f.trim(),h=h.trim(),f.length+h.length>e)?null:{name:f,value:i(h),...j(c)}},parseUnparsedAttributes:j}},7344:(a,b,c)=>{let d=c(78474),e=c(29167),f=a=>(b,c)=>a(b,e.wrap(c));class g extends d{dispatch(){throw Error("not implemented")}close(){throw Error("not implemented")}destroy(){throw Error("not implemented")}compose(...a){let b=Array.isArray(a[0])?a[0]:a,c=this.dispatch.bind(this);for(let a of b)if(null!=a){if("function"!=typeof a)throw TypeError(`invalid interceptor, expected function received ${typeof a}`);if(null==(c=f(c=a(c)))||"function"!=typeof c||2!==c.length)throw TypeError("invalid interceptor")}return new Proxy(this,{get:(a,b)=>"dispatch"===b?c:a[b]})}}a.exports=g},12600:(a,b,c)=>{let d,{extractBody:e,mixinBody:f,cloneBody:g,bodyUnusable:h}=c(35381),{Headers:i,fill:j,HeadersList:k,setHeadersGuard:l,getHeadersGuard:m,setHeadersList:n,getHeadersList:o}=c(28665),p=c(84285),q=c(57975),{isValidHTTPToken:r,sameOrigin:s,environmentSettingsObject:t}=c(42425),{forbiddenMethodsSet:u,corsSafeListedMethodsSet:v,referrerPolicy:w,requestRedirect:x,requestMode:y,requestCredentials:z,requestCache:A,requestDuplex:B}=c(19608),{kEnumerableProperty:C,normalizedMethodRecordsBase:D,normalizedMethodRecords:E}=p,{webidl:F}=c(32984),{URLSerializer:G}=c(16537),{kConstruct:H}=c(49176),I=c(34589),{getMaxListeners:J,setMaxListeners:K,defaultMaxListeners:L}=c(78474),M=Symbol("abortController"),N=new FinalizationRegistry(({signal:a,abort:b})=>{a.removeEventListener("abort",b)}),O=new WeakMap;try{d=J(new AbortController().signal)>0}catch{d=!1}function P(a){return function b(){let c=a.deref();if(void 0!==c){N.unregister(b),this.removeEventListener("abort",b),c.abort(this.reason);let a=O.get(c.signal);if(void 0!==a){if(0!==a.size){for(let b of a){let a=b.deref();void 0!==a&&a.abort(this.reason)}a.clear()}O.delete(c.signal)}}}}let Q=!1;class R{#b;#c;#d;#a;constructor(a,b){let c;if(F.util.markAsUncloneable(this),a===H)return;F.argumentLengthCheck(arguments,1,"Request constructor"),a=F.converters.RequestInfo(a),b=F.converters.RequestInit(b);let f=null,g=null;const m=t.settingsObject.baseUrl;let q=null;if("string"==typeof a){let c;this.#c=b.dispatcher;try{c=new URL(a,m)}catch(b){throw TypeError("Failed to parse URL from "+a,{cause:b})}if(c.username||c.password)throw TypeError("Request cannot be constructed from a URL that includes credentials: "+a);f=Y({urlList:[c]}),g="cors"}else I(F.is.Request(a)),f=a.#a,q=a.#b,this.#c=b.dispatcher||a.#c;const w=t.settingsObject.origin;let x="client";if(f.window?.constructor?.name==="EnvironmentSettingsObject"&&s(f.window,w)&&(x=f.window),null!=b.window)throw TypeError(`'window' option '${x}' must be null`);"window"in b&&(x="no-window"),f=Y({method:f.method,headersList:f.headersList,unsafeRequest:f.unsafeRequest,client:t.settingsObject,window:x,priority:f.priority,origin:f.origin,referrer:f.referrer,referrerPolicy:f.referrerPolicy,mode:f.mode,credentials:f.credentials,cache:f.cache,redirect:f.redirect,integrity:f.integrity,keepalive:f.keepalive,reloadNavigation:f.reloadNavigation,historyNavigation:f.historyNavigation,urlList:[...f.urlList]});const y=0!==Object.keys(b).length;if(y&&("navigate"===f.mode&&(f.mode="same-origin"),f.reloadNavigation=!1,f.historyNavigation=!1,f.origin="client",f.referrer="client",f.referrerPolicy="",f.url=f.urlList[f.urlList.length-1],f.urlList=[f.url]),void 0!==b.referrer){const a=b.referrer;if(""===a)f.referrer="no-referrer";else{let b;try{b=new URL(a,m)}catch(b){throw TypeError(`Referrer "${a}" is not a valid URL.`,{cause:b})}"about:"===b.protocol&&"client"===b.hostname||w&&!s(b,t.settingsObject.baseUrl)?f.referrer="client":f.referrer=b}}if(void 0!==b.referrerPolicy&&(f.referrerPolicy=b.referrerPolicy),"navigate"===(c=void 0!==b.mode?b.mode:g))throw F.errors.exception({header:"Request constructor",message:"invalid request mode navigate."});if(null!=c&&(f.mode=c),void 0!==b.credentials&&(f.credentials=b.credentials),void 0!==b.cache&&(f.cache=b.cache),"only-if-cached"===f.cache&&"same-origin"!==f.mode)throw TypeError("'only-if-cached' can be set only with 'same-origin' mode");if(void 0!==b.redirect&&(f.redirect=b.redirect),null!=b.integrity&&(f.integrity=String(b.integrity)),void 0!==b.keepalive&&(f.keepalive=!!b.keepalive),void 0!==b.method){let a=b.method;const c=E[a];if(void 0!==c)f.method=c;else{if(!r(a))throw TypeError(`'${a}' is not a valid HTTP method.`);const b=a.toUpperCase();if(u.has(b))throw TypeError(`'${a}' HTTP method is unsupported.`);a=D[b]??a,f.method=a}Q||"patch"!==f.method||(process.emitWarning("Using `patch` is highly likely to result in a `405 Method Not Allowed`. `PATCH` is much more likely to succeed.",{code:"UNDICI-FETCH-patch"}),Q=!0)}void 0!==b.signal&&(q=b.signal),this.#a=f;const z=new AbortController;if(this.#b=z.signal,null!=q)if(q.aborted)z.abort(q.reason);else{this[M]=z;const a=P(new WeakRef(z));d&&J(q)===L&&K(1500,q),p.addAbortListener(q,a),N.register(z,{signal:q,abort:a},a)}if(this.#d=new i(H),n(this.#d,f.headersList),l(this.#d,"request"),"no-cors"===c){if(!v.has(f.method))throw TypeError(`'${f.method} is unsupported in no-cors mode.`);l(this.#d,"request-no-cors")}if(y){const a=o(this.#d),c=void 0!==b.headers?b.headers:new k(a);if(a.clear(),c instanceof k){for(const{name:b,value:d}of c.rawValues())a.append(b,d,!1);a.cookies=c.cookies}else j(this.#d,c)}const A=F.is.Request(a)?a.#a.body:null;if((null!=b.body||null!=A)&&("GET"===f.method||"HEAD"===f.method))throw TypeError("Request with GET/HEAD method cannot have body.");let B=null;if(null!=b.body){const[a,c]=e(b.body,f.keepalive);B=a,c&&!o(this.#d).contains("content-type",!0)&&this.#d.append("content-type",c,!0)}const C=B??A;if(null!=C&&null==C.source){if(null!=B&&null==b.duplex)throw TypeError("RequestInit: duplex option is required when sending a body.");if("same-origin"!==f.mode&&"cors"!==f.mode)throw TypeError('If request is made from ReadableStream, mode should be "same-origin" or "cors"');f.useCORSPreflightFlag=!0}let G=C;if(null==B&&null!=A){if(h(a.#a))throw TypeError("Cannot construct a Request with a Request object that has already been used.");const b=new TransformStream;A.stream.pipeThrough(b),G={source:A.source,length:A.length,stream:b.readable}}this.#a.body=G}get method(){return F.brandCheck(this,R),this.#a.method}get url(){return F.brandCheck(this,R),G(this.#a.url)}get headers(){return F.brandCheck(this,R),this.#d}get destination(){return F.brandCheck(this,R),this.#a.destination}get referrer(){return(F.brandCheck(this,R),"no-referrer"===this.#a.referrer)?"":"client"===this.#a.referrer?"about:client":this.#a.referrer.toString()}get referrerPolicy(){return F.brandCheck(this,R),this.#a.referrerPolicy}get mode(){return F.brandCheck(this,R),this.#a.mode}get credentials(){return F.brandCheck(this,R),this.#a.credentials}get cache(){return F.brandCheck(this,R),this.#a.cache}get redirect(){return F.brandCheck(this,R),this.#a.redirect}get integrity(){return F.brandCheck(this,R),this.#a.integrity}get keepalive(){return F.brandCheck(this,R),this.#a.keepalive}get isReloadNavigation(){return F.brandCheck(this,R),this.#a.reloadNavigation}get isHistoryNavigation(){return F.brandCheck(this,R),this.#a.historyNavigation}get signal(){return F.brandCheck(this,R),this.#b}get body(){return F.brandCheck(this,R),this.#a.body?this.#a.body.stream:null}get bodyUsed(){return F.brandCheck(this,R),!!this.#a.body&&p.isDisturbed(this.#a.body.stream)}get duplex(){return F.brandCheck(this,R),"half"}clone(){if(F.brandCheck(this,R),h(this.#a))throw TypeError("unusable");let a=Z(this.#a),b=new AbortController;if(this.signal.aborted)b.abort(this.signal.reason);else{let a=O.get(this.signal);void 0===a&&(a=new Set,O.set(this.signal,a));let c=new WeakRef(b);a.add(c),p.addAbortListener(b.signal,P(c))}return $(a,this.#c,b.signal,m(this.#d))}[q.inspect.custom](a,b){null===b.depth&&(b.depth=2),b.colors??=!0;let c={method:this.method,url:this.url,headers:this.headers,destination:this.destination,referrer:this.referrer,referrerPolicy:this.referrerPolicy,mode:this.mode,credentials:this.credentials,cache:this.cache,redirect:this.redirect,integrity:this.integrity,keepalive:this.keepalive,isReloadNavigation:this.isReloadNavigation,isHistoryNavigation:this.isHistoryNavigation,signal:this.signal};return`Request ${q.formatWithOptions(b,c)}`}static setRequestSignal(a,b){return a.#b=b,a}static getRequestDispatcher(a){return a.#c}static setRequestDispatcher(a,b){a.#c=b}static setRequestHeaders(a,b){a.#d=b}static getRequestState(a){return a.#a}static setRequestState(a,b){a.#a=b}}let{setRequestSignal:S,getRequestDispatcher:T,setRequestDispatcher:U,setRequestHeaders:V,getRequestState:W,setRequestState:X}=R;function Y(a){return{method:a.method??"GET",localURLsOnly:a.localURLsOnly??!1,unsafeRequest:a.unsafeRequest??!1,body:a.body??null,client:a.client??null,reservedClient:a.reservedClient??null,replacesClientId:a.replacesClientId??"",window:a.window??"client",keepalive:a.keepalive??!1,serviceWorkers:a.serviceWorkers??"all",initiator:a.initiator??"",destination:a.destination??"",priority:a.priority??null,origin:a.origin??"client",policyContainer:a.policyContainer??"client",referrer:a.referrer??"client",referrerPolicy:a.referrerPolicy??"",mode:a.mode??"no-cors",useCORSPreflightFlag:a.useCORSPreflightFlag??!1,credentials:a.credentials??"same-origin",useCredentials:a.useCredentials??!1,cache:a.cache??"default",redirect:a.redirect??"follow",integrity:a.integrity??"",cryptoGraphicsNonceMetadata:a.cryptoGraphicsNonceMetadata??"",parserMetadata:a.parserMetadata??"",reloadNavigation:a.reloadNavigation??!1,historyNavigation:a.historyNavigation??!1,userActivation:a.userActivation??!1,taintedOrigin:a.taintedOrigin??!1,redirectCount:a.redirectCount??0,responseTainting:a.responseTainting??"basic",preventNoCacheCacheControlHeaderModification:a.preventNoCacheCacheControlHeaderModification??!1,done:a.done??!1,timingAllowFailed:a.timingAllowFailed??!1,useURLCredentials:a.useURLCredentials??void 0,traversableForUserPrompts:a.traversableForUserPrompts??"client",urlList:a.urlList,url:a.urlList[0],headersList:a.headersList?new k(a.headersList):new k}}function Z(a){let b=Y({...a,body:null});return null!=a.body&&(b.body=g(a.body)),b}function $(a,b,c,d){let e=new R(H);X(e,a),U(e,b),S(e,c);let f=new i(H);return V(e,f),n(f,a.headersList),l(f,d),e}Reflect.deleteProperty(R,"setRequestSignal"),Reflect.deleteProperty(R,"getRequestDispatcher"),Reflect.deleteProperty(R,"setRequestDispatcher"),Reflect.deleteProperty(R,"setRequestHeaders"),Reflect.deleteProperty(R,"getRequestState"),Reflect.deleteProperty(R,"setRequestState"),f(R,W),Object.defineProperties(R.prototype,{method:C,url:C,headers:C,redirect:C,clone:C,signal:C,duplex:C,destination:C,body:C,bodyUsed:C,isHistoryNavigation:C,isReloadNavigation:C,keepalive:C,integrity:C,cache:C,credentials:C,attribute:C,referrerPolicy:C,referrer:C,mode:C,[Symbol.toStringTag]:{value:"Request",configurable:!0}}),F.is.Request=F.util.MakeTypeAssertion(R),F.converters.RequestInfo=function(a){return"string"==typeof a?F.converters.USVString(a):F.is.Request(a)?a:F.converters.USVString(a)},F.converters.RequestInit=F.dictionaryConverter([{key:"method",converter:F.converters.ByteString},{key:"headers",converter:F.converters.HeadersInit},{key:"body",converter:F.nullableConverter(F.converters.BodyInit)},{key:"referrer",converter:F.converters.USVString},{key:"referrerPolicy",converter:F.converters.DOMString,allowedValues:w},{key:"mode",converter:F.converters.DOMString,allowedValues:y},{key:"credentials",converter:F.converters.DOMString,allowedValues:z},{key:"cache",converter:F.converters.DOMString,allowedValues:A},{key:"redirect",converter:F.converters.DOMString,allowedValues:x},{key:"integrity",converter:F.converters.DOMString},{key:"keepalive",converter:F.converters.boolean},{key:"signal",converter:F.nullableConverter(a=>F.converters.AbortSignal(a,"RequestInit","signal"))},{key:"window",converter:F.converters.any},{key:"duplex",converter:F.converters.DOMString,allowedValues:B},{key:"dispatcher",converter:F.converters.any},{key:"priority",converter:F.converters.DOMString,allowedValues:["high","low","auto"],defaultValue:()=>"auto"}]),a.exports={Request:R,makeRequest:Y,fromInnerRequest:$,cloneRequest:Z,getRequestDispatcher:T,getRequestState:W}},16537:(a,b,c)=>{let d=c(34589),{forgivingBase64:e,collectASequenceOfCodePoints:f,collectASequenceOfCodePointsFast:g,isomorphicDecode:h,removeASCIIWhitespace:i,removeChars:j}=c(70745),k=new TextEncoder,l=/^[-!#$%&'*+.^_|~A-Za-z0-9]+$/u,m=/[\u000A\u000D\u0009\u0020]/u,n=/^[\u0009\u0020-\u007E\u0080-\u00FF]+$/u;function o(a,b=!1){if(!b)return a.href;let c=a.href,d=a.hash.length,e=0===d?c:c.substring(0,c.length-d);return!d&&c.endsWith("#")?e.slice(0,-1):e}function p(a){return function(a){let b=a.length,c=new Uint8Array(b),d=0,e=0;for(;e<b;){let b=a[e];37!==b?c[d++]=b:37!==b||q(a[e+1])&&q(a[e+2])?(c[d++]=r(a[e+1])<<4|r(a[e+2]),e+=2):c[d++]=37,++e}return b===d?c:c.subarray(0,d)}(k.encode(a))}function q(a){return a>=48&&a<=57||a>=65&&a<=70||a>=97&&a<=102}function r(a){return a>=48&&a<=57?a-48:(223&a)-55}function s(a){a=v(a,!0,!0);let b={position:0},c=g("/",a,b);if(0===c.length||!l.test(c)||b.position>=a.length)return"failure";b.position++;let d=g(";",a,b);if(0===(d=v(d,!1,!0)).length||!l.test(d))return"failure";let e=c.toLowerCase(),h=d.toLowerCase(),i={type:e,subtype:h,parameters:new Map,essence:`${e}/${h}`};for(;b.position<a.length;){b.position++,f(a=>m.test(a),a,b);let c=f(a=>";"!==a&&"="!==a,a,b);if(c=c.toLowerCase(),b.position<a.length){if(";"===a[b.position])continue;b.position++}if(b.position>=a.length)break;let d=null;if('"'===a[b.position])d=t(a,b,!0),g(";",a,b);else if(0===(d=v(d=g(";",a,b),!1,!0)).length)continue;0!==c.length&&l.test(c)&&(0===d.length||n.test(d))&&!i.parameters.has(c)&&i.parameters.set(c,d)}return i}function t(a,b,c=!1){let e=b.position,g="";for(d('"'===a[b.position]),b.position++;g+=f(a=>'"'!==a&&"\\"!==a,a,b),!(b.position>=a.length);){let c=a[b.position];if(b.position++,"\\"===c){if(b.position>=a.length){g+="\\";break}g+=a[b.position],b.position++}else{d('"'===c);break}}return c?g:a.slice(e,b.position)}function u(a){return 13===a||10===a||9===a||32===a}function v(a,b=!0,c=!0){return j(a,b,c,u)}a.exports={dataURLProcessor:function(a){d("data:"===a.protocol);let b=o(a,!0);b=b.slice(5);let c={position:0},f=g(",",b,c),j=f.length;if(f=i(f,!0,!0),c.position>=b.length)return"failure";c.position++;let k=p(b.slice(j+1));if(/;(?:\u0020*)base64$/ui.test(f)){if("failure"===(k=e(h(k))))return"failure";f=(f=(f=f.slice(0,-6)).replace(/(\u0020+)$/u,"")).slice(0,-1)}f.startsWith(";")&&(f="text/plain"+f);let l=s(f);return"failure"===l&&(l=s("text/plain;charset=US-ASCII")),{mimeType:l,body:k}},URLSerializer:o,stringPercentDecode:p,parseMIMEType:s,collectAnHTTPQuotedString:t,serializeAMimeType:function(a){d("failure"!==a);let{parameters:b,essence:c}=a,e=c;for(let[a,c]of b.entries())e+=";",e+=a,e+="=",l.test(c)||(c='"'+(c=c.replace(/[\\"]/ug,"\\$&"))+'"'),e+=c;return e},removeHTTPWhitespace:v,minimizeSupportedMimeType:function(a){switch(a.essence){case"application/ecmascript":case"application/javascript":case"application/x-ecmascript":case"application/x-javascript":case"text/ecmascript":case"text/javascript":case"text/javascript1.0":case"text/javascript1.1":case"text/javascript1.2":case"text/javascript1.3":case"text/javascript1.4":case"text/javascript1.5":case"text/jscript":case"text/livescript":case"text/x-ecmascript":case"text/x-javascript":return"text/javascript";case"application/json":case"text/json":return"application/json";case"image/svg+xml":return"image/svg+xml";case"text/xml":case"application/xml":return"application/xml"}return a.subtype.endsWith("+json")?"application/json":a.subtype.endsWith("+xml")?"application/xml":""},HTTP_TOKEN_CODEPOINTS:l}},16712:(a,b,c)=>{let d=c(34589),{AsyncResource:e}=c(16698),{Readable:f}=c(1712),{InvalidArgumentError:g,RequestAbortedError:h}=c(61448),i=c(84285);function j(){}class k extends e{constructor(a,b){if(!a||"object"!=typeof a)throw new g("invalid opts");const{signal:c,method:d,opaque:e,body:f,onInfo:k,responseHeaders:l,highWaterMark:m}=a;try{if("function"!=typeof b)throw new g("invalid callback");if(m&&("number"!=typeof m||m<0))throw new g("invalid highWaterMark");if(c&&"function"!=typeof c.on&&"function"!=typeof c.addEventListener)throw new g("signal must be an EventEmitter or EventTarget");if("CONNECT"===d)throw new g("invalid method");if(k&&"function"!=typeof k)throw new g("invalid onInfo callback");super("UNDICI_REQUEST")}catch(a){throw i.isStream(f)&&i.destroy(f.on("error",j),a),a}this.method=d,this.responseHeaders=l||null,this.opaque=e||null,this.callback=b,this.res=null,this.abort=null,this.body=f,this.trailers={},this.context=null,this.onInfo=k||null,this.highWaterMark=m,this.reason=null,this.removeAbortListener=null,c?.aborted?this.reason=c.reason??new h:c&&(this.removeAbortListener=i.addAbortListener(c,()=>{this.reason=c.reason??new h,this.res?i.destroy(this.res.on("error",j),this.reason):this.abort&&this.abort(this.reason)}))}onConnect(a,b){this.reason?a(this.reason):(d(this.callback),this.abort=a,this.context=b)}onHeaders(a,b,c,d){let{callback:e,opaque:g,abort:h,context:k,responseHeaders:l,highWaterMark:m}=this,n="raw"===l?i.parseRawHeaders(b):i.parseHeaders(b);if(a<200){this.onInfo&&this.onInfo({statusCode:a,headers:n});return}let o="raw"===l?i.parseHeaders(b):n,p=o["content-type"],q=o["content-length"],r=new f({resume:c,abort:h,contentType:p,contentLength:"HEAD"!==this.method&&q?Number(q):null,highWaterMark:m});if(this.removeAbortListener&&(r.on("close",this.removeAbortListener),this.removeAbortListener=null),this.callback=null,this.res=r,null!==e)try{this.runInAsyncScope(e,null,null,{statusCode:a,statusText:d,headers:n,trailers:this.trailers,opaque:g,body:r,context:k})}catch(a){this.res=null,i.destroy(r.on("error",j),a),queueMicrotask(()=>{throw a})}}onData(a){return this.res.push(a)}onComplete(a){i.parseHeaders(a,this.trailers),this.res.push(null)}onError(a){let{res:b,callback:c,body:d,opaque:e}=this;c&&(this.callback=null,queueMicrotask(()=>{this.runInAsyncScope(c,null,a,{opaque:e})})),b&&(this.res=null,queueMicrotask(()=>{i.destroy(b.on("error",j),a)})),d&&(this.body=null,i.isStream(d)&&(d.on("error",j),i.destroy(d,a))),this.removeAbortListener&&(this.removeAbortListener(),this.removeAbortListener=null)}}a.exports=function a(b,c){if(void 0===c)return new Promise((c,d)=>{a.call(this,b,(a,b)=>a?d(a):c(b))});try{let a=new k(b,c);this.dispatch(b,a)}catch(d){if("function"!=typeof c)throw d;let a=b?.opaque;queueMicrotask(()=>c(d,{opaque:a}))}},a.exports.RequestHandler=k},17181:(a,b,c)=>{var d,e,f,g,h,i=Object.defineProperty,j=Object.getOwnPropertyDescriptor,k=Object.getOwnPropertyNames,l=Object.prototype.hasOwnProperty,m={},n={Headers:()=>F,RequestError:()=>u,Response:()=>N,Session:()=>P,Transport:()=>O,WebSocket:()=>ao,createSession:()=>ab,createTransport:()=>aa,default:()=>aq,fetch:()=>_,get:()=>ag,getOperatingSystems:()=>af,getProfiles:()=>ae,post:()=>ah,request:()=>ad,websocket:()=>ap,withSession:()=>ac};for(var o in n)i(m,o,{get:n[o],enumerable:!0});a.exports=((a,b,c,d)=>{if(b&&"object"==typeof b||"function"==typeof b)for(let e of k(b))l.call(a,e)||e===c||i(a,e,{get:()=>b[e],enumerable:!(d=j(b,e))||d.enumerable});return a})(i({},"__esModule",{value:!0}),m);var p=c(55511),q=c(81630),r=c(8086),s=c(27910),t=c(94175),u=class extends TypeError{constructor(a){super(a),this.name="RequestError"}},v={},w=v.url?(0,r.createRequire)(v.url):(0,r.createRequire)(__filename);d=function(){let a=process.platform,b=process.arch,c=function(){if("linux"!==process.platform)return;let a=process.env.LIBC??process.env.npm_config_libc;if(a)return a.toLowerCase().includes("musl")?"musl":"gnu";try{let a=process.report?.getReport?.();if(a?.header?.glibcVersionRuntime)return"gnu";return"musl"}catch{return"gnu"}}(),d={darwin:{x64:"darwin-x64",arm64:"darwin-arm64"},linux:{x64:{gnu:"linux-x64-gnu",musl:"linux-x64-musl"},arm64:"linux-arm64-gnu"},win32:{x64:"win32-x64-msvc"}}[a]?.[b],e="string"==typeof d?d:d?.[c??"gnu"];if(!e)throw Error(`Unsupported platform: ${a}-${b}${c?`-${c}`:""}. Supported platforms: darwin-x64, darwin-arm64, linux-x64-gnu, linux-x64-musl, linux-arm64-gnu, win32-x64-msvc`);let f=`wreq-js.${e}.node`;try{return w(`../rust/${f}`)}catch{try{return w("../rust/wreq-js.node")}catch{throw Error(`Failed to load native module for ${a}-${b}. Tried: ../rust/${f} and ../rust/wreq-js.node. Make sure the package is installed correctly and the native module is built for your platform.`)}}}();var x="function"==typeof FinalizationRegistry?new FinalizationRegistry(a=>{d.websocketClose(a).catch(()=>void 0)}):void 0,y="function"==typeof FinalizationRegistry?new FinalizationRegistry(a=>{if(!a.released){a.released=!0;try{d.cancelBody(a.id)}catch{}}}):void 0,z="chrome_142",A="macos",B=["windows","macos","linux","android","ios"],C=new TextDecoder("utf-8"),D=0;function E(a){if("object"!=typeof a||null===a)return!1;let b=Object.getPrototypeOf(a);return b===Object.prototype||null===b}var F=class a{store=new Map;constructor(a){a&&this.applyInit(a)}applyInit(b){if(b instanceof a){for(let[a,c]of b)this.append(a,c);return}if(Array.isArray(b)||b&&"function"==typeof b[Symbol.iterator]){for(let a of b){if(!a)continue;let[b,c]=a;this.append(b,c)}return}if(E(b))for(let[a,c]of Object.entries(b))null!=c&&this.set(a,String(c))}normalizeName(a){if("string"!=typeof a)throw TypeError("Header name must be a string");let b=a.trim();if(!b)throw TypeError("Header name must not be empty");return{key:b.toLowerCase(),display:b}}assertValue(a){if(null==a)throw TypeError("Header value must not be null or undefined");return String(a)}append(a,b){let c=this.normalizeName(a),d=this.store.get(c.key),e=this.assertValue(b);d?d.values.push(e):this.store.set(c.key,{name:c.display,values:[e]})}set(a,b){let c=this.normalizeName(a),d=this.assertValue(b);this.store.set(c.key,{name:c.display,values:[d]})}get(a){let b=this.normalizeName(a),c=this.store.get(b.key);return c?c.values.join(", "):null}has(a){let b=this.normalizeName(a);return this.store.has(b.key)}delete(a){let b=this.normalizeName(a);this.store.delete(b.key)}entries(){return this[Symbol.iterator]()}*keys(){for(let[a]of this)yield a}*values(){for(let[,a]of this)yield a}forEach(a,b){for(let[c,d]of this)a.call(b,d,c,this)}[Symbol.iterator](){return function*(a){for(let b of a.values())yield[b.name,b.values.join(", ")]}(this.store)}toObject(){let a={};for(let[b,c]of this)a[b]=c;return a}toTuples(){let a=[];for(let[b,c]of this)a.push([b,c]);return a}};function G(a){return new F(a).toTuples()}function H(a,b){if(!a)return!1;let c=b.toLowerCase();for(let[b]of a)if(b.toLowerCase()===c)return!0;return!1}function I(a){if(a&&H(G(a),"Sec-WebSocket-Protocol"))throw new u("Do not set `Sec-WebSocket-Protocol` header manually; use the `protocols` option instead.")}function J(a){if(void 0!==a)return"string"==typeof a?[a]:[...a]}function K(a){return{status:a.status,headers:a.headers.map(([a,b])=>[a,b]),bodyHandle:a.bodyHandle,bodyBytes:a.bodyBytes,contentLength:a.contentLength,cookies:a.cookies.map(([a,b])=>[a,b]),url:a.url}}function L(a){if(!a.released){a.released=!0;try{d.cancelBody(a.id)}catch{}y?.unregister(a)}}function M(a){let b=new t.ReadableStream({async pull(b){try{let c=await d.readBodyChunk(a.id);if(null===c){L(a),b.close();return}b.enqueue(c)}catch(c){L(a),b.error(c)}},cancel(){L(a)}});return y?.register(b,a,a),b}var N=class a{status;ok;contentLength;url;type="basic";bodyUsed=!1;payload;requestUrl;redirectedMemo;headersInit;headersInstance;cookiesInit;cookiesRecord;inlineBody;bodySource;bodyStream;nativeHandleAvailable;nativeHandle;constructor(a,b,c){this.payload=a,this.requestUrl=b,this.status=this.payload.status,this.ok=this.status>=200&&this.status<300,this.headersInit=this.payload.headers,this.headersInstance=null,this.url=this.payload.url,this.cookiesInit=this.payload.cookies,this.cookiesRecord=null,this.contentLength=this.payload.contentLength??null,this.inlineBody=this.payload.bodyBytes??null,this.nativeHandle=null,void 0!==c?(this.bodySource=c,this.nativeHandleAvailable=!1):null!==this.inlineBody?(this.bodySource=null,this.nativeHandleAvailable=!1):null!==this.payload.bodyHandle?(this.bodySource=null,this.nativeHandleAvailable=!0,this.nativeHandle={id:this.payload.bodyHandle,released:!1},y?.register(this,this.nativeHandle,this.nativeHandle)):(this.bodySource=null,this.nativeHandleAvailable=!1),this.bodyStream=void 0}get redirected(){if(void 0!==this.redirectedMemo)return this.redirectedMemo;if(this.url===this.requestUrl)return this.redirectedMemo=!1,!1;let a=function(a){try{return new URL(a).toString()}catch{return null}}(this.requestUrl);return this.redirectedMemo=!a||this.url!==a,this.redirectedMemo}get statusText(){return q.STATUS_CODES[this.status]??""}get headers(){return this.headersInstance||(this.headersInstance=new F(this.headersInit)),this.headersInstance}get cookies(){if(!this.cookiesRecord){let a=Object.create(null);for(let[b,c]of this.cookiesInit){let d=a[b];void 0===d?a[b]=c:Array.isArray(d)?d.push(c):a[b]=[d,c]}this.cookiesRecord=a}return this.cookiesRecord}get body(){var a,b;let c,d;if(this.inlineBody&&null===this.bodySource){let a=this.inlineBody;this.inlineBody=null,this.bodySource=new t.ReadableStream({start(b){b.enqueue(a),b.close()}})}if(null===this.inlineBody&&null===this.payload.bodyHandle&&null===this.bodySource)return null;if(null===this.bodySource&&this.nativeHandleAvailable&&null!==this.payload.bodyHandle){this.nativeHandle&&y?.unregister(this.nativeHandle);let a=this.nativeHandle??{id:this.payload.bodyHandle,released:!1};this.nativeHandle=a,this.bodySource=M(a),this.nativeHandleAvailable=!1}return null===this.bodySource?null:(void 0===this.bodyStream&&(this.bodyStream=(a=this.bodySource,b=()=>{this.bodyUsed=!0},c=!1,d=null,new t.ReadableStream({async pull(e){c||(c=!0,b()),d||(d=a.getReader());try{let{done:a,value:b}=await d.read();if(a)return void e.close();e.enqueue(b)}catch(a){e.error(a)}},cancel:b=>d?d.cancel(b):a.cancel(b)}))),this.bodyStream)}async json(){return JSON.parse(await this.text())}async arrayBuffer(){let a=await this.consumeBody(),{buffer:b,byteOffset:c,byteLength:d}=a;if(b instanceof ArrayBuffer)return 0===c&&d===b.byteLength?b:b.slice(c,c+d);let e=new Uint8Array(d);return e.set(a),e.buffer}async text(){let a=await this.consumeBody();return C.decode(a)}async blob(){let a=await this.consumeBody(),b=this.headers.get("content-type")??"";return new Blob([a],b?{type:b}:void 0)}async formData(){let a=await this.consumeBody(),b=this.headers.get("content-type");return new globalThis.Response(a,b?{headers:{"content-type":b}}:void 0).formData()}readable(){this.assertBodyAvailable(),this.bodyUsed=!0;let a=this.body;return null===a?s.Readable.from([]):s.Readable.fromWeb(a)}clone(){if(this.bodyUsed)throw TypeError("Cannot clone a Response whose body is already used");if(this.nativeHandleAvailable&&null!==this.payload.bodyHandle){this.nativeHandle&&y?.unregister(this.nativeHandle);let a=this.nativeHandle??{id:this.payload.bodyHandle,released:!1};this.nativeHandle=a,this.bodySource=M(a),this.nativeHandleAvailable=!1}if(null===this.bodySource)return new a(K(this.payload),this.requestUrl,null);let[b,c]=this.bodySource.tee();return this.bodySource=b,this.bodyStream=void 0,new a(K(this.payload),this.requestUrl,c)}assertBodyAvailable(){if(this.bodyUsed)throw TypeError("Response body is already used")}async consumeBody(){if(this.assertBodyAvailable(),this.bodyUsed=!0,this.inlineBody){let a=this.inlineBody;return this.inlineBody=null,a}if(this.nativeHandleAvailable&&null!==this.payload.bodyHandle){this.nativeHandleAvailable=!1;try{return await d.readBodyAll(this.payload.bodyHandle)}catch(a){if(String(a).includes("Body handle")&&String(a).includes("not found"))return Buffer.alloc(0);throw a}finally{var a;this.nativeHandle&&((a=this.nativeHandle).released||(a.released=!0,y?.unregister(a)))}}let b=this.body;if(!b)return Buffer.alloc(0);let c=b.getReader(),e=[];for(;;){let{done:a,value:b}=await c.read();if(a)break;b&&b.byteLength>0&&(Buffer.isBuffer(b)?e.push(b):e.push(Buffer.from(b.buffer,b.byteOffset,b.byteLength)))}return 0===e.length?Buffer.alloc(0):Buffer.concat(e)}},O=class{id;disposed=!1;constructor(a){this.id=a}get closed(){return this.disposed}async close(){if(!this.disposed){this.disposed=!0;try{d.dropTransport(this.id)}catch(a){throw new u(String(a))}}}},P=class{id;disposed=!1;defaults;constructor(a,b){this.id=a,this.defaults=b}get closed(){return this.disposed}ensureActive(){if(this.disposed)throw new u("Session has been closed")}getDefaults(){let a={...this.defaults};return this.defaults.defaultHeaders&&(a.defaultHeaders=[...this.defaults.defaultHeaders]),a}_defaultsRef(){return this.defaults}async fetch(a,b){return this.ensureActive(),_(a,b?{...b,session:this}:{session:this})}async clearCookies(){this.ensureActive();try{d.clearSession(this.id)}catch(a){throw new u(String(a))}}getCookies(a){this.ensureActive();try{return d.getCookies(this.id,String(a))}catch(a){throw new u(String(a))}}setCookie(a,b,c){this.ensureActive();try{d.setCookie(this.id,a,b,String(c))}catch(a){throw new u(String(a))}}async websocket(a,b){this.ensureActive();let c=function(a,b){if("string"==typeof a||a instanceof URL){let c=al(b);return{url:ai(a),options:c,legacyCallbacks:am(b)}}let c=al(a);return{url:ai(a.url),options:c,legacyCallbacks:am(a)}}(a,b);aj(c.options.protocols),I(c.options.headers);let e=J(c.options.protocols),f=this.defaults.transportId;if(!f)throw new u("Session has no transport. Create the session with browser/os options or pass a transport to use session.websocket().");return ao._connectWithInit({_internal:!0,url:c.url,options:c.options,openDispatchMode:"deferred",connect:a=>d.websocketConnectSession({url:c.url,sessionId:this.id,transportId:f,headers:G(c.options.headers??{}),...e&&e.length>0&&{protocols:e},onMessage:a.onMessage,onClose:a.onClose,onError:a.onError}),legacyCallbacks:c.legacyCallbacks})}async close(){if(this.disposed)return;this.disposed=!0;let a=this.defaults.transportId,b=this.defaults.ownsTransport;try{d.dropSession(this.id)}catch(c){if(!b||!a)throw new u(String(c));try{d.dropTransport(a)}catch{}throw new u(String(c))}if(b&&a)try{d.dropTransport(a)}catch(a){throw new u(String(a))}}};function Q(a){let b="string"==typeof a?a:"The operation was aborted";if("u">typeof DOMException&&a instanceof DOMException)return"AbortError"===a.name?a:new DOMException(a.message||b,"AbortError");if(a instanceof Error){let b=Error(a.message);return b.name="AbortError",b.cause=a,b}if("u">typeof DOMException)return new DOMException(b,"AbortError");let c=Error(b);return c.name="AbortError",c}var R=Math.trunc(Number(process.hrtime.bigint()%BigInt(0x1000000000000-1)))+1;function S(){return(R+=1)>=0x1000000000000&&(R=1),R}function T(a){if(a instanceof URL)return a.href;if(0===a.length)throw new u("URL is required");if(a.charCodeAt(0)>32&&a.charCodeAt(a.length-1)>32)return a;let b=a.trim();if(0===b.length)throw new u("URL is required");return b}async function U(a,b){if(!(a&&"object"==typeof a&&("u">typeof Request&&a instanceof Request||"string"==typeof a.url&&"string"==typeof a.method&&"function"==typeof a.arrayBuffer&&"string"==typeof a.redirect)))return{url:T(a),init:b??{}};let c=b?{...b}:{};if(void 0===c.method&&(c.method=a.method),void 0===c.headers&&(c.headers=a.headers),void 0===c.redirect&&("follow"===a.redirect||"manual"===a.redirect||"error"===a.redirect)&&(c.redirect=a.redirect),void 0===c.signal&&(c.signal=a.signal),void 0===c.body&&null!==a.body){if(a.bodyUsed)throw TypeError("Request body is already used");c.body=Buffer.from(await a.arrayBuffer())}return{url:T(a.url),init:c}}async function V(a){if(null==a)return{};if("string"==typeof a)return{body:Buffer.from(a,"utf8")};if(Buffer.isBuffer(a))return{body:a};if(a instanceof URLSearchParams)return{body:Buffer.from(a.toString(),"utf8"),contentType:"application/x-www-form-urlencoded;charset=UTF-8"};if(a instanceof ArrayBuffer)return{body:Buffer.from(a)};if(ArrayBuffer.isView(a))return{body:Buffer.from(a.buffer,a.byteOffset,a.byteLength)};if("u">typeof Blob&&a instanceof Blob)return{body:Buffer.from(await a.arrayBuffer()),...a.type?{contentType:a.type}:{}};if("u">typeof FormData&&a instanceof FormData){let b=new globalThis.Response(a),c=b.headers.get("content-type")??void 0;return{body:Buffer.from(await b.arrayBuffer()),...c?{contentType:c}:{}}}throw TypeError("Unsupported body type; expected string, Buffer, ArrayBuffer, ArrayBufferView, URLSearchParams, Blob, or FormData")}function W(a){if(void 0!==a){if("string"!=typeof a||0===a.trim().length)throw new u("Browser profile must not be empty");if(!(f||(f=new Set(ae())),f).has(a))throw new u(`Invalid browser profile: ${a}. Available profiles: ${ae().join(", ")}`)}}function X(a){if(void 0!==a){if("string"!=typeof a||0===a.trim().length)throw new u("Operating system must not be empty");if(!(h||(h=new Set(af())),h).has(a))throw new u(`Invalid operating system: ${a}. Available options: ${af().join(", ")}`)}}function Y(a){if(void 0!==a){if("number"!=typeof a||!Number.isFinite(a))throw new u("Timeout must be a finite number");if(a<0)throw new u("Timeout must be 0 (no timeout) or a positive number")}}function Z(a,b){if("number"!=typeof a||!Number.isFinite(a))throw new u(`${b} must be a finite number`);if(a<=0)throw new u(`${b} must be greater than 0`)}async function $(a,b,c){let e;if(!c){let c,e=S();try{c=await d.request(a,e,!1)}catch(a){if(a instanceof u)throw a;throw new u(String(a))}return new N(c,b)}let f=S(),g=function(a,b){let c;if(!a)return null;if(a.aborted)throw b(),Q(a.reason);return{promise:new Promise((d,e)=>{c=()=>{b(),e(Q(a.reason))},a.addEventListener("abort",c,{once:!0})}),cleanup:()=>{c&&(a.removeEventListener("abort",c),c=void 0)}}}(c,()=>{try{d.cancelRequest(f)}catch{}}),h=Promise.race([d.request(a,f,!0),g.promise]);try{e=await h}catch(a){if(a&&"string"==typeof a.name&&"AbortError"===a.name||a instanceof u)throw a;throw new u(String(a))}finally{g.cleanup()}return new N(e,b)}async function _(a,b){let c=await U(a,b),d=c.url,e=c.init,f=function(a){let b=a.cookieMode??"ephemeral",c=a.session,d="string"==typeof a.sessionId?a.sessionId.trim():void 0;if(c&&d)throw new u("Provide either `session` or `sessionId`, not both.");if(c){if(!(c instanceof P))throw new u("`session` must be created via createSession()");if(c.closed)throw new u("Session has been closed");return{sessionId:c.id,cookieMode:"session",dropAfterRequest:!1,defaults:c._defaultsRef()}}if(d){if(!d)throw new u("sessionId must not be empty");if("ephemeral"===b)throw new u("cookieMode 'ephemeral' cannot be combined with sessionId");return{sessionId:d,cookieMode:"session",dropAfterRequest:!1}}if("session"===b)throw new u("cookieMode 'session' requires a session or sessionId");return{sessionId:`_e${++D}`,cookieMode:"ephemeral",dropAfterRequest:!0}}(e),g=f.defaults;var h=e.redirect;if(void 0!==h&&"follow"!==h&&"manual"!==h&&"error"!==h)throw new u(`Redirect mode '${h}' is not supported`);void 0!==e.timeout&&Y(e.timeout);let i=function(a){if(void 0===a||0===a.length)return"GET";switch(a){case"GET":case"POST":case"PUT":case"DELETE":case"PATCH":case"HEAD":case"OPTIONS":return a}let b=a.trim().toUpperCase();return b.length>0?b:"GET"}(e.method),j=await V(e.body??null),k=j.body;if(void 0!==k&&("GET"===i||"HEAD"===i))throw new u(`Request with ${i} method cannot have a body`);let l=function(a,b){if(!a)return void 0===b?void 0:G(b);if(void 0===b)return a;let c=G(b);if(0===c.length)return a;let d=new Set;for(let a of c)d.add(a[0].toLowerCase());let e=[];for(let b of a)d.has(b[0].toLowerCase())||e.push(b);for(let a of c)e.push(a);return e}(g?.defaultHeaders,e.headers);j.contentType&&!H(l,"content-type")&&(l||(l=[]),l.push(["Content-Type",j.contentType]));let m=function(a,b){if(void 0!==a.transport){if(!(a.transport instanceof O))throw new u("`transport` must be created via createTransport()");if(a.transport.closed)throw new u("Transport has been closed");let b=void 0!==a.proxy;if(void 0!==a.browser||void 0!==a.os||b||void 0!==a.insecure)throw new u("`transport` cannot be combined with browser/os/proxy/insecure options");return{transportId:a.transport.id}}if(b?.transportId){if(void 0!==a.browser&&(W(a.browser),a.browser!==b.browser))throw new u("Session browser cannot be changed after creation");if(void 0!==a.os&&(X(a.os),a.os!==b.os))throw new u("Session operating system cannot be changed after creation");let c=Object.hasOwn(a,"proxy"),d=c?a.proxy:void 0;if(c&&void 0!==d&&(b.proxy??null)!==(d??null))throw new u("Session proxy cannot be changed after creation");if(void 0!==a.insecure){let c=b.insecure??!1;if(a.insecure!==c)throw new u("Session insecure setting cannot be changed after creation")}return{transportId:b.transportId}}let c=a.browser??z,d=a.os??A;W(c),X(d);let e={browser:c,os:d};return void 0!==a.proxy&&(e.proxy=a.proxy),void 0!==a.insecure&&(e.insecure=a.insecure),e}(e,g),n=e.timeout??g?.timeout??3e5,o={url:d,method:i,sessionId:f.sessionId,ephemeral:f.dropAfterRequest};return void 0!==k&&(o.body=k),m.transportId?o.transportId=m.transportId:(o.browser=m.browser??z,o.os=m.os??A,void 0!==m.proxy&&(o.proxy=m.proxy),void 0!==m.insecure&&(o.insecure=m.insecure)),o.timeout=n,void 0!==e.redirect&&(o.redirect=e.redirect),void 0!==e.disableDefaultHeaders&&(o.disableDefaultHeaders=e.disableDefaultHeaders),void 0!==e.compress&&(o.compress=e.compress),l&&l.length>0&&(o.headers=l),$(o,d,e.signal??null)}async function aa(a){let b=a?.browser??z,c=a?.os??A;W(b),X(c),a?.poolIdleTimeout!==void 0&&Z(a.poolIdleTimeout,"poolIdleTimeout"),a?.poolMaxIdlePerHost!==void 0&&function(a,b){if("number"!=typeof a||!Number.isFinite(a)||!Number.isInteger(a))throw new u(`${b} must be an integer`);if(a<0)throw new u(`${b} must be greater than or equal to 0`)}(a.poolMaxIdlePerHost,"poolMaxIdlePerHost"),a?.poolMaxSize!==void 0&&function(a,b){if("number"!=typeof a||!Number.isFinite(a)||!Number.isInteger(a))throw new u(`${b} must be an integer`);if(a<=0)throw new u(`${b} must be greater than 0`)}(a.poolMaxSize,"poolMaxSize"),a?.connectTimeout!==void 0&&Z(a.connectTimeout,"connectTimeout"),a?.readTimeout!==void 0&&Z(a.readTimeout,"readTimeout");try{let e=d.createTransport({browser:b,os:c,...a?.proxy!==void 0&&{proxy:a.proxy},...a?.insecure!==void 0&&{insecure:a.insecure},...a?.poolIdleTimeout!==void 0&&{poolIdleTimeout:a.poolIdleTimeout},...a?.poolMaxIdlePerHost!==void 0&&{poolMaxIdlePerHost:a.poolMaxIdlePerHost},...a?.poolMaxSize!==void 0&&{poolMaxSize:a.poolMaxSize},...a?.connectTimeout!==void 0&&{connectTimeout:a.connectTimeout},...a?.readTimeout!==void 0&&{readTimeout:a.readTimeout}});return new O(e)}catch(a){throw new u(String(a))}}async function ab(a){let b,c,e,f,{sessionId:g,defaults:h}=(e=a?.sessionId??(0,p.randomUUID)(),f={browser:a?.browser??z,os:a?.os??A},a?.proxy!==void 0&&(f.proxy=a.proxy),a?.timeout!==void 0&&(Y(a.timeout),f.timeout=a.timeout),a?.insecure!==void 0&&(f.insecure=a.insecure),a?.defaultHeaders!==void 0&&(f.defaultHeaders=G(a.defaultHeaders)),{sessionId:e,defaults:f});W(h.browser),X(h.os);try{c=d.createTransport({browser:h.browser,os:h.os,...void 0!==h.proxy&&{proxy:h.proxy},...void 0!==h.insecure&&{insecure:h.insecure}})}catch(a){throw new u(String(a))}try{b=d.createSession({sessionId:g})}catch(a){try{d.dropTransport(c)}catch{}throw new u(String(a))}return h.transportId=c,h.ownsTransport=!0,new P(b,h)}async function ac(a,b){let c=await ab(b);try{return await a(c)}finally{await c.close()}}async function ad(a){if(!a.url)throw new u("URL is required");let{url:b,...c}=a,d={};return void 0!==c.method&&(d.method=c.method),void 0!==c.headers&&(d.headers=c.headers),void 0!==c.body&&(d.body=c.body),void 0!==c.browser&&(d.browser=c.browser),void 0!==c.os&&(d.os=c.os),void 0!==c.proxy&&(d.proxy=c.proxy),void 0!==c.timeout&&(d.timeout=c.timeout),void 0!==c.sessionId&&(d.sessionId=c.sessionId),void 0!==c.transport&&(d.transport=c.transport),void 0!==c.insecure&&(d.insecure=c.insecure),void 0!==c.disableDefaultHeaders&&(d.disableDefaultHeaders=c.disableDefaultHeaders),void 0!==c.redirect&&(d.redirect=c.redirect),void 0!==c.signal&&(d.signal=c.signal),void 0!==c.session&&(d.session=c.session),void 0!==c.cookieMode?d.cookieMode=c.cookieMode:!0===c.ephemeral&&(d.cookieMode="ephemeral"),_(b,d)}function ae(){return e||(e=d.getProfiles()),e}function af(){if(!g){let a=d.getOperatingSystems?.();g=a&&a.length>0?a:[...B]}return g}async function ag(a,b){let c={};return b&&Object.assign(c,b),c.method="GET",_(a,c)}async function ah(a,b,c){let d={};return c&&Object.assign(d,c),d.method="POST",void 0!==b&&(d.body=b),_(a,d)}function ai(a){let b,c=String(a).trim();if(!c)throw new u("URL is required");try{b=new URL(c)}catch(a){throw new u(String(a))}if(b.hash)throw new u("WebSocket URL must not include a hash fragment");if("http:"===b.protocol?b.protocol="ws:":"https:"===b.protocol&&(b.protocol="wss:"),"ws:"!==b.protocol&&"wss:"!==b.protocol)throw new u("expected a ws: or wss: url");return b.toString()}function aj(a){if(void 0===a)return;let b=new Set,c=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/;for(let d of"string"==typeof a?[a]:a){if("string"!=typeof d||0===d.length)throw new u("WebSocket protocol values must be non-empty strings");if(!c.test(d))throw new u(`Invalid WebSocket protocol value: ${d}`);if(b.has(d))throw new u(`Duplicate WebSocket protocol: ${d}`);b.add(d)}}function ak(a){let b={};if(!a)return b;if(void 0!==a.browser&&(b.browser=a.browser),void 0!==a.os&&(b.os=a.os),void 0!==a.headers&&(b.headers=a.headers),void 0!==a.proxy&&(b.proxy=a.proxy),void 0!==a.protocols&&(b.protocols=a.protocols),void 0!==a.binaryType){if("nodebuffer"!==a.binaryType&&"arraybuffer"!==a.binaryType&&"blob"!==a.binaryType)throw new u("binaryType must be one of: 'nodebuffer', 'arraybuffer', 'blob'");b.binaryType=a.binaryType}return b}function al(a){let b={};if(!a)return b;if(void 0!==a.browser)throw new u("`browser` is not supported in session.websocket(); the session controls browser emulation.");if(void 0!==a.os)throw new u("`os` is not supported in session.websocket(); the session controls OS emulation.");if(void 0!==a.proxy)throw new u("`proxy` is not supported in session.websocket(); the session transport controls proxying.");if(void 0!==a.headers&&(b.headers=a.headers),void 0!==a.protocols&&(b.protocols=a.protocols),void 0!==a.binaryType){if("nodebuffer"!==a.binaryType&&"arraybuffer"!==a.binaryType&&"blob"!==a.binaryType)throw new u("binaryType must be one of: 'nodebuffer', 'arraybuffer', 'blob'");b.binaryType=a.binaryType}return b}function am(a){if(!E(a))return;let b={};return"function"==typeof a.onMessage&&(b.onMessage=a.onMessage),"function"==typeof a.onClose&&(b.onClose=a.onClose),"function"==typeof a.onError&&(b.onError=a.onError),Object.keys(b).length>0?b:void 0}function an(a){return"open"===a||"message"===a||"close"===a||"error"===a}var ao=class a{static CONNECTING=0;static OPEN=1;static CLOSING=2;static CLOSED=3;url;protocol="";extensions="";readyState=a.CONNECTING;_binaryType="nodebuffer";_bufferedAmount=0;_onopen=null;_onmessage=null;_onclose=null;_onerror=null;_onHandlerOrder={open:-1,message:-1,close:-1,error:-1};_listenerOrderCounter=0;_listeners={open:new Map,message:new Map,close:new Map,error:new Map};_legacyCallbacks;_openDispatchMode;_connection;_connectPromise;_closeOptions;_finalizerToken;_openEventDispatched=!1;_openEventQueued=!1;_closeEventDispatched=!1;_nativeCloseStarted=!1;_pendingMessages=[];_sendChain=Promise.resolve();constructor(b,c,d){let e;e=!function(a){return!!E(a)&&!0===a._internal&&"string"==typeof a.url&&"function"==typeof a.connect}(b)?a.buildStandaloneInit(b,c,d):b,this.url=e.url,this.binaryType=e.options.binaryType??"nodebuffer",this._legacyCallbacks=e.legacyCallbacks,this._openDispatchMode=e.openDispatchMode,this._connectPromise=this.connect(e.connect),this._connectPromise.catch(()=>void 0)}get binaryType(){return this._binaryType}set binaryType(a){("arraybuffer"===a||"blob"===a||"nodebuffer"===a)&&(this._binaryType=a)}get bufferedAmount(){return this._bufferedAmount}get onopen(){return this._onopen}set onopen(a){this._onopen=a,this._onHandlerOrder.open=a?++this._listenerOrderCounter:-1}get onmessage(){return this._onmessage}set onmessage(a){this._onmessage=a,this._onHandlerOrder.message=a?++this._listenerOrderCounter:-1}get onclose(){return this._onclose}set onclose(a){this._onclose=a,this._onHandlerOrder.close=a?++this._listenerOrderCounter:-1}get onerror(){return this._onerror}set onerror(a){this._onerror=a,this._onHandlerOrder.error=a?++this._listenerOrderCounter:-1}static async _connectWithInit(b){let c=new a(b);return await c._waitUntilConnected(),c.scheduleOpenEventAfterAwait(),c}static buildStandaloneInit(a,b,c){let e="string"==typeof b||Array.isArray(b)?c:b??c,f=ak(e);aj("string"==typeof b||Array.isArray(b)?b:f.protocols),I(f.headers),W(f.browser);let g=f.os??A;X(g);let h=f.browser??z,i=J("string"==typeof b||Array.isArray(b)?b:f.protocols);return{_internal:!0,url:ai(a),options:f,openDispatchMode:"automatic",connect:b=>d.websocketConnect({url:ai(a),browser:h,os:g,headers:G(f.headers??{}),...i&&i.length>0&&{protocols:i},...void 0!==f.proxy&&{proxy:f.proxy},onMessage:b.onMessage,onClose:b.onClose,onError:b.onError}),legacyCallbacks:am(e)}}async connect(b){try{let c=await b({onMessage:a=>{this.handleNativeMessage(a)},onClose:a=>{this.handleNativeClose(a)},onError:a=>{this.handleNativeError(a)}});if(this._connection=c,this.protocol=c.protocol??"",this.extensions=c.extensions??"",x&&(this._finalizerToken=c,x.register(this,c,c)),this.readyState===a.CLOSING)return void this.startNativeClose();this.readyState=a.OPEN,"automatic"===this._openDispatchMode&&this.scheduleOpenEventAfterConnect()}catch(a){throw this.handleNativeError(String(a)),this.finalizeClosed({code:1006,reason:""},!1),new u(String(a))}}_waitUntilConnected(){return this._connectPromise}scheduleOpenEventAfterConnect(){this.scheduleOpenEventWithDepth(2)}scheduleOpenEventAfterAwait(){this.scheduleOpenEventWithDepth(3)}scheduleOpenEventWithDepth(b){if(this._openEventDispatched||this._openEventQueued||this.readyState!==a.OPEN)return;this._openEventQueued=!0;let c=b=>{if(0===b){if(this._openEventQueued=!1,this._openEventDispatched||this.readyState!==a.OPEN)return;this._openEventDispatched=!0,this.dispatchOpenEvent();return}queueMicrotask(()=>{c(b-1)})};c(b)}releaseConnectionTracking(){this._finalizerToken&&x&&(x.unregister(this._finalizerToken),this._finalizerToken=void 0)}toMessageEventData(a){if("string"==typeof a)return a;if("arraybuffer"===this._binaryType){let b=new ArrayBuffer(a.byteLength);return new Uint8Array(b).set(a),b}return"blob"===this._binaryType?new Blob([a]):a}invokeListener(a,b){try{"function"==typeof a?a.call(this,b):a.handleEvent(b)}catch{}}createBaseEvent(a){return{type:a,isTrusted:!1,timeStamp:Date.now(),target:this,currentTarget:this}}getOnHandler(a){switch(a){case"open":return this._onopen;case"message":return this._onmessage;case"close":return this._onclose;case"error":return this._onerror;default:return null}}getOnHandlerOrder(a){return this._onHandlerOrder[a]}getListenerMap(a){return this._listeners[a]}dispatchEvent(a,b){let c=this.getListenerMap(a),d=this.getOnHandler(a);if(0===c.size&&!d)return;let e=[];for(let a of c.values())e.push({order:a.order,listener:a.listener,once:a.once});for(let c of(d&&e.push({order:this.getOnHandlerOrder(a),listener:d,once:!1}),e.sort((a,b)=>a.order-b.order),e))c.once&&this.removeEventListener(a,c.listener),this.invokeListener(c.listener,b)}dispatchOpenEvent(){let a=this.createBaseEvent("open");if(this.dispatchEvent("open",a),!this._closeEventDispatched&&this._pendingMessages.length>0){let a=this._pendingMessages;for(let b of(this._pendingMessages=[],a))this.dispatchMessageEvent(this.toMessageEventData(b))}}dispatchMessageEvent(a){let b={...this.createBaseEvent("message"),data:a};this.dispatchEvent("message",b)}dispatchCloseEvent(a){this.dispatchEvent("close",a)}dispatchErrorEvent(a){let b={...this.createBaseEvent("error"),...void 0!==a&&{message:a}};this.dispatchEvent("error",b)}handleNativeMessage(b){if(!this._closeEventDispatched){if(this._legacyCallbacks?.onMessage?.(b),!this._openEventDispatched&&this.readyState===a.OPEN)return void this._pendingMessages.push(b);this.dispatchMessageEvent(this.toMessageEventData(b))}}handleNativeError(a){this._legacyCallbacks?.onError?.(a),this.dispatchErrorEvent(a)}handleNativeClose(b){let c=this.readyState===a.CLOSING||1e3===b.code;this.finalizeClosed(b,c)}finalizeClosed(b,c){if(this._closeEventDispatched)return;this.readyState=a.CLOSED,this._closeEventDispatched=!0,this._pendingMessages=[],this.releaseConnectionTracking();let d={...this.createBaseEvent("close"),code:b.code,reason:b.reason,wasClean:c};this._legacyCallbacks?.onClose?.(d),this.dispatchCloseEvent(d)}startNativeClose(){if(this._nativeCloseStarted||!this._connection)return;this._nativeCloseStarted=!0;let a=this._connection,b=this._closeOptions;d.websocketClose(a,b).catch(a=>{this.handleNativeError(String(a)),this.finalizeClosed({code:1006,reason:""},!1)})}addEventListener(a,b,c){if(!b||!an(a)||"function"!=typeof b&&("object"!=typeof b||null===b||"function"!=typeof b.handleEvent))return;let d=this.getListenerMap(a);if(d.has(b))return;let e="boolean"==typeof c?{}:c??{},f=!0===e.once,g=e.signal;if(g?.aborted)return;let h={listener:b,order:++this._listenerOrderCounter,once:f};if(g){let c=()=>{this.removeEventListener(a,b)};h.abortSignal=g,h.abortHandler=c,g.addEventListener("abort",c,{once:!0})}d.set(b,h)}removeEventListener(a,b){if(!b||!an(a)||"function"!=typeof b&&"object"!=typeof b)return;let c=this.getListenerMap(a),d=c.get(b);d&&(d.abortSignal&&d.abortHandler&&d.abortSignal.removeEventListener("abort",d.abortHandler),c.delete(b))}getSendByteLength(a){if("string"==typeof a)return Buffer.byteLength(a);if(Buffer.isBuffer(a)||a instanceof ArrayBuffer||ArrayBuffer.isView(a))return a.byteLength;if("u">typeof Blob&&a instanceof Blob)return a.size;throw TypeError("WebSocket data must be a string, Buffer, ArrayBuffer, ArrayBufferView, or Blob")}async normalizeSendPayload(a){if("string"==typeof a||Buffer.isBuffer(a))return a;if(a instanceof ArrayBuffer)return Buffer.from(a);if(ArrayBuffer.isView(a))return Buffer.from(a.buffer,a.byteOffset,a.byteLength);if("u">typeof Blob&&a instanceof Blob)return Buffer.from(await a.arrayBuffer());throw TypeError("WebSocket data must be a string, Buffer, ArrayBuffer, ArrayBufferView, or Blob")}send(b){if(this.readyState!==a.OPEN||!this._connection)throw new u("WebSocket is not open");let c=this.getSendByteLength(b),e=this._connection;this._bufferedAmount+=c;let f=async()=>{try{let a=await this.normalizeSendPayload(b);await d.websocketSend(e,a)}catch(a){this.handleNativeError(String(a)),this.finalizeClosed({code:1006,reason:""},!1)}finally{this._bufferedAmount=Math.max(0,this._bufferedAmount-c)}};this._sendChain=this._sendChain.then(f,f)}close(b,c){this.readyState!==a.CLOSING&&this.readyState!==a.CLOSED&&(this._closeOptions=function(a,b){if(void 0===a&&void 0===b)return;if(void 0===a)throw new u("A close code is required when providing a close reason");if(!Number.isInteger(a))throw new u("Close code must be an integer");if(1e3!==a&&(a<3e3||a>4999))throw new u("Close code must be 1000 or in range 3000-4999");let c=b??"";if(Buffer.byteLength(c,"utf8")>123)throw new u("Close reason must be 123 bytes or fewer");return{code:a,reason:c}}(b,c),this.readyState=a.CLOSING,this.startNativeClose())}};async function ap(a,b){let c=function(a,b){if("string"==typeof a||a instanceof URL){let c=ak(b);return{url:ai(a),options:c,legacyCallbacks:am(b)}}let c=ak(a);return{url:ai(a.url),options:c,legacyCallbacks:am(a)}}(a,b);aj(c.options.protocols),I(c.options.headers),W(c.options.browser);let e=c.options.os??A;X(e);let f=c.options.browser??z,g=J(c.options.protocols);return ao._connectWithInit({_internal:!0,url:c.url,options:c.options,openDispatchMode:"deferred",connect:a=>d.websocketConnect({url:c.url,browser:f,os:e,headers:G(c.options.headers??{}),...g&&g.length>0&&{protocols:g},...void 0!==c.options.proxy&&{proxy:c.options.proxy},onMessage:a.onMessage,onClose:a.onClose,onError:a.onError}),legacyCallbacks:c.legacyCallbacks})}var aq={fetch:_,request:ad,get:ag,post:ah,getProfiles:ae,getOperatingSystems:af,createTransport:aa,createSession:ab,withSession:ac,websocket:ap,WebSocket:ao,Headers:F,Response:N,Transport:O,Session:P,RequestError:u}},19071:(a,b,c)=>{let{kConnected:d,kPending:e,kRunning:f,kSize:g,kFree:h,kQueued:i}=c(49176);class j{constructor(a){this.connected=a[d],this.pending=a[e],this.running=a[f],this.size=a[g]}}class k{constructor(a){this.connected=a[d],this.free=a[h],this.pending=a[e],this.queued=a[i],this.running=a[f],this.size=a[g]}}a.exports={ClientStats:j,PoolStats:k}},19431:(a,b,c)=>{let d=c(34589),{Readable:e}=c(57075),f=c(84285),g=c(89409),h=c(38650),i=c(56698),{assertCacheStore:j,assertCacheMethods:k,makeCacheKey:l,normalizeHeaders:m,parseCacheControlHeader:n}=c(79468),{AbortError:o}=c(61448),p=()=>{};function q(a,b,c,g,h,i){let j=f.isStream(c.body)?c.body:e.from(c.body??[]);d(!j.destroyed,"stream should not be destroyed"),d(!j.readableDidRead,"stream should not be readableDidRead");let k={resume(){j.resume()},pause(){j.pause()},get paused(){return j.isPaused()},get aborted(){return j.destroyed},get reason(){return j.errored},abort(a){j.destroy(a??new o)}};if(j.on("error",function(b){if(!this.readableEnded)if("function"==typeof a.onResponseError)a.onResponseError(k,b);else throw b}).on("close",function(){this.errored||a.onResponseEnd?.(k,{})}),a.onRequestStart?.(k,h),j.destroyed)return;let l={...c.headers,age:String(g)};i&&(l.warning='110 - "response is stale"'),a.onResponseStart?.(k,c.statusCode,l,c.statusMessage),"HEAD"===b.method?j.destroy():j.on("data",function(b){a.onResponseData?.(k,b)})}function r(a,b,c,d,e,h,j){var k,l,m;let n;if(!j){if(h?.["only-if-cached"]){let a=!1;try{if("function"==typeof d.onConnect&&(d.onConnect(()=>{a=!0}),a)||"function"==typeof d.onHeaders&&(d.onHeaders(504,[],p,"Gateway Timeout"),a))return;"function"==typeof d.onComplete&&d.onComplete([])}catch(a){"function"==typeof d.onError&&d.onError(a)}return!0}return a(e,new g(b,c,d))}let o=Date.now();if(o>j.deleteAt)return a(e,new g(b,c,d));let r=Math.round((o-j.cachedAt)/1e3);if(h?.["max-age"]&&r>=h["max-age"])return a(e,d);let s=(k=j,l=h,(n=Date.now())>k.staleAt?!l?.["max-stale"]||n>k.staleAt+1e3*l["max-stale"]:!!l?.["min-fresh"]&&k.staleAt-n<=1e3*l["min-fresh"]),t=function(a,b,{headers:c={}}){return!!(b?.["no-cache"]||a.cacheControlDirectives?.["no-cache"]&&!Array.isArray(a.cacheControlDirectives["no-cache"]))||!!c["if-modified-since"]||!!c["if-none-match"]}(j,h,e);if(s||t){let k;if(f.isStream(e.body)&&0!==f.bodyLength(e.body))return a(e,new g(b,c,d));if(!t&&(m=j,(k=m.cacheControlDirectives?.["stale-while-revalidate"])&&Date.now()<=m.staleAt+1e3*k))return q(d,e,j,r,null,!0),queueMicrotask(()=>{let d={...e.headers,"if-modified-since":new Date(j.cachedAt).toUTCString()};if(j.etag&&(d["if-none-match"]=j.etag),j.vary)for(let a in j.vary)null!=j.vary[a]&&(d[a]=j.vary[a]);a({...e,headers:d},new g(b,c,{onRequestStart(){},onRequestUpgrade(){},onResponseStart(){},onResponseData(){},onResponseEnd(){},onResponseError(){}}))}),!0;let l=!1,n=j.cacheControlDirectives["stale-if-error"]??h?.["stale-if-error"];n&&(l=o<j.staleAt+1e3*n);let u={...e.headers,"if-modified-since":new Date(j.cachedAt).toUTCString()};if(j.etag&&(u["if-none-match"]=j.etag),j.vary)for(let a in j.vary)null!=j.vary[a]&&(u[a]=j.vary[a]);return a({...e,headers:u},new i((a,b)=>{a?q(d,e,j,r,b,s):f.isStream(j.body)&&j.body.on("error",p).destroy()},new g(b,c,d),l))}f.isStream(e.body)&&e.body.on("error",p).destroy(),q(d,e,j,r,null,!1)}a.exports=(a={})=>{let{store:b=new h,methods:c=["GET"],cacheByDefault:d,type:e="shared",origins:g}=a;if("object"!=typeof a||null===a)throw TypeError(`expected type of opts to be an Object, got ${null===a?"null":typeof a}`);j(b,"opts.store"),k(c,"opts.methods");var i="opts.origins";if(void 0!==g){if(!Array.isArray(g))throw TypeError(`expected ${i} to be an array or undefined, got ${typeof g}`);for(let a=0;a<g.length;a++){let b=g[a];if("string"!=typeof b&&!(b instanceof RegExp))throw TypeError(`expected ${i}[${a}] to be a string or RegExp, got ${typeof b}`)}}if(void 0!==d&&"number"!=typeof d)throw TypeError(`expected opts.cacheByDefault to be number or undefined, got ${typeof d}`);if(void 0!==e&&"shared"!==e&&"private"!==e)throw TypeError(`expected opts.type to be shared, private, or undefined, got ${typeof e}`);let o={store:b,methods:c,cacheByDefault:d,type:e},p=f.safeHTTPMethods.filter(a=>!1===c.includes(a));return a=>(c,d)=>{if(!c.origin||p.includes(c.method))return a(c,d);if(void 0!==g){let b=c.origin.toString().toLowerCase(),e=!1;for(let a=0;a<g.length;a++){let c=g[a];if("string"==typeof c){if(c.toLowerCase()===b){e=!0;break}}else if(c.test(b)){e=!0;break}}if(!e)return a(c,d)}c={...c,headers:m(c)};let e=c.headers?.["cache-control"]?n(c.headers["cache-control"]):void 0;if(e?.["no-store"])return a(c,d);let f=l(c),h=b.get(f);return h&&"function"==typeof h.then?h.then(b=>r(a,o,f,d,c,e,b)):r(a,o,f,d,c,e,h)}}},19608:a=>{let b=["GET","HEAD","POST"],c=new Set(b),d=[301,302,303,307,308],e=new Set(d),f=["1","7","9","11","13","15","17","19","20","21","22","23","25","37","42","43","53","69","77","79","87","95","101","102","103","104","109","110","111","113","115","117","119","123","135","137","139","143","161","179","389","427","465","512","513","514","515","526","530","531","532","540","548","554","556","563","587","601","636","989","990","993","995","1719","1720","1723","2049","3659","4045","4190","5060","5061","6000","6566","6665","6666","6667","6668","6669","6679","6697","10080"],g=new Set(f),h=["no-referrer","no-referrer-when-downgrade","same-origin","origin","strict-origin","origin-when-cross-origin","strict-origin-when-cross-origin","unsafe-url"],i=["",...h],j=new Set(h),k=["GET","HEAD","OPTIONS","TRACE"],l=new Set(k),m=["CONNECT","TRACE","TRACK"],n=new Set(m),o=["audio","audioworklet","font","image","manifest","paintworklet","script","style","track","video","xslt",""],p=new Set(o);a.exports={subresource:o,forbiddenMethods:m,requestBodyHeader:["content-encoding","content-language","content-location","content-type","content-length"],referrerPolicy:i,requestRedirect:["follow","manual","error"],requestMode:["navigate","same-origin","no-cors","cors"],requestCredentials:["omit","same-origin","include"],requestCache:["default","no-store","reload","no-cache","force-cache","only-if-cached"],redirectStatus:d,corsSafeListedMethods:b,nullBodyStatus:[101,204,205,304],safeMethods:k,badPorts:f,requestDuplex:["half"],subresourceSet:p,badPortsSet:g,redirectStatusSet:e,corsSafeListedMethodsSet:c,safeMethodsSet:l,forbiddenMethodsSet:n,referrerPolicyTokens:j}},20146:(a,b)=>{Object.defineProperty(b,"__esModule",{value:!0}),b.ReceiveBuffer=void 0;class c{constructor(a=4096){this.buffer=Buffer.allocUnsafe(a),this.offset=0,this.originalSize=a}get length(){return this.offset}append(a){if(!Buffer.isBuffer(a))throw Error("Attempted to append a non-buffer instance to ReceiveBuffer.");if(this.offset+a.length>=this.buffer.length){let b=this.buffer;this.buffer=Buffer.allocUnsafe(Math.max(this.buffer.length+this.originalSize,this.buffer.length+a.length)),b.copy(this.buffer)}return a.copy(this.buffer,this.offset),this.offset+=a.length}peek(a){if(a>this.offset)throw Error("Attempted to read beyond the bounds of the managed internal data.");return this.buffer.slice(0,a)}get(a){if(a>this.offset)throw Error("Attempted to read beyond the bounds of the managed internal data.");let b=Buffer.allocUnsafe(a);return this.buffer.slice(0,a).copy(b),this.buffer.copyWithin(0,a,a+this.offset-a),this.offset-=a,b}}b.ReceiveBuffer=c},20579:(a,b,c)=>{let d,{Writable:e}=c(57075),{assertCacheKey:f,assertCacheValue:g}=c(79468);a.exports=class{#e=2e9;#f=1/0;#g;#h;#i;#j;#k;#l;#m;#n;constructor(a){if(a){if("object"!=typeof a)throw TypeError("SqliteCacheStore options must be an object");if(void 0!==a.maxEntrySize){if("number"!=typeof a.maxEntrySize||!Number.isInteger(a.maxEntrySize)||a.maxEntrySize<0)throw TypeError("SqliteCacheStore options.maxEntrySize must be a non-negative integer");if(a.maxEntrySize>2e9)throw TypeError("SqliteCacheStore options.maxEntrySize must be less than 2gb");this.#e=a.maxEntrySize}if(void 0!==a.maxCount){if("number"!=typeof a.maxCount||!Number.isInteger(a.maxCount)||a.maxCount<0)throw TypeError("SqliteCacheStore options.maxCount must be a non-negative integer");this.#f=a.maxCount}}d||(d=c(80099).DatabaseSync),this.#g=new d(a?.location??":memory:"),this.#g.exec(`
|
|
3
3
|
PRAGMA journal_mode = WAL;
|
|
4
4
|
PRAGMA synchronous = NORMAL;
|