@requestnetwork/request-client.js 0.40.1-next.1916 → 0.40.1-next.1918

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.
@@ -427,5 +427,5 @@ ${t.PaymentFragmentFragmentDoc}`;const f=(e,t)=>e();t.getSdk=function(e,r=f){ret
427
427
  }
428
428
  }
429
429
  ${t.EventFragment}
430
- ${t.PaymentFragment}`},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.EthInputDataPaymentDetector=void 0;const n=r(13),f=r(50),a=r(4),i=r(715),o=r(297),s=r(100),c=r(36),u=r(68),d={"0.1.0":"0.1.0","0.2.0":"0.1.0","0.3.0":"0.3.0"};class l extends s.ReferenceBasedDetector{constructor({advancedLogic:e,currencyManager:t,explorerApiKeys:r,getSubgraphClient:n}){super(a.ExtensionTypes.PAYMENT_NETWORK_ID.ETH_INPUT_DATA,e.extensions.ethereumInputData,t),this.explorerApiKeys=r||{},this.getSubgraphClient=n}extractEvents(e,t,r,f,a,s){return n.__awaiter(this,void 0,void 0,(function*(){if(!t)return{paymentEvents:[]};const n=new i.EthInputDataInfoRetriever(t,e,a,r,this.explorerApiKeys[a]),f=yield n.getTransferEvents(),c=l.getDeploymentInformation(a,s.version);let d,p=[];if(c){const n=this.getSubgraphClient(a);if(n){const f=new u.TheGraphInfoRetriever(n,this.currencyManager);d=yield f.getTransferEvents({paymentReference:r,contractAddress:c.address,toAddress:t,eventName:e,paymentChain:a})}else{const n=new o.EthProxyInfoRetriever(r,c.address,c.creationBlockNumber,t,e,a);d={paymentEvents:yield n.getTransferEvents()}}f.push(...d.paymentEvents),p=d.escrowEvents}return{paymentEvents:f,escrowEvents:p}}))}}t.EthInputDataPaymentDetector=l,l.getDeploymentInformation=(0,c.makeGetDeploymentInformation)(f.ethereumProxyArtifact,d,!0)},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.EthInputDataInfoRetriever=void 0;const n=r(13),f=r(716);t.EthInputDataInfoRetriever=class{constructor(e,t,r,n,f){this.toAddress=e,this.eventName=t,this.network=r,this.paymentReference=n,this.explorerApiKey=f}getTransferEvents(){return n.__awaiter(this,void 0,void 0,(function*(){if("private"===this.network)throw new Error("ETH input data info-retriever works with etherscan and cannot work on a local network");const e=new f.MultichainExplorerApiProvider(this.network,this.explorerApiKey),t=yield e.getHistory(this.toAddress);return t.filter(((e,r)=>t.findIndex((t=>t.hash===e.hash))===r)).filter((e=>e.to&&e.to.toLowerCase()===this.toAddress.toLowerCase())).filter((e=>e.data.toLowerCase()==="0x"+this.paymentReference.toLowerCase())).map((e=>({amount:e.value.toString(),name:this.eventName,parameters:{block:e.blockNumber,confirmations:e.confirmations,txHash:e.hash},timestamp:e.timestamp})))}))}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.MultichainExplorerApiProvider=void 0;const n=r(3),f={sokol:{chainId:77,name:"sokol"},fuse:{chainId:122,name:"fuse"},celo:{chainId:42220,name:"celo"},fantom:{chainId:250,name:"fantom"},"arbitrum-rinkeby":{chainId:421611,name:"arbitrum-rinkeby"},"arbitrum-one":{chainId:42161,name:"arbitrum-one"},avalanche:{chainId:43114,name:"avalanche"},bsc:{chainId:56,name:"bsc"},optimism:{chainId:10,name:"optimism"},moonbeam:{chainId:1284,name:"moonbeam"},tombchain:{chainId:6969,name:"tombchain"},mantle:{chainId:5e3,name:"mantle"},"mantle-testnet":{chainId:5001,name:"mantle-testnet"}};class a extends n.ethers.providers.EtherscanProvider{constructor(e,t){"string"==typeof e&&f[e]&&(e=f[e]),t||"mainnet"!==e&&"rinkeby"!==e||(t="TCVQQU5V39TAS1V6HF61P9K7IJZVEHH1D9"),super(e,t)}getBaseUrl(){switch(this.network.name){case"sokol":case"xdai":return"https://api.gnosisscan.io";case"fuse":return"https://explorer.fuse.io";case"celo":return"https://api.celoscan.io";case"matic":return"https://api.polygonscan.com";case"fantom":return"https://api.ftmscan.com";case"bsctest":return"https://api-testnet.bscscan.com/";case"bsc":return"https://api.bscscan.com/";case"aurora":return"https://explorer.mainnet.near.org";case"aurora-testnet":case"near-testnet":return"https://explorer.testnet.near.org";case"arbitrum-rinkeby":return"https://testnet.arbiscan.io/";case"arbitrum-one":return"https://api.arbiscan.io";case"avalanche":return"https://api.snowtrace.io";case"mantle":return"https://explorer.mantle.xyz/";case"mantle-testnet":return"https://explorer.testnet.mantle.xyz/";default:return super.getBaseUrl()}}}t.MultichainExplorerApiProvider=a},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.EthFeeProxyPaymentDetector=void 0;const n=r(13),f=r(50),a=r(4),i=r(297),o=r(99),s=r(36),c=r(68),u={"0.1.0":"0.1.0","0.2.0":"0.2.0"};class d extends o.FeeReferenceBasedDetector{constructor({advancedLogic:e,currencyManager:t,getSubgraphClient:r}){super(a.ExtensionTypes.PAYMENT_NETWORK_ID.ETH_FEE_PROXY_CONTRACT,e.extensions.feeProxyContractEth,t),this.getSubgraphClient=r}extractEvents(e,t,r,f,a,o){return n.__awaiter(this,void 0,void 0,(function*(){if(!t)return{paymentEvents:[]};const n=d.getDeploymentInformation(a,o.version),f=this.getSubgraphClient(a);if(f){return new c.TheGraphInfoRetriever(f,this.currencyManager).getTransferEvents({paymentReference:r,contractAddress:n.address,toAddress:t,eventName:e,paymentChain:a})}{const f=new i.EthProxyInfoRetriever(r,n.address,n.creationBlockNumber,t,e,a);return{paymentEvents:yield f.getTransferEvents()}}}))}}t.EthFeeProxyPaymentDetector=d,d.getDeploymentInformation=(0,s.makeGetDeploymentInformation)(f.ethereumFeeProxyArtifact,u)},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AnyToERC20PaymentDetector=void 0;const n=r(13),f=r(50),a=r(4),i=r(257),o=r(719),s=r(300),c=r(36),u=r(8),d=r(33),l={"0.1.0":"0.1.0"};class p extends i.ERC20FeeProxyPaymentDetectorBase{constructor({advancedLogic:e,currencyManager:t,getSubgraphClient:r}){super(a.ExtensionTypes.PAYMENT_NETWORK_ID.ANY_TO_ERC20_PROXY,e.extensions.anyToErc20Proxy,t),this.getSubgraphClient=r}createExtensionsDataForCreation(e){return n.__awaiter(this,void 0,void 0,(function*(){const t=e.salt||(yield(0,u.generate8randomBytes)());return this.extension.createCreationAction({feeAddress:e.feeAddress,feeAmount:e.feeAmount,paymentAddress:e.paymentAddress,refundAddress:e.refundAddress,network:e.network,acceptedTokens:e.acceptedTokens,maxRateTimespan:e.maxRateTimespan,salt:t})}))}extractEvents(e,t,r,a,i,c){return n.__awaiter(this,void 0,void 0,(function*(){if(!t)return{paymentEvents:[]};const{acceptedTokens:n,maxRateTimespan:u=0}=c.values,{address:d,creationBlockNumber:l}=p.getDeploymentInformation(i,c.version),h=f.erc20ConversionProxy.getContractAbi(c.version),b=yield this.getCurrency(a),m=this.getSubgraphClient(i);if(m){const f=new s.TheGraphConversionInfoRetriever(m,this.currencyManager);return yield f.getTransferEvents({paymentReference:r,contractAddress:d,toAddress:t,eventName:e,paymentChain:i,acceptedTokens:n,maxRateTimespan:u,requestCurrency:b})}const y=new o.AnyToErc20InfoRetriever(b,r,d,l,h,t,e,i,n,u);return{paymentEvents:yield y.getTransferEvents()}}))}getPaymentChain(e){const t=this.getPaymentExtension(e).values.network;if(!t)throw Error(`request.extensions[${this.paymentNetworkId}].values.network must be defined`);return d.EvmChains.assertChainSupported(t),t}}t.AnyToERC20PaymentDetector=p,p.getDeploymentInformation=(0,c.makeGetDeploymentInformation)(f.erc20ConversionProxy,l)},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AnyToErc20InfoRetriever=void 0;const n=r(299);class f extends n.ConversionInfoRetriever{getFeeFilter(){const e=this.contractConversionProxy.filters.TransferWithReferenceAndFee(null,null,null,"0x"+this.paymentReference);return e.fromBlock=this.conversionProxyCreationBlockNumber,e.toBlock="latest",e}}t.AnyToErc20InfoRetriever=f},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AnyToEthFeeProxyPaymentDetector=void 0;const n=r(13),f=r(50),a=r(4),i=r(33),o=r(721),s=r(293),c=r(36),u=r(300),d={"0.1.0":"0.1.0","0.2.0":"0.2.0"};class l extends s.AnyToAnyDetector{constructor({advancedLogic:e,currencyManager:t,getSubgraphClient:r}){super(a.ExtensionTypes.PAYMENT_NETWORK_ID.ANY_TO_ETH_PROXY,e.extensions.anyToEthProxy,t),this.getSubgraphClient=r}extractEvents(e,t,r,a,s,c){var d,p;return n.__awaiter(this,void 0,void 0,(function*(){if(!t)return{paymentEvents:[]};const n=l.getDeploymentInformation(s,c.version),h=this.currencyManager.fromStorageCurrency(a);if(!h)throw new i.UnsupportedCurrencyError(a.value);const b=this.getSubgraphClient(s);if(b){const f=new u.TheGraphConversionInfoRetriever(b,this.currencyManager);return yield f.getTransferEvents({paymentReference:r,contractAddress:n.address,toAddress:t,eventName:e,paymentChain:s,maxRateTimespan:null===(d=c.values)||void 0===d?void 0:d.maxRateTimespan,requestCurrency:h})}const m=f.ethConversionArtifact.getContractAbi(n.contractVersion),y=new o.AnyToEthInfoRetriever(h,r,n.address,n.creationBlockNumber,m,t,e,s,void 0,null===(p=c.values)||void 0===p?void 0:p.maxRateTimespan);return{paymentEvents:yield y.getTransferEvents()}}))}getPaymentChain(e){const t=this.getPaymentExtension(e).values.network;if(!t)throw Error(`request.extensions[${this.paymentNetworkId}].values.network must be defined`);return i.EvmChains.assertChainSupported(t),t}}t.AnyToEthFeeProxyPaymentDetector=l,l.getDeploymentInformation=(0,c.makeGetDeploymentInformation)(f.ethConversionArtifact,d)},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AnyToEthInfoRetriever=void 0;const n=r(299);class f extends n.ConversionInfoRetriever{getFeeFilter(){const e=this.contractConversionProxy.filters.TransferWithReferenceAndFee(null,null,"0x"+this.paymentReference);return e.fromBlock=this.conversionProxyCreationBlockNumber,e.toBlock="latest",e}}t.AnyToEthInfoRetriever=f},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.EscrowERC20InfoRetriever=void 0;const n=r(13),f=r(4),a=r(50),i=r(3),o=r(36),s=r(8),c={"0.1.0":"0.1.0","0.2.0":"0.1.0"};class u{constructor(e,t,r,n,f,o,c){this.paymentReference=e,this.escrowContractAddress=t,this.escrowCreationBlockNumber=r,this.tokenContractAddress=n,this.toAddress=f,this.network=o,this.eventName=c,this.provider=(0,s.getDefaultProvider)(this.network),this.contractEscrow=new i.ethers.Contract(this.escrowContractAddress,a.erc20EscrowToPayArtifact.getContractAbi(),this.provider)}getAllContractEvents(){return n.__awaiter(this,void 0,void 0,(function*(){return[...yield this.getContractEventsForEventName(f.PaymentTypes.ESCROW_EVENTS_NAMES.FREEZE_ESCROW),...yield this.getContractEventsForEventName(f.PaymentTypes.ESCROW_EVENTS_NAMES.INITIATE_EMERGENCY_CLAIM),...yield this.getContractEventsForEventName(f.PaymentTypes.ESCROW_EVENTS_NAMES.REVERT_EMERGENCY_CLAIM)]}))}getContractEvents(){return n.__awaiter(this,void 0,void 0,(function*(){if(!this.eventName)throw new Error("Missing event name in EscrowInfoRetriever for getContractEvents()");return this.getContractEventsForEventName(this.eventName)}))}getContractEventsForEventName(e){return n.__awaiter(this,void 0,void 0,(function*(){const t=e===f.PaymentTypes.ESCROW_EVENTS_NAMES.FREEZE_ESCROW?this.contractEscrow.filters.RequestFrozen("0x"+this.paymentReference):e===f.PaymentTypes.ESCROW_EVENTS_NAMES.INITIATE_EMERGENCY_CLAIM?this.contractEscrow.filters.InitiatedEmergencyClaim("0x"+this.paymentReference):e===f.PaymentTypes.ESCROW_EVENTS_NAMES.REVERT_EMERGENCY_CLAIM?this.contractEscrow.filters.RevertedEmergencyClaim("0x"+this.paymentReference):e===f.PaymentTypes.ESCROW_EVENTS_NAMES.PAID_ESCROW?this.contractEscrow.filters.TransferWithReferenceAndFee(null,null,null,"0x"+this.paymentReference,null,null):void 0;if(!t)throw new Error("Wrong eventName for Escrow event retriever");t.fromBlock=this.escrowCreationBlockNumber,t.toBlock="latest";const r=(yield this.provider.getLogs(t)).map((e=>{const t=this.contractEscrow.interface.parseLog(e);return Object.assign(Object.assign({},e),{parsedLog:(0,o.parseLogArgs)(t)})})).filter((({parsedLog:e})=>!e.tokenAddress||e.tokenAddress.toLowerCase()===this.tokenContractAddress.toLowerCase()&&e.to.toLowerCase()===this.toAddress.toLowerCase())).map((({parsedLog:t,blockNumber:r,transactionHash:f})=>n.__awaiter(this,void 0,void 0,(function*(){var n,a;return{amount:(null===(n=t.amount)||void 0===n?void 0:n.toString())||void 0,name:e,parameters:{block:r,paymentReference:t.paymentReference,feeAddress:t.feeAddress||void 0,feeAmount:(null===(a=t.feeAmount)||void 0===a?void 0:a.toString())||void 0,to:this.toAddress||void 0,txHash:f},timestamp:(yield this.provider.getBlock(r||0)).timestamp}}))));return Promise.all(r)}))}getEscrowRequestMapping(){return n.__awaiter(this,void 0,void 0,(function*(){return this.contractEscrow.requestMapping(`0x${this.paymentReference}`)}))}}t.EscrowERC20InfoRetriever=u,u.getEscrowDeploymentInformation=(0,o.makeGetDeploymentInformation)(a.erc20EscrowToPayArtifact,c)},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(33),f=r(302),a=r(325),i=r(840),o=r(848);class s extends f.default{constructor({decryptionProvider:e,httpConfig:t,nodeConnectionConfig:r,signatureProvider:f,useMockStorage:s,currencies:c,currencyManager:u,paymentOptions:d}={httpConfig:{},nodeConnectionConfig:{},useMockStorage:!1}){const l=s?new i.default(new o.default):new a.default({httpConfig:t,nodeConnectionConfig:r});u||(u=new n.CurrencyManager(c||n.CurrencyManager.getDefaultList())),super({dataAccess:l,signatureProvider:f,decryptionProvider:e,currencyManager:u,paymentOptions:d})}}t.default=s},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AdvancedLogic=void 0;var n=r(725);Object.defineProperty(t,"AdvancedLogic",{enumerable:!0,get:function(){return n.default}})},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(4),f=r(33),a=r(726),i=r(304),o=r(727),s=r(305),c=r(728),u=r(306),d=r(729),l=r(730),p=r(307),h=r(731),b=r(308),m=r(733),y=r(734),g=r(735),v=r(309),_=r(737),w=r(738);t.default=class{constructor(e){e||(e=f.CurrencyManager.getDefault()),this.extensions={addressBasedBtc:new i.default,addressBasedErc20:new c.default,addressBasedTestnetBtc:new o.default,contentData:new a.default,anyToErc20Proxy:new y.default(e),declarative:new s.default,ethereumInputData:new h.default,feeProxyContractErc20:new u.default,proxyContractErc20:new d.default,erc777Stream:new l.default,feeProxyContractEth:new p.default,anyToEthProxy:new g.default(e),nativeToken:[new b.default,new m.default],anyToNativeToken:[new v.default(e),new _.default(e)],erc20TransferableReceivable:new w.default}}applyActionToExtensions(e,t,r,n,f){return this.getExtensionForActionAndState(t,r).applyActionToExtension(e,t,r,n,f)}getExtensionForActionAndState(e,t){const r=e.id,f=this.getNetwork(e,t)||t.currency.network,a={[n.ExtensionTypes.ID.CONTENT_DATA]:this.extensions.contentData,[n.ExtensionTypes.PAYMENT_NETWORK_ID.BITCOIN_ADDRESS_BASED]:this.extensions.addressBasedBtc,[n.ExtensionTypes.PAYMENT_NETWORK_ID.TESTNET_BITCOIN_ADDRESS_BASED]:this.extensions.addressBasedTestnetBtc,[n.ExtensionTypes.PAYMENT_NETWORK_ID.ANY_DECLARATIVE]:this.extensions.declarative,[n.ExtensionTypes.PAYMENT_NETWORK_ID.ERC20_ADDRESS_BASED]:this.extensions.addressBasedErc20,[n.ExtensionTypes.PAYMENT_NETWORK_ID.ERC20_PROXY_CONTRACT]:this.extensions.proxyContractErc20,[n.ExtensionTypes.PAYMENT_NETWORK_ID.ERC20_FEE_PROXY_CONTRACT]:this.getFeeProxyContractErc20ForNetwork(f),[n.ExtensionTypes.PAYMENT_NETWORK_ID.ERC777_STREAM]:this.extensions.erc777Stream,[n.ExtensionTypes.PAYMENT_NETWORK_ID.ETH_INPUT_DATA]:this.extensions.ethereumInputData,[n.ExtensionTypes.PAYMENT_NETWORK_ID.NATIVE_TOKEN]:this.getNativeTokenExtensionForNetwork(f),[n.ExtensionTypes.PAYMENT_NETWORK_ID.ANY_TO_ERC20_PROXY]:this.extensions.anyToErc20Proxy,[n.ExtensionTypes.PAYMENT_NETWORK_ID.ETH_FEE_PROXY_CONTRACT]:this.extensions.feeProxyContractEth,[n.ExtensionTypes.PAYMENT_NETWORK_ID.ANY_TO_ETH_PROXY]:this.extensions.anyToEthProxy,[n.ExtensionTypes.PAYMENT_NETWORK_ID.ANY_TO_NATIVE_TOKEN]:this.getAnyToNativeTokenExtensionForNetwork(f),[n.ExtensionTypes.PAYMENT_NETWORK_ID.ERC20_TRANSFERABLE_RECEIVABLE]:this.extensions.erc20TransferableReceivable}[r];if(!a){if(r===n.ExtensionTypes.PAYMENT_NETWORK_ID.NATIVE_TOKEN||r===n.ExtensionTypes.PAYMENT_NETWORK_ID.ANY_TO_NATIVE_TOKEN)throw Error(`extension with id: ${r} not found for network: ${f}`);throw Error(`extension not recognized, id: ${r}`)}return a}getNativeTokenExtensionForNetwork(e){return e?this.extensions.nativeToken.find((t=>t.supportedNetworks.includes(e))):void 0}getAnyToNativeTokenExtensionForNetwork(e){return e?this.extensions.anyToNativeToken.find((t=>t.supportedNetworks.includes(e))):void 0}getFeeProxyContractErc20ForNetwork(e){return f.NearChains.isChainSupported(e)?new u.default(void 0,void 0,e):this.extensions.feeProxyContractErc20}getNetwork(e,t){var r,a;if(t.currency.network&&e.parameters.paymentNetworkName&&!(0,f.isSameChain)(t.currency.network,e.parameters.paymentNetworkName))throw new Error(`Cannot apply action for network ${e.parameters.paymentNetworkName} on state with payment network: ${t.currency.network}`);return"create"===e.action?e.parameters.network:null===(a=null===(r=t.extensions[n.ExtensionTypes.PAYMENT_NETWORK_ID.ANY_TO_NATIVE_TOKEN])||void 0===r?void 0:r.values)||void 0===a?void 0:a.network}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(4),f=r(303);class a extends f.AbstractExtension{constructor(){super(n.ExtensionTypes.TYPE.CONTENT_DATA,n.ExtensionTypes.ID.CONTENT_DATA,"0.1.0")}createCreationAction(e){if(!e.content)throw Error("No content has been given for the extension content-data");return super.createCreationAction(e)}applyCreation(e,t){if(!e.parameters.content)throw Error("No content has been given for the extension content-data");const r=super.applyCreation(e,t);return Object.assign(Object.assign({},r),{events:[],id:this.extensionId,type:this.extensionType,values:Object.assign(Object.assign({},r.values),{content:e.parameters.content})})}}t.default=a},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(304),f=r(4);class a extends n.default{constructor(){super(f.ExtensionTypes.PAYMENT_NETWORK_ID.TESTNET_BITCOIN_ADDRESS_BASED)}isValidAddress(e){return this.isValidAddressForSymbolAndNetwork(e,"BTC-testnet","testnet")}}t.default=a},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(4),f=r(81);class a extends f.default{constructor(){super(n.ExtensionTypes.PAYMENT_NETWORK_ID.ERC20_ADDRESS_BASED,"0.1.0",n.RequestLogicTypes.CURRENCY.ERC20)}}t.default=a},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(4),f=r(101);class a extends f.default{constructor(){super(n.ExtensionTypes.PAYMENT_NETWORK_ID.ERC20_PROXY_CONTRACT,"0.1.0",n.RequestLogicTypes.CURRENCY.ERC20)}}t.default=a},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(4),f=r(101),a=r(8);class i extends f.default{constructor(){super(n.ExtensionTypes.PAYMENT_NETWORK_ID.ERC777_STREAM,"0.1.0",n.RequestLogicTypes.CURRENCY.ERC777)}createCreationAction(e){if(!n.TypesUtils.isOriginalRequestCreationParameters(e)&&!n.TypesUtils.isSubsequentRequestCreationParameters(e))throw Error("originalRequestId, previousRequestId and recurrenceNumber must be all empty or all filled");if(n.TypesUtils.isOriginalRequestCreationParameters(e)){if(!e.expectedFlowRate)throw Error("expectedFlowRate should not be empty");if(!e.expectedStartDate)throw Error("expectedStartDate should not be empty");return super.createCreationAction(e)}if(!this.isSubsequentRequestParametersValid(e))throw Error("recurrenceNumber must be 1 if originalRequestId and previousRequestId are equal and vice versa");return{action:n.ExtensionTypes.PnFeeReferenceBased.ACTION.CREATE,id:this.extensionId,parameters:e,version:this.currentVersion}}applyCreation(e,t){if(!n.TypesUtils.isOriginalRequestCreationParameters(e.parameters)&&!n.TypesUtils.isSubsequentRequestCreationParameters(e.parameters))throw Error("originalRequestId, previousRequestId and recurrenceNumber must be all empty or all filled");if(n.TypesUtils.isOriginalRequestCreationParameters(e.parameters)){if(!e.parameters.expectedStartDate||e.parameters.expectedStartDate&&!(0,a.isValidAmount)(e.parameters.expectedStartDate))throw Error("expectedStartDate is empty or invalid");if(!e.parameters.expectedFlowRate||e.parameters.expectedFlowRate&&!(0,a.isValidAmount)(e.parameters.expectedFlowRate))throw Error("expectedFlowRate is empty or invalid");const r=super.applyCreation(e,t);return Object.assign(Object.assign({},r),{events:[{name:n.ExtensionTypes.PnFeeReferenceBased.ACTION.CREATE,parameters:e.parameters,timestamp:t}],values:Object.assign(Object.assign({},r.values),{expectedStartDate:e.parameters.expectedStartDate,expectedFlowRate:e.parameters.expectedFlowRate})})}if(!e.parameters.originalRequestId)throw Error("originalRequestId is empty");if(!e.parameters.previousRequestId)throw Error("previousRequestId is empty");if(!e.parameters.recurrenceNumber)throw Error("recurrenceNumber is empty");if(!e.version)throw Error("version is required at creation");if(!this.isSubsequentRequestParametersValid(e.parameters))throw Error("recurrenceNumber must be 1 if originalRequestId and previousRequestId are equal and vice versa");return{events:[{name:n.ExtensionTypes.PnFeeReferenceBased.ACTION.CREATE,parameters:e.parameters,timestamp:t}],id:e.id,type:this.extensionType,values:e.parameters,version:e.version}}isSubsequentRequestParametersValid(e){return e.originalRequestId===e.previousRequestId&&1===e.recurrenceNumber||1!==e.recurrenceNumber&&e.originalRequestId!==e.previousRequestId}}t.default=i},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(4),f=r(101);class a extends f.default{constructor(e=n.ExtensionTypes.PAYMENT_NETWORK_ID.ETH_INPUT_DATA,t="0.3.0"){super(e,t,n.RequestLogicTypes.CURRENCY.ETH)}}t.default=a},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(4),f=r(81),a=r(101);class i extends a.default{constructor(e,t,r){super(e,t,n.RequestLogicTypes.CURRENCY.ETH),this.supportedNetworks=r}createCreationAction(e){const t=e.paymentNetworkName;if(e.paymentAddress||e.refundAddress){if(!t)throw new Error(`The network name is mandatory for the creation of the extension ${this.extensionId}.`);this.throwIfInvalidNetwork(t)}if(e.paymentAddress&&!this.isValidAddress(e.paymentAddress))throw new f.InvalidPaymentAddressError(e.paymentAddress);if(e.refundAddress&&!this.isValidAddress(e.refundAddress))throw new f.InvalidPaymentAddressError(e.refundAddress,"refundAddress");return super.createCreationAction(e)}isValidAddress(e){throw new Error("Default implementation of isValidAddress() does not support native tokens. Please override this method.")}throwIfInvalidNetwork(e){if(super.throwIfInvalidNetwork(e),this.supportedNetworks&&!this.supportedNetworks.includes(e))throw new f.UnsupportedNetworkError(e,this.supportedNetworks)}}t.default=i},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(308);class f extends n.default{constructor(){super(["aurora-testnet","near-testnet"])}isValidAddress(e){return this.isValidAddressForSymbolAndNetwork(e,"NEAR-testnet","aurora-testnet")}}t.default=f},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(33),f=r(4),a=r(306);class i extends a.default{constructor(e,t=f.ExtensionTypes.PAYMENT_NETWORK_ID.ANY_TO_ERC20_PROXY,r="0.1.0"){super(t,r),this.currencyManager=e}createCreationAction(e){if(!e.acceptedTokens||0===e.acceptedTokens.length)throw Error("acceptedTokens is required");if(e.acceptedTokens.some((e=>!this.isValidAddress(e))))throw Error("acceptedTokens must contains only valid ethereum addresses");const t=e.network;this.throwIfInvalidNetwork(t);for(const r of e.acceptedTokens){const e=this.currencyManager.fromAddress(r,t);if(!e)throw new n.UnsupportedCurrencyError({value:r,network:t});if(!this.currencyManager.supportsConversion(e,t))throw Error(`acceptedTokens must contain only supported token addresses (ERC20 only). ${r} is not supported for ${t}.`)}return super.createCreationAction(e)}applyCreation(e,t){if(!e.parameters.network||0===e.parameters.network.length)throw Error("network is required");if(!e.parameters.acceptedTokens||0===e.parameters.acceptedTokens.length)throw Error("acceptedTokens is required and cannot be empty");if(e.parameters.acceptedTokens.some((e=>!this.isValidAddress(e))))throw Error("acceptedTokens must contains only valid ethereum addresses");const r=super.applyCreation(e,t);return Object.assign(Object.assign({},r),{events:[{name:"create",parameters:{feeAddress:e.parameters.feeAddress,feeAmount:e.parameters.feeAmount,paymentAddress:e.parameters.paymentAddress,refundAddress:e.parameters.refundAddress,salt:e.parameters.salt,network:e.parameters.network,acceptedTokens:e.parameters.acceptedTokens,maxRateTimespan:e.parameters.maxRateTimespan},timestamp:t}],values:Object.assign(Object.assign({},r.values),{network:e.parameters.network,acceptedTokens:e.parameters.acceptedTokens,maxRateTimespan:e.parameters.maxRateTimespan})})}validate(e,t){var r;const a=t.action===f.ExtensionTypes.PnFeeReferenceBased.ACTION.CREATE?t.parameters.network:null===(r=e.extensions[this.extensionId])||void 0===r?void 0:r.values.network;if(!a)return;if(!a)return;if(!n.conversionSupportedNetworks.includes(a))throw new Error(`The network (${a}) is not supported for this payment network.`);const i=this.currencyManager.fromStorageCurrency(e.currency);if(!i)throw new n.UnsupportedCurrencyError(e.currency);if(!this.currencyManager.supportsConversion(i,a))throw new Error(`The currency (${i.id}, ${i.hash}) of the request is not supported for this payment network.`)}}t.default=i},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(33),f=r(4),a=r(307);class i extends a.default{constructor(e){super(f.ExtensionTypes.PAYMENT_NETWORK_ID.ANY_TO_ETH_PROXY,"0.2.0"),this.currencyManager=e}createCreationAction(e){return this.throwIfInvalidNetwork(e.network),super.createCreationAction(e)}applyCreation(e,t){if(!e.parameters.network||0===e.parameters.network.length)throw Error("network is required");const r=super.applyCreation(e,t);return Object.assign(Object.assign({},r),{events:[{name:"create",parameters:{feeAddress:e.parameters.feeAddress,feeAmount:e.parameters.feeAmount,paymentAddress:e.parameters.paymentAddress,refundAddress:e.parameters.refundAddress,salt:e.parameters.salt,network:e.parameters.network,maxRateTimespan:e.parameters.maxRateTimespan},timestamp:t}],values:Object.assign(Object.assign({},r.values),{network:e.parameters.network,maxRateTimespan:e.parameters.maxRateTimespan})})}validate(e,t){var r;const a=t.action===f.ExtensionTypes.PnFeeReferenceBased.ACTION.CREATE?t.parameters.network:null===(r=e.extensions[this.extensionId])||void 0===r?void 0:r.values.network;if(!a)throw new Error("The network must be provided from the creation action or from the extension state");const i=this.currencyManager.fromStorageCurrency(e.currency);if(!i)throw new n.UnsupportedCurrencyError(e.currency);if(!this.currencyManager.supportsConversion(i,a))throw new Error(`The currency (${e.currency.value}) of the request is not supported for this payment network.`)}}t.default=i},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.InvalidMaxRateTimespanError=void 0;const n=r(115),f=r(4),a=r(81);class i extends n.FeeReferenceBasedPaymentNetwork{constructor(e,t,r){super(e,t,f.RequestLogicTypes.CURRENCY.ETH),this.supportedNetworks=r}createCreationAction(e){const t=e.network;if(this.throwIfInvalidNetwork(t),e.paymentAddress&&!this.isValidAddress(e.paymentAddress))throw new a.InvalidPaymentAddressError(e.paymentAddress);if(e.refundAddress&&!this.isValidAddress(e.refundAddress))throw new a.InvalidPaymentAddressError(e.refundAddress,"refundAddress");if(e.feeAddress&&!this.isValidAddress(e.feeAddress))throw new a.InvalidPaymentAddressError(e.feeAddress,"feeAddress");if(e.maxRateTimespan&&e.maxRateTimespan<0)throw new o(e.maxRateTimespan);return super.createCreationAction(e)}isValidAddress(e){throw new Error("Default implementation of isValidAddress() does not support native tokens. Please override this method.")}throwIfInvalidNetwork(e){if(super.throwIfInvalidNetwork(e),this.supportedNetworks&&!this.supportedNetworks.includes(e))throw new a.UnsupportedNetworkError(e,this.supportedNetworks)}}t.default=i;class o extends Error{constructor(e){super(`${e} is not a valid maxRateTimespan`)}}t.InvalidMaxRateTimespanError=o},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(309);class f extends n.default{constructor(e){super(e,["aurora-testnet","near-testnet"])}isValidAddress(e){return this.isValidAddressForSymbolAndNetwork(e,"NEAR-testnet","aurora-testnet")}}t.default=f},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(4),f=r(115);class a extends f.FeeReferenceBasedPaymentNetwork{constructor(e=n.ExtensionTypes.PAYMENT_NETWORK_ID.ERC20_TRANSFERABLE_RECEIVABLE,t="0.2.0"){super(e,t,n.RequestLogicTypes.CURRENCY.ERC20)}}t.default=a},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.RequestLogic=void 0;var n=r(740);Object.defineProperty(t,"RequestLogic",{enumerable:!0,get:function(){return n.default}})},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(741),f=r(32),a=r(52),i=r(4),o=r(752),s=r(8);t.default=class{constructor(e,t,r){this.transactionManager=e,this.signatureProvider=t,this.advancedLogic=r}createRequest(e,t,r=[]){return n.__awaiter(this,void 0,void 0,(function*(){const{action:n,requestId:f,hashedTopics:a}=yield this.createCreationActionRequestIdAndTopics(e,t,r);return o.default.applyActionToRequest(null,n,Date.now(),this.advancedLogic),this.persistTransaction(f,n,{requestId:f},a)}))}createEncryptedRequest(e,t,r,f=[]){return n.__awaiter(this,void 0,void 0,(function*(){if(0===r.length)throw new Error("You must give at least one encryption parameter to create an encrypted request");const{action:n,requestId:a,hashedTopics:i}=yield this.createCreationActionRequestIdAndTopics(e,t,f);return o.default.applyActionToRequest(null,n,Date.now(),this.advancedLogic),this.persistTransaction(a,n,{requestId:a},i,r)}))}computeRequestId(e,t){return n.__awaiter(this,void 0,void 0,(function*(){if(!this.signatureProvider)throw new Error("You must give a signature provider to create actions");const r=yield o.default.formatCreate(e,t,this.signatureProvider);return o.default.applyActionToRequest(null,r,Date.now(),this.advancedLogic),o.default.getRequestIdFromAction(r)}))}acceptRequest(e,t,r=!1){return n.__awaiter(this,void 0,void 0,(function*(){if(!this.signatureProvider)throw new Error("You must give a signature provider to create actions");const n=yield o.default.formatAccept(e,t,this.signatureProvider),f=o.default.getRequestIdFromAction(n);return r&&(yield this.validateAction(f,n)),this.persistTransaction(f,n,void 0)}))}cancelRequest(e,t,r=!1){return n.__awaiter(this,void 0,void 0,(function*(){if(!this.signatureProvider)throw new Error("You must give a signature provider to create actions");const n=yield o.default.formatCancel(e,t,this.signatureProvider),f=o.default.getRequestIdFromAction(n);return r&&(yield this.validateAction(f,n)),this.persistTransaction(f,n,void 0)}))}increaseExpectedAmountRequest(e,t,r=!1){return n.__awaiter(this,void 0,void 0,(function*(){if(!this.signatureProvider)throw new Error("You must give a signature provider to create actions");const n=yield o.default.formatIncreaseExpectedAmount(e,t,this.signatureProvider),f=o.default.getRequestIdFromAction(n);return r&&(yield this.validateAction(f,n)),this.persistTransaction(f,n,void 0)}))}reduceExpectedAmountRequest(e,t,r=!1){return n.__awaiter(this,void 0,void 0,(function*(){if(!this.signatureProvider)throw new Error("You must give a signature provider to create actions");const n=yield o.default.formatReduceExpectedAmount(e,t,this.signatureProvider),f=o.default.getRequestIdFromAction(n);return r&&(yield this.validateAction(f,n)),this.persistTransaction(f,n,void 0)}))}addStakeholders(e,t,r,f=!1){return n.__awaiter(this,void 0,void 0,(function*(){if(!this.signatureProvider)throw new Error("You must give a signature provider to create actions");const n=yield o.default.formatAddStakeholders(e,t,this.signatureProvider),a=o.default.getRequestIdFromAction(n);return f&&(yield this.validateAction(a,n)),this.persistTransaction(a,n,void 0,[],r)}))}addExtensionsDataRequest(e,t,r=!1){return n.__awaiter(this,void 0,void 0,(function*(){if(!this.signatureProvider)throw new Error("You must give a signature provider to create actions");const n=yield o.default.formatAddExtensionsData(e,t,this.signatureProvider),f=o.default.getRequestIdFromAction(n);return r&&(yield this.validateAction(f,n)),this.persistTransaction(f,n,void 0)}))}getRequestFromId(e){return n.__awaiter(this,void 0,void 0,(function*(){const{ignoredTransactions:t,confirmedRequestState:r,pendingRequestState:n,transactionManagerMeta:f}=yield this.computeRequestFromRequestId(e);return{meta:{ignoredTransactions:t,transactionManagerMeta:f},result:{request:r,pending:this.computeDiffBetweenPendingAndConfirmedRequestState(r,n)}}}))}getRequestsByTopic(e,t){return n.__awaiter(this,void 0,void 0,(function*(){const r=a.default.serialize((0,s.normalizeKeccak256Hash)(e)),n=yield this.transactionManager.getChannelsByTopic(r,t);return this.computeMultipleRequestFromChannels(n)}))}getRequestsByMultipleTopics(e,t){return n.__awaiter(this,void 0,void 0,(function*(){const r=e.map((e=>a.default.serialize((0,s.normalizeKeccak256Hash)(e)))),n=yield this.transactionManager.getChannelsByMultipleTopics(r,t);return this.computeMultipleRequestFromChannels(n)}))}createCreationActionRequestIdAndTopics(e,t,r){return n.__awaiter(this,void 0,void 0,(function*(){if(!this.signatureProvider)throw new Error("You must give a signature provider to create actions");const n=yield o.default.formatCreate(e,t,this.signatureProvider),f=o.default.getRequestIdFromAction(n);return{action:n,hashedTopics:r.map((e=>a.default.serialize((0,s.normalizeKeccak256Hash)(e)))),requestId:f}}))}computeRequestFromRequestId(e){return n.__awaiter(this,void 0,void 0,(function*(){const t=yield this.transactionManager.getTransactionsByChannelId(e),r=t.result.transactions.filter(s.notNull).sort(((e,t)=>e.timestamp-t.timestamp));let{ignoredTransactions:n,keptTransactions:f}=this.removeOldPendingTransactions(r);const a=(0,s.uniqueByProperty)(f.filter(s.notNull).map((e=>{try{return{action:JSON.parse(e.transaction.data||""),state:e.state,timestamp:e.timestamp}}catch(t){return void n.push({reason:"JSON parsing error",transaction:e})}})).filter(s.notNull),"action");n=n.concat(a.duplicates.map((e=>({reason:"Duplicated transaction",transaction:e}))));const{confirmedRequestState:i,pendingRequestState:o,ignoredTransactionsByApplication:c}=yield this.computeRequestFromTransactions(a.uniqueItems);return n=n.concat(c),{confirmedRequestState:i,ignoredTransactions:n,pendingRequestState:o,transactionManagerMeta:t.meta}}))}computeRequestFromTransactions(e){return n.__awaiter(this,void 0,void 0,(function*(){const t=[],r=e.filter((e=>e.state===i.TransactionTypes.TransactionState.CONFIRMED)).reduce(((e,r)=>{try{return o.default.applyActionToRequest(e,r.action,r.timestamp,this.advancedLogic)}catch(n){return t.push({reason:n.message,transaction:r}),e}}),null),n=e.filter((e=>e.state===i.TransactionTypes.TransactionState.PENDING)).reduce(((e,r)=>{try{return o.default.applyActionToRequest(e,r.action,r.timestamp,this.advancedLogic)}catch(n){return t.push({reason:n.message,transaction:r}),e}}),r);return{confirmedRequestState:r,ignoredTransactionsByApplication:t,pendingRequestState:n}}))}computeMultipleRequestFromChannels(e){return n.__awaiter(this,void 0,void 0,(function*(){const t=e.result.transactions,r=e.meta.dataAccessMeta,f=Object.keys(e.result.transactions).map((e=>n.__awaiter(this,void 0,void 0,(function*(){let{ignoredTransactions:n,keptTransactions:f}=this.removeOldPendingTransactions(t[e]);const a=(0,s.uniqueByProperty)(f.filter(s.notNull).map((e=>{try{return{action:JSON.parse(e.transaction.data||""),state:e.state,timestamp:e.timestamp}}catch(t){return void n.push({reason:"JSON parsing error",transaction:e})}})).filter(s.notNull),"action");n=n.concat(a.duplicates.map((e=>({reason:"Duplicated transaction",transaction:e}))));const{confirmedRequestState:i,pendingRequestState:o,ignoredTransactionsByApplication:c}=yield this.computeRequestFromTransactions(a.uniqueItems);n=n.concat(c);const u=this.computeDiffBetweenPendingAndConfirmedRequestState(i,o);return{ignoredTransactions:n,pending:u,request:i,transactionManagerMeta:r[e]}}))));return(yield Promise.all(f)).reduce(((e,t)=>((t.request||t.pending)&&(e.result.requests.push({pending:t.pending,request:t.request}),(e.meta.ignoredTransactions||[]).push(t.ignoredTransactions),(e.meta.transactionManagerMeta||[]).push(t.transactionManagerMeta)),e)),{meta:{ignoredTransactions:[],transactionManagerMeta:[]},result:{requests:[]}})}))}validateAction(e,t){return n.__awaiter(this,void 0,void 0,(function*(){const{confirmedRequestState:r,pendingRequestState:n}=yield this.computeRequestFromRequestId(e);try{o.default.applyActionToRequest(r,t,Date.now(),this.advancedLogic)}catch(e){n&&o.default.applyActionToRequest(n,t,Date.now(),this.advancedLogic)}}))}computeDiffBetweenPendingAndConfirmedRequestState(e,t){let r=null;if(e){if(t)for(const n in t)n in t&&(0,s.normalizeKeccak256Hash)(t[n]).value!==(0,s.normalizeKeccak256Hash)(e[n]).value&&(r||(r={}),r[n]="events"===n?t[n].slice(e[n].length):t[n])}else r=t;return r}removeOldPendingTransactions(e){const t=[];let r=!1;const n=e.reverse().filter((e=>!!e&&(r=r||e.state===i.TransactionTypes.TransactionState.CONFIRMED,e.state===i.TransactionTypes.TransactionState.CONFIRMED||e.state===i.TransactionTypes.TransactionState.PENDING&&!r||(t.push({reason:"Confirmed transaction newer than this pending transaction",transaction:e}),!1)))).reverse();return{ignoredTransactions:t,keptTransactions:n}}persistTransaction(e,t,r,a=[],i=[]){return n.__awaiter(this,void 0,void 0,(function*(){const n=yield this.transactionManager.persistTransaction(JSON.stringify(t),e,a,i),o=new f.EventEmitter;return n.on("confirmed",(e=>o.emit("confirmed",{meta:{transactionManagerMeta:e.meta},result:r}))).on("error",(e=>o.emit("error",e))),Object.assign(o,{meta:{transactionManagerMeta:n.meta},result:r})}))}}},function(e,t,r){"use strict";r.r(t),r.d(t,"__extends",(function(){return f})),r.d(t,"__assign",(function(){return a})),r.d(t,"__rest",(function(){return i})),r.d(t,"__decorate",(function(){return o})),r.d(t,"__param",(function(){return s})),r.d(t,"__esDecorate",(function(){return c})),r.d(t,"__runInitializers",(function(){return u})),r.d(t,"__propKey",(function(){return d})),r.d(t,"__setFunctionName",(function(){return l})),r.d(t,"__metadata",(function(){return p})),r.d(t,"__awaiter",(function(){return h})),r.d(t,"__generator",(function(){return b})),r.d(t,"__createBinding",(function(){return m})),r.d(t,"__exportStar",(function(){return y})),r.d(t,"__values",(function(){return g})),r.d(t,"__read",(function(){return v})),r.d(t,"__spread",(function(){return _})),r.d(t,"__spreadArrays",(function(){return w})),r.d(t,"__spreadArray",(function(){return E})),r.d(t,"__await",(function(){return A})),r.d(t,"__asyncGenerator",(function(){return T})),r.d(t,"__asyncDelegator",(function(){return x})),r.d(t,"__asyncValues",(function(){return k})),r.d(t,"__makeTemplateObject",(function(){return S})),r.d(t,"__importStar",(function(){return C})),r.d(t,"__importDefault",(function(){return P})),r.d(t,"__classPrivateFieldGet",(function(){return R})),r.d(t,"__classPrivateFieldSet",(function(){return N})),r.d(t,"__classPrivateFieldIn",(function(){return I}));var n=function(e,t){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},n(e,t)};function f(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}var a=function(){return a=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var f in t=arguments[r])Object.prototype.hasOwnProperty.call(t,f)&&(e[f]=t[f]);return e},a.apply(this,arguments)};function i(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var f=0;for(n=Object.getOwnPropertySymbols(e);f<n.length;f++)t.indexOf(n[f])<0&&Object.prototype.propertyIsEnumerable.call(e,n[f])&&(r[n[f]]=e[n[f]])}return r}function o(e,t,r,n){var f,a=arguments.length,i=a<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)i=Reflect.decorate(e,t,r,n);else for(var o=e.length-1;o>=0;o--)(f=e[o])&&(i=(a<3?f(i):a>3?f(t,r,i):f(t,r))||i);return a>3&&i&&Object.defineProperty(t,r,i),i}function s(e,t){return function(r,n){t(r,n,e)}}function c(e,t,r,n,f,a){function i(e){if(void 0!==e&&"function"!=typeof e)throw new TypeError("Function expected");return e}for(var o,s=n.kind,c="getter"===s?"get":"setter"===s?"set":"value",u=!t&&e?n.static?e:e.prototype:null,d=t||(u?Object.getOwnPropertyDescriptor(u,n.name):{}),l=!1,p=r.length-1;p>=0;p--){var h={};for(var b in n)h[b]="access"===b?{}:n[b];for(var b in n.access)h.access[b]=n.access[b];h.addInitializer=function(e){if(l)throw new TypeError("Cannot add initializers after decoration has completed");a.push(i(e||null))};var m=(0,r[p])("accessor"===s?{get:d.get,set:d.set}:d[c],h);if("accessor"===s){if(void 0===m)continue;if(null===m||"object"!=typeof m)throw new TypeError("Object expected");(o=i(m.get))&&(d.get=o),(o=i(m.set))&&(d.set=o),(o=i(m.init))&&f.push(o)}else(o=i(m))&&("field"===s?f.push(o):d[c]=o)}u&&Object.defineProperty(u,n.name,d),l=!0}function u(e,t,r){for(var n=arguments.length>2,f=0;f<t.length;f++)r=n?t[f].call(e,r):t[f].call(e);return n?r:void 0}function d(e){return"symbol"==typeof e?e:"".concat(e)}function l(e,t,r){return"symbol"==typeof t&&(t=t.description?"[".concat(t.description,"]"):""),Object.defineProperty(e,"name",{configurable:!0,value:r?"".concat(r," ",t):t})}function p(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}function h(e,t,r,n){return new(r||(r=Promise))((function(f,a){function i(e){try{s(n.next(e))}catch(e){a(e)}}function o(e){try{s(n.throw(e))}catch(e){a(e)}}function s(e){var t;e.done?f(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(i,o)}s((n=n.apply(e,t||[])).next())}))}function b(e,t){var r,n,f,a,i={label:0,sent:function(){if(1&f[0])throw f[1];return f[1]},trys:[],ops:[]};return a={next:o(0),throw:o(1),return:o(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function o(o){return function(s){return function(o){if(r)throw new TypeError("Generator is already executing.");for(;a&&(a=0,o[0]&&(i=0)),i;)try{if(r=1,n&&(f=2&o[0]?n.return:o[0]?n.throw||((f=n.return)&&f.call(n),0):n.next)&&!(f=f.call(n,o[1])).done)return f;switch(n=0,f&&(o=[2&o[0],f.value]),o[0]){case 0:case 1:f=o;break;case 4:return i.label++,{value:o[1],done:!1};case 5:i.label++,n=o[1],o=[0];continue;case 7:o=i.ops.pop(),i.trys.pop();continue;default:if(!(f=i.trys,(f=f.length>0&&f[f.length-1])||6!==o[0]&&2!==o[0])){i=0;continue}if(3===o[0]&&(!f||o[1]>f[0]&&o[1]<f[3])){i.label=o[1];break}if(6===o[0]&&i.label<f[1]){i.label=f[1],f=o;break}if(f&&i.label<f[2]){i.label=f[2],i.ops.push(o);break}f[2]&&i.ops.pop(),i.trys.pop();continue}o=t.call(e,i)}catch(e){o=[6,e],n=0}finally{r=f=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,s])}}}var m=Object.create?function(e,t,r,n){void 0===n&&(n=r);var f=Object.getOwnPropertyDescriptor(t,r);f&&!("get"in f?!t.__esModule:f.writable||f.configurable)||(f={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,f)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]};function y(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||m(t,e,r)}function g(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function v(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,f,a=r.call(e),i=[];try{for(;(void 0===t||t-- >0)&&!(n=a.next()).done;)i.push(n.value)}catch(e){f={error:e}}finally{try{n&&!n.done&&(r=a.return)&&r.call(a)}finally{if(f)throw f.error}}return i}function _(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(v(arguments[t]));return e}function w(){for(var e=0,t=0,r=arguments.length;t<r;t++)e+=arguments[t].length;var n=Array(e),f=0;for(t=0;t<r;t++)for(var a=arguments[t],i=0,o=a.length;i<o;i++,f++)n[f]=a[i];return n}function E(e,t,r){if(r||2===arguments.length)for(var n,f=0,a=t.length;f<a;f++)!n&&f in t||(n||(n=Array.prototype.slice.call(t,0,f)),n[f]=t[f]);return e.concat(n||Array.prototype.slice.call(t))}function A(e){return this instanceof A?(this.v=e,this):new A(e)}function T(e,t,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n,f=r.apply(e,t||[]),a=[];return n={},i("next"),i("throw"),i("return"),n[Symbol.asyncIterator]=function(){return this},n;function i(e){f[e]&&(n[e]=function(t){return new Promise((function(r,n){a.push([e,t,r,n])>1||o(e,t)}))})}function o(e,t){try{(r=f[e](t)).value instanceof A?Promise.resolve(r.value.v).then(s,c):u(a[0][2],r)}catch(e){u(a[0][3],e)}var r}function s(e){o("next",e)}function c(e){o("throw",e)}function u(e,t){e(t),a.shift(),a.length&&o(a[0][0],a[0][1])}}function x(e){var t,r;return t={},n("next"),n("throw",(function(e){throw e})),n("return"),t[Symbol.iterator]=function(){return this},t;function n(n,f){t[n]=e[n]?function(t){return(r=!r)?{value:A(e[n](t)),done:!1}:f?f(t):t}:f}}function k(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,r=e[Symbol.asyncIterator];return r?r.call(e):(e=g(e),t={},n("next"),n("throw"),n("return"),t[Symbol.asyncIterator]=function(){return this},t);function n(r){t[r]=e[r]&&function(t){return new Promise((function(n,f){(function(e,t,r,n){Promise.resolve(n).then((function(t){e({value:t,done:r})}),t)})(n,f,(t=e[r](t)).done,t.value)}))}}}function S(e,t){return Object.defineProperty?Object.defineProperty(e,"raw",{value:t}):e.raw=t,e}var O=Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t};function C(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&m(t,e,r);return O(t,e),t}function P(e){return e&&e.__esModule?e:{default:e}}function R(e,t,r,n){if("a"===r&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?n:"a"===r?n.call(e):n?n.value:t.get(e)}function N(e,t,r,n,f){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!f)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!f:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?f.call(e,r):f?f.value=r:t.set(e,r),r}function I(e,t){if(null===t||"object"!=typeof t&&"function"!=typeof t)throw new TypeError("Cannot use 'in' operator on non-object");return"function"==typeof e?t===e:e.has(t)}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(116),f=r(743),a=r(744),i=r(745),o=new n.default([new f.default,new i.default,new a.default]);t.default=o},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(4),f=r(102);class a extends f.default{constructor(){super(n.MultiFormatTypes.prefix.AES256_CBC_ENCRYPTED,n.EncryptionTypes.METHOD.AES256_CBC)}}t.default=a},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(4),f=r(102);class a extends f.default{constructor(){super(n.MultiFormatTypes.prefix.AES256_GCM_ENCRYPTED,n.EncryptionTypes.METHOD.AES256_GCM)}}t.default=a},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(4),f=r(102);class a extends f.default{constructor(){super(n.MultiFormatTypes.prefix.ECIES_ENCRYPTED,n.EncryptionTypes.METHOD.ECIES)}}t.default=a},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(116),f=r(747),a=new n.default([new f.default]);t.default=a},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(4),f=r(310);class a extends f.default{constructor(){super(n.MultiFormatTypes.prefix.NORMALIZE_KECCAK256_HASH,n.MultiFormatTypes.HashTypes.TYPE.KECCAK256)}isSerializableObject(e){return super.isSerializableObject(e)&&e.value.length===n.MultiFormatTypes.FORMAT_NORMALIZE_KECCAK256_HASH_LENGTH}isDeserializableString(e){return super.isDeserializableString(e)&&e.length===n.MultiFormatTypes.FORMAT_NORMALIZE_KECCAK256_HASH_LENGTH}}t.default=a},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(116),f=r(749),a=new n.default([new f.default]);t.default=a},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(4),f=r(310);class a extends f.default{constructor(){super(n.MultiFormatTypes.prefix.IDENTITY_ETHEREUM_ADDRESS,n.IdentityTypes.TYPE.ETHEREUM_ADDRESS)}isSerializableObject(e){return super.isSerializableObject(e)&&e.value.length===n.MultiFormatTypes.FORMAT_IDENTITY_ETHEREUM_ADDRESS_LENGTH}isDeserializableString(e){return super.isDeserializableString(e)&&e.length===n.MultiFormatTypes.FORMAT_IDENTITY_ETHEREUM_ADDRESS_LENGTH}}t.default=a},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(116),f=r(751),a=new n.default([new f.default]);t.default=a},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(4),f=r(102);class a extends f.default{constructor(){super(n.MultiFormatTypes.prefix.PLAIN_TEXT,n.MultiFormatTypes.PlainTypes.TYPE.PLAIN_TEXT)}}t.default=a},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(4),f=r(59),a=r(69),i=r(780),o=r(781),s=r(782),c=r(783),u=r(784),d=r(785),l=r(786),p=r(8);t.default={applyActionToRequest:function(e,t,r,h){if(!f.default.isActionVersionSupported(t))throw new Error("action version not supported");const b=e?(0,p.deepCopy)(e):null;let m=null;if(t.data.name===n.RequestLogicTypes.ACTION_NAME.CREATE){if(b)throw new Error("no request is expected at the creation");m=c.default.createRequest(t,r)}else{if(!b)throw new Error("request is expected");a.default.checkRequest(b),t.data.name===n.RequestLogicTypes.ACTION_NAME.ACCEPT&&(m=i.default.applyActionToRequest(t,r,b)),t.data.name===n.RequestLogicTypes.ACTION_NAME.CANCEL&&(m=s.default.applyActionToRequest(t,r,b)),t.data.name===n.RequestLogicTypes.ACTION_NAME.INCREASE_EXPECTED_AMOUNT&&(m=u.default.applyActionToRequest(t,r,b)),t.data.name===n.RequestLogicTypes.ACTION_NAME.REDUCE_EXPECTED_AMOUNT&&(m=d.default.applyActionToRequest(t,r,b)),t.data.name===n.RequestLogicTypes.ACTION_NAME.ADD_STAKEHOLDERS&&(m=l.default.applyActionToRequest(t,r,b)),t.data.name===n.RequestLogicTypes.ACTION_NAME.ADD_EXTENSIONS_DATA&&(m=o.default.applyActionToRequest(t,r,b))}if(!m)throw new Error(`Unknown action ${t.data.name}`);t.data.parameters.extensionsData&&h&&(m.extensions=t.data.parameters.extensionsData.reduce(((e,n)=>h.applyActionToExtensions(e,n,m,f.default.getSignerIdentityFromAction(t),r)),m.extensions));return m},formatAccept:i.default.format,formatAddExtensionsData:o.default.format,formatCancel:s.default.format,formatCreate:c.default.format,formatIncreaseExpectedAmount:u.default.format,formatReduceExpectedAmount:d.default.format,formatAddStakeholders:l.default.format,getRequestIdFromAction:function(e){return f.default.getRequestId(e)}}},function(e,t,r){const n=r(82);e.exports=(e,t)=>{const r=n(e,t);return r?r.version:null}},function(e,t,r){const n=r(82);e.exports=(e,t)=>{const r=n(e.trim().replace(/^[=v]+/,""),t);return r?r.version:null}},function(e,t,r){const n=r(34);e.exports=(e,t,r,f,a)=>{"string"==typeof r&&(a=f,f=r,r=void 0);try{return new n(e instanceof n?e.version:e,r).inc(t,f,a).version}catch(e){return null}}},function(e,t,r){const n=r(82);e.exports=(e,t)=>{const r=n(e,null,!0),f=n(t,null,!0),a=r.compare(f);if(0===a)return null;const i=a>0,o=i?r:f,s=i?f:r,c=!!o.prerelease.length;if(!!s.prerelease.length&&!c)return s.patch||s.minor?o.patch?"patch":o.minor?"minor":"major":"major";const u=c?"pre":"";return r.major!==f.major?u+"major":r.minor!==f.minor?u+"minor":r.patch!==f.patch?u+"patch":"prerelease"}},function(e,t,r){const n=r(34);e.exports=(e,t)=>new n(e,t).major},function(e,t,r){const n=r(34);e.exports=(e,t)=>new n(e,t).minor},function(e,t,r){const n=r(34);e.exports=(e,t)=>new n(e,t).patch},function(e,t,r){const n=r(82);e.exports=(e,t)=>{const r=n(e,t);return r&&r.prerelease.length?r.prerelease:null}},function(e,t,r){const n=r(46);e.exports=(e,t,r)=>n(t,e,r)},function(e,t,r){const n=r(46);e.exports=(e,t)=>n(e,t,!0)},function(e,t,r){const n=r(170);e.exports=(e,t)=>e.sort(((e,r)=>n(e,r,t)))},function(e,t,r){const n=r(170);e.exports=(e,t)=>e.sort(((e,r)=>n(r,e,t)))},function(e,t,r){const n=r(34),f=r(82),{safeRe:a,t:i}=r(103);e.exports=(e,t)=>{if(e instanceof n)return e;if("number"==typeof e&&(e=String(e)),"string"!=typeof e)return null;let r=null;if((t=t||{}).rtl){let t;for(;(t=a[i.COERCERTL].exec(e))&&(!r||r.index+r[0].length!==e.length);)r&&t.index+t[0].length===r.index+r[0].length||(r=t),a[i.COERCERTL].lastIndex=t.index+t[1].length+t[2].length;a[i.COERCERTL].lastIndex=-1}else r=e.match(a[i.COERCE]);return null===r?null:f(`${r[2]}.${r[3]||"0"}.${r[4]||"0"}`,t)}},function(e,t,r){"use strict";const n=r(767),f=Symbol("max"),a=Symbol("length"),i=Symbol("lengthCalculator"),o=Symbol("allowStale"),s=Symbol("maxAge"),c=Symbol("dispose"),u=Symbol("noDisposeOnSet"),d=Symbol("lruList"),l=Symbol("cache"),p=Symbol("updateAgeOnGet"),h=()=>1;const b=(e,t,r)=>{const n=e[l].get(t);if(n){const t=n.value;if(m(e,t)){if(g(e,n),!e[o])return}else r&&(e[p]&&(n.value.now=Date.now()),e[d].unshiftNode(n));return t.value}},m=(e,t)=>{if(!t||!t.maxAge&&!e[s])return!1;const r=Date.now()-t.now;return t.maxAge?r>t.maxAge:e[s]&&r>e[s]},y=e=>{if(e[a]>e[f])for(let t=e[d].tail;e[a]>e[f]&&null!==t;){const r=t.prev;g(e,t),t=r}},g=(e,t)=>{if(t){const r=t.value;e[c]&&e[c](r.key,r.value),e[a]-=r.length,e[l].delete(r.key),e[d].removeNode(t)}};class v{constructor(e,t,r,n,f){this.key=e,this.value=t,this.length=r,this.now=n,this.maxAge=f||0}}const _=(e,t,r,n)=>{let f=r.value;m(e,f)&&(g(e,r),e[o]||(f=void 0)),f&&t.call(n,f.value,f.key,e)};e.exports=class{constructor(e){if("number"==typeof e&&(e={max:e}),e||(e={}),e.max&&("number"!=typeof e.max||e.max<0))throw new TypeError("max must be a non-negative number");this[f]=e.max||1/0;const t=e.length||h;if(this[i]="function"!=typeof t?h:t,this[o]=e.stale||!1,e.maxAge&&"number"!=typeof e.maxAge)throw new TypeError("maxAge must be a number");this[s]=e.maxAge||0,this[c]=e.dispose,this[u]=e.noDisposeOnSet||!1,this[p]=e.updateAgeOnGet||!1,this.reset()}set max(e){if("number"!=typeof e||e<0)throw new TypeError("max must be a non-negative number");this[f]=e||1/0,y(this)}get max(){return this[f]}set allowStale(e){this[o]=!!e}get allowStale(){return this[o]}set maxAge(e){if("number"!=typeof e)throw new TypeError("maxAge must be a non-negative number");this[s]=e,y(this)}get maxAge(){return this[s]}set lengthCalculator(e){"function"!=typeof e&&(e=h),e!==this[i]&&(this[i]=e,this[a]=0,this[d].forEach((e=>{e.length=this[i](e.value,e.key),this[a]+=e.length}))),y(this)}get lengthCalculator(){return this[i]}get length(){return this[a]}get itemCount(){return this[d].length}rforEach(e,t){t=t||this;for(let r=this[d].tail;null!==r;){const n=r.prev;_(this,e,r,t),r=n}}forEach(e,t){t=t||this;for(let r=this[d].head;null!==r;){const n=r.next;_(this,e,r,t),r=n}}keys(){return this[d].toArray().map((e=>e.key))}values(){return this[d].toArray().map((e=>e.value))}reset(){this[c]&&this[d]&&this[d].length&&this[d].forEach((e=>this[c](e.key,e.value))),this[l]=new Map,this[d]=new n,this[a]=0}dump(){return this[d].map((e=>!m(this,e)&&{k:e.key,v:e.value,e:e.now+(e.maxAge||0)})).toArray().filter((e=>e))}dumpLru(){return this[d]}set(e,t,r){if((r=r||this[s])&&"number"!=typeof r)throw new TypeError("maxAge must be a number");const n=r?Date.now():0,o=this[i](t,e);if(this[l].has(e)){if(o>this[f])return g(this,this[l].get(e)),!1;const i=this[l].get(e).value;return this[c]&&(this[u]||this[c](e,i.value)),i.now=n,i.maxAge=r,i.value=t,this[a]+=o-i.length,i.length=o,this.get(e),y(this),!0}const p=new v(e,t,o,n,r);return p.length>this[f]?(this[c]&&this[c](e,t),!1):(this[a]+=p.length,this[d].unshift(p),this[l].set(e,this[d].head),y(this),!0)}has(e){if(!this[l].has(e))return!1;const t=this[l].get(e).value;return!m(this,t)}get(e){return b(this,e,!0)}peek(e){return b(this,e,!1)}pop(){const e=this[d].tail;return e?(g(this,e),e.value):null}del(e){g(this,this[l].get(e))}load(e){this.reset();const t=Date.now();for(let r=e.length-1;r>=0;r--){const n=e[r],f=n.e||0;if(0===f)this.set(n.k,n.v);else{const e=f-t;e>0&&this.set(n.k,n.v,e)}}}prune(){this[l].forEach(((e,t)=>b(this,t,!1)))}}},function(e,t,r){"use strict";function n(e){var t=this;if(t instanceof n||(t=new n),t.tail=null,t.head=null,t.length=0,e&&"function"==typeof e.forEach)e.forEach((function(e){t.push(e)}));else if(arguments.length>0)for(var r=0,f=arguments.length;r<f;r++)t.push(arguments[r]);return t}function f(e,t,r){var n=t===e.head?new o(r,null,t,e):new o(r,t,t.next,e);return null===n.next&&(e.tail=n),null===n.prev&&(e.head=n),e.length++,n}function a(e,t){e.tail=new o(t,e.tail,null,e),e.head||(e.head=e.tail),e.length++}function i(e,t){e.head=new o(t,null,e.head,e),e.tail||(e.tail=e.head),e.length++}function o(e,t,r,n){if(!(this instanceof o))return new o(e,t,r,n);this.list=n,this.value=e,t?(t.next=this,this.prev=t):this.prev=null,r?(r.prev=this,this.next=r):this.next=null}e.exports=n,n.Node=o,n.create=n,n.prototype.removeNode=function(e){if(e.list!==this)throw new Error("removing node which does not belong to this list");var t=e.next,r=e.prev;return t&&(t.prev=r),r&&(r.next=t),e===this.head&&(this.head=t),e===this.tail&&(this.tail=r),e.list.length--,e.next=null,e.prev=null,e.list=null,t},n.prototype.unshiftNode=function(e){if(e!==this.head){e.list&&e.list.removeNode(e);var t=this.head;e.list=this,e.next=t,t&&(t.prev=e),this.head=e,this.tail||(this.tail=e),this.length++}},n.prototype.pushNode=function(e){if(e!==this.tail){e.list&&e.list.removeNode(e);var t=this.tail;e.list=this,e.prev=t,t&&(t.next=e),this.tail=e,this.head||(this.head=e),this.length++}},n.prototype.push=function(){for(var e=0,t=arguments.length;e<t;e++)a(this,arguments[e]);return this.length},n.prototype.unshift=function(){for(var e=0,t=arguments.length;e<t;e++)i(this,arguments[e]);return this.length},n.prototype.pop=function(){if(this.tail){var e=this.tail.value;return this.tail=this.tail.prev,this.tail?this.tail.next=null:this.head=null,this.length--,e}},n.prototype.shift=function(){if(this.head){var e=this.head.value;return this.head=this.head.next,this.head?this.head.prev=null:this.tail=null,this.length--,e}},n.prototype.forEach=function(e,t){t=t||this;for(var r=this.head,n=0;null!==r;n++)e.call(t,r.value,n,this),r=r.next},n.prototype.forEachReverse=function(e,t){t=t||this;for(var r=this.tail,n=this.length-1;null!==r;n--)e.call(t,r.value,n,this),r=r.prev},n.prototype.get=function(e){for(var t=0,r=this.head;null!==r&&t<e;t++)r=r.next;if(t===e&&null!==r)return r.value},n.prototype.getReverse=function(e){for(var t=0,r=this.tail;null!==r&&t<e;t++)r=r.prev;if(t===e&&null!==r)return r.value},n.prototype.map=function(e,t){t=t||this;for(var r=new n,f=this.head;null!==f;)r.push(e.call(t,f.value,this)),f=f.next;return r},n.prototype.mapReverse=function(e,t){t=t||this;for(var r=new n,f=this.tail;null!==f;)r.push(e.call(t,f.value,this)),f=f.prev;return r},n.prototype.reduce=function(e,t){var r,n=this.head;if(arguments.length>1)r=t;else{if(!this.head)throw new TypeError("Reduce of empty list with no initial value");n=this.head.next,r=this.head.value}for(var f=0;null!==n;f++)r=e(r,n.value,f),n=n.next;return r},n.prototype.reduceReverse=function(e,t){var r,n=this.tail;if(arguments.length>1)r=t;else{if(!this.tail)throw new TypeError("Reduce of empty list with no initial value");n=this.tail.prev,r=this.tail.value}for(var f=this.length-1;null!==n;f--)r=e(r,n.value,f),n=n.prev;return r},n.prototype.toArray=function(){for(var e=new Array(this.length),t=0,r=this.head;null!==r;t++)e[t]=r.value,r=r.next;return e},n.prototype.toArrayReverse=function(){for(var e=new Array(this.length),t=0,r=this.tail;null!==r;t++)e[t]=r.value,r=r.prev;return e},n.prototype.slice=function(e,t){(t=t||this.length)<0&&(t+=this.length),(e=e||0)<0&&(e+=this.length);var r=new n;if(t<e||t<0)return r;e<0&&(e=0),t>this.length&&(t=this.length);for(var f=0,a=this.head;null!==a&&f<e;f++)a=a.next;for(;null!==a&&f<t;f++,a=a.next)r.push(a.value);return r},n.prototype.sliceReverse=function(e,t){(t=t||this.length)<0&&(t+=this.length),(e=e||0)<0&&(e+=this.length);var r=new n;if(t<e||t<0)return r;e<0&&(e=0),t>this.length&&(t=this.length);for(var f=this.length,a=this.tail;null!==a&&f>t;f--)a=a.prev;for(;null!==a&&f>e;f--,a=a.prev)r.push(a.value);return r},n.prototype.splice=function(e,t,...r){e>this.length&&(e=this.length-1),e<0&&(e=this.length+e);for(var n=0,a=this.head;null!==a&&n<e;n++)a=a.next;var i=[];for(n=0;a&&n<t;n++)i.push(a.value),a=this.removeNode(a);null===a&&(a=this.tail),a!==this.head&&a!==this.tail&&(a=a.prev);for(n=0;n<r.length;n++)a=f(this,a,r[n]);return i},n.prototype.reverse=function(){for(var e=this.head,t=this.tail,r=e;null!==r;r=r.prev){var n=r.prev;r.prev=r.next,r.next=n}return this.head=t,this.tail=e,this};try{r(768)(n)}catch(e){}},function(e,t,r){"use strict";e.exports=function(e){e.prototype[Symbol.iterator]=function*(){for(let e=this.head;e;e=e.next)yield e.value}}},function(e,t,r){const n=r(47);e.exports=(e,t)=>new n(e,t).set.map((e=>e.map((e=>e.value)).join(" ").trim().split(" ")))},function(e,t,r){const n=r(34),f=r(47);e.exports=(e,t,r)=>{let a=null,i=null,o=null;try{o=new f(t,r)}catch(e){return null}return e.forEach((e=>{o.test(e)&&(a&&-1!==i.compare(e)||(a=e,i=new n(a,r)))})),a}},function(e,t,r){const n=r(34),f=r(47);e.exports=(e,t,r)=>{let a=null,i=null,o=null;try{o=new f(t,r)}catch(e){return null}return e.forEach((e=>{o.test(e)&&(a&&1!==i.compare(e)||(a=e,i=new n(a,r)))})),a}},function(e,t,r){const n=r(34),f=r(47),a=r(119);e.exports=(e,t)=>{e=new f(e,t);let r=new n("0.0.0");if(e.test(r))return r;if(r=new n("0.0.0-0"),e.test(r))return r;r=null;for(let t=0;t<e.set.length;++t){const f=e.set[t];let i=null;f.forEach((e=>{const t=new n(e.semver.version);switch(e.operator){case">":0===t.prerelease.length?t.patch++:t.prerelease.push(0),t.raw=t.format();case"":case">=":i&&!a(t,i)||(i=t);break;case"<":case"<=":break;default:throw new Error(`Unexpected operation: ${e.operator}`)}})),!i||r&&!a(r,i)||(r=i)}return r&&e.test(r)?r:null}},function(e,t,r){const n=r(47);e.exports=(e,t)=>{try{return new n(e,t).range||"*"}catch(e){return null}}},function(e,t,r){const n=r(174);e.exports=(e,t,r)=>n(e,t,">",r)},function(e,t,r){const n=r(174);e.exports=(e,t,r)=>n(e,t,"<",r)},function(e,t,r){const n=r(47);e.exports=(e,t,r)=>(e=new n(e,r),t=new n(t,r),e.intersects(t,r))},function(e,t,r){const n=r(121),f=r(46);e.exports=(e,t,r)=>{const a=[];let i=null,o=null;const s=e.sort(((e,t)=>f(e,t,r)));for(const e of s){n(e,t,r)?(o=e,i||(i=e)):(o&&a.push([i,o]),o=null,i=null)}i&&a.push([i,null]);const c=[];for(const[e,t]of a)e===t?c.push(e):t||e!==s[0]?t?e===s[0]?c.push(`<=${t}`):c.push(`${e} - ${t}`):c.push(`>=${e}`):c.push("*");const u=c.join(" || "),d="string"==typeof t.raw?t.raw:String(t);return u.length<d.length?u:t}},function(e,t,r){const n=r(47),f=r(120),{ANY:a}=f,i=r(121),o=r(46),s=[new f(">=0.0.0-0")],c=[new f(">=0.0.0")],u=(e,t,r)=>{if(e===t)return!0;if(1===e.length&&e[0].semver===a){if(1===t.length&&t[0].semver===a)return!0;e=r.includePrerelease?s:c}if(1===t.length&&t[0].semver===a){if(r.includePrerelease)return!0;t=c}const n=new Set;let f,u,p,h,b,m,y;for(const t of e)">"===t.operator||">="===t.operator?f=d(f,t,r):"<"===t.operator||"<="===t.operator?u=l(u,t,r):n.add(t.semver);if(n.size>1)return null;if(f&&u){if(p=o(f.semver,u.semver,r),p>0)return null;if(0===p&&(">="!==f.operator||"<="!==u.operator))return null}for(const e of n){if(f&&!i(e,String(f),r))return null;if(u&&!i(e,String(u),r))return null;for(const n of t)if(!i(e,String(n),r))return!1;return!0}let g=!(!u||r.includePrerelease||!u.semver.prerelease.length)&&u.semver,v=!(!f||r.includePrerelease||!f.semver.prerelease.length)&&f.semver;g&&1===g.prerelease.length&&"<"===u.operator&&0===g.prerelease[0]&&(g=!1);for(const e of t){if(y=y||">"===e.operator||">="===e.operator,m=m||"<"===e.operator||"<="===e.operator,f)if(v&&e.semver.prerelease&&e.semver.prerelease.length&&e.semver.major===v.major&&e.semver.minor===v.minor&&e.semver.patch===v.patch&&(v=!1),">"===e.operator||">="===e.operator){if(h=d(f,e,r),h===e&&h!==f)return!1}else if(">="===f.operator&&!i(f.semver,String(e),r))return!1;if(u)if(g&&e.semver.prerelease&&e.semver.prerelease.length&&e.semver.major===g.major&&e.semver.minor===g.minor&&e.semver.patch===g.patch&&(g=!1),"<"===e.operator||"<="===e.operator){if(b=l(u,e,r),b===e&&b!==u)return!1}else if("<="===u.operator&&!i(u.semver,String(e),r))return!1;if(!e.operator&&(u||f)&&0!==p)return!1}return!(f&&m&&!u&&0!==p)&&(!(u&&y&&!f&&0!==p)&&(!v&&!g))},d=(e,t,r)=>{if(!e)return t;const n=o(e.semver,t.semver,r);return n>0?e:n<0||">"===t.operator&&">="===e.operator?t:e},l=(e,t,r)=>{if(!e)return t;const n=o(e.semver,t.semver,r);return n<0?e:n>0||"<"===t.operator&&"<="===e.operator?t:e};e.exports=(e,t,r={})=>{if(e===t)return!0;e=new n(e,r),t=new n(t,r);let f=!1;e:for(const n of e.set){for(const e of t.set){const t=u(n,e,r);if(f=f||null!==t,t)continue e}if(f)return!1}return!0}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default={specificationVersion:{current:"2.0.3",exceptions:[]}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(4),f=r(59),a=r(69),i=r(60),o=r(8);function s(e,t,r){const f=e.data.parameters;return{actionSigner:r,name:n.RequestLogicTypes.ACTION_NAME.ACCEPT,parameters:{extensionsDataLength:f.extensionsData?f.extensionsData.length:0},timestamp:t}}t.default={applyActionToRequest:function(e,t,r){if(!e.data.parameters.requestId)throw new Error("requestId must be given");if(!r.payer)throw new Error("the request must have a payer");if(r.state!==n.RequestLogicTypes.STATE.CREATED)throw new Error("the request state must be created");const i=f.default.getSignerIdentityFromAction(e);if(a.default.getRoleInRequest(i,r)!==n.RequestLogicTypes.ROLE.PAYER)throw new Error("Signer must be the payer");r.state=n.RequestLogicTypes.STATE.ACCEPTED;let c=(0,o.deepCopy)(r);return c=a.default.pushExtensionsData(c,e.data.parameters.extensionsData),c.events.push(s(e,t,i)),c},format:function(e,t,r){const a={name:n.RequestLogicTypes.ACTION_NAME.ACCEPT,parameters:e,version:i.default.currentVersion};return f.default.createAction(a,t,r)}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(4),f=r(59),a=r(69),i=r(60),o=r(8);function s(e,t,r){const f=e.data.parameters;return{actionSigner:r,name:n.RequestLogicTypes.ACTION_NAME.ADD_EXTENSIONS_DATA,parameters:{extensionsDataLength:f.extensionsData?f.extensionsData.length:0},timestamp:t}}t.default={applyActionToRequest:function(e,t,r){if(!e.data.parameters.requestId)throw new Error("requestId must be given");if(!e.data.parameters.extensionsData||0===e.data.parameters.extensionsData.length)throw new Error("extensionsData must be given");const n=f.default.getSignerIdentityFromAction(e);let i=(0,o.deepCopy)(r);return i=a.default.pushExtensionsData(i,e.data.parameters.extensionsData),i.events.push(s(e,t,n)),i},format:function(e,t,r){if(!e.extensionsData||0===e.extensionsData.length)throw new Error("extensionsData must be given");const a={name:n.RequestLogicTypes.ACTION_NAME.ADD_EXTENSIONS_DATA,parameters:e,version:i.default.currentVersion};return f.default.createAction(a,t,r)}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(4),f=r(59),a=r(69),i=r(60),o=r(8);function s(e,t,r){const f=e.data.parameters;return{actionSigner:r,name:n.RequestLogicTypes.ACTION_NAME.CANCEL,parameters:{extensionsDataLength:f.extensionsData?f.extensionsData.length:0},timestamp:t}}t.default={applyActionToRequest:function(e,t,r){if(!e.data.parameters.requestId)throw new Error("requestId must be given");const i=f.default.getSignerIdentityFromAction(e),c=a.default.getRoleInRequest(i,r);let u=(0,o.deepCopy)(r);if(u=a.default.pushExtensionsData(u,e.data.parameters.extensionsData),u.events.push(s(e,t,i)),c===n.RequestLogicTypes.ROLE.PAYER){if(r.state!==n.RequestLogicTypes.STATE.CREATED)throw new Error("A payer cancel need to be done on a request with the state created");return u.state=n.RequestLogicTypes.STATE.CANCELED,u}if(c===n.RequestLogicTypes.ROLE.PAYEE){if(r.state===n.RequestLogicTypes.STATE.CANCELED)throw new Error("Cannot cancel an already canceled request");return u.state=n.RequestLogicTypes.STATE.CANCELED,u}throw new Error("Signer must be the payer or the payee")},format:function(e,t,r){const a={name:n.RequestLogicTypes.ACTION_NAME.CANCEL,parameters:e,version:i.default.currentVersion};return f.default.createAction(a,t,r)}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(4),f=r(168),a=r(59),i=r(60),o=r(8);function s(e,t,r){const f=e.data.parameters;return{actionSigner:r,name:n.RequestLogicTypes.ACTION_NAME.CREATE,parameters:{expectedAmount:f.expectedAmount,extensionsDataLength:f.extensionsData?f.extensionsData.length:0,isSignedRequest:!1},timestamp:t}}t.default={createRequest:function(e,t){if(!e.data.parameters.payee&&!e.data.parameters.payer)throw new Error("action.parameters.payee or action.parameters.payer must be given");if(e.data.parameters.payee&&(0,o.identityHasError)(e.data.parameters.payee))throw new Error(`payee: ${(0,o.identityHasError)(e.data.parameters.payee)}̀`);if(e.data.parameters.payer&&(0,o.identityHasError)(e.data.parameters.payer))throw new Error(`payer: ${(0,o.identityHasError)(e.data.parameters.payer)}̀`);if(!(0,o.isString)(e.data.parameters.expectedAmount)||!(0,o.isValidAmount)(e.data.parameters.expectedAmount))throw new Error("action.parameters.expectedAmount must be a string representing a positive integer");const r=a.default.getSignerIdentityFromAction(e),i=(0,o.deepCopy)(e.data.parameters);i.extensions={},i.requestId=a.default.getRequestId(e),i.version=a.default.getVersionFromAction(e),i.events=[s(e,t,r)],f.lt(e.data.version,"2.0.2")&&(i.currency=function(e){switch(e){case"BTC":return{network:"mainnet",type:n.RequestLogicTypes.CURRENCY.BTC,value:"BTC"};case"ETH":return{network:"mainnet",type:n.RequestLogicTypes.CURRENCY.ETH,value:"ETH"};case"EUR":return{type:n.RequestLogicTypes.CURRENCY.ISO4217,value:"EUR"};case"USD":return{type:n.RequestLogicTypes.CURRENCY.ISO4217,value:"USD"};case"DAI":return{type:n.RequestLogicTypes.CURRENCY.ERC20,value:"0x89d24A6b4CcB1B6fAA2625fE562bDD9a23260359"};default:throw new Error("Unsupported currency when getting request from transactions.")}}(e.data.parameters.currency));const c=a.default.getRoleInAction(r,e);if(c===n.RequestLogicTypes.ROLE.PAYEE)return i.state=n.RequestLogicTypes.STATE.CREATED,i.creator=e.data.parameters.payee,i;if(c===n.RequestLogicTypes.ROLE.PAYER)return i.state=n.RequestLogicTypes.STATE.ACCEPTED,i.creator=e.data.parameters.payer,i;throw new Error("Signer must be the payee or the payer")},format:function(e,t,r){if(!e.payee&&!e.payer)throw new Error("payee or PayerId must be given");if(!(0,o.isValidAmount)(e.expectedAmount))throw new Error("expectedAmount must be a positive integer");if(e.payee&&(0,o.identityHasError)(e.payee))throw new Error(`payee: ${(0,o.identityHasError)(e.payee)}̀`);if(e.payer&&(0,o.identityHasError)(e.payer))throw new Error(`payer: ${(0,o.identityHasError)(e.payer)}̀`);e.timestamp||(e.timestamp=(0,o.getCurrentTimestampInSecond)());e.expectedAmount=e.expectedAmount.toString();const f=i.default.currentVersion,s={name:n.RequestLogicTypes.ACTION_NAME.CREATE,parameters:e,version:f},c=a.default.getRoleInUnsignedAction(t,s);if(c!==n.RequestLogicTypes.ROLE.PAYEE&&c!==n.RequestLogicTypes.ROLE.PAYER)throw new Error("Signer must be the payee or the payer");return a.default.createAction(s,t,r)}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(4),f=r(59),a=r(69),i=r(60),o=r(8);function s(e,t,r){const f=e.data.parameters;return{actionSigner:r,name:n.RequestLogicTypes.ACTION_NAME.INCREASE_EXPECTED_AMOUNT,parameters:{deltaAmount:e.data.parameters.deltaAmount,extensionsDataLength:f.extensionsData?f.extensionsData.length:0},timestamp:t}}t.default={applyActionToRequest:function(e,t,r){if(!e.data.parameters.requestId)throw new Error("requestId must be given");if(!r.payer)throw new Error("the request must have a payer");if(!e.data.parameters.deltaAmount)throw new Error("deltaAmount must be given");if(!(0,o.isValidAmount)(e.data.parameters.deltaAmount))throw new Error("deltaAmount must be a string representing a positive integer");const i=f.default.getSignerIdentityFromAction(e),c=a.default.getRoleInRequest(i,r);let u=(0,o.deepCopy)(r);if(u=a.default.pushExtensionsData(u,e.data.parameters.extensionsData),u.events.push(s(e,t,i)),c===n.RequestLogicTypes.ROLE.PAYER){if(r.state===n.RequestLogicTypes.STATE.CANCELED)throw new Error("the request must not be canceled");return u.expectedAmount=(0,o.addAmount)(r.expectedAmount,e.data.parameters.deltaAmount),u}throw new Error("signer must be the payer")},format:function(e,t,r){if(!(0,o.isValidAmount)(e.deltaAmount))throw new Error("deltaAmount must be a string representing a positive integer");const a={name:n.RequestLogicTypes.ACTION_NAME.INCREASE_EXPECTED_AMOUNT,parameters:e,version:i.default.currentVersion};return f.default.createAction(a,t,r)}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(4),f=r(59),a=r(69),i=r(60),o=r(8);function s(e,t,r){const f=e.data.parameters;return{actionSigner:r,name:n.RequestLogicTypes.ACTION_NAME.REDUCE_EXPECTED_AMOUNT,parameters:{deltaAmount:e.data.parameters.deltaAmount,extensionsDataLength:f.extensionsData?f.extensionsData.length:0},timestamp:t}}t.default={applyActionToRequest:function(e,t,r){if(!e.data.parameters.requestId)throw new Error("requestId must be given");if(!r.payee)throw new Error("the request must have a payee");if(!e.data.parameters.deltaAmount)throw new Error("deltaAmount must be given");if(!(0,o.isValidAmount)(e.data.parameters.deltaAmount))throw new Error("deltaAmount must be a string representing a positive integer");const i=f.default.getSignerIdentityFromAction(e),c=a.default.getRoleInRequest(i,r);let u=(0,o.deepCopy)(r);if(u=a.default.pushExtensionsData(u,e.data.parameters.extensionsData),u.events.push(s(e,t,i)),c===n.RequestLogicTypes.ROLE.PAYEE){if(r.state===n.RequestLogicTypes.STATE.CANCELED)throw new Error("the request must not be canceled");return u.expectedAmount=(0,o.reduceAmount)(r.expectedAmount,e.data.parameters.deltaAmount),u}throw new Error("signer must be the payee")},format:function(e,t,r){if(!(0,o.isValidAmount)(e.deltaAmount))throw new Error("deltaAmount must be a string representing a positive integer");const a={name:n.RequestLogicTypes.ACTION_NAME.REDUCE_EXPECTED_AMOUNT,parameters:e,version:i.default.currentVersion};return f.default.createAction(a,t,r)}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(4),f=r(8),a=r(59),i=r(69),o=r(60);function s(e,t,r){const f=e.data.parameters;return{actionSigner:r,name:n.RequestLogicTypes.ACTION_NAME.ADD_STAKEHOLDERS,parameters:{extensionsDataLength:f.extensionsData?f.extensionsData.length:0},timestamp:t}}t.default={applyActionToRequest:function(e,t,r){if(!e.data.parameters.requestId)throw new Error("requestId must be given");const n=a.default.getSignerIdentityFromAction(e);let o=(0,f.deepCopy)(r);return o=i.default.pushExtensionsData(o,e.data.parameters.extensionsData),o.events.push(s(e,t,n)),o},format:function(e,t,r){const f={name:n.RequestLogicTypes.ACTION_NAME.ADD_STAKEHOLDERS,parameters:e,version:o.default.currentVersion};return a.default.createAction(f,t,r)}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.TransactionManager=void 0;var n=r(788);Object.defineProperty(t,"TransactionManager",{enumerable:!0,get:function(){return n.default}})},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(83),f=r(52),a=r(4),i=r(8),o=r(32),s=r(789),c=r(793);t.default=class{constructor(e,t){this.dataAccess=e,this.channelParser=new s.default(t)}persistTransaction(e,t,r=[],s=[]){return n.__awaiter(this,void 0,void 0,(function*(){let n,u={};const d=f.default.serialize((0,i.normalizeKeccak256Hash)(JSON.parse(e)));if(t===d)0===s.length?u=yield c.default.createClearTransaction(e):(u=yield c.default.createEncryptedTransactionInNewChannel(e,s),n=u.encryptionMethod);else{const r=yield this.dataAccess.getTransactionsByChannelId(t),{channelKey:f,channelType:i,encryptionMethod:o}=yield this.channelParser.getChannelTypeAndChannelKey(t,r.result.transactions);if(i===a.TransactionTypes.ChannelType.UNKNOWN)throw new Error(`Impossible to retrieve the channel: ${t}`);if(i===a.TransactionTypes.ChannelType.CLEAR&&(u=yield c.default.createClearTransaction(e)),i===a.TransactionTypes.ChannelType.ENCRYPTED){if(!f)throw new Error(`Impossible to decrypt the channel key of: ${t}`);u=yield c.default.createEncryptedTransaction(e,f,s),n=o}}const l=yield this.dataAccess.persistTransaction(u,t,r.concat([d])),p=Object.assign(new o.EventEmitter,{meta:{dataAccessMeta:l.meta,encryptionMethod:n},result:{}});return l.on("confirmed",(e=>{const t={meta:{dataAccessMeta:e.meta,encryptionMethod:n},result:{}};p.emit("confirmed",t)})).on("error",(e=>{p.emit("error",e)})),p}))}getTransactionsByChannelId(e,t){return n.__awaiter(this,void 0,void 0,(function*(){const r=yield this.dataAccess.getTransactionsByChannelId(e,t),{transactions:n,ignoredTransactions:f,encryptionMethod:a}=yield this.channelParser.decryptAndCleanChannel(e,r.result.transactions),i={dataAccessMeta:r.meta,encryptionMethod:a,ignoredTransactions:f};return a||delete i.encryptionMethod,{meta:i,result:{transactions:n}}}))}getChannelsByTopic(e,t){return n.__awaiter(this,void 0,void 0,(function*(){const r=yield this.dataAccess.getChannelsByTopic(e,t);return this.parseMultipleChannels(r)}))}getChannelsByMultipleTopics(e,t){return n.__awaiter(this,void 0,void 0,(function*(){const r=yield this.dataAccess.getChannelsByMultipleTopics(e,t);return this.parseMultipleChannels(r)}))}parseMultipleChannels(e){return n.__awaiter(this,void 0,void 0,(function*(){const t=yield Object.keys(e.result.transactions).reduce(((t,r)=>n.__awaiter(this,void 0,void 0,(function*(){const n=yield this.channelParser.decryptAndCleanChannel(r,e.result.transactions[r]),f=yield t;return f.transactions[r]=n.transactions,f.ignoredTransactions[r]=n.ignoredTransactions,f}))),Promise.resolve({transactions:{},ignoredTransactions:{}}));return{meta:{dataAccessMeta:e.meta,ignoredTransactions:t.ignoredTransactions},result:{transactions:t.transactions}}}))}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(83),f=r(4),a=r(790);t.default=class{constructor(e){this.transactionParser=new a.default(e)}decryptAndCleanChannel(e,t){return n.__awaiter(this,void 0,void 0,(function*(){let r,a=f.TransactionTypes.ChannelType.UNKNOWN;const{channelKey:i}=yield this.getChannelTypeAndChannelKey(e,t),o=yield t.reduce(((t,o)=>n.__awaiter(this,void 0,void 0,(function*(){const n=yield t;let s;try{s=yield this.transactionParser.parsePersistedTransaction(o.transaction,a,i,r)}catch(u){return n.concat([{ignored:{reason:u.message,transaction:o},valid:null}])}const c=s.transaction,u=yield c.getError();if(""!==u)return n.concat([{ignored:{reason:u,transaction:o},valid:null}]);if(a===f.TransactionTypes.ChannelType.UNKNOWN){if((yield c.getHash())!==e)return n.concat([{ignored:{reason:"as first transaction, the hash of the transaction do not match the channelId",transaction:o},valid:null}]);a=s.channelKey?f.TransactionTypes.ChannelType.ENCRYPTED:f.TransactionTypes.ChannelType.CLEAR,r=s.encryptionMethod}const d=yield c.getData();return n.concat([{ignored:null,valid:{state:o.state,timestamp:o.timestamp,transaction:{data:d}}}])}))),Promise.resolve([])),s=o.map((e=>e.ignored)),c=o.map((e=>e.valid));return{encryptionMethod:r,ignoredTransactions:s,transactions:c}}))}getChannelTypeAndChannelKey(e,t){return n.__awaiter(this,void 0,void 0,(function*(){return yield t.reduce(((e,t)=>n.__awaiter(this,void 0,void 0,(function*(){const r=yield e;if(r.channelType===f.TransactionTypes.ChannelType.CLEAR||r.channelKey)return r;let n;try{n=yield this.transactionParser.parsePersistedTransaction(t.transaction,r.channelType,r.channelKey,r.encryptionMethod)}catch(i){return i.message.startsWith("Impossible to decrypt the channel key from this transaction")&&r.channelType===f.TransactionTypes.ChannelType.UNKNOWN&&(r.channelType=f.TransactionTypes.ChannelType.ENCRYPTED,r.encryptionMethod=t.transaction.encryptionMethod),r}const a=n.transaction,i=undefined;return""!==(yield a.getError())||(r.channelType=n.channelKey?f.TransactionTypes.ChannelType.ENCRYPTED:f.TransactionTypes.ChannelType.CLEAR,r.channelKey=n.channelKey,r.encryptionMethod=n.encryptionMethod),r}))),Promise.resolve({channelKey:void 0,channelType:f.TransactionTypes.ChannelType.UNKNOWN,encryptionMethod:void 0}))}))}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(83),f=r(52),a=r(4),i=r(791),o=r(792);t.default=class{constructor(e){this.decryptionProvider=e}parsePersistedTransaction(e,t,r,f){return n.__awaiter(this,void 0,void 0,(function*(){if(e.data){if(t===a.TransactionTypes.ChannelType.ENCRYPTED)throw new Error("Clear transactions are not allowed in encrypted channel");if(e.encryptedData||e.encryptionMethod||e.keys)throw new Error('only the property "data" is allowed for clear transaction');return{transaction:new i.default(e.data)}}if(e.encryptedData){if(t===a.TransactionTypes.ChannelType.CLEAR)throw new Error("Encrypted transactions are not allowed in clear channel");if(r)if(f){if(e.encryptionMethod)throw new Error('the "encryptionMethod" property has been already given for this channel')}else{if(!e.encryptionMethod)throw new Error('the "encryptionMethod" property is needed to use the channel key');f=e.encryptionMethod}else if(f){if(e.encryptionMethod)throw new Error('the "encryptionMethod" property has been already given for this channel');if(!e.keys)throw new Error('the "keys" property is needed to compute the channel key');r=yield this.decryptChannelKey(e.keys,f)}else{if(!e.encryptionMethod||!e.keys)throw new Error('the properties "encryptionMethod" and "keys" are needed to compute the channel key');f=e.encryptionMethod,r=yield this.decryptChannelKey(e.keys,f)}return{channelKey:r,encryptionMethod:f,transaction:new o.default(e.encryptedData,r)}}throw new Error('Transaction must have a property "data" or "encryptedData"')}))}decryptChannelKey(e,t){return n.__awaiter(this,void 0,void 0,(function*(){if(!this.decryptionProvider)throw new Error("No decryption provider given");let r;if(t===`${a.EncryptionTypes.METHOD.ECIES}-${a.EncryptionTypes.METHOD.AES256_CBC}`)r=a.EncryptionTypes.METHOD.AES256_CBC;else{if(t!==`${a.EncryptionTypes.METHOD.ECIES}-${a.EncryptionTypes.METHOD.AES256_GCM}`)throw new Error(`Encryption method not supported: ${t}`);r=a.EncryptionTypes.METHOD.AES256_GCM}let i="";const o=yield Object.keys(e||{}).reduce(((t,r)=>n.__awaiter(this,void 0,void 0,(function*(){let n=yield t;if(e&&""===n){let t;try{t=f.default.deserialize(r)}catch(e){}if(t&&t.type===a.IdentityTypes.TYPE.ETHEREUM_ADDRESS&&this.decryptionProvider&&(yield this.decryptionProvider.isIdentityRegistered(t)))try{const a=f.default.deserialize(e[r]);n=yield this.decryptionProvider.decrypt(a,t)}catch(e){i=e.message}}return n}))),Promise.resolve(""));if(""===o)throw new Error(`Impossible to decrypt the channel key from this transaction (${i})`);return{key:o,method:r}}))}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(83),f=r(52),a=r(8);t.default=class{constructor(e){this.data=e}getData(){return n.__awaiter(this,void 0,void 0,(function*(){return this.data}))}getHash(){return n.__awaiter(this,void 0,void 0,(function*(){return f.default.serialize((0,a.normalizeKeccak256Hash)(JSON.parse(this.data)))}))}getError(){return n.__awaiter(this,void 0,void 0,(function*(){try{return JSON.parse(this.data),""}catch(e){return"Impossible to JSON parse the transaction"}}))}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(83),f=r(52),a=r(8);t.default=class{constructor(e,t){this.data="",this.dataHashSerialized="",this.persistedData=e,this.channelKey=t}getData(){return n.__awaiter(this,void 0,void 0,(function*(){if(""===this.data)try{const e=f.default.deserialize(this.persistedData);this.data=yield(0,a.decrypt)(e,this.channelKey)}catch(e){throw new Error("Impossible to decrypt the transaction")}return this.data}))}getHash(){return n.__awaiter(this,void 0,void 0,(function*(){if(""===this.dataHashSerialized){const e=yield this.getData();try{const t=(0,a.normalizeKeccak256Hash)(JSON.parse(e));this.dataHashSerialized=f.default.serialize(t)}catch(e){throw new Error("Impossible to JSON parse the decrypted transaction data")}}return this.dataHashSerialized}))}getError(){return n.__awaiter(this,void 0,void 0,(function*(){let e="";try{e=yield this.getData()}catch(e){return e.message}try{JSON.parse(e)}catch(e){return"Impossible to JSON parse the decrypted transaction data"}return""}))}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(83),f=r(52),a=r(4),i=r(8);t.default=class{static createClearTransaction(e){return n.__awaiter(this,void 0,void 0,(function*(){try{JSON.parse(e)}catch(e){throw new Error("Data not parsable")}return{data:e}}))}static createEncryptedTransactionInNewChannel(e,t){return n.__awaiter(this,void 0,void 0,(function*(){const r=`${a.EncryptionTypes.METHOD.ECIES}-${a.EncryptionTypes.METHOD.AES256_GCM}`,o=yield(0,i.generate32BufferKey)(),s=yield(0,i.encrypt)(e,{key:o,method:a.EncryptionTypes.METHOD.AES256_GCM});try{JSON.parse(e)}catch(e){throw new Error("Data not parsable")}if(!t.every((e=>e.method===a.EncryptionTypes.METHOD.ECIES)))throw new Error(`encryptionParams method must be all: ${a.EncryptionTypes.METHOD.ECIES}`);const c=t.map((e=>n.__awaiter(this,void 0,void 0,(function*(){const t=yield(0,i.encrypt)(o,e),r=(0,i.getIdentityFromEncryptionParams)(e);return{encryptedKey:t,multiFormattedIdentity:f.default.serialize(r)}})))),u=(yield Promise.all(c)).reduce(((e,t)=>{const r=f.default.serialize(t.encryptedKey);return e[t.multiFormattedIdentity]=r,e}),{});return{encryptedData:f.default.serialize(s),keys:u,encryptionMethod:r}}))}static createEncryptedTransaction(e,t,r=[]){return n.__awaiter(this,void 0,void 0,(function*(){if(t.method!==a.EncryptionTypes.METHOD.AES256_GCM)throw new Error(`encryption method not supported for the channel key: ${t.method}`);const o=yield(0,i.encrypt)(e,t);try{JSON.parse(e)}catch(e){throw new Error("Data not parsable")}const s=f.default.serialize(o);if(0===r.length)return{encryptedData:s};{if(!r.every((e=>e.method===a.EncryptionTypes.METHOD.ECIES)))throw new Error(`encryptionParams method must be all: ${a.EncryptionTypes.METHOD.ECIES}`);const e=r.map((e=>n.__awaiter(this,void 0,void 0,(function*(){const r=yield(0,i.encrypt)(t.key,e),n=(0,i.getIdentityFromEncryptionParams)(e);return{encryptedKey:r,multiFormattedIdentity:f.default.serialize(n)}}))));return{encryptedData:s,keys:(yield Promise.all(e)).reduce(((e,t)=>{const r=f.default.serialize(t.encryptedKey);return e[t.multiFormattedIdentity]=r,e}),{})}}}))}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(795),f=r(4).ExtensionTypes.ID.CONTENT_DATA;t.default=class{constructor(e){this.extension=e.extensions.contentData}createExtensionsDataForCreation(e){if(n.default.isKnownFormat(e)){const{valid:t,errors:r}=n.default.validate(e);if(!t){const e=r.map((e=>JSON.stringify(e))).join("\n");throw new Error(`The content data seem to follow a request format but contains errors: ${e}`)}}return this.extension.createCreationAction({content:e})}getContent(e){return e&&e.extensions&&e.extensions[f]?e.extensions[f].values.content:null}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(316),f=r(796),a=r(830),i=r(831),o=r(832);t.default={validate(e){var t;const r=(new f).addMetaSchema(a).addSchema(i);if(!e.meta)return{valid:!1,errors:[{message:"meta not found"}]};if(!e.meta.format)return{valid:!1,errors:[{message:"meta.format not found"}]};if(!e.meta.version)return{valid:!1,errors:[{message:"meta.version not found"}]};const n=null===(t=o.default[e.meta.format])||void 0===t?void 0:t[e.meta.version];if(!n)return{valid:!1,errors:[{message:"format not found"}]};const s=r.compile(n);return s(e)?{valid:!0}:{valid:!1,errors:s.errors}},isKnownFormat:e=>!!e.meta&&"rnf_invoice"===e.meta.format},n.__exportStar(r(836),t)},function(e,t,r){"use strict";var n=r(797),f=r(175),a=r(801),i=r(317),o=r(318),s=r(802),c=r(803),u=r(824),d=r(84);e.exports=y,y.prototype.validate=function(e,t){var r;if("string"==typeof e){if(!(r=this.getSchema(e)))throw new Error('no schema with key or ref "'+e+'"')}else{var n=this._addSchema(e);r=n.validate||this._compile(n)}var f=r(t);!0!==r.$async&&(this.errors=r.errors);return f},y.prototype.compile=function(e,t){var r=this._addSchema(e,void 0,t);return r.validate||this._compile(r)},y.prototype.addSchema=function(e,t,r,n){if(Array.isArray(e)){for(var a=0;a<e.length;a++)this.addSchema(e[a],void 0,r,n);return this}var i=this._getId(e);if(void 0!==i&&"string"!=typeof i)throw new Error("schema id must be string");return A(this,t=f.normalizeId(t||i)),this._schemas[t]=this._addSchema(e,r,n,!0),this},y.prototype.addMetaSchema=function(e,t,r){return this.addSchema(e,t,r,!0),this},y.prototype.validateSchema=function(e,t){var r=e.$schema;if(void 0!==r&&"string"!=typeof r)throw new Error("$schema must be a string");if(!(r=r||this._opts.defaultMeta||function(e){var t=e._opts.meta;return e._opts.defaultMeta="object"==typeof t?e._getId(t)||t:e.getSchema(h)?h:void 0,e._opts.defaultMeta}(this)))return this.logger.warn("meta-schema not available"),this.errors=null,!0;var n=this.validate(r,e);if(!n&&t){var f="schema is invalid: "+this.errorsText();if("log"!=this._opts.validateSchema)throw new Error(f);this.logger.error(f)}return n},y.prototype.getSchema=function(e){var t=g(this,e);switch(typeof t){case"object":return t.validate||this._compile(t);case"string":return this.getSchema(t);case"undefined":return function(e,t){var r=f.schema.call(e,{schema:{}},t);if(r){var a=r.schema,o=r.root,s=r.baseId,c=n.call(e,a,o,void 0,s);return e._fragments[t]=new i({ref:t,fragment:!0,schema:a,root:o,baseId:s,validate:c}),c}}(this,e)}},y.prototype.removeSchema=function(e){if(e instanceof RegExp)return v(this,this._schemas,e),v(this,this._refs,e),this;switch(typeof e){case"undefined":return v(this,this._schemas),v(this,this._refs),this._cache.clear(),this;case"string":var t=g(this,e);return t&&this._cache.del(t.cacheKey),delete this._schemas[e],delete this._refs[e],this;case"object":var r=this._opts.serialize,n=r?r(e):e;this._cache.del(n);var a=this._getId(e);a&&(a=f.normalizeId(a),delete this._schemas[a],delete this._refs[a])}return this},y.prototype.addFormat=function(e,t){"string"==typeof t&&(t=new RegExp(t));return this._formats[e]=t,this},y.prototype.errorsText=function(e,t){if(!(e=e||this.errors))return"No errors";for(var r=void 0===(t=t||{}).separator?", ":t.separator,n=void 0===t.dataVar?"data":t.dataVar,f="",a=0;a<e.length;a++){var i=e[a];i&&(f+=n+i.dataPath+" "+i.message+r)}return f.slice(0,-r.length)},y.prototype._addSchema=function(e,t,r,n){if("object"!=typeof e&&"boolean"!=typeof e)throw new Error("schema should be object or boolean");var a=this._opts.serialize,o=a?a(e):e,s=this._cache.get(o);if(s)return s;n=n||!1!==this._opts.addUsedSchema;var c=f.normalizeId(this._getId(e));c&&n&&A(this,c);var u,d=!1!==this._opts.validateSchema&&!t;d&&!(u=c&&c==f.normalizeId(e.$schema))&&this.validateSchema(e,!0);var l=f.ids.call(this,e),p=new i({id:c,schema:e,localRefs:l,cacheKey:o,meta:r});"#"!=c[0]&&n&&(this._refs[c]=p);this._cache.put(o,p),d&&u&&this.validateSchema(e,!0);return p},y.prototype._compile=function(e,t){if(e.compiling)return e.validate=a,a.schema=e.schema,a.errors=null,a.root=t||a,!0===e.schema.$async&&(a.$async=!0),a;var r,f;e.compiling=!0,e.meta&&(r=this._opts,this._opts=this._metaOpts);try{f=n.call(this,e.schema,t,e.localRefs)}catch(t){throw delete e.validate,t}finally{e.compiling=!1,e.meta&&(this._opts=r)}return e.validate=f,e.refs=f.refs,e.refVal=f.refVal,e.root=f.root,f;function a(){var t=e.validate,r=t.apply(this,arguments);return a.errors=t.errors,r}},y.prototype.compileAsync=r(825);var l=r(826);y.prototype.addKeyword=l.add,y.prototype.getKeyword=l.get,y.prototype.removeKeyword=l.remove,y.prototype.validateKeyword=l.validate;var p=r(177);y.ValidationError=p.Validation,y.MissingRefError=p.MissingRef,y.$dataMetaSchema=u;var h="http://json-schema.org/draft-07/schema",b=["removeAdditional","useDefaults","coerceTypes","strictDefaults"],m=["/properties"];function y(e){if(!(this instanceof y))return new y(e);e=this._opts=d.copy(e)||{},function(e){var t=e._opts.logger;if(!1===t)e.logger={log:T,warn:T,error:T};else{if(void 0===t&&(t=console),!("object"==typeof t&&t.log&&t.warn&&t.error))throw new Error("logger must implement log, warn and error methods");e.logger=t}}(this),this._schemas={},this._refs={},this._fragments={},this._formats=s(e.format),this._cache=e.cache||new a,this._loadingSchemas={},this._compilations=[],this.RULES=c(),this._getId=function(e){switch(e.schemaId){case"auto":return E;case"id":return _;default:return w}}(e),e.loopRequired=e.loopRequired||1/0,"property"==e.errorDataPath&&(e._errorDataPathProperty=!0),void 0===e.serialize&&(e.serialize=o),this._metaOpts=function(e){for(var t=d.copy(e._opts),r=0;r<b.length;r++)delete t[b[r]];return t}(this),e.formats&&function(e){for(var t in e._opts.formats){var r=e._opts.formats[t];e.addFormat(t,r)}}(this),e.keywords&&function(e){for(var t in e._opts.keywords){var r=e._opts.keywords[t];e.addKeyword(t,r)}}(this),function(e){var t;e._opts.$data&&(t=r(829),e.addMetaSchema(t,t.$id,!0));if(!1===e._opts.meta)return;var n=r(324);e._opts.$data&&(n=u(n,m));e.addMetaSchema(n,h,!0),e._refs["http://json-schema.org/schema"]=h}(this),"object"==typeof e.meta&&this.addMetaSchema(e.meta),e.nullable&&this.addKeyword("nullable",{metaSchema:{type:"boolean"}}),function(e){var t=e._opts.schemas;if(!t)return;if(Array.isArray(t))e.addSchema(t);else for(var r in t)e.addSchema(t[r],r)}(this)}function g(e,t){return t=f.normalizeId(t),e._schemas[t]||e._refs[t]||e._fragments[t]}function v(e,t,r){for(var n in t){var f=t[n];f.meta||r&&!r.test(n)||(e._cache.del(f.cacheKey),delete t[n])}}function _(e){return e.$id&&this.logger.warn("schema $id ignored",e.$id),e.id}function w(e){return e.id&&this.logger.warn("schema id ignored",e.id),e.$id}function E(e){if(e.$id&&e.id&&e.$id!=e.id)throw new Error("schema $id is different from id");return e.$id||e.id}function A(e,t){if(e._schemas[t]||e._refs[t])throw new Error('schema with key or id "'+t+'" already exists')}function T(){}},function(e,t,r){"use strict";var n=r(175),f=r(84),a=r(177),i=r(318),o=r(319),s=f.ucs2length,c=r(176),u=a.Validation;function d(e,t,r){var n=p.call(this,e,t,r);return n>=0?{index:n,compiling:!0}:(n=this._compilations.length,this._compilations[n]={schema:e,root:t,baseId:r},{index:n,compiling:!1})}function l(e,t,r){var n=p.call(this,e,t,r);n>=0&&this._compilations.splice(n,1)}function p(e,t,r){for(var n=0;n<this._compilations.length;n++){var f=this._compilations[n];if(f.schema==e&&f.root==t&&f.baseId==r)return n}return-1}function h(e,t){return"var pattern"+e+" = new RegExp("+f.toQuotedString(t[e])+");"}function b(e){return"var default"+e+" = defaults["+e+"];"}function m(e,t){return void 0===t[e]?"":"var refVal"+e+" = refVal["+e+"];"}function y(e){return"var customRule"+e+" = customRules["+e+"];"}function g(e,t){if(!e.length)return"";for(var r="",n=0;n<e.length;n++)r+=t(n,e);return r}e.exports=function e(t,r,p,v){var _=this,w=this._opts,E=[void 0],A={},T=[],x={},k=[],S={},O=[];r=r||{schema:t,refVal:E,refs:A};var C=d.call(this,t,r,v),P=this._compilations[C.index];if(C.compiling)return P.callValidate=function e(){var t=P.validate,r=t.apply(this,arguments);return e.errors=t.errors,r};var R=this._formats,N=this.RULES;try{var I=D(t,r,p,v);P.validate=I;var M=P.callValidate;return M&&(M.schema=I.schema,M.errors=null,M.refs=I.refs,M.refVal=I.refVal,M.root=I.root,M.$async=I.$async,w.sourceCode&&(M.source=I.source)),I}finally{l.call(this,t,r,v)}function D(t,i,d,l){var p=!i||i&&i.schema==t;if(i.schema!=r.schema)return e.call(_,t,i,d,l);var v,x=!0===t.$async,S=o({isTop:!0,schema:t,isRoot:p,baseId:l,root:i,schemaPath:"",errSchemaPath:"#",errorPath:'""',MissingRefError:a.MissingRef,RULES:N,validate:o,util:f,resolve:n,resolveRef:B,usePattern:L,useDefault:U,useCustomRule:q,opts:w,formats:R,logger:_.logger,self:_});S=g(E,m)+g(T,h)+g(k,b)+g(O,y)+S,w.processCode&&(S=w.processCode(S,t));try{v=new Function("self","RULES","formats","root","refVal","defaults","customRules","equal","ucs2length","ValidationError",S)(_,N,R,r,E,k,O,c,s,u),E[0]=v}catch(e){throw _.logger.error("Error compiling schema, function code:",S),e}return v.schema=t,v.errors=null,v.refs=A,v.refVal=E,v.root=p?v:i,x&&(v.$async=!0),!0===w.sourceCode&&(v.source={code:S,patterns:T,defaults:k}),v}function B(t,f,a){f=n.url(t,f);var i,o,s=A[f];if(void 0!==s)return j(i=E[s],o="refVal["+s+"]");if(!a&&r.refs){var c=r.refs[f];if(void 0!==c)return j(i=r.refVal[c],o=F(f,i))}o=F(f);var u=n.call(_,D,r,f);if(void 0===u){var d=p&&p[f];d&&(u=n.inlineRef(d,w.inlineRefs)?d:e.call(_,d,r,p,t))}if(void 0!==u)return function(e,t){var r=A[e];E[r]=t}(f,u),j(u,o);!function(e){delete A[e]}(f)}function F(e,t){var r=E.length;return E[r]=t,A[e]=r,"refVal"+r}function j(e,t){return"object"==typeof e||"boolean"==typeof e?{code:t,schema:e,inline:!0}:{code:t,$async:e&&!!e.$async}}function L(e){var t=x[e];return void 0===t&&(t=x[e]=T.length,T[t]=e),"pattern"+t}function U(e){switch(typeof e){case"boolean":case"number":return""+e;case"string":return f.toQuotedString(e);case"object":if(null===e)return"null";var t=i(e),r=S[t];return void 0===r&&(r=S[t]=k.length,k[r]=e),"default"+r}}function q(e,t,r,n){if(!1!==_._opts.validateSchema){var f=e.definition.dependencies;if(f&&!f.every((function(e){return Object.prototype.hasOwnProperty.call(r,e)})))throw new Error("parent schema must have all required keywords: "+f.join(","));var a=e.definition.validateSchema;if(a)if(!a(t)){var i="keyword schema is invalid: "+_.errorsText(a.errors);if("log"!=_._opts.validateSchema)throw new Error(i);_.logger.error(i)}}var o,s=e.definition.compile,c=e.definition.inline,u=e.definition.macro;if(s)o=s.call(_,t,r,n);else if(u)o=u.call(_,t,r,n),!1!==w.validateSchema&&_.validateSchema(o,!0);else if(c)o=c.call(_,n,e.keyword,t,r);else if(!(o=e.definition.validate))return;if(void 0===o)throw new Error('custom keyword "'+e.keyword+'"failed to compile');var d=O.length;return O[d]=o,{code:"customRule"+d,validate:o}}}},function(e,t,r){!function(e){"use strict";function t(){for(var e=arguments.length,t=Array(e),r=0;r<e;r++)t[r]=arguments[r];if(t.length>1){t[0]=t[0].slice(0,-1);for(var n=t.length-1,f=1;f<n;++f)t[f]=t[f].slice(1,-1);return t[n]=t[n].slice(1),t.join("")}return t[0]}function r(e){return"(?:"+e+")"}function n(e){return void 0===e?"undefined":null===e?"null":Object.prototype.toString.call(e).split(" ").pop().split("]").shift().toLowerCase()}function f(e){return e.toUpperCase()}function a(e){return null!=e?e instanceof Array?e:"number"!=typeof e.length||e.split||e.setInterval||e.call?[e]:Array.prototype.slice.call(e):[]}function i(e,t){var r=e;if(t)for(var n in t)r[n]=t[n];return r}function o(e){var n="[A-Za-z]",f="[0-9]",a=t(f,"[A-Fa-f]"),i=r(r("%[EFef]"+a+"%"+a+a+"%"+a+a)+"|"+r("%[89A-Fa-f]"+a+"%"+a+a)+"|"+r("%"+a+a)),o="[\\!\\$\\&\\'\\(\\)\\*\\+\\,\\;\\=]",s=t("[\\:\\/\\?\\#\\[\\]\\@]",o),c=e?"[\\uE000-\\uF8FF]":"[]",u=t(n,f,"[\\-\\.\\_\\~]",e?"[\\xA0-\\u200D\\u2010-\\u2029\\u202F-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF]":"[]"),d=r(n+t(n,f,"[\\+\\-\\.]")+"*"),l=r(r(i+"|"+t(u,o,"[\\:]"))+"*"),p=(r(r("25[0-5]")+"|"+r("2[0-4]"+f)+"|"+r("1"+f+f)+"|"+r("[1-9]"+f)+"|"+f),r(r("25[0-5]")+"|"+r("2[0-4]"+f)+"|"+r("1"+f+f)+"|"+r("0?[1-9]"+f)+"|0?0?"+f)),h=r(p+"\\."+p+"\\."+p+"\\."+p),b=r(a+"{1,4}"),m=r(r(b+"\\:"+b)+"|"+h),y=r(r(b+"\\:")+"{6}"+m),g=r("\\:\\:"+r(b+"\\:")+"{5}"+m),v=r(r(b)+"?\\:\\:"+r(b+"\\:")+"{4}"+m),_=r(r(r(b+"\\:")+"{0,1}"+b)+"?\\:\\:"+r(b+"\\:")+"{3}"+m),w=r(r(r(b+"\\:")+"{0,2}"+b)+"?\\:\\:"+r(b+"\\:")+"{2}"+m),E=r(r(r(b+"\\:")+"{0,3}"+b)+"?\\:\\:"+b+"\\:"+m),A=r(r(r(b+"\\:")+"{0,4}"+b)+"?\\:\\:"+m),T=r(r(r(b+"\\:")+"{0,5}"+b)+"?\\:\\:"+b),x=r(r(r(b+"\\:")+"{0,6}"+b)+"?\\:\\:"),k=r([y,g,v,_,w,E,A,T,x].join("|")),S=r(r(u+"|"+i)+"+"),O=(r(k+"\\%25"+S),r(k+r("\\%25|\\%(?!"+a+"{2})")+S)),C=r("[vV]"+a+"+\\."+t(u,o,"[\\:]")+"+"),P=r("\\["+r(O+"|"+k+"|"+C)+"\\]"),R=r(r(i+"|"+t(u,o))+"*"),N=r(P+"|"+h+"(?!"+R+")|"+R),I=r(f+"*"),M=r(r(l+"@")+"?"+N+r("\\:"+I)+"?"),D=r(i+"|"+t(u,o,"[\\:\\@]")),B=r(D+"*"),F=r(D+"+"),j=r(r(i+"|"+t(u,o,"[\\@]"))+"+"),L=r(r("\\/"+B)+"*"),U=r("\\/"+r(F+L)+"?"),q=r(j+L),H=r(F+L),$="(?!"+D+")",z=(r(L+"|"+U+"|"+q+"|"+H+"|"+$),r(r(D+"|"+t("[\\/\\?]",c))+"*")),V=r(r(D+"|[\\/\\?]")+"*"),G=r(r("\\/\\/"+M+L)+"|"+U+"|"+H+"|"+$),K=r(d+"\\:"+G+r("\\?"+z)+"?"+r("\\#"+V)+"?"),W=r(r("\\/\\/"+M+L)+"|"+U+"|"+q+"|"+$),Y=r(W+r("\\?"+z)+"?"+r("\\#"+V)+"?");return r(K+"|"+Y),r(d+"\\:"+G+r("\\?"+z)+"?"),r(r("\\/\\/("+r("("+l+")@")+"?("+N+")"+r("\\:("+I+")")+"?)")+"?("+L+"|"+U+"|"+H+"|"+$+")"),r("\\?("+z+")"),r("\\#("+V+")"),r(r("\\/\\/("+r("("+l+")@")+"?("+N+")"+r("\\:("+I+")")+"?)")+"?("+L+"|"+U+"|"+q+"|"+$+")"),r("\\?("+z+")"),r("\\#("+V+")"),r(r("\\/\\/("+r("("+l+")@")+"?("+N+")"+r("\\:("+I+")")+"?)")+"?("+L+"|"+U+"|"+H+"|"+$+")"),r("\\?("+z+")"),r("\\#("+V+")"),r("("+l+")@"),r("\\:("+I+")"),{NOT_SCHEME:new RegExp(t("[^]",n,f,"[\\+\\-\\.]"),"g"),NOT_USERINFO:new RegExp(t("[^\\%\\:]",u,o),"g"),NOT_HOST:new RegExp(t("[^\\%\\[\\]\\:]",u,o),"g"),NOT_PATH:new RegExp(t("[^\\%\\/\\:\\@]",u,o),"g"),NOT_PATH_NOSCHEME:new RegExp(t("[^\\%\\/\\@]",u,o),"g"),NOT_QUERY:new RegExp(t("[^\\%]",u,o,"[\\:\\@\\/\\?]",c),"g"),NOT_FRAGMENT:new RegExp(t("[^\\%]",u,o,"[\\:\\@\\/\\?]"),"g"),ESCAPE:new RegExp(t("[^]",u,o),"g"),UNRESERVED:new RegExp(u,"g"),OTHER_CHARS:new RegExp(t("[^\\%]",u,s),"g"),PCT_ENCODED:new RegExp(i,"g"),IPV4ADDRESS:new RegExp("^("+h+")$"),IPV6ADDRESS:new RegExp("^\\[?("+k+")"+r(r("\\%25|\\%(?!"+a+"{2})")+"("+S+")")+"?\\]?$")}}var s=o(!1),c=o(!0),u=function(){function e(e,t){var r=[],n=!0,f=!1,a=void 0;try{for(var i,o=e[Symbol.iterator]();!(n=(i=o.next()).done)&&(r.push(i.value),!t||r.length!==t);n=!0);}catch(e){f=!0,a=e}finally{try{!n&&o.return&&o.return()}finally{if(f)throw a}}return r}return function(t,r){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return e(t,r);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),d=function(e){if(Array.isArray(e)){for(var t=0,r=Array(e.length);t<e.length;t++)r[t]=e[t];return r}return Array.from(e)},l=2147483647,p=36,h=1,b=26,m=38,y=700,g=72,v=128,_="-",w=/^xn--/,E=/[^\0-\x7E]/,A=/[\x2E\u3002\uFF0E\uFF61]/g,T={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},x=p-h,k=Math.floor,S=String.fromCharCode;function O(e){throw new RangeError(T[e])}function C(e,t){for(var r=[],n=e.length;n--;)r[n]=t(e[n]);return r}function P(e,t){var r=e.split("@"),n="";return r.length>1&&(n=r[0]+"@",e=r[1]),n+C((e=e.replace(A,".")).split("."),t).join(".")}function R(e){for(var t=[],r=0,n=e.length;r<n;){var f=e.charCodeAt(r++);if(f>=55296&&f<=56319&&r<n){var a=e.charCodeAt(r++);56320==(64512&a)?t.push(((1023&f)<<10)+(1023&a)+65536):(t.push(f),r--)}else t.push(f)}return t}var N=function(e){return e-48<10?e-22:e-65<26?e-65:e-97<26?e-97:p},I=function(e,t){return e+22+75*(e<26)-((0!=t)<<5)},M=function(e,t,r){var n=0;for(e=r?k(e/y):e>>1,e+=k(e/t);e>x*b>>1;n+=p)e=k(e/x);return k(n+(x+1)*e/(e+m))},D=function(e){var t=[],r=e.length,n=0,f=v,a=g,i=e.lastIndexOf(_);i<0&&(i=0);for(var o=0;o<i;++o)e.charCodeAt(o)>=128&&O("not-basic"),t.push(e.charCodeAt(o));for(var s=i>0?i+1:0;s<r;){for(var c=n,u=1,d=p;;d+=p){s>=r&&O("invalid-input");var m=N(e.charCodeAt(s++));(m>=p||m>k((l-n)/u))&&O("overflow"),n+=m*u;var y=d<=a?h:d>=a+b?b:d-a;if(m<y)break;var w=p-y;u>k(l/w)&&O("overflow"),u*=w}var E=t.length+1;a=M(n-c,E,0==c),k(n/E)>l-f&&O("overflow"),f+=k(n/E),n%=E,t.splice(n++,0,f)}return String.fromCodePoint.apply(String,t)},B=function(e){var t=[],r=(e=R(e)).length,n=v,f=0,a=g,i=!0,o=!1,s=void 0;try{for(var c,u=e[Symbol.iterator]();!(i=(c=u.next()).done);i=!0){var d=c.value;d<128&&t.push(S(d))}}catch(e){o=!0,s=e}finally{try{!i&&u.return&&u.return()}finally{if(o)throw s}}var m=t.length,y=m;for(m&&t.push(_);y<r;){var w=l,E=!0,A=!1,T=void 0;try{for(var x,C=e[Symbol.iterator]();!(E=(x=C.next()).done);E=!0){var P=x.value;P>=n&&P<w&&(w=P)}}catch(e){A=!0,T=e}finally{try{!E&&C.return&&C.return()}finally{if(A)throw T}}var N=y+1;w-n>k((l-f)/N)&&O("overflow"),f+=(w-n)*N,n=w;var D=!0,B=!1,F=void 0;try{for(var j,L=e[Symbol.iterator]();!(D=(j=L.next()).done);D=!0){var U=j.value;if(U<n&&++f>l&&O("overflow"),U==n){for(var q=f,H=p;;H+=p){var $=H<=a?h:H>=a+b?b:H-a;if(q<$)break;var z=q-$,V=p-$;t.push(S(I($+z%V,0))),q=k(z/V)}t.push(S(I(q,0))),a=M(f,N,y==m),f=0,++y}}}catch(e){B=!0,F=e}finally{try{!D&&L.return&&L.return()}finally{if(B)throw F}}++f,++n}return t.join("")},F=function(e){return P(e,(function(e){return w.test(e)?D(e.slice(4).toLowerCase()):e}))},j=function(e){return P(e,(function(e){return E.test(e)?"xn--"+B(e):e}))},L={version:"2.1.0",ucs2:{decode:R,encode:function(e){return String.fromCodePoint.apply(String,d(e))}},decode:D,encode:B,toASCII:j,toUnicode:F},U={};function q(e){var t=e.charCodeAt(0);return t<16?"%0"+t.toString(16).toUpperCase():t<128?"%"+t.toString(16).toUpperCase():t<2048?"%"+(t>>6|192).toString(16).toUpperCase()+"%"+(63&t|128).toString(16).toUpperCase():"%"+(t>>12|224).toString(16).toUpperCase()+"%"+(t>>6&63|128).toString(16).toUpperCase()+"%"+(63&t|128).toString(16).toUpperCase()}function H(e){for(var t="",r=0,n=e.length;r<n;){var f=parseInt(e.substr(r+1,2),16);if(f<128)t+=String.fromCharCode(f),r+=3;else if(f>=194&&f<224){if(n-r>=6){var a=parseInt(e.substr(r+4,2),16);t+=String.fromCharCode((31&f)<<6|63&a)}else t+=e.substr(r,6);r+=6}else if(f>=224){if(n-r>=9){var i=parseInt(e.substr(r+4,2),16),o=parseInt(e.substr(r+7,2),16);t+=String.fromCharCode((15&f)<<12|(63&i)<<6|63&o)}else t+=e.substr(r,9);r+=9}else t+=e.substr(r,3),r+=3}return t}function $(e,t){function r(e){var r=H(e);return r.match(t.UNRESERVED)?r:e}return e.scheme&&(e.scheme=String(e.scheme).replace(t.PCT_ENCODED,r).toLowerCase().replace(t.NOT_SCHEME,"")),void 0!==e.userinfo&&(e.userinfo=String(e.userinfo).replace(t.PCT_ENCODED,r).replace(t.NOT_USERINFO,q).replace(t.PCT_ENCODED,f)),void 0!==e.host&&(e.host=String(e.host).replace(t.PCT_ENCODED,r).toLowerCase().replace(t.NOT_HOST,q).replace(t.PCT_ENCODED,f)),void 0!==e.path&&(e.path=String(e.path).replace(t.PCT_ENCODED,r).replace(e.scheme?t.NOT_PATH:t.NOT_PATH_NOSCHEME,q).replace(t.PCT_ENCODED,f)),void 0!==e.query&&(e.query=String(e.query).replace(t.PCT_ENCODED,r).replace(t.NOT_QUERY,q).replace(t.PCT_ENCODED,f)),void 0!==e.fragment&&(e.fragment=String(e.fragment).replace(t.PCT_ENCODED,r).replace(t.NOT_FRAGMENT,q).replace(t.PCT_ENCODED,f)),e}function z(e){return e.replace(/^0*(.*)/,"$1")||"0"}function V(e,t){var r=e.match(t.IPV4ADDRESS)||[],n=u(r,2)[1];return n?n.split(".").map(z).join("."):e}function G(e,t){var r=e.match(t.IPV6ADDRESS)||[],n=u(r,3),f=n[1],a=n[2];if(f){for(var i=f.toLowerCase().split("::").reverse(),o=u(i,2),s=o[0],c=o[1],d=c?c.split(":").map(z):[],l=s.split(":").map(z),p=t.IPV4ADDRESS.test(l[l.length-1]),h=p?7:8,b=l.length-h,m=Array(h),y=0;y<h;++y)m[y]=d[y]||l[b+y]||"";p&&(m[h-1]=V(m[h-1],t));var g=m.reduce((function(e,t,r){if(!t||"0"===t){var n=e[e.length-1];n&&n.index+n.length===r?n.length++:e.push({index:r,length:1})}return e}),[]).sort((function(e,t){return t.length-e.length}))[0],v=void 0;if(g&&g.length>1){var _=m.slice(0,g.index),w=m.slice(g.index+g.length);v=_.join(":")+"::"+w.join(":")}else v=m.join(":");return a&&(v+="%"+a),v}return e}var K=/^(?:([^:\/?#]+):)?(?:\/\/((?:([^\/?#@]*)@)?(\[[^\/?#\]]+\]|[^\/?#:]*)(?:\:(\d*))?))?([^?#]*)(?:\?([^#]*))?(?:#((?:.|\n|\r)*))?/i,W=void 0==="".match(/(){0}/)[1];function Y(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r={},n=!1!==t.iri?c:s;"suffix"===t.reference&&(e=(t.scheme?t.scheme+":":"")+"//"+e);var f=e.match(K);if(f){W?(r.scheme=f[1],r.userinfo=f[3],r.host=f[4],r.port=parseInt(f[5],10),r.path=f[6]||"",r.query=f[7],r.fragment=f[8],isNaN(r.port)&&(r.port=f[5])):(r.scheme=f[1]||void 0,r.userinfo=-1!==e.indexOf("@")?f[3]:void 0,r.host=-1!==e.indexOf("//")?f[4]:void 0,r.port=parseInt(f[5],10),r.path=f[6]||"",r.query=-1!==e.indexOf("?")?f[7]:void 0,r.fragment=-1!==e.indexOf("#")?f[8]:void 0,isNaN(r.port)&&(r.port=e.match(/\/\/(?:.|\n)*\:(?:\/|\?|\#|$)/)?f[4]:void 0)),r.host&&(r.host=G(V(r.host,n),n)),void 0!==r.scheme||void 0!==r.userinfo||void 0!==r.host||void 0!==r.port||r.path||void 0!==r.query?void 0===r.scheme?r.reference="relative":void 0===r.fragment?r.reference="absolute":r.reference="uri":r.reference="same-document",t.reference&&"suffix"!==t.reference&&t.reference!==r.reference&&(r.error=r.error||"URI is not a "+t.reference+" reference.");var a=U[(t.scheme||r.scheme||"").toLowerCase()];if(t.unicodeSupport||a&&a.unicodeSupport)$(r,n);else{if(r.host&&(t.domainHost||a&&a.domainHost))try{r.host=L.toASCII(r.host.replace(n.PCT_ENCODED,H).toLowerCase())}catch(e){r.error=r.error||"Host's domain name can not be converted to ASCII via punycode: "+e}$(r,s)}a&&a.parse&&a.parse(r,t)}else r.error=r.error||"URI can not be parsed.";return r}function J(e,t){var r=!1!==t.iri?c:s,n=[];return void 0!==e.userinfo&&(n.push(e.userinfo),n.push("@")),void 0!==e.host&&n.push(G(V(String(e.host),r),r).replace(r.IPV6ADDRESS,(function(e,t,r){return"["+t+(r?"%25"+r:"")+"]"}))),"number"!=typeof e.port&&"string"!=typeof e.port||(n.push(":"),n.push(String(e.port))),n.length?n.join(""):void 0}var X=/^\.\.?\//,Z=/^\/\.(\/|$)/,Q=/^\/\.\.(\/|$)/,ee=/^\/?(?:.|\n)*?(?=\/|$)/;function te(e){for(var t=[];e.length;)if(e.match(X))e=e.replace(X,"");else if(e.match(Z))e=e.replace(Z,"/");else if(e.match(Q))e=e.replace(Q,"/"),t.pop();else if("."===e||".."===e)e="";else{var r=e.match(ee);if(!r)throw new Error("Unexpected dot segment condition");var n=r[0];e=e.slice(n.length),t.push(n)}return t.join("")}function re(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=t.iri?c:s,n=[],f=U[(t.scheme||e.scheme||"").toLowerCase()];if(f&&f.serialize&&f.serialize(e,t),e.host)if(r.IPV6ADDRESS.test(e.host));else if(t.domainHost||f&&f.domainHost)try{e.host=t.iri?L.toUnicode(e.host):L.toASCII(e.host.replace(r.PCT_ENCODED,H).toLowerCase())}catch(r){e.error=e.error||"Host's domain name can not be converted to "+(t.iri?"Unicode":"ASCII")+" via punycode: "+r}$(e,r),"suffix"!==t.reference&&e.scheme&&(n.push(e.scheme),n.push(":"));var a=J(e,t);if(void 0!==a&&("suffix"!==t.reference&&n.push("//"),n.push(a),e.path&&"/"!==e.path.charAt(0)&&n.push("/")),void 0!==e.path){var i=e.path;t.absolutePath||f&&f.absolutePath||(i=te(i)),void 0===a&&(i=i.replace(/^\/\//,"/%2F")),n.push(i)}return void 0!==e.query&&(n.push("?"),n.push(e.query)),void 0!==e.fragment&&(n.push("#"),n.push(e.fragment)),n.join("")}function ne(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n={};return arguments[3]||(e=Y(re(e,r),r),t=Y(re(t,r),r)),!(r=r||{}).tolerant&&t.scheme?(n.scheme=t.scheme,n.userinfo=t.userinfo,n.host=t.host,n.port=t.port,n.path=te(t.path||""),n.query=t.query):(void 0!==t.userinfo||void 0!==t.host||void 0!==t.port?(n.userinfo=t.userinfo,n.host=t.host,n.port=t.port,n.path=te(t.path||""),n.query=t.query):(t.path?("/"===t.path.charAt(0)?n.path=te(t.path):(void 0===e.userinfo&&void 0===e.host&&void 0===e.port||e.path?e.path?n.path=e.path.slice(0,e.path.lastIndexOf("/")+1)+t.path:n.path=t.path:n.path="/"+t.path,n.path=te(n.path)),n.query=t.query):(n.path=e.path,void 0!==t.query?n.query=t.query:n.query=e.query),n.userinfo=e.userinfo,n.host=e.host,n.port=e.port),n.scheme=e.scheme),n.fragment=t.fragment,n}function fe(e,t,r){var n=i({scheme:"null"},r);return re(ne(Y(e,n),Y(t,n),n,!0),n)}function ae(e,t){return"string"==typeof e?e=re(Y(e,t),t):"object"===n(e)&&(e=Y(re(e,t),t)),e}function ie(e,t,r){return"string"==typeof e?e=re(Y(e,r),r):"object"===n(e)&&(e=re(e,r)),"string"==typeof t?t=re(Y(t,r),r):"object"===n(t)&&(t=re(t,r)),e===t}function oe(e,t){return e&&e.toString().replace(t&&t.iri?c.ESCAPE:s.ESCAPE,q)}function se(e,t){return e&&e.toString().replace(t&&t.iri?c.PCT_ENCODED:s.PCT_ENCODED,H)}var ce={scheme:"http",domainHost:!0,parse:function(e,t){return e.host||(e.error=e.error||"HTTP URIs must have a host."),e},serialize:function(e,t){var r="https"===String(e.scheme).toLowerCase();return e.port!==(r?443:80)&&""!==e.port||(e.port=void 0),e.path||(e.path="/"),e}},ue={scheme:"https",domainHost:ce.domainHost,parse:ce.parse,serialize:ce.serialize};function de(e){return"boolean"==typeof e.secure?e.secure:"wss"===String(e.scheme).toLowerCase()}var le={scheme:"ws",domainHost:!0,parse:function(e,t){var r=e;return r.secure=de(r),r.resourceName=(r.path||"/")+(r.query?"?"+r.query:""),r.path=void 0,r.query=void 0,r},serialize:function(e,t){if(e.port!==(de(e)?443:80)&&""!==e.port||(e.port=void 0),"boolean"==typeof e.secure&&(e.scheme=e.secure?"wss":"ws",e.secure=void 0),e.resourceName){var r=e.resourceName.split("?"),n=u(r,2),f=n[0],a=n[1];e.path=f&&"/"!==f?f:void 0,e.query=a,e.resourceName=void 0}return e.fragment=void 0,e}},pe={scheme:"wss",domainHost:le.domainHost,parse:le.parse,serialize:le.serialize},he={},be="[A-Za-z0-9\\-\\.\\_\\~\\xA0-\\u200D\\u2010-\\u2029\\u202F-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF]",me="[0-9A-Fa-f]",ye=r(r("%[EFef]"+me+"%"+me+me+"%"+me+me)+"|"+r("%[89A-Fa-f]"+me+"%"+me+me)+"|"+r("%"+me+me)),ge="[A-Za-z0-9\\!\\$\\%\\'\\*\\+\\-\\^\\_\\`\\{\\|\\}\\~]",ve=t("[\\!\\$\\%\\'\\(\\)\\*\\+\\,\\-\\.0-9\\<\\>A-Z\\x5E-\\x7E]",'[\\"\\\\]'),_e="[\\!\\$\\'\\(\\)\\*\\+\\,\\;\\:\\@]",we=new RegExp(be,"g"),Ee=new RegExp(ye,"g"),Ae=new RegExp(t("[^]",ge,"[\\.]",'[\\"]',ve),"g"),Te=new RegExp(t("[^]",be,_e),"g"),xe=Te;function ke(e){var t=H(e);return t.match(we)?t:e}var Se={scheme:"mailto",parse:function(e,t){var r=e,n=r.to=r.path?r.path.split(","):[];if(r.path=void 0,r.query){for(var f=!1,a={},i=r.query.split("&"),o=0,s=i.length;o<s;++o){var c=i[o].split("=");switch(c[0]){case"to":for(var u=c[1].split(","),d=0,l=u.length;d<l;++d)n.push(u[d]);break;case"subject":r.subject=se(c[1],t);break;case"body":r.body=se(c[1],t);break;default:f=!0,a[se(c[0],t)]=se(c[1],t)}}f&&(r.headers=a)}r.query=void 0;for(var p=0,h=n.length;p<h;++p){var b=n[p].split("@");if(b[0]=se(b[0]),t.unicodeSupport)b[1]=se(b[1],t).toLowerCase();else try{b[1]=L.toASCII(se(b[1],t).toLowerCase())}catch(e){r.error=r.error||"Email address's domain name can not be converted to ASCII via punycode: "+e}n[p]=b.join("@")}return r},serialize:function(e,t){var r=e,n=a(e.to);if(n){for(var i=0,o=n.length;i<o;++i){var s=String(n[i]),c=s.lastIndexOf("@"),u=s.slice(0,c).replace(Ee,ke).replace(Ee,f).replace(Ae,q),d=s.slice(c+1);try{d=t.iri?L.toUnicode(d):L.toASCII(se(d,t).toLowerCase())}catch(e){r.error=r.error||"Email address's domain name can not be converted to "+(t.iri?"Unicode":"ASCII")+" via punycode: "+e}n[i]=u+"@"+d}r.path=n.join(",")}var l=e.headers=e.headers||{};e.subject&&(l.subject=e.subject),e.body&&(l.body=e.body);var p=[];for(var h in l)l[h]!==he[h]&&p.push(h.replace(Ee,ke).replace(Ee,f).replace(Te,q)+"="+l[h].replace(Ee,ke).replace(Ee,f).replace(xe,q));return p.length&&(r.query=p.join("&")),r}},Oe=/^([^\:]+)\:(.*)/,Ce={scheme:"urn",parse:function(e,t){var r=e.path&&e.path.match(Oe),n=e;if(r){var f=t.scheme||n.scheme||"urn",a=r[1].toLowerCase(),i=r[2],o=f+":"+(t.nid||a),s=U[o];n.nid=a,n.nss=i,n.path=void 0,s&&(n=s.parse(n,t))}else n.error=n.error||"URN can not be parsed.";return n},serialize:function(e,t){var r=t.scheme||e.scheme||"urn",n=e.nid,f=r+":"+(t.nid||n),a=U[f];a&&(e=a.serialize(e,t));var i=e,o=e.nss;return i.path=(n||t.nid)+":"+o,i}},Pe=/^[0-9A-Fa-f]{8}(?:\-[0-9A-Fa-f]{4}){3}\-[0-9A-Fa-f]{12}$/,Re={scheme:"urn:uuid",parse:function(e,t){var r=e;return r.uuid=r.nss,r.nss=void 0,t.tolerant||r.uuid&&r.uuid.match(Pe)||(r.error=r.error||"UUID is not valid."),r},serialize:function(e,t){var r=e;return r.nss=(e.uuid||"").toLowerCase(),r}};U[ce.scheme]=ce,U[ue.scheme]=ue,U[le.scheme]=le,U[pe.scheme]=pe,U[Se.scheme]=Se,U[Ce.scheme]=Ce,U[Re.scheme]=Re,e.SCHEMES=U,e.pctEncChar=q,e.pctDecChars=H,e.parse=Y,e.removeDotSegments=te,e.serialize=re,e.resolveComponents=ne,e.resolve=fe,e.normalize=ae,e.equal=ie,e.escapeComponent=oe,e.unescapeComponent=se,Object.defineProperty(e,"__esModule",{value:!0})}(t)},function(e,t,r){"use strict";e.exports=function(e){for(var t,r=0,n=e.length,f=0;f<n;)r++,(t=e.charCodeAt(f++))>=55296&&t<=56319&&f<n&&56320==(64512&(t=e.charCodeAt(f)))&&f++;return r}},function(e,t,r){"use strict";var n=e.exports=function(e,t,r){"function"==typeof t&&(r=t,t={}),f(t,"function"==typeof(r=t.cb||r)?r:r.pre||function(){},r.post||function(){},e,"",e)};function f(e,t,r,a,i,o,s,c,u,d){if(a&&"object"==typeof a&&!Array.isArray(a)){for(var l in t(a,i,o,s,c,u,d),a){var p=a[l];if(Array.isArray(p)){if(l in n.arrayKeywords)for(var h=0;h<p.length;h++)f(e,t,r,p[h],i+"/"+l+"/"+h,o,i,l,a,h)}else if(l in n.propsKeywords){if(p&&"object"==typeof p)for(var b in p)f(e,t,r,p[b],i+"/"+l+"/"+b.replace(/~/g,"~0").replace(/\//g,"~1"),o,i,l,a,b)}else(l in n.keywords||e.allKeys&&!(l in n.skipKeywords))&&f(e,t,r,p,i+"/"+l,o,i,l,a)}r(a,i,o,s,c,u,d)}}n.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0},n.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0},n.propsKeywords={definitions:!0,properties:!0,patternProperties:!0,dependencies:!0},n.skipKeywords={default:!0,enum:!0,const:!0,required:!0,maximum:!0,minimum:!0,exclusiveMaximum:!0,exclusiveMinimum:!0,multipleOf:!0,maxLength:!0,minLength:!0,pattern:!0,format:!0,maxItems:!0,minItems:!0,uniqueItems:!0,maxProperties:!0,minProperties:!0}},function(e,t,r){"use strict";var n=e.exports=function(){this._cache={}};n.prototype.put=function(e,t){this._cache[e]=t},n.prototype.get=function(e){return this._cache[e]},n.prototype.del=function(e){delete this._cache[e]},n.prototype.clear=function(){this._cache={}}},function(e,t,r){"use strict";var n=r(84),f=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,a=[0,31,28,31,30,31,30,31,31,30,31,30,31],i=/^(\d\d):(\d\d):(\d\d)(\.\d+)?(z|[+-]\d\d(?::?\d\d)?)?$/i,o=/^(?=.{1,253}\.?$)[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[-0-9a-z]{0,61}[0-9a-z])?)*\.?$/i,s=/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)(?:\?(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i,c=/^(?:(?:[^\x00-\x20"'<>%\\^`{|}]|%[0-9a-f]{2})|\{[+#./;?&=,!@|]?(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?(?:,(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?)*\})*$/i,u=/^(?:(?:http[s\u017F]?|ftp):\/\/)(?:(?:[\0-\x08\x0E-\x1F!-\x9F\xA1-\u167F\u1681-\u1FFF\u200B-\u2027\u202A-\u202E\u2030-\u205E\u2060-\u2FFF\u3001-\uD7FF\uE000-\uFEFE\uFF00-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+(?::(?:[\0-\x08\x0E-\x1F!-\x9F\xA1-\u167F\u1681-\u1FFF\u200B-\u2027\u202A-\u202E\u2030-\u205E\u2060-\u2FFF\u3001-\uD7FF\uE000-\uFEFE\uFF00-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*)?@)?(?:(?!10(?:\.[0-9]{1,3}){3})(?!127(?:\.[0-9]{1,3}){3})(?!169\.254(?:\.[0-9]{1,3}){2})(?!192\.168(?:\.[0-9]{1,3}){2})(?!172\.(?:1[6-9]|2[0-9]|3[01])(?:\.[0-9]{1,3}){2})(?:[1-9][0-9]?|1[0-9][0-9]|2[01][0-9]|22[0-3])(?:\.(?:1?[0-9]{1,2}|2[0-4][0-9]|25[0-5])){2}(?:\.(?:[1-9][0-9]?|1[0-9][0-9]|2[0-4][0-9]|25[0-4]))|(?:(?:(?:[0-9KSa-z\xA1-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+-?)*(?:[0-9KSa-z\xA1-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+)(?:\.(?:(?:[0-9KSa-z\xA1-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+-?)*(?:[0-9KSa-z\xA1-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+)*(?:\.(?:(?:[KSa-z\xA1-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]){2,})))(?::[0-9]{2,5})?(?:\/(?:[\0-\x08\x0E-\x1F!-\x9F\xA1-\u167F\u1681-\u1FFF\u200B-\u2027\u202A-\u202E\u2030-\u205E\u2060-\u2FFF\u3001-\uD7FF\uE000-\uFEFE\uFF00-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*)?$/i,d=/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i,l=/^(?:\/(?:[^~/]|~0|~1)*)*$/,p=/^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i,h=/^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/;function b(e){return e="full"==e?"full":"fast",n.copy(b[e])}function m(e){var t=e.match(f);if(!t)return!1;var r=+t[1],n=+t[2],i=+t[3];return n>=1&&n<=12&&i>=1&&i<=(2==n&&function(e){return e%4==0&&(e%100!=0||e%400==0)}(r)?29:a[n])}function y(e,t){var r=e.match(i);if(!r)return!1;var n=r[1],f=r[2],a=r[3],o=r[5];return(n<=23&&f<=59&&a<=59||23==n&&59==f&&60==a)&&(!t||o)}e.exports=b,b.fast={date:/^\d\d\d\d-[0-1]\d-[0-3]\d$/,time:/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,"date-time":/^\d\d\d\d-[0-1]\d-[0-3]\d[t\s](?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,uri:/^(?:[a-z][a-z0-9+-.]*:)(?:\/?\/)?[^\s]*$/i,"uri-reference":/^(?:(?:[a-z][a-z0-9+-.]*:)?\/?\/)?(?:[^\\\s#][^\s#]*)?(?:#[^\\\s]*)?$/i,"uri-template":c,url:u,email:/^[a-z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*$/i,hostname:o,ipv4:/^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)$/,ipv6:/^\s*(?:(?:(?:[0-9a-f]{1,4}:){7}(?:[0-9a-f]{1,4}|:))|(?:(?:[0-9a-f]{1,4}:){6}(?::[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(?:(?:[0-9a-f]{1,4}:){5}(?:(?:(?::[0-9a-f]{1,4}){1,2})|:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(?:(?:[0-9a-f]{1,4}:){4}(?:(?:(?::[0-9a-f]{1,4}){1,3})|(?:(?::[0-9a-f]{1,4})?:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){3}(?:(?:(?::[0-9a-f]{1,4}){1,4})|(?:(?::[0-9a-f]{1,4}){0,2}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){2}(?:(?:(?::[0-9a-f]{1,4}){1,5})|(?:(?::[0-9a-f]{1,4}){0,3}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){1}(?:(?:(?::[0-9a-f]{1,4}){1,6})|(?:(?::[0-9a-f]{1,4}){0,4}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?::(?:(?:(?::[0-9a-f]{1,4}){1,7})|(?:(?::[0-9a-f]{1,4}){0,5}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(?:%.+)?\s*$/i,regex:w,uuid:d,"json-pointer":l,"json-pointer-uri-fragment":p,"relative-json-pointer":h},b.full={date:m,time:y,"date-time":function(e){var t=e.split(g);return 2==t.length&&m(t[0])&&y(t[1],!0)},uri:function(e){return v.test(e)&&s.test(e)},"uri-reference":/^(?:[a-z][a-z0-9+\-.]*:)?(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'"()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?(?:\?(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i,"uri-template":c,url:u,email:/^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i,hostname:o,ipv4:/^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)$/,ipv6:/^\s*(?:(?:(?:[0-9a-f]{1,4}:){7}(?:[0-9a-f]{1,4}|:))|(?:(?:[0-9a-f]{1,4}:){6}(?::[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(?:(?:[0-9a-f]{1,4}:){5}(?:(?:(?::[0-9a-f]{1,4}){1,2})|:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(?:(?:[0-9a-f]{1,4}:){4}(?:(?:(?::[0-9a-f]{1,4}){1,3})|(?:(?::[0-9a-f]{1,4})?:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){3}(?:(?:(?::[0-9a-f]{1,4}){1,4})|(?:(?::[0-9a-f]{1,4}){0,2}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){2}(?:(?:(?::[0-9a-f]{1,4}){1,5})|(?:(?::[0-9a-f]{1,4}){0,3}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){1}(?:(?:(?::[0-9a-f]{1,4}){1,6})|(?:(?::[0-9a-f]{1,4}){0,4}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?::(?:(?:(?::[0-9a-f]{1,4}){1,7})|(?:(?::[0-9a-f]{1,4}){0,5}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(?:%.+)?\s*$/i,regex:w,uuid:d,"json-pointer":l,"json-pointer-uri-fragment":p,"relative-json-pointer":h};var g=/t|\s/i;var v=/\/|:/;var _=/[^\\]\\Z/;function w(e){if(_.test(e))return!1;try{return new RegExp(e),!0}catch(e){return!1}}},function(e,t,r){"use strict";var n=r(804),f=r(84).toHash;e.exports=function(){var e=[{type:"number",rules:[{maximum:["exclusiveMaximum"]},{minimum:["exclusiveMinimum"]},"multipleOf","format"]},{type:"string",rules:["maxLength","minLength","pattern","format"]},{type:"array",rules:["maxItems","minItems","items","contains","uniqueItems"]},{type:"object",rules:["maxProperties","minProperties","required","dependencies","propertyNames",{properties:["additionalProperties","patternProperties"]}]},{rules:["$ref","const","enum","not","anyOf","oneOf","allOf","if"]}],t=["type","$comment"];return e.all=f(t),e.types=f(["number","integer","string","array","object","boolean","null"]),e.forEach((function(r){r.rules=r.rules.map((function(r){var f;if("object"==typeof r){var a=Object.keys(r)[0];f=r[a],r=a,f.forEach((function(r){t.push(r),e.all[r]=!0}))}return t.push(r),e.all[r]={keyword:r,code:n[r],implements:f}})),e.all.$comment={keyword:"$comment",code:n.$comment},r.type&&(e.types[r.type]=r)})),e.keywords=f(t.concat(["$schema","$id","id","$data","$async","title","description","default","definitions","examples","readOnly","writeOnly","contentMediaType","contentEncoding","additionalItems","then","else"])),e.custom={},e}},function(e,t,r){"use strict";e.exports={$ref:r(805),allOf:r(806),anyOf:r(807),$comment:r(808),const:r(809),contains:r(810),dependencies:r(811),enum:r(812),format:r(813),if:r(814),items:r(815),maximum:r(320),minimum:r(320),maxItems:r(321),minItems:r(321),maxLength:r(322),minLength:r(322),maxProperties:r(323),minProperties:r(323),multipleOf:r(816),not:r(817),oneOf:r(818),pattern:r(819),properties:r(820),propertyNames:r(821),required:r(822),uniqueItems:r(823),validate:r(319)}},function(e,t,r){"use strict";e.exports=function(e,t,r){var n,f,a=" ",i=e.level,o=e.dataLevel,s=e.schema[t],c=e.errSchemaPath+"/"+t,u=!e.opts.allErrors,d="data"+(o||""),l="valid"+i;if("#"==s||"#/"==s)e.isRoot?(n=e.async,f="validate"):(n=!0===e.root.schema.$async,f="root.refVal[0]");else{var p=e.resolveRef(e.baseId,s,e.isRoot);if(void 0===p){var h=e.MissingRefError.message(e.baseId,s);if("fail"==e.opts.missingRefs){e.logger.error(h),(g=g||[]).push(a),a="",!1!==e.createErrors?(a+=" { keyword: '$ref' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(c)+" , params: { ref: '"+e.util.escapeQuotes(s)+"' } ",!1!==e.opts.messages&&(a+=" , message: 'can\\'t resolve reference "+e.util.escapeQuotes(s)+"' "),e.opts.verbose&&(a+=" , schema: "+e.util.toQuotedString(s)+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+d+" "),a+=" } "):a+=" {} ";var b=a;a=g.pop(),!e.compositeRule&&u?e.async?a+=" throw new ValidationError(["+b+"]); ":a+=" validate.errors = ["+b+"]; return false; ":a+=" var err = "+b+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",u&&(a+=" if (false) { ")}else{if("ignore"!=e.opts.missingRefs)throw new e.MissingRefError(e.baseId,s,h);e.logger.warn(h),u&&(a+=" if (true) { ")}}else if(p.inline){var m=e.util.copy(e);m.level++;var y="valid"+m.level;m.schema=p.schema,m.schemaPath="",m.errSchemaPath=s,a+=" "+e.validate(m).replace(/validate\.schema/g,p.code)+" ",u&&(a+=" if ("+y+") { ")}else n=!0===p.$async||e.async&&!1!==p.$async,f=p.code}if(f){var g;(g=g||[]).push(a),a="",e.opts.passContext?a+=" "+f+".call(this, ":a+=" "+f+"( ",a+=" "+d+", (dataPath || '')",'""'!=e.errorPath&&(a+=" + "+e.errorPath);var v=a+=" , "+(o?"data"+(o-1||""):"parentData")+" , "+(o?e.dataPathArr[o]:"parentDataProperty")+", rootData) ";if(a=g.pop(),n){if(!e.async)throw new Error("async schema referenced by sync schema");u&&(a+=" var "+l+"; "),a+=" try { await "+v+"; ",u&&(a+=" "+l+" = true; "),a+=" } catch (e) { if (!(e instanceof ValidationError)) throw e; if (vErrors === null) vErrors = e.errors; else vErrors = vErrors.concat(e.errors); errors = vErrors.length; ",u&&(a+=" "+l+" = false; "),a+=" } ",u&&(a+=" if ("+l+") { ")}else a+=" if (!"+v+") { if (vErrors === null) vErrors = "+f+".errors; else vErrors = vErrors.concat("+f+".errors); errors = vErrors.length; } ",u&&(a+=" else { ")}return a}},function(e,t,r){"use strict";e.exports=function(e,t,r){var n=" ",f=e.schema[t],a=e.schemaPath+e.util.getProperty(t),i=e.errSchemaPath+"/"+t,o=!e.opts.allErrors,s=e.util.copy(e),c="";s.level++;var u="valid"+s.level,d=s.baseId,l=!0,p=f;if(p)for(var h,b=-1,m=p.length-1;b<m;)h=p[b+=1],(e.opts.strictKeywords?"object"==typeof h&&Object.keys(h).length>0:e.util.schemaHasRules(h,e.RULES.all))&&(l=!1,s.schema=h,s.schemaPath=a+"["+b+"]",s.errSchemaPath=i+"/"+b,n+=" "+e.validate(s)+" ",s.baseId=d,o&&(n+=" if ("+u+") { ",c+="}"));return o&&(n+=l?" if (true) { ":" "+c.slice(0,-1)+" "),n}},function(e,t,r){"use strict";e.exports=function(e,t,r){var n=" ",f=e.level,a=e.dataLevel,i=e.schema[t],o=e.schemaPath+e.util.getProperty(t),s=e.errSchemaPath+"/"+t,c=!e.opts.allErrors,u="data"+(a||""),d="valid"+f,l="errs__"+f,p=e.util.copy(e),h="";p.level++;var b="valid"+p.level,m=i.every((function(t){return e.opts.strictKeywords?"object"==typeof t&&Object.keys(t).length>0:e.util.schemaHasRules(t,e.RULES.all)}));if(m){var y=p.baseId;n+=" var "+l+" = errors; var "+d+" = false; ";var g=e.compositeRule;e.compositeRule=p.compositeRule=!0;var v=i;if(v)for(var _,w=-1,E=v.length-1;w<E;)_=v[w+=1],p.schema=_,p.schemaPath=o+"["+w+"]",p.errSchemaPath=s+"/"+w,n+=" "+e.validate(p)+" ",p.baseId=y,n+=" "+d+" = "+d+" || "+b+"; if (!"+d+") { ",h+="}";e.compositeRule=p.compositeRule=g,n+=" "+h+" if (!"+d+") { var err = ",!1!==e.createErrors?(n+=" { keyword: 'anyOf' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(s)+" , params: {} ",!1!==e.opts.messages&&(n+=" , message: 'should match some schema in anyOf' "),e.opts.verbose&&(n+=" , schema: validate.schema"+o+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+u+" "),n+=" } "):n+=" {} ",n+="; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",!e.compositeRule&&c&&(e.async?n+=" throw new ValidationError(vErrors); ":n+=" validate.errors = vErrors; return false; "),n+=" } else { errors = "+l+"; if (vErrors !== null) { if ("+l+") vErrors.length = "+l+"; else vErrors = null; } ",e.opts.allErrors&&(n+=" } ")}else c&&(n+=" if (true) { ");return n}},function(e,t,r){"use strict";e.exports=function(e,t,r){var n=" ",f=e.schema[t],a=e.errSchemaPath+"/"+t,i=(e.opts.allErrors,e.util.toQuotedString(f));return!0===e.opts.$comment?n+=" console.log("+i+");":"function"==typeof e.opts.$comment&&(n+=" self._opts.$comment("+i+", "+e.util.toQuotedString(a)+", validate.root.schema);"),n}},function(e,t,r){"use strict";e.exports=function(e,t,r){var n=" ",f=e.level,a=e.dataLevel,i=e.schema[t],o=e.schemaPath+e.util.getProperty(t),s=e.errSchemaPath+"/"+t,c=!e.opts.allErrors,u="data"+(a||""),d="valid"+f,l=e.opts.$data&&i&&i.$data;l&&(n+=" var schema"+f+" = "+e.util.getData(i.$data,a,e.dataPathArr)+"; "),l||(n+=" var schema"+f+" = validate.schema"+o+";"),n+="var "+d+" = equal("+u+", schema"+f+"); if (!"+d+") { ";var p=p||[];p.push(n),n="",!1!==e.createErrors?(n+=" { keyword: 'const' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(s)+" , params: { allowedValue: schema"+f+" } ",!1!==e.opts.messages&&(n+=" , message: 'should be equal to constant' "),e.opts.verbose&&(n+=" , schema: validate.schema"+o+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+u+" "),n+=" } "):n+=" {} ";var h=n;return n=p.pop(),!e.compositeRule&&c?e.async?n+=" throw new ValidationError(["+h+"]); ":n+=" validate.errors = ["+h+"]; return false; ":n+=" var err = "+h+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",n+=" }",c&&(n+=" else { "),n}},function(e,t,r){"use strict";e.exports=function(e,t,r){var n=" ",f=e.level,a=e.dataLevel,i=e.schema[t],o=e.schemaPath+e.util.getProperty(t),s=e.errSchemaPath+"/"+t,c=!e.opts.allErrors,u="data"+(a||""),d="valid"+f,l="errs__"+f,p=e.util.copy(e);p.level++;var h="valid"+p.level,b="i"+f,m=p.dataLevel=e.dataLevel+1,y="data"+m,g=e.baseId,v=e.opts.strictKeywords?"object"==typeof i&&Object.keys(i).length>0:e.util.schemaHasRules(i,e.RULES.all);if(n+="var "+l+" = errors;var "+d+";",v){var _=e.compositeRule;e.compositeRule=p.compositeRule=!0,p.schema=i,p.schemaPath=o,p.errSchemaPath=s,n+=" var "+h+" = false; for (var "+b+" = 0; "+b+" < "+u+".length; "+b+"++) { ",p.errorPath=e.util.getPathExpr(e.errorPath,b,e.opts.jsonPointers,!0);var w=u+"["+b+"]";p.dataPathArr[m]=b;var E=e.validate(p);p.baseId=g,e.util.varOccurences(E,y)<2?n+=" "+e.util.varReplace(E,y,w)+" ":n+=" var "+y+" = "+w+"; "+E+" ",n+=" if ("+h+") break; } ",e.compositeRule=p.compositeRule=_,n+=" if (!"+h+") {"}else n+=" if ("+u+".length == 0) {";var A=A||[];A.push(n),n="",!1!==e.createErrors?(n+=" { keyword: 'contains' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(s)+" , params: {} ",!1!==e.opts.messages&&(n+=" , message: 'should contain a valid item' "),e.opts.verbose&&(n+=" , schema: validate.schema"+o+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+u+" "),n+=" } "):n+=" {} ";var T=n;return n=A.pop(),!e.compositeRule&&c?e.async?n+=" throw new ValidationError(["+T+"]); ":n+=" validate.errors = ["+T+"]; return false; ":n+=" var err = "+T+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",n+=" } else { ",v&&(n+=" errors = "+l+"; if (vErrors !== null) { if ("+l+") vErrors.length = "+l+"; else vErrors = null; } "),e.opts.allErrors&&(n+=" } "),n}},function(e,t,r){"use strict";e.exports=function(e,t,r){var n=" ",f=e.level,a=e.dataLevel,i=e.schema[t],o=e.schemaPath+e.util.getProperty(t),s=e.errSchemaPath+"/"+t,c=!e.opts.allErrors,u="data"+(a||""),d="errs__"+f,l=e.util.copy(e),p="";l.level++;var h="valid"+l.level,b={},m={},y=e.opts.ownProperties;for(w in i)if("__proto__"!=w){var g=i[w],v=Array.isArray(g)?m:b;v[w]=g}n+="var "+d+" = errors;";var _=e.errorPath;for(var w in n+="var missing"+f+";",m)if((v=m[w]).length){if(n+=" if ( "+u+e.util.getProperty(w)+" !== undefined ",y&&(n+=" && Object.prototype.hasOwnProperty.call("+u+", '"+e.util.escapeQuotes(w)+"') "),c){n+=" && ( ";var E=v;if(E)for(var A=-1,T=E.length-1;A<T;){P=E[A+=1],A&&(n+=" || "),n+=" ( ( "+(M=u+(I=e.util.getProperty(P)))+" === undefined ",y&&(n+=" || ! Object.prototype.hasOwnProperty.call("+u+", '"+e.util.escapeQuotes(P)+"') "),n+=") && (missing"+f+" = "+e.util.toQuotedString(e.opts.jsonPointers?P:I)+") ) "}n+=")) { ";var x="missing"+f,k="' + "+x+" + '";e.opts._errorDataPathProperty&&(e.errorPath=e.opts.jsonPointers?e.util.getPathExpr(_,x,!0):_+" + "+x);var S=S||[];S.push(n),n="",!1!==e.createErrors?(n+=" { keyword: 'dependencies' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(s)+" , params: { property: '"+e.util.escapeQuotes(w)+"', missingProperty: '"+k+"', depsCount: "+v.length+", deps: '"+e.util.escapeQuotes(1==v.length?v[0]:v.join(", "))+"' } ",!1!==e.opts.messages&&(n+=" , message: 'should have ",1==v.length?n+="property "+e.util.escapeQuotes(v[0]):n+="properties "+e.util.escapeQuotes(v.join(", ")),n+=" when property "+e.util.escapeQuotes(w)+" is present' "),e.opts.verbose&&(n+=" , schema: validate.schema"+o+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+u+" "),n+=" } "):n+=" {} ";var O=n;n=S.pop(),!e.compositeRule&&c?e.async?n+=" throw new ValidationError(["+O+"]); ":n+=" validate.errors = ["+O+"]; return false; ":n+=" var err = "+O+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; "}else{n+=" ) { ";var C=v;if(C)for(var P,R=-1,N=C.length-1;R<N;){P=C[R+=1];var I=e.util.getProperty(P),M=(k=e.util.escapeQuotes(P),u+I);e.opts._errorDataPathProperty&&(e.errorPath=e.util.getPath(_,P,e.opts.jsonPointers)),n+=" if ( "+M+" === undefined ",y&&(n+=" || ! Object.prototype.hasOwnProperty.call("+u+", '"+e.util.escapeQuotes(P)+"') "),n+=") { var err = ",!1!==e.createErrors?(n+=" { keyword: 'dependencies' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(s)+" , params: { property: '"+e.util.escapeQuotes(w)+"', missingProperty: '"+k+"', depsCount: "+v.length+", deps: '"+e.util.escapeQuotes(1==v.length?v[0]:v.join(", "))+"' } ",!1!==e.opts.messages&&(n+=" , message: 'should have ",1==v.length?n+="property "+e.util.escapeQuotes(v[0]):n+="properties "+e.util.escapeQuotes(v.join(", ")),n+=" when property "+e.util.escapeQuotes(w)+" is present' "),e.opts.verbose&&(n+=" , schema: validate.schema"+o+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+u+" "),n+=" } "):n+=" {} ",n+="; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; } "}}n+=" } ",c&&(p+="}",n+=" else { ")}e.errorPath=_;var D=l.baseId;for(var w in b){g=b[w];(e.opts.strictKeywords?"object"==typeof g&&Object.keys(g).length>0:e.util.schemaHasRules(g,e.RULES.all))&&(n+=" "+h+" = true; if ( "+u+e.util.getProperty(w)+" !== undefined ",y&&(n+=" && Object.prototype.hasOwnProperty.call("+u+", '"+e.util.escapeQuotes(w)+"') "),n+=") { ",l.schema=g,l.schemaPath=o+e.util.getProperty(w),l.errSchemaPath=s+"/"+e.util.escapeFragment(w),n+=" "+e.validate(l)+" ",l.baseId=D,n+=" } ",c&&(n+=" if ("+h+") { ",p+="}"))}return c&&(n+=" "+p+" if ("+d+" == errors) {"),n}},function(e,t,r){"use strict";e.exports=function(e,t,r){var n=" ",f=e.level,a=e.dataLevel,i=e.schema[t],o=e.schemaPath+e.util.getProperty(t),s=e.errSchemaPath+"/"+t,c=!e.opts.allErrors,u="data"+(a||""),d="valid"+f,l=e.opts.$data&&i&&i.$data;l&&(n+=" var schema"+f+" = "+e.util.getData(i.$data,a,e.dataPathArr)+"; ");var p="i"+f,h="schema"+f;l||(n+=" var "+h+" = validate.schema"+o+";"),n+="var "+d+";",l&&(n+=" if (schema"+f+" === undefined) "+d+" = true; else if (!Array.isArray(schema"+f+")) "+d+" = false; else {"),n+=d+" = false;for (var "+p+"=0; "+p+"<"+h+".length; "+p+"++) if (equal("+u+", "+h+"["+p+"])) { "+d+" = true; break; }",l&&(n+=" } "),n+=" if (!"+d+") { ";var b=b||[];b.push(n),n="",!1!==e.createErrors?(n+=" { keyword: 'enum' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(s)+" , params: { allowedValues: schema"+f+" } ",!1!==e.opts.messages&&(n+=" , message: 'should be equal to one of the allowed values' "),e.opts.verbose&&(n+=" , schema: validate.schema"+o+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+u+" "),n+=" } "):n+=" {} ";var m=n;return n=b.pop(),!e.compositeRule&&c?e.async?n+=" throw new ValidationError(["+m+"]); ":n+=" validate.errors = ["+m+"]; return false; ":n+=" var err = "+m+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",n+=" }",c&&(n+=" else { "),n}},function(e,t,r){"use strict";e.exports=function(e,t,r){var n=" ",f=e.level,a=e.dataLevel,i=e.schema[t],o=e.schemaPath+e.util.getProperty(t),s=e.errSchemaPath+"/"+t,c=!e.opts.allErrors,u="data"+(a||"");if(!1===e.opts.format)return c&&(n+=" if (true) { "),n;var d,l=e.opts.$data&&i&&i.$data;l?(n+=" var schema"+f+" = "+e.util.getData(i.$data,a,e.dataPathArr)+"; ",d="schema"+f):d=i;var p=e.opts.unknownFormats,h=Array.isArray(p);if(l){n+=" var "+(b="format"+f)+" = formats["+d+"]; var "+(m="isObject"+f)+" = typeof "+b+" == 'object' && !("+b+" instanceof RegExp) && "+b+".validate; var "+(y="formatType"+f)+" = "+m+" && "+b+".type || 'string'; if ("+m+") { ",e.async&&(n+=" var async"+f+" = "+b+".async; "),n+=" "+b+" = "+b+".validate; } if ( ",l&&(n+=" ("+d+" !== undefined && typeof "+d+" != 'string') || "),n+=" (","ignore"!=p&&(n+=" ("+d+" && !"+b+" ",h&&(n+=" && self._opts.unknownFormats.indexOf("+d+") == -1 "),n+=") || "),n+=" ("+b+" && "+y+" == '"+r+"' && !(typeof "+b+" == 'function' ? ",e.async?n+=" (async"+f+" ? await "+b+"("+u+") : "+b+"("+u+")) ":n+=" "+b+"("+u+") ",n+=" : "+b+".test("+u+"))))) {"}else{var b;if(!(b=e.formats[i])){if("ignore"==p)return e.logger.warn('unknown format "'+i+'" ignored in schema at path "'+e.errSchemaPath+'"'),c&&(n+=" if (true) { "),n;if(h&&p.indexOf(i)>=0)return c&&(n+=" if (true) { "),n;throw new Error('unknown format "'+i+'" is used in schema at path "'+e.errSchemaPath+'"')}var m,y=(m="object"==typeof b&&!(b instanceof RegExp)&&b.validate)&&b.type||"string";if(m){var g=!0===b.async;b=b.validate}if(y!=r)return c&&(n+=" if (true) { "),n;if(g){if(!e.async)throw new Error("async format in sync schema");n+=" if (!(await "+(v="formats"+e.util.getProperty(i)+".validate")+"("+u+"))) { "}else{n+=" if (! ";var v="formats"+e.util.getProperty(i);m&&(v+=".validate"),n+="function"==typeof b?" "+v+"("+u+") ":" "+v+".test("+u+") ",n+=") { "}}var _=_||[];_.push(n),n="",!1!==e.createErrors?(n+=" { keyword: 'format' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(s)+" , params: { format: ",n+=l?""+d:""+e.util.toQuotedString(i),n+=" } ",!1!==e.opts.messages&&(n+=" , message: 'should match format \"",n+=l?"' + "+d+" + '":""+e.util.escapeQuotes(i),n+="\"' "),e.opts.verbose&&(n+=" , schema: ",n+=l?"validate.schema"+o:""+e.util.toQuotedString(i),n+=" , parentSchema: validate.schema"+e.schemaPath+" , data: "+u+" "),n+=" } "):n+=" {} ";var w=n;return n=_.pop(),!e.compositeRule&&c?e.async?n+=" throw new ValidationError(["+w+"]); ":n+=" validate.errors = ["+w+"]; return false; ":n+=" var err = "+w+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",n+=" } ",c&&(n+=" else { "),n}},function(e,t,r){"use strict";e.exports=function(e,t,r){var n=" ",f=e.level,a=e.dataLevel,i=e.schema[t],o=e.schemaPath+e.util.getProperty(t),s=e.errSchemaPath+"/"+t,c=!e.opts.allErrors,u="data"+(a||""),d="valid"+f,l="errs__"+f,p=e.util.copy(e);p.level++;var h="valid"+p.level,b=e.schema.then,m=e.schema.else,y=void 0!==b&&(e.opts.strictKeywords?"object"==typeof b&&Object.keys(b).length>0:e.util.schemaHasRules(b,e.RULES.all)),g=void 0!==m&&(e.opts.strictKeywords?"object"==typeof m&&Object.keys(m).length>0:e.util.schemaHasRules(m,e.RULES.all)),v=p.baseId;if(y||g){var _;p.createErrors=!1,p.schema=i,p.schemaPath=o,p.errSchemaPath=s,n+=" var "+l+" = errors; var "+d+" = true; ";var w=e.compositeRule;e.compositeRule=p.compositeRule=!0,n+=" "+e.validate(p)+" ",p.baseId=v,p.createErrors=!0,n+=" errors = "+l+"; if (vErrors !== null) { if ("+l+") vErrors.length = "+l+"; else vErrors = null; } ",e.compositeRule=p.compositeRule=w,y?(n+=" if ("+h+") { ",p.schema=e.schema.then,p.schemaPath=e.schemaPath+".then",p.errSchemaPath=e.errSchemaPath+"/then",n+=" "+e.validate(p)+" ",p.baseId=v,n+=" "+d+" = "+h+"; ",y&&g?n+=" var "+(_="ifClause"+f)+" = 'then'; ":_="'then'",n+=" } ",g&&(n+=" else { ")):n+=" if (!"+h+") { ",g&&(p.schema=e.schema.else,p.schemaPath=e.schemaPath+".else",p.errSchemaPath=e.errSchemaPath+"/else",n+=" "+e.validate(p)+" ",p.baseId=v,n+=" "+d+" = "+h+"; ",y&&g?n+=" var "+(_="ifClause"+f)+" = 'else'; ":_="'else'",n+=" } "),n+=" if (!"+d+") { var err = ",!1!==e.createErrors?(n+=" { keyword: 'if' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(s)+" , params: { failingKeyword: "+_+" } ",!1!==e.opts.messages&&(n+=" , message: 'should match \"' + "+_+" + '\" schema' "),e.opts.verbose&&(n+=" , schema: validate.schema"+o+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+u+" "),n+=" } "):n+=" {} ",n+="; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",!e.compositeRule&&c&&(e.async?n+=" throw new ValidationError(vErrors); ":n+=" validate.errors = vErrors; return false; "),n+=" } ",c&&(n+=" else { ")}else c&&(n+=" if (true) { ");return n}},function(e,t,r){"use strict";e.exports=function(e,t,r){var n=" ",f=e.level,a=e.dataLevel,i=e.schema[t],o=e.schemaPath+e.util.getProperty(t),s=e.errSchemaPath+"/"+t,c=!e.opts.allErrors,u="data"+(a||""),d="valid"+f,l="errs__"+f,p=e.util.copy(e),h="";p.level++;var b="valid"+p.level,m="i"+f,y=p.dataLevel=e.dataLevel+1,g="data"+y,v=e.baseId;if(n+="var "+l+" = errors;var "+d+";",Array.isArray(i)){var _=e.schema.additionalItems;if(!1===_){n+=" "+d+" = "+u+".length <= "+i.length+"; ";var w=s;s=e.errSchemaPath+"/additionalItems",n+=" if (!"+d+") { ";var E=E||[];E.push(n),n="",!1!==e.createErrors?(n+=" { keyword: 'additionalItems' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(s)+" , params: { limit: "+i.length+" } ",!1!==e.opts.messages&&(n+=" , message: 'should NOT have more than "+i.length+" items' "),e.opts.verbose&&(n+=" , schema: false , parentSchema: validate.schema"+e.schemaPath+" , data: "+u+" "),n+=" } "):n+=" {} ";var A=n;n=E.pop(),!e.compositeRule&&c?e.async?n+=" throw new ValidationError(["+A+"]); ":n+=" validate.errors = ["+A+"]; return false; ":n+=" var err = "+A+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",n+=" } ",s=w,c&&(h+="}",n+=" else { ")}var T=i;if(T)for(var x,k=-1,S=T.length-1;k<S;)if(x=T[k+=1],e.opts.strictKeywords?"object"==typeof x&&Object.keys(x).length>0:e.util.schemaHasRules(x,e.RULES.all)){n+=" "+b+" = true; if ("+u+".length > "+k+") { ";var O=u+"["+k+"]";p.schema=x,p.schemaPath=o+"["+k+"]",p.errSchemaPath=s+"/"+k,p.errorPath=e.util.getPathExpr(e.errorPath,k,e.opts.jsonPointers,!0),p.dataPathArr[y]=k;var C=e.validate(p);p.baseId=v,e.util.varOccurences(C,g)<2?n+=" "+e.util.varReplace(C,g,O)+" ":n+=" var "+g+" = "+O+"; "+C+" ",n+=" } ",c&&(n+=" if ("+b+") { ",h+="}")}if("object"==typeof _&&(e.opts.strictKeywords?"object"==typeof _&&Object.keys(_).length>0:e.util.schemaHasRules(_,e.RULES.all))){p.schema=_,p.schemaPath=e.schemaPath+".additionalItems",p.errSchemaPath=e.errSchemaPath+"/additionalItems",n+=" "+b+" = true; if ("+u+".length > "+i.length+") { for (var "+m+" = "+i.length+"; "+m+" < "+u+".length; "+m+"++) { ",p.errorPath=e.util.getPathExpr(e.errorPath,m,e.opts.jsonPointers,!0);O=u+"["+m+"]";p.dataPathArr[y]=m;C=e.validate(p);p.baseId=v,e.util.varOccurences(C,g)<2?n+=" "+e.util.varReplace(C,g,O)+" ":n+=" var "+g+" = "+O+"; "+C+" ",c&&(n+=" if (!"+b+") break; "),n+=" } } ",c&&(n+=" if ("+b+") { ",h+="}")}}else if(e.opts.strictKeywords?"object"==typeof i&&Object.keys(i).length>0:e.util.schemaHasRules(i,e.RULES.all)){p.schema=i,p.schemaPath=o,p.errSchemaPath=s,n+=" for (var "+m+" = 0; "+m+" < "+u+".length; "+m+"++) { ",p.errorPath=e.util.getPathExpr(e.errorPath,m,e.opts.jsonPointers,!0);O=u+"["+m+"]";p.dataPathArr[y]=m;C=e.validate(p);p.baseId=v,e.util.varOccurences(C,g)<2?n+=" "+e.util.varReplace(C,g,O)+" ":n+=" var "+g+" = "+O+"; "+C+" ",c&&(n+=" if (!"+b+") break; "),n+=" }"}return c&&(n+=" "+h+" if ("+l+" == errors) {"),n}},function(e,t,r){"use strict";e.exports=function(e,t,r){var n,f=" ",a=e.level,i=e.dataLevel,o=e.schema[t],s=e.schemaPath+e.util.getProperty(t),c=e.errSchemaPath+"/"+t,u=!e.opts.allErrors,d="data"+(i||""),l=e.opts.$data&&o&&o.$data;if(l?(f+=" var schema"+a+" = "+e.util.getData(o.$data,i,e.dataPathArr)+"; ",n="schema"+a):n=o,!l&&"number"!=typeof o)throw new Error(t+" must be number");f+="var division"+a+";if (",l&&(f+=" "+n+" !== undefined && ( typeof "+n+" != 'number' || "),f+=" (division"+a+" = "+d+" / "+n+", ",e.opts.multipleOfPrecision?f+=" Math.abs(Math.round(division"+a+") - division"+a+") > 1e-"+e.opts.multipleOfPrecision+" ":f+=" division"+a+" !== parseInt(division"+a+") ",f+=" ) ",l&&(f+=" ) "),f+=" ) { ";var p=p||[];p.push(f),f="",!1!==e.createErrors?(f+=" { keyword: 'multipleOf' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(c)+" , params: { multipleOf: "+n+" } ",!1!==e.opts.messages&&(f+=" , message: 'should be multiple of ",f+=l?"' + "+n:n+"'"),e.opts.verbose&&(f+=" , schema: ",f+=l?"validate.schema"+s:""+o,f+=" , parentSchema: validate.schema"+e.schemaPath+" , data: "+d+" "),f+=" } "):f+=" {} ";var h=f;return f=p.pop(),!e.compositeRule&&u?e.async?f+=" throw new ValidationError(["+h+"]); ":f+=" validate.errors = ["+h+"]; return false; ":f+=" var err = "+h+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",f+="} ",u&&(f+=" else { "),f}},function(e,t,r){"use strict";e.exports=function(e,t,r){var n=" ",f=e.level,a=e.dataLevel,i=e.schema[t],o=e.schemaPath+e.util.getProperty(t),s=e.errSchemaPath+"/"+t,c=!e.opts.allErrors,u="data"+(a||""),d="errs__"+f,l=e.util.copy(e);l.level++;var p="valid"+l.level;if(e.opts.strictKeywords?"object"==typeof i&&Object.keys(i).length>0:e.util.schemaHasRules(i,e.RULES.all)){l.schema=i,l.schemaPath=o,l.errSchemaPath=s,n+=" var "+d+" = errors; ";var h,b=e.compositeRule;e.compositeRule=l.compositeRule=!0,l.createErrors=!1,l.opts.allErrors&&(h=l.opts.allErrors,l.opts.allErrors=!1),n+=" "+e.validate(l)+" ",l.createErrors=!0,h&&(l.opts.allErrors=h),e.compositeRule=l.compositeRule=b,n+=" if ("+p+") { ";var m=m||[];m.push(n),n="",!1!==e.createErrors?(n+=" { keyword: 'not' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(s)+" , params: {} ",!1!==e.opts.messages&&(n+=" , message: 'should NOT be valid' "),e.opts.verbose&&(n+=" , schema: validate.schema"+o+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+u+" "),n+=" } "):n+=" {} ";var y=n;n=m.pop(),!e.compositeRule&&c?e.async?n+=" throw new ValidationError(["+y+"]); ":n+=" validate.errors = ["+y+"]; return false; ":n+=" var err = "+y+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",n+=" } else { errors = "+d+"; if (vErrors !== null) { if ("+d+") vErrors.length = "+d+"; else vErrors = null; } ",e.opts.allErrors&&(n+=" } ")}else n+=" var err = ",!1!==e.createErrors?(n+=" { keyword: 'not' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(s)+" , params: {} ",!1!==e.opts.messages&&(n+=" , message: 'should NOT be valid' "),e.opts.verbose&&(n+=" , schema: validate.schema"+o+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+u+" "),n+=" } "):n+=" {} ",n+="; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",c&&(n+=" if (false) { ");return n}},function(e,t,r){"use strict";e.exports=function(e,t,r){var n=" ",f=e.level,a=e.dataLevel,i=e.schema[t],o=e.schemaPath+e.util.getProperty(t),s=e.errSchemaPath+"/"+t,c=!e.opts.allErrors,u="data"+(a||""),d="valid"+f,l="errs__"+f,p=e.util.copy(e),h="";p.level++;var b="valid"+p.level,m=p.baseId,y="prevValid"+f,g="passingSchemas"+f;n+="var "+l+" = errors , "+y+" = false , "+d+" = false , "+g+" = null; ";var v=e.compositeRule;e.compositeRule=p.compositeRule=!0;var _=i;if(_)for(var w,E=-1,A=_.length-1;E<A;)w=_[E+=1],(e.opts.strictKeywords?"object"==typeof w&&Object.keys(w).length>0:e.util.schemaHasRules(w,e.RULES.all))?(p.schema=w,p.schemaPath=o+"["+E+"]",p.errSchemaPath=s+"/"+E,n+=" "+e.validate(p)+" ",p.baseId=m):n+=" var "+b+" = true; ",E&&(n+=" if ("+b+" && "+y+") { "+d+" = false; "+g+" = ["+g+", "+E+"]; } else { ",h+="}"),n+=" if ("+b+") { "+d+" = "+y+" = true; "+g+" = "+E+"; }";return e.compositeRule=p.compositeRule=v,n+=h+"if (!"+d+") { var err = ",!1!==e.createErrors?(n+=" { keyword: 'oneOf' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(s)+" , params: { passingSchemas: "+g+" } ",!1!==e.opts.messages&&(n+=" , message: 'should match exactly one schema in oneOf' "),e.opts.verbose&&(n+=" , schema: validate.schema"+o+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+u+" "),n+=" } "):n+=" {} ",n+="; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",!e.compositeRule&&c&&(e.async?n+=" throw new ValidationError(vErrors); ":n+=" validate.errors = vErrors; return false; "),n+="} else { errors = "+l+"; if (vErrors !== null) { if ("+l+") vErrors.length = "+l+"; else vErrors = null; }",e.opts.allErrors&&(n+=" } "),n}},function(e,t,r){"use strict";e.exports=function(e,t,r){var n,f=" ",a=e.level,i=e.dataLevel,o=e.schema[t],s=e.schemaPath+e.util.getProperty(t),c=e.errSchemaPath+"/"+t,u=!e.opts.allErrors,d="data"+(i||""),l=e.opts.$data&&o&&o.$data;l?(f+=" var schema"+a+" = "+e.util.getData(o.$data,i,e.dataPathArr)+"; ",n="schema"+a):n=o,f+="if ( ",l&&(f+=" ("+n+" !== undefined && typeof "+n+" != 'string') || "),f+=" !"+(l?"(new RegExp("+n+"))":e.usePattern(o))+".test("+d+") ) { ";var p=p||[];p.push(f),f="",!1!==e.createErrors?(f+=" { keyword: 'pattern' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(c)+" , params: { pattern: ",f+=l?""+n:""+e.util.toQuotedString(o),f+=" } ",!1!==e.opts.messages&&(f+=" , message: 'should match pattern \"",f+=l?"' + "+n+" + '":""+e.util.escapeQuotes(o),f+="\"' "),e.opts.verbose&&(f+=" , schema: ",f+=l?"validate.schema"+s:""+e.util.toQuotedString(o),f+=" , parentSchema: validate.schema"+e.schemaPath+" , data: "+d+" "),f+=" } "):f+=" {} ";var h=f;return f=p.pop(),!e.compositeRule&&u?e.async?f+=" throw new ValidationError(["+h+"]); ":f+=" validate.errors = ["+h+"]; return false; ":f+=" var err = "+h+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",f+="} ",u&&(f+=" else { "),f}},function(e,t,r){"use strict";e.exports=function(e,t,r){var n=" ",f=e.level,a=e.dataLevel,i=e.schema[t],o=e.schemaPath+e.util.getProperty(t),s=e.errSchemaPath+"/"+t,c=!e.opts.allErrors,u="data"+(a||""),d="errs__"+f,l=e.util.copy(e),p="";l.level++;var h="valid"+l.level,b="key"+f,m="idx"+f,y=l.dataLevel=e.dataLevel+1,g="data"+y,v="dataProperties"+f,_=Object.keys(i||{}).filter(I),w=e.schema.patternProperties||{},E=Object.keys(w).filter(I),A=e.schema.additionalProperties,T=_.length||E.length,x=!1===A,k="object"==typeof A&&Object.keys(A).length,S=e.opts.removeAdditional,O=x||k||S,C=e.opts.ownProperties,P=e.baseId,R=e.schema.required;if(R&&(!e.opts.$data||!R.$data)&&R.length<e.opts.loopRequired)var N=e.util.toHash(R);function I(e){return"__proto__"!==e}if(n+="var "+d+" = errors;var "+h+" = true;",C&&(n+=" var "+v+" = undefined;"),O){if(n+=C?" "+v+" = "+v+" || Object.keys("+u+"); for (var "+m+"=0; "+m+"<"+v+".length; "+m+"++) { var "+b+" = "+v+"["+m+"]; ":" for (var "+b+" in "+u+") { ",T){if(n+=" var isAdditional"+f+" = !(false ",_.length)if(_.length>8)n+=" || validate.schema"+o+".hasOwnProperty("+b+") ";else{var M=_;if(M)for(var D=-1,B=M.length-1;D<B;)Y=M[D+=1],n+=" || "+b+" == "+e.util.toQuotedString(Y)+" "}if(E.length){var F=E;if(F)for(var j=-1,L=F.length-1;j<L;)ae=F[j+=1],n+=" || "+e.usePattern(ae)+".test("+b+") "}n+=" ); if (isAdditional"+f+") { "}if("all"==S)n+=" delete "+u+"["+b+"]; ";else{var U=e.errorPath,q="' + "+b+" + '";if(e.opts._errorDataPathProperty&&(e.errorPath=e.util.getPathExpr(e.errorPath,b,e.opts.jsonPointers)),x)if(S)n+=" delete "+u+"["+b+"]; ";else{n+=" "+h+" = false; ";var H=s;s=e.errSchemaPath+"/additionalProperties",(re=re||[]).push(n),n="",!1!==e.createErrors?(n+=" { keyword: 'additionalProperties' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(s)+" , params: { additionalProperty: '"+q+"' } ",!1!==e.opts.messages&&(n+=" , message: '",e.opts._errorDataPathProperty?n+="is an invalid additional property":n+="should NOT have additional properties",n+="' "),e.opts.verbose&&(n+=" , schema: false , parentSchema: validate.schema"+e.schemaPath+" , data: "+u+" "),n+=" } "):n+=" {} ";var $=n;n=re.pop(),!e.compositeRule&&c?e.async?n+=" throw new ValidationError(["+$+"]); ":n+=" validate.errors = ["+$+"]; return false; ":n+=" var err = "+$+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",s=H,c&&(n+=" break; ")}else if(k)if("failing"==S){n+=" var "+d+" = errors; ";var z=e.compositeRule;e.compositeRule=l.compositeRule=!0,l.schema=A,l.schemaPath=e.schemaPath+".additionalProperties",l.errSchemaPath=e.errSchemaPath+"/additionalProperties",l.errorPath=e.opts._errorDataPathProperty?e.errorPath:e.util.getPathExpr(e.errorPath,b,e.opts.jsonPointers);var V=u+"["+b+"]";l.dataPathArr[y]=b;var G=e.validate(l);l.baseId=P,e.util.varOccurences(G,g)<2?n+=" "+e.util.varReplace(G,g,V)+" ":n+=" var "+g+" = "+V+"; "+G+" ",n+=" if (!"+h+") { errors = "+d+"; if (validate.errors !== null) { if (errors) validate.errors.length = errors; else validate.errors = null; } delete "+u+"["+b+"]; } ",e.compositeRule=l.compositeRule=z}else{l.schema=A,l.schemaPath=e.schemaPath+".additionalProperties",l.errSchemaPath=e.errSchemaPath+"/additionalProperties",l.errorPath=e.opts._errorDataPathProperty?e.errorPath:e.util.getPathExpr(e.errorPath,b,e.opts.jsonPointers);V=u+"["+b+"]";l.dataPathArr[y]=b;G=e.validate(l);l.baseId=P,e.util.varOccurences(G,g)<2?n+=" "+e.util.varReplace(G,g,V)+" ":n+=" var "+g+" = "+V+"; "+G+" ",c&&(n+=" if (!"+h+") break; ")}e.errorPath=U}T&&(n+=" } "),n+=" } ",c&&(n+=" if ("+h+") { ",p+="}")}var K=e.opts.useDefaults&&!e.compositeRule;if(_.length){var W=_;if(W)for(var Y,J=-1,X=W.length-1;J<X;){var Z=i[Y=W[J+=1]];if(e.opts.strictKeywords?"object"==typeof Z&&Object.keys(Z).length>0:e.util.schemaHasRules(Z,e.RULES.all)){var Q=e.util.getProperty(Y),ee=(V=u+Q,K&&void 0!==Z.default);l.schema=Z,l.schemaPath=o+Q,l.errSchemaPath=s+"/"+e.util.escapeFragment(Y),l.errorPath=e.util.getPath(e.errorPath,Y,e.opts.jsonPointers),l.dataPathArr[y]=e.util.toQuotedString(Y);G=e.validate(l);if(l.baseId=P,e.util.varOccurences(G,g)<2){G=e.util.varReplace(G,g,V);var te=V}else{te=g;n+=" var "+g+" = "+V+"; "}if(ee)n+=" "+G+" ";else{if(N&&N[Y]){n+=" if ( "+te+" === undefined ",C&&(n+=" || ! Object.prototype.hasOwnProperty.call("+u+", '"+e.util.escapeQuotes(Y)+"') "),n+=") { "+h+" = false; ";U=e.errorPath,H=s;var re,ne=e.util.escapeQuotes(Y);e.opts._errorDataPathProperty&&(e.errorPath=e.util.getPath(U,Y,e.opts.jsonPointers)),s=e.errSchemaPath+"/required",(re=re||[]).push(n),n="",!1!==e.createErrors?(n+=" { keyword: 'required' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(s)+" , params: { missingProperty: '"+ne+"' } ",!1!==e.opts.messages&&(n+=" , message: '",e.opts._errorDataPathProperty?n+="is a required property":n+="should have required property \\'"+ne+"\\'",n+="' "),e.opts.verbose&&(n+=" , schema: validate.schema"+o+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+u+" "),n+=" } "):n+=" {} ";$=n;n=re.pop(),!e.compositeRule&&c?e.async?n+=" throw new ValidationError(["+$+"]); ":n+=" validate.errors = ["+$+"]; return false; ":n+=" var err = "+$+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",s=H,e.errorPath=U,n+=" } else { "}else c?(n+=" if ( "+te+" === undefined ",C&&(n+=" || ! Object.prototype.hasOwnProperty.call("+u+", '"+e.util.escapeQuotes(Y)+"') "),n+=") { "+h+" = true; } else { "):(n+=" if ("+te+" !== undefined ",C&&(n+=" && Object.prototype.hasOwnProperty.call("+u+", '"+e.util.escapeQuotes(Y)+"') "),n+=" ) { ");n+=" "+G+" } "}}c&&(n+=" if ("+h+") { ",p+="}")}}if(E.length){var fe=E;if(fe)for(var ae,ie=-1,oe=fe.length-1;ie<oe;){Z=w[ae=fe[ie+=1]];if(e.opts.strictKeywords?"object"==typeof Z&&Object.keys(Z).length>0:e.util.schemaHasRules(Z,e.RULES.all)){l.schema=Z,l.schemaPath=e.schemaPath+".patternProperties"+e.util.getProperty(ae),l.errSchemaPath=e.errSchemaPath+"/patternProperties/"+e.util.escapeFragment(ae),n+=C?" "+v+" = "+v+" || Object.keys("+u+"); for (var "+m+"=0; "+m+"<"+v+".length; "+m+"++) { var "+b+" = "+v+"["+m+"]; ":" for (var "+b+" in "+u+") { ",n+=" if ("+e.usePattern(ae)+".test("+b+")) { ",l.errorPath=e.util.getPathExpr(e.errorPath,b,e.opts.jsonPointers);V=u+"["+b+"]";l.dataPathArr[y]=b;G=e.validate(l);l.baseId=P,e.util.varOccurences(G,g)<2?n+=" "+e.util.varReplace(G,g,V)+" ":n+=" var "+g+" = "+V+"; "+G+" ",c&&(n+=" if (!"+h+") break; "),n+=" } ",c&&(n+=" else "+h+" = true; "),n+=" } ",c&&(n+=" if ("+h+") { ",p+="}")}}}return c&&(n+=" "+p+" if ("+d+" == errors) {"),n}},function(e,t,r){"use strict";e.exports=function(e,t,r){var n=" ",f=e.level,a=e.dataLevel,i=e.schema[t],o=e.schemaPath+e.util.getProperty(t),s=e.errSchemaPath+"/"+t,c=!e.opts.allErrors,u="data"+(a||""),d="errs__"+f,l=e.util.copy(e);l.level++;var p="valid"+l.level;if(n+="var "+d+" = errors;",e.opts.strictKeywords?"object"==typeof i&&Object.keys(i).length>0:e.util.schemaHasRules(i,e.RULES.all)){l.schema=i,l.schemaPath=o,l.errSchemaPath=s;var h="key"+f,b="idx"+f,m="i"+f,y="' + "+h+" + '",g="data"+(l.dataLevel=e.dataLevel+1),v="dataProperties"+f,_=e.opts.ownProperties,w=e.baseId;_&&(n+=" var "+v+" = undefined; "),n+=_?" "+v+" = "+v+" || Object.keys("+u+"); for (var "+b+"=0; "+b+"<"+v+".length; "+b+"++) { var "+h+" = "+v+"["+b+"]; ":" for (var "+h+" in "+u+") { ",n+=" var startErrs"+f+" = errors; ";var E=h,A=e.compositeRule;e.compositeRule=l.compositeRule=!0;var T=e.validate(l);l.baseId=w,e.util.varOccurences(T,g)<2?n+=" "+e.util.varReplace(T,g,E)+" ":n+=" var "+g+" = "+E+"; "+T+" ",e.compositeRule=l.compositeRule=A,n+=" if (!"+p+") { for (var "+m+"=startErrs"+f+"; "+m+"<errors; "+m+"++) { vErrors["+m+"].propertyName = "+h+"; } var err = ",!1!==e.createErrors?(n+=" { keyword: 'propertyNames' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(s)+" , params: { propertyName: '"+y+"' } ",!1!==e.opts.messages&&(n+=" , message: 'property name \\'"+y+"\\' is invalid' "),e.opts.verbose&&(n+=" , schema: validate.schema"+o+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+u+" "),n+=" } "):n+=" {} ",n+="; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",!e.compositeRule&&c&&(e.async?n+=" throw new ValidationError(vErrors); ":n+=" validate.errors = vErrors; return false; "),c&&(n+=" break; "),n+=" } }"}return c&&(n+=" if ("+d+" == errors) {"),n}},function(e,t,r){"use strict";e.exports=function(e,t,r){var n=" ",f=e.level,a=e.dataLevel,i=e.schema[t],o=e.schemaPath+e.util.getProperty(t),s=e.errSchemaPath+"/"+t,c=!e.opts.allErrors,u="data"+(a||""),d="valid"+f,l=e.opts.$data&&i&&i.$data;l&&(n+=" var schema"+f+" = "+e.util.getData(i.$data,a,e.dataPathArr)+"; ");var p="schema"+f;if(!l)if(i.length<e.opts.loopRequired&&e.schema.properties&&Object.keys(e.schema.properties).length){var h=[],b=i;if(b)for(var m,y=-1,g=b.length-1;y<g;){m=b[y+=1];var v=e.schema.properties[m];v&&(e.opts.strictKeywords?"object"==typeof v&&Object.keys(v).length>0:e.util.schemaHasRules(v,e.RULES.all))||(h[h.length]=m)}}else h=i;if(l||h.length){var _=e.errorPath,w=l||h.length>=e.opts.loopRequired,E=e.opts.ownProperties;if(c)if(n+=" var missing"+f+"; ",w){l||(n+=" var "+p+" = validate.schema"+o+"; ");var A="' + "+(C="schema"+f+"["+(k="i"+f)+"]")+" + '";e.opts._errorDataPathProperty&&(e.errorPath=e.util.getPathExpr(_,C,e.opts.jsonPointers)),n+=" var "+d+" = true; ",l&&(n+=" if (schema"+f+" === undefined) "+d+" = true; else if (!Array.isArray(schema"+f+")) "+d+" = false; else {"),n+=" for (var "+k+" = 0; "+k+" < "+p+".length; "+k+"++) { "+d+" = "+u+"["+p+"["+k+"]] !== undefined ",E&&(n+=" && Object.prototype.hasOwnProperty.call("+u+", "+p+"["+k+"]) "),n+="; if (!"+d+") break; } ",l&&(n+=" } "),n+=" if (!"+d+") { ",(O=O||[]).push(n),n="",!1!==e.createErrors?(n+=" { keyword: 'required' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(s)+" , params: { missingProperty: '"+A+"' } ",!1!==e.opts.messages&&(n+=" , message: '",e.opts._errorDataPathProperty?n+="is a required property":n+="should have required property \\'"+A+"\\'",n+="' "),e.opts.verbose&&(n+=" , schema: validate.schema"+o+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+u+" "),n+=" } "):n+=" {} ";var T=n;n=O.pop(),!e.compositeRule&&c?e.async?n+=" throw new ValidationError(["+T+"]); ":n+=" validate.errors = ["+T+"]; return false; ":n+=" var err = "+T+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",n+=" } else { "}else{n+=" if ( ";var x=h;if(x)for(var k=-1,S=x.length-1;k<S;){R=x[k+=1],k&&(n+=" || "),n+=" ( ( "+(D=u+(M=e.util.getProperty(R)))+" === undefined ",E&&(n+=" || ! Object.prototype.hasOwnProperty.call("+u+", '"+e.util.escapeQuotes(R)+"') "),n+=") && (missing"+f+" = "+e.util.toQuotedString(e.opts.jsonPointers?R:M)+") ) "}n+=") { ";var O;A="' + "+(C="missing"+f)+" + '";e.opts._errorDataPathProperty&&(e.errorPath=e.opts.jsonPointers?e.util.getPathExpr(_,C,!0):_+" + "+C),(O=O||[]).push(n),n="",!1!==e.createErrors?(n+=" { keyword: 'required' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(s)+" , params: { missingProperty: '"+A+"' } ",!1!==e.opts.messages&&(n+=" , message: '",e.opts._errorDataPathProperty?n+="is a required property":n+="should have required property \\'"+A+"\\'",n+="' "),e.opts.verbose&&(n+=" , schema: validate.schema"+o+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+u+" "),n+=" } "):n+=" {} ";T=n;n=O.pop(),!e.compositeRule&&c?e.async?n+=" throw new ValidationError(["+T+"]); ":n+=" validate.errors = ["+T+"]; return false; ":n+=" var err = "+T+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",n+=" } else { "}else if(w){l||(n+=" var "+p+" = validate.schema"+o+"; ");var C;A="' + "+(C="schema"+f+"["+(k="i"+f)+"]")+" + '";e.opts._errorDataPathProperty&&(e.errorPath=e.util.getPathExpr(_,C,e.opts.jsonPointers)),l&&(n+=" if ("+p+" && !Array.isArray("+p+")) { var err = ",!1!==e.createErrors?(n+=" { keyword: 'required' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(s)+" , params: { missingProperty: '"+A+"' } ",!1!==e.opts.messages&&(n+=" , message: '",e.opts._errorDataPathProperty?n+="is a required property":n+="should have required property \\'"+A+"\\'",n+="' "),e.opts.verbose&&(n+=" , schema: validate.schema"+o+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+u+" "),n+=" } "):n+=" {} ",n+="; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; } else if ("+p+" !== undefined) { "),n+=" for (var "+k+" = 0; "+k+" < "+p+".length; "+k+"++) { if ("+u+"["+p+"["+k+"]] === undefined ",E&&(n+=" || ! Object.prototype.hasOwnProperty.call("+u+", "+p+"["+k+"]) "),n+=") { var err = ",!1!==e.createErrors?(n+=" { keyword: 'required' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(s)+" , params: { missingProperty: '"+A+"' } ",!1!==e.opts.messages&&(n+=" , message: '",e.opts._errorDataPathProperty?n+="is a required property":n+="should have required property \\'"+A+"\\'",n+="' "),e.opts.verbose&&(n+=" , schema: validate.schema"+o+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+u+" "),n+=" } "):n+=" {} ",n+="; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; } } ",l&&(n+=" } ")}else{var P=h;if(P)for(var R,N=-1,I=P.length-1;N<I;){R=P[N+=1];var M=e.util.getProperty(R),D=(A=e.util.escapeQuotes(R),u+M);e.opts._errorDataPathProperty&&(e.errorPath=e.util.getPath(_,R,e.opts.jsonPointers)),n+=" if ( "+D+" === undefined ",E&&(n+=" || ! Object.prototype.hasOwnProperty.call("+u+", '"+e.util.escapeQuotes(R)+"') "),n+=") { var err = ",!1!==e.createErrors?(n+=" { keyword: 'required' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(s)+" , params: { missingProperty: '"+A+"' } ",!1!==e.opts.messages&&(n+=" , message: '",e.opts._errorDataPathProperty?n+="is a required property":n+="should have required property \\'"+A+"\\'",n+="' "),e.opts.verbose&&(n+=" , schema: validate.schema"+o+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+u+" "),n+=" } "):n+=" {} ",n+="; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; } "}}e.errorPath=_}else c&&(n+=" if (true) {");return n}},function(e,t,r){"use strict";e.exports=function(e,t,r){var n,f=" ",a=e.level,i=e.dataLevel,o=e.schema[t],s=e.schemaPath+e.util.getProperty(t),c=e.errSchemaPath+"/"+t,u=!e.opts.allErrors,d="data"+(i||""),l="valid"+a,p=e.opts.$data&&o&&o.$data;if(p?(f+=" var schema"+a+" = "+e.util.getData(o.$data,i,e.dataPathArr)+"; ",n="schema"+a):n=o,(o||p)&&!1!==e.opts.uniqueItems){p&&(f+=" var "+l+"; if ("+n+" === false || "+n+" === undefined) "+l+" = true; else if (typeof "+n+" != 'boolean') "+l+" = false; else { "),f+=" var i = "+d+".length , "+l+" = true , j; if (i > 1) { ";var h=e.schema.items&&e.schema.items.type,b=Array.isArray(h);if(!h||"object"==h||"array"==h||b&&(h.indexOf("object")>=0||h.indexOf("array")>=0))f+=" outer: for (;i--;) { for (j = i; j--;) { if (equal("+d+"[i], "+d+"[j])) { "+l+" = false; break outer; } } } ";else{f+=" var itemIndices = {}, item; for (;i--;) { var item = "+d+"[i]; ";var m="checkDataType"+(b?"s":"");f+=" if ("+e.util[m](h,"item",e.opts.strictNumbers,!0)+") continue; ",b&&(f+=" if (typeof item == 'string') item = '\"' + item; "),f+=" if (typeof itemIndices[item] == 'number') { "+l+" = false; j = itemIndices[item]; break; } itemIndices[item] = i; } "}f+=" } ",p&&(f+=" } "),f+=" if (!"+l+") { ";var y=y||[];y.push(f),f="",!1!==e.createErrors?(f+=" { keyword: 'uniqueItems' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(c)+" , params: { i: i, j: j } ",!1!==e.opts.messages&&(f+=" , message: 'should NOT have duplicate items (items ## ' + j + ' and ' + i + ' are identical)' "),e.opts.verbose&&(f+=" , schema: ",f+=p?"validate.schema"+s:""+o,f+=" , parentSchema: validate.schema"+e.schemaPath+" , data: "+d+" "),f+=" } "):f+=" {} ";var g=f;f=y.pop(),!e.compositeRule&&u?e.async?f+=" throw new ValidationError(["+g+"]); ":f+=" validate.errors = ["+g+"]; return false; ":f+=" var err = "+g+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",f+=" } ",u&&(f+=" else { ")}else u&&(f+=" if (true) { ");return f}},function(e,t,r){"use strict";var n=["multipleOf","maximum","exclusiveMaximum","minimum","exclusiveMinimum","maxLength","minLength","pattern","additionalItems","maxItems","minItems","uniqueItems","maxProperties","minProperties","required","additionalProperties","enum","format","const"];e.exports=function(e,t){for(var r=0;r<t.length;r++){e=JSON.parse(JSON.stringify(e));var f,a=t[r].split("/"),i=e;for(f=1;f<a.length;f++)i=i[a[f]];for(f=0;f<n.length;f++){var o=n[f],s=i[o];s&&(i[o]={anyOf:[s,{$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"}]})}}return e}},function(e,t,r){"use strict";var n=r(177).MissingRef;e.exports=function e(t,r,f){var a=this;if("function"!=typeof this._opts.loadSchema)throw new Error("options.loadSchema should be a function");"function"==typeof r&&(f=r,r=void 0);var i=o(t).then((function(){var e=a._addSchema(t,void 0,r);return e.validate||s(e)}));f&&i.then((function(e){f(null,e)}),f);return i;function o(t){var r=t.$schema;return r&&!a.getSchema(r)?e.call(a,{$ref:r},!0):Promise.resolve()}function s(e){try{return a._compile(e)}catch(t){if(t instanceof n)return function(t){var n=t.missingSchema;if(c(n))throw new Error("Schema "+n+" is loaded but "+t.missingRef+" cannot be resolved");var f=a._loadingSchemas[n];f||(f=a._loadingSchemas[n]=a._opts.loadSchema(n)).then(i,i);return f.then((function(e){if(!c(n))return o(e).then((function(){c(n)||a.addSchema(e,n,void 0,r)}))})).then((function(){return s(e)}));function i(){delete a._loadingSchemas[n]}function c(e){return a._refs[e]||a._schemas[e]}}(t);throw t}}}},function(e,t,r){"use strict";var n=/^[a-z_$][a-z0-9_$-]*$/i,f=r(827),a=r(828);e.exports={add:function(e,t){var r=this.RULES;if(r.keywords[e])throw new Error("Keyword "+e+" is already defined");if(!n.test(e))throw new Error("Keyword "+e+" is not a valid identifier");if(t){this.validateKeyword(t,!0);var a=t.type;if(Array.isArray(a))for(var i=0;i<a.length;i++)s(e,a[i],t);else s(e,a,t);var o=t.metaSchema;o&&(t.$data&&this._opts.$data&&(o={anyOf:[o,{$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"}]}),t.validateSchema=this.compile(o,!0))}function s(e,t,n){for(var a,i=0;i<r.length;i++){var o=r[i];if(o.type==t){a=o;break}}a||(a={type:t,rules:[]},r.push(a));var s={keyword:e,definition:n,custom:!0,code:f,implements:n.implements};a.rules.push(s),r.custom[e]=s}return r.keywords[e]=r.all[e]=!0,this},get:function(e){var t=this.RULES.custom[e];return t?t.definition:this.RULES.keywords[e]||!1},remove:function(e){var t=this.RULES;delete t.keywords[e],delete t.all[e],delete t.custom[e];for(var r=0;r<t.length;r++)for(var n=t[r].rules,f=0;f<n.length;f++)if(n[f].keyword==e){n.splice(f,1);break}return this},validate:function e(t,r){e.errors=null;var n=this._validateKeyword=this._validateKeyword||this.compile(a,!0);if(n(t))return!0;if(e.errors=n.errors,r)throw new Error("custom keyword definition is invalid: "+this.errorsText(n.errors));return!1}}},function(e,t,r){"use strict";e.exports=function(e,t,r){var n,f,a=" ",i=e.level,o=e.dataLevel,s=e.schema[t],c=e.schemaPath+e.util.getProperty(t),u=e.errSchemaPath+"/"+t,d=!e.opts.allErrors,l="data"+(o||""),p="valid"+i,h="errs__"+i,b=e.opts.$data&&s&&s.$data;b?(a+=" var schema"+i+" = "+e.util.getData(s.$data,o,e.dataPathArr)+"; ",f="schema"+i):f=s;var m,y,g,v,_,w=this,E="definition"+i,A=w.definition,T="";if(b&&A.$data){_="keywordValidate"+i;var x=A.validateSchema;a+=" var "+E+" = RULES.custom['"+t+"'].definition; var "+_+" = "+E+".validate;"}else{if(!(v=e.useCustomRule(w,s,e.schema,e)))return;f="validate.schema"+c,_=v.code,m=A.compile,y=A.inline,g=A.macro}var k=_+".errors",S="i"+i,O="ruleErr"+i,C=A.async;if(C&&!e.async)throw new Error("async keyword in sync schema");if(y||g||(a+=k+" = null;"),a+="var "+h+" = errors;var "+p+";",b&&A.$data&&(T+="}",a+=" if ("+f+" === undefined) { "+p+" = true; } else { ",x&&(T+="}",a+=" "+p+" = "+E+".validateSchema("+f+"); if ("+p+") { ")),y)A.statements?a+=" "+v.validate+" ":a+=" "+p+" = "+v.validate+"; ";else if(g){var P=e.util.copy(e);T="";P.level++;var R="valid"+P.level;P.schema=v.validate,P.schemaPath="";var N=e.compositeRule;e.compositeRule=P.compositeRule=!0;var I=e.validate(P).replace(/validate\.schema/g,_);e.compositeRule=P.compositeRule=N,a+=" "+I}else{(F=F||[]).push(a),a="",a+=" "+_+".call( ",e.opts.passContext?a+="this":a+="self",m||!1===A.schema?a+=" , "+l+" ":a+=" , "+f+" , "+l+" , validate.schema"+e.schemaPath+" ",a+=" , (dataPath || '')",'""'!=e.errorPath&&(a+=" + "+e.errorPath);var M=o?"data"+(o-1||""):"parentData",D=o?e.dataPathArr[o]:"parentDataProperty",B=a+=" , "+M+" , "+D+" , rootData ) ";a=F.pop(),!1===A.errors?(a+=" "+p+" = ",C&&(a+="await "),a+=B+"; "):a+=C?" var "+(k="customErrors"+i)+" = null; try { "+p+" = await "+B+"; } catch (e) { "+p+" = false; if (e instanceof ValidationError) "+k+" = e.errors; else throw e; } ":" "+k+" = null; "+p+" = "+B+"; "}if(A.modifying&&(a+=" if ("+M+") "+l+" = "+M+"["+D+"];"),a+=""+T,A.valid)d&&(a+=" if (true) { ");else{var F;a+=" if ( ",void 0===A.valid?(a+=" !",a+=g?""+R:""+p):a+=" "+!A.valid+" ",a+=") { ",n=w.keyword,(F=F||[]).push(a),a="",(F=F||[]).push(a),a="",!1!==e.createErrors?(a+=" { keyword: '"+(n||"custom")+"' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(u)+" , params: { keyword: '"+w.keyword+"' } ",!1!==e.opts.messages&&(a+=" , message: 'should pass \""+w.keyword+"\" keyword validation' "),e.opts.verbose&&(a+=" , schema: validate.schema"+c+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+l+" "),a+=" } "):a+=" {} ";var j=a;a=F.pop(),!e.compositeRule&&d?e.async?a+=" throw new ValidationError(["+j+"]); ":a+=" validate.errors = ["+j+"]; return false; ":a+=" var err = "+j+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ";var L=a;a=F.pop(),y?A.errors?"full"!=A.errors&&(a+=" for (var "+S+"="+h+"; "+S+"<errors; "+S+"++) { var "+O+" = vErrors["+S+"]; if ("+O+".dataPath === undefined) "+O+".dataPath = (dataPath || '') + "+e.errorPath+"; if ("+O+".schemaPath === undefined) { "+O+'.schemaPath = "'+u+'"; } ',e.opts.verbose&&(a+=" "+O+".schema = "+f+"; "+O+".data = "+l+"; "),a+=" } "):!1===A.errors?a+=" "+L+" ":(a+=" if ("+h+" == errors) { "+L+" } else { for (var "+S+"="+h+"; "+S+"<errors; "+S+"++) { var "+O+" = vErrors["+S+"]; if ("+O+".dataPath === undefined) "+O+".dataPath = (dataPath || '') + "+e.errorPath+"; if ("+O+".schemaPath === undefined) { "+O+'.schemaPath = "'+u+'"; } ',e.opts.verbose&&(a+=" "+O+".schema = "+f+"; "+O+".data = "+l+"; "),a+=" } } "):g?(a+=" var err = ",!1!==e.createErrors?(a+=" { keyword: '"+(n||"custom")+"' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(u)+" , params: { keyword: '"+w.keyword+"' } ",!1!==e.opts.messages&&(a+=" , message: 'should pass \""+w.keyword+"\" keyword validation' "),e.opts.verbose&&(a+=" , schema: validate.schema"+c+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+l+" "),a+=" } "):a+=" {} ",a+="; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",!e.compositeRule&&d&&(e.async?a+=" throw new ValidationError(vErrors); ":a+=" validate.errors = vErrors; return false; ")):!1===A.errors?a+=" "+L+" ":(a+=" if (Array.isArray("+k+")) { if (vErrors === null) vErrors = "+k+"; else vErrors = vErrors.concat("+k+"); errors = vErrors.length; for (var "+S+"="+h+"; "+S+"<errors; "+S+"++) { var "+O+" = vErrors["+S+"]; if ("+O+".dataPath === undefined) "+O+".dataPath = (dataPath || '') + "+e.errorPath+"; "+O+'.schemaPath = "'+u+'"; ',e.opts.verbose&&(a+=" "+O+".schema = "+f+"; "+O+".data = "+l+"; "),a+=" } } else { "+L+" } "),a+=" } ",d&&(a+=" else { ")}return a}},function(e,t,r){"use strict";var n=r(324);e.exports={$id:"https://github.com/ajv-validator/ajv/blob/master/lib/definition_schema.js",definitions:{simpleTypes:n.definitions.simpleTypes},type:"object",dependencies:{schema:["validate"],$data:["validate"],statements:["inline"],valid:{not:{required:["macro"]}}},properties:{type:n.properties.type,schema:{type:"boolean"},statements:{type:"boolean"},dependencies:{type:"array",items:{type:"string"}},metaSchema:{type:"object"},modifying:{type:"boolean"},valid:{type:"boolean"},$data:{type:"boolean"},async:{type:"boolean"},errors:{anyOf:[{type:"boolean"},{const:"full"}]}}}},function(e){e.exports=JSON.parse('{"$schema":"http://json-schema.org/draft-07/schema#","$id":"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#","description":"Meta-schema for $data reference (JSON Schema extension proposal)","type":"object","required":["$data"],"properties":{"$data":{"type":"string","anyOf":[{"format":"relative-json-pointer"},{"format":"json-pointer"}]}},"additionalProperties":false}')},function(e){e.exports=JSON.parse('{"$schema":"http://json-schema.org/draft-06/schema#","$id":"http://json-schema.org/draft-06/schema#","title":"Core schema meta-schema","definitions":{"schemaArray":{"type":"array","minItems":1,"items":{"$ref":"#"}},"nonNegativeInteger":{"type":"integer","minimum":0},"nonNegativeIntegerDefault0":{"allOf":[{"$ref":"#/definitions/nonNegativeInteger"},{"default":0}]},"simpleTypes":{"enum":["array","boolean","integer","null","number","object","string"]},"stringArray":{"type":"array","items":{"type":"string"},"uniqueItems":true,"default":[]}},"type":["object","boolean"],"properties":{"$id":{"type":"string","format":"uri-reference"},"$schema":{"type":"string","format":"uri"},"$ref":{"type":"string","format":"uri-reference"},"title":{"type":"string"},"description":{"type":"string"},"default":{},"examples":{"type":"array","items":{}},"multipleOf":{"type":"number","exclusiveMinimum":0},"maximum":{"type":"number"},"exclusiveMaximum":{"type":"number"},"minimum":{"type":"number"},"exclusiveMinimum":{"type":"number"},"maxLength":{"$ref":"#/definitions/nonNegativeInteger"},"minLength":{"$ref":"#/definitions/nonNegativeIntegerDefault0"},"pattern":{"type":"string","format":"regex"},"additionalItems":{"$ref":"#"},"items":{"anyOf":[{"$ref":"#"},{"$ref":"#/definitions/schemaArray"}],"default":{}},"maxItems":{"$ref":"#/definitions/nonNegativeInteger"},"minItems":{"$ref":"#/definitions/nonNegativeIntegerDefault0"},"uniqueItems":{"type":"boolean","default":false},"contains":{"$ref":"#"},"maxProperties":{"$ref":"#/definitions/nonNegativeInteger"},"minProperties":{"$ref":"#/definitions/nonNegativeIntegerDefault0"},"required":{"$ref":"#/definitions/stringArray"},"additionalProperties":{"$ref":"#"},"definitions":{"type":"object","additionalProperties":{"$ref":"#"},"default":{}},"properties":{"type":"object","additionalProperties":{"$ref":"#"},"default":{}},"patternProperties":{"type":"object","additionalProperties":{"$ref":"#"},"default":{}},"dependencies":{"type":"object","additionalProperties":{"anyOf":[{"$ref":"#"},{"$ref":"#/definitions/stringArray"}]}},"propertyNames":{"$ref":"#"},"const":{},"enum":{"type":"array","minItems":1,"uniqueItems":true},"type":{"anyOf":[{"$ref":"#/definitions/simpleTypes"},{"type":"array","items":{"$ref":"#/definitions/simpleTypes"},"minItems":1,"uniqueItems":true}]},"format":{"type":"string"},"allOf":{"$ref":"#/definitions/schemaArray"},"anyOf":{"$ref":"#/definitions/schemaArray"},"oneOf":{"$ref":"#/definitions/schemaArray"},"not":{"$ref":"#"}},"default":{}}')},function(e){e.exports=JSON.parse('{"$id":"http://json-schema.org/address","$schema":"http://json-schema.org/draft-06/schema#","description":"An Address following the convention of http://microformats.org/wiki/hcard","type":"object","properties":{"post-office-box":{"type":"string"},"extended-address":{"type":"string"},"street-address":{"type":"string"},"locality":{"type":"string"},"region":{"type":"string"},"postal-code":{"type":"string"},"country-name":{"type":"string"}},"dependencies":{"post-office-box":["street-address"],"extended-address":["street-address"]}}')},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n={rnf_invoice:{"0.0.1":r(833),"0.0.2":r(834),"0.0.3":r(835)}};t.default=n},function(e){e.exports=JSON.parse('{"$schema":"http://json-schema.org/draft-07/schema#","description":"Request Network Format of an invoice","type":"object","additionalProperties":false,"required":["meta","invoiceNumber","creationDate","invoiceItems"],"properties":{"meta":{"description":"Meta information about the format","type":"object","additionalProperties":false,"required":["format","version"],"properties":{"format":{"const":"rnf_invoice"},"version":{"const":"0.0.1"}}},"creationDate":{"type":"string","format":"date-time"},"invoiceNumber":{"type":"string"},"purchaseOrderId":{"type":"string"},"note":{"type":"string"},"terms":{"type":"string"},"sellerInfo":{"description":"Seller information","type":"object","additionalProperties":false,"properties":{"email":{"type":"string","format":"email"},"firstName":{"type":"string"},"lastName":{"type":"string"},"businessName":{"type":"string"},"phone":{"type":"string"},"address":{"$ref":"http://json-schema.org/address"},"taxRegistration":{"type":"string"},"companyRegistration":{"type":"string"},"miscellaneous":{"type":"object"}}},"buyerInfo":{"description":"Buyer information","type":"object","additionalProperties":false,"properties":{"email":{"type":"string","format":"email"},"firstName":{"type":"string"},"lastName":{"type":"string"},"businessName":{"type":"string"},"phone":{"type":"string"},"address":{"$ref":"http://json-schema.org/address"},"taxRegistration":{"type":"string"},"miscellaneous":{"type":"object"}}},"invoiceItems":{"type":"array","items":{"type":"object","additionalProperties":false,"required":["name","quantity","unitPrice","taxPercent","currency"],"properties":{"name":{"type":"string"},"reference":{"type":"string"},"quantity":{"type":"number","minimum":0},"unitPrice":{"type":"number","minimum":0},"discount":{"type":"number"},"taxPercent":{"type":"number"},"currency":{"type":"string","minLength":2},"deliveryDate":{"type":"string","format":"date-time"},"deliveryPeriod":{"type":"string"}}}},"paymentTerms":{"description":"Payment terms","type":"object","additionalProperties":false,"properties":{"dueDate":{"type":"string","format":"date-time"},"lateFeesPercent":{"type":"number"},"lateFeesFix":{"type":"number"},"miscellaneous":{"type":"object"}}},"miscellaneous":{"type":"object"}}}')},function(e){e.exports=JSON.parse('{"$schema":"http://json-schema.org/draft-07/schema#","description":"Request Network Format of an invoice","type":"object","additionalProperties":false,"required":["meta","invoiceNumber","creationDate","invoiceItems"],"properties":{"meta":{"description":"Meta information about the format","type":"object","additionalProperties":false,"required":["format","version"],"properties":{"format":{"const":"rnf_invoice"},"version":{"const":"0.0.2"}}},"creationDate":{"type":"string","format":"date-time"},"invoiceNumber":{"type":"string"},"purchaseOrderId":{"type":"string"},"note":{"type":"string"},"terms":{"type":"string"},"sellerInfo":{"description":"Seller information","type":"object","additionalProperties":false,"properties":{"email":{"type":"string","format":"email"},"firstName":{"type":"string"},"lastName":{"type":"string"},"businessName":{"type":"string"},"phone":{"type":"string"},"address":{"$ref":"http://json-schema.org/address"},"taxRegistration":{"type":"string"},"companyRegistration":{"type":"string"},"miscellaneous":{"type":"object"}}},"buyerInfo":{"description":"Buyer information","type":"object","additionalProperties":false,"properties":{"email":{"type":"string","format":"email"},"firstName":{"type":"string"},"lastName":{"type":"string"},"businessName":{"type":"string"},"phone":{"type":"string"},"address":{"$ref":"http://json-schema.org/address"},"taxRegistration":{"type":"string"},"companyRegistration":{"type":"string"},"miscellaneous":{"type":"object"}}},"invoiceItems":{"type":"array","items":{"type":"object","additionalProperties":false,"required":["name","quantity","unitPrice","taxPercent","currency"],"properties":{"name":{"type":"string"},"reference":{"type":"string"},"quantity":{"type":"number","minimum":0},"unitPrice":{"type":"string","pattern":"^\\\\d+$"},"discount":{"type":"string","pattern":"^\\\\d+$"},"taxPercent":{"type":"number"},"currency":{"type":"string","minLength":2},"deliveryDate":{"type":"string","format":"date-time"},"deliveryPeriod":{"type":"string"}}}},"paymentTerms":{"description":"Payment terms","type":"object","additionalProperties":false,"properties":{"dueDate":{"type":"string","format":"date-time"},"lateFeesPercent":{"type":"number"},"lateFeesFix":{"type":"string","pattern":"^\\\\d+$"},"miscellaneous":{"type":"object"}}},"miscellaneous":{"type":"object"}}}')},function(e){e.exports=JSON.parse('{"$schema":"http://json-schema.org/draft-07/schema#","description":"Request Network Format of an invoice","type":"object","additionalProperties":false,"required":["meta","invoiceNumber","creationDate","invoiceItems"],"properties":{"meta":{"description":"Meta information about the format","type":"object","additionalProperties":false,"required":["format","version"],"properties":{"format":{"const":"rnf_invoice"},"version":{"const":"0.0.3"}}},"creationDate":{"type":"string","format":"date-time"},"invoiceNumber":{"type":"string"},"purchaseOrderId":{"type":"string"},"note":{"type":"string"},"terms":{"type":"string"},"sellerInfo":{"description":"Seller information","type":"object","additionalProperties":false,"properties":{"email":{"type":"string","format":"email"},"firstName":{"type":"string"},"lastName":{"type":"string"},"businessName":{"type":"string"},"phone":{"type":"string"},"address":{"$ref":"http://json-schema.org/address"},"taxRegistration":{"type":"string"},"companyRegistration":{"type":"string"},"miscellaneous":{"type":"object"}}},"buyerInfo":{"description":"Buyer information","type":"object","additionalProperties":false,"properties":{"email":{"type":"string","format":"email"},"firstName":{"type":"string"},"lastName":{"type":"string"},"businessName":{"type":"string"},"phone":{"type":"string"},"address":{"$ref":"http://json-schema.org/address"},"taxRegistration":{"type":"string"},"companyRegistration":{"type":"string"},"miscellaneous":{"type":"object"}}},"invoiceItems":{"type":"array","items":{"type":"object","additionalProperties":false,"required":["name","quantity","unitPrice","tax","currency"],"properties":{"name":{"type":"string"},"reference":{"type":"string"},"quantity":{"type":"number","minimum":0},"unitPrice":{"type":"string","pattern":"^\\\\d+$"},"discount":{"type":"string","pattern":"^\\\\d+$"},"tax":{"description":"Tax information about the invoice","type":"object","additionalProperties":false,"required":["amount","type"],"properties":{"amount":{"type":"string"},"type":{"type":"string","enum":["percentage","fixed"]}},"if":{"properties":{"type":{"const":"percentage"}}},"then":{"properties":{"amount":{"pattern":"^\\\\d*\\\\.?\\\\d+$"}}},"else":{"properties":{"amount":{"pattern":"^\\\\d+$"}}}},"currency":{"type":"string","minLength":2},"deliveryDate":{"type":"string","format":"date-time"},"deliveryPeriod":{"type":"string"}}}},"paymentTerms":{"description":"Payment terms","type":"object","additionalProperties":false,"properties":{"dueDate":{"type":"string","format":"date-time"},"lateFeesPercent":{"type":"number"},"lateFeesFix":{"type":"string","pattern":"^\\\\d+$"},"miscellaneous":{"type":"object"}}},"miscellaneous":{"type":"object"}}}')},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});r(316).__exportStar(r(837),t)},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getInvoiceTaxTotal=t.getInvoiceLineTotalWithoutTax=t.getInvoiceTotalWithoutTax=t.getInvoiceLineTotal=t.getInvoiceTotal=void 0;const n=r(3);t.getInvoiceTotal=e=>e.invoiceItems.reduce(((e,r)=>e.add((0,t.getInvoiceLineTotal)(r))),n.BigNumber.from(0));t.getInvoiceLineTotal=e=>{const t=e.taxPercent?{type:"percentage",amount:String(e.taxPercent)}:e.tax||{type:"percentage",amount:"0"},r=t.amount&&"percentage"===t.type?Number(t.amount)+100:100,f=t.amount&&"fixed"===t.type?n.BigNumber.from(t.amount):n.BigNumber.from(0),a=e.discount?n.BigNumber.from(e.discount):n.BigNumber.from(0);return n.BigNumber.from(n.FixedNumber.from(e.unitPrice).mulUnsafe(n.FixedNumber.fromString(e.quantity.toString())).subUnsafe(n.FixedNumber.from(a)).mulUnsafe(n.FixedNumber.fromString(r.toString())).divUnsafe(n.FixedNumber.from(100)).addUnsafe(n.FixedNumber.from(f)).round(0).toString().split(".")[0])};t.getInvoiceTotalWithoutTax=e=>e.invoiceItems.reduce(((e,r)=>e.add((0,t.getInvoiceLineTotalWithoutTax)(r))),n.BigNumber.from(0));t.getInvoiceLineTotalWithoutTax=e=>{const t=e.discount?n.BigNumber.from(e.discount):n.BigNumber.from(0);return n.BigNumber.from(n.FixedNumber.from(e.unitPrice).mulUnsafe(n.FixedNumber.fromString(e.quantity.toString())).subUnsafe(n.FixedNumber.from(t)).round(0).toString().split(".")[0])};t.getInvoiceTaxTotal=e=>{const r=e.invoiceItems.reduce(((e,r)=>e.add((0,t.getInvoiceLineTotalWithoutTax)(r))),n.BigNumber.from(0));return e.invoiceItems.reduce(((e,r)=>e.add((0,t.getInvoiceLineTotal)(r))),n.BigNumber.from(0)).sub(r)}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.default={requestClientVersionHeader:"X-Request-Network-Client-Version",httpRequestMaxRetry:3,httpRequestRetryDelay:100,httpRequestExponentialBackoffDelay:0,httpRequestMaxExponentialBackoffDelay:3e4,getConfirmationMaxRetry:500,getConfirmationRetryDelay:3e3,getConfirmationExponentialBackoffDelay:0,getConfirmationMaxExponentialBackoffDelay:3e4,getConfirmationDeferDelay:3e3}},function(e){e.exports=JSON.parse('{"name":"@requestnetwork/request-client.js","version":"0.40.1-next.1916+76216892","publishConfig":{"access":"public"},"description":"Client side library for Request Network.","keywords":["requestnetwork","request-client.js"],"repository":{"type":"git","url":"git+https://github.com/RequestNetwork/requestNetwork.git"},"homepage":"https://github.com/RequestNetwork/requestNetwork/tree/master/packages/request-client.js#readme","bugs":{"url":"https://github.com/RequestNetwork/requestNetwork/issues"},"license":"MIT","engines":{"node":">=16.0.0"},"main":"dist/index.js","types":"dist/index.d.ts","directories":{"lib":"src","test":"test"},"files":["dist"],"scripts":{"build":"run-s build:commonjs build:umd","build:commonjs":"tsc -b tsconfig.build.json","build:umd":"webpack","clean":"shx rm -rf dist tsconfig.tsbuildinfo tsconfig.build.tsbuildinfo","docs":"shx rm -rf ./docs && compodoc -p tsconfig.json --output docs --disablePrivate --gaID UA-105153327-8","lint":"eslint . --fix","lint:check":"eslint .","prepare":"yarn run build","test":"jest","test:watch":"yarn test --watch"},"dependencies":{"@requestnetwork/advanced-logic":"0.35.1-next.1916+76216892","@requestnetwork/currency":"0.9.1-next.1916+76216892","@requestnetwork/data-access":"0.27.1-next.1916+76216892","@requestnetwork/data-format":"0.10.1-next.1916+76216892","@requestnetwork/epk-signature":"0.5.36-next.1916+76216892","@requestnetwork/multi-format":"0.15.11-next.1916+76216892","@requestnetwork/payment-detection":"0.36.1-next.1916+76216892","@requestnetwork/request-logic":"0.26.11-next.1916+76216892","@requestnetwork/smart-contracts":"0.29.1-next.1916+76216892","@requestnetwork/transaction-manager":"0.27.1-next.1916+76216892","@requestnetwork/types":"0.36.1-next.1916+76216892","@requestnetwork/utils":"0.36.1-next.1916+76216892","axios":"0.27.2","ethers":"5.5.1","tslib":"2.5.0"},"devDependencies":{"@compodoc/compodoc":"1.1.11","@types/jest":"26.0.13","amd-loader":"0.0.8","axios-mock-adapter":"1.19.0","duplicate-package-checker-webpack-plugin":"3.0.0","jest":"26.4.2","npm-run-all":"4.1.5","nyc":"15.1.0","shx":"0.3.2","source-map-support":"0.5.19","terser-webpack-plugin":"4.2.3","ts-jest":"26.3.0","ts-loader":"8.4.0","ts-node":"10.9.1","typescript":"4.9.5","webpack":"4.44.2","webpack-bundle-analyzer":"4.2.0","webpack-cli":"3.3.12"},"gitHead":"7621689212c0fde4df76a60e8c70de05eab9cd34"}')},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(326);class f extends n.DataAccess{constructor(e){super(e),this.isInitialized=!0}}t.default=f},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(61),f=r(52),a=r(4),i=r(8),o=r(327),s=r(32),c=r(328),u=r(842),d=r(845),l=r(329),p={meta:{storageMeta:{},transactionsStorageLocation:{}},result:{transactions:{}}};t.default=class{constructor(e,t){this.isInitialized=!1;const r={ignoredLocationIndex:new u.default,logger:new i.SimpleLogger,synchronizationIntervalTime:1e4,transactionIndex:new l.default,autoStartSynchronization:!1},{ignoredLocationIndex:n,logger:f,synchronizationIntervalTime:a,transactionIndex:o,autoStartSynchronization:s}=Object.assign(Object.assign({},r),t);this.storage=e,this.lastSyncStorageTimestamp=0,this.autoStartSynchronization=s,this.synchronizationTimer=new d.default((()=>this.synchronizeNewDataIds()),a,f,5),this.transactionIndex=o,this.ignoredLocationIndex=n,this.logger=f}initialize(){return n.__awaiter(this,void 0,void 0,(function*(){if(this.isInitialized)throw new Error("already initialized");yield this.transactionIndex.initialize(),yield this.storage.initialize();const e=yield this.transactionIndex.getLastTransactionTimestamp(),t=(0,i.getCurrentTimestampInSecond)(),r=yield this.storage.getData(e?{from:e,to:t}:void 0);this.lastSyncStorageTimestamp=r.lastTimestamp,yield this.pushLocationsWithTopics(r.entries),this.isInitialized=!0,this.autoStartSynchronization&&this.startAutoSynchronization()}))}close(){return n.__awaiter(this,void 0,void 0,(function*(){yield this.stopAutoSynchronization()}))}persistTransaction(e,t,r=[]){return n.__awaiter(this,void 0,void 0,(function*(){this.checkInitialized();const a=r.filter((e=>!f.default.hashFormat.isDeserializableString(e)));if(0!==a.length)throw new Error(`The following topics are not well formatted: ${JSON.stringify(a)}`);const i=c.default.pushTransaction(c.default.createEmptyBlock(),e,t,r),o=yield this.storage.append(JSON.stringify(i)),u=Object.assign(new s.EventEmitter,{meta:{storageMeta:o.meta,topics:r,transactionStorageLocation:o.id},result:{}});return o.on("confirmed",(e=>n.__awaiter(this,void 0,void 0,(function*(){yield this.transactionIndex.updateTimestamp(e.id,e.meta.timestamp);const t={meta:{storageMeta:e.meta,topics:r,transactionStorageLocation:e.id},result:{}};u.emit("confirmed",t)})))).on("error",(e=>n.__awaiter(this,void 0,void 0,(function*(){u.emit("error",e)})))),yield this.transactionIndex.addTransaction(o.id,i.header,o.meta.timestamp),u}))}getTransactionsByChannelId(e,t){return n.__awaiter(this,void 0,void 0,(function*(){this.checkInitialized();const r=yield this.transactionIndex.getStorageLocationList(e,t);return(yield this.getBlockAndMetaFromStorageLocation(r)).map((t=>{const r=c.default.getTransactionPositionFromChannelId(t.block,e);return this.getTransactionAndMetaFromPosition(r,t.block,t.location,t.meta)})).reduce(((e,t)=>({meta:{storageMeta:e.meta.storageMeta.concat(t.storageMeta),transactionsStorageLocation:e.meta.transactionsStorageLocation.concat(t.transactionsStorageLocation)},result:{transactions:e.result.transactions.concat(t.transactions)}})),{meta:{storageMeta:[],transactionsStorageLocation:[]},result:{transactions:[]}})}))}getChannelsByTopic(e,t){return n.__awaiter(this,void 0,void 0,(function*(){if(this.checkInitialized(),!f.default.hashFormat.isDeserializableString(e))throw new Error(`The topic is not well formatted: ${e}`);const r=yield this.transactionIndex.getChannelIdsForTopic(e,t);return o.map(r,(e=>this.getTransactionsByChannelId(e).then((t=>({channelId:e,transactionsWithMeta:t}))))).reduce(((e,t)=>{const r=t.channelId;return e.meta.transactionsStorageLocation[r]=t.transactionsWithMeta.meta.transactionsStorageLocation,e.meta.storageMeta[r]=t.transactionsWithMeta.meta.storageMeta,e.result.transactions[r]=t.transactionsWithMeta.result.transactions,e}),(0,i.deepCopy)(p))}))}getChannelsByMultipleTopics(e,t){return n.__awaiter(this,void 0,void 0,(function*(){if(this.checkInitialized(),e.some((e=>!f.default.hashFormat.isDeserializableString(e))))throw new Error("The topics are not well formatted");const r=yield this.transactionIndex.getChannelIdsForMultipleTopics(e,t);return o.map(r,(e=>this.getTransactionsByChannelId(e).then((t=>({channelId:e,transactionsWithMeta:t}))))).reduce(((e,t)=>{const r=t.channelId;return e.meta.transactionsStorageLocation[r]=t.transactionsWithMeta.meta.transactionsStorageLocation,e.meta.storageMeta[r]=t.transactionsWithMeta.meta.storageMeta,e.result.transactions[r]=t.transactionsWithMeta.result.transactions,e}),(0,i.deepCopy)(p))}))}synchronizeNewDataIds(){return n.__awaiter(this,void 0,void 0,(function*(){this.checkInitialized();const e=(0,i.getCurrentTimestampInSecond)();let t=0;this.lastSyncStorageTimestamp>0&&(t=this.lastSyncStorageTimestamp+1);const r=yield this.storage.getData({from:t,to:e}),n=yield this.storage.getIgnoredData();yield this.pushLocationsWithTopics(r.entries.concat(n)),this.lastSyncStorageTimestamp=r.lastTimestamp}))}startAutoSynchronization(){this.checkInitialized(),this.synchronizationTimer.start()}stopAutoSynchronization(){return n.__awaiter(this,void 0,void 0,(function*(){this.synchronizationTimer.isStarted&&(yield this.synchronizationTimer.stop())}))}_getStatus(e=!1){return n.__awaiter(this,void 0,void 0,(function*(){this.checkInitialized();const t=yield this.transactionIndex.getLastTransactionTimestamp(),r=yield this.transactionIndex.getIndexedLocations(),n=yield this.ignoredLocationIndex.getIgnoredLocations(),f=this.synchronizationTimer.getConfig();return{filesIgnored:{count:Object.keys(n).length,list:e?n:void 0},filesRetrieved:{count:r.length,lastTimestamp:t,list:e?r:void 0},lastSynchronizationTimestamp:this.lastSyncStorageTimestamp,storage:yield this.storage._getStatus(e),synchronizationConfig:f}}))}pushLocationsWithTopics(e){return n.__awaiter(this,void 0,void 0,(function*(){if(!e)throw Error("data from storage do not follow the standard");let t=0,r=0;yield o.each(e,(e=>n.__awaiter(this,void 0,void 0,(function*(){if(!e.content||!e.id)throw Error("data from storage do not follow the standard");let n;const f=e.content;try{n=c.default.parseBlock(f),r++,yield this.transactionIndex.addTransaction(e.id,n.header,e.meta.timestamp)}catch(r){t++,yield this.ignoredLocationIndex.pushReasonByLocation(e.id,r.message),this.logger.debug(`Error: can't parse content of the dataId (${e.id}): ${r}`,["synchronization"])}})))),this.logger.info(`Synchronization: ${r} blocks synchronized, ${t} ignored from parsing error`,["synchronization"])}))}getBlockAndMetaFromStorageLocation(e){return n.__awaiter(this,void 0,void 0,(function*(){return Promise.all(e.map((e=>n.__awaiter(this,void 0,void 0,(function*(){const t=yield this.storage.read(e);return{block:c.default.parseBlock(t.content),location:e,meta:t.meta}})))))}))}getTransactionAndMetaFromPosition(e,t,r,n){const f=(0,i.unique)(e).uniqueItems.map((e=>({state:n.state===a.StorageTypes.ContentState.CONFIRMED?a.DataAccessTypes.TransactionState.CONFIRMED:a.DataAccessTypes.TransactionState.PENDING,timestamp:n.timestamp,transaction:t.transactions[e]}))),o=Array(f.length).fill(r),s=f.map((()=>n));return{transactions:f,transactionsStorageLocation:o,storageMeta:s}}checkInitialized(){if(!this.isInitialized)throw new Error("DataAccess must be initialized")}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(61),f=r(122);t.default=class{constructor(e){this.reasonsByIgnoredLocation=new f({namespace:"reasonsByIgnoredLocation",store:e}),this.listIgnoredLocation=new f({namespace:"listIgnoredLocation",store:e})}pushReasonByLocation(e,t){return n.__awaiter(this,void 0,void 0,(function*(){(yield this.reasonsByIgnoredLocation.get(e))||(yield this.reasonsByIgnoredLocation.set(e,t),yield this.updateDataId(e))}))}removeReasonByLocation(e){return n.__awaiter(this,void 0,void 0,(function*(){yield this.reasonsByIgnoredLocation.delete(e)}))}getReasonFromLocation(e){return n.__awaiter(this,void 0,void 0,(function*(){const t=yield this.reasonsByIgnoredLocation.get(e);return t||null}))}getIgnoredLocations(){return n.__awaiter(this,void 0,void 0,(function*(){const e=yield this.listIgnoredLocation.get("list");if(!e)return{};const t={};for(const r of Array.from(e))t[r]=yield this.reasonsByIgnoredLocation.get(r);return t}))}updateDataId(e){return n.__awaiter(this,void 0,void 0,(function*(){let t=yield this.listIgnoredLocation.get("list");t||(t=[]),t.push(e),yield this.listIgnoredLocation.set("list",t)}))}}},function(e,t,r){(function(e){t.stringify=function t(r){if(void 0===r)return r;if(r&&e.isBuffer(r))return JSON.stringify(":base64:"+r.toString("base64"));if(r&&r.toJSON&&(r=r.toJSON()),r&&"object"==typeof r){var n="",f=Array.isArray(r);n=f?"[":"{";var a=!0;for(var i in r){var o="function"==typeof r[i]||!f&&void 0===r[i];Object.hasOwnProperty.call(r,i)&&!o&&(a||(n+=","),a=!1,f?null==r[i]?n+="null":n+=t(r[i]):void 0!==r[i]&&(n+=t(i)+":"+t(r[i])))}return n+=f?"]":"}"}return"string"==typeof r?JSON.stringify(/^:/.test(r)?":"+r:r):void 0===r?"null":JSON.stringify(r)},t.parse=function(t){return JSON.parse(t,(function(t,r){return"string"==typeof r?/^:base64:/.test(r)?e.from(r.substring(8),"base64"):/^:/.test(r)?r.substring(1):r:r}))}}).call(this,r(7).Buffer)},function(e,t){function r(e){var t=new Error("Cannot find module '"+e+"'");throw t.code="MODULE_NOT_FOUND",t}r.keys=function(){return[]},r.resolve=r,e.exports=r,r.id=844},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(61);t.default=class{constructor(e,t,r,n=1){this.intervalFunctionSuccessiveFailureCount=0,this.timeoutObject=null,this.lastRecursion=Promise.resolve(),this.intervalFunction=e,this.intervalTime=t,this.logger=r,this.successiveFailureThreshold=n}start(){if(this.timeoutObject)throw Error("IntervalTimer already started");const e=()=>n.__awaiter(this,void 0,void 0,(function*(){try{yield this.intervalFunction(),this.intervalFunctionSuccessiveFailureCount=0}catch(e){this.logger.warn(`${this.intervalFunction.name||"intervalFunction"} error: ${e}`),this.intervalFunctionSuccessiveFailureCount++,this.intervalFunctionSuccessiveFailureCount>=this.successiveFailureThreshold&&this.logger.error(`${this.intervalFunction.name||"intervalFunction"} failed ${this.intervalFunctionSuccessiveFailureCount} times in a row, last error: ${e}`)}t()})),t=()=>{this.timeoutObject=setTimeout((()=>{this.lastRecursion=e()}),this.intervalTime)};t()}stop(){return n.__awaiter(this,void 0,void 0,(function*(){return this.timeoutObject?(clearTimeout(this.timeoutObject),this.timeoutObject=null,this.lastRecursion):Promise.reject("Can't stop IntervalTimer if it has not been started")}))}get isStarted(){return Boolean(this.timeoutObject)}getConfig(){return{intervalTime:this.intervalTime,successiveFailureThreshold:this.successiveFailureThreshold}}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(61),f=r(327),a=r(122),i=r(330),o=r(331);t.default=class{constructor(e){this.timestampByLocation=new o.default(e),this.locationByTopic=new i.default(e),this.indexedLocation=new a({namespace:"indexedLocation",store:e})}initialize(){return n.__awaiter(this,void 0,void 0,(function*(){}))}getLastTransactionTimestamp(){return this.timestampByLocation.getLastTransactionTimestamp()}addTransaction(e,t,r){return n.__awaiter(this,void 0,void 0,(function*(){if(!this.locationByTopic)throw new Error("TransactionIndex must be initialized");yield this.locationByTopic.pushStorageLocationIndexedWithBlockTopics(e,t),yield this.timestampByLocation.pushTimestampByLocation(e,r),yield this.updateIndexedLocation(e)}))}removeTransaction(e){return n.__awaiter(this,void 0,void 0,(function*(){if(!this.locationByTopic)throw new Error("TransactionIndex must be initialized");yield this.timestampByLocation.removeIndexedDataId(e)}))}updateTimestamp(e,t){return n.__awaiter(this,void 0,void 0,(function*(){if(!this.timestampByLocation)throw new Error("TransactionIndex must be initialized");yield this.timestampByLocation.updateTimestampByLocation(e,t)}))}getStorageLocationList(e,t){return n.__awaiter(this,void 0,void 0,(function*(){if(!this.locationByTopic)throw new Error("TransactionIndex must be initialized");let r=yield this.locationByTopic.getStorageLocationsFromChannelId(e);return r=yield f.filter(r,(e=>n.__awaiter(this,void 0,void 0,(function*(){const r=null!==(yield this.timestampByLocation.getTimestampFromLocation(e)),n=!t||(yield this.timestampByLocation.isDataInBoundaries(e,t));return r&&n})))),r}))}getChannelIdsForTopic(e,t){return n.__awaiter(this,void 0,void 0,(function*(){if(!this.locationByTopic)throw new Error("TransactionIndex must be initialized");const r=yield this.locationByTopic.getChannelIdsFromTopic(e);if(t){const e=[];for(const n of r){const r=yield this.locationByTopic.getStorageLocationsFromChannelId(n);for(const f of r){if(yield this.timestampByLocation.isDataInBoundaries(f,t)){e.push(n);break}}}return e}return r}))}getChannelIdsForMultipleTopics(e,t){return n.__awaiter(this,void 0,void 0,(function*(){if(!this.locationByTopic)throw new Error("TransactionIndex must be initialized");const r=yield this.locationByTopic.getChannelIdsFromMultipleTopics(e);if(t){const e=[];for(const n of r){const r=yield this.locationByTopic.getStorageLocationsFromChannelId(n);for(const f of r){if(yield this.timestampByLocation.isDataInBoundaries(f,t)){e.push(n);break}}}return e}return r}))}getIndexedLocations(){return n.__awaiter(this,void 0,void 0,(function*(){return(yield this.indexedLocation.get("list"))||[]}))}updateIndexedLocation(e){return n.__awaiter(this,void 0,void 0,(function*(){let t=yield this.indexedLocation.get("list");t||(t=[]),t.includes(e)||(t.push(e),yield this.indexedLocation.set("list",t))}))}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CombinedDataAccess=void 0;const n=r(61);t.CombinedDataAccess=class{constructor(e,t){this.reader=e,this.writer=t,this.getTransactionsByChannelId=this.reader.getTransactionsByChannelId.bind(this.reader),this.getChannelsByTopic=this.reader.getChannelsByTopic.bind(this.reader),this.getChannelsByMultipleTopics=this.reader.getChannelsByMultipleTopics.bind(this.reader),this.persistTransaction=this.writer.persistTransaction.bind(this.writer)}initialize(){return n.__awaiter(this,void 0,void 0,(function*(){yield this.reader.initialize(),yield this.writer.initialize()}))}close(){return n.__awaiter(this,void 0,void 0,(function*(){yield this.writer.close(),yield this.reader.close()}))}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(80),f=r(52),a=r(4),i=r(32),o=r(8);t.default=class{constructor(){this.data=new Map,this.forceEmitError=!1}initialize(){return n.__awaiter(this,void 0,void 0,(function*(){}))}ipfsAdd(e){return n.__awaiter(this,void 0,void 0,(function*(){if(!e)throw Error("Error: no content provided");const t=f.default.serialize((0,o.normalizeKeccak256Hash)(e)),r=(0,o.getCurrentTimestampInSecond)();return this.data.set(t,{content:e,state:a.StorageTypes.ContentState.PENDING,timestamp:r}),{ipfsHash:t,ipfsSize:e.length}}))}append(e){return n.__awaiter(this,void 0,void 0,(function*(){if(!e)throw Error("Error: no content provided");const t=f.default.serialize((0,o.normalizeKeccak256Hash)(e)),r=(0,o.getCurrentTimestampInSecond)(),n={content:e,state:a.StorageTypes.ContentState.PENDING,timestamp:r};this.data.set(t,n);const s={content:e,id:t,meta:{state:a.StorageTypes.ContentState.PENDING,storageType:a.StorageTypes.StorageSystemType.IN_MEMORY_MOCK,timestamp:r}},c=Object.assign(new i.EventEmitter,s);return setTimeout((()=>{this.forceEmitError?(this.forceEmitError=!1,c.emit("error","forced error asked by _makeNextAppendFailInsteadOfConfirmed()")):(n.state=a.StorageTypes.ContentState.CONFIRMED,this.data.set(t,n),c.emit("confirmed",s))}),100),c}))}read(e){return n.__awaiter(this,void 0,void 0,(function*(){if(!e)throw Error("No id provided");const t=this.data.get(e);if(!t)throw Error("No content found from this id");return{content:t.content,id:e,meta:{state:t.state,storageType:a.StorageTypes.StorageSystemType.IN_MEMORY_MOCK,timestamp:t.timestamp}}}))}readMany(e){return n.__awaiter(this,void 0,void 0,(function*(){return Promise.all(e.map((e=>this.read(e))))}))}getData(){return n.__awaiter(this,void 0,void 0,(function*(){return{entries:Array.from(this.data.entries()).map((([e,{content:t,state:r,timestamp:n}])=>({content:t,id:e,meta:{state:r,storageType:a.StorageTypes.StorageSystemType.IN_MEMORY_MOCK,timestamp:n}}))),lastTimestamp:(0,o.getCurrentTimestampInSecond)()}}))}getIgnoredData(){return n.__awaiter(this,void 0,void 0,(function*(){return[]}))}_getStatus(e){return n.__awaiter(this,void 0,void 0,(function*(){return{dataIds:{count:Object.entries(this.data).length,values:e?Object.entries(this.data):void 0},ignoredDataIds:{count:0,values:e?[]:void 0}}}))}_makeNextAppendFailInsteadOfConfirmed(){this.forceEmitError=!0}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(80),f=r(326),a=r(50),i=r(4),o=r(77),s=r(3),c=r(32),u=r(325),d=r(8);class l extends u.default{constructor({httpConfig:e,nodeConnectionConfig:t,web3:r,ethereumProviderUrl:n}={httpConfig:{},nodeConnectionConfig:{}}){super({httpConfig:e,nodeConnectionConfig:t}),this.cache={},this.networkName="private",n=n||"http://localhost:8545",this.provider=r?new s.ethers.providers.Web3Provider(r):new s.ethers.providers.JsonRpcProvider({url:n})}initialize(){return n.__awaiter(this,void 0,void 0,(function*(){}))}persistTransaction(e,t,r){return n.__awaiter(this,void 0,void 0,(function*(){if(!this.submitterContract){const e=yield this.provider.getNetwork();this.networkName=1===e.chainId?"mainnet":4===e.chainId?"rinkeby":"private",this.submitterContract=new s.ethers.Contract(a.requestHashSubmitterArtifact.getAddress(this.networkName),a.requestHashSubmitterArtifact.getContractAbi(),this.provider.getSigner())}const n=f.Block.pushTransaction(f.Block.createEmptyBlock(),e,t,r),{data:{ipfsHash:u,ipfsSize:d}}=yield o.default.post("/ipfsAdd",{data:n},this.axiosConfig),l=yield this.submitterContract.getFeesAmount(d),p=yield this.submitterContract.submitHash(u,s.ethers.utils.hexZeroPad(s.ethers.utils.hexlify(d),32),{value:l}),h=yield this.provider.getBlock(p.blockNumber),b={blockConfirmation:p.confirmations,blockNumber:p.blockNumber,blockTimestamp:h.timestamp,fee:l,networkName:this.networkName,smartContractAddress:p.to,transactionHash:p.hash};this.cache[t]||(this.cache[t]={}),this.cache[t][u]={block:n,storageMeta:b};const m=new c.EventEmitter,y={meta:{storageMeta:{ethereum:b,ipfs:{size:d},state:i.StorageTypes.ContentState.PENDING,timestamp:b.blockTimestamp},topics:r||[],transactionStorageLocation:u},result:{}};return p.wait().then((e=>{const t={blockConfirmation:e.confirmations,blockNumber:e.blockNumber,blockTimestamp:h.timestamp,fee:l,networkName:this.networkName,smartContractAddress:e.to,transactionHash:e.hash};m.emit("confirmed",{meta:{storageMeta:t,topics:r||[],transactionStorageLocation:u},result:{}})})),Object.assign(m,y)}))}getTransactionsByChannelId(e,t){return n.__awaiter(this,void 0,void 0,(function*(){const{data:r}=yield(0,d.retry)((()=>n.__awaiter(this,void 0,void 0,(function*(){return o.default.get("/getTransactionsByChannelId",Object.assign(this.axiosConfig,{params:{channelId:e,timestampBoundaries:t}}))}))),{maxRetries:this.httpConfig.httpRequestMaxRetry,retryDelay:this.httpConfig.httpRequestRetryDelay})(),f=this.getCachedTransactionsAndCleanCache(e,r.meta.transactionsStorageLocation,t);return{meta:{storageMeta:r.meta.storageMeta.concat(f.meta.storageMeta),transactionsStorageLocation:r.meta.transactionsStorageLocation.concat(f.meta.transactionsStorageLocation)},result:{transactions:r.result.transactions.concat(f.result.transactions)}}}))}getCachedTransactionsAndCleanCache(e,t,r){for(const r of t)this.cache[e][r]=null;return Object.keys(this.cache[e]||[]).reduce(((t,n)=>{var f;const a=this.cache[e][n];return this.cache[e][n]&&(!r||(void 0===r.from||r.from<=(null==a?void 0:a.storageMeta.blockTimestamp))&&(void 0===r.to||r.to>=(null==a?void 0:a.storageMeta.blockTimestamp)))&&(null===(f=t.meta.storageMeta)||void 0===f||f.push(null==a?void 0:a.storageMeta),t.meta.transactionsStorageLocation.push(n),t.result.transactions.push({state:i.DataAccessTypes.TransactionState.PENDING,timestamp:null==a?void 0:a.storageMeta.blockTimestamp,transaction:null==a?void 0:a.block.transactions[0]})),t}),{meta:{storageMeta:[],transactionsStorageLocation:[]},result:{transactions:[]}})}}t.default=l},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Payment=t.Transaction=t.Storage=t.Identity=t.SignatureProvider=t.Signature=t.DataAccess=t.RequestLogic=t.Encryption=t.Extension=t.DecryptionProvider=t.Log=t.AdvancedLogic=void 0;r(80).__exportStar(r(182),t);var n=r(4);Object.defineProperty(t,"AdvancedLogic",{enumerable:!0,get:function(){return n.AdvancedLogicTypes}}),Object.defineProperty(t,"Log",{enumerable:!0,get:function(){return n.LogTypes}}),Object.defineProperty(t,"DecryptionProvider",{enumerable:!0,get:function(){return n.DecryptionProviderTypes}}),Object.defineProperty(t,"Extension",{enumerable:!0,get:function(){return n.ExtensionTypes}}),Object.defineProperty(t,"Encryption",{enumerable:!0,get:function(){return n.EncryptionTypes}}),Object.defineProperty(t,"RequestLogic",{enumerable:!0,get:function(){return n.RequestLogicTypes}}),Object.defineProperty(t,"DataAccess",{enumerable:!0,get:function(){return n.DataAccessTypes}}),Object.defineProperty(t,"Signature",{enumerable:!0,get:function(){return n.SignatureTypes}}),Object.defineProperty(t,"SignatureProvider",{enumerable:!0,get:function(){return n.SignatureProviderTypes}}),Object.defineProperty(t,"Identity",{enumerable:!0,get:function(){return n.IdentityTypes}}),Object.defineProperty(t,"Storage",{enumerable:!0,get:function(){return n.StorageTypes}}),Object.defineProperty(t,"Transaction",{enumerable:!0,get:function(){return n.TransactionTypes}}),Object.defineProperty(t,"Payment",{enumerable:!0,get:function(){return n.PaymentTypes}})},function(e,t,r){"use strict";r.r(t),r.d(t,"ethers",(function(){return a})),r.d(t,"Signer",(function(){return c.a})),r.d(t,"Wallet",(function(){return u.Wallet})),r.d(t,"VoidSigner",(function(){return c.b})),r.d(t,"getDefaultProvider",(function(){return gt})),r.d(t,"providers",(function(){return n})),r.d(t,"BaseContract",(function(){return i.a})),r.d(t,"Contract",(function(){return i.b})),r.d(t,"ContractFactory",(function(){return i.c})),r.d(t,"BigNumber",(function(){return o.a})),r.d(t,"FixedNumber",(function(){return s.a})),r.d(t,"constants",(function(){return d})),r.d(t,"errors",(function(){return T.ErrorCode})),r.d(t,"logger",(function(){return Zr})),r.d(t,"utils",(function(){return f})),r.d(t,"wordlists",(function(){return vt.a})),r.d(t,"version",(function(){return Xr})),r.d(t,"Wordlist",(function(){return _t.a}));var n={};r.r(n),r.d(n,"Provider",(function(){return l.b})),r.d(n,"BaseProvider",(function(){return te})),r.d(n,"Resolver",(function(){return Z})),r.d(n,"UrlJsonRpcProvider",(function(){return Ae})),r.d(n,"FallbackProvider",(function(){return tt})),r.d(n,"AlchemyProvider",(function(){return Se})),r.d(n,"AlchemyWebSocketProvider",(function(){return ke})),r.d(n,"CloudflareProvider",(function(){return Pe})),r.d(n,"EtherscanProvider",(function(){return Le})),r.d(n,"InfuraProvider",(function(){return it})),r.d(n,"InfuraWebSocketProvider",(function(){return at})),r.d(n,"JsonRpcProvider",(function(){return he})),r.d(n,"JsonRpcBatchProvider",(function(){return ot})),r.d(n,"NodesmithProvider",(function(){return ct})),r.d(n,"PocketProvider",(function(){return lt})),r.d(n,"StaticJsonRpcProvider",(function(){return Ee})),r.d(n,"Web3Provider",(function(){return mt})),r.d(n,"WebSocketProvider",(function(){return ve})),r.d(n,"IpcProvider",(function(){return rt})),r.d(n,"JsonRpcSigner",(function(){return de})),r.d(n,"getDefaultProvider",(function(){return gt})),r.d(n,"getNetwork",(function(){return p.a})),r.d(n,"isCommunityResource",(function(){return N})),r.d(n,"isCommunityResourcable",(function(){return R})),r.d(n,"showThrottleMessage",(function(){return M})),r.d(n,"Formatter",(function(){return P}));var f={};r.r(f),r.d(f,"AbiCoder",(function(){return hr})),r.d(f,"defaultAbiCoder",(function(){return br})),r.d(f,"Fragment",(function(){return Zt})),r.d(f,"ConstructorFragment",(function(){return nr})),r.d(f,"ErrorFragment",(function(){return ir})),r.d(f,"EventFragment",(function(){return Qt})),r.d(f,"FunctionFragment",(function(){return fr})),r.d(f,"ParamType",(function(){return Jt})),r.d(f,"FormatTypes",(function(){return Wt})),r.d(f,"checkResultErrors",(function(){return At})),r.d(f,"Logger",(function(){return T.Logger})),r.d(f,"RLP",(function(){return Dr})),r.d(f,"_fetchData",(function(){return Kr})),r.d(f,"fetchJson",(function(){return Wr})),r.d(f,"poll",(function(){return Yr})),r.d(f,"checkProperties",(function(){return g.checkProperties})),r.d(f,"deepCopy",(function(){return g.deepCopy})),r.d(f,"defineReadOnly",(function(){return g.defineReadOnly})),r.d(f,"getStatic",(function(){return g.getStatic})),r.d(f,"resolveProperties",(function(){return g.resolveProperties})),r.d(f,"shallowCopy",(function(){return g.shallowCopy})),r.d(f,"arrayify",(function(){return b.arrayify})),r.d(f,"concat",(function(){return b.concat})),r.d(f,"stripZeros",(function(){return b.stripZeros})),r.d(f,"zeroPad",(function(){return b.zeroPad})),r.d(f,"isBytes",(function(){return b.isBytes})),r.d(f,"isBytesLike",(function(){return b.isBytesLike})),r.d(f,"defaultPath",(function(){return Pr.defaultPath})),r.d(f,"HDNode",(function(){return Pr.HDNode})),r.d(f,"SigningKey",(function(){return Br.SigningKey})),r.d(f,"Interface",(function(){return Sr})),r.d(f,"LogDescription",(function(){return wr})),r.d(f,"TransactionDescription",(function(){return Er})),r.d(f,"base58",(function(){return h.Base58})),r.d(f,"base64",(function(){return Or})),r.d(f,"hexlify",(function(){return b.hexlify})),r.d(f,"isHexString",(function(){return b.isHexString})),r.d(f,"hexConcat",(function(){return b.hexConcat})),r.d(f,"hexStripZeros",(function(){return b.hexStripZeros})),r.d(f,"hexValue",(function(){return b.hexValue})),r.d(f,"hexZeroPad",(function(){return b.hexZeroPad})),r.d(f,"hexDataLength",(function(){return b.hexDataLength})),r.d(f,"hexDataSlice",(function(){return b.hexDataSlice})),r.d(f,"nameprep",(function(){return Fr.a})),r.d(f,"_toEscapedUtf8String",(function(){return _.d})),r.d(f,"toUtf8Bytes",(function(){return _.f})),r.d(f,"toUtf8CodePoints",(function(){return _.g})),r.d(f,"toUtf8String",(function(){return _.h})),r.d(f,"Utf8ErrorFuncs",(function(){return _.b})),r.d(f,"formatBytes32String",(function(){return jr.a})),r.d(f,"parseBytes32String",(function(){return jr.b})),r.d(f,"hashMessage",(function(){return Cr.a})),r.d(f,"namehash",(function(){return y.b})),r.d(f,"isValidName",(function(){return y.a})),r.d(f,"id",(function(){return mr.a})),r.d(f,"_TypedDataEncoder",(function(){return re.a})),r.d(f,"getAddress",(function(){return k.getAddress})),r.d(f,"getIcapAddress",(function(){return k.getIcapAddress})),r.d(f,"getContractAddress",(function(){return k.getContractAddress})),r.d(f,"getCreate2Address",(function(){return k.getCreate2Address})),r.d(f,"isAddress",(function(){return k.isAddress})),r.d(f,"formatEther",(function(){return Lr.formatEther})),r.d(f,"parseEther",(function(){return Lr.parseEther})),r.d(f,"formatUnits",(function(){return Lr.formatUnits})),r.d(f,"parseUnits",(function(){return Lr.parseUnits})),r.d(f,"commify",(function(){return Lr.commify})),r.d(f,"computeHmac",(function(){return v.a})),r.d(f,"keccak256",(function(){return vr})),r.d(f,"ripemd160",(function(){return v.b})),r.d(f,"sha256",(function(){return v.c})),r.d(f,"sha512",(function(){return v.d})),r.d(f,"randomBytes",(function(){return Ir.a})),r.d(f,"shuffled",(function(){return Mr})),r.d(f,"solidityPack",(function(){return Nr.pack})),r.d(f,"solidityKeccak256",(function(){return Nr.keccak256})),r.d(f,"soliditySha256",(function(){return Nr.sha256})),r.d(f,"splitSignature",(function(){return b.splitSignature})),r.d(f,"joinSignature",(function(){return b.joinSignature})),r.d(f,"accessListify",(function(){return O.accessListify})),r.d(f,"parseTransaction",(function(){return O.parse})),r.d(f,"serializeTransaction",(function(){return O.serialize})),r.d(f,"TransactionTypes",(function(){return O.TransactionTypes})),r.d(f,"getJsonWalletAddress",(function(){return Rr.a})),r.d(f,"computeAddress",(function(){return O.computeAddress})),r.d(f,"recoverAddress",(function(){return O.recoverAddress})),r.d(f,"computePublicKey",(function(){return Br.computePublicKey})),r.d(f,"recoverPublicKey",(function(){return Br.recoverPublicKey})),r.d(f,"verifyMessage",(function(){return u.verifyMessage})),r.d(f,"verifyTypedData",(function(){return u.verifyTypedData})),r.d(f,"getAccountPath",(function(){return Pr.getAccountPath})),r.d(f,"mnemonicToEntropy",(function(){return Pr.mnemonicToEntropy})),r.d(f,"entropyToMnemonic",(function(){return Pr.entropyToMnemonic})),r.d(f,"isValidMnemonic",(function(){return Pr.isValidMnemonic})),r.d(f,"mnemonicToSeed",(function(){return Pr.mnemonicToSeed})),r.d(f,"SupportedAlgorithm",(function(){return Jr.a})),r.d(f,"UnicodeNormalizationForm",(function(){return _.a})),r.d(f,"Utf8ErrorReason",(function(){return _.c})),r.d(f,"Indexed",(function(){return Tr}));var a={};r.r(a),r.d(a,"Signer",(function(){return c.a})),r.d(a,"Wallet",(function(){return u.Wallet})),r.d(a,"VoidSigner",(function(){return c.b})),r.d(a,"getDefaultProvider",(function(){return gt})),r.d(a,"providers",(function(){return n})),r.d(a,"BaseContract",(function(){return i.a})),r.d(a,"Contract",(function(){return i.b})),r.d(a,"ContractFactory",(function(){return i.c})),r.d(a,"BigNumber",(function(){return o.a})),r.d(a,"FixedNumber",(function(){return s.a})),r.d(a,"constants",(function(){return d})),r.d(a,"errors",(function(){return T.ErrorCode})),r.d(a,"logger",(function(){return Zr})),r.d(a,"utils",(function(){return f})),r.d(a,"wordlists",(function(){return vt.a})),r.d(a,"version",(function(){return Xr})),r.d(a,"Wordlist",(function(){return _t.a}));var i=r(62),o=r(17),s=r(858),c=r(30),u=r(48),d=r(39),l=r(24),p=r(53),h=r(37),b=r(0),m=r(179),y=r(136),g=r(1),v=r(70),_=r(20),w=r(14),E=r(89),A=r.n(E),T=r(2);const x="providers/5.5.3";var k=r(6),S=r(191),O=r(10);const C=new T.Logger(x);class P{constructor(){C.checkNew(new.target,P),this.formats=this.getDefaultFormats()}getDefaultFormats(){const e={},t=this.address.bind(this),r=this.bigNumber.bind(this),n=this.blockTag.bind(this),f=this.data.bind(this),a=this.hash.bind(this),i=this.hex.bind(this),o=this.number.bind(this),s=this.type.bind(this);return e.transaction={hash:a,type:s,accessList:P.allowNull(this.accessList.bind(this),null),blockHash:P.allowNull(a,null),blockNumber:P.allowNull(o,null),transactionIndex:P.allowNull(o,null),confirmations:P.allowNull(o,null),from:t,gasPrice:P.allowNull(r),maxPriorityFeePerGas:P.allowNull(r),maxFeePerGas:P.allowNull(r),gasLimit:r,to:P.allowNull(t,null),value:r,nonce:o,data:f,r:P.allowNull(this.uint256),s:P.allowNull(this.uint256),v:P.allowNull(o),creates:P.allowNull(t,null),raw:P.allowNull(f)},e.transactionRequest={from:P.allowNull(t),nonce:P.allowNull(o),gasLimit:P.allowNull(r),gasPrice:P.allowNull(r),maxPriorityFeePerGas:P.allowNull(r),maxFeePerGas:P.allowNull(r),to:P.allowNull(t),value:P.allowNull(r),data:P.allowNull((e=>this.data(e,!0))),type:P.allowNull(o),accessList:P.allowNull(this.accessList.bind(this),null)},e.receiptLog={transactionIndex:o,blockNumber:o,transactionHash:a,address:t,topics:P.arrayOf(a),data:f,logIndex:o,blockHash:a},e.receipt={to:P.allowNull(this.address,null),from:P.allowNull(this.address,null),contractAddress:P.allowNull(t,null),transactionIndex:o,root:P.allowNull(i),gasUsed:r,logsBloom:P.allowNull(f),blockHash:a,transactionHash:a,logs:P.arrayOf(this.receiptLog.bind(this)),blockNumber:o,confirmations:P.allowNull(o,null),cumulativeGasUsed:r,effectiveGasPrice:P.allowNull(r),status:P.allowNull(o),type:s},e.block={hash:a,parentHash:a,number:o,timestamp:o,nonce:P.allowNull(i),difficulty:this.difficulty.bind(this),gasLimit:r,gasUsed:r,miner:t,extraData:f,transactions:P.allowNull(P.arrayOf(a)),baseFeePerGas:P.allowNull(r)},e.blockWithTransactions=Object(g.shallowCopy)(e.block),e.blockWithTransactions.transactions=P.allowNull(P.arrayOf(this.transactionResponse.bind(this))),e.filter={fromBlock:P.allowNull(n,void 0),toBlock:P.allowNull(n,void 0),blockHash:P.allowNull(a,void 0),address:P.allowNull(t,void 0),topics:P.allowNull(this.topics.bind(this),void 0)},e.filterLog={blockNumber:P.allowNull(o),blockHash:P.allowNull(a),transactionIndex:o,removed:P.allowNull(this.boolean.bind(this)),address:t,data:P.allowFalsish(f,"0x"),topics:P.arrayOf(a),transactionHash:a,logIndex:o},e}accessList(e){return Object(O.accessListify)(e||[])}number(e){return"0x"===e?0:o.a.from(e).toNumber()}type(e){return"0x"===e||null==e?0:o.a.from(e).toNumber()}bigNumber(e){return o.a.from(e)}boolean(e){if("boolean"==typeof e)return e;if("string"==typeof e){if("true"===(e=e.toLowerCase()))return!0;if("false"===e)return!1}throw new Error("invalid boolean - "+e)}hex(e,t){return"string"==typeof e&&(t||"0x"===e.substring(0,2)||(e="0x"+e),Object(b.isHexString)(e))?e.toLowerCase():C.throwArgumentError("invalid hash","value",e)}data(e,t){const r=this.hex(e,t);if(r.length%2!=0)throw new Error("invalid data; odd-length - "+e);return r}address(e){return Object(k.getAddress)(e)}callAddress(e){if(!Object(b.isHexString)(e,32))return null;const t=Object(k.getAddress)(Object(b.hexDataSlice)(e,12));return t===S.a?null:t}contractAddress(e){return Object(k.getContractAddress)(e)}blockTag(e){if(null==e)return"latest";if("earliest"===e)return"0x0";if("latest"===e||"pending"===e)return e;if("number"==typeof e||Object(b.isHexString)(e))return Object(b.hexValue)(e);throw new Error("invalid blockTag")}hash(e,t){const r=this.hex(e,t);return 32!==Object(b.hexDataLength)(r)?C.throwArgumentError("invalid hash","value",e):r}difficulty(e){if(null==e)return null;const t=o.a.from(e);try{return t.toNumber()}catch(e){}return null}uint256(e){if(!Object(b.isHexString)(e))throw new Error("invalid uint256");return Object(b.hexZeroPad)(e,32)}_block(e,t){null!=e.author&&null==e.miner&&(e.miner=e.author);const r=null!=e._difficulty?e._difficulty:e.difficulty,n=P.check(t,e);return n._difficulty=null==r?null:o.a.from(r),n}block(e){return this._block(e,this.formats.block)}blockWithTransactions(e){return this._block(e,this.formats.blockWithTransactions)}transactionRequest(e){return P.check(this.formats.transactionRequest,e)}transactionResponse(e){null!=e.gas&&null==e.gasLimit&&(e.gasLimit=e.gas),e.to&&o.a.from(e.to).isZero()&&(e.to="0x0000000000000000000000000000000000000000"),null!=e.input&&null==e.data&&(e.data=e.input),null==e.to&&null==e.creates&&(e.creates=this.contractAddress(e)),1!==e.type&&2!==e.type||null!=e.accessList||(e.accessList=[]);const t=P.check(this.formats.transaction,e);if(null!=e.chainId){let r=e.chainId;Object(b.isHexString)(r)&&(r=o.a.from(r).toNumber()),t.chainId=r}else{let r=e.networkId;null==r&&null==t.v&&(r=e.chainId),Object(b.isHexString)(r)&&(r=o.a.from(r).toNumber()),"number"!=typeof r&&null!=t.v&&(r=(t.v-35)/2,r<0&&(r=0),r=parseInt(r)),"number"!=typeof r&&(r=0),t.chainId=r}return t.blockHash&&"x"===t.blockHash.replace(/0/g,"")&&(t.blockHash=null),t}transaction(e){return Object(O.parse)(e)}receiptLog(e){return P.check(this.formats.receiptLog,e)}receipt(e){const t=P.check(this.formats.receipt,e);if(null!=t.root)if(t.root.length<=4){const e=o.a.from(t.root).toNumber();0===e||1===e?(null!=t.status&&t.status!==e&&C.throwArgumentError("alt-root-status/status mismatch","value",{root:t.root,status:t.status}),t.status=e,delete t.root):C.throwArgumentError("invalid alt-root-status","value.root",t.root)}else 66!==t.root.length&&C.throwArgumentError("invalid root hash","value.root",t.root);return null!=t.status&&(t.byzantium=!0),t}topics(e){return Array.isArray(e)?e.map((e=>this.topics(e))):null!=e?this.hash(e,!0):null}filter(e){return P.check(this.formats.filter,e)}filterLog(e){return P.check(this.formats.filterLog,e)}static check(e,t){const r={};for(const n in e)try{const f=e[n](t[n]);void 0!==f&&(r[n]=f)}catch(e){throw e.checkKey=n,e.checkValue=t[n],e}return r}static allowNull(e,t){return function(r){return null==r?t:e(r)}}static allowFalsish(e,t){return function(r){return r?e(r):t}}static arrayOf(e){return function(t){if(!Array.isArray(t))throw new Error("not an array");const r=[];return t.forEach((function(t){r.push(e(t))})),r}}}function R(e){return e&&"function"==typeof e.isCommunityResource}function N(e){return R(e)&&e.isCommunityResource()}let I=!1;function M(){I||(I=!0,console.log("========= NOTICE ========="),console.log("Request-Rate Exceeded (this message will not be repeated)"),console.log(""),console.log("The default API keys for each service are provided as a highly-throttled,"),console.log("community resource for low-traffic projects and early prototyping."),console.log(""),console.log("While your application will continue to function, we highly recommended"),console.log("signing up for your own API keys to improve performance, increase your"),console.log("request rate/limit and enable other perks, such as metrics and advanced APIs."),console.log(""),console.log("For more details: https://docs.ethers.io/api-keys/"),console.log("=========================="))}var D=function(e,t,r,n){return new(r||(r=Promise))((function(f,a){function i(e){try{s(n.next(e))}catch(e){a(e)}}function o(e){try{s(n.throw(e))}catch(e){a(e)}}function s(e){var t;e.done?f(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(i,o)}s((n=n.apply(e,t||[])).next())}))};const B=new T.Logger(x);function F(e){return null==e?"null":(32!==Object(b.hexDataLength)(e)&&B.throwArgumentError("invalid topic","topic",e),e.toLowerCase())}function j(e){for(e=e.slice();e.length>0&&null==e[e.length-1];)e.pop();return e.map((e=>{if(Array.isArray(e)){const t={};e.forEach((e=>{t[F(e)]=!0}));const r=Object.keys(t);return r.sort(),r.join("|")}return F(e)})).join("&")}function L(e){if("string"==typeof e){if(e=e.toLowerCase(),32===Object(b.hexDataLength)(e))return"tx:"+e;if(-1===e.indexOf(":"))return e}else{if(Array.isArray(e))return"filter:*:"+j(e);if(l.a.isForkEvent(e))throw B.warn("not implemented"),new Error("not implemented");if(e&&"object"==typeof e)return"filter:"+(e.address||"*")+":"+j(e.topics||[])}throw new Error("invalid event - "+e)}function U(){return(new Date).getTime()}function q(e){return new Promise((t=>{setTimeout(t,e)}))}const H=["block","network","pending","poll"];class ${constructor(e,t,r){Object(g.defineReadOnly)(this,"tag",e),Object(g.defineReadOnly)(this,"listener",t),Object(g.defineReadOnly)(this,"once",r)}get event(){switch(this.type){case"tx":return this.hash;case"filter":return this.filter}return this.tag}get type(){return this.tag.split(":")[0]}get hash(){const e=this.tag.split(":");return"tx"!==e[0]?null:e[1]}get filter(){const e=this.tag.split(":");if("filter"!==e[0])return null;const t=e[1],r=""===(n=e[2])?[]:n.split(/&/g).map((e=>{if(""===e)return[];const t=e.split("|").map((e=>"null"===e?null:e));return 1===t.length?t[0]:t}));var n;const f={};return r.length>0&&(f.topics=r),t&&"*"!==t&&(f.address=t),f}pollable(){return this.tag.indexOf(":")>=0||H.indexOf(this.tag)>=0}}const z={0:{symbol:"btc",p2pkh:0,p2sh:5,prefix:"bc"},2:{symbol:"ltc",p2pkh:48,p2sh:50,prefix:"ltc"},3:{symbol:"doge",p2pkh:30,p2sh:22},60:{symbol:"eth",ilk:"eth"},61:{symbol:"etc",ilk:"eth"},700:{symbol:"xdai",ilk:"eth"}};function V(e){return Object(b.hexZeroPad)(o.a.from(e).toHexString(),32)}function G(e){return h.Base58.encode(Object(b.concat)([e,Object(b.hexDataSlice)(Object(v.c)(Object(v.c)(e)),0,4)]))}const K=new RegExp("^(ipfs)://(.*)$","i"),W=[new RegExp("^(https)://(.*)$","i"),new RegExp("^(data):(.*)$","i"),K,new RegExp("^eip155:[0-9]+/(erc[0-9]+):(.*)$","i")];function Y(e){try{return Object(_.h)(J(e))}catch(e){}return null}function J(e){if("0x"===e)return null;const t=o.a.from(Object(b.hexDataSlice)(e,0,32)).toNumber(),r=o.a.from(Object(b.hexDataSlice)(e,t,t+32)).toNumber();return Object(b.hexDataSlice)(e,t+32,t+32+r)}function X(e){return e.match(/^ipfs:\/\/ipfs\//i)?e=e.substring(12):e.match(/^ipfs:\/\//i)?e=e.substring(7):B.throwArgumentError("unsupported IPFS format","link",e),`https://gateway.ipfs.io/ipfs/${e}`}class Z{constructor(e,t,r,n){Object(g.defineReadOnly)(this,"provider",e),Object(g.defineReadOnly)(this,"name",r),Object(g.defineReadOnly)(this,"address",e.formatter.address(t)),Object(g.defineReadOnly)(this,"_resolvedAddress",n)}_fetchBytes(e,t){return D(this,void 0,void 0,(function*(){const r={to:this.address,data:Object(b.hexConcat)([e,Object(y.b)(this.name),t||"0x"])};try{return J(yield this.provider.call(r))}catch(e){return e.code,T.Logger.errors.CALL_EXCEPTION,null}}))}_getAddress(e,t){const r=z[String(e)];if(null==r&&B.throwError(`unsupported coin type: ${e}`,T.Logger.errors.UNSUPPORTED_OPERATION,{operation:`getAddress(${e})`}),"eth"===r.ilk)return this.provider.formatter.address(t);const n=Object(b.arrayify)(t);if(null!=r.p2pkh){const e=t.match(/^0x76a9([0-9a-f][0-9a-f])([0-9a-f]*)88ac$/);if(e){const t=parseInt(e[1],16);if(e[2].length===2*t&&t>=1&&t<=75)return G(Object(b.concat)([[r.p2pkh],"0x"+e[2]]))}}if(null!=r.p2sh){const e=t.match(/^0xa9([0-9a-f][0-9a-f])([0-9a-f]*)87$/);if(e){const t=parseInt(e[1],16);if(e[2].length===2*t&&t>=1&&t<=75)return G(Object(b.concat)([[r.p2sh],"0x"+e[2]]))}}if(null!=r.prefix){const e=n[1];let t=n[0];if(0===t?20!==e&&32!==e&&(t=-1):t=-1,t>=0&&n.length===2+e&&e>=1&&e<=75){const e=A.a.toWords(n.slice(2));return e.unshift(t),A.a.encode(r.prefix,e)}}return null}getAddress(e){return D(this,void 0,void 0,(function*(){if(null==e&&(e=60),60===e)try{const e={to:this.address,data:"0x3b3b57de"+Object(y.b)(this.name).substring(2)},t=yield this.provider.call(e);return"0x"===t||t===m.a?null:this.provider.formatter.callAddress(t)}catch(e){if(e.code===T.Logger.errors.CALL_EXCEPTION)return null;throw e}const t=yield this._fetchBytes("0xf1cb7e06",V(e));if(null==t||"0x"===t)return null;const r=this._getAddress(e,t);return null==r&&B.throwError("invalid or unsupported coin data",T.Logger.errors.UNSUPPORTED_OPERATION,{operation:`getAddress(${e})`,coinType:e,data:t}),r}))}getAvatar(){return D(this,void 0,void 0,(function*(){const e=[{type:"name",content:this.name}];try{const t=yield this.getText("avatar");if(null==t)return null;for(let r=0;r<W.length;r++){const n=t.match(W[r]);if(null==n)continue;const f=n[1].toLowerCase();switch(f){case"https":return e.push({type:"url",content:t}),{linkage:e,url:t};case"data":return e.push({type:"data",content:t}),{linkage:e,url:t};case"ipfs":return e.push({type:"ipfs",content:t}),{linkage:e,url:X(t)};case"erc721":case"erc1155":{const r="erc721"===f?"0xc87b56dd":"0x0e89341c";e.push({type:f,content:t});const a=this._resolvedAddress||(yield this.getAddress()),i=(n[2]||"").split("/");if(2!==i.length)return null;const s=yield this.provider.formatter.address(i[0]),c=Object(b.hexZeroPad)(o.a.from(i[1]).toHexString(),32);if("erc721"===f){const t=this.provider.formatter.callAddress(yield this.provider.call({to:s,data:Object(b.hexConcat)(["0x6352211e",c])}));if(a!==t)return null;e.push({type:"owner",content:t})}else if("erc1155"===f){const t=o.a.from(yield this.provider.call({to:s,data:Object(b.hexConcat)(["0x00fdd58e",Object(b.hexZeroPad)(a,32),c])}));if(t.isZero())return null;e.push({type:"balance",content:t.toString()})}const u={to:this.provider.formatter.address(i[0]),data:Object(b.hexConcat)([r,c])};let d=Y(yield this.provider.call(u));if(null==d)return null;e.push({type:"metadata-url-base",content:d}),"erc1155"===f&&(d=d.replace("{id}",c.substring(2)),e.push({type:"metadata-url-expanded",content:d})),d.match(/^ipfs:/i)&&(d=X(d)),e.push({type:"metadata-url",content:d});const l=yield Object(w.fetchJson)(d);if(!l)return null;e.push({type:"metadata",content:JSON.stringify(l)});let p=l.image;if("string"!=typeof p)return null;if(p.match(/^(https:\/\/|data:)/i));else{if(null==p.match(K))return null;e.push({type:"url-ipfs",content:p}),p=X(p)}return e.push({type:"url",content:p}),{linkage:e,url:p}}}}}catch(e){}return null}))}getContentHash(){return D(this,void 0,void 0,(function*(){const e=yield this._fetchBytes("0xbc1c58d1");if(null==e||"0x"===e)return null;const t=e.match(/^0xe3010170(([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])([0-9a-f]*))$/);if(t){const e=parseInt(t[3],16);if(t[4].length===2*e)return"ipfs://"+h.Base58.encode("0x"+t[1])}const r=e.match(/^0xe40101fa011b20([0-9a-f]*)$/);return r&&64===r[1].length?"bzz://"+r[1]:B.throwError("invalid or unsupported content hash data",T.Logger.errors.UNSUPPORTED_OPERATION,{operation:"getContentHash()",data:e})}))}getText(e){return D(this,void 0,void 0,(function*(){let t=Object(_.f)(e);t=Object(b.concat)([V(64),V(t.length),t]),t.length%32!=0&&(t=Object(b.concat)([t,Object(b.hexZeroPad)("0x",32-e.length%32)]));const r=yield this._fetchBytes("0x59d1d43c",Object(b.hexlify)(t));return null==r||"0x"===r?null:Object(_.h)(r)}))}}let Q=null,ee=1;class te extends l.b{constructor(e){if(B.checkNew(new.target,l.b),super(),this._events=[],this._emitted={block:-2},this.formatter=new.target.getFormatter(),Object(g.defineReadOnly)(this,"anyNetwork","any"===e),this.anyNetwork&&(e=this.detectNetwork()),e instanceof Promise)this._networkPromise=e,e.catch((e=>{})),this._ready().catch((e=>{}));else{const t=Object(g.getStatic)(new.target,"getNetwork")(e);t?(Object(g.defineReadOnly)(this,"_network",t),this.emit("network",t,null)):B.throwArgumentError("invalid network","network",e)}this._maxInternalBlockNumber=-1024,this._lastBlockNumber=-2,this._pollingInterval=4e3,this._fastQueryDate=0}_ready(){return D(this,void 0,void 0,(function*(){if(null==this._network){let e=null;if(this._networkPromise)try{e=yield this._networkPromise}catch(e){}null==e&&(e=yield this.detectNetwork()),e||B.throwError("no network detected",T.Logger.errors.UNKNOWN_ERROR,{}),null==this._network&&(this.anyNetwork?this._network=e:Object(g.defineReadOnly)(this,"_network",e),this.emit("network",e,null))}return this._network}))}get ready(){return Object(w.poll)((()=>this._ready().then((e=>e),(e=>{if(e.code!==T.Logger.errors.NETWORK_ERROR||"noNetwork"!==e.event)throw e}))))}static getFormatter(){return null==Q&&(Q=new P),Q}static getNetwork(e){return Object(p.a)(null==e?"homestead":e)}_getInternalBlockNumber(e){return D(this,void 0,void 0,(function*(){if(yield this._ready(),e>0)for(;this._internalBlockNumber;){const t=this._internalBlockNumber;try{const r=yield t;if(U()-r.respTime<=e)return r.blockNumber;break}catch(e){if(this._internalBlockNumber===t)break}}const t=U(),r=Object(g.resolveProperties)({blockNumber:this.perform("getBlockNumber",{}),networkError:this.getNetwork().then((e=>null),(e=>e))}).then((({blockNumber:e,networkError:n})=>{if(n)throw this._internalBlockNumber===r&&(this._internalBlockNumber=null),n;const f=U();return(e=o.a.from(e).toNumber())<this._maxInternalBlockNumber&&(e=this._maxInternalBlockNumber),this._maxInternalBlockNumber=e,this._setFastBlockNumber(e),{blockNumber:e,reqTime:t,respTime:f}}));return this._internalBlockNumber=r,r.catch((e=>{this._internalBlockNumber===r&&(this._internalBlockNumber=null)})),(yield r).blockNumber}))}poll(){return D(this,void 0,void 0,(function*(){const e=ee++,t=[];let r=null;try{r=yield this._getInternalBlockNumber(100+this.pollingInterval/2)}catch(e){return void this.emit("error",e)}if(this._setFastBlockNumber(r),this.emit("poll",e,r),r!==this._lastBlockNumber){if(-2===this._emitted.block&&(this._emitted.block=r-1),Math.abs(this._emitted.block-r)>1e3)B.warn(`network block skew detected; skipping block events (emitted=${this._emitted.block} blockNumber${r})`),this.emit("error",B.makeError("network block skew detected",T.Logger.errors.NETWORK_ERROR,{blockNumber:r,event:"blockSkew",previousBlockNumber:this._emitted.block})),this.emit("block",r);else for(let e=this._emitted.block+1;e<=r;e++)this.emit("block",e);this._emitted.block!==r&&(this._emitted.block=r,Object.keys(this._emitted).forEach((e=>{if("block"===e)return;const t=this._emitted[e];"pending"!==t&&r-t>12&&delete this._emitted[e]}))),-2===this._lastBlockNumber&&(this._lastBlockNumber=r-1),this._events.forEach((e=>{switch(e.type){case"tx":{const r=e.hash;let n=this.getTransactionReceipt(r).then((e=>e&&null!=e.blockNumber?(this._emitted["t:"+r]=e.blockNumber,this.emit(r,e),null):null)).catch((e=>{this.emit("error",e)}));t.push(n);break}case"filter":{const n=e.filter;n.fromBlock=this._lastBlockNumber+1,n.toBlock=r;const f=this.getLogs(n).then((e=>{0!==e.length&&e.forEach((e=>{this._emitted["b:"+e.blockHash]=e.blockNumber,this._emitted["t:"+e.transactionHash]=e.blockNumber,this.emit(n,e)}))})).catch((e=>{this.emit("error",e)}));t.push(f);break}}})),this._lastBlockNumber=r,Promise.all(t).then((()=>{this.emit("didPoll",e)})).catch((e=>{this.emit("error",e)}))}else this.emit("didPoll",e)}))}resetEventsBlock(e){this._lastBlockNumber=e-1,this.polling&&this.poll()}get network(){return this._network}detectNetwork(){return D(this,void 0,void 0,(function*(){return B.throwError("provider does not support network detection",T.Logger.errors.UNSUPPORTED_OPERATION,{operation:"provider.detectNetwork"})}))}getNetwork(){return D(this,void 0,void 0,(function*(){const e=yield this._ready(),t=yield this.detectNetwork();if(e.chainId!==t.chainId){if(this.anyNetwork)return this._network=t,this._lastBlockNumber=-2,this._fastBlockNumber=null,this._fastBlockNumberPromise=null,this._fastQueryDate=0,this._emitted.block=-2,this._maxInternalBlockNumber=-1024,this._internalBlockNumber=null,this.emit("network",t,e),yield q(0),this._network;const r=B.makeError("underlying network changed",T.Logger.errors.NETWORK_ERROR,{event:"changed",network:e,detectedNetwork:t});throw this.emit("error",r),r}return e}))}get blockNumber(){return this._getInternalBlockNumber(100+this.pollingInterval/2).then((e=>{this._setFastBlockNumber(e)}),(e=>{})),null!=this._fastBlockNumber?this._fastBlockNumber:-1}get polling(){return null!=this._poller}set polling(e){e&&!this._poller?(this._poller=setInterval((()=>{this.poll()}),this.pollingInterval),this._bootstrapPoll||(this._bootstrapPoll=setTimeout((()=>{this.poll(),this._bootstrapPoll=setTimeout((()=>{this._poller||this.poll(),this._bootstrapPoll=null}),this.pollingInterval)}),0))):!e&&this._poller&&(clearInterval(this._poller),this._poller=null)}get pollingInterval(){return this._pollingInterval}set pollingInterval(e){if("number"!=typeof e||e<=0||parseInt(String(e))!=e)throw new Error("invalid polling interval");this._pollingInterval=e,this._poller&&(clearInterval(this._poller),this._poller=setInterval((()=>{this.poll()}),this._pollingInterval))}_getFastBlockNumber(){const e=U();return e-this._fastQueryDate>2*this._pollingInterval&&(this._fastQueryDate=e,this._fastBlockNumberPromise=this.getBlockNumber().then((e=>((null==this._fastBlockNumber||e>this._fastBlockNumber)&&(this._fastBlockNumber=e),this._fastBlockNumber)))),this._fastBlockNumberPromise}_setFastBlockNumber(e){null!=this._fastBlockNumber&&e<this._fastBlockNumber||(this._fastQueryDate=U(),(null==this._fastBlockNumber||e>this._fastBlockNumber)&&(this._fastBlockNumber=e,this._fastBlockNumberPromise=Promise.resolve(e)))}waitForTransaction(e,t,r){return D(this,void 0,void 0,(function*(){return this._waitForTransaction(e,null==t?1:t,r||0,null)}))}_waitForTransaction(e,t,r,n){return D(this,void 0,void 0,(function*(){const f=yield this.getTransactionReceipt(e);return(f?f.confirmations:0)>=t?f:new Promise(((f,a)=>{const i=[];let o=!1;const s=function(){return!!o||(o=!0,i.forEach((e=>{e()})),!1)},c=e=>{e.confirmations<t||s()||f(e)};if(this.on(e,c),i.push((()=>{this.removeListener(e,c)})),n){let r=n.startBlock,f=null;const c=i=>D(this,void 0,void 0,(function*(){o||(yield q(1e3),this.getTransactionCount(n.from).then((u=>D(this,void 0,void 0,(function*(){if(!o){if(u<=n.nonce)r=i;else{{const t=yield this.getTransaction(e);if(t&&null!=t.blockNumber)return}for(null==f&&(f=r-3,f<n.startBlock&&(f=n.startBlock));f<=i;){if(o)return;const r=yield this.getBlockWithTransactions(f);for(let f=0;f<r.transactions.length;f++){const i=r.transactions[f];if(i.hash===e)return;if(i.from===n.from&&i.nonce===n.nonce){if(o)return;const r=yield this.waitForTransaction(i.hash,t);if(s())return;let f="replaced";return i.data===n.data&&i.to===n.to&&i.value.eq(n.value)?f="repriced":"0x"===i.data&&i.from===i.to&&i.value.isZero()&&(f="cancelled"),void a(B.makeError("transaction was replaced",T.Logger.errors.TRANSACTION_REPLACED,{cancelled:"replaced"===f||"cancelled"===f,reason:f,replacement:this._wrapTransaction(i),hash:e,receipt:r}))}}f++}}o||this.once("block",c)}}))),(e=>{o||this.once("block",c)})))}));if(o)return;this.once("block",c),i.push((()=>{this.removeListener("block",c)}))}if("number"==typeof r&&r>0){const e=setTimeout((()=>{s()||a(B.makeError("timeout exceeded",T.Logger.errors.TIMEOUT,{timeout:r}))}),r);e.unref&&e.unref(),i.push((()=>{clearTimeout(e)}))}}))}))}getBlockNumber(){return D(this,void 0,void 0,(function*(){return this._getInternalBlockNumber(0)}))}getGasPrice(){return D(this,void 0,void 0,(function*(){yield this.getNetwork();const e=yield this.perform("getGasPrice",{});try{return o.a.from(e)}catch(t){return B.throwError("bad result from backend",T.Logger.errors.SERVER_ERROR,{method:"getGasPrice",result:e,error:t})}}))}getBalance(e,t){return D(this,void 0,void 0,(function*(){yield this.getNetwork();const r=yield Object(g.resolveProperties)({address:this._getAddress(e),blockTag:this._getBlockTag(t)}),n=yield this.perform("getBalance",r);try{return o.a.from(n)}catch(e){return B.throwError("bad result from backend",T.Logger.errors.SERVER_ERROR,{method:"getBalance",params:r,result:n,error:e})}}))}getTransactionCount(e,t){return D(this,void 0,void 0,(function*(){yield this.getNetwork();const r=yield Object(g.resolveProperties)({address:this._getAddress(e),blockTag:this._getBlockTag(t)}),n=yield this.perform("getTransactionCount",r);try{return o.a.from(n).toNumber()}catch(e){return B.throwError("bad result from backend",T.Logger.errors.SERVER_ERROR,{method:"getTransactionCount",params:r,result:n,error:e})}}))}getCode(e,t){return D(this,void 0,void 0,(function*(){yield this.getNetwork();const r=yield Object(g.resolveProperties)({address:this._getAddress(e),blockTag:this._getBlockTag(t)}),n=yield this.perform("getCode",r);try{return Object(b.hexlify)(n)}catch(e){return B.throwError("bad result from backend",T.Logger.errors.SERVER_ERROR,{method:"getCode",params:r,result:n,error:e})}}))}getStorageAt(e,t,r){return D(this,void 0,void 0,(function*(){yield this.getNetwork();const n=yield Object(g.resolveProperties)({address:this._getAddress(e),blockTag:this._getBlockTag(r),position:Promise.resolve(t).then((e=>Object(b.hexValue)(e)))}),f=yield this.perform("getStorageAt",n);try{return Object(b.hexlify)(f)}catch(e){return B.throwError("bad result from backend",T.Logger.errors.SERVER_ERROR,{method:"getStorageAt",params:n,result:f,error:e})}}))}_wrapTransaction(e,t,r){if(null!=t&&32!==Object(b.hexDataLength)(t))throw new Error("invalid response - sendTransaction");const n=e;return null!=t&&e.hash!==t&&B.throwError("Transaction hash mismatch from Provider.sendTransaction.",T.Logger.errors.UNKNOWN_ERROR,{expectedHash:e.hash,returnedHash:t}),n.wait=(t,n)=>D(this,void 0,void 0,(function*(){let f;null==t&&(t=1),null==n&&(n=0),0!==t&&null!=r&&(f={data:e.data,from:e.from,nonce:e.nonce,to:e.to,value:e.value,startBlock:r});const a=yield this._waitForTransaction(e.hash,t,n,f);return null==a&&0===t?null:(this._emitted["t:"+e.hash]=a.blockNumber,0===a.status&&B.throwError("transaction failed",T.Logger.errors.CALL_EXCEPTION,{transactionHash:e.hash,transaction:e,receipt:a}),a)})),n}sendTransaction(e){return D(this,void 0,void 0,(function*(){yield this.getNetwork();const t=yield Promise.resolve(e).then((e=>Object(b.hexlify)(e))),r=this.formatter.transaction(e);null==r.confirmations&&(r.confirmations=0);const n=yield this._getInternalBlockNumber(100+2*this.pollingInterval);try{const e=yield this.perform("sendTransaction",{signedTransaction:t});return this._wrapTransaction(r,e,n)}catch(e){throw e.transaction=r,e.transactionHash=r.hash,e}}))}_getTransactionRequest(e){return D(this,void 0,void 0,(function*(){const t=yield e,r={};return["from","to"].forEach((e=>{null!=t[e]&&(r[e]=Promise.resolve(t[e]).then((e=>e?this._getAddress(e):null)))})),["gasLimit","gasPrice","maxFeePerGas","maxPriorityFeePerGas","value"].forEach((e=>{null!=t[e]&&(r[e]=Promise.resolve(t[e]).then((e=>e?o.a.from(e):null)))})),["type"].forEach((e=>{null!=t[e]&&(r[e]=Promise.resolve(t[e]).then((e=>null!=e?e:null)))})),t.accessList&&(r.accessList=this.formatter.accessList(t.accessList)),["data"].forEach((e=>{null!=t[e]&&(r[e]=Promise.resolve(t[e]).then((e=>e?Object(b.hexlify)(e):null)))})),this.formatter.transactionRequest(yield Object(g.resolveProperties)(r))}))}_getFilter(e){return D(this,void 0,void 0,(function*(){e=yield e;const t={};return null!=e.address&&(t.address=this._getAddress(e.address)),["blockHash","topics"].forEach((r=>{null!=e[r]&&(t[r]=e[r])})),["fromBlock","toBlock"].forEach((r=>{null!=e[r]&&(t[r]=this._getBlockTag(e[r]))})),this.formatter.filter(yield Object(g.resolveProperties)(t))}))}call(e,t){return D(this,void 0,void 0,(function*(){yield this.getNetwork();const r=yield Object(g.resolveProperties)({transaction:this._getTransactionRequest(e),blockTag:this._getBlockTag(t)}),n=yield this.perform("call",r);try{return Object(b.hexlify)(n)}catch(e){return B.throwError("bad result from backend",T.Logger.errors.SERVER_ERROR,{method:"call",params:r,result:n,error:e})}}))}estimateGas(e){return D(this,void 0,void 0,(function*(){yield this.getNetwork();const t=yield Object(g.resolveProperties)({transaction:this._getTransactionRequest(e)}),r=yield this.perform("estimateGas",t);try{return o.a.from(r)}catch(e){return B.throwError("bad result from backend",T.Logger.errors.SERVER_ERROR,{method:"estimateGas",params:t,result:r,error:e})}}))}_getAddress(e){return D(this,void 0,void 0,(function*(){"string"!=typeof(e=yield e)&&B.throwArgumentError("invalid address or ENS name","name",e);const t=yield this.resolveName(e);return null==t&&B.throwError("ENS name not configured",T.Logger.errors.UNSUPPORTED_OPERATION,{operation:`resolveName(${JSON.stringify(e)})`}),t}))}_getBlock(e,t){return D(this,void 0,void 0,(function*(){yield this.getNetwork(),e=yield e;let r=-128;const n={includeTransactions:!!t};if(Object(b.isHexString)(e,32))n.blockHash=e;else try{n.blockTag=yield this._getBlockTag(e),Object(b.isHexString)(n.blockTag)&&(r=parseInt(n.blockTag.substring(2),16))}catch(t){B.throwArgumentError("invalid block hash or block tag","blockHashOrBlockTag",e)}return Object(w.poll)((()=>D(this,void 0,void 0,(function*(){const e=yield this.perform("getBlock",n);if(null==e)return null!=n.blockHash&&null==this._emitted["b:"+n.blockHash]||null!=n.blockTag&&r>this._emitted.block?null:void 0;if(t){let t=null;for(let r=0;r<e.transactions.length;r++){const n=e.transactions[r];if(null==n.blockNumber)n.confirmations=0;else if(null==n.confirmations){null==t&&(t=yield this._getInternalBlockNumber(100+2*this.pollingInterval));let e=t-n.blockNumber+1;e<=0&&(e=1),n.confirmations=e}}const r=this.formatter.blockWithTransactions(e);return r.transactions=r.transactions.map((e=>this._wrapTransaction(e))),r}return this.formatter.block(e)}))),{oncePoll:this})}))}getBlock(e){return this._getBlock(e,!1)}getBlockWithTransactions(e){return this._getBlock(e,!0)}getTransaction(e){return D(this,void 0,void 0,(function*(){yield this.getNetwork(),e=yield e;const t={transactionHash:this.formatter.hash(e,!0)};return Object(w.poll)((()=>D(this,void 0,void 0,(function*(){const r=yield this.perform("getTransaction",t);if(null==r)return null==this._emitted["t:"+e]?null:void 0;const n=this.formatter.transactionResponse(r);if(null==n.blockNumber)n.confirmations=0;else if(null==n.confirmations){let e=(yield this._getInternalBlockNumber(100+2*this.pollingInterval))-n.blockNumber+1;e<=0&&(e=1),n.confirmations=e}return this._wrapTransaction(n)}))),{oncePoll:this})}))}getTransactionReceipt(e){return D(this,void 0,void 0,(function*(){yield this.getNetwork(),e=yield e;const t={transactionHash:this.formatter.hash(e,!0)};return Object(w.poll)((()=>D(this,void 0,void 0,(function*(){const r=yield this.perform("getTransactionReceipt",t);if(null==r)return null==this._emitted["t:"+e]?null:void 0;if(null==r.blockHash)return;const n=this.formatter.receipt(r);if(null==n.blockNumber)n.confirmations=0;else if(null==n.confirmations){let e=(yield this._getInternalBlockNumber(100+2*this.pollingInterval))-n.blockNumber+1;e<=0&&(e=1),n.confirmations=e}return n}))),{oncePoll:this})}))}getLogs(e){return D(this,void 0,void 0,(function*(){yield this.getNetwork();const t=yield Object(g.resolveProperties)({filter:this._getFilter(e)}),r=yield this.perform("getLogs",t);return r.forEach((e=>{null==e.removed&&(e.removed=!1)})),P.arrayOf(this.formatter.filterLog.bind(this.formatter))(r)}))}getEtherPrice(){return D(this,void 0,void 0,(function*(){return yield this.getNetwork(),this.perform("getEtherPrice",{})}))}_getBlockTag(e){return D(this,void 0,void 0,(function*(){if("number"==typeof(e=yield e)&&e<0){e%1&&B.throwArgumentError("invalid BlockTag","blockTag",e);let t=yield this._getInternalBlockNumber(100+2*this.pollingInterval);return t+=e,t<0&&(t=0),this.formatter.blockTag(t)}return this.formatter.blockTag(e)}))}getResolver(e){return D(this,void 0,void 0,(function*(){try{const t=yield this._getResolver(e);return null==t?null:new Z(this,t,e)}catch(e){if(e.code===T.Logger.errors.CALL_EXCEPTION)return null;throw e}}))}_getResolver(e){return D(this,void 0,void 0,(function*(){const t=yield this.getNetwork();t.ensAddress||B.throwError("network does not support ENS",T.Logger.errors.UNSUPPORTED_OPERATION,{operation:"ENS",network:t.name});const r={to:t.ensAddress,data:"0x0178b8bf"+Object(y.b)(e).substring(2)};try{return this.formatter.callAddress(yield this.call(r))}catch(e){if(e.code===T.Logger.errors.CALL_EXCEPTION)return null;throw e}}))}resolveName(e){return D(this,void 0,void 0,(function*(){e=yield e;try{return Promise.resolve(this.formatter.address(e))}catch(t){if(Object(b.isHexString)(e))throw t}"string"!=typeof e&&B.throwArgumentError("invalid ENS name","name",e);const t=yield this.getResolver(e);return t?yield t.getAddress():null}))}lookupAddress(e){return D(this,void 0,void 0,(function*(){e=yield e;const t=(e=this.formatter.address(e)).substring(2).toLowerCase()+".addr.reverse",r=yield this._getResolver(t);if(!r)return null;let n=Object(b.arrayify)(yield this.call({to:r,data:"0x691f3431"+Object(y.b)(t).substring(2)}));if(n.length<32||!o.a.from(n.slice(0,32)).eq(32))return null;if(n=n.slice(32),n.length<32)return null;const f=o.a.from(n.slice(0,32)).toNumber();if(n=n.slice(32),f>n.length)return null;const a=Object(_.h)(n.slice(0,f));return(yield this.resolveName(a))!=e?null:a}))}getAvatar(e){return D(this,void 0,void 0,(function*(){let t=null;if(Object(b.isHexString)(e)){const r=this.formatter.address(e),n=r.substring(2).toLowerCase()+".addr.reverse",f=yield this._getResolver(n);if(!f)return null;t=new Z(this,f,"_",r)}else if(t=yield this.getResolver(e),!t)return null;const r=yield t.getAvatar();return null==r?null:r.url}))}perform(e,t){return B.throwError(e+" not implemented",T.Logger.errors.NOT_IMPLEMENTED,{operation:e})}_startEvent(e){this.polling=this._events.filter((e=>e.pollable())).length>0}_stopEvent(e){this.polling=this._events.filter((e=>e.pollable())).length>0}_addEventListener(e,t,r){const n=new $(L(e),t,r);return this._events.push(n),this._startEvent(n),this}on(e,t){return this._addEventListener(e,t,!1)}once(e,t){return this._addEventListener(e,t,!0)}emit(e,...t){let r=!1,n=[],f=L(e);return this._events=this._events.filter((e=>e.tag!==f||(setTimeout((()=>{e.listener.apply(this,t)}),0),r=!0,!e.once||(n.push(e),!1)))),n.forEach((e=>{this._stopEvent(e)})),r}listenerCount(e){if(!e)return this._events.length;let t=L(e);return this._events.filter((e=>e.tag===t)).length}listeners(e){if(null==e)return this._events.map((e=>e.listener));let t=L(e);return this._events.filter((e=>e.tag===t)).map((e=>e.listener))}off(e,t){if(null==t)return this.removeAllListeners(e);const r=[];let n=!1,f=L(e);return this._events=this._events.filter((e=>e.tag!==f||e.listener!=t||(!!n||(n=!0,r.push(e),!1)))),r.forEach((e=>{this._stopEvent(e)})),this}removeAllListeners(e){let t=[];if(null==e)t=this._events,this._events=[];else{const r=L(e);this._events=this._events.filter((e=>e.tag!==r||(t.push(e),!1)))}return t.forEach((e=>{this._stopEvent(e)})),this}}var re=r(190),ne=function(e,t,r,n){return new(r||(r=Promise))((function(f,a){function i(e){try{s(n.next(e))}catch(e){a(e)}}function o(e){try{s(n.throw(e))}catch(e){a(e)}}function s(e){var t;e.done?f(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(i,o)}s((n=n.apply(e,t||[])).next())}))};const fe=new T.Logger(x),ae=["call","estimateGas"];function ie(e,t,r){if("call"===e&&t.code===T.Logger.errors.SERVER_ERROR){const e=t.error;if(e&&e.message.match("reverted")&&Object(b.isHexString)(e.data))return e.data;fe.throwError("missing revert data in call exception",T.Logger.errors.CALL_EXCEPTION,{error:t,data:"0x"})}let n=t.message;t.code===T.Logger.errors.SERVER_ERROR&&t.error&&"string"==typeof t.error.message?n=t.error.message:"string"==typeof t.body?n=t.body:"string"==typeof t.responseText&&(n=t.responseText),n=(n||"").toLowerCase();const f=r.transaction||r.signedTransaction;throw n.match(/insufficient funds|base fee exceeds gas limit/)&&fe.throwError("insufficient funds for intrinsic transaction cost",T.Logger.errors.INSUFFICIENT_FUNDS,{error:t,method:e,transaction:f}),n.match(/nonce too low/)&&fe.throwError("nonce has already been used",T.Logger.errors.NONCE_EXPIRED,{error:t,method:e,transaction:f}),n.match(/replacement transaction underpriced/)&&fe.throwError("replacement fee too low",T.Logger.errors.REPLACEMENT_UNDERPRICED,{error:t,method:e,transaction:f}),n.match(/only replay-protected/)&&fe.throwError("legacy pre-eip-155 transactions not supported",T.Logger.errors.UNSUPPORTED_OPERATION,{error:t,method:e,transaction:f}),ae.indexOf(e)>=0&&n.match(/gas required exceeds allowance|always failing transaction|execution reverted/)&&fe.throwError("cannot estimate gas; transaction may fail or may require manual gas limit",T.Logger.errors.UNPREDICTABLE_GAS_LIMIT,{error:t,method:e,transaction:f}),t}function oe(e){return new Promise((function(t){setTimeout(t,e)}))}function se(e){if(e.error){const t=new Error(e.error.message);throw t.code=e.error.code,t.data=e.error.data,t}return e.result}function ce(e){return e?e.toLowerCase():e}const ue={};class de extends c.a{constructor(e,t,r){if(fe.checkNew(new.target,de),super(),e!==ue)throw new Error("do not call the JsonRpcSigner constructor directly; use provider.getSigner");Object(g.defineReadOnly)(this,"provider",t),null==r&&(r=0),"string"==typeof r?(Object(g.defineReadOnly)(this,"_address",this.provider.formatter.address(r)),Object(g.defineReadOnly)(this,"_index",null)):"number"==typeof r?(Object(g.defineReadOnly)(this,"_index",r),Object(g.defineReadOnly)(this,"_address",null)):fe.throwArgumentError("invalid address or index","addressOrIndex",r)}connect(e){return fe.throwError("cannot alter JSON-RPC Signer connection",T.Logger.errors.UNSUPPORTED_OPERATION,{operation:"connect"})}connectUnchecked(){return new le(ue,this.provider,this._address||this._index)}getAddress(){return this._address?Promise.resolve(this._address):this.provider.send("eth_accounts",[]).then((e=>(e.length<=this._index&&fe.throwError("unknown account #"+this._index,T.Logger.errors.UNSUPPORTED_OPERATION,{operation:"getAddress"}),this.provider.formatter.address(e[this._index]))))}sendUncheckedTransaction(e){e=Object(g.shallowCopy)(e);const t=this.getAddress().then((e=>(e&&(e=e.toLowerCase()),e)));if(null==e.gasLimit){const r=Object(g.shallowCopy)(e);r.from=t,e.gasLimit=this.provider.estimateGas(r)}return null!=e.to&&(e.to=Promise.resolve(e.to).then((e=>ne(this,void 0,void 0,(function*(){if(null==e)return null;const t=yield this.provider.resolveName(e);return null==t&&fe.throwArgumentError("provided ENS name resolves to null","tx.to",e),t}))))),Object(g.resolveProperties)({tx:Object(g.resolveProperties)(e),sender:t}).then((({tx:t,sender:r})=>{null!=t.from?t.from.toLowerCase()!==r&&fe.throwArgumentError("from address mismatch","transaction",e):t.from=r;const n=this.provider.constructor.hexlifyTransaction(t,{from:!0});return this.provider.send("eth_sendTransaction",[n]).then((e=>e),(e=>ie("sendTransaction",e,n)))}))}signTransaction(e){return fe.throwError("signing transactions is unsupported",T.Logger.errors.UNSUPPORTED_OPERATION,{operation:"signTransaction"})}sendTransaction(e){return ne(this,void 0,void 0,(function*(){const t=yield this.provider._getInternalBlockNumber(100+2*this.provider.pollingInterval),r=yield this.sendUncheckedTransaction(e);try{return yield Object(w.poll)((()=>ne(this,void 0,void 0,(function*(){const e=yield this.provider.getTransaction(r);if(null!==e)return this.provider._wrapTransaction(e,r,t)}))),{oncePoll:this.provider})}catch(e){throw e.transactionHash=r,e}}))}signMessage(e){return ne(this,void 0,void 0,(function*(){const t="string"==typeof e?Object(_.f)(e):e,r=yield this.getAddress();return yield this.provider.send("personal_sign",[Object(b.hexlify)(t),r.toLowerCase()])}))}_legacySignMessage(e){return ne(this,void 0,void 0,(function*(){const t="string"==typeof e?Object(_.f)(e):e,r=yield this.getAddress();return yield this.provider.send("eth_sign",[r.toLowerCase(),Object(b.hexlify)(t)])}))}_signTypedData(e,t,r){return ne(this,void 0,void 0,(function*(){const n=yield re.a.resolveNames(e,t,r,(e=>this.provider.resolveName(e))),f=yield this.getAddress();return yield this.provider.send("eth_signTypedData_v4",[f.toLowerCase(),JSON.stringify(re.a.getPayload(n.domain,t,n.value))])}))}unlock(e){return ne(this,void 0,void 0,(function*(){const t=this.provider,r=yield this.getAddress();return t.send("personal_unlockAccount",[r.toLowerCase(),e,null])}))}}class le extends de{sendTransaction(e){return this.sendUncheckedTransaction(e).then((e=>({hash:e,nonce:null,gasLimit:null,gasPrice:null,data:null,value:null,chainId:null,confirmations:0,from:null,wait:t=>this.provider.waitForTransaction(e,t)})))}}const pe={chainId:!0,data:!0,gasLimit:!0,gasPrice:!0,nonce:!0,to:!0,value:!0,type:!0,accessList:!0,maxFeePerGas:!0,maxPriorityFeePerGas:!0};class he extends te{constructor(e,t){fe.checkNew(new.target,he);let r=t;null==r&&(r=new Promise(((e,t)=>{setTimeout((()=>{this.detectNetwork().then((t=>{e(t)}),(e=>{t(e)}))}),0)}))),super(r),e||(e=Object(g.getStatic)(this.constructor,"defaultUrl")()),"string"==typeof e?Object(g.defineReadOnly)(this,"connection",Object.freeze({url:e})):Object(g.defineReadOnly)(this,"connection",Object.freeze(Object(g.shallowCopy)(e))),this._nextId=42}get _cache(){return null==this._eventLoopCache&&(this._eventLoopCache={}),this._eventLoopCache}static defaultUrl(){return"http://localhost:8545"}detectNetwork(){return this._cache.detectNetwork||(this._cache.detectNetwork=this._uncachedDetectNetwork(),setTimeout((()=>{this._cache.detectNetwork=null}),0)),this._cache.detectNetwork}_uncachedDetectNetwork(){return ne(this,void 0,void 0,(function*(){yield oe(0);let e=null;try{e=yield this.send("eth_chainId",[])}catch(t){try{e=yield this.send("net_version",[])}catch(e){}}if(null!=e){const t=Object(g.getStatic)(this.constructor,"getNetwork");try{return t(o.a.from(e).toNumber())}catch(t){return fe.throwError("could not detect network",T.Logger.errors.NETWORK_ERROR,{chainId:e,event:"invalidNetwork",serverError:t})}}return fe.throwError("could not detect network",T.Logger.errors.NETWORK_ERROR,{event:"noNetwork"})}))}getSigner(e){return new de(ue,this,e)}getUncheckedSigner(e){return this.getSigner(e).connectUnchecked()}listAccounts(){return this.send("eth_accounts",[]).then((e=>e.map((e=>this.formatter.address(e)))))}send(e,t){const r={method:e,params:t,id:this._nextId++,jsonrpc:"2.0"};this.emit("debug",{action:"request",request:Object(g.deepCopy)(r),provider:this});const n=["eth_chainId","eth_blockNumber"].indexOf(e)>=0;if(n&&this._cache[e])return this._cache[e];const f=Object(w.fetchJson)(this.connection,JSON.stringify(r),se).then((e=>(this.emit("debug",{action:"response",request:r,response:e,provider:this}),e)),(e=>{throw this.emit("debug",{action:"response",error:e,request:r,provider:this}),e}));return n&&(this._cache[e]=f,setTimeout((()=>{this._cache[e]=null}),0)),f}prepareRequest(e,t){switch(e){case"getBlockNumber":return["eth_blockNumber",[]];case"getGasPrice":return["eth_gasPrice",[]];case"getBalance":return["eth_getBalance",[ce(t.address),t.blockTag]];case"getTransactionCount":return["eth_getTransactionCount",[ce(t.address),t.blockTag]];case"getCode":return["eth_getCode",[ce(t.address),t.blockTag]];case"getStorageAt":return["eth_getStorageAt",[ce(t.address),t.position,t.blockTag]];case"sendTransaction":return["eth_sendRawTransaction",[t.signedTransaction]];case"getBlock":return t.blockTag?["eth_getBlockByNumber",[t.blockTag,!!t.includeTransactions]]:t.blockHash?["eth_getBlockByHash",[t.blockHash,!!t.includeTransactions]]:null;case"getTransaction":return["eth_getTransactionByHash",[t.transactionHash]];case"getTransactionReceipt":return["eth_getTransactionReceipt",[t.transactionHash]];case"call":return["eth_call",[Object(g.getStatic)(this.constructor,"hexlifyTransaction")(t.transaction,{from:!0}),t.blockTag]];case"estimateGas":return["eth_estimateGas",[Object(g.getStatic)(this.constructor,"hexlifyTransaction")(t.transaction,{from:!0})]];case"getLogs":return t.filter&&null!=t.filter.address&&(t.filter.address=ce(t.filter.address)),["eth_getLogs",[t.filter]]}return null}perform(e,t){return ne(this,void 0,void 0,(function*(){if("call"===e||"estimateGas"===e){const e=t.transaction;if(e&&null!=e.type&&o.a.from(e.type).isZero()&&null==e.maxFeePerGas&&null==e.maxPriorityFeePerGas){const r=yield this.getFeeData();null==r.maxFeePerGas&&null==r.maxPriorityFeePerGas&&((t=Object(g.shallowCopy)(t)).transaction=Object(g.shallowCopy)(e),delete t.transaction.type)}}const r=this.prepareRequest(e,t);null==r&&fe.throwError(e+" not implemented",T.Logger.errors.NOT_IMPLEMENTED,{operation:e});try{return yield this.send(r[0],r[1])}catch(r){return ie(e,r,t)}}))}_startEvent(e){"pending"===e.tag&&this._startPending(),super._startEvent(e)}_startPending(){if(null!=this._pendingFilter)return;const e=this,t=this.send("eth_newPendingTransactionFilter",[]);this._pendingFilter=t,t.then((function(r){return function n(){e.send("eth_getFilterChanges",[r]).then((function(r){if(e._pendingFilter!=t)return null;let n=Promise.resolve();return r.forEach((function(t){e._emitted["t:"+t.toLowerCase()]="pending",n=n.then((function(){return e.getTransaction(t).then((function(t){return e.emit("pending",t),null}))}))})),n.then((function(){return oe(1e3)}))})).then((function(){if(e._pendingFilter==t)return setTimeout((function(){n()}),0),null;e.send("eth_uninstallFilter",[r])})).catch((e=>{}))}(),r})).catch((e=>{}))}_stopEvent(e){"pending"===e.tag&&0===this.listenerCount("pending")&&(this._pendingFilter=null),super._stopEvent(e)}static hexlifyTransaction(e,t){const r=Object(g.shallowCopy)(pe);if(t)for(const e in t)t[e]&&(r[e]=!0);Object(g.checkProperties)(e,r);const n={};return["gasLimit","gasPrice","type","maxFeePerGas","maxPriorityFeePerGas","nonce","value"].forEach((function(t){if(null==e[t])return;const r=Object(b.hexValue)(e[t]);"gasLimit"===t&&(t="gas"),n[t]=r})),["from","to","data"].forEach((function(t){null!=e[t]&&(n[t]=Object(b.hexlify)(e[t]))})),e.accessList&&(n.accessList=Object(O.accessListify)(e.accessList)),n}}let be=null;try{if(be=WebSocket,null==be)throw new Error("inject please")}catch(e){const t=new T.Logger(x);be=function(){t.throwError("WebSockets not supported in this environment",T.Logger.errors.UNSUPPORTED_OPERATION,{operation:"new WebSocket()"})}}var me=function(e,t,r,n){return new(r||(r=Promise))((function(f,a){function i(e){try{s(n.next(e))}catch(e){a(e)}}function o(e){try{s(n.throw(e))}catch(e){a(e)}}function s(e){var t;e.done?f(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(i,o)}s((n=n.apply(e,t||[])).next())}))};const ye=new T.Logger(x);let ge=1;class ve extends he{constructor(e,t){"any"===t&&ye.throwError("WebSocketProvider does not support 'any' network yet",T.Logger.errors.UNSUPPORTED_OPERATION,{operation:"network:any"}),super(e,t),this._pollingInterval=-1,this._wsReady=!1,Object(g.defineReadOnly)(this,"_websocket",new be(this.connection.url)),Object(g.defineReadOnly)(this,"_requests",{}),Object(g.defineReadOnly)(this,"_subs",{}),Object(g.defineReadOnly)(this,"_subIds",{}),Object(g.defineReadOnly)(this,"_detectNetwork",super.detectNetwork()),this._websocket.onopen=()=>{this._wsReady=!0,Object.keys(this._requests).forEach((e=>{this._websocket.send(this._requests[e].payload)}))},this._websocket.onmessage=e=>{const t=e.data,r=JSON.parse(t);if(null!=r.id){const e=String(r.id),n=this._requests[e];if(delete this._requests[e],void 0!==r.result)n.callback(null,r.result),this.emit("debug",{action:"response",request:JSON.parse(n.payload),response:r.result,provider:this});else{let e=null;r.error?(e=new Error(r.error.message||"unknown error"),Object(g.defineReadOnly)(e,"code",r.error.code||null),Object(g.defineReadOnly)(e,"response",t)):e=new Error("unknown error"),n.callback(e,void 0),this.emit("debug",{action:"response",error:e,request:JSON.parse(n.payload),provider:this})}}else if("eth_subscription"===r.method){const e=this._subs[r.params.subscription];e&&e.processFunc(r.params.result)}else console.warn("this should not happen")};const r=setInterval((()=>{this.emit("poll")}),1e3);r.unref&&r.unref()}detectNetwork(){return this._detectNetwork}get pollingInterval(){return 0}resetEventsBlock(e){ye.throwError("cannot reset events block on WebSocketProvider",T.Logger.errors.UNSUPPORTED_OPERATION,{operation:"resetEventBlock"})}set pollingInterval(e){ye.throwError("cannot set polling interval on WebSocketProvider",T.Logger.errors.UNSUPPORTED_OPERATION,{operation:"setPollingInterval"})}poll(){return me(this,void 0,void 0,(function*(){return null}))}set polling(e){e&&ye.throwError("cannot set polling on WebSocketProvider",T.Logger.errors.UNSUPPORTED_OPERATION,{operation:"setPolling"})}send(e,t){const r=ge++;return new Promise(((n,f)=>{const a=JSON.stringify({method:e,params:t,id:r,jsonrpc:"2.0"});this.emit("debug",{action:"request",request:JSON.parse(a),provider:this}),this._requests[String(r)]={callback:function(e,t){return e?f(e):n(t)},payload:a},this._wsReady&&this._websocket.send(a)}))}static defaultUrl(){return"ws://localhost:8546"}_subscribe(e,t,r){return me(this,void 0,void 0,(function*(){let n=this._subIds[e];null==n&&(n=Promise.all(t).then((e=>this.send("eth_subscribe",e))),this._subIds[e]=n);const f=yield n;this._subs[f]={tag:e,processFunc:r}}))}_startEvent(e){switch(e.type){case"block":this._subscribe("block",["newHeads"],(e=>{const t=o.a.from(e.number).toNumber();this._emitted.block=t,this.emit("block",t)}));break;case"pending":this._subscribe("pending",["newPendingTransactions"],(e=>{this.emit("pending",e)}));break;case"filter":this._subscribe(e.tag,["logs",this._getFilter(e.filter)],(t=>{null==t.removed&&(t.removed=!1),this.emit(e.filter,this.formatter.filterLog(t))}));break;case"tx":{const t=e=>{const t=e.hash;this.getTransactionReceipt(t).then((e=>{e&&this.emit(t,e)}))};t(e),this._subscribe("tx",["newHeads"],(e=>{this._events.filter((e=>"tx"===e.type)).forEach(t)}));break}case"debug":case"poll":case"willPoll":case"didPoll":case"error":break;default:console.log("unhandled:",e)}}_stopEvent(e){let t=e.tag;if("tx"===e.type){if(this._events.filter((e=>"tx"===e.type)).length)return;t="tx"}else if(this.listenerCount(e.event))return;const r=this._subIds[t];r&&(delete this._subIds[t],r.then((e=>{this._subs[e]&&(delete this._subs[e],this.send("eth_unsubscribe",[e]))})))}destroy(){return me(this,void 0,void 0,(function*(){this._websocket.readyState===be.CONNECTING&&(yield new Promise((e=>{this._websocket.onopen=function(){e(!0)},this._websocket.onerror=function(){e(!1)}}))),this._websocket.close(1e3)}))}}var _e=function(e,t,r,n){return new(r||(r=Promise))((function(f,a){function i(e){try{s(n.next(e))}catch(e){a(e)}}function o(e){try{s(n.throw(e))}catch(e){a(e)}}function s(e){var t;e.done?f(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(i,o)}s((n=n.apply(e,t||[])).next())}))};const we=new T.Logger(x);class Ee extends he{detectNetwork(){const e=Object.create(null,{detectNetwork:{get:()=>super.detectNetwork}});return _e(this,void 0,void 0,(function*(){let t=this.network;return null==t&&(t=yield e.detectNetwork.call(this),t||we.throwError("no network detected",T.Logger.errors.UNKNOWN_ERROR,{}),null==this._network&&(Object(g.defineReadOnly)(this,"_network",t),this.emit("network",t,null))),t}))}}class Ae extends Ee{constructor(e,t){we.checkAbstract(new.target,Ae),e=Object(g.getStatic)(new.target,"getNetwork")(e),t=Object(g.getStatic)(new.target,"getApiKey")(t);super(Object(g.getStatic)(new.target,"getUrl")(e,t),e),"string"==typeof t?Object(g.defineReadOnly)(this,"apiKey",t):null!=t&&Object.keys(t).forEach((e=>{Object(g.defineReadOnly)(this,e,t[e])}))}_startPending(){we.warn("WARNING: API provider does not support pending filters")}isCommunityResource(){return!1}getSigner(e){return we.throwError("API provider does not support signing",T.Logger.errors.UNSUPPORTED_OPERATION,{operation:"getSigner"})}listAccounts(){return Promise.resolve([])}static getApiKey(e){return e}static getUrl(e,t){return we.throwError("not implemented; sub-classes must override getUrl",T.Logger.errors.NOT_IMPLEMENTED,{operation:"getUrl"})}}const Te=new T.Logger(x),xe="_gg7wSSi0KMBsdKnGVfHDueq6xMB9EkC";class ke extends ve{constructor(e,t){const r=new Se(e,t);super(r.connection.url.replace(/^http/i,"ws").replace(".alchemyapi.",".ws.alchemyapi."),r.network),Object(g.defineReadOnly)(this,"apiKey",r.apiKey)}isCommunityResource(){return this.apiKey===xe}}class Se extends Ae{static getWebSocketProvider(e,t){return new ke(e,t)}static getApiKey(e){return null==e?xe:(e&&"string"!=typeof e&&Te.throwArgumentError("invalid apiKey","apiKey",e),e)}static getUrl(e,t){let r=null;switch(e.name){case"homestead":r="eth-mainnet.alchemyapi.io/v2/";break;case"ropsten":r="eth-ropsten.alchemyapi.io/v2/";break;case"rinkeby":r="eth-rinkeby.alchemyapi.io/v2/";break;case"goerli":r="eth-goerli.alchemyapi.io/v2/";break;case"kovan":r="eth-kovan.alchemyapi.io/v2/";break;case"matic":r="polygon-mainnet.g.alchemy.com/v2/";break;case"maticmum":r="polygon-mumbai.g.alchemy.com/v2/";break;case"arbitrum":r="arb-mainnet.g.alchemy.com/v2/";break;case"arbitrum-rinkeby":r="arb-rinkeby.g.alchemy.com/v2/";break;case"optimism":r="opt-mainnet.g.alchemy.com/v2/";break;case"optimism-kovan":r="opt-kovan.g.alchemy.com/v2/";break;default:Te.throwArgumentError("unsupported network","network",arguments[0])}return{allowGzip:!0,url:"https://"+r+t,throttleCallback:(e,r)=>(t===xe&&M(),Promise.resolve(!0))}}isCommunityResource(){return this.apiKey===xe}}var Oe=function(e,t,r,n){return new(r||(r=Promise))((function(f,a){function i(e){try{s(n.next(e))}catch(e){a(e)}}function o(e){try{s(n.throw(e))}catch(e){a(e)}}function s(e){var t;e.done?f(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(i,o)}s((n=n.apply(e,t||[])).next())}))};const Ce=new T.Logger(x);class Pe extends Ae{static getApiKey(e){return null!=e&&Ce.throwArgumentError("apiKey not supported for cloudflare","apiKey",e),null}static getUrl(e,t){let r=null;if("homestead"===e.name)r="https://cloudflare-eth.com/";else Ce.throwArgumentError("unsupported network","network",arguments[0]);return r}perform(e,t){const r=Object.create(null,{perform:{get:()=>super.perform}});return Oe(this,void 0,void 0,(function*(){if("getBlockNumber"===e){return(yield r.perform.call(this,"getBlock",{blockTag:"latest"})).number}return r.perform.call(this,e,t)}))}}var Re=function(e,t,r,n){return new(r||(r=Promise))((function(f,a){function i(e){try{s(n.next(e))}catch(e){a(e)}}function o(e){try{s(n.throw(e))}catch(e){a(e)}}function s(e){var t;e.done?f(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(i,o)}s((n=n.apply(e,t||[])).next())}))};const Ne=new T.Logger(x);function Ie(e){const t={};for(let r in e){if(null==e[r])continue;let n=e[r];"type"===r&&0===n||(n={type:!0,gasLimit:!0,gasPrice:!0,maxFeePerGs:!0,maxPriorityFeePerGas:!0,nonce:!0,value:!0}[r]?Object(b.hexValue)(Object(b.hexlify)(n)):"accessList"===r?"["+Object(O.accessListify)(n).map((e=>`{address:"${e.address}",storageKeys:["${e.storageKeys.join('","')}"]}`)).join(",")+"]":Object(b.hexlify)(n),t[r]=n)}return t}function Me(e){if(0==e.status&&("No records found"===e.message||"No transactions found"===e.message))return e.result;if(1!=e.status||"OK"!=e.message){const t=new Error("invalid response");throw t.result=JSON.stringify(e),(e.result||"").toLowerCase().indexOf("rate limit")>=0&&(t.throttleRetry=!0),t}return e.result}function De(e){if(e&&0==e.status&&"NOTOK"==e.message&&(e.result||"").toLowerCase().indexOf("rate limit")>=0){const t=new Error("throttled response");throw t.result=JSON.stringify(e),t.throttleRetry=!0,t}if("2.0"!=e.jsonrpc){const t=new Error("invalid response");throw t.result=JSON.stringify(e),t}if(e.error){const t=new Error(e.error.message||"unknown error");throw e.error.code&&(t.code=e.error.code),e.error.data&&(t.data=e.error.data),t}return e.result}function Be(e){if("pending"===e)throw new Error("pending not supported");return"latest"===e?e:parseInt(e.substring(2),16)}const Fe="9D13ZE7XSBTJ94N9BNJ2MA33VMAY2YPIRB";function je(e,t,r){if("call"===e&&t.code===T.Logger.errors.SERVER_ERROR){const e=t.error;if(e&&(e.message.match(/reverted/i)||e.message.match(/VM execution error/i))){let r=e.data;if(r&&(r="0x"+r.replace(/^.*0x/i,"")),Object(b.isHexString)(r))return r;Ne.throwError("missing revert data in call exception",T.Logger.errors.CALL_EXCEPTION,{error:t,data:"0x"})}}let n=t.message;throw t.code===T.Logger.errors.SERVER_ERROR&&(t.error&&"string"==typeof t.error.message?n=t.error.message:"string"==typeof t.body?n=t.body:"string"==typeof t.responseText&&(n=t.responseText)),n=(n||"").toLowerCase(),n.match(/insufficient funds/)&&Ne.throwError("insufficient funds for intrinsic transaction cost",T.Logger.errors.INSUFFICIENT_FUNDS,{error:t,method:e,transaction:r}),n.match(/same hash was already imported|transaction nonce is too low|nonce too low/)&&Ne.throwError("nonce has already been used",T.Logger.errors.NONCE_EXPIRED,{error:t,method:e,transaction:r}),n.match(/another transaction with same nonce/)&&Ne.throwError("replacement fee too low",T.Logger.errors.REPLACEMENT_UNDERPRICED,{error:t,method:e,transaction:r}),n.match(/execution failed due to an exception|execution reverted/)&&Ne.throwError("cannot estimate gas; transaction may fail or may require manual gas limit",T.Logger.errors.UNPREDICTABLE_GAS_LIMIT,{error:t,method:e,transaction:r}),t}class Le extends te{constructor(e,t){Ne.checkNew(new.target,Le),super(e),Object(g.defineReadOnly)(this,"baseUrl",this.getBaseUrl()),Object(g.defineReadOnly)(this,"apiKey",t||Fe)}getBaseUrl(){switch(this.network?this.network.name:"invalid"){case"homestead":return"https://api.etherscan.io";case"ropsten":return"https://api-ropsten.etherscan.io";case"rinkeby":return"https://api-rinkeby.etherscan.io";case"kovan":return"https://api-kovan.etherscan.io";case"goerli":return"https://api-goerli.etherscan.io"}return Ne.throwArgumentError("unsupported network","network",name)}getUrl(e,t){const r=Object.keys(t).reduce(((e,r)=>{const n=t[r];return null!=n&&(e+=`&${r}=${n}`),e}),""),n=this.apiKey?`&apikey=${this.apiKey}`:"";return`${this.baseUrl}/api?module=${e}${r}${n}`}getPostUrl(){return`${this.baseUrl}/api`}getPostData(e,t){return t.module=e,t.apikey=this.apiKey,t}fetch(e,t,r){return Re(this,void 0,void 0,(function*(){const n=r?this.getPostUrl():this.getUrl(e,t),f=r?this.getPostData(e,t):null,a="proxy"===e?De:Me;this.emit("debug",{action:"request",request:n,provider:this});const i={url:n,throttleSlotInterval:1e3,throttleCallback:(e,t)=>(this.isCommunityResource()&&M(),Promise.resolve(!0))};let o=null;f&&(i.headers={"content-type":"application/x-www-form-urlencoded; charset=UTF-8"},o=Object.keys(f).map((e=>`${e}=${f[e]}`)).join("&"));const s=yield Object(w.fetchJson)(i,o,a||De);return this.emit("debug",{action:"response",request:n,response:Object(g.deepCopy)(s),provider:this}),s}))}detectNetwork(){return Re(this,void 0,void 0,(function*(){return this.network}))}perform(e,t){const r=Object.create(null,{perform:{get:()=>super.perform}});return Re(this,void 0,void 0,(function*(){switch(e){case"getBlockNumber":return this.fetch("proxy",{action:"eth_blockNumber"});case"getGasPrice":return this.fetch("proxy",{action:"eth_gasPrice"});case"getBalance":return this.fetch("account",{action:"balance",address:t.address,tag:t.blockTag});case"getTransactionCount":return this.fetch("proxy",{action:"eth_getTransactionCount",address:t.address,tag:t.blockTag});case"getCode":return this.fetch("proxy",{action:"eth_getCode",address:t.address,tag:t.blockTag});case"getStorageAt":return this.fetch("proxy",{action:"eth_getStorageAt",address:t.address,position:t.position,tag:t.blockTag});case"sendTransaction":return this.fetch("proxy",{action:"eth_sendRawTransaction",hex:t.signedTransaction},!0).catch((e=>je("sendTransaction",e,t.signedTransaction)));case"getBlock":if(t.blockTag)return this.fetch("proxy",{action:"eth_getBlockByNumber",tag:t.blockTag,boolean:t.includeTransactions?"true":"false"});throw new Error("getBlock by blockHash not implemented");case"getTransaction":return this.fetch("proxy",{action:"eth_getTransactionByHash",txhash:t.transactionHash});case"getTransactionReceipt":return this.fetch("proxy",{action:"eth_getTransactionReceipt",txhash:t.transactionHash});case"call":{if("latest"!==t.blockTag)throw new Error("EtherscanProvider does not support blockTag for call");const e=Ie(t.transaction);e.module="proxy",e.action="eth_call";try{return yield this.fetch("proxy",e,!0)}catch(e){return je("call",e,t.transaction)}}case"estimateGas":{const e=Ie(t.transaction);e.module="proxy",e.action="eth_estimateGas";try{return yield this.fetch("proxy",e,!0)}catch(e){return je("estimateGas",e,t.transaction)}}case"getLogs":{const e={action:"getLogs"};if(t.filter.fromBlock&&(e.fromBlock=Be(t.filter.fromBlock)),t.filter.toBlock&&(e.toBlock=Be(t.filter.toBlock)),t.filter.address&&(e.address=t.filter.address),t.filter.topics&&t.filter.topics.length>0&&(t.filter.topics.length>1&&Ne.throwError("unsupported topic count",T.Logger.errors.UNSUPPORTED_OPERATION,{topics:t.filter.topics}),1===t.filter.topics.length)){const r=t.filter.topics[0];"string"==typeof r&&66===r.length||Ne.throwError("unsupported topic format",T.Logger.errors.UNSUPPORTED_OPERATION,{topic0:r}),e.topic0=r}const r=yield this.fetch("logs",e);let n={};for(let e=0;e<r.length;e++){const t=r[e];if(null==t.blockHash){if(null==n[t.blockNumber]){const e=yield this.getBlock(t.blockNumber);e&&(n[t.blockNumber]=e.hash)}t.blockHash=n[t.blockNumber]}}return r}case"getEtherPrice":return"homestead"!==this.network.name?0:parseFloat((yield this.fetch("stats",{action:"ethprice"})).ethusd)}return r.perform.call(this,e,t)}))}getHistory(e,t,r){return Re(this,void 0,void 0,(function*(){const n={action:"txlist",address:yield this.resolveName(e),startblock:null==t?0:t,endblock:null==r?99999999:r,sort:"asc"};return(yield this.fetch("account",n)).map((e=>{["contractAddress","to"].forEach((function(t){""==e[t]&&delete e[t]})),null==e.creates&&null!=e.contractAddress&&(e.creates=e.contractAddress);const t=this.formatter.transactionResponse(e);return e.timeStamp&&(t.timestamp=parseInt(e.timeStamp)),t}))}))}isCommunityResource(){return this.apiKey===Fe}}var Ue=r(192),qe=function(e,t,r,n){return new(r||(r=Promise))((function(f,a){function i(e){try{s(n.next(e))}catch(e){a(e)}}function o(e){try{s(n.throw(e))}catch(e){a(e)}}function s(e){var t;e.done?f(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(i,o)}s((n=n.apply(e,t||[])).next())}))};const He=new T.Logger(x);function $e(){return(new Date).getTime()}function ze(e){let t=null;for(let r=0;r<e.length;r++){const n=e[r];if(null==n)return null;t?t.name===n.name&&t.chainId===n.chainId&&(t.ensAddress===n.ensAddress||null==t.ensAddress&&null==n.ensAddress)||He.throwArgumentError("provider mismatch","networks",e):t=n}return t}function Ve(e,t){e=e.slice().sort();const r=Math.floor(e.length/2);if(e.length%2)return e[r];const n=e[r-1],f=e[r];return null!=t&&Math.abs(n-f)>t?null:(n+f)/2}function Ge(e){if(null===e)return"null";if("number"==typeof e||"boolean"==typeof e)return JSON.stringify(e);if("string"==typeof e)return e;if(o.a.isBigNumber(e))return e.toString();if(Array.isArray(e))return JSON.stringify(e.map((e=>Ge(e))));if("object"==typeof e){const t=Object.keys(e);return t.sort(),"{"+t.map((t=>{let r=e[t];return r="function"==typeof r?"[function]":Ge(r),JSON.stringify(t)+":"+r})).join(",")+"}"}throw new Error("unknown value type: "+typeof e)}let Ke=1;function We(e){let t=null,r=null,n=new Promise((n=>{t=function(){r&&(clearTimeout(r),r=null),n()},r=setTimeout(t,e)}));return{cancel:t,getPromise:function(){return n},wait:e=>(n=n.then(e),n)}}const Ye=[T.Logger.errors.CALL_EXCEPTION,T.Logger.errors.INSUFFICIENT_FUNDS,T.Logger.errors.NONCE_EXPIRED,T.Logger.errors.REPLACEMENT_UNDERPRICED,T.Logger.errors.UNPREDICTABLE_GAS_LIMIT],Je=["address","args","errorArgs","errorSignature","method","transaction"];function Xe(e,t){const r={weight:e.weight};return Object.defineProperty(r,"provider",{get:()=>e.provider}),e.start&&(r.start=e.start),t&&(r.duration=t-e.start),e.done&&(e.error?r.error=e.error:r.result=e.result||null),r}function Ze(e,t,r){let n=Ge;switch(t){case"getBlockNumber":return function(t){const r=t.map((e=>e.result));let n=Ve(t.map((e=>e.result)),2);if(null!=n)return n=Math.ceil(n),r.indexOf(n+1)>=0&&n++,n>=e._highestBlockNumber&&(e._highestBlockNumber=n),e._highestBlockNumber};case"getGasPrice":return function(e){const t=e.map((e=>e.result));return t.sort(),t[Math.floor(t.length/2)]};case"getEtherPrice":return function(e){return Ve(e.map((e=>e.result)))};case"getBalance":case"getTransactionCount":case"getCode":case"getStorageAt":case"call":case"estimateGas":case"getLogs":break;case"getTransaction":case"getTransactionReceipt":n=function(e){return null==e?null:((e=Object(g.shallowCopy)(e)).confirmations=-1,Ge(e))};break;case"getBlock":n=r.includeTransactions?function(e){return null==e?null:((e=Object(g.shallowCopy)(e)).transactions=e.transactions.map((e=>((e=Object(g.shallowCopy)(e)).confirmations=-1,e))),Ge(e))}:function(e){return null==e?null:Ge(e)};break;default:throw new Error("unknown method: "+t)}return function(e,t){return function(r){const n={};r.forEach((t=>{const r=e(t.result);n[r]||(n[r]={count:0,result:t.result}),n[r].count++}));const f=Object.keys(n);for(let e=0;e<f.length;e++){const r=n[f[e]];if(r.count>=t)return r.result}}}(n,e.quorum)}function Qe(e,t){return qe(this,void 0,void 0,(function*(){const r=e.provider;return null!=r.blockNumber&&r.blockNumber>=t||-1===t?r:Object(w.poll)((()=>new Promise(((n,f)=>{setTimeout((function(){return r.blockNumber>=t?n(r):e.cancelled?n(null):n(void 0)}),0)}))),{oncePoll:r})}))}function et(e,t,r,n){return qe(this,void 0,void 0,(function*(){let f=e.provider;switch(r){case"getBlockNumber":case"getGasPrice":return f[r]();case"getEtherPrice":if(f.getEtherPrice)return f.getEtherPrice();break;case"getBalance":case"getTransactionCount":case"getCode":return n.blockTag&&Object(b.isHexString)(n.blockTag)&&(f=yield Qe(e,t)),f[r](n.address,n.blockTag||"latest");case"getStorageAt":return n.blockTag&&Object(b.isHexString)(n.blockTag)&&(f=yield Qe(e,t)),f.getStorageAt(n.address,n.position,n.blockTag||"latest");case"getBlock":return n.blockTag&&Object(b.isHexString)(n.blockTag)&&(f=yield Qe(e,t)),f[n.includeTransactions?"getBlockWithTransactions":"getBlock"](n.blockTag||n.blockHash);case"call":case"estimateGas":return n.blockTag&&Object(b.isHexString)(n.blockTag)&&(f=yield Qe(e,t)),f[r](n.transaction);case"getTransaction":case"getTransactionReceipt":return f[r](n.transactionHash);case"getLogs":{let r=n.filter;return(r.fromBlock&&Object(b.isHexString)(r.fromBlock)||r.toBlock&&Object(b.isHexString)(r.toBlock))&&(f=yield Qe(e,t)),f.getLogs(r)}}return He.throwError("unknown method error",T.Logger.errors.UNKNOWN_ERROR,{method:r,params:n})}))}class tt extends te{constructor(e,t){He.checkNew(new.target,tt),0===e.length&&He.throwArgumentError("missing providers","providers",e);const r=e.map(((e,t)=>{if(l.b.isProvider(e)){const t=N(e)?2e3:750,r=1;return Object.freeze({provider:e,weight:1,stallTimeout:t,priority:r})}const r=Object(g.shallowCopy)(e);null==r.priority&&(r.priority=1),null==r.stallTimeout&&(r.stallTimeout=N(e)?2e3:750),null==r.weight&&(r.weight=1);const n=r.weight;return(n%1||n>512||n<1)&&He.throwArgumentError("invalid weight; must be integer in [1, 512]",`providers[${t}].weight`,n),Object.freeze(r)})),n=r.reduce(((e,t)=>e+t.weight),0);null==t?t=n/2:t>n&&He.throwArgumentError("quorum will always fail; larger than total weight","quorum",t);let f=ze(r.map((e=>e.provider.network)));null==f&&(f=new Promise(((e,t)=>{setTimeout((()=>{this.detectNetwork().then(e,t)}),0)}))),super(f),Object(g.defineReadOnly)(this,"providerConfigs",Object.freeze(r)),Object(g.defineReadOnly)(this,"quorum",t),this._highestBlockNumber=-1}detectNetwork(){return qe(this,void 0,void 0,(function*(){return ze(yield Promise.all(this.providerConfigs.map((e=>e.provider.getNetwork()))))}))}perform(e,t){return qe(this,void 0,void 0,(function*(){if("sendTransaction"===e){const e=yield Promise.all(this.providerConfigs.map((e=>e.provider.sendTransaction(t.signedTransaction).then((e=>e.hash),(e=>e)))));for(let t=0;t<e.length;t++){const r=e[t];if("string"==typeof r)return r}throw e[0]}-1===this._highestBlockNumber&&"getBlockNumber"!==e&&(yield this.getBlockNumber());const r=Ze(this,e,t),n=Object(Ue.a)(this.providerConfigs.map(g.shallowCopy));n.sort(((e,t)=>e.priority-t.priority));const f=this._highestBlockNumber;let a=0,i=!0;for(;;){const o=$e();let s=n.filter((e=>e.runner&&o-e.start<e.stallTimeout)).reduce(((e,t)=>e+t.weight),0);for(;s<this.quorum&&a<n.length;){const r=n[a++],i=Ke++;r.start=$e(),r.staller=We(r.stallTimeout),r.staller.wait((()=>{r.staller=null})),r.runner=et(r,f,e,t).then((n=>{r.done=!0,r.result=n,this.listenerCount("debug")&&this.emit("debug",{action:"request",rid:i,backend:Xe(r,$e()),request:{method:e,params:Object(g.deepCopy)(t)},provider:this})}),(n=>{r.done=!0,r.error=n,this.listenerCount("debug")&&this.emit("debug",{action:"request",rid:i,backend:Xe(r,$e()),request:{method:e,params:Object(g.deepCopy)(t)},provider:this})})),this.listenerCount("debug")&&this.emit("debug",{action:"request",rid:i,backend:Xe(r,null),request:{method:e,params:Object(g.deepCopy)(t)},provider:this}),s+=r.weight}const c=[];n.forEach((e=>{!e.done&&e.runner&&(c.push(e.runner),e.staller&&c.push(e.staller.getPromise()))})),c.length&&(yield Promise.race(c));const u=n.filter((e=>e.done&&null==e.error));if(u.length>=this.quorum){const e=r(u);if(void 0!==e)return n.forEach((e=>{e.staller&&e.staller.cancel(),e.cancelled=!0})),e;i||(yield We(100).getPromise()),i=!1}const d=n.reduce(((e,t)=>{if(!t.done||null==t.error)return e;const r=t.error.code;return Ye.indexOf(r)>=0&&(e[r]||(e[r]={error:t.error,weight:0}),e[r].weight+=t.weight),e}),{});if(Object.keys(d).forEach((e=>{const t=d[e];if(t.weight<this.quorum)return;n.forEach((e=>{e.staller&&e.staller.cancel(),e.cancelled=!0}));const r=t.error,f={};Je.forEach((e=>{null!=r[e]&&(f[e]=r[e])})),He.throwError(r.reason||r.message,e,f)})),0===n.filter((e=>!e.done)).length)break}return n.forEach((e=>{e.staller&&e.staller.cancel(),e.cancelled=!0})),He.throwError("failed to meet quorum",T.Logger.errors.SERVER_ERROR,{method:e,params:t,results:n.map((e=>Xe(e))),provider:this})}))}}const rt=null,nt=new T.Logger(x),ft="84842078b09946638c03157f83405213";class at extends ve{constructor(e,t){const r=new it(e,t),n=r.connection;n.password&&nt.throwError("INFURA WebSocket project secrets unsupported",T.Logger.errors.UNSUPPORTED_OPERATION,{operation:"InfuraProvider.getWebSocketProvider()"});super(n.url.replace(/^http/i,"ws").replace("/v3/","/ws/v3/"),e),Object(g.defineReadOnly)(this,"apiKey",r.projectId),Object(g.defineReadOnly)(this,"projectId",r.projectId),Object(g.defineReadOnly)(this,"projectSecret",r.projectSecret)}isCommunityResource(){return this.projectId===ft}}class it extends Ae{static getWebSocketProvider(e,t){return new at(e,t)}static getApiKey(e){const t={apiKey:ft,projectId:ft,projectSecret:null};return null==e||("string"==typeof e?t.projectId=e:null!=e.projectSecret?(nt.assertArgument("string"==typeof e.projectId,"projectSecret requires a projectId","projectId",e.projectId),nt.assertArgument("string"==typeof e.projectSecret,"invalid projectSecret","projectSecret","[REDACTED]"),t.projectId=e.projectId,t.projectSecret=e.projectSecret):e.projectId&&(t.projectId=e.projectId),t.apiKey=t.projectId),t}static getUrl(e,t){let r=null;switch(e?e.name:"unknown"){case"homestead":r="mainnet.infura.io";break;case"ropsten":r="ropsten.infura.io";break;case"rinkeby":r="rinkeby.infura.io";break;case"kovan":r="kovan.infura.io";break;case"goerli":r="goerli.infura.io";break;case"matic":r="polygon-mainnet.infura.io";break;case"maticmum":r="polygon-mumbai.infura.io";break;case"optimism":r="optimism-mainnet.infura.io";break;case"optimism-kovan":r="optimism-kovan.infura.io";break;case"arbitrum":r="arbitrum-mainnet.infura.io";break;case"arbitrum-rinkeby":r="arbitrum-rinkeby.infura.io";break;default:nt.throwError("unsupported network",T.Logger.errors.INVALID_ARGUMENT,{argument:"network",value:e})}const n={allowGzip:!0,url:"https://"+r+"/v3/"+t.projectId,throttleCallback:(e,r)=>(t.projectId===ft&&M(),Promise.resolve(!0))};return null!=t.projectSecret&&(n.user="",n.password=t.projectSecret),n}isCommunityResource(){return this.projectId===ft}}class ot extends he{send(e,t){const r={method:e,params:t,id:this._nextId++,jsonrpc:"2.0"};null==this._pendingBatch&&(this._pendingBatch=[]);const n={request:r,resolve:null,reject:null},f=new Promise(((e,t)=>{n.resolve=e,n.reject=t}));return this._pendingBatch.push(n),this._pendingBatchAggregator||(this._pendingBatchAggregator=setTimeout((()=>{const e=this._pendingBatch;this._pendingBatch=null,this._pendingBatchAggregator=null;const t=e.map((e=>e.request));return this.emit("debug",{action:"requestBatch",request:Object(g.deepCopy)(t),provider:this}),Object(w.fetchJson)(this.connection,JSON.stringify(t)).then((r=>{this.emit("debug",{action:"response",request:t,response:r,provider:this}),e.forEach(((e,t)=>{const n=r[t];if(n.error){const t=new Error(n.error.message);t.code=n.error.code,t.data=n.error.data,e.reject(t)}else e.resolve(n.result)}))}),(r=>{this.emit("debug",{action:"response",error:r,request:t,provider:this}),e.forEach((e=>{e.reject(r)}))}))}),10)),f}}const st=new T.Logger(x);class ct extends Ae{static getApiKey(e){return e&&"string"!=typeof e&&st.throwArgumentError("invalid apiKey","apiKey",e),e||"ETHERS_JS_SHARED"}static getUrl(e,t){st.warn("NodeSmith will be discontinued on 2019-12-20; please migrate to another platform.");let r=null;switch(e.name){case"homestead":r="https://ethereum.api.nodesmith.io/v1/mainnet/jsonrpc";break;case"ropsten":r="https://ethereum.api.nodesmith.io/v1/ropsten/jsonrpc";break;case"rinkeby":r="https://ethereum.api.nodesmith.io/v1/rinkeby/jsonrpc";break;case"goerli":r="https://ethereum.api.nodesmith.io/v1/goerli/jsonrpc";break;case"kovan":r="https://ethereum.api.nodesmith.io/v1/kovan/jsonrpc";break;default:st.throwArgumentError("unsupported network","network",arguments[0])}return r+"?apiKey="+t}}const ut=new T.Logger(x),dt={homestead:"6004bcd10040261633ade990",ropsten:"6004bd4d0040261633ade991",rinkeby:"6004bda20040261633ade994",goerli:"6004bd860040261633ade992"};class lt extends Ae{constructor(e,t){if(null==t){const r=Object(g.getStatic)(new.target,"getNetwork")(e);if(r){const e=dt[r.name];e&&(t={applicationId:e,loadBalancer:!0})}null==t&&ut.throwError("unsupported network",T.Logger.errors.INVALID_ARGUMENT,{argument:"network",value:e})}super(e,t)}static getApiKey(e){null==e&&ut.throwArgumentError("PocketProvider.getApiKey does not support null apiKey","apiKey",e);const t={applicationId:null,loadBalancer:!1,applicationSecretKey:null};return"string"==typeof e?t.applicationId=e:null!=e.applicationSecretKey?(ut.assertArgument("string"==typeof e.applicationId,"applicationSecretKey requires an applicationId","applicationId",e.applicationId),ut.assertArgument("string"==typeof e.applicationSecretKey,"invalid applicationSecretKey","applicationSecretKey","[REDACTED]"),t.applicationId=e.applicationId,t.applicationSecretKey=e.applicationSecretKey,t.loadBalancer=!!e.loadBalancer):e.applicationId?(ut.assertArgument("string"==typeof e.applicationId,"apiKey.applicationId must be a string","apiKey.applicationId",e.applicationId),t.applicationId=e.applicationId,t.loadBalancer=!!e.loadBalancer):ut.throwArgumentError("unsupported PocketProvider apiKey","apiKey",e),t}static getUrl(e,t){let r=null;switch(e?e.name:"unknown"){case"homestead":r="eth-mainnet.gateway.pokt.network";break;case"ropsten":r="eth-ropsten.gateway.pokt.network";break;case"rinkeby":r="eth-rinkeby.gateway.pokt.network";break;case"goerli":r="eth-goerli.gateway.pokt.network";break;default:ut.throwError("unsupported network",T.Logger.errors.INVALID_ARGUMENT,{argument:"network",value:e})}let n=null;n=t.loadBalancer?`https://${r}/v1/lb/${t.applicationId}`:`https://${r}/v1/${t.applicationId}`;const f={url:n,headers:{}};return null!=t.applicationSecretKey&&(f.user="",f.password=t.applicationSecretKey),f}isCommunityResource(){return this.applicationId===dt[this.network.name]}}const pt=new T.Logger(x);let ht=1;function bt(e,t){const r="Web3LegacyFetcher";return function(e,n){const f={method:e,params:n,id:ht++,jsonrpc:"2.0"};return new Promise(((e,n)=>{this.emit("debug",{action:"request",fetcher:r,request:Object(g.deepCopy)(f),provider:this}),t(f,((t,a)=>{if(t)return this.emit("debug",{action:"response",fetcher:r,error:t,request:f,provider:this}),n(t);if(this.emit("debug",{action:"response",fetcher:r,request:f,response:a,provider:this}),a.error){const e=new Error(a.error.message);return e.code=a.error.code,e.data=a.error.data,n(e)}e(a.result)}))}))}}class mt extends he{constructor(e,t){pt.checkNew(new.target,mt),null==e&&pt.throwArgumentError("missing provider","provider",e);let r=null,n=null,f=null;"function"==typeof e?(r="unknown:",n=e):(r=e.host||e.path||"",!r&&e.isMetaMask&&(r="metamask"),f=e,e.request?(""===r&&(r="eip-1193:"),n=function(e){return function(t,r){null==r&&(r=[]);const n={method:t,params:r};return this.emit("debug",{action:"request",fetcher:"Eip1193Fetcher",request:Object(g.deepCopy)(n),provider:this}),e.request(n).then((e=>(this.emit("debug",{action:"response",fetcher:"Eip1193Fetcher",request:n,response:e,provider:this}),e)),(e=>{throw this.emit("debug",{action:"response",fetcher:"Eip1193Fetcher",request:n,error:e,provider:this}),e}))}}(e)):e.sendAsync?n=bt(0,e.sendAsync.bind(e)):e.send?n=bt(0,e.send.bind(e)):pt.throwArgumentError("unsupported provider","provider",e),r||(r="unknown:")),super(r,t),Object(g.defineReadOnly)(this,"jsonRpcFetchFunc",n),Object(g.defineReadOnly)(this,"provider",f)}send(e,t){return this.jsonRpcFetchFunc(e,t)}}const yt=new T.Logger(x);function gt(e,t){if(null==e&&(e="homestead"),"string"==typeof e){const t=e.match(/^(ws|http)s?:/i);if(t)switch(t[1]){case"http":return new he(e);case"ws":return new ve(e);default:yt.throwArgumentError("unsupported URL scheme","network",e)}}const r=Object(p.a)(e);return r&&r._defaultProvider||yt.throwError("unsupported getDefaultProvider network",T.Logger.errors.NETWORK_ERROR,{operation:"getDefaultProvider",network:e}),r._defaultProvider({FallbackProvider:tt,AlchemyProvider:Se,CloudflareProvider:Pe,EtherscanProvider:Le,InfuraProvider:it,JsonRpcProvider:he,NodesmithProvider:ct,PocketProvider:lt,Web3Provider:mt,IpcProvider:rt},t)}var vt=r(860),_t=r(129);const wt="abi/5.5.0",Et=new T.Logger(wt);function At(e){const t=[],r=function(e,n){if(Array.isArray(n))for(let f in n){const a=e.slice();a.push(f);try{r(a,n[f])}catch(e){t.push({path:a,error:e})}}};return r([],e),t}class Tt{constructor(e,t,r,n){this.name=e,this.type=t,this.localName=r,this.dynamic=n}_throwError(e,t){Et.throwArgumentError(e,this.localName,t)}}class xt{constructor(e){Object(g.defineReadOnly)(this,"wordSize",e||32),this._data=[],this._dataLength=0,this._padding=new Uint8Array(e)}get data(){return Object(b.hexConcat)(this._data)}get length(){return this._dataLength}_writeData(e){return this._data.push(e),this._dataLength+=e.length,e.length}appendWriter(e){return this._writeData(Object(b.concat)(e._data))}writeBytes(e){let t=Object(b.arrayify)(e);const r=t.length%this.wordSize;return r&&(t=Object(b.concat)([t,this._padding.slice(r)])),this._writeData(t)}_getValue(e){let t=Object(b.arrayify)(o.a.from(e));return t.length>this.wordSize&&Et.throwError("value out-of-bounds",T.Logger.errors.BUFFER_OVERRUN,{length:this.wordSize,offset:t.length}),t.length%this.wordSize&&(t=Object(b.concat)([this._padding.slice(t.length%this.wordSize),t])),t}writeValue(e){return this._writeData(this._getValue(e))}writeUpdatableValue(){const e=this._data.length;return this._data.push(this._padding),this._dataLength+=this.wordSize,t=>{this._data[e]=this._getValue(t)}}}class kt{constructor(e,t,r,n){Object(g.defineReadOnly)(this,"_data",Object(b.arrayify)(e)),Object(g.defineReadOnly)(this,"wordSize",t||32),Object(g.defineReadOnly)(this,"_coerceFunc",r),Object(g.defineReadOnly)(this,"allowLoose",n),this._offset=0}get data(){return Object(b.hexlify)(this._data)}get consumed(){return this._offset}static coerce(e,t){let r=e.match("^u?int([0-9]+)$");return r&&parseInt(r[1])<=48&&(t=t.toNumber()),t}coerce(e,t){return this._coerceFunc?this._coerceFunc(e,t):kt.coerce(e,t)}_peekBytes(e,t,r){let n=Math.ceil(t/this.wordSize)*this.wordSize;return this._offset+n>this._data.length&&(this.allowLoose&&r&&this._offset+t<=this._data.length?n=t:Et.throwError("data out-of-bounds",T.Logger.errors.BUFFER_OVERRUN,{length:this._data.length,offset:this._offset+n})),this._data.slice(this._offset,this._offset+n)}subReader(e){return new kt(this._data.slice(this._offset+e),this.wordSize,this._coerceFunc,this.allowLoose)}readBytes(e,t){let r=this._peekBytes(0,e,!!t);return this._offset+=r.length,r.slice(0,e)}readValue(){return o.a.from(this.readBytes(this.wordSize))}}class St extends Tt{constructor(e){super("address","address",e,!1)}defaultValue(){return"0x0000000000000000000000000000000000000000"}encode(e,t){try{t=Object(k.getAddress)(t)}catch(e){this._throwError(e.message,t)}return e.writeValue(t)}decode(e){return Object(k.getAddress)(Object(b.hexZeroPad)(e.readValue().toHexString(),20))}}class Ot extends Tt{constructor(e){super(e.name,e.type,void 0,e.dynamic),this.coder=e}defaultValue(){return this.coder.defaultValue()}encode(e,t){return this.coder.encode(e,t)}decode(e){return this.coder.decode(e)}}const Ct=new T.Logger(wt);function Pt(e,t,r){let n=null;if(Array.isArray(r))n=r;else if(r&&"object"==typeof r){let e={};n=t.map((t=>{const n=t.localName;return n||Ct.throwError("cannot encode object for signature with missing names",T.Logger.errors.INVALID_ARGUMENT,{argument:"values",coder:t,value:r}),e[n]&&Ct.throwError("cannot encode object for signature with duplicate names",T.Logger.errors.INVALID_ARGUMENT,{argument:"values",coder:t,value:r}),e[n]=!0,r[n]}))}else Ct.throwArgumentError("invalid tuple value","tuple",r);t.length!==n.length&&Ct.throwArgumentError("types/value length mismatch","tuple",r);let f=new xt(e.wordSize),a=new xt(e.wordSize),i=[];t.forEach(((e,t)=>{let r=n[t];if(e.dynamic){let t=a.length;e.encode(a,r);let n=f.writeUpdatableValue();i.push((e=>{n(e+t)}))}else e.encode(f,r)})),i.forEach((e=>{e(f.length)}));let o=e.appendWriter(f);return o+=e.appendWriter(a),o}function Rt(e,t){let r=[],n=e.subReader(0);t.forEach((t=>{let f=null;if(t.dynamic){let r=e.readValue(),a=n.subReader(r.toNumber());try{f=t.decode(a)}catch(e){if(e.code===T.Logger.errors.BUFFER_OVERRUN)throw e;f=e,f.baseType=t.name,f.name=t.localName,f.type=t.type}}else try{f=t.decode(e)}catch(e){if(e.code===T.Logger.errors.BUFFER_OVERRUN)throw e;f=e,f.baseType=t.name,f.name=t.localName,f.type=t.type}null!=f&&r.push(f)}));const f=t.reduce(((e,t)=>{const r=t.localName;return r&&(e[r]||(e[r]=0),e[r]++),e}),{});t.forEach(((e,t)=>{let n=e.localName;if(!n||1!==f[n])return;if("length"===n&&(n="_length"),null!=r[n])return;const a=r[t];a instanceof Error?Object.defineProperty(r,n,{enumerable:!0,get:()=>{throw a}}):r[n]=a}));for(let e=0;e<r.length;e++){const t=r[e];t instanceof Error&&Object.defineProperty(r,e,{enumerable:!0,get:()=>{throw t}})}return Object.freeze(r)}class Nt extends Tt{constructor(e,t,r){super("array",e.type+"["+(t>=0?t:"")+"]",r,-1===t||e.dynamic),this.coder=e,this.length=t}defaultValue(){const e=this.coder.defaultValue(),t=[];for(let r=0;r<this.length;r++)t.push(e);return t}encode(e,t){Array.isArray(t)||this._throwError("expected array value",t);let r=this.length;-1===r&&(r=t.length,e.writeValue(t.length)),Ct.checkArgumentCount(t.length,r,"coder array"+(this.localName?" "+this.localName:""));let n=[];for(let e=0;e<t.length;e++)n.push(this.coder);return Pt(e,n,t)}decode(e){let t=this.length;-1===t&&(t=e.readValue().toNumber(),32*t>e._data.length&&Ct.throwError("insufficient data length",T.Logger.errors.BUFFER_OVERRUN,{length:e._data.length,count:t}));let r=[];for(let e=0;e<t;e++)r.push(new Ot(this.coder));return e.coerce(this.name,Rt(e,r))}}class It extends Tt{constructor(e){super("bool","bool",e,!1)}defaultValue(){return!1}encode(e,t){return e.writeValue(t?1:0)}decode(e){return e.coerce(this.type,!e.readValue().isZero())}}class Mt extends Tt{constructor(e,t){super(e,e,t,!0)}defaultValue(){return"0x"}encode(e,t){t=Object(b.arrayify)(t);let r=e.writeValue(t.length);return r+=e.writeBytes(t),r}decode(e){return e.readBytes(e.readValue().toNumber(),!0)}}class Dt extends Mt{constructor(e){super("bytes",e)}decode(e){return e.coerce(this.name,Object(b.hexlify)(super.decode(e)))}}class Bt extends Tt{constructor(e,t){let r="bytes"+String(e);super(r,r,t,!1),this.size=e}defaultValue(){return"0x0000000000000000000000000000000000000000000000000000000000000000".substring(0,2+2*this.size)}encode(e,t){let r=Object(b.arrayify)(t);return r.length!==this.size&&this._throwError("incorrect data length",t),e.writeBytes(r)}decode(e){return e.coerce(this.name,Object(b.hexlify)(e.readBytes(this.size)))}}class Ft extends Tt{constructor(e){super("null","",e,!1)}defaultValue(){return null}encode(e,t){return null!=t&&this._throwError("not null",t),e.writeBytes([])}decode(e){return e.readBytes(0),e.coerce(this.name,null)}}var jt=r(55);class Lt extends Tt{constructor(e,t,r){const n=(t?"int":"uint")+8*e;super(n,n,r,!1),this.size=e,this.signed=t}defaultValue(){return 0}encode(e,t){let r=o.a.from(t),n=jt.b.mask(8*e.wordSize);if(this.signed){let e=n.mask(8*this.size-1);(r.gt(e)||r.lt(e.add(jt.e).mul(jt.d)))&&this._throwError("value out-of-bounds",t)}else(r.lt(jt.h)||r.gt(n.mask(8*this.size)))&&this._throwError("value out-of-bounds",t);return r=r.toTwos(8*this.size).mask(8*this.size),this.signed&&(r=r.fromTwos(8*this.size).toTwos(8*e.wordSize)),e.writeValue(r)}decode(e){let t=e.readValue().mask(8*this.size);return this.signed&&(t=t.fromTwos(8*this.size)),e.coerce(this.name,t)}}class Ut extends Mt{constructor(e){super("string",e)}defaultValue(){return""}encode(e,t){return super.encode(e,Object(_.f)(t))}decode(e){return Object(_.h)(super.decode(e))}}class qt extends Tt{constructor(e,t){let r=!1;const n=[];e.forEach((e=>{e.dynamic&&(r=!0),n.push(e.type)}));super("tuple","tuple("+n.join(",")+")",t,r),this.coders=e}defaultValue(){const e=[];this.coders.forEach((t=>{e.push(t.defaultValue())}));const t=this.coders.reduce(((e,t)=>{const r=t.localName;return r&&(e[r]||(e[r]=0),e[r]++),e}),{});return this.coders.forEach(((r,n)=>{let f=r.localName;f&&1===t[f]&&("length"===f&&(f="_length"),null==e[f]&&(e[f]=e[n]))})),Object.freeze(e)}encode(e,t){return Pt(e,this.coders,t)}decode(e){return e.coerce(this.name,Rt(e,this.coders))}}const Ht=new T.Logger(wt),$t={};let zt={calldata:!0,memory:!0,storage:!0},Vt={calldata:!0,memory:!0};function Gt(e,t){if("bytes"===e||"string"===e){if(zt[t])return!0}else if("address"===e){if("payable"===t)return!0}else if((e.indexOf("[")>=0||"tuple"===e)&&Vt[t])return!0;return(zt[t]||"payable"===t)&&Ht.throwArgumentError("invalid modifier","name",t),!1}function Kt(e,t){for(let r in t)Object(g.defineReadOnly)(e,r,t[r])}const Wt=Object.freeze({sighash:"sighash",minimal:"minimal",full:"full",json:"json"}),Yt=new RegExp(/^(.*)\[([0-9]*)\]$/);class Jt{constructor(e,t){e!==$t&&Ht.throwError("use fromString",T.Logger.errors.UNSUPPORTED_OPERATION,{operation:"new ParamType()"}),Kt(this,t);let r=this.type.match(Yt);Kt(this,r?{arrayLength:parseInt(r[2]||"-1"),arrayChildren:Jt.fromObject({type:r[1],components:this.components}),baseType:"array"}:{arrayLength:null,arrayChildren:null,baseType:null!=this.components?"tuple":this.type}),this._isParamType=!0,Object.freeze(this)}format(e){if(e||(e=Wt.sighash),Wt[e]||Ht.throwArgumentError("invalid format type","format",e),e===Wt.json){let t={type:"tuple"===this.baseType?"tuple":this.type,name:this.name||void 0};return"boolean"==typeof this.indexed&&(t.indexed=this.indexed),this.components&&(t.components=this.components.map((t=>JSON.parse(t.format(e))))),JSON.stringify(t)}let t="";return"array"===this.baseType?(t+=this.arrayChildren.format(e),t+="["+(this.arrayLength<0?"":String(this.arrayLength))+"]"):"tuple"===this.baseType?(e!==Wt.sighash&&(t+=this.type),t+="("+this.components.map((t=>t.format(e))).join(e===Wt.full?", ":",")+")"):t+=this.type,e!==Wt.sighash&&(!0===this.indexed&&(t+=" indexed"),e===Wt.full&&this.name&&(t+=" "+this.name)),t}static from(e,t){return"string"==typeof e?Jt.fromString(e,t):Jt.fromObject(e)}static fromObject(e){return Jt.isParamType(e)?e:new Jt($t,{name:e.name||null,type:or(e.type),indexed:null==e.indexed?null:!!e.indexed,components:e.components?e.components.map(Jt.fromObject):null})}static fromString(e,t){return r=function(e,t){let r=e;function n(t){Ht.throwArgumentError(`unexpected character at position ${t}`,"param",e)}function f(e){let r={type:"",name:"",parent:e,state:{allowType:!0}};return t&&(r.indexed=!1),r}e=e.replace(/\s/g," ");let a={type:"",name:"",state:{allowType:!0}},i=a;for(let r=0;r<e.length;r++){let a=e[r];switch(a){case"(":i.state.allowType&&""===i.type?i.type="tuple":i.state.allowParams||n(r),i.state.allowType=!1,i.type=or(i.type),i.components=[f(i)],i=i.components[0];break;case")":delete i.state,"indexed"===i.name&&(t||n(r),i.indexed=!0,i.name=""),Gt(i.type,i.name)&&(i.name=""),i.type=or(i.type);let e=i;i=i.parent,i||n(r),delete e.parent,i.state.allowParams=!1,i.state.allowName=!0,i.state.allowArray=!0;break;case",":delete i.state,"indexed"===i.name&&(t||n(r),i.indexed=!0,i.name=""),Gt(i.type,i.name)&&(i.name=""),i.type=or(i.type);let o=f(i.parent);i.parent.components.push(o),delete i.parent,i=o;break;case" ":i.state.allowType&&""!==i.type&&(i.type=or(i.type),delete i.state.allowType,i.state.allowName=!0,i.state.allowParams=!0),i.state.allowName&&""!==i.name&&("indexed"===i.name?(t||n(r),i.indexed&&n(r),i.indexed=!0,i.name=""):Gt(i.type,i.name)?i.name="":i.state.allowName=!1);break;case"[":i.state.allowArray||n(r),i.type+=a,i.state.allowArray=!1,i.state.allowName=!1,i.state.readArray=!0;break;case"]":i.state.readArray||n(r),i.type+=a,i.state.readArray=!1,i.state.allowArray=!0,i.state.allowName=!0;break;default:i.state.allowType?(i.type+=a,i.state.allowParams=!0,i.state.allowArray=!0):i.state.allowName?(i.name+=a,delete i.state.allowArray):i.state.readArray?i.type+=a:n(r)}}return i.parent&&Ht.throwArgumentError("unexpected eof","param",e),delete a.state,"indexed"===i.name?(t||n(r.length-7),i.indexed&&n(r.length-7),i.indexed=!0,i.name=""):Gt(i.type,i.name)&&(i.name=""),a.type=or(a.type),a}(e,!!t),Jt.fromObject({name:r.name,type:r.type,indexed:r.indexed,components:r.components});var r}static isParamType(e){return!(null==e||!e._isParamType)}}function Xt(e,t){return function(e){e=e.trim();let t=[],r="",n=0;for(let f=0;f<e.length;f++){let a=e[f];","===a&&0===n?(t.push(r),r=""):(r+=a,"("===a?n++:")"===a&&(n--,-1===n&&Ht.throwArgumentError("unbalanced parenthesis","value",e)))}r&&t.push(r);return t}(e).map((e=>Jt.fromString(e,t)))}class Zt{constructor(e,t){e!==$t&&Ht.throwError("use a static from method",T.Logger.errors.UNSUPPORTED_OPERATION,{operation:"new Fragment()"}),Kt(this,t),this._isFragment=!0,Object.freeze(this)}static from(e){return Zt.isFragment(e)?e:"string"==typeof e?Zt.fromString(e):Zt.fromObject(e)}static fromObject(e){if(Zt.isFragment(e))return e;switch(e.type){case"function":return fr.fromObject(e);case"event":return Qt.fromObject(e);case"constructor":return nr.fromObject(e);case"error":return ir.fromObject(e);case"fallback":case"receive":return null}return Ht.throwArgumentError("invalid fragment object","value",e)}static fromString(e){return"event"===(e=(e=(e=e.replace(/\s/g," ")).replace(/\(/g," (").replace(/\)/g,") ").replace(/\s+/g," ")).trim()).split(" ")[0]?Qt.fromString(e.substring(5).trim()):"function"===e.split(" ")[0]?fr.fromString(e.substring(8).trim()):"constructor"===e.split("(")[0].trim()?nr.fromString(e.trim()):"error"===e.split(" ")[0]?ir.fromString(e.substring(5).trim()):Ht.throwArgumentError("unsupported fragment","value",e)}static isFragment(e){return!(!e||!e._isFragment)}}class Qt extends Zt{format(e){if(e||(e=Wt.sighash),Wt[e]||Ht.throwArgumentError("invalid format type","format",e),e===Wt.json)return JSON.stringify({type:"event",anonymous:this.anonymous,name:this.name,inputs:this.inputs.map((t=>JSON.parse(t.format(e))))});let t="";return e!==Wt.sighash&&(t+="event "),t+=this.name+"("+this.inputs.map((t=>t.format(e))).join(e===Wt.full?", ":",")+") ",e!==Wt.sighash&&this.anonymous&&(t+="anonymous "),t.trim()}static from(e){return"string"==typeof e?Qt.fromString(e):Qt.fromObject(e)}static fromObject(e){if(Qt.isEventFragment(e))return e;"event"!==e.type&&Ht.throwArgumentError("invalid event object","value",e);const t={name:cr(e.name),anonymous:e.anonymous,inputs:e.inputs?e.inputs.map(Jt.fromObject):[],type:"event"};return new Qt($t,t)}static fromString(e){let t=e.match(ur);t||Ht.throwArgumentError("invalid event string","value",e);let r=!1;return t[3].split(" ").forEach((e=>{switch(e.trim()){case"anonymous":r=!0;break;case"":break;default:Ht.warn("unknown modifier: "+e)}})),Qt.fromObject({name:t[1].trim(),anonymous:r,inputs:Xt(t[2],!0),type:"event"})}static isEventFragment(e){return e&&e._isFragment&&"event"===e.type}}function er(e,t){t.gas=null;let r=e.split("@");return 1!==r.length?(r.length>2&&Ht.throwArgumentError("invalid human-readable ABI signature","value",e),r[1].match(/^[0-9]+$/)||Ht.throwArgumentError("invalid human-readable ABI signature gas","value",e),t.gas=o.a.from(r[1]),r[0]):e}function tr(e,t){t.constant=!1,t.payable=!1,t.stateMutability="nonpayable",e.split(" ").forEach((e=>{switch(e.trim()){case"constant":t.constant=!0;break;case"payable":t.payable=!0,t.stateMutability="payable";break;case"nonpayable":t.payable=!1,t.stateMutability="nonpayable";break;case"pure":t.constant=!0,t.stateMutability="pure";break;case"view":t.constant=!0,t.stateMutability="view";break;case"external":case"public":case"":break;default:console.log("unknown modifier: "+e)}}))}function rr(e){let t={constant:!1,payable:!0,stateMutability:"payable"};return null!=e.stateMutability?(t.stateMutability=e.stateMutability,t.constant="view"===t.stateMutability||"pure"===t.stateMutability,null!=e.constant&&!!e.constant!==t.constant&&Ht.throwArgumentError("cannot have constant function with mutability "+t.stateMutability,"value",e),t.payable="payable"===t.stateMutability,null!=e.payable&&!!e.payable!==t.payable&&Ht.throwArgumentError("cannot have payable function with mutability "+t.stateMutability,"value",e)):null!=e.payable?(t.payable=!!e.payable,null!=e.constant||t.payable||"constructor"===e.type||Ht.throwArgumentError("unable to determine stateMutability","value",e),t.constant=!!e.constant,t.constant?t.stateMutability="view":t.stateMutability=t.payable?"payable":"nonpayable",t.payable&&t.constant&&Ht.throwArgumentError("cannot have constant payable function","value",e)):null!=e.constant?(t.constant=!!e.constant,t.payable=!t.constant,t.stateMutability=t.constant?"view":"payable"):"constructor"!==e.type&&Ht.throwArgumentError("unable to determine stateMutability","value",e),t}class nr extends Zt{format(e){if(e||(e=Wt.sighash),Wt[e]||Ht.throwArgumentError("invalid format type","format",e),e===Wt.json)return JSON.stringify({type:"constructor",stateMutability:"nonpayable"!==this.stateMutability?this.stateMutability:void 0,payable:this.payable,gas:this.gas?this.gas.toNumber():void 0,inputs:this.inputs.map((t=>JSON.parse(t.format(e))))});e===Wt.sighash&&Ht.throwError("cannot format a constructor for sighash",T.Logger.errors.UNSUPPORTED_OPERATION,{operation:"format(sighash)"});let t="constructor("+this.inputs.map((t=>t.format(e))).join(e===Wt.full?", ":",")+") ";return this.stateMutability&&"nonpayable"!==this.stateMutability&&(t+=this.stateMutability+" "),t.trim()}static from(e){return"string"==typeof e?nr.fromString(e):nr.fromObject(e)}static fromObject(e){if(nr.isConstructorFragment(e))return e;"constructor"!==e.type&&Ht.throwArgumentError("invalid constructor object","value",e);let t=rr(e);t.constant&&Ht.throwArgumentError("constructor cannot be constant","value",e);const r={name:null,type:e.type,inputs:e.inputs?e.inputs.map(Jt.fromObject):[],payable:t.payable,stateMutability:t.stateMutability,gas:e.gas?o.a.from(e.gas):null};return new nr($t,r)}static fromString(e){let t={type:"constructor"},r=(e=er(e,t)).match(ur);return r&&"constructor"===r[1].trim()||Ht.throwArgumentError("invalid constructor string","value",e),t.inputs=Xt(r[2].trim(),!1),tr(r[3].trim(),t),nr.fromObject(t)}static isConstructorFragment(e){return e&&e._isFragment&&"constructor"===e.type}}class fr extends nr{format(e){if(e||(e=Wt.sighash),Wt[e]||Ht.throwArgumentError("invalid format type","format",e),e===Wt.json)return JSON.stringify({type:"function",name:this.name,constant:this.constant,stateMutability:"nonpayable"!==this.stateMutability?this.stateMutability:void 0,payable:this.payable,gas:this.gas?this.gas.toNumber():void 0,inputs:this.inputs.map((t=>JSON.parse(t.format(e)))),outputs:this.outputs.map((t=>JSON.parse(t.format(e))))});let t="";return e!==Wt.sighash&&(t+="function "),t+=this.name+"("+this.inputs.map((t=>t.format(e))).join(e===Wt.full?", ":",")+") ",e!==Wt.sighash&&(this.stateMutability?"nonpayable"!==this.stateMutability&&(t+=this.stateMutability+" "):this.constant&&(t+="view "),this.outputs&&this.outputs.length&&(t+="returns ("+this.outputs.map((t=>t.format(e))).join(", ")+") "),null!=this.gas&&(t+="@"+this.gas.toString()+" ")),t.trim()}static from(e){return"string"==typeof e?fr.fromString(e):fr.fromObject(e)}static fromObject(e){if(fr.isFunctionFragment(e))return e;"function"!==e.type&&Ht.throwArgumentError("invalid function object","value",e);let t=rr(e);const r={type:e.type,name:cr(e.name),constant:t.constant,inputs:e.inputs?e.inputs.map(Jt.fromObject):[],outputs:e.outputs?e.outputs.map(Jt.fromObject):[],payable:t.payable,stateMutability:t.stateMutability,gas:e.gas?o.a.from(e.gas):null};return new fr($t,r)}static fromString(e){let t={type:"function"},r=(e=er(e,t)).split(" returns ");r.length>2&&Ht.throwArgumentError("invalid function string","value",e);let n=r[0].match(ur);if(n||Ht.throwArgumentError("invalid function signature","value",e),t.name=n[1].trim(),t.name&&cr(t.name),t.inputs=Xt(n[2],!1),tr(n[3].trim(),t),r.length>1){let n=r[1].match(ur);""==n[1].trim()&&""==n[3].trim()||Ht.throwArgumentError("unexpected tokens","value",e),t.outputs=Xt(n[2],!1)}else t.outputs=[];return fr.fromObject(t)}static isFunctionFragment(e){return e&&e._isFragment&&"function"===e.type}}function ar(e){const t=e.format();return"Error(string)"!==t&&"Panic(uint256)"!==t||Ht.throwArgumentError(`cannot specify user defined ${t} error`,"fragment",e),e}class ir extends Zt{format(e){if(e||(e=Wt.sighash),Wt[e]||Ht.throwArgumentError("invalid format type","format",e),e===Wt.json)return JSON.stringify({type:"error",name:this.name,inputs:this.inputs.map((t=>JSON.parse(t.format(e))))});let t="";return e!==Wt.sighash&&(t+="error "),t+=this.name+"("+this.inputs.map((t=>t.format(e))).join(e===Wt.full?", ":",")+") ",t.trim()}static from(e){return"string"==typeof e?ir.fromString(e):ir.fromObject(e)}static fromObject(e){if(ir.isErrorFragment(e))return e;"error"!==e.type&&Ht.throwArgumentError("invalid error object","value",e);const t={type:e.type,name:cr(e.name),inputs:e.inputs?e.inputs.map(Jt.fromObject):[]};return ar(new ir($t,t))}static fromString(e){let t={type:"error"},r=e.match(ur);return r||Ht.throwArgumentError("invalid error signature","value",e),t.name=r[1].trim(),t.name&&cr(t.name),t.inputs=Xt(r[2],!1),ar(ir.fromObject(t))}static isErrorFragment(e){return e&&e._isFragment&&"error"===e.type}}function or(e){return e.match(/^uint($|[^1-9])/)?e="uint256"+e.substring(4):e.match(/^int($|[^1-9])/)&&(e="int256"+e.substring(3)),e}const sr=new RegExp("^[a-zA-Z$_][a-zA-Z0-9$_]*$");function cr(e){return e&&e.match(sr)||Ht.throwArgumentError(`invalid identifier "${e}"`,"value",e),e}const ur=new RegExp("^([^)(]*)\\((.*)\\)([^)(]*)$");const dr=new T.Logger(wt),lr=new RegExp(/^bytes([0-9]*)$/),pr=new RegExp(/^(u?int)([0-9]*)$/);class hr{constructor(e){dr.checkNew(new.target,hr),Object(g.defineReadOnly)(this,"coerceFunc",e||null)}_getCoder(e){switch(e.baseType){case"address":return new St(e.name);case"bool":return new It(e.name);case"string":return new Ut(e.name);case"bytes":return new Dt(e.name);case"array":return new Nt(this._getCoder(e.arrayChildren),e.arrayLength,e.name);case"tuple":return new qt((e.components||[]).map((e=>this._getCoder(e))),e.name);case"":return new Ft(e.name)}let t=e.type.match(pr);if(t){let r=parseInt(t[2]||"256");return(0===r||r>256||r%8!=0)&&dr.throwArgumentError("invalid "+t[1]+" bit length","param",e),new Lt(r/8,"int"===t[1],e.name)}if(t=e.type.match(lr),t){let r=parseInt(t[1]);return(0===r||r>32)&&dr.throwArgumentError("invalid bytes length","param",e),new Bt(r,e.name)}return dr.throwArgumentError("invalid type","type",e.type)}_getWordSize(){return 32}_getReader(e,t){return new kt(e,this._getWordSize(),this.coerceFunc,t)}_getWriter(){return new xt(this._getWordSize())}getDefaultValue(e){const t=e.map((e=>this._getCoder(Jt.from(e))));return new qt(t,"_").defaultValue()}encode(e,t){e.length!==t.length&&dr.throwError("types/values length mismatch",T.Logger.errors.INVALID_ARGUMENT,{count:{types:e.length,values:t.length},value:{types:e,values:t}});const r=e.map((e=>this._getCoder(Jt.from(e)))),n=new qt(r,"_"),f=this._getWriter();return n.encode(f,t),f.data}decode(e,t,r){const n=e.map((e=>this._getCoder(Jt.from(e))));return new qt(n,"_").decode(this._getReader(Object(b.arrayify)(t),r))}}const br=new hr;var mr=r(57),yr=r(28),gr=r.n(yr);function vr(e){return"0x"+gr.a.keccak_256(Object(b.arrayify)(e))}const _r=new T.Logger(wt);class wr extends g.Description{}class Er extends g.Description{}class Ar extends g.Description{}class Tr extends g.Description{static isIndexed(e){return!(!e||!e._isIndexed)}}const xr={"0x08c379a0":{signature:"Error(string)",name:"Error",inputs:["string"],reason:!0},"0x4e487b71":{signature:"Panic(uint256)",name:"Panic",inputs:["uint256"]}};function kr(e,t){const r=new Error(`deferred error during ABI decoding triggered accessing ${e}`);return r.error=t,r}class Sr{constructor(e){_r.checkNew(new.target,Sr);let t=[];t="string"==typeof e?JSON.parse(e):e,Object(g.defineReadOnly)(this,"fragments",t.map((e=>Zt.from(e))).filter((e=>null!=e))),Object(g.defineReadOnly)(this,"_abiCoder",Object(g.getStatic)(new.target,"getAbiCoder")()),Object(g.defineReadOnly)(this,"functions",{}),Object(g.defineReadOnly)(this,"errors",{}),Object(g.defineReadOnly)(this,"events",{}),Object(g.defineReadOnly)(this,"structs",{}),this.fragments.forEach((e=>{let t=null;switch(e.type){case"constructor":return this.deploy?void _r.warn("duplicate definition - constructor"):void Object(g.defineReadOnly)(this,"deploy",e);case"function":t=this.functions;break;case"event":t=this.events;break;case"error":t=this.errors;break;default:return}let r=e.format();t[r]?_r.warn("duplicate definition - "+r):t[r]=e})),this.deploy||Object(g.defineReadOnly)(this,"deploy",nr.from({payable:!1,type:"constructor"})),Object(g.defineReadOnly)(this,"_isInterface",!0)}format(e){e||(e=Wt.full),e===Wt.sighash&&_r.throwArgumentError("interface does not support formatting sighash","format",e);const t=this.fragments.map((t=>t.format(e)));return e===Wt.json?JSON.stringify(t.map((e=>JSON.parse(e)))):t}static getAbiCoder(){return br}static getAddress(e){return Object(k.getAddress)(e)}static getSighash(e){return Object(b.hexDataSlice)(Object(mr.a)(e.format()),0,4)}static getEventTopic(e){return Object(mr.a)(e.format())}getFunction(e){if(Object(b.isHexString)(e)){for(const t in this.functions)if(e===this.getSighash(t))return this.functions[t];_r.throwArgumentError("no matching function","sighash",e)}if(-1===e.indexOf("(")){const t=e.trim(),r=Object.keys(this.functions).filter((e=>e.split("(")[0]===t));return 0===r.length?_r.throwArgumentError("no matching function","name",t):r.length>1&&_r.throwArgumentError("multiple matching functions","name",t),this.functions[r[0]]}const t=this.functions[fr.fromString(e).format()];return t||_r.throwArgumentError("no matching function","signature",e),t}getEvent(e){if(Object(b.isHexString)(e)){const t=e.toLowerCase();for(const e in this.events)if(t===this.getEventTopic(e))return this.events[e];_r.throwArgumentError("no matching event","topichash",t)}if(-1===e.indexOf("(")){const t=e.trim(),r=Object.keys(this.events).filter((e=>e.split("(")[0]===t));return 0===r.length?_r.throwArgumentError("no matching event","name",t):r.length>1&&_r.throwArgumentError("multiple matching events","name",t),this.events[r[0]]}const t=this.events[Qt.fromString(e).format()];return t||_r.throwArgumentError("no matching event","signature",e),t}getError(e){if(Object(b.isHexString)(e)){const t=Object(g.getStatic)(this.constructor,"getSighash");for(const r in this.errors){if(e===t(this.errors[r]))return this.errors[r]}_r.throwArgumentError("no matching error","sighash",e)}if(-1===e.indexOf("(")){const t=e.trim(),r=Object.keys(this.errors).filter((e=>e.split("(")[0]===t));return 0===r.length?_r.throwArgumentError("no matching error","name",t):r.length>1&&_r.throwArgumentError("multiple matching errors","name",t),this.errors[r[0]]}const t=this.errors[fr.fromString(e).format()];return t||_r.throwArgumentError("no matching error","signature",e),t}getSighash(e){if("string"==typeof e)try{e=this.getFunction(e)}catch(t){try{e=this.getError(e)}catch(e){throw t}}return Object(g.getStatic)(this.constructor,"getSighash")(e)}getEventTopic(e){return"string"==typeof e&&(e=this.getEvent(e)),Object(g.getStatic)(this.constructor,"getEventTopic")(e)}_decodeParams(e,t){return this._abiCoder.decode(e,t)}_encodeParams(e,t){return this._abiCoder.encode(e,t)}encodeDeploy(e){return this._encodeParams(this.deploy.inputs,e||[])}decodeErrorResult(e,t){"string"==typeof e&&(e=this.getError(e));const r=Object(b.arrayify)(t);return Object(b.hexlify)(r.slice(0,4))!==this.getSighash(e)&&_r.throwArgumentError(`data signature does not match error ${e.name}.`,"data",Object(b.hexlify)(r)),this._decodeParams(e.inputs,r.slice(4))}encodeErrorResult(e,t){return"string"==typeof e&&(e=this.getError(e)),Object(b.hexlify)(Object(b.concat)([this.getSighash(e),this._encodeParams(e.inputs,t||[])]))}decodeFunctionData(e,t){"string"==typeof e&&(e=this.getFunction(e));const r=Object(b.arrayify)(t);return Object(b.hexlify)(r.slice(0,4))!==this.getSighash(e)&&_r.throwArgumentError(`data signature does not match function ${e.name}.`,"data",Object(b.hexlify)(r)),this._decodeParams(e.inputs,r.slice(4))}encodeFunctionData(e,t){return"string"==typeof e&&(e=this.getFunction(e)),Object(b.hexlify)(Object(b.concat)([this.getSighash(e),this._encodeParams(e.inputs,t||[])]))}decodeFunctionResult(e,t){"string"==typeof e&&(e=this.getFunction(e));let r=Object(b.arrayify)(t),n=null,f=null,a=null,i=null;switch(r.length%this._abiCoder._getWordSize()){case 0:try{return this._abiCoder.decode(e.outputs,r)}catch(e){}break;case 4:{const e=Object(b.hexlify)(r.slice(0,4)),t=xr[e];if(t)f=this._abiCoder.decode(t.inputs,r.slice(4)),a=t.name,i=t.signature,t.reason&&(n=f[0]);else try{const t=this.getError(e);f=this._abiCoder.decode(t.inputs,r.slice(4)),a=t.name,i=t.format()}catch(e){console.log(e)}break}}return _r.throwError("call revert exception",T.Logger.errors.CALL_EXCEPTION,{method:e.format(),errorArgs:f,errorName:a,errorSignature:i,reason:n})}encodeFunctionResult(e,t){return"string"==typeof e&&(e=this.getFunction(e)),Object(b.hexlify)(this._abiCoder.encode(e.outputs,t||[]))}encodeFilterTopics(e,t){"string"==typeof e&&(e=this.getEvent(e)),t.length>e.inputs.length&&_r.throwError("too many arguments for "+e.format(),T.Logger.errors.UNEXPECTED_ARGUMENT,{argument:"values",value:t});let r=[];e.anonymous||r.push(this.getEventTopic(e));const n=(e,t)=>"string"===e.type?Object(mr.a)(t):"bytes"===e.type?vr(Object(b.hexlify)(t)):("address"===e.type&&this._abiCoder.encode(["address"],[t]),Object(b.hexZeroPad)(Object(b.hexlify)(t),32));for(t.forEach(((t,f)=>{let a=e.inputs[f];a.indexed?null==t?r.push(null):"array"===a.baseType||"tuple"===a.baseType?_r.throwArgumentError("filtering with tuples or arrays not supported","contract."+a.name,t):Array.isArray(t)?r.push(t.map((e=>n(a,e)))):r.push(n(a,t)):null!=t&&_r.throwArgumentError("cannot filter non-indexed parameters; must be null","contract."+a.name,t)}));r.length&&null===r[r.length-1];)r.pop();return r}encodeEventLog(e,t){"string"==typeof e&&(e=this.getEvent(e));const r=[],n=[],f=[];return e.anonymous||r.push(this.getEventTopic(e)),t.length!==e.inputs.length&&_r.throwArgumentError("event arguments/values mismatch","values",t),e.inputs.forEach(((e,a)=>{const i=t[a];if(e.indexed)if("string"===e.type)r.push(Object(mr.a)(i));else if("bytes"===e.type)r.push(vr(i));else{if("tuple"===e.baseType||"array"===e.baseType)throw new Error("not implemented");r.push(this._abiCoder.encode([e.type],[i]))}else n.push(e),f.push(i)})),{data:this._abiCoder.encode(n,f),topics:r}}decodeEventLog(e,t,r){if("string"==typeof e&&(e=this.getEvent(e)),null!=r&&!e.anonymous){let t=this.getEventTopic(e);Object(b.isHexString)(r[0],32)&&r[0].toLowerCase()===t||_r.throwError("fragment/topic mismatch",T.Logger.errors.INVALID_ARGUMENT,{argument:"topics[0]",expected:t,value:r[0]}),r=r.slice(1)}let n=[],f=[],a=[];e.inputs.forEach(((e,t)=>{e.indexed?"string"===e.type||"bytes"===e.type||"tuple"===e.baseType||"array"===e.baseType?(n.push(Jt.fromObject({type:"bytes32",name:e.name})),a.push(!0)):(n.push(e),a.push(!1)):(f.push(e),a.push(!1))}));let i=null!=r?this._abiCoder.decode(n,Object(b.concat)(r)):null,o=this._abiCoder.decode(f,t,!0),s=[],c=0,u=0;e.inputs.forEach(((e,t)=>{if(e.indexed)if(null==i)s[t]=new Tr({_isIndexed:!0,hash:null});else if(a[t])s[t]=new Tr({_isIndexed:!0,hash:i[u++]});else try{s[t]=i[u++]}catch(e){s[t]=e}else try{s[t]=o[c++]}catch(e){s[t]=e}if(e.name&&null==s[e.name]){const r=s[t];r instanceof Error?Object.defineProperty(s,e.name,{enumerable:!0,get:()=>{throw kr(`property ${JSON.stringify(e.name)}`,r)}}):s[e.name]=r}}));for(let e=0;e<s.length;e++){const t=s[e];t instanceof Error&&Object.defineProperty(s,e,{enumerable:!0,get:()=>{throw kr(`index ${e}`,t)}})}return Object.freeze(s)}parseTransaction(e){let t=this.getFunction(e.data.substring(0,10).toLowerCase());return t?new Er({args:this._abiCoder.decode(t.inputs,"0x"+e.data.substring(10)),functionFragment:t,name:t.name,signature:t.format(),sighash:this.getSighash(t),value:o.a.from(e.value||"0")}):null}parseLog(e){let t=this.getEvent(e.topics[0]);return!t||t.anonymous?null:new wr({eventFragment:t,name:t.name,signature:t.format(),topic:this.getEventTopic(t),args:this.decodeEventLog(t,e.data,e.topics)})}parseError(e){const t=Object(b.hexlify)(e);let r=this.getError(t.substring(0,10).toLowerCase());return r?new Ar({args:this._abiCoder.decode(r.inputs,"0x"+t.substring(10)),errorFragment:r,name:r.name,signature:r.format(),sighash:this.getSighash(r)}):null}static isInterface(e){return!(!e||!e._isInterface)}}var Or=r(65),Cr=r(133),Pr=r(16),Rr=r(63),Nr=r(56),Ir=r(859);function Mr(e){for(let t=(e=e.slice()).length-1;t>0;t--){const r=Math.floor(Math.random()*(t+1)),n=e[t];e[t]=e[r],e[r]=n}return e}var Dr=r(31),Br=r(25),Fr=r(127),jr=r(137),Lr=r(40),Ur=r(135);var qr=function(e,t,r,n){return new(r||(r=Promise))((function(f,a){function i(e){try{s(n.next(e))}catch(e){a(e)}}function o(e){try{s(n.throw(e))}catch(e){a(e)}}function s(e){var t;e.done?f(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(i,o)}s((n=n.apply(e,t||[])).next())}))};function Hr(e,t){return qr(this,void 0,void 0,(function*(){null==t&&(t={});const r={method:t.method||"GET",headers:t.headers||{},body:t.body||void 0};!0!==t.skipFetchSetup&&(r.mode="cors",r.cache="no-cache",r.credentials="same-origin",r.redirect="follow",r.referrer="client");const n=yield fetch(e,r),f=yield n.arrayBuffer(),a={};return n.headers.forEach?n.headers.forEach(((e,t)=>{a[t.toLowerCase()]=e})):n.headers.keys().forEach((e=>{a[e.toLowerCase()]=n.headers.get(e)})),{headers:a,statusCode:n.status,statusMessage:n.statusText,body:Object(b.arrayify)(new Uint8Array(f))}}))}var $r=function(e,t,r,n){return new(r||(r=Promise))((function(f,a){function i(e){try{s(n.next(e))}catch(e){a(e)}}function o(e){try{s(n.throw(e))}catch(e){a(e)}}function s(e){var t;e.done?f(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(i,o)}s((n=n.apply(e,t||[])).next())}))};const zr=new T.Logger("web/5.5.1");function Vr(e){return new Promise((t=>{setTimeout(t,e)}))}function Gr(e,t){if(null==e)return null;if("string"==typeof e)return e;if(Object(b.isBytesLike)(e)){if(t&&("text"===t.split("/")[0]||"application/json"===t.split(";")[0].trim()))try{return Object(_.h)(e)}catch(e){}return Object(b.hexlify)(e)}return e}function Kr(e,t,r){const n="object"==typeof e&&null!=e.throttleLimit?e.throttleLimit:12;zr.assertArgument(n>0&&n%1==0,"invalid connection throttle limit","connection.throttleLimit",n);const f="object"==typeof e?e.throttleCallback:null,a="object"==typeof e&&"number"==typeof e.throttleSlotInterval?e.throttleSlotInterval:100;zr.assertArgument(a>0&&a%1==0,"invalid connection throttle slot interval","connection.throttleSlotInterval",a);const i={};let o=null;const s={method:"GET"};let c=!1,u=12e4;if("string"==typeof e)o=e;else if("object"==typeof e){if(null!=e&&null!=e.url||zr.throwArgumentError("missing URL","connection.url",e),o=e.url,"number"==typeof e.timeout&&e.timeout>0&&(u=e.timeout),e.headers)for(const t in e.headers)i[t.toLowerCase()]={key:t,value:String(e.headers[t])},["if-none-match","if-modified-since"].indexOf(t.toLowerCase())>=0&&(c=!0);if(s.allowGzip=!!e.allowGzip,null!=e.user&&null!=e.password){"https:"!==o.substring(0,6)&&!0!==e.allowInsecureAuthentication&&zr.throwError("basic authentication requires a secure https url",T.Logger.errors.INVALID_ARGUMENT,{argument:"url",url:o,user:e.user,password:"[REDACTED]"});const t=e.user+":"+e.password;i.authorization={key:"Authorization",value:"Basic "+Object(Ur.b)(Object(_.f)(t))}}}const d=new RegExp("^data:([a-z0-9-]+/[a-z0-9-]+);base64,(.*)$","i"),l=o?o.match(d):null;if(l)try{const e={statusCode:200,statusMessage:"OK",headers:{"content-type":l[1]},body:Object(Ur.a)(l[2])};let t=e.body;return r&&(t=r(e.body,e)),Promise.resolve(t)}catch(e){zr.throwError("processing response error",T.Logger.errors.SERVER_ERROR,{body:Gr(l[1],l[2]),error:e,requestBody:null,requestMethod:"GET",url:o})}t&&(s.method="POST",s.body=t,null==i["content-type"]&&(i["content-type"]={key:"Content-Type",value:"application/octet-stream"}),null==i["content-length"]&&(i["content-length"]={key:"Content-Length",value:String(t.length)}));const p={};Object.keys(i).forEach((e=>{const t=i[e];p[t.key]=t.value})),s.headers=p;const h=function(){let e=null;return{promise:new Promise((function(t,r){u&&(e=setTimeout((()=>{null!=e&&(e=null,r(zr.makeError("timeout",T.Logger.errors.TIMEOUT,{requestBody:Gr(s.body,p["content-type"]),requestMethod:s.method,timeout:u,url:o})))}),u))})),cancel:function(){null!=e&&(clearTimeout(e),e=null)}}}(),b=function(){return $r(this,void 0,void 0,(function*(){for(let e=0;e<n;e++){let t=null;try{if(t=yield Hr(o,s),e<n)if(301===t.statusCode||302===t.statusCode){const e=t.headers.location||"";if("GET"===s.method&&e.match(/^https:/)){o=t.headers.location;continue}}else if(429===t.statusCode){let r=!0;if(f&&(r=yield f(e,o)),r){let r=0;const n=t.headers["retry-after"];r="string"==typeof n&&n.match(/^[1-9][0-9]*$/)?1e3*parseInt(n):a*parseInt(String(Math.random()*Math.pow(2,e))),yield Vr(r);continue}}}catch(e){t=e.response,null==t&&(h.cancel(),zr.throwError("missing response",T.Logger.errors.SERVER_ERROR,{requestBody:Gr(s.body,p["content-type"]),requestMethod:s.method,serverError:e,url:o}))}let i=t.body;if(c&&304===t.statusCode?i=null:(t.statusCode<200||t.statusCode>=300)&&(h.cancel(),zr.throwError("bad response",T.Logger.errors.SERVER_ERROR,{status:t.statusCode,headers:t.headers,body:Gr(i,t.headers?t.headers["content-type"]:null),requestBody:Gr(s.body,p["content-type"]),requestMethod:s.method,url:o})),r)try{const e=yield r(i,t);return h.cancel(),e}catch(r){if(r.throttleRetry&&e<n){let t=!0;if(f&&(t=yield f(e,o)),t){const t=a*parseInt(String(Math.random()*Math.pow(2,e)));yield Vr(t);continue}}h.cancel(),zr.throwError("processing response error",T.Logger.errors.SERVER_ERROR,{body:Gr(i,t.headers?t.headers["content-type"]:null),error:r,requestBody:Gr(s.body,p["content-type"]),requestMethod:s.method,url:o})}return h.cancel(),i}return zr.throwError("failed response",T.Logger.errors.SERVER_ERROR,{requestBody:Gr(s.body,p["content-type"]),requestMethod:s.method,url:o})}))}();return Promise.race([h.promise,b])}function Wr(e,t,r){let n=null;if(null!=t){n=Object(_.f)(t);const r="string"==typeof e?{url:e}:Object(g.shallowCopy)(e);if(r.headers){0!==Object.keys(r.headers).filter((e=>"content-type"===e.toLowerCase())).length||(r.headers=Object(g.shallowCopy)(r.headers),r.headers["content-type"]="application/json")}else r.headers={"content-type":"application/json"};e=r}return Kr(e,n,((e,t)=>{let n=null;if(null!=e)try{n=JSON.parse(Object(_.h)(e))}catch(t){zr.throwError("invalid JSON",T.Logger.errors.SERVER_ERROR,{body:e,error:t})}return r&&(n=r(n,t)),n}))}function Yr(e,t){return t||(t={}),null==(t=Object(g.shallowCopy)(t)).floor&&(t.floor=0),null==t.ceiling&&(t.ceiling=1e4),null==t.interval&&(t.interval=250),new Promise((function(r,n){let f=null,a=!1;const i=()=>!a&&(a=!0,f&&clearTimeout(f),!0);t.timeout&&(f=setTimeout((()=>{i()&&n(new Error("timeout"))}),t.timeout));const o=t.retryLimit;let s=0;!function f(){return e().then((function(e){if(void 0!==e)i()&&r(e);else if(t.oncePoll)t.oncePoll.once("poll",f);else if(t.onceBlock)t.onceBlock.once("block",f);else if(!a){if(s++,s>o)return void(i()&&n(new Error("retry limit reached")));let e=t.interval*parseInt(String(Math.random()*Math.pow(2,s)));e<t.floor&&(e=t.floor),e>t.ceiling&&(e=t.ceiling),setTimeout(f,e)}return null}),(function(e){i()&&n(e)}))}()}))}var Jr=r(123);const Xr="ethers/5.5.4",Zr=new T.Logger(Xr);try{const e=window;null==e._ethers&&(e._ethers=a)}catch(e){}},function(e,t,r){"use strict";r.r(t),r.d(t,"dma",(function(){return a})),r.d(t,"sma",(function(){return i})),r.d(t,"ema",(function(){return o})),r.d(t,"ma",(function(){return s})),r.d(t,"wma",(function(){return c}));const n=e=>"number"==typeof e&&e==e,f=Array.isArray;var a=(e,t,r)=>{const a=e.length;if(t>1)return Array(a);if(1===t)return e.slice();const i=!f(t),o=[];let s,c=0,u=0;for(;c<a;c++)if(s=e[c],n(s)&&(i||n(s))){o[c]=r?0:s,u=s,c++;break}if(!i){for(;c<a;c++)s=e[c],n(s)&&n(t[c])?u=o[c]=t[c]*s+(1-t[c])*u:o[c]=o[c-1];return o}const d=1-t;for(;c<a;c++)s=e[c],n(s)?u=o[c]=t*s+d*u:o[c]=o[c-1];return o},i=(e,t,r=1)=>a(e,r/t,1),o=(e,t)=>a(e,2/(t+1)),s=(e,t)=>{const r=e.length;if(!t)return e.reduce(((e,t)=>e+t))/r;if(t<=1)return e.slice();if(t>r)return Array(r);const f=t-1,a=[];let i,o=0,s=0,c=0;for(;s<r&&c<f;s++)i=e[s],n(i)&&(o+=i,c++);for(;s<r;s++)i=e[s],n(i)&&(o+=i),n(e[s-t])&&(o-=e[s-t]),a[s]=o/t;return a},c=(e,t)=>{const r=e.length;if(t<=1)return e.slice();if(t>r)return Array(r);const f=[],a=t*(t+1)/2,i=t-1;let o=0,s=0,c=0,u=0,d=-1;for(;u<i;u++)c=e[u],n(c)&&(o+=c,s+=(u+1)*c);for(;u<r;u++,d++)c=e[u],n(c)&&(o+=c,s+=t*c),d>=0&&n(e[d])&&(o-=e[d]),f[u]=s/a,s-=o;return f}},function(e,t,r){"use strict";r.d(t,"a",(function(){return a}));var n=r(0),f=r(70);function a(e,t,r,a,i){let o;e=Object(n.arrayify)(e),t=Object(n.arrayify)(t);let s=1;const c=new Uint8Array(a),u=new Uint8Array(t.length+4);let d,l;u.set(t);for(let p=1;p<=s;p++){u[t.length]=p>>24&255,u[t.length+1]=p>>16&255,u[t.length+2]=p>>8&255,u[t.length+3]=255&p;let h=Object(n.arrayify)(Object(f.a)(i,e,u));o||(o=h.length,l=new Uint8Array(o),s=Math.ceil(a/o),d=a-(s-1)*o),l.set(h);for(let t=1;t<r;t++){h=Object(n.arrayify)(Object(f.a)(i,e,h));for(let e=0;e<o;e++)l[e]^=h[e]}const b=(p-1)*o,m=p===s?d:o;c.set(Object(n.arrayify)(l).slice(0,m),b)}return Object(n.hexlify)(c)}},,,,,function(e,t,r){"use strict";r.d(t,"b",(function(){return h})),r.d(t,"c",(function(){return b})),r.d(t,"a",(function(){return y}));var n=r(0),f=r(2),a=r(124),i=r(17);const o=new f.Logger(a.a),s={},c=i.a.from(0),u=i.a.from(-1);function d(e,t,r,n){const a={fault:t,operation:r};return void 0!==n&&(a.value=n),o.throwError(e,f.Logger.errors.NUMERIC_FAULT,a)}let l="0";for(;l.length<256;)l+=l;function p(e){if("number"!=typeof e)try{e=i.a.from(e).toNumber()}catch(e){}return"number"==typeof e&&e>=0&&e<=256&&!(e%1)?"1"+l.substring(0,e):o.throwArgumentError("invalid decimal size","decimals",e)}function h(e,t){null==t&&(t=0);const r=p(t),n=(e=i.a.from(e)).lt(c);n&&(e=e.mul(u));let f=e.mod(r).toString();for(;f.length<r.length-1;)f="0"+f;f=f.match(/^([0-9]*[1-9]|0)(0*)/)[1];const a=e.div(r).toString();return e=1===r.length?a:a+"."+f,n&&(e="-"+e),e}function b(e,t){null==t&&(t=0);const r=p(t);"string"==typeof e&&e.match(/^-?[0-9.]+$/)||o.throwArgumentError("invalid decimal value","value",e);const n="-"===e.substring(0,1);n&&(e=e.substring(1)),"."===e&&o.throwArgumentError("missing value","value",e);const f=e.split(".");f.length>2&&o.throwArgumentError("too many decimal points","value",e);let a=f[0],s=f[1];for(a||(a="0"),s||(s="0");"0"===s[s.length-1];)s=s.substring(0,s.length-1);for(s.length>r.length-1&&d("fractional component exceeds decimals","underflow","parseFixed"),""===s&&(s="0");s.length<r.length-1;)s+="0";const c=i.a.from(a),l=i.a.from(s);let h=c.mul(r).add(l);return n&&(h=h.mul(u)),h}class m{constructor(e,t,r,n){e!==s&&o.throwError("cannot use FixedFormat constructor; use FixedFormat.from",f.Logger.errors.UNSUPPORTED_OPERATION,{operation:"new FixedFormat"}),this.signed=t,this.width=r,this.decimals=n,this.name=(t?"":"u")+"fixed"+String(r)+"x"+String(n),this._multiplier=p(n),Object.freeze(this)}static from(e){if(e instanceof m)return e;"number"==typeof e&&(e=`fixed128x${e}`);let t=!0,r=128,n=18;if("string"==typeof e)if("fixed"===e);else if("ufixed"===e)t=!1;else{const f=e.match(/^(u?)fixed([0-9]+)x([0-9]+)$/);f||o.throwArgumentError("invalid fixed format","format",e),t="u"!==f[1],r=parseInt(f[2]),n=parseInt(f[3])}else if(e){const f=(t,r,n)=>null==e[t]?n:(typeof e[t]!==r&&o.throwArgumentError("invalid fixed format ("+t+" not "+r+")","format."+t,e[t]),e[t]);t=f("signed","boolean",t),r=f("width","number",r),n=f("decimals","number",n)}return r%8&&o.throwArgumentError("invalid fixed format width (not byte aligned)","format.width",r),n>80&&o.throwArgumentError("invalid fixed format (decimals too large)","format.decimals",n),new m(s,t,r,n)}}class y{constructor(e,t,r,n){o.checkNew(new.target,y),e!==s&&o.throwError("cannot use FixedNumber constructor; use FixedNumber.from",f.Logger.errors.UNSUPPORTED_OPERATION,{operation:"new FixedFormat"}),this.format=n,this._hex=t,this._value=r,this._isFixedNumber=!0,Object.freeze(this)}_checkFormat(e){this.format.name!==e.format.name&&o.throwArgumentError("incompatible format; use fixedNumber.toFormat","other",e)}addUnsafe(e){this._checkFormat(e);const t=b(this._value,this.format.decimals),r=b(e._value,e.format.decimals);return y.fromValue(t.add(r),this.format.decimals,this.format)}subUnsafe(e){this._checkFormat(e);const t=b(this._value,this.format.decimals),r=b(e._value,e.format.decimals);return y.fromValue(t.sub(r),this.format.decimals,this.format)}mulUnsafe(e){this._checkFormat(e);const t=b(this._value,this.format.decimals),r=b(e._value,e.format.decimals);return y.fromValue(t.mul(r).div(this.format._multiplier),this.format.decimals,this.format)}divUnsafe(e){this._checkFormat(e);const t=b(this._value,this.format.decimals),r=b(e._value,e.format.decimals);return y.fromValue(t.mul(this.format._multiplier).div(r),this.format.decimals,this.format)}floor(){const e=this.toString().split(".");1===e.length&&e.push("0");let t=y.from(e[0],this.format);const r=!e[1].match(/^(0*)$/);return this.isNegative()&&r&&(t=t.subUnsafe(g.toFormat(t.format))),t}ceiling(){const e=this.toString().split(".");1===e.length&&e.push("0");let t=y.from(e[0],this.format);const r=!e[1].match(/^(0*)$/);return!this.isNegative()&&r&&(t=t.addUnsafe(g.toFormat(t.format))),t}round(e){null==e&&(e=0);const t=this.toString().split(".");if(1===t.length&&t.push("0"),(e<0||e>80||e%1)&&o.throwArgumentError("invalid decimal count","decimals",e),t[1].length<=e)return this;const r=y.from("1"+l.substring(0,e),this.format),n=v.toFormat(this.format);return this.mulUnsafe(r).addUnsafe(n).floor().divUnsafe(r)}isZero(){return"0.0"===this._value||"0"===this._value}isNegative(){return"-"===this._value[0]}toString(){return this._value}toHexString(e){if(null==e)return this._hex;e%8&&o.throwArgumentError("invalid byte width","width",e);const t=i.a.from(this._hex).fromTwos(this.format.width).toTwos(e).toHexString();return Object(n.hexZeroPad)(t,e/8)}toUnsafeFloat(){return parseFloat(this.toString())}toFormat(e){return y.fromString(this._value,e)}static fromValue(e,t,r){return null!=r||null==t||Object(i.d)(t)||(r=t,t=null),null==t&&(t=0),null==r&&(r="fixed"),y.fromString(h(e,t),m.from(r))}static fromString(e,t){null==t&&(t="fixed");const r=m.from(t),f=b(e,r.decimals);!r.signed&&f.lt(c)&&d("unsigned value cannot be negative","overflow","value",e);let a=null;r.signed?a=f.toTwos(r.width).toHexString():(a=f.toHexString(),a=Object(n.hexZeroPad)(a,r.width/8));const i=h(f,r.decimals);return new y(s,a,i,r)}static fromBytes(e,t){null==t&&(t="fixed");const r=m.from(t);if(Object(n.arrayify)(e).length>r.width/8)throw new Error("overflow");let f=i.a.from(e);r.signed&&(f=f.fromTwos(r.width));const a=f.toTwos((r.signed?0:1)+r.width).toHexString(),o=h(f,r.decimals);return new y(s,a,o,r)}static from(e,t){if("string"==typeof e)return y.fromString(e,t);if(Object(n.isBytes)(e))return y.fromBytes(e,t);try{return y.fromValue(e,0,t)}catch(e){if(e.code!==f.Logger.errors.INVALID_ARGUMENT)throw e}return o.throwArgumentError("invalid FixedNumber value","value",e)}static isFixedNumber(e){return!(!e||!e._isFixedNumber)}}const g=y.from(1),v=y.from("0.5")},function(e,t,r){"use strict";(function(e){r.d(t,"a",(function(){return c}));var n=r(0),f=r(2),a=r(335);const i=new f.Logger(a.a);const o=function(){if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if(void 0!==e)return e;throw new Error("unable to locate global object")}();let s=o.crypto||o.msCrypto;function c(e){(e<=0||e>1024||e%1||e!=e)&&i.throwArgumentError("invalid length","length",e);const t=new Uint8Array(e);return s.getRandomValues(t),Object(n.arrayify)(t)}s&&s.getRandomValues||(i.warn("WARNING: Missing strong random number source"),s={getRandomValues:function(e){return i.throwError("no secure random source avaialble",f.Logger.errors.UNSUPPORTED_OPERATION,{operation:"crypto.getRandomValues"})}})}).call(this,r(21))},function(e,t,r){"use strict";r.d(t,"a",(function(){return s}));var n=r(129);let f=null;function a(e){if(null==f&&(f="AbandonAbilityAbleAboutAboveAbsentAbsorbAbstractAbsurdAbuseAccessAccidentAccountAccuseAchieveAcidAcousticAcquireAcrossActActionActorActressActualAdaptAddAddictAddressAdjustAdmitAdultAdvanceAdviceAerobicAffairAffordAfraidAgainAgeAgentAgreeAheadAimAirAirportAisleAlarmAlbumAlcoholAlertAlienAllAlleyAllowAlmostAloneAlphaAlreadyAlsoAlterAlwaysAmateurAmazingAmongAmountAmusedAnalystAnchorAncientAngerAngleAngryAnimalAnkleAnnounceAnnualAnotherAnswerAntennaAntiqueAnxietyAnyApartApologyAppearAppleApproveAprilArchArcticAreaArenaArgueArmArmedArmorArmyAroundArrangeArrestArriveArrowArtArtefactArtistArtworkAskAspectAssaultAssetAssistAssumeAsthmaAthleteAtomAttackAttendAttitudeAttractAuctionAuditAugustAuntAuthorAutoAutumnAverageAvocadoAvoidAwakeAwareAwayAwesomeAwfulAwkwardAxisBabyBachelorBaconBadgeBagBalanceBalconyBallBambooBananaBannerBarBarelyBargainBarrelBaseBasicBasketBattleBeachBeanBeautyBecauseBecomeBeefBeforeBeginBehaveBehindBelieveBelowBeltBenchBenefitBestBetrayBetterBetweenBeyondBicycleBidBikeBindBiologyBirdBirthBitterBlackBladeBlameBlanketBlastBleakBlessBlindBloodBlossomBlouseBlueBlurBlushBoardBoatBodyBoilBombBoneBonusBookBoostBorderBoringBorrowBossBottomBounceBoxBoyBracketBrainBrandBrassBraveBreadBreezeBrickBridgeBriefBrightBringBriskBroccoliBrokenBronzeBroomBrotherBrownBrushBubbleBuddyBudgetBuffaloBuildBulbBulkBulletBundleBunkerBurdenBurgerBurstBusBusinessBusyButterBuyerBuzzCabbageCabinCableCactusCageCakeCallCalmCameraCampCanCanalCancelCandyCannonCanoeCanvasCanyonCapableCapitalCaptainCarCarbonCardCargoCarpetCarryCartCaseCashCasinoCastleCasualCatCatalogCatchCategoryCattleCaughtCauseCautionCaveCeilingCeleryCementCensusCenturyCerealCertainChairChalkChampionChangeChaosChapterChargeChaseChatCheapCheckCheeseChefCherryChestChickenChiefChildChimneyChoiceChooseChronicChuckleChunkChurnCigarCinnamonCircleCitizenCityCivilClaimClapClarifyClawClayCleanClerkCleverClickClientCliffClimbClinicClipClockClogCloseClothCloudClownClubClumpClusterClutchCoachCoastCoconutCodeCoffeeCoilCoinCollectColorColumnCombineComeComfortComicCommonCompanyConcertConductConfirmCongressConnectConsiderControlConvinceCookCoolCopperCopyCoralCoreCornCorrectCostCottonCouchCountryCoupleCourseCousinCoverCoyoteCrackCradleCraftCramCraneCrashCraterCrawlCrazyCreamCreditCreekCrewCricketCrimeCrispCriticCropCrossCrouchCrowdCrucialCruelCruiseCrumbleCrunchCrushCryCrystalCubeCultureCupCupboardCuriousCurrentCurtainCurveCushionCustomCuteCycleDadDamageDampDanceDangerDaringDashDaughterDawnDayDealDebateDebrisDecadeDecemberDecideDeclineDecorateDecreaseDeerDefenseDefineDefyDegreeDelayDeliverDemandDemiseDenialDentistDenyDepartDependDepositDepthDeputyDeriveDescribeDesertDesignDeskDespairDestroyDetailDetectDevelopDeviceDevoteDiagramDialDiamondDiaryDiceDieselDietDifferDigitalDignityDilemmaDinnerDinosaurDirectDirtDisagreeDiscoverDiseaseDishDismissDisorderDisplayDistanceDivertDivideDivorceDizzyDoctorDocumentDogDollDolphinDomainDonateDonkeyDonorDoorDoseDoubleDoveDraftDragonDramaDrasticDrawDreamDressDriftDrillDrinkDripDriveDropDrumDryDuckDumbDuneDuringDustDutchDutyDwarfDynamicEagerEagleEarlyEarnEarthEasilyEastEasyEchoEcologyEconomyEdgeEditEducateEffortEggEightEitherElbowElderElectricElegantElementElephantElevatorEliteElseEmbarkEmbodyEmbraceEmergeEmotionEmployEmpowerEmptyEnableEnactEndEndlessEndorseEnemyEnergyEnforceEngageEngineEnhanceEnjoyEnlistEnoughEnrichEnrollEnsureEnterEntireEntryEnvelopeEpisodeEqualEquipEraEraseErodeErosionErrorEruptEscapeEssayEssenceEstateEternalEthicsEvidenceEvilEvokeEvolveExactExampleExcessExchangeExciteExcludeExcuseExecuteExerciseExhaustExhibitExileExistExitExoticExpandExpectExpireExplainExposeExpressExtendExtraEyeEyebrowFabricFaceFacultyFadeFaintFaithFallFalseFameFamilyFamousFanFancyFantasyFarmFashionFatFatalFatherFatigueFaultFavoriteFeatureFebruaryFederalFeeFeedFeelFemaleFenceFestivalFetchFeverFewFiberFictionFieldFigureFileFilmFilterFinalFindFineFingerFinishFireFirmFirstFiscalFishFitFitnessFixFlagFlameFlashFlatFlavorFleeFlightFlipFloatFlockFloorFlowerFluidFlushFlyFoamFocusFogFoilFoldFollowFoodFootForceForestForgetForkFortuneForumForwardFossilFosterFoundFoxFragileFrameFrequentFreshFriendFringeFrogFrontFrostFrownFrozenFruitFuelFunFunnyFurnaceFuryFutureGadgetGainGalaxyGalleryGameGapGarageGarbageGardenGarlicGarmentGasGaspGateGatherGaugeGazeGeneralGeniusGenreGentleGenuineGestureGhostGiantGiftGiggleGingerGiraffeGirlGiveGladGlanceGlareGlassGlideGlimpseGlobeGloomGloryGloveGlowGlueGoatGoddessGoldGoodGooseGorillaGospelGossipGovernGownGrabGraceGrainGrantGrapeGrassGravityGreatGreenGridGriefGritGroceryGroupGrowGruntGuardGuessGuideGuiltGuitarGunGymHabitHairHalfHammerHamsterHandHappyHarborHardHarshHarvestHatHaveHawkHazardHeadHealthHeartHeavyHedgehogHeightHelloHelmetHelpHenHeroHiddenHighHillHintHipHireHistoryHobbyHockeyHoldHoleHolidayHollowHomeHoneyHoodHopeHornHorrorHorseHospitalHostHotelHourHoverHubHugeHumanHumbleHumorHundredHungryHuntHurdleHurryHurtHusbandHybridIceIconIdeaIdentifyIdleIgnoreIllIllegalIllnessImageImitateImmenseImmuneImpactImposeImproveImpulseInchIncludeIncomeIncreaseIndexIndicateIndoorIndustryInfantInflictInformInhaleInheritInitialInjectInjuryInmateInnerInnocentInputInquiryInsaneInsectInsideInspireInstallIntactInterestIntoInvestInviteInvolveIronIslandIsolateIssueItemIvoryJacketJaguarJarJazzJealousJeansJellyJewelJobJoinJokeJourneyJoyJudgeJuiceJumpJungleJuniorJunkJustKangarooKeenKeepKetchupKeyKickKidKidneyKindKingdomKissKitKitchenKiteKittenKiwiKneeKnifeKnockKnowLabLabelLaborLadderLadyLakeLampLanguageLaptopLargeLaterLatinLaughLaundryLavaLawLawnLawsuitLayerLazyLeaderLeafLearnLeaveLectureLeftLegLegalLegendLeisureLemonLendLengthLensLeopardLessonLetterLevelLiarLibertyLibraryLicenseLifeLiftLightLikeLimbLimitLinkLionLiquidListLittleLiveLizardLoadLoanLobsterLocalLockLogicLonelyLongLoopLotteryLoudLoungeLoveLoyalLuckyLuggageLumberLunarLunchLuxuryLyricsMachineMadMagicMagnetMaidMailMainMajorMakeMammalManManageMandateMangoMansionManualMapleMarbleMarchMarginMarineMarketMarriageMaskMassMasterMatchMaterialMathMatrixMatterMaximumMazeMeadowMeanMeasureMeatMechanicMedalMediaMelodyMeltMemberMemoryMentionMenuMercyMergeMeritMerryMeshMessageMetalMethodMiddleMidnightMilkMillionMimicMindMinimumMinorMinuteMiracleMirrorMiseryMissMistakeMixMixedMixtureMobileModelModifyMomMomentMonitorMonkeyMonsterMonthMoonMoralMoreMorningMosquitoMotherMotionMotorMountainMouseMoveMovieMuchMuffinMuleMultiplyMuscleMuseumMushroomMusicMustMutualMyselfMysteryMythNaiveNameNapkinNarrowNastyNationNatureNearNeckNeedNegativeNeglectNeitherNephewNerveNestNetNetworkNeutralNeverNewsNextNiceNightNobleNoiseNomineeNoodleNormalNorthNoseNotableNoteNothingNoticeNovelNowNuclearNumberNurseNutOakObeyObjectObligeObscureObserveObtainObviousOccurOceanOctoberOdorOffOfferOfficeOftenOilOkayOldOliveOlympicOmitOnceOneOnionOnlineOnlyOpenOperaOpinionOpposeOptionOrangeOrbitOrchardOrderOrdinaryOrganOrientOriginalOrphanOstrichOtherOutdoorOuterOutputOutsideOvalOvenOverOwnOwnerOxygenOysterOzonePactPaddlePagePairPalacePalmPandaPanelPanicPantherPaperParadeParentParkParrotPartyPassPatchPathPatientPatrolPatternPausePavePaymentPeacePeanutPearPeasantPelicanPenPenaltyPencilPeoplePepperPerfectPermitPersonPetPhonePhotoPhrasePhysicalPianoPicnicPicturePiecePigPigeonPillPilotPinkPioneerPipePistolPitchPizzaPlacePlanetPlasticPlatePlayPleasePledgePluckPlugPlungePoemPoetPointPolarPolePolicePondPonyPoolPopularPortionPositionPossiblePostPotatoPotteryPovertyPowderPowerPracticePraisePredictPreferPreparePresentPrettyPreventPricePridePrimaryPrintPriorityPrisonPrivatePrizeProblemProcessProduceProfitProgramProjectPromoteProofPropertyProsperProtectProudProvidePublicPuddingPullPulpPulsePumpkinPunchPupilPuppyPurchasePurityPurposePursePushPutPuzzlePyramidQualityQuantumQuarterQuestionQuickQuitQuizQuoteRabbitRaccoonRaceRackRadarRadioRailRainRaiseRallyRampRanchRandomRangeRapidRareRateRatherRavenRawRazorReadyRealReasonRebelRebuildRecallReceiveRecipeRecordRecycleReduceReflectReformRefuseRegionRegretRegularRejectRelaxReleaseReliefRelyRemainRememberRemindRemoveRenderRenewRentReopenRepairRepeatReplaceReportRequireRescueResembleResistResourceResponseResultRetireRetreatReturnReunionRevealReviewRewardRhythmRibRibbonRiceRichRideRidgeRifleRightRigidRingRiotRippleRiskRitualRivalRiverRoadRoastRobotRobustRocketRomanceRoofRookieRoomRoseRotateRoughRoundRouteRoyalRubberRudeRugRuleRunRunwayRuralSadSaddleSadnessSafeSailSaladSalmonSalonSaltSaluteSameSampleSandSatisfySatoshiSauceSausageSaveSayScaleScanScareScatterSceneSchemeSchoolScienceScissorsScorpionScoutScrapScreenScriptScrubSeaSearchSeasonSeatSecondSecretSectionSecuritySeedSeekSegmentSelectSellSeminarSeniorSenseSentenceSeriesServiceSessionSettleSetupSevenShadowShaftShallowShareShedShellSheriffShieldShiftShineShipShiverShockShoeShootShopShortShoulderShoveShrimpShrugShuffleShySiblingSickSideSiegeSightSignSilentSilkSillySilverSimilarSimpleSinceSingSirenSisterSituateSixSizeSkateSketchSkiSkillSkinSkirtSkullSlabSlamSleepSlenderSliceSlideSlightSlimSloganSlotSlowSlushSmallSmartSmileSmokeSmoothSnackSnakeSnapSniffSnowSoapSoccerSocialSockSodaSoftSolarSoldierSolidSolutionSolveSomeoneSongSoonSorrySortSoulSoundSoupSourceSouthSpaceSpareSpatialSpawnSpeakSpecialSpeedSpellSpendSphereSpiceSpiderSpikeSpinSpiritSplitSpoilSponsorSpoonSportSpotSpraySpreadSpringSpySquareSqueezeSquirrelStableStadiumStaffStageStairsStampStandStartStateStaySteakSteelStemStepStereoStickStillStingStockStomachStoneStoolStoryStoveStrategyStreetStrikeStrongStruggleStudentStuffStumbleStyleSubjectSubmitSubwaySuccessSuchSuddenSufferSugarSuggestSuitSummerSunSunnySunsetSuperSupplySupremeSureSurfaceSurgeSurpriseSurroundSurveySuspectSustainSwallowSwampSwapSwarmSwearSweetSwiftSwimSwingSwitchSwordSymbolSymptomSyrupSystemTableTackleTagTailTalentTalkTankTapeTargetTaskTasteTattooTaxiTeachTeamTellTenTenantTennisTentTermTestTextThankThatThemeThenTheoryThereTheyThingThisThoughtThreeThriveThrowThumbThunderTicketTideTigerTiltTimberTimeTinyTipTiredTissueTitleToastTobaccoTodayToddlerToeTogetherToiletTokenTomatoTomorrowToneTongueTonightToolToothTopTopicToppleTorchTornadoTortoiseTossTotalTouristTowardTowerTownToyTrackTradeTrafficTragicTrainTransferTrapTrashTravelTrayTreatTreeTrendTrialTribeTrickTriggerTrimTripTrophyTroubleTruckTrueTrulyTrumpetTrustTruthTryTubeTuitionTumbleTunaTunnelTurkeyTurnTurtleTwelveTwentyTwiceTwinTwistTwoTypeTypicalUglyUmbrellaUnableUnawareUncleUncoverUnderUndoUnfairUnfoldUnhappyUniformUniqueUnitUniverseUnknownUnlockUntilUnusualUnveilUpdateUpgradeUpholdUponUpperUpsetUrbanUrgeUsageUseUsedUsefulUselessUsualUtilityVacantVacuumVagueValidValleyValveVanVanishVaporVariousVastVaultVehicleVelvetVendorVentureVenueVerbVerifyVersionVeryVesselVeteranViableVibrantViciousVictoryVideoViewVillageVintageViolinVirtualVirusVisaVisitVisualVitalVividVocalVoiceVoidVolcanoVolumeVoteVoyageWageWagonWaitWalkWallWalnutWantWarfareWarmWarriorWashWaspWasteWaterWaveWayWealthWeaponWearWeaselWeatherWebWeddingWeekendWeirdWelcomeWestWetWhaleWhatWheatWheelWhenWhereWhipWhisperWideWidthWifeWildWillWinWindowWineWingWinkWinnerWinterWireWisdomWiseWishWitnessWolfWomanWonderWoodWoolWordWorkWorldWorryWorthWrapWreckWrestleWristWriteWrongYardYearYellowYouYoungYouthZebraZeroZoneZoo".replace(/([A-Z])/g," $1").toLowerCase().substring(1).split(" "),"0x3c8acc1e7b08d8e76f9fda015ef48dc8c710a73cb7e0f77b2c18a9b5a7adde60"!==n.a.check(e)))throw f=null,new Error("BIP39 Wordlist for en (English) FAILED")}class i extends n.a{constructor(){super("en")}getWord(e){return a(this),f[e]}getWordIndex(e){return a(this),f.indexOf(e)}}const o=new i;n.a.register(o);const s={en:o}}])}));
430
+ ${t.PaymentFragment}`},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.EthInputDataPaymentDetector=void 0;const n=r(13),f=r(50),a=r(4),i=r(715),o=r(297),s=r(100),c=r(36),u=r(68),d={"0.1.0":"0.1.0","0.2.0":"0.1.0","0.3.0":"0.3.0"};class l extends s.ReferenceBasedDetector{constructor({advancedLogic:e,currencyManager:t,explorerApiKeys:r,getSubgraphClient:n}){super(a.ExtensionTypes.PAYMENT_NETWORK_ID.ETH_INPUT_DATA,e.extensions.ethereumInputData,t),this.explorerApiKeys=r||{},this.getSubgraphClient=n}extractEvents(e,t,r,f,a,s){return n.__awaiter(this,void 0,void 0,(function*(){if(!t)return{paymentEvents:[]};const n=new i.EthInputDataInfoRetriever(t,e,a,r,this.explorerApiKeys[a]),f=yield n.getTransferEvents(),c=l.getDeploymentInformation(a,s.version);let d,p=[];if(c){const n=this.getSubgraphClient(a);if(n){const f=new u.TheGraphInfoRetriever(n,this.currencyManager);d=yield f.getTransferEvents({paymentReference:r,contractAddress:c.address,toAddress:t,eventName:e,paymentChain:a})}else{const n=new o.EthProxyInfoRetriever(r,c.address,c.creationBlockNumber,t,e,a);d={paymentEvents:yield n.getTransferEvents()}}f.push(...d.paymentEvents),p=d.escrowEvents}return{paymentEvents:f,escrowEvents:p}}))}}t.EthInputDataPaymentDetector=l,l.getDeploymentInformation=(0,c.makeGetDeploymentInformation)(f.ethereumProxyArtifact,d,!0)},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.EthInputDataInfoRetriever=void 0;const n=r(13),f=r(716);t.EthInputDataInfoRetriever=class{constructor(e,t,r,n,f){this.toAddress=e,this.eventName=t,this.network=r,this.paymentReference=n,this.explorerApiKey=f}getTransferEvents(){return n.__awaiter(this,void 0,void 0,(function*(){if("private"===this.network)throw new Error("ETH input data info-retriever works with etherscan and cannot work on a local network");const e=new f.MultichainExplorerApiProvider(this.network,this.explorerApiKey),t=yield e.getHistory(this.toAddress);return t.filter(((e,r)=>t.findIndex((t=>t.hash===e.hash))===r)).filter((e=>e.to&&e.to.toLowerCase()===this.toAddress.toLowerCase())).filter((e=>e.data.toLowerCase()==="0x"+this.paymentReference.toLowerCase())).map((e=>({amount:e.value.toString(),name:this.eventName,parameters:{block:e.blockNumber,confirmations:e.confirmations,txHash:e.hash},timestamp:e.timestamp})))}))}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.MultichainExplorerApiProvider=void 0;const n=r(3),f={sokol:{chainId:77,name:"sokol"},fuse:{chainId:122,name:"fuse"},celo:{chainId:42220,name:"celo"},fantom:{chainId:250,name:"fantom"},"arbitrum-rinkeby":{chainId:421611,name:"arbitrum-rinkeby"},"arbitrum-one":{chainId:42161,name:"arbitrum-one"},avalanche:{chainId:43114,name:"avalanche"},bsc:{chainId:56,name:"bsc"},optimism:{chainId:10,name:"optimism"},moonbeam:{chainId:1284,name:"moonbeam"},tombchain:{chainId:6969,name:"tombchain"},mantle:{chainId:5e3,name:"mantle"},"mantle-testnet":{chainId:5001,name:"mantle-testnet"}};class a extends n.ethers.providers.EtherscanProvider{constructor(e,t){"string"==typeof e&&f[e]&&(e=f[e]),t||"mainnet"!==e&&"rinkeby"!==e||(t="TCVQQU5V39TAS1V6HF61P9K7IJZVEHH1D9"),super(e,t)}getBaseUrl(){switch(this.network.name){case"sokol":case"xdai":return"https://api.gnosisscan.io";case"fuse":return"https://explorer.fuse.io";case"celo":return"https://api.celoscan.io";case"matic":return"https://api.polygonscan.com";case"fantom":return"https://api.ftmscan.com";case"bsctest":return"https://api-testnet.bscscan.com/";case"bsc":return"https://api.bscscan.com/";case"aurora":return"https://explorer.mainnet.near.org";case"aurora-testnet":case"near-testnet":return"https://explorer.testnet.near.org";case"arbitrum-rinkeby":return"https://testnet.arbiscan.io/";case"arbitrum-one":return"https://api.arbiscan.io";case"avalanche":return"https://api.snowtrace.io";case"mantle":return"https://explorer.mantle.xyz/";case"mantle-testnet":return"https://explorer.testnet.mantle.xyz/";default:return super.getBaseUrl()}}}t.MultichainExplorerApiProvider=a},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.EthFeeProxyPaymentDetector=void 0;const n=r(13),f=r(50),a=r(4),i=r(297),o=r(99),s=r(36),c=r(68),u={"0.1.0":"0.1.0","0.2.0":"0.2.0"};class d extends o.FeeReferenceBasedDetector{constructor({advancedLogic:e,currencyManager:t,getSubgraphClient:r}){super(a.ExtensionTypes.PAYMENT_NETWORK_ID.ETH_FEE_PROXY_CONTRACT,e.extensions.feeProxyContractEth,t),this.getSubgraphClient=r}extractEvents(e,t,r,f,a,o){return n.__awaiter(this,void 0,void 0,(function*(){if(!t)return{paymentEvents:[]};const n=d.getDeploymentInformation(a,o.version),f=this.getSubgraphClient(a);if(f){return new c.TheGraphInfoRetriever(f,this.currencyManager).getTransferEvents({paymentReference:r,contractAddress:n.address,toAddress:t,eventName:e,paymentChain:a})}{const f=new i.EthProxyInfoRetriever(r,n.address,n.creationBlockNumber,t,e,a);return{paymentEvents:yield f.getTransferEvents()}}}))}}t.EthFeeProxyPaymentDetector=d,d.getDeploymentInformation=(0,s.makeGetDeploymentInformation)(f.ethereumFeeProxyArtifact,u)},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AnyToERC20PaymentDetector=void 0;const n=r(13),f=r(50),a=r(4),i=r(257),o=r(719),s=r(300),c=r(36),u=r(8),d=r(33),l={"0.1.0":"0.1.0"};class p extends i.ERC20FeeProxyPaymentDetectorBase{constructor({advancedLogic:e,currencyManager:t,getSubgraphClient:r}){super(a.ExtensionTypes.PAYMENT_NETWORK_ID.ANY_TO_ERC20_PROXY,e.extensions.anyToErc20Proxy,t),this.getSubgraphClient=r}createExtensionsDataForCreation(e){return n.__awaiter(this,void 0,void 0,(function*(){const t=e.salt||(yield(0,u.generate8randomBytes)());return this.extension.createCreationAction({feeAddress:e.feeAddress,feeAmount:e.feeAmount,paymentAddress:e.paymentAddress,refundAddress:e.refundAddress,network:e.network,acceptedTokens:e.acceptedTokens,maxRateTimespan:e.maxRateTimespan,salt:t})}))}extractEvents(e,t,r,a,i,c){return n.__awaiter(this,void 0,void 0,(function*(){if(!t)return{paymentEvents:[]};const{acceptedTokens:n,maxRateTimespan:u=0}=c.values,{address:d,creationBlockNumber:l}=p.getDeploymentInformation(i,c.version),h=f.erc20ConversionProxy.getContractAbi(c.version),b=yield this.getCurrency(a),m=this.getSubgraphClient(i);if(m){const f=new s.TheGraphConversionInfoRetriever(m,this.currencyManager);return yield f.getTransferEvents({paymentReference:r,contractAddress:d,toAddress:t,eventName:e,paymentChain:i,acceptedTokens:n,maxRateTimespan:u,requestCurrency:b})}const y=new o.AnyToErc20InfoRetriever(b,r,d,l,h,t,e,i,n,u);return{paymentEvents:yield y.getTransferEvents()}}))}getPaymentChain(e){const t=this.getPaymentExtension(e).values.network;if(!t)throw Error(`request.extensions[${this.paymentNetworkId}].values.network must be defined`);return d.EvmChains.assertChainSupported(t),t}}t.AnyToERC20PaymentDetector=p,p.getDeploymentInformation=(0,c.makeGetDeploymentInformation)(f.erc20ConversionProxy,l)},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AnyToErc20InfoRetriever=void 0;const n=r(299);class f extends n.ConversionInfoRetriever{getFeeFilter(){const e=this.contractConversionProxy.filters.TransferWithReferenceAndFee(null,null,null,"0x"+this.paymentReference);return e.fromBlock=this.conversionProxyCreationBlockNumber,e.toBlock="latest",e}}t.AnyToErc20InfoRetriever=f},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AnyToEthFeeProxyPaymentDetector=void 0;const n=r(13),f=r(50),a=r(4),i=r(33),o=r(721),s=r(293),c=r(36),u=r(300),d={"0.1.0":"0.1.0","0.2.0":"0.2.0"};class l extends s.AnyToAnyDetector{constructor({advancedLogic:e,currencyManager:t,getSubgraphClient:r}){super(a.ExtensionTypes.PAYMENT_NETWORK_ID.ANY_TO_ETH_PROXY,e.extensions.anyToEthProxy,t),this.getSubgraphClient=r}extractEvents(e,t,r,a,s,c){var d,p;return n.__awaiter(this,void 0,void 0,(function*(){if(!t)return{paymentEvents:[]};const n=l.getDeploymentInformation(s,c.version),h=this.currencyManager.fromStorageCurrency(a);if(!h)throw new i.UnsupportedCurrencyError(a.value);const b=this.getSubgraphClient(s);if(b){const f=new u.TheGraphConversionInfoRetriever(b,this.currencyManager);return yield f.getTransferEvents({paymentReference:r,contractAddress:n.address,toAddress:t,eventName:e,paymentChain:s,maxRateTimespan:null===(d=c.values)||void 0===d?void 0:d.maxRateTimespan,requestCurrency:h})}const m=f.ethConversionArtifact.getContractAbi(n.contractVersion),y=new o.AnyToEthInfoRetriever(h,r,n.address,n.creationBlockNumber,m,t,e,s,void 0,null===(p=c.values)||void 0===p?void 0:p.maxRateTimespan);return{paymentEvents:yield y.getTransferEvents()}}))}getPaymentChain(e){const t=this.getPaymentExtension(e).values.network;if(!t)throw Error(`request.extensions[${this.paymentNetworkId}].values.network must be defined`);return i.EvmChains.assertChainSupported(t),t}}t.AnyToEthFeeProxyPaymentDetector=l,l.getDeploymentInformation=(0,c.makeGetDeploymentInformation)(f.ethConversionArtifact,d)},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AnyToEthInfoRetriever=void 0;const n=r(299);class f extends n.ConversionInfoRetriever{getFeeFilter(){const e=this.contractConversionProxy.filters.TransferWithReferenceAndFee(null,null,"0x"+this.paymentReference);return e.fromBlock=this.conversionProxyCreationBlockNumber,e.toBlock="latest",e}}t.AnyToEthInfoRetriever=f},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.EscrowERC20InfoRetriever=void 0;const n=r(13),f=r(4),a=r(50),i=r(3),o=r(36),s=r(8),c={"0.1.0":"0.1.0","0.2.0":"0.1.0"};class u{constructor(e,t,r,n,f,o,c){this.paymentReference=e,this.escrowContractAddress=t,this.escrowCreationBlockNumber=r,this.tokenContractAddress=n,this.toAddress=f,this.network=o,this.eventName=c,this.provider=(0,s.getDefaultProvider)(this.network),this.contractEscrow=new i.ethers.Contract(this.escrowContractAddress,a.erc20EscrowToPayArtifact.getContractAbi(),this.provider)}getAllContractEvents(){return n.__awaiter(this,void 0,void 0,(function*(){return[...yield this.getContractEventsForEventName(f.PaymentTypes.ESCROW_EVENTS_NAMES.FREEZE_ESCROW),...yield this.getContractEventsForEventName(f.PaymentTypes.ESCROW_EVENTS_NAMES.INITIATE_EMERGENCY_CLAIM),...yield this.getContractEventsForEventName(f.PaymentTypes.ESCROW_EVENTS_NAMES.REVERT_EMERGENCY_CLAIM)]}))}getContractEvents(){return n.__awaiter(this,void 0,void 0,(function*(){if(!this.eventName)throw new Error("Missing event name in EscrowInfoRetriever for getContractEvents()");return this.getContractEventsForEventName(this.eventName)}))}getContractEventsForEventName(e){return n.__awaiter(this,void 0,void 0,(function*(){const t=e===f.PaymentTypes.ESCROW_EVENTS_NAMES.FREEZE_ESCROW?this.contractEscrow.filters.RequestFrozen("0x"+this.paymentReference):e===f.PaymentTypes.ESCROW_EVENTS_NAMES.INITIATE_EMERGENCY_CLAIM?this.contractEscrow.filters.InitiatedEmergencyClaim("0x"+this.paymentReference):e===f.PaymentTypes.ESCROW_EVENTS_NAMES.REVERT_EMERGENCY_CLAIM?this.contractEscrow.filters.RevertedEmergencyClaim("0x"+this.paymentReference):e===f.PaymentTypes.ESCROW_EVENTS_NAMES.PAID_ESCROW?this.contractEscrow.filters.TransferWithReferenceAndFee(null,null,null,"0x"+this.paymentReference,null,null):void 0;if(!t)throw new Error("Wrong eventName for Escrow event retriever");t.fromBlock=this.escrowCreationBlockNumber,t.toBlock="latest";const r=(yield this.provider.getLogs(t)).map((e=>{const t=this.contractEscrow.interface.parseLog(e);return Object.assign(Object.assign({},e),{parsedLog:(0,o.parseLogArgs)(t)})})).filter((({parsedLog:e})=>!e.tokenAddress||e.tokenAddress.toLowerCase()===this.tokenContractAddress.toLowerCase()&&e.to.toLowerCase()===this.toAddress.toLowerCase())).map((({parsedLog:t,blockNumber:r,transactionHash:f})=>n.__awaiter(this,void 0,void 0,(function*(){var n,a;return{amount:(null===(n=t.amount)||void 0===n?void 0:n.toString())||void 0,name:e,parameters:{block:r,paymentReference:t.paymentReference,feeAddress:t.feeAddress||void 0,feeAmount:(null===(a=t.feeAmount)||void 0===a?void 0:a.toString())||void 0,to:this.toAddress||void 0,txHash:f},timestamp:(yield this.provider.getBlock(r||0)).timestamp}}))));return Promise.all(r)}))}getEscrowRequestMapping(){return n.__awaiter(this,void 0,void 0,(function*(){return this.contractEscrow.requestMapping(`0x${this.paymentReference}`)}))}}t.EscrowERC20InfoRetriever=u,u.getEscrowDeploymentInformation=(0,o.makeGetDeploymentInformation)(a.erc20EscrowToPayArtifact,c)},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(33),f=r(302),a=r(325),i=r(840),o=r(848);class s extends f.default{constructor({decryptionProvider:e,httpConfig:t,nodeConnectionConfig:r,signatureProvider:f,useMockStorage:s,currencies:c,currencyManager:u,paymentOptions:d}={httpConfig:{},nodeConnectionConfig:{},useMockStorage:!1}){const l=s?new i.default(new o.default):new a.default({httpConfig:t,nodeConnectionConfig:r});u||(u=new n.CurrencyManager(c||n.CurrencyManager.getDefaultList())),super({dataAccess:l,signatureProvider:f,decryptionProvider:e,currencyManager:u,paymentOptions:d})}}t.default=s},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AdvancedLogic=void 0;var n=r(725);Object.defineProperty(t,"AdvancedLogic",{enumerable:!0,get:function(){return n.default}})},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(4),f=r(33),a=r(726),i=r(304),o=r(727),s=r(305),c=r(728),u=r(306),d=r(729),l=r(730),p=r(307),h=r(731),b=r(308),m=r(733),y=r(734),g=r(735),v=r(309),_=r(737),w=r(738);t.default=class{constructor(e){e||(e=f.CurrencyManager.getDefault()),this.extensions={addressBasedBtc:new i.default,addressBasedErc20:new c.default,addressBasedTestnetBtc:new o.default,contentData:new a.default,anyToErc20Proxy:new y.default(e),declarative:new s.default,ethereumInputData:new h.default,feeProxyContractErc20:new u.default,proxyContractErc20:new d.default,erc777Stream:new l.default,feeProxyContractEth:new p.default,anyToEthProxy:new g.default(e),nativeToken:[new b.default,new m.default],anyToNativeToken:[new v.default(e),new _.default(e)],erc20TransferableReceivable:new w.default}}applyActionToExtensions(e,t,r,n,f){return this.getExtensionForActionAndState(t,r).applyActionToExtension(e,t,r,n,f)}getExtensionForActionAndState(e,t){const r=e.id,f=this.getNetwork(e,t)||t.currency.network,a={[n.ExtensionTypes.ID.CONTENT_DATA]:this.extensions.contentData,[n.ExtensionTypes.PAYMENT_NETWORK_ID.BITCOIN_ADDRESS_BASED]:this.extensions.addressBasedBtc,[n.ExtensionTypes.PAYMENT_NETWORK_ID.TESTNET_BITCOIN_ADDRESS_BASED]:this.extensions.addressBasedTestnetBtc,[n.ExtensionTypes.PAYMENT_NETWORK_ID.ANY_DECLARATIVE]:this.extensions.declarative,[n.ExtensionTypes.PAYMENT_NETWORK_ID.ERC20_ADDRESS_BASED]:this.extensions.addressBasedErc20,[n.ExtensionTypes.PAYMENT_NETWORK_ID.ERC20_PROXY_CONTRACT]:this.extensions.proxyContractErc20,[n.ExtensionTypes.PAYMENT_NETWORK_ID.ERC20_FEE_PROXY_CONTRACT]:this.getFeeProxyContractErc20ForNetwork(f),[n.ExtensionTypes.PAYMENT_NETWORK_ID.ERC777_STREAM]:this.extensions.erc777Stream,[n.ExtensionTypes.PAYMENT_NETWORK_ID.ETH_INPUT_DATA]:this.extensions.ethereumInputData,[n.ExtensionTypes.PAYMENT_NETWORK_ID.NATIVE_TOKEN]:this.getNativeTokenExtensionForNetwork(f),[n.ExtensionTypes.PAYMENT_NETWORK_ID.ANY_TO_ERC20_PROXY]:this.extensions.anyToErc20Proxy,[n.ExtensionTypes.PAYMENT_NETWORK_ID.ETH_FEE_PROXY_CONTRACT]:this.extensions.feeProxyContractEth,[n.ExtensionTypes.PAYMENT_NETWORK_ID.ANY_TO_ETH_PROXY]:this.extensions.anyToEthProxy,[n.ExtensionTypes.PAYMENT_NETWORK_ID.ANY_TO_NATIVE_TOKEN]:this.getAnyToNativeTokenExtensionForNetwork(f),[n.ExtensionTypes.PAYMENT_NETWORK_ID.ERC20_TRANSFERABLE_RECEIVABLE]:this.extensions.erc20TransferableReceivable}[r];if(!a){if(r===n.ExtensionTypes.PAYMENT_NETWORK_ID.NATIVE_TOKEN||r===n.ExtensionTypes.PAYMENT_NETWORK_ID.ANY_TO_NATIVE_TOKEN)throw Error(`extension with id: ${r} not found for network: ${f}`);throw Error(`extension not recognized, id: ${r}`)}return a}getNativeTokenExtensionForNetwork(e){return e?this.extensions.nativeToken.find((t=>t.supportedNetworks.includes(e))):void 0}getAnyToNativeTokenExtensionForNetwork(e){return e?this.extensions.anyToNativeToken.find((t=>t.supportedNetworks.includes(e))):void 0}getFeeProxyContractErc20ForNetwork(e){return f.NearChains.isChainSupported(e)?new u.default(void 0,void 0,e):this.extensions.feeProxyContractErc20}getNetwork(e,t){var r,a;if(t.currency.network&&e.parameters.paymentNetworkName&&!(0,f.isSameChain)(t.currency.network,e.parameters.paymentNetworkName))throw new Error(`Cannot apply action for network ${e.parameters.paymentNetworkName} on state with payment network: ${t.currency.network}`);return"create"===e.action?e.parameters.network:null===(a=null===(r=t.extensions[n.ExtensionTypes.PAYMENT_NETWORK_ID.ANY_TO_NATIVE_TOKEN])||void 0===r?void 0:r.values)||void 0===a?void 0:a.network}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(4),f=r(303);class a extends f.AbstractExtension{constructor(){super(n.ExtensionTypes.TYPE.CONTENT_DATA,n.ExtensionTypes.ID.CONTENT_DATA,"0.1.0")}createCreationAction(e){if(!e.content)throw Error("No content has been given for the extension content-data");return super.createCreationAction(e)}applyCreation(e,t){if(!e.parameters.content)throw Error("No content has been given for the extension content-data");const r=super.applyCreation(e,t);return Object.assign(Object.assign({},r),{events:[],id:this.extensionId,type:this.extensionType,values:Object.assign(Object.assign({},r.values),{content:e.parameters.content})})}}t.default=a},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(304),f=r(4);class a extends n.default{constructor(){super(f.ExtensionTypes.PAYMENT_NETWORK_ID.TESTNET_BITCOIN_ADDRESS_BASED)}isValidAddress(e){return this.isValidAddressForSymbolAndNetwork(e,"BTC-testnet","testnet")}}t.default=a},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(4),f=r(81);class a extends f.default{constructor(){super(n.ExtensionTypes.PAYMENT_NETWORK_ID.ERC20_ADDRESS_BASED,"0.1.0",n.RequestLogicTypes.CURRENCY.ERC20)}}t.default=a},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(4),f=r(101);class a extends f.default{constructor(){super(n.ExtensionTypes.PAYMENT_NETWORK_ID.ERC20_PROXY_CONTRACT,"0.1.0",n.RequestLogicTypes.CURRENCY.ERC20)}}t.default=a},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(4),f=r(101),a=r(8);class i extends f.default{constructor(){super(n.ExtensionTypes.PAYMENT_NETWORK_ID.ERC777_STREAM,"0.1.0",n.RequestLogicTypes.CURRENCY.ERC777)}createCreationAction(e){if(!n.TypesUtils.isOriginalRequestCreationParameters(e)&&!n.TypesUtils.isSubsequentRequestCreationParameters(e))throw Error("originalRequestId, previousRequestId and recurrenceNumber must be all empty or all filled");if(n.TypesUtils.isOriginalRequestCreationParameters(e)){if(!e.expectedFlowRate)throw Error("expectedFlowRate should not be empty");if(!e.expectedStartDate)throw Error("expectedStartDate should not be empty");return super.createCreationAction(e)}if(!this.isSubsequentRequestParametersValid(e))throw Error("recurrenceNumber must be 1 if originalRequestId and previousRequestId are equal and vice versa");return{action:n.ExtensionTypes.PnFeeReferenceBased.ACTION.CREATE,id:this.extensionId,parameters:e,version:this.currentVersion}}applyCreation(e,t){if(!n.TypesUtils.isOriginalRequestCreationParameters(e.parameters)&&!n.TypesUtils.isSubsequentRequestCreationParameters(e.parameters))throw Error("originalRequestId, previousRequestId and recurrenceNumber must be all empty or all filled");if(n.TypesUtils.isOriginalRequestCreationParameters(e.parameters)){if(!e.parameters.expectedStartDate||e.parameters.expectedStartDate&&!(0,a.isValidAmount)(e.parameters.expectedStartDate))throw Error("expectedStartDate is empty or invalid");if(!e.parameters.expectedFlowRate||e.parameters.expectedFlowRate&&!(0,a.isValidAmount)(e.parameters.expectedFlowRate))throw Error("expectedFlowRate is empty or invalid");const r=super.applyCreation(e,t);return Object.assign(Object.assign({},r),{events:[{name:n.ExtensionTypes.PnFeeReferenceBased.ACTION.CREATE,parameters:e.parameters,timestamp:t}],values:Object.assign(Object.assign({},r.values),{expectedStartDate:e.parameters.expectedStartDate,expectedFlowRate:e.parameters.expectedFlowRate})})}if(!e.parameters.originalRequestId)throw Error("originalRequestId is empty");if(!e.parameters.previousRequestId)throw Error("previousRequestId is empty");if(!e.parameters.recurrenceNumber)throw Error("recurrenceNumber is empty");if(!e.version)throw Error("version is required at creation");if(!this.isSubsequentRequestParametersValid(e.parameters))throw Error("recurrenceNumber must be 1 if originalRequestId and previousRequestId are equal and vice versa");return{events:[{name:n.ExtensionTypes.PnFeeReferenceBased.ACTION.CREATE,parameters:e.parameters,timestamp:t}],id:e.id,type:this.extensionType,values:e.parameters,version:e.version}}isSubsequentRequestParametersValid(e){return e.originalRequestId===e.previousRequestId&&1===e.recurrenceNumber||1!==e.recurrenceNumber&&e.originalRequestId!==e.previousRequestId}}t.default=i},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(4),f=r(101);class a extends f.default{constructor(e=n.ExtensionTypes.PAYMENT_NETWORK_ID.ETH_INPUT_DATA,t="0.3.0"){super(e,t,n.RequestLogicTypes.CURRENCY.ETH)}}t.default=a},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(4),f=r(81),a=r(101);class i extends a.default{constructor(e,t,r){super(e,t,n.RequestLogicTypes.CURRENCY.ETH),this.supportedNetworks=r}createCreationAction(e){const t=e.paymentNetworkName;if(e.paymentAddress||e.refundAddress){if(!t)throw new Error(`The network name is mandatory for the creation of the extension ${this.extensionId}.`);this.throwIfInvalidNetwork(t)}if(e.paymentAddress&&!this.isValidAddress(e.paymentAddress))throw new f.InvalidPaymentAddressError(e.paymentAddress);if(e.refundAddress&&!this.isValidAddress(e.refundAddress))throw new f.InvalidPaymentAddressError(e.refundAddress,"refundAddress");return super.createCreationAction(e)}isValidAddress(e){throw new Error("Default implementation of isValidAddress() does not support native tokens. Please override this method.")}throwIfInvalidNetwork(e){if(super.throwIfInvalidNetwork(e),this.supportedNetworks&&!this.supportedNetworks.includes(e))throw new f.UnsupportedNetworkError(e,this.supportedNetworks)}}t.default=i},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(308);class f extends n.default{constructor(){super(["aurora-testnet","near-testnet"])}isValidAddress(e){return this.isValidAddressForSymbolAndNetwork(e,"NEAR-testnet","aurora-testnet")}}t.default=f},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(33),f=r(4),a=r(306);class i extends a.default{constructor(e,t=f.ExtensionTypes.PAYMENT_NETWORK_ID.ANY_TO_ERC20_PROXY,r="0.1.0"){super(t,r),this.currencyManager=e}createCreationAction(e){if(!e.acceptedTokens||0===e.acceptedTokens.length)throw Error("acceptedTokens is required");if(e.acceptedTokens.some((e=>!this.isValidAddress(e))))throw Error("acceptedTokens must contains only valid ethereum addresses");const t=e.network;this.throwIfInvalidNetwork(t);for(const r of e.acceptedTokens){const e=this.currencyManager.fromAddress(r,t);if(!e)throw new n.UnsupportedCurrencyError({value:r,network:t});if(!this.currencyManager.supportsConversion(e,t))throw Error(`acceptedTokens must contain only supported token addresses (ERC20 only). ${r} is not supported for ${t}.`)}return super.createCreationAction(e)}applyCreation(e,t){if(!e.parameters.network||0===e.parameters.network.length)throw Error("network is required");if(!e.parameters.acceptedTokens||0===e.parameters.acceptedTokens.length)throw Error("acceptedTokens is required and cannot be empty");if(e.parameters.acceptedTokens.some((e=>!this.isValidAddress(e))))throw Error("acceptedTokens must contains only valid ethereum addresses");const r=super.applyCreation(e,t);return Object.assign(Object.assign({},r),{events:[{name:"create",parameters:{feeAddress:e.parameters.feeAddress,feeAmount:e.parameters.feeAmount,paymentAddress:e.parameters.paymentAddress,refundAddress:e.parameters.refundAddress,salt:e.parameters.salt,network:e.parameters.network,acceptedTokens:e.parameters.acceptedTokens,maxRateTimespan:e.parameters.maxRateTimespan},timestamp:t}],values:Object.assign(Object.assign({},r.values),{network:e.parameters.network,acceptedTokens:e.parameters.acceptedTokens,maxRateTimespan:e.parameters.maxRateTimespan})})}validate(e,t){var r;const a=t.action===f.ExtensionTypes.PnFeeReferenceBased.ACTION.CREATE?t.parameters.network:null===(r=e.extensions[this.extensionId])||void 0===r?void 0:r.values.network;if(!a)return;if(!a)return;if(!n.conversionSupportedNetworks.includes(a))throw new Error(`The network (${a}) is not supported for this payment network.`);const i=this.currencyManager.fromStorageCurrency(e.currency);if(!i)throw new n.UnsupportedCurrencyError(e.currency);if(!this.currencyManager.supportsConversion(i,a))throw new Error(`The currency (${i.id}, ${i.hash}) of the request is not supported for this payment network.`)}}t.default=i},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(33),f=r(4),a=r(307);class i extends a.default{constructor(e){super(f.ExtensionTypes.PAYMENT_NETWORK_ID.ANY_TO_ETH_PROXY,"0.2.0"),this.currencyManager=e}createCreationAction(e){return this.throwIfInvalidNetwork(e.network),super.createCreationAction(e)}applyCreation(e,t){if(!e.parameters.network||0===e.parameters.network.length)throw Error("network is required");const r=super.applyCreation(e,t);return Object.assign(Object.assign({},r),{events:[{name:"create",parameters:{feeAddress:e.parameters.feeAddress,feeAmount:e.parameters.feeAmount,paymentAddress:e.parameters.paymentAddress,refundAddress:e.parameters.refundAddress,salt:e.parameters.salt,network:e.parameters.network,maxRateTimespan:e.parameters.maxRateTimespan},timestamp:t}],values:Object.assign(Object.assign({},r.values),{network:e.parameters.network,maxRateTimespan:e.parameters.maxRateTimespan})})}validate(e,t){var r;const a=t.action===f.ExtensionTypes.PnFeeReferenceBased.ACTION.CREATE?t.parameters.network:null===(r=e.extensions[this.extensionId])||void 0===r?void 0:r.values.network;if(!a)throw new Error("The network must be provided from the creation action or from the extension state");const i=this.currencyManager.fromStorageCurrency(e.currency);if(!i)throw new n.UnsupportedCurrencyError(e.currency);if(!this.currencyManager.supportsConversion(i,a))throw new Error(`The currency (${e.currency.value}) of the request is not supported for this payment network.`)}}t.default=i},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.InvalidMaxRateTimespanError=void 0;const n=r(115),f=r(4),a=r(81);class i extends n.FeeReferenceBasedPaymentNetwork{constructor(e,t,r){super(e,t,f.RequestLogicTypes.CURRENCY.ETH),this.supportedNetworks=r}createCreationAction(e){const t=e.network;if(this.throwIfInvalidNetwork(t),e.paymentAddress&&!this.isValidAddress(e.paymentAddress))throw new a.InvalidPaymentAddressError(e.paymentAddress);if(e.refundAddress&&!this.isValidAddress(e.refundAddress))throw new a.InvalidPaymentAddressError(e.refundAddress,"refundAddress");if(e.feeAddress&&!this.isValidAddress(e.feeAddress))throw new a.InvalidPaymentAddressError(e.feeAddress,"feeAddress");if(e.maxRateTimespan&&e.maxRateTimespan<0)throw new o(e.maxRateTimespan);return super.createCreationAction(e)}isValidAddress(e){throw new Error("Default implementation of isValidAddress() does not support native tokens. Please override this method.")}throwIfInvalidNetwork(e){if(super.throwIfInvalidNetwork(e),this.supportedNetworks&&!this.supportedNetworks.includes(e))throw new a.UnsupportedNetworkError(e,this.supportedNetworks)}}t.default=i;class o extends Error{constructor(e){super(`${e} is not a valid maxRateTimespan`)}}t.InvalidMaxRateTimespanError=o},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(309);class f extends n.default{constructor(e){super(e,["aurora-testnet","near-testnet"])}isValidAddress(e){return this.isValidAddressForSymbolAndNetwork(e,"NEAR-testnet","aurora-testnet")}}t.default=f},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(4),f=r(115);class a extends f.FeeReferenceBasedPaymentNetwork{constructor(e=n.ExtensionTypes.PAYMENT_NETWORK_ID.ERC20_TRANSFERABLE_RECEIVABLE,t="0.2.0"){super(e,t,n.RequestLogicTypes.CURRENCY.ERC20)}}t.default=a},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.RequestLogic=void 0;var n=r(740);Object.defineProperty(t,"RequestLogic",{enumerable:!0,get:function(){return n.default}})},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(741),f=r(32),a=r(52),i=r(4),o=r(752),s=r(8);t.default=class{constructor(e,t,r){this.transactionManager=e,this.signatureProvider=t,this.advancedLogic=r}createRequest(e,t,r=[]){return n.__awaiter(this,void 0,void 0,(function*(){const{action:n,requestId:f,hashedTopics:a}=yield this.createCreationActionRequestIdAndTopics(e,t,r);return o.default.applyActionToRequest(null,n,Date.now(),this.advancedLogic),this.persistTransaction(f,n,{requestId:f},a)}))}createEncryptedRequest(e,t,r,f=[]){return n.__awaiter(this,void 0,void 0,(function*(){if(0===r.length)throw new Error("You must give at least one encryption parameter to create an encrypted request");const{action:n,requestId:a,hashedTopics:i}=yield this.createCreationActionRequestIdAndTopics(e,t,f);return o.default.applyActionToRequest(null,n,Date.now(),this.advancedLogic),this.persistTransaction(a,n,{requestId:a},i,r)}))}computeRequestId(e,t){return n.__awaiter(this,void 0,void 0,(function*(){if(!this.signatureProvider)throw new Error("You must give a signature provider to create actions");const r=yield o.default.formatCreate(e,t,this.signatureProvider);return o.default.applyActionToRequest(null,r,Date.now(),this.advancedLogic),o.default.getRequestIdFromAction(r)}))}acceptRequest(e,t,r=!1){return n.__awaiter(this,void 0,void 0,(function*(){if(!this.signatureProvider)throw new Error("You must give a signature provider to create actions");const n=yield o.default.formatAccept(e,t,this.signatureProvider),f=o.default.getRequestIdFromAction(n);return r&&(yield this.validateAction(f,n)),this.persistTransaction(f,n,void 0)}))}cancelRequest(e,t,r=!1){return n.__awaiter(this,void 0,void 0,(function*(){if(!this.signatureProvider)throw new Error("You must give a signature provider to create actions");const n=yield o.default.formatCancel(e,t,this.signatureProvider),f=o.default.getRequestIdFromAction(n);return r&&(yield this.validateAction(f,n)),this.persistTransaction(f,n,void 0)}))}increaseExpectedAmountRequest(e,t,r=!1){return n.__awaiter(this,void 0,void 0,(function*(){if(!this.signatureProvider)throw new Error("You must give a signature provider to create actions");const n=yield o.default.formatIncreaseExpectedAmount(e,t,this.signatureProvider),f=o.default.getRequestIdFromAction(n);return r&&(yield this.validateAction(f,n)),this.persistTransaction(f,n,void 0)}))}reduceExpectedAmountRequest(e,t,r=!1){return n.__awaiter(this,void 0,void 0,(function*(){if(!this.signatureProvider)throw new Error("You must give a signature provider to create actions");const n=yield o.default.formatReduceExpectedAmount(e,t,this.signatureProvider),f=o.default.getRequestIdFromAction(n);return r&&(yield this.validateAction(f,n)),this.persistTransaction(f,n,void 0)}))}addStakeholders(e,t,r,f=!1){return n.__awaiter(this,void 0,void 0,(function*(){if(!this.signatureProvider)throw new Error("You must give a signature provider to create actions");const n=yield o.default.formatAddStakeholders(e,t,this.signatureProvider),a=o.default.getRequestIdFromAction(n);return f&&(yield this.validateAction(a,n)),this.persistTransaction(a,n,void 0,[],r)}))}addExtensionsDataRequest(e,t,r=!1){return n.__awaiter(this,void 0,void 0,(function*(){if(!this.signatureProvider)throw new Error("You must give a signature provider to create actions");const n=yield o.default.formatAddExtensionsData(e,t,this.signatureProvider),f=o.default.getRequestIdFromAction(n);return r&&(yield this.validateAction(f,n)),this.persistTransaction(f,n,void 0)}))}getRequestFromId(e){return n.__awaiter(this,void 0,void 0,(function*(){const{ignoredTransactions:t,confirmedRequestState:r,pendingRequestState:n,transactionManagerMeta:f}=yield this.computeRequestFromRequestId(e);return{meta:{ignoredTransactions:t,transactionManagerMeta:f},result:{request:r,pending:this.computeDiffBetweenPendingAndConfirmedRequestState(r,n)}}}))}getRequestsByTopic(e,t){return n.__awaiter(this,void 0,void 0,(function*(){const r=a.default.serialize((0,s.normalizeKeccak256Hash)(e)),n=yield this.transactionManager.getChannelsByTopic(r,t);return this.computeMultipleRequestFromChannels(n)}))}getRequestsByMultipleTopics(e,t){return n.__awaiter(this,void 0,void 0,(function*(){const r=e.map((e=>a.default.serialize((0,s.normalizeKeccak256Hash)(e)))),n=yield this.transactionManager.getChannelsByMultipleTopics(r,t);return this.computeMultipleRequestFromChannels(n)}))}createCreationActionRequestIdAndTopics(e,t,r){return n.__awaiter(this,void 0,void 0,(function*(){if(!this.signatureProvider)throw new Error("You must give a signature provider to create actions");const n=yield o.default.formatCreate(e,t,this.signatureProvider),f=o.default.getRequestIdFromAction(n);return{action:n,hashedTopics:r.map((e=>a.default.serialize((0,s.normalizeKeccak256Hash)(e)))),requestId:f}}))}computeRequestFromRequestId(e){return n.__awaiter(this,void 0,void 0,(function*(){const t=yield this.transactionManager.getTransactionsByChannelId(e),r=t.result.transactions.filter(s.notNull).sort(((e,t)=>e.timestamp-t.timestamp));let{ignoredTransactions:n,keptTransactions:f}=this.removeOldPendingTransactions(r);const a=(0,s.uniqueByProperty)(f.filter(s.notNull).map((e=>{try{return{action:JSON.parse(e.transaction.data||""),state:e.state,timestamp:e.timestamp}}catch(t){return void n.push({reason:"JSON parsing error",transaction:e})}})).filter(s.notNull),"action");n=n.concat(a.duplicates.map((e=>({reason:"Duplicated transaction",transaction:e}))));const{confirmedRequestState:i,pendingRequestState:o,ignoredTransactionsByApplication:c}=yield this.computeRequestFromTransactions(a.uniqueItems);return n=n.concat(c),{confirmedRequestState:i,ignoredTransactions:n,pendingRequestState:o,transactionManagerMeta:t.meta}}))}computeRequestFromTransactions(e){return n.__awaiter(this,void 0,void 0,(function*(){const t=[],r=e.filter((e=>e.state===i.TransactionTypes.TransactionState.CONFIRMED)).reduce(((e,r)=>{try{return o.default.applyActionToRequest(e,r.action,r.timestamp,this.advancedLogic)}catch(n){return t.push({reason:n.message,transaction:r}),e}}),null),n=e.filter((e=>e.state===i.TransactionTypes.TransactionState.PENDING)).reduce(((e,r)=>{try{return o.default.applyActionToRequest(e,r.action,r.timestamp,this.advancedLogic)}catch(n){return t.push({reason:n.message,transaction:r}),e}}),r);return{confirmedRequestState:r,ignoredTransactionsByApplication:t,pendingRequestState:n}}))}computeMultipleRequestFromChannels(e){return n.__awaiter(this,void 0,void 0,(function*(){const t=e.result.transactions,r=e.meta.dataAccessMeta,f=Object.keys(e.result.transactions).map((e=>n.__awaiter(this,void 0,void 0,(function*(){let{ignoredTransactions:n,keptTransactions:f}=this.removeOldPendingTransactions(t[e]);const a=(0,s.uniqueByProperty)(f.filter(s.notNull).map((e=>{try{return{action:JSON.parse(e.transaction.data||""),state:e.state,timestamp:e.timestamp}}catch(t){return void n.push({reason:"JSON parsing error",transaction:e})}})).filter(s.notNull),"action");n=n.concat(a.duplicates.map((e=>({reason:"Duplicated transaction",transaction:e}))));const{confirmedRequestState:i,pendingRequestState:o,ignoredTransactionsByApplication:c}=yield this.computeRequestFromTransactions(a.uniqueItems);n=n.concat(c);const u=this.computeDiffBetweenPendingAndConfirmedRequestState(i,o);return{ignoredTransactions:n,pending:u,request:i,transactionManagerMeta:r[e]}}))));return(yield Promise.all(f)).reduce(((e,t)=>((t.request||t.pending)&&(e.result.requests.push({pending:t.pending,request:t.request}),(e.meta.ignoredTransactions||[]).push(t.ignoredTransactions),(e.meta.transactionManagerMeta||[]).push(t.transactionManagerMeta)),e)),{meta:{ignoredTransactions:[],transactionManagerMeta:[]},result:{requests:[]}})}))}validateAction(e,t){return n.__awaiter(this,void 0,void 0,(function*(){const{confirmedRequestState:r,pendingRequestState:n}=yield this.computeRequestFromRequestId(e);try{o.default.applyActionToRequest(r,t,Date.now(),this.advancedLogic)}catch(e){n&&o.default.applyActionToRequest(n,t,Date.now(),this.advancedLogic)}}))}computeDiffBetweenPendingAndConfirmedRequestState(e,t){let r=null;if(e){if(t)for(const n in t)n in t&&(0,s.normalizeKeccak256Hash)(t[n]).value!==(0,s.normalizeKeccak256Hash)(e[n]).value&&(r||(r={}),r[n]="events"===n?t[n].slice(e[n].length):t[n])}else r=t;return r}removeOldPendingTransactions(e){const t=[];let r=!1;const n=e.reverse().filter((e=>!!e&&(r=r||e.state===i.TransactionTypes.TransactionState.CONFIRMED,e.state===i.TransactionTypes.TransactionState.CONFIRMED||e.state===i.TransactionTypes.TransactionState.PENDING&&!r||(t.push({reason:"Confirmed transaction newer than this pending transaction",transaction:e}),!1)))).reverse();return{ignoredTransactions:t,keptTransactions:n}}persistTransaction(e,t,r,a=[],i=[]){return n.__awaiter(this,void 0,void 0,(function*(){const n=yield this.transactionManager.persistTransaction(JSON.stringify(t),e,a,i),o=new f.EventEmitter;return n.on("confirmed",(e=>o.emit("confirmed",{meta:{transactionManagerMeta:e.meta},result:r}))).on("error",(e=>o.emit("error",e))),Object.assign(o,{meta:{transactionManagerMeta:n.meta},result:r})}))}}},function(e,t,r){"use strict";r.r(t),r.d(t,"__extends",(function(){return f})),r.d(t,"__assign",(function(){return a})),r.d(t,"__rest",(function(){return i})),r.d(t,"__decorate",(function(){return o})),r.d(t,"__param",(function(){return s})),r.d(t,"__esDecorate",(function(){return c})),r.d(t,"__runInitializers",(function(){return u})),r.d(t,"__propKey",(function(){return d})),r.d(t,"__setFunctionName",(function(){return l})),r.d(t,"__metadata",(function(){return p})),r.d(t,"__awaiter",(function(){return h})),r.d(t,"__generator",(function(){return b})),r.d(t,"__createBinding",(function(){return m})),r.d(t,"__exportStar",(function(){return y})),r.d(t,"__values",(function(){return g})),r.d(t,"__read",(function(){return v})),r.d(t,"__spread",(function(){return _})),r.d(t,"__spreadArrays",(function(){return w})),r.d(t,"__spreadArray",(function(){return E})),r.d(t,"__await",(function(){return A})),r.d(t,"__asyncGenerator",(function(){return T})),r.d(t,"__asyncDelegator",(function(){return x})),r.d(t,"__asyncValues",(function(){return k})),r.d(t,"__makeTemplateObject",(function(){return S})),r.d(t,"__importStar",(function(){return C})),r.d(t,"__importDefault",(function(){return P})),r.d(t,"__classPrivateFieldGet",(function(){return R})),r.d(t,"__classPrivateFieldSet",(function(){return N})),r.d(t,"__classPrivateFieldIn",(function(){return I}));var n=function(e,t){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},n(e,t)};function f(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}var a=function(){return a=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var f in t=arguments[r])Object.prototype.hasOwnProperty.call(t,f)&&(e[f]=t[f]);return e},a.apply(this,arguments)};function i(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var f=0;for(n=Object.getOwnPropertySymbols(e);f<n.length;f++)t.indexOf(n[f])<0&&Object.prototype.propertyIsEnumerable.call(e,n[f])&&(r[n[f]]=e[n[f]])}return r}function o(e,t,r,n){var f,a=arguments.length,i=a<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)i=Reflect.decorate(e,t,r,n);else for(var o=e.length-1;o>=0;o--)(f=e[o])&&(i=(a<3?f(i):a>3?f(t,r,i):f(t,r))||i);return a>3&&i&&Object.defineProperty(t,r,i),i}function s(e,t){return function(r,n){t(r,n,e)}}function c(e,t,r,n,f,a){function i(e){if(void 0!==e&&"function"!=typeof e)throw new TypeError("Function expected");return e}for(var o,s=n.kind,c="getter"===s?"get":"setter"===s?"set":"value",u=!t&&e?n.static?e:e.prototype:null,d=t||(u?Object.getOwnPropertyDescriptor(u,n.name):{}),l=!1,p=r.length-1;p>=0;p--){var h={};for(var b in n)h[b]="access"===b?{}:n[b];for(var b in n.access)h.access[b]=n.access[b];h.addInitializer=function(e){if(l)throw new TypeError("Cannot add initializers after decoration has completed");a.push(i(e||null))};var m=(0,r[p])("accessor"===s?{get:d.get,set:d.set}:d[c],h);if("accessor"===s){if(void 0===m)continue;if(null===m||"object"!=typeof m)throw new TypeError("Object expected");(o=i(m.get))&&(d.get=o),(o=i(m.set))&&(d.set=o),(o=i(m.init))&&f.push(o)}else(o=i(m))&&("field"===s?f.push(o):d[c]=o)}u&&Object.defineProperty(u,n.name,d),l=!0}function u(e,t,r){for(var n=arguments.length>2,f=0;f<t.length;f++)r=n?t[f].call(e,r):t[f].call(e);return n?r:void 0}function d(e){return"symbol"==typeof e?e:"".concat(e)}function l(e,t,r){return"symbol"==typeof t&&(t=t.description?"[".concat(t.description,"]"):""),Object.defineProperty(e,"name",{configurable:!0,value:r?"".concat(r," ",t):t})}function p(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}function h(e,t,r,n){return new(r||(r=Promise))((function(f,a){function i(e){try{s(n.next(e))}catch(e){a(e)}}function o(e){try{s(n.throw(e))}catch(e){a(e)}}function s(e){var t;e.done?f(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(i,o)}s((n=n.apply(e,t||[])).next())}))}function b(e,t){var r,n,f,a,i={label:0,sent:function(){if(1&f[0])throw f[1];return f[1]},trys:[],ops:[]};return a={next:o(0),throw:o(1),return:o(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function o(o){return function(s){return function(o){if(r)throw new TypeError("Generator is already executing.");for(;a&&(a=0,o[0]&&(i=0)),i;)try{if(r=1,n&&(f=2&o[0]?n.return:o[0]?n.throw||((f=n.return)&&f.call(n),0):n.next)&&!(f=f.call(n,o[1])).done)return f;switch(n=0,f&&(o=[2&o[0],f.value]),o[0]){case 0:case 1:f=o;break;case 4:return i.label++,{value:o[1],done:!1};case 5:i.label++,n=o[1],o=[0];continue;case 7:o=i.ops.pop(),i.trys.pop();continue;default:if(!(f=i.trys,(f=f.length>0&&f[f.length-1])||6!==o[0]&&2!==o[0])){i=0;continue}if(3===o[0]&&(!f||o[1]>f[0]&&o[1]<f[3])){i.label=o[1];break}if(6===o[0]&&i.label<f[1]){i.label=f[1],f=o;break}if(f&&i.label<f[2]){i.label=f[2],i.ops.push(o);break}f[2]&&i.ops.pop(),i.trys.pop();continue}o=t.call(e,i)}catch(e){o=[6,e],n=0}finally{r=f=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,s])}}}var m=Object.create?function(e,t,r,n){void 0===n&&(n=r);var f=Object.getOwnPropertyDescriptor(t,r);f&&!("get"in f?!t.__esModule:f.writable||f.configurable)||(f={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,f)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]};function y(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||m(t,e,r)}function g(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function v(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,f,a=r.call(e),i=[];try{for(;(void 0===t||t-- >0)&&!(n=a.next()).done;)i.push(n.value)}catch(e){f={error:e}}finally{try{n&&!n.done&&(r=a.return)&&r.call(a)}finally{if(f)throw f.error}}return i}function _(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(v(arguments[t]));return e}function w(){for(var e=0,t=0,r=arguments.length;t<r;t++)e+=arguments[t].length;var n=Array(e),f=0;for(t=0;t<r;t++)for(var a=arguments[t],i=0,o=a.length;i<o;i++,f++)n[f]=a[i];return n}function E(e,t,r){if(r||2===arguments.length)for(var n,f=0,a=t.length;f<a;f++)!n&&f in t||(n||(n=Array.prototype.slice.call(t,0,f)),n[f]=t[f]);return e.concat(n||Array.prototype.slice.call(t))}function A(e){return this instanceof A?(this.v=e,this):new A(e)}function T(e,t,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n,f=r.apply(e,t||[]),a=[];return n={},i("next"),i("throw"),i("return"),n[Symbol.asyncIterator]=function(){return this},n;function i(e){f[e]&&(n[e]=function(t){return new Promise((function(r,n){a.push([e,t,r,n])>1||o(e,t)}))})}function o(e,t){try{(r=f[e](t)).value instanceof A?Promise.resolve(r.value.v).then(s,c):u(a[0][2],r)}catch(e){u(a[0][3],e)}var r}function s(e){o("next",e)}function c(e){o("throw",e)}function u(e,t){e(t),a.shift(),a.length&&o(a[0][0],a[0][1])}}function x(e){var t,r;return t={},n("next"),n("throw",(function(e){throw e})),n("return"),t[Symbol.iterator]=function(){return this},t;function n(n,f){t[n]=e[n]?function(t){return(r=!r)?{value:A(e[n](t)),done:!1}:f?f(t):t}:f}}function k(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,r=e[Symbol.asyncIterator];return r?r.call(e):(e=g(e),t={},n("next"),n("throw"),n("return"),t[Symbol.asyncIterator]=function(){return this},t);function n(r){t[r]=e[r]&&function(t){return new Promise((function(n,f){(function(e,t,r,n){Promise.resolve(n).then((function(t){e({value:t,done:r})}),t)})(n,f,(t=e[r](t)).done,t.value)}))}}}function S(e,t){return Object.defineProperty?Object.defineProperty(e,"raw",{value:t}):e.raw=t,e}var O=Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t};function C(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&m(t,e,r);return O(t,e),t}function P(e){return e&&e.__esModule?e:{default:e}}function R(e,t,r,n){if("a"===r&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?n:"a"===r?n.call(e):n?n.value:t.get(e)}function N(e,t,r,n,f){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!f)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!f:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?f.call(e,r):f?f.value=r:t.set(e,r),r}function I(e,t){if(null===t||"object"!=typeof t&&"function"!=typeof t)throw new TypeError("Cannot use 'in' operator on non-object");return"function"==typeof e?t===e:e.has(t)}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(116),f=r(743),a=r(744),i=r(745),o=new n.default([new f.default,new i.default,new a.default]);t.default=o},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(4),f=r(102);class a extends f.default{constructor(){super(n.MultiFormatTypes.prefix.AES256_CBC_ENCRYPTED,n.EncryptionTypes.METHOD.AES256_CBC)}}t.default=a},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(4),f=r(102);class a extends f.default{constructor(){super(n.MultiFormatTypes.prefix.AES256_GCM_ENCRYPTED,n.EncryptionTypes.METHOD.AES256_GCM)}}t.default=a},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(4),f=r(102);class a extends f.default{constructor(){super(n.MultiFormatTypes.prefix.ECIES_ENCRYPTED,n.EncryptionTypes.METHOD.ECIES)}}t.default=a},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(116),f=r(747),a=new n.default([new f.default]);t.default=a},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(4),f=r(310);class a extends f.default{constructor(){super(n.MultiFormatTypes.prefix.NORMALIZE_KECCAK256_HASH,n.MultiFormatTypes.HashTypes.TYPE.KECCAK256)}isSerializableObject(e){return super.isSerializableObject(e)&&e.value.length===n.MultiFormatTypes.FORMAT_NORMALIZE_KECCAK256_HASH_LENGTH}isDeserializableString(e){return super.isDeserializableString(e)&&e.length===n.MultiFormatTypes.FORMAT_NORMALIZE_KECCAK256_HASH_LENGTH}}t.default=a},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(116),f=r(749),a=new n.default([new f.default]);t.default=a},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(4),f=r(310);class a extends f.default{constructor(){super(n.MultiFormatTypes.prefix.IDENTITY_ETHEREUM_ADDRESS,n.IdentityTypes.TYPE.ETHEREUM_ADDRESS)}isSerializableObject(e){return super.isSerializableObject(e)&&e.value.length===n.MultiFormatTypes.FORMAT_IDENTITY_ETHEREUM_ADDRESS_LENGTH}isDeserializableString(e){return super.isDeserializableString(e)&&e.length===n.MultiFormatTypes.FORMAT_IDENTITY_ETHEREUM_ADDRESS_LENGTH}}t.default=a},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(116),f=r(751),a=new n.default([new f.default]);t.default=a},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(4),f=r(102);class a extends f.default{constructor(){super(n.MultiFormatTypes.prefix.PLAIN_TEXT,n.MultiFormatTypes.PlainTypes.TYPE.PLAIN_TEXT)}}t.default=a},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(4),f=r(59),a=r(69),i=r(780),o=r(781),s=r(782),c=r(783),u=r(784),d=r(785),l=r(786),p=r(8);t.default={applyActionToRequest:function(e,t,r,h){if(!f.default.isActionVersionSupported(t))throw new Error("action version not supported");const b=e?(0,p.deepCopy)(e):null;let m=null;if(t.data.name===n.RequestLogicTypes.ACTION_NAME.CREATE){if(b)throw new Error("no request is expected at the creation");m=c.default.createRequest(t,r)}else{if(!b)throw new Error("request is expected");a.default.checkRequest(b),t.data.name===n.RequestLogicTypes.ACTION_NAME.ACCEPT&&(m=i.default.applyActionToRequest(t,r,b)),t.data.name===n.RequestLogicTypes.ACTION_NAME.CANCEL&&(m=s.default.applyActionToRequest(t,r,b)),t.data.name===n.RequestLogicTypes.ACTION_NAME.INCREASE_EXPECTED_AMOUNT&&(m=u.default.applyActionToRequest(t,r,b)),t.data.name===n.RequestLogicTypes.ACTION_NAME.REDUCE_EXPECTED_AMOUNT&&(m=d.default.applyActionToRequest(t,r,b)),t.data.name===n.RequestLogicTypes.ACTION_NAME.ADD_STAKEHOLDERS&&(m=l.default.applyActionToRequest(t,r,b)),t.data.name===n.RequestLogicTypes.ACTION_NAME.ADD_EXTENSIONS_DATA&&(m=o.default.applyActionToRequest(t,r,b))}if(!m)throw new Error(`Unknown action ${t.data.name}`);t.data.parameters.extensionsData&&h&&(m.extensions=t.data.parameters.extensionsData.reduce(((e,n)=>h.applyActionToExtensions(e,n,m,f.default.getSignerIdentityFromAction(t),r)),m.extensions));return m},formatAccept:i.default.format,formatAddExtensionsData:o.default.format,formatCancel:s.default.format,formatCreate:c.default.format,formatIncreaseExpectedAmount:u.default.format,formatReduceExpectedAmount:d.default.format,formatAddStakeholders:l.default.format,getRequestIdFromAction:function(e){return f.default.getRequestId(e)}}},function(e,t,r){const n=r(82);e.exports=(e,t)=>{const r=n(e,t);return r?r.version:null}},function(e,t,r){const n=r(82);e.exports=(e,t)=>{const r=n(e.trim().replace(/^[=v]+/,""),t);return r?r.version:null}},function(e,t,r){const n=r(34);e.exports=(e,t,r,f,a)=>{"string"==typeof r&&(a=f,f=r,r=void 0);try{return new n(e instanceof n?e.version:e,r).inc(t,f,a).version}catch(e){return null}}},function(e,t,r){const n=r(82);e.exports=(e,t)=>{const r=n(e,null,!0),f=n(t,null,!0),a=r.compare(f);if(0===a)return null;const i=a>0,o=i?r:f,s=i?f:r,c=!!o.prerelease.length;if(!!s.prerelease.length&&!c)return s.patch||s.minor?o.patch?"patch":o.minor?"minor":"major":"major";const u=c?"pre":"";return r.major!==f.major?u+"major":r.minor!==f.minor?u+"minor":r.patch!==f.patch?u+"patch":"prerelease"}},function(e,t,r){const n=r(34);e.exports=(e,t)=>new n(e,t).major},function(e,t,r){const n=r(34);e.exports=(e,t)=>new n(e,t).minor},function(e,t,r){const n=r(34);e.exports=(e,t)=>new n(e,t).patch},function(e,t,r){const n=r(82);e.exports=(e,t)=>{const r=n(e,t);return r&&r.prerelease.length?r.prerelease:null}},function(e,t,r){const n=r(46);e.exports=(e,t,r)=>n(t,e,r)},function(e,t,r){const n=r(46);e.exports=(e,t)=>n(e,t,!0)},function(e,t,r){const n=r(170);e.exports=(e,t)=>e.sort(((e,r)=>n(e,r,t)))},function(e,t,r){const n=r(170);e.exports=(e,t)=>e.sort(((e,r)=>n(r,e,t)))},function(e,t,r){const n=r(34),f=r(82),{safeRe:a,t:i}=r(103);e.exports=(e,t)=>{if(e instanceof n)return e;if("number"==typeof e&&(e=String(e)),"string"!=typeof e)return null;let r=null;if((t=t||{}).rtl){let t;for(;(t=a[i.COERCERTL].exec(e))&&(!r||r.index+r[0].length!==e.length);)r&&t.index+t[0].length===r.index+r[0].length||(r=t),a[i.COERCERTL].lastIndex=t.index+t[1].length+t[2].length;a[i.COERCERTL].lastIndex=-1}else r=e.match(a[i.COERCE]);return null===r?null:f(`${r[2]}.${r[3]||"0"}.${r[4]||"0"}`,t)}},function(e,t,r){"use strict";const n=r(767),f=Symbol("max"),a=Symbol("length"),i=Symbol("lengthCalculator"),o=Symbol("allowStale"),s=Symbol("maxAge"),c=Symbol("dispose"),u=Symbol("noDisposeOnSet"),d=Symbol("lruList"),l=Symbol("cache"),p=Symbol("updateAgeOnGet"),h=()=>1;const b=(e,t,r)=>{const n=e[l].get(t);if(n){const t=n.value;if(m(e,t)){if(g(e,n),!e[o])return}else r&&(e[p]&&(n.value.now=Date.now()),e[d].unshiftNode(n));return t.value}},m=(e,t)=>{if(!t||!t.maxAge&&!e[s])return!1;const r=Date.now()-t.now;return t.maxAge?r>t.maxAge:e[s]&&r>e[s]},y=e=>{if(e[a]>e[f])for(let t=e[d].tail;e[a]>e[f]&&null!==t;){const r=t.prev;g(e,t),t=r}},g=(e,t)=>{if(t){const r=t.value;e[c]&&e[c](r.key,r.value),e[a]-=r.length,e[l].delete(r.key),e[d].removeNode(t)}};class v{constructor(e,t,r,n,f){this.key=e,this.value=t,this.length=r,this.now=n,this.maxAge=f||0}}const _=(e,t,r,n)=>{let f=r.value;m(e,f)&&(g(e,r),e[o]||(f=void 0)),f&&t.call(n,f.value,f.key,e)};e.exports=class{constructor(e){if("number"==typeof e&&(e={max:e}),e||(e={}),e.max&&("number"!=typeof e.max||e.max<0))throw new TypeError("max must be a non-negative number");this[f]=e.max||1/0;const t=e.length||h;if(this[i]="function"!=typeof t?h:t,this[o]=e.stale||!1,e.maxAge&&"number"!=typeof e.maxAge)throw new TypeError("maxAge must be a number");this[s]=e.maxAge||0,this[c]=e.dispose,this[u]=e.noDisposeOnSet||!1,this[p]=e.updateAgeOnGet||!1,this.reset()}set max(e){if("number"!=typeof e||e<0)throw new TypeError("max must be a non-negative number");this[f]=e||1/0,y(this)}get max(){return this[f]}set allowStale(e){this[o]=!!e}get allowStale(){return this[o]}set maxAge(e){if("number"!=typeof e)throw new TypeError("maxAge must be a non-negative number");this[s]=e,y(this)}get maxAge(){return this[s]}set lengthCalculator(e){"function"!=typeof e&&(e=h),e!==this[i]&&(this[i]=e,this[a]=0,this[d].forEach((e=>{e.length=this[i](e.value,e.key),this[a]+=e.length}))),y(this)}get lengthCalculator(){return this[i]}get length(){return this[a]}get itemCount(){return this[d].length}rforEach(e,t){t=t||this;for(let r=this[d].tail;null!==r;){const n=r.prev;_(this,e,r,t),r=n}}forEach(e,t){t=t||this;for(let r=this[d].head;null!==r;){const n=r.next;_(this,e,r,t),r=n}}keys(){return this[d].toArray().map((e=>e.key))}values(){return this[d].toArray().map((e=>e.value))}reset(){this[c]&&this[d]&&this[d].length&&this[d].forEach((e=>this[c](e.key,e.value))),this[l]=new Map,this[d]=new n,this[a]=0}dump(){return this[d].map((e=>!m(this,e)&&{k:e.key,v:e.value,e:e.now+(e.maxAge||0)})).toArray().filter((e=>e))}dumpLru(){return this[d]}set(e,t,r){if((r=r||this[s])&&"number"!=typeof r)throw new TypeError("maxAge must be a number");const n=r?Date.now():0,o=this[i](t,e);if(this[l].has(e)){if(o>this[f])return g(this,this[l].get(e)),!1;const i=this[l].get(e).value;return this[c]&&(this[u]||this[c](e,i.value)),i.now=n,i.maxAge=r,i.value=t,this[a]+=o-i.length,i.length=o,this.get(e),y(this),!0}const p=new v(e,t,o,n,r);return p.length>this[f]?(this[c]&&this[c](e,t),!1):(this[a]+=p.length,this[d].unshift(p),this[l].set(e,this[d].head),y(this),!0)}has(e){if(!this[l].has(e))return!1;const t=this[l].get(e).value;return!m(this,t)}get(e){return b(this,e,!0)}peek(e){return b(this,e,!1)}pop(){const e=this[d].tail;return e?(g(this,e),e.value):null}del(e){g(this,this[l].get(e))}load(e){this.reset();const t=Date.now();for(let r=e.length-1;r>=0;r--){const n=e[r],f=n.e||0;if(0===f)this.set(n.k,n.v);else{const e=f-t;e>0&&this.set(n.k,n.v,e)}}}prune(){this[l].forEach(((e,t)=>b(this,t,!1)))}}},function(e,t,r){"use strict";function n(e){var t=this;if(t instanceof n||(t=new n),t.tail=null,t.head=null,t.length=0,e&&"function"==typeof e.forEach)e.forEach((function(e){t.push(e)}));else if(arguments.length>0)for(var r=0,f=arguments.length;r<f;r++)t.push(arguments[r]);return t}function f(e,t,r){var n=t===e.head?new o(r,null,t,e):new o(r,t,t.next,e);return null===n.next&&(e.tail=n),null===n.prev&&(e.head=n),e.length++,n}function a(e,t){e.tail=new o(t,e.tail,null,e),e.head||(e.head=e.tail),e.length++}function i(e,t){e.head=new o(t,null,e.head,e),e.tail||(e.tail=e.head),e.length++}function o(e,t,r,n){if(!(this instanceof o))return new o(e,t,r,n);this.list=n,this.value=e,t?(t.next=this,this.prev=t):this.prev=null,r?(r.prev=this,this.next=r):this.next=null}e.exports=n,n.Node=o,n.create=n,n.prototype.removeNode=function(e){if(e.list!==this)throw new Error("removing node which does not belong to this list");var t=e.next,r=e.prev;return t&&(t.prev=r),r&&(r.next=t),e===this.head&&(this.head=t),e===this.tail&&(this.tail=r),e.list.length--,e.next=null,e.prev=null,e.list=null,t},n.prototype.unshiftNode=function(e){if(e!==this.head){e.list&&e.list.removeNode(e);var t=this.head;e.list=this,e.next=t,t&&(t.prev=e),this.head=e,this.tail||(this.tail=e),this.length++}},n.prototype.pushNode=function(e){if(e!==this.tail){e.list&&e.list.removeNode(e);var t=this.tail;e.list=this,e.prev=t,t&&(t.next=e),this.tail=e,this.head||(this.head=e),this.length++}},n.prototype.push=function(){for(var e=0,t=arguments.length;e<t;e++)a(this,arguments[e]);return this.length},n.prototype.unshift=function(){for(var e=0,t=arguments.length;e<t;e++)i(this,arguments[e]);return this.length},n.prototype.pop=function(){if(this.tail){var e=this.tail.value;return this.tail=this.tail.prev,this.tail?this.tail.next=null:this.head=null,this.length--,e}},n.prototype.shift=function(){if(this.head){var e=this.head.value;return this.head=this.head.next,this.head?this.head.prev=null:this.tail=null,this.length--,e}},n.prototype.forEach=function(e,t){t=t||this;for(var r=this.head,n=0;null!==r;n++)e.call(t,r.value,n,this),r=r.next},n.prototype.forEachReverse=function(e,t){t=t||this;for(var r=this.tail,n=this.length-1;null!==r;n--)e.call(t,r.value,n,this),r=r.prev},n.prototype.get=function(e){for(var t=0,r=this.head;null!==r&&t<e;t++)r=r.next;if(t===e&&null!==r)return r.value},n.prototype.getReverse=function(e){for(var t=0,r=this.tail;null!==r&&t<e;t++)r=r.prev;if(t===e&&null!==r)return r.value},n.prototype.map=function(e,t){t=t||this;for(var r=new n,f=this.head;null!==f;)r.push(e.call(t,f.value,this)),f=f.next;return r},n.prototype.mapReverse=function(e,t){t=t||this;for(var r=new n,f=this.tail;null!==f;)r.push(e.call(t,f.value,this)),f=f.prev;return r},n.prototype.reduce=function(e,t){var r,n=this.head;if(arguments.length>1)r=t;else{if(!this.head)throw new TypeError("Reduce of empty list with no initial value");n=this.head.next,r=this.head.value}for(var f=0;null!==n;f++)r=e(r,n.value,f),n=n.next;return r},n.prototype.reduceReverse=function(e,t){var r,n=this.tail;if(arguments.length>1)r=t;else{if(!this.tail)throw new TypeError("Reduce of empty list with no initial value");n=this.tail.prev,r=this.tail.value}for(var f=this.length-1;null!==n;f--)r=e(r,n.value,f),n=n.prev;return r},n.prototype.toArray=function(){for(var e=new Array(this.length),t=0,r=this.head;null!==r;t++)e[t]=r.value,r=r.next;return e},n.prototype.toArrayReverse=function(){for(var e=new Array(this.length),t=0,r=this.tail;null!==r;t++)e[t]=r.value,r=r.prev;return e},n.prototype.slice=function(e,t){(t=t||this.length)<0&&(t+=this.length),(e=e||0)<0&&(e+=this.length);var r=new n;if(t<e||t<0)return r;e<0&&(e=0),t>this.length&&(t=this.length);for(var f=0,a=this.head;null!==a&&f<e;f++)a=a.next;for(;null!==a&&f<t;f++,a=a.next)r.push(a.value);return r},n.prototype.sliceReverse=function(e,t){(t=t||this.length)<0&&(t+=this.length),(e=e||0)<0&&(e+=this.length);var r=new n;if(t<e||t<0)return r;e<0&&(e=0),t>this.length&&(t=this.length);for(var f=this.length,a=this.tail;null!==a&&f>t;f--)a=a.prev;for(;null!==a&&f>e;f--,a=a.prev)r.push(a.value);return r},n.prototype.splice=function(e,t,...r){e>this.length&&(e=this.length-1),e<0&&(e=this.length+e);for(var n=0,a=this.head;null!==a&&n<e;n++)a=a.next;var i=[];for(n=0;a&&n<t;n++)i.push(a.value),a=this.removeNode(a);null===a&&(a=this.tail),a!==this.head&&a!==this.tail&&(a=a.prev);for(n=0;n<r.length;n++)a=f(this,a,r[n]);return i},n.prototype.reverse=function(){for(var e=this.head,t=this.tail,r=e;null!==r;r=r.prev){var n=r.prev;r.prev=r.next,r.next=n}return this.head=t,this.tail=e,this};try{r(768)(n)}catch(e){}},function(e,t,r){"use strict";e.exports=function(e){e.prototype[Symbol.iterator]=function*(){for(let e=this.head;e;e=e.next)yield e.value}}},function(e,t,r){const n=r(47);e.exports=(e,t)=>new n(e,t).set.map((e=>e.map((e=>e.value)).join(" ").trim().split(" ")))},function(e,t,r){const n=r(34),f=r(47);e.exports=(e,t,r)=>{let a=null,i=null,o=null;try{o=new f(t,r)}catch(e){return null}return e.forEach((e=>{o.test(e)&&(a&&-1!==i.compare(e)||(a=e,i=new n(a,r)))})),a}},function(e,t,r){const n=r(34),f=r(47);e.exports=(e,t,r)=>{let a=null,i=null,o=null;try{o=new f(t,r)}catch(e){return null}return e.forEach((e=>{o.test(e)&&(a&&1!==i.compare(e)||(a=e,i=new n(a,r)))})),a}},function(e,t,r){const n=r(34),f=r(47),a=r(119);e.exports=(e,t)=>{e=new f(e,t);let r=new n("0.0.0");if(e.test(r))return r;if(r=new n("0.0.0-0"),e.test(r))return r;r=null;for(let t=0;t<e.set.length;++t){const f=e.set[t];let i=null;f.forEach((e=>{const t=new n(e.semver.version);switch(e.operator){case">":0===t.prerelease.length?t.patch++:t.prerelease.push(0),t.raw=t.format();case"":case">=":i&&!a(t,i)||(i=t);break;case"<":case"<=":break;default:throw new Error(`Unexpected operation: ${e.operator}`)}})),!i||r&&!a(r,i)||(r=i)}return r&&e.test(r)?r:null}},function(e,t,r){const n=r(47);e.exports=(e,t)=>{try{return new n(e,t).range||"*"}catch(e){return null}}},function(e,t,r){const n=r(174);e.exports=(e,t,r)=>n(e,t,">",r)},function(e,t,r){const n=r(174);e.exports=(e,t,r)=>n(e,t,"<",r)},function(e,t,r){const n=r(47);e.exports=(e,t,r)=>(e=new n(e,r),t=new n(t,r),e.intersects(t,r))},function(e,t,r){const n=r(121),f=r(46);e.exports=(e,t,r)=>{const a=[];let i=null,o=null;const s=e.sort(((e,t)=>f(e,t,r)));for(const e of s){n(e,t,r)?(o=e,i||(i=e)):(o&&a.push([i,o]),o=null,i=null)}i&&a.push([i,null]);const c=[];for(const[e,t]of a)e===t?c.push(e):t||e!==s[0]?t?e===s[0]?c.push(`<=${t}`):c.push(`${e} - ${t}`):c.push(`>=${e}`):c.push("*");const u=c.join(" || "),d="string"==typeof t.raw?t.raw:String(t);return u.length<d.length?u:t}},function(e,t,r){const n=r(47),f=r(120),{ANY:a}=f,i=r(121),o=r(46),s=[new f(">=0.0.0-0")],c=[new f(">=0.0.0")],u=(e,t,r)=>{if(e===t)return!0;if(1===e.length&&e[0].semver===a){if(1===t.length&&t[0].semver===a)return!0;e=r.includePrerelease?s:c}if(1===t.length&&t[0].semver===a){if(r.includePrerelease)return!0;t=c}const n=new Set;let f,u,p,h,b,m,y;for(const t of e)">"===t.operator||">="===t.operator?f=d(f,t,r):"<"===t.operator||"<="===t.operator?u=l(u,t,r):n.add(t.semver);if(n.size>1)return null;if(f&&u){if(p=o(f.semver,u.semver,r),p>0)return null;if(0===p&&(">="!==f.operator||"<="!==u.operator))return null}for(const e of n){if(f&&!i(e,String(f),r))return null;if(u&&!i(e,String(u),r))return null;for(const n of t)if(!i(e,String(n),r))return!1;return!0}let g=!(!u||r.includePrerelease||!u.semver.prerelease.length)&&u.semver,v=!(!f||r.includePrerelease||!f.semver.prerelease.length)&&f.semver;g&&1===g.prerelease.length&&"<"===u.operator&&0===g.prerelease[0]&&(g=!1);for(const e of t){if(y=y||">"===e.operator||">="===e.operator,m=m||"<"===e.operator||"<="===e.operator,f)if(v&&e.semver.prerelease&&e.semver.prerelease.length&&e.semver.major===v.major&&e.semver.minor===v.minor&&e.semver.patch===v.patch&&(v=!1),">"===e.operator||">="===e.operator){if(h=d(f,e,r),h===e&&h!==f)return!1}else if(">="===f.operator&&!i(f.semver,String(e),r))return!1;if(u)if(g&&e.semver.prerelease&&e.semver.prerelease.length&&e.semver.major===g.major&&e.semver.minor===g.minor&&e.semver.patch===g.patch&&(g=!1),"<"===e.operator||"<="===e.operator){if(b=l(u,e,r),b===e&&b!==u)return!1}else if("<="===u.operator&&!i(u.semver,String(e),r))return!1;if(!e.operator&&(u||f)&&0!==p)return!1}return!(f&&m&&!u&&0!==p)&&(!(u&&y&&!f&&0!==p)&&(!v&&!g))},d=(e,t,r)=>{if(!e)return t;const n=o(e.semver,t.semver,r);return n>0?e:n<0||">"===t.operator&&">="===e.operator?t:e},l=(e,t,r)=>{if(!e)return t;const n=o(e.semver,t.semver,r);return n<0?e:n>0||"<"===t.operator&&"<="===e.operator?t:e};e.exports=(e,t,r={})=>{if(e===t)return!0;e=new n(e,r),t=new n(t,r);let f=!1;e:for(const n of e.set){for(const e of t.set){const t=u(n,e,r);if(f=f||null!==t,t)continue e}if(f)return!1}return!0}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default={specificationVersion:{current:"2.0.3",exceptions:[]}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(4),f=r(59),a=r(69),i=r(60),o=r(8);function s(e,t,r){const f=e.data.parameters;return{actionSigner:r,name:n.RequestLogicTypes.ACTION_NAME.ACCEPT,parameters:{extensionsDataLength:f.extensionsData?f.extensionsData.length:0},timestamp:t}}t.default={applyActionToRequest:function(e,t,r){if(!e.data.parameters.requestId)throw new Error("requestId must be given");if(!r.payer)throw new Error("the request must have a payer");if(r.state!==n.RequestLogicTypes.STATE.CREATED)throw new Error("the request state must be created");const i=f.default.getSignerIdentityFromAction(e);if(a.default.getRoleInRequest(i,r)!==n.RequestLogicTypes.ROLE.PAYER)throw new Error("Signer must be the payer");r.state=n.RequestLogicTypes.STATE.ACCEPTED;let c=(0,o.deepCopy)(r);return c=a.default.pushExtensionsData(c,e.data.parameters.extensionsData),c.events.push(s(e,t,i)),c},format:function(e,t,r){const a={name:n.RequestLogicTypes.ACTION_NAME.ACCEPT,parameters:e,version:i.default.currentVersion};return f.default.createAction(a,t,r)}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(4),f=r(59),a=r(69),i=r(60),o=r(8);function s(e,t,r){const f=e.data.parameters;return{actionSigner:r,name:n.RequestLogicTypes.ACTION_NAME.ADD_EXTENSIONS_DATA,parameters:{extensionsDataLength:f.extensionsData?f.extensionsData.length:0},timestamp:t}}t.default={applyActionToRequest:function(e,t,r){if(!e.data.parameters.requestId)throw new Error("requestId must be given");if(!e.data.parameters.extensionsData||0===e.data.parameters.extensionsData.length)throw new Error("extensionsData must be given");const n=f.default.getSignerIdentityFromAction(e);let i=(0,o.deepCopy)(r);return i=a.default.pushExtensionsData(i,e.data.parameters.extensionsData),i.events.push(s(e,t,n)),i},format:function(e,t,r){if(!e.extensionsData||0===e.extensionsData.length)throw new Error("extensionsData must be given");const a={name:n.RequestLogicTypes.ACTION_NAME.ADD_EXTENSIONS_DATA,parameters:e,version:i.default.currentVersion};return f.default.createAction(a,t,r)}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(4),f=r(59),a=r(69),i=r(60),o=r(8);function s(e,t,r){const f=e.data.parameters;return{actionSigner:r,name:n.RequestLogicTypes.ACTION_NAME.CANCEL,parameters:{extensionsDataLength:f.extensionsData?f.extensionsData.length:0},timestamp:t}}t.default={applyActionToRequest:function(e,t,r){if(!e.data.parameters.requestId)throw new Error("requestId must be given");const i=f.default.getSignerIdentityFromAction(e),c=a.default.getRoleInRequest(i,r);let u=(0,o.deepCopy)(r);if(u=a.default.pushExtensionsData(u,e.data.parameters.extensionsData),u.events.push(s(e,t,i)),c===n.RequestLogicTypes.ROLE.PAYER){if(r.state!==n.RequestLogicTypes.STATE.CREATED)throw new Error("A payer cancel need to be done on a request with the state created");return u.state=n.RequestLogicTypes.STATE.CANCELED,u}if(c===n.RequestLogicTypes.ROLE.PAYEE){if(r.state===n.RequestLogicTypes.STATE.CANCELED)throw new Error("Cannot cancel an already canceled request");return u.state=n.RequestLogicTypes.STATE.CANCELED,u}throw new Error("Signer must be the payer or the payee")},format:function(e,t,r){const a={name:n.RequestLogicTypes.ACTION_NAME.CANCEL,parameters:e,version:i.default.currentVersion};return f.default.createAction(a,t,r)}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(4),f=r(168),a=r(59),i=r(60),o=r(8);function s(e,t,r){const f=e.data.parameters;return{actionSigner:r,name:n.RequestLogicTypes.ACTION_NAME.CREATE,parameters:{expectedAmount:f.expectedAmount,extensionsDataLength:f.extensionsData?f.extensionsData.length:0,isSignedRequest:!1},timestamp:t}}t.default={createRequest:function(e,t){if(!e.data.parameters.payee&&!e.data.parameters.payer)throw new Error("action.parameters.payee or action.parameters.payer must be given");if(e.data.parameters.payee&&(0,o.identityHasError)(e.data.parameters.payee))throw new Error(`payee: ${(0,o.identityHasError)(e.data.parameters.payee)}̀`);if(e.data.parameters.payer&&(0,o.identityHasError)(e.data.parameters.payer))throw new Error(`payer: ${(0,o.identityHasError)(e.data.parameters.payer)}̀`);if(!(0,o.isString)(e.data.parameters.expectedAmount)||!(0,o.isValidAmount)(e.data.parameters.expectedAmount))throw new Error("action.parameters.expectedAmount must be a string representing a positive integer");const r=a.default.getSignerIdentityFromAction(e),i=(0,o.deepCopy)(e.data.parameters);i.extensions={},i.requestId=a.default.getRequestId(e),i.version=a.default.getVersionFromAction(e),i.events=[s(e,t,r)],f.lt(e.data.version,"2.0.2")&&(i.currency=function(e){switch(e){case"BTC":return{network:"mainnet",type:n.RequestLogicTypes.CURRENCY.BTC,value:"BTC"};case"ETH":return{network:"mainnet",type:n.RequestLogicTypes.CURRENCY.ETH,value:"ETH"};case"EUR":return{type:n.RequestLogicTypes.CURRENCY.ISO4217,value:"EUR"};case"USD":return{type:n.RequestLogicTypes.CURRENCY.ISO4217,value:"USD"};case"DAI":return{type:n.RequestLogicTypes.CURRENCY.ERC20,value:"0x89d24A6b4CcB1B6fAA2625fE562bDD9a23260359"};default:throw new Error("Unsupported currency when getting request from transactions.")}}(e.data.parameters.currency));const c=a.default.getRoleInAction(r,e);if(c===n.RequestLogicTypes.ROLE.PAYEE)return i.state=n.RequestLogicTypes.STATE.CREATED,i.creator=e.data.parameters.payee,i;if(c===n.RequestLogicTypes.ROLE.PAYER)return i.state=n.RequestLogicTypes.STATE.ACCEPTED,i.creator=e.data.parameters.payer,i;throw new Error("Signer must be the payee or the payer")},format:function(e,t,r){if(!e.payee&&!e.payer)throw new Error("payee or PayerId must be given");if(!(0,o.isValidAmount)(e.expectedAmount))throw new Error("expectedAmount must be a positive integer");if(e.payee&&(0,o.identityHasError)(e.payee))throw new Error(`payee: ${(0,o.identityHasError)(e.payee)}̀`);if(e.payer&&(0,o.identityHasError)(e.payer))throw new Error(`payer: ${(0,o.identityHasError)(e.payer)}̀`);e.timestamp||(e.timestamp=(0,o.getCurrentTimestampInSecond)());e.expectedAmount=e.expectedAmount.toString();const f=i.default.currentVersion,s={name:n.RequestLogicTypes.ACTION_NAME.CREATE,parameters:e,version:f},c=a.default.getRoleInUnsignedAction(t,s);if(c!==n.RequestLogicTypes.ROLE.PAYEE&&c!==n.RequestLogicTypes.ROLE.PAYER)throw new Error("Signer must be the payee or the payer");return a.default.createAction(s,t,r)}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(4),f=r(59),a=r(69),i=r(60),o=r(8);function s(e,t,r){const f=e.data.parameters;return{actionSigner:r,name:n.RequestLogicTypes.ACTION_NAME.INCREASE_EXPECTED_AMOUNT,parameters:{deltaAmount:e.data.parameters.deltaAmount,extensionsDataLength:f.extensionsData?f.extensionsData.length:0},timestamp:t}}t.default={applyActionToRequest:function(e,t,r){if(!e.data.parameters.requestId)throw new Error("requestId must be given");if(!r.payer)throw new Error("the request must have a payer");if(!e.data.parameters.deltaAmount)throw new Error("deltaAmount must be given");if(!(0,o.isValidAmount)(e.data.parameters.deltaAmount))throw new Error("deltaAmount must be a string representing a positive integer");const i=f.default.getSignerIdentityFromAction(e),c=a.default.getRoleInRequest(i,r);let u=(0,o.deepCopy)(r);if(u=a.default.pushExtensionsData(u,e.data.parameters.extensionsData),u.events.push(s(e,t,i)),c===n.RequestLogicTypes.ROLE.PAYER){if(r.state===n.RequestLogicTypes.STATE.CANCELED)throw new Error("the request must not be canceled");return u.expectedAmount=(0,o.addAmount)(r.expectedAmount,e.data.parameters.deltaAmount),u}throw new Error("signer must be the payer")},format:function(e,t,r){if(!(0,o.isValidAmount)(e.deltaAmount))throw new Error("deltaAmount must be a string representing a positive integer");const a={name:n.RequestLogicTypes.ACTION_NAME.INCREASE_EXPECTED_AMOUNT,parameters:e,version:i.default.currentVersion};return f.default.createAction(a,t,r)}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(4),f=r(59),a=r(69),i=r(60),o=r(8);function s(e,t,r){const f=e.data.parameters;return{actionSigner:r,name:n.RequestLogicTypes.ACTION_NAME.REDUCE_EXPECTED_AMOUNT,parameters:{deltaAmount:e.data.parameters.deltaAmount,extensionsDataLength:f.extensionsData?f.extensionsData.length:0},timestamp:t}}t.default={applyActionToRequest:function(e,t,r){if(!e.data.parameters.requestId)throw new Error("requestId must be given");if(!r.payee)throw new Error("the request must have a payee");if(!e.data.parameters.deltaAmount)throw new Error("deltaAmount must be given");if(!(0,o.isValidAmount)(e.data.parameters.deltaAmount))throw new Error("deltaAmount must be a string representing a positive integer");const i=f.default.getSignerIdentityFromAction(e),c=a.default.getRoleInRequest(i,r);let u=(0,o.deepCopy)(r);if(u=a.default.pushExtensionsData(u,e.data.parameters.extensionsData),u.events.push(s(e,t,i)),c===n.RequestLogicTypes.ROLE.PAYEE){if(r.state===n.RequestLogicTypes.STATE.CANCELED)throw new Error("the request must not be canceled");return u.expectedAmount=(0,o.reduceAmount)(r.expectedAmount,e.data.parameters.deltaAmount),u}throw new Error("signer must be the payee")},format:function(e,t,r){if(!(0,o.isValidAmount)(e.deltaAmount))throw new Error("deltaAmount must be a string representing a positive integer");const a={name:n.RequestLogicTypes.ACTION_NAME.REDUCE_EXPECTED_AMOUNT,parameters:e,version:i.default.currentVersion};return f.default.createAction(a,t,r)}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(4),f=r(8),a=r(59),i=r(69),o=r(60);function s(e,t,r){const f=e.data.parameters;return{actionSigner:r,name:n.RequestLogicTypes.ACTION_NAME.ADD_STAKEHOLDERS,parameters:{extensionsDataLength:f.extensionsData?f.extensionsData.length:0},timestamp:t}}t.default={applyActionToRequest:function(e,t,r){if(!e.data.parameters.requestId)throw new Error("requestId must be given");const n=a.default.getSignerIdentityFromAction(e);let o=(0,f.deepCopy)(r);return o=i.default.pushExtensionsData(o,e.data.parameters.extensionsData),o.events.push(s(e,t,n)),o},format:function(e,t,r){const f={name:n.RequestLogicTypes.ACTION_NAME.ADD_STAKEHOLDERS,parameters:e,version:o.default.currentVersion};return a.default.createAction(f,t,r)}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.TransactionManager=void 0;var n=r(788);Object.defineProperty(t,"TransactionManager",{enumerable:!0,get:function(){return n.default}})},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(83),f=r(52),a=r(4),i=r(8),o=r(32),s=r(789),c=r(793);t.default=class{constructor(e,t){this.dataAccess=e,this.channelParser=new s.default(t)}persistTransaction(e,t,r=[],s=[]){return n.__awaiter(this,void 0,void 0,(function*(){let n,u={};const d=f.default.serialize((0,i.normalizeKeccak256Hash)(JSON.parse(e)));if(t===d)0===s.length?u=yield c.default.createClearTransaction(e):(u=yield c.default.createEncryptedTransactionInNewChannel(e,s),n=u.encryptionMethod);else{const r=yield this.dataAccess.getTransactionsByChannelId(t),{channelKey:f,channelType:i,encryptionMethod:o}=yield this.channelParser.getChannelTypeAndChannelKey(t,r.result.transactions);if(i===a.TransactionTypes.ChannelType.UNKNOWN)throw new Error(`Impossible to retrieve the channel: ${t}`);if(i===a.TransactionTypes.ChannelType.CLEAR&&(u=yield c.default.createClearTransaction(e)),i===a.TransactionTypes.ChannelType.ENCRYPTED){if(!f)throw new Error(`Impossible to decrypt the channel key of: ${t}`);u=yield c.default.createEncryptedTransaction(e,f,s),n=o}}const l=yield this.dataAccess.persistTransaction(u,t,r.concat([d])),p=Object.assign(new o.EventEmitter,{meta:{dataAccessMeta:l.meta,encryptionMethod:n},result:{}});return l.on("confirmed",(e=>{const t={meta:{dataAccessMeta:e.meta,encryptionMethod:n},result:{}};p.emit("confirmed",t)})).on("error",(e=>{p.emit("error",e)})),p}))}getTransactionsByChannelId(e,t){return n.__awaiter(this,void 0,void 0,(function*(){const r=yield this.dataAccess.getTransactionsByChannelId(e,t),{transactions:n,ignoredTransactions:f,encryptionMethod:a}=yield this.channelParser.decryptAndCleanChannel(e,r.result.transactions),i={dataAccessMeta:r.meta,encryptionMethod:a,ignoredTransactions:f};return a||delete i.encryptionMethod,{meta:i,result:{transactions:n}}}))}getChannelsByTopic(e,t){return n.__awaiter(this,void 0,void 0,(function*(){const r=yield this.dataAccess.getChannelsByTopic(e,t);return this.parseMultipleChannels(r)}))}getChannelsByMultipleTopics(e,t){return n.__awaiter(this,void 0,void 0,(function*(){const r=yield this.dataAccess.getChannelsByMultipleTopics(e,t);return this.parseMultipleChannels(r)}))}parseMultipleChannels(e){return n.__awaiter(this,void 0,void 0,(function*(){const t=yield Object.keys(e.result.transactions).reduce(((t,r)=>n.__awaiter(this,void 0,void 0,(function*(){const n=yield this.channelParser.decryptAndCleanChannel(r,e.result.transactions[r]),f=yield t;return f.transactions[r]=n.transactions,f.ignoredTransactions[r]=n.ignoredTransactions,f}))),Promise.resolve({transactions:{},ignoredTransactions:{}}));return{meta:{dataAccessMeta:e.meta,ignoredTransactions:t.ignoredTransactions},result:{transactions:t.transactions}}}))}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(83),f=r(4),a=r(790);t.default=class{constructor(e){this.transactionParser=new a.default(e)}decryptAndCleanChannel(e,t){return n.__awaiter(this,void 0,void 0,(function*(){let r,a=f.TransactionTypes.ChannelType.UNKNOWN;const{channelKey:i}=yield this.getChannelTypeAndChannelKey(e,t),o=yield t.reduce(((t,o)=>n.__awaiter(this,void 0,void 0,(function*(){const n=yield t;let s;try{s=yield this.transactionParser.parsePersistedTransaction(o.transaction,a,i,r)}catch(u){return n.concat([{ignored:{reason:u.message,transaction:o},valid:null}])}const c=s.transaction,u=yield c.getError();if(""!==u)return n.concat([{ignored:{reason:u,transaction:o},valid:null}]);if(a===f.TransactionTypes.ChannelType.UNKNOWN){if((yield c.getHash())!==e)return n.concat([{ignored:{reason:"as first transaction, the hash of the transaction do not match the channelId",transaction:o},valid:null}]);a=s.channelKey?f.TransactionTypes.ChannelType.ENCRYPTED:f.TransactionTypes.ChannelType.CLEAR,r=s.encryptionMethod}const d=yield c.getData();return n.concat([{ignored:null,valid:{state:o.state,timestamp:o.timestamp,transaction:{data:d}}}])}))),Promise.resolve([])),s=o.map((e=>e.ignored)),c=o.map((e=>e.valid));return{encryptionMethod:r,ignoredTransactions:s,transactions:c}}))}getChannelTypeAndChannelKey(e,t){return n.__awaiter(this,void 0,void 0,(function*(){return yield t.reduce(((e,t)=>n.__awaiter(this,void 0,void 0,(function*(){const r=yield e;if(r.channelType===f.TransactionTypes.ChannelType.CLEAR||r.channelKey)return r;let n;try{n=yield this.transactionParser.parsePersistedTransaction(t.transaction,r.channelType,r.channelKey,r.encryptionMethod)}catch(i){return i.message.startsWith("Impossible to decrypt the channel key from this transaction")&&r.channelType===f.TransactionTypes.ChannelType.UNKNOWN&&(r.channelType=f.TransactionTypes.ChannelType.ENCRYPTED,r.encryptionMethod=t.transaction.encryptionMethod),r}const a=n.transaction,i=undefined;return""!==(yield a.getError())||(r.channelType=n.channelKey?f.TransactionTypes.ChannelType.ENCRYPTED:f.TransactionTypes.ChannelType.CLEAR,r.channelKey=n.channelKey,r.encryptionMethod=n.encryptionMethod),r}))),Promise.resolve({channelKey:void 0,channelType:f.TransactionTypes.ChannelType.UNKNOWN,encryptionMethod:void 0}))}))}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(83),f=r(52),a=r(4),i=r(791),o=r(792);t.default=class{constructor(e){this.decryptionProvider=e}parsePersistedTransaction(e,t,r,f){return n.__awaiter(this,void 0,void 0,(function*(){if(e.data){if(t===a.TransactionTypes.ChannelType.ENCRYPTED)throw new Error("Clear transactions are not allowed in encrypted channel");if(e.encryptedData||e.encryptionMethod||e.keys)throw new Error('only the property "data" is allowed for clear transaction');return{transaction:new i.default(e.data)}}if(e.encryptedData){if(t===a.TransactionTypes.ChannelType.CLEAR)throw new Error("Encrypted transactions are not allowed in clear channel");if(r)if(f){if(e.encryptionMethod)throw new Error('the "encryptionMethod" property has been already given for this channel')}else{if(!e.encryptionMethod)throw new Error('the "encryptionMethod" property is needed to use the channel key');f=e.encryptionMethod}else if(f){if(e.encryptionMethod)throw new Error('the "encryptionMethod" property has been already given for this channel');if(!e.keys)throw new Error('the "keys" property is needed to compute the channel key');r=yield this.decryptChannelKey(e.keys,f)}else{if(!e.encryptionMethod||!e.keys)throw new Error('the properties "encryptionMethod" and "keys" are needed to compute the channel key');f=e.encryptionMethod,r=yield this.decryptChannelKey(e.keys,f)}return{channelKey:r,encryptionMethod:f,transaction:new o.default(e.encryptedData,r)}}throw new Error('Transaction must have a property "data" or "encryptedData"')}))}decryptChannelKey(e,t){return n.__awaiter(this,void 0,void 0,(function*(){if(!this.decryptionProvider)throw new Error("No decryption provider given");let r;if(t===`${a.EncryptionTypes.METHOD.ECIES}-${a.EncryptionTypes.METHOD.AES256_CBC}`)r=a.EncryptionTypes.METHOD.AES256_CBC;else{if(t!==`${a.EncryptionTypes.METHOD.ECIES}-${a.EncryptionTypes.METHOD.AES256_GCM}`)throw new Error(`Encryption method not supported: ${t}`);r=a.EncryptionTypes.METHOD.AES256_GCM}let i="";const o=yield Object.keys(e||{}).reduce(((t,r)=>n.__awaiter(this,void 0,void 0,(function*(){let n=yield t;if(e&&""===n){let t;try{t=f.default.deserialize(r)}catch(e){}if(t&&t.type===a.IdentityTypes.TYPE.ETHEREUM_ADDRESS&&this.decryptionProvider&&(yield this.decryptionProvider.isIdentityRegistered(t)))try{const a=f.default.deserialize(e[r]);n=yield this.decryptionProvider.decrypt(a,t)}catch(e){i=e.message}}return n}))),Promise.resolve(""));if(""===o)throw new Error(`Impossible to decrypt the channel key from this transaction (${i})`);return{key:o,method:r}}))}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(83),f=r(52),a=r(8);t.default=class{constructor(e){this.data=e}getData(){return n.__awaiter(this,void 0,void 0,(function*(){return this.data}))}getHash(){return n.__awaiter(this,void 0,void 0,(function*(){return f.default.serialize((0,a.normalizeKeccak256Hash)(JSON.parse(this.data)))}))}getError(){return n.__awaiter(this,void 0,void 0,(function*(){try{return JSON.parse(this.data),""}catch(e){return"Impossible to JSON parse the transaction"}}))}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(83),f=r(52),a=r(8);t.default=class{constructor(e,t){this.data="",this.dataHashSerialized="",this.persistedData=e,this.channelKey=t}getData(){return n.__awaiter(this,void 0,void 0,(function*(){if(""===this.data)try{const e=f.default.deserialize(this.persistedData);this.data=yield(0,a.decrypt)(e,this.channelKey)}catch(e){throw new Error("Impossible to decrypt the transaction")}return this.data}))}getHash(){return n.__awaiter(this,void 0,void 0,(function*(){if(""===this.dataHashSerialized){const e=yield this.getData();try{const t=(0,a.normalizeKeccak256Hash)(JSON.parse(e));this.dataHashSerialized=f.default.serialize(t)}catch(e){throw new Error("Impossible to JSON parse the decrypted transaction data")}}return this.dataHashSerialized}))}getError(){return n.__awaiter(this,void 0,void 0,(function*(){let e="";try{e=yield this.getData()}catch(e){return e.message}try{JSON.parse(e)}catch(e){return"Impossible to JSON parse the decrypted transaction data"}return""}))}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(83),f=r(52),a=r(4),i=r(8);t.default=class{static createClearTransaction(e){return n.__awaiter(this,void 0,void 0,(function*(){try{JSON.parse(e)}catch(e){throw new Error("Data not parsable")}return{data:e}}))}static createEncryptedTransactionInNewChannel(e,t){return n.__awaiter(this,void 0,void 0,(function*(){const r=`${a.EncryptionTypes.METHOD.ECIES}-${a.EncryptionTypes.METHOD.AES256_GCM}`,o=yield(0,i.generate32BufferKey)(),s=yield(0,i.encrypt)(e,{key:o,method:a.EncryptionTypes.METHOD.AES256_GCM});try{JSON.parse(e)}catch(e){throw new Error("Data not parsable")}if(!t.every((e=>e.method===a.EncryptionTypes.METHOD.ECIES)))throw new Error(`encryptionParams method must be all: ${a.EncryptionTypes.METHOD.ECIES}`);const c=t.map((e=>n.__awaiter(this,void 0,void 0,(function*(){const t=yield(0,i.encrypt)(o,e),r=(0,i.getIdentityFromEncryptionParams)(e);return{encryptedKey:t,multiFormattedIdentity:f.default.serialize(r)}})))),u=(yield Promise.all(c)).reduce(((e,t)=>{const r=f.default.serialize(t.encryptedKey);return e[t.multiFormattedIdentity]=r,e}),{});return{encryptedData:f.default.serialize(s),keys:u,encryptionMethod:r}}))}static createEncryptedTransaction(e,t,r=[]){return n.__awaiter(this,void 0,void 0,(function*(){if(t.method!==a.EncryptionTypes.METHOD.AES256_GCM)throw new Error(`encryption method not supported for the channel key: ${t.method}`);const o=yield(0,i.encrypt)(e,t);try{JSON.parse(e)}catch(e){throw new Error("Data not parsable")}const s=f.default.serialize(o);if(0===r.length)return{encryptedData:s};{if(!r.every((e=>e.method===a.EncryptionTypes.METHOD.ECIES)))throw new Error(`encryptionParams method must be all: ${a.EncryptionTypes.METHOD.ECIES}`);const e=r.map((e=>n.__awaiter(this,void 0,void 0,(function*(){const r=yield(0,i.encrypt)(t.key,e),n=(0,i.getIdentityFromEncryptionParams)(e);return{encryptedKey:r,multiFormattedIdentity:f.default.serialize(n)}}))));return{encryptedData:s,keys:(yield Promise.all(e)).reduce(((e,t)=>{const r=f.default.serialize(t.encryptedKey);return e[t.multiFormattedIdentity]=r,e}),{})}}}))}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(795),f=r(4).ExtensionTypes.ID.CONTENT_DATA;t.default=class{constructor(e){this.extension=e.extensions.contentData}createExtensionsDataForCreation(e){if(n.default.isKnownFormat(e)){const{valid:t,errors:r}=n.default.validate(e);if(!t){const e=r.map((e=>JSON.stringify(e))).join("\n");throw new Error(`The content data seem to follow a request format but contains errors: ${e}`)}}return this.extension.createCreationAction({content:e})}getContent(e){return e&&e.extensions&&e.extensions[f]?e.extensions[f].values.content:null}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(316),f=r(796),a=r(830),i=r(831),o=r(832);t.default={validate(e){var t;const r=(new f).addMetaSchema(a).addSchema(i);if(!e.meta)return{valid:!1,errors:[{message:"meta not found"}]};if(!e.meta.format)return{valid:!1,errors:[{message:"meta.format not found"}]};if(!e.meta.version)return{valid:!1,errors:[{message:"meta.version not found"}]};const n=null===(t=o.default[e.meta.format])||void 0===t?void 0:t[e.meta.version];if(!n)return{valid:!1,errors:[{message:"format not found"}]};const s=r.compile(n);return s(e)?{valid:!0}:{valid:!1,errors:s.errors}},isKnownFormat:e=>!!e.meta&&"rnf_invoice"===e.meta.format},n.__exportStar(r(836),t)},function(e,t,r){"use strict";var n=r(797),f=r(175),a=r(801),i=r(317),o=r(318),s=r(802),c=r(803),u=r(824),d=r(84);e.exports=y,y.prototype.validate=function(e,t){var r;if("string"==typeof e){if(!(r=this.getSchema(e)))throw new Error('no schema with key or ref "'+e+'"')}else{var n=this._addSchema(e);r=n.validate||this._compile(n)}var f=r(t);!0!==r.$async&&(this.errors=r.errors);return f},y.prototype.compile=function(e,t){var r=this._addSchema(e,void 0,t);return r.validate||this._compile(r)},y.prototype.addSchema=function(e,t,r,n){if(Array.isArray(e)){for(var a=0;a<e.length;a++)this.addSchema(e[a],void 0,r,n);return this}var i=this._getId(e);if(void 0!==i&&"string"!=typeof i)throw new Error("schema id must be string");return A(this,t=f.normalizeId(t||i)),this._schemas[t]=this._addSchema(e,r,n,!0),this},y.prototype.addMetaSchema=function(e,t,r){return this.addSchema(e,t,r,!0),this},y.prototype.validateSchema=function(e,t){var r=e.$schema;if(void 0!==r&&"string"!=typeof r)throw new Error("$schema must be a string");if(!(r=r||this._opts.defaultMeta||function(e){var t=e._opts.meta;return e._opts.defaultMeta="object"==typeof t?e._getId(t)||t:e.getSchema(h)?h:void 0,e._opts.defaultMeta}(this)))return this.logger.warn("meta-schema not available"),this.errors=null,!0;var n=this.validate(r,e);if(!n&&t){var f="schema is invalid: "+this.errorsText();if("log"!=this._opts.validateSchema)throw new Error(f);this.logger.error(f)}return n},y.prototype.getSchema=function(e){var t=g(this,e);switch(typeof t){case"object":return t.validate||this._compile(t);case"string":return this.getSchema(t);case"undefined":return function(e,t){var r=f.schema.call(e,{schema:{}},t);if(r){var a=r.schema,o=r.root,s=r.baseId,c=n.call(e,a,o,void 0,s);return e._fragments[t]=new i({ref:t,fragment:!0,schema:a,root:o,baseId:s,validate:c}),c}}(this,e)}},y.prototype.removeSchema=function(e){if(e instanceof RegExp)return v(this,this._schemas,e),v(this,this._refs,e),this;switch(typeof e){case"undefined":return v(this,this._schemas),v(this,this._refs),this._cache.clear(),this;case"string":var t=g(this,e);return t&&this._cache.del(t.cacheKey),delete this._schemas[e],delete this._refs[e],this;case"object":var r=this._opts.serialize,n=r?r(e):e;this._cache.del(n);var a=this._getId(e);a&&(a=f.normalizeId(a),delete this._schemas[a],delete this._refs[a])}return this},y.prototype.addFormat=function(e,t){"string"==typeof t&&(t=new RegExp(t));return this._formats[e]=t,this},y.prototype.errorsText=function(e,t){if(!(e=e||this.errors))return"No errors";for(var r=void 0===(t=t||{}).separator?", ":t.separator,n=void 0===t.dataVar?"data":t.dataVar,f="",a=0;a<e.length;a++){var i=e[a];i&&(f+=n+i.dataPath+" "+i.message+r)}return f.slice(0,-r.length)},y.prototype._addSchema=function(e,t,r,n){if("object"!=typeof e&&"boolean"!=typeof e)throw new Error("schema should be object or boolean");var a=this._opts.serialize,o=a?a(e):e,s=this._cache.get(o);if(s)return s;n=n||!1!==this._opts.addUsedSchema;var c=f.normalizeId(this._getId(e));c&&n&&A(this,c);var u,d=!1!==this._opts.validateSchema&&!t;d&&!(u=c&&c==f.normalizeId(e.$schema))&&this.validateSchema(e,!0);var l=f.ids.call(this,e),p=new i({id:c,schema:e,localRefs:l,cacheKey:o,meta:r});"#"!=c[0]&&n&&(this._refs[c]=p);this._cache.put(o,p),d&&u&&this.validateSchema(e,!0);return p},y.prototype._compile=function(e,t){if(e.compiling)return e.validate=a,a.schema=e.schema,a.errors=null,a.root=t||a,!0===e.schema.$async&&(a.$async=!0),a;var r,f;e.compiling=!0,e.meta&&(r=this._opts,this._opts=this._metaOpts);try{f=n.call(this,e.schema,t,e.localRefs)}catch(t){throw delete e.validate,t}finally{e.compiling=!1,e.meta&&(this._opts=r)}return e.validate=f,e.refs=f.refs,e.refVal=f.refVal,e.root=f.root,f;function a(){var t=e.validate,r=t.apply(this,arguments);return a.errors=t.errors,r}},y.prototype.compileAsync=r(825);var l=r(826);y.prototype.addKeyword=l.add,y.prototype.getKeyword=l.get,y.prototype.removeKeyword=l.remove,y.prototype.validateKeyword=l.validate;var p=r(177);y.ValidationError=p.Validation,y.MissingRefError=p.MissingRef,y.$dataMetaSchema=u;var h="http://json-schema.org/draft-07/schema",b=["removeAdditional","useDefaults","coerceTypes","strictDefaults"],m=["/properties"];function y(e){if(!(this instanceof y))return new y(e);e=this._opts=d.copy(e)||{},function(e){var t=e._opts.logger;if(!1===t)e.logger={log:T,warn:T,error:T};else{if(void 0===t&&(t=console),!("object"==typeof t&&t.log&&t.warn&&t.error))throw new Error("logger must implement log, warn and error methods");e.logger=t}}(this),this._schemas={},this._refs={},this._fragments={},this._formats=s(e.format),this._cache=e.cache||new a,this._loadingSchemas={},this._compilations=[],this.RULES=c(),this._getId=function(e){switch(e.schemaId){case"auto":return E;case"id":return _;default:return w}}(e),e.loopRequired=e.loopRequired||1/0,"property"==e.errorDataPath&&(e._errorDataPathProperty=!0),void 0===e.serialize&&(e.serialize=o),this._metaOpts=function(e){for(var t=d.copy(e._opts),r=0;r<b.length;r++)delete t[b[r]];return t}(this),e.formats&&function(e){for(var t in e._opts.formats){var r=e._opts.formats[t];e.addFormat(t,r)}}(this),e.keywords&&function(e){for(var t in e._opts.keywords){var r=e._opts.keywords[t];e.addKeyword(t,r)}}(this),function(e){var t;e._opts.$data&&(t=r(829),e.addMetaSchema(t,t.$id,!0));if(!1===e._opts.meta)return;var n=r(324);e._opts.$data&&(n=u(n,m));e.addMetaSchema(n,h,!0),e._refs["http://json-schema.org/schema"]=h}(this),"object"==typeof e.meta&&this.addMetaSchema(e.meta),e.nullable&&this.addKeyword("nullable",{metaSchema:{type:"boolean"}}),function(e){var t=e._opts.schemas;if(!t)return;if(Array.isArray(t))e.addSchema(t);else for(var r in t)e.addSchema(t[r],r)}(this)}function g(e,t){return t=f.normalizeId(t),e._schemas[t]||e._refs[t]||e._fragments[t]}function v(e,t,r){for(var n in t){var f=t[n];f.meta||r&&!r.test(n)||(e._cache.del(f.cacheKey),delete t[n])}}function _(e){return e.$id&&this.logger.warn("schema $id ignored",e.$id),e.id}function w(e){return e.id&&this.logger.warn("schema id ignored",e.id),e.$id}function E(e){if(e.$id&&e.id&&e.$id!=e.id)throw new Error("schema $id is different from id");return e.$id||e.id}function A(e,t){if(e._schemas[t]||e._refs[t])throw new Error('schema with key or id "'+t+'" already exists')}function T(){}},function(e,t,r){"use strict";var n=r(175),f=r(84),a=r(177),i=r(318),o=r(319),s=f.ucs2length,c=r(176),u=a.Validation;function d(e,t,r){var n=p.call(this,e,t,r);return n>=0?{index:n,compiling:!0}:(n=this._compilations.length,this._compilations[n]={schema:e,root:t,baseId:r},{index:n,compiling:!1})}function l(e,t,r){var n=p.call(this,e,t,r);n>=0&&this._compilations.splice(n,1)}function p(e,t,r){for(var n=0;n<this._compilations.length;n++){var f=this._compilations[n];if(f.schema==e&&f.root==t&&f.baseId==r)return n}return-1}function h(e,t){return"var pattern"+e+" = new RegExp("+f.toQuotedString(t[e])+");"}function b(e){return"var default"+e+" = defaults["+e+"];"}function m(e,t){return void 0===t[e]?"":"var refVal"+e+" = refVal["+e+"];"}function y(e){return"var customRule"+e+" = customRules["+e+"];"}function g(e,t){if(!e.length)return"";for(var r="",n=0;n<e.length;n++)r+=t(n,e);return r}e.exports=function e(t,r,p,v){var _=this,w=this._opts,E=[void 0],A={},T=[],x={},k=[],S={},O=[];r=r||{schema:t,refVal:E,refs:A};var C=d.call(this,t,r,v),P=this._compilations[C.index];if(C.compiling)return P.callValidate=function e(){var t=P.validate,r=t.apply(this,arguments);return e.errors=t.errors,r};var R=this._formats,N=this.RULES;try{var I=D(t,r,p,v);P.validate=I;var M=P.callValidate;return M&&(M.schema=I.schema,M.errors=null,M.refs=I.refs,M.refVal=I.refVal,M.root=I.root,M.$async=I.$async,w.sourceCode&&(M.source=I.source)),I}finally{l.call(this,t,r,v)}function D(t,i,d,l){var p=!i||i&&i.schema==t;if(i.schema!=r.schema)return e.call(_,t,i,d,l);var v,x=!0===t.$async,S=o({isTop:!0,schema:t,isRoot:p,baseId:l,root:i,schemaPath:"",errSchemaPath:"#",errorPath:'""',MissingRefError:a.MissingRef,RULES:N,validate:o,util:f,resolve:n,resolveRef:B,usePattern:L,useDefault:U,useCustomRule:q,opts:w,formats:R,logger:_.logger,self:_});S=g(E,m)+g(T,h)+g(k,b)+g(O,y)+S,w.processCode&&(S=w.processCode(S,t));try{v=new Function("self","RULES","formats","root","refVal","defaults","customRules","equal","ucs2length","ValidationError",S)(_,N,R,r,E,k,O,c,s,u),E[0]=v}catch(e){throw _.logger.error("Error compiling schema, function code:",S),e}return v.schema=t,v.errors=null,v.refs=A,v.refVal=E,v.root=p?v:i,x&&(v.$async=!0),!0===w.sourceCode&&(v.source={code:S,patterns:T,defaults:k}),v}function B(t,f,a){f=n.url(t,f);var i,o,s=A[f];if(void 0!==s)return j(i=E[s],o="refVal["+s+"]");if(!a&&r.refs){var c=r.refs[f];if(void 0!==c)return j(i=r.refVal[c],o=F(f,i))}o=F(f);var u=n.call(_,D,r,f);if(void 0===u){var d=p&&p[f];d&&(u=n.inlineRef(d,w.inlineRefs)?d:e.call(_,d,r,p,t))}if(void 0!==u)return function(e,t){var r=A[e];E[r]=t}(f,u),j(u,o);!function(e){delete A[e]}(f)}function F(e,t){var r=E.length;return E[r]=t,A[e]=r,"refVal"+r}function j(e,t){return"object"==typeof e||"boolean"==typeof e?{code:t,schema:e,inline:!0}:{code:t,$async:e&&!!e.$async}}function L(e){var t=x[e];return void 0===t&&(t=x[e]=T.length,T[t]=e),"pattern"+t}function U(e){switch(typeof e){case"boolean":case"number":return""+e;case"string":return f.toQuotedString(e);case"object":if(null===e)return"null";var t=i(e),r=S[t];return void 0===r&&(r=S[t]=k.length,k[r]=e),"default"+r}}function q(e,t,r,n){if(!1!==_._opts.validateSchema){var f=e.definition.dependencies;if(f&&!f.every((function(e){return Object.prototype.hasOwnProperty.call(r,e)})))throw new Error("parent schema must have all required keywords: "+f.join(","));var a=e.definition.validateSchema;if(a)if(!a(t)){var i="keyword schema is invalid: "+_.errorsText(a.errors);if("log"!=_._opts.validateSchema)throw new Error(i);_.logger.error(i)}}var o,s=e.definition.compile,c=e.definition.inline,u=e.definition.macro;if(s)o=s.call(_,t,r,n);else if(u)o=u.call(_,t,r,n),!1!==w.validateSchema&&_.validateSchema(o,!0);else if(c)o=c.call(_,n,e.keyword,t,r);else if(!(o=e.definition.validate))return;if(void 0===o)throw new Error('custom keyword "'+e.keyword+'"failed to compile');var d=O.length;return O[d]=o,{code:"customRule"+d,validate:o}}}},function(e,t,r){!function(e){"use strict";function t(){for(var e=arguments.length,t=Array(e),r=0;r<e;r++)t[r]=arguments[r];if(t.length>1){t[0]=t[0].slice(0,-1);for(var n=t.length-1,f=1;f<n;++f)t[f]=t[f].slice(1,-1);return t[n]=t[n].slice(1),t.join("")}return t[0]}function r(e){return"(?:"+e+")"}function n(e){return void 0===e?"undefined":null===e?"null":Object.prototype.toString.call(e).split(" ").pop().split("]").shift().toLowerCase()}function f(e){return e.toUpperCase()}function a(e){return null!=e?e instanceof Array?e:"number"!=typeof e.length||e.split||e.setInterval||e.call?[e]:Array.prototype.slice.call(e):[]}function i(e,t){var r=e;if(t)for(var n in t)r[n]=t[n];return r}function o(e){var n="[A-Za-z]",f="[0-9]",a=t(f,"[A-Fa-f]"),i=r(r("%[EFef]"+a+"%"+a+a+"%"+a+a)+"|"+r("%[89A-Fa-f]"+a+"%"+a+a)+"|"+r("%"+a+a)),o="[\\!\\$\\&\\'\\(\\)\\*\\+\\,\\;\\=]",s=t("[\\:\\/\\?\\#\\[\\]\\@]",o),c=e?"[\\uE000-\\uF8FF]":"[]",u=t(n,f,"[\\-\\.\\_\\~]",e?"[\\xA0-\\u200D\\u2010-\\u2029\\u202F-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF]":"[]"),d=r(n+t(n,f,"[\\+\\-\\.]")+"*"),l=r(r(i+"|"+t(u,o,"[\\:]"))+"*"),p=(r(r("25[0-5]")+"|"+r("2[0-4]"+f)+"|"+r("1"+f+f)+"|"+r("[1-9]"+f)+"|"+f),r(r("25[0-5]")+"|"+r("2[0-4]"+f)+"|"+r("1"+f+f)+"|"+r("0?[1-9]"+f)+"|0?0?"+f)),h=r(p+"\\."+p+"\\."+p+"\\."+p),b=r(a+"{1,4}"),m=r(r(b+"\\:"+b)+"|"+h),y=r(r(b+"\\:")+"{6}"+m),g=r("\\:\\:"+r(b+"\\:")+"{5}"+m),v=r(r(b)+"?\\:\\:"+r(b+"\\:")+"{4}"+m),_=r(r(r(b+"\\:")+"{0,1}"+b)+"?\\:\\:"+r(b+"\\:")+"{3}"+m),w=r(r(r(b+"\\:")+"{0,2}"+b)+"?\\:\\:"+r(b+"\\:")+"{2}"+m),E=r(r(r(b+"\\:")+"{0,3}"+b)+"?\\:\\:"+b+"\\:"+m),A=r(r(r(b+"\\:")+"{0,4}"+b)+"?\\:\\:"+m),T=r(r(r(b+"\\:")+"{0,5}"+b)+"?\\:\\:"+b),x=r(r(r(b+"\\:")+"{0,6}"+b)+"?\\:\\:"),k=r([y,g,v,_,w,E,A,T,x].join("|")),S=r(r(u+"|"+i)+"+"),O=(r(k+"\\%25"+S),r(k+r("\\%25|\\%(?!"+a+"{2})")+S)),C=r("[vV]"+a+"+\\."+t(u,o,"[\\:]")+"+"),P=r("\\["+r(O+"|"+k+"|"+C)+"\\]"),R=r(r(i+"|"+t(u,o))+"*"),N=r(P+"|"+h+"(?!"+R+")|"+R),I=r(f+"*"),M=r(r(l+"@")+"?"+N+r("\\:"+I)+"?"),D=r(i+"|"+t(u,o,"[\\:\\@]")),B=r(D+"*"),F=r(D+"+"),j=r(r(i+"|"+t(u,o,"[\\@]"))+"+"),L=r(r("\\/"+B)+"*"),U=r("\\/"+r(F+L)+"?"),q=r(j+L),H=r(F+L),$="(?!"+D+")",z=(r(L+"|"+U+"|"+q+"|"+H+"|"+$),r(r(D+"|"+t("[\\/\\?]",c))+"*")),V=r(r(D+"|[\\/\\?]")+"*"),G=r(r("\\/\\/"+M+L)+"|"+U+"|"+H+"|"+$),K=r(d+"\\:"+G+r("\\?"+z)+"?"+r("\\#"+V)+"?"),W=r(r("\\/\\/"+M+L)+"|"+U+"|"+q+"|"+$),Y=r(W+r("\\?"+z)+"?"+r("\\#"+V)+"?");return r(K+"|"+Y),r(d+"\\:"+G+r("\\?"+z)+"?"),r(r("\\/\\/("+r("("+l+")@")+"?("+N+")"+r("\\:("+I+")")+"?)")+"?("+L+"|"+U+"|"+H+"|"+$+")"),r("\\?("+z+")"),r("\\#("+V+")"),r(r("\\/\\/("+r("("+l+")@")+"?("+N+")"+r("\\:("+I+")")+"?)")+"?("+L+"|"+U+"|"+q+"|"+$+")"),r("\\?("+z+")"),r("\\#("+V+")"),r(r("\\/\\/("+r("("+l+")@")+"?("+N+")"+r("\\:("+I+")")+"?)")+"?("+L+"|"+U+"|"+H+"|"+$+")"),r("\\?("+z+")"),r("\\#("+V+")"),r("("+l+")@"),r("\\:("+I+")"),{NOT_SCHEME:new RegExp(t("[^]",n,f,"[\\+\\-\\.]"),"g"),NOT_USERINFO:new RegExp(t("[^\\%\\:]",u,o),"g"),NOT_HOST:new RegExp(t("[^\\%\\[\\]\\:]",u,o),"g"),NOT_PATH:new RegExp(t("[^\\%\\/\\:\\@]",u,o),"g"),NOT_PATH_NOSCHEME:new RegExp(t("[^\\%\\/\\@]",u,o),"g"),NOT_QUERY:new RegExp(t("[^\\%]",u,o,"[\\:\\@\\/\\?]",c),"g"),NOT_FRAGMENT:new RegExp(t("[^\\%]",u,o,"[\\:\\@\\/\\?]"),"g"),ESCAPE:new RegExp(t("[^]",u,o),"g"),UNRESERVED:new RegExp(u,"g"),OTHER_CHARS:new RegExp(t("[^\\%]",u,s),"g"),PCT_ENCODED:new RegExp(i,"g"),IPV4ADDRESS:new RegExp("^("+h+")$"),IPV6ADDRESS:new RegExp("^\\[?("+k+")"+r(r("\\%25|\\%(?!"+a+"{2})")+"("+S+")")+"?\\]?$")}}var s=o(!1),c=o(!0),u=function(){function e(e,t){var r=[],n=!0,f=!1,a=void 0;try{for(var i,o=e[Symbol.iterator]();!(n=(i=o.next()).done)&&(r.push(i.value),!t||r.length!==t);n=!0);}catch(e){f=!0,a=e}finally{try{!n&&o.return&&o.return()}finally{if(f)throw a}}return r}return function(t,r){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return e(t,r);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),d=function(e){if(Array.isArray(e)){for(var t=0,r=Array(e.length);t<e.length;t++)r[t]=e[t];return r}return Array.from(e)},l=2147483647,p=36,h=1,b=26,m=38,y=700,g=72,v=128,_="-",w=/^xn--/,E=/[^\0-\x7E]/,A=/[\x2E\u3002\uFF0E\uFF61]/g,T={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},x=p-h,k=Math.floor,S=String.fromCharCode;function O(e){throw new RangeError(T[e])}function C(e,t){for(var r=[],n=e.length;n--;)r[n]=t(e[n]);return r}function P(e,t){var r=e.split("@"),n="";return r.length>1&&(n=r[0]+"@",e=r[1]),n+C((e=e.replace(A,".")).split("."),t).join(".")}function R(e){for(var t=[],r=0,n=e.length;r<n;){var f=e.charCodeAt(r++);if(f>=55296&&f<=56319&&r<n){var a=e.charCodeAt(r++);56320==(64512&a)?t.push(((1023&f)<<10)+(1023&a)+65536):(t.push(f),r--)}else t.push(f)}return t}var N=function(e){return e-48<10?e-22:e-65<26?e-65:e-97<26?e-97:p},I=function(e,t){return e+22+75*(e<26)-((0!=t)<<5)},M=function(e,t,r){var n=0;for(e=r?k(e/y):e>>1,e+=k(e/t);e>x*b>>1;n+=p)e=k(e/x);return k(n+(x+1)*e/(e+m))},D=function(e){var t=[],r=e.length,n=0,f=v,a=g,i=e.lastIndexOf(_);i<0&&(i=0);for(var o=0;o<i;++o)e.charCodeAt(o)>=128&&O("not-basic"),t.push(e.charCodeAt(o));for(var s=i>0?i+1:0;s<r;){for(var c=n,u=1,d=p;;d+=p){s>=r&&O("invalid-input");var m=N(e.charCodeAt(s++));(m>=p||m>k((l-n)/u))&&O("overflow"),n+=m*u;var y=d<=a?h:d>=a+b?b:d-a;if(m<y)break;var w=p-y;u>k(l/w)&&O("overflow"),u*=w}var E=t.length+1;a=M(n-c,E,0==c),k(n/E)>l-f&&O("overflow"),f+=k(n/E),n%=E,t.splice(n++,0,f)}return String.fromCodePoint.apply(String,t)},B=function(e){var t=[],r=(e=R(e)).length,n=v,f=0,a=g,i=!0,o=!1,s=void 0;try{for(var c,u=e[Symbol.iterator]();!(i=(c=u.next()).done);i=!0){var d=c.value;d<128&&t.push(S(d))}}catch(e){o=!0,s=e}finally{try{!i&&u.return&&u.return()}finally{if(o)throw s}}var m=t.length,y=m;for(m&&t.push(_);y<r;){var w=l,E=!0,A=!1,T=void 0;try{for(var x,C=e[Symbol.iterator]();!(E=(x=C.next()).done);E=!0){var P=x.value;P>=n&&P<w&&(w=P)}}catch(e){A=!0,T=e}finally{try{!E&&C.return&&C.return()}finally{if(A)throw T}}var N=y+1;w-n>k((l-f)/N)&&O("overflow"),f+=(w-n)*N,n=w;var D=!0,B=!1,F=void 0;try{for(var j,L=e[Symbol.iterator]();!(D=(j=L.next()).done);D=!0){var U=j.value;if(U<n&&++f>l&&O("overflow"),U==n){for(var q=f,H=p;;H+=p){var $=H<=a?h:H>=a+b?b:H-a;if(q<$)break;var z=q-$,V=p-$;t.push(S(I($+z%V,0))),q=k(z/V)}t.push(S(I(q,0))),a=M(f,N,y==m),f=0,++y}}}catch(e){B=!0,F=e}finally{try{!D&&L.return&&L.return()}finally{if(B)throw F}}++f,++n}return t.join("")},F=function(e){return P(e,(function(e){return w.test(e)?D(e.slice(4).toLowerCase()):e}))},j=function(e){return P(e,(function(e){return E.test(e)?"xn--"+B(e):e}))},L={version:"2.1.0",ucs2:{decode:R,encode:function(e){return String.fromCodePoint.apply(String,d(e))}},decode:D,encode:B,toASCII:j,toUnicode:F},U={};function q(e){var t=e.charCodeAt(0);return t<16?"%0"+t.toString(16).toUpperCase():t<128?"%"+t.toString(16).toUpperCase():t<2048?"%"+(t>>6|192).toString(16).toUpperCase()+"%"+(63&t|128).toString(16).toUpperCase():"%"+(t>>12|224).toString(16).toUpperCase()+"%"+(t>>6&63|128).toString(16).toUpperCase()+"%"+(63&t|128).toString(16).toUpperCase()}function H(e){for(var t="",r=0,n=e.length;r<n;){var f=parseInt(e.substr(r+1,2),16);if(f<128)t+=String.fromCharCode(f),r+=3;else if(f>=194&&f<224){if(n-r>=6){var a=parseInt(e.substr(r+4,2),16);t+=String.fromCharCode((31&f)<<6|63&a)}else t+=e.substr(r,6);r+=6}else if(f>=224){if(n-r>=9){var i=parseInt(e.substr(r+4,2),16),o=parseInt(e.substr(r+7,2),16);t+=String.fromCharCode((15&f)<<12|(63&i)<<6|63&o)}else t+=e.substr(r,9);r+=9}else t+=e.substr(r,3),r+=3}return t}function $(e,t){function r(e){var r=H(e);return r.match(t.UNRESERVED)?r:e}return e.scheme&&(e.scheme=String(e.scheme).replace(t.PCT_ENCODED,r).toLowerCase().replace(t.NOT_SCHEME,"")),void 0!==e.userinfo&&(e.userinfo=String(e.userinfo).replace(t.PCT_ENCODED,r).replace(t.NOT_USERINFO,q).replace(t.PCT_ENCODED,f)),void 0!==e.host&&(e.host=String(e.host).replace(t.PCT_ENCODED,r).toLowerCase().replace(t.NOT_HOST,q).replace(t.PCT_ENCODED,f)),void 0!==e.path&&(e.path=String(e.path).replace(t.PCT_ENCODED,r).replace(e.scheme?t.NOT_PATH:t.NOT_PATH_NOSCHEME,q).replace(t.PCT_ENCODED,f)),void 0!==e.query&&(e.query=String(e.query).replace(t.PCT_ENCODED,r).replace(t.NOT_QUERY,q).replace(t.PCT_ENCODED,f)),void 0!==e.fragment&&(e.fragment=String(e.fragment).replace(t.PCT_ENCODED,r).replace(t.NOT_FRAGMENT,q).replace(t.PCT_ENCODED,f)),e}function z(e){return e.replace(/^0*(.*)/,"$1")||"0"}function V(e,t){var r=e.match(t.IPV4ADDRESS)||[],n=u(r,2)[1];return n?n.split(".").map(z).join("."):e}function G(e,t){var r=e.match(t.IPV6ADDRESS)||[],n=u(r,3),f=n[1],a=n[2];if(f){for(var i=f.toLowerCase().split("::").reverse(),o=u(i,2),s=o[0],c=o[1],d=c?c.split(":").map(z):[],l=s.split(":").map(z),p=t.IPV4ADDRESS.test(l[l.length-1]),h=p?7:8,b=l.length-h,m=Array(h),y=0;y<h;++y)m[y]=d[y]||l[b+y]||"";p&&(m[h-1]=V(m[h-1],t));var g=m.reduce((function(e,t,r){if(!t||"0"===t){var n=e[e.length-1];n&&n.index+n.length===r?n.length++:e.push({index:r,length:1})}return e}),[]).sort((function(e,t){return t.length-e.length}))[0],v=void 0;if(g&&g.length>1){var _=m.slice(0,g.index),w=m.slice(g.index+g.length);v=_.join(":")+"::"+w.join(":")}else v=m.join(":");return a&&(v+="%"+a),v}return e}var K=/^(?:([^:\/?#]+):)?(?:\/\/((?:([^\/?#@]*)@)?(\[[^\/?#\]]+\]|[^\/?#:]*)(?:\:(\d*))?))?([^?#]*)(?:\?([^#]*))?(?:#((?:.|\n|\r)*))?/i,W=void 0==="".match(/(){0}/)[1];function Y(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r={},n=!1!==t.iri?c:s;"suffix"===t.reference&&(e=(t.scheme?t.scheme+":":"")+"//"+e);var f=e.match(K);if(f){W?(r.scheme=f[1],r.userinfo=f[3],r.host=f[4],r.port=parseInt(f[5],10),r.path=f[6]||"",r.query=f[7],r.fragment=f[8],isNaN(r.port)&&(r.port=f[5])):(r.scheme=f[1]||void 0,r.userinfo=-1!==e.indexOf("@")?f[3]:void 0,r.host=-1!==e.indexOf("//")?f[4]:void 0,r.port=parseInt(f[5],10),r.path=f[6]||"",r.query=-1!==e.indexOf("?")?f[7]:void 0,r.fragment=-1!==e.indexOf("#")?f[8]:void 0,isNaN(r.port)&&(r.port=e.match(/\/\/(?:.|\n)*\:(?:\/|\?|\#|$)/)?f[4]:void 0)),r.host&&(r.host=G(V(r.host,n),n)),void 0!==r.scheme||void 0!==r.userinfo||void 0!==r.host||void 0!==r.port||r.path||void 0!==r.query?void 0===r.scheme?r.reference="relative":void 0===r.fragment?r.reference="absolute":r.reference="uri":r.reference="same-document",t.reference&&"suffix"!==t.reference&&t.reference!==r.reference&&(r.error=r.error||"URI is not a "+t.reference+" reference.");var a=U[(t.scheme||r.scheme||"").toLowerCase()];if(t.unicodeSupport||a&&a.unicodeSupport)$(r,n);else{if(r.host&&(t.domainHost||a&&a.domainHost))try{r.host=L.toASCII(r.host.replace(n.PCT_ENCODED,H).toLowerCase())}catch(e){r.error=r.error||"Host's domain name can not be converted to ASCII via punycode: "+e}$(r,s)}a&&a.parse&&a.parse(r,t)}else r.error=r.error||"URI can not be parsed.";return r}function J(e,t){var r=!1!==t.iri?c:s,n=[];return void 0!==e.userinfo&&(n.push(e.userinfo),n.push("@")),void 0!==e.host&&n.push(G(V(String(e.host),r),r).replace(r.IPV6ADDRESS,(function(e,t,r){return"["+t+(r?"%25"+r:"")+"]"}))),"number"!=typeof e.port&&"string"!=typeof e.port||(n.push(":"),n.push(String(e.port))),n.length?n.join(""):void 0}var X=/^\.\.?\//,Z=/^\/\.(\/|$)/,Q=/^\/\.\.(\/|$)/,ee=/^\/?(?:.|\n)*?(?=\/|$)/;function te(e){for(var t=[];e.length;)if(e.match(X))e=e.replace(X,"");else if(e.match(Z))e=e.replace(Z,"/");else if(e.match(Q))e=e.replace(Q,"/"),t.pop();else if("."===e||".."===e)e="";else{var r=e.match(ee);if(!r)throw new Error("Unexpected dot segment condition");var n=r[0];e=e.slice(n.length),t.push(n)}return t.join("")}function re(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=t.iri?c:s,n=[],f=U[(t.scheme||e.scheme||"").toLowerCase()];if(f&&f.serialize&&f.serialize(e,t),e.host)if(r.IPV6ADDRESS.test(e.host));else if(t.domainHost||f&&f.domainHost)try{e.host=t.iri?L.toUnicode(e.host):L.toASCII(e.host.replace(r.PCT_ENCODED,H).toLowerCase())}catch(r){e.error=e.error||"Host's domain name can not be converted to "+(t.iri?"Unicode":"ASCII")+" via punycode: "+r}$(e,r),"suffix"!==t.reference&&e.scheme&&(n.push(e.scheme),n.push(":"));var a=J(e,t);if(void 0!==a&&("suffix"!==t.reference&&n.push("//"),n.push(a),e.path&&"/"!==e.path.charAt(0)&&n.push("/")),void 0!==e.path){var i=e.path;t.absolutePath||f&&f.absolutePath||(i=te(i)),void 0===a&&(i=i.replace(/^\/\//,"/%2F")),n.push(i)}return void 0!==e.query&&(n.push("?"),n.push(e.query)),void 0!==e.fragment&&(n.push("#"),n.push(e.fragment)),n.join("")}function ne(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n={};return arguments[3]||(e=Y(re(e,r),r),t=Y(re(t,r),r)),!(r=r||{}).tolerant&&t.scheme?(n.scheme=t.scheme,n.userinfo=t.userinfo,n.host=t.host,n.port=t.port,n.path=te(t.path||""),n.query=t.query):(void 0!==t.userinfo||void 0!==t.host||void 0!==t.port?(n.userinfo=t.userinfo,n.host=t.host,n.port=t.port,n.path=te(t.path||""),n.query=t.query):(t.path?("/"===t.path.charAt(0)?n.path=te(t.path):(void 0===e.userinfo&&void 0===e.host&&void 0===e.port||e.path?e.path?n.path=e.path.slice(0,e.path.lastIndexOf("/")+1)+t.path:n.path=t.path:n.path="/"+t.path,n.path=te(n.path)),n.query=t.query):(n.path=e.path,void 0!==t.query?n.query=t.query:n.query=e.query),n.userinfo=e.userinfo,n.host=e.host,n.port=e.port),n.scheme=e.scheme),n.fragment=t.fragment,n}function fe(e,t,r){var n=i({scheme:"null"},r);return re(ne(Y(e,n),Y(t,n),n,!0),n)}function ae(e,t){return"string"==typeof e?e=re(Y(e,t),t):"object"===n(e)&&(e=Y(re(e,t),t)),e}function ie(e,t,r){return"string"==typeof e?e=re(Y(e,r),r):"object"===n(e)&&(e=re(e,r)),"string"==typeof t?t=re(Y(t,r),r):"object"===n(t)&&(t=re(t,r)),e===t}function oe(e,t){return e&&e.toString().replace(t&&t.iri?c.ESCAPE:s.ESCAPE,q)}function se(e,t){return e&&e.toString().replace(t&&t.iri?c.PCT_ENCODED:s.PCT_ENCODED,H)}var ce={scheme:"http",domainHost:!0,parse:function(e,t){return e.host||(e.error=e.error||"HTTP URIs must have a host."),e},serialize:function(e,t){var r="https"===String(e.scheme).toLowerCase();return e.port!==(r?443:80)&&""!==e.port||(e.port=void 0),e.path||(e.path="/"),e}},ue={scheme:"https",domainHost:ce.domainHost,parse:ce.parse,serialize:ce.serialize};function de(e){return"boolean"==typeof e.secure?e.secure:"wss"===String(e.scheme).toLowerCase()}var le={scheme:"ws",domainHost:!0,parse:function(e,t){var r=e;return r.secure=de(r),r.resourceName=(r.path||"/")+(r.query?"?"+r.query:""),r.path=void 0,r.query=void 0,r},serialize:function(e,t){if(e.port!==(de(e)?443:80)&&""!==e.port||(e.port=void 0),"boolean"==typeof e.secure&&(e.scheme=e.secure?"wss":"ws",e.secure=void 0),e.resourceName){var r=e.resourceName.split("?"),n=u(r,2),f=n[0],a=n[1];e.path=f&&"/"!==f?f:void 0,e.query=a,e.resourceName=void 0}return e.fragment=void 0,e}},pe={scheme:"wss",domainHost:le.domainHost,parse:le.parse,serialize:le.serialize},he={},be="[A-Za-z0-9\\-\\.\\_\\~\\xA0-\\u200D\\u2010-\\u2029\\u202F-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF]",me="[0-9A-Fa-f]",ye=r(r("%[EFef]"+me+"%"+me+me+"%"+me+me)+"|"+r("%[89A-Fa-f]"+me+"%"+me+me)+"|"+r("%"+me+me)),ge="[A-Za-z0-9\\!\\$\\%\\'\\*\\+\\-\\^\\_\\`\\{\\|\\}\\~]",ve=t("[\\!\\$\\%\\'\\(\\)\\*\\+\\,\\-\\.0-9\\<\\>A-Z\\x5E-\\x7E]",'[\\"\\\\]'),_e="[\\!\\$\\'\\(\\)\\*\\+\\,\\;\\:\\@]",we=new RegExp(be,"g"),Ee=new RegExp(ye,"g"),Ae=new RegExp(t("[^]",ge,"[\\.]",'[\\"]',ve),"g"),Te=new RegExp(t("[^]",be,_e),"g"),xe=Te;function ke(e){var t=H(e);return t.match(we)?t:e}var Se={scheme:"mailto",parse:function(e,t){var r=e,n=r.to=r.path?r.path.split(","):[];if(r.path=void 0,r.query){for(var f=!1,a={},i=r.query.split("&"),o=0,s=i.length;o<s;++o){var c=i[o].split("=");switch(c[0]){case"to":for(var u=c[1].split(","),d=0,l=u.length;d<l;++d)n.push(u[d]);break;case"subject":r.subject=se(c[1],t);break;case"body":r.body=se(c[1],t);break;default:f=!0,a[se(c[0],t)]=se(c[1],t)}}f&&(r.headers=a)}r.query=void 0;for(var p=0,h=n.length;p<h;++p){var b=n[p].split("@");if(b[0]=se(b[0]),t.unicodeSupport)b[1]=se(b[1],t).toLowerCase();else try{b[1]=L.toASCII(se(b[1],t).toLowerCase())}catch(e){r.error=r.error||"Email address's domain name can not be converted to ASCII via punycode: "+e}n[p]=b.join("@")}return r},serialize:function(e,t){var r=e,n=a(e.to);if(n){for(var i=0,o=n.length;i<o;++i){var s=String(n[i]),c=s.lastIndexOf("@"),u=s.slice(0,c).replace(Ee,ke).replace(Ee,f).replace(Ae,q),d=s.slice(c+1);try{d=t.iri?L.toUnicode(d):L.toASCII(se(d,t).toLowerCase())}catch(e){r.error=r.error||"Email address's domain name can not be converted to "+(t.iri?"Unicode":"ASCII")+" via punycode: "+e}n[i]=u+"@"+d}r.path=n.join(",")}var l=e.headers=e.headers||{};e.subject&&(l.subject=e.subject),e.body&&(l.body=e.body);var p=[];for(var h in l)l[h]!==he[h]&&p.push(h.replace(Ee,ke).replace(Ee,f).replace(Te,q)+"="+l[h].replace(Ee,ke).replace(Ee,f).replace(xe,q));return p.length&&(r.query=p.join("&")),r}},Oe=/^([^\:]+)\:(.*)/,Ce={scheme:"urn",parse:function(e,t){var r=e.path&&e.path.match(Oe),n=e;if(r){var f=t.scheme||n.scheme||"urn",a=r[1].toLowerCase(),i=r[2],o=f+":"+(t.nid||a),s=U[o];n.nid=a,n.nss=i,n.path=void 0,s&&(n=s.parse(n,t))}else n.error=n.error||"URN can not be parsed.";return n},serialize:function(e,t){var r=t.scheme||e.scheme||"urn",n=e.nid,f=r+":"+(t.nid||n),a=U[f];a&&(e=a.serialize(e,t));var i=e,o=e.nss;return i.path=(n||t.nid)+":"+o,i}},Pe=/^[0-9A-Fa-f]{8}(?:\-[0-9A-Fa-f]{4}){3}\-[0-9A-Fa-f]{12}$/,Re={scheme:"urn:uuid",parse:function(e,t){var r=e;return r.uuid=r.nss,r.nss=void 0,t.tolerant||r.uuid&&r.uuid.match(Pe)||(r.error=r.error||"UUID is not valid."),r},serialize:function(e,t){var r=e;return r.nss=(e.uuid||"").toLowerCase(),r}};U[ce.scheme]=ce,U[ue.scheme]=ue,U[le.scheme]=le,U[pe.scheme]=pe,U[Se.scheme]=Se,U[Ce.scheme]=Ce,U[Re.scheme]=Re,e.SCHEMES=U,e.pctEncChar=q,e.pctDecChars=H,e.parse=Y,e.removeDotSegments=te,e.serialize=re,e.resolveComponents=ne,e.resolve=fe,e.normalize=ae,e.equal=ie,e.escapeComponent=oe,e.unescapeComponent=se,Object.defineProperty(e,"__esModule",{value:!0})}(t)},function(e,t,r){"use strict";e.exports=function(e){for(var t,r=0,n=e.length,f=0;f<n;)r++,(t=e.charCodeAt(f++))>=55296&&t<=56319&&f<n&&56320==(64512&(t=e.charCodeAt(f)))&&f++;return r}},function(e,t,r){"use strict";var n=e.exports=function(e,t,r){"function"==typeof t&&(r=t,t={}),f(t,"function"==typeof(r=t.cb||r)?r:r.pre||function(){},r.post||function(){},e,"",e)};function f(e,t,r,a,i,o,s,c,u,d){if(a&&"object"==typeof a&&!Array.isArray(a)){for(var l in t(a,i,o,s,c,u,d),a){var p=a[l];if(Array.isArray(p)){if(l in n.arrayKeywords)for(var h=0;h<p.length;h++)f(e,t,r,p[h],i+"/"+l+"/"+h,o,i,l,a,h)}else if(l in n.propsKeywords){if(p&&"object"==typeof p)for(var b in p)f(e,t,r,p[b],i+"/"+l+"/"+b.replace(/~/g,"~0").replace(/\//g,"~1"),o,i,l,a,b)}else(l in n.keywords||e.allKeys&&!(l in n.skipKeywords))&&f(e,t,r,p,i+"/"+l,o,i,l,a)}r(a,i,o,s,c,u,d)}}n.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0},n.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0},n.propsKeywords={definitions:!0,properties:!0,patternProperties:!0,dependencies:!0},n.skipKeywords={default:!0,enum:!0,const:!0,required:!0,maximum:!0,minimum:!0,exclusiveMaximum:!0,exclusiveMinimum:!0,multipleOf:!0,maxLength:!0,minLength:!0,pattern:!0,format:!0,maxItems:!0,minItems:!0,uniqueItems:!0,maxProperties:!0,minProperties:!0}},function(e,t,r){"use strict";var n=e.exports=function(){this._cache={}};n.prototype.put=function(e,t){this._cache[e]=t},n.prototype.get=function(e){return this._cache[e]},n.prototype.del=function(e){delete this._cache[e]},n.prototype.clear=function(){this._cache={}}},function(e,t,r){"use strict";var n=r(84),f=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,a=[0,31,28,31,30,31,30,31,31,30,31,30,31],i=/^(\d\d):(\d\d):(\d\d)(\.\d+)?(z|[+-]\d\d(?::?\d\d)?)?$/i,o=/^(?=.{1,253}\.?$)[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[-0-9a-z]{0,61}[0-9a-z])?)*\.?$/i,s=/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)(?:\?(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i,c=/^(?:(?:[^\x00-\x20"'<>%\\^`{|}]|%[0-9a-f]{2})|\{[+#./;?&=,!@|]?(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?(?:,(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?)*\})*$/i,u=/^(?:(?:http[s\u017F]?|ftp):\/\/)(?:(?:[\0-\x08\x0E-\x1F!-\x9F\xA1-\u167F\u1681-\u1FFF\u200B-\u2027\u202A-\u202E\u2030-\u205E\u2060-\u2FFF\u3001-\uD7FF\uE000-\uFEFE\uFF00-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+(?::(?:[\0-\x08\x0E-\x1F!-\x9F\xA1-\u167F\u1681-\u1FFF\u200B-\u2027\u202A-\u202E\u2030-\u205E\u2060-\u2FFF\u3001-\uD7FF\uE000-\uFEFE\uFF00-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*)?@)?(?:(?!10(?:\.[0-9]{1,3}){3})(?!127(?:\.[0-9]{1,3}){3})(?!169\.254(?:\.[0-9]{1,3}){2})(?!192\.168(?:\.[0-9]{1,3}){2})(?!172\.(?:1[6-9]|2[0-9]|3[01])(?:\.[0-9]{1,3}){2})(?:[1-9][0-9]?|1[0-9][0-9]|2[01][0-9]|22[0-3])(?:\.(?:1?[0-9]{1,2}|2[0-4][0-9]|25[0-5])){2}(?:\.(?:[1-9][0-9]?|1[0-9][0-9]|2[0-4][0-9]|25[0-4]))|(?:(?:(?:[0-9KSa-z\xA1-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+-?)*(?:[0-9KSa-z\xA1-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+)(?:\.(?:(?:[0-9KSa-z\xA1-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+-?)*(?:[0-9KSa-z\xA1-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+)*(?:\.(?:(?:[KSa-z\xA1-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]){2,})))(?::[0-9]{2,5})?(?:\/(?:[\0-\x08\x0E-\x1F!-\x9F\xA1-\u167F\u1681-\u1FFF\u200B-\u2027\u202A-\u202E\u2030-\u205E\u2060-\u2FFF\u3001-\uD7FF\uE000-\uFEFE\uFF00-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*)?$/i,d=/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i,l=/^(?:\/(?:[^~/]|~0|~1)*)*$/,p=/^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i,h=/^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/;function b(e){return e="full"==e?"full":"fast",n.copy(b[e])}function m(e){var t=e.match(f);if(!t)return!1;var r=+t[1],n=+t[2],i=+t[3];return n>=1&&n<=12&&i>=1&&i<=(2==n&&function(e){return e%4==0&&(e%100!=0||e%400==0)}(r)?29:a[n])}function y(e,t){var r=e.match(i);if(!r)return!1;var n=r[1],f=r[2],a=r[3],o=r[5];return(n<=23&&f<=59&&a<=59||23==n&&59==f&&60==a)&&(!t||o)}e.exports=b,b.fast={date:/^\d\d\d\d-[0-1]\d-[0-3]\d$/,time:/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,"date-time":/^\d\d\d\d-[0-1]\d-[0-3]\d[t\s](?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,uri:/^(?:[a-z][a-z0-9+-.]*:)(?:\/?\/)?[^\s]*$/i,"uri-reference":/^(?:(?:[a-z][a-z0-9+-.]*:)?\/?\/)?(?:[^\\\s#][^\s#]*)?(?:#[^\\\s]*)?$/i,"uri-template":c,url:u,email:/^[a-z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*$/i,hostname:o,ipv4:/^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)$/,ipv6:/^\s*(?:(?:(?:[0-9a-f]{1,4}:){7}(?:[0-9a-f]{1,4}|:))|(?:(?:[0-9a-f]{1,4}:){6}(?::[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(?:(?:[0-9a-f]{1,4}:){5}(?:(?:(?::[0-9a-f]{1,4}){1,2})|:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(?:(?:[0-9a-f]{1,4}:){4}(?:(?:(?::[0-9a-f]{1,4}){1,3})|(?:(?::[0-9a-f]{1,4})?:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){3}(?:(?:(?::[0-9a-f]{1,4}){1,4})|(?:(?::[0-9a-f]{1,4}){0,2}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){2}(?:(?:(?::[0-9a-f]{1,4}){1,5})|(?:(?::[0-9a-f]{1,4}){0,3}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){1}(?:(?:(?::[0-9a-f]{1,4}){1,6})|(?:(?::[0-9a-f]{1,4}){0,4}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?::(?:(?:(?::[0-9a-f]{1,4}){1,7})|(?:(?::[0-9a-f]{1,4}){0,5}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(?:%.+)?\s*$/i,regex:w,uuid:d,"json-pointer":l,"json-pointer-uri-fragment":p,"relative-json-pointer":h},b.full={date:m,time:y,"date-time":function(e){var t=e.split(g);return 2==t.length&&m(t[0])&&y(t[1],!0)},uri:function(e){return v.test(e)&&s.test(e)},"uri-reference":/^(?:[a-z][a-z0-9+\-.]*:)?(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'"()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?(?:\?(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i,"uri-template":c,url:u,email:/^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i,hostname:o,ipv4:/^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)$/,ipv6:/^\s*(?:(?:(?:[0-9a-f]{1,4}:){7}(?:[0-9a-f]{1,4}|:))|(?:(?:[0-9a-f]{1,4}:){6}(?::[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(?:(?:[0-9a-f]{1,4}:){5}(?:(?:(?::[0-9a-f]{1,4}){1,2})|:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(?:(?:[0-9a-f]{1,4}:){4}(?:(?:(?::[0-9a-f]{1,4}){1,3})|(?:(?::[0-9a-f]{1,4})?:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){3}(?:(?:(?::[0-9a-f]{1,4}){1,4})|(?:(?::[0-9a-f]{1,4}){0,2}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){2}(?:(?:(?::[0-9a-f]{1,4}){1,5})|(?:(?::[0-9a-f]{1,4}){0,3}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){1}(?:(?:(?::[0-9a-f]{1,4}){1,6})|(?:(?::[0-9a-f]{1,4}){0,4}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?::(?:(?:(?::[0-9a-f]{1,4}){1,7})|(?:(?::[0-9a-f]{1,4}){0,5}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(?:%.+)?\s*$/i,regex:w,uuid:d,"json-pointer":l,"json-pointer-uri-fragment":p,"relative-json-pointer":h};var g=/t|\s/i;var v=/\/|:/;var _=/[^\\]\\Z/;function w(e){if(_.test(e))return!1;try{return new RegExp(e),!0}catch(e){return!1}}},function(e,t,r){"use strict";var n=r(804),f=r(84).toHash;e.exports=function(){var e=[{type:"number",rules:[{maximum:["exclusiveMaximum"]},{minimum:["exclusiveMinimum"]},"multipleOf","format"]},{type:"string",rules:["maxLength","minLength","pattern","format"]},{type:"array",rules:["maxItems","minItems","items","contains","uniqueItems"]},{type:"object",rules:["maxProperties","minProperties","required","dependencies","propertyNames",{properties:["additionalProperties","patternProperties"]}]},{rules:["$ref","const","enum","not","anyOf","oneOf","allOf","if"]}],t=["type","$comment"];return e.all=f(t),e.types=f(["number","integer","string","array","object","boolean","null"]),e.forEach((function(r){r.rules=r.rules.map((function(r){var f;if("object"==typeof r){var a=Object.keys(r)[0];f=r[a],r=a,f.forEach((function(r){t.push(r),e.all[r]=!0}))}return t.push(r),e.all[r]={keyword:r,code:n[r],implements:f}})),e.all.$comment={keyword:"$comment",code:n.$comment},r.type&&(e.types[r.type]=r)})),e.keywords=f(t.concat(["$schema","$id","id","$data","$async","title","description","default","definitions","examples","readOnly","writeOnly","contentMediaType","contentEncoding","additionalItems","then","else"])),e.custom={},e}},function(e,t,r){"use strict";e.exports={$ref:r(805),allOf:r(806),anyOf:r(807),$comment:r(808),const:r(809),contains:r(810),dependencies:r(811),enum:r(812),format:r(813),if:r(814),items:r(815),maximum:r(320),minimum:r(320),maxItems:r(321),minItems:r(321),maxLength:r(322),minLength:r(322),maxProperties:r(323),minProperties:r(323),multipleOf:r(816),not:r(817),oneOf:r(818),pattern:r(819),properties:r(820),propertyNames:r(821),required:r(822),uniqueItems:r(823),validate:r(319)}},function(e,t,r){"use strict";e.exports=function(e,t,r){var n,f,a=" ",i=e.level,o=e.dataLevel,s=e.schema[t],c=e.errSchemaPath+"/"+t,u=!e.opts.allErrors,d="data"+(o||""),l="valid"+i;if("#"==s||"#/"==s)e.isRoot?(n=e.async,f="validate"):(n=!0===e.root.schema.$async,f="root.refVal[0]");else{var p=e.resolveRef(e.baseId,s,e.isRoot);if(void 0===p){var h=e.MissingRefError.message(e.baseId,s);if("fail"==e.opts.missingRefs){e.logger.error(h),(g=g||[]).push(a),a="",!1!==e.createErrors?(a+=" { keyword: '$ref' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(c)+" , params: { ref: '"+e.util.escapeQuotes(s)+"' } ",!1!==e.opts.messages&&(a+=" , message: 'can\\'t resolve reference "+e.util.escapeQuotes(s)+"' "),e.opts.verbose&&(a+=" , schema: "+e.util.toQuotedString(s)+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+d+" "),a+=" } "):a+=" {} ";var b=a;a=g.pop(),!e.compositeRule&&u?e.async?a+=" throw new ValidationError(["+b+"]); ":a+=" validate.errors = ["+b+"]; return false; ":a+=" var err = "+b+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",u&&(a+=" if (false) { ")}else{if("ignore"!=e.opts.missingRefs)throw new e.MissingRefError(e.baseId,s,h);e.logger.warn(h),u&&(a+=" if (true) { ")}}else if(p.inline){var m=e.util.copy(e);m.level++;var y="valid"+m.level;m.schema=p.schema,m.schemaPath="",m.errSchemaPath=s,a+=" "+e.validate(m).replace(/validate\.schema/g,p.code)+" ",u&&(a+=" if ("+y+") { ")}else n=!0===p.$async||e.async&&!1!==p.$async,f=p.code}if(f){var g;(g=g||[]).push(a),a="",e.opts.passContext?a+=" "+f+".call(this, ":a+=" "+f+"( ",a+=" "+d+", (dataPath || '')",'""'!=e.errorPath&&(a+=" + "+e.errorPath);var v=a+=" , "+(o?"data"+(o-1||""):"parentData")+" , "+(o?e.dataPathArr[o]:"parentDataProperty")+", rootData) ";if(a=g.pop(),n){if(!e.async)throw new Error("async schema referenced by sync schema");u&&(a+=" var "+l+"; "),a+=" try { await "+v+"; ",u&&(a+=" "+l+" = true; "),a+=" } catch (e) { if (!(e instanceof ValidationError)) throw e; if (vErrors === null) vErrors = e.errors; else vErrors = vErrors.concat(e.errors); errors = vErrors.length; ",u&&(a+=" "+l+" = false; "),a+=" } ",u&&(a+=" if ("+l+") { ")}else a+=" if (!"+v+") { if (vErrors === null) vErrors = "+f+".errors; else vErrors = vErrors.concat("+f+".errors); errors = vErrors.length; } ",u&&(a+=" else { ")}return a}},function(e,t,r){"use strict";e.exports=function(e,t,r){var n=" ",f=e.schema[t],a=e.schemaPath+e.util.getProperty(t),i=e.errSchemaPath+"/"+t,o=!e.opts.allErrors,s=e.util.copy(e),c="";s.level++;var u="valid"+s.level,d=s.baseId,l=!0,p=f;if(p)for(var h,b=-1,m=p.length-1;b<m;)h=p[b+=1],(e.opts.strictKeywords?"object"==typeof h&&Object.keys(h).length>0:e.util.schemaHasRules(h,e.RULES.all))&&(l=!1,s.schema=h,s.schemaPath=a+"["+b+"]",s.errSchemaPath=i+"/"+b,n+=" "+e.validate(s)+" ",s.baseId=d,o&&(n+=" if ("+u+") { ",c+="}"));return o&&(n+=l?" if (true) { ":" "+c.slice(0,-1)+" "),n}},function(e,t,r){"use strict";e.exports=function(e,t,r){var n=" ",f=e.level,a=e.dataLevel,i=e.schema[t],o=e.schemaPath+e.util.getProperty(t),s=e.errSchemaPath+"/"+t,c=!e.opts.allErrors,u="data"+(a||""),d="valid"+f,l="errs__"+f,p=e.util.copy(e),h="";p.level++;var b="valid"+p.level,m=i.every((function(t){return e.opts.strictKeywords?"object"==typeof t&&Object.keys(t).length>0:e.util.schemaHasRules(t,e.RULES.all)}));if(m){var y=p.baseId;n+=" var "+l+" = errors; var "+d+" = false; ";var g=e.compositeRule;e.compositeRule=p.compositeRule=!0;var v=i;if(v)for(var _,w=-1,E=v.length-1;w<E;)_=v[w+=1],p.schema=_,p.schemaPath=o+"["+w+"]",p.errSchemaPath=s+"/"+w,n+=" "+e.validate(p)+" ",p.baseId=y,n+=" "+d+" = "+d+" || "+b+"; if (!"+d+") { ",h+="}";e.compositeRule=p.compositeRule=g,n+=" "+h+" if (!"+d+") { var err = ",!1!==e.createErrors?(n+=" { keyword: 'anyOf' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(s)+" , params: {} ",!1!==e.opts.messages&&(n+=" , message: 'should match some schema in anyOf' "),e.opts.verbose&&(n+=" , schema: validate.schema"+o+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+u+" "),n+=" } "):n+=" {} ",n+="; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",!e.compositeRule&&c&&(e.async?n+=" throw new ValidationError(vErrors); ":n+=" validate.errors = vErrors; return false; "),n+=" } else { errors = "+l+"; if (vErrors !== null) { if ("+l+") vErrors.length = "+l+"; else vErrors = null; } ",e.opts.allErrors&&(n+=" } ")}else c&&(n+=" if (true) { ");return n}},function(e,t,r){"use strict";e.exports=function(e,t,r){var n=" ",f=e.schema[t],a=e.errSchemaPath+"/"+t,i=(e.opts.allErrors,e.util.toQuotedString(f));return!0===e.opts.$comment?n+=" console.log("+i+");":"function"==typeof e.opts.$comment&&(n+=" self._opts.$comment("+i+", "+e.util.toQuotedString(a)+", validate.root.schema);"),n}},function(e,t,r){"use strict";e.exports=function(e,t,r){var n=" ",f=e.level,a=e.dataLevel,i=e.schema[t],o=e.schemaPath+e.util.getProperty(t),s=e.errSchemaPath+"/"+t,c=!e.opts.allErrors,u="data"+(a||""),d="valid"+f,l=e.opts.$data&&i&&i.$data;l&&(n+=" var schema"+f+" = "+e.util.getData(i.$data,a,e.dataPathArr)+"; "),l||(n+=" var schema"+f+" = validate.schema"+o+";"),n+="var "+d+" = equal("+u+", schema"+f+"); if (!"+d+") { ";var p=p||[];p.push(n),n="",!1!==e.createErrors?(n+=" { keyword: 'const' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(s)+" , params: { allowedValue: schema"+f+" } ",!1!==e.opts.messages&&(n+=" , message: 'should be equal to constant' "),e.opts.verbose&&(n+=" , schema: validate.schema"+o+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+u+" "),n+=" } "):n+=" {} ";var h=n;return n=p.pop(),!e.compositeRule&&c?e.async?n+=" throw new ValidationError(["+h+"]); ":n+=" validate.errors = ["+h+"]; return false; ":n+=" var err = "+h+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",n+=" }",c&&(n+=" else { "),n}},function(e,t,r){"use strict";e.exports=function(e,t,r){var n=" ",f=e.level,a=e.dataLevel,i=e.schema[t],o=e.schemaPath+e.util.getProperty(t),s=e.errSchemaPath+"/"+t,c=!e.opts.allErrors,u="data"+(a||""),d="valid"+f,l="errs__"+f,p=e.util.copy(e);p.level++;var h="valid"+p.level,b="i"+f,m=p.dataLevel=e.dataLevel+1,y="data"+m,g=e.baseId,v=e.opts.strictKeywords?"object"==typeof i&&Object.keys(i).length>0:e.util.schemaHasRules(i,e.RULES.all);if(n+="var "+l+" = errors;var "+d+";",v){var _=e.compositeRule;e.compositeRule=p.compositeRule=!0,p.schema=i,p.schemaPath=o,p.errSchemaPath=s,n+=" var "+h+" = false; for (var "+b+" = 0; "+b+" < "+u+".length; "+b+"++) { ",p.errorPath=e.util.getPathExpr(e.errorPath,b,e.opts.jsonPointers,!0);var w=u+"["+b+"]";p.dataPathArr[m]=b;var E=e.validate(p);p.baseId=g,e.util.varOccurences(E,y)<2?n+=" "+e.util.varReplace(E,y,w)+" ":n+=" var "+y+" = "+w+"; "+E+" ",n+=" if ("+h+") break; } ",e.compositeRule=p.compositeRule=_,n+=" if (!"+h+") {"}else n+=" if ("+u+".length == 0) {";var A=A||[];A.push(n),n="",!1!==e.createErrors?(n+=" { keyword: 'contains' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(s)+" , params: {} ",!1!==e.opts.messages&&(n+=" , message: 'should contain a valid item' "),e.opts.verbose&&(n+=" , schema: validate.schema"+o+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+u+" "),n+=" } "):n+=" {} ";var T=n;return n=A.pop(),!e.compositeRule&&c?e.async?n+=" throw new ValidationError(["+T+"]); ":n+=" validate.errors = ["+T+"]; return false; ":n+=" var err = "+T+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",n+=" } else { ",v&&(n+=" errors = "+l+"; if (vErrors !== null) { if ("+l+") vErrors.length = "+l+"; else vErrors = null; } "),e.opts.allErrors&&(n+=" } "),n}},function(e,t,r){"use strict";e.exports=function(e,t,r){var n=" ",f=e.level,a=e.dataLevel,i=e.schema[t],o=e.schemaPath+e.util.getProperty(t),s=e.errSchemaPath+"/"+t,c=!e.opts.allErrors,u="data"+(a||""),d="errs__"+f,l=e.util.copy(e),p="";l.level++;var h="valid"+l.level,b={},m={},y=e.opts.ownProperties;for(w in i)if("__proto__"!=w){var g=i[w],v=Array.isArray(g)?m:b;v[w]=g}n+="var "+d+" = errors;";var _=e.errorPath;for(var w in n+="var missing"+f+";",m)if((v=m[w]).length){if(n+=" if ( "+u+e.util.getProperty(w)+" !== undefined ",y&&(n+=" && Object.prototype.hasOwnProperty.call("+u+", '"+e.util.escapeQuotes(w)+"') "),c){n+=" && ( ";var E=v;if(E)for(var A=-1,T=E.length-1;A<T;){P=E[A+=1],A&&(n+=" || "),n+=" ( ( "+(M=u+(I=e.util.getProperty(P)))+" === undefined ",y&&(n+=" || ! Object.prototype.hasOwnProperty.call("+u+", '"+e.util.escapeQuotes(P)+"') "),n+=") && (missing"+f+" = "+e.util.toQuotedString(e.opts.jsonPointers?P:I)+") ) "}n+=")) { ";var x="missing"+f,k="' + "+x+" + '";e.opts._errorDataPathProperty&&(e.errorPath=e.opts.jsonPointers?e.util.getPathExpr(_,x,!0):_+" + "+x);var S=S||[];S.push(n),n="",!1!==e.createErrors?(n+=" { keyword: 'dependencies' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(s)+" , params: { property: '"+e.util.escapeQuotes(w)+"', missingProperty: '"+k+"', depsCount: "+v.length+", deps: '"+e.util.escapeQuotes(1==v.length?v[0]:v.join(", "))+"' } ",!1!==e.opts.messages&&(n+=" , message: 'should have ",1==v.length?n+="property "+e.util.escapeQuotes(v[0]):n+="properties "+e.util.escapeQuotes(v.join(", ")),n+=" when property "+e.util.escapeQuotes(w)+" is present' "),e.opts.verbose&&(n+=" , schema: validate.schema"+o+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+u+" "),n+=" } "):n+=" {} ";var O=n;n=S.pop(),!e.compositeRule&&c?e.async?n+=" throw new ValidationError(["+O+"]); ":n+=" validate.errors = ["+O+"]; return false; ":n+=" var err = "+O+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; "}else{n+=" ) { ";var C=v;if(C)for(var P,R=-1,N=C.length-1;R<N;){P=C[R+=1];var I=e.util.getProperty(P),M=(k=e.util.escapeQuotes(P),u+I);e.opts._errorDataPathProperty&&(e.errorPath=e.util.getPath(_,P,e.opts.jsonPointers)),n+=" if ( "+M+" === undefined ",y&&(n+=" || ! Object.prototype.hasOwnProperty.call("+u+", '"+e.util.escapeQuotes(P)+"') "),n+=") { var err = ",!1!==e.createErrors?(n+=" { keyword: 'dependencies' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(s)+" , params: { property: '"+e.util.escapeQuotes(w)+"', missingProperty: '"+k+"', depsCount: "+v.length+", deps: '"+e.util.escapeQuotes(1==v.length?v[0]:v.join(", "))+"' } ",!1!==e.opts.messages&&(n+=" , message: 'should have ",1==v.length?n+="property "+e.util.escapeQuotes(v[0]):n+="properties "+e.util.escapeQuotes(v.join(", ")),n+=" when property "+e.util.escapeQuotes(w)+" is present' "),e.opts.verbose&&(n+=" , schema: validate.schema"+o+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+u+" "),n+=" } "):n+=" {} ",n+="; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; } "}}n+=" } ",c&&(p+="}",n+=" else { ")}e.errorPath=_;var D=l.baseId;for(var w in b){g=b[w];(e.opts.strictKeywords?"object"==typeof g&&Object.keys(g).length>0:e.util.schemaHasRules(g,e.RULES.all))&&(n+=" "+h+" = true; if ( "+u+e.util.getProperty(w)+" !== undefined ",y&&(n+=" && Object.prototype.hasOwnProperty.call("+u+", '"+e.util.escapeQuotes(w)+"') "),n+=") { ",l.schema=g,l.schemaPath=o+e.util.getProperty(w),l.errSchemaPath=s+"/"+e.util.escapeFragment(w),n+=" "+e.validate(l)+" ",l.baseId=D,n+=" } ",c&&(n+=" if ("+h+") { ",p+="}"))}return c&&(n+=" "+p+" if ("+d+" == errors) {"),n}},function(e,t,r){"use strict";e.exports=function(e,t,r){var n=" ",f=e.level,a=e.dataLevel,i=e.schema[t],o=e.schemaPath+e.util.getProperty(t),s=e.errSchemaPath+"/"+t,c=!e.opts.allErrors,u="data"+(a||""),d="valid"+f,l=e.opts.$data&&i&&i.$data;l&&(n+=" var schema"+f+" = "+e.util.getData(i.$data,a,e.dataPathArr)+"; ");var p="i"+f,h="schema"+f;l||(n+=" var "+h+" = validate.schema"+o+";"),n+="var "+d+";",l&&(n+=" if (schema"+f+" === undefined) "+d+" = true; else if (!Array.isArray(schema"+f+")) "+d+" = false; else {"),n+=d+" = false;for (var "+p+"=0; "+p+"<"+h+".length; "+p+"++) if (equal("+u+", "+h+"["+p+"])) { "+d+" = true; break; }",l&&(n+=" } "),n+=" if (!"+d+") { ";var b=b||[];b.push(n),n="",!1!==e.createErrors?(n+=" { keyword: 'enum' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(s)+" , params: { allowedValues: schema"+f+" } ",!1!==e.opts.messages&&(n+=" , message: 'should be equal to one of the allowed values' "),e.opts.verbose&&(n+=" , schema: validate.schema"+o+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+u+" "),n+=" } "):n+=" {} ";var m=n;return n=b.pop(),!e.compositeRule&&c?e.async?n+=" throw new ValidationError(["+m+"]); ":n+=" validate.errors = ["+m+"]; return false; ":n+=" var err = "+m+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",n+=" }",c&&(n+=" else { "),n}},function(e,t,r){"use strict";e.exports=function(e,t,r){var n=" ",f=e.level,a=e.dataLevel,i=e.schema[t],o=e.schemaPath+e.util.getProperty(t),s=e.errSchemaPath+"/"+t,c=!e.opts.allErrors,u="data"+(a||"");if(!1===e.opts.format)return c&&(n+=" if (true) { "),n;var d,l=e.opts.$data&&i&&i.$data;l?(n+=" var schema"+f+" = "+e.util.getData(i.$data,a,e.dataPathArr)+"; ",d="schema"+f):d=i;var p=e.opts.unknownFormats,h=Array.isArray(p);if(l){n+=" var "+(b="format"+f)+" = formats["+d+"]; var "+(m="isObject"+f)+" = typeof "+b+" == 'object' && !("+b+" instanceof RegExp) && "+b+".validate; var "+(y="formatType"+f)+" = "+m+" && "+b+".type || 'string'; if ("+m+") { ",e.async&&(n+=" var async"+f+" = "+b+".async; "),n+=" "+b+" = "+b+".validate; } if ( ",l&&(n+=" ("+d+" !== undefined && typeof "+d+" != 'string') || "),n+=" (","ignore"!=p&&(n+=" ("+d+" && !"+b+" ",h&&(n+=" && self._opts.unknownFormats.indexOf("+d+") == -1 "),n+=") || "),n+=" ("+b+" && "+y+" == '"+r+"' && !(typeof "+b+" == 'function' ? ",e.async?n+=" (async"+f+" ? await "+b+"("+u+") : "+b+"("+u+")) ":n+=" "+b+"("+u+") ",n+=" : "+b+".test("+u+"))))) {"}else{var b;if(!(b=e.formats[i])){if("ignore"==p)return e.logger.warn('unknown format "'+i+'" ignored in schema at path "'+e.errSchemaPath+'"'),c&&(n+=" if (true) { "),n;if(h&&p.indexOf(i)>=0)return c&&(n+=" if (true) { "),n;throw new Error('unknown format "'+i+'" is used in schema at path "'+e.errSchemaPath+'"')}var m,y=(m="object"==typeof b&&!(b instanceof RegExp)&&b.validate)&&b.type||"string";if(m){var g=!0===b.async;b=b.validate}if(y!=r)return c&&(n+=" if (true) { "),n;if(g){if(!e.async)throw new Error("async format in sync schema");n+=" if (!(await "+(v="formats"+e.util.getProperty(i)+".validate")+"("+u+"))) { "}else{n+=" if (! ";var v="formats"+e.util.getProperty(i);m&&(v+=".validate"),n+="function"==typeof b?" "+v+"("+u+") ":" "+v+".test("+u+") ",n+=") { "}}var _=_||[];_.push(n),n="",!1!==e.createErrors?(n+=" { keyword: 'format' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(s)+" , params: { format: ",n+=l?""+d:""+e.util.toQuotedString(i),n+=" } ",!1!==e.opts.messages&&(n+=" , message: 'should match format \"",n+=l?"' + "+d+" + '":""+e.util.escapeQuotes(i),n+="\"' "),e.opts.verbose&&(n+=" , schema: ",n+=l?"validate.schema"+o:""+e.util.toQuotedString(i),n+=" , parentSchema: validate.schema"+e.schemaPath+" , data: "+u+" "),n+=" } "):n+=" {} ";var w=n;return n=_.pop(),!e.compositeRule&&c?e.async?n+=" throw new ValidationError(["+w+"]); ":n+=" validate.errors = ["+w+"]; return false; ":n+=" var err = "+w+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",n+=" } ",c&&(n+=" else { "),n}},function(e,t,r){"use strict";e.exports=function(e,t,r){var n=" ",f=e.level,a=e.dataLevel,i=e.schema[t],o=e.schemaPath+e.util.getProperty(t),s=e.errSchemaPath+"/"+t,c=!e.opts.allErrors,u="data"+(a||""),d="valid"+f,l="errs__"+f,p=e.util.copy(e);p.level++;var h="valid"+p.level,b=e.schema.then,m=e.schema.else,y=void 0!==b&&(e.opts.strictKeywords?"object"==typeof b&&Object.keys(b).length>0:e.util.schemaHasRules(b,e.RULES.all)),g=void 0!==m&&(e.opts.strictKeywords?"object"==typeof m&&Object.keys(m).length>0:e.util.schemaHasRules(m,e.RULES.all)),v=p.baseId;if(y||g){var _;p.createErrors=!1,p.schema=i,p.schemaPath=o,p.errSchemaPath=s,n+=" var "+l+" = errors; var "+d+" = true; ";var w=e.compositeRule;e.compositeRule=p.compositeRule=!0,n+=" "+e.validate(p)+" ",p.baseId=v,p.createErrors=!0,n+=" errors = "+l+"; if (vErrors !== null) { if ("+l+") vErrors.length = "+l+"; else vErrors = null; } ",e.compositeRule=p.compositeRule=w,y?(n+=" if ("+h+") { ",p.schema=e.schema.then,p.schemaPath=e.schemaPath+".then",p.errSchemaPath=e.errSchemaPath+"/then",n+=" "+e.validate(p)+" ",p.baseId=v,n+=" "+d+" = "+h+"; ",y&&g?n+=" var "+(_="ifClause"+f)+" = 'then'; ":_="'then'",n+=" } ",g&&(n+=" else { ")):n+=" if (!"+h+") { ",g&&(p.schema=e.schema.else,p.schemaPath=e.schemaPath+".else",p.errSchemaPath=e.errSchemaPath+"/else",n+=" "+e.validate(p)+" ",p.baseId=v,n+=" "+d+" = "+h+"; ",y&&g?n+=" var "+(_="ifClause"+f)+" = 'else'; ":_="'else'",n+=" } "),n+=" if (!"+d+") { var err = ",!1!==e.createErrors?(n+=" { keyword: 'if' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(s)+" , params: { failingKeyword: "+_+" } ",!1!==e.opts.messages&&(n+=" , message: 'should match \"' + "+_+" + '\" schema' "),e.opts.verbose&&(n+=" , schema: validate.schema"+o+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+u+" "),n+=" } "):n+=" {} ",n+="; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",!e.compositeRule&&c&&(e.async?n+=" throw new ValidationError(vErrors); ":n+=" validate.errors = vErrors; return false; "),n+=" } ",c&&(n+=" else { ")}else c&&(n+=" if (true) { ");return n}},function(e,t,r){"use strict";e.exports=function(e,t,r){var n=" ",f=e.level,a=e.dataLevel,i=e.schema[t],o=e.schemaPath+e.util.getProperty(t),s=e.errSchemaPath+"/"+t,c=!e.opts.allErrors,u="data"+(a||""),d="valid"+f,l="errs__"+f,p=e.util.copy(e),h="";p.level++;var b="valid"+p.level,m="i"+f,y=p.dataLevel=e.dataLevel+1,g="data"+y,v=e.baseId;if(n+="var "+l+" = errors;var "+d+";",Array.isArray(i)){var _=e.schema.additionalItems;if(!1===_){n+=" "+d+" = "+u+".length <= "+i.length+"; ";var w=s;s=e.errSchemaPath+"/additionalItems",n+=" if (!"+d+") { ";var E=E||[];E.push(n),n="",!1!==e.createErrors?(n+=" { keyword: 'additionalItems' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(s)+" , params: { limit: "+i.length+" } ",!1!==e.opts.messages&&(n+=" , message: 'should NOT have more than "+i.length+" items' "),e.opts.verbose&&(n+=" , schema: false , parentSchema: validate.schema"+e.schemaPath+" , data: "+u+" "),n+=" } "):n+=" {} ";var A=n;n=E.pop(),!e.compositeRule&&c?e.async?n+=" throw new ValidationError(["+A+"]); ":n+=" validate.errors = ["+A+"]; return false; ":n+=" var err = "+A+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",n+=" } ",s=w,c&&(h+="}",n+=" else { ")}var T=i;if(T)for(var x,k=-1,S=T.length-1;k<S;)if(x=T[k+=1],e.opts.strictKeywords?"object"==typeof x&&Object.keys(x).length>0:e.util.schemaHasRules(x,e.RULES.all)){n+=" "+b+" = true; if ("+u+".length > "+k+") { ";var O=u+"["+k+"]";p.schema=x,p.schemaPath=o+"["+k+"]",p.errSchemaPath=s+"/"+k,p.errorPath=e.util.getPathExpr(e.errorPath,k,e.opts.jsonPointers,!0),p.dataPathArr[y]=k;var C=e.validate(p);p.baseId=v,e.util.varOccurences(C,g)<2?n+=" "+e.util.varReplace(C,g,O)+" ":n+=" var "+g+" = "+O+"; "+C+" ",n+=" } ",c&&(n+=" if ("+b+") { ",h+="}")}if("object"==typeof _&&(e.opts.strictKeywords?"object"==typeof _&&Object.keys(_).length>0:e.util.schemaHasRules(_,e.RULES.all))){p.schema=_,p.schemaPath=e.schemaPath+".additionalItems",p.errSchemaPath=e.errSchemaPath+"/additionalItems",n+=" "+b+" = true; if ("+u+".length > "+i.length+") { for (var "+m+" = "+i.length+"; "+m+" < "+u+".length; "+m+"++) { ",p.errorPath=e.util.getPathExpr(e.errorPath,m,e.opts.jsonPointers,!0);O=u+"["+m+"]";p.dataPathArr[y]=m;C=e.validate(p);p.baseId=v,e.util.varOccurences(C,g)<2?n+=" "+e.util.varReplace(C,g,O)+" ":n+=" var "+g+" = "+O+"; "+C+" ",c&&(n+=" if (!"+b+") break; "),n+=" } } ",c&&(n+=" if ("+b+") { ",h+="}")}}else if(e.opts.strictKeywords?"object"==typeof i&&Object.keys(i).length>0:e.util.schemaHasRules(i,e.RULES.all)){p.schema=i,p.schemaPath=o,p.errSchemaPath=s,n+=" for (var "+m+" = 0; "+m+" < "+u+".length; "+m+"++) { ",p.errorPath=e.util.getPathExpr(e.errorPath,m,e.opts.jsonPointers,!0);O=u+"["+m+"]";p.dataPathArr[y]=m;C=e.validate(p);p.baseId=v,e.util.varOccurences(C,g)<2?n+=" "+e.util.varReplace(C,g,O)+" ":n+=" var "+g+" = "+O+"; "+C+" ",c&&(n+=" if (!"+b+") break; "),n+=" }"}return c&&(n+=" "+h+" if ("+l+" == errors) {"),n}},function(e,t,r){"use strict";e.exports=function(e,t,r){var n,f=" ",a=e.level,i=e.dataLevel,o=e.schema[t],s=e.schemaPath+e.util.getProperty(t),c=e.errSchemaPath+"/"+t,u=!e.opts.allErrors,d="data"+(i||""),l=e.opts.$data&&o&&o.$data;if(l?(f+=" var schema"+a+" = "+e.util.getData(o.$data,i,e.dataPathArr)+"; ",n="schema"+a):n=o,!l&&"number"!=typeof o)throw new Error(t+" must be number");f+="var division"+a+";if (",l&&(f+=" "+n+" !== undefined && ( typeof "+n+" != 'number' || "),f+=" (division"+a+" = "+d+" / "+n+", ",e.opts.multipleOfPrecision?f+=" Math.abs(Math.round(division"+a+") - division"+a+") > 1e-"+e.opts.multipleOfPrecision+" ":f+=" division"+a+" !== parseInt(division"+a+") ",f+=" ) ",l&&(f+=" ) "),f+=" ) { ";var p=p||[];p.push(f),f="",!1!==e.createErrors?(f+=" { keyword: 'multipleOf' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(c)+" , params: { multipleOf: "+n+" } ",!1!==e.opts.messages&&(f+=" , message: 'should be multiple of ",f+=l?"' + "+n:n+"'"),e.opts.verbose&&(f+=" , schema: ",f+=l?"validate.schema"+s:""+o,f+=" , parentSchema: validate.schema"+e.schemaPath+" , data: "+d+" "),f+=" } "):f+=" {} ";var h=f;return f=p.pop(),!e.compositeRule&&u?e.async?f+=" throw new ValidationError(["+h+"]); ":f+=" validate.errors = ["+h+"]; return false; ":f+=" var err = "+h+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",f+="} ",u&&(f+=" else { "),f}},function(e,t,r){"use strict";e.exports=function(e,t,r){var n=" ",f=e.level,a=e.dataLevel,i=e.schema[t],o=e.schemaPath+e.util.getProperty(t),s=e.errSchemaPath+"/"+t,c=!e.opts.allErrors,u="data"+(a||""),d="errs__"+f,l=e.util.copy(e);l.level++;var p="valid"+l.level;if(e.opts.strictKeywords?"object"==typeof i&&Object.keys(i).length>0:e.util.schemaHasRules(i,e.RULES.all)){l.schema=i,l.schemaPath=o,l.errSchemaPath=s,n+=" var "+d+" = errors; ";var h,b=e.compositeRule;e.compositeRule=l.compositeRule=!0,l.createErrors=!1,l.opts.allErrors&&(h=l.opts.allErrors,l.opts.allErrors=!1),n+=" "+e.validate(l)+" ",l.createErrors=!0,h&&(l.opts.allErrors=h),e.compositeRule=l.compositeRule=b,n+=" if ("+p+") { ";var m=m||[];m.push(n),n="",!1!==e.createErrors?(n+=" { keyword: 'not' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(s)+" , params: {} ",!1!==e.opts.messages&&(n+=" , message: 'should NOT be valid' "),e.opts.verbose&&(n+=" , schema: validate.schema"+o+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+u+" "),n+=" } "):n+=" {} ";var y=n;n=m.pop(),!e.compositeRule&&c?e.async?n+=" throw new ValidationError(["+y+"]); ":n+=" validate.errors = ["+y+"]; return false; ":n+=" var err = "+y+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",n+=" } else { errors = "+d+"; if (vErrors !== null) { if ("+d+") vErrors.length = "+d+"; else vErrors = null; } ",e.opts.allErrors&&(n+=" } ")}else n+=" var err = ",!1!==e.createErrors?(n+=" { keyword: 'not' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(s)+" , params: {} ",!1!==e.opts.messages&&(n+=" , message: 'should NOT be valid' "),e.opts.verbose&&(n+=" , schema: validate.schema"+o+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+u+" "),n+=" } "):n+=" {} ",n+="; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",c&&(n+=" if (false) { ");return n}},function(e,t,r){"use strict";e.exports=function(e,t,r){var n=" ",f=e.level,a=e.dataLevel,i=e.schema[t],o=e.schemaPath+e.util.getProperty(t),s=e.errSchemaPath+"/"+t,c=!e.opts.allErrors,u="data"+(a||""),d="valid"+f,l="errs__"+f,p=e.util.copy(e),h="";p.level++;var b="valid"+p.level,m=p.baseId,y="prevValid"+f,g="passingSchemas"+f;n+="var "+l+" = errors , "+y+" = false , "+d+" = false , "+g+" = null; ";var v=e.compositeRule;e.compositeRule=p.compositeRule=!0;var _=i;if(_)for(var w,E=-1,A=_.length-1;E<A;)w=_[E+=1],(e.opts.strictKeywords?"object"==typeof w&&Object.keys(w).length>0:e.util.schemaHasRules(w,e.RULES.all))?(p.schema=w,p.schemaPath=o+"["+E+"]",p.errSchemaPath=s+"/"+E,n+=" "+e.validate(p)+" ",p.baseId=m):n+=" var "+b+" = true; ",E&&(n+=" if ("+b+" && "+y+") { "+d+" = false; "+g+" = ["+g+", "+E+"]; } else { ",h+="}"),n+=" if ("+b+") { "+d+" = "+y+" = true; "+g+" = "+E+"; }";return e.compositeRule=p.compositeRule=v,n+=h+"if (!"+d+") { var err = ",!1!==e.createErrors?(n+=" { keyword: 'oneOf' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(s)+" , params: { passingSchemas: "+g+" } ",!1!==e.opts.messages&&(n+=" , message: 'should match exactly one schema in oneOf' "),e.opts.verbose&&(n+=" , schema: validate.schema"+o+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+u+" "),n+=" } "):n+=" {} ",n+="; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",!e.compositeRule&&c&&(e.async?n+=" throw new ValidationError(vErrors); ":n+=" validate.errors = vErrors; return false; "),n+="} else { errors = "+l+"; if (vErrors !== null) { if ("+l+") vErrors.length = "+l+"; else vErrors = null; }",e.opts.allErrors&&(n+=" } "),n}},function(e,t,r){"use strict";e.exports=function(e,t,r){var n,f=" ",a=e.level,i=e.dataLevel,o=e.schema[t],s=e.schemaPath+e.util.getProperty(t),c=e.errSchemaPath+"/"+t,u=!e.opts.allErrors,d="data"+(i||""),l=e.opts.$data&&o&&o.$data;l?(f+=" var schema"+a+" = "+e.util.getData(o.$data,i,e.dataPathArr)+"; ",n="schema"+a):n=o,f+="if ( ",l&&(f+=" ("+n+" !== undefined && typeof "+n+" != 'string') || "),f+=" !"+(l?"(new RegExp("+n+"))":e.usePattern(o))+".test("+d+") ) { ";var p=p||[];p.push(f),f="",!1!==e.createErrors?(f+=" { keyword: 'pattern' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(c)+" , params: { pattern: ",f+=l?""+n:""+e.util.toQuotedString(o),f+=" } ",!1!==e.opts.messages&&(f+=" , message: 'should match pattern \"",f+=l?"' + "+n+" + '":""+e.util.escapeQuotes(o),f+="\"' "),e.opts.verbose&&(f+=" , schema: ",f+=l?"validate.schema"+s:""+e.util.toQuotedString(o),f+=" , parentSchema: validate.schema"+e.schemaPath+" , data: "+d+" "),f+=" } "):f+=" {} ";var h=f;return f=p.pop(),!e.compositeRule&&u?e.async?f+=" throw new ValidationError(["+h+"]); ":f+=" validate.errors = ["+h+"]; return false; ":f+=" var err = "+h+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",f+="} ",u&&(f+=" else { "),f}},function(e,t,r){"use strict";e.exports=function(e,t,r){var n=" ",f=e.level,a=e.dataLevel,i=e.schema[t],o=e.schemaPath+e.util.getProperty(t),s=e.errSchemaPath+"/"+t,c=!e.opts.allErrors,u="data"+(a||""),d="errs__"+f,l=e.util.copy(e),p="";l.level++;var h="valid"+l.level,b="key"+f,m="idx"+f,y=l.dataLevel=e.dataLevel+1,g="data"+y,v="dataProperties"+f,_=Object.keys(i||{}).filter(I),w=e.schema.patternProperties||{},E=Object.keys(w).filter(I),A=e.schema.additionalProperties,T=_.length||E.length,x=!1===A,k="object"==typeof A&&Object.keys(A).length,S=e.opts.removeAdditional,O=x||k||S,C=e.opts.ownProperties,P=e.baseId,R=e.schema.required;if(R&&(!e.opts.$data||!R.$data)&&R.length<e.opts.loopRequired)var N=e.util.toHash(R);function I(e){return"__proto__"!==e}if(n+="var "+d+" = errors;var "+h+" = true;",C&&(n+=" var "+v+" = undefined;"),O){if(n+=C?" "+v+" = "+v+" || Object.keys("+u+"); for (var "+m+"=0; "+m+"<"+v+".length; "+m+"++) { var "+b+" = "+v+"["+m+"]; ":" for (var "+b+" in "+u+") { ",T){if(n+=" var isAdditional"+f+" = !(false ",_.length)if(_.length>8)n+=" || validate.schema"+o+".hasOwnProperty("+b+") ";else{var M=_;if(M)for(var D=-1,B=M.length-1;D<B;)Y=M[D+=1],n+=" || "+b+" == "+e.util.toQuotedString(Y)+" "}if(E.length){var F=E;if(F)for(var j=-1,L=F.length-1;j<L;)ae=F[j+=1],n+=" || "+e.usePattern(ae)+".test("+b+") "}n+=" ); if (isAdditional"+f+") { "}if("all"==S)n+=" delete "+u+"["+b+"]; ";else{var U=e.errorPath,q="' + "+b+" + '";if(e.opts._errorDataPathProperty&&(e.errorPath=e.util.getPathExpr(e.errorPath,b,e.opts.jsonPointers)),x)if(S)n+=" delete "+u+"["+b+"]; ";else{n+=" "+h+" = false; ";var H=s;s=e.errSchemaPath+"/additionalProperties",(re=re||[]).push(n),n="",!1!==e.createErrors?(n+=" { keyword: 'additionalProperties' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(s)+" , params: { additionalProperty: '"+q+"' } ",!1!==e.opts.messages&&(n+=" , message: '",e.opts._errorDataPathProperty?n+="is an invalid additional property":n+="should NOT have additional properties",n+="' "),e.opts.verbose&&(n+=" , schema: false , parentSchema: validate.schema"+e.schemaPath+" , data: "+u+" "),n+=" } "):n+=" {} ";var $=n;n=re.pop(),!e.compositeRule&&c?e.async?n+=" throw new ValidationError(["+$+"]); ":n+=" validate.errors = ["+$+"]; return false; ":n+=" var err = "+$+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",s=H,c&&(n+=" break; ")}else if(k)if("failing"==S){n+=" var "+d+" = errors; ";var z=e.compositeRule;e.compositeRule=l.compositeRule=!0,l.schema=A,l.schemaPath=e.schemaPath+".additionalProperties",l.errSchemaPath=e.errSchemaPath+"/additionalProperties",l.errorPath=e.opts._errorDataPathProperty?e.errorPath:e.util.getPathExpr(e.errorPath,b,e.opts.jsonPointers);var V=u+"["+b+"]";l.dataPathArr[y]=b;var G=e.validate(l);l.baseId=P,e.util.varOccurences(G,g)<2?n+=" "+e.util.varReplace(G,g,V)+" ":n+=" var "+g+" = "+V+"; "+G+" ",n+=" if (!"+h+") { errors = "+d+"; if (validate.errors !== null) { if (errors) validate.errors.length = errors; else validate.errors = null; } delete "+u+"["+b+"]; } ",e.compositeRule=l.compositeRule=z}else{l.schema=A,l.schemaPath=e.schemaPath+".additionalProperties",l.errSchemaPath=e.errSchemaPath+"/additionalProperties",l.errorPath=e.opts._errorDataPathProperty?e.errorPath:e.util.getPathExpr(e.errorPath,b,e.opts.jsonPointers);V=u+"["+b+"]";l.dataPathArr[y]=b;G=e.validate(l);l.baseId=P,e.util.varOccurences(G,g)<2?n+=" "+e.util.varReplace(G,g,V)+" ":n+=" var "+g+" = "+V+"; "+G+" ",c&&(n+=" if (!"+h+") break; ")}e.errorPath=U}T&&(n+=" } "),n+=" } ",c&&(n+=" if ("+h+") { ",p+="}")}var K=e.opts.useDefaults&&!e.compositeRule;if(_.length){var W=_;if(W)for(var Y,J=-1,X=W.length-1;J<X;){var Z=i[Y=W[J+=1]];if(e.opts.strictKeywords?"object"==typeof Z&&Object.keys(Z).length>0:e.util.schemaHasRules(Z,e.RULES.all)){var Q=e.util.getProperty(Y),ee=(V=u+Q,K&&void 0!==Z.default);l.schema=Z,l.schemaPath=o+Q,l.errSchemaPath=s+"/"+e.util.escapeFragment(Y),l.errorPath=e.util.getPath(e.errorPath,Y,e.opts.jsonPointers),l.dataPathArr[y]=e.util.toQuotedString(Y);G=e.validate(l);if(l.baseId=P,e.util.varOccurences(G,g)<2){G=e.util.varReplace(G,g,V);var te=V}else{te=g;n+=" var "+g+" = "+V+"; "}if(ee)n+=" "+G+" ";else{if(N&&N[Y]){n+=" if ( "+te+" === undefined ",C&&(n+=" || ! Object.prototype.hasOwnProperty.call("+u+", '"+e.util.escapeQuotes(Y)+"') "),n+=") { "+h+" = false; ";U=e.errorPath,H=s;var re,ne=e.util.escapeQuotes(Y);e.opts._errorDataPathProperty&&(e.errorPath=e.util.getPath(U,Y,e.opts.jsonPointers)),s=e.errSchemaPath+"/required",(re=re||[]).push(n),n="",!1!==e.createErrors?(n+=" { keyword: 'required' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(s)+" , params: { missingProperty: '"+ne+"' } ",!1!==e.opts.messages&&(n+=" , message: '",e.opts._errorDataPathProperty?n+="is a required property":n+="should have required property \\'"+ne+"\\'",n+="' "),e.opts.verbose&&(n+=" , schema: validate.schema"+o+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+u+" "),n+=" } "):n+=" {} ";$=n;n=re.pop(),!e.compositeRule&&c?e.async?n+=" throw new ValidationError(["+$+"]); ":n+=" validate.errors = ["+$+"]; return false; ":n+=" var err = "+$+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",s=H,e.errorPath=U,n+=" } else { "}else c?(n+=" if ( "+te+" === undefined ",C&&(n+=" || ! Object.prototype.hasOwnProperty.call("+u+", '"+e.util.escapeQuotes(Y)+"') "),n+=") { "+h+" = true; } else { "):(n+=" if ("+te+" !== undefined ",C&&(n+=" && Object.prototype.hasOwnProperty.call("+u+", '"+e.util.escapeQuotes(Y)+"') "),n+=" ) { ");n+=" "+G+" } "}}c&&(n+=" if ("+h+") { ",p+="}")}}if(E.length){var fe=E;if(fe)for(var ae,ie=-1,oe=fe.length-1;ie<oe;){Z=w[ae=fe[ie+=1]];if(e.opts.strictKeywords?"object"==typeof Z&&Object.keys(Z).length>0:e.util.schemaHasRules(Z,e.RULES.all)){l.schema=Z,l.schemaPath=e.schemaPath+".patternProperties"+e.util.getProperty(ae),l.errSchemaPath=e.errSchemaPath+"/patternProperties/"+e.util.escapeFragment(ae),n+=C?" "+v+" = "+v+" || Object.keys("+u+"); for (var "+m+"=0; "+m+"<"+v+".length; "+m+"++) { var "+b+" = "+v+"["+m+"]; ":" for (var "+b+" in "+u+") { ",n+=" if ("+e.usePattern(ae)+".test("+b+")) { ",l.errorPath=e.util.getPathExpr(e.errorPath,b,e.opts.jsonPointers);V=u+"["+b+"]";l.dataPathArr[y]=b;G=e.validate(l);l.baseId=P,e.util.varOccurences(G,g)<2?n+=" "+e.util.varReplace(G,g,V)+" ":n+=" var "+g+" = "+V+"; "+G+" ",c&&(n+=" if (!"+h+") break; "),n+=" } ",c&&(n+=" else "+h+" = true; "),n+=" } ",c&&(n+=" if ("+h+") { ",p+="}")}}}return c&&(n+=" "+p+" if ("+d+" == errors) {"),n}},function(e,t,r){"use strict";e.exports=function(e,t,r){var n=" ",f=e.level,a=e.dataLevel,i=e.schema[t],o=e.schemaPath+e.util.getProperty(t),s=e.errSchemaPath+"/"+t,c=!e.opts.allErrors,u="data"+(a||""),d="errs__"+f,l=e.util.copy(e);l.level++;var p="valid"+l.level;if(n+="var "+d+" = errors;",e.opts.strictKeywords?"object"==typeof i&&Object.keys(i).length>0:e.util.schemaHasRules(i,e.RULES.all)){l.schema=i,l.schemaPath=o,l.errSchemaPath=s;var h="key"+f,b="idx"+f,m="i"+f,y="' + "+h+" + '",g="data"+(l.dataLevel=e.dataLevel+1),v="dataProperties"+f,_=e.opts.ownProperties,w=e.baseId;_&&(n+=" var "+v+" = undefined; "),n+=_?" "+v+" = "+v+" || Object.keys("+u+"); for (var "+b+"=0; "+b+"<"+v+".length; "+b+"++) { var "+h+" = "+v+"["+b+"]; ":" for (var "+h+" in "+u+") { ",n+=" var startErrs"+f+" = errors; ";var E=h,A=e.compositeRule;e.compositeRule=l.compositeRule=!0;var T=e.validate(l);l.baseId=w,e.util.varOccurences(T,g)<2?n+=" "+e.util.varReplace(T,g,E)+" ":n+=" var "+g+" = "+E+"; "+T+" ",e.compositeRule=l.compositeRule=A,n+=" if (!"+p+") { for (var "+m+"=startErrs"+f+"; "+m+"<errors; "+m+"++) { vErrors["+m+"].propertyName = "+h+"; } var err = ",!1!==e.createErrors?(n+=" { keyword: 'propertyNames' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(s)+" , params: { propertyName: '"+y+"' } ",!1!==e.opts.messages&&(n+=" , message: 'property name \\'"+y+"\\' is invalid' "),e.opts.verbose&&(n+=" , schema: validate.schema"+o+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+u+" "),n+=" } "):n+=" {} ",n+="; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",!e.compositeRule&&c&&(e.async?n+=" throw new ValidationError(vErrors); ":n+=" validate.errors = vErrors; return false; "),c&&(n+=" break; "),n+=" } }"}return c&&(n+=" if ("+d+" == errors) {"),n}},function(e,t,r){"use strict";e.exports=function(e,t,r){var n=" ",f=e.level,a=e.dataLevel,i=e.schema[t],o=e.schemaPath+e.util.getProperty(t),s=e.errSchemaPath+"/"+t,c=!e.opts.allErrors,u="data"+(a||""),d="valid"+f,l=e.opts.$data&&i&&i.$data;l&&(n+=" var schema"+f+" = "+e.util.getData(i.$data,a,e.dataPathArr)+"; ");var p="schema"+f;if(!l)if(i.length<e.opts.loopRequired&&e.schema.properties&&Object.keys(e.schema.properties).length){var h=[],b=i;if(b)for(var m,y=-1,g=b.length-1;y<g;){m=b[y+=1];var v=e.schema.properties[m];v&&(e.opts.strictKeywords?"object"==typeof v&&Object.keys(v).length>0:e.util.schemaHasRules(v,e.RULES.all))||(h[h.length]=m)}}else h=i;if(l||h.length){var _=e.errorPath,w=l||h.length>=e.opts.loopRequired,E=e.opts.ownProperties;if(c)if(n+=" var missing"+f+"; ",w){l||(n+=" var "+p+" = validate.schema"+o+"; ");var A="' + "+(C="schema"+f+"["+(k="i"+f)+"]")+" + '";e.opts._errorDataPathProperty&&(e.errorPath=e.util.getPathExpr(_,C,e.opts.jsonPointers)),n+=" var "+d+" = true; ",l&&(n+=" if (schema"+f+" === undefined) "+d+" = true; else if (!Array.isArray(schema"+f+")) "+d+" = false; else {"),n+=" for (var "+k+" = 0; "+k+" < "+p+".length; "+k+"++) { "+d+" = "+u+"["+p+"["+k+"]] !== undefined ",E&&(n+=" && Object.prototype.hasOwnProperty.call("+u+", "+p+"["+k+"]) "),n+="; if (!"+d+") break; } ",l&&(n+=" } "),n+=" if (!"+d+") { ",(O=O||[]).push(n),n="",!1!==e.createErrors?(n+=" { keyword: 'required' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(s)+" , params: { missingProperty: '"+A+"' } ",!1!==e.opts.messages&&(n+=" , message: '",e.opts._errorDataPathProperty?n+="is a required property":n+="should have required property \\'"+A+"\\'",n+="' "),e.opts.verbose&&(n+=" , schema: validate.schema"+o+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+u+" "),n+=" } "):n+=" {} ";var T=n;n=O.pop(),!e.compositeRule&&c?e.async?n+=" throw new ValidationError(["+T+"]); ":n+=" validate.errors = ["+T+"]; return false; ":n+=" var err = "+T+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",n+=" } else { "}else{n+=" if ( ";var x=h;if(x)for(var k=-1,S=x.length-1;k<S;){R=x[k+=1],k&&(n+=" || "),n+=" ( ( "+(D=u+(M=e.util.getProperty(R)))+" === undefined ",E&&(n+=" || ! Object.prototype.hasOwnProperty.call("+u+", '"+e.util.escapeQuotes(R)+"') "),n+=") && (missing"+f+" = "+e.util.toQuotedString(e.opts.jsonPointers?R:M)+") ) "}n+=") { ";var O;A="' + "+(C="missing"+f)+" + '";e.opts._errorDataPathProperty&&(e.errorPath=e.opts.jsonPointers?e.util.getPathExpr(_,C,!0):_+" + "+C),(O=O||[]).push(n),n="",!1!==e.createErrors?(n+=" { keyword: 'required' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(s)+" , params: { missingProperty: '"+A+"' } ",!1!==e.opts.messages&&(n+=" , message: '",e.opts._errorDataPathProperty?n+="is a required property":n+="should have required property \\'"+A+"\\'",n+="' "),e.opts.verbose&&(n+=" , schema: validate.schema"+o+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+u+" "),n+=" } "):n+=" {} ";T=n;n=O.pop(),!e.compositeRule&&c?e.async?n+=" throw new ValidationError(["+T+"]); ":n+=" validate.errors = ["+T+"]; return false; ":n+=" var err = "+T+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",n+=" } else { "}else if(w){l||(n+=" var "+p+" = validate.schema"+o+"; ");var C;A="' + "+(C="schema"+f+"["+(k="i"+f)+"]")+" + '";e.opts._errorDataPathProperty&&(e.errorPath=e.util.getPathExpr(_,C,e.opts.jsonPointers)),l&&(n+=" if ("+p+" && !Array.isArray("+p+")) { var err = ",!1!==e.createErrors?(n+=" { keyword: 'required' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(s)+" , params: { missingProperty: '"+A+"' } ",!1!==e.opts.messages&&(n+=" , message: '",e.opts._errorDataPathProperty?n+="is a required property":n+="should have required property \\'"+A+"\\'",n+="' "),e.opts.verbose&&(n+=" , schema: validate.schema"+o+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+u+" "),n+=" } "):n+=" {} ",n+="; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; } else if ("+p+" !== undefined) { "),n+=" for (var "+k+" = 0; "+k+" < "+p+".length; "+k+"++) { if ("+u+"["+p+"["+k+"]] === undefined ",E&&(n+=" || ! Object.prototype.hasOwnProperty.call("+u+", "+p+"["+k+"]) "),n+=") { var err = ",!1!==e.createErrors?(n+=" { keyword: 'required' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(s)+" , params: { missingProperty: '"+A+"' } ",!1!==e.opts.messages&&(n+=" , message: '",e.opts._errorDataPathProperty?n+="is a required property":n+="should have required property \\'"+A+"\\'",n+="' "),e.opts.verbose&&(n+=" , schema: validate.schema"+o+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+u+" "),n+=" } "):n+=" {} ",n+="; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; } } ",l&&(n+=" } ")}else{var P=h;if(P)for(var R,N=-1,I=P.length-1;N<I;){R=P[N+=1];var M=e.util.getProperty(R),D=(A=e.util.escapeQuotes(R),u+M);e.opts._errorDataPathProperty&&(e.errorPath=e.util.getPath(_,R,e.opts.jsonPointers)),n+=" if ( "+D+" === undefined ",E&&(n+=" || ! Object.prototype.hasOwnProperty.call("+u+", '"+e.util.escapeQuotes(R)+"') "),n+=") { var err = ",!1!==e.createErrors?(n+=" { keyword: 'required' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(s)+" , params: { missingProperty: '"+A+"' } ",!1!==e.opts.messages&&(n+=" , message: '",e.opts._errorDataPathProperty?n+="is a required property":n+="should have required property \\'"+A+"\\'",n+="' "),e.opts.verbose&&(n+=" , schema: validate.schema"+o+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+u+" "),n+=" } "):n+=" {} ",n+="; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; } "}}e.errorPath=_}else c&&(n+=" if (true) {");return n}},function(e,t,r){"use strict";e.exports=function(e,t,r){var n,f=" ",a=e.level,i=e.dataLevel,o=e.schema[t],s=e.schemaPath+e.util.getProperty(t),c=e.errSchemaPath+"/"+t,u=!e.opts.allErrors,d="data"+(i||""),l="valid"+a,p=e.opts.$data&&o&&o.$data;if(p?(f+=" var schema"+a+" = "+e.util.getData(o.$data,i,e.dataPathArr)+"; ",n="schema"+a):n=o,(o||p)&&!1!==e.opts.uniqueItems){p&&(f+=" var "+l+"; if ("+n+" === false || "+n+" === undefined) "+l+" = true; else if (typeof "+n+" != 'boolean') "+l+" = false; else { "),f+=" var i = "+d+".length , "+l+" = true , j; if (i > 1) { ";var h=e.schema.items&&e.schema.items.type,b=Array.isArray(h);if(!h||"object"==h||"array"==h||b&&(h.indexOf("object")>=0||h.indexOf("array")>=0))f+=" outer: for (;i--;) { for (j = i; j--;) { if (equal("+d+"[i], "+d+"[j])) { "+l+" = false; break outer; } } } ";else{f+=" var itemIndices = {}, item; for (;i--;) { var item = "+d+"[i]; ";var m="checkDataType"+(b?"s":"");f+=" if ("+e.util[m](h,"item",e.opts.strictNumbers,!0)+") continue; ",b&&(f+=" if (typeof item == 'string') item = '\"' + item; "),f+=" if (typeof itemIndices[item] == 'number') { "+l+" = false; j = itemIndices[item]; break; } itemIndices[item] = i; } "}f+=" } ",p&&(f+=" } "),f+=" if (!"+l+") { ";var y=y||[];y.push(f),f="",!1!==e.createErrors?(f+=" { keyword: 'uniqueItems' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(c)+" , params: { i: i, j: j } ",!1!==e.opts.messages&&(f+=" , message: 'should NOT have duplicate items (items ## ' + j + ' and ' + i + ' are identical)' "),e.opts.verbose&&(f+=" , schema: ",f+=p?"validate.schema"+s:""+o,f+=" , parentSchema: validate.schema"+e.schemaPath+" , data: "+d+" "),f+=" } "):f+=" {} ";var g=f;f=y.pop(),!e.compositeRule&&u?e.async?f+=" throw new ValidationError(["+g+"]); ":f+=" validate.errors = ["+g+"]; return false; ":f+=" var err = "+g+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",f+=" } ",u&&(f+=" else { ")}else u&&(f+=" if (true) { ");return f}},function(e,t,r){"use strict";var n=["multipleOf","maximum","exclusiveMaximum","minimum","exclusiveMinimum","maxLength","minLength","pattern","additionalItems","maxItems","minItems","uniqueItems","maxProperties","minProperties","required","additionalProperties","enum","format","const"];e.exports=function(e,t){for(var r=0;r<t.length;r++){e=JSON.parse(JSON.stringify(e));var f,a=t[r].split("/"),i=e;for(f=1;f<a.length;f++)i=i[a[f]];for(f=0;f<n.length;f++){var o=n[f],s=i[o];s&&(i[o]={anyOf:[s,{$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"}]})}}return e}},function(e,t,r){"use strict";var n=r(177).MissingRef;e.exports=function e(t,r,f){var a=this;if("function"!=typeof this._opts.loadSchema)throw new Error("options.loadSchema should be a function");"function"==typeof r&&(f=r,r=void 0);var i=o(t).then((function(){var e=a._addSchema(t,void 0,r);return e.validate||s(e)}));f&&i.then((function(e){f(null,e)}),f);return i;function o(t){var r=t.$schema;return r&&!a.getSchema(r)?e.call(a,{$ref:r},!0):Promise.resolve()}function s(e){try{return a._compile(e)}catch(t){if(t instanceof n)return function(t){var n=t.missingSchema;if(c(n))throw new Error("Schema "+n+" is loaded but "+t.missingRef+" cannot be resolved");var f=a._loadingSchemas[n];f||(f=a._loadingSchemas[n]=a._opts.loadSchema(n)).then(i,i);return f.then((function(e){if(!c(n))return o(e).then((function(){c(n)||a.addSchema(e,n,void 0,r)}))})).then((function(){return s(e)}));function i(){delete a._loadingSchemas[n]}function c(e){return a._refs[e]||a._schemas[e]}}(t);throw t}}}},function(e,t,r){"use strict";var n=/^[a-z_$][a-z0-9_$-]*$/i,f=r(827),a=r(828);e.exports={add:function(e,t){var r=this.RULES;if(r.keywords[e])throw new Error("Keyword "+e+" is already defined");if(!n.test(e))throw new Error("Keyword "+e+" is not a valid identifier");if(t){this.validateKeyword(t,!0);var a=t.type;if(Array.isArray(a))for(var i=0;i<a.length;i++)s(e,a[i],t);else s(e,a,t);var o=t.metaSchema;o&&(t.$data&&this._opts.$data&&(o={anyOf:[o,{$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"}]}),t.validateSchema=this.compile(o,!0))}function s(e,t,n){for(var a,i=0;i<r.length;i++){var o=r[i];if(o.type==t){a=o;break}}a||(a={type:t,rules:[]},r.push(a));var s={keyword:e,definition:n,custom:!0,code:f,implements:n.implements};a.rules.push(s),r.custom[e]=s}return r.keywords[e]=r.all[e]=!0,this},get:function(e){var t=this.RULES.custom[e];return t?t.definition:this.RULES.keywords[e]||!1},remove:function(e){var t=this.RULES;delete t.keywords[e],delete t.all[e],delete t.custom[e];for(var r=0;r<t.length;r++)for(var n=t[r].rules,f=0;f<n.length;f++)if(n[f].keyword==e){n.splice(f,1);break}return this},validate:function e(t,r){e.errors=null;var n=this._validateKeyword=this._validateKeyword||this.compile(a,!0);if(n(t))return!0;if(e.errors=n.errors,r)throw new Error("custom keyword definition is invalid: "+this.errorsText(n.errors));return!1}}},function(e,t,r){"use strict";e.exports=function(e,t,r){var n,f,a=" ",i=e.level,o=e.dataLevel,s=e.schema[t],c=e.schemaPath+e.util.getProperty(t),u=e.errSchemaPath+"/"+t,d=!e.opts.allErrors,l="data"+(o||""),p="valid"+i,h="errs__"+i,b=e.opts.$data&&s&&s.$data;b?(a+=" var schema"+i+" = "+e.util.getData(s.$data,o,e.dataPathArr)+"; ",f="schema"+i):f=s;var m,y,g,v,_,w=this,E="definition"+i,A=w.definition,T="";if(b&&A.$data){_="keywordValidate"+i;var x=A.validateSchema;a+=" var "+E+" = RULES.custom['"+t+"'].definition; var "+_+" = "+E+".validate;"}else{if(!(v=e.useCustomRule(w,s,e.schema,e)))return;f="validate.schema"+c,_=v.code,m=A.compile,y=A.inline,g=A.macro}var k=_+".errors",S="i"+i,O="ruleErr"+i,C=A.async;if(C&&!e.async)throw new Error("async keyword in sync schema");if(y||g||(a+=k+" = null;"),a+="var "+h+" = errors;var "+p+";",b&&A.$data&&(T+="}",a+=" if ("+f+" === undefined) { "+p+" = true; } else { ",x&&(T+="}",a+=" "+p+" = "+E+".validateSchema("+f+"); if ("+p+") { ")),y)A.statements?a+=" "+v.validate+" ":a+=" "+p+" = "+v.validate+"; ";else if(g){var P=e.util.copy(e);T="";P.level++;var R="valid"+P.level;P.schema=v.validate,P.schemaPath="";var N=e.compositeRule;e.compositeRule=P.compositeRule=!0;var I=e.validate(P).replace(/validate\.schema/g,_);e.compositeRule=P.compositeRule=N,a+=" "+I}else{(F=F||[]).push(a),a="",a+=" "+_+".call( ",e.opts.passContext?a+="this":a+="self",m||!1===A.schema?a+=" , "+l+" ":a+=" , "+f+" , "+l+" , validate.schema"+e.schemaPath+" ",a+=" , (dataPath || '')",'""'!=e.errorPath&&(a+=" + "+e.errorPath);var M=o?"data"+(o-1||""):"parentData",D=o?e.dataPathArr[o]:"parentDataProperty",B=a+=" , "+M+" , "+D+" , rootData ) ";a=F.pop(),!1===A.errors?(a+=" "+p+" = ",C&&(a+="await "),a+=B+"; "):a+=C?" var "+(k="customErrors"+i)+" = null; try { "+p+" = await "+B+"; } catch (e) { "+p+" = false; if (e instanceof ValidationError) "+k+" = e.errors; else throw e; } ":" "+k+" = null; "+p+" = "+B+"; "}if(A.modifying&&(a+=" if ("+M+") "+l+" = "+M+"["+D+"];"),a+=""+T,A.valid)d&&(a+=" if (true) { ");else{var F;a+=" if ( ",void 0===A.valid?(a+=" !",a+=g?""+R:""+p):a+=" "+!A.valid+" ",a+=") { ",n=w.keyword,(F=F||[]).push(a),a="",(F=F||[]).push(a),a="",!1!==e.createErrors?(a+=" { keyword: '"+(n||"custom")+"' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(u)+" , params: { keyword: '"+w.keyword+"' } ",!1!==e.opts.messages&&(a+=" , message: 'should pass \""+w.keyword+"\" keyword validation' "),e.opts.verbose&&(a+=" , schema: validate.schema"+c+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+l+" "),a+=" } "):a+=" {} ";var j=a;a=F.pop(),!e.compositeRule&&d?e.async?a+=" throw new ValidationError(["+j+"]); ":a+=" validate.errors = ["+j+"]; return false; ":a+=" var err = "+j+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ";var L=a;a=F.pop(),y?A.errors?"full"!=A.errors&&(a+=" for (var "+S+"="+h+"; "+S+"<errors; "+S+"++) { var "+O+" = vErrors["+S+"]; if ("+O+".dataPath === undefined) "+O+".dataPath = (dataPath || '') + "+e.errorPath+"; if ("+O+".schemaPath === undefined) { "+O+'.schemaPath = "'+u+'"; } ',e.opts.verbose&&(a+=" "+O+".schema = "+f+"; "+O+".data = "+l+"; "),a+=" } "):!1===A.errors?a+=" "+L+" ":(a+=" if ("+h+" == errors) { "+L+" } else { for (var "+S+"="+h+"; "+S+"<errors; "+S+"++) { var "+O+" = vErrors["+S+"]; if ("+O+".dataPath === undefined) "+O+".dataPath = (dataPath || '') + "+e.errorPath+"; if ("+O+".schemaPath === undefined) { "+O+'.schemaPath = "'+u+'"; } ',e.opts.verbose&&(a+=" "+O+".schema = "+f+"; "+O+".data = "+l+"; "),a+=" } } "):g?(a+=" var err = ",!1!==e.createErrors?(a+=" { keyword: '"+(n||"custom")+"' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(u)+" , params: { keyword: '"+w.keyword+"' } ",!1!==e.opts.messages&&(a+=" , message: 'should pass \""+w.keyword+"\" keyword validation' "),e.opts.verbose&&(a+=" , schema: validate.schema"+c+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+l+" "),a+=" } "):a+=" {} ",a+="; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",!e.compositeRule&&d&&(e.async?a+=" throw new ValidationError(vErrors); ":a+=" validate.errors = vErrors; return false; ")):!1===A.errors?a+=" "+L+" ":(a+=" if (Array.isArray("+k+")) { if (vErrors === null) vErrors = "+k+"; else vErrors = vErrors.concat("+k+"); errors = vErrors.length; for (var "+S+"="+h+"; "+S+"<errors; "+S+"++) { var "+O+" = vErrors["+S+"]; if ("+O+".dataPath === undefined) "+O+".dataPath = (dataPath || '') + "+e.errorPath+"; "+O+'.schemaPath = "'+u+'"; ',e.opts.verbose&&(a+=" "+O+".schema = "+f+"; "+O+".data = "+l+"; "),a+=" } } else { "+L+" } "),a+=" } ",d&&(a+=" else { ")}return a}},function(e,t,r){"use strict";var n=r(324);e.exports={$id:"https://github.com/ajv-validator/ajv/blob/master/lib/definition_schema.js",definitions:{simpleTypes:n.definitions.simpleTypes},type:"object",dependencies:{schema:["validate"],$data:["validate"],statements:["inline"],valid:{not:{required:["macro"]}}},properties:{type:n.properties.type,schema:{type:"boolean"},statements:{type:"boolean"},dependencies:{type:"array",items:{type:"string"}},metaSchema:{type:"object"},modifying:{type:"boolean"},valid:{type:"boolean"},$data:{type:"boolean"},async:{type:"boolean"},errors:{anyOf:[{type:"boolean"},{const:"full"}]}}}},function(e){e.exports=JSON.parse('{"$schema":"http://json-schema.org/draft-07/schema#","$id":"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#","description":"Meta-schema for $data reference (JSON Schema extension proposal)","type":"object","required":["$data"],"properties":{"$data":{"type":"string","anyOf":[{"format":"relative-json-pointer"},{"format":"json-pointer"}]}},"additionalProperties":false}')},function(e){e.exports=JSON.parse('{"$schema":"http://json-schema.org/draft-06/schema#","$id":"http://json-schema.org/draft-06/schema#","title":"Core schema meta-schema","definitions":{"schemaArray":{"type":"array","minItems":1,"items":{"$ref":"#"}},"nonNegativeInteger":{"type":"integer","minimum":0},"nonNegativeIntegerDefault0":{"allOf":[{"$ref":"#/definitions/nonNegativeInteger"},{"default":0}]},"simpleTypes":{"enum":["array","boolean","integer","null","number","object","string"]},"stringArray":{"type":"array","items":{"type":"string"},"uniqueItems":true,"default":[]}},"type":["object","boolean"],"properties":{"$id":{"type":"string","format":"uri-reference"},"$schema":{"type":"string","format":"uri"},"$ref":{"type":"string","format":"uri-reference"},"title":{"type":"string"},"description":{"type":"string"},"default":{},"examples":{"type":"array","items":{}},"multipleOf":{"type":"number","exclusiveMinimum":0},"maximum":{"type":"number"},"exclusiveMaximum":{"type":"number"},"minimum":{"type":"number"},"exclusiveMinimum":{"type":"number"},"maxLength":{"$ref":"#/definitions/nonNegativeInteger"},"minLength":{"$ref":"#/definitions/nonNegativeIntegerDefault0"},"pattern":{"type":"string","format":"regex"},"additionalItems":{"$ref":"#"},"items":{"anyOf":[{"$ref":"#"},{"$ref":"#/definitions/schemaArray"}],"default":{}},"maxItems":{"$ref":"#/definitions/nonNegativeInteger"},"minItems":{"$ref":"#/definitions/nonNegativeIntegerDefault0"},"uniqueItems":{"type":"boolean","default":false},"contains":{"$ref":"#"},"maxProperties":{"$ref":"#/definitions/nonNegativeInteger"},"minProperties":{"$ref":"#/definitions/nonNegativeIntegerDefault0"},"required":{"$ref":"#/definitions/stringArray"},"additionalProperties":{"$ref":"#"},"definitions":{"type":"object","additionalProperties":{"$ref":"#"},"default":{}},"properties":{"type":"object","additionalProperties":{"$ref":"#"},"default":{}},"patternProperties":{"type":"object","additionalProperties":{"$ref":"#"},"default":{}},"dependencies":{"type":"object","additionalProperties":{"anyOf":[{"$ref":"#"},{"$ref":"#/definitions/stringArray"}]}},"propertyNames":{"$ref":"#"},"const":{},"enum":{"type":"array","minItems":1,"uniqueItems":true},"type":{"anyOf":[{"$ref":"#/definitions/simpleTypes"},{"type":"array","items":{"$ref":"#/definitions/simpleTypes"},"minItems":1,"uniqueItems":true}]},"format":{"type":"string"},"allOf":{"$ref":"#/definitions/schemaArray"},"anyOf":{"$ref":"#/definitions/schemaArray"},"oneOf":{"$ref":"#/definitions/schemaArray"},"not":{"$ref":"#"}},"default":{}}')},function(e){e.exports=JSON.parse('{"$id":"http://json-schema.org/address","$schema":"http://json-schema.org/draft-06/schema#","description":"An Address following the convention of http://microformats.org/wiki/hcard","type":"object","properties":{"post-office-box":{"type":"string"},"extended-address":{"type":"string"},"street-address":{"type":"string"},"locality":{"type":"string"},"region":{"type":"string"},"postal-code":{"type":"string"},"country-name":{"type":"string"}},"dependencies":{"post-office-box":["street-address"],"extended-address":["street-address"]}}')},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n={rnf_invoice:{"0.0.1":r(833),"0.0.2":r(834),"0.0.3":r(835)}};t.default=n},function(e){e.exports=JSON.parse('{"$schema":"http://json-schema.org/draft-07/schema#","description":"Request Network Format of an invoice","type":"object","additionalProperties":false,"required":["meta","invoiceNumber","creationDate","invoiceItems"],"properties":{"meta":{"description":"Meta information about the format","type":"object","additionalProperties":false,"required":["format","version"],"properties":{"format":{"const":"rnf_invoice"},"version":{"const":"0.0.1"}}},"creationDate":{"type":"string","format":"date-time"},"invoiceNumber":{"type":"string"},"purchaseOrderId":{"type":"string"},"note":{"type":"string"},"terms":{"type":"string"},"sellerInfo":{"description":"Seller information","type":"object","additionalProperties":false,"properties":{"email":{"type":"string","format":"email"},"firstName":{"type":"string"},"lastName":{"type":"string"},"businessName":{"type":"string"},"phone":{"type":"string"},"address":{"$ref":"http://json-schema.org/address"},"taxRegistration":{"type":"string"},"companyRegistration":{"type":"string"},"miscellaneous":{"type":"object"}}},"buyerInfo":{"description":"Buyer information","type":"object","additionalProperties":false,"properties":{"email":{"type":"string","format":"email"},"firstName":{"type":"string"},"lastName":{"type":"string"},"businessName":{"type":"string"},"phone":{"type":"string"},"address":{"$ref":"http://json-schema.org/address"},"taxRegistration":{"type":"string"},"miscellaneous":{"type":"object"}}},"invoiceItems":{"type":"array","items":{"type":"object","additionalProperties":false,"required":["name","quantity","unitPrice","taxPercent","currency"],"properties":{"name":{"type":"string"},"reference":{"type":"string"},"quantity":{"type":"number","minimum":0},"unitPrice":{"type":"number","minimum":0},"discount":{"type":"number"},"taxPercent":{"type":"number"},"currency":{"type":"string","minLength":2},"deliveryDate":{"type":"string","format":"date-time"},"deliveryPeriod":{"type":"string"}}}},"paymentTerms":{"description":"Payment terms","type":"object","additionalProperties":false,"properties":{"dueDate":{"type":"string","format":"date-time"},"lateFeesPercent":{"type":"number"},"lateFeesFix":{"type":"number"},"miscellaneous":{"type":"object"}}},"miscellaneous":{"type":"object"}}}')},function(e){e.exports=JSON.parse('{"$schema":"http://json-schema.org/draft-07/schema#","description":"Request Network Format of an invoice","type":"object","additionalProperties":false,"required":["meta","invoiceNumber","creationDate","invoiceItems"],"properties":{"meta":{"description":"Meta information about the format","type":"object","additionalProperties":false,"required":["format","version"],"properties":{"format":{"const":"rnf_invoice"},"version":{"const":"0.0.2"}}},"creationDate":{"type":"string","format":"date-time"},"invoiceNumber":{"type":"string"},"purchaseOrderId":{"type":"string"},"note":{"type":"string"},"terms":{"type":"string"},"sellerInfo":{"description":"Seller information","type":"object","additionalProperties":false,"properties":{"email":{"type":"string","format":"email"},"firstName":{"type":"string"},"lastName":{"type":"string"},"businessName":{"type":"string"},"phone":{"type":"string"},"address":{"$ref":"http://json-schema.org/address"},"taxRegistration":{"type":"string"},"companyRegistration":{"type":"string"},"miscellaneous":{"type":"object"}}},"buyerInfo":{"description":"Buyer information","type":"object","additionalProperties":false,"properties":{"email":{"type":"string","format":"email"},"firstName":{"type":"string"},"lastName":{"type":"string"},"businessName":{"type":"string"},"phone":{"type":"string"},"address":{"$ref":"http://json-schema.org/address"},"taxRegistration":{"type":"string"},"companyRegistration":{"type":"string"},"miscellaneous":{"type":"object"}}},"invoiceItems":{"type":"array","items":{"type":"object","additionalProperties":false,"required":["name","quantity","unitPrice","taxPercent","currency"],"properties":{"name":{"type":"string"},"reference":{"type":"string"},"quantity":{"type":"number","minimum":0},"unitPrice":{"type":"string","pattern":"^\\\\d+$"},"discount":{"type":"string","pattern":"^\\\\d+$"},"taxPercent":{"type":"number"},"currency":{"type":"string","minLength":2},"deliveryDate":{"type":"string","format":"date-time"},"deliveryPeriod":{"type":"string"}}}},"paymentTerms":{"description":"Payment terms","type":"object","additionalProperties":false,"properties":{"dueDate":{"type":"string","format":"date-time"},"lateFeesPercent":{"type":"number"},"lateFeesFix":{"type":"string","pattern":"^\\\\d+$"},"miscellaneous":{"type":"object"}}},"miscellaneous":{"type":"object"}}}')},function(e){e.exports=JSON.parse('{"$schema":"http://json-schema.org/draft-07/schema#","description":"Request Network Format of an invoice","type":"object","additionalProperties":false,"required":["meta","invoiceNumber","creationDate","invoiceItems"],"properties":{"meta":{"description":"Meta information about the format","type":"object","additionalProperties":false,"required":["format","version"],"properties":{"format":{"const":"rnf_invoice"},"version":{"const":"0.0.3"}}},"creationDate":{"type":"string","format":"date-time"},"invoiceNumber":{"type":"string"},"purchaseOrderId":{"type":"string"},"note":{"type":"string"},"terms":{"type":"string"},"sellerInfo":{"description":"Seller information","type":"object","additionalProperties":false,"properties":{"email":{"type":"string","format":"email"},"firstName":{"type":"string"},"lastName":{"type":"string"},"businessName":{"type":"string"},"phone":{"type":"string"},"address":{"$ref":"http://json-schema.org/address"},"taxRegistration":{"type":"string"},"companyRegistration":{"type":"string"},"miscellaneous":{"type":"object"}}},"buyerInfo":{"description":"Buyer information","type":"object","additionalProperties":false,"properties":{"email":{"type":"string","format":"email"},"firstName":{"type":"string"},"lastName":{"type":"string"},"businessName":{"type":"string"},"phone":{"type":"string"},"address":{"$ref":"http://json-schema.org/address"},"taxRegistration":{"type":"string"},"companyRegistration":{"type":"string"},"miscellaneous":{"type":"object"}}},"invoiceItems":{"type":"array","items":{"type":"object","additionalProperties":false,"required":["name","quantity","unitPrice","tax","currency"],"properties":{"name":{"type":"string"},"reference":{"type":"string"},"quantity":{"type":"number","minimum":0},"unitPrice":{"type":"string","pattern":"^\\\\d+$"},"discount":{"type":"string","pattern":"^\\\\d+$"},"tax":{"description":"Tax information about the invoice","type":"object","additionalProperties":false,"required":["amount","type"],"properties":{"amount":{"type":"string"},"type":{"type":"string","enum":["percentage","fixed"]}},"if":{"properties":{"type":{"const":"percentage"}}},"then":{"properties":{"amount":{"pattern":"^\\\\d*\\\\.?\\\\d+$"}}},"else":{"properties":{"amount":{"pattern":"^\\\\d+$"}}}},"currency":{"type":"string","minLength":2},"deliveryDate":{"type":"string","format":"date-time"},"deliveryPeriod":{"type":"string"}}}},"paymentTerms":{"description":"Payment terms","type":"object","additionalProperties":false,"properties":{"dueDate":{"type":"string","format":"date-time"},"lateFeesPercent":{"type":"number"},"lateFeesFix":{"type":"string","pattern":"^\\\\d+$"},"miscellaneous":{"type":"object"}}},"miscellaneous":{"type":"object"}}}')},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});r(316).__exportStar(r(837),t)},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getInvoiceTaxTotal=t.getInvoiceLineTotalWithoutTax=t.getInvoiceTotalWithoutTax=t.getInvoiceLineTotal=t.getInvoiceTotal=void 0;const n=r(3);t.getInvoiceTotal=e=>e.invoiceItems.reduce(((e,r)=>e.add((0,t.getInvoiceLineTotal)(r))),n.BigNumber.from(0));t.getInvoiceLineTotal=e=>{const t=e.taxPercent?{type:"percentage",amount:String(e.taxPercent)}:e.tax||{type:"percentage",amount:"0"},r=t.amount&&"percentage"===t.type?Number(t.amount)+100:100,f=t.amount&&"fixed"===t.type?n.BigNumber.from(t.amount):n.BigNumber.from(0),a=e.discount?n.BigNumber.from(e.discount):n.BigNumber.from(0);return n.BigNumber.from(n.FixedNumber.from(e.unitPrice).mulUnsafe(n.FixedNumber.fromString(e.quantity.toString())).subUnsafe(n.FixedNumber.from(a)).mulUnsafe(n.FixedNumber.fromString(r.toString())).divUnsafe(n.FixedNumber.from(100)).addUnsafe(n.FixedNumber.from(f)).round(0).toString().split(".")[0])};t.getInvoiceTotalWithoutTax=e=>e.invoiceItems.reduce(((e,r)=>e.add((0,t.getInvoiceLineTotalWithoutTax)(r))),n.BigNumber.from(0));t.getInvoiceLineTotalWithoutTax=e=>{const t=e.discount?n.BigNumber.from(e.discount):n.BigNumber.from(0);return n.BigNumber.from(n.FixedNumber.from(e.unitPrice).mulUnsafe(n.FixedNumber.fromString(e.quantity.toString())).subUnsafe(n.FixedNumber.from(t)).round(0).toString().split(".")[0])};t.getInvoiceTaxTotal=e=>{const r=e.invoiceItems.reduce(((e,r)=>e.add((0,t.getInvoiceLineTotalWithoutTax)(r))),n.BigNumber.from(0));return e.invoiceItems.reduce(((e,r)=>e.add((0,t.getInvoiceLineTotal)(r))),n.BigNumber.from(0)).sub(r)}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.default={requestClientVersionHeader:"X-Request-Network-Client-Version",httpRequestMaxRetry:3,httpRequestRetryDelay:100,httpRequestExponentialBackoffDelay:0,httpRequestMaxExponentialBackoffDelay:3e4,getConfirmationMaxRetry:500,getConfirmationRetryDelay:3e3,getConfirmationExponentialBackoffDelay:0,getConfirmationMaxExponentialBackoffDelay:3e4,getConfirmationDeferDelay:3e3}},function(e){e.exports=JSON.parse('{"name":"@requestnetwork/request-client.js","version":"0.40.1-next.1918+be4b6778","publishConfig":{"access":"public"},"description":"Client side library for Request Network.","keywords":["requestnetwork","request-client.js"],"repository":{"type":"git","url":"git+https://github.com/RequestNetwork/requestNetwork.git"},"homepage":"https://github.com/RequestNetwork/requestNetwork/tree/master/packages/request-client.js#readme","bugs":{"url":"https://github.com/RequestNetwork/requestNetwork/issues"},"license":"MIT","engines":{"node":">=16.0.0"},"main":"dist/index.js","types":"dist/index.d.ts","directories":{"lib":"src","test":"test"},"files":["dist"],"scripts":{"build":"run-s build:commonjs build:umd","build:commonjs":"tsc -b tsconfig.build.json","build:umd":"webpack","clean":"shx rm -rf dist tsconfig.tsbuildinfo tsconfig.build.tsbuildinfo","docs":"shx rm -rf ./docs && compodoc -p tsconfig.json --output docs --disablePrivate --gaID UA-105153327-8","lint":"eslint . --fix","lint:check":"eslint .","prepare":"yarn run build","test":"jest","test:watch":"yarn test --watch"},"dependencies":{"@requestnetwork/advanced-logic":"0.35.1-next.1918+be4b6778","@requestnetwork/currency":"0.9.1-next.1918+be4b6778","@requestnetwork/data-access":"0.27.1-next.1918+be4b6778","@requestnetwork/data-format":"0.10.1-next.1918+be4b6778","@requestnetwork/epk-signature":"0.5.36-next.1918+be4b6778","@requestnetwork/multi-format":"0.15.11-next.1918+be4b6778","@requestnetwork/payment-detection":"0.36.1-next.1918+be4b6778","@requestnetwork/request-logic":"0.26.11-next.1918+be4b6778","@requestnetwork/smart-contracts":"0.29.1-next.1918+be4b6778","@requestnetwork/transaction-manager":"0.27.1-next.1918+be4b6778","@requestnetwork/types":"0.36.1-next.1918+be4b6778","@requestnetwork/utils":"0.36.1-next.1918+be4b6778","axios":"0.27.2","ethers":"5.5.1","tslib":"2.5.0"},"devDependencies":{"@compodoc/compodoc":"1.1.11","@types/jest":"26.0.13","amd-loader":"0.0.8","axios-mock-adapter":"1.19.0","duplicate-package-checker-webpack-plugin":"3.0.0","jest":"26.4.2","npm-run-all":"4.1.5","nyc":"15.1.0","shx":"0.3.2","source-map-support":"0.5.19","terser-webpack-plugin":"4.2.3","ts-jest":"26.3.0","ts-loader":"8.4.0","ts-node":"10.9.1","typescript":"4.9.5","webpack":"4.44.2","webpack-bundle-analyzer":"4.2.0","webpack-cli":"3.3.12"},"gitHead":"be4b6778a9fee43c5fd82529c715248a9143edf6"}')},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(326);class f extends n.DataAccess{constructor(e){super(e),this.isInitialized=!0}}t.default=f},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(61),f=r(52),a=r(4),i=r(8),o=r(327),s=r(32),c=r(328),u=r(842),d=r(845),l=r(329),p={meta:{storageMeta:{},transactionsStorageLocation:{}},result:{transactions:{}}};t.default=class{constructor(e,t){this.isInitialized=!1;const r={ignoredLocationIndex:new u.default,logger:new i.SimpleLogger,synchronizationIntervalTime:1e4,transactionIndex:new l.default,autoStartSynchronization:!1},{ignoredLocationIndex:n,logger:f,synchronizationIntervalTime:a,transactionIndex:o,autoStartSynchronization:s}=Object.assign(Object.assign({},r),t);this.storage=e,this.lastSyncStorageTimestamp=0,this.autoStartSynchronization=s,this.synchronizationTimer=new d.default((()=>this.synchronizeNewDataIds()),a,f,5),this.transactionIndex=o,this.ignoredLocationIndex=n,this.logger=f}initialize(){return n.__awaiter(this,void 0,void 0,(function*(){if(this.isInitialized)throw new Error("already initialized");yield this.transactionIndex.initialize(),yield this.storage.initialize();const e=yield this.transactionIndex.getLastTransactionTimestamp(),t=(0,i.getCurrentTimestampInSecond)(),r=yield this.storage.getData(e?{from:e,to:t}:void 0);this.lastSyncStorageTimestamp=r.lastTimestamp,yield this.pushLocationsWithTopics(r.entries),this.isInitialized=!0,this.autoStartSynchronization&&this.startAutoSynchronization()}))}close(){return n.__awaiter(this,void 0,void 0,(function*(){yield this.stopAutoSynchronization()}))}persistTransaction(e,t,r=[]){return n.__awaiter(this,void 0,void 0,(function*(){this.checkInitialized();const a=r.filter((e=>!f.default.hashFormat.isDeserializableString(e)));if(0!==a.length)throw new Error(`The following topics are not well formatted: ${JSON.stringify(a)}`);const i=c.default.pushTransaction(c.default.createEmptyBlock(),e,t,r),o=yield this.storage.append(JSON.stringify(i)),u=Object.assign(new s.EventEmitter,{meta:{storageMeta:o.meta,topics:r,transactionStorageLocation:o.id},result:{}});return o.on("confirmed",(e=>n.__awaiter(this,void 0,void 0,(function*(){yield this.transactionIndex.updateTimestamp(e.id,e.meta.timestamp);const t={meta:{storageMeta:e.meta,topics:r,transactionStorageLocation:e.id},result:{}};u.emit("confirmed",t)})))).on("error",(e=>n.__awaiter(this,void 0,void 0,(function*(){u.emit("error",e)})))),yield this.transactionIndex.addTransaction(o.id,i.header,o.meta.timestamp),u}))}getTransactionsByChannelId(e,t){return n.__awaiter(this,void 0,void 0,(function*(){this.checkInitialized();const r=yield this.transactionIndex.getStorageLocationList(e,t);return(yield this.getBlockAndMetaFromStorageLocation(r)).map((t=>{const r=c.default.getTransactionPositionFromChannelId(t.block,e);return this.getTransactionAndMetaFromPosition(r,t.block,t.location,t.meta)})).reduce(((e,t)=>({meta:{storageMeta:e.meta.storageMeta.concat(t.storageMeta),transactionsStorageLocation:e.meta.transactionsStorageLocation.concat(t.transactionsStorageLocation)},result:{transactions:e.result.transactions.concat(t.transactions)}})),{meta:{storageMeta:[],transactionsStorageLocation:[]},result:{transactions:[]}})}))}getChannelsByTopic(e,t){return n.__awaiter(this,void 0,void 0,(function*(){if(this.checkInitialized(),!f.default.hashFormat.isDeserializableString(e))throw new Error(`The topic is not well formatted: ${e}`);const r=yield this.transactionIndex.getChannelIdsForTopic(e,t);return o.map(r,(e=>this.getTransactionsByChannelId(e).then((t=>({channelId:e,transactionsWithMeta:t}))))).reduce(((e,t)=>{const r=t.channelId;return e.meta.transactionsStorageLocation[r]=t.transactionsWithMeta.meta.transactionsStorageLocation,e.meta.storageMeta[r]=t.transactionsWithMeta.meta.storageMeta,e.result.transactions[r]=t.transactionsWithMeta.result.transactions,e}),(0,i.deepCopy)(p))}))}getChannelsByMultipleTopics(e,t){return n.__awaiter(this,void 0,void 0,(function*(){if(this.checkInitialized(),e.some((e=>!f.default.hashFormat.isDeserializableString(e))))throw new Error("The topics are not well formatted");const r=yield this.transactionIndex.getChannelIdsForMultipleTopics(e,t);return o.map(r,(e=>this.getTransactionsByChannelId(e).then((t=>({channelId:e,transactionsWithMeta:t}))))).reduce(((e,t)=>{const r=t.channelId;return e.meta.transactionsStorageLocation[r]=t.transactionsWithMeta.meta.transactionsStorageLocation,e.meta.storageMeta[r]=t.transactionsWithMeta.meta.storageMeta,e.result.transactions[r]=t.transactionsWithMeta.result.transactions,e}),(0,i.deepCopy)(p))}))}synchronizeNewDataIds(){return n.__awaiter(this,void 0,void 0,(function*(){this.checkInitialized();const e=(0,i.getCurrentTimestampInSecond)();let t=0;this.lastSyncStorageTimestamp>0&&(t=this.lastSyncStorageTimestamp+1);const r=yield this.storage.getData({from:t,to:e}),n=yield this.storage.getIgnoredData();yield this.pushLocationsWithTopics(r.entries.concat(n)),this.lastSyncStorageTimestamp=r.lastTimestamp}))}startAutoSynchronization(){this.checkInitialized(),this.synchronizationTimer.start()}stopAutoSynchronization(){return n.__awaiter(this,void 0,void 0,(function*(){this.synchronizationTimer.isStarted&&(yield this.synchronizationTimer.stop())}))}_getStatus(e=!1){return n.__awaiter(this,void 0,void 0,(function*(){this.checkInitialized();const t=yield this.transactionIndex.getLastTransactionTimestamp(),r=yield this.transactionIndex.getIndexedLocations(),n=yield this.ignoredLocationIndex.getIgnoredLocations(),f=this.synchronizationTimer.getConfig();return{filesIgnored:{count:Object.keys(n).length,list:e?n:void 0},filesRetrieved:{count:r.length,lastTimestamp:t,list:e?r:void 0},lastSynchronizationTimestamp:this.lastSyncStorageTimestamp,storage:yield this.storage._getStatus(e),synchronizationConfig:f}}))}pushLocationsWithTopics(e){return n.__awaiter(this,void 0,void 0,(function*(){if(!e)throw Error("data from storage do not follow the standard");let t=0,r=0;yield o.each(e,(e=>n.__awaiter(this,void 0,void 0,(function*(){if(!e.content||!e.id)throw Error("data from storage do not follow the standard");let n;const f=e.content;try{n=c.default.parseBlock(f),r++,yield this.transactionIndex.addTransaction(e.id,n.header,e.meta.timestamp)}catch(r){t++,yield this.ignoredLocationIndex.pushReasonByLocation(e.id,r.message),this.logger.debug(`Error: can't parse content of the dataId (${e.id}): ${r}`,["synchronization"])}})))),this.logger.info(`Synchronization: ${r} blocks synchronized, ${t} ignored from parsing error`,["synchronization"])}))}getBlockAndMetaFromStorageLocation(e){return n.__awaiter(this,void 0,void 0,(function*(){return Promise.all(e.map((e=>n.__awaiter(this,void 0,void 0,(function*(){const t=yield this.storage.read(e);return{block:c.default.parseBlock(t.content),location:e,meta:t.meta}})))))}))}getTransactionAndMetaFromPosition(e,t,r,n){const f=(0,i.unique)(e).uniqueItems.map((e=>({state:n.state===a.StorageTypes.ContentState.CONFIRMED?a.DataAccessTypes.TransactionState.CONFIRMED:a.DataAccessTypes.TransactionState.PENDING,timestamp:n.timestamp,transaction:t.transactions[e]}))),o=Array(f.length).fill(r),s=f.map((()=>n));return{transactions:f,transactionsStorageLocation:o,storageMeta:s}}checkInitialized(){if(!this.isInitialized)throw new Error("DataAccess must be initialized")}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(61),f=r(122);t.default=class{constructor(e){this.reasonsByIgnoredLocation=new f({namespace:"reasonsByIgnoredLocation",store:e}),this.listIgnoredLocation=new f({namespace:"listIgnoredLocation",store:e})}pushReasonByLocation(e,t){return n.__awaiter(this,void 0,void 0,(function*(){(yield this.reasonsByIgnoredLocation.get(e))||(yield this.reasonsByIgnoredLocation.set(e,t),yield this.updateDataId(e))}))}removeReasonByLocation(e){return n.__awaiter(this,void 0,void 0,(function*(){yield this.reasonsByIgnoredLocation.delete(e)}))}getReasonFromLocation(e){return n.__awaiter(this,void 0,void 0,(function*(){const t=yield this.reasonsByIgnoredLocation.get(e);return t||null}))}getIgnoredLocations(){return n.__awaiter(this,void 0,void 0,(function*(){const e=yield this.listIgnoredLocation.get("list");if(!e)return{};const t={};for(const r of Array.from(e))t[r]=yield this.reasonsByIgnoredLocation.get(r);return t}))}updateDataId(e){return n.__awaiter(this,void 0,void 0,(function*(){let t=yield this.listIgnoredLocation.get("list");t||(t=[]),t.push(e),yield this.listIgnoredLocation.set("list",t)}))}}},function(e,t,r){(function(e){t.stringify=function t(r){if(void 0===r)return r;if(r&&e.isBuffer(r))return JSON.stringify(":base64:"+r.toString("base64"));if(r&&r.toJSON&&(r=r.toJSON()),r&&"object"==typeof r){var n="",f=Array.isArray(r);n=f?"[":"{";var a=!0;for(var i in r){var o="function"==typeof r[i]||!f&&void 0===r[i];Object.hasOwnProperty.call(r,i)&&!o&&(a||(n+=","),a=!1,f?null==r[i]?n+="null":n+=t(r[i]):void 0!==r[i]&&(n+=t(i)+":"+t(r[i])))}return n+=f?"]":"}"}return"string"==typeof r?JSON.stringify(/^:/.test(r)?":"+r:r):void 0===r?"null":JSON.stringify(r)},t.parse=function(t){return JSON.parse(t,(function(t,r){return"string"==typeof r?/^:base64:/.test(r)?e.from(r.substring(8),"base64"):/^:/.test(r)?r.substring(1):r:r}))}}).call(this,r(7).Buffer)},function(e,t){function r(e){var t=new Error("Cannot find module '"+e+"'");throw t.code="MODULE_NOT_FOUND",t}r.keys=function(){return[]},r.resolve=r,e.exports=r,r.id=844},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(61);t.default=class{constructor(e,t,r,n=1){this.intervalFunctionSuccessiveFailureCount=0,this.timeoutObject=null,this.lastRecursion=Promise.resolve(),this.intervalFunction=e,this.intervalTime=t,this.logger=r,this.successiveFailureThreshold=n}start(){if(this.timeoutObject)throw Error("IntervalTimer already started");const e=()=>n.__awaiter(this,void 0,void 0,(function*(){try{yield this.intervalFunction(),this.intervalFunctionSuccessiveFailureCount=0}catch(e){this.logger.warn(`${this.intervalFunction.name||"intervalFunction"} error: ${e}`),this.intervalFunctionSuccessiveFailureCount++,this.intervalFunctionSuccessiveFailureCount>=this.successiveFailureThreshold&&this.logger.error(`${this.intervalFunction.name||"intervalFunction"} failed ${this.intervalFunctionSuccessiveFailureCount} times in a row, last error: ${e}`)}t()})),t=()=>{this.timeoutObject=setTimeout((()=>{this.lastRecursion=e()}),this.intervalTime)};t()}stop(){return n.__awaiter(this,void 0,void 0,(function*(){return this.timeoutObject?(clearTimeout(this.timeoutObject),this.timeoutObject=null,this.lastRecursion):Promise.reject("Can't stop IntervalTimer if it has not been started")}))}get isStarted(){return Boolean(this.timeoutObject)}getConfig(){return{intervalTime:this.intervalTime,successiveFailureThreshold:this.successiveFailureThreshold}}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(61),f=r(327),a=r(122),i=r(330),o=r(331);t.default=class{constructor(e){this.timestampByLocation=new o.default(e),this.locationByTopic=new i.default(e),this.indexedLocation=new a({namespace:"indexedLocation",store:e})}initialize(){return n.__awaiter(this,void 0,void 0,(function*(){}))}getLastTransactionTimestamp(){return this.timestampByLocation.getLastTransactionTimestamp()}addTransaction(e,t,r){return n.__awaiter(this,void 0,void 0,(function*(){if(!this.locationByTopic)throw new Error("TransactionIndex must be initialized");yield this.locationByTopic.pushStorageLocationIndexedWithBlockTopics(e,t),yield this.timestampByLocation.pushTimestampByLocation(e,r),yield this.updateIndexedLocation(e)}))}removeTransaction(e){return n.__awaiter(this,void 0,void 0,(function*(){if(!this.locationByTopic)throw new Error("TransactionIndex must be initialized");yield this.timestampByLocation.removeIndexedDataId(e)}))}updateTimestamp(e,t){return n.__awaiter(this,void 0,void 0,(function*(){if(!this.timestampByLocation)throw new Error("TransactionIndex must be initialized");yield this.timestampByLocation.updateTimestampByLocation(e,t)}))}getStorageLocationList(e,t){return n.__awaiter(this,void 0,void 0,(function*(){if(!this.locationByTopic)throw new Error("TransactionIndex must be initialized");let r=yield this.locationByTopic.getStorageLocationsFromChannelId(e);return r=yield f.filter(r,(e=>n.__awaiter(this,void 0,void 0,(function*(){const r=null!==(yield this.timestampByLocation.getTimestampFromLocation(e)),n=!t||(yield this.timestampByLocation.isDataInBoundaries(e,t));return r&&n})))),r}))}getChannelIdsForTopic(e,t){return n.__awaiter(this,void 0,void 0,(function*(){if(!this.locationByTopic)throw new Error("TransactionIndex must be initialized");const r=yield this.locationByTopic.getChannelIdsFromTopic(e);if(t){const e=[];for(const n of r){const r=yield this.locationByTopic.getStorageLocationsFromChannelId(n);for(const f of r){if(yield this.timestampByLocation.isDataInBoundaries(f,t)){e.push(n);break}}}return e}return r}))}getChannelIdsForMultipleTopics(e,t){return n.__awaiter(this,void 0,void 0,(function*(){if(!this.locationByTopic)throw new Error("TransactionIndex must be initialized");const r=yield this.locationByTopic.getChannelIdsFromMultipleTopics(e);if(t){const e=[];for(const n of r){const r=yield this.locationByTopic.getStorageLocationsFromChannelId(n);for(const f of r){if(yield this.timestampByLocation.isDataInBoundaries(f,t)){e.push(n);break}}}return e}return r}))}getIndexedLocations(){return n.__awaiter(this,void 0,void 0,(function*(){return(yield this.indexedLocation.get("list"))||[]}))}updateIndexedLocation(e){return n.__awaiter(this,void 0,void 0,(function*(){let t=yield this.indexedLocation.get("list");t||(t=[]),t.includes(e)||(t.push(e),yield this.indexedLocation.set("list",t))}))}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CombinedDataAccess=void 0;const n=r(61);t.CombinedDataAccess=class{constructor(e,t){this.reader=e,this.writer=t,this.getTransactionsByChannelId=this.reader.getTransactionsByChannelId.bind(this.reader),this.getChannelsByTopic=this.reader.getChannelsByTopic.bind(this.reader),this.getChannelsByMultipleTopics=this.reader.getChannelsByMultipleTopics.bind(this.reader),this.persistTransaction=this.writer.persistTransaction.bind(this.writer)}initialize(){return n.__awaiter(this,void 0,void 0,(function*(){yield this.reader.initialize(),yield this.writer.initialize()}))}close(){return n.__awaiter(this,void 0,void 0,(function*(){yield this.writer.close(),yield this.reader.close()}))}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(80),f=r(52),a=r(4),i=r(32),o=r(8);t.default=class{constructor(){this.data=new Map,this.forceEmitError=!1}initialize(){return n.__awaiter(this,void 0,void 0,(function*(){}))}ipfsAdd(e){return n.__awaiter(this,void 0,void 0,(function*(){if(!e)throw Error("Error: no content provided");const t=f.default.serialize((0,o.normalizeKeccak256Hash)(e)),r=(0,o.getCurrentTimestampInSecond)();return this.data.set(t,{content:e,state:a.StorageTypes.ContentState.PENDING,timestamp:r}),{ipfsHash:t,ipfsSize:e.length}}))}append(e){return n.__awaiter(this,void 0,void 0,(function*(){if(!e)throw Error("Error: no content provided");const t=f.default.serialize((0,o.normalizeKeccak256Hash)(e)),r=(0,o.getCurrentTimestampInSecond)(),n={content:e,state:a.StorageTypes.ContentState.PENDING,timestamp:r};this.data.set(t,n);const s={content:e,id:t,meta:{state:a.StorageTypes.ContentState.PENDING,storageType:a.StorageTypes.StorageSystemType.IN_MEMORY_MOCK,timestamp:r}},c=Object.assign(new i.EventEmitter,s);return setTimeout((()=>{this.forceEmitError?(this.forceEmitError=!1,c.emit("error","forced error asked by _makeNextAppendFailInsteadOfConfirmed()")):(n.state=a.StorageTypes.ContentState.CONFIRMED,this.data.set(t,n),c.emit("confirmed",s))}),100),c}))}read(e){return n.__awaiter(this,void 0,void 0,(function*(){if(!e)throw Error("No id provided");const t=this.data.get(e);if(!t)throw Error("No content found from this id");return{content:t.content,id:e,meta:{state:t.state,storageType:a.StorageTypes.StorageSystemType.IN_MEMORY_MOCK,timestamp:t.timestamp}}}))}readMany(e){return n.__awaiter(this,void 0,void 0,(function*(){return Promise.all(e.map((e=>this.read(e))))}))}getData(){return n.__awaiter(this,void 0,void 0,(function*(){return{entries:Array.from(this.data.entries()).map((([e,{content:t,state:r,timestamp:n}])=>({content:t,id:e,meta:{state:r,storageType:a.StorageTypes.StorageSystemType.IN_MEMORY_MOCK,timestamp:n}}))),lastTimestamp:(0,o.getCurrentTimestampInSecond)()}}))}getIgnoredData(){return n.__awaiter(this,void 0,void 0,(function*(){return[]}))}_getStatus(e){return n.__awaiter(this,void 0,void 0,(function*(){return{dataIds:{count:Object.entries(this.data).length,values:e?Object.entries(this.data):void 0},ignoredDataIds:{count:0,values:e?[]:void 0}}}))}_makeNextAppendFailInsteadOfConfirmed(){this.forceEmitError=!0}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(80),f=r(326),a=r(50),i=r(4),o=r(77),s=r(3),c=r(32),u=r(325),d=r(8);class l extends u.default{constructor({httpConfig:e,nodeConnectionConfig:t,web3:r,ethereumProviderUrl:n}={httpConfig:{},nodeConnectionConfig:{}}){super({httpConfig:e,nodeConnectionConfig:t}),this.cache={},this.networkName="private",n=n||"http://localhost:8545",this.provider=r?new s.ethers.providers.Web3Provider(r):new s.ethers.providers.JsonRpcProvider({url:n})}initialize(){return n.__awaiter(this,void 0,void 0,(function*(){}))}persistTransaction(e,t,r){return n.__awaiter(this,void 0,void 0,(function*(){if(!this.submitterContract){const e=yield this.provider.getNetwork();this.networkName=1===e.chainId?"mainnet":4===e.chainId?"rinkeby":"private",this.submitterContract=new s.ethers.Contract(a.requestHashSubmitterArtifact.getAddress(this.networkName),a.requestHashSubmitterArtifact.getContractAbi(),this.provider.getSigner())}const n=f.Block.pushTransaction(f.Block.createEmptyBlock(),e,t,r),{data:{ipfsHash:u,ipfsSize:d}}=yield o.default.post("/ipfsAdd",{data:n},this.axiosConfig),l=yield this.submitterContract.getFeesAmount(d),p=yield this.submitterContract.submitHash(u,s.ethers.utils.hexZeroPad(s.ethers.utils.hexlify(d),32),{value:l}),h=yield this.provider.getBlock(p.blockNumber),b={blockConfirmation:p.confirmations,blockNumber:p.blockNumber,blockTimestamp:h.timestamp,fee:l,networkName:this.networkName,smartContractAddress:p.to,transactionHash:p.hash};this.cache[t]||(this.cache[t]={}),this.cache[t][u]={block:n,storageMeta:b};const m=new c.EventEmitter,y={meta:{storageMeta:{ethereum:b,ipfs:{size:d},state:i.StorageTypes.ContentState.PENDING,timestamp:b.blockTimestamp},topics:r||[],transactionStorageLocation:u},result:{}};return p.wait().then((e=>{const t={blockConfirmation:e.confirmations,blockNumber:e.blockNumber,blockTimestamp:h.timestamp,fee:l,networkName:this.networkName,smartContractAddress:e.to,transactionHash:e.hash};m.emit("confirmed",{meta:{storageMeta:t,topics:r||[],transactionStorageLocation:u},result:{}})})),Object.assign(m,y)}))}getTransactionsByChannelId(e,t){return n.__awaiter(this,void 0,void 0,(function*(){const{data:r}=yield(0,d.retry)((()=>n.__awaiter(this,void 0,void 0,(function*(){return o.default.get("/getTransactionsByChannelId",Object.assign(this.axiosConfig,{params:{channelId:e,timestampBoundaries:t}}))}))),{maxRetries:this.httpConfig.httpRequestMaxRetry,retryDelay:this.httpConfig.httpRequestRetryDelay})(),f=this.getCachedTransactionsAndCleanCache(e,r.meta.transactionsStorageLocation,t);return{meta:{storageMeta:r.meta.storageMeta.concat(f.meta.storageMeta),transactionsStorageLocation:r.meta.transactionsStorageLocation.concat(f.meta.transactionsStorageLocation)},result:{transactions:r.result.transactions.concat(f.result.transactions)}}}))}getCachedTransactionsAndCleanCache(e,t,r){for(const r of t)this.cache[e][r]=null;return Object.keys(this.cache[e]||[]).reduce(((t,n)=>{var f;const a=this.cache[e][n];return this.cache[e][n]&&(!r||(void 0===r.from||r.from<=(null==a?void 0:a.storageMeta.blockTimestamp))&&(void 0===r.to||r.to>=(null==a?void 0:a.storageMeta.blockTimestamp)))&&(null===(f=t.meta.storageMeta)||void 0===f||f.push(null==a?void 0:a.storageMeta),t.meta.transactionsStorageLocation.push(n),t.result.transactions.push({state:i.DataAccessTypes.TransactionState.PENDING,timestamp:null==a?void 0:a.storageMeta.blockTimestamp,transaction:null==a?void 0:a.block.transactions[0]})),t}),{meta:{storageMeta:[],transactionsStorageLocation:[]},result:{transactions:[]}})}}t.default=l},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Payment=t.Transaction=t.Storage=t.Identity=t.SignatureProvider=t.Signature=t.DataAccess=t.RequestLogic=t.Encryption=t.Extension=t.DecryptionProvider=t.Log=t.AdvancedLogic=void 0;r(80).__exportStar(r(182),t);var n=r(4);Object.defineProperty(t,"AdvancedLogic",{enumerable:!0,get:function(){return n.AdvancedLogicTypes}}),Object.defineProperty(t,"Log",{enumerable:!0,get:function(){return n.LogTypes}}),Object.defineProperty(t,"DecryptionProvider",{enumerable:!0,get:function(){return n.DecryptionProviderTypes}}),Object.defineProperty(t,"Extension",{enumerable:!0,get:function(){return n.ExtensionTypes}}),Object.defineProperty(t,"Encryption",{enumerable:!0,get:function(){return n.EncryptionTypes}}),Object.defineProperty(t,"RequestLogic",{enumerable:!0,get:function(){return n.RequestLogicTypes}}),Object.defineProperty(t,"DataAccess",{enumerable:!0,get:function(){return n.DataAccessTypes}}),Object.defineProperty(t,"Signature",{enumerable:!0,get:function(){return n.SignatureTypes}}),Object.defineProperty(t,"SignatureProvider",{enumerable:!0,get:function(){return n.SignatureProviderTypes}}),Object.defineProperty(t,"Identity",{enumerable:!0,get:function(){return n.IdentityTypes}}),Object.defineProperty(t,"Storage",{enumerable:!0,get:function(){return n.StorageTypes}}),Object.defineProperty(t,"Transaction",{enumerable:!0,get:function(){return n.TransactionTypes}}),Object.defineProperty(t,"Payment",{enumerable:!0,get:function(){return n.PaymentTypes}})},function(e,t,r){"use strict";r.r(t),r.d(t,"ethers",(function(){return a})),r.d(t,"Signer",(function(){return c.a})),r.d(t,"Wallet",(function(){return u.Wallet})),r.d(t,"VoidSigner",(function(){return c.b})),r.d(t,"getDefaultProvider",(function(){return gt})),r.d(t,"providers",(function(){return n})),r.d(t,"BaseContract",(function(){return i.a})),r.d(t,"Contract",(function(){return i.b})),r.d(t,"ContractFactory",(function(){return i.c})),r.d(t,"BigNumber",(function(){return o.a})),r.d(t,"FixedNumber",(function(){return s.a})),r.d(t,"constants",(function(){return d})),r.d(t,"errors",(function(){return T.ErrorCode})),r.d(t,"logger",(function(){return Zr})),r.d(t,"utils",(function(){return f})),r.d(t,"wordlists",(function(){return vt.a})),r.d(t,"version",(function(){return Xr})),r.d(t,"Wordlist",(function(){return _t.a}));var n={};r.r(n),r.d(n,"Provider",(function(){return l.b})),r.d(n,"BaseProvider",(function(){return te})),r.d(n,"Resolver",(function(){return Z})),r.d(n,"UrlJsonRpcProvider",(function(){return Ae})),r.d(n,"FallbackProvider",(function(){return tt})),r.d(n,"AlchemyProvider",(function(){return Se})),r.d(n,"AlchemyWebSocketProvider",(function(){return ke})),r.d(n,"CloudflareProvider",(function(){return Pe})),r.d(n,"EtherscanProvider",(function(){return Le})),r.d(n,"InfuraProvider",(function(){return it})),r.d(n,"InfuraWebSocketProvider",(function(){return at})),r.d(n,"JsonRpcProvider",(function(){return he})),r.d(n,"JsonRpcBatchProvider",(function(){return ot})),r.d(n,"NodesmithProvider",(function(){return ct})),r.d(n,"PocketProvider",(function(){return lt})),r.d(n,"StaticJsonRpcProvider",(function(){return Ee})),r.d(n,"Web3Provider",(function(){return mt})),r.d(n,"WebSocketProvider",(function(){return ve})),r.d(n,"IpcProvider",(function(){return rt})),r.d(n,"JsonRpcSigner",(function(){return de})),r.d(n,"getDefaultProvider",(function(){return gt})),r.d(n,"getNetwork",(function(){return p.a})),r.d(n,"isCommunityResource",(function(){return N})),r.d(n,"isCommunityResourcable",(function(){return R})),r.d(n,"showThrottleMessage",(function(){return M})),r.d(n,"Formatter",(function(){return P}));var f={};r.r(f),r.d(f,"AbiCoder",(function(){return hr})),r.d(f,"defaultAbiCoder",(function(){return br})),r.d(f,"Fragment",(function(){return Zt})),r.d(f,"ConstructorFragment",(function(){return nr})),r.d(f,"ErrorFragment",(function(){return ir})),r.d(f,"EventFragment",(function(){return Qt})),r.d(f,"FunctionFragment",(function(){return fr})),r.d(f,"ParamType",(function(){return Jt})),r.d(f,"FormatTypes",(function(){return Wt})),r.d(f,"checkResultErrors",(function(){return At})),r.d(f,"Logger",(function(){return T.Logger})),r.d(f,"RLP",(function(){return Dr})),r.d(f,"_fetchData",(function(){return Kr})),r.d(f,"fetchJson",(function(){return Wr})),r.d(f,"poll",(function(){return Yr})),r.d(f,"checkProperties",(function(){return g.checkProperties})),r.d(f,"deepCopy",(function(){return g.deepCopy})),r.d(f,"defineReadOnly",(function(){return g.defineReadOnly})),r.d(f,"getStatic",(function(){return g.getStatic})),r.d(f,"resolveProperties",(function(){return g.resolveProperties})),r.d(f,"shallowCopy",(function(){return g.shallowCopy})),r.d(f,"arrayify",(function(){return b.arrayify})),r.d(f,"concat",(function(){return b.concat})),r.d(f,"stripZeros",(function(){return b.stripZeros})),r.d(f,"zeroPad",(function(){return b.zeroPad})),r.d(f,"isBytes",(function(){return b.isBytes})),r.d(f,"isBytesLike",(function(){return b.isBytesLike})),r.d(f,"defaultPath",(function(){return Pr.defaultPath})),r.d(f,"HDNode",(function(){return Pr.HDNode})),r.d(f,"SigningKey",(function(){return Br.SigningKey})),r.d(f,"Interface",(function(){return Sr})),r.d(f,"LogDescription",(function(){return wr})),r.d(f,"TransactionDescription",(function(){return Er})),r.d(f,"base58",(function(){return h.Base58})),r.d(f,"base64",(function(){return Or})),r.d(f,"hexlify",(function(){return b.hexlify})),r.d(f,"isHexString",(function(){return b.isHexString})),r.d(f,"hexConcat",(function(){return b.hexConcat})),r.d(f,"hexStripZeros",(function(){return b.hexStripZeros})),r.d(f,"hexValue",(function(){return b.hexValue})),r.d(f,"hexZeroPad",(function(){return b.hexZeroPad})),r.d(f,"hexDataLength",(function(){return b.hexDataLength})),r.d(f,"hexDataSlice",(function(){return b.hexDataSlice})),r.d(f,"nameprep",(function(){return Fr.a})),r.d(f,"_toEscapedUtf8String",(function(){return _.d})),r.d(f,"toUtf8Bytes",(function(){return _.f})),r.d(f,"toUtf8CodePoints",(function(){return _.g})),r.d(f,"toUtf8String",(function(){return _.h})),r.d(f,"Utf8ErrorFuncs",(function(){return _.b})),r.d(f,"formatBytes32String",(function(){return jr.a})),r.d(f,"parseBytes32String",(function(){return jr.b})),r.d(f,"hashMessage",(function(){return Cr.a})),r.d(f,"namehash",(function(){return y.b})),r.d(f,"isValidName",(function(){return y.a})),r.d(f,"id",(function(){return mr.a})),r.d(f,"_TypedDataEncoder",(function(){return re.a})),r.d(f,"getAddress",(function(){return k.getAddress})),r.d(f,"getIcapAddress",(function(){return k.getIcapAddress})),r.d(f,"getContractAddress",(function(){return k.getContractAddress})),r.d(f,"getCreate2Address",(function(){return k.getCreate2Address})),r.d(f,"isAddress",(function(){return k.isAddress})),r.d(f,"formatEther",(function(){return Lr.formatEther})),r.d(f,"parseEther",(function(){return Lr.parseEther})),r.d(f,"formatUnits",(function(){return Lr.formatUnits})),r.d(f,"parseUnits",(function(){return Lr.parseUnits})),r.d(f,"commify",(function(){return Lr.commify})),r.d(f,"computeHmac",(function(){return v.a})),r.d(f,"keccak256",(function(){return vr})),r.d(f,"ripemd160",(function(){return v.b})),r.d(f,"sha256",(function(){return v.c})),r.d(f,"sha512",(function(){return v.d})),r.d(f,"randomBytes",(function(){return Ir.a})),r.d(f,"shuffled",(function(){return Mr})),r.d(f,"solidityPack",(function(){return Nr.pack})),r.d(f,"solidityKeccak256",(function(){return Nr.keccak256})),r.d(f,"soliditySha256",(function(){return Nr.sha256})),r.d(f,"splitSignature",(function(){return b.splitSignature})),r.d(f,"joinSignature",(function(){return b.joinSignature})),r.d(f,"accessListify",(function(){return O.accessListify})),r.d(f,"parseTransaction",(function(){return O.parse})),r.d(f,"serializeTransaction",(function(){return O.serialize})),r.d(f,"TransactionTypes",(function(){return O.TransactionTypes})),r.d(f,"getJsonWalletAddress",(function(){return Rr.a})),r.d(f,"computeAddress",(function(){return O.computeAddress})),r.d(f,"recoverAddress",(function(){return O.recoverAddress})),r.d(f,"computePublicKey",(function(){return Br.computePublicKey})),r.d(f,"recoverPublicKey",(function(){return Br.recoverPublicKey})),r.d(f,"verifyMessage",(function(){return u.verifyMessage})),r.d(f,"verifyTypedData",(function(){return u.verifyTypedData})),r.d(f,"getAccountPath",(function(){return Pr.getAccountPath})),r.d(f,"mnemonicToEntropy",(function(){return Pr.mnemonicToEntropy})),r.d(f,"entropyToMnemonic",(function(){return Pr.entropyToMnemonic})),r.d(f,"isValidMnemonic",(function(){return Pr.isValidMnemonic})),r.d(f,"mnemonicToSeed",(function(){return Pr.mnemonicToSeed})),r.d(f,"SupportedAlgorithm",(function(){return Jr.a})),r.d(f,"UnicodeNormalizationForm",(function(){return _.a})),r.d(f,"Utf8ErrorReason",(function(){return _.c})),r.d(f,"Indexed",(function(){return Tr}));var a={};r.r(a),r.d(a,"Signer",(function(){return c.a})),r.d(a,"Wallet",(function(){return u.Wallet})),r.d(a,"VoidSigner",(function(){return c.b})),r.d(a,"getDefaultProvider",(function(){return gt})),r.d(a,"providers",(function(){return n})),r.d(a,"BaseContract",(function(){return i.a})),r.d(a,"Contract",(function(){return i.b})),r.d(a,"ContractFactory",(function(){return i.c})),r.d(a,"BigNumber",(function(){return o.a})),r.d(a,"FixedNumber",(function(){return s.a})),r.d(a,"constants",(function(){return d})),r.d(a,"errors",(function(){return T.ErrorCode})),r.d(a,"logger",(function(){return Zr})),r.d(a,"utils",(function(){return f})),r.d(a,"wordlists",(function(){return vt.a})),r.d(a,"version",(function(){return Xr})),r.d(a,"Wordlist",(function(){return _t.a}));var i=r(62),o=r(17),s=r(858),c=r(30),u=r(48),d=r(39),l=r(24),p=r(53),h=r(37),b=r(0),m=r(179),y=r(136),g=r(1),v=r(70),_=r(20),w=r(14),E=r(89),A=r.n(E),T=r(2);const x="providers/5.5.3";var k=r(6),S=r(191),O=r(10);const C=new T.Logger(x);class P{constructor(){C.checkNew(new.target,P),this.formats=this.getDefaultFormats()}getDefaultFormats(){const e={},t=this.address.bind(this),r=this.bigNumber.bind(this),n=this.blockTag.bind(this),f=this.data.bind(this),a=this.hash.bind(this),i=this.hex.bind(this),o=this.number.bind(this),s=this.type.bind(this);return e.transaction={hash:a,type:s,accessList:P.allowNull(this.accessList.bind(this),null),blockHash:P.allowNull(a,null),blockNumber:P.allowNull(o,null),transactionIndex:P.allowNull(o,null),confirmations:P.allowNull(o,null),from:t,gasPrice:P.allowNull(r),maxPriorityFeePerGas:P.allowNull(r),maxFeePerGas:P.allowNull(r),gasLimit:r,to:P.allowNull(t,null),value:r,nonce:o,data:f,r:P.allowNull(this.uint256),s:P.allowNull(this.uint256),v:P.allowNull(o),creates:P.allowNull(t,null),raw:P.allowNull(f)},e.transactionRequest={from:P.allowNull(t),nonce:P.allowNull(o),gasLimit:P.allowNull(r),gasPrice:P.allowNull(r),maxPriorityFeePerGas:P.allowNull(r),maxFeePerGas:P.allowNull(r),to:P.allowNull(t),value:P.allowNull(r),data:P.allowNull((e=>this.data(e,!0))),type:P.allowNull(o),accessList:P.allowNull(this.accessList.bind(this),null)},e.receiptLog={transactionIndex:o,blockNumber:o,transactionHash:a,address:t,topics:P.arrayOf(a),data:f,logIndex:o,blockHash:a},e.receipt={to:P.allowNull(this.address,null),from:P.allowNull(this.address,null),contractAddress:P.allowNull(t,null),transactionIndex:o,root:P.allowNull(i),gasUsed:r,logsBloom:P.allowNull(f),blockHash:a,transactionHash:a,logs:P.arrayOf(this.receiptLog.bind(this)),blockNumber:o,confirmations:P.allowNull(o,null),cumulativeGasUsed:r,effectiveGasPrice:P.allowNull(r),status:P.allowNull(o),type:s},e.block={hash:a,parentHash:a,number:o,timestamp:o,nonce:P.allowNull(i),difficulty:this.difficulty.bind(this),gasLimit:r,gasUsed:r,miner:t,extraData:f,transactions:P.allowNull(P.arrayOf(a)),baseFeePerGas:P.allowNull(r)},e.blockWithTransactions=Object(g.shallowCopy)(e.block),e.blockWithTransactions.transactions=P.allowNull(P.arrayOf(this.transactionResponse.bind(this))),e.filter={fromBlock:P.allowNull(n,void 0),toBlock:P.allowNull(n,void 0),blockHash:P.allowNull(a,void 0),address:P.allowNull(t,void 0),topics:P.allowNull(this.topics.bind(this),void 0)},e.filterLog={blockNumber:P.allowNull(o),blockHash:P.allowNull(a),transactionIndex:o,removed:P.allowNull(this.boolean.bind(this)),address:t,data:P.allowFalsish(f,"0x"),topics:P.arrayOf(a),transactionHash:a,logIndex:o},e}accessList(e){return Object(O.accessListify)(e||[])}number(e){return"0x"===e?0:o.a.from(e).toNumber()}type(e){return"0x"===e||null==e?0:o.a.from(e).toNumber()}bigNumber(e){return o.a.from(e)}boolean(e){if("boolean"==typeof e)return e;if("string"==typeof e){if("true"===(e=e.toLowerCase()))return!0;if("false"===e)return!1}throw new Error("invalid boolean - "+e)}hex(e,t){return"string"==typeof e&&(t||"0x"===e.substring(0,2)||(e="0x"+e),Object(b.isHexString)(e))?e.toLowerCase():C.throwArgumentError("invalid hash","value",e)}data(e,t){const r=this.hex(e,t);if(r.length%2!=0)throw new Error("invalid data; odd-length - "+e);return r}address(e){return Object(k.getAddress)(e)}callAddress(e){if(!Object(b.isHexString)(e,32))return null;const t=Object(k.getAddress)(Object(b.hexDataSlice)(e,12));return t===S.a?null:t}contractAddress(e){return Object(k.getContractAddress)(e)}blockTag(e){if(null==e)return"latest";if("earliest"===e)return"0x0";if("latest"===e||"pending"===e)return e;if("number"==typeof e||Object(b.isHexString)(e))return Object(b.hexValue)(e);throw new Error("invalid blockTag")}hash(e,t){const r=this.hex(e,t);return 32!==Object(b.hexDataLength)(r)?C.throwArgumentError("invalid hash","value",e):r}difficulty(e){if(null==e)return null;const t=o.a.from(e);try{return t.toNumber()}catch(e){}return null}uint256(e){if(!Object(b.isHexString)(e))throw new Error("invalid uint256");return Object(b.hexZeroPad)(e,32)}_block(e,t){null!=e.author&&null==e.miner&&(e.miner=e.author);const r=null!=e._difficulty?e._difficulty:e.difficulty,n=P.check(t,e);return n._difficulty=null==r?null:o.a.from(r),n}block(e){return this._block(e,this.formats.block)}blockWithTransactions(e){return this._block(e,this.formats.blockWithTransactions)}transactionRequest(e){return P.check(this.formats.transactionRequest,e)}transactionResponse(e){null!=e.gas&&null==e.gasLimit&&(e.gasLimit=e.gas),e.to&&o.a.from(e.to).isZero()&&(e.to="0x0000000000000000000000000000000000000000"),null!=e.input&&null==e.data&&(e.data=e.input),null==e.to&&null==e.creates&&(e.creates=this.contractAddress(e)),1!==e.type&&2!==e.type||null!=e.accessList||(e.accessList=[]);const t=P.check(this.formats.transaction,e);if(null!=e.chainId){let r=e.chainId;Object(b.isHexString)(r)&&(r=o.a.from(r).toNumber()),t.chainId=r}else{let r=e.networkId;null==r&&null==t.v&&(r=e.chainId),Object(b.isHexString)(r)&&(r=o.a.from(r).toNumber()),"number"!=typeof r&&null!=t.v&&(r=(t.v-35)/2,r<0&&(r=0),r=parseInt(r)),"number"!=typeof r&&(r=0),t.chainId=r}return t.blockHash&&"x"===t.blockHash.replace(/0/g,"")&&(t.blockHash=null),t}transaction(e){return Object(O.parse)(e)}receiptLog(e){return P.check(this.formats.receiptLog,e)}receipt(e){const t=P.check(this.formats.receipt,e);if(null!=t.root)if(t.root.length<=4){const e=o.a.from(t.root).toNumber();0===e||1===e?(null!=t.status&&t.status!==e&&C.throwArgumentError("alt-root-status/status mismatch","value",{root:t.root,status:t.status}),t.status=e,delete t.root):C.throwArgumentError("invalid alt-root-status","value.root",t.root)}else 66!==t.root.length&&C.throwArgumentError("invalid root hash","value.root",t.root);return null!=t.status&&(t.byzantium=!0),t}topics(e){return Array.isArray(e)?e.map((e=>this.topics(e))):null!=e?this.hash(e,!0):null}filter(e){return P.check(this.formats.filter,e)}filterLog(e){return P.check(this.formats.filterLog,e)}static check(e,t){const r={};for(const n in e)try{const f=e[n](t[n]);void 0!==f&&(r[n]=f)}catch(e){throw e.checkKey=n,e.checkValue=t[n],e}return r}static allowNull(e,t){return function(r){return null==r?t:e(r)}}static allowFalsish(e,t){return function(r){return r?e(r):t}}static arrayOf(e){return function(t){if(!Array.isArray(t))throw new Error("not an array");const r=[];return t.forEach((function(t){r.push(e(t))})),r}}}function R(e){return e&&"function"==typeof e.isCommunityResource}function N(e){return R(e)&&e.isCommunityResource()}let I=!1;function M(){I||(I=!0,console.log("========= NOTICE ========="),console.log("Request-Rate Exceeded (this message will not be repeated)"),console.log(""),console.log("The default API keys for each service are provided as a highly-throttled,"),console.log("community resource for low-traffic projects and early prototyping."),console.log(""),console.log("While your application will continue to function, we highly recommended"),console.log("signing up for your own API keys to improve performance, increase your"),console.log("request rate/limit and enable other perks, such as metrics and advanced APIs."),console.log(""),console.log("For more details: https://docs.ethers.io/api-keys/"),console.log("=========================="))}var D=function(e,t,r,n){return new(r||(r=Promise))((function(f,a){function i(e){try{s(n.next(e))}catch(e){a(e)}}function o(e){try{s(n.throw(e))}catch(e){a(e)}}function s(e){var t;e.done?f(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(i,o)}s((n=n.apply(e,t||[])).next())}))};const B=new T.Logger(x);function F(e){return null==e?"null":(32!==Object(b.hexDataLength)(e)&&B.throwArgumentError("invalid topic","topic",e),e.toLowerCase())}function j(e){for(e=e.slice();e.length>0&&null==e[e.length-1];)e.pop();return e.map((e=>{if(Array.isArray(e)){const t={};e.forEach((e=>{t[F(e)]=!0}));const r=Object.keys(t);return r.sort(),r.join("|")}return F(e)})).join("&")}function L(e){if("string"==typeof e){if(e=e.toLowerCase(),32===Object(b.hexDataLength)(e))return"tx:"+e;if(-1===e.indexOf(":"))return e}else{if(Array.isArray(e))return"filter:*:"+j(e);if(l.a.isForkEvent(e))throw B.warn("not implemented"),new Error("not implemented");if(e&&"object"==typeof e)return"filter:"+(e.address||"*")+":"+j(e.topics||[])}throw new Error("invalid event - "+e)}function U(){return(new Date).getTime()}function q(e){return new Promise((t=>{setTimeout(t,e)}))}const H=["block","network","pending","poll"];class ${constructor(e,t,r){Object(g.defineReadOnly)(this,"tag",e),Object(g.defineReadOnly)(this,"listener",t),Object(g.defineReadOnly)(this,"once",r)}get event(){switch(this.type){case"tx":return this.hash;case"filter":return this.filter}return this.tag}get type(){return this.tag.split(":")[0]}get hash(){const e=this.tag.split(":");return"tx"!==e[0]?null:e[1]}get filter(){const e=this.tag.split(":");if("filter"!==e[0])return null;const t=e[1],r=""===(n=e[2])?[]:n.split(/&/g).map((e=>{if(""===e)return[];const t=e.split("|").map((e=>"null"===e?null:e));return 1===t.length?t[0]:t}));var n;const f={};return r.length>0&&(f.topics=r),t&&"*"!==t&&(f.address=t),f}pollable(){return this.tag.indexOf(":")>=0||H.indexOf(this.tag)>=0}}const z={0:{symbol:"btc",p2pkh:0,p2sh:5,prefix:"bc"},2:{symbol:"ltc",p2pkh:48,p2sh:50,prefix:"ltc"},3:{symbol:"doge",p2pkh:30,p2sh:22},60:{symbol:"eth",ilk:"eth"},61:{symbol:"etc",ilk:"eth"},700:{symbol:"xdai",ilk:"eth"}};function V(e){return Object(b.hexZeroPad)(o.a.from(e).toHexString(),32)}function G(e){return h.Base58.encode(Object(b.concat)([e,Object(b.hexDataSlice)(Object(v.c)(Object(v.c)(e)),0,4)]))}const K=new RegExp("^(ipfs)://(.*)$","i"),W=[new RegExp("^(https)://(.*)$","i"),new RegExp("^(data):(.*)$","i"),K,new RegExp("^eip155:[0-9]+/(erc[0-9]+):(.*)$","i")];function Y(e){try{return Object(_.h)(J(e))}catch(e){}return null}function J(e){if("0x"===e)return null;const t=o.a.from(Object(b.hexDataSlice)(e,0,32)).toNumber(),r=o.a.from(Object(b.hexDataSlice)(e,t,t+32)).toNumber();return Object(b.hexDataSlice)(e,t+32,t+32+r)}function X(e){return e.match(/^ipfs:\/\/ipfs\//i)?e=e.substring(12):e.match(/^ipfs:\/\//i)?e=e.substring(7):B.throwArgumentError("unsupported IPFS format","link",e),`https://gateway.ipfs.io/ipfs/${e}`}class Z{constructor(e,t,r,n){Object(g.defineReadOnly)(this,"provider",e),Object(g.defineReadOnly)(this,"name",r),Object(g.defineReadOnly)(this,"address",e.formatter.address(t)),Object(g.defineReadOnly)(this,"_resolvedAddress",n)}_fetchBytes(e,t){return D(this,void 0,void 0,(function*(){const r={to:this.address,data:Object(b.hexConcat)([e,Object(y.b)(this.name),t||"0x"])};try{return J(yield this.provider.call(r))}catch(e){return e.code,T.Logger.errors.CALL_EXCEPTION,null}}))}_getAddress(e,t){const r=z[String(e)];if(null==r&&B.throwError(`unsupported coin type: ${e}`,T.Logger.errors.UNSUPPORTED_OPERATION,{operation:`getAddress(${e})`}),"eth"===r.ilk)return this.provider.formatter.address(t);const n=Object(b.arrayify)(t);if(null!=r.p2pkh){const e=t.match(/^0x76a9([0-9a-f][0-9a-f])([0-9a-f]*)88ac$/);if(e){const t=parseInt(e[1],16);if(e[2].length===2*t&&t>=1&&t<=75)return G(Object(b.concat)([[r.p2pkh],"0x"+e[2]]))}}if(null!=r.p2sh){const e=t.match(/^0xa9([0-9a-f][0-9a-f])([0-9a-f]*)87$/);if(e){const t=parseInt(e[1],16);if(e[2].length===2*t&&t>=1&&t<=75)return G(Object(b.concat)([[r.p2sh],"0x"+e[2]]))}}if(null!=r.prefix){const e=n[1];let t=n[0];if(0===t?20!==e&&32!==e&&(t=-1):t=-1,t>=0&&n.length===2+e&&e>=1&&e<=75){const e=A.a.toWords(n.slice(2));return e.unshift(t),A.a.encode(r.prefix,e)}}return null}getAddress(e){return D(this,void 0,void 0,(function*(){if(null==e&&(e=60),60===e)try{const e={to:this.address,data:"0x3b3b57de"+Object(y.b)(this.name).substring(2)},t=yield this.provider.call(e);return"0x"===t||t===m.a?null:this.provider.formatter.callAddress(t)}catch(e){if(e.code===T.Logger.errors.CALL_EXCEPTION)return null;throw e}const t=yield this._fetchBytes("0xf1cb7e06",V(e));if(null==t||"0x"===t)return null;const r=this._getAddress(e,t);return null==r&&B.throwError("invalid or unsupported coin data",T.Logger.errors.UNSUPPORTED_OPERATION,{operation:`getAddress(${e})`,coinType:e,data:t}),r}))}getAvatar(){return D(this,void 0,void 0,(function*(){const e=[{type:"name",content:this.name}];try{const t=yield this.getText("avatar");if(null==t)return null;for(let r=0;r<W.length;r++){const n=t.match(W[r]);if(null==n)continue;const f=n[1].toLowerCase();switch(f){case"https":return e.push({type:"url",content:t}),{linkage:e,url:t};case"data":return e.push({type:"data",content:t}),{linkage:e,url:t};case"ipfs":return e.push({type:"ipfs",content:t}),{linkage:e,url:X(t)};case"erc721":case"erc1155":{const r="erc721"===f?"0xc87b56dd":"0x0e89341c";e.push({type:f,content:t});const a=this._resolvedAddress||(yield this.getAddress()),i=(n[2]||"").split("/");if(2!==i.length)return null;const s=yield this.provider.formatter.address(i[0]),c=Object(b.hexZeroPad)(o.a.from(i[1]).toHexString(),32);if("erc721"===f){const t=this.provider.formatter.callAddress(yield this.provider.call({to:s,data:Object(b.hexConcat)(["0x6352211e",c])}));if(a!==t)return null;e.push({type:"owner",content:t})}else if("erc1155"===f){const t=o.a.from(yield this.provider.call({to:s,data:Object(b.hexConcat)(["0x00fdd58e",Object(b.hexZeroPad)(a,32),c])}));if(t.isZero())return null;e.push({type:"balance",content:t.toString()})}const u={to:this.provider.formatter.address(i[0]),data:Object(b.hexConcat)([r,c])};let d=Y(yield this.provider.call(u));if(null==d)return null;e.push({type:"metadata-url-base",content:d}),"erc1155"===f&&(d=d.replace("{id}",c.substring(2)),e.push({type:"metadata-url-expanded",content:d})),d.match(/^ipfs:/i)&&(d=X(d)),e.push({type:"metadata-url",content:d});const l=yield Object(w.fetchJson)(d);if(!l)return null;e.push({type:"metadata",content:JSON.stringify(l)});let p=l.image;if("string"!=typeof p)return null;if(p.match(/^(https:\/\/|data:)/i));else{if(null==p.match(K))return null;e.push({type:"url-ipfs",content:p}),p=X(p)}return e.push({type:"url",content:p}),{linkage:e,url:p}}}}}catch(e){}return null}))}getContentHash(){return D(this,void 0,void 0,(function*(){const e=yield this._fetchBytes("0xbc1c58d1");if(null==e||"0x"===e)return null;const t=e.match(/^0xe3010170(([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])([0-9a-f]*))$/);if(t){const e=parseInt(t[3],16);if(t[4].length===2*e)return"ipfs://"+h.Base58.encode("0x"+t[1])}const r=e.match(/^0xe40101fa011b20([0-9a-f]*)$/);return r&&64===r[1].length?"bzz://"+r[1]:B.throwError("invalid or unsupported content hash data",T.Logger.errors.UNSUPPORTED_OPERATION,{operation:"getContentHash()",data:e})}))}getText(e){return D(this,void 0,void 0,(function*(){let t=Object(_.f)(e);t=Object(b.concat)([V(64),V(t.length),t]),t.length%32!=0&&(t=Object(b.concat)([t,Object(b.hexZeroPad)("0x",32-e.length%32)]));const r=yield this._fetchBytes("0x59d1d43c",Object(b.hexlify)(t));return null==r||"0x"===r?null:Object(_.h)(r)}))}}let Q=null,ee=1;class te extends l.b{constructor(e){if(B.checkNew(new.target,l.b),super(),this._events=[],this._emitted={block:-2},this.formatter=new.target.getFormatter(),Object(g.defineReadOnly)(this,"anyNetwork","any"===e),this.anyNetwork&&(e=this.detectNetwork()),e instanceof Promise)this._networkPromise=e,e.catch((e=>{})),this._ready().catch((e=>{}));else{const t=Object(g.getStatic)(new.target,"getNetwork")(e);t?(Object(g.defineReadOnly)(this,"_network",t),this.emit("network",t,null)):B.throwArgumentError("invalid network","network",e)}this._maxInternalBlockNumber=-1024,this._lastBlockNumber=-2,this._pollingInterval=4e3,this._fastQueryDate=0}_ready(){return D(this,void 0,void 0,(function*(){if(null==this._network){let e=null;if(this._networkPromise)try{e=yield this._networkPromise}catch(e){}null==e&&(e=yield this.detectNetwork()),e||B.throwError("no network detected",T.Logger.errors.UNKNOWN_ERROR,{}),null==this._network&&(this.anyNetwork?this._network=e:Object(g.defineReadOnly)(this,"_network",e),this.emit("network",e,null))}return this._network}))}get ready(){return Object(w.poll)((()=>this._ready().then((e=>e),(e=>{if(e.code!==T.Logger.errors.NETWORK_ERROR||"noNetwork"!==e.event)throw e}))))}static getFormatter(){return null==Q&&(Q=new P),Q}static getNetwork(e){return Object(p.a)(null==e?"homestead":e)}_getInternalBlockNumber(e){return D(this,void 0,void 0,(function*(){if(yield this._ready(),e>0)for(;this._internalBlockNumber;){const t=this._internalBlockNumber;try{const r=yield t;if(U()-r.respTime<=e)return r.blockNumber;break}catch(e){if(this._internalBlockNumber===t)break}}const t=U(),r=Object(g.resolveProperties)({blockNumber:this.perform("getBlockNumber",{}),networkError:this.getNetwork().then((e=>null),(e=>e))}).then((({blockNumber:e,networkError:n})=>{if(n)throw this._internalBlockNumber===r&&(this._internalBlockNumber=null),n;const f=U();return(e=o.a.from(e).toNumber())<this._maxInternalBlockNumber&&(e=this._maxInternalBlockNumber),this._maxInternalBlockNumber=e,this._setFastBlockNumber(e),{blockNumber:e,reqTime:t,respTime:f}}));return this._internalBlockNumber=r,r.catch((e=>{this._internalBlockNumber===r&&(this._internalBlockNumber=null)})),(yield r).blockNumber}))}poll(){return D(this,void 0,void 0,(function*(){const e=ee++,t=[];let r=null;try{r=yield this._getInternalBlockNumber(100+this.pollingInterval/2)}catch(e){return void this.emit("error",e)}if(this._setFastBlockNumber(r),this.emit("poll",e,r),r!==this._lastBlockNumber){if(-2===this._emitted.block&&(this._emitted.block=r-1),Math.abs(this._emitted.block-r)>1e3)B.warn(`network block skew detected; skipping block events (emitted=${this._emitted.block} blockNumber${r})`),this.emit("error",B.makeError("network block skew detected",T.Logger.errors.NETWORK_ERROR,{blockNumber:r,event:"blockSkew",previousBlockNumber:this._emitted.block})),this.emit("block",r);else for(let e=this._emitted.block+1;e<=r;e++)this.emit("block",e);this._emitted.block!==r&&(this._emitted.block=r,Object.keys(this._emitted).forEach((e=>{if("block"===e)return;const t=this._emitted[e];"pending"!==t&&r-t>12&&delete this._emitted[e]}))),-2===this._lastBlockNumber&&(this._lastBlockNumber=r-1),this._events.forEach((e=>{switch(e.type){case"tx":{const r=e.hash;let n=this.getTransactionReceipt(r).then((e=>e&&null!=e.blockNumber?(this._emitted["t:"+r]=e.blockNumber,this.emit(r,e),null):null)).catch((e=>{this.emit("error",e)}));t.push(n);break}case"filter":{const n=e.filter;n.fromBlock=this._lastBlockNumber+1,n.toBlock=r;const f=this.getLogs(n).then((e=>{0!==e.length&&e.forEach((e=>{this._emitted["b:"+e.blockHash]=e.blockNumber,this._emitted["t:"+e.transactionHash]=e.blockNumber,this.emit(n,e)}))})).catch((e=>{this.emit("error",e)}));t.push(f);break}}})),this._lastBlockNumber=r,Promise.all(t).then((()=>{this.emit("didPoll",e)})).catch((e=>{this.emit("error",e)}))}else this.emit("didPoll",e)}))}resetEventsBlock(e){this._lastBlockNumber=e-1,this.polling&&this.poll()}get network(){return this._network}detectNetwork(){return D(this,void 0,void 0,(function*(){return B.throwError("provider does not support network detection",T.Logger.errors.UNSUPPORTED_OPERATION,{operation:"provider.detectNetwork"})}))}getNetwork(){return D(this,void 0,void 0,(function*(){const e=yield this._ready(),t=yield this.detectNetwork();if(e.chainId!==t.chainId){if(this.anyNetwork)return this._network=t,this._lastBlockNumber=-2,this._fastBlockNumber=null,this._fastBlockNumberPromise=null,this._fastQueryDate=0,this._emitted.block=-2,this._maxInternalBlockNumber=-1024,this._internalBlockNumber=null,this.emit("network",t,e),yield q(0),this._network;const r=B.makeError("underlying network changed",T.Logger.errors.NETWORK_ERROR,{event:"changed",network:e,detectedNetwork:t});throw this.emit("error",r),r}return e}))}get blockNumber(){return this._getInternalBlockNumber(100+this.pollingInterval/2).then((e=>{this._setFastBlockNumber(e)}),(e=>{})),null!=this._fastBlockNumber?this._fastBlockNumber:-1}get polling(){return null!=this._poller}set polling(e){e&&!this._poller?(this._poller=setInterval((()=>{this.poll()}),this.pollingInterval),this._bootstrapPoll||(this._bootstrapPoll=setTimeout((()=>{this.poll(),this._bootstrapPoll=setTimeout((()=>{this._poller||this.poll(),this._bootstrapPoll=null}),this.pollingInterval)}),0))):!e&&this._poller&&(clearInterval(this._poller),this._poller=null)}get pollingInterval(){return this._pollingInterval}set pollingInterval(e){if("number"!=typeof e||e<=0||parseInt(String(e))!=e)throw new Error("invalid polling interval");this._pollingInterval=e,this._poller&&(clearInterval(this._poller),this._poller=setInterval((()=>{this.poll()}),this._pollingInterval))}_getFastBlockNumber(){const e=U();return e-this._fastQueryDate>2*this._pollingInterval&&(this._fastQueryDate=e,this._fastBlockNumberPromise=this.getBlockNumber().then((e=>((null==this._fastBlockNumber||e>this._fastBlockNumber)&&(this._fastBlockNumber=e),this._fastBlockNumber)))),this._fastBlockNumberPromise}_setFastBlockNumber(e){null!=this._fastBlockNumber&&e<this._fastBlockNumber||(this._fastQueryDate=U(),(null==this._fastBlockNumber||e>this._fastBlockNumber)&&(this._fastBlockNumber=e,this._fastBlockNumberPromise=Promise.resolve(e)))}waitForTransaction(e,t,r){return D(this,void 0,void 0,(function*(){return this._waitForTransaction(e,null==t?1:t,r||0,null)}))}_waitForTransaction(e,t,r,n){return D(this,void 0,void 0,(function*(){const f=yield this.getTransactionReceipt(e);return(f?f.confirmations:0)>=t?f:new Promise(((f,a)=>{const i=[];let o=!1;const s=function(){return!!o||(o=!0,i.forEach((e=>{e()})),!1)},c=e=>{e.confirmations<t||s()||f(e)};if(this.on(e,c),i.push((()=>{this.removeListener(e,c)})),n){let r=n.startBlock,f=null;const c=i=>D(this,void 0,void 0,(function*(){o||(yield q(1e3),this.getTransactionCount(n.from).then((u=>D(this,void 0,void 0,(function*(){if(!o){if(u<=n.nonce)r=i;else{{const t=yield this.getTransaction(e);if(t&&null!=t.blockNumber)return}for(null==f&&(f=r-3,f<n.startBlock&&(f=n.startBlock));f<=i;){if(o)return;const r=yield this.getBlockWithTransactions(f);for(let f=0;f<r.transactions.length;f++){const i=r.transactions[f];if(i.hash===e)return;if(i.from===n.from&&i.nonce===n.nonce){if(o)return;const r=yield this.waitForTransaction(i.hash,t);if(s())return;let f="replaced";return i.data===n.data&&i.to===n.to&&i.value.eq(n.value)?f="repriced":"0x"===i.data&&i.from===i.to&&i.value.isZero()&&(f="cancelled"),void a(B.makeError("transaction was replaced",T.Logger.errors.TRANSACTION_REPLACED,{cancelled:"replaced"===f||"cancelled"===f,reason:f,replacement:this._wrapTransaction(i),hash:e,receipt:r}))}}f++}}o||this.once("block",c)}}))),(e=>{o||this.once("block",c)})))}));if(o)return;this.once("block",c),i.push((()=>{this.removeListener("block",c)}))}if("number"==typeof r&&r>0){const e=setTimeout((()=>{s()||a(B.makeError("timeout exceeded",T.Logger.errors.TIMEOUT,{timeout:r}))}),r);e.unref&&e.unref(),i.push((()=>{clearTimeout(e)}))}}))}))}getBlockNumber(){return D(this,void 0,void 0,(function*(){return this._getInternalBlockNumber(0)}))}getGasPrice(){return D(this,void 0,void 0,(function*(){yield this.getNetwork();const e=yield this.perform("getGasPrice",{});try{return o.a.from(e)}catch(t){return B.throwError("bad result from backend",T.Logger.errors.SERVER_ERROR,{method:"getGasPrice",result:e,error:t})}}))}getBalance(e,t){return D(this,void 0,void 0,(function*(){yield this.getNetwork();const r=yield Object(g.resolveProperties)({address:this._getAddress(e),blockTag:this._getBlockTag(t)}),n=yield this.perform("getBalance",r);try{return o.a.from(n)}catch(e){return B.throwError("bad result from backend",T.Logger.errors.SERVER_ERROR,{method:"getBalance",params:r,result:n,error:e})}}))}getTransactionCount(e,t){return D(this,void 0,void 0,(function*(){yield this.getNetwork();const r=yield Object(g.resolveProperties)({address:this._getAddress(e),blockTag:this._getBlockTag(t)}),n=yield this.perform("getTransactionCount",r);try{return o.a.from(n).toNumber()}catch(e){return B.throwError("bad result from backend",T.Logger.errors.SERVER_ERROR,{method:"getTransactionCount",params:r,result:n,error:e})}}))}getCode(e,t){return D(this,void 0,void 0,(function*(){yield this.getNetwork();const r=yield Object(g.resolveProperties)({address:this._getAddress(e),blockTag:this._getBlockTag(t)}),n=yield this.perform("getCode",r);try{return Object(b.hexlify)(n)}catch(e){return B.throwError("bad result from backend",T.Logger.errors.SERVER_ERROR,{method:"getCode",params:r,result:n,error:e})}}))}getStorageAt(e,t,r){return D(this,void 0,void 0,(function*(){yield this.getNetwork();const n=yield Object(g.resolveProperties)({address:this._getAddress(e),blockTag:this._getBlockTag(r),position:Promise.resolve(t).then((e=>Object(b.hexValue)(e)))}),f=yield this.perform("getStorageAt",n);try{return Object(b.hexlify)(f)}catch(e){return B.throwError("bad result from backend",T.Logger.errors.SERVER_ERROR,{method:"getStorageAt",params:n,result:f,error:e})}}))}_wrapTransaction(e,t,r){if(null!=t&&32!==Object(b.hexDataLength)(t))throw new Error("invalid response - sendTransaction");const n=e;return null!=t&&e.hash!==t&&B.throwError("Transaction hash mismatch from Provider.sendTransaction.",T.Logger.errors.UNKNOWN_ERROR,{expectedHash:e.hash,returnedHash:t}),n.wait=(t,n)=>D(this,void 0,void 0,(function*(){let f;null==t&&(t=1),null==n&&(n=0),0!==t&&null!=r&&(f={data:e.data,from:e.from,nonce:e.nonce,to:e.to,value:e.value,startBlock:r});const a=yield this._waitForTransaction(e.hash,t,n,f);return null==a&&0===t?null:(this._emitted["t:"+e.hash]=a.blockNumber,0===a.status&&B.throwError("transaction failed",T.Logger.errors.CALL_EXCEPTION,{transactionHash:e.hash,transaction:e,receipt:a}),a)})),n}sendTransaction(e){return D(this,void 0,void 0,(function*(){yield this.getNetwork();const t=yield Promise.resolve(e).then((e=>Object(b.hexlify)(e))),r=this.formatter.transaction(e);null==r.confirmations&&(r.confirmations=0);const n=yield this._getInternalBlockNumber(100+2*this.pollingInterval);try{const e=yield this.perform("sendTransaction",{signedTransaction:t});return this._wrapTransaction(r,e,n)}catch(e){throw e.transaction=r,e.transactionHash=r.hash,e}}))}_getTransactionRequest(e){return D(this,void 0,void 0,(function*(){const t=yield e,r={};return["from","to"].forEach((e=>{null!=t[e]&&(r[e]=Promise.resolve(t[e]).then((e=>e?this._getAddress(e):null)))})),["gasLimit","gasPrice","maxFeePerGas","maxPriorityFeePerGas","value"].forEach((e=>{null!=t[e]&&(r[e]=Promise.resolve(t[e]).then((e=>e?o.a.from(e):null)))})),["type"].forEach((e=>{null!=t[e]&&(r[e]=Promise.resolve(t[e]).then((e=>null!=e?e:null)))})),t.accessList&&(r.accessList=this.formatter.accessList(t.accessList)),["data"].forEach((e=>{null!=t[e]&&(r[e]=Promise.resolve(t[e]).then((e=>e?Object(b.hexlify)(e):null)))})),this.formatter.transactionRequest(yield Object(g.resolveProperties)(r))}))}_getFilter(e){return D(this,void 0,void 0,(function*(){e=yield e;const t={};return null!=e.address&&(t.address=this._getAddress(e.address)),["blockHash","topics"].forEach((r=>{null!=e[r]&&(t[r]=e[r])})),["fromBlock","toBlock"].forEach((r=>{null!=e[r]&&(t[r]=this._getBlockTag(e[r]))})),this.formatter.filter(yield Object(g.resolveProperties)(t))}))}call(e,t){return D(this,void 0,void 0,(function*(){yield this.getNetwork();const r=yield Object(g.resolveProperties)({transaction:this._getTransactionRequest(e),blockTag:this._getBlockTag(t)}),n=yield this.perform("call",r);try{return Object(b.hexlify)(n)}catch(e){return B.throwError("bad result from backend",T.Logger.errors.SERVER_ERROR,{method:"call",params:r,result:n,error:e})}}))}estimateGas(e){return D(this,void 0,void 0,(function*(){yield this.getNetwork();const t=yield Object(g.resolveProperties)({transaction:this._getTransactionRequest(e)}),r=yield this.perform("estimateGas",t);try{return o.a.from(r)}catch(e){return B.throwError("bad result from backend",T.Logger.errors.SERVER_ERROR,{method:"estimateGas",params:t,result:r,error:e})}}))}_getAddress(e){return D(this,void 0,void 0,(function*(){"string"!=typeof(e=yield e)&&B.throwArgumentError("invalid address or ENS name","name",e);const t=yield this.resolveName(e);return null==t&&B.throwError("ENS name not configured",T.Logger.errors.UNSUPPORTED_OPERATION,{operation:`resolveName(${JSON.stringify(e)})`}),t}))}_getBlock(e,t){return D(this,void 0,void 0,(function*(){yield this.getNetwork(),e=yield e;let r=-128;const n={includeTransactions:!!t};if(Object(b.isHexString)(e,32))n.blockHash=e;else try{n.blockTag=yield this._getBlockTag(e),Object(b.isHexString)(n.blockTag)&&(r=parseInt(n.blockTag.substring(2),16))}catch(t){B.throwArgumentError("invalid block hash or block tag","blockHashOrBlockTag",e)}return Object(w.poll)((()=>D(this,void 0,void 0,(function*(){const e=yield this.perform("getBlock",n);if(null==e)return null!=n.blockHash&&null==this._emitted["b:"+n.blockHash]||null!=n.blockTag&&r>this._emitted.block?null:void 0;if(t){let t=null;for(let r=0;r<e.transactions.length;r++){const n=e.transactions[r];if(null==n.blockNumber)n.confirmations=0;else if(null==n.confirmations){null==t&&(t=yield this._getInternalBlockNumber(100+2*this.pollingInterval));let e=t-n.blockNumber+1;e<=0&&(e=1),n.confirmations=e}}const r=this.formatter.blockWithTransactions(e);return r.transactions=r.transactions.map((e=>this._wrapTransaction(e))),r}return this.formatter.block(e)}))),{oncePoll:this})}))}getBlock(e){return this._getBlock(e,!1)}getBlockWithTransactions(e){return this._getBlock(e,!0)}getTransaction(e){return D(this,void 0,void 0,(function*(){yield this.getNetwork(),e=yield e;const t={transactionHash:this.formatter.hash(e,!0)};return Object(w.poll)((()=>D(this,void 0,void 0,(function*(){const r=yield this.perform("getTransaction",t);if(null==r)return null==this._emitted["t:"+e]?null:void 0;const n=this.formatter.transactionResponse(r);if(null==n.blockNumber)n.confirmations=0;else if(null==n.confirmations){let e=(yield this._getInternalBlockNumber(100+2*this.pollingInterval))-n.blockNumber+1;e<=0&&(e=1),n.confirmations=e}return this._wrapTransaction(n)}))),{oncePoll:this})}))}getTransactionReceipt(e){return D(this,void 0,void 0,(function*(){yield this.getNetwork(),e=yield e;const t={transactionHash:this.formatter.hash(e,!0)};return Object(w.poll)((()=>D(this,void 0,void 0,(function*(){const r=yield this.perform("getTransactionReceipt",t);if(null==r)return null==this._emitted["t:"+e]?null:void 0;if(null==r.blockHash)return;const n=this.formatter.receipt(r);if(null==n.blockNumber)n.confirmations=0;else if(null==n.confirmations){let e=(yield this._getInternalBlockNumber(100+2*this.pollingInterval))-n.blockNumber+1;e<=0&&(e=1),n.confirmations=e}return n}))),{oncePoll:this})}))}getLogs(e){return D(this,void 0,void 0,(function*(){yield this.getNetwork();const t=yield Object(g.resolveProperties)({filter:this._getFilter(e)}),r=yield this.perform("getLogs",t);return r.forEach((e=>{null==e.removed&&(e.removed=!1)})),P.arrayOf(this.formatter.filterLog.bind(this.formatter))(r)}))}getEtherPrice(){return D(this,void 0,void 0,(function*(){return yield this.getNetwork(),this.perform("getEtherPrice",{})}))}_getBlockTag(e){return D(this,void 0,void 0,(function*(){if("number"==typeof(e=yield e)&&e<0){e%1&&B.throwArgumentError("invalid BlockTag","blockTag",e);let t=yield this._getInternalBlockNumber(100+2*this.pollingInterval);return t+=e,t<0&&(t=0),this.formatter.blockTag(t)}return this.formatter.blockTag(e)}))}getResolver(e){return D(this,void 0,void 0,(function*(){try{const t=yield this._getResolver(e);return null==t?null:new Z(this,t,e)}catch(e){if(e.code===T.Logger.errors.CALL_EXCEPTION)return null;throw e}}))}_getResolver(e){return D(this,void 0,void 0,(function*(){const t=yield this.getNetwork();t.ensAddress||B.throwError("network does not support ENS",T.Logger.errors.UNSUPPORTED_OPERATION,{operation:"ENS",network:t.name});const r={to:t.ensAddress,data:"0x0178b8bf"+Object(y.b)(e).substring(2)};try{return this.formatter.callAddress(yield this.call(r))}catch(e){if(e.code===T.Logger.errors.CALL_EXCEPTION)return null;throw e}}))}resolveName(e){return D(this,void 0,void 0,(function*(){e=yield e;try{return Promise.resolve(this.formatter.address(e))}catch(t){if(Object(b.isHexString)(e))throw t}"string"!=typeof e&&B.throwArgumentError("invalid ENS name","name",e);const t=yield this.getResolver(e);return t?yield t.getAddress():null}))}lookupAddress(e){return D(this,void 0,void 0,(function*(){e=yield e;const t=(e=this.formatter.address(e)).substring(2).toLowerCase()+".addr.reverse",r=yield this._getResolver(t);if(!r)return null;let n=Object(b.arrayify)(yield this.call({to:r,data:"0x691f3431"+Object(y.b)(t).substring(2)}));if(n.length<32||!o.a.from(n.slice(0,32)).eq(32))return null;if(n=n.slice(32),n.length<32)return null;const f=o.a.from(n.slice(0,32)).toNumber();if(n=n.slice(32),f>n.length)return null;const a=Object(_.h)(n.slice(0,f));return(yield this.resolveName(a))!=e?null:a}))}getAvatar(e){return D(this,void 0,void 0,(function*(){let t=null;if(Object(b.isHexString)(e)){const r=this.formatter.address(e),n=r.substring(2).toLowerCase()+".addr.reverse",f=yield this._getResolver(n);if(!f)return null;t=new Z(this,f,"_",r)}else if(t=yield this.getResolver(e),!t)return null;const r=yield t.getAvatar();return null==r?null:r.url}))}perform(e,t){return B.throwError(e+" not implemented",T.Logger.errors.NOT_IMPLEMENTED,{operation:e})}_startEvent(e){this.polling=this._events.filter((e=>e.pollable())).length>0}_stopEvent(e){this.polling=this._events.filter((e=>e.pollable())).length>0}_addEventListener(e,t,r){const n=new $(L(e),t,r);return this._events.push(n),this._startEvent(n),this}on(e,t){return this._addEventListener(e,t,!1)}once(e,t){return this._addEventListener(e,t,!0)}emit(e,...t){let r=!1,n=[],f=L(e);return this._events=this._events.filter((e=>e.tag!==f||(setTimeout((()=>{e.listener.apply(this,t)}),0),r=!0,!e.once||(n.push(e),!1)))),n.forEach((e=>{this._stopEvent(e)})),r}listenerCount(e){if(!e)return this._events.length;let t=L(e);return this._events.filter((e=>e.tag===t)).length}listeners(e){if(null==e)return this._events.map((e=>e.listener));let t=L(e);return this._events.filter((e=>e.tag===t)).map((e=>e.listener))}off(e,t){if(null==t)return this.removeAllListeners(e);const r=[];let n=!1,f=L(e);return this._events=this._events.filter((e=>e.tag!==f||e.listener!=t||(!!n||(n=!0,r.push(e),!1)))),r.forEach((e=>{this._stopEvent(e)})),this}removeAllListeners(e){let t=[];if(null==e)t=this._events,this._events=[];else{const r=L(e);this._events=this._events.filter((e=>e.tag!==r||(t.push(e),!1)))}return t.forEach((e=>{this._stopEvent(e)})),this}}var re=r(190),ne=function(e,t,r,n){return new(r||(r=Promise))((function(f,a){function i(e){try{s(n.next(e))}catch(e){a(e)}}function o(e){try{s(n.throw(e))}catch(e){a(e)}}function s(e){var t;e.done?f(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(i,o)}s((n=n.apply(e,t||[])).next())}))};const fe=new T.Logger(x),ae=["call","estimateGas"];function ie(e,t,r){if("call"===e&&t.code===T.Logger.errors.SERVER_ERROR){const e=t.error;if(e&&e.message.match("reverted")&&Object(b.isHexString)(e.data))return e.data;fe.throwError("missing revert data in call exception",T.Logger.errors.CALL_EXCEPTION,{error:t,data:"0x"})}let n=t.message;t.code===T.Logger.errors.SERVER_ERROR&&t.error&&"string"==typeof t.error.message?n=t.error.message:"string"==typeof t.body?n=t.body:"string"==typeof t.responseText&&(n=t.responseText),n=(n||"").toLowerCase();const f=r.transaction||r.signedTransaction;throw n.match(/insufficient funds|base fee exceeds gas limit/)&&fe.throwError("insufficient funds for intrinsic transaction cost",T.Logger.errors.INSUFFICIENT_FUNDS,{error:t,method:e,transaction:f}),n.match(/nonce too low/)&&fe.throwError("nonce has already been used",T.Logger.errors.NONCE_EXPIRED,{error:t,method:e,transaction:f}),n.match(/replacement transaction underpriced/)&&fe.throwError("replacement fee too low",T.Logger.errors.REPLACEMENT_UNDERPRICED,{error:t,method:e,transaction:f}),n.match(/only replay-protected/)&&fe.throwError("legacy pre-eip-155 transactions not supported",T.Logger.errors.UNSUPPORTED_OPERATION,{error:t,method:e,transaction:f}),ae.indexOf(e)>=0&&n.match(/gas required exceeds allowance|always failing transaction|execution reverted/)&&fe.throwError("cannot estimate gas; transaction may fail or may require manual gas limit",T.Logger.errors.UNPREDICTABLE_GAS_LIMIT,{error:t,method:e,transaction:f}),t}function oe(e){return new Promise((function(t){setTimeout(t,e)}))}function se(e){if(e.error){const t=new Error(e.error.message);throw t.code=e.error.code,t.data=e.error.data,t}return e.result}function ce(e){return e?e.toLowerCase():e}const ue={};class de extends c.a{constructor(e,t,r){if(fe.checkNew(new.target,de),super(),e!==ue)throw new Error("do not call the JsonRpcSigner constructor directly; use provider.getSigner");Object(g.defineReadOnly)(this,"provider",t),null==r&&(r=0),"string"==typeof r?(Object(g.defineReadOnly)(this,"_address",this.provider.formatter.address(r)),Object(g.defineReadOnly)(this,"_index",null)):"number"==typeof r?(Object(g.defineReadOnly)(this,"_index",r),Object(g.defineReadOnly)(this,"_address",null)):fe.throwArgumentError("invalid address or index","addressOrIndex",r)}connect(e){return fe.throwError("cannot alter JSON-RPC Signer connection",T.Logger.errors.UNSUPPORTED_OPERATION,{operation:"connect"})}connectUnchecked(){return new le(ue,this.provider,this._address||this._index)}getAddress(){return this._address?Promise.resolve(this._address):this.provider.send("eth_accounts",[]).then((e=>(e.length<=this._index&&fe.throwError("unknown account #"+this._index,T.Logger.errors.UNSUPPORTED_OPERATION,{operation:"getAddress"}),this.provider.formatter.address(e[this._index]))))}sendUncheckedTransaction(e){e=Object(g.shallowCopy)(e);const t=this.getAddress().then((e=>(e&&(e=e.toLowerCase()),e)));if(null==e.gasLimit){const r=Object(g.shallowCopy)(e);r.from=t,e.gasLimit=this.provider.estimateGas(r)}return null!=e.to&&(e.to=Promise.resolve(e.to).then((e=>ne(this,void 0,void 0,(function*(){if(null==e)return null;const t=yield this.provider.resolveName(e);return null==t&&fe.throwArgumentError("provided ENS name resolves to null","tx.to",e),t}))))),Object(g.resolveProperties)({tx:Object(g.resolveProperties)(e),sender:t}).then((({tx:t,sender:r})=>{null!=t.from?t.from.toLowerCase()!==r&&fe.throwArgumentError("from address mismatch","transaction",e):t.from=r;const n=this.provider.constructor.hexlifyTransaction(t,{from:!0});return this.provider.send("eth_sendTransaction",[n]).then((e=>e),(e=>ie("sendTransaction",e,n)))}))}signTransaction(e){return fe.throwError("signing transactions is unsupported",T.Logger.errors.UNSUPPORTED_OPERATION,{operation:"signTransaction"})}sendTransaction(e){return ne(this,void 0,void 0,(function*(){const t=yield this.provider._getInternalBlockNumber(100+2*this.provider.pollingInterval),r=yield this.sendUncheckedTransaction(e);try{return yield Object(w.poll)((()=>ne(this,void 0,void 0,(function*(){const e=yield this.provider.getTransaction(r);if(null!==e)return this.provider._wrapTransaction(e,r,t)}))),{oncePoll:this.provider})}catch(e){throw e.transactionHash=r,e}}))}signMessage(e){return ne(this,void 0,void 0,(function*(){const t="string"==typeof e?Object(_.f)(e):e,r=yield this.getAddress();return yield this.provider.send("personal_sign",[Object(b.hexlify)(t),r.toLowerCase()])}))}_legacySignMessage(e){return ne(this,void 0,void 0,(function*(){const t="string"==typeof e?Object(_.f)(e):e,r=yield this.getAddress();return yield this.provider.send("eth_sign",[r.toLowerCase(),Object(b.hexlify)(t)])}))}_signTypedData(e,t,r){return ne(this,void 0,void 0,(function*(){const n=yield re.a.resolveNames(e,t,r,(e=>this.provider.resolveName(e))),f=yield this.getAddress();return yield this.provider.send("eth_signTypedData_v4",[f.toLowerCase(),JSON.stringify(re.a.getPayload(n.domain,t,n.value))])}))}unlock(e){return ne(this,void 0,void 0,(function*(){const t=this.provider,r=yield this.getAddress();return t.send("personal_unlockAccount",[r.toLowerCase(),e,null])}))}}class le extends de{sendTransaction(e){return this.sendUncheckedTransaction(e).then((e=>({hash:e,nonce:null,gasLimit:null,gasPrice:null,data:null,value:null,chainId:null,confirmations:0,from:null,wait:t=>this.provider.waitForTransaction(e,t)})))}}const pe={chainId:!0,data:!0,gasLimit:!0,gasPrice:!0,nonce:!0,to:!0,value:!0,type:!0,accessList:!0,maxFeePerGas:!0,maxPriorityFeePerGas:!0};class he extends te{constructor(e,t){fe.checkNew(new.target,he);let r=t;null==r&&(r=new Promise(((e,t)=>{setTimeout((()=>{this.detectNetwork().then((t=>{e(t)}),(e=>{t(e)}))}),0)}))),super(r),e||(e=Object(g.getStatic)(this.constructor,"defaultUrl")()),"string"==typeof e?Object(g.defineReadOnly)(this,"connection",Object.freeze({url:e})):Object(g.defineReadOnly)(this,"connection",Object.freeze(Object(g.shallowCopy)(e))),this._nextId=42}get _cache(){return null==this._eventLoopCache&&(this._eventLoopCache={}),this._eventLoopCache}static defaultUrl(){return"http://localhost:8545"}detectNetwork(){return this._cache.detectNetwork||(this._cache.detectNetwork=this._uncachedDetectNetwork(),setTimeout((()=>{this._cache.detectNetwork=null}),0)),this._cache.detectNetwork}_uncachedDetectNetwork(){return ne(this,void 0,void 0,(function*(){yield oe(0);let e=null;try{e=yield this.send("eth_chainId",[])}catch(t){try{e=yield this.send("net_version",[])}catch(e){}}if(null!=e){const t=Object(g.getStatic)(this.constructor,"getNetwork");try{return t(o.a.from(e).toNumber())}catch(t){return fe.throwError("could not detect network",T.Logger.errors.NETWORK_ERROR,{chainId:e,event:"invalidNetwork",serverError:t})}}return fe.throwError("could not detect network",T.Logger.errors.NETWORK_ERROR,{event:"noNetwork"})}))}getSigner(e){return new de(ue,this,e)}getUncheckedSigner(e){return this.getSigner(e).connectUnchecked()}listAccounts(){return this.send("eth_accounts",[]).then((e=>e.map((e=>this.formatter.address(e)))))}send(e,t){const r={method:e,params:t,id:this._nextId++,jsonrpc:"2.0"};this.emit("debug",{action:"request",request:Object(g.deepCopy)(r),provider:this});const n=["eth_chainId","eth_blockNumber"].indexOf(e)>=0;if(n&&this._cache[e])return this._cache[e];const f=Object(w.fetchJson)(this.connection,JSON.stringify(r),se).then((e=>(this.emit("debug",{action:"response",request:r,response:e,provider:this}),e)),(e=>{throw this.emit("debug",{action:"response",error:e,request:r,provider:this}),e}));return n&&(this._cache[e]=f,setTimeout((()=>{this._cache[e]=null}),0)),f}prepareRequest(e,t){switch(e){case"getBlockNumber":return["eth_blockNumber",[]];case"getGasPrice":return["eth_gasPrice",[]];case"getBalance":return["eth_getBalance",[ce(t.address),t.blockTag]];case"getTransactionCount":return["eth_getTransactionCount",[ce(t.address),t.blockTag]];case"getCode":return["eth_getCode",[ce(t.address),t.blockTag]];case"getStorageAt":return["eth_getStorageAt",[ce(t.address),t.position,t.blockTag]];case"sendTransaction":return["eth_sendRawTransaction",[t.signedTransaction]];case"getBlock":return t.blockTag?["eth_getBlockByNumber",[t.blockTag,!!t.includeTransactions]]:t.blockHash?["eth_getBlockByHash",[t.blockHash,!!t.includeTransactions]]:null;case"getTransaction":return["eth_getTransactionByHash",[t.transactionHash]];case"getTransactionReceipt":return["eth_getTransactionReceipt",[t.transactionHash]];case"call":return["eth_call",[Object(g.getStatic)(this.constructor,"hexlifyTransaction")(t.transaction,{from:!0}),t.blockTag]];case"estimateGas":return["eth_estimateGas",[Object(g.getStatic)(this.constructor,"hexlifyTransaction")(t.transaction,{from:!0})]];case"getLogs":return t.filter&&null!=t.filter.address&&(t.filter.address=ce(t.filter.address)),["eth_getLogs",[t.filter]]}return null}perform(e,t){return ne(this,void 0,void 0,(function*(){if("call"===e||"estimateGas"===e){const e=t.transaction;if(e&&null!=e.type&&o.a.from(e.type).isZero()&&null==e.maxFeePerGas&&null==e.maxPriorityFeePerGas){const r=yield this.getFeeData();null==r.maxFeePerGas&&null==r.maxPriorityFeePerGas&&((t=Object(g.shallowCopy)(t)).transaction=Object(g.shallowCopy)(e),delete t.transaction.type)}}const r=this.prepareRequest(e,t);null==r&&fe.throwError(e+" not implemented",T.Logger.errors.NOT_IMPLEMENTED,{operation:e});try{return yield this.send(r[0],r[1])}catch(r){return ie(e,r,t)}}))}_startEvent(e){"pending"===e.tag&&this._startPending(),super._startEvent(e)}_startPending(){if(null!=this._pendingFilter)return;const e=this,t=this.send("eth_newPendingTransactionFilter",[]);this._pendingFilter=t,t.then((function(r){return function n(){e.send("eth_getFilterChanges",[r]).then((function(r){if(e._pendingFilter!=t)return null;let n=Promise.resolve();return r.forEach((function(t){e._emitted["t:"+t.toLowerCase()]="pending",n=n.then((function(){return e.getTransaction(t).then((function(t){return e.emit("pending",t),null}))}))})),n.then((function(){return oe(1e3)}))})).then((function(){if(e._pendingFilter==t)return setTimeout((function(){n()}),0),null;e.send("eth_uninstallFilter",[r])})).catch((e=>{}))}(),r})).catch((e=>{}))}_stopEvent(e){"pending"===e.tag&&0===this.listenerCount("pending")&&(this._pendingFilter=null),super._stopEvent(e)}static hexlifyTransaction(e,t){const r=Object(g.shallowCopy)(pe);if(t)for(const e in t)t[e]&&(r[e]=!0);Object(g.checkProperties)(e,r);const n={};return["gasLimit","gasPrice","type","maxFeePerGas","maxPriorityFeePerGas","nonce","value"].forEach((function(t){if(null==e[t])return;const r=Object(b.hexValue)(e[t]);"gasLimit"===t&&(t="gas"),n[t]=r})),["from","to","data"].forEach((function(t){null!=e[t]&&(n[t]=Object(b.hexlify)(e[t]))})),e.accessList&&(n.accessList=Object(O.accessListify)(e.accessList)),n}}let be=null;try{if(be=WebSocket,null==be)throw new Error("inject please")}catch(e){const t=new T.Logger(x);be=function(){t.throwError("WebSockets not supported in this environment",T.Logger.errors.UNSUPPORTED_OPERATION,{operation:"new WebSocket()"})}}var me=function(e,t,r,n){return new(r||(r=Promise))((function(f,a){function i(e){try{s(n.next(e))}catch(e){a(e)}}function o(e){try{s(n.throw(e))}catch(e){a(e)}}function s(e){var t;e.done?f(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(i,o)}s((n=n.apply(e,t||[])).next())}))};const ye=new T.Logger(x);let ge=1;class ve extends he{constructor(e,t){"any"===t&&ye.throwError("WebSocketProvider does not support 'any' network yet",T.Logger.errors.UNSUPPORTED_OPERATION,{operation:"network:any"}),super(e,t),this._pollingInterval=-1,this._wsReady=!1,Object(g.defineReadOnly)(this,"_websocket",new be(this.connection.url)),Object(g.defineReadOnly)(this,"_requests",{}),Object(g.defineReadOnly)(this,"_subs",{}),Object(g.defineReadOnly)(this,"_subIds",{}),Object(g.defineReadOnly)(this,"_detectNetwork",super.detectNetwork()),this._websocket.onopen=()=>{this._wsReady=!0,Object.keys(this._requests).forEach((e=>{this._websocket.send(this._requests[e].payload)}))},this._websocket.onmessage=e=>{const t=e.data,r=JSON.parse(t);if(null!=r.id){const e=String(r.id),n=this._requests[e];if(delete this._requests[e],void 0!==r.result)n.callback(null,r.result),this.emit("debug",{action:"response",request:JSON.parse(n.payload),response:r.result,provider:this});else{let e=null;r.error?(e=new Error(r.error.message||"unknown error"),Object(g.defineReadOnly)(e,"code",r.error.code||null),Object(g.defineReadOnly)(e,"response",t)):e=new Error("unknown error"),n.callback(e,void 0),this.emit("debug",{action:"response",error:e,request:JSON.parse(n.payload),provider:this})}}else if("eth_subscription"===r.method){const e=this._subs[r.params.subscription];e&&e.processFunc(r.params.result)}else console.warn("this should not happen")};const r=setInterval((()=>{this.emit("poll")}),1e3);r.unref&&r.unref()}detectNetwork(){return this._detectNetwork}get pollingInterval(){return 0}resetEventsBlock(e){ye.throwError("cannot reset events block on WebSocketProvider",T.Logger.errors.UNSUPPORTED_OPERATION,{operation:"resetEventBlock"})}set pollingInterval(e){ye.throwError("cannot set polling interval on WebSocketProvider",T.Logger.errors.UNSUPPORTED_OPERATION,{operation:"setPollingInterval"})}poll(){return me(this,void 0,void 0,(function*(){return null}))}set polling(e){e&&ye.throwError("cannot set polling on WebSocketProvider",T.Logger.errors.UNSUPPORTED_OPERATION,{operation:"setPolling"})}send(e,t){const r=ge++;return new Promise(((n,f)=>{const a=JSON.stringify({method:e,params:t,id:r,jsonrpc:"2.0"});this.emit("debug",{action:"request",request:JSON.parse(a),provider:this}),this._requests[String(r)]={callback:function(e,t){return e?f(e):n(t)},payload:a},this._wsReady&&this._websocket.send(a)}))}static defaultUrl(){return"ws://localhost:8546"}_subscribe(e,t,r){return me(this,void 0,void 0,(function*(){let n=this._subIds[e];null==n&&(n=Promise.all(t).then((e=>this.send("eth_subscribe",e))),this._subIds[e]=n);const f=yield n;this._subs[f]={tag:e,processFunc:r}}))}_startEvent(e){switch(e.type){case"block":this._subscribe("block",["newHeads"],(e=>{const t=o.a.from(e.number).toNumber();this._emitted.block=t,this.emit("block",t)}));break;case"pending":this._subscribe("pending",["newPendingTransactions"],(e=>{this.emit("pending",e)}));break;case"filter":this._subscribe(e.tag,["logs",this._getFilter(e.filter)],(t=>{null==t.removed&&(t.removed=!1),this.emit(e.filter,this.formatter.filterLog(t))}));break;case"tx":{const t=e=>{const t=e.hash;this.getTransactionReceipt(t).then((e=>{e&&this.emit(t,e)}))};t(e),this._subscribe("tx",["newHeads"],(e=>{this._events.filter((e=>"tx"===e.type)).forEach(t)}));break}case"debug":case"poll":case"willPoll":case"didPoll":case"error":break;default:console.log("unhandled:",e)}}_stopEvent(e){let t=e.tag;if("tx"===e.type){if(this._events.filter((e=>"tx"===e.type)).length)return;t="tx"}else if(this.listenerCount(e.event))return;const r=this._subIds[t];r&&(delete this._subIds[t],r.then((e=>{this._subs[e]&&(delete this._subs[e],this.send("eth_unsubscribe",[e]))})))}destroy(){return me(this,void 0,void 0,(function*(){this._websocket.readyState===be.CONNECTING&&(yield new Promise((e=>{this._websocket.onopen=function(){e(!0)},this._websocket.onerror=function(){e(!1)}}))),this._websocket.close(1e3)}))}}var _e=function(e,t,r,n){return new(r||(r=Promise))((function(f,a){function i(e){try{s(n.next(e))}catch(e){a(e)}}function o(e){try{s(n.throw(e))}catch(e){a(e)}}function s(e){var t;e.done?f(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(i,o)}s((n=n.apply(e,t||[])).next())}))};const we=new T.Logger(x);class Ee extends he{detectNetwork(){const e=Object.create(null,{detectNetwork:{get:()=>super.detectNetwork}});return _e(this,void 0,void 0,(function*(){let t=this.network;return null==t&&(t=yield e.detectNetwork.call(this),t||we.throwError("no network detected",T.Logger.errors.UNKNOWN_ERROR,{}),null==this._network&&(Object(g.defineReadOnly)(this,"_network",t),this.emit("network",t,null))),t}))}}class Ae extends Ee{constructor(e,t){we.checkAbstract(new.target,Ae),e=Object(g.getStatic)(new.target,"getNetwork")(e),t=Object(g.getStatic)(new.target,"getApiKey")(t);super(Object(g.getStatic)(new.target,"getUrl")(e,t),e),"string"==typeof t?Object(g.defineReadOnly)(this,"apiKey",t):null!=t&&Object.keys(t).forEach((e=>{Object(g.defineReadOnly)(this,e,t[e])}))}_startPending(){we.warn("WARNING: API provider does not support pending filters")}isCommunityResource(){return!1}getSigner(e){return we.throwError("API provider does not support signing",T.Logger.errors.UNSUPPORTED_OPERATION,{operation:"getSigner"})}listAccounts(){return Promise.resolve([])}static getApiKey(e){return e}static getUrl(e,t){return we.throwError("not implemented; sub-classes must override getUrl",T.Logger.errors.NOT_IMPLEMENTED,{operation:"getUrl"})}}const Te=new T.Logger(x),xe="_gg7wSSi0KMBsdKnGVfHDueq6xMB9EkC";class ke extends ve{constructor(e,t){const r=new Se(e,t);super(r.connection.url.replace(/^http/i,"ws").replace(".alchemyapi.",".ws.alchemyapi."),r.network),Object(g.defineReadOnly)(this,"apiKey",r.apiKey)}isCommunityResource(){return this.apiKey===xe}}class Se extends Ae{static getWebSocketProvider(e,t){return new ke(e,t)}static getApiKey(e){return null==e?xe:(e&&"string"!=typeof e&&Te.throwArgumentError("invalid apiKey","apiKey",e),e)}static getUrl(e,t){let r=null;switch(e.name){case"homestead":r="eth-mainnet.alchemyapi.io/v2/";break;case"ropsten":r="eth-ropsten.alchemyapi.io/v2/";break;case"rinkeby":r="eth-rinkeby.alchemyapi.io/v2/";break;case"goerli":r="eth-goerli.alchemyapi.io/v2/";break;case"kovan":r="eth-kovan.alchemyapi.io/v2/";break;case"matic":r="polygon-mainnet.g.alchemy.com/v2/";break;case"maticmum":r="polygon-mumbai.g.alchemy.com/v2/";break;case"arbitrum":r="arb-mainnet.g.alchemy.com/v2/";break;case"arbitrum-rinkeby":r="arb-rinkeby.g.alchemy.com/v2/";break;case"optimism":r="opt-mainnet.g.alchemy.com/v2/";break;case"optimism-kovan":r="opt-kovan.g.alchemy.com/v2/";break;default:Te.throwArgumentError("unsupported network","network",arguments[0])}return{allowGzip:!0,url:"https://"+r+t,throttleCallback:(e,r)=>(t===xe&&M(),Promise.resolve(!0))}}isCommunityResource(){return this.apiKey===xe}}var Oe=function(e,t,r,n){return new(r||(r=Promise))((function(f,a){function i(e){try{s(n.next(e))}catch(e){a(e)}}function o(e){try{s(n.throw(e))}catch(e){a(e)}}function s(e){var t;e.done?f(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(i,o)}s((n=n.apply(e,t||[])).next())}))};const Ce=new T.Logger(x);class Pe extends Ae{static getApiKey(e){return null!=e&&Ce.throwArgumentError("apiKey not supported for cloudflare","apiKey",e),null}static getUrl(e,t){let r=null;if("homestead"===e.name)r="https://cloudflare-eth.com/";else Ce.throwArgumentError("unsupported network","network",arguments[0]);return r}perform(e,t){const r=Object.create(null,{perform:{get:()=>super.perform}});return Oe(this,void 0,void 0,(function*(){if("getBlockNumber"===e){return(yield r.perform.call(this,"getBlock",{blockTag:"latest"})).number}return r.perform.call(this,e,t)}))}}var Re=function(e,t,r,n){return new(r||(r=Promise))((function(f,a){function i(e){try{s(n.next(e))}catch(e){a(e)}}function o(e){try{s(n.throw(e))}catch(e){a(e)}}function s(e){var t;e.done?f(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(i,o)}s((n=n.apply(e,t||[])).next())}))};const Ne=new T.Logger(x);function Ie(e){const t={};for(let r in e){if(null==e[r])continue;let n=e[r];"type"===r&&0===n||(n={type:!0,gasLimit:!0,gasPrice:!0,maxFeePerGs:!0,maxPriorityFeePerGas:!0,nonce:!0,value:!0}[r]?Object(b.hexValue)(Object(b.hexlify)(n)):"accessList"===r?"["+Object(O.accessListify)(n).map((e=>`{address:"${e.address}",storageKeys:["${e.storageKeys.join('","')}"]}`)).join(",")+"]":Object(b.hexlify)(n),t[r]=n)}return t}function Me(e){if(0==e.status&&("No records found"===e.message||"No transactions found"===e.message))return e.result;if(1!=e.status||"OK"!=e.message){const t=new Error("invalid response");throw t.result=JSON.stringify(e),(e.result||"").toLowerCase().indexOf("rate limit")>=0&&(t.throttleRetry=!0),t}return e.result}function De(e){if(e&&0==e.status&&"NOTOK"==e.message&&(e.result||"").toLowerCase().indexOf("rate limit")>=0){const t=new Error("throttled response");throw t.result=JSON.stringify(e),t.throttleRetry=!0,t}if("2.0"!=e.jsonrpc){const t=new Error("invalid response");throw t.result=JSON.stringify(e),t}if(e.error){const t=new Error(e.error.message||"unknown error");throw e.error.code&&(t.code=e.error.code),e.error.data&&(t.data=e.error.data),t}return e.result}function Be(e){if("pending"===e)throw new Error("pending not supported");return"latest"===e?e:parseInt(e.substring(2),16)}const Fe="9D13ZE7XSBTJ94N9BNJ2MA33VMAY2YPIRB";function je(e,t,r){if("call"===e&&t.code===T.Logger.errors.SERVER_ERROR){const e=t.error;if(e&&(e.message.match(/reverted/i)||e.message.match(/VM execution error/i))){let r=e.data;if(r&&(r="0x"+r.replace(/^.*0x/i,"")),Object(b.isHexString)(r))return r;Ne.throwError("missing revert data in call exception",T.Logger.errors.CALL_EXCEPTION,{error:t,data:"0x"})}}let n=t.message;throw t.code===T.Logger.errors.SERVER_ERROR&&(t.error&&"string"==typeof t.error.message?n=t.error.message:"string"==typeof t.body?n=t.body:"string"==typeof t.responseText&&(n=t.responseText)),n=(n||"").toLowerCase(),n.match(/insufficient funds/)&&Ne.throwError("insufficient funds for intrinsic transaction cost",T.Logger.errors.INSUFFICIENT_FUNDS,{error:t,method:e,transaction:r}),n.match(/same hash was already imported|transaction nonce is too low|nonce too low/)&&Ne.throwError("nonce has already been used",T.Logger.errors.NONCE_EXPIRED,{error:t,method:e,transaction:r}),n.match(/another transaction with same nonce/)&&Ne.throwError("replacement fee too low",T.Logger.errors.REPLACEMENT_UNDERPRICED,{error:t,method:e,transaction:r}),n.match(/execution failed due to an exception|execution reverted/)&&Ne.throwError("cannot estimate gas; transaction may fail or may require manual gas limit",T.Logger.errors.UNPREDICTABLE_GAS_LIMIT,{error:t,method:e,transaction:r}),t}class Le extends te{constructor(e,t){Ne.checkNew(new.target,Le),super(e),Object(g.defineReadOnly)(this,"baseUrl",this.getBaseUrl()),Object(g.defineReadOnly)(this,"apiKey",t||Fe)}getBaseUrl(){switch(this.network?this.network.name:"invalid"){case"homestead":return"https://api.etherscan.io";case"ropsten":return"https://api-ropsten.etherscan.io";case"rinkeby":return"https://api-rinkeby.etherscan.io";case"kovan":return"https://api-kovan.etherscan.io";case"goerli":return"https://api-goerli.etherscan.io"}return Ne.throwArgumentError("unsupported network","network",name)}getUrl(e,t){const r=Object.keys(t).reduce(((e,r)=>{const n=t[r];return null!=n&&(e+=`&${r}=${n}`),e}),""),n=this.apiKey?`&apikey=${this.apiKey}`:"";return`${this.baseUrl}/api?module=${e}${r}${n}`}getPostUrl(){return`${this.baseUrl}/api`}getPostData(e,t){return t.module=e,t.apikey=this.apiKey,t}fetch(e,t,r){return Re(this,void 0,void 0,(function*(){const n=r?this.getPostUrl():this.getUrl(e,t),f=r?this.getPostData(e,t):null,a="proxy"===e?De:Me;this.emit("debug",{action:"request",request:n,provider:this});const i={url:n,throttleSlotInterval:1e3,throttleCallback:(e,t)=>(this.isCommunityResource()&&M(),Promise.resolve(!0))};let o=null;f&&(i.headers={"content-type":"application/x-www-form-urlencoded; charset=UTF-8"},o=Object.keys(f).map((e=>`${e}=${f[e]}`)).join("&"));const s=yield Object(w.fetchJson)(i,o,a||De);return this.emit("debug",{action:"response",request:n,response:Object(g.deepCopy)(s),provider:this}),s}))}detectNetwork(){return Re(this,void 0,void 0,(function*(){return this.network}))}perform(e,t){const r=Object.create(null,{perform:{get:()=>super.perform}});return Re(this,void 0,void 0,(function*(){switch(e){case"getBlockNumber":return this.fetch("proxy",{action:"eth_blockNumber"});case"getGasPrice":return this.fetch("proxy",{action:"eth_gasPrice"});case"getBalance":return this.fetch("account",{action:"balance",address:t.address,tag:t.blockTag});case"getTransactionCount":return this.fetch("proxy",{action:"eth_getTransactionCount",address:t.address,tag:t.blockTag});case"getCode":return this.fetch("proxy",{action:"eth_getCode",address:t.address,tag:t.blockTag});case"getStorageAt":return this.fetch("proxy",{action:"eth_getStorageAt",address:t.address,position:t.position,tag:t.blockTag});case"sendTransaction":return this.fetch("proxy",{action:"eth_sendRawTransaction",hex:t.signedTransaction},!0).catch((e=>je("sendTransaction",e,t.signedTransaction)));case"getBlock":if(t.blockTag)return this.fetch("proxy",{action:"eth_getBlockByNumber",tag:t.blockTag,boolean:t.includeTransactions?"true":"false"});throw new Error("getBlock by blockHash not implemented");case"getTransaction":return this.fetch("proxy",{action:"eth_getTransactionByHash",txhash:t.transactionHash});case"getTransactionReceipt":return this.fetch("proxy",{action:"eth_getTransactionReceipt",txhash:t.transactionHash});case"call":{if("latest"!==t.blockTag)throw new Error("EtherscanProvider does not support blockTag for call");const e=Ie(t.transaction);e.module="proxy",e.action="eth_call";try{return yield this.fetch("proxy",e,!0)}catch(e){return je("call",e,t.transaction)}}case"estimateGas":{const e=Ie(t.transaction);e.module="proxy",e.action="eth_estimateGas";try{return yield this.fetch("proxy",e,!0)}catch(e){return je("estimateGas",e,t.transaction)}}case"getLogs":{const e={action:"getLogs"};if(t.filter.fromBlock&&(e.fromBlock=Be(t.filter.fromBlock)),t.filter.toBlock&&(e.toBlock=Be(t.filter.toBlock)),t.filter.address&&(e.address=t.filter.address),t.filter.topics&&t.filter.topics.length>0&&(t.filter.topics.length>1&&Ne.throwError("unsupported topic count",T.Logger.errors.UNSUPPORTED_OPERATION,{topics:t.filter.topics}),1===t.filter.topics.length)){const r=t.filter.topics[0];"string"==typeof r&&66===r.length||Ne.throwError("unsupported topic format",T.Logger.errors.UNSUPPORTED_OPERATION,{topic0:r}),e.topic0=r}const r=yield this.fetch("logs",e);let n={};for(let e=0;e<r.length;e++){const t=r[e];if(null==t.blockHash){if(null==n[t.blockNumber]){const e=yield this.getBlock(t.blockNumber);e&&(n[t.blockNumber]=e.hash)}t.blockHash=n[t.blockNumber]}}return r}case"getEtherPrice":return"homestead"!==this.network.name?0:parseFloat((yield this.fetch("stats",{action:"ethprice"})).ethusd)}return r.perform.call(this,e,t)}))}getHistory(e,t,r){return Re(this,void 0,void 0,(function*(){const n={action:"txlist",address:yield this.resolveName(e),startblock:null==t?0:t,endblock:null==r?99999999:r,sort:"asc"};return(yield this.fetch("account",n)).map((e=>{["contractAddress","to"].forEach((function(t){""==e[t]&&delete e[t]})),null==e.creates&&null!=e.contractAddress&&(e.creates=e.contractAddress);const t=this.formatter.transactionResponse(e);return e.timeStamp&&(t.timestamp=parseInt(e.timeStamp)),t}))}))}isCommunityResource(){return this.apiKey===Fe}}var Ue=r(192),qe=function(e,t,r,n){return new(r||(r=Promise))((function(f,a){function i(e){try{s(n.next(e))}catch(e){a(e)}}function o(e){try{s(n.throw(e))}catch(e){a(e)}}function s(e){var t;e.done?f(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(i,o)}s((n=n.apply(e,t||[])).next())}))};const He=new T.Logger(x);function $e(){return(new Date).getTime()}function ze(e){let t=null;for(let r=0;r<e.length;r++){const n=e[r];if(null==n)return null;t?t.name===n.name&&t.chainId===n.chainId&&(t.ensAddress===n.ensAddress||null==t.ensAddress&&null==n.ensAddress)||He.throwArgumentError("provider mismatch","networks",e):t=n}return t}function Ve(e,t){e=e.slice().sort();const r=Math.floor(e.length/2);if(e.length%2)return e[r];const n=e[r-1],f=e[r];return null!=t&&Math.abs(n-f)>t?null:(n+f)/2}function Ge(e){if(null===e)return"null";if("number"==typeof e||"boolean"==typeof e)return JSON.stringify(e);if("string"==typeof e)return e;if(o.a.isBigNumber(e))return e.toString();if(Array.isArray(e))return JSON.stringify(e.map((e=>Ge(e))));if("object"==typeof e){const t=Object.keys(e);return t.sort(),"{"+t.map((t=>{let r=e[t];return r="function"==typeof r?"[function]":Ge(r),JSON.stringify(t)+":"+r})).join(",")+"}"}throw new Error("unknown value type: "+typeof e)}let Ke=1;function We(e){let t=null,r=null,n=new Promise((n=>{t=function(){r&&(clearTimeout(r),r=null),n()},r=setTimeout(t,e)}));return{cancel:t,getPromise:function(){return n},wait:e=>(n=n.then(e),n)}}const Ye=[T.Logger.errors.CALL_EXCEPTION,T.Logger.errors.INSUFFICIENT_FUNDS,T.Logger.errors.NONCE_EXPIRED,T.Logger.errors.REPLACEMENT_UNDERPRICED,T.Logger.errors.UNPREDICTABLE_GAS_LIMIT],Je=["address","args","errorArgs","errorSignature","method","transaction"];function Xe(e,t){const r={weight:e.weight};return Object.defineProperty(r,"provider",{get:()=>e.provider}),e.start&&(r.start=e.start),t&&(r.duration=t-e.start),e.done&&(e.error?r.error=e.error:r.result=e.result||null),r}function Ze(e,t,r){let n=Ge;switch(t){case"getBlockNumber":return function(t){const r=t.map((e=>e.result));let n=Ve(t.map((e=>e.result)),2);if(null!=n)return n=Math.ceil(n),r.indexOf(n+1)>=0&&n++,n>=e._highestBlockNumber&&(e._highestBlockNumber=n),e._highestBlockNumber};case"getGasPrice":return function(e){const t=e.map((e=>e.result));return t.sort(),t[Math.floor(t.length/2)]};case"getEtherPrice":return function(e){return Ve(e.map((e=>e.result)))};case"getBalance":case"getTransactionCount":case"getCode":case"getStorageAt":case"call":case"estimateGas":case"getLogs":break;case"getTransaction":case"getTransactionReceipt":n=function(e){return null==e?null:((e=Object(g.shallowCopy)(e)).confirmations=-1,Ge(e))};break;case"getBlock":n=r.includeTransactions?function(e){return null==e?null:((e=Object(g.shallowCopy)(e)).transactions=e.transactions.map((e=>((e=Object(g.shallowCopy)(e)).confirmations=-1,e))),Ge(e))}:function(e){return null==e?null:Ge(e)};break;default:throw new Error("unknown method: "+t)}return function(e,t){return function(r){const n={};r.forEach((t=>{const r=e(t.result);n[r]||(n[r]={count:0,result:t.result}),n[r].count++}));const f=Object.keys(n);for(let e=0;e<f.length;e++){const r=n[f[e]];if(r.count>=t)return r.result}}}(n,e.quorum)}function Qe(e,t){return qe(this,void 0,void 0,(function*(){const r=e.provider;return null!=r.blockNumber&&r.blockNumber>=t||-1===t?r:Object(w.poll)((()=>new Promise(((n,f)=>{setTimeout((function(){return r.blockNumber>=t?n(r):e.cancelled?n(null):n(void 0)}),0)}))),{oncePoll:r})}))}function et(e,t,r,n){return qe(this,void 0,void 0,(function*(){let f=e.provider;switch(r){case"getBlockNumber":case"getGasPrice":return f[r]();case"getEtherPrice":if(f.getEtherPrice)return f.getEtherPrice();break;case"getBalance":case"getTransactionCount":case"getCode":return n.blockTag&&Object(b.isHexString)(n.blockTag)&&(f=yield Qe(e,t)),f[r](n.address,n.blockTag||"latest");case"getStorageAt":return n.blockTag&&Object(b.isHexString)(n.blockTag)&&(f=yield Qe(e,t)),f.getStorageAt(n.address,n.position,n.blockTag||"latest");case"getBlock":return n.blockTag&&Object(b.isHexString)(n.blockTag)&&(f=yield Qe(e,t)),f[n.includeTransactions?"getBlockWithTransactions":"getBlock"](n.blockTag||n.blockHash);case"call":case"estimateGas":return n.blockTag&&Object(b.isHexString)(n.blockTag)&&(f=yield Qe(e,t)),f[r](n.transaction);case"getTransaction":case"getTransactionReceipt":return f[r](n.transactionHash);case"getLogs":{let r=n.filter;return(r.fromBlock&&Object(b.isHexString)(r.fromBlock)||r.toBlock&&Object(b.isHexString)(r.toBlock))&&(f=yield Qe(e,t)),f.getLogs(r)}}return He.throwError("unknown method error",T.Logger.errors.UNKNOWN_ERROR,{method:r,params:n})}))}class tt extends te{constructor(e,t){He.checkNew(new.target,tt),0===e.length&&He.throwArgumentError("missing providers","providers",e);const r=e.map(((e,t)=>{if(l.b.isProvider(e)){const t=N(e)?2e3:750,r=1;return Object.freeze({provider:e,weight:1,stallTimeout:t,priority:r})}const r=Object(g.shallowCopy)(e);null==r.priority&&(r.priority=1),null==r.stallTimeout&&(r.stallTimeout=N(e)?2e3:750),null==r.weight&&(r.weight=1);const n=r.weight;return(n%1||n>512||n<1)&&He.throwArgumentError("invalid weight; must be integer in [1, 512]",`providers[${t}].weight`,n),Object.freeze(r)})),n=r.reduce(((e,t)=>e+t.weight),0);null==t?t=n/2:t>n&&He.throwArgumentError("quorum will always fail; larger than total weight","quorum",t);let f=ze(r.map((e=>e.provider.network)));null==f&&(f=new Promise(((e,t)=>{setTimeout((()=>{this.detectNetwork().then(e,t)}),0)}))),super(f),Object(g.defineReadOnly)(this,"providerConfigs",Object.freeze(r)),Object(g.defineReadOnly)(this,"quorum",t),this._highestBlockNumber=-1}detectNetwork(){return qe(this,void 0,void 0,(function*(){return ze(yield Promise.all(this.providerConfigs.map((e=>e.provider.getNetwork()))))}))}perform(e,t){return qe(this,void 0,void 0,(function*(){if("sendTransaction"===e){const e=yield Promise.all(this.providerConfigs.map((e=>e.provider.sendTransaction(t.signedTransaction).then((e=>e.hash),(e=>e)))));for(let t=0;t<e.length;t++){const r=e[t];if("string"==typeof r)return r}throw e[0]}-1===this._highestBlockNumber&&"getBlockNumber"!==e&&(yield this.getBlockNumber());const r=Ze(this,e,t),n=Object(Ue.a)(this.providerConfigs.map(g.shallowCopy));n.sort(((e,t)=>e.priority-t.priority));const f=this._highestBlockNumber;let a=0,i=!0;for(;;){const o=$e();let s=n.filter((e=>e.runner&&o-e.start<e.stallTimeout)).reduce(((e,t)=>e+t.weight),0);for(;s<this.quorum&&a<n.length;){const r=n[a++],i=Ke++;r.start=$e(),r.staller=We(r.stallTimeout),r.staller.wait((()=>{r.staller=null})),r.runner=et(r,f,e,t).then((n=>{r.done=!0,r.result=n,this.listenerCount("debug")&&this.emit("debug",{action:"request",rid:i,backend:Xe(r,$e()),request:{method:e,params:Object(g.deepCopy)(t)},provider:this})}),(n=>{r.done=!0,r.error=n,this.listenerCount("debug")&&this.emit("debug",{action:"request",rid:i,backend:Xe(r,$e()),request:{method:e,params:Object(g.deepCopy)(t)},provider:this})})),this.listenerCount("debug")&&this.emit("debug",{action:"request",rid:i,backend:Xe(r,null),request:{method:e,params:Object(g.deepCopy)(t)},provider:this}),s+=r.weight}const c=[];n.forEach((e=>{!e.done&&e.runner&&(c.push(e.runner),e.staller&&c.push(e.staller.getPromise()))})),c.length&&(yield Promise.race(c));const u=n.filter((e=>e.done&&null==e.error));if(u.length>=this.quorum){const e=r(u);if(void 0!==e)return n.forEach((e=>{e.staller&&e.staller.cancel(),e.cancelled=!0})),e;i||(yield We(100).getPromise()),i=!1}const d=n.reduce(((e,t)=>{if(!t.done||null==t.error)return e;const r=t.error.code;return Ye.indexOf(r)>=0&&(e[r]||(e[r]={error:t.error,weight:0}),e[r].weight+=t.weight),e}),{});if(Object.keys(d).forEach((e=>{const t=d[e];if(t.weight<this.quorum)return;n.forEach((e=>{e.staller&&e.staller.cancel(),e.cancelled=!0}));const r=t.error,f={};Je.forEach((e=>{null!=r[e]&&(f[e]=r[e])})),He.throwError(r.reason||r.message,e,f)})),0===n.filter((e=>!e.done)).length)break}return n.forEach((e=>{e.staller&&e.staller.cancel(),e.cancelled=!0})),He.throwError("failed to meet quorum",T.Logger.errors.SERVER_ERROR,{method:e,params:t,results:n.map((e=>Xe(e))),provider:this})}))}}const rt=null,nt=new T.Logger(x),ft="84842078b09946638c03157f83405213";class at extends ve{constructor(e,t){const r=new it(e,t),n=r.connection;n.password&&nt.throwError("INFURA WebSocket project secrets unsupported",T.Logger.errors.UNSUPPORTED_OPERATION,{operation:"InfuraProvider.getWebSocketProvider()"});super(n.url.replace(/^http/i,"ws").replace("/v3/","/ws/v3/"),e),Object(g.defineReadOnly)(this,"apiKey",r.projectId),Object(g.defineReadOnly)(this,"projectId",r.projectId),Object(g.defineReadOnly)(this,"projectSecret",r.projectSecret)}isCommunityResource(){return this.projectId===ft}}class it extends Ae{static getWebSocketProvider(e,t){return new at(e,t)}static getApiKey(e){const t={apiKey:ft,projectId:ft,projectSecret:null};return null==e||("string"==typeof e?t.projectId=e:null!=e.projectSecret?(nt.assertArgument("string"==typeof e.projectId,"projectSecret requires a projectId","projectId",e.projectId),nt.assertArgument("string"==typeof e.projectSecret,"invalid projectSecret","projectSecret","[REDACTED]"),t.projectId=e.projectId,t.projectSecret=e.projectSecret):e.projectId&&(t.projectId=e.projectId),t.apiKey=t.projectId),t}static getUrl(e,t){let r=null;switch(e?e.name:"unknown"){case"homestead":r="mainnet.infura.io";break;case"ropsten":r="ropsten.infura.io";break;case"rinkeby":r="rinkeby.infura.io";break;case"kovan":r="kovan.infura.io";break;case"goerli":r="goerli.infura.io";break;case"matic":r="polygon-mainnet.infura.io";break;case"maticmum":r="polygon-mumbai.infura.io";break;case"optimism":r="optimism-mainnet.infura.io";break;case"optimism-kovan":r="optimism-kovan.infura.io";break;case"arbitrum":r="arbitrum-mainnet.infura.io";break;case"arbitrum-rinkeby":r="arbitrum-rinkeby.infura.io";break;default:nt.throwError("unsupported network",T.Logger.errors.INVALID_ARGUMENT,{argument:"network",value:e})}const n={allowGzip:!0,url:"https://"+r+"/v3/"+t.projectId,throttleCallback:(e,r)=>(t.projectId===ft&&M(),Promise.resolve(!0))};return null!=t.projectSecret&&(n.user="",n.password=t.projectSecret),n}isCommunityResource(){return this.projectId===ft}}class ot extends he{send(e,t){const r={method:e,params:t,id:this._nextId++,jsonrpc:"2.0"};null==this._pendingBatch&&(this._pendingBatch=[]);const n={request:r,resolve:null,reject:null},f=new Promise(((e,t)=>{n.resolve=e,n.reject=t}));return this._pendingBatch.push(n),this._pendingBatchAggregator||(this._pendingBatchAggregator=setTimeout((()=>{const e=this._pendingBatch;this._pendingBatch=null,this._pendingBatchAggregator=null;const t=e.map((e=>e.request));return this.emit("debug",{action:"requestBatch",request:Object(g.deepCopy)(t),provider:this}),Object(w.fetchJson)(this.connection,JSON.stringify(t)).then((r=>{this.emit("debug",{action:"response",request:t,response:r,provider:this}),e.forEach(((e,t)=>{const n=r[t];if(n.error){const t=new Error(n.error.message);t.code=n.error.code,t.data=n.error.data,e.reject(t)}else e.resolve(n.result)}))}),(r=>{this.emit("debug",{action:"response",error:r,request:t,provider:this}),e.forEach((e=>{e.reject(r)}))}))}),10)),f}}const st=new T.Logger(x);class ct extends Ae{static getApiKey(e){return e&&"string"!=typeof e&&st.throwArgumentError("invalid apiKey","apiKey",e),e||"ETHERS_JS_SHARED"}static getUrl(e,t){st.warn("NodeSmith will be discontinued on 2019-12-20; please migrate to another platform.");let r=null;switch(e.name){case"homestead":r="https://ethereum.api.nodesmith.io/v1/mainnet/jsonrpc";break;case"ropsten":r="https://ethereum.api.nodesmith.io/v1/ropsten/jsonrpc";break;case"rinkeby":r="https://ethereum.api.nodesmith.io/v1/rinkeby/jsonrpc";break;case"goerli":r="https://ethereum.api.nodesmith.io/v1/goerli/jsonrpc";break;case"kovan":r="https://ethereum.api.nodesmith.io/v1/kovan/jsonrpc";break;default:st.throwArgumentError("unsupported network","network",arguments[0])}return r+"?apiKey="+t}}const ut=new T.Logger(x),dt={homestead:"6004bcd10040261633ade990",ropsten:"6004bd4d0040261633ade991",rinkeby:"6004bda20040261633ade994",goerli:"6004bd860040261633ade992"};class lt extends Ae{constructor(e,t){if(null==t){const r=Object(g.getStatic)(new.target,"getNetwork")(e);if(r){const e=dt[r.name];e&&(t={applicationId:e,loadBalancer:!0})}null==t&&ut.throwError("unsupported network",T.Logger.errors.INVALID_ARGUMENT,{argument:"network",value:e})}super(e,t)}static getApiKey(e){null==e&&ut.throwArgumentError("PocketProvider.getApiKey does not support null apiKey","apiKey",e);const t={applicationId:null,loadBalancer:!1,applicationSecretKey:null};return"string"==typeof e?t.applicationId=e:null!=e.applicationSecretKey?(ut.assertArgument("string"==typeof e.applicationId,"applicationSecretKey requires an applicationId","applicationId",e.applicationId),ut.assertArgument("string"==typeof e.applicationSecretKey,"invalid applicationSecretKey","applicationSecretKey","[REDACTED]"),t.applicationId=e.applicationId,t.applicationSecretKey=e.applicationSecretKey,t.loadBalancer=!!e.loadBalancer):e.applicationId?(ut.assertArgument("string"==typeof e.applicationId,"apiKey.applicationId must be a string","apiKey.applicationId",e.applicationId),t.applicationId=e.applicationId,t.loadBalancer=!!e.loadBalancer):ut.throwArgumentError("unsupported PocketProvider apiKey","apiKey",e),t}static getUrl(e,t){let r=null;switch(e?e.name:"unknown"){case"homestead":r="eth-mainnet.gateway.pokt.network";break;case"ropsten":r="eth-ropsten.gateway.pokt.network";break;case"rinkeby":r="eth-rinkeby.gateway.pokt.network";break;case"goerli":r="eth-goerli.gateway.pokt.network";break;default:ut.throwError("unsupported network",T.Logger.errors.INVALID_ARGUMENT,{argument:"network",value:e})}let n=null;n=t.loadBalancer?`https://${r}/v1/lb/${t.applicationId}`:`https://${r}/v1/${t.applicationId}`;const f={url:n,headers:{}};return null!=t.applicationSecretKey&&(f.user="",f.password=t.applicationSecretKey),f}isCommunityResource(){return this.applicationId===dt[this.network.name]}}const pt=new T.Logger(x);let ht=1;function bt(e,t){const r="Web3LegacyFetcher";return function(e,n){const f={method:e,params:n,id:ht++,jsonrpc:"2.0"};return new Promise(((e,n)=>{this.emit("debug",{action:"request",fetcher:r,request:Object(g.deepCopy)(f),provider:this}),t(f,((t,a)=>{if(t)return this.emit("debug",{action:"response",fetcher:r,error:t,request:f,provider:this}),n(t);if(this.emit("debug",{action:"response",fetcher:r,request:f,response:a,provider:this}),a.error){const e=new Error(a.error.message);return e.code=a.error.code,e.data=a.error.data,n(e)}e(a.result)}))}))}}class mt extends he{constructor(e,t){pt.checkNew(new.target,mt),null==e&&pt.throwArgumentError("missing provider","provider",e);let r=null,n=null,f=null;"function"==typeof e?(r="unknown:",n=e):(r=e.host||e.path||"",!r&&e.isMetaMask&&(r="metamask"),f=e,e.request?(""===r&&(r="eip-1193:"),n=function(e){return function(t,r){null==r&&(r=[]);const n={method:t,params:r};return this.emit("debug",{action:"request",fetcher:"Eip1193Fetcher",request:Object(g.deepCopy)(n),provider:this}),e.request(n).then((e=>(this.emit("debug",{action:"response",fetcher:"Eip1193Fetcher",request:n,response:e,provider:this}),e)),(e=>{throw this.emit("debug",{action:"response",fetcher:"Eip1193Fetcher",request:n,error:e,provider:this}),e}))}}(e)):e.sendAsync?n=bt(0,e.sendAsync.bind(e)):e.send?n=bt(0,e.send.bind(e)):pt.throwArgumentError("unsupported provider","provider",e),r||(r="unknown:")),super(r,t),Object(g.defineReadOnly)(this,"jsonRpcFetchFunc",n),Object(g.defineReadOnly)(this,"provider",f)}send(e,t){return this.jsonRpcFetchFunc(e,t)}}const yt=new T.Logger(x);function gt(e,t){if(null==e&&(e="homestead"),"string"==typeof e){const t=e.match(/^(ws|http)s?:/i);if(t)switch(t[1]){case"http":return new he(e);case"ws":return new ve(e);default:yt.throwArgumentError("unsupported URL scheme","network",e)}}const r=Object(p.a)(e);return r&&r._defaultProvider||yt.throwError("unsupported getDefaultProvider network",T.Logger.errors.NETWORK_ERROR,{operation:"getDefaultProvider",network:e}),r._defaultProvider({FallbackProvider:tt,AlchemyProvider:Se,CloudflareProvider:Pe,EtherscanProvider:Le,InfuraProvider:it,JsonRpcProvider:he,NodesmithProvider:ct,PocketProvider:lt,Web3Provider:mt,IpcProvider:rt},t)}var vt=r(860),_t=r(129);const wt="abi/5.5.0",Et=new T.Logger(wt);function At(e){const t=[],r=function(e,n){if(Array.isArray(n))for(let f in n){const a=e.slice();a.push(f);try{r(a,n[f])}catch(e){t.push({path:a,error:e})}}};return r([],e),t}class Tt{constructor(e,t,r,n){this.name=e,this.type=t,this.localName=r,this.dynamic=n}_throwError(e,t){Et.throwArgumentError(e,this.localName,t)}}class xt{constructor(e){Object(g.defineReadOnly)(this,"wordSize",e||32),this._data=[],this._dataLength=0,this._padding=new Uint8Array(e)}get data(){return Object(b.hexConcat)(this._data)}get length(){return this._dataLength}_writeData(e){return this._data.push(e),this._dataLength+=e.length,e.length}appendWriter(e){return this._writeData(Object(b.concat)(e._data))}writeBytes(e){let t=Object(b.arrayify)(e);const r=t.length%this.wordSize;return r&&(t=Object(b.concat)([t,this._padding.slice(r)])),this._writeData(t)}_getValue(e){let t=Object(b.arrayify)(o.a.from(e));return t.length>this.wordSize&&Et.throwError("value out-of-bounds",T.Logger.errors.BUFFER_OVERRUN,{length:this.wordSize,offset:t.length}),t.length%this.wordSize&&(t=Object(b.concat)([this._padding.slice(t.length%this.wordSize),t])),t}writeValue(e){return this._writeData(this._getValue(e))}writeUpdatableValue(){const e=this._data.length;return this._data.push(this._padding),this._dataLength+=this.wordSize,t=>{this._data[e]=this._getValue(t)}}}class kt{constructor(e,t,r,n){Object(g.defineReadOnly)(this,"_data",Object(b.arrayify)(e)),Object(g.defineReadOnly)(this,"wordSize",t||32),Object(g.defineReadOnly)(this,"_coerceFunc",r),Object(g.defineReadOnly)(this,"allowLoose",n),this._offset=0}get data(){return Object(b.hexlify)(this._data)}get consumed(){return this._offset}static coerce(e,t){let r=e.match("^u?int([0-9]+)$");return r&&parseInt(r[1])<=48&&(t=t.toNumber()),t}coerce(e,t){return this._coerceFunc?this._coerceFunc(e,t):kt.coerce(e,t)}_peekBytes(e,t,r){let n=Math.ceil(t/this.wordSize)*this.wordSize;return this._offset+n>this._data.length&&(this.allowLoose&&r&&this._offset+t<=this._data.length?n=t:Et.throwError("data out-of-bounds",T.Logger.errors.BUFFER_OVERRUN,{length:this._data.length,offset:this._offset+n})),this._data.slice(this._offset,this._offset+n)}subReader(e){return new kt(this._data.slice(this._offset+e),this.wordSize,this._coerceFunc,this.allowLoose)}readBytes(e,t){let r=this._peekBytes(0,e,!!t);return this._offset+=r.length,r.slice(0,e)}readValue(){return o.a.from(this.readBytes(this.wordSize))}}class St extends Tt{constructor(e){super("address","address",e,!1)}defaultValue(){return"0x0000000000000000000000000000000000000000"}encode(e,t){try{t=Object(k.getAddress)(t)}catch(e){this._throwError(e.message,t)}return e.writeValue(t)}decode(e){return Object(k.getAddress)(Object(b.hexZeroPad)(e.readValue().toHexString(),20))}}class Ot extends Tt{constructor(e){super(e.name,e.type,void 0,e.dynamic),this.coder=e}defaultValue(){return this.coder.defaultValue()}encode(e,t){return this.coder.encode(e,t)}decode(e){return this.coder.decode(e)}}const Ct=new T.Logger(wt);function Pt(e,t,r){let n=null;if(Array.isArray(r))n=r;else if(r&&"object"==typeof r){let e={};n=t.map((t=>{const n=t.localName;return n||Ct.throwError("cannot encode object for signature with missing names",T.Logger.errors.INVALID_ARGUMENT,{argument:"values",coder:t,value:r}),e[n]&&Ct.throwError("cannot encode object for signature with duplicate names",T.Logger.errors.INVALID_ARGUMENT,{argument:"values",coder:t,value:r}),e[n]=!0,r[n]}))}else Ct.throwArgumentError("invalid tuple value","tuple",r);t.length!==n.length&&Ct.throwArgumentError("types/value length mismatch","tuple",r);let f=new xt(e.wordSize),a=new xt(e.wordSize),i=[];t.forEach(((e,t)=>{let r=n[t];if(e.dynamic){let t=a.length;e.encode(a,r);let n=f.writeUpdatableValue();i.push((e=>{n(e+t)}))}else e.encode(f,r)})),i.forEach((e=>{e(f.length)}));let o=e.appendWriter(f);return o+=e.appendWriter(a),o}function Rt(e,t){let r=[],n=e.subReader(0);t.forEach((t=>{let f=null;if(t.dynamic){let r=e.readValue(),a=n.subReader(r.toNumber());try{f=t.decode(a)}catch(e){if(e.code===T.Logger.errors.BUFFER_OVERRUN)throw e;f=e,f.baseType=t.name,f.name=t.localName,f.type=t.type}}else try{f=t.decode(e)}catch(e){if(e.code===T.Logger.errors.BUFFER_OVERRUN)throw e;f=e,f.baseType=t.name,f.name=t.localName,f.type=t.type}null!=f&&r.push(f)}));const f=t.reduce(((e,t)=>{const r=t.localName;return r&&(e[r]||(e[r]=0),e[r]++),e}),{});t.forEach(((e,t)=>{let n=e.localName;if(!n||1!==f[n])return;if("length"===n&&(n="_length"),null!=r[n])return;const a=r[t];a instanceof Error?Object.defineProperty(r,n,{enumerable:!0,get:()=>{throw a}}):r[n]=a}));for(let e=0;e<r.length;e++){const t=r[e];t instanceof Error&&Object.defineProperty(r,e,{enumerable:!0,get:()=>{throw t}})}return Object.freeze(r)}class Nt extends Tt{constructor(e,t,r){super("array",e.type+"["+(t>=0?t:"")+"]",r,-1===t||e.dynamic),this.coder=e,this.length=t}defaultValue(){const e=this.coder.defaultValue(),t=[];for(let r=0;r<this.length;r++)t.push(e);return t}encode(e,t){Array.isArray(t)||this._throwError("expected array value",t);let r=this.length;-1===r&&(r=t.length,e.writeValue(t.length)),Ct.checkArgumentCount(t.length,r,"coder array"+(this.localName?" "+this.localName:""));let n=[];for(let e=0;e<t.length;e++)n.push(this.coder);return Pt(e,n,t)}decode(e){let t=this.length;-1===t&&(t=e.readValue().toNumber(),32*t>e._data.length&&Ct.throwError("insufficient data length",T.Logger.errors.BUFFER_OVERRUN,{length:e._data.length,count:t}));let r=[];for(let e=0;e<t;e++)r.push(new Ot(this.coder));return e.coerce(this.name,Rt(e,r))}}class It extends Tt{constructor(e){super("bool","bool",e,!1)}defaultValue(){return!1}encode(e,t){return e.writeValue(t?1:0)}decode(e){return e.coerce(this.type,!e.readValue().isZero())}}class Mt extends Tt{constructor(e,t){super(e,e,t,!0)}defaultValue(){return"0x"}encode(e,t){t=Object(b.arrayify)(t);let r=e.writeValue(t.length);return r+=e.writeBytes(t),r}decode(e){return e.readBytes(e.readValue().toNumber(),!0)}}class Dt extends Mt{constructor(e){super("bytes",e)}decode(e){return e.coerce(this.name,Object(b.hexlify)(super.decode(e)))}}class Bt extends Tt{constructor(e,t){let r="bytes"+String(e);super(r,r,t,!1),this.size=e}defaultValue(){return"0x0000000000000000000000000000000000000000000000000000000000000000".substring(0,2+2*this.size)}encode(e,t){let r=Object(b.arrayify)(t);return r.length!==this.size&&this._throwError("incorrect data length",t),e.writeBytes(r)}decode(e){return e.coerce(this.name,Object(b.hexlify)(e.readBytes(this.size)))}}class Ft extends Tt{constructor(e){super("null","",e,!1)}defaultValue(){return null}encode(e,t){return null!=t&&this._throwError("not null",t),e.writeBytes([])}decode(e){return e.readBytes(0),e.coerce(this.name,null)}}var jt=r(55);class Lt extends Tt{constructor(e,t,r){const n=(t?"int":"uint")+8*e;super(n,n,r,!1),this.size=e,this.signed=t}defaultValue(){return 0}encode(e,t){let r=o.a.from(t),n=jt.b.mask(8*e.wordSize);if(this.signed){let e=n.mask(8*this.size-1);(r.gt(e)||r.lt(e.add(jt.e).mul(jt.d)))&&this._throwError("value out-of-bounds",t)}else(r.lt(jt.h)||r.gt(n.mask(8*this.size)))&&this._throwError("value out-of-bounds",t);return r=r.toTwos(8*this.size).mask(8*this.size),this.signed&&(r=r.fromTwos(8*this.size).toTwos(8*e.wordSize)),e.writeValue(r)}decode(e){let t=e.readValue().mask(8*this.size);return this.signed&&(t=t.fromTwos(8*this.size)),e.coerce(this.name,t)}}class Ut extends Mt{constructor(e){super("string",e)}defaultValue(){return""}encode(e,t){return super.encode(e,Object(_.f)(t))}decode(e){return Object(_.h)(super.decode(e))}}class qt extends Tt{constructor(e,t){let r=!1;const n=[];e.forEach((e=>{e.dynamic&&(r=!0),n.push(e.type)}));super("tuple","tuple("+n.join(",")+")",t,r),this.coders=e}defaultValue(){const e=[];this.coders.forEach((t=>{e.push(t.defaultValue())}));const t=this.coders.reduce(((e,t)=>{const r=t.localName;return r&&(e[r]||(e[r]=0),e[r]++),e}),{});return this.coders.forEach(((r,n)=>{let f=r.localName;f&&1===t[f]&&("length"===f&&(f="_length"),null==e[f]&&(e[f]=e[n]))})),Object.freeze(e)}encode(e,t){return Pt(e,this.coders,t)}decode(e){return e.coerce(this.name,Rt(e,this.coders))}}const Ht=new T.Logger(wt),$t={};let zt={calldata:!0,memory:!0,storage:!0},Vt={calldata:!0,memory:!0};function Gt(e,t){if("bytes"===e||"string"===e){if(zt[t])return!0}else if("address"===e){if("payable"===t)return!0}else if((e.indexOf("[")>=0||"tuple"===e)&&Vt[t])return!0;return(zt[t]||"payable"===t)&&Ht.throwArgumentError("invalid modifier","name",t),!1}function Kt(e,t){for(let r in t)Object(g.defineReadOnly)(e,r,t[r])}const Wt=Object.freeze({sighash:"sighash",minimal:"minimal",full:"full",json:"json"}),Yt=new RegExp(/^(.*)\[([0-9]*)\]$/);class Jt{constructor(e,t){e!==$t&&Ht.throwError("use fromString",T.Logger.errors.UNSUPPORTED_OPERATION,{operation:"new ParamType()"}),Kt(this,t);let r=this.type.match(Yt);Kt(this,r?{arrayLength:parseInt(r[2]||"-1"),arrayChildren:Jt.fromObject({type:r[1],components:this.components}),baseType:"array"}:{arrayLength:null,arrayChildren:null,baseType:null!=this.components?"tuple":this.type}),this._isParamType=!0,Object.freeze(this)}format(e){if(e||(e=Wt.sighash),Wt[e]||Ht.throwArgumentError("invalid format type","format",e),e===Wt.json){let t={type:"tuple"===this.baseType?"tuple":this.type,name:this.name||void 0};return"boolean"==typeof this.indexed&&(t.indexed=this.indexed),this.components&&(t.components=this.components.map((t=>JSON.parse(t.format(e))))),JSON.stringify(t)}let t="";return"array"===this.baseType?(t+=this.arrayChildren.format(e),t+="["+(this.arrayLength<0?"":String(this.arrayLength))+"]"):"tuple"===this.baseType?(e!==Wt.sighash&&(t+=this.type),t+="("+this.components.map((t=>t.format(e))).join(e===Wt.full?", ":",")+")"):t+=this.type,e!==Wt.sighash&&(!0===this.indexed&&(t+=" indexed"),e===Wt.full&&this.name&&(t+=" "+this.name)),t}static from(e,t){return"string"==typeof e?Jt.fromString(e,t):Jt.fromObject(e)}static fromObject(e){return Jt.isParamType(e)?e:new Jt($t,{name:e.name||null,type:or(e.type),indexed:null==e.indexed?null:!!e.indexed,components:e.components?e.components.map(Jt.fromObject):null})}static fromString(e,t){return r=function(e,t){let r=e;function n(t){Ht.throwArgumentError(`unexpected character at position ${t}`,"param",e)}function f(e){let r={type:"",name:"",parent:e,state:{allowType:!0}};return t&&(r.indexed=!1),r}e=e.replace(/\s/g," ");let a={type:"",name:"",state:{allowType:!0}},i=a;for(let r=0;r<e.length;r++){let a=e[r];switch(a){case"(":i.state.allowType&&""===i.type?i.type="tuple":i.state.allowParams||n(r),i.state.allowType=!1,i.type=or(i.type),i.components=[f(i)],i=i.components[0];break;case")":delete i.state,"indexed"===i.name&&(t||n(r),i.indexed=!0,i.name=""),Gt(i.type,i.name)&&(i.name=""),i.type=or(i.type);let e=i;i=i.parent,i||n(r),delete e.parent,i.state.allowParams=!1,i.state.allowName=!0,i.state.allowArray=!0;break;case",":delete i.state,"indexed"===i.name&&(t||n(r),i.indexed=!0,i.name=""),Gt(i.type,i.name)&&(i.name=""),i.type=or(i.type);let o=f(i.parent);i.parent.components.push(o),delete i.parent,i=o;break;case" ":i.state.allowType&&""!==i.type&&(i.type=or(i.type),delete i.state.allowType,i.state.allowName=!0,i.state.allowParams=!0),i.state.allowName&&""!==i.name&&("indexed"===i.name?(t||n(r),i.indexed&&n(r),i.indexed=!0,i.name=""):Gt(i.type,i.name)?i.name="":i.state.allowName=!1);break;case"[":i.state.allowArray||n(r),i.type+=a,i.state.allowArray=!1,i.state.allowName=!1,i.state.readArray=!0;break;case"]":i.state.readArray||n(r),i.type+=a,i.state.readArray=!1,i.state.allowArray=!0,i.state.allowName=!0;break;default:i.state.allowType?(i.type+=a,i.state.allowParams=!0,i.state.allowArray=!0):i.state.allowName?(i.name+=a,delete i.state.allowArray):i.state.readArray?i.type+=a:n(r)}}return i.parent&&Ht.throwArgumentError("unexpected eof","param",e),delete a.state,"indexed"===i.name?(t||n(r.length-7),i.indexed&&n(r.length-7),i.indexed=!0,i.name=""):Gt(i.type,i.name)&&(i.name=""),a.type=or(a.type),a}(e,!!t),Jt.fromObject({name:r.name,type:r.type,indexed:r.indexed,components:r.components});var r}static isParamType(e){return!(null==e||!e._isParamType)}}function Xt(e,t){return function(e){e=e.trim();let t=[],r="",n=0;for(let f=0;f<e.length;f++){let a=e[f];","===a&&0===n?(t.push(r),r=""):(r+=a,"("===a?n++:")"===a&&(n--,-1===n&&Ht.throwArgumentError("unbalanced parenthesis","value",e)))}r&&t.push(r);return t}(e).map((e=>Jt.fromString(e,t)))}class Zt{constructor(e,t){e!==$t&&Ht.throwError("use a static from method",T.Logger.errors.UNSUPPORTED_OPERATION,{operation:"new Fragment()"}),Kt(this,t),this._isFragment=!0,Object.freeze(this)}static from(e){return Zt.isFragment(e)?e:"string"==typeof e?Zt.fromString(e):Zt.fromObject(e)}static fromObject(e){if(Zt.isFragment(e))return e;switch(e.type){case"function":return fr.fromObject(e);case"event":return Qt.fromObject(e);case"constructor":return nr.fromObject(e);case"error":return ir.fromObject(e);case"fallback":case"receive":return null}return Ht.throwArgumentError("invalid fragment object","value",e)}static fromString(e){return"event"===(e=(e=(e=e.replace(/\s/g," ")).replace(/\(/g," (").replace(/\)/g,") ").replace(/\s+/g," ")).trim()).split(" ")[0]?Qt.fromString(e.substring(5).trim()):"function"===e.split(" ")[0]?fr.fromString(e.substring(8).trim()):"constructor"===e.split("(")[0].trim()?nr.fromString(e.trim()):"error"===e.split(" ")[0]?ir.fromString(e.substring(5).trim()):Ht.throwArgumentError("unsupported fragment","value",e)}static isFragment(e){return!(!e||!e._isFragment)}}class Qt extends Zt{format(e){if(e||(e=Wt.sighash),Wt[e]||Ht.throwArgumentError("invalid format type","format",e),e===Wt.json)return JSON.stringify({type:"event",anonymous:this.anonymous,name:this.name,inputs:this.inputs.map((t=>JSON.parse(t.format(e))))});let t="";return e!==Wt.sighash&&(t+="event "),t+=this.name+"("+this.inputs.map((t=>t.format(e))).join(e===Wt.full?", ":",")+") ",e!==Wt.sighash&&this.anonymous&&(t+="anonymous "),t.trim()}static from(e){return"string"==typeof e?Qt.fromString(e):Qt.fromObject(e)}static fromObject(e){if(Qt.isEventFragment(e))return e;"event"!==e.type&&Ht.throwArgumentError("invalid event object","value",e);const t={name:cr(e.name),anonymous:e.anonymous,inputs:e.inputs?e.inputs.map(Jt.fromObject):[],type:"event"};return new Qt($t,t)}static fromString(e){let t=e.match(ur);t||Ht.throwArgumentError("invalid event string","value",e);let r=!1;return t[3].split(" ").forEach((e=>{switch(e.trim()){case"anonymous":r=!0;break;case"":break;default:Ht.warn("unknown modifier: "+e)}})),Qt.fromObject({name:t[1].trim(),anonymous:r,inputs:Xt(t[2],!0),type:"event"})}static isEventFragment(e){return e&&e._isFragment&&"event"===e.type}}function er(e,t){t.gas=null;let r=e.split("@");return 1!==r.length?(r.length>2&&Ht.throwArgumentError("invalid human-readable ABI signature","value",e),r[1].match(/^[0-9]+$/)||Ht.throwArgumentError("invalid human-readable ABI signature gas","value",e),t.gas=o.a.from(r[1]),r[0]):e}function tr(e,t){t.constant=!1,t.payable=!1,t.stateMutability="nonpayable",e.split(" ").forEach((e=>{switch(e.trim()){case"constant":t.constant=!0;break;case"payable":t.payable=!0,t.stateMutability="payable";break;case"nonpayable":t.payable=!1,t.stateMutability="nonpayable";break;case"pure":t.constant=!0,t.stateMutability="pure";break;case"view":t.constant=!0,t.stateMutability="view";break;case"external":case"public":case"":break;default:console.log("unknown modifier: "+e)}}))}function rr(e){let t={constant:!1,payable:!0,stateMutability:"payable"};return null!=e.stateMutability?(t.stateMutability=e.stateMutability,t.constant="view"===t.stateMutability||"pure"===t.stateMutability,null!=e.constant&&!!e.constant!==t.constant&&Ht.throwArgumentError("cannot have constant function with mutability "+t.stateMutability,"value",e),t.payable="payable"===t.stateMutability,null!=e.payable&&!!e.payable!==t.payable&&Ht.throwArgumentError("cannot have payable function with mutability "+t.stateMutability,"value",e)):null!=e.payable?(t.payable=!!e.payable,null!=e.constant||t.payable||"constructor"===e.type||Ht.throwArgumentError("unable to determine stateMutability","value",e),t.constant=!!e.constant,t.constant?t.stateMutability="view":t.stateMutability=t.payable?"payable":"nonpayable",t.payable&&t.constant&&Ht.throwArgumentError("cannot have constant payable function","value",e)):null!=e.constant?(t.constant=!!e.constant,t.payable=!t.constant,t.stateMutability=t.constant?"view":"payable"):"constructor"!==e.type&&Ht.throwArgumentError("unable to determine stateMutability","value",e),t}class nr extends Zt{format(e){if(e||(e=Wt.sighash),Wt[e]||Ht.throwArgumentError("invalid format type","format",e),e===Wt.json)return JSON.stringify({type:"constructor",stateMutability:"nonpayable"!==this.stateMutability?this.stateMutability:void 0,payable:this.payable,gas:this.gas?this.gas.toNumber():void 0,inputs:this.inputs.map((t=>JSON.parse(t.format(e))))});e===Wt.sighash&&Ht.throwError("cannot format a constructor for sighash",T.Logger.errors.UNSUPPORTED_OPERATION,{operation:"format(sighash)"});let t="constructor("+this.inputs.map((t=>t.format(e))).join(e===Wt.full?", ":",")+") ";return this.stateMutability&&"nonpayable"!==this.stateMutability&&(t+=this.stateMutability+" "),t.trim()}static from(e){return"string"==typeof e?nr.fromString(e):nr.fromObject(e)}static fromObject(e){if(nr.isConstructorFragment(e))return e;"constructor"!==e.type&&Ht.throwArgumentError("invalid constructor object","value",e);let t=rr(e);t.constant&&Ht.throwArgumentError("constructor cannot be constant","value",e);const r={name:null,type:e.type,inputs:e.inputs?e.inputs.map(Jt.fromObject):[],payable:t.payable,stateMutability:t.stateMutability,gas:e.gas?o.a.from(e.gas):null};return new nr($t,r)}static fromString(e){let t={type:"constructor"},r=(e=er(e,t)).match(ur);return r&&"constructor"===r[1].trim()||Ht.throwArgumentError("invalid constructor string","value",e),t.inputs=Xt(r[2].trim(),!1),tr(r[3].trim(),t),nr.fromObject(t)}static isConstructorFragment(e){return e&&e._isFragment&&"constructor"===e.type}}class fr extends nr{format(e){if(e||(e=Wt.sighash),Wt[e]||Ht.throwArgumentError("invalid format type","format",e),e===Wt.json)return JSON.stringify({type:"function",name:this.name,constant:this.constant,stateMutability:"nonpayable"!==this.stateMutability?this.stateMutability:void 0,payable:this.payable,gas:this.gas?this.gas.toNumber():void 0,inputs:this.inputs.map((t=>JSON.parse(t.format(e)))),outputs:this.outputs.map((t=>JSON.parse(t.format(e))))});let t="";return e!==Wt.sighash&&(t+="function "),t+=this.name+"("+this.inputs.map((t=>t.format(e))).join(e===Wt.full?", ":",")+") ",e!==Wt.sighash&&(this.stateMutability?"nonpayable"!==this.stateMutability&&(t+=this.stateMutability+" "):this.constant&&(t+="view "),this.outputs&&this.outputs.length&&(t+="returns ("+this.outputs.map((t=>t.format(e))).join(", ")+") "),null!=this.gas&&(t+="@"+this.gas.toString()+" ")),t.trim()}static from(e){return"string"==typeof e?fr.fromString(e):fr.fromObject(e)}static fromObject(e){if(fr.isFunctionFragment(e))return e;"function"!==e.type&&Ht.throwArgumentError("invalid function object","value",e);let t=rr(e);const r={type:e.type,name:cr(e.name),constant:t.constant,inputs:e.inputs?e.inputs.map(Jt.fromObject):[],outputs:e.outputs?e.outputs.map(Jt.fromObject):[],payable:t.payable,stateMutability:t.stateMutability,gas:e.gas?o.a.from(e.gas):null};return new fr($t,r)}static fromString(e){let t={type:"function"},r=(e=er(e,t)).split(" returns ");r.length>2&&Ht.throwArgumentError("invalid function string","value",e);let n=r[0].match(ur);if(n||Ht.throwArgumentError("invalid function signature","value",e),t.name=n[1].trim(),t.name&&cr(t.name),t.inputs=Xt(n[2],!1),tr(n[3].trim(),t),r.length>1){let n=r[1].match(ur);""==n[1].trim()&&""==n[3].trim()||Ht.throwArgumentError("unexpected tokens","value",e),t.outputs=Xt(n[2],!1)}else t.outputs=[];return fr.fromObject(t)}static isFunctionFragment(e){return e&&e._isFragment&&"function"===e.type}}function ar(e){const t=e.format();return"Error(string)"!==t&&"Panic(uint256)"!==t||Ht.throwArgumentError(`cannot specify user defined ${t} error`,"fragment",e),e}class ir extends Zt{format(e){if(e||(e=Wt.sighash),Wt[e]||Ht.throwArgumentError("invalid format type","format",e),e===Wt.json)return JSON.stringify({type:"error",name:this.name,inputs:this.inputs.map((t=>JSON.parse(t.format(e))))});let t="";return e!==Wt.sighash&&(t+="error "),t+=this.name+"("+this.inputs.map((t=>t.format(e))).join(e===Wt.full?", ":",")+") ",t.trim()}static from(e){return"string"==typeof e?ir.fromString(e):ir.fromObject(e)}static fromObject(e){if(ir.isErrorFragment(e))return e;"error"!==e.type&&Ht.throwArgumentError("invalid error object","value",e);const t={type:e.type,name:cr(e.name),inputs:e.inputs?e.inputs.map(Jt.fromObject):[]};return ar(new ir($t,t))}static fromString(e){let t={type:"error"},r=e.match(ur);return r||Ht.throwArgumentError("invalid error signature","value",e),t.name=r[1].trim(),t.name&&cr(t.name),t.inputs=Xt(r[2],!1),ar(ir.fromObject(t))}static isErrorFragment(e){return e&&e._isFragment&&"error"===e.type}}function or(e){return e.match(/^uint($|[^1-9])/)?e="uint256"+e.substring(4):e.match(/^int($|[^1-9])/)&&(e="int256"+e.substring(3)),e}const sr=new RegExp("^[a-zA-Z$_][a-zA-Z0-9$_]*$");function cr(e){return e&&e.match(sr)||Ht.throwArgumentError(`invalid identifier "${e}"`,"value",e),e}const ur=new RegExp("^([^)(]*)\\((.*)\\)([^)(]*)$");const dr=new T.Logger(wt),lr=new RegExp(/^bytes([0-9]*)$/),pr=new RegExp(/^(u?int)([0-9]*)$/);class hr{constructor(e){dr.checkNew(new.target,hr),Object(g.defineReadOnly)(this,"coerceFunc",e||null)}_getCoder(e){switch(e.baseType){case"address":return new St(e.name);case"bool":return new It(e.name);case"string":return new Ut(e.name);case"bytes":return new Dt(e.name);case"array":return new Nt(this._getCoder(e.arrayChildren),e.arrayLength,e.name);case"tuple":return new qt((e.components||[]).map((e=>this._getCoder(e))),e.name);case"":return new Ft(e.name)}let t=e.type.match(pr);if(t){let r=parseInt(t[2]||"256");return(0===r||r>256||r%8!=0)&&dr.throwArgumentError("invalid "+t[1]+" bit length","param",e),new Lt(r/8,"int"===t[1],e.name)}if(t=e.type.match(lr),t){let r=parseInt(t[1]);return(0===r||r>32)&&dr.throwArgumentError("invalid bytes length","param",e),new Bt(r,e.name)}return dr.throwArgumentError("invalid type","type",e.type)}_getWordSize(){return 32}_getReader(e,t){return new kt(e,this._getWordSize(),this.coerceFunc,t)}_getWriter(){return new xt(this._getWordSize())}getDefaultValue(e){const t=e.map((e=>this._getCoder(Jt.from(e))));return new qt(t,"_").defaultValue()}encode(e,t){e.length!==t.length&&dr.throwError("types/values length mismatch",T.Logger.errors.INVALID_ARGUMENT,{count:{types:e.length,values:t.length},value:{types:e,values:t}});const r=e.map((e=>this._getCoder(Jt.from(e)))),n=new qt(r,"_"),f=this._getWriter();return n.encode(f,t),f.data}decode(e,t,r){const n=e.map((e=>this._getCoder(Jt.from(e))));return new qt(n,"_").decode(this._getReader(Object(b.arrayify)(t),r))}}const br=new hr;var mr=r(57),yr=r(28),gr=r.n(yr);function vr(e){return"0x"+gr.a.keccak_256(Object(b.arrayify)(e))}const _r=new T.Logger(wt);class wr extends g.Description{}class Er extends g.Description{}class Ar extends g.Description{}class Tr extends g.Description{static isIndexed(e){return!(!e||!e._isIndexed)}}const xr={"0x08c379a0":{signature:"Error(string)",name:"Error",inputs:["string"],reason:!0},"0x4e487b71":{signature:"Panic(uint256)",name:"Panic",inputs:["uint256"]}};function kr(e,t){const r=new Error(`deferred error during ABI decoding triggered accessing ${e}`);return r.error=t,r}class Sr{constructor(e){_r.checkNew(new.target,Sr);let t=[];t="string"==typeof e?JSON.parse(e):e,Object(g.defineReadOnly)(this,"fragments",t.map((e=>Zt.from(e))).filter((e=>null!=e))),Object(g.defineReadOnly)(this,"_abiCoder",Object(g.getStatic)(new.target,"getAbiCoder")()),Object(g.defineReadOnly)(this,"functions",{}),Object(g.defineReadOnly)(this,"errors",{}),Object(g.defineReadOnly)(this,"events",{}),Object(g.defineReadOnly)(this,"structs",{}),this.fragments.forEach((e=>{let t=null;switch(e.type){case"constructor":return this.deploy?void _r.warn("duplicate definition - constructor"):void Object(g.defineReadOnly)(this,"deploy",e);case"function":t=this.functions;break;case"event":t=this.events;break;case"error":t=this.errors;break;default:return}let r=e.format();t[r]?_r.warn("duplicate definition - "+r):t[r]=e})),this.deploy||Object(g.defineReadOnly)(this,"deploy",nr.from({payable:!1,type:"constructor"})),Object(g.defineReadOnly)(this,"_isInterface",!0)}format(e){e||(e=Wt.full),e===Wt.sighash&&_r.throwArgumentError("interface does not support formatting sighash","format",e);const t=this.fragments.map((t=>t.format(e)));return e===Wt.json?JSON.stringify(t.map((e=>JSON.parse(e)))):t}static getAbiCoder(){return br}static getAddress(e){return Object(k.getAddress)(e)}static getSighash(e){return Object(b.hexDataSlice)(Object(mr.a)(e.format()),0,4)}static getEventTopic(e){return Object(mr.a)(e.format())}getFunction(e){if(Object(b.isHexString)(e)){for(const t in this.functions)if(e===this.getSighash(t))return this.functions[t];_r.throwArgumentError("no matching function","sighash",e)}if(-1===e.indexOf("(")){const t=e.trim(),r=Object.keys(this.functions).filter((e=>e.split("(")[0]===t));return 0===r.length?_r.throwArgumentError("no matching function","name",t):r.length>1&&_r.throwArgumentError("multiple matching functions","name",t),this.functions[r[0]]}const t=this.functions[fr.fromString(e).format()];return t||_r.throwArgumentError("no matching function","signature",e),t}getEvent(e){if(Object(b.isHexString)(e)){const t=e.toLowerCase();for(const e in this.events)if(t===this.getEventTopic(e))return this.events[e];_r.throwArgumentError("no matching event","topichash",t)}if(-1===e.indexOf("(")){const t=e.trim(),r=Object.keys(this.events).filter((e=>e.split("(")[0]===t));return 0===r.length?_r.throwArgumentError("no matching event","name",t):r.length>1&&_r.throwArgumentError("multiple matching events","name",t),this.events[r[0]]}const t=this.events[Qt.fromString(e).format()];return t||_r.throwArgumentError("no matching event","signature",e),t}getError(e){if(Object(b.isHexString)(e)){const t=Object(g.getStatic)(this.constructor,"getSighash");for(const r in this.errors){if(e===t(this.errors[r]))return this.errors[r]}_r.throwArgumentError("no matching error","sighash",e)}if(-1===e.indexOf("(")){const t=e.trim(),r=Object.keys(this.errors).filter((e=>e.split("(")[0]===t));return 0===r.length?_r.throwArgumentError("no matching error","name",t):r.length>1&&_r.throwArgumentError("multiple matching errors","name",t),this.errors[r[0]]}const t=this.errors[fr.fromString(e).format()];return t||_r.throwArgumentError("no matching error","signature",e),t}getSighash(e){if("string"==typeof e)try{e=this.getFunction(e)}catch(t){try{e=this.getError(e)}catch(e){throw t}}return Object(g.getStatic)(this.constructor,"getSighash")(e)}getEventTopic(e){return"string"==typeof e&&(e=this.getEvent(e)),Object(g.getStatic)(this.constructor,"getEventTopic")(e)}_decodeParams(e,t){return this._abiCoder.decode(e,t)}_encodeParams(e,t){return this._abiCoder.encode(e,t)}encodeDeploy(e){return this._encodeParams(this.deploy.inputs,e||[])}decodeErrorResult(e,t){"string"==typeof e&&(e=this.getError(e));const r=Object(b.arrayify)(t);return Object(b.hexlify)(r.slice(0,4))!==this.getSighash(e)&&_r.throwArgumentError(`data signature does not match error ${e.name}.`,"data",Object(b.hexlify)(r)),this._decodeParams(e.inputs,r.slice(4))}encodeErrorResult(e,t){return"string"==typeof e&&(e=this.getError(e)),Object(b.hexlify)(Object(b.concat)([this.getSighash(e),this._encodeParams(e.inputs,t||[])]))}decodeFunctionData(e,t){"string"==typeof e&&(e=this.getFunction(e));const r=Object(b.arrayify)(t);return Object(b.hexlify)(r.slice(0,4))!==this.getSighash(e)&&_r.throwArgumentError(`data signature does not match function ${e.name}.`,"data",Object(b.hexlify)(r)),this._decodeParams(e.inputs,r.slice(4))}encodeFunctionData(e,t){return"string"==typeof e&&(e=this.getFunction(e)),Object(b.hexlify)(Object(b.concat)([this.getSighash(e),this._encodeParams(e.inputs,t||[])]))}decodeFunctionResult(e,t){"string"==typeof e&&(e=this.getFunction(e));let r=Object(b.arrayify)(t),n=null,f=null,a=null,i=null;switch(r.length%this._abiCoder._getWordSize()){case 0:try{return this._abiCoder.decode(e.outputs,r)}catch(e){}break;case 4:{const e=Object(b.hexlify)(r.slice(0,4)),t=xr[e];if(t)f=this._abiCoder.decode(t.inputs,r.slice(4)),a=t.name,i=t.signature,t.reason&&(n=f[0]);else try{const t=this.getError(e);f=this._abiCoder.decode(t.inputs,r.slice(4)),a=t.name,i=t.format()}catch(e){console.log(e)}break}}return _r.throwError("call revert exception",T.Logger.errors.CALL_EXCEPTION,{method:e.format(),errorArgs:f,errorName:a,errorSignature:i,reason:n})}encodeFunctionResult(e,t){return"string"==typeof e&&(e=this.getFunction(e)),Object(b.hexlify)(this._abiCoder.encode(e.outputs,t||[]))}encodeFilterTopics(e,t){"string"==typeof e&&(e=this.getEvent(e)),t.length>e.inputs.length&&_r.throwError("too many arguments for "+e.format(),T.Logger.errors.UNEXPECTED_ARGUMENT,{argument:"values",value:t});let r=[];e.anonymous||r.push(this.getEventTopic(e));const n=(e,t)=>"string"===e.type?Object(mr.a)(t):"bytes"===e.type?vr(Object(b.hexlify)(t)):("address"===e.type&&this._abiCoder.encode(["address"],[t]),Object(b.hexZeroPad)(Object(b.hexlify)(t),32));for(t.forEach(((t,f)=>{let a=e.inputs[f];a.indexed?null==t?r.push(null):"array"===a.baseType||"tuple"===a.baseType?_r.throwArgumentError("filtering with tuples or arrays not supported","contract."+a.name,t):Array.isArray(t)?r.push(t.map((e=>n(a,e)))):r.push(n(a,t)):null!=t&&_r.throwArgumentError("cannot filter non-indexed parameters; must be null","contract."+a.name,t)}));r.length&&null===r[r.length-1];)r.pop();return r}encodeEventLog(e,t){"string"==typeof e&&(e=this.getEvent(e));const r=[],n=[],f=[];return e.anonymous||r.push(this.getEventTopic(e)),t.length!==e.inputs.length&&_r.throwArgumentError("event arguments/values mismatch","values",t),e.inputs.forEach(((e,a)=>{const i=t[a];if(e.indexed)if("string"===e.type)r.push(Object(mr.a)(i));else if("bytes"===e.type)r.push(vr(i));else{if("tuple"===e.baseType||"array"===e.baseType)throw new Error("not implemented");r.push(this._abiCoder.encode([e.type],[i]))}else n.push(e),f.push(i)})),{data:this._abiCoder.encode(n,f),topics:r}}decodeEventLog(e,t,r){if("string"==typeof e&&(e=this.getEvent(e)),null!=r&&!e.anonymous){let t=this.getEventTopic(e);Object(b.isHexString)(r[0],32)&&r[0].toLowerCase()===t||_r.throwError("fragment/topic mismatch",T.Logger.errors.INVALID_ARGUMENT,{argument:"topics[0]",expected:t,value:r[0]}),r=r.slice(1)}let n=[],f=[],a=[];e.inputs.forEach(((e,t)=>{e.indexed?"string"===e.type||"bytes"===e.type||"tuple"===e.baseType||"array"===e.baseType?(n.push(Jt.fromObject({type:"bytes32",name:e.name})),a.push(!0)):(n.push(e),a.push(!1)):(f.push(e),a.push(!1))}));let i=null!=r?this._abiCoder.decode(n,Object(b.concat)(r)):null,o=this._abiCoder.decode(f,t,!0),s=[],c=0,u=0;e.inputs.forEach(((e,t)=>{if(e.indexed)if(null==i)s[t]=new Tr({_isIndexed:!0,hash:null});else if(a[t])s[t]=new Tr({_isIndexed:!0,hash:i[u++]});else try{s[t]=i[u++]}catch(e){s[t]=e}else try{s[t]=o[c++]}catch(e){s[t]=e}if(e.name&&null==s[e.name]){const r=s[t];r instanceof Error?Object.defineProperty(s,e.name,{enumerable:!0,get:()=>{throw kr(`property ${JSON.stringify(e.name)}`,r)}}):s[e.name]=r}}));for(let e=0;e<s.length;e++){const t=s[e];t instanceof Error&&Object.defineProperty(s,e,{enumerable:!0,get:()=>{throw kr(`index ${e}`,t)}})}return Object.freeze(s)}parseTransaction(e){let t=this.getFunction(e.data.substring(0,10).toLowerCase());return t?new Er({args:this._abiCoder.decode(t.inputs,"0x"+e.data.substring(10)),functionFragment:t,name:t.name,signature:t.format(),sighash:this.getSighash(t),value:o.a.from(e.value||"0")}):null}parseLog(e){let t=this.getEvent(e.topics[0]);return!t||t.anonymous?null:new wr({eventFragment:t,name:t.name,signature:t.format(),topic:this.getEventTopic(t),args:this.decodeEventLog(t,e.data,e.topics)})}parseError(e){const t=Object(b.hexlify)(e);let r=this.getError(t.substring(0,10).toLowerCase());return r?new Ar({args:this._abiCoder.decode(r.inputs,"0x"+t.substring(10)),errorFragment:r,name:r.name,signature:r.format(),sighash:this.getSighash(r)}):null}static isInterface(e){return!(!e||!e._isInterface)}}var Or=r(65),Cr=r(133),Pr=r(16),Rr=r(63),Nr=r(56),Ir=r(859);function Mr(e){for(let t=(e=e.slice()).length-1;t>0;t--){const r=Math.floor(Math.random()*(t+1)),n=e[t];e[t]=e[r],e[r]=n}return e}var Dr=r(31),Br=r(25),Fr=r(127),jr=r(137),Lr=r(40),Ur=r(135);var qr=function(e,t,r,n){return new(r||(r=Promise))((function(f,a){function i(e){try{s(n.next(e))}catch(e){a(e)}}function o(e){try{s(n.throw(e))}catch(e){a(e)}}function s(e){var t;e.done?f(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(i,o)}s((n=n.apply(e,t||[])).next())}))};function Hr(e,t){return qr(this,void 0,void 0,(function*(){null==t&&(t={});const r={method:t.method||"GET",headers:t.headers||{},body:t.body||void 0};!0!==t.skipFetchSetup&&(r.mode="cors",r.cache="no-cache",r.credentials="same-origin",r.redirect="follow",r.referrer="client");const n=yield fetch(e,r),f=yield n.arrayBuffer(),a={};return n.headers.forEach?n.headers.forEach(((e,t)=>{a[t.toLowerCase()]=e})):n.headers.keys().forEach((e=>{a[e.toLowerCase()]=n.headers.get(e)})),{headers:a,statusCode:n.status,statusMessage:n.statusText,body:Object(b.arrayify)(new Uint8Array(f))}}))}var $r=function(e,t,r,n){return new(r||(r=Promise))((function(f,a){function i(e){try{s(n.next(e))}catch(e){a(e)}}function o(e){try{s(n.throw(e))}catch(e){a(e)}}function s(e){var t;e.done?f(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(i,o)}s((n=n.apply(e,t||[])).next())}))};const zr=new T.Logger("web/5.5.1");function Vr(e){return new Promise((t=>{setTimeout(t,e)}))}function Gr(e,t){if(null==e)return null;if("string"==typeof e)return e;if(Object(b.isBytesLike)(e)){if(t&&("text"===t.split("/")[0]||"application/json"===t.split(";")[0].trim()))try{return Object(_.h)(e)}catch(e){}return Object(b.hexlify)(e)}return e}function Kr(e,t,r){const n="object"==typeof e&&null!=e.throttleLimit?e.throttleLimit:12;zr.assertArgument(n>0&&n%1==0,"invalid connection throttle limit","connection.throttleLimit",n);const f="object"==typeof e?e.throttleCallback:null,a="object"==typeof e&&"number"==typeof e.throttleSlotInterval?e.throttleSlotInterval:100;zr.assertArgument(a>0&&a%1==0,"invalid connection throttle slot interval","connection.throttleSlotInterval",a);const i={};let o=null;const s={method:"GET"};let c=!1,u=12e4;if("string"==typeof e)o=e;else if("object"==typeof e){if(null!=e&&null!=e.url||zr.throwArgumentError("missing URL","connection.url",e),o=e.url,"number"==typeof e.timeout&&e.timeout>0&&(u=e.timeout),e.headers)for(const t in e.headers)i[t.toLowerCase()]={key:t,value:String(e.headers[t])},["if-none-match","if-modified-since"].indexOf(t.toLowerCase())>=0&&(c=!0);if(s.allowGzip=!!e.allowGzip,null!=e.user&&null!=e.password){"https:"!==o.substring(0,6)&&!0!==e.allowInsecureAuthentication&&zr.throwError("basic authentication requires a secure https url",T.Logger.errors.INVALID_ARGUMENT,{argument:"url",url:o,user:e.user,password:"[REDACTED]"});const t=e.user+":"+e.password;i.authorization={key:"Authorization",value:"Basic "+Object(Ur.b)(Object(_.f)(t))}}}const d=new RegExp("^data:([a-z0-9-]+/[a-z0-9-]+);base64,(.*)$","i"),l=o?o.match(d):null;if(l)try{const e={statusCode:200,statusMessage:"OK",headers:{"content-type":l[1]},body:Object(Ur.a)(l[2])};let t=e.body;return r&&(t=r(e.body,e)),Promise.resolve(t)}catch(e){zr.throwError("processing response error",T.Logger.errors.SERVER_ERROR,{body:Gr(l[1],l[2]),error:e,requestBody:null,requestMethod:"GET",url:o})}t&&(s.method="POST",s.body=t,null==i["content-type"]&&(i["content-type"]={key:"Content-Type",value:"application/octet-stream"}),null==i["content-length"]&&(i["content-length"]={key:"Content-Length",value:String(t.length)}));const p={};Object.keys(i).forEach((e=>{const t=i[e];p[t.key]=t.value})),s.headers=p;const h=function(){let e=null;return{promise:new Promise((function(t,r){u&&(e=setTimeout((()=>{null!=e&&(e=null,r(zr.makeError("timeout",T.Logger.errors.TIMEOUT,{requestBody:Gr(s.body,p["content-type"]),requestMethod:s.method,timeout:u,url:o})))}),u))})),cancel:function(){null!=e&&(clearTimeout(e),e=null)}}}(),b=function(){return $r(this,void 0,void 0,(function*(){for(let e=0;e<n;e++){let t=null;try{if(t=yield Hr(o,s),e<n)if(301===t.statusCode||302===t.statusCode){const e=t.headers.location||"";if("GET"===s.method&&e.match(/^https:/)){o=t.headers.location;continue}}else if(429===t.statusCode){let r=!0;if(f&&(r=yield f(e,o)),r){let r=0;const n=t.headers["retry-after"];r="string"==typeof n&&n.match(/^[1-9][0-9]*$/)?1e3*parseInt(n):a*parseInt(String(Math.random()*Math.pow(2,e))),yield Vr(r);continue}}}catch(e){t=e.response,null==t&&(h.cancel(),zr.throwError("missing response",T.Logger.errors.SERVER_ERROR,{requestBody:Gr(s.body,p["content-type"]),requestMethod:s.method,serverError:e,url:o}))}let i=t.body;if(c&&304===t.statusCode?i=null:(t.statusCode<200||t.statusCode>=300)&&(h.cancel(),zr.throwError("bad response",T.Logger.errors.SERVER_ERROR,{status:t.statusCode,headers:t.headers,body:Gr(i,t.headers?t.headers["content-type"]:null),requestBody:Gr(s.body,p["content-type"]),requestMethod:s.method,url:o})),r)try{const e=yield r(i,t);return h.cancel(),e}catch(r){if(r.throttleRetry&&e<n){let t=!0;if(f&&(t=yield f(e,o)),t){const t=a*parseInt(String(Math.random()*Math.pow(2,e)));yield Vr(t);continue}}h.cancel(),zr.throwError("processing response error",T.Logger.errors.SERVER_ERROR,{body:Gr(i,t.headers?t.headers["content-type"]:null),error:r,requestBody:Gr(s.body,p["content-type"]),requestMethod:s.method,url:o})}return h.cancel(),i}return zr.throwError("failed response",T.Logger.errors.SERVER_ERROR,{requestBody:Gr(s.body,p["content-type"]),requestMethod:s.method,url:o})}))}();return Promise.race([h.promise,b])}function Wr(e,t,r){let n=null;if(null!=t){n=Object(_.f)(t);const r="string"==typeof e?{url:e}:Object(g.shallowCopy)(e);if(r.headers){0!==Object.keys(r.headers).filter((e=>"content-type"===e.toLowerCase())).length||(r.headers=Object(g.shallowCopy)(r.headers),r.headers["content-type"]="application/json")}else r.headers={"content-type":"application/json"};e=r}return Kr(e,n,((e,t)=>{let n=null;if(null!=e)try{n=JSON.parse(Object(_.h)(e))}catch(t){zr.throwError("invalid JSON",T.Logger.errors.SERVER_ERROR,{body:e,error:t})}return r&&(n=r(n,t)),n}))}function Yr(e,t){return t||(t={}),null==(t=Object(g.shallowCopy)(t)).floor&&(t.floor=0),null==t.ceiling&&(t.ceiling=1e4),null==t.interval&&(t.interval=250),new Promise((function(r,n){let f=null,a=!1;const i=()=>!a&&(a=!0,f&&clearTimeout(f),!0);t.timeout&&(f=setTimeout((()=>{i()&&n(new Error("timeout"))}),t.timeout));const o=t.retryLimit;let s=0;!function f(){return e().then((function(e){if(void 0!==e)i()&&r(e);else if(t.oncePoll)t.oncePoll.once("poll",f);else if(t.onceBlock)t.onceBlock.once("block",f);else if(!a){if(s++,s>o)return void(i()&&n(new Error("retry limit reached")));let e=t.interval*parseInt(String(Math.random()*Math.pow(2,s)));e<t.floor&&(e=t.floor),e>t.ceiling&&(e=t.ceiling),setTimeout(f,e)}return null}),(function(e){i()&&n(e)}))}()}))}var Jr=r(123);const Xr="ethers/5.5.4",Zr=new T.Logger(Xr);try{const e=window;null==e._ethers&&(e._ethers=a)}catch(e){}},function(e,t,r){"use strict";r.r(t),r.d(t,"dma",(function(){return a})),r.d(t,"sma",(function(){return i})),r.d(t,"ema",(function(){return o})),r.d(t,"ma",(function(){return s})),r.d(t,"wma",(function(){return c}));const n=e=>"number"==typeof e&&e==e,f=Array.isArray;var a=(e,t,r)=>{const a=e.length;if(t>1)return Array(a);if(1===t)return e.slice();const i=!f(t),o=[];let s,c=0,u=0;for(;c<a;c++)if(s=e[c],n(s)&&(i||n(s))){o[c]=r?0:s,u=s,c++;break}if(!i){for(;c<a;c++)s=e[c],n(s)&&n(t[c])?u=o[c]=t[c]*s+(1-t[c])*u:o[c]=o[c-1];return o}const d=1-t;for(;c<a;c++)s=e[c],n(s)?u=o[c]=t*s+d*u:o[c]=o[c-1];return o},i=(e,t,r=1)=>a(e,r/t,1),o=(e,t)=>a(e,2/(t+1)),s=(e,t)=>{const r=e.length;if(!t)return e.reduce(((e,t)=>e+t))/r;if(t<=1)return e.slice();if(t>r)return Array(r);const f=t-1,a=[];let i,o=0,s=0,c=0;for(;s<r&&c<f;s++)i=e[s],n(i)&&(o+=i,c++);for(;s<r;s++)i=e[s],n(i)&&(o+=i),n(e[s-t])&&(o-=e[s-t]),a[s]=o/t;return a},c=(e,t)=>{const r=e.length;if(t<=1)return e.slice();if(t>r)return Array(r);const f=[],a=t*(t+1)/2,i=t-1;let o=0,s=0,c=0,u=0,d=-1;for(;u<i;u++)c=e[u],n(c)&&(o+=c,s+=(u+1)*c);for(;u<r;u++,d++)c=e[u],n(c)&&(o+=c,s+=t*c),d>=0&&n(e[d])&&(o-=e[d]),f[u]=s/a,s-=o;return f}},function(e,t,r){"use strict";r.d(t,"a",(function(){return a}));var n=r(0),f=r(70);function a(e,t,r,a,i){let o;e=Object(n.arrayify)(e),t=Object(n.arrayify)(t);let s=1;const c=new Uint8Array(a),u=new Uint8Array(t.length+4);let d,l;u.set(t);for(let p=1;p<=s;p++){u[t.length]=p>>24&255,u[t.length+1]=p>>16&255,u[t.length+2]=p>>8&255,u[t.length+3]=255&p;let h=Object(n.arrayify)(Object(f.a)(i,e,u));o||(o=h.length,l=new Uint8Array(o),s=Math.ceil(a/o),d=a-(s-1)*o),l.set(h);for(let t=1;t<r;t++){h=Object(n.arrayify)(Object(f.a)(i,e,h));for(let e=0;e<o;e++)l[e]^=h[e]}const b=(p-1)*o,m=p===s?d:o;c.set(Object(n.arrayify)(l).slice(0,m),b)}return Object(n.hexlify)(c)}},,,,,function(e,t,r){"use strict";r.d(t,"b",(function(){return h})),r.d(t,"c",(function(){return b})),r.d(t,"a",(function(){return y}));var n=r(0),f=r(2),a=r(124),i=r(17);const o=new f.Logger(a.a),s={},c=i.a.from(0),u=i.a.from(-1);function d(e,t,r,n){const a={fault:t,operation:r};return void 0!==n&&(a.value=n),o.throwError(e,f.Logger.errors.NUMERIC_FAULT,a)}let l="0";for(;l.length<256;)l+=l;function p(e){if("number"!=typeof e)try{e=i.a.from(e).toNumber()}catch(e){}return"number"==typeof e&&e>=0&&e<=256&&!(e%1)?"1"+l.substring(0,e):o.throwArgumentError("invalid decimal size","decimals",e)}function h(e,t){null==t&&(t=0);const r=p(t),n=(e=i.a.from(e)).lt(c);n&&(e=e.mul(u));let f=e.mod(r).toString();for(;f.length<r.length-1;)f="0"+f;f=f.match(/^([0-9]*[1-9]|0)(0*)/)[1];const a=e.div(r).toString();return e=1===r.length?a:a+"."+f,n&&(e="-"+e),e}function b(e,t){null==t&&(t=0);const r=p(t);"string"==typeof e&&e.match(/^-?[0-9.]+$/)||o.throwArgumentError("invalid decimal value","value",e);const n="-"===e.substring(0,1);n&&(e=e.substring(1)),"."===e&&o.throwArgumentError("missing value","value",e);const f=e.split(".");f.length>2&&o.throwArgumentError("too many decimal points","value",e);let a=f[0],s=f[1];for(a||(a="0"),s||(s="0");"0"===s[s.length-1];)s=s.substring(0,s.length-1);for(s.length>r.length-1&&d("fractional component exceeds decimals","underflow","parseFixed"),""===s&&(s="0");s.length<r.length-1;)s+="0";const c=i.a.from(a),l=i.a.from(s);let h=c.mul(r).add(l);return n&&(h=h.mul(u)),h}class m{constructor(e,t,r,n){e!==s&&o.throwError("cannot use FixedFormat constructor; use FixedFormat.from",f.Logger.errors.UNSUPPORTED_OPERATION,{operation:"new FixedFormat"}),this.signed=t,this.width=r,this.decimals=n,this.name=(t?"":"u")+"fixed"+String(r)+"x"+String(n),this._multiplier=p(n),Object.freeze(this)}static from(e){if(e instanceof m)return e;"number"==typeof e&&(e=`fixed128x${e}`);let t=!0,r=128,n=18;if("string"==typeof e)if("fixed"===e);else if("ufixed"===e)t=!1;else{const f=e.match(/^(u?)fixed([0-9]+)x([0-9]+)$/);f||o.throwArgumentError("invalid fixed format","format",e),t="u"!==f[1],r=parseInt(f[2]),n=parseInt(f[3])}else if(e){const f=(t,r,n)=>null==e[t]?n:(typeof e[t]!==r&&o.throwArgumentError("invalid fixed format ("+t+" not "+r+")","format."+t,e[t]),e[t]);t=f("signed","boolean",t),r=f("width","number",r),n=f("decimals","number",n)}return r%8&&o.throwArgumentError("invalid fixed format width (not byte aligned)","format.width",r),n>80&&o.throwArgumentError("invalid fixed format (decimals too large)","format.decimals",n),new m(s,t,r,n)}}class y{constructor(e,t,r,n){o.checkNew(new.target,y),e!==s&&o.throwError("cannot use FixedNumber constructor; use FixedNumber.from",f.Logger.errors.UNSUPPORTED_OPERATION,{operation:"new FixedFormat"}),this.format=n,this._hex=t,this._value=r,this._isFixedNumber=!0,Object.freeze(this)}_checkFormat(e){this.format.name!==e.format.name&&o.throwArgumentError("incompatible format; use fixedNumber.toFormat","other",e)}addUnsafe(e){this._checkFormat(e);const t=b(this._value,this.format.decimals),r=b(e._value,e.format.decimals);return y.fromValue(t.add(r),this.format.decimals,this.format)}subUnsafe(e){this._checkFormat(e);const t=b(this._value,this.format.decimals),r=b(e._value,e.format.decimals);return y.fromValue(t.sub(r),this.format.decimals,this.format)}mulUnsafe(e){this._checkFormat(e);const t=b(this._value,this.format.decimals),r=b(e._value,e.format.decimals);return y.fromValue(t.mul(r).div(this.format._multiplier),this.format.decimals,this.format)}divUnsafe(e){this._checkFormat(e);const t=b(this._value,this.format.decimals),r=b(e._value,e.format.decimals);return y.fromValue(t.mul(this.format._multiplier).div(r),this.format.decimals,this.format)}floor(){const e=this.toString().split(".");1===e.length&&e.push("0");let t=y.from(e[0],this.format);const r=!e[1].match(/^(0*)$/);return this.isNegative()&&r&&(t=t.subUnsafe(g.toFormat(t.format))),t}ceiling(){const e=this.toString().split(".");1===e.length&&e.push("0");let t=y.from(e[0],this.format);const r=!e[1].match(/^(0*)$/);return!this.isNegative()&&r&&(t=t.addUnsafe(g.toFormat(t.format))),t}round(e){null==e&&(e=0);const t=this.toString().split(".");if(1===t.length&&t.push("0"),(e<0||e>80||e%1)&&o.throwArgumentError("invalid decimal count","decimals",e),t[1].length<=e)return this;const r=y.from("1"+l.substring(0,e),this.format),n=v.toFormat(this.format);return this.mulUnsafe(r).addUnsafe(n).floor().divUnsafe(r)}isZero(){return"0.0"===this._value||"0"===this._value}isNegative(){return"-"===this._value[0]}toString(){return this._value}toHexString(e){if(null==e)return this._hex;e%8&&o.throwArgumentError("invalid byte width","width",e);const t=i.a.from(this._hex).fromTwos(this.format.width).toTwos(e).toHexString();return Object(n.hexZeroPad)(t,e/8)}toUnsafeFloat(){return parseFloat(this.toString())}toFormat(e){return y.fromString(this._value,e)}static fromValue(e,t,r){return null!=r||null==t||Object(i.d)(t)||(r=t,t=null),null==t&&(t=0),null==r&&(r="fixed"),y.fromString(h(e,t),m.from(r))}static fromString(e,t){null==t&&(t="fixed");const r=m.from(t),f=b(e,r.decimals);!r.signed&&f.lt(c)&&d("unsigned value cannot be negative","overflow","value",e);let a=null;r.signed?a=f.toTwos(r.width).toHexString():(a=f.toHexString(),a=Object(n.hexZeroPad)(a,r.width/8));const i=h(f,r.decimals);return new y(s,a,i,r)}static fromBytes(e,t){null==t&&(t="fixed");const r=m.from(t);if(Object(n.arrayify)(e).length>r.width/8)throw new Error("overflow");let f=i.a.from(e);r.signed&&(f=f.fromTwos(r.width));const a=f.toTwos((r.signed?0:1)+r.width).toHexString(),o=h(f,r.decimals);return new y(s,a,o,r)}static from(e,t){if("string"==typeof e)return y.fromString(e,t);if(Object(n.isBytes)(e))return y.fromBytes(e,t);try{return y.fromValue(e,0,t)}catch(e){if(e.code!==f.Logger.errors.INVALID_ARGUMENT)throw e}return o.throwArgumentError("invalid FixedNumber value","value",e)}static isFixedNumber(e){return!(!e||!e._isFixedNumber)}}const g=y.from(1),v=y.from("0.5")},function(e,t,r){"use strict";(function(e){r.d(t,"a",(function(){return c}));var n=r(0),f=r(2),a=r(335);const i=new f.Logger(a.a);const o=function(){if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if(void 0!==e)return e;throw new Error("unable to locate global object")}();let s=o.crypto||o.msCrypto;function c(e){(e<=0||e>1024||e%1||e!=e)&&i.throwArgumentError("invalid length","length",e);const t=new Uint8Array(e);return s.getRandomValues(t),Object(n.arrayify)(t)}s&&s.getRandomValues||(i.warn("WARNING: Missing strong random number source"),s={getRandomValues:function(e){return i.throwError("no secure random source avaialble",f.Logger.errors.UNSUPPORTED_OPERATION,{operation:"crypto.getRandomValues"})}})}).call(this,r(21))},function(e,t,r){"use strict";r.d(t,"a",(function(){return s}));var n=r(129);let f=null;function a(e){if(null==f&&(f="AbandonAbilityAbleAboutAboveAbsentAbsorbAbstractAbsurdAbuseAccessAccidentAccountAccuseAchieveAcidAcousticAcquireAcrossActActionActorActressActualAdaptAddAddictAddressAdjustAdmitAdultAdvanceAdviceAerobicAffairAffordAfraidAgainAgeAgentAgreeAheadAimAirAirportAisleAlarmAlbumAlcoholAlertAlienAllAlleyAllowAlmostAloneAlphaAlreadyAlsoAlterAlwaysAmateurAmazingAmongAmountAmusedAnalystAnchorAncientAngerAngleAngryAnimalAnkleAnnounceAnnualAnotherAnswerAntennaAntiqueAnxietyAnyApartApologyAppearAppleApproveAprilArchArcticAreaArenaArgueArmArmedArmorArmyAroundArrangeArrestArriveArrowArtArtefactArtistArtworkAskAspectAssaultAssetAssistAssumeAsthmaAthleteAtomAttackAttendAttitudeAttractAuctionAuditAugustAuntAuthorAutoAutumnAverageAvocadoAvoidAwakeAwareAwayAwesomeAwfulAwkwardAxisBabyBachelorBaconBadgeBagBalanceBalconyBallBambooBananaBannerBarBarelyBargainBarrelBaseBasicBasketBattleBeachBeanBeautyBecauseBecomeBeefBeforeBeginBehaveBehindBelieveBelowBeltBenchBenefitBestBetrayBetterBetweenBeyondBicycleBidBikeBindBiologyBirdBirthBitterBlackBladeBlameBlanketBlastBleakBlessBlindBloodBlossomBlouseBlueBlurBlushBoardBoatBodyBoilBombBoneBonusBookBoostBorderBoringBorrowBossBottomBounceBoxBoyBracketBrainBrandBrassBraveBreadBreezeBrickBridgeBriefBrightBringBriskBroccoliBrokenBronzeBroomBrotherBrownBrushBubbleBuddyBudgetBuffaloBuildBulbBulkBulletBundleBunkerBurdenBurgerBurstBusBusinessBusyButterBuyerBuzzCabbageCabinCableCactusCageCakeCallCalmCameraCampCanCanalCancelCandyCannonCanoeCanvasCanyonCapableCapitalCaptainCarCarbonCardCargoCarpetCarryCartCaseCashCasinoCastleCasualCatCatalogCatchCategoryCattleCaughtCauseCautionCaveCeilingCeleryCementCensusCenturyCerealCertainChairChalkChampionChangeChaosChapterChargeChaseChatCheapCheckCheeseChefCherryChestChickenChiefChildChimneyChoiceChooseChronicChuckleChunkChurnCigarCinnamonCircleCitizenCityCivilClaimClapClarifyClawClayCleanClerkCleverClickClientCliffClimbClinicClipClockClogCloseClothCloudClownClubClumpClusterClutchCoachCoastCoconutCodeCoffeeCoilCoinCollectColorColumnCombineComeComfortComicCommonCompanyConcertConductConfirmCongressConnectConsiderControlConvinceCookCoolCopperCopyCoralCoreCornCorrectCostCottonCouchCountryCoupleCourseCousinCoverCoyoteCrackCradleCraftCramCraneCrashCraterCrawlCrazyCreamCreditCreekCrewCricketCrimeCrispCriticCropCrossCrouchCrowdCrucialCruelCruiseCrumbleCrunchCrushCryCrystalCubeCultureCupCupboardCuriousCurrentCurtainCurveCushionCustomCuteCycleDadDamageDampDanceDangerDaringDashDaughterDawnDayDealDebateDebrisDecadeDecemberDecideDeclineDecorateDecreaseDeerDefenseDefineDefyDegreeDelayDeliverDemandDemiseDenialDentistDenyDepartDependDepositDepthDeputyDeriveDescribeDesertDesignDeskDespairDestroyDetailDetectDevelopDeviceDevoteDiagramDialDiamondDiaryDiceDieselDietDifferDigitalDignityDilemmaDinnerDinosaurDirectDirtDisagreeDiscoverDiseaseDishDismissDisorderDisplayDistanceDivertDivideDivorceDizzyDoctorDocumentDogDollDolphinDomainDonateDonkeyDonorDoorDoseDoubleDoveDraftDragonDramaDrasticDrawDreamDressDriftDrillDrinkDripDriveDropDrumDryDuckDumbDuneDuringDustDutchDutyDwarfDynamicEagerEagleEarlyEarnEarthEasilyEastEasyEchoEcologyEconomyEdgeEditEducateEffortEggEightEitherElbowElderElectricElegantElementElephantElevatorEliteElseEmbarkEmbodyEmbraceEmergeEmotionEmployEmpowerEmptyEnableEnactEndEndlessEndorseEnemyEnergyEnforceEngageEngineEnhanceEnjoyEnlistEnoughEnrichEnrollEnsureEnterEntireEntryEnvelopeEpisodeEqualEquipEraEraseErodeErosionErrorEruptEscapeEssayEssenceEstateEternalEthicsEvidenceEvilEvokeEvolveExactExampleExcessExchangeExciteExcludeExcuseExecuteExerciseExhaustExhibitExileExistExitExoticExpandExpectExpireExplainExposeExpressExtendExtraEyeEyebrowFabricFaceFacultyFadeFaintFaithFallFalseFameFamilyFamousFanFancyFantasyFarmFashionFatFatalFatherFatigueFaultFavoriteFeatureFebruaryFederalFeeFeedFeelFemaleFenceFestivalFetchFeverFewFiberFictionFieldFigureFileFilmFilterFinalFindFineFingerFinishFireFirmFirstFiscalFishFitFitnessFixFlagFlameFlashFlatFlavorFleeFlightFlipFloatFlockFloorFlowerFluidFlushFlyFoamFocusFogFoilFoldFollowFoodFootForceForestForgetForkFortuneForumForwardFossilFosterFoundFoxFragileFrameFrequentFreshFriendFringeFrogFrontFrostFrownFrozenFruitFuelFunFunnyFurnaceFuryFutureGadgetGainGalaxyGalleryGameGapGarageGarbageGardenGarlicGarmentGasGaspGateGatherGaugeGazeGeneralGeniusGenreGentleGenuineGestureGhostGiantGiftGiggleGingerGiraffeGirlGiveGladGlanceGlareGlassGlideGlimpseGlobeGloomGloryGloveGlowGlueGoatGoddessGoldGoodGooseGorillaGospelGossipGovernGownGrabGraceGrainGrantGrapeGrassGravityGreatGreenGridGriefGritGroceryGroupGrowGruntGuardGuessGuideGuiltGuitarGunGymHabitHairHalfHammerHamsterHandHappyHarborHardHarshHarvestHatHaveHawkHazardHeadHealthHeartHeavyHedgehogHeightHelloHelmetHelpHenHeroHiddenHighHillHintHipHireHistoryHobbyHockeyHoldHoleHolidayHollowHomeHoneyHoodHopeHornHorrorHorseHospitalHostHotelHourHoverHubHugeHumanHumbleHumorHundredHungryHuntHurdleHurryHurtHusbandHybridIceIconIdeaIdentifyIdleIgnoreIllIllegalIllnessImageImitateImmenseImmuneImpactImposeImproveImpulseInchIncludeIncomeIncreaseIndexIndicateIndoorIndustryInfantInflictInformInhaleInheritInitialInjectInjuryInmateInnerInnocentInputInquiryInsaneInsectInsideInspireInstallIntactInterestIntoInvestInviteInvolveIronIslandIsolateIssueItemIvoryJacketJaguarJarJazzJealousJeansJellyJewelJobJoinJokeJourneyJoyJudgeJuiceJumpJungleJuniorJunkJustKangarooKeenKeepKetchupKeyKickKidKidneyKindKingdomKissKitKitchenKiteKittenKiwiKneeKnifeKnockKnowLabLabelLaborLadderLadyLakeLampLanguageLaptopLargeLaterLatinLaughLaundryLavaLawLawnLawsuitLayerLazyLeaderLeafLearnLeaveLectureLeftLegLegalLegendLeisureLemonLendLengthLensLeopardLessonLetterLevelLiarLibertyLibraryLicenseLifeLiftLightLikeLimbLimitLinkLionLiquidListLittleLiveLizardLoadLoanLobsterLocalLockLogicLonelyLongLoopLotteryLoudLoungeLoveLoyalLuckyLuggageLumberLunarLunchLuxuryLyricsMachineMadMagicMagnetMaidMailMainMajorMakeMammalManManageMandateMangoMansionManualMapleMarbleMarchMarginMarineMarketMarriageMaskMassMasterMatchMaterialMathMatrixMatterMaximumMazeMeadowMeanMeasureMeatMechanicMedalMediaMelodyMeltMemberMemoryMentionMenuMercyMergeMeritMerryMeshMessageMetalMethodMiddleMidnightMilkMillionMimicMindMinimumMinorMinuteMiracleMirrorMiseryMissMistakeMixMixedMixtureMobileModelModifyMomMomentMonitorMonkeyMonsterMonthMoonMoralMoreMorningMosquitoMotherMotionMotorMountainMouseMoveMovieMuchMuffinMuleMultiplyMuscleMuseumMushroomMusicMustMutualMyselfMysteryMythNaiveNameNapkinNarrowNastyNationNatureNearNeckNeedNegativeNeglectNeitherNephewNerveNestNetNetworkNeutralNeverNewsNextNiceNightNobleNoiseNomineeNoodleNormalNorthNoseNotableNoteNothingNoticeNovelNowNuclearNumberNurseNutOakObeyObjectObligeObscureObserveObtainObviousOccurOceanOctoberOdorOffOfferOfficeOftenOilOkayOldOliveOlympicOmitOnceOneOnionOnlineOnlyOpenOperaOpinionOpposeOptionOrangeOrbitOrchardOrderOrdinaryOrganOrientOriginalOrphanOstrichOtherOutdoorOuterOutputOutsideOvalOvenOverOwnOwnerOxygenOysterOzonePactPaddlePagePairPalacePalmPandaPanelPanicPantherPaperParadeParentParkParrotPartyPassPatchPathPatientPatrolPatternPausePavePaymentPeacePeanutPearPeasantPelicanPenPenaltyPencilPeoplePepperPerfectPermitPersonPetPhonePhotoPhrasePhysicalPianoPicnicPicturePiecePigPigeonPillPilotPinkPioneerPipePistolPitchPizzaPlacePlanetPlasticPlatePlayPleasePledgePluckPlugPlungePoemPoetPointPolarPolePolicePondPonyPoolPopularPortionPositionPossiblePostPotatoPotteryPovertyPowderPowerPracticePraisePredictPreferPreparePresentPrettyPreventPricePridePrimaryPrintPriorityPrisonPrivatePrizeProblemProcessProduceProfitProgramProjectPromoteProofPropertyProsperProtectProudProvidePublicPuddingPullPulpPulsePumpkinPunchPupilPuppyPurchasePurityPurposePursePushPutPuzzlePyramidQualityQuantumQuarterQuestionQuickQuitQuizQuoteRabbitRaccoonRaceRackRadarRadioRailRainRaiseRallyRampRanchRandomRangeRapidRareRateRatherRavenRawRazorReadyRealReasonRebelRebuildRecallReceiveRecipeRecordRecycleReduceReflectReformRefuseRegionRegretRegularRejectRelaxReleaseReliefRelyRemainRememberRemindRemoveRenderRenewRentReopenRepairRepeatReplaceReportRequireRescueResembleResistResourceResponseResultRetireRetreatReturnReunionRevealReviewRewardRhythmRibRibbonRiceRichRideRidgeRifleRightRigidRingRiotRippleRiskRitualRivalRiverRoadRoastRobotRobustRocketRomanceRoofRookieRoomRoseRotateRoughRoundRouteRoyalRubberRudeRugRuleRunRunwayRuralSadSaddleSadnessSafeSailSaladSalmonSalonSaltSaluteSameSampleSandSatisfySatoshiSauceSausageSaveSayScaleScanScareScatterSceneSchemeSchoolScienceScissorsScorpionScoutScrapScreenScriptScrubSeaSearchSeasonSeatSecondSecretSectionSecuritySeedSeekSegmentSelectSellSeminarSeniorSenseSentenceSeriesServiceSessionSettleSetupSevenShadowShaftShallowShareShedShellSheriffShieldShiftShineShipShiverShockShoeShootShopShortShoulderShoveShrimpShrugShuffleShySiblingSickSideSiegeSightSignSilentSilkSillySilverSimilarSimpleSinceSingSirenSisterSituateSixSizeSkateSketchSkiSkillSkinSkirtSkullSlabSlamSleepSlenderSliceSlideSlightSlimSloganSlotSlowSlushSmallSmartSmileSmokeSmoothSnackSnakeSnapSniffSnowSoapSoccerSocialSockSodaSoftSolarSoldierSolidSolutionSolveSomeoneSongSoonSorrySortSoulSoundSoupSourceSouthSpaceSpareSpatialSpawnSpeakSpecialSpeedSpellSpendSphereSpiceSpiderSpikeSpinSpiritSplitSpoilSponsorSpoonSportSpotSpraySpreadSpringSpySquareSqueezeSquirrelStableStadiumStaffStageStairsStampStandStartStateStaySteakSteelStemStepStereoStickStillStingStockStomachStoneStoolStoryStoveStrategyStreetStrikeStrongStruggleStudentStuffStumbleStyleSubjectSubmitSubwaySuccessSuchSuddenSufferSugarSuggestSuitSummerSunSunnySunsetSuperSupplySupremeSureSurfaceSurgeSurpriseSurroundSurveySuspectSustainSwallowSwampSwapSwarmSwearSweetSwiftSwimSwingSwitchSwordSymbolSymptomSyrupSystemTableTackleTagTailTalentTalkTankTapeTargetTaskTasteTattooTaxiTeachTeamTellTenTenantTennisTentTermTestTextThankThatThemeThenTheoryThereTheyThingThisThoughtThreeThriveThrowThumbThunderTicketTideTigerTiltTimberTimeTinyTipTiredTissueTitleToastTobaccoTodayToddlerToeTogetherToiletTokenTomatoTomorrowToneTongueTonightToolToothTopTopicToppleTorchTornadoTortoiseTossTotalTouristTowardTowerTownToyTrackTradeTrafficTragicTrainTransferTrapTrashTravelTrayTreatTreeTrendTrialTribeTrickTriggerTrimTripTrophyTroubleTruckTrueTrulyTrumpetTrustTruthTryTubeTuitionTumbleTunaTunnelTurkeyTurnTurtleTwelveTwentyTwiceTwinTwistTwoTypeTypicalUglyUmbrellaUnableUnawareUncleUncoverUnderUndoUnfairUnfoldUnhappyUniformUniqueUnitUniverseUnknownUnlockUntilUnusualUnveilUpdateUpgradeUpholdUponUpperUpsetUrbanUrgeUsageUseUsedUsefulUselessUsualUtilityVacantVacuumVagueValidValleyValveVanVanishVaporVariousVastVaultVehicleVelvetVendorVentureVenueVerbVerifyVersionVeryVesselVeteranViableVibrantViciousVictoryVideoViewVillageVintageViolinVirtualVirusVisaVisitVisualVitalVividVocalVoiceVoidVolcanoVolumeVoteVoyageWageWagonWaitWalkWallWalnutWantWarfareWarmWarriorWashWaspWasteWaterWaveWayWealthWeaponWearWeaselWeatherWebWeddingWeekendWeirdWelcomeWestWetWhaleWhatWheatWheelWhenWhereWhipWhisperWideWidthWifeWildWillWinWindowWineWingWinkWinnerWinterWireWisdomWiseWishWitnessWolfWomanWonderWoodWoolWordWorkWorldWorryWorthWrapWreckWrestleWristWriteWrongYardYearYellowYouYoungYouthZebraZeroZoneZoo".replace(/([A-Z])/g," $1").toLowerCase().substring(1).split(" "),"0x3c8acc1e7b08d8e76f9fda015ef48dc8c710a73cb7e0f77b2c18a9b5a7adde60"!==n.a.check(e)))throw f=null,new Error("BIP39 Wordlist for en (English) FAILED")}class i extends n.a{constructor(){super("en")}getWord(e){return a(this),f[e]}getWordIndex(e){return a(this),f.indexOf(e)}}const o=new i;n.a.register(o);const s={en:o}}])}));
431
431
  //# sourceMappingURL=requestnetwork.min.js.map