@superglue/cli 1.1.77 → 1.1.78

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/dist/cli.js CHANGED
@@ -514,7 +514,13 @@ References: https://docs.datahub.com/docs/features \u2014 product context; https
514
514
  - claude-3-5-sonnet-* (retired Oct 2025)
515
515
  - claude-3-opus-20240229 (retired Jan 2026)
516
516
  - claude-2.*, claude-3-sonnet-* (retired Jul 2025)
517
- `},openrouter:{name:"openrouter",apiUrl:"https://openrouter.ai/api/v1",regex:"^.*(openrouter|openrouter\\.ai).*$",icon:"openrouter",docsUrl:"https://openrouter.ai/docs",openApiUrl:"https://openrouter.ai/openapi.json",preferredAuthType:"api_key",keywords:["chat completions","completions","generation","models","embeddings","llm","ai","model routing","openai compatible"],systemSpecificInstructions:"OpenRouter is an OpenAI-compatible routing API \u2014 set baseURL/base_url to https://openrouter.ai/api/v1 when using OpenAI SDKs. Authentication is Bearer token (Authorization: Bearer <key>). Model names must include the provider prefix (e.g. openai/gpt-4o, anthropic/claude-3-5-sonnet); a bare model name silently uses the account default instead of erroring. OpenRouter also accepts optional HTTP-Referer and X-Title headers for dashboard attribution. Per-request generation metadata (cost, tokens, latency) is available after the call via GET /api/v1/generation?id=<generation_id> using the id field from the completion response."},pinecone:{name:"pinecone",apiUrl:"https://api.pinecone.io",regex:"^(.*\\.)?pinecone\\.io(/.*)?$",icon:"/logos/pinecone.svg",docsUrl:"https://docs.pinecone.io/reference",openApiUrl:"https://raw.githubusercontent.com/sigpwned/pinecone-openapi-spec/refs/heads/main/openapi.yml",preferredAuthType:"api_key",keywords:["indexes","vectors","upsert","collections","namespaces","metadata","embeddings","dimensions","pods","replicas","shards","api key"]},zoom:{name:"zoom",apiUrl:"https://api.zoom.us",regex:"^(.*\\.)?zoom\\.us(/.*)?$",icon:"zoom",docsUrl:"https://developers.zoom.us/docs/api",preferredAuthType:"oauth2",oauth:{authUrl:"https://zoom.us/oauth/authorize",tokenUrl:"https://zoom.us/oauth/token",scopes:"user:read user:write meeting:read meeting:write meeting:master recording:read recording:write webinar:read webinar:write chat_message:read chat_message:write chat_channel:read chat_channel:write contact:read report:read report:master dashboard:read"},keywords:["meetings","webinars","users","recordings","chat","channels","messages","participants","registrants","reports","dashboards","rooms","schedule","join","oauth"]},sharepoint:{name:"sharepoint",label:"SharePoint",apiUrl:"https://graph.microsoft.com",regex:"^.*(sharepoint|graph\\.microsoft\\.com.*(sites|drives|driveItem|lists)|learn\\.microsoft\\.com.*graph.*sharepoint).*$",icon:"sharepoint",docsUrl:"https://learn.microsoft.com/en-us/graph/api/resources/sharepoint",preferredAuthType:"oauth2",oauth:{authUrl:"https://login.microsoftonline.com/organizations/oauth2/v2.0/authorize",tokenUrl:"https://login.microsoftonline.com/organizations/oauth2/v2.0/token",scopes:"openid profile email offline_access User.Read Files.Read.All Sites.Read.All",client_id:"b4bf6bc2-5b30-4eea-b3eb-ca138d2d69fc",credentialTemplateId:"microsoft"},keywords:["sharepoint","sites","document libraries","files","folders","lists","drive items","microsoft graph","office 365","oauth"],systemSpecificInstructions:"SharePoint uses Microsoft Graph with a work or school account. Tenant policy can require administrator approval."},microsoftTeams:{name:"microsoftTeams",label:"Microsoft Teams",apiUrl:"https://graph.microsoft.com",regex:"^.*(microsoft.*teams|teams\\.microsoft\\.com|graph\\.microsoft\\.com.*(teams|chats|channels|chatMessage)|learn\\.microsoft\\.com.*graph.*teams).*$",icon:"/logos/microsoft_teams.svg",docsUrl:"https://learn.microsoft.com/en-us/graph/teams-concept-overview",preferredAuthType:"oauth2",oauth:{authUrl:"https://login.microsoftonline.com/common/oauth2/v2.0/authorize",tokenUrl:"https://login.microsoftonline.com/common/oauth2/v2.0/token",scopes:"openid profile email offline_access User.Read Team.ReadBasic.All Channel.ReadBasic.All Calendars.Read OnlineMeetings.Read",client_id:"b4bf6bc2-5b30-4eea-b3eb-ca138d2d69fc"},keywords:["microsoft teams","teams","team","channel","chat","message","conversation","microsoft graph","office 365","oauth"],systemSpecificInstructions:"Teams uses delegated Microsoft Graph access for work or school accounts. Some permissions require tenant administrator approval."},outlookMail:{name:"outlookMail",label:"Outlook",apiUrl:"https://graph.microsoft.com",regex:"^.*(outlook|graph\\.microsoft\\.com.*(messages|mailFolders|mailboxSettings)|learn\\.microsoft\\.com.*graph.*(mail|message)).*$",icon:"/logos/outlook.svg",docsUrl:"https://learn.microsoft.com/en-us/graph/api/resources/mail-api-overview",preferredAuthType:"oauth2",oauth:{authUrl:"https://login.microsoftonline.com/common/oauth2/v2.0/authorize",tokenUrl:"https://login.microsoftonline.com/common/oauth2/v2.0/token",scopes:"openid profile email offline_access User.Read Mail.ReadWrite",client_id:"b4bf6bc2-5b30-4eea-b3eb-ca138d2d69fc"},keywords:["outlook","email","mail","mailbox","messages","inbox","drafts","send","attachments","microsoft graph","office 365","oauth"],systemSpecificInstructions:"Use delegated Microsoft Graph permissions so access remains scoped to the signed-in user. The template defaults to openid profile email offline_access User.Read Mail.ReadWrite for reading mail and creating drafts. It intentionally omits Mail.Send. superglue provides a managed multi-tenant Microsoft app, so no Entra app registration is needed by default. A custom Entra Web app registration (with the exact OAuth callback URL for the current superglue deployment; copy the client secret Value rather than its Secret ID) is only needed when the organization requires single-tenant access \u2014 then use a tenant-specific authorization and token URL instead of /common. Tenant consent policies can require administrator approval even for delegated permissions. Never send email directly. Ask for approval before creating a draft."},microsoft:{name:"microsoft",apiUrl:"https://graph.microsoft.com",regex:"^.*(microsoft|graph\\.microsoft|office|outlook|live\\.com|sharepoint).*$",icon:"default",docsUrl:"https://learn.microsoft.com/en-us/graph/api/overview",preferredAuthType:"oauth2",oauth:{authUrl:"https://login.microsoftonline.com/common/oauth2/v2.0/authorize",tokenUrl:"https://login.microsoftonline.com/common/oauth2/v2.0/token",scopes:"User.Read User.ReadWrite Mail.Read Mail.ReadWrite Mail.Send Calendars.Read Calendars.ReadWrite Files.Read Files.ReadWrite Sites.Read.All Sites.ReadWrite.All Team.ReadBasic.All Chat.Read Chat.ReadWrite offline_access",client_id:"b4bf6bc2-5b30-4eea-b3eb-ca138d2d69fc"},keywords:["users","groups","mail","calendar","contacts","onedrive","sharepoint","teams","planner","tasks","drives","sites","lists","permissions","graph","oauth"],systemSpecificInstructions:"superglue provides a managed multi-tenant Microsoft app (work/school and personal accounts), so no Azure app registration is needed \u2014 authenticate directly via OAuth. The default scopes are user-consentable in most tenants; some delegated Graph permissions (e.g. ChannelMessage.Read.All, Group.ReadWrite.All) require Microsoft Entra administrator consent in the user's tenant, so add those only when the use case needs them. Conditional Access policies can require administrator involvement for other permissions. Always keep offline_access in scopes to receive refresh tokens for long-term access. A custom Entra Web app registration is only needed when an organization requires single-tenant access or its own app governance: register it with the exact OAuth callback URL of the current superglue deployment, use tenant-specific authorization and token URLs instead of /common, and copy the client secret Value, not the Secret ID."},dynamics365_sales:{name:"dynamics365_sales",apiUrl:"https://<<api_host>>/api/data/v9.2",regex:"^.*(crm\\d*\\.dynamics\\.com|dynamicscrm).*$",icon:"dynamics365",docsUrl:"https://learn.microsoft.com/en-us/power-apps/developer/data-platform/webapi/query-data-web-api",preferredAuthType:"oauth2",connectionFields:[{key:"api_host",label:"Environment host",placeholder:"contoso.crm.dynamics.com",required:!0}],oauth:{authUrl:"https://login.microsoftonline.com/common/oauth2/v2.0/authorize",tokenUrl:"https://login.microsoftonline.com/common/oauth2/v2.0/token",scopes:"https://<<api_host>>/user_impersonation offline_access",client_id:"b4bf6bc2-5b30-4eea-b3eb-ca138d2d69fc",credentialTemplateId:"microsoft",grant_type:"authorization_code"},keywords:["accounts","contacts","leads","opportunities","quotes","salesorders","salesorderdetails","products","incidents","campaigns","invoices","competitors","teams","systemusers","businessunits","odata","dynamics","crm","dynamics 365 sales","dataverse","oauth"],systemSpecificInstructions:`Dynamics 365 Sales \u2014 Dataverse Web API v9.2
517
+ `},openrouter:{name:"openrouter",apiUrl:"https://openrouter.ai/api/v1",regex:"^.*(openrouter|openrouter\\.ai).*$",icon:"openrouter",docsUrl:"https://openrouter.ai/docs",openApiUrl:"https://openrouter.ai/openapi.json",preferredAuthType:"api_key",keywords:["chat completions","completions","generation","models","embeddings","llm","ai","model routing","openai compatible"],systemSpecificInstructions:"OpenRouter is an OpenAI-compatible routing API \u2014 set baseURL/base_url to https://openrouter.ai/api/v1 when using OpenAI SDKs. Authentication is Bearer token (Authorization: Bearer <key>). Model names must include the provider prefix (e.g. openai/gpt-4o, anthropic/claude-3-5-sonnet); a bare model name silently uses the account default instead of erroring. OpenRouter also accepts optional HTTP-Referer and X-Title headers for dashboard attribution. Per-request generation metadata (cost, tokens, latency) is available after the call via GET /api/v1/generation?id=<generation_id> using the id field from the completion response."},pinecone:{name:"pinecone",apiUrl:"https://api.pinecone.io",regex:"^(.*\\.)?pinecone\\.io(/.*)?$",icon:"/logos/pinecone.svg",docsUrl:"https://docs.pinecone.io/reference",openApiUrl:"https://raw.githubusercontent.com/sigpwned/pinecone-openapi-spec/refs/heads/main/openapi.yml",preferredAuthType:"api_key",keywords:["indexes","vectors","upsert","collections","namespaces","metadata","embeddings","dimensions","pods","replicas","shards","api key"]},zoom:{name:"zoom",apiUrl:"https://api.zoom.us",regex:"^(.*\\.)?zoom\\.us(/.*)?$",icon:"zoom",docsUrl:"https://developers.zoom.us/docs/api",preferredAuthType:"oauth2",oauth:{authUrl:"https://zoom.us/oauth/authorize",tokenUrl:"https://zoom.us/oauth/token",scopes:"user:read user:write meeting:read meeting:write meeting:master recording:read recording:write webinar:read webinar:write chat_message:read chat_message:write chat_channel:read chat_channel:write contact:read report:read report:master dashboard:read"},keywords:["meetings","webinars","users","recordings","chat","channels","messages","participants","registrants","reports","dashboards","rooms","schedule","join","oauth"]},sharepoint:{name:"sharepoint",label:"SharePoint",apiUrl:"https://graph.microsoft.com",regex:"^.*(sharepoint|graph\\.microsoft\\.com.*(sites|drives|driveItem|lists)|learn\\.microsoft\\.com.*graph.*sharepoint).*$",icon:"sharepoint",docsUrl:"https://learn.microsoft.com/en-us/graph/api/resources/sharepoint",preferredAuthType:"oauth2",oauth:{authUrl:"https://login.microsoftonline.com/organizations/oauth2/v2.0/authorize",tokenUrl:"https://login.microsoftonline.com/organizations/oauth2/v2.0/token",scopes:"openid profile email offline_access User.Read Files.ReadWrite.All Sites.ReadWrite.All Sites.Manage.All",client_id:"b4bf6bc2-5b30-4eea-b3eb-ca138d2d69fc",credentialTemplateId:"microsoft"},keywords:["sharepoint","sites","document libraries","files","folders","lists","drive items","microsoft graph","office 365","oauth"],systemSpecificInstructions:"SharePoint uses Microsoft Graph with a work or school account. Tenant policy can require administrator approval. Add the admin-consent scope Group.ReadWrite.All only when strictly needed, for example to manage group-connected sites."},microsoftTeams:{name:"microsoftTeams",label:"Microsoft Teams",apiUrl:"https://graph.microsoft.com",regex:"^.*(microsoft.*teams|teams\\.microsoft\\.com|graph\\.microsoft\\.com.*(teams|chats|channels|chatMessage)|learn\\.microsoft\\.com.*graph.*teams).*$",icon:"/logos/microsoft_teams.svg",docsUrl:"https://learn.microsoft.com/en-us/graph/teams-concept-overview",preferredAuthType:"oauth2",oauth:{authUrl:"https://login.microsoftonline.com/common/oauth2/v2.0/authorize",tokenUrl:"https://login.microsoftonline.com/common/oauth2/v2.0/token",scopes:"openid profile email offline_access User.Read User.ReadBasic.All Team.ReadBasic.All Team.Create Channel.ReadBasic.All Channel.Create ChannelMessage.Read.All ChannelMessage.Send Chat.ReadWrite TeamMember.ReadWrite.All Group.ReadWrite.All Calendars.ReadWrite",client_id:"b4bf6bc2-5b30-4eea-b3eb-ca138d2d69fc",credentialTemplateId:"microsoft"},keywords:["microsoft teams","teams","team","channel","chat","message","conversation","microsoft graph","office 365","oauth"],systemSpecificInstructions:`Teams uses delegated Microsoft Graph access for work or school accounts. The default scopes include Channel.Create, ChannelMessage.Read.All, Group.ReadWrite.All and TeamMember.ReadWrite.All, which need tenant administrator consent; remove them when the tool does not need them and consent fails.
518
+
519
+ PAGINATION: Teams endpoints ignore $skip and $count. Page only with @odata.nextLink and call it verbatim; it already encodes $top, $filter and $orderby. Max $top is 50 for chats, chat messages, channel messages and replies (channel messages default to 20). /me/joinedTeams and /teams/{id}/allChannels accept no $top; read until @odata.nextLink is absent. In superglue use pagination { type: "cursorBased", pageSize: "50", cursorPath: "@odata.nextLink" } and build the whole URL in the step url so the cursor replaces it: url: "<<(sourceData) => sourceData.cursor || 'https://graph.microsoft.com/v1.0/chats/<chat-id>/messages?$top=50'>>". Leave queryParams empty so they are not re-applied to the nextLink. Do not pass cursor as an input variable; payload values override the pagination cursor on every page.
520
+
521
+ QUERY LIMITS: Chat messages support $orderby lastModifiedDateTime or createdDateTime (desc only) and $filter on the same property; $filter is ignored without the matching $orderby. Channel messages support only $top and $expand=replies (first 200 replies inline, more via replies@odata.nextLink) and are sorted by last activity of the whole reply chain, not by creation. /chats supports $expand=members (capped at 25 members) and $expand=lastMessagePreview.
522
+
523
+ RATE LIMITS: 429 with Retry-After. Per app per tenant: 1 request per second on a given chat or channel and 4 per second on a given team. Long backfills of one channel get throttled; keep page size at 50 and retry on Retry-After.`},outlookMail:{name:"outlookMail",label:"Outlook",apiUrl:"https://graph.microsoft.com",regex:"^.*(outlook|graph\\.microsoft\\.com.*(messages|mailFolders|mailboxSettings)|learn\\.microsoft\\.com.*graph.*(mail|message)).*$",icon:"/logos/outlook.svg",docsUrl:"https://learn.microsoft.com/en-us/graph/api/resources/mail-api-overview",preferredAuthType:"oauth2",oauth:{authUrl:"https://login.microsoftonline.com/common/oauth2/v2.0/authorize",tokenUrl:"https://login.microsoftonline.com/common/oauth2/v2.0/token",scopes:"openid profile email offline_access User.Read Mail.ReadWrite Mail.Send MailboxSettings.Read Contacts.ReadWrite Calendars.ReadWrite",client_id:"b4bf6bc2-5b30-4eea-b3eb-ca138d2d69fc",credentialTemplateId:"microsoft"},keywords:["outlook","email","mail","mailbox","messages","inbox","drafts","send","attachments","microsoft graph","office 365","oauth"],systemSpecificInstructions:"Outlook uses delegated Microsoft Graph access for work or school accounts. Some permissions require tenant administrator approval. Avoid requesting scopes that need admin consent unless the tool cannot work without them."},powerAutomate:{name:"powerAutomate",label:"Power Automate",apiUrl:"https://api.flow.microsoft.com",regex:"^.*(flow\\.microsoft\\.com|powerautomate|power-automate|api\\.powerplatform\\.com.*powerautomate|learn\\.microsoft\\.com.*power-automate).*$",icon:"/logos/power_automate.svg",docsUrl:"https://learn.microsoft.com/en-us/power-automate/manage-flows-with-code",preferredAuthType:"oauth2",oauth:{authUrl:"https://login.microsoftonline.com/common/oauth2/v2.0/authorize",tokenUrl:"https://login.microsoftonline.com/common/oauth2/v2.0/token",scopes:"openid profile email offline_access Activity.Read.All Approvals.Manage.All Approvals.Read.All Flows.Install Flows.Manage.All Flows.Read.All",client_id:"b4bf6bc2-5b30-4eea-b3eb-ca138d2d69fc",credentialTemplateId:"microsoft"},keywords:["power automate","flow","cloud flow","flow run","run history","activity","approval","approvals","approve","reject","trigger","environment","power platform","oauth"],systemSpecificInstructions:"Power Automate uses the delegated Flow service API with a work or school account."},microsoft:{name:"microsoft",apiUrl:"https://graph.microsoft.com",regex:"^.*(microsoft|graph\\.microsoft|office|outlook|live\\.com|sharepoint).*$",icon:"default",docsUrl:"https://learn.microsoft.com/en-us/graph/api/overview",preferredAuthType:"oauth2",oauth:{authUrl:"https://login.microsoftonline.com/common/oauth2/v2.0/authorize",tokenUrl:"https://login.microsoftonline.com/common/oauth2/v2.0/token",scopes:"openid profile email offline_access User.Read User.ReadBasic.All Mail.ReadWrite Mail.Send MailboxSettings.Read Calendars.ReadWrite Contacts.ReadWrite Files.ReadWrite.All Sites.ReadWrite.All Sites.Manage.All Notes.ReadWrite.All Tasks.ReadWrite Team.ReadBasic.All Team.Create Channel.ReadBasic.All ChannelMessage.Send Chat.ReadWrite",client_id:"b4bf6bc2-5b30-4eea-b3eb-ca138d2d69fc"},keywords:["users","groups","mail","calendar","contacts","onedrive","sharepoint","teams","planner","tasks","drives","sites","lists","permissions","graph","oauth"],systemSpecificInstructions:"superglue provides a managed multi-tenant Microsoft app (work/school and personal accounts), so no Azure app registration is needed \u2014 authenticate directly via OAuth. The default scopes are user-consentable in most tenants. Add the admin-consent scopes Channel.Create, ChannelMessage.Read.All, Group.ReadWrite.All and TeamMember.ReadWrite.All only when strictly needed. Conditional Access policies can require administrator involvement for other permissions. Always keep offline_access in scopes to receive refresh tokens for long-term access. A custom Entra Web app registration is only needed when an organization requires single-tenant access or its own app governance: register it with the exact OAuth callback URL of the current superglue deployment, use tenant-specific authorization and token URLs instead of /common, and copy the client secret Value, not the Secret ID."},dynamics365_sales:{name:"dynamics365_sales",apiUrl:"https://<<api_host>>/api/data/v9.2",regex:"^.*(crm\\d*\\.dynamics\\.com|dynamicscrm).*$",icon:"dynamics365",docsUrl:"https://learn.microsoft.com/en-us/power-apps/developer/data-platform/webapi/query-data-web-api",preferredAuthType:"oauth2",connectionFields:[{key:"api_host",label:"Environment host",placeholder:"contoso.crm.dynamics.com",required:!0}],oauth:{authUrl:"https://login.microsoftonline.com/common/oauth2/v2.0/authorize",tokenUrl:"https://login.microsoftonline.com/common/oauth2/v2.0/token",scopes:"https://<<api_host>>/user_impersonation offline_access",client_id:"b4bf6bc2-5b30-4eea-b3eb-ca138d2d69fc",credentialTemplateId:"microsoft",grant_type:"authorization_code"},keywords:["accounts","contacts","leads","opportunities","quotes","salesorders","salesorderdetails","products","incidents","campaigns","invoices","competitors","teams","systemusers","businessunits","odata","dynamics","crm","dynamics 365 sales","dataverse","oauth"],systemSpecificInstructions:`Dynamics 365 Sales \u2014 Dataverse Web API v9.2
518
524
 
519
525
  CONNECTING: superglue provides a managed multi-tenant Microsoft app, so no Azure app registration is needed \u2014 authenticate directly via OAuth. The Dataverse scope is per-environment: the template scope contains an <<api_host>> placeholder and Microsoft rejects it unresolved \u2014 ALWAYS substitute the environment host (e.g. https://contoso.crm.dynamics.com/user_impersonation offline_access) in scopes when calling authenticate_oauth. Ask the user for the host if it is unknown. The user_impersonation scope does not require Entra administrator consent, but the signed-in user needs a Dynamics 365 license and a security role in the target environment. Keep offline_access in scopes to receive refresh tokens.
520
526
 
@@ -527,7 +533,7 @@ QUERY BEHAVIOR:
527
533
  - $skip is NOT supported. Use @odata.nextLink for pagination (default page size 5000, control with Prefer: odata.maxpagesize=<n>).
528
534
  - PAGINATION IN SUPERGLUE: Use cursorBased pagination with cursorPath "@odata.nextLink":
529
535
  pagination: { type: "cursorBased", pageSize: "5000", cursorPath: "@odata.nextLink" }
530
- The cursor is a full URL \u2014 use <<cursor>> as the step URL (set the initial URL via a "cursor" input variable).
536
+ The cursor is a full URL \u2014 build the step url as an expression that falls back to the base query when the cursor is null: url: "<<(sourceData) => sourceData.cursor || 'https://' + sourceData.<systemId>_api_host + '/api/data/v9.2/accounts?$select=name'>>" where <systemId> is the connected system id (e.g. sourceData.dynamics365_sales_api_host). Saved credentials resolve as <systemId>_<key> inside expressions. Do not nest <<...>> placeholders inside the expression. Leave queryParams empty. Do not pass cursor as an input variable; payload values override the pagination cursor on every page.
531
537
  - COUNTS ARE CAPPED: $count=true returns @odata.count capped at 5000 (500 for elastic tables). When the real total is higher, Dataverse sets @Microsoft.Dynamics.CRM.totalrecordcountlimitexceeded to true and @odata.count stays 5000. Always read that flag before reporting a total, or use $apply=aggregate($count as total) for an exact count.
532
538
  - $apply is supported for aggregations.
533
539
  - Lookup fields (foreign keys) are named _<field>_value \u2014 e.g. _parentaccountid_value, _customerid_value.
@@ -1318,11 +1324,11 @@ ${m.toString(16)}\r
1318
1324
  \r
1319
1325
  `,"latin1"),t!==null&&i!==t){if(a[Zy])throw new qr;process.emitWarning(new qr)}e[ve].timeout&&e[ve].timeoutType===Js&&e[ve].timeout.refresh&&e[ve].timeout.refresh(),a[Na]()}}destroy(e){let{socket:t,client:a,abort:i}=this;t[wi]=!1,e&&(P(a[_e]<=1,"pipeline should only contain this request"),i(e))}};Vj.exports=AK});var a8=y((Mge,t8)=>{"use strict";var wt=require("assert"),{pipeline:SK}=require("stream"),ee=K(),{RequestContentLengthMismatchError:nk,RequestAbortedError:DK,SocketError:um,InformationalError:vi,InvalidArgumentError:TK}=$(),{kUrl:lm,kReset:Id,kClient:Wo,kRunning:dm,kPending:RK,kQueue:xi,kPendingIdx:mk,kRunningIdx:Mt,kError:Jo,kSocket:Ie,kStrictContentLength:NK,kOnError:Ks,kMaxConcurrentStreams:qd,kPingInterval:Wj,kHTTP2Session:Ua,kHTTP2InitialWindowSize:UK,kHTTP2ConnectionWindowSize:OK,kResume:aa,kSize:MK,kHTTPContext:lk,kClosed:ck,kBodyTimeout:_K,kEnableConnectProtocol:cm,kRemoteSettings:mm,kHTTP2Stream:zd,kHTTP2SessionState:uk}=de(),{channels:Jj}=yi(),At=Symbol("open streams"),Kj,Ed;try{Ed=require("http2")}catch{Ed={constants:{}}}var{constants:{HTTP2_HEADER_AUTHORITY:LK,HTTP2_HEADER_METHOD:Zj,HTTP2_HEADER_PATH:Xj,HTTP2_HEADER_SCHEME:ik,HTTP2_HEADER_CONTENT_LENGTH:FK,HTTP2_HEADER_EXPECT:PK,HTTP2_HEADER_STATUS:rk,HTTP2_HEADER_PROTOCOL:HK,NGHTTP2_REFUSED_STREAM:GK,NGHTTP2_CANCEL:YK}}=Ed;function sk(o){let e=[];for(let[t,a]of Object.entries(o))if(Array.isArray(a))for(let i of a)e.push(Buffer.from(t),Buffer.from(i));else e.push(Buffer.from(t),Buffer.from(a));return e}function VK(o,e){o[Ie]=e;let t=o[UK],a=o[OK],i=Ed.connect(o[lm],{createConnection:()=>e,peerMaxConcurrentStreams:o[qd],settings:{enablePush:!1,...t!=null?{initialWindowSize:t}:null}});return o[Ie]=e,i[At]=0,i[Wo]=o,i[Ie]=e,i[uk]={ping:{interval:o[Wj]===0?null:setInterval(KK,o[Wj],i).unref()}},i[cm]=!1,i[mm]=!1,a&&ee.addListener(i,"connect",WK.bind(i,a)),ee.addListener(i,"error",ZK),ee.addListener(i,"frameError",XK),ee.addListener(i,"end",eZ),ee.addListener(i,"goaway",oZ),ee.addListener(i,"close",tZ),ee.addListener(i,"remoteSettings",JK),i.unref(),o[Ua]=i,e[Ua]=i,ee.addListener(e,"error",iZ),ee.addListener(e,"end",rZ),ee.addListener(e,"close",aZ),e[ck]=!1,e.on("close",sZ),{version:"h2",defaultPipelining:1/0,write(r){return cZ(o,r)},resume(){$K(o)},destroy(r,s){e[ck]?queueMicrotask(s):e.destroy(r).on("close",s)},get destroyed(){return e.destroyed},busy(r){if(r!=null)if(o[dm]>0){if(r.idempotent===!1||(r.upgrade==="websocket"||r.method==="CONNECT")&&i[mm]===!1||ee.bodyLength(r.body)!==0&&(ee.isStream(r.body)||ee.isAsyncIterable(r.body)||ee.isFormDataLike(r.body)))return!0}else return(r.upgrade==="websocket"||r.method==="CONNECT")&&i[mm]===!1;return!1}}}function $K(o){let e=o[Ie];e?.destroyed===!1&&(o[MK]===0||o[qd]===0?(e.unref(),o[Ua].unref()):(e.ref(),o[Ua].ref()))}function WK(o){try{typeof this.setLocalWindowSize=="function"&&this.setLocalWindowSize(o)}catch{}}function JK(o){if(this[Wo][qd]=o.maxConcurrentStreams??this[Wo][qd],this[mm]===!0&&this[cm]===!0&&o.enableConnectProtocol===!1){let e=new vi("HTTP/2: Server disabled extended CONNECT protocol against RFC-8441");this[Ie][Jo]=e,this[Wo][Ks](e);return}this[cm]=o.enableConnectProtocol??this[cm],this[mm]=!0,this[Wo][aa]()}function KK(o){let e=o[uk];if((o.closed||o.destroyed)&&e.ping.interval!=null){clearInterval(e.ping.interval),e.ping.interval=null;return}o.ping(t.bind(o));function t(a,i){let r=this[Wo],s=this[Wo];if(a!=null){let n=new vi(`HTTP/2: "PING" errored - type ${a.message}`);s[Jo]=n,r[Ks](n)}else r.emit("ping",i)}}function ZK(o){wt(o.code!=="ERR_TLS_CERT_ALTNAME_INVALID"),this[Ie][Jo]=o,this[Wo][Ks](o)}function XK(o,e,t){if(t===0){let a=new vi(`HTTP/2: "frameError" received - type ${o}, code ${e}`);this[Ie][Jo]=a,this[Wo][Ks](a)}}function eZ(){let o=new um("other side closed",ee.getSocketInfo(this[Ie]));this.destroy(o),ee.destroy(this[Ie],o)}function oZ(o){let e=this[Jo]||new um(`HTTP/2: "GOAWAY" frame received with code ${o}`,ee.getSocketInfo(this[Ie])),t=this[Wo];if(t[Ie]=null,t[lk]=null,this.close(),this[Ua]=null,ee.destroy(this[Ie],e),t[Mt]<t[xi].length){let a=t[xi][t[Mt]];t[xi][t[Mt]++]=null,ee.errorRequest(t,a,e),t[mk]=t[Mt]}wt(t[dm]===0),t.emit("disconnect",t[lm],[t],e),t.emit("connectionError",t[lm],[t],e),t[aa]()}function tZ(){let{[Wo]:o,[uk]:e}=this,{[Ie]:t}=o,a=this[Ie][Jo]||this[Jo]||new um("closed",ee.getSocketInfo(t));if(o[Ie]=null,o[lk]=null,e.ping.interval!=null&&(clearInterval(e.ping.interval),e.ping.interval=null),o.destroyed){wt(o[RK]===0);let i=o[xi].splice(o[Mt]);for(let r=0;r<i.length;r++){let s=i[r];ee.errorRequest(o,s,a)}}}function aZ(){let o=this[Jo]||new um("closed",ee.getSocketInfo(this)),e=this[Ua][Wo];e[Ie]=null,e[lk]=null,this[Ua]!==null&&this[Ua].destroy(o),e[mk]=e[Mt],wt(e[dm]===0),e.emit("disconnect",e[lm],[e],o),e[aa]()}function iZ(o){wt(o.code!=="ERR_TLS_CERT_ALTNAME_INVALID"),this[Jo]=o,this[Wo][Ks](o)}function rZ(){ee.destroy(this,new um("other side closed",ee.getSocketInfo(this)))}function sZ(){this[ck]=!0}function nZ(o){return o!=="GET"&&o!=="HEAD"&&o!=="OPTIONS"&&o!=="TRACE"&&o!=="CONNECT"}function cZ(o,e){let t=e.bodyTimeout??o[_K],a=o[Ua],{method:i,path:r,host:s,upgrade:n,expectContinue:c,signal:m,protocol:l,headers:u}=e,{body:d}=e;if(n!=null&&n!=="websocket")return ee.errorRequest(o,e,new TK(`Custom upgrade "${n}" not supported over HTTP/2`)),!1;let g={};for(let D=0;D<u.length;D+=2){let O=u[D+0],S=u[D+1];if(O==="cookie"){g[O]!=null?g[O]=Array.isArray(g[O])?(g[O].push(S),g[O]):[g[O],S]:g[O]=S;continue}if(Array.isArray(S))for(let oe=0;oe<S.length;oe++)g[O]?g[O]+=`, ${S[oe]}`:g[O]=S[oe];else g[O]?g[O]+=`, ${S}`:g[O]=S}let p=null,{hostname:b,port:A}=o[lm];g[LK]=s||`${b}${A?`:${A}`:""}`,g[Zj]=i;let k=D=>{e.aborted||e.completed||(D=D||new DK,ee.errorRequest(o,e,D),p!=null&&(p.removeAllListeners("data"),p.close(),o[Ks](D),o[aa]()),ee.destroy(d,D))};try{e.onConnect(k)}catch(D){ee.errorRequest(o,e,D)}if(e.aborted)return!1;if(n||i==="CONNECT")return a.ref(),n==="websocket"?a[cm]===!1?(ee.errorRequest(o,e,new vi("HTTP/2: Extended CONNECT protocol not supported by server")),a.unref(),!1):(g[Zj]="CONNECT",g[HK]="websocket",g[Xj]=r,l==="ws:"||l==="wss:"?g[ik]=l==="ws:"?"http":"https":g[ik]=l==="http:"?"http":"https",p=a.request(g,{endStream:!1,signal:m}),p[zd]=!0,p.once("response",(D,O)=>{let{[rk]:S,...oe}=D;e.onUpgrade(S,sk(oe),p),++a[At],o[xi][o[Mt]++]=null}),p.on("error",()=>{(p.rstCode===GK||p.rstCode===YK)&&k(new vi(`HTTP/2: "stream error" received - code ${p.rstCode}`))}),p.once("close",()=>{a[At]-=1,a[At]===0&&a.unref()}),p.setTimeout(t),!0):(p=a.request(g,{endStream:!1,signal:m}),p[zd]=!0,p.on("response",D=>{let{[rk]:O,...S}=D;e.onUpgrade(O,sk(S),p),++a[At],o[xi][o[Mt]++]=null}),p.once("close",()=>{a[At]-=1,a[At]===0&&a.unref()}),p.setTimeout(t),!0);g[Xj]=r,g[ik]=l==="http:"?"http":"https";let x=i==="PUT"||i==="POST"||i==="PATCH";d&&typeof d.read=="function"&&d.read(0);let v=ee.bodyLength(d);if(ee.isFormDataLike(d)){Kj??=$s().extractBody;let[D,O]=Kj(d);g["content-type"]=O,d=D.stream,v=D.length}if(v==null&&(v=e.contentLength),x||(v=null),nZ(i)&&v>0&&e.contentLength!=null&&e.contentLength!==v){if(o[NK])return ee.errorRequest(o,e,new nk),!1;process.emitWarning(new nk)}if(v!=null&&(wt(d||v===0,"no body must not have content length"),g[FK]=`${v}`),a.ref(),Jj.sendHeaders.hasSubscribers){let D="";for(let O in g)D+=`${O}: ${g[O]}\r
1320
1326
  `;Jj.sendHeaders.publish({request:e,headers:D,socket:a[Ie]})}let j=i==="GET"||i==="HEAD"||d===null;c?(g[PK]="100-continue",p=a.request(g,{endStream:j,signal:m}),p[zd]=!0,p.once("continue",T)):(p=a.request(g,{endStream:j,signal:m}),p[zd]=!0,T()),++a[At],p.setTimeout(t);let I=!1;return p.once("response",D=>{let{[rk]:O,...S}=D;if(e.onResponseStarted(),I=!0,e.aborted){p.removeAllListeners("data");return}e.onHeaders(Number(O),sk(S),p.resume.bind(p),"")===!1&&p.pause(),p.on("data",oe=>{e.aborted||e.completed||e.onData(oe)===!1&&p.pause()})}),p.once("end",()=>{p.removeAllListeners("data"),I?(!e.aborted&&!e.completed&&e.onComplete({}),o[xi][o[Mt]++]=null,o[aa]()):(k(new vi("HTTP/2: stream half-closed (remote)")),o[xi][o[Mt]++]=null,o[mk]=o[Mt],o[aa]())}),p.once("close",()=>{p.removeAllListeners("data"),a[At]-=1,a[At]===0&&a.unref()}),p.once("error",function(D){p.removeAllListeners("data"),k(D)}),p.once("frameError",(D,O)=>{p.removeAllListeners("data"),k(new vi(`HTTP/2: "frameError" received - type ${D}, code ${O}`))}),p.on("aborted",()=>{p.removeAllListeners("data")}),p.on("timeout",()=>{let D=new vi(`HTTP/2: "stream timeout after ${t}"`);p.removeAllListeners("data"),a[At]-=1,a[At]===0&&a.unref(),k(D)}),p.once("trailers",D=>{e.aborted||e.completed||(p.removeAllListeners("data"),e.onComplete(D))}),!0;function T(){!d||v===0?e8(k,p,null,o,e,o[Ie],v,x):ee.isBuffer(d)?e8(k,p,d,o,e,o[Ie],v,x):ee.isBlobLike(d)?typeof d.stream=="function"?o8(k,p,d.stream(),o,e,o[Ie],v,x):lZ(k,p,d,o,e,o[Ie],v,x):ee.isStream(d)?mZ(k,o[Ie],x,p,d,o,e,v):ee.isIterable(d)?o8(k,p,d,o,e,o[Ie],v,x):wt(!1)}}function e8(o,e,t,a,i,r,s,n){try{t!=null&&ee.isBuffer(t)&&(wt(s===t.byteLength,"buffer body must have content length"),e.cork(),e.write(t),e.uncork(),e.end(),i.onBodySent(t)),n||(r[Id]=!0),i.onRequestSent(),a[aa]()}catch(c){o(c)}}function mZ(o,e,t,a,i,r,s,n){wt(n!==0||r[dm]===0,"stream body cannot be pipelined");let c=SK(i,a,l=>{l?(ee.destroy(c,l),o(l)):(ee.removeAllListeners(c),s.onRequestSent(),t||(e[Id]=!0),r[aa]())});ee.addListener(c,"data",m);function m(l){s.onBodySent(l)}}async function lZ(o,e,t,a,i,r,s,n){wt(s===t.size,"blob body must have content length");try{if(s!=null&&s!==t.size)throw new nk;let c=Buffer.from(await t.arrayBuffer());e.cork(),e.write(c),e.uncork(),e.end(),i.onBodySent(c),i.onRequestSent(),n||(r[Id]=!0),a[aa]()}catch(c){o(c)}}async function o8(o,e,t,a,i,r,s,n){wt(s!==0||a[dm]===0,"iterator body cannot be pipelined");let c=null;function m(){if(c){let u=c;c=null,u()}}let l=()=>new Promise((u,d)=>{wt(c===null),r[Jo]?d(r[Jo]):c=u});e.on("close",m).on("drain",m);try{for await(let u of t){if(r[Jo])throw r[Jo];let d=e.write(u);i.onBodySent(u),d||await l()}e.end(),i.onRequestSent(),n||(r[Id]=!0),a[aa]()}catch(u){o(u)}finally{e.off("close",m).off("drain",m)}}t8.exports=VK});var Ii=y((_ge,u8)=>{"use strict";var Oa=require("assert"),n8=require("net"),gm=require("http"),Br=K(),{ClientStats:uZ}=iy(),{channels:Zs}=yi(),dZ=wC(),gZ=Ar(),{InvalidArgumentError:xe,InformationalError:pZ,ClientDestroyedError:hZ}=$(),fZ=wr(),{kUrl:ia,kServerName:Ei,kClient:bZ,kBusy:gk,kConnect:yZ,kResuming:Qr,kRunning:bm,kPending:ym,kSize:pm,kQueue:_t,kConnected:kZ,kConnecting:Xs,kNeedDrain:qi,kKeepAliveDefaultTimeout:i8,kHostHeader:AZ,kPendingIdx:Lt,kRunningIdx:_a,kError:wZ,kPipelining:Cd,kKeepAliveTimeoutValue:vZ,kMaxHeadersSize:xZ,kKeepAliveMaxTimeout:zZ,kKeepAliveTimeoutThreshold:qZ,kHeadersTimeout:EZ,kBodyTimeout:IZ,kStrictContentLength:CZ,kConnector:hm,kMaxRequests:pk,kCounter:jZ,kClose:BZ,kDestroy:QZ,kDispatch:SZ,kLocalAddress:fm,kMaxResponseSize:DZ,kOnError:TZ,kHTTPContext:Ne,kMaxConcurrentStreams:RZ,kHTTP2InitialWindowSize:NZ,kHTTP2ConnectionWindowSize:UZ,kResume:Ma,kPingInterval:OZ}=de(),MZ=$j(),_Z=a8(),zi=Symbol("kClosedResolve"),LZ=gm&&gm.maxHeaderSize&&Number.isInteger(gm.maxHeaderSize)&&gm.maxHeaderSize>0?()=>gm.maxHeaderSize:()=>{throw new xe("http module not available or http.maxHeaderSize invalid")},r8=()=>{};function c8(o){return o[Cd]??o[Ne]?.defaultPipelining??1}var hk=class extends gZ{constructor(e,{maxHeaderSize:t,headersTimeout:a,socketTimeout:i,requestTimeout:r,connectTimeout:s,bodyTimeout:n,idleTimeout:c,keepAlive:m,keepAliveTimeout:l,maxKeepAliveTimeout:u,keepAliveMaxTimeout:d,keepAliveTimeoutThreshold:g,socketPath:p,pipelining:b,tls:A,strictContentLength:k,maxCachedSessions:x,connect:v,maxRequestsPerClient:j,localAddress:I,maxResponseSize:T,autoSelectFamily:D,autoSelectFamilyAttemptTimeout:O,maxConcurrentStreams:S,allowH2:oe,useH2c:te,initialWindowSize:ye,connectionWindowSize:po,pingInterval:Ve,webSocket:ya}={}){if(m!==void 0)throw new xe("unsupported keepAlive, use pipelining=0 instead");if(i!==void 0)throw new xe("unsupported socketTimeout, use headersTimeout & bodyTimeout instead");if(r!==void 0)throw new xe("unsupported requestTimeout, use headersTimeout & bodyTimeout instead");if(c!==void 0)throw new xe("unsupported idleTimeout, use keepAliveTimeout instead");if(u!==void 0)throw new xe("unsupported maxKeepAliveTimeout, use keepAliveMaxTimeout instead");if(t!=null){if(!Number.isInteger(t)||t<1)throw new xe("invalid maxHeaderSize")}else t=LZ();if(p!=null&&typeof p!="string")throw new xe("invalid socketPath");if(s!=null&&(!Number.isFinite(s)||s<0))throw new xe("invalid connectTimeout");if(l!=null&&(!Number.isFinite(l)||l<=0))throw new xe("invalid keepAliveTimeout");if(d!=null&&(!Number.isFinite(d)||d<=0))throw new xe("invalid keepAliveMaxTimeout");if(g!=null&&!Number.isFinite(g))throw new xe("invalid keepAliveTimeoutThreshold");if(a!=null&&(!Number.isInteger(a)||a<0))throw new xe("headersTimeout must be a positive integer or zero");if(n!=null&&(!Number.isInteger(n)||n<0))throw new xe("bodyTimeout must be a positive integer or zero");if(v!=null&&typeof v!="function"&&typeof v!="object")throw new xe("connect must be a function or an object");if(j!=null&&(!Number.isInteger(j)||j<0))throw new xe("maxRequestsPerClient must be a positive number");if(I!=null&&(typeof I!="string"||n8.isIP(I)===0))throw new xe("localAddress must be valid string IP address");if(T!=null&&(!Number.isInteger(T)||T<-1))throw new xe("maxResponseSize must be a positive number");if(O!=null&&(!Number.isInteger(O)||O<-1))throw new xe("autoSelectFamilyAttemptTimeout must be a positive number");if(oe!=null&&typeof oe!="boolean")throw new xe("allowH2 must be a valid boolean value");if(S!=null&&(typeof S!="number"||S<1))throw new xe("maxConcurrentStreams must be a positive integer, greater than 0");if(te!=null&&typeof te!="boolean")throw new xe("useH2c must be a valid boolean value");if(ye!=null&&(!Number.isInteger(ye)||ye<1))throw new xe("initialWindowSize must be a positive integer, greater than 0");if(po!=null&&(!Number.isInteger(po)||po<1))throw new xe("connectionWindowSize must be a positive integer, greater than 0");if(Ve!=null&&(typeof Ve!="number"||!Number.isInteger(Ve)||Ve<0))throw new xe("pingInterval must be a positive integer, greater or equal to 0");if(super({webSocket:ya}),typeof v!="function")v=fZ({...A,maxCachedSessions:x,allowH2:oe,useH2c:te,socketPath:p,timeout:s,...typeof D=="boolean"?{autoSelectFamily:D,autoSelectFamilyAttemptTimeout:O}:void 0,...v});else{let it=v;v=(Wi,Ji)=>it({...Wi,...p!=null?{socketPath:p}:null,...oe!=null?{allowH2:oe}:null},Ji)}this[ia]=Br.parseOrigin(e),this[hm]=v,this[Cd]=b??1,this[xZ]=t,this[i8]=l??4e3,this[zZ]=d??6e5,this[qZ]=g??2e3,this[vZ]=this[i8],this[Ei]=null,this[fm]=I??null,this[Qr]=0,this[qi]=0,this[AZ]=`host: ${this[ia].hostname}${this[ia].port?`:${this[ia].port}`:""}\r
1321
- `,this[IZ]=n??3e5,this[EZ]=a??3e5,this[CZ]=k??!0,this[pk]=j,this[zi]=null,this[DZ]=T>-1?T:-1,this[Ne]=null,this[RZ]=S??100,this[NZ]=ye??262144,this[UZ]=po??524288,this[OZ]=Ve??6e4,this[_t]=[],this[_a]=0,this[Lt]=0,this[Ma]=it=>fk(this,it),this[TZ]=it=>m8(this,it)}get pipelining(){return this[Cd]}set pipelining(e){this[Cd]=e,this[Ma](!0)}get stats(){return new uZ(this)}get[ym](){return this[_t].length-this[Lt]}get[bm](){return this[Lt]-this[_a]}get[pm](){return this[_t].length-this[_a]}get[kZ](){return!!this[Ne]&&!this[Xs]&&!this[Ne].destroyed}get[gk](){return!!(this[Ne]?.busy(null)||this[pm]>=(c8(this)||1)||this[ym]>0)}[yZ](e){l8(this),this.once("connect",e)}[SZ](e,t){let a=new dZ(this[ia].origin,e,t);return this[_t].push(a),this[Qr]||(Br.bodyLength(a.body)==null&&Br.isIterable(a.body)?(this[Qr]=1,queueMicrotask(()=>fk(this))):this[Ma](!0)),this[Qr]&&this[qi]!==2&&this[gk]&&(this[qi]=2),this[qi]<2}[BZ](){return new Promise(e=>{this[pm]?this[zi]=e:e(null)})}[QZ](e){return new Promise(t=>{let a=this[_t].splice(this[Lt]);for(let r=0;r<a.length;r++){let s=a[r];Br.errorRequest(this,s,e)}let i=()=>{this[zi]&&(this[zi](),this[zi]=null),t(null)};this[Ne]?(this[Ne].destroy(e,i),this[Ne]=null):queueMicrotask(i),this[Ma]()})}};function m8(o,e){if(o[bm]===0&&e.code!=="UND_ERR_INFO"&&e.code!=="UND_ERR_SOCKET"){Oa(o[Lt]===o[_a]);let t=o[_t].splice(o[_a]);for(let a=0;a<t.length;a++){let i=t[a];Br.errorRequest(o,i,e)}Oa(o[pm]===0)}}function l8(o){Oa(!o[Xs]),Oa(!o[Ne]);let{host:e,hostname:t,protocol:a,port:i}=o[ia];if(t[0]==="["){let r=t.indexOf("]");Oa(r!==-1);let s=t.substring(1,r);Oa(n8.isIPv6(s)),t=s}o[Xs]=!0,Zs.beforeConnect.hasSubscribers&&Zs.beforeConnect.publish({connectParams:{host:e,hostname:t,protocol:a,port:i,version:o[Ne]?.version,servername:o[Ei],localAddress:o[fm]},connector:o[hm]});try{o[hm]({host:e,hostname:t,protocol:a,port:i,servername:o[Ei],localAddress:o[fm]},(r,s)=>{if(r){dk(o,r,{host:e,hostname:t,protocol:a,port:i}),o[Ma]();return}if(o.destroyed){Br.destroy(s.on("error",r8),new hZ),o[Ma]();return}Oa(s);try{o[Ne]=s.alpnProtocol==="h2"?_Z(o,s):MZ(o,s)}catch(n){s.destroy().on("error",r8),dk(o,n,{host:e,hostname:t,protocol:a,port:i}),o[Ma]();return}o[Xs]=!1,s[jZ]=0,s[pk]=o[pk],s[bZ]=o,s[wZ]=null,Zs.connected.hasSubscribers&&Zs.connected.publish({connectParams:{host:e,hostname:t,protocol:a,port:i,version:o[Ne]?.version,servername:o[Ei],localAddress:o[fm]},connector:o[hm],socket:s}),o.emit("connect",o[ia],[o]),o[Ma]()})}catch(r){dk(o,r,{host:e,hostname:t,protocol:a,port:i}),o[Ma]()}}function dk(o,e,{host:t,hostname:a,protocol:i,port:r}){if(!o.destroyed){if(o[Xs]=!1,Zs.connectError.hasSubscribers&&Zs.connectError.publish({connectParams:{host:t,hostname:a,protocol:i,port:r,version:o[Ne]?.version,servername:o[Ei],localAddress:o[fm]},connector:o[hm],error:e}),e.code==="ERR_TLS_CERT_ALTNAME_INVALID")for(Oa(o[bm]===0);o[ym]>0&&o[_t][o[Lt]].servername===o[Ei];){let s=o[_t][o[Lt]++];Br.errorRequest(o,s,e)}else m8(o,e);o.emit("connectionError",o[ia],[o],e)}}function s8(o){o[qi]=0,o.emit("drain",o[ia],[o])}function fk(o,e){o[Qr]!==2&&(o[Qr]=2,FZ(o,e),o[Qr]=0,o[_a]>256&&(o[_t].splice(0,o[_a]),o[Lt]-=o[_a],o[_a]=0))}function FZ(o,e){for(;;){if(o.destroyed){Oa(o[ym]===0);return}if(o[zi]&&!o[pm]){o[zi](),o[zi]=null;return}if(o[Ne]&&o[Ne].resume(),o[gk])o[qi]=2;else if(o[qi]===2){e?(o[qi]=1,queueMicrotask(()=>s8(o))):s8(o);continue}if(o[ym]===0||o[bm]>=(c8(o)||1))return;let t=o[_t][o[Lt]];if(t===null)return;if(o[ia].protocol==="https:"&&o[Ei]!==t.servername){if(o[bm]>0)return;o[Ei]=t.servername,o[Ne]?.destroy(new pZ("servername changed"),()=>{o[Ne]=null,fk(o)})}if(o[Xs])return;if(!o[Ne]){l8(o);return}if(o[Ne].destroyed||o[Ne].busy(t))return;!t.aborted&&o[Ne].write(t)?o[Lt]++:o[_t].splice(o[Lt],1)}}u8.exports=hk});var bk=y((Fge,d8)=>{"use strict";var jd=class{bottom=0;top=0;list=new Array(2048).fill(void 0);next=null;isEmpty(){return this.top===this.bottom}isFull(){return(this.top+1&2047)===this.bottom}push(e){this.list[this.top]=e,this.top=this.top+1&2047}shift(){let e=this.list[this.bottom];return e===void 0?null:(this.list[this.bottom]=void 0,this.bottom=this.bottom+1&2047,e)}};d8.exports=class{constructor(){this.head=this.tail=new jd}isEmpty(){return this.head.isEmpty()}push(e){this.head.isFull()&&(this.head=this.head.next=new jd),this.head.push(e)}shift(){let e=this.tail,t=e.shift();return e.isEmpty()&&e.next!==null&&(this.tail=e.next,e.next=null),t}}});var Bd=y((Pge,w8)=>{"use strict";var{PoolStats:PZ}=iy(),HZ=Ar(),GZ=bk(),{kConnected:yk,kSize:g8,kRunning:p8,kPending:h8,kQueued:km,kBusy:YZ,kFree:VZ,kUrl:$Z,kClose:WZ,kDestroy:JZ,kDispatch:KZ}=de(),Ze=Symbol("clients"),Ao=Symbol("needDrain"),Am=Symbol("queue"),kk=Symbol("closed resolve"),Ak=Symbol("onDrain"),f8=Symbol("onConnect"),b8=Symbol("onDisconnect"),y8=Symbol("onConnectionError"),wk=Symbol("get dispatcher"),k8=Symbol("add client"),A8=Symbol("remove client"),vk=class extends HZ{[Am]=new GZ;[km]=0;[Ze]=[];[Ao]=!1;[Ak](e,t,a){let i=this[Am],r=!1;for(;!r;){let s=i.shift();if(!s)break;this[km]--,r=!e.dispatch(s.opts,s.handler)}if(e[Ao]=r,!r&&this[Ao]&&(this[Ao]=!1,this.emit("drain",t,[this,...a])),this[kk]&&i.isEmpty()){let s=[];for(let n=0;n<this[Ze].length;n++){let c=this[Ze][n];c.destroyed||s.push(c.close())}return Promise.all(s).then(this[kk])}}[f8]=(e,t)=>{this.emit("connect",e,[this,...t])};[b8]=(e,t,a)=>{this.emit("disconnect",e,[this,...t],a)};[y8]=(e,t,a)=>{this.emit("connectionError",e,[this,...t],a)};get[YZ](){return this[Ao]}get[yk](){let e=0;for(let{[yk]:t}of this[Ze])e+=t;return e}get[VZ](){let e=0;for(let{[yk]:t,[Ao]:a}of this[Ze])e+=t&&!a;return e}get[h8](){let e=this[km];for(let{[h8]:t}of this[Ze])e+=t;return e}get[p8](){let e=0;for(let{[p8]:t}of this[Ze])e+=t;return e}get[g8](){let e=this[km];for(let{[g8]:t}of this[Ze])e+=t;return e}get stats(){return new PZ(this)}[WZ](){if(this[Am].isEmpty()){let e=[];for(let t=0;t<this[Ze].length;t++){let a=this[Ze][t];a.destroyed||e.push(a.close())}return Promise.all(e)}else return new Promise(e=>{this[kk]=e})}[JZ](e){for(;;){let a=this[Am].shift();if(!a)break;a.handler.onError(e)}let t=new Array(this[Ze].length);for(let a=0;a<this[Ze].length;a++)t[a]=this[Ze][a].destroy(e);return Promise.all(t)}[KZ](e,t){let a=this[wk]();return a?a.dispatch(e,t)||(a[Ao]=!0,this[Ao]=!this[wk]()):(this[Ao]=!0,this[Am].push({opts:e,handler:t}),this[km]++),!this[Ao]}[k8](e){return e.on("drain",this[Ak].bind(this,e)).on("connect",this[f8]).on("disconnect",this[b8]).on("connectionError",this[y8]),this[Ze].push(e),this[Ao]&&queueMicrotask(()=>{this[Ao]&&this[Ak](e,e[$Z],[e,this])}),this}[A8](e){e.close(()=>{let t=this[Ze].indexOf(e);t!==-1&&this[Ze].splice(t,1)}),this[Ao]=this[Ze].some(t=>!t[Ao]&&t.closed!==!0&&t.destroyed!==!0)}};w8.exports={PoolBase:vk,kClients:Ze,kNeedDrain:Ao,kAddClient:k8,kRemoveClient:A8,kGetDispatcher:wk}});var Sr=y((Hge,q8)=>{"use strict";var{PoolBase:ZZ,kClients:Qd,kNeedDrain:XZ,kAddClient:eX,kGetDispatcher:oX,kRemoveClient:tX}=Bd(),aX=Ii(),{InvalidArgumentError:xk}=$(),v8=K(),{kUrl:x8}=de(),iX=wr(),Sd=Symbol("options"),zk=Symbol("connections"),z8=Symbol("factory");function rX(o,e){return new aX(o,e)}var qk=class extends ZZ{constructor(e,{connections:t,factory:a=rX,connect:i,connectTimeout:r,tls:s,maxCachedSessions:n,socketPath:c,autoSelectFamily:m,autoSelectFamilyAttemptTimeout:l,allowH2:u,clientTtl:d,...g}={}){if(t!=null&&(!Number.isFinite(t)||t<0))throw new xk("invalid connections");if(typeof a!="function")throw new xk("factory must be a function.");if(i!=null&&typeof i!="function"&&typeof i!="object")throw new xk("connect must be a function or an object");typeof i!="function"&&(i=iX({...s,maxCachedSessions:n,allowH2:u,socketPath:c,timeout:r,...typeof m=="boolean"?{autoSelectFamily:m,autoSelectFamilyAttemptTimeout:l}:void 0,...i})),super(g),this[zk]=t||null,this[x8]=v8.parseOrigin(e),this[Sd]={...v8.deepClone(g),connect:i,allowH2:u,clientTtl:d,socketPath:c},this[Sd].interceptors=g.interceptors?{...g.interceptors}:void 0,this[z8]=a,this.on("connect",(p,b)=>{if(d!=null&&d>0)for(let A of b)Object.assign(A,{ttl:Date.now()})}),this.on("connectionError",(p,b,A)=>{for(let k of b){let x=this[Qd].indexOf(k);x!==-1&&this[Qd].splice(x,1)}})}[oX](){let e=this[Sd].clientTtl;for(let t of this[Qd])if(e!=null&&e>0&&t.ttl&&Date.now()-t.ttl>e)this[tX](t);else if(!t[XZ])return t;if(!this[zk]||this[Qd].length<this[zk]){let t=this[z8](this[x8],this[Sd]);return this[eX](t),t}}};q8.exports=qk});var j8=y((Gge,C8)=>{"use strict";var{BalancedPoolMissingUpstreamError:sX,InvalidArgumentError:nX}=$(),{PoolBase:cX,kClients:ao,kNeedDrain:wm,kAddClient:mX,kRemoveClient:lX,kGetDispatcher:uX}=Bd(),dX=Sr(),{kUrl:Dd}=de(),Td=K(),E8=Symbol("factory"),vm=Symbol("options"),I8=Symbol("kGreatestCommonDivisor"),Dr=Symbol("kCurrentWeight"),Tr=Symbol("kIndex"),vt=Symbol("kWeight"),Rd=Symbol("kMaxWeightPerServer"),Nd=Symbol("kErrorPenalty");function gX(o,e){if(o===0)return e;for(;e!==0;){let t=e;e=o%e,o=t}return o}function pX(o,e){return new dX(o,e)}var Ek=class extends cX{constructor(e=[],{factory:t=pX,...a}={}){if(typeof t!="function")throw new nX("factory must be a function.");super(a),this[vm]={...Td.deepClone(a)},this[vm].interceptors=a.interceptors?{...a.interceptors}:void 0,this[Tr]=-1,this[Dr]=0,this[Rd]=this[vm].maxWeightPerServer||100,this[Nd]=this[vm].errorPenalty||15,Array.isArray(e)||(e=[e]),this[E8]=t;for(let i of e)this.addUpstream(i);this._updateBalancedPoolStats()}addUpstream(e){let t=Td.parseOrigin(e).origin;if(this[ao].find(i=>i[Dd].origin===t&&i.closed!==!0&&i.destroyed!==!0))return this;let a=this[E8](t,this[vm]);this[mX](a),a.on("connect",()=>{a[vt]=Math.min(this[Rd],a[vt]+this[Nd])}),a.on("connectionError",()=>{a[vt]=Math.max(1,a[vt]-this[Nd]),this._updateBalancedPoolStats()}),a.on("disconnect",(...i)=>{let r=i[2];r&&r.code==="UND_ERR_SOCKET"&&(a[vt]=Math.max(1,a[vt]-this[Nd]),this._updateBalancedPoolStats())});for(let i of this[ao])i[vt]=this[Rd];return this._updateBalancedPoolStats(),this}_updateBalancedPoolStats(){let e=0;for(let t=0;t<this[ao].length;t++)e=gX(this[ao][t][vt],e);this[I8]=e}removeUpstream(e){let t=Td.parseOrigin(e).origin,a=this[ao].find(i=>i[Dd].origin===t&&i.closed!==!0&&i.destroyed!==!0);return a&&this[lX](a),this}getUpstream(e){let t=Td.parseOrigin(e).origin;return this[ao].find(a=>a[Dd].origin===t&&a.closed!==!0&&a.destroyed!==!0)}get upstreams(){return this[ao].filter(e=>e.closed!==!0&&e.destroyed!==!0).map(e=>e[Dd].origin)}[uX](){if(this[ao].length===0)throw new sX;if(!this[ao].find(r=>!r[wm]&&r.closed!==!0&&r.destroyed!==!0)||this[ao].map(r=>r[wm]).reduce((r,s)=>r&&s,!0))return;let a=0,i=this[ao].findIndex(r=>!r[wm]);for(;a++<this[ao].length;){this[Tr]=(this[Tr]+1)%this[ao].length;let r=this[ao][this[Tr]];if(r[vt]>this[ao][i][vt]&&!r[wm]&&(i=this[Tr]),this[Tr]===0&&(this[Dr]=this[Dr]-this[I8],this[Dr]<=0&&(this[Dr]=this[Rd])),r[vt]>=this[Dr]&&!r[wm])return r}return this[Dr]=this[ao][i][vt],this[Tr]=i,this[ao][i]}};C8.exports=Ek});var D8=y((Yge,S8)=>{"use strict";var{PoolBase:hX,kClients:Ud,kNeedDrain:fX,kAddClient:B8,kGetDispatcher:bX,kRemoveClient:yX}=Bd(),kX=Ii(),{InvalidArgumentError:Ik}=$(),Q8=K(),{kUrl:Ck}=de(),AX=wr(),xm=Symbol("options"),jk=Symbol("connections"),Bk=Symbol("factory"),Od=Symbol("index");function wX(o,e){return new kX(o,e)}var Qk=class extends hX{constructor(e,{connections:t,factory:a=wX,connect:i,connectTimeout:r,tls:s,maxCachedSessions:n,socketPath:c,autoSelectFamily:m,autoSelectFamilyAttemptTimeout:l,allowH2:u,clientTtl:d,...g}={}){if(t!=null&&(!Number.isFinite(t)||t<0))throw new Ik("invalid connections");if(typeof a!="function")throw new Ik("factory must be a function.");if(i!=null&&typeof i!="function"&&typeof i!="object")throw new Ik("connect must be a function or an object");typeof i!="function"&&(i=AX({...s,maxCachedSessions:n,allowH2:u,socketPath:c,timeout:r,...typeof m=="boolean"?{autoSelectFamily:m,autoSelectFamilyAttemptTimeout:l}:void 0,...i})),super(),this[jk]=t||null,this[Ck]=Q8.parseOrigin(e),this[xm]={...Q8.deepClone(g),connect:i,allowH2:u,clientTtl:d,socketPath:c},this[xm].interceptors=g.interceptors?{...g.interceptors}:void 0,this[Bk]=a,this[Od]=-1,this.on("connect",(p,b)=>{if(d!=null&&d>0)for(let A of b)Object.assign(A,{ttl:Date.now()})}),this.on("connectionError",(p,b,A)=>{for(let k of b){let x=this[Ud].indexOf(k);x!==-1&&this[Ud].splice(x,1)}})}[bX](){let e=this[xm].clientTtl,t=this[Ud].length;if(t===0){let i=this[Bk](this[Ck],this[xm]);return this[B8](i),i}let a=0;for(;a<t;){this[Od]=(this[Od]+1)%t;let i=this[Ud][this[Od]];if(e!=null&&e>0&&i.ttl&&Date.now()-i.ttl>e){this[yX](i),a++;continue}if(!i[fX])return i;a++}if(!this[jk]||t<this[jk]){let i=this[Bk](this[Ck],this[xm]);return this[B8](i),i}}};S8.exports=Qk});var Rr=y((Vge,_8)=>{"use strict";var{InvalidArgumentError:Md,MaxOriginsReachedError:vX}=$(),{kClients:xt,kRunning:T8,kClose:xX,kDestroy:zX,kDispatch:qX,kUrl:EX}=de(),IX=Ar(),CX=Sr(),jX=Ii(),BX=K(),R8=Symbol("onConnect"),N8=Symbol("onDisconnect"),U8=Symbol("onConnectionError"),O8=Symbol("onDrain"),M8=Symbol("factory"),Sk=Symbol("options"),zm=Symbol("origins");function QX(o,e){return e&&e.connections===1?new jX(o,e):new CX(o,e)}var Dk=class extends IX{constructor({factory:e=QX,maxOrigins:t=1/0,connect:a,...i}={}){if(typeof e!="function")throw new Md("factory must be a function.");if(a!=null&&typeof a!="function"&&typeof a!="object")throw new Md("connect must be a function or an object");if(typeof t!="number"||Number.isNaN(t)||t<=0)throw new Md("maxOrigins must be a number greater than 0");super(i),a&&typeof a!="function"&&(a={...a}),this[Sk]={...BX.deepClone(i),maxOrigins:t,connect:a},this[M8]=e,this[xt]=new Map,this[zm]=new Set,this[O8]=(r,s)=>{this.emit("drain",r,[this,...s])},this[R8]=(r,s)=>{this.emit("connect",r,[this,...s])},this[N8]=(r,s,n)=>{this.emit("disconnect",r,[this,...s],n)},this[U8]=(r,s,n)=>{this.emit("connectionError",r,[this,...s],n)}}get[T8](){let e=0;for(let{dispatcher:t}of this[xt].values())e+=t[T8];return e}[qX](e,t){let a;if(e.origin&&(typeof e.origin=="string"||e.origin instanceof URL))a=String(e.origin);else throw new Md("opts.origin must be a non-empty string or URL.");if(this[zm].size>=this[Sk].maxOrigins&&!this[zm].has(a))throw new vX;let i=this[xt].get(a),r=i&&i.dispatcher;if(!r){let s=n=>{let c=this[xt].get(a);c&&(n&&(c.count-=1),c.count<=0&&(this[xt].delete(a),c.dispatcher.destroyed||c.dispatcher.close()),this[zm].delete(a))};r=this[M8](e.origin,this[Sk]).on("drain",this[O8]).on("connect",(n,c)=>{let m=this[xt].get(a);m&&(m.count+=1),this[R8](n,c)}).on("disconnect",(n,c,m)=>{s(!0),this[N8](n,c,m)}).on("connectionError",(n,c,m)=>{s(!1),this[U8](n,c,m)}),this[xt].set(a,{count:0,dispatcher:r}),this[zm].add(a)}return r.dispatch(e,t)}[xX](){let e=[];for(let{dispatcher:t}of this[xt].values())e.push(t.close());return this[xt].clear(),Promise.all(e)}[zX](e){let t=[];for(let{dispatcher:a}of this[xt].values())t.push(a.destroy(e));return this[xt].clear(),Promise.all(t)}get stats(){let e={};for(let{dispatcher:t}of this[xt].values())t.stats&&(e[t[EX].origin]=t.stats);return e}};_8.exports=Dk});var P8=y(($ge,F8)=>{"use strict";var{Buffer:ji}=require("buffer"),Tk=require("net"),{InvalidArgumentError:Ci}=$();function SX(o){if(Tk.isIPv4(o)){let t=o.split(".").map(Number);return{type:1,buffer:ji.from(t)}}if(Tk.isIPv6(o))return{type:4,buffer:L8(o)};let e=ji.from(o,"utf8");if(e.length>255)throw new Ci("Domain name too long (max 255 bytes)");return{type:3,buffer:ji.concat([ji.from([e.length]),e])}}function L8(o){let e=ji.alloc(16),t=o;if(o.includes(".")){let i=o.lastIndexOf(":"),r=o.slice(i+1);if(Tk.isIPv4(r)){let s=r.split(".").map(Number),n=(s[0]<<8|s[1]).toString(16),c=(s[2]<<8|s[3]).toString(16);t=`${o.slice(0,i)}:${n}:${c}`}}let a=t.indexOf("::");if(a!==-1){let i=t.slice(0,a),r=t.slice(a+2),s=i===""?[]:i.split(":"),n=r===""?[]:r.split(":"),c=0;for(let m of s)e.writeUInt16BE(parseInt(m,16),c),c+=2;c=16-n.length*2;for(let m of n)e.writeUInt16BE(parseInt(m,16),c),c+=2}else{let i=t.split(":");for(let r=0;r<i.length;r++)e.writeUInt16BE(parseInt(i[r],16),r*2)}return e}function DX(o,e,t){let a=ji.allocUnsafe(2);return a.writeUInt16BE(t,0),ji.concat([ji.from([o]),e,a])}function TX(o,e=0){if(o.length<e+1)throw new Ci("Buffer too small to contain address type");let t=o[e],a,i=e+1;switch(t){case 1:{if(o.length<i+6)throw new Ci("Buffer too small for IPv4 address");a=Array.from(o.subarray(i,i+4)).join("."),i+=4;break}case 3:{if(o.length<i+1)throw new Ci("Buffer too small for domain length");let s=o[i];if(i+=1,o.length<i+s+2)throw new Ci("Buffer too small for domain address");a=o.subarray(i,i+s).toString("utf8"),i+=s;break}case 4:{if(o.length<i+18)throw new Ci("Buffer too small for IPv6 address");let s=[];for(let n=0;n<8;n++){let c=o.readUInt16BE(i+n*2);s.push(c.toString(16))}a=s.join(":"),i+=16;break}default:throw new Ci(`Invalid address type: ${t}`)}if(o.length<i+2)throw new Ci("Buffer too small for port");let r=o.readUInt16BE(i);return i+=2,{address:a,port:r,bytesRead:i-e}}function RX(o){let t={1:"General SOCKS server failure",2:"Connection not allowed by ruleset",3:"Network unreachable",4:"Host unreachable",5:"Connection refused",6:"TTL expired",7:"Command not supported",8:"Address type not supported"}[o]||`Unknown SOCKS5 error code: ${o}`,a=new Error(t);return a.code=`SOCKS5_${o}`,a}F8.exports={parseAddress:SX,parseIPv6:L8,buildAddressBuffer:DX,parseResponseAddress:TX,createReplyError:RX}});var V8=y((Wge,Y8)=>{"use strict";var{EventEmitter:NX}=require("events"),{Buffer:Nr}=require("buffer"),{InvalidArgumentError:en,Socks5ProxyError:Bi}=$(),{debuglog:UX}=require("util"),{parseAddress:OX}=P8(),La=UX("undici:socks5"),H8=Nr.alloc(0),_d=5,on={NO_AUTH:0,GSSAPI:1,USERNAME_PASSWORD:2,NO_ACCEPTABLE:255},G8={CONNECT:1,BIND:2,UDP_ASSOCIATE:3},Ur={IPV4:1,DOMAIN:3,IPV6:4},ra={SUCCEEDED:0,GENERAL_FAILURE:1,CONNECTION_NOT_ALLOWED:2,NETWORK_UNREACHABLE:3,HOST_UNREACHABLE:4,CONNECTION_REFUSED:5,TTL_EXPIRED:6,COMMAND_NOT_SUPPORTED:7,ADDRESS_TYPE_NOT_SUPPORTED:8},mo={INITIAL:"initial",HANDSHAKING:"handshaking",AUTHENTICATING:"authenticating",AUTHENTICATED:"authenticated",CONNECTING:"connecting",CONNECTED:"connected",ERROR:"error",CLOSED:"closed"},Rk=class extends NX{constructor(e,t={}){if(super(),!e)throw new en("socket is required");this.socket=e,this.options=t,this.state=mo.INITIAL,this.buffer=H8,this.onSocketData=this.onData.bind(this),this.onSocketError=this.onError.bind(this),this.onSocketClose=this.onClose.bind(this),this.authMethods=[],t.username&&t.password&&this.authMethods.push(on.USERNAME_PASSWORD),this.authMethods.push(on.NO_AUTH),this.socket.on("data",this.onSocketData),this.socket.on("error",this.onSocketError),this.socket.on("close",this.onSocketClose)}onData(e){La("received data",e.length,"bytes in state",this.state),this.buffer=Nr.concat([this.buffer,e]);try{switch(this.state){case mo.HANDSHAKING:this.handleHandshakeResponse();break;case mo.AUTHENTICATING:this.handleAuthResponse();break;case mo.CONNECTING:this.handleConnectResponse();break}}catch(t){this.onError(t)}}onError(e){La("socket error",e),this.state=mo.ERROR,this.emit("error",e),this.destroy()}onClose(){La("socket closed"),this.state=mo.CLOSED,this.emit("close")}destroy(){this.socket&&!this.socket.destroyed&&this.socket.destroy()}markAuthenticated(){this.state=mo.AUTHENTICATED,this.emit("authenticated")}handshake(){if(this.state!==mo.INITIAL)throw new en("Handshake already started");La("starting handshake with",this.authMethods.length,"auth methods"),this.state=mo.HANDSHAKING;let e=Nr.alloc(2+this.authMethods.length);e[0]=_d,e[1]=this.authMethods.length,this.authMethods.forEach((t,a)=>{e[2+a]=t}),this.socket.write(e)}handleHandshakeResponse(){if(this.buffer.length<2)return;let e=this.buffer[0],t=this.buffer[1];if(e!==_d)throw new Bi(`Invalid SOCKS version: ${e}`,"UND_ERR_SOCKS5_VERSION");if(t===on.NO_ACCEPTABLE)throw new Bi("No acceptable authentication method","UND_ERR_SOCKS5_AUTH_REJECTED");if(this.buffer=this.buffer.subarray(2),La("server selected auth method",t),t===on.NO_AUTH)this.markAuthenticated();else if(t===on.USERNAME_PASSWORD)this.state=mo.AUTHENTICATING,this.sendAuthRequest();else throw new Bi(`Unsupported authentication method: ${t}`,"UND_ERR_SOCKS5_AUTH_METHOD")}sendAuthRequest(){let{username:e,password:t}=this.options;if(!e||!t)throw new en("Username and password required for authentication");La("sending username/password auth");let a=Nr.from(e),i=Nr.from(t);if(a.length>255||i.length>255)throw new en("Username or password too long");let r=Nr.alloc(3+a.length+i.length);r[0]=1,r[1]=a.length,a.copy(r,2),r[2+a.length]=i.length,i.copy(r,3+a.length),this.socket.write(r)}handleAuthResponse(){if(this.buffer.length<2)return;let e=this.buffer[0],t=this.buffer[1];if(e!==1)throw new Bi(`Invalid auth sub-negotiation version: ${e}`,"UND_ERR_SOCKS5_AUTH_VERSION");if(t!==0)throw new Bi("Authentication failed","UND_ERR_SOCKS5_AUTH_FAILED");this.buffer=this.buffer.subarray(2),La("authentication successful"),this.markAuthenticated()}connect(e,t){if(this.state===mo.CONNECTING||this.state===mo.CONNECTED)throw new en("Connection already in progress");if(this.state!==mo.AUTHENTICATED)throw new en("Client must be authenticated before CONNECT");La("connecting to",e,t),this.state=mo.CONNECTING;let a=this.buildConnectRequest(G8.CONNECT,e,t);this.socket.write(a)}buildConnectRequest(e,t,a){let{type:i,buffer:r}=OX(t),s=Nr.alloc(4+r.length+2);return s[0]=_d,s[1]=e,s[2]=0,s[3]=i,r.copy(s,4),s.writeUInt16BE(a,4+r.length),s}handleConnectResponse(){if(this.buffer.length<4)return;let e=this.buffer[0],t=this.buffer[1],a=this.buffer[3];if(e!==_d)throw new Bi(`Invalid SOCKS version in reply: ${e}`,"UND_ERR_SOCKS5_REPLY_VERSION");let i=4;if(a===Ur.IPV4)i+=6;else if(a===Ur.DOMAIN){if(this.buffer.length<5)return;i+=1+this.buffer[4]+2}else if(a===Ur.IPV6)i+=18;else throw new Bi(`Invalid address type in reply: ${a}`,"UND_ERR_SOCKS5_ADDR_TYPE");if(this.buffer.length<i)return;if(t!==ra.SUCCEEDED){let c=this.getReplyErrorMessage(t);throw new Bi(`SOCKS5 connection failed: ${c}`,`UND_ERR_SOCKS5_REPLY_${t}`)}let r,s=4;if(a===Ur.IPV4)r=Array.from(this.buffer.subarray(s,s+4)).join("."),s+=4;else if(a===Ur.DOMAIN){let c=this.buffer[s];s+=1,r=this.buffer.subarray(s,s+c).toString(),s+=c}else if(a===Ur.IPV6){let c=[];for(let m=0;m<8;m++){let l=this.buffer.readUInt16BE(s+m*2);c.push(l.toString(16))}r=c.join(":"),s+=16}let n=this.buffer.readUInt16BE(s);this.buffer=H8,this.state=mo.CONNECTED,this.socket.removeListener("data",this.onSocketData),La("connected, bound address:",r,"port:",n),this.emit("connected",{address:r,port:n})}getReplyErrorMessage(e){switch(e){case ra.GENERAL_FAILURE:return"General SOCKS server failure";case ra.CONNECTION_NOT_ALLOWED:return"Connection not allowed by ruleset";case ra.NETWORK_UNREACHABLE:return"Network unreachable";case ra.HOST_UNREACHABLE:return"Host unreachable";case ra.CONNECTION_REFUSED:return"Connection refused";case ra.TTL_EXPIRED:return"TTL expired";case ra.COMMAND_NOT_SUPPORTED:return"Command not supported";case ra.ADDRESS_TYPE_NOT_SUPPORTED:return"Address type not supported";default:return`Unknown error code: ${e}`}}};Y8.exports={Socks5Client:Rk,AUTH_METHODS:on,COMMANDS:G8,ADDRESS_TYPES:Ur,REPLY_CODES:ra,STATES:mo}});var _k=y((Jge,oB)=>{"use strict";var{URL:$8}=require("url"),Nk,MX=Ar(),{InvalidArgumentError:W8}=$(),{Socks5Client:_X,STATES:LX}=V8(),{kDispatch:J8,kClose:FX,kDestroy:PX}=de(),HX=Sr(),GX=wr(),{debuglog:YX}=require("util"),Qi=YX("undici:socks5-proxy"),Uk=Symbol("proxy url"),VX=Symbol("proxy headers"),K8=Symbol("proxy auth"),Z8=Symbol("proxy protocol"),Or=Symbol("pools"),X8=Symbol("connector"),Ok=Symbol("request tls settings"),eB=!1,Mk=class extends MX{constructor(e,t={}){if(super(),eB||(process.emitWarning("SOCKS5 proxy support is experimental and subject to change","ExperimentalWarning"),eB=!0),!e)throw new W8("Proxy URL is mandatory");let a=typeof e=="string"?new $8(e):e;if(a.protocol!=="socks5:"&&a.protocol!=="socks:")throw new W8("Proxy URL must use socks5:// or socks:// protocol");this[Uk]=a,this[VX]=t.headers||{},this[Z8]=t.proxyTls?"https:":"http:",this[Ok]=t.requestTls,this[K8]={username:t.username||(a.username?decodeURIComponent(a.username):null),password:t.password||(a.password?decodeURIComponent(a.password):null)},this[X8]=t.connect||GX({...t.proxyTls,servername:t.proxyTls?.servername||a.hostname}),this[Or]=new Map}async createSocks5Connection(e,t){let a=this[Uk].hostname,i=parseInt(this[Uk].port)||1080;Qi("creating SOCKS5 connection to",a,i);let r=await new Promise((n,c)=>{this[X8]({hostname:a,host:a,port:i,protocol:this[Z8]},(m,l)=>{m?c(m):n(l)})}),s=new _X(r,this[K8]);return s.on("error",n=>{Qi("SOCKS5 error:",n),r.destroy()}),await s.handshake(),await new Promise((n,c)=>{let m=setTimeout(()=>{c(new Error("SOCKS5 authentication timeout"))},5e3),l=()=>{clearTimeout(m),s.removeListener("error",u),n()},u=d=>{clearTimeout(m),s.removeListener("authenticated",l),c(d)};s.state===LX.AUTHENTICATED?(clearTimeout(m),n()):(s.once("authenticated",l),s.once("error",u))}),await s.connect(e,t),await new Promise((n,c)=>{let m=setTimeout(()=>{c(new Error("SOCKS5 connection timeout"))},5e3),l=d=>{Qi("SOCKS5 tunnel established to",e,t,"via",d),clearTimeout(m),s.removeListener("error",u),n()},u=d=>{clearTimeout(m),s.removeListener("connected",l),c(d)};s.once("connected",l),s.once("error",u)}),r}[J8](e,t){let{origin:a}=e;Qi("dispatching request to",a,"via SOCKS5");try{let i=String(a),r=this[Or].get(i);return(!r||r.destroyed||r.closed)&&(r=new HX(a,{pipelining:e.pipelining,connections:e.connections,connect:async(s,n)=>{try{let c=new $8(a),m=c.hostname,l=parseInt(c.port)||(c.protocol==="https:"?443:80);Qi("establishing SOCKS5 connection to",m,l);let u=await this.createSocks5Connection(m,l),d=u;c.protocol==="https:"&&(Nk||(Nk=require("tls")),Qi("upgrading to TLS"),d=Nk.connect({...this[Ok],socket:u,servername:this[Ok]?.servername||m}),await new Promise((g,p)=>{d.once("secureConnect",g),d.once("error",p)})),n(null,d)}catch(c){Qi("SOCKS5 connection error:",c),n(c)}}}),this[Or].set(i,r)),r[J8](e,t)}catch(i){if(Qi("dispatch error:",i),typeof t.onResponseError=="function")return t.onResponseError(null,i),!1;if(typeof t.onError=="function")return t.onError(i),!1;throw i}}async[FX](){let e=[];for(let t of this[Or].values())e.push(t.close());this[Or].clear(),await Promise.all(e)}async[PX](e){let t=[];for(let a of this[Or].values())t.push(a.destroy(e));this[Or].clear(),await Promise.all(t)}};oB.exports=Mk});var Hk=y((Kge,gB)=>{"use strict";var{kProxy:tn,kClose:cB,kDestroy:mB,kDispatch:tB}=de(),$X=Rr(),lB=Sr(),uB=Ar(),{InvalidArgumentError:Mr,RequestAbortedError:WX,SecureProxyConnectionError:JX}=$(),aB=wr(),dB=Ii(),{channels:iB}=yi(),KX=_k(),Ld=Symbol("proxy agent"),Si=Symbol("proxy client"),Fa=Symbol("proxy headers"),Lk=Symbol("request tls settings"),rB=Symbol("proxy tls settings"),sB=Symbol("connect endpoint function"),nB=Symbol("tunnel proxy");function ZX(o){return o==="https:"?443:80}function XX(o,e){return new lB(o,e)}var eee=()=>{};function oee(o,e){return e.connections===1?new dB(o,e):new lB(o,e)}var Fk=class extends uB{#e;constructor(e,{headers:t={},connect:a,factory:i}){if(!e)throw new Mr("Proxy URL is mandatory");super(),this[Fa]=t,i?this.#e=i(e,{connect:a}):this.#e=new dB(e,{connect:a})}[tB](e,t){let a=t.onHeaders;t.onHeaders=function(n,c,m){if(n===407){typeof t.onError=="function"&&t.onError(new Mr("Proxy Authentication Required (407)"));return}a&&a.call(this,n,c,m)};let{origin:i,path:r="/",headers:s={}}=e;if(e.path=i+r,!("host"in s)&&!("Host"in s)){let{host:n}=new URL(i);s.host=n}return e.headers={...this[Fa],...s},this.#e[tB](e,t)}[cB](){return this.#e.close()}[mB](e){return this.#e.destroy(e)}},Pk=class extends uB{constructor(e){if(!e||typeof e=="object"&&!(e instanceof URL)&&!e.uri)throw new Mr("Proxy uri is mandatory");let{clientFactory:t=XX}=e;if(typeof t!="function")throw new Mr("Proxy opts.clientFactory must be a function.");let{proxyTunnel:a=!0}=e;super();let i=this.#e(e),{href:r,origin:s,port:n,protocol:c,username:m,password:l,hostname:u}=i;if(this[tn]={uri:r,protocol:c},this[Lk]=e.requestTls,this[rB]=e.proxyTls,this[Fa]=e.headers||{},this[nB]=a,e.auth&&e.token)throw new Mr("opts.auth cannot be used in combination with opts.token");e.auth?this[Fa]["proxy-authorization"]=`Basic ${e.auth}`:e.token?this[Fa]["proxy-authorization"]=e.token:m&&l&&(this[Fa]["proxy-authorization"]=`Basic ${Buffer.from(`${decodeURIComponent(m)}:${decodeURIComponent(l)}`).toString("base64")}`);let d=aB({...e.proxyTls});this[sB]=aB({...e.requestTls});let g=e.factory||oee,p=(b,A)=>{let{protocol:k}=new URL(b);return this[tn].protocol==="socks5:"||this[tn].protocol==="socks:"?new KX(this[tn].uri,{headers:this[Fa],connect:d,factory:g,username:e.username||m,password:e.password||l,proxyTls:e.proxyTls,requestTls:e.requestTls}):!this[nB]&&k==="http:"&&this[tn].protocol==="http:"?new Fk(this[tn].uri,{headers:this[Fa],connect:d,factory:g}):g(b,A)};c==="socks5:"||c==="socks:"?this[Si]=null:this[Si]=t(i,{connect:d}),this[Ld]=new $X({...e,factory:p,connect:async(b,A)=>{if(!this[Si]){A(new Mr("Cannot establish tunnel connection without a proxy client"));return}let k=b.host;b.port||(k+=`:${ZX(b.protocol)}`);try{let x={origin:s,port:n,path:k,signal:b.signal,headers:{...this[Fa],host:b.host,...b.connections==null||b.connections>0?{"proxy-connection":"keep-alive"}:{}},servername:this[rB]?.servername||u},{socket:v,statusCode:j}=await this[Si].connect(x);if(j!==200){v.on("error",eee).destroy(),A(new WX(`Proxy response (${j}) !== 200 when HTTP Tunneling`));return}if(iB.proxyConnected.hasSubscribers&&iB.proxyConnected.publish({socket:v,connectParams:x}),b.protocol!=="https:"){A(null,v);return}let I;this[Lk]?I=this[Lk].servername:I=b.servername,this[sB]({...b,servername:I,httpSocket:v},A)}catch(x){x.code==="ERR_TLS_CERT_ALTNAME_INVALID"?A(new JX(x)):A(x)}}})}dispatch(e,t){let a=tee(e.headers);if(aee(a),a&&!("host"in a)&&!("Host"in a)){let{host:i}=new URL(e.origin);a.host=i}return this[Ld].dispatch({...e,headers:a},t)}#e(e){return typeof e=="string"?new URL(e):e instanceof URL?e:new URL(e.uri)}[cB](){let e=[this[Ld].close()];return this[Si]&&e.push(this[Si].close()),Promise.all(e)}[mB](){let e=[this[Ld].destroy()];return this[Si]&&e.push(this[Si].destroy()),Promise.all(e)}};function tee(o){if(Array.isArray(o)){let e={};for(let t=0;t<o.length;t+=2)e[o[t]]=o[t+1];return e}return o}function aee(o){if(o&&Object.keys(o).find(t=>t.toLowerCase()==="proxy-authorization"))throw new Mr("Proxy-Authorization should be sent in ProxyAgent constructor")}gB.exports=Pk});var yB=y((Zge,bB)=>{"use strict";var iee=Ar(),{kClose:ree,kDestroy:see,kClosed:pB,kDestroyed:hB,kDispatch:nee,kNoProxyAgent:qm,kHttpProxyAgent:Di,kHttpsProxyAgent:_r}=de(),fB=Hk(),cee=Rr(),mee={"http:":80,"https:":443},Gk=class extends iee{#e=null;#o=null;#a=null;constructor(e={}){super(),this.#a=e;let{httpProxy:t,httpsProxy:a,noProxy:i,...r}=e;this[qm]=new cee(r);let s=t??process.env.http_proxy??process.env.HTTP_PROXY;s?this[Di]=new fB({...r,uri:s}):this[Di]=this[qm];let n=a??process.env.https_proxy??process.env.HTTPS_PROXY;n?this[_r]=new fB({...r,uri:n}):this[_r]=this[Di],this.#t()}[nee](e,t){let a=new URL(e.origin);return this.#i(a).dispatch(e,t)}[ree](){return Promise.all([this[qm].close(),!this[Di][pB]&&this[Di].close(),!this[_r][pB]&&this[_r].close()])}[see](e){return Promise.all([this[qm].destroy(e),!this[Di][hB]&&this[Di].destroy(e),!this[_r][hB]&&this[_r].destroy(e)])}#i(e){let{protocol:t,host:a,port:i}=e;return a=a.replace(/:\d*$/,"").toLowerCase(),i=Number.parseInt(i,10)||mee[t]||0,this.#r(a,i)?t==="https:"?this[_r]:this[Di]:this[qm]}#r(e,t){if(this.#c&&this.#t(),this.#o.length===0)return!0;if(this.#e==="*")return!1;for(let a=0;a<this.#o.length;a++){let i=this.#o[a];if(!(i.port&&i.port!==t)&&(e===i.hostname||e.slice(-(i.hostname.length+1))===`.${i.hostname}`))return!1}return!0}#t(){let e=this.#a.noProxy??this.#s,t=e.split(/[,\s]/),a=[];for(let i=0;i<t.length;i++){let r=t[i];if(!r)continue;let s=r.match(/^(.+):(\d+)$/);a.push({hostname:(s?s[1]:r).replace(/^\*?\./,"").toLowerCase(),port:s?Number.parseInt(s[2],10):0})}this.#e=e,this.#o=a}get#c(){return this.#a.noProxy!==void 0?!1:this.#e!==this.#s}get#s(){return process.env.no_proxy??process.env.NO_PROXY??""}};bB.exports=Gk});var Fd=y((Xge,xB)=>{"use strict";var an=require("assert"),{kRetryHandlerDefaultRetry:kB}=de(),{RequestRetryError:rn}=$(),lee=Jc(),{isDisturbed:AB,parseRangeHeader:wB,wrapRequestBody:uee}=K();function dee(o){let e=new Date(o).getTime();return isNaN(e)?0:e-Date.now()}function vB(o,e,t,a){let i=o["content-length"];if(i==null||!Number.isFinite(e.start)||!Number.isFinite(e.end))return;let r=Number(i),s=e.end-e.start+1;if(!Number.isFinite(r)||r!==s)throw new rn("Content-Length mismatch",t,{headers:o,data:{count:a}})}var Yk=class o{constructor(e,{dispatch:t,handler:a}){let{retryOptions:i,...r}=e,{retry:s,maxRetries:n,maxTimeout:c,minTimeout:m,timeoutFactor:l,methods:u,errorCodes:d,retryAfter:g,statusCodes:p,throwOnError:b}=i??{};this.error=null,this.dispatch=t,this.handler=lee.wrap(a),this.opts={...r,body:uee(e.body)},this.retryOpts={throwOnError:b??!0,retry:s??o[kB],retryAfter:g??!0,maxTimeout:c??30*1e3,minTimeout:m??500,timeoutFactor:l??2,maxRetries:n??5,methods:u??["GET","HEAD","OPTIONS","PUT","DELETE","TRACE"],statusCodes:p??[500,502,503,504,429],errorCodes:d??["ECONNRESET","ECONNREFUSED","ENOTFOUND","ENETDOWN","ENETUNREACH","EHOSTDOWN","EHOSTUNREACH","EPIPE","UND_ERR_SOCKET"]},this.retryCount=0,this.retryCountCheckpoint=0,this.headersSent=!1,this.start=0,this.end=null,this.etag=null}onResponseStartWithRetry(e,t,a,i,r){if(this.retryOpts.throwOnError){this.retryOpts.statusCodes.includes(t)===!1?(this.headersSent=!0,this.handler.onResponseStart?.(e,t,a,i)):this.error=r;return}if(AB(this.opts.body)){this.headersSent=!0,this.handler.onResponseStart?.(e,t,a,i);return}function s(n){if(n){this.headersSent=!0,this.handler.onResponseStart?.(e,t,a,i),e.resume();return}this.error=r,e.resume()}e.pause(),this.retryOpts.retry(r,{state:{counter:this.retryCount},opts:{retryOptions:this.retryOpts,...this.opts}},s.bind(this))}onRequestStart(e,t){this.headersSent||this.handler.onRequestStart?.(e,t)}onRequestUpgrade(e,t,a,i){this.handler.onRequestUpgrade?.(e,t,a,i)}static[kB](e,{state:t,opts:a},i){let{statusCode:r,code:s,headers:n}=e,{method:c,retryOptions:m}=a,{maxRetries:l,minTimeout:u,maxTimeout:d,timeoutFactor:g,statusCodes:p,errorCodes:b,methods:A}=m,{counter:k}=t;if(s&&s!=="UND_ERR_REQ_RETRY"&&!b.includes(s)){i(e);return}if(Array.isArray(A)&&!A.includes(c)){i(e);return}if(r!=null&&Array.isArray(p)&&!p.includes(r)){i(e);return}if(k>l){i(e);return}let x=n?.["retry-after"];x&&(x=Number(x),x=Number.isNaN(x)?dee(n["retry-after"]):x*1e3);let v=x>0?Math.min(x,d):Math.min(u*g**(k-1),d);setTimeout(()=>i(null),v)}onResponseStart(e,t,a,i){if(this.error=null,this.retryCount+=1,t>=300){let r=new rn("Request failed",t,{headers:a,data:{count:this.retryCount}});this.onResponseStartWithRetry(e,t,a,i,r);return}if(this.headersSent){if(t!==206&&(this.start>0||t!==200))throw new rn("server does not support the range header and the payload was partially consumed",t,{headers:a,data:{count:this.retryCount}});let r=wB(a["content-range"]);if(!r)throw new rn("Content-Range mismatch",t,{headers:a,data:{count:this.retryCount}});if(this.etag!=null&&this.etag!==a.etag)throw new rn("ETag mismatch",t,{headers:a,data:{count:this.retryCount}});vB(a,r,t,this.retryCount);let{start:s,size:n,end:c=n?n-1:null}=r;an(this.start===s,"content-range mismatch"),an(this.end==null||this.end===c,"content-range mismatch");return}if(this.end==null){if(t===206){let r=wB(a["content-range"]);if(r==null){this.headersSent=!0,this.handler.onResponseStart?.(e,t,a,i);return}vB(a,r,t,this.retryCount);let{start:s,size:n,end:c=n?n-1:null}=r;an(s!=null&&Number.isFinite(s),"content-range mismatch"),an(c!=null&&Number.isFinite(c),"invalid content-length"),this.start=s,this.end=c}if(this.end==null){let r=a["content-length"];this.end=r!=null?Number(r)-1:null}an(Number.isFinite(this.start)),an(this.end==null||Number.isFinite(this.end),"invalid content-length"),this.resume=!0,this.etag=a.etag!=null?a.etag:null,this.etag!=null&&this.etag[0]==="W"&&this.etag[1]==="/"&&(this.etag=null),this.headersSent=!0,this.handler.onResponseStart?.(e,t,a,i)}else throw new rn("Request failed",t,{headers:a,data:{count:this.retryCount}})}onResponseData(e,t){this.error||(this.start+=t.length,this.handler.onResponseData?.(e,t))}onResponseEnd(e,t){if(this.error&&this.retryOpts.throwOnError)throw this.error;if(!this.error)return this.retryCount=0,this.handler.onResponseEnd?.(e,t);this.retry(e)}retry(e){if(this.start!==0){let t={range:`bytes=${this.start}-${this.end??""}`};this.etag!=null&&(t["if-match"]=this.etag),this.opts={...this.opts,headers:{...this.opts.headers,...t}}}try{this.retryCountCheckpoint=this.retryCount,this.dispatch(this.opts,this)}catch(t){this.handler.onResponseError?.(e,t)}}onResponseError(e,t){if(e?.aborted||AB(this.opts.body)){this.handler.onResponseError?.(e,t);return}function a(i){if(!i){this.retry(e);return}this.handler?.onResponseError?.(e,i)}this.retryCount-this.retryCountCheckpoint>0?this.retryCount=this.retryCountCheckpoint+(this.retryCount-this.retryCountCheckpoint):this.retryCount+=1,this.retryOpts.retry(t,{state:{counter:this.retryCount},opts:{retryOptions:this.retryOpts,...this.opts}},a.bind(this))}};xB.exports=Yk});var qB=y((epe,zB)=>{"use strict";var gee=Kc(),pee=Fd(),Vk=class extends gee{#e=null;#o=null;constructor(e,t={}){super(t),this.#e=e,this.#o=t}dispatch(e,t){let a=new pee({...e,retryOptions:this.#o},{dispatch:this.#e.dispatch.bind(this.#e),handler:t});return this.#e.dispatch(e,a)}close(){return this.#e.close()}destroy(){return this.#e.destroy()}};zB.exports=Vk});var CB=y((ope,IB)=>{"use strict";var{InvalidArgumentError:EB}=$(),hee=Ii(),$k=class extends hee{constructor(e,t){if(typeof e=="string"&&(e=new URL(e)),e.protocol!=="http:")throw new EB("h2c-client: Only h2c protocol is supported");let{maxConcurrentStreams:a,pipelining:i,...r}=t??{},s=100,n=100;if(a!=null&&Number.isInteger(a)&&a>0&&(s=a),i!=null&&Number.isInteger(i)&&i>0&&(n=i),n>s)throw new EB("h2c-client: pipelining cannot be greater than maxConcurrentStreams");super(e,{...r,maxConcurrentStreams:s,pipelining:n,allowH2:!0,useH2c:!0})}};IB.exports=$k});var UB=y((tpe,NB)=>{"use strict";var SB=require("assert"),{Readable:fee}=require("stream"),{RequestAbortedError:DB,NotSupportedError:bee,InvalidArgumentError:yee,AbortError:Pd}=$(),TB=K(),{ReadableStreamFrom:kee}=K(),Ko=Symbol("kConsume"),Hd=Symbol("kReading"),Lr=Symbol("kBody"),jB=Symbol("kAbort"),RB=Symbol("kContentType"),Wk=Symbol("kContentLength"),Jk=Symbol("kUsed"),Gd=Symbol("kBytesRead"),Aee=()=>{},Kk=class extends fee{constructor({resume:e,abort:t,contentType:a="",contentLength:i,highWaterMark:r=64*1024}){super({autoDestroy:!0,read:e,highWaterMark:r}),this._readableState.dataEmitted=!1,this[jB]=t,this[Ko]=null,this[Gd]=0,this[Lr]=null,this[Jk]=!1,this[RB]=a,this[Wk]=Number.isFinite(i)?i:null,this[Hd]=!1}_destroy(e,t){!e&&!this._readableState.endEmitted&&(e=new DB),e&&this[jB](),this[Jk]?t(e):setImmediate(t,e)}on(e,t){return(e==="data"||e==="readable")&&(this[Hd]=!0,this[Jk]=!0),super.on(e,t)}addListener(e,t){return this.on(e,t)}off(e,t){let a=super.off(e,t);return(e==="data"||e==="readable")&&(this[Hd]=this.listenerCount("data")>0||this.listenerCount("readable")>0),a}removeListener(e,t){return this.off(e,t)}push(e){return e&&(this[Gd]+=e.length,this[Ko])?(Xk(this[Ko],e),this[Hd]?super.push(e):!0):super.push(e)}text(){return Em(this,"text")}json(){return Em(this,"json")}blob(){return Em(this,"blob")}bytes(){return Em(this,"bytes")}arrayBuffer(){return Em(this,"arrayBuffer")}async formData(){throw new bee}get bodyUsed(){return TB.isDisturbed(this)}get body(){return this[Lr]||(this[Lr]=kee(this),this[Ko]&&(this[Lr].getReader(),SB(this[Lr].locked))),this[Lr]}dump(e){let t=e?.signal;if(t!=null&&(typeof t!="object"||!("aborted"in t)))return Promise.reject(new yee("signal must be an AbortSignal"));let a=e?.limit&&Number.isFinite(e.limit)?e.limit:128*1024;return t?.aborted?Promise.reject(t.reason??new Pd):this._readableState.closeEmitted?Promise.resolve(null):new Promise((i,r)=>{if((this[Wk]&&this[Wk]>a||this[Gd]>a)&&this.destroy(new Pd),t){let s=()=>{this.destroy(t.reason??new Pd)};t.addEventListener("abort",s),this.on("close",function(){t.removeEventListener("abort",s),t.aborted?r(t.reason??new Pd):i(null)})}else this.on("close",i);this.on("error",Aee).on("data",()=>{this[Gd]>a&&this.destroy()}).resume()})}setEncoding(e){return Buffer.isEncoding(e)&&(this._readableState.encoding=e),this}};function wee(o){return o[Lr]?.locked===!0||o[Ko]!==null}function vee(o){return TB.isDisturbed(o)||wee(o)}function Em(o,e){return SB(!o[Ko]),new Promise((t,a)=>{if(vee(o)){let i=o._readableState;i.destroyed&&i.closeEmitted===!1?o.on("error",a).on("close",()=>{a(new TypeError("unusable"))}):a(i.errored??new TypeError("unusable"))}else queueMicrotask(()=>{o[Ko]={type:e,stream:o,resolve:t,reject:a,length:0,body:[]},o.on("error",function(i){eA(this[Ko],i)}).on("close",function(){this[Ko].body!==null&&eA(this[Ko],new DB)}),xee(o[Ko])})})}function xee(o){if(o.body===null)return;let{_readableState:e}=o.stream;if(e.bufferIndex){let t=e.bufferIndex,a=e.buffer.length;for(let i=t;i<a;i++)Xk(o,e.buffer[i])}else for(let t of e.buffer)Xk(o,t);for(e.endEmitted?QB(this[Ko],this._readableState.encoding):o.stream.on("end",function(){QB(this[Ko],this._readableState.encoding)}),o.stream.resume();o.stream.read()!=null;);}function Zk(o,e,t){if(o.length===0||e===0)return"";let a=o.length===1?o[0]:Buffer.concat(o,e),i=a.length,r=i>2&&a[0]===239&&a[1]===187&&a[2]===191?3:0;return!t||t==="utf8"||t==="utf-8"?a.utf8Slice(r,i):a.subarray(r,i).toString(t)}function BB(o,e){if(o.length===0||e===0)return new Uint8Array(0);if(o.length===1)return new Uint8Array(o[0]);let t=new Uint8Array(Buffer.allocUnsafeSlow(e).buffer),a=0;for(let i=0;i<o.length;++i){let r=o[i];t.set(r,a),a+=r.length}return t}function QB(o,e){let{type:t,body:a,resolve:i,stream:r,length:s}=o;try{t==="text"?i(Zk(a,s,e)):t==="json"?i(JSON.parse(Zk(a,s,e))):t==="arrayBuffer"?i(BB(a,s).buffer):t==="blob"?i(new Blob(a,{type:r[RB]})):t==="bytes"&&i(BB(a,s)),eA(o)}catch(n){r.destroy(n)}}function Xk(o,e){o.length+=e.length,o.body.push(e)}function eA(o,e){o.body!==null&&(e?o.reject(e):o.resolve(),o.type=null,o.stream=null,o.resolve=null,o.reject=null,o.length=0,o.body=null)}NB.exports={Readable:Kk,chunksDecode:Zk}});var _B=y((ape,oA)=>{"use strict";var zee=require("assert"),{AsyncResource:qee}=require("async_hooks"),{Readable:Eee}=UB(),{InvalidArgumentError:sn,RequestAbortedError:OB}=$(),zt=K();function Im(){}var Yd=class extends qee{constructor(e,t){if(!e||typeof e!="object")throw new sn("invalid opts");let{signal:a,method:i,opaque:r,body:s,onInfo:n,responseHeaders:c,highWaterMark:m}=e;try{if(typeof t!="function")throw new sn("invalid callback");if(m!=null&&(!Number.isFinite(m)||m<0))throw new sn("invalid highWaterMark");if(a&&typeof a.on!="function"&&typeof a.addEventListener!="function")throw new sn("signal must be an EventEmitter or EventTarget");if(i==="CONNECT")throw new sn("invalid method");if(n&&typeof n!="function")throw new sn("invalid onInfo callback");super("UNDICI_REQUEST")}catch(l){throw zt.isStream(s)&&zt.destroy(s.on("error",Im),l),l}this.method=i,this.responseHeaders=c||null,this.opaque=r||null,this.callback=t,this.res=null,this.abort=null,this.body=s,this.trailers={},this.context=null,this.onInfo=n||null,this.highWaterMark=m,this.reason=null,this.removeAbortListener=null,a?.aborted?this.reason=a.reason??new OB:a&&(this.removeAbortListener=zt.addAbortListener(a,()=>{this.reason=a.reason??new OB,this.res?zt.destroy(this.res.on("error",Im),this.reason):this.abort&&this.abort(this.reason)}))}onConnect(e,t){if(this.reason){e(this.reason);return}zee(this.callback),this.abort=e,this.context=t}onHeaders(e,t,a,i){let{callback:r,opaque:s,abort:n,context:c,responseHeaders:m,highWaterMark:l}=this,u=m==="raw"?zt.parseRawHeaders(t):zt.parseHeaders(t);if(e<200){this.onInfo&&this.onInfo({statusCode:e,headers:u});return}let d=m==="raw"?zt.parseHeaders(t):u,g=d["content-type"],p=d["content-length"],b=new Eee({resume:a,abort:n,contentType:g,contentLength:this.method!=="HEAD"&&p?Number(p):null,highWaterMark:l});if(this.removeAbortListener&&(b.on("close",this.removeAbortListener),this.removeAbortListener=null),this.callback=null,this.res=b,r!==null)try{this.runInAsyncScope(r,null,null,{statusCode:e,statusText:i,headers:u,trailers:this.trailers,opaque:s,body:b,context:c})}catch(A){this.res=null,zt.destroy(b.on("error",Im),A),queueMicrotask(()=>{throw A})}}onData(e){return this.res.push(e)}onComplete(e){zt.parseHeaders(e,this.trailers),this.res.push(null)}onError(e){let{res:t,callback:a,body:i,opaque:r}=this;a&&(this.callback=null,queueMicrotask(()=>{this.runInAsyncScope(a,null,e,{opaque:r})})),t&&(this.res=null,queueMicrotask(()=>{zt.destroy(t.on("error",Im),e)})),i&&(this.body=null,zt.isStream(i)&&(i.on("error",Im),zt.destroy(i,e))),this.removeAbortListener&&(this.removeAbortListener(),this.removeAbortListener=null)}};function MB(o,e){if(e===void 0)return new Promise((t,a)=>{MB.call(this,o,(i,r)=>i?a(i):t(r))});try{let t=new Yd(o,e);this.dispatch(o,t)}catch(t){if(typeof e!="function")throw t;let a=o?.opaque;queueMicrotask(()=>e(t,{opaque:a}))}}oA.exports=MB;oA.exports.RequestHandler=Yd});var Cm=y((ipe,PB)=>{"use strict";var{addAbortListener:Iee}=K(),{RequestAbortedError:Cee}=$(),nn=Symbol("kListener"),sa=Symbol("kSignal");function LB(o){o.abort?o.abort(o[sa]?.reason):o.reason=o[sa]?.reason??new Cee,FB(o)}function jee(o,e){if(o.reason=null,o[sa]=null,o[nn]=null,!!e){if(e.aborted){LB(o);return}o[sa]=e,o[nn]=()=>{LB(o)},Iee(o[sa],o[nn])}}function FB(o){o[sa]&&("removeEventListener"in o[sa]?o[sa].removeEventListener("abort",o[nn]):o[sa].removeListener("abort",o[nn]),o[sa]=null,o[nn]=null)}PB.exports={addSignal:jee,removeSignal:FB}});var VB=y((rpe,YB)=>{"use strict";var Bee=require("assert"),{finished:Qee}=require("stream"),{AsyncResource:See}=require("async_hooks"),{InvalidArgumentError:cn,InvalidReturnValueError:Dee}=$(),Pa=K(),{addSignal:Tee,removeSignal:HB}=Cm();function Ree(){}var tA=class extends See{constructor(e,t,a){if(!e||typeof e!="object")throw new cn("invalid opts");let{signal:i,method:r,opaque:s,body:n,onInfo:c,responseHeaders:m}=e;try{if(typeof a!="function")throw new cn("invalid callback");if(typeof t!="function")throw new cn("invalid factory");if(i&&typeof i.on!="function"&&typeof i.addEventListener!="function")throw new cn("signal must be an EventEmitter or EventTarget");if(r==="CONNECT")throw new cn("invalid method");if(c&&typeof c!="function")throw new cn("invalid onInfo callback");super("UNDICI_STREAM")}catch(l){throw Pa.isStream(n)&&Pa.destroy(n.on("error",Ree),l),l}this.responseHeaders=m||null,this.opaque=s||null,this.factory=t,this.callback=a,this.res=null,this.abort=null,this.context=null,this.trailers=null,this.body=n,this.onInfo=c||null,Pa.isStream(n)&&n.on("error",l=>{this.onError(l)}),Tee(this,i)}onConnect(e,t){if(this.reason){e(this.reason);return}Bee(this.callback),this.abort=e,this.context=t}onHeaders(e,t,a,i){let{factory:r,opaque:s,context:n,responseHeaders:c}=this,m=c==="raw"?Pa.parseRawHeaders(t):Pa.parseHeaders(t);if(e<200){this.onInfo&&this.onInfo({statusCode:e,headers:m});return}if(this.factory=null,r===null)return;let l=this.runInAsyncScope(r,null,{statusCode:e,headers:m,opaque:s,context:n});if(!l||typeof l.write!="function"||typeof l.end!="function"||typeof l.on!="function")throw new Dee("expected Writable");return Qee(l,{readable:!1},d=>{let{callback:g,res:p,opaque:b,trailers:A,abort:k}=this;this.res=null,(d||!p?.readable)&&Pa.destroy(p,d),this.callback=null,this.runInAsyncScope(g,null,d||null,{opaque:b,trailers:A}),d&&k()}),l.on("drain",a),this.res=l,(l.writableNeedDrain!==void 0?l.writableNeedDrain:l._writableState?.needDrain)!==!0}onData(e){let{res:t}=this;return t?t.write(e):!0}onComplete(e){let{res:t}=this;HB(this),t&&(this.trailers=Pa.parseHeaders(e),t.end())}onError(e){let{res:t,callback:a,opaque:i,body:r}=this;HB(this),this.factory=null,t?(this.res=null,Pa.destroy(t,e)):a&&(this.callback=null,queueMicrotask(()=>{this.runInAsyncScope(a,null,e,{opaque:i})})),r&&(this.body=null,Pa.destroy(r,e))}};function GB(o,e,t){if(t===void 0)return new Promise((a,i)=>{GB.call(this,o,e,(r,s)=>r?i(r):a(s))});try{let a=new tA(o,e,t);this.dispatch(o,a)}catch(a){if(typeof t!="function")throw a;let i=o?.opaque;queueMicrotask(()=>t(a,{opaque:i}))}}YB.exports=GB});var KB=y((spe,JB)=>{"use strict";var{Readable:WB,Duplex:Nee,PassThrough:Uee}=require("stream"),Oee=require("assert"),{AsyncResource:Mee}=require("async_hooks"),{InvalidArgumentError:jm,InvalidReturnValueError:_ee,RequestAbortedError:aA}=$(),na=K(),{addSignal:Lee,removeSignal:Fee}=Cm();function $B(){}var mn=Symbol("resume"),iA=class extends WB{constructor(){super({autoDestroy:!0}),this[mn]=null}_read(){let{[mn]:e}=this;e&&(this[mn]=null,e())}_destroy(e,t){this._read(),t(e)}},rA=class extends WB{constructor(e){super({autoDestroy:!0}),this[mn]=e}_read(){this[mn]()}_destroy(e,t){!e&&!this._readableState.endEmitted&&(e=new aA),t(e)}},sA=class extends Mee{constructor(e,t){if(!e||typeof e!="object")throw new jm("invalid opts");if(typeof t!="function")throw new jm("invalid handler");let{signal:a,method:i,opaque:r,onInfo:s,responseHeaders:n}=e;if(a&&typeof a.on!="function"&&typeof a.addEventListener!="function")throw new jm("signal must be an EventEmitter or EventTarget");if(i==="CONNECT")throw new jm("invalid method");if(s&&typeof s!="function")throw new jm("invalid onInfo callback");super("UNDICI_PIPELINE"),this.opaque=r||null,this.responseHeaders=n||null,this.handler=t,this.abort=null,this.context=null,this.onInfo=s||null,this.req=new iA().on("error",$B),this.ret=new Nee({readableObjectMode:e.objectMode,autoDestroy:!0,read:()=>{let{body:c}=this;c?.resume&&c.resume()},write:(c,m,l)=>{let{req:u}=this;u.push(c,m)||u._readableState.destroyed?l():u[mn]=l},destroy:(c,m)=>{let{body:l,req:u,res:d,ret:g,abort:p}=this;!c&&!g._readableState.endEmitted&&(c=new aA),p&&c&&p(),na.destroy(l,c),na.destroy(u,c),na.destroy(d,c),Fee(this),m(c)}}).on("prefinish",()=>{let{req:c}=this;c.push(null)}),this.res=null,Lee(this,a)}onConnect(e,t){let{res:a}=this;if(this.reason){e(this.reason);return}Oee(!a,"pipeline cannot be retried"),this.abort=e,this.context=t}onHeaders(e,t,a){let{opaque:i,handler:r,context:s}=this;if(e<200){if(this.onInfo){let c=this.responseHeaders==="raw"?na.parseRawHeaders(t):na.parseHeaders(t);this.onInfo({statusCode:e,headers:c})}return}this.res=new rA(a);let n;try{this.handler=null;let c=this.responseHeaders==="raw"?na.parseRawHeaders(t):na.parseHeaders(t);n=this.runInAsyncScope(r,null,{statusCode:e,headers:c,opaque:i,body:this.res,context:s})}catch(c){throw this.res.on("error",$B),c}if(!n||typeof n.on!="function")throw new _ee("expected Readable");n.on("data",c=>{let{ret:m,body:l}=this;!m.push(c)&&l.pause&&l.pause()}).on("error",c=>{let{ret:m}=this;na.destroy(m,c)}).on("end",()=>{let{ret:c}=this;c.push(null)}).on("close",()=>{let{ret:c}=this;c._readableState.ended||na.destroy(c,new aA)}),this.body=n}onData(e){let{res:t}=this;return t.push(e)}onComplete(e){let{res:t}=this;t.push(null)}onError(e){let{ret:t}=this;this.handler=null,na.destroy(t,e)}};function Pee(o,e){try{let t=new sA(o,e);return this.dispatch({...o,body:t.req},t),t.ret}catch(t){return new Uee().destroy(t)}}JB.exports=Pee});var aQ=y((npe,tQ)=>{"use strict";var{InvalidArgumentError:nA,SocketError:Hee}=$(),{AsyncResource:Gee}=require("async_hooks"),ZB=require("assert"),XB=K(),{kHTTP2Stream:Yee}=de(),{addSignal:Vee,removeSignal:eQ}=Cm(),cA=class extends Gee{constructor(e,t){if(!e||typeof e!="object")throw new nA("invalid opts");if(typeof t!="function")throw new nA("invalid callback");let{signal:a,opaque:i,responseHeaders:r}=e;if(a&&typeof a.on!="function"&&typeof a.addEventListener!="function")throw new nA("signal must be an EventEmitter or EventTarget");super("UNDICI_UPGRADE"),this.responseHeaders=r||null,this.opaque=i||null,this.callback=t,this.abort=null,this.context=null,Vee(this,a)}onConnect(e,t){if(this.reason){e(this.reason);return}ZB(this.callback),this.abort=e,this.context=null}onHeaders(){throw new Hee("bad upgrade",null)}onUpgrade(e,t,a){ZB(a[Yee]===!0?e===200:e===101);let{callback:i,opaque:r,context:s}=this;eQ(this),this.callback=null;let n=this.responseHeaders==="raw"?XB.parseRawHeaders(t):XB.parseHeaders(t);this.runInAsyncScope(i,null,null,{headers:n,socket:a,opaque:r,context:s})}onError(e){let{callback:t,opaque:a}=this;eQ(this),t&&(this.callback=null,queueMicrotask(()=>{this.runInAsyncScope(t,null,e,{opaque:a})}))}};function oQ(o,e){if(e===void 0)return new Promise((t,a)=>{oQ.call(this,o,(i,r)=>i?a(i):t(r))});try{let t=new cA(o,e),a={...o,method:o.method||"GET",upgrade:o.protocol||"Websocket"};this.dispatch(a,t)}catch(t){if(typeof e!="function")throw t;let a=o?.opaque;queueMicrotask(()=>e(t,{opaque:a}))}}tQ.exports=oQ});var cQ=y((cpe,nQ)=>{"use strict";var $ee=require("assert"),{AsyncResource:Wee}=require("async_hooks"),{InvalidArgumentError:mA,SocketError:Jee}=$(),iQ=K(),{addSignal:Kee,removeSignal:rQ}=Cm(),lA=class extends Wee{constructor(e,t){if(!e||typeof e!="object")throw new mA("invalid opts");if(typeof t!="function")throw new mA("invalid callback");let{signal:a,opaque:i,responseHeaders:r}=e;if(a&&typeof a.on!="function"&&typeof a.addEventListener!="function")throw new mA("signal must be an EventEmitter or EventTarget");super("UNDICI_CONNECT"),this.opaque=i||null,this.responseHeaders=r||null,this.callback=t,this.abort=null,Kee(this,a)}onConnect(e,t){if(this.reason){e(this.reason);return}$ee(this.callback),this.abort=e,this.context=t}onHeaders(){throw new Jee("bad connect",null)}onUpgrade(e,t,a){let{callback:i,opaque:r,context:s}=this;rQ(this),this.callback=null;let n=t;n!=null&&(n=this.responseHeaders==="raw"?iQ.parseRawHeaders(t):iQ.parseHeaders(t)),this.runInAsyncScope(i,null,null,{statusCode:e,headers:n,socket:a,opaque:r,context:s})}onError(e){let{callback:t,opaque:a}=this;rQ(this),t&&(this.callback=null,queueMicrotask(()=>{this.runInAsyncScope(t,null,e,{opaque:a})}))}};function sQ(o,e){if(e===void 0)return new Promise((t,a)=>{sQ.call(this,o,(i,r)=>i?a(i):t(r))});try{let t=new lA(o,e),a={...o,method:"CONNECT"};this.dispatch(a,t)}catch(t){if(typeof e!="function")throw t;let a=o?.opaque;queueMicrotask(()=>e(t,{opaque:a}))}}nQ.exports=sQ});var mQ=y((mpe,ln)=>{"use strict";ln.exports.request=_B();ln.exports.stream=VB();ln.exports.pipeline=KB();ln.exports.upgrade=aQ();ln.exports.connect=cQ()});var dA=y((lpe,uQ)=>{"use strict";var{UndiciError:Zee}=$(),lQ=Symbol.for("undici.error.UND_MOCK_ERR_MOCK_NOT_MATCHED"),uA=class extends Zee{constructor(e){super(e),this.name="MockNotMatchedError",this.message=e||"The request does not match any registered mock dispatches",this.code="UND_MOCK_ERR_MOCK_NOT_MATCHED"}static[Symbol.hasInstance](e){return e&&e[lQ]===!0}get[lQ](){return!0}};uQ.exports={MockNotMatchedError:uA}});var Fr=y((upe,dQ)=>{"use strict";dQ.exports={kAgent:Symbol("agent"),kOptions:Symbol("options"),kFactory:Symbol("factory"),kDispatches:Symbol("dispatches"),kDispatchKey:Symbol("dispatch key"),kDefaultHeaders:Symbol("default headers"),kDefaultTrailers:Symbol("default trailers"),kContentLength:Symbol("content length"),kMockAgent:Symbol("mock agent"),kMockAgentSet:Symbol("mock agent set"),kMockAgentGet:Symbol("mock agent get"),kMockDispatch:Symbol("mock dispatch"),kClose:Symbol("close"),kOriginalClose:Symbol("original agent close"),kOriginalDispatch:Symbol("original dispatch"),kOrigin:Symbol("origin"),kIsMockActive:Symbol("is mock active"),kNetConnect:Symbol("net connect"),kGetNetConnect:Symbol("get net connect"),kConnected:Symbol("connected"),kIgnoreTrailingSlash:Symbol("ignore trailing slash"),kMockAgentMockCallHistoryInstance:Symbol("mock agent mock call history name"),kMockAgentRegisterCallHistory:Symbol("mock agent register mock call history"),kMockAgentAddCallHistoryLog:Symbol("mock agent add call history log"),kMockAgentIsCallHistoryEnabled:Symbol("mock agent is call history enabled"),kMockAgentAcceptsNonStandardSearchParameters:Symbol("mock agent accepts non standard search parameters"),kMockCallHistoryAddLog:Symbol("mock call history add log"),kTotalDispatchCount:Symbol("total dispatch count")}});var Bm=y((dpe,xQ)=>{"use strict";var{MockNotMatchedError:un}=dA(),{kDispatches:Pr,kMockAgent:Xee,kOriginalDispatch:eoe,kOrigin:ooe,kGetNetConnect:toe,kTotalDispatchCount:hA}=Fr(),{serializePathWithQuery:aoe}=K(),{STATUS_CODES:ioe}=require("http"),{types:{isPromise:roe}}=require("util"),{InvalidArgumentError:gA}=$();function ca(o,e){return typeof o=="string"?o===e:o instanceof RegExp?o.test(e):typeof o=="function"?o(e)===!0:!1}function pQ(o){return Object.fromEntries(Object.entries(o).map(([e,t])=>[e.toLocaleLowerCase(),t]))}function hQ(o,e){if(Array.isArray(o)){for(let t=0;t<o.length;t+=2)if(o[t].toLocaleLowerCase()===e.toLocaleLowerCase())return o[t+1];return}else return typeof o.get=="function"?o.get(e):pQ(o)[e.toLocaleLowerCase()]}function yA(o){let e=o.slice(),t=[];for(let a=0;a<e.length;a+=2)t.push([e[a],e[a+1]]);return Object.fromEntries(t)}function fQ(o,e){if(typeof o.headers=="function")return Array.isArray(e)&&(e=yA(e)),o.headers(e?pQ(e):{});if(typeof o.headers>"u")return!0;if(typeof e!="object"||typeof o.headers!="object")return!1;for(let[t,a]of Object.entries(o.headers)){let i=hQ(e,t);if(!ca(a,i))return!1}return!0}function soe(o){if(typeof o!="string")return o;let e=new URLSearchParams(o),t=new URLSearchParams;for(let[a,i]of e.entries()){if(a=a.replace("[]",""),/^(['"]).*\1$/.test(i)){t.append(a,i);continue}if(i.includes(",")){let s=i.split(",");for(let n of s)t.append(a,n);continue}t.append(a,i)}return t}function pA(o){if(typeof o!="string")return o;let e=o.split("?",3);if(e.length!==2)return o;let t=new URLSearchParams(e.pop());return t.sort(),[...e,t.toString()].join("?")}function noe(o,{path:e,method:t,body:a,headers:i}){let r=ca(o.path,e),s=ca(o.method,t),n=typeof o.body<"u"?ca(o.body,a):!0,c=fQ(o,i);return r&&s&&n&&c}function bQ(o){return Buffer.isBuffer(o)||o instanceof Uint8Array||o instanceof ArrayBuffer?o:typeof o=="object"?JSON.stringify(o):o?o.toString():""}function yQ(o,e){let t=e.query?aoe(e.path,e.query):e.path,a=typeof t=="string"?pA(t):t,i=gQ(a),r=o.filter(({consumed:s})=>!s).filter(({path:s,ignoreTrailingSlash:n})=>n?ca(gQ(pA(s)),i):ca(pA(s),a));if(r.length===0)throw new un(`Mock dispatch not matched for path '${a}'`);if(r=r.filter(({method:s})=>ca(s,e.method)),r.length===0)throw new un(`Mock dispatch not matched for method '${e.method}' on path '${a}'`);if(r=r.filter(({body:s})=>typeof s<"u"?ca(s,e.body):!0),r.length===0)throw new un(`Mock dispatch not matched for body '${e.body}' on path '${a}'`);if(r=r.filter(s=>fQ(s,e.headers)),r.length===0){let s=typeof e.headers=="object"?JSON.stringify(e.headers):e.headers;throw new un(`Mock dispatch not matched for headers '${s}' on path '${a}'`)}return r[0]}function coe(o,e,t,a){let i={timesInvoked:0,times:1,persist:!1,consumed:!1,...a},r=typeof t=="function"?{callback:t}:{...t},s={...i,...e,pending:!0,data:{error:null,...r}};return o.push(s),o[hA]=(o[hA]||0)+1,s}function fA(o,e){let t=o.findIndex(a=>a.consumed?noe(a,e):!1);t!==-1&&o.splice(t,1)}function gQ(o){for(;o.endsWith("/");)o=o.slice(0,-1);return o.length===0&&(o="/"),o}function kQ(o){let{path:e,method:t,body:a,headers:i,query:r}=o;return{path:e,method:t,body:a,headers:i,query:r}}function bA(o){let e=Object.keys(o),t=[];for(let a=0;a<e.length;++a){let i=e[a],r=o[i],s=Buffer.from(`${i}`);if(Array.isArray(r))for(let n=0;n<r.length;++n)t.push(s,Buffer.from(`${r[n]}`));else t.push(s,Buffer.from(`${r}`))}return t}function AQ(o){return ioe[o]||"unknown"}async function moe(o){let e=[];for await(let t of o)e.push(t);return Buffer.concat(e).toString("utf8")}function wQ(o,e){let t=kQ(o),a=yQ(this[Pr],t);a.timesInvoked++,a.data.callback&&(a.data={...a.data,...a.data.callback(o)});let{data:{statusCode:i,data:r,headers:s,trailers:n,error:c},delay:m,persist:l}=a,{timesInvoked:u,times:d}=a;if(a.consumed=!l&&u>=d,a.pending=u<d,c!==null)return fA(this[Pr],t),e.onError(c),!0;let g=!1,p=null;function b(x){g||(g=!0,p!==null&&(clearTimeout(p),p=null),e.onError(x))}e.onConnect?.(b,null),typeof m=="number"&&m>0?p=setTimeout(()=>{p=null,A(this[Pr])},m):A(this[Pr]);function A(x,v=r){if(g)return;let j=Array.isArray(o.headers)?yA(o.headers):o.headers,I=typeof v=="function"?v({...o,headers:j}):v;if(roe(I))return I.then(S=>A(x,S));if(g)return;let T=bQ(I),D=bA(s),O=bA(n);e.onHeaders?.(i,D,k,AQ(i)),e.onData?.(Buffer.from(T)),e.onComplete?.(O),fA(x,t)}function k(){}return!0}function loe(){let o=this[Xee],e=this[ooe],t=this[eoe];return function(i,r){if(o.isMockActive)try{wQ.call(this,i,r)}catch(s){if(s.code==="UND_MOCK_ERR_MOCK_NOT_MATCHED"){let n=o[toe](),c=this[Pr][hA]||this[Pr].length,l=`, ${this[Pr].filter(({consumed:u})=>!u).length} interceptor(s) remaining out of ${c} defined`;if(n===!1)throw new un(`${s.message}: subsequent request to origin ${e} was not allowed (net.connect disabled)${l}`);if(vQ(n,e))t.call(this,i,r);else throw new un(`${s.message}: subsequent request to origin ${e} was not allowed (net.connect is not enabled for this origin)${l}`)}else throw s}else t.call(this,i,r)}}function vQ(o,e){let t=new URL(e);return o===!0?!0:!!(Array.isArray(o)&&o.some(a=>ca(a,t.host)))}function uoe(o){return typeof o!="string"&&!(o instanceof URL)?o:o instanceof URL?o.origin:o.toLowerCase()}function doe(o){let{agent:e,...t}=o;if("enableCallHistory"in t&&typeof t.enableCallHistory!="boolean")throw new gA("options.enableCallHistory must to be a boolean");if("acceptNonStandardSearchParameters"in t&&typeof t.acceptNonStandardSearchParameters!="boolean")throw new gA("options.acceptNonStandardSearchParameters must to be a boolean");if("ignoreTrailingSlash"in t&&typeof t.ignoreTrailingSlash!="boolean")throw new gA("options.ignoreTrailingSlash must to be a boolean");return t}xQ.exports={getResponseData:bQ,getMockDispatch:yQ,addMockDispatch:coe,deleteMockDispatch:fA,buildKey:kQ,generateKeyValues:bA,matchValue:ca,getResponse:moe,getStatusText:AQ,mockDispatch:wQ,buildMockDispatch:loe,checkNetConnect:vQ,buildAndValidateMockOptions:doe,getHeaderByName:hQ,buildHeadersFromArray:yA,normalizeSearchParams:soe,normalizeOrigin:uoe}});var qA=y((gpe,zA)=>{"use strict";var{getResponseData:goe,buildKey:poe,addMockDispatch:kA}=Bm(),{kDispatches:Vd,kDispatchKey:$d,kDefaultHeaders:AA,kDefaultTrailers:wA,kContentLength:vA,kMockDispatch:Wd,kIgnoreTrailingSlash:Jd}=Fr(),{InvalidArgumentError:ma}=$(),{serializePathWithQuery:hoe}=K(),dn=class{constructor(e){this[Wd]=e}delay(e){if(typeof e!="number"||!Number.isInteger(e)||e<=0)throw new ma("waitInMs must be a valid integer > 0");return this[Wd].delay=e,this}persist(){return this[Wd].persist=!0,this}times(e){if(typeof e!="number"||!Number.isInteger(e)||e<=0)throw new ma("repeatTimes must be a valid integer > 0");return this[Wd].times=e,this}},xA=class{constructor(e,t){if(typeof e!="object")throw new ma("opts must be an object");if(typeof e.path>"u")throw new ma("opts.path must be defined");if(typeof e.method>"u"&&(e.method="GET"),typeof e.path=="string")if(e.query)e.path=hoe(e.path,e.query);else{let a=new URL(e.path,"data://");e.path=a.pathname+a.search}typeof e.method=="string"&&(e.method=e.method.toUpperCase()),this[$d]=poe(e),this[Vd]=t,this[Jd]=e.ignoreTrailingSlash??!1,this[AA]={},this[wA]={},this[vA]=!1}createMockScopeDispatchData({statusCode:e,data:t,responseOptions:a}){let i=goe(t),r=this[vA]?{"content-length":i.length}:{},s={...this[AA],...r,...a.headers},n={...this[wA],...a.trailers};return{statusCode:e,data:t,headers:s,trailers:n}}validateReplyParameters(e){if(typeof e.statusCode>"u")throw new ma("statusCode must be defined");if(typeof e.responseOptions!="object"||e.responseOptions===null)throw new ma("responseOptions must be an object")}reply(e){if(typeof e=="function"){let r=n=>{let c=e(n);if(typeof c!="object"||c===null)throw new ma("reply options callback must return an object");let m={data:"",responseOptions:{},...c};return this.validateReplyParameters(m),{...this.createMockScopeDispatchData(m)}},s=kA(this[Vd],this[$d],r,{ignoreTrailingSlash:this[Jd]});return new dn(s)}let t={statusCode:e,data:arguments[1]===void 0?"":arguments[1],responseOptions:arguments[2]===void 0?{}:arguments[2]};this.validateReplyParameters(t);let a=this.createMockScopeDispatchData(t),i=kA(this[Vd],this[$d],a,{ignoreTrailingSlash:this[Jd]});return new dn(i)}replyWithError(e){if(typeof e>"u")throw new ma("error must be defined");let t=kA(this[Vd],this[$d],{error:e},{ignoreTrailingSlash:this[Jd]});return new dn(t)}defaultReplyHeaders(e){if(typeof e>"u")throw new ma("headers must be defined");return this[AA]=e,this}defaultReplyTrailers(e){if(typeof e>"u")throw new ma("trailers must be defined");return this[wA]=e,this}replyContentLength(){return this[vA]=!0,this}};zA.exports.MockInterceptor=xA;zA.exports.MockScope=dn});var jA=y((ppe,BQ)=>{"use strict";var{promisify:foe}=require("util"),boe=Ii(),{buildMockDispatch:yoe}=Bm(),{kDispatches:EA,kMockAgent:zQ,kClose:qQ,kOriginalClose:EQ,kOrigin:IQ,kOriginalDispatch:koe,kConnected:IA,kIgnoreTrailingSlash:CQ}=Fr(),{MockInterceptor:Aoe}=qA(),jQ=de(),{InvalidArgumentError:woe}=$(),CA=class extends boe{constructor(e,t){if(!t||!t.agent||typeof t.agent.dispatch!="function")throw new woe("Argument opts.agent must implement Agent");super(e,t),this[zQ]=t.agent,this[IQ]=e,this[CQ]=t.ignoreTrailingSlash??!1,this[EA]=[],this[IA]=1,this[koe]=this.dispatch,this[EQ]=this.close.bind(this),this.dispatch=yoe.call(this),this.close=this[qQ]}get[jQ.kConnected](){return this[IA]}intercept(e){return new Aoe(e&&{ignoreTrailingSlash:this[CQ],...e},this[EA])}cleanMocks(){this[EA]=[]}async[qQ](){await foe(this[EQ])(),this[IA]=0,this[zQ][jQ.kClients].delete(this[IQ])}};BQ.exports=CA});var SA=y((hpe,QA)=>{"use strict";var{kMockCallHistoryAddLog:voe}=Fr(),{InvalidArgumentError:Ni}=$();function Ti(o,e,t,a,i){switch(e.operator){case"OR":return a.push(...t(o,i)),a;case"AND":return t(o,a);default:throw new Ni("options.operator must to be a case insensitive string equal to 'OR' or 'AND'")}}function xoe(o={}){let e={};if("operator"in o){if(typeof o.operator!="string"||o.operator.toUpperCase()!=="OR"&&o.operator.toUpperCase()!=="AND")throw new Ni("options.operator must to be a case insensitive string equal to 'OR' or 'AND'");return{...e,operator:o.operator.toUpperCase()}}return e}function Ri(o){return(e,t)=>{if(typeof e=="string"||e==null)return t.filter(a=>a[o]===e);if(e instanceof RegExp)return t.filter(a=>e.test(a[o]));throw new Ni(`${o} parameter should be one of string, regexp, undefined or null`)}}function zoe(o){try{let e=new URL(o.path,o.origin);return e.search.length!==0||(e.search=new URLSearchParams(o.query).toString()),e}catch(e){throw new Ni("An error occurred when computing MockCallHistoryLog.url",{cause:e})}}var Kd=class{constructor(e={}){this.body=e.body,this.headers=e.headers,this.method=e.method;let t=zoe(e);this.fullUrl=t.toString(),this.origin=t.origin,this.path=t.pathname,this.searchParams=Object.fromEntries(t.searchParams),this.protocol=t.protocol,this.host=t.host,this.port=t.port,this.hash=t.hash}toMap(){return new Map([["protocol",this.protocol],["host",this.host],["port",this.port],["origin",this.origin],["path",this.path],["hash",this.hash],["searchParams",this.searchParams],["fullUrl",this.fullUrl],["method",this.method],["body",this.body],["headers",this.headers]])}toString(){let e={betweenKeyValueSeparator:"->",betweenPairSeparator:"|"},t="";return this.toMap().forEach((a,i)=>{(typeof a=="string"||a===void 0||a===null)&&(t=`${t}${i}${e.betweenKeyValueSeparator}${a}${e.betweenPairSeparator}`),(typeof a=="object"&&a!==null||Array.isArray(a))&&(t=`${t}${i}${e.betweenKeyValueSeparator}${JSON.stringify(a)}${e.betweenPairSeparator}`)}),t.slice(0,-1)}},BA=class{logs=[];calls(){return this.logs}firstCall(){return this.logs.at(0)}lastCall(){return this.logs.at(-1)}nthCall(e){if(typeof e!="number")throw new Ni("nthCall must be called with a number");if(!Number.isInteger(e))throw new Ni("nthCall must be called with an integer");if(Math.sign(e)!==1)throw new Ni("nthCall must be called with a positive value. use firstCall or lastCall instead");return this.logs.at(e-1)}filterCalls(e,t){if(this.logs.length===0)return this.logs;if(typeof e=="function")return this.logs.filter(e);if(e instanceof RegExp)return this.logs.filter(a=>e.test(a.toString()));if(typeof e=="object"&&e!==null){if(Object.keys(e).length===0)return this.logs;let a={operator:"OR",...xoe(t)},i=a.operator==="AND"?this.logs:[];return"protocol"in e&&(i=Ti(e.protocol,a,this.filterCallsByProtocol,i,this.logs)),"host"in e&&(i=Ti(e.host,a,this.filterCallsByHost,i,this.logs)),"port"in e&&(i=Ti(e.port,a,this.filterCallsByPort,i,this.logs)),"origin"in e&&(i=Ti(e.origin,a,this.filterCallsByOrigin,i,this.logs)),"path"in e&&(i=Ti(e.path,a,this.filterCallsByPath,i,this.logs)),"hash"in e&&(i=Ti(e.hash,a,this.filterCallsByHash,i,this.logs)),"fullUrl"in e&&(i=Ti(e.fullUrl,a,this.filterCallsByFullUrl,i,this.logs)),"method"in e&&(i=Ti(e.method,a,this.filterCallsByMethod,i,this.logs)),[...new Set(i)]}throw new Ni("criteria parameter should be one of function, regexp, or object")}filterCallsByProtocol=Ri.call(this,"protocol");filterCallsByHost=Ri.call(this,"host");filterCallsByPort=Ri.call(this,"port");filterCallsByOrigin=Ri.call(this,"origin");filterCallsByPath=Ri.call(this,"path");filterCallsByHash=Ri.call(this,"hash");filterCallsByFullUrl=Ri.call(this,"fullUrl");filterCallsByMethod=Ri.call(this,"method");clear(){this.logs=[]}[voe](e){let t=new Kd(e);return this.logs.push(t),t}*[Symbol.iterator](){for(let e of this.calls())yield e}};QA.exports.MockCallHistory=BA;QA.exports.MockCallHistoryLog=Kd});var NA=y((fpe,UQ)=>{"use strict";var{promisify:qoe}=require("util"),Eoe=Sr(),{buildMockDispatch:Ioe}=Bm(),{kDispatches:DA,kMockAgent:QQ,kClose:SQ,kOriginalClose:DQ,kOrigin:TQ,kOriginalDispatch:Coe,kConnected:TA,kIgnoreTrailingSlash:RQ}=Fr(),{MockInterceptor:joe}=qA(),NQ=de(),{InvalidArgumentError:Boe}=$(),RA=class extends Eoe{constructor(e,t){if(!t||!t.agent||typeof t.agent.dispatch!="function")throw new Boe("Argument opts.agent must implement Agent");super(e,t),this[QQ]=t.agent,this[TQ]=e,this[RQ]=t.ignoreTrailingSlash??!1,this[DA]=[],this[TA]=1,this[Coe]=this.dispatch,this[DQ]=this.close.bind(this),this.dispatch=Ioe.call(this),this.close=this[SQ]}get[NQ.kConnected](){return this[TA]}intercept(e){return new joe(e&&{ignoreTrailingSlash:this[RQ],...e},this[DA])}cleanMocks(){this[DA]=[]}async[SQ](){await qoe(this[DQ])(),this[TA]=0,this[QQ][NQ.kClients].delete(this[TQ])}};UQ.exports=RA});var MQ=y((ype,OQ)=>{"use strict";var{Transform:Qoe}=require("stream"),{Console:Soe}=require("console"),Doe=process.versions.icu?"\u2705":"Y ",Toe=process.versions.icu?"\u274C":"N ";OQ.exports=class{constructor({disableColors:e}={}){this.transform=new Qoe({transform(t,a,i){i(null,t)}}),this.logger=new Soe({stdout:this.transform,inspectOptions:{colors:!e&&!process.env.CI}})}format(e){let t=e.map(({method:a,path:i,data:{statusCode:r},persist:s,times:n,timesInvoked:c,origin:m})=>({Method:a,Origin:m,Path:i,"Status code":r,Persistent:s?Doe:Toe,Invocations:c,Remaining:s?1/0:n-c}));return this.logger.table(t),this.transform.read().toString()}}});var LA=y((kpe,YQ)=>{"use strict";var{kClients:Hr}=de(),Roe=Rr(),{kAgent:UA,kMockAgentSet:Zd,kMockAgentGet:_Q,kDispatches:OA,kIsMockActive:Xd,kNetConnect:Gr,kGetNetConnect:Noe,kOptions:eg,kFactory:og,kMockAgentRegisterCallHistory:MA,kMockAgentIsCallHistoryEnabled:Qm,kMockAgentAddCallHistoryLog:LQ,kMockAgentMockCallHistoryInstance:gn,kMockAgentAcceptsNonStandardSearchParameters:FQ,kMockCallHistoryAddLog:Uoe,kIgnoreTrailingSlash:PQ}=Fr(),Ooe=jA(),Moe=NA(),{matchValue:_oe,normalizeSearchParams:Loe,buildAndValidateMockOptions:Foe,normalizeOrigin:HQ}=Bm(),{InvalidArgumentError:GQ,UndiciError:Poe}=$(),Hoe=Kc(),Goe=MQ(),{MockCallHistory:Yoe}=SA(),_A=class extends Hoe{constructor(e={}){super(e);let t=Foe(e);if(this[Gr]=!0,this[Xd]=!0,this[Qm]=t.enableCallHistory??!1,this[FQ]=t.acceptNonStandardSearchParameters??!1,this[PQ]=t.ignoreTrailingSlash??!1,e?.agent&&typeof e.agent.dispatch!="function")throw new GQ("Argument opts.agent must implement Agent");let a=e?.agent?e.agent:new Roe(e);this[UA]=a,this[Hr]=a[Hr],this[eg]=t,this[Qm]&&this[MA]()}get(e){let t=HQ(e),a=this[PQ]?t.replace(/\/$/,""):t,i=this[_Q](a);return i||(i=this[og](a),this[Zd](a,i)),i}dispatch(e,t){e.origin=HQ(e.origin),this.get(e.origin),this[LQ](e);let a=this[FQ],i={...e};if(a&&i.path){let[r,s]=i.path.split("?"),n=Loe(s,a);i.path=`${r}?${n}`}return this[UA].dispatch(i,t)}async close(){this.clearCallHistory(),await this[UA].close(),this[Hr].clear()}deactivate(){this[Xd]=!1}activate(){this[Xd]=!0}enableNetConnect(e){if(typeof e=="string"||typeof e=="function"||e instanceof RegExp)Array.isArray(this[Gr])?this[Gr].push(e):this[Gr]=[e];else if(typeof e>"u")this[Gr]=!0;else throw new GQ("Unsupported matcher. Must be one of String|Function|RegExp.")}disableNetConnect(){this[Gr]=!1}enableCallHistory(){return this[Qm]=!0,this}disableCallHistory(){return this[Qm]=!1,this}getCallHistory(){return this[gn]}clearCallHistory(){this[gn]!==void 0&&this[gn].clear()}get isMockActive(){return this[Xd]}[MA](){this[gn]===void 0&&(this[gn]=new Yoe)}[LQ](e){this[Qm]&&(this[MA](),this[gn][Uoe](e))}[Zd](e,t){this[Hr].set(e,{count:0,dispatcher:t})}[og](e){let t=Object.assign({agent:this},this[eg]);return this[eg]&&this[eg].connections===1?new Ooe(e,t):new Moe(e,t)}[_Q](e){let t=this[Hr].get(e);if(t?.dispatcher)return t.dispatcher;if(typeof e!="string"){let a=this[og]("http://localhost:9999");return this[Zd](e,a),a}for(let[a,i]of Array.from(this[Hr]))if(i&&typeof a!="string"&&_oe(a,e)){let r=this[og](e);return this[Zd](e,r),r[OA]=i.dispatcher[OA],r}}[Noe](){return this[Gr]}pendingInterceptors(){let e=this[Hr];return Array.from(e.entries()).flatMap(([t,a])=>a.dispatcher[OA].map(i=>({...i,origin:t}))).filter(({pending:t})=>t)}assertNoPendingInterceptors({pendingInterceptorsFormatter:e=new Goe}={}){let t=this.pendingInterceptors();if(t.length!==0)throw new Poe(t.length===1?`1 interceptor is pending:
1327
+ `,this[IZ]=n??3e5,this[EZ]=a??3e5,this[CZ]=k??!0,this[pk]=j,this[zi]=null,this[DZ]=T>-1?T:-1,this[Ne]=null,this[RZ]=S??100,this[NZ]=ye??262144,this[UZ]=po??524288,this[OZ]=Ve??6e4,this[_t]=[],this[_a]=0,this[Lt]=0,this[Ma]=it=>fk(this,it),this[TZ]=it=>m8(this,it)}get pipelining(){return this[Cd]}set pipelining(e){this[Cd]=e,this[Ma](!0)}get stats(){return new uZ(this)}get[ym](){return this[_t].length-this[Lt]}get[bm](){return this[Lt]-this[_a]}get[pm](){return this[_t].length-this[_a]}get[kZ](){return!!this[Ne]&&!this[Xs]&&!this[Ne].destroyed}get[gk](){return!!(this[Ne]?.busy(null)||this[pm]>=(c8(this)||1)||this[ym]>0)}[yZ](e){l8(this),this.once("connect",e)}[SZ](e,t){let a=new dZ(this[ia].origin,e,t);return this[_t].push(a),this[Qr]||(Br.bodyLength(a.body)==null&&Br.isIterable(a.body)?(this[Qr]=1,queueMicrotask(()=>fk(this))):this[Ma](!0)),this[Qr]&&this[qi]!==2&&this[gk]&&(this[qi]=2),this[qi]<2}[BZ](){return new Promise(e=>{this[pm]?this[zi]=e:e(null)})}[QZ](e){return new Promise(t=>{let a=this[_t].splice(this[Lt]);for(let r=0;r<a.length;r++){let s=a[r];Br.errorRequest(this,s,e)}let i=()=>{this[zi]&&(this[zi](),this[zi]=null),t(null)};this[Ne]?(this[Ne].destroy(e,i),this[Ne]=null):queueMicrotask(i),this[Ma]()})}};function m8(o,e){if(o[bm]===0&&e.code!=="UND_ERR_INFO"&&e.code!=="UND_ERR_SOCKET"){Oa(o[Lt]===o[_a]);let t=o[_t].splice(o[_a]);for(let a=0;a<t.length;a++){let i=t[a];Br.errorRequest(o,i,e)}Oa(o[pm]===0)}}function l8(o){Oa(!o[Xs]),Oa(!o[Ne]);let{host:e,hostname:t,protocol:a,port:i}=o[ia];if(t[0]==="["){let r=t.indexOf("]");Oa(r!==-1);let s=t.substring(1,r);Oa(n8.isIPv6(s)),t=s}o[Xs]=!0,Zs.beforeConnect.hasSubscribers&&Zs.beforeConnect.publish({connectParams:{host:e,hostname:t,protocol:a,port:i,version:o[Ne]?.version,servername:o[Ei],localAddress:o[fm]},connector:o[hm]});try{o[hm]({host:e,hostname:t,protocol:a,port:i,servername:o[Ei],localAddress:o[fm]},(r,s)=>{if(r){dk(o,r,{host:e,hostname:t,protocol:a,port:i}),o[Ma]();return}if(o.destroyed){Br.destroy(s.on("error",r8),new hZ),o[Ma]();return}Oa(s);try{o[Ne]=s.alpnProtocol==="h2"?_Z(o,s):MZ(o,s)}catch(n){s.destroy().on("error",r8),dk(o,n,{host:e,hostname:t,protocol:a,port:i}),o[Ma]();return}o[Xs]=!1,s[jZ]=0,s[pk]=o[pk],s[bZ]=o,s[wZ]=null,Zs.connected.hasSubscribers&&Zs.connected.publish({connectParams:{host:e,hostname:t,protocol:a,port:i,version:o[Ne]?.version,servername:o[Ei],localAddress:o[fm]},connector:o[hm],socket:s}),o.emit("connect",o[ia],[o]),o[Ma]()})}catch(r){dk(o,r,{host:e,hostname:t,protocol:a,port:i}),o[Ma]()}}function dk(o,e,{host:t,hostname:a,protocol:i,port:r}){if(!o.destroyed){if(o[Xs]=!1,Zs.connectError.hasSubscribers&&Zs.connectError.publish({connectParams:{host:t,hostname:a,protocol:i,port:r,version:o[Ne]?.version,servername:o[Ei],localAddress:o[fm]},connector:o[hm],error:e}),e.code==="ERR_TLS_CERT_ALTNAME_INVALID")for(Oa(o[bm]===0);o[ym]>0&&o[_t][o[Lt]].servername===o[Ei];){let s=o[_t][o[Lt]++];Br.errorRequest(o,s,e)}else m8(o,e);o.emit("connectionError",o[ia],[o],e)}}function s8(o){o[qi]=0,o.emit("drain",o[ia],[o])}function fk(o,e){o[Qr]!==2&&(o[Qr]=2,FZ(o,e),o[Qr]=0,o[_a]>256&&(o[_t].splice(0,o[_a]),o[Lt]-=o[_a],o[_a]=0))}function FZ(o,e){for(;;){if(o.destroyed){Oa(o[ym]===0);return}if(o[zi]&&!o[pm]){o[zi](),o[zi]=null;return}if(o[Ne]&&o[Ne].resume(),o[gk])o[qi]=2;else if(o[qi]===2){e?(o[qi]=1,queueMicrotask(()=>s8(o))):s8(o);continue}if(o[ym]===0||o[bm]>=(c8(o)||1))return;let t=o[_t][o[Lt]];if(t===null)return;if(o[ia].protocol==="https:"&&o[Ei]!==t.servername){if(o[bm]>0)return;o[Ei]=t.servername,o[Ne]?.destroy(new pZ("servername changed"),()=>{o[Ne]=null,fk(o)})}if(o[Xs])return;if(!o[Ne]){l8(o);return}if(o[Ne].destroyed||o[Ne].busy(t))return;!t.aborted&&o[Ne].write(t)?o[Lt]++:o[_t].splice(o[Lt],1)}}u8.exports=hk});var bk=y((Fge,d8)=>{"use strict";var jd=class{bottom=0;top=0;list=new Array(2048).fill(void 0);next=null;isEmpty(){return this.top===this.bottom}isFull(){return(this.top+1&2047)===this.bottom}push(e){this.list[this.top]=e,this.top=this.top+1&2047}shift(){let e=this.list[this.bottom];return e===void 0?null:(this.list[this.bottom]=void 0,this.bottom=this.bottom+1&2047,e)}};d8.exports=class{constructor(){this.head=this.tail=new jd}isEmpty(){return this.head.isEmpty()}push(e){this.head.isFull()&&(this.head=this.head.next=new jd),this.head.push(e)}shift(){let e=this.tail,t=e.shift();return e.isEmpty()&&e.next!==null&&(this.tail=e.next,e.next=null),t}}});var Bd=y((Pge,w8)=>{"use strict";var{PoolStats:PZ}=iy(),HZ=Ar(),GZ=bk(),{kConnected:yk,kSize:g8,kRunning:p8,kPending:h8,kQueued:km,kBusy:YZ,kFree:VZ,kUrl:$Z,kClose:WZ,kDestroy:JZ,kDispatch:KZ}=de(),Ze=Symbol("clients"),Ao=Symbol("needDrain"),Am=Symbol("queue"),kk=Symbol("closed resolve"),Ak=Symbol("onDrain"),f8=Symbol("onConnect"),b8=Symbol("onDisconnect"),y8=Symbol("onConnectionError"),wk=Symbol("get dispatcher"),k8=Symbol("add client"),A8=Symbol("remove client"),vk=class extends HZ{[Am]=new GZ;[km]=0;[Ze]=[];[Ao]=!1;[Ak](e,t,a){let i=this[Am],r=!1;for(;!r;){let s=i.shift();if(!s)break;this[km]--,r=!e.dispatch(s.opts,s.handler)}if(e[Ao]=r,!r&&this[Ao]&&(this[Ao]=!1,this.emit("drain",t,[this,...a])),this[kk]&&i.isEmpty()){let s=[];for(let n=0;n<this[Ze].length;n++){let c=this[Ze][n];c.destroyed||s.push(c.close())}return Promise.all(s).then(this[kk])}}[f8]=(e,t)=>{this.emit("connect",e,[this,...t])};[b8]=(e,t,a)=>{this.emit("disconnect",e,[this,...t],a)};[y8]=(e,t,a)=>{this.emit("connectionError",e,[this,...t],a)};get[YZ](){return this[Ao]}get[yk](){let e=0;for(let{[yk]:t}of this[Ze])e+=t;return e}get[VZ](){let e=0;for(let{[yk]:t,[Ao]:a}of this[Ze])e+=t&&!a;return e}get[h8](){let e=this[km];for(let{[h8]:t}of this[Ze])e+=t;return e}get[p8](){let e=0;for(let{[p8]:t}of this[Ze])e+=t;return e}get[g8](){let e=this[km];for(let{[g8]:t}of this[Ze])e+=t;return e}get stats(){return new PZ(this)}[WZ](){if(this[Am].isEmpty()){let e=[];for(let t=0;t<this[Ze].length;t++){let a=this[Ze][t];a.destroyed||e.push(a.close())}return Promise.all(e)}else return new Promise(e=>{this[kk]=e})}[JZ](e){for(;;){let a=this[Am].shift();if(!a)break;a.handler.onError(e)}let t=new Array(this[Ze].length);for(let a=0;a<this[Ze].length;a++)t[a]=this[Ze][a].destroy(e);return Promise.all(t)}[KZ](e,t){let a=this[wk]();return a?a.dispatch(e,t)||(a[Ao]=!0,this[Ao]=!this[wk]()):(this[Ao]=!0,this[Am].push({opts:e,handler:t}),this[km]++),!this[Ao]}[k8](e){return e.on("drain",this[Ak].bind(this,e)).on("connect",this[f8]).on("disconnect",this[b8]).on("connectionError",this[y8]),this[Ze].push(e),this[Ao]&&queueMicrotask(()=>{this[Ao]&&this[Ak](e,e[$Z],[e,this])}),this}[A8](e){e.close(()=>{let t=this[Ze].indexOf(e);t!==-1&&this[Ze].splice(t,1)}),this[Ao]=this[Ze].some(t=>!t[Ao]&&t.closed!==!0&&t.destroyed!==!0)}};w8.exports={PoolBase:vk,kClients:Ze,kNeedDrain:Ao,kAddClient:k8,kRemoveClient:A8,kGetDispatcher:wk}});var Sr=y((Hge,q8)=>{"use strict";var{PoolBase:ZZ,kClients:Qd,kNeedDrain:XZ,kAddClient:eX,kGetDispatcher:oX,kRemoveClient:tX}=Bd(),aX=Ii(),{InvalidArgumentError:xk}=$(),v8=K(),{kUrl:x8}=de(),iX=wr(),Sd=Symbol("options"),zk=Symbol("connections"),z8=Symbol("factory");function rX(o,e){return new aX(o,e)}var qk=class extends ZZ{constructor(e,{connections:t,factory:a=rX,connect:i,connectTimeout:r,tls:s,maxCachedSessions:n,socketPath:c,autoSelectFamily:m,autoSelectFamilyAttemptTimeout:l,allowH2:u,clientTtl:d,...g}={}){if(t!=null&&(!Number.isFinite(t)||t<0))throw new xk("invalid connections");if(typeof a!="function")throw new xk("factory must be a function.");if(i!=null&&typeof i!="function"&&typeof i!="object")throw new xk("connect must be a function or an object");typeof i!="function"&&(i=iX({...s,maxCachedSessions:n,allowH2:u,socketPath:c,timeout:r,...typeof m=="boolean"?{autoSelectFamily:m,autoSelectFamilyAttemptTimeout:l}:void 0,...i})),super(g),this[zk]=t||null,this[x8]=v8.parseOrigin(e),this[Sd]={...v8.deepClone(g),connect:i,allowH2:u,clientTtl:d,socketPath:c},this[Sd].interceptors=g.interceptors?{...g.interceptors}:void 0,this[z8]=a,this.on("connect",(p,b)=>{if(d!=null&&d>0)for(let A of b)Object.assign(A,{ttl:Date.now()})}),this.on("connectionError",(p,b,A)=>{for(let k of b){let x=this[Qd].indexOf(k);x!==-1&&this[Qd].splice(x,1)}})}[oX](){let e=this[Sd].clientTtl;for(let t of this[Qd])if(e!=null&&e>0&&t.ttl&&Date.now()-t.ttl>e)this[tX](t);else if(!t[XZ])return t;if(!this[zk]||this[Qd].length<this[zk]){let t=this[z8](this[x8],this[Sd]);return this[eX](t),t}}};q8.exports=qk});var j8=y((Gge,C8)=>{"use strict";var{BalancedPoolMissingUpstreamError:sX,InvalidArgumentError:nX}=$(),{PoolBase:cX,kClients:ao,kNeedDrain:wm,kAddClient:mX,kRemoveClient:lX,kGetDispatcher:uX}=Bd(),dX=Sr(),{kUrl:Dd}=de(),Td=K(),E8=Symbol("factory"),vm=Symbol("options"),I8=Symbol("kGreatestCommonDivisor"),Dr=Symbol("kCurrentWeight"),Tr=Symbol("kIndex"),vt=Symbol("kWeight"),Rd=Symbol("kMaxWeightPerServer"),Nd=Symbol("kErrorPenalty");function gX(o,e){if(o===0)return e;for(;e!==0;){let t=e;e=o%e,o=t}return o}function pX(o,e){return new dX(o,e)}var Ek=class extends cX{constructor(e=[],{factory:t=pX,...a}={}){if(typeof t!="function")throw new nX("factory must be a function.");super(a),this[vm]={...Td.deepClone(a)},this[vm].interceptors=a.interceptors?{...a.interceptors}:void 0,this[Tr]=-1,this[Dr]=0,this[Rd]=this[vm].maxWeightPerServer||100,this[Nd]=this[vm].errorPenalty||15,Array.isArray(e)||(e=[e]),this[E8]=t;for(let i of e)this.addUpstream(i);this._updateBalancedPoolStats()}addUpstream(e){let t=Td.parseOrigin(e).origin;if(this[ao].find(i=>i[Dd].origin===t&&i.closed!==!0&&i.destroyed!==!0))return this;let a=this[E8](t,this[vm]);this[mX](a),a.on("connect",()=>{a[vt]=Math.min(this[Rd],a[vt]+this[Nd])}),a.on("connectionError",()=>{a[vt]=Math.max(1,a[vt]-this[Nd]),this._updateBalancedPoolStats()}),a.on("disconnect",(...i)=>{let r=i[2];r&&r.code==="UND_ERR_SOCKET"&&(a[vt]=Math.max(1,a[vt]-this[Nd]),this._updateBalancedPoolStats())});for(let i of this[ao])i[vt]=this[Rd];return this._updateBalancedPoolStats(),this}_updateBalancedPoolStats(){let e=0;for(let t=0;t<this[ao].length;t++)e=gX(this[ao][t][vt],e);this[I8]=e}removeUpstream(e){let t=Td.parseOrigin(e).origin,a=this[ao].find(i=>i[Dd].origin===t&&i.closed!==!0&&i.destroyed!==!0);return a&&this[lX](a),this}getUpstream(e){let t=Td.parseOrigin(e).origin;return this[ao].find(a=>a[Dd].origin===t&&a.closed!==!0&&a.destroyed!==!0)}get upstreams(){return this[ao].filter(e=>e.closed!==!0&&e.destroyed!==!0).map(e=>e[Dd].origin)}[uX](){if(this[ao].length===0)throw new sX;if(!this[ao].find(r=>!r[wm]&&r.closed!==!0&&r.destroyed!==!0)||this[ao].map(r=>r[wm]).reduce((r,s)=>r&&s,!0))return;let a=0,i=this[ao].findIndex(r=>!r[wm]);for(;a++<this[ao].length;){this[Tr]=(this[Tr]+1)%this[ao].length;let r=this[ao][this[Tr]];if(r[vt]>this[ao][i][vt]&&!r[wm]&&(i=this[Tr]),this[Tr]===0&&(this[Dr]=this[Dr]-this[I8],this[Dr]<=0&&(this[Dr]=this[Rd])),r[vt]>=this[Dr]&&!r[wm])return r}return this[Dr]=this[ao][i][vt],this[Tr]=i,this[ao][i]}};C8.exports=Ek});var D8=y((Yge,S8)=>{"use strict";var{PoolBase:hX,kClients:Ud,kNeedDrain:fX,kAddClient:B8,kGetDispatcher:bX,kRemoveClient:yX}=Bd(),kX=Ii(),{InvalidArgumentError:Ik}=$(),Q8=K(),{kUrl:Ck}=de(),AX=wr(),xm=Symbol("options"),jk=Symbol("connections"),Bk=Symbol("factory"),Od=Symbol("index");function wX(o,e){return new kX(o,e)}var Qk=class extends hX{constructor(e,{connections:t,factory:a=wX,connect:i,connectTimeout:r,tls:s,maxCachedSessions:n,socketPath:c,autoSelectFamily:m,autoSelectFamilyAttemptTimeout:l,allowH2:u,clientTtl:d,...g}={}){if(t!=null&&(!Number.isFinite(t)||t<0))throw new Ik("invalid connections");if(typeof a!="function")throw new Ik("factory must be a function.");if(i!=null&&typeof i!="function"&&typeof i!="object")throw new Ik("connect must be a function or an object");typeof i!="function"&&(i=AX({...s,maxCachedSessions:n,allowH2:u,socketPath:c,timeout:r,...typeof m=="boolean"?{autoSelectFamily:m,autoSelectFamilyAttemptTimeout:l}:void 0,...i})),super(),this[jk]=t||null,this[Ck]=Q8.parseOrigin(e),this[xm]={...Q8.deepClone(g),connect:i,allowH2:u,clientTtl:d,socketPath:c},this[xm].interceptors=g.interceptors?{...g.interceptors}:void 0,this[Bk]=a,this[Od]=-1,this.on("connect",(p,b)=>{if(d!=null&&d>0)for(let A of b)Object.assign(A,{ttl:Date.now()})}),this.on("connectionError",(p,b,A)=>{for(let k of b){let x=this[Ud].indexOf(k);x!==-1&&this[Ud].splice(x,1)}})}[bX](){let e=this[xm].clientTtl,t=this[Ud].length;if(t===0){let i=this[Bk](this[Ck],this[xm]);return this[B8](i),i}let a=0;for(;a<t;){this[Od]=(this[Od]+1)%t;let i=this[Ud][this[Od]];if(e!=null&&e>0&&i.ttl&&Date.now()-i.ttl>e){this[yX](i),a++;continue}if(!i[fX])return i;a++}if(!this[jk]||t<this[jk]){let i=this[Bk](this[Ck],this[xm]);return this[B8](i),i}}};S8.exports=Qk});var Rr=y((Vge,_8)=>{"use strict";var{InvalidArgumentError:Md,MaxOriginsReachedError:vX}=$(),{kClients:xt,kRunning:T8,kClose:xX,kDestroy:zX,kDispatch:qX,kUrl:EX}=de(),IX=Ar(),CX=Sr(),jX=Ii(),BX=K(),R8=Symbol("onConnect"),N8=Symbol("onDisconnect"),U8=Symbol("onConnectionError"),O8=Symbol("onDrain"),M8=Symbol("factory"),Sk=Symbol("options"),zm=Symbol("origins");function QX(o,e){return e&&e.connections===1?new jX(o,e):new CX(o,e)}var Dk=class extends IX{constructor({factory:e=QX,maxOrigins:t=1/0,connect:a,...i}={}){if(typeof e!="function")throw new Md("factory must be a function.");if(a!=null&&typeof a!="function"&&typeof a!="object")throw new Md("connect must be a function or an object");if(typeof t!="number"||Number.isNaN(t)||t<=0)throw new Md("maxOrigins must be a number greater than 0");super(i),a&&typeof a!="function"&&(a={...a}),this[Sk]={...BX.deepClone(i),maxOrigins:t,connect:a},this[M8]=e,this[xt]=new Map,this[zm]=new Set,this[O8]=(r,s)=>{this.emit("drain",r,[this,...s])},this[R8]=(r,s)=>{this.emit("connect",r,[this,...s])},this[N8]=(r,s,n)=>{this.emit("disconnect",r,[this,...s],n)},this[U8]=(r,s,n)=>{this.emit("connectionError",r,[this,...s],n)}}get[T8](){let e=0;for(let{dispatcher:t}of this[xt].values())e+=t[T8];return e}[qX](e,t){let a;if(e.origin&&(typeof e.origin=="string"||e.origin instanceof URL))a=String(e.origin);else throw new Md("opts.origin must be a non-empty string or URL.");if(this[zm].size>=this[Sk].maxOrigins&&!this[zm].has(a))throw new vX;let i=this[xt].get(a),r=i&&i.dispatcher;if(!r){let s=n=>{let c=this[xt].get(a);c&&(n&&(c.count-=1),c.count<=0&&(this[xt].delete(a),c.dispatcher.destroyed||c.dispatcher.close()),this[zm].delete(a))};r=this[M8](e.origin,this[Sk]).on("drain",this[O8]).on("connect",(n,c)=>{let m=this[xt].get(a);m&&(m.count+=1),this[R8](n,c)}).on("disconnect",(n,c,m)=>{s(!0),this[N8](n,c,m)}).on("connectionError",(n,c,m)=>{s(!1),this[U8](n,c,m)}),this[xt].set(a,{count:0,dispatcher:r}),this[zm].add(a)}return r.dispatch(e,t)}[xX](){let e=[];for(let{dispatcher:t}of this[xt].values())e.push(t.close());return this[xt].clear(),Promise.all(e)}[zX](e){let t=[];for(let{dispatcher:a}of this[xt].values())t.push(a.destroy(e));return this[xt].clear(),Promise.all(t)}get stats(){let e={};for(let{dispatcher:t}of this[xt].values())t.stats&&(e[t[EX].origin]=t.stats);return e}};_8.exports=Dk});var P8=y(($ge,F8)=>{"use strict";var{Buffer:ji}=require("buffer"),Tk=require("net"),{InvalidArgumentError:Ci}=$();function SX(o){if(Tk.isIPv4(o)){let t=o.split(".").map(Number);return{type:1,buffer:ji.from(t)}}if(Tk.isIPv6(o))return{type:4,buffer:L8(o)};let e=ji.from(o,"utf8");if(e.length>255)throw new Ci("Domain name too long (max 255 bytes)");return{type:3,buffer:ji.concat([ji.from([e.length]),e])}}function L8(o){let e=ji.alloc(16),t=o;if(o.includes(".")){let i=o.lastIndexOf(":"),r=o.slice(i+1);if(Tk.isIPv4(r)){let s=r.split(".").map(Number),n=(s[0]<<8|s[1]).toString(16),c=(s[2]<<8|s[3]).toString(16);t=`${o.slice(0,i)}:${n}:${c}`}}let a=t.indexOf("::");if(a!==-1){let i=t.slice(0,a),r=t.slice(a+2),s=i===""?[]:i.split(":"),n=r===""?[]:r.split(":"),c=0;for(let m of s)e.writeUInt16BE(parseInt(m,16),c),c+=2;c=16-n.length*2;for(let m of n)e.writeUInt16BE(parseInt(m,16),c),c+=2}else{let i=t.split(":");for(let r=0;r<i.length;r++)e.writeUInt16BE(parseInt(i[r],16),r*2)}return e}function DX(o,e,t){let a=ji.allocUnsafe(2);return a.writeUInt16BE(t,0),ji.concat([ji.from([o]),e,a])}function TX(o,e=0){if(o.length<e+1)throw new Ci("Buffer too small to contain address type");let t=o[e],a,i=e+1;switch(t){case 1:{if(o.length<i+6)throw new Ci("Buffer too small for IPv4 address");a=Array.from(o.subarray(i,i+4)).join("."),i+=4;break}case 3:{if(o.length<i+1)throw new Ci("Buffer too small for domain length");let s=o[i];if(i+=1,o.length<i+s+2)throw new Ci("Buffer too small for domain address");a=o.subarray(i,i+s).toString("utf8"),i+=s;break}case 4:{if(o.length<i+18)throw new Ci("Buffer too small for IPv6 address");let s=[];for(let n=0;n<8;n++){let c=o.readUInt16BE(i+n*2);s.push(c.toString(16))}a=s.join(":"),i+=16;break}default:throw new Ci(`Invalid address type: ${t}`)}if(o.length<i+2)throw new Ci("Buffer too small for port");let r=o.readUInt16BE(i);return i+=2,{address:a,port:r,bytesRead:i-e}}function RX(o){let t={1:"General SOCKS server failure",2:"Connection not allowed by ruleset",3:"Network unreachable",4:"Host unreachable",5:"Connection refused",6:"TTL expired",7:"Command not supported",8:"Address type not supported"}[o]||`Unknown SOCKS5 error code: ${o}`,a=new Error(t);return a.code=`SOCKS5_${o}`,a}F8.exports={parseAddress:SX,parseIPv6:L8,buildAddressBuffer:DX,parseResponseAddress:TX,createReplyError:RX}});var V8=y((Wge,Y8)=>{"use strict";var{EventEmitter:NX}=require("events"),{Buffer:Nr}=require("buffer"),{InvalidArgumentError:en,Socks5ProxyError:Bi}=$(),{debuglog:UX}=require("util"),{parseAddress:OX}=P8(),La=UX("undici:socks5"),H8=Nr.alloc(0),_d=5,on={NO_AUTH:0,GSSAPI:1,USERNAME_PASSWORD:2,NO_ACCEPTABLE:255},G8={CONNECT:1,BIND:2,UDP_ASSOCIATE:3},Ur={IPV4:1,DOMAIN:3,IPV6:4},ra={SUCCEEDED:0,GENERAL_FAILURE:1,CONNECTION_NOT_ALLOWED:2,NETWORK_UNREACHABLE:3,HOST_UNREACHABLE:4,CONNECTION_REFUSED:5,TTL_EXPIRED:6,COMMAND_NOT_SUPPORTED:7,ADDRESS_TYPE_NOT_SUPPORTED:8},mo={INITIAL:"initial",HANDSHAKING:"handshaking",AUTHENTICATING:"authenticating",AUTHENTICATED:"authenticated",CONNECTING:"connecting",CONNECTED:"connected",ERROR:"error",CLOSED:"closed"},Rk=class extends NX{constructor(e,t={}){if(super(),!e)throw new en("socket is required");this.socket=e,this.options=t,this.state=mo.INITIAL,this.buffer=H8,this.onSocketData=this.onData.bind(this),this.onSocketError=this.onError.bind(this),this.onSocketClose=this.onClose.bind(this),this.authMethods=[],t.username&&t.password&&this.authMethods.push(on.USERNAME_PASSWORD),this.authMethods.push(on.NO_AUTH),this.socket.on("data",this.onSocketData),this.socket.on("error",this.onSocketError),this.socket.on("close",this.onSocketClose)}onData(e){La("received data",e.length,"bytes in state",this.state),this.buffer=Nr.concat([this.buffer,e]);try{switch(this.state){case mo.HANDSHAKING:this.handleHandshakeResponse();break;case mo.AUTHENTICATING:this.handleAuthResponse();break;case mo.CONNECTING:this.handleConnectResponse();break}}catch(t){this.onError(t)}}onError(e){La("socket error",e),this.state=mo.ERROR,this.emit("error",e),this.destroy()}onClose(){La("socket closed"),this.state=mo.CLOSED,this.emit("close")}destroy(){this.socket&&!this.socket.destroyed&&this.socket.destroy()}markAuthenticated(){this.state=mo.AUTHENTICATED,this.emit("authenticated")}handshake(){if(this.state!==mo.INITIAL)throw new en("Handshake already started");La("starting handshake with",this.authMethods.length,"auth methods"),this.state=mo.HANDSHAKING;let e=Nr.alloc(2+this.authMethods.length);e[0]=_d,e[1]=this.authMethods.length,this.authMethods.forEach((t,a)=>{e[2+a]=t}),this.socket.write(e)}handleHandshakeResponse(){if(this.buffer.length<2)return;let e=this.buffer[0],t=this.buffer[1];if(e!==_d)throw new Bi(`Invalid SOCKS version: ${e}`,"UND_ERR_SOCKS5_VERSION");if(t===on.NO_ACCEPTABLE)throw new Bi("No acceptable authentication method","UND_ERR_SOCKS5_AUTH_REJECTED");if(this.buffer=this.buffer.subarray(2),La("server selected auth method",t),t===on.NO_AUTH)this.markAuthenticated();else if(t===on.USERNAME_PASSWORD)this.state=mo.AUTHENTICATING,this.sendAuthRequest();else throw new Bi(`Unsupported authentication method: ${t}`,"UND_ERR_SOCKS5_AUTH_METHOD")}sendAuthRequest(){let{username:e,password:t}=this.options;if(!e||!t)throw new en("Username and password required for authentication");La("sending username/password auth");let a=Nr.from(e),i=Nr.from(t);if(a.length>255||i.length>255)throw new en("Username or password too long");let r=Nr.alloc(3+a.length+i.length);r[0]=1,r[1]=a.length,a.copy(r,2),r[2+a.length]=i.length,i.copy(r,3+a.length),this.socket.write(r)}handleAuthResponse(){if(this.buffer.length<2)return;let e=this.buffer[0],t=this.buffer[1];if(e!==1)throw new Bi(`Invalid auth sub-negotiation version: ${e}`,"UND_ERR_SOCKS5_AUTH_VERSION");if(t!==0)throw new Bi("Authentication failed","UND_ERR_SOCKS5_AUTH_FAILED");this.buffer=this.buffer.subarray(2),La("authentication successful"),this.markAuthenticated()}connect(e,t){if(this.state===mo.CONNECTING||this.state===mo.CONNECTED)throw new en("Connection already in progress");if(this.state!==mo.AUTHENTICATED)throw new en("Client must be authenticated before CONNECT");La("connecting to",e,t),this.state=mo.CONNECTING;let a=this.buildConnectRequest(G8.CONNECT,e,t);this.socket.write(a)}buildConnectRequest(e,t,a){let{type:i,buffer:r}=OX(t),s=Nr.alloc(4+r.length+2);return s[0]=_d,s[1]=e,s[2]=0,s[3]=i,r.copy(s,4),s.writeUInt16BE(a,4+r.length),s}handleConnectResponse(){if(this.buffer.length<4)return;let e=this.buffer[0],t=this.buffer[1],a=this.buffer[3];if(e!==_d)throw new Bi(`Invalid SOCKS version in reply: ${e}`,"UND_ERR_SOCKS5_REPLY_VERSION");let i=4;if(a===Ur.IPV4)i+=6;else if(a===Ur.DOMAIN){if(this.buffer.length<5)return;i+=1+this.buffer[4]+2}else if(a===Ur.IPV6)i+=18;else throw new Bi(`Invalid address type in reply: ${a}`,"UND_ERR_SOCKS5_ADDR_TYPE");if(this.buffer.length<i)return;if(t!==ra.SUCCEEDED){let c=this.getReplyErrorMessage(t);throw new Bi(`SOCKS5 connection failed: ${c}`,`UND_ERR_SOCKS5_REPLY_${t}`)}let r,s=4;if(a===Ur.IPV4)r=Array.from(this.buffer.subarray(s,s+4)).join("."),s+=4;else if(a===Ur.DOMAIN){let c=this.buffer[s];s+=1,r=this.buffer.subarray(s,s+c).toString(),s+=c}else if(a===Ur.IPV6){let c=[];for(let m=0;m<8;m++){let l=this.buffer.readUInt16BE(s+m*2);c.push(l.toString(16))}r=c.join(":"),s+=16}let n=this.buffer.readUInt16BE(s);this.buffer=H8,this.state=mo.CONNECTED,this.socket.removeListener("data",this.onSocketData),La("connected, bound address:",r,"port:",n),this.emit("connected",{address:r,port:n})}getReplyErrorMessage(e){switch(e){case ra.GENERAL_FAILURE:return"General SOCKS server failure";case ra.CONNECTION_NOT_ALLOWED:return"Connection not allowed by ruleset";case ra.NETWORK_UNREACHABLE:return"Network unreachable";case ra.HOST_UNREACHABLE:return"Host unreachable";case ra.CONNECTION_REFUSED:return"Connection refused";case ra.TTL_EXPIRED:return"TTL expired";case ra.COMMAND_NOT_SUPPORTED:return"Command not supported";case ra.ADDRESS_TYPE_NOT_SUPPORTED:return"Address type not supported";default:return`Unknown error code: ${e}`}}};Y8.exports={Socks5Client:Rk,AUTH_METHODS:on,COMMANDS:G8,ADDRESS_TYPES:Ur,REPLY_CODES:ra,STATES:mo}});var _k=y((Jge,oB)=>{"use strict";var{URL:$8}=require("url"),Nk,MX=Ar(),{InvalidArgumentError:W8}=$(),{Socks5Client:_X,STATES:LX}=V8(),{kDispatch:J8,kClose:FX,kDestroy:PX}=de(),HX=Sr(),GX=wr(),{debuglog:YX}=require("util"),Qi=YX("undici:socks5-proxy"),Uk=Symbol("proxy url"),VX=Symbol("proxy headers"),K8=Symbol("proxy auth"),Z8=Symbol("proxy protocol"),Or=Symbol("pools"),X8=Symbol("connector"),Ok=Symbol("request tls settings"),eB=!1,Mk=class extends MX{constructor(e,t={}){if(super(),eB||(process.emitWarning("SOCKS5 proxy support is experimental and subject to change","ExperimentalWarning"),eB=!0),!e)throw new W8("Proxy URL is mandatory");let a=typeof e=="string"?new $8(e):e;if(a.protocol!=="socks5:"&&a.protocol!=="socks:")throw new W8("Proxy URL must use socks5:// or socks:// protocol");this[Uk]=a,this[VX]=t.headers||{},this[Z8]=t.proxyTls?"https:":"http:",this[Ok]=t.requestTls,this[K8]={username:t.username||(a.username?decodeURIComponent(a.username):null),password:t.password||(a.password?decodeURIComponent(a.password):null)},this[X8]=t.connect||GX({...t.proxyTls,servername:t.proxyTls?.servername||a.hostname}),this[Or]=new Map}async createSocks5Connection(e,t){let a=this[Uk].hostname,i=parseInt(this[Uk].port)||1080;Qi("creating SOCKS5 connection to",a,i);let r=await new Promise((n,c)=>{this[X8]({hostname:a,host:a,port:i,protocol:this[Z8]},(m,l)=>{m?c(m):n(l)})}),s=new _X(r,this[K8]);return s.on("error",n=>{Qi("SOCKS5 error:",n),r.destroy()}),await s.handshake(),await new Promise((n,c)=>{let m=setTimeout(()=>{c(new Error("SOCKS5 authentication timeout"))},5e3),l=()=>{clearTimeout(m),s.removeListener("error",u),n()},u=d=>{clearTimeout(m),s.removeListener("authenticated",l),c(d)};s.state===LX.AUTHENTICATED?(clearTimeout(m),n()):(s.once("authenticated",l),s.once("error",u))}),await s.connect(e,t),await new Promise((n,c)=>{let m=setTimeout(()=>{c(new Error("SOCKS5 connection timeout"))},5e3),l=d=>{Qi("SOCKS5 tunnel established to",e,t,"via",d),clearTimeout(m),s.removeListener("error",u),n()},u=d=>{clearTimeout(m),s.removeListener("connected",l),c(d)};s.once("connected",l),s.once("error",u)}),r}[J8](e,t){let{origin:a}=e;Qi("dispatching request to",a,"via SOCKS5");try{let i=String(a),r=this[Or].get(i);return(!r||r.destroyed||r.closed)&&(r=new HX(a,{pipelining:e.pipelining,connections:e.connections,connect:async(s,n)=>{try{let c=new $8(a),m=c.hostname,l=parseInt(c.port)||(c.protocol==="https:"?443:80);Qi("establishing SOCKS5 connection to",m,l);let u=await this.createSocks5Connection(m,l),d=u;c.protocol==="https:"&&(Nk||(Nk=require("tls")),Qi("upgrading to TLS"),d=Nk.connect({...this[Ok],socket:u,servername:this[Ok]?.servername||m}),await new Promise((g,p)=>{d.once("secureConnect",g),d.once("error",p)})),n(null,d)}catch(c){Qi("SOCKS5 connection error:",c),n(c)}}}),this[Or].set(i,r)),r[J8](e,t)}catch(i){if(Qi("dispatch error:",i),typeof t.onResponseError=="function")return t.onResponseError(null,i),!1;if(typeof t.onError=="function")return t.onError(i),!1;throw i}}async[FX](){let e=[];for(let t of this[Or].values())e.push(t.close());this[Or].clear(),await Promise.all(e)}async[PX](e){let t=[];for(let a of this[Or].values())t.push(a.destroy(e));this[Or].clear(),await Promise.all(t)}};oB.exports=Mk});var Hk=y((Kge,gB)=>{"use strict";var{kProxy:tn,kClose:cB,kDestroy:mB,kDispatch:tB}=de(),$X=Rr(),lB=Sr(),uB=Ar(),{InvalidArgumentError:Mr,RequestAbortedError:WX,SecureProxyConnectionError:JX}=$(),aB=wr(),dB=Ii(),{channels:iB}=yi(),KX=_k(),Ld=Symbol("proxy agent"),Si=Symbol("proxy client"),Fa=Symbol("proxy headers"),Lk=Symbol("request tls settings"),rB=Symbol("proxy tls settings"),sB=Symbol("connect endpoint function"),nB=Symbol("tunnel proxy");function ZX(o){return o==="https:"?443:80}function XX(o,e){return new lB(o,e)}var eee=()=>{};function oee(o,e){return e.connections===1?new dB(o,e):new lB(o,e)}var Fk=class extends uB{#e;constructor(e,{headers:t={},connect:a,factory:i}){if(!e)throw new Mr("Proxy URL is mandatory");super(),this[Fa]=t,i?this.#e=i(e,{connect:a}):this.#e=new dB(e,{connect:a})}[tB](e,t){let a=t.onHeaders;t.onHeaders=function(n,c,m){if(n===407){typeof t.onError=="function"&&t.onError(new Mr("Proxy Authentication Required (407)"));return}a&&a.call(this,n,c,m)};let{origin:i,path:r="/",headers:s={}}=e;if(e.path=i+r,!("host"in s)&&!("Host"in s)){let{host:n}=new URL(i);s.host=n}return e.headers={...this[Fa],...s},this.#e[tB](e,t)}[cB](){return this.#e.close()}[mB](e){return this.#e.destroy(e)}},Pk=class extends uB{constructor(e){if(!e||typeof e=="object"&&!(e instanceof URL)&&!e.uri)throw new Mr("Proxy uri is mandatory");let{clientFactory:t=XX}=e;if(typeof t!="function")throw new Mr("Proxy opts.clientFactory must be a function.");let{proxyTunnel:a=!0}=e;super();let i=this.#e(e),{href:r,origin:s,port:n,protocol:c,username:m,password:l,hostname:u}=i;if(this[tn]={uri:r,protocol:c},this[Lk]=e.requestTls,this[rB]=e.proxyTls,this[Fa]=e.headers||{},this[nB]=a,e.auth&&e.token)throw new Mr("opts.auth cannot be used in combination with opts.token");e.auth?this[Fa]["proxy-authorization"]=`Basic ${e.auth}`:e.token?this[Fa]["proxy-authorization"]=e.token:m&&l&&(this[Fa]["proxy-authorization"]=`Basic ${Buffer.from(`${decodeURIComponent(m)}:${decodeURIComponent(l)}`).toString("base64")}`);let d=aB({...e.proxyTls});this[sB]=aB({...e.requestTls});let g=e.factory||oee,p=(b,A)=>{let{protocol:k}=new URL(b);return this[tn].protocol==="socks5:"||this[tn].protocol==="socks:"?new KX(this[tn].uri,{headers:this[Fa],connect:d,factory:g,username:e.username||m,password:e.password||l,proxyTls:e.proxyTls,requestTls:e.requestTls}):!this[nB]&&k==="http:"&&this[tn].protocol==="http:"?new Fk(this[tn].uri,{headers:this[Fa],connect:d,factory:g}):g(b,A)};c==="socks5:"||c==="socks:"?this[Si]=null:this[Si]=t(i,{connect:d}),this[Ld]=new $X({...e,factory:p,connect:async(b,A)=>{if(!this[Si]){A(new Mr("Cannot establish tunnel connection without a proxy client"));return}let k=b.host;b.port||(k+=`:${ZX(b.protocol)}`);try{let x={origin:s,port:n,path:k,signal:b.signal,headers:{...this[Fa],host:b.host,...b.connections==null||b.connections>0?{"proxy-connection":"keep-alive"}:{}},servername:this[rB]?.servername||u},{socket:v,statusCode:j}=await this[Si].connect(x);if(j!==200){v.on("error",eee).destroy(),A(new WX(`Proxy response (${j}) !== 200 when HTTP Tunneling`));return}if(iB.proxyConnected.hasSubscribers&&iB.proxyConnected.publish({socket:v,connectParams:x}),b.protocol!=="https:"){A(null,v);return}let I;this[Lk]?I=this[Lk].servername:I=b.servername,this[sB]({...b,servername:I,httpSocket:v},A)}catch(x){x.code==="ERR_TLS_CERT_ALTNAME_INVALID"?A(new JX(x)):A(x)}}})}dispatch(e,t){let a=tee(e.headers);if(aee(a),a&&!("host"in a)&&!("Host"in a)){let{host:i}=new URL(e.origin);a.host=i}return this[Ld].dispatch({...e,headers:a},t)}#e(e){return typeof e=="string"?new URL(e):e instanceof URL?e:new URL(e.uri)}[cB](){let e=[this[Ld].close()];return this[Si]&&e.push(this[Si].close()),Promise.all(e)}[mB](){let e=[this[Ld].destroy()];return this[Si]&&e.push(this[Si].destroy()),Promise.all(e)}};function tee(o){if(Array.isArray(o)){let e={};for(let t=0;t<o.length;t+=2)e[o[t]]=o[t+1];return e}return o}function aee(o){if(o&&Object.keys(o).find(t=>t.toLowerCase()==="proxy-authorization"))throw new Mr("Proxy-Authorization should be sent in ProxyAgent constructor")}gB.exports=Pk});var yB=y((Zge,bB)=>{"use strict";var iee=Ar(),{kClose:ree,kDestroy:see,kClosed:pB,kDestroyed:hB,kDispatch:nee,kNoProxyAgent:qm,kHttpProxyAgent:Di,kHttpsProxyAgent:_r}=de(),fB=Hk(),cee=Rr(),mee={"http:":80,"https:":443},Gk=class extends iee{#e=null;#o=null;#a=null;constructor(e={}){super(),this.#a=e;let{httpProxy:t,httpsProxy:a,noProxy:i,...r}=e;this[qm]=new cee(r);let s=t??process.env.http_proxy??process.env.HTTP_PROXY;s?this[Di]=new fB({...r,uri:s}):this[Di]=this[qm];let n=a??process.env.https_proxy??process.env.HTTPS_PROXY;n?this[_r]=new fB({...r,uri:n}):this[_r]=this[Di],this.#t()}[nee](e,t){let a=new URL(e.origin);return this.#i(a).dispatch(e,t)}[ree](){return Promise.all([this[qm].close(),!this[Di][pB]&&this[Di].close(),!this[_r][pB]&&this[_r].close()])}[see](e){return Promise.all([this[qm].destroy(e),!this[Di][hB]&&this[Di].destroy(e),!this[_r][hB]&&this[_r].destroy(e)])}#i(e){let{protocol:t,host:a,port:i}=e;return a=a.replace(/:\d*$/,"").toLowerCase(),i=Number.parseInt(i,10)||mee[t]||0,this.#r(a,i)?t==="https:"?this[_r]:this[Di]:this[qm]}#r(e,t){if(this.#c&&this.#t(),this.#o.length===0)return!0;if(this.#e==="*")return!1;for(let a=0;a<this.#o.length;a++){let i=this.#o[a];if(!(i.port&&i.port!==t)&&(e===i.hostname||e.slice(-(i.hostname.length+1))===`.${i.hostname}`))return!1}return!0}#t(){let e=this.#a.noProxy??this.#s,t=e.split(/[,\s]/),a=[];for(let i=0;i<t.length;i++){let r=t[i];if(!r)continue;let s=r.match(/^(.+):(\d+)$/);a.push({hostname:(s?s[1]:r).replace(/^\*?\./,"").toLowerCase(),port:s?Number.parseInt(s[2],10):0})}this.#e=e,this.#o=a}get#c(){return this.#a.noProxy!==void 0?!1:this.#e!==this.#s}get#s(){return process.env.no_proxy??process.env.NO_PROXY??""}};bB.exports=Gk});var Fd=y((Xge,xB)=>{"use strict";var an=require("assert"),{kRetryHandlerDefaultRetry:kB}=de(),{RequestRetryError:rn}=$(),lee=Jc(),{isDisturbed:AB,parseRangeHeader:wB,wrapRequestBody:uee}=K();function dee(o){let e=new Date(o).getTime();return isNaN(e)?0:e-Date.now()}function vB(o,e,t,a){let i=o["content-length"];if(i==null||!Number.isFinite(e.start)||!Number.isFinite(e.end))return;let r=Number(i),s=e.end-e.start+1;if(!Number.isFinite(r)||r!==s)throw new rn("Content-Length mismatch",t,{headers:o,data:{count:a}})}var Yk=class o{constructor(e,{dispatch:t,handler:a}){let{retryOptions:i,...r}=e,{retry:s,maxRetries:n,maxTimeout:c,minTimeout:m,timeoutFactor:l,methods:u,errorCodes:d,retryAfter:g,statusCodes:p,throwOnError:b}=i??{};this.error=null,this.dispatch=t,this.handler=lee.wrap(a),this.opts={...r,body:uee(e.body)},this.retryOpts={throwOnError:b??!0,retry:s??o[kB],retryAfter:g??!0,maxTimeout:c??30*1e3,minTimeout:m??500,timeoutFactor:l??2,maxRetries:n??5,methods:u??["GET","HEAD","OPTIONS","PUT","DELETE","TRACE"],statusCodes:p??[500,502,503,504,429],errorCodes:d??["ECONNRESET","ECONNREFUSED","ENOTFOUND","ENETDOWN","ENETUNREACH","EHOSTDOWN","EHOSTUNREACH","EPIPE","UND_ERR_SOCKET"]},this.retryCount=0,this.retryCountCheckpoint=0,this.headersSent=!1,this.start=0,this.end=null,this.etag=null}onResponseStartWithRetry(e,t,a,i,r){if(this.retryOpts.throwOnError){this.retryOpts.statusCodes.includes(t)===!1?(this.headersSent=!0,this.handler.onResponseStart?.(e,t,a,i)):this.error=r;return}if(AB(this.opts.body)){this.headersSent=!0,this.handler.onResponseStart?.(e,t,a,i);return}function s(n){if(n){this.headersSent=!0,this.handler.onResponseStart?.(e,t,a,i),e.resume();return}this.error=r,e.resume()}e.pause(),this.retryOpts.retry(r,{state:{counter:this.retryCount},opts:{retryOptions:this.retryOpts,...this.opts}},s.bind(this))}onRequestStart(e,t){this.headersSent||this.handler.onRequestStart?.(e,t)}onRequestUpgrade(e,t,a,i){this.handler.onRequestUpgrade?.(e,t,a,i)}static[kB](e,{state:t,opts:a},i){let{statusCode:r,code:s,headers:n}=e,{method:c,retryOptions:m}=a,{maxRetries:l,minTimeout:u,maxTimeout:d,timeoutFactor:g,statusCodes:p,errorCodes:b,methods:A}=m,{counter:k}=t;if(s&&s!=="UND_ERR_REQ_RETRY"&&!b.includes(s)){i(e);return}if(Array.isArray(A)&&!A.includes(c)){i(e);return}if(r!=null&&Array.isArray(p)&&!p.includes(r)){i(e);return}if(k>l){i(e);return}let x=n?.["retry-after"];x&&(x=Number(x),x=Number.isNaN(x)?dee(n["retry-after"]):x*1e3);let v=x>0?Math.min(x,d):Math.min(u*g**(k-1),d);setTimeout(()=>i(null),v)}onResponseStart(e,t,a,i){if(this.error=null,this.retryCount+=1,t>=300){let r=new rn("Request failed",t,{headers:a,data:{count:this.retryCount}});this.onResponseStartWithRetry(e,t,a,i,r);return}if(this.headersSent){if(t!==206&&(this.start>0||t!==200))throw new rn("server does not support the range header and the payload was partially consumed",t,{headers:a,data:{count:this.retryCount}});let r=wB(a["content-range"]);if(!r)throw new rn("Content-Range mismatch",t,{headers:a,data:{count:this.retryCount}});if(this.etag!=null&&this.etag!==a.etag)throw new rn("ETag mismatch",t,{headers:a,data:{count:this.retryCount}});vB(a,r,t,this.retryCount);let{start:s,size:n,end:c=n?n-1:null}=r;an(this.start===s,"content-range mismatch"),an(this.end==null||this.end===c,"content-range mismatch");return}if(this.end==null){if(t===206){let r=wB(a["content-range"]);if(r==null){this.headersSent=!0,this.handler.onResponseStart?.(e,t,a,i);return}vB(a,r,t,this.retryCount);let{start:s,size:n,end:c=n?n-1:null}=r;an(s!=null&&Number.isFinite(s),"content-range mismatch"),an(c!=null&&Number.isFinite(c),"invalid content-length"),this.start=s,this.end=c}if(this.end==null){let r=a["content-length"];this.end=r!=null?Number(r)-1:null}an(Number.isFinite(this.start)),an(this.end==null||Number.isFinite(this.end),"invalid content-length"),this.resume=!0,this.etag=a.etag!=null?a.etag:null,this.etag!=null&&this.etag[0]==="W"&&this.etag[1]==="/"&&(this.etag=null),this.headersSent=!0,this.handler.onResponseStart?.(e,t,a,i)}else throw new rn("Request failed",t,{headers:a,data:{count:this.retryCount}})}onResponseData(e,t){this.error||(this.start+=t.length,this.handler.onResponseData?.(e,t))}onResponseEnd(e,t){if(this.error&&this.retryOpts.throwOnError)throw this.error;if(!this.error)return this.retryCount=0,this.handler.onResponseEnd?.(e,t);this.retry(e)}retry(e){if(this.start!==0){let t={range:`bytes=${this.start}-${this.end??""}`};this.etag!=null&&(t["if-match"]=this.etag),this.opts={...this.opts,headers:{...this.opts.headers,...t}}}try{this.retryCountCheckpoint=this.retryCount,this.dispatch(this.opts,this)}catch(t){this.handler.onResponseError?.(e,t)}}onResponseError(e,t){if(e?.aborted||AB(this.opts.body)){this.handler.onResponseError?.(e,t);return}function a(i){if(!i){this.retry(e);return}this.handler?.onResponseError?.(e,i)}this.retryCount-this.retryCountCheckpoint>0?this.retryCount=this.retryCountCheckpoint+(this.retryCount-this.retryCountCheckpoint):this.retryCount+=1,this.retryOpts.retry(t,{state:{counter:this.retryCount},opts:{retryOptions:this.retryOpts,...this.opts}},a.bind(this))}};xB.exports=Yk});var qB=y((epe,zB)=>{"use strict";var gee=Kc(),pee=Fd(),Vk=class extends gee{#e=null;#o=null;constructor(e,t={}){super(t),this.#e=e,this.#o=t}dispatch(e,t){let a=new pee({...e,retryOptions:this.#o},{dispatch:this.#e.dispatch.bind(this.#e),handler:t});return this.#e.dispatch(e,a)}close(){return this.#e.close()}destroy(){return this.#e.destroy()}};zB.exports=Vk});var CB=y((ope,IB)=>{"use strict";var{InvalidArgumentError:EB}=$(),hee=Ii(),$k=class extends hee{constructor(e,t){if(typeof e=="string"&&(e=new URL(e)),e.protocol!=="http:")throw new EB("h2c-client: Only h2c protocol is supported");let{maxConcurrentStreams:a,pipelining:i,...r}=t??{},s=100,n=100;if(a!=null&&Number.isInteger(a)&&a>0&&(s=a),i!=null&&Number.isInteger(i)&&i>0&&(n=i),n>s)throw new EB("h2c-client: pipelining cannot be greater than maxConcurrentStreams");super(e,{...r,maxConcurrentStreams:s,pipelining:n,allowH2:!0,useH2c:!0})}};IB.exports=$k});var UB=y((tpe,NB)=>{"use strict";var SB=require("assert"),{Readable:fee}=require("stream"),{RequestAbortedError:DB,NotSupportedError:bee,InvalidArgumentError:yee,AbortError:Pd}=$(),TB=K(),{ReadableStreamFrom:kee}=K(),Ko=Symbol("kConsume"),Hd=Symbol("kReading"),Lr=Symbol("kBody"),jB=Symbol("kAbort"),RB=Symbol("kContentType"),Wk=Symbol("kContentLength"),Jk=Symbol("kUsed"),Gd=Symbol("kBytesRead"),Aee=()=>{},Kk=class extends fee{constructor({resume:e,abort:t,contentType:a="",contentLength:i,highWaterMark:r=64*1024}){super({autoDestroy:!0,read:e,highWaterMark:r}),this._readableState.dataEmitted=!1,this[jB]=t,this[Ko]=null,this[Gd]=0,this[Lr]=null,this[Jk]=!1,this[RB]=a,this[Wk]=Number.isFinite(i)?i:null,this[Hd]=!1}_destroy(e,t){!e&&!this._readableState.endEmitted&&(e=new DB),e&&this[jB](),this[Jk]?t(e):setImmediate(t,e)}on(e,t){return(e==="data"||e==="readable")&&(this[Hd]=!0,this[Jk]=!0),super.on(e,t)}addListener(e,t){return this.on(e,t)}off(e,t){let a=super.off(e,t);return(e==="data"||e==="readable")&&(this[Hd]=this.listenerCount("data")>0||this.listenerCount("readable")>0),a}removeListener(e,t){return this.off(e,t)}push(e){return e&&(this[Gd]+=e.length,this[Ko])?(Xk(this[Ko],e),this[Hd]?super.push(e):!0):super.push(e)}text(){return Em(this,"text")}json(){return Em(this,"json")}blob(){return Em(this,"blob")}bytes(){return Em(this,"bytes")}arrayBuffer(){return Em(this,"arrayBuffer")}async formData(){throw new bee}get bodyUsed(){return TB.isDisturbed(this)}get body(){return this[Lr]||(this[Lr]=kee(this),this[Ko]&&(this[Lr].getReader(),SB(this[Lr].locked))),this[Lr]}dump(e){let t=e?.signal;if(t!=null&&(typeof t!="object"||!("aborted"in t)))return Promise.reject(new yee("signal must be an AbortSignal"));let a=e?.limit&&Number.isFinite(e.limit)?e.limit:128*1024;return t?.aborted?Promise.reject(t.reason??new Pd):this._readableState.closeEmitted?Promise.resolve(null):new Promise((i,r)=>{if((this[Wk]&&this[Wk]>a||this[Gd]>a)&&this.destroy(new Pd),t){let s=()=>{this.destroy(t.reason??new Pd)};t.addEventListener("abort",s),this.on("close",function(){t.removeEventListener("abort",s),t.aborted?r(t.reason??new Pd):i(null)})}else this.on("close",i);this.on("error",Aee).on("data",()=>{this[Gd]>a&&this.destroy()}).resume()})}setEncoding(e){return Buffer.isEncoding(e)&&(this._readableState.encoding=e),this}};function wee(o){return o[Lr]?.locked===!0||o[Ko]!==null}function vee(o){return TB.isDisturbed(o)||wee(o)}function Em(o,e){return SB(!o[Ko]),new Promise((t,a)=>{if(vee(o)){let i=o._readableState;i.destroyed&&i.closeEmitted===!1?o.on("error",a).on("close",()=>{a(new TypeError("unusable"))}):a(i.errored??new TypeError("unusable"))}else queueMicrotask(()=>{o[Ko]={type:e,stream:o,resolve:t,reject:a,length:0,body:[]},o.on("error",function(i){eA(this[Ko],i)}).on("close",function(){this[Ko].body!==null&&eA(this[Ko],new DB)}),xee(o[Ko])})})}function xee(o){if(o.body===null)return;let{_readableState:e}=o.stream;if(e.bufferIndex){let t=e.bufferIndex,a=e.buffer.length;for(let i=t;i<a;i++)Xk(o,e.buffer[i])}else for(let t of e.buffer)Xk(o,t);for(e.endEmitted?QB(this[Ko],this._readableState.encoding):o.stream.on("end",function(){QB(this[Ko],this._readableState.encoding)}),o.stream.resume();o.stream.read()!=null;);}function Zk(o,e,t){if(o.length===0||e===0)return"";let a=o.length===1?o[0]:Buffer.concat(o,e),i=a.length,r=i>2&&a[0]===239&&a[1]===187&&a[2]===191?3:0;return!t||t==="utf8"||t==="utf-8"?a.utf8Slice(r,i):a.subarray(r,i).toString(t)}function BB(o,e){if(o.length===0||e===0)return new Uint8Array(0);if(o.length===1)return new Uint8Array(o[0]);let t=new Uint8Array(Buffer.allocUnsafeSlow(e).buffer),a=0;for(let i=0;i<o.length;++i){let r=o[i];t.set(r,a),a+=r.length}return t}function QB(o,e){let{type:t,body:a,resolve:i,stream:r,length:s}=o;try{t==="text"?i(Zk(a,s,e)):t==="json"?i(JSON.parse(Zk(a,s,e))):t==="arrayBuffer"?i(BB(a,s).buffer):t==="blob"?i(new Blob(a,{type:r[RB]})):t==="bytes"&&i(BB(a,s)),eA(o)}catch(n){r.destroy(n)}}function Xk(o,e){o.length+=e.length,o.body.push(e)}function eA(o,e){o.body!==null&&(e?o.reject(e):o.resolve(),o.type=null,o.stream=null,o.resolve=null,o.reject=null,o.length=0,o.body=null)}NB.exports={Readable:Kk,chunksDecode:Zk}});var _B=y((ape,oA)=>{"use strict";var zee=require("assert"),{AsyncResource:qee}=require("async_hooks"),{Readable:Eee}=UB(),{InvalidArgumentError:sn,RequestAbortedError:OB}=$(),zt=K();function Im(){}var Yd=class extends qee{constructor(e,t){if(!e||typeof e!="object")throw new sn("invalid opts");let{signal:a,method:i,opaque:r,body:s,onInfo:n,responseHeaders:c,highWaterMark:m}=e;try{if(typeof t!="function")throw new sn("invalid callback");if(m!=null&&(!Number.isFinite(m)||m<0))throw new sn("invalid highWaterMark");if(a&&typeof a.on!="function"&&typeof a.addEventListener!="function")throw new sn("signal must be an EventEmitter or EventTarget");if(i==="CONNECT")throw new sn("invalid method");if(n&&typeof n!="function")throw new sn("invalid onInfo callback");super("UNDICI_REQUEST")}catch(l){throw zt.isStream(s)&&zt.destroy(s.on("error",Im),l),l}this.method=i,this.responseHeaders=c||null,this.opaque=r||null,this.callback=t,this.res=null,this.abort=null,this.body=s,this.trailers={},this.context=null,this.onInfo=n||null,this.highWaterMark=m,this.reason=null,this.removeAbortListener=null,a?.aborted?this.reason=a.reason??new OB:a&&(this.removeAbortListener=zt.addAbortListener(a,()=>{this.reason=a.reason??new OB,this.res?zt.destroy(this.res.on("error",Im),this.reason):this.abort&&this.abort(this.reason)}))}onConnect(e,t){if(this.reason){e(this.reason);return}zee(this.callback),this.abort=e,this.context=t}onHeaders(e,t,a,i){let{callback:r,opaque:s,abort:n,context:c,responseHeaders:m,highWaterMark:l}=this,u=m==="raw"?zt.parseRawHeaders(t):zt.parseHeaders(t);if(e<200){this.onInfo&&this.onInfo({statusCode:e,headers:u});return}let d=m==="raw"?zt.parseHeaders(t):u,g=d["content-type"],p=d["content-length"],b=new Eee({resume:a,abort:n,contentType:g,contentLength:this.method!=="HEAD"&&p?Number(p):null,highWaterMark:l});if(this.removeAbortListener&&(b.on("close",this.removeAbortListener),this.removeAbortListener=null),this.callback=null,this.res=b,r!==null)try{this.runInAsyncScope(r,null,null,{statusCode:e,statusText:i,headers:u,trailers:this.trailers,opaque:s,body:b,context:c})}catch(A){this.res=null,zt.destroy(b.on("error",Im),A),queueMicrotask(()=>{throw A})}}onData(e){return this.res.push(e)}onComplete(e){zt.parseHeaders(e,this.trailers),this.res.push(null)}onError(e){let{res:t,callback:a,body:i,opaque:r}=this;a&&(this.callback=null,queueMicrotask(()=>{this.runInAsyncScope(a,null,e,{opaque:r})})),t&&(this.res=null,queueMicrotask(()=>{zt.destroy(t.on("error",Im),e)})),i&&(this.body=null,zt.isStream(i)&&(i.on("error",Im),zt.destroy(i,e))),this.removeAbortListener&&(this.removeAbortListener(),this.removeAbortListener=null)}};function MB(o,e){if(e===void 0)return new Promise((t,a)=>{MB.call(this,o,(i,r)=>i?a(i):t(r))});try{let t=new Yd(o,e);this.dispatch(o,t)}catch(t){if(typeof e!="function")throw t;let a=o?.opaque;queueMicrotask(()=>e(t,{opaque:a}))}}oA.exports=MB;oA.exports.RequestHandler=Yd});var Cm=y((ipe,PB)=>{"use strict";var{addAbortListener:Iee}=K(),{RequestAbortedError:Cee}=$(),nn=Symbol("kListener"),sa=Symbol("kSignal");function LB(o){o.abort?o.abort(o[sa]?.reason):o.reason=o[sa]?.reason??new Cee,FB(o)}function jee(o,e){if(o.reason=null,o[sa]=null,o[nn]=null,!!e){if(e.aborted){LB(o);return}o[sa]=e,o[nn]=()=>{LB(o)},Iee(o[sa],o[nn])}}function FB(o){o[sa]&&("removeEventListener"in o[sa]?o[sa].removeEventListener("abort",o[nn]):o[sa].removeListener("abort",o[nn]),o[sa]=null,o[nn]=null)}PB.exports={addSignal:jee,removeSignal:FB}});var VB=y((rpe,YB)=>{"use strict";var Bee=require("assert"),{finished:Qee}=require("stream"),{AsyncResource:See}=require("async_hooks"),{InvalidArgumentError:cn,InvalidReturnValueError:Dee}=$(),Pa=K(),{addSignal:Tee,removeSignal:HB}=Cm();function Ree(){}var tA=class extends See{constructor(e,t,a){if(!e||typeof e!="object")throw new cn("invalid opts");let{signal:i,method:r,opaque:s,body:n,onInfo:c,responseHeaders:m}=e;try{if(typeof a!="function")throw new cn("invalid callback");if(typeof t!="function")throw new cn("invalid factory");if(i&&typeof i.on!="function"&&typeof i.addEventListener!="function")throw new cn("signal must be an EventEmitter or EventTarget");if(r==="CONNECT")throw new cn("invalid method");if(c&&typeof c!="function")throw new cn("invalid onInfo callback");super("UNDICI_STREAM")}catch(l){throw Pa.isStream(n)&&Pa.destroy(n.on("error",Ree),l),l}this.responseHeaders=m||null,this.opaque=s||null,this.factory=t,this.callback=a,this.res=null,this.abort=null,this.context=null,this.trailers=null,this.body=n,this.onInfo=c||null,Pa.isStream(n)&&n.on("error",l=>{this.onError(l)}),Tee(this,i)}onConnect(e,t){if(this.reason){e(this.reason);return}Bee(this.callback),this.abort=e,this.context=t}onHeaders(e,t,a,i){let{factory:r,opaque:s,context:n,responseHeaders:c}=this,m=c==="raw"?Pa.parseRawHeaders(t):Pa.parseHeaders(t);if(e<200){this.onInfo&&this.onInfo({statusCode:e,headers:m});return}if(this.factory=null,r===null)return;let l=this.runInAsyncScope(r,null,{statusCode:e,headers:m,opaque:s,context:n});if(!l||typeof l.write!="function"||typeof l.end!="function"||typeof l.on!="function")throw new Dee("expected Writable");return Qee(l,{readable:!1},d=>{let{callback:g,res:p,opaque:b,trailers:A,abort:k}=this;this.res=null,(d||!p?.readable)&&Pa.destroy(p,d),this.callback=null,this.runInAsyncScope(g,null,d||null,{opaque:b,trailers:A}),d&&k()}),l.on("drain",a),this.res=l,(l.writableNeedDrain!==void 0?l.writableNeedDrain:l._writableState?.needDrain)!==!0}onData(e){let{res:t}=this;return t?t.write(e):!0}onComplete(e){let{res:t}=this;HB(this),t&&(this.trailers=Pa.parseHeaders(e),t.end())}onError(e){let{res:t,callback:a,opaque:i,body:r}=this;HB(this),this.factory=null,t?(this.res=null,Pa.destroy(t,e)):a&&(this.callback=null,queueMicrotask(()=>{this.runInAsyncScope(a,null,e,{opaque:i})})),r&&(this.body=null,Pa.destroy(r,e))}};function GB(o,e,t){if(t===void 0)return new Promise((a,i)=>{GB.call(this,o,e,(r,s)=>r?i(r):a(s))});try{let a=new tA(o,e,t);this.dispatch(o,a)}catch(a){if(typeof t!="function")throw a;let i=o?.opaque;queueMicrotask(()=>t(a,{opaque:i}))}}YB.exports=GB});var KB=y((spe,JB)=>{"use strict";var{Readable:WB,Duplex:Nee,PassThrough:Uee}=require("stream"),Oee=require("assert"),{AsyncResource:Mee}=require("async_hooks"),{InvalidArgumentError:jm,InvalidReturnValueError:_ee,RequestAbortedError:aA}=$(),na=K(),{addSignal:Lee,removeSignal:Fee}=Cm();function $B(){}var mn=Symbol("resume"),iA=class extends WB{constructor(){super({autoDestroy:!0}),this[mn]=null}_read(){let{[mn]:e}=this;e&&(this[mn]=null,e())}_destroy(e,t){this._read(),t(e)}},rA=class extends WB{constructor(e){super({autoDestroy:!0}),this[mn]=e}_read(){this[mn]()}_destroy(e,t){!e&&!this._readableState.endEmitted&&(e=new aA),t(e)}},sA=class extends Mee{constructor(e,t){if(!e||typeof e!="object")throw new jm("invalid opts");if(typeof t!="function")throw new jm("invalid handler");let{signal:a,method:i,opaque:r,onInfo:s,responseHeaders:n}=e;if(a&&typeof a.on!="function"&&typeof a.addEventListener!="function")throw new jm("signal must be an EventEmitter or EventTarget");if(i==="CONNECT")throw new jm("invalid method");if(s&&typeof s!="function")throw new jm("invalid onInfo callback");super("UNDICI_PIPELINE"),this.opaque=r||null,this.responseHeaders=n||null,this.handler=t,this.abort=null,this.context=null,this.onInfo=s||null,this.req=new iA().on("error",$B),this.ret=new Nee({readableObjectMode:e.objectMode,autoDestroy:!0,read:()=>{let{body:c}=this;c?.resume&&c.resume()},write:(c,m,l)=>{let{req:u}=this;u.push(c,m)||u._readableState.destroyed?l():u[mn]=l},destroy:(c,m)=>{let{body:l,req:u,res:d,ret:g,abort:p}=this;!c&&!g._readableState.endEmitted&&(c=new aA),p&&c&&p(),na.destroy(l,c),na.destroy(u,c),na.destroy(d,c),Fee(this),m(c)}}).on("prefinish",()=>{let{req:c}=this;c.push(null)}),this.res=null,Lee(this,a)}onConnect(e,t){let{res:a}=this;if(this.reason){e(this.reason);return}Oee(!a,"pipeline cannot be retried"),this.abort=e,this.context=t}onHeaders(e,t,a){let{opaque:i,handler:r,context:s}=this;if(e<200){if(this.onInfo){let c=this.responseHeaders==="raw"?na.parseRawHeaders(t):na.parseHeaders(t);this.onInfo({statusCode:e,headers:c})}return}this.res=new rA(a);let n;try{this.handler=null;let c=this.responseHeaders==="raw"?na.parseRawHeaders(t):na.parseHeaders(t);n=this.runInAsyncScope(r,null,{statusCode:e,headers:c,opaque:i,body:this.res,context:s})}catch(c){throw this.res.on("error",$B),c}if(!n||typeof n.on!="function")throw new _ee("expected Readable");n.on("data",c=>{let{ret:m,body:l}=this;!m.push(c)&&l.pause&&l.pause()}).on("error",c=>{let{ret:m}=this;na.destroy(m,c)}).on("end",()=>{let{ret:c}=this;c.push(null)}).on("close",()=>{let{ret:c}=this;c._readableState.ended||na.destroy(c,new aA)}),this.body=n}onData(e){let{res:t}=this;return t.push(e)}onComplete(e){let{res:t}=this;t.push(null)}onError(e){let{ret:t}=this;this.handler=null,na.destroy(t,e)}};function Pee(o,e){try{let t=new sA(o,e);return this.dispatch({...o,body:t.req},t),t.ret}catch(t){return new Uee().destroy(t)}}JB.exports=Pee});var a4=y((npe,t4)=>{"use strict";var{InvalidArgumentError:nA,SocketError:Hee}=$(),{AsyncResource:Gee}=require("async_hooks"),ZB=require("assert"),XB=K(),{kHTTP2Stream:Yee}=de(),{addSignal:Vee,removeSignal:e4}=Cm(),cA=class extends Gee{constructor(e,t){if(!e||typeof e!="object")throw new nA("invalid opts");if(typeof t!="function")throw new nA("invalid callback");let{signal:a,opaque:i,responseHeaders:r}=e;if(a&&typeof a.on!="function"&&typeof a.addEventListener!="function")throw new nA("signal must be an EventEmitter or EventTarget");super("UNDICI_UPGRADE"),this.responseHeaders=r||null,this.opaque=i||null,this.callback=t,this.abort=null,this.context=null,Vee(this,a)}onConnect(e,t){if(this.reason){e(this.reason);return}ZB(this.callback),this.abort=e,this.context=null}onHeaders(){throw new Hee("bad upgrade",null)}onUpgrade(e,t,a){ZB(a[Yee]===!0?e===200:e===101);let{callback:i,opaque:r,context:s}=this;e4(this),this.callback=null;let n=this.responseHeaders==="raw"?XB.parseRawHeaders(t):XB.parseHeaders(t);this.runInAsyncScope(i,null,null,{headers:n,socket:a,opaque:r,context:s})}onError(e){let{callback:t,opaque:a}=this;e4(this),t&&(this.callback=null,queueMicrotask(()=>{this.runInAsyncScope(t,null,e,{opaque:a})}))}};function o4(o,e){if(e===void 0)return new Promise((t,a)=>{o4.call(this,o,(i,r)=>i?a(i):t(r))});try{let t=new cA(o,e),a={...o,method:o.method||"GET",upgrade:o.protocol||"Websocket"};this.dispatch(a,t)}catch(t){if(typeof e!="function")throw t;let a=o?.opaque;queueMicrotask(()=>e(t,{opaque:a}))}}t4.exports=o4});var c4=y((cpe,n4)=>{"use strict";var $ee=require("assert"),{AsyncResource:Wee}=require("async_hooks"),{InvalidArgumentError:mA,SocketError:Jee}=$(),i4=K(),{addSignal:Kee,removeSignal:r4}=Cm(),lA=class extends Wee{constructor(e,t){if(!e||typeof e!="object")throw new mA("invalid opts");if(typeof t!="function")throw new mA("invalid callback");let{signal:a,opaque:i,responseHeaders:r}=e;if(a&&typeof a.on!="function"&&typeof a.addEventListener!="function")throw new mA("signal must be an EventEmitter or EventTarget");super("UNDICI_CONNECT"),this.opaque=i||null,this.responseHeaders=r||null,this.callback=t,this.abort=null,Kee(this,a)}onConnect(e,t){if(this.reason){e(this.reason);return}$ee(this.callback),this.abort=e,this.context=t}onHeaders(){throw new Jee("bad connect",null)}onUpgrade(e,t,a){let{callback:i,opaque:r,context:s}=this;r4(this),this.callback=null;let n=t;n!=null&&(n=this.responseHeaders==="raw"?i4.parseRawHeaders(t):i4.parseHeaders(t)),this.runInAsyncScope(i,null,null,{statusCode:e,headers:n,socket:a,opaque:r,context:s})}onError(e){let{callback:t,opaque:a}=this;r4(this),t&&(this.callback=null,queueMicrotask(()=>{this.runInAsyncScope(t,null,e,{opaque:a})}))}};function s4(o,e){if(e===void 0)return new Promise((t,a)=>{s4.call(this,o,(i,r)=>i?a(i):t(r))});try{let t=new lA(o,e),a={...o,method:"CONNECT"};this.dispatch(a,t)}catch(t){if(typeof e!="function")throw t;let a=o?.opaque;queueMicrotask(()=>e(t,{opaque:a}))}}n4.exports=s4});var m4=y((mpe,ln)=>{"use strict";ln.exports.request=_B();ln.exports.stream=VB();ln.exports.pipeline=KB();ln.exports.upgrade=a4();ln.exports.connect=c4()});var dA=y((lpe,u4)=>{"use strict";var{UndiciError:Zee}=$(),l4=Symbol.for("undici.error.UND_MOCK_ERR_MOCK_NOT_MATCHED"),uA=class extends Zee{constructor(e){super(e),this.name="MockNotMatchedError",this.message=e||"The request does not match any registered mock dispatches",this.code="UND_MOCK_ERR_MOCK_NOT_MATCHED"}static[Symbol.hasInstance](e){return e&&e[l4]===!0}get[l4](){return!0}};u4.exports={MockNotMatchedError:uA}});var Fr=y((upe,d4)=>{"use strict";d4.exports={kAgent:Symbol("agent"),kOptions:Symbol("options"),kFactory:Symbol("factory"),kDispatches:Symbol("dispatches"),kDispatchKey:Symbol("dispatch key"),kDefaultHeaders:Symbol("default headers"),kDefaultTrailers:Symbol("default trailers"),kContentLength:Symbol("content length"),kMockAgent:Symbol("mock agent"),kMockAgentSet:Symbol("mock agent set"),kMockAgentGet:Symbol("mock agent get"),kMockDispatch:Symbol("mock dispatch"),kClose:Symbol("close"),kOriginalClose:Symbol("original agent close"),kOriginalDispatch:Symbol("original dispatch"),kOrigin:Symbol("origin"),kIsMockActive:Symbol("is mock active"),kNetConnect:Symbol("net connect"),kGetNetConnect:Symbol("get net connect"),kConnected:Symbol("connected"),kIgnoreTrailingSlash:Symbol("ignore trailing slash"),kMockAgentMockCallHistoryInstance:Symbol("mock agent mock call history name"),kMockAgentRegisterCallHistory:Symbol("mock agent register mock call history"),kMockAgentAddCallHistoryLog:Symbol("mock agent add call history log"),kMockAgentIsCallHistoryEnabled:Symbol("mock agent is call history enabled"),kMockAgentAcceptsNonStandardSearchParameters:Symbol("mock agent accepts non standard search parameters"),kMockCallHistoryAddLog:Symbol("mock call history add log"),kTotalDispatchCount:Symbol("total dispatch count")}});var Bm=y((dpe,x4)=>{"use strict";var{MockNotMatchedError:un}=dA(),{kDispatches:Pr,kMockAgent:Xee,kOriginalDispatch:eoe,kOrigin:ooe,kGetNetConnect:toe,kTotalDispatchCount:hA}=Fr(),{serializePathWithQuery:aoe}=K(),{STATUS_CODES:ioe}=require("http"),{types:{isPromise:roe}}=require("util"),{InvalidArgumentError:gA}=$();function ca(o,e){return typeof o=="string"?o===e:o instanceof RegExp?o.test(e):typeof o=="function"?o(e)===!0:!1}function p4(o){return Object.fromEntries(Object.entries(o).map(([e,t])=>[e.toLocaleLowerCase(),t]))}function h4(o,e){if(Array.isArray(o)){for(let t=0;t<o.length;t+=2)if(o[t].toLocaleLowerCase()===e.toLocaleLowerCase())return o[t+1];return}else return typeof o.get=="function"?o.get(e):p4(o)[e.toLocaleLowerCase()]}function yA(o){let e=o.slice(),t=[];for(let a=0;a<e.length;a+=2)t.push([e[a],e[a+1]]);return Object.fromEntries(t)}function f4(o,e){if(typeof o.headers=="function")return Array.isArray(e)&&(e=yA(e)),o.headers(e?p4(e):{});if(typeof o.headers>"u")return!0;if(typeof e!="object"||typeof o.headers!="object")return!1;for(let[t,a]of Object.entries(o.headers)){let i=h4(e,t);if(!ca(a,i))return!1}return!0}function soe(o){if(typeof o!="string")return o;let e=new URLSearchParams(o),t=new URLSearchParams;for(let[a,i]of e.entries()){if(a=a.replace("[]",""),/^(['"]).*\1$/.test(i)){t.append(a,i);continue}if(i.includes(",")){let s=i.split(",");for(let n of s)t.append(a,n);continue}t.append(a,i)}return t}function pA(o){if(typeof o!="string")return o;let e=o.split("?",3);if(e.length!==2)return o;let t=new URLSearchParams(e.pop());return t.sort(),[...e,t.toString()].join("?")}function noe(o,{path:e,method:t,body:a,headers:i}){let r=ca(o.path,e),s=ca(o.method,t),n=typeof o.body<"u"?ca(o.body,a):!0,c=f4(o,i);return r&&s&&n&&c}function b4(o){return Buffer.isBuffer(o)||o instanceof Uint8Array||o instanceof ArrayBuffer?o:typeof o=="object"?JSON.stringify(o):o?o.toString():""}function y4(o,e){let t=e.query?aoe(e.path,e.query):e.path,a=typeof t=="string"?pA(t):t,i=g4(a),r=o.filter(({consumed:s})=>!s).filter(({path:s,ignoreTrailingSlash:n})=>n?ca(g4(pA(s)),i):ca(pA(s),a));if(r.length===0)throw new un(`Mock dispatch not matched for path '${a}'`);if(r=r.filter(({method:s})=>ca(s,e.method)),r.length===0)throw new un(`Mock dispatch not matched for method '${e.method}' on path '${a}'`);if(r=r.filter(({body:s})=>typeof s<"u"?ca(s,e.body):!0),r.length===0)throw new un(`Mock dispatch not matched for body '${e.body}' on path '${a}'`);if(r=r.filter(s=>f4(s,e.headers)),r.length===0){let s=typeof e.headers=="object"?JSON.stringify(e.headers):e.headers;throw new un(`Mock dispatch not matched for headers '${s}' on path '${a}'`)}return r[0]}function coe(o,e,t,a){let i={timesInvoked:0,times:1,persist:!1,consumed:!1,...a},r=typeof t=="function"?{callback:t}:{...t},s={...i,...e,pending:!0,data:{error:null,...r}};return o.push(s),o[hA]=(o[hA]||0)+1,s}function fA(o,e){let t=o.findIndex(a=>a.consumed?noe(a,e):!1);t!==-1&&o.splice(t,1)}function g4(o){for(;o.endsWith("/");)o=o.slice(0,-1);return o.length===0&&(o="/"),o}function k4(o){let{path:e,method:t,body:a,headers:i,query:r}=o;return{path:e,method:t,body:a,headers:i,query:r}}function bA(o){let e=Object.keys(o),t=[];for(let a=0;a<e.length;++a){let i=e[a],r=o[i],s=Buffer.from(`${i}`);if(Array.isArray(r))for(let n=0;n<r.length;++n)t.push(s,Buffer.from(`${r[n]}`));else t.push(s,Buffer.from(`${r}`))}return t}function A4(o){return ioe[o]||"unknown"}async function moe(o){let e=[];for await(let t of o)e.push(t);return Buffer.concat(e).toString("utf8")}function w4(o,e){let t=k4(o),a=y4(this[Pr],t);a.timesInvoked++,a.data.callback&&(a.data={...a.data,...a.data.callback(o)});let{data:{statusCode:i,data:r,headers:s,trailers:n,error:c},delay:m,persist:l}=a,{timesInvoked:u,times:d}=a;if(a.consumed=!l&&u>=d,a.pending=u<d,c!==null)return fA(this[Pr],t),e.onError(c),!0;let g=!1,p=null;function b(x){g||(g=!0,p!==null&&(clearTimeout(p),p=null),e.onError(x))}e.onConnect?.(b,null),typeof m=="number"&&m>0?p=setTimeout(()=>{p=null,A(this[Pr])},m):A(this[Pr]);function A(x,v=r){if(g)return;let j=Array.isArray(o.headers)?yA(o.headers):o.headers,I=typeof v=="function"?v({...o,headers:j}):v;if(roe(I))return I.then(S=>A(x,S));if(g)return;let T=b4(I),D=bA(s),O=bA(n);e.onHeaders?.(i,D,k,A4(i)),e.onData?.(Buffer.from(T)),e.onComplete?.(O),fA(x,t)}function k(){}return!0}function loe(){let o=this[Xee],e=this[ooe],t=this[eoe];return function(i,r){if(o.isMockActive)try{w4.call(this,i,r)}catch(s){if(s.code==="UND_MOCK_ERR_MOCK_NOT_MATCHED"){let n=o[toe](),c=this[Pr][hA]||this[Pr].length,l=`, ${this[Pr].filter(({consumed:u})=>!u).length} interceptor(s) remaining out of ${c} defined`;if(n===!1)throw new un(`${s.message}: subsequent request to origin ${e} was not allowed (net.connect disabled)${l}`);if(v4(n,e))t.call(this,i,r);else throw new un(`${s.message}: subsequent request to origin ${e} was not allowed (net.connect is not enabled for this origin)${l}`)}else throw s}else t.call(this,i,r)}}function v4(o,e){let t=new URL(e);return o===!0?!0:!!(Array.isArray(o)&&o.some(a=>ca(a,t.host)))}function uoe(o){return typeof o!="string"&&!(o instanceof URL)?o:o instanceof URL?o.origin:o.toLowerCase()}function doe(o){let{agent:e,...t}=o;if("enableCallHistory"in t&&typeof t.enableCallHistory!="boolean")throw new gA("options.enableCallHistory must to be a boolean");if("acceptNonStandardSearchParameters"in t&&typeof t.acceptNonStandardSearchParameters!="boolean")throw new gA("options.acceptNonStandardSearchParameters must to be a boolean");if("ignoreTrailingSlash"in t&&typeof t.ignoreTrailingSlash!="boolean")throw new gA("options.ignoreTrailingSlash must to be a boolean");return t}x4.exports={getResponseData:b4,getMockDispatch:y4,addMockDispatch:coe,deleteMockDispatch:fA,buildKey:k4,generateKeyValues:bA,matchValue:ca,getResponse:moe,getStatusText:A4,mockDispatch:w4,buildMockDispatch:loe,checkNetConnect:v4,buildAndValidateMockOptions:doe,getHeaderByName:h4,buildHeadersFromArray:yA,normalizeSearchParams:soe,normalizeOrigin:uoe}});var qA=y((gpe,zA)=>{"use strict";var{getResponseData:goe,buildKey:poe,addMockDispatch:kA}=Bm(),{kDispatches:Vd,kDispatchKey:$d,kDefaultHeaders:AA,kDefaultTrailers:wA,kContentLength:vA,kMockDispatch:Wd,kIgnoreTrailingSlash:Jd}=Fr(),{InvalidArgumentError:ma}=$(),{serializePathWithQuery:hoe}=K(),dn=class{constructor(e){this[Wd]=e}delay(e){if(typeof e!="number"||!Number.isInteger(e)||e<=0)throw new ma("waitInMs must be a valid integer > 0");return this[Wd].delay=e,this}persist(){return this[Wd].persist=!0,this}times(e){if(typeof e!="number"||!Number.isInteger(e)||e<=0)throw new ma("repeatTimes must be a valid integer > 0");return this[Wd].times=e,this}},xA=class{constructor(e,t){if(typeof e!="object")throw new ma("opts must be an object");if(typeof e.path>"u")throw new ma("opts.path must be defined");if(typeof e.method>"u"&&(e.method="GET"),typeof e.path=="string")if(e.query)e.path=hoe(e.path,e.query);else{let a=new URL(e.path,"data://");e.path=a.pathname+a.search}typeof e.method=="string"&&(e.method=e.method.toUpperCase()),this[$d]=poe(e),this[Vd]=t,this[Jd]=e.ignoreTrailingSlash??!1,this[AA]={},this[wA]={},this[vA]=!1}createMockScopeDispatchData({statusCode:e,data:t,responseOptions:a}){let i=goe(t),r=this[vA]?{"content-length":i.length}:{},s={...this[AA],...r,...a.headers},n={...this[wA],...a.trailers};return{statusCode:e,data:t,headers:s,trailers:n}}validateReplyParameters(e){if(typeof e.statusCode>"u")throw new ma("statusCode must be defined");if(typeof e.responseOptions!="object"||e.responseOptions===null)throw new ma("responseOptions must be an object")}reply(e){if(typeof e=="function"){let r=n=>{let c=e(n);if(typeof c!="object"||c===null)throw new ma("reply options callback must return an object");let m={data:"",responseOptions:{},...c};return this.validateReplyParameters(m),{...this.createMockScopeDispatchData(m)}},s=kA(this[Vd],this[$d],r,{ignoreTrailingSlash:this[Jd]});return new dn(s)}let t={statusCode:e,data:arguments[1]===void 0?"":arguments[1],responseOptions:arguments[2]===void 0?{}:arguments[2]};this.validateReplyParameters(t);let a=this.createMockScopeDispatchData(t),i=kA(this[Vd],this[$d],a,{ignoreTrailingSlash:this[Jd]});return new dn(i)}replyWithError(e){if(typeof e>"u")throw new ma("error must be defined");let t=kA(this[Vd],this[$d],{error:e},{ignoreTrailingSlash:this[Jd]});return new dn(t)}defaultReplyHeaders(e){if(typeof e>"u")throw new ma("headers must be defined");return this[AA]=e,this}defaultReplyTrailers(e){if(typeof e>"u")throw new ma("trailers must be defined");return this[wA]=e,this}replyContentLength(){return this[vA]=!0,this}};zA.exports.MockInterceptor=xA;zA.exports.MockScope=dn});var jA=y((ppe,B4)=>{"use strict";var{promisify:foe}=require("util"),boe=Ii(),{buildMockDispatch:yoe}=Bm(),{kDispatches:EA,kMockAgent:z4,kClose:q4,kOriginalClose:E4,kOrigin:I4,kOriginalDispatch:koe,kConnected:IA,kIgnoreTrailingSlash:C4}=Fr(),{MockInterceptor:Aoe}=qA(),j4=de(),{InvalidArgumentError:woe}=$(),CA=class extends boe{constructor(e,t){if(!t||!t.agent||typeof t.agent.dispatch!="function")throw new woe("Argument opts.agent must implement Agent");super(e,t),this[z4]=t.agent,this[I4]=e,this[C4]=t.ignoreTrailingSlash??!1,this[EA]=[],this[IA]=1,this[koe]=this.dispatch,this[E4]=this.close.bind(this),this.dispatch=yoe.call(this),this.close=this[q4]}get[j4.kConnected](){return this[IA]}intercept(e){return new Aoe(e&&{ignoreTrailingSlash:this[C4],...e},this[EA])}cleanMocks(){this[EA]=[]}async[q4](){await foe(this[E4])(),this[IA]=0,this[z4][j4.kClients].delete(this[I4])}};B4.exports=CA});var SA=y((hpe,QA)=>{"use strict";var{kMockCallHistoryAddLog:voe}=Fr(),{InvalidArgumentError:Ni}=$();function Ti(o,e,t,a,i){switch(e.operator){case"OR":return a.push(...t(o,i)),a;case"AND":return t(o,a);default:throw new Ni("options.operator must to be a case insensitive string equal to 'OR' or 'AND'")}}function xoe(o={}){let e={};if("operator"in o){if(typeof o.operator!="string"||o.operator.toUpperCase()!=="OR"&&o.operator.toUpperCase()!=="AND")throw new Ni("options.operator must to be a case insensitive string equal to 'OR' or 'AND'");return{...e,operator:o.operator.toUpperCase()}}return e}function Ri(o){return(e,t)=>{if(typeof e=="string"||e==null)return t.filter(a=>a[o]===e);if(e instanceof RegExp)return t.filter(a=>e.test(a[o]));throw new Ni(`${o} parameter should be one of string, regexp, undefined or null`)}}function zoe(o){try{let e=new URL(o.path,o.origin);return e.search.length!==0||(e.search=new URLSearchParams(o.query).toString()),e}catch(e){throw new Ni("An error occurred when computing MockCallHistoryLog.url",{cause:e})}}var Kd=class{constructor(e={}){this.body=e.body,this.headers=e.headers,this.method=e.method;let t=zoe(e);this.fullUrl=t.toString(),this.origin=t.origin,this.path=t.pathname,this.searchParams=Object.fromEntries(t.searchParams),this.protocol=t.protocol,this.host=t.host,this.port=t.port,this.hash=t.hash}toMap(){return new Map([["protocol",this.protocol],["host",this.host],["port",this.port],["origin",this.origin],["path",this.path],["hash",this.hash],["searchParams",this.searchParams],["fullUrl",this.fullUrl],["method",this.method],["body",this.body],["headers",this.headers]])}toString(){let e={betweenKeyValueSeparator:"->",betweenPairSeparator:"|"},t="";return this.toMap().forEach((a,i)=>{(typeof a=="string"||a===void 0||a===null)&&(t=`${t}${i}${e.betweenKeyValueSeparator}${a}${e.betweenPairSeparator}`),(typeof a=="object"&&a!==null||Array.isArray(a))&&(t=`${t}${i}${e.betweenKeyValueSeparator}${JSON.stringify(a)}${e.betweenPairSeparator}`)}),t.slice(0,-1)}},BA=class{logs=[];calls(){return this.logs}firstCall(){return this.logs.at(0)}lastCall(){return this.logs.at(-1)}nthCall(e){if(typeof e!="number")throw new Ni("nthCall must be called with a number");if(!Number.isInteger(e))throw new Ni("nthCall must be called with an integer");if(Math.sign(e)!==1)throw new Ni("nthCall must be called with a positive value. use firstCall or lastCall instead");return this.logs.at(e-1)}filterCalls(e,t){if(this.logs.length===0)return this.logs;if(typeof e=="function")return this.logs.filter(e);if(e instanceof RegExp)return this.logs.filter(a=>e.test(a.toString()));if(typeof e=="object"&&e!==null){if(Object.keys(e).length===0)return this.logs;let a={operator:"OR",...xoe(t)},i=a.operator==="AND"?this.logs:[];return"protocol"in e&&(i=Ti(e.protocol,a,this.filterCallsByProtocol,i,this.logs)),"host"in e&&(i=Ti(e.host,a,this.filterCallsByHost,i,this.logs)),"port"in e&&(i=Ti(e.port,a,this.filterCallsByPort,i,this.logs)),"origin"in e&&(i=Ti(e.origin,a,this.filterCallsByOrigin,i,this.logs)),"path"in e&&(i=Ti(e.path,a,this.filterCallsByPath,i,this.logs)),"hash"in e&&(i=Ti(e.hash,a,this.filterCallsByHash,i,this.logs)),"fullUrl"in e&&(i=Ti(e.fullUrl,a,this.filterCallsByFullUrl,i,this.logs)),"method"in e&&(i=Ti(e.method,a,this.filterCallsByMethod,i,this.logs)),[...new Set(i)]}throw new Ni("criteria parameter should be one of function, regexp, or object")}filterCallsByProtocol=Ri.call(this,"protocol");filterCallsByHost=Ri.call(this,"host");filterCallsByPort=Ri.call(this,"port");filterCallsByOrigin=Ri.call(this,"origin");filterCallsByPath=Ri.call(this,"path");filterCallsByHash=Ri.call(this,"hash");filterCallsByFullUrl=Ri.call(this,"fullUrl");filterCallsByMethod=Ri.call(this,"method");clear(){this.logs=[]}[voe](e){let t=new Kd(e);return this.logs.push(t),t}*[Symbol.iterator](){for(let e of this.calls())yield e}};QA.exports.MockCallHistory=BA;QA.exports.MockCallHistoryLog=Kd});var NA=y((fpe,U4)=>{"use strict";var{promisify:qoe}=require("util"),Eoe=Sr(),{buildMockDispatch:Ioe}=Bm(),{kDispatches:DA,kMockAgent:Q4,kClose:S4,kOriginalClose:D4,kOrigin:T4,kOriginalDispatch:Coe,kConnected:TA,kIgnoreTrailingSlash:R4}=Fr(),{MockInterceptor:joe}=qA(),N4=de(),{InvalidArgumentError:Boe}=$(),RA=class extends Eoe{constructor(e,t){if(!t||!t.agent||typeof t.agent.dispatch!="function")throw new Boe("Argument opts.agent must implement Agent");super(e,t),this[Q4]=t.agent,this[T4]=e,this[R4]=t.ignoreTrailingSlash??!1,this[DA]=[],this[TA]=1,this[Coe]=this.dispatch,this[D4]=this.close.bind(this),this.dispatch=Ioe.call(this),this.close=this[S4]}get[N4.kConnected](){return this[TA]}intercept(e){return new joe(e&&{ignoreTrailingSlash:this[R4],...e},this[DA])}cleanMocks(){this[DA]=[]}async[S4](){await qoe(this[D4])(),this[TA]=0,this[Q4][N4.kClients].delete(this[T4])}};U4.exports=RA});var M4=y((ype,O4)=>{"use strict";var{Transform:Qoe}=require("stream"),{Console:Soe}=require("console"),Doe=process.versions.icu?"\u2705":"Y ",Toe=process.versions.icu?"\u274C":"N ";O4.exports=class{constructor({disableColors:e}={}){this.transform=new Qoe({transform(t,a,i){i(null,t)}}),this.logger=new Soe({stdout:this.transform,inspectOptions:{colors:!e&&!process.env.CI}})}format(e){let t=e.map(({method:a,path:i,data:{statusCode:r},persist:s,times:n,timesInvoked:c,origin:m})=>({Method:a,Origin:m,Path:i,"Status code":r,Persistent:s?Doe:Toe,Invocations:c,Remaining:s?1/0:n-c}));return this.logger.table(t),this.transform.read().toString()}}});var LA=y((kpe,Y4)=>{"use strict";var{kClients:Hr}=de(),Roe=Rr(),{kAgent:UA,kMockAgentSet:Zd,kMockAgentGet:_4,kDispatches:OA,kIsMockActive:Xd,kNetConnect:Gr,kGetNetConnect:Noe,kOptions:eg,kFactory:og,kMockAgentRegisterCallHistory:MA,kMockAgentIsCallHistoryEnabled:Qm,kMockAgentAddCallHistoryLog:L4,kMockAgentMockCallHistoryInstance:gn,kMockAgentAcceptsNonStandardSearchParameters:F4,kMockCallHistoryAddLog:Uoe,kIgnoreTrailingSlash:P4}=Fr(),Ooe=jA(),Moe=NA(),{matchValue:_oe,normalizeSearchParams:Loe,buildAndValidateMockOptions:Foe,normalizeOrigin:H4}=Bm(),{InvalidArgumentError:G4,UndiciError:Poe}=$(),Hoe=Kc(),Goe=M4(),{MockCallHistory:Yoe}=SA(),_A=class extends Hoe{constructor(e={}){super(e);let t=Foe(e);if(this[Gr]=!0,this[Xd]=!0,this[Qm]=t.enableCallHistory??!1,this[F4]=t.acceptNonStandardSearchParameters??!1,this[P4]=t.ignoreTrailingSlash??!1,e?.agent&&typeof e.agent.dispatch!="function")throw new G4("Argument opts.agent must implement Agent");let a=e?.agent?e.agent:new Roe(e);this[UA]=a,this[Hr]=a[Hr],this[eg]=t,this[Qm]&&this[MA]()}get(e){let t=H4(e),a=this[P4]?t.replace(/\/$/,""):t,i=this[_4](a);return i||(i=this[og](a),this[Zd](a,i)),i}dispatch(e,t){e.origin=H4(e.origin),this.get(e.origin),this[L4](e);let a=this[F4],i={...e};if(a&&i.path){let[r,s]=i.path.split("?"),n=Loe(s,a);i.path=`${r}?${n}`}return this[UA].dispatch(i,t)}async close(){this.clearCallHistory(),await this[UA].close(),this[Hr].clear()}deactivate(){this[Xd]=!1}activate(){this[Xd]=!0}enableNetConnect(e){if(typeof e=="string"||typeof e=="function"||e instanceof RegExp)Array.isArray(this[Gr])?this[Gr].push(e):this[Gr]=[e];else if(typeof e>"u")this[Gr]=!0;else throw new G4("Unsupported matcher. Must be one of String|Function|RegExp.")}disableNetConnect(){this[Gr]=!1}enableCallHistory(){return this[Qm]=!0,this}disableCallHistory(){return this[Qm]=!1,this}getCallHistory(){return this[gn]}clearCallHistory(){this[gn]!==void 0&&this[gn].clear()}get isMockActive(){return this[Xd]}[MA](){this[gn]===void 0&&(this[gn]=new Yoe)}[L4](e){this[Qm]&&(this[MA](),this[gn][Uoe](e))}[Zd](e,t){this[Hr].set(e,{count:0,dispatcher:t})}[og](e){let t=Object.assign({agent:this},this[eg]);return this[eg]&&this[eg].connections===1?new Ooe(e,t):new Moe(e,t)}[_4](e){let t=this[Hr].get(e);if(t?.dispatcher)return t.dispatcher;if(typeof e!="string"){let a=this[og]("http://localhost:9999");return this[Zd](e,a),a}for(let[a,i]of Array.from(this[Hr]))if(i&&typeof a!="string"&&_oe(a,e)){let r=this[og](e);return this[Zd](e,r),r[OA]=i.dispatcher[OA],r}}[Noe](){return this[Gr]}pendingInterceptors(){let e=this[Hr];return Array.from(e.entries()).flatMap(([t,a])=>a.dispatcher[OA].map(i=>({...i,origin:t}))).filter(({pending:t})=>t)}assertNoPendingInterceptors({pendingInterceptorsFormatter:e=new Goe}={}){let t=this.pendingInterceptors();if(t.length!==0)throw new Poe(t.length===1?`1 interceptor is pending:
1322
1328
 
1323
1329
  ${e.format(t)}`.trim():`${t.length} interceptors are pending:
1324
1330
 
1325
- ${e.format(t)}`.trim())}};YQ.exports=_A});var FA=y((Ape,JQ)=>{"use strict";var{InvalidArgumentError:Voe}=$(),{runtimeFeatures:$oe}=Ta();function Woe(o={}){let{ignoreHeaders:e=[],excludeHeaders:t=[],matchHeaders:a=[],caseSensitive:i=!1}=o;return{ignore:new Set(e.map(r=>i?r:r.toLowerCase())),exclude:new Set(t.map(r=>i?r:r.toLowerCase())),match:new Set(a.map(r=>i?r:r.toLowerCase()))}}var VQ=$oe.has("crypto")?require("crypto"):null,Joe=VQ?.hash?o=>VQ.hash("sha256",o,"base64url"):o=>Buffer.from(o).toString("base64url");function WQ(o){return Array.isArray(o)&&(o.length&1)===0}function Koe(o=[]){return o.length===0?()=>!1:function(t){let a;for(let i of o)if(typeof i=="string"){if(a||(a=t.toLowerCase()),a.includes(i.toLowerCase()))return!0}else if(i instanceof RegExp&&i.test(t))return!0;return!1}}function Zoe(o){let e={};if(!o)return e;if(WQ(o)){for(let t=0;t<o.length;t+=2){let a=o[t],i=o[t+1];if(a&&i!==void 0){let r=Buffer.isBuffer(a)?a.toString():a,s=Buffer.isBuffer(i)?i.toString():i;e[r.toLowerCase()]=s}}return e}if(o&&typeof o=="object")for(let[t,a]of Object.entries(o))t&&typeof t=="string"&&(e[t.toLowerCase()]=Array.isArray(a)?a.join(", "):String(a));return e}var $Q=["record","playback","update"];function Xoe(o){if(!$Q.includes(o))throw new Voe(`Invalid snapshot mode: ${o}. Must be one of: ${$Q.join(", ")}`)}JQ.exports={createHeaderFilters:Woe,hashId:Joe,isUndiciHeaders:WQ,normalizeHeaders:Zoe,isUrlExcludedFactory:Koe,validateSnapshotMode:Xoe}});var r4=y((wpe,i4)=>{"use strict";var{writeFile:ete,readFile:ote,mkdir:tte}=require("fs/promises"),{dirname:ate,resolve:KQ}=require("path"),{setTimeout:ite,clearTimeout:ZQ}=require("timers"),{InvalidArgumentError:XQ,UndiciError:rte}=$(),{hashId:ste,isUrlExcludedFactory:nte,normalizeHeaders:e4,createHeaderFilters:o4}=FA();function Sm(o,e,t={}){let a=new URL(o.path,o.origin),i=o._normalizedHeaders||e4(o.headers);return o._normalizedHeaders||(o._normalizedHeaders=i),{method:o.method||"GET",url:t.matchQuery!==!1?a.toString():`${a.origin}${a.pathname}`,headers:t4(i,e,t),body:t.matchBody!==!1&&o.body?String(o.body):""}}function t4(o,e,t={}){if(!o||typeof o!="object")return{};let{caseSensitive:a=!1}=t,i={},{ignore:r,exclude:s,match:n}=e;for(let[c,m]of Object.entries(o)){let l=a?c:c.toLowerCase();s.has(l)||r.has(l)||n.size!==0&&!n.has(l)||(i[l]=m)}return i}function a4(o,e,t={}){if(!o||typeof o!="object")return{};let{caseSensitive:a=!1}=t,i={},{exclude:r}=e;for(let[s,n]of Object.entries(o)){let c=a?s:s.toLowerCase();r.has(c)||(i[c]=n)}return i}function Dm(o){let e=[o.method,o.url];if(o.headers&&typeof o.headers=="object"){let a=Object.keys(o.headers).sort();for(let i of a){let r=Array.isArray(o.headers[i])?o.headers[i]:[o.headers[i]];e.push(i);for(let s of r.sort())e.push(String(s))}}e.push(o.body);let t=e.join("|");return ste(t)}var PA=class{#e;#o;#a=new Map;#i;#r=1/0;#t=!1;#c;constructor(e={}){this.#i=e.snapshotPath,this.#r=e.maxSnapshots||1/0,this.#t=e.autoFlush||!1,this.flushInterval=e.flushInterval||3e4,this._flushTimer=null,this.matchOptions={matchHeaders:e.matchHeaders||[],ignoreHeaders:e.ignoreHeaders||[],excludeHeaders:e.excludeHeaders||[],matchBody:e.matchBody!==!1,matchQuery:e.matchQuery!==!1,caseSensitive:e.caseSensitive||!1},this.#c=o4(this.matchOptions),this.shouldRecord=e.shouldRecord||(()=>!0),this.shouldPlayback=e.shouldPlayback||(()=>!0),this.#o=nte(e.excludeUrls),this.#t&&this.#i&&this.#s()}async record(e,t){if(!this.shouldRecord(e)||this.isUrlExcluded(e))return;let a=Sm(e,this.#c,this.matchOptions),i=Dm(a),r=e4(t.headers),s={statusCode:t.statusCode,headers:a4(r,this.#c,this.matchOptions),body:Buffer.isBuffer(t.body)?t.body.toString("base64"):Buffer.from(String(t.body||"")).toString("base64"),trailers:t.trailers};if(this.#a.size>=this.#r&&!this.#a.has(i)){let c=this.#a.keys().next().value;this.#a.delete(c)}let n=this.#a.get(i);n&&n.responses?(n.responses.push(s),n.timestamp=new Date().toISOString()):this.#a.set(i,{request:a,responses:[s],callCount:0,timestamp:new Date().toISOString()}),this.#t&&this.#i&&this.#m()}isUrlExcluded(e){let t=new URL(e.path,e.origin).toString();return this.#o(t)}findSnapshot(e){if(!this.shouldPlayback(e)||this.isUrlExcluded(e))return;let t=Sm(e,this.#c,this.matchOptions),a=Dm(t),i=this.#a.get(a);if(!i)return;let r=i.callCount||0,s=Math.min(r,i.responses.length-1);return i.callCount=r+1,{...i,response:i.responses[s]}}async loadSnapshots(e){let t=e||this.#i;if(!t)throw new XQ("Snapshot path is required");try{let a=await ote(KQ(t),"utf8"),i=JSON.parse(a);if(Array.isArray(i)){this.#a.clear();for(let{hash:r,snapshot:s}of i)this.#a.set(r,s)}else this.#a=new Map(Object.entries(i))}catch(a){if(a.code==="ENOENT")this.#a.clear();else throw new rte(`Failed to load snapshots from ${t}`,{cause:a})}}async saveSnapshots(e){let t=e||this.#i;if(!t)throw new XQ("Snapshot path is required");let a=KQ(t);await tte(ate(a),{recursive:!0});let i=Array.from(this.#a.entries()).map(([r,s])=>({hash:r,snapshot:s}));await ete(a,JSON.stringify(i,null,2),{flush:!0})}clear(){this.#a.clear()}getSnapshots(){return Array.from(this.#a.values())}size(){return this.#a.size}resetCallCounts(){for(let e of this.#a.values())e.callCount=0}deleteSnapshot(e){let t=Sm(e,this.#c,this.matchOptions),a=Dm(t);return this.#a.delete(a)}getSnapshotInfo(e){let t=Sm(e,this.#c,this.matchOptions),a=Dm(t),i=this.#a.get(a);return i?{hash:a,request:i.request,responseCount:i.responses?i.responses.length:i.response?1:0,callCount:i.callCount||0,timestamp:i.timestamp}:null}replaceSnapshots(e){if(this.#a.clear(),Array.isArray(e))for(let{hash:t,snapshot:a}of e)this.#a.set(t,a);else e&&typeof e=="object"&&(this.#a=new Map(Object.entries(e)))}#s(){return this.#m()}#n(){this.#e&&(ZQ(this.#e),this.saveSnapshots().catch(()=>{}),this.#e=null)}#m(){this.#e=ite(()=>{this.saveSnapshots().catch(()=>{}),this.#t?this.#e?.refresh():this.#e=null},1e3)}destroy(){this.#n(),this.#e&&(ZQ(this.#e),this.#e=null)}async close(){this.#i&&this.#a.size!==0&&await this.saveSnapshots(),this.destroy()}};i4.exports={SnapshotRecorder:PA,formatRequestKey:Sm,createRequestHash:Dm,filterHeadersForMatching:t4,filterHeadersForStorage:a4,createHeaderFilters:o4}});var c4=y((vpe,n4)=>{"use strict";var cte=Rr(),mte=LA(),{SnapshotRecorder:lte}=r4(),ute=Jc(),{InvalidArgumentError:dte,UndiciError:gte}=$(),{validateSnapshotMode:pte}=FA(),Bo=Symbol("kSnapshotRecorder"),la=Symbol("kSnapshotMode"),Tm=Symbol("kSnapshotPath"),HA=Symbol("kSnapshotLoaded"),tg=Symbol("kRealAgent"),s4=!1,GA=class extends mte{constructor(e={}){s4||(process.emitWarning("SnapshotAgent is experimental and subject to change","ExperimentalWarning"),s4=!0);let{mode:t="record",snapshotPath:a=null,...i}=e;if(super(i),pte(t),(t==="playback"||t==="update")&&!a)throw new dte(`snapshotPath is required when mode is '${t}'`);this[la]=t,this[Tm]=a,this[Bo]=new lte({snapshotPath:this[Tm],mode:this[la],maxSnapshots:e.maxSnapshots,autoFlush:e.autoFlush,flushInterval:e.flushInterval,matchHeaders:e.matchHeaders,ignoreHeaders:e.ignoreHeaders,excludeHeaders:e.excludeHeaders,matchBody:e.matchBody,matchQuery:e.matchQuery,caseSensitive:e.caseSensitive,shouldRecord:e.shouldRecord,shouldPlayback:e.shouldPlayback,excludeUrls:e.excludeUrls}),this[HA]=!1,(this[la]==="record"||this[la]==="update"||this[la]==="playback"&&e.excludeUrls&&e.excludeUrls.length>0)&&(this[tg]=new cte(e)),(this[la]==="playback"||this[la]==="update")&&this[Tm]&&this.loadSnapshots().catch(()=>{})}dispatch(e,t){t=ute.wrap(t);let a=this[la];if(this[Bo].isUrlExcluded(e))return this[tg].dispatch(e,t);if(a==="playback"||a==="update"){if(!this[HA])return this.#e(e,t);let i=this[Bo].findSnapshot(e);if(i)return this.#a(i,t);if(a==="update")return this.#o(e,t);{let r=new gte(`No snapshot found for ${e.method||"GET"} ${e.path}`);if(t.onError){t.onError(r);return}throw r}}else if(a==="record")return this.#o(e,t)}async#e(e,t){return await this.loadSnapshots(),this.dispatch(e,t)}#o(e,t){let a={statusCode:null,headers:{},trailers:{},body:[]},i=this,r={onRequestStart(n,c){return t.onRequestStart(n,{...c,history:this.history})},onRequestUpgrade(n,c,m,l){return t.onRequestUpgrade(n,c,m,l)},onResponseStart(n,c,m,l){return a.statusCode=c,a.headers=m,t.onResponseStart(n,c,m,l)},onResponseData(n,c){return a.body.push(c),t.onResponseData(n,c)},onResponseEnd(n,c){a.trailers=c;let m=Buffer.concat(a.body);i[Bo].record(e,{statusCode:a.statusCode,headers:a.headers,body:m,trailers:a.trailers}).then(()=>t.onResponseEnd(n,c)).catch(l=>t.onResponseError(n,l))}};return this[tg].dispatch(e,r)}#a(e,t){try{let{response:a}=e,i={pause(){},resume(){},abort(s){this.aborted=!0,this.reason=s},aborted:!1,paused:!1};t.onRequestStart(i),t.onResponseStart(i,a.statusCode,a.headers);let r=Buffer.from(a.body,"base64");t.onResponseData(i,r),t.onResponseEnd(i,a.trailers)}catch(a){t.onError?.(a)}}async loadSnapshots(e){await this[Bo].loadSnapshots(e||this[Tm]),this[HA]=!0,this[la]==="playback"&&this.#i()}async saveSnapshots(e){return this[Bo].saveSnapshots(e||this[Tm])}#i(){for(let e of this[Bo].getSnapshots()){let{request:t,responses:a,response:i}=e,r=new URL(t.url),s=this.get(r.origin),n=a?a[0]:i;n&&s.intercept({path:r.pathname+r.search,method:t.method,headers:t.headers,body:t.body}).reply(n.statusCode,n.body,{headers:n.headers,trailers:n.trailers}).persist()}}getRecorder(){return this[Bo]}getMode(){return this[la]}clearSnapshots(){this[Bo].clear()}resetCallCounts(){this[Bo].resetCallCounts()}deleteSnapshot(e){return this[Bo].deleteSnapshot(e)}getSnapshotInfo(e){return this[Bo].getSnapshotInfo(e)}replaceSnapshots(e){this[Bo].replaceSnapshots(e)}async close(){await this[Bo].close(),await this[tg]?.close(),await super.close()}};n4.exports=GA});var ag=y((xpe,d4)=>{"use strict";var hte=Symbol.for("undici.globalDispatcher.2"),m4=Symbol.for("undici.globalDispatcher.1"),{InvalidArgumentError:fte}=$(),bte=Rr();u4()===void 0&&l4(new bte);function l4(o){if(!o||typeof o.dispatch!="function")throw new fte("Argument agent must implement Agent");Object.defineProperty(globalThis,hte,{value:o,writable:!0,enumerable:!1,configurable:!1}),Object.defineProperty(globalThis,m4,{value:o,writable:!0,enumerable:!1,configurable:!1})}function u4(){return globalThis[m4]}var yte=["fetch","Headers","Response","Request","FormData","WebSocket","CloseEvent","ErrorEvent","MessageEvent","EventSource"];d4.exports={setGlobalDispatcher:l4,getGlobalDispatcher:u4,installedExports:yte}});var pn=y((qpe,g4)=>{"use strict";var Ha=require("assert"),kte=Jc();g4.exports=class{#e;#o=!1;#a=!1;#i=!1;constructor(e){if(typeof e!="object"||e===null)throw new TypeError("handler must be an object");this.#e=kte.wrap(e)}onRequestStart(...e){this.#e.onRequestStart?.(...e)}onRequestUpgrade(...e){return Ha(!this.#o),Ha(!this.#a),this.#e.onRequestUpgrade?.(...e)}onResponseStart(...e){return Ha(!this.#o),Ha(!this.#a),Ha(!this.#i),this.#i=!0,this.#e.onResponseStart?.(...e)}onResponseData(...e){return Ha(!this.#o),Ha(!this.#a),this.#e.onResponseData?.(...e)}onResponseEnd(...e){return Ha(!this.#o),Ha(!this.#a),this.#o=!0,this.#e.onResponseEnd?.(...e)}onResponseError(...e){return this.#a=!0,this.#e.onResponseError?.(...e)}onBodySent(){}}});var WA=y((Epe,b4)=>{"use strict";var Qo=K(),{kBodyUsed:Rm}=de(),$A=require("assert"),{InvalidArgumentError:YA}=$(),Ate=require("events"),wte=[300,301,302,303,307,308],p4=Symbol("body"),h4=()=>{},ig=class{constructor(e){this[p4]=e,this[Rm]=!1}async*[Symbol.asyncIterator](){$A(!this[Rm],"disturbed"),this[Rm]=!0,yield*this[p4]}},VA=class o{static buildDispatch(e,t){if(t!=null&&(!Number.isInteger(t)||t<0))throw new YA("maxRedirections must be a positive number");let a=e.dispatch.bind(e);return(i,r)=>a(i,new o(a,t,i,r))}constructor(e,t,a,i){if(t!=null&&(!Number.isInteger(t)||t<0))throw new YA("maxRedirections must be a positive number");this.dispatch=e,this.location=null;let{maxRedirections:r,...s}=a;this.opts=s,this.maxRedirections=t,this.handler=i,this.history=[],Qo.isStream(this.opts.body)?(Qo.bodyLength(this.opts.body)===0&&this.opts.body.on("data",function(){$A(!1)}),typeof this.opts.body.readableDidRead!="boolean"&&(this.opts.body[Rm]=!1,Ate.prototype.on.call(this.opts.body,"data",function(){this[Rm]=!0}))):this.opts.body&&typeof this.opts.body.pipeTo=="function"?this.opts.body=new ig(this.opts.body):this.opts.body&&typeof this.opts.body!="string"&&!ArrayBuffer.isView(this.opts.body)&&Qo.isIterable(this.opts.body)&&!Qo.isFormDataLike(this.opts.body)&&(this.opts.body=new ig(this.opts.body))}onRequestStart(e,t){this.handler.onRequestStart?.(e,{...t,history:this.history})}onRequestUpgrade(e,t,a,i){this.handler.onRequestUpgrade?.(e,t,a,i)}onResponseStart(e,t,a,i){if(this.opts.throwOnMaxRedirect&&this.history.length>=this.maxRedirections)throw new Error("max redirects");if((t===301||t===302)&&this.opts.method==="POST"&&(this.opts.method="GET",Qo.isStream(this.opts.body)&&Qo.destroy(this.opts.body.on("error",h4)),this.opts.body=null),t===303&&this.opts.method!=="HEAD"&&(this.opts.method="GET",Qo.isStream(this.opts.body)&&Qo.destroy(this.opts.body.on("error",h4)),this.opts.body=null),this.location=this.history.length>=this.maxRedirections||Qo.isDisturbed(this.opts.body)||wte.indexOf(t)===-1?null:a.location,this.opts.origin&&this.history.push(new URL(this.opts.path,this.opts.origin)),!this.location){this.handler.onResponseStart?.(e,t,a,i);return}let{origin:r,pathname:s,search:n}=Qo.parseURL(new URL(this.location,this.opts.origin&&new URL(this.opts.path,this.opts.origin))),c=n?`${s}${n}`:s,m=`${r}${c}`;for(let l of this.history)if(l.toString()===m)throw new YA(`Redirect loop detected. Cannot redirect to ${r}. This typically happens when using a Client or Pool with cross-origin redirects. Use an Agent for cross-origin redirects.`);this.opts.headers=vte(this.opts.headers,t===303,this.opts.origin!==r),this.opts.path=c,this.opts.origin=r,this.opts.query=null}onResponseData(e,t){this.location||this.handler.onResponseData?.(e,t)}onResponseEnd(e,t){this.location?this.dispatch(this.opts,this):this.handler.onResponseEnd(e,t)}onResponseError(e,t){this.handler.onResponseError?.(e,t)}};function f4(o,e,t){if(o.length===4)return Qo.headerNameToString(o)==="host";if(e&&Qo.headerNameToString(o).startsWith("content-"))return!0;if(t&&(o.length===13||o.length===6||o.length===19)){let a=Qo.headerNameToString(o);return a==="authorization"||a==="cookie"||a==="proxy-authorization"}return!1}function vte(o,e,t){let a=[];if(Array.isArray(o))for(let i=0;i<o.length;i+=2)f4(o[i],e,t)||a.push(o[i],o[i+1]);else if(o&&typeof o=="object"){let i=Qo.hasSafeIterator(o)?o:Object.entries(o);for(let[r,s]of i)f4(r,e,t)||a.push(r,s)}else $A(o==null,"headers must be an object or an array");return a}b4.exports=VA});var k4=y((Ipe,y4)=>{"use strict";var xte=WA();function zte({maxRedirections:o}={}){return e=>function(a,i){let{maxRedirections:r=o,...s}=a;if(r==null||r===0)return e(a,i);let n={...s},c=new xte(e,r,n,i);return e(n,c)}}y4.exports=zte});var w4=y((Cpe,A4)=>{"use strict";var qte=pn(),{ResponseError:Ete}=$(),JA=class extends qte{#e;#o;#a;#i;#r;constructor(e,{handler:t}){super(t)}#t(e){return(this.#o??"").indexOf(e)===0}onRequestStart(e,t){return this.#e=0,this.#o=null,this.#a=null,this.#i=null,this.#r="",super.onRequestStart(e,t)}onResponseStart(e,t,a,i){if(this.#e=t,this.#i=a,this.#o=a["content-type"],this.#e<400)return super.onResponseStart(e,t,a,i);(this.#t("application/json")||this.#t("text/plain"))&&(this.#a=new TextDecoder("utf-8"))}onResponseData(e,t){if(this.#e<400)return super.onResponseData(e,t);this.#r+=this.#a?.decode(t,{stream:!0})??""}onResponseEnd(e,t){if(this.#e>=400){if(this.#r+=this.#a?.decode(void 0,{stream:!1})??"",this.#t("application/json"))try{this.#r=JSON.parse(this.#r)}catch{}let a,i=Error.stackTraceLimit;Error.stackTraceLimit=0;try{a=new Ete("Response Error",this.#e,{body:this.#r,headers:this.#i})}finally{Error.stackTraceLimit=i}super.onResponseError(e,a)}else super.onResponseEnd(e,t)}onResponseError(e,t){super.onResponseError(e,t)}};A4.exports=()=>o=>function(t,a){return o(t,new JA(t,{handler:a}))}});var x4=y((jpe,v4)=>{"use strict";var Ite=Fd();v4.exports=o=>e=>function(a,i){return e(a,new Ite({...a,retryOptions:{...o,...a.retryOptions}},{handler:i,dispatch:e}))}});var q4=y((Bpe,z4)=>{"use strict";var{InvalidArgumentError:Cte,RequestAbortedError:jte}=$(),Bte=pn(),KA=class extends Bte{#e=1024*1024;#o=!1;#a=0;#i=null;aborted=!1;reason=!1;constructor({maxSize:e,signal:t},a){if(e!=null&&(!Number.isFinite(e)||e<1))throw new Cte("maxSize must be a number greater than 0");super(a),this.#e=e??this.#e}#r(e){this.aborted=!0,this.reason=e}onRequestStart(e,t){return e.abort=this.#r.bind(this),this.#i=e,super.onRequestStart(e,t)}onResponseStart(e,t,a,i){let r=a["content-length"];if(r!=null&&r>this.#e)throw new jte(`Response size (${r}) larger than maxSize (${this.#e})`);return this.aborted===!0?!0:super.onResponseStart(e,t,a,i)}onResponseError(e,t){this.#o||(t=this.#i?.reason??t,super.onResponseError(e,t))}onResponseData(e,t){return this.#a=this.#a+t.length,this.#a>=this.#e&&(this.#o=!0,this.aborted===!0?super.onResponseError(e,this.reason):super.onResponseEnd(e,{})),!0}onResponseEnd(e,t){if(!this.#o){if(this.#i.aborted===!0){super.onResponseError(e,this.reason);return}super.onResponseEnd(e,t)}}};function Qte({maxSize:o}={maxSize:1024*1024}){return e=>function(a,i){let{dumpMaxSize:r=o}=a,s=new KA({maxSize:r,signal:a.signal},i);return e(a,s)}}z4.exports=Qte});var j4=y((Qpe,C4)=>{"use strict";var{isIP:Ste}=require("net"),{lookup:Dte}=require("dns"),Tte=pn(),{InvalidArgumentError:Yr,InformationalError:Rte}=$(),ZA=Math.pow(2,31)-1;function Nte(o){let e=Object.getPrototypeOf(o);return Object.prototype.hasOwnProperty.call(o,Symbol.iterator)||e!=null&&e!==Object.prototype&&typeof o[Symbol.iterator]=="function"}function E4(o){return typeof o=="string"&&o.toLowerCase()==="host"}function Ute(o){if(o==null)return null;if(Array.isArray(o)){if(o.length===0||!Array.isArray(o[0]))return o;let e=[];for(let t of o)Array.isArray(t)&&t.length===2?e.push(t[0],t[1]):e.push(t);return e}if(typeof o=="object"&&Nte(o)){let e=[];for(let t of o)Array.isArray(t)&&t.length===2?e.push(t[0],t[1]):e.push(t);return e}return o}function Ote(o){if(o==null)return!1;if(Array.isArray(o)){if(o.length===0)return!1;for(let e=0;e<o.length;e+=2)if(E4(o[e]))return!0;return!1}if(typeof o=="object"){for(let e in o)if(E4(e))return!0}return!1}function I4(o,e){let t=Ute(e);return Ote(t)?t:Array.isArray(t)?["host",o,...t]:t&&typeof t=="object"?{host:o,...t}:{host:o}}var XA=class{#e=0;#o=new Map;constructor(e){this.#e=e.maxItems}get size(){return this.#o.size}get(e){return this.#o.get(e)??null}set(e,t){this.#o.set(e,t)}delete(e){this.#o.delete(e)}full(){return this.size>=this.#e}},ew=class{#e=0;#o=0;dualStack=!0;affinity=null;lookup=null;pick=null;storage=null;constructor(e){this.#e=e.maxTTL,this.#o=e.maxItems,this.dualStack=e.dualStack,this.affinity=e.affinity,this.lookup=e.lookup??this.#a,this.pick=e.pick??this.#i,this.storage=e.storage??new XA(e)}runLookup(e,t,a){let i=this.storage.get(e.hostname);if(i==null&&this.storage.full()){a(null,e);return}let r={affinity:this.affinity,dualStack:this.dualStack,lookup:this.lookup,pick:this.pick,...t.dns,maxTTL:this.#e,maxItems:this.#o};if(i==null)this.lookup(e,r,(s,n)=>{if(s||n==null||n.length===0){a(s??new Rte("No DNS entries found"));return}this.setRecords(e,n);let c=this.storage.get(e.hostname),m=this.pick(e,c,r.affinity),l;typeof m.port=="number"?l=`:${m.port}`:e.port!==""?l=`:${e.port}`:l="",a(null,new URL(`${e.protocol}//${m.family===6?`[${m.address}]`:m.address}${l}`))});else{let s=this.pick(e,i,r.affinity);if(s==null){this.storage.delete(e.hostname),this.runLookup(e,t,a);return}let n;typeof s.port=="number"?n=`:${s.port}`:e.port!==""?n=`:${e.port}`:n="",a(null,new URL(`${e.protocol}//${s.family===6?`[${s.address}]`:s.address}${n}`))}}#a(e,t,a){Dte(e.hostname,{all:!0,family:this.dualStack===!1?this.affinity:0,order:"ipv4first"},(i,r)=>{if(i)return a(i);let s=new Map;for(let n of r)s.set(`${n.address}:${n.family}`,n);a(null,s.values())})}#i(e,t,a){let i=null,{records:r,offset:s}=t,n;if(this.dualStack?(a==null&&(s==null||s===ZA?(t.offset=0,a=4):(t.offset++,a=(t.offset&1)===1?6:4)),r[a]!=null&&r[a].ips.length>0?n=r[a]:n=r[a===4?6:4]):n=r[a],n==null||n.ips.length===0)return i;n.offset==null||n.offset===ZA?n.offset=0:n.offset++;let c=n.offset%n.ips.length;return i=n.ips[c]??null,i==null?i:Date.now()-i.timestamp>i.ttl?(n.ips.splice(c,1),this.pick(e,t,a)):i}pickFamily(e,t){let a=this.storage.get(e.hostname)?.records;if(!a)return null;let i=a[t];if(!i)return null;i.offset==null||i.offset===ZA?i.offset=0:i.offset++;let r=i.offset%i.ips.length,s=i.ips[r]??null;return s==null||Date.now()-s.timestamp>s.ttl&&i.ips.splice(r,1),s}setRecords(e,t){let a=Date.now(),i={records:{4:null,6:null}},r=this.#e;for(let s of t){s.timestamp=a,typeof s.ttl=="number"?(s.ttl=Math.min(s.ttl,this.#e),r=Math.min(r,s.ttl)):s.ttl=this.#e;let n=i.records[s.family]??{ips:[]};n.ips.push(s),i.records[s.family]=n}this.storage.set(e.hostname,i,{ttl:r})}deleteRecords(e){this.storage.delete(e.hostname)}getHandler(e,t){return new ow(this,e,t)}},ow=class extends Tte{#e=null;#o=null;#a=null;#i=null;#r=null;#t=null;#c=!0;constructor(e,{origin:t,handler:a,dispatch:i,newOrigin:r},s){super(a),this.#i=t,this.#t=r,this.#o={...s},this.#e=e,this.#a=i}onResponseError(e,t){switch(t.code){case"ETIMEDOUT":case"ECONNREFUSED":{if(this.#e.dualStack){if(!this.#c){super.onResponseError(e,t);return}this.#c=!1;let a=this.#t.hostname[0]==="["?4:6,i=this.#e.pickFamily(this.#i,a);if(i==null){super.onResponseError(e,t);return}let r;typeof i.port=="number"?r=`:${i.port}`:this.#i.port!==""?r=`:${this.#i.port}`:r="";let s={...this.#o,origin:`${this.#i.protocol}//${i.family===6?`[${i.address}]`:i.address}${r}`,headers:I4(this.#i.host,this.#o.headers)};this.#a(s,this);return}super.onResponseError(e,t);break}case"ENOTFOUND":this.#e.deleteRecords(this.#i),super.onResponseError(e,t);break;default:super.onResponseError(e,t);break}}};C4.exports=o=>{if(o?.maxTTL!=null&&(typeof o?.maxTTL!="number"||o?.maxTTL<0))throw new Yr("Invalid maxTTL. Must be a positive number");if(o?.maxItems!=null&&(typeof o?.maxItems!="number"||o?.maxItems<1))throw new Yr("Invalid maxItems. Must be a positive number and greater than zero");if(o?.affinity!=null&&o?.affinity!==4&&o?.affinity!==6)throw new Yr("Invalid affinity. Must be either 4 or 6");if(o?.dualStack!=null&&typeof o?.dualStack!="boolean")throw new Yr("Invalid dualStack. Must be a boolean");if(o?.lookup!=null&&typeof o?.lookup!="function")throw new Yr("Invalid lookup. Must be a function");if(o?.pick!=null&&typeof o?.pick!="function")throw new Yr("Invalid pick. Must be a function");if(o?.storage!=null&&(typeof o?.storage?.get!="function"||typeof o?.storage?.set!="function"||typeof o?.storage?.full!="function"||typeof o?.storage?.delete!="function"))throw new Yr("Invalid storage. Must be a object with methods: { get, set, full, delete }");let e=o?.dualStack??!0,t;e?t=o?.affinity??null:t=o?.affinity??4;let a={maxTTL:o?.maxTTL??1e4,lookup:o?.lookup??null,pick:o?.pick??null,dualStack:e,affinity:t,maxItems:o?.maxItems??1/0,storage:o?.storage},i=new ew(a);return r=>function(n,c){let m=n.origin.constructor===URL?n.origin:new URL(n.origin);return Ste(m.hostname)!==0?r(n,c):(i.runLookup(m,n,(l,u)=>{if(l)return c.onResponseError(null,l);let d={...n,servername:m.hostname,origin:u.origin,headers:I4(m.host,n.headers)};r(d,i.getHandler({origin:m,dispatch:r,handler:c,newOrigin:u},n))}),!0)}}});var hn=y((Spe,_4)=>{"use strict";var{safeHTTPMethods:B4,pathHasQueryOrFragment:Mte,hasSafeIterator:_te,isValidHTTPToken:Nm}=K(),{serializePathWithQuery:Lte}=K(),Fte=2147483647,Q4=["no-store","private","no-cache"],tw=Symbol("invalid cache-control directives");function Vr(o){return o.replace(/^[\t ]+|[\t ]+$/g,"")}function U4(o,e){for(let t=0;t<o.length;t++)if(o[t]===e)return!0;return!1}function S4(o){return o.replace(/^[\t ]+/,"")}function D4(o){return o.replace(/[\t ]+$/,"")}function T4(o,e){let t=!1;for(let a=e;a<o.length;a++)if(t)t=!1;else if(o[a]==="\\")t=!0;else if(o[a]==='"')return a;return-1}function Pte(o){let e=[],t=0,a=-1,i=!1,r=!1;for(let m=0;m<o.length;m++)i?r?r=!1:o[m]==="\\"?r=!0:o[m]==='"'&&(i=!1,a=-1):o[m]==='"'?(i=!0,a=m):o[m]===","&&(e.push({value:o.substring(t,m),fromMalformedQuote:!1}),t=m+1);if(!i)return e.push({value:o.substring(t),fromMalformedQuote:!1}),e;let s=o.substring(t),n=a-t,c=0;for(let m=0;m<s.length;m++)s[m]===","&&(e.push({value:s.substring(c,m),fromMalformedQuote:c>n}),c=m+1);return e.push({value:s.substring(c),fromMalformedQuote:c>n}),e}function R4(o,e){let t=o[tw];t===void 0&&(t=new Set,Object.defineProperty(o,tw,{value:t})),t.add(e)}function Hte(o,e){return o[tw]?.has(e)===!0}function Gte(o){for(let a of Q4)if(o.startsWith(a)&&o.length>a.length&&!Nm(o[a.length]))return a;let e="",t=!1;for(let a=0;a<o.length;a++)Nm(o[a])?e+=o[a]:t=!0;if(t&&U4(Q4,e))return e}function Yte(o){if(!o.origin)throw new Error("opts.origin is undefined");let e=o.path||"/";return o.query&&!Mte(e)&&(e=Lte(e,o.query)),{origin:o.origin.toString(),method:o.method,path:e,headers:o.headers}}function N4(o,e,t){let a=e.toLowerCase(),i=o[a],r=Array.isArray(t)?t:[t];i===void 0?o[a]=Array.isArray(t)?t.slice():t:Array.isArray(i)?i.push(...r):o[a]=[i,...r]}function Vte(o){let e;if(o.headers==null)e={};else if(typeof o.headers=="object")if(e={},_te(o.headers))for(let t of o.headers){if(!Array.isArray(t))throw new Error("opts.headers is not a valid header map");let[a,i]=t;if(typeof a!="string"||typeof i!="string")throw new Error("opts.headers is not a valid header map");N4(e,a,i)}else for(let t of Object.keys(o.headers))N4(e,t,o.headers[t]);else throw new Error("opts.headers is not an object");return e}function $te(o){if(typeof o!="object")throw new TypeError(`expected key to be object, got ${typeof o}`);for(let e of["origin","method","path"])if(typeof o[e]!="string")throw new TypeError(`expected key.${e} to be string, got ${typeof o[e]}`);if(o.headers!==void 0&&typeof o.headers!="object")throw new TypeError(`expected headers to be object, got ${typeof o}`)}function Wte(o){if(typeof o!="object")throw new TypeError(`expected value to be object, got ${typeof o}`);for(let e of["statusCode","cachedAt","staleAt","deleteAt"])if(typeof o[e]!="number")throw new TypeError(`expected value.${e} to be number, got ${typeof o[e]}`);if(typeof o.statusMessage!="string")throw new TypeError(`expected value.statusMessage to be string, got ${typeof o.statusMessage}`);if(o.headers!=null&&typeof o.headers!="object")throw new TypeError(`expected value.rawHeaders to be object, got ${typeof o.headers}`);if(o.vary!==void 0&&typeof o.vary!="object")throw new TypeError(`expected value.vary to be object, got ${typeof o.vary}`);if(o.etag!==void 0&&typeof o.etag!="string")throw new TypeError(`expected value.etag to be string, got ${typeof o.etag}`)}function Jte(o){let e={},t=new Set,a=new Set,i=Pte(Array.isArray(o)?o.join(","):o);for(let r=0;r<i.length;r++){let s=i[r],n=s.value.toLowerCase(),c=s.fromMalformedQuote,m=n.indexOf("="),l,u,d=!1,g=!1;if(m!==-1){let b=n.substring(0,m),A=n.substring(m+1);d=D4(b)!==b,g=S4(A)!==A,l=Vr(b),u=S4(A)}else l=Vr(n);let p=Gte(l);if(p!==void 0){e[p]=!0;continue}switch(l){case"min-fresh":case"max-stale":case"max-age":case"s-maxage":case"stale-while-revalidate":case"stale-if-error":{if(c||t.has(l))continue;if(u===void 0||d||g){delete e[l],t.add(l),R4(e,l);continue}if(u.length>=2&&u[0]==='"'&&u[u.length-1]==='"'&&(u=u.substring(1,u.length-1)),!/^[0-9]+$/.test(u)){delete e[l],t.add(l),R4(e,l);continue}let b=Math.min(parseInt(u,10),Fte);l==="min-fresh"?(!(l in e)||e[l]<b)&&(e[l]=b):(!(l in e)||e[l]>b)&&(e[l]=b);break}case"private":case"no-cache":{if(c){e[l]=!0;break}if(u!==void 0&&u.length===0){e[l]=!0;break}if(u){if(u[0]==='"'){u=D4(u);let b="",A=r,k=!1,x=T4(u,1);if(x!==-1)b=u.substring(1,x),k=!0;else{let I=[u.substring(1)];for(let T=r+1;T<i.length;T++){let D=Vr(i[T].value),O=T4(D,0);if(A=T,O!==-1){I.push(D.substring(0,O)),k=!0;break}I.push(D)}b=I.join(",")}if(!k){e[l]=!0;break}r=A;let v=b.split(","),j=!0;for(let I=0;I<v.length;I++)v[I]=Vr(v[I]),Nm(v[I])||(j=!1);j?e[l]!==!0&&(l in e?e[l]=e[l].concat(v):e[l]=v):e[l]=!0}else{let b=Vr(u);Nm(b)?e[l]!==!0&&(l in e?e[l]=e[l].concat(b):e[l]=[b]):e[l]=!0}break}}case"public":case"must-revalidate":case"proxy-revalidate":case"immutable":case"no-transform":case"must-understand":case"only-if-cached":if(c||a.has(l))continue;if(u!==void 0){delete e[l],a.add(l);continue}e[l]=!0;break;case"no-store":e[l]=!0;break;default:continue}}return e}function O4(o){let e=Array.isArray(o)?o:[o],t=[];for(let a=0;a<e.length;a++){let i=e[a].split(",");for(let r=0;r<i.length;r++)t.push(i[r])}return t}function aw(o){let e=O4(o);for(let t=0;t<e.length;t++)if(Vr(e[t]).indexOf("*")!==-1)return!0;return!1}function M4(o,e){if(aw(o))return e;let t={},a=O4(o);for(let i of a){let r=Vr(i).toLowerCase();if(r.length===0)continue;if(!Nm(r))return;let s=e[r];t[r]=Array.isArray(s)?s.slice():s??null}return t}function Kte(o){return aw(o)||M4(o,{})===void 0}function Zte(o){return o.length<=2?!1:o[0]==='"'&&o[o.length-1]==='"'?!(o[1]==='"'||o.startsWith('"W/')):o.startsWith('W/"')&&o[o.length-1]==='"'?o.length!==4:!1}function Xte(o,e="CacheStore"){if(typeof o!="object"||o===null)throw new TypeError(`expected type of ${e} to be a CacheStore, got ${o===null?"null":typeof o}`);for(let t of["get","createWriteStream","delete"])if(typeof o[t]!="function")throw new TypeError(`${e} needs to have a \`${t}()\` function`)}function eae(o,e="CacheMethods"){if(!Array.isArray(o))throw new TypeError(`expected type of ${e} needs to be an array, got ${o===null?"null":typeof o}`);if(o.length===0)throw new TypeError(`${e} needs to have at least one method`);for(let t of o)if(!U4(B4,t))throw new TypeError(`element of ${e}-array needs to be one of following values: ${B4.join(", ")}, got ${t}`)}function oae(o,e){let t={};if(o.headers){let a=Object.keys(o.headers).sort();for(let i of a)e?.has(i.toLowerCase())||(t[i]=o.headers[i])}return JSON.stringify([o.origin,o.method,o.path,t])}_4.exports={makeCacheKey:Yte,normalizeHeaders:Vte,assertCacheKey:$te,assertCacheValue:Wte,parseCacheControlHeader:Jte,hasInvalidCacheControlDirective:Hte,parseVaryHeader:M4,hasVaryStar:aw,isInvalidOrWildcardVaryHeader:Kte,isEtagUsable:Zte,assertCacheMethods:eae,assertCacheStore:Xte,makeDeduplicationKey:oae}});var rw=y((Dpe,L4)=>{"use strict";function tae(o){switch(o[3]){case",":return aae(o);case" ":return iae(o);default:return rae(o)}}function iw(o,e,t,a,i,r,s){let n=new Date(Date.UTC(o,e,t,a,i,r));return o>=0&&o<=99&&n.setUTCFullYear(o),n.getUTCFullYear()===o&&n.getUTCMonth()===e&&n.getUTCDate()===t&&n.getUTCHours()===a&&n.getUTCMinutes()===i&&n.getUTCSeconds()===r&&n.getUTCDay()===s?n:void 0}function aae(o){if(o.length!==29||o[4]!==" "||o[7]!==" "||o[11]!==" "||o[16]!==" "||o[19]!==":"||o[22]!==":"||o[25]!==" "||o[26]!=="G"||o[27]!=="M"||o[28]!=="T")return;let e=-1;if(o[0]==="S"&&o[1]==="u"&&o[2]==="n")e=0;else if(o[0]==="M"&&o[1]==="o"&&o[2]==="n")e=1;else if(o[0]==="T"&&o[1]==="u"&&o[2]==="e")e=2;else if(o[0]==="W"&&o[1]==="e"&&o[2]==="d")e=3;else if(o[0]==="T"&&o[1]==="h"&&o[2]==="u")e=4;else if(o[0]==="F"&&o[1]==="r"&&o[2]==="i")e=5;else if(o[0]==="S"&&o[1]==="a"&&o[2]==="t")e=6;else return;let t=0;if(o[5]==="0"){let d=o.charCodeAt(6);if(d<49||d>57)return;t=d-48}else{let d=o.charCodeAt(5);if(d<49||d>51)return;let g=o.charCodeAt(6);if(g<48||g>57)return;t=(d-48)*10+(g-48)}let a=-1;if(o[8]==="J"&&o[9]==="a"&&o[10]==="n")a=0;else if(o[8]==="F"&&o[9]==="e"&&o[10]==="b")a=1;else if(o[8]==="M"&&o[9]==="a")if(o[10]==="r")a=2;else if(o[10]==="y")a=4;else return;else if(o[8]==="J")if(o[9]==="a"&&o[10]==="n")a=0;else if(o[9]==="u")if(o[10]==="n")a=5;else if(o[10]==="l")a=6;else return;else return;else if(o[8]==="A")if(o[9]==="p"&&o[10]==="r")a=3;else if(o[9]==="u"&&o[10]==="g")a=7;else return;else if(o[8]==="S"&&o[9]==="e"&&o[10]==="p")a=8;else if(o[8]==="O"&&o[9]==="c"&&o[10]==="t")a=9;else if(o[8]==="N"&&o[9]==="o"&&o[10]==="v")a=10;else if(o[8]==="D"&&o[9]==="e"&&o[10]==="c")a=11;else return;let i=o.charCodeAt(12);if(i<48||i>57)return;let r=o.charCodeAt(13);if(r<48||r>57)return;let s=o.charCodeAt(14);if(s<48||s>57)return;let n=o.charCodeAt(15);if(n<48||n>57)return;let c=(i-48)*1e3+(r-48)*100+(s-48)*10+(n-48),m=0;if(o[17]==="0"){let d=o.charCodeAt(18);if(d<48||d>57)return;m=d-48}else{let d=o.charCodeAt(17);if(d<48||d>50)return;let g=o.charCodeAt(18);if(g<48||g>57||d===50&&g>51)return;m=(d-48)*10+(g-48)}let l=0;if(o[20]==="0"){let d=o.charCodeAt(21);if(d<48||d>57)return;l=d-48}else{let d=o.charCodeAt(20);if(d<48||d>53)return;let g=o.charCodeAt(21);if(g<48||g>57)return;l=(d-48)*10+(g-48)}let u=0;if(o[23]==="0"){let d=o.charCodeAt(24);if(d<48||d>57)return;u=d-48}else{let d=o.charCodeAt(23);if(d<48||d>53)return;let g=o.charCodeAt(24);if(g<48||g>57)return;u=(d-48)*10+(g-48)}return iw(c,a,t,m,l,u,e)}function iae(o){if(o.length!==24||o[7]!==" "||o[10]!==" "||o[19]!==" ")return;let e=-1;if(o[0]==="S"&&o[1]==="u"&&o[2]==="n")e=0;else if(o[0]==="M"&&o[1]==="o"&&o[2]==="n")e=1;else if(o[0]==="T"&&o[1]==="u"&&o[2]==="e")e=2;else if(o[0]==="W"&&o[1]==="e"&&o[2]==="d")e=3;else if(o[0]==="T"&&o[1]==="h"&&o[2]==="u")e=4;else if(o[0]==="F"&&o[1]==="r"&&o[2]==="i")e=5;else if(o[0]==="S"&&o[1]==="a"&&o[2]==="t")e=6;else return;let t=-1;if(o[4]==="J"&&o[5]==="a"&&o[6]==="n")t=0;else if(o[4]==="F"&&o[5]==="e"&&o[6]==="b")t=1;else if(o[4]==="M"&&o[5]==="a")if(o[6]==="r")t=2;else if(o[6]==="y")t=4;else return;else if(o[4]==="J")if(o[5]==="a"&&o[6]==="n")t=0;else if(o[5]==="u")if(o[6]==="n")t=5;else if(o[6]==="l")t=6;else return;else return;else if(o[4]==="A")if(o[5]==="p"&&o[6]==="r")t=3;else if(o[5]==="u"&&o[6]==="g")t=7;else return;else if(o[4]==="S"&&o[5]==="e"&&o[6]==="p")t=8;else if(o[4]==="O"&&o[5]==="c"&&o[6]==="t")t=9;else if(o[4]==="N"&&o[5]==="o"&&o[6]==="v")t=10;else if(o[4]==="D"&&o[5]==="e"&&o[6]==="c")t=11;else return;let a=0;if(o[8]===" "){let d=o.charCodeAt(9);if(d<49||d>57)return;a=d-48}else{let d=o.charCodeAt(8);if(d<49||d>51)return;let g=o.charCodeAt(9);if(g<48||g>57)return;a=(d-48)*10+(g-48)}let i=0;if(o[11]==="0"){let d=o.charCodeAt(12);if(d<48||d>57)return;i=d-48}else{let d=o.charCodeAt(11);if(d<48||d>50)return;let g=o.charCodeAt(12);if(g<48||g>57||d===50&&g>51)return;i=(d-48)*10+(g-48)}let r=0;if(o[14]==="0"){let d=o.charCodeAt(15);if(d<48||d>57)return;r=d-48}else{let d=o.charCodeAt(14);if(d<48||d>53)return;let g=o.charCodeAt(15);if(g<48||g>57)return;r=(d-48)*10+(g-48)}let s=0;if(o[17]==="0"){let d=o.charCodeAt(18);if(d<48||d>57)return;s=d-48}else{let d=o.charCodeAt(17);if(d<48||d>53)return;let g=o.charCodeAt(18);if(g<48||g>57)return;s=(d-48)*10+(g-48)}let n=o.charCodeAt(20);if(n<48||n>57)return;let c=o.charCodeAt(21);if(c<48||c>57)return;let m=o.charCodeAt(22);if(m<48||m>57)return;let l=o.charCodeAt(23);if(l<48||l>57)return;let u=(n-48)*1e3+(c-48)*100+(m-48)*10+(l-48);return iw(u,t,a,i,r,s,e)}function rae(o){let e=-1,t=-1;if(o[0]==="S")o[1]==="u"&&o[2]==="n"&&o[3]==="d"&&o[4]==="a"&&o[5]==="y"?(t=0,e=6):o[1]==="a"&&o[2]==="t"&&o[3]==="u"&&o[4]==="r"&&o[5]==="d"&&o[6]==="a"&&o[7]==="y"&&(t=6,e=8);else if(o[0]==="M"&&o[1]==="o"&&o[2]==="n"&&o[3]==="d"&&o[4]==="a"&&o[5]==="y")t=1,e=6;else if(o[0]==="T")o[1]==="u"&&o[2]==="e"&&o[3]==="s"&&o[4]==="d"&&o[5]==="a"&&o[6]==="y"?(t=2,e=7):o[1]==="h"&&o[2]==="u"&&o[3]==="r"&&o[4]==="s"&&o[5]==="d"&&o[6]==="a"&&o[7]==="y"&&(t=4,e=8);else if(o[0]==="W"&&o[1]==="e"&&o[2]==="d"&&o[3]==="n"&&o[4]==="e"&&o[5]==="s"&&o[6]==="d"&&o[7]==="a"&&o[8]==="y")t=3,e=9;else if(o[0]==="F"&&o[1]==="r"&&o[2]==="i"&&o[3]==="d"&&o[4]==="a"&&o[5]==="y")t=5,e=6;else return;if(o[e]!==","||o.length-e-1!==23||o[e+1]!==" "||o[e+4]!=="-"||o[e+8]!=="-"||o[e+11]!==" "||o[e+14]!==":"||o[e+17]!==":"||o[e+20]!==" "||o[e+21]!=="G"||o[e+22]!=="M"||o[e+23]!=="T")return;let a=0;if(o[e+2]==="0"){let u=o.charCodeAt(e+3);if(u<49||u>57)return;a=u-48}else{let u=o.charCodeAt(e+2);if(u<49||u>51)return;let d=o.charCodeAt(e+3);if(d<48||d>57)return;a=(u-48)*10+(d-48)}let i=-1;if(o[e+5]==="J"&&o[e+6]==="a"&&o[e+7]==="n")i=0;else if(o[e+5]==="F"&&o[e+6]==="e"&&o[e+7]==="b")i=1;else if(o[e+5]==="M"&&o[e+6]==="a"&&o[e+7]==="r")i=2;else if(o[e+5]==="A"&&o[e+6]==="p"&&o[e+7]==="r")i=3;else if(o[e+5]==="M"&&o[e+6]==="a"&&o[e+7]==="y")i=4;else if(o[e+5]==="J"&&o[e+6]==="u"&&o[e+7]==="n")i=5;else if(o[e+5]==="J"&&o[e+6]==="u"&&o[e+7]==="l")i=6;else if(o[e+5]==="A"&&o[e+6]==="u"&&o[e+7]==="g")i=7;else if(o[e+5]==="S"&&o[e+6]==="e"&&o[e+7]==="p")i=8;else if(o[e+5]==="O"&&o[e+6]==="c"&&o[e+7]==="t")i=9;else if(o[e+5]==="N"&&o[e+6]==="o"&&o[e+7]==="v")i=10;else if(o[e+5]==="D"&&o[e+6]==="e"&&o[e+7]==="c")i=11;else return;let r=o.charCodeAt(e+9);if(r<48||r>57)return;let s=o.charCodeAt(e+10);if(s<48||s>57)return;let n=(r-48)*10+(s-48);n+=n<70?2e3:1900;let c=0;if(o[e+12]==="0"){let u=o.charCodeAt(e+13);if(u<48||u>57)return;c=u-48}else{let u=o.charCodeAt(e+12);if(u<48||u>50)return;let d=o.charCodeAt(e+13);if(d<48||d>57||u===50&&d>51)return;c=(u-48)*10+(d-48)}let m=0;if(o[e+15]==="0"){let u=o.charCodeAt(e+16);if(u<48||u>57)return;m=u-48}else{let u=o.charCodeAt(e+15);if(u<48||u>53)return;let d=o.charCodeAt(e+16);if(d<48||d>57)return;m=(u-48)*10+(d-48)}let l=0;if(o[e+18]==="0"){let u=o.charCodeAt(e+19);if(u<48||u>57)return;l=u-48}else{let u=o.charCodeAt(e+18);if(u<48||u>53)return;let d=o.charCodeAt(e+19);if(d<48||d>57)return;l=(u-48)*10+(d-48)}return iw(n,i,a,c,m,l,t)}L4.exports={parseHttpDate:tae}});var $4=y((Tpe,V4)=>{"use strict";var sw=K(),{parseCacheControlHeader:sae,hasInvalidCacheControlDirective:F4,parseVaryHeader:nae,hasVaryStar:cae,isInvalidOrWildcardVaryHeader:H4,isEtagUsable:mae}=hn(),{parseHttpDate:nw}=rw();function lae(){}var G4=[200,203,204,206,300,301,308,404,405,410,414,501],uae=[206],Um=2147483647e3;function dae(o){return o.replace(/^[\t ]+|[\t ]+$/g,"")}function fn(o,e){for(let t=0;t<o.length;t++)if(o[t]===e)return!0;return!1}function gae(o,e){let t=Array.isArray(e)?e:[e];for(let a=0;a<t.length;a++){let i=t[a].split(",");for(let r=0;r<i.length;r++)o.push(dae(i[r]).toLowerCase())}}function pae(o,e){if(typeof e!="string")return;let t,a,i;try{t=new URL(o.origin),a=new URL(o.path,t),i=new URL(e,a)}catch{return}if(i.origin===t.origin)return i.pathname+i.search}function Y4(o,e,t){Om(o,{...e,path:t});for(let a=0;a<sw.safeHTTPMethods.length;a++){let i=sw.safeHTTPMethods[a];i!==e.method&&Om(o,{...e,method:i,path:t})}}function P4(o,e,t){if(t===void 0)return;let a=Array.isArray(t)?t:[t];for(let i=0;i<a.length;i++){let r=pae(e,a[i]);r!==void 0&&Y4(o,e,r)}}function hae(o,e,t){Y4(o,e,e.path),P4(o,e,t.location),P4(o,e,t["content-location"])}var cw=class{#e;#o;#a;#i;#r;#t;constructor({store:e,type:t,cacheByDefault:a},i,r){this.#i=e,this.#o=t,this.#a=a,this.#e=i,this.#r=r}onRequestStart(e,t){this.#t?.destroy(),this.#t=void 0,this.#r.onRequestStart?.(e,t)}onRequestUpgrade(e,t,a,i){this.#r.onRequestUpgrade?.(e,t,a,i)}onResponseStart(e,t,a,i){let r=()=>this.#r.onResponseStart?.(e,t,a,i),s=this;if(!fn(sw.safeHTTPMethods,this.#e.method)&&t>=200&&t<=399)return hae(this.#i,this.#e,a),r();let n=a["cache-control"],c=a["last-modified"]&&fn(G4,t);if(!n&&!a.expires&&!c&&!this.#a)return t===304&&a.vary&&H4(a.vary)&&Om(this.#i,this.#e),r();let m=n?sae(n):{};if(!bae(this.#o,t,a,m,this.#e.headers))return t===304&&(n||fae(this.#o,a,m))&&Om(this.#i,this.#e),r();let l=Date.now(),u=Object.hasOwn(a,"age")?kae(a.age):void 0;if(u!==void 0&&u>=Um)return rg(t,this.#i,this.#e),r();let d=Object.hasOwn(a,"date")?yae(a.date):void 0;if(d===null)return rg(t,this.#i,this.#e),r();let g=d?Math.max(0,l-d.getTime()):0,p=Math.max(g,u??0),b=Aae(this.#o,l,u,a,d,m)??this.#a;if(b===void 0||p>=b)return(n||b!==void 0)&&rg(t,this.#i,this.#e),r();let A=l-p,k=b+A;if(l>=k)return rg(t,this.#i,this.#e),r();let x;if(this.#e.headers&&a.vary&&(x=nae(a.vary,this.#e.headers),!x))return r();let v=A,j=wae(A,l,m,k),I=vae(a,m),T={statusCode:t,statusMessage:i,headers:I,vary:x,cacheControlDirectives:m,cachedAt:v,staleAt:k,deleteAt:j};if(t===304){let D=S=>{if(!S)return r();if(T.statusCode=S.statusCode,T.statusMessage=S.statusMessage,T.etag=S.etag,T.vary=x??S.vary,T.headers={...S.headers,...I},r(),this.#t=this.#i.createWriteStream(this.#e,T),!(!this.#t||!S?.body))if(typeof S.body.values=="function"){let oe=S.body.values(),te=()=>{for(let ye of oe){let po=this.#t.write(ye)===!1;if(this.#r.onResponseData?.(e,ye),po)break}};this.#t.on("error",function(){s.#t=void 0,s.#i.delete(s.#e)}).on("drain",()=>{te()}).on("close",function(){s.#t===this&&(s.#t=void 0)}),te()}else typeof S.body.on=="function"&&(S.body.on("data",oe=>{this.#t.write(oe),this.#r.onResponseData?.(e,oe)}).on("end",()=>{this.#t.end()}).on("error",()=>{this.#t=void 0,this.#i.delete(this.#e)}),this.#t.on("error",function(){s.#t=void 0,s.#i.delete(s.#e)}).on("close",function(){s.#t===this&&(s.#t=void 0)}))},O=this.#i.get(this.#e);O&&typeof O.then=="function"?O.then(D):D(O)}else{if(typeof a.etag=="string"&&mae(a.etag)&&(T.etag=a.etag),this.#t=this.#i.createWriteStream(this.#e,T),!this.#t)return r();this.#t.on("drain",()=>e.resume()).on("error",function(){s.#t=void 0,s.#i.delete(s.#e)}).on("close",function(){s.#t===this&&(s.#t=void 0),e.resume()}),r()}}onResponseData(e,t){this.#t?.write(t)===!1&&e.pause(),this.#r.onResponseData?.(e,t)}onResponseEnd(e,t){this.#t?.end(),this.#r.onResponseEnd?.(e,t)}onResponseError(e,t){this.#t?.destroy(t),this.#t=void 0,this.#r.onResponseError?.(e,t)}};function Om(o,e){try{o.delete(e)?.catch?.(lae)}catch{}}function rg(o,e,t){o===304&&Om(e,t)}function fae(o,e,t){return t["no-store"]===!0||o==="shared"&&t.private===!0||(e.vary?H4(e.vary):!1)}function bae(o,e,t,a,i){return!(e<200||fn(uae,e)||!fn(G4,e)&&!t.expires&&!a.public&&a["max-age"]===void 0&&!(a.private&&o==="private")&&!(a["s-maxage"]!==void 0&&o==="shared")||a["no-store"]||o==="shared"&&a.private===!0||t.vary&&cae(t.vary)||i!=null&&Object.hasOwn(i,"authorization")&&(!a.public&&!a["s-maxage"]&&!a["must-revalidate"]||typeof i.authorization!="string"||Array.isArray(a["no-cache"])&&fn(a["no-cache"],"authorization")||Array.isArray(a.private)&&fn(a.private,"authorization")))}function yae(o){let e=o;if(Array.isArray(e)){if(e.length!==1)return null;e=e[0]}return typeof e!="string"?null:nw(e)}function kae(o){let e=o;if(Array.isArray(e)){if(e.length!==1)return Um;e=e[0]}if(typeof e!="string"||!/^[\t ]*[0-9]+[\t ]*$/.test(e))return Um;let t=BigInt(e.replace(/^[\t ]+|[\t ]+$/g,""));return t>=BigInt(Um/1e3)?Um:Number(t)*1e3}function Aae(o,e,t,a,i,r){if(o==="shared"){if(F4(r,"s-maxage"))return 0;let n=r["s-maxage"];if(n!==void 0)return n*1e3}if(F4(r,"max-age"))return 0;let s=r["max-age"];if(s!==void 0)return s*1e3;if(Object.hasOwn(a,"expires")){if(typeof a.expires!="string")return 0;let n=nw(a.expires);if(!n||e>=n.getTime())return 0;if(i){if(i>=n)return 0;let c=n.getTime()-i.getTime();return t!==void 0&&t>=c?0:c}return n.getTime()-e}if(typeof a["last-modified"]=="string"){let n=nw(a["last-modified"]);if(n)return n.getTime()>=e?void 0:(e-n.getTime())*.1}if(r.immutable)return 31536e6}function wae(o,e,t,a){let i=-1/0,r=-1/0,s=-1/0;if(t["stale-while-revalidate"]&&(i=a+t["stale-while-revalidate"]*1e3),t["stale-if-error"]&&(r=a+t["stale-if-error"]*1e3),t.immutable&&i===-1/0&&r===-1/0&&(s=e+31536e6),i===-1/0&&r===-1/0&&s===-1/0){let n=a-o,c=Math.min(Math.max(e-o,0),1e3);return a+n+c}return Math.max(a,i,r,s)}function vae(o,e){let t=["connection","proxy-authenticate","proxy-authentication-info","proxy-authorization","proxy-connection","te","transfer-encoding","upgrade","age"];o.connection&&gae(t,o.connection),Array.isArray(e["no-cache"])&&t.push(...e["no-cache"]),Array.isArray(e.private)&&t.push(...e.private);let a;for(let i of t)Object.hasOwn(o,i)&&(a??={...o},delete a[i]);return a??o}V4.exports=cw});var lw=y((Rpe,K4)=>{"use strict";var{Writable:xae}=require("stream"),{EventEmitter:zae}=require("events"),{assertCacheKey:W4,assertCacheValue:qae}=hn(),mw=class extends zae{#e=1024;#o=104857600;#a=5242880;#i=0;#r=0;#t=new Map;#c=!1;constructor(e){if(super(),e){if(typeof e!="object")throw new TypeError("MemoryCacheStore options must be an object");if(e.maxCount!==void 0){if(typeof e.maxCount!="number"||!Number.isInteger(e.maxCount)||e.maxCount<0)throw new TypeError("MemoryCacheStore options.maxCount must be a non-negative integer");this.#e=e.maxCount}if(e.maxSize!==void 0){if(typeof e.maxSize!="number"||!Number.isInteger(e.maxSize)||e.maxSize<0)throw new TypeError("MemoryCacheStore options.maxSize must be a non-negative integer");this.#o=e.maxSize}if(e.maxEntrySize!==void 0){if(typeof e.maxEntrySize!="number"||!Number.isInteger(e.maxEntrySize)||e.maxEntrySize<0)throw new TypeError("MemoryCacheStore options.maxEntrySize must be a non-negative integer");this.#a=e.maxEntrySize}}}get size(){return this.#i}isFull(){return this.#i>=this.#o||this.#r>=this.#e}get(e){W4(e);let t=`${e.origin}:${e.path}`,a=Date.now(),i=this.#t.get(t),r=i?J4(e,i,a):null;return r==null?void 0:{statusMessage:r.statusMessage,statusCode:r.statusCode,headers:r.headers,body:r.body,vary:r.vary?r.vary:void 0,etag:r.etag,cacheControlDirectives:r.cacheControlDirectives,cachedAt:r.cachedAt,staleAt:r.staleAt,deleteAt:r.deleteAt}}createWriteStream(e,t){W4(e),qae(t);let a=`${e.origin}:${e.path}`,i=this,r={...e,...t,body:[],size:0};return new xae({write(s,n,c){typeof s=="string"&&(s=Buffer.from(s,n)),r.size+=s.byteLength,r.size>=i.#a?this.destroy():r.body.push(s),c(null)},final(s){let n=i.#t.get(a);n||(n=[],i.#t.set(a,n));let c=J4(e,n,Date.now());if(c){let m=n.indexOf(c);n.splice(m,1,r),i.#i-=c.size}else n.push(r),i.#r+=1;if(i.#i+=r.size,i.#i>i.#o||i.#r>i.#e){i.#c||(i.emit("maxSizeExceeded",{size:i.#i,maxSize:i.#o,count:i.#r,maxCount:i.#e}),i.#c=!0);for(let[m,l]of i.#t){for(let u of l.splice(0,l.length/2))i.#i-=u.size,i.#r-=1;l.length===0&&i.#t.delete(m)}i.#i<i.#o&&i.#r<i.#e&&(i.#c=!1)}s(null)}})}delete(e){if(typeof e!="object")throw new TypeError(`expected key to be object, got ${typeof e}`);let t=`${e.origin}:${e.path}`;for(let a of this.#t.get(t)??[])this.#i-=a.size,this.#r-=1;this.#t.delete(t)}};function J4(o,e,t){for(let a=0;a<e.length;a++){let i=e[a];if(i.deleteAt>t&&i.method===o.method&&Eae(o,i))return i}}function Eae(o,e){if(e.vary==null)return!0;for(let t in e.vary)if(Object.hasOwn(e.vary,t)&&!Iae(o.headers?.[t],e.vary[t]))return!1;return!0}function Iae(o,e){if(o==null&&e==null)return!0;if(o==null&&e!=null||o!=null&&e==null)return!1;if(Array.isArray(o)&&Array.isArray(e)){if(o.length!==e.length)return!1;for(let t=0;t<o.length;t++)if(o[t]!==e[t])return!1;return!0}return o===e}K4.exports=mw});var X4=y((Npe,Z4)=>{"use strict";var Cae=require("assert"),uw=class{#e=!1;#o;#a;#i;#r;constructor(e,t,a){if(typeof e!="function")throw new TypeError("callback must be a function");this.#o=e,this.#a=t,this.#r=a}onRequestStart(e,t){this.#e=!1,this.#i=t}onRequestUpgrade(e,t,a,i){this.#a.onRequestUpgrade?.(e,t,a,i)}onResponseStart(e,t,a,i){if(Cae(this.#o!=null),this.#e=t===304||this.#r&&t>=500&&t<=504,this.#o(this.#e,this.#i,t,a),this.#o=null,this.#e)return!0;this.#a.onRequestStart?.(e,this.#i),this.#a.onResponseStart?.(e,t,a,i)}onResponseData(e,t){if(!this.#e)return this.#a.onResponseData?.(e,t)}onResponseEnd(e,t){this.#e||this.#a.onResponseEnd?.(e,t)}onResponseError(e,t){if(!this.#e)if(this.#o&&(this.#o(!1),this.#o=null),typeof this.#a.onResponseError=="function")this.#a.onResponseError(e,t);else throw t}};Z4.exports=uw});var n3=y((Upe,s3)=>{"use strict";var e3=require("assert"),{Readable:jae}=require("stream"),Ui=K(),bn=$4(),Bae=lw(),Qae=X4(),{assertCacheStore:Sae,assertCacheMethods:Dae,makeCacheKey:Tae,normalizeHeaders:Rae,parseCacheControlHeader:r3,isInvalidOrWildcardVaryHeader:Nae}=hn(),{AbortError:Uae}=$(),{parseHttpDate:Oae}=rw();function Mae(o,e){if(o!==void 0){if(!Array.isArray(o))throw new TypeError(`expected ${e} to be an array or undefined, got ${typeof o}`);for(let t=0;t<o.length;t++){let a=o[t];if(typeof a!="string"&&!(a instanceof RegExp))throw new TypeError(`expected ${e}[${t}] to be a string or RegExp, got ${typeof a}`)}}}var Mm=()=>{};function _ae(o){return o.replace(/^[\t ]+|[\t ]+$/g,"")}function o3(o,e){for(let t=0;t<o.length;t++)if(o[t]===e)return!0;return!1}function Lae(o){let e=o?.pragma;if(!e)return!1;let t=Array.isArray(e)?e:[e];for(let a=0;a<t.length;a++){let i=t[a];if(typeof i!="string")continue;let r=i.split(",");for(let s=0;s<r.length;s++)if(_ae(r[s]).toLowerCase()==="no-cache")return!0}return!1}function Fae(o,e,{headers:t={}}){return!!(e?.["no-cache"]||o.cacheControlDirectives?.["no-cache"]&&!Array.isArray(o.cacheControlDirectives["no-cache"])||t["if-modified-since"]||t["if-none-match"])}function gw(o,e){return o.cacheControlDirectives?.["must-revalidate"]===!0||e==="shared"&&(o.cacheControlDirectives?.["proxy-revalidate"]===!0||o.cacheControlDirectives?.["s-maxage"]!==void 0)}function Pae(o,e){if(e.vary&&Nae(e.vary))return!0;let t=e["cache-control"];if(!t)return!1;let a=r3(t);return a["no-store"]===!0||o==="shared"&&a.private===!0}function Hae(o){return o["cache-control"]!==void 0}function t3(o,e){try{o.delete(e)?.catch?.(Mm)}catch{}}function Gae(o){let e=o?.["last-modified"];if(typeof e=="string"&&Oae(e))return e}function a3(o,e){let t={...o.headers,"if-modified-since":Gae(e.headers)??new Date(e.cachedAt).toUTCString()};if(e.etag&&(t["if-none-match"]=e.etag),e.vary)for(let a in e.vary)e.vary[a]!=null&&(t[a]=e.vary[a]);return t}function Yae(o,e,t){let a=Date.now();if(a>o.staleAt){if(!gw(o,t)&&e?.["max-stale"]){let i=o.staleAt+e["max-stale"]*1e3;return a>i}return!0}if(e?.["min-fresh"]){let i=o.staleAt-a,r=e["min-fresh"]*1e3;return i<=r}return!1}function Vae(o,e){let t=o.cacheControlDirectives?.["stale-while-revalidate"];if(!t||gw(o,e))return!1;let a=Date.now(),i=o.staleAt+t*1e3;return a<=i}function $ae(o,e,t,a,i,r){if(r?.["only-if-cached"]){let s=!1;try{if(typeof a.onConnect=="function"&&(a.onConnect(()=>{s=!0}),s)||typeof a.onHeaders=="function"&&(a.onHeaders(504,[],Mm,"Gateway Timeout"),s))return;typeof a.onComplete=="function"&&a.onComplete([])}catch(n){typeof a.onError=="function"&&a.onError(n)}return!0}return o(i,new bn(e,t,a))}function dw(o,e,t,a,i,r){let s=Ui.isStream(t.body)?t.body:jae.from(t.body??[]);e3(!s.destroyed,"stream should not be destroyed"),e3(!s.readableDidRead,"stream should not be readableDidRead");let n={resume(){s.resume()},pause(){s.pause()},get paused(){return s.isPaused()},get aborted(){return s.destroyed},get reason(){return s.errored},abort(m){s.destroy(m??new Uae)}};if(s.on("error",function(m){if(!this.readableEnded)if(typeof o.onResponseError=="function")o.onResponseError(n,m);else throw m}).on("close",function(){this.errored||o.onResponseEnd?.(n,{})}),o.onRequestStart?.(n,i),s.destroyed)return;let c={...t.headers,age:String(a)};r&&(c.warning='110 - "response is stale"'),o.onResponseStart?.(n,t.statusCode,c,t.statusMessage),e.method==="HEAD"?s.destroy():s.on("data",function(m){o.onResponseData?.(n,m)})}function i3(o,e,t,a,i,r,s){if(!s)return $ae(o,e,t,a,i,r);let n=Date.now();if(n>s.deleteAt)return o(i,new bn(e,t,a));let c=Math.round((n-s.cachedAt)/1e3),m=r?.["max-age"]!==void 0&&c>=r["max-age"],l=m||Yae(s,r,e.type),u=m||Fae(s,r,i);if(l||u){if(Ui.isStream(i.body)&&Ui.bodyLength(i.body)!==0)return o(i,new bn(e,t,a));if(!u&&Vae(s,e.type))return dw(a,i,s,c,null,!0),queueMicrotask(()=>{let p=a3(i,s);o({...i,headers:p},new bn(e,t,{onRequestStart(){},onRequestUpgrade(){},onResponseStart(){},onResponseData(){},onResponseEnd(){},onResponseError(){}}))}),!0;let d=!1;if(!gw(s,e.type)){let p=s.cacheControlDirectives["stale-if-error"]??r?.["stale-if-error"];p&&(d=n<s.staleAt+p*1e3)}let g=a3(i,s);return o({...i,headers:g},new Qae((p,b,A,k)=>{if(p){if(A===304){if(Pae(e.type,k))return Ui.isStream(s.body)&&s.body.on("error",Mm).destroy(),t3(e.store,t),o(i,new bn(e,t,a));Hae(k)&&t3(e.store,t)}dw(a,i,s,c,b,l)}else Ui.isStream(s.body)&&s.body.on("error",Mm).destroy()},new bn(e,t,a),d))}Ui.isStream(i.body)&&i.body.on("error",Mm).destroy(),dw(a,i,s,c,null,!1)}s3.exports=(o={})=>{let{store:e=new Bae,methods:t=["GET"],cacheByDefault:a=void 0,type:i="shared",origins:r=void 0}=o;if(typeof o!="object"||o===null)throw new TypeError(`expected type of opts to be an Object, got ${o===null?"null":typeof o}`);if(Sae(e,"opts.store"),Dae(t,"opts.methods"),Mae(r,"opts.origins"),typeof a<"u"&&typeof a!="number")throw new TypeError(`expected opts.cacheByDefault to be number or undefined, got ${typeof a}`);if(typeof i<"u"&&i!=="shared"&&i!=="private")throw new TypeError(`expected opts.type to be shared, private, or undefined, got ${typeof i}`);let s={store:e,methods:t,cacheByDefault:a,type:i},n=[];for(let c=0;c<Ui.safeHTTPMethods.length;c++){let m=Ui.safeHTTPMethods[c];o3(t,m)||n.push(m)}return c=>(m,l)=>{if(!m.origin||o3(n,m.method))return c(m,l);if(r!==void 0){let p=m.origin.toString().toLowerCase(),b=!1;for(let A=0;A<r.length;A++){let k=r[A];if(typeof k=="string"){if(k.toLowerCase()===p){b=!0;break}}else if(k.test(p)){b=!0;break}}if(!b)return c(m,l)}m={...m,headers:Rae(m)};let u=m.headers?.["cache-control"]?r3(m.headers["cache-control"]):Lae(m.headers)?{"no-cache":!0}:void 0;if(u?.["no-store"])return c(m,l);let d=Tae(m),g=e.get(d);return g&&typeof g.then=="function"?g.then(p=>i3(c,s,d,l,m,u,p)):i3(c,s,d,l,m,u,g)}}});var d3=y((Ope,u3)=>{"use strict";var{createInflate:pw,createGunzip:c3,createBrotliDecompress:Wae,createZstdDecompress:Jae}=require("zlib"),{pipeline:Kae}=require("stream"),Zae=pn(),{runtimeFeatures:Xae}=Ta(),m3={gzip:c3,"x-gzip":c3,br:Wae,deflate:pw,compress:pw,"x-compress":pw,...Xae.has("zstd")?{zstd:Jae}:{}},eie=[204,304],l3=!1,hw=class extends Zae{#e=[];#o;#a;constructor(e,{skipStatusCodes:t=eie,skipErrorResponses:a=!0}={}){super(e),this.#o=t,this.#a=a}#i(e,t){return!!(!e||t<200||this.#o.includes(t)||this.#a&&t>=400)}#r(e){let t=e.split(","),a=5;if(t.length>a)throw new Error(`too many content-encodings in response: ${t.length}, maximum allowed is ${a}`);let i=[];for(let r=t.length-1;r>=0;r--){let s=t[r].trim();if(s){if(!m3[s])return i.length=0,i;i.push(m3[s]())}}return i}#t(e,t){e.on("readable",()=>{let a;for(;(a=e.read())!==null&&super.onResponseData(t,a)!==!1;);}),e.on("error",a=>{super.onResponseError(t,a)})}#c(e){let t=this.#e[0];this.#t(t,e),t.on("end",()=>{super.onResponseEnd(e,{})})}#s(e){let t=this.#e[this.#e.length-1];this.#t(t,e),Kae(this.#e,a=>{if(a){super.onResponseError(e,a);return}super.onResponseEnd(e,{})})}#n(){this.#e.length=0}onResponseStart(e,t,a,i){let r=a["content-encoding"];if(this.#i(r,t))return super.onResponseStart(e,t,a,i);let s=this.#r(r.toLowerCase());if(s.length===0)return this.#n(),super.onResponseStart(e,t,a,i);this.#e=s;let{"content-encoding":n,"content-length":c,...m}=a;return this.#e.length===1?this.#c(e):this.#s(e),super.onResponseStart(e,t,m,i)}onResponseData(e,t){if(this.#e.length>0){this.#e[0].write(t);return}super.onResponseData(e,t)}onResponseEnd(e,t){if(this.#e.length>0){this.#e[0].end(),this.#n();return}super.onResponseEnd(e,t)}onResponseError(e,t){if(this.#e.length>0){for(let a of this.#e)a.destroy(t);this.#n()}super.onResponseError(e,t)}};function oie(o={}){return l3||(process.emitWarning("DecompressInterceptor is experimental and subject to change","ExperimentalWarning"),l3=!0),e=>(t,a)=>{let i=new hw(a,o);return e(t,i)}}u3.exports=oie});var h3=y((Mpe,p3)=>{"use strict";var{RequestAbortedError:tie}=$(),g3=5*1024*1024,fw=class{#e;#o=[];#a=g3;#i=0;#r={};#t="";#c=!1;#s=!1;#n=!1;#m=!1;#u=null;#l=null;constructor(e,t,a=g3){this.#e=e,this.#l=t,this.#a=a}addWaitingHandler(e){if(this.#m||this.#n)return!1;let t=this.#d(e),a=t.controller;try{if(e.onRequestStart?.(a,null),a.aborted)return t.done=!0,!0;this.#s&&e.onResponseStart?.(a,this.#i,this.#r,this.#t)}catch{return t.done=!0,!0}return a.aborted||this.#o.push(t),!0}onRequestStart(e,t){this.#u=e,this.#e.onRequestStart?.(e,t)}onRequestUpgrade(e,t,a,i){this.#e.onRequestUpgrade?.(e,t,a,i)}onResponseStart(e,t,a,i){this.#s=!0,this.#i=t,this.#r=a,this.#t=i,this.#e.onResponseStart?.(e,t,a,i);for(let r of this.#o){let{handler:s,controller:n}=r;if(r.done||n.aborted){r.done=!0;continue}try{s.onResponseStart?.(n,t,a,i)}catch{}n.aborted&&(r.done=!0)}this.#h()}onResponseData(e,t){if(!(this.#c||this.#m)){this.#n=!0,this.#e.onResponseData?.(e,t);for(let a of this.#o){let{handler:i,controller:r}=a;if(a.done||r.aborted){a.done=!0;continue}if(r.paused){this.#p(a,t);continue}try{i.onResponseData?.(r,t)}catch{}r.aborted&&(a.done=!0,a.bufferedChunks=[],a.bufferedBytes=0)}this.#h()}}onResponseEnd(e,t){if(!(this.#c||this.#m)){this.#m=!0,this.#e.onResponseEnd?.(e,t);for(let a of this.#o){if(a.done||a.controller.aborted){a.done=!0;continue}if(this.#g(a),a.done||a.controller.aborted){a.done=!0;continue}if(a.controller.paused&&a.bufferedChunks.length>0){a.pendingTrailers=t;continue}try{a.handler.onResponseEnd?.(a.controller,t)}catch{}a.done=!0}this.#h(),this.#l?.()}}onResponseError(e,t){if(!this.#m){this.#c=!0,this.#m=!0,this.#e.onResponseError?.(e,t);for(let a of this.#o)this.#b(a,t);this.#o=[],this.#l?.()}}#d(e){let t={handler:e,controller:null,bufferedChunks:[],bufferedBytes:0,pendingTrailers:null,done:!1},a={aborted:!1,paused:!1,reason:null};return t.controller={resume:()=>{if(!a.aborted){if(a.paused=!1,this.#g(t),this.#m&&t.pendingTrailers&&t.bufferedChunks.length===0&&!a.paused&&!a.aborted){try{t.handler.onResponseEnd?.(t.controller,t.pendingTrailers)}catch{}t.pendingTrailers=null,t.done=!0}this.#h()}},pause:()=>{a.aborted||(a.paused=!0)},get paused(){return a.paused},get aborted(){return a.aborted},get reason(){return a.reason},abort:i=>{a.aborted=!0,a.reason=i??null,t.done=!0,t.pendingTrailers=null,t.bufferedChunks=[],t.bufferedBytes=0}},t}#p(e,t){if(e.done||e.controller.aborted){e.done=!0,e.bufferedChunks=[],e.bufferedBytes=0;return}let a=Buffer.from(t);if(e.bufferedChunks.push(a),e.bufferedBytes+=a.length,e.bufferedBytes>this.#a){let i=new tie(`Deduplicated waiting handler exceeded maxBufferSize (${this.#a} bytes) while paused`);this.#b(e,i)}}#g(e){let{handler:t,controller:a}=e;for(;!e.done&&!a.aborted&&!a.paused&&e.bufferedChunks.length>0;){let i=e.bufferedChunks.shift();e.bufferedBytes-=i.length;try{t.onResponseData?.(a,i)}catch{}if(a.aborted){e.done=!0,e.pendingTrailers=null,e.bufferedChunks=[],e.bufferedBytes=0;break}}}#b(e,t){if(!e.done){e.done=!0,e.pendingTrailers=null,e.bufferedChunks=[],e.bufferedBytes=0;try{e.controller.abort(t),e.handler.onResponseError?.(e.controller,t)}catch{}}}#h(){this.#o=this.#o.filter(e=>e.done===!1)}};p3.exports=fw});var b3=y((_pe,f3)=>{"use strict";var aie=require("diagnostics_channel"),iie=K(),rie=h3(),{normalizeHeaders:sie,makeCacheKey:nie,makeDeduplicationKey:cie}=hn(),sg=aie.channel("undici:request:pending-requests");f3.exports=(o={})=>{let{methods:e=["GET"],skipHeaderNames:t=[],excludeHeaderNames:a=[],maxBufferSize:i=5*1024*1024}=o;if(typeof o!="object"||o===null)throw new TypeError(`expected type of opts to be an Object, got ${o===null?"null":typeof o}`);if(!Array.isArray(e))throw new TypeError(`expected opts.methods to be an array, got ${typeof e}`);for(let c of e)if(!iie.safeHTTPMethods.includes(c))throw new TypeError(`expected opts.methods to only contain safe HTTP methods, got ${c}`);if(!Array.isArray(t))throw new TypeError(`expected opts.skipHeaderNames to be an array, got ${typeof t}`);if(!Array.isArray(a))throw new TypeError(`expected opts.excludeHeaderNames to be an array, got ${typeof a}`);if(!Number.isFinite(i)||i<=0)throw new TypeError(`expected opts.maxBufferSize to be a positive finite number, got ${i}`);let r=new Set(t.map(c=>c.toLowerCase())),s=new Set(a.map(c=>c.toLowerCase())),n=new Map;return c=>(m,l)=>{if(!m.origin||e.includes(m.method)===!1)return c(m,l);if(m={...m,headers:sie(m)},r.size>0){for(let b of Object.keys(m.headers))if(r.has(b.toLowerCase()))return c(m,l)}let u=nie(m),d=cie(u,s),g=n.get(d);if(g)return g.addWaitingHandler(l)?!0:c(m,l);let p=new rie(l,()=>{n.delete(d),sg.hasSubscribers&&sg.publish({size:n.size,key:d,type:"removed"})},i);return n.set(d,p),sg.hasSubscribers&&sg.publish({size:n.size,key:d,type:"added"}),c(m,p)}}});var A3=y((Fpe,k3)=>{"use strict";var{Writable:mie}=require("stream"),{assertCacheKey:bw,assertCacheValue:lie}=hn(),yw,Zo=3,y3=2*1e3*1e3*1e3;k3.exports=class{#e=y3;#o=1/0;#a;#i;#r;#t;#c;#s;#n;#m;constructor(e){if(e){if(typeof e!="object")throw new TypeError("SqliteCacheStore options must be an object");if(e.maxEntrySize!==void 0){if(typeof e.maxEntrySize!="number"||!Number.isInteger(e.maxEntrySize)||e.maxEntrySize<0)throw new TypeError("SqliteCacheStore options.maxEntrySize must be a non-negative integer");if(e.maxEntrySize>y3)throw new TypeError("SqliteCacheStore options.maxEntrySize must be less than 2gb");this.#e=e.maxEntrySize}if(e.maxCount!==void 0){if(typeof e.maxCount!="number"||!Number.isInteger(e.maxCount)||e.maxCount<0)throw new TypeError("SqliteCacheStore options.maxCount must be a non-negative integer");this.#o=e.maxCount}}yw||(yw=require("sqlite").DatabaseSync),this.#a=new yw(e?.location??":memory:"),this.#a.exec(`
1331
+ ${e.format(t)}`.trim())}};Y4.exports=_A});var FA=y((Ape,J4)=>{"use strict";var{InvalidArgumentError:Voe}=$(),{runtimeFeatures:$oe}=Ta();function Woe(o={}){let{ignoreHeaders:e=[],excludeHeaders:t=[],matchHeaders:a=[],caseSensitive:i=!1}=o;return{ignore:new Set(e.map(r=>i?r:r.toLowerCase())),exclude:new Set(t.map(r=>i?r:r.toLowerCase())),match:new Set(a.map(r=>i?r:r.toLowerCase()))}}var V4=$oe.has("crypto")?require("crypto"):null,Joe=V4?.hash?o=>V4.hash("sha256",o,"base64url"):o=>Buffer.from(o).toString("base64url");function W4(o){return Array.isArray(o)&&(o.length&1)===0}function Koe(o=[]){return o.length===0?()=>!1:function(t){let a;for(let i of o)if(typeof i=="string"){if(a||(a=t.toLowerCase()),a.includes(i.toLowerCase()))return!0}else if(i instanceof RegExp&&i.test(t))return!0;return!1}}function Zoe(o){let e={};if(!o)return e;if(W4(o)){for(let t=0;t<o.length;t+=2){let a=o[t],i=o[t+1];if(a&&i!==void 0){let r=Buffer.isBuffer(a)?a.toString():a,s=Buffer.isBuffer(i)?i.toString():i;e[r.toLowerCase()]=s}}return e}if(o&&typeof o=="object")for(let[t,a]of Object.entries(o))t&&typeof t=="string"&&(e[t.toLowerCase()]=Array.isArray(a)?a.join(", "):String(a));return e}var $4=["record","playback","update"];function Xoe(o){if(!$4.includes(o))throw new Voe(`Invalid snapshot mode: ${o}. Must be one of: ${$4.join(", ")}`)}J4.exports={createHeaderFilters:Woe,hashId:Joe,isUndiciHeaders:W4,normalizeHeaders:Zoe,isUrlExcludedFactory:Koe,validateSnapshotMode:Xoe}});var rQ=y((wpe,iQ)=>{"use strict";var{writeFile:ete,readFile:ote,mkdir:tte}=require("fs/promises"),{dirname:ate,resolve:K4}=require("path"),{setTimeout:ite,clearTimeout:Z4}=require("timers"),{InvalidArgumentError:X4,UndiciError:rte}=$(),{hashId:ste,isUrlExcludedFactory:nte,normalizeHeaders:eQ,createHeaderFilters:oQ}=FA();function Sm(o,e,t={}){let a=new URL(o.path,o.origin),i=o._normalizedHeaders||eQ(o.headers);return o._normalizedHeaders||(o._normalizedHeaders=i),{method:o.method||"GET",url:t.matchQuery!==!1?a.toString():`${a.origin}${a.pathname}`,headers:tQ(i,e,t),body:t.matchBody!==!1&&o.body?String(o.body):""}}function tQ(o,e,t={}){if(!o||typeof o!="object")return{};let{caseSensitive:a=!1}=t,i={},{ignore:r,exclude:s,match:n}=e;for(let[c,m]of Object.entries(o)){let l=a?c:c.toLowerCase();s.has(l)||r.has(l)||n.size!==0&&!n.has(l)||(i[l]=m)}return i}function aQ(o,e,t={}){if(!o||typeof o!="object")return{};let{caseSensitive:a=!1}=t,i={},{exclude:r}=e;for(let[s,n]of Object.entries(o)){let c=a?s:s.toLowerCase();r.has(c)||(i[c]=n)}return i}function Dm(o){let e=[o.method,o.url];if(o.headers&&typeof o.headers=="object"){let a=Object.keys(o.headers).sort();for(let i of a){let r=Array.isArray(o.headers[i])?o.headers[i]:[o.headers[i]];e.push(i);for(let s of r.sort())e.push(String(s))}}e.push(o.body);let t=e.join("|");return ste(t)}var PA=class{#e;#o;#a=new Map;#i;#r=1/0;#t=!1;#c;constructor(e={}){this.#i=e.snapshotPath,this.#r=e.maxSnapshots||1/0,this.#t=e.autoFlush||!1,this.flushInterval=e.flushInterval||3e4,this._flushTimer=null,this.matchOptions={matchHeaders:e.matchHeaders||[],ignoreHeaders:e.ignoreHeaders||[],excludeHeaders:e.excludeHeaders||[],matchBody:e.matchBody!==!1,matchQuery:e.matchQuery!==!1,caseSensitive:e.caseSensitive||!1},this.#c=oQ(this.matchOptions),this.shouldRecord=e.shouldRecord||(()=>!0),this.shouldPlayback=e.shouldPlayback||(()=>!0),this.#o=nte(e.excludeUrls),this.#t&&this.#i&&this.#s()}async record(e,t){if(!this.shouldRecord(e)||this.isUrlExcluded(e))return;let a=Sm(e,this.#c,this.matchOptions),i=Dm(a),r=eQ(t.headers),s={statusCode:t.statusCode,headers:aQ(r,this.#c,this.matchOptions),body:Buffer.isBuffer(t.body)?t.body.toString("base64"):Buffer.from(String(t.body||"")).toString("base64"),trailers:t.trailers};if(this.#a.size>=this.#r&&!this.#a.has(i)){let c=this.#a.keys().next().value;this.#a.delete(c)}let n=this.#a.get(i);n&&n.responses?(n.responses.push(s),n.timestamp=new Date().toISOString()):this.#a.set(i,{request:a,responses:[s],callCount:0,timestamp:new Date().toISOString()}),this.#t&&this.#i&&this.#m()}isUrlExcluded(e){let t=new URL(e.path,e.origin).toString();return this.#o(t)}findSnapshot(e){if(!this.shouldPlayback(e)||this.isUrlExcluded(e))return;let t=Sm(e,this.#c,this.matchOptions),a=Dm(t),i=this.#a.get(a);if(!i)return;let r=i.callCount||0,s=Math.min(r,i.responses.length-1);return i.callCount=r+1,{...i,response:i.responses[s]}}async loadSnapshots(e){let t=e||this.#i;if(!t)throw new X4("Snapshot path is required");try{let a=await ote(K4(t),"utf8"),i=JSON.parse(a);if(Array.isArray(i)){this.#a.clear();for(let{hash:r,snapshot:s}of i)this.#a.set(r,s)}else this.#a=new Map(Object.entries(i))}catch(a){if(a.code==="ENOENT")this.#a.clear();else throw new rte(`Failed to load snapshots from ${t}`,{cause:a})}}async saveSnapshots(e){let t=e||this.#i;if(!t)throw new X4("Snapshot path is required");let a=K4(t);await tte(ate(a),{recursive:!0});let i=Array.from(this.#a.entries()).map(([r,s])=>({hash:r,snapshot:s}));await ete(a,JSON.stringify(i,null,2),{flush:!0})}clear(){this.#a.clear()}getSnapshots(){return Array.from(this.#a.values())}size(){return this.#a.size}resetCallCounts(){for(let e of this.#a.values())e.callCount=0}deleteSnapshot(e){let t=Sm(e,this.#c,this.matchOptions),a=Dm(t);return this.#a.delete(a)}getSnapshotInfo(e){let t=Sm(e,this.#c,this.matchOptions),a=Dm(t),i=this.#a.get(a);return i?{hash:a,request:i.request,responseCount:i.responses?i.responses.length:i.response?1:0,callCount:i.callCount||0,timestamp:i.timestamp}:null}replaceSnapshots(e){if(this.#a.clear(),Array.isArray(e))for(let{hash:t,snapshot:a}of e)this.#a.set(t,a);else e&&typeof e=="object"&&(this.#a=new Map(Object.entries(e)))}#s(){return this.#m()}#n(){this.#e&&(Z4(this.#e),this.saveSnapshots().catch(()=>{}),this.#e=null)}#m(){this.#e=ite(()=>{this.saveSnapshots().catch(()=>{}),this.#t?this.#e?.refresh():this.#e=null},1e3)}destroy(){this.#n(),this.#e&&(Z4(this.#e),this.#e=null)}async close(){this.#i&&this.#a.size!==0&&await this.saveSnapshots(),this.destroy()}};iQ.exports={SnapshotRecorder:PA,formatRequestKey:Sm,createRequestHash:Dm,filterHeadersForMatching:tQ,filterHeadersForStorage:aQ,createHeaderFilters:oQ}});var cQ=y((vpe,nQ)=>{"use strict";var cte=Rr(),mte=LA(),{SnapshotRecorder:lte}=rQ(),ute=Jc(),{InvalidArgumentError:dte,UndiciError:gte}=$(),{validateSnapshotMode:pte}=FA(),Bo=Symbol("kSnapshotRecorder"),la=Symbol("kSnapshotMode"),Tm=Symbol("kSnapshotPath"),HA=Symbol("kSnapshotLoaded"),tg=Symbol("kRealAgent"),sQ=!1,GA=class extends mte{constructor(e={}){sQ||(process.emitWarning("SnapshotAgent is experimental and subject to change","ExperimentalWarning"),sQ=!0);let{mode:t="record",snapshotPath:a=null,...i}=e;if(super(i),pte(t),(t==="playback"||t==="update")&&!a)throw new dte(`snapshotPath is required when mode is '${t}'`);this[la]=t,this[Tm]=a,this[Bo]=new lte({snapshotPath:this[Tm],mode:this[la],maxSnapshots:e.maxSnapshots,autoFlush:e.autoFlush,flushInterval:e.flushInterval,matchHeaders:e.matchHeaders,ignoreHeaders:e.ignoreHeaders,excludeHeaders:e.excludeHeaders,matchBody:e.matchBody,matchQuery:e.matchQuery,caseSensitive:e.caseSensitive,shouldRecord:e.shouldRecord,shouldPlayback:e.shouldPlayback,excludeUrls:e.excludeUrls}),this[HA]=!1,(this[la]==="record"||this[la]==="update"||this[la]==="playback"&&e.excludeUrls&&e.excludeUrls.length>0)&&(this[tg]=new cte(e)),(this[la]==="playback"||this[la]==="update")&&this[Tm]&&this.loadSnapshots().catch(()=>{})}dispatch(e,t){t=ute.wrap(t);let a=this[la];if(this[Bo].isUrlExcluded(e))return this[tg].dispatch(e,t);if(a==="playback"||a==="update"){if(!this[HA])return this.#e(e,t);let i=this[Bo].findSnapshot(e);if(i)return this.#a(i,t);if(a==="update")return this.#o(e,t);{let r=new gte(`No snapshot found for ${e.method||"GET"} ${e.path}`);if(t.onError){t.onError(r);return}throw r}}else if(a==="record")return this.#o(e,t)}async#e(e,t){return await this.loadSnapshots(),this.dispatch(e,t)}#o(e,t){let a={statusCode:null,headers:{},trailers:{},body:[]},i=this,r={onRequestStart(n,c){return t.onRequestStart(n,{...c,history:this.history})},onRequestUpgrade(n,c,m,l){return t.onRequestUpgrade(n,c,m,l)},onResponseStart(n,c,m,l){return a.statusCode=c,a.headers=m,t.onResponseStart(n,c,m,l)},onResponseData(n,c){return a.body.push(c),t.onResponseData(n,c)},onResponseEnd(n,c){a.trailers=c;let m=Buffer.concat(a.body);i[Bo].record(e,{statusCode:a.statusCode,headers:a.headers,body:m,trailers:a.trailers}).then(()=>t.onResponseEnd(n,c)).catch(l=>t.onResponseError(n,l))}};return this[tg].dispatch(e,r)}#a(e,t){try{let{response:a}=e,i={pause(){},resume(){},abort(s){this.aborted=!0,this.reason=s},aborted:!1,paused:!1};t.onRequestStart(i),t.onResponseStart(i,a.statusCode,a.headers);let r=Buffer.from(a.body,"base64");t.onResponseData(i,r),t.onResponseEnd(i,a.trailers)}catch(a){t.onError?.(a)}}async loadSnapshots(e){await this[Bo].loadSnapshots(e||this[Tm]),this[HA]=!0,this[la]==="playback"&&this.#i()}async saveSnapshots(e){return this[Bo].saveSnapshots(e||this[Tm])}#i(){for(let e of this[Bo].getSnapshots()){let{request:t,responses:a,response:i}=e,r=new URL(t.url),s=this.get(r.origin),n=a?a[0]:i;n&&s.intercept({path:r.pathname+r.search,method:t.method,headers:t.headers,body:t.body}).reply(n.statusCode,n.body,{headers:n.headers,trailers:n.trailers}).persist()}}getRecorder(){return this[Bo]}getMode(){return this[la]}clearSnapshots(){this[Bo].clear()}resetCallCounts(){this[Bo].resetCallCounts()}deleteSnapshot(e){return this[Bo].deleteSnapshot(e)}getSnapshotInfo(e){return this[Bo].getSnapshotInfo(e)}replaceSnapshots(e){this[Bo].replaceSnapshots(e)}async close(){await this[Bo].close(),await this[tg]?.close(),await super.close()}};nQ.exports=GA});var ag=y((xpe,dQ)=>{"use strict";var hte=Symbol.for("undici.globalDispatcher.2"),mQ=Symbol.for("undici.globalDispatcher.1"),{InvalidArgumentError:fte}=$(),bte=Rr();uQ()===void 0&&lQ(new bte);function lQ(o){if(!o||typeof o.dispatch!="function")throw new fte("Argument agent must implement Agent");Object.defineProperty(globalThis,hte,{value:o,writable:!0,enumerable:!1,configurable:!1}),Object.defineProperty(globalThis,mQ,{value:o,writable:!0,enumerable:!1,configurable:!1})}function uQ(){return globalThis[mQ]}var yte=["fetch","Headers","Response","Request","FormData","WebSocket","CloseEvent","ErrorEvent","MessageEvent","EventSource"];dQ.exports={setGlobalDispatcher:lQ,getGlobalDispatcher:uQ,installedExports:yte}});var pn=y((qpe,gQ)=>{"use strict";var Ha=require("assert"),kte=Jc();gQ.exports=class{#e;#o=!1;#a=!1;#i=!1;constructor(e){if(typeof e!="object"||e===null)throw new TypeError("handler must be an object");this.#e=kte.wrap(e)}onRequestStart(...e){this.#e.onRequestStart?.(...e)}onRequestUpgrade(...e){return Ha(!this.#o),Ha(!this.#a),this.#e.onRequestUpgrade?.(...e)}onResponseStart(...e){return Ha(!this.#o),Ha(!this.#a),Ha(!this.#i),this.#i=!0,this.#e.onResponseStart?.(...e)}onResponseData(...e){return Ha(!this.#o),Ha(!this.#a),this.#e.onResponseData?.(...e)}onResponseEnd(...e){return Ha(!this.#o),Ha(!this.#a),this.#o=!0,this.#e.onResponseEnd?.(...e)}onResponseError(...e){return this.#a=!0,this.#e.onResponseError?.(...e)}onBodySent(){}}});var WA=y((Epe,bQ)=>{"use strict";var Qo=K(),{kBodyUsed:Rm}=de(),$A=require("assert"),{InvalidArgumentError:YA}=$(),Ate=require("events"),wte=[300,301,302,303,307,308],pQ=Symbol("body"),hQ=()=>{},ig=class{constructor(e){this[pQ]=e,this[Rm]=!1}async*[Symbol.asyncIterator](){$A(!this[Rm],"disturbed"),this[Rm]=!0,yield*this[pQ]}},VA=class o{static buildDispatch(e,t){if(t!=null&&(!Number.isInteger(t)||t<0))throw new YA("maxRedirections must be a positive number");let a=e.dispatch.bind(e);return(i,r)=>a(i,new o(a,t,i,r))}constructor(e,t,a,i){if(t!=null&&(!Number.isInteger(t)||t<0))throw new YA("maxRedirections must be a positive number");this.dispatch=e,this.location=null;let{maxRedirections:r,...s}=a;this.opts=s,this.maxRedirections=t,this.handler=i,this.history=[],Qo.isStream(this.opts.body)?(Qo.bodyLength(this.opts.body)===0&&this.opts.body.on("data",function(){$A(!1)}),typeof this.opts.body.readableDidRead!="boolean"&&(this.opts.body[Rm]=!1,Ate.prototype.on.call(this.opts.body,"data",function(){this[Rm]=!0}))):this.opts.body&&typeof this.opts.body.pipeTo=="function"?this.opts.body=new ig(this.opts.body):this.opts.body&&typeof this.opts.body!="string"&&!ArrayBuffer.isView(this.opts.body)&&Qo.isIterable(this.opts.body)&&!Qo.isFormDataLike(this.opts.body)&&(this.opts.body=new ig(this.opts.body))}onRequestStart(e,t){this.handler.onRequestStart?.(e,{...t,history:this.history})}onRequestUpgrade(e,t,a,i){this.handler.onRequestUpgrade?.(e,t,a,i)}onResponseStart(e,t,a,i){if(this.opts.throwOnMaxRedirect&&this.history.length>=this.maxRedirections)throw new Error("max redirects");if((t===301||t===302)&&this.opts.method==="POST"&&(this.opts.method="GET",Qo.isStream(this.opts.body)&&Qo.destroy(this.opts.body.on("error",hQ)),this.opts.body=null),t===303&&this.opts.method!=="HEAD"&&(this.opts.method="GET",Qo.isStream(this.opts.body)&&Qo.destroy(this.opts.body.on("error",hQ)),this.opts.body=null),this.location=this.history.length>=this.maxRedirections||Qo.isDisturbed(this.opts.body)||wte.indexOf(t)===-1?null:a.location,this.opts.origin&&this.history.push(new URL(this.opts.path,this.opts.origin)),!this.location){this.handler.onResponseStart?.(e,t,a,i);return}let{origin:r,pathname:s,search:n}=Qo.parseURL(new URL(this.location,this.opts.origin&&new URL(this.opts.path,this.opts.origin))),c=n?`${s}${n}`:s,m=`${r}${c}`;for(let l of this.history)if(l.toString()===m)throw new YA(`Redirect loop detected. Cannot redirect to ${r}. This typically happens when using a Client or Pool with cross-origin redirects. Use an Agent for cross-origin redirects.`);this.opts.headers=vte(this.opts.headers,t===303,this.opts.origin!==r),this.opts.path=c,this.opts.origin=r,this.opts.query=null}onResponseData(e,t){this.location||this.handler.onResponseData?.(e,t)}onResponseEnd(e,t){this.location?this.dispatch(this.opts,this):this.handler.onResponseEnd(e,t)}onResponseError(e,t){this.handler.onResponseError?.(e,t)}};function fQ(o,e,t){if(o.length===4)return Qo.headerNameToString(o)==="host";if(e&&Qo.headerNameToString(o).startsWith("content-"))return!0;if(t&&(o.length===13||o.length===6||o.length===19)){let a=Qo.headerNameToString(o);return a==="authorization"||a==="cookie"||a==="proxy-authorization"}return!1}function vte(o,e,t){let a=[];if(Array.isArray(o))for(let i=0;i<o.length;i+=2)fQ(o[i],e,t)||a.push(o[i],o[i+1]);else if(o&&typeof o=="object"){let i=Qo.hasSafeIterator(o)?o:Object.entries(o);for(let[r,s]of i)fQ(r,e,t)||a.push(r,s)}else $A(o==null,"headers must be an object or an array");return a}bQ.exports=VA});var kQ=y((Ipe,yQ)=>{"use strict";var xte=WA();function zte({maxRedirections:o}={}){return e=>function(a,i){let{maxRedirections:r=o,...s}=a;if(r==null||r===0)return e(a,i);let n={...s},c=new xte(e,r,n,i);return e(n,c)}}yQ.exports=zte});var wQ=y((Cpe,AQ)=>{"use strict";var qte=pn(),{ResponseError:Ete}=$(),JA=class extends qte{#e;#o;#a;#i;#r;constructor(e,{handler:t}){super(t)}#t(e){return(this.#o??"").indexOf(e)===0}onRequestStart(e,t){return this.#e=0,this.#o=null,this.#a=null,this.#i=null,this.#r="",super.onRequestStart(e,t)}onResponseStart(e,t,a,i){if(this.#e=t,this.#i=a,this.#o=a["content-type"],this.#e<400)return super.onResponseStart(e,t,a,i);(this.#t("application/json")||this.#t("text/plain"))&&(this.#a=new TextDecoder("utf-8"))}onResponseData(e,t){if(this.#e<400)return super.onResponseData(e,t);this.#r+=this.#a?.decode(t,{stream:!0})??""}onResponseEnd(e,t){if(this.#e>=400){if(this.#r+=this.#a?.decode(void 0,{stream:!1})??"",this.#t("application/json"))try{this.#r=JSON.parse(this.#r)}catch{}let a,i=Error.stackTraceLimit;Error.stackTraceLimit=0;try{a=new Ete("Response Error",this.#e,{body:this.#r,headers:this.#i})}finally{Error.stackTraceLimit=i}super.onResponseError(e,a)}else super.onResponseEnd(e,t)}onResponseError(e,t){super.onResponseError(e,t)}};AQ.exports=()=>o=>function(t,a){return o(t,new JA(t,{handler:a}))}});var xQ=y((jpe,vQ)=>{"use strict";var Ite=Fd();vQ.exports=o=>e=>function(a,i){return e(a,new Ite({...a,retryOptions:{...o,...a.retryOptions}},{handler:i,dispatch:e}))}});var qQ=y((Bpe,zQ)=>{"use strict";var{InvalidArgumentError:Cte,RequestAbortedError:jte}=$(),Bte=pn(),KA=class extends Bte{#e=1024*1024;#o=!1;#a=0;#i=null;aborted=!1;reason=!1;constructor({maxSize:e,signal:t},a){if(e!=null&&(!Number.isFinite(e)||e<1))throw new Cte("maxSize must be a number greater than 0");super(a),this.#e=e??this.#e}#r(e){this.aborted=!0,this.reason=e}onRequestStart(e,t){return e.abort=this.#r.bind(this),this.#i=e,super.onRequestStart(e,t)}onResponseStart(e,t,a,i){let r=a["content-length"];if(r!=null&&r>this.#e)throw new jte(`Response size (${r}) larger than maxSize (${this.#e})`);return this.aborted===!0?!0:super.onResponseStart(e,t,a,i)}onResponseError(e,t){this.#o||(t=this.#i?.reason??t,super.onResponseError(e,t))}onResponseData(e,t){return this.#a=this.#a+t.length,this.#a>=this.#e&&(this.#o=!0,this.aborted===!0?super.onResponseError(e,this.reason):super.onResponseEnd(e,{})),!0}onResponseEnd(e,t){if(!this.#o){if(this.#i.aborted===!0){super.onResponseError(e,this.reason);return}super.onResponseEnd(e,t)}}};function Qte({maxSize:o}={maxSize:1024*1024}){return e=>function(a,i){let{dumpMaxSize:r=o}=a,s=new KA({maxSize:r,signal:a.signal},i);return e(a,s)}}zQ.exports=Qte});var jQ=y((Qpe,CQ)=>{"use strict";var{isIP:Ste}=require("net"),{lookup:Dte}=require("dns"),Tte=pn(),{InvalidArgumentError:Yr,InformationalError:Rte}=$(),ZA=Math.pow(2,31)-1;function Nte(o){let e=Object.getPrototypeOf(o);return Object.prototype.hasOwnProperty.call(o,Symbol.iterator)||e!=null&&e!==Object.prototype&&typeof o[Symbol.iterator]=="function"}function EQ(o){return typeof o=="string"&&o.toLowerCase()==="host"}function Ute(o){if(o==null)return null;if(Array.isArray(o)){if(o.length===0||!Array.isArray(o[0]))return o;let e=[];for(let t of o)Array.isArray(t)&&t.length===2?e.push(t[0],t[1]):e.push(t);return e}if(typeof o=="object"&&Nte(o)){let e=[];for(let t of o)Array.isArray(t)&&t.length===2?e.push(t[0],t[1]):e.push(t);return e}return o}function Ote(o){if(o==null)return!1;if(Array.isArray(o)){if(o.length===0)return!1;for(let e=0;e<o.length;e+=2)if(EQ(o[e]))return!0;return!1}if(typeof o=="object"){for(let e in o)if(EQ(e))return!0}return!1}function IQ(o,e){let t=Ute(e);return Ote(t)?t:Array.isArray(t)?["host",o,...t]:t&&typeof t=="object"?{host:o,...t}:{host:o}}var XA=class{#e=0;#o=new Map;constructor(e){this.#e=e.maxItems}get size(){return this.#o.size}get(e){return this.#o.get(e)??null}set(e,t){this.#o.set(e,t)}delete(e){this.#o.delete(e)}full(){return this.size>=this.#e}},ew=class{#e=0;#o=0;dualStack=!0;affinity=null;lookup=null;pick=null;storage=null;constructor(e){this.#e=e.maxTTL,this.#o=e.maxItems,this.dualStack=e.dualStack,this.affinity=e.affinity,this.lookup=e.lookup??this.#a,this.pick=e.pick??this.#i,this.storage=e.storage??new XA(e)}runLookup(e,t,a){let i=this.storage.get(e.hostname);if(i==null&&this.storage.full()){a(null,e);return}let r={affinity:this.affinity,dualStack:this.dualStack,lookup:this.lookup,pick:this.pick,...t.dns,maxTTL:this.#e,maxItems:this.#o};if(i==null)this.lookup(e,r,(s,n)=>{if(s||n==null||n.length===0){a(s??new Rte("No DNS entries found"));return}this.setRecords(e,n);let c=this.storage.get(e.hostname),m=this.pick(e,c,r.affinity),l;typeof m.port=="number"?l=`:${m.port}`:e.port!==""?l=`:${e.port}`:l="",a(null,new URL(`${e.protocol}//${m.family===6?`[${m.address}]`:m.address}${l}`))});else{let s=this.pick(e,i,r.affinity);if(s==null){this.storage.delete(e.hostname),this.runLookup(e,t,a);return}let n;typeof s.port=="number"?n=`:${s.port}`:e.port!==""?n=`:${e.port}`:n="",a(null,new URL(`${e.protocol}//${s.family===6?`[${s.address}]`:s.address}${n}`))}}#a(e,t,a){Dte(e.hostname,{all:!0,family:this.dualStack===!1?this.affinity:0,order:"ipv4first"},(i,r)=>{if(i)return a(i);let s=new Map;for(let n of r)s.set(`${n.address}:${n.family}`,n);a(null,s.values())})}#i(e,t,a){let i=null,{records:r,offset:s}=t,n;if(this.dualStack?(a==null&&(s==null||s===ZA?(t.offset=0,a=4):(t.offset++,a=(t.offset&1)===1?6:4)),r[a]!=null&&r[a].ips.length>0?n=r[a]:n=r[a===4?6:4]):n=r[a],n==null||n.ips.length===0)return i;n.offset==null||n.offset===ZA?n.offset=0:n.offset++;let c=n.offset%n.ips.length;return i=n.ips[c]??null,i==null?i:Date.now()-i.timestamp>i.ttl?(n.ips.splice(c,1),this.pick(e,t,a)):i}pickFamily(e,t){let a=this.storage.get(e.hostname)?.records;if(!a)return null;let i=a[t];if(!i)return null;i.offset==null||i.offset===ZA?i.offset=0:i.offset++;let r=i.offset%i.ips.length,s=i.ips[r]??null;return s==null||Date.now()-s.timestamp>s.ttl&&i.ips.splice(r,1),s}setRecords(e,t){let a=Date.now(),i={records:{4:null,6:null}},r=this.#e;for(let s of t){s.timestamp=a,typeof s.ttl=="number"?(s.ttl=Math.min(s.ttl,this.#e),r=Math.min(r,s.ttl)):s.ttl=this.#e;let n=i.records[s.family]??{ips:[]};n.ips.push(s),i.records[s.family]=n}this.storage.set(e.hostname,i,{ttl:r})}deleteRecords(e){this.storage.delete(e.hostname)}getHandler(e,t){return new ow(this,e,t)}},ow=class extends Tte{#e=null;#o=null;#a=null;#i=null;#r=null;#t=null;#c=!0;constructor(e,{origin:t,handler:a,dispatch:i,newOrigin:r},s){super(a),this.#i=t,this.#t=r,this.#o={...s},this.#e=e,this.#a=i}onResponseError(e,t){switch(t.code){case"ETIMEDOUT":case"ECONNREFUSED":{if(this.#e.dualStack){if(!this.#c){super.onResponseError(e,t);return}this.#c=!1;let a=this.#t.hostname[0]==="["?4:6,i=this.#e.pickFamily(this.#i,a);if(i==null){super.onResponseError(e,t);return}let r;typeof i.port=="number"?r=`:${i.port}`:this.#i.port!==""?r=`:${this.#i.port}`:r="";let s={...this.#o,origin:`${this.#i.protocol}//${i.family===6?`[${i.address}]`:i.address}${r}`,headers:IQ(this.#i.host,this.#o.headers)};this.#a(s,this);return}super.onResponseError(e,t);break}case"ENOTFOUND":this.#e.deleteRecords(this.#i),super.onResponseError(e,t);break;default:super.onResponseError(e,t);break}}};CQ.exports=o=>{if(o?.maxTTL!=null&&(typeof o?.maxTTL!="number"||o?.maxTTL<0))throw new Yr("Invalid maxTTL. Must be a positive number");if(o?.maxItems!=null&&(typeof o?.maxItems!="number"||o?.maxItems<1))throw new Yr("Invalid maxItems. Must be a positive number and greater than zero");if(o?.affinity!=null&&o?.affinity!==4&&o?.affinity!==6)throw new Yr("Invalid affinity. Must be either 4 or 6");if(o?.dualStack!=null&&typeof o?.dualStack!="boolean")throw new Yr("Invalid dualStack. Must be a boolean");if(o?.lookup!=null&&typeof o?.lookup!="function")throw new Yr("Invalid lookup. Must be a function");if(o?.pick!=null&&typeof o?.pick!="function")throw new Yr("Invalid pick. Must be a function");if(o?.storage!=null&&(typeof o?.storage?.get!="function"||typeof o?.storage?.set!="function"||typeof o?.storage?.full!="function"||typeof o?.storage?.delete!="function"))throw new Yr("Invalid storage. Must be a object with methods: { get, set, full, delete }");let e=o?.dualStack??!0,t;e?t=o?.affinity??null:t=o?.affinity??4;let a={maxTTL:o?.maxTTL??1e4,lookup:o?.lookup??null,pick:o?.pick??null,dualStack:e,affinity:t,maxItems:o?.maxItems??1/0,storage:o?.storage},i=new ew(a);return r=>function(n,c){let m=n.origin.constructor===URL?n.origin:new URL(n.origin);return Ste(m.hostname)!==0?r(n,c):(i.runLookup(m,n,(l,u)=>{if(l)return c.onResponseError(null,l);let d={...n,servername:m.hostname,origin:u.origin,headers:IQ(m.host,n.headers)};r(d,i.getHandler({origin:m,dispatch:r,handler:c,newOrigin:u},n))}),!0)}}});var hn=y((Spe,_Q)=>{"use strict";var{safeHTTPMethods:BQ,pathHasQueryOrFragment:Mte,hasSafeIterator:_te,isValidHTTPToken:Nm}=K(),{serializePathWithQuery:Lte}=K(),Fte=2147483647,QQ=["no-store","private","no-cache"],tw=Symbol("invalid cache-control directives");function Vr(o){return o.replace(/^[\t ]+|[\t ]+$/g,"")}function UQ(o,e){for(let t=0;t<o.length;t++)if(o[t]===e)return!0;return!1}function SQ(o){return o.replace(/^[\t ]+/,"")}function DQ(o){return o.replace(/[\t ]+$/,"")}function TQ(o,e){let t=!1;for(let a=e;a<o.length;a++)if(t)t=!1;else if(o[a]==="\\")t=!0;else if(o[a]==='"')return a;return-1}function Pte(o){let e=[],t=0,a=-1,i=!1,r=!1;for(let m=0;m<o.length;m++)i?r?r=!1:o[m]==="\\"?r=!0:o[m]==='"'&&(i=!1,a=-1):o[m]==='"'?(i=!0,a=m):o[m]===","&&(e.push({value:o.substring(t,m),fromMalformedQuote:!1}),t=m+1);if(!i)return e.push({value:o.substring(t),fromMalformedQuote:!1}),e;let s=o.substring(t),n=a-t,c=0;for(let m=0;m<s.length;m++)s[m]===","&&(e.push({value:s.substring(c,m),fromMalformedQuote:c>n}),c=m+1);return e.push({value:s.substring(c),fromMalformedQuote:c>n}),e}function RQ(o,e){let t=o[tw];t===void 0&&(t=new Set,Object.defineProperty(o,tw,{value:t})),t.add(e)}function Hte(o,e){return o[tw]?.has(e)===!0}function Gte(o){for(let a of QQ)if(o.startsWith(a)&&o.length>a.length&&!Nm(o[a.length]))return a;let e="",t=!1;for(let a=0;a<o.length;a++)Nm(o[a])?e+=o[a]:t=!0;if(t&&UQ(QQ,e))return e}function Yte(o){if(!o.origin)throw new Error("opts.origin is undefined");let e=o.path||"/";return o.query&&!Mte(e)&&(e=Lte(e,o.query)),{origin:o.origin.toString(),method:o.method,path:e,headers:o.headers}}function NQ(o,e,t){let a=e.toLowerCase(),i=o[a],r=Array.isArray(t)?t:[t];i===void 0?o[a]=Array.isArray(t)?t.slice():t:Array.isArray(i)?i.push(...r):o[a]=[i,...r]}function Vte(o){let e;if(o.headers==null)e={};else if(typeof o.headers=="object")if(e={},_te(o.headers))for(let t of o.headers){if(!Array.isArray(t))throw new Error("opts.headers is not a valid header map");let[a,i]=t;if(typeof a!="string"||typeof i!="string")throw new Error("opts.headers is not a valid header map");NQ(e,a,i)}else for(let t of Object.keys(o.headers))NQ(e,t,o.headers[t]);else throw new Error("opts.headers is not an object");return e}function $te(o){if(typeof o!="object")throw new TypeError(`expected key to be object, got ${typeof o}`);for(let e of["origin","method","path"])if(typeof o[e]!="string")throw new TypeError(`expected key.${e} to be string, got ${typeof o[e]}`);if(o.headers!==void 0&&typeof o.headers!="object")throw new TypeError(`expected headers to be object, got ${typeof o}`)}function Wte(o){if(typeof o!="object")throw new TypeError(`expected value to be object, got ${typeof o}`);for(let e of["statusCode","cachedAt","staleAt","deleteAt"])if(typeof o[e]!="number")throw new TypeError(`expected value.${e} to be number, got ${typeof o[e]}`);if(typeof o.statusMessage!="string")throw new TypeError(`expected value.statusMessage to be string, got ${typeof o.statusMessage}`);if(o.headers!=null&&typeof o.headers!="object")throw new TypeError(`expected value.rawHeaders to be object, got ${typeof o.headers}`);if(o.vary!==void 0&&typeof o.vary!="object")throw new TypeError(`expected value.vary to be object, got ${typeof o.vary}`);if(o.etag!==void 0&&typeof o.etag!="string")throw new TypeError(`expected value.etag to be string, got ${typeof o.etag}`)}function Jte(o){let e={},t=new Set,a=new Set,i=Pte(Array.isArray(o)?o.join(","):o);for(let r=0;r<i.length;r++){let s=i[r],n=s.value.toLowerCase(),c=s.fromMalformedQuote,m=n.indexOf("="),l,u,d=!1,g=!1;if(m!==-1){let b=n.substring(0,m),A=n.substring(m+1);d=DQ(b)!==b,g=SQ(A)!==A,l=Vr(b),u=SQ(A)}else l=Vr(n);let p=Gte(l);if(p!==void 0){e[p]=!0;continue}switch(l){case"min-fresh":case"max-stale":case"max-age":case"s-maxage":case"stale-while-revalidate":case"stale-if-error":{if(c||t.has(l))continue;if(u===void 0||d||g){delete e[l],t.add(l),RQ(e,l);continue}if(u.length>=2&&u[0]==='"'&&u[u.length-1]==='"'&&(u=u.substring(1,u.length-1)),!/^[0-9]+$/.test(u)){delete e[l],t.add(l),RQ(e,l);continue}let b=Math.min(parseInt(u,10),Fte);l==="min-fresh"?(!(l in e)||e[l]<b)&&(e[l]=b):(!(l in e)||e[l]>b)&&(e[l]=b);break}case"private":case"no-cache":{if(c){e[l]=!0;break}if(u!==void 0&&u.length===0){e[l]=!0;break}if(u){if(u[0]==='"'){u=DQ(u);let b="",A=r,k=!1,x=TQ(u,1);if(x!==-1)b=u.substring(1,x),k=!0;else{let I=[u.substring(1)];for(let T=r+1;T<i.length;T++){let D=Vr(i[T].value),O=TQ(D,0);if(A=T,O!==-1){I.push(D.substring(0,O)),k=!0;break}I.push(D)}b=I.join(",")}if(!k){e[l]=!0;break}r=A;let v=b.split(","),j=!0;for(let I=0;I<v.length;I++)v[I]=Vr(v[I]),Nm(v[I])||(j=!1);j?e[l]!==!0&&(l in e?e[l]=e[l].concat(v):e[l]=v):e[l]=!0}else{let b=Vr(u);Nm(b)?e[l]!==!0&&(l in e?e[l]=e[l].concat(b):e[l]=[b]):e[l]=!0}break}}case"public":case"must-revalidate":case"proxy-revalidate":case"immutable":case"no-transform":case"must-understand":case"only-if-cached":if(c||a.has(l))continue;if(u!==void 0){delete e[l],a.add(l);continue}e[l]=!0;break;case"no-store":e[l]=!0;break;default:continue}}return e}function OQ(o){let e=Array.isArray(o)?o:[o],t=[];for(let a=0;a<e.length;a++){let i=e[a].split(",");for(let r=0;r<i.length;r++)t.push(i[r])}return t}function aw(o){let e=OQ(o);for(let t=0;t<e.length;t++)if(Vr(e[t]).indexOf("*")!==-1)return!0;return!1}function MQ(o,e){if(aw(o))return e;let t={},a=OQ(o);for(let i of a){let r=Vr(i).toLowerCase();if(r.length===0)continue;if(!Nm(r))return;let s=e[r];t[r]=Array.isArray(s)?s.slice():s??null}return t}function Kte(o){return aw(o)||MQ(o,{})===void 0}function Zte(o){return o.length<=2?!1:o[0]==='"'&&o[o.length-1]==='"'?!(o[1]==='"'||o.startsWith('"W/')):o.startsWith('W/"')&&o[o.length-1]==='"'?o.length!==4:!1}function Xte(o,e="CacheStore"){if(typeof o!="object"||o===null)throw new TypeError(`expected type of ${e} to be a CacheStore, got ${o===null?"null":typeof o}`);for(let t of["get","createWriteStream","delete"])if(typeof o[t]!="function")throw new TypeError(`${e} needs to have a \`${t}()\` function`)}function eae(o,e="CacheMethods"){if(!Array.isArray(o))throw new TypeError(`expected type of ${e} needs to be an array, got ${o===null?"null":typeof o}`);if(o.length===0)throw new TypeError(`${e} needs to have at least one method`);for(let t of o)if(!UQ(BQ,t))throw new TypeError(`element of ${e}-array needs to be one of following values: ${BQ.join(", ")}, got ${t}`)}function oae(o,e){let t={};if(o.headers){let a=Object.keys(o.headers).sort();for(let i of a)e?.has(i.toLowerCase())||(t[i]=o.headers[i])}return JSON.stringify([o.origin,o.method,o.path,t])}_Q.exports={makeCacheKey:Yte,normalizeHeaders:Vte,assertCacheKey:$te,assertCacheValue:Wte,parseCacheControlHeader:Jte,hasInvalidCacheControlDirective:Hte,parseVaryHeader:MQ,hasVaryStar:aw,isInvalidOrWildcardVaryHeader:Kte,isEtagUsable:Zte,assertCacheMethods:eae,assertCacheStore:Xte,makeDeduplicationKey:oae}});var rw=y((Dpe,LQ)=>{"use strict";function tae(o){switch(o[3]){case",":return aae(o);case" ":return iae(o);default:return rae(o)}}function iw(o,e,t,a,i,r,s){let n=new Date(Date.UTC(o,e,t,a,i,r));return o>=0&&o<=99&&n.setUTCFullYear(o),n.getUTCFullYear()===o&&n.getUTCMonth()===e&&n.getUTCDate()===t&&n.getUTCHours()===a&&n.getUTCMinutes()===i&&n.getUTCSeconds()===r&&n.getUTCDay()===s?n:void 0}function aae(o){if(o.length!==29||o[4]!==" "||o[7]!==" "||o[11]!==" "||o[16]!==" "||o[19]!==":"||o[22]!==":"||o[25]!==" "||o[26]!=="G"||o[27]!=="M"||o[28]!=="T")return;let e=-1;if(o[0]==="S"&&o[1]==="u"&&o[2]==="n")e=0;else if(o[0]==="M"&&o[1]==="o"&&o[2]==="n")e=1;else if(o[0]==="T"&&o[1]==="u"&&o[2]==="e")e=2;else if(o[0]==="W"&&o[1]==="e"&&o[2]==="d")e=3;else if(o[0]==="T"&&o[1]==="h"&&o[2]==="u")e=4;else if(o[0]==="F"&&o[1]==="r"&&o[2]==="i")e=5;else if(o[0]==="S"&&o[1]==="a"&&o[2]==="t")e=6;else return;let t=0;if(o[5]==="0"){let d=o.charCodeAt(6);if(d<49||d>57)return;t=d-48}else{let d=o.charCodeAt(5);if(d<49||d>51)return;let g=o.charCodeAt(6);if(g<48||g>57)return;t=(d-48)*10+(g-48)}let a=-1;if(o[8]==="J"&&o[9]==="a"&&o[10]==="n")a=0;else if(o[8]==="F"&&o[9]==="e"&&o[10]==="b")a=1;else if(o[8]==="M"&&o[9]==="a")if(o[10]==="r")a=2;else if(o[10]==="y")a=4;else return;else if(o[8]==="J")if(o[9]==="a"&&o[10]==="n")a=0;else if(o[9]==="u")if(o[10]==="n")a=5;else if(o[10]==="l")a=6;else return;else return;else if(o[8]==="A")if(o[9]==="p"&&o[10]==="r")a=3;else if(o[9]==="u"&&o[10]==="g")a=7;else return;else if(o[8]==="S"&&o[9]==="e"&&o[10]==="p")a=8;else if(o[8]==="O"&&o[9]==="c"&&o[10]==="t")a=9;else if(o[8]==="N"&&o[9]==="o"&&o[10]==="v")a=10;else if(o[8]==="D"&&o[9]==="e"&&o[10]==="c")a=11;else return;let i=o.charCodeAt(12);if(i<48||i>57)return;let r=o.charCodeAt(13);if(r<48||r>57)return;let s=o.charCodeAt(14);if(s<48||s>57)return;let n=o.charCodeAt(15);if(n<48||n>57)return;let c=(i-48)*1e3+(r-48)*100+(s-48)*10+(n-48),m=0;if(o[17]==="0"){let d=o.charCodeAt(18);if(d<48||d>57)return;m=d-48}else{let d=o.charCodeAt(17);if(d<48||d>50)return;let g=o.charCodeAt(18);if(g<48||g>57||d===50&&g>51)return;m=(d-48)*10+(g-48)}let l=0;if(o[20]==="0"){let d=o.charCodeAt(21);if(d<48||d>57)return;l=d-48}else{let d=o.charCodeAt(20);if(d<48||d>53)return;let g=o.charCodeAt(21);if(g<48||g>57)return;l=(d-48)*10+(g-48)}let u=0;if(o[23]==="0"){let d=o.charCodeAt(24);if(d<48||d>57)return;u=d-48}else{let d=o.charCodeAt(23);if(d<48||d>53)return;let g=o.charCodeAt(24);if(g<48||g>57)return;u=(d-48)*10+(g-48)}return iw(c,a,t,m,l,u,e)}function iae(o){if(o.length!==24||o[7]!==" "||o[10]!==" "||o[19]!==" ")return;let e=-1;if(o[0]==="S"&&o[1]==="u"&&o[2]==="n")e=0;else if(o[0]==="M"&&o[1]==="o"&&o[2]==="n")e=1;else if(o[0]==="T"&&o[1]==="u"&&o[2]==="e")e=2;else if(o[0]==="W"&&o[1]==="e"&&o[2]==="d")e=3;else if(o[0]==="T"&&o[1]==="h"&&o[2]==="u")e=4;else if(o[0]==="F"&&o[1]==="r"&&o[2]==="i")e=5;else if(o[0]==="S"&&o[1]==="a"&&o[2]==="t")e=6;else return;let t=-1;if(o[4]==="J"&&o[5]==="a"&&o[6]==="n")t=0;else if(o[4]==="F"&&o[5]==="e"&&o[6]==="b")t=1;else if(o[4]==="M"&&o[5]==="a")if(o[6]==="r")t=2;else if(o[6]==="y")t=4;else return;else if(o[4]==="J")if(o[5]==="a"&&o[6]==="n")t=0;else if(o[5]==="u")if(o[6]==="n")t=5;else if(o[6]==="l")t=6;else return;else return;else if(o[4]==="A")if(o[5]==="p"&&o[6]==="r")t=3;else if(o[5]==="u"&&o[6]==="g")t=7;else return;else if(o[4]==="S"&&o[5]==="e"&&o[6]==="p")t=8;else if(o[4]==="O"&&o[5]==="c"&&o[6]==="t")t=9;else if(o[4]==="N"&&o[5]==="o"&&o[6]==="v")t=10;else if(o[4]==="D"&&o[5]==="e"&&o[6]==="c")t=11;else return;let a=0;if(o[8]===" "){let d=o.charCodeAt(9);if(d<49||d>57)return;a=d-48}else{let d=o.charCodeAt(8);if(d<49||d>51)return;let g=o.charCodeAt(9);if(g<48||g>57)return;a=(d-48)*10+(g-48)}let i=0;if(o[11]==="0"){let d=o.charCodeAt(12);if(d<48||d>57)return;i=d-48}else{let d=o.charCodeAt(11);if(d<48||d>50)return;let g=o.charCodeAt(12);if(g<48||g>57||d===50&&g>51)return;i=(d-48)*10+(g-48)}let r=0;if(o[14]==="0"){let d=o.charCodeAt(15);if(d<48||d>57)return;r=d-48}else{let d=o.charCodeAt(14);if(d<48||d>53)return;let g=o.charCodeAt(15);if(g<48||g>57)return;r=(d-48)*10+(g-48)}let s=0;if(o[17]==="0"){let d=o.charCodeAt(18);if(d<48||d>57)return;s=d-48}else{let d=o.charCodeAt(17);if(d<48||d>53)return;let g=o.charCodeAt(18);if(g<48||g>57)return;s=(d-48)*10+(g-48)}let n=o.charCodeAt(20);if(n<48||n>57)return;let c=o.charCodeAt(21);if(c<48||c>57)return;let m=o.charCodeAt(22);if(m<48||m>57)return;let l=o.charCodeAt(23);if(l<48||l>57)return;let u=(n-48)*1e3+(c-48)*100+(m-48)*10+(l-48);return iw(u,t,a,i,r,s,e)}function rae(o){let e=-1,t=-1;if(o[0]==="S")o[1]==="u"&&o[2]==="n"&&o[3]==="d"&&o[4]==="a"&&o[5]==="y"?(t=0,e=6):o[1]==="a"&&o[2]==="t"&&o[3]==="u"&&o[4]==="r"&&o[5]==="d"&&o[6]==="a"&&o[7]==="y"&&(t=6,e=8);else if(o[0]==="M"&&o[1]==="o"&&o[2]==="n"&&o[3]==="d"&&o[4]==="a"&&o[5]==="y")t=1,e=6;else if(o[0]==="T")o[1]==="u"&&o[2]==="e"&&o[3]==="s"&&o[4]==="d"&&o[5]==="a"&&o[6]==="y"?(t=2,e=7):o[1]==="h"&&o[2]==="u"&&o[3]==="r"&&o[4]==="s"&&o[5]==="d"&&o[6]==="a"&&o[7]==="y"&&(t=4,e=8);else if(o[0]==="W"&&o[1]==="e"&&o[2]==="d"&&o[3]==="n"&&o[4]==="e"&&o[5]==="s"&&o[6]==="d"&&o[7]==="a"&&o[8]==="y")t=3,e=9;else if(o[0]==="F"&&o[1]==="r"&&o[2]==="i"&&o[3]==="d"&&o[4]==="a"&&o[5]==="y")t=5,e=6;else return;if(o[e]!==","||o.length-e-1!==23||o[e+1]!==" "||o[e+4]!=="-"||o[e+8]!=="-"||o[e+11]!==" "||o[e+14]!==":"||o[e+17]!==":"||o[e+20]!==" "||o[e+21]!=="G"||o[e+22]!=="M"||o[e+23]!=="T")return;let a=0;if(o[e+2]==="0"){let u=o.charCodeAt(e+3);if(u<49||u>57)return;a=u-48}else{let u=o.charCodeAt(e+2);if(u<49||u>51)return;let d=o.charCodeAt(e+3);if(d<48||d>57)return;a=(u-48)*10+(d-48)}let i=-1;if(o[e+5]==="J"&&o[e+6]==="a"&&o[e+7]==="n")i=0;else if(o[e+5]==="F"&&o[e+6]==="e"&&o[e+7]==="b")i=1;else if(o[e+5]==="M"&&o[e+6]==="a"&&o[e+7]==="r")i=2;else if(o[e+5]==="A"&&o[e+6]==="p"&&o[e+7]==="r")i=3;else if(o[e+5]==="M"&&o[e+6]==="a"&&o[e+7]==="y")i=4;else if(o[e+5]==="J"&&o[e+6]==="u"&&o[e+7]==="n")i=5;else if(o[e+5]==="J"&&o[e+6]==="u"&&o[e+7]==="l")i=6;else if(o[e+5]==="A"&&o[e+6]==="u"&&o[e+7]==="g")i=7;else if(o[e+5]==="S"&&o[e+6]==="e"&&o[e+7]==="p")i=8;else if(o[e+5]==="O"&&o[e+6]==="c"&&o[e+7]==="t")i=9;else if(o[e+5]==="N"&&o[e+6]==="o"&&o[e+7]==="v")i=10;else if(o[e+5]==="D"&&o[e+6]==="e"&&o[e+7]==="c")i=11;else return;let r=o.charCodeAt(e+9);if(r<48||r>57)return;let s=o.charCodeAt(e+10);if(s<48||s>57)return;let n=(r-48)*10+(s-48);n+=n<70?2e3:1900;let c=0;if(o[e+12]==="0"){let u=o.charCodeAt(e+13);if(u<48||u>57)return;c=u-48}else{let u=o.charCodeAt(e+12);if(u<48||u>50)return;let d=o.charCodeAt(e+13);if(d<48||d>57||u===50&&d>51)return;c=(u-48)*10+(d-48)}let m=0;if(o[e+15]==="0"){let u=o.charCodeAt(e+16);if(u<48||u>57)return;m=u-48}else{let u=o.charCodeAt(e+15);if(u<48||u>53)return;let d=o.charCodeAt(e+16);if(d<48||d>57)return;m=(u-48)*10+(d-48)}let l=0;if(o[e+18]==="0"){let u=o.charCodeAt(e+19);if(u<48||u>57)return;l=u-48}else{let u=o.charCodeAt(e+18);if(u<48||u>53)return;let d=o.charCodeAt(e+19);if(d<48||d>57)return;l=(u-48)*10+(d-48)}return iw(n,i,a,c,m,l,t)}LQ.exports={parseHttpDate:tae}});var $Q=y((Tpe,VQ)=>{"use strict";var sw=K(),{parseCacheControlHeader:sae,hasInvalidCacheControlDirective:FQ,parseVaryHeader:nae,hasVaryStar:cae,isInvalidOrWildcardVaryHeader:HQ,isEtagUsable:mae}=hn(),{parseHttpDate:nw}=rw();function lae(){}var GQ=[200,203,204,206,300,301,308,404,405,410,414,501],uae=[206],Um=2147483647e3;function dae(o){return o.replace(/^[\t ]+|[\t ]+$/g,"")}function fn(o,e){for(let t=0;t<o.length;t++)if(o[t]===e)return!0;return!1}function gae(o,e){let t=Array.isArray(e)?e:[e];for(let a=0;a<t.length;a++){let i=t[a].split(",");for(let r=0;r<i.length;r++)o.push(dae(i[r]).toLowerCase())}}function pae(o,e){if(typeof e!="string")return;let t,a,i;try{t=new URL(o.origin),a=new URL(o.path,t),i=new URL(e,a)}catch{return}if(i.origin===t.origin)return i.pathname+i.search}function YQ(o,e,t){Om(o,{...e,path:t});for(let a=0;a<sw.safeHTTPMethods.length;a++){let i=sw.safeHTTPMethods[a];i!==e.method&&Om(o,{...e,method:i,path:t})}}function PQ(o,e,t){if(t===void 0)return;let a=Array.isArray(t)?t:[t];for(let i=0;i<a.length;i++){let r=pae(e,a[i]);r!==void 0&&YQ(o,e,r)}}function hae(o,e,t){YQ(o,e,e.path),PQ(o,e,t.location),PQ(o,e,t["content-location"])}var cw=class{#e;#o;#a;#i;#r;#t;constructor({store:e,type:t,cacheByDefault:a},i,r){this.#i=e,this.#o=t,this.#a=a,this.#e=i,this.#r=r}onRequestStart(e,t){this.#t?.destroy(),this.#t=void 0,this.#r.onRequestStart?.(e,t)}onRequestUpgrade(e,t,a,i){this.#r.onRequestUpgrade?.(e,t,a,i)}onResponseStart(e,t,a,i){let r=()=>this.#r.onResponseStart?.(e,t,a,i),s=this;if(!fn(sw.safeHTTPMethods,this.#e.method)&&t>=200&&t<=399)return hae(this.#i,this.#e,a),r();let n=a["cache-control"],c=a["last-modified"]&&fn(GQ,t);if(!n&&!a.expires&&!c&&!this.#a)return t===304&&a.vary&&HQ(a.vary)&&Om(this.#i,this.#e),r();let m=n?sae(n):{};if(!bae(this.#o,t,a,m,this.#e.headers))return t===304&&(n||fae(this.#o,a,m))&&Om(this.#i,this.#e),r();let l=Date.now(),u=Object.hasOwn(a,"age")?kae(a.age):void 0;if(u!==void 0&&u>=Um)return rg(t,this.#i,this.#e),r();let d=Object.hasOwn(a,"date")?yae(a.date):void 0;if(d===null)return rg(t,this.#i,this.#e),r();let g=d?Math.max(0,l-d.getTime()):0,p=Math.max(g,u??0),b=Aae(this.#o,l,u,a,d,m)??this.#a;if(b===void 0||p>=b)return(n||b!==void 0)&&rg(t,this.#i,this.#e),r();let A=l-p,k=b+A;if(l>=k)return rg(t,this.#i,this.#e),r();let x;if(this.#e.headers&&a.vary&&(x=nae(a.vary,this.#e.headers),!x))return r();let v=A,j=wae(A,l,m,k),I=vae(a,m),T={statusCode:t,statusMessage:i,headers:I,vary:x,cacheControlDirectives:m,cachedAt:v,staleAt:k,deleteAt:j};if(t===304){let D=S=>{if(!S)return r();if(T.statusCode=S.statusCode,T.statusMessage=S.statusMessage,T.etag=S.etag,T.vary=x??S.vary,T.headers={...S.headers,...I},r(),this.#t=this.#i.createWriteStream(this.#e,T),!(!this.#t||!S?.body))if(typeof S.body.values=="function"){let oe=S.body.values(),te=()=>{for(let ye of oe){let po=this.#t.write(ye)===!1;if(this.#r.onResponseData?.(e,ye),po)break}};this.#t.on("error",function(){s.#t=void 0,s.#i.delete(s.#e)}).on("drain",()=>{te()}).on("close",function(){s.#t===this&&(s.#t=void 0)}),te()}else typeof S.body.on=="function"&&(S.body.on("data",oe=>{this.#t.write(oe),this.#r.onResponseData?.(e,oe)}).on("end",()=>{this.#t.end()}).on("error",()=>{this.#t=void 0,this.#i.delete(this.#e)}),this.#t.on("error",function(){s.#t=void 0,s.#i.delete(s.#e)}).on("close",function(){s.#t===this&&(s.#t=void 0)}))},O=this.#i.get(this.#e);O&&typeof O.then=="function"?O.then(D):D(O)}else{if(typeof a.etag=="string"&&mae(a.etag)&&(T.etag=a.etag),this.#t=this.#i.createWriteStream(this.#e,T),!this.#t)return r();this.#t.on("drain",()=>e.resume()).on("error",function(){s.#t=void 0,s.#i.delete(s.#e)}).on("close",function(){s.#t===this&&(s.#t=void 0),e.resume()}),r()}}onResponseData(e,t){this.#t?.write(t)===!1&&e.pause(),this.#r.onResponseData?.(e,t)}onResponseEnd(e,t){this.#t?.end(),this.#r.onResponseEnd?.(e,t)}onResponseError(e,t){this.#t?.destroy(t),this.#t=void 0,this.#r.onResponseError?.(e,t)}};function Om(o,e){try{o.delete(e)?.catch?.(lae)}catch{}}function rg(o,e,t){o===304&&Om(e,t)}function fae(o,e,t){return t["no-store"]===!0||o==="shared"&&t.private===!0||(e.vary?HQ(e.vary):!1)}function bae(o,e,t,a,i){return!(e<200||fn(uae,e)||!fn(GQ,e)&&!t.expires&&!a.public&&a["max-age"]===void 0&&!(a.private&&o==="private")&&!(a["s-maxage"]!==void 0&&o==="shared")||a["no-store"]||o==="shared"&&a.private===!0||t.vary&&cae(t.vary)||i!=null&&Object.hasOwn(i,"authorization")&&(!a.public&&!a["s-maxage"]&&!a["must-revalidate"]||typeof i.authorization!="string"||Array.isArray(a["no-cache"])&&fn(a["no-cache"],"authorization")||Array.isArray(a.private)&&fn(a.private,"authorization")))}function yae(o){let e=o;if(Array.isArray(e)){if(e.length!==1)return null;e=e[0]}return typeof e!="string"?null:nw(e)}function kae(o){let e=o;if(Array.isArray(e)){if(e.length!==1)return Um;e=e[0]}if(typeof e!="string"||!/^[\t ]*[0-9]+[\t ]*$/.test(e))return Um;let t=BigInt(e.replace(/^[\t ]+|[\t ]+$/g,""));return t>=BigInt(Um/1e3)?Um:Number(t)*1e3}function Aae(o,e,t,a,i,r){if(o==="shared"){if(FQ(r,"s-maxage"))return 0;let n=r["s-maxage"];if(n!==void 0)return n*1e3}if(FQ(r,"max-age"))return 0;let s=r["max-age"];if(s!==void 0)return s*1e3;if(Object.hasOwn(a,"expires")){if(typeof a.expires!="string")return 0;let n=nw(a.expires);if(!n||e>=n.getTime())return 0;if(i){if(i>=n)return 0;let c=n.getTime()-i.getTime();return t!==void 0&&t>=c?0:c}return n.getTime()-e}if(typeof a["last-modified"]=="string"){let n=nw(a["last-modified"]);if(n)return n.getTime()>=e?void 0:(e-n.getTime())*.1}if(r.immutable)return 31536e6}function wae(o,e,t,a){let i=-1/0,r=-1/0,s=-1/0;if(t["stale-while-revalidate"]&&(i=a+t["stale-while-revalidate"]*1e3),t["stale-if-error"]&&(r=a+t["stale-if-error"]*1e3),t.immutable&&i===-1/0&&r===-1/0&&(s=e+31536e6),i===-1/0&&r===-1/0&&s===-1/0){let n=a-o,c=Math.min(Math.max(e-o,0),1e3);return a+n+c}return Math.max(a,i,r,s)}function vae(o,e){let t=["connection","proxy-authenticate","proxy-authentication-info","proxy-authorization","proxy-connection","te","transfer-encoding","upgrade","age"];o.connection&&gae(t,o.connection),Array.isArray(e["no-cache"])&&t.push(...e["no-cache"]),Array.isArray(e.private)&&t.push(...e.private);let a;for(let i of t)Object.hasOwn(o,i)&&(a??={...o},delete a[i]);return a??o}VQ.exports=cw});var lw=y((Rpe,KQ)=>{"use strict";var{Writable:xae}=require("stream"),{EventEmitter:zae}=require("events"),{assertCacheKey:WQ,assertCacheValue:qae}=hn(),mw=class extends zae{#e=1024;#o=104857600;#a=5242880;#i=0;#r=0;#t=new Map;#c=!1;constructor(e){if(super(),e){if(typeof e!="object")throw new TypeError("MemoryCacheStore options must be an object");if(e.maxCount!==void 0){if(typeof e.maxCount!="number"||!Number.isInteger(e.maxCount)||e.maxCount<0)throw new TypeError("MemoryCacheStore options.maxCount must be a non-negative integer");this.#e=e.maxCount}if(e.maxSize!==void 0){if(typeof e.maxSize!="number"||!Number.isInteger(e.maxSize)||e.maxSize<0)throw new TypeError("MemoryCacheStore options.maxSize must be a non-negative integer");this.#o=e.maxSize}if(e.maxEntrySize!==void 0){if(typeof e.maxEntrySize!="number"||!Number.isInteger(e.maxEntrySize)||e.maxEntrySize<0)throw new TypeError("MemoryCacheStore options.maxEntrySize must be a non-negative integer");this.#a=e.maxEntrySize}}}get size(){return this.#i}isFull(){return this.#i>=this.#o||this.#r>=this.#e}get(e){WQ(e);let t=`${e.origin}:${e.path}`,a=Date.now(),i=this.#t.get(t),r=i?JQ(e,i,a):null;return r==null?void 0:{statusMessage:r.statusMessage,statusCode:r.statusCode,headers:r.headers,body:r.body,vary:r.vary?r.vary:void 0,etag:r.etag,cacheControlDirectives:r.cacheControlDirectives,cachedAt:r.cachedAt,staleAt:r.staleAt,deleteAt:r.deleteAt}}createWriteStream(e,t){WQ(e),qae(t);let a=`${e.origin}:${e.path}`,i=this,r={...e,...t,body:[],size:0};return new xae({write(s,n,c){typeof s=="string"&&(s=Buffer.from(s,n)),r.size+=s.byteLength,r.size>=i.#a?this.destroy():r.body.push(s),c(null)},final(s){let n=i.#t.get(a);n||(n=[],i.#t.set(a,n));let c=JQ(e,n,Date.now());if(c){let m=n.indexOf(c);n.splice(m,1,r),i.#i-=c.size}else n.push(r),i.#r+=1;if(i.#i+=r.size,i.#i>i.#o||i.#r>i.#e){i.#c||(i.emit("maxSizeExceeded",{size:i.#i,maxSize:i.#o,count:i.#r,maxCount:i.#e}),i.#c=!0);for(let[m,l]of i.#t){for(let u of l.splice(0,l.length/2))i.#i-=u.size,i.#r-=1;l.length===0&&i.#t.delete(m)}i.#i<i.#o&&i.#r<i.#e&&(i.#c=!1)}s(null)}})}delete(e){if(typeof e!="object")throw new TypeError(`expected key to be object, got ${typeof e}`);let t=`${e.origin}:${e.path}`;for(let a of this.#t.get(t)??[])this.#i-=a.size,this.#r-=1;this.#t.delete(t)}};function JQ(o,e,t){for(let a=0;a<e.length;a++){let i=e[a];if(i.deleteAt>t&&i.method===o.method&&Eae(o,i))return i}}function Eae(o,e){if(e.vary==null)return!0;for(let t in e.vary)if(Object.hasOwn(e.vary,t)&&!Iae(o.headers?.[t],e.vary[t]))return!1;return!0}function Iae(o,e){if(o==null&&e==null)return!0;if(o==null&&e!=null||o!=null&&e==null)return!1;if(Array.isArray(o)&&Array.isArray(e)){if(o.length!==e.length)return!1;for(let t=0;t<o.length;t++)if(o[t]!==e[t])return!1;return!0}return o===e}KQ.exports=mw});var XQ=y((Npe,ZQ)=>{"use strict";var Cae=require("assert"),uw=class{#e=!1;#o;#a;#i;#r;constructor(e,t,a){if(typeof e!="function")throw new TypeError("callback must be a function");this.#o=e,this.#a=t,this.#r=a}onRequestStart(e,t){this.#e=!1,this.#i=t}onRequestUpgrade(e,t,a,i){this.#a.onRequestUpgrade?.(e,t,a,i)}onResponseStart(e,t,a,i){if(Cae(this.#o!=null),this.#e=t===304||this.#r&&t>=500&&t<=504,this.#o(this.#e,this.#i,t,a),this.#o=null,this.#e)return!0;this.#a.onRequestStart?.(e,this.#i),this.#a.onResponseStart?.(e,t,a,i)}onResponseData(e,t){if(!this.#e)return this.#a.onResponseData?.(e,t)}onResponseEnd(e,t){this.#e||this.#a.onResponseEnd?.(e,t)}onResponseError(e,t){if(!this.#e)if(this.#o&&(this.#o(!1),this.#o=null),typeof this.#a.onResponseError=="function")this.#a.onResponseError(e,t);else throw t}};ZQ.exports=uw});var n3=y((Upe,s3)=>{"use strict";var e3=require("assert"),{Readable:jae}=require("stream"),Ui=K(),bn=$Q(),Bae=lw(),Qae=XQ(),{assertCacheStore:Sae,assertCacheMethods:Dae,makeCacheKey:Tae,normalizeHeaders:Rae,parseCacheControlHeader:r3,isInvalidOrWildcardVaryHeader:Nae}=hn(),{AbortError:Uae}=$(),{parseHttpDate:Oae}=rw();function Mae(o,e){if(o!==void 0){if(!Array.isArray(o))throw new TypeError(`expected ${e} to be an array or undefined, got ${typeof o}`);for(let t=0;t<o.length;t++){let a=o[t];if(typeof a!="string"&&!(a instanceof RegExp))throw new TypeError(`expected ${e}[${t}] to be a string or RegExp, got ${typeof a}`)}}}var Mm=()=>{};function _ae(o){return o.replace(/^[\t ]+|[\t ]+$/g,"")}function o3(o,e){for(let t=0;t<o.length;t++)if(o[t]===e)return!0;return!1}function Lae(o){let e=o?.pragma;if(!e)return!1;let t=Array.isArray(e)?e:[e];for(let a=0;a<t.length;a++){let i=t[a];if(typeof i!="string")continue;let r=i.split(",");for(let s=0;s<r.length;s++)if(_ae(r[s]).toLowerCase()==="no-cache")return!0}return!1}function Fae(o,e,{headers:t={}}){return!!(e?.["no-cache"]||o.cacheControlDirectives?.["no-cache"]&&!Array.isArray(o.cacheControlDirectives["no-cache"])||t["if-modified-since"]||t["if-none-match"])}function gw(o,e){return o.cacheControlDirectives?.["must-revalidate"]===!0||e==="shared"&&(o.cacheControlDirectives?.["proxy-revalidate"]===!0||o.cacheControlDirectives?.["s-maxage"]!==void 0)}function Pae(o,e){if(e.vary&&Nae(e.vary))return!0;let t=e["cache-control"];if(!t)return!1;let a=r3(t);return a["no-store"]===!0||o==="shared"&&a.private===!0}function Hae(o){return o["cache-control"]!==void 0}function t3(o,e){try{o.delete(e)?.catch?.(Mm)}catch{}}function Gae(o){let e=o?.["last-modified"];if(typeof e=="string"&&Oae(e))return e}function a3(o,e){let t={...o.headers,"if-modified-since":Gae(e.headers)??new Date(e.cachedAt).toUTCString()};if(e.etag&&(t["if-none-match"]=e.etag),e.vary)for(let a in e.vary)e.vary[a]!=null&&(t[a]=e.vary[a]);return t}function Yae(o,e,t){let a=Date.now();if(a>o.staleAt){if(!gw(o,t)&&e?.["max-stale"]){let i=o.staleAt+e["max-stale"]*1e3;return a>i}return!0}if(e?.["min-fresh"]){let i=o.staleAt-a,r=e["min-fresh"]*1e3;return i<=r}return!1}function Vae(o,e){let t=o.cacheControlDirectives?.["stale-while-revalidate"];if(!t||gw(o,e))return!1;let a=Date.now(),i=o.staleAt+t*1e3;return a<=i}function $ae(o,e,t,a,i,r){if(r?.["only-if-cached"]){let s=!1;try{if(typeof a.onConnect=="function"&&(a.onConnect(()=>{s=!0}),s)||typeof a.onHeaders=="function"&&(a.onHeaders(504,[],Mm,"Gateway Timeout"),s))return;typeof a.onComplete=="function"&&a.onComplete([])}catch(n){typeof a.onError=="function"&&a.onError(n)}return!0}return o(i,new bn(e,t,a))}function dw(o,e,t,a,i,r){let s=Ui.isStream(t.body)?t.body:jae.from(t.body??[]);e3(!s.destroyed,"stream should not be destroyed"),e3(!s.readableDidRead,"stream should not be readableDidRead");let n={resume(){s.resume()},pause(){s.pause()},get paused(){return s.isPaused()},get aborted(){return s.destroyed},get reason(){return s.errored},abort(m){s.destroy(m??new Uae)}};if(s.on("error",function(m){if(!this.readableEnded)if(typeof o.onResponseError=="function")o.onResponseError(n,m);else throw m}).on("close",function(){this.errored||o.onResponseEnd?.(n,{})}),o.onRequestStart?.(n,i),s.destroyed)return;let c={...t.headers,age:String(a)};r&&(c.warning='110 - "response is stale"'),o.onResponseStart?.(n,t.statusCode,c,t.statusMessage),e.method==="HEAD"?s.destroy():s.on("data",function(m){o.onResponseData?.(n,m)})}function i3(o,e,t,a,i,r,s){if(!s)return $ae(o,e,t,a,i,r);let n=Date.now();if(n>s.deleteAt)return o(i,new bn(e,t,a));let c=Math.round((n-s.cachedAt)/1e3),m=r?.["max-age"]!==void 0&&c>=r["max-age"],l=m||Yae(s,r,e.type),u=m||Fae(s,r,i);if(l||u){if(Ui.isStream(i.body)&&Ui.bodyLength(i.body)!==0)return o(i,new bn(e,t,a));if(!u&&Vae(s,e.type))return dw(a,i,s,c,null,!0),queueMicrotask(()=>{let p=a3(i,s);o({...i,headers:p},new bn(e,t,{onRequestStart(){},onRequestUpgrade(){},onResponseStart(){},onResponseData(){},onResponseEnd(){},onResponseError(){}}))}),!0;let d=!1;if(!gw(s,e.type)){let p=s.cacheControlDirectives["stale-if-error"]??r?.["stale-if-error"];p&&(d=n<s.staleAt+p*1e3)}let g=a3(i,s);return o({...i,headers:g},new Qae((p,b,A,k)=>{if(p){if(A===304){if(Pae(e.type,k))return Ui.isStream(s.body)&&s.body.on("error",Mm).destroy(),t3(e.store,t),o(i,new bn(e,t,a));Hae(k)&&t3(e.store,t)}dw(a,i,s,c,b,l)}else Ui.isStream(s.body)&&s.body.on("error",Mm).destroy()},new bn(e,t,a),d))}Ui.isStream(i.body)&&i.body.on("error",Mm).destroy(),dw(a,i,s,c,null,!1)}s3.exports=(o={})=>{let{store:e=new Bae,methods:t=["GET"],cacheByDefault:a=void 0,type:i="shared",origins:r=void 0}=o;if(typeof o!="object"||o===null)throw new TypeError(`expected type of opts to be an Object, got ${o===null?"null":typeof o}`);if(Sae(e,"opts.store"),Dae(t,"opts.methods"),Mae(r,"opts.origins"),typeof a<"u"&&typeof a!="number")throw new TypeError(`expected opts.cacheByDefault to be number or undefined, got ${typeof a}`);if(typeof i<"u"&&i!=="shared"&&i!=="private")throw new TypeError(`expected opts.type to be shared, private, or undefined, got ${typeof i}`);let s={store:e,methods:t,cacheByDefault:a,type:i},n=[];for(let c=0;c<Ui.safeHTTPMethods.length;c++){let m=Ui.safeHTTPMethods[c];o3(t,m)||n.push(m)}return c=>(m,l)=>{if(!m.origin||o3(n,m.method))return c(m,l);if(r!==void 0){let p=m.origin.toString().toLowerCase(),b=!1;for(let A=0;A<r.length;A++){let k=r[A];if(typeof k=="string"){if(k.toLowerCase()===p){b=!0;break}}else if(k.test(p)){b=!0;break}}if(!b)return c(m,l)}m={...m,headers:Rae(m)};let u=m.headers?.["cache-control"]?r3(m.headers["cache-control"]):Lae(m.headers)?{"no-cache":!0}:void 0;if(u?.["no-store"])return c(m,l);let d=Tae(m),g=e.get(d);return g&&typeof g.then=="function"?g.then(p=>i3(c,s,d,l,m,u,p)):i3(c,s,d,l,m,u,g)}}});var d3=y((Ope,u3)=>{"use strict";var{createInflate:pw,createGunzip:c3,createBrotliDecompress:Wae,createZstdDecompress:Jae}=require("zlib"),{pipeline:Kae}=require("stream"),Zae=pn(),{runtimeFeatures:Xae}=Ta(),m3={gzip:c3,"x-gzip":c3,br:Wae,deflate:pw,compress:pw,"x-compress":pw,...Xae.has("zstd")?{zstd:Jae}:{}},eie=[204,304],l3=!1,hw=class extends Zae{#e=[];#o;#a;constructor(e,{skipStatusCodes:t=eie,skipErrorResponses:a=!0}={}){super(e),this.#o=t,this.#a=a}#i(e,t){return!!(!e||t<200||this.#o.includes(t)||this.#a&&t>=400)}#r(e){let t=e.split(","),a=5;if(t.length>a)throw new Error(`too many content-encodings in response: ${t.length}, maximum allowed is ${a}`);let i=[];for(let r=t.length-1;r>=0;r--){let s=t[r].trim();if(s){if(!m3[s])return i.length=0,i;i.push(m3[s]())}}return i}#t(e,t){e.on("readable",()=>{let a;for(;(a=e.read())!==null&&super.onResponseData(t,a)!==!1;);}),e.on("error",a=>{super.onResponseError(t,a)})}#c(e){let t=this.#e[0];this.#t(t,e),t.on("end",()=>{super.onResponseEnd(e,{})})}#s(e){let t=this.#e[this.#e.length-1];this.#t(t,e),Kae(this.#e,a=>{if(a){super.onResponseError(e,a);return}super.onResponseEnd(e,{})})}#n(){this.#e.length=0}onResponseStart(e,t,a,i){let r=a["content-encoding"];if(this.#i(r,t))return super.onResponseStart(e,t,a,i);let s=this.#r(r.toLowerCase());if(s.length===0)return this.#n(),super.onResponseStart(e,t,a,i);this.#e=s;let{"content-encoding":n,"content-length":c,...m}=a;return this.#e.length===1?this.#c(e):this.#s(e),super.onResponseStart(e,t,m,i)}onResponseData(e,t){if(this.#e.length>0){this.#e[0].write(t);return}super.onResponseData(e,t)}onResponseEnd(e,t){if(this.#e.length>0){this.#e[0].end(),this.#n();return}super.onResponseEnd(e,t)}onResponseError(e,t){if(this.#e.length>0){for(let a of this.#e)a.destroy(t);this.#n()}super.onResponseError(e,t)}};function oie(o={}){return l3||(process.emitWarning("DecompressInterceptor is experimental and subject to change","ExperimentalWarning"),l3=!0),e=>(t,a)=>{let i=new hw(a,o);return e(t,i)}}u3.exports=oie});var h3=y((Mpe,p3)=>{"use strict";var{RequestAbortedError:tie}=$(),g3=5*1024*1024,fw=class{#e;#o=[];#a=g3;#i=0;#r={};#t="";#c=!1;#s=!1;#n=!1;#m=!1;#u=null;#l=null;constructor(e,t,a=g3){this.#e=e,this.#l=t,this.#a=a}addWaitingHandler(e){if(this.#m||this.#n)return!1;let t=this.#d(e),a=t.controller;try{if(e.onRequestStart?.(a,null),a.aborted)return t.done=!0,!0;this.#s&&e.onResponseStart?.(a,this.#i,this.#r,this.#t)}catch{return t.done=!0,!0}return a.aborted||this.#o.push(t),!0}onRequestStart(e,t){this.#u=e,this.#e.onRequestStart?.(e,t)}onRequestUpgrade(e,t,a,i){this.#e.onRequestUpgrade?.(e,t,a,i)}onResponseStart(e,t,a,i){this.#s=!0,this.#i=t,this.#r=a,this.#t=i,this.#e.onResponseStart?.(e,t,a,i);for(let r of this.#o){let{handler:s,controller:n}=r;if(r.done||n.aborted){r.done=!0;continue}try{s.onResponseStart?.(n,t,a,i)}catch{}n.aborted&&(r.done=!0)}this.#h()}onResponseData(e,t){if(!(this.#c||this.#m)){this.#n=!0,this.#e.onResponseData?.(e,t);for(let a of this.#o){let{handler:i,controller:r}=a;if(a.done||r.aborted){a.done=!0;continue}if(r.paused){this.#p(a,t);continue}try{i.onResponseData?.(r,t)}catch{}r.aborted&&(a.done=!0,a.bufferedChunks=[],a.bufferedBytes=0)}this.#h()}}onResponseEnd(e,t){if(!(this.#c||this.#m)){this.#m=!0,this.#e.onResponseEnd?.(e,t);for(let a of this.#o){if(a.done||a.controller.aborted){a.done=!0;continue}if(this.#g(a),a.done||a.controller.aborted){a.done=!0;continue}if(a.controller.paused&&a.bufferedChunks.length>0){a.pendingTrailers=t;continue}try{a.handler.onResponseEnd?.(a.controller,t)}catch{}a.done=!0}this.#h(),this.#l?.()}}onResponseError(e,t){if(!this.#m){this.#c=!0,this.#m=!0,this.#e.onResponseError?.(e,t);for(let a of this.#o)this.#b(a,t);this.#o=[],this.#l?.()}}#d(e){let t={handler:e,controller:null,bufferedChunks:[],bufferedBytes:0,pendingTrailers:null,done:!1},a={aborted:!1,paused:!1,reason:null};return t.controller={resume:()=>{if(!a.aborted){if(a.paused=!1,this.#g(t),this.#m&&t.pendingTrailers&&t.bufferedChunks.length===0&&!a.paused&&!a.aborted){try{t.handler.onResponseEnd?.(t.controller,t.pendingTrailers)}catch{}t.pendingTrailers=null,t.done=!0}this.#h()}},pause:()=>{a.aborted||(a.paused=!0)},get paused(){return a.paused},get aborted(){return a.aborted},get reason(){return a.reason},abort:i=>{a.aborted=!0,a.reason=i??null,t.done=!0,t.pendingTrailers=null,t.bufferedChunks=[],t.bufferedBytes=0}},t}#p(e,t){if(e.done||e.controller.aborted){e.done=!0,e.bufferedChunks=[],e.bufferedBytes=0;return}let a=Buffer.from(t);if(e.bufferedChunks.push(a),e.bufferedBytes+=a.length,e.bufferedBytes>this.#a){let i=new tie(`Deduplicated waiting handler exceeded maxBufferSize (${this.#a} bytes) while paused`);this.#b(e,i)}}#g(e){let{handler:t,controller:a}=e;for(;!e.done&&!a.aborted&&!a.paused&&e.bufferedChunks.length>0;){let i=e.bufferedChunks.shift();e.bufferedBytes-=i.length;try{t.onResponseData?.(a,i)}catch{}if(a.aborted){e.done=!0,e.pendingTrailers=null,e.bufferedChunks=[],e.bufferedBytes=0;break}}}#b(e,t){if(!e.done){e.done=!0,e.pendingTrailers=null,e.bufferedChunks=[],e.bufferedBytes=0;try{e.controller.abort(t),e.handler.onResponseError?.(e.controller,t)}catch{}}}#h(){this.#o=this.#o.filter(e=>e.done===!1)}};p3.exports=fw});var b3=y((_pe,f3)=>{"use strict";var aie=require("diagnostics_channel"),iie=K(),rie=h3(),{normalizeHeaders:sie,makeCacheKey:nie,makeDeduplicationKey:cie}=hn(),sg=aie.channel("undici:request:pending-requests");f3.exports=(o={})=>{let{methods:e=["GET"],skipHeaderNames:t=[],excludeHeaderNames:a=[],maxBufferSize:i=5*1024*1024}=o;if(typeof o!="object"||o===null)throw new TypeError(`expected type of opts to be an Object, got ${o===null?"null":typeof o}`);if(!Array.isArray(e))throw new TypeError(`expected opts.methods to be an array, got ${typeof e}`);for(let c of e)if(!iie.safeHTTPMethods.includes(c))throw new TypeError(`expected opts.methods to only contain safe HTTP methods, got ${c}`);if(!Array.isArray(t))throw new TypeError(`expected opts.skipHeaderNames to be an array, got ${typeof t}`);if(!Array.isArray(a))throw new TypeError(`expected opts.excludeHeaderNames to be an array, got ${typeof a}`);if(!Number.isFinite(i)||i<=0)throw new TypeError(`expected opts.maxBufferSize to be a positive finite number, got ${i}`);let r=new Set(t.map(c=>c.toLowerCase())),s=new Set(a.map(c=>c.toLowerCase())),n=new Map;return c=>(m,l)=>{if(!m.origin||e.includes(m.method)===!1)return c(m,l);if(m={...m,headers:sie(m)},r.size>0){for(let b of Object.keys(m.headers))if(r.has(b.toLowerCase()))return c(m,l)}let u=nie(m),d=cie(u,s),g=n.get(d);if(g)return g.addWaitingHandler(l)?!0:c(m,l);let p=new rie(l,()=>{n.delete(d),sg.hasSubscribers&&sg.publish({size:n.size,key:d,type:"removed"})},i);return n.set(d,p),sg.hasSubscribers&&sg.publish({size:n.size,key:d,type:"added"}),c(m,p)}}});var A3=y((Fpe,k3)=>{"use strict";var{Writable:mie}=require("stream"),{assertCacheKey:bw,assertCacheValue:lie}=hn(),yw,Zo=3,y3=2*1e3*1e3*1e3;k3.exports=class{#e=y3;#o=1/0;#a;#i;#r;#t;#c;#s;#n;#m;constructor(e){if(e){if(typeof e!="object")throw new TypeError("SqliteCacheStore options must be an object");if(e.maxEntrySize!==void 0){if(typeof e.maxEntrySize!="number"||!Number.isInteger(e.maxEntrySize)||e.maxEntrySize<0)throw new TypeError("SqliteCacheStore options.maxEntrySize must be a non-negative integer");if(e.maxEntrySize>y3)throw new TypeError("SqliteCacheStore options.maxEntrySize must be less than 2gb");this.#e=e.maxEntrySize}if(e.maxCount!==void 0){if(typeof e.maxCount!="number"||!Number.isInteger(e.maxCount)||e.maxCount<0)throw new TypeError("SqliteCacheStore options.maxCount must be a non-negative integer");this.#o=e.maxCount}}yw||(yw=require("sqlite").DatabaseSync),this.#a=new yw(e?.location??":memory:"),this.#a.exec(`
1326
1332
  PRAGMA journal_mode = WAL;
1327
1333
  PRAGMA synchronous = NORMAL;
1328
1334
  PRAGMA temp_store = memory;
@@ -1406,12 +1412,12 @@ ${e.format(t)}`.trim())}};YQ.exports=_A});var FA=y((Ape,JQ)=>{"use strict";var{I
1406
1412
  LIMIT ?
1407
1413
  )
1408
1414
  `)}close(){this.#a.close()}get(e){bw(e);let t=this.#d(e);return t?{body:t.body?Buffer.from(t.body.buffer,t.body.byteOffset,t.body.byteLength):void 0,statusCode:t.statusCode,statusMessage:t.statusMessage,headers:t.headers?JSON.parse(t.headers):void 0,etag:t.etag?t.etag:void 0,vary:t.vary?JSON.parse(t.vary):void 0,cacheControlDirectives:t.cacheControlDirectives?JSON.parse(t.cacheControlDirectives):void 0,cachedAt:t.cachedAt,staleAt:t.staleAt,deleteAt:t.deleteAt}:void 0}set(e,t){bw(e);let a=this.#l(e),i=Array.isArray(t.body)?Buffer.concat(t.body):t.body,r=i?.byteLength;if(r&&r>this.#e)return;let s=this.#d(e,!0);s?this.#r.run(i,t.deleteAt,t.statusCode,t.statusMessage,t.headers?JSON.stringify(t.headers):null,t.etag?t.etag:null,t.cacheControlDirectives?JSON.stringify(t.cacheControlDirectives):null,t.cachedAt,t.staleAt,s.id):(this.#t.run(a,e.method,i,t.deleteAt,t.statusCode,t.statusMessage,t.headers?JSON.stringify(t.headers):null,t.etag?t.etag:null,t.cacheControlDirectives?JSON.stringify(t.cacheControlDirectives):null,t.vary?JSON.stringify(t.vary):null,t.cachedAt,t.staleAt),this.#u())}createWriteStream(e,t){bw(e),lie(t);let a=0,i=[],r=this;return new mie({decodeStrings:!0,write(s,n,c){a+=s.byteLength,a<r.#e?i.push(s):this.destroy(),c()},final(s){r.set(e,{...t,body:i}),s()}})}delete(e){if(typeof e!="object")throw new TypeError(`expected key to be object, got ${typeof e}`);this.#s.run(this.#l(e))}#u(){if(Number.isFinite(this.#o)&&this.size<=this.#o)return 0;{let e=this.#c.run(Date.now()).changes;if(e)return e}{let e=this.#m?.run(Math.max(Math.floor(this.#o*.1),1)).changes;if(e)return e}return 0}get size(){let{total:e}=this.#n.get();return e}#l(e){return`${e.origin}/${e.path}`}#d(e,t=!1){let a=this.#l(e),{headers:i,method:r}=e,s=this.#i.all(a,r);if(s.length===0)return;let n=Date.now();for(let c of s){if(n>=c.deleteAt&&!t)continue;let m=!0;if(c.vary){let l=JSON.parse(c.vary);for(let u in l)if(!uie(i[u],l[u])){m=!1;break}}if(m)return c}}};function uie(o,e){if(o==null&&e==null)return!0;if(o==null&&e!=null||o!=null&&e==null)return!1;if(Array.isArray(o)&&Array.isArray(e)){if(o.length!==e.length)return!1;for(let t=0;t<o.length;t++)if(o[t]!==e[t])return!1;return!0}return o===e}});var $r=y((Ppe,I3)=>{"use strict";var{kConstruct:die}=de(),{kEnumerableProperty:yn}=K(),{iteratorMixin:gie,isValidHeaderName:_m,isValidHeaderValue:v3}=Vo(),{webidl:se}=to(),kw=require("assert"),ng=require("util");function w3(o){return o===10||o===13||o===9||o===32}function x3(o){let e=0,t=o.length;for(;t>e&&w3(o.charCodeAt(t-1));)--t;for(;t>e&&w3(o.charCodeAt(e));)++e;return e===0&&t===o.length?o:o.substring(e,t)}function z3(o,e){if(Array.isArray(e))for(let t=0;t<e.length;++t){let a=e[t];if(a.length!==2)throw se.errors.exception({header:"Headers constructor",message:`expected name/value pair to be length 2, found ${a.length}.`});Aw(o,a[0],a[1])}else if(typeof e=="object"&&e!==null){let t=Object.keys(e);for(let a=0;a<t.length;++a)Aw(o,t[a],e[t[a]])}else throw se.errors.conversionFailed({prefix:"Headers constructor",argument:"Argument 1",types:["sequence<sequence<ByteString>>","record<ByteString, ByteString>"]})}function Aw(o,e,t){if(t=x3(t),_m(e)){if(!v3(t))throw se.errors.invalidArgument({prefix:"Headers.append",value:t,type:"header value"})}else throw se.errors.invalidArgument({prefix:"Headers.append",value:e,type:"header name"});if(E3(o)==="immutable")throw new TypeError("immutable");return mg(o).append(e,t,!1)}function pie(o){let e=mg(o);if(!e)return[];if(e.sortedMap)return e.sortedMap;let t=[],a=e.toSortedArray(),i=e.cookies;if(i===null||i.length===1)return e.sortedMap=a;for(let r=0;r<a.length;++r){let{0:s,1:n}=a[r];if(s==="set-cookie")for(let c=0;c<i.length;++c)t.push([s,i[c]]);else t.push([s,n])}return e.sortedMap=t}function q3(o,e){return o[0]<e[0]?-1:1}var cg=class o{cookies=null;sortedMap;headersMap;constructor(e){e instanceof o?(this.headersMap=new Map(e.headersMap),this.sortedMap=e.sortedMap,this.cookies=e.cookies===null?null:[...e.cookies]):(this.headersMap=new Map(e),this.sortedMap=null)}contains(e,t){return this.headersMap.has(t?e:e.toLowerCase())}clear(){this.headersMap.clear(),this.sortedMap=null,this.cookies=null}append(e,t,a){this.sortedMap=null;let i=a?e:e.toLowerCase(),r=this.headersMap.get(i);if(r){let s=i==="cookie"?"; ":", ";this.headersMap.set(i,{name:r.name,value:`${r.value}${s}${t}`})}else this.headersMap.set(i,{name:e,value:t});i==="set-cookie"&&(this.cookies??=[]).push(t)}set(e,t,a){this.sortedMap=null;let i=a?e:e.toLowerCase();i==="set-cookie"&&(this.cookies=[t]),this.headersMap.set(i,{name:e,value:t})}delete(e,t){this.sortedMap=null,t||(e=e.toLowerCase()),e==="set-cookie"&&(this.cookies=null),this.headersMap.delete(e)}get(e,t){return this.headersMap.get(t?e:e.toLowerCase())?.value??null}*[Symbol.iterator](){for(let{0:e,1:{value:t}}of this.headersMap)yield[e,t]}get entries(){let e={};if(this.headersMap.size!==0)for(let{name:t,value:a}of this.headersMap.values())e[t]=a;return e}rawValues(){return this.headersMap.values()}get entriesList(){let e=[];if(this.headersMap.size!==0)for(let{0:t,1:{name:a,value:i}}of this.headersMap)if(t==="set-cookie")for(let r of this.cookies)e.push([a,r]);else e.push([a,i]);return e}toSortedArray(){let e=this.headersMap.size,t=new Array(e);if(e<=32){if(e===0)return t;let a=this.headersMap[Symbol.iterator](),i=a.next().value;t[0]=[i[0],i[1].value],kw(i[1].value!==null);for(let r=1,s=0,n=0,c=0,m=0,l,u;r<e;++r){for(u=a.next().value,l=t[r]=[u[0],u[1].value],kw(l[1]!==null),c=0,n=r;c<n;)m=c+(n-c>>1),t[m][0]<=l[0]?c=m+1:n=m;if(r!==m){for(s=r;s>c;)t[s]=t[--s];t[c]=l}}if(!a.next().done)throw new TypeError("Unreachable");return t}else{let a=0;for(let{0:i,1:{value:r}}of this.headersMap)t[a++]=[i,r],kw(r!==null);return t.sort(q3)}}},Ft=class o{#e;#o;constructor(e=void 0){se.util.markAsUncloneable(this),e!==die&&(this.#o=new cg,this.#e="none",e!==void 0&&(e=se.converters.HeadersInit(e,"Headers constructor","init"),z3(this,e)))}append(e,t){se.brandCheck(this,o),se.argumentLengthCheck(arguments,2,"Headers.append");let a="Headers.append";return e=se.converters.ByteString(e,a,"name"),t=se.converters.ByteString(t,a,"value"),Aw(this,e,t)}delete(e){if(se.brandCheck(this,o),se.argumentLengthCheck(arguments,1,"Headers.delete"),e=se.converters.ByteString(e,"Headers.delete","name"),!_m(e))throw se.errors.invalidArgument({prefix:"Headers.delete",value:e,type:"header name"});if(this.#e==="immutable")throw new TypeError("immutable");this.#o.contains(e,!1)&&this.#o.delete(e,!1)}get(e){se.brandCheck(this,o),se.argumentLengthCheck(arguments,1,"Headers.get");let t="Headers.get";if(e=se.converters.ByteString(e,t,"name"),!_m(e))throw se.errors.invalidArgument({prefix:t,value:e,type:"header name"});return this.#o.get(e,!1)}has(e){se.brandCheck(this,o),se.argumentLengthCheck(arguments,1,"Headers.has");let t="Headers.has";if(e=se.converters.ByteString(e,t,"name"),!_m(e))throw se.errors.invalidArgument({prefix:t,value:e,type:"header name"});return this.#o.contains(e,!1)}set(e,t){se.brandCheck(this,o),se.argumentLengthCheck(arguments,2,"Headers.set");let a="Headers.set";if(e=se.converters.ByteString(e,a,"name"),t=se.converters.ByteString(t,a,"value"),t=x3(t),_m(e)){if(!v3(t))throw se.errors.invalidArgument({prefix:a,value:t,type:"header value"})}else throw se.errors.invalidArgument({prefix:a,value:e,type:"header name"});if(this.#e==="immutable")throw new TypeError("immutable");this.#o.set(e,t,!1)}getSetCookie(){se.brandCheck(this,o);let e=this.#o.cookies;return e?[...e]:[]}[ng.inspect.custom](e,t){return t.depth??=e,`Headers ${ng.formatWithOptions(t,this.#o.entries)}`}static getHeadersGuard(e){return e.#e}static setHeadersGuard(e,t){e.#e=t}static getHeadersList(e){return e.#o}static setHeadersList(e,t){e.#o=t}},{getHeadersGuard:E3,setHeadersGuard:hie,getHeadersList:mg,setHeadersList:fie}=Ft;Reflect.deleteProperty(Ft,"getHeadersGuard");Reflect.deleteProperty(Ft,"setHeadersGuard");Reflect.deleteProperty(Ft,"getHeadersList");Reflect.deleteProperty(Ft,"setHeadersList");gie("Headers",Ft,pie,0,1);Object.defineProperties(Ft.prototype,{append:yn,delete:yn,get:yn,has:yn,set:yn,getSetCookie:yn,[Symbol.toStringTag]:{value:"Headers",configurable:!0},[ng.inspect.custom]:{enumerable:!1}});se.converters.HeadersInit=function(o,e,t){if(se.util.Type(o)===se.util.Types.OBJECT){let a=Reflect.get(o,Symbol.iterator);if(!ng.types.isProxy(o)&&a===Ft.prototype.entries)try{return mg(o).entriesList}catch{}return typeof a=="function"?se.converters["sequence<sequence<ByteString>>"](o,e,t,a.bind(o)):se.converters["record<ByteString, ByteString>"](o,e,t)}throw se.errors.conversionFailed({prefix:"Headers constructor",argument:"Argument 1",types:["sequence<sequence<ByteString>>","record<ByteString, ByteString>"]})};I3.exports={fill:z3,compareHeaderName:q3,Headers:Ft,HeadersList:cg,getHeadersGuard:E3,setHeadersGuard:hie,setHeadersList:fie,getHeadersList:mg}});var Fm=y((Hpe,M3)=>{"use strict";var{Headers:D3,HeadersList:C3,fill:bie,getHeadersGuard:yie,setHeadersGuard:T3,setHeadersList:R3}=$r(),{extractBody:j3,cloneBody:kie,mixinBody:Aie,streamRegistry:N3,bodyUnusable:wie}=$s(),U3=K(),B3=require("util"),{kEnumerableProperty:Xo}=U3,{isValidReasonPhrase:vie,isCancelled:xie,isAborted:zie,isErrorLike:qie,environmentSettingsObject:Eie}=Vo(),{redirectStatusSet:Iie,nullBodyStatus:Cie}=Xc(),{webidl:ae}=to(),{URLSerializer:Q3}=bt(),{kConstruct:ug}=de(),ww=require("assert"),{isomorphicEncode:jie,serializeJavascriptValueToJSONString:Bie}=Da(),Qie=new TextEncoder("utf-8"),et=class o{#e;#o;static error(){return Lm(dg(),"immutable")}static json(e,t=void 0){ae.argumentLengthCheck(arguments,1,"Response.json"),t!==null&&(t=ae.converters.ResponseInit(t));let a=Qie.encode(Bie(e)),i=j3(a),r=Lm(kn({}),"response");return S3(r,t,{body:i[0],type:"application/json"}),r}static redirect(e,t=302){ae.argumentLengthCheck(arguments,1,"Response.redirect"),e=ae.converters.USVString(e),t=ae.converters["unsigned short"](t);let a;try{a=new URL(e,Eie.settingsObject.baseUrl)}catch(s){throw new TypeError(`Failed to parse URL from ${e}`,{cause:s})}if(!Iie.has(t))throw new RangeError(`Invalid status code ${t}`);let i=Lm(kn({}),"immutable");i.#o.status=t;let r=jie(Q3(a));return i.#o.headersList.append("location",r,!0),i}constructor(e=null,t=void 0){if(ae.util.markAsUncloneable(this),e===ug)return;e!==null&&(e=ae.converters.BodyInit(e,"Response","body")),t=ae.converters.ResponseInit(t),this.#o=kn({}),this.#e=new D3(ug),T3(this.#e,"response"),R3(this.#e,this.#o.headersList);let a=null;if(e!=null){let[i,r]=j3(e);a={body:i,type:r}}S3(this,t,a)}get type(){return ae.brandCheck(this,o),this.#o.type}get url(){ae.brandCheck(this,o);let e=this.#o.urlList,t=e[e.length-1]??null;return t===null?"":Q3(t,!0)}get redirected(){return ae.brandCheck(this,o),this.#o.urlList.length>1}get status(){return ae.brandCheck(this,o),this.#o.status}get ok(){return ae.brandCheck(this,o),this.#o.status>=200&&this.#o.status<=299}get statusText(){return ae.brandCheck(this,o),this.#o.statusText}get headers(){return ae.brandCheck(this,o),this.#e}get body(){return ae.brandCheck(this,o),this.#o.body?this.#o.body.stream:null}get bodyUsed(){return ae.brandCheck(this,o),!!this.#o.body&&U3.isDisturbed(this.#o.body.stream)}clone(){if(ae.brandCheck(this,o),wie(this.#o))throw ae.errors.exception({header:"Response.clone",message:"Body has already been consumed."});let e=vw(this.#o);return this.#o.urlList.length!==0&&this.#o.body?.stream&&N3.register(this,new WeakRef(this.#o.body.stream)),Lm(e,yie(this.#e))}[B3.inspect.custom](e,t){t.depth===null&&(t.depth=2),t.colors??=!0;let a={status:this.status,statusText:this.statusText,headers:this.headers,body:this.body,bodyUsed:this.bodyUsed,ok:this.ok,redirected:this.redirected,type:this.type,url:this.url};return`Response ${B3.formatWithOptions(t,a)}`}static getResponseHeaders(e){return e.#e}static setResponseHeaders(e,t){e.#e=t}static getResponseState(e){return e.#o}static setResponseState(e,t){e.#o=t}},{getResponseHeaders:Sie,setResponseHeaders:Die,getResponseState:Wr,setResponseState:Tie}=et;Reflect.deleteProperty(et,"getResponseHeaders");Reflect.deleteProperty(et,"setResponseHeaders");Reflect.deleteProperty(et,"getResponseState");Reflect.deleteProperty(et,"setResponseState");Aie(et,Wr);Object.defineProperties(et.prototype,{type:Xo,url:Xo,status:Xo,ok:Xo,redirected:Xo,statusText:Xo,headers:Xo,clone:Xo,body:Xo,bodyUsed:Xo,[Symbol.toStringTag]:{value:"Response",configurable:!0}});Object.defineProperties(et,{json:Xo,redirect:Xo,error:Xo});function vw(o){if(o.internalResponse)return O3(vw(o.internalResponse),o.type);let e=kn({...o,body:null});return o.body!=null&&(e.body=kie(o.body)),e}function kn(o){return{aborted:!1,rangeRequested:!1,timingAllowPassed:!1,requestIncludesCredentials:!1,type:"default",status:200,timingInfo:null,cacheState:"",statusText:"",...o,headersList:o?.headersList?new C3(o?.headersList):new C3,urlList:o?.urlList?[...o.urlList]:[]}}function dg(o){let e=qie(o);return kn({type:"error",status:0,error:e?o:new Error(o&&String(o)),aborted:o&&o.name==="AbortError"})}function Rie(o){return o.type==="error"&&o.status===0}function lg(o,e){return e={internalResponse:o,...e},new Proxy(o,{get(t,a){return a in e?e[a]:t[a]},set(t,a,i){return ww(!(a in e)),t[a]=i,!0}})}function O3(o,e){if(e==="basic")return lg(o,{type:"basic",headersList:o.headersList});if(e==="cors")return lg(o,{type:"cors",headersList:o.headersList});if(e==="opaque")return lg(o,{type:"opaque",urlList:[],status:0,statusText:"",body:null});if(e==="opaqueredirect")return lg(o,{type:"opaqueredirect",status:0,statusText:"",headersList:[],body:null});ww(!1)}function Nie(o,e=null){return ww(xie(o)),zie(o)?dg(Object.assign(new DOMException("The operation was aborted.","AbortError"),{cause:e})):dg(Object.assign(new DOMException("Request was cancelled."),{cause:e}))}function S3(o,e,t){if(e.status!==null&&(e.status<200||e.status>599))throw new RangeError('init["status"] must be in the range of 200 to 599, inclusive.');if("statusText"in e&&e.statusText!=null&&!vie(String(e.statusText)))throw new TypeError("Invalid statusText");if("status"in e&&e.status!=null&&(Wr(o).status=e.status),"statusText"in e&&e.statusText!=null&&(Wr(o).statusText=e.statusText),"headers"in e&&e.headers!=null&&bie(Sie(o),e.headers),t){if(Cie.includes(o.status))throw ae.errors.exception({header:"Response constructor",message:`Invalid response status code ${o.status}`});Wr(o).body=t.body,t.type!=null&&!Wr(o).headersList.contains("content-type",!0)&&Wr(o).headersList.append("content-type",t.type,!0)}}function Lm(o,e){let t=new et(ug);Tie(t,o);let a=new D3(ug);return Die(t,a),R3(a,o.headersList),T3(a,e),o.urlList.length!==0&&o.body?.stream&&N3.register(t,new WeakRef(o.body.stream)),t}ae.converters.XMLHttpRequestBodyInit=function(o,e,t){return typeof o=="string"?ae.converters.USVString(o,e,t):ae.is.Blob(o)||ae.is.BufferSource(o)||ae.is.FormData(o)||ae.is.URLSearchParams(o)?o:ae.converters.DOMString(o,e,t)};ae.converters.BodyInit=function(o,e,t){return ae.is.ReadableStream(o)||o?.[Symbol.asyncIterator]?o:ae.converters.XMLHttpRequestBodyInit(o,e,t)};ae.converters.ResponseInit=ae.dictionaryConverter([{key:"status",converter:ae.converters["unsigned short"],defaultValue:()=>200},{key:"statusText",converter:ae.converters.ByteString,defaultValue:()=>""},{key:"headers",converter:ae.converters.HeadersInit}]);ae.is.Response=ae.util.MakeTypeAssertion(et);M3.exports={isNetworkError:Rie,makeNetworkError:dg,makeResponse:kn,makeAppropriateNetworkError:Nie,filterResponse:O3,Response:et,cloneResponse:vw,fromInnerResponse:Lm,getResponseState:Wr}});var An=y((Gpe,X3)=>{"use strict";var{extractBody:Uie,mixinBody:Oie,cloneBody:Mie,bodyUnusable:_3}=$s(),{Headers:Y3,fill:_ie,HeadersList:hg,setHeadersGuard:xw,getHeadersGuard:Lie,setHeadersList:V3,getHeadersList:L3}=$r(),pg=K(),F3=require("util"),{isValidHTTPToken:Fie,sameOrigin:P3,environmentSettingsObject:gg}=Vo(),{forbiddenMethodsSet:Pie,corsSafeListedMethodsSet:Hie,referrerPolicy:Gie,requestRedirect:Yie,requestMode:Vie,requestCredentials:$ie,requestCache:Wie,requestDuplex:Jie}=Xc(),{kEnumerableProperty:Le,normalizedMethodRecordsBase:Kie,normalizedMethodRecords:Zie}=pg,{webidl:H}=to(),{URLSerializer:Xie}=bt(),{kConstruct:fg}=de(),ere=require("assert"),{getMaxListeners:$3,setMaxListeners:ore,defaultMaxListeners:tre}=require("events"),are=Symbol("abortController"),W3=new FinalizationRegistry(({signal:o,abort:e})=>{o.removeEventListener("abort",e)}),bg=new WeakMap,zw;try{zw=$3(new AbortController().signal)>0}catch{zw=!1}function H3(o){return e;function e(){let t=o.deref();if(t!==void 0){W3.unregister(e),this.removeEventListener("abort",e),t.abort(this.reason);let a=bg.get(t.signal);if(a!==void 0){if(a.size!==0){for(let i of a){let r=i.deref();r!==void 0&&r.abort(this.reason)}a.clear()}bg.delete(t.signal)}}}}var G3=!1,So=class o{#e;#o;#a;#i;constructor(e,t=void 0){if(H.util.markAsUncloneable(this),e===fg)return;H.argumentLengthCheck(arguments,1,"Request constructor"),e=H.converters.RequestInfo(e),t=H.converters.RequestInit(t);let i=null,r=null,s=gg.settingsObject.baseUrl,n=null;if(typeof e=="string"){this.#o=t.dispatcher;let k;try{k=new URL(e,s)}catch(x){throw new TypeError("Failed to parse URL from "+e,{cause:x})}if(k.username||k.password)throw new TypeError("Request cannot be constructed from a URL that includes credentials: "+e);i=yg({urlList:[k]}),r="cors"}else ere(H.is.Request(e)),i=e.#i,n=e.#e,this.#o=t.dispatcher||e.#o;let c=gg.settingsObject.origin,m="client";if(i.window?.constructor?.name==="EnvironmentSettingsObject"&&P3(i.window,c)&&(m=i.window),t.window!=null)throw new TypeError(`'window' option '${m}' must be null`);"window"in t&&(m="no-window"),i=yg({method:i.method,headersList:i.headersList,unsafeRequest:i.unsafeRequest,client:gg.settingsObject,window:m,priority:i.priority,origin:i.origin,referrer:i.referrer,referrerPolicy:i.referrerPolicy,mode:i.mode,credentials:i.credentials,cache:i.cache,redirect:i.redirect,integrity:i.integrity,keepalive:i.keepalive,reloadNavigation:i.reloadNavigation,historyNavigation:i.historyNavigation,urlList:[...i.urlList]});let l=Object.keys(t).length!==0;if(l&&(i.mode==="navigate"&&(i.mode="same-origin"),i.reloadNavigation=!1,i.historyNavigation=!1,i.origin="client",i.referrer="client",i.referrerPolicy="",i.url=i.urlList[i.urlList.length-1],i.urlList=[i.url]),t.referrer!==void 0){let k=t.referrer;if(k==="")i.referrer="no-referrer";else{let x;try{x=new URL(k,s)}catch(v){throw new TypeError(`Referrer "${k}" is not a valid URL.`,{cause:v})}x.protocol==="about:"&&x.hostname==="client"||c&&!P3(x,gg.settingsObject.baseUrl)?i.referrer="client":i.referrer=x}}t.referrerPolicy!==void 0&&(i.referrerPolicy=t.referrerPolicy);let u;if(t.mode!==void 0?u=t.mode:u=r,u==="navigate")throw H.errors.exception({header:"Request constructor",message:"invalid request mode navigate."});if(u!=null&&(i.mode=u),t.credentials!==void 0&&(i.credentials=t.credentials),t.cache!==void 0&&(i.cache=t.cache),i.cache==="only-if-cached"&&i.mode!=="same-origin")throw new TypeError("'only-if-cached' can be set only with 'same-origin' mode");if(t.redirect!==void 0&&(i.redirect=t.redirect),t.integrity!=null&&(i.integrity=String(t.integrity)),t.keepalive!==void 0&&(i.keepalive=!!t.keepalive),t.method!==void 0){let k=t.method,x=Zie[k];if(x!==void 0)i.method=x;else{if(!Fie(k))throw new TypeError(`'${k}' is not a valid HTTP method.`);let v=k.toUpperCase();if(Pie.has(v))throw new TypeError(`'${k}' HTTP method is unsupported.`);k=Kie[v]??k,i.method=k}!G3&&i.method==="patch"&&(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"}),G3=!0)}t.signal!==void 0&&(n=t.signal),this.#i=i;let d=new AbortController;if(this.#e=d.signal,n!=null)if(n.aborted)d.abort(n.reason);else{this[are]=d;let k=new WeakRef(d),x=H3(k);zw&&$3(n)===tre&&ore(1500,n),pg.addAbortListener(n,x),W3.register(d,{signal:n,abort:x},x)}if(this.#a=new Y3(fg),V3(this.#a,i.headersList),xw(this.#a,"request"),u==="no-cors"){if(!Hie.has(i.method))throw new TypeError(`'${i.method} is unsupported in no-cors mode.`);xw(this.#a,"request-no-cors")}if(l){let k=L3(this.#a),x=t.headers!==void 0?t.headers:new hg(k);if(k.clear(),x instanceof hg){for(let{name:v,value:j}of x.rawValues())k.append(v,j,!1);k.cookies=x.cookies}else _ie(this.#a,x)}let g=H.is.Request(e)?e.#i.body:null;if((t.body!=null||g!=null)&&(i.method==="GET"||i.method==="HEAD"))throw new TypeError("Request with GET/HEAD method cannot have body.");let p=null;if(t.body!=null){let[k,x]=Uie(t.body,i.keepalive);p=k,x&&!L3(this.#a).contains("content-type",!0)&&this.#a.append("content-type",x,!0)}let b=p??g;if(b!=null&&b.source==null){if(p!=null&&t.duplex==null)throw new TypeError("RequestInit: duplex option is required when sending a body.");if(i.mode!=="same-origin"&&i.mode!=="cors")throw new TypeError('If request is made from ReadableStream, mode should be "same-origin" or "cors"');i.useCORSPreflightFlag=!0}let A=b;if(p==null&&g!=null){if(_3(e.#i))throw new TypeError("Cannot construct a Request with a Request object that has already been used.");let k=new TransformStream;g.stream.pipeThrough(k),A={source:g.source,length:g.length,stream:k.readable}}this.#i.body=A}get method(){return H.brandCheck(this,o),this.#i.method}get url(){return H.brandCheck(this,o),Xie(this.#i.url)}get headers(){return H.brandCheck(this,o),this.#a}get destination(){return H.brandCheck(this,o),this.#i.destination}get referrer(){return H.brandCheck(this,o),this.#i.referrer==="no-referrer"?"":this.#i.referrer==="client"?"about:client":this.#i.referrer.toString()}get referrerPolicy(){return H.brandCheck(this,o),this.#i.referrerPolicy}get mode(){return H.brandCheck(this,o),this.#i.mode}get credentials(){return H.brandCheck(this,o),this.#i.credentials}get cache(){return H.brandCheck(this,o),this.#i.cache}get redirect(){return H.brandCheck(this,o),this.#i.redirect}get integrity(){return H.brandCheck(this,o),this.#i.integrity}get keepalive(){return H.brandCheck(this,o),this.#i.keepalive}get isReloadNavigation(){return H.brandCheck(this,o),this.#i.reloadNavigation}get isHistoryNavigation(){return H.brandCheck(this,o),this.#i.historyNavigation}get signal(){return H.brandCheck(this,o),this.#e}get body(){return H.brandCheck(this,o),this.#i.body?this.#i.body.stream:null}get bodyUsed(){return H.brandCheck(this,o),!!this.#i.body&&pg.isDisturbed(this.#i.body.stream)}get duplex(){return H.brandCheck(this,o),"half"}clone(){if(H.brandCheck(this,o),_3(this.#i))throw new TypeError("unusable");let e=K3(this.#i),t=new AbortController;if(this.signal.aborted)t.abort(this.signal.reason);else{let a=bg.get(this.signal);a===void 0&&(a=new Set,bg.set(this.signal,a));let i=new WeakRef(t);a.add(i),pg.addAbortListener(t.signal,H3(i))}return Z3(e,this.#o,t.signal,Lie(this.#a))}[F3.inspect.custom](e,t){t.depth===null&&(t.depth=2),t.colors??=!0;let a={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 ${F3.formatWithOptions(t,a)}`}static setRequestSignal(e,t){return e.#e=t,e}static getRequestDispatcher(e){return e.#o}static setRequestDispatcher(e,t){e.#o=t}static setRequestHeaders(e,t){e.#a=t}static getRequestState(e){return e.#i}static setRequestState(e,t){e.#i=t}},{setRequestSignal:ire,getRequestDispatcher:rre,setRequestDispatcher:sre,setRequestHeaders:nre,getRequestState:J3,setRequestState:cre}=So;Reflect.deleteProperty(So,"setRequestSignal");Reflect.deleteProperty(So,"getRequestDispatcher");Reflect.deleteProperty(So,"setRequestDispatcher");Reflect.deleteProperty(So,"setRequestHeaders");Reflect.deleteProperty(So,"getRequestState");Reflect.deleteProperty(So,"setRequestState");Oie(So,J3);function yg(o){return{method:o.method??"GET",localURLsOnly:o.localURLsOnly??!1,unsafeRequest:o.unsafeRequest??!1,body:o.body??null,client:o.client??null,reservedClient:o.reservedClient??null,replacesClientId:o.replacesClientId??"",window:o.window??"client",keepalive:o.keepalive??!1,serviceWorkers:o.serviceWorkers??"all",initiator:o.initiator??"",destination:o.destination??"",priority:o.priority??null,origin:o.origin??"client",policyContainer:o.policyContainer??"client",referrer:o.referrer??"client",referrerPolicy:o.referrerPolicy??"",mode:o.mode??"no-cors",useCORSPreflightFlag:o.useCORSPreflightFlag??!1,credentials:o.credentials??"same-origin",useCredentials:o.useCredentials??!1,cache:o.cache??"default",redirect:o.redirect??"follow",integrity:o.integrity??"",cryptoGraphicsNonceMetadata:o.cryptoGraphicsNonceMetadata??"",parserMetadata:o.parserMetadata??"",reloadNavigation:o.reloadNavigation??!1,historyNavigation:o.historyNavigation??!1,userActivation:o.userActivation??!1,taintedOrigin:o.taintedOrigin??!1,redirectCount:o.redirectCount??0,responseTainting:o.responseTainting??"basic",preventNoCacheCacheControlHeaderModification:o.preventNoCacheCacheControlHeaderModification??!1,done:o.done??!1,timingAllowFailed:o.timingAllowFailed??!1,useURLCredentials:o.useURLCredentials??void 0,traversableForUserPrompts:o.traversableForUserPrompts??"client",urlList:o.urlList,url:o.urlList[0],headersList:o.headersList?new hg(o.headersList):new hg}}function K3(o){let e=yg({...o,body:null});return o.body!=null&&(e.body=Mie(o.body)),e}function Z3(o,e,t,a){let i=new So(fg);cre(i,o),sre(i,e),ire(i,t);let r=new Y3(fg);return nre(i,r),V3(r,o.headersList),xw(r,a),i}Object.defineProperties(So.prototype,{method:Le,url:Le,headers:Le,redirect:Le,clone:Le,signal:Le,duplex:Le,destination:Le,body:Le,bodyUsed:Le,isHistoryNavigation:Le,isReloadNavigation:Le,keepalive:Le,integrity:Le,cache:Le,credentials:Le,attribute:Le,referrerPolicy:Le,referrer:Le,mode:Le,[Symbol.toStringTag]:{value:"Request",configurable:!0}});H.is.Request=H.util.MakeTypeAssertion(So);H.converters.RequestInfo=function(o){return typeof o=="string"?H.converters.USVString(o):H.is.Request(o)?o:H.converters.USVString(o)};H.converters.RequestInit=H.dictionaryConverter([{key:"method",converter:H.converters.ByteString},{key:"headers",converter:H.converters.HeadersInit},{key:"body",converter:H.nullableConverter(H.converters.BodyInit)},{key:"referrer",converter:H.converters.USVString},{key:"referrerPolicy",converter:H.converters.DOMString,allowedValues:Gie},{key:"mode",converter:H.converters.DOMString,allowedValues:Vie},{key:"credentials",converter:H.converters.DOMString,allowedValues:$ie},{key:"cache",converter:H.converters.DOMString,allowedValues:Wie},{key:"redirect",converter:H.converters.DOMString,allowedValues:Yie},{key:"integrity",converter:H.converters.DOMString},{key:"keepalive",converter:H.converters.boolean},{key:"signal",converter:H.nullableConverter(o=>H.converters.AbortSignal(o,"RequestInit","signal"))},{key:"window",converter:H.converters.any},{key:"duplex",converter:H.converters.DOMString,allowedValues:Jie},{key:"dispatcher",converter:H.converters.any},{key:"priority",converter:H.converters.DOMString,allowedValues:["high","low","auto"],defaultValue:()=>"auto"}]);X3.exports={Request:So,makeRequest:yg,fromInnerRequest:Z3,cloneRequest:K3,getRequestDispatcher:rre,getRequestState:J3}});var n9=y((Ype,s9)=>{"use strict";var mre=require("assert"),{runtimeFeatures:o9}=Ta(),Jr=new Map([["sha256",0],["sha384",1],["sha512",2]]),qw;if(o9.has("crypto")){qw=require("crypto");let o=qw.getHashes();o.length===0&&Jr.clear();for(let e of Jr.keys())o.includes(e)===!1&&Jr.delete(e)}else Jr.clear();var e9=Map.prototype.get.bind(Jr),Ew=Map.prototype.has.bind(Jr),lre=o9.has("crypto")===!1||Jr.size===0?()=>!0:(o,e)=>{let t=a9(e);if(t.length===0)return!0;let a=t9(t);for(let i of a){let r=i.alg,s=i.val,n=i9(r,o);if(r9(n,s))return!0}return!1};function t9(o){let e=[],t=null;for(let a of o){if(mre(Ew(a.alg),"Invalid SRI hash algorithm token"),e.length===0){e.push(a),t=a;continue}let i=t.alg,r=e9(i),s=a.alg,n=e9(s);n<r||(n>r?(t=a,e[0]=a,e.length=1):e.push(a))}return e}function a9(o){let e=[];for(let t of o.split(" ")){let i=t.split("?",1)[0],r="",s=[i.slice(0,6),i.slice(7)],n=s[0];if(!Ew(n))continue;s[1]&&(r=s[1]);let c={alg:n,val:r};e.push(c)}return e}var i9=(o,e)=>qw.hash(o,e,"base64");function r9(o,e){let t=o.length;t!==0&&o[t-1]==="="&&(t-=1),t!==0&&o[t-1]==="="&&(t-=1);let a=e.length;if(a!==0&&e[a-1]==="="&&(a-=1),a!==0&&e[a-1]==="="&&(a-=1),t!==a)return!1;for(let i=0;i<t;++i)if(!(o[i]===e[i]||o[i]==="+"&&e[i]==="-"||o[i]==="/"&&e[i]==="_"))return!1;return!0}s9.exports={applyAlgorithmToBytes:i9,bytesMatch:lre,caseSensitiveMatch:r9,isValidSRIHashAlgorithm:Ew,getStrongestMetadata:t9,parseMetadata:a9}});var Gm=y((Vpe,w9)=>{"use strict";var{makeNetworkError:pe,makeAppropriateNetworkError:Pm,filterResponse:Iw,makeResponse:kg,fromInnerResponse:ure,getResponseState:dre}=Fm(),{HeadersList:Cw}=$r(),{Request:gre,cloneRequest:pre,getRequestDispatcher:hre,getRequestState:fre}=An(),Pt=require("zlib"),{makePolicyContainer:bre,clonePolicyContainer:yre,requestBadPort:kre,TAOCheck:Are,appendRequestOriginHeader:wre,responseLocationURL:vre,requestCurrentURL:ot,setRequestReferrerPolicyOnRedirect:xre,tryUpgradeRequestToAPotentiallyTrustworthyURL:zre,createOpaqueTimingInfo:Tw,appendFetchMetadata:qre,corsCheck:Ere,crossOriginResourcePolicyCheck:Ire,determineRequestsReferrer:Cre,coarsenedSharedCurrentTime:Hm,sameOrigin:Sw,isCancelled:Oi,isAborted:c9,isErrorLike:jre,fullyReadBody:Bre,readableStreamClose:Qre,urlIsLocal:Sre,urlIsHttpHttpsScheme:xg,urlHasHttpsScheme:Dre,clampAndCoarsenConnectionTimingInfo:Tre,simpleRangeHeaderValue:Rre,buildContentRange:Nre,createInflate:Ure,extractMimeType:Ore,hasAuthenticationEntry:Mre,includesCredentials:m9,isTraversableNavigable:_re}=Vo(),Kr=require("assert"),{safelyExtractBody:zg,extractBody:l9}=$s(),{redirectStatusSet:p9,nullBodyStatus:h9,safeMethodsSet:Lre,requestBodyHeader:Fre,subresourceSet:Pre}=Xc(),Hre=require("events"),{Readable:Gre,pipeline:Yre,finished:Vre,isErrored:$re,isReadable:Ag}=require("stream"),{addAbortListener:Wre,bufferToLowerCasedHeaderName:u9}=K(),{dataURLProcessor:Jre,serializeAMimeType:Kre,minimizeSupportedMimeType:Zre}=bt(),{getGlobalDispatcher:Xre}=ag(),{webidl:Rw}=to(),{STATUS_CODES:d9}=require("http"),{bytesMatch:ese}=n9(),{createDeferredPromise:ose}=im(),{isomorphicEncode:wg}=Da(),{runtimeFeatures:tse}=Ta(),ase=tse.has("zstd"),ise=["GET","HEAD"],rse=typeof __UNDICI_IS_NODE__<"u"||typeof esbuildDetection<"u"?"node":"undici",jw,vg=class extends Hre{constructor(e){super(),this.dispatcher=e,this.connection=null,this.dump=!1,this.state="ongoing"}terminate(e){this.state==="ongoing"&&(this.state="terminated",this.connection?.destroy(e),this.emit("terminated",e))}abort(e){this.state==="ongoing"&&(this.state="aborted",e||(e=new DOMException("The operation was aborted.","AbortError")),this.serializedAbortReason=e,this.connection?.destroy(e),this.emit("terminated",e))}};function sse(o){f9(o,"fetch")}function nse(o,e=void 0){Rw.argumentLengthCheck(arguments,1,"globalThis.fetch");let t=ose(),a;try{a=new gre(o,e)}catch(l){return t.reject(l),t.promise}let i=fre(a);if(a.signal.aborted)return Bw(t,i,null,a.signal.reason,null),t.promise;i.client.globalObject?.constructor?.name==="ServiceWorkerGlobalScope"&&(i.serviceWorkers="none");let s=null,n=!1,c=null;return Wre(a.signal,()=>{n=!0,Kr(c!=null),c.abort(a.signal.reason);let l=s?.deref();Bw(t,i,l,a.signal.reason,c.controller)}),c=y9({request:i,processResponseEndOfBody:sse,processResponse:l=>{if(!n){if(l.aborted){Bw(t,i,s,c.serializedAbortReason,c.controller);return}if(l.type==="error"){t.reject(new TypeError("fetch failed",{cause:l.error}));return}s=new WeakRef(ure(l,"immutable")),t.resolve(s.deref()),t=null}},dispatcher:hre(a),requestObject:a}),t.promise}function f9(o,e="other"){if(o.type==="error"&&o.aborted||!o.urlList?.length)return;let t=o.urlList[0],a=o.timingInfo,i=o.cacheState;xg(t)&&a!==null&&(o.timingAllowPassed||(a=Tw({startTime:a.startTime}),i=""),a.endTime=Hm(),o.timingInfo=a,b9(a,t.href,e,globalThis,i,"",o.status))}var b9=performance.markResourceTiming;function Bw(o,e,t,a,i){if(o&&o.reject(a),e.body?.stream!=null&&Ag(e.body.stream)&&e.body.stream.cancel(a).catch(s=>{if(s.code!=="ERR_INVALID_STATE")throw s}),t==null)return;let r=dre(t);r.body?.stream!=null&&Ag(r.body.stream)&&i.error(a)}function y9({request:o,processRequestBodyChunkLength:e,processRequestEndOfBody:t,processResponse:a,processResponseEndOfBody:i,processResponseConsumeBody:r,useParallelQueue:s=!1,dispatcher:n=Xre(),requestObject:c=null}){Kr(n);let m=null,l=!1;o.client!=null&&(m=o.client.globalObject,l=o.client.crossOriginIsolatedCapability);let u=Hm(l),d=Tw({startTime:u}),g={controller:new vg(n),request:o,timingInfo:d,processRequestBodyChunkLength:e,processRequestEndOfBody:t,processResponse:a,processResponseConsumeBody:r,processResponseEndOfBody:i,taskDestination:m,crossOriginIsolatedCapability:l,requestObject:c};return Kr(!o.body||o.body.stream),o.window==="client"&&(o.window=o.client?.globalObject?.constructor?.name==="Window"?o.client:"no-window"),o.origin==="client"&&(o.origin=o.client.origin),o.policyContainer==="client"&&(o.client!=null?o.policyContainer=yre(o.client.policyContainer):o.policyContainer=bre()),o.headersList.contains("accept",!0)||o.headersList.append("accept","*/*",!0),o.headersList.contains("accept-language",!0)||o.headersList.append("accept-language","*",!0),o.priority,Pre.has(o.destination),k9(g,!1),g.controller}async function k9(o,e){try{let t=o.request,a=null;if(t.localURLsOnly&&!Sre(ot(t))&&(a=pe("local URLs only")),zre(t),kre(t)==="blocked"&&(a=pe("bad port")),t.referrerPolicy===""&&(t.referrerPolicy=t.policyContainer.referrerPolicy),t.referrer!=="no-referrer"&&(t.referrer=Cre(t)),a===null){let r=ot(t);Sw(r,t.url)&&t.responseTainting==="basic"||r.protocol==="data:"||t.mode==="navigate"||t.mode==="websocket"?(t.responseTainting="basic",a=await g9(o)):t.mode==="same-origin"?a=pe('request mode cannot be "same-origin"'):t.mode==="no-cors"?t.redirect!=="follow"?a=pe('redirect mode cannot be "follow" for "no-cors" request'):(t.responseTainting="opaque",a=await g9(o)):xg(ot(t))?(t.responseTainting="cors",a=await A9(o)):a=pe("URL scheme must be a HTTP(S) scheme")}if(e)return a;a.status!==0&&!a.internalResponse&&(t.responseTainting,t.responseTainting==="basic"?a=Iw(a,"basic"):t.responseTainting==="cors"?a=Iw(a,"cors"):t.responseTainting==="opaque"?a=Iw(a,"opaque"):Kr(!1));let i=a.status===0?a:a.internalResponse;if(i.urlList.length===0&&i.urlList.push(...t.urlList),t.timingAllowFailed||(a.timingAllowPassed=!0),a.type==="opaque"&&i.status===206&&i.rangeRequested&&!t.headers.contains("range",!0)&&(a=i=pe()),a.status!==0&&(t.method==="HEAD"||t.method==="CONNECT"||h9.includes(i.status))&&(i.body=null,o.controller.dump=!0),t.integrity){let r=n=>Qw(o,pe(n));if(t.responseTainting==="opaque"||a.body==null){r(a.error);return}let s=n=>{if(!ese(n,t.integrity)){r("integrity mismatch");return}a.body=zg(n)[0],Qw(o,a)};Bre(a.body,s,r)}else Qw(o,a)}catch(t){o.controller.terminate(t)}}function g9(o){if(Oi(o)&&o.request.redirectCount===0)return Promise.resolve(Pm(o));let{request:e}=o,{protocol:t}=ot(e);switch(t){case"about:":return Promise.resolve(pe("about scheme is not supported"));case"blob:":{jw||(jw=require("buffer").resolveObjectURL);let a=ot(e);if(a.search.length!==0)return Promise.resolve(pe("NetworkError when attempting to fetch resource."));let i=jw(a.toString());if(e.method!=="GET"||!Rw.is.Blob(i))return Promise.resolve(pe("invalid method"));let r=kg(),s=i.size,n=wg(`${s}`),c=i.type;if(e.headersList.contains("range",!0)){r.rangeRequested=!0;let m=e.headersList.get("range",!0),l=Rre(m,!0);if(l==="failure")return Promise.resolve(pe("failed to fetch the data URL"));let{rangeStartValue:u,rangeEndValue:d}=l;if(u===null)u=s-d,d=u+d-1;else{if(u>=s)return Promise.resolve(pe("Range start is greater than the blob's size."));(d===null||d>=s)&&(d=s-1)}let g=i.slice(u,d+1,c),p=l9(g);r.body=p[0];let b=wg(`${g.size}`),A=Nre(u,d,s);r.status=206,r.statusText="Partial Content",r.headersList.set("content-length",b,!0),r.headersList.set("content-type",c,!0),r.headersList.set("content-range",A,!0)}else{let m=l9(i);r.statusText="OK",r.body=m[0],r.headersList.set("content-length",n,!0),r.headersList.set("content-type",c,!0)}return Promise.resolve(r)}case"data:":{let a=ot(e),i=Jre(a);if(i==="failure")return Promise.resolve(pe("failed to fetch the data URL"));let r=Kre(i.mimeType);return Promise.resolve(kg({statusText:"OK",headersList:[["content-type",{name:"Content-Type",value:r}]],body:zg(i.body)[0]}))}case"file:":return Promise.resolve(pe("not implemented... yet..."));case"http:":case"https:":return A9(o).catch(a=>pe(a));default:return Promise.resolve(pe("unknown scheme"))}}function cse(o,e){o.request.done=!0,o.processResponseDone!=null&&queueMicrotask(()=>o.processResponseDone(e))}function Qw(o,e){let t=o.timingInfo,a=()=>{let r=Date.now();o.request.destination==="document"&&(o.controller.fullTimingInfo=t),o.controller.reportTimingSteps=()=>{if(!xg(o.request.url))return;t.endTime=r;let n=e.cacheState,c=e.bodyInfo;e.timingAllowPassed||(t=Tw(t),n="");let m=0;if(o.request.mode!=="navigate"||!e.hasCrossOriginRedirects){m=e.status;let l=Ore(e.headersList);l!=="failure"&&(c.contentType=Zre(l))}o.request.initiatorType!=null&&b9(t,o.request.url.href,o.request.initiatorType,globalThis,n,c,m)};let s=()=>{o.request.done=!0,o.processResponseEndOfBody!=null&&queueMicrotask(()=>o.processResponseEndOfBody(e)),o.request.initiatorType!=null&&o.controller.reportTimingSteps()};queueMicrotask(()=>s())};o.processResponse!=null&&queueMicrotask(()=>{o.processResponse(e),o.processResponse=null});let i=e.type==="error"?e:e.internalResponse??e;i.body==null?a():Vre(i.body.stream,()=>{a()})}async function A9(o){let e=o.request,t=null,a=null,i=o.timingInfo;if(e.serviceWorkers,t===null){if(e.redirect==="follow"&&(e.serviceWorkers="none"),a=t=await Dw(o),e.responseTainting==="cors"&&Ere(e,t)==="failure")return pe("cors failure");Are(e,t)==="failure"&&(e.timingAllowFailed=!0)}return(e.responseTainting==="opaque"||t.type==="opaque")&&Ire(e.origin,e.client,e.destination,a)==="blocked"?pe("blocked"):(p9.has(a.status)&&(e.redirect!=="manual"&&o.controller.connection.destroy(void 0,!1),e.redirect==="error"?t=pe("unexpected redirect"):e.redirect==="manual"?t=a:e.redirect==="follow"?t=await mse(o,t):Kr(!1)),t.timingInfo=i,t)}function mse(o,e){let t=o.request,a=e.internalResponse?e.internalResponse:e,i;try{if(i=vre(a,ot(t).hash),i==null)return e}catch(s){return Promise.resolve(pe(s))}if(!xg(i))return Promise.resolve(pe("URL scheme must be a HTTP(S) scheme"));if(t.redirectCount===20)return Promise.resolve(pe("redirect count exceeded"));if(t.redirectCount+=1,t.mode==="cors"&&(i.username||i.password)&&!Sw(t,i))return Promise.resolve(pe('cross origin not allowed for request mode "cors"'));if(t.responseTainting==="cors"&&(i.username||i.password))return Promise.resolve(pe('URL cannot contain credentials for request mode "cors"'));if(a.status!==303&&t.body!=null&&t.body.source==null)return Promise.resolve(pe());if([301,302].includes(a.status)&&t.method==="POST"||a.status===303&&!ise.includes(t.method)){t.method="GET",t.body=null;for(let s of Fre)t.headersList.delete(s)}Sw(ot(t),i)||(t.headersList.delete("authorization",!0),t.headersList.delete("proxy-authorization",!0),t.headersList.delete("cookie",!0),t.headersList.delete("host",!0)),t.body!=null&&(Kr(t.body.source!=null),t.body=zg(t.body.source)[0]);let r=o.timingInfo;return r.redirectEndTime=r.postRedirectStartTime=Hm(o.crossOriginIsolatedCapability),r.redirectStartTime===0&&(r.redirectStartTime=r.startTime),t.urlList.push(i),xre(t,a),k9(o,!0)}async function Dw(o,e=!1,t=!1){let a=o.request,i=null,r=null,s=null,n=null,c=!1;a.window==="no-window"&&a.redirect==="error"?(i=o,r=a):(r=pre(a),i={...o},i.request=r);let m=a.credentials==="include"||a.credentials==="same-origin"&&a.responseTainting==="basic",l=r.body?r.body.length:null,u=null;if(r.body==null&&["POST","PUT"].includes(r.method)&&(u="0"),l!=null&&(u=wg(`${l}`)),u!=null&&!r.headersList.contains("content-length",!0)&&r.headersList.append("content-length",u,!0),l!=null&&r.keepalive,Rw.is.URL(r.referrer)&&r.headersList.append("referer",wg(r.referrer.href),!0),wre(r),qre(r),r.headersList.contains("user-agent",!0)||r.headersList.append("user-agent",rse,!0),r.cache==="default"&&(r.headersList.contains("if-modified-since",!0)||r.headersList.contains("if-none-match",!0)||r.headersList.contains("if-unmodified-since",!0)||r.headersList.contains("if-match",!0)||r.headersList.contains("if-range",!0))&&(r.cache="no-store"),r.cache==="no-cache"&&!r.preventNoCacheCacheControlHeaderModification&&!r.headersList.contains("cache-control",!0)&&r.headersList.append("cache-control","max-age=0",!0),(r.cache==="no-store"||r.cache==="reload")&&(r.headersList.contains("pragma",!0)||r.headersList.append("pragma","no-cache",!0),r.headersList.contains("cache-control",!0)||r.headersList.append("cache-control","no-cache",!0)),r.headersList.contains("range",!0)&&r.headersList.append("accept-encoding","identity",!0),r.headersList.contains("accept-encoding",!0)||(Dre(ot(r))?r.headersList.append("accept-encoding","br, gzip, deflate",!0):r.headersList.append("accept-encoding","gzip, deflate",!0)),r.headersList.delete("host",!0),m&&!r.headersList.contains("authorization",!0)){let d=null;if(!(Mre(r)&&(r.useURLCredentials===void 0||!m9(ot(r))))){if(m9(ot(r))&&e){let{username:g,password:p}=ot(r);d=`Basic ${Buffer.from(`${g}:${p}`).toString("base64")}`}}d!==null&&r.headersList.append("Authorization",d,!1)}if(n==null&&(r.cache="no-store"),r.cache!=="no-store"&&r.cache,s==null){if(r.cache==="only-if-cached")return pe("only if cached");let d=await lse(i,m,t);!Lre.has(r.method)&&d.status>=200&&d.status<=399,c&&d.status,s==null&&(s=d)}if(s.urlList=[...r.urlList],r.headersList.contains("range",!0)&&(s.rangeRequested=!0),s.requestIncludesCredentials=m,s.status===401&&r.responseTainting!=="cors"&&m&&(a.useURLCredentials!==void 0||_re(a.traversableForUserPrompts))){if(a.body!=null){if(a.body.source==null)return s;a.body=zg(a.body.source)[0]}if(a.useURLCredentials===void 0||e)return Oi(o)?Pm(o):s;o.controller.connection.destroy(),s=await Dw(o,!0)}if(s.status===407)return a.window==="no-window"?pe():Oi(o)?Pm(o):pe("proxy authentication required");if(s.status===421&&!t&&(a.body==null||a.body.source!=null)){if(Oi(o))return Pm(o);o.controller.connection.destroy(),s=await Dw(o,e,!0)}return s}async function lse(o,e=!1,t=!1){Kr(!o.controller.connection||o.controller.connection.destroyed),o.controller.connection={abort:null,destroyed:!1,destroy(p,b=!0){this.destroyed||(this.destroyed=!0,b&&this.abort?.(p??new DOMException("The operation was aborted.","AbortError")))}};let a=o.request,i=null,r=o.timingInfo;null==null&&(a.cache="no-store");let n=t?"yes":"no";a.mode;let c=null;if(a.body==null&&o.processRequestEndOfBody)queueMicrotask(()=>o.processRequestEndOfBody());else if(a.body!=null){let p=async function*(k){Oi(o)||(yield k,o.processRequestBodyChunkLength?.(k.byteLength))},b=()=>{Oi(o)||o.processRequestEndOfBody&&o.processRequestEndOfBody()},A=k=>{Oi(o)||(k.name==="AbortError"?o.controller.abort():o.controller.terminate(k))};c=(async function*(){try{for await(let k of a.body.stream)yield*p(k);b()}catch(k){A(k)}})()}try{let{body:p,status:b,statusText:A,headersList:k,socket:x}=await g({body:c});if(x)i=kg({status:b,statusText:A,headersList:k,socket:x});else{let v=p[Symbol.asyncIterator]();o.controller.next=()=>v.next(),i=kg({status:b,statusText:A,headersList:k})}}catch(p){return p.name==="AbortError"?(o.controller.connection.destroy(),Pm(o,p)):pe(p)}let m=()=>o.controller.resume(),l=p=>{Oi(o)||o.controller.abort(p)},u=new ReadableStream({start(p){o.controller.controller=p},pull:m,cancel:l,type:"bytes"});i.body={stream:u,source:null,length:null},o.controller.resume||o.controller.on("terminated",d),o.controller.resume=async()=>{for(;;){let p,b;try{let{done:k,value:x}=await o.controller.next();if(c9(o))break;p=k?void 0:x}catch(k){o.controller.ended&&!r.encodedBodySize?p=void 0:(p=k,b=!0)}if(p===void 0){Qre(o.controller.controller),cse(o,i);return}if(r.decodedBodySize+=p?.byteLength??0,b){o.controller.terminate(p);return}let A=new Uint8Array(p);if(A.byteLength&&o.controller.controller.enqueue(A),$re(u)){o.controller.terminate();return}if(o.controller.controller.desiredSize<=0)return}};function d(p){c9(o)?(i.aborted=!0,Ag(u)&&o.controller.controller.error(o.controller.serializedAbortReason)):Ag(u)&&o.controller.controller.error(new TypeError("terminated",{cause:jre(p)?p:void 0})),o.controller.connection.destroy()}return i;function g({body:p}){let b=ot(a),A=o.controller.dispatcher,k=b.pathname+b.search,x=b.search.length===0&&b.href[b.href.length-b.hash.length-1]==="?";return new Promise((v,j)=>A.dispatch({path:x?`${k}?`:k,origin:b.origin,method:a.method,body:A.isMockActive?a.body&&(a.body.source||a.body.stream):p,headers:a.headersList.entries,maxRedirections:0,upgrade:a.mode==="websocket"?"websocket":void 0},{body:null,abort:null,onConnect(I){let{connection:T}=o.controller;r.finalConnectionTimingInfo=Tre(void 0,r.postRedirectStartTime,o.crossOriginIsolatedCapability),T.destroyed?I(new DOMException("The operation was aborted.","AbortError")):(o.controller.on("terminated",I),this.abort=T.abort=I),r.finalNetworkRequestStartTime=Hm(o.crossOriginIsolatedCapability)},onResponseStarted(){r.finalNetworkResponseStartTime=Hm(o.crossOriginIsolatedCapability)},onHeaders(I,T,D,O){if(I<200)return!1;let S=new Cw;for(let Ve=0;Ve<T.length;Ve+=2){let ya=u9(T[Ve]),it=T[Ve+1];if(Array.isArray(it)&&!Buffer.isBuffer(T[Ve+1]))for(let Wi of it)S.append(ya,Wi.toString("latin1"),!0);else S.append(ya,it.toString("latin1"),!0)}let oe=S.get("location",!0);this.body=new Gre({read:D});let te=oe&&a.redirect==="follow"&&p9.has(I),ye=[];if(a.method!=="HEAD"&&a.method!=="CONNECT"&&!h9.includes(I)&&!te){let Ve=S.get("content-encoding",!0),ya=Ve?Ve.toLowerCase().split(","):[],it=5;if(ya.length>it)return j(new Error(`too many content-encodings in response: ${ya.length}, maximum allowed is ${it}`)),!0;for(let Wi=ya.length-1;Wi>=0;--Wi){let Ji=ya[Wi].trim();if(Ji==="x-gzip"||Ji==="gzip")ye.push(Pt.createGunzip({flush:Pt.constants.Z_SYNC_FLUSH,finishFlush:Pt.constants.Z_SYNC_FLUSH}));else if(Ji==="deflate")ye.push(Ure({flush:Pt.constants.Z_SYNC_FLUSH,finishFlush:Pt.constants.Z_SYNC_FLUSH}));else if(Ji==="br")ye.push(Pt.createBrotliDecompress({flush:Pt.constants.BROTLI_OPERATION_FLUSH,finishFlush:Pt.constants.BROTLI_OPERATION_FLUSH}));else if(Ji==="zstd"&&ase)ye.push(Pt.createZstdDecompress({flush:Pt.constants.ZSTD_e_continue,finishFlush:Pt.constants.ZSTD_e_end}));else{ye.length=0;break}}}let po=this.onError.bind(this);return v({status:I,statusText:O,headersList:S,body:ye.length?Yre(this.body,...ye,Ve=>{Ve&&this.onError(Ve)}).on("error",po):this.body.on("error",po)}),!0},onData(I){if(o.controller.dump)return;let T=I;return r.encodedBodySize+=T.byteLength,this.body.push(T)},onComplete(){this.abort&&o.controller.off("terminated",this.abort),o.controller.ended=!0,this.body.push(null)},onError(I){this.abort&&o.controller.off("terminated",this.abort),this.body?.destroy(I),o.controller.terminate(I),j(I)},onRequestUpgrade(I,T,D,O){if(O.session!=null&&T!==200||O.session==null&&T!==101)return!1;let S=new Cw;for(let[oe,te]of Object.entries(D)){if(te==null)continue;let ye=oe.toLowerCase();if(Array.isArray(te))for(let po of te)S.append(ye,String(po),!0);else S.append(ye,String(te),!0)}return v({status:T,statusText:d9[T],headersList:S,socket:O}),!0},onUpgrade(I,T,D){if(D.session!=null&&I!==200||D.session==null&&I!==101)return!1;let O=new Cw;for(let S=0;S<T.length;S+=2){let oe=u9(T[S]),te=T[S+1];if(Array.isArray(te)&&!Buffer.isBuffer(T[S+1]))for(let ye of te)O.append(oe,ye.toString("latin1"),!0);else O.append(oe,te.toString("latin1"),!0)}return v({status:I,statusText:d9[I],headersList:O,socket:D}),!0}}))}}w9.exports={fetch:nse,Fetch:vg,fetching:y9,finalizeAndReportTiming:f9}});var z9=y(($pe,x9)=>{"use strict";var use=require("assert"),{URLSerializer:v9}=bt(),{isValidHeaderName:dse}=Vo();function gse(o,e,t=!1){let a=v9(o,t),i=v9(e,t);return a===i}function pse(o){use(o!==null);let e=[];for(let t of o.split(","))t=t.trim(),dse(t)&&e.push(t);return e}x9.exports={urlEquals:gse,getFieldValues:pse}});var C9=y((Wpe,I9)=>{"use strict";var Nw=require("assert"),{kConstruct:hse}=de(),{urlEquals:fse,getFieldValues:Uw}=z9(),{kEnumerableProperty:Zr,isDisturbed:bse}=K(),{webidl:R}=to(),{cloneResponse:q9,fromInnerResponse:yse,getResponseState:kse}=Fm(),{Request:Ym,fromInnerRequest:Ase,getRequestState:ua}=An(),{fetching:wse}=Gm(),{urlIsHttpHttpsScheme:qg,readAllBytes:vse}=Vo(),{createDeferredPromise:wn}=im(),Eg=class o{#e;constructor(){arguments[0]!==hse&&R.illegalConstructor(),R.util.markAsUncloneable(this),this.#e=arguments[1]}async match(e,t={}){R.brandCheck(this,o);let a="Cache.match";R.argumentLengthCheck(arguments,1,a),e=R.converters.RequestInfo(e),t=R.converters.CacheQueryOptions(t,a,"options");let i=this.#r(e,t,1);if(i.length!==0)return i[0]}async matchAll(e=void 0,t={}){R.brandCheck(this,o);let a="Cache.matchAll";return e!==void 0&&(e=R.converters.RequestInfo(e)),t=R.converters.CacheQueryOptions(t,a,"options"),this.#r(e,t)}async add(e){R.brandCheck(this,o),R.argumentLengthCheck(arguments,1,"Cache.add"),e=R.converters.RequestInfo(e);let a=[e];return await this.addAll(a)}async addAll(e){R.brandCheck(this,o);let t="Cache.addAll";R.argumentLengthCheck(arguments,1,t);let a=[],i=[];for(let d of e){if(d===void 0)throw R.errors.conversionFailed({prefix:t,argument:"Argument 1",types:["undefined is not allowed"]});if(d=R.converters.RequestInfo(d),typeof d=="string")continue;let g=ua(d);if(!qg(g.url)||g.method!=="GET")throw R.errors.exception({header:t,message:"Expected http/s scheme when method is not GET."})}let r=[];for(let d of e){let g=ua(new Ym(d));if(!qg(g.url))throw R.errors.exception({header:t,message:"Expected http/s scheme."});g.initiator="fetch",g.destination="subresource",i.push(g);let p=wn();r.push(wse({request:g,processResponse(b){if(b.type==="error"||b.status===206||b.status<200||b.status>299)p.reject(R.errors.exception({header:"Cache.addAll",message:"Received an invalid status code or the request failed."}));else if(b.headersList.contains("vary")){let A=Uw(b.headersList.get("vary"));for(let k of A)if(k==="*"){p.reject(R.errors.exception({header:"Cache.addAll",message:"invalid vary field value"}));for(let x of r)x.abort();return}}},processResponseEndOfBody(b){if(b.aborted){p.reject(new DOMException("aborted","AbortError"));return}p.resolve(b)}})),a.push(p.promise)}let n=await Promise.all(a),c=[],m=0;for(let d of n){let g={type:"put",request:i[m],response:d};c.push(g),m++}let l=wn(),u=null;try{this.#o(c)}catch(d){u=d}return queueMicrotask(()=>{u===null?l.resolve(void 0):l.reject(u)}),l.promise}async put(e,t){R.brandCheck(this,o);let a="Cache.put";R.argumentLengthCheck(arguments,2,a),e=R.converters.RequestInfo(e),t=R.converters.Response(t,a,"response");let i=null;if(R.is.Request(e)?i=ua(e):i=ua(new Ym(e)),!qg(i.url)||i.method!=="GET")throw R.errors.exception({header:a,message:"Expected an http/s scheme when method is not GET"});let r=kse(t);if(r.status===206)throw R.errors.exception({header:a,message:"Got 206 status"});if(r.headersList.contains("vary")){let g=Uw(r.headersList.get("vary"));for(let p of g)if(p==="*")throw R.errors.exception({header:a,message:"Got * vary field value"})}if(r.body&&(bse(r.body.stream)||r.body.stream.locked))throw R.errors.exception({header:a,message:"Response body is locked or disturbed"});let s=q9(r),n=wn();if(r.body!=null){let p=r.body.stream.getReader();vse(p,n.resolve,n.reject)}else n.resolve(void 0);let c=[],m={type:"put",request:i,response:s};c.push(m);let l=await n.promise;s.body!=null&&(s.body.source=l);let u=wn(),d=null;try{this.#o(c)}catch(g){d=g}return queueMicrotask(()=>{d===null?u.resolve():u.reject(d)}),u.promise}async delete(e,t={}){R.brandCheck(this,o);let a="Cache.delete";R.argumentLengthCheck(arguments,1,a),e=R.converters.RequestInfo(e),t=R.converters.CacheQueryOptions(t,a,"options");let i=null;if(R.is.Request(e)){if(i=ua(e),i.method!=="GET"&&!t.ignoreMethod)return!1}else Nw(typeof e=="string"),i=ua(new Ym(e));let r=[],s={type:"delete",request:i,options:t};r.push(s);let n=wn(),c=null,m;try{m=this.#o(r)}catch(l){c=l}return queueMicrotask(()=>{c===null?n.resolve(!!m?.length):n.reject(c)}),n.promise}async keys(e=void 0,t={}){R.brandCheck(this,o);let a="Cache.keys";e!==void 0&&(e=R.converters.RequestInfo(e)),t=R.converters.CacheQueryOptions(t,a,"options");let i=null;if(e!==void 0)if(R.is.Request(e)){if(i=ua(e),i.method!=="GET"&&!t.ignoreMethod)return[]}else typeof e=="string"&&(i=ua(new Ym(e)));let r=wn(),s=[];if(e===void 0)for(let n of this.#e)s.push(n[0]);else{let n=this.#a(i,t);for(let c of n)s.push(c[0])}return queueMicrotask(()=>{let n=[];for(let c of s){let m=Ase(c,void 0,new AbortController().signal,"immutable");n.push(m)}r.resolve(Object.freeze(n))}),r.promise}#o(e){let t=this.#e,a=[...t],i=[],r=[];try{for(let s of e){if(s.type!=="delete"&&s.type!=="put")throw R.errors.exception({header:"Cache.#batchCacheOperations",message:'operation type does not match "delete" or "put"'});if(s.type==="delete"&&s.response!=null)throw R.errors.exception({header:"Cache.#batchCacheOperations",message:"delete operation should not have an associated response"});if(this.#a(s.request,s.options,i).length)throw new DOMException("???","InvalidStateError");let n;if(s.type==="delete"){if(n=this.#a(s.request,s.options),n.length===0)return[];for(let c of n){let m=t.indexOf(c);Nw(m!==-1),t.splice(m,1)}}else if(s.type==="put"){if(s.response==null)throw R.errors.exception({header:"Cache.#batchCacheOperations",message:"put operation should have an associated response"});let c=s.request;if(!qg(c.url))throw R.errors.exception({header:"Cache.#batchCacheOperations",message:"expected http or https scheme"});if(c.method!=="GET")throw R.errors.exception({header:"Cache.#batchCacheOperations",message:"not get method"});if(s.options!=null)throw R.errors.exception({header:"Cache.#batchCacheOperations",message:"options must not be defined"});n=this.#a(s.request);for(let m of n){let l=t.indexOf(m);Nw(l!==-1),t.splice(l,1)}t.push([s.request,s.response]),i.push([s.request,s.response])}r.push([s.request,s.response])}return r}catch(s){throw this.#e.length=0,this.#e=a,s}}#a(e,t,a){let i=[],r=a??this.#e;for(let s of r){let[n,c]=s;this.#i(e,n,c,t)&&i.push(s)}return i}#i(e,t,a=null,i){let r=new URL(e.url),s=new URL(t.url);if(i?.ignoreSearch&&(s.search="",r.search=""),!fse(r,s,!0))return!1;if(a==null||i?.ignoreVary||!a.headersList.contains("vary"))return!0;let n=Uw(a.headersList.get("vary"));for(let c of n){if(c==="*")return!1;let m=t.headersList.get(c),l=e.headersList.get(c);if(m!==l)return!1}return!0}#r(e,t,a=1/0){let i=null;if(e!==void 0)if(R.is.Request(e)){if(i=ua(e),i.method!=="GET"&&!t.ignoreMethod)return[]}else typeof e=="string"&&(i=ua(new Ym(e)));let r=[];if(e===void 0)for(let n of this.#e)r.push(n[1]);else{let n=this.#a(i,t);for(let c of n)r.push(c[1])}let s=[];for(let n of r){let c=yse(q9(n),"immutable");if(s.push(c),s.length>=a)break}return Object.freeze(s)}};Object.defineProperties(Eg.prototype,{[Symbol.toStringTag]:{value:"Cache",configurable:!0},match:Zr,matchAll:Zr,add:Zr,addAll:Zr,put:Zr,delete:Zr,keys:Zr});var E9=[{key:"ignoreSearch",converter:R.converters.boolean,defaultValue:()=>!1},{key:"ignoreMethod",converter:R.converters.boolean,defaultValue:()=>!1},{key:"ignoreVary",converter:R.converters.boolean,defaultValue:()=>!1}];R.converters.CacheQueryOptions=R.dictionaryConverter(E9);R.converters.MultiCacheQueryOptions=R.dictionaryConverter([...E9,{key:"cacheName",converter:R.converters.DOMString}]);R.converters.Response=R.interfaceConverter(R.is.Response,"Response");R.converters["sequence<RequestInfo>"]=R.sequenceConverter(R.converters.RequestInfo);I9.exports={Cache:Eg}});var B9=y((Jpe,j9)=>{"use strict";var{Cache:Ig}=C9(),{webidl:lo}=to(),{kEnumerableProperty:Vm}=K(),{kConstruct:$m}=de(),Cg=class o{#e=new Map;constructor(){arguments[0]!==$m&&lo.illegalConstructor(),lo.util.markAsUncloneable(this)}async match(e,t={}){if(lo.brandCheck(this,o),lo.argumentLengthCheck(arguments,1,"CacheStorage.match"),e=lo.converters.RequestInfo(e),t=lo.converters.MultiCacheQueryOptions(t),t.cacheName!=null){if(this.#e.has(t.cacheName)){let a=this.#e.get(t.cacheName);return await new Ig($m,a).match(e,t)}}else for(let a of this.#e.values()){let r=await new Ig($m,a).match(e,t);if(r!==void 0)return r}}async has(e){lo.brandCheck(this,o);let t="CacheStorage.has";return lo.argumentLengthCheck(arguments,1,t),e=lo.converters.DOMString(e,t,"cacheName"),this.#e.has(e)}async open(e){lo.brandCheck(this,o);let t="CacheStorage.open";if(lo.argumentLengthCheck(arguments,1,t),e=lo.converters.DOMString(e,t,"cacheName"),this.#e.has(e)){let i=this.#e.get(e);return new Ig($m,i)}let a=[];return this.#e.set(e,a),new Ig($m,a)}async delete(e){lo.brandCheck(this,o);let t="CacheStorage.delete";return lo.argumentLengthCheck(arguments,1,t),e=lo.converters.DOMString(e,t,"cacheName"),this.#e.delete(e)}async keys(){return lo.brandCheck(this,o),[...this.#e.keys()]}};Object.defineProperties(Cg.prototype,{[Symbol.toStringTag]:{value:"CacheStorage",configurable:!0},match:Vm,has:Vm,open:Vm,delete:Vm,keys:Vm});j9.exports={CacheStorage:Cg}});var S9=y((Kpe,Q9)=>{"use strict";Q9.exports={maxAttributeValueSize:1024,maxNameValuePairSize:4096}});var _w=y((Zpe,N9)=>{"use strict";function xse(o){for(let e=0;e<o.length;++e){let t=o.charCodeAt(e);if(t>=0&&t<=8||t>=10&&t<=31||t===127)return!0}return!1}function Ow(o){for(let e=0;e<o.length;++e){let t=o.charCodeAt(e);if(t<33||t>126||t===34||t===40||t===41||t===60||t===62||t===64||t===44||t===59||t===58||t===92||t===47||t===91||t===93||t===63||t===61||t===123||t===125)throw new Error("Invalid cookie name")}}function Mw(o){let e=o.length,t=0;if(o[0]==='"'){if(e===1||o[e-1]!=='"')throw new Error("Invalid cookie value");--e,++t}for(;t<e;){let a=o.charCodeAt(t++);if(a<33||a>126||a===34||a===44||a===59||a===92)throw new Error("Invalid cookie value")}}function T9(o){for(let e=0;e<o.length;++e){let t=o.charCodeAt(e);if(t<32||t>126||t===59)throw new Error("Invalid cookie path")}}function D9(o){return o>=48&&o<=57||o>=65&&o<=90||o>=97&&o<=122}function zse(o){if(o===" ")return;if(o.length>255)throw new Error("Invalid cookie domain");let e=0;for(let t=0;t<o.length;++t){let a=o.charCodeAt(t);if(a===46){if(e===0)throw new Error("Invalid cookie domain");if(o.charCodeAt(t-1)===45)throw new Error("Invalid cookie domain");e=0;continue}if(e===0&&!D9(a))throw new Error("Invalid cookie domain");if(!D9(a)&&a!==45)throw new Error("Invalid cookie domain");if(++e>63)throw new Error("Invalid cookie domain")}if(e===0||o.charCodeAt(o.length-1)===45)throw new Error("Invalid cookie domain")}var qse=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],Ese=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],jg=Array(61).fill(0).map((o,e)=>e.toString().padStart(2,"0"));function R9(o){return typeof o=="number"&&(o=new Date(o)),`${qse[o.getUTCDay()]}, ${jg[o.getUTCDate()]} ${Ese[o.getUTCMonth()]} ${o.getUTCFullYear()} ${jg[o.getUTCHours()]}:${jg[o.getUTCMinutes()]}:${jg[o.getUTCSeconds()]} GMT`}function Ise(o){if(o<0)throw new Error("Invalid cookie max-age")}function Cse(o){if(o.name.length===0)return null;Ow(o.name),Mw(o.value);let e=[`${o.name}=${o.value}`];o.name.startsWith("__Secure-")&&(o.secure=!0),o.name.startsWith("__Host-")&&(o.secure=!0,o.domain=null,o.path="/"),o.secure&&e.push("Secure"),o.httpOnly&&e.push("HttpOnly"),typeof o.maxAge=="number"&&(Ise(o.maxAge),e.push(`Max-Age=${o.maxAge}`)),o.domain&&(zse(o.domain),e.push(`Domain=${o.domain}`)),o.path&&(T9(o.path),e.push(`Path=${o.path}`)),o.expires&&o.expires.toString()!=="Invalid Date"&&e.push(`Expires=${R9(o.expires)}`),o.sameSite&&e.push(`SameSite=${o.sameSite}`);for(let t of o.unparsed){if(!t.includes("="))throw new Error("Invalid unparsed");let[a,...i]=t.split("="),r=a.trim(),s=i.join("=");Ow(r),Mw(s),e.push(`${r}=${s}`)}return e.join("; ")}N9.exports={isCTLExcludingHtab:xse,validateCookieName:Ow,validateCookiePath:T9,validateCookieValue:Mw,toIMFDate:R9,stringify:Cse}});var O9=y((Xpe,U9)=>{"use strict";var{collectASequenceOfCodePointsFast:Bg}=Da(),{maxNameValuePairSize:jse,maxAttributeValueSize:Bse}=S9(),{isCTLExcludingHtab:Qse}=_w(),Sse=require("assert");function Dse(o){if(Qse(o))return null;let e="",t="",a="",i="";if(o.includes(";")){let r={position:0};e=Bg(";",o,r),t=o.slice(r.position)}else e=o;if(!e.includes("="))i=e;else{let r={position:0};a=Bg("=",e,r),i=e.slice(r.position+1)}return a=a.trim(),i=i.trim(),a.length+i.length>jse?null:{name:a,value:i,...vn(t)}}function vn(o,e={}){if(o.length===0)return e;Sse(o[0]===";"),o=o.slice(1);let t="";o.includes(";")?(t=Bg(";",o,{position:0}),o=o.slice(t.length)):(t=o,o="");let a="",i="";if(t.includes("=")){let s={position:0};a=Bg("=",t,s),i=t.slice(s.position+1)}else a=t;if(a=a.trim(),i=i.trim(),i.length>Bse)return vn(o,e);let r=a.toLowerCase();if(r==="expires"){let s=new Date(i);e.expires=s}else if(r==="max-age"){let s=i.charCodeAt(0);if((s<48||s>57)&&i[0]!=="-"||!/^\d+$/.test(i))return vn(o,e);let n=Number(i);e.maxAge=n}else if(r==="domain"){let s=i;s[0]==="."&&(s=s.slice(1)),s=s.toLowerCase(),e.domain=s}else if(r==="path"){let s="";i.length===0||i[0]!=="/"?s="/":s=i,e.path=s}else if(r==="secure")e.secure=!0;else if(r==="httponly")e.httpOnly=!0;else if(r==="samesite"){let s=i.toLowerCase();s==="none"?e.sameSite="None":s==="strict"?e.sameSite="Strict":s==="lax"&&(e.sameSite="Lax")}else e.unparsed??=[],e.unparsed.push(`${a}=${i}`);return vn(o,e)}U9.exports={parseSetCookie:Dse,parseUnparsedAttributes:vn}});var F9=y((ehe,L9)=>{"use strict";var{parseSetCookie:M9}=O9(),{stringify:Tse}=_w(),{webidl:ne}=to(),{Headers:Rse}=$r(),Qg=ne.brandCheckMultiple([Rse,globalThis.Headers].filter(Boolean));function Nse(o){ne.argumentLengthCheck(arguments,1,"getCookies"),Qg(o);let e=o.get("cookie"),t={};if(!e)return t;for(let a of e.split(";")){let[i,...r]=a.split("=");t[i.trim()]=r.join("=")}return t}function Use(o,e,t){Qg(o);let a="deleteCookie";ne.argumentLengthCheck(arguments,2,a),e=ne.converters.DOMString(e,a,"name"),t=ne.converters.DeleteCookieAttributes(t),_9(o,{name:e,value:"",expires:new Date(0),...t})}function Ose(o){ne.argumentLengthCheck(arguments,1,"getSetCookies"),Qg(o);let e=o.getSetCookie();return e?e.map(t=>M9(t)):[]}function Mse(o){return o=ne.converters.DOMString(o),M9(o)}function _9(o,e){ne.argumentLengthCheck(arguments,2,"setCookie"),Qg(o),e=ne.converters.Cookie(e);let t=Tse(e);t&&o.append("set-cookie",t,!0)}ne.converters.DeleteCookieAttributes=ne.dictionaryConverter([{converter:ne.nullableConverter(ne.converters.DOMString),key:"path",defaultValue:()=>null},{converter:ne.nullableConverter(ne.converters.DOMString),key:"domain",defaultValue:()=>null}]);ne.converters.Cookie=ne.dictionaryConverter([{converter:ne.converters.DOMString,key:"name"},{converter:ne.converters.DOMString,key:"value"},{converter:ne.nullableConverter(o=>typeof o=="number"?ne.converters["unsigned long long"](o):new Date(o)),key:"expires",defaultValue:()=>null},{converter:ne.nullableConverter(ne.converters["long long"]),key:"maxAge",defaultValue:()=>null},{converter:ne.nullableConverter(ne.converters.DOMString),key:"domain",defaultValue:()=>null},{converter:ne.nullableConverter(ne.converters.DOMString),key:"path",defaultValue:()=>null},{converter:ne.nullableConverter(ne.converters.boolean),key:"secure",defaultValue:()=>null},{converter:ne.nullableConverter(ne.converters.boolean),key:"httpOnly",defaultValue:()=>null},{converter:ne.converters.USVString,key:"sameSite",allowedValues:["Strict","Lax","None"]},{converter:ne.sequenceConverter(ne.converters.DOMString),key:"unparsed",defaultValue:()=>[]}]);L9.exports={getCookies:Nse,deleteCookie:Use,getSetCookies:Ose,setCookie:_9,parseCookie:Mse}});var Tg=y((ohe,H9)=>{"use strict";var{webidl:N}=to(),{kEnumerableProperty:Do}=K(),{kConstruct:P9}=de(),xn=class o extends Event{#e;constructor(e,t={}){if(e===P9){super(arguments[1],arguments[2]),N.util.markAsUncloneable(this);return}let a="MessageEvent constructor";N.argumentLengthCheck(arguments,1,a),e=N.converters.DOMString(e,a,"type"),t=N.converters.MessageEventInit(t,a,"eventInitDict"),super(e,t),this.#e=t,N.util.markAsUncloneable(this)}get data(){return N.brandCheck(this,o),this.#e.data}get origin(){return N.brandCheck(this,o),this.#e.origin}get lastEventId(){return N.brandCheck(this,o),this.#e.lastEventId}get source(){return N.brandCheck(this,o),this.#e.source}get ports(){return N.brandCheck(this,o),Object.isFrozen(this.#e.ports)||Object.freeze(this.#e.ports),this.#e.ports}initMessageEvent(e,t=!1,a=!1,i=null,r="",s="",n=null,c=[]){return N.brandCheck(this,o),N.argumentLengthCheck(arguments,1,"MessageEvent.initMessageEvent"),new o(e,{bubbles:t,cancelable:a,data:i,origin:r,lastEventId:s,source:n,ports:c})}static createFastMessageEvent(e,t){let a=new o(P9,e,t);return a.#e=t,a.#e.data??=null,a.#e.origin??="",a.#e.lastEventId??="",a.#e.source??=null,a.#e.ports??=[],a}},{createFastMessageEvent:_se}=xn;delete xn.createFastMessageEvent;var Sg=class o extends Event{#e;constructor(e,t={}){let a="CloseEvent constructor";N.argumentLengthCheck(arguments,1,a),e=N.converters.DOMString(e,a,"type"),t=N.converters.CloseEventInit(t),super(e,t),this.#e=t,N.util.markAsUncloneable(this)}get wasClean(){return N.brandCheck(this,o),this.#e.wasClean}get code(){return N.brandCheck(this,o),this.#e.code}get reason(){return N.brandCheck(this,o),this.#e.reason}},Dg=class o extends Event{#e;constructor(e,t){let a="ErrorEvent constructor";N.argumentLengthCheck(arguments,1,a),super(e,t),N.util.markAsUncloneable(this),e=N.converters.DOMString(e,a,"type"),t=N.converters.ErrorEventInit(t??{}),this.#e=t}get message(){return N.brandCheck(this,o),this.#e.message}get filename(){return N.brandCheck(this,o),this.#e.filename}get lineno(){return N.brandCheck(this,o),this.#e.lineno}get colno(){return N.brandCheck(this,o),this.#e.colno}get error(){return N.brandCheck(this,o),this.#e.error}};Object.defineProperties(xn.prototype,{[Symbol.toStringTag]:{value:"MessageEvent",configurable:!0},data:Do,origin:Do,lastEventId:Do,source:Do,ports:Do,initMessageEvent:Do});Object.defineProperties(Sg.prototype,{[Symbol.toStringTag]:{value:"CloseEvent",configurable:!0},reason:Do,code:Do,wasClean:Do});Object.defineProperties(Dg.prototype,{[Symbol.toStringTag]:{value:"ErrorEvent",configurable:!0},message:Do,filename:Do,lineno:Do,colno:Do,error:Do});N.converters.MessagePort=N.interfaceConverter(N.is.MessagePort,"MessagePort");N.converters["sequence<MessagePort>"]=N.sequenceConverter(N.converters.MessagePort);var Lw=[{key:"bubbles",converter:N.converters.boolean,defaultValue:()=>!1},{key:"cancelable",converter:N.converters.boolean,defaultValue:()=>!1},{key:"composed",converter:N.converters.boolean,defaultValue:()=>!1}];N.converters.MessageEventInit=N.dictionaryConverter([...Lw,{key:"data",converter:N.converters.any,defaultValue:()=>null},{key:"origin",converter:N.converters.USVString,defaultValue:()=>""},{key:"lastEventId",converter:N.converters.DOMString,defaultValue:()=>""},{key:"source",converter:N.nullableConverter(N.converters.MessagePort),defaultValue:()=>null},{key:"ports",converter:N.converters["sequence<MessagePort>"],defaultValue:()=>[]}]);N.converters.CloseEventInit=N.dictionaryConverter([...Lw,{key:"wasClean",converter:N.converters.boolean,defaultValue:()=>!1},{key:"code",converter:N.converters["unsigned short"],defaultValue:()=>0},{key:"reason",converter:N.converters.USVString,defaultValue:()=>""}]);N.converters.ErrorEventInit=N.dictionaryConverter([...Lw,{key:"message",converter:N.converters.DOMString,defaultValue:()=>""},{key:"filename",converter:N.converters.USVString,defaultValue:()=>""},{key:"lineno",converter:N.converters["unsigned long"],defaultValue:()=>0},{key:"colno",converter:N.converters["unsigned long"],defaultValue:()=>0},{key:"error",converter:N.converters.any}]);H9.exports={MessageEvent:xn,CloseEvent:Sg,ErrorEvent:Dg,createFastMessageEvent:_se}});var Mi=y((the,G9)=>{"use strict";var Lse="258EAFA5-E914-47DA-95CA-C5AB0DC85B11",Fse={enumerable:!0,writable:!1,configurable:!1},Pse={CONNECTING:0,OPEN:1,CLOSING:2,CLOSED:3},Hse={SENT:1,RECEIVED:2},Gse={CONTINUATION:0,TEXT:1,BINARY:2,CLOSE:8,PING:9,PONG:10},Yse=65535,Vse={INFO:0,PAYLOADLENGTH_16:2,PAYLOADLENGTH_64:3,READ_DATA:4},$se=Buffer.allocUnsafe(0),Wse={text:1,typedArray:2,arrayBuffer:3,blob:4};G9.exports={uid:Lse,sentCloseFrameState:Hse,staticPropertyDescriptors:Fse,states:Pse,opcodes:Gse,maxUnsigned16Bit:Yse,parserStates:Vse,emptyBuffer:$se,sendHints:Wse}});var Xr=y((ahe,J9)=>{"use strict";var{states:Rg,opcodes:zn}=Mi(),{isUtf8:Jse}=require("buffer"),{removeHTTPWhitespace:Y9}=bt(),{collectASequenceOfCodePointsFast:Kse}=Da();function Zse(o){return o===Rg.CONNECTING}function Xse(o){return o===Rg.OPEN}function ene(o){return o===Rg.CLOSING}function one(o){return o===Rg.CLOSED}function tne(o,e,t=(i,r)=>new Event(i,r),a={}){let i=t(o,a);e.dispatchEvent(i)}function ane(o,e,t){o.onMessage(e,t)}function ine(o){return o.byteLength===o.buffer.byteLength?o.buffer:new Uint8Array(o).buffer}function rne(o){if(o.length===0)return!1;for(let e=0;e<o.length;++e){let t=o.charCodeAt(e);if(t<33||t>126||t===34||t===40||t===41||t===44||t===47||t===58||t===59||t===60||t===61||t===62||t===63||t===64||t===91||t===92||t===93||t===123||t===125)return!1}return!0}function sne(o){return o>=1e3&&o<1015?o!==1004&&o!==1005&&o!==1006:o>=3e3&&o<=4999}function V9(o){return o===zn.CLOSE||o===zn.PING||o===zn.PONG}function $9(o){return o===zn.CONTINUATION}function W9(o){return o===zn.TEXT||o===zn.BINARY}function nne(o){return W9(o)||$9(o)||V9(o)}function cne(o){let e={position:0},t=new Map;for(;e.position<o.length;){let a=Kse(";",o,e),[i,r=""]=a.split("=",2);t.set(Y9(i,!0,!1),Y9(r,!1,!0)),e.position++}return t}function mne(o){if(o.length===0)return!1;for(let t=0;t<o.length;t++){let a=o.charCodeAt(t);if(a<48||a>57)return!1}let e=Number.parseInt(o,10);return e>=8&&e<=15}function lne(o,e){let t;try{t=new URL(o,e)}catch(a){throw new DOMException(a,"SyntaxError")}if(t.protocol==="http:"?t.protocol="ws:":t.protocol==="https:"&&(t.protocol="wss:"),t.protocol!=="ws:"&&t.protocol!=="wss:")throw new DOMException("expected a ws: or wss: url","SyntaxError");if(t.hash.length||t.href.endsWith("#"))throw new DOMException("hash","SyntaxError");return t}function une(o,e){if(o!==null&&o!==1e3&&(o<3e3||o>4999))throw new DOMException("invalid code","InvalidAccessError");if(e!==null){let t=Buffer.byteLength(e);if(t>123)throw new DOMException(`Reason must be less than 123 bytes; received ${t}`,"SyntaxError")}}var dne=(()=>{if(typeof process.versions.icu=="string"){let o=new TextDecoder("utf-8",{fatal:!0});return o.decode.bind(o)}return function(o){if(Jse(o))return o.toString("utf-8");throw new TypeError("Invalid utf-8 received.")}})();J9.exports={isConnecting:Zse,isEstablished:Xse,isClosing:ene,isClosed:one,fireEvent:tne,isValidSubprotocol:rne,isValidStatusCode:sne,websocketMessageReceived:ane,utf8Decode:dne,isControlFrame:V9,isContinuationFrame:$9,isTextBinaryFrame:W9,isValidOpcode:nne,parseExtensions:cne,isValidClientWindowBits:mne,toArrayBuffer:ine,getURLRecord:lne,validateCloseCodeAndReason:une}});var En=y((ihe,Z9)=>{"use strict";var{runtimeFeatures:gne}=Ta(),{maxUnsigned16Bit:K9,opcodes:pne}=Mi(),Ng=8*1024,Wm=null,qn=Ng,hne=gne.has("crypto")?require("crypto").randomFillSync:function(e,t,a){for(let i=0;i<e.length;++i)e[i]=Math.random()*255|0;return e};function Fw(){return qn===Ng&&(qn=0,hne(Wm??=Buffer.allocUnsafeSlow(Ng),0,Ng)),[Wm[qn++],Wm[qn++],Wm[qn++],Wm[qn++]]}var Pw=class{constructor(e){this.frameData=e}createFrame(e){let t=this.frameData,a=Fw(),i=t?.byteLength??0,r=i,s=6;i>K9?(s+=8,r=127):i>125&&(s+=2,r=126);let n=Buffer.allocUnsafe(i+s);n[0]=n[1]=0,n[0]|=128,n[0]=(n[0]&240)+e;n[s-4]=a[0],n[s-3]=a[1],n[s-2]=a[2],n[s-1]=a[3],n[1]=r,r===126?n.writeUInt16BE(i,2):r===127&&(n[2]=n[3]=0,n.writeUIntBE(i,4,6)),n[1]|=128;for(let c=0;c<i;++c)n[s+c]=t[c]^a[c&3];return n}static createFastTextFrame(e){let t=Fw(),a=e.length;for(let n=0;n<a;++n)e[n]^=t[n&3];let i=a,r=6;a>K9?(r+=8,i=127):a>125&&(r+=2,i=126);let s=Buffer.allocUnsafeSlow(r);return s[0]=128|pne.TEXT,s[1]=i|128,s[r-4]=t[0],s[r-3]=t[1],s[r-2]=t[2],s[r-1]=t[3],i===126?s.writeUInt16BE(a,2):i===127&&(s[2]=s[3]=0,s.writeUIntBE(a,4,6)),[s,e]}};Z9.exports={WebsocketFrameSend:Pw,generateMask:Fw}});var Ug=y((rhe,i5)=>{"use strict";var{uid:fne,states:Hw,sentCloseFrameState:Gw,emptyBuffer:X9,opcodes:bne}=Mi(),{parseExtensions:yne,isClosed:kne,isClosing:Ane,isEstablished:t5,isConnecting:wne,validateCloseCodeAndReason:vne}=Xr(),{makeRequest:xne}=An(),{fetching:zne}=Gm(),{Headers:qne,getHeadersList:Ene}=$r(),{getDecodeSplit:Ine}=Vo(),{WebsocketFrameSend:Cne}=En(),jne=require("assert"),{runtimeFeatures:Bne}=Ta(),e5=Bne.has("crypto")?require("crypto"):null,o5=!1;function Qne(o,e,t,a,i){let r=o;r.protocol=o.protocol==="ws:"?"http:":"https:";let s=xne({urlList:[r],client:t,serviceWorkers:"none",referrer:"no-referrer",mode:"websocket",credentials:"include",cache:"no-store",redirect:"error",useURLCredentials:!0});if(i.headers){let l=Ene(new qne(i.headers));s.headersList=l}let n=e5.randomBytes(16).toString("base64");s.headersList.append("sec-websocket-key",n,!0),s.headersList.append("sec-websocket-version","13",!0);for(let l of e)s.headersList.append("sec-websocket-protocol",l,!0);return s.headersList.append("sec-websocket-extensions","permessage-deflate; client_max_window_bits",!0),zne({request:s,useParallelQueue:!0,dispatcher:i.dispatcher,processResponse(l){if(l.type==="error"||l.status!==101){if(l.socket?.session==null){da(a,1002,"Received network error or non-101 status code.",l.error);return}if(l.status!==200){da(a,1002,"Received network error or non-200 status code.",l.error);return}}if(o5===!1&&l.socket?.session!=null&&(process.emitWarning("WebSocket over HTTP2 is experimental, and subject to change.","ExperimentalWarning"),o5=!0),e.length!==0&&!l.headersList.get("Sec-WebSocket-Protocol")){da(a,1002,"Server did not respond with sent protocols.");return}if(l.socket.session==null&&l.headersList.get("Upgrade")?.toLowerCase()!=="websocket"){da(a,1002,'Server did not set Upgrade header to "websocket".');return}if(l.socket.session==null&&l.headersList.get("Connection")?.toLowerCase()!=="upgrade"){da(a,1002,'Server did not set Connection header to "upgrade".');return}let u=l.headersList.get("Sec-WebSocket-Accept"),d=e5.hash("sha1",n+fne,"base64");if(u!==d){da(a,1002,"Incorrect hash received in Sec-WebSocket-Accept header.");return}let g=l.headersList.get("Sec-WebSocket-Extensions"),p;if(g!==null&&(p=yne(g),!p.has("permessage-deflate"))){da(a,1002,"Sec-WebSocket-Extensions header does not match.");return}let b=l.headersList.get("Sec-WebSocket-Protocol");if(b!==null&&!Ine("sec-websocket-protocol",s.headersList).includes(b)){da(a,1002,"Protocol was not set in the opening handshake.");return}l.socket.on("data",a.onSocketData),l.socket.on("close",a.onSocketClose),l.socket.on("error",a.onSocketError),a.wasEverConnected=!0,a.onConnectionEstablished(l,p)}})}function a5(o,e,t,a=!1){if(e??=null,t??="",a&&vne(e,t),!(kne(o.readyState)||Ane(o.readyState)))if(!t5(o.readyState))da(o),o.readyState=Hw.CLOSING;else if(!o.closeState.has(Gw.SENT)&&!o.closeState.has(Gw.RECEIVED)){let i=new Cne;t.length!==0&&e===null&&(e=1e3),jne(e===null||Number.isInteger(e)),e===null&&t.length===0?i.frameData=X9:e!==null&&t===null?(i.frameData=Buffer.allocUnsafe(2),i.frameData.writeUInt16BE(e,0)):e!==null&&t!==null?(i.frameData=Buffer.allocUnsafe(2+Buffer.byteLength(t)),i.frameData.writeUInt16BE(e,0),i.frameData.write(t,2,"utf-8")):i.frameData=X9,o.socket.write(i.createFrame(bne.CLOSE)),o.closeState.add(Gw.SENT),o.readyState=Hw.CLOSING}else o.readyState=Hw.CLOSING}function da(o,e,t,a){t5(o.readyState)&&a5(o,e,t,!1),o.controller.abort(),wne(o.readyState)?o.onSocketClose():o.socket?.destroyed===!1&&o.socket.destroy()}i5.exports={establishWebSocketConnection:Qne,failWebsocketConnection:da,closeWebSocketConnection:a5}});var s5=y((she,r5)=>{"use strict";var{createInflateRaw:Sne,Z_DEFAULT_WINDOWBITS:Dne}=require("zlib"),{isValidClientWindowBits:Tne}=Xr(),{MessageSizeExceededError:Rne}=$(),Nne=Buffer.from([0,0,255,255]),Og=Symbol("kBuffer"),Jm=Symbol("kLength"),Yw=class{#e;#o={};#a=0;constructor(e,t){this.#o.serverNoContextTakeover=e.has("server_no_context_takeover"),this.#o.serverMaxWindowBits=e.get("server_max_window_bits"),this.#a=t.maxPayloadSize}decompress(e,t,a){if(!this.#e){let i=Dne;if(this.#o.serverMaxWindowBits){if(!Tne(this.#o.serverMaxWindowBits)){a(new Error("Invalid server_max_window_bits"));return}i=Number.parseInt(this.#o.serverMaxWindowBits)}try{this.#e=Sne({windowBits:i})}catch(r){a(r);return}this.#e[Og]=[],this.#e[Jm]=0,this.#e.on("data",r=>{if(this.#e[Jm]+=r.length,this.#a>0&&this.#e[Jm]>this.#a){a(new Rne),this.#e.removeAllListeners(),this.#e=null;return}this.#e[Og].push(r)}),this.#e.on("error",r=>{this.#e=null,a(r)})}this.#e.write(e),t&&this.#e.write(Nne),this.#e.flush(()=>{if(!this.#e)return;let i=Buffer.concat(this.#e[Og],this.#e[Jm]);this.#e[Og].length=0,this.#e[Jm]=0,a(null,i)})}};r5.exports={PerMessageDeflate:Yw}});var Jw=y((nhe,u5)=>{"use strict";var{Writable:Une}=require("stream"),One=require("assert"),{parserStates:To,opcodes:In,states:Mne,emptyBuffer:n5,sentCloseFrameState:Km}=Mi(),{isValidStatusCode:_ne,isValidOpcode:Lne,websocketMessageReceived:c5,utf8Decode:Fne,isControlFrame:Vw,isTextBinaryFrame:$w,isContinuationFrame:Pne}=Xr(),{failWebsocketConnection:uo}=Ug(),{WebsocketFrameSend:m5}=En(),{PerMessageDeflate:Hne}=s5(),{MessageSizeExceededError:l5}=$(),Ww=class extends Une{#e=[];#o=0;#a=0;#i=!1;#r=To.INFO;#t={};#c=[];#s;#n;#m;#u;constructor(e,t,a={}){super(),this.#n=e,this.#s=t??new Map,this.#m=a.maxFragments??0,this.#u=a.maxPayloadSize??0,this.#s.has("permessage-deflate")&&this.#s.set("permessage-deflate",new Hne(t,a))}_write(e,t,a){this.#e.push(e),this.#a+=e.length,this.#i=!0,this.run(a)}#l(){return this.#u>0&&!Vw(this.#t.opcode)&&this.#t.payloadLength+this.#o>this.#u?(uo(this.#n,1009,"Payload size exceeds maximum allowed size"),!1):!0}run(e){for(;this.#i;)if(this.#r===To.INFO){if(this.#a<2)return e();let t=this.consume(2),a=(t[0]&128)!==0,i=t[0]&15,r=(t[1]&128)===128,s=!a&&i!==In.CONTINUATION,n=t[1]&127,c=t[0]&64,m=t[0]&32,l=t[0]&16;if(!Lne(i))return uo(this.#n,1002,"Invalid opcode received"),e();if(r)return uo(this.#n,1002,"Frame cannot be masked"),e();if(c!==0&&!this.#s.has("permessage-deflate")){uo(this.#n,1002,"Expected RSV1 to be clear.");return}if(m!==0||l!==0){uo(this.#n,1002,"RSV1, RSV2, RSV3 must be clear");return}if(s&&!$w(i)){uo(this.#n,1002,"Invalid frame type was fragmented.");return}if($w(i)&&this.#c.length>0){uo(this.#n,1002,"Expected continuation frame");return}if(this.#t.fragmented&&s){uo(this.#n,1002,"Fragmented frame exceeded 125 bytes.");return}if((n>125||s)&&Vw(i)){uo(this.#n,1002,"Control frame either too large or fragmented");return}if(Pne(i)&&this.#c.length===0&&!this.#t.compressed){uo(this.#n,1002,"Unexpected continuation frame");return}if(n<=125){if(this.#t.payloadLength=n,this.#r=To.READ_DATA,!this.#l())return}else n===126?this.#r=To.PAYLOADLENGTH_16:n===127&&(this.#r=To.PAYLOADLENGTH_64);$w(i)&&(this.#t.binaryType=i,this.#t.compressed=c!==0),this.#t.opcode=i,this.#t.masked=r,this.#t.fin=a,this.#t.fragmented=s}else if(this.#r===To.PAYLOADLENGTH_16){if(this.#a<2)return e();let t=this.consume(2);if(this.#t.payloadLength=t.readUInt16BE(0),this.#r=To.READ_DATA,!this.#l())return}else if(this.#r===To.PAYLOADLENGTH_64){if(this.#a<8)return e();let t=this.consume(8),a=t.readUInt32BE(0),i=t.readUInt32BE(4);if(a!==0||i>2**31-1){uo(this.#n,1009,"Received payload length > 2^31 bytes.");return}if(this.#t.payloadLength=i,this.#r=To.READ_DATA,!this.#l())return}else if(this.#r===To.READ_DATA){if(this.#a<this.#t.payloadLength)return e();let t=this.consume(this.#t.payloadLength);if(Vw(this.#t.opcode))this.#i=this.parseControlFrame(t),this.#r=To.INFO;else if(this.#t.compressed){this.#s.get("permessage-deflate").decompress(t,this.#t.fin,(a,i)=>{if(a){let r=a instanceof l5?1009:1007;uo(this.#n,r,a.message);return}if(this.writeFragments(i)){if(this.#u>0&&this.#o>this.#u){uo(this.#n,1009,new l5().message);return}if(!this.#t.fin){this.#r=To.INFO,this.#i=!0,this.run(e);return}c5(this.#n,this.#t.binaryType,this.consumeFragments()),this.#i=!0,this.#r=To.INFO,this.run(e)}},this.#o),this.#i=!1;break}else{if(!this.writeFragments(t))return;!this.#t.fragmented&&this.#t.fin&&c5(this.#n,this.#t.binaryType,this.consumeFragments()),this.#r=To.INFO}}}consume(e){if(e>this.#a)throw new Error("Called consume() before buffers satiated.");if(e===0)return n5;this.#a-=e;let t=this.#e[0];if(t.length>e)return this.#e[0]=t.subarray(e,t.length),t.subarray(0,e);if(t.length===e)return this.#e.shift();{let a=0,i=Buffer.allocUnsafeSlow(e);for(;a!==e;){let r=this.#e[0],s=r.length;if(s+a===e){i.set(this.#e.shift(),a);break}else if(s+a>e){i.set(r.subarray(0,e-a),a),this.#e[0]=r.subarray(e-a);break}else i.set(this.#e.shift(),a),a+=s}return i}}writeFragments(e){return this.#m>0&&this.#c.length===this.#m?(uo(this.#n,1008,"Too many message fragments"),!1):(this.#o+=e.length,this.#c.push(e),!0)}consumeFragments(){let e=this.#c;if(e.length===1)return this.#o=0,e.shift();let t=0,a=Buffer.allocUnsafeSlow(this.#o);for(let i=0;i<e.length;++i){let r=e[i];a.set(r,t),t+=r.length}return this.#c=[],this.#o=0,a}parseCloseBody(e){One(e.length!==1);let t;if(e.length>=2&&(t=e.readUInt16BE(0)),t!==void 0&&!_ne(t))return{code:1002,reason:"Invalid status code",error:!0};let a=e.subarray(2);a[0]===239&&a[1]===187&&a[2]===191&&(a=a.subarray(3));try{a=Fne(a)}catch{return{code:1007,reason:"Invalid UTF-8",error:!0}}return{code:t,reason:a,error:!1}}parseControlFrame(e){let{opcode:t,payloadLength:a}=this.#t;if(t===In.CLOSE){if(a===1)return uo(this.#n,1002,"Received close frame with a 1-byte body."),!1;if(this.#t.closeInfo=this.parseCloseBody(e),this.#t.closeInfo.error){let{code:i,reason:r}=this.#t.closeInfo;return uo(this.#n,i,r),!1}if(!this.#n.closeState.has(Km.SENT)&&!this.#n.closeState.has(Km.RECEIVED)){let i=n5;this.#t.closeInfo.code&&(i=Buffer.allocUnsafe(2),i.writeUInt16BE(this.#t.closeInfo.code,0));let r=new m5(i);this.#n.socket.write(r.createFrame(In.CLOSE)),this.#n.closeState.add(Km.SENT)}return this.#n.readyState=Mne.CLOSING,this.#n.closeState.add(Km.RECEIVED),!1}else if(t===In.PING){if(!this.#n.closeState.has(Km.RECEIVED)){let i=new m5(e);this.#n.socket.write(i.createFrame(In.PONG)),this.#n.onPing(e)}}else t===In.PONG&&this.#n.onPong(e);return!0}get closingInfo(){return this.#t.closeInfo}};u5.exports={ByteParser:Ww}});var h5=y((che,p5)=>{"use strict";var{WebsocketFrameSend:g5}=En(),{opcodes:d5,sendHints:es}=Mi(),Gne=bk(),Zw=class{#e=new Gne;#o=!1;#a;constructor(e){this.#a=e}add(e,t,a){if(a!==es.blob){if(this.#o){let r={promise:null,callback:t,frame:Kw(e,a)};this.#e.push(r)}else if(a===es.text){let{0:r,1:s}=g5.createFastTextFrame(e);this.#a.cork(),this.#a.write(r),this.#a.write(s,t),this.#a.uncork()}else this.#a.write(Kw(e,a),t);return}let i={promise:e.arrayBuffer().then(r=>{i.promise=null,i.frame=Kw(r,a)}),callback:t,frame:null};this.#e.push(i),this.#o||this.#i()}async#i(){this.#o=!0;let e=this.#e;for(;!e.isEmpty();){let t=e.shift();t.promise!==null&&await t.promise,this.#a.write(t.frame,t.callback),t.callback=t.frame=null}this.#o=!1}};function Kw(o,e){return new g5(Yne(o,e)).createFrame(e===es.text?d5.TEXT:d5.BINARY)}function Yne(o,e){switch(e){case es.text:case es.typedArray:return new Uint8Array(o.buffer,o.byteOffset,o.byteLength);case es.arrayBuffer:case es.blob:return new Uint8Array(o)}}p5.exports={SendQueue:Zw}});var w5=y((mhe,A5)=>{"use strict";var{isArrayBuffer:Vne}=require("util/types"),{webidl:_}=to(),{URLSerializer:$ne}=bt(),{environmentSettingsObject:f5}=Vo(),{staticPropertyDescriptors:_i,states:Ga,sentCloseFrameState:Xw,sendHints:Mg,opcodes:ev}=Mi(),{isConnecting:Wne,isEstablished:b5,isClosing:y5,isClosed:Jne,isValidSubprotocol:Kne,fireEvent:_g,utf8Decode:Zne,toArrayBuffer:Xne,getURLRecord:ece}=Xr(),{establishWebSocketConnection:oce,closeWebSocketConnection:tce,failWebsocketConnection:k5}=Ug(),{ByteParser:ace}=Jw(),{kEnumerableProperty:qt}=K(),{getGlobalDispatcher:ice}=ag(),{ErrorEvent:rce,CloseEvent:sce,createFastMessageEvent:nce}=Tg(),{SendQueue:cce}=h5(),{WebsocketFrameSend:mce}=En(),{channels:ga}=yi();function lce(o){return typeof o?.address=="function"?o.address():typeof o?.session?.socket?.address=="function"?o.session.socket.address():null}var wo=class o extends EventTarget{#e={open:null,error:null,close:null,message:null};#o=0;#a="";#i="";#r;#t={onConnectionEstablished:(e,t)=>this.#m(e,t),onMessage:(e,t)=>this.#u(e,t),onParserError:e=>k5(this.#t,null,e.message),onParserDrain:()=>this.#l(),onSocketData:e=>{this.#n.write(e)||this.#t.socket.pause()},onSocketError:e=>{this.#t.readyState=Ga.CLOSING,ga.socketError.hasSubscribers&&ga.socketError.publish(e),this.#t.socket.destroy()},onSocketClose:()=>this.#d(),onPing:e=>{ga.ping.hasSubscribers&&ga.ping.publish({payload:e,websocket:this})},onPong:e=>{ga.pong.hasSubscribers&&ga.pong.publish({payload:e,websocket:this})},readyState:Ga.CONNECTING,socket:null,closeState:new Set,controller:null,wasEverConnected:!1};#c;#s;#n;constructor(e,t=[]){super(),_.util.markAsUncloneable(this);let a="WebSocket constructor";_.argumentLengthCheck(arguments,1,a);let i=_.converters["DOMString or sequence<DOMString> or WebSocketInit"](t,a,"options");e=_.converters.USVString(e),t=i.protocols;let r=f5.settingsObject.baseUrl,s=ece(e,r);if(typeof t=="string"&&(t=[t]),t.length!==new Set(t.map(c=>c.toLowerCase())).size)throw new DOMException("Invalid Sec-WebSocket-Protocol value","SyntaxError");if(t.length>0&&!t.every(c=>Kne(c)))throw new DOMException("Invalid Sec-WebSocket-Protocol value","SyntaxError");this.#c=new URL(s.href);let n=f5.settingsObject;this.#t.controller=oce(s,t,n,this.#t,i),this.#t.readyState=o.CONNECTING,this.#s="blob"}close(e=void 0,t=void 0){_.brandCheck(this,o),e!==void 0&&(e=_.converters["unsigned short"](e,"WebSocket.close","code",_.attributes.Clamp)),t!==void 0&&(t=_.converters.USVString(t)),e??=null,t??="",tce(this.#t,e,t,!0)}send(e){_.brandCheck(this,o);let t="WebSocket.send";if(_.argumentLengthCheck(arguments,1,t),e=_.converters.WebSocketSendData(e,t,"data"),Wne(this.#t.readyState))throw new DOMException("Sent before connected.","InvalidStateError");if(!(!b5(this.#t.readyState)||y5(this.#t.readyState)))if(typeof e=="string"){let a=Buffer.from(e);this.#o+=a.byteLength,this.#r.add(a,()=>{this.#o-=a.byteLength},Mg.text)}else Vne(e)?(this.#o+=e.byteLength,this.#r.add(e,()=>{this.#o-=e.byteLength},Mg.arrayBuffer)):ArrayBuffer.isView(e)?(this.#o+=e.byteLength,this.#r.add(e,()=>{this.#o-=e.byteLength},Mg.typedArray)):_.is.Blob(e)&&(this.#o+=e.size,this.#r.add(e,()=>{this.#o-=e.size},Mg.blob))}get readyState(){return _.brandCheck(this,o),this.#t.readyState}get bufferedAmount(){return _.brandCheck(this,o),this.#o}get url(){return _.brandCheck(this,o),$ne(this.#c)}get extensions(){return _.brandCheck(this,o),this.#i}get protocol(){return _.brandCheck(this,o),this.#a}get onopen(){return _.brandCheck(this,o),this.#e.open}set onopen(e){_.brandCheck(this,o),this.#e.open&&this.removeEventListener("open",this.#e.open);let t=_.converters.EventHandlerNonNull(e);t!==null?(this.addEventListener("open",t),this.#e.open=e):this.#e.open=null}get onerror(){return _.brandCheck(this,o),this.#e.error}set onerror(e){_.brandCheck(this,o),this.#e.error&&this.removeEventListener("error",this.#e.error);let t=_.converters.EventHandlerNonNull(e);t!==null?(this.addEventListener("error",t),this.#e.error=e):this.#e.error=null}get onclose(){return _.brandCheck(this,o),this.#e.close}set onclose(e){_.brandCheck(this,o),this.#e.close&&this.removeEventListener("close",this.#e.close);let t=_.converters.EventHandlerNonNull(e);t!==null?(this.addEventListener("close",t),this.#e.close=e):this.#e.close=null}get onmessage(){return _.brandCheck(this,o),this.#e.message}set onmessage(e){_.brandCheck(this,o),this.#e.message&&this.removeEventListener("message",this.#e.message);let t=_.converters.EventHandlerNonNull(e);t!==null?(this.addEventListener("message",t),this.#e.message=e):this.#e.message=null}get binaryType(){return _.brandCheck(this,o),this.#s}set binaryType(e){_.brandCheck(this,o),e!=="blob"&&e!=="arraybuffer"?this.#s="blob":this.#s=e}#m(e,t){this.#t.socket=e.socket;let a=this.#t.controller.dispatcher?.webSocketOptions,i=a?.maxFragments,r=a?.maxPayloadSize,s=new ace(this.#t,t,{maxFragments:i,maxPayloadSize:r});s.on("drain",()=>this.#t.onParserDrain()),s.on("error",m=>this.#t.onParserError(m)),this.#n=s,this.#r=new cce(e.socket),this.#t.readyState=Ga.OPEN;let n=e.headersList.get("sec-websocket-extensions");n!==null&&(this.#i=n);let c=e.headersList.get("sec-websocket-protocol");if(c!==null&&(this.#a=c),_g("open",this),ga.open.hasSubscribers){let m=e.headersList.entries;ga.open.publish({address:lce(e.socket),protocol:this.#a,extensions:this.#i,websocket:this,handshakeResponse:{status:e.status,statusText:e.statusText,headers:m}})}}#u(e,t){if(this.#t.readyState!==Ga.OPEN)return;let a;if(e===ev.TEXT)try{a=Zne(t)}catch{k5(this.#t,1007,"Received invalid UTF-8 in text frame.");return}else e===ev.BINARY&&(this.#s==="blob"?a=new Blob([t]):a=Xne(t));_g("message",this,nce,{origin:this.#c.origin,data:a})}#l(){this.#t.socket.resume()}#d(){let e=this.#t.closeState.has(Xw.SENT)&&this.#t.closeState.has(Xw.RECEIVED),t=1005,a="",i=this.#n?.closingInfo;i&&!i.error&&(t=i.code??1005,a=i.reason),this.#t.readyState=Ga.CLOSED,this.#t.closeState.has(Xw.RECEIVED)||(t=1006,_g("error",this,(r,s)=>new rce(r,s),{error:new TypeError(a)})),_g("close",this,(r,s)=>new sce(r,s),{wasClean:e,code:t,reason:a}),ga.close.hasSubscribers&&ga.close.publish({websocket:this,code:t,reason:a})}static ping(e,t){if(Buffer.isBuffer(t)){if(t.length>125)throw new TypeError("A PING frame cannot have a body larger than 125 bytes.")}else if(t!==void 0)throw new TypeError("Expected buffer payload");let a=e.#t.readyState;if(b5(a)&&!y5(a)&&!Jne(a)){let i=new mce(t);e.#t.socket.write(i.createFrame(ev.PING))}}},{ping:uce}=wo;Reflect.deleteProperty(wo,"ping");wo.CONNECTING=wo.prototype.CONNECTING=Ga.CONNECTING;wo.OPEN=wo.prototype.OPEN=Ga.OPEN;wo.CLOSING=wo.prototype.CLOSING=Ga.CLOSING;wo.CLOSED=wo.prototype.CLOSED=Ga.CLOSED;Object.defineProperties(wo.prototype,{CONNECTING:_i,OPEN:_i,CLOSING:_i,CLOSED:_i,url:qt,readyState:qt,bufferedAmount:qt,onopen:qt,onerror:qt,onclose:qt,close:qt,onmessage:qt,binaryType:qt,send:qt,extensions:qt,protocol:qt,[Symbol.toStringTag]:{value:"WebSocket",writable:!1,enumerable:!1,configurable:!0}});Object.defineProperties(wo,{CONNECTING:_i,OPEN:_i,CLOSING:_i,CLOSED:_i});_.converters["sequence<DOMString>"]=_.sequenceConverter(_.converters.DOMString);_.converters["DOMString or sequence<DOMString>"]=function(o,e,t){return _.util.Type(o)===_.util.Types.OBJECT&&Symbol.iterator in o?_.converters["sequence<DOMString>"](o):_.converters.DOMString(o,e,t)};_.converters.WebSocketInit=_.dictionaryConverter([{key:"protocols",converter:_.converters["DOMString or sequence<DOMString>"],defaultValue:()=>[]},{key:"dispatcher",converter:_.converters.any,defaultValue:()=>ice()},{key:"headers",converter:_.nullableConverter(_.converters.HeadersInit)}]);_.converters["DOMString or sequence<DOMString> or WebSocketInit"]=function(o){return _.util.Type(o)===_.util.Types.OBJECT&&!(Symbol.iterator in o)?_.converters.WebSocketInit(o):{protocols:_.converters["DOMString or sequence<DOMString>"](o)}};_.converters.WebSocketSendData=function(o){return _.util.Type(o)===_.util.Types.OBJECT&&(_.is.Blob(o)||_.is.BufferSource(o))?o:_.converters.USVString(o)};A5.exports={WebSocket:wo,ping:uce}});var ov=y((lhe,z5)=>{"use strict";var{webidl:Lg}=to(),{validateCloseCodeAndReason:dce}=Xr(),{kConstruct:v5}=de(),{kEnumerableProperty:x5}=K();function gce(){class o extends DOMException{get reason(){return""}}return new o().reason!==void 0?DOMException:new Proxy(DOMException,{construct(e,t,a){let i=Reflect.construct(e,t,e);return Object.setPrototypeOf(i,a.prototype),i}})}var os=class o extends gce(){#e;#o;constructor(e="",t=void 0){if(e=Lg.converters.DOMString(e,"WebSocketError","message"),super(e,"WebSocketError"),t===v5)return;t!==null&&(t=Lg.converters.WebSocketCloseInfo(t));let a=t.closeCode??null,i=t.reason??"";dce(a,i),i.length!==0&&a===null&&(a=1e3),this.#e=a,this.#o=i}get closeCode(){return this.#e}get reason(){return this.#o}static createUnvalidatedWebSocketError(e,t,a){let i=new o(e,v5);return i.#e=t,i.#o=a,i}},{createUnvalidatedWebSocketError:pce}=os;delete os.createUnvalidatedWebSocketError;Object.defineProperties(os.prototype,{closeCode:x5,reason:x5,[Symbol.toStringTag]:{value:"WebSocketError",writable:!1,enumerable:!1,configurable:!0}});Lg.is.WebSocketError=Lg.util.MakeTypeAssertion(os);z5.exports={WebSocketError:os,createUnvalidatedWebSocketError:pce}});var j5=y((uhe,C5)=>{"use strict";var{createDeferredPromise:tv}=im(),{environmentSettingsObject:q5}=Vo(),{states:Cn,opcodes:Fg,sentCloseFrameState:jn}=Mi(),{webidl:Re}=to(),{getURLRecord:hce,isValidSubprotocol:fce,isEstablished:bce,utf8Decode:yce}=Xr(),{establishWebSocketConnection:kce,failWebsocketConnection:av,closeWebSocketConnection:iv}=Ug(),{channels:E5}=yi(),{WebsocketFrameSend:Ace}=En(),{ByteParser:wce}=Jw(),{WebSocketError:vce,createUnvalidatedWebSocketError:xce}=ov(),{kEnumerableProperty:Pg}=K(),{utf8DecodeBytes:zce}=md(),I5=!1,Hg=class{#e;#o;#a;#i;#r;#t;#c=!1;#s={onConnectionEstablished:(e,t)=>this.#u(e,t),onMessage:(e,t)=>this.#l(e,t),onParserError:e=>av(this.#s,null,e.message),onParserDrain:()=>this.#s.socket.resume(),onSocketData:e=>{this.#n.write(e)||this.#s.socket.pause()},onSocketError:e=>{this.#s.readyState=Cn.CLOSING,E5.socketError.hasSubscribers&&E5.socketError.publish(e),this.#s.socket.destroy()},onSocketClose:()=>this.#d(),onPing:()=>{},onPong:()=>{},readyState:Cn.CONNECTING,socket:null,closeState:new Set,controller:null,wasEverConnected:!1};#n;constructor(e,t=void 0){I5||(process.emitWarning("WebSocketStream is experimental! Expect it to change at any time.",{code:"UNDICI-WSS"}),I5=!0),Re.argumentLengthCheck(arguments,1,"WebSocket"),e=Re.converters.USVString(e),t!==null&&(t=Re.converters.WebSocketStreamOptions(t));let a=q5.settingsObject.baseUrl,i=hce(e,a),r=t.protocols;if(r.length!==new Set(r.map(n=>n.toLowerCase())).size)throw new DOMException("Invalid Sec-WebSocket-Protocol value","SyntaxError");if(r.length>0&&!r.every(n=>fce(n)))throw new DOMException("Invalid Sec-WebSocket-Protocol value","SyntaxError");if(this.#e=i.toString(),this.#o=tv(),this.#a=tv(),t.signal!=null){let n=t.signal;if(n.aborted){this.#o.reject(n.reason),this.#a.reject(n.reason);return}n.addEventListener("abort",()=>{bce(this.#s.readyState)||(av(this.#s),this.#s.readyState=Cn.CLOSING,this.#o.reject(n.reason),this.#a.reject(n.reason),this.#c=!0)},{once:!0})}let s=q5.settingsObject;this.#s.controller=kce(i,r,s,this.#s,t)}get url(){return this.#e.toString()}get opened(){return this.#o.promise}get closed(){return this.#a.promise}close(e=void 0){e!==null&&(e=Re.converters.WebSocketCloseInfo(e));let t=e.closeCode??null,a=e.reason;iv(this.#s,t,a,!0)}#m(e){e=Re.converters.WebSocketStreamWrite(e);let t=tv(),a=null,i=null;if(Re.is.BufferSource(e))a=new Uint8Array(ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):e.slice()),i=Fg.BINARY;else{let r;try{r=Re.converters.DOMString(e)}catch(s){return t.reject(s),t.promise}a=new TextEncoder().encode(r),i=Fg.TEXT}if(!this.#s.closeState.has(jn.SENT)&&!this.#s.closeState.has(jn.RECEIVED)){let r=new Ace(a);this.#s.socket.write(r.createFrame(i),()=>{t.resolve(void 0)})}return t.promise}#u(e,t){this.#s.socket=e.socket;let a=this.#s.controller.dispatcher?.webSocketOptions?.maxFragments,i=this.#s.controller.dispatcher?.webSocketOptions?.maxPayloadSize,r=new wce(this.#s,t,{maxFragments:a,maxPayloadSize:i});r.on("drain",()=>this.#s.onParserDrain()),r.on("error",l=>this.#s.onParserError(l)),this.#n=r,this.#s.readyState=Cn.OPEN;let s=t??"",n=e.headersList.get("sec-websocket-protocol")??"",c=new ReadableStream({start:l=>{this.#r=l},cancel:l=>this.#g(l)}),m=new WritableStream({write:l=>this.#m(l),close:()=>iv(this.#s,null,null),abort:l=>this.#p(l)});this.#i=c,this.#t=m,this.#o.resolve({extensions:s,protocol:n,readable:c,writable:m})}#l(e,t){if(this.#s.readyState!==Cn.OPEN)return;let a;if(e===Fg.TEXT)try{a=yce(t)}catch{av(this.#s,1007,"Received invalid UTF-8 in text frame.");return}else e===Fg.BINARY&&(a=new Uint8Array(t.buffer,t.byteOffset,t.byteLength));this.#r.enqueue(a)}#d(){let e=this.#s.closeState.has(jn.SENT)&&this.#s.closeState.has(jn.RECEIVED);if(this.#s.readyState=Cn.CLOSED,this.#c)return;this.#s.wasEverConnected||this.#o.reject(new vce("Socket never opened"));let t=this.#n?.closingInfo,a=t?.code??1005;!this.#s.closeState.has(jn.SENT)&&!this.#s.closeState.has(jn.RECEIVED)&&(a=1006);let i=t?.reason==null?"":zce(Buffer.from(t.reason));if(e)this.#r.close(),this.#t.locked||this.#t.abort(new DOMException("A closed WebSocketStream cannot be written to","InvalidStateError")),this.#a.resolve({closeCode:a,reason:i});else{let r=xce("unclean close",a,i);this.#r?.error(r),this.#t?.abort(r),this.#a.reject(r)}}#p(e){let t=null,a="";Re.is.WebSocketError(e)&&(t=e.closeCode,a=e.reason),iv(this.#s,t,a)}#g(e){this.#p(e)}};Object.defineProperties(Hg.prototype,{url:Pg,opened:Pg,closed:Pg,close:Pg,[Symbol.toStringTag]:{value:"WebSocketStream",writable:!1,enumerable:!1,configurable:!0}});Re.converters.WebSocketStreamOptions=Re.dictionaryConverter([{key:"protocols",converter:Re.sequenceConverter(Re.converters.USVString),defaultValue:()=>[]},{key:"signal",converter:Re.nullableConverter(Re.converters.AbortSignal),defaultValue:()=>null}]);Re.converters.WebSocketCloseInfo=Re.dictionaryConverter([{key:"closeCode",converter:o=>Re.converters["unsigned short"](o,Re.attributes.EnforceRange)},{key:"reason",converter:Re.converters.USVString,defaultValue:()=>""}]);Re.converters.WebSocketStreamWrite=function(o){return typeof o=="string"?Re.converters.USVString(o):Re.converters.BufferSource(o)};C5.exports={WebSocketStream:Hg}});var Q5=y((dhe,B5)=>{"use strict";function qce(o){return o.indexOf("\0")===-1}function Ece(o){if(o.length===0)return!1;for(let e=0;e<o.length;e++)if(o.charCodeAt(e)<48||o.charCodeAt(e)>57)return!1;return!0}B5.exports={isValidLastEventId:qce,isASCIINumber:Ece}});var R5=y((ghe,T5)=>{"use strict";var{Transform:Ice}=require("stream"),{isASCIINumber:S5,isValidLastEventId:D5}=Q5(),Ya=[239,187,191],rv=10,Gg=13,Cce=58,jce=32,sv=class extends Ice{state;checkBOM=!0;crlfCheck=!1;eventEndCheck=!1;buffer=null;pos=0;event={data:void 0,event:void 0,id:void 0,retry:void 0};constructor(e={}){e.readableObjectMode=!0,super(e),this.state=e.eventSourceSettings||{},e.push&&(this.push=e.push)}_transform(e,t,a){if(e.length===0){a();return}if(this.buffer?this.buffer=Buffer.concat([this.buffer,e]):this.buffer=e,this.checkBOM)switch(this.buffer.length){case 1:if(this.buffer[0]===Ya[0]){a();return}this.checkBOM=!1,a();return;case 2:if(this.buffer[0]===Ya[0]&&this.buffer[1]===Ya[1]){a();return}this.checkBOM=!1;break;case 3:if(this.buffer[0]===Ya[0]&&this.buffer[1]===Ya[1]&&this.buffer[2]===Ya[2]){this.buffer=Buffer.alloc(0),this.checkBOM=!1,a();return}this.checkBOM=!1;break;default:this.buffer[0]===Ya[0]&&this.buffer[1]===Ya[1]&&this.buffer[2]===Ya[2]&&(this.buffer=this.buffer.subarray(3)),this.checkBOM=!1;break}for(;this.pos<this.buffer.length;){if(this.eventEndCheck){if(this.crlfCheck){if(this.buffer[this.pos]===rv){this.buffer=this.buffer.subarray(this.pos+1),this.pos=0,this.crlfCheck=!1;continue}this.crlfCheck=!1}if(this.buffer[this.pos]===rv||this.buffer[this.pos]===Gg){this.buffer[this.pos]===Gg&&(this.crlfCheck=!0),this.buffer=this.buffer.subarray(this.pos+1),this.pos=0,(this.event.data!==void 0||this.event.event||this.event.id!==void 0||this.event.retry)&&this.processEvent(this.event),this.clearEvent();continue}this.eventEndCheck=!1;continue}if(this.buffer[this.pos]===rv||this.buffer[this.pos]===Gg){this.buffer[this.pos]===Gg&&(this.crlfCheck=!0),this.parseLine(this.buffer.subarray(0,this.pos),this.event),this.buffer=this.buffer.subarray(this.pos+1),this.pos=0,this.eventEndCheck=!0;continue}this.pos++}a()}parseLine(e,t){if(e.length===0)return;let a=e.indexOf(Cce);if(a===0)return;let i="",r="";if(a!==-1){i=e.subarray(0,a).toString("utf8");let s=a+1;e[s]===jce&&++s,r=e.subarray(s).toString("utf8")}else i=e.toString("utf8"),r="";switch(i){case"data":t[i]===void 0?t[i]=r:t[i]+=`
1409
- ${r}`;break;case"retry":S5(r)&&(t[i]=r);break;case"id":D5(r)&&(t[i]=r);break;case"event":r.length>0&&(t[i]=r);break}}processEvent(e){e.retry&&S5(e.retry)&&(this.state.reconnectionTime=parseInt(e.retry,10)),e.id!==void 0&&D5(e.id)&&(this.state.lastEventId=e.id),e.data!==void 0&&this.push({type:e.event||"message",options:{data:e.data,lastEventId:this.state.lastEventId,origin:this.state.origin}})}clearEvent(){this.event={data:void 0,event:void 0,id:void 0,retry:void 0}}};T5.exports={EventSourceStream:sv}});var P5=y((phe,F5)=>{"use strict";var{pipeline:Bce}=require("stream"),{fetching:Qce}=Gm(),{makeRequest:Sce}=An(),{webidl:vo}=to(),{EventSourceStream:Dce}=R5(),{parseMIMEType:Tce}=bt(),{createFastMessageEvent:Rce}=Tg(),{isNetworkError:N5}=Fm(),{kEnumerableProperty:ts}=K(),{environmentSettingsObject:U5}=Vo(),O5=!1,M5=3e3,Zm=0,_5=1,Xm=2,Nce="anonymous",Uce="use-credentials",Bn=class o extends EventTarget{#e={open:null,error:null,message:null};#o;#a=!1;#i=Zm;#r=null;#t=null;#c;#s;constructor(e,t={}){super(),vo.util.markAsUncloneable(this);let a="EventSource constructor";vo.argumentLengthCheck(arguments,1,a),O5||(O5=!0,process.emitWarning("EventSource is experimental, expect them to change at any time.",{code:"UNDICI-ES"})),e=vo.converters.USVString(e),t=vo.converters.EventSourceInitDict(t,a,"eventSourceInitDict"),this.#c=t.node.dispatcher||t.dispatcher,this.#s={lastEventId:"",reconnectionTime:t.node.reconnectionTime};let i=U5,r;try{r=new URL(e,i.settingsObject.baseUrl),this.#s.origin=r.origin}catch(c){throw new DOMException(c,"SyntaxError")}this.#o=r.href;let s=Nce;t.withCredentials===!0&&(s=Uce,this.#a=!0);let n={redirect:"follow",keepalive:!0,mode:"cors",credentials:s==="anonymous"?"same-origin":"omit",referrer:"no-referrer"};n.client=U5.settingsObject,n.headersList=[["accept",{name:"accept",value:"text/event-stream"}]],n.cache="no-store",n.initiator="other",n.urlList=[new URL(this.#o)],this.#r=Sce(n),this.#n()}get readyState(){return this.#i}get url(){return this.#o}get withCredentials(){return this.#a}#n(){if(this.#i===Xm)return;this.#i=Zm;let e={request:this.#r,dispatcher:this.#c},t=a=>{if(!N5(a))return this.#m()};e.processResponseEndOfBody=t,e.processResponse=a=>{if(N5(a))if(a.aborted){this.close(),this.dispatchEvent(new Event("error"));return}else{this.#m();return}let i=a.headersList.get("content-type",!0),r=i!==null?Tce(i):"failure",s=r!=="failure"&&r.essence==="text/event-stream";if(a.status!==200||s===!1){this.close(),this.dispatchEvent(new Event("error"));return}this.#i=_5,this.dispatchEvent(new Event("open")),this.#s.origin=a.urlList[a.urlList.length-1].origin;let n=new Dce({eventSourceSettings:this.#s,push:c=>{this.dispatchEvent(Rce(c.type,c.options))}});Bce(a.body.stream,n,c=>{c?.aborted===!1&&(this.close(),this.dispatchEvent(new Event("error")))})},this.#t=Qce(e)}#m(){this.#i!==Xm&&(this.#i=Zm,this.dispatchEvent(new Event("error")),setTimeout(()=>{this.#i===Zm&&(this.#s.lastEventId.length&&this.#r.headersList.set("last-event-id",this.#s.lastEventId,!0),this.#n())},this.#s.reconnectionTime)?.unref())}close(){vo.brandCheck(this,o),this.#i!==Xm&&(this.#i=Xm,this.#t.abort(),this.#r=null)}get onopen(){return this.#e.open}set onopen(e){this.#e.open&&this.removeEventListener("open",this.#e.open);let t=vo.converters.EventHandlerNonNull(e);t!==null?(this.addEventListener("open",t),this.#e.open=e):this.#e.open=null}get onmessage(){return this.#e.message}set onmessage(e){this.#e.message&&this.removeEventListener("message",this.#e.message);let t=vo.converters.EventHandlerNonNull(e);t!==null?(this.addEventListener("message",t),this.#e.message=e):this.#e.message=null}get onerror(){return this.#e.error}set onerror(e){this.#e.error&&this.removeEventListener("error",this.#e.error);let t=vo.converters.EventHandlerNonNull(e);t!==null?(this.addEventListener("error",t),this.#e.error=e):this.#e.error=null}},L5={CONNECTING:{__proto__:null,configurable:!1,enumerable:!0,value:Zm,writable:!1},OPEN:{__proto__:null,configurable:!1,enumerable:!0,value:_5,writable:!1},CLOSED:{__proto__:null,configurable:!1,enumerable:!0,value:Xm,writable:!1}};Object.defineProperties(Bn,L5);Object.defineProperties(Bn.prototype,L5);Object.defineProperties(Bn.prototype,{close:ts,onerror:ts,onmessage:ts,onopen:ts,readyState:ts,url:ts,withCredentials:ts});vo.converters.EventSourceInitDict=vo.dictionaryConverter([{key:"withCredentials",converter:vo.converters.boolean,defaultValue:()=>!1},{key:"dispatcher",converter:vo.converters.any},{key:"node",converter:vo.dictionaryConverter([{key:"reconnectionTime",converter:vo.converters["unsigned long"],defaultValue:()=>M5},{key:"dispatcher",converter:vo.converters.any}]),defaultValue:()=>({})}]);F5.exports={EventSource:Bn,defaultReconnectionTime:M5}});var W5=y((hhe,Q)=>{"use strict";var Oce=Ii(),G5=Kc(),Mce=Sr(),_ce=j8(),Lce=D8(),Fce=Rr(),Pce=Hk(),Hce=_k(),Gce=yB(),Yce=qB(),Vce=CB(),Y5=$(),Vg=K(),{InvalidArgumentError:Yg}=Y5,Qn=mQ(),$ce=wr(),Wce=jA(),{MockCallHistory:Jce,MockCallHistoryLog:Kce}=SA(),Zce=LA(),Xce=NA(),eme=c4(),ome=dA(),tme=Fd(),{getGlobalDispatcher:V5,setGlobalDispatcher:ame}=ag(),ime=pn(),rme=WA();Object.assign(G5.prototype,Qn);Q.exports.Dispatcher=G5;Q.exports.Client=Oce;Q.exports.Pool=Mce;Q.exports.BalancedPool=_ce;Q.exports.RoundRobinPool=Lce;Q.exports.Agent=Fce;Q.exports.ProxyAgent=Pce;Q.exports.Socks5ProxyAgent=Hce;Q.exports.EnvHttpProxyAgent=Gce;Q.exports.RetryAgent=Yce;Q.exports.H2CClient=Vce;Q.exports.RetryHandler=tme;Q.exports.DecoratorHandler=ime;Q.exports.RedirectHandler=rme;Q.exports.interceptors={redirect:k4(),responseError:w4(),retry:x4(),dump:q4(),dns:j4(),cache:n3(),decompress:d3(),deduplicate:b3()};Q.exports.cacheStores={MemoryCacheStore:lw()};var sme=A3();Q.exports.cacheStores.SqliteCacheStore=sme;Q.exports.buildConnector=$ce;Q.exports.errors=Y5;Q.exports.util={parseHeaders:Vg.parseHeaders,headerNameToString:Vg.headerNameToString};function el(o){return(e,t,a)=>{if(typeof t=="function"&&(a=t,t=null),!e||typeof e!="string"&&typeof e!="object"&&!(e instanceof URL))throw new Yg("invalid url");if(t!=null&&typeof t!="object")throw new Yg("invalid opts");if(t&&t.path!=null){if(typeof t.path!="string")throw new Yg("invalid opts.path");let s=t.path;t.path.startsWith("/")||(s=`/${s}`),e=new URL(Vg.parseOrigin(e).origin+s)}else t||(t=typeof e=="object"?e:{}),e=Vg.parseURL(e);let{agent:i,dispatcher:r=V5()}=t;if(i)throw new Yg("unsupported opts.agent. Did you mean opts.client?");return o.call(r,{...t,origin:e.origin,path:e.search?`${e.pathname}${e.search}`:e.pathname,method:t.method||(t.body?"PUT":"GET")},a)}}Q.exports.setGlobalDispatcher=ame;Q.exports.getGlobalDispatcher=V5;var nme=Gm().fetch,H5=typeof __filename<"u"?__filename:void 0;function $5(o,e){if(!o||typeof o!="object")return;let t=typeof o.stack=="string"?o.stack:"",a=e.replace(/\\/g,"/");if(t&&(t.includes(e)||t.includes(a)))return;let i={};if(Error.captureStackTrace(i,$5),!i.stack)return;let r=i.stack.split(`
1415
+ ${r}`;break;case"retry":S5(r)&&(t[i]=r);break;case"id":D5(r)&&(t[i]=r);break;case"event":r.length>0&&(t[i]=r);break}}processEvent(e){e.retry&&S5(e.retry)&&(this.state.reconnectionTime=parseInt(e.retry,10)),e.id!==void 0&&D5(e.id)&&(this.state.lastEventId=e.id),e.data!==void 0&&this.push({type:e.event||"message",options:{data:e.data,lastEventId:this.state.lastEventId,origin:this.state.origin}})}clearEvent(){this.event={data:void 0,event:void 0,id:void 0,retry:void 0}}};T5.exports={EventSourceStream:sv}});var P5=y((phe,F5)=>{"use strict";var{pipeline:Bce}=require("stream"),{fetching:Qce}=Gm(),{makeRequest:Sce}=An(),{webidl:vo}=to(),{EventSourceStream:Dce}=R5(),{parseMIMEType:Tce}=bt(),{createFastMessageEvent:Rce}=Tg(),{isNetworkError:N5}=Fm(),{kEnumerableProperty:ts}=K(),{environmentSettingsObject:U5}=Vo(),O5=!1,M5=3e3,Zm=0,_5=1,Xm=2,Nce="anonymous",Uce="use-credentials",Bn=class o extends EventTarget{#e={open:null,error:null,message:null};#o;#a=!1;#i=Zm;#r=null;#t=null;#c;#s;constructor(e,t={}){super(),vo.util.markAsUncloneable(this);let a="EventSource constructor";vo.argumentLengthCheck(arguments,1,a),O5||(O5=!0,process.emitWarning("EventSource is experimental, expect them to change at any time.",{code:"UNDICI-ES"})),e=vo.converters.USVString(e),t=vo.converters.EventSourceInitDict(t,a,"eventSourceInitDict"),this.#c=t.node.dispatcher||t.dispatcher,this.#s={lastEventId:"",reconnectionTime:t.node.reconnectionTime};let i=U5,r;try{r=new URL(e,i.settingsObject.baseUrl),this.#s.origin=r.origin}catch(c){throw new DOMException(c,"SyntaxError")}this.#o=r.href;let s=Nce;t.withCredentials===!0&&(s=Uce,this.#a=!0);let n={redirect:"follow",keepalive:!0,mode:"cors",credentials:s==="anonymous"?"same-origin":"omit",referrer:"no-referrer"};n.client=U5.settingsObject,n.headersList=[["accept",{name:"accept",value:"text/event-stream"}]],n.cache="no-store",n.initiator="other",n.urlList=[new URL(this.#o)],this.#r=Sce(n),this.#n()}get readyState(){return this.#i}get url(){return this.#o}get withCredentials(){return this.#a}#n(){if(this.#i===Xm)return;this.#i=Zm;let e={request:this.#r,dispatcher:this.#c},t=a=>{if(!N5(a))return this.#m()};e.processResponseEndOfBody=t,e.processResponse=a=>{if(N5(a))if(a.aborted){this.close(),this.dispatchEvent(new Event("error"));return}else{this.#m();return}let i=a.headersList.get("content-type",!0),r=i!==null?Tce(i):"failure",s=r!=="failure"&&r.essence==="text/event-stream";if(a.status!==200||s===!1){this.close(),this.dispatchEvent(new Event("error"));return}this.#i=_5,this.dispatchEvent(new Event("open")),this.#s.origin=a.urlList[a.urlList.length-1].origin;let n=new Dce({eventSourceSettings:this.#s,push:c=>{this.dispatchEvent(Rce(c.type,c.options))}});Bce(a.body.stream,n,c=>{c?.aborted===!1&&(this.close(),this.dispatchEvent(new Event("error")))})},this.#t=Qce(e)}#m(){this.#i!==Xm&&(this.#i=Zm,this.dispatchEvent(new Event("error")),setTimeout(()=>{this.#i===Zm&&(this.#s.lastEventId.length&&this.#r.headersList.set("last-event-id",this.#s.lastEventId,!0),this.#n())},this.#s.reconnectionTime)?.unref())}close(){vo.brandCheck(this,o),this.#i!==Xm&&(this.#i=Xm,this.#t.abort(),this.#r=null)}get onopen(){return this.#e.open}set onopen(e){this.#e.open&&this.removeEventListener("open",this.#e.open);let t=vo.converters.EventHandlerNonNull(e);t!==null?(this.addEventListener("open",t),this.#e.open=e):this.#e.open=null}get onmessage(){return this.#e.message}set onmessage(e){this.#e.message&&this.removeEventListener("message",this.#e.message);let t=vo.converters.EventHandlerNonNull(e);t!==null?(this.addEventListener("message",t),this.#e.message=e):this.#e.message=null}get onerror(){return this.#e.error}set onerror(e){this.#e.error&&this.removeEventListener("error",this.#e.error);let t=vo.converters.EventHandlerNonNull(e);t!==null?(this.addEventListener("error",t),this.#e.error=e):this.#e.error=null}},L5={CONNECTING:{__proto__:null,configurable:!1,enumerable:!0,value:Zm,writable:!1},OPEN:{__proto__:null,configurable:!1,enumerable:!0,value:_5,writable:!1},CLOSED:{__proto__:null,configurable:!1,enumerable:!0,value:Xm,writable:!1}};Object.defineProperties(Bn,L5);Object.defineProperties(Bn.prototype,L5);Object.defineProperties(Bn.prototype,{close:ts,onerror:ts,onmessage:ts,onopen:ts,readyState:ts,url:ts,withCredentials:ts});vo.converters.EventSourceInitDict=vo.dictionaryConverter([{key:"withCredentials",converter:vo.converters.boolean,defaultValue:()=>!1},{key:"dispatcher",converter:vo.converters.any},{key:"node",converter:vo.dictionaryConverter([{key:"reconnectionTime",converter:vo.converters["unsigned long"],defaultValue:()=>M5},{key:"dispatcher",converter:vo.converters.any}]),defaultValue:()=>({})}]);F5.exports={EventSource:Bn,defaultReconnectionTime:M5}});var W5=y((hhe,Q)=>{"use strict";var Oce=Ii(),G5=Kc(),Mce=Sr(),_ce=j8(),Lce=D8(),Fce=Rr(),Pce=Hk(),Hce=_k(),Gce=yB(),Yce=qB(),Vce=CB(),Y5=$(),Vg=K(),{InvalidArgumentError:Yg}=Y5,Qn=m4(),$ce=wr(),Wce=jA(),{MockCallHistory:Jce,MockCallHistoryLog:Kce}=SA(),Zce=LA(),Xce=NA(),eme=cQ(),ome=dA(),tme=Fd(),{getGlobalDispatcher:V5,setGlobalDispatcher:ame}=ag(),ime=pn(),rme=WA();Object.assign(G5.prototype,Qn);Q.exports.Dispatcher=G5;Q.exports.Client=Oce;Q.exports.Pool=Mce;Q.exports.BalancedPool=_ce;Q.exports.RoundRobinPool=Lce;Q.exports.Agent=Fce;Q.exports.ProxyAgent=Pce;Q.exports.Socks5ProxyAgent=Hce;Q.exports.EnvHttpProxyAgent=Gce;Q.exports.RetryAgent=Yce;Q.exports.H2CClient=Vce;Q.exports.RetryHandler=tme;Q.exports.DecoratorHandler=ime;Q.exports.RedirectHandler=rme;Q.exports.interceptors={redirect:kQ(),responseError:wQ(),retry:xQ(),dump:qQ(),dns:jQ(),cache:n3(),decompress:d3(),deduplicate:b3()};Q.exports.cacheStores={MemoryCacheStore:lw()};var sme=A3();Q.exports.cacheStores.SqliteCacheStore=sme;Q.exports.buildConnector=$ce;Q.exports.errors=Y5;Q.exports.util={parseHeaders:Vg.parseHeaders,headerNameToString:Vg.headerNameToString};function el(o){return(e,t,a)=>{if(typeof t=="function"&&(a=t,t=null),!e||typeof e!="string"&&typeof e!="object"&&!(e instanceof URL))throw new Yg("invalid url");if(t!=null&&typeof t!="object")throw new Yg("invalid opts");if(t&&t.path!=null){if(typeof t.path!="string")throw new Yg("invalid opts.path");let s=t.path;t.path.startsWith("/")||(s=`/${s}`),e=new URL(Vg.parseOrigin(e).origin+s)}else t||(t=typeof e=="object"?e:{}),e=Vg.parseURL(e);let{agent:i,dispatcher:r=V5()}=t;if(i)throw new Yg("unsupported opts.agent. Did you mean opts.client?");return o.call(r,{...t,origin:e.origin,path:e.search?`${e.pathname}${e.search}`:e.pathname,method:t.method||(t.body?"PUT":"GET")},a)}}Q.exports.setGlobalDispatcher=ame;Q.exports.getGlobalDispatcher=V5;var nme=Gm().fetch,H5=typeof __filename<"u"?__filename:void 0;function $5(o,e){if(!o||typeof o!="object")return;let t=typeof o.stack=="string"?o.stack:"",a=e.replace(/\\/g,"/");if(t&&(t.includes(e)||t.includes(a)))return;let i={};if(Error.captureStackTrace(i,$5),!i.stack)return;let r=i.stack.split(`
1410
1416
  `).slice(1).join(`
1411
1417
  `);o.stack=t?`${t}
1412
1418
  ${r}`:i.stack}Q.exports.fetch=function(e,t=void 0){return nme(e,t).catch(a=>{throw H5?$5(a,H5):a&&typeof a=="object"&&Error.captureStackTrace(a,Q.exports.fetch),a})};Q.exports.Headers=$r().Headers;Q.exports.Response=Fm().Response;Q.exports.Request=An().Request;Q.exports.FormData=hd().FormData;var{setGlobalOrigin:cme,getGlobalOrigin:mme}=qy();Q.exports.setGlobalOrigin=cme;Q.exports.getGlobalOrigin=mme;var{CacheStorage:lme}=B9(),{kConstruct:ume}=de();Q.exports.caches=new lme(ume);var{deleteCookie:dme,getCookies:gme,getSetCookies:pme,setCookie:hme,parseCookie:fme}=F9();Q.exports.deleteCookie=dme;Q.exports.getCookies=gme;Q.exports.getSetCookies=pme;Q.exports.setCookie=hme;Q.exports.parseCookie=fme;var{parseMIMEType:bme,serializeAMimeType:yme}=bt();Q.exports.parseMIMEType=bme;Q.exports.serializeAMimeType=yme;var{CloseEvent:kme,ErrorEvent:Ame,MessageEvent:wme}=Tg(),{WebSocket:vme,ping:xme}=w5();Q.exports.WebSocket=vme;Q.exports.CloseEvent=kme;Q.exports.ErrorEvent=Ame;Q.exports.MessageEvent=wme;Q.exports.ping=xme;Q.exports.WebSocketStream=j5().WebSocketStream;Q.exports.WebSocketError=ov().WebSocketError;Q.exports.request=el(Qn.request);Q.exports.stream=el(Qn.stream);Q.exports.pipeline=el(Qn.pipeline);Q.exports.connect=el(Qn.connect);Q.exports.upgrade=el(Qn.upgrade);Q.exports.MockClient=Wce;Q.exports.MockCallHistory=Jce;Q.exports.MockCallHistoryLog=Kce;Q.exports.MockPool=Xce;Q.exports.MockAgent=Zce;Q.exports.SnapshotAgent=eme;Q.exports.mockErrors=ome;var{EventSource:zme}=P5();Q.exports.EventSource=zme;function qme(){globalThis.fetch=Q.exports.fetch,globalThis.Headers=Q.exports.Headers,globalThis.Response=Q.exports.Response,globalThis.Request=Q.exports.Request,globalThis.FormData=Q.exports.FormData,globalThis.WebSocket=Q.exports.WebSocket,globalThis.CloseEvent=Q.exports.CloseEvent,globalThis.ErrorEvent=Q.exports.ErrorEvent,globalThis.MessageEvent=Q.exports.MessageEvent,globalThis.EventSource=Q.exports.EventSource}Q.exports.install=qme});var J5=y(Dn=>{"use strict";Object.defineProperty(Dn,"__esModule",{value:!0});Dn.SuperglueClient=Dn.SuperglueHttpError=void 0;var Sn=rt(),Va=Jf(),Eme=wb(),Ime=cI(),Cme=Kt(),$a=Cs(),jme=wu(),tl=14400*1e3,ol;if(typeof globalThis.process<"u"&&globalThis.process.versions?.node)try{let{Agent:o}=W5();ol=new o({headersTimeout:tl,bodyTimeout:tl})}catch{}var $g=class extends Error{constructor(e,t,a,i){super(e),this.status=t,this.code=a,this.details=i,this.name="SuperglueHttpError"}};Dn.SuperglueHttpError=$g;var nv=class{constructor({apiKey:e,apiEndpoint:t,onInfrastructureError:a,sseTokenProvider:i,tokenProvider:r}){if(!e&&!r)throw new Error("SuperglueClient requires either apiKey or tokenProvider");this.tokenProvider=r??(async()=>e),this.apiEndpoint=t??"https://api.superglue.cloud",this.sseManager=new Eme.SSELogSubscriptionManager(this.apiEndpoint,i??this.tokenProvider),this.onInfrastructureError=a}async getApiKey(){return this.tokenProvider()}isInfrastructureError(e){return(0,Cme.isAbortError)(e)?!1:!!(e instanceof TypeError&&e.message.toLowerCase().includes("fetch")||e instanceof Error&&e.name==="TimeoutError")}async restRequest(e,t,a,i,r){let n=await(await this.restResponse({method:e,path:t,body:a,extraHeaders:i,requestInit:r})).text();if(n)return JSON.parse(n)}async restResponse({method:e,path:t,body:a,extraHeaders:i,requestInit:r}){let s=`${this.apiEndpoint.replace(/\/$/,"")}${t}`,n=a!=null,c=typeof FormData<"u"&&a instanceof FormData,l={Authorization:`Bearer ${await this.getApiKey()}`,...i};n&&!c&&e!=="GET"&&(l["Content-Type"]="application/json");let u;try{u=await fetch(s,{...r,method:e,headers:l,body:n?c?a:JSON.stringify(a):void 0,signal:r?.signal??AbortSignal.timeout(tl),...ol?{dispatcher:ol}:{}})}catch(d){throw this.isInfrastructureError(d)&&this.onInfrastructureError?.(),d}if(!u.ok)throw await this.buildHttpError(u);return u}async uploadFiles(e,t){if(typeof t?.process!="boolean")throw new Error("process must be a boolean");if(e.length===0)return[];let a=e.map(l=>({...l,contentLength:l.contentLength??this.getUploadContentLength(l.content)})),r=(await this.restRequest("POST","/v1/files/uploads",{process:t.process,files:a.map(({fileName:l,contentType:u,contentLength:d})=>({fileName:l,contentLength:d,...u?{contentType:u}:{}}))})).data.files;if(r.length!==a.length)throw await Promise.all(r.map(l=>this.deleteFileUpload(l.id).catch(()=>{}))),new Error("Upload response did not match the selected files");let s=await Promise.allSettled(r.map(async(l,u)=>{let d=a[u],g=await fetch(l.uploadUrl,{method:"PUT",body:d.content,headers:d.contentType?{"Content-Type":d.contentType}:void 0,signal:AbortSignal.timeout(Math.min(tl,l.expiresIn*1e3))});if(!g.ok)throw new Error(`Upload failed for ${d.fileName}: ${g.status} ${g.statusText}`);return l.id})),n=s.flatMap(l=>l.status==="fulfilled"?[l.value]:[]),c=new Map;if(n.length>0)try{let l=await this.restRequest("POST","/v1/files/uploads/complete",{fileIds:n});c=new Map(l.data.files.map(u=>[u.id,u]))}catch(l){c=new Map(n.map(u=>[u,{id:u,fileName:a[r.findIndex(d=>d.id===u)]?.fileName||u,contentLength:a[r.findIndex(d=>d.id===u)]?.contentLength||0,status:"failed",error:l instanceof Error?l.message:String(l)}]))}let m=r.map((l,u)=>{let d=s[u],g=a[u];return d.status==="rejected"?{id:l.id,fileName:g.fileName,contentLength:g.contentLength,status:"failed",error:d.reason instanceof Error?d.reason.message:String(d.reason)}:c.get(l.id)||{id:l.id,fileName:g.fileName,contentLength:g.contentLength,status:"failed",error:"Upload completion returned no result"}});return await Promise.all(m.filter(l=>l.status==="failed").map(l=>this.deleteFileUpload(l.id).catch(()=>{}))),m}async deleteFileUpload(e){await this.restRequest("DELETE",`/v1/files/uploads/${encodeURIComponent(e)}`)}getUploadContentLength(e){return typeof e=="string"?new TextEncoder().encode(e).byteLength:e instanceof Uint8Array?e.byteLength:e.size}async buildHttpError(e){e.status>=500&&this.onInfrastructureError?.();let t=await e.text(),a=`HTTP ${e.status}: ${t}`,i,r;try{let s=JSON.parse(t);s&&typeof s=="object"&&!Array.isArray(s)&&(r=s),typeof s?.code=="string"&&(i=s.code);let n=s.error;typeof n=="string"?a=n:n&&typeof n=="object"&&(a=n.message||JSON.stringify(n))}catch{}return new $g(a,e.status,i,r)}async streamRequest(e,t,a){let i=e.includes("?")?"&":"?",r=`${this.apiEndpoint.replace(/\/$/,"")}${e}${i}stream=true`,n={Authorization:`Bearer ${await this.getApiKey()}`,Accept:"text/event-stream","Content-Type":"application/json"},c;try{c=await fetch(r,{method:"POST",headers:n,body:JSON.stringify(t),signal:a??AbortSignal.timeout(tl),...ol?{dispatcher:ol}:{}})}catch(l){throw this.isInfrastructureError(l)&&this.onInfrastructureError?.(),l}if(!c.ok)throw await this.buildHttpError(c);if(!(c.headers.get("content-type")||"").includes("text/event-stream")){let l=await c.text();return l?JSON.parse(l):void 0}try{return await(0,Ime.consumeEventStreamResult)(c)}catch(l){throw this.isInfrastructureError(l)&&this.onInfrastructureError?.(),l}}async subscribeToLogsSSE(e={}){return this.sseManager.subscribeToLogs(e)}async disconnect(){await this.sseManager.disconnect()}async getMe(){return this.restRequest("GET","/v1/me")}async completeOnboarding(){return this.restRequest("POST","/v1/me/onboarding/complete")}async runTool(e){let t=await this.restRequest("POST",`/v1/tools/${encodeURIComponent(e.toolId)}/run`,{inputs:e.payload,files:e.files,credentials:e.credentials,includeStepResultData:e.includeStepResultData,options:e.options,runId:e.runId,stateFixture:e.stateFixture},void 0,e.signal?{signal:e.signal}:void 0);return{success:t.status==="success",data:t.data,error:t.error,tool:t.tool,stepResults:t.stepResults?.map(a=>({...a}))||[],...t.fileArtifacts&&t.fileArtifacts.length>0?{fileArtifacts:t.fileArtifacts}:{},...t.metadata?.warnings?.length?{warnings:t.metadata.warnings}:{}}}async runToolConfig(e){let t=e.createRun?"/v1/tools/run?createRun=true":"/v1/tools/run",a=await this.restRequest("POST",t,{tool:e.tool,payload:e.payload,files:e.files,credentials:e.credentials,includeStepResultData:e.includeStepResultData,options:e.options,runId:e.runId,stateFixture:e.stateFixture,executionKind:e.executionKind,parentToolId:e.parentToolId,draftId:e.draftId},e.traceId?{"X-Trace-Id":e.traceId}:void 0,e.signal?{signal:e.signal}:void 0);return{success:a.status?a.status==="success":a.success??!1,data:a.data,error:a.error,tool:a.tool||e.tool,stepResults:a.stepResults?.map(r=>({...r}))||[],...a.fileArtifacts&&a.fileArtifacts.length>0?{fileArtifacts:a.fileArtifacts}:{},...a.metadata?.warnings?.length?{warnings:a.metadata.warnings}:{}}}async abortToolExecution(e){return{success:!0,runId:(await this.restRequest("POST",`/v1/runs/${encodeURIComponent(e)}/cancel`)).runId}}async executeStep({step:e,payload:t,files:a,previousResults:i,credentials:r,options:s,runId:n,systemIds:c,createRun:m,parentToolId:l,stepIndex:u,stepId:d,signal:g,stream:p}){let b={step:e,payload:t,files:a,previousResults:i,credentials:r,options:s,runId:n,systemIds:c,createRun:m,parentToolId:l,stepIndex:u,stepId:d};return p?this.streamRequest("/v1/tools/step/run",b,g):this.restRequest("POST","/v1/tools/step/run",b,void 0,g?{signal:g}:void 0)}async abortStep(e){return this.restRequest("POST","/v1/tools/step/abort",{runId:e})}async executeTransformOnly({outputTransform:e,outputSchema:t,inputSchema:a,payload:i,files:r,stepResults:s,options:n,runId:c,createRun:m,parentToolId:l,stepId:u,signal:d,stream:g}){let p={outputTransform:e,outputSchema:t,inputSchema:a,payload:i,files:r,stepResults:s,options:n,runId:c,createRun:m,parentToolId:l,stepId:u};return g?this.streamRequest("/v1/tools/transform/run",p,d):this.restRequest("POST","/v1/tools/transform/run",p,void 0,d?{signal:d}:void 0)}async createRun({toolId:e,toolConfig:t,toolResult:a,stepResults:i,toolPayload:r,status:s,error:n,startedAt:c,completedAt:m,executionKind:l,parentToolId:u,draftId:d}){return this.restRequest("POST","/v1/runs",{toolId:e,toolConfig:t,toolResult:a,stepResults:i,toolPayload:r,status:s,error:n,startedAt:(0,$a.toUTCISOString)(c,"run.startedAt"),completedAt:(0,$a.toUTCISOString)(m,"run.completedAt"),executionKind:l,parentToolId:u,draftId:d})}async checkRunLimit(){return(await this.restRequest("POST","/v1/runs/check-limit")).data}async extract({file:e,envelope:t}){if(!e)throw new Error("File must be provided for extract.");let a=new FormData;a.append("file",e);let i=t?"/v1/extract?envelope=true":"/v1/extract";return this.restRequest("POST",i,a)}mapOpenAPIRunToRun(e){let t={running:Sn.RunStatus.RUNNING,success:Sn.RunStatus.SUCCESS,failed:Sn.RunStatus.FAILED,aborted:Sn.RunStatus.ABORTED};return{runId:e.runId??e.id,toolId:e.toolId,tool:e.tool,systemIds:e.systemIds,status:t[e.status]??Sn.RunStatus.FAILED,toolPayload:e.toolPayload,data:e.data,toolResult:e.data,error:e.error,stepResults:e.stepResults,options:e.options,requestSource:e.requestSource,traceId:e.traceId,resultStorageUri:e.resultStorageUri,userId:e.userId,userEmail:e.userEmail,userName:e.userName,metadata:{...e.metadata,executionKind:e.metadata?.executionKind??Sn.RunExecutionKind.FULL},fileArtifacts:e.fileArtifacts}}mapOpenAPIScheduleToToolSchedule(e){return{...e,lastRunAt:e.lastRunAt?(0,$a.requireUTCDate)(e.lastRunAt,"schedule.lastRunAt"):void 0,nextRunAt:(0,$a.requireUTCDate)(e.nextRunAt,"schedule.nextRunAt"),createdAt:(0,$a.requireUTCDate)(e.createdAt,"schedule.createdAt"),updatedAt:(0,$a.requireUTCDate)(e.updatedAt,"schedule.updatedAt")}}async listRuns(e={}){let t=(0,Va.createSearchListQueryParams)(e);e.toolId!==void 0&&t.set("toolId",e.toolId),e.searchUserIds?.length&&t.set("searchUserIds",e.searchUserIds.join(",")),e.includeTotal!==void 0&&t.set("includeTotal",String(e.includeTotal)),e.startedAfter!==void 0&&t.set("startedAfter",e.startedAfter instanceof Date?(0,$a.toUTCISOString)(e.startedAfter,"run.startedAfter"):e.startedAfter),e.statuses!==void 0?t.set("status",e.statuses.join(",")):e.status!==void 0&&t.set("status",e.status),e.requestSources!==void 0&&t.set("requestSources",e.requestSources.join(",")),e.executionKinds!==void 0&&t.set("executionKinds",e.executionKinds.join(",")),e.userId!==void 0&&t.set("userId",e.userId),e.systemId!==void 0&&t.set("systemId",e.systemId),e.systemIds!==void 0&&t.set("systemIds",e.systemIds.join(","));let a=t.size>0?`?${t.toString()}`:"",i=await this.restRequest("GET",`/v1/runs${a}`,void 0,void 0,{signal:e.signal});return{data:i.data.map(r=>this.mapOpenAPIRunToRun(r)),total:i.total,page:i.page,limit:i.limit,hasMore:i.hasMore}}async getActivityCounts(e){let t=new URLSearchParams;e?.from&&t.set("from",e.from instanceof Date?(0,$a.toUTCISOString)(e.from,"activity.from"):e.from),e?.to&&t.set("to",e.to instanceof Date?(0,$a.toUTCISOString)(e.to,"activity.to"):e.to);let a=t.toString();return(await this.restRequest("GET",`/v1/activity/counts${a?`?${a}`:""}`,void 0,void 0,{signal:e?.signal})).counts}async getRun(e){try{let t=await this.restRequest("GET",`/v1/runs/${encodeURIComponent(e)}`);return this.mapOpenAPIRunToRun(t)}catch(t){if(t.message?.includes("404")||t.message?.includes("not found"))return null;throw t}}async getTool(e){try{return await this.restRequest("GET",`/v1/tools/${encodeURIComponent(e)}`)}catch(t){if(t.message?.includes("404")||t.message?.includes("not found")||t.message?.includes("403")||t.message?.includes("not allowed"))return null;throw t}}async getToolState(e){return(await this.restRequest("GET",`/v1/tools/${encodeURIComponent(e)}/state`)).state}async setToolState(e,t){await this.restRequest("PUT",`/v1/tools/${encodeURIComponent(e)}/state`,{state:t})}async deleteToolState(e){return(await this.restRequest("DELETE",`/v1/tools/${encodeURIComponent(e)}/state`)).deletedKeys}async archiveTool(e,t=!0){return this.updateTool(e,{archived:t})}async bulkArchiveTools(e,t=!0){return this.restRequest("POST","/v1/tools/bulk/archive",{ids:e,archived:t})}async bulkDeleteTools(e){return this.restRequest("POST","/v1/tools/bulk/delete",{ids:e})}async listTools(e={}){let t=(0,Va.createListQueryParams)(e);e.includeArchived!==void 0&&t.set("includeArchived",String(e.includeArchived));let a=t.size>0?`?${t.toString()}`:"";return this.restRequest("GET",`/v1/tools${a}`)}async listAllTools(e={}){return(0,Va.listAllPages)((t,a)=>this.listTools({...e,page:t,limit:a}))}async createTool(e,t){return this.restRequest("POST","/v1/tools",{...t,id:e})}async updateTool(e,t){return this.restRequest("PUT",`/v1/tools/${encodeURIComponent(e)}`,t)}async deleteTool(e){try{return await this.restRequest("DELETE",`/v1/tools/${encodeURIComponent(e)}`),!0}catch(t){if(t.message?.includes("404"))return!1;throw t}}async renameTool(e,t){return this.restRequest("POST",`/v1/tools/${encodeURIComponent(e)}/rename`,{newId:t})}async getWorkflow(e){return this.getTool(e)}async archiveWorkflow(e,t=!0){return this.upsertWorkflow(e,{archived:t})}async createWorkflow(e,t){return this.createTool(e,t)}async updateWorkflow(e,t){return this.updateTool(e,t)}async upsertWorkflow(e,t){return await this.getTool(e)?this.updateTool(e,t):this.createTool(e,t)}async deleteWorkflow(e){return this.deleteTool(e)}async renameWorkflow(e,t){return this.renameTool(e,t)}async listSchedules(e={}){let t=(0,Va.createListQueryParams)(e),a=t.size>0?`?${t.toString()}`:"",i=e.toolId?`/v1/tools/${encodeURIComponent(e.toolId)}/schedules${a}`:`/v1/schedules${a}`,r=await this.restRequest("GET",i);return{...r,data:r.data.map(s=>this.mapOpenAPIScheduleToToolSchedule(s))}}async listAllSchedules(e={}){return(0,Va.listAllPages)((t,a)=>this.listSchedules({...e,page:t,limit:a}))}async getToolSchedule(e,t){try{let a=await this.restRequest("GET",`/v1/tools/${encodeURIComponent(e)}/schedules/${encodeURIComponent(t)}`);return this.mapOpenAPIScheduleToToolSchedule(a)}catch(a){if(a.message?.includes("404")||a.message?.includes("not found"))return null;throw a}}async createToolSchedule(e,t){let a=await this.restRequest("POST",`/v1/tools/${encodeURIComponent(e)}/schedules`,{...t,timezone:t.timezone||(0,jme.getRuntimeTimezone)()});return this.mapOpenAPIScheduleToToolSchedule(a)}async updateToolSchedule(e,t,a){let i=await this.restRequest("PUT",`/v1/tools/${encodeURIComponent(e)}/schedules/${encodeURIComponent(t)}`,a);return this.mapOpenAPIScheduleToToolSchedule(i)}async deleteToolSchedule(e,t){return await this.restRequest("DELETE",`/v1/tools/${encodeURIComponent(e)}/schedules/${encodeURIComponent(t)}`),!0}async bulkSetSchedulesEnabled(e,t){return this.restRequest("POST","/v1/schedules/bulk/enable",{ids:e,enabled:t})}async bulkDeleteSchedules(e){return this.restRequest("POST","/v1/schedules/bulk/delete",{ids:e})}async listCredentials(e={}){let t=(0,Va.createListQueryParams)(e);e.systemId!==void 0&&t.set("systemId",e.systemId);let a=t.size>0?`?${t.toString()}`:"";return this.restRequest("GET",`/v1/credentials${a}`)}async listAllCredentials(e={}){return(0,Va.listAllPages)((t,a)=>this.listCredentials({...e,page:t,limit:a}))}async createCredentials(e){return(await this.restRequest("POST","/v1/credentials",e)).data}async replaceCredentials(e,t){return(await this.restRequest("PUT",`/v1/credentials/${encodeURIComponent(e)}`,{credentials:t})).data}async updateCredentials(e,t){return(await this.restRequest("PATCH",`/v1/credentials/${encodeURIComponent(e)}`,t)).data}async deleteCredentials(e){await this.restRequest("DELETE",`/v1/credentials/${encodeURIComponent(e)}`)}async setDefaultCredentials(e){await this.restRequest("POST",`/v1/credentials/${encodeURIComponent(e)}/default`)}async listSystems(e={}){let t=(0,Va.createListQueryParams)(e),a=t.size>0?`?${t.toString()}`:"";return this.restRequest("GET",`/v1/systems${a}`)}async listAllSystems(e={}){return(0,Va.listAllPages)((t,a)=>this.listSystems({...e,page:t,limit:a}))}async getSystem(e){return(await this.restRequest("GET",`/v1/systems/${encodeURIComponent(e)}`)).data}async createSystem(e){return(await this.restRequest("POST","/v1/systems",e)).data}async updateSystem(e,t){return(await this.restRequest("PATCH",`/v1/systems/${encodeURIComponent(e)}`,t)).data}async deleteSystem(e){return await this.restRequest("DELETE",`/v1/systems/${encodeURIComponent(e)}`),!0}async bulkDeleteSystems(e){return this.restRequest("POST","/v1/systems/bulk/delete",{ids:e})}async createOAuthExchange(e){return(await this.restRequest("POST","/v1/oauth/exchanges",e)).data}async completeOAuthExchange(e,t){return(await this.restRequest("POST",`/v1/oauth/exchanges/${encodeURIComponent(e)}/complete`,t)).data}async searchSystemDocumentation(e,t){return(await this.restRequest("POST",`/v1/systems/${encodeURIComponent(e)}/documentation/search`,{keywords:t})).data}async triggerSystemDocumentationScrapeJob(e,t){return(await this.restRequest("POST",`/v1/systems/${encodeURIComponent(e)}/documentation/scrape`,t)).data}async fetchOpenApiSpec(e,t,a){return(await this.restRequest("POST",`/v1/systems/${encodeURIComponent(e)}/documentation/openapi`,{url:t,link:a?.link})).data}async uploadSystemDocumentationFiles(e,t,a){let i=await this.uploadFiles(t,{process:!0}),r=i.flatMap(s=>s.status==="uploaded"?[s.id]:[]);if(r.length>0)try{await this.restRequest("POST",`/v1/systems/${encodeURIComponent(e)}/documentation/files`,{fileIds:r,link:a?.link!==!1})}catch(s){throw await Promise.all(r.map(n=>this.deleteFileUpload(n).catch(()=>{}))),s}if(!a?.settle){let s=i.filter(n=>n.status==="failed");if(s.length>0)throw new Error(s.map(n=>n.error).join("; "))}return i}async listSystemDocumentationFiles(e,t){let a=new URLSearchParams;t?.length&&a.set("fileIds",t.join(","));let i=a.size>0?`?${a.toString()}`:"";return(await this.restRequest("GET",`/v1/systems/${encodeURIComponent(e)}/documentation/files${i}`)).data}async getSystemDocumentationFileContent(e,t,a){return(await this.restRequest("GET",`/v1/systems/${encodeURIComponent(e)}/documentation/files/${encodeURIComponent(t)}/content?processed=${a.processed}`)).data}async deleteSystemDocumentationFile(e,t){await this.restRequest("DELETE",`/v1/systems/${encodeURIComponent(e)}/documentation/files/${encodeURIComponent(t)}`)}async generateCredentialsLink(e){try{return{success:!0,credentialsUrl:(await this.restRequest("POST","/v1/authenticate",e||{})).data.credentialsUrl}}catch(t){return{success:!1,error:t.message}}}};Dn.SuperglueClient=nv});var Z5=y(Ce=>{"use strict";Object.defineProperty(Ce,"__esModule",{value:!0});Ce.UnquotedKeyStrategy=Ce.TripleQuoteStrategy=Ce.TrailingCommaStrategy=Ce.SingleQuoteStrategy=Ce.PythonLiteralStrategy=Ce.CommentStrategy=Ce.ResilientJsonParser=Ce.RepairStrategy=void 0;Ce.parseJsonResilient=Bme;Ce.parseJSON=Qme;Ce.isValidJson=Sme;Ce.prettyPrintJson=Dme;Ce.minifyJson=Tme;var Ht=class{validate(e){try{return JSON.parse(e),!0}catch{return!1}}};Ce.RepairStrategy=Ht;var Wg=class extends Ht{constructor(){super(...arguments),this.name="TripleQuoteRepair",this.description="Converts triple-quoted strings to proper JSON, parsing nested JSON content"}canApply(e){return/"""/.test(e)}apply(e){return e.replace(/"""([\s\S]*?)"""/g,(t,a)=>{let i=a.trim();if(i.startsWith("{")&&i.endsWith("}")||i.startsWith("[")&&i.endsWith("]"))try{let s=JSON.parse(i);return JSON.stringify(s)}catch{return`"${a.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t")}"`}return`"${a.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t")}"`})}};Ce.TripleQuoteStrategy=Wg;var Jg=class extends Ht{constructor(){super(...arguments),this.name="PythonLiteralRepair",this.description="Converts Python literals to JavaScript equivalents"}canApply(e){return/\b(None|True|False)\b/.test(e)}apply(e){return e.replace(/\bNone\b/g,"null").replace(/\bTrue\b/g,"true").replace(/\bFalse\b/g,"false")}};Ce.PythonLiteralStrategy=Jg;var Kg=class extends Ht{constructor(){super(...arguments),this.name="TrailingCommaRepair",this.description="Removes trailing commas from objects and arrays"}canApply(e){return/,\s*[}\]]/.test(e)}apply(e){return e.replace(/,(\s*[}\]])/g,"$1")}};Ce.TrailingCommaStrategy=Kg;var Zg=class extends Ht{constructor(){super(...arguments),this.name="SingleQuoteRepair",this.description="Converts single quotes to double quotes"}canApply(e){return/[{,]\s*'[^']*'\s*:/.test(e)||/:\s*'[^']*'/.test(e)}apply(e){let t=e.replace(/([{,]\s*)'([^']+)'(\s*:)/g,'$1"$2"$3');return t=t.replace(/(:\s*)'([^']+)'(\s*[,}])/g,'$1"$2"$3'),t}};Ce.SingleQuoteStrategy=Zg;var Xg=class extends Ht{constructor(){super(...arguments),this.name="UnquotedKeyRepair",this.description="Adds quotes to unquoted object keys"}canApply(e){return/[{,]\s*[a-zA-Z_$][a-zA-Z0-9_$]*\s*:/.test(e)}apply(e){return e.replace(/([{,]\s*)([a-zA-Z_$][a-zA-Z0-9_$]*)(\s*:)/g,'$1"$2"$3')}};Ce.UnquotedKeyStrategy=Xg;var ep=class extends Ht{constructor(){super(...arguments),this.name="CommentRemoval",this.description="Removes JavaScript-style comments"}canApply(e){return/\/\/.*$|\/\*[\s\S]*?\*\//m.test(e)}apply(e){let t=e.replace(/\/\/.*$/gm,"");return t=t.replace(/\/\*[\s\S]*?\*\//g,""),t}};Ce.CommentStrategy=ep;var cv=class extends Ht{constructor(){super(...arguments),this.name="UnescapedControlCharactersRepair",this.description="Escapes unescaped control characters (newlines, tabs, etc.) in JSON strings"}canApply(e){try{return JSON.parse(e),!1}catch(t){let a=t.message||"";return a.includes("control character")||a.includes("Bad control")||a.includes("Unexpected token")&&/[\n\r\t]/.test(e)}}apply(e){let t="",a=!1,i=!1;for(let r=0;r<e.length;r++){let s=e[r],n=r>0?e[r-1]:"";if(i){t+=s,i=!1;continue}if(s==="\\"&&a){t+=s,i=!0;continue}if(s==='"'&&n!=="\\"){a=!a,t+=s;continue}if(a)switch(s){case`
1413
1419
  `:t+="\\n";break;case"\r":t+="\\r";break;case" ":t+="\\t";break;case"\b":t+="\\b";break;case"\f":t+="\\f";break;default:let c=s.charCodeAt(0);c<32?t+="\\u"+("0000"+c.toString(16)).slice(-4):t+=s}else t+=s}return t}},mv=class extends Ht{constructor(){super(...arguments),this.name="TrailingCharactersRepair",this.description="Removes trailing characters after valid JSON structure"}canApply(e){let t=e.trim();if(!t.startsWith("{")&&!t.startsWith("["))return!1;let a=0,i=0,r=!1,s=!1;for(let n=0;n<t.length;n++){let c=t[n];if(r)s?s=!1:c==="\\"?s=!0:c==='"'&&(r=!1);else if(c==='"')r=!0;else if(c==="{")a++;else if(c==="}"){if(a--,a===0&&i===0&&n>0&&n<t.length-1)return!0}else if(c==="[")i++;else if(c==="]"&&(i--,i===0&&a===0&&n>0&&n<t.length-1))return!0}return!1}apply(e){let t=e.trim(),a=0,i=0,r=!1,s=!1,n=-1;for(let c=0;c<t.length;c++){let m=t[c];if(r)s?s=!1:m==="\\"?s=!0:m==='"'&&(r=!1);else if(m==='"')r=!0;else if(m==="{")a++;else if(m==="}"){if(a--,a===0&&i===0&&c>0){n=c;break}}else if(m==="[")i++;else if(m==="]"&&(i--,i===0&&a===0&&c>0)){n=c;break}}return n>0&&n<t.length-1?t.substring(0,n+1):e}},Tn=class{constructor(e={}){this.strategies=[],this.repairLog=[],this.options={attemptRepair:!0,maxDepth:10,preserveStringsOnFailure:!1,logRepairs:!1,...e},this.initializeDefaultStrategies(),e.customStrategies&&this.strategies.push(...e.customStrategies)}initializeDefaultStrategies(){this.strategies=[new Wg,new Zg,new cv,new mv,new Jg,new Kg,new Xg,new ep]}parse(e){let t=Date.now();this.repairLog=[];let a=e instanceof Buffer?e.toString("utf8"):String(e);try{return{success:!0,data:JSON.parse(a),metadata:{parseTime:Date.now()-t,strategiesApplied:[]}}}catch(s){if(!this.options.attemptRepair)return{success:!1,error:`JSON parse error: ${s}`,metadata:{parseTime:Date.now()-t}}}let i=a,r=[];for(let s of this.strategies)if(s.canApply(i)){let n=i;if(i=s.apply(i),n!==i){r.push(s.name),this.repairLog.push(s.description),this.options.logRepairs&&console.log(`Applied ${s.name}: ${s.description}`);try{return{success:!0,data:JSON.parse(i),repairs:this.repairLog,metadata:{parseTime:Date.now()-t,strategiesApplied:r}}}catch{}}}try{return{success:!0,data:JSON.parse(i),repairs:this.repairLog,metadata:{parseTime:Date.now()-t,strategiesApplied:r}}}catch(s){let n=this.aggressiveFallback(i);return n.success?{...n,repairs:[...this.repairLog,"Applied aggressive fallback"],metadata:{parseTime:Date.now()-t,strategiesApplied:[...r,"AggressiveFallback"]}}:{success:!1,error:`Failed to parse JSON after applying ${r.length} strategies: ${s}`,repairs:this.repairLog,metadata:{parseTime:Date.now()-t,strategiesApplied:r}}}}aggressiveFallback(e){try{let t=e.indexOf("{"),a=e.indexOf("[");if(t===-1&&a===-1)return{success:!1,error:"No JSON-like structure found"};let i=t===-1?a:a===-1?t:Math.min(t,a),r=e.substring(i);for(let n of this.strategies)n.canApply(r)&&(r=n.apply(r));return{success:!0,data:JSON.parse(r)}}catch(t){return{success:!1,error:`Aggressive fallback failed: ${t}`}}}addStrategy(e){this.strategies.push(e)}removeStrategy(e){this.strategies=this.strategies.filter(t=>t.name!==e)}getStrategies(){return this.strategies.map(e=>e.name)}};Ce.ResilientJsonParser=Tn;var K5=new Tn;function Bme(o,e){return(e?new Tn(e):K5).parse(o)}function Qme(o){let e=K5.parse(o);if(e.success)return e.repairs&&e.repairs.length>0&&console.log("JSON parsed with repairs:",e.repairs),e.data;throw new Error(`Failed to parse JSON: ${e.error}`)}function Sme(o){try{return JSON.parse(o),!0}catch{return!1}}function Dme(o,e=2){return JSON.stringify(o,null,e)}function Tme(o){let t=new Tn().parse(o);if(t.success)return JSON.stringify(t.data);throw new Error("Cannot minify invalid JSON")}});var tt=y(F=>{"use strict";var Rme=F&&F.__createBinding||(Object.create?(function(o,e,t,a){a===void 0&&(a=t);var i=Object.getOwnPropertyDescriptor(e,t);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[t]}}),Object.defineProperty(o,a,i)}):(function(o,e,t,a){a===void 0&&(a=t),o[a]=e[t]})),Z=F&&F.__exportStar||function(o,e){for(var t in o)t!=="default"&&!Object.prototype.hasOwnProperty.call(e,t)&&Rme(e,o,t)};Object.defineProperty(F,"__esModule",{value:!0});F.SSELogSubscriptionManager=F.SuperglueHttpError=F.SuperglueClient=void 0;Z(r1(),F);Z(h1(),F);Z(f1(),F);Z(w1(),F);Z(q1(),F);Z(Mc(),F);Z(H1(),F);Z(G1(),F);Z(Y1(),F);Z(V1(),F);Z(Jf(),F);Z(W1(),F);Z(J1(),F);Z(K1(),F);Z(X1(),F);Z(e2(),F);Z(t2(),F);Z(Al(),F);Z(i2(),F);Z(r2(),F);Z(n2(),F);Z(l2(),F);Z(d2(),F);Z(y2(),F);Z(A2(),F);Z(v2(),F);Z(D2(),F);Z(R2(),F);Z(lb(),F);Z(W2(),F);Z(yb(),F);Z(X2(),F);Z(aI(),F);Z(rI(),F);Z(rt(),F);Z(Kt(),F);Z(sI(),F);Z(nI(),F);Z(Ru(),F);Z(Cs(),F);Z(wu(),F);var X5=J5();Object.defineProperty(F,"SuperglueClient",{enumerable:!0,get:function(){return X5.SuperglueClient}});Object.defineProperty(F,"SuperglueHttpError",{enumerable:!0,get:function(){return X5.SuperglueHttpError}});var Nme=wb();Object.defineProperty(F,"SSELogSubscriptionManager",{enumerable:!0,get:function(){return Nme.SSELogSubscriptionManager}});Z(Z5(),F)});var Tp=require("commander");var Ro=W(require("fs")),t6=W(require("os")),Wa=W(require("path")),al=W(tt()),e6=new Set(["runner","builder","admin"]),o6={output:{mode:"stdout",directory:".superglue/output"},preset:"admin"};function Ja(o){let e=Wa.join(process.cwd(),".superglue"),t=t6.homedir();if(!t)return e;let a=Wa.join(t,".superglue");return o===!0?e:o===!1?a:Ro.existsSync(Wa.join(e,"config.json"))?e:a}function lv(o){return Wa.join(Ja(o),"config.json")}function op(o){let e=lv(o);if(!Ro.existsSync(e))return{};try{return JSON.parse(Ro.readFileSync(e,"utf-8"))}catch{return{}}}function Rn(o){let e=op(),t=o.apiKey||(0,al.readProcessEnvironmentValue)("SUPERGLUE_API_KEY")||e.apiKey||"",a=o.endpoint||(0,al.readProcessEnvironmentValue)("SUPERGLUE_API_ENDPOINT")||e.endpoint||"https://api.superglue.cloud",i=(0,al.readProcessEnvironmentValue)("SUPERGLUE_WEB_ENDPOINT")||e.webEndpoint||a.replace(/:3002\b/,":3001").replace(/api\.superglue/,"app.superglue"),r=(0,al.readProcessEnvironmentValue)("SUPERGLUE_CLI_PRESET"),s=r&&e6.has(r)?r:e.preset&&e6.has(e.preset)?e.preset:"admin";return{...o6,...e,apiKey:t,endpoint:a,webEndpoint:i,preset:s,output:{...o6.output,...e.output}}}function tp(o,e){let t=Ja(e);Ro.existsSync(t)||Ro.mkdirSync(t,{recursive:!0}),Ro.writeFileSync(Wa.join(t,"config.json"),JSON.stringify(o,null,2)+`
1414
- `,{mode:384})}function ap(o,e){let t=Wa.join(Ja(e),"drafts");if(Ro.existsSync(t)||Ro.mkdirSync(t,{recursive:!0}),o.output.mode==="stdout+file"){let a=Wa.resolve(o.output.directory);Ro.existsSync(a)||Ro.mkdirSync(a,{recursive:!0})}}var bv=W(tt());var uv=W(require("readline"));var r6=require("child_process"),s6=require("util");var a6={name:"@superglue/cli",version:"1.1.77",bin:{sg:"./dist/cli.js"},files:[".claude-plugin/","dist/","skills/","LICENSE"],dependencies:{commander:"15.0.0-0","fast-json-patch":"3.1.1"},devDependencies:{"@superglue/shared":"file:../shared","@types/node":"25.5.0",tsup:"8.5.1",typescript:"5.8.3"},scripts:{build:"tsup && (cp -r skills dist/ 2>/dev/null || true)",dev:"tsup --watch","type-check":"tsc --noEmit",prepublishOnly:"npm run build"},publishConfig:{access:"public"}};var Ome=(0,s6.promisify)(r6.exec),xo=a6.version;function i6(o){let e=o.match(/^(\d+)(?:-(.+))?$/);return e?{numeric:parseInt(e[1],10),prerelease:e[2]||null}:{numeric:0,prerelease:o}}function rp(o,e){let t=o.split("."),a=e.split("."),i=Math.max(t.length,a.length);for(let r=0;r<i;r++){let s=i6(t[r]||"0"),n=i6(a[r]||"0");if(s.numeric<n.numeric)return-1;if(s.numeric>n.numeric||s.prerelease===null&&n.prerelease!==null)return 1;if(s.prerelease!==null&&n.prerelease===null)return-1;if(s.prerelease!==null&&n.prerelease!==null){if(s.prerelease<n.prerelease)return-1;if(s.prerelease>n.prerelease)return 1}}return 0}async function sp(){try{let o=await fetch("https://registry.npmjs.org/@superglue/cli/latest",{signal:AbortSignal.timeout(5e3)});return o.ok&&(await o.json()).version||null}catch{return null}}var ip=null;function n6(){G()&&(ip=sp())}async function c6(){if(!(!G()||!ip)){try{let o=new Promise(t=>{setTimeout(()=>t(null),2e3).unref()}),e=await Promise.race([ip,o]);e&&rp(xo,e)<0&&(console.error(""),console.error(`${h.cyan}${h.bold} Update available: ${xo} \u2192 ${e}${h.reset}`),console.error(`${h.cyan} Run ${h.bold}sg update${h.reset}${h.cyan} to upgrade${h.reset}`),console.error(""))}catch{}ip=null}}async function m6(){let o=await sp();if(!o)return{success:!1,message:"Could not fetch latest version from npm"};if(rp(xo,o)>=0)return{success:!0,message:`Already on latest version (${xo})`};try{return await Ome("npm install -g @superglue/cli@latest"),{success:!0,message:`Updated from ${xo} to ${o}`}}catch(e){return{success:!1,message:`Update failed: ${e.message}. Try manually: npm install -g @superglue/cli@latest`}}}var G=()=>process.argv.includes("--table")&&process.stdout.isTTY,Et=()=>process.argv.includes("--full"),h={reset:"\x1B[0m",bold:"\x1B[1m",dim:"\x1B[2m",italic:"\x1B[3m",underline:"\x1B[4m",red:"\x1B[31m",green:"\x1B[32m",yellow:"\x1B[33m",blue:"\x1B[34m",magenta:"\x1B[35m",cyan:"\x1B[36m",white:"\x1B[37m",gray:"\x1B[90m",bgRed:"\x1B[41m",bgGreen:"\x1B[42m",bgYellow:"\x1B[43m",bgBlue:"\x1B[44m",bgMagenta:"\x1B[45m",bgCyan:"\x1B[46m"};function l6(o,e){let t=e||o;return`\x1B]8;;${o}\x07${h.underline}${h.cyan}${t}${h.reset}\x1B]8;;\x07`}function u6(){if(!G())return;let o=h.reset,e=h.dim,t="\x1B[47;30m",a=[" #@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@- "," =@@@- @@@@ "," @@@ @@% "," -@@ @@@@= @@@ @@@ @@@@@#@ @@@@@@@ @@@@@@@ @@@@@@ @@@ @@@ @@@ @@@@@@* %@@ "," @@ @@@ *@ @@@ @@@ @@@ :@@ @@@ @@@ -@@ @@@ @% @@@ @@@ @@@ @@* @@# "," #@@ @@@# @@@ @@@ @@@ :@@ @@@ @@@ -@@ @@@ @@@ @@@ @@@ @@* @@ "," @@- @@@@= @@@ @@@ @@@@@@@ @@@@@@ @@@@@@@ @@@ @@% @@@ @@@ @@@ @@@@@. @@."," #@% .@@@@ @@@ @@@ @@@ @@@ @@@ -@@ @@@ @@% @@@ @@@ @@@ @@* @@ "," @@ @ @@@ @@@ @@@ @@@ @@@ @@@ -@@ @@@ @@% @@@ @@@ @@@ @@* *@@ "," -@@ @@@@= @@@@@@ @@@ @@@@@@@ @@@ -@@ @@@@@@ @@@@@@% @@@@@@. @@@@@@* #@@ "," :@@* @@@ "," %@@@ =@@@. "," :@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@% "];console.log(""),a.forEach(i=>{let r=i.search(/\S/),s=i.length-[...i].reverse().join("").search(/\S/)-1;if(r===-1)return console.log(" "+i);let n=i.slice(0,r),c=i.slice(r,s+1).split("").map(l=>l===" "?" ":"\u2588").join(""),m=i.slice(s+1);console.log(` ${n}${t}${c}${o}${m}`)}),console.log(` ${e} CLI v${xo}${o}`),console.log("")}function Ee(o){if(!G())return{stop:()=>{},update:()=>{},log:()=>{}};let e=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"],t=0,a=o,i=()=>process.stdout.write("\r\x1B[2K"),r=()=>{process.stdout.write(`\r ${h.cyan}${e[t++%e.length]}${h.reset} ${a}`)},s=setInterval(r,80);return{update:n=>{a=n},log:n=>{i(),console.log(` ${h.dim}\u2502${h.reset} ${n}`),r()},stop:n=>{clearInterval(s),i(),n&&console.log(` ${n}`)}}}function U(o){G()?np(o):console.log(JSON.stringify(o,null,2))}function re(o,e){G()?(console.log(` ${h.green}\u2713${h.reset} ${o}`),e&&np(e,4)):console.log(JSON.stringify({success:!0,message:o,...e&&typeof e=="object"?e:{data:e}}))}function z(o,e){G()?(console.error(` ${h.red}\u2717${h.reset} ${o}`),e&&np(e,4)):console.error(JSON.stringify({success:!1,error:o,details:e}))}function d6(o){G()&&console.log(` ${h.yellow}\u26A0${h.reset} ${o}`)}function go(o){G()&&console.log(` ${h.dim}${o}${h.reset}`)}function Ka(o){G()&&(console.log(`
1420
+ `,{mode:384})}function ap(o,e){let t=Wa.join(Ja(e),"drafts");if(Ro.existsSync(t)||Ro.mkdirSync(t,{recursive:!0}),o.output.mode==="stdout+file"){let a=Wa.resolve(o.output.directory);Ro.existsSync(a)||Ro.mkdirSync(a,{recursive:!0})}}var bv=W(tt());var uv=W(require("readline"));var r6=require("child_process"),s6=require("util");var a6={name:"@superglue/cli",version:"1.1.78",bin:{sg:"./dist/cli.js"},files:[".claude-plugin/","dist/","skills/","LICENSE"],dependencies:{commander:"15.0.0-0","fast-json-patch":"3.1.1"},devDependencies:{"@superglue/shared":"file:../shared","@types/node":"25.5.0",tsup:"8.5.1",typescript:"5.8.3"},scripts:{build:"tsup && (cp -r skills dist/ 2>/dev/null || true)",dev:"tsup --watch","type-check":"tsc --noEmit",prepublishOnly:"npm run build"},publishConfig:{access:"public"}};var Ome=(0,s6.promisify)(r6.exec),xo=a6.version;function i6(o){let e=o.match(/^(\d+)(?:-(.+))?$/);return e?{numeric:parseInt(e[1],10),prerelease:e[2]||null}:{numeric:0,prerelease:o}}function rp(o,e){let t=o.split("."),a=e.split("."),i=Math.max(t.length,a.length);for(let r=0;r<i;r++){let s=i6(t[r]||"0"),n=i6(a[r]||"0");if(s.numeric<n.numeric)return-1;if(s.numeric>n.numeric||s.prerelease===null&&n.prerelease!==null)return 1;if(s.prerelease!==null&&n.prerelease===null)return-1;if(s.prerelease!==null&&n.prerelease!==null){if(s.prerelease<n.prerelease)return-1;if(s.prerelease>n.prerelease)return 1}}return 0}async function sp(){try{let o=await fetch("https://registry.npmjs.org/@superglue/cli/latest",{signal:AbortSignal.timeout(5e3)});return o.ok&&(await o.json()).version||null}catch{return null}}var ip=null;function n6(){G()&&(ip=sp())}async function c6(){if(!(!G()||!ip)){try{let o=new Promise(t=>{setTimeout(()=>t(null),2e3).unref()}),e=await Promise.race([ip,o]);e&&rp(xo,e)<0&&(console.error(""),console.error(`${h.cyan}${h.bold} Update available: ${xo} \u2192 ${e}${h.reset}`),console.error(`${h.cyan} Run ${h.bold}sg update${h.reset}${h.cyan} to upgrade${h.reset}`),console.error(""))}catch{}ip=null}}async function m6(){let o=await sp();if(!o)return{success:!1,message:"Could not fetch latest version from npm"};if(rp(xo,o)>=0)return{success:!0,message:`Already on latest version (${xo})`};try{return await Ome("npm install -g @superglue/cli@latest"),{success:!0,message:`Updated from ${xo} to ${o}`}}catch(e){return{success:!1,message:`Update failed: ${e.message}. Try manually: npm install -g @superglue/cli@latest`}}}var G=()=>process.argv.includes("--table")&&process.stdout.isTTY,Et=()=>process.argv.includes("--full"),h={reset:"\x1B[0m",bold:"\x1B[1m",dim:"\x1B[2m",italic:"\x1B[3m",underline:"\x1B[4m",red:"\x1B[31m",green:"\x1B[32m",yellow:"\x1B[33m",blue:"\x1B[34m",magenta:"\x1B[35m",cyan:"\x1B[36m",white:"\x1B[37m",gray:"\x1B[90m",bgRed:"\x1B[41m",bgGreen:"\x1B[42m",bgYellow:"\x1B[43m",bgBlue:"\x1B[44m",bgMagenta:"\x1B[45m",bgCyan:"\x1B[46m"};function l6(o,e){let t=e||o;return`\x1B]8;;${o}\x07${h.underline}${h.cyan}${t}${h.reset}\x1B]8;;\x07`}function u6(){if(!G())return;let o=h.reset,e=h.dim,t="\x1B[47;30m",a=[" #@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@- "," =@@@- @@@@ "," @@@ @@% "," -@@ @@@@= @@@ @@@ @@@@@#@ @@@@@@@ @@@@@@@ @@@@@@ @@@ @@@ @@@ @@@@@@* %@@ "," @@ @@@ *@ @@@ @@@ @@@ :@@ @@@ @@@ -@@ @@@ @% @@@ @@@ @@@ @@* @@# "," #@@ @@@# @@@ @@@ @@@ :@@ @@@ @@@ -@@ @@@ @@@ @@@ @@@ @@* @@ "," @@- @@@@= @@@ @@@ @@@@@@@ @@@@@@ @@@@@@@ @@@ @@% @@@ @@@ @@@ @@@@@. @@."," #@% .@@@@ @@@ @@@ @@@ @@@ @@@ -@@ @@@ @@% @@@ @@@ @@@ @@* @@ "," @@ @ @@@ @@@ @@@ @@@ @@@ @@@ -@@ @@@ @@% @@@ @@@ @@@ @@* *@@ "," -@@ @@@@= @@@@@@ @@@ @@@@@@@ @@@ -@@ @@@@@@ @@@@@@% @@@@@@. @@@@@@* #@@ "," :@@* @@@ "," %@@@ =@@@. "," :@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@% "];console.log(""),a.forEach(i=>{let r=i.search(/\S/),s=i.length-[...i].reverse().join("").search(/\S/)-1;if(r===-1)return console.log(" "+i);let n=i.slice(0,r),c=i.slice(r,s+1).split("").map(l=>l===" "?" ":"\u2588").join(""),m=i.slice(s+1);console.log(` ${n}${t}${c}${o}${m}`)}),console.log(` ${e} CLI v${xo}${o}`),console.log("")}function Ee(o){if(!G())return{stop:()=>{},update:()=>{},log:()=>{}};let e=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"],t=0,a=o,i=()=>process.stdout.write("\r\x1B[2K"),r=()=>{process.stdout.write(`\r ${h.cyan}${e[t++%e.length]}${h.reset} ${a}`)},s=setInterval(r,80);return{update:n=>{a=n},log:n=>{i(),console.log(` ${h.dim}\u2502${h.reset} ${n}`),r()},stop:n=>{clearInterval(s),i(),n&&console.log(` ${n}`)}}}function U(o){G()?np(o):console.log(JSON.stringify(o,null,2))}function re(o,e){G()?(console.log(` ${h.green}\u2713${h.reset} ${o}`),e&&np(e,4)):console.log(JSON.stringify({success:!0,message:o,...e&&typeof e=="object"?e:{data:e}}))}function z(o,e){G()?(console.error(` ${h.red}\u2717${h.reset} ${o}`),e&&np(e,4)):console.error(JSON.stringify({success:!1,error:o,details:e}))}function d6(o){G()&&console.log(` ${h.yellow}\u26A0${h.reset} ${o}`)}function go(o){G()&&console.log(` ${h.dim}${o}${h.reset}`)}function Ka(o){G()&&(console.log(`
1415
1421
  ${h.bold}${h.cyan}${o}${h.reset}`),console.log(` ${h.dim}${"\u2500".repeat(o.length)}${h.reset}`))}function pa(o,e,t){if(!G()){console.log(JSON.stringify({success:!0,total:t?.total??o.length,items:o}));return}if(o.length===0){console.log(`
1416
1422
  ${h.dim}0 results${h.reset}
1417
1423
  `);return}let a=e||Object.keys(o[0]),i=Et()?1/0:60,r=a.map(l=>Math.min(i,Math.max(l.length,...o.map(u=>String(u[l]??"").replace(/[\n\r]+/g," ").trim().length))));console.log("");let s=a.map((l,u)=>`${h.bold}${h.cyan}${l.toUpperCase().padEnd(r[u])}${h.reset}`).join(" ");console.log(` ${s}`);let n=r.map(l=>`${h.dim}${"\u2500".repeat(l)}${h.reset}`).join(`${h.dim}\u2500\u2500${h.reset}`);console.log(` ${n}`);for(let l of o){let u=a.map((d,g)=>{let p=String(l[d]??"").replace(/[\n\r]+/g," ").trim();if(p.length>i){let A=`\u2026 (${p.length})`;p=p.slice(0,Math.max(0,i-A.length))+`${h.dim}${A}${h.reset}`}return d==="status"?`${{success:h.green,running:h.yellow,failed:h.red,aborted:h.red,error:h.red,pending:h.dim}[p.toLowerCase()]||""}${p.padEnd(r[g])}${h.reset}`:p.padEnd(r[g])}).join(" ");console.log(` ${u}`)}let c=t?.total??o.length,m=c===o.length?`${o.length} result${o.length===1?"":"s"}`:`${o.length} of ${c} result${c===1?"":"s"}`;console.log(`