@superglue/cli 1.1.79 → 1.1.80
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/.claude-plugin/plugin.json +1 -1
- package/dist/cli.js +5 -5
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -421,7 +421,7 @@ REQUIRED GCP PERMISSIONS:
|
|
|
421
421
|
- BigQuery Data Editor (roles/bigquery.dataEditor) - write access
|
|
422
422
|
- BigQuery Job User (roles/bigquery.jobUser) - run queries
|
|
423
423
|
|
|
424
|
-
HEADERS: { "Authorization": "Bearer <<token>>", "Content-Type": "application/json" }`,keywords:["datasets","tables","queries","jobs","projects","schemas","rows","streaming","partitions","clustering","views","routines","models","data warehouse","sql","oauth"]},firebase:{name:"firebase",apiUrl:"https://firestore.googleapis.com",regex:"^.*(firebase|firestore).*$",icon:"firebase",docsUrl:"https://firebase.google.com/docs/reference/firebase-management/rest",openApiUrl:"https://firestore.googleapis.com/$discovery/rest?version=v1",preferredAuthType:"oauth2",oauth:{authUrl:"https://accounts.google.com/o/oauth2/v2/auth",tokenUrl:"https://oauth2.googleapis.com/token",scopes:"https://www.googleapis.com/auth/firebase https://www.googleapis.com/auth/cloud-platform"},keywords:["firestore","realtime database","authentication","cloud functions","storage","hosting","documents","collections","users","projects","apps","query","oauth"]},salesforce:{name:"salesforce",apiUrl:"https://api.salesforce.com",regex:"^.*salesforce.*$",icon:"salesforce",docsUrl:"https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/intro_rest.htm",preferredAuthType:"oauth2",oauth:{authUrl:"https://login.salesforce.com/services/oauth2/authorize",tokenUrl:"https://login.salesforce.com/services/oauth2/token",scopes:"full",grant_type:"authorization_code",client_id:"3MVG9rZjd7MXFdLj8gMo0sojKlWRAgOP9F7nsk3Tec.eesq86nNTvbzDJDcmCW9YRCbteTayd_dP4OCLtISIo"},keywords:["accounts","contacts","leads","opportunities","cases","campaigns","products","price books","quotes","contracts","orders","custom objects","soql","query","search","sobjects","oauth"]},facebook:{name:"facebook",apiUrl:"https://graph.facebook.com",regex:"^.*facebook.*$",icon:"facebook",docsUrl:"https://developers.facebook.com/docs/graph-api",preferredAuthType:"oauth2",oauth:{authUrl:"https://www.facebook.com/v18.0/dialog/oauth",tokenUrl:"https://graph.facebook.com/v18.0/oauth/access_token",scopes:"email public_profile pages_show_list pages_read_engagement pages_manage_metadata pages_read_user_content pages_manage_posts pages_manage_engagement business_management ads_management ads_read catalog_management leads_retrieval"},keywords:["pages","posts","comments","insights","ads","campaigns","audiences","business","catalog","events","groups","photos","videos","live videos","oauth"]},meta_ads:{name:"meta_ads",apiUrl:"https://graph.facebook.com",regex:"^.*(meta[_ .-]?ads|facebook[_ .-]?ads|marketing[_ .-]?api|/act_).*$",icon:"meta",docsUrl:"https://developers.facebook.com/docs/marketing-api/",preferredAuthType:"oauth2",oauth:{authUrl:"https://www.facebook.com/v23.0/dialog/oauth",tokenUrl:"https://graph.facebook.com/v23.0/oauth/access_token",scopes:"ads_read ads_management business_management"},keywords:["meta ads","facebook ads","marketing api","ad accounts","campaigns","adsets","ads","adcreatives","insights","custom audiences","pixels","leadgen forms","product catalogs","spend","reach","oauth"],systemSpecificInstructions:"Ad account IDs are prefixed with act_ in all request paths (e.g. /v23.0/act_<ACCOUNT_ID>/insights, /act_<ACCOUNT_ID>/campaigns) \u2014 the numeric ID alone fails. With Standard Access, ads_read/ads_management only work for users who hold a role on the Meta app (suitable for development); serving arbitrary users requires Advanced Access, which needs business verification and App Review. For unattended server-to-server use, Business Manager system user tokens are the standard approach instead of user OAuth tokens. Graph API versions sunset roughly two years after release \u2014 prefer the latest version in paths rather than copying versions from older examples."},instagram:{name:"instagram",apiUrl:"https://graph.facebook.com/v23.0/",regex:"^.*instagram.*$",icon:"instagram",docsUrl:"https://developers.facebook.com/docs/instagram-platform/",preferredAuthType:"oauth2",oauth:{authUrl:"https://www.facebook.com/v23.0/dialog/oauth",tokenUrl:"https://graph.facebook.com/v23.0/oauth/access_token",scopes:"instagram_basic pages_show_list instagram_content_publish pages_read_engagement instagram_manage_comments instagram_manage_insights instagram_manage_messages business_management"},keywords:["instagram","instagram api","instagram graph api","media","posts","stories","comments","insights","hashtags","mentions","business discovery","content publishing","user media","account info","oauth"],systemSpecificInstructions:"There are two distinct Instagram APIs: this template targets the Instagram API with Facebook Login (host graph.facebook.com), which requires an Instagram professional (Business/Creator) account linked to a Facebook Page; hashtag search and business discovery are only available on this variant. The alternative Instagram API with Instagram Login uses host graph.instagram.com, needs no Facebook Page, and uses different tokens/scopes. The legacy Instagram Basic Display API was shut down in December 2024 and cannot be used."},twitter:{name:"twitter",apiUrl:"https://api.twitter.com",regex:"^https?:\\/\\/(?:[^/]+\\.)*(?:twitter\\.com|x\\.com)(?:[:/?#].*)?$",icon:"x",docsUrl:"https://docs.x.com/x-api/introduction",openApiUrl:"https://api.x.com/2/openapi.json",preferredAuthType:"oauth2",oauth:{authUrl:"https://twitter.com/i/oauth2/authorize",tokenUrl:"https://api.twitter.com/2/oauth2/token",scopes:"tweet.read tweet.write users.read follows.read follows.write offline.access like.read like.write list.read list.write block.read block.write bookmark.read bookmark.write mute.read mute.write"},keywords:["tweets","users","followers","timeline","mentions","retweets","likes","lists","spaces","direct messages","trends","media","polls","oauth"]},linkedin:{name:"linkedin",apiUrl:"https://api.linkedin.com",regex:"^.*linkedin.*$",icon:"/logos/linkedin.svg",docsUrl:"https://learn.microsoft.com/en-us/linkedin/shared/authentication/getting-access",preferredAuthType:"oauth2",oauth:{authUrl:"https://www.linkedin.com/oauth/v2/authorization",tokenUrl:"https://www.linkedin.com/oauth/v2/accessToken",scopes:"r_liteprofile r_emailaddress w_member_social r_fullprofile r_basicprofile rw_company_admin r_1st_connections r_ads r_ads_reporting r_organization_social rw_organization_admin w_organization_social r_events"},keywords:["profiles","connections","companies","shares","posts","articles","jobs","skills","endorsements","recommendations","groups","events","messaging","oauth"]},paypal:{name:"paypal",apiUrl:"https://api.paypal.com",regex:"^.*paypal.*$",icon:"paypal",docsUrl:"https://developer.paypal.com/api/rest",preferredAuthType:"api_key",keywords:["payments","orders","captures","refunds","payouts","invoices","subscriptions","plans","products","transactions","balances","webhooks","checkout","billing","query","search"]},square:{name:"square",apiUrl:"https://connect.squareup.com",regex:"^.*(square|squareup).*$",icon:"square",docsUrl:"https://developer.squareup.com/reference/square",openApiUrl:"https://raw.githubusercontent.com/square/connect-api-specification/refs/heads/master/api.json",preferredAuthType:"oauth2",oauth:{authUrl:"https://connect.squareup.com/oauth2/authorize",tokenUrl:"https://connect.squareup.com/oauth2/token",scopes:"MERCHANT_PROFILE_READ PAYMENTS_READ PAYMENTS_WRITE CUSTOMERS_READ CUSTOMERS_WRITE INVENTORY_READ INVENTORY_WRITE ORDERS_READ ORDERS_WRITE ITEMS_READ ITEMS_WRITE EMPLOYEES_READ EMPLOYEES_WRITE TIMECARDS_READ TIMECARDS_WRITE"},keywords:["payments","customers","orders","catalog","inventory","locations","transactions","refunds","cards","checkout","invoices","subscriptions","terminals","employees","shifts","query","search","oauth"]},adyen:{name:"adyen",apiUrl:"https://checkout-test.adyen.com",regex:"^.*adyen.*$",icon:"adyen",docsUrl:"https://docs.adyen.com/api-explorer",openApiUrl:"https://raw.githubusercontent.com/Adyen/adyen-openapi/main/yaml/CheckoutService-v71.yaml",preferredAuthType:"api_key",keywords:["paymentMethods","sessions","payments","payments.details","cardDetails","recurringContracts","payouts","balanceTransfers","legalEntities","binLookup","storedValueCards","transferRules","terminalManagement","accountHolders","issuers"]},razorpay:{name:"razorpay",apiUrl:"https://api.razorpay.com",regex:"^.*razorpay.*$",icon:"razorpay",docsUrl:"https://razorpay.com/docs/api",preferredAuthType:"api_key",keywords:["payments","orders","customers","refunds","invoices","subscriptions","accounts","fund_accounts","payouts","virtual_accounts","mandates","disputes","settlements","payment_links","bin_lookup"]},plaid:{name:"plaid",apiUrl:"https://production.plaid.com",regex:"^.*plaid.*$",icon:"/logos/plaid.svg",docsUrl:"https://plaid.com/docs/api",openApiUrl:"https://raw.githubusercontent.com/plaid/plaid-openapi/master/2020-09-14.yml",preferredAuthType:"api_key",keywords:["items","accounts","institutions","link_tokens","access_tokens","transactions","auth","identity","assets","liabilities","income","user","processor_tokens","transfer","investments"]},zendesk:{name:"zendesk",apiUrl:"https://api.zendesk.com",regex:"^.*zendesk.*$",icon:"zendesk",docsUrl:"https://developer.zendesk.com/api-reference",openApiUrl:"https://developer.zendesk.com/zendesk/oas.yaml",preferredAuthType:"api_key",oauth:{authUrl:"https://{subdomain}.zendesk.com/oauth/authorizations/new",tokenUrl:"https://{subdomain}.zendesk.com/oauth/tokens",scopes:"read write tickets:read tickets:write users:read users:write organizations:read organizations:write hc:read hc:write chat:read chat:write"},keywords:["tickets","users","organizations","groups","agents","views","macros","triggers","automations","sla","custom fields","tags","satisfaction","help center","api key"]},freshdesk:{name:"freshdesk",apiUrl:"https://{domain}.freshdesk.com/api/v2",regex:"^.*freshdesk.*$",icon:"/logos/freshdesk.svg",docsUrl:"https://developers.freshdesk.com/api",preferredAuthType:"api_key",keywords:["tickets","contacts","agents","companies","groups","forums","solutions","categories","folders","articles","time entries","surveys","satisfaction","sla","escalations","api key"]},freshworks:{name:"freshworks",apiUrl:"https://{domain}.freshservice.com/api/v2",regex:"^.*(freshworks|freshservice).*$",icon:"/logos/freshworks.svg",docsUrl:"https://api.freshservice.com",preferredAuthType:"api_key",keywords:["tickets","requesters","agents","assets","changes","problems","releases","service catalog","service items","departments","locations","products","vendors","contracts","api key"]},servicenow:{name:"servicenow",apiUrl:"https://{instance}.service-now.com/api",regex:"^.*(servicenow|service-now).*$",icon:"servicenow",docsUrl:"https://developer.servicenow.com/dev.do#!/reference/api/latest/rest",preferredAuthType:"api_key",keywords:["incidents","problems","changes","requests","users","groups","cmdb","configuration items","service catalog","knowledge","tasks","approvals","sla","workflows","tables","api key"]},helpscout:{name:"helpscout",apiUrl:"https://api.helpscout.net",regex:"^.*helpscout.*$",icon:"helpscout",docsUrl:"https://developer.helpscout.com/mailbox-api",preferredAuthType:"api_key",keywords:["conversations","customers","mailboxes","threads","tags","teams","users","reports","satisfaction","ratings","workflows","saved replies","docs","beacon","api key"]},box:{name:"box",label:"Box",apiUrl:"https://api.box.com/2.0",regex:"^https?:\\/\\/(?:[^/]+\\.)*box\\.com(?:[:/?#].*)?$",icon:"simpleicons:box",docsUrl:"https://developer.box.com/reference/",preferredAuthType:"oauth2",oauth:{authUrl:"https://account.box.com/api/oauth2/authorize",tokenUrl:"https://api.box.com/oauth2/token",scopes:"root_readwrite",client_id:"m7zi0ai4amo32eg0ao8mpr6rx0uzjell",tokenAuthMethod:"body",tokenContentType:"form"},systemSpecificInstructions:"superglue provides a managed Box OAuth app; users connect with their Box login and never need to create a Box app or supply a client ID or secret. File uploads go to https://upload.box.com/api/2.0, not the main API host. If authorization fails with an app-not-authorized error, the Box enterprise blocks unpublished apps; a Box admin must enable the app in Admin Console > Apps > Custom Apps Manager using the client ID. Refresh tokens rotate and expire after 60 days without use.",keywords:["files","folders","upload","download","sharing","links","metadata","search","collaborations","comments","tasks","enterprise","content","oauth"]},dropbox:{name:"dropbox",apiUrl:"https://api.dropboxapi.com",regex:"^.*dropbox.*$",icon:"dropbox",docsUrl:"https://www.dropbox.com/developers/documentation/http/documentation",preferredAuthType:"oauth2",oauth:{authUrl:"https://www.dropbox.com/oauth2/authorize",tokenUrl:"https://api.dropboxapi.com/oauth2/token",scopes:"files.metadata.read files.metadata.write files.content.read files.content.write sharing.read sharing.write account_info.read account_info.write"},keywords:["files","folders","upload","download","sharing","links","metadata","search","sync","paper","users","teams","move","copy","delete","oauth"]},mailchimp:{name:"mailchimp",apiUrl:"https://api.mailchimp.com",regex:"^.*mailchimp.*$",icon:"mailchimp",docsUrl:"https://mailchimp.com/developer/marketing/api",openApiUrl:"https://api.mailchimp.com/schema/3.0/Swagger.json",preferredAuthType:"api_key",oauth:{authUrl:"https://login.mailchimp.com/oauth2/authorize",tokenUrl:"https://login.mailchimp.com/oauth2/token",scopes:"audiences:read audiences:write automations:read automations:write campaigns:read campaigns:write conversations:read conversations:write ecommerce:read ecommerce:write files:read files:write lists:read lists:write reports:read templates:read templates:write"},keywords:["lists","campaigns","templates","audiences","members","segments","tags","automations","reports","folders","merge fields","activities","ecommerce","batch","query","api key"]},jira:{name:"jira",apiUrl:"https://{your-domain}.atlassian.net/rest/api",regex:"^.*(jira|atlassian).*$",icon:"jira",docsUrl:"https://developer.atlassian.com/cloud/jira/platform/rest/v3",openApiUrl:"https://developer.atlassian.com/cloud/jira/platform/swagger-v3.json",preferredAuthType:"oauth2",oauth:{authUrl:"https://auth.atlassian.com/authorize",tokenUrl:"https://auth.atlassian.com/oauth/token",scopes:"read:jira-work write:jira-work read:jira-user write:jira-user read:jira-work-management write:jira-work-management read:servicedesk-request write:servicedesk-request manage:jira-project manage:jira-configuration manage:jira-data-provider offline_access",client_id:"Az7iTb4uWYSv5N4p295PulP8oO2B3PjK"},systemSpecificInstructions:"You need a cloud id in the url to connect to the Jira instance. Fetch it from available-resources and store it in the system. The /rest/api/3/search endpoint has been deprecated - Use GET /rest/api/3/search/jql with query parameter 'jql' for searching issues. MUST specify a project in the JQL query. Example: GET /rest/api/3/search/jql?jql=project=KAN&maxResults=100. The jql parameter accepts JQL queries like 'project=KEY', 'assignee=currentUser()', 'order by created DESC'. Always URL-encode the jql parameter value.",keywords:["issues","projects","boards","sprints","epics","users","workflows","fields","components","versions","priorities","statuses","comments","attachments","jql","query","search","oauth"]},confluence:{name:"confluence",apiUrl:"https://{your-domain}.atlassian.net/wiki/api/v2",regex:"^.*(confluence|atlassian).*$",icon:"confluence",docsUrl:"https://developer.atlassian.com/cloud/confluence/rest/v2",openApiUrl:"https://dac-static.atlassian.com/cloud/confluence/openapi-v2.v3.json",preferredAuthType:"oauth2",oauth:{authUrl:"https://auth.atlassian.com/authorize",tokenUrl:"https://auth.atlassian.com/oauth/token",scopes:"read:confluence-content.all write:confluence-content read:confluence-space.summary write:confluence-space read:confluence-props write:confluence-props read:confluence-user write:confluence-user read:confluence-groups write:confluence-groups delete:confluence-content delete:confluence-space offline_access",client_id:"Az7iTb4uWYSv5N4p295PulP8oO2B3PjK"},systemSpecificInstructions:"Use the Confluence Cloud REST API v2 under /wiki/api/v2 instead of legacy /wiki/rest/api v1 endpoints when a v2 equivalent exists. With OAuth 2.0, fetch the cloud id from GET https://api.atlassian.com/oauth/token/accessible-resources and use https://api.atlassian.com/ex/confluence/{cloudId}/wiki/api/v2 as the system base URL. V2 list endpoints use cursor-based pagination; follow the Link header or _links.next URL until no next page remains.",keywords:["spaces","pages","content","attachments","comments","labels","templates","blueprints","macros","restrictions","versions","ancestors","descendants","children","oauth"]},quickbooks:{name:"quickbooks",apiUrl:"https://quickbooks.api.intuit.com",regex:"^.*(quickbooks|intuit).*$",icon:"quickbooks",docsUrl:"https://developer.intuit.com/app/developer/qbo/docs/api/accounting/most-commonly-used/account",preferredAuthType:"oauth2",oauth:{authUrl:"https://appcenter.intuit.com/connect/oauth2",tokenUrl:"https://oauth.platform.intuit.com/oauth2/v1/tokens/bearer",scopes:"com.intuit.quickbooks.accounting com.intuit.quickbooks.payment com.intuit.quickbooks.payroll com.intuit.quickbooks.payroll.timetracking com.intuit.quickbooks.payroll.benefits openid profile email phone address"},keywords:["accounts","invoices","customers","vendors","bills","payments","estimates","purchase orders","sales receipts","credit memos","journal entries","items","tax rates","employees","reports","oauth"]},ramp:{name:"ramp",apiUrl:"https://api.ramp.com/developer/v1",regex:"(^|.*\\b)(ramp|ramp\\.com|api\\.ramp\\.com|demo-api\\.ramp\\.com)(\\b.*|$)",icon:"ramp",docsUrl:"https://docs.ramp.com/developer-api/v1",openApiUrl:"https://docs.ramp.com/openapi/developer-api.json",preferredAuthType:"oauth2",oauth:{tokenUrl:"https://api.ramp.com/developer/v1/token",scopes:"transactions:read cards:read users:read business:read bills:read reimbursements:read vendors:read accounting:read receipts:read departments:read locations:read limits:read spend_programs:read statements:read transfers:read bank_accounts:read",grant_type:"client_credentials",tokenAuthMethod:"basic_auth",tokenContentType:"form"},keywords:["transactions","cards","users","business","bills","reimbursements","vendors","accounting","receipts","departments","locations","limits","spend_programs","statements","transfers","bank_accounts"],systemSpecificInstructions:`Ramp has separate production and sandbox API hosts. Production calls use https://api.ramp.com/developer/v1; sandbox calls use https://demo-api.ramp.com/developer/v1. Do not use the Ramp web app hosts (app.ramp.com or demo.ramp.com) for API calls.
|
|
424
|
+
HEADERS: { "Authorization": "Bearer <<token>>", "Content-Type": "application/json" }`,keywords:["datasets","tables","queries","jobs","projects","schemas","rows","streaming","partitions","clustering","views","routines","models","data warehouse","sql","oauth"]},firebase:{name:"firebase",apiUrl:"https://firestore.googleapis.com",regex:"^.*(firebase|firestore).*$",icon:"firebase",docsUrl:"https://firebase.google.com/docs/reference/firebase-management/rest",openApiUrl:"https://firestore.googleapis.com/$discovery/rest?version=v1",preferredAuthType:"oauth2",oauth:{authUrl:"https://accounts.google.com/o/oauth2/v2/auth",tokenUrl:"https://oauth2.googleapis.com/token",scopes:"https://www.googleapis.com/auth/firebase https://www.googleapis.com/auth/cloud-platform"},keywords:["firestore","realtime database","authentication","cloud functions","storage","hosting","documents","collections","users","projects","apps","query","oauth"]},salesforce:{name:"salesforce",apiUrl:"https://api.salesforce.com",regex:"^.*salesforce.*$",icon:"salesforce",docsUrl:"https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/intro_rest.htm",preferredAuthType:"oauth2",oauth:{authUrl:"https://login.salesforce.com/services/oauth2/authorize",tokenUrl:"https://login.salesforce.com/services/oauth2/token",scopes:"full",grant_type:"authorization_code",client_id:"3MVG9rZjd7MXFdLj8gMo0sojKlWRAgOP9F7nsk3Tec.eesq86nNTvbzDJDcmCW9YRCbteTayd_dP4OCLtISIo"},keywords:["accounts","contacts","leads","opportunities","cases","campaigns","products","price books","quotes","contracts","orders","custom objects","soql","query","search","sobjects","oauth"]},facebook:{name:"facebook",apiUrl:"https://graph.facebook.com",regex:"^.*facebook.*$",icon:"facebook",docsUrl:"https://developers.facebook.com/docs/graph-api",preferredAuthType:"oauth2",oauth:{authUrl:"https://www.facebook.com/v18.0/dialog/oauth",tokenUrl:"https://graph.facebook.com/v18.0/oauth/access_token",scopes:"email public_profile pages_show_list pages_read_engagement pages_manage_metadata pages_read_user_content pages_manage_posts pages_manage_engagement business_management ads_management ads_read catalog_management leads_retrieval"},keywords:["pages","posts","comments","insights","ads","campaigns","audiences","business","catalog","events","groups","photos","videos","live videos","oauth"]},meta_ads:{name:"meta_ads",apiUrl:"https://graph.facebook.com",regex:"^.*(meta[_ .-]?ads|facebook[_ .-]?ads|marketing[_ .-]?api|/act_).*$",icon:"meta",docsUrl:"https://developers.facebook.com/docs/marketing-api/",preferredAuthType:"oauth2",oauth:{authUrl:"https://www.facebook.com/v23.0/dialog/oauth",tokenUrl:"https://graph.facebook.com/v23.0/oauth/access_token",scopes:"ads_read ads_management business_management"},keywords:["meta ads","facebook ads","marketing api","ad accounts","campaigns","adsets","ads","adcreatives","insights","custom audiences","pixels","leadgen forms","product catalogs","spend","reach","oauth"],systemSpecificInstructions:"Ad account IDs are prefixed with act_ in all request paths (e.g. /v23.0/act_<ACCOUNT_ID>/insights, /act_<ACCOUNT_ID>/campaigns) \u2014 the numeric ID alone fails. With Standard Access, ads_read/ads_management only work for users who hold a role on the Meta app (suitable for development); serving arbitrary users requires Advanced Access, which needs business verification and App Review. For unattended server-to-server use, Business Manager system user tokens are the standard approach instead of user OAuth tokens. Graph API versions sunset roughly two years after release \u2014 prefer the latest version in paths rather than copying versions from older examples."},instagram:{name:"instagram",apiUrl:"https://graph.facebook.com/v23.0/",regex:"^.*instagram.*$",icon:"instagram",docsUrl:"https://developers.facebook.com/docs/instagram-platform/",preferredAuthType:"oauth2",oauth:{authUrl:"https://www.facebook.com/v23.0/dialog/oauth",tokenUrl:"https://graph.facebook.com/v23.0/oauth/access_token",scopes:"instagram_basic pages_show_list instagram_content_publish pages_read_engagement instagram_manage_comments instagram_manage_insights instagram_manage_messages business_management"},keywords:["instagram","instagram api","instagram graph api","media","posts","stories","comments","insights","hashtags","mentions","business discovery","content publishing","user media","account info","oauth"],systemSpecificInstructions:"There are two distinct Instagram APIs: this template targets the Instagram API with Facebook Login (host graph.facebook.com), which requires an Instagram professional (Business/Creator) account linked to a Facebook Page; hashtag search and business discovery are only available on this variant. The alternative Instagram API with Instagram Login uses host graph.instagram.com, needs no Facebook Page, and uses different tokens/scopes. The legacy Instagram Basic Display API was shut down in December 2024 and cannot be used."},twitter:{name:"twitter",apiUrl:"https://api.twitter.com",regex:"^https?:\\/\\/(?:[^/]+\\.)*(?:twitter\\.com|x\\.com)(?:[:/?#].*)?$",icon:"x",docsUrl:"https://docs.x.com/x-api/introduction",openApiUrl:"https://api.x.com/2/openapi.json",preferredAuthType:"oauth2",oauth:{authUrl:"https://twitter.com/i/oauth2/authorize",tokenUrl:"https://api.twitter.com/2/oauth2/token",scopes:"tweet.read tweet.write users.read follows.read follows.write offline.access like.read like.write list.read list.write block.read block.write bookmark.read bookmark.write mute.read mute.write"},keywords:["tweets","users","followers","timeline","mentions","retweets","likes","lists","spaces","direct messages","trends","media","polls","oauth"]},linkedin:{name:"linkedin",apiUrl:"https://api.linkedin.com",regex:"^.*linkedin.*$",icon:"/logos/linkedin.svg",docsUrl:"https://learn.microsoft.com/en-us/linkedin/shared/authentication/getting-access",preferredAuthType:"oauth2",oauth:{authUrl:"https://www.linkedin.com/oauth/v2/authorization",tokenUrl:"https://www.linkedin.com/oauth/v2/accessToken",scopes:"r_liteprofile r_emailaddress w_member_social r_fullprofile r_basicprofile rw_company_admin r_1st_connections r_ads r_ads_reporting r_organization_social rw_organization_admin w_organization_social r_events"},keywords:["profiles","connections","companies","shares","posts","articles","jobs","skills","endorsements","recommendations","groups","events","messaging","oauth"]},paypal:{name:"paypal",apiUrl:"https://api.paypal.com",regex:"^.*paypal.*$",icon:"paypal",docsUrl:"https://developer.paypal.com/api/rest",preferredAuthType:"api_key",keywords:["payments","orders","captures","refunds","payouts","invoices","subscriptions","plans","products","transactions","balances","webhooks","checkout","billing","query","search"]},square:{name:"square",apiUrl:"https://connect.squareup.com",regex:"^.*(square|squareup).*$",icon:"square",docsUrl:"https://developer.squareup.com/reference/square",openApiUrl:"https://raw.githubusercontent.com/square/connect-api-specification/refs/heads/master/api.json",preferredAuthType:"oauth2",oauth:{authUrl:"https://connect.squareup.com/oauth2/authorize",tokenUrl:"https://connect.squareup.com/oauth2/token",scopes:"MERCHANT_PROFILE_READ PAYMENTS_READ PAYMENTS_WRITE CUSTOMERS_READ CUSTOMERS_WRITE INVENTORY_READ INVENTORY_WRITE ORDERS_READ ORDERS_WRITE ITEMS_READ ITEMS_WRITE EMPLOYEES_READ EMPLOYEES_WRITE TIMECARDS_READ TIMECARDS_WRITE"},keywords:["payments","customers","orders","catalog","inventory","locations","transactions","refunds","cards","checkout","invoices","subscriptions","terminals","employees","shifts","query","search","oauth"]},adyen:{name:"adyen",apiUrl:"https://checkout-test.adyen.com",regex:"^.*adyen.*$",icon:"adyen",docsUrl:"https://docs.adyen.com/api-explorer",openApiUrl:"https://raw.githubusercontent.com/Adyen/adyen-openapi/main/yaml/CheckoutService-v71.yaml",preferredAuthType:"api_key",keywords:["paymentMethods","sessions","payments","payments.details","cardDetails","recurringContracts","payouts","balanceTransfers","legalEntities","binLookup","storedValueCards","transferRules","terminalManagement","accountHolders","issuers"]},razorpay:{name:"razorpay",apiUrl:"https://api.razorpay.com",regex:"^.*razorpay.*$",icon:"razorpay",docsUrl:"https://razorpay.com/docs/api",preferredAuthType:"api_key",keywords:["payments","orders","customers","refunds","invoices","subscriptions","accounts","fund_accounts","payouts","virtual_accounts","mandates","disputes","settlements","payment_links","bin_lookup"]},plaid:{name:"plaid",apiUrl:"https://production.plaid.com",regex:"^.*plaid.*$",icon:"/logos/plaid.svg",docsUrl:"https://plaid.com/docs/api",openApiUrl:"https://raw.githubusercontent.com/plaid/plaid-openapi/master/2020-09-14.yml",preferredAuthType:"api_key",keywords:["items","accounts","institutions","link_tokens","access_tokens","transactions","auth","identity","assets","liabilities","income","user","processor_tokens","transfer","investments"]},zendesk:{name:"zendesk",apiUrl:"https://api.zendesk.com",regex:"^.*zendesk.*$",icon:"zendesk",docsUrl:"https://developer.zendesk.com/api-reference",openApiUrl:"https://developer.zendesk.com/zendesk/oas.yaml",preferredAuthType:"api_key",oauth:{authUrl:"https://{subdomain}.zendesk.com/oauth/authorizations/new",tokenUrl:"https://{subdomain}.zendesk.com/oauth/tokens",scopes:"read write tickets:read tickets:write users:read users:write organizations:read organizations:write hc:read hc:write chat:read chat:write"},keywords:["tickets","users","organizations","groups","agents","views","macros","triggers","automations","sla","custom fields","tags","satisfaction","help center","api key"]},freshdesk:{name:"freshdesk",apiUrl:"https://{domain}.freshdesk.com/api/v2",regex:"^.*freshdesk.*$",icon:"/logos/freshdesk.svg",docsUrl:"https://developers.freshdesk.com/api",preferredAuthType:"api_key",keywords:["tickets","contacts","agents","companies","groups","forums","solutions","categories","folders","articles","time entries","surveys","satisfaction","sla","escalations","api key"]},freshworks:{name:"freshworks",apiUrl:"https://{domain}.freshservice.com/api/v2",regex:"^.*(freshworks|freshservice).*$",icon:"/logos/freshworks.svg",docsUrl:"https://api.freshservice.com",preferredAuthType:"api_key",keywords:["tickets","requesters","agents","assets","changes","problems","releases","service catalog","service items","departments","locations","products","vendors","contracts","api key"]},servicenow:{name:"servicenow",apiUrl:"https://{instance}.service-now.com/api",regex:"^.*(servicenow|service-now).*$",icon:"servicenow",docsUrl:"https://developer.servicenow.com/dev.do#!/reference/api/latest/rest",preferredAuthType:"api_key",keywords:["incidents","problems","changes","requests","users","groups","cmdb","configuration items","service catalog","knowledge","tasks","approvals","sla","workflows","tables","api key"]},helpscout:{name:"helpscout",apiUrl:"https://api.helpscout.net",regex:"^.*helpscout.*$",icon:"helpscout",docsUrl:"https://developer.helpscout.com/mailbox-api",preferredAuthType:"api_key",keywords:["conversations","customers","mailboxes","threads","tags","teams","users","reports","satisfaction","ratings","workflows","saved replies","docs","beacon","api key"]},box:{name:"box",label:"Box",apiUrl:"https://api.box.com/2.0",regex:"^https?:\\/\\/(?:[^/]+\\.)*box\\.com(?:[:/?#].*)?$",icon:"simpleicons:box",docsUrl:"https://developer.box.com/reference/",preferredAuthType:"oauth2",oauth:{authUrl:"https://account.box.com/api/oauth2/authorize",tokenUrl:"https://api.box.com/oauth2/token",scopes:"root_readwrite",client_id:"m7zi0ai4amo32eg0ao8mpr6rx0uzjell",tokenAuthMethod:"body",tokenContentType:"form"},systemSpecificInstructions:"superglue provides a managed Box OAuth app; users connect with their Box login and never need to create a Box app or supply a client ID or secret. File uploads go to https://upload.box.com/api/2.0, not the main API host. If authorization fails with an app-not-authorized error, the Box enterprise blocks unpublished apps; a Box admin must enable the app in Admin Console > Apps > Custom Apps Manager using the client ID. Refresh tokens rotate and expire after 60 days without use.",keywords:["files","folders","upload","download","sharing","links","metadata","search","collaborations","comments","tasks","enterprise","content","oauth"]},dropbox:{name:"dropbox",apiUrl:"https://api.dropboxapi.com",regex:"^.*dropbox.*$",icon:"dropbox",docsUrl:"https://www.dropbox.com/developers/documentation/http/documentation",preferredAuthType:"oauth2",oauth:{authUrl:"https://www.dropbox.com/oauth2/authorize",tokenUrl:"https://api.dropboxapi.com/oauth2/token",scopes:"files.metadata.read files.metadata.write files.content.read files.content.write sharing.read sharing.write account_info.read account_info.write"},keywords:["files","folders","upload","download","sharing","links","metadata","search","sync","paper","users","teams","move","copy","delete","oauth"]},mailchimp:{name:"mailchimp",apiUrl:"https://api.mailchimp.com",regex:"^.*mailchimp.*$",icon:"mailchimp",docsUrl:"https://mailchimp.com/developer/marketing/api",openApiUrl:"https://api.mailchimp.com/schema/3.0/Swagger.json",preferredAuthType:"api_key",oauth:{authUrl:"https://login.mailchimp.com/oauth2/authorize",tokenUrl:"https://login.mailchimp.com/oauth2/token",scopes:"audiences:read audiences:write automations:read automations:write campaigns:read campaigns:write conversations:read conversations:write ecommerce:read ecommerce:write files:read files:write lists:read lists:write reports:read templates:read templates:write"},keywords:["lists","campaigns","templates","audiences","members","segments","tags","automations","reports","folders","merge fields","activities","ecommerce","batch","query","api key"]},jira:{name:"jira",apiUrl:"https://{your-domain}.atlassian.net/rest/api",regex:"^.*(jira|atlassian).*$",icon:"jira",docsUrl:"https://developer.atlassian.com/cloud/jira/platform/rest/v3",openApiUrl:"https://developer.atlassian.com/cloud/jira/platform/swagger-v3.json",preferredAuthType:"oauth2",oauth:{authUrl:"https://auth.atlassian.com/authorize",tokenUrl:"https://auth.atlassian.com/oauth/token",scopes:"read:jira-work write:jira-work read:jira-user write:jira-user read:jira-work-management write:jira-work-management read:servicedesk-request write:servicedesk-request manage:jira-project manage:jira-configuration manage:jira-data-provider offline_access",client_id:"Az7iTb4uWYSv5N4p295PulP8oO2B3PjK"},systemSpecificInstructions:"You need a cloud id in the url to connect to the Jira instance. Fetch it from available-resources and store it in the system. The /rest/api/3/search endpoint has been deprecated - Use GET /rest/api/3/search/jql with query parameter 'jql' for searching issues. MUST specify a project in the JQL query. Example: GET /rest/api/3/search/jql?jql=project=KAN&maxResults=100. The jql parameter accepts JQL queries like 'project=KEY', 'assignee=currentUser()', 'order by created DESC'. Always URL-encode the jql parameter value.",keywords:["issues","projects","boards","sprints","epics","users","workflows","fields","components","versions","priorities","statuses","comments","attachments","jql","query","search","oauth"]},confluence:{name:"confluence",apiUrl:"https://{your-domain}.atlassian.net/wiki/api/v2",regex:"^.*(confluence|atlassian).*$",icon:"confluence",docsUrl:"https://developer.atlassian.com/cloud/confluence/rest/v2",openApiUrl:"https://dac-static.atlassian.com/cloud/confluence/openapi-v2.v3.json",preferredAuthType:"oauth2",oauth:{authUrl:"https://auth.atlassian.com/authorize",tokenUrl:"https://auth.atlassian.com/oauth/token",scopes:"read:confluence-content.all write:confluence-content read:confluence-space.summary write:confluence-space read:confluence-props write:confluence-props read:confluence-user write:confluence-user read:confluence-groups write:confluence-groups delete:confluence-content delete:confluence-space offline_access",client_id:"Az7iTb4uWYSv5N4p295PulP8oO2B3PjK"},systemSpecificInstructions:"Use the Confluence Cloud REST API v2 under /wiki/api/v2 instead of legacy /wiki/rest/api v1 endpoints when a v2 equivalent exists. With OAuth 2.0, fetch the cloud id from GET https://api.atlassian.com/oauth/token/accessible-resources and use https://api.atlassian.com/ex/confluence/{cloudId}/wiki/api/v2 as the system base URL. V2 list endpoints use cursor-based pagination; follow the Link header or _links.next URL until no next page remains.",keywords:["spaces","pages","content","attachments","comments","labels","templates","blueprints","macros","restrictions","versions","ancestors","descendants","children","oauth"]},quickbooks:{name:"quickbooks",apiUrl:"https://quickbooks.api.intuit.com",regex:"^.*(quickbooks|intuit).*$",icon:"quickbooks",docsUrl:"https://developer.intuit.com/app/developer/qbo/docs/api/accounting/most-commonly-used/account",preferredAuthType:"oauth2",oauth:{authUrl:"https://appcenter.intuit.com/connect/oauth2",tokenUrl:"https://oauth.platform.intuit.com/oauth2/v1/tokens/bearer",scopes:"com.intuit.quickbooks.accounting com.intuit.quickbooks.payment com.intuit.quickbooks.payroll com.intuit.quickbooks.payroll.timetracking com.intuit.quickbooks.payroll.benefits openid profile email phone address",client_id:"ABzdIKeLde7iGXfGGjbozUUHcQ6k84yINaX42S6OmJtftvM3Q4"},keywords:["accounts","invoices","customers","vendors","bills","payments","estimates","purchase orders","sales receipts","credit memos","journal entries","items","tax rates","employees","reports","oauth"]},ramp:{name:"ramp",apiUrl:"https://api.ramp.com/developer/v1",regex:"(^|.*\\b)(ramp|ramp\\.com|api\\.ramp\\.com|demo-api\\.ramp\\.com)(\\b.*|$)",icon:"ramp",docsUrl:"https://docs.ramp.com/developer-api/v1",openApiUrl:"https://docs.ramp.com/openapi/developer-api.json",preferredAuthType:"oauth2",oauth:{tokenUrl:"https://api.ramp.com/developer/v1/token",scopes:"transactions:read cards:read users:read business:read bills:read reimbursements:read vendors:read accounting:read receipts:read departments:read locations:read limits:read spend_programs:read statements:read transfers:read bank_accounts:read",grant_type:"client_credentials",tokenAuthMethod:"basic_auth",tokenContentType:"form"},keywords:["transactions","cards","users","business","bills","reimbursements","vendors","accounting","receipts","departments","locations","limits","spend_programs","statements","transfers","bank_accounts"],systemSpecificInstructions:`Ramp has separate production and sandbox API hosts. Production calls use https://api.ramp.com/developer/v1; sandbox calls use https://demo-api.ramp.com/developer/v1. Do not use the Ramp web app hosts (app.ramp.com or demo.ramp.com) for API calls.
|
|
425
425
|
|
|
426
426
|
Create the developer app from the Ramp dashboard's Developer area with an Admin or Business Owner account, enable the Client Credentials grant for internal server-to-server integrations, configure only the required scopes, and copy the client ID and client secret. Sandbox access is not self-serve; the customer must request a sandbox from Ramp, and sandbox credentials do not work in production.
|
|
427
427
|
|
|
@@ -1324,11 +1324,11 @@ ${m.toString(16)}\r
|
|
|
1324
1324
|
\r
|
|
1325
1325
|
`,"latin1"),t!==null&&i!==t){if(a[Zy])throw new qr;process.emitWarning(new qr)}e[xe].timeout&&e[xe].timeoutType===Js&&e[xe].timeout.refresh&&e[xe].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=wK});var a8=y((_ge,t8)=>{"use strict";var wt=require("assert"),{pipeline:DK}=require("stream"),ee=K(),{RequestContentLengthMismatchError:nk,RequestAbortedError:TK,SocketError:um,InformationalError:vi,InvalidArgumentError:RK}=$(),{kUrl:lm,kReset:Id,kClient:Wo,kRunning:dm,kPending:NK,kQueue:xi,kPendingIdx:mk,kRunningIdx:Mt,kError:Jo,kSocket:Ie,kStrictContentLength:UK,kOnError:Ks,kMaxConcurrentStreams:qd,kPingInterval:Wj,kHTTP2Session:Ua,kHTTP2InitialWindowSize:OK,kHTTP2ConnectionWindowSize:MK,kResume:aa,kSize:_K,kHTTPContext:lk,kClosed:ck,kBodyTimeout:LK,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:FK,HTTP2_HEADER_METHOD:Zj,HTTP2_HEADER_PATH:Xj,HTTP2_HEADER_SCHEME:ik,HTTP2_HEADER_CONTENT_LENGTH:PK,HTTP2_HEADER_EXPECT:HK,HTTP2_HEADER_STATUS:rk,HTTP2_HEADER_PROTOCOL:GK,NGHTTP2_REFUSED_STREAM:YK,NGHTTP2_CANCEL:VK}}=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 $K(o,e){o[Ie]=e;let t=o[OK],a=o[MK],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(ZK,o[Wj],i).unref()}},i[cm]=!1,i[mm]=!1,a&&ee.addListener(i,"connect",JK.bind(i,a)),ee.addListener(i,"error",XK),ee.addListener(i,"frameError",eZ),ee.addListener(i,"end",oZ),ee.addListener(i,"goaway",tZ),ee.addListener(i,"close",aZ),ee.addListener(i,"remoteSettings",KK),i.unref(),o[Ua]=i,e[Ua]=i,ee.addListener(e,"error",rZ),ee.addListener(e,"end",sZ),ee.addListener(e,"close",iZ),e[ck]=!1,e.on("close",nZ),{version:"h2",defaultPipelining:1/0,write(r){return mZ(o,r)},resume(){WK(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 WK(o){let e=o[Ie];e?.destroyed===!1&&(o[_K]===0||o[qd]===0?(e.unref(),o[Ua].unref()):(e.ref(),o[Ua].ref()))}function JK(o){try{typeof this.setLocalWindowSize=="function"&&this.setLocalWindowSize(o)}catch{}}function KK(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 ZK(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 XK(o){wt(o.code!=="ERR_TLS_CERT_ALTNAME_INVALID"),this[Ie][Jo]=o,this[Wo][Ks](o)}function eZ(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 oZ(){let o=new um("other side closed",ee.getSocketInfo(this[Ie]));this.destroy(o),ee.destroy(this[Ie],o)}function tZ(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 aZ(){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[NK]===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 iZ(){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 rZ(o){wt(o.code!=="ERR_TLS_CERT_ALTNAME_INVALID"),this[Jo]=o,this[Wo][Ks](o)}function sZ(){ee.destroy(this,new um("other side closed",ee.getSocketInfo(this)))}function nZ(){this[ck]=!0}function cZ(o){return o!=="GET"&&o!=="HEAD"&&o!=="OPTIONS"&&o!=="TRACE"&&o!=="CONNECT"}function mZ(o,e){let t=e.bodyTimeout??o[LK],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 RK(`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[FK]=s||`${b}${A?`:${A}`:""}`,g[Zj]=i;let k=D=>{e.aborted||e.completed||(D=D||new TK,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[GK]="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===YK||p.rstCode===VK)&&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),cZ(i)&&v>0&&e.contentLength!=null&&e.contentLength!==v){if(o[UK])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[PK]=`${v}`),a.ref(),Jj.sendHeaders.hasSubscribers){let D="";for(let O in g)D+=`${O}: ${g[O]}\r
|
|
1326
1326
|
`;Jj.sendHeaders.publish({request:e,headers:D,socket:a[Ie]})}let j=i==="GET"||i==="HEAD"||d===null;c?(g[HK]="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):uZ(k,p,d,o,e,o[Ie],v,x):ee.isStream(d)?lZ(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 lZ(o,e,t,a,i,r,s,n){wt(n!==0||r[dm]===0,"stream body cannot be pipelined");let c=DK(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 uZ(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=$K});var Ii=y((Lge,u8)=>{"use strict";var Oa=require("assert"),n8=require("net"),gm=require("http"),Br=K(),{ClientStats:dZ}=iy(),{channels:Zs}=yi(),gZ=wC(),pZ=Ar(),{InvalidArgumentError:ze,InformationalError:hZ,ClientDestroyedError:fZ}=$(),bZ=wr(),{kUrl:ia,kServerName:Ei,kClient:yZ,kBusy:gk,kConnect:kZ,kResuming:Qr,kRunning:bm,kPending:ym,kSize:pm,kQueue:_t,kConnected:AZ,kConnecting:Xs,kNeedDrain:qi,kKeepAliveDefaultTimeout:i8,kHostHeader:wZ,kPendingIdx:Lt,kRunningIdx:_a,kError:vZ,kPipelining:Cd,kKeepAliveTimeoutValue:xZ,kMaxHeadersSize:zZ,kKeepAliveMaxTimeout:qZ,kKeepAliveTimeoutThreshold:EZ,kHeadersTimeout:IZ,kBodyTimeout:CZ,kStrictContentLength:jZ,kConnector:hm,kMaxRequests:pk,kCounter:BZ,kClose:QZ,kDestroy:SZ,kDispatch:DZ,kLocalAddress:fm,kMaxResponseSize:TZ,kOnError:RZ,kHTTPContext:Ne,kMaxConcurrentStreams:NZ,kHTTP2InitialWindowSize:UZ,kHTTP2ConnectionWindowSize:OZ,kResume:Ma,kPingInterval:MZ}=de(),_Z=$j(),LZ=a8(),zi=Symbol("kClosedResolve"),FZ=gm&&gm.maxHeaderSize&&Number.isInteger(gm.maxHeaderSize)&&gm.maxHeaderSize>0?()=>gm.maxHeaderSize:()=>{throw new ze("http module not available or http.maxHeaderSize invalid")},r8=()=>{};function c8(o){return o[Cd]??o[Ne]?.defaultPipelining??1}var hk=class extends pZ{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:ae,initialWindowSize:ye,connectionWindowSize:po,pingInterval:Ve,webSocket:ya}={}){if(m!==void 0)throw new ze("unsupported keepAlive, use pipelining=0 instead");if(i!==void 0)throw new ze("unsupported socketTimeout, use headersTimeout & bodyTimeout instead");if(r!==void 0)throw new ze("unsupported requestTimeout, use headersTimeout & bodyTimeout instead");if(c!==void 0)throw new ze("unsupported idleTimeout, use keepAliveTimeout instead");if(u!==void 0)throw new ze("unsupported maxKeepAliveTimeout, use keepAliveMaxTimeout instead");if(t!=null){if(!Number.isInteger(t)||t<1)throw new ze("invalid maxHeaderSize")}else t=FZ();if(p!=null&&typeof p!="string")throw new ze("invalid socketPath");if(s!=null&&(!Number.isFinite(s)||s<0))throw new ze("invalid connectTimeout");if(l!=null&&(!Number.isFinite(l)||l<=0))throw new ze("invalid keepAliveTimeout");if(d!=null&&(!Number.isFinite(d)||d<=0))throw new ze("invalid keepAliveMaxTimeout");if(g!=null&&!Number.isFinite(g))throw new ze("invalid keepAliveTimeoutThreshold");if(a!=null&&(!Number.isInteger(a)||a<0))throw new ze("headersTimeout must be a positive integer or zero");if(n!=null&&(!Number.isInteger(n)||n<0))throw new ze("bodyTimeout must be a positive integer or zero");if(v!=null&&typeof v!="function"&&typeof v!="object")throw new ze("connect must be a function or an object");if(j!=null&&(!Number.isInteger(j)||j<0))throw new ze("maxRequestsPerClient must be a positive number");if(I!=null&&(typeof I!="string"||n8.isIP(I)===0))throw new ze("localAddress must be valid string IP address");if(T!=null&&(!Number.isInteger(T)||T<-1))throw new ze("maxResponseSize must be a positive number");if(O!=null&&(!Number.isInteger(O)||O<-1))throw new ze("autoSelectFamilyAttemptTimeout must be a positive number");if(oe!=null&&typeof oe!="boolean")throw new ze("allowH2 must be a valid boolean value");if(S!=null&&(typeof S!="number"||S<1))throw new ze("maxConcurrentStreams must be a positive integer, greater than 0");if(ae!=null&&typeof ae!="boolean")throw new ze("useH2c must be a valid boolean value");if(ye!=null&&(!Number.isInteger(ye)||ye<1))throw new ze("initialWindowSize must be a positive integer, greater than 0");if(po!=null&&(!Number.isInteger(po)||po<1))throw new ze("connectionWindowSize must be a positive integer, greater than 0");if(Ve!=null&&(typeof Ve!="number"||!Number.isInteger(Ve)||Ve<0))throw new ze("pingInterval must be a positive integer, greater or equal to 0");if(super({webSocket:ya}),typeof v!="function")v=bZ({...A,maxCachedSessions:x,allowH2:oe,useH2c:ae,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[zZ]=t,this[i8]=l??4e3,this[qZ]=d??6e5,this[EZ]=g??2e3,this[xZ]=this[i8],this[Ei]=null,this[fm]=I??null,this[Qr]=0,this[qi]=0,this[wZ]=`host: ${this[ia].hostname}${this[ia].port?`:${this[ia].port}`:""}\r
|
|
1327
|
-
`,this[CZ]=n??3e5,this[IZ]=a??3e5,this[jZ]=k??!0,this[pk]=j,this[zi]=null,this[TZ]=T>-1?T:-1,this[Ne]=null,this[NZ]=S??100,this[UZ]=ye??262144,this[OZ]=po??524288,this[MZ]=Ve??6e4,this[_t]=[],this[_a]=0,this[Lt]=0,this[Ma]=it=>fk(this,it),this[RZ]=it=>m8(this,it)}get pipelining(){return this[Cd]}set pipelining(e){this[Cd]=e,this[Ma](!0)}get stats(){return new dZ(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[AZ](){return!!this[Ne]&&!this[Xs]&&!this[Ne].destroyed}get[gk](){return!!(this[Ne]?.busy(null)||this[pm]>=(c8(this)||1)||this[ym]>0)}[kZ](e){l8(this),this.once("connect",e)}[DZ](e,t){let a=new gZ(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}[QZ](){return new Promise(e=>{this[pm]?this[zi]=e:e(null)})}[SZ](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 fZ),o[Ma]();return}Oa(s);try{o[Ne]=s.alpnProtocol==="h2"?LZ(o,s):_Z(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[BZ]=0,s[pk]=o[pk],s[yZ]=o,s[vZ]=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,PZ(o,e),o[Qr]=0,o[_a]>256&&(o[_t].splice(0,o[_a]),o[Lt]-=o[_a],o[_a]=0))}function PZ(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 hZ("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((Pge,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((Hge,w8)=>{"use strict";var{PoolStats:HZ}=iy(),GZ=Ar(),YZ=bk(),{kConnected:yk,kSize:g8,kRunning:p8,kPending:h8,kQueued:km,kBusy:VZ,kFree:$Z,kUrl:WZ,kClose:JZ,kDestroy:KZ,kDispatch:ZZ}=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 GZ{[Am]=new YZ;[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[VZ](){return this[Ao]}get[yk](){let e=0;for(let{[yk]:t}of this[Ze])e+=t;return e}get[$Z](){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 HZ(this)}[JZ](){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})}[KZ](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)}[ZZ](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[WZ],[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((Gge,q8)=>{"use strict";var{PoolBase:XZ,kClients:Qd,kNeedDrain:eX,kAddClient:oX,kGetDispatcher:tX,kRemoveClient:aX}=Bd(),iX=Ii(),{InvalidArgumentError:xk}=$(),v8=K(),{kUrl:x8}=de(),rX=wr(),Sd=Symbol("options"),zk=Symbol("connections"),z8=Symbol("factory");function sX(o,e){return new iX(o,e)}var qk=class extends XZ{constructor(e,{connections:t,factory:a=sX,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=rX({...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)}})}[tX](){let e=this[Sd].clientTtl;for(let t of this[Qd])if(e!=null&&e>0&&t.ttl&&Date.now()-t.ttl>e)this[aX](t);else if(!t[eX])return t;if(!this[zk]||this[Qd].length<this[zk]){let t=this[z8](this[x8],this[Sd]);return this[oX](t),t}}};q8.exports=qk});var j8=y((Yge,C8)=>{"use strict";var{BalancedPoolMissingUpstreamError:nX,InvalidArgumentError:cX}=$(),{PoolBase:mX,kClients:ao,kNeedDrain:wm,kAddClient:lX,kRemoveClient:uX,kGetDispatcher:dX}=Bd(),gX=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 pX(o,e){if(o===0)return e;for(;e!==0;){let t=e;e=o%e,o=t}return o}function hX(o,e){return new gX(o,e)}var Ek=class extends mX{constructor(e=[],{factory:t=hX,...a}={}){if(typeof t!="function")throw new cX("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[lX](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=pX(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[uX](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)}[dX](){if(this[ao].length===0)throw new nX;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((Vge,S8)=>{"use strict";var{PoolBase:fX,kClients:Ud,kNeedDrain:bX,kAddClient:B8,kGetDispatcher:yX,kRemoveClient:kX}=Bd(),AX=Ii(),{InvalidArgumentError:Ik}=$(),Q8=K(),{kUrl:Ck}=de(),wX=wr(),xm=Symbol("options"),jk=Symbol("connections"),Bk=Symbol("factory"),Od=Symbol("index");function vX(o,e){return new AX(o,e)}var Qk=class extends fX{constructor(e,{connections:t,factory:a=vX,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=wX({...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)}})}[yX](){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[kX](i),a++;continue}if(!i[bX])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(($ge,_8)=>{"use strict";var{InvalidArgumentError:Md,MaxOriginsReachedError:xX}=$(),{kClients:xt,kRunning:T8,kClose:zX,kDestroy:qX,kDispatch:EX,kUrl:IX}=de(),CX=Ar(),jX=Sr(),BX=Ii(),QX=K(),R8=Symbol("onConnect"),N8=Symbol("onDisconnect"),U8=Symbol("onConnectionError"),O8=Symbol("onDrain"),M8=Symbol("factory"),Sk=Symbol("options"),zm=Symbol("origins");function SX(o,e){return e&&e.connections===1?new BX(o,e):new jX(o,e)}var Dk=class extends CX{constructor({factory:e=SX,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]={...QX.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}[EX](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 xX;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)}[zX](){let e=[];for(let{dispatcher:t}of this[xt].values())e.push(t.close());return this[xt].clear(),Promise.all(e)}[qX](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[IX].origin]=t.stats);return e}};_8.exports=Dk});var P8=y((Wge,F8)=>{"use strict";var{Buffer:ji}=require("buffer"),Tk=require("net"),{InvalidArgumentError:Ci}=$();function DX(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 TX(o,e,t){let a=ji.allocUnsafe(2);return a.writeUInt16BE(t,0),ji.concat([ji.from([o]),e,a])}function RX(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 NX(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:DX,parseIPv6:L8,buildAddressBuffer:TX,parseResponseAddress:RX,createReplyError:NX}});var V8=y((Jge,Y8)=>{"use strict";var{EventEmitter:UX}=require("events"),{Buffer:Nr}=require("buffer"),{InvalidArgumentError:en,Socks5ProxyError:Bi}=$(),{debuglog:OX}=require("util"),{parseAddress:MX}=P8(),La=OX("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 UX{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}=MX(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((Kge,oB)=>{"use strict";var{URL:$8}=require("url"),Nk,_X=Ar(),{InvalidArgumentError:W8}=$(),{Socks5Client:LX,STATES:FX}=V8(),{kDispatch:J8,kClose:PX,kDestroy:HX}=de(),GX=Sr(),YX=wr(),{debuglog:VX}=require("util"),Qi=VX("undici:socks5-proxy"),Uk=Symbol("proxy url"),$X=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 _X{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[$X]=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||YX({...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 LX(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===FX.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 GX(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[PX](){let e=[];for(let t of this[Or].values())e.push(t.close());this[Or].clear(),await Promise.all(e)}async[HX](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((Zge,gB)=>{"use strict";var{kProxy:tn,kClose:cB,kDestroy:mB,kDispatch:tB}=de(),WX=Rr(),lB=Sr(),uB=Ar(),{InvalidArgumentError:Mr,RequestAbortedError:JX,SecureProxyConnectionError:KX}=$(),aB=wr(),dB=Ii(),{channels:iB}=yi(),ZX=_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 XX(o){return o==="https:"?443:80}function eee(o,e){return new lB(o,e)}var oee=()=>{};function tee(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=eee}=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||tee,p=(b,A)=>{let{protocol:k}=new URL(b);return this[tn].protocol==="socks5:"||this[tn].protocol==="socks:"?new ZX(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 WX({...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+=`:${XX(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",oee).destroy(),A(new JX(`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 KX(x)):A(x)}}})}dispatch(e,t){let a=aee(e.headers);if(iee(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 aee(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 iee(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((Xge,bB)=>{"use strict";var ree=Ar(),{kClose:see,kDestroy:nee,kClosed:pB,kDestroyed:hB,kDispatch:cee,kNoProxyAgent:qm,kHttpProxyAgent:Di,kHttpsProxyAgent:_r}=de(),fB=Hk(),mee=Rr(),lee={"http:":80,"https:":443},Gk=class extends ree{#e=null;#o=null;#a=null;constructor(e={}){super(),this.#a=e;let{httpProxy:t,httpsProxy:a,noProxy:i,...r}=e;this[qm]=new mee(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()}[cee](e,t){let a=new URL(e.origin);return this.#i(a).dispatch(e,t)}[see](){return Promise.all([this[qm].close(),!this[Di][pB]&&this[Di].close(),!this[_r][pB]&&this[_r].close()])}[nee](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)||lee[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((epe,xB)=>{"use strict";var an=require("assert"),{kRetryHandlerDefaultRetry:kB}=de(),{RequestRetryError:rn}=$(),uee=Jc(),{isDisturbed:AB,parseRangeHeader:wB,wrapRequestBody:dee}=K();function gee(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=uee.wrap(a),this.opts={...r,body:dee(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)?gee(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((ope,zB)=>{"use strict";var pee=Kc(),hee=Fd(),Vk=class extends pee{#e=null;#o=null;constructor(e,t={}){super(t),this.#e=e,this.#o=t}dispatch(e,t){let a=new hee({...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((tpe,IB)=>{"use strict";var{InvalidArgumentError:EB}=$(),fee=Ii(),$k=class extends fee{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((ape,NB)=>{"use strict";var SB=require("assert"),{Readable:bee}=require("stream"),{RequestAbortedError:DB,NotSupportedError:yee,InvalidArgumentError:kee,AbortError:Pd}=$(),TB=K(),{ReadableStreamFrom:Aee}=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"),wee=()=>{},Kk=class extends bee{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 yee}get bodyUsed(){return TB.isDisturbed(this)}get body(){return this[Lr]||(this[Lr]=Aee(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 kee("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",wee).on("data",()=>{this[Gd]>a&&this.destroy()}).resume()})}setEncoding(e){return Buffer.isEncoding(e)&&(this._readableState.encoding=e),this}};function vee(o){return o[Lr]?.locked===!0||o[Ko]!==null}function xee(o){return TB.isDisturbed(o)||vee(o)}function Em(o,e){return SB(!o[Ko]),new Promise((t,a)=>{if(xee(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)}),zee(o[Ko])})})}function zee(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((ipe,oA)=>{"use strict";var qee=require("assert"),{AsyncResource:Eee}=require("async_hooks"),{Readable:Iee}=UB(),{InvalidArgumentError:sn,RequestAbortedError:OB}=$(),zt=K();function Im(){}var Yd=class extends Eee{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}qee(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 Iee({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((rpe,PB)=>{"use strict";var{addAbortListener:Cee}=K(),{RequestAbortedError:jee}=$(),nn=Symbol("kListener"),sa=Symbol("kSignal");function LB(o){o.abort?o.abort(o[sa]?.reason):o.reason=o[sa]?.reason??new jee,FB(o)}function Bee(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)},Cee(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:Bee,removeSignal:FB}});var VB=y((spe,YB)=>{"use strict";var Qee=require("assert"),{finished:See}=require("stream"),{AsyncResource:Dee}=require("async_hooks"),{InvalidArgumentError:cn,InvalidReturnValueError:Tee}=$(),Pa=K(),{addSignal:Ree,removeSignal:HB}=Cm();function Nee(){}var tA=class extends Dee{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",Nee),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)}),Ree(this,i)}onConnect(e,t){if(this.reason){e(this.reason);return}Qee(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 Tee("expected Writable");return See(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((npe,JB)=>{"use strict";var{Readable:WB,Duplex:Uee,PassThrough:Oee}=require("stream"),Mee=require("assert"),{AsyncResource:_ee}=require("async_hooks"),{InvalidArgumentError:jm,InvalidReturnValueError:Lee,RequestAbortedError:aA}=$(),na=K(),{addSignal:Fee,removeSignal:Pee}=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 _ee{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 Uee({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),Pee(this),m(c)}}).on("prefinish",()=>{let{req:c}=this;c.push(null)}),this.res=null,Fee(this,a)}onConnect(e,t){let{res:a}=this;if(this.reason){e(this.reason);return}Mee(!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 Lee("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 Hee(o,e){try{let t=new sA(o,e);return this.dispatch({...o,body:t.req},t),t.ret}catch(t){return new Oee().destroy(t)}}JB.exports=Hee});var aQ=y((cpe,tQ)=>{"use strict";var{InvalidArgumentError:nA,SocketError:Gee}=$(),{AsyncResource:Yee}=require("async_hooks"),ZB=require("assert"),XB=K(),{kHTTP2Stream:Vee}=de(),{addSignal:$ee,removeSignal:eQ}=Cm(),cA=class extends Yee{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,$ee(this,a)}onConnect(e,t){if(this.reason){e(this.reason);return}ZB(this.callback),this.abort=e,this.context=null}onHeaders(){throw new Gee("bad upgrade",null)}onUpgrade(e,t,a){ZB(a[Vee]===!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((mpe,nQ)=>{"use strict";var Wee=require("assert"),{AsyncResource:Jee}=require("async_hooks"),{InvalidArgumentError:mA,SocketError:Kee}=$(),iQ=K(),{addSignal:Zee,removeSignal:rQ}=Cm(),lA=class extends Jee{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,Zee(this,a)}onConnect(e,t){if(this.reason){e(this.reason);return}Wee(this.callback),this.abort=e,this.context=t}onHeaders(){throw new Kee("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((lpe,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((upe,uQ)=>{"use strict";var{UndiciError:Xee}=$(),lQ=Symbol.for("undici.error.UND_MOCK_ERR_MOCK_NOT_MATCHED"),uA=class extends Xee{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((dpe,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((gpe,xQ)=>{"use strict";var{MockNotMatchedError:un}=dA(),{kDispatches:Pr,kMockAgent:eoe,kOriginalDispatch:ooe,kOrigin:toe,kGetNetConnect:aoe,kTotalDispatchCount:hA}=Fr(),{serializePathWithQuery:ioe}=K(),{STATUS_CODES:roe}=require("http"),{types:{isPromise:soe}}=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 noe(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 coe(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?ioe(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 moe(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?coe(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 roe[o]||"unknown"}async function loe(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(soe(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 uoe(){let o=this[eoe],e=this[toe],t=this[ooe];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[aoe](),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 doe(o){return typeof o!="string"&&!(o instanceof URL)?o:o instanceof URL?o.origin:o.toLowerCase()}function goe(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:moe,deleteMockDispatch:fA,buildKey:kQ,generateKeyValues:bA,matchValue:ca,getResponse:loe,getStatusText:AQ,mockDispatch:wQ,buildMockDispatch:uoe,checkNetConnect:vQ,buildAndValidateMockOptions:goe,getHeaderByName:hQ,buildHeadersFromArray:yA,normalizeSearchParams:noe,normalizeOrigin:doe}});var qA=y((ppe,zA)=>{"use strict";var{getResponseData:poe,buildKey:hoe,addMockDispatch:kA}=Bm(),{kDispatches:Vd,kDispatchKey:$d,kDefaultHeaders:AA,kDefaultTrailers:wA,kContentLength:vA,kMockDispatch:Wd,kIgnoreTrailingSlash:Jd}=Fr(),{InvalidArgumentError:ma}=$(),{serializePathWithQuery:foe}=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=foe(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]=hoe(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=poe(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((hpe,BQ)=>{"use strict";var{promisify:boe}=require("util"),yoe=Ii(),{buildMockDispatch:koe}=Bm(),{kDispatches:EA,kMockAgent:zQ,kClose:qQ,kOriginalClose:EQ,kOrigin:IQ,kOriginalDispatch:Aoe,kConnected:IA,kIgnoreTrailingSlash:CQ}=Fr(),{MockInterceptor:woe}=qA(),jQ=de(),{InvalidArgumentError:voe}=$(),CA=class extends yoe{constructor(e,t){if(!t||!t.agent||typeof t.agent.dispatch!="function")throw new voe("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[Aoe]=this.dispatch,this[EQ]=this.close.bind(this),this.dispatch=koe.call(this),this.close=this[qQ]}get[jQ.kConnected](){return this[IA]}intercept(e){return new woe(e&&{ignoreTrailingSlash:this[CQ],...e},this[EA])}cleanMocks(){this[EA]=[]}async[qQ](){await boe(this[EQ])(),this[IA]=0,this[zQ][jQ.kClients].delete(this[IQ])}};BQ.exports=CA});var SA=y((fpe,QA)=>{"use strict";var{kMockCallHistoryAddLog:xoe}=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 zoe(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 qoe(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=qoe(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",...zoe(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=[]}[xoe](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((bpe,UQ)=>{"use strict";var{promisify:Eoe}=require("util"),Ioe=Sr(),{buildMockDispatch:Coe}=Bm(),{kDispatches:DA,kMockAgent:QQ,kClose:SQ,kOriginalClose:DQ,kOrigin:TQ,kOriginalDispatch:joe,kConnected:TA,kIgnoreTrailingSlash:RQ}=Fr(),{MockInterceptor:Boe}=qA(),NQ=de(),{InvalidArgumentError:Qoe}=$(),RA=class extends Ioe{constructor(e,t){if(!t||!t.agent||typeof t.agent.dispatch!="function")throw new Qoe("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[joe]=this.dispatch,this[DQ]=this.close.bind(this),this.dispatch=Coe.call(this),this.close=this[SQ]}get[NQ.kConnected](){return this[TA]}intercept(e){return new Boe(e&&{ignoreTrailingSlash:this[RQ],...e},this[DA])}cleanMocks(){this[DA]=[]}async[SQ](){await Eoe(this[DQ])(),this[TA]=0,this[QQ][NQ.kClients].delete(this[TQ])}};UQ.exports=RA});var MQ=y((kpe,OQ)=>{"use strict";var{Transform:Soe}=require("stream"),{Console:Doe}=require("console"),Toe=process.versions.icu?"\u2705":"Y ",Roe=process.versions.icu?"\u274C":"N ";OQ.exports=class{constructor({disableColors:e}={}){this.transform=new Soe({transform(t,a,i){i(null,t)}}),this.logger=new Doe({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?Toe:Roe,Invocations:c,Remaining:s?1/0:n-c}));return this.logger.table(t),this.transform.read().toString()}}});var LA=y((Ape,YQ)=>{"use strict";var{kClients:Hr}=de(),Noe=Rr(),{kAgent:UA,kMockAgentSet:Zd,kMockAgentGet:_Q,kDispatches:OA,kIsMockActive:Xd,kNetConnect:Gr,kGetNetConnect:Uoe,kOptions:eg,kFactory:og,kMockAgentRegisterCallHistory:MA,kMockAgentIsCallHistoryEnabled:Qm,kMockAgentAddCallHistoryLog:LQ,kMockAgentMockCallHistoryInstance:gn,kMockAgentAcceptsNonStandardSearchParameters:FQ,kMockCallHistoryAddLog:Ooe,kIgnoreTrailingSlash:PQ}=Fr(),Moe=jA(),_oe=NA(),{matchValue:Loe,normalizeSearchParams:Foe,buildAndValidateMockOptions:Poe,normalizeOrigin:HQ}=Bm(),{InvalidArgumentError:GQ,UndiciError:Hoe}=$(),Goe=Kc(),Yoe=MQ(),{MockCallHistory:Voe}=SA(),_A=class extends Goe{constructor(e={}){super(e);let t=Poe(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 Noe(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=Foe(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 Voe)}[LQ](e){this[Qm]&&(this[MA](),this[gn][Ooe](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 Moe(e,t):new _oe(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"&&Loe(a,e)){let r=this[og](e);return this[Zd](e,r),r[OA]=i.dispatcher[OA],r}}[Uoe](){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 Yoe}={}){let t=this.pendingInterceptors();if(t.length!==0)throw new Hoe(t.length===1?`1 interceptor is pending:
|
|
1327
|
+
`,this[CZ]=n??3e5,this[IZ]=a??3e5,this[jZ]=k??!0,this[pk]=j,this[zi]=null,this[TZ]=T>-1?T:-1,this[Ne]=null,this[NZ]=S??100,this[UZ]=ye??262144,this[OZ]=po??524288,this[MZ]=Ve??6e4,this[_t]=[],this[_a]=0,this[Lt]=0,this[Ma]=it=>fk(this,it),this[RZ]=it=>m8(this,it)}get pipelining(){return this[Cd]}set pipelining(e){this[Cd]=e,this[Ma](!0)}get stats(){return new dZ(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[AZ](){return!!this[Ne]&&!this[Xs]&&!this[Ne].destroyed}get[gk](){return!!(this[Ne]?.busy(null)||this[pm]>=(c8(this)||1)||this[ym]>0)}[kZ](e){l8(this),this.once("connect",e)}[DZ](e,t){let a=new gZ(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}[QZ](){return new Promise(e=>{this[pm]?this[zi]=e:e(null)})}[SZ](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 fZ),o[Ma]();return}Oa(s);try{o[Ne]=s.alpnProtocol==="h2"?LZ(o,s):_Z(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[BZ]=0,s[pk]=o[pk],s[yZ]=o,s[vZ]=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,PZ(o,e),o[Qr]=0,o[_a]>256&&(o[_t].splice(0,o[_a]),o[Lt]-=o[_a],o[_a]=0))}function PZ(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 hZ("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((Pge,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((Hge,w8)=>{"use strict";var{PoolStats:HZ}=iy(),GZ=Ar(),YZ=bk(),{kConnected:yk,kSize:g8,kRunning:p8,kPending:h8,kQueued:km,kBusy:VZ,kFree:$Z,kUrl:WZ,kClose:JZ,kDestroy:KZ,kDispatch:ZZ}=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 GZ{[Am]=new YZ;[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[VZ](){return this[Ao]}get[yk](){let e=0;for(let{[yk]:t}of this[Ze])e+=t;return e}get[$Z](){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 HZ(this)}[JZ](){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})}[KZ](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)}[ZZ](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[WZ],[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((Gge,q8)=>{"use strict";var{PoolBase:XZ,kClients:Qd,kNeedDrain:eX,kAddClient:oX,kGetDispatcher:tX,kRemoveClient:aX}=Bd(),iX=Ii(),{InvalidArgumentError:xk}=$(),v8=K(),{kUrl:x8}=de(),rX=wr(),Sd=Symbol("options"),zk=Symbol("connections"),z8=Symbol("factory");function sX(o,e){return new iX(o,e)}var qk=class extends XZ{constructor(e,{connections:t,factory:a=sX,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=rX({...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)}})}[tX](){let e=this[Sd].clientTtl;for(let t of this[Qd])if(e!=null&&e>0&&t.ttl&&Date.now()-t.ttl>e)this[aX](t);else if(!t[eX])return t;if(!this[zk]||this[Qd].length<this[zk]){let t=this[z8](this[x8],this[Sd]);return this[oX](t),t}}};q8.exports=qk});var j8=y((Yge,C8)=>{"use strict";var{BalancedPoolMissingUpstreamError:nX,InvalidArgumentError:cX}=$(),{PoolBase:mX,kClients:ao,kNeedDrain:wm,kAddClient:lX,kRemoveClient:uX,kGetDispatcher:dX}=Bd(),gX=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 pX(o,e){if(o===0)return e;for(;e!==0;){let t=e;e=o%e,o=t}return o}function hX(o,e){return new gX(o,e)}var Ek=class extends mX{constructor(e=[],{factory:t=hX,...a}={}){if(typeof t!="function")throw new cX("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[lX](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=pX(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[uX](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)}[dX](){if(this[ao].length===0)throw new nX;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((Vge,S8)=>{"use strict";var{PoolBase:fX,kClients:Ud,kNeedDrain:bX,kAddClient:B8,kGetDispatcher:yX,kRemoveClient:kX}=Bd(),AX=Ii(),{InvalidArgumentError:Ik}=$(),Q8=K(),{kUrl:Ck}=de(),wX=wr(),xm=Symbol("options"),jk=Symbol("connections"),Bk=Symbol("factory"),Od=Symbol("index");function vX(o,e){return new AX(o,e)}var Qk=class extends fX{constructor(e,{connections:t,factory:a=vX,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=wX({...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)}})}[yX](){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[kX](i),a++;continue}if(!i[bX])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(($ge,_8)=>{"use strict";var{InvalidArgumentError:Md,MaxOriginsReachedError:xX}=$(),{kClients:xt,kRunning:T8,kClose:zX,kDestroy:qX,kDispatch:EX,kUrl:IX}=de(),CX=Ar(),jX=Sr(),BX=Ii(),QX=K(),R8=Symbol("onConnect"),N8=Symbol("onDisconnect"),U8=Symbol("onConnectionError"),O8=Symbol("onDrain"),M8=Symbol("factory"),Sk=Symbol("options"),zm=Symbol("origins");function SX(o,e){return e&&e.connections===1?new BX(o,e):new jX(o,e)}var Dk=class extends CX{constructor({factory:e=SX,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]={...QX.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}[EX](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 xX;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)}[zX](){let e=[];for(let{dispatcher:t}of this[xt].values())e.push(t.close());return this[xt].clear(),Promise.all(e)}[qX](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[IX].origin]=t.stats);return e}};_8.exports=Dk});var P8=y((Wge,F8)=>{"use strict";var{Buffer:ji}=require("buffer"),Tk=require("net"),{InvalidArgumentError:Ci}=$();function DX(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 TX(o,e,t){let a=ji.allocUnsafe(2);return a.writeUInt16BE(t,0),ji.concat([ji.from([o]),e,a])}function RX(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 NX(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:DX,parseIPv6:L8,buildAddressBuffer:TX,parseResponseAddress:RX,createReplyError:NX}});var V8=y((Jge,Y8)=>{"use strict";var{EventEmitter:UX}=require("events"),{Buffer:Nr}=require("buffer"),{InvalidArgumentError:en,Socks5ProxyError:Bi}=$(),{debuglog:OX}=require("util"),{parseAddress:MX}=P8(),La=OX("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 UX{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}=MX(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((Kge,oB)=>{"use strict";var{URL:$8}=require("url"),Nk,_X=Ar(),{InvalidArgumentError:W8}=$(),{Socks5Client:LX,STATES:FX}=V8(),{kDispatch:J8,kClose:PX,kDestroy:HX}=de(),GX=Sr(),YX=wr(),{debuglog:VX}=require("util"),Qi=VX("undici:socks5-proxy"),Uk=Symbol("proxy url"),$X=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 _X{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[$X]=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||YX({...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 LX(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===FX.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 GX(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[PX](){let e=[];for(let t of this[Or].values())e.push(t.close());this[Or].clear(),await Promise.all(e)}async[HX](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((Zge,gB)=>{"use strict";var{kProxy:tn,kClose:cB,kDestroy:mB,kDispatch:tB}=de(),WX=Rr(),lB=Sr(),uB=Ar(),{InvalidArgumentError:Mr,RequestAbortedError:JX,SecureProxyConnectionError:KX}=$(),aB=wr(),dB=Ii(),{channels:iB}=yi(),ZX=_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 XX(o){return o==="https:"?443:80}function eee(o,e){return new lB(o,e)}var oee=()=>{};function tee(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=eee}=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||tee,p=(b,A)=>{let{protocol:k}=new URL(b);return this[tn].protocol==="socks5:"||this[tn].protocol==="socks:"?new ZX(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 WX({...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+=`:${XX(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",oee).destroy(),A(new JX(`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 KX(x)):A(x)}}})}dispatch(e,t){let a=aee(e.headers);if(iee(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 aee(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 iee(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((Xge,bB)=>{"use strict";var ree=Ar(),{kClose:see,kDestroy:nee,kClosed:pB,kDestroyed:hB,kDispatch:cee,kNoProxyAgent:qm,kHttpProxyAgent:Di,kHttpsProxyAgent:_r}=de(),fB=Hk(),mee=Rr(),lee={"http:":80,"https:":443},Gk=class extends ree{#e=null;#o=null;#a=null;constructor(e={}){super(),this.#a=e;let{httpProxy:t,httpsProxy:a,noProxy:i,...r}=e;this[qm]=new mee(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()}[cee](e,t){let a=new URL(e.origin);return this.#i(a).dispatch(e,t)}[see](){return Promise.all([this[qm].close(),!this[Di][pB]&&this[Di].close(),!this[_r][pB]&&this[_r].close()])}[nee](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)||lee[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((epe,xB)=>{"use strict";var an=require("assert"),{kRetryHandlerDefaultRetry:kB}=de(),{RequestRetryError:rn}=$(),uee=Jc(),{isDisturbed:AB,parseRangeHeader:wB,wrapRequestBody:dee}=K();function gee(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=uee.wrap(a),this.opts={...r,body:dee(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)?gee(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((ope,zB)=>{"use strict";var pee=Kc(),hee=Fd(),Vk=class extends pee{#e=null;#o=null;constructor(e,t={}){super(t),this.#e=e,this.#o=t}dispatch(e,t){let a=new hee({...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((tpe,IB)=>{"use strict";var{InvalidArgumentError:EB}=$(),fee=Ii(),$k=class extends fee{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((ape,NB)=>{"use strict";var SB=require("assert"),{Readable:bee}=require("stream"),{RequestAbortedError:DB,NotSupportedError:yee,InvalidArgumentError:kee,AbortError:Pd}=$(),TB=K(),{ReadableStreamFrom:Aee}=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"),wee=()=>{},Kk=class extends bee{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 yee}get bodyUsed(){return TB.isDisturbed(this)}get body(){return this[Lr]||(this[Lr]=Aee(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 kee("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",wee).on("data",()=>{this[Gd]>a&&this.destroy()}).resume()})}setEncoding(e){return Buffer.isEncoding(e)&&(this._readableState.encoding=e),this}};function vee(o){return o[Lr]?.locked===!0||o[Ko]!==null}function xee(o){return TB.isDisturbed(o)||vee(o)}function Em(o,e){return SB(!o[Ko]),new Promise((t,a)=>{if(xee(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)}),zee(o[Ko])})})}function zee(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((ipe,oA)=>{"use strict";var qee=require("assert"),{AsyncResource:Eee}=require("async_hooks"),{Readable:Iee}=UB(),{InvalidArgumentError:sn,RequestAbortedError:OB}=$(),zt=K();function Im(){}var Yd=class extends Eee{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}qee(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 Iee({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((rpe,PB)=>{"use strict";var{addAbortListener:Cee}=K(),{RequestAbortedError:jee}=$(),nn=Symbol("kListener"),sa=Symbol("kSignal");function LB(o){o.abort?o.abort(o[sa]?.reason):o.reason=o[sa]?.reason??new jee,FB(o)}function Bee(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)},Cee(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:Bee,removeSignal:FB}});var VB=y((spe,YB)=>{"use strict";var Qee=require("assert"),{finished:See}=require("stream"),{AsyncResource:Dee}=require("async_hooks"),{InvalidArgumentError:cn,InvalidReturnValueError:Tee}=$(),Pa=K(),{addSignal:Ree,removeSignal:HB}=Cm();function Nee(){}var tA=class extends Dee{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",Nee),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)}),Ree(this,i)}onConnect(e,t){if(this.reason){e(this.reason);return}Qee(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 Tee("expected Writable");return See(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((npe,JB)=>{"use strict";var{Readable:WB,Duplex:Uee,PassThrough:Oee}=require("stream"),Mee=require("assert"),{AsyncResource:_ee}=require("async_hooks"),{InvalidArgumentError:jm,InvalidReturnValueError:Lee,RequestAbortedError:aA}=$(),na=K(),{addSignal:Fee,removeSignal:Pee}=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 _ee{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 Uee({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),Pee(this),m(c)}}).on("prefinish",()=>{let{req:c}=this;c.push(null)}),this.res=null,Fee(this,a)}onConnect(e,t){let{res:a}=this;if(this.reason){e(this.reason);return}Mee(!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 Lee("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 Hee(o,e){try{let t=new sA(o,e);return this.dispatch({...o,body:t.req},t),t.ret}catch(t){return new Oee().destroy(t)}}JB.exports=Hee});var a4=y((cpe,t4)=>{"use strict";var{InvalidArgumentError:nA,SocketError:Gee}=$(),{AsyncResource:Yee}=require("async_hooks"),ZB=require("assert"),XB=K(),{kHTTP2Stream:Vee}=de(),{addSignal:$ee,removeSignal:e4}=Cm(),cA=class extends Yee{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,$ee(this,a)}onConnect(e,t){if(this.reason){e(this.reason);return}ZB(this.callback),this.abort=e,this.context=null}onHeaders(){throw new Gee("bad upgrade",null)}onUpgrade(e,t,a){ZB(a[Vee]===!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((mpe,n4)=>{"use strict";var Wee=require("assert"),{AsyncResource:Jee}=require("async_hooks"),{InvalidArgumentError:mA,SocketError:Kee}=$(),i4=K(),{addSignal:Zee,removeSignal:r4}=Cm(),lA=class extends Jee{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,Zee(this,a)}onConnect(e,t){if(this.reason){e(this.reason);return}Wee(this.callback),this.abort=e,this.context=t}onHeaders(){throw new Kee("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((lpe,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((upe,u4)=>{"use strict";var{UndiciError:Xee}=$(),l4=Symbol.for("undici.error.UND_MOCK_ERR_MOCK_NOT_MATCHED"),uA=class extends Xee{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((dpe,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((gpe,x4)=>{"use strict";var{MockNotMatchedError:un}=dA(),{kDispatches:Pr,kMockAgent:eoe,kOriginalDispatch:ooe,kOrigin:toe,kGetNetConnect:aoe,kTotalDispatchCount:hA}=Fr(),{serializePathWithQuery:ioe}=K(),{STATUS_CODES:roe}=require("http"),{types:{isPromise:soe}}=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 noe(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 coe(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?ioe(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 moe(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?coe(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 roe[o]||"unknown"}async function loe(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(soe(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 uoe(){let o=this[eoe],e=this[toe],t=this[ooe];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[aoe](),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 doe(o){return typeof o!="string"&&!(o instanceof URL)?o:o instanceof URL?o.origin:o.toLowerCase()}function goe(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:moe,deleteMockDispatch:fA,buildKey:k4,generateKeyValues:bA,matchValue:ca,getResponse:loe,getStatusText:A4,mockDispatch:w4,buildMockDispatch:uoe,checkNetConnect:v4,buildAndValidateMockOptions:goe,getHeaderByName:h4,buildHeadersFromArray:yA,normalizeSearchParams:noe,normalizeOrigin:doe}});var qA=y((ppe,zA)=>{"use strict";var{getResponseData:poe,buildKey:hoe,addMockDispatch:kA}=Bm(),{kDispatches:Vd,kDispatchKey:$d,kDefaultHeaders:AA,kDefaultTrailers:wA,kContentLength:vA,kMockDispatch:Wd,kIgnoreTrailingSlash:Jd}=Fr(),{InvalidArgumentError:ma}=$(),{serializePathWithQuery:foe}=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=foe(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]=hoe(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=poe(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((hpe,B4)=>{"use strict";var{promisify:boe}=require("util"),yoe=Ii(),{buildMockDispatch:koe}=Bm(),{kDispatches:EA,kMockAgent:z4,kClose:q4,kOriginalClose:E4,kOrigin:I4,kOriginalDispatch:Aoe,kConnected:IA,kIgnoreTrailingSlash:C4}=Fr(),{MockInterceptor:woe}=qA(),j4=de(),{InvalidArgumentError:voe}=$(),CA=class extends yoe{constructor(e,t){if(!t||!t.agent||typeof t.agent.dispatch!="function")throw new voe("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[Aoe]=this.dispatch,this[E4]=this.close.bind(this),this.dispatch=koe.call(this),this.close=this[q4]}get[j4.kConnected](){return this[IA]}intercept(e){return new woe(e&&{ignoreTrailingSlash:this[C4],...e},this[EA])}cleanMocks(){this[EA]=[]}async[q4](){await boe(this[E4])(),this[IA]=0,this[z4][j4.kClients].delete(this[I4])}};B4.exports=CA});var SA=y((fpe,QA)=>{"use strict";var{kMockCallHistoryAddLog:xoe}=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 zoe(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 qoe(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=qoe(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",...zoe(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=[]}[xoe](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((bpe,U4)=>{"use strict";var{promisify:Eoe}=require("util"),Ioe=Sr(),{buildMockDispatch:Coe}=Bm(),{kDispatches:DA,kMockAgent:Q4,kClose:S4,kOriginalClose:D4,kOrigin:T4,kOriginalDispatch:joe,kConnected:TA,kIgnoreTrailingSlash:R4}=Fr(),{MockInterceptor:Boe}=qA(),N4=de(),{InvalidArgumentError:Qoe}=$(),RA=class extends Ioe{constructor(e,t){if(!t||!t.agent||typeof t.agent.dispatch!="function")throw new Qoe("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[joe]=this.dispatch,this[D4]=this.close.bind(this),this.dispatch=Coe.call(this),this.close=this[S4]}get[N4.kConnected](){return this[TA]}intercept(e){return new Boe(e&&{ignoreTrailingSlash:this[R4],...e},this[DA])}cleanMocks(){this[DA]=[]}async[S4](){await Eoe(this[D4])(),this[TA]=0,this[Q4][N4.kClients].delete(this[T4])}};U4.exports=RA});var M4=y((kpe,O4)=>{"use strict";var{Transform:Soe}=require("stream"),{Console:Doe}=require("console"),Toe=process.versions.icu?"\u2705":"Y ",Roe=process.versions.icu?"\u274C":"N ";O4.exports=class{constructor({disableColors:e}={}){this.transform=new Soe({transform(t,a,i){i(null,t)}}),this.logger=new Doe({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?Toe:Roe,Invocations:c,Remaining:s?1/0:n-c}));return this.logger.table(t),this.transform.read().toString()}}});var LA=y((Ape,Y4)=>{"use strict";var{kClients:Hr}=de(),Noe=Rr(),{kAgent:UA,kMockAgentSet:Zd,kMockAgentGet:_4,kDispatches:OA,kIsMockActive:Xd,kNetConnect:Gr,kGetNetConnect:Uoe,kOptions:eg,kFactory:og,kMockAgentRegisterCallHistory:MA,kMockAgentIsCallHistoryEnabled:Qm,kMockAgentAddCallHistoryLog:L4,kMockAgentMockCallHistoryInstance:gn,kMockAgentAcceptsNonStandardSearchParameters:F4,kMockCallHistoryAddLog:Ooe,kIgnoreTrailingSlash:P4}=Fr(),Moe=jA(),_oe=NA(),{matchValue:Loe,normalizeSearchParams:Foe,buildAndValidateMockOptions:Poe,normalizeOrigin:H4}=Bm(),{InvalidArgumentError:G4,UndiciError:Hoe}=$(),Goe=Kc(),Yoe=M4(),{MockCallHistory:Voe}=SA(),_A=class extends Goe{constructor(e={}){super(e);let t=Poe(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 Noe(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=Foe(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 Voe)}[L4](e){this[Qm]&&(this[MA](),this[gn][Ooe](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 Moe(e,t):new _oe(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"&&Loe(a,e)){let r=this[og](e);return this[Zd](e,r),r[OA]=i.dispatcher[OA],r}}[Uoe](){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 Yoe}={}){let t=this.pendingInterceptors();if(t.length!==0)throw new Hoe(t.length===1?`1 interceptor is pending:
|
|
1328
1328
|
|
|
1329
1329
|
${e.format(t)}`.trim():`${t.length} interceptors are pending:
|
|
1330
1330
|
|
|
1331
|
-
${e.format(t)}`.trim())}};YQ.exports=_A});var FA=y((wpe,JQ)=>{"use strict";var{InvalidArgumentError:$oe}=$(),{runtimeFeatures:Woe}=Ta();function Joe(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=Woe.has("crypto")?require("crypto"):null,Koe=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 Zoe(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 Xoe(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 ete(o){if(!$Q.includes(o))throw new $oe(`Invalid snapshot mode: ${o}. Must be one of: ${$Q.join(", ")}`)}JQ.exports={createHeaderFilters:Joe,hashId:Koe,isUndiciHeaders:WQ,normalizeHeaders:Xoe,isUrlExcludedFactory:Zoe,validateSnapshotMode:ete}});var r4=y((vpe,i4)=>{"use strict";var{writeFile:ote,readFile:tte,mkdir:ate}=require("fs/promises"),{dirname:ite,resolve:KQ}=require("path"),{setTimeout:rte,clearTimeout:ZQ}=require("timers"),{InvalidArgumentError:XQ,UndiciError:ste}=$(),{hashId:nte,isUrlExcludedFactory:cte,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 nte(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=cte(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 tte(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 ste(`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 ate(ite(a),{recursive:!0});let i=Array.from(this.#a.entries()).map(([r,s])=>({hash:r,snapshot:s}));await ote(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=rte(()=>{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((xpe,n4)=>{"use strict";var mte=Rr(),lte=LA(),{SnapshotRecorder:ute}=r4(),dte=Jc(),{InvalidArgumentError:gte,UndiciError:pte}=$(),{validateSnapshotMode:hte}=FA(),Bo=Symbol("kSnapshotRecorder"),la=Symbol("kSnapshotMode"),Tm=Symbol("kSnapshotPath"),HA=Symbol("kSnapshotLoaded"),tg=Symbol("kRealAgent"),s4=!1,GA=class extends lte{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),hte(t),(t==="playback"||t==="update")&&!a)throw new gte(`snapshotPath is required when mode is '${t}'`);this[la]=t,this[Tm]=a,this[Bo]=new ute({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 mte(e)),(this[la]==="playback"||this[la]==="update")&&this[Tm]&&this.loadSnapshots().catch(()=>{})}dispatch(e,t){t=dte.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 pte(`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((zpe,d4)=>{"use strict";var fte=Symbol.for("undici.globalDispatcher.2"),m4=Symbol.for("undici.globalDispatcher.1"),{InvalidArgumentError:bte}=$(),yte=Rr();u4()===void 0&&l4(new yte);function l4(o){if(!o||typeof o.dispatch!="function")throw new bte("Argument agent must implement Agent");Object.defineProperty(globalThis,fte,{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 kte=["fetch","Headers","Response","Request","FormData","WebSocket","CloseEvent","ErrorEvent","MessageEvent","EventSource"];d4.exports={setGlobalDispatcher:l4,getGlobalDispatcher:u4,installedExports:kte}});var pn=y((Epe,g4)=>{"use strict";var Ha=require("assert"),Ate=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=Ate.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((Ipe,b4)=>{"use strict";var Qo=K(),{kBodyUsed:Rm}=de(),$A=require("assert"),{InvalidArgumentError:YA}=$(),wte=require("events"),vte=[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,wte.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)||vte.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=xte(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 xte(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((Cpe,y4)=>{"use strict";var zte=WA();function qte({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 zte(e,r,n,i);return e(n,c)}}y4.exports=qte});var w4=y((jpe,A4)=>{"use strict";var Ete=pn(),{ResponseError:Ite}=$(),JA=class extends Ete{#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 Ite("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((Bpe,v4)=>{"use strict";var Cte=Fd();v4.exports=o=>e=>function(a,i){return e(a,new Cte({...a,retryOptions:{...o,...a.retryOptions}},{handler:i,dispatch:e}))}});var q4=y((Qpe,z4)=>{"use strict";var{InvalidArgumentError:jte,RequestAbortedError:Bte}=$(),Qte=pn(),KA=class extends Qte{#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 jte("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 Bte(`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 Ste({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=Ste});var j4=y((Spe,C4)=>{"use strict";var{isIP:Dte}=require("net"),{lookup:Tte}=require("dns"),Rte=pn(),{InvalidArgumentError:Yr,InformationalError:Nte}=$(),ZA=Math.pow(2,31)-1;function Ute(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 Ote(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"&&Ute(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 Mte(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=Ote(e);return Mte(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 Nte("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){Tte(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 Rte{#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 Dte(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((Dpe,_4)=>{"use strict";var{safeHTTPMethods:B4,pathHasQueryOrFragment:_te,hasSafeIterator:Lte,isValidHTTPToken:Nm}=K(),{serializePathWithQuery:Fte}=K(),Pte=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 Hte(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 Gte(o,e){return o[tw]?.has(e)===!0}function Yte(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 Vte(o){if(!o.origin)throw new Error("opts.origin is undefined");let e=o.path||"/";return o.query&&!_te(e)&&(e=Fte(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 $te(o){let e;if(o.headers==null)e={};else if(typeof o.headers=="object")if(e={},Lte(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 Wte(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 Jte(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 Kte(o){let e={},t=new Set,a=new Set,i=Hte(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=Yte(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),Pte);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 Zte(o){return aw(o)||M4(o,{})===void 0}function Xte(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 eae(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 oae(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 tae(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:Vte,normalizeHeaders:$te,assertCacheKey:Wte,assertCacheValue:Jte,parseCacheControlHeader:Kte,hasInvalidCacheControlDirective:Gte,parseVaryHeader:M4,hasVaryStar:aw,isInvalidOrWildcardVaryHeader:Zte,isEtagUsable:Xte,assertCacheMethods:oae,assertCacheStore:eae,makeDeduplicationKey:tae}});var rw=y((Tpe,L4)=>{"use strict";function aae(o){switch(o[3]){case",":return iae(o);case" ":return rae(o);default:return sae(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 iae(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 rae(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 sae(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:aae}});var $4=y((Rpe,V4)=>{"use strict";var sw=K(),{parseCacheControlHeader:nae,hasInvalidCacheControlDirective:F4,parseVaryHeader:cae,hasVaryStar:mae,isInvalidOrWildcardVaryHeader:H4,isEtagUsable:lae}=hn(),{parseHttpDate:nw}=rw();function uae(){}var G4=[200,203,204,206,300,301,308,404,405,410,414,501],dae=[206],Um=2147483647e3;function gae(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 pae(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(gae(i[r]).toLowerCase())}}function hae(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=hae(e,a[i]);r!==void 0&&Y4(o,e,r)}}function fae(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 fae(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?nae(n):{};if(!yae(this.#o,t,a,m,this.#e.headers))return t===304&&(n||bae(this.#o,a,m))&&Om(this.#i,this.#e),r();let l=Date.now(),u=Object.hasOwn(a,"age")?Aae(a.age):void 0;if(u!==void 0&&u>=Um)return rg(t,this.#i,this.#e),r();let d=Object.hasOwn(a,"date")?kae(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=wae(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=cae(a.vary,this.#e.headers),!x))return r();let v=A,j=vae(A,l,m,k),I=xae(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(),ae=()=>{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",()=>{ae()}).on("close",function(){s.#t===this&&(s.#t=void 0)}),ae()}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"&&lae(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?.(uae)}catch{}}function rg(o,e,t){o===304&&Om(e,t)}function bae(o,e,t){return t["no-store"]===!0||o==="shared"&&t.private===!0||(e.vary?H4(e.vary):!1)}function yae(o,e,t,a,i){return!(e<200||fn(dae,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&&mae(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 kae(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 Aae(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 wae(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 vae(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 xae(o,e){let t=["connection","proxy-authenticate","proxy-authentication-info","proxy-authorization","proxy-connection","te","transfer-encoding","upgrade","age"];o.connection&&pae(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((Npe,K4)=>{"use strict";var{Writable:zae}=require("stream"),{EventEmitter:qae}=require("events"),{assertCacheKey:W4,assertCacheValue:Eae}=hn(),mw=class extends qae{#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),Eae(t);let a=`${e.origin}:${e.path}`,i=this,r={...e,...t,body:[],size:0};return new zae({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&&Iae(o,i))return i}}function Iae(o,e){if(e.vary==null)return!0;for(let t in e.vary)if(Object.hasOwn(e.vary,t)&&!Cae(o.headers?.[t],e.vary[t]))return!1;return!0}function Cae(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((Upe,Z4)=>{"use strict";var jae=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(jae(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((Ope,s3)=>{"use strict";var e3=require("assert"),{Readable:Bae}=require("stream"),Ui=K(),bn=$4(),Qae=lw(),Sae=X4(),{assertCacheStore:Dae,assertCacheMethods:Tae,makeCacheKey:Rae,normalizeHeaders:Nae,parseCacheControlHeader:r3,isInvalidOrWildcardVaryHeader:Uae}=hn(),{AbortError:Oae}=$(),{parseHttpDate:Mae}=rw();function _ae(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 Lae(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 Fae(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(Lae(r[s]).toLowerCase()==="no-cache")return!0}return!1}function Pae(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 Hae(o,e){if(e.vary&&Uae(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 Gae(o){return o["cache-control"]!==void 0}function t3(o,e){try{o.delete(e)?.catch?.(Mm)}catch{}}function Yae(o){let e=o?.["last-modified"];if(typeof e=="string"&&Mae(e))return e}function a3(o,e){let t={...o.headers,"if-modified-since":Yae(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 Vae(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 $ae(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 Wae(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:Bae.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 Oae)}};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 Wae(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||Vae(s,r,e.type),u=m||Pae(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&&$ae(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 Sae((p,b,A,k)=>{if(p){if(A===304){if(Hae(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));Gae(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 Qae,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(Dae(e,"opts.store"),Tae(t,"opts.methods"),_ae(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:Nae(m)};let u=m.headers?.["cache-control"]?r3(m.headers["cache-control"]):Fae(m.headers)?{"no-cache":!0}:void 0;if(u?.["no-store"])return c(m,l);let d=Rae(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((Mpe,u3)=>{"use strict";var{createInflate:pw,createGunzip:c3,createBrotliDecompress:Jae,createZstdDecompress:Kae}=require("zlib"),{pipeline:Zae}=require("stream"),Xae=pn(),{runtimeFeatures:eie}=Ta(),m3={gzip:c3,"x-gzip":c3,br:Jae,deflate:pw,compress:pw,"x-compress":pw,...eie.has("zstd")?{zstd:Kae}:{}},oie=[204,304],l3=!1,hw=class extends Xae{#e=[];#o;#a;constructor(e,{skipStatusCodes:t=oie,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),Zae(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 tie(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=tie});var h3=y((_pe,p3)=>{"use strict";var{RequestAbortedError:aie}=$(),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 aie(`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((Lpe,f3)=>{"use strict";var iie=require("diagnostics_channel"),rie=K(),sie=h3(),{normalizeHeaders:nie,makeCacheKey:cie,makeDeduplicationKey:mie}=hn(),sg=iie.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(!rie.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:nie(m)},r.size>0){for(let b of Object.keys(m.headers))if(r.has(b.toLowerCase()))return c(m,l)}let u=cie(m),d=mie(u,s),g=n.get(d);if(g)return g.addWaitingHandler(l)?!0:c(m,l);let p=new sie(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((Ppe,k3)=>{"use strict";var{Writable:lie}=require("stream"),{assertCacheKey:bw,assertCacheValue:uie}=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((wpe,J4)=>{"use strict";var{InvalidArgumentError:$oe}=$(),{runtimeFeatures:Woe}=Ta();function Joe(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=Woe.has("crypto")?require("crypto"):null,Koe=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 Zoe(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 Xoe(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 ete(o){if(!$4.includes(o))throw new $oe(`Invalid snapshot mode: ${o}. Must be one of: ${$4.join(", ")}`)}J4.exports={createHeaderFilters:Joe,hashId:Koe,isUndiciHeaders:W4,normalizeHeaders:Xoe,isUrlExcludedFactory:Zoe,validateSnapshotMode:ete}});var rQ=y((vpe,iQ)=>{"use strict";var{writeFile:ote,readFile:tte,mkdir:ate}=require("fs/promises"),{dirname:ite,resolve:K4}=require("path"),{setTimeout:rte,clearTimeout:Z4}=require("timers"),{InvalidArgumentError:X4,UndiciError:ste}=$(),{hashId:nte,isUrlExcludedFactory:cte,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 nte(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=cte(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 tte(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 ste(`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 ate(ite(a),{recursive:!0});let i=Array.from(this.#a.entries()).map(([r,s])=>({hash:r,snapshot:s}));await ote(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=rte(()=>{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((xpe,nQ)=>{"use strict";var mte=Rr(),lte=LA(),{SnapshotRecorder:ute}=rQ(),dte=Jc(),{InvalidArgumentError:gte,UndiciError:pte}=$(),{validateSnapshotMode:hte}=FA(),Bo=Symbol("kSnapshotRecorder"),la=Symbol("kSnapshotMode"),Tm=Symbol("kSnapshotPath"),HA=Symbol("kSnapshotLoaded"),tg=Symbol("kRealAgent"),sQ=!1,GA=class extends lte{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),hte(t),(t==="playback"||t==="update")&&!a)throw new gte(`snapshotPath is required when mode is '${t}'`);this[la]=t,this[Tm]=a,this[Bo]=new ute({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 mte(e)),(this[la]==="playback"||this[la]==="update")&&this[Tm]&&this.loadSnapshots().catch(()=>{})}dispatch(e,t){t=dte.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 pte(`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((zpe,dQ)=>{"use strict";var fte=Symbol.for("undici.globalDispatcher.2"),mQ=Symbol.for("undici.globalDispatcher.1"),{InvalidArgumentError:bte}=$(),yte=Rr();uQ()===void 0&&lQ(new yte);function lQ(o){if(!o||typeof o.dispatch!="function")throw new bte("Argument agent must implement Agent");Object.defineProperty(globalThis,fte,{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 kte=["fetch","Headers","Response","Request","FormData","WebSocket","CloseEvent","ErrorEvent","MessageEvent","EventSource"];dQ.exports={setGlobalDispatcher:lQ,getGlobalDispatcher:uQ,installedExports:kte}});var pn=y((Epe,gQ)=>{"use strict";var Ha=require("assert"),Ate=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=Ate.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((Ipe,bQ)=>{"use strict";var Qo=K(),{kBodyUsed:Rm}=de(),$A=require("assert"),{InvalidArgumentError:YA}=$(),wte=require("events"),vte=[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,wte.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)||vte.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=xte(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 xte(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((Cpe,yQ)=>{"use strict";var zte=WA();function qte({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 zte(e,r,n,i);return e(n,c)}}yQ.exports=qte});var wQ=y((jpe,AQ)=>{"use strict";var Ete=pn(),{ResponseError:Ite}=$(),JA=class extends Ete{#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 Ite("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((Bpe,vQ)=>{"use strict";var Cte=Fd();vQ.exports=o=>e=>function(a,i){return e(a,new Cte({...a,retryOptions:{...o,...a.retryOptions}},{handler:i,dispatch:e}))}});var qQ=y((Qpe,zQ)=>{"use strict";var{InvalidArgumentError:jte,RequestAbortedError:Bte}=$(),Qte=pn(),KA=class extends Qte{#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 jte("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 Bte(`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 Ste({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=Ste});var jQ=y((Spe,CQ)=>{"use strict";var{isIP:Dte}=require("net"),{lookup:Tte}=require("dns"),Rte=pn(),{InvalidArgumentError:Yr,InformationalError:Nte}=$(),ZA=Math.pow(2,31)-1;function Ute(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 Ote(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"&&Ute(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 Mte(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=Ote(e);return Mte(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 Nte("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){Tte(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 Rte{#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 Dte(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((Dpe,_Q)=>{"use strict";var{safeHTTPMethods:BQ,pathHasQueryOrFragment:_te,hasSafeIterator:Lte,isValidHTTPToken:Nm}=K(),{serializePathWithQuery:Fte}=K(),Pte=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 Hte(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 Gte(o,e){return o[tw]?.has(e)===!0}function Yte(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 Vte(o){if(!o.origin)throw new Error("opts.origin is undefined");let e=o.path||"/";return o.query&&!_te(e)&&(e=Fte(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 $te(o){let e;if(o.headers==null)e={};else if(typeof o.headers=="object")if(e={},Lte(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 Wte(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 Jte(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 Kte(o){let e={},t=new Set,a=new Set,i=Hte(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=Yte(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),Pte);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 Zte(o){return aw(o)||MQ(o,{})===void 0}function Xte(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 eae(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 oae(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 tae(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:Vte,normalizeHeaders:$te,assertCacheKey:Wte,assertCacheValue:Jte,parseCacheControlHeader:Kte,hasInvalidCacheControlDirective:Gte,parseVaryHeader:MQ,hasVaryStar:aw,isInvalidOrWildcardVaryHeader:Zte,isEtagUsable:Xte,assertCacheMethods:oae,assertCacheStore:eae,makeDeduplicationKey:tae}});var rw=y((Tpe,LQ)=>{"use strict";function aae(o){switch(o[3]){case",":return iae(o);case" ":return rae(o);default:return sae(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 iae(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 rae(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 sae(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:aae}});var $Q=y((Rpe,VQ)=>{"use strict";var sw=K(),{parseCacheControlHeader:nae,hasInvalidCacheControlDirective:FQ,parseVaryHeader:cae,hasVaryStar:mae,isInvalidOrWildcardVaryHeader:HQ,isEtagUsable:lae}=hn(),{parseHttpDate:nw}=rw();function uae(){}var GQ=[200,203,204,206,300,301,308,404,405,410,414,501],dae=[206],Um=2147483647e3;function gae(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 pae(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(gae(i[r]).toLowerCase())}}function hae(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=hae(e,a[i]);r!==void 0&&YQ(o,e,r)}}function fae(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 fae(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?nae(n):{};if(!yae(this.#o,t,a,m,this.#e.headers))return t===304&&(n||bae(this.#o,a,m))&&Om(this.#i,this.#e),r();let l=Date.now(),u=Object.hasOwn(a,"age")?Aae(a.age):void 0;if(u!==void 0&&u>=Um)return rg(t,this.#i,this.#e),r();let d=Object.hasOwn(a,"date")?kae(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=wae(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=cae(a.vary,this.#e.headers),!x))return r();let v=A,j=vae(A,l,m,k),I=xae(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(),ae=()=>{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",()=>{ae()}).on("close",function(){s.#t===this&&(s.#t=void 0)}),ae()}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"&&lae(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?.(uae)}catch{}}function rg(o,e,t){o===304&&Om(e,t)}function bae(o,e,t){return t["no-store"]===!0||o==="shared"&&t.private===!0||(e.vary?HQ(e.vary):!1)}function yae(o,e,t,a,i){return!(e<200||fn(dae,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&&mae(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 kae(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 Aae(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 wae(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 vae(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 xae(o,e){let t=["connection","proxy-authenticate","proxy-authentication-info","proxy-authorization","proxy-connection","te","transfer-encoding","upgrade","age"];o.connection&&pae(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((Npe,KQ)=>{"use strict";var{Writable:zae}=require("stream"),{EventEmitter:qae}=require("events"),{assertCacheKey:WQ,assertCacheValue:Eae}=hn(),mw=class extends qae{#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),Eae(t);let a=`${e.origin}:${e.path}`,i=this,r={...e,...t,body:[],size:0};return new zae({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&&Iae(o,i))return i}}function Iae(o,e){if(e.vary==null)return!0;for(let t in e.vary)if(Object.hasOwn(e.vary,t)&&!Cae(o.headers?.[t],e.vary[t]))return!1;return!0}function Cae(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((Upe,ZQ)=>{"use strict";var jae=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(jae(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((Ope,s3)=>{"use strict";var e3=require("assert"),{Readable:Bae}=require("stream"),Ui=K(),bn=$Q(),Qae=lw(),Sae=XQ(),{assertCacheStore:Dae,assertCacheMethods:Tae,makeCacheKey:Rae,normalizeHeaders:Nae,parseCacheControlHeader:r3,isInvalidOrWildcardVaryHeader:Uae}=hn(),{AbortError:Oae}=$(),{parseHttpDate:Mae}=rw();function _ae(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 Lae(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 Fae(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(Lae(r[s]).toLowerCase()==="no-cache")return!0}return!1}function Pae(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 Hae(o,e){if(e.vary&&Uae(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 Gae(o){return o["cache-control"]!==void 0}function t3(o,e){try{o.delete(e)?.catch?.(Mm)}catch{}}function Yae(o){let e=o?.["last-modified"];if(typeof e=="string"&&Mae(e))return e}function a3(o,e){let t={...o.headers,"if-modified-since":Yae(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 Vae(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 $ae(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 Wae(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:Bae.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 Oae)}};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 Wae(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||Vae(s,r,e.type),u=m||Pae(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&&$ae(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 Sae((p,b,A,k)=>{if(p){if(A===304){if(Hae(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));Gae(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 Qae,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(Dae(e,"opts.store"),Tae(t,"opts.methods"),_ae(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:Nae(m)};let u=m.headers?.["cache-control"]?r3(m.headers["cache-control"]):Fae(m.headers)?{"no-cache":!0}:void 0;if(u?.["no-store"])return c(m,l);let d=Rae(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((Mpe,u3)=>{"use strict";var{createInflate:pw,createGunzip:c3,createBrotliDecompress:Jae,createZstdDecompress:Kae}=require("zlib"),{pipeline:Zae}=require("stream"),Xae=pn(),{runtimeFeatures:eie}=Ta(),m3={gzip:c3,"x-gzip":c3,br:Jae,deflate:pw,compress:pw,"x-compress":pw,...eie.has("zstd")?{zstd:Kae}:{}},oie=[204,304],l3=!1,hw=class extends Xae{#e=[];#o;#a;constructor(e,{skipStatusCodes:t=oie,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),Zae(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 tie(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=tie});var h3=y((_pe,p3)=>{"use strict";var{RequestAbortedError:aie}=$(),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 aie(`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((Lpe,f3)=>{"use strict";var iie=require("diagnostics_channel"),rie=K(),sie=h3(),{normalizeHeaders:nie,makeCacheKey:cie,makeDeduplicationKey:mie}=hn(),sg=iie.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(!rie.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:nie(m)},r.size>0){for(let b of Object.keys(m.headers))if(r.has(b.toLowerCase()))return c(m,l)}let u=cie(m),d=mie(u,s),g=n.get(d);if(g)return g.addWaitingHandler(l)?!0:c(m,l);let p=new sie(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((Ppe,k3)=>{"use strict";var{Writable:lie}=require("stream"),{assertCacheKey:bw,assertCacheValue:uie}=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(`
|
|
1332
1332
|
PRAGMA journal_mode = WAL;
|
|
1333
1333
|
PRAGMA synchronous = NORMAL;
|
|
1334
1334
|
PRAGMA temp_store = memory;
|
|
@@ -1412,12 +1412,12 @@ ${e.format(t)}`.trim())}};YQ.exports=_A});var FA=y((wpe,JQ)=>{"use strict";var{I
|
|
|
1412
1412
|
LIMIT ?
|
|
1413
1413
|
)
|
|
1414
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),uie(t);let a=0,i=[],r=this;return new lie({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(!die(i[u],l[u])){m=!1;break}}if(m)return c}}};function die(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((Hpe,I3)=>{"use strict";var{kConstruct:gie}=de(),{kEnumerableProperty:yn}=K(),{iteratorMixin:pie,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 hie(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!==gie&&(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:fie,getHeadersList:mg,setHeadersList:bie}=Ft;Reflect.deleteProperty(Ft,"getHeadersGuard");Reflect.deleteProperty(Ft,"setHeadersGuard");Reflect.deleteProperty(Ft,"getHeadersList");Reflect.deleteProperty(Ft,"setHeadersList");pie("Headers",Ft,hie,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:fie,setHeadersList:bie,getHeadersList:mg}});var Fm=y((Gpe,M3)=>{"use strict";var{Headers:D3,HeadersList:C3,fill:yie,getHeadersGuard:kie,setHeadersGuard:T3,setHeadersList:R3}=$r(),{extractBody:j3,cloneBody:Aie,mixinBody:wie,streamRegistry:N3,bodyUnusable:vie}=$s(),U3=K(),B3=require("util"),{kEnumerableProperty:Xo}=U3,{isValidReasonPhrase:xie,isCancelled:zie,isAborted:qie,isErrorLike:Eie,environmentSettingsObject:Iie}=Vo(),{redirectStatusSet:Cie,nullBodyStatus:jie}=Xc(),{webidl:ie}=to(),{URLSerializer:Q3}=bt(),{kConstruct:ug}=de(),ww=require("assert"),{isomorphicEncode:Bie,serializeJavascriptValueToJSONString:Qie}=Da(),Sie=new TextEncoder("utf-8"),et=class o{#e;#o;static error(){return Lm(dg(),"immutable")}static json(e,t=void 0){ie.argumentLengthCheck(arguments,1,"Response.json"),t!==null&&(t=ie.converters.ResponseInit(t));let a=Sie.encode(Qie(e)),i=j3(a),r=Lm(kn({}),"response");return S3(r,t,{body:i[0],type:"application/json"}),r}static redirect(e,t=302){ie.argumentLengthCheck(arguments,1,"Response.redirect"),e=ie.converters.USVString(e),t=ie.converters["unsigned short"](t);let a;try{a=new URL(e,Iie.settingsObject.baseUrl)}catch(s){throw new TypeError(`Failed to parse URL from ${e}`,{cause:s})}if(!Cie.has(t))throw new RangeError(`Invalid status code ${t}`);let i=Lm(kn({}),"immutable");i.#o.status=t;let r=Bie(Q3(a));return i.#o.headersList.append("location",r,!0),i}constructor(e=null,t=void 0){if(ie.util.markAsUncloneable(this),e===ug)return;e!==null&&(e=ie.converters.BodyInit(e,"Response","body")),t=ie.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 ie.brandCheck(this,o),this.#o.type}get url(){ie.brandCheck(this,o);let e=this.#o.urlList,t=e[e.length-1]??null;return t===null?"":Q3(t,!0)}get redirected(){return ie.brandCheck(this,o),this.#o.urlList.length>1}get status(){return ie.brandCheck(this,o),this.#o.status}get ok(){return ie.brandCheck(this,o),this.#o.status>=200&&this.#o.status<=299}get statusText(){return ie.brandCheck(this,o),this.#o.statusText}get headers(){return ie.brandCheck(this,o),this.#e}get body(){return ie.brandCheck(this,o),this.#o.body?this.#o.body.stream:null}get bodyUsed(){return ie.brandCheck(this,o),!!this.#o.body&&U3.isDisturbed(this.#o.body.stream)}clone(){if(ie.brandCheck(this,o),vie(this.#o))throw ie.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,kie(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:Die,setResponseHeaders:Tie,getResponseState:Wr,setResponseState:Rie}=et;Reflect.deleteProperty(et,"getResponseHeaders");Reflect.deleteProperty(et,"setResponseHeaders");Reflect.deleteProperty(et,"getResponseState");Reflect.deleteProperty(et,"setResponseState");wie(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=Aie(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=Eie(o);return kn({type:"error",status:0,error:e?o:new Error(o&&String(o)),aborted:o&&o.name==="AbortError"})}function Nie(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 Uie(o,e=null){return ww(zie(o)),qie(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&&!xie(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&&yie(Die(o),e.headers),t){if(jie.includes(o.status))throw ie.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);Rie(t,o);let a=new D3(ug);return Tie(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}ie.converters.XMLHttpRequestBodyInit=function(o,e,t){return typeof o=="string"?ie.converters.USVString(o,e,t):ie.is.Blob(o)||ie.is.BufferSource(o)||ie.is.FormData(o)||ie.is.URLSearchParams(o)?o:ie.converters.DOMString(o,e,t)};ie.converters.BodyInit=function(o,e,t){return ie.is.ReadableStream(o)||o?.[Symbol.asyncIterator]?o:ie.converters.XMLHttpRequestBodyInit(o,e,t)};ie.converters.ResponseInit=ie.dictionaryConverter([{key:"status",converter:ie.converters["unsigned short"],defaultValue:()=>200},{key:"statusText",converter:ie.converters.ByteString,defaultValue:()=>""},{key:"headers",converter:ie.converters.HeadersInit}]);ie.is.Response=ie.util.MakeTypeAssertion(et);M3.exports={isNetworkError:Nie,makeNetworkError:dg,makeResponse:kn,makeAppropriateNetworkError:Uie,filterResponse:O3,Response:et,cloneResponse:vw,fromInnerResponse:Lm,getResponseState:Wr}});var An=y((Ype,X3)=>{"use strict";var{extractBody:Oie,mixinBody:Mie,cloneBody:_ie,bodyUnusable:_3}=$s(),{Headers:Y3,fill:Lie,HeadersList:hg,setHeadersGuard:xw,getHeadersGuard:Fie,setHeadersList:V3,getHeadersList:L3}=$r(),pg=K(),F3=require("util"),{isValidHTTPToken:Pie,sameOrigin:P3,environmentSettingsObject:gg}=Vo(),{forbiddenMethodsSet:Hie,corsSafeListedMethodsSet:Gie,referrerPolicy:Yie,requestRedirect:Vie,requestMode:$ie,requestCredentials:Wie,requestCache:Jie,requestDuplex:Kie}=Xc(),{kEnumerableProperty:Le,normalizedMethodRecordsBase:Zie,normalizedMethodRecords:Xie}=pg,{webidl:H}=to(),{URLSerializer:ere}=bt(),{kConstruct:fg}=de(),ore=require("assert"),{getMaxListeners:$3,setMaxListeners:tre,defaultMaxListeners:are}=require("events"),ire=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 ore(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=Xie[k];if(x!==void 0)i.method=x;else{if(!Pie(k))throw new TypeError(`'${k}' is not a valid HTTP method.`);let v=k.toUpperCase();if(Hie.has(v))throw new TypeError(`'${k}' HTTP method is unsupported.`);k=Zie[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[ire]=d;let k=new WeakRef(d),x=H3(k);zw&&$3(n)===are&&tre(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(!Gie.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 Lie(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]=Oie(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),ere(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,Fie(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:rre,getRequestDispatcher:sre,setRequestDispatcher:nre,setRequestHeaders:cre,getRequestState:J3,setRequestState:mre}=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");Mie(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=_ie(o.body)),e}function Z3(o,e,t,a){let i=new So(fg);mre(i,o),nre(i,e),rre(i,t);let r=new Y3(fg);return cre(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:Yie},{key:"mode",converter:H.converters.DOMString,allowedValues:$ie},{key:"credentials",converter:H.converters.DOMString,allowedValues:Wie},{key:"cache",converter:H.converters.DOMString,allowedValues:Jie},{key:"redirect",converter:H.converters.DOMString,allowedValues:Vie},{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:Kie},{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:sre,getRequestState:J3}});var n9=y((Vpe,s9)=>{"use strict";var lre=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),ure=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(lre(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:ure,caseSensitiveMatch:r9,isValidSRIHashAlgorithm:Ew,getStrongestMetadata:t9,parseMetadata:a9}});var Gm=y(($pe,w9)=>{"use strict";var{makeNetworkError:pe,makeAppropriateNetworkError:Pm,filterResponse:Iw,makeResponse:kg,fromInnerResponse:dre,getResponseState:gre}=Fm(),{HeadersList:Cw}=$r(),{Request:pre,cloneRequest:hre,getRequestDispatcher:fre,getRequestState:bre}=An(),Pt=require("zlib"),{makePolicyContainer:yre,clonePolicyContainer:kre,requestBadPort:Are,TAOCheck:wre,appendRequestOriginHeader:vre,responseLocationURL:xre,requestCurrentURL:ot,setRequestReferrerPolicyOnRedirect:zre,tryUpgradeRequestToAPotentiallyTrustworthyURL:qre,createOpaqueTimingInfo:Tw,appendFetchMetadata:Ere,corsCheck:Ire,crossOriginResourcePolicyCheck:Cre,determineRequestsReferrer:jre,coarsenedSharedCurrentTime:Hm,sameOrigin:Sw,isCancelled:Oi,isAborted:c9,isErrorLike:Bre,fullyReadBody:Qre,readableStreamClose:Sre,urlIsLocal:Dre,urlIsHttpHttpsScheme:xg,urlHasHttpsScheme:Tre,clampAndCoarsenConnectionTimingInfo:Rre,simpleRangeHeaderValue:Nre,buildContentRange:Ure,createInflate:Ore,extractMimeType:Mre,hasAuthenticationEntry:_re,includesCredentials:m9,isTraversableNavigable:Lre}=Vo(),Kr=require("assert"),{safelyExtractBody:zg,extractBody:l9}=$s(),{redirectStatusSet:p9,nullBodyStatus:h9,safeMethodsSet:Fre,requestBodyHeader:Pre,subresourceSet:Hre}=Xc(),Gre=require("events"),{Readable:Yre,pipeline:Vre,finished:$re,isErrored:Wre,isReadable:Ag}=require("stream"),{addAbortListener:Jre,bufferToLowerCasedHeaderName:u9}=K(),{dataURLProcessor:Kre,serializeAMimeType:Zre,minimizeSupportedMimeType:Xre}=bt(),{getGlobalDispatcher:ese}=ag(),{webidl:Rw}=to(),{STATUS_CODES:d9}=require("http"),{bytesMatch:ose}=n9(),{createDeferredPromise:tse}=im(),{isomorphicEncode:wg}=Da(),{runtimeFeatures:ase}=Ta(),ise=ase.has("zstd"),rse=["GET","HEAD"],sse=typeof __UNDICI_IS_NODE__<"u"||typeof esbuildDetection<"u"?"node":"undici",jw,vg=class extends Gre{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 nse(o){f9(o,"fetch")}function cse(o,e=void 0){Rw.argumentLengthCheck(arguments,1,"globalThis.fetch");let t=tse(),a;try{a=new pre(o,e)}catch(l){return t.reject(l),t.promise}let i=bre(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 Jre(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:nse,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(dre(l,"immutable")),t.resolve(s.deref()),t=null}},dispatcher:fre(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=gre(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=ese(),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=kre(o.client.policyContainer):o.policyContainer=yre()),o.headersList.contains("accept",!0)||o.headersList.append("accept","*/*",!0),o.headersList.contains("accept-language",!0)||o.headersList.append("accept-language","*",!0),o.priority,Hre.has(o.destination),k9(g,!1),g.controller}async function k9(o,e){try{let t=o.request,a=null;if(t.localURLsOnly&&!Dre(ot(t))&&(a=pe("local URLs only")),qre(t),Are(t)==="blocked"&&(a=pe("bad port")),t.referrerPolicy===""&&(t.referrerPolicy=t.policyContainer.referrerPolicy),t.referrer!=="no-referrer"&&(t.referrer=jre(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(!ose(n,t.integrity)){r("integrity mismatch");return}a.body=zg(n)[0],Qw(o,a)};Qre(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=Nre(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=Ure(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=Kre(a);if(i==="failure")return Promise.resolve(pe("failed to fetch the data URL"));let r=Zre(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 mse(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=Mre(e.headersList);l!=="failure"&&(c.contentType=Xre(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():$re(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"&&Ire(e,t)==="failure")return pe("cors failure");wre(e,t)==="failure"&&(e.timingAllowFailed=!0)}return(e.responseTainting==="opaque"||t.type==="opaque")&&Cre(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 lse(o,t):Kr(!1)),t.timingInfo=i,t)}function lse(o,e){let t=o.request,a=e.internalResponse?e.internalResponse:e,i;try{if(i=xre(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&&!rse.includes(t.method)){t.method="GET",t.body=null;for(let s of Pre)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),zre(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=hre(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),vre(r),Ere(r),r.headersList.contains("user-agent",!0)||r.headersList.append("user-agent",sse,!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)||(Tre(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(!(_re(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 use(i,m,t);!Fre.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||Lre(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 use(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){Sre(o.controller.controller),mse(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),Wre(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:Bre(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=Rre(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 Yre({read:D});let ae=oe&&a.redirect==="follow"&&p9.has(I),ye=[];if(a.method!=="HEAD"&&a.method!=="CONNECT"&&!h9.includes(I)&&!ae){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(Ore({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"&&ise)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?Vre(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,ae]of Object.entries(D)){if(ae==null)continue;let ye=oe.toLowerCase();if(Array.isArray(ae))for(let po of ae)S.append(ye,String(po),!0);else S.append(ye,String(ae),!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]),ae=T[S+1];if(Array.isArray(ae)&&!Buffer.isBuffer(T[S+1]))for(let ye of ae)O.append(oe,ye.toString("latin1"),!0);else O.append(oe,ae.toString("latin1"),!0)}return v({status:I,statusText:d9[I],headersList:O,socket:D}),!0}}))}}w9.exports={fetch:cse,Fetch:vg,fetching:y9,finalizeAndReportTiming:f9}});var z9=y((Wpe,x9)=>{"use strict";var dse=require("assert"),{URLSerializer:v9}=bt(),{isValidHeaderName:gse}=Vo();function pse(o,e,t=!1){let a=v9(o,t),i=v9(e,t);return a===i}function hse(o){dse(o!==null);let e=[];for(let t of o.split(","))t=t.trim(),gse(t)&&e.push(t);return e}x9.exports={urlEquals:pse,getFieldValues:hse}});var C9=y((Jpe,I9)=>{"use strict";var Nw=require("assert"),{kConstruct:fse}=de(),{urlEquals:bse,getFieldValues:Uw}=z9(),{kEnumerableProperty:Zr,isDisturbed:yse}=K(),{webidl:R}=to(),{cloneResponse:q9,fromInnerResponse:kse,getResponseState:Ase}=Fm(),{Request:Ym,fromInnerRequest:wse,getRequestState:ua}=An(),{fetching:vse}=Gm(),{urlIsHttpHttpsScheme:qg,readAllBytes:xse}=Vo(),{createDeferredPromise:wn}=im(),Eg=class o{#e;constructor(){arguments[0]!==fse&&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(vse({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=Ase(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&&(yse(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();xse(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=wse(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=""),!bse(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=kse(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((Kpe,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((Zpe,Q9)=>{"use strict";Q9.exports={maxAttributeValueSize:1024,maxNameValuePairSize:4096}});var _w=y((Xpe,N9)=>{"use strict";function zse(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 qse(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 Ese=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],Ise=["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)),`${Ese[o.getUTCDay()]}, ${jg[o.getUTCDate()]} ${Ise[o.getUTCMonth()]} ${o.getUTCFullYear()} ${jg[o.getUTCHours()]}:${jg[o.getUTCMinutes()]}:${jg[o.getUTCSeconds()]} GMT`}function Cse(o){if(o<0)throw new Error("Invalid cookie max-age")}function jse(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"&&(Cse(o.maxAge),e.push(`Max-Age=${o.maxAge}`)),o.domain&&(qse(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:zse,validateCookieName:Ow,validateCookiePath:T9,validateCookieValue:Mw,toIMFDate:R9,stringify:jse}});var O9=y((ehe,U9)=>{"use strict";var{collectASequenceOfCodePointsFast:Bg}=Da(),{maxNameValuePairSize:Bse,maxAttributeValueSize:Qse}=S9(),{isCTLExcludingHtab:Sse}=_w(),Dse=require("assert");function Tse(o){if(Sse(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>Bse?null:{name:a,value:i,...vn(t)}}function vn(o,e={}){if(o.length===0)return e;Dse(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>Qse)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:Tse,parseUnparsedAttributes:vn}});var F9=y((ohe,L9)=>{"use strict";var{parseSetCookie:M9}=O9(),{stringify:Rse}=_w(),{webidl:ne}=to(),{Headers:Nse}=$r(),Qg=ne.brandCheckMultiple([Nse,globalThis.Headers].filter(Boolean));function Use(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 Ose(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 Mse(o){ne.argumentLengthCheck(arguments,1,"getSetCookies"),Qg(o);let e=o.getSetCookie();return e?e.map(t=>M9(t)):[]}function _se(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=Rse(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:Use,deleteCookie:Ose,getSetCookies:Mse,setCookie:_9,parseCookie:_se}});var Tg=y((the,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:Lse}=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:Lse}});var Mi=y((ahe,G9)=>{"use strict";var Fse="258EAFA5-E914-47DA-95CA-C5AB0DC85B11",Pse={enumerable:!0,writable:!1,configurable:!1},Hse={CONNECTING:0,OPEN:1,CLOSING:2,CLOSED:3},Gse={SENT:1,RECEIVED:2},Yse={CONTINUATION:0,TEXT:1,BINARY:2,CLOSE:8,PING:9,PONG:10},Vse=65535,$se={INFO:0,PAYLOADLENGTH_16:2,PAYLOADLENGTH_64:3,READ_DATA:4},Wse=Buffer.allocUnsafe(0),Jse={text:1,typedArray:2,arrayBuffer:3,blob:4};G9.exports={uid:Fse,sentCloseFrameState:Gse,staticPropertyDescriptors:Pse,states:Hse,opcodes:Yse,maxUnsigned16Bit:Vse,parserStates:$se,emptyBuffer:Wse,sendHints:Jse}});var Xr=y((ihe,J9)=>{"use strict";var{states:Rg,opcodes:zn}=Mi(),{isUtf8:Kse}=require("buffer"),{removeHTTPWhitespace:Y9}=bt(),{collectASequenceOfCodePointsFast:Zse}=Da();function Xse(o){return o===Rg.CONNECTING}function ene(o){return o===Rg.OPEN}function one(o){return o===Rg.CLOSING}function tne(o){return o===Rg.CLOSED}function ane(o,e,t=(i,r)=>new Event(i,r),a={}){let i=t(o,a);e.dispatchEvent(i)}function ine(o,e,t){o.onMessage(e,t)}function rne(o){return o.byteLength===o.buffer.byteLength?o.buffer:new Uint8Array(o).buffer}function sne(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 nne(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 cne(o){return W9(o)||$9(o)||V9(o)}function mne(o){let e={position:0},t=new Map;for(;e.position<o.length;){let a=Zse(";",o,e),[i,r=""]=a.split("=",2);t.set(Y9(i,!0,!1),Y9(r,!1,!0)),e.position++}return t}function lne(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 une(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 dne(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 gne=(()=>{if(typeof process.versions.icu=="string"){let o=new TextDecoder("utf-8",{fatal:!0});return o.decode.bind(o)}return function(o){if(Kse(o))return o.toString("utf-8");throw new TypeError("Invalid utf-8 received.")}})();J9.exports={isConnecting:Xse,isEstablished:ene,isClosing:one,isClosed:tne,fireEvent:ane,isValidSubprotocol:sne,isValidStatusCode:nne,websocketMessageReceived:ine,utf8Decode:gne,isControlFrame:V9,isContinuationFrame:$9,isTextBinaryFrame:W9,isValidOpcode:cne,parseExtensions:mne,isValidClientWindowBits:lne,toArrayBuffer:rne,getURLRecord:une,validateCloseCodeAndReason:dne}});var En=y((rhe,Z9)=>{"use strict";var{runtimeFeatures:pne}=Ta(),{maxUnsigned16Bit:K9,opcodes:hne}=Mi(),Ng=8*1024,Wm=null,qn=Ng,fne=pne.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,fne(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|hne.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((she,i5)=>{"use strict";var{uid:bne,states:Hw,sentCloseFrameState:Gw,emptyBuffer:X9,opcodes:yne}=Mi(),{parseExtensions:kne,isClosed:Ane,isClosing:wne,isEstablished:t5,isConnecting:vne,validateCloseCodeAndReason:xne}=Xr(),{makeRequest:zne}=An(),{fetching:qne}=Gm(),{Headers:Ene,getHeadersList:Ine}=$r(),{getDecodeSplit:Cne}=Vo(),{WebsocketFrameSend:jne}=En(),Bne=require("assert"),{runtimeFeatures:Qne}=Ta(),e5=Qne.has("crypto")?require("crypto"):null,o5=!1;function Sne(o,e,t,a,i){let r=o;r.protocol=o.protocol==="ws:"?"http:":"https:";let s=zne({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=Ine(new Ene(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),qne({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+bne,"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=kne(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&&!Cne("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&&xne(e,t),!(Ane(o.readyState)||wne(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 jne;t.length!==0&&e===null&&(e=1e3),Bne(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(yne.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(),vne(o.readyState)?o.onSocketClose():o.socket?.destroyed===!1&&o.socket.destroy()}i5.exports={establishWebSocketConnection:Sne,failWebsocketConnection:da,closeWebSocketConnection:a5}});var s5=y((nhe,r5)=>{"use strict";var{createInflateRaw:Dne,Z_DEFAULT_WINDOWBITS:Tne}=require("zlib"),{isValidClientWindowBits:Rne}=Xr(),{MessageSizeExceededError:Nne}=$(),Une=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=Tne;if(this.#o.serverMaxWindowBits){if(!Rne(this.#o.serverMaxWindowBits)){a(new Error("Invalid server_max_window_bits"));return}i=Number.parseInt(this.#o.serverMaxWindowBits)}try{this.#e=Dne({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 Nne),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(Une),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((che,u5)=>{"use strict";var{Writable:One}=require("stream"),Mne=require("assert"),{parserStates:To,opcodes:In,states:_ne,emptyBuffer:n5,sentCloseFrameState:Km}=Mi(),{isValidStatusCode:Lne,isValidOpcode:Fne,websocketMessageReceived:c5,utf8Decode:Pne,isControlFrame:Vw,isTextBinaryFrame:$w,isContinuationFrame:Hne}=Xr(),{failWebsocketConnection:uo}=Ug(),{WebsocketFrameSend:m5}=En(),{PerMessageDeflate:Gne}=s5(),{MessageSizeExceededError:l5}=$(),Ww=class extends One{#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 Gne(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(!Fne(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(Hne(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){Mne(e.length!==1);let t;if(e.length>=2&&(t=e.readUInt16BE(0)),t!==void 0&&!Lne(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=Pne(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=_ne.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((mhe,p5)=>{"use strict";var{WebsocketFrameSend:g5}=En(),{opcodes:d5,sendHints:es}=Mi(),Yne=bk(),Zw=class{#e=new Yne;#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(Vne(o,e)).createFrame(e===es.text?d5.TEXT:d5.BINARY)}function Vne(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((lhe,A5)=>{"use strict";var{isArrayBuffer:$ne}=require("util/types"),{webidl:_}=to(),{URLSerializer:Wne}=bt(),{environmentSettingsObject:f5}=Vo(),{staticPropertyDescriptors:_i,states:Ga,sentCloseFrameState:Xw,sendHints:Mg,opcodes:ev}=Mi(),{isConnecting:Jne,isEstablished:b5,isClosing:y5,isClosed:Kne,isValidSubprotocol:Zne,fireEvent:_g,utf8Decode:Xne,toArrayBuffer:ece,getURLRecord:oce}=Xr(),{establishWebSocketConnection:tce,closeWebSocketConnection:ace,failWebsocketConnection:k5}=Ug(),{ByteParser:ice}=Jw(),{kEnumerableProperty:qt}=K(),{getGlobalDispatcher:rce}=ag(),{ErrorEvent:sce,CloseEvent:nce,createFastMessageEvent:cce}=Tg(),{SendQueue:mce}=h5(),{WebsocketFrameSend:lce}=En(),{channels:ga}=yi();function uce(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=oce(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=>Zne(c)))throw new DOMException("Invalid Sec-WebSocket-Protocol value","SyntaxError");this.#c=new URL(s.href);let n=f5.settingsObject;this.#t.controller=tce(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??="",ace(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"),Jne(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 $ne(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),Wne(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 ice(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 mce(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:uce(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=Xne(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=ece(t));_g("message",this,cce,{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 sce(r,s),{error:new TypeError(a)})),_g("close",this,(r,s)=>new nce(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)&&!Kne(a)){let i=new lce(t);e.#t.socket.write(i.createFrame(ev.PING))}}},{ping:dce}=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:()=>rce()},{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:dce}});var ov=y((uhe,z5)=>{"use strict";var{webidl:Lg}=to(),{validateCloseCodeAndReason:gce}=Xr(),{kConstruct:v5}=de(),{kEnumerableProperty:x5}=K();function pce(){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 pce(){#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??"";gce(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:hce}=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:hce}});var j5=y((dhe,C5)=>{"use strict";var{createDeferredPromise:tv}=im(),{environmentSettingsObject:q5}=Vo(),{states:Cn,opcodes:Fg,sentCloseFrameState:jn}=Mi(),{webidl:Re}=to(),{getURLRecord:fce,isValidSubprotocol:bce,isEstablished:yce,utf8Decode:kce}=Xr(),{establishWebSocketConnection:Ace,failWebsocketConnection:av,closeWebSocketConnection:iv}=Ug(),{channels:E5}=yi(),{WebsocketFrameSend:wce}=En(),{ByteParser:vce}=Jw(),{WebSocketError:xce,createUnvalidatedWebSocketError:zce}=ov(),{kEnumerableProperty:Pg}=K(),{utf8DecodeBytes:qce}=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=fce(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=>bce(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",()=>{yce(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=Ace(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 wce(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 vce(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=kce(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 xce("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?"":qce(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=zce("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((ghe,B5)=>{"use strict";function Ece(o){return o.indexOf("\0")===-1}function Ice(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:Ece,isASCIINumber:Ice}});var R5=y((phe,T5)=>{"use strict";var{Transform:Cce}=require("stream"),{isASCIINumber:S5,isValidLastEventId:D5}=Q5(),Ya=[239,187,191],rv=10,Gg=13,jce=58,Bce=32,sv=class extends Cce{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(jce);if(a===0)return;let i="",r="";if(a!==-1){i=e.subarray(0,a).toString("utf8");let s=a+1;e[s]===Bce&&++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]+=`
|
|
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((hhe,F5)=>{"use strict";var{pipeline:Qce}=require("stream"),{fetching:Sce}=Gm(),{makeRequest:Dce}=An(),{webidl:vo}=to(),{EventSourceStream:Tce}=R5(),{parseMIMEType:Rce}=bt(),{createFastMessageEvent:Nce}=Tg(),{isNetworkError:N5}=Fm(),{kEnumerableProperty:ts}=K(),{environmentSettingsObject:U5}=Vo(),O5=!1,M5=3e3,Zm=0,_5=1,Xm=2,Uce="anonymous",Oce="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=Uce;t.withCredentials===!0&&(s=Oce,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=Dce(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?Rce(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 Tce({eventSourceSettings:this.#s,push:c=>{this.dispatchEvent(Nce(c.type,c.options))}});Qce(a.body.stream,n,c=>{c?.aborted===!1&&(this.close(),this.dispatchEvent(new Event("error")))})},this.#t=Sce(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((fhe,Q)=>{"use strict";var Mce=Ii(),G5=Kc(),_ce=Sr(),Lce=j8(),Fce=D8(),Pce=Rr(),Hce=Hk(),Gce=_k(),Yce=yB(),Vce=qB(),$ce=CB(),Y5=$(),Vg=K(),{InvalidArgumentError:Yg}=Y5,Qn=
|
|
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((hhe,F5)=>{"use strict";var{pipeline:Qce}=require("stream"),{fetching:Sce}=Gm(),{makeRequest:Dce}=An(),{webidl:vo}=to(),{EventSourceStream:Tce}=R5(),{parseMIMEType:Rce}=bt(),{createFastMessageEvent:Nce}=Tg(),{isNetworkError:N5}=Fm(),{kEnumerableProperty:ts}=K(),{environmentSettingsObject:U5}=Vo(),O5=!1,M5=3e3,Zm=0,_5=1,Xm=2,Uce="anonymous",Oce="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=Uce;t.withCredentials===!0&&(s=Oce,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=Dce(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?Rce(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 Tce({eventSourceSettings:this.#s,push:c=>{this.dispatchEvent(Nce(c.type,c.options))}});Qce(a.body.stream,n,c=>{c?.aborted===!1&&(this.close(),this.dispatchEvent(new Event("error")))})},this.#t=Sce(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((fhe,Q)=>{"use strict";var Mce=Ii(),G5=Kc(),_ce=Sr(),Lce=j8(),Fce=D8(),Pce=Rr(),Hce=Hk(),Gce=_k(),Yce=yB(),Vce=qB(),$ce=CB(),Y5=$(),Vg=K(),{InvalidArgumentError:Yg}=Y5,Qn=m4(),Wce=wr(),Jce=jA(),{MockCallHistory:Kce,MockCallHistoryLog:Zce}=SA(),Xce=LA(),eme=NA(),ome=cQ(),tme=dA(),ame=Fd(),{getGlobalDispatcher:V5,setGlobalDispatcher:ime}=ag(),rme=pn(),sme=WA();Object.assign(G5.prototype,Qn);Q.exports.Dispatcher=G5;Q.exports.Client=Mce;Q.exports.Pool=_ce;Q.exports.BalancedPool=Lce;Q.exports.RoundRobinPool=Fce;Q.exports.Agent=Pce;Q.exports.ProxyAgent=Hce;Q.exports.Socks5ProxyAgent=Gce;Q.exports.EnvHttpProxyAgent=Yce;Q.exports.RetryAgent=Vce;Q.exports.H2CClient=$ce;Q.exports.RetryHandler=ame;Q.exports.DecoratorHandler=rme;Q.exports.RedirectHandler=sme;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 nme=A3();Q.exports.cacheStores.SqliteCacheStore=nme;Q.exports.buildConnector=Wce;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=ime;Q.exports.getGlobalDispatcher=V5;var cme=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(`
|
|
1416
1416
|
`).slice(1).join(`
|
|
1417
1417
|
`);o.stack=t?`${t}
|
|
1418
1418
|
${r}`:i.stack}Q.exports.fetch=function(e,t=void 0){return cme(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:mme,getGlobalOrigin:lme}=qy();Q.exports.setGlobalOrigin=mme;Q.exports.getGlobalOrigin=lme;var{CacheStorage:ume}=B9(),{kConstruct:dme}=de();Q.exports.caches=new ume(dme);var{deleteCookie:gme,getCookies:pme,getSetCookies:hme,setCookie:fme,parseCookie:bme}=F9();Q.exports.deleteCookie=gme;Q.exports.getCookies=pme;Q.exports.getSetCookies=hme;Q.exports.setCookie=fme;Q.exports.parseCookie=bme;var{parseMIMEType:yme,serializeAMimeType:kme}=bt();Q.exports.parseMIMEType=yme;Q.exports.serializeAMimeType=kme;var{CloseEvent:Ame,ErrorEvent:wme,MessageEvent:vme}=Tg(),{WebSocket:xme,ping:zme}=w5();Q.exports.WebSocket=xme;Q.exports.CloseEvent=Ame;Q.exports.ErrorEvent=wme;Q.exports.MessageEvent=vme;Q.exports.ping=zme;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=Jce;Q.exports.MockCallHistory=Kce;Q.exports.MockCallHistoryLog=Zce;Q.exports.MockPool=eme;Q.exports.MockAgent=Xce;Q.exports.SnapshotAgent=ome;Q.exports.mockErrors=tme;var{EventSource:qme}=P5();Q.exports.EventSource=qme;function Eme(){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=Eme});var J5=y(Dn=>{"use strict";Object.defineProperty(Dn,"__esModule",{value:!0});Dn.SuperglueClient=Dn.SuperglueHttpError=void 0;var Sn=rt(),Va=Jf(),Ime=wb(),Cme=cI(),jme=Kt(),$a=Cs(),Bme=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 Ime.SSELogSubscriptionManager(this.apiEndpoint,i??this.tokenProvider),this.onInfrastructureError=a}async getApiKey(){return this.tokenProvider()}isInfrastructureError(e){return(0,jme.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,Cme.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,Bme.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=Qme;Ce.parseJSON=Sme;Ce.isValidJson=Dme;Ce.prettyPrintJson=Tme;Ce.minifyJson=Rme;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`
|
|
1419
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 Qme(o,e){return(e?new Tn(e):K5).parse(o)}function Sme(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 Dme(o){try{return JSON.parse(o),!0}catch{return!1}}function Tme(o,e=2){return JSON.stringify(o,null,e)}function Rme(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 Nme=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)&&Nme(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 Ume=wb();Object.defineProperty(F,"SSELogSubscriptionManager",{enumerable:!0,get:function(){return Ume.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)+`
|
|
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.
|
|
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.80",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 Mme=(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 Mme("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(`
|
|
1421
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(`
|
|
1422
1422
|
${h.dim}0 results${h.reset}
|
|
1423
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(`
|