@rechargeapps/storefront-client 1.38.0 → 1.39.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.
@@ -181,7 +181,7 @@ async function rechargeAdminRequest(method, url, { id, query, data, headers } =
181
181
  ...storefrontAccessToken ? { "X-Recharge-Storefront-Access-Token": storefrontAccessToken } : {},
182
182
  ...appName ? { "X-Recharge-Sdk-App-Name": appName } : {},
183
183
  ...appVersion ? { "X-Recharge-Sdk-App-Version": appVersion } : {},
184
- "X-Recharge-Sdk-Version": "1.38.0",
184
+ "X-Recharge-Sdk-Version": "1.39.0",
185
185
  ...headers ? headers : {}
186
186
  };
187
187
  return request.request(method, `${rechargeBaseUrl}${url}`, { id, query, data, headers: reqHeaders });
@@ -135,6 +135,9 @@ async function validateBundle(bundle) {
135
135
  if (!bundle) {
136
136
  return "Bundle is not defined";
137
137
  }
138
+ if (bundle.selections.length === 0) {
139
+ return "No selections defined";
140
+ }
138
141
  return true;
139
142
  } catch (e) {
140
143
  return `Error fetching bundle settings: ${e}`;
@@ -1 +1 @@
1
- {"version":3,"file":"bundle.js","sources":["../../../src/api/bundle.ts"],"sourcesContent":["import { nanoid } from 'nanoid/non-secure';\nimport {\n BundleAppProxy,\n DynamicBundleItemAppProxy,\n BundleSelection,\n BundleSelectionListParams,\n BundleSelectionsResponse,\n CreateBundleSelectionRequest,\n InternalSession,\n Session,\n UpdateBundleSelectionRequest,\n UpdateBundlePurchaseItem,\n BundlePurchaseItem,\n BundlePurchaseItemParams,\n BundleData,\n} from '../types';\nimport { getInternalSession, rechargeApiRequest, shopifyAppProxyRequest } from '../utils/request';\nimport { getOptions } from '../utils/options';\nimport { BundleSelectionValidator, toLineItemProperty } from '../utils/bundle';\n\nconst STORE_FRONT_MANAGER_URL = '/bundling-storefront-manager';\n\nfunction getTimestampSecondsFromClient(): number {\n /**\n * Get the current unix epoch in seconds from the client-side.\n */\n return Math.ceil(Date.now() / 1000);\n}\n\nasync function getTimestampSecondsFromServer(): Promise<number> {\n /**\n * Get the unix epoch from the server instead of using it directly from the\n * client. This must reduce even more the number of invalid Bundles.\n */\n try {\n const { timestamp } = await shopifyAppProxyRequest<{ timestamp: number }>('get', `${STORE_FRONT_MANAGER_URL}/t`);\n return timestamp;\n } catch (ex) {\n console.error(`Fetch failed: ${ex}. Using client-side date.`);\n return getTimestampSecondsFromClient();\n }\n}\n\nasync function getTimestampSecondsFromServerApi(internalSession: InternalSession): Promise<number> {\n /**\n * Same as getTimestampSecondsFromServer, but using the recharge API server instead of the storefront manager.\n * This is done to bypass origin validation and expose this endpoint to headless storefronts.\n */\n try {\n const { timestamp } = await rechargeApiRequest<{ timestamp: number }>(\n 'get',\n `/bundle_selections/timestamp`,\n {},\n internalSession\n );\n return timestamp;\n } catch (ex) {\n console.error(`Fetch failed: ${ex}. Using client-side date.`);\n return getTimestampSecondsFromClient();\n }\n}\n\nfunction createBundleData(bundle: BundleAppProxy, timestampSeconds: number) {\n return toLineItemProperty({\n variantId: bundle.externalVariantId,\n version: timestampSeconds,\n items: bundle.selections.map(item => {\n return {\n collectionId: item.collectionId,\n productId: item.externalProductId,\n variantId: item.externalVariantId,\n quantity: item.quantity,\n sku: '',\n };\n }),\n });\n}\n\nexport async function getBundleId(bundle: BundleAppProxy): Promise<string> {\n const opts = getOptions();\n const isValid = await validateBundle(bundle);\n if (isValid !== true) {\n throw new Error(isValid);\n }\n const timestampSeconds = await getTimestampSecondsFromServer();\n const bundleData = createBundleData(bundle, timestampSeconds);\n\n try {\n const payload = await shopifyAppProxyRequest<{ id: string; code: number; message: string }>(\n 'post',\n `${STORE_FRONT_MANAGER_URL}/api/v1/bundles`,\n {\n data: {\n bundle: bundleData,\n },\n headers: {\n Origin: `https://${opts.storeIdentifier}`,\n },\n }\n );\n\n if (!payload.id || payload.code !== 200) {\n throw new Error(`1: failed generating rb_id: ${JSON.stringify(payload)}`);\n }\n\n return payload.id;\n } catch (e) {\n // Handle NetworkError exceptions\n throw new Error(`2: failed generating rb_id ${e}`);\n }\n}\n\nexport async function getBundleSelectionId(session: Session, bundle: BundleAppProxy): Promise<string> {\n const isValid = await validateBundle(bundle);\n if (isValid !== true) {\n throw new Error(isValid);\n }\n const internalSession = getInternalSession(session, 'getBundleSelectionId');\n const timestampSeconds = await getTimestampSecondsFromServerApi(internalSession);\n const bundleData = createBundleData(bundle, timestampSeconds);\n\n try {\n const payload = await rechargeApiRequest<{ id: string; code: number; message: string }>(\n 'post',\n `/bundle_selections/bundle_id`,\n {\n data: {\n bundle: bundleData,\n },\n },\n internalSession\n );\n\n if (!payload.id || payload.code !== 200) {\n throw new Error(`1: failed generating rb_id: ${JSON.stringify(payload)}`);\n }\n\n return payload.id;\n } catch (e) {\n // Handle NetworkError exceptions\n throw new Error(`2: failed generating rb_id ${e}`);\n }\n}\n\nexport function getDynamicBundleItems(bundle: BundleAppProxy, shopifyProductHandle: string) {\n const isValid = validateDynamicBundle(bundle);\n if (isValid !== true) {\n throw new Error(`Dynamic Bundle is invalid. ${isValid}`);\n }\n // generate unique id for dynamic bundle\n const bundleId = `${nanoid(9)}:${bundle.externalProductId}`;\n return bundle.selections.map(item => {\n const itemData: DynamicBundleItemAppProxy = {\n id: item.externalVariantId,\n quantity: item.quantity,\n properties: {\n _rc_bundle: bundleId,\n _rc_bundle_variant: bundle.externalVariantId,\n _rc_bundle_parent: shopifyProductHandle,\n _rc_bundle_collection_id: item.collectionId,\n },\n };\n\n if (item.sellingPlan) {\n // this is used by SCI stores\n itemData.selling_plan = item.sellingPlan;\n } else if (item.shippingIntervalFrequency) {\n // this is used by RCS stores\n itemData.properties.shipping_interval_frequency = item.shippingIntervalFrequency;\n itemData.properties.shipping_interval_unit_type = item.shippingIntervalUnitType;\n itemData.id = `${item.discountedVariantId}`;\n }\n\n return itemData;\n });\n}\n\nexport async function validateBundle(bundle: BundleAppProxy): Promise<true | string> {\n try {\n // once we implement this function, we can make it raise an exception\n // we could also have a local store relative to this function so we don't have to pass bundleProduct\n if (!bundle) {\n return 'Bundle is not defined';\n }\n // Don't make bundle settings call due to merchant issues\n // const bundleSettings = await getCDNBundleSettings(bundle.externalProductId);\n // if (!bundleSettings) {\n // return 'Bundle settings do not exist for the given product';\n // }\n return true;\n } catch (e) {\n return `Error fetching bundle settings: ${e}`;\n }\n}\n\nexport async function validateBundleSelection(bundle: BundleAppProxy): Promise<{ valid: boolean; error?: string }> {\n try {\n const bundleData = await shopifyAppProxyRequest<BundleData>('get', `/bundle-data/${bundle.externalProductId}`);\n\n const selectionValidator = new BundleSelectionValidator(bundle.selections, bundleData);\n\n return { valid: selectionValidator.isBundleSelectionValid(bundle.externalVariantId) };\n } catch (error) {\n return { valid: false, error: String(error) };\n }\n}\n\nconst intervalUnitGroups = {\n day: ['day', 'days', 'Days'],\n days: ['day', 'days', 'Days'],\n Days: ['day', 'days', 'Days'],\n week: ['week', 'weeks', 'Weeks'],\n weeks: ['week', 'weeks', 'Weeks'],\n Weeks: ['week', 'weeks', 'Weeks'],\n month: ['month', 'months', 'Months'],\n months: ['month', 'months', 'Months'],\n Months: ['month', 'months', 'Months'],\n};\n\n/**\n * Validates a dynamic bundle\n *\n * @param bundle Dynamic Bundle being validated\n * @returns true or error message\n */\nexport function validateDynamicBundle(bundle: BundleAppProxy): true | string {\n if (!bundle) {\n return 'No bundle defined.';\n }\n if (bundle.selections.length === 0) {\n return 'No selections defined.';\n }\n // validation for RCS onetimes\n const { shippingIntervalFrequency, shippingIntervalUnitType } =\n bundle.selections.find(selection => selection.shippingIntervalFrequency || selection.shippingIntervalUnitType) ||\n {};\n if (shippingIntervalFrequency || shippingIntervalUnitType) {\n // if we have shipping intervals then we should have both defined\n if (!shippingIntervalFrequency || !shippingIntervalUnitType) {\n return 'Shipping intervals do not match on selections.';\n } else {\n // if we have shipping intervals then any that are defined should match\n const shippingIntervalUnitGroup = intervalUnitGroups[shippingIntervalUnitType];\n for (let x = 0; x < bundle.selections.length; x++) {\n const { shippingIntervalFrequency: frequency, shippingIntervalUnitType: unitType } = bundle.selections[x];\n if (\n (frequency && frequency !== shippingIntervalFrequency) ||\n (unitType && !shippingIntervalUnitGroup.includes(unitType))\n ) {\n return 'Shipping intervals do not match on selections.';\n }\n }\n }\n }\n return true;\n}\n\nexport async function getBundleSelection(session: Session, id: string | number): Promise<BundleSelection> {\n if (id === undefined || id === '') {\n throw new Error('ID is required');\n }\n const { bundle_selection } = await rechargeApiRequest<{ bundle_selection: BundleSelection }>(\n 'get',\n `/bundle_selections`,\n {\n id,\n },\n getInternalSession(session, 'getBundleSelection')\n );\n return bundle_selection;\n}\n\nexport function listBundleSelections(\n session: Session,\n query?: BundleSelectionListParams\n): Promise<BundleSelectionsResponse> {\n return rechargeApiRequest<BundleSelectionsResponse>(\n 'get',\n `/bundle_selections`,\n { query },\n getInternalSession(session, 'listBundleSelections')\n );\n}\n\nexport async function createBundleSelection(\n session: Session,\n createRequest: CreateBundleSelectionRequest\n): Promise<BundleSelection> {\n const { bundle_selection } = await rechargeApiRequest<{ bundle_selection: BundleSelection }>(\n 'post',\n `/bundle_selections`,\n {\n data: createRequest,\n },\n getInternalSession(session, 'createBundleSelection')\n );\n return bundle_selection;\n}\n\nexport async function updateBundleSelection(\n session: Session,\n id: string | number,\n updateRequest: UpdateBundleSelectionRequest\n): Promise<BundleSelection> {\n if (id === undefined || id === '') {\n throw new Error('ID is required');\n }\n const { bundle_selection } = await rechargeApiRequest<{ bundle_selection: BundleSelection }>(\n 'put',\n `/bundle_selections`,\n {\n id,\n data: updateRequest,\n },\n getInternalSession(session, 'updateBundleSelection')\n );\n return bundle_selection;\n}\n\nexport function deleteBundleSelection(session: Session, id: string | number): Promise<void> {\n if (id === undefined || id === '') {\n throw new Error('ID is required');\n }\n return rechargeApiRequest<void>(\n 'delete',\n `/bundle_selections`,\n {\n id,\n },\n getInternalSession(session, 'deleteBundleSelection')\n );\n}\n\nexport async function updateBundle(\n session: Session,\n purchase_item_id: string | number,\n updateRequest: UpdateBundlePurchaseItem,\n query?: BundlePurchaseItemParams\n): Promise<BundlePurchaseItem> {\n if (purchase_item_id === undefined || purchase_item_id === '') {\n throw new Error('Purchase item ID is required');\n }\n const { subscription } = await rechargeApiRequest<{ subscription: BundlePurchaseItem }>(\n 'put',\n '/bundles',\n {\n id: purchase_item_id,\n data: updateRequest,\n query,\n },\n getInternalSession(session, 'updateBundle')\n );\n\n return subscription;\n}\n"],"names":["shopifyAppProxyRequest","rechargeApiRequest","bundle","toLineItemProperty","getOptions","getInternalSession","nanoid","BundleSelectionValidator"],"mappings":";;;;;;;AAoBA,MAAM,uBAA0B,GAAA,8BAAA,CAAA;AAEhC,SAAS,6BAAwC,GAAA;AAI/C,EAAA,OAAO,IAAK,CAAA,IAAA,CAAK,IAAK,CAAA,GAAA,KAAQ,GAAI,CAAA,CAAA;AACpC,CAAA;AAEA,eAAe,6BAAiD,GAAA;AAK9D,EAAI,IAAA;AACF,IAAM,MAAA,EAAE,WAAc,GAAA,MAAMA,+BAA8C,KAAO,EAAA,CAAA,EAAG,uBAAuB,CAAI,EAAA,CAAA,CAAA,CAAA;AAC/G,IAAO,OAAA,SAAA,CAAA;AAAA,WACA,EAAI,EAAA;AACX,IAAQ,OAAA,CAAA,KAAA,CAAM,CAAiB,cAAA,EAAA,EAAE,CAA2B,yBAAA,CAAA,CAAA,CAAA;AAC5D,IAAA,OAAO,6BAA8B,EAAA,CAAA;AAAA,GACvC;AACF,CAAA;AAEA,eAAe,iCAAiC,eAAmD,EAAA;AAKjG,EAAI,IAAA;AACF,IAAM,MAAA,EAAE,SAAU,EAAA,GAAI,MAAMC,0BAAA;AAAA,MAC1B,KAAA;AAAA,MACA,CAAA,4BAAA,CAAA;AAAA,MACA,EAAC;AAAA,MACD,eAAA;AAAA,KACF,CAAA;AACA,IAAO,OAAA,SAAA,CAAA;AAAA,WACA,EAAI,EAAA;AACX,IAAQ,OAAA,CAAA,KAAA,CAAM,CAAiB,cAAA,EAAA,EAAE,CAA2B,yBAAA,CAAA,CAAA,CAAA;AAC5D,I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,OAAA,YAAA,CAAA;AACT;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"bundle.js","sources":["../../../src/api/bundle.ts"],"sourcesContent":["import { nanoid } from 'nanoid/non-secure';\nimport {\n BundleAppProxy,\n DynamicBundleItemAppProxy,\n BundleSelection,\n BundleSelectionListParams,\n BundleSelectionsResponse,\n CreateBundleSelectionRequest,\n InternalSession,\n Session,\n UpdateBundleSelectionRequest,\n UpdateBundlePurchaseItem,\n BundlePurchaseItem,\n BundlePurchaseItemParams,\n BundleData,\n} from '../types';\nimport { getInternalSession, rechargeApiRequest, shopifyAppProxyRequest } from '../utils/request';\nimport { getOptions } from '../utils/options';\nimport { BundleSelectionValidator, toLineItemProperty } from '../utils/bundle';\n\nconst STORE_FRONT_MANAGER_URL = '/bundling-storefront-manager';\n\nfunction getTimestampSecondsFromClient(): number {\n /**\n * Get the current unix epoch in seconds from the client-side.\n */\n return Math.ceil(Date.now() / 1000);\n}\n\nasync function getTimestampSecondsFromServer(): Promise<number> {\n /**\n * Get the unix epoch from the server instead of using it directly from the\n * client. This must reduce even more the number of invalid Bundles.\n */\n try {\n const { timestamp } = await shopifyAppProxyRequest<{ timestamp: number }>('get', `${STORE_FRONT_MANAGER_URL}/t`);\n return timestamp;\n } catch (ex) {\n console.error(`Fetch failed: ${ex}. Using client-side date.`);\n return getTimestampSecondsFromClient();\n }\n}\n\nasync function getTimestampSecondsFromServerApi(internalSession: InternalSession): Promise<number> {\n /**\n * Same as getTimestampSecondsFromServer, but using the recharge API server instead of the storefront manager.\n * This is done to bypass origin validation and expose this endpoint to headless storefronts.\n */\n try {\n const { timestamp } = await rechargeApiRequest<{ timestamp: number }>(\n 'get',\n `/bundle_selections/timestamp`,\n {},\n internalSession\n );\n return timestamp;\n } catch (ex) {\n console.error(`Fetch failed: ${ex}. Using client-side date.`);\n return getTimestampSecondsFromClient();\n }\n}\n\nfunction createBundleData(bundle: BundleAppProxy, timestampSeconds: number) {\n return toLineItemProperty({\n variantId: bundle.externalVariantId,\n version: timestampSeconds,\n items: bundle.selections.map(item => {\n return {\n collectionId: item.collectionId,\n productId: item.externalProductId,\n variantId: item.externalVariantId,\n quantity: item.quantity,\n sku: '',\n };\n }),\n });\n}\n\nexport async function getBundleId(bundle: BundleAppProxy): Promise<string> {\n const opts = getOptions();\n const isValid = await validateBundle(bundle);\n if (isValid !== true) {\n throw new Error(isValid);\n }\n const timestampSeconds = await getTimestampSecondsFromServer();\n const bundleData = createBundleData(bundle, timestampSeconds);\n\n try {\n const payload = await shopifyAppProxyRequest<{ id: string; code: number; message: string }>(\n 'post',\n `${STORE_FRONT_MANAGER_URL}/api/v1/bundles`,\n {\n data: {\n bundle: bundleData,\n },\n headers: {\n Origin: `https://${opts.storeIdentifier}`,\n },\n }\n );\n\n if (!payload.id || payload.code !== 200) {\n throw new Error(`1: failed generating rb_id: ${JSON.stringify(payload)}`);\n }\n\n return payload.id;\n } catch (e) {\n // Handle NetworkError exceptions\n throw new Error(`2: failed generating rb_id ${e}`);\n }\n}\n\nexport async function getBundleSelectionId(session: Session, bundle: BundleAppProxy): Promise<string> {\n const isValid = await validateBundle(bundle);\n if (isValid !== true) {\n throw new Error(isValid);\n }\n const internalSession = getInternalSession(session, 'getBundleSelectionId');\n const timestampSeconds = await getTimestampSecondsFromServerApi(internalSession);\n const bundleData = createBundleData(bundle, timestampSeconds);\n\n try {\n const payload = await rechargeApiRequest<{ id: string; code: number; message: string }>(\n 'post',\n `/bundle_selections/bundle_id`,\n {\n data: {\n bundle: bundleData,\n },\n },\n internalSession\n );\n\n if (!payload.id || payload.code !== 200) {\n throw new Error(`1: failed generating rb_id: ${JSON.stringify(payload)}`);\n }\n\n return payload.id;\n } catch (e) {\n // Handle NetworkError exceptions\n throw new Error(`2: failed generating rb_id ${e}`);\n }\n}\n\nexport function getDynamicBundleItems(bundle: BundleAppProxy, shopifyProductHandle: string) {\n const isValid = validateDynamicBundle(bundle);\n if (isValid !== true) {\n throw new Error(`Dynamic Bundle is invalid. ${isValid}`);\n }\n // generate unique id for dynamic bundle\n const bundleId = `${nanoid(9)}:${bundle.externalProductId}`;\n return bundle.selections.map(item => {\n const itemData: DynamicBundleItemAppProxy = {\n id: item.externalVariantId,\n quantity: item.quantity,\n properties: {\n _rc_bundle: bundleId,\n _rc_bundle_variant: bundle.externalVariantId,\n _rc_bundle_parent: shopifyProductHandle,\n _rc_bundle_collection_id: item.collectionId,\n },\n };\n\n if (item.sellingPlan) {\n // this is used by SCI stores\n itemData.selling_plan = item.sellingPlan;\n } else if (item.shippingIntervalFrequency) {\n // this is used by RCS stores\n itemData.properties.shipping_interval_frequency = item.shippingIntervalFrequency;\n itemData.properties.shipping_interval_unit_type = item.shippingIntervalUnitType;\n itemData.id = `${item.discountedVariantId}`;\n }\n\n return itemData;\n });\n}\n\nexport async function validateBundle(bundle: BundleAppProxy): Promise<true | string> {\n try {\n // once we implement this function, we can make it raise an exception\n // we could also have a local store relative to this function so we don't have to pass bundleProduct\n if (!bundle) {\n return 'Bundle is not defined';\n }\n if (bundle.selections.length === 0) {\n return 'No selections defined';\n }\n // Don't make bundle settings call due to merchant issues\n // const bundleSettings = await getCDNBundleSettings(bundle.externalProductId);\n // if (!bundleSettings) {\n // return 'Bundle settings do not exist for the given product';\n // }\n return true;\n } catch (e) {\n return `Error fetching bundle settings: ${e}`;\n }\n}\n\nexport async function validateBundleSelection(bundle: BundleAppProxy): Promise<{ valid: boolean; error?: string }> {\n try {\n const bundleData = await shopifyAppProxyRequest<BundleData>('get', `/bundle-data/${bundle.externalProductId}`);\n\n const selectionValidator = new BundleSelectionValidator(bundle.selections, bundleData);\n\n return { valid: selectionValidator.isBundleSelectionValid(bundle.externalVariantId) };\n } catch (error) {\n return { valid: false, error: String(error) };\n }\n}\n\nconst intervalUnitGroups = {\n day: ['day', 'days', 'Days'],\n days: ['day', 'days', 'Days'],\n Days: ['day', 'days', 'Days'],\n week: ['week', 'weeks', 'Weeks'],\n weeks: ['week', 'weeks', 'Weeks'],\n Weeks: ['week', 'weeks', 'Weeks'],\n month: ['month', 'months', 'Months'],\n months: ['month', 'months', 'Months'],\n Months: ['month', 'months', 'Months'],\n};\n\n/**\n * Validates a dynamic bundle\n *\n * @param bundle Dynamic Bundle being validated\n * @returns true or error message\n */\nexport function validateDynamicBundle(bundle: BundleAppProxy): true | string {\n if (!bundle) {\n return 'No bundle defined.';\n }\n if (bundle.selections.length === 0) {\n return 'No selections defined.';\n }\n // validation for RCS onetimes\n const { shippingIntervalFrequency, shippingIntervalUnitType } =\n bundle.selections.find(selection => selection.shippingIntervalFrequency || selection.shippingIntervalUnitType) ||\n {};\n if (shippingIntervalFrequency || shippingIntervalUnitType) {\n // if we have shipping intervals then we should have both defined\n if (!shippingIntervalFrequency || !shippingIntervalUnitType) {\n return 'Shipping intervals do not match on selections.';\n } else {\n // if we have shipping intervals then any that are defined should match\n const shippingIntervalUnitGroup = intervalUnitGroups[shippingIntervalUnitType];\n for (let x = 0; x < bundle.selections.length; x++) {\n const { shippingIntervalFrequency: frequency, shippingIntervalUnitType: unitType } = bundle.selections[x];\n if (\n (frequency && frequency !== shippingIntervalFrequency) ||\n (unitType && !shippingIntervalUnitGroup.includes(unitType))\n ) {\n return 'Shipping intervals do not match on selections.';\n }\n }\n }\n }\n return true;\n}\n\nexport async function getBundleSelection(session: Session, id: string | number): Promise<BundleSelection> {\n if (id === undefined || id === '') {\n throw new Error('ID is required');\n }\n const { bundle_selection } = await rechargeApiRequest<{ bundle_selection: BundleSelection }>(\n 'get',\n `/bundle_selections`,\n {\n id,\n },\n getInternalSession(session, 'getBundleSelection')\n );\n return bundle_selection;\n}\n\nexport function listBundleSelections(\n session: Session,\n query?: BundleSelectionListParams\n): Promise<BundleSelectionsResponse> {\n return rechargeApiRequest<BundleSelectionsResponse>(\n 'get',\n `/bundle_selections`,\n { query },\n getInternalSession(session, 'listBundleSelections')\n );\n}\n\nexport async function createBundleSelection(\n session: Session,\n createRequest: CreateBundleSelectionRequest\n): Promise<BundleSelection> {\n const { bundle_selection } = await rechargeApiRequest<{ bundle_selection: BundleSelection }>(\n 'post',\n `/bundle_selections`,\n {\n data: createRequest,\n },\n getInternalSession(session, 'createBundleSelection')\n );\n return bundle_selection;\n}\n\nexport async function updateBundleSelection(\n session: Session,\n id: string | number,\n updateRequest: UpdateBundleSelectionRequest\n): Promise<BundleSelection> {\n if (id === undefined || id === '') {\n throw new Error('ID is required');\n }\n const { bundle_selection } = await rechargeApiRequest<{ bundle_selection: BundleSelection }>(\n 'put',\n `/bundle_selections`,\n {\n id,\n data: updateRequest,\n },\n getInternalSession(session, 'updateBundleSelection')\n );\n return bundle_selection;\n}\n\nexport function deleteBundleSelection(session: Session, id: string | number): Promise<void> {\n if (id === undefined || id === '') {\n throw new Error('ID is required');\n }\n return rechargeApiRequest<void>(\n 'delete',\n `/bundle_selections`,\n {\n id,\n },\n getInternalSession(session, 'deleteBundleSelection')\n );\n}\n\nexport async function updateBundle(\n session: Session,\n purchase_item_id: string | number,\n updateRequest: UpdateBundlePurchaseItem,\n query?: BundlePurchaseItemParams\n): Promise<BundlePurchaseItem> {\n if (purchase_item_id === undefined || purchase_item_id === '') {\n throw new Error('Purchase item ID is required');\n }\n const { subscription } = await rechargeApiRequest<{ subscription: BundlePurchaseItem }>(\n 'put',\n '/bundles',\n {\n id: purchase_item_id,\n data: updateRequest,\n query,\n },\n getInternalSession(session, 'updateBundle')\n );\n\n return subscription;\n}\n"],"names":["shopifyAppProxyRequest","rechargeApiRequest","bundle","toLineItemProperty","getOptions","getInternalSession","nanoid","BundleSelectionValidator"],"mappings":";;;;;;;AAoBA,MAAM,uBAA0B,GAAA,8BAAA,CAAA;AAEhC,SAAS,6BAAwC,GAAA;AAI/C,EAAA,OAAO,IAAK,CAAA,IAAA,CAAK,IAAK,CAAA,GAAA,KAAQ,GAAI,CAAA,CAAA;AACpC,CAAA;AAEA,eAAe,6BAAiD,GAAA;AAK9D,EAAI,IAAA;AACF,IAAM,MAAA,EAAE,WAAc,GAAA,MAAMA,+BAA8C,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EAAI,EAAA;AACjC,IAAM,MAAA,IAAI,MAAM,gBAAgB,CAAA,CAAA;AAAA,GAClC;AACA,EAAO,OAAAJ,0BAAA;AAAA,IACL,QAAA;AAAA,IACA,CAAA,kBAAA,CAAA;AAAA,IACA;AAAA,MACE,EAAA;AAAA,KACF;AAAA,IACAI,0BAAA,CAAmB,SAAS,uBAAuB,CAAA;AAAA,GACrD,CAAA;AACF,CAAA;AAEA,eAAsB,YACpB,CAAA,OAAA,EACA,gBACA,EAAA,aAAA,EACA,KAC6B,EAAA;AAC7B,EAAI,IAAA,gBAAA,KAAqB,KAAa,CAAA,IAAA,gBAAA,KAAqB,EAAI,EAAA;AAC7D,IAAM,MAAA,IAAI,MAAM,8BAA8B,CAAA,CAAA;AAAA,GAChD;AACA,EAAM,MAAA,EAAE,YAAa,EAAA,GAAI,MAAMJ,0BAAA;AAAA,IAC7B,KAAA;AAAA,IACA,UAAA;AAAA,IACA;AAAA,MACE,EAAI,EAAA,gBAAA;AAAA,MACJ,IAAM,EAAA,aAAA;AAAA,MACN,KAAA;AAAA,KACF;AAAA,IACAI,0BAAA,CAAmB,SAAS,cAAc,CAAA;AAAA,GAC5C,CAAA;AAEA,EAAO,OAAA,YAAA,CAAA;AACT;;;;;;;;;;;;;;;"}
@@ -41,7 +41,7 @@ async function rechargeApiRequest(method, url, { id, query, data, headers } = {}
41
41
  "X-Recharge-Sdk-Fn": session.internalFnCall,
42
42
  ...appName ? { "X-Recharge-Sdk-App-Name": appName } : {},
43
43
  ...appVersion ? { "X-Recharge-Sdk-App-Version": appVersion } : {},
44
- "X-Recharge-Sdk-Version": "1.38.0",
44
+ "X-Recharge-Sdk-Version": "1.39.0",
45
45
  "X-Request-Id": session.internalRequestId,
46
46
  ...session.tmp_fn_identifier ? { "X-Recharge-Sdk-Fn-Identifier": session.tmp_fn_identifier } : {},
47
47
  ...headers ? headers : {}
@@ -179,7 +179,7 @@ async function rechargeAdminRequest(method, url, { id, query, data, headers } =
179
179
  ...storefrontAccessToken ? { "X-Recharge-Storefront-Access-Token": storefrontAccessToken } : {},
180
180
  ...appName ? { "X-Recharge-Sdk-App-Name": appName } : {},
181
181
  ...appVersion ? { "X-Recharge-Sdk-App-Version": appVersion } : {},
182
- "X-Recharge-Sdk-Version": "1.38.0",
182
+ "X-Recharge-Sdk-Version": "1.39.0",
183
183
  ...headers ? headers : {}
184
184
  };
185
185
  return request(method, `${rechargeBaseUrl}${url}`, { id, query, data, headers: reqHeaders });
@@ -133,6 +133,9 @@ async function validateBundle(bundle) {
133
133
  if (!bundle) {
134
134
  return "Bundle is not defined";
135
135
  }
136
+ if (bundle.selections.length === 0) {
137
+ return "No selections defined";
138
+ }
136
139
  return true;
137
140
  } catch (e) {
138
141
  return `Error fetching bundle settings: ${e}`;
@@ -1 +1 @@
1
- {"version":3,"file":"bundle.js","sources":["../../../src/api/bundle.ts"],"sourcesContent":["import { nanoid } from 'nanoid/non-secure';\nimport {\n BundleAppProxy,\n DynamicBundleItemAppProxy,\n BundleSelection,\n BundleSelectionListParams,\n BundleSelectionsResponse,\n CreateBundleSelectionRequest,\n InternalSession,\n Session,\n UpdateBundleSelectionRequest,\n UpdateBundlePurchaseItem,\n BundlePurchaseItem,\n BundlePurchaseItemParams,\n BundleData,\n} from '../types';\nimport { getInternalSession, rechargeApiRequest, shopifyAppProxyRequest } from '../utils/request';\nimport { getOptions } from '../utils/options';\nimport { BundleSelectionValidator, toLineItemProperty } from '../utils/bundle';\n\nconst STORE_FRONT_MANAGER_URL = '/bundling-storefront-manager';\n\nfunction getTimestampSecondsFromClient(): number {\n /**\n * Get the current unix epoch in seconds from the client-side.\n */\n return Math.ceil(Date.now() / 1000);\n}\n\nasync function getTimestampSecondsFromServer(): Promise<number> {\n /**\n * Get the unix epoch from the server instead of using it directly from the\n * client. This must reduce even more the number of invalid Bundles.\n */\n try {\n const { timestamp } = await shopifyAppProxyRequest<{ timestamp: number }>('get', `${STORE_FRONT_MANAGER_URL}/t`);\n return timestamp;\n } catch (ex) {\n console.error(`Fetch failed: ${ex}. Using client-side date.`);\n return getTimestampSecondsFromClient();\n }\n}\n\nasync function getTimestampSecondsFromServerApi(internalSession: InternalSession): Promise<number> {\n /**\n * Same as getTimestampSecondsFromServer, but using the recharge API server instead of the storefront manager.\n * This is done to bypass origin validation and expose this endpoint to headless storefronts.\n */\n try {\n const { timestamp } = await rechargeApiRequest<{ timestamp: number }>(\n 'get',\n `/bundle_selections/timestamp`,\n {},\n internalSession\n );\n return timestamp;\n } catch (ex) {\n console.error(`Fetch failed: ${ex}. Using client-side date.`);\n return getTimestampSecondsFromClient();\n }\n}\n\nfunction createBundleData(bundle: BundleAppProxy, timestampSeconds: number) {\n return toLineItemProperty({\n variantId: bundle.externalVariantId,\n version: timestampSeconds,\n items: bundle.selections.map(item => {\n return {\n collectionId: item.collectionId,\n productId: item.externalProductId,\n variantId: item.externalVariantId,\n quantity: item.quantity,\n sku: '',\n };\n }),\n });\n}\n\nexport async function getBundleId(bundle: BundleAppProxy): Promise<string> {\n const opts = getOptions();\n const isValid = await validateBundle(bundle);\n if (isValid !== true) {\n throw new Error(isValid);\n }\n const timestampSeconds = await getTimestampSecondsFromServer();\n const bundleData = createBundleData(bundle, timestampSeconds);\n\n try {\n const payload = await shopifyAppProxyRequest<{ id: string; code: number; message: string }>(\n 'post',\n `${STORE_FRONT_MANAGER_URL}/api/v1/bundles`,\n {\n data: {\n bundle: bundleData,\n },\n headers: {\n Origin: `https://${opts.storeIdentifier}`,\n },\n }\n );\n\n if (!payload.id || payload.code !== 200) {\n throw new Error(`1: failed generating rb_id: ${JSON.stringify(payload)}`);\n }\n\n return payload.id;\n } catch (e) {\n // Handle NetworkError exceptions\n throw new Error(`2: failed generating rb_id ${e}`);\n }\n}\n\nexport async function getBundleSelectionId(session: Session, bundle: BundleAppProxy): Promise<string> {\n const isValid = await validateBundle(bundle);\n if (isValid !== true) {\n throw new Error(isValid);\n }\n const internalSession = getInternalSession(session, 'getBundleSelectionId');\n const timestampSeconds = await getTimestampSecondsFromServerApi(internalSession);\n const bundleData = createBundleData(bundle, timestampSeconds);\n\n try {\n const payload = await rechargeApiRequest<{ id: string; code: number; message: string }>(\n 'post',\n `/bundle_selections/bundle_id`,\n {\n data: {\n bundle: bundleData,\n },\n },\n internalSession\n );\n\n if (!payload.id || payload.code !== 200) {\n throw new Error(`1: failed generating rb_id: ${JSON.stringify(payload)}`);\n }\n\n return payload.id;\n } catch (e) {\n // Handle NetworkError exceptions\n throw new Error(`2: failed generating rb_id ${e}`);\n }\n}\n\nexport function getDynamicBundleItems(bundle: BundleAppProxy, shopifyProductHandle: string) {\n const isValid = validateDynamicBundle(bundle);\n if (isValid !== true) {\n throw new Error(`Dynamic Bundle is invalid. ${isValid}`);\n }\n // generate unique id for dynamic bundle\n const bundleId = `${nanoid(9)}:${bundle.externalProductId}`;\n return bundle.selections.map(item => {\n const itemData: DynamicBundleItemAppProxy = {\n id: item.externalVariantId,\n quantity: item.quantity,\n properties: {\n _rc_bundle: bundleId,\n _rc_bundle_variant: bundle.externalVariantId,\n _rc_bundle_parent: shopifyProductHandle,\n _rc_bundle_collection_id: item.collectionId,\n },\n };\n\n if (item.sellingPlan) {\n // this is used by SCI stores\n itemData.selling_plan = item.sellingPlan;\n } else if (item.shippingIntervalFrequency) {\n // this is used by RCS stores\n itemData.properties.shipping_interval_frequency = item.shippingIntervalFrequency;\n itemData.properties.shipping_interval_unit_type = item.shippingIntervalUnitType;\n itemData.id = `${item.discountedVariantId}`;\n }\n\n return itemData;\n });\n}\n\nexport async function validateBundle(bundle: BundleAppProxy): Promise<true | string> {\n try {\n // once we implement this function, we can make it raise an exception\n // we could also have a local store relative to this function so we don't have to pass bundleProduct\n if (!bundle) {\n return 'Bundle is not defined';\n }\n // Don't make bundle settings call due to merchant issues\n // const bundleSettings = await getCDNBundleSettings(bundle.externalProductId);\n // if (!bundleSettings) {\n // return 'Bundle settings do not exist for the given product';\n // }\n return true;\n } catch (e) {\n return `Error fetching bundle settings: ${e}`;\n }\n}\n\nexport async function validateBundleSelection(bundle: BundleAppProxy): Promise<{ valid: boolean; error?: string }> {\n try {\n const bundleData = await shopifyAppProxyRequest<BundleData>('get', `/bundle-data/${bundle.externalProductId}`);\n\n const selectionValidator = new BundleSelectionValidator(bundle.selections, bundleData);\n\n return { valid: selectionValidator.isBundleSelectionValid(bundle.externalVariantId) };\n } catch (error) {\n return { valid: false, error: String(error) };\n }\n}\n\nconst intervalUnitGroups = {\n day: ['day', 'days', 'Days'],\n days: ['day', 'days', 'Days'],\n Days: ['day', 'days', 'Days'],\n week: ['week', 'weeks', 'Weeks'],\n weeks: ['week', 'weeks', 'Weeks'],\n Weeks: ['week', 'weeks', 'Weeks'],\n month: ['month', 'months', 'Months'],\n months: ['month', 'months', 'Months'],\n Months: ['month', 'months', 'Months'],\n};\n\n/**\n * Validates a dynamic bundle\n *\n * @param bundle Dynamic Bundle being validated\n * @returns true or error message\n */\nexport function validateDynamicBundle(bundle: BundleAppProxy): true | string {\n if (!bundle) {\n return 'No bundle defined.';\n }\n if (bundle.selections.length === 0) {\n return 'No selections defined.';\n }\n // validation for RCS onetimes\n const { shippingIntervalFrequency, shippingIntervalUnitType } =\n bundle.selections.find(selection => selection.shippingIntervalFrequency || selection.shippingIntervalUnitType) ||\n {};\n if (shippingIntervalFrequency || shippingIntervalUnitType) {\n // if we have shipping intervals then we should have both defined\n if (!shippingIntervalFrequency || !shippingIntervalUnitType) {\n return 'Shipping intervals do not match on selections.';\n } else {\n // if we have shipping intervals then any that are defined should match\n const shippingIntervalUnitGroup = intervalUnitGroups[shippingIntervalUnitType];\n for (let x = 0; x < bundle.selections.length; x++) {\n const { shippingIntervalFrequency: frequency, shippingIntervalUnitType: unitType } = bundle.selections[x];\n if (\n (frequency && frequency !== shippingIntervalFrequency) ||\n (unitType && !shippingIntervalUnitGroup.includes(unitType))\n ) {\n return 'Shipping intervals do not match on selections.';\n }\n }\n }\n }\n return true;\n}\n\nexport async function getBundleSelection(session: Session, id: string | number): Promise<BundleSelection> {\n if (id === undefined || id === '') {\n throw new Error('ID is required');\n }\n const { bundle_selection } = await rechargeApiRequest<{ bundle_selection: BundleSelection }>(\n 'get',\n `/bundle_selections`,\n {\n id,\n },\n getInternalSession(session, 'getBundleSelection')\n );\n return bundle_selection;\n}\n\nexport function listBundleSelections(\n session: Session,\n query?: BundleSelectionListParams\n): Promise<BundleSelectionsResponse> {\n return rechargeApiRequest<BundleSelectionsResponse>(\n 'get',\n `/bundle_selections`,\n { query },\n getInternalSession(session, 'listBundleSelections')\n );\n}\n\nexport async function createBundleSelection(\n session: Session,\n createRequest: CreateBundleSelectionRequest\n): Promise<BundleSelection> {\n const { bundle_selection } = await rechargeApiRequest<{ bundle_selection: BundleSelection }>(\n 'post',\n `/bundle_selections`,\n {\n data: createRequest,\n },\n getInternalSession(session, 'createBundleSelection')\n );\n return bundle_selection;\n}\n\nexport async function updateBundleSelection(\n session: Session,\n id: string | number,\n updateRequest: UpdateBundleSelectionRequest\n): Promise<BundleSelection> {\n if (id === undefined || id === '') {\n throw new Error('ID is required');\n }\n const { bundle_selection } = await rechargeApiRequest<{ bundle_selection: BundleSelection }>(\n 'put',\n `/bundle_selections`,\n {\n id,\n data: updateRequest,\n },\n getInternalSession(session, 'updateBundleSelection')\n );\n return bundle_selection;\n}\n\nexport function deleteBundleSelection(session: Session, id: string | number): Promise<void> {\n if (id === undefined || id === '') {\n throw new Error('ID is required');\n }\n return rechargeApiRequest<void>(\n 'delete',\n `/bundle_selections`,\n {\n id,\n },\n getInternalSession(session, 'deleteBundleSelection')\n );\n}\n\nexport async function updateBundle(\n session: Session,\n purchase_item_id: string | number,\n updateRequest: UpdateBundlePurchaseItem,\n query?: BundlePurchaseItemParams\n): Promise<BundlePurchaseItem> {\n if (purchase_item_id === undefined || purchase_item_id === '') {\n throw new Error('Purchase item ID is required');\n }\n const { subscription } = await rechargeApiRequest<{ subscription: BundlePurchaseItem }>(\n 'put',\n '/bundles',\n {\n id: purchase_item_id,\n data: updateRequest,\n query,\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uBAAuB,CAAA;AAAA,GACrD,CAAA;AACA,EAAO,OAAA,gBAAA,CAAA;AACT,CAAA;AAEgB,SAAA,qBAAA,CAAsB,SAAkB,EAAoC,EAAA;AAC1F,EAAI,IAAA,EAAA,KAAO,KAAa,CAAA,IAAA,EAAA,KAAO,EAAI,EAAA;AACjC,IAAM,MAAA,IAAI,MAAM,gBAAgB,CAAA,CAAA;AAAA,GAClC;AACA,EAAO,OAAA,kBAAA;AAAA,IACL,QAAA;AAAA,IACA,CAAA,kBAAA,CAAA;AAAA,IACA;AAAA,MACE,EAAA;AAAA,KACF;AAAA,IACA,kBAAA,CAAmB,SAAS,uBAAuB,CAAA;AAAA,GACrD,CAAA;AACF,CAAA;AAEA,eAAsB,YACpB,CAAA,OAAA,EACA,gBACA,EAAA,aAAA,EACA,KAC6B,EAAA;AAC7B,EAAI,IAAA,gBAAA,KAAqB,KAAa,CAAA,IAAA,gBAAA,KAAqB,EAAI,EAAA;AAC7D,IAAM,MAAA,IAAI,MAAM,8BAA8B,CAAA,CAAA;AAAA,GAChD;AACA,EAAM,MAAA,EAAE,YAAa,EAAA,GAAI,MAAM,kBAAA;AAAA,IAC7B,KAAA;AAAA,IACA,UAAA;AAAA,IACA;AAAA,MACE,EAAI,EAAA,gBAAA;AAAA,MACJ,IAAM,EAAA,aAAA;AAAA,MACN,KAAA;AAAA,KACF;AAAA,IACA,kBAAA,CAAmB,SAAS,cAAc,CAAA;AAAA,GAC5C,CAAA;AAEA,EAAO,OAAA,YAAA,CAAA;AACT;;;;"}
1
+ {"version":3,"file":"bundle.js","sources":["../../../src/api/bundle.ts"],"sourcesContent":["import { nanoid } from 'nanoid/non-secure';\nimport {\n BundleAppProxy,\n DynamicBundleItemAppProxy,\n BundleSelection,\n BundleSelectionListParams,\n BundleSelectionsResponse,\n CreateBundleSelectionRequest,\n InternalSession,\n Session,\n UpdateBundleSelectionRequest,\n UpdateBundlePurchaseItem,\n BundlePurchaseItem,\n BundlePurchaseItemParams,\n BundleData,\n} from '../types';\nimport { getInternalSession, rechargeApiRequest, shopifyAppProxyRequest } from '../utils/request';\nimport { getOptions } from '../utils/options';\nimport { BundleSelectionValidator, toLineItemProperty } from '../utils/bundle';\n\nconst STORE_FRONT_MANAGER_URL = '/bundling-storefront-manager';\n\nfunction getTimestampSecondsFromClient(): number {\n /**\n * Get the current unix epoch in seconds from the client-side.\n */\n return Math.ceil(Date.now() / 1000);\n}\n\nasync function getTimestampSecondsFromServer(): Promise<number> {\n /**\n * Get the unix epoch from the server instead of using it directly from the\n * client. This must reduce even more the number of invalid Bundles.\n */\n try {\n const { timestamp } = await shopifyAppProxyRequest<{ timestamp: number }>('get', `${STORE_FRONT_MANAGER_URL}/t`);\n return timestamp;\n } catch (ex) {\n console.error(`Fetch failed: ${ex}. Using client-side date.`);\n return getTimestampSecondsFromClient();\n }\n}\n\nasync function getTimestampSecondsFromServerApi(internalSession: InternalSession): Promise<number> {\n /**\n * Same as getTimestampSecondsFromServer, but using the recharge API server instead of the storefront manager.\n * This is done to bypass origin validation and expose this endpoint to headless storefronts.\n */\n try {\n const { timestamp } = await rechargeApiRequest<{ timestamp: number }>(\n 'get',\n `/bundle_selections/timestamp`,\n {},\n internalSession\n );\n return timestamp;\n } catch (ex) {\n console.error(`Fetch failed: ${ex}. Using client-side date.`);\n return getTimestampSecondsFromClient();\n }\n}\n\nfunction createBundleData(bundle: BundleAppProxy, timestampSeconds: number) {\n return toLineItemProperty({\n variantId: bundle.externalVariantId,\n version: timestampSeconds,\n items: bundle.selections.map(item => {\n return {\n collectionId: item.collectionId,\n productId: item.externalProductId,\n variantId: item.externalVariantId,\n quantity: item.quantity,\n sku: '',\n };\n }),\n });\n}\n\nexport async function getBundleId(bundle: BundleAppProxy): Promise<string> {\n const opts = getOptions();\n const isValid = await validateBundle(bundle);\n if (isValid !== true) {\n throw new Error(isValid);\n }\n const timestampSeconds = await getTimestampSecondsFromServer();\n const bundleData = createBundleData(bundle, timestampSeconds);\n\n try {\n const payload = await shopifyAppProxyRequest<{ id: string; code: number; message: string }>(\n 'post',\n `${STORE_FRONT_MANAGER_URL}/api/v1/bundles`,\n {\n data: {\n bundle: bundleData,\n },\n headers: {\n Origin: `https://${opts.storeIdentifier}`,\n },\n }\n );\n\n if (!payload.id || payload.code !== 200) {\n throw new Error(`1: failed generating rb_id: ${JSON.stringify(payload)}`);\n }\n\n return payload.id;\n } catch (e) {\n // Handle NetworkError exceptions\n throw new Error(`2: failed generating rb_id ${e}`);\n }\n}\n\nexport async function getBundleSelectionId(session: Session, bundle: BundleAppProxy): Promise<string> {\n const isValid = await validateBundle(bundle);\n if (isValid !== true) {\n throw new Error(isValid);\n }\n const internalSession = getInternalSession(session, 'getBundleSelectionId');\n const timestampSeconds = await getTimestampSecondsFromServerApi(internalSession);\n const bundleData = createBundleData(bundle, timestampSeconds);\n\n try {\n const payload = await rechargeApiRequest<{ id: string; code: number; message: string }>(\n 'post',\n `/bundle_selections/bundle_id`,\n {\n data: {\n bundle: bundleData,\n },\n },\n internalSession\n );\n\n if (!payload.id || payload.code !== 200) {\n throw new Error(`1: failed generating rb_id: ${JSON.stringify(payload)}`);\n }\n\n return payload.id;\n } catch (e) {\n // Handle NetworkError exceptions\n throw new Error(`2: failed generating rb_id ${e}`);\n }\n}\n\nexport function getDynamicBundleItems(bundle: BundleAppProxy, shopifyProductHandle: string) {\n const isValid = validateDynamicBundle(bundle);\n if (isValid !== true) {\n throw new Error(`Dynamic Bundle is invalid. ${isValid}`);\n }\n // generate unique id for dynamic bundle\n const bundleId = `${nanoid(9)}:${bundle.externalProductId}`;\n return bundle.selections.map(item => {\n const itemData: DynamicBundleItemAppProxy = {\n id: item.externalVariantId,\n quantity: item.quantity,\n properties: {\n _rc_bundle: bundleId,\n _rc_bundle_variant: bundle.externalVariantId,\n _rc_bundle_parent: shopifyProductHandle,\n _rc_bundle_collection_id: item.collectionId,\n },\n };\n\n if (item.sellingPlan) {\n // this is used by SCI stores\n itemData.selling_plan = item.sellingPlan;\n } else if (item.shippingIntervalFrequency) {\n // this is used by RCS stores\n itemData.properties.shipping_interval_frequency = item.shippingIntervalFrequency;\n itemData.properties.shipping_interval_unit_type = item.shippingIntervalUnitType;\n itemData.id = `${item.discountedVariantId}`;\n }\n\n return itemData;\n });\n}\n\nexport async function validateBundle(bundle: BundleAppProxy): Promise<true | string> {\n try {\n // once we implement this function, we can make it raise an exception\n // we could also have a local store relative to this function so we don't have to pass bundleProduct\n if (!bundle) {\n return 'Bundle is not defined';\n }\n if (bundle.selections.length === 0) {\n return 'No selections defined';\n }\n // Don't make bundle settings call due to merchant issues\n // const bundleSettings = await getCDNBundleSettings(bundle.externalProductId);\n // if (!bundleSettings) {\n // return 'Bundle settings do not exist for the given product';\n // }\n return true;\n } catch (e) {\n return `Error fetching bundle settings: ${e}`;\n }\n}\n\nexport async function validateBundleSelection(bundle: BundleAppProxy): Promise<{ valid: boolean; error?: string }> {\n try {\n const bundleData = await shopifyAppProxyRequest<BundleData>('get', `/bundle-data/${bundle.externalProductId}`);\n\n const selectionValidator = new BundleSelectionValidator(bundle.selections, bundleData);\n\n return { valid: selectionValidator.isBundleSelectionValid(bundle.externalVariantId) };\n } catch (error) {\n return { valid: false, error: String(error) };\n }\n}\n\nconst intervalUnitGroups = {\n day: ['day', 'days', 'Days'],\n days: ['day', 'days', 'Days'],\n Days: ['day', 'days', 'Days'],\n week: ['week', 'weeks', 'Weeks'],\n weeks: ['week', 'weeks', 'Weeks'],\n Weeks: ['week', 'weeks', 'Weeks'],\n month: ['month', 'months', 'Months'],\n months: ['month', 'months', 'Months'],\n Months: ['month', 'months', 'Months'],\n};\n\n/**\n * Validates a dynamic bundle\n *\n * @param bundle Dynamic Bundle being validated\n * @returns true or error message\n */\nexport function validateDynamicBundle(bundle: BundleAppProxy): true | string {\n if (!bundle) {\n return 'No bundle defined.';\n }\n if (bundle.selections.length === 0) {\n return 'No selections defined.';\n }\n // validation for RCS onetimes\n const { shippingIntervalFrequency, shippingIntervalUnitType } =\n bundle.selections.find(selection => selection.shippingIntervalFrequency || selection.shippingIntervalUnitType) ||\n {};\n if (shippingIntervalFrequency || shippingIntervalUnitType) {\n // if we have shipping intervals then we should have both defined\n if (!shippingIntervalFrequency || !shippingIntervalUnitType) {\n return 'Shipping intervals do not match on selections.';\n } else {\n // if we have shipping intervals then any that are defined should match\n const shippingIntervalUnitGroup = intervalUnitGroups[shippingIntervalUnitType];\n for (let x = 0; x < bundle.selections.length; x++) {\n const { shippingIntervalFrequency: frequency, shippingIntervalUnitType: unitType } = bundle.selections[x];\n if (\n (frequency && frequency !== shippingIntervalFrequency) ||\n (unitType && !shippingIntervalUnitGroup.includes(unitType))\n ) {\n return 'Shipping intervals do not match on selections.';\n }\n }\n }\n }\n return true;\n}\n\nexport async function getBundleSelection(session: Session, id: string | number): Promise<BundleSelection> {\n if (id === undefined || id === '') {\n throw new Error('ID is required');\n }\n const { bundle_selection } = await rechargeApiRequest<{ bundle_selection: BundleSelection }>(\n 'get',\n `/bundle_selections`,\n {\n id,\n },\n getInternalSession(session, 'getBundleSelection')\n );\n return bundle_selection;\n}\n\nexport function listBundleSelections(\n session: Session,\n query?: BundleSelectionListParams\n): Promise<BundleSelectionsResponse> {\n return rechargeApiRequest<BundleSelectionsResponse>(\n 'get',\n `/bundle_selections`,\n { query },\n getInternalSession(session, 'listBundleSelections')\n );\n}\n\nexport async function createBundleSelection(\n session: Session,\n createRequest: CreateBundleSelectionRequest\n): Promise<BundleSelection> {\n const { bundle_selection } = await rechargeApiRequest<{ bundle_selection: BundleSelection }>(\n 'post',\n `/bundle_selections`,\n {\n data: createRequest,\n },\n getInternalSession(session, 'createBundleSelection')\n );\n return bundle_selection;\n}\n\nexport async function updateBundleSelection(\n session: Session,\n id: string | number,\n updateRequest: UpdateBundleSelectionRequest\n): Promise<BundleSelection> {\n if (id === undefined || id === '') {\n throw new Error('ID is required');\n }\n const { bundle_selection } = await rechargeApiRequest<{ bundle_selection: BundleSelection }>(\n 'put',\n `/bundle_selections`,\n {\n id,\n data: updateRequest,\n },\n getInternalSession(session, 'updateBundleSelection')\n );\n return bundle_selection;\n}\n\nexport function deleteBundleSelection(session: Session, id: string | number): Promise<void> {\n if (id === undefined || id === '') {\n throw new Error('ID is required');\n }\n return rechargeApiRequest<void>(\n 'delete',\n `/bundle_selections`,\n {\n id,\n },\n getInternalSession(session, 'deleteBundleSelection')\n );\n}\n\nexport async function updateBundle(\n session: Session,\n purchase_item_id: string | number,\n updateRequest: UpdateBundlePurchaseItem,\n query?: BundlePurchaseItemParams\n): Promise<BundlePurchaseItem> {\n if (purchase_item_id === undefined || purchase_item_id === '') {\n throw new Error('Purchase item ID is required');\n }\n const { subscription } = await rechargeApiRequest<{ subscription: BundlePurchaseItem }>(\n 'put',\n '/bundles',\n {\n id: purchase_item_id,\n data: updateRequest,\n query,\n },\n getInternalSession(session, 'updateBundle')\n );\n\n return subscription;\n}\n"],"names":[],"mappings":";;;;;AAoBA,MAAM,uBAA0B,GAAA,8BAAA,CAAA;AAEhC,SAAS,6BAAwC,GAAA;AAI/C,EAAA,OAAO,IAAK,CAAA,IAAA,CAAK,IAAK,CAAA,GAAA,KAAQ,GAAI,CAAA,CAAA;AACpC,CAAA;AAEA,eAAe,6BAAiD,GAAA;AAK9D,EAAI,IAAA;AACF,IAAM,MAAA,EAAE,WAAc,GAAA,MAAM,uBAA8C,KAAO,EAAA,CAAA,EAAG,uBAAuB,CAAI,EAAA,CAAA,CAAA,CAAA;AAC/G,IAAO,OAAA,SAAA,CAAA;AAAA,WACA,EAAI,EAAA;AACX,IAAQ,OAAA,CAAA,KAAA,CAAM,CAAiB,cAAA,EAAA,EAAE,CAA2B,yBAAA,CAAA,CAAA,CAAA;AAC5D,IAAA,OAAO,6BAA8B,EAAA,CAAA;AAAA,GACvC;AACF,CAAA;AAEA,eAAe,iCAAiC,eAAmD,EAAA;AAKjG,EAAI,IAAA;AACF,IAAM,MAAA,EAAE,SAAU,EAAA,GAAI,MAAM,kBAAA;AAAA,MAC1B,KAAA;AAAA,MAC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B,CAAA,CAAA;AAAA,GAChD;AACA,EAAM,MAAA,EAAE,YAAa,EAAA,GAAI,MAAM,kBAAA;AAAA,IAC7B,KAAA;AAAA,IACA,UAAA;AAAA,IACA;AAAA,MACE,EAAI,EAAA,gBAAA;AAAA,MACJ,IAAM,EAAA,aAAA;AAAA,MACN,KAAA;AAAA,KACF;AAAA,IACA,kBAAA,CAAmB,SAAS,cAAc,CAAA;AAAA,GAC5C,CAAA;AAEA,EAAO,OAAA,YAAA,CAAA;AACT;;;;"}
@@ -39,7 +39,7 @@ async function rechargeApiRequest(method, url, { id, query, data, headers } = {}
39
39
  "X-Recharge-Sdk-Fn": session.internalFnCall,
40
40
  ...appName ? { "X-Recharge-Sdk-App-Name": appName } : {},
41
41
  ...appVersion ? { "X-Recharge-Sdk-App-Version": appVersion } : {},
42
- "X-Recharge-Sdk-Version": "1.38.0",
42
+ "X-Recharge-Sdk-Version": "1.39.0",
43
43
  "X-Request-Id": session.internalRequestId,
44
44
  ...session.tmp_fn_identifier ? { "X-Recharge-Sdk-Fn-Identifier": session.tmp_fn_identifier } : {},
45
45
  ...headers ? headers : {}
package/dist/index.d.ts CHANGED
@@ -1876,6 +1876,8 @@ interface ProductSearchParams_2022_06 extends ListParams<SortBy> {
1876
1876
  product_title?: string;
1877
1877
  /** Accept up to 256 characters. Should search on the following fields: title, description, tags, variants[].sku, variants[].title. */
1878
1878
  search_term?: string;
1879
+ /** Accepts an external_product_id. The product will be used as reference for smart select. */
1880
+ smart_select_product_id?: string;
1879
1881
  /** Perform substring match on variants[].sku */
1880
1882
  sku?: string;
1881
1883
  /** Perform substring match on tags */
@@ -2681,7 +2683,7 @@ interface CustomerPortalSettings {
2681
2683
  * */
2682
2684
  collection_ids: number[];
2683
2685
  /** The filter of products that are available to create new subscriptions. */
2684
- available_products: 'all' | 'specific_recharge_collections' | 'specific_plan_types';
2686
+ available_products: 'all' | 'specific_recharge_collections' | 'specific_plan_types' | 'smart_select';
2685
2687
  /** Settings related to backup payment methods */
2686
2688
  backup_payment_methods_settings: {
2687
2689
  backup_payment_methods_enabled: boolean;
@@ -1,4 +1,4 @@
1
- // recharge-client-1.38.0.min.js | MIT License | © Recharge Inc.
1
+ // recharge-client-1.39.0.min.js | MIT License | © Recharge Inc.
2
2
  (function(U,be){typeof exports=="object"&&typeof module<"u"?module.exports=be():typeof define=="function"&&define.amd?define(be):(U=typeof globalThis<"u"?globalThis:U||self,U.recharge=be())})(this,function(){"use strict";var U=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function be(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}function Zs(r){if(r.__esModule)return r;var e=r.default;if(typeof e=="function"){var t=function n(){return this instanceof n?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};t.prototype=e.prototype}else t={};return Object.defineProperty(t,"__esModule",{value:!0}),Object.keys(r).forEach(function(n){var i=Object.getOwnPropertyDescriptor(r,n);Object.defineProperty(t,n,i.get?i:{enumerable:!0,get:function(){return r[n]}})}),t}var q=typeof globalThis<"u"&&globalThis||typeof self<"u"&&self||typeof q<"u"&&q,G={searchParams:"URLSearchParams"in q,iterable:"Symbol"in q&&"iterator"in Symbol,blob:"FileReader"in q&&"Blob"in q&&function(){try{return new Blob,!0}catch{return!1}}(),formData:"FormData"in q,arrayBuffer:"ArrayBuffer"in q};function Js(r){return r&&DataView.prototype.isPrototypeOf(r)}if(G.arrayBuffer)var Qs=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],ef=ArrayBuffer.isView||function(r){return r&&Qs.indexOf(Object.prototype.toString.call(r))>-1};function hr(r){if(typeof r!="string"&&(r=String(r)),/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(r)||r==="")throw new TypeError('Invalid character in header field name: "'+r+'"');return r.toLowerCase()}function nn(r){return typeof r!="string"&&(r=String(r)),r}function an(r){var e={next:function(){var t=r.shift();return{done:t===void 0,value:t}}};return G.iterable&&(e[Symbol.iterator]=function(){return e}),e}function C(r){this.map={},r instanceof C?r.forEach(function(e,t){this.append(t,e)},this):Array.isArray(r)?r.forEach(function(e){this.append(e[0],e[1])},this):r&&Object.getOwnPropertyNames(r).forEach(function(e){this.append(e,r[e])},this)}C.prototype.append=function(r,e){r=hr(r),e=nn(e);var t=this.map[r];this.map[r]=t?t+", "+e:e},C.prototype.delete=function(r){delete this.map[hr(r)]},C.prototype.get=function(r){return r=hr(r),this.has(r)?this.map[r]:null},C.prototype.has=function(r){return this.map.hasOwnProperty(hr(r))},C.prototype.set=function(r,e){this.map[hr(r)]=nn(e)},C.prototype.forEach=function(r,e){for(var t in this.map)this.map.hasOwnProperty(t)&&r.call(e,this.map[t],t,this)},C.prototype.keys=function(){var r=[];return this.forEach(function(e,t){r.push(t)}),an(r)},C.prototype.values=function(){var r=[];return this.forEach(function(e){r.push(e)}),an(r)},C.prototype.entries=function(){var r=[];return this.forEach(function(e,t){r.push([t,e])}),an(r)},G.iterable&&(C.prototype[Symbol.iterator]=C.prototype.entries);function on(r){if(r.bodyUsed)return Promise.reject(new TypeError("Already read"));r.bodyUsed=!0}function qi(r){return new Promise(function(e,t){r.onload=function(){e(r.result)},r.onerror=function(){t(r.error)}})}function rf(r){var e=new FileReader,t=qi(e);return e.readAsArrayBuffer(r),t}function tf(r){var e=new FileReader,t=qi(e);return e.readAsText(r),t}function nf(r){for(var e=new Uint8Array(r),t=new Array(e.length),n=0;n<e.length;n++)t[n]=String.fromCharCode(e[n]);return t.join("")}function Li(r){if(r.slice)return r.slice(0);var e=new Uint8Array(r.byteLength);return e.set(new Uint8Array(r)),e.buffer}function ki(){return this.bodyUsed=!1,this._initBody=function(r){this.bodyUsed=this.bodyUsed,this._bodyInit=r,r?typeof r=="string"?this._bodyText=r:G.blob&&Blob.prototype.isPrototypeOf(r)?this._bodyBlob=r:G.formData&&FormData.prototype.isPrototypeOf(r)?this._bodyFormData=r:G.searchParams&&URLSearchParams.prototype.isPrototypeOf(r)?this._bodyText=r.toString():G.arrayBuffer&&G.blob&&Js(r)?(this._bodyArrayBuffer=Li(r.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):G.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(r)||ef(r))?this._bodyArrayBuffer=Li(r):this._bodyText=r=Object.prototype.toString.call(r):this._bodyText="",this.headers.get("content-type")||(typeof r=="string"?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):G.searchParams&&URLSearchParams.prototype.isPrototypeOf(r)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},G.blob&&(this.blob=function(){var r=on(this);if(r)return r;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 r=on(this);return r||(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(rf)}),this.text=function(){var r=on(this);if(r)return r;if(this._bodyBlob)return tf(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(nf(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},G.formData&&(this.formData=function(){return this.text().then(uf)}),this.json=function(){return this.text().then(JSON.parse)},this}var af=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function of(r){var e=r.toUpperCase();return af.indexOf(e)>-1?e:r}function $e(r,e){if(!(this instanceof $e))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');e=e||{};var t=e.body;if(r instanceof $e){if(r.bodyUsed)throw new TypeError("Already read");this.url=r.url,this.credentials=r.credentials,e.headers||(this.headers=new C(r.headers)),this.method=r.method,this.mode=r.mode,this.signal=r.signal,!t&&r._bodyInit!=null&&(t=r._bodyInit,r.bodyUsed=!0)}else this.url=String(r);if(this.credentials=e.credentials||this.credentials||"same-origin",(e.headers||!this.headers)&&(this.headers=new C(e.headers)),this.method=of(e.method||this.method||"GET"),this.mode=e.mode||this.mode||null,this.signal=e.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")&&(e.cache==="no-store"||e.cache==="no-cache")){var n=/([?&])_=[^&]*/;if(n.test(this.url))this.url=this.url.replace(n,"$1_="+new Date().getTime());else{var i=/\?/;this.url+=(i.test(this.url)?"&":"?")+"_="+new Date().getTime()}}}$e.prototype.clone=function(){return new $e(this,{body:this._bodyInit})};function uf(r){var e=new FormData;return r.trim().split("&").forEach(function(t){if(t){var n=t.split("="),i=n.shift().replace(/\+/g," "),a=n.join("=").replace(/\+/g," ");e.append(decodeURIComponent(i),decodeURIComponent(a))}}),e}function sf(r){var e=new C,t=r.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 i=n.split(":"),a=i.shift().trim();if(a){var o=i.join(":").trim();e.append(a,o)}}),e}ki.call($e.prototype);function Y(r,e){if(!(this instanceof Y))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');e||(e={}),this.type="default",this.status=e.status===void 0?200:e.status,this.ok=this.status>=200&&this.status<300,this.statusText=e.statusText===void 0?"":""+e.statusText,this.headers=new C(e.headers),this.url=e.url||"",this._initBody(r)}ki.call(Y.prototype),Y.prototype.clone=function(){return new Y(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new C(this.headers),url:this.url})},Y.error=function(){var r=new Y(null,{status:0,statusText:""});return r.type="error",r};var ff=[301,302,303,307,308];Y.redirect=function(r,e){if(ff.indexOf(e)===-1)throw new RangeError("Invalid status code");return new Y(null,{status:e,headers:{location:r}})};var Ee=q.DOMException;try{new Ee}catch{Ee=function(e,t){this.message=e,this.name=t;var n=Error(e);this.stack=n.stack},Ee.prototype=Object.create(Error.prototype),Ee.prototype.constructor=Ee}function ji(r,e){return new Promise(function(t,n){var i=new $e(r,e);if(i.signal&&i.signal.aborted)return n(new Ee("Aborted","AbortError"));var a=new XMLHttpRequest;function o(){a.abort()}a.onload=function(){var f={status:a.status,statusText:a.statusText,headers:sf(a.getAllResponseHeaders()||"")};f.url="responseURL"in a?a.responseURL:f.headers.get("X-Request-URL");var c="response"in a?a.response:a.responseText;setTimeout(function(){t(new Y(c,f))},0)},a.onerror=function(){setTimeout(function(){n(new TypeError("Network request failed"))},0)},a.ontimeout=function(){setTimeout(function(){n(new TypeError("Network request failed"))},0)},a.onabort=function(){setTimeout(function(){n(new Ee("Aborted","AbortError"))},0)};function u(f){try{return f===""&&q.location.href?q.location.href:f}catch{return f}}a.open(i.method,u(i.url),!0),i.credentials==="include"?a.withCredentials=!0:i.credentials==="omit"&&(a.withCredentials=!1),"responseType"in a&&(G.blob?a.responseType="blob":G.arrayBuffer&&i.headers.get("Content-Type")&&i.headers.get("Content-Type").indexOf("application/octet-stream")!==-1&&(a.responseType="arraybuffer")),e&&typeof e.headers=="object"&&!(e.headers instanceof C)?Object.getOwnPropertyNames(e.headers).forEach(function(f){a.setRequestHeader(f,nn(e.headers[f]))}):i.headers.forEach(function(f,c){a.setRequestHeader(c,f)}),i.signal&&(i.signal.addEventListener("abort",o),a.onreadystatechange=function(){a.readyState===4&&i.signal.removeEventListener("abort",o)}),a.send(typeof i._bodyInit>"u"?null:i._bodyInit)})}ji.polyfill=!0,q.fetch||(q.fetch=ji,q.Headers=C,q.Request=$e,q.Response=Y),self.fetch.bind(self);let cf="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict",Vi=(r=21)=>{let e="",t=r;for(;t--;)e+=cf[Math.random()*64|0];return e};var lf=function(){if(typeof Symbol!="function"||typeof Object.getOwnPropertySymbols!="function")return!1;if(typeof Symbol.iterator=="symbol")return!0;var e={},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 i=42;e[t]=i;for(t in e)return!1;if(typeof Object.keys=="function"&&Object.keys(e).length!==0||typeof Object.getOwnPropertyNames=="function"&&Object.getOwnPropertyNames(e).length!==0)return!1;var a=Object.getOwnPropertySymbols(e);if(a.length!==1||a[0]!==t||!Object.prototype.propertyIsEnumerable.call(e,t))return!1;if(typeof Object.getOwnPropertyDescriptor=="function"){var o=Object.getOwnPropertyDescriptor(e,t);if(o.value!==i||o.enumerable!==!0)return!1}return!0},Gi=typeof Symbol<"u"&&Symbol,hf=lf,df=function(){return typeof Gi!="function"||typeof Symbol!="function"||typeof Gi("foo")!="symbol"||typeof Symbol("bar")!="symbol"?!1:hf()},Hi={foo:{}},pf=Object,yf=function(){return{__proto__:Hi}.foo===Hi.foo&&!({__proto__:null}instanceof pf)},gf="Function.prototype.bind called on incompatible ",un=Array.prototype.slice,vf=Object.prototype.toString,_f="[object Function]",mf=function(e){var t=this;if(typeof t!="function"||vf.call(t)!==_f)throw new TypeError(gf+t);for(var n=un.call(arguments,1),i,a=function(){if(this instanceof i){var l=t.apply(this,n.concat(un.call(arguments)));return Object(l)===l?l:this}else return t.apply(e,n.concat(un.call(arguments)))},o=Math.max(0,t.length-n.length),u=[],f=0;f<o;f++)u.push("$"+f);if(i=Function("binder","return function ("+u.join(",")+"){ return binder.apply(this,arguments); }")(a),t.prototype){var c=function(){};c.prototype=t.prototype,i.prototype=new c,c.prototype=null}return i},wf=mf,sn=Function.prototype.bind||wf,bf=sn,$f=bf.call(Function.call,Object.prototype.hasOwnProperty),x,Le=SyntaxError,Wi=Function,ke=TypeError,fn=function(r){try{return Wi('"use strict"; return ('+r+").constructor;")()}catch{}},Ae=Object.getOwnPropertyDescriptor;if(Ae)try{Ae({},"")}catch{Ae=null}var cn=function(){throw new ke},Ef=Ae?function(){try{return arguments.callee,cn}catch{try{return Ae(arguments,"callee").get}catch{return cn}}}():cn,je=df(),Af=yf(),N=Object.getPrototypeOf||(Af?function(r){return r.__proto__}:null),Ve={},Sf=typeof Uint8Array>"u"||!N?x:N(Uint8Array),Se={"%AggregateError%":typeof AggregateError>"u"?x:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer>"u"?x:ArrayBuffer,"%ArrayIteratorPrototype%":je&&N?N([][Symbol.iterator]()):x,"%AsyncFromSyncIteratorPrototype%":x,"%AsyncFunction%":Ve,"%AsyncGenerator%":Ve,"%AsyncGeneratorFunction%":Ve,"%AsyncIteratorPrototype%":Ve,"%Atomics%":typeof Atomics>"u"?x:Atomics,"%BigInt%":typeof BigInt>"u"?x:BigInt,"%BigInt64Array%":typeof BigInt64Array>"u"?x:BigInt64Array,"%BigUint64Array%":typeof BigUint64Array>"u"?x:BigUint64Array,"%Boolean%":Boolean,"%DataView%":typeof DataView>"u"?x:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":Error,"%eval%":eval,"%EvalError%":EvalError,"%Float32Array%":typeof Float32Array>"u"?x:Float32Array,"%Float64Array%":typeof Float64Array>"u"?x:Float64Array,"%FinalizationRegistry%":typeof FinalizationRegistry>"u"?x:FinalizationRegistry,"%Function%":Wi,"%GeneratorFunction%":Ve,"%Int8Array%":typeof Int8Array>"u"?x:Int8Array,"%Int16Array%":typeof Int16Array>"u"?x:Int16Array,"%Int32Array%":typeof Int32Array>"u"?x:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":je&&N?N(N([][Symbol.iterator]())):x,"%JSON%":typeof JSON=="object"?JSON:x,"%Map%":typeof Map>"u"?x:Map,"%MapIteratorPrototype%":typeof Map>"u"||!je||!N?x:N(new Map()[Symbol.iterator]()),"%Math%":Math,"%Number%":Number,"%Object%":Object,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise>"u"?x:Promise,"%Proxy%":typeof Proxy>"u"?x:Proxy,"%RangeError%":RangeError,"%ReferenceError%":ReferenceError,"%Reflect%":typeof Reflect>"u"?x:Reflect,"%RegExp%":RegExp,"%Set%":typeof Set>"u"?x:Set,"%SetIteratorPrototype%":typeof Set>"u"||!je||!N?x:N(new Set()[Symbol.iterator]()),"%SharedArrayBuffer%":typeof SharedArrayBuffer>"u"?x:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":je&&N?N(""[Symbol.iterator]()):x,"%Symbol%":je?Symbol:x,"%SyntaxError%":Le,"%ThrowTypeError%":Ef,"%TypedArray%":Sf,"%TypeError%":ke,"%Uint8Array%":typeof Uint8Array>"u"?x:Uint8Array,"%Uint8ClampedArray%":typeof Uint8ClampedArray>"u"?x:Uint8ClampedArray,"%Uint16Array%":typeof Uint16Array>"u"?x:Uint16Array,"%Uint32Array%":typeof Uint32Array>"u"?x:Uint32Array,"%URIError%":URIError,"%WeakMap%":typeof WeakMap>"u"?x:WeakMap,"%WeakRef%":typeof WeakRef>"u"?x:WeakRef,"%WeakSet%":typeof WeakSet>"u"?x:WeakSet};if(N)try{null.error}catch(r){var Of=N(N(r));Se["%Error.prototype%"]=Of}var If=function r(e){var t;if(e==="%AsyncFunction%")t=fn("async function () {}");else if(e==="%GeneratorFunction%")t=fn("function* () {}");else if(e==="%AsyncGeneratorFunction%")t=fn("async function* () {}");else if(e==="%AsyncGenerator%"){var n=r("%AsyncGeneratorFunction%");n&&(t=n.prototype)}else if(e==="%AsyncIteratorPrototype%"){var i=r("%AsyncGenerator%");i&&N&&(t=N(i.prototype))}return Se[e]=t,t},Xi={"%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"]},dr=sn,zr=$f,Pf=dr.call(Function.call,Array.prototype.concat),xf=dr.call(Function.apply,Array.prototype.splice),zi=dr.call(Function.call,String.prototype.replace),Yr=dr.call(Function.call,String.prototype.slice),Tf=dr.call(Function.call,RegExp.prototype.exec),Rf=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,Ff=/\\(\\)?/g,Mf=function(e){var t=Yr(e,0,1),n=Yr(e,-1);if(t==="%"&&n!=="%")throw new Le("invalid intrinsic syntax, expected closing `%`");if(n==="%"&&t!=="%")throw new Le("invalid intrinsic syntax, expected opening `%`");var i=[];return zi(e,Rf,function(a,o,u,f){i[i.length]=u?zi(f,Ff,"$1"):o||a}),i},Df=function(e,t){var n=e,i;if(zr(Xi,n)&&(i=Xi[n],n="%"+i[0]+"%"),zr(Se,n)){var a=Se[n];if(a===Ve&&(a=If(n)),typeof a>"u"&&!t)throw new ke("intrinsic "+e+" exists, but is not available. Please file an issue!");return{alias:i,name:n,value:a}}throw new Le("intrinsic "+e+" does not exist!")},ln=function(e,t){if(typeof e!="string"||e.length===0)throw new ke("intrinsic name must be a non-empty string");if(arguments.length>1&&typeof t!="boolean")throw new ke('"allowMissing" argument must be a boolean');if(Tf(/^%?[^%]*%?$/,e)===null)throw new Le("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var n=Mf(e),i=n.length>0?n[0]:"",a=Df("%"+i+"%",t),o=a.name,u=a.value,f=!1,c=a.alias;c&&(i=c[0],xf(n,Pf([0,1],c)));for(var l=1,s=!0;l<n.length;l+=1){var h=n[l],y=Yr(h,0,1),w=Yr(h,-1);if((y==='"'||y==="'"||y==="`"||w==='"'||w==="'"||w==="`")&&y!==w)throw new Le("property names with quotes must have matching quotes");if((h==="constructor"||!s)&&(f=!0),i+="."+h,o="%"+i+"%",zr(Se,o))u=Se[o];else if(u!=null){if(!(h in u)){if(!t)throw new ke("base intrinsic for "+e+" exists, but the property is not available.");return}if(Ae&&l+1>=n.length){var S=Ae(u,h);s=!!S,s&&"get"in S&&!("originalValue"in S.get)?u=S.get:u=u[h]}else s=zr(u,h),u=u[h];s&&!f&&(Se[o]=u)}}return u},Yi={exports:{}};(function(r){var e=sn,t=ln,n=t("%Function.prototype.apply%"),i=t("%Function.prototype.call%"),a=t("%Reflect.apply%",!0)||e.call(i,n),o=t("%Object.getOwnPropertyDescriptor%",!0),u=t("%Object.defineProperty%",!0),f=t("%Math.max%");if(u)try{u({},"a",{value:1})}catch{u=null}r.exports=function(s){var h=a(e,i,arguments);if(o&&u){var y=o(h,"length");y.configurable&&u(h,"length",{value:1+f(0,s.length-(arguments.length-1))})}return h};var c=function(){return a(e,n,arguments)};u?u(r.exports,"apply",{value:c}):r.exports.apply=c})(Yi);var Cf=Yi.exports,Ki=ln,Zi=Cf,Nf=Zi(Ki("String.prototype.indexOf")),Bf=function(e,t){var n=Ki(e,!!t);return typeof n=="function"&&Nf(e,".prototype.")>-1?Zi(n):n},Ge=typeof global<"u"?global:typeof self<"u"?self:typeof window<"u"?window:{},K=[],X=[],Uf=typeof Uint8Array<"u"?Uint8Array:Array,hn=!1;function Ji(){hn=!0;for(var r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",e=0,t=r.length;e<t;++e)K[e]=r[e],X[r.charCodeAt(e)]=e;X["-".charCodeAt(0)]=62,X["_".charCodeAt(0)]=63}function qf(r){hn||Ji();var e,t,n,i,a,o,u=r.length;if(u%4>0)throw new Error("Invalid string. Length must be a multiple of 4");a=r[u-2]==="="?2:r[u-1]==="="?1:0,o=new Uf(u*3/4-a),n=a>0?u-4:u;var f=0;for(e=0,t=0;e<n;e+=4,t+=3)i=X[r.charCodeAt(e)]<<18|X[r.charCodeAt(e+1)]<<12|X[r.charCodeAt(e+2)]<<6|X[r.charCodeAt(e+3)],o[f++]=i>>16&255,o[f++]=i>>8&255,o[f++]=i&255;return a===2?(i=X[r.charCodeAt(e)]<<2|X[r.charCodeAt(e+1)]>>4,o[f++]=i&255):a===1&&(i=X[r.charCodeAt(e)]<<10|X[r.charCodeAt(e+1)]<<4|X[r.charCodeAt(e+2)]>>2,o[f++]=i>>8&255,o[f++]=i&255),o}function Lf(r){return K[r>>18&63]+K[r>>12&63]+K[r>>6&63]+K[r&63]}function kf(r,e,t){for(var n,i=[],a=e;a<t;a+=3)n=(r[a]<<16)+(r[a+1]<<8)+r[a+2],i.push(Lf(n));return i.join("")}function Qi(r){hn||Ji();for(var e,t=r.length,n=t%3,i="",a=[],o=16383,u=0,f=t-n;u<f;u+=o)a.push(kf(r,u,u+o>f?f:u+o));return n===1?(e=r[t-1],i+=K[e>>2],i+=K[e<<4&63],i+="=="):n===2&&(e=(r[t-2]<<8)+r[t-1],i+=K[e>>10],i+=K[e>>4&63],i+=K[e<<2&63],i+="="),a.push(i),a.join("")}function Kr(r,e,t,n,i){var a,o,u=i*8-n-1,f=(1<<u)-1,c=f>>1,l=-7,s=t?i-1:0,h=t?-1:1,y=r[e+s];for(s+=h,a=y&(1<<-l)-1,y>>=-l,l+=u;l>0;a=a*256+r[e+s],s+=h,l-=8);for(o=a&(1<<-l)-1,a>>=-l,l+=n;l>0;o=o*256+r[e+s],s+=h,l-=8);if(a===0)a=1-c;else{if(a===f)return o?NaN:(y?-1:1)*(1/0);o=o+Math.pow(2,n),a=a-c}return(y?-1:1)*o*Math.pow(2,a-n)}function ea(r,e,t,n,i,a){var o,u,f,c=a*8-i-1,l=(1<<c)-1,s=l>>1,h=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,y=n?0:a-1,w=n?1:-1,S=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(u=isNaN(e)?1:0,o=l):(o=Math.floor(Math.log(e)/Math.LN2),e*(f=Math.pow(2,-o))<1&&(o--,f*=2),o+s>=1?e+=h/f:e+=h*Math.pow(2,1-s),e*f>=2&&(o++,f/=2),o+s>=l?(u=0,o=l):o+s>=1?(u=(e*f-1)*Math.pow(2,i),o=o+s):(u=e*Math.pow(2,s-1)*Math.pow(2,i),o=0));i>=8;r[t+y]=u&255,y+=w,u/=256,i-=8);for(o=o<<i|u,c+=i;c>0;r[t+y]=o&255,y+=w,o/=256,c-=8);r[t+y-w]|=S*128}var jf={}.toString,ra=Array.isArray||function(r){return jf.call(r)=="[object Array]"};/*!
4
4
  * The buffer module from node.js, for the browser.
@@ -17,10 +17,10 @@
17
17
  `)+" "+t[1]:t[0]+e+" "+r.join(", ")+" "+t[1]}function bn(r){return Array.isArray(r)}function ot(r){return typeof r=="boolean"}function pr(r){return r===null}function Ea(r){return r==null}function $n(r){return typeof r=="number"}function yr(r){return typeof r=="string"}function Aa(r){return typeof r=="symbol"}function Q(r){return r===void 0}function gr(r){return xe(r)&&En(r)==="[object RegExp]"}function xe(r){return typeof r=="object"&&r!==null}function ut(r){return xe(r)&&En(r)==="[object Date]"}function vr(r){return xe(r)&&(En(r)==="[object Error]"||r instanceof Error)}function _r(r){return typeof r=="function"}function Sa(r){return r===null||typeof r=="boolean"||typeof r=="number"||typeof r=="string"||typeof r=="symbol"||typeof r>"u"}function Oa(r){return p.isBuffer(r)}function En(r){return Object.prototype.toString.call(r)}function An(r){return r<10?"0"+r.toString(10):r.toString(10)}var Yc=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function Kc(){var r=new Date,e=[An(r.getHours()),An(r.getMinutes()),An(r.getSeconds())].join(":");return[r.getDate(),Yc[r.getMonth()],e].join(" ")}function Ia(){console.log("%s - %s",Kc(),nt.apply(null,arguments))}function Sn(r,e){if(!e||!xe(e))return r;for(var t=Object.keys(e),n=t.length;n--;)r[t[n]]=e[t[n]];return r}function Pa(r,e){return Object.prototype.hasOwnProperty.call(r,e)}var Te=typeof Symbol<"u"?Symbol("util.promisify.custom"):void 0;function On(r){if(typeof r!="function")throw new TypeError('The "original" argument must be of type Function');if(Te&&r[Te]){var e=r[Te];if(typeof e!="function")throw new TypeError('The "util.promisify.custom" argument must be of type Function');return Object.defineProperty(e,Te,{value:e,enumerable:!1,writable:!1,configurable:!0}),e}function e(){for(var t,n,i=new Promise(function(u,f){t=u,n=f}),a=[],o=0;o<arguments.length;o++)a.push(arguments[o]);a.push(function(u,f){u?n(u):t(f)});try{r.apply(this,a)}catch(u){n(u)}return i}return Object.setPrototypeOf(e,Object.getPrototypeOf(r)),Te&&Object.defineProperty(e,Te,{value:e,enumerable:!1,writable:!1,configurable:!0}),Object.defineProperties(e,ba(r))}On.custom=Te;function Zc(r,e){if(!r){var t=new Error("Promise was rejected with a falsy value");t.reason=r,r=t}return e(r)}function xa(r){if(typeof r!="function")throw new TypeError('The "original" argument must be of type Function');function e(){for(var t=[],n=0;n<arguments.length;n++)t.push(arguments[n]);var i=t.pop();if(typeof i!="function")throw new TypeError("The last argument must be of type Function");var a=this,o=function(){return i.apply(a,arguments)};r.apply(this,t).then(function(u){Xe.nextTick(o.bind(null,null,u))},function(u){Xe.nextTick(Zc.bind(null,u,o))})}return Object.setPrototypeOf(e,Object.getPrototypeOf(r)),Object.defineProperties(e,ba(r)),e}var Jc={inherits:wa,_extend:Sn,log:Ia,isBuffer:Oa,isPrimitive:Sa,isFunction:_r,isError:vr,isDate:ut,isObject:xe,isRegExp:gr,isUndefined:Q,isSymbol:Aa,isString:yr,isNumber:$n,isNullOrUndefined:Ea,isNull:pr,isBoolean:ot,isArray:bn,inspect:J,deprecate:vn,format:nt,debuglog:$a,promisify:On,callbackify:xa},Qc=Object.freeze({__proto__:null,_extend:Sn,callbackify:xa,debuglog:$a,default:Jc,deprecate:vn,format:nt,inherits:wa,inspect:J,isArray:bn,isBoolean:ot,isBuffer:Oa,isDate:ut,isError:vr,isFunction:_r,isNull:pr,isNullOrUndefined:Ea,isNumber:$n,isObject:xe,isPrimitive:Sa,isRegExp:gr,isString:yr,isSymbol:Aa,isUndefined:Q,log:Ia,promisify:On}),el=Zs(Qc),rl=el.inspect,In=typeof Map=="function"&&Map.prototype,Pn=Object.getOwnPropertyDescriptor&&In?Object.getOwnPropertyDescriptor(Map.prototype,"size"):null,st=In&&Pn&&typeof Pn.get=="function"?Pn.get:null,Ta=In&&Map.prototype.forEach,xn=typeof Set=="function"&&Set.prototype,Tn=Object.getOwnPropertyDescriptor&&xn?Object.getOwnPropertyDescriptor(Set.prototype,"size"):null,ft=xn&&Tn&&typeof Tn.get=="function"?Tn.get:null,Ra=xn&&Set.prototype.forEach,tl=typeof WeakMap=="function"&&WeakMap.prototype,mr=tl?WeakMap.prototype.has:null,nl=typeof WeakSet=="function"&&WeakSet.prototype,wr=nl?WeakSet.prototype.has:null,il=typeof WeakRef=="function"&&WeakRef.prototype,Fa=il?WeakRef.prototype.deref:null,al=Boolean.prototype.valueOf,ol=Object.prototype.toString,ul=Function.prototype.toString,sl=String.prototype.match,Rn=String.prototype.slice,de=String.prototype.replace,fl=String.prototype.toUpperCase,Ma=String.prototype.toLowerCase,Da=RegExp.prototype.test,Ca=Array.prototype.concat,ee=Array.prototype.join,cl=Array.prototype.slice,Na=Math.floor,Fn=typeof BigInt=="function"?BigInt.prototype.valueOf:null,Mn=Object.getOwnPropertySymbols,Dn=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Symbol.prototype.toString:null,ze=typeof Symbol=="function"&&typeof Symbol.iterator=="object",L=typeof Symbol=="function"&&Symbol.toStringTag&&(typeof Symbol.toStringTag===ze||"symbol")?Symbol.toStringTag:null,Ba=Object.prototype.propertyIsEnumerable,Ua=(typeof Reflect=="function"?Reflect.getPrototypeOf:Object.getPrototypeOf)||([].__proto__===Array.prototype?function(r){return r.__proto__}:null);function qa(r,e){if(r===1/0||r===-1/0||r!==r||r&&r>-1e3&&r<1e3||Da.call(/e/,e))return e;var t=/[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;if(typeof r=="number"){var n=r<0?-Na(-r):Na(r);if(n!==r){var i=String(n),a=Rn.call(e,i.length+1);return de.call(i,t,"$&_")+"."+de.call(de.call(a,/([0-9]{3})/g,"$&_"),/_$/,"")}}return de.call(e,t,"$&_")}var Cn=rl,La=Cn.custom,ka=Ga(La)?La:null,ll=function r(e,t,n,i){var a=t||{};if(pe(a,"quoteStyle")&&a.quoteStyle!=="single"&&a.quoteStyle!=="double")throw new TypeError('option "quoteStyle" must be "single" or "double"');if(pe(a,"maxStringLength")&&(typeof a.maxStringLength=="number"?a.maxStringLength<0&&a.maxStringLength!==1/0:a.maxStringLength!==null))throw new TypeError('option "maxStringLength", if provided, must be a positive integer, Infinity, or `null`');var o=pe(a,"customInspect")?a.customInspect:!0;if(typeof o!="boolean"&&o!=="symbol")throw new TypeError("option \"customInspect\", if provided, must be `true`, `false`, or `'symbol'`");if(pe(a,"indent")&&a.indent!==null&&a.indent!==" "&&!(parseInt(a.indent,10)===a.indent&&a.indent>0))throw new TypeError('option "indent" must be "\\t", an integer > 0, or `null`');if(pe(a,"numericSeparator")&&typeof a.numericSeparator!="boolean")throw new TypeError('option "numericSeparator", if provided, must be `true` or `false`');var u=a.numericSeparator;if(typeof e>"u")return"undefined";if(e===null)return"null";if(typeof e=="boolean")return e?"true":"false";if(typeof e=="string")return Wa(e,a);if(typeof e=="number"){if(e===0)return 1/0/e>0?"0":"-0";var f=String(e);return u?qa(e,f):f}if(typeof e=="bigint"){var c=String(e)+"n";return u?qa(e,c):c}var l=typeof a.depth>"u"?5:a.depth;if(typeof n>"u"&&(n=0),n>=l&&l>0&&typeof e=="object")return Nn(e)?"[Array]":"[Object]";var s=xl(a,n);if(typeof i>"u")i=[];else if(Ha(i,e)>=0)return"[Circular]";function h(z,me,lr){if(me&&(i=cl.call(i),i.push(me)),lr){var we={depth:a.depth};return pe(a,"quoteStyle")&&(we.quoteStyle=a.quoteStyle),r(z,we,n+1,i)}return r(z,a,n+1,i)}if(typeof e=="function"&&!Va(e)){var y=wl(e),w=ct(e,h);return"[Function"+(y?": "+y:" (anonymous)")+"]"+(w.length>0?" { "+ee.call(w,", ")+" }":"")}if(Ga(e)){var S=ze?de.call(String(e),/^(Symbol\(.*\))_[^)]*$/,"$1"):Dn.call(e);return typeof e=="object"&&!ze?br(S):S}if(Ol(e)){for(var O="<"+Ma.call(String(e.nodeName)),b=e.attributes||[],E=0;E<b.length;E++)O+=" "+b[E].name+"="+ja(hl(b[E].value),"double",a);return O+=">",e.childNodes&&e.childNodes.length&&(O+="..."),O+="</"+Ma.call(String(e.nodeName))+">",O}if(Nn(e)){if(e.length===0)return"[]";var d=ct(e,h);return s&&!Pl(d)?"["+Un(d,s)+"]":"[ "+ee.call(d,", ")+" ]"}if(pl(e)){var I=ct(e,h);return!("cause"in Error.prototype)&&"cause"in e&&!Ba.call(e,"cause")?"{ ["+String(e)+"] "+ee.call(Ca.call("[cause]: "+h(e.cause),I),", ")+" }":I.length===0?"["+String(e)+"]":"{ ["+String(e)+"] "+ee.call(I,", ")+" }"}if(typeof e=="object"&&o){if(ka&&typeof e[ka]=="function"&&Cn)return Cn(e,{depth:l-n});if(o!=="symbol"&&typeof e.inspect=="function")return e.inspect()}if(bl(e)){var T=[];return Ta&&Ta.call(e,function(z,me){T.push(h(me,e,!0)+" => "+h(z,e))}),Xa("Map",st.call(e),T,s)}if(Al(e)){var F=[];return Ra&&Ra.call(e,function(z){F.push(h(z,e))}),Xa("Set",ft.call(e),F,s)}if($l(e))return Bn("WeakMap");if(Sl(e))return Bn("WeakSet");if(El(e))return Bn("WeakRef");if(gl(e))return br(h(Number(e)));if(_l(e))return br(h(Fn.call(e)));if(vl(e))return br(al.call(e));if(yl(e))return br(h(String(e)));if(!dl(e)&&!Va(e)){var m=ct(e,h),g=Ua?Ua(e)===Object.prototype:e instanceof Object||e.constructor===Object,v=e instanceof Object?"":"null prototype",A=!g&&L&&Object(e)===e&&L in e?Rn.call(ye(e),8,-1):v?"Object":"",P=g||typeof e.constructor!="function"?"":e.constructor.name?e.constructor.name+" ":"",M=P+(A||v?"["+ee.call(Ca.call([],A||[],v||[]),": ")+"] ":"");return m.length===0?M+"{}":s?M+"{"+Un(m,s)+"}":M+"{ "+ee.call(m,", ")+" }"}return String(e)};function ja(r,e,t){var n=(t.quoteStyle||e)==="double"?'"':"'";return n+r+n}function hl(r){return de.call(String(r),/"/g,"&quot;")}function Nn(r){return ye(r)==="[object Array]"&&(!L||!(typeof r=="object"&&L in r))}function dl(r){return ye(r)==="[object Date]"&&(!L||!(typeof r=="object"&&L in r))}function Va(r){return ye(r)==="[object RegExp]"&&(!L||!(typeof r=="object"&&L in r))}function pl(r){return ye(r)==="[object Error]"&&(!L||!(typeof r=="object"&&L in r))}function yl(r){return ye(r)==="[object String]"&&(!L||!(typeof r=="object"&&L in r))}function gl(r){return ye(r)==="[object Number]"&&(!L||!(typeof r=="object"&&L in r))}function vl(r){return ye(r)==="[object Boolean]"&&(!L||!(typeof r=="object"&&L in r))}function Ga(r){if(ze)return r&&typeof r=="object"&&r instanceof Symbol;if(typeof r=="symbol")return!0;if(!r||typeof r!="object"||!Dn)return!1;try{return Dn.call(r),!0}catch{}return!1}function _l(r){if(!r||typeof r!="object"||!Fn)return!1;try{return Fn.call(r),!0}catch{}return!1}var ml=Object.prototype.hasOwnProperty||function(r){return r in this};function pe(r,e){return ml.call(r,e)}function ye(r){return ol.call(r)}function wl(r){if(r.name)return r.name;var e=sl.call(ul.call(r),/^function\s*([\w$]+)/);return e?e[1]:null}function Ha(r,e){if(r.indexOf)return r.indexOf(e);for(var t=0,n=r.length;t<n;t++)if(r[t]===e)return t;return-1}function bl(r){if(!st||!r||typeof r!="object")return!1;try{st.call(r);try{ft.call(r)}catch{return!0}return r instanceof Map}catch{}return!1}function $l(r){if(!mr||!r||typeof r!="object")return!1;try{mr.call(r,mr);try{wr.call(r,wr)}catch{return!0}return r instanceof WeakMap}catch{}return!1}function El(r){if(!Fa||!r||typeof r!="object")return!1;try{return Fa.call(r),!0}catch{}return!1}function Al(r){if(!ft||!r||typeof r!="object")return!1;try{ft.call(r);try{st.call(r)}catch{return!0}return r instanceof Set}catch{}return!1}function Sl(r){if(!wr||!r||typeof r!="object")return!1;try{wr.call(r,wr);try{mr.call(r,mr)}catch{return!0}return r instanceof WeakSet}catch{}return!1}function Ol(r){return!r||typeof r!="object"?!1:typeof HTMLElement<"u"&&r instanceof HTMLElement?!0:typeof r.nodeName=="string"&&typeof r.getAttribute=="function"}function Wa(r,e){if(r.length>e.maxStringLength){var t=r.length-e.maxStringLength,n="... "+t+" more character"+(t>1?"s":"");return Wa(Rn.call(r,0,e.maxStringLength),e)+n}var i=de.call(de.call(r,/(['\\])/g,"\\$1"),/[\x00-\x1f]/g,Il);return ja(i,"single",e)}function Il(r){var e=r.charCodeAt(0),t={8:"b",9:"t",10:"n",12:"f",13:"r"}[e];return t?"\\"+t:"\\x"+(e<16?"0":"")+fl.call(e.toString(16))}function br(r){return"Object("+r+")"}function Bn(r){return r+" { ? }"}function Xa(r,e,t,n){var i=n?Un(t,n):ee.call(t,", ");return r+" ("+e+") {"+i+"}"}function Pl(r){for(var e=0;e<r.length;e++)if(Ha(r[e],`
18
18
  `)>=0)return!1;return!0}function xl(r,e){var t;if(r.indent===" ")t=" ";else if(typeof r.indent=="number"&&r.indent>0)t=ee.call(Array(r.indent+1)," ");else return null;return{base:t,prev:ee.call(Array(e+1),t)}}function Un(r,e){if(r.length===0)return"";var t=`
19
19
  `+e.prev+e.base;return t+ee.call(r,","+t)+`
20
- `+e.prev}function ct(r,e){var t=Nn(r),n=[];if(t){n.length=r.length;for(var i=0;i<r.length;i++)n[i]=pe(r,i)?e(r[i],r):""}var a=typeof Mn=="function"?Mn(r):[],o;if(ze){o={};for(var u=0;u<a.length;u++)o["$"+a[u]]=a[u]}for(var f in r)pe(r,f)&&(t&&String(Number(f))===f&&f<r.length||ze&&o["$"+f]instanceof Symbol||(Da.call(/[^\w$]/,f)?n.push(e(f,r)+": "+e(r[f],r)):n.push(f+": "+e(r[f],r))));if(typeof Mn=="function")for(var c=0;c<a.length;c++)Ba.call(r,a[c])&&n.push("["+e(a[c])+"]: "+e(r[a[c]],r));return n}var qn=ln,Ye=Bf,Tl=ll,Rl=qn("%TypeError%"),lt=qn("%WeakMap%",!0),ht=qn("%Map%",!0),Fl=Ye("WeakMap.prototype.get",!0),Ml=Ye("WeakMap.prototype.set",!0),Dl=Ye("WeakMap.prototype.has",!0),Cl=Ye("Map.prototype.get",!0),Nl=Ye("Map.prototype.set",!0),Bl=Ye("Map.prototype.has",!0),Ln=function(r,e){for(var t=r,n;(n=t.next)!==null;t=n)if(n.key===e)return t.next=n.next,n.next=r.next,r.next=n,n},Ul=function(r,e){var t=Ln(r,e);return t&&t.value},ql=function(r,e,t){var n=Ln(r,e);n?n.value=t:r.next={key:e,next:r.next,value:t}},Ll=function(r,e){return!!Ln(r,e)},kl=function(){var e,t,n,i={assert:function(a){if(!i.has(a))throw new Rl("Side channel does not contain "+Tl(a))},get:function(a){if(lt&&a&&(typeof a=="object"||typeof a=="function")){if(e)return Fl(e,a)}else if(ht){if(t)return Cl(t,a)}else if(n)return Ul(n,a)},has:function(a){if(lt&&a&&(typeof a=="object"||typeof a=="function")){if(e)return Dl(e,a)}else if(ht){if(t)return Bl(t,a)}else if(n)return Ll(n,a);return!1},set:function(a,o){lt&&a&&(typeof a=="object"||typeof a=="function")?(e||(e=new lt),Ml(e,a,o)):ht?(t||(t=new ht),Nl(t,a,o)):(n||(n={key:{},next:null}),ql(n,a,o))}};return i},jl=String.prototype.replace,Vl=/%20/g,kn={RFC1738:"RFC1738",RFC3986:"RFC3986"},za={default:kn.RFC3986,formatters:{RFC1738:function(r){return jl.call(r,Vl,"+")},RFC3986:function(r){return String(r)}},RFC1738:kn.RFC1738,RFC3986:kn.RFC3986},Gl=za,jn=Object.prototype.hasOwnProperty,Re=Array.isArray,re=function(){for(var r=[],e=0;e<256;++e)r.push("%"+((e<16?"0":"")+e.toString(16)).toUpperCase());return r}(),Hl=function(e){for(;e.length>1;){var t=e.pop(),n=t.obj[t.prop];if(Re(n)){for(var i=[],a=0;a<n.length;++a)typeof n[a]<"u"&&i.push(n[a]);t.obj[t.prop]=i}}},Ya=function(e,t){for(var n=t&&t.plainObjects?Object.create(null):{},i=0;i<e.length;++i)typeof e[i]<"u"&&(n[i]=e[i]);return n},Wl=function r(e,t,n){if(!t)return e;if(typeof t!="object"){if(Re(e))e.push(t);else if(e&&typeof e=="object")(n&&(n.plainObjects||n.allowPrototypes)||!jn.call(Object.prototype,t))&&(e[t]=!0);else return[e,t];return e}if(!e||typeof e!="object")return[e].concat(t);var i=e;return Re(e)&&!Re(t)&&(i=Ya(e,n)),Re(e)&&Re(t)?(t.forEach(function(a,o){if(jn.call(e,o)){var u=e[o];u&&typeof u=="object"&&a&&typeof a=="object"?e[o]=r(u,a,n):e.push(a)}else e[o]=a}),e):Object.keys(t).reduce(function(a,o){var u=t[o];return jn.call(a,o)?a[o]=r(a[o],u,n):a[o]=u,a},i)},Xl=function(e,t){return Object.keys(t).reduce(function(n,i){return n[i]=t[i],n},e)},zl=function(r,e,t){var n=r.replace(/\+/g," ");if(t==="iso-8859-1")return n.replace(/%[0-9a-f]{2}/gi,unescape);try{return decodeURIComponent(n)}catch{return n}},Yl=function(e,t,n,i,a){if(e.length===0)return e;var o=e;if(typeof e=="symbol"?o=Symbol.prototype.toString.call(e):typeof e!="string"&&(o=String(e)),n==="iso-8859-1")return escape(o).replace(/%u[0-9a-f]{4}/gi,function(l){return"%26%23"+parseInt(l.slice(2),16)+"%3B"});for(var u="",f=0;f<o.length;++f){var c=o.charCodeAt(f);if(c===45||c===46||c===95||c===126||c>=48&&c<=57||c>=65&&c<=90||c>=97&&c<=122||a===Gl.RFC1738&&(c===40||c===41)){u+=o.charAt(f);continue}if(c<128){u=u+re[c];continue}if(c<2048){u=u+(re[192|c>>6]+re[128|c&63]);continue}if(c<55296||c>=57344){u=u+(re[224|c>>12]+re[128|c>>6&63]+re[128|c&63]);continue}f+=1,c=65536+((c&1023)<<10|o.charCodeAt(f)&1023),u+=re[240|c>>18]+re[128|c>>12&63]+re[128|c>>6&63]+re[128|c&63]}return u},Kl=function(e){for(var t=[{obj:{o:e},prop:"o"}],n=[],i=0;i<t.length;++i)for(var a=t[i],o=a.obj[a.prop],u=Object.keys(o),f=0;f<u.length;++f){var c=u[f],l=o[c];typeof l=="object"&&l!==null&&n.indexOf(l)===-1&&(t.push({obj:o,prop:c}),n.push(l))}return Hl(t),e},Zl=function(e){return Object.prototype.toString.call(e)==="[object RegExp]"},Jl=function(e){return!e||typeof e!="object"?!1:!!(e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer(e))},Ql=function(e,t){return[].concat(e,t)},eh=function(e,t){if(Re(e)){for(var n=[],i=0;i<e.length;i+=1)n.push(t(e[i]));return n}return t(e)},rh={arrayToObject:Ya,assign:Xl,combine:Ql,compact:Kl,decode:zl,encode:Yl,isBuffer:Jl,isRegExp:Zl,maybeMap:eh,merge:Wl},Ka=kl,dt=rh,$r=za,th=Object.prototype.hasOwnProperty,Za={brackets:function(e){return e+"[]"},comma:"comma",indices:function(e,t){return e+"["+t+"]"},repeat:function(e){return e}},oe=Array.isArray,nh=Array.prototype.push,Ja=function(r,e){nh.apply(r,oe(e)?e:[e])},ih=Date.prototype.toISOString,Qa=$r.default,k={addQueryPrefix:!1,allowDots:!1,charset:"utf-8",charsetSentinel:!1,delimiter:"&",encode:!0,encoder:dt.encode,encodeValuesOnly:!1,format:Qa,formatter:$r.formatters[Qa],indices:!1,serializeDate:function(e){return ih.call(e)},skipNulls:!1,strictNullHandling:!1},ah=function(e){return typeof e=="string"||typeof e=="number"||typeof e=="boolean"||typeof e=="symbol"||typeof e=="bigint"},Vn={},oh=function r(e,t,n,i,a,o,u,f,c,l,s,h,y,w,S,O){for(var b=e,E=O,d=0,I=!1;(E=E.get(Vn))!==void 0&&!I;){var T=E.get(e);if(d+=1,typeof T<"u"){if(T===d)throw new RangeError("Cyclic object value");I=!0}typeof E.get(Vn)>"u"&&(d=0)}if(typeof f=="function"?b=f(t,b):b instanceof Date?b=s(b):n==="comma"&&oe(b)&&(b=dt.maybeMap(b,function(we){return we instanceof Date?s(we):we})),b===null){if(a)return u&&!w?u(t,k.encoder,S,"key",h):t;b=""}if(ah(b)||dt.isBuffer(b)){if(u){var F=w?t:u(t,k.encoder,S,"key",h);return[y(F)+"="+y(u(b,k.encoder,S,"value",h))]}return[y(t)+"="+y(String(b))]}var m=[];if(typeof b>"u")return m;var g;if(n==="comma"&&oe(b))w&&u&&(b=dt.maybeMap(b,u)),g=[{value:b.length>0?b.join(",")||null:void 0}];else if(oe(f))g=f;else{var v=Object.keys(b);g=c?v.sort(c):v}for(var A=i&&oe(b)&&b.length===1?t+"[]":t,P=0;P<g.length;++P){var M=g[P],z=typeof M=="object"&&typeof M.value<"u"?M.value:b[M];if(!(o&&z===null)){var me=oe(b)?typeof n=="function"?n(A,M):A:A+(l?"."+M:"["+M+"]");O.set(e,d);var lr=Ka();lr.set(Vn,O),Ja(m,r(z,me,n,i,a,o,n==="comma"&&w&&oe(b)?null:u,f,c,l,s,h,y,w,S,lr))}}return m},uh=function(e){if(!e)return k;if(e.encoder!==null&&typeof e.encoder<"u"&&typeof e.encoder!="function")throw new TypeError("Encoder has to be a function.");var t=e.charset||k.charset;if(typeof e.charset<"u"&&e.charset!=="utf-8"&&e.charset!=="iso-8859-1")throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var n=$r.default;if(typeof e.format<"u"){if(!th.call($r.formatters,e.format))throw new TypeError("Unknown format option provided.");n=e.format}var i=$r.formatters[n],a=k.filter;return(typeof e.filter=="function"||oe(e.filter))&&(a=e.filter),{addQueryPrefix:typeof e.addQueryPrefix=="boolean"?e.addQueryPrefix:k.addQueryPrefix,allowDots:typeof e.allowDots>"u"?k.allowDots:!!e.allowDots,charset:t,charsetSentinel:typeof e.charsetSentinel=="boolean"?e.charsetSentinel:k.charsetSentinel,delimiter:typeof e.delimiter>"u"?k.delimiter:e.delimiter,encode:typeof e.encode=="boolean"?e.encode:k.encode,encoder:typeof e.encoder=="function"?e.encoder:k.encoder,encodeValuesOnly:typeof e.encodeValuesOnly=="boolean"?e.encodeValuesOnly:k.encodeValuesOnly,filter:a,format:n,formatter:i,serializeDate:typeof e.serializeDate=="function"?e.serializeDate:k.serializeDate,skipNulls:typeof e.skipNulls=="boolean"?e.skipNulls:k.skipNulls,sort:typeof e.sort=="function"?e.sort:null,strictNullHandling:typeof e.strictNullHandling=="boolean"?e.strictNullHandling:k.strictNullHandling}},sh=function(r,e){var t=r,n=uh(e),i,a;typeof n.filter=="function"?(a=n.filter,t=a("",t)):oe(n.filter)&&(a=n.filter,i=a);var o=[];if(typeof t!="object"||t===null)return"";var u;e&&e.arrayFormat in Za?u=e.arrayFormat:e&&"indices"in e?u=e.indices?"indices":"repeat":u="indices";var f=Za[u];if(e&&"commaRoundTrip"in e&&typeof e.commaRoundTrip!="boolean")throw new TypeError("`commaRoundTrip` must be a boolean, or absent");var c=f==="comma"&&e&&e.commaRoundTrip;i||(i=Object.keys(t)),n.sort&&i.sort(n.sort);for(var l=Ka(),s=0;s<i.length;++s){var h=i[s];n.skipNulls&&t[h]===null||Ja(o,oh(t[h],h,f,c,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,l))}var y=o.join(n.delimiter),w=n.addQueryPrefix===!0?"?":"";return n.charsetSentinel&&(n.charset==="iso-8859-1"?w+="utf8=%26%2310003%3B&":w+="utf8=%E2%9C%93&"),y.length>0?w+y:""},fh=be(sh);let eo={storeIdentifier:"",environment:"prod"};function ch(r){eo=r}function W(){return eo}const lh=(r,e="")=>{switch(r){case"prod":return"https://api.rechargeapps.com";case"stage":return"https://api.stage.rechargeapps.com";case"preprod":case"prestage":return`${e}/api`}},hh=(r,e="")=>{switch(r){case"prod":return"https://admin.rechargeapps.com";case"stage":return"https://admin.stage.rechargeapps.com";case"preprod":case"prestage":return e}},dh=r=>{switch(r){case"prod":case"preprod":return"https://static.rechargecdn.com";case"stage":case"prestage":return"https://static.stage.rechargecdn.com"}},ph="/tools/recurring";class Er{constructor(e,t){this.name="RechargeRequestError",this.message=e,this.status=t}}function yh(r){return fh(r,{encode:!1,indices:!1,arrayFormat:"comma"})}function _(r,e){return{...r,internalFnCall:r.internalFnCall??e,internalRequestId:r.internalRequestId??Vi()}}async function pt(r,e,t={}){const n=W();return ue(r,`${dh(n.environment)}/store/${n.storeIdentifier}${e}`,t)}async function $(r,e,{id:t,query:n,data:i,headers:a}={},o){const{environment:u,environmentUri:f,storeIdentifier:c,loginRetryFn:l,appName:s,appVersion:h}=W();if(!c)throw new Error("InitRecharge has not been called and/or no store identifier has been defined.");const y=o.apiToken;if(!y)throw new Error("No API token defined on session.");const w=lh(u,f),S={"X-Recharge-Access-Token":y,"X-Recharge-Version":"2021-11","X-Recharge-Sdk-Fn":o.internalFnCall,...s?{"X-Recharge-Sdk-App-Name":s}:{},...h?{"X-Recharge-Sdk-App-Version":h}:{},"X-Recharge-Sdk-Version":"1.38.0","X-Request-Id":o.internalRequestId,...o.tmp_fn_identifier?{"X-Recharge-Sdk-Fn-Identifier":o.tmp_fn_identifier}:{},...a||{}},O={shop_url:c,...n};try{return await ue(r,`${w}${e}`,{id:t,query:O,data:i,headers:S})}catch(b){if(l&&b instanceof Er&&b.status===401)return l().then(E=>{if(E)return ue(r,`${w}${e}`,{id:t,query:O,data:i,headers:{...S,"X-Recharge-Access-Token":E.apiToken}});throw b});throw b}}async function Ke(r,e,t={}){return ue(r,`${ph}${e}`,t)}async function ue(r,e,{id:t,query:n,data:i,headers:a}={}){let o=e.trim();if(t&&(o=[o,`${t}`.trim()].join("/")),n){let s;[o,s]=o.split("?");const h=[s,yh(n)].join("&").replace(/^&/,"");o=`${o}${h?`?${h}`:""}`}let u;i&&r!=="get"&&(u=JSON.stringify(i));const f={Accept:"application/json","Content-Type":"application/json","X-Recharge-App":"storefront-client",...a||{}},c=await fetch(o,{method:r,headers:f,body:u});let l;try{l=await c.json()}catch{}if(!c.ok)throw c.status===502||c.status===504?new Er("A gateway error occurred while making the request",c.status):l&&l.error?new Er(l.error,c.status):l&&l.errors?new Er(JSON.stringify(l.errors),c.status):new Er("A connection error occurred while making the request");return l}function gh(r,e){return $("get","/addresses",{query:e},_(r,"listAddresses"))}async function vh(r,e,t){if(e===void 0||e==="")throw new Error("ID is required");const{address:n}=await $("get","/addresses",{id:e,query:{include:t?.include}},_(r,"getAddress"));return n}async function _h(r,e){const{address:t}=await $("post","/addresses",{data:{customer_id:r.customerId?Number(r.customerId):void 0,...e}},_(r,"createAddress"));return t}async function Gn(r,e,t,n){if(e===void 0||e==="")throw new Error("ID is required");const{address:i}=await $("put","/addresses",{id:e,data:t,query:n},_(r,"updateAddress"));return i}async function mh(r,e,t,n){return Gn(_(r,"applyDiscountToAddress"),e,{discounts:[{code:t}]},n)}async function wh(r,e,t){if(e===void 0||e==="")throw new Error("Id is required");return Gn(_(r,"removeDiscountsFromAddress"),e,{discounts:[]},t)}function bh(r,e){if(e===void 0||e==="")throw new Error("ID is required");return $("delete","/addresses",{id:e},_(r,"deleteAddress"))}async function $h(r,e){const{address:t}=await $("post","/addresses/merge",{data:e},_(r,"mergeAddresses"));return t}async function Eh(r,e,t){if(e===void 0||e==="")throw new Error("ID is required");const{charge:n}=await $("post",`/addresses/${e}/charges/skip`,{data:t},_(r,"skipFutureCharge"));return n}var Ah=Object.freeze({__proto__:null,applyDiscountToAddress:mh,createAddress:_h,deleteAddress:bh,getAddress:vh,listAddresses:gh,mergeAddresses:$h,removeDiscountsFromAddress:wh,skipFutureCharge:Eh,updateAddress:Gn});async function Sh(){const{storefrontAccessToken:r}=W(),e={};r&&(e["X-Recharge-Storefront-Access-Token"]=r);const t=await Ke("get","/access",{headers:e});return{apiToken:t.api_token,customerId:t.customer_id,message:t.message}}async function Oh(r,e){return ro(r,e)}async function ro(r,e){if(!r)throw new Error("Shopify storefront token is required");const{storeIdentifier:t}=W();if(!t)throw new Error("InitRecharge has not been called and/or no store identifier has been defined.");const{api_token:n,customer_id:i,message:a}=await Ar("post","/shopify_storefront_access",{data:{customer_token:e,storefront_token:r,shop_url:t}});return n?{apiToken:n,customerId:i,message:a}:null}async function Ih(r){const{storeIdentifier:e}=W();if(!e)throw new Error("InitRecharge has not been called and/or no store identifier has been defined.");const{api_token:t,customer_id:n,message:i}=await Ar("post","/shopify_customer_account_api_access",{data:{customer_token:r,shop_url:e}});return t?{apiToken:t,customerId:n,message:i}:null}async function Ph(r,e={}){if(!r)throw new Error("Email is required.");const{storeIdentifier:t}=W();if(!t)throw new Error("InitRecharge has not been called and/or no store identifier has been defined.");const n=await Ar("post","/attempt_login",{data:{email:r,shop:t,...e}});if(n.errors)throw new Error(n.errors);return n.session_token}async function xh(r,e={}){if(!r)throw new Error("Email is required.");const{storefrontAccessToken:t}=W(),n={};t&&(n["X-Recharge-Storefront-Access-Token"]=t);const i=await Ke("post","/attempt_login",{data:{email:r,...e},headers:n});if(i.errors)throw new Error(i.errors);return i.session_token}async function Th(r,e,t){if(!r)throw new Error("Email is required.");if(!e)throw new Error("Session token is required.");if(!t)throw new Error("Code is required.");const{storeIdentifier:n}=W();if(!n)throw new Error("InitRecharge has not been called and/or no store identifier has been defined.");const i=await Ar("post","/validate_login",{data:{code:t,email:r,session_token:e,shop:n}});if(i.errors)throw new Error(i.errors);return{apiToken:i.api_token,customerId:i.customer_id}}async function Rh(r,e,t){if(!r)throw new Error("Email is required.");if(!e)throw new Error("Session token is required.");if(!t)throw new Error("Code is required.");const{storefrontAccessToken:n}=W(),i={};n&&(i["X-Recharge-Storefront-Access-Token"]=n);const a=await Ke("post","/validate_login",{data:{code:t,email:r,session_token:e},headers:i});if(a.errors)throw new Error(a.errors);return{apiToken:a.api_token,customerId:a.customer_id}}function Fh(){const{customerHash:r}=W(),{pathname:e,search:t}=window.location,n=new URLSearchParams(t).get("token"),i=e.split("/").filter(Boolean),a=i.findIndex(u=>u==="portal"),o=a!==-1?i[a+1]:r;if(!n||!o)throw new Error("Not in context of Recharge Customer Portal or URL did not contain correct params");return{customerHash:o,token:n}}async function Mh(){const{customerHash:r,token:e}=Fh(),{storeIdentifier:t}=W(),n=await Ar("post",`/customers/${r}/access`,{data:{token:e,shop:t}});return{apiToken:n.api_token,customerId:n.customer_id}}async function Ar(r,e,{id:t,query:n,data:i,headers:a}={}){const{environment:o,environmentUri:u,storefrontAccessToken:f,appName:c,appVersion:l}=W(),s=hh(o,u),h={...f?{"X-Recharge-Storefront-Access-Token":f}:{},...c?{"X-Recharge-Sdk-App-Name":c}:{},...l?{"X-Recharge-Sdk-App-Version":l}:{},"X-Recharge-Sdk-Version":"1.38.0",...a||{}};return ue(r,`${s}${e}`,{id:t,query:n,data:i,headers:h})}var Dh=Object.freeze({__proto__:null,loginCustomerPortal:Mh,loginShopifyApi:Oh,loginShopifyAppProxy:Sh,loginWithShopifyCustomerAccount:Ih,loginWithShopifyStorefront:ro,sendPasswordlessCode:Ph,sendPasswordlessCodeAppProxy:xh,validatePasswordlessCode:Th,validatePasswordlessCodeAppProxy:Rh}),to={},Hn={},se={},Ch=typeof U=="object"&&U&&U.Object===Object&&U,no=Ch,Nh=no,Bh=typeof self=="object"&&self&&self.Object===Object&&self,Uh=Nh||Bh||Function("return this")(),fe=Uh,qh=fe,Lh=qh.Symbol,yt=Lh,io=yt,ao=Object.prototype,kh=ao.hasOwnProperty,jh=ao.toString,Sr=io?io.toStringTag:void 0;function Vh(r){var e=kh.call(r,Sr),t=r[Sr];try{r[Sr]=void 0;var n=!0}catch{}var i=jh.call(r);return n&&(e?r[Sr]=t:delete r[Sr]),i}var Gh=Vh,Hh=Object.prototype,Wh=Hh.toString;function Xh(r){return Wh.call(r)}var zh=Xh,oo=yt,Yh=Gh,Kh=zh,Zh="[object Null]",Jh="[object Undefined]",uo=oo?oo.toStringTag:void 0;function Qh(r){return r==null?r===void 0?Jh:Zh:uo&&uo in Object(r)?Yh(r):Kh(r)}var ge=Qh;function ed(r){return r!=null&&typeof r=="object"}var ve=ed,rd=ge,td=ve,nd="[object Number]";function id(r){return typeof r=="number"||td(r)&&rd(r)==nd}var gt=id,D={};function ad(r){var e=typeof r;return r!=null&&(e=="object"||e=="function")}var Ze=ad,od=ge,ud=Ze,sd="[object AsyncFunction]",fd="[object Function]",cd="[object GeneratorFunction]",ld="[object Proxy]";function hd(r){if(!ud(r))return!1;var e=od(r);return e==fd||e==cd||e==sd||e==ld}var Wn=hd,dd=fe,pd=dd["__core-js_shared__"],yd=pd,Xn=yd,so=function(){var r=/[^.]+$/.exec(Xn&&Xn.keys&&Xn.keys.IE_PROTO||"");return r?"Symbol(src)_1."+r:""}();function gd(r){return!!so&&so in r}var vd=gd,_d=Function.prototype,md=_d.toString;function wd(r){if(r!=null){try{return md.call(r)}catch{}try{return r+""}catch{}}return""}var fo=wd,bd=Wn,$d=vd,Ed=Ze,Ad=fo,Sd=/[\\^$.*+?()[\]{}|]/g,Od=/^\[object .+?Constructor\]$/,Id=Function.prototype,Pd=Object.prototype,xd=Id.toString,Td=Pd.hasOwnProperty,Rd=RegExp("^"+xd.call(Td).replace(Sd,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Fd(r){if(!Ed(r)||$d(r))return!1;var e=bd(r)?Rd:Od;return e.test(Ad(r))}var Md=Fd;function Dd(r,e){return r?.[e]}var Cd=Dd,Nd=Md,Bd=Cd;function Ud(r,e){var t=Bd(r,e);return Nd(t)?t:void 0}var Fe=Ud,qd=Fe,Ld=function(){try{var r=qd(Object,"defineProperty");return r({},"",{}),r}catch{}}(),co=Ld,lo=co;function kd(r,e,t){e=="__proto__"&&lo?lo(r,e,{configurable:!0,enumerable:!0,value:t,writable:!0}):r[e]=t}var ho=kd;function jd(r,e){return r===e||r!==r&&e!==e}var vt=jd,Vd=ho,Gd=vt,Hd=Object.prototype,Wd=Hd.hasOwnProperty;function Xd(r,e,t){var n=r[e];(!(Wd.call(r,e)&&Gd(n,t))||t===void 0&&!(e in r))&&Vd(r,e,t)}var zd=Xd,Yd=zd,Kd=ho;function Zd(r,e,t,n){var i=!t;t||(t={});for(var a=-1,o=e.length;++a<o;){var u=e[a],f=n?n(t[u],r[u],u,t,r):void 0;f===void 0&&(f=r[u]),i?Kd(t,u,f):Yd(t,u,f)}return t}var Jd=Zd;function Qd(r){return r}var _t=Qd;function ep(r,e,t){switch(t.length){case 0:return r.call(e);case 1:return r.call(e,t[0]);case 2:return r.call(e,t[0],t[1]);case 3:return r.call(e,t[0],t[1],t[2])}return r.apply(e,t)}var rp=ep,tp=rp,po=Math.max;function np(r,e,t){return e=po(e===void 0?r.length-1:e,0),function(){for(var n=arguments,i=-1,a=po(n.length-e,0),o=Array(a);++i<a;)o[i]=n[e+i];i=-1;for(var u=Array(e+1);++i<e;)u[i]=n[i];return u[e]=t(o),tp(r,this,u)}}var ip=np;function ap(r){return function(){return r}}var op=ap,up=op,yo=co,sp=_t,fp=yo?function(r,e){return yo(r,"toString",{configurable:!0,enumerable:!1,value:up(e),writable:!0})}:sp,cp=fp,lp=800,hp=16,dp=Date.now;function pp(r){var e=0,t=0;return function(){var n=dp(),i=hp-(n-t);if(t=n,i>0){if(++e>=lp)return arguments[0]}else e=0;return r.apply(void 0,arguments)}}var yp=pp,gp=cp,vp=yp,_p=vp(gp),mp=_p,wp=_t,bp=ip,$p=mp;function Ep(r,e){return $p(bp(r,e,wp),r+"")}var Ap=Ep,Sp=9007199254740991;function Op(r){return typeof r=="number"&&r>-1&&r%1==0&&r<=Sp}var zn=Op,Ip=Wn,Pp=zn;function xp(r){return r!=null&&Pp(r.length)&&!Ip(r)}var Or=xp,Tp=9007199254740991,Rp=/^(?:0|[1-9]\d*)$/;function Fp(r,e){var t=typeof r;return e=e??Tp,!!e&&(t=="number"||t!="symbol"&&Rp.test(r))&&r>-1&&r%1==0&&r<e}var Yn=Fp,Mp=vt,Dp=Or,Cp=Yn,Np=Ze;function Bp(r,e,t){if(!Np(t))return!1;var n=typeof e;return(n=="number"?Dp(t)&&Cp(e,t.length):n=="string"&&e in t)?Mp(t[e],r):!1}var go=Bp,Up=Ap,qp=go;function Lp(r){return Up(function(e,t){var n=-1,i=t.length,a=i>1?t[i-1]:void 0,o=i>2?t[2]:void 0;for(a=r.length>3&&typeof a=="function"?(i--,a):void 0,o&&qp(t[0],t[1],o)&&(a=i<3?void 0:a,i=1),e=Object(e);++n<i;){var u=t[n];u&&r(e,u,n,a)}return e})}var kp=Lp;function jp(r,e){for(var t=-1,n=Array(r);++t<r;)n[t]=e(t);return n}var vo=jp,Vp=ge,Gp=ve,Hp="[object Arguments]";function Wp(r){return Gp(r)&&Vp(r)==Hp}var Xp=Wp,_o=Xp,zp=ve,mo=Object.prototype,Yp=mo.hasOwnProperty,Kp=mo.propertyIsEnumerable,Zp=_o(function(){return arguments}())?_o:function(r){return zp(r)&&Yp.call(r,"callee")&&!Kp.call(r,"callee")},wo=Zp,Jp=Array.isArray,V=Jp,mt={exports:{}};function Qp(){return!1}var ey=Qp;mt.exports,function(r,e){var t=fe,n=ey,i=e&&!e.nodeType&&e,a=i&&!0&&r&&!r.nodeType&&r,o=a&&a.exports===i,u=o?t.Buffer:void 0,f=u?u.isBuffer:void 0,c=f||n;r.exports=c}(mt,mt.exports);var bo=mt.exports,ry=ge,ty=zn,ny=ve,iy="[object Arguments]",ay="[object Array]",oy="[object Boolean]",uy="[object Date]",sy="[object Error]",fy="[object Function]",cy="[object Map]",ly="[object Number]",hy="[object Object]",dy="[object RegExp]",py="[object Set]",yy="[object String]",gy="[object WeakMap]",vy="[object ArrayBuffer]",_y="[object DataView]",my="[object Float32Array]",wy="[object Float64Array]",by="[object Int8Array]",$y="[object Int16Array]",Ey="[object Int32Array]",Ay="[object Uint8Array]",Sy="[object Uint8ClampedArray]",Oy="[object Uint16Array]",Iy="[object Uint32Array]",R={};R[my]=R[wy]=R[by]=R[$y]=R[Ey]=R[Ay]=R[Sy]=R[Oy]=R[Iy]=!0,R[iy]=R[ay]=R[vy]=R[oy]=R[_y]=R[uy]=R[sy]=R[fy]=R[cy]=R[ly]=R[hy]=R[dy]=R[py]=R[yy]=R[gy]=!1;function Py(r){return ny(r)&&ty(r.length)&&!!R[ry(r)]}var xy=Py;function Ty(r){return function(e){return r(e)}}var Ry=Ty,wt={exports:{}};wt.exports,function(r,e){var t=no,n=e&&!e.nodeType&&e,i=n&&!0&&r&&!r.nodeType&&r,a=i&&i.exports===n,o=a&&t.process,u=function(){try{var f=i&&i.require&&i.require("util").types;return f||o&&o.binding&&o.binding("util")}catch{}}();r.exports=u}(wt,wt.exports);var Fy=wt.exports,My=xy,Dy=Ry,$o=Fy,Eo=$o&&$o.isTypedArray,Cy=Eo?Dy(Eo):My,Ao=Cy,Ny=vo,By=wo,Uy=V,qy=bo,Ly=Yn,ky=Ao,jy=Object.prototype,Vy=jy.hasOwnProperty;function Gy(r,e){var t=Uy(r),n=!t&&By(r),i=!t&&!n&&qy(r),a=!t&&!n&&!i&&ky(r),o=t||n||i||a,u=o?Ny(r.length,String):[],f=u.length;for(var c in r)(e||Vy.call(r,c))&&!(o&&(c=="length"||i&&(c=="offset"||c=="parent")||a&&(c=="buffer"||c=="byteLength"||c=="byteOffset")||Ly(c,f)))&&u.push(c);return u}var So=Gy,Hy=Object.prototype;function Wy(r){var e=r&&r.constructor,t=typeof e=="function"&&e.prototype||Hy;return r===t}var Oo=Wy;function Xy(r){var e=[];if(r!=null)for(var t in Object(r))e.push(t);return e}var zy=Xy,Yy=Ze,Ky=Oo,Zy=zy,Jy=Object.prototype,Qy=Jy.hasOwnProperty;function eg(r){if(!Yy(r))return Zy(r);var e=Ky(r),t=[];for(var n in r)n=="constructor"&&(e||!Qy.call(r,n))||t.push(n);return t}var rg=eg,tg=So,ng=rg,ig=Or;function ag(r){return ig(r)?tg(r,!0):ng(r)}var og=ag,ug=Jd,sg=kp,fg=og,cg=sg(function(r,e){ug(e,fg(e),r)}),lg=cg,hg=lg,bt={},Me={};function dg(r,e){for(var t=-1,n=r==null?0:r.length;++t<n;)if(!e(r[t],t,r))return!1;return!0}var pg=dg;function yg(r){return function(e,t,n){for(var i=-1,a=Object(e),o=n(e),u=o.length;u--;){var f=o[r?u:++i];if(t(a[f],f,a)===!1)break}return e}}var gg=yg,vg=gg,_g=vg(),mg=_g;function wg(r,e){return function(t){return r(e(t))}}var bg=wg,$g=bg,Eg=$g(Object.keys,Object),Ag=Eg,Sg=Oo,Og=Ag,Ig=Object.prototype,Pg=Ig.hasOwnProperty;function xg(r){if(!Sg(r))return Og(r);var e=[];for(var t in Object(r))Pg.call(r,t)&&t!="constructor"&&e.push(t);return e}var Tg=xg,Rg=So,Fg=Tg,Mg=Or;function Dg(r){return Mg(r)?Rg(r):Fg(r)}var $t=Dg,Cg=mg,Ng=$t;function Bg(r,e){return r&&Cg(r,e,Ng)}var Ug=Bg,qg=Or;function Lg(r,e){return function(t,n){if(t==null)return t;if(!qg(t))return r(t,n);for(var i=t.length,a=e?i:-1,o=Object(t);(e?a--:++a<i)&&n(o[a],a,o)!==!1;);return t}}var kg=Lg,jg=Ug,Vg=kg,Gg=Vg(jg),Kn=Gg,Hg=Kn;function Wg(r,e){var t=!0;return Hg(r,function(n,i,a){return t=!!e(n,i,a),t}),t}var Xg=Wg;function zg(){this.__data__=[],this.size=0}var Yg=zg,Kg=vt;function Zg(r,e){for(var t=r.length;t--;)if(Kg(r[t][0],e))return t;return-1}var Et=Zg,Jg=Et,Qg=Array.prototype,ev=Qg.splice;function rv(r){var e=this.__data__,t=Jg(e,r);if(t<0)return!1;var n=e.length-1;return t==n?e.pop():ev.call(e,t,1),--this.size,!0}var tv=rv,nv=Et;function iv(r){var e=this.__data__,t=nv(e,r);return t<0?void 0:e[t][1]}var av=iv,ov=Et;function uv(r){return ov(this.__data__,r)>-1}var sv=uv,fv=Et;function cv(r,e){var t=this.__data__,n=fv(t,r);return n<0?(++this.size,t.push([r,e])):t[n][1]=e,this}var lv=cv,hv=Yg,dv=tv,pv=av,yv=sv,gv=lv;function Je(r){var e=-1,t=r==null?0:r.length;for(this.clear();++e<t;){var n=r[e];this.set(n[0],n[1])}}Je.prototype.clear=hv,Je.prototype.delete=dv,Je.prototype.get=pv,Je.prototype.has=yv,Je.prototype.set=gv;var At=Je,vv=At;function _v(){this.__data__=new vv,this.size=0}var mv=_v;function wv(r){var e=this.__data__,t=e.delete(r);return this.size=e.size,t}var bv=wv;function $v(r){return this.__data__.get(r)}var Ev=$v;function Av(r){return this.__data__.has(r)}var Sv=Av,Ov=Fe,Iv=fe,Pv=Ov(Iv,"Map"),Zn=Pv,xv=Fe,Tv=xv(Object,"create"),St=Tv,Io=St;function Rv(){this.__data__=Io?Io(null):{},this.size=0}var Fv=Rv;function Mv(r){var e=this.has(r)&&delete this.__data__[r];return this.size-=e?1:0,e}var Dv=Mv,Cv=St,Nv="__lodash_hash_undefined__",Bv=Object.prototype,Uv=Bv.hasOwnProperty;function qv(r){var e=this.__data__;if(Cv){var t=e[r];return t===Nv?void 0:t}return Uv.call(e,r)?e[r]:void 0}var Lv=qv,kv=St,jv=Object.prototype,Vv=jv.hasOwnProperty;function Gv(r){var e=this.__data__;return kv?e[r]!==void 0:Vv.call(e,r)}var Hv=Gv,Wv=St,Xv="__lodash_hash_undefined__";function zv(r,e){var t=this.__data__;return this.size+=this.has(r)?0:1,t[r]=Wv&&e===void 0?Xv:e,this}var Yv=zv,Kv=Fv,Zv=Dv,Jv=Lv,Qv=Hv,e_=Yv;function Qe(r){var e=-1,t=r==null?0:r.length;for(this.clear();++e<t;){var n=r[e];this.set(n[0],n[1])}}Qe.prototype.clear=Kv,Qe.prototype.delete=Zv,Qe.prototype.get=Jv,Qe.prototype.has=Qv,Qe.prototype.set=e_;var r_=Qe,Po=r_,t_=At,n_=Zn;function i_(){this.size=0,this.__data__={hash:new Po,map:new(n_||t_),string:new Po}}var a_=i_;function o_(r){var e=typeof r;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?r!=="__proto__":r===null}var u_=o_,s_=u_;function f_(r,e){var t=r.__data__;return s_(e)?t[typeof e=="string"?"string":"hash"]:t.map}var Ot=f_,c_=Ot;function l_(r){var e=c_(this,r).delete(r);return this.size-=e?1:0,e}var h_=l_,d_=Ot;function p_(r){return d_(this,r).get(r)}var y_=p_,g_=Ot;function v_(r){return g_(this,r).has(r)}var __=v_,m_=Ot;function w_(r,e){var t=m_(this,r),n=t.size;return t.set(r,e),this.size+=t.size==n?0:1,this}var b_=w_,$_=a_,E_=h_,A_=y_,S_=__,O_=b_;function er(r){var e=-1,t=r==null?0:r.length;for(this.clear();++e<t;){var n=r[e];this.set(n[0],n[1])}}er.prototype.clear=$_,er.prototype.delete=E_,er.prototype.get=A_,er.prototype.has=S_,er.prototype.set=O_;var Jn=er,I_=At,P_=Zn,x_=Jn,T_=200;function R_(r,e){var t=this.__data__;if(t instanceof I_){var n=t.__data__;if(!P_||n.length<T_-1)return n.push([r,e]),this.size=++t.size,this;t=this.__data__=new x_(n)}return t.set(r,e),this.size=t.size,this}var F_=R_,M_=At,D_=mv,C_=bv,N_=Ev,B_=Sv,U_=F_;function rr(r){var e=this.__data__=new M_(r);this.size=e.size}rr.prototype.clear=D_,rr.prototype.delete=C_,rr.prototype.get=N_,rr.prototype.has=B_,rr.prototype.set=U_;var xo=rr,q_="__lodash_hash_undefined__";function L_(r){return this.__data__.set(r,q_),this}var k_=L_;function j_(r){return this.__data__.has(r)}var V_=j_,G_=Jn,H_=k_,W_=V_;function It(r){var e=-1,t=r==null?0:r.length;for(this.__data__=new G_;++e<t;)this.add(r[e])}It.prototype.add=It.prototype.push=H_,It.prototype.has=W_;var X_=It;function z_(r,e){for(var t=-1,n=r==null?0:r.length;++t<n;)if(e(r[t],t,r))return!0;return!1}var Y_=z_;function K_(r,e){return r.has(e)}var Z_=K_,J_=X_,Q_=Y_,em=Z_,rm=1,tm=2;function nm(r,e,t,n,i,a){var o=t&rm,u=r.length,f=e.length;if(u!=f&&!(o&&f>u))return!1;var c=a.get(r),l=a.get(e);if(c&&l)return c==e&&l==r;var s=-1,h=!0,y=t&tm?new J_:void 0;for(a.set(r,e),a.set(e,r);++s<u;){var w=r[s],S=e[s];if(n)var O=o?n(S,w,s,e,r,a):n(w,S,s,r,e,a);if(O!==void 0){if(O)continue;h=!1;break}if(y){if(!Q_(e,function(b,E){if(!em(y,E)&&(w===b||i(w,b,t,n,a)))return y.push(E)})){h=!1;break}}else if(!(w===S||i(w,S,t,n,a))){h=!1;break}}return a.delete(r),a.delete(e),h}var To=nm,im=fe,am=im.Uint8Array,om=am;function um(r){var e=-1,t=Array(r.size);return r.forEach(function(n,i){t[++e]=[i,n]}),t}var sm=um;function fm(r){var e=-1,t=Array(r.size);return r.forEach(function(n){t[++e]=n}),t}var cm=fm,Ro=yt,Fo=om,lm=vt,hm=To,dm=sm,pm=cm,ym=1,gm=2,vm="[object Boolean]",_m="[object Date]",mm="[object Error]",wm="[object Map]",bm="[object Number]",$m="[object RegExp]",Em="[object Set]",Am="[object String]",Sm="[object Symbol]",Om="[object ArrayBuffer]",Im="[object DataView]",Mo=Ro?Ro.prototype:void 0,Qn=Mo?Mo.valueOf:void 0;function Pm(r,e,t,n,i,a,o){switch(t){case Im:if(r.byteLength!=e.byteLength||r.byteOffset!=e.byteOffset)return!1;r=r.buffer,e=e.buffer;case Om:return!(r.byteLength!=e.byteLength||!a(new Fo(r),new Fo(e)));case vm:case _m:case bm:return lm(+r,+e);case mm:return r.name==e.name&&r.message==e.message;case $m:case Am:return r==e+"";case wm:var u=dm;case Em:var f=n&ym;if(u||(u=pm),r.size!=e.size&&!f)return!1;var c=o.get(r);if(c)return c==e;n|=gm,o.set(r,e);var l=hm(u(r),u(e),n,i,a,o);return o.delete(r),l;case Sm:if(Qn)return Qn.call(r)==Qn.call(e)}return!1}var xm=Pm;function Tm(r,e){for(var t=-1,n=e.length,i=r.length;++t<n;)r[i+t]=e[t];return r}var Rm=Tm,Fm=Rm,Mm=V;function Dm(r,e,t){var n=e(r);return Mm(r)?n:Fm(n,t(r))}var Cm=Dm;function Nm(r,e){for(var t=-1,n=r==null?0:r.length,i=0,a=[];++t<n;){var o=r[t];e(o,t,r)&&(a[i++]=o)}return a}var Bm=Nm;function Um(){return[]}var qm=Um,Lm=Bm,km=qm,jm=Object.prototype,Vm=jm.propertyIsEnumerable,Do=Object.getOwnPropertySymbols,Gm=Do?function(r){return r==null?[]:(r=Object(r),Lm(Do(r),function(e){return Vm.call(r,e)}))}:km,Hm=Gm,Wm=Cm,Xm=Hm,zm=$t;function Ym(r){return Wm(r,zm,Xm)}var Km=Ym,Co=Km,Zm=1,Jm=Object.prototype,Qm=Jm.hasOwnProperty;function ew(r,e,t,n,i,a){var o=t&Zm,u=Co(r),f=u.length,c=Co(e),l=c.length;if(f!=l&&!o)return!1;for(var s=f;s--;){var h=u[s];if(!(o?h in e:Qm.call(e,h)))return!1}var y=a.get(r),w=a.get(e);if(y&&w)return y==e&&w==r;var S=!0;a.set(r,e),a.set(e,r);for(var O=o;++s<f;){h=u[s];var b=r[h],E=e[h];if(n)var d=o?n(E,b,h,e,r,a):n(b,E,h,r,e,a);if(!(d===void 0?b===E||i(b,E,t,n,a):d)){S=!1;break}O||(O=h=="constructor")}if(S&&!O){var I=r.constructor,T=e.constructor;I!=T&&"constructor"in r&&"constructor"in e&&!(typeof I=="function"&&I instanceof I&&typeof T=="function"&&T instanceof T)&&(S=!1)}return a.delete(r),a.delete(e),S}var rw=ew,tw=Fe,nw=fe,iw=tw(nw,"DataView"),aw=iw,ow=Fe,uw=fe,sw=ow(uw,"Promise"),fw=sw,cw=Fe,lw=fe,hw=cw(lw,"Set"),dw=hw,pw=Fe,yw=fe,gw=pw(yw,"WeakMap"),vw=gw,ei=aw,ri=Zn,ti=fw,ni=dw,ii=vw,No=ge,tr=fo,Bo="[object Map]",_w="[object Object]",Uo="[object Promise]",qo="[object Set]",Lo="[object WeakMap]",ko="[object DataView]",mw=tr(ei),ww=tr(ri),bw=tr(ti),$w=tr(ni),Ew=tr(ii),De=No;(ei&&De(new ei(new ArrayBuffer(1)))!=ko||ri&&De(new ri)!=Bo||ti&&De(ti.resolve())!=Uo||ni&&De(new ni)!=qo||ii&&De(new ii)!=Lo)&&(De=function(r){var e=No(r),t=e==_w?r.constructor:void 0,n=t?tr(t):"";if(n)switch(n){case mw:return ko;case ww:return Bo;case bw:return Uo;case $w:return qo;case Ew:return Lo}return e});var Aw=De,ai=xo,Sw=To,Ow=xm,Iw=rw,jo=Aw,Vo=V,Go=bo,Pw=Ao,xw=1,Ho="[object Arguments]",Wo="[object Array]",Pt="[object Object]",Tw=Object.prototype,Xo=Tw.hasOwnProperty;function Rw(r,e,t,n,i,a){var o=Vo(r),u=Vo(e),f=o?Wo:jo(r),c=u?Wo:jo(e);f=f==Ho?Pt:f,c=c==Ho?Pt:c;var l=f==Pt,s=c==Pt,h=f==c;if(h&&Go(r)){if(!Go(e))return!1;o=!0,l=!1}if(h&&!l)return a||(a=new ai),o||Pw(r)?Sw(r,e,t,n,i,a):Ow(r,e,f,t,n,i,a);if(!(t&xw)){var y=l&&Xo.call(r,"__wrapped__"),w=s&&Xo.call(e,"__wrapped__");if(y||w){var S=y?r.value():r,O=w?e.value():e;return a||(a=new ai),i(S,O,t,n,a)}}return h?(a||(a=new ai),Iw(r,e,t,n,i,a)):!1}var Fw=Rw,Mw=Fw,zo=ve;function Yo(r,e,t,n,i){return r===e?!0:r==null||e==null||!zo(r)&&!zo(e)?r!==r&&e!==e:Mw(r,e,t,n,Yo,i)}var Ko=Yo,Dw=xo,Cw=Ko,Nw=1,Bw=2;function Uw(r,e,t,n){var i=t.length,a=i,o=!n;if(r==null)return!a;for(r=Object(r);i--;){var u=t[i];if(o&&u[2]?u[1]!==r[u[0]]:!(u[0]in r))return!1}for(;++i<a;){u=t[i];var f=u[0],c=r[f],l=u[1];if(o&&u[2]){if(c===void 0&&!(f in r))return!1}else{var s=new Dw;if(n)var h=n(c,l,f,r,e,s);if(!(h===void 0?Cw(l,c,Nw|Bw,n,s):h))return!1}}return!0}var qw=Uw,Lw=Ze;function kw(r){return r===r&&!Lw(r)}var Zo=kw,jw=Zo,Vw=$t;function Gw(r){for(var e=Vw(r),t=e.length;t--;){var n=e[t],i=r[n];e[t]=[n,i,jw(i)]}return e}var Hw=Gw;function Ww(r,e){return function(t){return t==null?!1:t[r]===e&&(e!==void 0||r in Object(t))}}var Jo=Ww,Xw=qw,zw=Hw,Yw=Jo;function Kw(r){var e=zw(r);return e.length==1&&e[0][2]?Yw(e[0][0],e[0][1]):function(t){return t===r||Xw(t,r,e)}}var Zw=Kw,Jw=ge,Qw=ve,e0="[object Symbol]";function r0(r){return typeof r=="symbol"||Qw(r)&&Jw(r)==e0}var xt=r0,t0=V,n0=xt,i0=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,a0=/^\w*$/;function o0(r,e){if(t0(r))return!1;var t=typeof r;return t=="number"||t=="symbol"||t=="boolean"||r==null||n0(r)?!0:a0.test(r)||!i0.test(r)||e!=null&&r in Object(e)}var oi=o0,Qo=Jn,u0="Expected a function";function ui(r,e){if(typeof r!="function"||e!=null&&typeof e!="function")throw new TypeError(u0);var t=function(){var n=arguments,i=e?e.apply(this,n):n[0],a=t.cache;if(a.has(i))return a.get(i);var o=r.apply(this,n);return t.cache=a.set(i,o)||a,o};return t.cache=new(ui.Cache||Qo),t}ui.Cache=Qo;var s0=ui,f0=s0,c0=500;function l0(r){var e=f0(r,function(n){return t.size===c0&&t.clear(),n}),t=e.cache;return e}var h0=l0,d0=h0,p0=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,y0=/\\(\\)?/g,g0=d0(function(r){var e=[];return r.charCodeAt(0)===46&&e.push(""),r.replace(p0,function(t,n,i,a){e.push(i?a.replace(y0,"$1"):n||t)}),e}),v0=g0;function _0(r,e){for(var t=-1,n=r==null?0:r.length,i=Array(n);++t<n;)i[t]=e(r[t],t,r);return i}var si=_0,eu=yt,m0=si,w0=V,b0=xt,$0=1/0,ru=eu?eu.prototype:void 0,tu=ru?ru.toString:void 0;function nu(r){if(typeof r=="string")return r;if(w0(r))return m0(r,nu)+"";if(b0(r))return tu?tu.call(r):"";var e=r+"";return e=="0"&&1/r==-$0?"-0":e}var E0=nu,A0=E0;function S0(r){return r==null?"":A0(r)}var O0=S0,I0=V,P0=oi,x0=v0,T0=O0;function R0(r,e){return I0(r)?r:P0(r,e)?[r]:x0(T0(r))}var iu=R0,F0=xt,M0=1/0;function D0(r){if(typeof r=="string"||F0(r))return r;var e=r+"";return e=="0"&&1/r==-M0?"-0":e}var Tt=D0,C0=iu,N0=Tt;function B0(r,e){e=C0(e,r);for(var t=0,n=e.length;r!=null&&t<n;)r=r[N0(e[t++])];return t&&t==n?r:void 0}var au=B0,U0=au;function q0(r,e,t){var n=r==null?void 0:U0(r,e);return n===void 0?t:n}var L0=q0;function k0(r,e){return r!=null&&e in Object(r)}var j0=k0,V0=iu,G0=wo,H0=V,W0=Yn,X0=zn,z0=Tt;function Y0(r,e,t){e=V0(e,r);for(var n=-1,i=e.length,a=!1;++n<i;){var o=z0(e[n]);if(!(a=r!=null&&t(r,o)))break;r=r[o]}return a||++n!=i?a:(i=r==null?0:r.length,!!i&&X0(i)&&W0(o,i)&&(H0(r)||G0(r)))}var K0=Y0,Z0=j0,J0=K0;function Q0(r,e){return r!=null&&J0(r,e,Z0)}var eb=Q0,rb=Ko,tb=L0,nb=eb,ib=oi,ab=Zo,ob=Jo,ub=Tt,sb=1,fb=2;function cb(r,e){return ib(r)&&ab(e)?ob(ub(r),e):function(t){var n=tb(t,r);return n===void 0&&n===e?nb(t,r):rb(e,n,sb|fb)}}var lb=cb;function hb(r){return function(e){return e?.[r]}}var db=hb,pb=au;function yb(r){return function(e){return pb(e,r)}}var gb=yb,vb=db,_b=gb,mb=oi,wb=Tt;function bb(r){return mb(r)?vb(wb(r)):_b(r)}var $b=bb,Eb=Zw,Ab=lb,Sb=_t,Ob=V,Ib=$b;function Pb(r){return typeof r=="function"?r:r==null?Sb:typeof r=="object"?Ob(r)?Ab(r[0],r[1]):Eb(r):Ib(r)}var ou=Pb,xb=pg,Tb=Xg,Rb=ou,Fb=V,Mb=go;function Db(r,e,t){var n=Fb(r)?xb:Tb;return t&&Mb(r,e,t)&&(e=void 0),n(r,Rb(e))}var fi=Db;Object.defineProperty(Me,"__esModule",{value:!0}),Me.calculatePadding=Ub,Me.slicePadding=qb;var Cb=fi,Nb=Bb(Cb);function Bb(r){return r&&r.__esModule?r:{default:r}}function Ub(r){switch(r%4){case 0:return 0;case 1:return 3;case 2:return 2;case 3:return 1;default:return null}}function qb(r,e){var t=r.slice(e),n=(0,Nb.default)(t.buffer(),function(i){return i===0});if(n!==!0)throw new Error("XDR Read Error: invalid padding")}Object.defineProperty(bt,"__esModule",{value:!0}),bt.Cursor=void 0;var Lb=function(){function r(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(e,t,n){return t&&r(e.prototype,t),n&&r(e,n),e}}(),kb=Me;function jb(r,e){if(!(r instanceof e))throw new TypeError("Cannot call a class as a function")}var ci=function(){function r(e){jb(this,r),e instanceof p||(e=typeof e=="number"?p.alloc(e):p.from(e)),this._setBuffer(e),this.rewind()}return Lb(r,[{key:"_setBuffer",value:function(t){this._buffer=t,this.length=t.length}},{key:"buffer",value:function(){return this._buffer}},{key:"tap",value:function(t){return t(this),this}},{key:"clone",value:function(t){var n=new this.constructor(this.buffer());return n.seek(arguments.length===0?this.tell():t),n}},{key:"tell",value:function(){return this._index}},{key:"seek",value:function(t,n){return arguments.length===1&&(n=t,t="="),t==="+"?this._index+=n:t==="-"?this._index-=n:this._index=n,this}},{key:"rewind",value:function(){return this.seek(0)}},{key:"eof",value:function(){return this.tell()===this.buffer().length}},{key:"write",value:function(t,n,i){return this.seek("+",this.buffer().write(t,this.tell(),n,i))}},{key:"fill",value:function(t,n){return arguments.length===1&&(n=this.buffer().length-this.tell()),this.buffer().fill(t,this.tell(),this.tell()+n),this.seek("+",n),this}},{key:"slice",value:function(t){arguments.length===0&&(t=this.length-this.tell());var n=new this.constructor(this.buffer().slice(this.tell(),this.tell()+t));return this.seek("+",t),n}},{key:"copyFrom",value:function(t){var n=t instanceof p?t:t.buffer();return n.copy(this.buffer(),this.tell(),0,n.length),this.seek("+",n.length),this}},{key:"concat",value:function(t){t.forEach(function(i,a){i instanceof r&&(t[a]=i.buffer())}),t.unshift(this.buffer());var n=p.concat(t);return this._setBuffer(n),this}},{key:"toString",value:function(t,n){arguments.length===0?(t="utf8",n=this.buffer().length-this.tell()):arguments.length===1&&(n=this.buffer().length-this.tell());var i=this.buffer().toString(t,this.tell(),this.tell()+n);return this.seek("+",n),i}},{key:"writeBufferPadded",value:function(t){var n=(0,kb.calculatePadding)(t.length),i=p.alloc(n);return this.copyFrom(new r(t)).copyFrom(new r(i))}}]),r}();[[1,["readInt8","readUInt8"]],[2,["readInt16BE","readInt16LE","readUInt16BE","readUInt16LE"]],[4,["readInt32BE","readInt32LE","readUInt32BE","readUInt32LE","readFloatBE","readFloatLE"]],[8,["readDoubleBE","readDoubleLE"]]].forEach(function(r){r[1].forEach(function(e){ci.prototype[e]=function(){var n=this.buffer()[e](this.tell());return this.seek("+",r[0]),n}})}),[[1,["writeInt8","writeUInt8"]],[2,["writeInt16BE","writeInt16LE","writeUInt16BE","writeUInt16LE"]],[4,["writeInt32BE","writeInt32LE","writeUInt32BE","writeUInt32LE","writeFloatBE","writeFloatLE"]],[8,["writeDoubleBE","writeDoubleLE"]]].forEach(function(r){r[1].forEach(function(e){ci.prototype[e]=function(n){return this.buffer()[e](n,this.tell()),this.seek("+",r[0]),this}})}),bt.Cursor=ci,Object.defineProperty(D,"__esModule",{value:!0}),D.default=Yb;var Vb=hg,uu=fu(Vb),Gb=Wn,Hb=fu(Gb),su=bt;function fu(r){return r&&r.__esModule?r:{default:r}}var Wb=Math.pow(2,16),Xb={toXDR:function(e){var t=new su.Cursor(Wb);this.write(e,t);var n=t.tell();return t.rewind(),t.slice(n).buffer()},fromXDR:function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"raw",n=void 0;switch(t){case"raw":n=e;break;case"hex":n=p.from(e,"hex");break;case"base64":n=p.from(e,"base64");break;default:throw new Error("Invalid format "+t+', must be "raw", "hex", "base64"')}var i=new su.Cursor(n),a=this.read(i);return a},validateXDR:function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"raw";try{return this.fromXDR(e,t),!0}catch{return!1}}},zb={toXDR:function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"raw",t=this.constructor.toXDR(this);switch(e){case"raw":return t;case"hex":return t.toString("hex");case"base64":return t.toString("base64");default:throw new Error("Invalid format "+e+', must be "raw", "hex", "base64"')}}};function Yb(r){(0,uu.default)(r,Xb),(0,Hb.default)(r)&&(0,uu.default)(r.prototype,zb)}Object.defineProperty(se,"__esModule",{value:!0}),se.Int=void 0;var Kb=gt,cu=lu(Kb),Zb=D,Jb=lu(Zb);function lu(r){return r&&r.__esModule?r:{default:r}}var Ir=se.Int={read:function(e){return e.readInt32BE()},write:function(e,t){if(!(0,cu.default)(e))throw new Error("XDR Write Error: not a number");if(Math.floor(e)!==e)throw new Error("XDR Write Error: not an integer");t.writeInt32BE(e)},isValid:function(e){return!(0,cu.default)(e)||Math.floor(e)!==e?!1:e>=Ir.MIN_VALUE&&e<=Ir.MAX_VALUE}};Ir.MAX_VALUE=Math.pow(2,31)-1,Ir.MIN_VALUE=-Math.pow(2,31),(0,Jb.default)(Ir);var Rt={};function Qb(r){throw new Error('Could not dynamically require "'+r+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var hu={exports:{}};(function(r){/**
20
+ `+e.prev}function ct(r,e){var t=Nn(r),n=[];if(t){n.length=r.length;for(var i=0;i<r.length;i++)n[i]=pe(r,i)?e(r[i],r):""}var a=typeof Mn=="function"?Mn(r):[],o;if(ze){o={};for(var u=0;u<a.length;u++)o["$"+a[u]]=a[u]}for(var f in r)pe(r,f)&&(t&&String(Number(f))===f&&f<r.length||ze&&o["$"+f]instanceof Symbol||(Da.call(/[^\w$]/,f)?n.push(e(f,r)+": "+e(r[f],r)):n.push(f+": "+e(r[f],r))));if(typeof Mn=="function")for(var c=0;c<a.length;c++)Ba.call(r,a[c])&&n.push("["+e(a[c])+"]: "+e(r[a[c]],r));return n}var qn=ln,Ye=Bf,Tl=ll,Rl=qn("%TypeError%"),lt=qn("%WeakMap%",!0),ht=qn("%Map%",!0),Fl=Ye("WeakMap.prototype.get",!0),Ml=Ye("WeakMap.prototype.set",!0),Dl=Ye("WeakMap.prototype.has",!0),Cl=Ye("Map.prototype.get",!0),Nl=Ye("Map.prototype.set",!0),Bl=Ye("Map.prototype.has",!0),Ln=function(r,e){for(var t=r,n;(n=t.next)!==null;t=n)if(n.key===e)return t.next=n.next,n.next=r.next,r.next=n,n},Ul=function(r,e){var t=Ln(r,e);return t&&t.value},ql=function(r,e,t){var n=Ln(r,e);n?n.value=t:r.next={key:e,next:r.next,value:t}},Ll=function(r,e){return!!Ln(r,e)},kl=function(){var e,t,n,i={assert:function(a){if(!i.has(a))throw new Rl("Side channel does not contain "+Tl(a))},get:function(a){if(lt&&a&&(typeof a=="object"||typeof a=="function")){if(e)return Fl(e,a)}else if(ht){if(t)return Cl(t,a)}else if(n)return Ul(n,a)},has:function(a){if(lt&&a&&(typeof a=="object"||typeof a=="function")){if(e)return Dl(e,a)}else if(ht){if(t)return Bl(t,a)}else if(n)return Ll(n,a);return!1},set:function(a,o){lt&&a&&(typeof a=="object"||typeof a=="function")?(e||(e=new lt),Ml(e,a,o)):ht?(t||(t=new ht),Nl(t,a,o)):(n||(n={key:{},next:null}),ql(n,a,o))}};return i},jl=String.prototype.replace,Vl=/%20/g,kn={RFC1738:"RFC1738",RFC3986:"RFC3986"},za={default:kn.RFC3986,formatters:{RFC1738:function(r){return jl.call(r,Vl,"+")},RFC3986:function(r){return String(r)}},RFC1738:kn.RFC1738,RFC3986:kn.RFC3986},Gl=za,jn=Object.prototype.hasOwnProperty,Re=Array.isArray,re=function(){for(var r=[],e=0;e<256;++e)r.push("%"+((e<16?"0":"")+e.toString(16)).toUpperCase());return r}(),Hl=function(e){for(;e.length>1;){var t=e.pop(),n=t.obj[t.prop];if(Re(n)){for(var i=[],a=0;a<n.length;++a)typeof n[a]<"u"&&i.push(n[a]);t.obj[t.prop]=i}}},Ya=function(e,t){for(var n=t&&t.plainObjects?Object.create(null):{},i=0;i<e.length;++i)typeof e[i]<"u"&&(n[i]=e[i]);return n},Wl=function r(e,t,n){if(!t)return e;if(typeof t!="object"){if(Re(e))e.push(t);else if(e&&typeof e=="object")(n&&(n.plainObjects||n.allowPrototypes)||!jn.call(Object.prototype,t))&&(e[t]=!0);else return[e,t];return e}if(!e||typeof e!="object")return[e].concat(t);var i=e;return Re(e)&&!Re(t)&&(i=Ya(e,n)),Re(e)&&Re(t)?(t.forEach(function(a,o){if(jn.call(e,o)){var u=e[o];u&&typeof u=="object"&&a&&typeof a=="object"?e[o]=r(u,a,n):e.push(a)}else e[o]=a}),e):Object.keys(t).reduce(function(a,o){var u=t[o];return jn.call(a,o)?a[o]=r(a[o],u,n):a[o]=u,a},i)},Xl=function(e,t){return Object.keys(t).reduce(function(n,i){return n[i]=t[i],n},e)},zl=function(r,e,t){var n=r.replace(/\+/g," ");if(t==="iso-8859-1")return n.replace(/%[0-9a-f]{2}/gi,unescape);try{return decodeURIComponent(n)}catch{return n}},Yl=function(e,t,n,i,a){if(e.length===0)return e;var o=e;if(typeof e=="symbol"?o=Symbol.prototype.toString.call(e):typeof e!="string"&&(o=String(e)),n==="iso-8859-1")return escape(o).replace(/%u[0-9a-f]{4}/gi,function(l){return"%26%23"+parseInt(l.slice(2),16)+"%3B"});for(var u="",f=0;f<o.length;++f){var c=o.charCodeAt(f);if(c===45||c===46||c===95||c===126||c>=48&&c<=57||c>=65&&c<=90||c>=97&&c<=122||a===Gl.RFC1738&&(c===40||c===41)){u+=o.charAt(f);continue}if(c<128){u=u+re[c];continue}if(c<2048){u=u+(re[192|c>>6]+re[128|c&63]);continue}if(c<55296||c>=57344){u=u+(re[224|c>>12]+re[128|c>>6&63]+re[128|c&63]);continue}f+=1,c=65536+((c&1023)<<10|o.charCodeAt(f)&1023),u+=re[240|c>>18]+re[128|c>>12&63]+re[128|c>>6&63]+re[128|c&63]}return u},Kl=function(e){for(var t=[{obj:{o:e},prop:"o"}],n=[],i=0;i<t.length;++i)for(var a=t[i],o=a.obj[a.prop],u=Object.keys(o),f=0;f<u.length;++f){var c=u[f],l=o[c];typeof l=="object"&&l!==null&&n.indexOf(l)===-1&&(t.push({obj:o,prop:c}),n.push(l))}return Hl(t),e},Zl=function(e){return Object.prototype.toString.call(e)==="[object RegExp]"},Jl=function(e){return!e||typeof e!="object"?!1:!!(e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer(e))},Ql=function(e,t){return[].concat(e,t)},eh=function(e,t){if(Re(e)){for(var n=[],i=0;i<e.length;i+=1)n.push(t(e[i]));return n}return t(e)},rh={arrayToObject:Ya,assign:Xl,combine:Ql,compact:Kl,decode:zl,encode:Yl,isBuffer:Jl,isRegExp:Zl,maybeMap:eh,merge:Wl},Ka=kl,dt=rh,$r=za,th=Object.prototype.hasOwnProperty,Za={brackets:function(e){return e+"[]"},comma:"comma",indices:function(e,t){return e+"["+t+"]"},repeat:function(e){return e}},oe=Array.isArray,nh=Array.prototype.push,Ja=function(r,e){nh.apply(r,oe(e)?e:[e])},ih=Date.prototype.toISOString,Qa=$r.default,k={addQueryPrefix:!1,allowDots:!1,charset:"utf-8",charsetSentinel:!1,delimiter:"&",encode:!0,encoder:dt.encode,encodeValuesOnly:!1,format:Qa,formatter:$r.formatters[Qa],indices:!1,serializeDate:function(e){return ih.call(e)},skipNulls:!1,strictNullHandling:!1},ah=function(e){return typeof e=="string"||typeof e=="number"||typeof e=="boolean"||typeof e=="symbol"||typeof e=="bigint"},Vn={},oh=function r(e,t,n,i,a,o,u,f,c,l,s,h,y,w,S,O){for(var b=e,E=O,d=0,I=!1;(E=E.get(Vn))!==void 0&&!I;){var T=E.get(e);if(d+=1,typeof T<"u"){if(T===d)throw new RangeError("Cyclic object value");I=!0}typeof E.get(Vn)>"u"&&(d=0)}if(typeof f=="function"?b=f(t,b):b instanceof Date?b=s(b):n==="comma"&&oe(b)&&(b=dt.maybeMap(b,function(we){return we instanceof Date?s(we):we})),b===null){if(a)return u&&!w?u(t,k.encoder,S,"key",h):t;b=""}if(ah(b)||dt.isBuffer(b)){if(u){var F=w?t:u(t,k.encoder,S,"key",h);return[y(F)+"="+y(u(b,k.encoder,S,"value",h))]}return[y(t)+"="+y(String(b))]}var m=[];if(typeof b>"u")return m;var g;if(n==="comma"&&oe(b))w&&u&&(b=dt.maybeMap(b,u)),g=[{value:b.length>0?b.join(",")||null:void 0}];else if(oe(f))g=f;else{var v=Object.keys(b);g=c?v.sort(c):v}for(var A=i&&oe(b)&&b.length===1?t+"[]":t,P=0;P<g.length;++P){var M=g[P],z=typeof M=="object"&&typeof M.value<"u"?M.value:b[M];if(!(o&&z===null)){var me=oe(b)?typeof n=="function"?n(A,M):A:A+(l?"."+M:"["+M+"]");O.set(e,d);var lr=Ka();lr.set(Vn,O),Ja(m,r(z,me,n,i,a,o,n==="comma"&&w&&oe(b)?null:u,f,c,l,s,h,y,w,S,lr))}}return m},uh=function(e){if(!e)return k;if(e.encoder!==null&&typeof e.encoder<"u"&&typeof e.encoder!="function")throw new TypeError("Encoder has to be a function.");var t=e.charset||k.charset;if(typeof e.charset<"u"&&e.charset!=="utf-8"&&e.charset!=="iso-8859-1")throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var n=$r.default;if(typeof e.format<"u"){if(!th.call($r.formatters,e.format))throw new TypeError("Unknown format option provided.");n=e.format}var i=$r.formatters[n],a=k.filter;return(typeof e.filter=="function"||oe(e.filter))&&(a=e.filter),{addQueryPrefix:typeof e.addQueryPrefix=="boolean"?e.addQueryPrefix:k.addQueryPrefix,allowDots:typeof e.allowDots>"u"?k.allowDots:!!e.allowDots,charset:t,charsetSentinel:typeof e.charsetSentinel=="boolean"?e.charsetSentinel:k.charsetSentinel,delimiter:typeof e.delimiter>"u"?k.delimiter:e.delimiter,encode:typeof e.encode=="boolean"?e.encode:k.encode,encoder:typeof e.encoder=="function"?e.encoder:k.encoder,encodeValuesOnly:typeof e.encodeValuesOnly=="boolean"?e.encodeValuesOnly:k.encodeValuesOnly,filter:a,format:n,formatter:i,serializeDate:typeof e.serializeDate=="function"?e.serializeDate:k.serializeDate,skipNulls:typeof e.skipNulls=="boolean"?e.skipNulls:k.skipNulls,sort:typeof e.sort=="function"?e.sort:null,strictNullHandling:typeof e.strictNullHandling=="boolean"?e.strictNullHandling:k.strictNullHandling}},sh=function(r,e){var t=r,n=uh(e),i,a;typeof n.filter=="function"?(a=n.filter,t=a("",t)):oe(n.filter)&&(a=n.filter,i=a);var o=[];if(typeof t!="object"||t===null)return"";var u;e&&e.arrayFormat in Za?u=e.arrayFormat:e&&"indices"in e?u=e.indices?"indices":"repeat":u="indices";var f=Za[u];if(e&&"commaRoundTrip"in e&&typeof e.commaRoundTrip!="boolean")throw new TypeError("`commaRoundTrip` must be a boolean, or absent");var c=f==="comma"&&e&&e.commaRoundTrip;i||(i=Object.keys(t)),n.sort&&i.sort(n.sort);for(var l=Ka(),s=0;s<i.length;++s){var h=i[s];n.skipNulls&&t[h]===null||Ja(o,oh(t[h],h,f,c,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,l))}var y=o.join(n.delimiter),w=n.addQueryPrefix===!0?"?":"";return n.charsetSentinel&&(n.charset==="iso-8859-1"?w+="utf8=%26%2310003%3B&":w+="utf8=%E2%9C%93&"),y.length>0?w+y:""},fh=be(sh);let eo={storeIdentifier:"",environment:"prod"};function ch(r){eo=r}function W(){return eo}const lh=(r,e="")=>{switch(r){case"prod":return"https://api.rechargeapps.com";case"stage":return"https://api.stage.rechargeapps.com";case"preprod":case"prestage":return`${e}/api`}},hh=(r,e="")=>{switch(r){case"prod":return"https://admin.rechargeapps.com";case"stage":return"https://admin.stage.rechargeapps.com";case"preprod":case"prestage":return e}},dh=r=>{switch(r){case"prod":case"preprod":return"https://static.rechargecdn.com";case"stage":case"prestage":return"https://static.stage.rechargecdn.com"}},ph="/tools/recurring";class Er{constructor(e,t){this.name="RechargeRequestError",this.message=e,this.status=t}}function yh(r){return fh(r,{encode:!1,indices:!1,arrayFormat:"comma"})}function _(r,e){return{...r,internalFnCall:r.internalFnCall??e,internalRequestId:r.internalRequestId??Vi()}}async function pt(r,e,t={}){const n=W();return ue(r,`${dh(n.environment)}/store/${n.storeIdentifier}${e}`,t)}async function $(r,e,{id:t,query:n,data:i,headers:a}={},o){const{environment:u,environmentUri:f,storeIdentifier:c,loginRetryFn:l,appName:s,appVersion:h}=W();if(!c)throw new Error("InitRecharge has not been called and/or no store identifier has been defined.");const y=o.apiToken;if(!y)throw new Error("No API token defined on session.");const w=lh(u,f),S={"X-Recharge-Access-Token":y,"X-Recharge-Version":"2021-11","X-Recharge-Sdk-Fn":o.internalFnCall,...s?{"X-Recharge-Sdk-App-Name":s}:{},...h?{"X-Recharge-Sdk-App-Version":h}:{},"X-Recharge-Sdk-Version":"1.39.0","X-Request-Id":o.internalRequestId,...o.tmp_fn_identifier?{"X-Recharge-Sdk-Fn-Identifier":o.tmp_fn_identifier}:{},...a||{}},O={shop_url:c,...n};try{return await ue(r,`${w}${e}`,{id:t,query:O,data:i,headers:S})}catch(b){if(l&&b instanceof Er&&b.status===401)return l().then(E=>{if(E)return ue(r,`${w}${e}`,{id:t,query:O,data:i,headers:{...S,"X-Recharge-Access-Token":E.apiToken}});throw b});throw b}}async function Ke(r,e,t={}){return ue(r,`${ph}${e}`,t)}async function ue(r,e,{id:t,query:n,data:i,headers:a}={}){let o=e.trim();if(t&&(o=[o,`${t}`.trim()].join("/")),n){let s;[o,s]=o.split("?");const h=[s,yh(n)].join("&").replace(/^&/,"");o=`${o}${h?`?${h}`:""}`}let u;i&&r!=="get"&&(u=JSON.stringify(i));const f={Accept:"application/json","Content-Type":"application/json","X-Recharge-App":"storefront-client",...a||{}},c=await fetch(o,{method:r,headers:f,body:u});let l;try{l=await c.json()}catch{}if(!c.ok)throw c.status===502||c.status===504?new Er("A gateway error occurred while making the request",c.status):l&&l.error?new Er(l.error,c.status):l&&l.errors?new Er(JSON.stringify(l.errors),c.status):new Er("A connection error occurred while making the request");return l}function gh(r,e){return $("get","/addresses",{query:e},_(r,"listAddresses"))}async function vh(r,e,t){if(e===void 0||e==="")throw new Error("ID is required");const{address:n}=await $("get","/addresses",{id:e,query:{include:t?.include}},_(r,"getAddress"));return n}async function _h(r,e){const{address:t}=await $("post","/addresses",{data:{customer_id:r.customerId?Number(r.customerId):void 0,...e}},_(r,"createAddress"));return t}async function Gn(r,e,t,n){if(e===void 0||e==="")throw new Error("ID is required");const{address:i}=await $("put","/addresses",{id:e,data:t,query:n},_(r,"updateAddress"));return i}async function mh(r,e,t,n){return Gn(_(r,"applyDiscountToAddress"),e,{discounts:[{code:t}]},n)}async function wh(r,e,t){if(e===void 0||e==="")throw new Error("Id is required");return Gn(_(r,"removeDiscountsFromAddress"),e,{discounts:[]},t)}function bh(r,e){if(e===void 0||e==="")throw new Error("ID is required");return $("delete","/addresses",{id:e},_(r,"deleteAddress"))}async function $h(r,e){const{address:t}=await $("post","/addresses/merge",{data:e},_(r,"mergeAddresses"));return t}async function Eh(r,e,t){if(e===void 0||e==="")throw new Error("ID is required");const{charge:n}=await $("post",`/addresses/${e}/charges/skip`,{data:t},_(r,"skipFutureCharge"));return n}var Ah=Object.freeze({__proto__:null,applyDiscountToAddress:mh,createAddress:_h,deleteAddress:bh,getAddress:vh,listAddresses:gh,mergeAddresses:$h,removeDiscountsFromAddress:wh,skipFutureCharge:Eh,updateAddress:Gn});async function Sh(){const{storefrontAccessToken:r}=W(),e={};r&&(e["X-Recharge-Storefront-Access-Token"]=r);const t=await Ke("get","/access",{headers:e});return{apiToken:t.api_token,customerId:t.customer_id,message:t.message}}async function Oh(r,e){return ro(r,e)}async function ro(r,e){if(!r)throw new Error("Shopify storefront token is required");const{storeIdentifier:t}=W();if(!t)throw new Error("InitRecharge has not been called and/or no store identifier has been defined.");const{api_token:n,customer_id:i,message:a}=await Ar("post","/shopify_storefront_access",{data:{customer_token:e,storefront_token:r,shop_url:t}});return n?{apiToken:n,customerId:i,message:a}:null}async function Ih(r){const{storeIdentifier:e}=W();if(!e)throw new Error("InitRecharge has not been called and/or no store identifier has been defined.");const{api_token:t,customer_id:n,message:i}=await Ar("post","/shopify_customer_account_api_access",{data:{customer_token:r,shop_url:e}});return t?{apiToken:t,customerId:n,message:i}:null}async function Ph(r,e={}){if(!r)throw new Error("Email is required.");const{storeIdentifier:t}=W();if(!t)throw new Error("InitRecharge has not been called and/or no store identifier has been defined.");const n=await Ar("post","/attempt_login",{data:{email:r,shop:t,...e}});if(n.errors)throw new Error(n.errors);return n.session_token}async function xh(r,e={}){if(!r)throw new Error("Email is required.");const{storefrontAccessToken:t}=W(),n={};t&&(n["X-Recharge-Storefront-Access-Token"]=t);const i=await Ke("post","/attempt_login",{data:{email:r,...e},headers:n});if(i.errors)throw new Error(i.errors);return i.session_token}async function Th(r,e,t){if(!r)throw new Error("Email is required.");if(!e)throw new Error("Session token is required.");if(!t)throw new Error("Code is required.");const{storeIdentifier:n}=W();if(!n)throw new Error("InitRecharge has not been called and/or no store identifier has been defined.");const i=await Ar("post","/validate_login",{data:{code:t,email:r,session_token:e,shop:n}});if(i.errors)throw new Error(i.errors);return{apiToken:i.api_token,customerId:i.customer_id}}async function Rh(r,e,t){if(!r)throw new Error("Email is required.");if(!e)throw new Error("Session token is required.");if(!t)throw new Error("Code is required.");const{storefrontAccessToken:n}=W(),i={};n&&(i["X-Recharge-Storefront-Access-Token"]=n);const a=await Ke("post","/validate_login",{data:{code:t,email:r,session_token:e},headers:i});if(a.errors)throw new Error(a.errors);return{apiToken:a.api_token,customerId:a.customer_id}}function Fh(){const{customerHash:r}=W(),{pathname:e,search:t}=window.location,n=new URLSearchParams(t).get("token"),i=e.split("/").filter(Boolean),a=i.findIndex(u=>u==="portal"),o=a!==-1?i[a+1]:r;if(!n||!o)throw new Error("Not in context of Recharge Customer Portal or URL did not contain correct params");return{customerHash:o,token:n}}async function Mh(){const{customerHash:r,token:e}=Fh(),{storeIdentifier:t}=W(),n=await Ar("post",`/customers/${r}/access`,{data:{token:e,shop:t}});return{apiToken:n.api_token,customerId:n.customer_id}}async function Ar(r,e,{id:t,query:n,data:i,headers:a}={}){const{environment:o,environmentUri:u,storefrontAccessToken:f,appName:c,appVersion:l}=W(),s=hh(o,u),h={...f?{"X-Recharge-Storefront-Access-Token":f}:{},...c?{"X-Recharge-Sdk-App-Name":c}:{},...l?{"X-Recharge-Sdk-App-Version":l}:{},"X-Recharge-Sdk-Version":"1.39.0",...a||{}};return ue(r,`${s}${e}`,{id:t,query:n,data:i,headers:h})}var Dh=Object.freeze({__proto__:null,loginCustomerPortal:Mh,loginShopifyApi:Oh,loginShopifyAppProxy:Sh,loginWithShopifyCustomerAccount:Ih,loginWithShopifyStorefront:ro,sendPasswordlessCode:Ph,sendPasswordlessCodeAppProxy:xh,validatePasswordlessCode:Th,validatePasswordlessCodeAppProxy:Rh}),to={},Hn={},se={},Ch=typeof U=="object"&&U&&U.Object===Object&&U,no=Ch,Nh=no,Bh=typeof self=="object"&&self&&self.Object===Object&&self,Uh=Nh||Bh||Function("return this")(),fe=Uh,qh=fe,Lh=qh.Symbol,yt=Lh,io=yt,ao=Object.prototype,kh=ao.hasOwnProperty,jh=ao.toString,Sr=io?io.toStringTag:void 0;function Vh(r){var e=kh.call(r,Sr),t=r[Sr];try{r[Sr]=void 0;var n=!0}catch{}var i=jh.call(r);return n&&(e?r[Sr]=t:delete r[Sr]),i}var Gh=Vh,Hh=Object.prototype,Wh=Hh.toString;function Xh(r){return Wh.call(r)}var zh=Xh,oo=yt,Yh=Gh,Kh=zh,Zh="[object Null]",Jh="[object Undefined]",uo=oo?oo.toStringTag:void 0;function Qh(r){return r==null?r===void 0?Jh:Zh:uo&&uo in Object(r)?Yh(r):Kh(r)}var ge=Qh;function ed(r){return r!=null&&typeof r=="object"}var ve=ed,rd=ge,td=ve,nd="[object Number]";function id(r){return typeof r=="number"||td(r)&&rd(r)==nd}var gt=id,D={};function ad(r){var e=typeof r;return r!=null&&(e=="object"||e=="function")}var Ze=ad,od=ge,ud=Ze,sd="[object AsyncFunction]",fd="[object Function]",cd="[object GeneratorFunction]",ld="[object Proxy]";function hd(r){if(!ud(r))return!1;var e=od(r);return e==fd||e==cd||e==sd||e==ld}var Wn=hd,dd=fe,pd=dd["__core-js_shared__"],yd=pd,Xn=yd,so=function(){var r=/[^.]+$/.exec(Xn&&Xn.keys&&Xn.keys.IE_PROTO||"");return r?"Symbol(src)_1."+r:""}();function gd(r){return!!so&&so in r}var vd=gd,_d=Function.prototype,md=_d.toString;function wd(r){if(r!=null){try{return md.call(r)}catch{}try{return r+""}catch{}}return""}var fo=wd,bd=Wn,$d=vd,Ed=Ze,Ad=fo,Sd=/[\\^$.*+?()[\]{}|]/g,Od=/^\[object .+?Constructor\]$/,Id=Function.prototype,Pd=Object.prototype,xd=Id.toString,Td=Pd.hasOwnProperty,Rd=RegExp("^"+xd.call(Td).replace(Sd,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Fd(r){if(!Ed(r)||$d(r))return!1;var e=bd(r)?Rd:Od;return e.test(Ad(r))}var Md=Fd;function Dd(r,e){return r?.[e]}var Cd=Dd,Nd=Md,Bd=Cd;function Ud(r,e){var t=Bd(r,e);return Nd(t)?t:void 0}var Fe=Ud,qd=Fe,Ld=function(){try{var r=qd(Object,"defineProperty");return r({},"",{}),r}catch{}}(),co=Ld,lo=co;function kd(r,e,t){e=="__proto__"&&lo?lo(r,e,{configurable:!0,enumerable:!0,value:t,writable:!0}):r[e]=t}var ho=kd;function jd(r,e){return r===e||r!==r&&e!==e}var vt=jd,Vd=ho,Gd=vt,Hd=Object.prototype,Wd=Hd.hasOwnProperty;function Xd(r,e,t){var n=r[e];(!(Wd.call(r,e)&&Gd(n,t))||t===void 0&&!(e in r))&&Vd(r,e,t)}var zd=Xd,Yd=zd,Kd=ho;function Zd(r,e,t,n){var i=!t;t||(t={});for(var a=-1,o=e.length;++a<o;){var u=e[a],f=n?n(t[u],r[u],u,t,r):void 0;f===void 0&&(f=r[u]),i?Kd(t,u,f):Yd(t,u,f)}return t}var Jd=Zd;function Qd(r){return r}var _t=Qd;function ep(r,e,t){switch(t.length){case 0:return r.call(e);case 1:return r.call(e,t[0]);case 2:return r.call(e,t[0],t[1]);case 3:return r.call(e,t[0],t[1],t[2])}return r.apply(e,t)}var rp=ep,tp=rp,po=Math.max;function np(r,e,t){return e=po(e===void 0?r.length-1:e,0),function(){for(var n=arguments,i=-1,a=po(n.length-e,0),o=Array(a);++i<a;)o[i]=n[e+i];i=-1;for(var u=Array(e+1);++i<e;)u[i]=n[i];return u[e]=t(o),tp(r,this,u)}}var ip=np;function ap(r){return function(){return r}}var op=ap,up=op,yo=co,sp=_t,fp=yo?function(r,e){return yo(r,"toString",{configurable:!0,enumerable:!1,value:up(e),writable:!0})}:sp,cp=fp,lp=800,hp=16,dp=Date.now;function pp(r){var e=0,t=0;return function(){var n=dp(),i=hp-(n-t);if(t=n,i>0){if(++e>=lp)return arguments[0]}else e=0;return r.apply(void 0,arguments)}}var yp=pp,gp=cp,vp=yp,_p=vp(gp),mp=_p,wp=_t,bp=ip,$p=mp;function Ep(r,e){return $p(bp(r,e,wp),r+"")}var Ap=Ep,Sp=9007199254740991;function Op(r){return typeof r=="number"&&r>-1&&r%1==0&&r<=Sp}var zn=Op,Ip=Wn,Pp=zn;function xp(r){return r!=null&&Pp(r.length)&&!Ip(r)}var Or=xp,Tp=9007199254740991,Rp=/^(?:0|[1-9]\d*)$/;function Fp(r,e){var t=typeof r;return e=e??Tp,!!e&&(t=="number"||t!="symbol"&&Rp.test(r))&&r>-1&&r%1==0&&r<e}var Yn=Fp,Mp=vt,Dp=Or,Cp=Yn,Np=Ze;function Bp(r,e,t){if(!Np(t))return!1;var n=typeof e;return(n=="number"?Dp(t)&&Cp(e,t.length):n=="string"&&e in t)?Mp(t[e],r):!1}var go=Bp,Up=Ap,qp=go;function Lp(r){return Up(function(e,t){var n=-1,i=t.length,a=i>1?t[i-1]:void 0,o=i>2?t[2]:void 0;for(a=r.length>3&&typeof a=="function"?(i--,a):void 0,o&&qp(t[0],t[1],o)&&(a=i<3?void 0:a,i=1),e=Object(e);++n<i;){var u=t[n];u&&r(e,u,n,a)}return e})}var kp=Lp;function jp(r,e){for(var t=-1,n=Array(r);++t<r;)n[t]=e(t);return n}var vo=jp,Vp=ge,Gp=ve,Hp="[object Arguments]";function Wp(r){return Gp(r)&&Vp(r)==Hp}var Xp=Wp,_o=Xp,zp=ve,mo=Object.prototype,Yp=mo.hasOwnProperty,Kp=mo.propertyIsEnumerable,Zp=_o(function(){return arguments}())?_o:function(r){return zp(r)&&Yp.call(r,"callee")&&!Kp.call(r,"callee")},wo=Zp,Jp=Array.isArray,V=Jp,mt={exports:{}};function Qp(){return!1}var ey=Qp;mt.exports,function(r,e){var t=fe,n=ey,i=e&&!e.nodeType&&e,a=i&&!0&&r&&!r.nodeType&&r,o=a&&a.exports===i,u=o?t.Buffer:void 0,f=u?u.isBuffer:void 0,c=f||n;r.exports=c}(mt,mt.exports);var bo=mt.exports,ry=ge,ty=zn,ny=ve,iy="[object Arguments]",ay="[object Array]",oy="[object Boolean]",uy="[object Date]",sy="[object Error]",fy="[object Function]",cy="[object Map]",ly="[object Number]",hy="[object Object]",dy="[object RegExp]",py="[object Set]",yy="[object String]",gy="[object WeakMap]",vy="[object ArrayBuffer]",_y="[object DataView]",my="[object Float32Array]",wy="[object Float64Array]",by="[object Int8Array]",$y="[object Int16Array]",Ey="[object Int32Array]",Ay="[object Uint8Array]",Sy="[object Uint8ClampedArray]",Oy="[object Uint16Array]",Iy="[object Uint32Array]",R={};R[my]=R[wy]=R[by]=R[$y]=R[Ey]=R[Ay]=R[Sy]=R[Oy]=R[Iy]=!0,R[iy]=R[ay]=R[vy]=R[oy]=R[_y]=R[uy]=R[sy]=R[fy]=R[cy]=R[ly]=R[hy]=R[dy]=R[py]=R[yy]=R[gy]=!1;function Py(r){return ny(r)&&ty(r.length)&&!!R[ry(r)]}var xy=Py;function Ty(r){return function(e){return r(e)}}var Ry=Ty,wt={exports:{}};wt.exports,function(r,e){var t=no,n=e&&!e.nodeType&&e,i=n&&!0&&r&&!r.nodeType&&r,a=i&&i.exports===n,o=a&&t.process,u=function(){try{var f=i&&i.require&&i.require("util").types;return f||o&&o.binding&&o.binding("util")}catch{}}();r.exports=u}(wt,wt.exports);var Fy=wt.exports,My=xy,Dy=Ry,$o=Fy,Eo=$o&&$o.isTypedArray,Cy=Eo?Dy(Eo):My,Ao=Cy,Ny=vo,By=wo,Uy=V,qy=bo,Ly=Yn,ky=Ao,jy=Object.prototype,Vy=jy.hasOwnProperty;function Gy(r,e){var t=Uy(r),n=!t&&By(r),i=!t&&!n&&qy(r),a=!t&&!n&&!i&&ky(r),o=t||n||i||a,u=o?Ny(r.length,String):[],f=u.length;for(var c in r)(e||Vy.call(r,c))&&!(o&&(c=="length"||i&&(c=="offset"||c=="parent")||a&&(c=="buffer"||c=="byteLength"||c=="byteOffset")||Ly(c,f)))&&u.push(c);return u}var So=Gy,Hy=Object.prototype;function Wy(r){var e=r&&r.constructor,t=typeof e=="function"&&e.prototype||Hy;return r===t}var Oo=Wy;function Xy(r){var e=[];if(r!=null)for(var t in Object(r))e.push(t);return e}var zy=Xy,Yy=Ze,Ky=Oo,Zy=zy,Jy=Object.prototype,Qy=Jy.hasOwnProperty;function eg(r){if(!Yy(r))return Zy(r);var e=Ky(r),t=[];for(var n in r)n=="constructor"&&(e||!Qy.call(r,n))||t.push(n);return t}var rg=eg,tg=So,ng=rg,ig=Or;function ag(r){return ig(r)?tg(r,!0):ng(r)}var og=ag,ug=Jd,sg=kp,fg=og,cg=sg(function(r,e){ug(e,fg(e),r)}),lg=cg,hg=lg,bt={},Me={};function dg(r,e){for(var t=-1,n=r==null?0:r.length;++t<n;)if(!e(r[t],t,r))return!1;return!0}var pg=dg;function yg(r){return function(e,t,n){for(var i=-1,a=Object(e),o=n(e),u=o.length;u--;){var f=o[r?u:++i];if(t(a[f],f,a)===!1)break}return e}}var gg=yg,vg=gg,_g=vg(),mg=_g;function wg(r,e){return function(t){return r(e(t))}}var bg=wg,$g=bg,Eg=$g(Object.keys,Object),Ag=Eg,Sg=Oo,Og=Ag,Ig=Object.prototype,Pg=Ig.hasOwnProperty;function xg(r){if(!Sg(r))return Og(r);var e=[];for(var t in Object(r))Pg.call(r,t)&&t!="constructor"&&e.push(t);return e}var Tg=xg,Rg=So,Fg=Tg,Mg=Or;function Dg(r){return Mg(r)?Rg(r):Fg(r)}var $t=Dg,Cg=mg,Ng=$t;function Bg(r,e){return r&&Cg(r,e,Ng)}var Ug=Bg,qg=Or;function Lg(r,e){return function(t,n){if(t==null)return t;if(!qg(t))return r(t,n);for(var i=t.length,a=e?i:-1,o=Object(t);(e?a--:++a<i)&&n(o[a],a,o)!==!1;);return t}}var kg=Lg,jg=Ug,Vg=kg,Gg=Vg(jg),Kn=Gg,Hg=Kn;function Wg(r,e){var t=!0;return Hg(r,function(n,i,a){return t=!!e(n,i,a),t}),t}var Xg=Wg;function zg(){this.__data__=[],this.size=0}var Yg=zg,Kg=vt;function Zg(r,e){for(var t=r.length;t--;)if(Kg(r[t][0],e))return t;return-1}var Et=Zg,Jg=Et,Qg=Array.prototype,ev=Qg.splice;function rv(r){var e=this.__data__,t=Jg(e,r);if(t<0)return!1;var n=e.length-1;return t==n?e.pop():ev.call(e,t,1),--this.size,!0}var tv=rv,nv=Et;function iv(r){var e=this.__data__,t=nv(e,r);return t<0?void 0:e[t][1]}var av=iv,ov=Et;function uv(r){return ov(this.__data__,r)>-1}var sv=uv,fv=Et;function cv(r,e){var t=this.__data__,n=fv(t,r);return n<0?(++this.size,t.push([r,e])):t[n][1]=e,this}var lv=cv,hv=Yg,dv=tv,pv=av,yv=sv,gv=lv;function Je(r){var e=-1,t=r==null?0:r.length;for(this.clear();++e<t;){var n=r[e];this.set(n[0],n[1])}}Je.prototype.clear=hv,Je.prototype.delete=dv,Je.prototype.get=pv,Je.prototype.has=yv,Je.prototype.set=gv;var At=Je,vv=At;function _v(){this.__data__=new vv,this.size=0}var mv=_v;function wv(r){var e=this.__data__,t=e.delete(r);return this.size=e.size,t}var bv=wv;function $v(r){return this.__data__.get(r)}var Ev=$v;function Av(r){return this.__data__.has(r)}var Sv=Av,Ov=Fe,Iv=fe,Pv=Ov(Iv,"Map"),Zn=Pv,xv=Fe,Tv=xv(Object,"create"),St=Tv,Io=St;function Rv(){this.__data__=Io?Io(null):{},this.size=0}var Fv=Rv;function Mv(r){var e=this.has(r)&&delete this.__data__[r];return this.size-=e?1:0,e}var Dv=Mv,Cv=St,Nv="__lodash_hash_undefined__",Bv=Object.prototype,Uv=Bv.hasOwnProperty;function qv(r){var e=this.__data__;if(Cv){var t=e[r];return t===Nv?void 0:t}return Uv.call(e,r)?e[r]:void 0}var Lv=qv,kv=St,jv=Object.prototype,Vv=jv.hasOwnProperty;function Gv(r){var e=this.__data__;return kv?e[r]!==void 0:Vv.call(e,r)}var Hv=Gv,Wv=St,Xv="__lodash_hash_undefined__";function zv(r,e){var t=this.__data__;return this.size+=this.has(r)?0:1,t[r]=Wv&&e===void 0?Xv:e,this}var Yv=zv,Kv=Fv,Zv=Dv,Jv=Lv,Qv=Hv,e_=Yv;function Qe(r){var e=-1,t=r==null?0:r.length;for(this.clear();++e<t;){var n=r[e];this.set(n[0],n[1])}}Qe.prototype.clear=Kv,Qe.prototype.delete=Zv,Qe.prototype.get=Jv,Qe.prototype.has=Qv,Qe.prototype.set=e_;var r_=Qe,Po=r_,t_=At,n_=Zn;function i_(){this.size=0,this.__data__={hash:new Po,map:new(n_||t_),string:new Po}}var a_=i_;function o_(r){var e=typeof r;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?r!=="__proto__":r===null}var u_=o_,s_=u_;function f_(r,e){var t=r.__data__;return s_(e)?t[typeof e=="string"?"string":"hash"]:t.map}var Ot=f_,c_=Ot;function l_(r){var e=c_(this,r).delete(r);return this.size-=e?1:0,e}var h_=l_,d_=Ot;function p_(r){return d_(this,r).get(r)}var y_=p_,g_=Ot;function v_(r){return g_(this,r).has(r)}var __=v_,m_=Ot;function w_(r,e){var t=m_(this,r),n=t.size;return t.set(r,e),this.size+=t.size==n?0:1,this}var b_=w_,$_=a_,E_=h_,A_=y_,S_=__,O_=b_;function er(r){var e=-1,t=r==null?0:r.length;for(this.clear();++e<t;){var n=r[e];this.set(n[0],n[1])}}er.prototype.clear=$_,er.prototype.delete=E_,er.prototype.get=A_,er.prototype.has=S_,er.prototype.set=O_;var Jn=er,I_=At,P_=Zn,x_=Jn,T_=200;function R_(r,e){var t=this.__data__;if(t instanceof I_){var n=t.__data__;if(!P_||n.length<T_-1)return n.push([r,e]),this.size=++t.size,this;t=this.__data__=new x_(n)}return t.set(r,e),this.size=t.size,this}var F_=R_,M_=At,D_=mv,C_=bv,N_=Ev,B_=Sv,U_=F_;function rr(r){var e=this.__data__=new M_(r);this.size=e.size}rr.prototype.clear=D_,rr.prototype.delete=C_,rr.prototype.get=N_,rr.prototype.has=B_,rr.prototype.set=U_;var xo=rr,q_="__lodash_hash_undefined__";function L_(r){return this.__data__.set(r,q_),this}var k_=L_;function j_(r){return this.__data__.has(r)}var V_=j_,G_=Jn,H_=k_,W_=V_;function It(r){var e=-1,t=r==null?0:r.length;for(this.__data__=new G_;++e<t;)this.add(r[e])}It.prototype.add=It.prototype.push=H_,It.prototype.has=W_;var X_=It;function z_(r,e){for(var t=-1,n=r==null?0:r.length;++t<n;)if(e(r[t],t,r))return!0;return!1}var Y_=z_;function K_(r,e){return r.has(e)}var Z_=K_,J_=X_,Q_=Y_,em=Z_,rm=1,tm=2;function nm(r,e,t,n,i,a){var o=t&rm,u=r.length,f=e.length;if(u!=f&&!(o&&f>u))return!1;var c=a.get(r),l=a.get(e);if(c&&l)return c==e&&l==r;var s=-1,h=!0,y=t&tm?new J_:void 0;for(a.set(r,e),a.set(e,r);++s<u;){var w=r[s],S=e[s];if(n)var O=o?n(S,w,s,e,r,a):n(w,S,s,r,e,a);if(O!==void 0){if(O)continue;h=!1;break}if(y){if(!Q_(e,function(b,E){if(!em(y,E)&&(w===b||i(w,b,t,n,a)))return y.push(E)})){h=!1;break}}else if(!(w===S||i(w,S,t,n,a))){h=!1;break}}return a.delete(r),a.delete(e),h}var To=nm,im=fe,am=im.Uint8Array,om=am;function um(r){var e=-1,t=Array(r.size);return r.forEach(function(n,i){t[++e]=[i,n]}),t}var sm=um;function fm(r){var e=-1,t=Array(r.size);return r.forEach(function(n){t[++e]=n}),t}var cm=fm,Ro=yt,Fo=om,lm=vt,hm=To,dm=sm,pm=cm,ym=1,gm=2,vm="[object Boolean]",_m="[object Date]",mm="[object Error]",wm="[object Map]",bm="[object Number]",$m="[object RegExp]",Em="[object Set]",Am="[object String]",Sm="[object Symbol]",Om="[object ArrayBuffer]",Im="[object DataView]",Mo=Ro?Ro.prototype:void 0,Qn=Mo?Mo.valueOf:void 0;function Pm(r,e,t,n,i,a,o){switch(t){case Im:if(r.byteLength!=e.byteLength||r.byteOffset!=e.byteOffset)return!1;r=r.buffer,e=e.buffer;case Om:return!(r.byteLength!=e.byteLength||!a(new Fo(r),new Fo(e)));case vm:case _m:case bm:return lm(+r,+e);case mm:return r.name==e.name&&r.message==e.message;case $m:case Am:return r==e+"";case wm:var u=dm;case Em:var f=n&ym;if(u||(u=pm),r.size!=e.size&&!f)return!1;var c=o.get(r);if(c)return c==e;n|=gm,o.set(r,e);var l=hm(u(r),u(e),n,i,a,o);return o.delete(r),l;case Sm:if(Qn)return Qn.call(r)==Qn.call(e)}return!1}var xm=Pm;function Tm(r,e){for(var t=-1,n=e.length,i=r.length;++t<n;)r[i+t]=e[t];return r}var Rm=Tm,Fm=Rm,Mm=V;function Dm(r,e,t){var n=e(r);return Mm(r)?n:Fm(n,t(r))}var Cm=Dm;function Nm(r,e){for(var t=-1,n=r==null?0:r.length,i=0,a=[];++t<n;){var o=r[t];e(o,t,r)&&(a[i++]=o)}return a}var Bm=Nm;function Um(){return[]}var qm=Um,Lm=Bm,km=qm,jm=Object.prototype,Vm=jm.propertyIsEnumerable,Do=Object.getOwnPropertySymbols,Gm=Do?function(r){return r==null?[]:(r=Object(r),Lm(Do(r),function(e){return Vm.call(r,e)}))}:km,Hm=Gm,Wm=Cm,Xm=Hm,zm=$t;function Ym(r){return Wm(r,zm,Xm)}var Km=Ym,Co=Km,Zm=1,Jm=Object.prototype,Qm=Jm.hasOwnProperty;function ew(r,e,t,n,i,a){var o=t&Zm,u=Co(r),f=u.length,c=Co(e),l=c.length;if(f!=l&&!o)return!1;for(var s=f;s--;){var h=u[s];if(!(o?h in e:Qm.call(e,h)))return!1}var y=a.get(r),w=a.get(e);if(y&&w)return y==e&&w==r;var S=!0;a.set(r,e),a.set(e,r);for(var O=o;++s<f;){h=u[s];var b=r[h],E=e[h];if(n)var d=o?n(E,b,h,e,r,a):n(b,E,h,r,e,a);if(!(d===void 0?b===E||i(b,E,t,n,a):d)){S=!1;break}O||(O=h=="constructor")}if(S&&!O){var I=r.constructor,T=e.constructor;I!=T&&"constructor"in r&&"constructor"in e&&!(typeof I=="function"&&I instanceof I&&typeof T=="function"&&T instanceof T)&&(S=!1)}return a.delete(r),a.delete(e),S}var rw=ew,tw=Fe,nw=fe,iw=tw(nw,"DataView"),aw=iw,ow=Fe,uw=fe,sw=ow(uw,"Promise"),fw=sw,cw=Fe,lw=fe,hw=cw(lw,"Set"),dw=hw,pw=Fe,yw=fe,gw=pw(yw,"WeakMap"),vw=gw,ei=aw,ri=Zn,ti=fw,ni=dw,ii=vw,No=ge,tr=fo,Bo="[object Map]",_w="[object Object]",Uo="[object Promise]",qo="[object Set]",Lo="[object WeakMap]",ko="[object DataView]",mw=tr(ei),ww=tr(ri),bw=tr(ti),$w=tr(ni),Ew=tr(ii),De=No;(ei&&De(new ei(new ArrayBuffer(1)))!=ko||ri&&De(new ri)!=Bo||ti&&De(ti.resolve())!=Uo||ni&&De(new ni)!=qo||ii&&De(new ii)!=Lo)&&(De=function(r){var e=No(r),t=e==_w?r.constructor:void 0,n=t?tr(t):"";if(n)switch(n){case mw:return ko;case ww:return Bo;case bw:return Uo;case $w:return qo;case Ew:return Lo}return e});var Aw=De,ai=xo,Sw=To,Ow=xm,Iw=rw,jo=Aw,Vo=V,Go=bo,Pw=Ao,xw=1,Ho="[object Arguments]",Wo="[object Array]",Pt="[object Object]",Tw=Object.prototype,Xo=Tw.hasOwnProperty;function Rw(r,e,t,n,i,a){var o=Vo(r),u=Vo(e),f=o?Wo:jo(r),c=u?Wo:jo(e);f=f==Ho?Pt:f,c=c==Ho?Pt:c;var l=f==Pt,s=c==Pt,h=f==c;if(h&&Go(r)){if(!Go(e))return!1;o=!0,l=!1}if(h&&!l)return a||(a=new ai),o||Pw(r)?Sw(r,e,t,n,i,a):Ow(r,e,f,t,n,i,a);if(!(t&xw)){var y=l&&Xo.call(r,"__wrapped__"),w=s&&Xo.call(e,"__wrapped__");if(y||w){var S=y?r.value():r,O=w?e.value():e;return a||(a=new ai),i(S,O,t,n,a)}}return h?(a||(a=new ai),Iw(r,e,t,n,i,a)):!1}var Fw=Rw,Mw=Fw,zo=ve;function Yo(r,e,t,n,i){return r===e?!0:r==null||e==null||!zo(r)&&!zo(e)?r!==r&&e!==e:Mw(r,e,t,n,Yo,i)}var Ko=Yo,Dw=xo,Cw=Ko,Nw=1,Bw=2;function Uw(r,e,t,n){var i=t.length,a=i,o=!n;if(r==null)return!a;for(r=Object(r);i--;){var u=t[i];if(o&&u[2]?u[1]!==r[u[0]]:!(u[0]in r))return!1}for(;++i<a;){u=t[i];var f=u[0],c=r[f],l=u[1];if(o&&u[2]){if(c===void 0&&!(f in r))return!1}else{var s=new Dw;if(n)var h=n(c,l,f,r,e,s);if(!(h===void 0?Cw(l,c,Nw|Bw,n,s):h))return!1}}return!0}var qw=Uw,Lw=Ze;function kw(r){return r===r&&!Lw(r)}var Zo=kw,jw=Zo,Vw=$t;function Gw(r){for(var e=Vw(r),t=e.length;t--;){var n=e[t],i=r[n];e[t]=[n,i,jw(i)]}return e}var Hw=Gw;function Ww(r,e){return function(t){return t==null?!1:t[r]===e&&(e!==void 0||r in Object(t))}}var Jo=Ww,Xw=qw,zw=Hw,Yw=Jo;function Kw(r){var e=zw(r);return e.length==1&&e[0][2]?Yw(e[0][0],e[0][1]):function(t){return t===r||Xw(t,r,e)}}var Zw=Kw,Jw=ge,Qw=ve,e0="[object Symbol]";function r0(r){return typeof r=="symbol"||Qw(r)&&Jw(r)==e0}var xt=r0,t0=V,n0=xt,i0=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,a0=/^\w*$/;function o0(r,e){if(t0(r))return!1;var t=typeof r;return t=="number"||t=="symbol"||t=="boolean"||r==null||n0(r)?!0:a0.test(r)||!i0.test(r)||e!=null&&r in Object(e)}var oi=o0,Qo=Jn,u0="Expected a function";function ui(r,e){if(typeof r!="function"||e!=null&&typeof e!="function")throw new TypeError(u0);var t=function(){var n=arguments,i=e?e.apply(this,n):n[0],a=t.cache;if(a.has(i))return a.get(i);var o=r.apply(this,n);return t.cache=a.set(i,o)||a,o};return t.cache=new(ui.Cache||Qo),t}ui.Cache=Qo;var s0=ui,f0=s0,c0=500;function l0(r){var e=f0(r,function(n){return t.size===c0&&t.clear(),n}),t=e.cache;return e}var h0=l0,d0=h0,p0=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,y0=/\\(\\)?/g,g0=d0(function(r){var e=[];return r.charCodeAt(0)===46&&e.push(""),r.replace(p0,function(t,n,i,a){e.push(i?a.replace(y0,"$1"):n||t)}),e}),v0=g0;function _0(r,e){for(var t=-1,n=r==null?0:r.length,i=Array(n);++t<n;)i[t]=e(r[t],t,r);return i}var si=_0,eu=yt,m0=si,w0=V,b0=xt,$0=1/0,ru=eu?eu.prototype:void 0,tu=ru?ru.toString:void 0;function nu(r){if(typeof r=="string")return r;if(w0(r))return m0(r,nu)+"";if(b0(r))return tu?tu.call(r):"";var e=r+"";return e=="0"&&1/r==-$0?"-0":e}var E0=nu,A0=E0;function S0(r){return r==null?"":A0(r)}var O0=S0,I0=V,P0=oi,x0=v0,T0=O0;function R0(r,e){return I0(r)?r:P0(r,e)?[r]:x0(T0(r))}var iu=R0,F0=xt,M0=1/0;function D0(r){if(typeof r=="string"||F0(r))return r;var e=r+"";return e=="0"&&1/r==-M0?"-0":e}var Tt=D0,C0=iu,N0=Tt;function B0(r,e){e=C0(e,r);for(var t=0,n=e.length;r!=null&&t<n;)r=r[N0(e[t++])];return t&&t==n?r:void 0}var au=B0,U0=au;function q0(r,e,t){var n=r==null?void 0:U0(r,e);return n===void 0?t:n}var L0=q0;function k0(r,e){return r!=null&&e in Object(r)}var j0=k0,V0=iu,G0=wo,H0=V,W0=Yn,X0=zn,z0=Tt;function Y0(r,e,t){e=V0(e,r);for(var n=-1,i=e.length,a=!1;++n<i;){var o=z0(e[n]);if(!(a=r!=null&&t(r,o)))break;r=r[o]}return a||++n!=i?a:(i=r==null?0:r.length,!!i&&X0(i)&&W0(o,i)&&(H0(r)||G0(r)))}var K0=Y0,Z0=j0,J0=K0;function Q0(r,e){return r!=null&&J0(r,e,Z0)}var eb=Q0,rb=Ko,tb=L0,nb=eb,ib=oi,ab=Zo,ob=Jo,ub=Tt,sb=1,fb=2;function cb(r,e){return ib(r)&&ab(e)?ob(ub(r),e):function(t){var n=tb(t,r);return n===void 0&&n===e?nb(t,r):rb(e,n,sb|fb)}}var lb=cb;function hb(r){return function(e){return e?.[r]}}var db=hb,pb=au;function yb(r){return function(e){return pb(e,r)}}var gb=yb,vb=db,_b=gb,mb=oi,wb=Tt;function bb(r){return mb(r)?vb(wb(r)):_b(r)}var $b=bb,Eb=Zw,Ab=lb,Sb=_t,Ob=V,Ib=$b;function Pb(r){return typeof r=="function"?r:r==null?Sb:typeof r=="object"?Ob(r)?Ab(r[0],r[1]):Eb(r):Ib(r)}var ou=Pb,xb=pg,Tb=Xg,Rb=ou,Fb=V,Mb=go;function Db(r,e,t){var n=Fb(r)?xb:Tb;return t&&Mb(r,e,t)&&(e=void 0),n(r,Rb(e))}var fi=Db;Object.defineProperty(Me,"__esModule",{value:!0}),Me.calculatePadding=Ub,Me.slicePadding=qb;var Cb=fi,Nb=Bb(Cb);function Bb(r){return r&&r.__esModule?r:{default:r}}function Ub(r){switch(r%4){case 0:return 0;case 1:return 3;case 2:return 2;case 3:return 1;default:return null}}function qb(r,e){var t=r.slice(e),n=(0,Nb.default)(t.buffer(),function(i){return i===0});if(n!==!0)throw new Error("XDR Read Error: invalid padding")}Object.defineProperty(bt,"__esModule",{value:!0}),bt.Cursor=void 0;var Lb=function(){function r(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(e,t,n){return t&&r(e.prototype,t),n&&r(e,n),e}}(),kb=Me;function jb(r,e){if(!(r instanceof e))throw new TypeError("Cannot call a class as a function")}var ci=function(){function r(e){jb(this,r),e instanceof p||(e=typeof e=="number"?p.alloc(e):p.from(e)),this._setBuffer(e),this.rewind()}return Lb(r,[{key:"_setBuffer",value:function(t){this._buffer=t,this.length=t.length}},{key:"buffer",value:function(){return this._buffer}},{key:"tap",value:function(t){return t(this),this}},{key:"clone",value:function(t){var n=new this.constructor(this.buffer());return n.seek(arguments.length===0?this.tell():t),n}},{key:"tell",value:function(){return this._index}},{key:"seek",value:function(t,n){return arguments.length===1&&(n=t,t="="),t==="+"?this._index+=n:t==="-"?this._index-=n:this._index=n,this}},{key:"rewind",value:function(){return this.seek(0)}},{key:"eof",value:function(){return this.tell()===this.buffer().length}},{key:"write",value:function(t,n,i){return this.seek("+",this.buffer().write(t,this.tell(),n,i))}},{key:"fill",value:function(t,n){return arguments.length===1&&(n=this.buffer().length-this.tell()),this.buffer().fill(t,this.tell(),this.tell()+n),this.seek("+",n),this}},{key:"slice",value:function(t){arguments.length===0&&(t=this.length-this.tell());var n=new this.constructor(this.buffer().slice(this.tell(),this.tell()+t));return this.seek("+",t),n}},{key:"copyFrom",value:function(t){var n=t instanceof p?t:t.buffer();return n.copy(this.buffer(),this.tell(),0,n.length),this.seek("+",n.length),this}},{key:"concat",value:function(t){t.forEach(function(i,a){i instanceof r&&(t[a]=i.buffer())}),t.unshift(this.buffer());var n=p.concat(t);return this._setBuffer(n),this}},{key:"toString",value:function(t,n){arguments.length===0?(t="utf8",n=this.buffer().length-this.tell()):arguments.length===1&&(n=this.buffer().length-this.tell());var i=this.buffer().toString(t,this.tell(),this.tell()+n);return this.seek("+",n),i}},{key:"writeBufferPadded",value:function(t){var n=(0,kb.calculatePadding)(t.length),i=p.alloc(n);return this.copyFrom(new r(t)).copyFrom(new r(i))}}]),r}();[[1,["readInt8","readUInt8"]],[2,["readInt16BE","readInt16LE","readUInt16BE","readUInt16LE"]],[4,["readInt32BE","readInt32LE","readUInt32BE","readUInt32LE","readFloatBE","readFloatLE"]],[8,["readDoubleBE","readDoubleLE"]]].forEach(function(r){r[1].forEach(function(e){ci.prototype[e]=function(){var n=this.buffer()[e](this.tell());return this.seek("+",r[0]),n}})}),[[1,["writeInt8","writeUInt8"]],[2,["writeInt16BE","writeInt16LE","writeUInt16BE","writeUInt16LE"]],[4,["writeInt32BE","writeInt32LE","writeUInt32BE","writeUInt32LE","writeFloatBE","writeFloatLE"]],[8,["writeDoubleBE","writeDoubleLE"]]].forEach(function(r){r[1].forEach(function(e){ci.prototype[e]=function(n){return this.buffer()[e](n,this.tell()),this.seek("+",r[0]),this}})}),bt.Cursor=ci,Object.defineProperty(D,"__esModule",{value:!0}),D.default=Yb;var Vb=hg,uu=fu(Vb),Gb=Wn,Hb=fu(Gb),su=bt;function fu(r){return r&&r.__esModule?r:{default:r}}var Wb=Math.pow(2,16),Xb={toXDR:function(e){var t=new su.Cursor(Wb);this.write(e,t);var n=t.tell();return t.rewind(),t.slice(n).buffer()},fromXDR:function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"raw",n=void 0;switch(t){case"raw":n=e;break;case"hex":n=p.from(e,"hex");break;case"base64":n=p.from(e,"base64");break;default:throw new Error("Invalid format "+t+', must be "raw", "hex", "base64"')}var i=new su.Cursor(n),a=this.read(i);return a},validateXDR:function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"raw";try{return this.fromXDR(e,t),!0}catch{return!1}}},zb={toXDR:function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"raw",t=this.constructor.toXDR(this);switch(e){case"raw":return t;case"hex":return t.toString("hex");case"base64":return t.toString("base64");default:throw new Error("Invalid format "+e+', must be "raw", "hex", "base64"')}}};function Yb(r){(0,uu.default)(r,Xb),(0,Hb.default)(r)&&(0,uu.default)(r.prototype,zb)}Object.defineProperty(se,"__esModule",{value:!0}),se.Int=void 0;var Kb=gt,cu=lu(Kb),Zb=D,Jb=lu(Zb);function lu(r){return r&&r.__esModule?r:{default:r}}var Ir=se.Int={read:function(e){return e.readInt32BE()},write:function(e,t){if(!(0,cu.default)(e))throw new Error("XDR Write Error: not a number");if(Math.floor(e)!==e)throw new Error("XDR Write Error: not an integer");t.writeInt32BE(e)},isValid:function(e){return!(0,cu.default)(e)||Math.floor(e)!==e?!1:e>=Ir.MIN_VALUE&&e<=Ir.MAX_VALUE}};Ir.MAX_VALUE=Math.pow(2,31)-1,Ir.MIN_VALUE=-Math.pow(2,31),(0,Jb.default)(Ir);var Rt={};function Qb(r){throw new Error('Could not dynamically require "'+r+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var hu={exports:{}};(function(r){/**
21
21
  * @license Long.js (c) 2013 Daniel Wirtz <dcode@dcode.io>
22
22
  * Released under the Apache License, Version 2.0
23
23
  * see: https://github.com/dcodeIO/Long.js for details
24
- */(function(e,t){typeof Qb=="function"&&r&&r.exports?r.exports=t():(e.dcodeIO=e.dcodeIO||{}).Long=t()})(U,function(){function e(l,s,h){this.low=l|0,this.high=s|0,this.unsigned=!!h}e.__isLong__,Object.defineProperty(e.prototype,"__isLong__",{value:!0,enumerable:!1,configurable:!1}),e.isLong=function(s){return(s&&s.__isLong__)===!0};var t={},n={};e.fromInt=function(s,h){var y,w;return h?(s=s>>>0,0<=s&&s<256&&(w=n[s],w)?w:(y=new e(s,(s|0)<0?-1:0,!0),0<=s&&s<256&&(n[s]=y),y)):(s=s|0,-128<=s&&s<128&&(w=t[s],w)?w:(y=new e(s,s<0?-1:0,!1),-128<=s&&s<128&&(t[s]=y),y))},e.fromNumber=function(s,h){return h=!!h,isNaN(s)||!isFinite(s)?e.ZERO:!h&&s<=-f?e.MIN_VALUE:!h&&s+1>=f?e.MAX_VALUE:h&&s>=u?e.MAX_UNSIGNED_VALUE:s<0?e.fromNumber(-s,h).negate():new e(s%o|0,s/o|0,h)},e.fromBits=function(s,h,y){return new e(s,h,y)},e.fromString=function(s,h,y){if(s.length===0)throw Error("number format error: empty string");if(s==="NaN"||s==="Infinity"||s==="+Infinity"||s==="-Infinity")return e.ZERO;if(typeof h=="number"&&(y=h,h=!1),y=y||10,y<2||36<y)throw Error("radix out of range: "+y);var w;if((w=s.indexOf("-"))>0)throw Error('number format error: interior "-" character: '+s);if(w===0)return e.fromString(s.substring(1),h,y).negate();for(var S=e.fromNumber(Math.pow(y,8)),O=e.ZERO,b=0;b<s.length;b+=8){var E=Math.min(8,s.length-b),d=parseInt(s.substring(b,b+E),y);if(E<8){var I=e.fromNumber(Math.pow(y,E));O=O.multiply(I).add(e.fromNumber(d))}else O=O.multiply(S),O=O.add(e.fromNumber(d))}return O.unsigned=h,O},e.fromValue=function(s){return s instanceof e?s:typeof s=="number"?e.fromNumber(s):typeof s=="string"?e.fromString(s):new e(s.low,s.high,s.unsigned)};var i=65536,a=1<<24,o=i*i,u=o*o,f=u/2,c=e.fromInt(a);return e.ZERO=e.fromInt(0),e.UZERO=e.fromInt(0,!0),e.ONE=e.fromInt(1),e.UONE=e.fromInt(1,!0),e.NEG_ONE=e.fromInt(-1),e.MAX_VALUE=e.fromBits(-1,2147483647,!1),e.MAX_UNSIGNED_VALUE=e.fromBits(-1,-1,!0),e.MIN_VALUE=e.fromBits(0,-2147483648,!1),e.prototype.toInt=function(){return this.unsigned?this.low>>>0:this.low},e.prototype.toNumber=function(){return this.unsigned?(this.high>>>0)*o+(this.low>>>0):this.high*o+(this.low>>>0)},e.prototype.toString=function(s){if(s=s||10,s<2||36<s)throw RangeError("radix out of range: "+s);if(this.isZero())return"0";var h;if(this.isNegative())if(this.equals(e.MIN_VALUE)){var y=e.fromNumber(s),w=this.divide(y);return h=w.multiply(y).subtract(this),w.toString(s)+h.toInt().toString(s)}else return"-"+this.negate().toString(s);var S=e.fromNumber(Math.pow(s,6),this.unsigned);h=this;for(var O="";;){var b=h.divide(S),E=h.subtract(b.multiply(S)).toInt()>>>0,d=E.toString(s);if(h=b,h.isZero())return d+O;for(;d.length<6;)d="0"+d;O=""+d+O}},e.prototype.getHighBits=function(){return this.high},e.prototype.getHighBitsUnsigned=function(){return this.high>>>0},e.prototype.getLowBits=function(){return this.low},e.prototype.getLowBitsUnsigned=function(){return this.low>>>0},e.prototype.getNumBitsAbs=function(){if(this.isNegative())return this.equals(e.MIN_VALUE)?64:this.negate().getNumBitsAbs();for(var s=this.high!=0?this.high:this.low,h=31;h>0&&!(s&1<<h);h--);return this.high!=0?h+33:h+1},e.prototype.isZero=function(){return this.high===0&&this.low===0},e.prototype.isNegative=function(){return!this.unsigned&&this.high<0},e.prototype.isPositive=function(){return this.unsigned||this.high>=0},e.prototype.isOdd=function(){return(this.low&1)===1},e.prototype.isEven=function(){return(this.low&1)===0},e.prototype.equals=function(s){return e.isLong(s)||(s=e.fromValue(s)),this.unsigned!==s.unsigned&&this.high>>>31===1&&s.high>>>31===1?!1:this.high===s.high&&this.low===s.low},e.eq=e.prototype.equals,e.prototype.notEquals=function(s){return!this.equals(s)},e.neq=e.prototype.notEquals,e.prototype.lessThan=function(s){return this.compare(s)<0},e.prototype.lt=e.prototype.lessThan,e.prototype.lessThanOrEqual=function(s){return this.compare(s)<=0},e.prototype.lte=e.prototype.lessThanOrEqual,e.prototype.greaterThan=function(s){return this.compare(s)>0},e.prototype.gt=e.prototype.greaterThan,e.prototype.greaterThanOrEqual=function(s){return this.compare(s)>=0},e.prototype.gte=e.prototype.greaterThanOrEqual,e.prototype.compare=function(s){if(e.isLong(s)||(s=e.fromValue(s)),this.equals(s))return 0;var h=this.isNegative(),y=s.isNegative();return h&&!y?-1:!h&&y?1:this.unsigned?s.high>>>0>this.high>>>0||s.high===this.high&&s.low>>>0>this.low>>>0?-1:1:this.subtract(s).isNegative()?-1:1},e.prototype.negate=function(){return!this.unsigned&&this.equals(e.MIN_VALUE)?e.MIN_VALUE:this.not().add(e.ONE)},e.prototype.neg=e.prototype.negate,e.prototype.add=function(s){e.isLong(s)||(s=e.fromValue(s));var h=this.high>>>16,y=this.high&65535,w=this.low>>>16,S=this.low&65535,O=s.high>>>16,b=s.high&65535,E=s.low>>>16,d=s.low&65535,I=0,T=0,F=0,m=0;return m+=S+d,F+=m>>>16,m&=65535,F+=w+E,T+=F>>>16,F&=65535,T+=y+b,I+=T>>>16,T&=65535,I+=h+O,I&=65535,e.fromBits(F<<16|m,I<<16|T,this.unsigned)},e.prototype.subtract=function(s){return e.isLong(s)||(s=e.fromValue(s)),this.add(s.negate())},e.prototype.sub=e.prototype.subtract,e.prototype.multiply=function(s){if(this.isZero()||(e.isLong(s)||(s=e.fromValue(s)),s.isZero()))return e.ZERO;if(this.equals(e.MIN_VALUE))return s.isOdd()?e.MIN_VALUE:e.ZERO;if(s.equals(e.MIN_VALUE))return this.isOdd()?e.MIN_VALUE:e.ZERO;if(this.isNegative())return s.isNegative()?this.negate().multiply(s.negate()):this.negate().multiply(s).negate();if(s.isNegative())return this.multiply(s.negate()).negate();if(this.lessThan(c)&&s.lessThan(c))return e.fromNumber(this.toNumber()*s.toNumber(),this.unsigned);var h=this.high>>>16,y=this.high&65535,w=this.low>>>16,S=this.low&65535,O=s.high>>>16,b=s.high&65535,E=s.low>>>16,d=s.low&65535,I=0,T=0,F=0,m=0;return m+=S*d,F+=m>>>16,m&=65535,F+=w*d,T+=F>>>16,F&=65535,F+=S*E,T+=F>>>16,F&=65535,T+=y*d,I+=T>>>16,T&=65535,T+=w*E,I+=T>>>16,T&=65535,T+=S*b,I+=T>>>16,T&=65535,I+=h*d+y*E+w*b+S*O,I&=65535,e.fromBits(F<<16|m,I<<16|T,this.unsigned)},e.prototype.mul=e.prototype.multiply,e.prototype.divide=function(s){if(e.isLong(s)||(s=e.fromValue(s)),s.isZero())throw new Error("division by zero");if(this.isZero())return this.unsigned?e.UZERO:e.ZERO;var h,y,w;if(this.equals(e.MIN_VALUE)){if(s.equals(e.ONE)||s.equals(e.NEG_ONE))return e.MIN_VALUE;if(s.equals(e.MIN_VALUE))return e.ONE;var S=this.shiftRight(1);return h=S.divide(s).shiftLeft(1),h.equals(e.ZERO)?s.isNegative()?e.ONE:e.NEG_ONE:(y=this.subtract(s.multiply(h)),w=h.add(y.divide(s)),w)}else if(s.equals(e.MIN_VALUE))return this.unsigned?e.UZERO:e.ZERO;if(this.isNegative())return s.isNegative()?this.negate().divide(s.negate()):this.negate().divide(s).negate();if(s.isNegative())return this.divide(s.negate()).negate();for(w=e.ZERO,y=this;y.greaterThanOrEqual(s);){h=Math.max(1,Math.floor(y.toNumber()/s.toNumber()));for(var O=Math.ceil(Math.log(h)/Math.LN2),b=O<=48?1:Math.pow(2,O-48),E=e.fromNumber(h),d=E.multiply(s);d.isNegative()||d.greaterThan(y);)h-=b,E=e.fromNumber(h,this.unsigned),d=E.multiply(s);E.isZero()&&(E=e.ONE),w=w.add(E),y=y.subtract(d)}return w},e.prototype.div=e.prototype.divide,e.prototype.modulo=function(s){return e.isLong(s)||(s=e.fromValue(s)),this.subtract(this.divide(s).multiply(s))},e.prototype.mod=e.prototype.modulo,e.prototype.not=function(){return e.fromBits(~this.low,~this.high,this.unsigned)},e.prototype.and=function(s){return e.isLong(s)||(s=e.fromValue(s)),e.fromBits(this.low&s.low,this.high&s.high,this.unsigned)},e.prototype.or=function(s){return e.isLong(s)||(s=e.fromValue(s)),e.fromBits(this.low|s.low,this.high|s.high,this.unsigned)},e.prototype.xor=function(s){return e.isLong(s)||(s=e.fromValue(s)),e.fromBits(this.low^s.low,this.high^s.high,this.unsigned)},e.prototype.shiftLeft=function(s){return e.isLong(s)&&(s=s.toInt()),(s&=63)===0?this:s<32?e.fromBits(this.low<<s,this.high<<s|this.low>>>32-s,this.unsigned):e.fromBits(0,this.low<<s-32,this.unsigned)},e.prototype.shl=e.prototype.shiftLeft,e.prototype.shiftRight=function(s){return e.isLong(s)&&(s=s.toInt()),(s&=63)===0?this:s<32?e.fromBits(this.low>>>s|this.high<<32-s,this.high>>s,this.unsigned):e.fromBits(this.high>>s-32,this.high>=0?0:-1,this.unsigned)},e.prototype.shr=e.prototype.shiftRight,e.prototype.shiftRightUnsigned=function(s){if(e.isLong(s)&&(s=s.toInt()),s&=63,s===0)return this;var h=this.high;if(s<32){var y=this.low;return e.fromBits(y>>>s|h<<32-s,h>>>s,this.unsigned)}else return s===32?e.fromBits(h,0,this.unsigned):e.fromBits(h>>>s-32,0,this.unsigned)},e.prototype.shru=e.prototype.shiftRightUnsigned,e.prototype.toSigned=function(){return this.unsigned?new e(this.low,this.high,!1):this},e.prototype.toUnsigned=function(){return this.unsigned?this:new e(this.low,this.high,!0)},e})})(hu);var du=hu.exports;Object.defineProperty(Rt,"__esModule",{value:!0}),Rt.Hyper=void 0;var e1=function(){function r(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(e,t,n){return t&&r(e.prototype,t),n&&r(e,n),e}}(),pu=function r(e,t,n){e===null&&(e=Function.prototype);var i=Object.getOwnPropertyDescriptor(e,t);if(i===void 0){var a=Object.getPrototypeOf(e);return a===null?void 0:r(a,t,n)}else{if("value"in i)return i.value;var o=i.get;return o===void 0?void 0:o.call(n)}},r1=du,Pr=yu(r1),t1=D,n1=yu(t1);function yu(r){return r&&r.__esModule?r:{default:r}}function i1(r,e){if(!(r instanceof e))throw new TypeError("Cannot call a class as a function")}function a1(r,e){if(!r)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e&&(typeof e=="object"||typeof e=="function")?e:r}function o1(r,e){if(typeof e!="function"&&e!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof e);r.prototype=Object.create(e&&e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(r,e):r.__proto__=e)}var xr=Rt.Hyper=function(r){o1(e,r),e1(e,null,[{key:"read",value:function(n){var i=n.readInt32BE(),a=n.readInt32BE();return this.fromBits(a,i)}},{key:"write",value:function(n,i){if(!(n instanceof this))throw new Error("XDR Write Error: "+n+" is not a Hyper");i.writeInt32BE(n.high),i.writeInt32BE(n.low)}},{key:"fromString",value:function(n){if(!/^-?\d+$/.test(n))throw new Error("Invalid hyper string: "+n);var i=pu(e.__proto__||Object.getPrototypeOf(e),"fromString",this).call(this,n,!1);return new this(i.low,i.high)}},{key:"fromBits",value:function(n,i){var a=pu(e.__proto__||Object.getPrototypeOf(e),"fromBits",this).call(this,n,i,!1);return new this(a.low,a.high)}},{key:"isValid",value:function(n){return n instanceof this}}]);function e(t,n){return i1(this,e),a1(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,t,n,!1))}return e}(Pr.default);(0,n1.default)(xr),xr.MAX_VALUE=new xr(Pr.default.MAX_VALUE.low,Pr.default.MAX_VALUE.high),xr.MIN_VALUE=new xr(Pr.default.MIN_VALUE.low,Pr.default.MIN_VALUE.high);var Ce={};Object.defineProperty(Ce,"__esModule",{value:!0}),Ce.UnsignedInt=void 0;var u1=gt,gu=vu(u1),s1=D,f1=vu(s1);function vu(r){return r&&r.__esModule?r:{default:r}}var Tr=Ce.UnsignedInt={read:function(e){return e.readUInt32BE()},write:function(e,t){if(!(0,gu.default)(e))throw new Error("XDR Write Error: not a number");if(Math.floor(e)!==e)throw new Error("XDR Write Error: not an integer");if(e<0)throw new Error("XDR Write Error: negative number "+e);t.writeUInt32BE(e)},isValid:function(e){return!(0,gu.default)(e)||Math.floor(e)!==e?!1:e>=Tr.MIN_VALUE&&e<=Tr.MAX_VALUE}};Tr.MAX_VALUE=Math.pow(2,32)-1,Tr.MIN_VALUE=0,(0,f1.default)(Tr);var Ft={};Object.defineProperty(Ft,"__esModule",{value:!0}),Ft.UnsignedHyper=void 0;var c1=function(){function r(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(e,t,n){return t&&r(e.prototype,t),n&&r(e,n),e}}(),_u=function r(e,t,n){e===null&&(e=Function.prototype);var i=Object.getOwnPropertyDescriptor(e,t);if(i===void 0){var a=Object.getPrototypeOf(e);return a===null?void 0:r(a,t,n)}else{if("value"in i)return i.value;var o=i.get;return o===void 0?void 0:o.call(n)}},l1=du,Rr=mu(l1),h1=D,d1=mu(h1);function mu(r){return r&&r.__esModule?r:{default:r}}function p1(r,e){if(!(r instanceof e))throw new TypeError("Cannot call a class as a function")}function y1(r,e){if(!r)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e&&(typeof e=="object"||typeof e=="function")?e:r}function g1(r,e){if(typeof e!="function"&&e!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof e);r.prototype=Object.create(e&&e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(r,e):r.__proto__=e)}var Fr=Ft.UnsignedHyper=function(r){g1(e,r),c1(e,null,[{key:"read",value:function(n){var i=n.readInt32BE(),a=n.readInt32BE();return this.fromBits(a,i)}},{key:"write",value:function(n,i){if(!(n instanceof this))throw new Error("XDR Write Error: "+n+" is not an UnsignedHyper");i.writeInt32BE(n.high),i.writeInt32BE(n.low)}},{key:"fromString",value:function(n){if(!/^\d+$/.test(n))throw new Error("Invalid hyper string: "+n);var i=_u(e.__proto__||Object.getPrototypeOf(e),"fromString",this).call(this,n,!0);return new this(i.low,i.high)}},{key:"fromBits",value:function(n,i){var a=_u(e.__proto__||Object.getPrototypeOf(e),"fromBits",this).call(this,n,i,!0);return new this(a.low,a.high)}},{key:"isValid",value:function(n){return n instanceof this}}]);function e(t,n){return p1(this,e),y1(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,t,n,!0))}return e}(Rr.default);(0,d1.default)(Fr),Fr.MAX_VALUE=new Fr(Rr.default.MAX_UNSIGNED_VALUE.low,Rr.default.MAX_UNSIGNED_VALUE.high),Fr.MIN_VALUE=new Fr(Rr.default.MIN_VALUE.low,Rr.default.MIN_VALUE.high);var Mt={};Object.defineProperty(Mt,"__esModule",{value:!0}),Mt.Float=void 0;var v1=gt,wu=bu(v1),_1=D,m1=bu(_1);function bu(r){return r&&r.__esModule?r:{default:r}}var w1=Mt.Float={read:function(e){return e.readFloatBE()},write:function(e,t){if(!(0,wu.default)(e))throw new Error("XDR Write Error: not a number");t.writeFloatBE(e)},isValid:function(e){return(0,wu.default)(e)}};(0,m1.default)(w1);var Dt={};Object.defineProperty(Dt,"__esModule",{value:!0}),Dt.Double=void 0;var b1=gt,$u=Eu(b1),$1=D,E1=Eu($1);function Eu(r){return r&&r.__esModule?r:{default:r}}var A1=Dt.Double={read:function(e){return e.readDoubleBE()},write:function(e,t){if(!(0,$u.default)(e))throw new Error("XDR Write Error: not a number");t.writeDoubleBE(e)},isValid:function(e){return(0,$u.default)(e)}};(0,E1.default)(A1);var Ct={};Object.defineProperty(Ct,"__esModule",{value:!0}),Ct.Quadruple=void 0;var S1=D,O1=I1(S1);function I1(r){return r&&r.__esModule?r:{default:r}}var P1=Ct.Quadruple={read:function(){throw new Error("XDR Read Error: quadruple not supported")},write:function(){throw new Error("XDR Write Error: quadruple not supported")},isValid:function(){return!1}};(0,O1.default)(P1);var Mr={},x1=ge,T1=ve,R1="[object Boolean]";function F1(r){return r===!0||r===!1||T1(r)&&x1(r)==R1}var M1=F1;Object.defineProperty(Mr,"__esModule",{value:!0}),Mr.Bool=void 0;var D1=M1,C1=Su(D1),Au=se,N1=D,B1=Su(N1);function Su(r){return r&&r.__esModule?r:{default:r}}var U1=Mr.Bool={read:function(e){var t=Au.Int.read(e);switch(t){case 0:return!1;case 1:return!0;default:throw new Error("XDR Read Error: Got "+t+" when trying to read a bool")}},write:function(e,t){var n=e?1:0;return Au.Int.write(n,t)},isValid:function(e){return(0,C1.default)(e)}};(0,B1.default)(U1);var Nt={},q1=ge,L1=V,k1=ve,j1="[object String]";function V1(r){return typeof r=="string"||!L1(r)&&k1(r)&&q1(r)==j1}var Ou=V1;Object.defineProperty(Nt,"__esModule",{value:!0}),Nt.String=void 0;var G1=function(){function r(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(e,t,n){return t&&r(e.prototype,t),n&&r(e,n),e}}(),H1=Ou,Iu=li(H1),W1=V,X1=li(W1),Pu=se,z1=Ce,xu=Me,Y1=D,K1=li(Y1);function li(r){return r&&r.__esModule?r:{default:r}}function Z1(r,e){if(!(r instanceof e))throw new TypeError("Cannot call a class as a function")}var J1=Nt.String=function(){function r(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:z1.UnsignedInt.MAX_VALUE;Z1(this,r),this._maxLength=e}return G1(r,[{key:"read",value:function(t){var n=Pu.Int.read(t);if(n>this._maxLength)throw new Error("XDR Read Error: Saw "+n+" length String,"+("max allowed is "+this._maxLength));var i=(0,xu.calculatePadding)(n),a=t.slice(n);return(0,xu.slicePadding)(t,i),a.buffer()}},{key:"readString",value:function(t){return this.read(t).toString("utf8")}},{key:"write",value:function(t,n){if(t.length>this._maxLength)throw new Error("XDR Write Error: Got "+t.length+" bytes,"+("max allows is "+this._maxLength));var i=void 0;(0,Iu.default)(t)?i=p.from(t,"utf8"):i=p.from(t),Pu.Int.write(i.length,n),n.writeBufferPadded(i)}},{key:"isValid",value:function(t){var n=void 0;if((0,Iu.default)(t))n=p.from(t,"utf8");else if((0,X1.default)(t)||p.isBuffer(t))n=p.from(t);else return!1;return n.length<=this._maxLength}}]),r}();(0,K1.default)(J1.prototype);var Bt={};Object.defineProperty(Bt,"__esModule",{value:!0}),Bt.Opaque=void 0;var Q1=function(){function r(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(e,t,n){return t&&r(e.prototype,t),n&&r(e,n),e}}(),Tu=Me,e$=D,r$=t$(e$);function t$(r){return r&&r.__esModule?r:{default:r}}function n$(r,e){if(!(r instanceof e))throw new TypeError("Cannot call a class as a function")}var i$=Bt.Opaque=function(){function r(e){n$(this,r),this._length=e,this._padding=(0,Tu.calculatePadding)(e)}return Q1(r,[{key:"read",value:function(t){var n=t.slice(this._length);return(0,Tu.slicePadding)(t,this._padding),n.buffer()}},{key:"write",value:function(t,n){if(t.length!==this._length)throw new Error("XDR Write Error: Got "+t.length+" bytes, expected "+this._length);n.writeBufferPadded(t)}},{key:"isValid",value:function(t){return p.isBuffer(t)&&t.length===this._length}}]),r}();(0,r$.default)(i$.prototype);var Ut={};Object.defineProperty(Ut,"__esModule",{value:!0}),Ut.VarOpaque=void 0;var a$=function(){function r(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(e,t,n){return t&&r(e.prototype,t),n&&r(e,n),e}}(),Ru=se,o$=Ce,Fu=Me,u$=D,s$=f$(u$);function f$(r){return r&&r.__esModule?r:{default:r}}function c$(r,e){if(!(r instanceof e))throw new TypeError("Cannot call a class as a function")}var l$=Ut.VarOpaque=function(){function r(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:o$.UnsignedInt.MAX_VALUE;c$(this,r),this._maxLength=e}return a$(r,[{key:"read",value:function(t){var n=Ru.Int.read(t);if(n>this._maxLength)throw new Error("XDR Read Error: Saw "+n+" length VarOpaque,"+("max allowed is "+this._maxLength));var i=(0,Fu.calculatePadding)(n),a=t.slice(n);return(0,Fu.slicePadding)(t,i),a.buffer()}},{key:"write",value:function(t,n){if(t.length>this._maxLength)throw new Error("XDR Write Error: Got "+t.length+" bytes,"+("max allows is "+this._maxLength));Ru.Int.write(t.length,n),n.writeBufferPadded(t)}},{key:"isValid",value:function(t){return p.isBuffer(t)&&t.length<=this._maxLength}}]),r}();(0,s$.default)(l$.prototype);var qt={};function h$(r,e){for(var t=-1,n=r==null?0:r.length;++t<n&&e(r[t],t,r)!==!1;);return r}var d$=h$,p$=_t;function y$(r){return typeof r=="function"?r:p$}var Mu=y$,g$=d$,v$=Kn,_$=Mu,m$=V;function w$(r,e){var t=m$(r)?g$:v$;return t(r,_$(e))}var b$=w$,nr=b$,$$=/\s/;function E$(r){for(var e=r.length;e--&&$$.test(r.charAt(e)););return e}var A$=E$,S$=A$,O$=/^\s+/;function I$(r){return r&&r.slice(0,S$(r)+1).replace(O$,"")}var P$=I$,x$=P$,Du=Ze,T$=xt,Cu=0/0,R$=/^[-+]0x[0-9a-f]+$/i,F$=/^0b[01]+$/i,M$=/^0o[0-7]+$/i,D$=parseInt;function C$(r){if(typeof r=="number")return r;if(T$(r))return Cu;if(Du(r)){var e=typeof r.valueOf=="function"?r.valueOf():r;r=Du(e)?e+"":e}if(typeof r!="string")return r===0?r:+r;r=x$(r);var t=F$.test(r);return t||M$.test(r)?D$(r.slice(2),t?2:8):R$.test(r)?Cu:+r}var N$=C$,B$=N$,Nu=1/0,U$=17976931348623157e292;function q$(r){if(!r)return r===0?r:0;if(r=B$(r),r===Nu||r===-Nu){var e=r<0?-1:1;return e*U$}return r===r?r:0}var L$=q$,k$=L$;function j$(r){var e=k$(r),t=e%1;return e===e?t?e-t:e:0}var V$=j$,G$=vo,H$=Mu,W$=V$,X$=9007199254740991,hi=4294967295,z$=Math.min;function Y$(r,e){if(r=W$(r),r<1||r>X$)return[];var t=hi,n=z$(r,hi);e=H$(e),r-=hi;for(var i=G$(n,e);++t<r;)e(t);return i}var Bu=Y$;Object.defineProperty(qt,"__esModule",{value:!0}),qt.Array=void 0;var K$=function(){function r(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(e,t,n){return t&&r(e.prototype,t),n&&r(e,n),e}}(),Z$=fi,J$=Dr(Z$),Q$=nr,eE=Dr(Q$),rE=Bu,tE=Dr(rE),nE=V,Uu=Dr(nE),iE=D,aE=Dr(iE);function Dr(r){return r&&r.__esModule?r:{default:r}}function oE(r,e){if(!(r instanceof e))throw new TypeError("Cannot call a class as a function")}var uE=qt.Array=function(){function r(e,t){oE(this,r),this._childType=e,this._length=t}return K$(r,[{key:"read",value:function(t){var n=this;return(0,tE.default)(this._length,function(){return n._childType.read(t)})}},{key:"write",value:function(t,n){var i=this;if(!(0,Uu.default)(t))throw new Error("XDR Write Error: value is not array");if(t.length!==this._length)throw new Error("XDR Write Error: Got array of size "+t.length+","+("expected "+this._length));(0,eE.default)(t,function(a){return i._childType.write(a,n)})}},{key:"isValid",value:function(t){var n=this;return!(0,Uu.default)(t)||t.length!==this._length?!1:(0,J$.default)(t,function(i){return n._childType.isValid(i)})}}]),r}();(0,aE.default)(uE.prototype);var Lt={};Object.defineProperty(Lt,"__esModule",{value:!0}),Lt.VarArray=void 0;var sE=function(){function r(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(e,t,n){return t&&r(e.prototype,t),n&&r(e,n),e}}(),fE=fi,cE=Cr(fE),lE=nr,hE=Cr(lE),dE=Bu,pE=Cr(dE),yE=V,qu=Cr(yE),gE=Ce,Lu=se,vE=D,_E=Cr(vE);function Cr(r){return r&&r.__esModule?r:{default:r}}function mE(r,e){if(!(r instanceof e))throw new TypeError("Cannot call a class as a function")}var wE=Lt.VarArray=function(){function r(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:gE.UnsignedInt.MAX_VALUE;mE(this,r),this._childType=e,this._maxLength=t}return sE(r,[{key:"read",value:function(t){var n=this,i=Lu.Int.read(t);if(i>this._maxLength)throw new Error("XDR Read Error: Saw "+i+" length VarArray,"+("max allowed is "+this._maxLength));return(0,pE.default)(i,function(){return n._childType.read(t)})}},{key:"write",value:function(t,n){var i=this;if(!(0,qu.default)(t))throw new Error("XDR Write Error: value is not array");if(t.length>this._maxLength)throw new Error("XDR Write Error: Got array of size "+t.length+","+("max allowed is "+this._maxLength));Lu.Int.write(t.length,n),(0,hE.default)(t,function(a){return i._childType.write(a,n)})}},{key:"isValid",value:function(t){var n=this;return!(0,qu.default)(t)||t.length>this._maxLength?!1:(0,cE.default)(t,function(i){return n._childType.isValid(i)})}}]),r}();(0,_E.default)(wE.prototype);var kt={};function bE(r){return r===null}var $E=bE;function EE(r){return r===void 0}var Nr=EE;Object.defineProperty(kt,"__esModule",{value:!0}),kt.Option=void 0;var AE=function(){function r(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(e,t,n){return t&&r(e.prototype,t),n&&r(e,n),e}}(),SE=$E,ku=di(SE),OE=Nr,ju=di(OE),Vu=Mr,IE=D,PE=di(IE);function di(r){return r&&r.__esModule?r:{default:r}}function xE(r,e){if(!(r instanceof e))throw new TypeError("Cannot call a class as a function")}var TE=kt.Option=function(){function r(e){xE(this,r),this._childType=e}return AE(r,[{key:"read",value:function(t){if(Vu.Bool.read(t))return this._childType.read(t)}},{key:"write",value:function(t,n){var i=!((0,ku.default)(t)||(0,ju.default)(t));Vu.Bool.write(i,n),i&&this._childType.write(t,n)}},{key:"isValid",value:function(t){return(0,ku.default)(t)||(0,ju.default)(t)?!0:this._childType.isValid(t)}}]),r}();(0,PE.default)(TE.prototype);var Br={};Object.defineProperty(Br,"__esModule",{value:!0}),Br.Void=void 0;var RE=Nr,Gu=Hu(RE),FE=D,ME=Hu(FE);function Hu(r){return r&&r.__esModule?r:{default:r}}var DE=Br.Void={read:function(){},write:function(e){if(!(0,Gu.default)(e))throw new Error("XDR Write Error: trying to write value to a void slot")},isValid:function(e){return(0,Gu.default)(e)}};(0,ME.default)(DE);var jt={},CE=si;function NE(r,e){return CE(e,function(t){return r[t]})}var BE=NE,UE=BE,qE=$t;function LE(r){return r==null?[]:UE(r,qE(r))}var kE=LE;Object.defineProperty(jt,"__esModule",{value:!0}),jt.Enum=void 0;var jE=function(){function r(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(e,t,n){return t&&r(e.prototype,t),n&&r(e,n),e}}(),VE=nr,GE=pi(VE),HE=kE,WE=pi(HE),Wu=se,XE=D,zE=pi(XE);function pi(r){return r&&r.__esModule?r:{default:r}}function YE(r,e){if(!r)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e&&(typeof e=="object"||typeof e=="function")?e:r}function KE(r,e){if(typeof e!="function"&&e!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof e);r.prototype=Object.create(e&&e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(r,e):r.__proto__=e)}function Xu(r,e){if(!(r instanceof e))throw new TypeError("Cannot call a class as a function")}var ZE=jt.Enum=function(){function r(e,t){Xu(this,r),this.name=e,this.value=t}return jE(r,null,[{key:"read",value:function(t){var n=Wu.Int.read(t);if(!this._byValue.has(n))throw new Error("XDR Read Error: Unknown "+this.enumName+" member for value "+n);return this._byValue.get(n)}},{key:"write",value:function(t,n){if(!(t instanceof this))throw new Error("XDR Write Error: Unknown "+t+" is not a "+this.enumName);Wu.Int.write(t.value,n)}},{key:"isValid",value:function(t){return t instanceof this}},{key:"members",value:function(){return this._members}},{key:"values",value:function(){return(0,WE.default)(this._members)}},{key:"fromName",value:function(t){var n=this._members[t];if(!n)throw new Error(t+" is not a member of "+this.enumName);return n}},{key:"fromValue",value:function(t){var n=this._byValue.get(t);if(!n)throw new Error(t+" is not a value of any member of "+this.enumName);return n}},{key:"create",value:function(t,n,i){var a=function(o){KE(u,o);function u(){return Xu(this,u),YE(this,(u.__proto__||Object.getPrototypeOf(u)).apply(this,arguments))}return u}(r);return a.enumName=n,t.results[n]=a,a._members={},a._byValue=new Map,(0,GE.default)(i,function(o,u){var f=new a(u,o);a._members[u]=f,a._byValue.set(o,f),a[u]=function(){return f}}),a}}]),r}();(0,zE.default)(ZE);var Vt={},JE=Kn,QE=Or;function eA(r,e){var t=-1,n=QE(r)?Array(r.length):[];return JE(r,function(i,a,o){n[++t]=e(i,a,o)}),n}var rA=eA,tA=si,nA=ou,iA=rA,aA=V;function oA(r,e){var t=aA(r)?tA:iA;return t(r,nA(e))}var uA=oA;function sA(r){for(var e=-1,t=r==null?0:r.length,n={};++e<t;){var i=r[e];n[i[0]]=i[1]}return n}var fA=sA,Ur={};Object.defineProperty(Ur,"__esModule",{value:!0});var cA=function(){function r(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(e,t,n){return t&&r(e.prototype,t),n&&r(e,n),e}}();function lA(r,e){if(!(r instanceof e))throw new TypeError("Cannot call a class as a function")}Ur.Reference=function(){function r(){lA(this,r)}return cA(r,[{key:"resolve",value:function(){throw new Error("implement resolve in child class")}}]),r}(),Object.defineProperty(Vt,"__esModule",{value:!0}),Vt.Struct=void 0;var Gt=function(){function r(e,t){var n=[],i=!0,a=!1,o=void 0;try{for(var u=e[Symbol.iterator](),f;!(i=(f=u.next()).done)&&(n.push(f.value),!(t&&n.length===t));i=!0);}catch(c){a=!0,o=c}finally{try{!i&&u.return&&u.return()}finally{if(a)throw o}}return n}return function(e,t){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e))return r(e,t);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),hA=function(){function r(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(e,t,n){return t&&r(e.prototype,t),n&&r(e,n),e}}(),dA=nr,zu=qr(dA),pA=uA,yA=qr(pA),gA=Nr,vA=qr(gA),_A=fA,mA=qr(_A),wA=Ur,bA=D,$A=qr(bA);function qr(r){return r&&r.__esModule?r:{default:r}}function EA(r,e){if(!r)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e&&(typeof e=="object"||typeof e=="function")?e:r}function AA(r,e){if(typeof e!="function"&&e!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof e);r.prototype=Object.create(e&&e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(r,e):r.__proto__=e)}function Yu(r,e){if(!(r instanceof e))throw new TypeError("Cannot call a class as a function")}var SA=Vt.Struct=function(){function r(e){Yu(this,r),this._attributes=e||{}}return hA(r,null,[{key:"read",value:function(t){var n=(0,yA.default)(this._fields,function(i){var a=Gt(i,2),o=a[0],u=a[1],f=u.read(t);return[o,f]});return new this((0,mA.default)(n))}},{key:"write",value:function(t,n){if(!(t instanceof this))throw new Error("XDR Write Error: "+t+" is not a "+this.structName);(0,zu.default)(this._fields,function(i){var a=Gt(i,2),o=a[0],u=a[1],f=t._attributes[o];u.write(f,n)})}},{key:"isValid",value:function(t){return t instanceof this}},{key:"create",value:function(t,n,i){var a=function(o){AA(u,o);function u(){return Yu(this,u),EA(this,(u.__proto__||Object.getPrototypeOf(u)).apply(this,arguments))}return u}(r);return a.structName=n,t.results[n]=a,a._fields=i.map(function(o){var u=Gt(o,2),f=u[0],c=u[1];return c instanceof wA.Reference&&(c=c.resolve(t)),[f,c]}),(0,zu.default)(a._fields,function(o){var u=Gt(o,1),f=u[0];a.prototype[f]=OA(f)}),a}}]),r}();(0,$A.default)(SA);function OA(r){return function(t){return(0,vA.default)(t)||(this._attributes[r]=t),this._attributes[r]}}var Ht={};Object.defineProperty(Ht,"__esModule",{value:!0}),Ht.Union=void 0;var IA=function(){function r(e,t){var n=[],i=!0,a=!1,o=void 0;try{for(var u=e[Symbol.iterator](),f;!(i=(f=u.next()).done)&&(n.push(f.value),!(t&&n.length===t));i=!0);}catch(c){a=!0,o=c}finally{try{!i&&u.return&&u.return()}finally{if(a)throw o}}return n}return function(e,t){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e))return r(e,t);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),PA=function(){function r(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(e,t,n){return t&&r(e.prototype,t),n&&r(e,n),e}}(),xA=nr,Wt=zt(xA),TA=Nr,Ku=zt(TA),RA=Ou,Zu=zt(RA),Xt=Br,yi=Ur,FA=D,MA=zt(FA);function zt(r){return r&&r.__esModule?r:{default:r}}function DA(r,e){if(!r)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e&&(typeof e=="object"||typeof e=="function")?e:r}function CA(r,e){if(typeof e!="function"&&e!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof e);r.prototype=Object.create(e&&e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(r,e):r.__proto__=e)}function Ju(r,e){if(!(r instanceof e))throw new TypeError("Cannot call a class as a function")}var NA=Ht.Union=function(){function r(e,t){Ju(this,r),this.set(e,t)}return PA(r,[{key:"set",value:function(t,n){(0,Zu.default)(t)&&(t=this.constructor._switchOn.fromName(t)),this._switch=t,this._arm=this.constructor.armForSwitch(this._switch),this._armType=this.constructor.armTypeForArm(this._arm),this._value=n}},{key:"get",value:function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this._arm;if(this._arm!==Xt.Void&&this._arm!==t)throw new Error(t+" not set");return this._value}},{key:"switch",value:function(){return this._switch}},{key:"arm",value:function(){return this._arm}},{key:"armType",value:function(){return this._armType}},{key:"value",value:function(){return this._value}}],[{key:"armForSwitch",value:function(t){if(this._switches.has(t))return this._switches.get(t);if(this._defaultArm)return this._defaultArm;throw new Error("Bad union switch: "+t)}},{key:"armTypeForArm",value:function(t){return t===Xt.Void?Xt.Void:this._arms[t]}},{key:"read",value:function(t){var n=this._switchOn.read(t),i=this.armForSwitch(n),a=this.armTypeForArm(i),o=void 0;return(0,Ku.default)(a)?o=i.read(t):o=a.read(t),new this(n,o)}},{key:"write",value:function(t,n){if(!(t instanceof this))throw new Error("XDR Write Error: "+t+" is not a "+this.unionName);this._switchOn.write(t.switch(),n),t.armType().write(t.value(),n)}},{key:"isValid",value:function(t){return t instanceof this}},{key:"create",value:function(t,n,i){var a=function(u){CA(f,u);function f(){return Ju(this,f),DA(this,(f.__proto__||Object.getPrototypeOf(f)).apply(this,arguments))}return f}(r);a.unionName=n,t.results[n]=a,i.switchOn instanceof yi.Reference?a._switchOn=i.switchOn.resolve(t):a._switchOn=i.switchOn,a._switches=new Map,a._arms={},(0,Wt.default)(i.arms,function(u,f){u instanceof yi.Reference&&(u=u.resolve(t)),a._arms[f]=u});var o=i.defaultArm;return o instanceof yi.Reference&&(o=o.resolve(t)),a._defaultArm=o,(0,Wt.default)(i.switches,function(u){var f=IA(u,2),c=f[0],l=f[1];(0,Zu.default)(c)&&(c=a._switchOn.fromName(c)),a._switches.set(c,l)}),(0,Ku.default)(a._switchOn.values)||(0,Wt.default)(a._switchOn.values(),function(u){a[u.name]=function(f){return new a(u,f)},a.prototype[u.name]=function(c){return this.set(u,c)}}),(0,Wt.default)(a._arms,function(u,f){u!==Xt.Void&&(a.prototype[f]=function(){return this.get(f)})}),a}}]),r}();(0,MA.default)(NA),function(r){Object.defineProperty(r,"__esModule",{value:!0});var e=se;Object.keys(e).forEach(function(d){d==="default"||d==="__esModule"||Object.defineProperty(r,d,{enumerable:!0,get:function(){return e[d]}})});var t=Rt;Object.keys(t).forEach(function(d){d==="default"||d==="__esModule"||Object.defineProperty(r,d,{enumerable:!0,get:function(){return t[d]}})});var n=Ce;Object.keys(n).forEach(function(d){d==="default"||d==="__esModule"||Object.defineProperty(r,d,{enumerable:!0,get:function(){return n[d]}})});var i=Ft;Object.keys(i).forEach(function(d){d==="default"||d==="__esModule"||Object.defineProperty(r,d,{enumerable:!0,get:function(){return i[d]}})});var a=Mt;Object.keys(a).forEach(function(d){d==="default"||d==="__esModule"||Object.defineProperty(r,d,{enumerable:!0,get:function(){return a[d]}})});var o=Dt;Object.keys(o).forEach(function(d){d==="default"||d==="__esModule"||Object.defineProperty(r,d,{enumerable:!0,get:function(){return o[d]}})});var u=Ct;Object.keys(u).forEach(function(d){d==="default"||d==="__esModule"||Object.defineProperty(r,d,{enumerable:!0,get:function(){return u[d]}})});var f=Mr;Object.keys(f).forEach(function(d){d==="default"||d==="__esModule"||Object.defineProperty(r,d,{enumerable:!0,get:function(){return f[d]}})});var c=Nt;Object.keys(c).forEach(function(d){d==="default"||d==="__esModule"||Object.defineProperty(r,d,{enumerable:!0,get:function(){return c[d]}})});var l=Bt;Object.keys(l).forEach(function(d){d==="default"||d==="__esModule"||Object.defineProperty(r,d,{enumerable:!0,get:function(){return l[d]}})});var s=Ut;Object.keys(s).forEach(function(d){d==="default"||d==="__esModule"||Object.defineProperty(r,d,{enumerable:!0,get:function(){return s[d]}})});var h=qt;Object.keys(h).forEach(function(d){d==="default"||d==="__esModule"||Object.defineProperty(r,d,{enumerable:!0,get:function(){return h[d]}})});var y=Lt;Object.keys(y).forEach(function(d){d==="default"||d==="__esModule"||Object.defineProperty(r,d,{enumerable:!0,get:function(){return y[d]}})});var w=kt;Object.keys(w).forEach(function(d){d==="default"||d==="__esModule"||Object.defineProperty(r,d,{enumerable:!0,get:function(){return w[d]}})});var S=Br;Object.keys(S).forEach(function(d){d==="default"||d==="__esModule"||Object.defineProperty(r,d,{enumerable:!0,get:function(){return S[d]}})});var O=jt;Object.keys(O).forEach(function(d){d==="default"||d==="__esModule"||Object.defineProperty(r,d,{enumerable:!0,get:function(){return O[d]}})});var b=Vt;Object.keys(b).forEach(function(d){d==="default"||d==="__esModule"||Object.defineProperty(r,d,{enumerable:!0,get:function(){return b[d]}})});var E=Ht;Object.keys(E).forEach(function(d){d==="default"||d==="__esModule"||Object.defineProperty(r,d,{enumerable:!0,get:function(){return E[d]}})})}(Hn);var Qu={};(function(r){Object.defineProperty(r,"__esModule",{value:!0});var e=function(){function m(g,v){for(var A=0;A<v.length;A++){var P=v[A];P.enumerable=P.enumerable||!1,P.configurable=!0,"value"in P&&(P.writable=!0),Object.defineProperty(g,P.key,P)}}return function(g,v,A){return v&&m(g.prototype,v),A&&m(g,A),g}}(),t=Ur;Object.keys(t).forEach(function(m){m==="default"||m==="__esModule"||Object.defineProperty(r,m,{enumerable:!0,get:function(){return t[m]}})}),r.config=w;var n=Nr,i=l(n),a=nr,o=l(a),u=Hn,f=c(u);function c(m){if(m&&m.__esModule)return m;var g={};if(m!=null)for(var v in m)Object.prototype.hasOwnProperty.call(m,v)&&(g[v]=m[v]);return g.default=m,g}function l(m){return m&&m.__esModule?m:{default:m}}function s(m,g){if(!(m instanceof g))throw new TypeError("Cannot call a class as a function")}function h(m,g){if(!m)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return g&&(typeof g=="object"||typeof g=="function")?g:m}function y(m,g){if(typeof g!="function"&&g!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof g);m.prototype=Object.create(g&&g.prototype,{constructor:{value:m,enumerable:!1,writable:!0,configurable:!0}}),g&&(Object.setPrototypeOf?Object.setPrototypeOf(m,g):m.__proto__=g)}function w(m){var g=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(m){var v=new F(g);m(v),v.resolve()}return g}var S=function(m){y(g,m);function g(v){s(this,g);var A=h(this,(g.__proto__||Object.getPrototypeOf(g)).call(this));return A.name=v,A}return e(g,[{key:"resolve",value:function(A){var P=A.definitions[this.name];return P.resolve(A)}}]),g}(t.Reference),O=function(m){y(g,m);function g(v,A){var P=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;s(this,g);var M=h(this,(g.__proto__||Object.getPrototypeOf(g)).call(this));return M.childReference=v,M.length=A,M.variable=P,M}return e(g,[{key:"resolve",value:function(A){var P=this.childReference,M=this.length;return P instanceof t.Reference&&(P=P.resolve(A)),M instanceof t.Reference&&(M=M.resolve(A)),this.variable?new f.VarArray(P,M):new f.Array(P,M)}}]),g}(t.Reference),b=function(m){y(g,m);function g(v){s(this,g);var A=h(this,(g.__proto__||Object.getPrototypeOf(g)).call(this));return A.childReference=v,A.name=v.name,A}return e(g,[{key:"resolve",value:function(A){var P=this.childReference;return P instanceof t.Reference&&(P=P.resolve(A)),new f.Option(P)}}]),g}(t.Reference),E=function(m){y(g,m);function g(v,A){s(this,g);var P=h(this,(g.__proto__||Object.getPrototypeOf(g)).call(this));return P.sizedType=v,P.length=A,P}return e(g,[{key:"resolve",value:function(A){var P=this.length;return P instanceof t.Reference&&(P=P.resolve(A)),new this.sizedType(P)}}]),g}(t.Reference),d=function(){function m(g,v,A){s(this,m),this.constructor=g,this.name=v,this.config=A}return e(m,[{key:"resolve",value:function(v){return this.name in v.results?v.results[this.name]:this.constructor(v,this.name,this.config)}}]),m}();function I(m,g,v){return v instanceof t.Reference&&(v=v.resolve(m)),m.results[g]=v,v}function T(m,g,v){return m.results[g]=v,v}var F=function(){function m(g){s(this,m),this._destination=g,this._definitions={}}return e(m,[{key:"enum",value:function(v,A){var P=new d(f.Enum.create,v,A);this.define(v,P)}},{key:"struct",value:function(v,A){var P=new d(f.Struct.create,v,A);this.define(v,P)}},{key:"union",value:function(v,A){var P=new d(f.Union.create,v,A);this.define(v,P)}},{key:"typedef",value:function(v,A){var P=new d(I,v,A);this.define(v,P)}},{key:"const",value:function(v,A){var P=new d(T,v,A);this.define(v,P)}},{key:"void",value:function(){return f.Void}},{key:"bool",value:function(){return f.Bool}},{key:"int",value:function(){return f.Int}},{key:"hyper",value:function(){return f.Hyper}},{key:"uint",value:function(){return f.UnsignedInt}},{key:"uhyper",value:function(){return f.UnsignedHyper}},{key:"float",value:function(){return f.Float}},{key:"double",value:function(){return f.Double}},{key:"quadruple",value:function(){return f.Quadruple}},{key:"string",value:function(v){return new E(f.String,v)}},{key:"opaque",value:function(v){return new E(f.Opaque,v)}},{key:"varOpaque",value:function(v){return new E(f.VarOpaque,v)}},{key:"array",value:function(v,A){return new O(v,A)}},{key:"varArray",value:function(v,A){return new O(v,A,!0)}},{key:"option",value:function(v){return new b(v)}},{key:"define",value:function(v,A){if((0,i.default)(this._destination[v]))this._definitions[v]=A;else throw new Error("XDRTypes Error:"+v+" is already defined")}},{key:"lookup",value:function(v){return new S(v)}},{key:"resolve",value:function(){var v=this;(0,o.default)(this._definitions,function(A){A.resolve({definitions:v._definitions,results:v._destination})})}}]),m}()})(Qu),function(r){Object.defineProperty(r,"__esModule",{value:!0});var e=Hn;Object.keys(e).forEach(function(n){n==="default"||n==="__esModule"||Object.defineProperty(r,n,{enumerable:!0,get:function(){return e[n]}})});var t=Qu;Object.keys(t).forEach(function(n){n==="default"||n==="__esModule"||Object.defineProperty(r,n,{enumerable:!0,get:function(){return t[n]}})})}(to);var gi=(r,e,t)=>{if(!e.has(r))throw TypeError("Cannot "+t)},j=(r,e,t)=>(gi(r,e,"read from private field"),t?t.call(r):e.get(r)),Ne=(r,e,t)=>{if(e.has(r))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(r):e.set(r,t)},vi=(r,e,t,n)=>(gi(r,e,"write to private field"),n?n.call(r,t):e.set(r,t),t),_e=(r,e,t)=>(gi(r,e,"access private method"),t),te,ne,Lr,_i,es,mi,rs,Yt,wi,ir,kr;function BA(r){const e={variantId:ce.Uint64.fromString(r.variantId.toString()),version:r.version||Math.floor(Date.now()/1e3),items:r.items.map(n=>new ce.BundleItem({collectionId:ce.Uint64.fromString(n.collectionId.toString()),productId:ce.Uint64.fromString(n.productId.toString()),variantId:ce.Uint64.fromString(n.variantId.toString()),sku:n.sku||"",quantity:n.quantity,ext:new ce.BundleItemExt(0)})),ext:new ce.BundleExt(0)},t=new ce.Bundle(e);return ce.BundleEnvelope.envelopeTypeBundle(t).toXDR("base64")}const ce=to.config(r=>{r.enum("EnvelopeType",{envelopeTypeBundle:0}),r.typedef("Uint32",r.uint()),r.typedef("Uint64",r.uhyper()),r.union("BundleItemExt",{switchOn:r.int(),switchName:"v",switches:[[0,r.void()]],arms:{}}),r.struct("BundleItem",[["collectionId",r.lookup("Uint64")],["productId",r.lookup("Uint64")],["variantId",r.lookup("Uint64")],["sku",r.string()],["quantity",r.lookup("Uint32")],["ext",r.lookup("BundleItemExt")]]),r.union("BundleExt",{switchOn:r.int(),switchName:"v",switches:[[0,r.void()]],arms:{}}),r.struct("Bundle",[["variantId",r.lookup("Uint64")],["items",r.varArray(r.lookup("BundleItem"),500)],["version",r.lookup("Uint32")],["ext",r.lookup("BundleExt")]]),r.union("BundleEnvelope",{switchOn:r.lookup("EnvelopeType"),switchName:"type",switches:[["envelopeTypeBundle","v1"]],arms:{v1:r.lookup("Bundle")}})});class UA{constructor(e,t){Ne(this,_i),Ne(this,mi),Ne(this,Yt),Ne(this,ir),Ne(this,te,void 0),Ne(this,ne,void 0),Ne(this,Lr,void 0),vi(this,te,_e(this,_i,es).call(this,t)),vi(this,Lr,_e(this,mi,rs).call(this,t)),vi(this,ne,e)}isInitialDataValid(){if(!j(this,Lr))throw"Bundle data does not exist for the given product.";if(!j(this,te))throw"Bundle settings do not exist for the given product.";if(!Array.isArray(j(this,ne))||!j(this,ne).length)throw"No bundle selection items provided.";return!0}isValidVariant(e){if(!j(this,te)?.variantsSettings[e])throw`The ${e} bundle variant is invalid.`;return!0}isSelectionInVariantRange(e){const t=j(this,ne).reduce((i,a)=>i+a.quantity,0),n=j(this,te)?.variantsSettings[e].ranges||[];if(!_e(this,Yt,wi).call(this,n,t))throw"The total number of products does not fall within the required variant range.";return!0}areItemsInMaxPerItemBound(){const e=j(this,te)?.bundleSettings.maxPerItem||0,t=j(this,ne).filter(({quantity:n})=>n>e);if(e&&t.length)throw`The selected products (${_e(this,ir,kr).call(this,t.map(({externalProductId:n})=>n)).join(", ")}) exceed the maximum limit of ${e} items per product.`;return!0}areSelectedCollectionsValid(e){const t=j(this,te)?.variantsSettings[e],n=j(this,ne).filter(({collectionId:i})=>!t?.optionSources[i]);if(n.length)throw`The collections (${_e(this,ir,kr).call(this,n.map(({collectionId:i})=>i)).join(", ")}) are no longer valid for the bundle variant (${e}).`;return!0}areItemsQuantitiesValidForTheCollection(e){const t=j(this,ne).reduce((a,o)=>(a[o.collectionId]=o.quantity+(a[o.collectionId]||0),a),{}),n=j(this,te)?.variantsSettings[e],i=Object.values(n?.optionSources||{}).filter(a=>{const o=t[a.collectionId]||0;return!_e(this,Yt,wi).call(this,[a],o)});if(!n||i.length)throw`The selection exceeds the limits for the collections (${_e(this,ir,kr).call(this,i.map(({collectionId:a})=>a)).join(", ")}).`;return!0}areSelectedProductsValid(e){const t=j(this,te)?.variantsSettings[e]?.optionSources||{},n=Object.values(t).reduce((a,o)=>{const u=j(this,Lr)?.collections[o.collectionId];return u&&(a[o.collectionId]=u),a},{});if(!Object.values(n).length)throw`No collections found for the bundle variant (${e}).`;const i=j(this,ne).filter(({externalProductId:a,collectionId:o})=>!n[o]?.products[a]);if(i.length)throw`The products (${_e(this,ir,kr).call(this,i.map(({externalProductId:a})=>a)).join(", ")}) are no longer valid for the bundle product.`;return!0}isBundleSelectionValid(e){return this.isInitialDataValid(),this.isValidVariant(e),this.isSelectionInVariantRange(e),this.areItemsInMaxPerItemBound(),this.areSelectedCollectionsValid(e),this.areItemsQuantitiesValidForTheCollection(e),this.areSelectedProductsValid(e),!0}}te=new WeakMap,ne=new WeakMap,Lr=new WeakMap,_i=new WeakSet,es=function(r){try{const e=r.bundle_settings;return{bundleSettings:{maxPerItem:e.max_quantity_per_variant,isCustomizable:e.is_customizable},variantsSettings:e.variants.reduce((t,n)=>{if(!n.enabled)return t;let i=[{min:n.items_count,max:n.items_count}];return n.items_count||(i=n.ranges.map(({quantity_max:a,quantity_min:o})=>({min:o,max:a}))),t[n.external_variant_id]={externalVariantId:n.external_variant_id,optionSources:n.option_sources.reduce((a,o)=>(a[o.option_source_id]={min:o.quantity_min,max:o.quantity_max,collectionId:o.option_source_id},a),{}),ranges:i},t},{})}}catch{return null}},mi=new WeakSet,rs=function(r){try{const e=Object.values(r.collections).reduce((t,n)=>(t[n.id]={...n,products:n.products.reduce((i,a)=>(i[a.id]=a,i),{})},t),{});return{...r,collections:e}}catch{return null}},Yt=new WeakSet,wi=function(r,e){return!!r.filter(({min:t,max:n})=>{const i=t??e,a=n??e;return i<=e&&e<=a}).length},ir=new WeakSet,kr=function(r){return Array.from(new Set(r))};const ts="/bundling-storefront-manager";function ns(){return Math.ceil(Date.now()/1e3)}async function qA(){try{const{timestamp:r}=await Ke("get",`${ts}/t`);return r}catch(r){return console.error(`Fetch failed: ${r}. Using client-side date.`),ns()}}async function LA(r){try{const{timestamp:e}=await $("get","/bundle_selections/timestamp",{},r);return e}catch(e){return console.error(`Fetch failed: ${e}. Using client-side date.`),ns()}}function is(r,e){return BA({variantId:r.externalVariantId,version:e,items:r.selections.map(t=>({collectionId:t.collectionId,productId:t.externalProductId,variantId:t.externalVariantId,quantity:t.quantity,sku:""}))})}async function kA(r){const e=W(),t=await bi(r);if(t!==!0)throw new Error(t);const n=await qA(),i=is(r,n);try{const a=await Ke("post",`${ts}/api/v1/bundles`,{data:{bundle:i},headers:{Origin:`https://${e.storeIdentifier}`}});if(!a.id||a.code!==200)throw new Error(`1: failed generating rb_id: ${JSON.stringify(a)}`);return a.id}catch(a){throw new Error(`2: failed generating rb_id ${a}`)}}async function jA(r,e){const t=await bi(e);if(t!==!0)throw new Error(t);const n=_(r,"getBundleSelectionId"),i=await LA(n),a=is(e,i);try{const o=await $("post","/bundle_selections/bundle_id",{data:{bundle:a}},n);if(!o.id||o.code!==200)throw new Error(`1: failed generating rb_id: ${JSON.stringify(o)}`);return o.id}catch(o){throw new Error(`2: failed generating rb_id ${o}`)}}function VA(r,e){const t=as(r);if(t!==!0)throw new Error(`Dynamic Bundle is invalid. ${t}`);const n=`${Vi(9)}:${r.externalProductId}`;return r.selections.map(i=>{const a={id:i.externalVariantId,quantity:i.quantity,properties:{_rc_bundle:n,_rc_bundle_variant:r.externalVariantId,_rc_bundle_parent:e,_rc_bundle_collection_id:i.collectionId}};return i.sellingPlan?a.selling_plan=i.sellingPlan:i.shippingIntervalFrequency&&(a.properties.shipping_interval_frequency=i.shippingIntervalFrequency,a.properties.shipping_interval_unit_type=i.shippingIntervalUnitType,a.id=`${i.discountedVariantId}`),a})}async function bi(r){try{return r?!0:"Bundle is not defined"}catch(e){return`Error fetching bundle settings: ${e}`}}async function GA(r){try{const e=await Ke("get",`/bundle-data/${r.externalProductId}`);return{valid:new UA(r.selections,e).isBundleSelectionValid(r.externalVariantId)}}catch(e){return{valid:!1,error:String(e)}}}const HA={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 as(r){if(!r)return"No bundle defined.";if(r.selections.length===0)return"No selections defined.";const{shippingIntervalFrequency:e,shippingIntervalUnitType:t}=r.selections.find(n=>n.shippingIntervalFrequency||n.shippingIntervalUnitType)||{};if(e||t){if(!e||!t)return"Shipping intervals do not match on selections.";{const n=HA[t];for(let i=0;i<r.selections.length;i++){const{shippingIntervalFrequency:a,shippingIntervalUnitType:o}=r.selections[i];if(a&&a!==e||o&&!n.includes(o))return"Shipping intervals do not match on selections."}}}return!0}async function WA(r,e){if(e===void 0||e==="")throw new Error("ID is required");const{bundle_selection:t}=await $("get","/bundle_selections",{id:e},_(r,"getBundleSelection"));return t}function XA(r,e){return $("get","/bundle_selections",{query:e},_(r,"listBundleSelections"))}async function zA(r,e){const{bundle_selection:t}=await $("post","/bundle_selections",{data:e},_(r,"createBundleSelection"));return t}async function YA(r,e,t){if(e===void 0||e==="")throw new Error("ID is required");const{bundle_selection:n}=await $("put","/bundle_selections",{id:e,data:t},_(r,"updateBundleSelection"));return n}function KA(r,e){if(e===void 0||e==="")throw new Error("ID is required");return $("delete","/bundle_selections",{id:e},_(r,"deleteBundleSelection"))}async function ZA(r,e,t,n){if(e===void 0||e==="")throw new Error("Purchase item ID is required");const{subscription:i}=await $("put","/bundles",{id:e,data:t,query:n},_(r,"updateBundle"));return i}var JA=Object.freeze({__proto__:null,createBundleSelection:zA,deleteBundleSelection:KA,getBundleId:kA,getBundleSelection:WA,getBundleSelectionId:jA,getDynamicBundleItems:VA,listBundleSelections:XA,updateBundle:ZA,updateBundleSelection:YA,validateBundle:bi,validateBundleSelection:GA,validateDynamicBundle:as}),QA=200,$i="__lodash_hash_undefined__",eS=1/0,os=9007199254740991,rS="[object Arguments]",tS="[object Function]",nS="[object GeneratorFunction]",iS="[object Symbol]",aS=/[\\^$.*+?()[\]{}|]/g,oS=/^\[object .+?Constructor\]$/,uS=/^(?:0|[1-9]\d*)$/,sS=typeof U=="object"&&U&&U.Object===Object&&U,fS=typeof self=="object"&&self&&self.Object===Object&&self,Ei=sS||fS||Function("return this")();function cS(r,e,t){switch(t.length){case 0:return r.call(e);case 1:return r.call(e,t[0]);case 2:return r.call(e,t[0],t[1]);case 3:return r.call(e,t[0],t[1],t[2])}return r.apply(e,t)}function lS(r,e){var t=r?r.length:0;return!!t&&pS(r,e,0)>-1}function hS(r,e,t){for(var n=-1,i=r?r.length:0;++n<i;)if(t(e,r[n]))return!0;return!1}function us(r,e){for(var t=-1,n=r?r.length:0,i=Array(n);++t<n;)i[t]=e(r[t],t,r);return i}function Ai(r,e){for(var t=-1,n=e.length,i=r.length;++t<n;)r[i+t]=e[t];return r}function dS(r,e,t,n){for(var i=r.length,a=t+(n?1:-1);n?a--:++a<i;)if(e(r[a],a,r))return a;return-1}function pS(r,e,t){if(e!==e)return dS(r,yS,t);for(var n=t-1,i=r.length;++n<i;)if(r[n]===e)return n;return-1}function yS(r){return r!==r}function gS(r,e){for(var t=-1,n=Array(r);++t<r;)n[t]=e(t);return n}function vS(r){return function(e){return r(e)}}function _S(r,e){return r.has(e)}function mS(r,e){return r?.[e]}function wS(r){var e=!1;if(r!=null&&typeof r.toString!="function")try{e=!!(r+"")}catch{}return e}function ss(r,e){return function(t){return r(e(t))}}var bS=Array.prototype,$S=Function.prototype,Kt=Object.prototype,Si=Ei["__core-js_shared__"],fs=function(){var r=/[^.]+$/.exec(Si&&Si.keys&&Si.keys.IE_PROTO||"");return r?"Symbol(src)_1."+r:""}(),cs=$S.toString,ar=Kt.hasOwnProperty,Oi=Kt.toString,ES=RegExp("^"+cs.call(ar).replace(aS,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),ls=Ei.Symbol,AS=ss(Object.getPrototypeOf,Object),SS=Kt.propertyIsEnumerable,OS=bS.splice,hs=ls?ls.isConcatSpreadable:void 0,Ii=Object.getOwnPropertySymbols,ds=Math.max,IS=ys(Ei,"Map"),jr=ys(Object,"create");function Be(r){var e=-1,t=r?r.length:0;for(this.clear();++e<t;){var n=r[e];this.set(n[0],n[1])}}function PS(){this.__data__=jr?jr(null):{}}function xS(r){return this.has(r)&&delete this.__data__[r]}function TS(r){var e=this.__data__;if(jr){var t=e[r];return t===$i?void 0:t}return ar.call(e,r)?e[r]:void 0}function RS(r){var e=this.__data__;return jr?e[r]!==void 0:ar.call(e,r)}function FS(r,e){var t=this.__data__;return t[r]=jr&&e===void 0?$i:e,this}Be.prototype.clear=PS,Be.prototype.delete=xS,Be.prototype.get=TS,Be.prototype.has=RS,Be.prototype.set=FS;function or(r){var e=-1,t=r?r.length:0;for(this.clear();++e<t;){var n=r[e];this.set(n[0],n[1])}}function MS(){this.__data__=[]}function DS(r){var e=this.__data__,t=Jt(e,r);if(t<0)return!1;var n=e.length-1;return t==n?e.pop():OS.call(e,t,1),!0}function CS(r){var e=this.__data__,t=Jt(e,r);return t<0?void 0:e[t][1]}function NS(r){return Jt(this.__data__,r)>-1}function BS(r,e){var t=this.__data__,n=Jt(t,r);return n<0?t.push([r,e]):t[n][1]=e,this}or.prototype.clear=MS,or.prototype.delete=DS,or.prototype.get=CS,or.prototype.has=NS,or.prototype.set=BS;function ur(r){var e=-1,t=r?r.length:0;for(this.clear();++e<t;){var n=r[e];this.set(n[0],n[1])}}function US(){this.__data__={hash:new Be,map:new(IS||or),string:new Be}}function qS(r){return Qt(this,r).delete(r)}function LS(r){return Qt(this,r).get(r)}function kS(r){return Qt(this,r).has(r)}function jS(r,e){return Qt(this,r).set(r,e),this}ur.prototype.clear=US,ur.prototype.delete=qS,ur.prototype.get=LS,ur.prototype.has=kS,ur.prototype.set=jS;function Zt(r){var e=-1,t=r?r.length:0;for(this.__data__=new ur;++e<t;)this.add(r[e])}function VS(r){return this.__data__.set(r,$i),this}function GS(r){return this.__data__.has(r)}Zt.prototype.add=Zt.prototype.push=VS,Zt.prototype.has=GS;function HS(r,e){var t=Pi(r)||gs(r)?gS(r.length,String):[],n=t.length,i=!!n;for(var a in r)(e||ar.call(r,a))&&!(i&&(a=="length"||nO(a,n)))&&t.push(a);return t}function Jt(r,e){for(var t=r.length;t--;)if(cO(r[t][0],e))return t;return-1}function WS(r,e,t,n){var i=-1,a=lS,o=!0,u=r.length,f=[],c=e.length;if(!u)return f;t&&(e=us(e,vS(t))),n?(a=hS,o=!1):e.length>=QA&&(a=_S,o=!1,e=new Zt(e));e:for(;++i<u;){var l=r[i],s=t?t(l):l;if(l=n||l!==0?l:0,o&&s===s){for(var h=c;h--;)if(e[h]===s)continue e;f.push(l)}else a(e,s,n)||f.push(l)}return f}function ps(r,e,t,n,i){var a=-1,o=r.length;for(t||(t=tO),i||(i=[]);++a<o;){var u=r[a];e>0&&t(u)?e>1?ps(u,e-1,t,n,i):Ai(i,u):n||(i[i.length]=u)}return i}function XS(r,e,t){var n=e(r);return Pi(r)?n:Ai(n,t(r))}function zS(r){if(!xi(r)||aO(r))return!1;var e=_s(r)||wS(r)?ES:oS;return e.test(fO(r))}function YS(r){if(!xi(r))return uO(r);var e=oO(r),t=[];for(var n in r)n=="constructor"&&(e||!ar.call(r,n))||t.push(n);return t}function KS(r,e){return r=Object(r),ZS(r,e,function(t,n){return n in r})}function ZS(r,e,t){for(var n=-1,i=e.length,a={};++n<i;){var o=e[n],u=r[o];t(u,o)&&(a[o]=u)}return a}function JS(r,e){return e=ds(e===void 0?r.length-1:e,0),function(){for(var t=arguments,n=-1,i=ds(t.length-e,0),a=Array(i);++n<i;)a[n]=t[e+n];n=-1;for(var o=Array(e+1);++n<e;)o[n]=t[n];return o[e]=a,cS(r,this,o)}}function QS(r){return XS(r,pO,rO)}function Qt(r,e){var t=r.__data__;return iO(e)?t[typeof e=="string"?"string":"hash"]:t.map}function ys(r,e){var t=mS(r,e);return zS(t)?t:void 0}var eO=Ii?ss(Ii,Object):ws,rO=Ii?function(r){for(var e=[];r;)Ai(e,eO(r)),r=AS(r);return e}:ws;function tO(r){return Pi(r)||gs(r)||!!(hs&&r&&r[hs])}function nO(r,e){return e=e??os,!!e&&(typeof r=="number"||uS.test(r))&&r>-1&&r%1==0&&r<e}function iO(r){var e=typeof r;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?r!=="__proto__":r===null}function aO(r){return!!fs&&fs in r}function oO(r){var e=r&&r.constructor,t=typeof e=="function"&&e.prototype||Kt;return r===t}function uO(r){var e=[];if(r!=null)for(var t in Object(r))e.push(t);return e}function sO(r){if(typeof r=="string"||dO(r))return r;var e=r+"";return e=="0"&&1/r==-eS?"-0":e}function fO(r){if(r!=null){try{return cs.call(r)}catch{}try{return r+""}catch{}}return""}function cO(r,e){return r===e||r!==r&&e!==e}function gs(r){return lO(r)&&ar.call(r,"callee")&&(!SS.call(r,"callee")||Oi.call(r)==rS)}var Pi=Array.isArray;function vs(r){return r!=null&&hO(r.length)&&!_s(r)}function lO(r){return ms(r)&&vs(r)}function _s(r){var e=xi(r)?Oi.call(r):"";return e==tS||e==nS}function hO(r){return typeof r=="number"&&r>-1&&r%1==0&&r<=os}function xi(r){var e=typeof r;return!!r&&(e=="object"||e=="function")}function ms(r){return!!r&&typeof r=="object"}function dO(r){return typeof r=="symbol"||ms(r)&&Oi.call(r)==iS}function pO(r){return vs(r)?HS(r,!0):YS(r)}var yO=JS(function(r,e){return r==null?{}:(e=us(ps(e,1),sO),KS(r,WS(QS(r),e)))});function ws(){return[]}var gO=yO,Ti=be(gO);function vO(r){try{return JSON.parse(r)}catch{return r}}function _O(r){return Object.entries(r).reduce((e,[t,n])=>({...e,[t]:vO(n)}),{})}const bs=r=>typeof r=="string"?r!=="0"&&r!=="false":!!r;function $s(r){const e=_O(r),t=e.auto_inject===void 0?!0:e.auto_inject,n=e.display_on??[],i=e.first_option==="autodeliver";return{...Ti(e,["display_on","first_option"]),auto_inject:t,valid_pages:n,is_subscription_first:i,autoInject:t,validPages:n,isSubscriptionFirst:i}}function Es(r){const e=r.subscription_options?.storefront_purchase_options==="subscription_only";return{...r,is_subscription_only:e,isSubscriptionOnly:e}}function mO(r){return r.map(e=>{const t={};return Object.entries(e).forEach(([n,i])=>{t[n]=Es(i)}),t})}const Ri="2020-12",wO={store_currency:{currency_code:"USD",currency_symbol:"$",decimal_separator:".",thousands_separator:",",currency_symbol_location:"left"}},Vr=new Map;function en(r,e){return Vr.has(r)||Vr.set(r,e()),Vr.get(r)}async function Fi(r,e){if(r===void 0||r==="")throw new Error("ID is required");const t=e?.version??"2020-12",{product:n}=await en(`product.${r}.${t}`,()=>pt("get",`/product/${t}/${r}.json`));return t==="2020-12"?Es(n):n}async function As(){return await en("storeSettings",()=>pt("get",`/${Ri}/store_settings.json`).catch(()=>wO))}async function Ss(){const{widget_settings:r}=await en("widgetSettings",()=>pt("get",`/${Ri}/widget_settings.json`));return $s(r)}async function Os(){const{products:r,widget_settings:e,store_settings:t,meta:n}=await en("productsAndSettings",()=>pt("get",`/product/${Ri}/products.json`));return n?.status==="error"?Promise.reject(n.message):{products:mO(r),widget_settings:$s(e),store_settings:t??{}}}async function bO(){const{products:r}=await Os();return r}async function $O(r){const[e,t,n]=await Promise.all([Fi(r),As(),Ss()]);return{product:e,store_settings:t,widget_settings:n,storeSettings:t,widgetSettings:n}}async function EO(r){const{bundle_product:e}=await Fi(r);return e}async function Is(){return Array.from(Vr.keys()).forEach(r=>Vr.delete(r))}var AO=Object.freeze({__proto__:null,getCDNBundleSettings:EO,getCDNProduct:Fi,getCDNProductAndSettings:$O,getCDNProducts:bO,getCDNProductsAndSettings:Os,getCDNStoreSettings:As,getCDNWidgetSettings:Ss,resetCDNCache:Is});async function SO(r,e,t){if(e===void 0||e==="")throw new Error("ID is required");const{charge:n}=await $("get","/charges",{id:e,query:{include:t?.include}},_(r,"getCharge"));return n}function OO(r,e){return $("get","/charges",{query:e},_(r,"listCharges"))}async function IO(r,e,t){if(e===void 0||e==="")throw new Error("ID is required");const{charge:n}=await $("post",`/charges/${e}/apply_discount`,{data:{discount_code:t}},_(r,"applyDiscountToCharge"));return n}async function PO(r,e){if(e===void 0||e==="")throw new Error("ID is required");const{charge:t}=await $("post",`/charges/${e}/remove_discount`,{},_(r,"removeDiscountsFromCharge"));return t}async function xO(r,e,t,n){if(e===void 0||e==="")throw new Error("ID is required");if(t===void 0||t.length===0)throw new Error("Purchase item IDs are required");const{charge:i}=await $("post",`/charges/${e}/skip`,{query:n,data:{purchase_item_ids:t.map(a=>Number(a))}},_(r,"skipCharge"));return i}async function TO(r,e,t,n){if(e===void 0||e==="")throw new Error("ID is required");if(t===void 0||t.length===0)throw new Error("Purchase item IDs are required");const{charge:i}=await $("post",`/charges/${e}/unskip`,{query:n,data:{purchase_item_ids:t.map(a=>Number(a))}},_(r,"unskipCharge"));return i}async function RO(r,e){if(e===void 0||e==="")throw new Error("ID is required");const{charge:t}=await $("post",`/charges/${e}/process`,{},_(r,"processCharge"));return t}var FO=Object.freeze({__proto__:null,applyDiscountToCharge:IO,getCharge:SO,listCharges:OO,processCharge:RO,removeDiscountsFromCharge:PO,skipCharge:xO,unskipCharge:TO});async function Ps(r,e){if(!["2020-12","2022-06"].includes(e.format_version))throw new Error("Missing or unsupported format_version.");return $("get","/product_search",{query:e,headers:{"X-Recharge-Version":"2021-01"}},_(r,"productSearch"))}var MO=Object.freeze({__proto__:null,productSearch:Ps});async function xs(r,e){if(e===void 0||e==="")throw new Error("ID is required");const{collection:t}=await $("get","/collections",{id:e},_(r,"getCollection"));return t}function DO(r,e){return $("get","/collections",{query:e},_(r,"listCollections"))}async function CO(r,e,t){if(e===void 0||e==="")throw new Error("ID is required");if(!["2020-12","2022-06"].includes(t.format_version))throw new Error("Missing or unsupported format_version.");const n=_(r,"listCollectionProducts"),[{sort_order:i,manual_sort_order:a},{products:o}]=await Promise.all([xs(n,e),Ps(n,{...t,collection_ids:[e],limit:250})]);if(i==="manual")return{products:a.reduce((u,f)=>{const c=o.find(l=>l.external_product_id===f);return c&&u.push(c),u},[])};{const u=NO(i);return{products:o.slice().sort(u)}}}function Ts(r,e){const t=r.external_created_at,n=e.external_created_at;return t<n?-1:n>t?1:0}function Rs(r,e){const t=r.external_product_id,n=e.external_product_id;return t<n?-1:n>t?1:0}function Fs(r,e){const t=r.title.toLowerCase(),n=e.title.toLowerCase();return t<n?-1:n>t?1:0}function NO(r){switch(r){case"created_at-asc":return Ts;case"created_at-desc":return(e,t)=>Ts(t,e);case"id-asc":return Rs;case"id-desc":return(e,t)=>Rs(t,e);case"title-asc":return Fs;case"title-desc":return(e,t)=>Fs(t,e)}}var BO=Object.freeze({__proto__:null,getCollection:xs,listCollectionProducts:CO,listCollections:DO});async function UO(r,e){const t=r.customerId;if(!t)throw new Error("Not logged in.");const{customer:n}=await $("get","/customers",{id:t,query:{include:e?.include}},_(r,"getCustomer"));return n}async function Ms(r,e){const t=r.customerId;if(!t)throw new Error("Not logged in.");const{customer:n}=await $("put","/customers",{id:t,data:e},_(r,"updateCustomer"));return n}async function qO(r,e){const t=r.customerId;if(!t)throw new Error("Not logged in.");const{deliveries:n}=await $("get",`/customers/${t}/delivery_schedule`,{query:e},_(r,"getDeliverySchedule"));return n}async function rn(r,e){return $("get","/portal_access",{query:e},_(r,"getCustomerPortalAccess"))}async function LO(r,e,t){if(e===void 0||e==="")throw new Error("Subscription ID is required");const{base_url:n,customer_hash:i,temp_token:a}=await rn(_(r,"getActiveChurnLandingPageURL"));return`${n.replace("portal","pages")}${i}/subscriptions/${e}/cancel?token=${a}&subscription=${e}&redirect_to=${t}`}async function kO(r){const{base_url:e,customer_hash:t,temp_token:n}=await rn(_(r,"getFailedPaymentMethodRecoveryLandingPageURL"));return`${e.replace("portal","pages")}account/payment-methods?token=${n}&hash=${t}`}async function jO(r,e,t){if(e===void 0||e==="")throw new Error("Gift ID is required");const{base_url:n,customer_hash:i,temp_token:a}=await rn(_(r,"getGiftRedemptionLandingPageURL"));return`${n.replace("portal","pages")}${i}/gifts/${e}?token=${a}&redirect_to=${t}`}const VO={SHOPIFY_UPDATE_PAYMENT_INFO:{type:"email",template_type:"shopify_update_payment_information"}};async function GO(r,e,t){const n=r.customerId;if(!n)throw new Error("Not logged in.");const i=VO[e];if(!i)throw new Error("Notification not supported.");return $("post",`/customers/${n}/notifications`,{data:{...i,template_vars:t}},_(r,"sendCustomerNotification"))}async function HO(r,e){const t=r.customerId;if(!t)throw new Error("Not logged in.");const{credit_summary:n}=await $("get",`/customers/${t}/credit_summary`,{query:{include:e?.include}},_(r,"getCreditSummary"));return n}var WO=Object.freeze({__proto__:null,getActiveChurnLandingPageURL:LO,getCreditSummary:HO,getCustomer:UO,getCustomerPortalAccess:rn,getDeliverySchedule:qO,getFailedPaymentMethodRecoveryLandingPageURL:kO,getGiftRedemptionLandingPageURL:jO,sendCustomerNotification:GO,updateCustomer:Ms});async function XO(r,e){const t=r.customerId;if(!t)throw new Error("Not logged in.");const{credit_summary:n}=await $("get",`/customers/${t}/credit_summary`,{query:{include:e?.include,presentment_currency_code:e?.presentment_currency_code}},_(r,"getCreditSummary"));return n}function zO(r,{recurring:e}){if(!r.customerId)throw new Error("Not logged in.");const t={};return e!==void 0&&(t.apply_credit_to_next_recurring_charge=e),Ms(_(r,"setApplyCreditsToNextCharge"),t)}async function YO(r,e){const t=r.customerId;if(!t)throw new Error("Not logged in.");return await $("get","/credit_accounts",{query:{customer_id:t,...e}},_(r,"listCreditAccounts"))}var KO=Object.freeze({__proto__:null,getCreditSummary:XO,listCreditAccounts:YO,setApplyCreditsToNextCharge:zO});function ZO(r,e){if(!r.customerId)throw new Error("Not logged in.");return $("get","/gift_purchases",{query:e},_(r,"listGiftPurchases"))}async function JO(r,e){if(!r.customerId)throw new Error("Not logged in.");if(e===void 0||e==="")throw new Error("ID is required");const{gift_purchase:t}=await $("get","/gift_purchases",{id:e},_(r,"getGiftPurchase"));return t}var QO=Object.freeze({__proto__:null,getGiftPurchase:JO,listGiftPurchases:ZO});async function eI(r,e){if(e===void 0||e==="")throw new Error("ID is required");const{membership:t}=await $("get","/memberships",{id:e},_(r,"getMembership"));return t}function rI(r,e){return $("get","/memberships",{query:e},_(r,"listMemberships"))}async function tI(r,e,t){if(e===void 0||e==="")throw new Error("ID is required");const{membership:n}=await $("post",`/memberships/${e}/cancel`,{data:t},_(r,"cancelMembership"));return n}async function nI(r,e,t){if(e===void 0||e==="")throw new Error("ID is required");const{membership:n}=await $("post",`/memberships/${e}/activate`,{data:t},_(r,"activateMembership"));return n}async function iI(r,e,t){if(e===void 0||e==="")throw new Error("ID is required");const{membership:n}=await $("post",`/memberships/${e}/change`,{data:t},_(r,"changeMembership"));return n}var aI=Object.freeze({__proto__:null,activateMembership:nI,cancelMembership:tI,changeMembership:iI,getMembership:eI,listMemberships:rI});async function oI(r,e,t){if(e===void 0||e==="")throw new Error("ID is required");const{membership_program:n}=await $("get","/membership_programs",{id:e,query:{include:t?.include}},_(r,"getMembershipProgram"));return n}function uI(r,e){return $("get","/membership_programs",{query:e},_(r,"listMembershipPrograms"))}var sI=Object.freeze({__proto__:null,getMembershipProgram:oI,listMembershipPrograms:uI});async function fI(r,e){const{metafield:t}=await $("post","/metafields",{data:{metafield:e}},_(r,"createMetafield"));return t}async function cI(r,e,t){if(e===void 0||e==="")throw new Error("ID is required");const{metafield:n}=await $("put","/metafields",{id:e,data:{metafield:t}},_(r,"updateMetafield"));return n}function lI(r,e){if(e===void 0||e==="")throw new Error("ID is required");return $("delete","/metafields",{id:e},_(r,"deleteMetafield"))}var hI=Object.freeze({__proto__:null,createMetafield:fI,deleteMetafield:lI,updateMetafield:cI});async function dI(r,e){if(e===void 0||e==="")throw new Error("ID is required");const{onetime:t}=await $("get","/onetimes",{id:e},_(r,"getOnetime"));return t}function pI(r,e){return $("get","/onetimes",{query:e},_(r,"listOnetimes"))}async function yI(r,e){const{onetime:t}=await $("post","/onetimes",{data:e},_(r,"createOnetime"));return t}async function gI(r,e,t){if(e===void 0||e==="")throw new Error("ID is required");const{onetime:n}=await $("put","/onetimes",{id:e,data:t},_(r,"updateOnetime"));return n}function vI(r,e){if(e===void 0||e==="")throw new Error("ID is required");return $("delete","/onetimes",{id:e},_(r,"deleteOnetime"))}var _I=Object.freeze({__proto__:null,createOnetime:yI,deleteOnetime:vI,getOnetime:dI,listOnetimes:pI,updateOnetime:gI});async function mI(r,e){if(e===void 0||e==="")throw new Error("ID is required");const{order:t}=await $("get","/orders",{id:e},_(r,"getOrder"));return t}function wI(r,e){return $("get","/orders",{query:e},_(r,"listOrders"))}async function bI(r,e){if(e===void 0||e==="")throw new Error("ID is required");const{order:t}=await $("post",`/orders/${e}/delay`,{},_(r,"delayOrder"));return t}var $I=Object.freeze({__proto__:null,delayOrder:bI,getOrder:mI,listOrders:wI});async function EI(r,e,t){if(e===void 0||e==="")throw new Error("ID is required");const{payment_method:n}=await $("get","/payment_methods",{id:e,query:{include:t?.include}},_(r,"getPaymentMethod"));return n}async function AI(r,e){const{payment_method:t}=await $("post","/payment_methods",{data:{...e,customer_id:r.customerId}},_(r,"createPaymentMethod"));return t}async function SI(r,e,t){if(e===void 0||e==="")throw new Error("ID is required");const{payment_method:n}=await $("put","/payment_methods",{id:e,data:t},_(r,"updatePaymentMethod"));return n}function OI(r,e){return $("get","/payment_methods",{query:e},_(r,"listPaymentMethods"))}var II=Object.freeze({__proto__:null,createPaymentMethod:AI,getPaymentMethod:EI,listPaymentMethods:OI,updatePaymentMethod:SI});async function PI(r,e){if(e===void 0||e==="")throw new Error("ID is required");const{plan:t}=await $("get","/plans",{id:e},_(r,"getPlan"));return t}function xI(r,e){return $("get","/plans",{query:e},_(r,"listPlans"))}var TI=Object.freeze({__proto__:null,getPlan:PI,listPlans:xI});async function RI(r,e){return await $("get","/shop/shipping_countries",{query:e,headers:{"X-Recharge-Version":"2021-01"}},_(r,"getShippingCountries"))}async function FI(r){return await $("get","/shop/settings",{headers:{"X-Recharge-Version":"2021-01"}},_(r,"getStoreSettings"))}var MI=Object.freeze({__proto__:null,getShippingCountries:RI,getStoreSettings:FI}),DI="Expected a function",Ds="__lodash_placeholder__",Ue=1,tn=2,CI=4,sr=8,Gr=16,qe=32,Hr=64,Cs=128,NI=256,Ns=512,Bs=1/0,BI=9007199254740991,UI=17976931348623157e292,Us=0/0,qI=[["ary",Cs],["bind",Ue],["bindKey",tn],["curry",sr],["curryRight",Gr],["flip",Ns],["partial",qe],["partialRight",Hr],["rearg",NI]],LI="[object Function]",kI="[object GeneratorFunction]",jI="[object Symbol]",VI=/[\\^$.*+?()[\]{}|]/g,GI=/^\s+|\s+$/g,HI=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,WI=/\{\n\/\* \[wrapped with (.+)\] \*/,XI=/,? & /,zI=/^[-+]0x[0-9a-f]+$/i,YI=/^0b[01]+$/i,KI=/^\[object .+?Constructor\]$/,ZI=/^0o[0-7]+$/i,JI=/^(?:0|[1-9]\d*)$/,QI=parseInt,e2=typeof U=="object"&&U&&U.Object===Object&&U,r2=typeof self=="object"&&self&&self.Object===Object&&self,Wr=e2||r2||Function("return this")();function Mi(r,e,t){switch(t.length){case 0:return r.call(e);case 1:return r.call(e,t[0]);case 2:return r.call(e,t[0],t[1]);case 3:return r.call(e,t[0],t[1],t[2])}return r.apply(e,t)}function t2(r,e){for(var t=-1,n=r?r.length:0;++t<n&&e(r[t],t,r)!==!1;);return r}function n2(r,e){var t=r?r.length:0;return!!t&&a2(r,e,0)>-1}function i2(r,e,t,n){for(var i=r.length,a=t+(n?1:-1);n?a--:++a<i;)if(e(r[a],a,r))return a;return-1}function a2(r,e,t){if(e!==e)return i2(r,o2,t);for(var n=t-1,i=r.length;++n<i;)if(r[n]===e)return n;return-1}function o2(r){return r!==r}function u2(r,e){for(var t=r.length,n=0;t--;)r[t]===e&&n++;return n}function s2(r,e){return r?.[e]}function f2(r){var e=!1;if(r!=null&&typeof r.toString!="function")try{e=!!(r+"")}catch{}return e}function Di(r,e){for(var t=-1,n=r.length,i=0,a=[];++t<n;){var o=r[t];(o===e||o===Ds)&&(r[t]=Ds,a[i++]=t)}return a}var c2=Function.prototype,qs=Object.prototype,Ci=Wr["__core-js_shared__"],Ls=function(){var r=/[^.]+$/.exec(Ci&&Ci.keys&&Ci.keys.IE_PROTO||"");return r?"Symbol(src)_1."+r:""}(),ks=c2.toString,l2=qs.hasOwnProperty,js=qs.toString,h2=RegExp("^"+ks.call(l2).replace(VI,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),d2=Object.create,fr=Math.max,p2=Math.min,Vs=function(){var r=Hs(Object,"defineProperty"),e=Hs.name;return e&&e.length>2?r:void 0}();function y2(r){return cr(r)?d2(r):{}}function g2(r){if(!cr(r)||P2(r))return!1;var e=F2(r)||f2(r)?h2:KI;return e.test(T2(r))}function v2(r,e){return e=fr(e===void 0?r.length-1:e,0),function(){for(var t=arguments,n=-1,i=fr(t.length-e,0),a=Array(i);++n<i;)a[n]=t[e+n];n=-1;for(var o=Array(e+1);++n<e;)o[n]=t[n];return o[e]=a,Mi(r,this,o)}}function _2(r,e,t,n){for(var i=-1,a=r.length,o=t.length,u=-1,f=e.length,c=fr(a-o,0),l=Array(f+c),s=!n;++u<f;)l[u]=e[u];for(;++i<o;)(s||i<a)&&(l[t[i]]=r[i]);for(;c--;)l[u++]=r[i++];return l}function m2(r,e,t,n){for(var i=-1,a=r.length,o=-1,u=t.length,f=-1,c=e.length,l=fr(a-u,0),s=Array(l+c),h=!n;++i<l;)s[i]=r[i];for(var y=i;++f<c;)s[y+f]=e[f];for(;++o<u;)(h||i<a)&&(s[y+t[o]]=r[i++]);return s}function w2(r,e){var t=-1,n=r.length;for(e||(e=Array(n));++t<n;)e[t]=r[t];return e}function b2(r,e,t){var n=e&Ue,i=Xr(r);function a(){var o=this&&this!==Wr&&this instanceof a?i:r;return o.apply(n?t:this,arguments)}return a}function Xr(r){return function(){var e=arguments;switch(e.length){case 0:return new r;case 1:return new r(e[0]);case 2:return new r(e[0],e[1]);case 3:return new r(e[0],e[1],e[2]);case 4:return new r(e[0],e[1],e[2],e[3]);case 5:return new r(e[0],e[1],e[2],e[3],e[4]);case 6:return new r(e[0],e[1],e[2],e[3],e[4],e[5]);case 7:return new r(e[0],e[1],e[2],e[3],e[4],e[5],e[6])}var t=y2(r.prototype),n=r.apply(t,e);return cr(n)?n:t}}function $2(r,e,t){var n=Xr(r);function i(){for(var a=arguments.length,o=Array(a),u=a,f=Bi(i);u--;)o[u]=arguments[u];var c=a<3&&o[0]!==f&&o[a-1]!==f?[]:Di(o,f);if(a-=c.length,a<t)return Gs(r,e,Ni,i.placeholder,void 0,o,c,void 0,void 0,t-a);var l=this&&this!==Wr&&this instanceof i?n:r;return Mi(l,this,o)}return i}function Ni(r,e,t,n,i,a,o,u,f,c){var l=e&Cs,s=e&Ue,h=e&tn,y=e&(sr|Gr),w=e&Ns,S=h?void 0:Xr(r);function O(){for(var b=arguments.length,E=Array(b),d=b;d--;)E[d]=arguments[d];if(y)var I=Bi(O),T=u2(E,I);if(n&&(E=_2(E,n,i,y)),a&&(E=m2(E,a,o,y)),b-=T,y&&b<c){var F=Di(E,I);return Gs(r,e,Ni,O.placeholder,t,E,F,u,f,c-b)}var m=s?t:this,g=h?m[r]:r;return b=E.length,u?E=x2(E,u):w&&b>1&&E.reverse(),l&&f<b&&(E.length=f),this&&this!==Wr&&this instanceof O&&(g=S||Xr(g)),g.apply(m,E)}return O}function E2(r,e,t,n){var i=e&Ue,a=Xr(r);function o(){for(var u=-1,f=arguments.length,c=-1,l=n.length,s=Array(l+f),h=this&&this!==Wr&&this instanceof o?a:r;++c<l;)s[c]=n[c];for(;f--;)s[c++]=arguments[++u];return Mi(h,i?t:this,s)}return o}function Gs(r,e,t,n,i,a,o,u,f,c){var l=e&sr,s=l?o:void 0,h=l?void 0:o,y=l?a:void 0,w=l?void 0:a;e|=l?qe:Hr,e&=~(l?Hr:qe),e&CI||(e&=~(Ue|tn));var S=t(r,e,i,y,s,w,h,u,f,c);return S.placeholder=n,Ws(S,r,e)}function A2(r,e,t,n,i,a,o,u){var f=e&tn;if(!f&&typeof r!="function")throw new TypeError(DI);var c=n?n.length:0;if(c||(e&=~(qe|Hr),n=i=void 0),o=o===void 0?o:fr(Xs(o),0),u=u===void 0?u:Xs(u),c-=i?i.length:0,e&Hr){var l=n,s=i;n=i=void 0}var h=[r,e,t,n,i,l,s,a,o,u];if(r=h[0],e=h[1],t=h[2],n=h[3],i=h[4],u=h[9]=h[9]==null?f?0:r.length:fr(h[9]-c,0),!u&&e&(sr|Gr)&&(e&=~(sr|Gr)),!e||e==Ue)var y=b2(r,e,t);else e==sr||e==Gr?y=$2(r,e,u):(e==qe||e==(Ue|qe))&&!i.length?y=E2(r,e,t,n):y=Ni.apply(void 0,h);return Ws(y,r,e)}function Bi(r){var e=r;return e.placeholder}function Hs(r,e){var t=s2(r,e);return g2(t)?t:void 0}function S2(r){var e=r.match(WI);return e?e[1].split(XI):[]}function O2(r,e){var t=e.length,n=t-1;return e[n]=(t>1?"& ":"")+e[n],e=e.join(t>2?", ":" "),r.replace(HI,`{
24
+ */(function(e,t){typeof Qb=="function"&&r&&r.exports?r.exports=t():(e.dcodeIO=e.dcodeIO||{}).Long=t()})(U,function(){function e(l,s,h){this.low=l|0,this.high=s|0,this.unsigned=!!h}e.__isLong__,Object.defineProperty(e.prototype,"__isLong__",{value:!0,enumerable:!1,configurable:!1}),e.isLong=function(s){return(s&&s.__isLong__)===!0};var t={},n={};e.fromInt=function(s,h){var y,w;return h?(s=s>>>0,0<=s&&s<256&&(w=n[s],w)?w:(y=new e(s,(s|0)<0?-1:0,!0),0<=s&&s<256&&(n[s]=y),y)):(s=s|0,-128<=s&&s<128&&(w=t[s],w)?w:(y=new e(s,s<0?-1:0,!1),-128<=s&&s<128&&(t[s]=y),y))},e.fromNumber=function(s,h){return h=!!h,isNaN(s)||!isFinite(s)?e.ZERO:!h&&s<=-f?e.MIN_VALUE:!h&&s+1>=f?e.MAX_VALUE:h&&s>=u?e.MAX_UNSIGNED_VALUE:s<0?e.fromNumber(-s,h).negate():new e(s%o|0,s/o|0,h)},e.fromBits=function(s,h,y){return new e(s,h,y)},e.fromString=function(s,h,y){if(s.length===0)throw Error("number format error: empty string");if(s==="NaN"||s==="Infinity"||s==="+Infinity"||s==="-Infinity")return e.ZERO;if(typeof h=="number"&&(y=h,h=!1),y=y||10,y<2||36<y)throw Error("radix out of range: "+y);var w;if((w=s.indexOf("-"))>0)throw Error('number format error: interior "-" character: '+s);if(w===0)return e.fromString(s.substring(1),h,y).negate();for(var S=e.fromNumber(Math.pow(y,8)),O=e.ZERO,b=0;b<s.length;b+=8){var E=Math.min(8,s.length-b),d=parseInt(s.substring(b,b+E),y);if(E<8){var I=e.fromNumber(Math.pow(y,E));O=O.multiply(I).add(e.fromNumber(d))}else O=O.multiply(S),O=O.add(e.fromNumber(d))}return O.unsigned=h,O},e.fromValue=function(s){return s instanceof e?s:typeof s=="number"?e.fromNumber(s):typeof s=="string"?e.fromString(s):new e(s.low,s.high,s.unsigned)};var i=65536,a=1<<24,o=i*i,u=o*o,f=u/2,c=e.fromInt(a);return e.ZERO=e.fromInt(0),e.UZERO=e.fromInt(0,!0),e.ONE=e.fromInt(1),e.UONE=e.fromInt(1,!0),e.NEG_ONE=e.fromInt(-1),e.MAX_VALUE=e.fromBits(-1,2147483647,!1),e.MAX_UNSIGNED_VALUE=e.fromBits(-1,-1,!0),e.MIN_VALUE=e.fromBits(0,-2147483648,!1),e.prototype.toInt=function(){return this.unsigned?this.low>>>0:this.low},e.prototype.toNumber=function(){return this.unsigned?(this.high>>>0)*o+(this.low>>>0):this.high*o+(this.low>>>0)},e.prototype.toString=function(s){if(s=s||10,s<2||36<s)throw RangeError("radix out of range: "+s);if(this.isZero())return"0";var h;if(this.isNegative())if(this.equals(e.MIN_VALUE)){var y=e.fromNumber(s),w=this.divide(y);return h=w.multiply(y).subtract(this),w.toString(s)+h.toInt().toString(s)}else return"-"+this.negate().toString(s);var S=e.fromNumber(Math.pow(s,6),this.unsigned);h=this;for(var O="";;){var b=h.divide(S),E=h.subtract(b.multiply(S)).toInt()>>>0,d=E.toString(s);if(h=b,h.isZero())return d+O;for(;d.length<6;)d="0"+d;O=""+d+O}},e.prototype.getHighBits=function(){return this.high},e.prototype.getHighBitsUnsigned=function(){return this.high>>>0},e.prototype.getLowBits=function(){return this.low},e.prototype.getLowBitsUnsigned=function(){return this.low>>>0},e.prototype.getNumBitsAbs=function(){if(this.isNegative())return this.equals(e.MIN_VALUE)?64:this.negate().getNumBitsAbs();for(var s=this.high!=0?this.high:this.low,h=31;h>0&&!(s&1<<h);h--);return this.high!=0?h+33:h+1},e.prototype.isZero=function(){return this.high===0&&this.low===0},e.prototype.isNegative=function(){return!this.unsigned&&this.high<0},e.prototype.isPositive=function(){return this.unsigned||this.high>=0},e.prototype.isOdd=function(){return(this.low&1)===1},e.prototype.isEven=function(){return(this.low&1)===0},e.prototype.equals=function(s){return e.isLong(s)||(s=e.fromValue(s)),this.unsigned!==s.unsigned&&this.high>>>31===1&&s.high>>>31===1?!1:this.high===s.high&&this.low===s.low},e.eq=e.prototype.equals,e.prototype.notEquals=function(s){return!this.equals(s)},e.neq=e.prototype.notEquals,e.prototype.lessThan=function(s){return this.compare(s)<0},e.prototype.lt=e.prototype.lessThan,e.prototype.lessThanOrEqual=function(s){return this.compare(s)<=0},e.prototype.lte=e.prototype.lessThanOrEqual,e.prototype.greaterThan=function(s){return this.compare(s)>0},e.prototype.gt=e.prototype.greaterThan,e.prototype.greaterThanOrEqual=function(s){return this.compare(s)>=0},e.prototype.gte=e.prototype.greaterThanOrEqual,e.prototype.compare=function(s){if(e.isLong(s)||(s=e.fromValue(s)),this.equals(s))return 0;var h=this.isNegative(),y=s.isNegative();return h&&!y?-1:!h&&y?1:this.unsigned?s.high>>>0>this.high>>>0||s.high===this.high&&s.low>>>0>this.low>>>0?-1:1:this.subtract(s).isNegative()?-1:1},e.prototype.negate=function(){return!this.unsigned&&this.equals(e.MIN_VALUE)?e.MIN_VALUE:this.not().add(e.ONE)},e.prototype.neg=e.prototype.negate,e.prototype.add=function(s){e.isLong(s)||(s=e.fromValue(s));var h=this.high>>>16,y=this.high&65535,w=this.low>>>16,S=this.low&65535,O=s.high>>>16,b=s.high&65535,E=s.low>>>16,d=s.low&65535,I=0,T=0,F=0,m=0;return m+=S+d,F+=m>>>16,m&=65535,F+=w+E,T+=F>>>16,F&=65535,T+=y+b,I+=T>>>16,T&=65535,I+=h+O,I&=65535,e.fromBits(F<<16|m,I<<16|T,this.unsigned)},e.prototype.subtract=function(s){return e.isLong(s)||(s=e.fromValue(s)),this.add(s.negate())},e.prototype.sub=e.prototype.subtract,e.prototype.multiply=function(s){if(this.isZero()||(e.isLong(s)||(s=e.fromValue(s)),s.isZero()))return e.ZERO;if(this.equals(e.MIN_VALUE))return s.isOdd()?e.MIN_VALUE:e.ZERO;if(s.equals(e.MIN_VALUE))return this.isOdd()?e.MIN_VALUE:e.ZERO;if(this.isNegative())return s.isNegative()?this.negate().multiply(s.negate()):this.negate().multiply(s).negate();if(s.isNegative())return this.multiply(s.negate()).negate();if(this.lessThan(c)&&s.lessThan(c))return e.fromNumber(this.toNumber()*s.toNumber(),this.unsigned);var h=this.high>>>16,y=this.high&65535,w=this.low>>>16,S=this.low&65535,O=s.high>>>16,b=s.high&65535,E=s.low>>>16,d=s.low&65535,I=0,T=0,F=0,m=0;return m+=S*d,F+=m>>>16,m&=65535,F+=w*d,T+=F>>>16,F&=65535,F+=S*E,T+=F>>>16,F&=65535,T+=y*d,I+=T>>>16,T&=65535,T+=w*E,I+=T>>>16,T&=65535,T+=S*b,I+=T>>>16,T&=65535,I+=h*d+y*E+w*b+S*O,I&=65535,e.fromBits(F<<16|m,I<<16|T,this.unsigned)},e.prototype.mul=e.prototype.multiply,e.prototype.divide=function(s){if(e.isLong(s)||(s=e.fromValue(s)),s.isZero())throw new Error("division by zero");if(this.isZero())return this.unsigned?e.UZERO:e.ZERO;var h,y,w;if(this.equals(e.MIN_VALUE)){if(s.equals(e.ONE)||s.equals(e.NEG_ONE))return e.MIN_VALUE;if(s.equals(e.MIN_VALUE))return e.ONE;var S=this.shiftRight(1);return h=S.divide(s).shiftLeft(1),h.equals(e.ZERO)?s.isNegative()?e.ONE:e.NEG_ONE:(y=this.subtract(s.multiply(h)),w=h.add(y.divide(s)),w)}else if(s.equals(e.MIN_VALUE))return this.unsigned?e.UZERO:e.ZERO;if(this.isNegative())return s.isNegative()?this.negate().divide(s.negate()):this.negate().divide(s).negate();if(s.isNegative())return this.divide(s.negate()).negate();for(w=e.ZERO,y=this;y.greaterThanOrEqual(s);){h=Math.max(1,Math.floor(y.toNumber()/s.toNumber()));for(var O=Math.ceil(Math.log(h)/Math.LN2),b=O<=48?1:Math.pow(2,O-48),E=e.fromNumber(h),d=E.multiply(s);d.isNegative()||d.greaterThan(y);)h-=b,E=e.fromNumber(h,this.unsigned),d=E.multiply(s);E.isZero()&&(E=e.ONE),w=w.add(E),y=y.subtract(d)}return w},e.prototype.div=e.prototype.divide,e.prototype.modulo=function(s){return e.isLong(s)||(s=e.fromValue(s)),this.subtract(this.divide(s).multiply(s))},e.prototype.mod=e.prototype.modulo,e.prototype.not=function(){return e.fromBits(~this.low,~this.high,this.unsigned)},e.prototype.and=function(s){return e.isLong(s)||(s=e.fromValue(s)),e.fromBits(this.low&s.low,this.high&s.high,this.unsigned)},e.prototype.or=function(s){return e.isLong(s)||(s=e.fromValue(s)),e.fromBits(this.low|s.low,this.high|s.high,this.unsigned)},e.prototype.xor=function(s){return e.isLong(s)||(s=e.fromValue(s)),e.fromBits(this.low^s.low,this.high^s.high,this.unsigned)},e.prototype.shiftLeft=function(s){return e.isLong(s)&&(s=s.toInt()),(s&=63)===0?this:s<32?e.fromBits(this.low<<s,this.high<<s|this.low>>>32-s,this.unsigned):e.fromBits(0,this.low<<s-32,this.unsigned)},e.prototype.shl=e.prototype.shiftLeft,e.prototype.shiftRight=function(s){return e.isLong(s)&&(s=s.toInt()),(s&=63)===0?this:s<32?e.fromBits(this.low>>>s|this.high<<32-s,this.high>>s,this.unsigned):e.fromBits(this.high>>s-32,this.high>=0?0:-1,this.unsigned)},e.prototype.shr=e.prototype.shiftRight,e.prototype.shiftRightUnsigned=function(s){if(e.isLong(s)&&(s=s.toInt()),s&=63,s===0)return this;var h=this.high;if(s<32){var y=this.low;return e.fromBits(y>>>s|h<<32-s,h>>>s,this.unsigned)}else return s===32?e.fromBits(h,0,this.unsigned):e.fromBits(h>>>s-32,0,this.unsigned)},e.prototype.shru=e.prototype.shiftRightUnsigned,e.prototype.toSigned=function(){return this.unsigned?new e(this.low,this.high,!1):this},e.prototype.toUnsigned=function(){return this.unsigned?this:new e(this.low,this.high,!0)},e})})(hu);var du=hu.exports;Object.defineProperty(Rt,"__esModule",{value:!0}),Rt.Hyper=void 0;var e1=function(){function r(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(e,t,n){return t&&r(e.prototype,t),n&&r(e,n),e}}(),pu=function r(e,t,n){e===null&&(e=Function.prototype);var i=Object.getOwnPropertyDescriptor(e,t);if(i===void 0){var a=Object.getPrototypeOf(e);return a===null?void 0:r(a,t,n)}else{if("value"in i)return i.value;var o=i.get;return o===void 0?void 0:o.call(n)}},r1=du,Pr=yu(r1),t1=D,n1=yu(t1);function yu(r){return r&&r.__esModule?r:{default:r}}function i1(r,e){if(!(r instanceof e))throw new TypeError("Cannot call a class as a function")}function a1(r,e){if(!r)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e&&(typeof e=="object"||typeof e=="function")?e:r}function o1(r,e){if(typeof e!="function"&&e!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof e);r.prototype=Object.create(e&&e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(r,e):r.__proto__=e)}var xr=Rt.Hyper=function(r){o1(e,r),e1(e,null,[{key:"read",value:function(n){var i=n.readInt32BE(),a=n.readInt32BE();return this.fromBits(a,i)}},{key:"write",value:function(n,i){if(!(n instanceof this))throw new Error("XDR Write Error: "+n+" is not a Hyper");i.writeInt32BE(n.high),i.writeInt32BE(n.low)}},{key:"fromString",value:function(n){if(!/^-?\d+$/.test(n))throw new Error("Invalid hyper string: "+n);var i=pu(e.__proto__||Object.getPrototypeOf(e),"fromString",this).call(this,n,!1);return new this(i.low,i.high)}},{key:"fromBits",value:function(n,i){var a=pu(e.__proto__||Object.getPrototypeOf(e),"fromBits",this).call(this,n,i,!1);return new this(a.low,a.high)}},{key:"isValid",value:function(n){return n instanceof this}}]);function e(t,n){return i1(this,e),a1(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,t,n,!1))}return e}(Pr.default);(0,n1.default)(xr),xr.MAX_VALUE=new xr(Pr.default.MAX_VALUE.low,Pr.default.MAX_VALUE.high),xr.MIN_VALUE=new xr(Pr.default.MIN_VALUE.low,Pr.default.MIN_VALUE.high);var Ce={};Object.defineProperty(Ce,"__esModule",{value:!0}),Ce.UnsignedInt=void 0;var u1=gt,gu=vu(u1),s1=D,f1=vu(s1);function vu(r){return r&&r.__esModule?r:{default:r}}var Tr=Ce.UnsignedInt={read:function(e){return e.readUInt32BE()},write:function(e,t){if(!(0,gu.default)(e))throw new Error("XDR Write Error: not a number");if(Math.floor(e)!==e)throw new Error("XDR Write Error: not an integer");if(e<0)throw new Error("XDR Write Error: negative number "+e);t.writeUInt32BE(e)},isValid:function(e){return!(0,gu.default)(e)||Math.floor(e)!==e?!1:e>=Tr.MIN_VALUE&&e<=Tr.MAX_VALUE}};Tr.MAX_VALUE=Math.pow(2,32)-1,Tr.MIN_VALUE=0,(0,f1.default)(Tr);var Ft={};Object.defineProperty(Ft,"__esModule",{value:!0}),Ft.UnsignedHyper=void 0;var c1=function(){function r(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(e,t,n){return t&&r(e.prototype,t),n&&r(e,n),e}}(),_u=function r(e,t,n){e===null&&(e=Function.prototype);var i=Object.getOwnPropertyDescriptor(e,t);if(i===void 0){var a=Object.getPrototypeOf(e);return a===null?void 0:r(a,t,n)}else{if("value"in i)return i.value;var o=i.get;return o===void 0?void 0:o.call(n)}},l1=du,Rr=mu(l1),h1=D,d1=mu(h1);function mu(r){return r&&r.__esModule?r:{default:r}}function p1(r,e){if(!(r instanceof e))throw new TypeError("Cannot call a class as a function")}function y1(r,e){if(!r)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e&&(typeof e=="object"||typeof e=="function")?e:r}function g1(r,e){if(typeof e!="function"&&e!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof e);r.prototype=Object.create(e&&e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(r,e):r.__proto__=e)}var Fr=Ft.UnsignedHyper=function(r){g1(e,r),c1(e,null,[{key:"read",value:function(n){var i=n.readInt32BE(),a=n.readInt32BE();return this.fromBits(a,i)}},{key:"write",value:function(n,i){if(!(n instanceof this))throw new Error("XDR Write Error: "+n+" is not an UnsignedHyper");i.writeInt32BE(n.high),i.writeInt32BE(n.low)}},{key:"fromString",value:function(n){if(!/^\d+$/.test(n))throw new Error("Invalid hyper string: "+n);var i=_u(e.__proto__||Object.getPrototypeOf(e),"fromString",this).call(this,n,!0);return new this(i.low,i.high)}},{key:"fromBits",value:function(n,i){var a=_u(e.__proto__||Object.getPrototypeOf(e),"fromBits",this).call(this,n,i,!0);return new this(a.low,a.high)}},{key:"isValid",value:function(n){return n instanceof this}}]);function e(t,n){return p1(this,e),y1(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,t,n,!0))}return e}(Rr.default);(0,d1.default)(Fr),Fr.MAX_VALUE=new Fr(Rr.default.MAX_UNSIGNED_VALUE.low,Rr.default.MAX_UNSIGNED_VALUE.high),Fr.MIN_VALUE=new Fr(Rr.default.MIN_VALUE.low,Rr.default.MIN_VALUE.high);var Mt={};Object.defineProperty(Mt,"__esModule",{value:!0}),Mt.Float=void 0;var v1=gt,wu=bu(v1),_1=D,m1=bu(_1);function bu(r){return r&&r.__esModule?r:{default:r}}var w1=Mt.Float={read:function(e){return e.readFloatBE()},write:function(e,t){if(!(0,wu.default)(e))throw new Error("XDR Write Error: not a number");t.writeFloatBE(e)},isValid:function(e){return(0,wu.default)(e)}};(0,m1.default)(w1);var Dt={};Object.defineProperty(Dt,"__esModule",{value:!0}),Dt.Double=void 0;var b1=gt,$u=Eu(b1),$1=D,E1=Eu($1);function Eu(r){return r&&r.__esModule?r:{default:r}}var A1=Dt.Double={read:function(e){return e.readDoubleBE()},write:function(e,t){if(!(0,$u.default)(e))throw new Error("XDR Write Error: not a number");t.writeDoubleBE(e)},isValid:function(e){return(0,$u.default)(e)}};(0,E1.default)(A1);var Ct={};Object.defineProperty(Ct,"__esModule",{value:!0}),Ct.Quadruple=void 0;var S1=D,O1=I1(S1);function I1(r){return r&&r.__esModule?r:{default:r}}var P1=Ct.Quadruple={read:function(){throw new Error("XDR Read Error: quadruple not supported")},write:function(){throw new Error("XDR Write Error: quadruple not supported")},isValid:function(){return!1}};(0,O1.default)(P1);var Mr={},x1=ge,T1=ve,R1="[object Boolean]";function F1(r){return r===!0||r===!1||T1(r)&&x1(r)==R1}var M1=F1;Object.defineProperty(Mr,"__esModule",{value:!0}),Mr.Bool=void 0;var D1=M1,C1=Su(D1),Au=se,N1=D,B1=Su(N1);function Su(r){return r&&r.__esModule?r:{default:r}}var U1=Mr.Bool={read:function(e){var t=Au.Int.read(e);switch(t){case 0:return!1;case 1:return!0;default:throw new Error("XDR Read Error: Got "+t+" when trying to read a bool")}},write:function(e,t){var n=e?1:0;return Au.Int.write(n,t)},isValid:function(e){return(0,C1.default)(e)}};(0,B1.default)(U1);var Nt={},q1=ge,L1=V,k1=ve,j1="[object String]";function V1(r){return typeof r=="string"||!L1(r)&&k1(r)&&q1(r)==j1}var Ou=V1;Object.defineProperty(Nt,"__esModule",{value:!0}),Nt.String=void 0;var G1=function(){function r(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(e,t,n){return t&&r(e.prototype,t),n&&r(e,n),e}}(),H1=Ou,Iu=li(H1),W1=V,X1=li(W1),Pu=se,z1=Ce,xu=Me,Y1=D,K1=li(Y1);function li(r){return r&&r.__esModule?r:{default:r}}function Z1(r,e){if(!(r instanceof e))throw new TypeError("Cannot call a class as a function")}var J1=Nt.String=function(){function r(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:z1.UnsignedInt.MAX_VALUE;Z1(this,r),this._maxLength=e}return G1(r,[{key:"read",value:function(t){var n=Pu.Int.read(t);if(n>this._maxLength)throw new Error("XDR Read Error: Saw "+n+" length String,"+("max allowed is "+this._maxLength));var i=(0,xu.calculatePadding)(n),a=t.slice(n);return(0,xu.slicePadding)(t,i),a.buffer()}},{key:"readString",value:function(t){return this.read(t).toString("utf8")}},{key:"write",value:function(t,n){if(t.length>this._maxLength)throw new Error("XDR Write Error: Got "+t.length+" bytes,"+("max allows is "+this._maxLength));var i=void 0;(0,Iu.default)(t)?i=p.from(t,"utf8"):i=p.from(t),Pu.Int.write(i.length,n),n.writeBufferPadded(i)}},{key:"isValid",value:function(t){var n=void 0;if((0,Iu.default)(t))n=p.from(t,"utf8");else if((0,X1.default)(t)||p.isBuffer(t))n=p.from(t);else return!1;return n.length<=this._maxLength}}]),r}();(0,K1.default)(J1.prototype);var Bt={};Object.defineProperty(Bt,"__esModule",{value:!0}),Bt.Opaque=void 0;var Q1=function(){function r(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(e,t,n){return t&&r(e.prototype,t),n&&r(e,n),e}}(),Tu=Me,e$=D,r$=t$(e$);function t$(r){return r&&r.__esModule?r:{default:r}}function n$(r,e){if(!(r instanceof e))throw new TypeError("Cannot call a class as a function")}var i$=Bt.Opaque=function(){function r(e){n$(this,r),this._length=e,this._padding=(0,Tu.calculatePadding)(e)}return Q1(r,[{key:"read",value:function(t){var n=t.slice(this._length);return(0,Tu.slicePadding)(t,this._padding),n.buffer()}},{key:"write",value:function(t,n){if(t.length!==this._length)throw new Error("XDR Write Error: Got "+t.length+" bytes, expected "+this._length);n.writeBufferPadded(t)}},{key:"isValid",value:function(t){return p.isBuffer(t)&&t.length===this._length}}]),r}();(0,r$.default)(i$.prototype);var Ut={};Object.defineProperty(Ut,"__esModule",{value:!0}),Ut.VarOpaque=void 0;var a$=function(){function r(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(e,t,n){return t&&r(e.prototype,t),n&&r(e,n),e}}(),Ru=se,o$=Ce,Fu=Me,u$=D,s$=f$(u$);function f$(r){return r&&r.__esModule?r:{default:r}}function c$(r,e){if(!(r instanceof e))throw new TypeError("Cannot call a class as a function")}var l$=Ut.VarOpaque=function(){function r(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:o$.UnsignedInt.MAX_VALUE;c$(this,r),this._maxLength=e}return a$(r,[{key:"read",value:function(t){var n=Ru.Int.read(t);if(n>this._maxLength)throw new Error("XDR Read Error: Saw "+n+" length VarOpaque,"+("max allowed is "+this._maxLength));var i=(0,Fu.calculatePadding)(n),a=t.slice(n);return(0,Fu.slicePadding)(t,i),a.buffer()}},{key:"write",value:function(t,n){if(t.length>this._maxLength)throw new Error("XDR Write Error: Got "+t.length+" bytes,"+("max allows is "+this._maxLength));Ru.Int.write(t.length,n),n.writeBufferPadded(t)}},{key:"isValid",value:function(t){return p.isBuffer(t)&&t.length<=this._maxLength}}]),r}();(0,s$.default)(l$.prototype);var qt={};function h$(r,e){for(var t=-1,n=r==null?0:r.length;++t<n&&e(r[t],t,r)!==!1;);return r}var d$=h$,p$=_t;function y$(r){return typeof r=="function"?r:p$}var Mu=y$,g$=d$,v$=Kn,_$=Mu,m$=V;function w$(r,e){var t=m$(r)?g$:v$;return t(r,_$(e))}var b$=w$,nr=b$,$$=/\s/;function E$(r){for(var e=r.length;e--&&$$.test(r.charAt(e)););return e}var A$=E$,S$=A$,O$=/^\s+/;function I$(r){return r&&r.slice(0,S$(r)+1).replace(O$,"")}var P$=I$,x$=P$,Du=Ze,T$=xt,Cu=0/0,R$=/^[-+]0x[0-9a-f]+$/i,F$=/^0b[01]+$/i,M$=/^0o[0-7]+$/i,D$=parseInt;function C$(r){if(typeof r=="number")return r;if(T$(r))return Cu;if(Du(r)){var e=typeof r.valueOf=="function"?r.valueOf():r;r=Du(e)?e+"":e}if(typeof r!="string")return r===0?r:+r;r=x$(r);var t=F$.test(r);return t||M$.test(r)?D$(r.slice(2),t?2:8):R$.test(r)?Cu:+r}var N$=C$,B$=N$,Nu=1/0,U$=17976931348623157e292;function q$(r){if(!r)return r===0?r:0;if(r=B$(r),r===Nu||r===-Nu){var e=r<0?-1:1;return e*U$}return r===r?r:0}var L$=q$,k$=L$;function j$(r){var e=k$(r),t=e%1;return e===e?t?e-t:e:0}var V$=j$,G$=vo,H$=Mu,W$=V$,X$=9007199254740991,hi=4294967295,z$=Math.min;function Y$(r,e){if(r=W$(r),r<1||r>X$)return[];var t=hi,n=z$(r,hi);e=H$(e),r-=hi;for(var i=G$(n,e);++t<r;)e(t);return i}var Bu=Y$;Object.defineProperty(qt,"__esModule",{value:!0}),qt.Array=void 0;var K$=function(){function r(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(e,t,n){return t&&r(e.prototype,t),n&&r(e,n),e}}(),Z$=fi,J$=Dr(Z$),Q$=nr,eE=Dr(Q$),rE=Bu,tE=Dr(rE),nE=V,Uu=Dr(nE),iE=D,aE=Dr(iE);function Dr(r){return r&&r.__esModule?r:{default:r}}function oE(r,e){if(!(r instanceof e))throw new TypeError("Cannot call a class as a function")}var uE=qt.Array=function(){function r(e,t){oE(this,r),this._childType=e,this._length=t}return K$(r,[{key:"read",value:function(t){var n=this;return(0,tE.default)(this._length,function(){return n._childType.read(t)})}},{key:"write",value:function(t,n){var i=this;if(!(0,Uu.default)(t))throw new Error("XDR Write Error: value is not array");if(t.length!==this._length)throw new Error("XDR Write Error: Got array of size "+t.length+","+("expected "+this._length));(0,eE.default)(t,function(a){return i._childType.write(a,n)})}},{key:"isValid",value:function(t){var n=this;return!(0,Uu.default)(t)||t.length!==this._length?!1:(0,J$.default)(t,function(i){return n._childType.isValid(i)})}}]),r}();(0,aE.default)(uE.prototype);var Lt={};Object.defineProperty(Lt,"__esModule",{value:!0}),Lt.VarArray=void 0;var sE=function(){function r(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(e,t,n){return t&&r(e.prototype,t),n&&r(e,n),e}}(),fE=fi,cE=Cr(fE),lE=nr,hE=Cr(lE),dE=Bu,pE=Cr(dE),yE=V,qu=Cr(yE),gE=Ce,Lu=se,vE=D,_E=Cr(vE);function Cr(r){return r&&r.__esModule?r:{default:r}}function mE(r,e){if(!(r instanceof e))throw new TypeError("Cannot call a class as a function")}var wE=Lt.VarArray=function(){function r(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:gE.UnsignedInt.MAX_VALUE;mE(this,r),this._childType=e,this._maxLength=t}return sE(r,[{key:"read",value:function(t){var n=this,i=Lu.Int.read(t);if(i>this._maxLength)throw new Error("XDR Read Error: Saw "+i+" length VarArray,"+("max allowed is "+this._maxLength));return(0,pE.default)(i,function(){return n._childType.read(t)})}},{key:"write",value:function(t,n){var i=this;if(!(0,qu.default)(t))throw new Error("XDR Write Error: value is not array");if(t.length>this._maxLength)throw new Error("XDR Write Error: Got array of size "+t.length+","+("max allowed is "+this._maxLength));Lu.Int.write(t.length,n),(0,hE.default)(t,function(a){return i._childType.write(a,n)})}},{key:"isValid",value:function(t){var n=this;return!(0,qu.default)(t)||t.length>this._maxLength?!1:(0,cE.default)(t,function(i){return n._childType.isValid(i)})}}]),r}();(0,_E.default)(wE.prototype);var kt={};function bE(r){return r===null}var $E=bE;function EE(r){return r===void 0}var Nr=EE;Object.defineProperty(kt,"__esModule",{value:!0}),kt.Option=void 0;var AE=function(){function r(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(e,t,n){return t&&r(e.prototype,t),n&&r(e,n),e}}(),SE=$E,ku=di(SE),OE=Nr,ju=di(OE),Vu=Mr,IE=D,PE=di(IE);function di(r){return r&&r.__esModule?r:{default:r}}function xE(r,e){if(!(r instanceof e))throw new TypeError("Cannot call a class as a function")}var TE=kt.Option=function(){function r(e){xE(this,r),this._childType=e}return AE(r,[{key:"read",value:function(t){if(Vu.Bool.read(t))return this._childType.read(t)}},{key:"write",value:function(t,n){var i=!((0,ku.default)(t)||(0,ju.default)(t));Vu.Bool.write(i,n),i&&this._childType.write(t,n)}},{key:"isValid",value:function(t){return(0,ku.default)(t)||(0,ju.default)(t)?!0:this._childType.isValid(t)}}]),r}();(0,PE.default)(TE.prototype);var Br={};Object.defineProperty(Br,"__esModule",{value:!0}),Br.Void=void 0;var RE=Nr,Gu=Hu(RE),FE=D,ME=Hu(FE);function Hu(r){return r&&r.__esModule?r:{default:r}}var DE=Br.Void={read:function(){},write:function(e){if(!(0,Gu.default)(e))throw new Error("XDR Write Error: trying to write value to a void slot")},isValid:function(e){return(0,Gu.default)(e)}};(0,ME.default)(DE);var jt={},CE=si;function NE(r,e){return CE(e,function(t){return r[t]})}var BE=NE,UE=BE,qE=$t;function LE(r){return r==null?[]:UE(r,qE(r))}var kE=LE;Object.defineProperty(jt,"__esModule",{value:!0}),jt.Enum=void 0;var jE=function(){function r(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(e,t,n){return t&&r(e.prototype,t),n&&r(e,n),e}}(),VE=nr,GE=pi(VE),HE=kE,WE=pi(HE),Wu=se,XE=D,zE=pi(XE);function pi(r){return r&&r.__esModule?r:{default:r}}function YE(r,e){if(!r)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e&&(typeof e=="object"||typeof e=="function")?e:r}function KE(r,e){if(typeof e!="function"&&e!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof e);r.prototype=Object.create(e&&e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(r,e):r.__proto__=e)}function Xu(r,e){if(!(r instanceof e))throw new TypeError("Cannot call a class as a function")}var ZE=jt.Enum=function(){function r(e,t){Xu(this,r),this.name=e,this.value=t}return jE(r,null,[{key:"read",value:function(t){var n=Wu.Int.read(t);if(!this._byValue.has(n))throw new Error("XDR Read Error: Unknown "+this.enumName+" member for value "+n);return this._byValue.get(n)}},{key:"write",value:function(t,n){if(!(t instanceof this))throw new Error("XDR Write Error: Unknown "+t+" is not a "+this.enumName);Wu.Int.write(t.value,n)}},{key:"isValid",value:function(t){return t instanceof this}},{key:"members",value:function(){return this._members}},{key:"values",value:function(){return(0,WE.default)(this._members)}},{key:"fromName",value:function(t){var n=this._members[t];if(!n)throw new Error(t+" is not a member of "+this.enumName);return n}},{key:"fromValue",value:function(t){var n=this._byValue.get(t);if(!n)throw new Error(t+" is not a value of any member of "+this.enumName);return n}},{key:"create",value:function(t,n,i){var a=function(o){KE(u,o);function u(){return Xu(this,u),YE(this,(u.__proto__||Object.getPrototypeOf(u)).apply(this,arguments))}return u}(r);return a.enumName=n,t.results[n]=a,a._members={},a._byValue=new Map,(0,GE.default)(i,function(o,u){var f=new a(u,o);a._members[u]=f,a._byValue.set(o,f),a[u]=function(){return f}}),a}}]),r}();(0,zE.default)(ZE);var Vt={},JE=Kn,QE=Or;function eA(r,e){var t=-1,n=QE(r)?Array(r.length):[];return JE(r,function(i,a,o){n[++t]=e(i,a,o)}),n}var rA=eA,tA=si,nA=ou,iA=rA,aA=V;function oA(r,e){var t=aA(r)?tA:iA;return t(r,nA(e))}var uA=oA;function sA(r){for(var e=-1,t=r==null?0:r.length,n={};++e<t;){var i=r[e];n[i[0]]=i[1]}return n}var fA=sA,Ur={};Object.defineProperty(Ur,"__esModule",{value:!0});var cA=function(){function r(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(e,t,n){return t&&r(e.prototype,t),n&&r(e,n),e}}();function lA(r,e){if(!(r instanceof e))throw new TypeError("Cannot call a class as a function")}Ur.Reference=function(){function r(){lA(this,r)}return cA(r,[{key:"resolve",value:function(){throw new Error("implement resolve in child class")}}]),r}(),Object.defineProperty(Vt,"__esModule",{value:!0}),Vt.Struct=void 0;var Gt=function(){function r(e,t){var n=[],i=!0,a=!1,o=void 0;try{for(var u=e[Symbol.iterator](),f;!(i=(f=u.next()).done)&&(n.push(f.value),!(t&&n.length===t));i=!0);}catch(c){a=!0,o=c}finally{try{!i&&u.return&&u.return()}finally{if(a)throw o}}return n}return function(e,t){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e))return r(e,t);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),hA=function(){function r(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(e,t,n){return t&&r(e.prototype,t),n&&r(e,n),e}}(),dA=nr,zu=qr(dA),pA=uA,yA=qr(pA),gA=Nr,vA=qr(gA),_A=fA,mA=qr(_A),wA=Ur,bA=D,$A=qr(bA);function qr(r){return r&&r.__esModule?r:{default:r}}function EA(r,e){if(!r)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e&&(typeof e=="object"||typeof e=="function")?e:r}function AA(r,e){if(typeof e!="function"&&e!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof e);r.prototype=Object.create(e&&e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(r,e):r.__proto__=e)}function Yu(r,e){if(!(r instanceof e))throw new TypeError("Cannot call a class as a function")}var SA=Vt.Struct=function(){function r(e){Yu(this,r),this._attributes=e||{}}return hA(r,null,[{key:"read",value:function(t){var n=(0,yA.default)(this._fields,function(i){var a=Gt(i,2),o=a[0],u=a[1],f=u.read(t);return[o,f]});return new this((0,mA.default)(n))}},{key:"write",value:function(t,n){if(!(t instanceof this))throw new Error("XDR Write Error: "+t+" is not a "+this.structName);(0,zu.default)(this._fields,function(i){var a=Gt(i,2),o=a[0],u=a[1],f=t._attributes[o];u.write(f,n)})}},{key:"isValid",value:function(t){return t instanceof this}},{key:"create",value:function(t,n,i){var a=function(o){AA(u,o);function u(){return Yu(this,u),EA(this,(u.__proto__||Object.getPrototypeOf(u)).apply(this,arguments))}return u}(r);return a.structName=n,t.results[n]=a,a._fields=i.map(function(o){var u=Gt(o,2),f=u[0],c=u[1];return c instanceof wA.Reference&&(c=c.resolve(t)),[f,c]}),(0,zu.default)(a._fields,function(o){var u=Gt(o,1),f=u[0];a.prototype[f]=OA(f)}),a}}]),r}();(0,$A.default)(SA);function OA(r){return function(t){return(0,vA.default)(t)||(this._attributes[r]=t),this._attributes[r]}}var Ht={};Object.defineProperty(Ht,"__esModule",{value:!0}),Ht.Union=void 0;var IA=function(){function r(e,t){var n=[],i=!0,a=!1,o=void 0;try{for(var u=e[Symbol.iterator](),f;!(i=(f=u.next()).done)&&(n.push(f.value),!(t&&n.length===t));i=!0);}catch(c){a=!0,o=c}finally{try{!i&&u.return&&u.return()}finally{if(a)throw o}}return n}return function(e,t){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e))return r(e,t);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),PA=function(){function r(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(e,t,n){return t&&r(e.prototype,t),n&&r(e,n),e}}(),xA=nr,Wt=zt(xA),TA=Nr,Ku=zt(TA),RA=Ou,Zu=zt(RA),Xt=Br,yi=Ur,FA=D,MA=zt(FA);function zt(r){return r&&r.__esModule?r:{default:r}}function DA(r,e){if(!r)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e&&(typeof e=="object"||typeof e=="function")?e:r}function CA(r,e){if(typeof e!="function"&&e!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof e);r.prototype=Object.create(e&&e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(r,e):r.__proto__=e)}function Ju(r,e){if(!(r instanceof e))throw new TypeError("Cannot call a class as a function")}var NA=Ht.Union=function(){function r(e,t){Ju(this,r),this.set(e,t)}return PA(r,[{key:"set",value:function(t,n){(0,Zu.default)(t)&&(t=this.constructor._switchOn.fromName(t)),this._switch=t,this._arm=this.constructor.armForSwitch(this._switch),this._armType=this.constructor.armTypeForArm(this._arm),this._value=n}},{key:"get",value:function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this._arm;if(this._arm!==Xt.Void&&this._arm!==t)throw new Error(t+" not set");return this._value}},{key:"switch",value:function(){return this._switch}},{key:"arm",value:function(){return this._arm}},{key:"armType",value:function(){return this._armType}},{key:"value",value:function(){return this._value}}],[{key:"armForSwitch",value:function(t){if(this._switches.has(t))return this._switches.get(t);if(this._defaultArm)return this._defaultArm;throw new Error("Bad union switch: "+t)}},{key:"armTypeForArm",value:function(t){return t===Xt.Void?Xt.Void:this._arms[t]}},{key:"read",value:function(t){var n=this._switchOn.read(t),i=this.armForSwitch(n),a=this.armTypeForArm(i),o=void 0;return(0,Ku.default)(a)?o=i.read(t):o=a.read(t),new this(n,o)}},{key:"write",value:function(t,n){if(!(t instanceof this))throw new Error("XDR Write Error: "+t+" is not a "+this.unionName);this._switchOn.write(t.switch(),n),t.armType().write(t.value(),n)}},{key:"isValid",value:function(t){return t instanceof this}},{key:"create",value:function(t,n,i){var a=function(u){CA(f,u);function f(){return Ju(this,f),DA(this,(f.__proto__||Object.getPrototypeOf(f)).apply(this,arguments))}return f}(r);a.unionName=n,t.results[n]=a,i.switchOn instanceof yi.Reference?a._switchOn=i.switchOn.resolve(t):a._switchOn=i.switchOn,a._switches=new Map,a._arms={},(0,Wt.default)(i.arms,function(u,f){u instanceof yi.Reference&&(u=u.resolve(t)),a._arms[f]=u});var o=i.defaultArm;return o instanceof yi.Reference&&(o=o.resolve(t)),a._defaultArm=o,(0,Wt.default)(i.switches,function(u){var f=IA(u,2),c=f[0],l=f[1];(0,Zu.default)(c)&&(c=a._switchOn.fromName(c)),a._switches.set(c,l)}),(0,Ku.default)(a._switchOn.values)||(0,Wt.default)(a._switchOn.values(),function(u){a[u.name]=function(f){return new a(u,f)},a.prototype[u.name]=function(c){return this.set(u,c)}}),(0,Wt.default)(a._arms,function(u,f){u!==Xt.Void&&(a.prototype[f]=function(){return this.get(f)})}),a}}]),r}();(0,MA.default)(NA),function(r){Object.defineProperty(r,"__esModule",{value:!0});var e=se;Object.keys(e).forEach(function(d){d==="default"||d==="__esModule"||Object.defineProperty(r,d,{enumerable:!0,get:function(){return e[d]}})});var t=Rt;Object.keys(t).forEach(function(d){d==="default"||d==="__esModule"||Object.defineProperty(r,d,{enumerable:!0,get:function(){return t[d]}})});var n=Ce;Object.keys(n).forEach(function(d){d==="default"||d==="__esModule"||Object.defineProperty(r,d,{enumerable:!0,get:function(){return n[d]}})});var i=Ft;Object.keys(i).forEach(function(d){d==="default"||d==="__esModule"||Object.defineProperty(r,d,{enumerable:!0,get:function(){return i[d]}})});var a=Mt;Object.keys(a).forEach(function(d){d==="default"||d==="__esModule"||Object.defineProperty(r,d,{enumerable:!0,get:function(){return a[d]}})});var o=Dt;Object.keys(o).forEach(function(d){d==="default"||d==="__esModule"||Object.defineProperty(r,d,{enumerable:!0,get:function(){return o[d]}})});var u=Ct;Object.keys(u).forEach(function(d){d==="default"||d==="__esModule"||Object.defineProperty(r,d,{enumerable:!0,get:function(){return u[d]}})});var f=Mr;Object.keys(f).forEach(function(d){d==="default"||d==="__esModule"||Object.defineProperty(r,d,{enumerable:!0,get:function(){return f[d]}})});var c=Nt;Object.keys(c).forEach(function(d){d==="default"||d==="__esModule"||Object.defineProperty(r,d,{enumerable:!0,get:function(){return c[d]}})});var l=Bt;Object.keys(l).forEach(function(d){d==="default"||d==="__esModule"||Object.defineProperty(r,d,{enumerable:!0,get:function(){return l[d]}})});var s=Ut;Object.keys(s).forEach(function(d){d==="default"||d==="__esModule"||Object.defineProperty(r,d,{enumerable:!0,get:function(){return s[d]}})});var h=qt;Object.keys(h).forEach(function(d){d==="default"||d==="__esModule"||Object.defineProperty(r,d,{enumerable:!0,get:function(){return h[d]}})});var y=Lt;Object.keys(y).forEach(function(d){d==="default"||d==="__esModule"||Object.defineProperty(r,d,{enumerable:!0,get:function(){return y[d]}})});var w=kt;Object.keys(w).forEach(function(d){d==="default"||d==="__esModule"||Object.defineProperty(r,d,{enumerable:!0,get:function(){return w[d]}})});var S=Br;Object.keys(S).forEach(function(d){d==="default"||d==="__esModule"||Object.defineProperty(r,d,{enumerable:!0,get:function(){return S[d]}})});var O=jt;Object.keys(O).forEach(function(d){d==="default"||d==="__esModule"||Object.defineProperty(r,d,{enumerable:!0,get:function(){return O[d]}})});var b=Vt;Object.keys(b).forEach(function(d){d==="default"||d==="__esModule"||Object.defineProperty(r,d,{enumerable:!0,get:function(){return b[d]}})});var E=Ht;Object.keys(E).forEach(function(d){d==="default"||d==="__esModule"||Object.defineProperty(r,d,{enumerable:!0,get:function(){return E[d]}})})}(Hn);var Qu={};(function(r){Object.defineProperty(r,"__esModule",{value:!0});var e=function(){function m(g,v){for(var A=0;A<v.length;A++){var P=v[A];P.enumerable=P.enumerable||!1,P.configurable=!0,"value"in P&&(P.writable=!0),Object.defineProperty(g,P.key,P)}}return function(g,v,A){return v&&m(g.prototype,v),A&&m(g,A),g}}(),t=Ur;Object.keys(t).forEach(function(m){m==="default"||m==="__esModule"||Object.defineProperty(r,m,{enumerable:!0,get:function(){return t[m]}})}),r.config=w;var n=Nr,i=l(n),a=nr,o=l(a),u=Hn,f=c(u);function c(m){if(m&&m.__esModule)return m;var g={};if(m!=null)for(var v in m)Object.prototype.hasOwnProperty.call(m,v)&&(g[v]=m[v]);return g.default=m,g}function l(m){return m&&m.__esModule?m:{default:m}}function s(m,g){if(!(m instanceof g))throw new TypeError("Cannot call a class as a function")}function h(m,g){if(!m)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return g&&(typeof g=="object"||typeof g=="function")?g:m}function y(m,g){if(typeof g!="function"&&g!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof g);m.prototype=Object.create(g&&g.prototype,{constructor:{value:m,enumerable:!1,writable:!0,configurable:!0}}),g&&(Object.setPrototypeOf?Object.setPrototypeOf(m,g):m.__proto__=g)}function w(m){var g=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(m){var v=new F(g);m(v),v.resolve()}return g}var S=function(m){y(g,m);function g(v){s(this,g);var A=h(this,(g.__proto__||Object.getPrototypeOf(g)).call(this));return A.name=v,A}return e(g,[{key:"resolve",value:function(A){var P=A.definitions[this.name];return P.resolve(A)}}]),g}(t.Reference),O=function(m){y(g,m);function g(v,A){var P=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;s(this,g);var M=h(this,(g.__proto__||Object.getPrototypeOf(g)).call(this));return M.childReference=v,M.length=A,M.variable=P,M}return e(g,[{key:"resolve",value:function(A){var P=this.childReference,M=this.length;return P instanceof t.Reference&&(P=P.resolve(A)),M instanceof t.Reference&&(M=M.resolve(A)),this.variable?new f.VarArray(P,M):new f.Array(P,M)}}]),g}(t.Reference),b=function(m){y(g,m);function g(v){s(this,g);var A=h(this,(g.__proto__||Object.getPrototypeOf(g)).call(this));return A.childReference=v,A.name=v.name,A}return e(g,[{key:"resolve",value:function(A){var P=this.childReference;return P instanceof t.Reference&&(P=P.resolve(A)),new f.Option(P)}}]),g}(t.Reference),E=function(m){y(g,m);function g(v,A){s(this,g);var P=h(this,(g.__proto__||Object.getPrototypeOf(g)).call(this));return P.sizedType=v,P.length=A,P}return e(g,[{key:"resolve",value:function(A){var P=this.length;return P instanceof t.Reference&&(P=P.resolve(A)),new this.sizedType(P)}}]),g}(t.Reference),d=function(){function m(g,v,A){s(this,m),this.constructor=g,this.name=v,this.config=A}return e(m,[{key:"resolve",value:function(v){return this.name in v.results?v.results[this.name]:this.constructor(v,this.name,this.config)}}]),m}();function I(m,g,v){return v instanceof t.Reference&&(v=v.resolve(m)),m.results[g]=v,v}function T(m,g,v){return m.results[g]=v,v}var F=function(){function m(g){s(this,m),this._destination=g,this._definitions={}}return e(m,[{key:"enum",value:function(v,A){var P=new d(f.Enum.create,v,A);this.define(v,P)}},{key:"struct",value:function(v,A){var P=new d(f.Struct.create,v,A);this.define(v,P)}},{key:"union",value:function(v,A){var P=new d(f.Union.create,v,A);this.define(v,P)}},{key:"typedef",value:function(v,A){var P=new d(I,v,A);this.define(v,P)}},{key:"const",value:function(v,A){var P=new d(T,v,A);this.define(v,P)}},{key:"void",value:function(){return f.Void}},{key:"bool",value:function(){return f.Bool}},{key:"int",value:function(){return f.Int}},{key:"hyper",value:function(){return f.Hyper}},{key:"uint",value:function(){return f.UnsignedInt}},{key:"uhyper",value:function(){return f.UnsignedHyper}},{key:"float",value:function(){return f.Float}},{key:"double",value:function(){return f.Double}},{key:"quadruple",value:function(){return f.Quadruple}},{key:"string",value:function(v){return new E(f.String,v)}},{key:"opaque",value:function(v){return new E(f.Opaque,v)}},{key:"varOpaque",value:function(v){return new E(f.VarOpaque,v)}},{key:"array",value:function(v,A){return new O(v,A)}},{key:"varArray",value:function(v,A){return new O(v,A,!0)}},{key:"option",value:function(v){return new b(v)}},{key:"define",value:function(v,A){if((0,i.default)(this._destination[v]))this._definitions[v]=A;else throw new Error("XDRTypes Error:"+v+" is already defined")}},{key:"lookup",value:function(v){return new S(v)}},{key:"resolve",value:function(){var v=this;(0,o.default)(this._definitions,function(A){A.resolve({definitions:v._definitions,results:v._destination})})}}]),m}()})(Qu),function(r){Object.defineProperty(r,"__esModule",{value:!0});var e=Hn;Object.keys(e).forEach(function(n){n==="default"||n==="__esModule"||Object.defineProperty(r,n,{enumerable:!0,get:function(){return e[n]}})});var t=Qu;Object.keys(t).forEach(function(n){n==="default"||n==="__esModule"||Object.defineProperty(r,n,{enumerable:!0,get:function(){return t[n]}})})}(to);var gi=(r,e,t)=>{if(!e.has(r))throw TypeError("Cannot "+t)},j=(r,e,t)=>(gi(r,e,"read from private field"),t?t.call(r):e.get(r)),Ne=(r,e,t)=>{if(e.has(r))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(r):e.set(r,t)},vi=(r,e,t,n)=>(gi(r,e,"write to private field"),n?n.call(r,t):e.set(r,t),t),_e=(r,e,t)=>(gi(r,e,"access private method"),t),te,ne,Lr,_i,es,mi,rs,Yt,wi,ir,kr;function BA(r){const e={variantId:ce.Uint64.fromString(r.variantId.toString()),version:r.version||Math.floor(Date.now()/1e3),items:r.items.map(n=>new ce.BundleItem({collectionId:ce.Uint64.fromString(n.collectionId.toString()),productId:ce.Uint64.fromString(n.productId.toString()),variantId:ce.Uint64.fromString(n.variantId.toString()),sku:n.sku||"",quantity:n.quantity,ext:new ce.BundleItemExt(0)})),ext:new ce.BundleExt(0)},t=new ce.Bundle(e);return ce.BundleEnvelope.envelopeTypeBundle(t).toXDR("base64")}const ce=to.config(r=>{r.enum("EnvelopeType",{envelopeTypeBundle:0}),r.typedef("Uint32",r.uint()),r.typedef("Uint64",r.uhyper()),r.union("BundleItemExt",{switchOn:r.int(),switchName:"v",switches:[[0,r.void()]],arms:{}}),r.struct("BundleItem",[["collectionId",r.lookup("Uint64")],["productId",r.lookup("Uint64")],["variantId",r.lookup("Uint64")],["sku",r.string()],["quantity",r.lookup("Uint32")],["ext",r.lookup("BundleItemExt")]]),r.union("BundleExt",{switchOn:r.int(),switchName:"v",switches:[[0,r.void()]],arms:{}}),r.struct("Bundle",[["variantId",r.lookup("Uint64")],["items",r.varArray(r.lookup("BundleItem"),500)],["version",r.lookup("Uint32")],["ext",r.lookup("BundleExt")]]),r.union("BundleEnvelope",{switchOn:r.lookup("EnvelopeType"),switchName:"type",switches:[["envelopeTypeBundle","v1"]],arms:{v1:r.lookup("Bundle")}})});class UA{constructor(e,t){Ne(this,_i),Ne(this,mi),Ne(this,Yt),Ne(this,ir),Ne(this,te,void 0),Ne(this,ne,void 0),Ne(this,Lr,void 0),vi(this,te,_e(this,_i,es).call(this,t)),vi(this,Lr,_e(this,mi,rs).call(this,t)),vi(this,ne,e)}isInitialDataValid(){if(!j(this,Lr))throw"Bundle data does not exist for the given product.";if(!j(this,te))throw"Bundle settings do not exist for the given product.";if(!Array.isArray(j(this,ne))||!j(this,ne).length)throw"No bundle selection items provided.";return!0}isValidVariant(e){if(!j(this,te)?.variantsSettings[e])throw`The ${e} bundle variant is invalid.`;return!0}isSelectionInVariantRange(e){const t=j(this,ne).reduce((i,a)=>i+a.quantity,0),n=j(this,te)?.variantsSettings[e].ranges||[];if(!_e(this,Yt,wi).call(this,n,t))throw"The total number of products does not fall within the required variant range.";return!0}areItemsInMaxPerItemBound(){const e=j(this,te)?.bundleSettings.maxPerItem||0,t=j(this,ne).filter(({quantity:n})=>n>e);if(e&&t.length)throw`The selected products (${_e(this,ir,kr).call(this,t.map(({externalProductId:n})=>n)).join(", ")}) exceed the maximum limit of ${e} items per product.`;return!0}areSelectedCollectionsValid(e){const t=j(this,te)?.variantsSettings[e],n=j(this,ne).filter(({collectionId:i})=>!t?.optionSources[i]);if(n.length)throw`The collections (${_e(this,ir,kr).call(this,n.map(({collectionId:i})=>i)).join(", ")}) are no longer valid for the bundle variant (${e}).`;return!0}areItemsQuantitiesValidForTheCollection(e){const t=j(this,ne).reduce((a,o)=>(a[o.collectionId]=o.quantity+(a[o.collectionId]||0),a),{}),n=j(this,te)?.variantsSettings[e],i=Object.values(n?.optionSources||{}).filter(a=>{const o=t[a.collectionId]||0;return!_e(this,Yt,wi).call(this,[a],o)});if(!n||i.length)throw`The selection exceeds the limits for the collections (${_e(this,ir,kr).call(this,i.map(({collectionId:a})=>a)).join(", ")}).`;return!0}areSelectedProductsValid(e){const t=j(this,te)?.variantsSettings[e]?.optionSources||{},n=Object.values(t).reduce((a,o)=>{const u=j(this,Lr)?.collections[o.collectionId];return u&&(a[o.collectionId]=u),a},{});if(!Object.values(n).length)throw`No collections found for the bundle variant (${e}).`;const i=j(this,ne).filter(({externalProductId:a,collectionId:o})=>!n[o]?.products[a]);if(i.length)throw`The products (${_e(this,ir,kr).call(this,i.map(({externalProductId:a})=>a)).join(", ")}) are no longer valid for the bundle product.`;return!0}isBundleSelectionValid(e){return this.isInitialDataValid(),this.isValidVariant(e),this.isSelectionInVariantRange(e),this.areItemsInMaxPerItemBound(),this.areSelectedCollectionsValid(e),this.areItemsQuantitiesValidForTheCollection(e),this.areSelectedProductsValid(e),!0}}te=new WeakMap,ne=new WeakMap,Lr=new WeakMap,_i=new WeakSet,es=function(r){try{const e=r.bundle_settings;return{bundleSettings:{maxPerItem:e.max_quantity_per_variant,isCustomizable:e.is_customizable},variantsSettings:e.variants.reduce((t,n)=>{if(!n.enabled)return t;let i=[{min:n.items_count,max:n.items_count}];return n.items_count||(i=n.ranges.map(({quantity_max:a,quantity_min:o})=>({min:o,max:a}))),t[n.external_variant_id]={externalVariantId:n.external_variant_id,optionSources:n.option_sources.reduce((a,o)=>(a[o.option_source_id]={min:o.quantity_min,max:o.quantity_max,collectionId:o.option_source_id},a),{}),ranges:i},t},{})}}catch{return null}},mi=new WeakSet,rs=function(r){try{const e=Object.values(r.collections).reduce((t,n)=>(t[n.id]={...n,products:n.products.reduce((i,a)=>(i[a.id]=a,i),{})},t),{});return{...r,collections:e}}catch{return null}},Yt=new WeakSet,wi=function(r,e){return!!r.filter(({min:t,max:n})=>{const i=t??e,a=n??e;return i<=e&&e<=a}).length},ir=new WeakSet,kr=function(r){return Array.from(new Set(r))};const ts="/bundling-storefront-manager";function ns(){return Math.ceil(Date.now()/1e3)}async function qA(){try{const{timestamp:r}=await Ke("get",`${ts}/t`);return r}catch(r){return console.error(`Fetch failed: ${r}. Using client-side date.`),ns()}}async function LA(r){try{const{timestamp:e}=await $("get","/bundle_selections/timestamp",{},r);return e}catch(e){return console.error(`Fetch failed: ${e}. Using client-side date.`),ns()}}function is(r,e){return BA({variantId:r.externalVariantId,version:e,items:r.selections.map(t=>({collectionId:t.collectionId,productId:t.externalProductId,variantId:t.externalVariantId,quantity:t.quantity,sku:""}))})}async function kA(r){const e=W(),t=await bi(r);if(t!==!0)throw new Error(t);const n=await qA(),i=is(r,n);try{const a=await Ke("post",`${ts}/api/v1/bundles`,{data:{bundle:i},headers:{Origin:`https://${e.storeIdentifier}`}});if(!a.id||a.code!==200)throw new Error(`1: failed generating rb_id: ${JSON.stringify(a)}`);return a.id}catch(a){throw new Error(`2: failed generating rb_id ${a}`)}}async function jA(r,e){const t=await bi(e);if(t!==!0)throw new Error(t);const n=_(r,"getBundleSelectionId"),i=await LA(n),a=is(e,i);try{const o=await $("post","/bundle_selections/bundle_id",{data:{bundle:a}},n);if(!o.id||o.code!==200)throw new Error(`1: failed generating rb_id: ${JSON.stringify(o)}`);return o.id}catch(o){throw new Error(`2: failed generating rb_id ${o}`)}}function VA(r,e){const t=as(r);if(t!==!0)throw new Error(`Dynamic Bundle is invalid. ${t}`);const n=`${Vi(9)}:${r.externalProductId}`;return r.selections.map(i=>{const a={id:i.externalVariantId,quantity:i.quantity,properties:{_rc_bundle:n,_rc_bundle_variant:r.externalVariantId,_rc_bundle_parent:e,_rc_bundle_collection_id:i.collectionId}};return i.sellingPlan?a.selling_plan=i.sellingPlan:i.shippingIntervalFrequency&&(a.properties.shipping_interval_frequency=i.shippingIntervalFrequency,a.properties.shipping_interval_unit_type=i.shippingIntervalUnitType,a.id=`${i.discountedVariantId}`),a})}async function bi(r){try{return r?r.selections.length===0?"No selections defined":!0:"Bundle is not defined"}catch(e){return`Error fetching bundle settings: ${e}`}}async function GA(r){try{const e=await Ke("get",`/bundle-data/${r.externalProductId}`);return{valid:new UA(r.selections,e).isBundleSelectionValid(r.externalVariantId)}}catch(e){return{valid:!1,error:String(e)}}}const HA={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 as(r){if(!r)return"No bundle defined.";if(r.selections.length===0)return"No selections defined.";const{shippingIntervalFrequency:e,shippingIntervalUnitType:t}=r.selections.find(n=>n.shippingIntervalFrequency||n.shippingIntervalUnitType)||{};if(e||t){if(!e||!t)return"Shipping intervals do not match on selections.";{const n=HA[t];for(let i=0;i<r.selections.length;i++){const{shippingIntervalFrequency:a,shippingIntervalUnitType:o}=r.selections[i];if(a&&a!==e||o&&!n.includes(o))return"Shipping intervals do not match on selections."}}}return!0}async function WA(r,e){if(e===void 0||e==="")throw new Error("ID is required");const{bundle_selection:t}=await $("get","/bundle_selections",{id:e},_(r,"getBundleSelection"));return t}function XA(r,e){return $("get","/bundle_selections",{query:e},_(r,"listBundleSelections"))}async function zA(r,e){const{bundle_selection:t}=await $("post","/bundle_selections",{data:e},_(r,"createBundleSelection"));return t}async function YA(r,e,t){if(e===void 0||e==="")throw new Error("ID is required");const{bundle_selection:n}=await $("put","/bundle_selections",{id:e,data:t},_(r,"updateBundleSelection"));return n}function KA(r,e){if(e===void 0||e==="")throw new Error("ID is required");return $("delete","/bundle_selections",{id:e},_(r,"deleteBundleSelection"))}async function ZA(r,e,t,n){if(e===void 0||e==="")throw new Error("Purchase item ID is required");const{subscription:i}=await $("put","/bundles",{id:e,data:t,query:n},_(r,"updateBundle"));return i}var JA=Object.freeze({__proto__:null,createBundleSelection:zA,deleteBundleSelection:KA,getBundleId:kA,getBundleSelection:WA,getBundleSelectionId:jA,getDynamicBundleItems:VA,listBundleSelections:XA,updateBundle:ZA,updateBundleSelection:YA,validateBundle:bi,validateBundleSelection:GA,validateDynamicBundle:as}),QA=200,$i="__lodash_hash_undefined__",eS=1/0,os=9007199254740991,rS="[object Arguments]",tS="[object Function]",nS="[object GeneratorFunction]",iS="[object Symbol]",aS=/[\\^$.*+?()[\]{}|]/g,oS=/^\[object .+?Constructor\]$/,uS=/^(?:0|[1-9]\d*)$/,sS=typeof U=="object"&&U&&U.Object===Object&&U,fS=typeof self=="object"&&self&&self.Object===Object&&self,Ei=sS||fS||Function("return this")();function cS(r,e,t){switch(t.length){case 0:return r.call(e);case 1:return r.call(e,t[0]);case 2:return r.call(e,t[0],t[1]);case 3:return r.call(e,t[0],t[1],t[2])}return r.apply(e,t)}function lS(r,e){var t=r?r.length:0;return!!t&&pS(r,e,0)>-1}function hS(r,e,t){for(var n=-1,i=r?r.length:0;++n<i;)if(t(e,r[n]))return!0;return!1}function us(r,e){for(var t=-1,n=r?r.length:0,i=Array(n);++t<n;)i[t]=e(r[t],t,r);return i}function Ai(r,e){for(var t=-1,n=e.length,i=r.length;++t<n;)r[i+t]=e[t];return r}function dS(r,e,t,n){for(var i=r.length,a=t+(n?1:-1);n?a--:++a<i;)if(e(r[a],a,r))return a;return-1}function pS(r,e,t){if(e!==e)return dS(r,yS,t);for(var n=t-1,i=r.length;++n<i;)if(r[n]===e)return n;return-1}function yS(r){return r!==r}function gS(r,e){for(var t=-1,n=Array(r);++t<r;)n[t]=e(t);return n}function vS(r){return function(e){return r(e)}}function _S(r,e){return r.has(e)}function mS(r,e){return r?.[e]}function wS(r){var e=!1;if(r!=null&&typeof r.toString!="function")try{e=!!(r+"")}catch{}return e}function ss(r,e){return function(t){return r(e(t))}}var bS=Array.prototype,$S=Function.prototype,Kt=Object.prototype,Si=Ei["__core-js_shared__"],fs=function(){var r=/[^.]+$/.exec(Si&&Si.keys&&Si.keys.IE_PROTO||"");return r?"Symbol(src)_1."+r:""}(),cs=$S.toString,ar=Kt.hasOwnProperty,Oi=Kt.toString,ES=RegExp("^"+cs.call(ar).replace(aS,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),ls=Ei.Symbol,AS=ss(Object.getPrototypeOf,Object),SS=Kt.propertyIsEnumerable,OS=bS.splice,hs=ls?ls.isConcatSpreadable:void 0,Ii=Object.getOwnPropertySymbols,ds=Math.max,IS=ys(Ei,"Map"),jr=ys(Object,"create");function Be(r){var e=-1,t=r?r.length:0;for(this.clear();++e<t;){var n=r[e];this.set(n[0],n[1])}}function PS(){this.__data__=jr?jr(null):{}}function xS(r){return this.has(r)&&delete this.__data__[r]}function TS(r){var e=this.__data__;if(jr){var t=e[r];return t===$i?void 0:t}return ar.call(e,r)?e[r]:void 0}function RS(r){var e=this.__data__;return jr?e[r]!==void 0:ar.call(e,r)}function FS(r,e){var t=this.__data__;return t[r]=jr&&e===void 0?$i:e,this}Be.prototype.clear=PS,Be.prototype.delete=xS,Be.prototype.get=TS,Be.prototype.has=RS,Be.prototype.set=FS;function or(r){var e=-1,t=r?r.length:0;for(this.clear();++e<t;){var n=r[e];this.set(n[0],n[1])}}function MS(){this.__data__=[]}function DS(r){var e=this.__data__,t=Jt(e,r);if(t<0)return!1;var n=e.length-1;return t==n?e.pop():OS.call(e,t,1),!0}function CS(r){var e=this.__data__,t=Jt(e,r);return t<0?void 0:e[t][1]}function NS(r){return Jt(this.__data__,r)>-1}function BS(r,e){var t=this.__data__,n=Jt(t,r);return n<0?t.push([r,e]):t[n][1]=e,this}or.prototype.clear=MS,or.prototype.delete=DS,or.prototype.get=CS,or.prototype.has=NS,or.prototype.set=BS;function ur(r){var e=-1,t=r?r.length:0;for(this.clear();++e<t;){var n=r[e];this.set(n[0],n[1])}}function US(){this.__data__={hash:new Be,map:new(IS||or),string:new Be}}function qS(r){return Qt(this,r).delete(r)}function LS(r){return Qt(this,r).get(r)}function kS(r){return Qt(this,r).has(r)}function jS(r,e){return Qt(this,r).set(r,e),this}ur.prototype.clear=US,ur.prototype.delete=qS,ur.prototype.get=LS,ur.prototype.has=kS,ur.prototype.set=jS;function Zt(r){var e=-1,t=r?r.length:0;for(this.__data__=new ur;++e<t;)this.add(r[e])}function VS(r){return this.__data__.set(r,$i),this}function GS(r){return this.__data__.has(r)}Zt.prototype.add=Zt.prototype.push=VS,Zt.prototype.has=GS;function HS(r,e){var t=Pi(r)||gs(r)?gS(r.length,String):[],n=t.length,i=!!n;for(var a in r)(e||ar.call(r,a))&&!(i&&(a=="length"||nO(a,n)))&&t.push(a);return t}function Jt(r,e){for(var t=r.length;t--;)if(cO(r[t][0],e))return t;return-1}function WS(r,e,t,n){var i=-1,a=lS,o=!0,u=r.length,f=[],c=e.length;if(!u)return f;t&&(e=us(e,vS(t))),n?(a=hS,o=!1):e.length>=QA&&(a=_S,o=!1,e=new Zt(e));e:for(;++i<u;){var l=r[i],s=t?t(l):l;if(l=n||l!==0?l:0,o&&s===s){for(var h=c;h--;)if(e[h]===s)continue e;f.push(l)}else a(e,s,n)||f.push(l)}return f}function ps(r,e,t,n,i){var a=-1,o=r.length;for(t||(t=tO),i||(i=[]);++a<o;){var u=r[a];e>0&&t(u)?e>1?ps(u,e-1,t,n,i):Ai(i,u):n||(i[i.length]=u)}return i}function XS(r,e,t){var n=e(r);return Pi(r)?n:Ai(n,t(r))}function zS(r){if(!xi(r)||aO(r))return!1;var e=_s(r)||wS(r)?ES:oS;return e.test(fO(r))}function YS(r){if(!xi(r))return uO(r);var e=oO(r),t=[];for(var n in r)n=="constructor"&&(e||!ar.call(r,n))||t.push(n);return t}function KS(r,e){return r=Object(r),ZS(r,e,function(t,n){return n in r})}function ZS(r,e,t){for(var n=-1,i=e.length,a={};++n<i;){var o=e[n],u=r[o];t(u,o)&&(a[o]=u)}return a}function JS(r,e){return e=ds(e===void 0?r.length-1:e,0),function(){for(var t=arguments,n=-1,i=ds(t.length-e,0),a=Array(i);++n<i;)a[n]=t[e+n];n=-1;for(var o=Array(e+1);++n<e;)o[n]=t[n];return o[e]=a,cS(r,this,o)}}function QS(r){return XS(r,pO,rO)}function Qt(r,e){var t=r.__data__;return iO(e)?t[typeof e=="string"?"string":"hash"]:t.map}function ys(r,e){var t=mS(r,e);return zS(t)?t:void 0}var eO=Ii?ss(Ii,Object):ws,rO=Ii?function(r){for(var e=[];r;)Ai(e,eO(r)),r=AS(r);return e}:ws;function tO(r){return Pi(r)||gs(r)||!!(hs&&r&&r[hs])}function nO(r,e){return e=e??os,!!e&&(typeof r=="number"||uS.test(r))&&r>-1&&r%1==0&&r<e}function iO(r){var e=typeof r;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?r!=="__proto__":r===null}function aO(r){return!!fs&&fs in r}function oO(r){var e=r&&r.constructor,t=typeof e=="function"&&e.prototype||Kt;return r===t}function uO(r){var e=[];if(r!=null)for(var t in Object(r))e.push(t);return e}function sO(r){if(typeof r=="string"||dO(r))return r;var e=r+"";return e=="0"&&1/r==-eS?"-0":e}function fO(r){if(r!=null){try{return cs.call(r)}catch{}try{return r+""}catch{}}return""}function cO(r,e){return r===e||r!==r&&e!==e}function gs(r){return lO(r)&&ar.call(r,"callee")&&(!SS.call(r,"callee")||Oi.call(r)==rS)}var Pi=Array.isArray;function vs(r){return r!=null&&hO(r.length)&&!_s(r)}function lO(r){return ms(r)&&vs(r)}function _s(r){var e=xi(r)?Oi.call(r):"";return e==tS||e==nS}function hO(r){return typeof r=="number"&&r>-1&&r%1==0&&r<=os}function xi(r){var e=typeof r;return!!r&&(e=="object"||e=="function")}function ms(r){return!!r&&typeof r=="object"}function dO(r){return typeof r=="symbol"||ms(r)&&Oi.call(r)==iS}function pO(r){return vs(r)?HS(r,!0):YS(r)}var yO=JS(function(r,e){return r==null?{}:(e=us(ps(e,1),sO),KS(r,WS(QS(r),e)))});function ws(){return[]}var gO=yO,Ti=be(gO);function vO(r){try{return JSON.parse(r)}catch{return r}}function _O(r){return Object.entries(r).reduce((e,[t,n])=>({...e,[t]:vO(n)}),{})}const bs=r=>typeof r=="string"?r!=="0"&&r!=="false":!!r;function $s(r){const e=_O(r),t=e.auto_inject===void 0?!0:e.auto_inject,n=e.display_on??[],i=e.first_option==="autodeliver";return{...Ti(e,["display_on","first_option"]),auto_inject:t,valid_pages:n,is_subscription_first:i,autoInject:t,validPages:n,isSubscriptionFirst:i}}function Es(r){const e=r.subscription_options?.storefront_purchase_options==="subscription_only";return{...r,is_subscription_only:e,isSubscriptionOnly:e}}function mO(r){return r.map(e=>{const t={};return Object.entries(e).forEach(([n,i])=>{t[n]=Es(i)}),t})}const Ri="2020-12",wO={store_currency:{currency_code:"USD",currency_symbol:"$",decimal_separator:".",thousands_separator:",",currency_symbol_location:"left"}},Vr=new Map;function en(r,e){return Vr.has(r)||Vr.set(r,e()),Vr.get(r)}async function Fi(r,e){if(r===void 0||r==="")throw new Error("ID is required");const t=e?.version??"2020-12",{product:n}=await en(`product.${r}.${t}`,()=>pt("get",`/product/${t}/${r}.json`));return t==="2020-12"?Es(n):n}async function As(){return await en("storeSettings",()=>pt("get",`/${Ri}/store_settings.json`).catch(()=>wO))}async function Ss(){const{widget_settings:r}=await en("widgetSettings",()=>pt("get",`/${Ri}/widget_settings.json`));return $s(r)}async function Os(){const{products:r,widget_settings:e,store_settings:t,meta:n}=await en("productsAndSettings",()=>pt("get",`/product/${Ri}/products.json`));return n?.status==="error"?Promise.reject(n.message):{products:mO(r),widget_settings:$s(e),store_settings:t??{}}}async function bO(){const{products:r}=await Os();return r}async function $O(r){const[e,t,n]=await Promise.all([Fi(r),As(),Ss()]);return{product:e,store_settings:t,widget_settings:n,storeSettings:t,widgetSettings:n}}async function EO(r){const{bundle_product:e}=await Fi(r);return e}async function Is(){return Array.from(Vr.keys()).forEach(r=>Vr.delete(r))}var AO=Object.freeze({__proto__:null,getCDNBundleSettings:EO,getCDNProduct:Fi,getCDNProductAndSettings:$O,getCDNProducts:bO,getCDNProductsAndSettings:Os,getCDNStoreSettings:As,getCDNWidgetSettings:Ss,resetCDNCache:Is});async function SO(r,e,t){if(e===void 0||e==="")throw new Error("ID is required");const{charge:n}=await $("get","/charges",{id:e,query:{include:t?.include}},_(r,"getCharge"));return n}function OO(r,e){return $("get","/charges",{query:e},_(r,"listCharges"))}async function IO(r,e,t){if(e===void 0||e==="")throw new Error("ID is required");const{charge:n}=await $("post",`/charges/${e}/apply_discount`,{data:{discount_code:t}},_(r,"applyDiscountToCharge"));return n}async function PO(r,e){if(e===void 0||e==="")throw new Error("ID is required");const{charge:t}=await $("post",`/charges/${e}/remove_discount`,{},_(r,"removeDiscountsFromCharge"));return t}async function xO(r,e,t,n){if(e===void 0||e==="")throw new Error("ID is required");if(t===void 0||t.length===0)throw new Error("Purchase item IDs are required");const{charge:i}=await $("post",`/charges/${e}/skip`,{query:n,data:{purchase_item_ids:t.map(a=>Number(a))}},_(r,"skipCharge"));return i}async function TO(r,e,t,n){if(e===void 0||e==="")throw new Error("ID is required");if(t===void 0||t.length===0)throw new Error("Purchase item IDs are required");const{charge:i}=await $("post",`/charges/${e}/unskip`,{query:n,data:{purchase_item_ids:t.map(a=>Number(a))}},_(r,"unskipCharge"));return i}async function RO(r,e){if(e===void 0||e==="")throw new Error("ID is required");const{charge:t}=await $("post",`/charges/${e}/process`,{},_(r,"processCharge"));return t}var FO=Object.freeze({__proto__:null,applyDiscountToCharge:IO,getCharge:SO,listCharges:OO,processCharge:RO,removeDiscountsFromCharge:PO,skipCharge:xO,unskipCharge:TO});async function Ps(r,e){if(!["2020-12","2022-06"].includes(e.format_version))throw new Error("Missing or unsupported format_version.");return $("get","/product_search",{query:e,headers:{"X-Recharge-Version":"2021-01"}},_(r,"productSearch"))}var MO=Object.freeze({__proto__:null,productSearch:Ps});async function xs(r,e){if(e===void 0||e==="")throw new Error("ID is required");const{collection:t}=await $("get","/collections",{id:e},_(r,"getCollection"));return t}function DO(r,e){return $("get","/collections",{query:e},_(r,"listCollections"))}async function CO(r,e,t){if(e===void 0||e==="")throw new Error("ID is required");if(!["2020-12","2022-06"].includes(t.format_version))throw new Error("Missing or unsupported format_version.");const n=_(r,"listCollectionProducts"),[{sort_order:i,manual_sort_order:a},{products:o}]=await Promise.all([xs(n,e),Ps(n,{...t,collection_ids:[e],limit:250})]);if(i==="manual")return{products:a.reduce((u,f)=>{const c=o.find(l=>l.external_product_id===f);return c&&u.push(c),u},[])};{const u=NO(i);return{products:o.slice().sort(u)}}}function Ts(r,e){const t=r.external_created_at,n=e.external_created_at;return t<n?-1:n>t?1:0}function Rs(r,e){const t=r.external_product_id,n=e.external_product_id;return t<n?-1:n>t?1:0}function Fs(r,e){const t=r.title.toLowerCase(),n=e.title.toLowerCase();return t<n?-1:n>t?1:0}function NO(r){switch(r){case"created_at-asc":return Ts;case"created_at-desc":return(e,t)=>Ts(t,e);case"id-asc":return Rs;case"id-desc":return(e,t)=>Rs(t,e);case"title-asc":return Fs;case"title-desc":return(e,t)=>Fs(t,e)}}var BO=Object.freeze({__proto__:null,getCollection:xs,listCollectionProducts:CO,listCollections:DO});async function UO(r,e){const t=r.customerId;if(!t)throw new Error("Not logged in.");const{customer:n}=await $("get","/customers",{id:t,query:{include:e?.include}},_(r,"getCustomer"));return n}async function Ms(r,e){const t=r.customerId;if(!t)throw new Error("Not logged in.");const{customer:n}=await $("put","/customers",{id:t,data:e},_(r,"updateCustomer"));return n}async function qO(r,e){const t=r.customerId;if(!t)throw new Error("Not logged in.");const{deliveries:n}=await $("get",`/customers/${t}/delivery_schedule`,{query:e},_(r,"getDeliverySchedule"));return n}async function rn(r,e){return $("get","/portal_access",{query:e},_(r,"getCustomerPortalAccess"))}async function LO(r,e,t){if(e===void 0||e==="")throw new Error("Subscription ID is required");const{base_url:n,customer_hash:i,temp_token:a}=await rn(_(r,"getActiveChurnLandingPageURL"));return`${n.replace("portal","pages")}${i}/subscriptions/${e}/cancel?token=${a}&subscription=${e}&redirect_to=${t}`}async function kO(r){const{base_url:e,customer_hash:t,temp_token:n}=await rn(_(r,"getFailedPaymentMethodRecoveryLandingPageURL"));return`${e.replace("portal","pages")}account/payment-methods?token=${n}&hash=${t}`}async function jO(r,e,t){if(e===void 0||e==="")throw new Error("Gift ID is required");const{base_url:n,customer_hash:i,temp_token:a}=await rn(_(r,"getGiftRedemptionLandingPageURL"));return`${n.replace("portal","pages")}${i}/gifts/${e}?token=${a}&redirect_to=${t}`}const VO={SHOPIFY_UPDATE_PAYMENT_INFO:{type:"email",template_type:"shopify_update_payment_information"}};async function GO(r,e,t){const n=r.customerId;if(!n)throw new Error("Not logged in.");const i=VO[e];if(!i)throw new Error("Notification not supported.");return $("post",`/customers/${n}/notifications`,{data:{...i,template_vars:t}},_(r,"sendCustomerNotification"))}async function HO(r,e){const t=r.customerId;if(!t)throw new Error("Not logged in.");const{credit_summary:n}=await $("get",`/customers/${t}/credit_summary`,{query:{include:e?.include}},_(r,"getCreditSummary"));return n}var WO=Object.freeze({__proto__:null,getActiveChurnLandingPageURL:LO,getCreditSummary:HO,getCustomer:UO,getCustomerPortalAccess:rn,getDeliverySchedule:qO,getFailedPaymentMethodRecoveryLandingPageURL:kO,getGiftRedemptionLandingPageURL:jO,sendCustomerNotification:GO,updateCustomer:Ms});async function XO(r,e){const t=r.customerId;if(!t)throw new Error("Not logged in.");const{credit_summary:n}=await $("get",`/customers/${t}/credit_summary`,{query:{include:e?.include,presentment_currency_code:e?.presentment_currency_code}},_(r,"getCreditSummary"));return n}function zO(r,{recurring:e}){if(!r.customerId)throw new Error("Not logged in.");const t={};return e!==void 0&&(t.apply_credit_to_next_recurring_charge=e),Ms(_(r,"setApplyCreditsToNextCharge"),t)}async function YO(r,e){const t=r.customerId;if(!t)throw new Error("Not logged in.");return await $("get","/credit_accounts",{query:{customer_id:t,...e}},_(r,"listCreditAccounts"))}var KO=Object.freeze({__proto__:null,getCreditSummary:XO,listCreditAccounts:YO,setApplyCreditsToNextCharge:zO});function ZO(r,e){if(!r.customerId)throw new Error("Not logged in.");return $("get","/gift_purchases",{query:e},_(r,"listGiftPurchases"))}async function JO(r,e){if(!r.customerId)throw new Error("Not logged in.");if(e===void 0||e==="")throw new Error("ID is required");const{gift_purchase:t}=await $("get","/gift_purchases",{id:e},_(r,"getGiftPurchase"));return t}var QO=Object.freeze({__proto__:null,getGiftPurchase:JO,listGiftPurchases:ZO});async function eI(r,e){if(e===void 0||e==="")throw new Error("ID is required");const{membership:t}=await $("get","/memberships",{id:e},_(r,"getMembership"));return t}function rI(r,e){return $("get","/memberships",{query:e},_(r,"listMemberships"))}async function tI(r,e,t){if(e===void 0||e==="")throw new Error("ID is required");const{membership:n}=await $("post",`/memberships/${e}/cancel`,{data:t},_(r,"cancelMembership"));return n}async function nI(r,e,t){if(e===void 0||e==="")throw new Error("ID is required");const{membership:n}=await $("post",`/memberships/${e}/activate`,{data:t},_(r,"activateMembership"));return n}async function iI(r,e,t){if(e===void 0||e==="")throw new Error("ID is required");const{membership:n}=await $("post",`/memberships/${e}/change`,{data:t},_(r,"changeMembership"));return n}var aI=Object.freeze({__proto__:null,activateMembership:nI,cancelMembership:tI,changeMembership:iI,getMembership:eI,listMemberships:rI});async function oI(r,e,t){if(e===void 0||e==="")throw new Error("ID is required");const{membership_program:n}=await $("get","/membership_programs",{id:e,query:{include:t?.include}},_(r,"getMembershipProgram"));return n}function uI(r,e){return $("get","/membership_programs",{query:e},_(r,"listMembershipPrograms"))}var sI=Object.freeze({__proto__:null,getMembershipProgram:oI,listMembershipPrograms:uI});async function fI(r,e){const{metafield:t}=await $("post","/metafields",{data:{metafield:e}},_(r,"createMetafield"));return t}async function cI(r,e,t){if(e===void 0||e==="")throw new Error("ID is required");const{metafield:n}=await $("put","/metafields",{id:e,data:{metafield:t}},_(r,"updateMetafield"));return n}function lI(r,e){if(e===void 0||e==="")throw new Error("ID is required");return $("delete","/metafields",{id:e},_(r,"deleteMetafield"))}var hI=Object.freeze({__proto__:null,createMetafield:fI,deleteMetafield:lI,updateMetafield:cI});async function dI(r,e){if(e===void 0||e==="")throw new Error("ID is required");const{onetime:t}=await $("get","/onetimes",{id:e},_(r,"getOnetime"));return t}function pI(r,e){return $("get","/onetimes",{query:e},_(r,"listOnetimes"))}async function yI(r,e){const{onetime:t}=await $("post","/onetimes",{data:e},_(r,"createOnetime"));return t}async function gI(r,e,t){if(e===void 0||e==="")throw new Error("ID is required");const{onetime:n}=await $("put","/onetimes",{id:e,data:t},_(r,"updateOnetime"));return n}function vI(r,e){if(e===void 0||e==="")throw new Error("ID is required");return $("delete","/onetimes",{id:e},_(r,"deleteOnetime"))}var _I=Object.freeze({__proto__:null,createOnetime:yI,deleteOnetime:vI,getOnetime:dI,listOnetimes:pI,updateOnetime:gI});async function mI(r,e){if(e===void 0||e==="")throw new Error("ID is required");const{order:t}=await $("get","/orders",{id:e},_(r,"getOrder"));return t}function wI(r,e){return $("get","/orders",{query:e},_(r,"listOrders"))}async function bI(r,e){if(e===void 0||e==="")throw new Error("ID is required");const{order:t}=await $("post",`/orders/${e}/delay`,{},_(r,"delayOrder"));return t}var $I=Object.freeze({__proto__:null,delayOrder:bI,getOrder:mI,listOrders:wI});async function EI(r,e,t){if(e===void 0||e==="")throw new Error("ID is required");const{payment_method:n}=await $("get","/payment_methods",{id:e,query:{include:t?.include}},_(r,"getPaymentMethod"));return n}async function AI(r,e){const{payment_method:t}=await $("post","/payment_methods",{data:{...e,customer_id:r.customerId}},_(r,"createPaymentMethod"));return t}async function SI(r,e,t){if(e===void 0||e==="")throw new Error("ID is required");const{payment_method:n}=await $("put","/payment_methods",{id:e,data:t},_(r,"updatePaymentMethod"));return n}function OI(r,e){return $("get","/payment_methods",{query:e},_(r,"listPaymentMethods"))}var II=Object.freeze({__proto__:null,createPaymentMethod:AI,getPaymentMethod:EI,listPaymentMethods:OI,updatePaymentMethod:SI});async function PI(r,e){if(e===void 0||e==="")throw new Error("ID is required");const{plan:t}=await $("get","/plans",{id:e},_(r,"getPlan"));return t}function xI(r,e){return $("get","/plans",{query:e},_(r,"listPlans"))}var TI=Object.freeze({__proto__:null,getPlan:PI,listPlans:xI});async function RI(r,e){return await $("get","/shop/shipping_countries",{query:e,headers:{"X-Recharge-Version":"2021-01"}},_(r,"getShippingCountries"))}async function FI(r){return await $("get","/shop/settings",{headers:{"X-Recharge-Version":"2021-01"}},_(r,"getStoreSettings"))}var MI=Object.freeze({__proto__:null,getShippingCountries:RI,getStoreSettings:FI}),DI="Expected a function",Ds="__lodash_placeholder__",Ue=1,tn=2,CI=4,sr=8,Gr=16,qe=32,Hr=64,Cs=128,NI=256,Ns=512,Bs=1/0,BI=9007199254740991,UI=17976931348623157e292,Us=0/0,qI=[["ary",Cs],["bind",Ue],["bindKey",tn],["curry",sr],["curryRight",Gr],["flip",Ns],["partial",qe],["partialRight",Hr],["rearg",NI]],LI="[object Function]",kI="[object GeneratorFunction]",jI="[object Symbol]",VI=/[\\^$.*+?()[\]{}|]/g,GI=/^\s+|\s+$/g,HI=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,WI=/\{\n\/\* \[wrapped with (.+)\] \*/,XI=/,? & /,zI=/^[-+]0x[0-9a-f]+$/i,YI=/^0b[01]+$/i,KI=/^\[object .+?Constructor\]$/,ZI=/^0o[0-7]+$/i,JI=/^(?:0|[1-9]\d*)$/,QI=parseInt,e2=typeof U=="object"&&U&&U.Object===Object&&U,r2=typeof self=="object"&&self&&self.Object===Object&&self,Wr=e2||r2||Function("return this")();function Mi(r,e,t){switch(t.length){case 0:return r.call(e);case 1:return r.call(e,t[0]);case 2:return r.call(e,t[0],t[1]);case 3:return r.call(e,t[0],t[1],t[2])}return r.apply(e,t)}function t2(r,e){for(var t=-1,n=r?r.length:0;++t<n&&e(r[t],t,r)!==!1;);return r}function n2(r,e){var t=r?r.length:0;return!!t&&a2(r,e,0)>-1}function i2(r,e,t,n){for(var i=r.length,a=t+(n?1:-1);n?a--:++a<i;)if(e(r[a],a,r))return a;return-1}function a2(r,e,t){if(e!==e)return i2(r,o2,t);for(var n=t-1,i=r.length;++n<i;)if(r[n]===e)return n;return-1}function o2(r){return r!==r}function u2(r,e){for(var t=r.length,n=0;t--;)r[t]===e&&n++;return n}function s2(r,e){return r?.[e]}function f2(r){var e=!1;if(r!=null&&typeof r.toString!="function")try{e=!!(r+"")}catch{}return e}function Di(r,e){for(var t=-1,n=r.length,i=0,a=[];++t<n;){var o=r[t];(o===e||o===Ds)&&(r[t]=Ds,a[i++]=t)}return a}var c2=Function.prototype,qs=Object.prototype,Ci=Wr["__core-js_shared__"],Ls=function(){var r=/[^.]+$/.exec(Ci&&Ci.keys&&Ci.keys.IE_PROTO||"");return r?"Symbol(src)_1."+r:""}(),ks=c2.toString,l2=qs.hasOwnProperty,js=qs.toString,h2=RegExp("^"+ks.call(l2).replace(VI,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),d2=Object.create,fr=Math.max,p2=Math.min,Vs=function(){var r=Hs(Object,"defineProperty"),e=Hs.name;return e&&e.length>2?r:void 0}();function y2(r){return cr(r)?d2(r):{}}function g2(r){if(!cr(r)||P2(r))return!1;var e=F2(r)||f2(r)?h2:KI;return e.test(T2(r))}function v2(r,e){return e=fr(e===void 0?r.length-1:e,0),function(){for(var t=arguments,n=-1,i=fr(t.length-e,0),a=Array(i);++n<i;)a[n]=t[e+n];n=-1;for(var o=Array(e+1);++n<e;)o[n]=t[n];return o[e]=a,Mi(r,this,o)}}function _2(r,e,t,n){for(var i=-1,a=r.length,o=t.length,u=-1,f=e.length,c=fr(a-o,0),l=Array(f+c),s=!n;++u<f;)l[u]=e[u];for(;++i<o;)(s||i<a)&&(l[t[i]]=r[i]);for(;c--;)l[u++]=r[i++];return l}function m2(r,e,t,n){for(var i=-1,a=r.length,o=-1,u=t.length,f=-1,c=e.length,l=fr(a-u,0),s=Array(l+c),h=!n;++i<l;)s[i]=r[i];for(var y=i;++f<c;)s[y+f]=e[f];for(;++o<u;)(h||i<a)&&(s[y+t[o]]=r[i++]);return s}function w2(r,e){var t=-1,n=r.length;for(e||(e=Array(n));++t<n;)e[t]=r[t];return e}function b2(r,e,t){var n=e&Ue,i=Xr(r);function a(){var o=this&&this!==Wr&&this instanceof a?i:r;return o.apply(n?t:this,arguments)}return a}function Xr(r){return function(){var e=arguments;switch(e.length){case 0:return new r;case 1:return new r(e[0]);case 2:return new r(e[0],e[1]);case 3:return new r(e[0],e[1],e[2]);case 4:return new r(e[0],e[1],e[2],e[3]);case 5:return new r(e[0],e[1],e[2],e[3],e[4]);case 6:return new r(e[0],e[1],e[2],e[3],e[4],e[5]);case 7:return new r(e[0],e[1],e[2],e[3],e[4],e[5],e[6])}var t=y2(r.prototype),n=r.apply(t,e);return cr(n)?n:t}}function $2(r,e,t){var n=Xr(r);function i(){for(var a=arguments.length,o=Array(a),u=a,f=Bi(i);u--;)o[u]=arguments[u];var c=a<3&&o[0]!==f&&o[a-1]!==f?[]:Di(o,f);if(a-=c.length,a<t)return Gs(r,e,Ni,i.placeholder,void 0,o,c,void 0,void 0,t-a);var l=this&&this!==Wr&&this instanceof i?n:r;return Mi(l,this,o)}return i}function Ni(r,e,t,n,i,a,o,u,f,c){var l=e&Cs,s=e&Ue,h=e&tn,y=e&(sr|Gr),w=e&Ns,S=h?void 0:Xr(r);function O(){for(var b=arguments.length,E=Array(b),d=b;d--;)E[d]=arguments[d];if(y)var I=Bi(O),T=u2(E,I);if(n&&(E=_2(E,n,i,y)),a&&(E=m2(E,a,o,y)),b-=T,y&&b<c){var F=Di(E,I);return Gs(r,e,Ni,O.placeholder,t,E,F,u,f,c-b)}var m=s?t:this,g=h?m[r]:r;return b=E.length,u?E=x2(E,u):w&&b>1&&E.reverse(),l&&f<b&&(E.length=f),this&&this!==Wr&&this instanceof O&&(g=S||Xr(g)),g.apply(m,E)}return O}function E2(r,e,t,n){var i=e&Ue,a=Xr(r);function o(){for(var u=-1,f=arguments.length,c=-1,l=n.length,s=Array(l+f),h=this&&this!==Wr&&this instanceof o?a:r;++c<l;)s[c]=n[c];for(;f--;)s[c++]=arguments[++u];return Mi(h,i?t:this,s)}return o}function Gs(r,e,t,n,i,a,o,u,f,c){var l=e&sr,s=l?o:void 0,h=l?void 0:o,y=l?a:void 0,w=l?void 0:a;e|=l?qe:Hr,e&=~(l?Hr:qe),e&CI||(e&=~(Ue|tn));var S=t(r,e,i,y,s,w,h,u,f,c);return S.placeholder=n,Ws(S,r,e)}function A2(r,e,t,n,i,a,o,u){var f=e&tn;if(!f&&typeof r!="function")throw new TypeError(DI);var c=n?n.length:0;if(c||(e&=~(qe|Hr),n=i=void 0),o=o===void 0?o:fr(Xs(o),0),u=u===void 0?u:Xs(u),c-=i?i.length:0,e&Hr){var l=n,s=i;n=i=void 0}var h=[r,e,t,n,i,l,s,a,o,u];if(r=h[0],e=h[1],t=h[2],n=h[3],i=h[4],u=h[9]=h[9]==null?f?0:r.length:fr(h[9]-c,0),!u&&e&(sr|Gr)&&(e&=~(sr|Gr)),!e||e==Ue)var y=b2(r,e,t);else e==sr||e==Gr?y=$2(r,e,u):(e==qe||e==(Ue|qe))&&!i.length?y=E2(r,e,t,n):y=Ni.apply(void 0,h);return Ws(y,r,e)}function Bi(r){var e=r;return e.placeholder}function Hs(r,e){var t=s2(r,e);return g2(t)?t:void 0}function S2(r){var e=r.match(WI);return e?e[1].split(XI):[]}function O2(r,e){var t=e.length,n=t-1;return e[n]=(t>1?"& ":"")+e[n],e=e.join(t>2?", ":" "),r.replace(HI,`{
25
25
  /* [wrapped with `+e+`] */
26
26
  `)}function I2(r,e){return e=e??BI,!!e&&(typeof r=="number"||JI.test(r))&&r>-1&&r%1==0&&r<e}function P2(r){return!!Ls&&Ls in r}function x2(r,e){for(var t=r.length,n=p2(e.length,t),i=w2(r);n--;){var a=e[n];r[n]=I2(a,t)?i[a]:void 0}return r}var Ws=Vs?function(r,e,t){var n=e+"";return Vs(r,"toString",{configurable:!0,enumerable:!1,value:B2(O2(n,R2(S2(n),t)))})}:U2;function T2(r){if(r!=null){try{return ks.call(r)}catch{}try{return r+""}catch{}}return""}function R2(r,e){return t2(qI,function(t){var n="_."+t[0];e&t[1]&&!n2(r,n)&&r.push(n)}),r.sort()}var Ui=v2(function(r,e){var t=Di(e,Bi(Ui));return A2(r,qe,void 0,e,t)});function F2(r){var e=cr(r)?js.call(r):"";return e==LI||e==kI}function cr(r){var e=typeof r;return!!r&&(e=="object"||e=="function")}function M2(r){return!!r&&typeof r=="object"}function D2(r){return typeof r=="symbol"||M2(r)&&js.call(r)==jI}function C2(r){if(!r)return r===0?r:0;if(r=N2(r),r===Bs||r===-Bs){var e=r<0?-1:1;return e*UI}return r===r?r:0}function Xs(r){var e=C2(r),t=e%1;return e===e?t?e-t:e:0}function N2(r){if(typeof r=="number")return r;if(D2(r))return Us;if(cr(r)){var e=typeof r.valueOf=="function"?r.valueOf():r;r=cr(e)?e+"":e}if(typeof r!="string")return r===0?r:+r;r=r.replace(GI,"");var t=YI.test(r);return t||ZI.test(r)?QI(r.slice(2),t?2:8):zI.test(r)?Us:+r}function B2(r){return function(){return r}}function U2(r){return r}Ui.placeholder={};var q2=Ui,zs=be(q2);function L2(r,e){return{...Ti(e,["address_id","external_variant_id","external_product_id","charge_interval_frequency","order_interval_frequency","price","status"]),customer_id:parseInt(r,10),shopify_variant_id:e.external_variant_id.ecommerce?parseInt(e.external_variant_id.ecommerce,10):void 0,...e.charge_interval_frequency?{charge_interval_frequency:`${e.charge_interval_frequency}`}:{},...e.order_interval_frequency?{order_interval_frequency:`${e.order_interval_frequency}`}:{},status:e.status?e.status.toUpperCase():void 0}}function k2(r,e){return{...Ti(e,["external_variant_id","external_product_id","charge_interval_frequency","order_interval_frequency","price","use_external_variant_defaults"]),shopify_variant_id:e.external_variant_id?.ecommerce?parseInt(e.external_variant_id.ecommerce,10):void 0,...e.charge_interval_frequency?{charge_interval_frequency:`${e.charge_interval_frequency}`}:void 0,...e.order_interval_frequency?{order_interval_frequency:`${e.order_interval_frequency}`}:void 0,force_update:r}}function Ys(r){const{id:e,address_id:t,customer_id:n,analytics_data:i,cancellation_reason:a,cancellation_reason_comments:o,cancelled_at:u,charge_interval_frequency:f,created_at:c,expire_after_specific_number_of_charges:l,shopify_product_id:s,shopify_variant_id:h,has_queued_charges:y,is_prepaid:w,is_skippable:S,is_swappable:O,max_retries_reached:b,next_charge_scheduled_at:E,order_day_of_month:d,order_day_of_week:I,order_interval_frequency:T,order_interval_unit:F,presentment_currency:m,price:g,product_title:v,properties:A,quantity:P,sku:M,sku_override:z,status:me,updated_at:lr,variant_title:we}=r;return{id:e,address_id:t,customer_id:n,analytics_data:i,cancellation_reason:a,cancellation_reason_comments:o,cancelled_at:u,charge_interval_frequency:parseInt(f,10),created_at:c,expire_after_specific_number_of_charges:l,external_product_id:{ecommerce:`${s}`},external_variant_id:{ecommerce:`${h}`},has_queued_charges:bs(y),is_prepaid:w,is_skippable:S,is_swappable:O,max_retries_reached:bs(b),next_charge_scheduled_at:E,order_day_of_month:d,order_day_of_week:I,order_interval_frequency:parseInt(T,10),order_interval_unit:F,presentment_currency:m,price:`${g}`,product_title:v??"",properties:A,quantity:P,sku:M,sku_override:z,status:me.toLowerCase(),updated_at:lr,variant_title:we}}async function j2(r,e,t){if(e===void 0||e==="")throw new Error("ID is required");const{subscription:n}=await $("get","/subscriptions",{id:e,query:{include:t?.include}},_(r,"getSubscription"));return n}function V2(r,e){return $("get","/subscriptions",{query:e},_(r,"listSubscriptions"))}async function G2(r,e,t){const{subscription:n}=await $("post","/subscriptions",{data:e,query:t},_(r,"createSubscription"));return n}async function H2(r,e,t,n){if(e===void 0||e==="")throw new Error("ID is required");const{subscription:i}=await $("put","/subscriptions",{id:e,data:t,query:n},_(r,"updateSubscription"));return i}async function W2(r,e,t,n){if(e===void 0||e==="")throw new Error("ID is required");const{subscription:i}=await $("post",`/subscriptions/${e}/set_next_charge_date`,{data:{date:t},query:n},_(r,"updateSubscriptionChargeDate"));return i}async function X2(r,e,t){if(e===void 0||e==="")throw new Error("ID is required");const{subscription:n}=await $("post",`/subscriptions/${e}/change_address`,{data:{address_id:t}},_(r,"updateSubscriptionAddress"));return n}async function z2(r,e,t,n){if(e===void 0||e==="")throw new Error("ID is required");const{subscription:i}=await $("post",`/subscriptions/${e}/cancel`,{data:t,query:n},_(r,"cancelSubscription"));return i}async function Y2(r,e,t){if(e===void 0||e==="")throw new Error("ID is required");const{subscription:n}=await $("post",`/subscriptions/${e}/activate`,{query:t},_(r,"activateSubscription"));return n}async function K2(r,e,t){if(e===void 0||e==="")throw new Error("ID is required");const{charge:n}=await $("post",`/subscriptions/${e}/charges/skip`,{data:{date:t,subscription_id:`${e}`}},_(r,"skipSubscriptionCharge"));return n}async function Z2(r,e,t){if(e===void 0||e.length===0)throw new Error("Subscription IDs are required");const{onetimes:n}=await $("post","/purchase_items/skip_gift",{data:{purchase_item_ids:e.map(Number),recipient_address:t}},_(r,"skipGiftSubscriptionCharge"));return n}async function J2(r,e,t){const n=e.length;if(n<1||n>21)throw new Error("Number of subscriptions must be between 1 and 20.");const{customerId:i}=r;if(!i)throw new Error("No customerId in session.");const a=e[0].address_id;if(!e.every(l=>l.address_id===a))throw new Error("All subscriptions must have the same address_id.");const o=zs(L2,i),u=e.map(o);let f;t?.allow_onetimes!==void 0&&(f={allow_onetimes:t.allow_onetimes});const{subscriptions:c}=await $("post",`/addresses/${a}/subscriptions-bulk`,{data:{subscriptions:u,commit_update:!!t?.commit},headers:{"X-Recharge-Version":"2021-01"},query:f},_(r,"createSubscriptions"));return c.map(Ys)}async function Q2(r,e,t,n){if(e===void 0||e==="")throw new Error("Address ID is required");const i=t.length;if(i<1||i>21)throw new Error("Number of subscriptions must be between 1 and 20.");const{customerId:a}=r;if(!a)throw new Error("No customerId in session.");const o=zs(k2,!!n?.force_update),u=t.map(o);let f;n?.allow_onetimes!==void 0&&(f={allow_onetimes:n.allow_onetimes});const{subscriptions:c}=await $("put",`/addresses/${e}/subscriptions-bulk`,{data:{subscriptions:u,commit_update:!!n?.commit},headers:{"X-Recharge-Version":"2021-01"},query:f},_(r,"updateSubscriptions"));return c.map(Ys)}async function eP(r,e,t,n){if(e===void 0||e==="")throw new Error("Address ID is required");const i=t.length;if(i<1||i>21)throw new Error("Number of subscriptions must be between 1 and 20.");const{customerId:a}=r;if(!a)throw new Error("No customerId in session.");let o;n?.allow_onetimes!==void 0&&(o={allow_onetimes:n.allow_onetimes}),await $("delete",`/addresses/${e}/subscriptions-bulk`,{data:{subscriptions:t,send_email:!!n?.send_email,commit_update:!!n?.commit},headers:{"X-Recharge-Version":"2021-01"},query:o},_(r,"deleteSubscriptions"))}var rP=Object.freeze({__proto__:null,activateSubscription:Y2,cancelSubscription:z2,createSubscription:G2,createSubscriptions:J2,deleteSubscriptions:eP,getSubscription:j2,listSubscriptions:V2,skipGiftSubscriptionCharge:Z2,skipSubscriptionCharge:K2,updateSubscription:H2,updateSubscriptionAddress:X2,updateSubscriptionChargeDate:W2,updateSubscriptions:Q2});const tP={get(r,e){return ue("get",r,e)},post(r,e){return ue("post",r,e)},put(r,e){return ue("put",r,e)},delete(r,e){return ue("delete",r,e)}};function nP(r){if(r)return r;if(window?.Shopify?.shop)return window.Shopify.shop;let e=window?.domain;if(!e){const t=location?.href.match(/(?:http[s]*:\/\/)*(.*?)\.(?=admin\.rechargeapps\.com)/i)?.[1].replace(/-sp$/,"");t&&(e=`${t}.myshopify.com`)}if(e)return e;throw new Error("No storeIdentifier was passed into init.")}function iP(r={}){const e=r,{storefrontAccessToken:t}=r;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.");ch({storeIdentifier:nP(r.storeIdentifier),loginRetryFn:r.loginRetryFn,storefrontAccessToken:t,appName:r.appName,appVersion:r.appVersion,environment:e.environment?e.environment:"prod",environmentUri:e.environmentUri,customerHash:e.customerHash}),Is()}const Ks={init:iP,api:tP,address:Ah,auth:Dh,bundle:JA,charge:FO,cdn:AO,collection:BO,credit:KO,customer:WO,gift:QO,membership:aI,membershipProgram:sI,metafield:hI,onetime:_I,order:$I,paymentMethod:II,plan:TI,product:MO,store:MI,subscription:rP};try{Ks.init()}catch{}return Ks});
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.38.0",
4
+ "version": "1.39.0",
5
5
  "author": "Recharge Inc.",
6
6
  "license": "MIT",
7
7
  "main": "dist/cjs/index.js",