@rechargeapps/storefront-client 0.5.1 → 0.5.3

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.
@@ -45,7 +45,7 @@ const getProductsAndSettings = async () => {
45
45
  return {
46
46
  products: cdn.productArrayMapper(products),
47
47
  widget_settings: cdn.widgetSettingsMapper(widget_settings),
48
- store_settings
48
+ store_settings: store_settings != null ? store_settings : {}
49
49
  };
50
50
  };
51
51
  const getProducts = async () => {
@@ -1 +1 @@
1
- {"version":3,"file":"cdn.js","sources":["../../../src/api/cdn.ts"],"sourcesContent":["import {\n CDNWidgetSettings,\n CDNStoreSettings,\n CDNWidgetSettingsResource,\n CDNProductsAndSettings,\n CDNProductResource,\n CDNProduct,\n CDNProductAndSettings,\n CDNProductsAndSettingsResource,\n CDNBundleSettings,\n CDNProductKeyObject,\n} from '../types';\nimport { productArrayMapper, productMapper, widgetSettingsMapper } from '../mappers/cdn';\nimport { cdnRequest } from '../utils/request';\n\nconst CDN_VERSION = '2020-12';\n\n// Default store settings if none are provided from the cdn\nconst DEFAULT_STORE_SETTINGS: CDNStoreSettings = {\n store_currency: {\n currency_code: 'USD',\n currency_symbol: '$',\n decimal_separator: '.',\n thousands_separator: ',',\n currency_symbol_location: 'left',\n },\n};\n\nconst promiseCache = new Map();\n\n// This will cache the request and use the same promise anywhere we call this function. This will never make multiple calls and always return the first request\nfunction cacheRequest<T>(cacheKey: string, request: () => T): T {\n if (!promiseCache.has(cacheKey)) {\n promiseCache.set(cacheKey, request());\n }\n return promiseCache.get(cacheKey);\n}\n\nexport const getProduct = async (externalProductId: string | number): Promise<CDNProduct> => {\n const { product } = await cacheRequest(`product.${externalProductId}`, () =>\n cdnRequest<CDNProductResource>('get', `/product/${CDN_VERSION}/${externalProductId}.json`)\n );\n\n return productMapper(product);\n};\n\nexport const getStoreSettings = async (): Promise<CDNStoreSettings> => {\n const storeSettings = await cacheRequest('storeSettings', () =>\n cdnRequest<CDNStoreSettings>('get', `/${CDN_VERSION}/store_settings.json`).catch(() => {\n return DEFAULT_STORE_SETTINGS;\n })\n );\n return storeSettings;\n};\n\nexport const getWidgetSettings = async (): Promise<CDNWidgetSettings> => {\n const { widget_settings } = await cacheRequest('widgetSettings', () =>\n cdnRequest<CDNWidgetSettingsResource>('get', `/${CDN_VERSION}/widget_settings.json`)\n );\n\n const widgetSettings = widgetSettingsMapper(widget_settings);\n\n return widgetSettings;\n};\n\nexport const getProductsAndSettings = async (): Promise<CDNProductsAndSettings> => {\n const { products, widget_settings, store_settings, meta } = await cacheRequest('productsAndSettings', () =>\n cdnRequest<CDNProductsAndSettingsResource>('get', `/product/${CDN_VERSION}/products.json`)\n );\n\n if (meta?.status === 'error') {\n return Promise.reject(meta.message);\n }\n\n return {\n products: productArrayMapper(products),\n widget_settings: widgetSettingsMapper(widget_settings),\n store_settings,\n };\n};\n\nexport const getProducts = async (): Promise<CDNProductKeyObject[]> => {\n const { products } = await getProductsAndSettings();\n return products;\n};\n\nexport const getProductAndSettings = async (externalProductId: string | number): Promise<CDNProductAndSettings> => {\n const [product, store_settings, widget_settings] = await Promise.all([\n getProduct(externalProductId),\n getStoreSettings(),\n getWidgetSettings(),\n ]);\n\n return {\n product,\n store_settings,\n widget_settings,\n storeSettings: store_settings,\n widgetSettings: widget_settings,\n };\n};\n\nexport const getBundleSettings = async (\n externalProductId: string | number\n): Promise<CDNBundleSettings | null | undefined> => {\n const { bundle_product } = await getProduct(externalProductId);\n\n return bundle_product;\n};\n\nexport const resetCache = () => Array.from(promiseCache.keys()).forEach(key => promiseCache.delete(key));\n"],"names":["cdnRequest","productMapper","widgetSettingsMapper","productArrayMapper"],"mappings":"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"}
1
+ {"version":3,"file":"cdn.js","sources":["../../../src/api/cdn.ts"],"sourcesContent":["import {\n CDNWidgetSettings,\n CDNStoreSettings,\n CDNWidgetSettingsResource,\n CDNProductsAndSettings,\n CDNProductResource,\n CDNProduct,\n CDNProductAndSettings,\n CDNProductsAndSettingsResource,\n CDNBundleSettings,\n CDNProductKeyObject,\n} from '../types';\nimport { productArrayMapper, productMapper, widgetSettingsMapper } from '../mappers/cdn';\nimport { cdnRequest } from '../utils/request';\n\nconst CDN_VERSION = '2020-12';\n\n// Default store settings if none are provided from the cdn\nconst DEFAULT_STORE_SETTINGS: CDNStoreSettings = {\n store_currency: {\n currency_code: 'USD',\n currency_symbol: '$',\n decimal_separator: '.',\n thousands_separator: ',',\n currency_symbol_location: 'left',\n },\n};\n\nconst promiseCache = new Map();\n\n// This will cache the request and use the same promise anywhere we call this function. This will never make multiple calls and always return the first request\nfunction cacheRequest<T>(cacheKey: string, request: () => T): T {\n if (!promiseCache.has(cacheKey)) {\n promiseCache.set(cacheKey, request());\n }\n return promiseCache.get(cacheKey);\n}\n\nexport const getProduct = async (externalProductId: string | number): Promise<CDNProduct> => {\n const { product } = await cacheRequest(`product.${externalProductId}`, () =>\n cdnRequest<CDNProductResource>('get', `/product/${CDN_VERSION}/${externalProductId}.json`)\n );\n\n return productMapper(product);\n};\n\nexport const getStoreSettings = async (): Promise<CDNStoreSettings> => {\n const storeSettings = await cacheRequest('storeSettings', () =>\n cdnRequest<CDNStoreSettings>('get', `/${CDN_VERSION}/store_settings.json`).catch(() => {\n return DEFAULT_STORE_SETTINGS;\n })\n );\n return storeSettings;\n};\n\nexport const getWidgetSettings = async (): Promise<CDNWidgetSettings> => {\n const { widget_settings } = await cacheRequest('widgetSettings', () =>\n cdnRequest<CDNWidgetSettingsResource>('get', `/${CDN_VERSION}/widget_settings.json`)\n );\n\n const widgetSettings = widgetSettingsMapper(widget_settings);\n\n return widgetSettings;\n};\n\nexport const getProductsAndSettings = async (): Promise<CDNProductsAndSettings> => {\n const { products, widget_settings, store_settings, meta } = await cacheRequest('productsAndSettings', () =>\n cdnRequest<CDNProductsAndSettingsResource>('get', `/product/${CDN_VERSION}/products.json`)\n );\n\n if (meta?.status === 'error') {\n return Promise.reject(meta.message);\n }\n\n return {\n products: productArrayMapper(products),\n widget_settings: widgetSettingsMapper(widget_settings),\n store_settings: store_settings ?? {},\n };\n};\n\nexport const getProducts = async (): Promise<CDNProductKeyObject[]> => {\n const { products } = await getProductsAndSettings();\n return products;\n};\n\nexport const getProductAndSettings = async (externalProductId: string | number): Promise<CDNProductAndSettings> => {\n const [product, store_settings, widget_settings] = await Promise.all([\n getProduct(externalProductId),\n getStoreSettings(),\n getWidgetSettings(),\n ]);\n\n return {\n product,\n store_settings,\n widget_settings,\n storeSettings: store_settings,\n widgetSettings: widget_settings,\n };\n};\n\nexport const getBundleSettings = async (\n externalProductId: string | number\n): Promise<CDNBundleSettings | null | undefined> => {\n const { bundle_product } = await getProduct(externalProductId);\n\n return bundle_product;\n};\n\nexport const resetCache = () => Array.from(promiseCache.keys()).forEach(key => promiseCache.delete(key));\n"],"names":["cdnRequest","productMapper","widgetSettingsMapper","productArrayMapper"],"mappings":"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"}
@@ -41,7 +41,7 @@ const getProductsAndSettings = async () => {
41
41
  return {
42
42
  products: productArrayMapper(products),
43
43
  widget_settings: widgetSettingsMapper(widget_settings),
44
- store_settings
44
+ store_settings: store_settings != null ? store_settings : {}
45
45
  };
46
46
  };
47
47
  const getProducts = async () => {
@@ -1 +1 @@
1
- {"version":3,"file":"cdn.js","sources":["../../../src/api/cdn.ts"],"sourcesContent":["import {\n CDNWidgetSettings,\n CDNStoreSettings,\n CDNWidgetSettingsResource,\n CDNProductsAndSettings,\n CDNProductResource,\n CDNProduct,\n CDNProductAndSettings,\n CDNProductsAndSettingsResource,\n CDNBundleSettings,\n CDNProductKeyObject,\n} from '../types';\nimport { productArrayMapper, productMapper, widgetSettingsMapper } from '../mappers/cdn';\nimport { cdnRequest } from '../utils/request';\n\nconst CDN_VERSION = '2020-12';\n\n// Default store settings if none are provided from the cdn\nconst DEFAULT_STORE_SETTINGS: CDNStoreSettings = {\n store_currency: {\n currency_code: 'USD',\n currency_symbol: '$',\n decimal_separator: '.',\n thousands_separator: ',',\n currency_symbol_location: 'left',\n },\n};\n\nconst promiseCache = new Map();\n\n// This will cache the request and use the same promise anywhere we call this function. This will never make multiple calls and always return the first request\nfunction cacheRequest<T>(cacheKey: string, request: () => T): T {\n if (!promiseCache.has(cacheKey)) {\n promiseCache.set(cacheKey, request());\n }\n return promiseCache.get(cacheKey);\n}\n\nexport const getProduct = async (externalProductId: string | number): Promise<CDNProduct> => {\n const { product } = await cacheRequest(`product.${externalProductId}`, () =>\n cdnRequest<CDNProductResource>('get', `/product/${CDN_VERSION}/${externalProductId}.json`)\n );\n\n return productMapper(product);\n};\n\nexport const getStoreSettings = async (): Promise<CDNStoreSettings> => {\n const storeSettings = await cacheRequest('storeSettings', () =>\n cdnRequest<CDNStoreSettings>('get', `/${CDN_VERSION}/store_settings.json`).catch(() => {\n return DEFAULT_STORE_SETTINGS;\n })\n );\n return storeSettings;\n};\n\nexport const getWidgetSettings = async (): Promise<CDNWidgetSettings> => {\n const { widget_settings } = await cacheRequest('widgetSettings', () =>\n cdnRequest<CDNWidgetSettingsResource>('get', `/${CDN_VERSION}/widget_settings.json`)\n );\n\n const widgetSettings = widgetSettingsMapper(widget_settings);\n\n return widgetSettings;\n};\n\nexport const getProductsAndSettings = async (): Promise<CDNProductsAndSettings> => {\n const { products, widget_settings, store_settings, meta } = await cacheRequest('productsAndSettings', () =>\n cdnRequest<CDNProductsAndSettingsResource>('get', `/product/${CDN_VERSION}/products.json`)\n );\n\n if (meta?.status === 'error') {\n return Promise.reject(meta.message);\n }\n\n return {\n products: productArrayMapper(products),\n widget_settings: widgetSettingsMapper(widget_settings),\n store_settings,\n };\n};\n\nexport const getProducts = async (): Promise<CDNProductKeyObject[]> => {\n const { products } = await getProductsAndSettings();\n return products;\n};\n\nexport const getProductAndSettings = async (externalProductId: string | number): Promise<CDNProductAndSettings> => {\n const [product, store_settings, widget_settings] = await Promise.all([\n getProduct(externalProductId),\n getStoreSettings(),\n getWidgetSettings(),\n ]);\n\n return {\n product,\n store_settings,\n widget_settings,\n storeSettings: store_settings,\n widgetSettings: widget_settings,\n };\n};\n\nexport const getBundleSettings = async (\n externalProductId: string | number\n): Promise<CDNBundleSettings | null | undefined> => {\n const { bundle_product } = await getProduct(externalProductId);\n\n return bundle_product;\n};\n\nexport const resetCache = () => Array.from(promiseCache.keys()).forEach(key => promiseCache.delete(key));\n"],"names":[],"mappings":"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"}
1
+ {"version":3,"file":"cdn.js","sources":["../../../src/api/cdn.ts"],"sourcesContent":["import {\n CDNWidgetSettings,\n CDNStoreSettings,\n CDNWidgetSettingsResource,\n CDNProductsAndSettings,\n CDNProductResource,\n CDNProduct,\n CDNProductAndSettings,\n CDNProductsAndSettingsResource,\n CDNBundleSettings,\n CDNProductKeyObject,\n} from '../types';\nimport { productArrayMapper, productMapper, widgetSettingsMapper } from '../mappers/cdn';\nimport { cdnRequest } from '../utils/request';\n\nconst CDN_VERSION = '2020-12';\n\n// Default store settings if none are provided from the cdn\nconst DEFAULT_STORE_SETTINGS: CDNStoreSettings = {\n store_currency: {\n currency_code: 'USD',\n currency_symbol: '$',\n decimal_separator: '.',\n thousands_separator: ',',\n currency_symbol_location: 'left',\n },\n};\n\nconst promiseCache = new Map();\n\n// This will cache the request and use the same promise anywhere we call this function. This will never make multiple calls and always return the first request\nfunction cacheRequest<T>(cacheKey: string, request: () => T): T {\n if (!promiseCache.has(cacheKey)) {\n promiseCache.set(cacheKey, request());\n }\n return promiseCache.get(cacheKey);\n}\n\nexport const getProduct = async (externalProductId: string | number): Promise<CDNProduct> => {\n const { product } = await cacheRequest(`product.${externalProductId}`, () =>\n cdnRequest<CDNProductResource>('get', `/product/${CDN_VERSION}/${externalProductId}.json`)\n );\n\n return productMapper(product);\n};\n\nexport const getStoreSettings = async (): Promise<CDNStoreSettings> => {\n const storeSettings = await cacheRequest('storeSettings', () =>\n cdnRequest<CDNStoreSettings>('get', `/${CDN_VERSION}/store_settings.json`).catch(() => {\n return DEFAULT_STORE_SETTINGS;\n })\n );\n return storeSettings;\n};\n\nexport const getWidgetSettings = async (): Promise<CDNWidgetSettings> => {\n const { widget_settings } = await cacheRequest('widgetSettings', () =>\n cdnRequest<CDNWidgetSettingsResource>('get', `/${CDN_VERSION}/widget_settings.json`)\n );\n\n const widgetSettings = widgetSettingsMapper(widget_settings);\n\n return widgetSettings;\n};\n\nexport const getProductsAndSettings = async (): Promise<CDNProductsAndSettings> => {\n const { products, widget_settings, store_settings, meta } = await cacheRequest('productsAndSettings', () =>\n cdnRequest<CDNProductsAndSettingsResource>('get', `/product/${CDN_VERSION}/products.json`)\n );\n\n if (meta?.status === 'error') {\n return Promise.reject(meta.message);\n }\n\n return {\n products: productArrayMapper(products),\n widget_settings: widgetSettingsMapper(widget_settings),\n store_settings: store_settings ?? {},\n };\n};\n\nexport const getProducts = async (): Promise<CDNProductKeyObject[]> => {\n const { products } = await getProductsAndSettings();\n return products;\n};\n\nexport const getProductAndSettings = async (externalProductId: string | number): Promise<CDNProductAndSettings> => {\n const [product, store_settings, widget_settings] = await Promise.all([\n getProduct(externalProductId),\n getStoreSettings(),\n getWidgetSettings(),\n ]);\n\n return {\n product,\n store_settings,\n widget_settings,\n storeSettings: store_settings,\n widgetSettings: widget_settings,\n };\n};\n\nexport const getBundleSettings = async (\n externalProductId: string | number\n): Promise<CDNBundleSettings | null | undefined> => {\n const { bundle_product } = await getProduct(externalProductId);\n\n return bundle_product;\n};\n\nexport const resetCache = () => Array.from(promiseCache.keys()).forEach(key => promiseCache.delete(key));\n"],"names":[],"mappings":"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"}
package/dist/index.d.ts CHANGED
@@ -563,7 +563,7 @@ interface CDNProductsAndSettingsResource {
563
563
  [key: string]: CDNProductRaw;
564
564
  }[];
565
565
  widget_settings: CDNWidgetSettingsRaw;
566
- store_settings: CDNStoreSettings;
566
+ store_settings?: CDNStoreSettings;
567
567
  meta?: {
568
568
  status: string;
569
569
  message: string;
@@ -649,7 +649,7 @@ interface CDNProductAndSettings {
649
649
  interface CDNProductsAndSettings {
650
650
  products: CDNProductKeyObject[];
651
651
  widget_settings: CDNWidgetSettings;
652
- store_settings: CDNStoreSettings;
652
+ store_settings: Partial<CDNStoreSettings>;
653
653
  }
654
654
  interface CDNBaseWidgetSettings {
655
655
  active_color: ColorString;
@@ -20,5 +20,5 @@
20
20
  * @license Long.js (c) 2013 Daniel Wirtz <dcode@dcode.io>
21
21
  * Released under the Apache License, Version 2.0
22
22
  * see: https://github.com/dcodeIO/Long.js for details
23
- */(function(e,t){typeof zb=="function"&&!0&&r&&r.exports?r.exports=t():(e.dcodeIO=e.dcodeIO||{}).Long=t()})(te,function(){function e(l,u,p){this.low=l|0,this.high=u|0,this.unsigned=!!p}e.__isLong__,Object.defineProperty(e.prototype,"__isLong__",{value:!0,enumerable:!1,configurable:!1}),e.isLong=function(u){return(u&&u.__isLong__)===!0};var t={},n={};e.fromInt=function(u,p){var d,_;return p?(u=u>>>0,0<=u&&u<256&&(_=n[u],_)?_:(d=new e(u,(u|0)<0?-1:0,!0),0<=u&&u<256&&(n[u]=d),d)):(u=u|0,-128<=u&&u<128&&(_=t[u],_)?_:(d=new e(u,u<0?-1:0,!1),-128<=u&&u<128&&(t[u]=d),d))},e.fromNumber=function(u,p){return p=!!p,isNaN(u)||!isFinite(u)?e.ZERO:!p&&u<=-s?e.MIN_VALUE:!p&&u+1>=s?e.MAX_VALUE:p&&u>=f?e.MAX_UNSIGNED_VALUE:u<0?e.fromNumber(-u,p).negate():new e(u%o|0,u/o|0,p)},e.fromBits=function(u,p,d){return new e(u,p,d)},e.fromString=function(u,p,d){if(u.length===0)throw Error("number format error: empty string");if(u==="NaN"||u==="Infinity"||u==="+Infinity"||u==="-Infinity")return e.ZERO;if(typeof p=="number"&&(d=p,p=!1),d=d||10,d<2||36<d)throw Error("radix out of range: "+d);var _;if((_=u.indexOf("-"))>0)throw Error('number format error: interior "-" character: '+u);if(_===0)return e.fromString(u.substring(1),p,d).negate();for(var E=e.fromNumber(Math.pow(d,8)),$=e.ZERO,b=0;b<u.length;b+=8){var S=Math.min(8,u.length-b),h=parseInt(u.substring(b,b+S),d);if(S<8){var A=e.fromNumber(Math.pow(d,S));$=$.multiply(A).add(e.fromNumber(h))}else $=$.multiply(E),$=$.add(e.fromNumber(h))}return $.unsigned=p,$},e.fromValue=function(u){return u instanceof e?u:typeof u=="number"?e.fromNumber(u):typeof u=="string"?e.fromString(u):new e(u.low,u.high,u.unsigned)};var i=1<<16,a=1<<24,o=i*i,f=o*o,s=f/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(u){if(u=u||10,u<2||36<u)throw RangeError("radix out of range: "+u);if(this.isZero())return"0";var p;if(this.isNegative())if(this.equals(e.MIN_VALUE)){var d=e.fromNumber(u),_=this.divide(d);return p=_.multiply(d).subtract(this),_.toString(u)+p.toInt().toString(u)}else return"-"+this.negate().toString(u);var E=e.fromNumber(Math.pow(u,6),this.unsigned);p=this;for(var $="";;){var b=p.divide(E),S=p.subtract(b.multiply(E)).toInt()>>>0,h=S.toString(u);if(p=b,p.isZero())return h+$;for(;h.length<6;)h="0"+h;$=""+h+$}},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 u=this.high!=0?this.high:this.low,p=31;p>0&&(u&1<<p)==0;p--);return this.high!=0?p+33:p+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(u){return e.isLong(u)||(u=e.fromValue(u)),this.unsigned!==u.unsigned&&this.high>>>31===1&&u.high>>>31===1?!1:this.high===u.high&&this.low===u.low},e.eq=e.prototype.equals,e.prototype.notEquals=function(u){return!this.equals(u)},e.neq=e.prototype.notEquals,e.prototype.lessThan=function(u){return this.compare(u)<0},e.prototype.lt=e.prototype.lessThan,e.prototype.lessThanOrEqual=function(u){return this.compare(u)<=0},e.prototype.lte=e.prototype.lessThanOrEqual,e.prototype.greaterThan=function(u){return this.compare(u)>0},e.prototype.gt=e.prototype.greaterThan,e.prototype.greaterThanOrEqual=function(u){return this.compare(u)>=0},e.prototype.gte=e.prototype.greaterThanOrEqual,e.prototype.compare=function(u){if(e.isLong(u)||(u=e.fromValue(u)),this.equals(u))return 0;var p=this.isNegative(),d=u.isNegative();return p&&!d?-1:!p&&d?1:this.unsigned?u.high>>>0>this.high>>>0||u.high===this.high&&u.low>>>0>this.low>>>0?-1:1:this.subtract(u).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(u){e.isLong(u)||(u=e.fromValue(u));var p=this.high>>>16,d=this.high&65535,_=this.low>>>16,E=this.low&65535,$=u.high>>>16,b=u.high&65535,S=u.low>>>16,h=u.low&65535,A=0,x=0,R=0,m=0;return m+=E+h,R+=m>>>16,m&=65535,R+=_+S,x+=R>>>16,R&=65535,x+=d+b,A+=x>>>16,x&=65535,A+=p+$,A&=65535,e.fromBits(R<<16|m,A<<16|x,this.unsigned)},e.prototype.subtract=function(u){return e.isLong(u)||(u=e.fromValue(u)),this.add(u.negate())},e.prototype.sub=e.prototype.subtract,e.prototype.multiply=function(u){if(this.isZero()||(e.isLong(u)||(u=e.fromValue(u)),u.isZero()))return e.ZERO;if(this.equals(e.MIN_VALUE))return u.isOdd()?e.MIN_VALUE:e.ZERO;if(u.equals(e.MIN_VALUE))return this.isOdd()?e.MIN_VALUE:e.ZERO;if(this.isNegative())return u.isNegative()?this.negate().multiply(u.negate()):this.negate().multiply(u).negate();if(u.isNegative())return this.multiply(u.negate()).negate();if(this.lessThan(c)&&u.lessThan(c))return e.fromNumber(this.toNumber()*u.toNumber(),this.unsigned);var p=this.high>>>16,d=this.high&65535,_=this.low>>>16,E=this.low&65535,$=u.high>>>16,b=u.high&65535,S=u.low>>>16,h=u.low&65535,A=0,x=0,R=0,m=0;return m+=E*h,R+=m>>>16,m&=65535,R+=_*h,x+=R>>>16,R&=65535,R+=E*S,x+=R>>>16,R&=65535,x+=d*h,A+=x>>>16,x&=65535,x+=_*S,A+=x>>>16,x&=65535,x+=E*b,A+=x>>>16,x&=65535,A+=p*h+d*S+_*b+E*$,A&=65535,e.fromBits(R<<16|m,A<<16|x,this.unsigned)},e.prototype.mul=e.prototype.multiply,e.prototype.divide=function(u){if(e.isLong(u)||(u=e.fromValue(u)),u.isZero())throw new Error("division by zero");if(this.isZero())return this.unsigned?e.UZERO:e.ZERO;var p,d,_;if(this.equals(e.MIN_VALUE)){if(u.equals(e.ONE)||u.equals(e.NEG_ONE))return e.MIN_VALUE;if(u.equals(e.MIN_VALUE))return e.ONE;var E=this.shiftRight(1);return p=E.divide(u).shiftLeft(1),p.equals(e.ZERO)?u.isNegative()?e.ONE:e.NEG_ONE:(d=this.subtract(u.multiply(p)),_=p.add(d.divide(u)),_)}else if(u.equals(e.MIN_VALUE))return this.unsigned?e.UZERO:e.ZERO;if(this.isNegative())return u.isNegative()?this.negate().divide(u.negate()):this.negate().divide(u).negate();if(u.isNegative())return this.divide(u.negate()).negate();for(_=e.ZERO,d=this;d.greaterThanOrEqual(u);){p=Math.max(1,Math.floor(d.toNumber()/u.toNumber()));for(var $=Math.ceil(Math.log(p)/Math.LN2),b=$<=48?1:Math.pow(2,$-48),S=e.fromNumber(p),h=S.multiply(u);h.isNegative()||h.greaterThan(d);)p-=b,S=e.fromNumber(p,this.unsigned),h=S.multiply(u);S.isZero()&&(S=e.ONE),_=_.add(S),d=d.subtract(h)}return _},e.prototype.div=e.prototype.divide,e.prototype.modulo=function(u){return e.isLong(u)||(u=e.fromValue(u)),this.subtract(this.divide(u).multiply(u))},e.prototype.mod=e.prototype.modulo,e.prototype.not=function(){return e.fromBits(~this.low,~this.high,this.unsigned)},e.prototype.and=function(u){return e.isLong(u)||(u=e.fromValue(u)),e.fromBits(this.low&u.low,this.high&u.high,this.unsigned)},e.prototype.or=function(u){return e.isLong(u)||(u=e.fromValue(u)),e.fromBits(this.low|u.low,this.high|u.high,this.unsigned)},e.prototype.xor=function(u){return e.isLong(u)||(u=e.fromValue(u)),e.fromBits(this.low^u.low,this.high^u.high,this.unsigned)},e.prototype.shiftLeft=function(u){return e.isLong(u)&&(u=u.toInt()),(u&=63)===0?this:u<32?e.fromBits(this.low<<u,this.high<<u|this.low>>>32-u,this.unsigned):e.fromBits(0,this.low<<u-32,this.unsigned)},e.prototype.shl=e.prototype.shiftLeft,e.prototype.shiftRight=function(u){return e.isLong(u)&&(u=u.toInt()),(u&=63)===0?this:u<32?e.fromBits(this.low>>>u|this.high<<32-u,this.high>>u,this.unsigned):e.fromBits(this.high>>u-32,this.high>=0?0:-1,this.unsigned)},e.prototype.shr=e.prototype.shiftRight,e.prototype.shiftRightUnsigned=function(u){if(e.isLong(u)&&(u=u.toInt()),u&=63,u===0)return this;var p=this.high;if(u<32){var d=this.low;return e.fromBits(d>>>u|p<<32-u,p>>>u,this.unsigned)}else return u===32?e.fromBits(p,0,this.unsigned):e.fromBits(p>>>u-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})})(ei),Object.defineProperty(dt,"__esModule",{value:!0}),dt.Hyper=void 0;var Xb=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}}(),No=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)}},Yb=ei.exports,dr=Co(Yb),Kb=M,Zb=Co(Kb);function Co(r){return r&&r.__esModule?r:{default:r}}function Jb(r,e){if(!(r instanceof e))throw new TypeError("Cannot call a class as a function")}function Qb(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 ew(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 vr=dt.Hyper=function(r){ew(e,r),Xb(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=No(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=No(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 Jb(this,e),Qb(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,t,n,!1))}return e}(dr.default);(0,Zb.default)(vr),vr.MAX_VALUE=new vr(dr.default.MAX_VALUE.low,dr.default.MAX_VALUE.high),vr.MIN_VALUE=new vr(dr.default.MIN_VALUE.low,dr.default.MIN_VALUE.high);var Pe={};Object.defineProperty(Pe,"__esModule",{value:!0}),Pe.UnsignedInt=void 0;var rw=et,Lo=jo(rw),tw=M,nw=jo(tw);function jo(r){return r&&r.__esModule?r:{default:r}}var gr=Pe.UnsignedInt={read:function(e){return e.readUInt32BE()},write:function(e,t){if(!(0,Lo.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,Lo.default)(e)||Math.floor(e)!==e?!1:e>=gr.MIN_VALUE&&e<=gr.MAX_VALUE}};gr.MAX_VALUE=Math.pow(2,32)-1,gr.MIN_VALUE=0,(0,nw.default)(gr);var vt={};Object.defineProperty(vt,"__esModule",{value:!0}),vt.UnsignedHyper=void 0;var iw=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}}(),ko=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)}},aw=ei.exports,_r=Vo(aw),ow=M,uw=Vo(ow);function Vo(r){return r&&r.__esModule?r:{default:r}}function fw(r,e){if(!(r instanceof e))throw new TypeError("Cannot call a class as a function")}function sw(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 cw(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 mr=vt.UnsignedHyper=function(r){cw(e,r),iw(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=ko(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=ko(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 fw(this,e),sw(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,t,n,!0))}return e}(_r.default);(0,uw.default)(mr),mr.MAX_VALUE=new mr(_r.default.MAX_UNSIGNED_VALUE.low,_r.default.MAX_UNSIGNED_VALUE.high),mr.MIN_VALUE=new mr(_r.default.MIN_VALUE.low,_r.default.MIN_VALUE.high);var gt={};Object.defineProperty(gt,"__esModule",{value:!0}),gt.Float=void 0;var lw=et,qo=Go(lw),pw=M,hw=Go(pw);function Go(r){return r&&r.__esModule?r:{default:r}}var yw=gt.Float={read:function(e){return e.readFloatBE()},write:function(e,t){if(!(0,qo.default)(e))throw new Error("XDR Write Error: not a number");t.writeFloatBE(e)},isValid:function(e){return(0,qo.default)(e)}};(0,hw.default)(yw);var _t={};Object.defineProperty(_t,"__esModule",{value:!0}),_t.Double=void 0;var dw=et,Ho=Wo(dw),vw=M,gw=Wo(vw);function Wo(r){return r&&r.__esModule?r:{default:r}}var _w=_t.Double={read:function(e){return e.readDoubleBE()},write:function(e,t){if(!(0,Ho.default)(e))throw new Error("XDR Write Error: not a number");t.writeDoubleBE(e)},isValid:function(e){return(0,Ho.default)(e)}};(0,gw.default)(_w);var mt={};Object.defineProperty(mt,"__esModule",{value:!0}),mt.Quadruple=void 0;var mw=M,bw=ww(mw);function ww(r){return r&&r.__esModule?r:{default:r}}var $w=mt.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,bw.default)($w);var br={},Ew=fe,Ow=H,Aw="[object Boolean]";function Sw(r){return r===!0||r===!1||Ow(r)&&Ew(r)==Aw}var Tw=Sw;Object.defineProperty(br,"__esModule",{value:!0}),br.Bool=void 0;var Iw=Tw,xw=Xo(Iw),zo=ue,Pw=M,Fw=Xo(Pw);function Xo(r){return r&&r.__esModule?r:{default:r}}var Rw=br.Bool={read:function(e){var t=zo.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 zo.Int.write(n,t)},isValid:function(e){return(0,xw.default)(e)}};(0,Fw.default)(Rw);var bt={},Mw=fe,Bw=C,Uw=H,Dw="[object String]";function Nw(r){return typeof r=="string"||!Bw(r)&&Uw(r)&&Mw(r)==Dw}var Yo=Nw;Object.defineProperty(bt,"__esModule",{value:!0}),bt.String=void 0;var Cw=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}}(),Lw=Yo,Ko=ri(Lw),jw=C,kw=ri(jw),Zo=ue,Vw=Pe,Jo=Ie,qw=M,Gw=ri(qw);function ri(r){return r&&r.__esModule?r:{default:r}}function Hw(r,e){if(!(r instanceof e))throw new TypeError("Cannot call a class as a function")}var Ww=bt.String=function(){function r(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Vw.UnsignedInt.MAX_VALUE;Hw(this,r),this._maxLength=e}return Cw(r,[{key:"read",value:function(t){var n=Zo.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,Jo.calculatePadding)(n),a=t.slice(n);return(0,Jo.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,Ko.default)(t)?i=y.from(t,"utf8"):i=y.from(t),Zo.Int.write(i.length,n),n.writeBufferPadded(i)}},{key:"isValid",value:function(t){var n=void 0;if((0,Ko.default)(t))n=y.from(t,"utf8");else if((0,kw.default)(t)||y.isBuffer(t))n=y.from(t);else return!1;return n.length<=this._maxLength}}]),r}();(0,Gw.default)(Ww.prototype);var wt={};Object.defineProperty(wt,"__esModule",{value:!0}),wt.Opaque=void 0;var zw=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}}(),Qo=Ie,Xw=M,Yw=Kw(Xw);function Kw(r){return r&&r.__esModule?r:{default:r}}function Zw(r,e){if(!(r instanceof e))throw new TypeError("Cannot call a class as a function")}var Jw=wt.Opaque=function(){function r(e){Zw(this,r),this._length=e,this._padding=(0,Qo.calculatePadding)(e)}return zw(r,[{key:"read",value:function(t){var n=t.slice(this._length);return(0,Qo.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 y.isBuffer(t)&&t.length===this._length}}]),r}();(0,Yw.default)(Jw.prototype);var $t={};Object.defineProperty($t,"__esModule",{value:!0}),$t.VarOpaque=void 0;var Qw=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}}(),eu=ue,e1=Pe,ru=Ie,r1=M,t1=n1(r1);function n1(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")}var a1=$t.VarOpaque=function(){function r(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:e1.UnsignedInt.MAX_VALUE;i1(this,r),this._maxLength=e}return Qw(r,[{key:"read",value:function(t){var n=eu.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,ru.calculatePadding)(n),a=t.slice(n);return(0,ru.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));eu.Int.write(t.length,n),n.writeBufferPadded(t)}},{key:"isValid",value:function(t){return y.isBuffer(t)&&t.length<=this._maxLength}}]),r}();(0,t1.default)(a1.prototype);var Et={},Fe={exports:{}};function o1(r,e){for(var t=-1,n=r==null?0:r.length;++t<n&&e(r[t],t,r)!==!1;);return r}var tu=o1,u1=tt;function f1(r){return typeof r=="function"?r:u1}var nu=f1,s1=tu,c1=Dn,l1=nu,p1=C;function h1(r,e){var t=p1(r)?s1:c1;return t(r,l1(e))}var y1=h1;(function(r){r.exports=y1})(Fe);var d1=/\s/;function v1(r){for(var e=r.length;e--&&d1.test(r.charAt(e)););return e}var g1=v1,_1=g1,m1=/^\s+/;function b1(r){return r&&r.slice(0,_1(r)+1).replace(m1,"")}var w1=b1,$1=w1,iu=ve,E1=pt,au=0/0,O1=/^[-+]0x[0-9a-f]+$/i,A1=/^0b[01]+$/i,S1=/^0o[0-7]+$/i,T1=parseInt;function I1(r){if(typeof r=="number")return r;if(E1(r))return au;if(iu(r)){var e=typeof r.valueOf=="function"?r.valueOf():r;r=iu(e)?e+"":e}if(typeof r!="string")return r===0?r:+r;r=$1(r);var t=A1.test(r);return t||S1.test(r)?T1(r.slice(2),t?2:8):O1.test(r)?au:+r}var x1=I1,P1=x1,ou=1/0,F1=17976931348623157e292;function R1(r){if(!r)return r===0?r:0;if(r=P1(r),r===ou||r===-ou){var e=r<0?-1:1;return e*F1}return r===r?r:0}var M1=R1,B1=M1;function U1(r){var e=B1(r),t=e%1;return e===e?t?e-t:e:0}var D1=U1,N1=Va,C1=nu,L1=D1,j1=9007199254740991,ti=4294967295,k1=Math.min;function V1(r,e){if(r=L1(r),r<1||r>j1)return[];var t=ti,n=k1(r,ti);e=C1(e),r-=ti;for(var i=N1(n,e);++t<r;)e(t);return i}var uu=V1;Object.defineProperty(Et,"__esModule",{value:!0}),Et.Array=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}}(),G1=Jn,H1=wr(G1),W1=Fe.exports,z1=wr(W1),X1=uu,Y1=wr(X1),K1=C,fu=wr(K1),Z1=M,J1=wr(Z1);function wr(r){return r&&r.__esModule?r:{default:r}}function Q1(r,e){if(!(r instanceof e))throw new TypeError("Cannot call a class as a function")}var e$=Et.Array=function(){function r(e,t){Q1(this,r),this._childType=e,this._length=t}return q1(r,[{key:"read",value:function(t){var n=this;return(0,Y1.default)(this._length,function(){return n._childType.read(t)})}},{key:"write",value:function(t,n){var i=this;if(!(0,fu.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,z1.default)(t,function(a){return i._childType.write(a,n)})}},{key:"isValid",value:function(t){var n=this;return!(0,fu.default)(t)||t.length!==this._length?!1:(0,H1.default)(t,function(i){return n._childType.isValid(i)})}}]),r}();(0,J1.default)(e$.prototype);var Ot={};Object.defineProperty(Ot,"__esModule",{value:!0}),Ot.VarArray=void 0;var r$=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}}(),t$=Jn,n$=$r(t$),i$=Fe.exports,a$=$r(i$),o$=uu,u$=$r(o$),f$=C,su=$r(f$),s$=Pe,cu=ue,c$=M,l$=$r(c$);function $r(r){return r&&r.__esModule?r:{default:r}}function p$(r,e){if(!(r instanceof e))throw new TypeError("Cannot call a class as a function")}var h$=Ot.VarArray=function(){function r(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:s$.UnsignedInt.MAX_VALUE;p$(this,r),this._childType=e,this._maxLength=t}return r$(r,[{key:"read",value:function(t){var n=this,i=cu.Int.read(t);if(i>this._maxLength)throw new Error("XDR Read Error: Saw "+i+" length VarArray,"+("max allowed is "+this._maxLength));return(0,u$.default)(i,function(){return n._childType.read(t)})}},{key:"write",value:function(t,n){var i=this;if(!(0,su.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));cu.Int.write(t.length,n),(0,a$.default)(t,function(a){return i._childType.write(a,n)})}},{key:"isValid",value:function(t){var n=this;return!(0,su.default)(t)||t.length>this._maxLength?!1:(0,n$.default)(t,function(i){return n._childType.isValid(i)})}}]),r}();(0,l$.default)(h$.prototype);var At={};function y$(r){return r===null}var d$=y$;function v$(r){return r===void 0}var Er=v$;Object.defineProperty(At,"__esModule",{value:!0}),At.Option=void 0;var g$=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}}(),_$=d$,lu=ni(_$),m$=Er,pu=ni(m$),hu=br,b$=M,w$=ni(b$);function ni(r){return r&&r.__esModule?r:{default:r}}function $$(r,e){if(!(r instanceof e))throw new TypeError("Cannot call a class as a function")}var E$=At.Option=function(){function r(e){$$(this,r),this._childType=e}return g$(r,[{key:"read",value:function(t){if(hu.Bool.read(t))return this._childType.read(t)}},{key:"write",value:function(t,n){var i=!((0,lu.default)(t)||(0,pu.default)(t));hu.Bool.write(i,n),i&&this._childType.write(t,n)}},{key:"isValid",value:function(t){return(0,lu.default)(t)||(0,pu.default)(t)?!0:this._childType.isValid(t)}}]),r}();(0,w$.default)(E$.prototype);var Or={};Object.defineProperty(Or,"__esModule",{value:!0}),Or.Void=void 0;var O$=Er,yu=du(O$),A$=M,S$=du(A$);function du(r){return r&&r.__esModule?r:{default:r}}var T$=Or.Void={read:function(){},write:function(e){if(!(0,yu.default)(e))throw new Error("XDR Write Error: trying to write value to a void slot")},isValid:function(e){return(0,yu.default)(e)}};(0,S$.default)(T$);var St={},I$=ht;function x$(r,e){return I$(e,function(t){return r[t]})}var P$=x$,F$=P$,R$=He;function M$(r){return r==null?[]:F$(r,R$(r))}var B$=M$;Object.defineProperty(St,"__esModule",{value:!0}),St.Enum=void 0;var U$=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}}(),D$=Fe.exports,N$=ii(D$),C$=B$,L$=ii(C$),vu=ue,j$=M,k$=ii(j$);function ii(r){return r&&r.__esModule?r:{default:r}}function V$(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 q$(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 gu(r,e){if(!(r instanceof e))throw new TypeError("Cannot call a class as a function")}var G$=St.Enum=function(){function r(e,t){gu(this,r),this.name=e,this.value=t}return U$(r,null,[{key:"read",value:function(t){var n=vu.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);vu.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,L$.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){q$(f,o);function f(){return gu(this,f),V$(this,(f.__proto__||Object.getPrototypeOf(f)).apply(this,arguments))}return f}(r);return a.enumName=n,t.results[n]=a,a._members={},a._byValue=new Map,(0,N$.default)(i,function(o,f){var s=new a(f,o);a._members[f]=s,a._byValue.set(o,s),a[f]=function(){return s}}),a}}]),r}();(0,k$.default)(G$);var Tt={},H$=Dn,W$=cr;function z$(r,e){var t=-1,n=W$(r)?Array(r.length):[];return H$(r,function(i,a,o){n[++t]=e(i,a,o)}),n}var X$=z$,Y$=ht,K$=Fo,Z$=X$,J$=C;function Q$(r,e){var t=J$(r)?Y$:Z$;return t(r,K$(e))}var eE=Q$;function rE(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 tE=rE,Ar={};Object.defineProperty(Ar,"__esModule",{value:!0});var nE=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 iE(r,e){if(!(r instanceof e))throw new TypeError("Cannot call a class as a function")}Ar.Reference=function(){function r(){iE(this,r)}return nE(r,[{key:"resolve",value:function(){throw new Error("implement resolve in child class")}}]),r}(),Object.defineProperty(Tt,"__esModule",{value:!0}),Tt.Struct=void 0;var It=function(){function r(e,t){var n=[],i=!0,a=!1,o=void 0;try{for(var f=e[Symbol.iterator](),s;!(i=(s=f.next()).done)&&(n.push(s.value),!(t&&n.length===t));i=!0);}catch(c){a=!0,o=c}finally{try{!i&&f.return&&f.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")}}(),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}}(),oE=Fe.exports,_u=Sr(oE),uE=eE,fE=Sr(uE),sE=Er,cE=Sr(sE),lE=tE,pE=Sr(lE),hE=Ar,yE=M,dE=Sr(yE);function Sr(r){return r&&r.__esModule?r:{default:r}}function vE(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 gE(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 mu(r,e){if(!(r instanceof e))throw new TypeError("Cannot call a class as a function")}var _E=Tt.Struct=function(){function r(e){mu(this,r),this._attributes=e||{}}return aE(r,null,[{key:"read",value:function(t){var n=(0,fE.default)(this._fields,function(i){var a=It(i,2),o=a[0],f=a[1],s=f.read(t);return[o,s]});return new this((0,pE.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,_u.default)(this._fields,function(i){var a=It(i,2),o=a[0],f=a[1],s=t._attributes[o];f.write(s,n)})}},{key:"isValid",value:function(t){return t instanceof this}},{key:"create",value:function(t,n,i){var a=function(o){gE(f,o);function f(){return mu(this,f),vE(this,(f.__proto__||Object.getPrototypeOf(f)).apply(this,arguments))}return f}(r);return a.structName=n,t.results[n]=a,a._fields=i.map(function(o){var f=It(o,2),s=f[0],c=f[1];return c instanceof hE.Reference&&(c=c.resolve(t)),[s,c]}),(0,_u.default)(a._fields,function(o){var f=It(o,1),s=f[0];a.prototype[s]=mE(s)}),a}}]),r}();(0,dE.default)(_E);function mE(r){return function(t){return(0,cE.default)(t)||(this._attributes[r]=t),this._attributes[r]}}var xt={};Object.defineProperty(xt,"__esModule",{value:!0}),xt.Union=void 0;var bE=function(){function r(e,t){var n=[],i=!0,a=!1,o=void 0;try{for(var f=e[Symbol.iterator](),s;!(i=(s=f.next()).done)&&(n.push(s.value),!(t&&n.length===t));i=!0);}catch(c){a=!0,o=c}finally{try{!i&&f.return&&f.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")}}(),wE=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}}(),$E=Fe.exports,Pt=Rt($E),EE=Er,bu=Rt(EE),OE=Yo,wu=Rt(OE),Ft=Or,ai=Ar,AE=M,SE=Rt(AE);function Rt(r){return r&&r.__esModule?r:{default:r}}function TE(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 IE(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 $u(r,e){if(!(r instanceof e))throw new TypeError("Cannot call a class as a function")}var xE=xt.Union=function(){function r(e,t){$u(this,r),this.set(e,t)}return wE(r,[{key:"set",value:function(t,n){(0,wu.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!==Ft.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===Ft.Void?Ft.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,bu.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(f){IE(s,f);function s(){return $u(this,s),TE(this,(s.__proto__||Object.getPrototypeOf(s)).apply(this,arguments))}return s}(r);a.unionName=n,t.results[n]=a,i.switchOn instanceof ai.Reference?a._switchOn=i.switchOn.resolve(t):a._switchOn=i.switchOn,a._switches=new Map,a._arms={},(0,Pt.default)(i.arms,function(f,s){f instanceof ai.Reference&&(f=f.resolve(t)),a._arms[s]=f});var o=i.defaultArm;return o instanceof ai.Reference&&(o=o.resolve(t)),a._defaultArm=o,(0,Pt.default)(i.switches,function(f){var s=bE(f,2),c=s[0],l=s[1];(0,wu.default)(c)&&(c=a._switchOn.fromName(c)),a._switches.set(c,l)}),(0,bu.default)(a._switchOn.values)||(0,Pt.default)(a._switchOn.values(),function(f){a[f.name]=function(s){return new a(f,s)},a.prototype[f.name]=function(c){return this.set(f,c)}}),(0,Pt.default)(a._arms,function(f,s){f!==Ft.Void&&(a.prototype[s]=function(){return this.get(s)})}),a}}]),r}();(0,SE.default)(xE),function(r){Object.defineProperty(r,"__esModule",{value:!0});var e=ue;Object.keys(e).forEach(function(h){h==="default"||h==="__esModule"||Object.defineProperty(r,h,{enumerable:!0,get:function(){return e[h]}})});var t=dt;Object.keys(t).forEach(function(h){h==="default"||h==="__esModule"||Object.defineProperty(r,h,{enumerable:!0,get:function(){return t[h]}})});var n=Pe;Object.keys(n).forEach(function(h){h==="default"||h==="__esModule"||Object.defineProperty(r,h,{enumerable:!0,get:function(){return n[h]}})});var i=vt;Object.keys(i).forEach(function(h){h==="default"||h==="__esModule"||Object.defineProperty(r,h,{enumerable:!0,get:function(){return i[h]}})});var a=gt;Object.keys(a).forEach(function(h){h==="default"||h==="__esModule"||Object.defineProperty(r,h,{enumerable:!0,get:function(){return a[h]}})});var o=_t;Object.keys(o).forEach(function(h){h==="default"||h==="__esModule"||Object.defineProperty(r,h,{enumerable:!0,get:function(){return o[h]}})});var f=mt;Object.keys(f).forEach(function(h){h==="default"||h==="__esModule"||Object.defineProperty(r,h,{enumerable:!0,get:function(){return f[h]}})});var s=br;Object.keys(s).forEach(function(h){h==="default"||h==="__esModule"||Object.defineProperty(r,h,{enumerable:!0,get:function(){return s[h]}})});var c=bt;Object.keys(c).forEach(function(h){h==="default"||h==="__esModule"||Object.defineProperty(r,h,{enumerable:!0,get:function(){return c[h]}})});var l=wt;Object.keys(l).forEach(function(h){h==="default"||h==="__esModule"||Object.defineProperty(r,h,{enumerable:!0,get:function(){return l[h]}})});var u=$t;Object.keys(u).forEach(function(h){h==="default"||h==="__esModule"||Object.defineProperty(r,h,{enumerable:!0,get:function(){return u[h]}})});var p=Et;Object.keys(p).forEach(function(h){h==="default"||h==="__esModule"||Object.defineProperty(r,h,{enumerable:!0,get:function(){return p[h]}})});var d=Ot;Object.keys(d).forEach(function(h){h==="default"||h==="__esModule"||Object.defineProperty(r,h,{enumerable:!0,get:function(){return d[h]}})});var _=At;Object.keys(_).forEach(function(h){h==="default"||h==="__esModule"||Object.defineProperty(r,h,{enumerable:!0,get:function(){return _[h]}})});var E=Or;Object.keys(E).forEach(function(h){h==="default"||h==="__esModule"||Object.defineProperty(r,h,{enumerable:!0,get:function(){return E[h]}})});var $=St;Object.keys($).forEach(function(h){h==="default"||h==="__esModule"||Object.defineProperty(r,h,{enumerable:!0,get:function(){return $[h]}})});var b=Tt;Object.keys(b).forEach(function(h){h==="default"||h==="__esModule"||Object.defineProperty(r,h,{enumerable:!0,get:function(){return b[h]}})});var S=xt;Object.keys(S).forEach(function(h){h==="default"||h==="__esModule"||Object.defineProperty(r,h,{enumerable:!0,get:function(){return S[h]}})})}(In);var Eu={};(function(r){Object.defineProperty(r,"__esModule",{value:!0});var e=function(){function m(v,g){for(var w=0;w<g.length;w++){var O=g[w];O.enumerable=O.enumerable||!1,O.configurable=!0,"value"in O&&(O.writable=!0),Object.defineProperty(v,O.key,O)}}return function(v,g,w){return g&&m(v.prototype,g),w&&m(v,w),v}}(),t=Ar;Object.keys(t).forEach(function(m){m==="default"||m==="__esModule"||Object.defineProperty(r,m,{enumerable:!0,get:function(){return t[m]}})}),r.config=_;var n=Er,i=l(n),a=Fe.exports,o=l(a),f=In,s=c(f);function c(m){if(m&&m.__esModule)return m;var v={};if(m!=null)for(var g in m)Object.prototype.hasOwnProperty.call(m,g)&&(v[g]=m[g]);return v.default=m,v}function l(m){return m&&m.__esModule?m:{default:m}}function u(m,v){if(!(m instanceof v))throw new TypeError("Cannot call a class as a function")}function p(m,v){if(!m)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return v&&(typeof v=="object"||typeof v=="function")?v:m}function d(m,v){if(typeof v!="function"&&v!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof v);m.prototype=Object.create(v&&v.prototype,{constructor:{value:m,enumerable:!1,writable:!0,configurable:!0}}),v&&(Object.setPrototypeOf?Object.setPrototypeOf(m,v):m.__proto__=v)}function _(m){var v=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(m){var g=new R(v);m(g),g.resolve()}return v}var E=function(m){d(v,m);function v(g){u(this,v);var w=p(this,(v.__proto__||Object.getPrototypeOf(v)).call(this));return w.name=g,w}return e(v,[{key:"resolve",value:function(w){var O=w.definitions[this.name];return O.resolve(w)}}]),v}(t.Reference),$=function(m){d(v,m);function v(g,w){var O=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;u(this,v);var L=p(this,(v.__proto__||Object.getPrototypeOf(v)).call(this));return L.childReference=g,L.length=w,L.variable=O,L}return e(v,[{key:"resolve",value:function(w){var O=this.childReference,L=this.length;return O instanceof t.Reference&&(O=O.resolve(w)),L instanceof t.Reference&&(L=L.resolve(w)),this.variable?new s.VarArray(O,L):new s.Array(O,L)}}]),v}(t.Reference),b=function(m){d(v,m);function v(g){u(this,v);var w=p(this,(v.__proto__||Object.getPrototypeOf(v)).call(this));return w.childReference=g,w.name=g.name,w}return e(v,[{key:"resolve",value:function(w){var O=this.childReference;return O instanceof t.Reference&&(O=O.resolve(w)),new s.Option(O)}}]),v}(t.Reference),S=function(m){d(v,m);function v(g,w){u(this,v);var O=p(this,(v.__proto__||Object.getPrototypeOf(v)).call(this));return O.sizedType=g,O.length=w,O}return e(v,[{key:"resolve",value:function(w){var O=this.length;return O instanceof t.Reference&&(O=O.resolve(w)),new this.sizedType(O)}}]),v}(t.Reference),h=function(){function m(v,g,w){u(this,m),this.constructor=v,this.name=g,this.config=w}return e(m,[{key:"resolve",value:function(g){return this.name in g.results?g.results[this.name]:this.constructor(g,this.name,this.config)}}]),m}();function A(m,v,g){return g instanceof t.Reference&&(g=g.resolve(m)),m.results[v]=g,g}function x(m,v,g){return m.results[v]=g,g}var R=function(){function m(v){u(this,m),this._destination=v,this._definitions={}}return e(m,[{key:"enum",value:function(g,w){var O=new h(s.Enum.create,g,w);this.define(g,O)}},{key:"struct",value:function(g,w){var O=new h(s.Struct.create,g,w);this.define(g,O)}},{key:"union",value:function(g,w){var O=new h(s.Union.create,g,w);this.define(g,O)}},{key:"typedef",value:function(g,w){var O=new h(A,g,w);this.define(g,O)}},{key:"const",value:function(g,w){var O=new h(x,g,w);this.define(g,O)}},{key:"void",value:function(){return s.Void}},{key:"bool",value:function(){return s.Bool}},{key:"int",value:function(){return s.Int}},{key:"hyper",value:function(){return s.Hyper}},{key:"uint",value:function(){return s.UnsignedInt}},{key:"uhyper",value:function(){return s.UnsignedHyper}},{key:"float",value:function(){return s.Float}},{key:"double",value:function(){return s.Double}},{key:"quadruple",value:function(){return s.Quadruple}},{key:"string",value:function(g){return new S(s.String,g)}},{key:"opaque",value:function(g){return new S(s.Opaque,g)}},{key:"varOpaque",value:function(g){return new S(s.VarOpaque,g)}},{key:"array",value:function(g,w){return new $(g,w)}},{key:"varArray",value:function(g,w){return new $(g,w,!0)}},{key:"option",value:function(g){return new b(g)}},{key:"define",value:function(g,w){if((0,i.default)(this._destination[g]))this._definitions[g]=w;else throw new Error("XDRTypes Error:"+g+" is already defined")}},{key:"lookup",value:function(g){return new E(g)}},{key:"resolve",value:function(){var g=this;(0,o.default)(this._definitions,function(w){w.resolve({definitions:g._definitions,results:g._destination})})}}]),m}()})(Eu),function(r){Object.defineProperty(r,"__esModule",{value:!0});var e=In;Object.keys(e).forEach(function(n){n==="default"||n==="__esModule"||Object.defineProperty(r,n,{enumerable:!0,get:function(){return e[n]}})});var t=Eu;Object.keys(t).forEach(function(n){n==="default"||n==="__esModule"||Object.defineProperty(r,n,{enumerable:!0,get:function(){return t[n]}})})}(Oa),Object.defineProperty(Qr,"__esModule",{value:!0}),Qr.xdr=void 0;const PE=(0,Oa.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")}})});Qr.xdr=PE,Object.defineProperty(oe,"__esModule",{value:!0}),oe.decodeToLegacyBoxOrder=oe.encodeLegacyBoxOrder=oe.toBundle=Au=oe.toLineItemProperty=void 0;const ee=Qr;function Ou(r){let e={variantId:ee.xdr.Uint64.fromString(r.variantId.toString()),version:r.version||Math.floor(Date.now()/1e3),items:r.items.map(n=>new ee.xdr.BundleItem({collectionId:ee.xdr.Uint64.fromString(n.collectionId.toString()),productId:ee.xdr.Uint64.fromString(n.productId.toString()),variantId:ee.xdr.Uint64.fromString(n.variantId.toString()),sku:n.sku||"",quantity:n.quantity,ext:new ee.xdr.BundleItemExt(0)})),ext:new ee.xdr.BundleExt(0)};const t=new ee.xdr.Bundle(e);return ee.xdr.BundleEnvelope.envelopeTypeBundle(t).toXDR("base64")}var Au=oe.toLineItemProperty=Ou;function Su(r){const e=ee.xdr.BundleEnvelope.fromXDR(r,"base64").v1();return{variantId:e.variantId().toString(),version:e.version(),items:e.items().map(t=>({collectionId:t.collectionId().toString(),productId:t.productId().toString(),variantId:t.variantId().toString(),sku:t.sku().toString(),quantity:t.quantity()}))}}oe.toBundle=Su;function FE(r,e,t=1){const n={variantId:r.toString(),version:t,items:[]};for(const i in e)if(Object.hasOwnProperty.call(e,i)){const a=e[i];n.items.push({collectionId:a.dsId.toString(),productId:a.pId.toString(),variantId:a.vId.toString(),sku:a.sku||"",quantity:a.qty})}return Ou(n)}oe.encodeLegacyBoxOrder=FE;function RE(r){let e={};try{Su(r).items.forEach(n=>{e[n.variantId]={dsId:n.collectionId,pId:Number.parseInt(n.productId),vId:Number.parseInt(n.variantId),sku:n.sku,qty:n.quantity}})}catch{e=JSON.parse(y.from(r,"base64").toString())}return e}oe.decodeToLegacyBoxOrder=RE;var ME=Ge,BE=He;function UE(r,e){return r&&ME(e,BE(e),r)}var DE=UE,NE=Ge,CE=nt;function LE(r,e){return r&&NE(e,CE(e),r)}var jE=LE,oi={exports:{}};(function(r,e){var t=Q,n=e&&!e.nodeType&&e,i=n&&!0&&r&&!r.nodeType&&r,a=i&&i.exports===n,o=a?t.Buffer:void 0,f=o?o.allocUnsafe:void 0;function s(c,l){if(l)return c.slice();var u=c.length,p=f?f(u):new c.constructor(u);return c.copy(p),p}r.exports=s})(oi,oi.exports);function kE(r,e){var t=-1,n=r.length;for(e||(e=Array(n));++t<n;)e[t]=r[t];return e}var VE=kE,qE=Ge,GE=Vn;function HE(r,e){return qE(r,GE(r),e)}var WE=HE,zE=Ya,XE=zE(Object.getPrototypeOf,Object),ui=XE,YE=kn,KE=ui,ZE=Vn,JE=io,QE=Object.getOwnPropertySymbols,eO=QE?function(r){for(var e=[];r;)YE(e,ZE(r)),r=KE(r);return e}:JE,Tu=eO,rO=Ge,tO=Tu;function nO(r,e){return rO(r,tO(r),e)}var iO=nO,aO=no,oO=Tu,uO=nt;function fO(r){return aO(r,uO,oO)}var Iu=fO,sO=Object.prototype,cO=sO.hasOwnProperty;function lO(r){var e=r.length,t=new r.constructor(e);return e&&typeof r[0]=="string"&&cO.call(r,"index")&&(t.index=r.index,t.input=r.input),t}var pO=lO,xu=Qa;function hO(r){var e=new r.constructor(r.byteLength);return new xu(e).set(new xu(r)),e}var fi=hO,yO=fi;function dO(r,e){var t=e?yO(r.buffer):r.buffer;return new r.constructor(t,r.byteOffset,r.byteLength)}var vO=dO,gO=/\w*$/;function _O(r){var e=new r.constructor(r.source,gO.exec(r));return e.lastIndex=r.lastIndex,e}var mO=_O,Pu=qe,Fu=Pu?Pu.prototype:void 0,Ru=Fu?Fu.valueOf:void 0;function bO(r){return Ru?Object(Ru.call(r)):{}}var wO=bO,$O=fi;function EO(r,e){var t=e?$O(r.buffer):r.buffer;return new r.constructor(t,r.byteOffset,r.length)}var OO=EO,AO=fi,SO=vO,TO=mO,IO=wO,xO=OO,PO="[object Boolean]",FO="[object Date]",RO="[object Map]",MO="[object Number]",BO="[object RegExp]",UO="[object Set]",DO="[object String]",NO="[object Symbol]",CO="[object ArrayBuffer]",LO="[object DataView]",jO="[object Float32Array]",kO="[object Float64Array]",VO="[object Int8Array]",qO="[object Int16Array]",GO="[object Int32Array]",HO="[object Uint8Array]",WO="[object Uint8ClampedArray]",zO="[object Uint16Array]",XO="[object Uint32Array]";function YO(r,e,t){var n=r.constructor;switch(e){case CO:return AO(r);case PO:case FO:return new n(+r);case LO:return SO(r,t);case jO:case kO:case VO:case qO:case GO:case HO:case WO:case zO:case XO:return xO(r,t);case RO:return new n;case MO:case DO:return new n(r);case BO:return TO(r);case UO:return new n;case NO:return IO(r)}}var KO=YO,ZO=ve,Mu=Object.create,JO=function(){function r(){}return function(e){if(!ZO(e))return{};if(Mu)return Mu(e);r.prototype=e;var t=new r;return r.prototype=void 0,t}}(),QO=JO,eA=QO,rA=ui,tA=Un;function nA(r){return typeof r.constructor=="function"&&!tA(r)?eA(rA(r)):{}}var iA=nA,aA=ct,oA=H,uA="[object Map]";function fA(r){return oA(r)&&aA(r)==uA}var sA=fA,cA=sA,lA=Bn,Bu=pr.exports,Uu=Bu&&Bu.isMap,pA=Uu?lA(Uu):cA,hA=pA,yA=ct,dA=H,vA="[object Set]";function gA(r){return dA(r)&&yA(r)==vA}var _A=gA,mA=_A,bA=Bn,Du=pr.exports,Nu=Du&&Du.isSet,wA=Nu?bA(Nu):mA,$A=wA,EA=Ln,OA=tu,AA=Da,SA=DE,TA=jE,IA=oi.exports,xA=VE,PA=WE,FA=iO,RA=oo,MA=Iu,BA=ct,UA=pO,DA=KO,NA=iA,CA=C,LA=lr.exports,jA=hA,kA=ve,VA=$A,qA=He,GA=nt,HA=1,WA=2,zA=4,Cu="[object Arguments]",XA="[object Array]",YA="[object Boolean]",KA="[object Date]",ZA="[object Error]",Lu="[object Function]",JA="[object GeneratorFunction]",QA="[object Map]",eS="[object Number]",ju="[object Object]",rS="[object RegExp]",tS="[object Set]",nS="[object String]",iS="[object Symbol]",aS="[object WeakMap]",oS="[object ArrayBuffer]",uS="[object DataView]",fS="[object Float32Array]",sS="[object Float64Array]",cS="[object Int8Array]",lS="[object Int16Array]",pS="[object Int32Array]",hS="[object Uint8Array]",yS="[object Uint8ClampedArray]",dS="[object Uint16Array]",vS="[object Uint32Array]",P={};P[Cu]=P[XA]=P[oS]=P[uS]=P[YA]=P[KA]=P[fS]=P[sS]=P[cS]=P[lS]=P[pS]=P[QA]=P[eS]=P[ju]=P[rS]=P[tS]=P[nS]=P[iS]=P[hS]=P[yS]=P[dS]=P[vS]=!0,P[ZA]=P[Lu]=P[aS]=!1;function Mt(r,e,t,n,i,a){var o,f=e&HA,s=e&WA,c=e&zA;if(t&&(o=i?t(r,n,i,a):t(r)),o!==void 0)return o;if(!kA(r))return r;var l=CA(r);if(l){if(o=UA(r),!f)return xA(r,o)}else{var u=BA(r),p=u==Lu||u==JA;if(LA(r))return IA(r,f);if(u==ju||u==Cu||p&&!i){if(o=s||p?{}:NA(r),!f)return s?FA(r,TA(o,r)):PA(r,SA(o,r))}else{if(!P[u])return i?r:{};o=DA(r,u,f)}}a||(a=new EA);var d=a.get(r);if(d)return d;a.set(r,o),VA(r)?r.forEach(function($){o.add(Mt($,e,t,$,r,a))}):jA(r)&&r.forEach(function($,b){o.set(b,Mt($,e,t,b,r,a))});var _=c?s?MA:RA:s?GA:qA,E=l?void 0:_(r);return OA(E||r,function($,b){E&&(b=$,$=r[b]),AA(o,b,Mt($,e,t,b,r,a))}),o}var gS=Mt;function _S(r){var e=r==null?0:r.length;return e?r[e-1]:void 0}var mS=_S;function bS(r,e,t){var n=-1,i=r.length;e<0&&(e=-e>i?0:i+e),t=t>i?i:t,t<0&&(t+=i),i=e>t?0:t-e>>>0,e>>>=0;for(var a=Array(i);++n<i;)a[n]=r[n+e];return a}var wS=bS,$S=Zn,ES=wS;function OS(r,e){return e.length<2?r:$S(r,ES(e,0,-1))}var AS=OS,SS=yt,TS=mS,IS=AS,xS=hr;function PS(r,e){return e=SS(e,r),r=IS(r,e),r==null||delete r[xS(TS(e))]}var FS=PS,RS=fe,MS=ui,BS=H,US="[object Object]",DS=Function.prototype,NS=Object.prototype,ku=DS.toString,CS=NS.hasOwnProperty,LS=ku.call(Object);function jS(r){if(!BS(r)||RS(r)!=US)return!1;var e=MS(r);if(e===null)return!0;var t=CS.call(e,"constructor")&&e.constructor;return typeof t=="function"&&t instanceof t&&ku.call(t)==LS}var kS=jS,VS=kS;function qS(r){return VS(r)?void 0:r}var GS=qS,Vu=qe,HS=Mn,WS=C,qu=Vu?Vu.isConcatSpreadable:void 0;function zS(r){return WS(r)||HS(r)||!!(qu&&r&&r[qu])}var XS=zS,YS=kn,KS=XS;function Gu(r,e,t,n,i){var a=-1,o=r.length;for(t||(t=KS),i||(i=[]);++a<o;){var f=r[a];e>0&&t(f)?e>1?Gu(f,e-1,t,n,i):YS(i,f):n||(i[i.length]=f)}return i}var ZS=Gu,JS=ZS;function QS(r){var e=r==null?0:r.length;return e?JS(r,1):[]}var eT=QS,rT=eT,tT=Ca,nT=ja;function iT(r){return nT(tT(r,void 0,rT),r+"")}var aT=iT,oT=ht,uT=gS,fT=FS,sT=yt,cT=Ge,lT=GS,pT=aT,hT=Iu,yT=1,dT=2,vT=4,gT=pT(function(r,e){var t={};if(r==null)return t;var n=!1;e=oT(e,function(a){return a=sT(a,r),n||(n=a.length>1),a}),cT(r,hT(r),t),n&&(t=uT(t,yT|dT|vT,lT));for(var i=e.length;i--;)fT(t,e[i]);return t}),_T=gT,mT=Object.defineProperty,bT=Object.defineProperties,wT=Object.getOwnPropertyDescriptors,Hu=Object.getOwnPropertySymbols,$T=Object.prototype.hasOwnProperty,ET=Object.prototype.propertyIsEnumerable,Wu=(r,e,t)=>e in r?mT(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,OT=(r,e)=>{for(var t in e||(e={}))$T.call(e,t)&&Wu(r,t,e[t]);if(Hu)for(var t of Hu(e))ET.call(e,t)&&Wu(r,t,e[t]);return r},AT=(r,e)=>bT(r,wT(e));function ST(r){try{return JSON.parse(r)}catch{return r}}function TT(r){return Object.entries(r).reduce((e,[t,n])=>AT(OT({},e),{[t]:ST(n)}),{})}var IT=Object.defineProperty,xT=Object.defineProperties,PT=Object.getOwnPropertyDescriptors,zu=Object.getOwnPropertySymbols,FT=Object.prototype.hasOwnProperty,RT=Object.prototype.propertyIsEnumerable,Xu=(r,e,t)=>e in r?IT(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Yu=(r,e)=>{for(var t in e||(e={}))FT.call(e,t)&&Xu(r,t,e[t]);if(zu)for(var t of zu(e))RT.call(e,t)&&Xu(r,t,e[t]);return r},Ku=(r,e)=>xT(r,PT(e));function Zu(r){var e;const t=TT(r),n=t.auto_inject===void 0?!0:t.auto_inject,i=(e=t.display_on)!=null?e:[],a=t.first_option==="autodeliver";return Ku(Yu({},_T(t,["display_on","first_option"])),{auto_inject:n,valid_pages:i,is_subscription_first:a,autoInject:n,validPages:i,isSubscriptionFirst:a})}function Ju(r){var e;const t=((e=r.subscription_options)==null?void 0:e.storefront_purchase_options)==="subscription_only";return Ku(Yu({},r),{is_subscription_only:t,isSubscriptionOnly:t})}function MT(r){return r.map(e=>{const t={};return Object.entries(e).forEach(([n,i])=>{t[n]=Ju(i)}),t})}const Bt="2020-12",BT={store_currency:{currency_code:"USD",currency_symbol:"$",decimal_separator:".",thousands_separator:",",currency_symbol_location:"left"}},Tr=new Map;function Ut(r,e){return Tr.has(r)||Tr.set(r,e()),Tr.get(r)}const si=async r=>{const{product:e}=await Ut(`product.${r}`,()=>Jr("get",`/product/${Bt}/${r}.json`));return Ju(e)},Qu=async()=>await Ut("storeSettings",()=>Jr("get",`/${Bt}/store_settings.json`).catch(()=>BT)),ef=async()=>{const{widget_settings:r}=await Ut("widgetSettings",()=>Jr("get",`/${Bt}/widget_settings.json`));return Zu(r)},rf=async()=>{const{products:r,widget_settings:e,store_settings:t,meta:n}=await Ut("productsAndSettings",()=>Jr("get",`/product/${Bt}/products.json`));return n?.status==="error"?Promise.reject(n.message):{products:MT(r),widget_settings:Zu(e),store_settings:t}},UT=async()=>{const{products:r}=await rf();return r},DT=async r=>{const[e,t,n]=await Promise.all([si(r),Qu(),ef()]);return{product:e,store_settings:t,widget_settings:n,storeSettings:t,widgetSettings:n}},tf=async r=>{const{bundle_product:e}=await si(r);return e},nf=()=>Array.from(Tr.keys()).forEach(r=>Tr.delete(r));var NT=Object.freeze({__proto__:null,getProduct:si,getStoreSettings:Qu,getWidgetSettings:ef,getProductsAndSettings:rf,getProducts:UT,getProductAndSettings:DT,getBundleSettings:tf,resetCache:nf});const af="/bundling-storefront-manager";function CT(){return Math.ceil(Date.now()/1e3)}async function LT(){try{const{timestamp:r}=await Tn("get",`${af}/t`,{headers:{"X-Recharge-App":"storefront-client"}});return r}catch(r){return console.error(`Fetch failed: ${r}. Using client-side date.`),CT()}}const jT=async r=>{const e=Sn();if(!await of(r))throw new Error("Bundle selection is invalid.");const t=await LT(),n=Au({variantId:r.externalVariantId,version:t,items:r.selections.map(i=>({collectionId:i.collectionId,productId:i.externalProductId,variantId:i.externalVariantId,quantity:i.quantity,sku:""}))});try{const i=await Tn("post",`${af}/api/v1/bundles`,{data:{bundle:n},headers:{Origin:`https://${e.storeIdentifier}`}});if(!i.id||i.code!==200)throw new Error(`1: failed generating rb_id: ${JSON.stringify(i)}`);return i.id}catch(i){throw new Error(`2: failed generating rb_id ${i}`)}},of=async r=>{try{const e=await tf(r.externalProductId);return!!r&&!!e}catch{return console.error("Error fetching bundle settings"),!1}};var kT=Object.freeze({__proto__:null,getBundleId:jT,validateBundle:of});async function VT(r){const{charge:e}=await T("get","/charges",{id:r});return e}function qT(r){return T("get","/charges",{query:r})}async function GT(r,e){const{charge:t}=await T("post",`/charges/${r}/apply_discount`,{data:e});return t}async function HT(r){const{charge:e}=await T("post",`/charges/${r}/remove_discount`);return e}async function WT(r){const{charge:e}=await T("post",`/charges/${r}/skip`);return e}async function zT(r){const{charge:e}=await T("post",`/charges/${r}/unskip`);return e}async function XT(r,e){const{charge:t}=await T("post",`/charges/${r}/refund`,{data:e});return t}async function YT(r){const{charge:e}=await T("post",`/charges/${r}/process`);return e}async function KT(r){const{charge:e}=await T("post",`/charges/${r}/capture_payment`);return e}var ZT=Object.freeze({__proto__:null,getCharge:VT,listCharges:qT,applyDiscount:GT,removeDiscount:HT,skipCharge:WT,unskipCharge:zT,refundCharge:XT,processCharge:YT,captureCharge:KT});async function JT(r){const{membership:e}=await T("get","/memberships",{id:r});return e}function QT(r){return T("get","/memberships",{query:r})}async function e2(r,e){const{membership:t}=await T("post",`/memberships/${r}/cancel`,{data:e});return t}async function r2(r,e){const{membership:t}=await T("post",`/memberships/${r}/activate`,{data:e});return t}var t2=Object.freeze({__proto__:null,getMembership:JT,listMemberships:QT,cancelMembership:e2,activateMembership:r2}),n2=Object.freeze({__proto__:null,getOnetime:async r=>{const{onetime:e}=await T("get","/onetimes",{id:r});return e},listOnetimes:r=>T("get","/onetimes",{query:r}),createOnetime:async r=>{const{onetime:e}=await T("post","/onetimes",{data:r});return e},updateOnetime:async(r,e)=>{const{onetime:t}=await T("put","/onetimes",{id:r,data:e});return t},deleteOnetime:r=>T("delete","/onetime",{id:r})}),i2=Object.freeze({__proto__:null,getOrder:async r=>{const{order:e}=await T("get","/orders",{id:r});return e},listOrders:r=>T("get","/orders",{query:r})}),a2=Object.freeze({__proto__:null,getSubscription:async r=>{const{subscription:e}=await T("get","/subscriptions",{id:r});return e},listSubscriptions:r=>T("get","/subscriptions",{query:r}),createSubscription:async r=>{const{subscription:e}=await T("post","/subscriptions",{data:r});return e},updateSubscription:async(r,e,t)=>{const{subscription:n}=await T("put","/subscriptions",{id:r,data:e,query:t});return n},updateSubscriptionChargeDate:async(r,e)=>{const{subscription:t}=await T("post",`/subscriptions/${r}/set_next_charge_date`,{data:{date:e}});return t},updateSubscriptionAddress:async(r,e)=>{const{subscription:t}=await T("post",`/subscriptions/${r}/change_address`,{data:{address_id:e}});return t},cancelSubscription:async(r,e)=>{const{subscription:t}=await T("post",`/subscriptions/${r}/cancel`,{data:e});return t},activateSubscription:async r=>{const{subscription:e}=await T("post",`/subscriptions/${r}/activate`);return e}});const o2={get(r,e){return Se("get",r,e)},post(r,e){return Se("post",r,e)},put(r,e){return Se("put",r,e)},delete(r,e){return Se("delete",r,e)}};function u2(r){var e,t;if(r)return r;if((e=window?.Shopify)!=null&&e.shop)return window.Shopify.shop;let n=window?.domain;if(!n){const i=(t=location?.href.match(/(?:http[s]*:\/\/)*(.*?)\.(?=admin\.rechargeapps\.com)/i))==null?void 0:t[1].replace(/-sp$/,"");i&&(n=`${i}.myshopify.com`)}if(n)return n;throw new Error("No storeIdentifier was passed into init.")}function f2(r={}){const e=r;Il({storeIdentifier:u2(r.storeIdentifier),environment:e.environment?e.environment:"prod",apiKey:e.apiKey?e.apiKey:""}),nf()}const uf={init:f2,api:o2,address:ql,auth:Gl,bundle:kT,charge:ZT,cdn:NT,memberships:t2,onetime:n2,order:i2,subscription:a2};try{uf.init()}catch{}return uf});
23
+ */(function(e,t){typeof zb=="function"&&!0&&r&&r.exports?r.exports=t():(e.dcodeIO=e.dcodeIO||{}).Long=t()})(te,function(){function e(l,u,p){this.low=l|0,this.high=u|0,this.unsigned=!!p}e.__isLong__,Object.defineProperty(e.prototype,"__isLong__",{value:!0,enumerable:!1,configurable:!1}),e.isLong=function(u){return(u&&u.__isLong__)===!0};var t={},n={};e.fromInt=function(u,p){var d,_;return p?(u=u>>>0,0<=u&&u<256&&(_=n[u],_)?_:(d=new e(u,(u|0)<0?-1:0,!0),0<=u&&u<256&&(n[u]=d),d)):(u=u|0,-128<=u&&u<128&&(_=t[u],_)?_:(d=new e(u,u<0?-1:0,!1),-128<=u&&u<128&&(t[u]=d),d))},e.fromNumber=function(u,p){return p=!!p,isNaN(u)||!isFinite(u)?e.ZERO:!p&&u<=-s?e.MIN_VALUE:!p&&u+1>=s?e.MAX_VALUE:p&&u>=f?e.MAX_UNSIGNED_VALUE:u<0?e.fromNumber(-u,p).negate():new e(u%o|0,u/o|0,p)},e.fromBits=function(u,p,d){return new e(u,p,d)},e.fromString=function(u,p,d){if(u.length===0)throw Error("number format error: empty string");if(u==="NaN"||u==="Infinity"||u==="+Infinity"||u==="-Infinity")return e.ZERO;if(typeof p=="number"&&(d=p,p=!1),d=d||10,d<2||36<d)throw Error("radix out of range: "+d);var _;if((_=u.indexOf("-"))>0)throw Error('number format error: interior "-" character: '+u);if(_===0)return e.fromString(u.substring(1),p,d).negate();for(var E=e.fromNumber(Math.pow(d,8)),$=e.ZERO,b=0;b<u.length;b+=8){var S=Math.min(8,u.length-b),h=parseInt(u.substring(b,b+S),d);if(S<8){var A=e.fromNumber(Math.pow(d,S));$=$.multiply(A).add(e.fromNumber(h))}else $=$.multiply(E),$=$.add(e.fromNumber(h))}return $.unsigned=p,$},e.fromValue=function(u){return u instanceof e?u:typeof u=="number"?e.fromNumber(u):typeof u=="string"?e.fromString(u):new e(u.low,u.high,u.unsigned)};var i=1<<16,a=1<<24,o=i*i,f=o*o,s=f/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(u){if(u=u||10,u<2||36<u)throw RangeError("radix out of range: "+u);if(this.isZero())return"0";var p;if(this.isNegative())if(this.equals(e.MIN_VALUE)){var d=e.fromNumber(u),_=this.divide(d);return p=_.multiply(d).subtract(this),_.toString(u)+p.toInt().toString(u)}else return"-"+this.negate().toString(u);var E=e.fromNumber(Math.pow(u,6),this.unsigned);p=this;for(var $="";;){var b=p.divide(E),S=p.subtract(b.multiply(E)).toInt()>>>0,h=S.toString(u);if(p=b,p.isZero())return h+$;for(;h.length<6;)h="0"+h;$=""+h+$}},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 u=this.high!=0?this.high:this.low,p=31;p>0&&(u&1<<p)==0;p--);return this.high!=0?p+33:p+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(u){return e.isLong(u)||(u=e.fromValue(u)),this.unsigned!==u.unsigned&&this.high>>>31===1&&u.high>>>31===1?!1:this.high===u.high&&this.low===u.low},e.eq=e.prototype.equals,e.prototype.notEquals=function(u){return!this.equals(u)},e.neq=e.prototype.notEquals,e.prototype.lessThan=function(u){return this.compare(u)<0},e.prototype.lt=e.prototype.lessThan,e.prototype.lessThanOrEqual=function(u){return this.compare(u)<=0},e.prototype.lte=e.prototype.lessThanOrEqual,e.prototype.greaterThan=function(u){return this.compare(u)>0},e.prototype.gt=e.prototype.greaterThan,e.prototype.greaterThanOrEqual=function(u){return this.compare(u)>=0},e.prototype.gte=e.prototype.greaterThanOrEqual,e.prototype.compare=function(u){if(e.isLong(u)||(u=e.fromValue(u)),this.equals(u))return 0;var p=this.isNegative(),d=u.isNegative();return p&&!d?-1:!p&&d?1:this.unsigned?u.high>>>0>this.high>>>0||u.high===this.high&&u.low>>>0>this.low>>>0?-1:1:this.subtract(u).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(u){e.isLong(u)||(u=e.fromValue(u));var p=this.high>>>16,d=this.high&65535,_=this.low>>>16,E=this.low&65535,$=u.high>>>16,b=u.high&65535,S=u.low>>>16,h=u.low&65535,A=0,x=0,R=0,m=0;return m+=E+h,R+=m>>>16,m&=65535,R+=_+S,x+=R>>>16,R&=65535,x+=d+b,A+=x>>>16,x&=65535,A+=p+$,A&=65535,e.fromBits(R<<16|m,A<<16|x,this.unsigned)},e.prototype.subtract=function(u){return e.isLong(u)||(u=e.fromValue(u)),this.add(u.negate())},e.prototype.sub=e.prototype.subtract,e.prototype.multiply=function(u){if(this.isZero()||(e.isLong(u)||(u=e.fromValue(u)),u.isZero()))return e.ZERO;if(this.equals(e.MIN_VALUE))return u.isOdd()?e.MIN_VALUE:e.ZERO;if(u.equals(e.MIN_VALUE))return this.isOdd()?e.MIN_VALUE:e.ZERO;if(this.isNegative())return u.isNegative()?this.negate().multiply(u.negate()):this.negate().multiply(u).negate();if(u.isNegative())return this.multiply(u.negate()).negate();if(this.lessThan(c)&&u.lessThan(c))return e.fromNumber(this.toNumber()*u.toNumber(),this.unsigned);var p=this.high>>>16,d=this.high&65535,_=this.low>>>16,E=this.low&65535,$=u.high>>>16,b=u.high&65535,S=u.low>>>16,h=u.low&65535,A=0,x=0,R=0,m=0;return m+=E*h,R+=m>>>16,m&=65535,R+=_*h,x+=R>>>16,R&=65535,R+=E*S,x+=R>>>16,R&=65535,x+=d*h,A+=x>>>16,x&=65535,x+=_*S,A+=x>>>16,x&=65535,x+=E*b,A+=x>>>16,x&=65535,A+=p*h+d*S+_*b+E*$,A&=65535,e.fromBits(R<<16|m,A<<16|x,this.unsigned)},e.prototype.mul=e.prototype.multiply,e.prototype.divide=function(u){if(e.isLong(u)||(u=e.fromValue(u)),u.isZero())throw new Error("division by zero");if(this.isZero())return this.unsigned?e.UZERO:e.ZERO;var p,d,_;if(this.equals(e.MIN_VALUE)){if(u.equals(e.ONE)||u.equals(e.NEG_ONE))return e.MIN_VALUE;if(u.equals(e.MIN_VALUE))return e.ONE;var E=this.shiftRight(1);return p=E.divide(u).shiftLeft(1),p.equals(e.ZERO)?u.isNegative()?e.ONE:e.NEG_ONE:(d=this.subtract(u.multiply(p)),_=p.add(d.divide(u)),_)}else if(u.equals(e.MIN_VALUE))return this.unsigned?e.UZERO:e.ZERO;if(this.isNegative())return u.isNegative()?this.negate().divide(u.negate()):this.negate().divide(u).negate();if(u.isNegative())return this.divide(u.negate()).negate();for(_=e.ZERO,d=this;d.greaterThanOrEqual(u);){p=Math.max(1,Math.floor(d.toNumber()/u.toNumber()));for(var $=Math.ceil(Math.log(p)/Math.LN2),b=$<=48?1:Math.pow(2,$-48),S=e.fromNumber(p),h=S.multiply(u);h.isNegative()||h.greaterThan(d);)p-=b,S=e.fromNumber(p,this.unsigned),h=S.multiply(u);S.isZero()&&(S=e.ONE),_=_.add(S),d=d.subtract(h)}return _},e.prototype.div=e.prototype.divide,e.prototype.modulo=function(u){return e.isLong(u)||(u=e.fromValue(u)),this.subtract(this.divide(u).multiply(u))},e.prototype.mod=e.prototype.modulo,e.prototype.not=function(){return e.fromBits(~this.low,~this.high,this.unsigned)},e.prototype.and=function(u){return e.isLong(u)||(u=e.fromValue(u)),e.fromBits(this.low&u.low,this.high&u.high,this.unsigned)},e.prototype.or=function(u){return e.isLong(u)||(u=e.fromValue(u)),e.fromBits(this.low|u.low,this.high|u.high,this.unsigned)},e.prototype.xor=function(u){return e.isLong(u)||(u=e.fromValue(u)),e.fromBits(this.low^u.low,this.high^u.high,this.unsigned)},e.prototype.shiftLeft=function(u){return e.isLong(u)&&(u=u.toInt()),(u&=63)===0?this:u<32?e.fromBits(this.low<<u,this.high<<u|this.low>>>32-u,this.unsigned):e.fromBits(0,this.low<<u-32,this.unsigned)},e.prototype.shl=e.prototype.shiftLeft,e.prototype.shiftRight=function(u){return e.isLong(u)&&(u=u.toInt()),(u&=63)===0?this:u<32?e.fromBits(this.low>>>u|this.high<<32-u,this.high>>u,this.unsigned):e.fromBits(this.high>>u-32,this.high>=0?0:-1,this.unsigned)},e.prototype.shr=e.prototype.shiftRight,e.prototype.shiftRightUnsigned=function(u){if(e.isLong(u)&&(u=u.toInt()),u&=63,u===0)return this;var p=this.high;if(u<32){var d=this.low;return e.fromBits(d>>>u|p<<32-u,p>>>u,this.unsigned)}else return u===32?e.fromBits(p,0,this.unsigned):e.fromBits(p>>>u-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})})(ei),Object.defineProperty(dt,"__esModule",{value:!0}),dt.Hyper=void 0;var Xb=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}}(),No=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)}},Yb=ei.exports,dr=Co(Yb),Kb=M,Zb=Co(Kb);function Co(r){return r&&r.__esModule?r:{default:r}}function Jb(r,e){if(!(r instanceof e))throw new TypeError("Cannot call a class as a function")}function Qb(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 ew(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 vr=dt.Hyper=function(r){ew(e,r),Xb(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=No(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=No(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 Jb(this,e),Qb(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,t,n,!1))}return e}(dr.default);(0,Zb.default)(vr),vr.MAX_VALUE=new vr(dr.default.MAX_VALUE.low,dr.default.MAX_VALUE.high),vr.MIN_VALUE=new vr(dr.default.MIN_VALUE.low,dr.default.MIN_VALUE.high);var Pe={};Object.defineProperty(Pe,"__esModule",{value:!0}),Pe.UnsignedInt=void 0;var rw=et,Lo=jo(rw),tw=M,nw=jo(tw);function jo(r){return r&&r.__esModule?r:{default:r}}var gr=Pe.UnsignedInt={read:function(e){return e.readUInt32BE()},write:function(e,t){if(!(0,Lo.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,Lo.default)(e)||Math.floor(e)!==e?!1:e>=gr.MIN_VALUE&&e<=gr.MAX_VALUE}};gr.MAX_VALUE=Math.pow(2,32)-1,gr.MIN_VALUE=0,(0,nw.default)(gr);var vt={};Object.defineProperty(vt,"__esModule",{value:!0}),vt.UnsignedHyper=void 0;var iw=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}}(),ko=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)}},aw=ei.exports,_r=Vo(aw),ow=M,uw=Vo(ow);function Vo(r){return r&&r.__esModule?r:{default:r}}function fw(r,e){if(!(r instanceof e))throw new TypeError("Cannot call a class as a function")}function sw(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 cw(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 mr=vt.UnsignedHyper=function(r){cw(e,r),iw(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=ko(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=ko(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 fw(this,e),sw(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,t,n,!0))}return e}(_r.default);(0,uw.default)(mr),mr.MAX_VALUE=new mr(_r.default.MAX_UNSIGNED_VALUE.low,_r.default.MAX_UNSIGNED_VALUE.high),mr.MIN_VALUE=new mr(_r.default.MIN_VALUE.low,_r.default.MIN_VALUE.high);var gt={};Object.defineProperty(gt,"__esModule",{value:!0}),gt.Float=void 0;var lw=et,qo=Go(lw),pw=M,hw=Go(pw);function Go(r){return r&&r.__esModule?r:{default:r}}var yw=gt.Float={read:function(e){return e.readFloatBE()},write:function(e,t){if(!(0,qo.default)(e))throw new Error("XDR Write Error: not a number");t.writeFloatBE(e)},isValid:function(e){return(0,qo.default)(e)}};(0,hw.default)(yw);var _t={};Object.defineProperty(_t,"__esModule",{value:!0}),_t.Double=void 0;var dw=et,Ho=Wo(dw),vw=M,gw=Wo(vw);function Wo(r){return r&&r.__esModule?r:{default:r}}var _w=_t.Double={read:function(e){return e.readDoubleBE()},write:function(e,t){if(!(0,Ho.default)(e))throw new Error("XDR Write Error: not a number");t.writeDoubleBE(e)},isValid:function(e){return(0,Ho.default)(e)}};(0,gw.default)(_w);var mt={};Object.defineProperty(mt,"__esModule",{value:!0}),mt.Quadruple=void 0;var mw=M,bw=ww(mw);function ww(r){return r&&r.__esModule?r:{default:r}}var $w=mt.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,bw.default)($w);var br={},Ew=fe,Ow=H,Aw="[object Boolean]";function Sw(r){return r===!0||r===!1||Ow(r)&&Ew(r)==Aw}var Tw=Sw;Object.defineProperty(br,"__esModule",{value:!0}),br.Bool=void 0;var Iw=Tw,xw=Xo(Iw),zo=ue,Pw=M,Fw=Xo(Pw);function Xo(r){return r&&r.__esModule?r:{default:r}}var Rw=br.Bool={read:function(e){var t=zo.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 zo.Int.write(n,t)},isValid:function(e){return(0,xw.default)(e)}};(0,Fw.default)(Rw);var bt={},Mw=fe,Bw=C,Uw=H,Dw="[object String]";function Nw(r){return typeof r=="string"||!Bw(r)&&Uw(r)&&Mw(r)==Dw}var Yo=Nw;Object.defineProperty(bt,"__esModule",{value:!0}),bt.String=void 0;var Cw=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}}(),Lw=Yo,Ko=ri(Lw),jw=C,kw=ri(jw),Zo=ue,Vw=Pe,Jo=Ie,qw=M,Gw=ri(qw);function ri(r){return r&&r.__esModule?r:{default:r}}function Hw(r,e){if(!(r instanceof e))throw new TypeError("Cannot call a class as a function")}var Ww=bt.String=function(){function r(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Vw.UnsignedInt.MAX_VALUE;Hw(this,r),this._maxLength=e}return Cw(r,[{key:"read",value:function(t){var n=Zo.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,Jo.calculatePadding)(n),a=t.slice(n);return(0,Jo.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,Ko.default)(t)?i=y.from(t,"utf8"):i=y.from(t),Zo.Int.write(i.length,n),n.writeBufferPadded(i)}},{key:"isValid",value:function(t){var n=void 0;if((0,Ko.default)(t))n=y.from(t,"utf8");else if((0,kw.default)(t)||y.isBuffer(t))n=y.from(t);else return!1;return n.length<=this._maxLength}}]),r}();(0,Gw.default)(Ww.prototype);var wt={};Object.defineProperty(wt,"__esModule",{value:!0}),wt.Opaque=void 0;var zw=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}}(),Qo=Ie,Xw=M,Yw=Kw(Xw);function Kw(r){return r&&r.__esModule?r:{default:r}}function Zw(r,e){if(!(r instanceof e))throw new TypeError("Cannot call a class as a function")}var Jw=wt.Opaque=function(){function r(e){Zw(this,r),this._length=e,this._padding=(0,Qo.calculatePadding)(e)}return zw(r,[{key:"read",value:function(t){var n=t.slice(this._length);return(0,Qo.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 y.isBuffer(t)&&t.length===this._length}}]),r}();(0,Yw.default)(Jw.prototype);var $t={};Object.defineProperty($t,"__esModule",{value:!0}),$t.VarOpaque=void 0;var Qw=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}}(),eu=ue,e1=Pe,ru=Ie,r1=M,t1=n1(r1);function n1(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")}var a1=$t.VarOpaque=function(){function r(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:e1.UnsignedInt.MAX_VALUE;i1(this,r),this._maxLength=e}return Qw(r,[{key:"read",value:function(t){var n=eu.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,ru.calculatePadding)(n),a=t.slice(n);return(0,ru.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));eu.Int.write(t.length,n),n.writeBufferPadded(t)}},{key:"isValid",value:function(t){return y.isBuffer(t)&&t.length<=this._maxLength}}]),r}();(0,t1.default)(a1.prototype);var Et={},Fe={exports:{}};function o1(r,e){for(var t=-1,n=r==null?0:r.length;++t<n&&e(r[t],t,r)!==!1;);return r}var tu=o1,u1=tt;function f1(r){return typeof r=="function"?r:u1}var nu=f1,s1=tu,c1=Dn,l1=nu,p1=C;function h1(r,e){var t=p1(r)?s1:c1;return t(r,l1(e))}var y1=h1;(function(r){r.exports=y1})(Fe);var d1=/\s/;function v1(r){for(var e=r.length;e--&&d1.test(r.charAt(e)););return e}var g1=v1,_1=g1,m1=/^\s+/;function b1(r){return r&&r.slice(0,_1(r)+1).replace(m1,"")}var w1=b1,$1=w1,iu=ve,E1=pt,au=0/0,O1=/^[-+]0x[0-9a-f]+$/i,A1=/^0b[01]+$/i,S1=/^0o[0-7]+$/i,T1=parseInt;function I1(r){if(typeof r=="number")return r;if(E1(r))return au;if(iu(r)){var e=typeof r.valueOf=="function"?r.valueOf():r;r=iu(e)?e+"":e}if(typeof r!="string")return r===0?r:+r;r=$1(r);var t=A1.test(r);return t||S1.test(r)?T1(r.slice(2),t?2:8):O1.test(r)?au:+r}var x1=I1,P1=x1,ou=1/0,F1=17976931348623157e292;function R1(r){if(!r)return r===0?r:0;if(r=P1(r),r===ou||r===-ou){var e=r<0?-1:1;return e*F1}return r===r?r:0}var M1=R1,B1=M1;function U1(r){var e=B1(r),t=e%1;return e===e?t?e-t:e:0}var D1=U1,N1=Va,C1=nu,L1=D1,j1=9007199254740991,ti=4294967295,k1=Math.min;function V1(r,e){if(r=L1(r),r<1||r>j1)return[];var t=ti,n=k1(r,ti);e=C1(e),r-=ti;for(var i=N1(n,e);++t<r;)e(t);return i}var uu=V1;Object.defineProperty(Et,"__esModule",{value:!0}),Et.Array=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}}(),G1=Jn,H1=wr(G1),W1=Fe.exports,z1=wr(W1),X1=uu,Y1=wr(X1),K1=C,fu=wr(K1),Z1=M,J1=wr(Z1);function wr(r){return r&&r.__esModule?r:{default:r}}function Q1(r,e){if(!(r instanceof e))throw new TypeError("Cannot call a class as a function")}var e$=Et.Array=function(){function r(e,t){Q1(this,r),this._childType=e,this._length=t}return q1(r,[{key:"read",value:function(t){var n=this;return(0,Y1.default)(this._length,function(){return n._childType.read(t)})}},{key:"write",value:function(t,n){var i=this;if(!(0,fu.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,z1.default)(t,function(a){return i._childType.write(a,n)})}},{key:"isValid",value:function(t){var n=this;return!(0,fu.default)(t)||t.length!==this._length?!1:(0,H1.default)(t,function(i){return n._childType.isValid(i)})}}]),r}();(0,J1.default)(e$.prototype);var Ot={};Object.defineProperty(Ot,"__esModule",{value:!0}),Ot.VarArray=void 0;var r$=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}}(),t$=Jn,n$=$r(t$),i$=Fe.exports,a$=$r(i$),o$=uu,u$=$r(o$),f$=C,su=$r(f$),s$=Pe,cu=ue,c$=M,l$=$r(c$);function $r(r){return r&&r.__esModule?r:{default:r}}function p$(r,e){if(!(r instanceof e))throw new TypeError("Cannot call a class as a function")}var h$=Ot.VarArray=function(){function r(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:s$.UnsignedInt.MAX_VALUE;p$(this,r),this._childType=e,this._maxLength=t}return r$(r,[{key:"read",value:function(t){var n=this,i=cu.Int.read(t);if(i>this._maxLength)throw new Error("XDR Read Error: Saw "+i+" length VarArray,"+("max allowed is "+this._maxLength));return(0,u$.default)(i,function(){return n._childType.read(t)})}},{key:"write",value:function(t,n){var i=this;if(!(0,su.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));cu.Int.write(t.length,n),(0,a$.default)(t,function(a){return i._childType.write(a,n)})}},{key:"isValid",value:function(t){var n=this;return!(0,su.default)(t)||t.length>this._maxLength?!1:(0,n$.default)(t,function(i){return n._childType.isValid(i)})}}]),r}();(0,l$.default)(h$.prototype);var At={};function y$(r){return r===null}var d$=y$;function v$(r){return r===void 0}var Er=v$;Object.defineProperty(At,"__esModule",{value:!0}),At.Option=void 0;var g$=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}}(),_$=d$,lu=ni(_$),m$=Er,pu=ni(m$),hu=br,b$=M,w$=ni(b$);function ni(r){return r&&r.__esModule?r:{default:r}}function $$(r,e){if(!(r instanceof e))throw new TypeError("Cannot call a class as a function")}var E$=At.Option=function(){function r(e){$$(this,r),this._childType=e}return g$(r,[{key:"read",value:function(t){if(hu.Bool.read(t))return this._childType.read(t)}},{key:"write",value:function(t,n){var i=!((0,lu.default)(t)||(0,pu.default)(t));hu.Bool.write(i,n),i&&this._childType.write(t,n)}},{key:"isValid",value:function(t){return(0,lu.default)(t)||(0,pu.default)(t)?!0:this._childType.isValid(t)}}]),r}();(0,w$.default)(E$.prototype);var Or={};Object.defineProperty(Or,"__esModule",{value:!0}),Or.Void=void 0;var O$=Er,yu=du(O$),A$=M,S$=du(A$);function du(r){return r&&r.__esModule?r:{default:r}}var T$=Or.Void={read:function(){},write:function(e){if(!(0,yu.default)(e))throw new Error("XDR Write Error: trying to write value to a void slot")},isValid:function(e){return(0,yu.default)(e)}};(0,S$.default)(T$);var St={},I$=ht;function x$(r,e){return I$(e,function(t){return r[t]})}var P$=x$,F$=P$,R$=He;function M$(r){return r==null?[]:F$(r,R$(r))}var B$=M$;Object.defineProperty(St,"__esModule",{value:!0}),St.Enum=void 0;var U$=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}}(),D$=Fe.exports,N$=ii(D$),C$=B$,L$=ii(C$),vu=ue,j$=M,k$=ii(j$);function ii(r){return r&&r.__esModule?r:{default:r}}function V$(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 q$(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 gu(r,e){if(!(r instanceof e))throw new TypeError("Cannot call a class as a function")}var G$=St.Enum=function(){function r(e,t){gu(this,r),this.name=e,this.value=t}return U$(r,null,[{key:"read",value:function(t){var n=vu.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);vu.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,L$.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){q$(f,o);function f(){return gu(this,f),V$(this,(f.__proto__||Object.getPrototypeOf(f)).apply(this,arguments))}return f}(r);return a.enumName=n,t.results[n]=a,a._members={},a._byValue=new Map,(0,N$.default)(i,function(o,f){var s=new a(f,o);a._members[f]=s,a._byValue.set(o,s),a[f]=function(){return s}}),a}}]),r}();(0,k$.default)(G$);var Tt={},H$=Dn,W$=cr;function z$(r,e){var t=-1,n=W$(r)?Array(r.length):[];return H$(r,function(i,a,o){n[++t]=e(i,a,o)}),n}var X$=z$,Y$=ht,K$=Fo,Z$=X$,J$=C;function Q$(r,e){var t=J$(r)?Y$:Z$;return t(r,K$(e))}var eE=Q$;function rE(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 tE=rE,Ar={};Object.defineProperty(Ar,"__esModule",{value:!0});var nE=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 iE(r,e){if(!(r instanceof e))throw new TypeError("Cannot call a class as a function")}Ar.Reference=function(){function r(){iE(this,r)}return nE(r,[{key:"resolve",value:function(){throw new Error("implement resolve in child class")}}]),r}(),Object.defineProperty(Tt,"__esModule",{value:!0}),Tt.Struct=void 0;var It=function(){function r(e,t){var n=[],i=!0,a=!1,o=void 0;try{for(var f=e[Symbol.iterator](),s;!(i=(s=f.next()).done)&&(n.push(s.value),!(t&&n.length===t));i=!0);}catch(c){a=!0,o=c}finally{try{!i&&f.return&&f.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")}}(),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}}(),oE=Fe.exports,_u=Sr(oE),uE=eE,fE=Sr(uE),sE=Er,cE=Sr(sE),lE=tE,pE=Sr(lE),hE=Ar,yE=M,dE=Sr(yE);function Sr(r){return r&&r.__esModule?r:{default:r}}function vE(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 gE(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 mu(r,e){if(!(r instanceof e))throw new TypeError("Cannot call a class as a function")}var _E=Tt.Struct=function(){function r(e){mu(this,r),this._attributes=e||{}}return aE(r,null,[{key:"read",value:function(t){var n=(0,fE.default)(this._fields,function(i){var a=It(i,2),o=a[0],f=a[1],s=f.read(t);return[o,s]});return new this((0,pE.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,_u.default)(this._fields,function(i){var a=It(i,2),o=a[0],f=a[1],s=t._attributes[o];f.write(s,n)})}},{key:"isValid",value:function(t){return t instanceof this}},{key:"create",value:function(t,n,i){var a=function(o){gE(f,o);function f(){return mu(this,f),vE(this,(f.__proto__||Object.getPrototypeOf(f)).apply(this,arguments))}return f}(r);return a.structName=n,t.results[n]=a,a._fields=i.map(function(o){var f=It(o,2),s=f[0],c=f[1];return c instanceof hE.Reference&&(c=c.resolve(t)),[s,c]}),(0,_u.default)(a._fields,function(o){var f=It(o,1),s=f[0];a.prototype[s]=mE(s)}),a}}]),r}();(0,dE.default)(_E);function mE(r){return function(t){return(0,cE.default)(t)||(this._attributes[r]=t),this._attributes[r]}}var xt={};Object.defineProperty(xt,"__esModule",{value:!0}),xt.Union=void 0;var bE=function(){function r(e,t){var n=[],i=!0,a=!1,o=void 0;try{for(var f=e[Symbol.iterator](),s;!(i=(s=f.next()).done)&&(n.push(s.value),!(t&&n.length===t));i=!0);}catch(c){a=!0,o=c}finally{try{!i&&f.return&&f.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")}}(),wE=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}}(),$E=Fe.exports,Pt=Rt($E),EE=Er,bu=Rt(EE),OE=Yo,wu=Rt(OE),Ft=Or,ai=Ar,AE=M,SE=Rt(AE);function Rt(r){return r&&r.__esModule?r:{default:r}}function TE(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 IE(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 $u(r,e){if(!(r instanceof e))throw new TypeError("Cannot call a class as a function")}var xE=xt.Union=function(){function r(e,t){$u(this,r),this.set(e,t)}return wE(r,[{key:"set",value:function(t,n){(0,wu.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!==Ft.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===Ft.Void?Ft.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,bu.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(f){IE(s,f);function s(){return $u(this,s),TE(this,(s.__proto__||Object.getPrototypeOf(s)).apply(this,arguments))}return s}(r);a.unionName=n,t.results[n]=a,i.switchOn instanceof ai.Reference?a._switchOn=i.switchOn.resolve(t):a._switchOn=i.switchOn,a._switches=new Map,a._arms={},(0,Pt.default)(i.arms,function(f,s){f instanceof ai.Reference&&(f=f.resolve(t)),a._arms[s]=f});var o=i.defaultArm;return o instanceof ai.Reference&&(o=o.resolve(t)),a._defaultArm=o,(0,Pt.default)(i.switches,function(f){var s=bE(f,2),c=s[0],l=s[1];(0,wu.default)(c)&&(c=a._switchOn.fromName(c)),a._switches.set(c,l)}),(0,bu.default)(a._switchOn.values)||(0,Pt.default)(a._switchOn.values(),function(f){a[f.name]=function(s){return new a(f,s)},a.prototype[f.name]=function(c){return this.set(f,c)}}),(0,Pt.default)(a._arms,function(f,s){f!==Ft.Void&&(a.prototype[s]=function(){return this.get(s)})}),a}}]),r}();(0,SE.default)(xE),function(r){Object.defineProperty(r,"__esModule",{value:!0});var e=ue;Object.keys(e).forEach(function(h){h==="default"||h==="__esModule"||Object.defineProperty(r,h,{enumerable:!0,get:function(){return e[h]}})});var t=dt;Object.keys(t).forEach(function(h){h==="default"||h==="__esModule"||Object.defineProperty(r,h,{enumerable:!0,get:function(){return t[h]}})});var n=Pe;Object.keys(n).forEach(function(h){h==="default"||h==="__esModule"||Object.defineProperty(r,h,{enumerable:!0,get:function(){return n[h]}})});var i=vt;Object.keys(i).forEach(function(h){h==="default"||h==="__esModule"||Object.defineProperty(r,h,{enumerable:!0,get:function(){return i[h]}})});var a=gt;Object.keys(a).forEach(function(h){h==="default"||h==="__esModule"||Object.defineProperty(r,h,{enumerable:!0,get:function(){return a[h]}})});var o=_t;Object.keys(o).forEach(function(h){h==="default"||h==="__esModule"||Object.defineProperty(r,h,{enumerable:!0,get:function(){return o[h]}})});var f=mt;Object.keys(f).forEach(function(h){h==="default"||h==="__esModule"||Object.defineProperty(r,h,{enumerable:!0,get:function(){return f[h]}})});var s=br;Object.keys(s).forEach(function(h){h==="default"||h==="__esModule"||Object.defineProperty(r,h,{enumerable:!0,get:function(){return s[h]}})});var c=bt;Object.keys(c).forEach(function(h){h==="default"||h==="__esModule"||Object.defineProperty(r,h,{enumerable:!0,get:function(){return c[h]}})});var l=wt;Object.keys(l).forEach(function(h){h==="default"||h==="__esModule"||Object.defineProperty(r,h,{enumerable:!0,get:function(){return l[h]}})});var u=$t;Object.keys(u).forEach(function(h){h==="default"||h==="__esModule"||Object.defineProperty(r,h,{enumerable:!0,get:function(){return u[h]}})});var p=Et;Object.keys(p).forEach(function(h){h==="default"||h==="__esModule"||Object.defineProperty(r,h,{enumerable:!0,get:function(){return p[h]}})});var d=Ot;Object.keys(d).forEach(function(h){h==="default"||h==="__esModule"||Object.defineProperty(r,h,{enumerable:!0,get:function(){return d[h]}})});var _=At;Object.keys(_).forEach(function(h){h==="default"||h==="__esModule"||Object.defineProperty(r,h,{enumerable:!0,get:function(){return _[h]}})});var E=Or;Object.keys(E).forEach(function(h){h==="default"||h==="__esModule"||Object.defineProperty(r,h,{enumerable:!0,get:function(){return E[h]}})});var $=St;Object.keys($).forEach(function(h){h==="default"||h==="__esModule"||Object.defineProperty(r,h,{enumerable:!0,get:function(){return $[h]}})});var b=Tt;Object.keys(b).forEach(function(h){h==="default"||h==="__esModule"||Object.defineProperty(r,h,{enumerable:!0,get:function(){return b[h]}})});var S=xt;Object.keys(S).forEach(function(h){h==="default"||h==="__esModule"||Object.defineProperty(r,h,{enumerable:!0,get:function(){return S[h]}})})}(In);var Eu={};(function(r){Object.defineProperty(r,"__esModule",{value:!0});var e=function(){function m(v,g){for(var w=0;w<g.length;w++){var O=g[w];O.enumerable=O.enumerable||!1,O.configurable=!0,"value"in O&&(O.writable=!0),Object.defineProperty(v,O.key,O)}}return function(v,g,w){return g&&m(v.prototype,g),w&&m(v,w),v}}(),t=Ar;Object.keys(t).forEach(function(m){m==="default"||m==="__esModule"||Object.defineProperty(r,m,{enumerable:!0,get:function(){return t[m]}})}),r.config=_;var n=Er,i=l(n),a=Fe.exports,o=l(a),f=In,s=c(f);function c(m){if(m&&m.__esModule)return m;var v={};if(m!=null)for(var g in m)Object.prototype.hasOwnProperty.call(m,g)&&(v[g]=m[g]);return v.default=m,v}function l(m){return m&&m.__esModule?m:{default:m}}function u(m,v){if(!(m instanceof v))throw new TypeError("Cannot call a class as a function")}function p(m,v){if(!m)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return v&&(typeof v=="object"||typeof v=="function")?v:m}function d(m,v){if(typeof v!="function"&&v!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof v);m.prototype=Object.create(v&&v.prototype,{constructor:{value:m,enumerable:!1,writable:!0,configurable:!0}}),v&&(Object.setPrototypeOf?Object.setPrototypeOf(m,v):m.__proto__=v)}function _(m){var v=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(m){var g=new R(v);m(g),g.resolve()}return v}var E=function(m){d(v,m);function v(g){u(this,v);var w=p(this,(v.__proto__||Object.getPrototypeOf(v)).call(this));return w.name=g,w}return e(v,[{key:"resolve",value:function(w){var O=w.definitions[this.name];return O.resolve(w)}}]),v}(t.Reference),$=function(m){d(v,m);function v(g,w){var O=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;u(this,v);var L=p(this,(v.__proto__||Object.getPrototypeOf(v)).call(this));return L.childReference=g,L.length=w,L.variable=O,L}return e(v,[{key:"resolve",value:function(w){var O=this.childReference,L=this.length;return O instanceof t.Reference&&(O=O.resolve(w)),L instanceof t.Reference&&(L=L.resolve(w)),this.variable?new s.VarArray(O,L):new s.Array(O,L)}}]),v}(t.Reference),b=function(m){d(v,m);function v(g){u(this,v);var w=p(this,(v.__proto__||Object.getPrototypeOf(v)).call(this));return w.childReference=g,w.name=g.name,w}return e(v,[{key:"resolve",value:function(w){var O=this.childReference;return O instanceof t.Reference&&(O=O.resolve(w)),new s.Option(O)}}]),v}(t.Reference),S=function(m){d(v,m);function v(g,w){u(this,v);var O=p(this,(v.__proto__||Object.getPrototypeOf(v)).call(this));return O.sizedType=g,O.length=w,O}return e(v,[{key:"resolve",value:function(w){var O=this.length;return O instanceof t.Reference&&(O=O.resolve(w)),new this.sizedType(O)}}]),v}(t.Reference),h=function(){function m(v,g,w){u(this,m),this.constructor=v,this.name=g,this.config=w}return e(m,[{key:"resolve",value:function(g){return this.name in g.results?g.results[this.name]:this.constructor(g,this.name,this.config)}}]),m}();function A(m,v,g){return g instanceof t.Reference&&(g=g.resolve(m)),m.results[v]=g,g}function x(m,v,g){return m.results[v]=g,g}var R=function(){function m(v){u(this,m),this._destination=v,this._definitions={}}return e(m,[{key:"enum",value:function(g,w){var O=new h(s.Enum.create,g,w);this.define(g,O)}},{key:"struct",value:function(g,w){var O=new h(s.Struct.create,g,w);this.define(g,O)}},{key:"union",value:function(g,w){var O=new h(s.Union.create,g,w);this.define(g,O)}},{key:"typedef",value:function(g,w){var O=new h(A,g,w);this.define(g,O)}},{key:"const",value:function(g,w){var O=new h(x,g,w);this.define(g,O)}},{key:"void",value:function(){return s.Void}},{key:"bool",value:function(){return s.Bool}},{key:"int",value:function(){return s.Int}},{key:"hyper",value:function(){return s.Hyper}},{key:"uint",value:function(){return s.UnsignedInt}},{key:"uhyper",value:function(){return s.UnsignedHyper}},{key:"float",value:function(){return s.Float}},{key:"double",value:function(){return s.Double}},{key:"quadruple",value:function(){return s.Quadruple}},{key:"string",value:function(g){return new S(s.String,g)}},{key:"opaque",value:function(g){return new S(s.Opaque,g)}},{key:"varOpaque",value:function(g){return new S(s.VarOpaque,g)}},{key:"array",value:function(g,w){return new $(g,w)}},{key:"varArray",value:function(g,w){return new $(g,w,!0)}},{key:"option",value:function(g){return new b(g)}},{key:"define",value:function(g,w){if((0,i.default)(this._destination[g]))this._definitions[g]=w;else throw new Error("XDRTypes Error:"+g+" is already defined")}},{key:"lookup",value:function(g){return new E(g)}},{key:"resolve",value:function(){var g=this;(0,o.default)(this._definitions,function(w){w.resolve({definitions:g._definitions,results:g._destination})})}}]),m}()})(Eu),function(r){Object.defineProperty(r,"__esModule",{value:!0});var e=In;Object.keys(e).forEach(function(n){n==="default"||n==="__esModule"||Object.defineProperty(r,n,{enumerable:!0,get:function(){return e[n]}})});var t=Eu;Object.keys(t).forEach(function(n){n==="default"||n==="__esModule"||Object.defineProperty(r,n,{enumerable:!0,get:function(){return t[n]}})})}(Oa),Object.defineProperty(Qr,"__esModule",{value:!0}),Qr.xdr=void 0;const PE=(0,Oa.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")}})});Qr.xdr=PE,Object.defineProperty(oe,"__esModule",{value:!0}),oe.decodeToLegacyBoxOrder=oe.encodeLegacyBoxOrder=oe.toBundle=Au=oe.toLineItemProperty=void 0;const ee=Qr;function Ou(r){let e={variantId:ee.xdr.Uint64.fromString(r.variantId.toString()),version:r.version||Math.floor(Date.now()/1e3),items:r.items.map(n=>new ee.xdr.BundleItem({collectionId:ee.xdr.Uint64.fromString(n.collectionId.toString()),productId:ee.xdr.Uint64.fromString(n.productId.toString()),variantId:ee.xdr.Uint64.fromString(n.variantId.toString()),sku:n.sku||"",quantity:n.quantity,ext:new ee.xdr.BundleItemExt(0)})),ext:new ee.xdr.BundleExt(0)};const t=new ee.xdr.Bundle(e);return ee.xdr.BundleEnvelope.envelopeTypeBundle(t).toXDR("base64")}var Au=oe.toLineItemProperty=Ou;function Su(r){const e=ee.xdr.BundleEnvelope.fromXDR(r,"base64").v1();return{variantId:e.variantId().toString(),version:e.version(),items:e.items().map(t=>({collectionId:t.collectionId().toString(),productId:t.productId().toString(),variantId:t.variantId().toString(),sku:t.sku().toString(),quantity:t.quantity()}))}}oe.toBundle=Su;function FE(r,e,t=1){const n={variantId:r.toString(),version:t,items:[]};for(const i in e)if(Object.hasOwnProperty.call(e,i)){const a=e[i];n.items.push({collectionId:a.dsId.toString(),productId:a.pId.toString(),variantId:a.vId.toString(),sku:a.sku||"",quantity:a.qty})}return Ou(n)}oe.encodeLegacyBoxOrder=FE;function RE(r){let e={};try{Su(r).items.forEach(n=>{e[n.variantId]={dsId:n.collectionId,pId:Number.parseInt(n.productId),vId:Number.parseInt(n.variantId),sku:n.sku,qty:n.quantity}})}catch{e=JSON.parse(y.from(r,"base64").toString())}return e}oe.decodeToLegacyBoxOrder=RE;var ME=Ge,BE=He;function UE(r,e){return r&&ME(e,BE(e),r)}var DE=UE,NE=Ge,CE=nt;function LE(r,e){return r&&NE(e,CE(e),r)}var jE=LE,oi={exports:{}};(function(r,e){var t=Q,n=e&&!e.nodeType&&e,i=n&&!0&&r&&!r.nodeType&&r,a=i&&i.exports===n,o=a?t.Buffer:void 0,f=o?o.allocUnsafe:void 0;function s(c,l){if(l)return c.slice();var u=c.length,p=f?f(u):new c.constructor(u);return c.copy(p),p}r.exports=s})(oi,oi.exports);function kE(r,e){var t=-1,n=r.length;for(e||(e=Array(n));++t<n;)e[t]=r[t];return e}var VE=kE,qE=Ge,GE=Vn;function HE(r,e){return qE(r,GE(r),e)}var WE=HE,zE=Ya,XE=zE(Object.getPrototypeOf,Object),ui=XE,YE=kn,KE=ui,ZE=Vn,JE=io,QE=Object.getOwnPropertySymbols,eO=QE?function(r){for(var e=[];r;)YE(e,ZE(r)),r=KE(r);return e}:JE,Tu=eO,rO=Ge,tO=Tu;function nO(r,e){return rO(r,tO(r),e)}var iO=nO,aO=no,oO=Tu,uO=nt;function fO(r){return aO(r,uO,oO)}var Iu=fO,sO=Object.prototype,cO=sO.hasOwnProperty;function lO(r){var e=r.length,t=new r.constructor(e);return e&&typeof r[0]=="string"&&cO.call(r,"index")&&(t.index=r.index,t.input=r.input),t}var pO=lO,xu=Qa;function hO(r){var e=new r.constructor(r.byteLength);return new xu(e).set(new xu(r)),e}var fi=hO,yO=fi;function dO(r,e){var t=e?yO(r.buffer):r.buffer;return new r.constructor(t,r.byteOffset,r.byteLength)}var vO=dO,gO=/\w*$/;function _O(r){var e=new r.constructor(r.source,gO.exec(r));return e.lastIndex=r.lastIndex,e}var mO=_O,Pu=qe,Fu=Pu?Pu.prototype:void 0,Ru=Fu?Fu.valueOf:void 0;function bO(r){return Ru?Object(Ru.call(r)):{}}var wO=bO,$O=fi;function EO(r,e){var t=e?$O(r.buffer):r.buffer;return new r.constructor(t,r.byteOffset,r.length)}var OO=EO,AO=fi,SO=vO,TO=mO,IO=wO,xO=OO,PO="[object Boolean]",FO="[object Date]",RO="[object Map]",MO="[object Number]",BO="[object RegExp]",UO="[object Set]",DO="[object String]",NO="[object Symbol]",CO="[object ArrayBuffer]",LO="[object DataView]",jO="[object Float32Array]",kO="[object Float64Array]",VO="[object Int8Array]",qO="[object Int16Array]",GO="[object Int32Array]",HO="[object Uint8Array]",WO="[object Uint8ClampedArray]",zO="[object Uint16Array]",XO="[object Uint32Array]";function YO(r,e,t){var n=r.constructor;switch(e){case CO:return AO(r);case PO:case FO:return new n(+r);case LO:return SO(r,t);case jO:case kO:case VO:case qO:case GO:case HO:case WO:case zO:case XO:return xO(r,t);case RO:return new n;case MO:case DO:return new n(r);case BO:return TO(r);case UO:return new n;case NO:return IO(r)}}var KO=YO,ZO=ve,Mu=Object.create,JO=function(){function r(){}return function(e){if(!ZO(e))return{};if(Mu)return Mu(e);r.prototype=e;var t=new r;return r.prototype=void 0,t}}(),QO=JO,eA=QO,rA=ui,tA=Un;function nA(r){return typeof r.constructor=="function"&&!tA(r)?eA(rA(r)):{}}var iA=nA,aA=ct,oA=H,uA="[object Map]";function fA(r){return oA(r)&&aA(r)==uA}var sA=fA,cA=sA,lA=Bn,Bu=pr.exports,Uu=Bu&&Bu.isMap,pA=Uu?lA(Uu):cA,hA=pA,yA=ct,dA=H,vA="[object Set]";function gA(r){return dA(r)&&yA(r)==vA}var _A=gA,mA=_A,bA=Bn,Du=pr.exports,Nu=Du&&Du.isSet,wA=Nu?bA(Nu):mA,$A=wA,EA=Ln,OA=tu,AA=Da,SA=DE,TA=jE,IA=oi.exports,xA=VE,PA=WE,FA=iO,RA=oo,MA=Iu,BA=ct,UA=pO,DA=KO,NA=iA,CA=C,LA=lr.exports,jA=hA,kA=ve,VA=$A,qA=He,GA=nt,HA=1,WA=2,zA=4,Cu="[object Arguments]",XA="[object Array]",YA="[object Boolean]",KA="[object Date]",ZA="[object Error]",Lu="[object Function]",JA="[object GeneratorFunction]",QA="[object Map]",eS="[object Number]",ju="[object Object]",rS="[object RegExp]",tS="[object Set]",nS="[object String]",iS="[object Symbol]",aS="[object WeakMap]",oS="[object ArrayBuffer]",uS="[object DataView]",fS="[object Float32Array]",sS="[object Float64Array]",cS="[object Int8Array]",lS="[object Int16Array]",pS="[object Int32Array]",hS="[object Uint8Array]",yS="[object Uint8ClampedArray]",dS="[object Uint16Array]",vS="[object Uint32Array]",P={};P[Cu]=P[XA]=P[oS]=P[uS]=P[YA]=P[KA]=P[fS]=P[sS]=P[cS]=P[lS]=P[pS]=P[QA]=P[eS]=P[ju]=P[rS]=P[tS]=P[nS]=P[iS]=P[hS]=P[yS]=P[dS]=P[vS]=!0,P[ZA]=P[Lu]=P[aS]=!1;function Mt(r,e,t,n,i,a){var o,f=e&HA,s=e&WA,c=e&zA;if(t&&(o=i?t(r,n,i,a):t(r)),o!==void 0)return o;if(!kA(r))return r;var l=CA(r);if(l){if(o=UA(r),!f)return xA(r,o)}else{var u=BA(r),p=u==Lu||u==JA;if(LA(r))return IA(r,f);if(u==ju||u==Cu||p&&!i){if(o=s||p?{}:NA(r),!f)return s?FA(r,TA(o,r)):PA(r,SA(o,r))}else{if(!P[u])return i?r:{};o=DA(r,u,f)}}a||(a=new EA);var d=a.get(r);if(d)return d;a.set(r,o),VA(r)?r.forEach(function($){o.add(Mt($,e,t,$,r,a))}):jA(r)&&r.forEach(function($,b){o.set(b,Mt($,e,t,b,r,a))});var _=c?s?MA:RA:s?GA:qA,E=l?void 0:_(r);return OA(E||r,function($,b){E&&(b=$,$=r[b]),AA(o,b,Mt($,e,t,b,r,a))}),o}var gS=Mt;function _S(r){var e=r==null?0:r.length;return e?r[e-1]:void 0}var mS=_S;function bS(r,e,t){var n=-1,i=r.length;e<0&&(e=-e>i?0:i+e),t=t>i?i:t,t<0&&(t+=i),i=e>t?0:t-e>>>0,e>>>=0;for(var a=Array(i);++n<i;)a[n]=r[n+e];return a}var wS=bS,$S=Zn,ES=wS;function OS(r,e){return e.length<2?r:$S(r,ES(e,0,-1))}var AS=OS,SS=yt,TS=mS,IS=AS,xS=hr;function PS(r,e){return e=SS(e,r),r=IS(r,e),r==null||delete r[xS(TS(e))]}var FS=PS,RS=fe,MS=ui,BS=H,US="[object Object]",DS=Function.prototype,NS=Object.prototype,ku=DS.toString,CS=NS.hasOwnProperty,LS=ku.call(Object);function jS(r){if(!BS(r)||RS(r)!=US)return!1;var e=MS(r);if(e===null)return!0;var t=CS.call(e,"constructor")&&e.constructor;return typeof t=="function"&&t instanceof t&&ku.call(t)==LS}var kS=jS,VS=kS;function qS(r){return VS(r)?void 0:r}var GS=qS,Vu=qe,HS=Mn,WS=C,qu=Vu?Vu.isConcatSpreadable:void 0;function zS(r){return WS(r)||HS(r)||!!(qu&&r&&r[qu])}var XS=zS,YS=kn,KS=XS;function Gu(r,e,t,n,i){var a=-1,o=r.length;for(t||(t=KS),i||(i=[]);++a<o;){var f=r[a];e>0&&t(f)?e>1?Gu(f,e-1,t,n,i):YS(i,f):n||(i[i.length]=f)}return i}var ZS=Gu,JS=ZS;function QS(r){var e=r==null?0:r.length;return e?JS(r,1):[]}var eT=QS,rT=eT,tT=Ca,nT=ja;function iT(r){return nT(tT(r,void 0,rT),r+"")}var aT=iT,oT=ht,uT=gS,fT=FS,sT=yt,cT=Ge,lT=GS,pT=aT,hT=Iu,yT=1,dT=2,vT=4,gT=pT(function(r,e){var t={};if(r==null)return t;var n=!1;e=oT(e,function(a){return a=sT(a,r),n||(n=a.length>1),a}),cT(r,hT(r),t),n&&(t=uT(t,yT|dT|vT,lT));for(var i=e.length;i--;)fT(t,e[i]);return t}),_T=gT,mT=Object.defineProperty,bT=Object.defineProperties,wT=Object.getOwnPropertyDescriptors,Hu=Object.getOwnPropertySymbols,$T=Object.prototype.hasOwnProperty,ET=Object.prototype.propertyIsEnumerable,Wu=(r,e,t)=>e in r?mT(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,OT=(r,e)=>{for(var t in e||(e={}))$T.call(e,t)&&Wu(r,t,e[t]);if(Hu)for(var t of Hu(e))ET.call(e,t)&&Wu(r,t,e[t]);return r},AT=(r,e)=>bT(r,wT(e));function ST(r){try{return JSON.parse(r)}catch{return r}}function TT(r){return Object.entries(r).reduce((e,[t,n])=>AT(OT({},e),{[t]:ST(n)}),{})}var IT=Object.defineProperty,xT=Object.defineProperties,PT=Object.getOwnPropertyDescriptors,zu=Object.getOwnPropertySymbols,FT=Object.prototype.hasOwnProperty,RT=Object.prototype.propertyIsEnumerable,Xu=(r,e,t)=>e in r?IT(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Yu=(r,e)=>{for(var t in e||(e={}))FT.call(e,t)&&Xu(r,t,e[t]);if(zu)for(var t of zu(e))RT.call(e,t)&&Xu(r,t,e[t]);return r},Ku=(r,e)=>xT(r,PT(e));function Zu(r){var e;const t=TT(r),n=t.auto_inject===void 0?!0:t.auto_inject,i=(e=t.display_on)!=null?e:[],a=t.first_option==="autodeliver";return Ku(Yu({},_T(t,["display_on","first_option"])),{auto_inject:n,valid_pages:i,is_subscription_first:a,autoInject:n,validPages:i,isSubscriptionFirst:a})}function Ju(r){var e;const t=((e=r.subscription_options)==null?void 0:e.storefront_purchase_options)==="subscription_only";return Ku(Yu({},r),{is_subscription_only:t,isSubscriptionOnly:t})}function MT(r){return r.map(e=>{const t={};return Object.entries(e).forEach(([n,i])=>{t[n]=Ju(i)}),t})}const Bt="2020-12",BT={store_currency:{currency_code:"USD",currency_symbol:"$",decimal_separator:".",thousands_separator:",",currency_symbol_location:"left"}},Tr=new Map;function Ut(r,e){return Tr.has(r)||Tr.set(r,e()),Tr.get(r)}const si=async r=>{const{product:e}=await Ut(`product.${r}`,()=>Jr("get",`/product/${Bt}/${r}.json`));return Ju(e)},Qu=async()=>await Ut("storeSettings",()=>Jr("get",`/${Bt}/store_settings.json`).catch(()=>BT)),ef=async()=>{const{widget_settings:r}=await Ut("widgetSettings",()=>Jr("get",`/${Bt}/widget_settings.json`));return Zu(r)},rf=async()=>{const{products:r,widget_settings:e,store_settings:t,meta:n}=await Ut("productsAndSettings",()=>Jr("get",`/product/${Bt}/products.json`));return n?.status==="error"?Promise.reject(n.message):{products:MT(r),widget_settings:Zu(e),store_settings:t??{}}},UT=async()=>{const{products:r}=await rf();return r},DT=async r=>{const[e,t,n]=await Promise.all([si(r),Qu(),ef()]);return{product:e,store_settings:t,widget_settings:n,storeSettings:t,widgetSettings:n}},tf=async r=>{const{bundle_product:e}=await si(r);return e},nf=()=>Array.from(Tr.keys()).forEach(r=>Tr.delete(r));var NT=Object.freeze({__proto__:null,getProduct:si,getStoreSettings:Qu,getWidgetSettings:ef,getProductsAndSettings:rf,getProducts:UT,getProductAndSettings:DT,getBundleSettings:tf,resetCache:nf});const af="/bundling-storefront-manager";function CT(){return Math.ceil(Date.now()/1e3)}async function LT(){try{const{timestamp:r}=await Tn("get",`${af}/t`,{headers:{"X-Recharge-App":"storefront-client"}});return r}catch(r){return console.error(`Fetch failed: ${r}. Using client-side date.`),CT()}}const jT=async r=>{const e=Sn();if(!await of(r))throw new Error("Bundle selection is invalid.");const t=await LT(),n=Au({variantId:r.externalVariantId,version:t,items:r.selections.map(i=>({collectionId:i.collectionId,productId:i.externalProductId,variantId:i.externalVariantId,quantity:i.quantity,sku:""}))});try{const i=await Tn("post",`${af}/api/v1/bundles`,{data:{bundle:n},headers:{Origin:`https://${e.storeIdentifier}`}});if(!i.id||i.code!==200)throw new Error(`1: failed generating rb_id: ${JSON.stringify(i)}`);return i.id}catch(i){throw new Error(`2: failed generating rb_id ${i}`)}},of=async r=>{try{const e=await tf(r.externalProductId);return!!r&&!!e}catch{return console.error("Error fetching bundle settings"),!1}};var kT=Object.freeze({__proto__:null,getBundleId:jT,validateBundle:of});async function VT(r){const{charge:e}=await T("get","/charges",{id:r});return e}function qT(r){return T("get","/charges",{query:r})}async function GT(r,e){const{charge:t}=await T("post",`/charges/${r}/apply_discount`,{data:e});return t}async function HT(r){const{charge:e}=await T("post",`/charges/${r}/remove_discount`);return e}async function WT(r){const{charge:e}=await T("post",`/charges/${r}/skip`);return e}async function zT(r){const{charge:e}=await T("post",`/charges/${r}/unskip`);return e}async function XT(r,e){const{charge:t}=await T("post",`/charges/${r}/refund`,{data:e});return t}async function YT(r){const{charge:e}=await T("post",`/charges/${r}/process`);return e}async function KT(r){const{charge:e}=await T("post",`/charges/${r}/capture_payment`);return e}var ZT=Object.freeze({__proto__:null,getCharge:VT,listCharges:qT,applyDiscount:GT,removeDiscount:HT,skipCharge:WT,unskipCharge:zT,refundCharge:XT,processCharge:YT,captureCharge:KT});async function JT(r){const{membership:e}=await T("get","/memberships",{id:r});return e}function QT(r){return T("get","/memberships",{query:r})}async function e2(r,e){const{membership:t}=await T("post",`/memberships/${r}/cancel`,{data:e});return t}async function r2(r,e){const{membership:t}=await T("post",`/memberships/${r}/activate`,{data:e});return t}var t2=Object.freeze({__proto__:null,getMembership:JT,listMemberships:QT,cancelMembership:e2,activateMembership:r2}),n2=Object.freeze({__proto__:null,getOnetime:async r=>{const{onetime:e}=await T("get","/onetimes",{id:r});return e},listOnetimes:r=>T("get","/onetimes",{query:r}),createOnetime:async r=>{const{onetime:e}=await T("post","/onetimes",{data:r});return e},updateOnetime:async(r,e)=>{const{onetime:t}=await T("put","/onetimes",{id:r,data:e});return t},deleteOnetime:r=>T("delete","/onetime",{id:r})}),i2=Object.freeze({__proto__:null,getOrder:async r=>{const{order:e}=await T("get","/orders",{id:r});return e},listOrders:r=>T("get","/orders",{query:r})}),a2=Object.freeze({__proto__:null,getSubscription:async r=>{const{subscription:e}=await T("get","/subscriptions",{id:r});return e},listSubscriptions:r=>T("get","/subscriptions",{query:r}),createSubscription:async r=>{const{subscription:e}=await T("post","/subscriptions",{data:r});return e},updateSubscription:async(r,e,t)=>{const{subscription:n}=await T("put","/subscriptions",{id:r,data:e,query:t});return n},updateSubscriptionChargeDate:async(r,e)=>{const{subscription:t}=await T("post",`/subscriptions/${r}/set_next_charge_date`,{data:{date:e}});return t},updateSubscriptionAddress:async(r,e)=>{const{subscription:t}=await T("post",`/subscriptions/${r}/change_address`,{data:{address_id:e}});return t},cancelSubscription:async(r,e)=>{const{subscription:t}=await T("post",`/subscriptions/${r}/cancel`,{data:e});return t},activateSubscription:async r=>{const{subscription:e}=await T("post",`/subscriptions/${r}/activate`);return e}});const o2={get(r,e){return Se("get",r,e)},post(r,e){return Se("post",r,e)},put(r,e){return Se("put",r,e)},delete(r,e){return Se("delete",r,e)}};function u2(r){var e,t;if(r)return r;if((e=window?.Shopify)!=null&&e.shop)return window.Shopify.shop;let n=window?.domain;if(!n){const i=(t=location?.href.match(/(?:http[s]*:\/\/)*(.*?)\.(?=admin\.rechargeapps\.com)/i))==null?void 0:t[1].replace(/-sp$/,"");i&&(n=`${i}.myshopify.com`)}if(n)return n;throw new Error("No storeIdentifier was passed into init.")}function f2(r={}){const e=r;Il({storeIdentifier:u2(r.storeIdentifier),environment:e.environment?e.environment:"prod",apiKey:e.apiKey?e.apiKey:""}),nf()}const uf={init:f2,api:o2,address:ql,auth:Gl,bundle:kT,charge:ZT,cdn:NT,memberships:t2,onetime:n2,order:i2,subscription:a2};try{uf.init()}catch{}return uf});
24
24
  //# sourceMappingURL=recharge-storefront-client.min.js.map