@rechargeapps/storefront-client 1.5.0 → 1.6.0

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.
@@ -132,7 +132,7 @@ function getCustomerParams() {
132
132
  const portalIndex = subpaths.findIndex((path) => path === "portal");
133
133
  const customerHash = portalIndex !== -1 ? subpaths[portalIndex + 1] : void 0;
134
134
  if (!token || !customerHash) {
135
- throw new Error("URL did not contain correct params");
135
+ throw new Error("Not in context of Recharge Customer Portal or URL did not contain correct params");
136
136
  }
137
137
  return { customerHash, token };
138
138
  }
@@ -1 +1 @@
1
- {"version":3,"file":"auth.js","sources":["../../../src/api/auth.ts"],"sourcesContent":["import { request as baseRequest, shopifyAppProxyRequest } from '../utils/request';\nimport {\n LoginResponse,\n PasswordlessCodeResponse,\n PasswordlessOptions,\n PasswordlessValidateResponse,\n} from '../types/auth';\nimport { getOptions } from '../utils/options';\nimport { RECHARGE_ADMIN_URL } from '../constants/api';\nimport { Session } from '../types/session';\nimport { RequestHeaders } from '../types';\n\nexport async function loginShopifyAppProxy(): Promise<Session> {\n const { storefrontAccessToken } = getOptions();\n const headers: RequestHeaders = {};\n if (storefrontAccessToken) {\n headers['X-Recharge-Storefront-Access-Token'] = storefrontAccessToken;\n }\n const response = await shopifyAppProxyRequest<LoginResponse>('get', '/access', { headers });\n\n return { apiToken: response.api_token, customerId: response.customer_id };\n}\n\nexport async function loginShopifyApi(\n shopifyStorefrontToken: string,\n shopifyCustomerAccessToken?: string\n): Promise<Session | null> {\n const { environment, storefrontAccessToken, storeIdentifier } = getOptions();\n const rechargeBaseUrl = RECHARGE_ADMIN_URL(environment);\n const headers: RequestHeaders = {};\n if (storefrontAccessToken) {\n headers['X-Recharge-Storefront-Access-Token'] = storefrontAccessToken;\n }\n const response = await baseRequest<LoginResponse>('post', `${rechargeBaseUrl}/shopify_storefront_access`, {\n data: {\n customer_token: shopifyCustomerAccessToken,\n storefront_token: shopifyStorefrontToken,\n shop_url: storeIdentifier,\n },\n headers,\n });\n\n return response.api_token ? { apiToken: response.api_token, customerId: response.customer_id } : null;\n}\n\nexport async function sendPasswordlessCode(email: string, options: PasswordlessOptions = {}): Promise<string> {\n const { environment, storefrontAccessToken, storeIdentifier } = getOptions();\n const rechargeBaseUrl = RECHARGE_ADMIN_URL(environment);\n const headers: RequestHeaders = {};\n if (storefrontAccessToken) {\n headers['X-Recharge-Storefront-Access-Token'] = storefrontAccessToken;\n }\n const response = await baseRequest<PasswordlessCodeResponse>('post', `${rechargeBaseUrl}/attempt_login`, {\n data: {\n email,\n shop: storeIdentifier,\n ...options,\n },\n headers,\n });\n\n if (response.errors) {\n throw new Error(response.errors);\n }\n return response.session_token;\n}\n\nexport async function sendPasswordlessCodeAppProxy(email: string, options: PasswordlessOptions = {}): Promise<string> {\n const { storefrontAccessToken } = getOptions();\n const headers: RequestHeaders = {};\n if (storefrontAccessToken) {\n headers['X-Recharge-Storefront-Access-Token'] = storefrontAccessToken;\n }\n const response = await shopifyAppProxyRequest<PasswordlessCodeResponse>('post', '/attempt_login', {\n data: {\n email,\n ...options,\n },\n headers,\n });\n\n if (response.errors) {\n throw new Error(response.errors);\n }\n return response.session_token;\n}\n\nexport async function validatePasswordlessCode(email: string, session_token: string, code: string): Promise<Session> {\n const { environment, storefrontAccessToken, storeIdentifier } = getOptions();\n const rechargeBaseUrl = RECHARGE_ADMIN_URL(environment);\n const headers: RequestHeaders = {};\n if (storefrontAccessToken) {\n headers['X-Recharge-Storefront-Access-Token'] = storefrontAccessToken;\n }\n const response = await baseRequest<PasswordlessValidateResponse>('post', `${rechargeBaseUrl}/validate_login`, {\n data: {\n code,\n email,\n session_token,\n shop: storeIdentifier,\n },\n headers,\n });\n\n if (response.errors) {\n throw new Error(response.errors);\n }\n return { apiToken: response.api_token, customerId: response.customer_id };\n}\n\nexport async function validatePasswordlessCodeAppProxy(\n email: string,\n session_token: string,\n code: string\n): Promise<Session> {\n const { storefrontAccessToken } = getOptions();\n const headers: RequestHeaders = {};\n if (storefrontAccessToken) {\n headers['X-Recharge-Storefront-Access-Token'] = storefrontAccessToken;\n }\n const response = await shopifyAppProxyRequest<PasswordlessValidateResponse>('post', '/validate_login', {\n data: {\n code,\n email,\n session_token,\n },\n headers,\n });\n\n if (response.errors) {\n throw new Error(response.errors);\n }\n return { apiToken: response.api_token, customerId: response.customer_id };\n}\n\nfunction getCustomerParams() {\n const { pathname, search } = window.location;\n const urlParams = new URLSearchParams(search);\n const token = urlParams.get('token');\n const subpaths = pathname.split('/').filter(Boolean);\n const portalIndex = subpaths.findIndex(path => path === 'portal');\n const customerHash = portalIndex !== -1 ? subpaths[portalIndex + 1] : undefined;\n\n // make sure the URL contained the data we need\n if (!token || !customerHash) {\n throw new Error('URL did not contain correct params');\n }\n return { customerHash, token };\n}\n\n/** @internal */\nexport async function loginCustomerPortal(): Promise<Session> {\n const { customerHash, token } = getCustomerParams();\n const { environment, storefrontAccessToken, storeIdentifier } = getOptions();\n const rechargeBaseUrl = RECHARGE_ADMIN_URL(environment);\n const headers: RequestHeaders = {};\n if (storefrontAccessToken) {\n headers['X-Recharge-Storefront-Access-Token'] = storefrontAccessToken;\n }\n const response = await baseRequest<LoginResponse>('post', `${rechargeBaseUrl}/customers/${customerHash}/access`, {\n headers,\n data: {\n token,\n shop: storeIdentifier,\n },\n });\n\n return { apiToken: response.api_token, customerId: response.customer_id };\n}\n"],"names":["getOptions","shopifyAppProxyRequest","RECHARGE_ADMIN_URL","baseRequest","options"],"mappings":";;;;;;;;AAAA,IAAI,SAAS,GAAG,MAAM,CAAC,cAAc,CAAC;AACtC,IAAI,mBAAmB,GAAG,MAAM,CAAC,qBAAqB,CAAC;AACvD,IAAI,YAAY,GAAG,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC;AACnD,IAAI,YAAY,GAAG,MAAM,CAAC,SAAS,CAAC,oBAAoB,CAAC;AACzD,IAAI,eAAe,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,KAAK,KAAK,GAAG,IAA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AE,IAAI,qBAAqB,EAAE;AAC7B,IAAI,OAAO,CAAC,oCAAoC,CAAC,GAAG,qBAAqB,CAAC;AAC1E,GAAG;AACH,EAAE,MAAM,QAAQ,GAAG,MAAMC,eAAW,CAAC,MAAM,EAAE,CAAC,EAAE,eAAe,CAAC,WAAW,EAAE,YAAY,CAAC,OAAO,CAAC,EAAE;AACpG,IAAI,OAAO;AACX,IAAI,IAAI,EAAE;AACV,MAAM,KAAK;AACX,MAAM,IAAI,EAAE,eAAe;AAC3B,KAAK;AACL,GAAG,CAAC,CAAC;AACL,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,CAAC,SAAS,EAAE,UAAU,EAAE,QAAQ,CAAC,WAAW,EAAE,CAAC;AAC5E;;;;;;;;;;"}
1
+ {"version":3,"file":"auth.js","sources":["../../../src/api/auth.ts"],"sourcesContent":["import { request as baseRequest, shopifyAppProxyRequest } from '../utils/request';\nimport {\n LoginResponse,\n PasswordlessCodeResponse,\n PasswordlessOptions,\n PasswordlessValidateResponse,\n} from '../types/auth';\nimport { getOptions } from '../utils/options';\nimport { RECHARGE_ADMIN_URL } from '../constants/api';\nimport { Session } from '../types/session';\nimport { RequestHeaders } from '../types';\n\nexport async function loginShopifyAppProxy(): Promise<Session> {\n const { storefrontAccessToken } = getOptions();\n const headers: RequestHeaders = {};\n if (storefrontAccessToken) {\n headers['X-Recharge-Storefront-Access-Token'] = storefrontAccessToken;\n }\n const response = await shopifyAppProxyRequest<LoginResponse>('get', '/access', { headers });\n\n return { apiToken: response.api_token, customerId: response.customer_id };\n}\n\nexport async function loginShopifyApi(\n shopifyStorefrontToken: string,\n shopifyCustomerAccessToken?: string\n): Promise<Session | null> {\n const { environment, storefrontAccessToken, storeIdentifier } = getOptions();\n const rechargeBaseUrl = RECHARGE_ADMIN_URL(environment);\n const headers: RequestHeaders = {};\n if (storefrontAccessToken) {\n headers['X-Recharge-Storefront-Access-Token'] = storefrontAccessToken;\n }\n const response = await baseRequest<LoginResponse>('post', `${rechargeBaseUrl}/shopify_storefront_access`, {\n data: {\n customer_token: shopifyCustomerAccessToken,\n storefront_token: shopifyStorefrontToken,\n shop_url: storeIdentifier,\n },\n headers,\n });\n\n return response.api_token ? { apiToken: response.api_token, customerId: response.customer_id } : null;\n}\n\nexport async function sendPasswordlessCode(email: string, options: PasswordlessOptions = {}): Promise<string> {\n const { environment, storefrontAccessToken, storeIdentifier } = getOptions();\n const rechargeBaseUrl = RECHARGE_ADMIN_URL(environment);\n const headers: RequestHeaders = {};\n if (storefrontAccessToken) {\n headers['X-Recharge-Storefront-Access-Token'] = storefrontAccessToken;\n }\n const response = await baseRequest<PasswordlessCodeResponse>('post', `${rechargeBaseUrl}/attempt_login`, {\n data: {\n email,\n shop: storeIdentifier,\n ...options,\n },\n headers,\n });\n\n if (response.errors) {\n throw new Error(response.errors);\n }\n return response.session_token;\n}\n\nexport async function sendPasswordlessCodeAppProxy(email: string, options: PasswordlessOptions = {}): Promise<string> {\n const { storefrontAccessToken } = getOptions();\n const headers: RequestHeaders = {};\n if (storefrontAccessToken) {\n headers['X-Recharge-Storefront-Access-Token'] = storefrontAccessToken;\n }\n const response = await shopifyAppProxyRequest<PasswordlessCodeResponse>('post', '/attempt_login', {\n data: {\n email,\n ...options,\n },\n headers,\n });\n\n if (response.errors) {\n throw new Error(response.errors);\n }\n return response.session_token;\n}\n\nexport async function validatePasswordlessCode(email: string, session_token: string, code: string): Promise<Session> {\n const { environment, storefrontAccessToken, storeIdentifier } = getOptions();\n const rechargeBaseUrl = RECHARGE_ADMIN_URL(environment);\n const headers: RequestHeaders = {};\n if (storefrontAccessToken) {\n headers['X-Recharge-Storefront-Access-Token'] = storefrontAccessToken;\n }\n const response = await baseRequest<PasswordlessValidateResponse>('post', `${rechargeBaseUrl}/validate_login`, {\n data: {\n code,\n email,\n session_token,\n shop: storeIdentifier,\n },\n headers,\n });\n\n if (response.errors) {\n throw new Error(response.errors);\n }\n return { apiToken: response.api_token, customerId: response.customer_id };\n}\n\nexport async function validatePasswordlessCodeAppProxy(\n email: string,\n session_token: string,\n code: string\n): Promise<Session> {\n const { storefrontAccessToken } = getOptions();\n const headers: RequestHeaders = {};\n if (storefrontAccessToken) {\n headers['X-Recharge-Storefront-Access-Token'] = storefrontAccessToken;\n }\n const response = await shopifyAppProxyRequest<PasswordlessValidateResponse>('post', '/validate_login', {\n data: {\n code,\n email,\n session_token,\n },\n headers,\n });\n\n if (response.errors) {\n throw new Error(response.errors);\n }\n return { apiToken: response.api_token, customerId: response.customer_id };\n}\n\nfunction getCustomerParams() {\n const { pathname, search } = window.location;\n const urlParams = new URLSearchParams(search);\n const token = urlParams.get('token');\n const subpaths = pathname.split('/').filter(Boolean);\n const portalIndex = subpaths.findIndex(path => path === 'portal');\n const customerHash = portalIndex !== -1 ? subpaths[portalIndex + 1] : undefined;\n\n // make sure the URL contained the data we need\n if (!token || !customerHash) {\n throw new Error('Not in context of Recharge Customer Portal or URL did not contain correct params');\n }\n return { customerHash, token };\n}\n\nexport async function loginCustomerPortal(): Promise<Session> {\n const { customerHash, token } = getCustomerParams();\n const { environment, storefrontAccessToken, storeIdentifier } = getOptions();\n const rechargeBaseUrl = RECHARGE_ADMIN_URL(environment);\n const headers: RequestHeaders = {};\n if (storefrontAccessToken) {\n headers['X-Recharge-Storefront-Access-Token'] = storefrontAccessToken;\n }\n const response = await baseRequest<LoginResponse>('post', `${rechargeBaseUrl}/customers/${customerHash}/access`, {\n headers,\n data: {\n token,\n shop: storeIdentifier,\n },\n });\n\n return { apiToken: response.api_token, customerId: response.customer_id };\n}\n"],"names":["getOptions","shopifyAppProxyRequest","RECHARGE_ADMIN_URL","baseRequest","options"],"mappings":";;;;;;;;AAAA,IAAI,SAAS,GAAG,MAAM,CAAC,cAAc,CAAC;AACtC,IAAI,mBAAmB,GAAG,MAAM,CAAC,qBAAqB,CAAC;AACvD,IAAI,YAAY,GAAG,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC;AACnD,IAAI,YAAY,GAAG,MAAM,CA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,MAAM,eAAe,GAAGE,sBAAkB,CAAC,WAAW,CAAC,CAAC;AAC1D,EAAE,MAAM,OAAO,GAAG,EAAE,CAAC;AACrB,EAAE,IAAI,qBAAqB,EAAE;AAC7B,IAAI,OAAO,CAAC,oCAAoC,CAAC,GAAG,qBAAqB,CAAC;AAC1E,GAAG;AACH,EAAE,MAAM,QAAQ,GAAG,MAAMC,eAAW,CAAC,MAAM,EAAE,CAAC,EAAE,eAAe,CAAC,WAAW,EAAE,YAAY,CAAC,OAAO,CAAC,EAAE;AACpG,IAAI,OAAO;AACX,IAAI,IAAI,EAAE;AACV,MAAM,KAAK;AACX,MAAM,IAAI,EAAE,eAAe;AAC3B,KAAK;AACL,GAAG,CAAC,CAAC;AACL,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,CAAC,SAAS,EAAE,UAAU,EAAE,QAAQ,CAAC,WAAW,EAAE,CAAC;AAC5E;;;;;;;;;;"}
@@ -128,7 +128,7 @@ function getCustomerParams() {
128
128
  const portalIndex = subpaths.findIndex((path) => path === "portal");
129
129
  const customerHash = portalIndex !== -1 ? subpaths[portalIndex + 1] : void 0;
130
130
  if (!token || !customerHash) {
131
- throw new Error("URL did not contain correct params");
131
+ throw new Error("Not in context of Recharge Customer Portal or URL did not contain correct params");
132
132
  }
133
133
  return { customerHash, token };
134
134
  }
@@ -1 +1 @@
1
- {"version":3,"file":"auth.js","sources":["../../../src/api/auth.ts"],"sourcesContent":["import { request as baseRequest, shopifyAppProxyRequest } from '../utils/request';\nimport {\n LoginResponse,\n PasswordlessCodeResponse,\n PasswordlessOptions,\n PasswordlessValidateResponse,\n} from '../types/auth';\nimport { getOptions } from '../utils/options';\nimport { RECHARGE_ADMIN_URL } from '../constants/api';\nimport { Session } from '../types/session';\nimport { RequestHeaders } from '../types';\n\nexport async function loginShopifyAppProxy(): Promise<Session> {\n const { storefrontAccessToken } = getOptions();\n const headers: RequestHeaders = {};\n if (storefrontAccessToken) {\n headers['X-Recharge-Storefront-Access-Token'] = storefrontAccessToken;\n }\n const response = await shopifyAppProxyRequest<LoginResponse>('get', '/access', { headers });\n\n return { apiToken: response.api_token, customerId: response.customer_id };\n}\n\nexport async function loginShopifyApi(\n shopifyStorefrontToken: string,\n shopifyCustomerAccessToken?: string\n): Promise<Session | null> {\n const { environment, storefrontAccessToken, storeIdentifier } = getOptions();\n const rechargeBaseUrl = RECHARGE_ADMIN_URL(environment);\n const headers: RequestHeaders = {};\n if (storefrontAccessToken) {\n headers['X-Recharge-Storefront-Access-Token'] = storefrontAccessToken;\n }\n const response = await baseRequest<LoginResponse>('post', `${rechargeBaseUrl}/shopify_storefront_access`, {\n data: {\n customer_token: shopifyCustomerAccessToken,\n storefront_token: shopifyStorefrontToken,\n shop_url: storeIdentifier,\n },\n headers,\n });\n\n return response.api_token ? { apiToken: response.api_token, customerId: response.customer_id } : null;\n}\n\nexport async function sendPasswordlessCode(email: string, options: PasswordlessOptions = {}): Promise<string> {\n const { environment, storefrontAccessToken, storeIdentifier } = getOptions();\n const rechargeBaseUrl = RECHARGE_ADMIN_URL(environment);\n const headers: RequestHeaders = {};\n if (storefrontAccessToken) {\n headers['X-Recharge-Storefront-Access-Token'] = storefrontAccessToken;\n }\n const response = await baseRequest<PasswordlessCodeResponse>('post', `${rechargeBaseUrl}/attempt_login`, {\n data: {\n email,\n shop: storeIdentifier,\n ...options,\n },\n headers,\n });\n\n if (response.errors) {\n throw new Error(response.errors);\n }\n return response.session_token;\n}\n\nexport async function sendPasswordlessCodeAppProxy(email: string, options: PasswordlessOptions = {}): Promise<string> {\n const { storefrontAccessToken } = getOptions();\n const headers: RequestHeaders = {};\n if (storefrontAccessToken) {\n headers['X-Recharge-Storefront-Access-Token'] = storefrontAccessToken;\n }\n const response = await shopifyAppProxyRequest<PasswordlessCodeResponse>('post', '/attempt_login', {\n data: {\n email,\n ...options,\n },\n headers,\n });\n\n if (response.errors) {\n throw new Error(response.errors);\n }\n return response.session_token;\n}\n\nexport async function validatePasswordlessCode(email: string, session_token: string, code: string): Promise<Session> {\n const { environment, storefrontAccessToken, storeIdentifier } = getOptions();\n const rechargeBaseUrl = RECHARGE_ADMIN_URL(environment);\n const headers: RequestHeaders = {};\n if (storefrontAccessToken) {\n headers['X-Recharge-Storefront-Access-Token'] = storefrontAccessToken;\n }\n const response = await baseRequest<PasswordlessValidateResponse>('post', `${rechargeBaseUrl}/validate_login`, {\n data: {\n code,\n email,\n session_token,\n shop: storeIdentifier,\n },\n headers,\n });\n\n if (response.errors) {\n throw new Error(response.errors);\n }\n return { apiToken: response.api_token, customerId: response.customer_id };\n}\n\nexport async function validatePasswordlessCodeAppProxy(\n email: string,\n session_token: string,\n code: string\n): Promise<Session> {\n const { storefrontAccessToken } = getOptions();\n const headers: RequestHeaders = {};\n if (storefrontAccessToken) {\n headers['X-Recharge-Storefront-Access-Token'] = storefrontAccessToken;\n }\n const response = await shopifyAppProxyRequest<PasswordlessValidateResponse>('post', '/validate_login', {\n data: {\n code,\n email,\n session_token,\n },\n headers,\n });\n\n if (response.errors) {\n throw new Error(response.errors);\n }\n return { apiToken: response.api_token, customerId: response.customer_id };\n}\n\nfunction getCustomerParams() {\n const { pathname, search } = window.location;\n const urlParams = new URLSearchParams(search);\n const token = urlParams.get('token');\n const subpaths = pathname.split('/').filter(Boolean);\n const portalIndex = subpaths.findIndex(path => path === 'portal');\n const customerHash = portalIndex !== -1 ? subpaths[portalIndex + 1] : undefined;\n\n // make sure the URL contained the data we need\n if (!token || !customerHash) {\n throw new Error('URL did not contain correct params');\n }\n return { customerHash, token };\n}\n\n/** @internal */\nexport async function loginCustomerPortal(): Promise<Session> {\n const { customerHash, token } = getCustomerParams();\n const { environment, storefrontAccessToken, storeIdentifier } = getOptions();\n const rechargeBaseUrl = RECHARGE_ADMIN_URL(environment);\n const headers: RequestHeaders = {};\n if (storefrontAccessToken) {\n headers['X-Recharge-Storefront-Access-Token'] = storefrontAccessToken;\n }\n const response = await baseRequest<LoginResponse>('post', `${rechargeBaseUrl}/customers/${customerHash}/access`, {\n headers,\n data: {\n token,\n shop: storeIdentifier,\n },\n });\n\n return { apiToken: response.api_token, customerId: response.customer_id };\n}\n"],"names":["baseRequest"],"mappings":";;;;AAAA,IAAI,SAAS,GAAG,MAAM,CAAC,cAAc,CAAC;AACtC,IAAI,mBAAmB,GAAG,MAAM,CAAC,qBAAqB,CAAC;AACvD,IAAI,YAAY,GAAG,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC;AACnD,IAAI,YAAY,GAAG,MAAM,CAAC,SAAS,CAAC,oBAAoB,CAAC;AACzD,IAAI,eAAe,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,KAAK,KAAK,GAAG,IAAI,GAAG,GAAG,SAAS,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,GAAG,GAAG,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;AAChK,IAAI,cAAc,GAAG,CAAC,CAAC,EAAE,CAAC,KAAK;AAC/B,EAAE,KAAK,IAAI,IAAI,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC;AAChC,IAAI,IAAI,YAAY,CAAC,IAAI,CAAC,CAAC,EAAE,IAAI,CAAC;AAClC,MAAM,eAAe,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;AACxC,EAAE,IAAI,mBAAmB;AACzB,IAAI,KAAK,IAAI,IAAI,IAAI,mBAAmB,CAAC,CAAC,CAAC,EAAE;AAC7C,MAAM,IAAI,YAAY,CAAC,IAAI,CAAC,CAAC,EAAE,IAAI,CAAC;AACpC,QAAQ,eAAe,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;AAC1C,KAAK;AACL,EAAE,OAAO,CAAC,CAAC;AACX,CAAC,CAAC;AAIK,eAAe,oBAAoB,GAAG;AAC7C,EAA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AC1D,GAAG;AACH,EAAE,OAAO,EAAE,YAAY,EAAE,KAAK,EAAE,CAAC;AACjC,CAAC;AACM,eAAe,mBAAmB,GAAG;AAC5C,EAAE,MAAM,EAAE,YAAY,EAAE,KAAK,EAAE,GAAG,iBAAiB,EAAE,CAAC;AACtD,EAAE,MAAM,EAAE,WAAW,EAAE,qBAAqB,EAAE,eAAe,EAAE,GAAG,UAAU,EAAE,CAAC;AAC/E,EAAE,MAAM,eAAe,GAAG,kBAAkB,CAAC,WAAW,CAAC,CAAC;AAC1D,EAAE,MAAM,OAAO,GAAG,EAAE,CAAC;AACrB,EAAE,IAAI,qBAAqB,EAAE;AAC7B,IAAI,OAAO,CAAC,oCAAoC,CAAC,GAAG,qBAAqB,CAAC;AAC1E,GAAG;AACH,EAAE,MAAM,QAAQ,GAAG,MAAMA,OAAW,CAAC,MAAM,EAAE,CAAC,EAAE,eAAe,CAAC,WAAW,EAAE,YAAY,CAAC,OAAO,CAAC,EAAE;AACpG,IAAI,OAAO;AACX,IAAI,IAAI,EAAE;AACV,MAAM,KAAK;AACX,MAAM,IAAI,EAAE,eAAe;AAC3B,KAAK;AACL,GAAG,CAAC,CAAC;AACL,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,CAAC,SAAS,EAAE,UAAU,EAAE,QAAQ,CAAC,WAAW,EAAE,CAAC;AAC5E;;;;"}
1
+ {"version":3,"file":"auth.js","sources":["../../../src/api/auth.ts"],"sourcesContent":["import { request as baseRequest, shopifyAppProxyRequest } from '../utils/request';\nimport {\n LoginResponse,\n PasswordlessCodeResponse,\n PasswordlessOptions,\n PasswordlessValidateResponse,\n} from '../types/auth';\nimport { getOptions } from '../utils/options';\nimport { RECHARGE_ADMIN_URL } from '../constants/api';\nimport { Session } from '../types/session';\nimport { RequestHeaders } from '../types';\n\nexport async function loginShopifyAppProxy(): Promise<Session> {\n const { storefrontAccessToken } = getOptions();\n const headers: RequestHeaders = {};\n if (storefrontAccessToken) {\n headers['X-Recharge-Storefront-Access-Token'] = storefrontAccessToken;\n }\n const response = await shopifyAppProxyRequest<LoginResponse>('get', '/access', { headers });\n\n return { apiToken: response.api_token, customerId: response.customer_id };\n}\n\nexport async function loginShopifyApi(\n shopifyStorefrontToken: string,\n shopifyCustomerAccessToken?: string\n): Promise<Session | null> {\n const { environment, storefrontAccessToken, storeIdentifier } = getOptions();\n const rechargeBaseUrl = RECHARGE_ADMIN_URL(environment);\n const headers: RequestHeaders = {};\n if (storefrontAccessToken) {\n headers['X-Recharge-Storefront-Access-Token'] = storefrontAccessToken;\n }\n const response = await baseRequest<LoginResponse>('post', `${rechargeBaseUrl}/shopify_storefront_access`, {\n data: {\n customer_token: shopifyCustomerAccessToken,\n storefront_token: shopifyStorefrontToken,\n shop_url: storeIdentifier,\n },\n headers,\n });\n\n return response.api_token ? { apiToken: response.api_token, customerId: response.customer_id } : null;\n}\n\nexport async function sendPasswordlessCode(email: string, options: PasswordlessOptions = {}): Promise<string> {\n const { environment, storefrontAccessToken, storeIdentifier } = getOptions();\n const rechargeBaseUrl = RECHARGE_ADMIN_URL(environment);\n const headers: RequestHeaders = {};\n if (storefrontAccessToken) {\n headers['X-Recharge-Storefront-Access-Token'] = storefrontAccessToken;\n }\n const response = await baseRequest<PasswordlessCodeResponse>('post', `${rechargeBaseUrl}/attempt_login`, {\n data: {\n email,\n shop: storeIdentifier,\n ...options,\n },\n headers,\n });\n\n if (response.errors) {\n throw new Error(response.errors);\n }\n return response.session_token;\n}\n\nexport async function sendPasswordlessCodeAppProxy(email: string, options: PasswordlessOptions = {}): Promise<string> {\n const { storefrontAccessToken } = getOptions();\n const headers: RequestHeaders = {};\n if (storefrontAccessToken) {\n headers['X-Recharge-Storefront-Access-Token'] = storefrontAccessToken;\n }\n const response = await shopifyAppProxyRequest<PasswordlessCodeResponse>('post', '/attempt_login', {\n data: {\n email,\n ...options,\n },\n headers,\n });\n\n if (response.errors) {\n throw new Error(response.errors);\n }\n return response.session_token;\n}\n\nexport async function validatePasswordlessCode(email: string, session_token: string, code: string): Promise<Session> {\n const { environment, storefrontAccessToken, storeIdentifier } = getOptions();\n const rechargeBaseUrl = RECHARGE_ADMIN_URL(environment);\n const headers: RequestHeaders = {};\n if (storefrontAccessToken) {\n headers['X-Recharge-Storefront-Access-Token'] = storefrontAccessToken;\n }\n const response = await baseRequest<PasswordlessValidateResponse>('post', `${rechargeBaseUrl}/validate_login`, {\n data: {\n code,\n email,\n session_token,\n shop: storeIdentifier,\n },\n headers,\n });\n\n if (response.errors) {\n throw new Error(response.errors);\n }\n return { apiToken: response.api_token, customerId: response.customer_id };\n}\n\nexport async function validatePasswordlessCodeAppProxy(\n email: string,\n session_token: string,\n code: string\n): Promise<Session> {\n const { storefrontAccessToken } = getOptions();\n const headers: RequestHeaders = {};\n if (storefrontAccessToken) {\n headers['X-Recharge-Storefront-Access-Token'] = storefrontAccessToken;\n }\n const response = await shopifyAppProxyRequest<PasswordlessValidateResponse>('post', '/validate_login', {\n data: {\n code,\n email,\n session_token,\n },\n headers,\n });\n\n if (response.errors) {\n throw new Error(response.errors);\n }\n return { apiToken: response.api_token, customerId: response.customer_id };\n}\n\nfunction getCustomerParams() {\n const { pathname, search } = window.location;\n const urlParams = new URLSearchParams(search);\n const token = urlParams.get('token');\n const subpaths = pathname.split('/').filter(Boolean);\n const portalIndex = subpaths.findIndex(path => path === 'portal');\n const customerHash = portalIndex !== -1 ? subpaths[portalIndex + 1] : undefined;\n\n // make sure the URL contained the data we need\n if (!token || !customerHash) {\n throw new Error('Not in context of Recharge Customer Portal or URL did not contain correct params');\n }\n return { customerHash, token };\n}\n\nexport async function loginCustomerPortal(): Promise<Session> {\n const { customerHash, token } = getCustomerParams();\n const { environment, storefrontAccessToken, storeIdentifier } = getOptions();\n const rechargeBaseUrl = RECHARGE_ADMIN_URL(environment);\n const headers: RequestHeaders = {};\n if (storefrontAccessToken) {\n headers['X-Recharge-Storefront-Access-Token'] = storefrontAccessToken;\n }\n const response = await baseRequest<LoginResponse>('post', `${rechargeBaseUrl}/customers/${customerHash}/access`, {\n headers,\n data: {\n token,\n shop: storeIdentifier,\n },\n });\n\n return { apiToken: response.api_token, customerId: response.customer_id };\n}\n"],"names":["baseRequest"],"mappings":";;;;AAAA,IAAI,SAAS,GAAG,MAAM,CAAC,cAAc,CAAC;AACtC,IAAI,mBAAmB,GAAG,MAAM,CAAC,qBAAqB,CAAC;AACvD,IAAI,YAAY,GAAG,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC;AACnD,IAAI,YAAY,GAAG,MAAM,CAAC,SAAS,CAAC,oBAAoB,CAAC;AACzD,IAAI,eAAe,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,KAAK,KAAK,GAAG,IAAI,GAAG,GAAG,SAAS,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,GAAG,GAAG,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;AAChK,IAAI,cAAc,GAAG,CAAC,CAAC,EAAE,CAAC,KAAK;AAC/B,EAAE,KAAK,IAAI,IAAI,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC;AAChC,IAAI,IAAI,YAAY,CAAC,IAAI,CAAC,CAAC,EAAE,IAAI,CAAC;AAClC,MAAM,eAAe,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;AACxC,EAAE,IAAI,mBAAmB;AACzB,IAAI,KAAK,IAAI,IAAI,IAAI,mBAAmB,CAAC,CAAC,CAAC,EAAE;AAC7C,MAAM,IAAI,YAAY,CAAC,IAAI,CAAC,CAAC,EAAE,IAAI,CAAC;AACpC,QAAQ,eAAe,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;AAC1C,KAAK;AACL,EAAE,OAAO,CAAC,CAAC;AACX,CAAC,CAAC;AAIK,eAAe,oBAAoB,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kF,CAAC,CAAC;AACxG,GAAG;AACH,EAAE,OAAO,EAAE,YAAY,EAAE,KAAK,EAAE,CAAC;AACjC,CAAC;AACM,eAAe,mBAAmB,GAAG;AAC5C,EAAE,MAAM,EAAE,YAAY,EAAE,KAAK,EAAE,GAAG,iBAAiB,EAAE,CAAC;AACtD,EAAE,MAAM,EAAE,WAAW,EAAE,qBAAqB,EAAE,eAAe,EAAE,GAAG,UAAU,EAAE,CAAC;AAC/E,EAAE,MAAM,eAAe,GAAG,kBAAkB,CAAC,WAAW,CAAC,CAAC;AAC1D,EAAE,MAAM,OAAO,GAAG,EAAE,CAAC;AACrB,EAAE,IAAI,qBAAqB,EAAE;AAC7B,IAAI,OAAO,CAAC,oCAAoC,CAAC,GAAG,qBAAqB,CAAC;AAC1E,GAAG;AACH,EAAE,MAAM,QAAQ,GAAG,MAAMA,OAAW,CAAC,MAAM,EAAE,CAAC,EAAE,eAAe,CAAC,WAAW,EAAE,YAAY,CAAC,OAAO,CAAC,EAAE;AACpG,IAAI,OAAO;AACX,IAAI,IAAI,EAAE;AACV,MAAM,KAAK;AACX,MAAM,IAAI,EAAE,eAAe;AAC3B,KAAK;AACL,GAAG,CAAC,CAAC;AACL,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,CAAC,SAAS,EAAE,UAAU,EAAE,QAAQ,CAAC,WAAW,EAAE,CAAC;AAC5E;;;;"}
package/dist/index.d.ts CHANGED
@@ -586,7 +586,7 @@ interface SubscriptionListParams extends ListParams<SubscriptionSortBy> {
586
586
  created_at_min?: IsoDateString;
587
587
  /** Return the subscriptions linked to the given external_variant_id */
588
588
  external_variant_id?: string;
589
- /** Comma-separated list of subscription_ids to filter */
589
+ /** List of subscription_ids to filter */
590
590
  ids?: (string | number)[];
591
591
  /** Return the subscriptions with specified status. */
592
592
  status?: SubscriptionStatus;
@@ -1044,15 +1044,12 @@ interface ChargeListParams extends ListParams<ChargeSortBy> {
1044
1044
  discount_code?: string;
1045
1045
  /** Filter Charges by the associated order ID in the external e-commerce platform. */
1046
1046
  external_order_id?: string | number;
1047
- /**
1048
- * Filter Charges by ID.
1049
- * If passing multiple values, must be comma separated. Non-integer values will result in a 422 error.
1050
- */
1051
- ids?: string | number;
1047
+ /** Filter Charges by list of IDs. */
1048
+ ids?: (string | number)[];
1052
1049
  /** Filter Charges by a Subscription or Onetime ID. */
1053
1050
  purchase_item_id?: string | number;
1054
- /** Filter Charges by a comma-separated list of Subscription or Onetime IDs. */
1055
- purchase_item_ids?: string | number;
1051
+ /** Filter Charges by list of Subscription or Onetime IDs. */
1052
+ purchase_item_ids?: (string | number)[];
1056
1053
  /** Filter Charges by specific scheduled charge date. */
1057
1054
  scheduled_at?: IsoDateString;
1058
1055
  /** Show Charges scheduled to be processed before the given date. */
@@ -1294,7 +1291,6 @@ declare function sendPasswordlessCode(email: string, options?: PasswordlessOptio
1294
1291
  declare function sendPasswordlessCodeAppProxy(email: string, options?: PasswordlessOptions): Promise<string>;
1295
1292
  declare function validatePasswordlessCode(email: string, session_token: string, code: string): Promise<Session>;
1296
1293
  declare function validatePasswordlessCodeAppProxy(email: string, session_token: string, code: string): Promise<Session>;
1297
- /** @internal */
1298
1294
  declare function loginCustomerPortal(): Promise<Session>;
1299
1295
 
1300
1296
  type Method = 'get' | 'post' | 'put' | 'delete';
@@ -1896,7 +1892,7 @@ interface OnetimeListParams extends ListParams<OnetimesSortBy> {
1896
1892
  created_at_min?: IsoDateString;
1897
1893
  /** Return the onetimes linked to the given external_variant_id */
1898
1894
  external_variant_id?: string | number;
1899
- /** Comma-separated list of onetime_ids to filter */
1895
+ /** List of onetime_ids to filter */
1900
1896
  ids?: (string | number)[];
1901
1897
  /** If true the response will include the cancelled Onetimes as well as the others. */
1902
1898
  include_cancelled?: boolean;
@@ -1,4 +1,4 @@
1
- // recharge-client-1.5.0.min.js | MIT License | © Recharge Inc.
1
+ // recharge-client-1.6.0.min.js | MIT License | © Recharge Inc.
2
2
  (function(Ae,vr){typeof exports=="object"&&typeof module<"u"?module.exports=vr():typeof define=="function"&&define.amd?define(vr):(Ae=typeof globalThis<"u"?globalThis:Ae||self,Ae.recharge=vr())})(this,function(){"use strict";var Ae=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function vr(e){var r=e.default;if(typeof r=="function"){var t=function(){return r.apply(this,arguments)};t.prototype=r.prototype}else t={};return Object.defineProperty(t,"__esModule",{value:!0}),Object.keys(e).forEach(function(n){var a=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,a.get?a:{enumerable:!0,get:function(){return e[n]}})}),t}var Z=typeof globalThis<"u"&&globalThis||typeof self<"u"&&self||typeof Z<"u"&&Z,ne={searchParams:"URLSearchParams"in Z,iterable:"Symbol"in Z&&"iterator"in Symbol,blob:"FileReader"in Z&&"Blob"in Z&&function(){try{return new Blob,!0}catch{return!1}}(),formData:"FormData"in Z,arrayBuffer:"ArrayBuffer"in Z};function Cs(e){return e&&DataView.prototype.isPrototypeOf(e)}if(ne.arrayBuffer)var Us=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],Ds=ArrayBuffer.isView||function(e){return e&&Us.indexOf(Object.prototype.toString.call(e))>-1};function mr(e){if(typeof e!="string"&&(e=String(e)),/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(e)||e==="")throw new TypeError('Invalid character in header field name: "'+e+'"');return e.toLowerCase()}function Pt(e){return typeof e!="string"&&(e=String(e)),e}function Rt(e){var r={next:function(){var t=e.shift();return{done:t===void 0,value:t}}};return ne.iterable&&(r[Symbol.iterator]=function(){return r}),r}function W(e){this.map={},e instanceof W?e.forEach(function(r,t){this.append(t,r)},this):Array.isArray(e)?e.forEach(function(r){this.append(r[0],r[1])},this):e&&Object.getOwnPropertyNames(e).forEach(function(r){this.append(r,e[r])},this)}W.prototype.append=function(e,r){e=mr(e),r=Pt(r);var t=this.map[e];this.map[e]=t?t+", "+r:r},W.prototype.delete=function(e){delete this.map[mr(e)]},W.prototype.get=function(e){return e=mr(e),this.has(e)?this.map[e]:null},W.prototype.has=function(e){return this.map.hasOwnProperty(mr(e))},W.prototype.set=function(e,r){this.map[mr(e)]=Pt(r)},W.prototype.forEach=function(e,r){for(var t in this.map)this.map.hasOwnProperty(t)&&e.call(r,this.map[t],t,this)},W.prototype.keys=function(){var e=[];return this.forEach(function(r,t){e.push(t)}),Rt(e)},W.prototype.values=function(){var e=[];return this.forEach(function(r){e.push(r)}),Rt(e)},W.prototype.entries=function(){var e=[];return this.forEach(function(r,t){e.push([t,r])}),Rt(e)},ne.iterable&&(W.prototype[Symbol.iterator]=W.prototype.entries);function Ft(e){if(e.bodyUsed)return Promise.reject(new TypeError("Already read"));e.bodyUsed=!0}function Zn(e){return new Promise(function(r,t){e.onload=function(){r(e.result)},e.onerror=function(){t(e.error)}})}function Ns(e){var r=new FileReader,t=Zn(r);return r.readAsArrayBuffer(e),t}function Ls(e){var r=new FileReader,t=Zn(r);return r.readAsText(e),t}function Ms(e){for(var r=new Uint8Array(e),t=new Array(r.length),n=0;n<r.length;n++)t[n]=String.fromCharCode(r[n]);return t.join("")}function ei(e){if(e.slice)return e.slice(0);var r=new Uint8Array(e.byteLength);return r.set(new Uint8Array(e)),r.buffer}function ri(){return this.bodyUsed=!1,this._initBody=function(e){this.bodyUsed=this.bodyUsed,this._bodyInit=e,e?typeof e=="string"?this._bodyText=e:ne.blob&&Blob.prototype.isPrototypeOf(e)?this._bodyBlob=e:ne.formData&&FormData.prototype.isPrototypeOf(e)?this._bodyFormData=e:ne.searchParams&&URLSearchParams.prototype.isPrototypeOf(e)?this._bodyText=e.toString():ne.arrayBuffer&&ne.blob&&Cs(e)?(this._bodyArrayBuffer=ei(e.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):ne.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(e)||Ds(e))?this._bodyArrayBuffer=ei(e):this._bodyText=e=Object.prototype.toString.call(e):this._bodyText="",this.headers.get("content-type")||(typeof e=="string"?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):ne.searchParams&&URLSearchParams.prototype.isPrototypeOf(e)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},ne.blob&&(this.blob=function(){var e=Ft(this);if(e)return e;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){if(this._bodyArrayBuffer){var e=Ft(this);return e||(ArrayBuffer.isView(this._bodyArrayBuffer)?Promise.resolve(this._bodyArrayBuffer.buffer.slice(this._bodyArrayBuffer.byteOffset,this._bodyArrayBuffer.byteOffset+this._bodyArrayBuffer.byteLength)):Promise.resolve(this._bodyArrayBuffer))}else return this.blob().then(Ns)}),this.text=function(){var e=Ft(this);if(e)return e;if(this._bodyBlob)return Ls(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(Ms(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},ne.formData&&(this.formData=function(){return this.text().then(Gs)}),this.json=function(){return this.text().then(JSON.parse)},this}var js=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function ks(e){var r=e.toUpperCase();return js.indexOf(r)>-1?r:e}function Me(e,r){if(!(this instanceof Me))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');r=r||{};var t=r.body;if(e instanceof Me){if(e.bodyUsed)throw new TypeError("Already read");this.url=e.url,this.credentials=e.credentials,r.headers||(this.headers=new W(e.headers)),this.method=e.method,this.mode=e.mode,this.signal=e.signal,!t&&e._bodyInit!=null&&(t=e._bodyInit,e.bodyUsed=!0)}else this.url=String(e);if(this.credentials=r.credentials||this.credentials||"same-origin",(r.headers||!this.headers)&&(this.headers=new W(r.headers)),this.method=ks(r.method||this.method||"GET"),this.mode=r.mode||this.mode||null,this.signal=r.signal||this.signal,this.referrer=null,(this.method==="GET"||this.method==="HEAD")&&t)throw new TypeError("Body not allowed for GET or HEAD requests");if(this._initBody(t),(this.method==="GET"||this.method==="HEAD")&&(r.cache==="no-store"||r.cache==="no-cache")){var n=/([?&])_=[^&]*/;if(n.test(this.url))this.url=this.url.replace(n,"$1_="+new Date().getTime());else{var a=/\?/;this.url+=(a.test(this.url)?"&":"?")+"_="+new Date().getTime()}}}Me.prototype.clone=function(){return new Me(this,{body:this._bodyInit})};function Gs(e){var r=new FormData;return e.trim().split("&").forEach(function(t){if(t){var n=t.split("="),a=n.shift().replace(/\+/g," "),s=n.join("=").replace(/\+/g," ");r.append(decodeURIComponent(a),decodeURIComponent(s))}}),r}function Ws(e){var r=new W,t=e.replace(/\r?\n[\t ]+/g," ");return t.split("\r").map(function(n){return n.indexOf(`
3
3
  `)===0?n.substr(1,n.length):n}).forEach(function(n){var a=n.split(":"),s=a.shift().trim();if(s){var c=a.join(":").trim();r.append(s,c)}}),r}ri.call(Me.prototype);function de(e,r){if(!(this instanceof de))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');r||(r={}),this.type="default",this.status=r.status===void 0?200:r.status,this.ok=this.status>=200&&this.status<300,this.statusText=r.statusText===void 0?"":""+r.statusText,this.headers=new W(r.headers),this.url=r.url||"",this._initBody(e)}ri.call(de.prototype),de.prototype.clone=function(){return new de(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new W(this.headers),url:this.url})},de.error=function(){var e=new de(null,{status:0,statusText:""});return e.type="error",e};var qs=[301,302,303,307,308];de.redirect=function(e,r){if(qs.indexOf(r)===-1)throw new RangeError("Invalid status code");return new de(null,{status:r,headers:{location:e}})};var je=Z.DOMException;try{new je}catch{je=function(r,t){this.message=r,this.name=t;var n=Error(r);this.stack=n.stack},je.prototype=Object.create(Error.prototype),je.prototype.constructor=je}function ti(e,r){return new Promise(function(t,n){var a=new Me(e,r);if(a.signal&&a.signal.aborted)return n(new je("Aborted","AbortError"));var s=new XMLHttpRequest;function c(){s.abort()}s.onload=function(){var h={status:s.status,statusText:s.statusText,headers:Ws(s.getAllResponseHeaders()||"")};h.url="responseURL"in s?s.responseURL:h.headers.get("X-Request-URL");var v="response"in s?s.response:s.responseText;setTimeout(function(){t(new de(v,h))},0)},s.onerror=function(){setTimeout(function(){n(new TypeError("Network request failed"))},0)},s.ontimeout=function(){setTimeout(function(){n(new TypeError("Network request failed"))},0)},s.onabort=function(){setTimeout(function(){n(new je("Aborted","AbortError"))},0)};function p(h){try{return h===""&&Z.location.href?Z.location.href:h}catch{return h}}s.open(a.method,p(a.url),!0),a.credentials==="include"?s.withCredentials=!0:a.credentials==="omit"&&(s.withCredentials=!1),"responseType"in s&&(ne.blob?s.responseType="blob":ne.arrayBuffer&&a.headers.get("Content-Type")&&a.headers.get("Content-Type").indexOf("application/octet-stream")!==-1&&(s.responseType="arraybuffer")),r&&typeof r.headers=="object"&&!(r.headers instanceof W)?Object.getOwnPropertyNames(r.headers).forEach(function(h){s.setRequestHeader(h,Pt(r.headers[h]))}):a.headers.forEach(function(h,v){s.setRequestHeader(v,h)}),a.signal&&(a.signal.addEventListener("abort",c),s.onreadystatechange=function(){s.readyState===4&&a.signal.removeEventListener("abort",c)}),s.send(typeof a._bodyInit>"u"?null:a._bodyInit)})}ti.polyfill=!0,Z.fetch||(Z.fetch=ti,Z.Headers=W,Z.Request=Me,Z.Response=de),self.fetch.bind(self);var zs=function(){if(typeof Symbol!="function"||typeof Object.getOwnPropertySymbols!="function")return!1;if(typeof Symbol.iterator=="symbol")return!0;var r={},t=Symbol("test"),n=Object(t);if(typeof t=="string"||Object.prototype.toString.call(t)!=="[object Symbol]"||Object.prototype.toString.call(n)!=="[object Symbol]")return!1;var a=42;r[t]=a;for(t in r)return!1;if(typeof Object.keys=="function"&&Object.keys(r).length!==0||typeof Object.getOwnPropertyNames=="function"&&Object.getOwnPropertyNames(r).length!==0)return!1;var s=Object.getOwnPropertySymbols(r);if(s.length!==1||s[0]!==t||!Object.prototype.propertyIsEnumerable.call(r,t))return!1;if(typeof Object.getOwnPropertyDescriptor=="function"){var c=Object.getOwnPropertyDescriptor(r,t);if(c.value!==a||c.enumerable!==!0)return!1}return!0},ni=typeof Symbol<"u"&&Symbol,Vs=zs,Hs=function(){return typeof ni!="function"||typeof Symbol!="function"||typeof ni("foo")!="symbol"||typeof Symbol("bar")!="symbol"?!1:Vs()},ii={foo:{}},Ys=Object,Ks=function(){return{__proto__:ii}.foo===ii.foo&&!({__proto__:null}instanceof Ys)},Xs="Function.prototype.bind called on incompatible ",Ct=Array.prototype.slice,Js=Object.prototype.toString,Qs="[object Function]",Zs=function(r){var t=this;if(typeof t!="function"||Js.call(t)!==Qs)throw new TypeError(Xs+t);for(var n=Ct.call(arguments,1),a,s=function(){if(this instanceof a){var _=t.apply(this,n.concat(Ct.call(arguments)));return Object(_)===_?_:this}else return t.apply(r,n.concat(Ct.call(arguments)))},c=Math.max(0,t.length-n.length),p=[],h=0;h<c;h++)p.push("$"+h);if(a=Function("binder","return function ("+p.join(",")+"){ return binder.apply(this,arguments); }")(s),t.prototype){var v=function(){};v.prototype=t.prototype,a.prototype=new v,v.prototype=null}return a},eu=Zs,Ut=Function.prototype.bind||eu,ru=Ut,tu=ru.call(Function.call,Object.prototype.hasOwnProperty),U,Qe=SyntaxError,oi=Function,Ze=TypeError,Dt=function(e){try{return oi('"use strict"; return ('+e+").constructor;")()}catch{}},ke=Object.getOwnPropertyDescriptor;if(ke)try{ke({},"")}catch{ke=null}var Nt=function(){throw new Ze},nu=ke?function(){try{return arguments.callee,Nt}catch{try{return ke(arguments,"callee").get}catch{return Nt}}}():Nt,er=Hs(),iu=Ks(),Y=Object.getPrototypeOf||(iu?function(e){return e.__proto__}:null),rr={},ou=typeof Uint8Array>"u"||!Y?U:Y(Uint8Array),Ge={"%AggregateError%":typeof AggregateError>"u"?U:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer>"u"?U:ArrayBuffer,"%ArrayIteratorPrototype%":er&&Y?Y([][Symbol.iterator]()):U,"%AsyncFromSyncIteratorPrototype%":U,"%AsyncFunction%":rr,"%AsyncGenerator%":rr,"%AsyncGeneratorFunction%":rr,"%AsyncIteratorPrototype%":rr,"%Atomics%":typeof Atomics>"u"?U:Atomics,"%BigInt%":typeof BigInt>"u"?U:BigInt,"%BigInt64Array%":typeof BigInt64Array>"u"?U:BigInt64Array,"%BigUint64Array%":typeof BigUint64Array>"u"?U:BigUint64Array,"%Boolean%":Boolean,"%DataView%":typeof DataView>"u"?U:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":Error,"%eval%":eval,"%EvalError%":EvalError,"%Float32Array%":typeof Float32Array>"u"?U:Float32Array,"%Float64Array%":typeof Float64Array>"u"?U:Float64Array,"%FinalizationRegistry%":typeof FinalizationRegistry>"u"?U:FinalizationRegistry,"%Function%":oi,"%GeneratorFunction%":rr,"%Int8Array%":typeof Int8Array>"u"?U:Int8Array,"%Int16Array%":typeof Int16Array>"u"?U:Int16Array,"%Int32Array%":typeof Int32Array>"u"?U:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":er&&Y?Y(Y([][Symbol.iterator]())):U,"%JSON%":typeof JSON=="object"?JSON:U,"%Map%":typeof Map>"u"?U:Map,"%MapIteratorPrototype%":typeof Map>"u"||!er||!Y?U:Y(new Map()[Symbol.iterator]()),"%Math%":Math,"%Number%":Number,"%Object%":Object,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise>"u"?U:Promise,"%Proxy%":typeof Proxy>"u"?U:Proxy,"%RangeError%":RangeError,"%ReferenceError%":ReferenceError,"%Reflect%":typeof Reflect>"u"?U:Reflect,"%RegExp%":RegExp,"%Set%":typeof Set>"u"?U:Set,"%SetIteratorPrototype%":typeof Set>"u"||!er||!Y?U:Y(new Set()[Symbol.iterator]()),"%SharedArrayBuffer%":typeof SharedArrayBuffer>"u"?U:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":er&&Y?Y(""[Symbol.iterator]()):U,"%Symbol%":er?Symbol:U,"%SyntaxError%":Qe,"%ThrowTypeError%":nu,"%TypedArray%":ou,"%TypeError%":Ze,"%Uint8Array%":typeof Uint8Array>"u"?U:Uint8Array,"%Uint8ClampedArray%":typeof Uint8ClampedArray>"u"?U:Uint8ClampedArray,"%Uint16Array%":typeof Uint16Array>"u"?U:Uint16Array,"%Uint32Array%":typeof Uint32Array>"u"?U:Uint32Array,"%URIError%":URIError,"%WeakMap%":typeof WeakMap>"u"?U:WeakMap,"%WeakRef%":typeof WeakRef>"u"?U:WeakRef,"%WeakSet%":typeof WeakSet>"u"?U:WeakSet};if(Y)try{null.error}catch(e){var au=Y(Y(e));Ge["%Error.prototype%"]=au}var su=function e(r){var t;if(r==="%AsyncFunction%")t=Dt("async function () {}");else if(r==="%GeneratorFunction%")t=Dt("function* () {}");else if(r==="%AsyncGeneratorFunction%")t=Dt("async function* () {}");else if(r==="%AsyncGenerator%"){var n=e("%AsyncGeneratorFunction%");n&&(t=n.prototype)}else if(r==="%AsyncIteratorPrototype%"){var a=e("%AsyncGenerator%");a&&Y&&(t=Y(a.prototype))}return Ge[r]=t,t},ai={"%ArrayBufferPrototype%":["ArrayBuffer","prototype"],"%ArrayPrototype%":["Array","prototype"],"%ArrayProto_entries%":["Array","prototype","entries"],"%ArrayProto_forEach%":["Array","prototype","forEach"],"%ArrayProto_keys%":["Array","prototype","keys"],"%ArrayProto_values%":["Array","prototype","values"],"%AsyncFunctionPrototype%":["AsyncFunction","prototype"],"%AsyncGenerator%":["AsyncGeneratorFunction","prototype"],"%AsyncGeneratorPrototype%":["AsyncGeneratorFunction","prototype","prototype"],"%BooleanPrototype%":["Boolean","prototype"],"%DataViewPrototype%":["DataView","prototype"],"%DatePrototype%":["Date","prototype"],"%ErrorPrototype%":["Error","prototype"],"%EvalErrorPrototype%":["EvalError","prototype"],"%Float32ArrayPrototype%":["Float32Array","prototype"],"%Float64ArrayPrototype%":["Float64Array","prototype"],"%FunctionPrototype%":["Function","prototype"],"%Generator%":["GeneratorFunction","prototype"],"%GeneratorPrototype%":["GeneratorFunction","prototype","prototype"],"%Int8ArrayPrototype%":["Int8Array","prototype"],"%Int16ArrayPrototype%":["Int16Array","prototype"],"%Int32ArrayPrototype%":["Int32Array","prototype"],"%JSONParse%":["JSON","parse"],"%JSONStringify%":["JSON","stringify"],"%MapPrototype%":["Map","prototype"],"%NumberPrototype%":["Number","prototype"],"%ObjectPrototype%":["Object","prototype"],"%ObjProto_toString%":["Object","prototype","toString"],"%ObjProto_valueOf%":["Object","prototype","valueOf"],"%PromisePrototype%":["Promise","prototype"],"%PromiseProto_then%":["Promise","prototype","then"],"%Promise_all%":["Promise","all"],"%Promise_reject%":["Promise","reject"],"%Promise_resolve%":["Promise","resolve"],"%RangeErrorPrototype%":["RangeError","prototype"],"%ReferenceErrorPrototype%":["ReferenceError","prototype"],"%RegExpPrototype%":["RegExp","prototype"],"%SetPrototype%":["Set","prototype"],"%SharedArrayBufferPrototype%":["SharedArrayBuffer","prototype"],"%StringPrototype%":["String","prototype"],"%SymbolPrototype%":["Symbol","prototype"],"%SyntaxErrorPrototype%":["SyntaxError","prototype"],"%TypedArrayPrototype%":["TypedArray","prototype"],"%TypeErrorPrototype%":["TypeError","prototype"],"%Uint8ArrayPrototype%":["Uint8Array","prototype"],"%Uint8ClampedArrayPrototype%":["Uint8ClampedArray","prototype"],"%Uint16ArrayPrototype%":["Uint16Array","prototype"],"%Uint32ArrayPrototype%":["Uint32Array","prototype"],"%URIErrorPrototype%":["URIError","prototype"],"%WeakMapPrototype%":["WeakMap","prototype"],"%WeakSetPrototype%":["WeakSet","prototype"]},_r=Ut,kr=tu,uu=_r.call(Function.call,Array.prototype.concat),cu=_r.call(Function.apply,Array.prototype.splice),si=_r.call(Function.call,String.prototype.replace),Gr=_r.call(Function.call,String.prototype.slice),fu=_r.call(Function.call,RegExp.prototype.exec),lu=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,pu=/\\(\\)?/g,hu=function(r){var t=Gr(r,0,1),n=Gr(r,-1);if(t==="%"&&n!=="%")throw new Qe("invalid intrinsic syntax, expected closing `%`");if(n==="%"&&t!=="%")throw new Qe("invalid intrinsic syntax, expected opening `%`");var a=[];return si(r,lu,function(s,c,p,h){a[a.length]=p?si(h,pu,"$1"):c||s}),a},du=function(r,t){var n=r,a;if(kr(ai,n)&&(a=ai[n],n="%"+a[0]+"%"),kr(Ge,n)){var s=Ge[n];if(s===rr&&(s=su(n)),typeof s>"u"&&!t)throw new Ze("intrinsic "+r+" exists, but is not available. Please file an issue!");return{alias:a,name:n,value:s}}throw new Qe("intrinsic "+r+" does not exist!")},Lt=function(r,t){if(typeof r!="string"||r.length===0)throw new Ze("intrinsic name must be a non-empty string");if(arguments.length>1&&typeof t!="boolean")throw new Ze('"allowMissing" argument must be a boolean');if(fu(/^%?[^%]*%?$/,r)===null)throw new Qe("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var n=hu(r),a=n.length>0?n[0]:"",s=du("%"+a+"%",t),c=s.name,p=s.value,h=!1,v=s.alias;v&&(a=v[0],cu(n,uu([0,1],v)));for(var _=1,w=!0;_<n.length;_+=1){var b=n[_],d=Gr(b,0,1),E=Gr(b,-1);if((d==='"'||d==="'"||d==="`"||E==='"'||E==="'"||E==="`")&&d!==E)throw new Qe("property names with quotes must have matching quotes");if((b==="constructor"||!w)&&(h=!0),a+="."+b,c="%"+a+"%",kr(Ge,c))p=Ge[c];else if(p!=null){if(!(b in p)){if(!t)throw new Ze("base intrinsic for "+r+" exists, but the property is not available.");return}if(ke&&_+1>=n.length){var x=ke(p,b);w=!!x,w&&"get"in x&&!("originalValue"in x.get)?p=x.get:p=p[b]}else w=kr(p,b),p=p[b];w&&!h&&(Ge[c]=p)}}return p},ui={exports:{}};(function(e){var r=Ut,t=Lt,n=t("%Function.prototype.apply%"),a=t("%Function.prototype.call%"),s=t("%Reflect.apply%",!0)||r.call(a,n),c=t("%Object.getOwnPropertyDescriptor%",!0),p=t("%Object.defineProperty%",!0),h=t("%Math.max%");if(p)try{p({},"a",{value:1})}catch{p=null}e.exports=function(w){var b=s(r,a,arguments);if(c&&p){var d=c(b,"length");d.configurable&&p(b,"length",{value:1+h(0,w.length-(arguments.length-1))})}return b};var v=function(){return s(r,n,arguments)};p?p(e.exports,"apply",{value:v}):e.exports.apply=v})(ui);var ci=Lt,fi=ui.exports,yu=fi(ci("String.prototype.indexOf")),gu=function(r,t){var n=ci(r,!!t);return typeof n=="function"&&yu(r,".prototype.")>-1?fi(n):n},tr=typeof global<"u"?global:typeof self<"u"?self:typeof window<"u"?window:{},ye=[],fe=[],vu=typeof Uint8Array<"u"?Uint8Array:Array,Mt=!1;function li(){Mt=!0;for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",r=0,t=e.length;r<t;++r)ye[r]=e[r],fe[e.charCodeAt(r)]=r;fe["-".charCodeAt(0)]=62,fe["_".charCodeAt(0)]=63}function mu(e){Mt||li();var r,t,n,a,s,c,p=e.length;if(p%4>0)throw new Error("Invalid string. Length must be a multiple of 4");s=e[p-2]==="="?2:e[p-1]==="="?1:0,c=new vu(p*3/4-s),n=s>0?p-4:p;var h=0;for(r=0,t=0;r<n;r+=4,t+=3)a=fe[e.charCodeAt(r)]<<18|fe[e.charCodeAt(r+1)]<<12|fe[e.charCodeAt(r+2)]<<6|fe[e.charCodeAt(r+3)],c[h++]=a>>16&255,c[h++]=a>>8&255,c[h++]=a&255;return s===2?(a=fe[e.charCodeAt(r)]<<2|fe[e.charCodeAt(r+1)]>>4,c[h++]=a&255):s===1&&(a=fe[e.charCodeAt(r)]<<10|fe[e.charCodeAt(r+1)]<<4|fe[e.charCodeAt(r+2)]>>2,c[h++]=a>>8&255,c[h++]=a&255),c}function _u(e){return ye[e>>18&63]+ye[e>>12&63]+ye[e>>6&63]+ye[e&63]}function wu(e,r,t){for(var n,a=[],s=r;s<t;s+=3)n=(e[s]<<16)+(e[s+1]<<8)+e[s+2],a.push(_u(n));return a.join("")}function pi(e){Mt||li();for(var r,t=e.length,n=t%3,a="",s=[],c=16383,p=0,h=t-n;p<h;p+=c)s.push(wu(e,p,p+c>h?h:p+c));return n===1?(r=e[t-1],a+=ye[r>>2],a+=ye[r<<4&63],a+="=="):n===2&&(r=(e[t-2]<<8)+e[t-1],a+=ye[r>>10],a+=ye[r>>4&63],a+=ye[r<<2&63],a+="="),s.push(a),s.join("")}function Wr(e,r,t,n,a){var s,c,p=a*8-n-1,h=(1<<p)-1,v=h>>1,_=-7,w=t?a-1:0,b=t?-1:1,d=e[r+w];for(w+=b,s=d&(1<<-_)-1,d>>=-_,_+=p;_>0;s=s*256+e[r+w],w+=b,_-=8);for(c=s&(1<<-_)-1,s>>=-_,_+=n;_>0;c=c*256+e[r+w],w+=b,_-=8);if(s===0)s=1-v;else{if(s===h)return c?NaN:(d?-1:1)*(1/0);c=c+Math.pow(2,n),s=s-v}return(d?-1:1)*c*Math.pow(2,s-n)}function hi(e,r,t,n,a,s){var c,p,h,v=s*8-a-1,_=(1<<v)-1,w=_>>1,b=a===23?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:s-1,E=n?1:-1,x=r<0||r===0&&1/r<0?1:0;for(r=Math.abs(r),isNaN(r)||r===1/0?(p=isNaN(r)?1:0,c=_):(c=Math.floor(Math.log(r)/Math.LN2),r*(h=Math.pow(2,-c))<1&&(c--,h*=2),c+w>=1?r+=b/h:r+=b*Math.pow(2,1-w),r*h>=2&&(c++,h/=2),c+w>=_?(p=0,c=_):c+w>=1?(p=(r*h-1)*Math.pow(2,a),c=c+w):(p=r*Math.pow(2,w-1)*Math.pow(2,a),c=0));a>=8;e[t+d]=p&255,d+=E,p/=256,a-=8);for(c=c<<a|p,v+=a;v>0;e[t+d]=c&255,d+=E,c/=256,v-=8);e[t+d-E]|=x*128}var bu={}.toString,di=Array.isArray||function(e){return bu.call(e)=="[object Array]"};/*!
4
4
  * The buffer module from node.js, for the browser.
@@ -17,6 +17,6 @@
17
17
  `)+" "+t[1]:t[0]+r+" "+e.join(", ")+" "+t[1]}function Yt(e){return Array.isArray(e)}function et(e){return typeof e=="boolean"}function wr(e){return e===null}function Ui(e){return e==null}function Kt(e){return typeof e=="number"}function br(e){return typeof e=="string"}function Di(e){return typeof e=="symbol"}function me(e){return e===void 0}function $r(e){return Ve(e)&&Xt(e)==="[object RegExp]"}function Ve(e){return typeof e=="object"&&e!==null}function rt(e){return Ve(e)&&Xt(e)==="[object Date]"}function Ar(e){return Ve(e)&&(Xt(e)==="[object Error]"||e instanceof Error)}function Er(e){return typeof e=="function"}function Ni(e){return e===null||typeof e=="boolean"||typeof e=="number"||typeof e=="string"||typeof e=="symbol"||typeof e>"u"}function Li(e){return $.isBuffer(e)}function Xt(e){return Object.prototype.toString.call(e)}function Jt(e){return e<10?"0"+e.toString(10):e.toString(10)}var Tc=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function Oc(){var e=new Date,r=[Jt(e.getHours()),Jt(e.getMinutes()),Jt(e.getSeconds())].join(":");return[e.getDate(),Tc[e.getMonth()],r].join(" ")}function Mi(){console.log("%s - %s",Oc(),Jr.apply(null,arguments))}function Qt(e,r){if(!r||!Ve(r))return e;for(var t=Object.keys(r),n=t.length;n--;)e[t[n]]=r[t[n]];return e}function ji(e,r){return Object.prototype.hasOwnProperty.call(e,r)}var Bc={inherits:Fi,_extend:Qt,log:Mi,isBuffer:Li,isPrimitive:Ni,isFunction:Er,isError:Ar,isDate:rt,isObject:Ve,isRegExp:$r,isUndefined:me,isSymbol:Di,isString:br,isNumber:Kt,isNullOrUndefined:Ui,isNull:wr,isBoolean:et,isArray:Yt,inspect:ve,deprecate:qt,format:Jr,debuglog:Ci},Pc=Object.freeze({__proto__:null,format:Jr,deprecate:qt,debuglog:Ci,inspect:ve,isArray:Yt,isBoolean:et,isNull:wr,isNullOrUndefined:Ui,isNumber:Kt,isString:br,isSymbol:Di,isUndefined:me,isRegExp:$r,isObject:Ve,isDate:rt,isError:Ar,isFunction:Er,isPrimitive:Ni,isBuffer:Li,log:Mi,inherits:Fi,_extend:Qt,default:Bc}),Rc=vr(Pc),Fc=Rc.inspect,Zt=typeof Map=="function"&&Map.prototype,en=Object.getOwnPropertyDescriptor&&Zt?Object.getOwnPropertyDescriptor(Map.prototype,"size"):null,tt=Zt&&en&&typeof en.get=="function"?en.get:null,ki=Zt&&Map.prototype.forEach,rn=typeof Set=="function"&&Set.prototype,tn=Object.getOwnPropertyDescriptor&&rn?Object.getOwnPropertyDescriptor(Set.prototype,"size"):null,nt=rn&&tn&&typeof tn.get=="function"?tn.get:null,Gi=rn&&Set.prototype.forEach,Cc=typeof WeakMap=="function"&&WeakMap.prototype,Sr=Cc?WeakMap.prototype.has:null,Uc=typeof WeakSet=="function"&&WeakSet.prototype,xr=Uc?WeakSet.prototype.has:null,Dc=typeof WeakRef=="function"&&WeakRef.prototype,Wi=Dc?WeakRef.prototype.deref:null,Nc=Boolean.prototype.valueOf,Lc=Object.prototype.toString,Mc=Function.prototype.toString,jc=String.prototype.match,nn=String.prototype.slice,Re=String.prototype.replace,kc=String.prototype.toUpperCase,qi=String.prototype.toLowerCase,zi=RegExp.prototype.test,Vi=Array.prototype.concat,_e=Array.prototype.join,Gc=Array.prototype.slice,Hi=Math.floor,on=typeof BigInt=="function"?BigInt.prototype.valueOf:null,an=Object.getOwnPropertySymbols,sn=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Symbol.prototype.toString:null,or=typeof Symbol=="function"&&typeof Symbol.iterator=="object",ee=typeof Symbol=="function"&&Symbol.toStringTag&&(typeof Symbol.toStringTag===or||"symbol")?Symbol.toStringTag:null,Yi=Object.prototype.propertyIsEnumerable,Ki=(typeof Reflect=="function"?Reflect.getPrototypeOf:Object.getPrototypeOf)||([].__proto__===Array.prototype?function(e){return e.__proto__}:null);function Xi(e,r){if(e===1/0||e===-1/0||e!==e||e&&e>-1e3&&e<1e3||zi.call(/e/,r))return r;var t=/[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;if(typeof e=="number"){var n=e<0?-Hi(-e):Hi(e);if(n!==e){var a=String(n),s=nn.call(r,a.length+1);return Re.call(a,t,"$&_")+"."+Re.call(Re.call(s,/([0-9]{3})/g,"$&_"),/_$/,"")}}return Re.call(r,t,"$&_")}var un=Fc,Ji=un.custom,Qi=ro(Ji)?Ji:null,Wc=function e(r,t,n,a){var s=t||{};if(Fe(s,"quoteStyle")&&s.quoteStyle!=="single"&&s.quoteStyle!=="double")throw new TypeError('option "quoteStyle" must be "single" or "double"');if(Fe(s,"maxStringLength")&&(typeof s.maxStringLength=="number"?s.maxStringLength<0&&s.maxStringLength!==1/0:s.maxStringLength!==null))throw new TypeError('option "maxStringLength", if provided, must be a positive integer, Infinity, or `null`');var c=Fe(s,"customInspect")?s.customInspect:!0;if(typeof c!="boolean"&&c!=="symbol")throw new TypeError("option \"customInspect\", if provided, must be `true`, `false`, or `'symbol'`");if(Fe(s,"indent")&&s.indent!==null&&s.indent!==" "&&!(parseInt(s.indent,10)===s.indent&&s.indent>0))throw new TypeError('option "indent" must be "\\t", an integer > 0, or `null`');if(Fe(s,"numericSeparator")&&typeof s.numericSeparator!="boolean")throw new TypeError('option "numericSeparator", if provided, must be `true` or `false`');var p=s.numericSeparator;if(typeof r>"u")return"undefined";if(r===null)return"null";if(typeof r=="boolean")return r?"true":"false";if(typeof r=="string")return no(r,s);if(typeof r=="number"){if(r===0)return 1/0/r>0?"0":"-0";var h=String(r);return p?Xi(r,h):h}if(typeof r=="bigint"){var v=String(r)+"n";return p?Xi(r,v):v}var _=typeof s.depth>"u"?5:s.depth;if(typeof n>"u"&&(n=0),n>=_&&_>0&&typeof r=="object")return cn(r)?"[Array]":"[Object]";var w=uf(s,n);if(typeof a>"u")a=[];else if(to(a,r)>=0)return"[Circular]";function b(k,re,N){if(re&&(a=Gc.call(a),a.push(re)),N){var ce={depth:s.depth};return Fe(s,"quoteStyle")&&(ce.quoteStyle=s.quoteStyle),e(k,ce,n+1,a)}return e(k,s,n+1,a)}if(typeof r=="function"&&!eo(r)){var d=Qc(r),E=it(r,b);return"[Function"+(d?": "+d:" (anonymous)")+"]"+(E.length>0?" { "+_e.call(E,", ")+" }":"")}if(ro(r)){var x=or?Re.call(String(r),/^(Symbol\(.*\))_[^)]*$/,"$1"):sn.call(r);return typeof r=="object"&&!or?Ir(x):x}if(of(r)){for(var I="<"+qi.call(String(r.nodeName)),S=r.attributes||[],T=0;T<S.length;T++)I+=" "+S[T].name+"="+Zi(qc(S[T].value),"double",s);return I+=">",r.childNodes&&r.childNodes.length&&(I+="..."),I+="</"+qi.call(String(r.nodeName))+">",I}if(cn(r)){if(r.length===0)return"[]";var P=it(r,b);return w&&!sf(P)?"["+ln(P,w)+"]":"[ "+_e.call(P,", ")+" ]"}if(Vc(r)){var B=it(r,b);return!("cause"in Error.prototype)&&"cause"in r&&!Yi.call(r,"cause")?"{ ["+String(r)+"] "+_e.call(Vi.call("[cause]: "+b(r.cause),B),", ")+" }":B.length===0?"["+String(r)+"]":"{ ["+String(r)+"] "+_e.call(B,", ")+" }"}if(typeof r=="object"&&c){if(Qi&&typeof r[Qi]=="function"&&un)return un(r,{depth:_-n});if(c!=="symbol"&&typeof r.inspect=="function")return r.inspect()}if(Zc(r)){var D=[];return ki&&ki.call(r,function(k,re){D.push(b(re,r,!0)+" => "+b(k,r))}),io("Map",tt.call(r),D,w)}if(tf(r)){var j=[];return Gi&&Gi.call(r,function(k){j.push(b(k,r))}),io("Set",nt.call(r),j,w)}if(ef(r))return fn("WeakMap");if(nf(r))return fn("WeakSet");if(rf(r))return fn("WeakRef");if(Yc(r))return Ir(b(Number(r)));if(Xc(r))return Ir(b(on.call(r)));if(Kc(r))return Ir(Nc.call(r));if(Hc(r))return Ir(b(String(r)));if(!zc(r)&&!eo(r)){var q=it(r,b),z=Ki?Ki(r)===Object.prototype:r instanceof Object||r.constructor===Object,X=r instanceof Object?"":"null prototype",V=!z&&ee&&Object(r)===r&&ee in r?nn.call(Ce(r),8,-1):X?"Object":"",ae=z||typeof r.constructor!="function"?"":r.constructor.name?r.constructor.name+" ":"",ue=ae+(V||X?"["+_e.call(Vi.call([],V||[],X||[]),": ")+"] ":"");return q.length===0?ue+"{}":w?ue+"{"+ln(q,w)+"}":ue+"{ "+_e.call(q,", ")+" }"}return String(r)};function Zi(e,r,t){var n=(t.quoteStyle||r)==="double"?'"':"'";return n+e+n}function qc(e){return Re.call(String(e),/"/g,"&quot;")}function cn(e){return Ce(e)==="[object Array]"&&(!ee||!(typeof e=="object"&&ee in e))}function zc(e){return Ce(e)==="[object Date]"&&(!ee||!(typeof e=="object"&&ee in e))}function eo(e){return Ce(e)==="[object RegExp]"&&(!ee||!(typeof e=="object"&&ee in e))}function Vc(e){return Ce(e)==="[object Error]"&&(!ee||!(typeof e=="object"&&ee in e))}function Hc(e){return Ce(e)==="[object String]"&&(!ee||!(typeof e=="object"&&ee in e))}function Yc(e){return Ce(e)==="[object Number]"&&(!ee||!(typeof e=="object"&&ee in e))}function Kc(e){return Ce(e)==="[object Boolean]"&&(!ee||!(typeof e=="object"&&ee in e))}function ro(e){if(or)return e&&typeof e=="object"&&e instanceof Symbol;if(typeof e=="symbol")return!0;if(!e||typeof e!="object"||!sn)return!1;try{return sn.call(e),!0}catch{}return!1}function Xc(e){if(!e||typeof e!="object"||!on)return!1;try{return on.call(e),!0}catch{}return!1}var Jc=Object.prototype.hasOwnProperty||function(e){return e in this};function Fe(e,r){return Jc.call(e,r)}function Ce(e){return Lc.call(e)}function Qc(e){if(e.name)return e.name;var r=jc.call(Mc.call(e),/^function\s*([\w$]+)/);return r?r[1]:null}function to(e,r){if(e.indexOf)return e.indexOf(r);for(var t=0,n=e.length;t<n;t++)if(e[t]===r)return t;return-1}function Zc(e){if(!tt||!e||typeof e!="object")return!1;try{tt.call(e);try{nt.call(e)}catch{return!0}return e instanceof Map}catch{}return!1}function ef(e){if(!Sr||!e||typeof e!="object")return!1;try{Sr.call(e,Sr);try{xr.call(e,xr)}catch{return!0}return e instanceof WeakMap}catch{}return!1}function rf(e){if(!Wi||!e||typeof e!="object")return!1;try{return Wi.call(e),!0}catch{}return!1}function tf(e){if(!nt||!e||typeof e!="object")return!1;try{nt.call(e);try{tt.call(e)}catch{return!0}return e instanceof Set}catch{}return!1}function nf(e){if(!xr||!e||typeof e!="object")return!1;try{xr.call(e,xr);try{Sr.call(e,Sr)}catch{return!0}return e instanceof WeakSet}catch{}return!1}function of(e){return!e||typeof e!="object"?!1:typeof HTMLElement<"u"&&e instanceof HTMLElement?!0:typeof e.nodeName=="string"&&typeof e.getAttribute=="function"}function no(e,r){if(e.length>r.maxStringLength){var t=e.length-r.maxStringLength,n="... "+t+" more character"+(t>1?"s":"");return no(nn.call(e,0,r.maxStringLength),r)+n}var a=Re.call(Re.call(e,/(['\\])/g,"\\$1"),/[\x00-\x1f]/g,af);return Zi(a,"single",r)}function af(e){var r=e.charCodeAt(0),t={8:"b",9:"t",10:"n",12:"f",13:"r"}[r];return t?"\\"+t:"\\x"+(r<16?"0":"")+kc.call(r.toString(16))}function Ir(e){return"Object("+e+")"}function fn(e){return e+" { ? }"}function io(e,r,t,n){var a=n?ln(t,n):_e.call(t,", ");return e+" ("+r+") {"+a+"}"}function sf(e){for(var r=0;r<e.length;r++)if(to(e[r],`
18
18
  `)>=0)return!1;return!0}function uf(e,r){var t;if(e.indent===" ")t=" ";else if(typeof e.indent=="number"&&e.indent>0)t=_e.call(Array(e.indent+1)," ");else return null;return{base:t,prev:_e.call(Array(r+1),t)}}function ln(e,r){if(e.length===0)return"";var t=`
19
19
  `+r.prev+r.base;return t+_e.call(e,","+t)+`
20
- `+r.prev}function it(e,r){var t=cn(e),n=[];if(t){n.length=e.length;for(var a=0;a<e.length;a++)n[a]=Fe(e,a)?r(e[a],e):""}var s=typeof an=="function"?an(e):[],c;if(or){c={};for(var p=0;p<s.length;p++)c["$"+s[p]]=s[p]}for(var h in e)Fe(e,h)&&(t&&String(Number(h))===h&&h<e.length||or&&c["$"+h]instanceof Symbol||(zi.call(/[^\w$]/,h)?n.push(r(h,e)+": "+r(e[h],e)):n.push(h+": "+r(e[h],e))));if(typeof an=="function")for(var v=0;v<s.length;v++)Yi.call(e,s[v])&&n.push("["+r(s[v])+"]: "+r(e[s[v]],e));return n}var pn=Lt,ar=gu,cf=Wc,ff=pn("%TypeError%"),ot=pn("%WeakMap%",!0),at=pn("%Map%",!0),lf=ar("WeakMap.prototype.get",!0),pf=ar("WeakMap.prototype.set",!0),hf=ar("WeakMap.prototype.has",!0),df=ar("Map.prototype.get",!0),yf=ar("Map.prototype.set",!0),gf=ar("Map.prototype.has",!0),hn=function(e,r){for(var t=e,n;(n=t.next)!==null;t=n)if(n.key===r)return t.next=n.next,n.next=e.next,e.next=n,n},vf=function(e,r){var t=hn(e,r);return t&&t.value},mf=function(e,r,t){var n=hn(e,r);n?n.value=t:e.next={key:r,next:e.next,value:t}},_f=function(e,r){return!!hn(e,r)},wf=function(){var r,t,n,a={assert:function(s){if(!a.has(s))throw new ff("Side channel does not contain "+cf(s))},get:function(s){if(ot&&s&&(typeof s=="object"||typeof s=="function")){if(r)return lf(r,s)}else if(at){if(t)return df(t,s)}else if(n)return vf(n,s)},has:function(s){if(ot&&s&&(typeof s=="object"||typeof s=="function")){if(r)return hf(r,s)}else if(at){if(t)return gf(t,s)}else if(n)return _f(n,s);return!1},set:function(s,c){ot&&s&&(typeof s=="object"||typeof s=="function")?(r||(r=new ot),pf(r,s,c)):at?(t||(t=new at),yf(t,s,c)):(n||(n={key:{},next:null}),mf(n,s,c))}};return a},bf=String.prototype.replace,$f=/%20/g,dn={RFC1738:"RFC1738",RFC3986:"RFC3986"},oo={default:dn.RFC3986,formatters:{RFC1738:function(e){return bf.call(e,$f,"+")},RFC3986:function(e){return String(e)}},RFC1738:dn.RFC1738,RFC3986:dn.RFC3986},Af=oo,yn=Object.prototype.hasOwnProperty,He=Array.isArray,we=function(){for(var e=[],r=0;r<256;++r)e.push("%"+((r<16?"0":"")+r.toString(16)).toUpperCase());return e}(),Ef=function(r){for(;r.length>1;){var t=r.pop(),n=t.obj[t.prop];if(He(n)){for(var a=[],s=0;s<n.length;++s)typeof n[s]<"u"&&a.push(n[s]);t.obj[t.prop]=a}}},ao=function(r,t){for(var n=t&&t.plainObjects?Object.create(null):{},a=0;a<r.length;++a)typeof r[a]<"u"&&(n[a]=r[a]);return n},Sf=function e(r,t,n){if(!t)return r;if(typeof t!="object"){if(He(r))r.push(t);else if(r&&typeof r=="object")(n&&(n.plainObjects||n.allowPrototypes)||!yn.call(Object.prototype,t))&&(r[t]=!0);else return[r,t];return r}if(!r||typeof r!="object")return[r].concat(t);var a=r;return He(r)&&!He(t)&&(a=ao(r,n)),He(r)&&He(t)?(t.forEach(function(s,c){if(yn.call(r,c)){var p=r[c];p&&typeof p=="object"&&s&&typeof s=="object"?r[c]=e(p,s,n):r.push(s)}else r[c]=s}),r):Object.keys(t).reduce(function(s,c){var p=t[c];return yn.call(s,c)?s[c]=e(s[c],p,n):s[c]=p,s},a)},xf=function(r,t){return Object.keys(t).reduce(function(n,a){return n[a]=t[a],n},r)},If=function(e,r,t){var n=e.replace(/\+/g," ");if(t==="iso-8859-1")return n.replace(/%[0-9a-f]{2}/gi,unescape);try{return decodeURIComponent(n)}catch{return n}},Tf=function(r,t,n,a,s){if(r.length===0)return r;var c=r;if(typeof r=="symbol"?c=Symbol.prototype.toString.call(r):typeof r!="string"&&(c=String(r)),n==="iso-8859-1")return escape(c).replace(/%u[0-9a-f]{4}/gi,function(_){return"%26%23"+parseInt(_.slice(2),16)+"%3B"});for(var p="",h=0;h<c.length;++h){var v=c.charCodeAt(h);if(v===45||v===46||v===95||v===126||v>=48&&v<=57||v>=65&&v<=90||v>=97&&v<=122||s===Af.RFC1738&&(v===40||v===41)){p+=c.charAt(h);continue}if(v<128){p=p+we[v];continue}if(v<2048){p=p+(we[192|v>>6]+we[128|v&63]);continue}if(v<55296||v>=57344){p=p+(we[224|v>>12]+we[128|v>>6&63]+we[128|v&63]);continue}h+=1,v=65536+((v&1023)<<10|c.charCodeAt(h)&1023),p+=we[240|v>>18]+we[128|v>>12&63]+we[128|v>>6&63]+we[128|v&63]}return p},Of=function(r){for(var t=[{obj:{o:r},prop:"o"}],n=[],a=0;a<t.length;++a)for(var s=t[a],c=s.obj[s.prop],p=Object.keys(c),h=0;h<p.length;++h){var v=p[h],_=c[v];typeof _=="object"&&_!==null&&n.indexOf(_)===-1&&(t.push({obj:c,prop:v}),n.push(_))}return Ef(t),r},Bf=function(r){return Object.prototype.toString.call(r)==="[object RegExp]"},Pf=function(r){return!r||typeof r!="object"?!1:!!(r.constructor&&r.constructor.isBuffer&&r.constructor.isBuffer(r))},Rf=function(r,t){return[].concat(r,t)},Ff=function(r,t){if(He(r)){for(var n=[],a=0;a<r.length;a+=1)n.push(t(r[a]));return n}return t(r)},Cf={arrayToObject:ao,assign:xf,combine:Rf,compact:Of,decode:If,encode:Tf,isBuffer:Pf,isRegExp:Bf,maybeMap:Ff,merge:Sf},so=wf,gn=Cf,Tr=oo,Uf=Object.prototype.hasOwnProperty,uo={brackets:function(r){return r+"[]"},comma:"comma",indices:function(r,t){return r+"["+t+"]"},repeat:function(r){return r}},xe=Array.isArray,Df=String.prototype.split,Nf=Array.prototype.push,co=function(e,r){Nf.apply(e,xe(r)?r:[r])},Lf=Date.prototype.toISOString,fo=Tr.default,J={addQueryPrefix:!1,allowDots:!1,charset:"utf-8",charsetSentinel:!1,delimiter:"&",encode:!0,encoder:gn.encode,encodeValuesOnly:!1,format:fo,formatter:Tr.formatters[fo],indices:!1,serializeDate:function(r){return Lf.call(r)},skipNulls:!1,strictNullHandling:!1},Mf=function(r){return typeof r=="string"||typeof r=="number"||typeof r=="boolean"||typeof r=="symbol"||typeof r=="bigint"},vn={},jf=function e(r,t,n,a,s,c,p,h,v,_,w,b,d,E,x,I){for(var S=r,T=I,P=0,B=!1;(T=T.get(vn))!==void 0&&!B;){var D=T.get(r);if(P+=1,typeof D<"u"){if(D===P)throw new RangeError("Cyclic object value");B=!0}typeof T.get(vn)>"u"&&(P=0)}if(typeof h=="function"?S=h(t,S):S instanceof Date?S=w(S):n==="comma"&&xe(S)&&(S=gn.maybeMap(S,function(Ne){return Ne instanceof Date?w(Ne):Ne})),S===null){if(s)return p&&!E?p(t,J.encoder,x,"key",b):t;S=""}if(Mf(S)||gn.isBuffer(S)){if(p){var j=E?t:p(t,J.encoder,x,"key",b);if(n==="comma"&&E){for(var q=Df.call(String(S),","),z="",X=0;X<q.length;++X)z+=(X===0?"":",")+d(p(q[X],J.encoder,x,"value",b));return[d(j)+(a&&xe(S)&&q.length===1?"[]":"")+"="+z]}return[d(j)+"="+d(p(S,J.encoder,x,"value",b))]}return[d(t)+"="+d(String(S))]}var V=[];if(typeof S>"u")return V;var ae;if(n==="comma"&&xe(S))ae=[{value:S.length>0?S.join(",")||null:void 0}];else if(xe(h))ae=h;else{var ue=Object.keys(S);ae=v?ue.sort(v):ue}for(var k=a&&xe(S)&&S.length===1?t+"[]":t,re=0;re<ae.length;++re){var N=ae[re],ce=typeof N=="object"&&typeof N.value<"u"?N.value:S[N];if(!(c&&ce===null)){var hr=xe(S)?typeof n=="function"?n(k,N):k:k+(_?"."+N:"["+N+"]");I.set(r,P);var se=so();se.set(vn,I),co(V,e(ce,hr,n,a,s,c,p,h,v,_,w,b,d,E,x,se))}}return V},kf=function(r){if(!r)return J;if(r.encoder!==null&&typeof r.encoder<"u"&&typeof r.encoder!="function")throw new TypeError("Encoder has to be a function.");var t=r.charset||J.charset;if(typeof r.charset<"u"&&r.charset!=="utf-8"&&r.charset!=="iso-8859-1")throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var n=Tr.default;if(typeof r.format<"u"){if(!Uf.call(Tr.formatters,r.format))throw new TypeError("Unknown format option provided.");n=r.format}var a=Tr.formatters[n],s=J.filter;return(typeof r.filter=="function"||xe(r.filter))&&(s=r.filter),{addQueryPrefix:typeof r.addQueryPrefix=="boolean"?r.addQueryPrefix:J.addQueryPrefix,allowDots:typeof r.allowDots>"u"?J.allowDots:!!r.allowDots,charset:t,charsetSentinel:typeof r.charsetSentinel=="boolean"?r.charsetSentinel:J.charsetSentinel,delimiter:typeof r.delimiter>"u"?J.delimiter:r.delimiter,encode:typeof r.encode=="boolean"?r.encode:J.encode,encoder:typeof r.encoder=="function"?r.encoder:J.encoder,encodeValuesOnly:typeof r.encodeValuesOnly=="boolean"?r.encodeValuesOnly:J.encodeValuesOnly,filter:s,format:n,formatter:a,serializeDate:typeof r.serializeDate=="function"?r.serializeDate:J.serializeDate,skipNulls:typeof r.skipNulls=="boolean"?r.skipNulls:J.skipNulls,sort:typeof r.sort=="function"?r.sort:null,strictNullHandling:typeof r.strictNullHandling=="boolean"?r.strictNullHandling:J.strictNullHandling}},Gf=function(e,r){var t=e,n=kf(r),a,s;typeof n.filter=="function"?(s=n.filter,t=s("",t)):xe(n.filter)&&(s=n.filter,a=s);var c=[];if(typeof t!="object"||t===null)return"";var p;r&&r.arrayFormat in uo?p=r.arrayFormat:r&&"indices"in r?p=r.indices?"indices":"repeat":p="indices";var h=uo[p];if(r&&"commaRoundTrip"in r&&typeof r.commaRoundTrip!="boolean")throw new TypeError("`commaRoundTrip` must be a boolean, or absent");var v=h==="comma"&&r&&r.commaRoundTrip;a||(a=Object.keys(t)),n.sort&&a.sort(n.sort);for(var _=so(),w=0;w<a.length;++w){var b=a[w];n.skipNulls&&t[b]===null||co(c,jf(t[b],b,h,v,n.strictNullHandling,n.skipNulls,n.encode?n.encoder:null,n.filter,n.sort,n.allowDots,n.serializeDate,n.format,n.formatter,n.encodeValuesOnly,n.charset,_))}var d=c.join(n.delimiter),E=n.addQueryPrefix===!0?"?":"";return n.charsetSentinel&&(n.charset==="iso-8859-1"?E+="utf8=%26%2310003%3B&":E+="utf8=%E2%9C%93&"),d.length>0?E+d:""};let lo={storeIdentifier:"",environment:"prod"};function Wf(e){lo=e}function be(){return lo}const qf=e=>e==="stage"?"https://api.stage.rechargeapps.com":"https://api.rechargeapps.com",st=e=>e==="stage"?"https://admin.stage.rechargeapps.com":"https://admin.rechargeapps.com",zf=e=>e==="stage"?"https://static.stage.rechargecdn.com":"https://static.rechargecdn.com",Vf="/tools/recurring";class ut{constructor(r,t){this.name="RechargeRequestError",this.message=r,this.status=t}}var Hf=Object.defineProperty,Yf=Object.defineProperties,Kf=Object.getOwnPropertyDescriptors,po=Object.getOwnPropertySymbols,Xf=Object.prototype.hasOwnProperty,Jf=Object.prototype.propertyIsEnumerable,ho=(e,r,t)=>r in e?Hf(e,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[r]=t,ct=(e,r)=>{for(var t in r||(r={}))Xf.call(r,t)&&ho(e,t,r[t]);if(po)for(var t of po(r))Jf.call(r,t)&&ho(e,t,r[t]);return e},Qf=(e,r)=>Yf(e,Kf(r));function Zf(e){return Gf(e,{encode:!1,indices:!1,arrayFormat:"comma"})}async function ft(e,r,t={}){const n=be();return le(e,`${zf(n.environment)}/store/${n.storeIdentifier}${r}`,t)}async function O(e,r,{id:t,query:n,data:a,headers:s}={},c){const{environment:p,storeIdentifier:h,loginRetryFn:v}=be(),_=c.apiToken,w=qf(p),b=ct({"X-Recharge-Access-Token":_,"X-Recharge-Version":"2021-11"},s||{}),d=ct({shop_url:h},n);try{return await le(e,`${w}${r}`,{id:t,query:d,data:a,headers:b})}catch(E){if(v&&E instanceof ut&&E.status===401)return v().then(x=>{if(x)return le(e,`${w}${r}`,{id:t,query:d,data:a,headers:Qf(ct({},b),{"X-Recharge-Access-Token":x.apiToken})});throw E});throw E}}async function Or(e,r,t={}){return le(e,`${Vf}${r}`,t)}async function le(e,r,{id:t,query:n,data:a,headers:s}={}){let c=r.trim();if(t&&(c=[c,`${t}`.trim()].join("/")),n){let w;[c,w]=c.split("?");const b=[w,Zf(n)].join("&").replace(/^&/,"");c=`${c}${b?`?${b}`:""}`}let p;a&&e!=="get"&&(p=JSON.stringify(a));const h=ct({Accept:"application/json","Content-Type":"application/json","X-Recharge-App":"storefront-client"},s||{}),v=await fetch(c,{method:e,headers:h,body:p});let _;try{_=await v.json()}catch{}if(!v.ok)throw _&&_.error?new ut(_.error,v.status):_&&_.errors?new ut(JSON.stringify(_.errors),v.status):new ut("A connection error occurred while making the request");return _}var el=Object.defineProperty,yo=Object.getOwnPropertySymbols,rl=Object.prototype.hasOwnProperty,tl=Object.prototype.propertyIsEnumerable,go=(e,r,t)=>r in e?el(e,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[r]=t,nl=(e,r)=>{for(var t in r||(r={}))rl.call(r,t)&&go(e,t,r[t]);if(yo)for(var t of yo(r))tl.call(r,t)&&go(e,t,r[t]);return e};function il(e,r){return O("get","/addresses",{query:r},e)}async function ol(e,r,t){const{address:n}=await O("get","/addresses",{id:r,query:{include:t?.include}},e);return n}async function al(e,r){const{address:t}=await O("post","/addresses",{data:nl({customer_id:e.customerId?Number(e.customerId):void 0},r)},e);return t}async function mn(e,r,t){const{address:n}=await O("put","/addresses",{id:r,data:t},e);return n}async function sl(e,r,t){return mn(e,r,{discounts:[{code:t}]})}async function ul(e,r){return mn(e,r,{discounts:[]})}function cl(e,r){return O("delete","/addresses",{id:r},e)}async function fl(e,r){const{address:t}=await O("post","/addresses/merge",{data:r},e);return t}async function ll(e,r,t){const{charge:n}=await O("post",`/addresses/${r}/charges/skip`,{data:t},e);return n}var pl=Object.freeze({__proto__:null,listAddresses:il,getAddress:ol,createAddress:al,updateAddress:mn,applyDiscountToAddress:sl,removeDiscountsFromAddress:ul,deleteAddress:cl,mergeAddresses:fl,skipFutureCharge:ll}),hl=Object.defineProperty,vo=Object.getOwnPropertySymbols,dl=Object.prototype.hasOwnProperty,yl=Object.prototype.propertyIsEnumerable,mo=(e,r,t)=>r in e?hl(e,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[r]=t,_o=(e,r)=>{for(var t in r||(r={}))dl.call(r,t)&&mo(e,t,r[t]);if(vo)for(var t of vo(r))yl.call(r,t)&&mo(e,t,r[t]);return e};async function gl(){const{storefrontAccessToken:e}=be(),r={};e&&(r["X-Recharge-Storefront-Access-Token"]=e);const t=await Or("get","/access",{headers:r});return{apiToken:t.api_token,customerId:t.customer_id}}async function vl(e,r){const{environment:t,storefrontAccessToken:n,storeIdentifier:a}=be(),s=st(t),c={};n&&(c["X-Recharge-Storefront-Access-Token"]=n);const p=await le("post",`${s}/shopify_storefront_access`,{data:{customer_token:r,storefront_token:e,shop_url:a},headers:c});return p.api_token?{apiToken:p.api_token,customerId:p.customer_id}:null}async function ml(e,r={}){const{environment:t,storefrontAccessToken:n,storeIdentifier:a}=be(),s=st(t),c={};n&&(c["X-Recharge-Storefront-Access-Token"]=n);const p=await le("post",`${s}/attempt_login`,{data:_o({email:e,shop:a},r),headers:c});if(p.errors)throw new Error(p.errors);return p.session_token}async function _l(e,r={}){const{storefrontAccessToken:t}=be(),n={};t&&(n["X-Recharge-Storefront-Access-Token"]=t);const a=await Or("post","/attempt_login",{data:_o({email:e},r),headers:n});if(a.errors)throw new Error(a.errors);return a.session_token}async function wl(e,r,t){const{environment:n,storefrontAccessToken:a,storeIdentifier:s}=be(),c=st(n),p={};a&&(p["X-Recharge-Storefront-Access-Token"]=a);const h=await le("post",`${c}/validate_login`,{data:{code:t,email:e,session_token:r,shop:s},headers:p});if(h.errors)throw new Error(h.errors);return{apiToken:h.api_token,customerId:h.customer_id}}async function bl(e,r,t){const{storefrontAccessToken:n}=be(),a={};n&&(a["X-Recharge-Storefront-Access-Token"]=n);const s=await Or("post","/validate_login",{data:{code:t,email:e,session_token:r},headers:a});if(s.errors)throw new Error(s.errors);return{apiToken:s.api_token,customerId:s.customer_id}}function $l(){const{pathname:e,search:r}=window.location,t=new URLSearchParams(r).get("token"),n=e.split("/").filter(Boolean),a=n.findIndex(c=>c==="portal"),s=a!==-1?n[a+1]:void 0;if(!t||!s)throw new Error("URL did not contain correct params");return{customerHash:s,token:t}}async function Al(){const{customerHash:e,token:r}=$l(),{environment:t,storefrontAccessToken:n,storeIdentifier:a}=be(),s=st(t),c={};n&&(c["X-Recharge-Storefront-Access-Token"]=n);const p=await le("post",`${s}/customers/${e}/access`,{headers:c,data:{token:r,shop:a}});return{apiToken:p.api_token,customerId:p.customer_id}}var El=Object.freeze({__proto__:null,loginShopifyAppProxy:gl,loginShopifyApi:vl,sendPasswordlessCode:ml,sendPasswordlessCodeAppProxy:_l,validatePasswordlessCode:wl,validatePasswordlessCodeAppProxy:bl,loginCustomerPortal:Al});let Sl=(e=21)=>crypto.getRandomValues(new Uint8Array(e)).reduce((r,t)=>(t&=63,t<36?r+=t.toString(36):t<62?r+=(t-26).toString(36).toUpperCase():t>62?r+="-":r+="_",r),"");function xl(e,r){for(var t=-1,n=e==null?0:e.length,a=Array(n);++t<n;)a[t]=r(e[t],t,e);return a}var wo=xl;function Il(){this.__data__=[],this.size=0}var Tl=Il;function Ol(e,r){return e===r||e!==e&&r!==r}var bo=Ol,Bl=bo;function Pl(e,r){for(var t=e.length;t--;)if(Bl(e[t][0],r))return t;return-1}var lt=Pl,Rl=lt,Fl=Array.prototype,Cl=Fl.splice;function Ul(e){var r=this.__data__,t=Rl(r,e);if(t<0)return!1;var n=r.length-1;return t==n?r.pop():Cl.call(r,t,1),--this.size,!0}var Dl=Ul,Nl=lt;function Ll(e){var r=this.__data__,t=Nl(r,e);return t<0?void 0:r[t][1]}var Ml=Ll,jl=lt;function kl(e){return jl(this.__data__,e)>-1}var Gl=kl,Wl=lt;function ql(e,r){var t=this.__data__,n=Wl(t,e);return n<0?(++this.size,t.push([e,r])):t[n][1]=r,this}var zl=ql,Vl=Tl,Hl=Dl,Yl=Ml,Kl=Gl,Xl=zl;function sr(e){var r=-1,t=e==null?0:e.length;for(this.clear();++r<t;){var n=e[r];this.set(n[0],n[1])}}sr.prototype.clear=Vl,sr.prototype.delete=Hl,sr.prototype.get=Yl,sr.prototype.has=Kl,sr.prototype.set=Xl;var pt=sr,Jl=pt;function Ql(){this.__data__=new Jl,this.size=0}var Zl=Ql;function ep(e){var r=this.__data__,t=r.delete(e);return this.size=r.size,t}var rp=ep;function tp(e){return this.__data__.get(e)}var np=tp;function ip(e){return this.__data__.has(e)}var op=ip,ap=typeof Ae=="object"&&Ae&&Ae.Object===Object&&Ae,$o=ap,sp=$o,up=typeof self=="object"&&self&&self.Object===Object&&self,cp=sp||up||Function("return this")(),oe=cp,fp=oe,lp=fp.Symbol,Br=lp,Ao=Br,Eo=Object.prototype,pp=Eo.hasOwnProperty,hp=Eo.toString,Pr=Ao?Ao.toStringTag:void 0;function dp(e){var r=pp.call(e,Pr),t=e[Pr];try{e[Pr]=void 0;var n=!0}catch{}var a=hp.call(e);return n&&(r?e[Pr]=t:delete e[Pr]),a}var yp=dp,gp=Object.prototype,vp=gp.toString;function mp(e){return vp.call(e)}var _p=mp,So=Br,wp=yp,bp=_p,$p="[object Null]",Ap="[object Undefined]",xo=So?So.toStringTag:void 0;function Ep(e){return e==null?e===void 0?Ap:$p:xo&&xo in Object(e)?wp(e):bp(e)}var ur=Ep;function Sp(e){var r=typeof e;return e!=null&&(r=="object"||r=="function")}var Ye=Sp,xp=ur,Ip=Ye,Tp="[object AsyncFunction]",Op="[object Function]",Bp="[object GeneratorFunction]",Pp="[object Proxy]";function Rp(e){if(!Ip(e))return!1;var r=xp(e);return r==Op||r==Bp||r==Tp||r==Pp}var Io=Rp,Fp=oe,Cp=Fp["__core-js_shared__"],Up=Cp,_n=Up,To=function(){var e=/[^.]+$/.exec(_n&&_n.keys&&_n.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}();function Dp(e){return!!To&&To in e}var Np=Dp,Lp=Function.prototype,Mp=Lp.toString;function jp(e){if(e!=null){try{return Mp.call(e)}catch{}try{return e+""}catch{}}return""}var Oo=jp,kp=Io,Gp=Np,Wp=Ye,qp=Oo,zp=/[\\^$.*+?()[\]{}|]/g,Vp=/^\[object .+?Constructor\]$/,Hp=Function.prototype,Yp=Object.prototype,Kp=Hp.toString,Xp=Yp.hasOwnProperty,Jp=RegExp("^"+Kp.call(Xp).replace(zp,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Qp(e){if(!Wp(e)||Gp(e))return!1;var r=kp(e)?Jp:Vp;return r.test(qp(e))}var Zp=Qp;function eh(e,r){return e?.[r]}var rh=eh,th=Zp,nh=rh;function ih(e,r){var t=nh(e,r);return th(t)?t:void 0}var Ke=ih,oh=Ke,ah=oe,sh=oh(ah,"Map"),wn=sh,uh=Ke,ch=uh(Object,"create"),ht=ch,Bo=ht;function fh(){this.__data__=Bo?Bo(null):{},this.size=0}var lh=fh;function ph(e){var r=this.has(e)&&delete this.__data__[e];return this.size-=r?1:0,r}var hh=ph,dh=ht,yh="__lodash_hash_undefined__",gh=Object.prototype,vh=gh.hasOwnProperty;function mh(e){var r=this.__data__;if(dh){var t=r[e];return t===yh?void 0:t}return vh.call(r,e)?r[e]:void 0}var _h=mh,wh=ht,bh=Object.prototype,$h=bh.hasOwnProperty;function Ah(e){var r=this.__data__;return wh?r[e]!==void 0:$h.call(r,e)}var Eh=Ah,Sh=ht,xh="__lodash_hash_undefined__";function Ih(e,r){var t=this.__data__;return this.size+=this.has(e)?0:1,t[e]=Sh&&r===void 0?xh:r,this}var Th=Ih,Oh=lh,Bh=hh,Ph=_h,Rh=Eh,Fh=Th;function cr(e){var r=-1,t=e==null?0:e.length;for(this.clear();++r<t;){var n=e[r];this.set(n[0],n[1])}}cr.prototype.clear=Oh,cr.prototype.delete=Bh,cr.prototype.get=Ph,cr.prototype.has=Rh,cr.prototype.set=Fh;var Ch=cr,Po=Ch,Uh=pt,Dh=wn;function Nh(){this.size=0,this.__data__={hash:new Po,map:new(Dh||Uh),string:new Po}}var Lh=Nh;function Mh(e){var r=typeof e;return r=="string"||r=="number"||r=="symbol"||r=="boolean"?e!=="__proto__":e===null}var jh=Mh,kh=jh;function Gh(e,r){var t=e.__data__;return kh(r)?t[typeof r=="string"?"string":"hash"]:t.map}var dt=Gh,Wh=dt;function qh(e){var r=Wh(this,e).delete(e);return this.size-=r?1:0,r}var zh=qh,Vh=dt;function Hh(e){return Vh(this,e).get(e)}var Yh=Hh,Kh=dt;function Xh(e){return Kh(this,e).has(e)}var Jh=Xh,Qh=dt;function Zh(e,r){var t=Qh(this,e),n=t.size;return t.set(e,r),this.size+=t.size==n?0:1,this}var ed=Zh,rd=Lh,td=zh,nd=Yh,id=Jh,od=ed;function fr(e){var r=-1,t=e==null?0:e.length;for(this.clear();++r<t;){var n=e[r];this.set(n[0],n[1])}}fr.prototype.clear=rd,fr.prototype.delete=td,fr.prototype.get=nd,fr.prototype.has=id,fr.prototype.set=od;var Ro=fr,ad=pt,sd=wn,ud=Ro,cd=200;function fd(e,r){var t=this.__data__;if(t instanceof ad){var n=t.__data__;if(!sd||n.length<cd-1)return n.push([e,r]),this.size=++t.size,this;t=this.__data__=new ud(n)}return t.set(e,r),this.size=t.size,this}var ld=fd,pd=pt,hd=Zl,dd=rp,yd=np,gd=op,vd=ld;function lr(e){var r=this.__data__=new pd(e);this.size=r.size}lr.prototype.clear=hd,lr.prototype.delete=dd,lr.prototype.get=yd,lr.prototype.has=gd,lr.prototype.set=vd;var md=lr;function _d(e,r){for(var t=-1,n=e==null?0:e.length;++t<n&&r(e[t],t,e)!==!1;);return e}var Fo=_d,wd=Ke,bd=function(){try{var e=wd(Object,"defineProperty");return e({},"",{}),e}catch{}}(),Co=bd,Uo=Co;function $d(e,r,t){r=="__proto__"&&Uo?Uo(e,r,{configurable:!0,enumerable:!0,value:t,writable:!0}):e[r]=t}var Do=$d,Ad=Do,Ed=bo,Sd=Object.prototype,xd=Sd.hasOwnProperty;function Id(e,r,t){var n=e[r];(!(xd.call(e,r)&&Ed(n,t))||t===void 0&&!(r in e))&&Ad(e,r,t)}var No=Id,Td=No,Od=Do;function Bd(e,r,t,n){var a=!t;t||(t={});for(var s=-1,c=r.length;++s<c;){var p=r[s],h=n?n(t[p],e[p],p,t,e):void 0;h===void 0&&(h=e[p]),a?Od(t,p,h):Td(t,p,h)}return t}var Rr=Bd;function Pd(e,r){for(var t=-1,n=Array(e);++t<e;)n[t]=r(t);return n}var Rd=Pd;function Fd(e){return e!=null&&typeof e=="object"}var Ue=Fd,Cd=ur,Ud=Ue,Dd="[object Arguments]";function Nd(e){return Ud(e)&&Cd(e)==Dd}var Ld=Nd,Lo=Ld,Md=Ue,Mo=Object.prototype,jd=Mo.hasOwnProperty,kd=Mo.propertyIsEnumerable,Gd=Lo(function(){return arguments}())?Lo:function(e){return Md(e)&&jd.call(e,"callee")&&!kd.call(e,"callee")},jo=Gd,Wd=Array.isArray,De=Wd,yt={exports:{}};function qd(){return!1}var zd=qd;(function(e,r){var t=oe,n=zd,a=r&&!r.nodeType&&r,s=a&&!0&&e&&!e.nodeType&&e,c=s&&s.exports===a,p=c?t.Buffer:void 0,h=p?p.isBuffer:void 0,v=h||n;e.exports=v})(yt,yt.exports);var Vd=9007199254740991,Hd=/^(?:0|[1-9]\d*)$/;function Yd(e,r){var t=typeof e;return r=r??Vd,!!r&&(t=="number"||t!="symbol"&&Hd.test(e))&&e>-1&&e%1==0&&e<r}var ko=Yd,Kd=9007199254740991;function Xd(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=Kd}var Go=Xd,Jd=ur,Qd=Go,Zd=Ue,ey="[object Arguments]",ry="[object Array]",ty="[object Boolean]",ny="[object Date]",iy="[object Error]",oy="[object Function]",ay="[object Map]",sy="[object Number]",uy="[object Object]",cy="[object RegExp]",fy="[object Set]",ly="[object String]",py="[object WeakMap]",hy="[object ArrayBuffer]",dy="[object DataView]",yy="[object Float32Array]",gy="[object Float64Array]",vy="[object Int8Array]",my="[object Int16Array]",_y="[object Int32Array]",wy="[object Uint8Array]",by="[object Uint8ClampedArray]",$y="[object Uint16Array]",Ay="[object Uint32Array]",M={};M[yy]=M[gy]=M[vy]=M[my]=M[_y]=M[wy]=M[by]=M[$y]=M[Ay]=!0,M[ey]=M[ry]=M[hy]=M[ty]=M[dy]=M[ny]=M[iy]=M[oy]=M[ay]=M[sy]=M[uy]=M[cy]=M[fy]=M[ly]=M[py]=!1;function Ey(e){return Zd(e)&&Qd(e.length)&&!!M[Jd(e)]}var Sy=Ey;function xy(e){return function(r){return e(r)}}var bn=xy,Fr={exports:{}};(function(e,r){var t=$o,n=r&&!r.nodeType&&r,a=n&&!0&&e&&!e.nodeType&&e,s=a&&a.exports===n,c=s&&t.process,p=function(){try{var h=a&&a.require&&a.require("util").types;return h||c&&c.binding&&c.binding("util")}catch{}}();e.exports=p})(Fr,Fr.exports);var Iy=Sy,Ty=bn,Wo=Fr.exports,qo=Wo&&Wo.isTypedArray,Oy=qo?Ty(qo):Iy,By=Oy,Py=Rd,Ry=jo,Fy=De,Cy=yt.exports,Uy=ko,Dy=By,Ny=Object.prototype,Ly=Ny.hasOwnProperty;function My(e,r){var t=Fy(e),n=!t&&Ry(e),a=!t&&!n&&Cy(e),s=!t&&!n&&!a&&Dy(e),c=t||n||a||s,p=c?Py(e.length,String):[],h=p.length;for(var v in e)(r||Ly.call(e,v))&&!(c&&(v=="length"||a&&(v=="offset"||v=="parent")||s&&(v=="buffer"||v=="byteLength"||v=="byteOffset")||Uy(v,h)))&&p.push(v);return p}var zo=My,jy=Object.prototype;function ky(e){var r=e&&e.constructor,t=typeof r=="function"&&r.prototype||jy;return e===t}var $n=ky;function Gy(e,r){return function(t){return e(r(t))}}var Vo=Gy,Wy=Vo,qy=Wy(Object.keys,Object),zy=qy,Vy=$n,Hy=zy,Yy=Object.prototype,Ky=Yy.hasOwnProperty;function Xy(e){if(!Vy(e))return Hy(e);var r=[];for(var t in Object(e))Ky.call(e,t)&&t!="constructor"&&r.push(t);return r}var Jy=Xy,Qy=Io,Zy=Go;function eg(e){return e!=null&&Zy(e.length)&&!Qy(e)}var Ho=eg,rg=zo,tg=Jy,ng=Ho;function ig(e){return ng(e)?rg(e):tg(e)}var An=ig,og=Rr,ag=An;function sg(e,r){return e&&og(r,ag(r),e)}var ug=sg;function cg(e){var r=[];if(e!=null)for(var t in Object(e))r.push(t);return r}var fg=cg,lg=Ye,pg=$n,hg=fg,dg=Object.prototype,yg=dg.hasOwnProperty;function gg(e){if(!lg(e))return hg(e);var r=pg(e),t=[];for(var n in e)n=="constructor"&&(r||!yg.call(e,n))||t.push(n);return t}var vg=gg,mg=zo,_g=vg,wg=Ho;function bg(e){return wg(e)?mg(e,!0):_g(e)}var En=bg,$g=Rr,Ag=En;function Eg(e,r){return e&&$g(r,Ag(r),e)}var Sg=Eg,Sn={exports:{}};(function(e,r){var t=oe,n=r&&!r.nodeType&&r,a=n&&!0&&e&&!e.nodeType&&e,s=a&&a.exports===n,c=s?t.Buffer:void 0,p=c?c.allocUnsafe:void 0;function h(v,_){if(_)return v.slice();var w=v.length,b=p?p(w):new v.constructor(w);return v.copy(b),b}e.exports=h})(Sn,Sn.exports);function xg(e,r){var t=-1,n=e.length;for(r||(r=Array(n));++t<n;)r[t]=e[t];return r}var xn=xg;function Ig(e,r){for(var t=-1,n=e==null?0:e.length,a=0,s=[];++t<n;){var c=e[t];r(c,t,e)&&(s[a++]=c)}return s}var Tg=Ig;function Og(){return[]}var Yo=Og,Bg=Tg,Pg=Yo,Rg=Object.prototype,Fg=Rg.propertyIsEnumerable,Ko=Object.getOwnPropertySymbols,Cg=Ko?function(e){return e==null?[]:(e=Object(e),Bg(Ko(e),function(r){return Fg.call(e,r)}))}:Pg,In=Cg,Ug=Rr,Dg=In;function Ng(e,r){return Ug(e,Dg(e),r)}var Lg=Ng;function Mg(e,r){for(var t=-1,n=r.length,a=e.length;++t<n;)e[a+t]=r[t];return e}var Tn=Mg,jg=Vo,kg=jg(Object.getPrototypeOf,Object),On=kg,Gg=Tn,Wg=On,qg=In,zg=Yo,Vg=Object.getOwnPropertySymbols,Hg=Vg?function(e){for(var r=[];e;)Gg(r,qg(e)),e=Wg(e);return r}:zg,Xo=Hg,Yg=Rr,Kg=Xo;function Xg(e,r){return Yg(e,Kg(e),r)}var Jg=Xg,Qg=Tn,Zg=De;function ev(e,r,t){var n=r(e);return Zg(e)?n:Qg(n,t(e))}var Jo=ev,rv=Jo,tv=In,nv=An;function iv(e){return rv(e,nv,tv)}var ov=iv,av=Jo,sv=Xo,uv=En;function cv(e){return av(e,uv,sv)}var Qo=cv,fv=Ke,lv=oe,pv=fv(lv,"DataView"),hv=pv,dv=Ke,yv=oe,gv=dv(yv,"Promise"),vv=gv,mv=Ke,_v=oe,wv=mv(_v,"Set"),bv=wv,$v=Ke,Av=oe,Ev=$v(Av,"WeakMap"),Zo=Ev,Bn=hv,Pn=wn,Rn=vv,Fn=bv,Cn=Zo,ea=ur,pr=Oo,ra="[object Map]",Sv="[object Object]",ta="[object Promise]",na="[object Set]",ia="[object WeakMap]",oa="[object DataView]",xv=pr(Bn),Iv=pr(Pn),Tv=pr(Rn),Ov=pr(Fn),Bv=pr(Cn),Xe=ea;(Bn&&Xe(new Bn(new ArrayBuffer(1)))!=oa||Pn&&Xe(new Pn)!=ra||Rn&&Xe(Rn.resolve())!=ta||Fn&&Xe(new Fn)!=na||Cn&&Xe(new Cn)!=ia)&&(Xe=function(e){var r=ea(e),t=r==Sv?e.constructor:void 0,n=t?pr(t):"";if(n)switch(n){case xv:return oa;case Iv:return ra;case Tv:return ta;case Ov:return na;case Bv:return ia}return r});var Un=Xe,Pv=Object.prototype,Rv=Pv.hasOwnProperty;function Fv(e){var r=e.length,t=new e.constructor(r);return r&&typeof e[0]=="string"&&Rv.call(e,"index")&&(t.index=e.index,t.input=e.input),t}var Cv=Fv,Uv=oe,Dv=Uv.Uint8Array,Nv=Dv,aa=Nv;function Lv(e){var r=new e.constructor(e.byteLength);return new aa(r).set(new aa(e)),r}var Dn=Lv,Mv=Dn;function jv(e,r){var t=r?Mv(e.buffer):e.buffer;return new e.constructor(t,e.byteOffset,e.byteLength)}var kv=jv,Gv=/\w*$/;function Wv(e){var r=new e.constructor(e.source,Gv.exec(e));return r.lastIndex=e.lastIndex,r}var qv=Wv,sa=Br,ua=sa?sa.prototype:void 0,ca=ua?ua.valueOf:void 0;function zv(e){return ca?Object(ca.call(e)):{}}var Vv=zv,Hv=Dn;function Yv(e,r){var t=r?Hv(e.buffer):e.buffer;return new e.constructor(t,e.byteOffset,e.length)}var Kv=Yv,Xv=Dn,Jv=kv,Qv=qv,Zv=Vv,e0=Kv,r0="[object Boolean]",t0="[object Date]",n0="[object Map]",i0="[object Number]",o0="[object RegExp]",a0="[object Set]",s0="[object String]",u0="[object Symbol]",c0="[object ArrayBuffer]",f0="[object DataView]",l0="[object Float32Array]",p0="[object Float64Array]",h0="[object Int8Array]",d0="[object Int16Array]",y0="[object Int32Array]",g0="[object Uint8Array]",v0="[object Uint8ClampedArray]",m0="[object Uint16Array]",_0="[object Uint32Array]";function w0(e,r,t){var n=e.constructor;switch(r){case c0:return Xv(e);case r0:case t0:return new n(+e);case f0:return Jv(e,t);case l0:case p0:case h0:case d0:case y0:case g0:case v0:case m0:case _0:return e0(e,t);case n0:return new n;case i0:case s0:return new n(e);case o0:return Qv(e);case a0:return new n;case u0:return Zv(e)}}var b0=w0,$0=Ye,fa=Object.create,A0=function(){function e(){}return function(r){if(!$0(r))return{};if(fa)return fa(r);e.prototype=r;var t=new e;return e.prototype=void 0,t}}(),gt=A0,E0=gt,S0=On,x0=$n;function I0(e){return typeof e.constructor=="function"&&!x0(e)?E0(S0(e)):{}}var T0=I0,O0=Un,B0=Ue,P0="[object Map]";function R0(e){return B0(e)&&O0(e)==P0}var F0=R0,C0=F0,U0=bn,la=Fr.exports,pa=la&&la.isMap,D0=pa?U0(pa):C0,N0=D0,L0=Un,M0=Ue,j0="[object Set]";function k0(e){return M0(e)&&L0(e)==j0}var G0=k0,W0=G0,q0=bn,ha=Fr.exports,da=ha&&ha.isSet,z0=da?q0(da):W0,V0=z0,H0=md,Y0=Fo,K0=No,X0=ug,J0=Sg,Q0=Sn.exports,Z0=xn,em=Lg,rm=Jg,tm=ov,nm=Qo,im=Un,om=Cv,am=b0,sm=T0,um=De,cm=yt.exports,fm=N0,lm=Ye,pm=V0,hm=An,dm=En,ym=1,gm=2,vm=4,ya="[object Arguments]",mm="[object Array]",_m="[object Boolean]",wm="[object Date]",bm="[object Error]",ga="[object Function]",$m="[object GeneratorFunction]",Am="[object Map]",Em="[object Number]",va="[object Object]",Sm="[object RegExp]",xm="[object Set]",Im="[object String]",Tm="[object Symbol]",Om="[object WeakMap]",Bm="[object ArrayBuffer]",Pm="[object DataView]",Rm="[object Float32Array]",Fm="[object Float64Array]",Cm="[object Int8Array]",Um="[object Int16Array]",Dm="[object Int32Array]",Nm="[object Uint8Array]",Lm="[object Uint8ClampedArray]",Mm="[object Uint16Array]",jm="[object Uint32Array]",L={};L[ya]=L[mm]=L[Bm]=L[Pm]=L[_m]=L[wm]=L[Rm]=L[Fm]=L[Cm]=L[Um]=L[Dm]=L[Am]=L[Em]=L[va]=L[Sm]=L[xm]=L[Im]=L[Tm]=L[Nm]=L[Lm]=L[Mm]=L[jm]=!0,L[bm]=L[ga]=L[Om]=!1;function vt(e,r,t,n,a,s){var c,p=r&ym,h=r&gm,v=r&vm;if(t&&(c=a?t(e,n,a,s):t(e)),c!==void 0)return c;if(!lm(e))return e;var _=um(e);if(_){if(c=om(e),!p)return Z0(e,c)}else{var w=im(e),b=w==ga||w==$m;if(cm(e))return Q0(e,p);if(w==va||w==ya||b&&!a){if(c=h||b?{}:sm(e),!p)return h?rm(e,J0(c,e)):em(e,X0(c,e))}else{if(!L[w])return a?e:{};c=am(e,w,p)}}s||(s=new H0);var d=s.get(e);if(d)return d;s.set(e,c),pm(e)?e.forEach(function(I){c.add(vt(I,r,t,I,e,s))}):fm(e)&&e.forEach(function(I,S){c.set(S,vt(I,r,t,S,e,s))});var E=v?h?nm:tm:h?dm:hm,x=_?void 0:E(e);return Y0(x||e,function(I,S){x&&(S=I,I=e[S]),K0(c,S,vt(I,r,t,S,e,s))}),c}var km=vt,Gm=ur,Wm=Ue,qm="[object Symbol]";function zm(e){return typeof e=="symbol"||Wm(e)&&Gm(e)==qm}var mt=zm,Vm=De,Hm=mt,Ym=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Km=/^\w*$/;function Xm(e,r){if(Vm(e))return!1;var t=typeof e;return t=="number"||t=="symbol"||t=="boolean"||e==null||Hm(e)?!0:Km.test(e)||!Ym.test(e)||r!=null&&e in Object(r)}var Jm=Xm,ma=Ro,Qm="Expected a function";function Nn(e,r){if(typeof e!="function"||r!=null&&typeof r!="function")throw new TypeError(Qm);var t=function(){var n=arguments,a=r?r.apply(this,n):n[0],s=t.cache;if(s.has(a))return s.get(a);var c=e.apply(this,n);return t.cache=s.set(a,c)||s,c};return t.cache=new(Nn.Cache||ma),t}Nn.Cache=ma;var Zm=Nn,e_=Zm,r_=500;function t_(e){var r=e_(e,function(n){return t.size===r_&&t.clear(),n}),t=r.cache;return r}var n_=t_,i_=n_,o_=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,a_=/\\(\\)?/g,s_=i_(function(e){var r=[];return e.charCodeAt(0)===46&&r.push(""),e.replace(o_,function(t,n,a,s){r.push(a?s.replace(a_,"$1"):n||t)}),r}),u_=s_,_a=Br,c_=wo,f_=De,l_=mt,p_=1/0,wa=_a?_a.prototype:void 0,ba=wa?wa.toString:void 0;function $a(e){if(typeof e=="string")return e;if(f_(e))return c_(e,$a)+"";if(l_(e))return ba?ba.call(e):"";var r=e+"";return r=="0"&&1/e==-p_?"-0":r}var h_=$a,d_=h_;function y_(e){return e==null?"":d_(e)}var g_=y_,v_=De,m_=Jm,__=u_,w_=g_;function b_(e,r){return v_(e)?e:m_(e,r)?[e]:__(w_(e))}var Ln=b_;function $_(e){var r=e==null?0:e.length;return r?e[r-1]:void 0}var A_=$_,E_=mt,S_=1/0;function x_(e){if(typeof e=="string"||E_(e))return e;var r=e+"";return r=="0"&&1/e==-S_?"-0":r}var Aa=x_,I_=Ln,T_=Aa;function O_(e,r){r=I_(r,e);for(var t=0,n=r.length;e!=null&&t<n;)e=e[T_(r[t++])];return t&&t==n?e:void 0}var B_=O_;function P_(e,r,t){var n=-1,a=e.length;r<0&&(r=-r>a?0:a+r),t=t>a?a:t,t<0&&(t+=a),a=r>t?0:t-r>>>0,r>>>=0;for(var s=Array(a);++n<a;)s[n]=e[n+r];return s}var R_=P_,F_=B_,C_=R_;function U_(e,r){return r.length<2?e:F_(e,C_(r,0,-1))}var D_=U_,N_=Ln,L_=A_,M_=D_,j_=Aa;function k_(e,r){return r=N_(r,e),e=M_(e,r),e==null||delete e[j_(L_(r))]}var G_=k_,W_=ur,q_=On,z_=Ue,V_="[object Object]",H_=Function.prototype,Y_=Object.prototype,Ea=H_.toString,K_=Y_.hasOwnProperty,X_=Ea.call(Object);function J_(e){if(!z_(e)||W_(e)!=V_)return!1;var r=q_(e);if(r===null)return!0;var t=K_.call(r,"constructor")&&r.constructor;return typeof t=="function"&&t instanceof t&&Ea.call(t)==X_}var Q_=J_,Z_=Q_;function ew(e){return Z_(e)?void 0:e}var rw=ew,Sa=Br,tw=jo,nw=De,xa=Sa?Sa.isConcatSpreadable:void 0;function iw(e){return nw(e)||tw(e)||!!(xa&&e&&e[xa])}var ow=iw,aw=Tn,sw=ow;function Ia(e,r,t,n,a){var s=-1,c=e.length;for(t||(t=sw),a||(a=[]);++s<c;){var p=e[s];r>0&&t(p)?r>1?Ia(p,r-1,t,n,a):aw(a,p):n||(a[a.length]=p)}return a}var uw=Ia,cw=uw;function fw(e){var r=e==null?0:e.length;return r?cw(e,1):[]}var lw=fw;function pw(e,r,t){switch(t.length){case 0:return e.call(r);case 1:return e.call(r,t[0]);case 2:return e.call(r,t[0],t[1]);case 3:return e.call(r,t[0],t[1],t[2])}return e.apply(r,t)}var Mn=pw,hw=Mn,Ta=Math.max;function dw(e,r,t){return r=Ta(r===void 0?e.length-1:r,0),function(){for(var n=arguments,a=-1,s=Ta(n.length-r,0),c=Array(s);++a<s;)c[a]=n[r+a];a=-1;for(var p=Array(r+1);++a<r;)p[a]=n[a];return p[r]=t(c),hw(e,this,p)}}var Oa=dw;function yw(e){return function(){return e}}var gw=yw;function vw(e){return e}var jn=vw,mw=gw,Ba=Co,_w=jn,ww=Ba?function(e,r){return Ba(e,"toString",{configurable:!0,enumerable:!1,value:mw(r),writable:!0})}:_w,bw=ww,$w=800,Aw=16,Ew=Date.now;function Sw(e){var r=0,t=0;return function(){var n=Ew(),a=Aw-(n-t);if(t=n,a>0){if(++r>=$w)return arguments[0]}else r=0;return e.apply(void 0,arguments)}}var Pa=Sw,xw=bw,Iw=Pa,Tw=Iw(xw),kn=Tw,Ow=lw,Bw=Oa,Pw=kn;function Rw(e){return Pw(Bw(e,void 0,Ow),e+"")}var Fw=Rw,Cw=wo,Uw=km,Dw=G_,Nw=Ln,Lw=Rr,Mw=rw,jw=Fw,kw=Qo,Gw=1,Ww=2,qw=4,zw=jw(function(e,r){var t={};if(e==null)return t;var n=!1;r=Cw(r,function(s){return s=Nw(s,e),n||(n=s.length>1),s}),Lw(e,kw(e),t),n&&(t=Uw(t,Gw|Ww|qw,Mw));for(var a=r.length;a--;)Dw(t,r[a]);return t}),Gn=zw,Vw=Object.defineProperty,Hw=Object.defineProperties,Yw=Object.getOwnPropertyDescriptors,Ra=Object.getOwnPropertySymbols,Kw=Object.prototype.hasOwnProperty,Xw=Object.prototype.propertyIsEnumerable,Fa=(e,r,t)=>r in e?Vw(e,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[r]=t,Jw=(e,r)=>{for(var t in r||(r={}))Kw.call(r,t)&&Fa(e,t,r[t]);if(Ra)for(var t of Ra(r))Xw.call(r,t)&&Fa(e,t,r[t]);return e},Qw=(e,r)=>Hw(e,Yw(r));function Zw(e){try{return JSON.parse(e)}catch{return e}}function e1(e){return Object.entries(e).reduce((r,[t,n])=>Qw(Jw({},r),{[t]:Zw(n)}),{})}const Ca=e=>typeof e=="string"?e!=="0"&&e!=="false":!!e;var r1=Object.defineProperty,t1=Object.defineProperties,n1=Object.getOwnPropertyDescriptors,Ua=Object.getOwnPropertySymbols,i1=Object.prototype.hasOwnProperty,o1=Object.prototype.propertyIsEnumerable,Da=(e,r,t)=>r in e?r1(e,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[r]=t,Na=(e,r)=>{for(var t in r||(r={}))i1.call(r,t)&&Da(e,t,r[t]);if(Ua)for(var t of Ua(r))o1.call(r,t)&&Da(e,t,r[t]);return e},La=(e,r)=>t1(e,n1(r));function Ma(e){var r;const t=e1(e),n=t.auto_inject===void 0?!0:t.auto_inject,a=(r=t.display_on)!=null?r:[],s=t.first_option==="autodeliver";return La(Na({},Gn(t,["display_on","first_option"])),{auto_inject:n,valid_pages:a,is_subscription_first:s,autoInject:n,validPages:a,isSubscriptionFirst:s})}function ja(e){var r;const t=((r=e.subscription_options)==null?void 0:r.storefront_purchase_options)==="subscription_only";return La(Na({},e),{is_subscription_only:t,isSubscriptionOnly:t})}function a1(e){return e.map(r=>{const t={};return Object.entries(r).forEach(([n,a])=>{t[n]=ja(a)}),t})}const _t="2020-12",s1={store_currency:{currency_code:"USD",currency_symbol:"$",decimal_separator:".",thousands_separator:",",currency_symbol_location:"left"}},Cr=new Map;function wt(e,r){return Cr.has(e)||Cr.set(e,r()),Cr.get(e)}async function Wn(e){const{product:r}=await wt(`product.${e}`,()=>ft("get",`/product/${_t}/${e}.json`));return ja(r)}async function ka(){return await wt("storeSettings",()=>ft("get",`/${_t}/store_settings.json`).catch(()=>s1))}async function Ga(){const{widget_settings:e}=await wt("widgetSettings",()=>ft("get",`/${_t}/widget_settings.json`));return Ma(e)}async function Wa(){const{products:e,widget_settings:r,store_settings:t,meta:n}=await wt("productsAndSettings",()=>ft("get",`/product/${_t}/products.json`));return n?.status==="error"?Promise.reject(n.message):{products:a1(e),widget_settings:Ma(r),store_settings:t??{}}}async function u1(){const{products:e}=await Wa();return e}async function c1(e){const[r,t,n]=await Promise.all([Wn(e),ka(),Ga()]);return{product:r,store_settings:t,widget_settings:n,storeSettings:t,widgetSettings:n}}async function qa(e){const{bundle_product:r}=await Wn(e);return r}async function za(){return Array.from(Cr.keys()).forEach(e=>Cr.delete(e))}var f1=Object.freeze({__proto__:null,getCDNProduct:Wn,getCDNStoreSettings:ka,getCDNWidgetSettings:Ga,getCDNProductsAndSettings:Wa,getCDNProducts:u1,getCDNProductAndSettings:c1,getCDNBundleSettings:qa,resetCDNCache:za}),Va={exports:{}};/*! For license information please see xdr.js.LICENSE.txt */(function(e,r){(function(t,n){e.exports=n()})(Ae,()=>(()=>{var t={899:(s,c,p)=>{const h=p(221);s.exports=h},221:(s,c,p)=>{p.r(c),p.d(c,{Array:()=>yr,Bool:()=>H,Double:()=>xt,Enum:()=>$e,Float:()=>Ne,Hyper:()=>k,Int:()=>V,Opaque:()=>Nr,Option:()=>Mr,Quadruple:()=>G,Reference:()=>te,String:()=>Dr,Struct:()=>Le,Union:()=>Oe,UnsignedHyper:()=>se,UnsignedInt:()=>N,VarArray:()=>Lr,VarOpaque:()=>Te,Void:()=>Q,config:()=>g});class h extends TypeError{constructor(o){super(`XDR Write Error: ${o}`)}}class v extends TypeError{constructor(o){super(`XDR Read Error: ${o}`)}}class _ extends TypeError{constructor(o){super(`XDR Type Definition Error: ${o}`)}}class w extends _{constructor(){super("method not implemented, it should be overloaded in the descendant class.")}}var b=p(764).lW;class d{constructor(o){if(!b.isBuffer(o)){if(!(o instanceof Array))throw new v("source not specified");o=b.from(o)}this._buffer=o,this._length=o.length,this._index=0}_buffer;_length;_index;get eof(){return this._index===this._length}advance(o){const l=this._index;if(this._index+=o,this._length<this._index)throw new v("attempt to read outside the boundary of the buffer");const m=4-(o%4||4);if(m>0){for(let A=0;A<m;A++)if(this._buffer[this._index+A]!==0)throw new v("invalid padding");this._index+=m}return l}rewind(){this._index=0}read(o){const l=this.advance(o);return this._buffer.subarray(l,l+o)}readInt32BE(){return this._buffer.readInt32BE(this.advance(4))}readUInt32BE(){return this._buffer.readUInt32BE(this.advance(4))}readBigInt64BE(){return this._buffer.readBigInt64BE(this.advance(8))}readBigUInt64BE(){return this._buffer.readBigUInt64BE(this.advance(8))}readFloatBE(){return this._buffer.readFloatBE(this.advance(4))}readDoubleBE(){return this._buffer.readDoubleBE(this.advance(8))}ensureInputConsumed(){if(this._index!==this._length)throw new v("invalid XDR contract typecast - source buffer not entirely consumed")}}var E=p(764).lW;const x=8192;class I{constructor(o){typeof o=="number"?o=E.allocUnsafe(o):o instanceof E||(o=E.allocUnsafe(x)),this._buffer=o,this._length=o.length}_buffer;_length;_index=0;alloc(o){const l=this._index;return this._index+=o,this._length<this._index&&this.resize(this._index),l}resize(o){const l=Math.ceil(o/x)*x,m=E.allocUnsafe(l);this._buffer.copy(m,0,0,this._length),this._buffer=m,this._length=l}finalize(){return this._buffer.subarray(0,this._index)}toArray(){return[...this.finalize()]}write(o,l){if(typeof o=="string"){const A=this.alloc(l);this._buffer.write(o,A,"utf8")}else{o instanceof E||(o=E.from(o));const A=this.alloc(l);o.copy(this._buffer,A,0,l)}const m=4-(l%4||4);if(m>0){const A=this.alloc(m);this._buffer.fill(0,A,this._index)}}writeInt32BE(o){const l=this.alloc(4);this._buffer.writeInt32BE(o,l)}writeUInt32BE(o){const l=this.alloc(4);this._buffer.writeUInt32BE(o,l)}writeBigInt64BE(o){const l=this.alloc(8);this._buffer.writeBigInt64BE(o,l)}writeBigUInt64BE(o){const l=this.alloc(8);this._buffer.writeBigUInt64BE(o,l)}writeFloatBE(o){const l=this.alloc(4);this._buffer.writeFloatBE(o,l)}writeDoubleBE(o){const l=this.alloc(8);this._buffer.writeDoubleBE(o,l)}static bufferChunkSize=x}var S=p(764).lW;class T{toXDR(){let o=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"raw";if(!this.write)return this.constructor.toXDR(this,o);const l=new I;return this.write(this,l),j(l.finalize(),o)}fromXDR(o){let l=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"raw";if(!this.read)return this.constructor.fromXDR(o,l);const m=new d(q(o,l)),A=this.read(m);return m.ensureInputConsumed(),A}validateXDR(o){let l=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"raw";try{return this.fromXDR(o,l),!0}catch{return!1}}static toXDR(o){let l=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"raw";const m=new I;return this.write(o,m),j(m.finalize(),l)}static fromXDR(o){const l=new d(q(o,arguments.length>1&&arguments[1]!==void 0?arguments[1]:"raw")),m=this.read(l);return l.ensureInputConsumed(),m}static validateXDR(o){let l=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"raw";try{return this.fromXDR(o,l),!0}catch{return!1}}}class P extends T{static read(o){throw new w}static write(o,l){throw new w}static isValid(o){return!1}}class B extends T{isValid(o){return!1}}class D extends TypeError{constructor(o){super(`Invalid format ${o}, must be one of "raw", "hex", "base64"`)}}function j(y,o){switch(o){case"raw":return y;case"hex":return y.toString("hex");case"base64":return y.toString("base64");default:throw new D(o)}}function q(y,o){switch(o){case"raw":return y;case"hex":return S.from(y,"hex");case"base64":return S.from(y,"base64");default:throw new D(o)}}const z=2147483647,X=-2147483648;class V extends P{static read(o){return o.readInt32BE()}static write(o,l){if(typeof o!="number")throw new h("not a number");if((0|o)!==o)throw new h("invalid i32 value");l.writeInt32BE(o)}static isValid(o){return typeof o=="number"&&(0|o)===o&&o>=X&&o<=z}}V.MAX_VALUE=z,V.MIN_VALUE=2147483648;const ae=-9223372036854775808n,ue=9223372036854775807n;class k extends P{constructor(o,l){if(super(),typeof o=="bigint"){if(o<ae||o>ue)throw new TypeError("Invalid i64 value");this._value=o}else{if((0|o)!==o||(0|l)!==l)throw new TypeError("Invalid i64 value");this._value=BigInt(l>>>0)<<32n|BigInt(o>>>0)}}get low(){return Number(0xFFFFFFFFn&this._value)<<0}get high(){return Number(this._value>>32n)>>0}get unsigned(){return!1}toString(){return this._value.toString()}toJSON(){return{_value:this._value.toString()}}static read(o){return new k(o.readBigInt64BE())}static write(o,l){if(!(o instanceof this))throw new h(`${o} is not a Hyper`);l.writeBigInt64BE(o._value)}static fromString(o){if(!/^-?\d{0,19}$/.test(o))throw new TypeError(`Invalid i64 string value: ${o}`);return new k(BigInt(o))}static fromBits(o,l){return new this(o,l)}static isValid(o){return o instanceof this}}k.MAX_VALUE=new k(ue),k.MIN_VALUE=new k(ae);const re=4294967295;class N extends P{static read(o){return o.readUInt32BE()}static write(o,l){if(typeof o!="number"||!(o>=0&&o<=re)||o%1!=0)throw new h("invalid u32 value");l.writeUInt32BE(o)}static isValid(o){return typeof o=="number"&&o%1==0&&o>=0&&o<=re}}N.MAX_VALUE=re,N.MIN_VALUE=0;const ce=0n,hr=0xFFFFFFFFFFFFFFFFn;class se extends P{constructor(o,l){if(super(),typeof o=="bigint"){if(o<ce||o>hr)throw new TypeError("Invalid u64 value");this._value=o}else{if((0|o)!==o||(0|l)!==l)throw new TypeError("Invalid u64 value");this._value=BigInt(l>>>0)<<32n|BigInt(o>>>0)}}get low(){return Number(0xFFFFFFFFn&this._value)<<0}get high(){return Number(this._value>>32n)>>0}get unsigned(){return!0}toString(){return this._value.toString()}toJSON(){return{_value:this._value.toString()}}static read(o){return new se(o.readBigUInt64BE())}static write(o,l){if(!(o instanceof this))throw new h(`${o} is not an UnsignedHyper`);l.writeBigUInt64BE(o._value)}static fromString(o){if(!/^\d{0,20}$/.test(o))throw new TypeError(`Invalid u64 string value: ${o}`);return new se(BigInt(o))}static fromBits(o,l){return new this(o,l)}static isValid(o){return o instanceof this}}se.MAX_VALUE=new se(hr),se.MIN_VALUE=new se(ce);class Ne extends P{static read(o){return o.readFloatBE()}static write(o,l){if(typeof o!="number")throw new h("not a number");l.writeFloatBE(o)}static isValid(o){return typeof o=="number"}}class xt extends P{static read(o){return o.readDoubleBE()}static write(o,l){if(typeof o!="number")throw new h("not a number");l.writeDoubleBE(o)}static isValid(o){return typeof o=="number"}}class G extends P{static read(){throw new _("quadruple not supported")}static write(){throw new _("quadruple not supported")}static isValid(){return!1}}class H extends P{static read(o){const l=V.read(o);switch(l){case 0:return!1;case 1:return!0;default:throw new v(`got ${l} when trying to read a bool`)}}static write(o,l){const m=o?1:0;V.write(m,l)}static isValid(o){return typeof o=="boolean"}}var dr=p(764).lW;class Dr extends B{constructor(){let o=arguments.length>0&&arguments[0]!==void 0?arguments[0]:N.MAX_VALUE;super(),this._maxLength=o}read(o){const l=N.read(o);if(l>this._maxLength)throw new v(`saw ${l} length String, max allowed is ${this._maxLength}`);return o.read(l)}readString(o){return this.read(o).toString("utf8")}write(o,l){const m=typeof o=="string"?dr.byteLength(o,"utf8"):o.length;if(m>this._maxLength)throw new h(`got ${o.length} bytes, max allowed is ${this._maxLength}`);N.write(m,l),l.write(o,m)}isValid(o){return typeof o=="string"?dr.byteLength(o,"utf8")<=this._maxLength:!!(o instanceof Array||dr.isBuffer(o))&&o.length<=this._maxLength}}var It=p(764).lW;class Nr extends B{constructor(o){super(),this._length=o}read(o){return o.read(this._length)}write(o,l){const{length:m}=o;if(m!==this._length)throw new h(`got ${o.length} bytes, expected ${this._length}`);l.write(o,m)}isValid(o){return It.isBuffer(o)&&o.length===this._length}}var Tt=p(764).lW;class Te extends B{constructor(){let o=arguments.length>0&&arguments[0]!==void 0?arguments[0]:N.MAX_VALUE;super(),this._maxLength=o}read(o){const l=N.read(o);if(l>this._maxLength)throw new v(`saw ${l} length VarOpaque, max allowed is ${this._maxLength}`);return o.read(l)}write(o,l){const{length:m}=o;if(o.length>this._maxLength)throw new h(`got ${o.length} bytes, max allowed is ${this._maxLength}`);N.write(m,l),l.write(o,m)}isValid(o){return Tt.isBuffer(o)&&o.length<=this._maxLength}}class yr extends B{constructor(o,l){super(),this._childType=o,this._length=l}read(o){const l=new p.g.Array(this._length);for(let m=0;m<this._length;m++)l[m]=this._childType.read(o);return l}write(o,l){if(!(o instanceof p.g.Array))throw new h("value is not array");if(o.length!==this._length)throw new h(`got array of size ${o.length}, expected ${this._length}`);for(const m of o)this._childType.write(m,l)}isValid(o){if(!(o instanceof p.g.Array)||o.length!==this._length)return!1;for(const l of o)if(!this._childType.isValid(l))return!1;return!0}}class Lr extends B{constructor(o){let l=arguments.length>1&&arguments[1]!==void 0?arguments[1]:N.MAX_VALUE;super(),this._childType=o,this._maxLength=l}read(o){const l=N.read(o);if(l>this._maxLength)throw new v(`saw ${l} length VarArray, max allowed is ${this._maxLength}`);const m=new Array(l);for(let A=0;A<l;A++)m[A]=this._childType.read(o);return m}write(o,l){if(!(o instanceof Array))throw new h("value is not array");if(o.length>this._maxLength)throw new h(`got array of size ${o.length}, max allowed is ${this._maxLength}`);N.write(o.length,l);for(const m of o)this._childType.write(m,l)}isValid(o){if(!(o instanceof Array)||o.length>this._maxLength)return!1;for(const l of o)if(!this._childType.isValid(l))return!1;return!0}}class Mr extends P{constructor(o){super(),this._childType=o}read(o){if(H.read(o))return this._childType.read(o)}write(o,l){const m=o!=null;H.write(m,l),m&&this._childType.write(o,l)}isValid(o){return o==null||this._childType.isValid(o)}}class Q extends P{static read(){}static write(o){if(o!==void 0)throw new h("trying to write value to a void slot")}static isValid(o){return o===void 0}}class $e extends P{constructor(o,l){super(),this.name=o,this.value=l}static read(o){const l=V.read(o),m=this._byValue[l];if(m===void 0)throw new v(`unknown ${this.enumName} member for value ${l}`);return m}static write(o,l){if(!(o instanceof this))throw new h(`unknown ${o} is not a ${this.enumName}`);V.write(o.value,l)}static isValid(o){return o instanceof this}static members(){return this._members}static values(){return Object.values(this._members)}static fromName(o){const l=this._members[o];if(!l)throw new TypeError(`${o} is not a member of ${this.enumName}`);return l}static fromValue(o){const l=this._byValue[o];if(l===void 0)throw new TypeError(`${o} is not a value of any member of ${this.enumName}`);return l}static create(o,l,m){const A=class extends $e{};A.enumName=l,o.results[l]=A,A._members={},A._byValue={};for(const[F,R]of Object.entries(m)){const C=new A(F,R);A._members[F]=C,A._byValue[R]=C,A[F]=()=>C}return A}}class te extends P{resolve(){throw new _('"resolve" method should be implemented in the descendant class')}}class Le extends P{constructor(o){super(),this._attributes=o||{}}static read(o){const l={};for(const[m,A]of this._fields)l[m]=A.read(o);return new this(l)}static write(o,l){if(!(o instanceof this))throw new h(`${o} is not a ${this.structName}`);for(const[m,A]of this._fields){const F=o._attributes[m];A.write(F,l)}}static isValid(o){return o instanceof this}static create(o,l,m){const A=class extends Le{};A.structName=l,o.results[l]=A;const F=new Array(m.length);for(let R=0;R<m.length;R++){const C=m[R],jr=C[0];let Bt=C[1];Bt instanceof te&&(Bt=Bt.resolve(o)),F[R]=[jr,Bt],A.prototype[jr]=Ot(jr)}return A._fields=F,A}}function Ot(y){return function(o){return o!==void 0&&(this._attributes[y]=o),this._attributes[y]}}class Oe extends B{constructor(o,l){super(),this.set(o,l)}set(o,l){typeof o=="string"&&(o=this.constructor._switchOn.fromName(o)),this._switch=o;const m=this.constructor.armForSwitch(this._switch);this._arm=m,this._armType=m===Q?Q:this.constructor._arms[m],this._value=l}get(){let o=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this._arm;if(this._arm!==Q&&this._arm!==o)throw new TypeError(`${o} not set`);return this._value}switch(){return this._switch}arm(){return this._arm}armType(){return this._armType}value(){return this._value}static armForSwitch(o){const l=this._switches.get(o);if(l!==void 0)return l;if(this._defaultArm)return this._defaultArm;throw new TypeError(`Bad union switch: ${o}`)}static armTypeForArm(o){return o===Q?Q:this._arms[o]}static read(o){const l=this._switchOn.read(o),m=this.armForSwitch(l),A=m===Q?Q:this._arms[m];let F;return F=A!==void 0?A.read(o):m.read(o),new this(l,F)}static write(o,l){if(!(o instanceof this))throw new h(`${o} is not a ${this.unionName}`);this._switchOn.write(o.switch(),l),o.armType().write(o.value(),l)}static isValid(o){return o instanceof this}static create(o,l,m){const A=class extends Oe{};A.unionName=l,o.results[l]=A,m.switchOn instanceof te?A._switchOn=m.switchOn.resolve(o):A._switchOn=m.switchOn,A._switches=new Map,A._arms={};let F=m.defaultArm;F instanceof te&&(F=F.resolve(o)),A._defaultArm=F;for(const[R,C]of m.switches){const jr=typeof R=="string"?A._switchOn.fromName(R):R;A._switches.set(jr,C)}if(A._switchOn.values!==void 0)for(const R of A._switchOn.values())A[R.name]=function(C){return new A(R,C)},A.prototype[R.name]=function(C){return this.set(R,C)};if(m.arms)for(const[R,C]of Object.entries(m.arms))A._arms[R]=C instanceof te?C.resolve(o):C,C!==Q&&(A.prototype[R]=function(){return this.get(R)});return A}}class pe extends te{constructor(o){super(),this.name=o}resolve(o){return o.definitions[this.name].resolve(o)}}class gr extends te{constructor(o,l){let m=arguments.length>2&&arguments[2]!==void 0&&arguments[2];super(),this.childReference=o,this.length=l,this.variable=m}resolve(o){let l=this.childReference,m=this.length;return l instanceof te&&(l=l.resolve(o)),m instanceof te&&(m=m.resolve(o)),this.variable?new Lr(l,m):new yr(l,m)}}class Qn extends te{constructor(o){super(),this.childReference=o,this.name=o.name}resolve(o){let l=this.childReference;return l instanceof te&&(l=l.resolve(o)),new Mr(l)}}class he extends te{constructor(o,l){super(),this.sizedType=o,this.length=l}resolve(o){let l=this.length;return l instanceof te&&(l=l.resolve(o)),new this.sizedType(l)}}class Je{constructor(o,l,m){this.constructor=o,this.name=l,this.config=m}resolve(o){return this.name in o.results?o.results[this.name]:this.constructor(o,this.name,this.config)}}function i(y,o,l){return l instanceof te&&(l=l.resolve(y)),y.results[o]=l,l}function u(y,o,l){return y.results[o]=l,l}class f{constructor(o){this._destination=o,this._definitions={}}enum(o,l){const m=new Je($e.create,o,l);this.define(o,m)}struct(o,l){const m=new Je(Le.create,o,l);this.define(o,m)}union(o,l){const m=new Je(Oe.create,o,l);this.define(o,m)}typedef(o,l){const m=new Je(i,o,l);this.define(o,m)}const(o,l){const m=new Je(u,o,l);this.define(o,m)}void(){return Q}bool(){return H}int(){return V}hyper(){return k}uint(){return N}uhyper(){return se}float(){return Ne}double(){return xt}quadruple(){return G}string(o){return new he(Dr,o)}opaque(o){return new he(Nr,o)}varOpaque(o){return new he(Te,o)}array(o,l){return new gr(o,l)}varArray(o,l){return new gr(o,l,!0)}option(o){return new Qn(o)}define(o,l){if(this._destination[o]!==void 0)throw new _(`${o} is already defined`);this._definitions[o]=l}lookup(o){return new pe(o)}resolve(){for(const o of Object.values(this._definitions))o.resolve({definitions:this._definitions,results:this._destination})}}function g(y){let o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(y){const l=new f(o);y(l),l.resolve()}return o}},742:(s,c)=>{c.byteLength=function(E){var x=b(E),I=x[0],S=x[1];return 3*(I+S)/4-S},c.toByteArray=function(E){var x,I,S=b(E),T=S[0],P=S[1],B=new v(function(q,z,X){return 3*(z+X)/4-X}(0,T,P)),D=0,j=P>0?T-4:T;for(I=0;I<j;I+=4)x=h[E.charCodeAt(I)]<<18|h[E.charCodeAt(I+1)]<<12|h[E.charCodeAt(I+2)]<<6|h[E.charCodeAt(I+3)],B[D++]=x>>16&255,B[D++]=x>>8&255,B[D++]=255&x;return P===2&&(x=h[E.charCodeAt(I)]<<2|h[E.charCodeAt(I+1)]>>4,B[D++]=255&x),P===1&&(x=h[E.charCodeAt(I)]<<10|h[E.charCodeAt(I+1)]<<4|h[E.charCodeAt(I+2)]>>2,B[D++]=x>>8&255,B[D++]=255&x),B},c.fromByteArray=function(E){for(var x,I=E.length,S=I%3,T=[],P=16383,B=0,D=I-S;B<D;B+=P)T.push(d(E,B,B+P>D?D:B+P));return S===1?(x=E[I-1],T.push(p[x>>2]+p[x<<4&63]+"==")):S===2&&(x=(E[I-2]<<8)+E[I-1],T.push(p[x>>10]+p[x>>4&63]+p[x<<2&63]+"=")),T.join("")};for(var p=[],h=[],v=typeof Uint8Array<"u"?Uint8Array:Array,_="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",w=0;w<64;++w)p[w]=_[w],h[_.charCodeAt(w)]=w;function b(E){var x=E.length;if(x%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var I=E.indexOf("=");return I===-1&&(I=x),[I,I===x?0:4-I%4]}function d(E,x,I){for(var S,T,P=[],B=x;B<I;B+=3)S=(E[B]<<16&16711680)+(E[B+1]<<8&65280)+(255&E[B+2]),P.push(p[(T=S)>>18&63]+p[T>>12&63]+p[T>>6&63]+p[63&T]);return P.join("")}h["-".charCodeAt(0)]=62,h["_".charCodeAt(0)]=63},764:(s,c,p)=>{const h=p(742),v=p(645),_=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;c.lW=d,c.h2=50;const w=2147483647;function b(i){if(i>w)throw new RangeError('The value "'+i+'" is invalid for option "size"');const u=new Uint8Array(i);return Object.setPrototypeOf(u,d.prototype),u}function d(i,u,f){if(typeof i=="number"){if(typeof u=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return I(i)}return E(i,u,f)}function E(i,u,f){if(typeof i=="string")return function(o,l){if(typeof l=="string"&&l!==""||(l="utf8"),!d.isEncoding(l))throw new TypeError("Unknown encoding: "+l);const m=0|B(o,l);let A=b(m);const F=A.write(o,l);return F!==m&&(A=A.slice(0,F)),A}(i,u);if(ArrayBuffer.isView(i))return function(o){if(pe(o,Uint8Array)){const l=new Uint8Array(o);return T(l.buffer,l.byteOffset,l.byteLength)}return S(o)}(i);if(i==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof i);if(pe(i,ArrayBuffer)||i&&pe(i.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(pe(i,SharedArrayBuffer)||i&&pe(i.buffer,SharedArrayBuffer)))return T(i,u,f);if(typeof i=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');const g=i.valueOf&&i.valueOf();if(g!=null&&g!==i)return d.from(g,u,f);const y=function(o){if(d.isBuffer(o)){const l=0|P(o.length),m=b(l);return m.length===0||o.copy(m,0,0,l),m}if(o.length!==void 0)return typeof o.length!="number"||gr(o.length)?b(0):S(o);if(o.type==="Buffer"&&Array.isArray(o.data))return S(o.data)}(i);if(y)return y;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof i[Symbol.toPrimitive]=="function")return d.from(i[Symbol.toPrimitive]("string"),u,f);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof i)}function x(i){if(typeof i!="number")throw new TypeError('"size" argument must be of type number');if(i<0)throw new RangeError('The value "'+i+'" is invalid for option "size"')}function I(i){return x(i),b(i<0?0:0|P(i))}function S(i){const u=i.length<0?0:0|P(i.length),f=b(u);for(let g=0;g<u;g+=1)f[g]=255&i[g];return f}function T(i,u,f){if(u<0||i.byteLength<u)throw new RangeError('"offset" is outside of buffer bounds');if(i.byteLength<u+(f||0))throw new RangeError('"length" is outside of buffer bounds');let g;return g=u===void 0&&f===void 0?new Uint8Array(i):f===void 0?new Uint8Array(i,u):new Uint8Array(i,u,f),Object.setPrototypeOf(g,d.prototype),g}function P(i){if(i>=w)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+w.toString(16)+" bytes");return 0|i}function B(i,u){if(d.isBuffer(i))return i.length;if(ArrayBuffer.isView(i)||pe(i,ArrayBuffer))return i.byteLength;if(typeof i!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof i);const f=i.length,g=arguments.length>2&&arguments[2]===!0;if(!g&&f===0)return 0;let y=!1;for(;;)switch(u){case"ascii":case"latin1":case"binary":return f;case"utf8":case"utf-8":return Le(i).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*f;case"hex":return f>>>1;case"base64":return Ot(i).length;default:if(y)return g?-1:Le(i).length;u=(""+u).toLowerCase(),y=!0}}function D(i,u,f){let g=!1;if((u===void 0||u<0)&&(u=0),u>this.length||((f===void 0||f>this.length)&&(f=this.length),f<=0)||(f>>>=0)<=(u>>>=0))return"";for(i||(i="utf8");;)switch(i){case"hex":return Ne(this,u,f);case"utf8":case"utf-8":return N(this,u,f);case"ascii":return hr(this,u,f);case"latin1":case"binary":return se(this,u,f);case"base64":return re(this,u,f);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return xt(this,u,f);default:if(g)throw new TypeError("Unknown encoding: "+i);i=(i+"").toLowerCase(),g=!0}}function j(i,u,f){const g=i[u];i[u]=i[f],i[f]=g}function q(i,u,f,g,y){if(i.length===0)return-1;if(typeof f=="string"?(g=f,f=0):f>2147483647?f=2147483647:f<-2147483648&&(f=-2147483648),gr(f=+f)&&(f=y?0:i.length-1),f<0&&(f=i.length+f),f>=i.length){if(y)return-1;f=i.length-1}else if(f<0){if(!y)return-1;f=0}if(typeof u=="string"&&(u=d.from(u,g)),d.isBuffer(u))return u.length===0?-1:z(i,u,f,g,y);if(typeof u=="number")return u&=255,typeof Uint8Array.prototype.indexOf=="function"?y?Uint8Array.prototype.indexOf.call(i,u,f):Uint8Array.prototype.lastIndexOf.call(i,u,f):z(i,[u],f,g,y);throw new TypeError("val must be string, number or Buffer")}function z(i,u,f,g,y){let o,l=1,m=i.length,A=u.length;if(g!==void 0&&((g=String(g).toLowerCase())==="ucs2"||g==="ucs-2"||g==="utf16le"||g==="utf-16le")){if(i.length<2||u.length<2)return-1;l=2,m/=2,A/=2,f/=2}function F(R,C){return l===1?R[C]:R.readUInt16BE(C*l)}if(y){let R=-1;for(o=f;o<m;o++)if(F(i,o)===F(u,R===-1?0:o-R)){if(R===-1&&(R=o),o-R+1===A)return R*l}else R!==-1&&(o-=o-R),R=-1}else for(f+A>m&&(f=m-A),o=f;o>=0;o--){let R=!0;for(let C=0;C<A;C++)if(F(i,o+C)!==F(u,C)){R=!1;break}if(R)return o}return-1}function X(i,u,f,g){f=Number(f)||0;const y=i.length-f;g?(g=Number(g))>y&&(g=y):g=y;const o=u.length;let l;for(g>o/2&&(g=o/2),l=0;l<g;++l){const m=parseInt(u.substr(2*l,2),16);if(gr(m))return l;i[f+l]=m}return l}function V(i,u,f,g){return Oe(Le(u,i.length-f),i,f,g)}function ae(i,u,f,g){return Oe(function(y){const o=[];for(let l=0;l<y.length;++l)o.push(255&y.charCodeAt(l));return o}(u),i,f,g)}function ue(i,u,f,g){return Oe(Ot(u),i,f,g)}function k(i,u,f,g){return Oe(function(y,o){let l,m,A;const F=[];for(let R=0;R<y.length&&!((o-=2)<0);++R)l=y.charCodeAt(R),m=l>>8,A=l%256,F.push(A),F.push(m);return F}(u,i.length-f),i,f,g)}function re(i,u,f){return u===0&&f===i.length?h.fromByteArray(i):h.fromByteArray(i.slice(u,f))}function N(i,u,f){f=Math.min(i.length,f);const g=[];let y=u;for(;y<f;){const o=i[y];let l=null,m=o>239?4:o>223?3:o>191?2:1;if(y+m<=f){let A,F,R,C;switch(m){case 1:o<128&&(l=o);break;case 2:A=i[y+1],(192&A)==128&&(C=(31&o)<<6|63&A,C>127&&(l=C));break;case 3:A=i[y+1],F=i[y+2],(192&A)==128&&(192&F)==128&&(C=(15&o)<<12|(63&A)<<6|63&F,C>2047&&(C<55296||C>57343)&&(l=C));break;case 4:A=i[y+1],F=i[y+2],R=i[y+3],(192&A)==128&&(192&F)==128&&(192&R)==128&&(C=(15&o)<<18|(63&A)<<12|(63&F)<<6|63&R,C>65535&&C<1114112&&(l=C))}}l===null?(l=65533,m=1):l>65535&&(l-=65536,g.push(l>>>10&1023|55296),l=56320|1023&l),g.push(l),y+=m}return function(o){const l=o.length;if(l<=ce)return String.fromCharCode.apply(String,o);let m="",A=0;for(;A<l;)m+=String.fromCharCode.apply(String,o.slice(A,A+=ce));return m}(g)}d.TYPED_ARRAY_SUPPORT=function(){try{const i=new Uint8Array(1),u={foo:function(){return 42}};return Object.setPrototypeOf(u,Uint8Array.prototype),Object.setPrototypeOf(i,u),i.foo()===42}catch{return!1}}(),d.TYPED_ARRAY_SUPPORT||typeof console>"u"||typeof console.error!="function"||console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."),Object.defineProperty(d.prototype,"parent",{enumerable:!0,get:function(){if(d.isBuffer(this))return this.buffer}}),Object.defineProperty(d.prototype,"offset",{enumerable:!0,get:function(){if(d.isBuffer(this))return this.byteOffset}}),d.poolSize=8192,d.from=function(i,u,f){return E(i,u,f)},Object.setPrototypeOf(d.prototype,Uint8Array.prototype),Object.setPrototypeOf(d,Uint8Array),d.alloc=function(i,u,f){return function(g,y,o){return x(g),g<=0?b(g):y!==void 0?typeof o=="string"?b(g).fill(y,o):b(g).fill(y):b(g)}(i,u,f)},d.allocUnsafe=function(i){return I(i)},d.allocUnsafeSlow=function(i){return I(i)},d.isBuffer=function(i){return i!=null&&i._isBuffer===!0&&i!==d.prototype},d.compare=function(i,u){if(pe(i,Uint8Array)&&(i=d.from(i,i.offset,i.byteLength)),pe(u,Uint8Array)&&(u=d.from(u,u.offset,u.byteLength)),!d.isBuffer(i)||!d.isBuffer(u))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(i===u)return 0;let f=i.length,g=u.length;for(let y=0,o=Math.min(f,g);y<o;++y)if(i[y]!==u[y]){f=i[y],g=u[y];break}return f<g?-1:g<f?1:0},d.isEncoding=function(i){switch(String(i).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},d.concat=function(i,u){if(!Array.isArray(i))throw new TypeError('"list" argument must be an Array of Buffers');if(i.length===0)return d.alloc(0);let f;if(u===void 0)for(u=0,f=0;f<i.length;++f)u+=i[f].length;const g=d.allocUnsafe(u);let y=0;for(f=0;f<i.length;++f){let o=i[f];if(pe(o,Uint8Array))y+o.length>g.length?(d.isBuffer(o)||(o=d.from(o)),o.copy(g,y)):Uint8Array.prototype.set.call(g,o,y);else{if(!d.isBuffer(o))throw new TypeError('"list" argument must be an Array of Buffers');o.copy(g,y)}y+=o.length}return g},d.byteLength=B,d.prototype._isBuffer=!0,d.prototype.swap16=function(){const i=this.length;if(i%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let u=0;u<i;u+=2)j(this,u,u+1);return this},d.prototype.swap32=function(){const i=this.length;if(i%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let u=0;u<i;u+=4)j(this,u,u+3),j(this,u+1,u+2);return this},d.prototype.swap64=function(){const i=this.length;if(i%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let u=0;u<i;u+=8)j(this,u,u+7),j(this,u+1,u+6),j(this,u+2,u+5),j(this,u+3,u+4);return this},d.prototype.toString=function(){const i=this.length;return i===0?"":arguments.length===0?N(this,0,i):D.apply(this,arguments)},d.prototype.toLocaleString=d.prototype.toString,d.prototype.equals=function(i){if(!d.isBuffer(i))throw new TypeError("Argument must be a Buffer");return this===i||d.compare(this,i)===0},d.prototype.inspect=function(){let i="";const u=c.h2;return i=this.toString("hex",0,u).replace(/(.{2})/g,"$1 ").trim(),this.length>u&&(i+=" ... "),"<Buffer "+i+">"},_&&(d.prototype[_]=d.prototype.inspect),d.prototype.compare=function(i,u,f,g,y){if(pe(i,Uint8Array)&&(i=d.from(i,i.offset,i.byteLength)),!d.isBuffer(i))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof i);if(u===void 0&&(u=0),f===void 0&&(f=i?i.length:0),g===void 0&&(g=0),y===void 0&&(y=this.length),u<0||f>i.length||g<0||y>this.length)throw new RangeError("out of range index");if(g>=y&&u>=f)return 0;if(g>=y)return-1;if(u>=f)return 1;if(this===i)return 0;let o=(y>>>=0)-(g>>>=0),l=(f>>>=0)-(u>>>=0);const m=Math.min(o,l),A=this.slice(g,y),F=i.slice(u,f);for(let R=0;R<m;++R)if(A[R]!==F[R]){o=A[R],l=F[R];break}return o<l?-1:l<o?1:0},d.prototype.includes=function(i,u,f){return this.indexOf(i,u,f)!==-1},d.prototype.indexOf=function(i,u,f){return q(this,i,u,f,!0)},d.prototype.lastIndexOf=function(i,u,f){return q(this,i,u,f,!1)},d.prototype.write=function(i,u,f,g){if(u===void 0)g="utf8",f=this.length,u=0;else if(f===void 0&&typeof u=="string")g=u,f=this.length,u=0;else{if(!isFinite(u))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");u>>>=0,isFinite(f)?(f>>>=0,g===void 0&&(g="utf8")):(g=f,f=void 0)}const y=this.length-u;if((f===void 0||f>y)&&(f=y),i.length>0&&(f<0||u<0)||u>this.length)throw new RangeError("Attempt to write outside buffer bounds");g||(g="utf8");let o=!1;for(;;)switch(g){case"hex":return X(this,i,u,f);case"utf8":case"utf-8":return V(this,i,u,f);case"ascii":case"latin1":case"binary":return ae(this,i,u,f);case"base64":return ue(this,i,u,f);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return k(this,i,u,f);default:if(o)throw new TypeError("Unknown encoding: "+g);g=(""+g).toLowerCase(),o=!0}},d.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};const ce=4096;function hr(i,u,f){let g="";f=Math.min(i.length,f);for(let y=u;y<f;++y)g+=String.fromCharCode(127&i[y]);return g}function se(i,u,f){let g="";f=Math.min(i.length,f);for(let y=u;y<f;++y)g+=String.fromCharCode(i[y]);return g}function Ne(i,u,f){const g=i.length;(!u||u<0)&&(u=0),(!f||f<0||f>g)&&(f=g);let y="";for(let o=u;o<f;++o)y+=Qn[i[o]];return y}function xt(i,u,f){const g=i.slice(u,f);let y="";for(let o=0;o<g.length-1;o+=2)y+=String.fromCharCode(g[o]+256*g[o+1]);return y}function G(i,u,f){if(i%1!=0||i<0)throw new RangeError("offset is not uint");if(i+u>f)throw new RangeError("Trying to access beyond buffer length")}function H(i,u,f,g,y,o){if(!d.isBuffer(i))throw new TypeError('"buffer" argument must be a Buffer instance');if(u>y||u<o)throw new RangeError('"value" argument is out of bounds');if(f+g>i.length)throw new RangeError("Index out of range")}function dr(i,u,f,g,y){Mr(u,g,y,i,f,7);let o=Number(u&BigInt(4294967295));i[f++]=o,o>>=8,i[f++]=o,o>>=8,i[f++]=o,o>>=8,i[f++]=o;let l=Number(u>>BigInt(32)&BigInt(4294967295));return i[f++]=l,l>>=8,i[f++]=l,l>>=8,i[f++]=l,l>>=8,i[f++]=l,f}function Dr(i,u,f,g,y){Mr(u,g,y,i,f,7);let o=Number(u&BigInt(4294967295));i[f+7]=o,o>>=8,i[f+6]=o,o>>=8,i[f+5]=o,o>>=8,i[f+4]=o;let l=Number(u>>BigInt(32)&BigInt(4294967295));return i[f+3]=l,l>>=8,i[f+2]=l,l>>=8,i[f+1]=l,l>>=8,i[f]=l,f+8}function It(i,u,f,g,y,o){if(f+g>i.length)throw new RangeError("Index out of range");if(f<0)throw new RangeError("Index out of range")}function Nr(i,u,f,g,y){return u=+u,f>>>=0,y||It(i,0,f,4),v.write(i,u,f,g,23,4),f+4}function Tt(i,u,f,g,y){return u=+u,f>>>=0,y||It(i,0,f,8),v.write(i,u,f,g,52,8),f+8}d.prototype.slice=function(i,u){const f=this.length;(i=~~i)<0?(i+=f)<0&&(i=0):i>f&&(i=f),(u=u===void 0?f:~~u)<0?(u+=f)<0&&(u=0):u>f&&(u=f),u<i&&(u=i);const g=this.subarray(i,u);return Object.setPrototypeOf(g,d.prototype),g},d.prototype.readUintLE=d.prototype.readUIntLE=function(i,u,f){i>>>=0,u>>>=0,f||G(i,u,this.length);let g=this[i],y=1,o=0;for(;++o<u&&(y*=256);)g+=this[i+o]*y;return g},d.prototype.readUintBE=d.prototype.readUIntBE=function(i,u,f){i>>>=0,u>>>=0,f||G(i,u,this.length);let g=this[i+--u],y=1;for(;u>0&&(y*=256);)g+=this[i+--u]*y;return g},d.prototype.readUint8=d.prototype.readUInt8=function(i,u){return i>>>=0,u||G(i,1,this.length),this[i]},d.prototype.readUint16LE=d.prototype.readUInt16LE=function(i,u){return i>>>=0,u||G(i,2,this.length),this[i]|this[i+1]<<8},d.prototype.readUint16BE=d.prototype.readUInt16BE=function(i,u){return i>>>=0,u||G(i,2,this.length),this[i]<<8|this[i+1]},d.prototype.readUint32LE=d.prototype.readUInt32LE=function(i,u){return i>>>=0,u||G(i,4,this.length),(this[i]|this[i+1]<<8|this[i+2]<<16)+16777216*this[i+3]},d.prototype.readUint32BE=d.prototype.readUInt32BE=function(i,u){return i>>>=0,u||G(i,4,this.length),16777216*this[i]+(this[i+1]<<16|this[i+2]<<8|this[i+3])},d.prototype.readBigUInt64LE=he(function(i){Q(i>>>=0,"offset");const u=this[i],f=this[i+7];u!==void 0&&f!==void 0||$e(i,this.length-8);const g=u+256*this[++i]+65536*this[++i]+this[++i]*2**24,y=this[++i]+256*this[++i]+65536*this[++i]+f*2**24;return BigInt(g)+(BigInt(y)<<BigInt(32))}),d.prototype.readBigUInt64BE=he(function(i){Q(i>>>=0,"offset");const u=this[i],f=this[i+7];u!==void 0&&f!==void 0||$e(i,this.length-8);const g=u*2**24+65536*this[++i]+256*this[++i]+this[++i],y=this[++i]*2**24+65536*this[++i]+256*this[++i]+f;return(BigInt(g)<<BigInt(32))+BigInt(y)}),d.prototype.readIntLE=function(i,u,f){i>>>=0,u>>>=0,f||G(i,u,this.length);let g=this[i],y=1,o=0;for(;++o<u&&(y*=256);)g+=this[i+o]*y;return y*=128,g>=y&&(g-=Math.pow(2,8*u)),g},d.prototype.readIntBE=function(i,u,f){i>>>=0,u>>>=0,f||G(i,u,this.length);let g=u,y=1,o=this[i+--g];for(;g>0&&(y*=256);)o+=this[i+--g]*y;return y*=128,o>=y&&(o-=Math.pow(2,8*u)),o},d.prototype.readInt8=function(i,u){return i>>>=0,u||G(i,1,this.length),128&this[i]?-1*(255-this[i]+1):this[i]},d.prototype.readInt16LE=function(i,u){i>>>=0,u||G(i,2,this.length);const f=this[i]|this[i+1]<<8;return 32768&f?4294901760|f:f},d.prototype.readInt16BE=function(i,u){i>>>=0,u||G(i,2,this.length);const f=this[i+1]|this[i]<<8;return 32768&f?4294901760|f:f},d.prototype.readInt32LE=function(i,u){return i>>>=0,u||G(i,4,this.length),this[i]|this[i+1]<<8|this[i+2]<<16|this[i+3]<<24},d.prototype.readInt32BE=function(i,u){return i>>>=0,u||G(i,4,this.length),this[i]<<24|this[i+1]<<16|this[i+2]<<8|this[i+3]},d.prototype.readBigInt64LE=he(function(i){Q(i>>>=0,"offset");const u=this[i],f=this[i+7];u!==void 0&&f!==void 0||$e(i,this.length-8);const g=this[i+4]+256*this[i+5]+65536*this[i+6]+(f<<24);return(BigInt(g)<<BigInt(32))+BigInt(u+256*this[++i]+65536*this[++i]+this[++i]*16777216)}),d.prototype.readBigInt64BE=he(function(i){Q(i>>>=0,"offset");const u=this[i],f=this[i+7];u!==void 0&&f!==void 0||$e(i,this.length-8);const g=(u<<24)+65536*this[++i]+256*this[++i]+this[++i];return(BigInt(g)<<BigInt(32))+BigInt(this[++i]*16777216+65536*this[++i]+256*this[++i]+f)}),d.prototype.readFloatLE=function(i,u){return i>>>=0,u||G(i,4,this.length),v.read(this,i,!0,23,4)},d.prototype.readFloatBE=function(i,u){return i>>>=0,u||G(i,4,this.length),v.read(this,i,!1,23,4)},d.prototype.readDoubleLE=function(i,u){return i>>>=0,u||G(i,8,this.length),v.read(this,i,!0,52,8)},d.prototype.readDoubleBE=function(i,u){return i>>>=0,u||G(i,8,this.length),v.read(this,i,!1,52,8)},d.prototype.writeUintLE=d.prototype.writeUIntLE=function(i,u,f,g){i=+i,u>>>=0,f>>>=0,!g&&H(this,i,u,f,Math.pow(2,8*f)-1,0);let y=1,o=0;for(this[u]=255&i;++o<f&&(y*=256);)this[u+o]=i/y&255;return u+f},d.prototype.writeUintBE=d.prototype.writeUIntBE=function(i,u,f,g){i=+i,u>>>=0,f>>>=0,!g&&H(this,i,u,f,Math.pow(2,8*f)-1,0);let y=f-1,o=1;for(this[u+y]=255&i;--y>=0&&(o*=256);)this[u+y]=i/o&255;return u+f},d.prototype.writeUint8=d.prototype.writeUInt8=function(i,u,f){return i=+i,u>>>=0,f||H(this,i,u,1,255,0),this[u]=255&i,u+1},d.prototype.writeUint16LE=d.prototype.writeUInt16LE=function(i,u,f){return i=+i,u>>>=0,f||H(this,i,u,2,65535,0),this[u]=255&i,this[u+1]=i>>>8,u+2},d.prototype.writeUint16BE=d.prototype.writeUInt16BE=function(i,u,f){return i=+i,u>>>=0,f||H(this,i,u,2,65535,0),this[u]=i>>>8,this[u+1]=255&i,u+2},d.prototype.writeUint32LE=d.prototype.writeUInt32LE=function(i,u,f){return i=+i,u>>>=0,f||H(this,i,u,4,4294967295,0),this[u+3]=i>>>24,this[u+2]=i>>>16,this[u+1]=i>>>8,this[u]=255&i,u+4},d.prototype.writeUint32BE=d.prototype.writeUInt32BE=function(i,u,f){return i=+i,u>>>=0,f||H(this,i,u,4,4294967295,0),this[u]=i>>>24,this[u+1]=i>>>16,this[u+2]=i>>>8,this[u+3]=255&i,u+4},d.prototype.writeBigUInt64LE=he(function(i,u=0){return dr(this,i,u,BigInt(0),BigInt("0xffffffffffffffff"))}),d.prototype.writeBigUInt64BE=he(function(i,u=0){return Dr(this,i,u,BigInt(0),BigInt("0xffffffffffffffff"))}),d.prototype.writeIntLE=function(i,u,f,g){if(i=+i,u>>>=0,!g){const m=Math.pow(2,8*f-1);H(this,i,u,f,m-1,-m)}let y=0,o=1,l=0;for(this[u]=255&i;++y<f&&(o*=256);)i<0&&l===0&&this[u+y-1]!==0&&(l=1),this[u+y]=(i/o>>0)-l&255;return u+f},d.prototype.writeIntBE=function(i,u,f,g){if(i=+i,u>>>=0,!g){const m=Math.pow(2,8*f-1);H(this,i,u,f,m-1,-m)}let y=f-1,o=1,l=0;for(this[u+y]=255&i;--y>=0&&(o*=256);)i<0&&l===0&&this[u+y+1]!==0&&(l=1),this[u+y]=(i/o>>0)-l&255;return u+f},d.prototype.writeInt8=function(i,u,f){return i=+i,u>>>=0,f||H(this,i,u,1,127,-128),i<0&&(i=255+i+1),this[u]=255&i,u+1},d.prototype.writeInt16LE=function(i,u,f){return i=+i,u>>>=0,f||H(this,i,u,2,32767,-32768),this[u]=255&i,this[u+1]=i>>>8,u+2},d.prototype.writeInt16BE=function(i,u,f){return i=+i,u>>>=0,f||H(this,i,u,2,32767,-32768),this[u]=i>>>8,this[u+1]=255&i,u+2},d.prototype.writeInt32LE=function(i,u,f){return i=+i,u>>>=0,f||H(this,i,u,4,2147483647,-2147483648),this[u]=255&i,this[u+1]=i>>>8,this[u+2]=i>>>16,this[u+3]=i>>>24,u+4},d.prototype.writeInt32BE=function(i,u,f){return i=+i,u>>>=0,f||H(this,i,u,4,2147483647,-2147483648),i<0&&(i=4294967295+i+1),this[u]=i>>>24,this[u+1]=i>>>16,this[u+2]=i>>>8,this[u+3]=255&i,u+4},d.prototype.writeBigInt64LE=he(function(i,u=0){return dr(this,i,u,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),d.prototype.writeBigInt64BE=he(function(i,u=0){return Dr(this,i,u,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),d.prototype.writeFloatLE=function(i,u,f){return Nr(this,i,u,!0,f)},d.prototype.writeFloatBE=function(i,u,f){return Nr(this,i,u,!1,f)},d.prototype.writeDoubleLE=function(i,u,f){return Tt(this,i,u,!0,f)},d.prototype.writeDoubleBE=function(i,u,f){return Tt(this,i,u,!1,f)},d.prototype.copy=function(i,u,f,g){if(!d.isBuffer(i))throw new TypeError("argument should be a Buffer");if(f||(f=0),g||g===0||(g=this.length),u>=i.length&&(u=i.length),u||(u=0),g>0&&g<f&&(g=f),g===f||i.length===0||this.length===0)return 0;if(u<0)throw new RangeError("targetStart out of bounds");if(f<0||f>=this.length)throw new RangeError("Index out of range");if(g<0)throw new RangeError("sourceEnd out of bounds");g>this.length&&(g=this.length),i.length-u<g-f&&(g=i.length-u+f);const y=g-f;return this===i&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(u,f,g):Uint8Array.prototype.set.call(i,this.subarray(f,g),u),y},d.prototype.fill=function(i,u,f,g){if(typeof i=="string"){if(typeof u=="string"?(g=u,u=0,f=this.length):typeof f=="string"&&(g=f,f=this.length),g!==void 0&&typeof g!="string")throw new TypeError("encoding must be a string");if(typeof g=="string"&&!d.isEncoding(g))throw new TypeError("Unknown encoding: "+g);if(i.length===1){const o=i.charCodeAt(0);(g==="utf8"&&o<128||g==="latin1")&&(i=o)}}else typeof i=="number"?i&=255:typeof i=="boolean"&&(i=Number(i));if(u<0||this.length<u||this.length<f)throw new RangeError("Out of range index");if(f<=u)return this;let y;if(u>>>=0,f=f===void 0?this.length:f>>>0,i||(i=0),typeof i=="number")for(y=u;y<f;++y)this[y]=i;else{const o=d.isBuffer(i)?i:d.from(i,g),l=o.length;if(l===0)throw new TypeError('The value "'+i+'" is invalid for argument "value"');for(y=0;y<f-u;++y)this[y+u]=o[y%l]}return this};const Te={};function yr(i,u,f){Te[i]=class extends f{constructor(){super(),Object.defineProperty(this,"message",{value:u.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${i}]`,this.stack,delete this.name}get code(){return i}set code(g){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:g,writable:!0})}toString(){return`${this.name} [${i}]: ${this.message}`}}}function Lr(i){let u="",f=i.length;const g=i[0]==="-"?1:0;for(;f>=g+4;f-=3)u=`_${i.slice(f-3,f)}${u}`;return`${i.slice(0,f)}${u}`}function Mr(i,u,f,g,y,o){if(i>f||i<u){const l=typeof u=="bigint"?"n":"";let m;throw m=o>3?u===0||u===BigInt(0)?`>= 0${l} and < 2${l} ** ${8*(o+1)}${l}`:`>= -(2${l} ** ${8*(o+1)-1}${l}) and < 2 ** ${8*(o+1)-1}${l}`:`>= ${u}${l} and <= ${f}${l}`,new Te.ERR_OUT_OF_RANGE("value",m,i)}(function(l,m,A){Q(m,"offset"),l[m]!==void 0&&l[m+A]!==void 0||$e(m,l.length-(A+1))})(g,y,o)}function Q(i,u){if(typeof i!="number")throw new Te.ERR_INVALID_ARG_TYPE(u,"number",i)}function $e(i,u,f){throw Math.floor(i)!==i?(Q(i,f),new Te.ERR_OUT_OF_RANGE(f||"offset","an integer",i)):u<0?new Te.ERR_BUFFER_OUT_OF_BOUNDS:new Te.ERR_OUT_OF_RANGE(f||"offset",`>= ${f?1:0} and <= ${u}`,i)}yr("ERR_BUFFER_OUT_OF_BOUNDS",function(i){return i?`${i} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),yr("ERR_INVALID_ARG_TYPE",function(i,u){return`The "${i}" argument must be of type number. Received type ${typeof u}`},TypeError),yr("ERR_OUT_OF_RANGE",function(i,u,f){let g=`The value of "${i}" is out of range.`,y=f;return Number.isInteger(f)&&Math.abs(f)>4294967296?y=Lr(String(f)):typeof f=="bigint"&&(y=String(f),(f>BigInt(2)**BigInt(32)||f<-(BigInt(2)**BigInt(32)))&&(y=Lr(y)),y+="n"),g+=` It must be ${u}. Received ${y}`,g},RangeError);const te=/[^+/0-9A-Za-z-_]/g;function Le(i,u){let f;u=u||1/0;const g=i.length;let y=null;const o=[];for(let l=0;l<g;++l){if(f=i.charCodeAt(l),f>55295&&f<57344){if(!y){if(f>56319){(u-=3)>-1&&o.push(239,191,189);continue}if(l+1===g){(u-=3)>-1&&o.push(239,191,189);continue}y=f;continue}if(f<56320){(u-=3)>-1&&o.push(239,191,189),y=f;continue}f=65536+(y-55296<<10|f-56320)}else y&&(u-=3)>-1&&o.push(239,191,189);if(y=null,f<128){if((u-=1)<0)break;o.push(f)}else if(f<2048){if((u-=2)<0)break;o.push(f>>6|192,63&f|128)}else if(f<65536){if((u-=3)<0)break;o.push(f>>12|224,f>>6&63|128,63&f|128)}else{if(!(f<1114112))throw new Error("Invalid code point");if((u-=4)<0)break;o.push(f>>18|240,f>>12&63|128,f>>6&63|128,63&f|128)}}return o}function Ot(i){return h.toByteArray(function(u){if((u=(u=u.split("=")[0]).trim().replace(te,"")).length<2)return"";for(;u.length%4!=0;)u+="=";return u}(i))}function Oe(i,u,f,g){let y;for(y=0;y<g&&!(y+f>=u.length||y>=i.length);++y)u[y+f]=i[y];return y}function pe(i,u){return i instanceof u||i!=null&&i.constructor!=null&&i.constructor.name!=null&&i.constructor.name===u.name}function gr(i){return i!=i}const Qn=function(){const i="0123456789abcdef",u=new Array(256);for(let f=0;f<16;++f){const g=16*f;for(let y=0;y<16;++y)u[g+y]=i[f]+i[y]}return u}();function he(i){return typeof BigInt>"u"?Je:i}function Je(){throw new Error("BigInt not supported")}},645:(s,c)=>{c.read=function(p,h,v,_,w){var b,d,E=8*w-_-1,x=(1<<E)-1,I=x>>1,S=-7,T=v?w-1:0,P=v?-1:1,B=p[h+T];for(T+=P,b=B&(1<<-S)-1,B>>=-S,S+=E;S>0;b=256*b+p[h+T],T+=P,S-=8);for(d=b&(1<<-S)-1,b>>=-S,S+=_;S>0;d=256*d+p[h+T],T+=P,S-=8);if(b===0)b=1-I;else{if(b===x)return d?NaN:1/0*(B?-1:1);d+=Math.pow(2,_),b-=I}return(B?-1:1)*d*Math.pow(2,b-_)},c.write=function(p,h,v,_,w,b){var d,E,x,I=8*b-w-1,S=(1<<I)-1,T=S>>1,P=w===23?Math.pow(2,-24)-Math.pow(2,-77):0,B=_?0:b-1,D=_?1:-1,j=h<0||h===0&&1/h<0?1:0;for(h=Math.abs(h),isNaN(h)||h===1/0?(E=isNaN(h)?1:0,d=S):(d=Math.floor(Math.log(h)/Math.LN2),h*(x=Math.pow(2,-d))<1&&(d--,x*=2),(h+=d+T>=1?P/x:P*Math.pow(2,1-T))*x>=2&&(d++,x/=2),d+T>=S?(E=0,d=S):d+T>=1?(E=(h*x-1)*Math.pow(2,w),d+=T):(E=h*Math.pow(2,T-1)*Math.pow(2,w),d=0));w>=8;p[v+B]=255&E,B+=D,E/=256,w-=8);for(d=d<<w|E,I+=w;I>0;p[v+B]=255&d,B+=D,d/=256,I-=8);p[v+B-D]|=128*j}}},n={};function a(s){var c=n[s];if(c!==void 0)return c.exports;var p=n[s]={exports:{}};return t[s](p,p.exports,a),p.exports}return a.d=(s,c)=>{for(var p in c)a.o(c,p)&&!a.o(s,p)&&Object.defineProperty(s,p,{enumerable:!0,get:c[p]})},a.g=function(){if(typeof globalThis=="object")return globalThis;try{return this||new Function("return this")()}catch{if(typeof window=="object")return window}}(),a.o=(s,c)=>Object.prototype.hasOwnProperty.call(s,c),a.r=s=>{typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(s,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(s,"__esModule",{value:!0})},a(899)})())})(Va);function l1(e){const r={variantId:Ie.Uint64.fromString(e.variantId.toString()),version:e.version||Math.floor(Date.now()/1e3),items:e.items.map(n=>new Ie.BundleItem({collectionId:Ie.Uint64.fromString(n.collectionId.toString()),productId:Ie.Uint64.fromString(n.productId.toString()),variantId:Ie.Uint64.fromString(n.variantId.toString()),sku:n.sku||"",quantity:n.quantity,ext:new Ie.BundleItemExt(0)})),ext:new Ie.BundleExt(0)},t=new Ie.Bundle(r);return Ie.BundleEnvelope.envelopeTypeBundle(t).toXDR("base64")}const Ie=Va.exports.config(e=>{e.enum("EnvelopeType",{envelopeTypeBundle:0}),e.typedef("Uint32",e.uint()),e.typedef("Uint64",e.uhyper()),e.union("BundleItemExt",{switchOn:e.int(),switchName:"v",switches:[[0,e.void()]],arms:{}}),e.struct("BundleItem",[["collectionId",e.lookup("Uint64")],["productId",e.lookup("Uint64")],["variantId",e.lookup("Uint64")],["sku",e.string()],["quantity",e.lookup("Uint32")],["ext",e.lookup("BundleItemExt")]]),e.union("BundleExt",{switchOn:e.int(),switchName:"v",switches:[[0,e.void()]],arms:{}}),e.struct("Bundle",[["variantId",e.lookup("Uint64")],["items",e.varArray(e.lookup("BundleItem"),500)],["version",e.lookup("Uint32")],["ext",e.lookup("BundleExt")]]),e.union("BundleEnvelope",{switchOn:e.lookup("EnvelopeType"),switchName:"type",switches:[["envelopeTypeBundle","v1"]],arms:{v1:e.lookup("Bundle")}})}),Ha="/bundling-storefront-manager";function p1(){return Math.ceil(Date.now()/1e3)}async function h1(){try{const{timestamp:e}=await Or("get",`${Ha}/t`,{headers:{"X-Recharge-App":"storefront-client"}});return e}catch(e){return console.error(`Fetch failed: ${e}. Using client-side date.`),p1()}}async function d1(e){const r=be(),t=await Ya(e);if(t!==!0)throw new Error(t);const n=await h1(),a=l1({variantId:e.externalVariantId,version:n,items:e.selections.map(s=>({collectionId:s.collectionId,productId:s.externalProductId,variantId:s.externalVariantId,quantity:s.quantity,sku:""}))});try{const s=await Or("post",`${Ha}/api/v1/bundles`,{data:{bundle:a},headers:{Origin:`https://${r.storeIdentifier}`}});if(!s.id||s.code!==200)throw new Error(`1: failed generating rb_id: ${JSON.stringify(s)}`);return s.id}catch(s){throw new Error(`2: failed generating rb_id ${s}`)}}function y1(e,r){const t=Ka(e);if(t!==!0)throw new Error(`Dynamic Bundle is invalid. ${t}`);const n=`${Sl(9)}:${e.externalProductId}`;return e.selections.map(a=>{const s={id:a.externalVariantId,quantity:a.quantity,properties:{_rc_bundle:n,_rc_bundle_variant:e.externalVariantId,_rc_bundle_parent:r,_rc_bundle_collection_id:a.collectionId}};return a.sellingPlan?s.selling_plan=a.sellingPlan:a.shippingIntervalFrequency&&(s.properties.shipping_interval_frequency=a.shippingIntervalFrequency,s.properties.shipping_interval_unit_type=a.shippingIntervalUnitType,s.id=`${a.discountedVariantId}`),s})}async function Ya(e){try{return e?await qa(e.externalProductId)?!0:"Bundle settings do not exist for the given product":"Bundle is not defined"}catch(r){return`Error fetching bundle settings: ${r}`}}const g1={day:["day","days","Days"],days:["day","days","Days"],Days:["day","days","Days"],week:["week","weeks","Weeks"],weeks:["week","weeks","Weeks"],Weeks:["week","weeks","Weeks"],month:["month","months","Months"],months:["month","months","Months"],Months:["month","months","Months"]};function Ka(e){if(!e)return"No bundle defined.";if(e.selections.length===0)return"No selections defined.";const{shippingIntervalFrequency:r,shippingIntervalUnitType:t}=e.selections.find(n=>n.shippingIntervalFrequency||n.shippingIntervalUnitType)||{};if(r||t){if(!r||!t)return"Shipping intervals do not match on selections.";{const n=g1[t];for(let a=0;a<e.selections.length;a++){const{shippingIntervalFrequency:s,shippingIntervalUnitType:c}=e.selections[a];if(s&&s!==r||c&&!n.includes(c))return"Shipping intervals do not match on selections."}}}return!0}async function v1(e,r){const{bundle_selection:t}=await O("get","/bundle_selections",{id:r},e);return t}function m1(e,r){return O("get","/bundle_selections",{query:r},e)}async function _1(e,r){const{bundle_selection:t}=await O("post","/bundle_selections",{data:r},e);return t}async function w1(e,r,t){const{bundle_selection:n}=await O("put","/bundle_selections",{id:r,data:t},e);return n}function b1(e,r){return O("delete","/bundle_selections",{id:r},e)}async function $1(e,r,t){const{subscription:n}=await O("put","/bundles",{id:r,data:t},e);return n}var A1=Object.freeze({__proto__:null,getBundleId:d1,getDynamicBundleItems:y1,validateBundle:Ya,validateDynamicBundle:Ka,getBundleSelection:v1,listBundleSelections:m1,createBundleSelection:_1,updateBundleSelection:w1,deleteBundleSelection:b1,updateBundle:$1});async function E1(e,r,t){const{charge:n}=await O("get","/charges",{id:r,query:{include:t?.include}},e);return n}function S1(e,r){return O("get","/charges",{query:r},e)}async function x1(e,r,t){const{charge:n}=await O("post",`/charges/${r}/apply_discount`,{data:{discount_code:t}},e);return n}async function I1(e,r){const{charge:t}=await O("post",`/charges/${r}/remove_discount`,{},e);return t}async function T1(e,r,t){const{charge:n}=await O("post",`/charges/${r}/skip`,{data:{purchase_item_ids:t.map(a=>Number(a))}},e);return n}async function O1(e,r,t){const{charge:n}=await O("post",`/charges/${r}/unskip`,{data:{purchase_item_ids:t.map(a=>Number(a))}},e);return n}async function B1(e,r){const{charge:t}=await O("post",`/charges/${r}/process`,{},e);return t}var P1=Object.freeze({__proto__:null,getCharge:E1,listCharges:S1,applyDiscountToCharge:x1,removeDiscountsFromCharge:I1,skipCharge:T1,unskipCharge:O1,processCharge:B1});async function R1(e,r){const{membership:t}=await O("get","/memberships",{id:r},e);return t}function F1(e,r){return O("get","/memberships",{query:r},e)}async function C1(e,r,t){const{membership:n}=await O("post",`/memberships/${r}/cancel`,{data:t},e);return n}async function U1(e,r,t){const{membership:n}=await O("post",`/memberships/${r}/activate`,{data:t},e);return n}async function D1(e,r,t){const{membership:n}=await O("post",`/memberships/${r}/change`,{data:t},e);return n}var N1=Object.freeze({__proto__:null,getMembership:R1,listMemberships:F1,cancelMembership:C1,activateMembership:U1,changeMembership:D1});async function L1(e,r,t){const{membership_program:n}=await O("get","/membership_programs",{id:r,query:{include:t?.include}},e);return n}function M1(e,r){return O("get","/membership_programs",{query:r},e)}var j1=Object.freeze({__proto__:null,getMembershipProgram:L1,listMembershipPrograms:M1});async function k1(e,r){const{metafield:t}=await O("post","/metafields",{data:{metafield:r}},e);return t}async function G1(e,r,t){const{metafield:n}=await O("put","/metafields",{id:r,data:{metafield:t}},e);return n}function W1(e,r){return O("delete","/metafields",{id:r},e)}var q1=Object.freeze({__proto__:null,createMetafield:k1,updateMetafield:G1,deleteMetafield:W1});async function z1(e,r){const{onetime:t}=await O("get","/onetimes",{id:r},e);return t}function V1(e,r){return O("get","/onetimes",{query:r},e)}async function H1(e,r){const{onetime:t}=await O("post","/onetimes",{data:r},e);return t}async function Y1(e,r,t){const{onetime:n}=await O("put","/onetimes",{id:r,data:t},e);return n}function K1(e,r){return O("delete","/onetimes",{id:r},e)}var X1=Object.freeze({__proto__:null,getOnetime:z1,listOnetimes:V1,createOnetime:H1,updateOnetime:Y1,deleteOnetime:K1});async function J1(e,r){const{order:t}=await O("get","/orders",{id:r},e);return t}function Q1(e,r){return O("get","/orders",{query:r},e)}var Z1=Object.freeze({__proto__:null,getOrder:J1,listOrders:Q1});async function eb(e,r,t){const{payment_method:n}=await O("get","/payment_methods",{id:r,query:{include:t?.include}},e);return n}async function rb(e,r,t){const{payment_method:n}=await O("put","/payment_methods",{id:r,data:t},e);return n}function tb(e,r){return O("get","/payment_methods",{query:r},e)}var nb=Object.freeze({__proto__:null,getPaymentMethod:eb,updatePaymentMethod:rb,listPaymentMethods:tb});async function ib(e,r){const{plan:t}=await O("get","/plans",{id:r},e);return t}function ob(e,r){return O("get","/plans",{query:r},e)}var ab=Object.freeze({__proto__:null,getPlan:ib,listPlans:ob}),sb=jn,ub=Oa,cb=kn;function fb(e,r){return cb(ub(e,r,sb),e+"")}var lb=fb,Xa=Zo,pb=Xa&&new Xa,Ja=pb,hb=jn,Qa=Ja,db=Qa?function(e,r){return Qa.set(e,r),e}:hb,Za=db,yb=gt,gb=Ye;function vb(e){return function(){var r=arguments;switch(r.length){case 0:return new e;case 1:return new e(r[0]);case 2:return new e(r[0],r[1]);case 3:return new e(r[0],r[1],r[2]);case 4:return new e(r[0],r[1],r[2],r[3]);case 5:return new e(r[0],r[1],r[2],r[3],r[4]);case 6:return new e(r[0],r[1],r[2],r[3],r[4],r[5]);case 7:return new e(r[0],r[1],r[2],r[3],r[4],r[5],r[6])}var t=yb(e.prototype),n=e.apply(t,r);return gb(n)?n:t}}var bt=vb,mb=bt,_b=oe,wb=1;function bb(e,r,t){var n=r&wb,a=mb(e);function s(){var c=this&&this!==_b&&this instanceof s?a:e;return c.apply(n?t:this,arguments)}return s}var $b=bb,Ab=Math.max;function Eb(e,r,t,n){for(var a=-1,s=e.length,c=t.length,p=-1,h=r.length,v=Ab(s-c,0),_=Array(h+v),w=!n;++p<h;)_[p]=r[p];for(;++a<c;)(w||a<s)&&(_[t[a]]=e[a]);for(;v--;)_[p++]=e[a++];return _}var es=Eb,Sb=Math.max;function xb(e,r,t,n){for(var a=-1,s=e.length,c=-1,p=t.length,h=-1,v=r.length,_=Sb(s-p,0),w=Array(_+v),b=!n;++a<_;)w[a]=e[a];for(var d=a;++h<v;)w[d+h]=r[h];for(;++c<p;)(b||a<s)&&(w[d+t[c]]=e[a++]);return w}var rs=xb;function Ib(e,r){for(var t=e.length,n=0;t--;)e[t]===r&&++n;return n}var Tb=Ib;function Ob(){}var qn=Ob,Bb=gt,Pb=qn,Rb=4294967295;function $t(e){this.__wrapped__=e,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=Rb,this.__views__=[]}$t.prototype=Bb(Pb.prototype),$t.prototype.constructor=$t;var zn=$t;function Fb(){}var Cb=Fb,ts=Ja,Ub=Cb,Db=ts?function(e){return ts.get(e)}:Ub,ns=Db,Nb={},Lb=Nb,is=Lb,Mb=Object.prototype,jb=Mb.hasOwnProperty;function kb(e){for(var r=e.name+"",t=is[r],n=jb.call(is,r)?t.length:0;n--;){var a=t[n],s=a.func;if(s==null||s==e)return a.name}return r}var Gb=kb,Wb=gt,qb=qn;function At(e,r){this.__wrapped__=e,this.__actions__=[],this.__chain__=!!r,this.__index__=0,this.__values__=void 0}At.prototype=Wb(qb.prototype),At.prototype.constructor=At;var os=At,zb=zn,Vb=os,Hb=xn;function Yb(e){if(e instanceof zb)return e.clone();var r=new Vb(e.__wrapped__,e.__chain__);return r.__actions__=Hb(e.__actions__),r.__index__=e.__index__,r.__values__=e.__values__,r}var Kb=Yb,Xb=zn,as=os,Jb=qn,Qb=De,Zb=Ue,e$=Kb,r$=Object.prototype,t$=r$.hasOwnProperty;function Et(e){if(Zb(e)&&!Qb(e)&&!(e instanceof Xb)){if(e instanceof as)return e;if(t$.call(e,"__wrapped__"))return e$(e)}return new as(e)}Et.prototype=Jb.prototype,Et.prototype.constructor=Et;var n$=Et,i$=zn,o$=ns,a$=Gb,s$=n$;function u$(e){var r=a$(e),t=s$[r];if(typeof t!="function"||!(r in i$.prototype))return!1;if(e===t)return!0;var n=o$(t);return!!n&&e===n[0]}var c$=u$,f$=Za,l$=Pa,p$=l$(f$),ss=p$,h$=/\{\n\/\* \[wrapped with (.+)\] \*/,d$=/,? & /;function y$(e){var r=e.match(h$);return r?r[1].split(d$):[]}var g$=y$,v$=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/;function m$(e,r){var t=r.length;if(!t)return e;var n=t-1;return r[n]=(t>1?"& ":"")+r[n],r=r.join(t>2?", ":" "),e.replace(v$,`{
20
+ `+r.prev}function it(e,r){var t=cn(e),n=[];if(t){n.length=e.length;for(var a=0;a<e.length;a++)n[a]=Fe(e,a)?r(e[a],e):""}var s=typeof an=="function"?an(e):[],c;if(or){c={};for(var p=0;p<s.length;p++)c["$"+s[p]]=s[p]}for(var h in e)Fe(e,h)&&(t&&String(Number(h))===h&&h<e.length||or&&c["$"+h]instanceof Symbol||(zi.call(/[^\w$]/,h)?n.push(r(h,e)+": "+r(e[h],e)):n.push(h+": "+r(e[h],e))));if(typeof an=="function")for(var v=0;v<s.length;v++)Yi.call(e,s[v])&&n.push("["+r(s[v])+"]: "+r(e[s[v]],e));return n}var pn=Lt,ar=gu,cf=Wc,ff=pn("%TypeError%"),ot=pn("%WeakMap%",!0),at=pn("%Map%",!0),lf=ar("WeakMap.prototype.get",!0),pf=ar("WeakMap.prototype.set",!0),hf=ar("WeakMap.prototype.has",!0),df=ar("Map.prototype.get",!0),yf=ar("Map.prototype.set",!0),gf=ar("Map.prototype.has",!0),hn=function(e,r){for(var t=e,n;(n=t.next)!==null;t=n)if(n.key===r)return t.next=n.next,n.next=e.next,e.next=n,n},vf=function(e,r){var t=hn(e,r);return t&&t.value},mf=function(e,r,t){var n=hn(e,r);n?n.value=t:e.next={key:r,next:e.next,value:t}},_f=function(e,r){return!!hn(e,r)},wf=function(){var r,t,n,a={assert:function(s){if(!a.has(s))throw new ff("Side channel does not contain "+cf(s))},get:function(s){if(ot&&s&&(typeof s=="object"||typeof s=="function")){if(r)return lf(r,s)}else if(at){if(t)return df(t,s)}else if(n)return vf(n,s)},has:function(s){if(ot&&s&&(typeof s=="object"||typeof s=="function")){if(r)return hf(r,s)}else if(at){if(t)return gf(t,s)}else if(n)return _f(n,s);return!1},set:function(s,c){ot&&s&&(typeof s=="object"||typeof s=="function")?(r||(r=new ot),pf(r,s,c)):at?(t||(t=new at),yf(t,s,c)):(n||(n={key:{},next:null}),mf(n,s,c))}};return a},bf=String.prototype.replace,$f=/%20/g,dn={RFC1738:"RFC1738",RFC3986:"RFC3986"},oo={default:dn.RFC3986,formatters:{RFC1738:function(e){return bf.call(e,$f,"+")},RFC3986:function(e){return String(e)}},RFC1738:dn.RFC1738,RFC3986:dn.RFC3986},Af=oo,yn=Object.prototype.hasOwnProperty,He=Array.isArray,we=function(){for(var e=[],r=0;r<256;++r)e.push("%"+((r<16?"0":"")+r.toString(16)).toUpperCase());return e}(),Ef=function(r){for(;r.length>1;){var t=r.pop(),n=t.obj[t.prop];if(He(n)){for(var a=[],s=0;s<n.length;++s)typeof n[s]<"u"&&a.push(n[s]);t.obj[t.prop]=a}}},ao=function(r,t){for(var n=t&&t.plainObjects?Object.create(null):{},a=0;a<r.length;++a)typeof r[a]<"u"&&(n[a]=r[a]);return n},Sf=function e(r,t,n){if(!t)return r;if(typeof t!="object"){if(He(r))r.push(t);else if(r&&typeof r=="object")(n&&(n.plainObjects||n.allowPrototypes)||!yn.call(Object.prototype,t))&&(r[t]=!0);else return[r,t];return r}if(!r||typeof r!="object")return[r].concat(t);var a=r;return He(r)&&!He(t)&&(a=ao(r,n)),He(r)&&He(t)?(t.forEach(function(s,c){if(yn.call(r,c)){var p=r[c];p&&typeof p=="object"&&s&&typeof s=="object"?r[c]=e(p,s,n):r.push(s)}else r[c]=s}),r):Object.keys(t).reduce(function(s,c){var p=t[c];return yn.call(s,c)?s[c]=e(s[c],p,n):s[c]=p,s},a)},xf=function(r,t){return Object.keys(t).reduce(function(n,a){return n[a]=t[a],n},r)},If=function(e,r,t){var n=e.replace(/\+/g," ");if(t==="iso-8859-1")return n.replace(/%[0-9a-f]{2}/gi,unescape);try{return decodeURIComponent(n)}catch{return n}},Tf=function(r,t,n,a,s){if(r.length===0)return r;var c=r;if(typeof r=="symbol"?c=Symbol.prototype.toString.call(r):typeof r!="string"&&(c=String(r)),n==="iso-8859-1")return escape(c).replace(/%u[0-9a-f]{4}/gi,function(_){return"%26%23"+parseInt(_.slice(2),16)+"%3B"});for(var p="",h=0;h<c.length;++h){var v=c.charCodeAt(h);if(v===45||v===46||v===95||v===126||v>=48&&v<=57||v>=65&&v<=90||v>=97&&v<=122||s===Af.RFC1738&&(v===40||v===41)){p+=c.charAt(h);continue}if(v<128){p=p+we[v];continue}if(v<2048){p=p+(we[192|v>>6]+we[128|v&63]);continue}if(v<55296||v>=57344){p=p+(we[224|v>>12]+we[128|v>>6&63]+we[128|v&63]);continue}h+=1,v=65536+((v&1023)<<10|c.charCodeAt(h)&1023),p+=we[240|v>>18]+we[128|v>>12&63]+we[128|v>>6&63]+we[128|v&63]}return p},Of=function(r){for(var t=[{obj:{o:r},prop:"o"}],n=[],a=0;a<t.length;++a)for(var s=t[a],c=s.obj[s.prop],p=Object.keys(c),h=0;h<p.length;++h){var v=p[h],_=c[v];typeof _=="object"&&_!==null&&n.indexOf(_)===-1&&(t.push({obj:c,prop:v}),n.push(_))}return Ef(t),r},Bf=function(r){return Object.prototype.toString.call(r)==="[object RegExp]"},Pf=function(r){return!r||typeof r!="object"?!1:!!(r.constructor&&r.constructor.isBuffer&&r.constructor.isBuffer(r))},Rf=function(r,t){return[].concat(r,t)},Ff=function(r,t){if(He(r)){for(var n=[],a=0;a<r.length;a+=1)n.push(t(r[a]));return n}return t(r)},Cf={arrayToObject:ao,assign:xf,combine:Rf,compact:Of,decode:If,encode:Tf,isBuffer:Pf,isRegExp:Bf,maybeMap:Ff,merge:Sf},so=wf,gn=Cf,Tr=oo,Uf=Object.prototype.hasOwnProperty,uo={brackets:function(r){return r+"[]"},comma:"comma",indices:function(r,t){return r+"["+t+"]"},repeat:function(r){return r}},xe=Array.isArray,Df=String.prototype.split,Nf=Array.prototype.push,co=function(e,r){Nf.apply(e,xe(r)?r:[r])},Lf=Date.prototype.toISOString,fo=Tr.default,J={addQueryPrefix:!1,allowDots:!1,charset:"utf-8",charsetSentinel:!1,delimiter:"&",encode:!0,encoder:gn.encode,encodeValuesOnly:!1,format:fo,formatter:Tr.formatters[fo],indices:!1,serializeDate:function(r){return Lf.call(r)},skipNulls:!1,strictNullHandling:!1},Mf=function(r){return typeof r=="string"||typeof r=="number"||typeof r=="boolean"||typeof r=="symbol"||typeof r=="bigint"},vn={},jf=function e(r,t,n,a,s,c,p,h,v,_,w,b,d,E,x,I){for(var S=r,T=I,P=0,B=!1;(T=T.get(vn))!==void 0&&!B;){var D=T.get(r);if(P+=1,typeof D<"u"){if(D===P)throw new RangeError("Cyclic object value");B=!0}typeof T.get(vn)>"u"&&(P=0)}if(typeof h=="function"?S=h(t,S):S instanceof Date?S=w(S):n==="comma"&&xe(S)&&(S=gn.maybeMap(S,function(Ne){return Ne instanceof Date?w(Ne):Ne})),S===null){if(s)return p&&!E?p(t,J.encoder,x,"key",b):t;S=""}if(Mf(S)||gn.isBuffer(S)){if(p){var j=E?t:p(t,J.encoder,x,"key",b);if(n==="comma"&&E){for(var q=Df.call(String(S),","),z="",X=0;X<q.length;++X)z+=(X===0?"":",")+d(p(q[X],J.encoder,x,"value",b));return[d(j)+(a&&xe(S)&&q.length===1?"[]":"")+"="+z]}return[d(j)+"="+d(p(S,J.encoder,x,"value",b))]}return[d(t)+"="+d(String(S))]}var V=[];if(typeof S>"u")return V;var ae;if(n==="comma"&&xe(S))ae=[{value:S.length>0?S.join(",")||null:void 0}];else if(xe(h))ae=h;else{var ue=Object.keys(S);ae=v?ue.sort(v):ue}for(var k=a&&xe(S)&&S.length===1?t+"[]":t,re=0;re<ae.length;++re){var N=ae[re],ce=typeof N=="object"&&typeof N.value<"u"?N.value:S[N];if(!(c&&ce===null)){var hr=xe(S)?typeof n=="function"?n(k,N):k:k+(_?"."+N:"["+N+"]");I.set(r,P);var se=so();se.set(vn,I),co(V,e(ce,hr,n,a,s,c,p,h,v,_,w,b,d,E,x,se))}}return V},kf=function(r){if(!r)return J;if(r.encoder!==null&&typeof r.encoder<"u"&&typeof r.encoder!="function")throw new TypeError("Encoder has to be a function.");var t=r.charset||J.charset;if(typeof r.charset<"u"&&r.charset!=="utf-8"&&r.charset!=="iso-8859-1")throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var n=Tr.default;if(typeof r.format<"u"){if(!Uf.call(Tr.formatters,r.format))throw new TypeError("Unknown format option provided.");n=r.format}var a=Tr.formatters[n],s=J.filter;return(typeof r.filter=="function"||xe(r.filter))&&(s=r.filter),{addQueryPrefix:typeof r.addQueryPrefix=="boolean"?r.addQueryPrefix:J.addQueryPrefix,allowDots:typeof r.allowDots>"u"?J.allowDots:!!r.allowDots,charset:t,charsetSentinel:typeof r.charsetSentinel=="boolean"?r.charsetSentinel:J.charsetSentinel,delimiter:typeof r.delimiter>"u"?J.delimiter:r.delimiter,encode:typeof r.encode=="boolean"?r.encode:J.encode,encoder:typeof r.encoder=="function"?r.encoder:J.encoder,encodeValuesOnly:typeof r.encodeValuesOnly=="boolean"?r.encodeValuesOnly:J.encodeValuesOnly,filter:s,format:n,formatter:a,serializeDate:typeof r.serializeDate=="function"?r.serializeDate:J.serializeDate,skipNulls:typeof r.skipNulls=="boolean"?r.skipNulls:J.skipNulls,sort:typeof r.sort=="function"?r.sort:null,strictNullHandling:typeof r.strictNullHandling=="boolean"?r.strictNullHandling:J.strictNullHandling}},Gf=function(e,r){var t=e,n=kf(r),a,s;typeof n.filter=="function"?(s=n.filter,t=s("",t)):xe(n.filter)&&(s=n.filter,a=s);var c=[];if(typeof t!="object"||t===null)return"";var p;r&&r.arrayFormat in uo?p=r.arrayFormat:r&&"indices"in r?p=r.indices?"indices":"repeat":p="indices";var h=uo[p];if(r&&"commaRoundTrip"in r&&typeof r.commaRoundTrip!="boolean")throw new TypeError("`commaRoundTrip` must be a boolean, or absent");var v=h==="comma"&&r&&r.commaRoundTrip;a||(a=Object.keys(t)),n.sort&&a.sort(n.sort);for(var _=so(),w=0;w<a.length;++w){var b=a[w];n.skipNulls&&t[b]===null||co(c,jf(t[b],b,h,v,n.strictNullHandling,n.skipNulls,n.encode?n.encoder:null,n.filter,n.sort,n.allowDots,n.serializeDate,n.format,n.formatter,n.encodeValuesOnly,n.charset,_))}var d=c.join(n.delimiter),E=n.addQueryPrefix===!0?"?":"";return n.charsetSentinel&&(n.charset==="iso-8859-1"?E+="utf8=%26%2310003%3B&":E+="utf8=%E2%9C%93&"),d.length>0?E+d:""};let lo={storeIdentifier:"",environment:"prod"};function Wf(e){lo=e}function be(){return lo}const qf=e=>e==="stage"?"https://api.stage.rechargeapps.com":"https://api.rechargeapps.com",st=e=>e==="stage"?"https://admin.stage.rechargeapps.com":"https://admin.rechargeapps.com",zf=e=>e==="stage"?"https://static.stage.rechargecdn.com":"https://static.rechargecdn.com",Vf="/tools/recurring";class ut{constructor(r,t){this.name="RechargeRequestError",this.message=r,this.status=t}}var Hf=Object.defineProperty,Yf=Object.defineProperties,Kf=Object.getOwnPropertyDescriptors,po=Object.getOwnPropertySymbols,Xf=Object.prototype.hasOwnProperty,Jf=Object.prototype.propertyIsEnumerable,ho=(e,r,t)=>r in e?Hf(e,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[r]=t,ct=(e,r)=>{for(var t in r||(r={}))Xf.call(r,t)&&ho(e,t,r[t]);if(po)for(var t of po(r))Jf.call(r,t)&&ho(e,t,r[t]);return e},Qf=(e,r)=>Yf(e,Kf(r));function Zf(e){return Gf(e,{encode:!1,indices:!1,arrayFormat:"comma"})}async function ft(e,r,t={}){const n=be();return le(e,`${zf(n.environment)}/store/${n.storeIdentifier}${r}`,t)}async function O(e,r,{id:t,query:n,data:a,headers:s}={},c){const{environment:p,storeIdentifier:h,loginRetryFn:v}=be(),_=c.apiToken,w=qf(p),b=ct({"X-Recharge-Access-Token":_,"X-Recharge-Version":"2021-11"},s||{}),d=ct({shop_url:h},n);try{return await le(e,`${w}${r}`,{id:t,query:d,data:a,headers:b})}catch(E){if(v&&E instanceof ut&&E.status===401)return v().then(x=>{if(x)return le(e,`${w}${r}`,{id:t,query:d,data:a,headers:Qf(ct({},b),{"X-Recharge-Access-Token":x.apiToken})});throw E});throw E}}async function Or(e,r,t={}){return le(e,`${Vf}${r}`,t)}async function le(e,r,{id:t,query:n,data:a,headers:s}={}){let c=r.trim();if(t&&(c=[c,`${t}`.trim()].join("/")),n){let w;[c,w]=c.split("?");const b=[w,Zf(n)].join("&").replace(/^&/,"");c=`${c}${b?`?${b}`:""}`}let p;a&&e!=="get"&&(p=JSON.stringify(a));const h=ct({Accept:"application/json","Content-Type":"application/json","X-Recharge-App":"storefront-client"},s||{}),v=await fetch(c,{method:e,headers:h,body:p});let _;try{_=await v.json()}catch{}if(!v.ok)throw _&&_.error?new ut(_.error,v.status):_&&_.errors?new ut(JSON.stringify(_.errors),v.status):new ut("A connection error occurred while making the request");return _}var el=Object.defineProperty,yo=Object.getOwnPropertySymbols,rl=Object.prototype.hasOwnProperty,tl=Object.prototype.propertyIsEnumerable,go=(e,r,t)=>r in e?el(e,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[r]=t,nl=(e,r)=>{for(var t in r||(r={}))rl.call(r,t)&&go(e,t,r[t]);if(yo)for(var t of yo(r))tl.call(r,t)&&go(e,t,r[t]);return e};function il(e,r){return O("get","/addresses",{query:r},e)}async function ol(e,r,t){const{address:n}=await O("get","/addresses",{id:r,query:{include:t?.include}},e);return n}async function al(e,r){const{address:t}=await O("post","/addresses",{data:nl({customer_id:e.customerId?Number(e.customerId):void 0},r)},e);return t}async function mn(e,r,t){const{address:n}=await O("put","/addresses",{id:r,data:t},e);return n}async function sl(e,r,t){return mn(e,r,{discounts:[{code:t}]})}async function ul(e,r){return mn(e,r,{discounts:[]})}function cl(e,r){return O("delete","/addresses",{id:r},e)}async function fl(e,r){const{address:t}=await O("post","/addresses/merge",{data:r},e);return t}async function ll(e,r,t){const{charge:n}=await O("post",`/addresses/${r}/charges/skip`,{data:t},e);return n}var pl=Object.freeze({__proto__:null,listAddresses:il,getAddress:ol,createAddress:al,updateAddress:mn,applyDiscountToAddress:sl,removeDiscountsFromAddress:ul,deleteAddress:cl,mergeAddresses:fl,skipFutureCharge:ll}),hl=Object.defineProperty,vo=Object.getOwnPropertySymbols,dl=Object.prototype.hasOwnProperty,yl=Object.prototype.propertyIsEnumerable,mo=(e,r,t)=>r in e?hl(e,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[r]=t,_o=(e,r)=>{for(var t in r||(r={}))dl.call(r,t)&&mo(e,t,r[t]);if(vo)for(var t of vo(r))yl.call(r,t)&&mo(e,t,r[t]);return e};async function gl(){const{storefrontAccessToken:e}=be(),r={};e&&(r["X-Recharge-Storefront-Access-Token"]=e);const t=await Or("get","/access",{headers:r});return{apiToken:t.api_token,customerId:t.customer_id}}async function vl(e,r){const{environment:t,storefrontAccessToken:n,storeIdentifier:a}=be(),s=st(t),c={};n&&(c["X-Recharge-Storefront-Access-Token"]=n);const p=await le("post",`${s}/shopify_storefront_access`,{data:{customer_token:r,storefront_token:e,shop_url:a},headers:c});return p.api_token?{apiToken:p.api_token,customerId:p.customer_id}:null}async function ml(e,r={}){const{environment:t,storefrontAccessToken:n,storeIdentifier:a}=be(),s=st(t),c={};n&&(c["X-Recharge-Storefront-Access-Token"]=n);const p=await le("post",`${s}/attempt_login`,{data:_o({email:e,shop:a},r),headers:c});if(p.errors)throw new Error(p.errors);return p.session_token}async function _l(e,r={}){const{storefrontAccessToken:t}=be(),n={};t&&(n["X-Recharge-Storefront-Access-Token"]=t);const a=await Or("post","/attempt_login",{data:_o({email:e},r),headers:n});if(a.errors)throw new Error(a.errors);return a.session_token}async function wl(e,r,t){const{environment:n,storefrontAccessToken:a,storeIdentifier:s}=be(),c=st(n),p={};a&&(p["X-Recharge-Storefront-Access-Token"]=a);const h=await le("post",`${c}/validate_login`,{data:{code:t,email:e,session_token:r,shop:s},headers:p});if(h.errors)throw new Error(h.errors);return{apiToken:h.api_token,customerId:h.customer_id}}async function bl(e,r,t){const{storefrontAccessToken:n}=be(),a={};n&&(a["X-Recharge-Storefront-Access-Token"]=n);const s=await Or("post","/validate_login",{data:{code:t,email:e,session_token:r},headers:a});if(s.errors)throw new Error(s.errors);return{apiToken:s.api_token,customerId:s.customer_id}}function $l(){const{pathname:e,search:r}=window.location,t=new URLSearchParams(r).get("token"),n=e.split("/").filter(Boolean),a=n.findIndex(c=>c==="portal"),s=a!==-1?n[a+1]:void 0;if(!t||!s)throw new Error("Not in context of Recharge Customer Portal or URL did not contain correct params");return{customerHash:s,token:t}}async function Al(){const{customerHash:e,token:r}=$l(),{environment:t,storefrontAccessToken:n,storeIdentifier:a}=be(),s=st(t),c={};n&&(c["X-Recharge-Storefront-Access-Token"]=n);const p=await le("post",`${s}/customers/${e}/access`,{headers:c,data:{token:r,shop:a}});return{apiToken:p.api_token,customerId:p.customer_id}}var El=Object.freeze({__proto__:null,loginShopifyAppProxy:gl,loginShopifyApi:vl,sendPasswordlessCode:ml,sendPasswordlessCodeAppProxy:_l,validatePasswordlessCode:wl,validatePasswordlessCodeAppProxy:bl,loginCustomerPortal:Al});let Sl=(e=21)=>crypto.getRandomValues(new Uint8Array(e)).reduce((r,t)=>(t&=63,t<36?r+=t.toString(36):t<62?r+=(t-26).toString(36).toUpperCase():t>62?r+="-":r+="_",r),"");function xl(e,r){for(var t=-1,n=e==null?0:e.length,a=Array(n);++t<n;)a[t]=r(e[t],t,e);return a}var wo=xl;function Il(){this.__data__=[],this.size=0}var Tl=Il;function Ol(e,r){return e===r||e!==e&&r!==r}var bo=Ol,Bl=bo;function Pl(e,r){for(var t=e.length;t--;)if(Bl(e[t][0],r))return t;return-1}var lt=Pl,Rl=lt,Fl=Array.prototype,Cl=Fl.splice;function Ul(e){var r=this.__data__,t=Rl(r,e);if(t<0)return!1;var n=r.length-1;return t==n?r.pop():Cl.call(r,t,1),--this.size,!0}var Dl=Ul,Nl=lt;function Ll(e){var r=this.__data__,t=Nl(r,e);return t<0?void 0:r[t][1]}var Ml=Ll,jl=lt;function kl(e){return jl(this.__data__,e)>-1}var Gl=kl,Wl=lt;function ql(e,r){var t=this.__data__,n=Wl(t,e);return n<0?(++this.size,t.push([e,r])):t[n][1]=r,this}var zl=ql,Vl=Tl,Hl=Dl,Yl=Ml,Kl=Gl,Xl=zl;function sr(e){var r=-1,t=e==null?0:e.length;for(this.clear();++r<t;){var n=e[r];this.set(n[0],n[1])}}sr.prototype.clear=Vl,sr.prototype.delete=Hl,sr.prototype.get=Yl,sr.prototype.has=Kl,sr.prototype.set=Xl;var pt=sr,Jl=pt;function Ql(){this.__data__=new Jl,this.size=0}var Zl=Ql;function ep(e){var r=this.__data__,t=r.delete(e);return this.size=r.size,t}var rp=ep;function tp(e){return this.__data__.get(e)}var np=tp;function ip(e){return this.__data__.has(e)}var op=ip,ap=typeof Ae=="object"&&Ae&&Ae.Object===Object&&Ae,$o=ap,sp=$o,up=typeof self=="object"&&self&&self.Object===Object&&self,cp=sp||up||Function("return this")(),oe=cp,fp=oe,lp=fp.Symbol,Br=lp,Ao=Br,Eo=Object.prototype,pp=Eo.hasOwnProperty,hp=Eo.toString,Pr=Ao?Ao.toStringTag:void 0;function dp(e){var r=pp.call(e,Pr),t=e[Pr];try{e[Pr]=void 0;var n=!0}catch{}var a=hp.call(e);return n&&(r?e[Pr]=t:delete e[Pr]),a}var yp=dp,gp=Object.prototype,vp=gp.toString;function mp(e){return vp.call(e)}var _p=mp,So=Br,wp=yp,bp=_p,$p="[object Null]",Ap="[object Undefined]",xo=So?So.toStringTag:void 0;function Ep(e){return e==null?e===void 0?Ap:$p:xo&&xo in Object(e)?wp(e):bp(e)}var ur=Ep;function Sp(e){var r=typeof e;return e!=null&&(r=="object"||r=="function")}var Ye=Sp,xp=ur,Ip=Ye,Tp="[object AsyncFunction]",Op="[object Function]",Bp="[object GeneratorFunction]",Pp="[object Proxy]";function Rp(e){if(!Ip(e))return!1;var r=xp(e);return r==Op||r==Bp||r==Tp||r==Pp}var Io=Rp,Fp=oe,Cp=Fp["__core-js_shared__"],Up=Cp,_n=Up,To=function(){var e=/[^.]+$/.exec(_n&&_n.keys&&_n.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}();function Dp(e){return!!To&&To in e}var Np=Dp,Lp=Function.prototype,Mp=Lp.toString;function jp(e){if(e!=null){try{return Mp.call(e)}catch{}try{return e+""}catch{}}return""}var Oo=jp,kp=Io,Gp=Np,Wp=Ye,qp=Oo,zp=/[\\^$.*+?()[\]{}|]/g,Vp=/^\[object .+?Constructor\]$/,Hp=Function.prototype,Yp=Object.prototype,Kp=Hp.toString,Xp=Yp.hasOwnProperty,Jp=RegExp("^"+Kp.call(Xp).replace(zp,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Qp(e){if(!Wp(e)||Gp(e))return!1;var r=kp(e)?Jp:Vp;return r.test(qp(e))}var Zp=Qp;function eh(e,r){return e?.[r]}var rh=eh,th=Zp,nh=rh;function ih(e,r){var t=nh(e,r);return th(t)?t:void 0}var Ke=ih,oh=Ke,ah=oe,sh=oh(ah,"Map"),wn=sh,uh=Ke,ch=uh(Object,"create"),ht=ch,Bo=ht;function fh(){this.__data__=Bo?Bo(null):{},this.size=0}var lh=fh;function ph(e){var r=this.has(e)&&delete this.__data__[e];return this.size-=r?1:0,r}var hh=ph,dh=ht,yh="__lodash_hash_undefined__",gh=Object.prototype,vh=gh.hasOwnProperty;function mh(e){var r=this.__data__;if(dh){var t=r[e];return t===yh?void 0:t}return vh.call(r,e)?r[e]:void 0}var _h=mh,wh=ht,bh=Object.prototype,$h=bh.hasOwnProperty;function Ah(e){var r=this.__data__;return wh?r[e]!==void 0:$h.call(r,e)}var Eh=Ah,Sh=ht,xh="__lodash_hash_undefined__";function Ih(e,r){var t=this.__data__;return this.size+=this.has(e)?0:1,t[e]=Sh&&r===void 0?xh:r,this}var Th=Ih,Oh=lh,Bh=hh,Ph=_h,Rh=Eh,Fh=Th;function cr(e){var r=-1,t=e==null?0:e.length;for(this.clear();++r<t;){var n=e[r];this.set(n[0],n[1])}}cr.prototype.clear=Oh,cr.prototype.delete=Bh,cr.prototype.get=Ph,cr.prototype.has=Rh,cr.prototype.set=Fh;var Ch=cr,Po=Ch,Uh=pt,Dh=wn;function Nh(){this.size=0,this.__data__={hash:new Po,map:new(Dh||Uh),string:new Po}}var Lh=Nh;function Mh(e){var r=typeof e;return r=="string"||r=="number"||r=="symbol"||r=="boolean"?e!=="__proto__":e===null}var jh=Mh,kh=jh;function Gh(e,r){var t=e.__data__;return kh(r)?t[typeof r=="string"?"string":"hash"]:t.map}var dt=Gh,Wh=dt;function qh(e){var r=Wh(this,e).delete(e);return this.size-=r?1:0,r}var zh=qh,Vh=dt;function Hh(e){return Vh(this,e).get(e)}var Yh=Hh,Kh=dt;function Xh(e){return Kh(this,e).has(e)}var Jh=Xh,Qh=dt;function Zh(e,r){var t=Qh(this,e),n=t.size;return t.set(e,r),this.size+=t.size==n?0:1,this}var ed=Zh,rd=Lh,td=zh,nd=Yh,id=Jh,od=ed;function fr(e){var r=-1,t=e==null?0:e.length;for(this.clear();++r<t;){var n=e[r];this.set(n[0],n[1])}}fr.prototype.clear=rd,fr.prototype.delete=td,fr.prototype.get=nd,fr.prototype.has=id,fr.prototype.set=od;var Ro=fr,ad=pt,sd=wn,ud=Ro,cd=200;function fd(e,r){var t=this.__data__;if(t instanceof ad){var n=t.__data__;if(!sd||n.length<cd-1)return n.push([e,r]),this.size=++t.size,this;t=this.__data__=new ud(n)}return t.set(e,r),this.size=t.size,this}var ld=fd,pd=pt,hd=Zl,dd=rp,yd=np,gd=op,vd=ld;function lr(e){var r=this.__data__=new pd(e);this.size=r.size}lr.prototype.clear=hd,lr.prototype.delete=dd,lr.prototype.get=yd,lr.prototype.has=gd,lr.prototype.set=vd;var md=lr;function _d(e,r){for(var t=-1,n=e==null?0:e.length;++t<n&&r(e[t],t,e)!==!1;);return e}var Fo=_d,wd=Ke,bd=function(){try{var e=wd(Object,"defineProperty");return e({},"",{}),e}catch{}}(),Co=bd,Uo=Co;function $d(e,r,t){r=="__proto__"&&Uo?Uo(e,r,{configurable:!0,enumerable:!0,value:t,writable:!0}):e[r]=t}var Do=$d,Ad=Do,Ed=bo,Sd=Object.prototype,xd=Sd.hasOwnProperty;function Id(e,r,t){var n=e[r];(!(xd.call(e,r)&&Ed(n,t))||t===void 0&&!(r in e))&&Ad(e,r,t)}var No=Id,Td=No,Od=Do;function Bd(e,r,t,n){var a=!t;t||(t={});for(var s=-1,c=r.length;++s<c;){var p=r[s],h=n?n(t[p],e[p],p,t,e):void 0;h===void 0&&(h=e[p]),a?Od(t,p,h):Td(t,p,h)}return t}var Rr=Bd;function Pd(e,r){for(var t=-1,n=Array(e);++t<e;)n[t]=r(t);return n}var Rd=Pd;function Fd(e){return e!=null&&typeof e=="object"}var Ue=Fd,Cd=ur,Ud=Ue,Dd="[object Arguments]";function Nd(e){return Ud(e)&&Cd(e)==Dd}var Ld=Nd,Lo=Ld,Md=Ue,Mo=Object.prototype,jd=Mo.hasOwnProperty,kd=Mo.propertyIsEnumerable,Gd=Lo(function(){return arguments}())?Lo:function(e){return Md(e)&&jd.call(e,"callee")&&!kd.call(e,"callee")},jo=Gd,Wd=Array.isArray,De=Wd,yt={exports:{}};function qd(){return!1}var zd=qd;(function(e,r){var t=oe,n=zd,a=r&&!r.nodeType&&r,s=a&&!0&&e&&!e.nodeType&&e,c=s&&s.exports===a,p=c?t.Buffer:void 0,h=p?p.isBuffer:void 0,v=h||n;e.exports=v})(yt,yt.exports);var Vd=9007199254740991,Hd=/^(?:0|[1-9]\d*)$/;function Yd(e,r){var t=typeof e;return r=r??Vd,!!r&&(t=="number"||t!="symbol"&&Hd.test(e))&&e>-1&&e%1==0&&e<r}var ko=Yd,Kd=9007199254740991;function Xd(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=Kd}var Go=Xd,Jd=ur,Qd=Go,Zd=Ue,ey="[object Arguments]",ry="[object Array]",ty="[object Boolean]",ny="[object Date]",iy="[object Error]",oy="[object Function]",ay="[object Map]",sy="[object Number]",uy="[object Object]",cy="[object RegExp]",fy="[object Set]",ly="[object String]",py="[object WeakMap]",hy="[object ArrayBuffer]",dy="[object DataView]",yy="[object Float32Array]",gy="[object Float64Array]",vy="[object Int8Array]",my="[object Int16Array]",_y="[object Int32Array]",wy="[object Uint8Array]",by="[object Uint8ClampedArray]",$y="[object Uint16Array]",Ay="[object Uint32Array]",M={};M[yy]=M[gy]=M[vy]=M[my]=M[_y]=M[wy]=M[by]=M[$y]=M[Ay]=!0,M[ey]=M[ry]=M[hy]=M[ty]=M[dy]=M[ny]=M[iy]=M[oy]=M[ay]=M[sy]=M[uy]=M[cy]=M[fy]=M[ly]=M[py]=!1;function Ey(e){return Zd(e)&&Qd(e.length)&&!!M[Jd(e)]}var Sy=Ey;function xy(e){return function(r){return e(r)}}var bn=xy,Fr={exports:{}};(function(e,r){var t=$o,n=r&&!r.nodeType&&r,a=n&&!0&&e&&!e.nodeType&&e,s=a&&a.exports===n,c=s&&t.process,p=function(){try{var h=a&&a.require&&a.require("util").types;return h||c&&c.binding&&c.binding("util")}catch{}}();e.exports=p})(Fr,Fr.exports);var Iy=Sy,Ty=bn,Wo=Fr.exports,qo=Wo&&Wo.isTypedArray,Oy=qo?Ty(qo):Iy,By=Oy,Py=Rd,Ry=jo,Fy=De,Cy=yt.exports,Uy=ko,Dy=By,Ny=Object.prototype,Ly=Ny.hasOwnProperty;function My(e,r){var t=Fy(e),n=!t&&Ry(e),a=!t&&!n&&Cy(e),s=!t&&!n&&!a&&Dy(e),c=t||n||a||s,p=c?Py(e.length,String):[],h=p.length;for(var v in e)(r||Ly.call(e,v))&&!(c&&(v=="length"||a&&(v=="offset"||v=="parent")||s&&(v=="buffer"||v=="byteLength"||v=="byteOffset")||Uy(v,h)))&&p.push(v);return p}var zo=My,jy=Object.prototype;function ky(e){var r=e&&e.constructor,t=typeof r=="function"&&r.prototype||jy;return e===t}var $n=ky;function Gy(e,r){return function(t){return e(r(t))}}var Vo=Gy,Wy=Vo,qy=Wy(Object.keys,Object),zy=qy,Vy=$n,Hy=zy,Yy=Object.prototype,Ky=Yy.hasOwnProperty;function Xy(e){if(!Vy(e))return Hy(e);var r=[];for(var t in Object(e))Ky.call(e,t)&&t!="constructor"&&r.push(t);return r}var Jy=Xy,Qy=Io,Zy=Go;function eg(e){return e!=null&&Zy(e.length)&&!Qy(e)}var Ho=eg,rg=zo,tg=Jy,ng=Ho;function ig(e){return ng(e)?rg(e):tg(e)}var An=ig,og=Rr,ag=An;function sg(e,r){return e&&og(r,ag(r),e)}var ug=sg;function cg(e){var r=[];if(e!=null)for(var t in Object(e))r.push(t);return r}var fg=cg,lg=Ye,pg=$n,hg=fg,dg=Object.prototype,yg=dg.hasOwnProperty;function gg(e){if(!lg(e))return hg(e);var r=pg(e),t=[];for(var n in e)n=="constructor"&&(r||!yg.call(e,n))||t.push(n);return t}var vg=gg,mg=zo,_g=vg,wg=Ho;function bg(e){return wg(e)?mg(e,!0):_g(e)}var En=bg,$g=Rr,Ag=En;function Eg(e,r){return e&&$g(r,Ag(r),e)}var Sg=Eg,Sn={exports:{}};(function(e,r){var t=oe,n=r&&!r.nodeType&&r,a=n&&!0&&e&&!e.nodeType&&e,s=a&&a.exports===n,c=s?t.Buffer:void 0,p=c?c.allocUnsafe:void 0;function h(v,_){if(_)return v.slice();var w=v.length,b=p?p(w):new v.constructor(w);return v.copy(b),b}e.exports=h})(Sn,Sn.exports);function xg(e,r){var t=-1,n=e.length;for(r||(r=Array(n));++t<n;)r[t]=e[t];return r}var xn=xg;function Ig(e,r){for(var t=-1,n=e==null?0:e.length,a=0,s=[];++t<n;){var c=e[t];r(c,t,e)&&(s[a++]=c)}return s}var Tg=Ig;function Og(){return[]}var Yo=Og,Bg=Tg,Pg=Yo,Rg=Object.prototype,Fg=Rg.propertyIsEnumerable,Ko=Object.getOwnPropertySymbols,Cg=Ko?function(e){return e==null?[]:(e=Object(e),Bg(Ko(e),function(r){return Fg.call(e,r)}))}:Pg,In=Cg,Ug=Rr,Dg=In;function Ng(e,r){return Ug(e,Dg(e),r)}var Lg=Ng;function Mg(e,r){for(var t=-1,n=r.length,a=e.length;++t<n;)e[a+t]=r[t];return e}var Tn=Mg,jg=Vo,kg=jg(Object.getPrototypeOf,Object),On=kg,Gg=Tn,Wg=On,qg=In,zg=Yo,Vg=Object.getOwnPropertySymbols,Hg=Vg?function(e){for(var r=[];e;)Gg(r,qg(e)),e=Wg(e);return r}:zg,Xo=Hg,Yg=Rr,Kg=Xo;function Xg(e,r){return Yg(e,Kg(e),r)}var Jg=Xg,Qg=Tn,Zg=De;function ev(e,r,t){var n=r(e);return Zg(e)?n:Qg(n,t(e))}var Jo=ev,rv=Jo,tv=In,nv=An;function iv(e){return rv(e,nv,tv)}var ov=iv,av=Jo,sv=Xo,uv=En;function cv(e){return av(e,uv,sv)}var Qo=cv,fv=Ke,lv=oe,pv=fv(lv,"DataView"),hv=pv,dv=Ke,yv=oe,gv=dv(yv,"Promise"),vv=gv,mv=Ke,_v=oe,wv=mv(_v,"Set"),bv=wv,$v=Ke,Av=oe,Ev=$v(Av,"WeakMap"),Zo=Ev,Bn=hv,Pn=wn,Rn=vv,Fn=bv,Cn=Zo,ea=ur,pr=Oo,ra="[object Map]",Sv="[object Object]",ta="[object Promise]",na="[object Set]",ia="[object WeakMap]",oa="[object DataView]",xv=pr(Bn),Iv=pr(Pn),Tv=pr(Rn),Ov=pr(Fn),Bv=pr(Cn),Xe=ea;(Bn&&Xe(new Bn(new ArrayBuffer(1)))!=oa||Pn&&Xe(new Pn)!=ra||Rn&&Xe(Rn.resolve())!=ta||Fn&&Xe(new Fn)!=na||Cn&&Xe(new Cn)!=ia)&&(Xe=function(e){var r=ea(e),t=r==Sv?e.constructor:void 0,n=t?pr(t):"";if(n)switch(n){case xv:return oa;case Iv:return ra;case Tv:return ta;case Ov:return na;case Bv:return ia}return r});var Un=Xe,Pv=Object.prototype,Rv=Pv.hasOwnProperty;function Fv(e){var r=e.length,t=new e.constructor(r);return r&&typeof e[0]=="string"&&Rv.call(e,"index")&&(t.index=e.index,t.input=e.input),t}var Cv=Fv,Uv=oe,Dv=Uv.Uint8Array,Nv=Dv,aa=Nv;function Lv(e){var r=new e.constructor(e.byteLength);return new aa(r).set(new aa(e)),r}var Dn=Lv,Mv=Dn;function jv(e,r){var t=r?Mv(e.buffer):e.buffer;return new e.constructor(t,e.byteOffset,e.byteLength)}var kv=jv,Gv=/\w*$/;function Wv(e){var r=new e.constructor(e.source,Gv.exec(e));return r.lastIndex=e.lastIndex,r}var qv=Wv,sa=Br,ua=sa?sa.prototype:void 0,ca=ua?ua.valueOf:void 0;function zv(e){return ca?Object(ca.call(e)):{}}var Vv=zv,Hv=Dn;function Yv(e,r){var t=r?Hv(e.buffer):e.buffer;return new e.constructor(t,e.byteOffset,e.length)}var Kv=Yv,Xv=Dn,Jv=kv,Qv=qv,Zv=Vv,e0=Kv,r0="[object Boolean]",t0="[object Date]",n0="[object Map]",i0="[object Number]",o0="[object RegExp]",a0="[object Set]",s0="[object String]",u0="[object Symbol]",c0="[object ArrayBuffer]",f0="[object DataView]",l0="[object Float32Array]",p0="[object Float64Array]",h0="[object Int8Array]",d0="[object Int16Array]",y0="[object Int32Array]",g0="[object Uint8Array]",v0="[object Uint8ClampedArray]",m0="[object Uint16Array]",_0="[object Uint32Array]";function w0(e,r,t){var n=e.constructor;switch(r){case c0:return Xv(e);case r0:case t0:return new n(+e);case f0:return Jv(e,t);case l0:case p0:case h0:case d0:case y0:case g0:case v0:case m0:case _0:return e0(e,t);case n0:return new n;case i0:case s0:return new n(e);case o0:return Qv(e);case a0:return new n;case u0:return Zv(e)}}var b0=w0,$0=Ye,fa=Object.create,A0=function(){function e(){}return function(r){if(!$0(r))return{};if(fa)return fa(r);e.prototype=r;var t=new e;return e.prototype=void 0,t}}(),gt=A0,E0=gt,S0=On,x0=$n;function I0(e){return typeof e.constructor=="function"&&!x0(e)?E0(S0(e)):{}}var T0=I0,O0=Un,B0=Ue,P0="[object Map]";function R0(e){return B0(e)&&O0(e)==P0}var F0=R0,C0=F0,U0=bn,la=Fr.exports,pa=la&&la.isMap,D0=pa?U0(pa):C0,N0=D0,L0=Un,M0=Ue,j0="[object Set]";function k0(e){return M0(e)&&L0(e)==j0}var G0=k0,W0=G0,q0=bn,ha=Fr.exports,da=ha&&ha.isSet,z0=da?q0(da):W0,V0=z0,H0=md,Y0=Fo,K0=No,X0=ug,J0=Sg,Q0=Sn.exports,Z0=xn,em=Lg,rm=Jg,tm=ov,nm=Qo,im=Un,om=Cv,am=b0,sm=T0,um=De,cm=yt.exports,fm=N0,lm=Ye,pm=V0,hm=An,dm=En,ym=1,gm=2,vm=4,ya="[object Arguments]",mm="[object Array]",_m="[object Boolean]",wm="[object Date]",bm="[object Error]",ga="[object Function]",$m="[object GeneratorFunction]",Am="[object Map]",Em="[object Number]",va="[object Object]",Sm="[object RegExp]",xm="[object Set]",Im="[object String]",Tm="[object Symbol]",Om="[object WeakMap]",Bm="[object ArrayBuffer]",Pm="[object DataView]",Rm="[object Float32Array]",Fm="[object Float64Array]",Cm="[object Int8Array]",Um="[object Int16Array]",Dm="[object Int32Array]",Nm="[object Uint8Array]",Lm="[object Uint8ClampedArray]",Mm="[object Uint16Array]",jm="[object Uint32Array]",L={};L[ya]=L[mm]=L[Bm]=L[Pm]=L[_m]=L[wm]=L[Rm]=L[Fm]=L[Cm]=L[Um]=L[Dm]=L[Am]=L[Em]=L[va]=L[Sm]=L[xm]=L[Im]=L[Tm]=L[Nm]=L[Lm]=L[Mm]=L[jm]=!0,L[bm]=L[ga]=L[Om]=!1;function vt(e,r,t,n,a,s){var c,p=r&ym,h=r&gm,v=r&vm;if(t&&(c=a?t(e,n,a,s):t(e)),c!==void 0)return c;if(!lm(e))return e;var _=um(e);if(_){if(c=om(e),!p)return Z0(e,c)}else{var w=im(e),b=w==ga||w==$m;if(cm(e))return Q0(e,p);if(w==va||w==ya||b&&!a){if(c=h||b?{}:sm(e),!p)return h?rm(e,J0(c,e)):em(e,X0(c,e))}else{if(!L[w])return a?e:{};c=am(e,w,p)}}s||(s=new H0);var d=s.get(e);if(d)return d;s.set(e,c),pm(e)?e.forEach(function(I){c.add(vt(I,r,t,I,e,s))}):fm(e)&&e.forEach(function(I,S){c.set(S,vt(I,r,t,S,e,s))});var E=v?h?nm:tm:h?dm:hm,x=_?void 0:E(e);return Y0(x||e,function(I,S){x&&(S=I,I=e[S]),K0(c,S,vt(I,r,t,S,e,s))}),c}var km=vt,Gm=ur,Wm=Ue,qm="[object Symbol]";function zm(e){return typeof e=="symbol"||Wm(e)&&Gm(e)==qm}var mt=zm,Vm=De,Hm=mt,Ym=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Km=/^\w*$/;function Xm(e,r){if(Vm(e))return!1;var t=typeof e;return t=="number"||t=="symbol"||t=="boolean"||e==null||Hm(e)?!0:Km.test(e)||!Ym.test(e)||r!=null&&e in Object(r)}var Jm=Xm,ma=Ro,Qm="Expected a function";function Nn(e,r){if(typeof e!="function"||r!=null&&typeof r!="function")throw new TypeError(Qm);var t=function(){var n=arguments,a=r?r.apply(this,n):n[0],s=t.cache;if(s.has(a))return s.get(a);var c=e.apply(this,n);return t.cache=s.set(a,c)||s,c};return t.cache=new(Nn.Cache||ma),t}Nn.Cache=ma;var Zm=Nn,e_=Zm,r_=500;function t_(e){var r=e_(e,function(n){return t.size===r_&&t.clear(),n}),t=r.cache;return r}var n_=t_,i_=n_,o_=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,a_=/\\(\\)?/g,s_=i_(function(e){var r=[];return e.charCodeAt(0)===46&&r.push(""),e.replace(o_,function(t,n,a,s){r.push(a?s.replace(a_,"$1"):n||t)}),r}),u_=s_,_a=Br,c_=wo,f_=De,l_=mt,p_=1/0,wa=_a?_a.prototype:void 0,ba=wa?wa.toString:void 0;function $a(e){if(typeof e=="string")return e;if(f_(e))return c_(e,$a)+"";if(l_(e))return ba?ba.call(e):"";var r=e+"";return r=="0"&&1/e==-p_?"-0":r}var h_=$a,d_=h_;function y_(e){return e==null?"":d_(e)}var g_=y_,v_=De,m_=Jm,__=u_,w_=g_;function b_(e,r){return v_(e)?e:m_(e,r)?[e]:__(w_(e))}var Ln=b_;function $_(e){var r=e==null?0:e.length;return r?e[r-1]:void 0}var A_=$_,E_=mt,S_=1/0;function x_(e){if(typeof e=="string"||E_(e))return e;var r=e+"";return r=="0"&&1/e==-S_?"-0":r}var Aa=x_,I_=Ln,T_=Aa;function O_(e,r){r=I_(r,e);for(var t=0,n=r.length;e!=null&&t<n;)e=e[T_(r[t++])];return t&&t==n?e:void 0}var B_=O_;function P_(e,r,t){var n=-1,a=e.length;r<0&&(r=-r>a?0:a+r),t=t>a?a:t,t<0&&(t+=a),a=r>t?0:t-r>>>0,r>>>=0;for(var s=Array(a);++n<a;)s[n]=e[n+r];return s}var R_=P_,F_=B_,C_=R_;function U_(e,r){return r.length<2?e:F_(e,C_(r,0,-1))}var D_=U_,N_=Ln,L_=A_,M_=D_,j_=Aa;function k_(e,r){return r=N_(r,e),e=M_(e,r),e==null||delete e[j_(L_(r))]}var G_=k_,W_=ur,q_=On,z_=Ue,V_="[object Object]",H_=Function.prototype,Y_=Object.prototype,Ea=H_.toString,K_=Y_.hasOwnProperty,X_=Ea.call(Object);function J_(e){if(!z_(e)||W_(e)!=V_)return!1;var r=q_(e);if(r===null)return!0;var t=K_.call(r,"constructor")&&r.constructor;return typeof t=="function"&&t instanceof t&&Ea.call(t)==X_}var Q_=J_,Z_=Q_;function ew(e){return Z_(e)?void 0:e}var rw=ew,Sa=Br,tw=jo,nw=De,xa=Sa?Sa.isConcatSpreadable:void 0;function iw(e){return nw(e)||tw(e)||!!(xa&&e&&e[xa])}var ow=iw,aw=Tn,sw=ow;function Ia(e,r,t,n,a){var s=-1,c=e.length;for(t||(t=sw),a||(a=[]);++s<c;){var p=e[s];r>0&&t(p)?r>1?Ia(p,r-1,t,n,a):aw(a,p):n||(a[a.length]=p)}return a}var uw=Ia,cw=uw;function fw(e){var r=e==null?0:e.length;return r?cw(e,1):[]}var lw=fw;function pw(e,r,t){switch(t.length){case 0:return e.call(r);case 1:return e.call(r,t[0]);case 2:return e.call(r,t[0],t[1]);case 3:return e.call(r,t[0],t[1],t[2])}return e.apply(r,t)}var Mn=pw,hw=Mn,Ta=Math.max;function dw(e,r,t){return r=Ta(r===void 0?e.length-1:r,0),function(){for(var n=arguments,a=-1,s=Ta(n.length-r,0),c=Array(s);++a<s;)c[a]=n[r+a];a=-1;for(var p=Array(r+1);++a<r;)p[a]=n[a];return p[r]=t(c),hw(e,this,p)}}var Oa=dw;function yw(e){return function(){return e}}var gw=yw;function vw(e){return e}var jn=vw,mw=gw,Ba=Co,_w=jn,ww=Ba?function(e,r){return Ba(e,"toString",{configurable:!0,enumerable:!1,value:mw(r),writable:!0})}:_w,bw=ww,$w=800,Aw=16,Ew=Date.now;function Sw(e){var r=0,t=0;return function(){var n=Ew(),a=Aw-(n-t);if(t=n,a>0){if(++r>=$w)return arguments[0]}else r=0;return e.apply(void 0,arguments)}}var Pa=Sw,xw=bw,Iw=Pa,Tw=Iw(xw),kn=Tw,Ow=lw,Bw=Oa,Pw=kn;function Rw(e){return Pw(Bw(e,void 0,Ow),e+"")}var Fw=Rw,Cw=wo,Uw=km,Dw=G_,Nw=Ln,Lw=Rr,Mw=rw,jw=Fw,kw=Qo,Gw=1,Ww=2,qw=4,zw=jw(function(e,r){var t={};if(e==null)return t;var n=!1;r=Cw(r,function(s){return s=Nw(s,e),n||(n=s.length>1),s}),Lw(e,kw(e),t),n&&(t=Uw(t,Gw|Ww|qw,Mw));for(var a=r.length;a--;)Dw(t,r[a]);return t}),Gn=zw,Vw=Object.defineProperty,Hw=Object.defineProperties,Yw=Object.getOwnPropertyDescriptors,Ra=Object.getOwnPropertySymbols,Kw=Object.prototype.hasOwnProperty,Xw=Object.prototype.propertyIsEnumerable,Fa=(e,r,t)=>r in e?Vw(e,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[r]=t,Jw=(e,r)=>{for(var t in r||(r={}))Kw.call(r,t)&&Fa(e,t,r[t]);if(Ra)for(var t of Ra(r))Xw.call(r,t)&&Fa(e,t,r[t]);return e},Qw=(e,r)=>Hw(e,Yw(r));function Zw(e){try{return JSON.parse(e)}catch{return e}}function e1(e){return Object.entries(e).reduce((r,[t,n])=>Qw(Jw({},r),{[t]:Zw(n)}),{})}const Ca=e=>typeof e=="string"?e!=="0"&&e!=="false":!!e;var r1=Object.defineProperty,t1=Object.defineProperties,n1=Object.getOwnPropertyDescriptors,Ua=Object.getOwnPropertySymbols,i1=Object.prototype.hasOwnProperty,o1=Object.prototype.propertyIsEnumerable,Da=(e,r,t)=>r in e?r1(e,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[r]=t,Na=(e,r)=>{for(var t in r||(r={}))i1.call(r,t)&&Da(e,t,r[t]);if(Ua)for(var t of Ua(r))o1.call(r,t)&&Da(e,t,r[t]);return e},La=(e,r)=>t1(e,n1(r));function Ma(e){var r;const t=e1(e),n=t.auto_inject===void 0?!0:t.auto_inject,a=(r=t.display_on)!=null?r:[],s=t.first_option==="autodeliver";return La(Na({},Gn(t,["display_on","first_option"])),{auto_inject:n,valid_pages:a,is_subscription_first:s,autoInject:n,validPages:a,isSubscriptionFirst:s})}function ja(e){var r;const t=((r=e.subscription_options)==null?void 0:r.storefront_purchase_options)==="subscription_only";return La(Na({},e),{is_subscription_only:t,isSubscriptionOnly:t})}function a1(e){return e.map(r=>{const t={};return Object.entries(r).forEach(([n,a])=>{t[n]=ja(a)}),t})}const _t="2020-12",s1={store_currency:{currency_code:"USD",currency_symbol:"$",decimal_separator:".",thousands_separator:",",currency_symbol_location:"left"}},Cr=new Map;function wt(e,r){return Cr.has(e)||Cr.set(e,r()),Cr.get(e)}async function Wn(e){const{product:r}=await wt(`product.${e}`,()=>ft("get",`/product/${_t}/${e}.json`));return ja(r)}async function ka(){return await wt("storeSettings",()=>ft("get",`/${_t}/store_settings.json`).catch(()=>s1))}async function Ga(){const{widget_settings:e}=await wt("widgetSettings",()=>ft("get",`/${_t}/widget_settings.json`));return Ma(e)}async function Wa(){const{products:e,widget_settings:r,store_settings:t,meta:n}=await wt("productsAndSettings",()=>ft("get",`/product/${_t}/products.json`));return n?.status==="error"?Promise.reject(n.message):{products:a1(e),widget_settings:Ma(r),store_settings:t??{}}}async function u1(){const{products:e}=await Wa();return e}async function c1(e){const[r,t,n]=await Promise.all([Wn(e),ka(),Ga()]);return{product:r,store_settings:t,widget_settings:n,storeSettings:t,widgetSettings:n}}async function qa(e){const{bundle_product:r}=await Wn(e);return r}async function za(){return Array.from(Cr.keys()).forEach(e=>Cr.delete(e))}var f1=Object.freeze({__proto__:null,getCDNProduct:Wn,getCDNStoreSettings:ka,getCDNWidgetSettings:Ga,getCDNProductsAndSettings:Wa,getCDNProducts:u1,getCDNProductAndSettings:c1,getCDNBundleSettings:qa,resetCDNCache:za}),Va={exports:{}};/*! For license information please see xdr.js.LICENSE.txt */(function(e,r){(function(t,n){e.exports=n()})(Ae,()=>(()=>{var t={899:(s,c,p)=>{const h=p(221);s.exports=h},221:(s,c,p)=>{p.r(c),p.d(c,{Array:()=>yr,Bool:()=>H,Double:()=>xt,Enum:()=>$e,Float:()=>Ne,Hyper:()=>k,Int:()=>V,Opaque:()=>Nr,Option:()=>Mr,Quadruple:()=>G,Reference:()=>te,String:()=>Dr,Struct:()=>Le,Union:()=>Oe,UnsignedHyper:()=>se,UnsignedInt:()=>N,VarArray:()=>Lr,VarOpaque:()=>Te,Void:()=>Q,config:()=>g});class h extends TypeError{constructor(o){super(`XDR Write Error: ${o}`)}}class v extends TypeError{constructor(o){super(`XDR Read Error: ${o}`)}}class _ extends TypeError{constructor(o){super(`XDR Type Definition Error: ${o}`)}}class w extends _{constructor(){super("method not implemented, it should be overloaded in the descendant class.")}}var b=p(764).lW;class d{constructor(o){if(!b.isBuffer(o)){if(!(o instanceof Array))throw new v("source not specified");o=b.from(o)}this._buffer=o,this._length=o.length,this._index=0}_buffer;_length;_index;get eof(){return this._index===this._length}advance(o){const l=this._index;if(this._index+=o,this._length<this._index)throw new v("attempt to read outside the boundary of the buffer");const m=4-(o%4||4);if(m>0){for(let A=0;A<m;A++)if(this._buffer[this._index+A]!==0)throw new v("invalid padding");this._index+=m}return l}rewind(){this._index=0}read(o){const l=this.advance(o);return this._buffer.subarray(l,l+o)}readInt32BE(){return this._buffer.readInt32BE(this.advance(4))}readUInt32BE(){return this._buffer.readUInt32BE(this.advance(4))}readBigInt64BE(){return this._buffer.readBigInt64BE(this.advance(8))}readBigUInt64BE(){return this._buffer.readBigUInt64BE(this.advance(8))}readFloatBE(){return this._buffer.readFloatBE(this.advance(4))}readDoubleBE(){return this._buffer.readDoubleBE(this.advance(8))}ensureInputConsumed(){if(this._index!==this._length)throw new v("invalid XDR contract typecast - source buffer not entirely consumed")}}var E=p(764).lW;const x=8192;class I{constructor(o){typeof o=="number"?o=E.allocUnsafe(o):o instanceof E||(o=E.allocUnsafe(x)),this._buffer=o,this._length=o.length}_buffer;_length;_index=0;alloc(o){const l=this._index;return this._index+=o,this._length<this._index&&this.resize(this._index),l}resize(o){const l=Math.ceil(o/x)*x,m=E.allocUnsafe(l);this._buffer.copy(m,0,0,this._length),this._buffer=m,this._length=l}finalize(){return this._buffer.subarray(0,this._index)}toArray(){return[...this.finalize()]}write(o,l){if(typeof o=="string"){const A=this.alloc(l);this._buffer.write(o,A,"utf8")}else{o instanceof E||(o=E.from(o));const A=this.alloc(l);o.copy(this._buffer,A,0,l)}const m=4-(l%4||4);if(m>0){const A=this.alloc(m);this._buffer.fill(0,A,this._index)}}writeInt32BE(o){const l=this.alloc(4);this._buffer.writeInt32BE(o,l)}writeUInt32BE(o){const l=this.alloc(4);this._buffer.writeUInt32BE(o,l)}writeBigInt64BE(o){const l=this.alloc(8);this._buffer.writeBigInt64BE(o,l)}writeBigUInt64BE(o){const l=this.alloc(8);this._buffer.writeBigUInt64BE(o,l)}writeFloatBE(o){const l=this.alloc(4);this._buffer.writeFloatBE(o,l)}writeDoubleBE(o){const l=this.alloc(8);this._buffer.writeDoubleBE(o,l)}static bufferChunkSize=x}var S=p(764).lW;class T{toXDR(){let o=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"raw";if(!this.write)return this.constructor.toXDR(this,o);const l=new I;return this.write(this,l),j(l.finalize(),o)}fromXDR(o){let l=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"raw";if(!this.read)return this.constructor.fromXDR(o,l);const m=new d(q(o,l)),A=this.read(m);return m.ensureInputConsumed(),A}validateXDR(o){let l=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"raw";try{return this.fromXDR(o,l),!0}catch{return!1}}static toXDR(o){let l=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"raw";const m=new I;return this.write(o,m),j(m.finalize(),l)}static fromXDR(o){const l=new d(q(o,arguments.length>1&&arguments[1]!==void 0?arguments[1]:"raw")),m=this.read(l);return l.ensureInputConsumed(),m}static validateXDR(o){let l=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"raw";try{return this.fromXDR(o,l),!0}catch{return!1}}}class P extends T{static read(o){throw new w}static write(o,l){throw new w}static isValid(o){return!1}}class B extends T{isValid(o){return!1}}class D extends TypeError{constructor(o){super(`Invalid format ${o}, must be one of "raw", "hex", "base64"`)}}function j(y,o){switch(o){case"raw":return y;case"hex":return y.toString("hex");case"base64":return y.toString("base64");default:throw new D(o)}}function q(y,o){switch(o){case"raw":return y;case"hex":return S.from(y,"hex");case"base64":return S.from(y,"base64");default:throw new D(o)}}const z=2147483647,X=-2147483648;class V extends P{static read(o){return o.readInt32BE()}static write(o,l){if(typeof o!="number")throw new h("not a number");if((0|o)!==o)throw new h("invalid i32 value");l.writeInt32BE(o)}static isValid(o){return typeof o=="number"&&(0|o)===o&&o>=X&&o<=z}}V.MAX_VALUE=z,V.MIN_VALUE=2147483648;const ae=-9223372036854775808n,ue=9223372036854775807n;class k extends P{constructor(o,l){if(super(),typeof o=="bigint"){if(o<ae||o>ue)throw new TypeError("Invalid i64 value");this._value=o}else{if((0|o)!==o||(0|l)!==l)throw new TypeError("Invalid i64 value");this._value=BigInt(l>>>0)<<32n|BigInt(o>>>0)}}get low(){return Number(0xFFFFFFFFn&this._value)<<0}get high(){return Number(this._value>>32n)>>0}get unsigned(){return!1}toString(){return this._value.toString()}toJSON(){return{_value:this._value.toString()}}static read(o){return new k(o.readBigInt64BE())}static write(o,l){if(!(o instanceof this))throw new h(`${o} is not a Hyper`);l.writeBigInt64BE(o._value)}static fromString(o){if(!/^-?\d{0,19}$/.test(o))throw new TypeError(`Invalid i64 string value: ${o}`);return new k(BigInt(o))}static fromBits(o,l){return new this(o,l)}static isValid(o){return o instanceof this}}k.MAX_VALUE=new k(ue),k.MIN_VALUE=new k(ae);const re=4294967295;class N extends P{static read(o){return o.readUInt32BE()}static write(o,l){if(typeof o!="number"||!(o>=0&&o<=re)||o%1!=0)throw new h("invalid u32 value");l.writeUInt32BE(o)}static isValid(o){return typeof o=="number"&&o%1==0&&o>=0&&o<=re}}N.MAX_VALUE=re,N.MIN_VALUE=0;const ce=0n,hr=0xFFFFFFFFFFFFFFFFn;class se extends P{constructor(o,l){if(super(),typeof o=="bigint"){if(o<ce||o>hr)throw new TypeError("Invalid u64 value");this._value=o}else{if((0|o)!==o||(0|l)!==l)throw new TypeError("Invalid u64 value");this._value=BigInt(l>>>0)<<32n|BigInt(o>>>0)}}get low(){return Number(0xFFFFFFFFn&this._value)<<0}get high(){return Number(this._value>>32n)>>0}get unsigned(){return!0}toString(){return this._value.toString()}toJSON(){return{_value:this._value.toString()}}static read(o){return new se(o.readBigUInt64BE())}static write(o,l){if(!(o instanceof this))throw new h(`${o} is not an UnsignedHyper`);l.writeBigUInt64BE(o._value)}static fromString(o){if(!/^\d{0,20}$/.test(o))throw new TypeError(`Invalid u64 string value: ${o}`);return new se(BigInt(o))}static fromBits(o,l){return new this(o,l)}static isValid(o){return o instanceof this}}se.MAX_VALUE=new se(hr),se.MIN_VALUE=new se(ce);class Ne extends P{static read(o){return o.readFloatBE()}static write(o,l){if(typeof o!="number")throw new h("not a number");l.writeFloatBE(o)}static isValid(o){return typeof o=="number"}}class xt extends P{static read(o){return o.readDoubleBE()}static write(o,l){if(typeof o!="number")throw new h("not a number");l.writeDoubleBE(o)}static isValid(o){return typeof o=="number"}}class G extends P{static read(){throw new _("quadruple not supported")}static write(){throw new _("quadruple not supported")}static isValid(){return!1}}class H extends P{static read(o){const l=V.read(o);switch(l){case 0:return!1;case 1:return!0;default:throw new v(`got ${l} when trying to read a bool`)}}static write(o,l){const m=o?1:0;V.write(m,l)}static isValid(o){return typeof o=="boolean"}}var dr=p(764).lW;class Dr extends B{constructor(){let o=arguments.length>0&&arguments[0]!==void 0?arguments[0]:N.MAX_VALUE;super(),this._maxLength=o}read(o){const l=N.read(o);if(l>this._maxLength)throw new v(`saw ${l} length String, max allowed is ${this._maxLength}`);return o.read(l)}readString(o){return this.read(o).toString("utf8")}write(o,l){const m=typeof o=="string"?dr.byteLength(o,"utf8"):o.length;if(m>this._maxLength)throw new h(`got ${o.length} bytes, max allowed is ${this._maxLength}`);N.write(m,l),l.write(o,m)}isValid(o){return typeof o=="string"?dr.byteLength(o,"utf8")<=this._maxLength:!!(o instanceof Array||dr.isBuffer(o))&&o.length<=this._maxLength}}var It=p(764).lW;class Nr extends B{constructor(o){super(),this._length=o}read(o){return o.read(this._length)}write(o,l){const{length:m}=o;if(m!==this._length)throw new h(`got ${o.length} bytes, expected ${this._length}`);l.write(o,m)}isValid(o){return It.isBuffer(o)&&o.length===this._length}}var Tt=p(764).lW;class Te extends B{constructor(){let o=arguments.length>0&&arguments[0]!==void 0?arguments[0]:N.MAX_VALUE;super(),this._maxLength=o}read(o){const l=N.read(o);if(l>this._maxLength)throw new v(`saw ${l} length VarOpaque, max allowed is ${this._maxLength}`);return o.read(l)}write(o,l){const{length:m}=o;if(o.length>this._maxLength)throw new h(`got ${o.length} bytes, max allowed is ${this._maxLength}`);N.write(m,l),l.write(o,m)}isValid(o){return Tt.isBuffer(o)&&o.length<=this._maxLength}}class yr extends B{constructor(o,l){super(),this._childType=o,this._length=l}read(o){const l=new p.g.Array(this._length);for(let m=0;m<this._length;m++)l[m]=this._childType.read(o);return l}write(o,l){if(!(o instanceof p.g.Array))throw new h("value is not array");if(o.length!==this._length)throw new h(`got array of size ${o.length}, expected ${this._length}`);for(const m of o)this._childType.write(m,l)}isValid(o){if(!(o instanceof p.g.Array)||o.length!==this._length)return!1;for(const l of o)if(!this._childType.isValid(l))return!1;return!0}}class Lr extends B{constructor(o){let l=arguments.length>1&&arguments[1]!==void 0?arguments[1]:N.MAX_VALUE;super(),this._childType=o,this._maxLength=l}read(o){const l=N.read(o);if(l>this._maxLength)throw new v(`saw ${l} length VarArray, max allowed is ${this._maxLength}`);const m=new Array(l);for(let A=0;A<l;A++)m[A]=this._childType.read(o);return m}write(o,l){if(!(o instanceof Array))throw new h("value is not array");if(o.length>this._maxLength)throw new h(`got array of size ${o.length}, max allowed is ${this._maxLength}`);N.write(o.length,l);for(const m of o)this._childType.write(m,l)}isValid(o){if(!(o instanceof Array)||o.length>this._maxLength)return!1;for(const l of o)if(!this._childType.isValid(l))return!1;return!0}}class Mr extends P{constructor(o){super(),this._childType=o}read(o){if(H.read(o))return this._childType.read(o)}write(o,l){const m=o!=null;H.write(m,l),m&&this._childType.write(o,l)}isValid(o){return o==null||this._childType.isValid(o)}}class Q extends P{static read(){}static write(o){if(o!==void 0)throw new h("trying to write value to a void slot")}static isValid(o){return o===void 0}}class $e extends P{constructor(o,l){super(),this.name=o,this.value=l}static read(o){const l=V.read(o),m=this._byValue[l];if(m===void 0)throw new v(`unknown ${this.enumName} member for value ${l}`);return m}static write(o,l){if(!(o instanceof this))throw new h(`unknown ${o} is not a ${this.enumName}`);V.write(o.value,l)}static isValid(o){return o instanceof this}static members(){return this._members}static values(){return Object.values(this._members)}static fromName(o){const l=this._members[o];if(!l)throw new TypeError(`${o} is not a member of ${this.enumName}`);return l}static fromValue(o){const l=this._byValue[o];if(l===void 0)throw new TypeError(`${o} is not a value of any member of ${this.enumName}`);return l}static create(o,l,m){const A=class extends $e{};A.enumName=l,o.results[l]=A,A._members={},A._byValue={};for(const[F,R]of Object.entries(m)){const C=new A(F,R);A._members[F]=C,A._byValue[R]=C,A[F]=()=>C}return A}}class te extends P{resolve(){throw new _('"resolve" method should be implemented in the descendant class')}}class Le extends P{constructor(o){super(),this._attributes=o||{}}static read(o){const l={};for(const[m,A]of this._fields)l[m]=A.read(o);return new this(l)}static write(o,l){if(!(o instanceof this))throw new h(`${o} is not a ${this.structName}`);for(const[m,A]of this._fields){const F=o._attributes[m];A.write(F,l)}}static isValid(o){return o instanceof this}static create(o,l,m){const A=class extends Le{};A.structName=l,o.results[l]=A;const F=new Array(m.length);for(let R=0;R<m.length;R++){const C=m[R],jr=C[0];let Bt=C[1];Bt instanceof te&&(Bt=Bt.resolve(o)),F[R]=[jr,Bt],A.prototype[jr]=Ot(jr)}return A._fields=F,A}}function Ot(y){return function(o){return o!==void 0&&(this._attributes[y]=o),this._attributes[y]}}class Oe extends B{constructor(o,l){super(),this.set(o,l)}set(o,l){typeof o=="string"&&(o=this.constructor._switchOn.fromName(o)),this._switch=o;const m=this.constructor.armForSwitch(this._switch);this._arm=m,this._armType=m===Q?Q:this.constructor._arms[m],this._value=l}get(){let o=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this._arm;if(this._arm!==Q&&this._arm!==o)throw new TypeError(`${o} not set`);return this._value}switch(){return this._switch}arm(){return this._arm}armType(){return this._armType}value(){return this._value}static armForSwitch(o){const l=this._switches.get(o);if(l!==void 0)return l;if(this._defaultArm)return this._defaultArm;throw new TypeError(`Bad union switch: ${o}`)}static armTypeForArm(o){return o===Q?Q:this._arms[o]}static read(o){const l=this._switchOn.read(o),m=this.armForSwitch(l),A=m===Q?Q:this._arms[m];let F;return F=A!==void 0?A.read(o):m.read(o),new this(l,F)}static write(o,l){if(!(o instanceof this))throw new h(`${o} is not a ${this.unionName}`);this._switchOn.write(o.switch(),l),o.armType().write(o.value(),l)}static isValid(o){return o instanceof this}static create(o,l,m){const A=class extends Oe{};A.unionName=l,o.results[l]=A,m.switchOn instanceof te?A._switchOn=m.switchOn.resolve(o):A._switchOn=m.switchOn,A._switches=new Map,A._arms={};let F=m.defaultArm;F instanceof te&&(F=F.resolve(o)),A._defaultArm=F;for(const[R,C]of m.switches){const jr=typeof R=="string"?A._switchOn.fromName(R):R;A._switches.set(jr,C)}if(A._switchOn.values!==void 0)for(const R of A._switchOn.values())A[R.name]=function(C){return new A(R,C)},A.prototype[R.name]=function(C){return this.set(R,C)};if(m.arms)for(const[R,C]of Object.entries(m.arms))A._arms[R]=C instanceof te?C.resolve(o):C,C!==Q&&(A.prototype[R]=function(){return this.get(R)});return A}}class pe extends te{constructor(o){super(),this.name=o}resolve(o){return o.definitions[this.name].resolve(o)}}class gr extends te{constructor(o,l){let m=arguments.length>2&&arguments[2]!==void 0&&arguments[2];super(),this.childReference=o,this.length=l,this.variable=m}resolve(o){let l=this.childReference,m=this.length;return l instanceof te&&(l=l.resolve(o)),m instanceof te&&(m=m.resolve(o)),this.variable?new Lr(l,m):new yr(l,m)}}class Qn extends te{constructor(o){super(),this.childReference=o,this.name=o.name}resolve(o){let l=this.childReference;return l instanceof te&&(l=l.resolve(o)),new Mr(l)}}class he extends te{constructor(o,l){super(),this.sizedType=o,this.length=l}resolve(o){let l=this.length;return l instanceof te&&(l=l.resolve(o)),new this.sizedType(l)}}class Je{constructor(o,l,m){this.constructor=o,this.name=l,this.config=m}resolve(o){return this.name in o.results?o.results[this.name]:this.constructor(o,this.name,this.config)}}function i(y,o,l){return l instanceof te&&(l=l.resolve(y)),y.results[o]=l,l}function u(y,o,l){return y.results[o]=l,l}class f{constructor(o){this._destination=o,this._definitions={}}enum(o,l){const m=new Je($e.create,o,l);this.define(o,m)}struct(o,l){const m=new Je(Le.create,o,l);this.define(o,m)}union(o,l){const m=new Je(Oe.create,o,l);this.define(o,m)}typedef(o,l){const m=new Je(i,o,l);this.define(o,m)}const(o,l){const m=new Je(u,o,l);this.define(o,m)}void(){return Q}bool(){return H}int(){return V}hyper(){return k}uint(){return N}uhyper(){return se}float(){return Ne}double(){return xt}quadruple(){return G}string(o){return new he(Dr,o)}opaque(o){return new he(Nr,o)}varOpaque(o){return new he(Te,o)}array(o,l){return new gr(o,l)}varArray(o,l){return new gr(o,l,!0)}option(o){return new Qn(o)}define(o,l){if(this._destination[o]!==void 0)throw new _(`${o} is already defined`);this._definitions[o]=l}lookup(o){return new pe(o)}resolve(){for(const o of Object.values(this._definitions))o.resolve({definitions:this._definitions,results:this._destination})}}function g(y){let o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(y){const l=new f(o);y(l),l.resolve()}return o}},742:(s,c)=>{c.byteLength=function(E){var x=b(E),I=x[0],S=x[1];return 3*(I+S)/4-S},c.toByteArray=function(E){var x,I,S=b(E),T=S[0],P=S[1],B=new v(function(q,z,X){return 3*(z+X)/4-X}(0,T,P)),D=0,j=P>0?T-4:T;for(I=0;I<j;I+=4)x=h[E.charCodeAt(I)]<<18|h[E.charCodeAt(I+1)]<<12|h[E.charCodeAt(I+2)]<<6|h[E.charCodeAt(I+3)],B[D++]=x>>16&255,B[D++]=x>>8&255,B[D++]=255&x;return P===2&&(x=h[E.charCodeAt(I)]<<2|h[E.charCodeAt(I+1)]>>4,B[D++]=255&x),P===1&&(x=h[E.charCodeAt(I)]<<10|h[E.charCodeAt(I+1)]<<4|h[E.charCodeAt(I+2)]>>2,B[D++]=x>>8&255,B[D++]=255&x),B},c.fromByteArray=function(E){for(var x,I=E.length,S=I%3,T=[],P=16383,B=0,D=I-S;B<D;B+=P)T.push(d(E,B,B+P>D?D:B+P));return S===1?(x=E[I-1],T.push(p[x>>2]+p[x<<4&63]+"==")):S===2&&(x=(E[I-2]<<8)+E[I-1],T.push(p[x>>10]+p[x>>4&63]+p[x<<2&63]+"=")),T.join("")};for(var p=[],h=[],v=typeof Uint8Array<"u"?Uint8Array:Array,_="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",w=0;w<64;++w)p[w]=_[w],h[_.charCodeAt(w)]=w;function b(E){var x=E.length;if(x%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var I=E.indexOf("=");return I===-1&&(I=x),[I,I===x?0:4-I%4]}function d(E,x,I){for(var S,T,P=[],B=x;B<I;B+=3)S=(E[B]<<16&16711680)+(E[B+1]<<8&65280)+(255&E[B+2]),P.push(p[(T=S)>>18&63]+p[T>>12&63]+p[T>>6&63]+p[63&T]);return P.join("")}h["-".charCodeAt(0)]=62,h["_".charCodeAt(0)]=63},764:(s,c,p)=>{const h=p(742),v=p(645),_=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;c.lW=d,c.h2=50;const w=2147483647;function b(i){if(i>w)throw new RangeError('The value "'+i+'" is invalid for option "size"');const u=new Uint8Array(i);return Object.setPrototypeOf(u,d.prototype),u}function d(i,u,f){if(typeof i=="number"){if(typeof u=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return I(i)}return E(i,u,f)}function E(i,u,f){if(typeof i=="string")return function(o,l){if(typeof l=="string"&&l!==""||(l="utf8"),!d.isEncoding(l))throw new TypeError("Unknown encoding: "+l);const m=0|B(o,l);let A=b(m);const F=A.write(o,l);return F!==m&&(A=A.slice(0,F)),A}(i,u);if(ArrayBuffer.isView(i))return function(o){if(pe(o,Uint8Array)){const l=new Uint8Array(o);return T(l.buffer,l.byteOffset,l.byteLength)}return S(o)}(i);if(i==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof i);if(pe(i,ArrayBuffer)||i&&pe(i.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(pe(i,SharedArrayBuffer)||i&&pe(i.buffer,SharedArrayBuffer)))return T(i,u,f);if(typeof i=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');const g=i.valueOf&&i.valueOf();if(g!=null&&g!==i)return d.from(g,u,f);const y=function(o){if(d.isBuffer(o)){const l=0|P(o.length),m=b(l);return m.length===0||o.copy(m,0,0,l),m}if(o.length!==void 0)return typeof o.length!="number"||gr(o.length)?b(0):S(o);if(o.type==="Buffer"&&Array.isArray(o.data))return S(o.data)}(i);if(y)return y;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof i[Symbol.toPrimitive]=="function")return d.from(i[Symbol.toPrimitive]("string"),u,f);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof i)}function x(i){if(typeof i!="number")throw new TypeError('"size" argument must be of type number');if(i<0)throw new RangeError('The value "'+i+'" is invalid for option "size"')}function I(i){return x(i),b(i<0?0:0|P(i))}function S(i){const u=i.length<0?0:0|P(i.length),f=b(u);for(let g=0;g<u;g+=1)f[g]=255&i[g];return f}function T(i,u,f){if(u<0||i.byteLength<u)throw new RangeError('"offset" is outside of buffer bounds');if(i.byteLength<u+(f||0))throw new RangeError('"length" is outside of buffer bounds');let g;return g=u===void 0&&f===void 0?new Uint8Array(i):f===void 0?new Uint8Array(i,u):new Uint8Array(i,u,f),Object.setPrototypeOf(g,d.prototype),g}function P(i){if(i>=w)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+w.toString(16)+" bytes");return 0|i}function B(i,u){if(d.isBuffer(i))return i.length;if(ArrayBuffer.isView(i)||pe(i,ArrayBuffer))return i.byteLength;if(typeof i!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof i);const f=i.length,g=arguments.length>2&&arguments[2]===!0;if(!g&&f===0)return 0;let y=!1;for(;;)switch(u){case"ascii":case"latin1":case"binary":return f;case"utf8":case"utf-8":return Le(i).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*f;case"hex":return f>>>1;case"base64":return Ot(i).length;default:if(y)return g?-1:Le(i).length;u=(""+u).toLowerCase(),y=!0}}function D(i,u,f){let g=!1;if((u===void 0||u<0)&&(u=0),u>this.length||((f===void 0||f>this.length)&&(f=this.length),f<=0)||(f>>>=0)<=(u>>>=0))return"";for(i||(i="utf8");;)switch(i){case"hex":return Ne(this,u,f);case"utf8":case"utf-8":return N(this,u,f);case"ascii":return hr(this,u,f);case"latin1":case"binary":return se(this,u,f);case"base64":return re(this,u,f);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return xt(this,u,f);default:if(g)throw new TypeError("Unknown encoding: "+i);i=(i+"").toLowerCase(),g=!0}}function j(i,u,f){const g=i[u];i[u]=i[f],i[f]=g}function q(i,u,f,g,y){if(i.length===0)return-1;if(typeof f=="string"?(g=f,f=0):f>2147483647?f=2147483647:f<-2147483648&&(f=-2147483648),gr(f=+f)&&(f=y?0:i.length-1),f<0&&(f=i.length+f),f>=i.length){if(y)return-1;f=i.length-1}else if(f<0){if(!y)return-1;f=0}if(typeof u=="string"&&(u=d.from(u,g)),d.isBuffer(u))return u.length===0?-1:z(i,u,f,g,y);if(typeof u=="number")return u&=255,typeof Uint8Array.prototype.indexOf=="function"?y?Uint8Array.prototype.indexOf.call(i,u,f):Uint8Array.prototype.lastIndexOf.call(i,u,f):z(i,[u],f,g,y);throw new TypeError("val must be string, number or Buffer")}function z(i,u,f,g,y){let o,l=1,m=i.length,A=u.length;if(g!==void 0&&((g=String(g).toLowerCase())==="ucs2"||g==="ucs-2"||g==="utf16le"||g==="utf-16le")){if(i.length<2||u.length<2)return-1;l=2,m/=2,A/=2,f/=2}function F(R,C){return l===1?R[C]:R.readUInt16BE(C*l)}if(y){let R=-1;for(o=f;o<m;o++)if(F(i,o)===F(u,R===-1?0:o-R)){if(R===-1&&(R=o),o-R+1===A)return R*l}else R!==-1&&(o-=o-R),R=-1}else for(f+A>m&&(f=m-A),o=f;o>=0;o--){let R=!0;for(let C=0;C<A;C++)if(F(i,o+C)!==F(u,C)){R=!1;break}if(R)return o}return-1}function X(i,u,f,g){f=Number(f)||0;const y=i.length-f;g?(g=Number(g))>y&&(g=y):g=y;const o=u.length;let l;for(g>o/2&&(g=o/2),l=0;l<g;++l){const m=parseInt(u.substr(2*l,2),16);if(gr(m))return l;i[f+l]=m}return l}function V(i,u,f,g){return Oe(Le(u,i.length-f),i,f,g)}function ae(i,u,f,g){return Oe(function(y){const o=[];for(let l=0;l<y.length;++l)o.push(255&y.charCodeAt(l));return o}(u),i,f,g)}function ue(i,u,f,g){return Oe(Ot(u),i,f,g)}function k(i,u,f,g){return Oe(function(y,o){let l,m,A;const F=[];for(let R=0;R<y.length&&!((o-=2)<0);++R)l=y.charCodeAt(R),m=l>>8,A=l%256,F.push(A),F.push(m);return F}(u,i.length-f),i,f,g)}function re(i,u,f){return u===0&&f===i.length?h.fromByteArray(i):h.fromByteArray(i.slice(u,f))}function N(i,u,f){f=Math.min(i.length,f);const g=[];let y=u;for(;y<f;){const o=i[y];let l=null,m=o>239?4:o>223?3:o>191?2:1;if(y+m<=f){let A,F,R,C;switch(m){case 1:o<128&&(l=o);break;case 2:A=i[y+1],(192&A)==128&&(C=(31&o)<<6|63&A,C>127&&(l=C));break;case 3:A=i[y+1],F=i[y+2],(192&A)==128&&(192&F)==128&&(C=(15&o)<<12|(63&A)<<6|63&F,C>2047&&(C<55296||C>57343)&&(l=C));break;case 4:A=i[y+1],F=i[y+2],R=i[y+3],(192&A)==128&&(192&F)==128&&(192&R)==128&&(C=(15&o)<<18|(63&A)<<12|(63&F)<<6|63&R,C>65535&&C<1114112&&(l=C))}}l===null?(l=65533,m=1):l>65535&&(l-=65536,g.push(l>>>10&1023|55296),l=56320|1023&l),g.push(l),y+=m}return function(o){const l=o.length;if(l<=ce)return String.fromCharCode.apply(String,o);let m="",A=0;for(;A<l;)m+=String.fromCharCode.apply(String,o.slice(A,A+=ce));return m}(g)}d.TYPED_ARRAY_SUPPORT=function(){try{const i=new Uint8Array(1),u={foo:function(){return 42}};return Object.setPrototypeOf(u,Uint8Array.prototype),Object.setPrototypeOf(i,u),i.foo()===42}catch{return!1}}(),d.TYPED_ARRAY_SUPPORT||typeof console>"u"||typeof console.error!="function"||console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."),Object.defineProperty(d.prototype,"parent",{enumerable:!0,get:function(){if(d.isBuffer(this))return this.buffer}}),Object.defineProperty(d.prototype,"offset",{enumerable:!0,get:function(){if(d.isBuffer(this))return this.byteOffset}}),d.poolSize=8192,d.from=function(i,u,f){return E(i,u,f)},Object.setPrototypeOf(d.prototype,Uint8Array.prototype),Object.setPrototypeOf(d,Uint8Array),d.alloc=function(i,u,f){return function(g,y,o){return x(g),g<=0?b(g):y!==void 0?typeof o=="string"?b(g).fill(y,o):b(g).fill(y):b(g)}(i,u,f)},d.allocUnsafe=function(i){return I(i)},d.allocUnsafeSlow=function(i){return I(i)},d.isBuffer=function(i){return i!=null&&i._isBuffer===!0&&i!==d.prototype},d.compare=function(i,u){if(pe(i,Uint8Array)&&(i=d.from(i,i.offset,i.byteLength)),pe(u,Uint8Array)&&(u=d.from(u,u.offset,u.byteLength)),!d.isBuffer(i)||!d.isBuffer(u))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(i===u)return 0;let f=i.length,g=u.length;for(let y=0,o=Math.min(f,g);y<o;++y)if(i[y]!==u[y]){f=i[y],g=u[y];break}return f<g?-1:g<f?1:0},d.isEncoding=function(i){switch(String(i).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},d.concat=function(i,u){if(!Array.isArray(i))throw new TypeError('"list" argument must be an Array of Buffers');if(i.length===0)return d.alloc(0);let f;if(u===void 0)for(u=0,f=0;f<i.length;++f)u+=i[f].length;const g=d.allocUnsafe(u);let y=0;for(f=0;f<i.length;++f){let o=i[f];if(pe(o,Uint8Array))y+o.length>g.length?(d.isBuffer(o)||(o=d.from(o)),o.copy(g,y)):Uint8Array.prototype.set.call(g,o,y);else{if(!d.isBuffer(o))throw new TypeError('"list" argument must be an Array of Buffers');o.copy(g,y)}y+=o.length}return g},d.byteLength=B,d.prototype._isBuffer=!0,d.prototype.swap16=function(){const i=this.length;if(i%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let u=0;u<i;u+=2)j(this,u,u+1);return this},d.prototype.swap32=function(){const i=this.length;if(i%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let u=0;u<i;u+=4)j(this,u,u+3),j(this,u+1,u+2);return this},d.prototype.swap64=function(){const i=this.length;if(i%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let u=0;u<i;u+=8)j(this,u,u+7),j(this,u+1,u+6),j(this,u+2,u+5),j(this,u+3,u+4);return this},d.prototype.toString=function(){const i=this.length;return i===0?"":arguments.length===0?N(this,0,i):D.apply(this,arguments)},d.prototype.toLocaleString=d.prototype.toString,d.prototype.equals=function(i){if(!d.isBuffer(i))throw new TypeError("Argument must be a Buffer");return this===i||d.compare(this,i)===0},d.prototype.inspect=function(){let i="";const u=c.h2;return i=this.toString("hex",0,u).replace(/(.{2})/g,"$1 ").trim(),this.length>u&&(i+=" ... "),"<Buffer "+i+">"},_&&(d.prototype[_]=d.prototype.inspect),d.prototype.compare=function(i,u,f,g,y){if(pe(i,Uint8Array)&&(i=d.from(i,i.offset,i.byteLength)),!d.isBuffer(i))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof i);if(u===void 0&&(u=0),f===void 0&&(f=i?i.length:0),g===void 0&&(g=0),y===void 0&&(y=this.length),u<0||f>i.length||g<0||y>this.length)throw new RangeError("out of range index");if(g>=y&&u>=f)return 0;if(g>=y)return-1;if(u>=f)return 1;if(this===i)return 0;let o=(y>>>=0)-(g>>>=0),l=(f>>>=0)-(u>>>=0);const m=Math.min(o,l),A=this.slice(g,y),F=i.slice(u,f);for(let R=0;R<m;++R)if(A[R]!==F[R]){o=A[R],l=F[R];break}return o<l?-1:l<o?1:0},d.prototype.includes=function(i,u,f){return this.indexOf(i,u,f)!==-1},d.prototype.indexOf=function(i,u,f){return q(this,i,u,f,!0)},d.prototype.lastIndexOf=function(i,u,f){return q(this,i,u,f,!1)},d.prototype.write=function(i,u,f,g){if(u===void 0)g="utf8",f=this.length,u=0;else if(f===void 0&&typeof u=="string")g=u,f=this.length,u=0;else{if(!isFinite(u))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");u>>>=0,isFinite(f)?(f>>>=0,g===void 0&&(g="utf8")):(g=f,f=void 0)}const y=this.length-u;if((f===void 0||f>y)&&(f=y),i.length>0&&(f<0||u<0)||u>this.length)throw new RangeError("Attempt to write outside buffer bounds");g||(g="utf8");let o=!1;for(;;)switch(g){case"hex":return X(this,i,u,f);case"utf8":case"utf-8":return V(this,i,u,f);case"ascii":case"latin1":case"binary":return ae(this,i,u,f);case"base64":return ue(this,i,u,f);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return k(this,i,u,f);default:if(o)throw new TypeError("Unknown encoding: "+g);g=(""+g).toLowerCase(),o=!0}},d.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};const ce=4096;function hr(i,u,f){let g="";f=Math.min(i.length,f);for(let y=u;y<f;++y)g+=String.fromCharCode(127&i[y]);return g}function se(i,u,f){let g="";f=Math.min(i.length,f);for(let y=u;y<f;++y)g+=String.fromCharCode(i[y]);return g}function Ne(i,u,f){const g=i.length;(!u||u<0)&&(u=0),(!f||f<0||f>g)&&(f=g);let y="";for(let o=u;o<f;++o)y+=Qn[i[o]];return y}function xt(i,u,f){const g=i.slice(u,f);let y="";for(let o=0;o<g.length-1;o+=2)y+=String.fromCharCode(g[o]+256*g[o+1]);return y}function G(i,u,f){if(i%1!=0||i<0)throw new RangeError("offset is not uint");if(i+u>f)throw new RangeError("Trying to access beyond buffer length")}function H(i,u,f,g,y,o){if(!d.isBuffer(i))throw new TypeError('"buffer" argument must be a Buffer instance');if(u>y||u<o)throw new RangeError('"value" argument is out of bounds');if(f+g>i.length)throw new RangeError("Index out of range")}function dr(i,u,f,g,y){Mr(u,g,y,i,f,7);let o=Number(u&BigInt(4294967295));i[f++]=o,o>>=8,i[f++]=o,o>>=8,i[f++]=o,o>>=8,i[f++]=o;let l=Number(u>>BigInt(32)&BigInt(4294967295));return i[f++]=l,l>>=8,i[f++]=l,l>>=8,i[f++]=l,l>>=8,i[f++]=l,f}function Dr(i,u,f,g,y){Mr(u,g,y,i,f,7);let o=Number(u&BigInt(4294967295));i[f+7]=o,o>>=8,i[f+6]=o,o>>=8,i[f+5]=o,o>>=8,i[f+4]=o;let l=Number(u>>BigInt(32)&BigInt(4294967295));return i[f+3]=l,l>>=8,i[f+2]=l,l>>=8,i[f+1]=l,l>>=8,i[f]=l,f+8}function It(i,u,f,g,y,o){if(f+g>i.length)throw new RangeError("Index out of range");if(f<0)throw new RangeError("Index out of range")}function Nr(i,u,f,g,y){return u=+u,f>>>=0,y||It(i,0,f,4),v.write(i,u,f,g,23,4),f+4}function Tt(i,u,f,g,y){return u=+u,f>>>=0,y||It(i,0,f,8),v.write(i,u,f,g,52,8),f+8}d.prototype.slice=function(i,u){const f=this.length;(i=~~i)<0?(i+=f)<0&&(i=0):i>f&&(i=f),(u=u===void 0?f:~~u)<0?(u+=f)<0&&(u=0):u>f&&(u=f),u<i&&(u=i);const g=this.subarray(i,u);return Object.setPrototypeOf(g,d.prototype),g},d.prototype.readUintLE=d.prototype.readUIntLE=function(i,u,f){i>>>=0,u>>>=0,f||G(i,u,this.length);let g=this[i],y=1,o=0;for(;++o<u&&(y*=256);)g+=this[i+o]*y;return g},d.prototype.readUintBE=d.prototype.readUIntBE=function(i,u,f){i>>>=0,u>>>=0,f||G(i,u,this.length);let g=this[i+--u],y=1;for(;u>0&&(y*=256);)g+=this[i+--u]*y;return g},d.prototype.readUint8=d.prototype.readUInt8=function(i,u){return i>>>=0,u||G(i,1,this.length),this[i]},d.prototype.readUint16LE=d.prototype.readUInt16LE=function(i,u){return i>>>=0,u||G(i,2,this.length),this[i]|this[i+1]<<8},d.prototype.readUint16BE=d.prototype.readUInt16BE=function(i,u){return i>>>=0,u||G(i,2,this.length),this[i]<<8|this[i+1]},d.prototype.readUint32LE=d.prototype.readUInt32LE=function(i,u){return i>>>=0,u||G(i,4,this.length),(this[i]|this[i+1]<<8|this[i+2]<<16)+16777216*this[i+3]},d.prototype.readUint32BE=d.prototype.readUInt32BE=function(i,u){return i>>>=0,u||G(i,4,this.length),16777216*this[i]+(this[i+1]<<16|this[i+2]<<8|this[i+3])},d.prototype.readBigUInt64LE=he(function(i){Q(i>>>=0,"offset");const u=this[i],f=this[i+7];u!==void 0&&f!==void 0||$e(i,this.length-8);const g=u+256*this[++i]+65536*this[++i]+this[++i]*2**24,y=this[++i]+256*this[++i]+65536*this[++i]+f*2**24;return BigInt(g)+(BigInt(y)<<BigInt(32))}),d.prototype.readBigUInt64BE=he(function(i){Q(i>>>=0,"offset");const u=this[i],f=this[i+7];u!==void 0&&f!==void 0||$e(i,this.length-8);const g=u*2**24+65536*this[++i]+256*this[++i]+this[++i],y=this[++i]*2**24+65536*this[++i]+256*this[++i]+f;return(BigInt(g)<<BigInt(32))+BigInt(y)}),d.prototype.readIntLE=function(i,u,f){i>>>=0,u>>>=0,f||G(i,u,this.length);let g=this[i],y=1,o=0;for(;++o<u&&(y*=256);)g+=this[i+o]*y;return y*=128,g>=y&&(g-=Math.pow(2,8*u)),g},d.prototype.readIntBE=function(i,u,f){i>>>=0,u>>>=0,f||G(i,u,this.length);let g=u,y=1,o=this[i+--g];for(;g>0&&(y*=256);)o+=this[i+--g]*y;return y*=128,o>=y&&(o-=Math.pow(2,8*u)),o},d.prototype.readInt8=function(i,u){return i>>>=0,u||G(i,1,this.length),128&this[i]?-1*(255-this[i]+1):this[i]},d.prototype.readInt16LE=function(i,u){i>>>=0,u||G(i,2,this.length);const f=this[i]|this[i+1]<<8;return 32768&f?4294901760|f:f},d.prototype.readInt16BE=function(i,u){i>>>=0,u||G(i,2,this.length);const f=this[i+1]|this[i]<<8;return 32768&f?4294901760|f:f},d.prototype.readInt32LE=function(i,u){return i>>>=0,u||G(i,4,this.length),this[i]|this[i+1]<<8|this[i+2]<<16|this[i+3]<<24},d.prototype.readInt32BE=function(i,u){return i>>>=0,u||G(i,4,this.length),this[i]<<24|this[i+1]<<16|this[i+2]<<8|this[i+3]},d.prototype.readBigInt64LE=he(function(i){Q(i>>>=0,"offset");const u=this[i],f=this[i+7];u!==void 0&&f!==void 0||$e(i,this.length-8);const g=this[i+4]+256*this[i+5]+65536*this[i+6]+(f<<24);return(BigInt(g)<<BigInt(32))+BigInt(u+256*this[++i]+65536*this[++i]+this[++i]*16777216)}),d.prototype.readBigInt64BE=he(function(i){Q(i>>>=0,"offset");const u=this[i],f=this[i+7];u!==void 0&&f!==void 0||$e(i,this.length-8);const g=(u<<24)+65536*this[++i]+256*this[++i]+this[++i];return(BigInt(g)<<BigInt(32))+BigInt(this[++i]*16777216+65536*this[++i]+256*this[++i]+f)}),d.prototype.readFloatLE=function(i,u){return i>>>=0,u||G(i,4,this.length),v.read(this,i,!0,23,4)},d.prototype.readFloatBE=function(i,u){return i>>>=0,u||G(i,4,this.length),v.read(this,i,!1,23,4)},d.prototype.readDoubleLE=function(i,u){return i>>>=0,u||G(i,8,this.length),v.read(this,i,!0,52,8)},d.prototype.readDoubleBE=function(i,u){return i>>>=0,u||G(i,8,this.length),v.read(this,i,!1,52,8)},d.prototype.writeUintLE=d.prototype.writeUIntLE=function(i,u,f,g){i=+i,u>>>=0,f>>>=0,!g&&H(this,i,u,f,Math.pow(2,8*f)-1,0);let y=1,o=0;for(this[u]=255&i;++o<f&&(y*=256);)this[u+o]=i/y&255;return u+f},d.prototype.writeUintBE=d.prototype.writeUIntBE=function(i,u,f,g){i=+i,u>>>=0,f>>>=0,!g&&H(this,i,u,f,Math.pow(2,8*f)-1,0);let y=f-1,o=1;for(this[u+y]=255&i;--y>=0&&(o*=256);)this[u+y]=i/o&255;return u+f},d.prototype.writeUint8=d.prototype.writeUInt8=function(i,u,f){return i=+i,u>>>=0,f||H(this,i,u,1,255,0),this[u]=255&i,u+1},d.prototype.writeUint16LE=d.prototype.writeUInt16LE=function(i,u,f){return i=+i,u>>>=0,f||H(this,i,u,2,65535,0),this[u]=255&i,this[u+1]=i>>>8,u+2},d.prototype.writeUint16BE=d.prototype.writeUInt16BE=function(i,u,f){return i=+i,u>>>=0,f||H(this,i,u,2,65535,0),this[u]=i>>>8,this[u+1]=255&i,u+2},d.prototype.writeUint32LE=d.prototype.writeUInt32LE=function(i,u,f){return i=+i,u>>>=0,f||H(this,i,u,4,4294967295,0),this[u+3]=i>>>24,this[u+2]=i>>>16,this[u+1]=i>>>8,this[u]=255&i,u+4},d.prototype.writeUint32BE=d.prototype.writeUInt32BE=function(i,u,f){return i=+i,u>>>=0,f||H(this,i,u,4,4294967295,0),this[u]=i>>>24,this[u+1]=i>>>16,this[u+2]=i>>>8,this[u+3]=255&i,u+4},d.prototype.writeBigUInt64LE=he(function(i,u=0){return dr(this,i,u,BigInt(0),BigInt("0xffffffffffffffff"))}),d.prototype.writeBigUInt64BE=he(function(i,u=0){return Dr(this,i,u,BigInt(0),BigInt("0xffffffffffffffff"))}),d.prototype.writeIntLE=function(i,u,f,g){if(i=+i,u>>>=0,!g){const m=Math.pow(2,8*f-1);H(this,i,u,f,m-1,-m)}let y=0,o=1,l=0;for(this[u]=255&i;++y<f&&(o*=256);)i<0&&l===0&&this[u+y-1]!==0&&(l=1),this[u+y]=(i/o>>0)-l&255;return u+f},d.prototype.writeIntBE=function(i,u,f,g){if(i=+i,u>>>=0,!g){const m=Math.pow(2,8*f-1);H(this,i,u,f,m-1,-m)}let y=f-1,o=1,l=0;for(this[u+y]=255&i;--y>=0&&(o*=256);)i<0&&l===0&&this[u+y+1]!==0&&(l=1),this[u+y]=(i/o>>0)-l&255;return u+f},d.prototype.writeInt8=function(i,u,f){return i=+i,u>>>=0,f||H(this,i,u,1,127,-128),i<0&&(i=255+i+1),this[u]=255&i,u+1},d.prototype.writeInt16LE=function(i,u,f){return i=+i,u>>>=0,f||H(this,i,u,2,32767,-32768),this[u]=255&i,this[u+1]=i>>>8,u+2},d.prototype.writeInt16BE=function(i,u,f){return i=+i,u>>>=0,f||H(this,i,u,2,32767,-32768),this[u]=i>>>8,this[u+1]=255&i,u+2},d.prototype.writeInt32LE=function(i,u,f){return i=+i,u>>>=0,f||H(this,i,u,4,2147483647,-2147483648),this[u]=255&i,this[u+1]=i>>>8,this[u+2]=i>>>16,this[u+3]=i>>>24,u+4},d.prototype.writeInt32BE=function(i,u,f){return i=+i,u>>>=0,f||H(this,i,u,4,2147483647,-2147483648),i<0&&(i=4294967295+i+1),this[u]=i>>>24,this[u+1]=i>>>16,this[u+2]=i>>>8,this[u+3]=255&i,u+4},d.prototype.writeBigInt64LE=he(function(i,u=0){return dr(this,i,u,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),d.prototype.writeBigInt64BE=he(function(i,u=0){return Dr(this,i,u,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),d.prototype.writeFloatLE=function(i,u,f){return Nr(this,i,u,!0,f)},d.prototype.writeFloatBE=function(i,u,f){return Nr(this,i,u,!1,f)},d.prototype.writeDoubleLE=function(i,u,f){return Tt(this,i,u,!0,f)},d.prototype.writeDoubleBE=function(i,u,f){return Tt(this,i,u,!1,f)},d.prototype.copy=function(i,u,f,g){if(!d.isBuffer(i))throw new TypeError("argument should be a Buffer");if(f||(f=0),g||g===0||(g=this.length),u>=i.length&&(u=i.length),u||(u=0),g>0&&g<f&&(g=f),g===f||i.length===0||this.length===0)return 0;if(u<0)throw new RangeError("targetStart out of bounds");if(f<0||f>=this.length)throw new RangeError("Index out of range");if(g<0)throw new RangeError("sourceEnd out of bounds");g>this.length&&(g=this.length),i.length-u<g-f&&(g=i.length-u+f);const y=g-f;return this===i&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(u,f,g):Uint8Array.prototype.set.call(i,this.subarray(f,g),u),y},d.prototype.fill=function(i,u,f,g){if(typeof i=="string"){if(typeof u=="string"?(g=u,u=0,f=this.length):typeof f=="string"&&(g=f,f=this.length),g!==void 0&&typeof g!="string")throw new TypeError("encoding must be a string");if(typeof g=="string"&&!d.isEncoding(g))throw new TypeError("Unknown encoding: "+g);if(i.length===1){const o=i.charCodeAt(0);(g==="utf8"&&o<128||g==="latin1")&&(i=o)}}else typeof i=="number"?i&=255:typeof i=="boolean"&&(i=Number(i));if(u<0||this.length<u||this.length<f)throw new RangeError("Out of range index");if(f<=u)return this;let y;if(u>>>=0,f=f===void 0?this.length:f>>>0,i||(i=0),typeof i=="number")for(y=u;y<f;++y)this[y]=i;else{const o=d.isBuffer(i)?i:d.from(i,g),l=o.length;if(l===0)throw new TypeError('The value "'+i+'" is invalid for argument "value"');for(y=0;y<f-u;++y)this[y+u]=o[y%l]}return this};const Te={};function yr(i,u,f){Te[i]=class extends f{constructor(){super(),Object.defineProperty(this,"message",{value:u.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${i}]`,this.stack,delete this.name}get code(){return i}set code(g){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:g,writable:!0})}toString(){return`${this.name} [${i}]: ${this.message}`}}}function Lr(i){let u="",f=i.length;const g=i[0]==="-"?1:0;for(;f>=g+4;f-=3)u=`_${i.slice(f-3,f)}${u}`;return`${i.slice(0,f)}${u}`}function Mr(i,u,f,g,y,o){if(i>f||i<u){const l=typeof u=="bigint"?"n":"";let m;throw m=o>3?u===0||u===BigInt(0)?`>= 0${l} and < 2${l} ** ${8*(o+1)}${l}`:`>= -(2${l} ** ${8*(o+1)-1}${l}) and < 2 ** ${8*(o+1)-1}${l}`:`>= ${u}${l} and <= ${f}${l}`,new Te.ERR_OUT_OF_RANGE("value",m,i)}(function(l,m,A){Q(m,"offset"),l[m]!==void 0&&l[m+A]!==void 0||$e(m,l.length-(A+1))})(g,y,o)}function Q(i,u){if(typeof i!="number")throw new Te.ERR_INVALID_ARG_TYPE(u,"number",i)}function $e(i,u,f){throw Math.floor(i)!==i?(Q(i,f),new Te.ERR_OUT_OF_RANGE(f||"offset","an integer",i)):u<0?new Te.ERR_BUFFER_OUT_OF_BOUNDS:new Te.ERR_OUT_OF_RANGE(f||"offset",`>= ${f?1:0} and <= ${u}`,i)}yr("ERR_BUFFER_OUT_OF_BOUNDS",function(i){return i?`${i} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),yr("ERR_INVALID_ARG_TYPE",function(i,u){return`The "${i}" argument must be of type number. Received type ${typeof u}`},TypeError),yr("ERR_OUT_OF_RANGE",function(i,u,f){let g=`The value of "${i}" is out of range.`,y=f;return Number.isInteger(f)&&Math.abs(f)>4294967296?y=Lr(String(f)):typeof f=="bigint"&&(y=String(f),(f>BigInt(2)**BigInt(32)||f<-(BigInt(2)**BigInt(32)))&&(y=Lr(y)),y+="n"),g+=` It must be ${u}. Received ${y}`,g},RangeError);const te=/[^+/0-9A-Za-z-_]/g;function Le(i,u){let f;u=u||1/0;const g=i.length;let y=null;const o=[];for(let l=0;l<g;++l){if(f=i.charCodeAt(l),f>55295&&f<57344){if(!y){if(f>56319){(u-=3)>-1&&o.push(239,191,189);continue}if(l+1===g){(u-=3)>-1&&o.push(239,191,189);continue}y=f;continue}if(f<56320){(u-=3)>-1&&o.push(239,191,189),y=f;continue}f=65536+(y-55296<<10|f-56320)}else y&&(u-=3)>-1&&o.push(239,191,189);if(y=null,f<128){if((u-=1)<0)break;o.push(f)}else if(f<2048){if((u-=2)<0)break;o.push(f>>6|192,63&f|128)}else if(f<65536){if((u-=3)<0)break;o.push(f>>12|224,f>>6&63|128,63&f|128)}else{if(!(f<1114112))throw new Error("Invalid code point");if((u-=4)<0)break;o.push(f>>18|240,f>>12&63|128,f>>6&63|128,63&f|128)}}return o}function Ot(i){return h.toByteArray(function(u){if((u=(u=u.split("=")[0]).trim().replace(te,"")).length<2)return"";for(;u.length%4!=0;)u+="=";return u}(i))}function Oe(i,u,f,g){let y;for(y=0;y<g&&!(y+f>=u.length||y>=i.length);++y)u[y+f]=i[y];return y}function pe(i,u){return i instanceof u||i!=null&&i.constructor!=null&&i.constructor.name!=null&&i.constructor.name===u.name}function gr(i){return i!=i}const Qn=function(){const i="0123456789abcdef",u=new Array(256);for(let f=0;f<16;++f){const g=16*f;for(let y=0;y<16;++y)u[g+y]=i[f]+i[y]}return u}();function he(i){return typeof BigInt>"u"?Je:i}function Je(){throw new Error("BigInt not supported")}},645:(s,c)=>{c.read=function(p,h,v,_,w){var b,d,E=8*w-_-1,x=(1<<E)-1,I=x>>1,S=-7,T=v?w-1:0,P=v?-1:1,B=p[h+T];for(T+=P,b=B&(1<<-S)-1,B>>=-S,S+=E;S>0;b=256*b+p[h+T],T+=P,S-=8);for(d=b&(1<<-S)-1,b>>=-S,S+=_;S>0;d=256*d+p[h+T],T+=P,S-=8);if(b===0)b=1-I;else{if(b===x)return d?NaN:1/0*(B?-1:1);d+=Math.pow(2,_),b-=I}return(B?-1:1)*d*Math.pow(2,b-_)},c.write=function(p,h,v,_,w,b){var d,E,x,I=8*b-w-1,S=(1<<I)-1,T=S>>1,P=w===23?Math.pow(2,-24)-Math.pow(2,-77):0,B=_?0:b-1,D=_?1:-1,j=h<0||h===0&&1/h<0?1:0;for(h=Math.abs(h),isNaN(h)||h===1/0?(E=isNaN(h)?1:0,d=S):(d=Math.floor(Math.log(h)/Math.LN2),h*(x=Math.pow(2,-d))<1&&(d--,x*=2),(h+=d+T>=1?P/x:P*Math.pow(2,1-T))*x>=2&&(d++,x/=2),d+T>=S?(E=0,d=S):d+T>=1?(E=(h*x-1)*Math.pow(2,w),d+=T):(E=h*Math.pow(2,T-1)*Math.pow(2,w),d=0));w>=8;p[v+B]=255&E,B+=D,E/=256,w-=8);for(d=d<<w|E,I+=w;I>0;p[v+B]=255&d,B+=D,d/=256,I-=8);p[v+B-D]|=128*j}}},n={};function a(s){var c=n[s];if(c!==void 0)return c.exports;var p=n[s]={exports:{}};return t[s](p,p.exports,a),p.exports}return a.d=(s,c)=>{for(var p in c)a.o(c,p)&&!a.o(s,p)&&Object.defineProperty(s,p,{enumerable:!0,get:c[p]})},a.g=function(){if(typeof globalThis=="object")return globalThis;try{return this||new Function("return this")()}catch{if(typeof window=="object")return window}}(),a.o=(s,c)=>Object.prototype.hasOwnProperty.call(s,c),a.r=s=>{typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(s,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(s,"__esModule",{value:!0})},a(899)})())})(Va);function l1(e){const r={variantId:Ie.Uint64.fromString(e.variantId.toString()),version:e.version||Math.floor(Date.now()/1e3),items:e.items.map(n=>new Ie.BundleItem({collectionId:Ie.Uint64.fromString(n.collectionId.toString()),productId:Ie.Uint64.fromString(n.productId.toString()),variantId:Ie.Uint64.fromString(n.variantId.toString()),sku:n.sku||"",quantity:n.quantity,ext:new Ie.BundleItemExt(0)})),ext:new Ie.BundleExt(0)},t=new Ie.Bundle(r);return Ie.BundleEnvelope.envelopeTypeBundle(t).toXDR("base64")}const Ie=Va.exports.config(e=>{e.enum("EnvelopeType",{envelopeTypeBundle:0}),e.typedef("Uint32",e.uint()),e.typedef("Uint64",e.uhyper()),e.union("BundleItemExt",{switchOn:e.int(),switchName:"v",switches:[[0,e.void()]],arms:{}}),e.struct("BundleItem",[["collectionId",e.lookup("Uint64")],["productId",e.lookup("Uint64")],["variantId",e.lookup("Uint64")],["sku",e.string()],["quantity",e.lookup("Uint32")],["ext",e.lookup("BundleItemExt")]]),e.union("BundleExt",{switchOn:e.int(),switchName:"v",switches:[[0,e.void()]],arms:{}}),e.struct("Bundle",[["variantId",e.lookup("Uint64")],["items",e.varArray(e.lookup("BundleItem"),500)],["version",e.lookup("Uint32")],["ext",e.lookup("BundleExt")]]),e.union("BundleEnvelope",{switchOn:e.lookup("EnvelopeType"),switchName:"type",switches:[["envelopeTypeBundle","v1"]],arms:{v1:e.lookup("Bundle")}})}),Ha="/bundling-storefront-manager";function p1(){return Math.ceil(Date.now()/1e3)}async function h1(){try{const{timestamp:e}=await Or("get",`${Ha}/t`,{headers:{"X-Recharge-App":"storefront-client"}});return e}catch(e){return console.error(`Fetch failed: ${e}. Using client-side date.`),p1()}}async function d1(e){const r=be(),t=await Ya(e);if(t!==!0)throw new Error(t);const n=await h1(),a=l1({variantId:e.externalVariantId,version:n,items:e.selections.map(s=>({collectionId:s.collectionId,productId:s.externalProductId,variantId:s.externalVariantId,quantity:s.quantity,sku:""}))});try{const s=await Or("post",`${Ha}/api/v1/bundles`,{data:{bundle:a},headers:{Origin:`https://${r.storeIdentifier}`}});if(!s.id||s.code!==200)throw new Error(`1: failed generating rb_id: ${JSON.stringify(s)}`);return s.id}catch(s){throw new Error(`2: failed generating rb_id ${s}`)}}function y1(e,r){const t=Ka(e);if(t!==!0)throw new Error(`Dynamic Bundle is invalid. ${t}`);const n=`${Sl(9)}:${e.externalProductId}`;return e.selections.map(a=>{const s={id:a.externalVariantId,quantity:a.quantity,properties:{_rc_bundle:n,_rc_bundle_variant:e.externalVariantId,_rc_bundle_parent:r,_rc_bundle_collection_id:a.collectionId}};return a.sellingPlan?s.selling_plan=a.sellingPlan:a.shippingIntervalFrequency&&(s.properties.shipping_interval_frequency=a.shippingIntervalFrequency,s.properties.shipping_interval_unit_type=a.shippingIntervalUnitType,s.id=`${a.discountedVariantId}`),s})}async function Ya(e){try{return e?await qa(e.externalProductId)?!0:"Bundle settings do not exist for the given product":"Bundle is not defined"}catch(r){return`Error fetching bundle settings: ${r}`}}const g1={day:["day","days","Days"],days:["day","days","Days"],Days:["day","days","Days"],week:["week","weeks","Weeks"],weeks:["week","weeks","Weeks"],Weeks:["week","weeks","Weeks"],month:["month","months","Months"],months:["month","months","Months"],Months:["month","months","Months"]};function Ka(e){if(!e)return"No bundle defined.";if(e.selections.length===0)return"No selections defined.";const{shippingIntervalFrequency:r,shippingIntervalUnitType:t}=e.selections.find(n=>n.shippingIntervalFrequency||n.shippingIntervalUnitType)||{};if(r||t){if(!r||!t)return"Shipping intervals do not match on selections.";{const n=g1[t];for(let a=0;a<e.selections.length;a++){const{shippingIntervalFrequency:s,shippingIntervalUnitType:c}=e.selections[a];if(s&&s!==r||c&&!n.includes(c))return"Shipping intervals do not match on selections."}}}return!0}async function v1(e,r){const{bundle_selection:t}=await O("get","/bundle_selections",{id:r},e);return t}function m1(e,r){return O("get","/bundle_selections",{query:r},e)}async function _1(e,r){const{bundle_selection:t}=await O("post","/bundle_selections",{data:r},e);return t}async function w1(e,r,t){const{bundle_selection:n}=await O("put","/bundle_selections",{id:r,data:t},e);return n}function b1(e,r){return O("delete","/bundle_selections",{id:r},e)}async function $1(e,r,t){const{subscription:n}=await O("put","/bundles",{id:r,data:t},e);return n}var A1=Object.freeze({__proto__:null,getBundleId:d1,getDynamicBundleItems:y1,validateBundle:Ya,validateDynamicBundle:Ka,getBundleSelection:v1,listBundleSelections:m1,createBundleSelection:_1,updateBundleSelection:w1,deleteBundleSelection:b1,updateBundle:$1});async function E1(e,r,t){const{charge:n}=await O("get","/charges",{id:r,query:{include:t?.include}},e);return n}function S1(e,r){return O("get","/charges",{query:r},e)}async function x1(e,r,t){const{charge:n}=await O("post",`/charges/${r}/apply_discount`,{data:{discount_code:t}},e);return n}async function I1(e,r){const{charge:t}=await O("post",`/charges/${r}/remove_discount`,{},e);return t}async function T1(e,r,t){const{charge:n}=await O("post",`/charges/${r}/skip`,{data:{purchase_item_ids:t.map(a=>Number(a))}},e);return n}async function O1(e,r,t){const{charge:n}=await O("post",`/charges/${r}/unskip`,{data:{purchase_item_ids:t.map(a=>Number(a))}},e);return n}async function B1(e,r){const{charge:t}=await O("post",`/charges/${r}/process`,{},e);return t}var P1=Object.freeze({__proto__:null,getCharge:E1,listCharges:S1,applyDiscountToCharge:x1,removeDiscountsFromCharge:I1,skipCharge:T1,unskipCharge:O1,processCharge:B1});async function R1(e,r){const{membership:t}=await O("get","/memberships",{id:r},e);return t}function F1(e,r){return O("get","/memberships",{query:r},e)}async function C1(e,r,t){const{membership:n}=await O("post",`/memberships/${r}/cancel`,{data:t},e);return n}async function U1(e,r,t){const{membership:n}=await O("post",`/memberships/${r}/activate`,{data:t},e);return n}async function D1(e,r,t){const{membership:n}=await O("post",`/memberships/${r}/change`,{data:t},e);return n}var N1=Object.freeze({__proto__:null,getMembership:R1,listMemberships:F1,cancelMembership:C1,activateMembership:U1,changeMembership:D1});async function L1(e,r,t){const{membership_program:n}=await O("get","/membership_programs",{id:r,query:{include:t?.include}},e);return n}function M1(e,r){return O("get","/membership_programs",{query:r},e)}var j1=Object.freeze({__proto__:null,getMembershipProgram:L1,listMembershipPrograms:M1});async function k1(e,r){const{metafield:t}=await O("post","/metafields",{data:{metafield:r}},e);return t}async function G1(e,r,t){const{metafield:n}=await O("put","/metafields",{id:r,data:{metafield:t}},e);return n}function W1(e,r){return O("delete","/metafields",{id:r},e)}var q1=Object.freeze({__proto__:null,createMetafield:k1,updateMetafield:G1,deleteMetafield:W1});async function z1(e,r){const{onetime:t}=await O("get","/onetimes",{id:r},e);return t}function V1(e,r){return O("get","/onetimes",{query:r},e)}async function H1(e,r){const{onetime:t}=await O("post","/onetimes",{data:r},e);return t}async function Y1(e,r,t){const{onetime:n}=await O("put","/onetimes",{id:r,data:t},e);return n}function K1(e,r){return O("delete","/onetimes",{id:r},e)}var X1=Object.freeze({__proto__:null,getOnetime:z1,listOnetimes:V1,createOnetime:H1,updateOnetime:Y1,deleteOnetime:K1});async function J1(e,r){const{order:t}=await O("get","/orders",{id:r},e);return t}function Q1(e,r){return O("get","/orders",{query:r},e)}var Z1=Object.freeze({__proto__:null,getOrder:J1,listOrders:Q1});async function eb(e,r,t){const{payment_method:n}=await O("get","/payment_methods",{id:r,query:{include:t?.include}},e);return n}async function rb(e,r,t){const{payment_method:n}=await O("put","/payment_methods",{id:r,data:t},e);return n}function tb(e,r){return O("get","/payment_methods",{query:r},e)}var nb=Object.freeze({__proto__:null,getPaymentMethod:eb,updatePaymentMethod:rb,listPaymentMethods:tb});async function ib(e,r){const{plan:t}=await O("get","/plans",{id:r},e);return t}function ob(e,r){return O("get","/plans",{query:r},e)}var ab=Object.freeze({__proto__:null,getPlan:ib,listPlans:ob}),sb=jn,ub=Oa,cb=kn;function fb(e,r){return cb(ub(e,r,sb),e+"")}var lb=fb,Xa=Zo,pb=Xa&&new Xa,Ja=pb,hb=jn,Qa=Ja,db=Qa?function(e,r){return Qa.set(e,r),e}:hb,Za=db,yb=gt,gb=Ye;function vb(e){return function(){var r=arguments;switch(r.length){case 0:return new e;case 1:return new e(r[0]);case 2:return new e(r[0],r[1]);case 3:return new e(r[0],r[1],r[2]);case 4:return new e(r[0],r[1],r[2],r[3]);case 5:return new e(r[0],r[1],r[2],r[3],r[4]);case 6:return new e(r[0],r[1],r[2],r[3],r[4],r[5]);case 7:return new e(r[0],r[1],r[2],r[3],r[4],r[5],r[6])}var t=yb(e.prototype),n=e.apply(t,r);return gb(n)?n:t}}var bt=vb,mb=bt,_b=oe,wb=1;function bb(e,r,t){var n=r&wb,a=mb(e);function s(){var c=this&&this!==_b&&this instanceof s?a:e;return c.apply(n?t:this,arguments)}return s}var $b=bb,Ab=Math.max;function Eb(e,r,t,n){for(var a=-1,s=e.length,c=t.length,p=-1,h=r.length,v=Ab(s-c,0),_=Array(h+v),w=!n;++p<h;)_[p]=r[p];for(;++a<c;)(w||a<s)&&(_[t[a]]=e[a]);for(;v--;)_[p++]=e[a++];return _}var es=Eb,Sb=Math.max;function xb(e,r,t,n){for(var a=-1,s=e.length,c=-1,p=t.length,h=-1,v=r.length,_=Sb(s-p,0),w=Array(_+v),b=!n;++a<_;)w[a]=e[a];for(var d=a;++h<v;)w[d+h]=r[h];for(;++c<p;)(b||a<s)&&(w[d+t[c]]=e[a++]);return w}var rs=xb;function Ib(e,r){for(var t=e.length,n=0;t--;)e[t]===r&&++n;return n}var Tb=Ib;function Ob(){}var qn=Ob,Bb=gt,Pb=qn,Rb=4294967295;function $t(e){this.__wrapped__=e,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=Rb,this.__views__=[]}$t.prototype=Bb(Pb.prototype),$t.prototype.constructor=$t;var zn=$t;function Fb(){}var Cb=Fb,ts=Ja,Ub=Cb,Db=ts?function(e){return ts.get(e)}:Ub,ns=Db,Nb={},Lb=Nb,is=Lb,Mb=Object.prototype,jb=Mb.hasOwnProperty;function kb(e){for(var r=e.name+"",t=is[r],n=jb.call(is,r)?t.length:0;n--;){var a=t[n],s=a.func;if(s==null||s==e)return a.name}return r}var Gb=kb,Wb=gt,qb=qn;function At(e,r){this.__wrapped__=e,this.__actions__=[],this.__chain__=!!r,this.__index__=0,this.__values__=void 0}At.prototype=Wb(qb.prototype),At.prototype.constructor=At;var os=At,zb=zn,Vb=os,Hb=xn;function Yb(e){if(e instanceof zb)return e.clone();var r=new Vb(e.__wrapped__,e.__chain__);return r.__actions__=Hb(e.__actions__),r.__index__=e.__index__,r.__values__=e.__values__,r}var Kb=Yb,Xb=zn,as=os,Jb=qn,Qb=De,Zb=Ue,e$=Kb,r$=Object.prototype,t$=r$.hasOwnProperty;function Et(e){if(Zb(e)&&!Qb(e)&&!(e instanceof Xb)){if(e instanceof as)return e;if(t$.call(e,"__wrapped__"))return e$(e)}return new as(e)}Et.prototype=Jb.prototype,Et.prototype.constructor=Et;var n$=Et,i$=zn,o$=ns,a$=Gb,s$=n$;function u$(e){var r=a$(e),t=s$[r];if(typeof t!="function"||!(r in i$.prototype))return!1;if(e===t)return!0;var n=o$(t);return!!n&&e===n[0]}var c$=u$,f$=Za,l$=Pa,p$=l$(f$),ss=p$,h$=/\{\n\/\* \[wrapped with (.+)\] \*/,d$=/,? & /;function y$(e){var r=e.match(h$);return r?r[1].split(d$):[]}var g$=y$,v$=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/;function m$(e,r){var t=r.length;if(!t)return e;var n=t-1;return r[n]=(t>1?"& ":"")+r[n],r=r.join(t>2?", ":" "),e.replace(v$,`{
21
21
  /* [wrapped with `+r+`] */
22
22
  `)}var _$=m$;function w$(e,r,t,n){for(var a=e.length,s=t+(n?1:-1);n?s--:++s<a;)if(r(e[s],s,e))return s;return-1}var b$=w$;function $$(e){return e!==e}var A$=$$;function E$(e,r,t){for(var n=t-1,a=e.length;++n<a;)if(e[n]===r)return n;return-1}var S$=E$,x$=b$,I$=A$,T$=S$;function O$(e,r,t){return r===r?T$(e,r,t):x$(e,I$,t)}var B$=O$,P$=B$;function R$(e,r){var t=e==null?0:e.length;return!!t&&P$(e,r,0)>-1}var F$=R$,C$=Fo,U$=F$,D$=1,N$=2,L$=8,M$=16,j$=32,k$=64,G$=128,W$=256,q$=512,z$=[["ary",G$],["bind",D$],["bindKey",N$],["curry",L$],["curryRight",M$],["flip",q$],["partial",j$],["partialRight",k$],["rearg",W$]];function V$(e,r){return C$(z$,function(t){var n="_."+t[0];r&t[1]&&!U$(e,n)&&e.push(n)}),e.sort()}var H$=V$,Y$=g$,K$=_$,X$=kn,J$=H$;function Q$(e,r,t){var n=r+"";return X$(e,K$(n,J$(Y$(n),t)))}var us=Q$,Z$=c$,eA=ss,rA=us,tA=1,nA=2,iA=4,oA=8,cs=32,fs=64;function aA(e,r,t,n,a,s,c,p,h,v){var _=r&oA,w=_?c:void 0,b=_?void 0:c,d=_?s:void 0,E=_?void 0:s;r|=_?cs:fs,r&=~(_?fs:cs),r&iA||(r&=~(tA|nA));var x=[e,r,a,d,w,E,b,p,h,v],I=t.apply(void 0,x);return Z$(e)&&eA(I,x),I.placeholder=n,rA(I,e,r)}var ls=aA;function sA(e){var r=e;return r.placeholder}var Vn=sA,uA=xn,cA=ko,fA=Math.min;function lA(e,r){for(var t=e.length,n=fA(r.length,t),a=uA(e);n--;){var s=r[n];e[n]=cA(s,t)?a[s]:void 0}return e}var pA=lA,ps="__lodash_placeholder__";function hA(e,r){for(var t=-1,n=e.length,a=0,s=[];++t<n;){var c=e[t];(c===r||c===ps)&&(e[t]=ps,s[a++]=t)}return s}var St=hA,dA=es,yA=rs,gA=Tb,hs=bt,vA=ls,mA=Vn,_A=pA,wA=St,bA=oe,$A=1,AA=2,EA=8,SA=16,xA=128,IA=512;function ds(e,r,t,n,a,s,c,p,h,v){var _=r&xA,w=r&$A,b=r&AA,d=r&(EA|SA),E=r&IA,x=b?void 0:hs(e);function I(){for(var S=arguments.length,T=Array(S),P=S;P--;)T[P]=arguments[P];if(d)var B=mA(I),D=gA(T,B);if(n&&(T=dA(T,n,a,d)),s&&(T=yA(T,s,c,d)),S-=D,d&&S<v){var j=wA(T,B);return vA(e,r,ds,I.placeholder,t,T,j,p,h,v-S)}var q=w?t:this,z=b?q[e]:e;return S=T.length,p?T=_A(T,p):E&&S>1&&T.reverse(),_&&h<S&&(T.length=h),this&&this!==bA&&this instanceof I&&(z=x||hs(z)),z.apply(q,T)}return I}var ys=ds,TA=Mn,OA=bt,BA=ys,PA=ls,RA=Vn,FA=St,CA=oe;function UA(e,r,t){var n=OA(e);function a(){for(var s=arguments.length,c=Array(s),p=s,h=RA(a);p--;)c[p]=arguments[p];var v=s<3&&c[0]!==h&&c[s-1]!==h?[]:FA(c,h);if(s-=v.length,s<t)return PA(e,r,BA,a.placeholder,void 0,c,v,void 0,void 0,t-s);var _=this&&this!==CA&&this instanceof a?n:e;return TA(_,this,c)}return a}var DA=UA,NA=Mn,LA=bt,MA=oe,jA=1;function kA(e,r,t,n){var a=r&jA,s=LA(e);function c(){for(var p=-1,h=arguments.length,v=-1,_=n.length,w=Array(_+h),b=this&&this!==MA&&this instanceof c?s:e;++v<_;)w[v]=n[v];for(;h--;)w[v++]=arguments[++p];return NA(b,a?t:this,w)}return c}var GA=kA,WA=es,qA=rs,gs=St,vs="__lodash_placeholder__",Hn=1,zA=2,VA=4,ms=8,Ur=128,_s=256,HA=Math.min;function YA(e,r){var t=e[1],n=r[1],a=t|n,s=a<(Hn|zA|Ur),c=n==Ur&&t==ms||n==Ur&&t==_s&&e[7].length<=r[8]||n==(Ur|_s)&&r[7].length<=r[8]&&t==ms;if(!(s||c))return e;n&Hn&&(e[2]=r[2],a|=t&Hn?0:VA);var p=r[3];if(p){var h=e[3];e[3]=h?WA(h,p,r[4]):p,e[4]=h?gs(e[3],vs):r[4]}return p=r[5],p&&(h=e[5],e[5]=h?qA(h,p,r[6]):p,e[6]=h?gs(e[5],vs):r[6]),p=r[7],p&&(e[7]=p),n&Ur&&(e[8]=e[8]==null?r[8]:HA(e[8],r[8])),e[9]==null&&(e[9]=r[9]),e[0]=r[0],e[1]=a,e}var KA=YA,XA=/\s/;function JA(e){for(var r=e.length;r--&&XA.test(e.charAt(r)););return r}var QA=JA,ZA=QA,e2=/^\s+/;function r2(e){return e&&e.slice(0,ZA(e)+1).replace(e2,"")}var t2=r2,n2=t2,ws=Ye,i2=mt,bs=0/0,o2=/^[-+]0x[0-9a-f]+$/i,a2=/^0b[01]+$/i,s2=/^0o[0-7]+$/i,u2=parseInt;function c2(e){if(typeof e=="number")return e;if(i2(e))return bs;if(ws(e)){var r=typeof e.valueOf=="function"?e.valueOf():e;e=ws(r)?r+"":r}if(typeof e!="string")return e===0?e:+e;e=n2(e);var t=a2.test(e);return t||s2.test(e)?u2(e.slice(2),t?2:8):o2.test(e)?bs:+e}var f2=c2,l2=f2,$s=1/0,p2=17976931348623157e292;function h2(e){if(!e)return e===0?e:0;if(e=l2(e),e===$s||e===-$s){var r=e<0?-1:1;return r*p2}return e===e?e:0}var d2=h2,y2=d2;function g2(e){var r=y2(e),t=r%1;return r===r?t?r-t:r:0}var v2=g2,m2=Za,_2=$b,w2=DA,b2=ys,$2=GA,A2=ns,E2=KA,S2=ss,x2=us,As=v2,I2="Expected a function",Es=1,T2=2,Yn=8,Kn=16,Xn=32,Ss=64,xs=Math.max;function O2(e,r,t,n,a,s,c,p){var h=r&T2;if(!h&&typeof e!="function")throw new TypeError(I2);var v=n?n.length:0;if(v||(r&=~(Xn|Ss),n=a=void 0),c=c===void 0?c:xs(As(c),0),p=p===void 0?p:As(p),v-=a?a.length:0,r&Ss){var _=n,w=a;n=a=void 0}var b=h?void 0:A2(e),d=[e,r,t,n,a,_,w,s,c,p];if(b&&E2(d,b),e=d[0],r=d[1],t=d[2],n=d[3],a=d[4],p=d[9]=d[9]===void 0?h?0:e.length:xs(d[9]-v,0),!p&&r&(Yn|Kn)&&(r&=~(Yn|Kn)),!r||r==Es)var E=_2(e,r,t);else r==Yn||r==Kn?E=w2(e,r,p):(r==Xn||r==(Es|Xn))&&!a.length?E=$2(e,r,t,n):E=b2.apply(void 0,d);var x=b?m2:S2;return x2(x(E,d),e,r)}var B2=O2,P2=lb,R2=B2,F2=Vn,C2=St,U2=32,Jn=P2(function(e,r){var t=C2(r,F2(Jn));return R2(e,U2,void 0,r,t)});Jn.placeholder={};var Is=Jn,D2=Object.defineProperty,N2=Object.defineProperties,L2=Object.getOwnPropertyDescriptors,Ts=Object.getOwnPropertySymbols,M2=Object.prototype.hasOwnProperty,j2=Object.prototype.propertyIsEnumerable,Os=(e,r,t)=>r in e?D2(e,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[r]=t,Bs=(e,r)=>{for(var t in r||(r={}))M2.call(r,t)&&Os(e,t,r[t]);if(Ts)for(var t of Ts(r))j2.call(r,t)&&Os(e,t,r[t]);return e},Ps=(e,r)=>N2(e,L2(r));function k2(e,r){return Ps(Bs({},Gn(r,["address_id","external_variant_id","external_product_id","charge_interval_frequency","order_interval_frequency","price","status"])),{customer_id:parseInt(e,10),shopify_variant_id:r.external_variant_id.ecommerce?parseInt(r.external_variant_id.ecommerce,10):void 0,charge_interval_frequency:`${r.charge_interval_frequency}`,order_interval_frequency:`${r.order_interval_frequency}`,status:r.status?r.status.toUpperCase():void 0})}function G2(e,r){var t;return Ps(Bs({},Gn(r,["external_variant_id","external_product_id","charge_interval_frequency","order_interval_frequency","price","use_external_variant_defaults"])),{shopify_variant_id:(t=r.external_variant_id)!=null&&t.ecommerce?parseInt(r.external_variant_id.ecommerce,10):void 0,charge_interval_frequency:r.charge_interval_frequency?`${r.charge_interval_frequency}`:void 0,order_interval_frequency:r.order_interval_frequency?`${r.order_interval_frequency}`:void 0,force_update:e})}function Rs(e){const{id:r,address_id:t,customer_id:n,analytics_data:a,cancellation_reason:s,cancellation_reason_comments:c,cancelled_at:p,charge_interval_frequency:h,created_at:v,expire_after_specific_number_of_charges:_,shopify_product_id:w,shopify_variant_id:b,has_queued_charges:d,is_prepaid:E,is_skippable:x,is_swappable:I,max_retries_reached:S,next_charge_scheduled_at:T,order_day_of_month:P,order_day_of_week:B,order_interval_frequency:D,order_interval_unit:j,presentment_currency:q,price:z,product_title:X,properties:V,quantity:ae,sku:ue,sku_override:k,status:re,updated_at:N,variant_title:ce}=e;return{id:r,address_id:t,customer_id:n,analytics_data:a,cancellation_reason:s,cancellation_reason_comments:c,cancelled_at:p,charge_interval_frequency:parseInt(h,10),created_at:v,expire_after_specific_number_of_charges:_,external_product_id:{ecommerce:`${w}`},external_variant_id:{ecommerce:`${b}`},has_queued_charges:Ca(d),is_prepaid:E,is_skippable:x,is_swappable:I,max_retries_reached:Ca(S),next_charge_scheduled_at:T,order_day_of_month:P,order_day_of_week:B,order_interval_frequency:parseInt(D,10),order_interval_unit:j,presentment_currency:q,price:`${z}`,product_title:X??"",properties:V,quantity:ae,sku:ue,sku_override:k,status:re.toLowerCase(),updated_at:N,variant_title:ce}}async function W2(e,r,t){const{subscription:n}=await O("get","/subscriptions",{id:r,query:{include:t?.include}},e);return n}function q2(e,r){return O("get","/subscriptions",{query:r},e)}async function z2(e,r,t){const{subscription:n}=await O("post","/subscriptions",{data:r,query:t},e);return n}async function V2(e,r,t,n){const{subscription:a}=await O("put","/subscriptions",{id:r,data:t,query:n},e);return a}async function H2(e,r,t,n){const{subscription:a}=await O("post",`/subscriptions/${r}/set_next_charge_date`,{data:{date:t},query:n},e);return a}async function Y2(e,r,t){const{subscription:n}=await O("post",`/subscriptions/${r}/change_address`,{data:{address_id:t}},e);return n}async function K2(e,r,t,n){const{subscription:a}=await O("post",`/subscriptions/${r}/cancel`,{data:t,query:n},e);return a}async function X2(e,r,t){const{subscription:n}=await O("post",`/subscriptions/${r}/activate`,{query:t},e);return n}async function J2(e,r,t){const{charge:n}=await O("post",`/subscriptions/${r}/charges/skip`,{data:{date:t,subscription_id:`${r}`}},e);return n}async function Q2(e,r,t){const{onetimes:n}=await O("post","/purchase_items/skip_gift",{data:{purchase_item_ids:r.map(Number),recipient_address:t}},e);return n}async function Z2(e,r){const t=r.length;if(t<1||t>21)throw new Error("Number of subscriptions must be between 1 and 20.");const{customerId:n}=e;if(!n)throw new Error("No customerId in session.");const a=r[0].address_id;if(!r.every(h=>h.address_id===a))throw new Error("All subscriptions must have the same address_id.");const s=Is(k2,n),c=r.map(s),{subscriptions:p}=await O("post",`/addresses/${a}/subscriptions-bulk`,{data:{subscriptions:c},headers:{"X-Recharge-Version":"2021-01"}},e);return p.map(Rs)}async function eE(e,r,t,n){const a=t.length;if(a<1||a>21)throw new Error("Number of subscriptions must be between 1 and 20.");const{customerId:s}=e;if(!s)throw new Error("No customerId in session.");const c=Is(G2,!!(n!=null&&n.force_update)),p=t.map(c),{subscriptions:h}=await O("put",`/addresses/${r}/subscriptions-bulk`,{data:{subscriptions:p},headers:{"X-Recharge-Version":"2021-01"}},e);return h.map(Rs)}var rE=Object.freeze({__proto__:null,getSubscription:W2,listSubscriptions:q2,createSubscription:z2,updateSubscription:V2,updateSubscriptionChargeDate:H2,updateSubscriptionAddress:Y2,cancelSubscription:K2,activateSubscription:X2,skipSubscriptionCharge:J2,skipGiftSubscriptionCharge:Q2,createSubscriptions:Z2,updateSubscriptions:eE});async function tE(e,r){const t=e.customerId;if(!t)throw new Error("Not logged in.");const{customer:n}=await O("get","/customers",{id:t,query:{include:r?.include}},e);return n}async function nE(e,r){const t=e.customerId;if(!t)throw new Error("Not logged in.");const{customer:n}=await O("put","/customers",{id:t,data:r},e);return n}async function iE(e,r){const t=e.customerId;if(!t)throw new Error("Not logged in.");const{deliveries:n}=await O("get",`/customers/${t}/delivery_schedule`,{query:r},e);return n}async function oE(e){return await O("get","/portal_access",{},e)}var aE=Object.freeze({__proto__:null,getCustomer:tE,updateCustomer:nE,getDeliverySchedule:iE,getCustomerPortalAccess:oE});const sE={get(e,r){return le("get",e,r)},post(e,r){return le("post",e,r)},put(e,r){return le("put",e,r)},delete(e,r){return le("delete",e,r)}};function uE(e){var r,t;if(e)return e;if((r=window?.Shopify)!=null&&r.shop)return window.Shopify.shop;let n=window?.domain;if(!n){const a=(t=location?.href.match(/(?:http[s]*:\/\/)*(.*?)\.(?=admin\.rechargeapps\.com)/i))==null?void 0:t[1].replace(/-sp$/,"");a&&(n=`${a}.myshopify.com`)}if(n)return n;throw new Error("No storeIdentifier was passed into init.")}function cE(e={}){const r=e,{storefrontAccessToken:t}=e;if(t&&!t.startsWith("strfnt"))throw new Error("Incorrect storefront access token used. See https://storefront.rechargepayments.com/client/docs/getting_started/package_setup/#initialization-- for more information.");Wf({storeIdentifier:uE(e.storeIdentifier),loginRetryFn:e.loginRetryFn,storefrontAccessToken:t,environment:r.environment?r.environment:"prod"}),za()}const Fs={init:cE,api:sE,address:pl,auth:El,bundle:A1,charge:P1,cdn:f1,customer:aE,membership:N1,membershipProgram:j1,metafield:q1,onetime:X1,order:Z1,paymentMethod:nb,plan:ab,subscription:rE};try{Fs.init()}catch{}return Fs});
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@rechargeapps/storefront-client",
3
3
  "description": "Storefront client for Recharge",
4
- "version": "1.5.0",
4
+ "version": "1.6.0",
5
5
  "author": "Recharge Inc.",
6
6
  "license": "MIT",
7
7
  "main": "dist/cjs/index.js",