droplinked-web3-ui 0.0.4 → 0.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -10,7 +10,7 @@ React keys must be passed directly to JSX without using spread:
10
10
  See https://react.dev/link/invalid-hook-call for tips about how to debug and fix this problem.`),c.useMemoCache(t)}})()),reactCompilerRuntime_development}var hasRequiredCompilerRuntime;function requireCompilerRuntime(){return hasRequiredCompilerRuntime||(hasRequiredCompilerRuntime=1,process.env.NODE_ENV==="production"?compilerRuntime.exports=requireReactCompilerRuntime_production():compilerRuntime.exports=requireReactCompilerRuntime_development()),compilerRuntime.exports}var compilerRuntimeExports=requireCompilerRuntime(),si=Object.defineProperty,ni=n=>{throw TypeError(n)},fi=(n,t,c)=>t in n?si(n,t,{enumerable:!0,configurable:!0,writable:!0,value:c}):n[t]=c,Xn=(n,t,c)=>fi(n,typeof t!="symbol"?t+"":t,c),ui=(n,t,c)=>t.has(n)||ni("Cannot "+c),ii=(n,t,c)=>t.has(n)?ni("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(n):t.set(n,c),ai=(n,t,c)=>(ui(n,t,"access private method"),c);class WalletException extends Error{constructor(t,c){const ie=`<${t}> ${c}`;console.log(ie),super(c),this.name=new.target.name}}class WalletNotFoundException extends WalletException{constructor(t,c=""){const ie=`Wallet Not found ${c}`;super(t,ie)}}class UserDeniedException extends WalletException{constructor(t){super(t,"User denied the request")}}class NotSupportedException extends WalletException{constructor(t,c){super(t,`${c} networks are not supported by this wallet.`)}}class WalletNotInstalledException extends WalletException{constructor(t){super(t,"Not Installed.")}}class TokenNotSupportedException extends WalletException{constructor(t,c){super(t,`${c} token is not supported by this wallet.`)}}class ChainNotSupportedException extends WalletException{constructor(t,c){super(t,`${c} is not supported by this wallet.`)}}class ProviderException extends WalletException{constructor(t){super(t,"Provider could not be initialized.")}}class ChainException extends Error{constructor(t,c){const ie=`<${t}> ${c}`;console.log(ie),super(c),this.name=new.target.name}}class ChainNotImplementedException extends ChainException{constructor(t){super(t,"Not Implemented!")}}class InvalidParametersException extends ChainException{constructor(t,c){super(t,`Invalid parameters: ${c}`)}}class Unauthorized extends ChainException{constructor(t,c,ie,se){super(t,`Unauthorized access to ${c} from ${ie} to ${se}`),this.method=c,this.from=ie,this.to=se}}class ActionExceptions extends Error{constructor(t,c){super(`${t}: ${c}`),this.name=new.target.name}}class ActionNotImplementedException extends ActionExceptions{constructor(t){super(t,"Not Implemented!")}}class Web3CallbackFailedException extends ActionExceptions{constructor(t){super(t,"Something went wrong during web3 callback process!")}}class InitializationException extends ActionExceptions{constructor(){super("","Provider not initialized.")}}class InsufficientBalanceException extends ActionExceptions{constructor(){super("Payment","Insufficient Funds")}}var Actions=(n=>(n.Payment="Payment",n.ClaimNFT="ClaimNFT",n.Record="Record",n.Auth="Aut",n.Login="Login",n))(Actions||{}),Groups=(n=>(n.EVM="EVM",n.SOL="SOL",n.BTC="BTC",n.XION="XION",n.UD="UD",n))(Groups||{}),Network=(n=>(n.TESTNET="TESTNET",n.MAINNET="MAINNET",n))(Network||{}),Chains=(n=>(n.POLYGON="POLYGON",n.BINANCE="BINANCE",n.SKALE="SKALE",n.BASE="BASE",n.LINEA="LINEA",n.ETH="ETH",n.SOLANA="SOLANA",n.REDBELLY="REDBELLY",n.UNSTOPPABLE="UNSTOPPABLE",n.BITLAYER="BITLAYER",n.XION="XION",n))(Chains||{});const chains=[{name:"BINANCE",group:Groups.EVM,TESTNET:{chainName:"Smart Chain - Testnet",chainId:"0x61",nativeCurrency:{name:"BNB",decimals:18,symbol:"BNB"},rpcUrls:["https://bsc-testnet-dataseed.bnbchain.org/"]},MAINNET:{chainName:"Smart Chain",chainId:"0x38",nativeCurrency:{name:"BNB",decimals:18,symbol:"BNB"},rpcUrls:["https://bsc-dataseed.binance.org/"]}},{name:"POLYGON",group:Groups.EVM,TESTNET:{chainName:"Polygon Amoy Testnet",chainId:"0x13882",nativeCurrency:{name:"MATIC",decimals:18,symbol:"MATIC"},rpcUrls:["https://rpc-amoy.polygon.technology"]},MAINNET:{chainName:"Polygon Mainnet",chainId:"0x89",nativeCurrency:{name:"MATIC",decimals:18,symbol:"MATIC"},rpcUrls:["https://polygon-rpc.com/"]}},{name:"SKALE",group:Groups.EVM,TESTNET:{chainName:"SKALE Testnet Calypso Hub",chainId:"0x3A14269B",nativeCurrency:{name:"sFUEL",decimals:18,symbol:"sFUEL"},rpcUrls:["https://testnet.skalenodes.com/v1/giant-half-dual-testnet"]},MAINNET:{chainName:"SKALE Calypso Hub",chainId:"0x5D456C62",nativeCurrency:{name:"sFUEL",decimals:18,symbol:"sFUEL"},rpcUrls:["https://mainnet.skalenodes.com/v1/honorable-steel-rasalhague"]}},{name:"BASE",group:Groups.EVM,TESTNET:{chainName:"Base Sepolia",chainId:"0x14a34",nativeCurrency:{name:"ETH",decimals:18,symbol:"ETH"},rpcUrls:["https://sepolia.base.org"]},MAINNET:{chainName:"Base Mainnet",chainId:"0x2105",nativeCurrency:{name:"ETH",decimals:18,symbol:"ETH"},rpcUrls:["https://mainnet.base.org/"]}},{name:"LINEA",group:Groups.EVM,MAINNET:{chainName:"Linea",chainId:"0xe708",nativeCurrency:{name:"ETH",decimals:18,symbol:"LineaETH"},rpcUrls:["https://rpc.linea.build"]},TESTNET:{chainName:"Linea",chainId:"0xe705",nativeCurrency:{name:"ETH",decimals:18,symbol:"LineaETH"},rpcUrls:["https://rpc.sepolia.linea.build"]}},{name:"ETH",group:Groups.EVM,MAINNET:{chainName:"Ethereum",chainId:"0x1",nativeCurrency:{name:"ETH",decimals:18,symbol:"ETH"},rpcUrls:["https://mainnet.infura.io/v3/"]},TESTNET:{chainName:"Sepolia",chainId:"0xaa36a7",nativeCurrency:{name:"ETH",decimals:18,symbol:"ETH"},rpcUrls:["https://eth-sepolia.public.blastapi.io/"]}},{name:"REDBELLY",group:Groups.EVM,TESTNET:{chainName:"Redbelly Network Testnet",chainId:"0x99",nativeCurrency:{name:"RBNT",decimals:18,symbol:"RBNT"},rpcUrls:["https://governors.testnet.redbelly.network"]},MAINNET:{chainName:"Redbelly Network Mainnet",chainId:"0x97",nativeCurrency:{name:"RBNT",decimals:18,symbol:"RBNT"},rpcUrls:["https://governors.mainnet.redbelly.network"]}},{name:"BITLAYER",group:Groups.EVM,MAINNET:{chainName:"Bitlayer Mainnet",chainId:"0x310C5",nativeCurrency:{name:"BTC",decimals:18,symbol:"BTC"},rpcUrls:["https://rpc.bitlayer.org"]},TESTNET:{chainName:"Bitlayer Testnet",chainId:"0x3106A",nativeCurrency:{name:"BTC",decimals:18,symbol:"BTC"},rpcUrls:["https://testnet-rpc.bitlayer.org"]}},{name:"SOLANA",group:Groups.SOL,MAINNET:{chainName:"Solana Mainnet",chainId:"0x1",nativeCurrency:{name:"SOL",decimals:9,symbol:"SOL"},rpcUrls:[]},TESTNET:{chainName:"Solana Testnet",chainId:"0x01",nativeCurrency:{name:"SOL",decimals:9,symbol:"SOL"},rpcUrls:[]}},{name:"XION",group:Groups.XION,MAINNET:{chainName:"Xion Mainnet",chainId:"0x1",nativeCurrency:{name:"XION",decimals:6,symbol:"XION"},rpcUrls:[]},TESTNET:{chainName:"Xion Testnet",chainId:"0x01",nativeCurrency:{name:"XION",decimals:6,symbol:"XION"},rpcUrls:[]}},{name:"UNSTOPPABLE",group:Groups.UD,MAINNET:{chainName:"Unstoppable Domains Mainnet",chainId:"0x1",nativeCurrency:{name:"UD",decimals:18,symbol:"UD"},rpcUrls:[]},TESTNET:{chainName:"Unstoppable Domains Testnet",chainId:"0x01",nativeCurrency:{name:"UD",decimals:18,symbol:"UD"},rpcUrls:[]}}];function getChainByName(n){const t=chains.find(c=>c.name.toLowerCase()===n.toLowerCase());if(!t)throw new ChainNotImplementedException(n);return t}function getGroupOfChain(n){return getChainByName(n).group}function isChainInGroup(n,t){return getGroupOfChain(n)===t}class Web3Wallet{constructor(t,c,ie){this.name=t,this.group=c,this.stepizer=ie}}async function getEvmProviderByWalletName(n,t=500){return new Promise(c=>{const ie=[];function se(ae){const ue=ae.detail;!(ue!=null&&ue.provider)||!(ue!=null&&ue.info)||ie.push(ue)}window.addEventListener("eip6963:announceProvider",se),window.dispatchEvent(new Event("eip6963:requestProvider")),setTimeout(()=>{window.removeEventListener("eip6963:announceProvider",se),console.log("EIP-6963 providers announced:",ie.map(de=>de.info.name));const ae=ie.find(({info:de})=>de.name===n||de.name.toLowerCase()===n.toLowerCase());if(ae){c(ae.provider);return}const ue=window.ethereum;if(n.toLowerCase()==="metamask"&&ue!=null&&ue.isMetaMask){c(ue);return}c(null)},t)})}var commonjsGlobal=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{};function getDefaultExportFromCjs$2(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}function getAugmentedNamespace(n){if(n.__esModule)return n;var t=n.default;if(typeof t=="function"){var c=function ie(){return this instanceof ie?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};c.prototype=t.prototype}else c={};return Object.defineProperty(c,"__esModule",{value:!0}),Object.keys(n).forEach(function(ie){var se=Object.getOwnPropertyDescriptor(n,ie);Object.defineProperty(c,ie,se.get?se:{enumerable:!0,get:function(){return n[ie]}})}),c}var bn$8={exports:{}},buffer$1={},base64Js={};base64Js.byteLength=byteLength;base64Js.toByteArray=toByteArray;base64Js.fromByteArray=fromByteArray;var lookup=[],revLookup=[],Arr=typeof Uint8Array<"u"?Uint8Array:Array,code="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(var i$3=0,len=code.length;i$3<len;++i$3)lookup[i$3]=code[i$3],revLookup[code.charCodeAt(i$3)]=i$3;revLookup[45]=62;revLookup[95]=63;function getLens(n){var t=n.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var c=n.indexOf("=");c===-1&&(c=t);var ie=c===t?0:4-c%4;return[c,ie]}function byteLength(n){var t=getLens(n),c=t[0],ie=t[1];return(c+ie)*3/4-ie}function _byteLength(n,t,c){return(t+c)*3/4-c}function toByteArray(n){var t,c=getLens(n),ie=c[0],se=c[1],ae=new Arr(_byteLength(n,ie,se)),ue=0,de=se>0?ie-4:ie,ve;for(ve=0;ve<de;ve+=4)t=revLookup[n.charCodeAt(ve)]<<18|revLookup[n.charCodeAt(ve+1)]<<12|revLookup[n.charCodeAt(ve+2)]<<6|revLookup[n.charCodeAt(ve+3)],ae[ue++]=t>>16&255,ae[ue++]=t>>8&255,ae[ue++]=t&255;return se===2&&(t=revLookup[n.charCodeAt(ve)]<<2|revLookup[n.charCodeAt(ve+1)]>>4,ae[ue++]=t&255),se===1&&(t=revLookup[n.charCodeAt(ve)]<<10|revLookup[n.charCodeAt(ve+1)]<<4|revLookup[n.charCodeAt(ve+2)]>>2,ae[ue++]=t>>8&255,ae[ue++]=t&255),ae}function tripletToBase64(n){return lookup[n>>18&63]+lookup[n>>12&63]+lookup[n>>6&63]+lookup[n&63]}function encodeChunk(n,t,c){for(var ie,se=[],ae=t;ae<c;ae+=3)ie=(n[ae]<<16&16711680)+(n[ae+1]<<8&65280)+(n[ae+2]&255),se.push(tripletToBase64(ie));return se.join("")}function fromByteArray(n){for(var t,c=n.length,ie=c%3,se=[],ae=16383,ue=0,de=c-ie;ue<de;ue+=ae)se.push(encodeChunk(n,ue,ue+ae>de?de:ue+ae));return ie===1?(t=n[c-1],se.push(lookup[t>>2]+lookup[t<<4&63]+"==")):ie===2&&(t=(n[c-2]<<8)+n[c-1],se.push(lookup[t>>10]+lookup[t>>4&63]+lookup[t<<2&63]+"=")),se.join("")}var ieee754={};ieee754.read=function(n,t,c,ie,se){var ae,ue,de=se*8-ie-1,ve=(1<<de)-1,ge=ve>>1,we=-7,Te=c?se-1:0,Ne=c?-1:1,qe=n[t+Te];for(Te+=Ne,ae=qe&(1<<-we)-1,qe>>=-we,we+=de;we>0;ae=ae*256+n[t+Te],Te+=Ne,we-=8);for(ue=ae&(1<<-we)-1,ae>>=-we,we+=ie;we>0;ue=ue*256+n[t+Te],Te+=Ne,we-=8);if(ae===0)ae=1-ge;else{if(ae===ve)return ue?NaN:(qe?-1:1)*(1/0);ue=ue+Math.pow(2,ie),ae=ae-ge}return(qe?-1:1)*ue*Math.pow(2,ae-ie)};ieee754.write=function(n,t,c,ie,se,ae){var ue,de,ve,ge=ae*8-se-1,we=(1<<ge)-1,Te=we>>1,Ne=se===23?Math.pow(2,-24)-Math.pow(2,-77):0,qe=ie?0:ae-1,ze=ie?1:-1,He=t<0||t===0&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(de=isNaN(t)?1:0,ue=we):(ue=Math.floor(Math.log(t)/Math.LN2),t*(ve=Math.pow(2,-ue))<1&&(ue--,ve*=2),ue+Te>=1?t+=Ne/ve:t+=Ne*Math.pow(2,1-Te),t*ve>=2&&(ue++,ve/=2),ue+Te>=we?(de=0,ue=we):ue+Te>=1?(de=(t*ve-1)*Math.pow(2,se),ue=ue+Te):(de=t*Math.pow(2,Te-1)*Math.pow(2,se),ue=0));se>=8;n[c+qe]=de&255,qe+=ze,de/=256,se-=8);for(ue=ue<<se|de,ge+=se;ge>0;n[c+qe]=ue&255,qe+=ze,ue/=256,ge-=8);n[c+qe-ze]|=He*128};(function(n){const t=base64Js,c=ieee754,ie=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;n.Buffer=we,n.SlowBuffer=Zt,n.INSPECT_MAX_BYTES=50;const se=2147483647;n.kMaxLength=se;const{Uint8Array:ae,ArrayBuffer:ue,SharedArrayBuffer:de}=globalThis;we.TYPED_ARRAY_SUPPORT=ve(),!we.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function ve(){try{const Gt=new ae(1),En={foo:function(){return 42}};return Object.setPrototypeOf(En,ae.prototype),Object.setPrototypeOf(Gt,En),Gt.foo()===42}catch{return!1}}Object.defineProperty(we.prototype,"parent",{enumerable:!0,get:function(){if(we.isBuffer(this))return this.buffer}}),Object.defineProperty(we.prototype,"offset",{enumerable:!0,get:function(){if(we.isBuffer(this))return this.byteOffset}});function ge(Gt){if(Gt>se)throw new RangeError('The value "'+Gt+'" is invalid for option "size"');const En=new ae(Gt);return Object.setPrototypeOf(En,we.prototype),En}function we(Gt,En,xn){if(typeof Gt=="number"){if(typeof En=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return ze(Gt)}return Te(Gt,En,xn)}we.poolSize=8192;function Te(Gt,En,xn){if(typeof Gt=="string")return He(Gt,En);if(ue.isView(Gt))return Ze(Gt);if(Gt==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof Gt);if(Ln(Gt,ue)||Gt&&Ln(Gt.buffer,ue)||typeof de<"u"&&(Ln(Gt,de)||Gt&&Ln(Gt.buffer,de)))return Ye(Gt,En,xn);if(typeof Gt=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');const In=Gt.valueOf&&Gt.valueOf();if(In!=null&&In!==Gt)return we.from(In,En,xn);const Wn=Ft(Gt);if(Wn)return Wn;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof Gt[Symbol.toPrimitive]=="function")return we.from(Gt[Symbol.toPrimitive]("string"),En,xn);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof Gt)}we.from=function(Gt,En,xn){return Te(Gt,En,xn)},Object.setPrototypeOf(we.prototype,ae.prototype),Object.setPrototypeOf(we,ae);function Ne(Gt){if(typeof Gt!="number")throw new TypeError('"size" argument must be of type number');if(Gt<0)throw new RangeError('The value "'+Gt+'" is invalid for option "size"')}function qe(Gt,En,xn){return Ne(Gt),Gt<=0?ge(Gt):En!==void 0?typeof xn=="string"?ge(Gt).fill(En,xn):ge(Gt).fill(En):ge(Gt)}we.alloc=function(Gt,En,xn){return qe(Gt,En,xn)};function ze(Gt){return Ne(Gt),ge(Gt<0?0:Mt(Gt)|0)}we.allocUnsafe=function(Gt){return ze(Gt)},we.allocUnsafeSlow=function(Gt){return ze(Gt)};function He(Gt,En){if((typeof En!="string"||En==="")&&(En="utf8"),!we.isEncoding(En))throw new TypeError("Unknown encoding: "+En);const xn=cn(Gt,En)|0;let In=ge(xn);const Wn=In.write(Gt,En);return Wn!==xn&&(In=In.slice(0,Wn)),In}function Ge(Gt){const En=Gt.length<0?0:Mt(Gt.length)|0,xn=ge(En);for(let In=0;In<En;In+=1)xn[In]=Gt[In]&255;return xn}function Ze(Gt){if(Ln(Gt,ae)){const En=new ae(Gt);return Ye(En.buffer,En.byteOffset,En.byteLength)}return Ge(Gt)}function Ye(Gt,En,xn){if(En<0||Gt.byteLength<En)throw new RangeError('"offset" is outside of buffer bounds');if(Gt.byteLength<En+(xn||0))throw new RangeError('"length" is outside of buffer bounds');let In;return En===void 0&&xn===void 0?In=new ae(Gt):xn===void 0?In=new ae(Gt,En):In=new ae(Gt,En,xn),Object.setPrototypeOf(In,we.prototype),In}function Ft(Gt){if(we.isBuffer(Gt)){const En=Mt(Gt.length)|0,xn=ge(En);return xn.length===0||Gt.copy(xn,0,0,En),xn}if(Gt.length!==void 0)return typeof Gt.length!="number"||On(Gt.length)?ge(0):Ge(Gt);if(Gt.type==="Buffer"&&Array.isArray(Gt.data))return Ge(Gt.data)}function Mt(Gt){if(Gt>=se)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+se.toString(16)+" bytes");return Gt|0}function Zt(Gt){return+Gt!=Gt&&(Gt=0),we.alloc(+Gt)}we.isBuffer=function(Gt){return Gt!=null&&Gt._isBuffer===!0&&Gt!==we.prototype},we.compare=function(Gt,En){if(Ln(Gt,ae)&&(Gt=we.from(Gt,Gt.offset,Gt.byteLength)),Ln(En,ae)&&(En=we.from(En,En.offset,En.byteLength)),!we.isBuffer(Gt)||!we.isBuffer(En))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(Gt===En)return 0;let xn=Gt.length,In=En.length;for(let Wn=0,jn=Math.min(xn,In);Wn<jn;++Wn)if(Gt[Wn]!==En[Wn]){xn=Gt[Wn],In=En[Wn];break}return xn<In?-1:In<xn?1:0},we.isEncoding=function(Gt){switch(String(Gt).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},we.concat=function(Gt,En){if(!Array.isArray(Gt))throw new TypeError('"list" argument must be an Array of Buffers');if(Gt.length===0)return we.alloc(0);let xn;if(En===void 0)for(En=0,xn=0;xn<Gt.length;++xn)En+=Gt[xn].length;const In=we.allocUnsafe(En);let Wn=0;for(xn=0;xn<Gt.length;++xn){let jn=Gt[xn];if(Ln(jn,ae))Wn+jn.length>In.length?(we.isBuffer(jn)||(jn=we.from(jn)),jn.copy(In,Wn)):ae.prototype.set.call(In,jn,Wn);else if(we.isBuffer(jn))jn.copy(In,Wn);else throw new TypeError('"list" argument must be an Array of Buffers');Wn+=jn.length}return In};function cn(Gt,En){if(we.isBuffer(Gt))return Gt.length;if(ue.isView(Gt)||Ln(Gt,ue))return Gt.byteLength;if(typeof Gt!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof Gt);const xn=Gt.length,In=arguments.length>2&&arguments[2]===!0;if(!In&&xn===0)return 0;let Wn=!1;for(;;)switch(En){case"ascii":case"latin1":case"binary":return xn;case"utf8":case"utf-8":return Kn(Gt).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return xn*2;case"hex":return xn>>>1;case"base64":return Hn(Gt).length;default:if(Wn)return In?-1:Kn(Gt).length;En=(""+En).toLowerCase(),Wn=!0}}we.byteLength=cn;function hn(Gt,En,xn){let In=!1;if((En===void 0||En<0)&&(En=0),En>this.length||((xn===void 0||xn>this.length)&&(xn=this.length),xn<=0)||(xn>>>=0,En>>>=0,xn<=En))return"";for(Gt||(Gt="utf8");;)switch(Gt){case"hex":return $t(this,En,xn);case"utf8":case"utf-8":return Fe(this,En,xn);case"ascii":return Me(this,En,xn);case"latin1":case"binary":return We(this,En,xn);case"base64":return De(this,En,xn);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return dn(this,En,xn);default:if(In)throw new TypeError("Unknown encoding: "+Gt);Gt=(Gt+"").toLowerCase(),In=!0}}we.prototype._isBuffer=!0;function yn(Gt,En,xn){const In=Gt[En];Gt[En]=Gt[xn],Gt[xn]=In}we.prototype.swap16=function(){const Gt=this.length;if(Gt%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let En=0;En<Gt;En+=2)yn(this,En,En+1);return this},we.prototype.swap32=function(){const Gt=this.length;if(Gt%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let En=0;En<Gt;En+=4)yn(this,En,En+3),yn(this,En+1,En+2);return this},we.prototype.swap64=function(){const Gt=this.length;if(Gt%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let En=0;En<Gt;En+=8)yn(this,En,En+7),yn(this,En+1,En+6),yn(this,En+2,En+5),yn(this,En+3,En+4);return this},we.prototype.toString=function(){const Gt=this.length;return Gt===0?"":arguments.length===0?Fe(this,0,Gt):hn.apply(this,arguments)},we.prototype.toLocaleString=we.prototype.toString,we.prototype.equals=function(Gt){if(!we.isBuffer(Gt))throw new TypeError("Argument must be a Buffer");return this===Gt?!0:we.compare(this,Gt)===0},we.prototype.inspect=function(){let Gt="";const En=n.INSPECT_MAX_BYTES;return Gt=this.toString("hex",0,En).replace(/(.{2})/g,"$1 ").trim(),this.length>En&&(Gt+=" ... "),"<Buffer "+Gt+">"},ie&&(we.prototype[ie]=we.prototype.inspect),we.prototype.compare=function(Gt,En,xn,In,Wn){if(Ln(Gt,ae)&&(Gt=we.from(Gt,Gt.offset,Gt.byteLength)),!we.isBuffer(Gt))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof Gt);if(En===void 0&&(En=0),xn===void 0&&(xn=Gt?Gt.length:0),In===void 0&&(In=0),Wn===void 0&&(Wn=this.length),En<0||xn>Gt.length||In<0||Wn>this.length)throw new RangeError("out of range index");if(In>=Wn&&En>=xn)return 0;if(In>=Wn)return-1;if(En>=xn)return 1;if(En>>>=0,xn>>>=0,In>>>=0,Wn>>>=0,this===Gt)return 0;let jn=Wn-In,zn=xn-En;const Ri=Math.min(jn,zn),Qn=this.slice(In,Wn),li=Gt.slice(En,xn);for(let Ci=0;Ci<Ri;++Ci)if(Qn[Ci]!==li[Ci]){jn=Qn[Ci],zn=li[Ci];break}return jn<zn?-1:zn<jn?1:0};function Ht(Gt,En,xn,In,Wn){if(Gt.length===0)return-1;if(typeof xn=="string"?(In=xn,xn=0):xn>2147483647?xn=2147483647:xn<-2147483648&&(xn=-2147483648),xn=+xn,On(xn)&&(xn=Wn?0:Gt.length-1),xn<0&&(xn=Gt.length+xn),xn>=Gt.length){if(Wn)return-1;xn=Gt.length-1}else if(xn<0)if(Wn)xn=0;else return-1;if(typeof En=="string"&&(En=we.from(En,In)),we.isBuffer(En))return En.length===0?-1:Sn(Gt,En,xn,In,Wn);if(typeof En=="number")return En=En&255,typeof ae.prototype.indexOf=="function"?Wn?ae.prototype.indexOf.call(Gt,En,xn):ae.prototype.lastIndexOf.call(Gt,En,xn):Sn(Gt,[En],xn,In,Wn);throw new TypeError("val must be string, number or Buffer")}function Sn(Gt,En,xn,In,Wn){let jn=1,zn=Gt.length,Ri=En.length;if(In!==void 0&&(In=String(In).toLowerCase(),In==="ucs2"||In==="ucs-2"||In==="utf16le"||In==="utf-16le")){if(Gt.length<2||En.length<2)return-1;jn=2,zn/=2,Ri/=2,xn/=2}function Qn(Ci,ri){return jn===1?Ci[ri]:Ci.readUInt16BE(ri*jn)}let li;if(Wn){let Ci=-1;for(li=xn;li<zn;li++)if(Qn(Gt,li)===Qn(En,Ci===-1?0:li-Ci)){if(Ci===-1&&(Ci=li),li-Ci+1===Ri)return Ci*jn}else Ci!==-1&&(li-=li-Ci),Ci=-1}else for(xn+Ri>zn&&(xn=zn-Ri),li=xn;li>=0;li--){let Ci=!0;for(let ri=0;ri<Ri;ri++)if(Qn(Gt,li+ri)!==Qn(En,ri)){Ci=!1;break}if(Ci)return li}return-1}we.prototype.includes=function(Gt,En,xn){return this.indexOf(Gt,En,xn)!==-1},we.prototype.indexOf=function(Gt,En,xn){return Ht(this,Gt,En,xn,!0)},we.prototype.lastIndexOf=function(Gt,En,xn){return Ht(this,Gt,En,xn,!1)};function le(Gt,En,xn,In){xn=Number(xn)||0;const Wn=Gt.length-xn;In?(In=Number(In),In>Wn&&(In=Wn)):In=Wn;const jn=En.length;In>jn/2&&(In=jn/2);let zn;for(zn=0;zn<In;++zn){const Ri=parseInt(En.substr(zn*2,2),16);if(On(Ri))return zn;Gt[xn+zn]=Ri}return zn}function pe(Gt,En,xn,In){return An(Kn(En,Gt.length-xn),Gt,xn,In)}function be(Gt,En,xn,In){return An(Jn(En),Gt,xn,In)}function xe(Gt,En,xn,In){return An(Hn(En),Gt,xn,In)}function _e(Gt,En,xn,In){return An(bi(En,Gt.length-xn),Gt,xn,In)}we.prototype.write=function(Gt,En,xn,In){if(En===void 0)In="utf8",xn=this.length,En=0;else if(xn===void 0&&typeof En=="string")In=En,xn=this.length,En=0;else if(isFinite(En))En=En>>>0,isFinite(xn)?(xn=xn>>>0,In===void 0&&(In="utf8")):(In=xn,xn=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");const Wn=this.length-En;if((xn===void 0||xn>Wn)&&(xn=Wn),Gt.length>0&&(xn<0||En<0)||En>this.length)throw new RangeError("Attempt to write outside buffer bounds");In||(In="utf8");let jn=!1;for(;;)switch(In){case"hex":return le(this,Gt,En,xn);case"utf8":case"utf-8":return pe(this,Gt,En,xn);case"ascii":case"latin1":case"binary":return be(this,Gt,En,xn);case"base64":return xe(this,Gt,En,xn);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return _e(this,Gt,En,xn);default:if(jn)throw new TypeError("Unknown encoding: "+In);In=(""+In).toLowerCase(),jn=!0}},we.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function De(Gt,En,xn){return En===0&&xn===Gt.length?t.fromByteArray(Gt):t.fromByteArray(Gt.slice(En,xn))}function Fe(Gt,En,xn){xn=Math.min(Gt.length,xn);const In=[];let Wn=En;for(;Wn<xn;){const jn=Gt[Wn];let zn=null,Ri=jn>239?4:jn>223?3:jn>191?2:1;if(Wn+Ri<=xn){let Qn,li,Ci,ri;switch(Ri){case 1:jn<128&&(zn=jn);break;case 2:Qn=Gt[Wn+1],(Qn&192)===128&&(ri=(jn&31)<<6|Qn&63,ri>127&&(zn=ri));break;case 3:Qn=Gt[Wn+1],li=Gt[Wn+2],(Qn&192)===128&&(li&192)===128&&(ri=(jn&15)<<12|(Qn&63)<<6|li&63,ri>2047&&(ri<55296||ri>57343)&&(zn=ri));break;case 4:Qn=Gt[Wn+1],li=Gt[Wn+2],Ci=Gt[Wn+3],(Qn&192)===128&&(li&192)===128&&(Ci&192)===128&&(ri=(jn&15)<<18|(Qn&63)<<12|(li&63)<<6|Ci&63,ri>65535&&ri<1114112&&(zn=ri))}}zn===null?(zn=65533,Ri=1):zn>65535&&(zn-=65536,In.push(zn>>>10&1023|55296),zn=56320|zn&1023),In.push(zn),Wn+=Ri}return ce(In)}const $e=4096;function ce(Gt){const En=Gt.length;if(En<=$e)return String.fromCharCode.apply(String,Gt);let xn="",In=0;for(;In<En;)xn+=String.fromCharCode.apply(String,Gt.slice(In,In+=$e));return xn}function Me(Gt,En,xn){let In="";xn=Math.min(Gt.length,xn);for(let Wn=En;Wn<xn;++Wn)In+=String.fromCharCode(Gt[Wn]&127);return In}function We(Gt,En,xn){let In="";xn=Math.min(Gt.length,xn);for(let Wn=En;Wn<xn;++Wn)In+=String.fromCharCode(Gt[Wn]);return In}function $t(Gt,En,xn){const In=Gt.length;(!En||En<0)&&(En=0),(!xn||xn<0||xn>In)&&(xn=In);let Wn="";for(let jn=En;jn<xn;++jn)Wn+=Un[Gt[jn]];return Wn}function dn(Gt,En,xn){const In=Gt.slice(En,xn);let Wn="";for(let jn=0;jn<In.length-1;jn+=2)Wn+=String.fromCharCode(In[jn]+In[jn+1]*256);return Wn}we.prototype.slice=function(Gt,En){const xn=this.length;Gt=~~Gt,En=En===void 0?xn:~~En,Gt<0?(Gt+=xn,Gt<0&&(Gt=0)):Gt>xn&&(Gt=xn),En<0?(En+=xn,En<0&&(En=0)):En>xn&&(En=xn),En<Gt&&(En=Gt);const In=this.subarray(Gt,En);return Object.setPrototypeOf(In,we.prototype),In};function gn(Gt,En,xn){if(Gt%1!==0||Gt<0)throw new RangeError("offset is not uint");if(Gt+En>xn)throw new RangeError("Trying to access beyond buffer length")}we.prototype.readUintLE=we.prototype.readUIntLE=function(Gt,En,xn){Gt=Gt>>>0,En=En>>>0,xn||gn(Gt,En,this.length);let In=this[Gt],Wn=1,jn=0;for(;++jn<En&&(Wn*=256);)In+=this[Gt+jn]*Wn;return In},we.prototype.readUintBE=we.prototype.readUIntBE=function(Gt,En,xn){Gt=Gt>>>0,En=En>>>0,xn||gn(Gt,En,this.length);let In=this[Gt+--En],Wn=1;for(;En>0&&(Wn*=256);)In+=this[Gt+--En]*Wn;return In},we.prototype.readUint8=we.prototype.readUInt8=function(Gt,En){return Gt=Gt>>>0,En||gn(Gt,1,this.length),this[Gt]},we.prototype.readUint16LE=we.prototype.readUInt16LE=function(Gt,En){return Gt=Gt>>>0,En||gn(Gt,2,this.length),this[Gt]|this[Gt+1]<<8},we.prototype.readUint16BE=we.prototype.readUInt16BE=function(Gt,En){return Gt=Gt>>>0,En||gn(Gt,2,this.length),this[Gt]<<8|this[Gt+1]},we.prototype.readUint32LE=we.prototype.readUInt32LE=function(Gt,En){return Gt=Gt>>>0,En||gn(Gt,4,this.length),(this[Gt]|this[Gt+1]<<8|this[Gt+2]<<16)+this[Gt+3]*16777216},we.prototype.readUint32BE=we.prototype.readUInt32BE=function(Gt,En){return Gt=Gt>>>0,En||gn(Gt,4,this.length),this[Gt]*16777216+(this[Gt+1]<<16|this[Gt+2]<<8|this[Gt+3])},we.prototype.readBigUInt64LE=ti(function(Gt){Gt=Gt>>>0,Zn(Gt,"offset");const En=this[Gt],xn=this[Gt+7];(En===void 0||xn===void 0)&&qn(Gt,this.length-8);const In=En+this[++Gt]*2**8+this[++Gt]*2**16+this[++Gt]*2**24,Wn=this[++Gt]+this[++Gt]*2**8+this[++Gt]*2**16+xn*2**24;return BigInt(In)+(BigInt(Wn)<<BigInt(32))}),we.prototype.readBigUInt64BE=ti(function(Gt){Gt=Gt>>>0,Zn(Gt,"offset");const En=this[Gt],xn=this[Gt+7];(En===void 0||xn===void 0)&&qn(Gt,this.length-8);const In=En*2**24+this[++Gt]*2**16+this[++Gt]*2**8+this[++Gt],Wn=this[++Gt]*2**24+this[++Gt]*2**16+this[++Gt]*2**8+xn;return(BigInt(In)<<BigInt(32))+BigInt(Wn)}),we.prototype.readIntLE=function(Gt,En,xn){Gt=Gt>>>0,En=En>>>0,xn||gn(Gt,En,this.length);let In=this[Gt],Wn=1,jn=0;for(;++jn<En&&(Wn*=256);)In+=this[Gt+jn]*Wn;return Wn*=128,In>=Wn&&(In-=Math.pow(2,8*En)),In},we.prototype.readIntBE=function(Gt,En,xn){Gt=Gt>>>0,En=En>>>0,xn||gn(Gt,En,this.length);let In=En,Wn=1,jn=this[Gt+--In];for(;In>0&&(Wn*=256);)jn+=this[Gt+--In]*Wn;return Wn*=128,jn>=Wn&&(jn-=Math.pow(2,8*En)),jn},we.prototype.readInt8=function(Gt,En){return Gt=Gt>>>0,En||gn(Gt,1,this.length),this[Gt]&128?(255-this[Gt]+1)*-1:this[Gt]},we.prototype.readInt16LE=function(Gt,En){Gt=Gt>>>0,En||gn(Gt,2,this.length);const xn=this[Gt]|this[Gt+1]<<8;return xn&32768?xn|4294901760:xn},we.prototype.readInt16BE=function(Gt,En){Gt=Gt>>>0,En||gn(Gt,2,this.length);const xn=this[Gt+1]|this[Gt]<<8;return xn&32768?xn|4294901760:xn},we.prototype.readInt32LE=function(Gt,En){return Gt=Gt>>>0,En||gn(Gt,4,this.length),this[Gt]|this[Gt+1]<<8|this[Gt+2]<<16|this[Gt+3]<<24},we.prototype.readInt32BE=function(Gt,En){return Gt=Gt>>>0,En||gn(Gt,4,this.length),this[Gt]<<24|this[Gt+1]<<16|this[Gt+2]<<8|this[Gt+3]},we.prototype.readBigInt64LE=ti(function(Gt){Gt=Gt>>>0,Zn(Gt,"offset");const En=this[Gt],xn=this[Gt+7];(En===void 0||xn===void 0)&&qn(Gt,this.length-8);const In=this[Gt+4]+this[Gt+5]*2**8+this[Gt+6]*2**16+(xn<<24);return(BigInt(In)<<BigInt(32))+BigInt(En+this[++Gt]*2**8+this[++Gt]*2**16+this[++Gt]*2**24)}),we.prototype.readBigInt64BE=ti(function(Gt){Gt=Gt>>>0,Zn(Gt,"offset");const En=this[Gt],xn=this[Gt+7];(En===void 0||xn===void 0)&&qn(Gt,this.length-8);const In=(En<<24)+this[++Gt]*2**16+this[++Gt]*2**8+this[++Gt];return(BigInt(In)<<BigInt(32))+BigInt(this[++Gt]*2**24+this[++Gt]*2**16+this[++Gt]*2**8+xn)}),we.prototype.readFloatLE=function(Gt,En){return Gt=Gt>>>0,En||gn(Gt,4,this.length),c.read(this,Gt,!0,23,4)},we.prototype.readFloatBE=function(Gt,En){return Gt=Gt>>>0,En||gn(Gt,4,this.length),c.read(this,Gt,!1,23,4)},we.prototype.readDoubleLE=function(Gt,En){return Gt=Gt>>>0,En||gn(Gt,8,this.length),c.read(this,Gt,!0,52,8)},we.prototype.readDoubleBE=function(Gt,En){return Gt=Gt>>>0,En||gn(Gt,8,this.length),c.read(this,Gt,!1,52,8)};function Vt(Gt,En,xn,In,Wn,jn){if(!we.isBuffer(Gt))throw new TypeError('"buffer" argument must be a Buffer instance');if(En>Wn||En<jn)throw new RangeError('"value" argument is out of bounds');if(xn+In>Gt.length)throw new RangeError("Index out of range")}we.prototype.writeUintLE=we.prototype.writeUIntLE=function(Gt,En,xn,In){if(Gt=+Gt,En=En>>>0,xn=xn>>>0,!In){const zn=Math.pow(2,8*xn)-1;Vt(this,Gt,En,xn,zn,0)}let Wn=1,jn=0;for(this[En]=Gt&255;++jn<xn&&(Wn*=256);)this[En+jn]=Gt/Wn&255;return En+xn},we.prototype.writeUintBE=we.prototype.writeUIntBE=function(Gt,En,xn,In){if(Gt=+Gt,En=En>>>0,xn=xn>>>0,!In){const zn=Math.pow(2,8*xn)-1;Vt(this,Gt,En,xn,zn,0)}let Wn=xn-1,jn=1;for(this[En+Wn]=Gt&255;--Wn>=0&&(jn*=256);)this[En+Wn]=Gt/jn&255;return En+xn},we.prototype.writeUint8=we.prototype.writeUInt8=function(Gt,En,xn){return Gt=+Gt,En=En>>>0,xn||Vt(this,Gt,En,1,255,0),this[En]=Gt&255,En+1},we.prototype.writeUint16LE=we.prototype.writeUInt16LE=function(Gt,En,xn){return Gt=+Gt,En=En>>>0,xn||Vt(this,Gt,En,2,65535,0),this[En]=Gt&255,this[En+1]=Gt>>>8,En+2},we.prototype.writeUint16BE=we.prototype.writeUInt16BE=function(Gt,En,xn){return Gt=+Gt,En=En>>>0,xn||Vt(this,Gt,En,2,65535,0),this[En]=Gt>>>8,this[En+1]=Gt&255,En+2},we.prototype.writeUint32LE=we.prototype.writeUInt32LE=function(Gt,En,xn){return Gt=+Gt,En=En>>>0,xn||Vt(this,Gt,En,4,4294967295,0),this[En+3]=Gt>>>24,this[En+2]=Gt>>>16,this[En+1]=Gt>>>8,this[En]=Gt&255,En+4},we.prototype.writeUint32BE=we.prototype.writeUInt32BE=function(Gt,En,xn){return Gt=+Gt,En=En>>>0,xn||Vt(this,Gt,En,4,4294967295,0),this[En]=Gt>>>24,this[En+1]=Gt>>>16,this[En+2]=Gt>>>8,this[En+3]=Gt&255,En+4};function Cn(Gt,En,xn,In,Wn){Nn(En,In,Wn,Gt,xn,7);let jn=Number(En&BigInt(4294967295));Gt[xn++]=jn,jn=jn>>8,Gt[xn++]=jn,jn=jn>>8,Gt[xn++]=jn,jn=jn>>8,Gt[xn++]=jn;let zn=Number(En>>BigInt(32)&BigInt(4294967295));return Gt[xn++]=zn,zn=zn>>8,Gt[xn++]=zn,zn=zn>>8,Gt[xn++]=zn,zn=zn>>8,Gt[xn++]=zn,xn}function un(Gt,En,xn,In,Wn){Nn(En,In,Wn,Gt,xn,7);let jn=Number(En&BigInt(4294967295));Gt[xn+7]=jn,jn=jn>>8,Gt[xn+6]=jn,jn=jn>>8,Gt[xn+5]=jn,jn=jn>>8,Gt[xn+4]=jn;let zn=Number(En>>BigInt(32)&BigInt(4294967295));return Gt[xn+3]=zn,zn=zn>>8,Gt[xn+2]=zn,zn=zn>>8,Gt[xn+1]=zn,zn=zn>>8,Gt[xn]=zn,xn+8}we.prototype.writeBigUInt64LE=ti(function(Gt,En=0){return Cn(this,Gt,En,BigInt(0),BigInt("0xffffffffffffffff"))}),we.prototype.writeBigUInt64BE=ti(function(Gt,En=0){return un(this,Gt,En,BigInt(0),BigInt("0xffffffffffffffff"))}),we.prototype.writeIntLE=function(Gt,En,xn,In){if(Gt=+Gt,En=En>>>0,!In){const Ri=Math.pow(2,8*xn-1);Vt(this,Gt,En,xn,Ri-1,-Ri)}let Wn=0,jn=1,zn=0;for(this[En]=Gt&255;++Wn<xn&&(jn*=256);)Gt<0&&zn===0&&this[En+Wn-1]!==0&&(zn=1),this[En+Wn]=(Gt/jn>>0)-zn&255;return En+xn},we.prototype.writeIntBE=function(Gt,En,xn,In){if(Gt=+Gt,En=En>>>0,!In){const Ri=Math.pow(2,8*xn-1);Vt(this,Gt,En,xn,Ri-1,-Ri)}let Wn=xn-1,jn=1,zn=0;for(this[En+Wn]=Gt&255;--Wn>=0&&(jn*=256);)Gt<0&&zn===0&&this[En+Wn+1]!==0&&(zn=1),this[En+Wn]=(Gt/jn>>0)-zn&255;return En+xn},we.prototype.writeInt8=function(Gt,En,xn){return Gt=+Gt,En=En>>>0,xn||Vt(this,Gt,En,1,127,-128),Gt<0&&(Gt=255+Gt+1),this[En]=Gt&255,En+1},we.prototype.writeInt16LE=function(Gt,En,xn){return Gt=+Gt,En=En>>>0,xn||Vt(this,Gt,En,2,32767,-32768),this[En]=Gt&255,this[En+1]=Gt>>>8,En+2},we.prototype.writeInt16BE=function(Gt,En,xn){return Gt=+Gt,En=En>>>0,xn||Vt(this,Gt,En,2,32767,-32768),this[En]=Gt>>>8,this[En+1]=Gt&255,En+2},we.prototype.writeInt32LE=function(Gt,En,xn){return Gt=+Gt,En=En>>>0,xn||Vt(this,Gt,En,4,2147483647,-2147483648),this[En]=Gt&255,this[En+1]=Gt>>>8,this[En+2]=Gt>>>16,this[En+3]=Gt>>>24,En+4},we.prototype.writeInt32BE=function(Gt,En,xn){return Gt=+Gt,En=En>>>0,xn||Vt(this,Gt,En,4,2147483647,-2147483648),Gt<0&&(Gt=4294967295+Gt+1),this[En]=Gt>>>24,this[En+1]=Gt>>>16,this[En+2]=Gt>>>8,this[En+3]=Gt&255,En+4},we.prototype.writeBigInt64LE=ti(function(Gt,En=0){return Cn(this,Gt,En,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),we.prototype.writeBigInt64BE=ti(function(Gt,En=0){return un(this,Gt,En,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function Pt(Gt,En,xn,In,Wn,jn){if(xn+In>Gt.length)throw new RangeError("Index out of range");if(xn<0)throw new RangeError("Index out of range")}function mn(Gt,En,xn,In,Wn){return En=+En,xn=xn>>>0,Wn||Pt(Gt,En,xn,4),c.write(Gt,En,xn,In,23,4),xn+4}we.prototype.writeFloatLE=function(Gt,En,xn){return mn(this,Gt,En,!0,xn)},we.prototype.writeFloatBE=function(Gt,En,xn){return mn(this,Gt,En,!1,xn)};function Pn(Gt,En,xn,In,Wn){return En=+En,xn=xn>>>0,Wn||Pt(Gt,En,xn,8),c.write(Gt,En,xn,In,52,8),xn+8}we.prototype.writeDoubleLE=function(Gt,En,xn){return Pn(this,Gt,En,!0,xn)},we.prototype.writeDoubleBE=function(Gt,En,xn){return Pn(this,Gt,En,!1,xn)},we.prototype.copy=function(Gt,En,xn,In){if(!we.isBuffer(Gt))throw new TypeError("argument should be a Buffer");if(xn||(xn=0),!In&&In!==0&&(In=this.length),En>=Gt.length&&(En=Gt.length),En||(En=0),In>0&&In<xn&&(In=xn),In===xn||Gt.length===0||this.length===0)return 0;if(En<0)throw new RangeError("targetStart out of bounds");if(xn<0||xn>=this.length)throw new RangeError("Index out of range");if(In<0)throw new RangeError("sourceEnd out of bounds");In>this.length&&(In=this.length),Gt.length-En<In-xn&&(In=Gt.length-En+xn);const Wn=In-xn;return this===Gt&&typeof ae.prototype.copyWithin=="function"?this.copyWithin(En,xn,In):ae.prototype.set.call(Gt,this.subarray(xn,In),En),Wn},we.prototype.fill=function(Gt,En,xn,In){if(typeof Gt=="string"){if(typeof En=="string"?(In=En,En=0,xn=this.length):typeof xn=="string"&&(In=xn,xn=this.length),In!==void 0&&typeof In!="string")throw new TypeError("encoding must be a string");if(typeof In=="string"&&!we.isEncoding(In))throw new TypeError("Unknown encoding: "+In);if(Gt.length===1){const jn=Gt.charCodeAt(0);(In==="utf8"&&jn<128||In==="latin1")&&(Gt=jn)}}else typeof Gt=="number"?Gt=Gt&255:typeof Gt=="boolean"&&(Gt=Number(Gt));if(En<0||this.length<En||this.length<xn)throw new RangeError("Out of range index");if(xn<=En)return this;En=En>>>0,xn=xn===void 0?this.length:xn>>>0,Gt||(Gt=0);let Wn;if(typeof Gt=="number")for(Wn=En;Wn<xn;++Wn)this[Wn]=Gt;else{const jn=we.isBuffer(Gt)?Gt:we.from(Gt,In),zn=jn.length;if(zn===0)throw new TypeError('The value "'+Gt+'" is invalid for argument "value"');for(Wn=0;Wn<xn-En;++Wn)this[Wn+En]=jn[Wn%zn]}return this};const wn={};function jt(Gt,En,xn){wn[Gt]=class extends xn{constructor(){super(),Object.defineProperty(this,"message",{value:En.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${Gt}]`,this.stack,delete this.name}get code(){return Gt}set code(In){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:In,writable:!0})}toString(){return`${this.name} [${Gt}]: ${this.message}`}}}jt("ERR_BUFFER_OUT_OF_BOUNDS",function(Gt){return Gt?`${Gt} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),jt("ERR_INVALID_ARG_TYPE",function(Gt,En){return`The "${Gt}" argument must be of type number. Received type ${typeof En}`},TypeError),jt("ERR_OUT_OF_RANGE",function(Gt,En,xn){let In=`The value of "${Gt}" is out of range.`,Wn=xn;return Number.isInteger(xn)&&Math.abs(xn)>2**32?Wn=$n(String(xn)):typeof xn=="bigint"&&(Wn=String(xn),(xn>BigInt(2)**BigInt(32)||xn<-(BigInt(2)**BigInt(32)))&&(Wn=$n(Wn)),Wn+="n"),In+=` It must be ${En}. Received ${Wn}`,In},RangeError);function $n(Gt){let En="",xn=Gt.length;const In=Gt[0]==="-"?1:0;for(;xn>=In+4;xn-=3)En=`_${Gt.slice(xn-3,xn)}${En}`;return`${Gt.slice(0,xn)}${En}`}function Mn(Gt,En,xn){Zn(En,"offset"),(Gt[En]===void 0||Gt[En+xn]===void 0)&&qn(En,Gt.length-(xn+1))}function Nn(Gt,En,xn,In,Wn,jn){if(Gt>xn||Gt<En){const zn=typeof En=="bigint"?"n":"";let Ri;throw En===0||En===BigInt(0)?Ri=`>= 0${zn} and < 2${zn} ** ${(jn+1)*8}${zn}`:Ri=`>= -(2${zn} ** ${(jn+1)*8-1}${zn}) and < 2 ** ${(jn+1)*8-1}${zn}`,new wn.ERR_OUT_OF_RANGE("value",Ri,Gt)}Mn(In,Wn,jn)}function Zn(Gt,En){if(typeof Gt!="number")throw new wn.ERR_INVALID_ARG_TYPE(En,"number",Gt)}function qn(Gt,En,xn){throw Math.floor(Gt)!==Gt?(Zn(Gt,xn),new wn.ERR_OUT_OF_RANGE("offset","an integer",Gt)):En<0?new wn.ERR_BUFFER_OUT_OF_BOUNDS:new wn.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${En}`,Gt)}const Vn=/[^+/0-9A-Za-z-_]/g;function Gn(Gt){if(Gt=Gt.split("=")[0],Gt=Gt.trim().replace(Vn,""),Gt.length<2)return"";for(;Gt.length%4!==0;)Gt=Gt+"=";return Gt}function Kn(Gt,En){En=En||1/0;let xn;const In=Gt.length;let Wn=null;const jn=[];for(let zn=0;zn<In;++zn){if(xn=Gt.charCodeAt(zn),xn>55295&&xn<57344){if(!Wn){if(xn>56319){(En-=3)>-1&&jn.push(239,191,189);continue}else if(zn+1===In){(En-=3)>-1&&jn.push(239,191,189);continue}Wn=xn;continue}if(xn<56320){(En-=3)>-1&&jn.push(239,191,189),Wn=xn;continue}xn=(Wn-55296<<10|xn-56320)+65536}else Wn&&(En-=3)>-1&&jn.push(239,191,189);if(Wn=null,xn<128){if((En-=1)<0)break;jn.push(xn)}else if(xn<2048){if((En-=2)<0)break;jn.push(xn>>6|192,xn&63|128)}else if(xn<65536){if((En-=3)<0)break;jn.push(xn>>12|224,xn>>6&63|128,xn&63|128)}else if(xn<1114112){if((En-=4)<0)break;jn.push(xn>>18|240,xn>>12&63|128,xn>>6&63|128,xn&63|128)}else throw new Error("Invalid code point")}return jn}function Jn(Gt){const En=[];for(let xn=0;xn<Gt.length;++xn)En.push(Gt.charCodeAt(xn)&255);return En}function bi(Gt,En){let xn,In,Wn;const jn=[];for(let zn=0;zn<Gt.length&&!((En-=2)<0);++zn)xn=Gt.charCodeAt(zn),In=xn>>8,Wn=xn%256,jn.push(Wn),jn.push(In);return jn}function Hn(Gt){return t.toByteArray(Gn(Gt))}function An(Gt,En,xn,In){let Wn;for(Wn=0;Wn<In&&!(Wn+xn>=En.length||Wn>=Gt.length);++Wn)En[Wn+xn]=Gt[Wn];return Wn}function Ln(Gt,En){return Gt instanceof En||Gt!=null&&Gt.constructor!=null&&Gt.constructor.name!=null&&Gt.constructor.name===En.name}function On(Gt){return Gt!==Gt}const Un=(function(){const Gt="0123456789abcdef",En=new Array(256);for(let xn=0;xn<16;++xn){const In=xn*16;for(let Wn=0;Wn<16;++Wn)En[In+Wn]=Gt[xn]+Gt[Wn]}return En})();function ti(Gt){return typeof BigInt>"u"?Fn:Gt}function Fn(){throw new Error("BigInt not supported")}})(buffer$1);const Buffer$7=buffer$1.Buffer,Blob$2=buffer$1.Blob,BlobOptions=buffer$1.BlobOptions,Buffer$1$1=buffer$1.Buffer,File=buffer$1.File,FileOptions=buffer$1.FileOptions,INSPECT_MAX_BYTES=buffer$1.INSPECT_MAX_BYTES,SlowBuffer=buffer$1.SlowBuffer,TranscodeEncoding=buffer$1.TranscodeEncoding,atob$1=buffer$1.atob,btoa$1=buffer$1.btoa,constants$4=buffer$1.constants,isAscii=buffer$1.isAscii,isUtf8=buffer$1.isUtf8,kMaxLength=buffer$1.kMaxLength,kStringMaxLength=buffer$1.kStringMaxLength,resolveObjectURL=buffer$1.resolveObjectURL,transcode=buffer$1.transcode,dist$1=Object.freeze(Object.defineProperty({__proto__:null,Blob:Blob$2,BlobOptions,Buffer:Buffer$1$1,File,FileOptions,INSPECT_MAX_BYTES,SlowBuffer,TranscodeEncoding,atob:atob$1,btoa:btoa$1,constants:constants$4,default:Buffer$7,isAscii,isUtf8,kMaxLength,kStringMaxLength,resolveObjectURL,transcode},Symbol.toStringTag,{value:"Module"})),require$$0$4=getAugmentedNamespace(dist$1);(function(n){(function(t,c){function ie(be,xe){if(!be)throw new Error(xe||"Assertion failed")}function se(be,xe){be.super_=xe;var _e=function(){};_e.prototype=xe.prototype,be.prototype=new _e,be.prototype.constructor=be}function ae(be,xe,_e){if(ae.isBN(be))return be;this.negative=0,this.words=null,this.length=0,this.red=null,be!==null&&((xe==="le"||xe==="be")&&(_e=xe,xe=10),this._init(be||0,xe||10,_e||"be"))}typeof t=="object"?t.exports=ae:c.BN=ae,ae.BN=ae,ae.wordSize=26;var ue;try{typeof window<"u"&&typeof window.Buffer<"u"?ue=window.Buffer:ue=require$$0$4.Buffer}catch{}ae.isBN=function(be){return be instanceof ae?!0:be!==null&&typeof be=="object"&&be.constructor.wordSize===ae.wordSize&&Array.isArray(be.words)},ae.max=function(be,xe){return be.cmp(xe)>0?be:xe},ae.min=function(be,xe){return be.cmp(xe)<0?be:xe},ae.prototype._init=function(be,xe,_e){if(typeof be=="number")return this._initNumber(be,xe,_e);if(typeof be=="object")return this._initArray(be,xe,_e);xe==="hex"&&(xe=16),ie(xe===(xe|0)&&xe>=2&&xe<=36),be=be.toString().replace(/\s+/g,"");var De=0;be[0]==="-"&&(De++,this.negative=1),De<be.length&&(xe===16?this._parseHex(be,De,_e):(this._parseBase(be,xe,De),_e==="le"&&this._initArray(this.toArray(),xe,_e)))},ae.prototype._initNumber=function(be,xe,_e){be<0&&(this.negative=1,be=-be),be<67108864?(this.words=[be&67108863],this.length=1):be<4503599627370496?(this.words=[be&67108863,be/67108864&67108863],this.length=2):(ie(be<9007199254740992),this.words=[be&67108863,be/67108864&67108863,1],this.length=3),_e==="le"&&this._initArray(this.toArray(),xe,_e)},ae.prototype._initArray=function(be,xe,_e){if(ie(typeof be.length=="number"),be.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(be.length/3),this.words=new Array(this.length);for(var De=0;De<this.length;De++)this.words[De]=0;var Fe,$e,ce=0;if(_e==="be")for(De=be.length-1,Fe=0;De>=0;De-=3)$e=be[De]|be[De-1]<<8|be[De-2]<<16,this.words[Fe]|=$e<<ce&67108863,this.words[Fe+1]=$e>>>26-ce&67108863,ce+=24,ce>=26&&(ce-=26,Fe++);else if(_e==="le")for(De=0,Fe=0;De<be.length;De+=3)$e=be[De]|be[De+1]<<8|be[De+2]<<16,this.words[Fe]|=$e<<ce&67108863,this.words[Fe+1]=$e>>>26-ce&67108863,ce+=24,ce>=26&&(ce-=26,Fe++);return this._strip()};function de(be,xe){var _e=be.charCodeAt(xe);if(_e>=48&&_e<=57)return _e-48;if(_e>=65&&_e<=70)return _e-55;if(_e>=97&&_e<=102)return _e-87;ie(!1,"Invalid character in "+be)}function ve(be,xe,_e){var De=de(be,_e);return _e-1>=xe&&(De|=de(be,_e-1)<<4),De}ae.prototype._parseHex=function(be,xe,_e){this.length=Math.ceil((be.length-xe)/6),this.words=new Array(this.length);for(var De=0;De<this.length;De++)this.words[De]=0;var Fe=0,$e=0,ce;if(_e==="be")for(De=be.length-1;De>=xe;De-=2)ce=ve(be,xe,De)<<Fe,this.words[$e]|=ce&67108863,Fe>=18?(Fe-=18,$e+=1,this.words[$e]|=ce>>>26):Fe+=8;else{var Me=be.length-xe;for(De=Me%2===0?xe+1:xe;De<be.length;De+=2)ce=ve(be,xe,De)<<Fe,this.words[$e]|=ce&67108863,Fe>=18?(Fe-=18,$e+=1,this.words[$e]|=ce>>>26):Fe+=8}this._strip()};function ge(be,xe,_e,De){for(var Fe=0,$e=0,ce=Math.min(be.length,_e),Me=xe;Me<ce;Me++){var We=be.charCodeAt(Me)-48;Fe*=De,We>=49?$e=We-49+10:We>=17?$e=We-17+10:$e=We,ie(We>=0&&$e<De,"Invalid character"),Fe+=$e}return Fe}ae.prototype._parseBase=function(be,xe,_e){this.words=[0],this.length=1;for(var De=0,Fe=1;Fe<=67108863;Fe*=xe)De++;De--,Fe=Fe/xe|0;for(var $e=be.length-_e,ce=$e%De,Me=Math.min($e,$e-ce)+_e,We=0,$t=_e;$t<Me;$t+=De)We=ge(be,$t,$t+De,xe),this.imuln(Fe),this.words[0]+We<67108864?this.words[0]+=We:this._iaddn(We);if(ce!==0){var dn=1;for(We=ge(be,$t,be.length,xe),$t=0;$t<ce;$t++)dn*=xe;this.imuln(dn),this.words[0]+We<67108864?this.words[0]+=We:this._iaddn(We)}this._strip()},ae.prototype.copy=function(be){be.words=new Array(this.length);for(var xe=0;xe<this.length;xe++)be.words[xe]=this.words[xe];be.length=this.length,be.negative=this.negative,be.red=this.red};function we(be,xe){be.words=xe.words,be.length=xe.length,be.negative=xe.negative,be.red=xe.red}if(ae.prototype._move=function(be){we(be,this)},ae.prototype.clone=function(){var be=new ae(null);return this.copy(be),be},ae.prototype._expand=function(be){for(;this.length<be;)this.words[this.length++]=0;return this},ae.prototype._strip=function(){for(;this.length>1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},ae.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},typeof Symbol<"u"&&typeof Symbol.for=="function")try{ae.prototype[Symbol.for("nodejs.util.inspect.custom")]=Te}catch{ae.prototype.inspect=Te}else ae.prototype.inspect=Te;function Te(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"}var Ne=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],qe=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],ze=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];ae.prototype.toString=function(be,xe){be=be||10,xe=xe|0||1;var _e;if(be===16||be==="hex"){_e="";for(var De=0,Fe=0,$e=0;$e<this.length;$e++){var ce=this.words[$e],Me=((ce<<De|Fe)&16777215).toString(16);Fe=ce>>>24-De&16777215,De+=2,De>=26&&(De-=26,$e--),Fe!==0||$e!==this.length-1?_e=Ne[6-Me.length]+Me+_e:_e=Me+_e}for(Fe!==0&&(_e=Fe.toString(16)+_e);_e.length%xe!==0;)_e="0"+_e;return this.negative!==0&&(_e="-"+_e),_e}if(be===(be|0)&&be>=2&&be<=36){var We=qe[be],$t=ze[be];_e="";var dn=this.clone();for(dn.negative=0;!dn.isZero();){var gn=dn.modrn($t).toString(be);dn=dn.idivn($t),dn.isZero()?_e=gn+_e:_e=Ne[We-gn.length]+gn+_e}for(this.isZero()&&(_e="0"+_e);_e.length%xe!==0;)_e="0"+_e;return this.negative!==0&&(_e="-"+_e),_e}ie(!1,"Base should be between 2 and 36")},ae.prototype.toNumber=function(){var be=this.words[0];return this.length===2?be+=this.words[1]*67108864:this.length===3&&this.words[2]===1?be+=4503599627370496+this.words[1]*67108864:this.length>2&&ie(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-be:be},ae.prototype.toJSON=function(){return this.toString(16,2)},ue&&(ae.prototype.toBuffer=function(be,xe){return this.toArrayLike(ue,be,xe)}),ae.prototype.toArray=function(be,xe){return this.toArrayLike(Array,be,xe)};var He=function(be,xe){return be.allocUnsafe?be.allocUnsafe(xe):new be(xe)};ae.prototype.toArrayLike=function(be,xe,_e){this._strip();var De=this.byteLength(),Fe=_e||Math.max(1,De);ie(De<=Fe,"byte array longer than desired length"),ie(Fe>0,"Requested array length <= 0");var $e=He(be,Fe),ce=xe==="le"?"LE":"BE";return this["_toArrayLike"+ce]($e,De),$e},ae.prototype._toArrayLikeLE=function(be,xe){for(var _e=0,De=0,Fe=0,$e=0;Fe<this.length;Fe++){var ce=this.words[Fe]<<$e|De;be[_e++]=ce&255,_e<be.length&&(be[_e++]=ce>>8&255),_e<be.length&&(be[_e++]=ce>>16&255),$e===6?(_e<be.length&&(be[_e++]=ce>>24&255),De=0,$e=0):(De=ce>>>24,$e+=2)}if(_e<be.length)for(be[_e++]=De;_e<be.length;)be[_e++]=0},ae.prototype._toArrayLikeBE=function(be,xe){for(var _e=be.length-1,De=0,Fe=0,$e=0;Fe<this.length;Fe++){var ce=this.words[Fe]<<$e|De;be[_e--]=ce&255,_e>=0&&(be[_e--]=ce>>8&255),_e>=0&&(be[_e--]=ce>>16&255),$e===6?(_e>=0&&(be[_e--]=ce>>24&255),De=0,$e=0):(De=ce>>>24,$e+=2)}if(_e>=0)for(be[_e--]=De;_e>=0;)be[_e--]=0},Math.clz32?ae.prototype._countBits=function(be){return 32-Math.clz32(be)}:ae.prototype._countBits=function(be){var xe=be,_e=0;return xe>=4096&&(_e+=13,xe>>>=13),xe>=64&&(_e+=7,xe>>>=7),xe>=8&&(_e+=4,xe>>>=4),xe>=2&&(_e+=2,xe>>>=2),_e+xe},ae.prototype._zeroBits=function(be){if(be===0)return 26;var xe=be,_e=0;return xe&8191||(_e+=13,xe>>>=13),xe&127||(_e+=7,xe>>>=7),xe&15||(_e+=4,xe>>>=4),xe&3||(_e+=2,xe>>>=2),xe&1||_e++,_e},ae.prototype.bitLength=function(){var be=this.words[this.length-1],xe=this._countBits(be);return(this.length-1)*26+xe};function Ge(be){for(var xe=new Array(be.bitLength()),_e=0;_e<xe.length;_e++){var De=_e/26|0,Fe=_e%26;xe[_e]=be.words[De]>>>Fe&1}return xe}ae.prototype.zeroBits=function(){if(this.isZero())return 0;for(var be=0,xe=0;xe<this.length;xe++){var _e=this._zeroBits(this.words[xe]);if(be+=_e,_e!==26)break}return be},ae.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},ae.prototype.toTwos=function(be){return this.negative!==0?this.abs().inotn(be).iaddn(1):this.clone()},ae.prototype.fromTwos=function(be){return this.testn(be-1)?this.notn(be).iaddn(1).ineg():this.clone()},ae.prototype.isNeg=function(){return this.negative!==0},ae.prototype.neg=function(){return this.clone().ineg()},ae.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},ae.prototype.iuor=function(be){for(;this.length<be.length;)this.words[this.length++]=0;for(var xe=0;xe<be.length;xe++)this.words[xe]=this.words[xe]|be.words[xe];return this._strip()},ae.prototype.ior=function(be){return ie((this.negative|be.negative)===0),this.iuor(be)},ae.prototype.or=function(be){return this.length>be.length?this.clone().ior(be):be.clone().ior(this)},ae.prototype.uor=function(be){return this.length>be.length?this.clone().iuor(be):be.clone().iuor(this)},ae.prototype.iuand=function(be){var xe;this.length>be.length?xe=be:xe=this;for(var _e=0;_e<xe.length;_e++)this.words[_e]=this.words[_e]&be.words[_e];return this.length=xe.length,this._strip()},ae.prototype.iand=function(be){return ie((this.negative|be.negative)===0),this.iuand(be)},ae.prototype.and=function(be){return this.length>be.length?this.clone().iand(be):be.clone().iand(this)},ae.prototype.uand=function(be){return this.length>be.length?this.clone().iuand(be):be.clone().iuand(this)},ae.prototype.iuxor=function(be){var xe,_e;this.length>be.length?(xe=this,_e=be):(xe=be,_e=this);for(var De=0;De<_e.length;De++)this.words[De]=xe.words[De]^_e.words[De];if(this!==xe)for(;De<xe.length;De++)this.words[De]=xe.words[De];return this.length=xe.length,this._strip()},ae.prototype.ixor=function(be){return ie((this.negative|be.negative)===0),this.iuxor(be)},ae.prototype.xor=function(be){return this.length>be.length?this.clone().ixor(be):be.clone().ixor(this)},ae.prototype.uxor=function(be){return this.length>be.length?this.clone().iuxor(be):be.clone().iuxor(this)},ae.prototype.inotn=function(be){ie(typeof be=="number"&&be>=0);var xe=Math.ceil(be/26)|0,_e=be%26;this._expand(xe),_e>0&&xe--;for(var De=0;De<xe;De++)this.words[De]=~this.words[De]&67108863;return _e>0&&(this.words[De]=~this.words[De]&67108863>>26-_e),this._strip()},ae.prototype.notn=function(be){return this.clone().inotn(be)},ae.prototype.setn=function(be,xe){ie(typeof be=="number"&&be>=0);var _e=be/26|0,De=be%26;return this._expand(_e+1),xe?this.words[_e]=this.words[_e]|1<<De:this.words[_e]=this.words[_e]&~(1<<De),this._strip()},ae.prototype.iadd=function(be){var xe;if(this.negative!==0&&be.negative===0)return this.negative=0,xe=this.isub(be),this.negative^=1,this._normSign();if(this.negative===0&&be.negative!==0)return be.negative=0,xe=this.isub(be),be.negative=1,xe._normSign();var _e,De;this.length>be.length?(_e=this,De=be):(_e=be,De=this);for(var Fe=0,$e=0;$e<De.length;$e++)xe=(_e.words[$e]|0)+(De.words[$e]|0)+Fe,this.words[$e]=xe&67108863,Fe=xe>>>26;for(;Fe!==0&&$e<_e.length;$e++)xe=(_e.words[$e]|0)+Fe,this.words[$e]=xe&67108863,Fe=xe>>>26;if(this.length=_e.length,Fe!==0)this.words[this.length]=Fe,this.length++;else if(_e!==this)for(;$e<_e.length;$e++)this.words[$e]=_e.words[$e];return this},ae.prototype.add=function(be){var xe;return be.negative!==0&&this.negative===0?(be.negative=0,xe=this.sub(be),be.negative^=1,xe):be.negative===0&&this.negative!==0?(this.negative=0,xe=be.sub(this),this.negative=1,xe):this.length>be.length?this.clone().iadd(be):be.clone().iadd(this)},ae.prototype.isub=function(be){if(be.negative!==0){be.negative=0;var xe=this.iadd(be);return be.negative=1,xe._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(be),this.negative=1,this._normSign();var _e=this.cmp(be);if(_e===0)return this.negative=0,this.length=1,this.words[0]=0,this;var De,Fe;_e>0?(De=this,Fe=be):(De=be,Fe=this);for(var $e=0,ce=0;ce<Fe.length;ce++)xe=(De.words[ce]|0)-(Fe.words[ce]|0)+$e,$e=xe>>26,this.words[ce]=xe&67108863;for(;$e!==0&&ce<De.length;ce++)xe=(De.words[ce]|0)+$e,$e=xe>>26,this.words[ce]=xe&67108863;if($e===0&&ce<De.length&&De!==this)for(;ce<De.length;ce++)this.words[ce]=De.words[ce];return this.length=Math.max(this.length,ce),De!==this&&(this.negative=1),this._strip()},ae.prototype.sub=function(be){return this.clone().isub(be)};function Ze(be,xe,_e){_e.negative=xe.negative^be.negative;var De=be.length+xe.length|0;_e.length=De,De=De-1|0;var Fe=be.words[0]|0,$e=xe.words[0]|0,ce=Fe*$e,Me=ce&67108863,We=ce/67108864|0;_e.words[0]=Me;for(var $t=1;$t<De;$t++){for(var dn=We>>>26,gn=We&67108863,Vt=Math.min($t,xe.length-1),Cn=Math.max(0,$t-be.length+1);Cn<=Vt;Cn++){var un=$t-Cn|0;Fe=be.words[un]|0,$e=xe.words[Cn]|0,ce=Fe*$e+gn,dn+=ce/67108864|0,gn=ce&67108863}_e.words[$t]=gn|0,We=dn|0}return We!==0?_e.words[$t]=We|0:_e.length--,_e._strip()}var Ye=function(be,xe,_e){var De=be.words,Fe=xe.words,$e=_e.words,ce=0,Me,We,$t,dn=De[0]|0,gn=dn&8191,Vt=dn>>>13,Cn=De[1]|0,un=Cn&8191,Pt=Cn>>>13,mn=De[2]|0,Pn=mn&8191,wn=mn>>>13,jt=De[3]|0,$n=jt&8191,Mn=jt>>>13,Nn=De[4]|0,Zn=Nn&8191,qn=Nn>>>13,Vn=De[5]|0,Gn=Vn&8191,Kn=Vn>>>13,Jn=De[6]|0,bi=Jn&8191,Hn=Jn>>>13,An=De[7]|0,Ln=An&8191,On=An>>>13,Un=De[8]|0,ti=Un&8191,Fn=Un>>>13,Gt=De[9]|0,En=Gt&8191,xn=Gt>>>13,In=Fe[0]|0,Wn=In&8191,jn=In>>>13,zn=Fe[1]|0,Ri=zn&8191,Qn=zn>>>13,li=Fe[2]|0,Ci=li&8191,ri=li>>>13,yi=Fe[3]|0,Ai=yi&8191,ci=yi>>>13,vi=Fe[4]|0,Mi=vi&8191,di=vi>>>13,wi=Fe[5]|0,Ti=wi&8191,hi=wi>>>13,xi=Fe[6]|0,Pi=xi&8191,pi=xi>>>13,Ei=Fe[7]|0,Bi=Ei&8191,mi=Ei>>>13,_i=Fe[8]|0,Ii=_i&8191,gi=_i>>>13,Si=Fe[9]|0,ki=Si&8191,$i=Si>>>13;_e.negative=be.negative^xe.negative,_e.length=19,Me=Math.imul(gn,Wn),We=Math.imul(gn,jn),We=We+Math.imul(Vt,Wn)|0,$t=Math.imul(Vt,jn);var Ni=(ce+Me|0)+((We&8191)<<13)|0;ce=($t+(We>>>13)|0)+(Ni>>>26)|0,Ni&=67108863,Me=Math.imul(un,Wn),We=Math.imul(un,jn),We=We+Math.imul(Pt,Wn)|0,$t=Math.imul(Pt,jn),Me=Me+Math.imul(gn,Ri)|0,We=We+Math.imul(gn,Qn)|0,We=We+Math.imul(Vt,Ri)|0,$t=$t+Math.imul(Vt,Qn)|0;var Oi=(ce+Me|0)+((We&8191)<<13)|0;ce=($t+(We>>>13)|0)+(Oi>>>26)|0,Oi&=67108863,Me=Math.imul(Pn,Wn),We=Math.imul(Pn,jn),We=We+Math.imul(wn,Wn)|0,$t=Math.imul(wn,jn),Me=Me+Math.imul(un,Ri)|0,We=We+Math.imul(un,Qn)|0,We=We+Math.imul(Pt,Ri)|0,$t=$t+Math.imul(Pt,Qn)|0,Me=Me+Math.imul(gn,Ci)|0,We=We+Math.imul(gn,ri)|0,We=We+Math.imul(Vt,Ci)|0,$t=$t+Math.imul(Vt,ri)|0;var Li=(ce+Me|0)+((We&8191)<<13)|0;ce=($t+(We>>>13)|0)+(Li>>>26)|0,Li&=67108863,Me=Math.imul($n,Wn),We=Math.imul($n,jn),We=We+Math.imul(Mn,Wn)|0,$t=Math.imul(Mn,jn),Me=Me+Math.imul(Pn,Ri)|0,We=We+Math.imul(Pn,Qn)|0,We=We+Math.imul(wn,Ri)|0,$t=$t+Math.imul(wn,Qn)|0,Me=Me+Math.imul(un,Ci)|0,We=We+Math.imul(un,ri)|0,We=We+Math.imul(Pt,Ci)|0,$t=$t+Math.imul(Pt,ri)|0,Me=Me+Math.imul(gn,Ai)|0,We=We+Math.imul(gn,ci)|0,We=We+Math.imul(Vt,Ai)|0,$t=$t+Math.imul(Vt,ci)|0;var Fi=(ce+Me|0)+((We&8191)<<13)|0;ce=($t+(We>>>13)|0)+(Fi>>>26)|0,Fi&=67108863,Me=Math.imul(Zn,Wn),We=Math.imul(Zn,jn),We=We+Math.imul(qn,Wn)|0,$t=Math.imul(qn,jn),Me=Me+Math.imul($n,Ri)|0,We=We+Math.imul($n,Qn)|0,We=We+Math.imul(Mn,Ri)|0,$t=$t+Math.imul(Mn,Qn)|0,Me=Me+Math.imul(Pn,Ci)|0,We=We+Math.imul(Pn,ri)|0,We=We+Math.imul(wn,Ci)|0,$t=$t+Math.imul(wn,ri)|0,Me=Me+Math.imul(un,Ai)|0,We=We+Math.imul(un,ci)|0,We=We+Math.imul(Pt,Ai)|0,$t=$t+Math.imul(Pt,ci)|0,Me=Me+Math.imul(gn,Mi)|0,We=We+Math.imul(gn,di)|0,We=We+Math.imul(Vt,Mi)|0,$t=$t+Math.imul(Vt,di)|0;var ji=(ce+Me|0)+((We&8191)<<13)|0;ce=($t+(We>>>13)|0)+(ji>>>26)|0,ji&=67108863,Me=Math.imul(Gn,Wn),We=Math.imul(Gn,jn),We=We+Math.imul(Kn,Wn)|0,$t=Math.imul(Kn,jn),Me=Me+Math.imul(Zn,Ri)|0,We=We+Math.imul(Zn,Qn)|0,We=We+Math.imul(qn,Ri)|0,$t=$t+Math.imul(qn,Qn)|0,Me=Me+Math.imul($n,Ci)|0,We=We+Math.imul($n,ri)|0,We=We+Math.imul(Mn,Ci)|0,$t=$t+Math.imul(Mn,ri)|0,Me=Me+Math.imul(Pn,Ai)|0,We=We+Math.imul(Pn,ci)|0,We=We+Math.imul(wn,Ai)|0,$t=$t+Math.imul(wn,ci)|0,Me=Me+Math.imul(un,Mi)|0,We=We+Math.imul(un,di)|0,We=We+Math.imul(Pt,Mi)|0,$t=$t+Math.imul(Pt,di)|0,Me=Me+Math.imul(gn,Ti)|0,We=We+Math.imul(gn,hi)|0,We=We+Math.imul(Vt,Ti)|0,$t=$t+Math.imul(Vt,hi)|0;var Di=(ce+Me|0)+((We&8191)<<13)|0;ce=($t+(We>>>13)|0)+(Di>>>26)|0,Di&=67108863,Me=Math.imul(bi,Wn),We=Math.imul(bi,jn),We=We+Math.imul(Hn,Wn)|0,$t=Math.imul(Hn,jn),Me=Me+Math.imul(Gn,Ri)|0,We=We+Math.imul(Gn,Qn)|0,We=We+Math.imul(Kn,Ri)|0,$t=$t+Math.imul(Kn,Qn)|0,Me=Me+Math.imul(Zn,Ci)|0,We=We+Math.imul(Zn,ri)|0,We=We+Math.imul(qn,Ci)|0,$t=$t+Math.imul(qn,ri)|0,Me=Me+Math.imul($n,Ai)|0,We=We+Math.imul($n,ci)|0,We=We+Math.imul(Mn,Ai)|0,$t=$t+Math.imul(Mn,ci)|0,Me=Me+Math.imul(Pn,Mi)|0,We=We+Math.imul(Pn,di)|0,We=We+Math.imul(wn,Mi)|0,$t=$t+Math.imul(wn,di)|0,Me=Me+Math.imul(un,Ti)|0,We=We+Math.imul(un,hi)|0,We=We+Math.imul(Pt,Ti)|0,$t=$t+Math.imul(Pt,hi)|0,Me=Me+Math.imul(gn,Pi)|0,We=We+Math.imul(gn,pi)|0,We=We+Math.imul(Vt,Pi)|0,$t=$t+Math.imul(Vt,pi)|0;var Ui=(ce+Me|0)+((We&8191)<<13)|0;ce=($t+(We>>>13)|0)+(Ui>>>26)|0,Ui&=67108863,Me=Math.imul(Ln,Wn),We=Math.imul(Ln,jn),We=We+Math.imul(On,Wn)|0,$t=Math.imul(On,jn),Me=Me+Math.imul(bi,Ri)|0,We=We+Math.imul(bi,Qn)|0,We=We+Math.imul(Hn,Ri)|0,$t=$t+Math.imul(Hn,Qn)|0,Me=Me+Math.imul(Gn,Ci)|0,We=We+Math.imul(Gn,ri)|0,We=We+Math.imul(Kn,Ci)|0,$t=$t+Math.imul(Kn,ri)|0,Me=Me+Math.imul(Zn,Ai)|0,We=We+Math.imul(Zn,ci)|0,We=We+Math.imul(qn,Ai)|0,$t=$t+Math.imul(qn,ci)|0,Me=Me+Math.imul($n,Mi)|0,We=We+Math.imul($n,di)|0,We=We+Math.imul(Mn,Mi)|0,$t=$t+Math.imul(Mn,di)|0,Me=Me+Math.imul(Pn,Ti)|0,We=We+Math.imul(Pn,hi)|0,We=We+Math.imul(wn,Ti)|0,$t=$t+Math.imul(wn,hi)|0,Me=Me+Math.imul(un,Pi)|0,We=We+Math.imul(un,pi)|0,We=We+Math.imul(Pt,Pi)|0,$t=$t+Math.imul(Pt,pi)|0,Me=Me+Math.imul(gn,Bi)|0,We=We+Math.imul(gn,mi)|0,We=We+Math.imul(Vt,Bi)|0,$t=$t+Math.imul(Vt,mi)|0;var qi=(ce+Me|0)+((We&8191)<<13)|0;ce=($t+(We>>>13)|0)+(qi>>>26)|0,qi&=67108863,Me=Math.imul(ti,Wn),We=Math.imul(ti,jn),We=We+Math.imul(Fn,Wn)|0,$t=Math.imul(Fn,jn),Me=Me+Math.imul(Ln,Ri)|0,We=We+Math.imul(Ln,Qn)|0,We=We+Math.imul(On,Ri)|0,$t=$t+Math.imul(On,Qn)|0,Me=Me+Math.imul(bi,Ci)|0,We=We+Math.imul(bi,ri)|0,We=We+Math.imul(Hn,Ci)|0,$t=$t+Math.imul(Hn,ri)|0,Me=Me+Math.imul(Gn,Ai)|0,We=We+Math.imul(Gn,ci)|0,We=We+Math.imul(Kn,Ai)|0,$t=$t+Math.imul(Kn,ci)|0,Me=Me+Math.imul(Zn,Mi)|0,We=We+Math.imul(Zn,di)|0,We=We+Math.imul(qn,Mi)|0,$t=$t+Math.imul(qn,di)|0,Me=Me+Math.imul($n,Ti)|0,We=We+Math.imul($n,hi)|0,We=We+Math.imul(Mn,Ti)|0,$t=$t+Math.imul(Mn,hi)|0,Me=Me+Math.imul(Pn,Pi)|0,We=We+Math.imul(Pn,pi)|0,We=We+Math.imul(wn,Pi)|0,$t=$t+Math.imul(wn,pi)|0,Me=Me+Math.imul(un,Bi)|0,We=We+Math.imul(un,mi)|0,We=We+Math.imul(Pt,Bi)|0,$t=$t+Math.imul(Pt,mi)|0,Me=Me+Math.imul(gn,Ii)|0,We=We+Math.imul(gn,gi)|0,We=We+Math.imul(Vt,Ii)|0,$t=$t+Math.imul(Vt,gi)|0;var Vi=(ce+Me|0)+((We&8191)<<13)|0;ce=($t+(We>>>13)|0)+(Vi>>>26)|0,Vi&=67108863,Me=Math.imul(En,Wn),We=Math.imul(En,jn),We=We+Math.imul(xn,Wn)|0,$t=Math.imul(xn,jn),Me=Me+Math.imul(ti,Ri)|0,We=We+Math.imul(ti,Qn)|0,We=We+Math.imul(Fn,Ri)|0,$t=$t+Math.imul(Fn,Qn)|0,Me=Me+Math.imul(Ln,Ci)|0,We=We+Math.imul(Ln,ri)|0,We=We+Math.imul(On,Ci)|0,$t=$t+Math.imul(On,ri)|0,Me=Me+Math.imul(bi,Ai)|0,We=We+Math.imul(bi,ci)|0,We=We+Math.imul(Hn,Ai)|0,$t=$t+Math.imul(Hn,ci)|0,Me=Me+Math.imul(Gn,Mi)|0,We=We+Math.imul(Gn,di)|0,We=We+Math.imul(Kn,Mi)|0,$t=$t+Math.imul(Kn,di)|0,Me=Me+Math.imul(Zn,Ti)|0,We=We+Math.imul(Zn,hi)|0,We=We+Math.imul(qn,Ti)|0,$t=$t+Math.imul(qn,hi)|0,Me=Me+Math.imul($n,Pi)|0,We=We+Math.imul($n,pi)|0,We=We+Math.imul(Mn,Pi)|0,$t=$t+Math.imul(Mn,pi)|0,Me=Me+Math.imul(Pn,Bi)|0,We=We+Math.imul(Pn,mi)|0,We=We+Math.imul(wn,Bi)|0,$t=$t+Math.imul(wn,mi)|0,Me=Me+Math.imul(un,Ii)|0,We=We+Math.imul(un,gi)|0,We=We+Math.imul(Pt,Ii)|0,$t=$t+Math.imul(Pt,gi)|0,Me=Me+Math.imul(gn,ki)|0,We=We+Math.imul(gn,$i)|0,We=We+Math.imul(Vt,ki)|0,$t=$t+Math.imul(Vt,$i)|0;var zi=(ce+Me|0)+((We&8191)<<13)|0;ce=($t+(We>>>13)|0)+(zi>>>26)|0,zi&=67108863,Me=Math.imul(En,Ri),We=Math.imul(En,Qn),We=We+Math.imul(xn,Ri)|0,$t=Math.imul(xn,Qn),Me=Me+Math.imul(ti,Ci)|0,We=We+Math.imul(ti,ri)|0,We=We+Math.imul(Fn,Ci)|0,$t=$t+Math.imul(Fn,ri)|0,Me=Me+Math.imul(Ln,Ai)|0,We=We+Math.imul(Ln,ci)|0,We=We+Math.imul(On,Ai)|0,$t=$t+Math.imul(On,ci)|0,Me=Me+Math.imul(bi,Mi)|0,We=We+Math.imul(bi,di)|0,We=We+Math.imul(Hn,Mi)|0,$t=$t+Math.imul(Hn,di)|0,Me=Me+Math.imul(Gn,Ti)|0,We=We+Math.imul(Gn,hi)|0,We=We+Math.imul(Kn,Ti)|0,$t=$t+Math.imul(Kn,hi)|0,Me=Me+Math.imul(Zn,Pi)|0,We=We+Math.imul(Zn,pi)|0,We=We+Math.imul(qn,Pi)|0,$t=$t+Math.imul(qn,pi)|0,Me=Me+Math.imul($n,Bi)|0,We=We+Math.imul($n,mi)|0,We=We+Math.imul(Mn,Bi)|0,$t=$t+Math.imul(Mn,mi)|0,Me=Me+Math.imul(Pn,Ii)|0,We=We+Math.imul(Pn,gi)|0,We=We+Math.imul(wn,Ii)|0,$t=$t+Math.imul(wn,gi)|0,Me=Me+Math.imul(un,ki)|0,We=We+Math.imul(un,$i)|0,We=We+Math.imul(Pt,ki)|0,$t=$t+Math.imul(Pt,$i)|0;var Hi=(ce+Me|0)+((We&8191)<<13)|0;ce=($t+(We>>>13)|0)+(Hi>>>26)|0,Hi&=67108863,Me=Math.imul(En,Ci),We=Math.imul(En,ri),We=We+Math.imul(xn,Ci)|0,$t=Math.imul(xn,ri),Me=Me+Math.imul(ti,Ai)|0,We=We+Math.imul(ti,ci)|0,We=We+Math.imul(Fn,Ai)|0,$t=$t+Math.imul(Fn,ci)|0,Me=Me+Math.imul(Ln,Mi)|0,We=We+Math.imul(Ln,di)|0,We=We+Math.imul(On,Mi)|0,$t=$t+Math.imul(On,di)|0,Me=Me+Math.imul(bi,Ti)|0,We=We+Math.imul(bi,hi)|0,We=We+Math.imul(Hn,Ti)|0,$t=$t+Math.imul(Hn,hi)|0,Me=Me+Math.imul(Gn,Pi)|0,We=We+Math.imul(Gn,pi)|0,We=We+Math.imul(Kn,Pi)|0,$t=$t+Math.imul(Kn,pi)|0,Me=Me+Math.imul(Zn,Bi)|0,We=We+Math.imul(Zn,mi)|0,We=We+Math.imul(qn,Bi)|0,$t=$t+Math.imul(qn,mi)|0,Me=Me+Math.imul($n,Ii)|0,We=We+Math.imul($n,gi)|0,We=We+Math.imul(Mn,Ii)|0,$t=$t+Math.imul(Mn,gi)|0,Me=Me+Math.imul(Pn,ki)|0,We=We+Math.imul(Pn,$i)|0,We=We+Math.imul(wn,ki)|0,$t=$t+Math.imul(wn,$i)|0;var Ki=(ce+Me|0)+((We&8191)<<13)|0;ce=($t+(We>>>13)|0)+(Ki>>>26)|0,Ki&=67108863,Me=Math.imul(En,Ai),We=Math.imul(En,ci),We=We+Math.imul(xn,Ai)|0,$t=Math.imul(xn,ci),Me=Me+Math.imul(ti,Mi)|0,We=We+Math.imul(ti,di)|0,We=We+Math.imul(Fn,Mi)|0,$t=$t+Math.imul(Fn,di)|0,Me=Me+Math.imul(Ln,Ti)|0,We=We+Math.imul(Ln,hi)|0,We=We+Math.imul(On,Ti)|0,$t=$t+Math.imul(On,hi)|0,Me=Me+Math.imul(bi,Pi)|0,We=We+Math.imul(bi,pi)|0,We=We+Math.imul(Hn,Pi)|0,$t=$t+Math.imul(Hn,pi)|0,Me=Me+Math.imul(Gn,Bi)|0,We=We+Math.imul(Gn,mi)|0,We=We+Math.imul(Kn,Bi)|0,$t=$t+Math.imul(Kn,mi)|0,Me=Me+Math.imul(Zn,Ii)|0,We=We+Math.imul(Zn,gi)|0,We=We+Math.imul(qn,Ii)|0,$t=$t+Math.imul(qn,gi)|0,Me=Me+Math.imul($n,ki)|0,We=We+Math.imul($n,$i)|0,We=We+Math.imul(Mn,ki)|0,$t=$t+Math.imul(Mn,$i)|0;var Wi=(ce+Me|0)+((We&8191)<<13)|0;ce=($t+(We>>>13)|0)+(Wi>>>26)|0,Wi&=67108863,Me=Math.imul(En,Mi),We=Math.imul(En,di),We=We+Math.imul(xn,Mi)|0,$t=Math.imul(xn,di),Me=Me+Math.imul(ti,Ti)|0,We=We+Math.imul(ti,hi)|0,We=We+Math.imul(Fn,Ti)|0,$t=$t+Math.imul(Fn,hi)|0,Me=Me+Math.imul(Ln,Pi)|0,We=We+Math.imul(Ln,pi)|0,We=We+Math.imul(On,Pi)|0,$t=$t+Math.imul(On,pi)|0,Me=Me+Math.imul(bi,Bi)|0,We=We+Math.imul(bi,mi)|0,We=We+Math.imul(Hn,Bi)|0,$t=$t+Math.imul(Hn,mi)|0,Me=Me+Math.imul(Gn,Ii)|0,We=We+Math.imul(Gn,gi)|0,We=We+Math.imul(Kn,Ii)|0,$t=$t+Math.imul(Kn,gi)|0,Me=Me+Math.imul(Zn,ki)|0,We=We+Math.imul(Zn,$i)|0,We=We+Math.imul(qn,ki)|0,$t=$t+Math.imul(qn,$i)|0;var Gi=(ce+Me|0)+((We&8191)<<13)|0;ce=($t+(We>>>13)|0)+(Gi>>>26)|0,Gi&=67108863,Me=Math.imul(En,Ti),We=Math.imul(En,hi),We=We+Math.imul(xn,Ti)|0,$t=Math.imul(xn,hi),Me=Me+Math.imul(ti,Pi)|0,We=We+Math.imul(ti,pi)|0,We=We+Math.imul(Fn,Pi)|0,$t=$t+Math.imul(Fn,pi)|0,Me=Me+Math.imul(Ln,Bi)|0,We=We+Math.imul(Ln,mi)|0,We=We+Math.imul(On,Bi)|0,$t=$t+Math.imul(On,mi)|0,Me=Me+Math.imul(bi,Ii)|0,We=We+Math.imul(bi,gi)|0,We=We+Math.imul(Hn,Ii)|0,$t=$t+Math.imul(Hn,gi)|0,Me=Me+Math.imul(Gn,ki)|0,We=We+Math.imul(Gn,$i)|0,We=We+Math.imul(Kn,ki)|0,$t=$t+Math.imul(Kn,$i)|0;var Zi=(ce+Me|0)+((We&8191)<<13)|0;ce=($t+(We>>>13)|0)+(Zi>>>26)|0,Zi&=67108863,Me=Math.imul(En,Pi),We=Math.imul(En,pi),We=We+Math.imul(xn,Pi)|0,$t=Math.imul(xn,pi),Me=Me+Math.imul(ti,Bi)|0,We=We+Math.imul(ti,mi)|0,We=We+Math.imul(Fn,Bi)|0,$t=$t+Math.imul(Fn,mi)|0,Me=Me+Math.imul(Ln,Ii)|0,We=We+Math.imul(Ln,gi)|0,We=We+Math.imul(On,Ii)|0,$t=$t+Math.imul(On,gi)|0,Me=Me+Math.imul(bi,ki)|0,We=We+Math.imul(bi,$i)|0,We=We+Math.imul(Hn,ki)|0,$t=$t+Math.imul(Hn,$i)|0;var Xi=(ce+Me|0)+((We&8191)<<13)|0;ce=($t+(We>>>13)|0)+(Xi>>>26)|0,Xi&=67108863,Me=Math.imul(En,Bi),We=Math.imul(En,mi),We=We+Math.imul(xn,Bi)|0,$t=Math.imul(xn,mi),Me=Me+Math.imul(ti,Ii)|0,We=We+Math.imul(ti,gi)|0,We=We+Math.imul(Fn,Ii)|0,$t=$t+Math.imul(Fn,gi)|0,Me=Me+Math.imul(Ln,ki)|0,We=We+Math.imul(Ln,$i)|0,We=We+Math.imul(On,ki)|0,$t=$t+Math.imul(On,$i)|0;var Ji=(ce+Me|0)+((We&8191)<<13)|0;ce=($t+(We>>>13)|0)+(Ji>>>26)|0,Ji&=67108863,Me=Math.imul(En,Ii),We=Math.imul(En,gi),We=We+Math.imul(xn,Ii)|0,$t=Math.imul(xn,gi),Me=Me+Math.imul(ti,ki)|0,We=We+Math.imul(ti,$i)|0,We=We+Math.imul(Fn,ki)|0,$t=$t+Math.imul(Fn,$i)|0;var no=(ce+Me|0)+((We&8191)<<13)|0;ce=($t+(We>>>13)|0)+(no>>>26)|0,no&=67108863,Me=Math.imul(En,ki),We=Math.imul(En,$i),We=We+Math.imul(xn,ki)|0,$t=Math.imul(xn,$i);var io=(ce+Me|0)+((We&8191)<<13)|0;return ce=($t+(We>>>13)|0)+(io>>>26)|0,io&=67108863,$e[0]=Ni,$e[1]=Oi,$e[2]=Li,$e[3]=Fi,$e[4]=ji,$e[5]=Di,$e[6]=Ui,$e[7]=qi,$e[8]=Vi,$e[9]=zi,$e[10]=Hi,$e[11]=Ki,$e[12]=Wi,$e[13]=Gi,$e[14]=Zi,$e[15]=Xi,$e[16]=Ji,$e[17]=no,$e[18]=io,ce!==0&&($e[19]=ce,_e.length++),_e};Math.imul||(Ye=Ze);function Ft(be,xe,_e){_e.negative=xe.negative^be.negative,_e.length=be.length+xe.length;for(var De=0,Fe=0,$e=0;$e<_e.length-1;$e++){var ce=Fe;Fe=0;for(var Me=De&67108863,We=Math.min($e,xe.length-1),$t=Math.max(0,$e-be.length+1);$t<=We;$t++){var dn=$e-$t,gn=be.words[dn]|0,Vt=xe.words[$t]|0,Cn=gn*Vt,un=Cn&67108863;ce=ce+(Cn/67108864|0)|0,un=un+Me|0,Me=un&67108863,ce=ce+(un>>>26)|0,Fe+=ce>>>26,ce&=67108863}_e.words[$e]=Me,De=ce,ce=Fe}return De!==0?_e.words[$e]=De:_e.length--,_e._strip()}function Mt(be,xe,_e){return Ft(be,xe,_e)}ae.prototype.mulTo=function(be,xe){var _e,De=this.length+be.length;return this.length===10&&be.length===10?_e=Ye(this,be,xe):De<63?_e=Ze(this,be,xe):De<1024?_e=Ft(this,be,xe):_e=Mt(this,be,xe),_e},ae.prototype.mul=function(be){var xe=new ae(null);return xe.words=new Array(this.length+be.length),this.mulTo(be,xe)},ae.prototype.mulf=function(be){var xe=new ae(null);return xe.words=new Array(this.length+be.length),Mt(this,be,xe)},ae.prototype.imul=function(be){return this.clone().mulTo(be,this)},ae.prototype.imuln=function(be){var xe=be<0;xe&&(be=-be),ie(typeof be=="number"),ie(be<67108864);for(var _e=0,De=0;De<this.length;De++){var Fe=(this.words[De]|0)*be,$e=(Fe&67108863)+(_e&67108863);_e>>=26,_e+=Fe/67108864|0,_e+=$e>>>26,this.words[De]=$e&67108863}return _e!==0&&(this.words[De]=_e,this.length++),this.length=be===0?1:this.length,xe?this.ineg():this},ae.prototype.muln=function(be){return this.clone().imuln(be)},ae.prototype.sqr=function(){return this.mul(this)},ae.prototype.isqr=function(){return this.imul(this.clone())},ae.prototype.pow=function(be){var xe=Ge(be);if(xe.length===0)return new ae(1);for(var _e=this,De=0;De<xe.length&&xe[De]===0;De++,_e=_e.sqr());if(++De<xe.length)for(var Fe=_e.sqr();De<xe.length;De++,Fe=Fe.sqr())xe[De]!==0&&(_e=_e.mul(Fe));return _e},ae.prototype.iushln=function(be){ie(typeof be=="number"&&be>=0);var xe=be%26,_e=(be-xe)/26,De=67108863>>>26-xe<<26-xe,Fe;if(xe!==0){var $e=0;for(Fe=0;Fe<this.length;Fe++){var ce=this.words[Fe]&De,Me=(this.words[Fe]|0)-ce<<xe;this.words[Fe]=Me|$e,$e=ce>>>26-xe}$e&&(this.words[Fe]=$e,this.length++)}if(_e!==0){for(Fe=this.length-1;Fe>=0;Fe--)this.words[Fe+_e]=this.words[Fe];for(Fe=0;Fe<_e;Fe++)this.words[Fe]=0;this.length+=_e}return this._strip()},ae.prototype.ishln=function(be){return ie(this.negative===0),this.iushln(be)},ae.prototype.iushrn=function(be,xe,_e){ie(typeof be=="number"&&be>=0);var De;xe?De=(xe-xe%26)/26:De=0;var Fe=be%26,$e=Math.min((be-Fe)/26,this.length),ce=67108863^67108863>>>Fe<<Fe,Me=_e;if(De-=$e,De=Math.max(0,De),Me){for(var We=0;We<$e;We++)Me.words[We]=this.words[We];Me.length=$e}if($e!==0)if(this.length>$e)for(this.length-=$e,We=0;We<this.length;We++)this.words[We]=this.words[We+$e];else this.words[0]=0,this.length=1;var $t=0;for(We=this.length-1;We>=0&&($t!==0||We>=De);We--){var dn=this.words[We]|0;this.words[We]=$t<<26-Fe|dn>>>Fe,$t=dn&ce}return Me&&$t!==0&&(Me.words[Me.length++]=$t),this.length===0&&(this.words[0]=0,this.length=1),this._strip()},ae.prototype.ishrn=function(be,xe,_e){return ie(this.negative===0),this.iushrn(be,xe,_e)},ae.prototype.shln=function(be){return this.clone().ishln(be)},ae.prototype.ushln=function(be){return this.clone().iushln(be)},ae.prototype.shrn=function(be){return this.clone().ishrn(be)},ae.prototype.ushrn=function(be){return this.clone().iushrn(be)},ae.prototype.testn=function(be){ie(typeof be=="number"&&be>=0);var xe=be%26,_e=(be-xe)/26,De=1<<xe;if(this.length<=_e)return!1;var Fe=this.words[_e];return!!(Fe&De)},ae.prototype.imaskn=function(be){ie(typeof be=="number"&&be>=0);var xe=be%26,_e=(be-xe)/26;if(ie(this.negative===0,"imaskn works only with positive numbers"),this.length<=_e)return this;if(xe!==0&&_e++,this.length=Math.min(_e,this.length),xe!==0){var De=67108863^67108863>>>xe<<xe;this.words[this.length-1]&=De}return this._strip()},ae.prototype.maskn=function(be){return this.clone().imaskn(be)},ae.prototype.iaddn=function(be){return ie(typeof be=="number"),ie(be<67108864),be<0?this.isubn(-be):this.negative!==0?this.length===1&&(this.words[0]|0)<=be?(this.words[0]=be-(this.words[0]|0),this.negative=0,this):(this.negative=0,this.isubn(be),this.negative=1,this):this._iaddn(be)},ae.prototype._iaddn=function(be){this.words[0]+=be;for(var xe=0;xe<this.length&&this.words[xe]>=67108864;xe++)this.words[xe]-=67108864,xe===this.length-1?this.words[xe+1]=1:this.words[xe+1]++;return this.length=Math.max(this.length,xe+1),this},ae.prototype.isubn=function(be){if(ie(typeof be=="number"),ie(be<67108864),be<0)return this.iaddn(-be);if(this.negative!==0)return this.negative=0,this.iaddn(be),this.negative=1,this;if(this.words[0]-=be,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var xe=0;xe<this.length&&this.words[xe]<0;xe++)this.words[xe]+=67108864,this.words[xe+1]-=1;return this._strip()},ae.prototype.addn=function(be){return this.clone().iaddn(be)},ae.prototype.subn=function(be){return this.clone().isubn(be)},ae.prototype.iabs=function(){return this.negative=0,this},ae.prototype.abs=function(){return this.clone().iabs()},ae.prototype._ishlnsubmul=function(be,xe,_e){var De=be.length+_e,Fe;this._expand(De);var $e,ce=0;for(Fe=0;Fe<be.length;Fe++){$e=(this.words[Fe+_e]|0)+ce;var Me=(be.words[Fe]|0)*xe;$e-=Me&67108863,ce=($e>>26)-(Me/67108864|0),this.words[Fe+_e]=$e&67108863}for(;Fe<this.length-_e;Fe++)$e=(this.words[Fe+_e]|0)+ce,ce=$e>>26,this.words[Fe+_e]=$e&67108863;if(ce===0)return this._strip();for(ie(ce===-1),ce=0,Fe=0;Fe<this.length;Fe++)$e=-(this.words[Fe]|0)+ce,ce=$e>>26,this.words[Fe]=$e&67108863;return this.negative=1,this._strip()},ae.prototype._wordDiv=function(be,xe){var _e=this.length-be.length,De=this.clone(),Fe=be,$e=Fe.words[Fe.length-1]|0,ce=this._countBits($e);_e=26-ce,_e!==0&&(Fe=Fe.ushln(_e),De.iushln(_e),$e=Fe.words[Fe.length-1]|0);var Me=De.length-Fe.length,We;if(xe!=="mod"){We=new ae(null),We.length=Me+1,We.words=new Array(We.length);for(var $t=0;$t<We.length;$t++)We.words[$t]=0}var dn=De.clone()._ishlnsubmul(Fe,1,Me);dn.negative===0&&(De=dn,We&&(We.words[Me]=1));for(var gn=Me-1;gn>=0;gn--){var Vt=(De.words[Fe.length+gn]|0)*67108864+(De.words[Fe.length+gn-1]|0);for(Vt=Math.min(Vt/$e|0,67108863),De._ishlnsubmul(Fe,Vt,gn);De.negative!==0;)Vt--,De.negative=0,De._ishlnsubmul(Fe,1,gn),De.isZero()||(De.negative^=1);We&&(We.words[gn]=Vt)}return We&&We._strip(),De._strip(),xe!=="div"&&_e!==0&&De.iushrn(_e),{div:We||null,mod:De}},ae.prototype.divmod=function(be,xe,_e){if(ie(!be.isZero()),this.isZero())return{div:new ae(0),mod:new ae(0)};var De,Fe,$e;return this.negative!==0&&be.negative===0?($e=this.neg().divmod(be,xe),xe!=="mod"&&(De=$e.div.neg()),xe!=="div"&&(Fe=$e.mod.neg(),_e&&Fe.negative!==0&&Fe.iadd(be)),{div:De,mod:Fe}):this.negative===0&&be.negative!==0?($e=this.divmod(be.neg(),xe),xe!=="mod"&&(De=$e.div.neg()),{div:De,mod:$e.mod}):this.negative&be.negative?($e=this.neg().divmod(be.neg(),xe),xe!=="div"&&(Fe=$e.mod.neg(),_e&&Fe.negative!==0&&Fe.isub(be)),{div:$e.div,mod:Fe}):be.length>this.length||this.cmp(be)<0?{div:new ae(0),mod:this}:be.length===1?xe==="div"?{div:this.divn(be.words[0]),mod:null}:xe==="mod"?{div:null,mod:new ae(this.modrn(be.words[0]))}:{div:this.divn(be.words[0]),mod:new ae(this.modrn(be.words[0]))}:this._wordDiv(be,xe)},ae.prototype.div=function(be){return this.divmod(be,"div",!1).div},ae.prototype.mod=function(be){return this.divmod(be,"mod",!1).mod},ae.prototype.umod=function(be){return this.divmod(be,"mod",!0).mod},ae.prototype.divRound=function(be){var xe=this.divmod(be);if(xe.mod.isZero())return xe.div;var _e=xe.div.negative!==0?xe.mod.isub(be):xe.mod,De=be.ushrn(1),Fe=be.andln(1),$e=_e.cmp(De);return $e<0||Fe===1&&$e===0?xe.div:xe.div.negative!==0?xe.div.isubn(1):xe.div.iaddn(1)},ae.prototype.modrn=function(be){var xe=be<0;xe&&(be=-be),ie(be<=67108863);for(var _e=(1<<26)%be,De=0,Fe=this.length-1;Fe>=0;Fe--)De=(_e*De+(this.words[Fe]|0))%be;return xe?-De:De},ae.prototype.modn=function(be){return this.modrn(be)},ae.prototype.idivn=function(be){var xe=be<0;xe&&(be=-be),ie(be<=67108863);for(var _e=0,De=this.length-1;De>=0;De--){var Fe=(this.words[De]|0)+_e*67108864;this.words[De]=Fe/be|0,_e=Fe%be}return this._strip(),xe?this.ineg():this},ae.prototype.divn=function(be){return this.clone().idivn(be)},ae.prototype.egcd=function(be){ie(be.negative===0),ie(!be.isZero());var xe=this,_e=be.clone();xe.negative!==0?xe=xe.umod(be):xe=xe.clone();for(var De=new ae(1),Fe=new ae(0),$e=new ae(0),ce=new ae(1),Me=0;xe.isEven()&&_e.isEven();)xe.iushrn(1),_e.iushrn(1),++Me;for(var We=_e.clone(),$t=xe.clone();!xe.isZero();){for(var dn=0,gn=1;!(xe.words[0]&gn)&&dn<26;++dn,gn<<=1);if(dn>0)for(xe.iushrn(dn);dn-- >0;)(De.isOdd()||Fe.isOdd())&&(De.iadd(We),Fe.isub($t)),De.iushrn(1),Fe.iushrn(1);for(var Vt=0,Cn=1;!(_e.words[0]&Cn)&&Vt<26;++Vt,Cn<<=1);if(Vt>0)for(_e.iushrn(Vt);Vt-- >0;)($e.isOdd()||ce.isOdd())&&($e.iadd(We),ce.isub($t)),$e.iushrn(1),ce.iushrn(1);xe.cmp(_e)>=0?(xe.isub(_e),De.isub($e),Fe.isub(ce)):(_e.isub(xe),$e.isub(De),ce.isub(Fe))}return{a:$e,b:ce,gcd:_e.iushln(Me)}},ae.prototype._invmp=function(be){ie(be.negative===0),ie(!be.isZero());var xe=this,_e=be.clone();xe.negative!==0?xe=xe.umod(be):xe=xe.clone();for(var De=new ae(1),Fe=new ae(0),$e=_e.clone();xe.cmpn(1)>0&&_e.cmpn(1)>0;){for(var ce=0,Me=1;!(xe.words[0]&Me)&&ce<26;++ce,Me<<=1);if(ce>0)for(xe.iushrn(ce);ce-- >0;)De.isOdd()&&De.iadd($e),De.iushrn(1);for(var We=0,$t=1;!(_e.words[0]&$t)&&We<26;++We,$t<<=1);if(We>0)for(_e.iushrn(We);We-- >0;)Fe.isOdd()&&Fe.iadd($e),Fe.iushrn(1);xe.cmp(_e)>=0?(xe.isub(_e),De.isub(Fe)):(_e.isub(xe),Fe.isub(De))}var dn;return xe.cmpn(1)===0?dn=De:dn=Fe,dn.cmpn(0)<0&&dn.iadd(be),dn},ae.prototype.gcd=function(be){if(this.isZero())return be.abs();if(be.isZero())return this.abs();var xe=this.clone(),_e=be.clone();xe.negative=0,_e.negative=0;for(var De=0;xe.isEven()&&_e.isEven();De++)xe.iushrn(1),_e.iushrn(1);do{for(;xe.isEven();)xe.iushrn(1);for(;_e.isEven();)_e.iushrn(1);var Fe=xe.cmp(_e);if(Fe<0){var $e=xe;xe=_e,_e=$e}else if(Fe===0||_e.cmpn(1)===0)break;xe.isub(_e)}while(!0);return _e.iushln(De)},ae.prototype.invm=function(be){return this.egcd(be).a.umod(be)},ae.prototype.isEven=function(){return(this.words[0]&1)===0},ae.prototype.isOdd=function(){return(this.words[0]&1)===1},ae.prototype.andln=function(be){return this.words[0]&be},ae.prototype.bincn=function(be){ie(typeof be=="number");var xe=be%26,_e=(be-xe)/26,De=1<<xe;if(this.length<=_e)return this._expand(_e+1),this.words[_e]|=De,this;for(var Fe=De,$e=_e;Fe!==0&&$e<this.length;$e++){var ce=this.words[$e]|0;ce+=Fe,Fe=ce>>>26,ce&=67108863,this.words[$e]=ce}return Fe!==0&&(this.words[$e]=Fe,this.length++),this},ae.prototype.isZero=function(){return this.length===1&&this.words[0]===0},ae.prototype.cmpn=function(be){var xe=be<0;if(this.negative!==0&&!xe)return-1;if(this.negative===0&&xe)return 1;this._strip();var _e;if(this.length>1)_e=1;else{xe&&(be=-be),ie(be<=67108863,"Number is too big");var De=this.words[0]|0;_e=De===be?0:De<be?-1:1}return this.negative!==0?-_e|0:_e},ae.prototype.cmp=function(be){if(this.negative!==0&&be.negative===0)return-1;if(this.negative===0&&be.negative!==0)return 1;var xe=this.ucmp(be);return this.negative!==0?-xe|0:xe},ae.prototype.ucmp=function(be){if(this.length>be.length)return 1;if(this.length<be.length)return-1;for(var xe=0,_e=this.length-1;_e>=0;_e--){var De=this.words[_e]|0,Fe=be.words[_e]|0;if(De!==Fe){De<Fe?xe=-1:De>Fe&&(xe=1);break}}return xe},ae.prototype.gtn=function(be){return this.cmpn(be)===1},ae.prototype.gt=function(be){return this.cmp(be)===1},ae.prototype.gten=function(be){return this.cmpn(be)>=0},ae.prototype.gte=function(be){return this.cmp(be)>=0},ae.prototype.ltn=function(be){return this.cmpn(be)===-1},ae.prototype.lt=function(be){return this.cmp(be)===-1},ae.prototype.lten=function(be){return this.cmpn(be)<=0},ae.prototype.lte=function(be){return this.cmp(be)<=0},ae.prototype.eqn=function(be){return this.cmpn(be)===0},ae.prototype.eq=function(be){return this.cmp(be)===0},ae.red=function(be){return new le(be)},ae.prototype.toRed=function(be){return ie(!this.red,"Already a number in reduction context"),ie(this.negative===0,"red works only with positives"),be.convertTo(this)._forceRed(be)},ae.prototype.fromRed=function(){return ie(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},ae.prototype._forceRed=function(be){return this.red=be,this},ae.prototype.forceRed=function(be){return ie(!this.red,"Already a number in reduction context"),this._forceRed(be)},ae.prototype.redAdd=function(be){return ie(this.red,"redAdd works only with red numbers"),this.red.add(this,be)},ae.prototype.redIAdd=function(be){return ie(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,be)},ae.prototype.redSub=function(be){return ie(this.red,"redSub works only with red numbers"),this.red.sub(this,be)},ae.prototype.redISub=function(be){return ie(this.red,"redISub works only with red numbers"),this.red.isub(this,be)},ae.prototype.redShl=function(be){return ie(this.red,"redShl works only with red numbers"),this.red.shl(this,be)},ae.prototype.redMul=function(be){return ie(this.red,"redMul works only with red numbers"),this.red._verify2(this,be),this.red.mul(this,be)},ae.prototype.redIMul=function(be){return ie(this.red,"redMul works only with red numbers"),this.red._verify2(this,be),this.red.imul(this,be)},ae.prototype.redSqr=function(){return ie(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},ae.prototype.redISqr=function(){return ie(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},ae.prototype.redSqrt=function(){return ie(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},ae.prototype.redInvm=function(){return ie(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},ae.prototype.redNeg=function(){return ie(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},ae.prototype.redPow=function(be){return ie(this.red&&!be.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,be)};var Zt={k256:null,p224:null,p192:null,p25519:null};function cn(be,xe){this.name=be,this.p=new ae(xe,16),this.n=this.p.bitLength(),this.k=new ae(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}cn.prototype._tmp=function(){var be=new ae(null);return be.words=new Array(Math.ceil(this.n/13)),be},cn.prototype.ireduce=function(be){var xe=be,_e;do this.split(xe,this.tmp),xe=this.imulK(xe),xe=xe.iadd(this.tmp),_e=xe.bitLength();while(_e>this.n);var De=_e<this.n?-1:xe.ucmp(this.p);return De===0?(xe.words[0]=0,xe.length=1):De>0?xe.isub(this.p):xe.strip!==void 0?xe.strip():xe._strip(),xe},cn.prototype.split=function(be,xe){be.iushrn(this.n,0,xe)},cn.prototype.imulK=function(be){return be.imul(this.k)};function hn(){cn.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}se(hn,cn),hn.prototype.split=function(be,xe){for(var _e=4194303,De=Math.min(be.length,9),Fe=0;Fe<De;Fe++)xe.words[Fe]=be.words[Fe];if(xe.length=De,be.length<=9){be.words[0]=0,be.length=1;return}var $e=be.words[9];for(xe.words[xe.length++]=$e&_e,Fe=10;Fe<be.length;Fe++){var ce=be.words[Fe]|0;be.words[Fe-10]=(ce&_e)<<4|$e>>>22,$e=ce}$e>>>=22,be.words[Fe-10]=$e,$e===0&&be.length>10?be.length-=10:be.length-=9},hn.prototype.imulK=function(be){be.words[be.length]=0,be.words[be.length+1]=0,be.length+=2;for(var xe=0,_e=0;_e<be.length;_e++){var De=be.words[_e]|0;xe+=De*977,be.words[_e]=xe&67108863,xe=De*64+(xe/67108864|0)}return be.words[be.length-1]===0&&(be.length--,be.words[be.length-1]===0&&be.length--),be};function yn(){cn.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}se(yn,cn);function Ht(){cn.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}se(Ht,cn);function Sn(){cn.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}se(Sn,cn),Sn.prototype.imulK=function(be){for(var xe=0,_e=0;_e<be.length;_e++){var De=(be.words[_e]|0)*19+xe,Fe=De&67108863;De>>>=26,be.words[_e]=Fe,xe=De}return xe!==0&&(be.words[be.length++]=xe),be},ae._prime=function(be){if(Zt[be])return Zt[be];var xe;if(be==="k256")xe=new hn;else if(be==="p224")xe=new yn;else if(be==="p192")xe=new Ht;else if(be==="p25519")xe=new Sn;else throw new Error("Unknown prime "+be);return Zt[be]=xe,xe};function le(be){if(typeof be=="string"){var xe=ae._prime(be);this.m=xe.p,this.prime=xe}else ie(be.gtn(1),"modulus must be greater than 1"),this.m=be,this.prime=null}le.prototype._verify1=function(be){ie(be.negative===0,"red works only with positives"),ie(be.red,"red works only with red numbers")},le.prototype._verify2=function(be,xe){ie((be.negative|xe.negative)===0,"red works only with positives"),ie(be.red&&be.red===xe.red,"red works only with red numbers")},le.prototype.imod=function(be){return this.prime?this.prime.ireduce(be)._forceRed(this):(we(be,be.umod(this.m)._forceRed(this)),be)},le.prototype.neg=function(be){return be.isZero()?be.clone():this.m.sub(be)._forceRed(this)},le.prototype.add=function(be,xe){this._verify2(be,xe);var _e=be.add(xe);return _e.cmp(this.m)>=0&&_e.isub(this.m),_e._forceRed(this)},le.prototype.iadd=function(be,xe){this._verify2(be,xe);var _e=be.iadd(xe);return _e.cmp(this.m)>=0&&_e.isub(this.m),_e},le.prototype.sub=function(be,xe){this._verify2(be,xe);var _e=be.sub(xe);return _e.cmpn(0)<0&&_e.iadd(this.m),_e._forceRed(this)},le.prototype.isub=function(be,xe){this._verify2(be,xe);var _e=be.isub(xe);return _e.cmpn(0)<0&&_e.iadd(this.m),_e},le.prototype.shl=function(be,xe){return this._verify1(be),this.imod(be.ushln(xe))},le.prototype.imul=function(be,xe){return this._verify2(be,xe),this.imod(be.imul(xe))},le.prototype.mul=function(be,xe){return this._verify2(be,xe),this.imod(be.mul(xe))},le.prototype.isqr=function(be){return this.imul(be,be.clone())},le.prototype.sqr=function(be){return this.mul(be,be)},le.prototype.sqrt=function(be){if(be.isZero())return be.clone();var xe=this.m.andln(3);if(ie(xe%2===1),xe===3){var _e=this.m.add(new ae(1)).iushrn(2);return this.pow(be,_e)}for(var De=this.m.subn(1),Fe=0;!De.isZero()&&De.andln(1)===0;)Fe++,De.iushrn(1);ie(!De.isZero());var $e=new ae(1).toRed(this),ce=$e.redNeg(),Me=this.m.subn(1).iushrn(1),We=this.m.bitLength();for(We=new ae(2*We*We).toRed(this);this.pow(We,Me).cmp(ce)!==0;)We.redIAdd(ce);for(var $t=this.pow(We,De),dn=this.pow(be,De.addn(1).iushrn(1)),gn=this.pow(be,De),Vt=Fe;gn.cmp($e)!==0;){for(var Cn=gn,un=0;Cn.cmp($e)!==0;un++)Cn=Cn.redSqr();ie(un<Vt);var Pt=this.pow($t,new ae(1).iushln(Vt-un-1));dn=dn.redMul(Pt),$t=Pt.redSqr(),gn=gn.redMul($t),Vt=un}return dn},le.prototype.invm=function(be){var xe=be._invmp(this.m);return xe.negative!==0?(xe.negative=0,this.imod(xe).redNeg()):this.imod(xe)},le.prototype.pow=function(be,xe){if(xe.isZero())return new ae(1).toRed(this);if(xe.cmpn(1)===0)return be.clone();var _e=4,De=new Array(1<<_e);De[0]=new ae(1).toRed(this),De[1]=be;for(var Fe=2;Fe<De.length;Fe++)De[Fe]=this.mul(De[Fe-1],be);var $e=De[0],ce=0,Me=0,We=xe.bitLength()%26;for(We===0&&(We=26),Fe=xe.length-1;Fe>=0;Fe--){for(var $t=xe.words[Fe],dn=We-1;dn>=0;dn--){var gn=$t>>dn&1;if($e!==De[0]&&($e=this.sqr($e)),gn===0&&ce===0){Me=0;continue}ce<<=1,ce|=gn,Me++,!(Me!==_e&&(Fe!==0||dn!==0))&&($e=this.mul($e,De[ce]),Me=0,ce=0)}We=26}return $e},le.prototype.convertTo=function(be){var xe=be.umod(this.m);return xe===be?xe.clone():xe},le.prototype.convertFrom=function(be){var xe=be.clone();return xe.red=null,xe},ae.mont=function(be){return new pe(be)};function pe(be){le.call(this,be),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new ae(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}se(pe,le),pe.prototype.convertTo=function(be){return this.imod(be.ushln(this.shift))},pe.prototype.convertFrom=function(be){var xe=this.imod(be.mul(this.rinv));return xe.red=null,xe},pe.prototype.imul=function(be,xe){if(be.isZero()||xe.isZero())return be.words[0]=0,be.length=1,be;var _e=be.imul(xe),De=_e.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),Fe=_e.isub(De).iushrn(this.shift),$e=Fe;return Fe.cmp(this.m)>=0?$e=Fe.isub(this.m):Fe.cmpn(0)<0&&($e=Fe.iadd(this.m)),$e._forceRed(this)},pe.prototype.mul=function(be,xe){if(be.isZero()||xe.isZero())return new ae(0)._forceRed(this);var _e=be.mul(xe),De=_e.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),Fe=_e.isub(De).iushrn(this.shift),$e=Fe;return Fe.cmp(this.m)>=0?$e=Fe.isub(this.m):Fe.cmpn(0)<0&&($e=Fe.iadd(this.m)),$e._forceRed(this)},pe.prototype.invm=function(be){var xe=this.imod(be._invmp(this.m).mul(this.r2));return xe._forceRed(this)}})(n,commonjsGlobal)})(bn$8);var bnExports$3=bn$8.exports;const BN$8=getDefaultExportFromCjs$2(bnExports$3),version$u="logger/5.8.0";let _permanentCensorErrors=!1,_censorErrors=!1;const LogLevels={debug:1,default:2,info:2,warning:3,error:4,off:5};let _logLevel=LogLevels.default,_globalLogger=null;function _checkNormalize(){try{const n=[];if(["NFD","NFC","NFKD","NFKC"].forEach(t=>{try{if("test".normalize(t)!=="test")throw new Error("bad normalize")}catch{n.push(t)}}),n.length)throw new Error("missing "+n.join(", "));if("é".normalize("NFD")!=="é")throw new Error("broken implementation")}catch(n){return n.message}return null}const _normalizeError=_checkNormalize();var LogLevel;(function(n){n.DEBUG="DEBUG",n.INFO="INFO",n.WARNING="WARNING",n.ERROR="ERROR",n.OFF="OFF"})(LogLevel||(LogLevel={}));var ErrorCode;(function(n){n.UNKNOWN_ERROR="UNKNOWN_ERROR",n.NOT_IMPLEMENTED="NOT_IMPLEMENTED",n.UNSUPPORTED_OPERATION="UNSUPPORTED_OPERATION",n.NETWORK_ERROR="NETWORK_ERROR",n.SERVER_ERROR="SERVER_ERROR",n.TIMEOUT="TIMEOUT",n.BUFFER_OVERRUN="BUFFER_OVERRUN",n.NUMERIC_FAULT="NUMERIC_FAULT",n.MISSING_NEW="MISSING_NEW",n.INVALID_ARGUMENT="INVALID_ARGUMENT",n.MISSING_ARGUMENT="MISSING_ARGUMENT",n.UNEXPECTED_ARGUMENT="UNEXPECTED_ARGUMENT",n.CALL_EXCEPTION="CALL_EXCEPTION",n.INSUFFICIENT_FUNDS="INSUFFICIENT_FUNDS",n.NONCE_EXPIRED="NONCE_EXPIRED",n.REPLACEMENT_UNDERPRICED="REPLACEMENT_UNDERPRICED",n.UNPREDICTABLE_GAS_LIMIT="UNPREDICTABLE_GAS_LIMIT",n.TRANSACTION_REPLACED="TRANSACTION_REPLACED",n.ACTION_REJECTED="ACTION_REJECTED"})(ErrorCode||(ErrorCode={}));const HEX="0123456789abcdef";class Logger{constructor(t){Object.defineProperty(this,"version",{enumerable:!0,value:t,writable:!1})}_log(t,c){const ie=t.toLowerCase();LogLevels[ie]==null&&this.throwArgumentError("invalid log level name","logLevel",t),!(_logLevel>LogLevels[ie])&&console.log.apply(console,c)}debug(...t){this._log(Logger.levels.DEBUG,t)}info(...t){this._log(Logger.levels.INFO,t)}warn(...t){this._log(Logger.levels.WARNING,t)}makeError(t,c,ie){if(_censorErrors)return this.makeError("censored error",c,{});c||(c=Logger.errors.UNKNOWN_ERROR),ie||(ie={});const se=[];Object.keys(ie).forEach(ve=>{const ge=ie[ve];try{if(ge instanceof Uint8Array){let we="";for(let Te=0;Te<ge.length;Te++)we+=HEX[ge[Te]>>4],we+=HEX[ge[Te]&15];se.push(ve+"=Uint8Array(0x"+we+")")}else se.push(ve+"="+JSON.stringify(ge))}catch{se.push(ve+"="+JSON.stringify(ie[ve].toString()))}}),se.push(`code=${c}`),se.push(`version=${this.version}`);const ae=t;let ue="";switch(c){case ErrorCode.NUMERIC_FAULT:{ue="NUMERIC_FAULT";const ve=t;switch(ve){case"overflow":case"underflow":case"division-by-zero":ue+="-"+ve;break;case"negative-power":case"negative-width":ue+="-unsupported";break;case"unbound-bitwise-result":ue+="-unbound-result";break}break}case ErrorCode.CALL_EXCEPTION:case ErrorCode.INSUFFICIENT_FUNDS:case ErrorCode.MISSING_NEW:case ErrorCode.NONCE_EXPIRED:case ErrorCode.REPLACEMENT_UNDERPRICED:case ErrorCode.TRANSACTION_REPLACED:case ErrorCode.UNPREDICTABLE_GAS_LIMIT:ue=c;break}ue&&(t+=" [ See: https://links.ethers.org/v5-errors-"+ue+" ]"),se.length&&(t+=" ("+se.join(", ")+")");const de=new Error(t);return de.reason=ae,de.code=c,Object.keys(ie).forEach(function(ve){de[ve]=ie[ve]}),de}throwError(t,c,ie){throw this.makeError(t,c,ie)}throwArgumentError(t,c,ie){return this.throwError(t,Logger.errors.INVALID_ARGUMENT,{argument:c,value:ie})}assert(t,c,ie,se){t||this.throwError(c,ie,se)}assertArgument(t,c,ie,se){t||this.throwArgumentError(c,ie,se)}checkNormalize(t){_normalizeError&&this.throwError("platform missing String.prototype.normalize",Logger.errors.UNSUPPORTED_OPERATION,{operation:"String.prototype.normalize",form:_normalizeError})}checkSafeUint53(t,c){typeof t=="number"&&(c==null&&(c="value not safe"),(t<0||t>=9007199254740991)&&this.throwError(c,Logger.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"out-of-safe-range",value:t}),t%1&&this.throwError(c,Logger.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"non-integer",value:t}))}checkArgumentCount(t,c,ie){ie?ie=": "+ie:ie="",t<c&&this.throwError("missing argument"+ie,Logger.errors.MISSING_ARGUMENT,{count:t,expectedCount:c}),t>c&&this.throwError("too many arguments"+ie,Logger.errors.UNEXPECTED_ARGUMENT,{count:t,expectedCount:c})}checkNew(t,c){(t===Object||t==null)&&this.throwError("missing new",Logger.errors.MISSING_NEW,{name:c.name})}checkAbstract(t,c){t===c?this.throwError("cannot instantiate abstract class "+JSON.stringify(c.name)+" directly; use a sub-class",Logger.errors.UNSUPPORTED_OPERATION,{name:t.name,operation:"new"}):(t===Object||t==null)&&this.throwError("missing new",Logger.errors.MISSING_NEW,{name:c.name})}static globalLogger(){return _globalLogger||(_globalLogger=new Logger(version$u)),_globalLogger}static setCensorship(t,c){if(!t&&c&&this.globalLogger().throwError("cannot permanently disable censorship",Logger.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"}),_permanentCensorErrors){if(!t)return;this.globalLogger().throwError("error censorship permanent",Logger.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"})}_censorErrors=!!t,_permanentCensorErrors=!!c}static setLogLevel(t){const c=LogLevels[t.toLowerCase()];if(c==null){Logger.globalLogger().warn("invalid log level - "+t);return}_logLevel=c}static from(t){return new Logger(t)}}Logger.errors=ErrorCode;Logger.levels=LogLevel;const lib_esm$k=Object.freeze(Object.defineProperty({__proto__:null,get ErrorCode(){return ErrorCode},get LogLevel(){return LogLevel},Logger},Symbol.toStringTag,{value:"Module"})),version$t="bytes/5.8.0",logger$x=new Logger(version$t);function isHexable(n){return!!n.toHexString}function addSlice(n){return n.slice||(n.slice=function(){const t=Array.prototype.slice.call(arguments);return addSlice(new Uint8Array(Array.prototype.slice.apply(n,t)))}),n}function isBytesLike(n){return isHexString(n)&&!(n.length%2)||isBytes$1(n)}function isInteger(n){return typeof n=="number"&&n==n&&n%1===0}function isBytes$1(n){if(n==null)return!1;if(n.constructor===Uint8Array)return!0;if(typeof n=="string"||!isInteger(n.length)||n.length<0)return!1;for(let t=0;t<n.length;t++){const c=n[t];if(!isInteger(c)||c<0||c>=256)return!1}return!0}function arrayify(n,t){if(t||(t={}),typeof n=="number"){logger$x.checkSafeUint53(n,"invalid arrayify value");const c=[];for(;n;)c.unshift(n&255),n=parseInt(String(n/256));return c.length===0&&c.push(0),addSlice(new Uint8Array(c))}if(t.allowMissingPrefix&&typeof n=="string"&&n.substring(0,2)!=="0x"&&(n="0x"+n),isHexable(n)&&(n=n.toHexString()),isHexString(n)){let c=n.substring(2);c.length%2&&(t.hexPad==="left"?c="0"+c:t.hexPad==="right"?c+="0":logger$x.throwArgumentError("hex data is odd-length","value",n));const ie=[];for(let se=0;se<c.length;se+=2)ie.push(parseInt(c.substring(se,se+2),16));return addSlice(new Uint8Array(ie))}return isBytes$1(n)?addSlice(new Uint8Array(n)):logger$x.throwArgumentError("invalid arrayify value","value",n)}function concat$1(n){const t=n.map(se=>arrayify(se)),c=t.reduce((se,ae)=>se+ae.length,0),ie=new Uint8Array(c);return t.reduce((se,ae)=>(ie.set(ae,se),se+ae.length),0),addSlice(ie)}function stripZeros(n){let t=arrayify(n);if(t.length===0)return t;let c=0;for(;c<t.length&&t[c]===0;)c++;return c&&(t=t.slice(c)),t}function zeroPad(n,t){n=arrayify(n),n.length>t&&logger$x.throwArgumentError("value out of range","value",arguments[0]);const c=new Uint8Array(t);return c.set(n,t-n.length),addSlice(c)}function isHexString(n,t){return!(typeof n!="string"||!n.match(/^0x[0-9A-Fa-f]*$/)||t&&n.length!==2+2*t)}const HexCharacters="0123456789abcdef";function hexlify(n,t){if(t||(t={}),typeof n=="number"){logger$x.checkSafeUint53(n,"invalid hexlify value");let c="";for(;n;)c=HexCharacters[n&15]+c,n=Math.floor(n/16);return c.length?(c.length%2&&(c="0"+c),"0x"+c):"0x00"}if(typeof n=="bigint")return n=n.toString(16),n.length%2?"0x0"+n:"0x"+n;if(t.allowMissingPrefix&&typeof n=="string"&&n.substring(0,2)!=="0x"&&(n="0x"+n),isHexable(n))return n.toHexString();if(isHexString(n))return n.length%2&&(t.hexPad==="left"?n="0x0"+n.substring(2):t.hexPad==="right"?n+="0":logger$x.throwArgumentError("hex data is odd-length","value",n)),n.toLowerCase();if(isBytes$1(n)){let c="0x";for(let ie=0;ie<n.length;ie++){let se=n[ie];c+=HexCharacters[(se&240)>>4]+HexCharacters[se&15]}return c}return logger$x.throwArgumentError("invalid hexlify value","value",n)}function hexDataLength(n){if(typeof n!="string")n=hexlify(n);else if(!isHexString(n)||n.length%2)return null;return(n.length-2)/2}function hexDataSlice(n,t,c){return typeof n!="string"?n=hexlify(n):(!isHexString(n)||n.length%2)&&logger$x.throwArgumentError("invalid hexData","value",n),t=2+2*t,c!=null?"0x"+n.substring(t,2+2*c):"0x"+n.substring(t)}function hexConcat(n){let t="0x";return n.forEach(c=>{t+=hexlify(c).substring(2)}),t}function hexValue(n){const t=hexStripZeros(hexlify(n,{hexPad:"left"}));return t==="0x"?"0x0":t}function hexStripZeros(n){typeof n!="string"&&(n=hexlify(n)),isHexString(n)||logger$x.throwArgumentError("invalid hex string","value",n),n=n.substring(2);let t=0;for(;t<n.length&&n[t]==="0";)t++;return"0x"+n.substring(t)}function hexZeroPad(n,t){for(typeof n!="string"?n=hexlify(n):isHexString(n)||logger$x.throwArgumentError("invalid hex string","value",n),n.length>2*t+2&&logger$x.throwArgumentError("value out of range","value",arguments[1]);n.length<2*t+2;)n="0x0"+n.substring(2);return n}function splitSignature(n){const t={r:"0x",s:"0x",_vs:"0x",recoveryParam:0,v:0,yParityAndS:"0x",compact:"0x"};if(isBytesLike(n)){let c=arrayify(n);c.length===64?(t.v=27+(c[32]>>7),c[32]&=127,t.r=hexlify(c.slice(0,32)),t.s=hexlify(c.slice(32,64))):c.length===65?(t.r=hexlify(c.slice(0,32)),t.s=hexlify(c.slice(32,64)),t.v=c[64]):logger$x.throwArgumentError("invalid signature string","signature",n),t.v<27&&(t.v===0||t.v===1?t.v+=27:logger$x.throwArgumentError("signature invalid v byte","signature",n)),t.recoveryParam=1-t.v%2,t.recoveryParam&&(c[32]|=128),t._vs=hexlify(c.slice(32,64))}else{if(t.r=n.r,t.s=n.s,t.v=n.v,t.recoveryParam=n.recoveryParam,t._vs=n._vs,t._vs!=null){const se=zeroPad(arrayify(t._vs),32);t._vs=hexlify(se);const ae=se[0]>=128?1:0;t.recoveryParam==null?t.recoveryParam=ae:t.recoveryParam!==ae&&logger$x.throwArgumentError("signature recoveryParam mismatch _vs","signature",n),se[0]&=127;const ue=hexlify(se);t.s==null?t.s=ue:t.s!==ue&&logger$x.throwArgumentError("signature v mismatch _vs","signature",n)}if(t.recoveryParam==null)t.v==null?logger$x.throwArgumentError("signature missing v and recoveryParam","signature",n):t.v===0||t.v===1?t.recoveryParam=t.v:t.recoveryParam=1-t.v%2;else if(t.v==null)t.v=27+t.recoveryParam;else{const se=t.v===0||t.v===1?t.v:1-t.v%2;t.recoveryParam!==se&&logger$x.throwArgumentError("signature recoveryParam mismatch v","signature",n)}t.r==null||!isHexString(t.r)?logger$x.throwArgumentError("signature missing or invalid r","signature",n):t.r=hexZeroPad(t.r,32),t.s==null||!isHexString(t.s)?logger$x.throwArgumentError("signature missing or invalid s","signature",n):t.s=hexZeroPad(t.s,32);const c=arrayify(t.s);c[0]>=128&&logger$x.throwArgumentError("signature s out of range","signature",n),t.recoveryParam&&(c[0]|=128);const ie=hexlify(c);t._vs&&(isHexString(t._vs)||logger$x.throwArgumentError("signature invalid _vs","signature",n),t._vs=hexZeroPad(t._vs,32)),t._vs==null?t._vs=ie:t._vs!==ie&&logger$x.throwArgumentError("signature _vs mismatch v and s","signature",n)}return t.yParityAndS=t._vs,t.compact=t.r+t.yParityAndS.substring(2),t}function joinSignature(n){return n=splitSignature(n),hexlify(concat$1([n.r,n.s,n.recoveryParam?"0x1c":"0x1b"]))}const lib_esm$j=Object.freeze(Object.defineProperty({__proto__:null,arrayify,concat:concat$1,hexConcat,hexDataLength,hexDataSlice,hexStripZeros,hexValue,hexZeroPad,hexlify,isBytes:isBytes$1,isBytesLike,isHexString,joinSignature,splitSignature,stripZeros,zeroPad},Symbol.toStringTag,{value:"Module"})),version$s="bignumber/5.8.0";var BN$7=BN$8.BN;const logger$w=new Logger(version$s),_constructorGuard$4={},MAX_SAFE=9007199254740991;function isBigNumberish(n){return n!=null&&(BigNumber.isBigNumber(n)||typeof n=="number"&&n%1===0||typeof n=="string"&&!!n.match(/^-?[0-9]+$/)||isHexString(n)||typeof n=="bigint"||isBytes$1(n))}let _warnedToStringRadix=!1;class BigNumber{constructor(t,c){t!==_constructorGuard$4&&logger$w.throwError("cannot call constructor directly; use BigNumber.from",Logger.errors.UNSUPPORTED_OPERATION,{operation:"new (BigNumber)"}),this._hex=c,this._isBigNumber=!0,Object.freeze(this)}fromTwos(t){return toBigNumber(toBN(this).fromTwos(t))}toTwos(t){return toBigNumber(toBN(this).toTwos(t))}abs(){return this._hex[0]==="-"?BigNumber.from(this._hex.substring(1)):this}add(t){return toBigNumber(toBN(this).add(toBN(t)))}sub(t){return toBigNumber(toBN(this).sub(toBN(t)))}div(t){return BigNumber.from(t).isZero()&&throwFault$1("division-by-zero","div"),toBigNumber(toBN(this).div(toBN(t)))}mul(t){return toBigNumber(toBN(this).mul(toBN(t)))}mod(t){const c=toBN(t);return c.isNeg()&&throwFault$1("division-by-zero","mod"),toBigNumber(toBN(this).umod(c))}pow(t){const c=toBN(t);return c.isNeg()&&throwFault$1("negative-power","pow"),toBigNumber(toBN(this).pow(c))}and(t){const c=toBN(t);return(this.isNegative()||c.isNeg())&&throwFault$1("unbound-bitwise-result","and"),toBigNumber(toBN(this).and(c))}or(t){const c=toBN(t);return(this.isNegative()||c.isNeg())&&throwFault$1("unbound-bitwise-result","or"),toBigNumber(toBN(this).or(c))}xor(t){const c=toBN(t);return(this.isNegative()||c.isNeg())&&throwFault$1("unbound-bitwise-result","xor"),toBigNumber(toBN(this).xor(c))}mask(t){return(this.isNegative()||t<0)&&throwFault$1("negative-width","mask"),toBigNumber(toBN(this).maskn(t))}shl(t){return(this.isNegative()||t<0)&&throwFault$1("negative-width","shl"),toBigNumber(toBN(this).shln(t))}shr(t){return(this.isNegative()||t<0)&&throwFault$1("negative-width","shr"),toBigNumber(toBN(this).shrn(t))}eq(t){return toBN(this).eq(toBN(t))}lt(t){return toBN(this).lt(toBN(t))}lte(t){return toBN(this).lte(toBN(t))}gt(t){return toBN(this).gt(toBN(t))}gte(t){return toBN(this).gte(toBN(t))}isNegative(){return this._hex[0]==="-"}isZero(){return toBN(this).isZero()}toNumber(){try{return toBN(this).toNumber()}catch{throwFault$1("overflow","toNumber",this.toString())}return null}toBigInt(){try{return BigInt(this.toString())}catch{}return logger$w.throwError("this platform does not support BigInt",Logger.errors.UNSUPPORTED_OPERATION,{value:this.toString()})}toString(){return arguments.length>0&&(arguments[0]===10?_warnedToStringRadix||(_warnedToStringRadix=!0,logger$w.warn("BigNumber.toString does not accept any parameters; base-10 is assumed")):arguments[0]===16?logger$w.throwError("BigNumber.toString does not accept any parameters; use bigNumber.toHexString()",Logger.errors.UNEXPECTED_ARGUMENT,{}):logger$w.throwError("BigNumber.toString does not accept parameters",Logger.errors.UNEXPECTED_ARGUMENT,{})),toBN(this).toString(10)}toHexString(){return this._hex}toJSON(t){return{type:"BigNumber",hex:this.toHexString()}}static from(t){if(t instanceof BigNumber)return t;if(typeof t=="string")return t.match(/^-?0x[0-9a-f]+$/i)?new BigNumber(_constructorGuard$4,toHex$2(t)):t.match(/^-?[0-9]+$/)?new BigNumber(_constructorGuard$4,toHex$2(new BN$7(t))):logger$w.throwArgumentError("invalid BigNumber string","value",t);if(typeof t=="number")return t%1&&throwFault$1("underflow","BigNumber.from",t),(t>=MAX_SAFE||t<=-MAX_SAFE)&&throwFault$1("overflow","BigNumber.from",t),BigNumber.from(String(t));const c=t;if(typeof c=="bigint")return BigNumber.from(c.toString());if(isBytes$1(c))return BigNumber.from(hexlify(c));if(c)if(c.toHexString){const ie=c.toHexString();if(typeof ie=="string")return BigNumber.from(ie)}else{let ie=c._hex;if(ie==null&&c.type==="BigNumber"&&(ie=c.hex),typeof ie=="string"&&(isHexString(ie)||ie[0]==="-"&&isHexString(ie.substring(1))))return BigNumber.from(ie)}return logger$w.throwArgumentError("invalid BigNumber value","value",t)}static isBigNumber(t){return!!(t&&t._isBigNumber)}}function toHex$2(n){if(typeof n!="string")return toHex$2(n.toString(16));if(n[0]==="-")return n=n.substring(1),n[0]==="-"&&logger$w.throwArgumentError("invalid hex","value",n),n=toHex$2(n),n==="0x00"?n:"-"+n;if(n.substring(0,2)!=="0x"&&(n="0x"+n),n==="0x")return"0x00";for(n.length%2&&(n="0x0"+n.substring(2));n.length>4&&n.substring(0,4)==="0x00";)n="0x"+n.substring(4);return n}function toBigNumber(n){return BigNumber.from(toHex$2(n))}function toBN(n){const t=BigNumber.from(n).toHexString();return t[0]==="-"?new BN$7("-"+t.substring(3),16):new BN$7(t.substring(2),16)}function throwFault$1(n,t,c){const ie={fault:n,operation:t};return c!=null&&(ie.value=c),logger$w.throwError(n,Logger.errors.NUMERIC_FAULT,ie)}function _base36To16(n){return new BN$7(n,36).toString(16)}function _base16To36(n){return new BN$7(n,16).toString(36)}const logger$v=new Logger(version$s),_constructorGuard$3={},Zero$2=BigNumber.from(0),NegativeOne$2=BigNumber.from(-1);function throwFault(n,t,c,ie){const se={fault:t,operation:c};return ie!==void 0&&(se.value=ie),logger$v.throwError(n,Logger.errors.NUMERIC_FAULT,se)}let zeros="0";for(;zeros.length<256;)zeros+=zeros;function getMultiplier(n){if(typeof n!="number")try{n=BigNumber.from(n).toNumber()}catch{}return typeof n=="number"&&n>=0&&n<=256&&!(n%1)?"1"+zeros.substring(0,n):logger$v.throwArgumentError("invalid decimal size","decimals",n)}function formatFixed(n,t){t==null&&(t=0);const c=getMultiplier(t);n=BigNumber.from(n);const ie=n.lt(Zero$2);ie&&(n=n.mul(NegativeOne$2));let se=n.mod(c).toString();for(;se.length<c.length-1;)se="0"+se;se=se.match(/^([0-9]*[1-9]|0)(0*)/)[1];const ae=n.div(c).toString();return c.length===1?n=ae:n=ae+"."+se,ie&&(n="-"+n),n}function parseFixed(n,t){t==null&&(t=0);const c=getMultiplier(t);(typeof n!="string"||!n.match(/^-?[0-9.]+$/))&&logger$v.throwArgumentError("invalid decimal value","value",n);const ie=n.substring(0,1)==="-";ie&&(n=n.substring(1)),n==="."&&logger$v.throwArgumentError("missing value","value",n);const se=n.split(".");se.length>2&&logger$v.throwArgumentError("too many decimal points","value",n);let ae=se[0],ue=se[1];for(ae||(ae="0"),ue||(ue="0");ue[ue.length-1]==="0";)ue=ue.substring(0,ue.length-1);for(ue.length>c.length-1&&throwFault("fractional component exceeds decimals","underflow","parseFixed"),ue===""&&(ue="0");ue.length<c.length-1;)ue+="0";const de=BigNumber.from(ae),ve=BigNumber.from(ue);let ge=de.mul(c).add(ve);return ie&&(ge=ge.mul(NegativeOne$2)),ge}class FixedFormat{constructor(t,c,ie,se){t!==_constructorGuard$3&&logger$v.throwError("cannot use FixedFormat constructor; use FixedFormat.from",Logger.errors.UNSUPPORTED_OPERATION,{operation:"new FixedFormat"}),this.signed=c,this.width=ie,this.decimals=se,this.name=(c?"":"u")+"fixed"+String(ie)+"x"+String(se),this._multiplier=getMultiplier(se),Object.freeze(this)}static from(t){if(t instanceof FixedFormat)return t;typeof t=="number"&&(t=`fixed128x${t}`);let c=!0,ie=128,se=18;if(typeof t=="string"){if(t!=="fixed")if(t==="ufixed")c=!1;else{const ae=t.match(/^(u?)fixed([0-9]+)x([0-9]+)$/);ae||logger$v.throwArgumentError("invalid fixed format","format",t),c=ae[1]!=="u",ie=parseInt(ae[2]),se=parseInt(ae[3])}}else if(t){const ae=(ue,de,ve)=>t[ue]==null?ve:(typeof t[ue]!==de&&logger$v.throwArgumentError("invalid fixed format ("+ue+" not "+de+")","format."+ue,t[ue]),t[ue]);c=ae("signed","boolean",c),ie=ae("width","number",ie),se=ae("decimals","number",se)}return ie%8&&logger$v.throwArgumentError("invalid fixed format width (not byte aligned)","format.width",ie),se>80&&logger$v.throwArgumentError("invalid fixed format (decimals too large)","format.decimals",se),new FixedFormat(_constructorGuard$3,c,ie,se)}}class FixedNumber{constructor(t,c,ie,se){t!==_constructorGuard$3&&logger$v.throwError("cannot use FixedNumber constructor; use FixedNumber.from",Logger.errors.UNSUPPORTED_OPERATION,{operation:"new FixedFormat"}),this.format=se,this._hex=c,this._value=ie,this._isFixedNumber=!0,Object.freeze(this)}_checkFormat(t){this.format.name!==t.format.name&&logger$v.throwArgumentError("incompatible format; use fixedNumber.toFormat","other",t)}addUnsafe(t){this._checkFormat(t);const c=parseFixed(this._value,this.format.decimals),ie=parseFixed(t._value,t.format.decimals);return FixedNumber.fromValue(c.add(ie),this.format.decimals,this.format)}subUnsafe(t){this._checkFormat(t);const c=parseFixed(this._value,this.format.decimals),ie=parseFixed(t._value,t.format.decimals);return FixedNumber.fromValue(c.sub(ie),this.format.decimals,this.format)}mulUnsafe(t){this._checkFormat(t);const c=parseFixed(this._value,this.format.decimals),ie=parseFixed(t._value,t.format.decimals);return FixedNumber.fromValue(c.mul(ie).div(this.format._multiplier),this.format.decimals,this.format)}divUnsafe(t){this._checkFormat(t);const c=parseFixed(this._value,this.format.decimals),ie=parseFixed(t._value,t.format.decimals);return FixedNumber.fromValue(c.mul(this.format._multiplier).div(ie),this.format.decimals,this.format)}floor(){const t=this.toString().split(".");t.length===1&&t.push("0");let c=FixedNumber.from(t[0],this.format);const ie=!t[1].match(/^(0*)$/);return this.isNegative()&&ie&&(c=c.subUnsafe(ONE.toFormat(c.format))),c}ceiling(){const t=this.toString().split(".");t.length===1&&t.push("0");let c=FixedNumber.from(t[0],this.format);const ie=!t[1].match(/^(0*)$/);return!this.isNegative()&&ie&&(c=c.addUnsafe(ONE.toFormat(c.format))),c}round(t){t==null&&(t=0);const c=this.toString().split(".");if(c.length===1&&c.push("0"),(t<0||t>80||t%1)&&logger$v.throwArgumentError("invalid decimal count","decimals",t),c[1].length<=t)return this;const ie=FixedNumber.from("1"+zeros.substring(0,t),this.format),se=BUMP.toFormat(this.format);return this.mulUnsafe(ie).addUnsafe(se).floor().divUnsafe(ie)}isZero(){return this._value==="0.0"||this._value==="0"}isNegative(){return this._value[0]==="-"}toString(){return this._value}toHexString(t){if(t==null)return this._hex;t%8&&logger$v.throwArgumentError("invalid byte width","width",t);const c=BigNumber.from(this._hex).fromTwos(this.format.width).toTwos(t).toHexString();return hexZeroPad(c,t/8)}toUnsafeFloat(){return parseFloat(this.toString())}toFormat(t){return FixedNumber.fromString(this._value,t)}static fromValue(t,c,ie){return ie==null&&c!=null&&!isBigNumberish(c)&&(ie=c,c=null),c==null&&(c=0),ie==null&&(ie="fixed"),FixedNumber.fromString(formatFixed(t,c),FixedFormat.from(ie))}static fromString(t,c){c==null&&(c="fixed");const ie=FixedFormat.from(c),se=parseFixed(t,ie.decimals);!ie.signed&&se.lt(Zero$2)&&throwFault("unsigned value cannot be negative","overflow","value",t);let ae=null;ie.signed?ae=se.toTwos(ie.width).toHexString():(ae=se.toHexString(),ae=hexZeroPad(ae,ie.width/8));const ue=formatFixed(se,ie.decimals);return new FixedNumber(_constructorGuard$3,ae,ue,ie)}static fromBytes(t,c){c==null&&(c="fixed");const ie=FixedFormat.from(c);if(arrayify(t).length>ie.width/8)throw new Error("overflow");let se=BigNumber.from(t);ie.signed&&(se=se.fromTwos(ie.width));const ae=se.toTwos((ie.signed?0:1)+ie.width).toHexString(),ue=formatFixed(se,ie.decimals);return new FixedNumber(_constructorGuard$3,ae,ue,ie)}static from(t,c){if(typeof t=="string")return FixedNumber.fromString(t,c);if(isBytes$1(t))return FixedNumber.fromBytes(t,c);try{return FixedNumber.fromValue(t,0,c)}catch(ie){if(ie.code!==Logger.errors.INVALID_ARGUMENT)throw ie}return logger$v.throwArgumentError("invalid FixedNumber value","value",t)}static isFixedNumber(t){return!!(t&&t._isFixedNumber)}}const ONE=FixedNumber.from(1),BUMP=FixedNumber.from("0.5"),version$r="properties/5.8.0";var __awaiter$l=function(n,t,c,ie){function se(ae){return ae instanceof c?ae:new c(function(ue){ue(ae)})}return new(c||(c=Promise))(function(ae,ue){function de(we){try{ge(ie.next(we))}catch(Te){ue(Te)}}function ve(we){try{ge(ie.throw(we))}catch(Te){ue(Te)}}function ge(we){we.done?ae(we.value):se(we.value).then(de,ve)}ge((ie=ie.apply(n,[])).next())})};const logger$u=new Logger(version$r);function defineReadOnly(n,t,c){Object.defineProperty(n,t,{enumerable:!0,value:c,writable:!1})}function getStatic(n,t){for(let c=0;c<32;c++){if(n[t])return n[t];if(!n.prototype||typeof n.prototype!="object")break;n=Object.getPrototypeOf(n.prototype).constructor}return null}function resolveProperties(n){return __awaiter$l(this,void 0,void 0,function*(){const t=Object.keys(n).map(c=>{const ie=n[c];return Promise.resolve(ie).then(se=>({key:c,value:se}))});return(yield Promise.all(t)).reduce((c,ie)=>(c[ie.key]=ie.value,c),{})})}function checkProperties(n,t){(!n||typeof n!="object")&&logger$u.throwArgumentError("invalid object","object",n),Object.keys(n).forEach(c=>{t[c]||logger$u.throwArgumentError("invalid object key - "+c,"transaction:"+c,n)})}function shallowCopy(n){const t={};for(const c in n)t[c]=n[c];return t}const opaque={bigint:!0,boolean:!0,function:!0,number:!0,string:!0};function _isFrozen(n){if(n==null||opaque[typeof n])return!0;if(Array.isArray(n)||typeof n=="object"){if(!Object.isFrozen(n))return!1;const t=Object.keys(n);for(let c=0;c<t.length;c++){let ie=null;try{ie=n[t[c]]}catch{continue}if(!_isFrozen(ie))return!1}return!0}return logger$u.throwArgumentError(`Cannot deepCopy ${typeof n}`,"object",n)}function _deepCopy(n){if(_isFrozen(n))return n;if(Array.isArray(n))return Object.freeze(n.map(t=>deepCopy(t)));if(typeof n=="object"){const t={};for(const c in n){const ie=n[c];ie!==void 0&&defineReadOnly(t,c,deepCopy(ie))}return t}return logger$u.throwArgumentError(`Cannot deepCopy ${typeof n}`,"object",n)}function deepCopy(n){return _deepCopy(n)}class Description{constructor(t){for(const c in t)this[c]=deepCopy(t[c])}}const lib_esm$i=Object.freeze(Object.defineProperty({__proto__:null,Description,checkProperties,deepCopy,defineReadOnly,getStatic,resolveProperties,shallowCopy},Symbol.toStringTag,{value:"Module"})),version$q="abi/5.8.0",logger$t=new Logger(version$q),_constructorGuard$2={};let ModifiersBytes={calldata:!0,memory:!0,storage:!0},ModifiersNest={calldata:!0,memory:!0};function checkModifier(n,t){if(n==="bytes"||n==="string"){if(ModifiersBytes[t])return!0}else if(n==="address"){if(t==="payable")return!0}else if((n.indexOf("[")>=0||n==="tuple")&&ModifiersNest[t])return!0;return(ModifiersBytes[t]||t==="payable")&&logger$t.throwArgumentError("invalid modifier","name",t),!1}function parseParamType(n,t){let c=n;function ie(de){logger$t.throwArgumentError(`unexpected character at position ${de}`,"param",n)}n=n.replace(/\s/g," ");function se(de){let ve={type:"",name:"",parent:de,state:{allowType:!0}};return t&&(ve.indexed=!1),ve}let ae={type:"",name:"",state:{allowType:!0}},ue=ae;for(let de=0;de<n.length;de++){let ve=n[de];switch(ve){case"(":ue.state.allowType&&ue.type===""?ue.type="tuple":ue.state.allowParams||ie(de),ue.state.allowType=!1,ue.type=verifyType(ue.type),ue.components=[se(ue)],ue=ue.components[0];break;case")":delete ue.state,ue.name==="indexed"&&(t||ie(de),ue.indexed=!0,ue.name=""),checkModifier(ue.type,ue.name)&&(ue.name=""),ue.type=verifyType(ue.type);let ge=ue;ue=ue.parent,ue||ie(de),delete ge.parent,ue.state.allowParams=!1,ue.state.allowName=!0,ue.state.allowArray=!0;break;case",":delete ue.state,ue.name==="indexed"&&(t||ie(de),ue.indexed=!0,ue.name=""),checkModifier(ue.type,ue.name)&&(ue.name=""),ue.type=verifyType(ue.type);let we=se(ue.parent);ue.parent.components.push(we),delete ue.parent,ue=we;break;case" ":ue.state.allowType&&ue.type!==""&&(ue.type=verifyType(ue.type),delete ue.state.allowType,ue.state.allowName=!0,ue.state.allowParams=!0),ue.state.allowName&&ue.name!==""&&(ue.name==="indexed"?(t||ie(de),ue.indexed&&ie(de),ue.indexed=!0,ue.name=""):checkModifier(ue.type,ue.name)?ue.name="":ue.state.allowName=!1);break;case"[":ue.state.allowArray||ie(de),ue.type+=ve,ue.state.allowArray=!1,ue.state.allowName=!1,ue.state.readArray=!0;break;case"]":ue.state.readArray||ie(de),ue.type+=ve,ue.state.readArray=!1,ue.state.allowArray=!0,ue.state.allowName=!0;break;default:ue.state.allowType?(ue.type+=ve,ue.state.allowParams=!0,ue.state.allowArray=!0):ue.state.allowName?(ue.name+=ve,delete ue.state.allowArray):ue.state.readArray?ue.type+=ve:ie(de)}}return ue.parent&&logger$t.throwArgumentError("unexpected eof","param",n),delete ae.state,ue.name==="indexed"?(t||ie(c.length-7),ue.indexed&&ie(c.length-7),ue.indexed=!0,ue.name=""):checkModifier(ue.type,ue.name)&&(ue.name=""),ae.type=verifyType(ae.type),ae}function populate(n,t){for(let c in t)defineReadOnly(n,c,t[c])}const FormatTypes=Object.freeze({sighash:"sighash",minimal:"minimal",full:"full",json:"json"}),paramTypeArray=new RegExp(/^(.*)\[([0-9]*)\]$/);class ParamType{constructor(t,c){t!==_constructorGuard$2&&logger$t.throwError("use fromString",Logger.errors.UNSUPPORTED_OPERATION,{operation:"new ParamType()"}),populate(this,c);let ie=this.type.match(paramTypeArray);ie?populate(this,{arrayLength:parseInt(ie[2]||"-1"),arrayChildren:ParamType.fromObject({type:ie[1],components:this.components}),baseType:"array"}):populate(this,{arrayLength:null,arrayChildren:null,baseType:this.components!=null?"tuple":this.type}),this._isParamType=!0,Object.freeze(this)}format(t){if(t||(t=FormatTypes.sighash),FormatTypes[t]||logger$t.throwArgumentError("invalid format type","format",t),t===FormatTypes.json){let ie={type:this.baseType==="tuple"?"tuple":this.type,name:this.name||void 0};return typeof this.indexed=="boolean"&&(ie.indexed=this.indexed),this.components&&(ie.components=this.components.map(se=>JSON.parse(se.format(t)))),JSON.stringify(ie)}let c="";return this.baseType==="array"?(c+=this.arrayChildren.format(t),c+="["+(this.arrayLength<0?"":String(this.arrayLength))+"]"):this.baseType==="tuple"?(t!==FormatTypes.sighash&&(c+=this.type),c+="("+this.components.map(ie=>ie.format(t)).join(t===FormatTypes.full?", ":",")+")"):c+=this.type,t!==FormatTypes.sighash&&(this.indexed===!0&&(c+=" indexed"),t===FormatTypes.full&&this.name&&(c+=" "+this.name)),c}static from(t,c){return typeof t=="string"?ParamType.fromString(t,c):ParamType.fromObject(t)}static fromObject(t){return ParamType.isParamType(t)?t:new ParamType(_constructorGuard$2,{name:t.name||null,type:verifyType(t.type),indexed:t.indexed==null?null:!!t.indexed,components:t.components?t.components.map(ParamType.fromObject):null})}static fromString(t,c){function ie(se){return ParamType.fromObject({name:se.name,type:se.type,indexed:se.indexed,components:se.components})}return ie(parseParamType(t,!!c))}static isParamType(t){return!!(t!=null&&t._isParamType)}}function parseParams(n,t){return splitNesting(n).map(c=>ParamType.fromString(c,t))}class Fragment{constructor(t,c){t!==_constructorGuard$2&&logger$t.throwError("use a static from method",Logger.errors.UNSUPPORTED_OPERATION,{operation:"new Fragment()"}),populate(this,c),this._isFragment=!0,Object.freeze(this)}static from(t){return Fragment.isFragment(t)?t:typeof t=="string"?Fragment.fromString(t):Fragment.fromObject(t)}static fromObject(t){if(Fragment.isFragment(t))return t;switch(t.type){case"function":return FunctionFragment.fromObject(t);case"event":return EventFragment.fromObject(t);case"constructor":return ConstructorFragment.fromObject(t);case"error":return ErrorFragment.fromObject(t);case"fallback":case"receive":return null}return logger$t.throwArgumentError("invalid fragment object","value",t)}static fromString(t){return t=t.replace(/\s/g," "),t=t.replace(/\(/g," (").replace(/\)/g,") ").replace(/\s+/g," "),t=t.trim(),t.split(" ")[0]==="event"?EventFragment.fromString(t.substring(5).trim()):t.split(" ")[0]==="function"?FunctionFragment.fromString(t.substring(8).trim()):t.split("(")[0].trim()==="constructor"?ConstructorFragment.fromString(t.trim()):t.split(" ")[0]==="error"?ErrorFragment.fromString(t.substring(5).trim()):logger$t.throwArgumentError("unsupported fragment","value",t)}static isFragment(t){return!!(t&&t._isFragment)}}class EventFragment extends Fragment{format(t){if(t||(t=FormatTypes.sighash),FormatTypes[t]||logger$t.throwArgumentError("invalid format type","format",t),t===FormatTypes.json)return JSON.stringify({type:"event",anonymous:this.anonymous,name:this.name,inputs:this.inputs.map(ie=>JSON.parse(ie.format(t)))});let c="";return t!==FormatTypes.sighash&&(c+="event "),c+=this.name+"("+this.inputs.map(ie=>ie.format(t)).join(t===FormatTypes.full?", ":",")+") ",t!==FormatTypes.sighash&&this.anonymous&&(c+="anonymous "),c.trim()}static from(t){return typeof t=="string"?EventFragment.fromString(t):EventFragment.fromObject(t)}static fromObject(t){if(EventFragment.isEventFragment(t))return t;t.type!=="event"&&logger$t.throwArgumentError("invalid event object","value",t);const c={name:verifyIdentifier(t.name),anonymous:t.anonymous,inputs:t.inputs?t.inputs.map(ParamType.fromObject):[],type:"event"};return new EventFragment(_constructorGuard$2,c)}static fromString(t){let c=t.match(regexParen);c||logger$t.throwArgumentError("invalid event string","value",t);let ie=!1;return c[3].split(" ").forEach(se=>{switch(se.trim()){case"anonymous":ie=!0;break;case"":break;default:logger$t.warn("unknown modifier: "+se)}}),EventFragment.fromObject({name:c[1].trim(),anonymous:ie,inputs:parseParams(c[2],!0),type:"event"})}static isEventFragment(t){return t&&t._isFragment&&t.type==="event"}}function parseGas(n,t){t.gas=null;let c=n.split("@");return c.length!==1?(c.length>2&&logger$t.throwArgumentError("invalid human-readable ABI signature","value",n),c[1].match(/^[0-9]+$/)||logger$t.throwArgumentError("invalid human-readable ABI signature gas","value",n),t.gas=BigNumber.from(c[1]),c[0]):n}function parseModifiers(n,t){t.constant=!1,t.payable=!1,t.stateMutability="nonpayable",n.split(" ").forEach(c=>{switch(c.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: "+c)}})}function verifyState(n){let t={constant:!1,payable:!0,stateMutability:"payable"};return n.stateMutability!=null?(t.stateMutability=n.stateMutability,t.constant=t.stateMutability==="view"||t.stateMutability==="pure",n.constant!=null&&!!n.constant!==t.constant&&logger$t.throwArgumentError("cannot have constant function with mutability "+t.stateMutability,"value",n),t.payable=t.stateMutability==="payable",n.payable!=null&&!!n.payable!==t.payable&&logger$t.throwArgumentError("cannot have payable function with mutability "+t.stateMutability,"value",n)):n.payable!=null?(t.payable=!!n.payable,n.constant==null&&!t.payable&&n.type!=="constructor"&&logger$t.throwArgumentError("unable to determine stateMutability","value",n),t.constant=!!n.constant,t.constant?t.stateMutability="view":t.stateMutability=t.payable?"payable":"nonpayable",t.payable&&t.constant&&logger$t.throwArgumentError("cannot have constant payable function","value",n)):n.constant!=null?(t.constant=!!n.constant,t.payable=!t.constant,t.stateMutability=t.constant?"view":"payable"):n.type!=="constructor"&&logger$t.throwArgumentError("unable to determine stateMutability","value",n),t}class ConstructorFragment extends Fragment{format(t){if(t||(t=FormatTypes.sighash),FormatTypes[t]||logger$t.throwArgumentError("invalid format type","format",t),t===FormatTypes.json)return JSON.stringify({type:"constructor",stateMutability:this.stateMutability!=="nonpayable"?this.stateMutability:void 0,payable:this.payable,gas:this.gas?this.gas.toNumber():void 0,inputs:this.inputs.map(ie=>JSON.parse(ie.format(t)))});t===FormatTypes.sighash&&logger$t.throwError("cannot format a constructor for sighash",Logger.errors.UNSUPPORTED_OPERATION,{operation:"format(sighash)"});let c="constructor("+this.inputs.map(ie=>ie.format(t)).join(t===FormatTypes.full?", ":",")+") ";return this.stateMutability&&this.stateMutability!=="nonpayable"&&(c+=this.stateMutability+" "),c.trim()}static from(t){return typeof t=="string"?ConstructorFragment.fromString(t):ConstructorFragment.fromObject(t)}static fromObject(t){if(ConstructorFragment.isConstructorFragment(t))return t;t.type!=="constructor"&&logger$t.throwArgumentError("invalid constructor object","value",t);let c=verifyState(t);c.constant&&logger$t.throwArgumentError("constructor cannot be constant","value",t);const ie={name:null,type:t.type,inputs:t.inputs?t.inputs.map(ParamType.fromObject):[],payable:c.payable,stateMutability:c.stateMutability,gas:t.gas?BigNumber.from(t.gas):null};return new ConstructorFragment(_constructorGuard$2,ie)}static fromString(t){let c={type:"constructor"};t=parseGas(t,c);let ie=t.match(regexParen);return(!ie||ie[1].trim()!=="constructor")&&logger$t.throwArgumentError("invalid constructor string","value",t),c.inputs=parseParams(ie[2].trim(),!1),parseModifiers(ie[3].trim(),c),ConstructorFragment.fromObject(c)}static isConstructorFragment(t){return t&&t._isFragment&&t.type==="constructor"}}class FunctionFragment extends ConstructorFragment{format(t){if(t||(t=FormatTypes.sighash),FormatTypes[t]||logger$t.throwArgumentError("invalid format type","format",t),t===FormatTypes.json)return JSON.stringify({type:"function",name:this.name,constant:this.constant,stateMutability:this.stateMutability!=="nonpayable"?this.stateMutability:void 0,payable:this.payable,gas:this.gas?this.gas.toNumber():void 0,inputs:this.inputs.map(ie=>JSON.parse(ie.format(t))),outputs:this.outputs.map(ie=>JSON.parse(ie.format(t)))});let c="";return t!==FormatTypes.sighash&&(c+="function "),c+=this.name+"("+this.inputs.map(ie=>ie.format(t)).join(t===FormatTypes.full?", ":",")+") ",t!==FormatTypes.sighash&&(this.stateMutability?this.stateMutability!=="nonpayable"&&(c+=this.stateMutability+" "):this.constant&&(c+="view "),this.outputs&&this.outputs.length&&(c+="returns ("+this.outputs.map(ie=>ie.format(t)).join(", ")+") "),this.gas!=null&&(c+="@"+this.gas.toString()+" ")),c.trim()}static from(t){return typeof t=="string"?FunctionFragment.fromString(t):FunctionFragment.fromObject(t)}static fromObject(t){if(FunctionFragment.isFunctionFragment(t))return t;t.type!=="function"&&logger$t.throwArgumentError("invalid function object","value",t);let c=verifyState(t);const ie={type:t.type,name:verifyIdentifier(t.name),constant:c.constant,inputs:t.inputs?t.inputs.map(ParamType.fromObject):[],outputs:t.outputs?t.outputs.map(ParamType.fromObject):[],payable:c.payable,stateMutability:c.stateMutability,gas:t.gas?BigNumber.from(t.gas):null};return new FunctionFragment(_constructorGuard$2,ie)}static fromString(t){let c={type:"function"};t=parseGas(t,c);let ie=t.split(" returns ");ie.length>2&&logger$t.throwArgumentError("invalid function string","value",t);let se=ie[0].match(regexParen);if(se||logger$t.throwArgumentError("invalid function signature","value",t),c.name=se[1].trim(),c.name&&verifyIdentifier(c.name),c.inputs=parseParams(se[2],!1),parseModifiers(se[3].trim(),c),ie.length>1){let ae=ie[1].match(regexParen);(ae[1].trim()!=""||ae[3].trim()!="")&&logger$t.throwArgumentError("unexpected tokens","value",t),c.outputs=parseParams(ae[2],!1)}else c.outputs=[];return FunctionFragment.fromObject(c)}static isFunctionFragment(t){return t&&t._isFragment&&t.type==="function"}}function checkForbidden(n){const t=n.format();return(t==="Error(string)"||t==="Panic(uint256)")&&logger$t.throwArgumentError(`cannot specify user defined ${t} error`,"fragment",n),n}class ErrorFragment extends Fragment{format(t){if(t||(t=FormatTypes.sighash),FormatTypes[t]||logger$t.throwArgumentError("invalid format type","format",t),t===FormatTypes.json)return JSON.stringify({type:"error",name:this.name,inputs:this.inputs.map(ie=>JSON.parse(ie.format(t)))});let c="";return t!==FormatTypes.sighash&&(c+="error "),c+=this.name+"("+this.inputs.map(ie=>ie.format(t)).join(t===FormatTypes.full?", ":",")+") ",c.trim()}static from(t){return typeof t=="string"?ErrorFragment.fromString(t):ErrorFragment.fromObject(t)}static fromObject(t){if(ErrorFragment.isErrorFragment(t))return t;t.type!=="error"&&logger$t.throwArgumentError("invalid error object","value",t);const c={type:t.type,name:verifyIdentifier(t.name),inputs:t.inputs?t.inputs.map(ParamType.fromObject):[]};return checkForbidden(new ErrorFragment(_constructorGuard$2,c))}static fromString(t){let c={type:"error"},ie=t.match(regexParen);return ie||logger$t.throwArgumentError("invalid error signature","value",t),c.name=ie[1].trim(),c.name&&verifyIdentifier(c.name),c.inputs=parseParams(ie[2],!1),checkForbidden(ErrorFragment.fromObject(c))}static isErrorFragment(t){return t&&t._isFragment&&t.type==="error"}}function verifyType(n){return n.match(/^uint($|[^1-9])/)?n="uint256"+n.substring(4):n.match(/^int($|[^1-9])/)&&(n="int256"+n.substring(3)),n}const regexIdentifier=new RegExp("^[a-zA-Z$_][a-zA-Z0-9$_]*$");function verifyIdentifier(n){return(!n||!n.match(regexIdentifier))&&logger$t.throwArgumentError(`invalid identifier "${n}"`,"value",n),n}const regexParen=new RegExp("^([^)(]*)\\((.*)\\)([^)(]*)$");function splitNesting(n){n=n.trim();let t=[],c="",ie=0;for(let se=0;se<n.length;se++){let ae=n[se];ae===","&&ie===0?(t.push(c),c=""):(c+=ae,ae==="("?ie++:ae===")"&&(ie--,ie===-1&&logger$t.throwArgumentError("unbalanced parenthesis","value",n)))}return c&&t.push(c),t}const logger$s=new Logger(version$q);function checkResultErrors(n){const t=[],c=function(ie,se){if(Array.isArray(se))for(let ae in se){const ue=ie.slice();ue.push(ae);try{c(ue,se[ae])}catch(de){t.push({path:ue,error:de})}}};return c([],n),t}class Coder{constructor(t,c,ie,se){this.name=t,this.type=c,this.localName=ie,this.dynamic=se}_throwError(t,c){logger$s.throwArgumentError(t,this.localName,c)}}class Writer{constructor(t){defineReadOnly(this,"wordSize",t||32),this._data=[],this._dataLength=0,this._padding=new Uint8Array(t)}get data(){return hexConcat(this._data)}get length(){return this._dataLength}_writeData(t){return this._data.push(t),this._dataLength+=t.length,t.length}appendWriter(t){return this._writeData(concat$1(t._data))}writeBytes(t){let c=arrayify(t);const ie=c.length%this.wordSize;return ie&&(c=concat$1([c,this._padding.slice(ie)])),this._writeData(c)}_getValue(t){let c=arrayify(BigNumber.from(t));return c.length>this.wordSize&&logger$s.throwError("value out-of-bounds",Logger.errors.BUFFER_OVERRUN,{length:this.wordSize,offset:c.length}),c.length%this.wordSize&&(c=concat$1([this._padding.slice(c.length%this.wordSize),c])),c}writeValue(t){return this._writeData(this._getValue(t))}writeUpdatableValue(){const t=this._data.length;return this._data.push(this._padding),this._dataLength+=this.wordSize,c=>{this._data[t]=this._getValue(c)}}}class Reader{constructor(t,c,ie,se){defineReadOnly(this,"_data",arrayify(t)),defineReadOnly(this,"wordSize",c||32),defineReadOnly(this,"_coerceFunc",ie),defineReadOnly(this,"allowLoose",se),this._offset=0}get data(){return hexlify(this._data)}get consumed(){return this._offset}static coerce(t,c){let ie=t.match("^u?int([0-9]+)$");return ie&&parseInt(ie[1])<=48&&(c=c.toNumber()),c}coerce(t,c){return this._coerceFunc?this._coerceFunc(t,c):Reader.coerce(t,c)}_peekBytes(t,c,ie){let se=Math.ceil(c/this.wordSize)*this.wordSize;return this._offset+se>this._data.length&&(this.allowLoose&&ie&&this._offset+c<=this._data.length?se=c:logger$s.throwError("data out-of-bounds",Logger.errors.BUFFER_OVERRUN,{length:this._data.length,offset:this._offset+se})),this._data.slice(this._offset,this._offset+se)}subReader(t){return new Reader(this._data.slice(this._offset+t),this.wordSize,this._coerceFunc,this.allowLoose)}readBytes(t,c){let ie=this._peekBytes(0,t,!!c);return this._offset+=ie.length,ie.slice(0,t)}readValue(){return BigNumber.from(this.readBytes(this.wordSize))}}function getDefaultExportFromCjs$1(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var browser$e={exports:{}},process$1=browser$e.exports={},cachedSetTimeout,cachedClearTimeout;function defaultSetTimout(){throw new Error("setTimeout has not been defined")}function defaultClearTimeout(){throw new Error("clearTimeout has not been defined")}(function(){try{typeof setTimeout=="function"?cachedSetTimeout=setTimeout:cachedSetTimeout=defaultSetTimout}catch{cachedSetTimeout=defaultSetTimout}try{typeof clearTimeout=="function"?cachedClearTimeout=clearTimeout:cachedClearTimeout=defaultClearTimeout}catch{cachedClearTimeout=defaultClearTimeout}})();function runTimeout(n){if(cachedSetTimeout===setTimeout)return setTimeout(n,0);if((cachedSetTimeout===defaultSetTimout||!cachedSetTimeout)&&setTimeout)return cachedSetTimeout=setTimeout,setTimeout(n,0);try{return cachedSetTimeout(n,0)}catch{try{return cachedSetTimeout.call(null,n,0)}catch{return cachedSetTimeout.call(this,n,0)}}}function runClearTimeout(n){if(cachedClearTimeout===clearTimeout)return clearTimeout(n);if((cachedClearTimeout===defaultClearTimeout||!cachedClearTimeout)&&clearTimeout)return cachedClearTimeout=clearTimeout,clearTimeout(n);try{return cachedClearTimeout(n)}catch{try{return cachedClearTimeout.call(null,n)}catch{return cachedClearTimeout.call(this,n)}}}var queue=[],draining=!1,currentQueue,queueIndex=-1;function cleanUpNextTick(){!draining||!currentQueue||(draining=!1,currentQueue.length?queue=currentQueue.concat(queue):queueIndex=-1,queue.length&&drainQueue())}function drainQueue(){if(!draining){var n=runTimeout(cleanUpNextTick);draining=!0;for(var t=queue.length;t;){for(currentQueue=queue,queue=[];++queueIndex<t;)currentQueue&&currentQueue[queueIndex].run();queueIndex=-1,t=queue.length}currentQueue=null,draining=!1,runClearTimeout(n)}}process$1.nextTick=function(n){var t=new Array(arguments.length-1);if(arguments.length>1)for(var c=1;c<arguments.length;c++)t[c-1]=arguments[c];queue.push(new Item(n,t)),queue.length===1&&!draining&&runTimeout(drainQueue)};function Item(n,t){this.fun=n,this.array=t}Item.prototype.run=function(){this.fun.apply(null,this.array)};process$1.title="browser";process$1.browser=!0;process$1.env={};process$1.argv=[];process$1.version="";process$1.versions={};function noop$4(){}process$1.on=noop$4;process$1.addListener=noop$4;process$1.once=noop$4;process$1.off=noop$4;process$1.removeListener=noop$4;process$1.removeAllListeners=noop$4;process$1.emit=noop$4;process$1.prependListener=noop$4;process$1.prependOnceListener=noop$4;process$1.listeners=function(n){return[]};process$1.binding=function(n){throw new Error("process.binding is not supported")};process$1.cwd=function(){return"/"};process$1.chdir=function(n){throw new Error("process.chdir is not supported")};process$1.umask=function(){return 0};var browserExports=browser$e.exports;const process$1$1=getDefaultExportFromCjs$1(browserExports);var sha3$3={exports:{}};(function(n){(function(){var t="input is invalid type",c="finalize already called",ie=typeof window=="object",se=ie?window:{};se.JS_SHA3_NO_WINDOW&&(ie=!1);var ae=!ie&&typeof self=="object",ue=!se.JS_SHA3_NO_NODE_JS&&typeof process$1$1=="object"&&process$1$1.versions&&process$1$1.versions.node;ue?se=globalThis:ae&&(se=self);var de=!se.JS_SHA3_NO_COMMON_JS&&!0&&n.exports,ve=!se.JS_SHA3_NO_ARRAY_BUFFER&&typeof ArrayBuffer<"u",ge="0123456789abcdef".split(""),we=[31,7936,2031616,520093696],Te=[4,1024,262144,67108864],Ne=[1,256,65536,16777216],qe=[6,1536,393216,100663296],ze=[0,8,16,24],He=[1,0,32898,0,32906,2147483648,2147516416,2147483648,32907,0,2147483649,0,2147516545,2147483648,32777,2147483648,138,0,136,0,2147516425,0,2147483658,0,2147516555,0,139,2147483648,32905,2147483648,32771,2147483648,32770,2147483648,128,2147483648,32778,0,2147483658,2147483648,2147516545,2147483648,32896,2147483648,2147483649,0,2147516424,2147483648],Ge=[224,256,384,512],Ze=[128,256],Ye=["hex","buffer","arrayBuffer","array","digest"],Ft={128:168,256:136};(se.JS_SHA3_NO_NODE_JS||!Array.isArray)&&(Array.isArray=function(Vt){return Object.prototype.toString.call(Vt)==="[object Array]"}),ve&&(se.JS_SHA3_NO_ARRAY_BUFFER_IS_VIEW||!ArrayBuffer.isView)&&(ArrayBuffer.isView=function(Vt){return typeof Vt=="object"&&Vt.buffer&&Vt.buffer.constructor===ArrayBuffer});for(var Mt=function(Vt,Cn,un){return function(Pt){return new $t(Vt,Cn,Vt).update(Pt)[un]()}},Zt=function(Vt,Cn,un){return function(Pt,mn){return new $t(Vt,Cn,mn).update(Pt)[un]()}},cn=function(Vt,Cn,un){return function(Pt,mn,Pn,wn){return xe["cshake"+Vt].update(Pt,mn,Pn,wn)[un]()}},hn=function(Vt,Cn,un){return function(Pt,mn,Pn,wn){return xe["kmac"+Vt].update(Pt,mn,Pn,wn)[un]()}},yn=function(Vt,Cn,un,Pt){for(var mn=0;mn<Ye.length;++mn){var Pn=Ye[mn];Vt[Pn]=Cn(un,Pt,Pn)}return Vt},Ht=function(Vt,Cn){var un=Mt(Vt,Cn,"hex");return un.create=function(){return new $t(Vt,Cn,Vt)},un.update=function(Pt){return un.create().update(Pt)},yn(un,Mt,Vt,Cn)},Sn=function(Vt,Cn){var un=Zt(Vt,Cn,"hex");return un.create=function(Pt){return new $t(Vt,Cn,Pt)},un.update=function(Pt,mn){return un.create(mn).update(Pt)},yn(un,Zt,Vt,Cn)},le=function(Vt,Cn){var un=Ft[Vt],Pt=cn(Vt,Cn,"hex");return Pt.create=function(mn,Pn,wn){return!Pn&&!wn?xe["shake"+Vt].create(mn):new $t(Vt,Cn,mn).bytepad([Pn,wn],un)},Pt.update=function(mn,Pn,wn,jt){return Pt.create(Pn,wn,jt).update(mn)},yn(Pt,cn,Vt,Cn)},pe=function(Vt,Cn){var un=Ft[Vt],Pt=hn(Vt,Cn,"hex");return Pt.create=function(mn,Pn,wn){return new dn(Vt,Cn,Pn).bytepad(["KMAC",wn],un).bytepad([mn],un)},Pt.update=function(mn,Pn,wn,jt){return Pt.create(mn,wn,jt).update(Pn)},yn(Pt,hn,Vt,Cn)},be=[{name:"keccak",padding:Ne,bits:Ge,createMethod:Ht},{name:"sha3",padding:qe,bits:Ge,createMethod:Ht},{name:"shake",padding:we,bits:Ze,createMethod:Sn},{name:"cshake",padding:Te,bits:Ze,createMethod:le},{name:"kmac",padding:Te,bits:Ze,createMethod:pe}],xe={},_e=[],De=0;De<be.length;++De)for(var Fe=be[De],$e=Fe.bits,ce=0;ce<$e.length;++ce){var Me=Fe.name+"_"+$e[ce];if(_e.push(Me),xe[Me]=Fe.createMethod($e[ce],Fe.padding),Fe.name!=="sha3"){var We=Fe.name+$e[ce];_e.push(We),xe[We]=xe[Me]}}function $t(Vt,Cn,un){this.blocks=[],this.s=[],this.padding=Cn,this.outputBits=un,this.reset=!0,this.finalized=!1,this.block=0,this.start=0,this.blockCount=1600-(Vt<<1)>>5,this.byteCount=this.blockCount<<2,this.outputBlocks=un>>5,this.extraBytes=(un&31)>>3;for(var Pt=0;Pt<50;++Pt)this.s[Pt]=0}$t.prototype.update=function(Vt){if(this.finalized)throw new Error(c);var Cn,un=typeof Vt;if(un!=="string"){if(un==="object"){if(Vt===null)throw new Error(t);if(ve&&Vt.constructor===ArrayBuffer)Vt=new Uint8Array(Vt);else if(!Array.isArray(Vt)&&(!ve||!ArrayBuffer.isView(Vt)))throw new Error(t)}else throw new Error(t);Cn=!0}for(var Pt=this.blocks,mn=this.byteCount,Pn=Vt.length,wn=this.blockCount,jt=0,$n=this.s,Mn,Nn;jt<Pn;){if(this.reset)for(this.reset=!1,Pt[0]=this.block,Mn=1;Mn<wn+1;++Mn)Pt[Mn]=0;if(Cn)for(Mn=this.start;jt<Pn&&Mn<mn;++jt)Pt[Mn>>2]|=Vt[jt]<<ze[Mn++&3];else for(Mn=this.start;jt<Pn&&Mn<mn;++jt)Nn=Vt.charCodeAt(jt),Nn<128?Pt[Mn>>2]|=Nn<<ze[Mn++&3]:Nn<2048?(Pt[Mn>>2]|=(192|Nn>>6)<<ze[Mn++&3],Pt[Mn>>2]|=(128|Nn&63)<<ze[Mn++&3]):Nn<55296||Nn>=57344?(Pt[Mn>>2]|=(224|Nn>>12)<<ze[Mn++&3],Pt[Mn>>2]|=(128|Nn>>6&63)<<ze[Mn++&3],Pt[Mn>>2]|=(128|Nn&63)<<ze[Mn++&3]):(Nn=65536+((Nn&1023)<<10|Vt.charCodeAt(++jt)&1023),Pt[Mn>>2]|=(240|Nn>>18)<<ze[Mn++&3],Pt[Mn>>2]|=(128|Nn>>12&63)<<ze[Mn++&3],Pt[Mn>>2]|=(128|Nn>>6&63)<<ze[Mn++&3],Pt[Mn>>2]|=(128|Nn&63)<<ze[Mn++&3]);if(this.lastByteIndex=Mn,Mn>=mn){for(this.start=Mn-mn,this.block=Pt[wn],Mn=0;Mn<wn;++Mn)$n[Mn]^=Pt[Mn];gn($n),this.reset=!0}else this.start=Mn}return this},$t.prototype.encode=function(Vt,Cn){var un=Vt&255,Pt=1,mn=[un];for(Vt=Vt>>8,un=Vt&255;un>0;)mn.unshift(un),Vt=Vt>>8,un=Vt&255,++Pt;return Cn?mn.push(Pt):mn.unshift(Pt),this.update(mn),mn.length},$t.prototype.encodeString=function(Vt){var Cn,un=typeof Vt;if(un!=="string"){if(un==="object"){if(Vt===null)throw new Error(t);if(ve&&Vt.constructor===ArrayBuffer)Vt=new Uint8Array(Vt);else if(!Array.isArray(Vt)&&(!ve||!ArrayBuffer.isView(Vt)))throw new Error(t)}else throw new Error(t);Cn=!0}var Pt=0,mn=Vt.length;if(Cn)Pt=mn;else for(var Pn=0;Pn<Vt.length;++Pn){var wn=Vt.charCodeAt(Pn);wn<128?Pt+=1:wn<2048?Pt+=2:wn<55296||wn>=57344?Pt+=3:(wn=65536+((wn&1023)<<10|Vt.charCodeAt(++Pn)&1023),Pt+=4)}return Pt+=this.encode(Pt*8),this.update(Vt),Pt},$t.prototype.bytepad=function(Vt,Cn){for(var un=this.encode(Cn),Pt=0;Pt<Vt.length;++Pt)un+=this.encodeString(Vt[Pt]);var mn=Cn-un%Cn,Pn=[];return Pn.length=mn,this.update(Pn),this},$t.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var Vt=this.blocks,Cn=this.lastByteIndex,un=this.blockCount,Pt=this.s;if(Vt[Cn>>2]|=this.padding[Cn&3],this.lastByteIndex===this.byteCount)for(Vt[0]=Vt[un],Cn=1;Cn<un+1;++Cn)Vt[Cn]=0;for(Vt[un-1]|=2147483648,Cn=0;Cn<un;++Cn)Pt[Cn]^=Vt[Cn];gn(Pt)}},$t.prototype.toString=$t.prototype.hex=function(){this.finalize();for(var Vt=this.blockCount,Cn=this.s,un=this.outputBlocks,Pt=this.extraBytes,mn=0,Pn=0,wn="",jt;Pn<un;){for(mn=0;mn<Vt&&Pn<un;++mn,++Pn)jt=Cn[mn],wn+=ge[jt>>4&15]+ge[jt&15]+ge[jt>>12&15]+ge[jt>>8&15]+ge[jt>>20&15]+ge[jt>>16&15]+ge[jt>>28&15]+ge[jt>>24&15];Pn%Vt===0&&(gn(Cn),mn=0)}return Pt&&(jt=Cn[mn],wn+=ge[jt>>4&15]+ge[jt&15],Pt>1&&(wn+=ge[jt>>12&15]+ge[jt>>8&15]),Pt>2&&(wn+=ge[jt>>20&15]+ge[jt>>16&15])),wn},$t.prototype.arrayBuffer=function(){this.finalize();var Vt=this.blockCount,Cn=this.s,un=this.outputBlocks,Pt=this.extraBytes,mn=0,Pn=0,wn=this.outputBits>>3,jt;Pt?jt=new ArrayBuffer(un+1<<2):jt=new ArrayBuffer(wn);for(var $n=new Uint32Array(jt);Pn<un;){for(mn=0;mn<Vt&&Pn<un;++mn,++Pn)$n[Pn]=Cn[mn];Pn%Vt===0&&gn(Cn)}return Pt&&($n[mn]=Cn[mn],jt=jt.slice(0,wn)),jt},$t.prototype.buffer=$t.prototype.arrayBuffer,$t.prototype.digest=$t.prototype.array=function(){this.finalize();for(var Vt=this.blockCount,Cn=this.s,un=this.outputBlocks,Pt=this.extraBytes,mn=0,Pn=0,wn=[],jt,$n;Pn<un;){for(mn=0;mn<Vt&&Pn<un;++mn,++Pn)jt=Pn<<2,$n=Cn[mn],wn[jt]=$n&255,wn[jt+1]=$n>>8&255,wn[jt+2]=$n>>16&255,wn[jt+3]=$n>>24&255;Pn%Vt===0&&gn(Cn)}return Pt&&(jt=Pn<<2,$n=Cn[mn],wn[jt]=$n&255,Pt>1&&(wn[jt+1]=$n>>8&255),Pt>2&&(wn[jt+2]=$n>>16&255)),wn};function dn(Vt,Cn,un){$t.call(this,Vt,Cn,un)}dn.prototype=new $t,dn.prototype.finalize=function(){return this.encode(this.outputBits,!0),$t.prototype.finalize.call(this)};var gn=function(Vt){var Cn,un,Pt,mn,Pn,wn,jt,$n,Mn,Nn,Zn,qn,Vn,Gn,Kn,Jn,bi,Hn,An,Ln,On,Un,ti,Fn,Gt,En,xn,In,Wn,jn,zn,Ri,Qn,li,Ci,ri,yi,Ai,ci,vi,Mi,di,wi,Ti,hi,xi,Pi,pi,Ei,Bi,mi,_i,Ii,gi,Si,ki,$i,Ni,Oi,Li,Fi,ji,Di;for(Pt=0;Pt<48;Pt+=2)mn=Vt[0]^Vt[10]^Vt[20]^Vt[30]^Vt[40],Pn=Vt[1]^Vt[11]^Vt[21]^Vt[31]^Vt[41],wn=Vt[2]^Vt[12]^Vt[22]^Vt[32]^Vt[42],jt=Vt[3]^Vt[13]^Vt[23]^Vt[33]^Vt[43],$n=Vt[4]^Vt[14]^Vt[24]^Vt[34]^Vt[44],Mn=Vt[5]^Vt[15]^Vt[25]^Vt[35]^Vt[45],Nn=Vt[6]^Vt[16]^Vt[26]^Vt[36]^Vt[46],Zn=Vt[7]^Vt[17]^Vt[27]^Vt[37]^Vt[47],qn=Vt[8]^Vt[18]^Vt[28]^Vt[38]^Vt[48],Vn=Vt[9]^Vt[19]^Vt[29]^Vt[39]^Vt[49],Cn=qn^(wn<<1|jt>>>31),un=Vn^(jt<<1|wn>>>31),Vt[0]^=Cn,Vt[1]^=un,Vt[10]^=Cn,Vt[11]^=un,Vt[20]^=Cn,Vt[21]^=un,Vt[30]^=Cn,Vt[31]^=un,Vt[40]^=Cn,Vt[41]^=un,Cn=mn^($n<<1|Mn>>>31),un=Pn^(Mn<<1|$n>>>31),Vt[2]^=Cn,Vt[3]^=un,Vt[12]^=Cn,Vt[13]^=un,Vt[22]^=Cn,Vt[23]^=un,Vt[32]^=Cn,Vt[33]^=un,Vt[42]^=Cn,Vt[43]^=un,Cn=wn^(Nn<<1|Zn>>>31),un=jt^(Zn<<1|Nn>>>31),Vt[4]^=Cn,Vt[5]^=un,Vt[14]^=Cn,Vt[15]^=un,Vt[24]^=Cn,Vt[25]^=un,Vt[34]^=Cn,Vt[35]^=un,Vt[44]^=Cn,Vt[45]^=un,Cn=$n^(qn<<1|Vn>>>31),un=Mn^(Vn<<1|qn>>>31),Vt[6]^=Cn,Vt[7]^=un,Vt[16]^=Cn,Vt[17]^=un,Vt[26]^=Cn,Vt[27]^=un,Vt[36]^=Cn,Vt[37]^=un,Vt[46]^=Cn,Vt[47]^=un,Cn=Nn^(mn<<1|Pn>>>31),un=Zn^(Pn<<1|mn>>>31),Vt[8]^=Cn,Vt[9]^=un,Vt[18]^=Cn,Vt[19]^=un,Vt[28]^=Cn,Vt[29]^=un,Vt[38]^=Cn,Vt[39]^=un,Vt[48]^=Cn,Vt[49]^=un,Gn=Vt[0],Kn=Vt[1],xi=Vt[11]<<4|Vt[10]>>>28,Pi=Vt[10]<<4|Vt[11]>>>28,In=Vt[20]<<3|Vt[21]>>>29,Wn=Vt[21]<<3|Vt[20]>>>29,Li=Vt[31]<<9|Vt[30]>>>23,Fi=Vt[30]<<9|Vt[31]>>>23,di=Vt[40]<<18|Vt[41]>>>14,wi=Vt[41]<<18|Vt[40]>>>14,li=Vt[2]<<1|Vt[3]>>>31,Ci=Vt[3]<<1|Vt[2]>>>31,Jn=Vt[13]<<12|Vt[12]>>>20,bi=Vt[12]<<12|Vt[13]>>>20,pi=Vt[22]<<10|Vt[23]>>>22,Ei=Vt[23]<<10|Vt[22]>>>22,jn=Vt[33]<<13|Vt[32]>>>19,zn=Vt[32]<<13|Vt[33]>>>19,ji=Vt[42]<<2|Vt[43]>>>30,Di=Vt[43]<<2|Vt[42]>>>30,gi=Vt[5]<<30|Vt[4]>>>2,Si=Vt[4]<<30|Vt[5]>>>2,ri=Vt[14]<<6|Vt[15]>>>26,yi=Vt[15]<<6|Vt[14]>>>26,Hn=Vt[25]<<11|Vt[24]>>>21,An=Vt[24]<<11|Vt[25]>>>21,Bi=Vt[34]<<15|Vt[35]>>>17,mi=Vt[35]<<15|Vt[34]>>>17,Ri=Vt[45]<<29|Vt[44]>>>3,Qn=Vt[44]<<29|Vt[45]>>>3,Fn=Vt[6]<<28|Vt[7]>>>4,Gt=Vt[7]<<28|Vt[6]>>>4,ki=Vt[17]<<23|Vt[16]>>>9,$i=Vt[16]<<23|Vt[17]>>>9,Ai=Vt[26]<<25|Vt[27]>>>7,ci=Vt[27]<<25|Vt[26]>>>7,Ln=Vt[36]<<21|Vt[37]>>>11,On=Vt[37]<<21|Vt[36]>>>11,_i=Vt[47]<<24|Vt[46]>>>8,Ii=Vt[46]<<24|Vt[47]>>>8,Ti=Vt[8]<<27|Vt[9]>>>5,hi=Vt[9]<<27|Vt[8]>>>5,En=Vt[18]<<20|Vt[19]>>>12,xn=Vt[19]<<20|Vt[18]>>>12,Ni=Vt[29]<<7|Vt[28]>>>25,Oi=Vt[28]<<7|Vt[29]>>>25,vi=Vt[38]<<8|Vt[39]>>>24,Mi=Vt[39]<<8|Vt[38]>>>24,Un=Vt[48]<<14|Vt[49]>>>18,ti=Vt[49]<<14|Vt[48]>>>18,Vt[0]=Gn^~Jn&Hn,Vt[1]=Kn^~bi&An,Vt[10]=Fn^~En&In,Vt[11]=Gt^~xn&Wn,Vt[20]=li^~ri&Ai,Vt[21]=Ci^~yi&ci,Vt[30]=Ti^~xi&pi,Vt[31]=hi^~Pi&Ei,Vt[40]=gi^~ki&Ni,Vt[41]=Si^~$i&Oi,Vt[2]=Jn^~Hn&Ln,Vt[3]=bi^~An&On,Vt[12]=En^~In&jn,Vt[13]=xn^~Wn&zn,Vt[22]=ri^~Ai&vi,Vt[23]=yi^~ci&Mi,Vt[32]=xi^~pi&Bi,Vt[33]=Pi^~Ei&mi,Vt[42]=ki^~Ni&Li,Vt[43]=$i^~Oi&Fi,Vt[4]=Hn^~Ln&Un,Vt[5]=An^~On&ti,Vt[14]=In^~jn&Ri,Vt[15]=Wn^~zn&Qn,Vt[24]=Ai^~vi&di,Vt[25]=ci^~Mi&wi,Vt[34]=pi^~Bi&_i,Vt[35]=Ei^~mi&Ii,Vt[44]=Ni^~Li&ji,Vt[45]=Oi^~Fi&Di,Vt[6]=Ln^~Un&Gn,Vt[7]=On^~ti&Kn,Vt[16]=jn^~Ri&Fn,Vt[17]=zn^~Qn&Gt,Vt[26]=vi^~di&li,Vt[27]=Mi^~wi&Ci,Vt[36]=Bi^~_i&Ti,Vt[37]=mi^~Ii&hi,Vt[46]=Li^~ji&gi,Vt[47]=Fi^~Di&Si,Vt[8]=Un^~Gn&Jn,Vt[9]=ti^~Kn&bi,Vt[18]=Ri^~Fn&En,Vt[19]=Qn^~Gt&xn,Vt[28]=di^~li&ri,Vt[29]=wi^~Ci&yi,Vt[38]=_i^~Ti&xi,Vt[39]=Ii^~hi&Pi,Vt[48]=ji^~gi&ki,Vt[49]=Di^~Si&$i,Vt[0]^=He[Pt],Vt[1]^=He[Pt+1]};if(de)n.exports=xe;else for(De=0;De<_e.length;++De)se[_e[De]]=xe[_e[De]]})()})(sha3$3);var sha3Exports$1=sha3$3.exports;const sha3$2=getDefaultExportFromCjs$2(sha3Exports$1);function keccak256$1(n){return"0x"+sha3$2.keccak_256(arrayify(n))}const lib_esm$h=Object.freeze(Object.defineProperty({__proto__:null,keccak256:keccak256$1},Symbol.toStringTag,{value:"Module"})),version$p="rlp/5.8.0",logger$r=new Logger(version$p);function arrayifyInteger(n){const t=[];for(;n;)t.unshift(n&255),n>>=8;return t}function unarrayifyInteger(n,t,c){let ie=0;for(let se=0;se<c;se++)ie=ie*256+n[t+se];return ie}function _encode(n){if(Array.isArray(n)){let ie=[];if(n.forEach(function(ae){ie=ie.concat(_encode(ae))}),ie.length<=55)return ie.unshift(192+ie.length),ie;const se=arrayifyInteger(ie.length);return se.unshift(247+se.length),se.concat(ie)}isBytesLike(n)||logger$r.throwArgumentError("RLP object must be BytesLike","object",n);const t=Array.prototype.slice.call(arrayify(n));if(t.length===1&&t[0]<=127)return t;if(t.length<=55)return t.unshift(128+t.length),t;const c=arrayifyInteger(t.length);return c.unshift(183+c.length),c.concat(t)}function encode$6(n){return hexlify(_encode(n))}function _decodeChildren(n,t,c,ie){const se=[];for(;c<t+1+ie;){const ae=_decode(n,c);se.push(ae.result),c+=ae.consumed,c>t+1+ie&&logger$r.throwError("child data too short",Logger.errors.BUFFER_OVERRUN,{})}return{consumed:1+ie,result:se}}function _decode(n,t){if(n.length===0&&logger$r.throwError("data too short",Logger.errors.BUFFER_OVERRUN,{}),n[t]>=248){const c=n[t]-247;t+1+c>n.length&&logger$r.throwError("data short segment too short",Logger.errors.BUFFER_OVERRUN,{});const ie=unarrayifyInteger(n,t+1,c);return t+1+c+ie>n.length&&logger$r.throwError("data long segment too short",Logger.errors.BUFFER_OVERRUN,{}),_decodeChildren(n,t,t+1+c,c+ie)}else if(n[t]>=192){const c=n[t]-192;return t+1+c>n.length&&logger$r.throwError("data array too short",Logger.errors.BUFFER_OVERRUN,{}),_decodeChildren(n,t,t+1,c)}else if(n[t]>=184){const c=n[t]-183;t+1+c>n.length&&logger$r.throwError("data array too short",Logger.errors.BUFFER_OVERRUN,{});const ie=unarrayifyInteger(n,t+1,c);t+1+c+ie>n.length&&logger$r.throwError("data array too short",Logger.errors.BUFFER_OVERRUN,{});const se=hexlify(n.slice(t+1+c,t+1+c+ie));return{consumed:1+c+ie,result:se}}else if(n[t]>=128){const c=n[t]-128;t+1+c>n.length&&logger$r.throwError("data too short",Logger.errors.BUFFER_OVERRUN,{});const ie=hexlify(n.slice(t+1,t+1+c));return{consumed:1+c,result:ie}}return{consumed:1,result:hexlify(n[t])}}function decode$7(n){const t=arrayify(n),c=_decode(t,0);return c.consumed!==t.length&&logger$r.throwArgumentError("invalid rlp data","data",n),c.result}const lib_esm$g=Object.freeze(Object.defineProperty({__proto__:null,decode:decode$7,encode:encode$6},Symbol.toStringTag,{value:"Module"})),version$o="address/5.8.0",logger$q=new Logger(version$o);function getChecksumAddress(n){isHexString(n,20)||logger$q.throwArgumentError("invalid address","address",n),n=n.toLowerCase();const t=n.substring(2).split(""),c=new Uint8Array(40);for(let se=0;se<40;se++)c[se]=t[se].charCodeAt(0);const ie=arrayify(keccak256$1(c));for(let se=0;se<40;se+=2)ie[se>>1]>>4>=8&&(t[se]=t[se].toUpperCase()),(ie[se>>1]&15)>=8&&(t[se+1]=t[se+1].toUpperCase());return"0x"+t.join("")}const MAX_SAFE_INTEGER=9007199254740991;function log10(n){return Math.log10?Math.log10(n):Math.log(n)/Math.LN10}const ibanLookup={};for(let n=0;n<10;n++)ibanLookup[String(n)]=String(n);for(let n=0;n<26;n++)ibanLookup[String.fromCharCode(65+n)]=String(10+n);const safeDigits=Math.floor(log10(MAX_SAFE_INTEGER));function ibanChecksum(n){n=n.toUpperCase(),n=n.substring(4)+n.substring(0,2)+"00";let t=n.split("").map(ie=>ibanLookup[ie]).join("");for(;t.length>=safeDigits;){let ie=t.substring(0,safeDigits);t=parseInt(ie,10)%97+t.substring(ie.length)}let c=String(98-parseInt(t,10)%97);for(;c.length<2;)c="0"+c;return c}function getAddress$1(n){let t=null;if(typeof n!="string"&&logger$q.throwArgumentError("invalid address","address",n),n.match(/^(0x)?[0-9a-fA-F]{40}$/))n.substring(0,2)!=="0x"&&(n="0x"+n),t=getChecksumAddress(n),n.match(/([A-F].*[a-f])|([a-f].*[A-F])/)&&t!==n&&logger$q.throwArgumentError("bad address checksum","address",n);else if(n.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)){for(n.substring(2,4)!==ibanChecksum(n)&&logger$q.throwArgumentError("bad icap checksum","address",n),t=_base36To16(n.substring(4));t.length<40;)t="0"+t;t=getChecksumAddress("0x"+t)}else logger$q.throwArgumentError("invalid address","address",n);return t}function isAddress(n){try{return getAddress$1(n),!0}catch{}return!1}function getIcapAddress(n){let t=_base16To36(getAddress$1(n).substring(2)).toUpperCase();for(;t.length<30;)t="0"+t;return"XE"+ibanChecksum("XE00"+t)+t}function getContractAddress(n){let t=null;try{t=getAddress$1(n.from)}catch{logger$q.throwArgumentError("missing from address","transaction",n)}const c=stripZeros(arrayify(BigNumber.from(n.nonce).toHexString()));return getAddress$1(hexDataSlice(keccak256$1(encode$6([t,c])),12))}function getCreate2Address(n,t,c){return hexDataLength(t)!==32&&logger$q.throwArgumentError("salt must be 32 bytes","salt",t),hexDataLength(c)!==32&&logger$q.throwArgumentError("initCodeHash must be 32 bytes","initCodeHash",c),getAddress$1(hexDataSlice(keccak256$1(concat$1(["0xff",getAddress$1(n),t,c])),12))}const lib_esm$f=Object.freeze(Object.defineProperty({__proto__:null,getAddress:getAddress$1,getContractAddress,getCreate2Address,getIcapAddress,isAddress},Symbol.toStringTag,{value:"Module"}));class AddressCoder extends Coder{constructor(t){super("address","address",t,!1)}defaultValue(){return"0x0000000000000000000000000000000000000000"}encode(t,c){try{c=getAddress$1(c)}catch(ie){this._throwError(ie.message,c)}return t.writeValue(c)}decode(t){return getAddress$1(hexZeroPad(t.readValue().toHexString(),20))}}class AnonymousCoder extends Coder{constructor(t){super(t.name,t.type,void 0,t.dynamic),this.coder=t}defaultValue(){return this.coder.defaultValue()}encode(t,c){return this.coder.encode(t,c)}decode(t){return this.coder.decode(t)}}const logger$p=new Logger(version$q);function pack$1(n,t,c){let ie=null;if(Array.isArray(c))ie=c;else if(c&&typeof c=="object"){let ve={};ie=t.map(ge=>{const we=ge.localName;return we||logger$p.throwError("cannot encode object for signature with missing names",Logger.errors.INVALID_ARGUMENT,{argument:"values",coder:ge,value:c}),ve[we]&&logger$p.throwError("cannot encode object for signature with duplicate names",Logger.errors.INVALID_ARGUMENT,{argument:"values",coder:ge,value:c}),ve[we]=!0,c[we]})}else logger$p.throwArgumentError("invalid tuple value","tuple",c);t.length!==ie.length&&logger$p.throwArgumentError("types/value length mismatch","tuple",c);let se=new Writer(n.wordSize),ae=new Writer(n.wordSize),ue=[];t.forEach((ve,ge)=>{let we=ie[ge];if(ve.dynamic){let Te=ae.length;ve.encode(ae,we);let Ne=se.writeUpdatableValue();ue.push(qe=>{Ne(qe+Te)})}else ve.encode(se,we)}),ue.forEach(ve=>{ve(se.length)});let de=n.appendWriter(se);return de+=n.appendWriter(ae),de}function unpack(n,t){let c=[],ie=n.subReader(0);t.forEach(ae=>{let ue=null;if(ae.dynamic){let de=n.readValue(),ve=ie.subReader(de.toNumber());try{ue=ae.decode(ve)}catch(ge){if(ge.code===Logger.errors.BUFFER_OVERRUN)throw ge;ue=ge,ue.baseType=ae.name,ue.name=ae.localName,ue.type=ae.type}}else try{ue=ae.decode(n)}catch(de){if(de.code===Logger.errors.BUFFER_OVERRUN)throw de;ue=de,ue.baseType=ae.name,ue.name=ae.localName,ue.type=ae.type}ue!=null&&c.push(ue)});const se=t.reduce((ae,ue)=>{const de=ue.localName;return de&&(ae[de]||(ae[de]=0),ae[de]++),ae},{});t.forEach((ae,ue)=>{let de=ae.localName;if(!de||se[de]!==1||(de==="length"&&(de="_length"),c[de]!=null))return;const ve=c[ue];ve instanceof Error?Object.defineProperty(c,de,{enumerable:!0,get:()=>{throw ve}}):c[de]=ve});for(let ae=0;ae<c.length;ae++){const ue=c[ae];ue instanceof Error&&Object.defineProperty(c,ae,{enumerable:!0,get:()=>{throw ue}})}return Object.freeze(c)}class ArrayCoder extends Coder{constructor(t,c,ie){const se=t.type+"["+(c>=0?c:"")+"]",ae=c===-1||t.dynamic;super("array",se,ie,ae),this.coder=t,this.length=c}defaultValue(){const t=this.coder.defaultValue(),c=[];for(let ie=0;ie<this.length;ie++)c.push(t);return c}encode(t,c){Array.isArray(c)||this._throwError("expected array value",c);let ie=this.length;ie===-1&&(ie=c.length,t.writeValue(c.length)),logger$p.checkArgumentCount(c.length,ie,"coder array"+(this.localName?" "+this.localName:""));let se=[];for(let ae=0;ae<c.length;ae++)se.push(this.coder);return pack$1(t,se,c)}decode(t){let c=this.length;c===-1&&(c=t.readValue().toNumber(),c*32>t._data.length&&logger$p.throwError("insufficient data length",Logger.errors.BUFFER_OVERRUN,{length:t._data.length,count:c}));let ie=[];for(let se=0;se<c;se++)ie.push(new AnonymousCoder(this.coder));return t.coerce(this.name,unpack(t,ie))}}class BooleanCoder extends Coder{constructor(t){super("bool","bool",t,!1)}defaultValue(){return!1}encode(t,c){return t.writeValue(c?1:0)}decode(t){return t.coerce(this.type,!t.readValue().isZero())}}class DynamicBytesCoder extends Coder{constructor(t,c){super(t,t,c,!0)}defaultValue(){return"0x"}encode(t,c){c=arrayify(c);let ie=t.writeValue(c.length);return ie+=t.writeBytes(c),ie}decode(t){return t.readBytes(t.readValue().toNumber(),!0)}}class BytesCoder extends DynamicBytesCoder{constructor(t){super("bytes",t)}decode(t){return t.coerce(this.name,hexlify(super.decode(t)))}}class FixedBytesCoder extends Coder{constructor(t,c){let ie="bytes"+String(t);super(ie,ie,c,!1),this.size=t}defaultValue(){return"0x0000000000000000000000000000000000000000000000000000000000000000".substring(0,2+this.size*2)}encode(t,c){let ie=arrayify(c);return ie.length!==this.size&&this._throwError("incorrect data length",c),t.writeBytes(ie)}decode(t){return t.coerce(this.name,hexlify(t.readBytes(this.size)))}}class NullCoder extends Coder{constructor(t){super("null","",t,!1)}defaultValue(){return null}encode(t,c){return c!=null&&this._throwError("not null",c),t.writeBytes([])}decode(t){return t.readBytes(0),t.coerce(this.name,null)}}const AddressZero="0x0000000000000000000000000000000000000000",NegativeOne$1=BigNumber.from(-1),Zero$1=BigNumber.from(0),One$1=BigNumber.from(1),MaxUint256$1=BigNumber.from("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),HashZero="0x0000000000000000000000000000000000000000000000000000000000000000";class NumberCoder extends Coder{constructor(t,c,ie){const se=(c?"int":"uint")+t*8;super(se,se,ie,!1),this.size=t,this.signed=c}defaultValue(){return 0}encode(t,c){let ie=BigNumber.from(c),se=MaxUint256$1.mask(t.wordSize*8);if(this.signed){let ae=se.mask(this.size*8-1);(ie.gt(ae)||ie.lt(ae.add(One$1).mul(NegativeOne$1)))&&this._throwError("value out-of-bounds",c)}else(ie.lt(Zero$1)||ie.gt(se.mask(this.size*8)))&&this._throwError("value out-of-bounds",c);return ie=ie.toTwos(this.size*8).mask(this.size*8),this.signed&&(ie=ie.fromTwos(this.size*8).toTwos(8*t.wordSize)),t.writeValue(ie)}decode(t){let c=t.readValue().mask(this.size*8);return this.signed&&(c=c.fromTwos(this.size*8)),t.coerce(this.name,c)}}const version$n="strings/5.8.0",logger$o=new Logger(version$n);var UnicodeNormalizationForm;(function(n){n.current="",n.NFC="NFC",n.NFD="NFD",n.NFKC="NFKC",n.NFKD="NFKD"})(UnicodeNormalizationForm||(UnicodeNormalizationForm={}));var Utf8ErrorReason;(function(n){n.UNEXPECTED_CONTINUE="unexpected continuation byte",n.BAD_PREFIX="bad codepoint prefix",n.OVERRUN="string overrun",n.MISSING_CONTINUE="missing continuation byte",n.OUT_OF_RANGE="out of UTF-8 range",n.UTF16_SURROGATE="UTF-16 surrogate",n.OVERLONG="overlong representation"})(Utf8ErrorReason||(Utf8ErrorReason={}));function errorFunc(n,t,c,ie,se){return logger$o.throwArgumentError(`invalid codepoint at offset ${t}; ${n}`,"bytes",c)}function ignoreFunc(n,t,c,ie,se){if(n===Utf8ErrorReason.BAD_PREFIX||n===Utf8ErrorReason.UNEXPECTED_CONTINUE){let ae=0;for(let ue=t+1;ue<c.length&&c[ue]>>6===2;ue++)ae++;return ae}return n===Utf8ErrorReason.OVERRUN?c.length-t-1:0}function replaceFunc(n,t,c,ie,se){return n===Utf8ErrorReason.OVERLONG?(ie.push(se),0):(ie.push(65533),ignoreFunc(n,t,c))}const Utf8ErrorFuncs=Object.freeze({error:errorFunc,ignore:ignoreFunc,replace:replaceFunc});function getUtf8CodePoints(n,t){t==null&&(t=Utf8ErrorFuncs.error),n=arrayify(n);const c=[];let ie=0;for(;ie<n.length;){const se=n[ie++];if(!(se>>7)){c.push(se);continue}let ae=null,ue=null;if((se&224)===192)ae=1,ue=127;else if((se&240)===224)ae=2,ue=2047;else if((se&248)===240)ae=3,ue=65535;else{(se&192)===128?ie+=t(Utf8ErrorReason.UNEXPECTED_CONTINUE,ie-1,n,c):ie+=t(Utf8ErrorReason.BAD_PREFIX,ie-1,n,c);continue}if(ie-1+ae>=n.length){ie+=t(Utf8ErrorReason.OVERRUN,ie-1,n,c);continue}let de=se&(1<<8-ae-1)-1;for(let ve=0;ve<ae;ve++){let ge=n[ie];if((ge&192)!=128){ie+=t(Utf8ErrorReason.MISSING_CONTINUE,ie,n,c),de=null;break}de=de<<6|ge&63,ie++}if(de!==null){if(de>1114111){ie+=t(Utf8ErrorReason.OUT_OF_RANGE,ie-1-ae,n,c,de);continue}if(de>=55296&&de<=57343){ie+=t(Utf8ErrorReason.UTF16_SURROGATE,ie-1-ae,n,c,de);continue}if(de<=ue){ie+=t(Utf8ErrorReason.OVERLONG,ie-1-ae,n,c,de);continue}c.push(de)}}return c}function toUtf8Bytes(n,t=UnicodeNormalizationForm.current){t!=UnicodeNormalizationForm.current&&(logger$o.checkNormalize(),n=n.normalize(t));let c=[];for(let ie=0;ie<n.length;ie++){const se=n.charCodeAt(ie);if(se<128)c.push(se);else if(se<2048)c.push(se>>6|192),c.push(se&63|128);else if((se&64512)==55296){ie++;const ae=n.charCodeAt(ie);if(ie>=n.length||(ae&64512)!==56320)throw new Error("invalid utf-8 string");const ue=65536+((se&1023)<<10)+(ae&1023);c.push(ue>>18|240),c.push(ue>>12&63|128),c.push(ue>>6&63|128),c.push(ue&63|128)}else c.push(se>>12|224),c.push(se>>6&63|128),c.push(se&63|128)}return arrayify(c)}function escapeChar(n){const t="0000"+n.toString(16);return"\\u"+t.substring(t.length-4)}function _toEscapedUtf8String(n,t){return'"'+getUtf8CodePoints(n,t).map(c=>{if(c<256){switch(c){case 8:return"\\b";case 9:return"\\t";case 10:return"\\n";case 13:return"\\r";case 34:return'\\"';case 92:return"\\\\"}if(c>=32&&c<127)return String.fromCharCode(c)}return c<=65535?escapeChar(c):(c-=65536,escapeChar((c>>10&1023)+55296)+escapeChar((c&1023)+56320))}).join("")+'"'}function _toUtf8String(n){return n.map(t=>t<=65535?String.fromCharCode(t):(t-=65536,String.fromCharCode((t>>10&1023)+55296,(t&1023)+56320))).join("")}function toUtf8String(n,t){return _toUtf8String(getUtf8CodePoints(n,t))}function toUtf8CodePoints(n,t=UnicodeNormalizationForm.current){return getUtf8CodePoints(toUtf8Bytes(n,t))}function formatBytes32String(n){const t=toUtf8Bytes(n);if(t.length>31)throw new Error("bytes32 string must be less than 32 bytes");return hexlify(concat$1([t,HashZero]).slice(0,32))}function parseBytes32String(n){const t=arrayify(n);if(t.length!==32)throw new Error("invalid bytes32 - not 32 bytes long");if(t[31]!==0)throw new Error("invalid bytes32 string - no null terminator");let c=31;for(;t[c-1]===0;)c--;return toUtf8String(t.slice(0,c))}function bytes2(n){if(n.length%4!==0)throw new Error("bad data");let t=[];for(let c=0;c<n.length;c+=4)t.push(parseInt(n.substring(c,c+4),16));return t}function createTable(n,t){t||(t=function(se){return[parseInt(se,16)]});let c=0,ie={};return n.split(",").forEach(se=>{let ae=se.split(":");c+=parseInt(ae[0],16),ie[c]=t(ae[1])}),ie}function createRangeTable(n){let t=0;return n.split(",").map(c=>{let ie=c.split("-");ie.length===1?ie[1]="0":ie[1]===""&&(ie[1]="1");let se=t+parseInt(ie[0],16);return t=parseInt(ie[1],16),{l:se,h:t}})}function matchMap(n,t){let c=0;for(let ie=0;ie<t.length;ie++){let se=t[ie];if(c+=se.l,n>=c&&n<=c+se.h&&(n-c)%(se.d||1)===0){if(se.e&&se.e.indexOf(n-c)!==-1)continue;return se}}return null}const Table_A_1_ranges=createRangeTable("221,13-1b,5f-,40-10,51-f,11-3,3-3,2-2,2-4,8,2,15,2d,28-8,88,48,27-,3-5,11-20,27-,8,28,3-5,12,18,b-a,1c-4,6-16,2-d,2-2,2,1b-4,17-9,8f-,10,f,1f-2,1c-34,33-14e,4,36-,13-,6-2,1a-f,4,9-,3-,17,8,2-2,5-,2,8-,3-,4-8,2-3,3,6-,16-6,2-,7-3,3-,17,8,3,3,3-,2,6-3,3-,4-a,5,2-6,10-b,4,8,2,4,17,8,3,6-,b,4,4-,2-e,2-4,b-10,4,9-,3-,17,8,3-,5-,9-2,3-,4-7,3-3,3,4-3,c-10,3,7-2,4,5-2,3,2,3-2,3-2,4-2,9,4-3,6-2,4,5-8,2-e,d-d,4,9,4,18,b,6-3,8,4,5-6,3-8,3-3,b-11,3,9,4,18,b,6-3,8,4,5-6,3-6,2,3-3,b-11,3,9,4,18,11-3,7-,4,5-8,2-7,3-3,b-11,3,13-2,19,a,2-,8-2,2-3,7,2,9-11,4-b,3b-3,1e-24,3,2-,3,2-,2-5,5,8,4,2,2-,3,e,4-,6,2,7-,b-,3-21,49,23-5,1c-3,9,25,10-,2-2f,23,6,3,8-2,5-5,1b-45,27-9,2a-,2-3,5b-4,45-4,53-5,8,40,2,5-,8,2,5-,28,2,5-,20,2,5-,8,2,5-,8,8,18,20,2,5-,8,28,14-5,1d-22,56-b,277-8,1e-2,52-e,e,8-a,18-8,15-b,e,4,3-b,5e-2,b-15,10,b-5,59-7,2b-555,9d-3,5b-5,17-,7-,27-,7-,9,2,2,2,20-,36,10,f-,7,14-,4,a,54-3,2-6,6-5,9-,1c-10,13-1d,1c-14,3c-,10-6,32-b,240-30,28-18,c-14,a0,115-,3,66-,b-76,5,5-,1d,24,2,5-2,2,8-,35-2,19,f-10,1d-3,311-37f,1b,5a-b,d7-19,d-3,41,57-,68-4,29-3,5f,29-37,2e-2,25-c,2c-2,4e-3,30,78-3,64-,20,19b7-49,51a7-59,48e-2,38-738,2ba5-5b,222f-,3c-94,8-b,6-4,1b,6,2,3,3,6d-20,16e-f,41-,37-7,2e-2,11-f,5-b,18-,b,14,5-3,6,88-,2,bf-2,7-,7-,7-,4-2,8,8-9,8-2ff,20,5-b,1c-b4,27-,27-cbb1,f7-9,28-2,b5-221,56,48,3-,2-,3-,5,d,2,5,3,42,5-,9,8,1d,5,6,2-2,8,153-3,123-3,33-27fd,a6da-5128,21f-5df,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3,2-1d,61-ff7d"),Table_B_1_flags="ad,34f,1806,180b,180c,180d,200b,200c,200d,2060,feff".split(",").map(n=>parseInt(n,16)),Table_B_2_ranges=[{h:25,s:32,l:65},{h:30,s:32,e:[23],l:127},{h:54,s:1,e:[48],l:64,d:2},{h:14,s:1,l:57,d:2},{h:44,s:1,l:17,d:2},{h:10,s:1,e:[2,6,8],l:61,d:2},{h:16,s:1,l:68,d:2},{h:84,s:1,e:[18,24,66],l:19,d:2},{h:26,s:32,e:[17],l:435},{h:22,s:1,l:71,d:2},{h:15,s:80,l:40},{h:31,s:32,l:16},{h:32,s:1,l:80,d:2},{h:52,s:1,l:42,d:2},{h:12,s:1,l:55,d:2},{h:40,s:1,e:[38],l:15,d:2},{h:14,s:1,l:48,d:2},{h:37,s:48,l:49},{h:148,s:1,l:6351,d:2},{h:88,s:1,l:160,d:2},{h:15,s:16,l:704},{h:25,s:26,l:854},{h:25,s:32,l:55915},{h:37,s:40,l:1247},{h:25,s:-119711,l:53248},{h:25,s:-119763,l:52},{h:25,s:-119815,l:52},{h:25,s:-119867,e:[1,4,5,7,8,11,12,17],l:52},{h:25,s:-119919,l:52},{h:24,s:-119971,e:[2,7,8,17],l:52},{h:24,s:-120023,e:[2,7,13,15,16,17],l:52},{h:25,s:-120075,l:52},{h:25,s:-120127,l:52},{h:25,s:-120179,l:52},{h:25,s:-120231,l:52},{h:25,s:-120283,l:52},{h:25,s:-120335,l:52},{h:24,s:-119543,e:[17],l:56},{h:24,s:-119601,e:[17],l:58},{h:24,s:-119659,e:[17],l:58},{h:24,s:-119717,e:[17],l:58},{h:24,s:-119775,e:[17],l:58}],Table_B_2_lut_abs=createTable("b5:3bc,c3:ff,7:73,2:253,5:254,3:256,1:257,5:259,1:25b,3:260,1:263,2:269,1:268,5:26f,1:272,2:275,7:280,3:283,5:288,3:28a,1:28b,5:292,3f:195,1:1bf,29:19e,125:3b9,8b:3b2,1:3b8,1:3c5,3:3c6,1:3c0,1a:3ba,1:3c1,1:3c3,2:3b8,1:3b5,1bc9:3b9,1c:1f76,1:1f77,f:1f7a,1:1f7b,d:1f78,1:1f79,1:1f7c,1:1f7d,107:63,5:25b,4:68,1:68,1:68,3:69,1:69,1:6c,3:6e,4:70,1:71,1:72,1:72,1:72,7:7a,2:3c9,2:7a,2:6b,1:e5,1:62,1:63,3:65,1:66,2:6d,b:3b3,1:3c0,6:64,1b574:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3"),Table_B_2_lut_rel=createTable("179:1,2:1,2:1,5:1,2:1,a:4f,a:1,8:1,2:1,2:1,3:1,5:1,3:1,4:1,2:1,3:1,4:1,8:2,1:1,2:2,1:1,2:2,27:2,195:26,2:25,1:25,1:25,2:40,2:3f,1:3f,33:1,11:-6,1:-9,1ac7:-3a,6d:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,b:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,c:-8,2:-8,2:-8,2:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,49:-8,1:-8,1:-4a,1:-4a,d:-56,1:-56,1:-56,1:-56,d:-8,1:-8,f:-8,1:-8,3:-7"),Table_B_2_complex=createTable("df:00730073,51:00690307,19:02BC006E,a7:006A030C,18a:002003B9,16:03B903080301,20:03C503080301,1d7:05650582,190f:00680331,1:00740308,1:0077030A,1:0079030A,1:006102BE,b6:03C50313,2:03C503130300,2:03C503130301,2:03C503130342,2a:1F0003B9,1:1F0103B9,1:1F0203B9,1:1F0303B9,1:1F0403B9,1:1F0503B9,1:1F0603B9,1:1F0703B9,1:1F0003B9,1:1F0103B9,1:1F0203B9,1:1F0303B9,1:1F0403B9,1:1F0503B9,1:1F0603B9,1:1F0703B9,1:1F2003B9,1:1F2103B9,1:1F2203B9,1:1F2303B9,1:1F2403B9,1:1F2503B9,1:1F2603B9,1:1F2703B9,1:1F2003B9,1:1F2103B9,1:1F2203B9,1:1F2303B9,1:1F2403B9,1:1F2503B9,1:1F2603B9,1:1F2703B9,1:1F6003B9,1:1F6103B9,1:1F6203B9,1:1F6303B9,1:1F6403B9,1:1F6503B9,1:1F6603B9,1:1F6703B9,1:1F6003B9,1:1F6103B9,1:1F6203B9,1:1F6303B9,1:1F6403B9,1:1F6503B9,1:1F6603B9,1:1F6703B9,3:1F7003B9,1:03B103B9,1:03AC03B9,2:03B10342,1:03B1034203B9,5:03B103B9,6:1F7403B9,1:03B703B9,1:03AE03B9,2:03B70342,1:03B7034203B9,5:03B703B9,6:03B903080300,1:03B903080301,3:03B90342,1:03B903080342,b:03C503080300,1:03C503080301,1:03C10313,2:03C50342,1:03C503080342,b:1F7C03B9,1:03C903B9,1:03CE03B9,2:03C90342,1:03C9034203B9,5:03C903B9,ac:00720073,5b:00B00063,6:00B00066,d:006E006F,a:0073006D,1:00740065006C,1:0074006D,124f:006800700061,2:00610075,2:006F0076,b:00700061,1:006E0061,1:03BC0061,1:006D0061,1:006B0061,1:006B0062,1:006D0062,1:00670062,3:00700066,1:006E0066,1:03BC0066,4:0068007A,1:006B0068007A,1:006D0068007A,1:00670068007A,1:00740068007A,15:00700061,1:006B00700061,1:006D00700061,1:006700700061,8:00700076,1:006E0076,1:03BC0076,1:006D0076,1:006B0076,1:006D0076,1:00700077,1:006E0077,1:03BC0077,1:006D0077,1:006B0077,1:006D0077,1:006B03C9,1:006D03C9,2:00620071,3:00632215006B0067,1:0063006F002E,1:00640062,1:00670079,2:00680070,2:006B006B,1:006B006D,9:00700068,2:00700070006D,1:00700072,2:00730076,1:00770062,c723:00660066,1:00660069,1:0066006C,1:006600660069,1:00660066006C,1:00730074,1:00730074,d:05740576,1:05740565,1:0574056B,1:057E0576,1:0574056D",bytes2),Table_C_ranges=createRangeTable("80-20,2a0-,39c,32,f71,18e,7f2-f,19-7,30-4,7-5,f81-b,5,a800-20ff,4d1-1f,110,fa-6,d174-7,2e84-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,2,1f-5f,ff7f-20001");function flatten$2(n){return n.reduce((t,c)=>(c.forEach(ie=>{t.push(ie)}),t),[])}function _nameprepTableA1(n){return!!matchMap(n,Table_A_1_ranges)}function _nameprepTableB2(n){let t=matchMap(n,Table_B_2_ranges);if(t)return[n+t.s];let c=Table_B_2_lut_abs[n];if(c)return c;let ie=Table_B_2_lut_rel[n];return ie?[n+ie[0]]:Table_B_2_complex[n]||null}function _nameprepTableC(n){return!!matchMap(n,Table_C_ranges)}function nameprep(n){if(n.match(/^[a-z0-9-]*$/i)&&n.length<=59)return n.toLowerCase();let t=toUtf8CodePoints(n);t=flatten$2(t.map(ie=>Table_B_1_flags.indexOf(ie)>=0?[]:ie>=65024&&ie<=65039?[]:_nameprepTableB2(ie)||[ie])),t=toUtf8CodePoints(_toUtf8String(t),UnicodeNormalizationForm.NFKC),t.forEach(ie=>{if(_nameprepTableC(ie))throw new Error("STRINGPREP_CONTAINS_PROHIBITED")}),t.forEach(ie=>{if(_nameprepTableA1(ie))throw new Error("STRINGPREP_CONTAINS_UNASSIGNED")});let c=_toUtf8String(t);if(c.substring(0,1)==="-"||c.substring(2,4)==="--"||c.substring(c.length-1)==="-")throw new Error("invalid hyphen");return c}const lib_esm$e=Object.freeze(Object.defineProperty({__proto__:null,get UnicodeNormalizationForm(){return UnicodeNormalizationForm},Utf8ErrorFuncs,get Utf8ErrorReason(){return Utf8ErrorReason},_toEscapedUtf8String,formatBytes32String,nameprep,parseBytes32String,toUtf8Bytes,toUtf8CodePoints,toUtf8String},Symbol.toStringTag,{value:"Module"}));class StringCoder extends DynamicBytesCoder{constructor(t){super("string",t)}defaultValue(){return""}encode(t,c){return super.encode(t,toUtf8Bytes(c))}decode(t){return toUtf8String(super.decode(t))}}class TupleCoder extends Coder{constructor(t,c){let ie=!1;const se=[];t.forEach(ue=>{ue.dynamic&&(ie=!0),se.push(ue.type)});const ae="tuple("+se.join(",")+")";super("tuple",ae,c,ie),this.coders=t}defaultValue(){const t=[];this.coders.forEach(ie=>{t.push(ie.defaultValue())});const c=this.coders.reduce((ie,se)=>{const ae=se.localName;return ae&&(ie[ae]||(ie[ae]=0),ie[ae]++),ie},{});return this.coders.forEach((ie,se)=>{let ae=ie.localName;!ae||c[ae]!==1||(ae==="length"&&(ae="_length"),t[ae]==null&&(t[ae]=t[se]))}),Object.freeze(t)}encode(t,c){return pack$1(t,this.coders,c)}decode(t){return t.coerce(this.name,unpack(t,this.coders))}}const logger$n=new Logger(version$q),paramTypeBytes=new RegExp(/^bytes([0-9]*)$/),paramTypeNumber=new RegExp(/^(u?int)([0-9]*)$/);class AbiCoder{constructor(t){defineReadOnly(this,"coerceFunc",t||null)}_getCoder(t){switch(t.baseType){case"address":return new AddressCoder(t.name);case"bool":return new BooleanCoder(t.name);case"string":return new StringCoder(t.name);case"bytes":return new BytesCoder(t.name);case"array":return new ArrayCoder(this._getCoder(t.arrayChildren),t.arrayLength,t.name);case"tuple":return new TupleCoder((t.components||[]).map(ie=>this._getCoder(ie)),t.name);case"":return new NullCoder(t.name)}let c=t.type.match(paramTypeNumber);if(c){let ie=parseInt(c[2]||"256");return(ie===0||ie>256||ie%8!==0)&&logger$n.throwArgumentError("invalid "+c[1]+" bit length","param",t),new NumberCoder(ie/8,c[1]==="int",t.name)}if(c=t.type.match(paramTypeBytes),c){let ie=parseInt(c[1]);return(ie===0||ie>32)&&logger$n.throwArgumentError("invalid bytes length","param",t),new FixedBytesCoder(ie,t.name)}return logger$n.throwArgumentError("invalid type","type",t.type)}_getWordSize(){return 32}_getReader(t,c){return new Reader(t,this._getWordSize(),this.coerceFunc,c)}_getWriter(){return new Writer(this._getWordSize())}getDefaultValue(t){const c=t.map(ie=>this._getCoder(ParamType.from(ie)));return new TupleCoder(c,"_").defaultValue()}encode(t,c){t.length!==c.length&&logger$n.throwError("types/values length mismatch",Logger.errors.INVALID_ARGUMENT,{count:{types:t.length,values:c.length},value:{types:t,values:c}});const ie=t.map(ue=>this._getCoder(ParamType.from(ue))),se=new TupleCoder(ie,"_"),ae=this._getWriter();return se.encode(ae,c),ae.data}decode(t,c,ie){const se=t.map(ae=>this._getCoder(ParamType.from(ae)));return new TupleCoder(se,"_").decode(this._getReader(arrayify(c),ie))}}const defaultAbiCoder=new AbiCoder;function id(n){return keccak256$1(toUtf8Bytes(n))}const version$m="hash/5.8.0";function decode$6(n){n=atob(n);const t=[];for(let c=0;c<n.length;c++)t.push(n.charCodeAt(c));return arrayify(t)}function encode$5(n){n=arrayify(n);let t="";for(let c=0;c<n.length;c++)t+=String.fromCharCode(n[c]);return btoa(t)}const lib_esm$d=Object.freeze(Object.defineProperty({__proto__:null,decode:decode$6,encode:encode$5},Symbol.toStringTag,{value:"Module"}));function flat(n,t){t==null&&(t=1);const c=[],ie=c.forEach,se=function(ae,ue){ie.call(ae,function(de){ue>0&&Array.isArray(de)?se(de,ue-1):c.push(de)})};return se(n,t),c}function fromEntries(n){const t={};for(let c=0;c<n.length;c++){const ie=n[c];t[ie[0]]=ie[1]}return t}function decode_arithmetic(n){let t=0;function c(){return n[t++]<<8|n[t++]}let ie=c(),se=1,ae=[0,1];for(let Zt=1;Zt<ie;Zt++)ae.push(se+=c());let ue=c(),de=t;t+=ue;let ve=0,ge=0;function we(){return ve==0&&(ge=ge<<8|n[t++],ve=8),ge>>--ve&1}const Te=31,Ne=Math.pow(2,Te),qe=Ne>>>1,ze=qe>>1,He=Ne-1;let Ge=0;for(let Zt=0;Zt<Te;Zt++)Ge=Ge<<1|we();let Ze=[],Ye=0,Ft=Ne;for(;;){let Zt=Math.floor(((Ge-Ye+1)*se-1)/Ft),cn=0,hn=ie;for(;hn-cn>1;){let Sn=cn+hn>>>1;Zt<ae[Sn]?hn=Sn:cn=Sn}if(cn==0)break;Ze.push(cn);let yn=Ye+Math.floor(Ft*ae[cn]/se),Ht=Ye+Math.floor(Ft*ae[cn+1]/se)-1;for(;!((yn^Ht)&qe);)Ge=Ge<<1&He|we(),yn=yn<<1&He,Ht=Ht<<1&He|1;for(;yn&~Ht&ze;)Ge=Ge&qe|Ge<<1&He>>>1|we(),yn=yn<<1^qe,Ht=(Ht^qe)<<1|qe|1;Ye=yn,Ft=1+Ht-yn}let Mt=ie-4;return Ze.map(Zt=>{switch(Zt-Mt){case 3:return Mt+65792+(n[de++]<<16|n[de++]<<8|n[de++]);case 2:return Mt+256+(n[de++]<<8|n[de++]);case 1:return Mt+n[de++];default:return Zt-1}})}function read_payload(n){let t=0;return()=>n[t++]}function read_compressed_payload(n){return read_payload(decode_arithmetic(n))}function signed(n){return n&1?~n>>1:n>>1}function read_counts(n,t){let c=Array(n);for(let ie=0;ie<n;ie++)c[ie]=1+t();return c}function read_ascending(n,t){let c=Array(n);for(let ie=0,se=-1;ie<n;ie++)c[ie]=se+=1+t();return c}function read_deltas(n,t){let c=Array(n);for(let ie=0,se=0;ie<n;ie++)c[ie]=se+=signed(t());return c}function read_member_array(n,t){let c=read_ascending(n(),n),ie=n(),se=read_ascending(ie,n),ae=read_counts(ie,n);for(let ue=0;ue<ie;ue++)for(let de=0;de<ae[ue];de++)c.push(se[ue]+de);return t?c.map(ue=>t[ue]):c}function read_mapped_map(n){let t=[];for(;;){let c=n();if(c==0)break;t.push(read_linear_table(c,n))}for(;;){let c=n()-1;if(c<0)break;t.push(read_replacement_table(c,n))}return fromEntries(flat(t))}function read_zero_terminated_array(n){let t=[];for(;;){let c=n();if(c==0)break;t.push(c)}return t}function read_transposed(n,t,c){let ie=Array(n).fill(void 0).map(()=>[]);for(let se=0;se<t;se++)read_deltas(n,c).forEach((ae,ue)=>ie[ue].push(ae));return ie}function read_linear_table(n,t){let c=1+t(),ie=t(),se=read_zero_terminated_array(t),ae=read_transposed(se.length,1+n,t);return flat(ae.map((ue,de)=>{const ve=ue[0],ge=ue.slice(1);return Array(se[de]).fill(void 0).map((we,Te)=>{let Ne=Te*ie;return[ve+Te*c,ge.map(qe=>qe+Ne)]})}))}function read_replacement_table(n,t){let c=1+t();return read_transposed(c,1+n,t).map(ie=>[ie[0],ie.slice(1)])}function read_emoji_trie(n){let t=read_member_array(n).sort((ie,se)=>ie-se);return c();function c(){let ie=[];for(;;){let ge=read_member_array(n,t);if(ge.length==0)break;ie.push({set:new Set(ge),node:c()})}ie.sort((ge,we)=>we.set.size-ge.set.size);let se=n(),ae=se%3;se=se/3|0;let ue=!!(se&1);se>>=1;let de=se==1,ve=se==2;return{branches:ie,valid:ae,fe0f:ue,save:de,check:ve}}}function getData(){return read_compressed_payload(decode$6("AEQF2AO2DEsA2wIrAGsBRABxAN8AZwCcAEwAqgA0AGwAUgByADcATAAVAFYAIQAyACEAKAAYAFgAGwAjABQAMAAmADIAFAAfABQAKwATACoADgAbAA8AHQAYABoAGQAxADgALAAoADwAEwA9ABMAGgARAA4ADwAWABMAFgAIAA8AHgQXBYMA5BHJAS8JtAYoAe4AExozi0UAH21tAaMnBT8CrnIyhrMDhRgDygIBUAEHcoFHUPe8AXBjAewCjgDQR8IICIcEcQLwATXCDgzvHwBmBoHNAqsBdBcUAykgDhAMShskMgo8AY8jqAQfAUAfHw8BDw87MioGlCIPBwZCa4ELatMAAMspJVgsDl8AIhckSg8XAHdvTwBcIQEiDT4OPhUqbyECAEoAS34Aej8Ybx83JgT/Xw8gHxZ/7w8RICxPHA9vBw+Pfw8PHwAPFv+fAsAvCc8vEr8ivwD/EQ8Bol8OEBa/A78hrwAPCU8vESNvvwWfHwNfAVoDHr+ZAAED34YaAdJPAK7PLwSEgDLHAGo1Pz8Pvx9fUwMrpb8O/58VTzAPIBoXIyQJNF8hpwIVAT8YGAUADDNBaX3RAMomJCg9EhUeA29MABsZBTMNJipjOhc19gcIDR8bBwQHEggCWi6DIgLuAQYA+BAFCha3A5XiAEsqM7UFFgFLhAMjFTMYE1Klnw74nRVBG/ASCm0BYRN/BrsU3VoWy+S0vV8LQx+vN8gF2AC2AK5EAWwApgYDKmAAroQ0NDQ0AT+OCg7wAAIHRAbpNgVcBV0APTA5BfbPFgMLzcYL/QqqA82eBALKCjQCjqYCht0/k2+OAsXQAoP3ASTKDgDw6ACKAUYCMpIKJpRaAE4A5womABzZvs0REEKiACIQAd5QdAECAj4Ywg/wGqY2AVgAYADYvAoCGAEubA0gvAY2ALAAbpbvqpyEAGAEpgQAJgAG7gAgAEACmghUFwCqAMpAINQIwC4DthRAAPcycKgApoIdABwBfCisABoATwBqASIAvhnSBP8aH/ECeAKXAq40NjgDBTwFYQU6AXs3oABgAD4XNgmcCY1eCl5tIFZeUqGgyoNHABgAEQAaABNwWQAmABMATPMa3T34ADldyprmM1M2XociUQgLzvwAXT3xABgAEQAaABNwIGFAnADD8AAgAD4BBJWzaCcIAIEBFMAWwKoAAdq9BWAF5wLQpALEtQAKUSGkahR4GnJM+gsAwCgeFAiUAECQ0BQuL8AAIAAAADKeIheclvFqQAAETr4iAMxIARMgAMIoHhQIAn0E0pDQFC4HhznoAAAAIAI2C0/4lvFqQAAETgBJJwYCAy4ABgYAFAA8MBKYEH4eRhTkAjYeFcgACAYAeABsOqyQ5gRwDayqugEgaIIAtgoACgDmEABmBAWGme5OBJJA2m4cDeoAmITWAXwrMgOgAGwBCh6CBXYF1Tzg1wKAAFdiuABRAFwAXQBsAG8AdgBrAHYAbwCEAHEwfxQBVE5TEQADVFhTBwBDANILAqcCzgLTApQCrQL6vAAMAL8APLhNBKkE6glGKTAU4Dr4N2EYEwBCkABKk8rHAbYBmwIoAiU4Ajf/Aq4CowCAANIChzgaNBsCsTgeODcFXrgClQKdAqQBiQGYAqsCsjTsNHsfNPA0ixsAWTWiOAMFPDQSNCk2BDZHNow2TTZUNhk28Jk9VzI3QkEoAoICoQKwAqcAQAAxBV4FXbS9BW47YkIXP1ciUqs05DS/FwABUwJW11e6nHuYZmSh/RAYA8oMKvZ8KASoUAJYWAJ6ILAsAZSoqjpgA0ocBIhmDgDWAAawRDQoAAcuAj5iAHABZiR2AIgiHgCaAU68ACxuHAG0ygM8MiZIAlgBdF4GagJqAPZOHAMuBgoATkYAsABiAHgAMLoGDPj0HpKEBAAOJgAuALggTAHWAeAMEDbd20Uege0ADwAWADkAQgA9OHd+2MUQZBBhBgNNDkxxPxUQArEPqwvqERoM1irQ090ANK4H8ANYB/ADWANYB/AH8ANYB/ADWANYA1gDWBwP8B/YxRBkD00EcgWTBZAE2wiIJk4RhgctCNdUEnQjHEwDSgEBIypJITuYMxAlR0wRTQgIATZHbKx9PQNMMbBU+pCnA9AyVDlxBgMedhKlAC8PeCE1uk6DekxxpQpQT7NX9wBFBgASqwAS5gBJDSgAUCwGPQBI4zTYABNGAE2bAE3KAExdGABKaAbgAFBXAFCOAFBJABI2SWdObALDOq0//QomCZhvwHdTBkIQHCemEPgMNAG2ATwN7kvZBPIGPATKH34ZGg/OlZ0Ipi3eDO4m5C6igFsj9iqEBe5L9TzeC05RaQ9aC2YJ5DpkgU8DIgEOIowK3g06CG4Q9ArKbA3mEUYHOgPWSZsApgcCCxIdNhW2JhFirQsKOXgG/Br3C5AmsBMqev0F1BoiBk4BKhsAANAu6IWxWjJcHU9gBgQLJiPIFKlQIQ0mQLh4SRocBxYlqgKSQ3FKiFE3HpQh9zw+DWcuFFF9B/Y8BhlQC4I8n0asRQ8R0z6OPUkiSkwtBDaALDAnjAnQD4YMunxzAVoJIgmyDHITMhEYN8YIOgcaLpclJxYIIkaWYJsE+KAD9BPSAwwFQAlCBxQDthwuEy8VKgUOgSXYAvQ21i60ApBWgQEYBcwPJh/gEFFH4Q7qCJwCZgOEJewALhUiABginAhEZABgj9lTBi7MCMhqbSN1A2gU6GIRdAeSDlgHqBw0FcAc4nDJXgyGCSiksAlcAXYJmgFgBOQICjVcjKEgQmdUi1kYnCBiQUBd/QIyDGYVoES+h3kCjA9sEhwBNgF0BzoNAgJ4Ee4RbBCWCOyGBTW2M/k6JgRQIYQgEgooA1BszwsoJvoM+WoBpBJjAw00PnfvZ6xgtyUX/gcaMsZBYSHyC5NPzgydGsIYQ1QvGeUHwAP0GvQn60FYBgADpAQUOk4z7wS+C2oIjAlAAEoOpBgH2BhrCnKM0QEyjAG4mgNYkoQCcJAGOAcMAGgMiAV65gAeAqgIpAAGANADWAA6Aq4HngAaAIZCAT4DKDABIuYCkAOUCDLMAZYwAfQqBBzEDBYA+DhuSwLDsgKAa2ajBd5ZAo8CSjYBTiYEBk9IUgOwcuIA3ABMBhTgSAEWrEvMG+REAeBwLADIAPwABjYHBkIBzgH0bgC4AWALMgmjtLYBTuoqAIQAFmwB2AKKAN4ANgCA8gFUAE4FWvoF1AJQSgESMhksWGIBvAMgATQBDgB6BsyOpsoIIARuB9QCEBwV4gLvLwe2AgMi4BPOQsYCvd9WADIXUu5eZwqoCqdeaAC0YTQHMnM9UQAPH6k+yAdy/BZIiQImSwBQ5gBQQzSaNTFWSTYBpwGqKQK38AFtqwBI/wK37gK3rQK3sAK6280C0gK33AK3zxAAUEIAUD9SklKDArekArw5AEQAzAHCO147WTteO1k7XjtZO147WTteO1kDmChYI03AVU0oJqkKbV9GYewMpw3VRMk6ShPcYFJgMxPJLbgUwhXPJVcZPhq9JwYl5VUKDwUt1GYxCC00dhe9AEApaYNCY4ceMQpMHOhTklT5LRwAskujM7ANrRsWREEFSHXuYisWDwojAmSCAmJDXE6wXDchAqH4AmiZAmYKAp+FOBwMAmY8AmYnBG8EgAN/FAN+kzkHOXgYOYM6JCQCbB4CMjc4CwJtyAJtr/CLADRoRiwBaADfAOIASwYHmQyOAP8MwwAOtgJ3MAJ2o0ACeUxEAni7Hl3cRa9G9AJ8QAJ6yQJ9CgJ88UgBSH5kJQAsFklZSlwWGErNAtECAtDNSygDiFADh+dExpEzAvKiXQQDA69Lz0wuJgTQTU1NsAKLQAKK2cIcCB5EaAa4Ao44Ao5dQZiCAo7aAo5deVG1UzYLUtVUhgKT/AKTDQDqAB1VH1WwVdEHLBwplocy4nhnRTw6ApegAu+zWCKpAFomApaQApZ9nQCqWa1aCoJOADwClrYClk9cRVzSApnMApllXMtdCBoCnJw5wzqeApwXAp+cAp65iwAeEDIrEAKd8gKekwC2PmE1YfACntQCoG8BqgKeoCACnk+mY8lkKCYsAiewAiZ/AqD8AqBN2AKmMAKlzwKoAAB+AqfzaH1osgAESmodatICrOQCrK8CrWgCrQMCVx4CVd0CseLYAx9PbJgCsr4OArLpGGzhbWRtSWADJc4Ctl08QG6RAylGArhfArlIFgK5K3hwN3DiAr0aAy2zAzISAr6JcgMDM3ICvhtzI3NQAsPMAsMFc4N0TDZGdOEDPKgDPJsDPcACxX0CxkgCxhGKAshqUgLIRQLJUALJLwJkngLd03h6YniveSZL0QMYpGcDAmH1GfSVJXsMXpNevBICz2wCz20wTFTT9BSgAMeuAs90ASrrA04TfkwGAtwoAtuLAtJQA1JdA1NgAQIDVY2AikABzBfuYUZ2AILPg44C2sgC2d+EEYRKpz0DhqYAMANkD4ZyWvoAVgLfZgLeuXR4AuIw7RUB8zEoAfScAfLTiALr9ALpcXoAAur6AurlAPpIAboC7ooC652Wq5cEAu5AA4XhmHpw4XGiAvMEAGoDjheZlAL3FAORbwOSiAL3mQL52gL4Z5odmqy8OJsfA52EAv77ARwAOp8dn7QDBY4DpmsDptoA0sYDBmuhiaIGCgMMSgFgASACtgNGAJwEgLpoBgC8BGzAEowcggCEDC6kdjoAJAM0C5IKRoABZCgiAIzw3AYBLACkfng9ogigkgNmWAN6AEQCvrkEVqTGAwCsBRbAA+4iQkMCHR072jI2PTbUNsk2RjY5NvA23TZKNiU3EDcZN5I+RTxDRTBCJkK5VBYKFhZfwQCWygU3AJBRHpu+OytgNxa61A40GMsYjsn7BVwFXQVcBV0FaAVdBVwFXQVcBV0FXAVdBVwFXUsaCNyKAK4AAQUHBwKU7oICoW1e7jAEzgPxA+YDwgCkBFDAwADABKzAAOxFLhitA1UFTDeyPkM+bj51QkRCuwTQWWQ8X+0AWBYzsACNA8xwzAGm7EZ/QisoCTAbLDs6fnLfb8H2GccsbgFw13M1HAVkBW/Jxsm9CNRO8E8FDD0FBQw9FkcClOYCoMFegpDfADgcMiA2AJQACB8AsigKAIzIEAJKeBIApY5yPZQIAKQiHb4fvj5BKSRPQrZCOz0oXyxgOywfKAnGbgMClQaCAkILXgdeCD9IIGUgQj5fPoY+dT52Ao5CM0dAX9BTVG9SDzFwWTQAbxBzJF/lOEIQQglCCkKJIAls5AcClQICoKPMODEFxhi6KSAbiyfIRrMjtCgdWCAkPlFBIitCsEJRzAbMAV/OEyQzDg0OAQQEJ36i328/Mk9AybDJsQlq3tDRApUKAkFzXf1d/j9uALYP6hCoFgCTGD8kPsFKQiobrm0+zj0KSD8kPnVCRBwMDyJRTHFgMTJa5rwXQiQ2YfI/JD7BMEJEHGINTw4TOFlIRzwJO0icMQpyPyQ+wzJCRBv6DVgnKB01NgUKj2bwYzMqCoBkznBgEF+zYDIocwRIX+NgHj4HICNfh2C4CwdwFWpTG/lgUhYGAwRfv2Ts8mAaXzVgml/XYIJfuWC4HI1gUF9pYJZgMR6ilQHMAOwLAlDRefC0in4AXAEJA6PjCwc0IamOANMMCAECRQDFNRTZBgd+CwQlRA+r6+gLBDEFBnwUBXgKATIArwAGRAAHA3cDdAN2A3kDdwN9A3oDdQN7A30DfAN4A3oDfQAYEAAlAtYASwMAUAFsAHcKAHcAmgB3AHUAdQB2AHVu8UgAygDAAHcAdQB1AHYAdQALCgB3AAsAmgB3AAsCOwB3AAtu8UgAygDAAHgKAJoAdwB3AHUAdQB2AHUAeAB1AHUAdgB1bvFIAMoAwAALCgCaAHcACwB3AAsCOwB3AAtu8UgAygDAAH4ACwGgALcBpwC6AahdAu0COwLtbvFIAMoAwAALCgCaAu0ACwLtAAsCOwLtAAtu8UgAygDAA24ACwNvAAu0VsQAAzsAABCkjUIpAAsAUIusOggWcgMeBxVsGwL67U/2HlzmWOEeOgALASvuAAseAfpKUpnpGgYJDCIZM6YyARUE9ThqAD5iXQgnAJYJPnOzw0ZAEZxEKsIAkA4DhAHnTAIDxxUDK0lxCQlPYgIvIQVYJQBVqE1GakUAKGYiDToSBA1EtAYAXQJYAIF8GgMHRyAAIAjOe9YncekRAA0KACUrjwE7Ayc6AAYWAqaiKG4McEcqANoN3+Mg9TwCBhIkuCny+JwUQ29L008JluRxu3K+oAdqiHOqFH0AG5SUIfUJ5SxCGfxdipRzqTmT4V5Zb+r1Uo4Vm+NqSSEl2mNvR2JhIa8SpYO6ntdwFXHCWTCK8f2+Hxo7uiG3drDycAuKIMP5bhi06ACnqArH1rz4Rqg//lm6SgJGEVbF9xJHISaR6HxqxSnkw6shDnelHKNEfGUXSJRJ1GcsmtJw25xrZMDK9gXSm1/YMkdX4/6NKYOdtk/NQ3/NnDASjTc3fPjIjW/5sVfVObX2oTDWkr1dF9f3kxBsD3/3aQO8hPfRz+e0uEiJqt1161griu7gz8hDDwtpy+F+BWtefnKHZPAxcZoWbnznhJpy0e842j36bcNzGnIEusgGX0a8ZxsnjcSsPDZ09yZ36fCQbriHeQ72JRMILNl6ePPf2HWoVwgWAm1fb3V2sAY0+B6rAXqSwPBgseVmoqsBTSrm91+XasMYYySI8eeRxH3ZvHkMz3BQ5aJ3iUVbYPNM3/7emRtjlsMgv/9VyTsyt/mK+8fgWeT6SoFaclXqn42dAIsvAarF5vNNWHzKSkKQ/8Hfk5ZWK7r9yliOsooyBjRhfkHP4Q2DkWXQi6FG/9r/IwbmkV5T7JSopHKn1pJwm9tb5Ot0oyN1Z2mPpKXHTxx2nlK08fKk1hEYA8WgVVWL5lgx0iTv+KdojJeU23ZDjmiubXOxVXJKKi2Wjuh2HLZOFLiSC7Tls5SMh4f+Pj6xUSrNjFqLGehRNB8lC0QSLNmkJJx/wSG3MnjE9T1CkPwJI0wH2lfzwETIiVqUxg0dfu5q39Gt+hwdcxkhhNvQ4TyrBceof3Mhs/IxFci1HmHr4FMZgXEEczPiGCx0HRwzAqDq2j9AVm1kwN0mRVLWLylgtoPNapF5cY4Y1wJh/e0BBwZj44YgZrDNqvD/9Hv7GFYdUQeDJuQ3EWI4HaKqavU1XjC/n41kT4L79kqGq0kLhdTZvgP3TA3fS0ozVz+5piZsoOtIvBUFoMKbNcmBL6YxxaUAusHB38XrS8dQMnQwJfUUkpRoGr5AUeWicvBTzyK9g77+yCkf5PAysL7r/JjcZgrbvRpMW9iyaxZvKO6ceZN2EwIxKwVFPuvFuiEPGCoagbMo+SpydLrXqBzNCDGFCrO/rkcwa2xhokQZ5CdZ0AsU3JfSqJ6n5I14YA+P/uAgfhPU84Tlw7cEFfp7AEE8ey4sP12PTt4Cods1GRgDOB5xvyiR5m+Bx8O5nBCNctU8BevfV5A08x6RHd5jcwPTMDSZJOedIZ1cGQ704lxbAzqZOP05ZxaOghzSdvFBHYqomATARyAADK4elP8Ly3IrUZKfWh23Xy20uBUmLS4Pfagu9+oyVa2iPgqRP3F2CTUsvJ7+RYnN8fFZbU/HVvxvcFFDKkiTqV5UBZ3Gz54JAKByi9hkKMZJvuGgcSYXFmw08UyoQyVdfTD1/dMkCHXcTGAKeROgArsvmRrQTLUOXioOHGK2QkjHuoYFgXciZoTJd6Fs5q1QX1G+p/e26hYsEf7QZD1nnIyl/SFkNtYYmmBhpBrxl9WbY0YpHWRuw2Ll/tj9mD8P4snVzJl4F9J+1arVeTb9E5r2ILH04qStjxQNwn3m4YNqxmaNbLAqW2TN6LidwuJRqS+NXbtqxoeDXpxeGWmxzSkWxjkyCkX4NQRme6q5SAcC+M7+9ETfA/EwrzQajKakCwYyeunP6ZFlxU2oMEn1Pz31zeStW74G406ZJFCl1wAXIoUKkWotYEpOuXB1uVNxJ63dpJEqfxBeptwIHNrPz8BllZoIcBoXwgfJ+8VAUnVPvRvexnw0Ma/WiGYuJO5y8QTvEYBigFmhUxY5RqzE8OcywN/8m4UYrlaniJO75XQ6KSo9+tWHlu+hMi0UVdiKQp7NelnoZUzNaIyBPVeOwK6GNp+FfHuPOoyhaWuNvTYFkvxscMQWDh+zeFCFkgwbXftiV23ywJ4+uwRqmg9k3KzwIQpzppt8DBBOMbrqwQM5Gb05sEwdKzMiAqOloaA/lr0KA+1pr0/+HiWoiIjHA/wir2nIuS3PeU/ji3O6ZwoxcR1SZ9FhtLC5S0FIzFhbBWcGVP/KpxOPSiUoAdWUpqKH++6Scz507iCcxYI6rdMBICPJZea7OcmeFw5mObJSiqpjg2UoWNIs+cFhyDSt6geV5qgi3FunmwwDoGSMgerFOZGX1m0dMCYo5XOruxO063dwENK9DbnVM9wYFREzh4vyU1WYYJ/LRRp6oxgjqP/X5a8/4Af6p6NWkQferzBmXme0zY/4nwMJm/wd1tIqSwGz+E3xPEAOoZlJit3XddD7/BT1pllzOx+8bmQtANQ/S6fZexc6qi3W+Q2xcmXTUhuS5mpHQRvcxZUN0S5+PL9lXWUAaRZhEH8hTdAcuNMMCuVNKTEGtSUKNi3O6KhSaTzck8csZ2vWRZ+d7mW8c4IKwXIYd25S/zIftPkwPzufjEvOHWVD1m+FjpDVUTV0DGDuHj6QnaEwLu/dEgdLQOg9E1Sro9XHJ8ykLAwtPu+pxqKDuFexqON1sKQm7rwbE1E68UCfA/erovrTCG+DBSNg0l4goDQvZN6uNlbyLpcZAwj2UclycvLpIZMgv4yRlpb3YuMftozorbcGVHt/VeDV3+Fdf1TP0iuaCsPi2G4XeGhsyF1ubVDxkoJhmniQ0/jSg/eYML9KLfnCFgISWkp91eauR3IQvED0nAPXK+6hPCYs+n3+hCZbiskmVMG2da+0EsZPonUeIY8EbfusQXjsK/eFDaosbPjEfQS0RKG7yj5GG69M7MeO1HmiUYocgygJHL6M1qzUDDwUSmr99V7Sdr2F3JjQAJY+F0yH33Iv3+C9M38eML7gTgmNu/r2bUMiPvpYbZ6v1/IaESirBHNa7mPKn4dEmYg7v/+HQgPN1G79jBQ1+soydfDC2r+h2Bl/KIc5KjMK7OH6nb1jLsNf0EHVe2KBiE51ox636uyG6Lho0t3J34L5QY/ilE3mikaF4HKXG1mG1rCevT1Vv6GavltxoQe/bMrpZvRggnBxSEPEeEzkEdOxTnPXHVjUYdw8JYvjB/o7Eegc3Ma+NUxLLnsK0kJlinPmUHzHGtrk5+CAbVzFOBqpyy3QVUnzTDfC/0XD94/okH+OB+i7g9lolhWIjSnfIb+Eq43ZXOWmwvjyV/qqD+t0e+7mTEM74qP/Ozt8nmC7mRpyu63OB4KnUzFc074SqoyPUAgM+/TJGFo6T44EHnQU4X4z6qannVqgw/U7zCpwcmXV1AubIrvOmkKHazJAR55ePjp5tLBsN8vAqs3NAHdcEHOR2xQ0lsNAFzSUuxFQCFYvXLZJdOj9p4fNq6p0HBGUik2YzaI4xySy91KzhQ0+q1hjxvImRwPRf76tChlRkhRCi74NXZ9qUNeIwP+s5p+3m5nwPdNOHgSLD79n7O9m1n1uDHiMntq4nkYwV5OZ1ENbXxFd4PgrlvavZsyUO4MqYlqqn1O8W/I1dEZq5dXhrbETLaZIbC2Kj/Aa/QM+fqUOHdf0tXAQ1huZ3cmWECWSXy/43j35+Mvq9xws7JKseriZ1pEWKc8qlzNrGPUGcVgOa9cPJYIJsGnJTAUsEcDOEVULO5x0rXBijc1lgXEzQQKhROf8zIV82w8eswc78YX11KYLWQRcgHNJElBxfXr72lS2RBSl07qTKorO2uUDZr3sFhYsvnhLZn0A94KRzJ/7DEGIAhW5ZWFpL8gEwu1aLA9MuWZzNwl8Oze9Y+bX+v9gywRVnoB5I/8kXTXU3141yRLYrIOOz6SOnyHNy4SieqzkBXharjfjqq1q6tklaEbA8Qfm2DaIPs7OTq/nvJBjKfO2H9bH2cCMh1+5gspfycu8f/cuuRmtDjyqZ7uCIMyjdV3a+p3fqmXsRx4C8lujezIFHnQiVTXLXuI1XrwN3+siYYj2HHTvESUx8DlOTXpak9qFRK+L3mgJ1WsD7F4cu1aJoFoYQnu+wGDMOjJM3kiBQWHCcvhJ/HRdxodOQp45YZaOTA22Nb4XKCVxqkbwMYFhzYQYIAnCW8FW14uf98jhUG2zrKhQQ0q0CEq0t5nXyvUyvR8DvD69LU+g3i+HFWQMQ8PqZuHD+sNKAV0+M6EJC0szq7rEr7B5bQ8BcNHzvDMc9eqB5ZCQdTf80Obn4uzjwpYU7SISdtV0QGa9D3Wrh2BDQtpBKxaNFV+/Cy2P/Sv+8s7Ud0Fd74X4+o/TNztWgETUapy+majNQ68Lq3ee0ZO48VEbTZYiH1Co4OlfWef82RWeyUXo7woM03PyapGfikTnQinoNq5z5veLpeMV3HCAMTaZmA1oGLAn7XS3XYsz+XK7VMQsc4XKrmDXOLU/pSXVNUq8dIqTba///3x6LiLS6xs1xuCAYSfcQ3+rQgmu7uvf3THKt5Ooo97TqcbRqxx7EASizaQCBQllG/rYxVapMLgtLbZS64w1MDBMXX+PQpBKNwqUKOf2DDRDUXQf9EhOS0Qj4nTmlA8dzSLz/G1d+Ud8MTy/6ghhdiLpeerGY/UlDOfiuqFsMUU5/UYlP+BAmgRLuNpvrUaLlVkrqDievNVEAwF+4CoM1MZTmjxjJMsKJq+u8Zd7tNCUFy6LiyYXRJQ4VyvEQFFaCGKsxIwQkk7EzZ6LTJq2hUuPhvAW+gQnSG6J+MszC+7QCRHcnqDdyNRJ6T9xyS87A6MDutbzKGvGktpbXqtzWtXb9HsfK2cBMomjN9a4y+TaJLnXxAeX/HWzmf4cR4vALt/P4w4qgKY04ml4ZdLOinFYS6cup3G/1ie4+t1eOnpBNlqGqs75ilzkT4+DsZQxNvaSKJ//6zIbbk/M7LOhFmRc/1R+kBtz7JFGdZm/COotIdvQoXpTqP/1uqEUmCb/QWoGLMwO5ANcHzxdY48IGP5+J+zKOTBFZ4Pid+GTM+Wq12MV/H86xEJptBa6T+p3kgpwLedManBHC2GgNrFpoN2xnrMz9WFWX/8/ygSBkavq2Uv7FdCsLEYLu9LLIvAU0bNRDtzYl+/vXmjpIvuJFYjmI0im6QEYqnIeMsNjXG4vIutIGHijeAG/9EDBozKV5cldkHbLxHh25vT+ZEzbhXlqvpzKJwcEgfNwLAKFeo0/pvEE10XDB+EXRTXtSzJozQKFFAJhMxYkVaCW+E9AL7tMeU8acxidHqzb6lX4691UsDpy/LLRmT+epgW56+5Cw8tB4kMUv6s9lh3eRKbyGs+H/4mQMaYzPTf2OOdokEn+zzgvoD3FqNKk8QqGAXVsqcGdXrT62fSPkR2vROFi68A6se86UxRUk4cajfPyCC4G5wDhD+zNq4jodQ4u4n/m37Lr36n4LIAAsVr02dFi9AiwA81MYs2rm4eDlDNmdMRvEKRHfBwW5DdMNp0jPFZMeARqF/wL4XBfd+EMLBfMzpH5GH6NaW+1vrvMdg+VxDzatk3MXgO3ro3P/DpcC6+Mo4MySJhKJhSR01SGGGp5hPWmrrUgrv3lDnP+HhcI3nt3YqBoVAVTBAQT5iuhTg8nvPtd8ZeYj6w1x6RqGUBrSku7+N1+BaasZvjTk64RoIDlL8brpEcJx3OmY7jLoZsswdtmhfC/G21llXhITOwmvRDDeTTPbyASOa16cF5/A1fZAidJpqju3wYAy9avPR1ya6eNp9K8XYrrtuxlqi+bDKwlfrYdR0RRiKRVTLOH85+ZY7XSmzRpfZBJjaTa81VDcJHpZnZnSQLASGYW9l51ZV/h7eVzTi3Hv6hUsgc/51AqJRTkpbFVLXXszoBL8nBX0u/0jBLT8nH+fJePbrwURT58OY+UieRjd1vs04w0VG5VN2U6MoGZkQzKN/ptz0Q366dxoTGmj7i1NQGHi9GgnquXFYdrCfZBmeb7s0T6yrdlZH5cZuwHFyIJ/kAtGsTg0xH5taAAq44BAk1CPk9KVVbqQzrCUiFdF/6gtlPQ8bHHc1G1W92MXGZ5HEHftyLYs8mbD/9xYRUWkHmlM0zC2ilJlnNgV4bfALpQghxOUoZL7VTqtCHIaQSXm+YUMnpkXybnV+A6xlm2CVy8fn0Xlm2XRa0+zzOa21JWWmixfiPMSCZ7qA4rS93VN3pkpF1s5TonQjisHf7iU9ZGvUPOAKZcR1pbeVf/Ul7OhepGCaId9wOtqo7pJ7yLcBZ0pFkOF28y4zEI/kcUNmutBHaQpBdNM8vjCS6HZRokkeo88TBAjGyG7SR+6vUgTcyK9Imalj0kuxz0wmK+byQU11AiJFk/ya5dNduRClcnU64yGu/ieWSeOos1t3ep+RPIWQ2pyTYVbZltTbsb7NiwSi3AV+8KLWk7LxCnfZUetEM8ThnsSoGH38/nyAwFguJp8FjvlHtcWZuU4hPva0rHfr0UhOOJ/F6vS62FW7KzkmRll2HEc7oUq4fyi5T70Vl7YVIfsPHUCdHesf9Lk7WNVWO75JDkYbMI8TOW8JKVtLY9d6UJRITO8oKo0xS+o99Yy04iniGHAaGj88kEWgwv0OrHdY/nr76DOGNS59hXCGXzTKUvDl9iKpLSWYN1lxIeyywdNpTkhay74w2jFT6NS8qkjo5CxA1yfSYwp6AJIZNKIeEK5PJAW7ORgWgwp0VgzYpqovMrWxbu+DGZ6Lhie1RAqpzm8VUzKJOH3mCzWuTOLsN3VT/dv2eeYe9UjbR8YTBsLz7q60VN1sU51k+um1f8JxD5pPhbhSC8rRaB454tmh6YUWrJI3+GWY0qeWioj/tbkYITOkJaeuGt4JrJvHA+l0Gu7kY7XOaa05alMnRWVCXqFgLIwSY4uF59Ue5SU4QKuc/HamDxbr0x6csCetXGoP7Qn1Bk/J9DsynO/UD6iZ1Hyrz+jit0hDCwi/E9OjgKTbB3ZQKQ/0ZOvevfNHG0NK4Aj3Cp7NpRk07RT1i/S0EL93Ag8GRgKI9CfpajKyK6+Jj/PI1KO5/85VAwz2AwzP8FTBb075IxCXv6T9RVvWT2tUaqxDS92zrGUbWzUYk9mSs82pECH+fkqsDt93VW++4YsR/dHCYcQSYTO/KaBMDj9LSD/J/+z20Kq8XvZUAIHtm9hRPP3ItbuAu2Hm5lkPs92pd7kCxgRs0xOVBnZ13ccdA0aunrwv9SdqElJRC3g+oCu+nXyCgmXUs9yMjTMAIHfxZV+aPKcZeUBWt057Xo85Ks1Ir5gzEHCWqZEhrLZMuF11ziGtFQUds/EESajhagzcKsxamcSZxGth4UII+adPhQkUnx2WyN+4YWR+r3f8MnkyGFuR4zjzxJS8WsQYR5PTyRaD9ixa6Mh741nBHbzfjXHskGDq179xaRNrCIB1z1xRfWfjqw2pHc1zk9xlPpL8sQWAIuETZZhbnmL54rceXVNRvUiKrrqIkeogsl0XXb17ylNb0f4GA9Wd44vffEG8FSZGHEL2fbaTGRcSiCeA8PmA/f6Hz8HCS76fXUHwgwkzSwlI71ekZ7Fapmlk/KC+Hs8hUcw3N2LN5LhkVYyizYFl/uPeVP5lsoJHhhfWvvSWruCUW1ZcJOeuTbrDgywJ/qG07gZJplnTvLcYdNaH0KMYOYMGX+rB4NGPFmQsNaIwlWrfCezxre8zXBrsMT+edVLbLqN1BqB76JH4BvZTqUIMfGwPGEn+EnmTV86fPBaYbFL3DFEhjB45CewkXEAtJxk4/Ms2pPXnaRqdky0HOYdcUcE2zcXq4vaIvW2/v0nHFJH2XXe22ueDmq/18XGtELSq85j9X8q0tcNSSKJIX8FTuJF/Pf8j5PhqG2u+osvsLxYrvvfeVJL+4tkcXcr9JV7v0ERmj/X6fM3NC4j6dS1+9Umr2oPavqiAydTZPLMNRGY23LO9zAVDly7jD+70G5TPPLdhRIl4WxcYjLnM+SNcJ26FOrkrISUtPObIz5Zb3AG612krnpy15RMW+1cQjlnWFI6538qky9axd2oJmHIHP08KyP0ubGO+TQNOYuv2uh17yCIvR8VcStw7o1g0NM60sk+8Tq7YfIBJrtp53GkvzXH7OA0p8/n/u1satf/VJhtR1l8Wa6Gmaug7haSpaCaYQax6ta0mkutlb+eAOSG1aobM81D9A4iS1RRlzBBoVX6tU1S6WE2N9ORY6DfeLRC4l9Rvr5h95XDWB2mR1d4WFudpsgVYwiTwT31ljskD8ZyDOlm5DkGh9N/UB/0AI5Xvb8ZBmai2hQ4BWMqFwYnzxwB26YHSOv9WgY3JXnvoN+2R4rqGVh/LLDMtpFP+SpMGJNWvbIl5SOodbCczW2RKleksPoUeGEzrjtKHVdtZA+kfqO+rVx/iclCqwoopepvJpSTDjT+b9GWylGRF8EDbGlw6eUzmJM95Ovoz+kwLX3c2fTjFeYEsE7vUZm3mqdGJuKh2w9/QGSaqRHs99aScGOdDqkFcACoqdbBoQqqjamhH6Q9ng39JCg3lrGJwd50Qk9ovnqBTr8MME7Ps2wiVfygUmPoUBJJfJWX5Nda0nuncbFkA=="))}const r$2=getData(),VALID=new Set(read_member_array(r$2)),IGNORED=new Set(read_member_array(r$2)),MAPPED=read_mapped_map(r$2),EMOJI_ROOT=read_emoji_trie(r$2),HYPHEN=45,UNDERSCORE=95;function explode_cp(n){return toUtf8CodePoints(n)}function filter_fe0f(n){return n.filter(t=>t!=65039)}function ens_normalize_post_check(n){for(let t of n.split(".")){let c=explode_cp(t);try{for(let ie=c.lastIndexOf(UNDERSCORE)-1;ie>=0;ie--)if(c[ie]!==UNDERSCORE)throw new Error("underscore only allowed at start");if(c.length>=4&&c.every(ie=>ie<128)&&c[2]===HYPHEN&&c[3]===HYPHEN)throw new Error("invalid label extension")}catch(ie){throw new Error(`Invalid label "${t}": ${ie.message}`)}}return n}function ens_normalize(n){return ens_normalize_post_check(normalize$1(n,filter_fe0f))}function normalize$1(n,t){let c=explode_cp(n).reverse(),ie=[];for(;c.length;){let se=consume_emoji_reversed(c);if(se){ie.push(...t(se));continue}let ae=c.pop();if(VALID.has(ae)){ie.push(ae);continue}if(IGNORED.has(ae))continue;let ue=MAPPED[ae];if(ue){ie.push(...ue);continue}throw new Error(`Disallowed codepoint: 0x${ae.toString(16).toUpperCase()}`)}return ens_normalize_post_check(nfc(String.fromCodePoint(...ie)))}function nfc(n){return n.normalize("NFC")}function consume_emoji_reversed(n,t){var c;let ie=EMOJI_ROOT,se,ae,ue=[],de=n.length;for(;de;){let ve=n[--de];if(ie=(c=ie.branches.find(ge=>ge.set.has(ve)))===null||c===void 0?void 0:c.node,!ie)break;if(ie.save)ae=ve;else if(ie.check&&ve===ae)break;ue.push(ve),ie.fe0f&&(ue.push(65039),de>0&&n[de-1]==65039&&de--),ie.valid&&(se=ue.slice(),ie.valid==2&&se.splice(1,1),n.length=de)}return se}const logger$m=new Logger(version$m),Zeros$1=new Uint8Array(32);Zeros$1.fill(0);function checkComponent(n){if(n.length===0)throw new Error("invalid ENS name; empty component");return n}function ensNameSplit(n){const t=toUtf8Bytes(ens_normalize(n)),c=[];if(n.length===0)return c;let ie=0;for(let se=0;se<t.length;se++)t[se]===46&&(c.push(checkComponent(t.slice(ie,se))),ie=se+1);if(ie>=t.length)throw new Error("invalid ENS name; empty component");return c.push(checkComponent(t.slice(ie))),c}function ensNormalize(n){return ensNameSplit(n).map(t=>toUtf8String(t)).join(".")}function isValidName(n){try{return ensNameSplit(n).length!==0}catch{}return!1}function namehash$1(n){typeof n!="string"&&logger$m.throwArgumentError("invalid ENS name; not a string","name",n);let t=Zeros$1;const c=ensNameSplit(n);for(;c.length;)t=keccak256$1(concat$1([t,keccak256$1(c.pop())]));return hexlify(t)}function dnsEncode(n){return hexlify(concat$1(ensNameSplit(n).map(t=>{if(t.length>63)throw new Error("invalid DNS encoded entry; length exceeds 63 bytes");const c=new Uint8Array(t.length+1);return c.set(t,1),c[0]=c.length-1,c})))+"00"}const messagePrefix=`Ethereum Signed Message:
11
11
  `;function hashMessage(n){return typeof n=="string"&&(n=toUtf8Bytes(n)),keccak256$1(concat$1([toUtf8Bytes(messagePrefix),toUtf8Bytes(String(n.length)),n]))}var __awaiter$k=function(n,t,c,ie){function se(ae){return ae instanceof c?ae:new c(function(ue){ue(ae)})}return new(c||(c=Promise))(function(ae,ue){function de(we){try{ge(ie.next(we))}catch(Te){ue(Te)}}function ve(we){try{ge(ie.throw(we))}catch(Te){ue(Te)}}function ge(we){we.done?ae(we.value):se(we.value).then(de,ve)}ge((ie=ie.apply(n,[])).next())})};const logger$l=new Logger(version$m),padding=new Uint8Array(32);padding.fill(0);const NegativeOne=BigNumber.from(-1),Zero=BigNumber.from(0),One=BigNumber.from(1),MaxUint256=BigNumber.from("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");function hexPadRight(n){const t=arrayify(n),c=t.length%32;return c?hexConcat([t,padding.slice(c)]):hexlify(t)}const hexTrue=hexZeroPad(One.toHexString(),32),hexFalse=hexZeroPad(Zero.toHexString(),32),domainFieldTypes={name:"string",version:"string",chainId:"uint256",verifyingContract:"address",salt:"bytes32"},domainFieldNames=["name","version","chainId","verifyingContract","salt"];function checkString(n){return function(t){return typeof t!="string"&&logger$l.throwArgumentError(`invalid domain value for ${JSON.stringify(n)}`,`domain.${n}`,t),t}}const domainChecks={name:checkString("name"),version:checkString("version"),chainId:function(n){try{return BigNumber.from(n).toString()}catch{}return logger$l.throwArgumentError('invalid domain value for "chainId"',"domain.chainId",n)},verifyingContract:function(n){try{return getAddress$1(n).toLowerCase()}catch{}return logger$l.throwArgumentError('invalid domain value "verifyingContract"',"domain.verifyingContract",n)},salt:function(n){try{const t=arrayify(n);if(t.length!==32)throw new Error("bad length");return hexlify(t)}catch{}return logger$l.throwArgumentError('invalid domain value "salt"',"domain.salt",n)}};function getBaseEncoder(n){{const t=n.match(/^(u?)int(\d*)$/);if(t){const c=t[1]==="",ie=parseInt(t[2]||"256");(ie%8!==0||ie>256||t[2]&&t[2]!==String(ie))&&logger$l.throwArgumentError("invalid numeric width","type",n);const se=MaxUint256.mask(c?ie-1:ie),ae=c?se.add(One).mul(NegativeOne):Zero;return function(ue){const de=BigNumber.from(ue);return(de.lt(ae)||de.gt(se))&&logger$l.throwArgumentError(`value out-of-bounds for ${n}`,"value",ue),hexZeroPad(de.toTwos(256).toHexString(),32)}}}{const t=n.match(/^bytes(\d+)$/);if(t){const c=parseInt(t[1]);return(c===0||c>32||t[1]!==String(c))&&logger$l.throwArgumentError("invalid bytes width","type",n),function(ie){return arrayify(ie).length!==c&&logger$l.throwArgumentError(`invalid length for ${n}`,"value",ie),hexPadRight(ie)}}}switch(n){case"address":return function(t){return hexZeroPad(getAddress$1(t),32)};case"bool":return function(t){return t?hexTrue:hexFalse};case"bytes":return function(t){return keccak256$1(t)};case"string":return function(t){return id(t)}}return null}function encodeType(n,t){return`${n}(${t.map(({name:c,type:ie})=>ie+" "+c).join(",")})`}class TypedDataEncoder{constructor(t){defineReadOnly(this,"types",Object.freeze(deepCopy(t))),defineReadOnly(this,"_encoderCache",{}),defineReadOnly(this,"_types",{});const c={},ie={},se={};Object.keys(t).forEach(de=>{c[de]={},ie[de]=[],se[de]={}});for(const de in t){const ve={};t[de].forEach(ge=>{ve[ge.name]&&logger$l.throwArgumentError(`duplicate variable name ${JSON.stringify(ge.name)} in ${JSON.stringify(de)}`,"types",t),ve[ge.name]=!0;const we=ge.type.match(/^([^\x5b]*)(\x5b|$)/)[1];we===de&&logger$l.throwArgumentError(`circular type reference to ${JSON.stringify(we)}`,"types",t),!getBaseEncoder(we)&&(ie[we]||logger$l.throwArgumentError(`unknown type ${JSON.stringify(we)}`,"types",t),ie[we].push(de),c[de][we]=!0)})}const ae=Object.keys(ie).filter(de=>ie[de].length===0);ae.length===0?logger$l.throwArgumentError("missing primary type","types",t):ae.length>1&&logger$l.throwArgumentError(`ambiguous primary types or unused types: ${ae.map(de=>JSON.stringify(de)).join(", ")}`,"types",t),defineReadOnly(this,"primaryType",ae[0]);function ue(de,ve){ve[de]&&logger$l.throwArgumentError(`circular type reference to ${JSON.stringify(de)}`,"types",t),ve[de]=!0,Object.keys(c[de]).forEach(ge=>{ie[ge]&&(ue(ge,ve),Object.keys(ve).forEach(we=>{se[we][ge]=!0}))}),delete ve[de]}ue(this.primaryType,{});for(const de in se){const ve=Object.keys(se[de]);ve.sort(),this._types[de]=encodeType(de,t[de])+ve.map(ge=>encodeType(ge,t[ge])).join("")}}getEncoder(t){let c=this._encoderCache[t];return c||(c=this._encoderCache[t]=this._getEncoder(t)),c}_getEncoder(t){{const se=getBaseEncoder(t);if(se)return se}const c=t.match(/^(.*)(\x5b(\d*)\x5d)$/);if(c){const se=c[1],ae=this.getEncoder(se),ue=parseInt(c[3]);return de=>{ue>=0&&de.length!==ue&&logger$l.throwArgumentError("array length mismatch; expected length ${ arrayLength }","value",de);let ve=de.map(ae);return this._types[se]&&(ve=ve.map(keccak256$1)),keccak256$1(hexConcat(ve))}}const ie=this.types[t];if(ie){const se=id(this._types[t]);return ae=>{const ue=ie.map(({name:de,type:ve})=>{const ge=this.getEncoder(ve)(ae[de]);return this._types[ve]?keccak256$1(ge):ge});return ue.unshift(se),hexConcat(ue)}}return logger$l.throwArgumentError(`unknown type: ${t}`,"type",t)}encodeType(t){const c=this._types[t];return c||logger$l.throwArgumentError(`unknown type: ${JSON.stringify(t)}`,"name",t),c}encodeData(t,c){return this.getEncoder(t)(c)}hashStruct(t,c){return keccak256$1(this.encodeData(t,c))}encode(t){return this.encodeData(this.primaryType,t)}hash(t){return this.hashStruct(this.primaryType,t)}_visit(t,c,ie){if(getBaseEncoder(t))return ie(t,c);const se=t.match(/^(.*)(\x5b(\d*)\x5d)$/);if(se){const ue=se[1],de=parseInt(se[3]);return de>=0&&c.length!==de&&logger$l.throwArgumentError("array length mismatch; expected length ${ arrayLength }","value",c),c.map(ve=>this._visit(ue,ve,ie))}const ae=this.types[t];return ae?ae.reduce((ue,{name:de,type:ve})=>(ue[de]=this._visit(ve,c[de],ie),ue),{}):logger$l.throwArgumentError(`unknown type: ${t}`,"type",t)}visit(t,c){return this._visit(this.primaryType,t,c)}static from(t){return new TypedDataEncoder(t)}static getPrimaryType(t){return TypedDataEncoder.from(t).primaryType}static hashStruct(t,c,ie){return TypedDataEncoder.from(c).hashStruct(t,ie)}static hashDomain(t){const c=[];for(const ie in t){const se=domainFieldTypes[ie];se||logger$l.throwArgumentError(`invalid typed-data domain key: ${JSON.stringify(ie)}`,"domain",t),c.push({name:ie,type:se})}return c.sort((ie,se)=>domainFieldNames.indexOf(ie.name)-domainFieldNames.indexOf(se.name)),TypedDataEncoder.hashStruct("EIP712Domain",{EIP712Domain:c},t)}static encode(t,c,ie){return hexConcat(["0x1901",TypedDataEncoder.hashDomain(t),TypedDataEncoder.from(c).hash(ie)])}static hash(t,c,ie){return keccak256$1(TypedDataEncoder.encode(t,c,ie))}static resolveNames(t,c,ie,se){return __awaiter$k(this,void 0,void 0,function*(){t=shallowCopy(t);const ae={};t.verifyingContract&&!isHexString(t.verifyingContract,20)&&(ae[t.verifyingContract]="0x");const ue=TypedDataEncoder.from(c);ue.visit(ie,(de,ve)=>(de==="address"&&!isHexString(ve,20)&&(ae[ve]="0x"),ve));for(const de in ae)ae[de]=yield se(de);return t.verifyingContract&&ae[t.verifyingContract]&&(t.verifyingContract=ae[t.verifyingContract]),ie=ue.visit(ie,(de,ve)=>de==="address"&&ae[ve]?ae[ve]:ve),{domain:t,value:ie}})}static getPayload(t,c,ie){TypedDataEncoder.hashDomain(t);const se={},ae=[];domainFieldNames.forEach(ve=>{const ge=t[ve];ge!=null&&(se[ve]=domainChecks[ve](ge),ae.push({name:ve,type:domainFieldTypes[ve]}))});const ue=TypedDataEncoder.from(c),de=shallowCopy(c);return de.EIP712Domain?logger$l.throwArgumentError("types must not contain EIP712Domain type","types.EIP712Domain",c):de.EIP712Domain=ae,ue.encode(ie),{types:de,domain:se,primaryType:ue.primaryType,message:ue.visit(ie,(ve,ge)=>{if(ve.match(/^bytes(\d*)/))return hexlify(arrayify(ge));if(ve.match(/^u?int/))return BigNumber.from(ge).toString();switch(ve){case"address":return ge.toLowerCase();case"bool":return!!ge;case"string":return typeof ge!="string"&&logger$l.throwArgumentError("invalid string","value",ge),ge}return logger$l.throwArgumentError("unsupported type","type",ve)})}}}const lib_esm$c=Object.freeze(Object.defineProperty({__proto__:null,_TypedDataEncoder:TypedDataEncoder,dnsEncode,ensNormalize,hashMessage,id,isValidName,messagePrefix,namehash:namehash$1},Symbol.toStringTag,{value:"Module"})),logger$k=new Logger(version$q);class LogDescription extends Description{}class TransactionDescription extends Description{}class ErrorDescription extends Description{}class Indexed extends Description{static isIndexed(t){return!!(t&&t._isIndexed)}}const BuiltinErrors={"0x08c379a0":{signature:"Error(string)",name:"Error",inputs:["string"],reason:!0},"0x4e487b71":{signature:"Panic(uint256)",name:"Panic",inputs:["uint256"]}};function wrapAccessError(n,t){const c=new Error(`deferred error during ABI decoding triggered accessing ${n}`);return c.error=t,c}class Interface{constructor(t){let c=[];typeof t=="string"?c=JSON.parse(t):c=t,defineReadOnly(this,"fragments",c.map(ie=>Fragment.from(ie)).filter(ie=>ie!=null)),defineReadOnly(this,"_abiCoder",getStatic(new.target,"getAbiCoder")()),defineReadOnly(this,"functions",{}),defineReadOnly(this,"errors",{}),defineReadOnly(this,"events",{}),defineReadOnly(this,"structs",{}),this.fragments.forEach(ie=>{let se=null;switch(ie.type){case"constructor":if(this.deploy){logger$k.warn("duplicate definition - constructor");return}defineReadOnly(this,"deploy",ie);return;case"function":se=this.functions;break;case"event":se=this.events;break;case"error":se=this.errors;break;default:return}let ae=ie.format();if(se[ae]){logger$k.warn("duplicate definition - "+ae);return}se[ae]=ie}),this.deploy||defineReadOnly(this,"deploy",ConstructorFragment.from({payable:!1,type:"constructor"})),defineReadOnly(this,"_isInterface",!0)}format(t){t||(t=FormatTypes.full),t===FormatTypes.sighash&&logger$k.throwArgumentError("interface does not support formatting sighash","format",t);const c=this.fragments.map(ie=>ie.format(t));return t===FormatTypes.json?JSON.stringify(c.map(ie=>JSON.parse(ie))):c}static getAbiCoder(){return defaultAbiCoder}static getAddress(t){return getAddress$1(t)}static getSighash(t){return hexDataSlice(id(t.format()),0,4)}static getEventTopic(t){return id(t.format())}getFunction(t){if(isHexString(t)){for(const ie in this.functions)if(t===this.getSighash(ie))return this.functions[ie];logger$k.throwArgumentError("no matching function","sighash",t)}if(t.indexOf("(")===-1){const ie=t.trim(),se=Object.keys(this.functions).filter(ae=>ae.split("(")[0]===ie);return se.length===0?logger$k.throwArgumentError("no matching function","name",ie):se.length>1&&logger$k.throwArgumentError("multiple matching functions","name",ie),this.functions[se[0]]}const c=this.functions[FunctionFragment.fromString(t).format()];return c||logger$k.throwArgumentError("no matching function","signature",t),c}getEvent(t){if(isHexString(t)){const ie=t.toLowerCase();for(const se in this.events)if(ie===this.getEventTopic(se))return this.events[se];logger$k.throwArgumentError("no matching event","topichash",ie)}if(t.indexOf("(")===-1){const ie=t.trim(),se=Object.keys(this.events).filter(ae=>ae.split("(")[0]===ie);return se.length===0?logger$k.throwArgumentError("no matching event","name",ie):se.length>1&&logger$k.throwArgumentError("multiple matching events","name",ie),this.events[se[0]]}const c=this.events[EventFragment.fromString(t).format()];return c||logger$k.throwArgumentError("no matching event","signature",t),c}getError(t){if(isHexString(t)){const ie=getStatic(this.constructor,"getSighash");for(const se in this.errors){const ae=this.errors[se];if(t===ie(ae))return this.errors[se]}logger$k.throwArgumentError("no matching error","sighash",t)}if(t.indexOf("(")===-1){const ie=t.trim(),se=Object.keys(this.errors).filter(ae=>ae.split("(")[0]===ie);return se.length===0?logger$k.throwArgumentError("no matching error","name",ie):se.length>1&&logger$k.throwArgumentError("multiple matching errors","name",ie),this.errors[se[0]]}const c=this.errors[FunctionFragment.fromString(t).format()];return c||logger$k.throwArgumentError("no matching error","signature",t),c}getSighash(t){if(typeof t=="string")try{t=this.getFunction(t)}catch(c){try{t=this.getError(t)}catch{throw c}}return getStatic(this.constructor,"getSighash")(t)}getEventTopic(t){return typeof t=="string"&&(t=this.getEvent(t)),getStatic(this.constructor,"getEventTopic")(t)}_decodeParams(t,c){return this._abiCoder.decode(t,c)}_encodeParams(t,c){return this._abiCoder.encode(t,c)}encodeDeploy(t){return this._encodeParams(this.deploy.inputs,t||[])}decodeErrorResult(t,c){typeof t=="string"&&(t=this.getError(t));const ie=arrayify(c);return hexlify(ie.slice(0,4))!==this.getSighash(t)&&logger$k.throwArgumentError(`data signature does not match error ${t.name}.`,"data",hexlify(ie)),this._decodeParams(t.inputs,ie.slice(4))}encodeErrorResult(t,c){return typeof t=="string"&&(t=this.getError(t)),hexlify(concat$1([this.getSighash(t),this._encodeParams(t.inputs,c||[])]))}decodeFunctionData(t,c){typeof t=="string"&&(t=this.getFunction(t));const ie=arrayify(c);return hexlify(ie.slice(0,4))!==this.getSighash(t)&&logger$k.throwArgumentError(`data signature does not match function ${t.name}.`,"data",hexlify(ie)),this._decodeParams(t.inputs,ie.slice(4))}encodeFunctionData(t,c){return typeof t=="string"&&(t=this.getFunction(t)),hexlify(concat$1([this.getSighash(t),this._encodeParams(t.inputs,c||[])]))}decodeFunctionResult(t,c){typeof t=="string"&&(t=this.getFunction(t));let ie=arrayify(c),se=null,ae="",ue=null,de=null,ve=null;switch(ie.length%this._abiCoder._getWordSize()){case 0:try{return this._abiCoder.decode(t.outputs,ie)}catch{}break;case 4:{const ge=hexlify(ie.slice(0,4)),we=BuiltinErrors[ge];if(we)ue=this._abiCoder.decode(we.inputs,ie.slice(4)),de=we.name,ve=we.signature,we.reason&&(se=ue[0]),de==="Error"?ae=`; VM Exception while processing transaction: reverted with reason string ${JSON.stringify(ue[0])}`:de==="Panic"&&(ae=`; VM Exception while processing transaction: reverted with panic code ${ue[0]}`);else try{const Te=this.getError(ge);ue=this._abiCoder.decode(Te.inputs,ie.slice(4)),de=Te.name,ve=Te.format()}catch{}break}}return logger$k.throwError("call revert exception"+ae,Logger.errors.CALL_EXCEPTION,{method:t.format(),data:hexlify(c),errorArgs:ue,errorName:de,errorSignature:ve,reason:se})}encodeFunctionResult(t,c){return typeof t=="string"&&(t=this.getFunction(t)),hexlify(this._abiCoder.encode(t.outputs,c||[]))}encodeFilterTopics(t,c){typeof t=="string"&&(t=this.getEvent(t)),c.length>t.inputs.length&&logger$k.throwError("too many arguments for "+t.format(),Logger.errors.UNEXPECTED_ARGUMENT,{argument:"values",value:c});let ie=[];t.anonymous||ie.push(this.getEventTopic(t));const se=(ae,ue)=>ae.type==="string"?id(ue):ae.type==="bytes"?keccak256$1(hexlify(ue)):(ae.type==="bool"&&typeof ue=="boolean"&&(ue=ue?"0x01":"0x00"),ae.type.match(/^u?int/)&&(ue=BigNumber.from(ue).toHexString()),ae.type==="address"&&this._abiCoder.encode(["address"],[ue]),hexZeroPad(hexlify(ue),32));for(c.forEach((ae,ue)=>{let de=t.inputs[ue];if(!de.indexed){ae!=null&&logger$k.throwArgumentError("cannot filter non-indexed parameters; must be null","contract."+de.name,ae);return}ae==null?ie.push(null):de.baseType==="array"||de.baseType==="tuple"?logger$k.throwArgumentError("filtering with tuples or arrays not supported","contract."+de.name,ae):Array.isArray(ae)?ie.push(ae.map(ve=>se(de,ve))):ie.push(se(de,ae))});ie.length&&ie[ie.length-1]===null;)ie.pop();return ie}encodeEventLog(t,c){typeof t=="string"&&(t=this.getEvent(t));const ie=[],se=[],ae=[];return t.anonymous||ie.push(this.getEventTopic(t)),c.length!==t.inputs.length&&logger$k.throwArgumentError("event arguments/values mismatch","values",c),t.inputs.forEach((ue,de)=>{const ve=c[de];if(ue.indexed)if(ue.type==="string")ie.push(id(ve));else if(ue.type==="bytes")ie.push(keccak256$1(ve));else{if(ue.baseType==="tuple"||ue.baseType==="array")throw new Error("not implemented");ie.push(this._abiCoder.encode([ue.type],[ve]))}else se.push(ue),ae.push(ve)}),{data:this._abiCoder.encode(se,ae),topics:ie}}decodeEventLog(t,c,ie){if(typeof t=="string"&&(t=this.getEvent(t)),ie!=null&&!t.anonymous){let Ne=this.getEventTopic(t);(!isHexString(ie[0],32)||ie[0].toLowerCase()!==Ne)&&logger$k.throwError("fragment/topic mismatch",Logger.errors.INVALID_ARGUMENT,{argument:"topics[0]",expected:Ne,value:ie[0]}),ie=ie.slice(1)}let se=[],ae=[],ue=[];t.inputs.forEach((Ne,qe)=>{Ne.indexed?Ne.type==="string"||Ne.type==="bytes"||Ne.baseType==="tuple"||Ne.baseType==="array"?(se.push(ParamType.fromObject({type:"bytes32",name:Ne.name})),ue.push(!0)):(se.push(Ne),ue.push(!1)):(ae.push(Ne),ue.push(!1))});let de=ie!=null?this._abiCoder.decode(se,concat$1(ie)):null,ve=this._abiCoder.decode(ae,c,!0),ge=[],we=0,Te=0;t.inputs.forEach((Ne,qe)=>{if(Ne.indexed)if(de==null)ge[qe]=new Indexed({_isIndexed:!0,hash:null});else if(ue[qe])ge[qe]=new Indexed({_isIndexed:!0,hash:de[Te++]});else try{ge[qe]=de[Te++]}catch(ze){ge[qe]=ze}else try{ge[qe]=ve[we++]}catch(ze){ge[qe]=ze}if(Ne.name&&ge[Ne.name]==null){const ze=ge[qe];ze instanceof Error?Object.defineProperty(ge,Ne.name,{enumerable:!0,get:()=>{throw wrapAccessError(`property ${JSON.stringify(Ne.name)}`,ze)}}):ge[Ne.name]=ze}});for(let Ne=0;Ne<ge.length;Ne++){const qe=ge[Ne];qe instanceof Error&&Object.defineProperty(ge,Ne,{enumerable:!0,get:()=>{throw wrapAccessError(`index ${Ne}`,qe)}})}return Object.freeze(ge)}parseTransaction(t){let c=this.getFunction(t.data.substring(0,10).toLowerCase());return c?new TransactionDescription({args:this._abiCoder.decode(c.inputs,"0x"+t.data.substring(10)),functionFragment:c,name:c.name,signature:c.format(),sighash:this.getSighash(c),value:BigNumber.from(t.value||"0")}):null}parseLog(t){let c=this.getEvent(t.topics[0]);return!c||c.anonymous?null:new LogDescription({eventFragment:c,name:c.name,signature:c.format(),topic:this.getEventTopic(c),args:this.decodeEventLog(c,t.data,t.topics)})}parseError(t){const c=hexlify(t);let ie=this.getError(c.substring(0,10).toLowerCase());return ie?new ErrorDescription({args:this._abiCoder.decode(ie.inputs,"0x"+c.substring(10)),errorFragment:ie,name:ie.name,signature:ie.format(),sighash:this.getSighash(ie)}):null}static isInterface(t){return!!(t&&t._isInterface)}}const lib_esm$b=Object.freeze(Object.defineProperty({__proto__:null,AbiCoder,ConstructorFragment,ErrorFragment,EventFragment,FormatTypes,Fragment,FunctionFragment,Indexed,Interface,LogDescription,ParamType,TransactionDescription,checkResultErrors,defaultAbiCoder},Symbol.toStringTag,{value:"Module"})),version$l="abstract-provider/5.8.0";var __awaiter$j=function(n,t,c,ie){function se(ae){return ae instanceof c?ae:new c(function(ue){ue(ae)})}return new(c||(c=Promise))(function(ae,ue){function de(we){try{ge(ie.next(we))}catch(Te){ue(Te)}}function ve(we){try{ge(ie.throw(we))}catch(Te){ue(Te)}}function ge(we){we.done?ae(we.value):se(we.value).then(de,ve)}ge((ie=ie.apply(n,[])).next())})};const logger$j=new Logger(version$l);class ForkEvent extends Description{static isForkEvent(t){return!!(t&&t._isForkEvent)}}class Provider{constructor(){logger$j.checkAbstract(new.target,Provider),defineReadOnly(this,"_isProvider",!0)}getFeeData(){return __awaiter$j(this,void 0,void 0,function*(){const{block:t,gasPrice:c}=yield resolveProperties({block:this.getBlock("latest"),gasPrice:this.getGasPrice().catch(ue=>null)});let ie=null,se=null,ae=null;return t&&t.baseFeePerGas&&(ie=t.baseFeePerGas,ae=BigNumber.from("1500000000"),se=t.baseFeePerGas.mul(2).add(ae)),{lastBaseFeePerGas:ie,maxFeePerGas:se,maxPriorityFeePerGas:ae,gasPrice:c}})}addListener(t,c){return this.on(t,c)}removeListener(t,c){return this.off(t,c)}static isProvider(t){return!!(t&&t._isProvider)}}const version$k="abstract-signer/5.8.0";var __awaiter$i=function(n,t,c,ie){function se(ae){return ae instanceof c?ae:new c(function(ue){ue(ae)})}return new(c||(c=Promise))(function(ae,ue){function de(we){try{ge(ie.next(we))}catch(Te){ue(Te)}}function ve(we){try{ge(ie.throw(we))}catch(Te){ue(Te)}}function ge(we){we.done?ae(we.value):se(we.value).then(de,ve)}ge((ie=ie.apply(n,[])).next())})};const logger$i=new Logger(version$k),allowedTransactionKeys$2=["accessList","ccipReadEnabled","chainId","customData","data","from","gasLimit","gasPrice","maxFeePerGas","maxPriorityFeePerGas","nonce","to","type","value"],forwardErrors=[Logger.errors.INSUFFICIENT_FUNDS,Logger.errors.NONCE_EXPIRED,Logger.errors.REPLACEMENT_UNDERPRICED];class Signer{constructor(){logger$i.checkAbstract(new.target,Signer),defineReadOnly(this,"_isSigner",!0)}getBalance(t){return __awaiter$i(this,void 0,void 0,function*(){return this._checkProvider("getBalance"),yield this.provider.getBalance(this.getAddress(),t)})}getTransactionCount(t){return __awaiter$i(this,void 0,void 0,function*(){return this._checkProvider("getTransactionCount"),yield this.provider.getTransactionCount(this.getAddress(),t)})}estimateGas(t){return __awaiter$i(this,void 0,void 0,function*(){this._checkProvider("estimateGas");const c=yield resolveProperties(this.checkTransaction(t));return yield this.provider.estimateGas(c)})}call(t,c){return __awaiter$i(this,void 0,void 0,function*(){this._checkProvider("call");const ie=yield resolveProperties(this.checkTransaction(t));return yield this.provider.call(ie,c)})}sendTransaction(t){return __awaiter$i(this,void 0,void 0,function*(){this._checkProvider("sendTransaction");const c=yield this.populateTransaction(t),ie=yield this.signTransaction(c);return yield this.provider.sendTransaction(ie)})}getChainId(){return __awaiter$i(this,void 0,void 0,function*(){return this._checkProvider("getChainId"),(yield this.provider.getNetwork()).chainId})}getGasPrice(){return __awaiter$i(this,void 0,void 0,function*(){return this._checkProvider("getGasPrice"),yield this.provider.getGasPrice()})}getFeeData(){return __awaiter$i(this,void 0,void 0,function*(){return this._checkProvider("getFeeData"),yield this.provider.getFeeData()})}resolveName(t){return __awaiter$i(this,void 0,void 0,function*(){return this._checkProvider("resolveName"),yield this.provider.resolveName(t)})}checkTransaction(t){for(const ie in t)allowedTransactionKeys$2.indexOf(ie)===-1&&logger$i.throwArgumentError("invalid transaction key: "+ie,"transaction",t);const c=shallowCopy(t);return c.from==null?c.from=this.getAddress():c.from=Promise.all([Promise.resolve(c.from),this.getAddress()]).then(ie=>(ie[0].toLowerCase()!==ie[1].toLowerCase()&&logger$i.throwArgumentError("from address mismatch","transaction",t),ie[0])),c}populateTransaction(t){return __awaiter$i(this,void 0,void 0,function*(){const c=yield resolveProperties(this.checkTransaction(t));c.to!=null&&(c.to=Promise.resolve(c.to).then(se=>__awaiter$i(this,void 0,void 0,function*(){if(se==null)return null;const ae=yield this.resolveName(se);return ae==null&&logger$i.throwArgumentError("provided ENS name resolves to null","tx.to",se),ae})),c.to.catch(se=>{}));const ie=c.maxFeePerGas!=null||c.maxPriorityFeePerGas!=null;if(c.gasPrice!=null&&(c.type===2||ie)?logger$i.throwArgumentError("eip-1559 transaction do not support gasPrice","transaction",t):(c.type===0||c.type===1)&&ie&&logger$i.throwArgumentError("pre-eip-1559 transaction do not support maxFeePerGas/maxPriorityFeePerGas","transaction",t),(c.type===2||c.type==null)&&c.maxFeePerGas!=null&&c.maxPriorityFeePerGas!=null)c.type=2;else if(c.type===0||c.type===1)c.gasPrice==null&&(c.gasPrice=this.getGasPrice());else{const se=yield this.getFeeData();if(c.type==null)if(se.maxFeePerGas!=null&&se.maxPriorityFeePerGas!=null)if(c.type=2,c.gasPrice!=null){const ae=c.gasPrice;delete c.gasPrice,c.maxFeePerGas=ae,c.maxPriorityFeePerGas=ae}else c.maxFeePerGas==null&&(c.maxFeePerGas=se.maxFeePerGas),c.maxPriorityFeePerGas==null&&(c.maxPriorityFeePerGas=se.maxPriorityFeePerGas);else se.gasPrice!=null?(ie&&logger$i.throwError("network does not support EIP-1559",Logger.errors.UNSUPPORTED_OPERATION,{operation:"populateTransaction"}),c.gasPrice==null&&(c.gasPrice=se.gasPrice),c.type=0):logger$i.throwError("failed to get consistent fee data",Logger.errors.UNSUPPORTED_OPERATION,{operation:"signer.getFeeData"});else c.type===2&&(c.maxFeePerGas==null&&(c.maxFeePerGas=se.maxFeePerGas),c.maxPriorityFeePerGas==null&&(c.maxPriorityFeePerGas=se.maxPriorityFeePerGas))}return c.nonce==null&&(c.nonce=this.getTransactionCount("pending")),c.gasLimit==null&&(c.gasLimit=this.estimateGas(c).catch(se=>{if(forwardErrors.indexOf(se.code)>=0)throw se;return logger$i.throwError("cannot estimate gas; transaction may fail or may require manual gas limit",Logger.errors.UNPREDICTABLE_GAS_LIMIT,{error:se,tx:c})})),c.chainId==null?c.chainId=this.getChainId():c.chainId=Promise.all([Promise.resolve(c.chainId),this.getChainId()]).then(se=>(se[1]!==0&&se[0]!==se[1]&&logger$i.throwArgumentError("chainId address mismatch","transaction",t),se[0])),yield resolveProperties(c)})}_checkProvider(t){this.provider||logger$i.throwError("missing provider",Logger.errors.UNSUPPORTED_OPERATION,{operation:t||"_checkProvider"})}static isSigner(t){return!!(t&&t._isSigner)}}class VoidSigner extends Signer{constructor(t,c){super(),defineReadOnly(this,"address",t),defineReadOnly(this,"provider",c||null)}getAddress(){return Promise.resolve(this.address)}_fail(t,c){return Promise.resolve().then(()=>{logger$i.throwError(t,Logger.errors.UNSUPPORTED_OPERATION,{operation:c})})}signMessage(t){return this._fail("VoidSigner cannot sign messages","signMessage")}signTransaction(t){return this._fail("VoidSigner cannot sign transactions","signTransaction")}_signTypedData(t,c,ie){return this._fail("VoidSigner cannot sign typed data","signTypedData")}connect(t){return new VoidSigner(this.address,t)}}var hash$4={},utils$o={},minimalisticAssert$1=assert$h;function assert$h(n,t){if(!n)throw new Error(t||"Assertion failed")}assert$h.equal=function(n,t,c){if(n!=t)throw new Error(c||"Assertion failed: "+n+" != "+t)};var inherits_browser$1={exports:{}};typeof Object.create=="function"?inherits_browser$1.exports=function(n,t){t&&(n.super_=t,n.prototype=Object.create(t.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}))}:inherits_browser$1.exports=function(n,t){if(t){n.super_=t;var c=function(){};c.prototype=t.prototype,n.prototype=new c,n.prototype.constructor=n}};var inherits_browserExports=inherits_browser$1.exports,assert$g=minimalisticAssert$1,inherits$3=inherits_browserExports;utils$o.inherits=inherits$3;function isSurrogatePair(n,t){return(n.charCodeAt(t)&64512)!==55296||t<0||t+1>=n.length?!1:(n.charCodeAt(t+1)&64512)===56320}function toArray$3(n,t){if(Array.isArray(n))return n.slice();if(!n)return[];var c=[];if(typeof n=="string")if(t){if(t==="hex")for(n=n.replace(/[^a-z0-9]+/ig,""),n.length%2!==0&&(n="0"+n),se=0;se<n.length;se+=2)c.push(parseInt(n[se]+n[se+1],16))}else for(var ie=0,se=0;se<n.length;se++){var ae=n.charCodeAt(se);ae<128?c[ie++]=ae:ae<2048?(c[ie++]=ae>>6|192,c[ie++]=ae&63|128):isSurrogatePair(n,se)?(ae=65536+((ae&1023)<<10)+(n.charCodeAt(++se)&1023),c[ie++]=ae>>18|240,c[ie++]=ae>>12&63|128,c[ie++]=ae>>6&63|128,c[ie++]=ae&63|128):(c[ie++]=ae>>12|224,c[ie++]=ae>>6&63|128,c[ie++]=ae&63|128)}else for(se=0;se<n.length;se++)c[se]=n[se]|0;return c}utils$o.toArray=toArray$3;function toHex$1(n){for(var t="",c=0;c<n.length;c++)t+=zero2(n[c].toString(16));return t}utils$o.toHex=toHex$1;function htonl(n){var t=n>>>24|n>>>8&65280|n<<8&16711680|(n&255)<<24;return t>>>0}utils$o.htonl=htonl;function toHex32(n,t){for(var c="",ie=0;ie<n.length;ie++){var se=n[ie];t==="little"&&(se=htonl(se)),c+=zero8(se.toString(16))}return c}utils$o.toHex32=toHex32;function zero2(n){return n.length===1?"0"+n:n}utils$o.zero2=zero2;function zero8(n){return n.length===7?"0"+n:n.length===6?"00"+n:n.length===5?"000"+n:n.length===4?"0000"+n:n.length===3?"00000"+n:n.length===2?"000000"+n:n.length===1?"0000000"+n:n}utils$o.zero8=zero8;function join32(n,t,c,ie){var se=c-t;assert$g(se%4===0);for(var ae=new Array(se/4),ue=0,de=t;ue<ae.length;ue++,de+=4){var ve;ie==="big"?ve=n[de]<<24|n[de+1]<<16|n[de+2]<<8|n[de+3]:ve=n[de+3]<<24|n[de+2]<<16|n[de+1]<<8|n[de],ae[ue]=ve>>>0}return ae}utils$o.join32=join32;function split32(n,t){for(var c=new Array(n.length*4),ie=0,se=0;ie<n.length;ie++,se+=4){var ae=n[ie];t==="big"?(c[se]=ae>>>24,c[se+1]=ae>>>16&255,c[se+2]=ae>>>8&255,c[se+3]=ae&255):(c[se+3]=ae>>>24,c[se+2]=ae>>>16&255,c[se+1]=ae>>>8&255,c[se]=ae&255)}return c}utils$o.split32=split32;function rotr32$1(n,t){return n>>>t|n<<32-t}utils$o.rotr32=rotr32$1;function rotl32$2(n,t){return n<<t|n>>>32-t}utils$o.rotl32=rotl32$2;function sum32$3(n,t){return n+t>>>0}utils$o.sum32=sum32$3;function sum32_3$1(n,t,c){return n+t+c>>>0}utils$o.sum32_3=sum32_3$1;function sum32_4$2(n,t,c,ie){return n+t+c+ie>>>0}utils$o.sum32_4=sum32_4$2;function sum32_5$2(n,t,c,ie,se){return n+t+c+ie+se>>>0}utils$o.sum32_5=sum32_5$2;function sum64$1(n,t,c,ie){var se=n[t],ae=n[t+1],ue=ie+ae>>>0,de=(ue<ie?1:0)+c+se;n[t]=de>>>0,n[t+1]=ue}utils$o.sum64=sum64$1;function sum64_hi$1(n,t,c,ie){var se=t+ie>>>0,ae=(se<t?1:0)+n+c;return ae>>>0}utils$o.sum64_hi=sum64_hi$1;function sum64_lo$1(n,t,c,ie){var se=t+ie;return se>>>0}utils$o.sum64_lo=sum64_lo$1;function sum64_4_hi$1(n,t,c,ie,se,ae,ue,de){var ve=0,ge=t;ge=ge+ie>>>0,ve+=ge<t?1:0,ge=ge+ae>>>0,ve+=ge<ae?1:0,ge=ge+de>>>0,ve+=ge<de?1:0;var we=n+c+se+ue+ve;return we>>>0}utils$o.sum64_4_hi=sum64_4_hi$1;function sum64_4_lo$1(n,t,c,ie,se,ae,ue,de){var ve=t+ie+ae+de;return ve>>>0}utils$o.sum64_4_lo=sum64_4_lo$1;function sum64_5_hi$1(n,t,c,ie,se,ae,ue,de,ve,ge){var we=0,Te=t;Te=Te+ie>>>0,we+=Te<t?1:0,Te=Te+ae>>>0,we+=Te<ae?1:0,Te=Te+de>>>0,we+=Te<de?1:0,Te=Te+ge>>>0,we+=Te<ge?1:0;var Ne=n+c+se+ue+ve+we;return Ne>>>0}utils$o.sum64_5_hi=sum64_5_hi$1;function sum64_5_lo$1(n,t,c,ie,se,ae,ue,de,ve,ge){var we=t+ie+ae+de+ge;return we>>>0}utils$o.sum64_5_lo=sum64_5_lo$1;function rotr64_hi$1(n,t,c){var ie=t<<32-c|n>>>c;return ie>>>0}utils$o.rotr64_hi=rotr64_hi$1;function rotr64_lo$1(n,t,c){var ie=n<<32-c|t>>>c;return ie>>>0}utils$o.rotr64_lo=rotr64_lo$1;function shr64_hi$1(n,t,c){return n>>>c}utils$o.shr64_hi=shr64_hi$1;function shr64_lo$1(n,t,c){var ie=n<<32-c|t>>>c;return ie>>>0}utils$o.shr64_lo=shr64_lo$1;var common$5={},utils$n=utils$o,assert$f=minimalisticAssert$1;function BlockHash$4(){this.pending=null,this.pendingTotal=0,this.blockSize=this.constructor.blockSize,this.outSize=this.constructor.outSize,this.hmacStrength=this.constructor.hmacStrength,this.padLength=this.constructor.padLength/8,this.endian="big",this._delta8=this.blockSize/8,this._delta32=this.blockSize/32}common$5.BlockHash=BlockHash$4;BlockHash$4.prototype.update=function(n,t){if(n=utils$n.toArray(n,t),this.pending?this.pending=this.pending.concat(n):this.pending=n,this.pendingTotal+=n.length,this.pending.length>=this._delta8){n=this.pending;var c=n.length%this._delta8;this.pending=n.slice(n.length-c,n.length),this.pending.length===0&&(this.pending=null),n=utils$n.join32(n,0,n.length-c,this.endian);for(var ie=0;ie<n.length;ie+=this._delta32)this._update(n,ie,ie+this._delta32)}return this};BlockHash$4.prototype.digest=function(n){return this.update(this._pad()),assert$f(this.pending===null),this._digest(n)};BlockHash$4.prototype._pad=function(){var n=this.pendingTotal,t=this._delta8,c=t-(n+this.padLength)%t,ie=new Array(c+this.padLength);ie[0]=128;for(var se=1;se<c;se++)ie[se]=0;if(n<<=3,this.endian==="big"){for(var ae=8;ae<this.padLength;ae++)ie[se++]=0;ie[se++]=0,ie[se++]=0,ie[se++]=0,ie[se++]=0,ie[se++]=n>>>24&255,ie[se++]=n>>>16&255,ie[se++]=n>>>8&255,ie[se++]=n&255}else for(ie[se++]=n&255,ie[se++]=n>>>8&255,ie[se++]=n>>>16&255,ie[se++]=n>>>24&255,ie[se++]=0,ie[se++]=0,ie[se++]=0,ie[se++]=0,ae=8;ae<this.padLength;ae++)ie[se++]=0;return ie};var sha$1={},common$4={},utils$m=utils$o,rotr32=utils$m.rotr32;function ft_1$1(n,t,c,ie){if(n===0)return ch32$1(t,c,ie);if(n===1||n===3)return p32(t,c,ie);if(n===2)return maj32$1(t,c,ie)}common$4.ft_1=ft_1$1;function ch32$1(n,t,c){return n&t^~n&c}common$4.ch32=ch32$1;function maj32$1(n,t,c){return n&t^n&c^t&c}common$4.maj32=maj32$1;function p32(n,t,c){return n^t^c}common$4.p32=p32;function s0_256$1(n){return rotr32(n,2)^rotr32(n,13)^rotr32(n,22)}common$4.s0_256=s0_256$1;function s1_256$1(n){return rotr32(n,6)^rotr32(n,11)^rotr32(n,25)}common$4.s1_256=s1_256$1;function g0_256$1(n){return rotr32(n,7)^rotr32(n,18)^n>>>3}common$4.g0_256=g0_256$1;function g1_256$1(n){return rotr32(n,17)^rotr32(n,19)^n>>>10}common$4.g1_256=g1_256$1;var utils$l=utils$o,common$3=common$5,shaCommon$1=common$4,rotl32$1=utils$l.rotl32,sum32$2=utils$l.sum32,sum32_5$1=utils$l.sum32_5,ft_1=shaCommon$1.ft_1,BlockHash$3=common$3.BlockHash,sha1_K=[1518500249,1859775393,2400959708,3395469782];function SHA1(){if(!(this instanceof SHA1))return new SHA1;BlockHash$3.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.W=new Array(80)}utils$l.inherits(SHA1,BlockHash$3);var _1=SHA1;SHA1.blockSize=512;SHA1.outSize=160;SHA1.hmacStrength=80;SHA1.padLength=64;SHA1.prototype._update=function(n,t){for(var c=this.W,ie=0;ie<16;ie++)c[ie]=n[t+ie];for(;ie<c.length;ie++)c[ie]=rotl32$1(c[ie-3]^c[ie-8]^c[ie-14]^c[ie-16],1);var se=this.h[0],ae=this.h[1],ue=this.h[2],de=this.h[3],ve=this.h[4];for(ie=0;ie<c.length;ie++){var ge=~~(ie/20),we=sum32_5$1(rotl32$1(se,5),ft_1(ge,ae,ue,de),ve,c[ie],sha1_K[ge]);ve=de,de=ue,ue=rotl32$1(ae,30),ae=se,se=we}this.h[0]=sum32$2(this.h[0],se),this.h[1]=sum32$2(this.h[1],ae),this.h[2]=sum32$2(this.h[2],ue),this.h[3]=sum32$2(this.h[3],de),this.h[4]=sum32$2(this.h[4],ve)};SHA1.prototype._digest=function(n){return n==="hex"?utils$l.toHex32(this.h,"big"):utils$l.split32(this.h,"big")};var utils$k=utils$o,common$2=common$5,shaCommon=common$4,assert$e=minimalisticAssert$1,sum32$1=utils$k.sum32,sum32_4$1=utils$k.sum32_4,sum32_5=utils$k.sum32_5,ch32=shaCommon.ch32,maj32=shaCommon.maj32,s0_256=shaCommon.s0_256,s1_256=shaCommon.s1_256,g0_256=shaCommon.g0_256,g1_256=shaCommon.g1_256,BlockHash$2=common$2.BlockHash,sha256_K=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298];function SHA256$2(){if(!(this instanceof SHA256$2))return new SHA256$2;BlockHash$2.call(this),this.h=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],this.k=sha256_K,this.W=new Array(64)}utils$k.inherits(SHA256$2,BlockHash$2);var _256=SHA256$2;SHA256$2.blockSize=512;SHA256$2.outSize=256;SHA256$2.hmacStrength=192;SHA256$2.padLength=64;SHA256$2.prototype._update=function(n,t){for(var c=this.W,ie=0;ie<16;ie++)c[ie]=n[t+ie];for(;ie<c.length;ie++)c[ie]=sum32_4$1(g1_256(c[ie-2]),c[ie-7],g0_256(c[ie-15]),c[ie-16]);var se=this.h[0],ae=this.h[1],ue=this.h[2],de=this.h[3],ve=this.h[4],ge=this.h[5],we=this.h[6],Te=this.h[7];for(assert$e(this.k.length===c.length),ie=0;ie<c.length;ie++){var Ne=sum32_5(Te,s1_256(ve),ch32(ve,ge,we),this.k[ie],c[ie]),qe=sum32$1(s0_256(se),maj32(se,ae,ue));Te=we,we=ge,ge=ve,ve=sum32$1(de,Ne),de=ue,ue=ae,ae=se,se=sum32$1(Ne,qe)}this.h[0]=sum32$1(this.h[0],se),this.h[1]=sum32$1(this.h[1],ae),this.h[2]=sum32$1(this.h[2],ue),this.h[3]=sum32$1(this.h[3],de),this.h[4]=sum32$1(this.h[4],ve),this.h[5]=sum32$1(this.h[5],ge),this.h[6]=sum32$1(this.h[6],we),this.h[7]=sum32$1(this.h[7],Te)};SHA256$2.prototype._digest=function(n){return n==="hex"?utils$k.toHex32(this.h,"big"):utils$k.split32(this.h,"big")};var utils$j=utils$o,SHA256$1=_256;function SHA224(){if(!(this instanceof SHA224))return new SHA224;SHA256$1.call(this),this.h=[3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428]}utils$j.inherits(SHA224,SHA256$1);var _224=SHA224;SHA224.blockSize=512;SHA224.outSize=224;SHA224.hmacStrength=192;SHA224.padLength=64;SHA224.prototype._digest=function(n){return n==="hex"?utils$j.toHex32(this.h.slice(0,7),"big"):utils$j.split32(this.h.slice(0,7),"big")};var utils$i=utils$o,common$1=common$5,assert$d=minimalisticAssert$1,rotr64_hi=utils$i.rotr64_hi,rotr64_lo=utils$i.rotr64_lo,shr64_hi=utils$i.shr64_hi,shr64_lo=utils$i.shr64_lo,sum64=utils$i.sum64,sum64_hi=utils$i.sum64_hi,sum64_lo=utils$i.sum64_lo,sum64_4_hi=utils$i.sum64_4_hi,sum64_4_lo=utils$i.sum64_4_lo,sum64_5_hi=utils$i.sum64_5_hi,sum64_5_lo=utils$i.sum64_5_lo,BlockHash$1=common$1.BlockHash,sha512_K=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591];function SHA512$2(){if(!(this instanceof SHA512$2))return new SHA512$2;BlockHash$1.call(this),this.h=[1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209],this.k=sha512_K,this.W=new Array(160)}utils$i.inherits(SHA512$2,BlockHash$1);var _512=SHA512$2;SHA512$2.blockSize=1024;SHA512$2.outSize=512;SHA512$2.hmacStrength=192;SHA512$2.padLength=128;SHA512$2.prototype._prepareBlock=function(n,t){for(var c=this.W,ie=0;ie<32;ie++)c[ie]=n[t+ie];for(;ie<c.length;ie+=2){var se=g1_512_hi(c[ie-4],c[ie-3]),ae=g1_512_lo(c[ie-4],c[ie-3]),ue=c[ie-14],de=c[ie-13],ve=g0_512_hi(c[ie-30],c[ie-29]),ge=g0_512_lo(c[ie-30],c[ie-29]),we=c[ie-32],Te=c[ie-31];c[ie]=sum64_4_hi(se,ae,ue,de,ve,ge,we,Te),c[ie+1]=sum64_4_lo(se,ae,ue,de,ve,ge,we,Te)}};SHA512$2.prototype._update=function(n,t){this._prepareBlock(n,t);var c=this.W,ie=this.h[0],se=this.h[1],ae=this.h[2],ue=this.h[3],de=this.h[4],ve=this.h[5],ge=this.h[6],we=this.h[7],Te=this.h[8],Ne=this.h[9],qe=this.h[10],ze=this.h[11],He=this.h[12],Ge=this.h[13],Ze=this.h[14],Ye=this.h[15];assert$d(this.k.length===c.length);for(var Ft=0;Ft<c.length;Ft+=2){var Mt=Ze,Zt=Ye,cn=s1_512_hi(Te,Ne),hn=s1_512_lo(Te,Ne),yn=ch64_hi(Te,Ne,qe,ze,He),Ht=ch64_lo(Te,Ne,qe,ze,He,Ge),Sn=this.k[Ft],le=this.k[Ft+1],pe=c[Ft],be=c[Ft+1],xe=sum64_5_hi(Mt,Zt,cn,hn,yn,Ht,Sn,le,pe,be),_e=sum64_5_lo(Mt,Zt,cn,hn,yn,Ht,Sn,le,pe,be);Mt=s0_512_hi(ie,se),Zt=s0_512_lo(ie,se),cn=maj64_hi(ie,se,ae,ue,de),hn=maj64_lo(ie,se,ae,ue,de,ve);var De=sum64_hi(Mt,Zt,cn,hn),Fe=sum64_lo(Mt,Zt,cn,hn);Ze=He,Ye=Ge,He=qe,Ge=ze,qe=Te,ze=Ne,Te=sum64_hi(ge,we,xe,_e),Ne=sum64_lo(we,we,xe,_e),ge=de,we=ve,de=ae,ve=ue,ae=ie,ue=se,ie=sum64_hi(xe,_e,De,Fe),se=sum64_lo(xe,_e,De,Fe)}sum64(this.h,0,ie,se),sum64(this.h,2,ae,ue),sum64(this.h,4,de,ve),sum64(this.h,6,ge,we),sum64(this.h,8,Te,Ne),sum64(this.h,10,qe,ze),sum64(this.h,12,He,Ge),sum64(this.h,14,Ze,Ye)};SHA512$2.prototype._digest=function(n){return n==="hex"?utils$i.toHex32(this.h,"big"):utils$i.split32(this.h,"big")};function ch64_hi(n,t,c,ie,se){var ae=n&c^~n&se;return ae<0&&(ae+=4294967296),ae}function ch64_lo(n,t,c,ie,se,ae){var ue=t&ie^~t&ae;return ue<0&&(ue+=4294967296),ue}function maj64_hi(n,t,c,ie,se){var ae=n&c^n&se^c&se;return ae<0&&(ae+=4294967296),ae}function maj64_lo(n,t,c,ie,se,ae){var ue=t&ie^t&ae^ie&ae;return ue<0&&(ue+=4294967296),ue}function s0_512_hi(n,t){var c=rotr64_hi(n,t,28),ie=rotr64_hi(t,n,2),se=rotr64_hi(t,n,7),ae=c^ie^se;return ae<0&&(ae+=4294967296),ae}function s0_512_lo(n,t){var c=rotr64_lo(n,t,28),ie=rotr64_lo(t,n,2),se=rotr64_lo(t,n,7),ae=c^ie^se;return ae<0&&(ae+=4294967296),ae}function s1_512_hi(n,t){var c=rotr64_hi(n,t,14),ie=rotr64_hi(n,t,18),se=rotr64_hi(t,n,9),ae=c^ie^se;return ae<0&&(ae+=4294967296),ae}function s1_512_lo(n,t){var c=rotr64_lo(n,t,14),ie=rotr64_lo(n,t,18),se=rotr64_lo(t,n,9),ae=c^ie^se;return ae<0&&(ae+=4294967296),ae}function g0_512_hi(n,t){var c=rotr64_hi(n,t,1),ie=rotr64_hi(n,t,8),se=shr64_hi(n,t,7),ae=c^ie^se;return ae<0&&(ae+=4294967296),ae}function g0_512_lo(n,t){var c=rotr64_lo(n,t,1),ie=rotr64_lo(n,t,8),se=shr64_lo(n,t,7),ae=c^ie^se;return ae<0&&(ae+=4294967296),ae}function g1_512_hi(n,t){var c=rotr64_hi(n,t,19),ie=rotr64_hi(t,n,29),se=shr64_hi(n,t,6),ae=c^ie^se;return ae<0&&(ae+=4294967296),ae}function g1_512_lo(n,t){var c=rotr64_lo(n,t,19),ie=rotr64_lo(t,n,29),se=shr64_lo(n,t,6),ae=c^ie^se;return ae<0&&(ae+=4294967296),ae}var utils$h=utils$o,SHA512$1=_512;function SHA384(){if(!(this instanceof SHA384))return new SHA384;SHA512$1.call(this),this.h=[3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]}utils$h.inherits(SHA384,SHA512$1);var _384=SHA384;SHA384.blockSize=1024;SHA384.outSize=384;SHA384.hmacStrength=192;SHA384.padLength=128;SHA384.prototype._digest=function(n){return n==="hex"?utils$h.toHex32(this.h.slice(0,12),"big"):utils$h.split32(this.h.slice(0,12),"big")};sha$1.sha1=_1;sha$1.sha224=_224;sha$1.sha256=_256;sha$1.sha384=_384;sha$1.sha512=_512;var ripemd={},utils$g=utils$o,common=common$5,rotl32=utils$g.rotl32,sum32=utils$g.sum32,sum32_3=utils$g.sum32_3,sum32_4=utils$g.sum32_4,BlockHash=common.BlockHash;function RIPEMD160$1(){if(!(this instanceof RIPEMD160$1))return new RIPEMD160$1;BlockHash.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.endian="little"}utils$g.inherits(RIPEMD160$1,BlockHash);ripemd.ripemd160=RIPEMD160$1;RIPEMD160$1.blockSize=512;RIPEMD160$1.outSize=160;RIPEMD160$1.hmacStrength=192;RIPEMD160$1.padLength=64;RIPEMD160$1.prototype._update=function(n,t){for(var c=this.h[0],ie=this.h[1],se=this.h[2],ae=this.h[3],ue=this.h[4],de=c,ve=ie,ge=se,we=ae,Te=ue,Ne=0;Ne<80;Ne++){var qe=sum32(rotl32(sum32_4(c,f$2(Ne,ie,se,ae),n[r$1[Ne]+t],K$3(Ne)),s$2[Ne]),ue);c=ue,ue=ae,ae=rotl32(se,10),se=ie,ie=qe,qe=sum32(rotl32(sum32_4(de,f$2(79-Ne,ve,ge,we),n[rh[Ne]+t],Kh(Ne)),sh[Ne]),Te),de=Te,Te=we,we=rotl32(ge,10),ge=ve,ve=qe}qe=sum32_3(this.h[1],se,we),this.h[1]=sum32_3(this.h[2],ae,Te),this.h[2]=sum32_3(this.h[3],ue,de),this.h[3]=sum32_3(this.h[4],c,ve),this.h[4]=sum32_3(this.h[0],ie,ge),this.h[0]=qe};RIPEMD160$1.prototype._digest=function(n){return n==="hex"?utils$g.toHex32(this.h,"little"):utils$g.split32(this.h,"little")};function f$2(n,t,c,ie){return n<=15?t^c^ie:n<=31?t&c|~t&ie:n<=47?(t|~c)^ie:n<=63?t&ie|c&~ie:t^(c|~ie)}function K$3(n){return n<=15?0:n<=31?1518500249:n<=47?1859775393:n<=63?2400959708:2840853838}function Kh(n){return n<=15?1352829926:n<=31?1548603684:n<=47?1836072691:n<=63?2053994217:0}var r$1=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13],rh=[5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11],s$2=[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6],sh=[8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11],utils$f=utils$o,assert$c=minimalisticAssert$1;function Hmac(n,t,c){if(!(this instanceof Hmac))return new Hmac(n,t,c);this.Hash=n,this.blockSize=n.blockSize/8,this.outSize=n.outSize/8,this.inner=null,this.outer=null,this._init(utils$f.toArray(t,c))}var hmac$1=Hmac;Hmac.prototype._init=function(n){n.length>this.blockSize&&(n=new this.Hash().update(n).digest()),assert$c(n.length<=this.blockSize);for(var t=n.length;t<this.blockSize;t++)n.push(0);for(t=0;t<n.length;t++)n[t]^=54;for(this.inner=new this.Hash().update(n),t=0;t<n.length;t++)n[t]^=106;this.outer=new this.Hash().update(n)};Hmac.prototype.update=function(n,t){return this.inner.update(n,t),this};Hmac.prototype.digest=function(n){return this.outer.update(this.inner.digest()),this.outer.digest(n)};(function(n){var t=n;t.utils=utils$o,t.common=common$5,t.sha=sha$1,t.ripemd=ripemd,t.hmac=hmac$1,t.sha1=t.sha.sha1,t.sha256=t.sha.sha256,t.sha224=t.sha.sha224,t.sha384=t.sha.sha384,t.sha512=t.sha.sha512,t.ripemd160=t.ripemd.ripemd160})(hash$4);const hash$3=getDefaultExportFromCjs$2(hash$4);function createCommonjsModule(n,t,c){return c={path:t,exports:{},require:function(ie,se){return commonjsRequire$1(ie,se??c.path)}},n(c,c.exports),c.exports}function commonjsRequire$1(){throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs")}var minimalisticAssert=assert$b;function assert$b(n,t){if(!n)throw new Error(t||"Assertion failed")}assert$b.equal=function(n,t,c){if(n!=t)throw new Error(c||"Assertion failed: "+n+" != "+t)};var utils_1$7=createCommonjsModule(function(n,t){var c=t;function ie(ue,de){if(Array.isArray(ue))return ue.slice();if(!ue)return[];var ve=[];if(typeof ue!="string"){for(var ge=0;ge<ue.length;ge++)ve[ge]=ue[ge]|0;return ve}if(de==="hex"){ue=ue.replace(/[^a-z0-9]+/ig,""),ue.length%2!==0&&(ue="0"+ue);for(var ge=0;ge<ue.length;ge+=2)ve.push(parseInt(ue[ge]+ue[ge+1],16))}else for(var ge=0;ge<ue.length;ge++){var we=ue.charCodeAt(ge),Te=we>>8,Ne=we&255;Te?ve.push(Te,Ne):ve.push(Ne)}return ve}c.toArray=ie;function se(ue){return ue.length===1?"0"+ue:ue}c.zero2=se;function ae(ue){for(var de="",ve=0;ve<ue.length;ve++)de+=se(ue[ve].toString(16));return de}c.toHex=ae,c.encode=function(ue,de){return de==="hex"?ae(ue):ue}}),utils_1$1$1=createCommonjsModule(function(n,t){var c=t;c.assert=minimalisticAssert,c.toArray=utils_1$7.toArray,c.zero2=utils_1$7.zero2,c.toHex=utils_1$7.toHex,c.encode=utils_1$7.encode;function ie(ve,ge,we){var Te=new Array(Math.max(ve.bitLength(),we)+1),Ne;for(Ne=0;Ne<Te.length;Ne+=1)Te[Ne]=0;var qe=1<<ge+1,ze=ve.clone();for(Ne=0;Ne<Te.length;Ne++){var He,Ge=ze.andln(qe-1);ze.isOdd()?(Ge>(qe>>1)-1?He=(qe>>1)-Ge:He=Ge,ze.isubn(He)):He=0,Te[Ne]=He,ze.iushrn(1)}return Te}c.getNAF=ie;function se(ve,ge){var we=[[],[]];ve=ve.clone(),ge=ge.clone();for(var Te=0,Ne=0,qe;ve.cmpn(-Te)>0||ge.cmpn(-Ne)>0;){var ze=ve.andln(3)+Te&3,He=ge.andln(3)+Ne&3;ze===3&&(ze=-1),He===3&&(He=-1);var Ge;ze&1?(qe=ve.andln(7)+Te&7,(qe===3||qe===5)&&He===2?Ge=-ze:Ge=ze):Ge=0,we[0].push(Ge);var Ze;He&1?(qe=ge.andln(7)+Ne&7,(qe===3||qe===5)&&ze===2?Ze=-He:Ze=He):Ze=0,we[1].push(Ze),2*Te===Ge+1&&(Te=1-Te),2*Ne===Ze+1&&(Ne=1-Ne),ve.iushrn(1),ge.iushrn(1)}return we}c.getJSF=se;function ae(ve,ge,we){var Te="_"+ge;ve.prototype[ge]=function(){return this[Te]!==void 0?this[Te]:this[Te]=we.call(this)}}c.cachedProperty=ae;function ue(ve){return typeof ve=="string"?c.toArray(ve,"hex"):ve}c.parseBytes=ue;function de(ve){return new BN$8(ve,"hex","le")}c.intFromLE=de}),getNAF$1=utils_1$1$1.getNAF,getJSF$1=utils_1$1$1.getJSF,assert$1$1=utils_1$1$1.assert;function BaseCurve$1(n,t){this.type=n,this.p=new BN$8(t.p,16),this.red=t.prime?BN$8.red(t.prime):BN$8.mont(this.p),this.zero=new BN$8(0).toRed(this.red),this.one=new BN$8(1).toRed(this.red),this.two=new BN$8(2).toRed(this.red),this.n=t.n&&new BN$8(t.n,16),this.g=t.g&&this.pointFromJSON(t.g,t.gRed),this._wnafT1=new Array(4),this._wnafT2=new Array(4),this._wnafT3=new Array(4),this._wnafT4=new Array(4),this._bitLength=this.n?this.n.bitLength():0;var c=this.n&&this.p.div(this.n);!c||c.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}var base$5=BaseCurve$1;BaseCurve$1.prototype.point=function(){throw new Error("Not implemented")};BaseCurve$1.prototype.validate=function(){throw new Error("Not implemented")};BaseCurve$1.prototype._fixedNafMul=function(n,t){assert$1$1(n.precomputed);var c=n._getDoubles(),ie=getNAF$1(t,1,this._bitLength),se=(1<<c.step+1)-(c.step%2===0?2:1);se/=3;var ae=[],ue,de;for(ue=0;ue<ie.length;ue+=c.step){de=0;for(var ve=ue+c.step-1;ve>=ue;ve--)de=(de<<1)+ie[ve];ae.push(de)}for(var ge=this.jpoint(null,null,null),we=this.jpoint(null,null,null),Te=se;Te>0;Te--){for(ue=0;ue<ae.length;ue++)de=ae[ue],de===Te?we=we.mixedAdd(c.points[ue]):de===-Te&&(we=we.mixedAdd(c.points[ue].neg()));ge=ge.add(we)}return ge.toP()};BaseCurve$1.prototype._wnafMul=function(n,t){var c=4,ie=n._getNAFPoints(c);c=ie.wnd;for(var se=ie.points,ae=getNAF$1(t,c,this._bitLength),ue=this.jpoint(null,null,null),de=ae.length-1;de>=0;de--){for(var ve=0;de>=0&&ae[de]===0;de--)ve++;if(de>=0&&ve++,ue=ue.dblp(ve),de<0)break;var ge=ae[de];assert$1$1(ge!==0),n.type==="affine"?ge>0?ue=ue.mixedAdd(se[ge-1>>1]):ue=ue.mixedAdd(se[-ge-1>>1].neg()):ge>0?ue=ue.add(se[ge-1>>1]):ue=ue.add(se[-ge-1>>1].neg())}return n.type==="affine"?ue.toP():ue};BaseCurve$1.prototype._wnafMulAdd=function(n,t,c,ie,se){var ae=this._wnafT1,ue=this._wnafT2,de=this._wnafT3,ve=0,ge,we,Te;for(ge=0;ge<ie;ge++){Te=t[ge];var Ne=Te._getNAFPoints(n);ae[ge]=Ne.wnd,ue[ge]=Ne.points}for(ge=ie-1;ge>=1;ge-=2){var qe=ge-1,ze=ge;if(ae[qe]!==1||ae[ze]!==1){de[qe]=getNAF$1(c[qe],ae[qe],this._bitLength),de[ze]=getNAF$1(c[ze],ae[ze],this._bitLength),ve=Math.max(de[qe].length,ve),ve=Math.max(de[ze].length,ve);continue}var He=[t[qe],null,null,t[ze]];t[qe].y.cmp(t[ze].y)===0?(He[1]=t[qe].add(t[ze]),He[2]=t[qe].toJ().mixedAdd(t[ze].neg())):t[qe].y.cmp(t[ze].y.redNeg())===0?(He[1]=t[qe].toJ().mixedAdd(t[ze]),He[2]=t[qe].add(t[ze].neg())):(He[1]=t[qe].toJ().mixedAdd(t[ze]),He[2]=t[qe].toJ().mixedAdd(t[ze].neg()));var Ge=[-3,-1,-5,-7,0,7,5,1,3],Ze=getJSF$1(c[qe],c[ze]);for(ve=Math.max(Ze[0].length,ve),de[qe]=new Array(ve),de[ze]=new Array(ve),we=0;we<ve;we++){var Ye=Ze[0][we]|0,Ft=Ze[1][we]|0;de[qe][we]=Ge[(Ye+1)*3+(Ft+1)],de[ze][we]=0,ue[qe]=He}}var Mt=this.jpoint(null,null,null),Zt=this._wnafT4;for(ge=ve;ge>=0;ge--){for(var cn=0;ge>=0;){var hn=!0;for(we=0;we<ie;we++)Zt[we]=de[we][ge]|0,Zt[we]!==0&&(hn=!1);if(!hn)break;cn++,ge--}if(ge>=0&&cn++,Mt=Mt.dblp(cn),ge<0)break;for(we=0;we<ie;we++){var yn=Zt[we];yn!==0&&(yn>0?Te=ue[we][yn-1>>1]:yn<0&&(Te=ue[we][-yn-1>>1].neg()),Te.type==="affine"?Mt=Mt.mixedAdd(Te):Mt=Mt.add(Te))}}for(ge=0;ge<ie;ge++)ue[ge]=null;return se?Mt:Mt.toP()};function BasePoint$1(n,t){this.curve=n,this.type=t,this.precomputed=null}BaseCurve$1.BasePoint=BasePoint$1;BasePoint$1.prototype.eq=function(){throw new Error("Not implemented")};BasePoint$1.prototype.validate=function(){return this.curve.validate(this)};BaseCurve$1.prototype.decodePoint=function(n,t){n=utils_1$1$1.toArray(n,t);var c=this.p.byteLength();if((n[0]===4||n[0]===6||n[0]===7)&&n.length-1===2*c){n[0]===6?assert$1$1(n[n.length-1]%2===0):n[0]===7&&assert$1$1(n[n.length-1]%2===1);var ie=this.point(n.slice(1,1+c),n.slice(1+c,1+2*c));return ie}else if((n[0]===2||n[0]===3)&&n.length-1===c)return this.pointFromX(n.slice(1,1+c),n[0]===3);throw new Error("Unknown point format")};BasePoint$1.prototype.encodeCompressed=function(n){return this.encode(n,!0)};BasePoint$1.prototype._encode=function(n){var t=this.curve.p.byteLength(),c=this.getX().toArray("be",t);return n?[this.getY().isEven()?2:3].concat(c):[4].concat(c,this.getY().toArray("be",t))};BasePoint$1.prototype.encode=function(n,t){return utils_1$1$1.encode(this._encode(t),n)};BasePoint$1.prototype.precompute=function(n){if(this.precomputed)return this;var t={doubles:null,naf:null,beta:null};return t.naf=this._getNAFPoints(8),t.doubles=this._getDoubles(4,n),t.beta=this._getBeta(),this.precomputed=t,this};BasePoint$1.prototype._hasDoubles=function(n){if(!this.precomputed)return!1;var t=this.precomputed.doubles;return t?t.points.length>=Math.ceil((n.bitLength()+1)/t.step):!1};BasePoint$1.prototype._getDoubles=function(n,t){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var c=[this],ie=this,se=0;se<t;se+=n){for(var ae=0;ae<n;ae++)ie=ie.dbl();c.push(ie)}return{step:n,points:c}};BasePoint$1.prototype._getNAFPoints=function(n){if(this.precomputed&&this.precomputed.naf)return this.precomputed.naf;for(var t=[this],c=(1<<n)-1,ie=c===1?null:this.dbl(),se=1;se<c;se++)t[se]=t[se-1].add(ie);return{wnd:n,points:t}};BasePoint$1.prototype._getBeta=function(){return null};BasePoint$1.prototype.dblp=function(n){for(var t=this,c=0;c<n;c++)t=t.dbl();return t};var inherits_browser=createCommonjsModule(function(n){typeof Object.create=="function"?n.exports=function(t,c){c&&(t.super_=c,t.prototype=Object.create(c.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}))}:n.exports=function(t,c){if(c){t.super_=c;var ie=function(){};ie.prototype=c.prototype,t.prototype=new ie,t.prototype.constructor=t}}}),assert$2$1=utils_1$1$1.assert;function ShortCurve$1(n){base$5.call(this,"short",n),this.a=new BN$8(n.a,16).toRed(this.red),this.b=new BN$8(n.b,16).toRed(this.red),this.tinv=this.two.redInvm(),this.zeroA=this.a.fromRed().cmpn(0)===0,this.threeA=this.a.fromRed().sub(this.p).cmpn(-3)===0,this.endo=this._getEndomorphism(n),this._endoWnafT1=new Array(4),this._endoWnafT2=new Array(4)}inherits_browser(ShortCurve$1,base$5);var short_1=ShortCurve$1;ShortCurve$1.prototype._getEndomorphism=function(n){if(!(!this.zeroA||!this.g||!this.n||this.p.modn(3)!==1)){var t,c;if(n.beta)t=new BN$8(n.beta,16).toRed(this.red);else{var ie=this._getEndoRoots(this.p);t=ie[0].cmp(ie[1])<0?ie[0]:ie[1],t=t.toRed(this.red)}if(n.lambda)c=new BN$8(n.lambda,16);else{var se=this._getEndoRoots(this.n);this.g.mul(se[0]).x.cmp(this.g.x.redMul(t))===0?c=se[0]:(c=se[1],assert$2$1(this.g.mul(c).x.cmp(this.g.x.redMul(t))===0))}var ae;return n.basis?ae=n.basis.map(function(ue){return{a:new BN$8(ue.a,16),b:new BN$8(ue.b,16)}}):ae=this._getEndoBasis(c),{beta:t,lambda:c,basis:ae}}};ShortCurve$1.prototype._getEndoRoots=function(n){var t=n===this.p?this.red:BN$8.mont(n),c=new BN$8(2).toRed(t).redInvm(),ie=c.redNeg(),se=new BN$8(3).toRed(t).redNeg().redSqrt().redMul(c),ae=ie.redAdd(se).fromRed(),ue=ie.redSub(se).fromRed();return[ae,ue]};ShortCurve$1.prototype._getEndoBasis=function(n){for(var t=this.n.ushrn(Math.floor(this.n.bitLength()/2)),c=n,ie=this.n.clone(),se=new BN$8(1),ae=new BN$8(0),ue=new BN$8(0),de=new BN$8(1),ve,ge,we,Te,Ne,qe,ze,He=0,Ge,Ze;c.cmpn(0)!==0;){var Ye=ie.div(c);Ge=ie.sub(Ye.mul(c)),Ze=ue.sub(Ye.mul(se));var Ft=de.sub(Ye.mul(ae));if(!we&&Ge.cmp(t)<0)ve=ze.neg(),ge=se,we=Ge.neg(),Te=Ze;else if(we&&++He===2)break;ze=Ge,ie=c,c=Ge,ue=se,se=Ze,de=ae,ae=Ft}Ne=Ge.neg(),qe=Ze;var Mt=we.sqr().add(Te.sqr()),Zt=Ne.sqr().add(qe.sqr());return Zt.cmp(Mt)>=0&&(Ne=ve,qe=ge),we.negative&&(we=we.neg(),Te=Te.neg()),Ne.negative&&(Ne=Ne.neg(),qe=qe.neg()),[{a:we,b:Te},{a:Ne,b:qe}]};ShortCurve$1.prototype._endoSplit=function(n){var t=this.endo.basis,c=t[0],ie=t[1],se=ie.b.mul(n).divRound(this.n),ae=c.b.neg().mul(n).divRound(this.n),ue=se.mul(c.a),de=ae.mul(ie.a),ve=se.mul(c.b),ge=ae.mul(ie.b),we=n.sub(ue).sub(de),Te=ve.add(ge).neg();return{k1:we,k2:Te}};ShortCurve$1.prototype.pointFromX=function(n,t){n=new BN$8(n,16),n.red||(n=n.toRed(this.red));var c=n.redSqr().redMul(n).redIAdd(n.redMul(this.a)).redIAdd(this.b),ie=c.redSqrt();if(ie.redSqr().redSub(c).cmp(this.zero)!==0)throw new Error("invalid point");var se=ie.fromRed().isOdd();return(t&&!se||!t&&se)&&(ie=ie.redNeg()),this.point(n,ie)};ShortCurve$1.prototype.validate=function(n){if(n.inf)return!0;var t=n.x,c=n.y,ie=this.a.redMul(t),se=t.redSqr().redMul(t).redIAdd(ie).redIAdd(this.b);return c.redSqr().redISub(se).cmpn(0)===0};ShortCurve$1.prototype._endoWnafMulAdd=function(n,t,c){for(var ie=this._endoWnafT1,se=this._endoWnafT2,ae=0;ae<n.length;ae++){var ue=this._endoSplit(t[ae]),de=n[ae],ve=de._getBeta();ue.k1.negative&&(ue.k1.ineg(),de=de.neg(!0)),ue.k2.negative&&(ue.k2.ineg(),ve=ve.neg(!0)),ie[ae*2]=de,ie[ae*2+1]=ve,se[ae*2]=ue.k1,se[ae*2+1]=ue.k2}for(var ge=this._wnafMulAdd(1,ie,se,ae*2,c),we=0;we<ae*2;we++)ie[we]=null,se[we]=null;return ge};function Point$3(n,t,c,ie){base$5.BasePoint.call(this,n,"affine"),t===null&&c===null?(this.x=null,this.y=null,this.inf=!0):(this.x=new BN$8(t,16),this.y=new BN$8(c,16),ie&&(this.x.forceRed(this.curve.red),this.y.forceRed(this.curve.red)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.inf=!1)}inherits_browser(Point$3,base$5.BasePoint);ShortCurve$1.prototype.point=function(n,t,c){return new Point$3(this,n,t,c)};ShortCurve$1.prototype.pointFromJSON=function(n,t){return Point$3.fromJSON(this,n,t)};Point$3.prototype._getBeta=function(){if(this.curve.endo){var n=this.precomputed;if(n&&n.beta)return n.beta;var t=this.curve.point(this.x.redMul(this.curve.endo.beta),this.y);if(n){var c=this.curve,ie=function(se){return c.point(se.x.redMul(c.endo.beta),se.y)};n.beta=t,t.precomputed={beta:null,naf:n.naf&&{wnd:n.naf.wnd,points:n.naf.points.map(ie)},doubles:n.doubles&&{step:n.doubles.step,points:n.doubles.points.map(ie)}}}return t}};Point$3.prototype.toJSON=function(){return this.precomputed?[this.x,this.y,this.precomputed&&{doubles:this.precomputed.doubles&&{step:this.precomputed.doubles.step,points:this.precomputed.doubles.points.slice(1)},naf:this.precomputed.naf&&{wnd:this.precomputed.naf.wnd,points:this.precomputed.naf.points.slice(1)}}]:[this.x,this.y]};Point$3.fromJSON=function(n,t,c){typeof t=="string"&&(t=JSON.parse(t));var ie=n.point(t[0],t[1],c);if(!t[2])return ie;function se(ue){return n.point(ue[0],ue[1],c)}var ae=t[2];return ie.precomputed={beta:null,doubles:ae.doubles&&{step:ae.doubles.step,points:[ie].concat(ae.doubles.points.map(se))},naf:ae.naf&&{wnd:ae.naf.wnd,points:[ie].concat(ae.naf.points.map(se))}},ie};Point$3.prototype.inspect=function(){return this.isInfinity()?"<EC Point Infinity>":"<EC Point x: "+this.x.fromRed().toString(16,2)+" y: "+this.y.fromRed().toString(16,2)+">"};Point$3.prototype.isInfinity=function(){return this.inf};Point$3.prototype.add=function(n){if(this.inf)return n;if(n.inf)return this;if(this.eq(n))return this.dbl();if(this.neg().eq(n))return this.curve.point(null,null);if(this.x.cmp(n.x)===0)return this.curve.point(null,null);var t=this.y.redSub(n.y);t.cmpn(0)!==0&&(t=t.redMul(this.x.redSub(n.x).redInvm()));var c=t.redSqr().redISub(this.x).redISub(n.x),ie=t.redMul(this.x.redSub(c)).redISub(this.y);return this.curve.point(c,ie)};Point$3.prototype.dbl=function(){if(this.inf)return this;var n=this.y.redAdd(this.y);if(n.cmpn(0)===0)return this.curve.point(null,null);var t=this.curve.a,c=this.x.redSqr(),ie=n.redInvm(),se=c.redAdd(c).redIAdd(c).redIAdd(t).redMul(ie),ae=se.redSqr().redISub(this.x.redAdd(this.x)),ue=se.redMul(this.x.redSub(ae)).redISub(this.y);return this.curve.point(ae,ue)};Point$3.prototype.getX=function(){return this.x.fromRed()};Point$3.prototype.getY=function(){return this.y.fromRed()};Point$3.prototype.mul=function(n){return n=new BN$8(n,16),this.isInfinity()?this:this._hasDoubles(n)?this.curve._fixedNafMul(this,n):this.curve.endo?this.curve._endoWnafMulAdd([this],[n]):this.curve._wnafMul(this,n)};Point$3.prototype.mulAdd=function(n,t,c){var ie=[this,t],se=[n,c];return this.curve.endo?this.curve._endoWnafMulAdd(ie,se):this.curve._wnafMulAdd(1,ie,se,2)};Point$3.prototype.jmulAdd=function(n,t,c){var ie=[this,t],se=[n,c];return this.curve.endo?this.curve._endoWnafMulAdd(ie,se,!0):this.curve._wnafMulAdd(1,ie,se,2,!0)};Point$3.prototype.eq=function(n){return this===n||this.inf===n.inf&&(this.inf||this.x.cmp(n.x)===0&&this.y.cmp(n.y)===0)};Point$3.prototype.neg=function(n){if(this.inf)return this;var t=this.curve.point(this.x,this.y.redNeg());if(n&&this.precomputed){var c=this.precomputed,ie=function(se){return se.neg()};t.precomputed={naf:c.naf&&{wnd:c.naf.wnd,points:c.naf.points.map(ie)},doubles:c.doubles&&{step:c.doubles.step,points:c.doubles.points.map(ie)}}}return t};Point$3.prototype.toJ=function(){if(this.inf)return this.curve.jpoint(null,null,null);var n=this.curve.jpoint(this.x,this.y,this.curve.one);return n};function JPoint$1(n,t,c,ie){base$5.BasePoint.call(this,n,"jacobian"),t===null&&c===null&&ie===null?(this.x=this.curve.one,this.y=this.curve.one,this.z=new BN$8(0)):(this.x=new BN$8(t,16),this.y=new BN$8(c,16),this.z=new BN$8(ie,16)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.zOne=this.z===this.curve.one}inherits_browser(JPoint$1,base$5.BasePoint);ShortCurve$1.prototype.jpoint=function(n,t,c){return new JPoint$1(this,n,t,c)};JPoint$1.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var n=this.z.redInvm(),t=n.redSqr(),c=this.x.redMul(t),ie=this.y.redMul(t).redMul(n);return this.curve.point(c,ie)};JPoint$1.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)};JPoint$1.prototype.add=function(n){if(this.isInfinity())return n;if(n.isInfinity())return this;var t=n.z.redSqr(),c=this.z.redSqr(),ie=this.x.redMul(t),se=n.x.redMul(c),ae=this.y.redMul(t.redMul(n.z)),ue=n.y.redMul(c.redMul(this.z)),de=ie.redSub(se),ve=ae.redSub(ue);if(de.cmpn(0)===0)return ve.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var ge=de.redSqr(),we=ge.redMul(de),Te=ie.redMul(ge),Ne=ve.redSqr().redIAdd(we).redISub(Te).redISub(Te),qe=ve.redMul(Te.redISub(Ne)).redISub(ae.redMul(we)),ze=this.z.redMul(n.z).redMul(de);return this.curve.jpoint(Ne,qe,ze)};JPoint$1.prototype.mixedAdd=function(n){if(this.isInfinity())return n.toJ();if(n.isInfinity())return this;var t=this.z.redSqr(),c=this.x,ie=n.x.redMul(t),se=this.y,ae=n.y.redMul(t).redMul(this.z),ue=c.redSub(ie),de=se.redSub(ae);if(ue.cmpn(0)===0)return de.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var ve=ue.redSqr(),ge=ve.redMul(ue),we=c.redMul(ve),Te=de.redSqr().redIAdd(ge).redISub(we).redISub(we),Ne=de.redMul(we.redISub(Te)).redISub(se.redMul(ge)),qe=this.z.redMul(ue);return this.curve.jpoint(Te,Ne,qe)};JPoint$1.prototype.dblp=function(n){if(n===0)return this;if(this.isInfinity())return this;if(!n)return this.dbl();var t;if(this.curve.zeroA||this.curve.threeA){var c=this;for(t=0;t<n;t++)c=c.dbl();return c}var ie=this.curve.a,se=this.curve.tinv,ae=this.x,ue=this.y,de=this.z,ve=de.redSqr().redSqr(),ge=ue.redAdd(ue);for(t=0;t<n;t++){var we=ae.redSqr(),Te=ge.redSqr(),Ne=Te.redSqr(),qe=we.redAdd(we).redIAdd(we).redIAdd(ie.redMul(ve)),ze=ae.redMul(Te),He=qe.redSqr().redISub(ze.redAdd(ze)),Ge=ze.redISub(He),Ze=qe.redMul(Ge);Ze=Ze.redIAdd(Ze).redISub(Ne);var Ye=ge.redMul(de);t+1<n&&(ve=ve.redMul(Ne)),ae=He,de=Ye,ge=Ze}return this.curve.jpoint(ae,ge.redMul(se),de)};JPoint$1.prototype.dbl=function(){return this.isInfinity()?this:this.curve.zeroA?this._zeroDbl():this.curve.threeA?this._threeDbl():this._dbl()};JPoint$1.prototype._zeroDbl=function(){var n,t,c;if(this.zOne){var ie=this.x.redSqr(),se=this.y.redSqr(),ae=se.redSqr(),ue=this.x.redAdd(se).redSqr().redISub(ie).redISub(ae);ue=ue.redIAdd(ue);var de=ie.redAdd(ie).redIAdd(ie),ve=de.redSqr().redISub(ue).redISub(ue),ge=ae.redIAdd(ae);ge=ge.redIAdd(ge),ge=ge.redIAdd(ge),n=ve,t=de.redMul(ue.redISub(ve)).redISub(ge),c=this.y.redAdd(this.y)}else{var we=this.x.redSqr(),Te=this.y.redSqr(),Ne=Te.redSqr(),qe=this.x.redAdd(Te).redSqr().redISub(we).redISub(Ne);qe=qe.redIAdd(qe);var ze=we.redAdd(we).redIAdd(we),He=ze.redSqr(),Ge=Ne.redIAdd(Ne);Ge=Ge.redIAdd(Ge),Ge=Ge.redIAdd(Ge),n=He.redISub(qe).redISub(qe),t=ze.redMul(qe.redISub(n)).redISub(Ge),c=this.y.redMul(this.z),c=c.redIAdd(c)}return this.curve.jpoint(n,t,c)};JPoint$1.prototype._threeDbl=function(){var n,t,c;if(this.zOne){var ie=this.x.redSqr(),se=this.y.redSqr(),ae=se.redSqr(),ue=this.x.redAdd(se).redSqr().redISub(ie).redISub(ae);ue=ue.redIAdd(ue);var de=ie.redAdd(ie).redIAdd(ie).redIAdd(this.curve.a),ve=de.redSqr().redISub(ue).redISub(ue);n=ve;var ge=ae.redIAdd(ae);ge=ge.redIAdd(ge),ge=ge.redIAdd(ge),t=de.redMul(ue.redISub(ve)).redISub(ge),c=this.y.redAdd(this.y)}else{var we=this.z.redSqr(),Te=this.y.redSqr(),Ne=this.x.redMul(Te),qe=this.x.redSub(we).redMul(this.x.redAdd(we));qe=qe.redAdd(qe).redIAdd(qe);var ze=Ne.redIAdd(Ne);ze=ze.redIAdd(ze);var He=ze.redAdd(ze);n=qe.redSqr().redISub(He),c=this.y.redAdd(this.z).redSqr().redISub(Te).redISub(we);var Ge=Te.redSqr();Ge=Ge.redIAdd(Ge),Ge=Ge.redIAdd(Ge),Ge=Ge.redIAdd(Ge),t=qe.redMul(ze.redISub(n)).redISub(Ge)}return this.curve.jpoint(n,t,c)};JPoint$1.prototype._dbl=function(){var n=this.curve.a,t=this.x,c=this.y,ie=this.z,se=ie.redSqr().redSqr(),ae=t.redSqr(),ue=c.redSqr(),de=ae.redAdd(ae).redIAdd(ae).redIAdd(n.redMul(se)),ve=t.redAdd(t);ve=ve.redIAdd(ve);var ge=ve.redMul(ue),we=de.redSqr().redISub(ge.redAdd(ge)),Te=ge.redISub(we),Ne=ue.redSqr();Ne=Ne.redIAdd(Ne),Ne=Ne.redIAdd(Ne),Ne=Ne.redIAdd(Ne);var qe=de.redMul(Te).redISub(Ne),ze=c.redAdd(c).redMul(ie);return this.curve.jpoint(we,qe,ze)};JPoint$1.prototype.trpl=function(){if(!this.curve.zeroA)return this.dbl().add(this);var n=this.x.redSqr(),t=this.y.redSqr(),c=this.z.redSqr(),ie=t.redSqr(),se=n.redAdd(n).redIAdd(n),ae=se.redSqr(),ue=this.x.redAdd(t).redSqr().redISub(n).redISub(ie);ue=ue.redIAdd(ue),ue=ue.redAdd(ue).redIAdd(ue),ue=ue.redISub(ae);var de=ue.redSqr(),ve=ie.redIAdd(ie);ve=ve.redIAdd(ve),ve=ve.redIAdd(ve),ve=ve.redIAdd(ve);var ge=se.redIAdd(ue).redSqr().redISub(ae).redISub(de).redISub(ve),we=t.redMul(ge);we=we.redIAdd(we),we=we.redIAdd(we);var Te=this.x.redMul(de).redISub(we);Te=Te.redIAdd(Te),Te=Te.redIAdd(Te);var Ne=this.y.redMul(ge.redMul(ve.redISub(ge)).redISub(ue.redMul(de)));Ne=Ne.redIAdd(Ne),Ne=Ne.redIAdd(Ne),Ne=Ne.redIAdd(Ne);var qe=this.z.redAdd(ue).redSqr().redISub(c).redISub(de);return this.curve.jpoint(Te,Ne,qe)};JPoint$1.prototype.mul=function(n,t){return n=new BN$8(n,t),this.curve._wnafMul(this,n)};JPoint$1.prototype.eq=function(n){if(n.type==="affine")return this.eq(n.toJ());if(this===n)return!0;var t=this.z.redSqr(),c=n.z.redSqr();if(this.x.redMul(c).redISub(n.x.redMul(t)).cmpn(0)!==0)return!1;var ie=t.redMul(this.z),se=c.redMul(n.z);return this.y.redMul(se).redISub(n.y.redMul(ie)).cmpn(0)===0};JPoint$1.prototype.eqXToP=function(n){var t=this.z.redSqr(),c=n.toRed(this.curve.red).redMul(t);if(this.x.cmp(c)===0)return!0;for(var ie=n.clone(),se=this.curve.redN.redMul(t);;){if(ie.iadd(this.curve.n),ie.cmp(this.curve.p)>=0)return!1;if(c.redIAdd(se),this.x.cmp(c)===0)return!0}};JPoint$1.prototype.inspect=function(){return this.isInfinity()?"<EC JPoint Infinity>":"<EC JPoint x: "+this.x.toString(16,2)+" y: "+this.y.toString(16,2)+" z: "+this.z.toString(16,2)+">"};JPoint$1.prototype.isInfinity=function(){return this.z.cmpn(0)===0};var curve_1=createCommonjsModule(function(n,t){var c=t;c.base=base$5,c.short=short_1,c.mont=null,c.edwards=null}),curves_1=createCommonjsModule(function(n,t){var c=t,ie=utils_1$1$1.assert;function se(de){de.type==="short"?this.curve=new curve_1.short(de):de.type==="edwards"?this.curve=new curve_1.edwards(de):this.curve=new curve_1.mont(de),this.g=this.curve.g,this.n=this.curve.n,this.hash=de.hash,ie(this.g.validate(),"Invalid curve"),ie(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}c.PresetCurve=se;function ae(de,ve){Object.defineProperty(c,de,{configurable:!0,enumerable:!0,get:function(){var ge=new se(ve);return Object.defineProperty(c,de,{configurable:!0,enumerable:!0,value:ge}),ge}})}ae("p192",{type:"short",prime:"p192",p:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff",a:"ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc",b:"64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1",n:"ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831",hash:hash$3.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]}),ae("p224",{type:"short",prime:"p224",p:"ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001",a:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe",b:"b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4",n:"ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d",hash:hash$3.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]}),ae("p256",{type:"short",prime:null,p:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff",a:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc",b:"5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b",n:"ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551",hash:hash$3.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]}),ae("p384",{type:"short",prime:null,p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 ffffffff",a:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 fffffffc",b:"b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f 5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef",n:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 f4372ddf 581a0db2 48b0a77a ecec196a ccc52973",hash:hash$3.sha384,gRed:!1,g:["aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 5502f25d bf55296c 3a545e38 72760ab7","3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 0a60b1ce 1d7e819d 7a431d7c 90ea0e5f"]}),ae("p521",{type:"short",prime:null,p:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff",a:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffc",b:"00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b 99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd 3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00",n:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409",hash:hash$3.sha512,gRed:!1,g:["000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66","00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 3fad0761 353c7086 a272c240 88be9476 9fd16650"]}),ae("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:hash$3.sha256,gRed:!1,g:["9"]}),ae("ed25519",{type:"edwards",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"-1",c:"1",d:"52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:hash$3.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});var ue;try{ue=null.crash()}catch{ue=void 0}ae("secp256k1",{type:"short",prime:"k256",p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f",a:"0",b:"7",n:"ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141",h:"1",hash:hash$3.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",ue]})});function HmacDRBG$1(n){if(!(this instanceof HmacDRBG$1))return new HmacDRBG$1(n);this.hash=n.hash,this.predResist=!!n.predResist,this.outLen=this.hash.outSize,this.minEntropy=n.minEntropy||this.hash.hmacStrength,this._reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var t=utils_1$7.toArray(n.entropy,n.entropyEnc||"hex"),c=utils_1$7.toArray(n.nonce,n.nonceEnc||"hex"),ie=utils_1$7.toArray(n.pers,n.persEnc||"hex");minimalisticAssert(t.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(t,c,ie)}var hmacDrbg$1=HmacDRBG$1;HmacDRBG$1.prototype._init=function(n,t,c){var ie=n.concat(t).concat(c);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var se=0;se<this.V.length;se++)this.K[se]=0,this.V[se]=1;this._update(ie),this._reseed=1,this.reseedInterval=281474976710656};HmacDRBG$1.prototype._hmac=function(){return new hash$3.hmac(this.hash,this.K)};HmacDRBG$1.prototype._update=function(n){var t=this._hmac().update(this.V).update([0]);n&&(t=t.update(n)),this.K=t.digest(),this.V=this._hmac().update(this.V).digest(),n&&(this.K=this._hmac().update(this.V).update([1]).update(n).digest(),this.V=this._hmac().update(this.V).digest())};HmacDRBG$1.prototype.reseed=function(n,t,c,ie){typeof t!="string"&&(ie=c,c=t,t=null),n=utils_1$7.toArray(n,t),c=utils_1$7.toArray(c,ie),minimalisticAssert(n.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(n.concat(c||[])),this._reseed=1};HmacDRBG$1.prototype.generate=function(n,t,c,ie){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");typeof t!="string"&&(ie=c,c=t,t=null),c&&(c=utils_1$7.toArray(c,ie||"hex"),this._update(c));for(var se=[];se.length<n;)this.V=this._hmac().update(this.V).digest(),se=se.concat(this.V);var ae=se.slice(0,n);return this._update(c),this._reseed++,utils_1$7.encode(ae,t)};var assert$3$1=utils_1$1$1.assert;function KeyPair$3(n,t){this.ec=n,this.priv=null,this.pub=null,t.priv&&this._importPrivate(t.priv,t.privEnc),t.pub&&this._importPublic(t.pub,t.pubEnc)}var key$2=KeyPair$3;KeyPair$3.fromPublic=function(n,t,c){return t instanceof KeyPair$3?t:new KeyPair$3(n,{pub:t,pubEnc:c})};KeyPair$3.fromPrivate=function(n,t,c){return t instanceof KeyPair$3?t:new KeyPair$3(n,{priv:t,privEnc:c})};KeyPair$3.prototype.validate=function(){var n=this.getPublic();return n.isInfinity()?{result:!1,reason:"Invalid public key"}:n.validate()?n.mul(this.ec.curve.n).isInfinity()?{result:!0,reason:null}:{result:!1,reason:"Public key * N != O"}:{result:!1,reason:"Public key is not a point"}};KeyPair$3.prototype.getPublic=function(n,t){return typeof n=="string"&&(t=n,n=null),this.pub||(this.pub=this.ec.g.mul(this.priv)),t?this.pub.encode(t,n):this.pub};KeyPair$3.prototype.getPrivate=function(n){return n==="hex"?this.priv.toString(16,2):this.priv};KeyPair$3.prototype._importPrivate=function(n,t){this.priv=new BN$8(n,t||16),this.priv=this.priv.umod(this.ec.curve.n)};KeyPair$3.prototype._importPublic=function(n,t){if(n.x||n.y){this.ec.curve.type==="mont"?assert$3$1(n.x,"Need x coordinate"):(this.ec.curve.type==="short"||this.ec.curve.type==="edwards")&&assert$3$1(n.x&&n.y,"Need both x and y coordinate"),this.pub=this.ec.curve.point(n.x,n.y);return}this.pub=this.ec.curve.decodePoint(n,t)};KeyPair$3.prototype.derive=function(n){return n.validate()||assert$3$1(n.validate(),"public point not validated"),n.mul(this.priv).getX()};KeyPair$3.prototype.sign=function(n,t,c){return this.ec.sign(n,this,t,c)};KeyPair$3.prototype.verify=function(n,t,c){return this.ec.verify(n,t,this,void 0,c)};KeyPair$3.prototype.inspect=function(){return"<Key priv: "+(this.priv&&this.priv.toString(16,2))+" pub: "+(this.pub&&this.pub.inspect())+" >"};var assert$4$1=utils_1$1$1.assert;function Signature$3(n,t){if(n instanceof Signature$3)return n;this._importDER(n,t)||(assert$4$1(n.r&&n.s,"Signature without r or s"),this.r=new BN$8(n.r,16),this.s=new BN$8(n.s,16),n.recoveryParam===void 0?this.recoveryParam=null:this.recoveryParam=n.recoveryParam)}var signature$3=Signature$3;function Position$1(){this.place=0}function getLength$1(n,t){var c=n[t.place++];if(!(c&128))return c;var ie=c&15;if(ie===0||ie>4||n[t.place]===0)return!1;for(var se=0,ae=0,ue=t.place;ae<ie;ae++,ue++)se<<=8,se|=n[ue],se>>>=0;return se<=127?!1:(t.place=ue,se)}function rmPadding$1(n){for(var t=0,c=n.length-1;!n[t]&&!(n[t+1]&128)&&t<c;)t++;return t===0?n:n.slice(t)}Signature$3.prototype._importDER=function(n,t){n=utils_1$1$1.toArray(n,t);var c=new Position$1;if(n[c.place++]!==48)return!1;var ie=getLength$1(n,c);if(ie===!1||ie+c.place!==n.length||n[c.place++]!==2)return!1;var se=getLength$1(n,c);if(se===!1||n[c.place]&128)return!1;var ae=n.slice(c.place,se+c.place);if(c.place+=se,n[c.place++]!==2)return!1;var ue=getLength$1(n,c);if(ue===!1||n.length!==ue+c.place||n[c.place]&128)return!1;var de=n.slice(c.place,ue+c.place);if(ae[0]===0)if(ae[1]&128)ae=ae.slice(1);else return!1;if(de[0]===0)if(de[1]&128)de=de.slice(1);else return!1;return this.r=new BN$8(ae),this.s=new BN$8(de),this.recoveryParam=null,!0};function constructLength$1(n,t){if(t<128){n.push(t);return}var c=1+(Math.log(t)/Math.LN2>>>3);for(n.push(c|128);--c;)n.push(t>>>(c<<3)&255);n.push(t)}Signature$3.prototype.toDER=function(n){var t=this.r.toArray(),c=this.s.toArray();for(t[0]&128&&(t=[0].concat(t)),c[0]&128&&(c=[0].concat(c)),t=rmPadding$1(t),c=rmPadding$1(c);!c[0]&&!(c[1]&128);)c=c.slice(1);var ie=[2];constructLength$1(ie,t.length),ie=ie.concat(t),ie.push(2),constructLength$1(ie,c.length);var se=ie.concat(c),ae=[48];return constructLength$1(ae,se.length),ae=ae.concat(se),utils_1$1$1.encode(ae,n)};var rand=(function(){throw new Error("unsupported")}),assert$5$1=utils_1$1$1.assert;function EC(n){if(!(this instanceof EC))return new EC(n);typeof n=="string"&&(assert$5$1(Object.prototype.hasOwnProperty.call(curves_1,n),"Unknown curve "+n),n=curves_1[n]),n instanceof curves_1.PresetCurve&&(n={curve:n}),this.curve=n.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=n.curve.g,this.g.precompute(n.curve.n.bitLength()+1),this.hash=n.hash||n.curve.hash}var ec$1=EC;EC.prototype.keyPair=function(n){return new key$2(this,n)};EC.prototype.keyFromPrivate=function(n,t){return key$2.fromPrivate(this,n,t)};EC.prototype.keyFromPublic=function(n,t){return key$2.fromPublic(this,n,t)};EC.prototype.genKeyPair=function(n){n||(n={});for(var t=new hmacDrbg$1({hash:this.hash,pers:n.pers,persEnc:n.persEnc||"utf8",entropy:n.entropy||rand(this.hash.hmacStrength),entropyEnc:n.entropy&&n.entropyEnc||"utf8",nonce:this.n.toArray()}),c=this.n.byteLength(),ie=this.n.sub(new BN$8(2));;){var se=new BN$8(t.generate(c));if(!(se.cmp(ie)>0))return se.iaddn(1),this.keyFromPrivate(se)}};EC.prototype._truncateToN=function(n,t,c){var ie;if(BN$8.isBN(n)||typeof n=="number")n=new BN$8(n,16),ie=n.byteLength();else if(typeof n=="object")ie=n.length,n=new BN$8(n,16);else{var se=n.toString();ie=se.length+1>>>1,n=new BN$8(se,16)}typeof c!="number"&&(c=ie*8);var ae=c-this.n.bitLength();return ae>0&&(n=n.ushrn(ae)),!t&&n.cmp(this.n)>=0?n.sub(this.n):n};EC.prototype.sign=function(n,t,c,ie){if(typeof c=="object"&&(ie=c,c=null),ie||(ie={}),typeof n!="string"&&typeof n!="number"&&!BN$8.isBN(n)){assert$5$1(typeof n=="object"&&n&&typeof n.length=="number","Expected message to be an array-like, a hex string, or a BN instance"),assert$5$1(n.length>>>0===n.length);for(var se=0;se<n.length;se++)assert$5$1((n[se]&255)===n[se])}t=this.keyFromPrivate(t,c),n=this._truncateToN(n,!1,ie.msgBitLength),assert$5$1(!n.isNeg(),"Can not sign a negative message");var ae=this.n.byteLength(),ue=t.getPrivate().toArray("be",ae),de=n.toArray("be",ae);assert$5$1(new BN$8(de).eq(n),"Can not sign message");for(var ve=new hmacDrbg$1({hash:this.hash,entropy:ue,nonce:de,pers:ie.pers,persEnc:ie.persEnc||"utf8"}),ge=this.n.sub(new BN$8(1)),we=0;;we++){var Te=ie.k?ie.k(we):new BN$8(ve.generate(this.n.byteLength()));if(Te=this._truncateToN(Te,!0),!(Te.cmpn(1)<=0||Te.cmp(ge)>=0)){var Ne=this.g.mul(Te);if(!Ne.isInfinity()){var qe=Ne.getX(),ze=qe.umod(this.n);if(ze.cmpn(0)!==0){var He=Te.invm(this.n).mul(ze.mul(t.getPrivate()).iadd(n));if(He=He.umod(this.n),He.cmpn(0)!==0){var Ge=(Ne.getY().isOdd()?1:0)|(qe.cmp(ze)!==0?2:0);return ie.canonical&&He.cmp(this.nh)>0&&(He=this.n.sub(He),Ge^=1),new signature$3({r:ze,s:He,recoveryParam:Ge})}}}}}};EC.prototype.verify=function(n,t,c,ie,se){se||(se={}),n=this._truncateToN(n,!1,se.msgBitLength),c=this.keyFromPublic(c,ie),t=new signature$3(t,"hex");var ae=t.r,ue=t.s;if(ae.cmpn(1)<0||ae.cmp(this.n)>=0||ue.cmpn(1)<0||ue.cmp(this.n)>=0)return!1;var de=ue.invm(this.n),ve=de.mul(n).umod(this.n),ge=de.mul(ae).umod(this.n),we;return this.curve._maxwellTrick?(we=this.g.jmulAdd(ve,c.getPublic(),ge),we.isInfinity()?!1:we.eqXToP(ae)):(we=this.g.mulAdd(ve,c.getPublic(),ge),we.isInfinity()?!1:we.getX().umod(this.n).cmp(ae)===0)};EC.prototype.recoverPubKey=function(n,t,c,ie){assert$5$1((3&c)===c,"The recovery param is more than two bits"),t=new signature$3(t,ie);var se=this.n,ae=new BN$8(n),ue=t.r,de=t.s,ve=c&1,ge=c>>1;if(ue.cmp(this.curve.p.umod(this.curve.n))>=0&&ge)throw new Error("Unable to find sencond key candinate");ge?ue=this.curve.pointFromX(ue.add(this.curve.n),ve):ue=this.curve.pointFromX(ue,ve);var we=t.r.invm(se),Te=se.sub(ae).mul(we).umod(se),Ne=de.mul(we).umod(se);return this.g.mulAdd(Te,ue,Ne)};EC.prototype.getKeyRecoveryParam=function(n,t,c,ie){if(t=new signature$3(t,ie),t.recoveryParam!==null)return t.recoveryParam;for(var se=0;se<4;se++){var ae;try{ae=this.recoverPubKey(n,t,se)}catch{continue}if(ae.eq(c))return se}throw new Error("Unable to find valid recovery factor")};var elliptic_1=createCommonjsModule(function(n,t){var c=t;c.version="6.6.1",c.utils=utils_1$1$1,c.rand=function(){throw new Error("unsupported")},c.curve=curve_1,c.curves=curves_1,c.ec=ec$1,c.eddsa=null}),EC$1=elliptic_1.ec;const version$j="signing-key/5.8.0",logger$h=new Logger(version$j);let _curve=null;function getCurve(){return _curve||(_curve=new EC$1("secp256k1")),_curve}class SigningKey{constructor(t){defineReadOnly(this,"curve","secp256k1"),defineReadOnly(this,"privateKey",hexlify(t)),hexDataLength(this.privateKey)!==32&&logger$h.throwArgumentError("invalid private key","privateKey","[[ REDACTED ]]");const c=getCurve().keyFromPrivate(arrayify(this.privateKey));defineReadOnly(this,"publicKey","0x"+c.getPublic(!1,"hex")),defineReadOnly(this,"compressedPublicKey","0x"+c.getPublic(!0,"hex")),defineReadOnly(this,"_isSigningKey",!0)}_addPoint(t){const c=getCurve().keyFromPublic(arrayify(this.publicKey)),ie=getCurve().keyFromPublic(arrayify(t));return"0x"+c.pub.add(ie.pub).encodeCompressed("hex")}signDigest(t){const c=getCurve().keyFromPrivate(arrayify(this.privateKey)),ie=arrayify(t);ie.length!==32&&logger$h.throwArgumentError("bad digest length","digest",t);const se=c.sign(ie,{canonical:!0});return splitSignature({recoveryParam:se.recoveryParam,r:hexZeroPad("0x"+se.r.toString(16),32),s:hexZeroPad("0x"+se.s.toString(16),32)})}computeSharedSecret(t){const c=getCurve().keyFromPrivate(arrayify(this.privateKey)),ie=getCurve().keyFromPublic(arrayify(computePublicKey(t)));return hexZeroPad("0x"+c.derive(ie.getPublic()).toString(16),32)}static isSigningKey(t){return!!(t&&t._isSigningKey)}}function recoverPublicKey(n,t){const c=splitSignature(t),ie={r:arrayify(c.r),s:arrayify(c.s)};return"0x"+getCurve().recoverPubKey(arrayify(n),ie,c.recoveryParam).encode("hex",!1)}function computePublicKey(n,t){const c=arrayify(n);if(c.length===32){const ie=new SigningKey(c);return t?"0x"+getCurve().keyFromPrivate(c).getPublic(!0,"hex"):ie.publicKey}else{if(c.length===33)return t?hexlify(c):"0x"+getCurve().keyFromPublic(c).getPublic(!1,"hex");if(c.length===65)return t?"0x"+getCurve().keyFromPublic(c).getPublic(!0,"hex"):hexlify(c)}return logger$h.throwArgumentError("invalid public or private key","key","[REDACTED]")}const lib_esm$a=Object.freeze(Object.defineProperty({__proto__:null,SigningKey,computePublicKey,recoverPublicKey},Symbol.toStringTag,{value:"Module"})),version$i="transactions/5.8.0",logger$g=new Logger(version$i);var TransactionTypes;(function(n){n[n.legacy=0]="legacy",n[n.eip2930=1]="eip2930",n[n.eip1559=2]="eip1559"})(TransactionTypes||(TransactionTypes={}));function handleAddress(n){return n==="0x"?null:getAddress$1(n)}function handleNumber(n){return n==="0x"?Zero$1:BigNumber.from(n)}const transactionFields=[{name:"nonce",maxLength:32,numeric:!0},{name:"gasPrice",maxLength:32,numeric:!0},{name:"gasLimit",maxLength:32,numeric:!0},{name:"to",length:20},{name:"value",maxLength:32,numeric:!0},{name:"data"}],allowedTransactionKeys$1={chainId:!0,data:!0,gasLimit:!0,gasPrice:!0,nonce:!0,to:!0,type:!0,value:!0};function computeAddress(n){const t=computePublicKey(n);return getAddress$1(hexDataSlice(keccak256$1(hexDataSlice(t,1)),12))}function recoverAddress(n,t){return computeAddress(recoverPublicKey(arrayify(n),t))}function formatNumber(n,t){const c=stripZeros(BigNumber.from(n).toHexString());return c.length>32&&logger$g.throwArgumentError("invalid length for "+t,"transaction:"+t,n),c}function accessSetify(n,t){return{address:getAddress$1(n),storageKeys:(t||[]).map((c,ie)=>(hexDataLength(c)!==32&&logger$g.throwArgumentError("invalid access list storageKey",`accessList[${n}:${ie}]`,c),c.toLowerCase()))}}function accessListify(n){if(Array.isArray(n))return n.map((c,ie)=>Array.isArray(c)?(c.length>2&&logger$g.throwArgumentError("access list expected to be [ address, storageKeys[] ]",`value[${ie}]`,c),accessSetify(c[0],c[1])):accessSetify(c.address,c.storageKeys));const t=Object.keys(n).map(c=>{const ie=n[c].reduce((se,ae)=>(se[ae]=!0,se),{});return accessSetify(c,Object.keys(ie).sort())});return t.sort((c,ie)=>c.address.localeCompare(ie.address)),t}function formatAccessList(n){return accessListify(n).map(t=>[t.address,t.storageKeys])}function _serializeEip1559(n,t){if(n.gasPrice!=null){const ie=BigNumber.from(n.gasPrice),se=BigNumber.from(n.maxFeePerGas||0);ie.eq(se)||logger$g.throwArgumentError("mismatch EIP-1559 gasPrice != maxFeePerGas","tx",{gasPrice:ie,maxFeePerGas:se})}const c=[formatNumber(n.chainId||0,"chainId"),formatNumber(n.nonce||0,"nonce"),formatNumber(n.maxPriorityFeePerGas||0,"maxPriorityFeePerGas"),formatNumber(n.maxFeePerGas||0,"maxFeePerGas"),formatNumber(n.gasLimit||0,"gasLimit"),n.to!=null?getAddress$1(n.to):"0x",formatNumber(n.value||0,"value"),n.data||"0x",formatAccessList(n.accessList||[])];if(t){const ie=splitSignature(t);c.push(formatNumber(ie.recoveryParam,"recoveryParam")),c.push(stripZeros(ie.r)),c.push(stripZeros(ie.s))}return hexConcat(["0x02",encode$6(c)])}function _serializeEip2930(n,t){const c=[formatNumber(n.chainId||0,"chainId"),formatNumber(n.nonce||0,"nonce"),formatNumber(n.gasPrice||0,"gasPrice"),formatNumber(n.gasLimit||0,"gasLimit"),n.to!=null?getAddress$1(n.to):"0x",formatNumber(n.value||0,"value"),n.data||"0x",formatAccessList(n.accessList||[])];if(t){const ie=splitSignature(t);c.push(formatNumber(ie.recoveryParam,"recoveryParam")),c.push(stripZeros(ie.r)),c.push(stripZeros(ie.s))}return hexConcat(["0x01",encode$6(c)])}function _serialize(n,t){checkProperties(n,allowedTransactionKeys$1);const c=[];transactionFields.forEach(function(ue){let de=n[ue.name]||[];const ve={};ue.numeric&&(ve.hexPad="left"),de=arrayify(hexlify(de,ve)),ue.length&&de.length!==ue.length&&de.length>0&&logger$g.throwArgumentError("invalid length for "+ue.name,"transaction:"+ue.name,de),ue.maxLength&&(de=stripZeros(de),de.length>ue.maxLength&&logger$g.throwArgumentError("invalid length for "+ue.name,"transaction:"+ue.name,de)),c.push(hexlify(de))});let ie=0;if(n.chainId!=null?(ie=n.chainId,typeof ie!="number"&&logger$g.throwArgumentError("invalid transaction.chainId","transaction",n)):t&&!isBytesLike(t)&&t.v>28&&(ie=Math.floor((t.v-35)/2)),ie!==0&&(c.push(hexlify(ie)),c.push("0x"),c.push("0x")),!t)return encode$6(c);const se=splitSignature(t);let ae=27+se.recoveryParam;return ie!==0?(c.pop(),c.pop(),c.pop(),ae+=ie*2+8,se.v>28&&se.v!==ae&&logger$g.throwArgumentError("transaction.chainId/signature.v mismatch","signature",t)):se.v!==ae&&logger$g.throwArgumentError("transaction.chainId/signature.v mismatch","signature",t),c.push(hexlify(ae)),c.push(stripZeros(arrayify(se.r))),c.push(stripZeros(arrayify(se.s))),encode$6(c)}function serialize$1$1(n,t){if(n.type==null||n.type===0)return n.accessList!=null&&logger$g.throwArgumentError("untyped transactions do not support accessList; include type: 1","transaction",n),_serialize(n,t);switch(n.type){case 1:return _serializeEip2930(n,t);case 2:return _serializeEip1559(n,t)}return logger$g.throwError(`unsupported transaction type: ${n.type}`,Logger.errors.UNSUPPORTED_OPERATION,{operation:"serializeTransaction",transactionType:n.type})}function _parseEipSignature(n,t,c){try{const ie=handleNumber(t[0]).toNumber();if(ie!==0&&ie!==1)throw new Error("bad recid");n.v=ie}catch{logger$g.throwArgumentError("invalid v for transaction type: 1","v",t[0])}n.r=hexZeroPad(t[1],32),n.s=hexZeroPad(t[2],32);try{const ie=keccak256$1(c(n));n.from=recoverAddress(ie,{r:n.r,s:n.s,recoveryParam:n.v})}catch{}}function _parseEip1559(n){const t=decode$7(n.slice(1));t.length!==9&&t.length!==12&&logger$g.throwArgumentError("invalid component count for transaction type: 2","payload",hexlify(n));const c=handleNumber(t[2]),ie=handleNumber(t[3]),se={type:2,chainId:handleNumber(t[0]).toNumber(),nonce:handleNumber(t[1]).toNumber(),maxPriorityFeePerGas:c,maxFeePerGas:ie,gasPrice:null,gasLimit:handleNumber(t[4]),to:handleAddress(t[5]),value:handleNumber(t[6]),data:t[7],accessList:accessListify(t[8])};return t.length===9||(se.hash=keccak256$1(n),_parseEipSignature(se,t.slice(9),_serializeEip1559)),se}function _parseEip2930(n){const t=decode$7(n.slice(1));t.length!==8&&t.length!==11&&logger$g.throwArgumentError("invalid component count for transaction type: 1","payload",hexlify(n));const c={type:1,chainId:handleNumber(t[0]).toNumber(),nonce:handleNumber(t[1]).toNumber(),gasPrice:handleNumber(t[2]),gasLimit:handleNumber(t[3]),to:handleAddress(t[4]),value:handleNumber(t[5]),data:t[6],accessList:accessListify(t[7])};return t.length===8||(c.hash=keccak256$1(n),_parseEipSignature(c,t.slice(8),_serializeEip2930)),c}function _parse(n){const t=decode$7(n);t.length!==9&&t.length!==6&&logger$g.throwArgumentError("invalid raw transaction","rawTransaction",n);const c={nonce:handleNumber(t[0]).toNumber(),gasPrice:handleNumber(t[1]),gasLimit:handleNumber(t[2]),to:handleAddress(t[3]),value:handleNumber(t[4]),data:t[5],chainId:0};if(t.length===6)return c;try{c.v=BigNumber.from(t[6]).toNumber()}catch{return c}if(c.r=hexZeroPad(t[7],32),c.s=hexZeroPad(t[8],32),BigNumber.from(c.r).isZero()&&BigNumber.from(c.s).isZero())c.chainId=c.v,c.v=0;else{c.chainId=Math.floor((c.v-35)/2),c.chainId<0&&(c.chainId=0);let ie=c.v-27;const se=t.slice(0,6);c.chainId!==0&&(se.push(hexlify(c.chainId)),se.push("0x"),se.push("0x"),ie-=c.chainId*2+8);const ae=keccak256$1(encode$6(se));try{c.from=recoverAddress(ae,{r:hexlify(c.r),s:hexlify(c.s),recoveryParam:ie})}catch{}c.hash=keccak256$1(n)}return c.type=null,c}function parse$2(n){const t=arrayify(n);if(t[0]>127)return _parse(t);switch(t[0]){case 1:return _parseEip2930(t);case 2:return _parseEip1559(t)}return logger$g.throwError(`unsupported transaction type: ${t[0]}`,Logger.errors.UNSUPPORTED_OPERATION,{operation:"parseTransaction",transactionType:t[0]})}const lib_esm$9=Object.freeze(Object.defineProperty({__proto__:null,get TransactionTypes(){return TransactionTypes},accessListify,computeAddress,parse:parse$2,recoverAddress,serialize:serialize$1$1},Symbol.toStringTag,{value:"Module"})),version$h="contracts/5.8.0";var __awaiter$h=function(n,t,c,ie){function se(ae){return ae instanceof c?ae:new c(function(ue){ue(ae)})}return new(c||(c=Promise))(function(ae,ue){function de(we){try{ge(ie.next(we))}catch(Te){ue(Te)}}function ve(we){try{ge(ie.throw(we))}catch(Te){ue(Te)}}function ge(we){we.done?ae(we.value):se(we.value).then(de,ve)}ge((ie=ie.apply(n,[])).next())})};const logger$f=new Logger(version$h);function resolveName(n,t){return __awaiter$h(this,void 0,void 0,function*(){const c=yield t;typeof c!="string"&&logger$f.throwArgumentError("invalid address or ENS name","name",c);try{return getAddress$1(c)}catch{}n||logger$f.throwError("a provider or signer is needed to resolve ENS names",Logger.errors.UNSUPPORTED_OPERATION,{operation:"resolveName"});const ie=yield n.resolveName(c);return ie==null&&logger$f.throwArgumentError("resolver or addr is not configured for ENS name","name",c),ie})}function resolveAddresses(n,t,c){return __awaiter$h(this,void 0,void 0,function*(){return Array.isArray(c)?yield Promise.all(c.map((ie,se)=>resolveAddresses(n,Array.isArray(t)?t[se]:t[ie.name],ie))):c.type==="address"?yield resolveName(n,t):c.type==="tuple"?yield resolveAddresses(n,t,c.components):c.baseType==="array"?Array.isArray(t)?yield Promise.all(t.map(ie=>resolveAddresses(n,ie,c.arrayChildren))):Promise.reject(logger$f.makeError("invalid value for array",Logger.errors.INVALID_ARGUMENT,{argument:"value",value:t})):t})}function populateTransaction(n,t,c){return __awaiter$h(this,void 0,void 0,function*(){let ie={};c.length===t.inputs.length+1&&typeof c[c.length-1]=="object"&&(ie=shallowCopy(c.pop())),logger$f.checkArgumentCount(c.length,t.inputs.length,"passed to contract"),n.signer?ie.from?ie.from=resolveProperties({override:resolveName(n.signer,ie.from),signer:n.signer.getAddress()}).then(ge=>__awaiter$h(this,void 0,void 0,function*(){return getAddress$1(ge.signer)!==ge.override&&logger$f.throwError("Contract with a Signer cannot override from",Logger.errors.UNSUPPORTED_OPERATION,{operation:"overrides.from"}),ge.override})):ie.from=n.signer.getAddress():ie.from&&(ie.from=resolveName(n.provider,ie.from));const se=yield resolveProperties({args:resolveAddresses(n.signer||n.provider,c,t.inputs),address:n.resolvedAddress,overrides:resolveProperties(ie)||{}}),ae=n.interface.encodeFunctionData(t,se.args),ue={data:ae,to:se.address},de=se.overrides;if(de.nonce!=null&&(ue.nonce=BigNumber.from(de.nonce).toNumber()),de.gasLimit!=null&&(ue.gasLimit=BigNumber.from(de.gasLimit)),de.gasPrice!=null&&(ue.gasPrice=BigNumber.from(de.gasPrice)),de.maxFeePerGas!=null&&(ue.maxFeePerGas=BigNumber.from(de.maxFeePerGas)),de.maxPriorityFeePerGas!=null&&(ue.maxPriorityFeePerGas=BigNumber.from(de.maxPriorityFeePerGas)),de.from!=null&&(ue.from=de.from),de.type!=null&&(ue.type=de.type),de.accessList!=null&&(ue.accessList=accessListify(de.accessList)),ue.gasLimit==null&&t.gas!=null){let ge=21e3;const we=arrayify(ae);for(let Te=0;Te<we.length;Te++)ge+=4,we[Te]&&(ge+=64);ue.gasLimit=BigNumber.from(t.gas).add(ge)}if(de.value){const ge=BigNumber.from(de.value);!ge.isZero()&&!t.payable&&logger$f.throwError("non-payable method cannot override value",Logger.errors.UNSUPPORTED_OPERATION,{operation:"overrides.value",value:ie.value}),ue.value=ge}de.customData&&(ue.customData=shallowCopy(de.customData)),de.ccipReadEnabled&&(ue.ccipReadEnabled=!!de.ccipReadEnabled),delete ie.nonce,delete ie.gasLimit,delete ie.gasPrice,delete ie.from,delete ie.value,delete ie.type,delete ie.accessList,delete ie.maxFeePerGas,delete ie.maxPriorityFeePerGas,delete ie.customData,delete ie.ccipReadEnabled;const ve=Object.keys(ie).filter(ge=>ie[ge]!=null);return ve.length&&logger$f.throwError(`cannot override ${ve.map(ge=>JSON.stringify(ge)).join(",")}`,Logger.errors.UNSUPPORTED_OPERATION,{operation:"overrides",overrides:ve}),ue})}function buildPopulate(n,t){return function(...c){return populateTransaction(n,t,c)}}function buildEstimate(n,t){const c=n.signer||n.provider;return function(...ie){return __awaiter$h(this,void 0,void 0,function*(){c||logger$f.throwError("estimate require a provider or signer",Logger.errors.UNSUPPORTED_OPERATION,{operation:"estimateGas"});const se=yield populateTransaction(n,t,ie);return yield c.estimateGas(se)})}}function addContractWait(n,t){const c=t.wait.bind(t);t.wait=ie=>c(ie).then(se=>(se.events=se.logs.map(ae=>{let ue=deepCopy(ae),de=null;try{de=n.interface.parseLog(ae)}catch{}return de&&(ue.args=de.args,ue.decode=(ve,ge)=>n.interface.decodeEventLog(de.eventFragment,ve,ge),ue.event=de.name,ue.eventSignature=de.signature),ue.removeListener=()=>n.provider,ue.getBlock=()=>n.provider.getBlock(se.blockHash),ue.getTransaction=()=>n.provider.getTransaction(se.transactionHash),ue.getTransactionReceipt=()=>Promise.resolve(se),ue}),se))}function buildCall(n,t,c){const ie=n.signer||n.provider;return function(...se){return __awaiter$h(this,void 0,void 0,function*(){let ae;if(se.length===t.inputs.length+1&&typeof se[se.length-1]=="object"){const ve=shallowCopy(se.pop());ve.blockTag!=null&&(ae=yield ve.blockTag),delete ve.blockTag,se.push(ve)}n.deployTransaction!=null&&(yield n._deployed(ae));const ue=yield populateTransaction(n,t,se),de=yield ie.call(ue,ae);try{let ve=n.interface.decodeFunctionResult(t,de);return c&&t.outputs.length===1&&(ve=ve[0]),ve}catch(ve){throw ve.code===Logger.errors.CALL_EXCEPTION&&(ve.address=n.address,ve.args=se,ve.transaction=ue),ve}})}}function buildSend(n,t){return function(...c){return __awaiter$h(this,void 0,void 0,function*(){n.signer||logger$f.throwError("sending a transaction requires a signer",Logger.errors.UNSUPPORTED_OPERATION,{operation:"sendTransaction"}),n.deployTransaction!=null&&(yield n._deployed());const ie=yield populateTransaction(n,t,c),se=yield n.signer.sendTransaction(ie);return addContractWait(n,se),se})}}function buildDefault(n,t,c){return t.constant?buildCall(n,t,c):buildSend(n,t)}function getEventTag$1(n){return n.address&&(n.topics==null||n.topics.length===0)?"*":(n.address||"*")+"@"+(n.topics?n.topics.map(t=>Array.isArray(t)?t.join("|"):t).join(":"):"")}class RunningEvent{constructor(t,c){defineReadOnly(this,"tag",t),defineReadOnly(this,"filter",c),this._listeners=[]}addListener(t,c){this._listeners.push({listener:t,once:c})}removeListener(t){let c=!1;this._listeners=this._listeners.filter(ie=>c||ie.listener!==t?!0:(c=!0,!1))}removeAllListeners(){this._listeners=[]}listeners(){return this._listeners.map(t=>t.listener)}listenerCount(){return this._listeners.length}run(t){const c=this.listenerCount();return this._listeners=this._listeners.filter(ie=>{const se=t.slice();return setTimeout(()=>{ie.listener.apply(this,se)},0),!ie.once}),c}prepareEvent(t){}getEmit(t){return[t]}}class ErrorRunningEvent extends RunningEvent{constructor(){super("error",null)}}class FragmentRunningEvent extends RunningEvent{constructor(t,c,ie,se){const ae={address:t};let ue=c.getEventTopic(ie);se?(ue!==se[0]&&logger$f.throwArgumentError("topic mismatch","topics",se),ae.topics=se.slice()):ae.topics=[ue],super(getEventTag$1(ae),ae),defineReadOnly(this,"address",t),defineReadOnly(this,"interface",c),defineReadOnly(this,"fragment",ie)}prepareEvent(t){super.prepareEvent(t),t.event=this.fragment.name,t.eventSignature=this.fragment.format(),t.decode=(c,ie)=>this.interface.decodeEventLog(this.fragment,c,ie);try{t.args=this.interface.decodeEventLog(this.fragment,t.data,t.topics)}catch(c){t.args=null,t.decodeError=c}}getEmit(t){const c=checkResultErrors(t.args);if(c.length)throw c[0].error;const ie=(t.args||[]).slice();return ie.push(t),ie}}class WildcardRunningEvent extends RunningEvent{constructor(t,c){super("*",{address:t}),defineReadOnly(this,"address",t),defineReadOnly(this,"interface",c)}prepareEvent(t){super.prepareEvent(t);try{const c=this.interface.parseLog(t);t.event=c.name,t.eventSignature=c.signature,t.decode=(ie,se)=>this.interface.decodeEventLog(c.eventFragment,ie,se),t.args=c.args}catch{}}}class BaseContract{constructor(t,c,ie){defineReadOnly(this,"interface",getStatic(new.target,"getInterface")(c)),ie==null?(defineReadOnly(this,"provider",null),defineReadOnly(this,"signer",null)):Signer.isSigner(ie)?(defineReadOnly(this,"provider",ie.provider||null),defineReadOnly(this,"signer",ie)):Provider.isProvider(ie)?(defineReadOnly(this,"provider",ie),defineReadOnly(this,"signer",null)):logger$f.throwArgumentError("invalid signer or provider","signerOrProvider",ie),defineReadOnly(this,"callStatic",{}),defineReadOnly(this,"estimateGas",{}),defineReadOnly(this,"functions",{}),defineReadOnly(this,"populateTransaction",{}),defineReadOnly(this,"filters",{});{const ue={};Object.keys(this.interface.events).forEach(de=>{const ve=this.interface.events[de];defineReadOnly(this.filters,de,(...ge)=>({address:this.address,topics:this.interface.encodeFilterTopics(ve,ge)})),ue[ve.name]||(ue[ve.name]=[]),ue[ve.name].push(de)}),Object.keys(ue).forEach(de=>{const ve=ue[de];ve.length===1?defineReadOnly(this.filters,de,this.filters[ve[0]]):logger$f.warn(`Duplicate definition of ${de} (${ve.join(", ")})`)})}if(defineReadOnly(this,"_runningEvents",{}),defineReadOnly(this,"_wrappedEmits",{}),t==null&&logger$f.throwArgumentError("invalid contract address or ENS name","addressOrName",t),defineReadOnly(this,"address",t),this.provider)defineReadOnly(this,"resolvedAddress",resolveName(this.provider,t));else try{defineReadOnly(this,"resolvedAddress",Promise.resolve(getAddress$1(t)))}catch{logger$f.throwError("provider is required to use ENS name as contract address",Logger.errors.UNSUPPORTED_OPERATION,{operation:"new Contract"})}this.resolvedAddress.catch(ue=>{});const se={},ae={};Object.keys(this.interface.functions).forEach(ue=>{const de=this.interface.functions[ue];if(ae[ue]){logger$f.warn(`Duplicate ABI entry for ${JSON.stringify(ue)}`);return}ae[ue]=!0;{const ve=de.name;se[`%${ve}`]||(se[`%${ve}`]=[]),se[`%${ve}`].push(ue)}this[ue]==null&&defineReadOnly(this,ue,buildDefault(this,de,!0)),this.functions[ue]==null&&defineReadOnly(this.functions,ue,buildDefault(this,de,!1)),this.callStatic[ue]==null&&defineReadOnly(this.callStatic,ue,buildCall(this,de,!0)),this.populateTransaction[ue]==null&&defineReadOnly(this.populateTransaction,ue,buildPopulate(this,de)),this.estimateGas[ue]==null&&defineReadOnly(this.estimateGas,ue,buildEstimate(this,de))}),Object.keys(se).forEach(ue=>{const de=se[ue];if(de.length>1)return;ue=ue.substring(1);const ve=de[0];try{this[ue]==null&&defineReadOnly(this,ue,this[ve])}catch{}this.functions[ue]==null&&defineReadOnly(this.functions,ue,this.functions[ve]),this.callStatic[ue]==null&&defineReadOnly(this.callStatic,ue,this.callStatic[ve]),this.populateTransaction[ue]==null&&defineReadOnly(this.populateTransaction,ue,this.populateTransaction[ve]),this.estimateGas[ue]==null&&defineReadOnly(this.estimateGas,ue,this.estimateGas[ve])})}static getContractAddress(t){return getContractAddress(t)}static getInterface(t){return Interface.isInterface(t)?t:new Interface(t)}deployed(){return this._deployed()}_deployed(t){return this._deployedPromise||(this.deployTransaction?this._deployedPromise=this.deployTransaction.wait().then(()=>this):this._deployedPromise=this.provider.getCode(this.address,t).then(c=>(c==="0x"&&logger$f.throwError("contract not deployed",Logger.errors.UNSUPPORTED_OPERATION,{contractAddress:this.address,operation:"getDeployed"}),this))),this._deployedPromise}fallback(t){this.signer||logger$f.throwError("sending a transactions require a signer",Logger.errors.UNSUPPORTED_OPERATION,{operation:"sendTransaction(fallback)"});const c=shallowCopy(t||{});return["from","to"].forEach(function(ie){c[ie]!=null&&logger$f.throwError("cannot override "+ie,Logger.errors.UNSUPPORTED_OPERATION,{operation:ie})}),c.to=this.resolvedAddress,this.deployed().then(()=>this.signer.sendTransaction(c))}connect(t){typeof t=="string"&&(t=new VoidSigner(t,this.provider));const c=new this.constructor(this.address,this.interface,t);return this.deployTransaction&&defineReadOnly(c,"deployTransaction",this.deployTransaction),c}attach(t){return new this.constructor(t,this.interface,this.signer||this.provider)}static isIndexed(t){return Indexed.isIndexed(t)}_normalizeRunningEvent(t){return this._runningEvents[t.tag]?this._runningEvents[t.tag]:t}_getRunningEvent(t){if(typeof t=="string"){if(t==="error")return this._normalizeRunningEvent(new ErrorRunningEvent);if(t==="event")return this._normalizeRunningEvent(new RunningEvent("event",null));if(t==="*")return this._normalizeRunningEvent(new WildcardRunningEvent(this.address,this.interface));const c=this.interface.getEvent(t);return this._normalizeRunningEvent(new FragmentRunningEvent(this.address,this.interface,c))}if(t.topics&&t.topics.length>0){try{const ie=t.topics[0];if(typeof ie!="string")throw new Error("invalid topic");const se=this.interface.getEvent(ie);return this._normalizeRunningEvent(new FragmentRunningEvent(this.address,this.interface,se,t.topics))}catch{}const c={address:this.address,topics:t.topics};return this._normalizeRunningEvent(new RunningEvent(getEventTag$1(c),c))}return this._normalizeRunningEvent(new WildcardRunningEvent(this.address,this.interface))}_checkRunningEvents(t){if(t.listenerCount()===0){delete this._runningEvents[t.tag];const c=this._wrappedEmits[t.tag];c&&t.filter&&(this.provider.off(t.filter,c),delete this._wrappedEmits[t.tag])}}_wrapEvent(t,c,ie){const se=deepCopy(c);return se.removeListener=()=>{ie&&(t.removeListener(ie),this._checkRunningEvents(t))},se.getBlock=()=>this.provider.getBlock(c.blockHash),se.getTransaction=()=>this.provider.getTransaction(c.transactionHash),se.getTransactionReceipt=()=>this.provider.getTransactionReceipt(c.transactionHash),t.prepareEvent(se),se}_addEventListener(t,c,ie){if(this.provider||logger$f.throwError("events require a provider or a signer with a provider",Logger.errors.UNSUPPORTED_OPERATION,{operation:"once"}),t.addListener(c,ie),this._runningEvents[t.tag]=t,!this._wrappedEmits[t.tag]){const se=ae=>{let ue=this._wrapEvent(t,ae,c);if(ue.decodeError==null)try{const de=t.getEmit(ue);this.emit(t.filter,...de)}catch(de){ue.decodeError=de.error}t.filter!=null&&this.emit("event",ue),ue.decodeError!=null&&this.emit("error",ue.decodeError,ue)};this._wrappedEmits[t.tag]=se,t.filter!=null&&this.provider.on(t.filter,se)}}queryFilter(t,c,ie){const se=this._getRunningEvent(t),ae=shallowCopy(se.filter);return typeof c=="string"&&isHexString(c,32)?(ie!=null&&logger$f.throwArgumentError("cannot specify toBlock with blockhash","toBlock",ie),ae.blockHash=c):(ae.fromBlock=c??0,ae.toBlock=ie??"latest"),this.provider.getLogs(ae).then(ue=>ue.map(de=>this._wrapEvent(se,de,null)))}on(t,c){return this._addEventListener(this._getRunningEvent(t),c,!1),this}once(t,c){return this._addEventListener(this._getRunningEvent(t),c,!0),this}emit(t,...c){if(!this.provider)return!1;const ie=this._getRunningEvent(t),se=ie.run(c)>0;return this._checkRunningEvents(ie),se}listenerCount(t){return this.provider?t==null?Object.keys(this._runningEvents).reduce((c,ie)=>c+this._runningEvents[ie].listenerCount(),0):this._getRunningEvent(t).listenerCount():0}listeners(t){if(!this.provider)return[];if(t==null){const c=[];for(let ie in this._runningEvents)this._runningEvents[ie].listeners().forEach(se=>{c.push(se)});return c}return this._getRunningEvent(t).listeners()}removeAllListeners(t){if(!this.provider)return this;if(t==null){for(const ie in this._runningEvents){const se=this._runningEvents[ie];se.removeAllListeners(),this._checkRunningEvents(se)}return this}const c=this._getRunningEvent(t);return c.removeAllListeners(),this._checkRunningEvents(c),this}off(t,c){if(!this.provider)return this;const ie=this._getRunningEvent(t);return ie.removeListener(c),this._checkRunningEvents(ie),this}removeListener(t,c){return this.off(t,c)}}class Contract extends BaseContract{}class BaseX{constructor(t){defineReadOnly(this,"alphabet",t),defineReadOnly(this,"base",t.length),defineReadOnly(this,"_alphabetMap",{}),defineReadOnly(this,"_leader",t.charAt(0));for(let c=0;c<t.length;c++)this._alphabetMap[t.charAt(c)]=c}encode(t){let c=arrayify(t);if(c.length===0)return"";let ie=[0];for(let ae=0;ae<c.length;++ae){let ue=c[ae];for(let de=0;de<ie.length;++de)ue+=ie[de]<<8,ie[de]=ue%this.base,ue=ue/this.base|0;for(;ue>0;)ie.push(ue%this.base),ue=ue/this.base|0}let se="";for(let ae=0;c[ae]===0&&ae<c.length-1;++ae)se+=this._leader;for(let ae=ie.length-1;ae>=0;--ae)se+=this.alphabet[ie[ae]];return se}decode(t){if(typeof t!="string")throw new TypeError("Expected String");let c=[];if(t.length===0)return new Uint8Array(c);c.push(0);for(let ie=0;ie<t.length;ie++){let se=this._alphabetMap[t[ie]];if(se===void 0)throw new Error("Non-base"+this.base+" character");let ae=se;for(let ue=0;ue<c.length;++ue)ae+=c[ue]*this.base,c[ue]=ae&255,ae>>=8;for(;ae>0;)c.push(ae&255),ae>>=8}for(let ie=0;t[ie]===this._leader&&ie<t.length-1;++ie)c.push(0);return arrayify(new Uint8Array(c.reverse()))}}const Base32=new BaseX("abcdefghijklmnopqrstuvwxyz234567"),Base58=new BaseX("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"),lib_esm$8=Object.freeze(Object.defineProperty({__proto__:null,Base32,Base58,BaseX},Symbol.toStringTag,{value:"Module"}));var SupportedAlgorithm;(function(n){n.sha256="sha256",n.sha512="sha512"})(SupportedAlgorithm||(SupportedAlgorithm={}));const version$g="sha2/5.8.0",logger$e=new Logger(version$g);function ripemd160$1(n){return"0x"+hash$3.ripemd160().update(arrayify(n)).digest("hex")}function sha256$7(n){return"0x"+hash$3.sha256().update(arrayify(n)).digest("hex")}function sha512$4(n){return"0x"+hash$3.sha512().update(arrayify(n)).digest("hex")}function computeHmac(n,t,c){return SupportedAlgorithm[n]||logger$e.throwError("unsupported algorithm "+n,Logger.errors.UNSUPPORTED_OPERATION,{operation:"hmac",algorithm:n}),"0x"+hash$3.hmac(hash$3[n],arrayify(t)).update(arrayify(c)).digest("hex")}const lib_esm$7=Object.freeze(Object.defineProperty({__proto__:null,get SupportedAlgorithm(){return SupportedAlgorithm},computeHmac,ripemd160:ripemd160$1,sha256:sha256$7,sha512:sha512$4},Symbol.toStringTag,{value:"Module"}));function pbkdf2$1(n,t,c,ie,se){n=arrayify(n),t=arrayify(t);let ae,ue=1;const de=new Uint8Array(ie),ve=new Uint8Array(t.length+4);ve.set(t);let ge,we;for(let Te=1;Te<=ue;Te++){ve[t.length]=Te>>24&255,ve[t.length+1]=Te>>16&255,ve[t.length+2]=Te>>8&255,ve[t.length+3]=Te&255;let Ne=arrayify(computeHmac(se,n,ve));ae||(ae=Ne.length,we=new Uint8Array(ae),ue=Math.ceil(ie/ae),ge=ie-(ue-1)*ae),we.set(Ne);for(let He=1;He<c;He++){Ne=arrayify(computeHmac(se,n,Ne));for(let Ge=0;Ge<ae;Ge++)we[Ge]^=Ne[Ge]}const qe=(Te-1)*ae,ze=Te===ue?ge:ae;de.set(arrayify(we).slice(0,ze),qe)}return hexlify(de)}const version$f="wordlists/5.8.0",logger$d=new Logger(version$f);class Wordlist{constructor(t){logger$d.checkAbstract(new.target,Wordlist),defineReadOnly(this,"locale",t)}split(t){return t.toLowerCase().split(/ +/g)}join(t){return t.join(" ")}static check(t){const c=[];for(let ie=0;ie<2048;ie++){const se=t.getWord(ie);if(ie!==t.getWordIndex(se))return"0x";c.push(se)}return id(c.join(`
12
12
  `)+`
13
- `)}static register(t,c){c||(c=t.locale)}}const words="AbandonAbilityAbleAboutAboveAbsentAbsorbAbstractAbsurdAbuseAccessAccidentAccountAccuseAchieveAcidAcousticAcquireAcrossActActionActorActressActualAdaptAddAddictAddressAdjustAdmitAdultAdvanceAdviceAerobicAffairAffordAfraidAgainAgeAgentAgreeAheadAimAirAirportAisleAlarmAlbumAlcoholAlertAlienAllAlleyAllowAlmostAloneAlphaAlreadyAlsoAlterAlwaysAmateurAmazingAmongAmountAmusedAnalystAnchorAncientAngerAngleAngryAnimalAnkleAnnounceAnnualAnotherAnswerAntennaAntiqueAnxietyAnyApartApologyAppearAppleApproveAprilArchArcticAreaArenaArgueArmArmedArmorArmyAroundArrangeArrestArriveArrowArtArtefactArtistArtworkAskAspectAssaultAssetAssistAssumeAsthmaAthleteAtomAttackAttendAttitudeAttractAuctionAuditAugustAuntAuthorAutoAutumnAverageAvocadoAvoidAwakeAwareAwayAwesomeAwfulAwkwardAxisBabyBachelorBaconBadgeBagBalanceBalconyBallBambooBananaBannerBarBarelyBargainBarrelBaseBasicBasketBattleBeachBeanBeautyBecauseBecomeBeefBeforeBeginBehaveBehindBelieveBelowBeltBenchBenefitBestBetrayBetterBetweenBeyondBicycleBidBikeBindBiologyBirdBirthBitterBlackBladeBlameBlanketBlastBleakBlessBlindBloodBlossomBlouseBlueBlurBlushBoardBoatBodyBoilBombBoneBonusBookBoostBorderBoringBorrowBossBottomBounceBoxBoyBracketBrainBrandBrassBraveBreadBreezeBrickBridgeBriefBrightBringBriskBroccoliBrokenBronzeBroomBrotherBrownBrushBubbleBuddyBudgetBuffaloBuildBulbBulkBulletBundleBunkerBurdenBurgerBurstBusBusinessBusyButterBuyerBuzzCabbageCabinCableCactusCageCakeCallCalmCameraCampCanCanalCancelCandyCannonCanoeCanvasCanyonCapableCapitalCaptainCarCarbonCardCargoCarpetCarryCartCaseCashCasinoCastleCasualCatCatalogCatchCategoryCattleCaughtCauseCautionCaveCeilingCeleryCementCensusCenturyCerealCertainChairChalkChampionChangeChaosChapterChargeChaseChatCheapCheckCheeseChefCherryChestChickenChiefChildChimneyChoiceChooseChronicChuckleChunkChurnCigarCinnamonCircleCitizenCityCivilClaimClapClarifyClawClayCleanClerkCleverClickClientCliffClimbClinicClipClockClogCloseClothCloudClownClubClumpClusterClutchCoachCoastCoconutCodeCoffeeCoilCoinCollectColorColumnCombineComeComfortComicCommonCompanyConcertConductConfirmCongressConnectConsiderControlConvinceCookCoolCopperCopyCoralCoreCornCorrectCostCottonCouchCountryCoupleCourseCousinCoverCoyoteCrackCradleCraftCramCraneCrashCraterCrawlCrazyCreamCreditCreekCrewCricketCrimeCrispCriticCropCrossCrouchCrowdCrucialCruelCruiseCrumbleCrunchCrushCryCrystalCubeCultureCupCupboardCuriousCurrentCurtainCurveCushionCustomCuteCycleDadDamageDampDanceDangerDaringDashDaughterDawnDayDealDebateDebrisDecadeDecemberDecideDeclineDecorateDecreaseDeerDefenseDefineDefyDegreeDelayDeliverDemandDemiseDenialDentistDenyDepartDependDepositDepthDeputyDeriveDescribeDesertDesignDeskDespairDestroyDetailDetectDevelopDeviceDevoteDiagramDialDiamondDiaryDiceDieselDietDifferDigitalDignityDilemmaDinnerDinosaurDirectDirtDisagreeDiscoverDiseaseDishDismissDisorderDisplayDistanceDivertDivideDivorceDizzyDoctorDocumentDogDollDolphinDomainDonateDonkeyDonorDoorDoseDoubleDoveDraftDragonDramaDrasticDrawDreamDressDriftDrillDrinkDripDriveDropDrumDryDuckDumbDuneDuringDustDutchDutyDwarfDynamicEagerEagleEarlyEarnEarthEasilyEastEasyEchoEcologyEconomyEdgeEditEducateEffortEggEightEitherElbowElderElectricElegantElementElephantElevatorEliteElseEmbarkEmbodyEmbraceEmergeEmotionEmployEmpowerEmptyEnableEnactEndEndlessEndorseEnemyEnergyEnforceEngageEngineEnhanceEnjoyEnlistEnoughEnrichEnrollEnsureEnterEntireEntryEnvelopeEpisodeEqualEquipEraEraseErodeErosionErrorEruptEscapeEssayEssenceEstateEternalEthicsEvidenceEvilEvokeEvolveExactExampleExcessExchangeExciteExcludeExcuseExecuteExerciseExhaustExhibitExileExistExitExoticExpandExpectExpireExplainExposeExpressExtendExtraEyeEyebrowFabricFaceFacultyFadeFaintFaithFallFalseFameFamilyFamousFanFancyFantasyFarmFashionFatFatalFatherFatigueFaultFavoriteFeatureFebruaryFederalFeeFeedFeelFemaleFenceFestivalFetchFeverFewFiberFictionFieldFigureFileFilmFilterFinalFindFineFingerFinishFireFirmFirstFiscalFishFitFitnessFixFlagFlameFlashFlatFlavorFleeFlightFlipFloatFlockFloorFlowerFluidFlushFlyFoamFocusFogFoilFoldFollowFoodFootForceForestForgetForkFortuneForumForwardFossilFosterFoundFoxFragileFrameFrequentFreshFriendFringeFrogFrontFrostFrownFrozenFruitFuelFunFunnyFurnaceFuryFutureGadgetGainGalaxyGalleryGameGapGarageGarbageGardenGarlicGarmentGasGaspGateGatherGaugeGazeGeneralGeniusGenreGentleGenuineGestureGhostGiantGiftGiggleGingerGiraffeGirlGiveGladGlanceGlareGlassGlideGlimpseGlobeGloomGloryGloveGlowGlueGoatGoddessGoldGoodGooseGorillaGospelGossipGovernGownGrabGraceGrainGrantGrapeGrassGravityGreatGreenGridGriefGritGroceryGroupGrowGruntGuardGuessGuideGuiltGuitarGunGymHabitHairHalfHammerHamsterHandHappyHarborHardHarshHarvestHatHaveHawkHazardHeadHealthHeartHeavyHedgehogHeightHelloHelmetHelpHenHeroHiddenHighHillHintHipHireHistoryHobbyHockeyHoldHoleHolidayHollowHomeHoneyHoodHopeHornHorrorHorseHospitalHostHotelHourHoverHubHugeHumanHumbleHumorHundredHungryHuntHurdleHurryHurtHusbandHybridIceIconIdeaIdentifyIdleIgnoreIllIllegalIllnessImageImitateImmenseImmuneImpactImposeImproveImpulseInchIncludeIncomeIncreaseIndexIndicateIndoorIndustryInfantInflictInformInhaleInheritInitialInjectInjuryInmateInnerInnocentInputInquiryInsaneInsectInsideInspireInstallIntactInterestIntoInvestInviteInvolveIronIslandIsolateIssueItemIvoryJacketJaguarJarJazzJealousJeansJellyJewelJobJoinJokeJourneyJoyJudgeJuiceJumpJungleJuniorJunkJustKangarooKeenKeepKetchupKeyKickKidKidneyKindKingdomKissKitKitchenKiteKittenKiwiKneeKnifeKnockKnowLabLabelLaborLadderLadyLakeLampLanguageLaptopLargeLaterLatinLaughLaundryLavaLawLawnLawsuitLayerLazyLeaderLeafLearnLeaveLectureLeftLegLegalLegendLeisureLemonLendLengthLensLeopardLessonLetterLevelLiarLibertyLibraryLicenseLifeLiftLightLikeLimbLimitLinkLionLiquidListLittleLiveLizardLoadLoanLobsterLocalLockLogicLonelyLongLoopLotteryLoudLoungeLoveLoyalLuckyLuggageLumberLunarLunchLuxuryLyricsMachineMadMagicMagnetMaidMailMainMajorMakeMammalManManageMandateMangoMansionManualMapleMarbleMarchMarginMarineMarketMarriageMaskMassMasterMatchMaterialMathMatrixMatterMaximumMazeMeadowMeanMeasureMeatMechanicMedalMediaMelodyMeltMemberMemoryMentionMenuMercyMergeMeritMerryMeshMessageMetalMethodMiddleMidnightMilkMillionMimicMindMinimumMinorMinuteMiracleMirrorMiseryMissMistakeMixMixedMixtureMobileModelModifyMomMomentMonitorMonkeyMonsterMonthMoonMoralMoreMorningMosquitoMotherMotionMotorMountainMouseMoveMovieMuchMuffinMuleMultiplyMuscleMuseumMushroomMusicMustMutualMyselfMysteryMythNaiveNameNapkinNarrowNastyNationNatureNearNeckNeedNegativeNeglectNeitherNephewNerveNestNetNetworkNeutralNeverNewsNextNiceNightNobleNoiseNomineeNoodleNormalNorthNoseNotableNoteNothingNoticeNovelNowNuclearNumberNurseNutOakObeyObjectObligeObscureObserveObtainObviousOccurOceanOctoberOdorOffOfferOfficeOftenOilOkayOldOliveOlympicOmitOnceOneOnionOnlineOnlyOpenOperaOpinionOpposeOptionOrangeOrbitOrchardOrderOrdinaryOrganOrientOriginalOrphanOstrichOtherOutdoorOuterOutputOutsideOvalOvenOverOwnOwnerOxygenOysterOzonePactPaddlePagePairPalacePalmPandaPanelPanicPantherPaperParadeParentParkParrotPartyPassPatchPathPatientPatrolPatternPausePavePaymentPeacePeanutPearPeasantPelicanPenPenaltyPencilPeoplePepperPerfectPermitPersonPetPhonePhotoPhrasePhysicalPianoPicnicPicturePiecePigPigeonPillPilotPinkPioneerPipePistolPitchPizzaPlacePlanetPlasticPlatePlayPleasePledgePluckPlugPlungePoemPoetPointPolarPolePolicePondPonyPoolPopularPortionPositionPossiblePostPotatoPotteryPovertyPowderPowerPracticePraisePredictPreferPreparePresentPrettyPreventPricePridePrimaryPrintPriorityPrisonPrivatePrizeProblemProcessProduceProfitProgramProjectPromoteProofPropertyProsperProtectProudProvidePublicPuddingPullPulpPulsePumpkinPunchPupilPuppyPurchasePurityPurposePursePushPutPuzzlePyramidQualityQuantumQuarterQuestionQuickQuitQuizQuoteRabbitRaccoonRaceRackRadarRadioRailRainRaiseRallyRampRanchRandomRangeRapidRareRateRatherRavenRawRazorReadyRealReasonRebelRebuildRecallReceiveRecipeRecordRecycleReduceReflectReformRefuseRegionRegretRegularRejectRelaxReleaseReliefRelyRemainRememberRemindRemoveRenderRenewRentReopenRepairRepeatReplaceReportRequireRescueResembleResistResourceResponseResultRetireRetreatReturnReunionRevealReviewRewardRhythmRibRibbonRiceRichRideRidgeRifleRightRigidRingRiotRippleRiskRitualRivalRiverRoadRoastRobotRobustRocketRomanceRoofRookieRoomRoseRotateRoughRoundRouteRoyalRubberRudeRugRuleRunRunwayRuralSadSaddleSadnessSafeSailSaladSalmonSalonSaltSaluteSameSampleSandSatisfySatoshiSauceSausageSaveSayScaleScanScareScatterSceneSchemeSchoolScienceScissorsScorpionScoutScrapScreenScriptScrubSeaSearchSeasonSeatSecondSecretSectionSecuritySeedSeekSegmentSelectSellSeminarSeniorSenseSentenceSeriesServiceSessionSettleSetupSevenShadowShaftShallowShareShedShellSheriffShieldShiftShineShipShiverShockShoeShootShopShortShoulderShoveShrimpShrugShuffleShySiblingSickSideSiegeSightSignSilentSilkSillySilverSimilarSimpleSinceSingSirenSisterSituateSixSizeSkateSketchSkiSkillSkinSkirtSkullSlabSlamSleepSlenderSliceSlideSlightSlimSloganSlotSlowSlushSmallSmartSmileSmokeSmoothSnackSnakeSnapSniffSnowSoapSoccerSocialSockSodaSoftSolarSoldierSolidSolutionSolveSomeoneSongSoonSorrySortSoulSoundSoupSourceSouthSpaceSpareSpatialSpawnSpeakSpecialSpeedSpellSpendSphereSpiceSpiderSpikeSpinSpiritSplitSpoilSponsorSpoonSportSpotSpraySpreadSpringSpySquareSqueezeSquirrelStableStadiumStaffStageStairsStampStandStartStateStaySteakSteelStemStepStereoStickStillStingStockStomachStoneStoolStoryStoveStrategyStreetStrikeStrongStruggleStudentStuffStumbleStyleSubjectSubmitSubwaySuccessSuchSuddenSufferSugarSuggestSuitSummerSunSunnySunsetSuperSupplySupremeSureSurfaceSurgeSurpriseSurroundSurveySuspectSustainSwallowSwampSwapSwarmSwearSweetSwiftSwimSwingSwitchSwordSymbolSymptomSyrupSystemTableTackleTagTailTalentTalkTankTapeTargetTaskTasteTattooTaxiTeachTeamTellTenTenantTennisTentTermTestTextThankThatThemeThenTheoryThereTheyThingThisThoughtThreeThriveThrowThumbThunderTicketTideTigerTiltTimberTimeTinyTipTiredTissueTitleToastTobaccoTodayToddlerToeTogetherToiletTokenTomatoTomorrowToneTongueTonightToolToothTopTopicToppleTorchTornadoTortoiseTossTotalTouristTowardTowerTownToyTrackTradeTrafficTragicTrainTransferTrapTrashTravelTrayTreatTreeTrendTrialTribeTrickTriggerTrimTripTrophyTroubleTruckTrueTrulyTrumpetTrustTruthTryTubeTuitionTumbleTunaTunnelTurkeyTurnTurtleTwelveTwentyTwiceTwinTwistTwoTypeTypicalUglyUmbrellaUnableUnawareUncleUncoverUnderUndoUnfairUnfoldUnhappyUniformUniqueUnitUniverseUnknownUnlockUntilUnusualUnveilUpdateUpgradeUpholdUponUpperUpsetUrbanUrgeUsageUseUsedUsefulUselessUsualUtilityVacantVacuumVagueValidValleyValveVanVanishVaporVariousVastVaultVehicleVelvetVendorVentureVenueVerbVerifyVersionVeryVesselVeteranViableVibrantViciousVictoryVideoViewVillageVintageViolinVirtualVirusVisaVisitVisualVitalVividVocalVoiceVoidVolcanoVolumeVoteVoyageWageWagonWaitWalkWallWalnutWantWarfareWarmWarriorWashWaspWasteWaterWaveWayWealthWeaponWearWeaselWeatherWebWeddingWeekendWeirdWelcomeWestWetWhaleWhatWheatWheelWhenWhereWhipWhisperWideWidthWifeWildWillWinWindowWineWingWinkWinnerWinterWireWisdomWiseWishWitnessWolfWomanWonderWoodWoolWordWorkWorldWorryWorthWrapWreckWrestleWristWriteWrongYardYearYellowYouYoungYouthZebraZeroZoneZoo";let wordlist=null;function loadWords(n){if(wordlist==null&&(wordlist=words.replace(/([A-Z])/g," $1").toLowerCase().substring(1).split(" "),Wordlist.check(n)!=="0x3c8acc1e7b08d8e76f9fda015ef48dc8c710a73cb7e0f77b2c18a9b5a7adde60"))throw wordlist=null,new Error("BIP39 Wordlist for en (English) FAILED")}class LangEn extends Wordlist{constructor(){super("en")}getWord(t){return loadWords(this),wordlist[t]}getWordIndex(t){return loadWords(this),wordlist.indexOf(t)}}const langEn=new LangEn;Wordlist.register(langEn);const wordlists={en:langEn},version$e="hdnode/5.8.0",logger$c=new Logger(version$e),N$3=BigNumber.from("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),MasterSecret=toUtf8Bytes("Bitcoin seed"),HardenedBit=2147483648;function getUpperMask(n){return(1<<n)-1<<8-n}function getLowerMask(n){return(1<<n)-1}function bytes32(n){return hexZeroPad(hexlify(n),32)}function base58check(n){return Base58.encode(concat$1([n,hexDataSlice(sha256$7(sha256$7(n)),0,4)]))}function getWordlist(n){if(n==null)return wordlists.en;if(typeof n=="string"){const t=wordlists[n];return t==null&&logger$c.throwArgumentError("unknown locale","wordlist",n),t}return n}const _constructorGuard$1={},defaultPath="m/44'/60'/0'/0/0";class HDNode{constructor(t,c,ie,se,ae,ue,de,ve){if(t!==_constructorGuard$1)throw new Error("HDNode constructor cannot be called directly");if(c){const ge=new SigningKey(c);defineReadOnly(this,"privateKey",ge.privateKey),defineReadOnly(this,"publicKey",ge.compressedPublicKey)}else defineReadOnly(this,"privateKey",null),defineReadOnly(this,"publicKey",hexlify(ie));defineReadOnly(this,"parentFingerprint",se),defineReadOnly(this,"fingerprint",hexDataSlice(ripemd160$1(sha256$7(this.publicKey)),0,4)),defineReadOnly(this,"address",computeAddress(this.publicKey)),defineReadOnly(this,"chainCode",ae),defineReadOnly(this,"index",ue),defineReadOnly(this,"depth",de),ve==null?(defineReadOnly(this,"mnemonic",null),defineReadOnly(this,"path",null)):typeof ve=="string"?(defineReadOnly(this,"mnemonic",null),defineReadOnly(this,"path",ve)):(defineReadOnly(this,"mnemonic",ve),defineReadOnly(this,"path",ve.path))}get extendedKey(){if(this.depth>=256)throw new Error("Depth too large!");return base58check(concat$1([this.privateKey!=null?"0x0488ADE4":"0x0488B21E",hexlify(this.depth),this.parentFingerprint,hexZeroPad(hexlify(this.index),4),this.chainCode,this.privateKey!=null?concat$1(["0x00",this.privateKey]):this.publicKey]))}neuter(){return new HDNode(_constructorGuard$1,null,this.publicKey,this.parentFingerprint,this.chainCode,this.index,this.depth,this.path)}_derive(t){if(t>4294967295)throw new Error("invalid index - "+String(t));let c=this.path;c&&(c+="/"+(t&~HardenedBit));const ie=new Uint8Array(37);if(t&HardenedBit){if(!this.privateKey)throw new Error("cannot derive child of neutered node");ie.set(arrayify(this.privateKey),1),c&&(c+="'")}else ie.set(arrayify(this.publicKey));for(let Te=24;Te>=0;Te-=8)ie[33+(Te>>3)]=t>>24-Te&255;const se=arrayify(computeHmac(SupportedAlgorithm.sha512,this.chainCode,ie)),ae=se.slice(0,32),ue=se.slice(32);let de=null,ve=null;this.privateKey?de=bytes32(BigNumber.from(ae).add(this.privateKey).mod(N$3)):ve=new SigningKey(hexlify(ae))._addPoint(this.publicKey);let ge=c;const we=this.mnemonic;return we&&(ge=Object.freeze({phrase:we.phrase,path:c,locale:we.locale||"en"})),new HDNode(_constructorGuard$1,de,ve,this.fingerprint,bytes32(ue),t,this.depth+1,ge)}derivePath(t){const c=t.split("/");if(c.length===0||c[0]==="m"&&this.depth!==0)throw new Error("invalid path - "+t);c[0]==="m"&&c.shift();let ie=this;for(let se=0;se<c.length;se++){const ae=c[se];if(ae.match(/^[0-9]+'$/)){const ue=parseInt(ae.substring(0,ae.length-1));if(ue>=HardenedBit)throw new Error("invalid path index - "+ae);ie=ie._derive(HardenedBit+ue)}else if(ae.match(/^[0-9]+$/)){const ue=parseInt(ae);if(ue>=HardenedBit)throw new Error("invalid path index - "+ae);ie=ie._derive(ue)}else throw new Error("invalid path component - "+ae)}return ie}static _fromSeed(t,c){const ie=arrayify(t);if(ie.length<16||ie.length>64)throw new Error("invalid seed");const se=arrayify(computeHmac(SupportedAlgorithm.sha512,MasterSecret,ie));return new HDNode(_constructorGuard$1,bytes32(se.slice(0,32)),null,"0x00000000",bytes32(se.slice(32)),0,0,c)}static fromMnemonic(t,c,ie){return ie=getWordlist(ie),t=entropyToMnemonic(mnemonicToEntropy(t,ie),ie),HDNode._fromSeed(mnemonicToSeed(t,c),{phrase:t,path:"m",locale:ie.locale})}static fromSeed(t){return HDNode._fromSeed(t,null)}static fromExtendedKey(t){const c=Base58.decode(t);(c.length!==82||base58check(c.slice(0,78))!==t)&&logger$c.throwArgumentError("invalid extended key","extendedKey","[REDACTED]");const ie=c[4],se=hexlify(c.slice(5,9)),ae=parseInt(hexlify(c.slice(9,13)).substring(2),16),ue=hexlify(c.slice(13,45)),de=c.slice(45,78);switch(hexlify(c.slice(0,4))){case"0x0488b21e":case"0x043587cf":return new HDNode(_constructorGuard$1,null,hexlify(de),se,ue,ae,ie,null);case"0x0488ade4":case"0x04358394 ":if(de[0]!==0)break;return new HDNode(_constructorGuard$1,hexlify(de.slice(1)),null,se,ue,ae,ie,null)}return logger$c.throwArgumentError("invalid extended key","extendedKey","[REDACTED]")}}function mnemonicToSeed(n,t){t||(t="");const c=toUtf8Bytes("mnemonic"+t,UnicodeNormalizationForm.NFKD);return pbkdf2$1(toUtf8Bytes(n,UnicodeNormalizationForm.NFKD),c,2048,64,"sha512")}function mnemonicToEntropy(n,t){t=getWordlist(t),logger$c.checkNormalize();const c=t.split(n);if(c.length%3!==0)throw new Error("invalid mnemonic");const ie=arrayify(new Uint8Array(Math.ceil(11*c.length/8)));let se=0;for(let ve=0;ve<c.length;ve++){let ge=t.getWordIndex(c[ve].normalize("NFKD"));if(ge===-1)throw new Error("invalid mnemonic");for(let we=0;we<11;we++)ge&1<<10-we&&(ie[se>>3]|=1<<7-se%8),se++}const ae=32*c.length/3,ue=c.length/3,de=getUpperMask(ue);if((arrayify(sha256$7(ie.slice(0,ae/8)))[0]&de)!==(ie[ie.length-1]&de))throw new Error("invalid checksum");return hexlify(ie.slice(0,ae/8))}function entropyToMnemonic(n,t){if(t=getWordlist(t),n=arrayify(n),n.length%4!==0||n.length<16||n.length>32)throw new Error("invalid entropy");const c=[0];let ie=11;for(let ue=0;ue<n.length;ue++)ie>8?(c[c.length-1]<<=8,c[c.length-1]|=n[ue],ie-=8):(c[c.length-1]<<=ie,c[c.length-1]|=n[ue]>>8-ie,c.push(n[ue]&getLowerMask(8-ie)),ie+=3);const se=n.length/4,ae=arrayify(sha256$7(n))[0]&getUpperMask(se);return c[c.length-1]<<=se,c[c.length-1]|=ae>>8-se,t.join(c.map(ue=>t.getWord(ue)))}function isValidMnemonic(n,t){try{return mnemonicToEntropy(n,t),!0}catch{}return!1}function getAccountPath(n){return(typeof n!="number"||n<0||n>=HardenedBit||n%1)&&logger$c.throwArgumentError("invalid account index","index",n),`m/44'/60'/${n}'/0/0`}const lib_esm$6=Object.freeze(Object.defineProperty({__proto__:null,HDNode,defaultPath,entropyToMnemonic,getAccountPath,isValidMnemonic,mnemonicToEntropy,mnemonicToSeed},Symbol.toStringTag,{value:"Module"})),version$d="random/5.8.0",logger$b=new Logger(version$d);function getGlobal(){if(typeof self<"u")return self;if(typeof window<"u")return window;if(typeof globalThis<"u")return globalThis;throw new Error("unable to locate global object")}const anyGlobal=getGlobal();let crypto$3=anyGlobal.crypto||anyGlobal.msCrypto;(!crypto$3||!crypto$3.getRandomValues)&&(logger$b.warn("WARNING: Missing strong random number source"),crypto$3={getRandomValues:function(n){return logger$b.throwError("no secure random source avaialble",Logger.errors.UNSUPPORTED_OPERATION,{operation:"crypto.getRandomValues"})}});function randomBytes$1(n){(n<=0||n>1024||n%1||n!=n)&&logger$b.throwArgumentError("invalid length","length",n);const t=new Uint8Array(n);return crypto$3.getRandomValues(t),arrayify(t)}function shuffled(n){n=n.slice();for(let t=n.length-1;t>0;t--){const c=Math.floor(Math.random()*(t+1)),ie=n[t];n[t]=n[c],n[c]=ie}return n}const lib_esm$5=Object.freeze(Object.defineProperty({__proto__:null,randomBytes:randomBytes$1,shuffled},Symbol.toStringTag,{value:"Module"}));var aesJs={exports:{}};(function(n,t){(function(c){function ie(We){return parseInt(We)===We}function se(We){if(!ie(We.length))return!1;for(var $t=0;$t<We.length;$t++)if(!ie(We[$t])||We[$t]<0||We[$t]>255)return!1;return!0}function ae(We,$t){if(We.buffer&&ArrayBuffer.isView(We)&&We.name==="Uint8Array")return $t&&(We.slice?We=We.slice():We=Array.prototype.slice.call(We)),We;if(Array.isArray(We)){if(!se(We))throw new Error("Array contains invalid value: "+We);return new Uint8Array(We)}if(ie(We.length)&&se(We))return new Uint8Array(We);throw new Error("unsupported array-like object")}function ue(We){return new Uint8Array(We)}function de(We,$t,dn,gn,Vt){(gn!=null||Vt!=null)&&(We.slice?We=We.slice(gn,Vt):We=Array.prototype.slice.call(We,gn,Vt)),$t.set(We,dn)}var ve=(function(){function We(dn){var gn=[],Vt=0;for(dn=encodeURI(dn);Vt<dn.length;){var Cn=dn.charCodeAt(Vt++);Cn===37?(gn.push(parseInt(dn.substr(Vt,2),16)),Vt+=2):gn.push(Cn)}return ae(gn)}function $t(dn){for(var gn=[],Vt=0;Vt<dn.length;){var Cn=dn[Vt];Cn<128?(gn.push(String.fromCharCode(Cn)),Vt++):Cn>191&&Cn<224?(gn.push(String.fromCharCode((Cn&31)<<6|dn[Vt+1]&63)),Vt+=2):(gn.push(String.fromCharCode((Cn&15)<<12|(dn[Vt+1]&63)<<6|dn[Vt+2]&63)),Vt+=3)}return gn.join("")}return{toBytes:We,fromBytes:$t}})(),ge=(function(){function We(gn){for(var Vt=[],Cn=0;Cn<gn.length;Cn+=2)Vt.push(parseInt(gn.substr(Cn,2),16));return Vt}var $t="0123456789abcdef";function dn(gn){for(var Vt=[],Cn=0;Cn<gn.length;Cn++){var un=gn[Cn];Vt.push($t[(un&240)>>4]+$t[un&15])}return Vt.join("")}return{toBytes:We,fromBytes:dn}})(),we={16:10,24:12,32:14},Te=[1,2,4,8,16,32,64,128,27,54,108,216,171,77,154,47,94,188,99,198,151,53,106,212,179,125,250,239,197,145],Ne=[99,124,119,123,242,107,111,197,48,1,103,43,254,215,171,118,202,130,201,125,250,89,71,240,173,212,162,175,156,164,114,192,183,253,147,38,54,63,247,204,52,165,229,241,113,216,49,21,4,199,35,195,24,150,5,154,7,18,128,226,235,39,178,117,9,131,44,26,27,110,90,160,82,59,214,179,41,227,47,132,83,209,0,237,32,252,177,91,106,203,190,57,74,76,88,207,208,239,170,251,67,77,51,133,69,249,2,127,80,60,159,168,81,163,64,143,146,157,56,245,188,182,218,33,16,255,243,210,205,12,19,236,95,151,68,23,196,167,126,61,100,93,25,115,96,129,79,220,34,42,144,136,70,238,184,20,222,94,11,219,224,50,58,10,73,6,36,92,194,211,172,98,145,149,228,121,231,200,55,109,141,213,78,169,108,86,244,234,101,122,174,8,186,120,37,46,28,166,180,198,232,221,116,31,75,189,139,138,112,62,181,102,72,3,246,14,97,53,87,185,134,193,29,158,225,248,152,17,105,217,142,148,155,30,135,233,206,85,40,223,140,161,137,13,191,230,66,104,65,153,45,15,176,84,187,22],qe=[82,9,106,213,48,54,165,56,191,64,163,158,129,243,215,251,124,227,57,130,155,47,255,135,52,142,67,68,196,222,233,203,84,123,148,50,166,194,35,61,238,76,149,11,66,250,195,78,8,46,161,102,40,217,36,178,118,91,162,73,109,139,209,37,114,248,246,100,134,104,152,22,212,164,92,204,93,101,182,146,108,112,72,80,253,237,185,218,94,21,70,87,167,141,157,132,144,216,171,0,140,188,211,10,247,228,88,5,184,179,69,6,208,44,30,143,202,63,15,2,193,175,189,3,1,19,138,107,58,145,17,65,79,103,220,234,151,242,207,206,240,180,230,115,150,172,116,34,231,173,53,133,226,249,55,232,28,117,223,110,71,241,26,113,29,41,197,137,111,183,98,14,170,24,190,27,252,86,62,75,198,210,121,32,154,219,192,254,120,205,90,244,31,221,168,51,136,7,199,49,177,18,16,89,39,128,236,95,96,81,127,169,25,181,74,13,45,229,122,159,147,201,156,239,160,224,59,77,174,42,245,176,200,235,187,60,131,83,153,97,23,43,4,126,186,119,214,38,225,105,20,99,85,33,12,125],ze=[3328402341,4168907908,4000806809,4135287693,4294111757,3597364157,3731845041,2445657428,1613770832,33620227,3462883241,1445669757,3892248089,3050821474,1303096294,3967186586,2412431941,528646813,2311702848,4202528135,4026202645,2992200171,2387036105,4226871307,1101901292,3017069671,1604494077,1169141738,597466303,1403299063,3832705686,2613100635,1974974402,3791519004,1033081774,1277568618,1815492186,2118074177,4126668546,2211236943,1748251740,1369810420,3521504564,4193382664,3799085459,2883115123,1647391059,706024767,134480908,2512897874,1176707941,2646852446,806885416,932615841,168101135,798661301,235341577,605164086,461406363,3756188221,3454790438,1311188841,2142417613,3933566367,302582043,495158174,1479289972,874125870,907746093,3698224818,3025820398,1537253627,2756858614,1983593293,3084310113,2108928974,1378429307,3722699582,1580150641,327451799,2790478837,3117535592,0,3253595436,1075847264,3825007647,2041688520,3059440621,3563743934,2378943302,1740553945,1916352843,2487896798,2555137236,2958579944,2244988746,3151024235,3320835882,1336584933,3992714006,2252555205,2588757463,1714631509,293963156,2319795663,3925473552,67240454,4269768577,2689618160,2017213508,631218106,1269344483,2723238387,1571005438,2151694528,93294474,1066570413,563977660,1882732616,4059428100,1673313503,2008463041,2950355573,1109467491,537923632,3858759450,4260623118,3218264685,2177748300,403442708,638784309,3287084079,3193921505,899127202,2286175436,773265209,2479146071,1437050866,4236148354,2050833735,3362022572,3126681063,840505643,3866325909,3227541664,427917720,2655997905,2749160575,1143087718,1412049534,999329963,193497219,2353415882,3354324521,1807268051,672404540,2816401017,3160301282,369822493,2916866934,3688947771,1681011286,1949973070,336202270,2454276571,201721354,1210328172,3093060836,2680341085,3184776046,1135389935,3294782118,965841320,831886756,3554993207,4068047243,3588745010,2345191491,1849112409,3664604599,26054028,2983581028,2622377682,1235855840,3630984372,2891339514,4092916743,3488279077,3395642799,4101667470,1202630377,268961816,1874508501,4034427016,1243948399,1546530418,941366308,1470539505,1941222599,2546386513,3421038627,2715671932,3899946140,1042226977,2521517021,1639824860,227249030,260737669,3765465232,2084453954,1907733956,3429263018,2420656344,100860677,4160157185,470683154,3261161891,1781871967,2924959737,1773779408,394692241,2579611992,974986535,664706745,3655459128,3958962195,731420851,571543859,3530123707,2849626480,126783113,865375399,765172662,1008606754,361203602,3387549984,2278477385,2857719295,1344809080,2782912378,59542671,1503764984,160008576,437062935,1707065306,3622233649,2218934982,3496503480,2185314755,697932208,1512910199,504303377,2075177163,2824099068,1841019862,739644986],He=[2781242211,2230877308,2582542199,2381740923,234877682,3184946027,2984144751,1418839493,1348481072,50462977,2848876391,2102799147,434634494,1656084439,3863849899,2599188086,1167051466,2636087938,1082771913,2281340285,368048890,3954334041,3381544775,201060592,3963727277,1739838676,4250903202,3930435503,3206782108,4149453988,2531553906,1536934080,3262494647,484572669,2923271059,1783375398,1517041206,1098792767,49674231,1334037708,1550332980,4098991525,886171109,150598129,2481090929,1940642008,1398944049,1059722517,201851908,1385547719,1699095331,1587397571,674240536,2704774806,252314885,3039795866,151914247,908333586,2602270848,1038082786,651029483,1766729511,3447698098,2682942837,454166793,2652734339,1951935532,775166490,758520603,3000790638,4004797018,4217086112,4137964114,1299594043,1639438038,3464344499,2068982057,1054729187,1901997871,2534638724,4121318227,1757008337,0,750906861,1614815264,535035132,3363418545,3988151131,3201591914,1183697867,3647454910,1265776953,3734260298,3566750796,3903871064,1250283471,1807470800,717615087,3847203498,384695291,3313910595,3617213773,1432761139,2484176261,3481945413,283769337,100925954,2180939647,4037038160,1148730428,3123027871,3813386408,4087501137,4267549603,3229630528,2315620239,2906624658,3156319645,1215313976,82966005,3747855548,3245848246,1974459098,1665278241,807407632,451280895,251524083,1841287890,1283575245,337120268,891687699,801369324,3787349855,2721421207,3431482436,959321879,1469301956,4065699751,2197585534,1199193405,2898814052,3887750493,724703513,2514908019,2696962144,2551808385,3516813135,2141445340,1715741218,2119445034,2872807568,2198571144,3398190662,700968686,3547052216,1009259540,2041044702,3803995742,487983883,1991105499,1004265696,1449407026,1316239930,504629770,3683797321,168560134,1816667172,3837287516,1570751170,1857934291,4014189740,2797888098,2822345105,2754712981,936633572,2347923833,852879335,1133234376,1500395319,3084545389,2348912013,1689376213,3533459022,3762923945,3034082412,4205598294,133428468,634383082,2949277029,2398386810,3913789102,403703816,3580869306,2297460856,1867130149,1918643758,607656988,4049053350,3346248884,1368901318,600565992,2090982877,2632479860,557719327,3717614411,3697393085,2249034635,2232388234,2430627952,1115438654,3295786421,2865522278,3633334344,84280067,33027830,303828494,2747425121,1600795957,4188952407,3496589753,2434238086,1486471617,658119965,3106381470,953803233,334231800,3005978776,857870609,3151128937,1890179545,2298973838,2805175444,3056442267,574365214,2450884487,550103529,1233637070,4289353045,2018519080,2057691103,2399374476,4166623649,2148108681,387583245,3664101311,836232934,3330556482,3100665960,3280093505,2955516313,2002398509,287182607,3413881008,4238890068,3597515707,975967766],Ge=[1671808611,2089089148,2006576759,2072901243,4061003762,1807603307,1873927791,3310653893,810573872,16974337,1739181671,729634347,4263110654,3613570519,2883997099,1989864566,3393556426,2191335298,3376449993,2106063485,4195741690,1508618841,1204391495,4027317232,2917941677,3563566036,2734514082,2951366063,2629772188,2767672228,1922491506,3227229120,3082974647,4246528509,2477669779,644500518,911895606,1061256767,4144166391,3427763148,878471220,2784252325,3845444069,4043897329,1905517169,3631459288,827548209,356461077,67897348,3344078279,593839651,3277757891,405286936,2527147926,84871685,2595565466,118033927,305538066,2157648768,3795705826,3945188843,661212711,2999812018,1973414517,152769033,2208177539,745822252,439235610,455947803,1857215598,1525593178,2700827552,1391895634,994932283,3596728278,3016654259,695947817,3812548067,795958831,2224493444,1408607827,3513301457,0,3979133421,543178784,4229948412,2982705585,1542305371,1790891114,3410398667,3201918910,961245753,1256100938,1289001036,1491644504,3477767631,3496721360,4012557807,2867154858,4212583931,1137018435,1305975373,861234739,2241073541,1171229253,4178635257,33948674,2139225727,1357946960,1011120188,2679776671,2833468328,1374921297,2751356323,1086357568,2408187279,2460827538,2646352285,944271416,4110742005,3168756668,3066132406,3665145818,560153121,271589392,4279952895,4077846003,3530407890,3444343245,202643468,322250259,3962553324,1608629855,2543990167,1154254916,389623319,3294073796,2817676711,2122513534,1028094525,1689045092,1575467613,422261273,1939203699,1621147744,2174228865,1339137615,3699352540,577127458,712922154,2427141008,2290289544,1187679302,3995715566,3100863416,339486740,3732514782,1591917662,186455563,3681988059,3762019296,844522546,978220090,169743370,1239126601,101321734,611076132,1558493276,3260915650,3547250131,2901361580,1655096418,2443721105,2510565781,3828863972,2039214713,3878868455,3359869896,928607799,1840765549,2374762893,3580146133,1322425422,2850048425,1823791212,1459268694,4094161908,3928346602,1706019429,2056189050,2934523822,135794696,3134549946,2022240376,628050469,779246638,472135708,2800834470,3032970164,3327236038,3894660072,3715932637,1956440180,522272287,1272813131,3185336765,2340818315,2323976074,1888542832,1044544574,3049550261,1722469478,1222152264,50660867,4127324150,236067854,1638122081,895445557,1475980887,3117443513,2257655686,3243809217,489110045,2662934430,3778599393,4162055160,2561878936,288563729,1773916777,3648039385,2391345038,2493985684,2612407707,505560094,2274497927,3911240169,3460925390,1442818645,678973480,3749357023,2358182796,2717407649,2306869641,219617805,3218761151,3862026214,1120306242,1756942440,1103331905,2578459033,762796589,252780047,2966125488,1425844308,3151392187,372911126],Ze=[1667474886,2088535288,2004326894,2071694838,4075949567,1802223062,1869591006,3318043793,808472672,16843522,1734846926,724270422,4278065639,3621216949,2880169549,1987484396,3402253711,2189597983,3385409673,2105378810,4210693615,1499065266,1195886990,4042263547,2913856577,3570689971,2728590687,2947541573,2627518243,2762274643,1920112356,3233831835,3082273397,4261223649,2475929149,640051788,909531756,1061110142,4160160501,3435941763,875846760,2779116625,3857003729,4059105529,1903268834,3638064043,825316194,353713962,67374088,3351728789,589522246,3284360861,404236336,2526454071,84217610,2593830191,117901582,303183396,2155911963,3806477791,3958056653,656894286,2998062463,1970642922,151591698,2206440989,741110872,437923380,454765878,1852748508,1515908788,2694904667,1381168804,993742198,3604373943,3014905469,690584402,3823320797,791638366,2223281939,1398011302,3520161977,0,3991743681,538992704,4244381667,2981218425,1532751286,1785380564,3419096717,3200178535,960056178,1246420628,1280103576,1482221744,3486468741,3503319995,4025428677,2863326543,4227536621,1128514950,1296947098,859002214,2240123921,1162203018,4193849577,33687044,2139062782,1347481760,1010582648,2678045221,2829640523,1364325282,2745433693,1077985408,2408548869,2459086143,2644360225,943212656,4126475505,3166494563,3065430391,3671750063,555836226,269496352,4294908645,4092792573,3537006015,3452783745,202118168,320025894,3974901699,1600119230,2543297077,1145359496,387397934,3301201811,2812801621,2122220284,1027426170,1684319432,1566435258,421079858,1936954854,1616945344,2172753945,1330631070,3705438115,572679748,707427924,2425400123,2290647819,1179044492,4008585671,3099120491,336870440,3739122087,1583276732,185277718,3688593069,3772791771,842159716,976899700,168435220,1229577106,101059084,606366792,1549591736,3267517855,3553849021,2897014595,1650632388,2442242105,2509612081,3840161747,2038008818,3890688725,3368567691,926374254,1835907034,2374863873,3587531953,1313788572,2846482505,1819063512,1448540844,4109633523,3941213647,1701162954,2054852340,2930698567,134748176,3132806511,2021165296,623210314,774795868,471606328,2795958615,3031746419,3334885783,3907527627,3722280097,1953799400,522133822,1263263126,3183336545,2341176845,2324333839,1886425312,1044267644,3048588401,1718004428,1212733584,50529542,4143317495,235803164,1633788866,892690282,1465383342,3115962473,2256965911,3250673817,488449850,2661202215,3789633753,4177007595,2560144171,286339874,1768537042,3654906025,2391705863,2492770099,2610673197,505291324,2273808917,3924369609,3469625735,1431699370,673740880,3755965093,2358021891,2711746649,2307489801,218961690,3217021541,3873845719,1111672452,1751693520,1094828930,2576986153,757954394,252645662,2964376443,1414855848,3149649517,370555436],Ye=[1374988112,2118214995,437757123,975658646,1001089995,530400753,2902087851,1273168787,540080725,2910219766,2295101073,4110568485,1340463100,3307916247,641025152,3043140495,3736164937,632953703,1172967064,1576976609,3274667266,2169303058,2370213795,1809054150,59727847,361929877,3211623147,2505202138,3569255213,1484005843,1239443753,2395588676,1975683434,4102977912,2572697195,666464733,3202437046,4035489047,3374361702,2110667444,1675577880,3843699074,2538681184,1649639237,2976151520,3144396420,4269907996,4178062228,1883793496,2403728665,2497604743,1383856311,2876494627,1917518562,3810496343,1716890410,3001755655,800440835,2261089178,3543599269,807962610,599762354,33778362,3977675356,2328828971,2809771154,4077384432,1315562145,1708848333,101039829,3509871135,3299278474,875451293,2733856160,92987698,2767645557,193195065,1080094634,1584504582,3178106961,1042385657,2531067453,3711829422,1306967366,2438237621,1908694277,67556463,1615861247,429456164,3602770327,2302690252,1742315127,2968011453,126454664,3877198648,2043211483,2709260871,2084704233,4169408201,0,159417987,841739592,504459436,1817866830,4245618683,260388950,1034867998,908933415,168810852,1750902305,2606453969,607530554,202008497,2472011535,3035535058,463180190,2160117071,1641816226,1517767529,470948374,3801332234,3231722213,1008918595,303765277,235474187,4069246893,766945465,337553864,1475418501,2943682380,4003061179,2743034109,4144047775,1551037884,1147550661,1543208500,2336434550,3408119516,3069049960,3102011747,3610369226,1113818384,328671808,2227573024,2236228733,3535486456,2935566865,3341394285,496906059,3702665459,226906860,2009195472,733156972,2842737049,294930682,1206477858,2835123396,2700099354,1451044056,573804783,2269728455,3644379585,2362090238,2564033334,2801107407,2776292904,3669462566,1068351396,742039012,1350078989,1784663195,1417561698,4136440770,2430122216,775550814,2193862645,2673705150,1775276924,1876241833,3475313331,3366754619,270040487,3902563182,3678124923,3441850377,1851332852,3969562369,2203032232,3868552805,2868897406,566021896,4011190502,3135740889,1248802510,3936291284,699432150,832877231,708780849,3332740144,899835584,1951317047,4236429990,3767586992,866637845,4043610186,1106041591,2144161806,395441711,1984812685,1139781709,3433712980,3835036895,2664543715,1282050075,3240894392,1181045119,2640243204,25965917,4203181171,4211818798,3009879386,2463879762,3910161971,1842759443,2597806476,933301370,1509430414,3943906441,3467192302,3076639029,3776767469,2051518780,2631065433,1441952575,404016761,1942435775,1408749034,1610459739,3745345300,2017778566,3400528769,3110650942,941896748,3265478751,371049330,3168937228,675039627,4279080257,967311729,135050206,3635733660,1683407248,2076935265,3576870512,1215061108,3501741890],Ft=[1347548327,1400783205,3273267108,2520393566,3409685355,4045380933,2880240216,2471224067,1428173050,4138563181,2441661558,636813900,4233094615,3620022987,2149987652,2411029155,1239331162,1730525723,2554718734,3781033664,46346101,310463728,2743944855,3328955385,3875770207,2501218972,3955191162,3667219033,768917123,3545789473,692707433,1150208456,1786102409,2029293177,1805211710,3710368113,3065962831,401639597,1724457132,3028143674,409198410,2196052529,1620529459,1164071807,3769721975,2226875310,486441376,2499348523,1483753576,428819965,2274680428,3075636216,598438867,3799141122,1474502543,711349675,129166120,53458370,2592523643,2782082824,4063242375,2988687269,3120694122,1559041666,730517276,2460449204,4042459122,2706270690,3446004468,3573941694,533804130,2328143614,2637442643,2695033685,839224033,1973745387,957055980,2856345839,106852767,1371368976,4181598602,1033297158,2933734917,1179510461,3046200461,91341917,1862534868,4284502037,605657339,2547432937,3431546947,2003294622,3182487618,2282195339,954669403,3682191598,1201765386,3917234703,3388507166,0,2198438022,1211247597,2887651696,1315723890,4227665663,1443857720,507358933,657861945,1678381017,560487590,3516619604,975451694,2970356327,261314535,3535072918,2652609425,1333838021,2724322336,1767536459,370938394,182621114,3854606378,1128014560,487725847,185469197,2918353863,3106780840,3356761769,2237133081,1286567175,3152976349,4255350624,2683765030,3160175349,3309594171,878443390,1988838185,3704300486,1756818940,1673061617,3403100636,272786309,1075025698,545572369,2105887268,4174560061,296679730,1841768865,1260232239,4091327024,3960309330,3497509347,1814803222,2578018489,4195456072,575138148,3299409036,446754879,3629546796,4011996048,3347532110,3252238545,4270639778,915985419,3483825537,681933534,651868046,2755636671,3828103837,223377554,2607439820,1649704518,3270937875,3901806776,1580087799,4118987695,3198115200,2087309459,2842678573,3016697106,1003007129,2802849917,1860738147,2077965243,164439672,4100872472,32283319,2827177882,1709610350,2125135846,136428751,3874428392,3652904859,3460984630,3572145929,3593056380,2939266226,824852259,818324884,3224740454,930369212,2801566410,2967507152,355706840,1257309336,4148292826,243256656,790073846,2373340630,1296297904,1422699085,3756299780,3818836405,457992840,3099667487,2135319889,77422314,1560382517,1945798516,788204353,1521706781,1385356242,870912086,325965383,2358957921,2050466060,2388260884,2313884476,4006521127,901210569,3990953189,1014646705,1503449823,1062597235,2031621326,3212035895,3931371469,1533017514,350174575,2256028891,2177544179,1052338372,741876788,1606591296,1914052035,213705253,2334669897,1107234197,1899603969,3725069491,2631447780,2422494913,1635502980,1893020342,1950903388,1120974935],Mt=[2807058932,1699970625,2764249623,1586903591,1808481195,1173430173,1487645946,59984867,4199882800,1844882806,1989249228,1277555970,3623636965,3419915562,1149249077,2744104290,1514790577,459744698,244860394,3235995134,1963115311,4027744588,2544078150,4190530515,1608975247,2627016082,2062270317,1507497298,2200818878,567498868,1764313568,3359936201,2305455554,2037970062,1047239e3,1910319033,1337376481,2904027272,2892417312,984907214,1243112415,830661914,861968209,2135253587,2011214180,2927934315,2686254721,731183368,1750626376,4246310725,1820824798,4172763771,3542330227,48394827,2404901663,2871682645,671593195,3254988725,2073724613,145085239,2280796200,2779915199,1790575107,2187128086,472615631,3029510009,4075877127,3802222185,4107101658,3201631749,1646252340,4270507174,1402811438,1436590835,3778151818,3950355702,3963161475,4020912224,2667994737,273792366,2331590177,104699613,95345982,3175501286,2377486676,1560637892,3564045318,369057872,4213447064,3919042237,1137477952,2658625497,1119727848,2340947849,1530455833,4007360968,172466556,266959938,516552836,0,2256734592,3980931627,1890328081,1917742170,4294704398,945164165,3575528878,958871085,3647212047,2787207260,1423022939,775562294,1739656202,3876557655,2530391278,2443058075,3310321856,547512796,1265195639,437656594,3121275539,719700128,3762502690,387781147,218828297,3350065803,2830708150,2848461854,428169201,122466165,3720081049,1627235199,648017665,4122762354,1002783846,2117360635,695634755,3336358691,4234721005,4049844452,3704280881,2232435299,574624663,287343814,612205898,1039717051,840019705,2708326185,793451934,821288114,1391201670,3822090177,376187827,3113855344,1224348052,1679968233,2361698556,1058709744,752375421,2431590963,1321699145,3519142200,2734591178,188127444,2177869557,3727205754,2384911031,3215212461,2648976442,2450346104,3432737375,1180849278,331544205,3102249176,4150144569,2952102595,2159976285,2474404304,766078933,313773861,2570832044,2108100632,1668212892,3145456443,2013908262,418672217,3070356634,2594734927,1852171925,3867060991,3473416636,3907448597,2614737639,919489135,164948639,2094410160,2997825956,590424639,2486224549,1723872674,3157750862,3399941250,3501252752,3625268135,2555048196,3673637356,1343127501,4130281361,3599595085,2957853679,1297403050,81781910,3051593425,2283490410,532201772,1367295589,3926170974,895287692,1953757831,1093597963,492483431,3528626907,1446242576,1192455638,1636604631,209336225,344873464,1015671571,669961897,3375740769,3857572124,2973530695,3747192018,1933530610,3464042516,935293895,3454686199,2858115069,1863638845,3683022916,4085369519,3292445032,875313188,1080017571,3279033885,621591778,1233856572,2504130317,24197544,3017672716,3835484340,3247465558,2220981195,3060847922,1551124588,1463996600],Zt=[4104605777,1097159550,396673818,660510266,2875968315,2638606623,4200115116,3808662347,821712160,1986918061,3430322568,38544885,3856137295,718002117,893681702,1654886325,2975484382,3122358053,3926825029,4274053469,796197571,1290801793,1184342925,3556361835,2405426947,2459735317,1836772287,1381620373,3196267988,1948373848,3764988233,3385345166,3263785589,2390325492,1480485785,3111247143,3780097726,2293045232,548169417,3459953789,3746175075,439452389,1362321559,1400849762,1685577905,1806599355,2174754046,137073913,1214797936,1174215055,3731654548,2079897426,1943217067,1258480242,529487843,1437280870,3945269170,3049390895,3313212038,923313619,679998e3,3215307299,57326082,377642221,3474729866,2041877159,133361907,1776460110,3673476453,96392454,878845905,2801699524,777231668,4082475170,2330014213,4142626212,2213296395,1626319424,1906247262,1846563261,562755902,3708173718,1040559837,3871163981,1418573201,3294430577,114585348,1343618912,2566595609,3186202582,1078185097,3651041127,3896688048,2307622919,425408743,3371096953,2081048481,1108339068,2216610296,0,2156299017,736970802,292596766,1517440620,251657213,2235061775,2933202493,758720310,265905162,1554391400,1532285339,908999204,174567692,1474760595,4002861748,2610011675,3234156416,3693126241,2001430874,303699484,2478443234,2687165888,585122620,454499602,151849742,2345119218,3064510765,514443284,4044981591,1963412655,2581445614,2137062819,19308535,1928707164,1715193156,4219352155,1126790795,600235211,3992742070,3841024952,836553431,1669664834,2535604243,3323011204,1243905413,3141400786,4180808110,698445255,2653899549,2989552604,2253581325,3252932727,3004591147,1891211689,2487810577,3915653703,4237083816,4030667424,2100090966,865136418,1229899655,953270745,3399679628,3557504664,4118925222,2061379749,3079546586,2915017791,983426092,2022837584,1607244650,2118541908,2366882550,3635996816,972512814,3283088770,1568718495,3499326569,3576539503,621982671,2895723464,410887952,2623762152,1002142683,645401037,1494807662,2595684844,1335535747,2507040230,4293295786,3167684641,367585007,3885750714,1865862730,2668221674,2960971305,2763173681,1059270954,2777952454,2724642869,1320957812,2194319100,2429595872,2815956275,77089521,3973773121,3444575871,2448830231,1305906550,4021308739,2857194700,2516901860,3518358430,1787304780,740276417,1699839814,1592394909,2352307457,2272556026,188821243,1729977011,3687994002,274084841,3594982253,3613494426,2701949495,4162096729,322734571,2837966542,1640576439,484830689,1202797690,3537852828,4067639125,349075736,3342319475,4157467219,4255800159,1030690015,1155237496,2951971274,1757691577,607398968,2738905026,499347990,3794078908,1011452712,227885567,2818666809,213114376,3034881240,1455525988,3414450555,850817237,1817998408,3092726480],cn=[0,235474187,470948374,303765277,941896748,908933415,607530554,708780849,1883793496,2118214995,1817866830,1649639237,1215061108,1181045119,1417561698,1517767529,3767586992,4003061179,4236429990,4069246893,3635733660,3602770327,3299278474,3400528769,2430122216,2664543715,2362090238,2193862645,2835123396,2801107407,3035535058,3135740889,3678124923,3576870512,3341394285,3374361702,3810496343,3977675356,4279080257,4043610186,2876494627,2776292904,3076639029,3110650942,2472011535,2640243204,2403728665,2169303058,1001089995,899835584,666464733,699432150,59727847,226906860,530400753,294930682,1273168787,1172967064,1475418501,1509430414,1942435775,2110667444,1876241833,1641816226,2910219766,2743034109,2976151520,3211623147,2505202138,2606453969,2302690252,2269728455,3711829422,3543599269,3240894392,3475313331,3843699074,3943906441,4178062228,4144047775,1306967366,1139781709,1374988112,1610459739,1975683434,2076935265,1775276924,1742315127,1034867998,866637845,566021896,800440835,92987698,193195065,429456164,395441711,1984812685,2017778566,1784663195,1683407248,1315562145,1080094634,1383856311,1551037884,101039829,135050206,437757123,337553864,1042385657,807962610,573804783,742039012,2531067453,2564033334,2328828971,2227573024,2935566865,2700099354,3001755655,3168937228,3868552805,3902563182,4203181171,4102977912,3736164937,3501741890,3265478751,3433712980,1106041591,1340463100,1576976609,1408749034,2043211483,2009195472,1708848333,1809054150,832877231,1068351396,766945465,599762354,159417987,126454664,361929877,463180190,2709260871,2943682380,3178106961,3009879386,2572697195,2538681184,2236228733,2336434550,3509871135,3745345300,3441850377,3274667266,3910161971,3877198648,4110568485,4211818798,2597806476,2497604743,2261089178,2295101073,2733856160,2902087851,3202437046,2968011453,3936291284,3835036895,4136440770,4169408201,3535486456,3702665459,3467192302,3231722213,2051518780,1951317047,1716890410,1750902305,1113818384,1282050075,1584504582,1350078989,168810852,67556463,371049330,404016761,841739592,1008918595,775550814,540080725,3969562369,3801332234,4035489047,4269907996,3569255213,3669462566,3366754619,3332740144,2631065433,2463879762,2160117071,2395588676,2767645557,2868897406,3102011747,3069049960,202008497,33778362,270040487,504459436,875451293,975658646,675039627,641025152,2084704233,1917518562,1615861247,1851332852,1147550661,1248802510,1484005843,1451044056,933301370,967311729,733156972,632953703,260388950,25965917,328671808,496906059,1206477858,1239443753,1543208500,1441952575,2144161806,1908694277,1675577880,1842759443,3610369226,3644379585,3408119516,3307916247,4011190502,3776767469,4077384432,4245618683,2809771154,2842737049,3144396420,3043140495,2673705150,2438237621,2203032232,2370213795],hn=[0,185469197,370938394,487725847,741876788,657861945,975451694,824852259,1483753576,1400783205,1315723890,1164071807,1950903388,2135319889,1649704518,1767536459,2967507152,3152976349,2801566410,2918353863,2631447780,2547432937,2328143614,2177544179,3901806776,3818836405,4270639778,4118987695,3299409036,3483825537,3535072918,3652904859,2077965243,1893020342,1841768865,1724457132,1474502543,1559041666,1107234197,1257309336,598438867,681933534,901210569,1052338372,261314535,77422314,428819965,310463728,3409685355,3224740454,3710368113,3593056380,3875770207,3960309330,4045380933,4195456072,2471224067,2554718734,2237133081,2388260884,3212035895,3028143674,2842678573,2724322336,4138563181,4255350624,3769721975,3955191162,3667219033,3516619604,3431546947,3347532110,2933734917,2782082824,3099667487,3016697106,2196052529,2313884476,2499348523,2683765030,1179510461,1296297904,1347548327,1533017514,1786102409,1635502980,2087309459,2003294622,507358933,355706840,136428751,53458370,839224033,957055980,605657339,790073846,2373340630,2256028891,2607439820,2422494913,2706270690,2856345839,3075636216,3160175349,3573941694,3725069491,3273267108,3356761769,4181598602,4063242375,4011996048,3828103837,1033297158,915985419,730517276,545572369,296679730,446754879,129166120,213705253,1709610350,1860738147,1945798516,2029293177,1239331162,1120974935,1606591296,1422699085,4148292826,4233094615,3781033664,3931371469,3682191598,3497509347,3446004468,3328955385,2939266226,2755636671,3106780840,2988687269,2198438022,2282195339,2501218972,2652609425,1201765386,1286567175,1371368976,1521706781,1805211710,1620529459,2105887268,1988838185,533804130,350174575,164439672,46346101,870912086,954669403,636813900,788204353,2358957921,2274680428,2592523643,2441661558,2695033685,2880240216,3065962831,3182487618,3572145929,3756299780,3270937875,3388507166,4174560061,4091327024,4006521127,3854606378,1014646705,930369212,711349675,560487590,272786309,457992840,106852767,223377554,1678381017,1862534868,1914052035,2031621326,1211247597,1128014560,1580087799,1428173050,32283319,182621114,401639597,486441376,768917123,651868046,1003007129,818324884,1503449823,1385356242,1333838021,1150208456,1973745387,2125135846,1673061617,1756818940,2970356327,3120694122,2802849917,2887651696,2637442643,2520393566,2334669897,2149987652,3917234703,3799141122,4284502037,4100872472,3309594171,3460984630,3545789473,3629546796,2050466060,1899603969,1814803222,1730525723,1443857720,1560382517,1075025698,1260232239,575138148,692707433,878443390,1062597235,243256656,91341917,409198410,325965383,3403100636,3252238545,3704300486,3620022987,3874428392,3990953189,4042459122,4227665663,2460449204,2578018489,2226875310,2411029155,3198115200,3046200461,2827177882,2743944855],yn=[0,218828297,437656594,387781147,875313188,958871085,775562294,590424639,1750626376,1699970625,1917742170,2135253587,1551124588,1367295589,1180849278,1265195639,3501252752,3720081049,3399941250,3350065803,3835484340,3919042237,4270507174,4085369519,3102249176,3051593425,2734591178,2952102595,2361698556,2177869557,2530391278,2614737639,3145456443,3060847922,2708326185,2892417312,2404901663,2187128086,2504130317,2555048196,3542330227,3727205754,3375740769,3292445032,3876557655,3926170974,4246310725,4027744588,1808481195,1723872674,1910319033,2094410160,1608975247,1391201670,1173430173,1224348052,59984867,244860394,428169201,344873464,935293895,984907214,766078933,547512796,1844882806,1627235199,2011214180,2062270317,1507497298,1423022939,1137477952,1321699145,95345982,145085239,532201772,313773861,830661914,1015671571,731183368,648017665,3175501286,2957853679,2807058932,2858115069,2305455554,2220981195,2474404304,2658625497,3575528878,3625268135,3473416636,3254988725,3778151818,3963161475,4213447064,4130281361,3599595085,3683022916,3432737375,3247465558,3802222185,4020912224,4172763771,4122762354,3201631749,3017672716,2764249623,2848461854,2331590177,2280796200,2431590963,2648976442,104699613,188127444,472615631,287343814,840019705,1058709744,671593195,621591778,1852171925,1668212892,1953757831,2037970062,1514790577,1463996600,1080017571,1297403050,3673637356,3623636965,3235995134,3454686199,4007360968,3822090177,4107101658,4190530515,2997825956,3215212461,2830708150,2779915199,2256734592,2340947849,2627016082,2443058075,172466556,122466165,273792366,492483431,1047239e3,861968209,612205898,695634755,1646252340,1863638845,2013908262,1963115311,1446242576,1530455833,1277555970,1093597963,1636604631,1820824798,2073724613,1989249228,1436590835,1487645946,1337376481,1119727848,164948639,81781910,331544205,516552836,1039717051,821288114,669961897,719700128,2973530695,3157750862,2871682645,2787207260,2232435299,2283490410,2667994737,2450346104,3647212047,3564045318,3279033885,3464042516,3980931627,3762502690,4150144569,4199882800,3070356634,3121275539,2904027272,2686254721,2200818878,2384911031,2570832044,2486224549,3747192018,3528626907,3310321856,3359936201,3950355702,3867060991,4049844452,4234721005,1739656202,1790575107,2108100632,1890328081,1402811438,1586903591,1233856572,1149249077,266959938,48394827,369057872,418672217,1002783846,919489135,567498868,752375421,209336225,24197544,376187827,459744698,945164165,895287692,574624663,793451934,1679968233,1764313568,2117360635,1933530610,1343127501,1560637892,1243112415,1192455638,3704280881,3519142200,3336358691,3419915562,3907448597,3857572124,4075877127,4294704398,3029510009,3113855344,2927934315,2744104290,2159976285,2377486676,2594734927,2544078150],Ht=[0,151849742,303699484,454499602,607398968,758720310,908999204,1059270954,1214797936,1097159550,1517440620,1400849762,1817998408,1699839814,2118541908,2001430874,2429595872,2581445614,2194319100,2345119218,3034881240,3186202582,2801699524,2951971274,3635996816,3518358430,3399679628,3283088770,4237083816,4118925222,4002861748,3885750714,1002142683,850817237,698445255,548169417,529487843,377642221,227885567,77089521,1943217067,2061379749,1640576439,1757691577,1474760595,1592394909,1174215055,1290801793,2875968315,2724642869,3111247143,2960971305,2405426947,2253581325,2638606623,2487810577,3808662347,3926825029,4044981591,4162096729,3342319475,3459953789,3576539503,3693126241,1986918061,2137062819,1685577905,1836772287,1381620373,1532285339,1078185097,1229899655,1040559837,923313619,740276417,621982671,439452389,322734571,137073913,19308535,3871163981,4021308739,4104605777,4255800159,3263785589,3414450555,3499326569,3651041127,2933202493,2815956275,3167684641,3049390895,2330014213,2213296395,2566595609,2448830231,1305906550,1155237496,1607244650,1455525988,1776460110,1626319424,2079897426,1928707164,96392454,213114376,396673818,514443284,562755902,679998e3,865136418,983426092,3708173718,3557504664,3474729866,3323011204,4180808110,4030667424,3945269170,3794078908,2507040230,2623762152,2272556026,2390325492,2975484382,3092726480,2738905026,2857194700,3973773121,3856137295,4274053469,4157467219,3371096953,3252932727,3673476453,3556361835,2763173681,2915017791,3064510765,3215307299,2156299017,2307622919,2459735317,2610011675,2081048481,1963412655,1846563261,1729977011,1480485785,1362321559,1243905413,1126790795,878845905,1030690015,645401037,796197571,274084841,425408743,38544885,188821243,3613494426,3731654548,3313212038,3430322568,4082475170,4200115116,3780097726,3896688048,2668221674,2516901860,2366882550,2216610296,3141400786,2989552604,2837966542,2687165888,1202797690,1320957812,1437280870,1554391400,1669664834,1787304780,1906247262,2022837584,265905162,114585348,499347990,349075736,736970802,585122620,972512814,821712160,2595684844,2478443234,2293045232,2174754046,3196267988,3079546586,2895723464,2777952454,3537852828,3687994002,3234156416,3385345166,4142626212,4293295786,3841024952,3992742070,174567692,57326082,410887952,292596766,777231668,660510266,1011452712,893681702,1108339068,1258480242,1343618912,1494807662,1715193156,1865862730,1948373848,2100090966,2701949495,2818666809,3004591147,3122358053,2235061775,2352307457,2535604243,2653899549,3915653703,3764988233,4219352155,4067639125,3444575871,3294430577,3746175075,3594982253,836553431,953270745,600235211,718002117,367585007,484830689,133361907,251657213,2041877159,1891211689,1806599355,1654886325,1568718495,1418573201,1335535747,1184342925];function Sn(We){for(var $t=[],dn=0;dn<We.length;dn+=4)$t.push(We[dn]<<24|We[dn+1]<<16|We[dn+2]<<8|We[dn+3]);return $t}var le=function(We){if(!(this instanceof le))throw Error("AES must be instanitated with `new`");Object.defineProperty(this,"key",{value:ae(We,!0)}),this._prepare()};le.prototype._prepare=function(){var We=we[this.key.length];if(We==null)throw new Error("invalid key size (must be 16, 24 or 32 bytes)");this._Ke=[],this._Kd=[];for(var $t=0;$t<=We;$t++)this._Ke.push([0,0,0,0]),this._Kd.push([0,0,0,0]);for(var dn=(We+1)*4,gn=this.key.length/4,Vt=Sn(this.key),Cn,$t=0;$t<gn;$t++)Cn=$t>>2,this._Ke[Cn][$t%4]=Vt[$t],this._Kd[We-Cn][$t%4]=Vt[$t];for(var un=0,Pt=gn,mn;Pt<dn;){if(mn=Vt[gn-1],Vt[0]^=Ne[mn>>16&255]<<24^Ne[mn>>8&255]<<16^Ne[mn&255]<<8^Ne[mn>>24&255]^Te[un]<<24,un+=1,gn!=8)for(var $t=1;$t<gn;$t++)Vt[$t]^=Vt[$t-1];else{for(var $t=1;$t<gn/2;$t++)Vt[$t]^=Vt[$t-1];mn=Vt[gn/2-1],Vt[gn/2]^=Ne[mn&255]^Ne[mn>>8&255]<<8^Ne[mn>>16&255]<<16^Ne[mn>>24&255]<<24;for(var $t=gn/2+1;$t<gn;$t++)Vt[$t]^=Vt[$t-1]}for(var $t=0,Pn,wn;$t<gn&&Pt<dn;)Pn=Pt>>2,wn=Pt%4,this._Ke[Pn][wn]=Vt[$t],this._Kd[We-Pn][wn]=Vt[$t++],Pt++}for(var Pn=1;Pn<We;Pn++)for(var wn=0;wn<4;wn++)mn=this._Kd[Pn][wn],this._Kd[Pn][wn]=cn[mn>>24&255]^hn[mn>>16&255]^yn[mn>>8&255]^Ht[mn&255]},le.prototype.encrypt=function(We){if(We.length!=16)throw new Error("invalid plaintext size (must be 16 bytes)");for(var $t=this._Ke.length-1,dn=[0,0,0,0],gn=Sn(We),Vt=0;Vt<4;Vt++)gn[Vt]^=this._Ke[0][Vt];for(var Cn=1;Cn<$t;Cn++){for(var Vt=0;Vt<4;Vt++)dn[Vt]=ze[gn[Vt]>>24&255]^He[gn[(Vt+1)%4]>>16&255]^Ge[gn[(Vt+2)%4]>>8&255]^Ze[gn[(Vt+3)%4]&255]^this._Ke[Cn][Vt];gn=dn.slice()}for(var un=ue(16),Pt,Vt=0;Vt<4;Vt++)Pt=this._Ke[$t][Vt],un[4*Vt]=(Ne[gn[Vt]>>24&255]^Pt>>24)&255,un[4*Vt+1]=(Ne[gn[(Vt+1)%4]>>16&255]^Pt>>16)&255,un[4*Vt+2]=(Ne[gn[(Vt+2)%4]>>8&255]^Pt>>8)&255,un[4*Vt+3]=(Ne[gn[(Vt+3)%4]&255]^Pt)&255;return un},le.prototype.decrypt=function(We){if(We.length!=16)throw new Error("invalid ciphertext size (must be 16 bytes)");for(var $t=this._Kd.length-1,dn=[0,0,0,0],gn=Sn(We),Vt=0;Vt<4;Vt++)gn[Vt]^=this._Kd[0][Vt];for(var Cn=1;Cn<$t;Cn++){for(var Vt=0;Vt<4;Vt++)dn[Vt]=Ye[gn[Vt]>>24&255]^Ft[gn[(Vt+3)%4]>>16&255]^Mt[gn[(Vt+2)%4]>>8&255]^Zt[gn[(Vt+1)%4]&255]^this._Kd[Cn][Vt];gn=dn.slice()}for(var un=ue(16),Pt,Vt=0;Vt<4;Vt++)Pt=this._Kd[$t][Vt],un[4*Vt]=(qe[gn[Vt]>>24&255]^Pt>>24)&255,un[4*Vt+1]=(qe[gn[(Vt+3)%4]>>16&255]^Pt>>16)&255,un[4*Vt+2]=(qe[gn[(Vt+2)%4]>>8&255]^Pt>>8)&255,un[4*Vt+3]=(qe[gn[(Vt+1)%4]&255]^Pt)&255;return un};var pe=function(We){if(!(this instanceof pe))throw Error("AES must be instanitated with `new`");this.description="Electronic Code Block",this.name="ecb",this._aes=new le(We)};pe.prototype.encrypt=function(We){if(We=ae(We),We.length%16!==0)throw new Error("invalid plaintext size (must be multiple of 16 bytes)");for(var $t=ue(We.length),dn=ue(16),gn=0;gn<We.length;gn+=16)de(We,dn,0,gn,gn+16),dn=this._aes.encrypt(dn),de(dn,$t,gn);return $t},pe.prototype.decrypt=function(We){if(We=ae(We),We.length%16!==0)throw new Error("invalid ciphertext size (must be multiple of 16 bytes)");for(var $t=ue(We.length),dn=ue(16),gn=0;gn<We.length;gn+=16)de(We,dn,0,gn,gn+16),dn=this._aes.decrypt(dn),de(dn,$t,gn);return $t};var be=function(We,$t){if(!(this instanceof be))throw Error("AES must be instanitated with `new`");if(this.description="Cipher Block Chaining",this.name="cbc",!$t)$t=ue(16);else if($t.length!=16)throw new Error("invalid initialation vector size (must be 16 bytes)");this._lastCipherblock=ae($t,!0),this._aes=new le(We)};be.prototype.encrypt=function(We){if(We=ae(We),We.length%16!==0)throw new Error("invalid plaintext size (must be multiple of 16 bytes)");for(var $t=ue(We.length),dn=ue(16),gn=0;gn<We.length;gn+=16){de(We,dn,0,gn,gn+16);for(var Vt=0;Vt<16;Vt++)dn[Vt]^=this._lastCipherblock[Vt];this._lastCipherblock=this._aes.encrypt(dn),de(this._lastCipherblock,$t,gn)}return $t},be.prototype.decrypt=function(We){if(We=ae(We),We.length%16!==0)throw new Error("invalid ciphertext size (must be multiple of 16 bytes)");for(var $t=ue(We.length),dn=ue(16),gn=0;gn<We.length;gn+=16){de(We,dn,0,gn,gn+16),dn=this._aes.decrypt(dn);for(var Vt=0;Vt<16;Vt++)$t[gn+Vt]=dn[Vt]^this._lastCipherblock[Vt];de(We,this._lastCipherblock,0,gn,gn+16)}return $t};var xe=function(We,$t,dn){if(!(this instanceof xe))throw Error("AES must be instanitated with `new`");if(this.description="Cipher Feedback",this.name="cfb",!$t)$t=ue(16);else if($t.length!=16)throw new Error("invalid initialation vector size (must be 16 size)");dn||(dn=1),this.segmentSize=dn,this._shiftRegister=ae($t,!0),this._aes=new le(We)};xe.prototype.encrypt=function(We){if(We.length%this.segmentSize!=0)throw new Error("invalid plaintext size (must be segmentSize bytes)");for(var $t=ae(We,!0),dn,gn=0;gn<$t.length;gn+=this.segmentSize){dn=this._aes.encrypt(this._shiftRegister);for(var Vt=0;Vt<this.segmentSize;Vt++)$t[gn+Vt]^=dn[Vt];de(this._shiftRegister,this._shiftRegister,0,this.segmentSize),de($t,this._shiftRegister,16-this.segmentSize,gn,gn+this.segmentSize)}return $t},xe.prototype.decrypt=function(We){if(We.length%this.segmentSize!=0)throw new Error("invalid ciphertext size (must be segmentSize bytes)");for(var $t=ae(We,!0),dn,gn=0;gn<$t.length;gn+=this.segmentSize){dn=this._aes.encrypt(this._shiftRegister);for(var Vt=0;Vt<this.segmentSize;Vt++)$t[gn+Vt]^=dn[Vt];de(this._shiftRegister,this._shiftRegister,0,this.segmentSize),de(We,this._shiftRegister,16-this.segmentSize,gn,gn+this.segmentSize)}return $t};var _e=function(We,$t){if(!(this instanceof _e))throw Error("AES must be instanitated with `new`");if(this.description="Output Feedback",this.name="ofb",!$t)$t=ue(16);else if($t.length!=16)throw new Error("invalid initialation vector size (must be 16 bytes)");this._lastPrecipher=ae($t,!0),this._lastPrecipherIndex=16,this._aes=new le(We)};_e.prototype.encrypt=function(We){for(var $t=ae(We,!0),dn=0;dn<$t.length;dn++)this._lastPrecipherIndex===16&&(this._lastPrecipher=this._aes.encrypt(this._lastPrecipher),this._lastPrecipherIndex=0),$t[dn]^=this._lastPrecipher[this._lastPrecipherIndex++];return $t},_e.prototype.decrypt=_e.prototype.encrypt;var De=function(We){if(!(this instanceof De))throw Error("Counter must be instanitated with `new`");We!==0&&!We&&(We=1),typeof We=="number"?(this._counter=ue(16),this.setValue(We)):this.setBytes(We)};De.prototype.setValue=function(We){if(typeof We!="number"||parseInt(We)!=We)throw new Error("invalid counter value (must be an integer)");for(var $t=15;$t>=0;--$t)this._counter[$t]=We%256,We=We>>8},De.prototype.setBytes=function(We){if(We=ae(We,!0),We.length!=16)throw new Error("invalid counter bytes size (must be 16 bytes)");this._counter=We},De.prototype.increment=function(){for(var We=15;We>=0;We--)if(this._counter[We]===255)this._counter[We]=0;else{this._counter[We]++;break}};var Fe=function(We,$t){if(!(this instanceof Fe))throw Error("AES must be instanitated with `new`");this.description="Counter",this.name="ctr",$t instanceof De||($t=new De($t)),this._counter=$t,this._remainingCounter=null,this._remainingCounterIndex=16,this._aes=new le(We)};Fe.prototype.encrypt=function(We){for(var $t=ae(We,!0),dn=0;dn<$t.length;dn++)this._remainingCounterIndex===16&&(this._remainingCounter=this._aes.encrypt(this._counter._counter),this._remainingCounterIndex=0,this._counter.increment()),$t[dn]^=this._remainingCounter[this._remainingCounterIndex++];return $t},Fe.prototype.decrypt=Fe.prototype.encrypt;function $e(We){We=ae(We,!0);var $t=16-We.length%16,dn=ue(We.length+$t);de(We,dn);for(var gn=We.length;gn<dn.length;gn++)dn[gn]=$t;return dn}function ce(We){if(We=ae(We,!0),We.length<16)throw new Error("PKCS#7 invalid length");var $t=We[We.length-1];if($t>16)throw new Error("PKCS#7 padding byte out of range");for(var dn=We.length-$t,gn=0;gn<$t;gn++)if(We[dn+gn]!==$t)throw new Error("PKCS#7 invalid padding byte");var Vt=ue(dn);return de(We,Vt,0,0,dn),Vt}var Me={AES:le,Counter:De,ModeOfOperation:{ecb:pe,cbc:be,cfb:xe,ofb:_e,ctr:Fe},utils:{hex:ge,utf8:ve},padding:{pkcs7:{pad:$e,strip:ce}},_arrayTest:{coerceArray:ae,createArray:ue,copyArray:de}};n.exports=Me})()})(aesJs);var aesJsExports=aesJs.exports;const aes$1=getDefaultExportFromCjs$2(aesJsExports),version$c="json-wallets/5.8.0";function looseArrayify(n){return typeof n=="string"&&n.substring(0,2)!=="0x"&&(n="0x"+n),arrayify(n)}function zpad(n,t){for(n=String(n);n.length<t;)n="0"+n;return n}function getPassword(n){return typeof n=="string"?toUtf8Bytes(n,UnicodeNormalizationForm.NFKC):arrayify(n)}function searchPath(n,t){let c=n;const ie=t.toLowerCase().split("/");for(let se=0;se<ie.length;se++){let ae=null;for(const ue in c)if(ue.toLowerCase()===ie[se]){ae=c[ue];break}if(ae===null)return null;c=ae}return c}function uuidV4(n){const t=arrayify(n);t[6]=t[6]&15|64,t[8]=t[8]&63|128;const c=hexlify(t);return[c.substring(2,10),c.substring(10,14),c.substring(14,18),c.substring(18,22),c.substring(22,34)].join("-")}const logger$a=new Logger(version$c);class CrowdsaleAccount extends Description{isCrowdsaleAccount(t){return!!(t&&t._isCrowdsaleAccount)}}function decrypt$1(n,t){const c=JSON.parse(n);t=getPassword(t);const ie=getAddress$1(searchPath(c,"ethaddr")),se=looseArrayify(searchPath(c,"encseed"));(!se||se.length%16!==0)&&logger$a.throwArgumentError("invalid encseed","json",n);const ae=arrayify(pbkdf2$1(t,t,2e3,32,"sha256")).slice(0,16),ue=se.slice(0,16),de=se.slice(16),ve=new aes$1.ModeOfOperation.cbc(ae,ue),ge=aes$1.padding.pkcs7.strip(arrayify(ve.decrypt(de)));let we="";for(let qe=0;qe<ge.length;qe++)we+=String.fromCharCode(ge[qe]);const Te=toUtf8Bytes(we),Ne=keccak256$1(Te);return new CrowdsaleAccount({_isCrowdsaleAccount:!0,address:ie,privateKey:Ne})}function isCrowdsaleWallet(n){let t=null;try{t=JSON.parse(n)}catch{return!1}return t.encseed&&t.ethaddr}function isKeystoreWallet(n){let t=null;try{t=JSON.parse(n)}catch{return!1}return!(!t.version||parseInt(t.version)!==t.version||parseInt(t.version)!==3)}function getJsonWalletAddress(n){if(isCrowdsaleWallet(n))try{return getAddress$1(JSON.parse(n).ethaddr)}catch{return null}if(isKeystoreWallet(n))try{return getAddress$1(JSON.parse(n).address)}catch{return null}return null}var scrypt$1={exports:{}};(function(n,t){(function(c){function ie(ze){const He=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]);let Ge=1779033703,Ze=3144134277,Ye=1013904242,Ft=2773480762,Mt=1359893119,Zt=2600822924,cn=528734635,hn=1541459225;const yn=new Uint32Array(64);function Ht(De){let Fe=0,$e=De.length;for(;$e>=64;){let ce=Ge,Me=Ze,We=Ye,$t=Ft,dn=Mt,gn=Zt,Vt=cn,Cn=hn,un,Pt,mn,Pn,wn;for(Pt=0;Pt<16;Pt++)mn=Fe+Pt*4,yn[Pt]=(De[mn]&255)<<24|(De[mn+1]&255)<<16|(De[mn+2]&255)<<8|De[mn+3]&255;for(Pt=16;Pt<64;Pt++)un=yn[Pt-2],Pn=(un>>>17|un<<15)^(un>>>19|un<<13)^un>>>10,un=yn[Pt-15],wn=(un>>>7|un<<25)^(un>>>18|un<<14)^un>>>3,yn[Pt]=(Pn+yn[Pt-7]|0)+(wn+yn[Pt-16]|0)|0;for(Pt=0;Pt<64;Pt++)Pn=(((dn>>>6|dn<<26)^(dn>>>11|dn<<21)^(dn>>>25|dn<<7))+(dn&gn^~dn&Vt)|0)+(Cn+(He[Pt]+yn[Pt]|0)|0)|0,wn=((ce>>>2|ce<<30)^(ce>>>13|ce<<19)^(ce>>>22|ce<<10))+(ce&Me^ce&We^Me&We)|0,Cn=Vt,Vt=gn,gn=dn,dn=$t+Pn|0,$t=We,We=Me,Me=ce,ce=Pn+wn|0;Ge=Ge+ce|0,Ze=Ze+Me|0,Ye=Ye+We|0,Ft=Ft+$t|0,Mt=Mt+dn|0,Zt=Zt+gn|0,cn=cn+Vt|0,hn=hn+Cn|0,Fe+=64,$e-=64}}Ht(ze);let Sn,le=ze.length%64,pe=ze.length/536870912|0,be=ze.length<<3,xe=le<56?56:120,_e=ze.slice(ze.length-le,ze.length);for(_e.push(128),Sn=le+1;Sn<xe;Sn++)_e.push(0);return _e.push(pe>>>24&255),_e.push(pe>>>16&255),_e.push(pe>>>8&255),_e.push(pe>>>0&255),_e.push(be>>>24&255),_e.push(be>>>16&255),_e.push(be>>>8&255),_e.push(be>>>0&255),Ht(_e),[Ge>>>24&255,Ge>>>16&255,Ge>>>8&255,Ge>>>0&255,Ze>>>24&255,Ze>>>16&255,Ze>>>8&255,Ze>>>0&255,Ye>>>24&255,Ye>>>16&255,Ye>>>8&255,Ye>>>0&255,Ft>>>24&255,Ft>>>16&255,Ft>>>8&255,Ft>>>0&255,Mt>>>24&255,Mt>>>16&255,Mt>>>8&255,Mt>>>0&255,Zt>>>24&255,Zt>>>16&255,Zt>>>8&255,Zt>>>0&255,cn>>>24&255,cn>>>16&255,cn>>>8&255,cn>>>0&255,hn>>>24&255,hn>>>16&255,hn>>>8&255,hn>>>0&255]}function se(ze,He,Ge){ze=ze.length<=64?ze:ie(ze);const Ze=64+He.length+4,Ye=new Array(Ze),Ft=new Array(64);let Mt,Zt=[];for(Mt=0;Mt<64;Mt++)Ye[Mt]=54;for(Mt=0;Mt<ze.length;Mt++)Ye[Mt]^=ze[Mt];for(Mt=0;Mt<He.length;Mt++)Ye[64+Mt]=He[Mt];for(Mt=Ze-4;Mt<Ze;Mt++)Ye[Mt]=0;for(Mt=0;Mt<64;Mt++)Ft[Mt]=92;for(Mt=0;Mt<ze.length;Mt++)Ft[Mt]^=ze[Mt];function cn(){for(let hn=Ze-1;hn>=Ze-4;hn--){if(Ye[hn]++,Ye[hn]<=255)return;Ye[hn]=0}}for(;Ge>=32;)cn(),Zt=Zt.concat(ie(Ft.concat(ie(Ye)))),Ge-=32;return Ge>0&&(cn(),Zt=Zt.concat(ie(Ft.concat(ie(Ye))).slice(0,Ge))),Zt}function ae(ze,He,Ge,Ze,Ye){let Ft;for(ge(ze,(2*Ge-1)*16,Ye,0,16),Ft=0;Ft<2*Ge;Ft++)ve(ze,Ft*16,Ye,16),de(Ye,Ze),ge(Ye,0,ze,He+Ft*16,16);for(Ft=0;Ft<Ge;Ft++)ge(ze,He+Ft*2*16,ze,Ft*16,16);for(Ft=0;Ft<Ge;Ft++)ge(ze,He+(Ft*2+1)*16,ze,(Ft+Ge)*16,16)}function ue(ze,He){return ze<<He|ze>>>32-He}function de(ze,He){ge(ze,0,He,0,16);for(let Ge=8;Ge>0;Ge-=2)He[4]^=ue(He[0]+He[12],7),He[8]^=ue(He[4]+He[0],9),He[12]^=ue(He[8]+He[4],13),He[0]^=ue(He[12]+He[8],18),He[9]^=ue(He[5]+He[1],7),He[13]^=ue(He[9]+He[5],9),He[1]^=ue(He[13]+He[9],13),He[5]^=ue(He[1]+He[13],18),He[14]^=ue(He[10]+He[6],7),He[2]^=ue(He[14]+He[10],9),He[6]^=ue(He[2]+He[14],13),He[10]^=ue(He[6]+He[2],18),He[3]^=ue(He[15]+He[11],7),He[7]^=ue(He[3]+He[15],9),He[11]^=ue(He[7]+He[3],13),He[15]^=ue(He[11]+He[7],18),He[1]^=ue(He[0]+He[3],7),He[2]^=ue(He[1]+He[0],9),He[3]^=ue(He[2]+He[1],13),He[0]^=ue(He[3]+He[2],18),He[6]^=ue(He[5]+He[4],7),He[7]^=ue(He[6]+He[5],9),He[4]^=ue(He[7]+He[6],13),He[5]^=ue(He[4]+He[7],18),He[11]^=ue(He[10]+He[9],7),He[8]^=ue(He[11]+He[10],9),He[9]^=ue(He[8]+He[11],13),He[10]^=ue(He[9]+He[8],18),He[12]^=ue(He[15]+He[14],7),He[13]^=ue(He[12]+He[15],9),He[14]^=ue(He[13]+He[12],13),He[15]^=ue(He[14]+He[13],18);for(let Ge=0;Ge<16;++Ge)ze[Ge]+=He[Ge]}function ve(ze,He,Ge,Ze){for(let Ye=0;Ye<Ze;Ye++)Ge[Ye]^=ze[He+Ye]}function ge(ze,He,Ge,Ze,Ye){for(;Ye--;)Ge[Ze++]=ze[He++]}function we(ze){if(!ze||typeof ze.length!="number")return!1;for(let He=0;He<ze.length;He++){const Ge=ze[He];if(typeof Ge!="number"||Ge%1||Ge<0||Ge>=256)return!1}return!0}function Te(ze,He){if(typeof ze!="number"||ze%1)throw new Error("invalid "+He);return ze}function Ne(ze,He,Ge,Ze,Ye,Ft,Mt){if(Ge=Te(Ge,"N"),Ze=Te(Ze,"r"),Ye=Te(Ye,"p"),Ft=Te(Ft,"dkLen"),Ge===0||Ge&Ge-1)throw new Error("N must be power of 2");if(Ge>2147483647/128/Ze)throw new Error("N too large");if(Ze>2147483647/128/Ye)throw new Error("r too large");if(!we(ze))throw new Error("password must be an array or buffer");if(ze=Array.prototype.slice.call(ze),!we(He))throw new Error("salt must be an array or buffer");He=Array.prototype.slice.call(He);let Zt=se(ze,He,Ye*128*Ze);const cn=new Uint32Array(Ye*32*Ze);for(let dn=0;dn<cn.length;dn++){const gn=dn*4;cn[dn]=(Zt[gn+3]&255)<<24|(Zt[gn+2]&255)<<16|(Zt[gn+1]&255)<<8|(Zt[gn+0]&255)<<0}const hn=new Uint32Array(64*Ze),yn=new Uint32Array(32*Ze*Ge),Ht=32*Ze,Sn=new Uint32Array(16),le=new Uint32Array(16),pe=Ye*Ge*2;let be=0,xe=null,_e=!1,De=0,Fe=0,$e,ce;const Me=Mt?parseInt(1e3/Ze):4294967295,We=typeof setImmediate<"u"?setImmediate:setTimeout,$t=function(){if(_e)return Mt(new Error("cancelled"),be/pe);let dn;switch(De){case 0:ce=Fe*32*Ze,ge(cn,ce,hn,0,Ht),De=1,$e=0;case 1:dn=Ge-$e,dn>Me&&(dn=Me);for(let Vt=0;Vt<dn;Vt++)ge(hn,0,yn,($e+Vt)*Ht,Ht),ae(hn,Ht,Ze,Sn,le);if($e+=dn,be+=dn,Mt){const Vt=parseInt(1e3*be/pe);if(Vt!==xe){if(_e=Mt(null,be/pe),_e)break;xe=Vt}}if($e<Ge)break;$e=0,De=2;case 2:dn=Ge-$e,dn>Me&&(dn=Me);for(let Vt=0;Vt<dn;Vt++){const Cn=(2*Ze-1)*16,un=hn[Cn]&Ge-1;ve(yn,un*Ht,hn,Ht),ae(hn,Ht,Ze,Sn,le)}if($e+=dn,be+=dn,Mt){const Vt=parseInt(1e3*be/pe);if(Vt!==xe){if(_e=Mt(null,be/pe),_e)break;xe=Vt}}if($e<Ge)break;if(ge(hn,0,cn,ce,Ht),Fe++,Fe<Ye){De=0;break}Zt=[];for(let Vt=0;Vt<cn.length;Vt++)Zt.push(cn[Vt]>>0&255),Zt.push(cn[Vt]>>8&255),Zt.push(cn[Vt]>>16&255),Zt.push(cn[Vt]>>24&255);const gn=se(ze,Zt,Ft);return Mt&&Mt(null,1,gn),gn}Mt&&We($t)};if(!Mt)for(;;){const dn=$t();if(dn!=null)return dn}$t()}const qe={scrypt:function(ze,He,Ge,Ze,Ye,Ft,Mt){return new Promise(function(Zt,cn){let hn=0;Mt&&Mt(0),Ne(ze,He,Ge,Ze,Ye,Ft,function(yn,Ht,Sn){if(yn)cn(yn);else if(Sn)Mt&&hn!==1&&Mt(1),Zt(new Uint8Array(Sn));else if(Mt&&Ht!==hn)return hn=Ht,Mt(Ht)})})},syncScrypt:function(ze,He,Ge,Ze,Ye,Ft){return new Uint8Array(Ne(ze,He,Ge,Ze,Ye,Ft))}};n.exports=qe})()})(scrypt$1);var scryptExports=scrypt$1.exports;const scrypt=getDefaultExportFromCjs$2(scryptExports);var __awaiter$g=function(n,t,c,ie){function se(ae){return ae instanceof c?ae:new c(function(ue){ue(ae)})}return new(c||(c=Promise))(function(ae,ue){function de(we){try{ge(ie.next(we))}catch(Te){ue(Te)}}function ve(we){try{ge(ie.throw(we))}catch(Te){ue(Te)}}function ge(we){we.done?ae(we.value):se(we.value).then(de,ve)}ge((ie=ie.apply(n,[])).next())})};const logger$9=new Logger(version$c);function hasMnemonic$1(n){return n!=null&&n.mnemonic&&n.mnemonic.phrase}class KeystoreAccount extends Description{isKeystoreAccount(t){return!!(t&&t._isKeystoreAccount)}}function _decrypt(n,t,c){if(searchPath(n,"crypto/cipher")==="aes-128-ctr"){const ie=looseArrayify(searchPath(n,"crypto/cipherparams/iv")),se=new aes$1.Counter(ie),ae=new aes$1.ModeOfOperation.ctr(t,se);return arrayify(ae.decrypt(c))}return null}function _getAccount(n,t){const c=looseArrayify(searchPath(n,"crypto/ciphertext"));if(hexlify(keccak256$1(concat$1([t.slice(16,32),c]))).substring(2)!==searchPath(n,"crypto/mac").toLowerCase())throw new Error("invalid password");const ie=_decrypt(n,t.slice(0,16),c);ie||logger$9.throwError("unsupported cipher",Logger.errors.UNSUPPORTED_OPERATION,{operation:"decrypt"});const se=t.slice(32,64),ae=computeAddress(ie);if(n.address){let de=n.address.toLowerCase();if(de.substring(0,2)!=="0x"&&(de="0x"+de),getAddress$1(de)!==ae)throw new Error("address mismatch")}const ue={_isKeystoreAccount:!0,address:ae,privateKey:hexlify(ie)};if(searchPath(n,"x-ethers/version")==="0.1"){const de=looseArrayify(searchPath(n,"x-ethers/mnemonicCiphertext")),ve=looseArrayify(searchPath(n,"x-ethers/mnemonicCounter")),ge=new aes$1.Counter(ve),we=new aes$1.ModeOfOperation.ctr(se,ge),Te=searchPath(n,"x-ethers/path")||defaultPath,Ne=searchPath(n,"x-ethers/locale")||"en",qe=arrayify(we.decrypt(de));try{const ze=entropyToMnemonic(qe,Ne),He=HDNode.fromMnemonic(ze,null,Ne).derivePath(Te);if(He.privateKey!=ue.privateKey)throw new Error("mnemonic mismatch");ue.mnemonic=He.mnemonic}catch(ze){if(ze.code!==Logger.errors.INVALID_ARGUMENT||ze.argument!=="wordlist")throw ze}}return new KeystoreAccount(ue)}function pbkdf2Sync(n,t,c,ie,se){return arrayify(pbkdf2$1(n,t,c,ie,se))}function pbkdf2(n,t,c,ie,se){return Promise.resolve(pbkdf2Sync(n,t,c,ie,se))}function _computeKdfKey(n,t,c,ie,se){const ae=getPassword(t),ue=searchPath(n,"crypto/kdf");if(ue&&typeof ue=="string"){const de=function(ve,ge){return logger$9.throwArgumentError("invalid key-derivation function parameters",ve,ge)};if(ue.toLowerCase()==="scrypt"){const ve=looseArrayify(searchPath(n,"crypto/kdfparams/salt")),ge=parseInt(searchPath(n,"crypto/kdfparams/n")),we=parseInt(searchPath(n,"crypto/kdfparams/r")),Te=parseInt(searchPath(n,"crypto/kdfparams/p"));(!ge||!we||!Te)&&de("kdf",ue),ge&ge-1&&de("N",ge);const Ne=parseInt(searchPath(n,"crypto/kdfparams/dklen"));return Ne!==32&&de("dklen",Ne),ie(ae,ve,ge,we,Te,64,se)}else if(ue.toLowerCase()==="pbkdf2"){const ve=looseArrayify(searchPath(n,"crypto/kdfparams/salt"));let ge=null;const we=searchPath(n,"crypto/kdfparams/prf");we==="hmac-sha256"?ge="sha256":we==="hmac-sha512"?ge="sha512":de("prf",we);const Te=parseInt(searchPath(n,"crypto/kdfparams/c")),Ne=parseInt(searchPath(n,"crypto/kdfparams/dklen"));return Ne!==32&&de("dklen",Ne),c(ae,ve,Te,Ne,ge)}}return logger$9.throwArgumentError("unsupported key-derivation function","kdf",ue)}function decryptSync(n,t){const c=JSON.parse(n),ie=_computeKdfKey(c,t,pbkdf2Sync,scrypt.syncScrypt);return _getAccount(c,ie)}function decrypt(n,t,c){return __awaiter$g(this,void 0,void 0,function*(){const ie=JSON.parse(n),se=yield _computeKdfKey(ie,t,pbkdf2,scrypt.scrypt,c);return _getAccount(ie,se)})}function encrypt(n,t,c,ie){try{if(getAddress$1(n.address)!==computeAddress(n.privateKey))throw new Error("address/privateKey mismatch");if(hasMnemonic$1(n)){const Ge=n.mnemonic;if(HDNode.fromMnemonic(Ge.phrase,null,Ge.locale).derivePath(Ge.path||defaultPath).privateKey!=n.privateKey)throw new Error("mnemonic mismatch")}}catch(Ge){return Promise.reject(Ge)}typeof c=="function"&&!ie&&(ie=c,c={}),c||(c={});const se=arrayify(n.privateKey),ae=getPassword(t);let ue=null,de=null,ve=null;if(hasMnemonic$1(n)){const Ge=n.mnemonic;ue=arrayify(mnemonicToEntropy(Ge.phrase,Ge.locale||"en")),de=Ge.path||defaultPath,ve=Ge.locale||"en"}let ge=c.client;ge||(ge="ethers.js");let we=null;c.salt?we=arrayify(c.salt):we=randomBytes$1(32);let Te=null;if(c.iv){if(Te=arrayify(c.iv),Te.length!==16)throw new Error("invalid iv")}else Te=randomBytes$1(16);let Ne=null;if(c.uuid){if(Ne=arrayify(c.uuid),Ne.length!==16)throw new Error("invalid uuid")}else Ne=randomBytes$1(16);let qe=1<<17,ze=8,He=1;return c.scrypt&&(c.scrypt.N&&(qe=c.scrypt.N),c.scrypt.r&&(ze=c.scrypt.r),c.scrypt.p&&(He=c.scrypt.p)),scrypt.scrypt(ae,we,qe,ze,He,64,ie).then(Ge=>{Ge=arrayify(Ge);const Ze=Ge.slice(0,16),Ye=Ge.slice(16,32),Ft=Ge.slice(32,64),Mt=new aes$1.Counter(Te),Zt=new aes$1.ModeOfOperation.ctr(Ze,Mt),cn=arrayify(Zt.encrypt(se)),hn=keccak256$1(concat$1([Ye,cn])),yn={address:n.address.substring(2).toLowerCase(),id:uuidV4(Ne),version:3,crypto:{cipher:"aes-128-ctr",cipherparams:{iv:hexlify(Te).substring(2)},ciphertext:hexlify(cn).substring(2),kdf:"scrypt",kdfparams:{salt:hexlify(we).substring(2),n:qe,dklen:32,p:He,r:ze},mac:hn.substring(2)}};if(ue){const Ht=randomBytes$1(16),Sn=new aes$1.Counter(Ht),le=new aes$1.ModeOfOperation.ctr(Ft,Sn),pe=arrayify(le.encrypt(ue)),be=new Date,xe=be.getUTCFullYear()+"-"+zpad(be.getUTCMonth()+1,2)+"-"+zpad(be.getUTCDate(),2)+"T"+zpad(be.getUTCHours(),2)+"-"+zpad(be.getUTCMinutes(),2)+"-"+zpad(be.getUTCSeconds(),2)+".0Z";yn["x-ethers"]={client:ge,gethFilename:"UTC--"+xe+"--"+yn.address,mnemonicCounter:hexlify(Ht).substring(2),mnemonicCiphertext:hexlify(pe).substring(2),path:de,locale:ve,version:"0.1"}}return JSON.stringify(yn)})}function decryptJsonWallet(n,t,c){if(isCrowdsaleWallet(n)){c&&c(0);const ie=decrypt$1(n,t);return c&&c(1),Promise.resolve(ie)}return isKeystoreWallet(n)?decrypt(n,t,c):Promise.reject(new Error("invalid JSON wallet"))}function decryptJsonWalletSync(n,t){if(isCrowdsaleWallet(n))return decrypt$1(n,t);if(isKeystoreWallet(n))return decryptSync(n,t);throw new Error("invalid JSON wallet")}const lib_esm$4=Object.freeze(Object.defineProperty({__proto__:null,decryptCrowdsale:decrypt$1,decryptJsonWallet,decryptJsonWalletSync,decryptKeystore:decrypt,decryptKeystoreSync:decryptSync,encryptKeystore:encrypt,getJsonWalletAddress,isCrowdsaleWallet,isKeystoreWallet},Symbol.toStringTag,{value:"Module"})),version$b="wallet/5.8.0";var __awaiter$f=function(n,t,c,ie){function se(ae){return ae instanceof c?ae:new c(function(ue){ue(ae)})}return new(c||(c=Promise))(function(ae,ue){function de(we){try{ge(ie.next(we))}catch(Te){ue(Te)}}function ve(we){try{ge(ie.throw(we))}catch(Te){ue(Te)}}function ge(we){we.done?ae(we.value):se(we.value).then(de,ve)}ge((ie=ie.apply(n,[])).next())})};const logger$8=new Logger(version$b);function isAccount(n){return n!=null&&isHexString(n.privateKey,32)&&n.address!=null}function hasMnemonic(n){const t=n.mnemonic;return t&&t.phrase}class Wallet extends Signer{constructor(t,c){if(super(),isAccount(t)){const ie=new SigningKey(t.privateKey);if(defineReadOnly(this,"_signingKey",()=>ie),defineReadOnly(this,"address",computeAddress(this.publicKey)),this.address!==getAddress$1(t.address)&&logger$8.throwArgumentError("privateKey/address mismatch","privateKey","[REDACTED]"),hasMnemonic(t)){const se=t.mnemonic;defineReadOnly(this,"_mnemonic",()=>({phrase:se.phrase,path:se.path||defaultPath,locale:se.locale||"en"}));const ae=this.mnemonic,ue=HDNode.fromMnemonic(ae.phrase,null,ae.locale).derivePath(ae.path);computeAddress(ue.privateKey)!==this.address&&logger$8.throwArgumentError("mnemonic/address mismatch","privateKey","[REDACTED]")}else defineReadOnly(this,"_mnemonic",()=>null)}else{if(SigningKey.isSigningKey(t))t.curve!=="secp256k1"&&logger$8.throwArgumentError("unsupported curve; must be secp256k1","privateKey","[REDACTED]"),defineReadOnly(this,"_signingKey",()=>t);else{typeof t=="string"&&t.match(/^[0-9a-f]*$/i)&&t.length===64&&(t="0x"+t);const ie=new SigningKey(t);defineReadOnly(this,"_signingKey",()=>ie)}defineReadOnly(this,"_mnemonic",()=>null),defineReadOnly(this,"address",computeAddress(this.publicKey))}c&&!Provider.isProvider(c)&&logger$8.throwArgumentError("invalid provider","provider",c),defineReadOnly(this,"provider",c||null)}get mnemonic(){return this._mnemonic()}get privateKey(){return this._signingKey().privateKey}get publicKey(){return this._signingKey().publicKey}getAddress(){return Promise.resolve(this.address)}connect(t){return new Wallet(this,t)}signTransaction(t){return resolveProperties(t).then(c=>{c.from!=null&&(getAddress$1(c.from)!==this.address&&logger$8.throwArgumentError("transaction from address mismatch","transaction.from",t.from),delete c.from);const ie=this._signingKey().signDigest(keccak256$1(serialize$1$1(c)));return serialize$1$1(c,ie)})}signMessage(t){return __awaiter$f(this,void 0,void 0,function*(){return joinSignature(this._signingKey().signDigest(hashMessage(t)))})}_signTypedData(t,c,ie){return __awaiter$f(this,void 0,void 0,function*(){const se=yield TypedDataEncoder.resolveNames(t,c,ie,ae=>(this.provider==null&&logger$8.throwError("cannot resolve ENS names without a provider",Logger.errors.UNSUPPORTED_OPERATION,{operation:"resolveName",value:ae}),this.provider.resolveName(ae)));return joinSignature(this._signingKey().signDigest(TypedDataEncoder.hash(se.domain,c,se.value)))})}encrypt(t,c,ie){if(typeof c=="function"&&!ie&&(ie=c,c={}),ie&&typeof ie!="function")throw new Error("invalid callback");return c||(c={}),encrypt(this,t,c,ie)}static createRandom(t){let c=randomBytes$1(16);t||(t={}),t.extraEntropy&&(c=arrayify(hexDataSlice(keccak256$1(concat$1([c,t.extraEntropy])),0,16)));const ie=entropyToMnemonic(c,t.locale);return Wallet.fromMnemonic(ie,t.path,t.locale)}static fromEncryptedJson(t,c,ie){return decryptJsonWallet(t,c,ie).then(se=>new Wallet(se))}static fromEncryptedJsonSync(t,c){return new Wallet(decryptJsonWalletSync(t,c))}static fromMnemonic(t,c,ie){return c||(c=defaultPath),new Wallet(HDNode.fromMnemonic(t,null,ie).derivePath(c))}}function verifyMessage(n,t){return recoverAddress(hashMessage(n),t)}function verifyTypedData(n,t,c,ie){return recoverAddress(TypedDataEncoder.hash(n,t,c),ie)}const lib_esm$3=Object.freeze(Object.defineProperty({__proto__:null,Wallet,verifyMessage,verifyTypedData},Symbol.toStringTag,{value:"Module"})),version$a="networks/5.8.0",logger$7=new Logger(version$a);function isRenetworkable(n){return n&&typeof n.renetwork=="function"}function ethDefaultProvider(n){const t=function(c,ie){ie==null&&(ie={});const se=[];if(c.InfuraProvider&&ie.infura!=="-")try{se.push(new c.InfuraProvider(n,ie.infura))}catch{}if(c.EtherscanProvider&&ie.etherscan!=="-")try{se.push(new c.EtherscanProvider(n,ie.etherscan))}catch{}if(c.AlchemyProvider&&ie.alchemy!=="-")try{se.push(new c.AlchemyProvider(n,ie.alchemy))}catch{}if(c.PocketProvider&&ie.pocket!=="-"){const ae=["goerli","ropsten","rinkeby","sepolia"];try{const ue=new c.PocketProvider(n,ie.pocket);ue.network&&ae.indexOf(ue.network.name)===-1&&se.push(ue)}catch{}}if(c.CloudflareProvider&&ie.cloudflare!=="-")try{se.push(new c.CloudflareProvider(n))}catch{}if(c.AnkrProvider&&ie.ankr!=="-")try{const ae=["ropsten"],ue=new c.AnkrProvider(n,ie.ankr);ue.network&&ae.indexOf(ue.network.name)===-1&&se.push(ue)}catch{}if(c.QuickNodeProvider&&ie.quicknode!=="-")try{se.push(new c.QuickNodeProvider(n,ie.quicknode))}catch{}if(se.length===0)return null;if(c.FallbackProvider){let ae=1;return ie.quorum!=null?ae=ie.quorum:n==="homestead"&&(ae=2),new c.FallbackProvider(se,ae)}return se[0]};return t.renetwork=function(c){return ethDefaultProvider(c)},t}function etcDefaultProvider(n,t){const c=function(ie,se){return ie.JsonRpcProvider?new ie.JsonRpcProvider(n,t):null};return c.renetwork=function(ie){return etcDefaultProvider(n,ie)},c}const homestead={chainId:1,ensAddress:"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e",name:"homestead",_defaultProvider:ethDefaultProvider("homestead")},ropsten={chainId:3,ensAddress:"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e",name:"ropsten",_defaultProvider:ethDefaultProvider("ropsten")},classicMordor={chainId:63,name:"classicMordor",_defaultProvider:etcDefaultProvider("https://www.ethercluster.com/mordor","classicMordor")},networks$2={unspecified:{chainId:0,name:"unspecified"},homestead,mainnet:homestead,morden:{chainId:2,name:"morden"},ropsten,testnet:ropsten,rinkeby:{chainId:4,ensAddress:"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e",name:"rinkeby",_defaultProvider:ethDefaultProvider("rinkeby")},kovan:{chainId:42,name:"kovan",_defaultProvider:ethDefaultProvider("kovan")},goerli:{chainId:5,ensAddress:"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e",name:"goerli",_defaultProvider:ethDefaultProvider("goerli")},kintsugi:{chainId:1337702,name:"kintsugi"},sepolia:{chainId:11155111,ensAddress:"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e",name:"sepolia",_defaultProvider:ethDefaultProvider("sepolia")},holesky:{chainId:17e3,name:"holesky",_defaultProvider:ethDefaultProvider("holesky")},classic:{chainId:61,name:"classic",_defaultProvider:etcDefaultProvider("https://www.ethercluster.com/etc","classic")},classicMorden:{chainId:62,name:"classicMorden"},classicMordor,classicTestnet:classicMordor,classicKotti:{chainId:6,name:"classicKotti",_defaultProvider:etcDefaultProvider("https://www.ethercluster.com/kotti","classicKotti")},xdai:{chainId:100,name:"xdai"},matic:{chainId:137,name:"matic",_defaultProvider:ethDefaultProvider("matic")},maticmum:{chainId:80001,name:"maticmum",_defaultProvider:ethDefaultProvider("maticmum")},optimism:{chainId:10,name:"optimism",_defaultProvider:ethDefaultProvider("optimism")},"optimism-kovan":{chainId:69,name:"optimism-kovan"},"optimism-goerli":{chainId:420,name:"optimism-goerli"},"optimism-sepolia":{chainId:11155420,name:"optimism-sepolia"},arbitrum:{chainId:42161,name:"arbitrum"},"arbitrum-rinkeby":{chainId:421611,name:"arbitrum-rinkeby"},"arbitrum-goerli":{chainId:421613,name:"arbitrum-goerli"},"arbitrum-sepolia":{chainId:421614,name:"arbitrum-sepolia"},bnb:{chainId:56,name:"bnb"},bnbt:{chainId:97,name:"bnbt"}};function getNetwork(n){if(n==null)return null;if(typeof n=="number"){for(const ie in networks$2){const se=networks$2[ie];if(se.chainId===n)return{name:se.name,chainId:se.chainId,ensAddress:se.ensAddress||null,_defaultProvider:se._defaultProvider||null}}return{chainId:n,name:"unknown"}}if(typeof n=="string"){const ie=networks$2[n];return ie==null?null:{name:ie.name,chainId:ie.chainId,ensAddress:ie.ensAddress,_defaultProvider:ie._defaultProvider||null}}const t=networks$2[n.name];if(!t)return typeof n.chainId!="number"&&logger$7.throwArgumentError("invalid network chainId","network",n),n;n.chainId!==0&&n.chainId!==t.chainId&&logger$7.throwArgumentError("network chainId mismatch","network",n);let c=n._defaultProvider||null;return c==null&&t._defaultProvider&&(isRenetworkable(t._defaultProvider)?c=t._defaultProvider.renetwork(n):c=t._defaultProvider),{name:n.name,chainId:t.chainId,ensAddress:n.ensAddress||t.ensAddress||null,_defaultProvider:c}}const version$9="web/5.8.0";var __awaiter$e=function(n,t,c,ie){function se(ae){return ae instanceof c?ae:new c(function(ue){ue(ae)})}return new(c||(c=Promise))(function(ae,ue){function de(we){try{ge(ie.next(we))}catch(Te){ue(Te)}}function ve(we){try{ge(ie.throw(we))}catch(Te){ue(Te)}}function ge(we){we.done?ae(we.value):se(we.value).then(de,ve)}ge((ie=ie.apply(n,[])).next())})};function getUrl(n,t){return __awaiter$e(this,void 0,void 0,function*(){t==null&&(t={});const c={method:t.method||"GET",headers:t.headers||{},body:t.body||void 0};if(t.skipFetchSetup!==!0&&(c.mode="cors",c.cache="no-cache",c.credentials="same-origin",c.redirect="follow",c.referrer="client"),t.fetchOptions!=null){const ue=t.fetchOptions;ue.mode&&(c.mode=ue.mode),ue.cache&&(c.cache=ue.cache),ue.credentials&&(c.credentials=ue.credentials),ue.redirect&&(c.redirect=ue.redirect),ue.referrer&&(c.referrer=ue.referrer)}const ie=yield fetch(n,c),se=yield ie.arrayBuffer(),ae={};return ie.headers.forEach?ie.headers.forEach((ue,de)=>{ae[de.toLowerCase()]=ue}):ie.headers.keys().forEach(ue=>{ae[ue.toLowerCase()]=ie.headers.get(ue)}),{headers:ae,statusCode:ie.status,statusMessage:ie.statusText,body:arrayify(new Uint8Array(se))}})}var __awaiter$d=function(n,t,c,ie){function se(ae){return ae instanceof c?ae:new c(function(ue){ue(ae)})}return new(c||(c=Promise))(function(ae,ue){function de(we){try{ge(ie.next(we))}catch(Te){ue(Te)}}function ve(we){try{ge(ie.throw(we))}catch(Te){ue(Te)}}function ge(we){we.done?ae(we.value):se(we.value).then(de,ve)}ge((ie=ie.apply(n,[])).next())})};const logger$6=new Logger(version$9);function staller(n){return new Promise(t=>{setTimeout(t,n)})}function bodyify(n,t){if(n==null)return null;if(typeof n=="string")return n;if(isBytesLike(n)){if(t&&(t.split("/")[0]==="text"||t.split(";")[0].trim()==="application/json"))try{return toUtf8String(n)}catch{}return hexlify(n)}return n}function unpercent(n){return toUtf8Bytes(n.replace(/%([0-9a-f][0-9a-f])/gi,(t,c)=>String.fromCharCode(parseInt(c,16))))}function _fetchData(n,t,c){const ie=typeof n=="object"&&n.throttleLimit!=null?n.throttleLimit:12;logger$6.assertArgument(ie>0&&ie%1===0,"invalid connection throttle limit","connection.throttleLimit",ie);const se=typeof n=="object"?n.throttleCallback:null,ae=typeof n=="object"&&typeof n.throttleSlotInterval=="number"?n.throttleSlotInterval:100;logger$6.assertArgument(ae>0&&ae%1===0,"invalid connection throttle slot interval","connection.throttleSlotInterval",ae);const ue=typeof n=="object"?!!n.errorPassThrough:!1,de={};let ve=null;const ge={method:"GET"};let we=!1,Te=120*1e3;if(typeof n=="string")ve=n;else if(typeof n=="object"){if((n==null||n.url==null)&&logger$6.throwArgumentError("missing URL","connection.url",n),ve=n.url,typeof n.timeout=="number"&&n.timeout>0&&(Te=n.timeout),n.headers)for(const Ze in n.headers)de[Ze.toLowerCase()]={key:Ze,value:String(n.headers[Ze])},["if-none-match","if-modified-since"].indexOf(Ze.toLowerCase())>=0&&(we=!0);if(ge.allowGzip=!!n.allowGzip,n.user!=null&&n.password!=null){ve.substring(0,6)!=="https:"&&n.allowInsecureAuthentication!==!0&&logger$6.throwError("basic authentication requires a secure https url",Logger.errors.INVALID_ARGUMENT,{argument:"url",url:ve,user:n.user,password:"[REDACTED]"});const Ze=n.user+":"+n.password;de.authorization={key:"Authorization",value:"Basic "+encode$5(toUtf8Bytes(Ze))}}n.skipFetchSetup!=null&&(ge.skipFetchSetup=!!n.skipFetchSetup),n.fetchOptions!=null&&(ge.fetchOptions=shallowCopy(n.fetchOptions))}const Ne=new RegExp("^data:([^;:]*)?(;base64)?,(.*)$","i"),qe=ve?ve.match(Ne):null;if(qe)try{const Ze={statusCode:200,statusMessage:"OK",headers:{"content-type":qe[1]||"text/plain"},body:qe[2]?decode$6(qe[3]):unpercent(qe[3])};let Ye=Ze.body;return c&&(Ye=c(Ze.body,Ze)),Promise.resolve(Ye)}catch(Ze){logger$6.throwError("processing response error",Logger.errors.SERVER_ERROR,{body:bodyify(qe[1],qe[2]),error:Ze,requestBody:null,requestMethod:"GET",url:ve})}t&&(ge.method="POST",ge.body=t,de["content-type"]==null&&(de["content-type"]={key:"Content-Type",value:"application/octet-stream"}),de["content-length"]==null&&(de["content-length"]={key:"Content-Length",value:String(t.length)}));const ze={};Object.keys(de).forEach(Ze=>{const Ye=de[Ze];ze[Ye.key]=Ye.value}),ge.headers=ze;const He=(function(){let Ze=null;return{promise:new Promise(function(Ye,Ft){Te&&(Ze=setTimeout(()=>{Ze!=null&&(Ze=null,Ft(logger$6.makeError("timeout",Logger.errors.TIMEOUT,{requestBody:bodyify(ge.body,ze["content-type"]),requestMethod:ge.method,timeout:Te,url:ve})))},Te))}),cancel:function(){Ze!=null&&(clearTimeout(Ze),Ze=null)}}})(),Ge=(function(){return __awaiter$d(this,void 0,void 0,function*(){for(let Ze=0;Ze<ie;Ze++){let Ye=null;try{if(Ye=yield getUrl(ve,ge),Ze<ie){if(Ye.statusCode===301||Ye.statusCode===302){const Mt=Ye.headers.location||"";if(ge.method==="GET"&&Mt.match(/^https:/)){ve=Ye.headers.location;continue}}else if(Ye.statusCode===429){let Mt=!0;if(se&&(Mt=yield se(Ze,ve)),Mt){let Zt=0;const cn=Ye.headers["retry-after"];typeof cn=="string"&&cn.match(/^[1-9][0-9]*$/)?Zt=parseInt(cn)*1e3:Zt=ae*parseInt(String(Math.random()*Math.pow(2,Ze))),yield staller(Zt);continue}}}}catch(Mt){Ye=Mt.response,Ye==null&&(He.cancel(),logger$6.throwError("missing response",Logger.errors.SERVER_ERROR,{requestBody:bodyify(ge.body,ze["content-type"]),requestMethod:ge.method,serverError:Mt,url:ve}))}let Ft=Ye.body;if(we&&Ye.statusCode===304?Ft=null:!ue&&(Ye.statusCode<200||Ye.statusCode>=300)&&(He.cancel(),logger$6.throwError("bad response",Logger.errors.SERVER_ERROR,{status:Ye.statusCode,headers:Ye.headers,body:bodyify(Ft,Ye.headers?Ye.headers["content-type"]:null),requestBody:bodyify(ge.body,ze["content-type"]),requestMethod:ge.method,url:ve})),c)try{const Mt=yield c(Ft,Ye);return He.cancel(),Mt}catch(Mt){if(Mt.throttleRetry&&Ze<ie){let Zt=!0;if(se&&(Zt=yield se(Ze,ve)),Zt){const cn=ae*parseInt(String(Math.random()*Math.pow(2,Ze)));yield staller(cn);continue}}He.cancel(),logger$6.throwError("processing response error",Logger.errors.SERVER_ERROR,{body:bodyify(Ft,Ye.headers?Ye.headers["content-type"]:null),error:Mt,requestBody:bodyify(ge.body,ze["content-type"]),requestMethod:ge.method,url:ve})}return He.cancel(),Ft}return logger$6.throwError("failed response",Logger.errors.SERVER_ERROR,{requestBody:bodyify(ge.body,ze["content-type"]),requestMethod:ge.method,url:ve})})})();return Promise.race([He.promise,Ge])}function fetchJson(n,t,c){let ie=(ae,ue)=>{let de=null;if(ae!=null)try{de=JSON.parse(toUtf8String(ae))}catch(ve){logger$6.throwError("invalid JSON",Logger.errors.SERVER_ERROR,{body:ae,error:ve})}return c&&(de=c(de,ue)),de},se=null;if(t!=null){se=toUtf8Bytes(t);const ae=typeof n=="string"?{url:n}:shallowCopy(n);ae.headers?Object.keys(ae.headers).filter(ue=>ue.toLowerCase()==="content-type").length!==0||(ae.headers=shallowCopy(ae.headers),ae.headers["content-type"]="application/json"):ae.headers={"content-type":"application/json"},n=ae}return _fetchData(n,se,ie)}function poll(n,t){return t||(t={}),t=shallowCopy(t),t.floor==null&&(t.floor=0),t.ceiling==null&&(t.ceiling=1e4),t.interval==null&&(t.interval=250),new Promise(function(c,ie){let se=null,ae=!1;const ue=()=>ae?!1:(ae=!0,se&&clearTimeout(se),!0);t.timeout&&(se=setTimeout(()=>{ue()&&ie(new Error("timeout"))},t.timeout));const de=t.retryLimit;let ve=0;function ge(){return n().then(function(we){if(we!==void 0)ue()&&c(we);else if(t.oncePoll)t.oncePoll.once("poll",ge);else if(t.onceBlock)t.onceBlock.once("block",ge);else if(!ae){if(ve++,ve>de){ue()&&ie(new Error("retry limit reached"));return}let Te=t.interval*parseInt(String(Math.random()*Math.pow(2,ve)));Te<t.floor&&(Te=t.floor),Te>t.ceiling&&(Te=t.ceiling),setTimeout(ge,Te)}return null},function(we){ue()&&ie(we)})}ge()})}const lib_esm$2=Object.freeze(Object.defineProperty({__proto__:null,_fetchData,fetchJson,poll},Symbol.toStringTag,{value:"Module"}));var ALPHABET$2="qpzry9x8gf2tvdw0s3jn54khce6mua7l",ALPHABET_MAP$1={};for(var z$3=0;z$3<ALPHABET$2.length;z$3++){var x$2=ALPHABET$2.charAt(z$3);if(ALPHABET_MAP$1[x$2]!==void 0)throw new TypeError(x$2+" is ambiguous");ALPHABET_MAP$1[x$2]=z$3}function polymodStep$1(n){var t=n>>25;return(n&33554431)<<5^-(t>>0&1)&996825010^-(t>>1&1)&642813549^-(t>>2&1)&513874426^-(t>>3&1)&1027748829^-(t>>4&1)&705979059}function prefixChk$1(n){for(var t=1,c=0;c<n.length;++c){var ie=n.charCodeAt(c);if(ie<33||ie>126)return"Invalid prefix ("+n+")";t=polymodStep$1(t)^ie>>5}for(t=polymodStep$1(t),c=0;c<n.length;++c){var se=n.charCodeAt(c);t=polymodStep$1(t)^se&31}return t}function encode$4(n,t,c){if(c=c||90,n.length+7+t.length>c)throw new TypeError("Exceeds length limit");n=n.toLowerCase();var ie=prefixChk$1(n);if(typeof ie=="string")throw new Error(ie);for(var se=n+"1",ae=0;ae<t.length;++ae){var ue=t[ae];if(ue>>5)throw new Error("Non 5-bit word");ie=polymodStep$1(ie)^ue,se+=ALPHABET$2.charAt(ue)}for(ae=0;ae<6;++ae)ie=polymodStep$1(ie);for(ie^=1,ae=0;ae<6;++ae){var de=ie>>(5-ae)*5&31;se+=ALPHABET$2.charAt(de)}return se}function __decode(n,t){if(t=t||90,n.length<8)return n+" too short";if(n.length>t)return"Exceeds length limit";var c=n.toLowerCase(),ie=n.toUpperCase();if(n!==c&&n!==ie)return"Mixed-case string "+n;n=c;var se=n.lastIndexOf("1");if(se===-1)return"No separator character for "+n;if(se===0)return"Missing prefix for "+n;var ae=n.slice(0,se),ue=n.slice(se+1);if(ue.length<6)return"Data too short";var de=prefixChk$1(ae);if(typeof de=="string")return de;for(var ve=[],ge=0;ge<ue.length;++ge){var we=ue.charAt(ge),Te=ALPHABET_MAP$1[we];if(Te===void 0)return"Unknown character "+we;de=polymodStep$1(de)^Te,!(ge+6>=ue.length)&&ve.push(Te)}return de!==1?"Invalid checksum for "+n:{prefix:ae,words:ve}}function decodeUnsafe(){var n=__decode.apply(null,arguments);if(typeof n=="object")return n}function decode$5(n){var t=__decode.apply(null,arguments);if(typeof t=="object")return t;throw new Error(t)}function convert$1(n,t,c,ie){for(var se=0,ae=0,ue=(1<<c)-1,de=[],ve=0;ve<n.length;++ve)for(se=se<<t|n[ve],ae+=t;ae>=c;)ae-=c,de.push(se>>ae&ue);if(ie)ae>0&&de.push(se<<c-ae&ue);else{if(ae>=t)return"Excess padding";if(se<<c-ae&ue)return"Non-zero padding"}return de}function toWordsUnsafe(n){var t=convert$1(n,8,5,!0);if(Array.isArray(t))return t}function toWords$1(n){var t=convert$1(n,8,5,!0);if(Array.isArray(t))return t;throw new Error(t)}function fromWordsUnsafe$1(n){var t=convert$1(n,5,8,!1);if(Array.isArray(t))return t}function fromWords$1(n){var t=convert$1(n,5,8,!1);if(Array.isArray(t))return t;throw new Error(t)}var bech32$1={decodeUnsafe,decode:decode$5,encode:encode$4,toWordsUnsafe,toWords:toWords$1,fromWordsUnsafe:fromWordsUnsafe$1,fromWords:fromWords$1};const bech32$2=getDefaultExportFromCjs$2(bech32$1),version$8="providers/5.8.0",logger$5=new Logger(version$8);class Formatter{constructor(){this.formats=this.getDefaultFormats()}getDefaultFormats(){const t={},c=this.address.bind(this),ie=this.bigNumber.bind(this),se=this.blockTag.bind(this),ae=this.data.bind(this),ue=this.hash.bind(this),de=this.hex.bind(this),ve=this.number.bind(this),ge=this.type.bind(this),we=Te=>this.data(Te,!0);return t.transaction={hash:ue,type:ge,accessList:Formatter.allowNull(this.accessList.bind(this),null),blockHash:Formatter.allowNull(ue,null),blockNumber:Formatter.allowNull(ve,null),transactionIndex:Formatter.allowNull(ve,null),confirmations:Formatter.allowNull(ve,null),from:c,gasPrice:Formatter.allowNull(ie),maxPriorityFeePerGas:Formatter.allowNull(ie),maxFeePerGas:Formatter.allowNull(ie),gasLimit:ie,to:Formatter.allowNull(c,null),value:ie,nonce:ve,data:ae,r:Formatter.allowNull(this.uint256),s:Formatter.allowNull(this.uint256),v:Formatter.allowNull(ve),creates:Formatter.allowNull(c,null),raw:Formatter.allowNull(ae)},t.transactionRequest={from:Formatter.allowNull(c),nonce:Formatter.allowNull(ve),gasLimit:Formatter.allowNull(ie),gasPrice:Formatter.allowNull(ie),maxPriorityFeePerGas:Formatter.allowNull(ie),maxFeePerGas:Formatter.allowNull(ie),to:Formatter.allowNull(c),value:Formatter.allowNull(ie),data:Formatter.allowNull(we),type:Formatter.allowNull(ve),accessList:Formatter.allowNull(this.accessList.bind(this),null)},t.receiptLog={transactionIndex:ve,blockNumber:ve,transactionHash:ue,address:c,topics:Formatter.arrayOf(ue),data:ae,logIndex:ve,blockHash:ue},t.receipt={to:Formatter.allowNull(this.address,null),from:Formatter.allowNull(this.address,null),contractAddress:Formatter.allowNull(c,null),transactionIndex:ve,root:Formatter.allowNull(de),gasUsed:ie,logsBloom:Formatter.allowNull(ae),blockHash:ue,transactionHash:ue,logs:Formatter.arrayOf(this.receiptLog.bind(this)),blockNumber:ve,confirmations:Formatter.allowNull(ve,null),cumulativeGasUsed:ie,effectiveGasPrice:Formatter.allowNull(ie),status:Formatter.allowNull(ve),type:ge},t.block={hash:Formatter.allowNull(ue),parentHash:ue,number:ve,timestamp:ve,nonce:Formatter.allowNull(de),difficulty:this.difficulty.bind(this),gasLimit:ie,gasUsed:ie,miner:Formatter.allowNull(c),extraData:ae,transactions:Formatter.allowNull(Formatter.arrayOf(ue)),baseFeePerGas:Formatter.allowNull(ie)},t.blockWithTransactions=shallowCopy(t.block),t.blockWithTransactions.transactions=Formatter.allowNull(Formatter.arrayOf(this.transactionResponse.bind(this))),t.filter={fromBlock:Formatter.allowNull(se,void 0),toBlock:Formatter.allowNull(se,void 0),blockHash:Formatter.allowNull(ue,void 0),address:Formatter.allowNull(c,void 0),topics:Formatter.allowNull(this.topics.bind(this),void 0)},t.filterLog={blockNumber:Formatter.allowNull(ve),blockHash:Formatter.allowNull(ue),transactionIndex:ve,removed:Formatter.allowNull(this.boolean.bind(this)),address:c,data:Formatter.allowFalsish(ae,"0x"),topics:Formatter.arrayOf(ue),transactionHash:ue,logIndex:ve},t}accessList(t){return accessListify(t||[])}number(t){return t==="0x"?0:BigNumber.from(t).toNumber()}type(t){return t==="0x"||t==null?0:BigNumber.from(t).toNumber()}bigNumber(t){return BigNumber.from(t)}boolean(t){if(typeof t=="boolean")return t;if(typeof t=="string"){if(t=t.toLowerCase(),t==="true")return!0;if(t==="false")return!1}throw new Error("invalid boolean - "+t)}hex(t,c){return typeof t=="string"&&(!c&&t.substring(0,2)!=="0x"&&(t="0x"+t),isHexString(t))?t.toLowerCase():logger$5.throwArgumentError("invalid hash","value",t)}data(t,c){const ie=this.hex(t,c);if(ie.length%2!==0)throw new Error("invalid data; odd-length - "+t);return ie}address(t){return getAddress$1(t)}callAddress(t){if(!isHexString(t,32))return null;const c=getAddress$1(hexDataSlice(t,12));return c===AddressZero?null:c}contractAddress(t){return getContractAddress(t)}blockTag(t){if(t==null)return"latest";if(t==="earliest")return"0x0";switch(t){case"earliest":return"0x0";case"latest":case"pending":case"safe":case"finalized":return t}if(typeof t=="number"||isHexString(t))return hexValue(t);throw new Error("invalid blockTag")}hash(t,c){const ie=this.hex(t,c);return hexDataLength(ie)!==32?logger$5.throwArgumentError("invalid hash","value",t):ie}difficulty(t){if(t==null)return null;const c=BigNumber.from(t);try{return c.toNumber()}catch{}return null}uint256(t){if(!isHexString(t))throw new Error("invalid uint256");return hexZeroPad(t,32)}_block(t,c){t.author!=null&&t.miner==null&&(t.miner=t.author);const ie=t._difficulty!=null?t._difficulty:t.difficulty,se=Formatter.check(c,t);return se._difficulty=ie==null?null:BigNumber.from(ie),se}block(t){return this._block(t,this.formats.block)}blockWithTransactions(t){return this._block(t,this.formats.blockWithTransactions)}transactionRequest(t){return Formatter.check(this.formats.transactionRequest,t)}transactionResponse(t){t.gas!=null&&t.gasLimit==null&&(t.gasLimit=t.gas),t.to&&BigNumber.from(t.to).isZero()&&(t.to="0x0000000000000000000000000000000000000000"),t.input!=null&&t.data==null&&(t.data=t.input),t.to==null&&t.creates==null&&(t.creates=this.contractAddress(t)),(t.type===1||t.type===2)&&t.accessList==null&&(t.accessList=[]);const c=Formatter.check(this.formats.transaction,t);if(t.chainId!=null){let ie=t.chainId;isHexString(ie)&&(ie=BigNumber.from(ie).toNumber()),c.chainId=ie}else{let ie=t.networkId;ie==null&&c.v==null&&(ie=t.chainId),isHexString(ie)&&(ie=BigNumber.from(ie).toNumber()),typeof ie!="number"&&c.v!=null&&(ie=(c.v-35)/2,ie<0&&(ie=0),ie=parseInt(ie)),typeof ie!="number"&&(ie=0),c.chainId=ie}return c.blockHash&&c.blockHash.replace(/0/g,"")==="x"&&(c.blockHash=null),c}transaction(t){return parse$2(t)}receiptLog(t){return Formatter.check(this.formats.receiptLog,t)}receipt(t){const c=Formatter.check(this.formats.receipt,t);if(c.root!=null)if(c.root.length<=4){const ie=BigNumber.from(c.root).toNumber();ie===0||ie===1?(c.status!=null&&c.status!==ie&&logger$5.throwArgumentError("alt-root-status/status mismatch","value",{root:c.root,status:c.status}),c.status=ie,delete c.root):logger$5.throwArgumentError("invalid alt-root-status","value.root",c.root)}else c.root.length!==66&&logger$5.throwArgumentError("invalid root hash","value.root",c.root);return c.status!=null&&(c.byzantium=!0),c}topics(t){return Array.isArray(t)?t.map(c=>this.topics(c)):t!=null?this.hash(t,!0):null}filter(t){return Formatter.check(this.formats.filter,t)}filterLog(t){return Formatter.check(this.formats.filterLog,t)}static check(t,c){const ie={};for(const se in t)try{const ae=t[se](c[se]);ae!==void 0&&(ie[se]=ae)}catch(ae){throw ae.checkKey=se,ae.checkValue=c[se],ae}return ie}static allowNull(t,c){return function(ie){return ie==null?c:t(ie)}}static allowFalsish(t,c){return function(ie){return ie?t(ie):c}}static arrayOf(t){return function(c){if(!Array.isArray(c))throw new Error("not an array");const ie=[];return c.forEach(function(se){ie.push(t(se))}),ie}}}var __awaiter$c=function(n,t,c,ie){function se(ae){return ae instanceof c?ae:new c(function(ue){ue(ae)})}return new(c||(c=Promise))(function(ae,ue){function de(we){try{ge(ie.next(we))}catch(Te){ue(Te)}}function ve(we){try{ge(ie.throw(we))}catch(Te){ue(Te)}}function ge(we){we.done?ae(we.value):se(we.value).then(de,ve)}ge((ie=ie.apply(n,[])).next())})};const logger$4=new Logger(version$8),MAX_CCIP_REDIRECTS=10;function checkTopic(n){return n==null?"null":(hexDataLength(n)!==32&&logger$4.throwArgumentError("invalid topic","topic",n),n.toLowerCase())}function serializeTopics(n){for(n=n.slice();n.length>0&&n[n.length-1]==null;)n.pop();return n.map(t=>{if(Array.isArray(t)){const c={};t.forEach(se=>{c[checkTopic(se)]=!0});const ie=Object.keys(c);return ie.sort(),ie.join("|")}else return checkTopic(t)}).join("&")}function deserializeTopics(n){return n===""?[]:n.split(/&/g).map(t=>{if(t==="")return[];const c=t.split("|").map(ie=>ie==="null"?null:ie);return c.length===1?c[0]:c})}function getEventTag(n){if(typeof n=="string"){if(n=n.toLowerCase(),hexDataLength(n)===32)return"tx:"+n;if(n.indexOf(":")===-1)return n}else{if(Array.isArray(n))return"filter:*:"+serializeTopics(n);if(ForkEvent.isForkEvent(n))throw logger$4.warn("not implemented"),new Error("not implemented");if(n&&typeof n=="object")return"filter:"+(n.address||"*")+":"+serializeTopics(n.topics||[])}throw new Error("invalid event - "+n)}function getTime(){return new Date().getTime()}function stall(n){return new Promise(t=>{setTimeout(t,n)})}const PollableEvents=["block","network","pending","poll"];let Event$1=class{constructor(n,t,c){defineReadOnly(this,"tag",n),defineReadOnly(this,"listener",t),defineReadOnly(this,"once",c),this._lastBlockNumber=-2,this._inflight=!1}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 n=this.tag.split(":");return n[0]!=="tx"?null:n[1]}get filter(){const n=this.tag.split(":");if(n[0]!=="filter")return null;const t=n[1],c=deserializeTopics(n[2]),ie={};return c.length>0&&(ie.topics=c),t&&t!=="*"&&(ie.address=t),ie}pollable(){return this.tag.indexOf(":")>=0||PollableEvents.indexOf(this.tag)>=0}};const coinInfos={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 bytes32ify(n){return hexZeroPad(BigNumber.from(n).toHexString(),32)}function base58Encode(n){return Base58.encode(concat$1([n,hexDataSlice(sha256$7(sha256$7(n)),0,4)]))}const matcherIpfs=new RegExp("^(ipfs)://(.*)$","i"),matchers=[new RegExp("^(https)://(.*)$","i"),new RegExp("^(data):(.*)$","i"),matcherIpfs,new RegExp("^eip155:[0-9]+/(erc[0-9]+):(.*)$","i")];function _parseString(n,t){try{return toUtf8String(_parseBytes(n,t))}catch{}return null}function _parseBytes(n,t){if(n==="0x")return null;const c=BigNumber.from(hexDataSlice(n,t,t+32)).toNumber(),ie=BigNumber.from(hexDataSlice(n,c,c+32)).toNumber();return hexDataSlice(n,c+32,c+32+ie)}function getIpfsLink(n){return n.match(/^ipfs:\/\/ipfs\//i)?n=n.substring(12):n.match(/^ipfs:\/\//i)?n=n.substring(7):logger$4.throwArgumentError("unsupported IPFS format","link",n),`https://gateway.ipfs.io/ipfs/${n}`}function numPad(n){const t=arrayify(n);if(t.length>32)throw new Error("internal; should not happen");const c=new Uint8Array(32);return c.set(t,32-t.length),c}function bytesPad(n){if(n.length%32===0)return n;const t=new Uint8Array(Math.ceil(n.length/32)*32);return t.set(n),t}function encodeBytes(n){const t=[];let c=0;for(let ie=0;ie<n.length;ie++)t.push(null),c+=32;for(let ie=0;ie<n.length;ie++){const se=arrayify(n[ie]);t[ie]=numPad(c),t.push(numPad(se.length)),t.push(bytesPad(se)),c+=32+Math.ceil(se.length/32)*32}return hexConcat(t)}class Resolver{constructor(t,c,ie,se){defineReadOnly(this,"provider",t),defineReadOnly(this,"name",ie),defineReadOnly(this,"address",t.formatter.address(c)),defineReadOnly(this,"_resolvedAddress",se)}supportsWildcard(){return this._supportsEip2544||(this._supportsEip2544=this.provider.call({to:this.address,data:"0x01ffc9a79061b92300000000000000000000000000000000000000000000000000000000"}).then(t=>BigNumber.from(t).eq(1)).catch(t=>{if(t.code===Logger.errors.CALL_EXCEPTION)return!1;throw this._supportsEip2544=null,t})),this._supportsEip2544}_fetch(t,c){return __awaiter$c(this,void 0,void 0,function*(){const ie={to:this.address,ccipReadEnabled:!0,data:hexConcat([t,namehash$1(this.name),c||"0x"])};let se=!1;(yield this.supportsWildcard())&&(se=!0,ie.data=hexConcat(["0x9061b923",encodeBytes([dnsEncode(this.name),ie.data])]));try{let ae=yield this.provider.call(ie);return arrayify(ae).length%32===4&&logger$4.throwError("resolver threw error",Logger.errors.CALL_EXCEPTION,{transaction:ie,data:ae}),se&&(ae=_parseBytes(ae,0)),ae}catch(ae){if(ae.code===Logger.errors.CALL_EXCEPTION)return null;throw ae}})}_fetchBytes(t,c){return __awaiter$c(this,void 0,void 0,function*(){const ie=yield this._fetch(t,c);return ie!=null?_parseBytes(ie,0):null})}_getAddress(t,c){const ie=coinInfos[String(t)];if(ie==null&&logger$4.throwError(`unsupported coin type: ${t}`,Logger.errors.UNSUPPORTED_OPERATION,{operation:`getAddress(${t})`}),ie.ilk==="eth")return this.provider.formatter.address(c);const se=arrayify(c);if(ie.p2pkh!=null){const ae=c.match(/^0x76a9([0-9a-f][0-9a-f])([0-9a-f]*)88ac$/);if(ae){const ue=parseInt(ae[1],16);if(ae[2].length===ue*2&&ue>=1&&ue<=75)return base58Encode(concat$1([[ie.p2pkh],"0x"+ae[2]]))}}if(ie.p2sh!=null){const ae=c.match(/^0xa9([0-9a-f][0-9a-f])([0-9a-f]*)87$/);if(ae){const ue=parseInt(ae[1],16);if(ae[2].length===ue*2&&ue>=1&&ue<=75)return base58Encode(concat$1([[ie.p2sh],"0x"+ae[2]]))}}if(ie.prefix!=null){const ae=se[1];let ue=se[0];if(ue===0?ae!==20&&ae!==32&&(ue=-1):ue=-1,ue>=0&&se.length===2+ae&&ae>=1&&ae<=75){const de=bech32$2.toWords(se.slice(2));return de.unshift(ue),bech32$2.encode(ie.prefix,de)}}return null}getAddress(t){return __awaiter$c(this,void 0,void 0,function*(){if(t==null&&(t=60),t===60)try{const se=yield this._fetch("0x3b3b57de");return se==="0x"||se===HashZero?null:this.provider.formatter.callAddress(se)}catch(se){if(se.code===Logger.errors.CALL_EXCEPTION)return null;throw se}const c=yield this._fetchBytes("0xf1cb7e06",bytes32ify(t));if(c==null||c==="0x")return null;const ie=this._getAddress(t,c);return ie==null&&logger$4.throwError("invalid or unsupported coin data",Logger.errors.UNSUPPORTED_OPERATION,{operation:`getAddress(${t})`,coinType:t,data:c}),ie})}getAvatar(){return __awaiter$c(this,void 0,void 0,function*(){const t=[{type:"name",content:this.name}];try{const c=yield this.getText("avatar");if(c==null)return null;for(let ie=0;ie<matchers.length;ie++){const se=c.match(matchers[ie]);if(se==null)continue;const ae=se[1].toLowerCase();switch(ae){case"https":return t.push({type:"url",content:c}),{linkage:t,url:c};case"data":return t.push({type:"data",content:c}),{linkage:t,url:c};case"ipfs":return t.push({type:"ipfs",content:c}),{linkage:t,url:getIpfsLink(c)};case"erc721":case"erc1155":{const ue=ae==="erc721"?"0xc87b56dd":"0x0e89341c";t.push({type:ae,content:c});const de=this._resolvedAddress||(yield this.getAddress()),ve=(se[2]||"").split("/");if(ve.length!==2)return null;const ge=yield this.provider.formatter.address(ve[0]),we=hexZeroPad(BigNumber.from(ve[1]).toHexString(),32);if(ae==="erc721"){const He=this.provider.formatter.callAddress(yield this.provider.call({to:ge,data:hexConcat(["0x6352211e",we])}));if(de!==He)return null;t.push({type:"owner",content:He})}else if(ae==="erc1155"){const He=BigNumber.from(yield this.provider.call({to:ge,data:hexConcat(["0x00fdd58e",hexZeroPad(de,32),we])}));if(He.isZero())return null;t.push({type:"balance",content:He.toString()})}const Te={to:this.provider.formatter.address(ve[0]),data:hexConcat([ue,we])};let Ne=_parseString(yield this.provider.call(Te),0);if(Ne==null)return null;t.push({type:"metadata-url-base",content:Ne}),ae==="erc1155"&&(Ne=Ne.replace("{id}",we.substring(2)),t.push({type:"metadata-url-expanded",content:Ne})),Ne.match(/^ipfs:/i)&&(Ne=getIpfsLink(Ne)),t.push({type:"metadata-url",content:Ne});const qe=yield fetchJson(Ne);if(!qe)return null;t.push({type:"metadata",content:JSON.stringify(qe)});let ze=qe.image;if(typeof ze!="string")return null;if(!ze.match(/^(https:\/\/|data:)/i)){if(ze.match(matcherIpfs)==null)return null;t.push({type:"url-ipfs",content:ze}),ze=getIpfsLink(ze)}return t.push({type:"url",content:ze}),{linkage:t,url:ze}}}}}catch{}return null})}getContentHash(){return __awaiter$c(this,void 0,void 0,function*(){const t=yield this._fetchBytes("0xbc1c58d1");if(t==null||t==="0x")return null;const c=t.match(/^0xe3010170(([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])([0-9a-f]*))$/);if(c){const ue=parseInt(c[3],16);if(c[4].length===ue*2)return"ipfs://"+Base58.encode("0x"+c[1])}const ie=t.match(/^0xe5010172(([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])([0-9a-f]*))$/);if(ie){const ue=parseInt(ie[3],16);if(ie[4].length===ue*2)return"ipns://"+Base58.encode("0x"+ie[1])}const se=t.match(/^0xe40101fa011b20([0-9a-f]*)$/);if(se&&se[1].length===64)return"bzz://"+se[1];const ae=t.match(/^0x90b2c605([0-9a-f]*)$/);if(ae&&ae[1].length===68){const ue={"=":"","+":"-","/":"_"};return"sia://"+encode$5("0x"+ae[1]).replace(/[=+\/]/g,de=>ue[de])}return logger$4.throwError("invalid or unsupported content hash data",Logger.errors.UNSUPPORTED_OPERATION,{operation:"getContentHash()",data:t})})}getText(t){return __awaiter$c(this,void 0,void 0,function*(){let c=toUtf8Bytes(t);c=concat$1([bytes32ify(64),bytes32ify(c.length),c]),c.length%32!==0&&(c=concat$1([c,hexZeroPad("0x",32-t.length%32)]));const ie=yield this._fetchBytes("0x59d1d43c",hexlify(c));return ie==null||ie==="0x"?null:toUtf8String(ie)})}}let defaultFormatter=null,nextPollId=1;class BaseProvider extends Provider{constructor(t){if(super(),this._events=[],this._emitted={block:-2},this.disableCcipRead=!1,this.formatter=new.target.getFormatter(),defineReadOnly(this,"anyNetwork",t==="any"),this.anyNetwork&&(t=this.detectNetwork()),t instanceof Promise)this._networkPromise=t,t.catch(c=>{}),this._ready().catch(c=>{});else{const c=getStatic(new.target,"getNetwork")(t);c?(defineReadOnly(this,"_network",c),this.emit("network",c,null)):logger$4.throwArgumentError("invalid network","network",t)}this._maxInternalBlockNumber=-1024,this._lastBlockNumber=-2,this._maxFilterBlockRange=10,this._pollingInterval=4e3,this._fastQueryDate=0}_ready(){return __awaiter$c(this,void 0,void 0,function*(){if(this._network==null){let t=null;if(this._networkPromise)try{t=yield this._networkPromise}catch{}t==null&&(t=yield this.detectNetwork()),t||logger$4.throwError("no network detected",Logger.errors.UNKNOWN_ERROR,{}),this._network==null&&(this.anyNetwork?this._network=t:defineReadOnly(this,"_network",t),this.emit("network",t,null))}return this._network})}get ready(){return poll(()=>this._ready().then(t=>t,t=>{if(!(t.code===Logger.errors.NETWORK_ERROR&&t.event==="noNetwork"))throw t}))}static getFormatter(){return defaultFormatter==null&&(defaultFormatter=new Formatter),defaultFormatter}static getNetwork(t){return getNetwork(t??"homestead")}ccipReadFetch(t,c,ie){return __awaiter$c(this,void 0,void 0,function*(){if(this.disableCcipRead||ie.length===0)return null;const se=t.to.toLowerCase(),ae=c.toLowerCase(),ue=[];for(let de=0;de<ie.length;de++){const ve=ie[de],ge=ve.replace("{sender}",se).replace("{data}",ae),we=ve.indexOf("{data}")>=0?null:JSON.stringify({data:ae,sender:se}),Te=yield fetchJson({url:ge,errorPassThrough:!0},we,(qe,ze)=>(qe.status=ze.statusCode,qe));if(Te.data)return Te.data;const Ne=Te.message||"unknown error";if(Te.status>=400&&Te.status<500)return logger$4.throwError(`response not found during CCIP fetch: ${Ne}`,Logger.errors.SERVER_ERROR,{url:ve,errorMessage:Ne});ue.push(Ne)}return logger$4.throwError(`error encountered during CCIP fetch: ${ue.map(de=>JSON.stringify(de)).join(", ")}`,Logger.errors.SERVER_ERROR,{urls:ie,errorMessages:ue})})}_getInternalBlockNumber(t){return __awaiter$c(this,void 0,void 0,function*(){if(yield this._ready(),t>0)for(;this._internalBlockNumber;){const se=this._internalBlockNumber;try{const ae=yield se;if(getTime()-ae.respTime<=t)return ae.blockNumber;break}catch{if(this._internalBlockNumber===se)break}}const c=getTime(),ie=resolveProperties({blockNumber:this.perform("getBlockNumber",{}),networkError:this.getNetwork().then(se=>null,se=>se)}).then(({blockNumber:se,networkError:ae})=>{if(ae)throw this._internalBlockNumber===ie&&(this._internalBlockNumber=null),ae;const ue=getTime();return se=BigNumber.from(se).toNumber(),se<this._maxInternalBlockNumber&&(se=this._maxInternalBlockNumber),this._maxInternalBlockNumber=se,this._setFastBlockNumber(se),{blockNumber:se,reqTime:c,respTime:ue}});return this._internalBlockNumber=ie,ie.catch(se=>{this._internalBlockNumber===ie&&(this._internalBlockNumber=null)}),(yield ie).blockNumber})}poll(){return __awaiter$c(this,void 0,void 0,function*(){const t=nextPollId++,c=[];let ie=null;try{ie=yield this._getInternalBlockNumber(100+this.pollingInterval/2)}catch(se){this.emit("error",se);return}if(this._setFastBlockNumber(ie),this.emit("poll",t,ie),ie===this._lastBlockNumber){this.emit("didPoll",t);return}if(this._emitted.block===-2&&(this._emitted.block=ie-1),Math.abs(this._emitted.block-ie)>1e3)logger$4.warn(`network block skew detected; skipping block events (emitted=${this._emitted.block} blockNumber${ie})`),this.emit("error",logger$4.makeError("network block skew detected",Logger.errors.NETWORK_ERROR,{blockNumber:ie,event:"blockSkew",previousBlockNumber:this._emitted.block})),this.emit("block",ie);else for(let se=this._emitted.block+1;se<=ie;se++)this.emit("block",se);this._emitted.block!==ie&&(this._emitted.block=ie,Object.keys(this._emitted).forEach(se=>{if(se==="block")return;const ae=this._emitted[se];ae!=="pending"&&ie-ae>12&&delete this._emitted[se]})),this._lastBlockNumber===-2&&(this._lastBlockNumber=ie-1),this._events.forEach(se=>{switch(se.type){case"tx":{const ae=se.hash;let ue=this.getTransactionReceipt(ae).then(de=>(!de||de.blockNumber==null||(this._emitted["t:"+ae]=de.blockNumber,this.emit(ae,de)),null)).catch(de=>{this.emit("error",de)});c.push(ue);break}case"filter":{if(!se._inflight){se._inflight=!0,se._lastBlockNumber===-2&&(se._lastBlockNumber=ie-1);const ae=se.filter;ae.fromBlock=se._lastBlockNumber+1,ae.toBlock=ie;const ue=ae.toBlock-this._maxFilterBlockRange;ue>ae.fromBlock&&(ae.fromBlock=ue),ae.fromBlock<0&&(ae.fromBlock=0);const de=this.getLogs(ae).then(ve=>{se._inflight=!1,ve.length!==0&&ve.forEach(ge=>{ge.blockNumber>se._lastBlockNumber&&(se._lastBlockNumber=ge.blockNumber),this._emitted["b:"+ge.blockHash]=ge.blockNumber,this._emitted["t:"+ge.transactionHash]=ge.blockNumber,this.emit(ae,ge)})}).catch(ve=>{this.emit("error",ve),se._inflight=!1});c.push(de)}break}}}),this._lastBlockNumber=ie,Promise.all(c).then(()=>{this.emit("didPoll",t)}).catch(se=>{this.emit("error",se)})})}resetEventsBlock(t){this._lastBlockNumber=t-1,this.polling&&this.poll()}get network(){return this._network}detectNetwork(){return __awaiter$c(this,void 0,void 0,function*(){return logger$4.throwError("provider does not support network detection",Logger.errors.UNSUPPORTED_OPERATION,{operation:"provider.detectNetwork"})})}getNetwork(){return __awaiter$c(this,void 0,void 0,function*(){const t=yield this._ready(),c=yield this.detectNetwork();if(t.chainId!==c.chainId){if(this.anyNetwork)return this._network=c,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",c,t),yield stall(0),this._network;const ie=logger$4.makeError("underlying network changed",Logger.errors.NETWORK_ERROR,{event:"changed",network:t,detectedNetwork:c});throw this.emit("error",ie),ie}return t})}get blockNumber(){return this._getInternalBlockNumber(100+this.pollingInterval/2).then(t=>{this._setFastBlockNumber(t)},t=>{}),this._fastBlockNumber!=null?this._fastBlockNumber:-1}get polling(){return this._poller!=null}set polling(t){t&&!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))):!t&&this._poller&&(clearInterval(this._poller),this._poller=null)}get pollingInterval(){return this._pollingInterval}set pollingInterval(t){if(typeof t!="number"||t<=0||parseInt(String(t))!=t)throw new Error("invalid polling interval");this._pollingInterval=t,this._poller&&(clearInterval(this._poller),this._poller=setInterval(()=>{this.poll()},this._pollingInterval))}_getFastBlockNumber(){const t=getTime();return t-this._fastQueryDate>2*this._pollingInterval&&(this._fastQueryDate=t,this._fastBlockNumberPromise=this.getBlockNumber().then(c=>((this._fastBlockNumber==null||c>this._fastBlockNumber)&&(this._fastBlockNumber=c),this._fastBlockNumber))),this._fastBlockNumberPromise}_setFastBlockNumber(t){this._fastBlockNumber!=null&&t<this._fastBlockNumber||(this._fastQueryDate=getTime(),(this._fastBlockNumber==null||t>this._fastBlockNumber)&&(this._fastBlockNumber=t,this._fastBlockNumberPromise=Promise.resolve(t)))}waitForTransaction(t,c,ie){return __awaiter$c(this,void 0,void 0,function*(){return this._waitForTransaction(t,c??1,ie||0,null)})}_waitForTransaction(t,c,ie,se){return __awaiter$c(this,void 0,void 0,function*(){const ae=yield this.getTransactionReceipt(t);return(ae?ae.confirmations:0)>=c?ae:new Promise((ue,de)=>{const ve=[];let ge=!1;const we=function(){return ge?!0:(ge=!0,ve.forEach(Ne=>{Ne()}),!1)},Te=Ne=>{Ne.confirmations<c||we()||ue(Ne)};if(this.on(t,Te),ve.push(()=>{this.removeListener(t,Te)}),se){let Ne=se.startBlock,qe=null;const ze=He=>__awaiter$c(this,void 0,void 0,function*(){ge||(yield stall(1e3),this.getTransactionCount(se.from).then(Ge=>__awaiter$c(this,void 0,void 0,function*(){if(!ge){if(Ge<=se.nonce)Ne=He;else{{const Ze=yield this.getTransaction(t);if(Ze&&Ze.blockNumber!=null)return}for(qe==null&&(qe=Ne-3,qe<se.startBlock&&(qe=se.startBlock));qe<=He;){if(ge)return;const Ze=yield this.getBlockWithTransactions(qe);for(let Ye=0;Ye<Ze.transactions.length;Ye++){const Ft=Ze.transactions[Ye];if(Ft.hash===t)return;if(Ft.from===se.from&&Ft.nonce===se.nonce){if(ge)return;const Mt=yield this.waitForTransaction(Ft.hash,c);if(we())return;let Zt="replaced";Ft.data===se.data&&Ft.to===se.to&&Ft.value.eq(se.value)?Zt="repriced":Ft.data==="0x"&&Ft.from===Ft.to&&Ft.value.isZero()&&(Zt="cancelled"),de(logger$4.makeError("transaction was replaced",Logger.errors.TRANSACTION_REPLACED,{cancelled:Zt==="replaced"||Zt==="cancelled",reason:Zt,replacement:this._wrapTransaction(Ft),hash:t,receipt:Mt}));return}}qe++}}ge||this.once("block",ze)}}),Ge=>{ge||this.once("block",ze)}))});if(ge)return;this.once("block",ze),ve.push(()=>{this.removeListener("block",ze)})}if(typeof ie=="number"&&ie>0){const Ne=setTimeout(()=>{we()||de(logger$4.makeError("timeout exceeded",Logger.errors.TIMEOUT,{timeout:ie}))},ie);Ne.unref&&Ne.unref(),ve.push(()=>{clearTimeout(Ne)})}})})}getBlockNumber(){return __awaiter$c(this,void 0,void 0,function*(){return this._getInternalBlockNumber(0)})}getGasPrice(){return __awaiter$c(this,void 0,void 0,function*(){yield this.getNetwork();const t=yield this.perform("getGasPrice",{});try{return BigNumber.from(t)}catch(c){return logger$4.throwError("bad result from backend",Logger.errors.SERVER_ERROR,{method:"getGasPrice",result:t,error:c})}})}getBalance(t,c){return __awaiter$c(this,void 0,void 0,function*(){yield this.getNetwork();const ie=yield resolveProperties({address:this._getAddress(t),blockTag:this._getBlockTag(c)}),se=yield this.perform("getBalance",ie);try{return BigNumber.from(se)}catch(ae){return logger$4.throwError("bad result from backend",Logger.errors.SERVER_ERROR,{method:"getBalance",params:ie,result:se,error:ae})}})}getTransactionCount(t,c){return __awaiter$c(this,void 0,void 0,function*(){yield this.getNetwork();const ie=yield resolveProperties({address:this._getAddress(t),blockTag:this._getBlockTag(c)}),se=yield this.perform("getTransactionCount",ie);try{return BigNumber.from(se).toNumber()}catch(ae){return logger$4.throwError("bad result from backend",Logger.errors.SERVER_ERROR,{method:"getTransactionCount",params:ie,result:se,error:ae})}})}getCode(t,c){return __awaiter$c(this,void 0,void 0,function*(){yield this.getNetwork();const ie=yield resolveProperties({address:this._getAddress(t),blockTag:this._getBlockTag(c)}),se=yield this.perform("getCode",ie);try{return hexlify(se)}catch(ae){return logger$4.throwError("bad result from backend",Logger.errors.SERVER_ERROR,{method:"getCode",params:ie,result:se,error:ae})}})}getStorageAt(t,c,ie){return __awaiter$c(this,void 0,void 0,function*(){yield this.getNetwork();const se=yield resolveProperties({address:this._getAddress(t),blockTag:this._getBlockTag(ie),position:Promise.resolve(c).then(ue=>hexValue(ue))}),ae=yield this.perform("getStorageAt",se);try{return hexlify(ae)}catch(ue){return logger$4.throwError("bad result from backend",Logger.errors.SERVER_ERROR,{method:"getStorageAt",params:se,result:ae,error:ue})}})}_wrapTransaction(t,c,ie){if(c!=null&&hexDataLength(c)!==32)throw new Error("invalid response - sendTransaction");const se=t;return c!=null&&t.hash!==c&&logger$4.throwError("Transaction hash mismatch from Provider.sendTransaction.",Logger.errors.UNKNOWN_ERROR,{expectedHash:t.hash,returnedHash:c}),se.wait=(ae,ue)=>__awaiter$c(this,void 0,void 0,function*(){ae==null&&(ae=1),ue==null&&(ue=0);let de;ae!==0&&ie!=null&&(de={data:t.data,from:t.from,nonce:t.nonce,to:t.to,value:t.value,startBlock:ie});const ve=yield this._waitForTransaction(t.hash,ae,ue,de);return ve==null&&ae===0?null:(this._emitted["t:"+t.hash]=ve.blockNumber,ve.status===0&&logger$4.throwError("transaction failed",Logger.errors.CALL_EXCEPTION,{transactionHash:t.hash,transaction:t,receipt:ve}),ve)}),se}sendTransaction(t){return __awaiter$c(this,void 0,void 0,function*(){yield this.getNetwork();const c=yield Promise.resolve(t).then(ae=>hexlify(ae)),ie=this.formatter.transaction(t);ie.confirmations==null&&(ie.confirmations=0);const se=yield this._getInternalBlockNumber(100+2*this.pollingInterval);try{const ae=yield this.perform("sendTransaction",{signedTransaction:c});return this._wrapTransaction(ie,ae,se)}catch(ae){throw ae.transaction=ie,ae.transactionHash=ie.hash,ae}})}_getTransactionRequest(t){return __awaiter$c(this,void 0,void 0,function*(){const c=yield t,ie={};return["from","to"].forEach(se=>{c[se]!=null&&(ie[se]=Promise.resolve(c[se]).then(ae=>ae?this._getAddress(ae):null))}),["gasLimit","gasPrice","maxFeePerGas","maxPriorityFeePerGas","value"].forEach(se=>{c[se]!=null&&(ie[se]=Promise.resolve(c[se]).then(ae=>ae?BigNumber.from(ae):null))}),["type"].forEach(se=>{c[se]!=null&&(ie[se]=Promise.resolve(c[se]).then(ae=>ae??null))}),c.accessList&&(ie.accessList=this.formatter.accessList(c.accessList)),["data"].forEach(se=>{c[se]!=null&&(ie[se]=Promise.resolve(c[se]).then(ae=>ae?hexlify(ae):null))}),this.formatter.transactionRequest(yield resolveProperties(ie))})}_getFilter(t){return __awaiter$c(this,void 0,void 0,function*(){t=yield t;const c={};return t.address!=null&&(c.address=this._getAddress(t.address)),["blockHash","topics"].forEach(ie=>{t[ie]!=null&&(c[ie]=t[ie])}),["fromBlock","toBlock"].forEach(ie=>{t[ie]!=null&&(c[ie]=this._getBlockTag(t[ie]))}),this.formatter.filter(yield resolveProperties(c))})}_call(t,c,ie){return __awaiter$c(this,void 0,void 0,function*(){ie>=MAX_CCIP_REDIRECTS&&logger$4.throwError("CCIP read exceeded maximum redirections",Logger.errors.SERVER_ERROR,{redirects:ie,transaction:t});const se=t.to,ae=yield this.perform("call",{transaction:t,blockTag:c});if(ie>=0&&c==="latest"&&se!=null&&ae.substring(0,10)==="0x556f1830"&&hexDataLength(ae)%32===4)try{const ue=hexDataSlice(ae,4),de=hexDataSlice(ue,0,32);BigNumber.from(de).eq(se)||logger$4.throwError("CCIP Read sender did not match",Logger.errors.CALL_EXCEPTION,{name:"OffchainLookup",signature:"OffchainLookup(address,string[],bytes,bytes4,bytes)",transaction:t,data:ae});const ve=[],ge=BigNumber.from(hexDataSlice(ue,32,64)).toNumber(),we=BigNumber.from(hexDataSlice(ue,ge,ge+32)).toNumber(),Te=hexDataSlice(ue,ge+32);for(let Ze=0;Ze<we;Ze++){const Ye=_parseString(Te,Ze*32);Ye==null&&logger$4.throwError("CCIP Read contained corrupt URL string",Logger.errors.CALL_EXCEPTION,{name:"OffchainLookup",signature:"OffchainLookup(address,string[],bytes,bytes4,bytes)",transaction:t,data:ae}),ve.push(Ye)}const Ne=_parseBytes(ue,64);BigNumber.from(hexDataSlice(ue,100,128)).isZero()||logger$4.throwError("CCIP Read callback selector included junk",Logger.errors.CALL_EXCEPTION,{name:"OffchainLookup",signature:"OffchainLookup(address,string[],bytes,bytes4,bytes)",transaction:t,data:ae});const qe=hexDataSlice(ue,96,100),ze=_parseBytes(ue,128),He=yield this.ccipReadFetch(t,Ne,ve);He==null&&logger$4.throwError("CCIP Read disabled or provided no URLs",Logger.errors.CALL_EXCEPTION,{name:"OffchainLookup",signature:"OffchainLookup(address,string[],bytes,bytes4,bytes)",transaction:t,data:ae});const Ge={to:se,data:hexConcat([qe,encodeBytes([He,ze])])};return this._call(Ge,c,ie+1)}catch(ue){if(ue.code===Logger.errors.SERVER_ERROR)throw ue}try{return hexlify(ae)}catch(ue){return logger$4.throwError("bad result from backend",Logger.errors.SERVER_ERROR,{method:"call",params:{transaction:t,blockTag:c},result:ae,error:ue})}})}call(t,c){return __awaiter$c(this,void 0,void 0,function*(){yield this.getNetwork();const ie=yield resolveProperties({transaction:this._getTransactionRequest(t),blockTag:this._getBlockTag(c),ccipReadEnabled:Promise.resolve(t.ccipReadEnabled)});return this._call(ie.transaction,ie.blockTag,ie.ccipReadEnabled?0:-1)})}estimateGas(t){return __awaiter$c(this,void 0,void 0,function*(){yield this.getNetwork();const c=yield resolveProperties({transaction:this._getTransactionRequest(t)}),ie=yield this.perform("estimateGas",c);try{return BigNumber.from(ie)}catch(se){return logger$4.throwError("bad result from backend",Logger.errors.SERVER_ERROR,{method:"estimateGas",params:c,result:ie,error:se})}})}_getAddress(t){return __awaiter$c(this,void 0,void 0,function*(){t=yield t,typeof t!="string"&&logger$4.throwArgumentError("invalid address or ENS name","name",t);const c=yield this.resolveName(t);return c==null&&logger$4.throwError("ENS name not configured",Logger.errors.UNSUPPORTED_OPERATION,{operation:`resolveName(${JSON.stringify(t)})`}),c})}_getBlock(t,c){return __awaiter$c(this,void 0,void 0,function*(){yield this.getNetwork(),t=yield t;let ie=-128;const se={includeTransactions:!!c};if(isHexString(t,32))se.blockHash=t;else try{se.blockTag=yield this._getBlockTag(t),isHexString(se.blockTag)&&(ie=parseInt(se.blockTag.substring(2),16))}catch{logger$4.throwArgumentError("invalid block hash or block tag","blockHashOrBlockTag",t)}return poll(()=>__awaiter$c(this,void 0,void 0,function*(){const ae=yield this.perform("getBlock",se);if(ae==null)return se.blockHash!=null&&this._emitted["b:"+se.blockHash]==null||se.blockTag!=null&&ie>this._emitted.block?null:void 0;if(c){let ue=null;for(let ve=0;ve<ae.transactions.length;ve++){const ge=ae.transactions[ve];if(ge.blockNumber==null)ge.confirmations=0;else if(ge.confirmations==null){ue==null&&(ue=yield this._getInternalBlockNumber(100+2*this.pollingInterval));let we=ue-ge.blockNumber+1;we<=0&&(we=1),ge.confirmations=we}}const de=this.formatter.blockWithTransactions(ae);return de.transactions=de.transactions.map(ve=>this._wrapTransaction(ve)),de}return this.formatter.block(ae)}),{oncePoll:this})})}getBlock(t){return this._getBlock(t,!1)}getBlockWithTransactions(t){return this._getBlock(t,!0)}getTransaction(t){return __awaiter$c(this,void 0,void 0,function*(){yield this.getNetwork(),t=yield t;const c={transactionHash:this.formatter.hash(t,!0)};return poll(()=>__awaiter$c(this,void 0,void 0,function*(){const ie=yield this.perform("getTransaction",c);if(ie==null)return this._emitted["t:"+t]==null?null:void 0;const se=this.formatter.transactionResponse(ie);if(se.blockNumber==null)se.confirmations=0;else if(se.confirmations==null){let ae=(yield this._getInternalBlockNumber(100+2*this.pollingInterval))-se.blockNumber+1;ae<=0&&(ae=1),se.confirmations=ae}return this._wrapTransaction(se)}),{oncePoll:this})})}getTransactionReceipt(t){return __awaiter$c(this,void 0,void 0,function*(){yield this.getNetwork(),t=yield t;const c={transactionHash:this.formatter.hash(t,!0)};return poll(()=>__awaiter$c(this,void 0,void 0,function*(){const ie=yield this.perform("getTransactionReceipt",c);if(ie==null)return this._emitted["t:"+t]==null?null:void 0;if(ie.blockHash==null)return;const se=this.formatter.receipt(ie);if(se.blockNumber==null)se.confirmations=0;else if(se.confirmations==null){let ae=(yield this._getInternalBlockNumber(100+2*this.pollingInterval))-se.blockNumber+1;ae<=0&&(ae=1),se.confirmations=ae}return se}),{oncePoll:this})})}getLogs(t){return __awaiter$c(this,void 0,void 0,function*(){yield this.getNetwork();const c=yield resolveProperties({filter:this._getFilter(t)}),ie=yield this.perform("getLogs",c);return ie.forEach(se=>{se.removed==null&&(se.removed=!1)}),Formatter.arrayOf(this.formatter.filterLog.bind(this.formatter))(ie)})}getEtherPrice(){return __awaiter$c(this,void 0,void 0,function*(){return yield this.getNetwork(),this.perform("getEtherPrice",{})})}_getBlockTag(t){return __awaiter$c(this,void 0,void 0,function*(){if(t=yield t,typeof t=="number"&&t<0){t%1&&logger$4.throwArgumentError("invalid BlockTag","blockTag",t);let c=yield this._getInternalBlockNumber(100+2*this.pollingInterval);return c+=t,c<0&&(c=0),this.formatter.blockTag(c)}return this.formatter.blockTag(t)})}getResolver(t){return __awaiter$c(this,void 0,void 0,function*(){let c=t;for(;;){if(c===""||c==="."||t!=="eth"&&c==="eth")return null;const ie=yield this._getResolver(c,"getResolver");if(ie!=null){const se=new Resolver(this,ie,t);return c!==t&&!(yield se.supportsWildcard())?null:se}c=c.split(".").slice(1).join(".")}})}_getResolver(t,c){return __awaiter$c(this,void 0,void 0,function*(){c==null&&(c="ENS");const ie=yield this.getNetwork();ie.ensAddress||logger$4.throwError("network does not support ENS",Logger.errors.UNSUPPORTED_OPERATION,{operation:c,network:ie.name});try{const se=yield this.call({to:ie.ensAddress,data:"0x0178b8bf"+namehash$1(t).substring(2)});return this.formatter.callAddress(se)}catch{}return null})}resolveName(t){return __awaiter$c(this,void 0,void 0,function*(){t=yield t;try{return Promise.resolve(this.formatter.address(t))}catch(ie){if(isHexString(t))throw ie}typeof t!="string"&&logger$4.throwArgumentError("invalid ENS name","name",t);const c=yield this.getResolver(t);return c?yield c.getAddress():null})}lookupAddress(t){return __awaiter$c(this,void 0,void 0,function*(){t=yield t,t=this.formatter.address(t);const c=t.substring(2).toLowerCase()+".addr.reverse",ie=yield this._getResolver(c,"lookupAddress");if(ie==null)return null;const se=_parseString(yield this.call({to:ie,data:"0x691f3431"+namehash$1(c).substring(2)}),0);return(yield this.resolveName(se))!=t?null:se})}getAvatar(t){return __awaiter$c(this,void 0,void 0,function*(){let c=null;if(isHexString(t)){const se=this.formatter.address(t).substring(2).toLowerCase()+".addr.reverse",ae=yield this._getResolver(se,"getAvatar");if(!ae)return null;c=new Resolver(this,ae,se);try{const ue=yield c.getAvatar();if(ue)return ue.url}catch(ue){if(ue.code!==Logger.errors.CALL_EXCEPTION)throw ue}try{const ue=_parseString(yield this.call({to:ae,data:"0x691f3431"+namehash$1(se).substring(2)}),0);c=yield this.getResolver(ue)}catch(ue){if(ue.code!==Logger.errors.CALL_EXCEPTION)throw ue;return null}}else if(c=yield this.getResolver(t),!c)return null;const ie=yield c.getAvatar();return ie==null?null:ie.url})}perform(t,c){return logger$4.throwError(t+" not implemented",Logger.errors.NOT_IMPLEMENTED,{operation:t})}_startEvent(t){this.polling=this._events.filter(c=>c.pollable()).length>0}_stopEvent(t){this.polling=this._events.filter(c=>c.pollable()).length>0}_addEventListener(t,c,ie){const se=new Event$1(getEventTag(t),c,ie);return this._events.push(se),this._startEvent(se),this}on(t,c){return this._addEventListener(t,c,!1)}once(t,c){return this._addEventListener(t,c,!0)}emit(t,...c){let ie=!1,se=[],ae=getEventTag(t);return this._events=this._events.filter(ue=>ue.tag!==ae?!0:(setTimeout(()=>{ue.listener.apply(this,c)},0),ie=!0,ue.once?(se.push(ue),!1):!0)),se.forEach(ue=>{this._stopEvent(ue)}),ie}listenerCount(t){if(!t)return this._events.length;let c=getEventTag(t);return this._events.filter(ie=>ie.tag===c).length}listeners(t){if(t==null)return this._events.map(ie=>ie.listener);let c=getEventTag(t);return this._events.filter(ie=>ie.tag===c).map(ie=>ie.listener)}off(t,c){if(c==null)return this.removeAllListeners(t);const ie=[];let se=!1,ae=getEventTag(t);return this._events=this._events.filter(ue=>ue.tag!==ae||ue.listener!=c||se?!0:(se=!0,ie.push(ue),!1)),ie.forEach(ue=>{this._stopEvent(ue)}),this}removeAllListeners(t){let c=[];if(t==null)c=this._events,this._events=[];else{const ie=getEventTag(t);this._events=this._events.filter(se=>se.tag!==ie?!0:(c.push(se),!1))}return c.forEach(ie=>{this._stopEvent(ie)}),this}}var __awaiter$b=function(n,t,c,ie){function se(ae){return ae instanceof c?ae:new c(function(ue){ue(ae)})}return new(c||(c=Promise))(function(ae,ue){function de(we){try{ge(ie.next(we))}catch(Te){ue(Te)}}function ve(we){try{ge(ie.throw(we))}catch(Te){ue(Te)}}function ge(we){we.done?ae(we.value):se(we.value).then(de,ve)}ge((ie=ie.apply(n,[])).next())})};const logger$3=new Logger(version$8),errorGas=["call","estimateGas"];function spelunk(n,t){if(n==null)return null;if(typeof n.message=="string"&&n.message.match("reverted")){const c=isHexString(n.data)?n.data:null;if(!t||c)return{message:n.message,data:c}}if(typeof n=="object"){for(const c in n){const ie=spelunk(n[c],t);if(ie)return ie}return null}if(typeof n=="string")try{return spelunk(JSON.parse(n),t)}catch{}return null}function checkError(n,t,c){const ie=c.transaction||c.signedTransaction;if(n==="call"){const ae=spelunk(t,!0);if(ae)return ae.data;logger$3.throwError("missing revert data in call exception; Transaction reverted without a reason string",Logger.errors.CALL_EXCEPTION,{data:"0x",transaction:ie,error:t})}if(n==="estimateGas"){let ae=spelunk(t.body,!1);ae==null&&(ae=spelunk(t,!1)),ae&&logger$3.throwError("cannot estimate gas; transaction may fail or may require manual gas limit",Logger.errors.UNPREDICTABLE_GAS_LIMIT,{reason:ae.message,method:n,transaction:ie,error:t})}let se=t.message;throw t.code===Logger.errors.SERVER_ERROR&&t.error&&typeof t.error.message=="string"?se=t.error.message:typeof t.body=="string"?se=t.body:typeof t.responseText=="string"&&(se=t.responseText),se=(se||"").toLowerCase(),se.match(/insufficient funds|base fee exceeds gas limit|InsufficientFunds/i)&&logger$3.throwError("insufficient funds for intrinsic transaction cost",Logger.errors.INSUFFICIENT_FUNDS,{error:t,method:n,transaction:ie}),se.match(/nonce (is )?too low/i)&&logger$3.throwError("nonce has already been used",Logger.errors.NONCE_EXPIRED,{error:t,method:n,transaction:ie}),se.match(/replacement transaction underpriced|transaction gas price.*too low/i)&&logger$3.throwError("replacement fee too low",Logger.errors.REPLACEMENT_UNDERPRICED,{error:t,method:n,transaction:ie}),se.match(/only replay-protected/i)&&logger$3.throwError("legacy pre-eip-155 transactions not supported",Logger.errors.UNSUPPORTED_OPERATION,{error:t,method:n,transaction:ie}),errorGas.indexOf(n)>=0&&se.match(/gas required exceeds allowance|always failing transaction|execution reverted|revert/)&&logger$3.throwError("cannot estimate gas; transaction may fail or may require manual gas limit",Logger.errors.UNPREDICTABLE_GAS_LIMIT,{error:t,method:n,transaction:ie}),t}function timer(n){return new Promise(function(t){setTimeout(t,n)})}function getResult(n){if(n.error){const t=new Error(n.error.message);throw t.code=n.error.code,t.data=n.error.data,t}return n.result}function getLowerCase(n){return n&&n.toLowerCase()}const _constructorGuard={};class JsonRpcSigner extends Signer{constructor(t,c,ie){if(super(),t!==_constructorGuard)throw new Error("do not call the JsonRpcSigner constructor directly; use provider.getSigner");defineReadOnly(this,"provider",c),ie==null&&(ie=0),typeof ie=="string"?(defineReadOnly(this,"_address",this.provider.formatter.address(ie)),defineReadOnly(this,"_index",null)):typeof ie=="number"?(defineReadOnly(this,"_index",ie),defineReadOnly(this,"_address",null)):logger$3.throwArgumentError("invalid address or index","addressOrIndex",ie)}connect(t){return logger$3.throwError("cannot alter JSON-RPC Signer connection",Logger.errors.UNSUPPORTED_OPERATION,{operation:"connect"})}connectUnchecked(){return new UncheckedJsonRpcSigner(_constructorGuard,this.provider,this._address||this._index)}getAddress(){return this._address?Promise.resolve(this._address):this.provider.send("eth_accounts",[]).then(t=>(t.length<=this._index&&logger$3.throwError("unknown account #"+this._index,Logger.errors.UNSUPPORTED_OPERATION,{operation:"getAddress"}),this.provider.formatter.address(t[this._index])))}sendUncheckedTransaction(t){t=shallowCopy(t);const c=this.getAddress().then(ie=>(ie&&(ie=ie.toLowerCase()),ie));if(t.gasLimit==null){const ie=shallowCopy(t);ie.from=c,t.gasLimit=this.provider.estimateGas(ie)}return t.to!=null&&(t.to=Promise.resolve(t.to).then(ie=>__awaiter$b(this,void 0,void 0,function*(){if(ie==null)return null;const se=yield this.provider.resolveName(ie);return se==null&&logger$3.throwArgumentError("provided ENS name resolves to null","tx.to",ie),se}))),resolveProperties({tx:resolveProperties(t),sender:c}).then(({tx:ie,sender:se})=>{ie.from!=null?ie.from.toLowerCase()!==se&&logger$3.throwArgumentError("from address mismatch","transaction",t):ie.from=se;const ae=this.provider.constructor.hexlifyTransaction(ie,{from:!0});return this.provider.send("eth_sendTransaction",[ae]).then(ue=>ue,ue=>(typeof ue.message=="string"&&ue.message.match(/user denied/i)&&logger$3.throwError("user rejected transaction",Logger.errors.ACTION_REJECTED,{action:"sendTransaction",transaction:ie}),checkError("sendTransaction",ue,ae)))})}signTransaction(t){return logger$3.throwError("signing transactions is unsupported",Logger.errors.UNSUPPORTED_OPERATION,{operation:"signTransaction"})}sendTransaction(t){return __awaiter$b(this,void 0,void 0,function*(){const c=yield this.provider._getInternalBlockNumber(100+2*this.provider.pollingInterval),ie=yield this.sendUncheckedTransaction(t);try{return yield poll(()=>__awaiter$b(this,void 0,void 0,function*(){const se=yield this.provider.getTransaction(ie);if(se!==null)return this.provider._wrapTransaction(se,ie,c)}),{oncePoll:this.provider})}catch(se){throw se.transactionHash=ie,se}})}signMessage(t){return __awaiter$b(this,void 0,void 0,function*(){const c=typeof t=="string"?toUtf8Bytes(t):t,ie=yield this.getAddress();try{return yield this.provider.send("personal_sign",[hexlify(c),ie.toLowerCase()])}catch(se){throw typeof se.message=="string"&&se.message.match(/user denied/i)&&logger$3.throwError("user rejected signing",Logger.errors.ACTION_REJECTED,{action:"signMessage",from:ie,messageData:t}),se}})}_legacySignMessage(t){return __awaiter$b(this,void 0,void 0,function*(){const c=typeof t=="string"?toUtf8Bytes(t):t,ie=yield this.getAddress();try{return yield this.provider.send("eth_sign",[ie.toLowerCase(),hexlify(c)])}catch(se){throw typeof se.message=="string"&&se.message.match(/user denied/i)&&logger$3.throwError("user rejected signing",Logger.errors.ACTION_REJECTED,{action:"_legacySignMessage",from:ie,messageData:t}),se}})}_signTypedData(t,c,ie){return __awaiter$b(this,void 0,void 0,function*(){const se=yield TypedDataEncoder.resolveNames(t,c,ie,ue=>this.provider.resolveName(ue)),ae=yield this.getAddress();try{return yield this.provider.send("eth_signTypedData_v4",[ae.toLowerCase(),JSON.stringify(TypedDataEncoder.getPayload(se.domain,c,se.value))])}catch(ue){throw typeof ue.message=="string"&&ue.message.match(/user denied/i)&&logger$3.throwError("user rejected signing",Logger.errors.ACTION_REJECTED,{action:"_signTypedData",from:ae,messageData:{domain:se.domain,types:c,value:se.value}}),ue}})}unlock(t){return __awaiter$b(this,void 0,void 0,function*(){const c=this.provider,ie=yield this.getAddress();return c.send("personal_unlockAccount",[ie.toLowerCase(),t,null])})}}class UncheckedJsonRpcSigner extends JsonRpcSigner{sendTransaction(t){return this.sendUncheckedTransaction(t).then(c=>({hash:c,nonce:null,gasLimit:null,gasPrice:null,data:null,value:null,chainId:null,confirmations:0,from:null,wait:ie=>this.provider.waitForTransaction(c,ie)}))}}const allowedTransactionKeys={chainId:!0,data:!0,gasLimit:!0,gasPrice:!0,nonce:!0,to:!0,value:!0,type:!0,accessList:!0,maxFeePerGas:!0,maxPriorityFeePerGas:!0};class JsonRpcProvider extends BaseProvider{constructor(t,c){let ie=c;ie==null&&(ie=new Promise((se,ae)=>{setTimeout(()=>{this.detectNetwork().then(ue=>{se(ue)},ue=>{ae(ue)})},0)})),super(ie),t||(t=getStatic(this.constructor,"defaultUrl")()),typeof t=="string"?defineReadOnly(this,"connection",Object.freeze({url:t})):defineReadOnly(this,"connection",Object.freeze(shallowCopy(t))),this._nextId=42}get _cache(){return this._eventLoopCache==null&&(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 __awaiter$b(this,void 0,void 0,function*(){yield timer(0);let t=null;try{t=yield this.send("eth_chainId",[])}catch{try{t=yield this.send("net_version",[])}catch{}}if(t!=null){const c=getStatic(this.constructor,"getNetwork");try{return c(BigNumber.from(t).toNumber())}catch(ie){return logger$3.throwError("could not detect network",Logger.errors.NETWORK_ERROR,{chainId:t,event:"invalidNetwork",serverError:ie})}}return logger$3.throwError("could not detect network",Logger.errors.NETWORK_ERROR,{event:"noNetwork"})})}getSigner(t){return new JsonRpcSigner(_constructorGuard,this,t)}getUncheckedSigner(t){return this.getSigner(t).connectUnchecked()}listAccounts(){return this.send("eth_accounts",[]).then(t=>t.map(c=>this.formatter.address(c)))}send(t,c){const ie={method:t,params:c,id:this._nextId++,jsonrpc:"2.0"};this.emit("debug",{action:"request",request:deepCopy(ie),provider:this});const se=["eth_chainId","eth_blockNumber"].indexOf(t)>=0;if(se&&this._cache[t])return this._cache[t];const ae=fetchJson(this.connection,JSON.stringify(ie),getResult).then(ue=>(this.emit("debug",{action:"response",request:ie,response:ue,provider:this}),ue),ue=>{throw this.emit("debug",{action:"response",error:ue,request:ie,provider:this}),ue});return se&&(this._cache[t]=ae,setTimeout(()=>{this._cache[t]=null},0)),ae}prepareRequest(t,c){switch(t){case"getBlockNumber":return["eth_blockNumber",[]];case"getGasPrice":return["eth_gasPrice",[]];case"getBalance":return["eth_getBalance",[getLowerCase(c.address),c.blockTag]];case"getTransactionCount":return["eth_getTransactionCount",[getLowerCase(c.address),c.blockTag]];case"getCode":return["eth_getCode",[getLowerCase(c.address),c.blockTag]];case"getStorageAt":return["eth_getStorageAt",[getLowerCase(c.address),hexZeroPad(c.position,32),c.blockTag]];case"sendTransaction":return["eth_sendRawTransaction",[c.signedTransaction]];case"getBlock":return c.blockTag?["eth_getBlockByNumber",[c.blockTag,!!c.includeTransactions]]:c.blockHash?["eth_getBlockByHash",[c.blockHash,!!c.includeTransactions]]:null;case"getTransaction":return["eth_getTransactionByHash",[c.transactionHash]];case"getTransactionReceipt":return["eth_getTransactionReceipt",[c.transactionHash]];case"call":return["eth_call",[getStatic(this.constructor,"hexlifyTransaction")(c.transaction,{from:!0}),c.blockTag]];case"estimateGas":return["eth_estimateGas",[getStatic(this.constructor,"hexlifyTransaction")(c.transaction,{from:!0})]];case"getLogs":return c.filter&&c.filter.address!=null&&(c.filter.address=getLowerCase(c.filter.address)),["eth_getLogs",[c.filter]]}return null}perform(t,c){return __awaiter$b(this,void 0,void 0,function*(){if(t==="call"||t==="estimateGas"){const se=c.transaction;if(se&&se.type!=null&&BigNumber.from(se.type).isZero()&&se.maxFeePerGas==null&&se.maxPriorityFeePerGas==null){const ae=yield this.getFeeData();ae.maxFeePerGas==null&&ae.maxPriorityFeePerGas==null&&(c=shallowCopy(c),c.transaction=shallowCopy(se),delete c.transaction.type)}}const ie=this.prepareRequest(t,c);ie==null&&logger$3.throwError(t+" not implemented",Logger.errors.NOT_IMPLEMENTED,{operation:t});try{return yield this.send(ie[0],ie[1])}catch(se){return checkError(t,se,c)}})}_startEvent(t){t.tag==="pending"&&this._startPending(),super._startEvent(t)}_startPending(){if(this._pendingFilter!=null)return;const t=this,c=this.send("eth_newPendingTransactionFilter",[]);this._pendingFilter=c,c.then(function(ie){function se(){t.send("eth_getFilterChanges",[ie]).then(function(ae){if(t._pendingFilter!=c)return null;let ue=Promise.resolve();return ae.forEach(function(de){t._emitted["t:"+de.toLowerCase()]="pending",ue=ue.then(function(){return t.getTransaction(de).then(function(ve){return t.emit("pending",ve),null})})}),ue.then(function(){return timer(1e3)})}).then(function(){if(t._pendingFilter!=c){t.send("eth_uninstallFilter",[ie]);return}return setTimeout(function(){se()},0),null}).catch(ae=>{})}return se(),ie}).catch(ie=>{})}_stopEvent(t){t.tag==="pending"&&this.listenerCount("pending")===0&&(this._pendingFilter=null),super._stopEvent(t)}static hexlifyTransaction(t,c){const ie=shallowCopy(allowedTransactionKeys);if(c)for(const ae in c)c[ae]&&(ie[ae]=!0);checkProperties(t,ie);const se={};return["chainId","gasLimit","gasPrice","type","maxFeePerGas","maxPriorityFeePerGas","nonce","value"].forEach(function(ae){if(t[ae]==null)return;const ue=hexValue(BigNumber.from(t[ae]));ae==="gasLimit"&&(ae="gas"),se[ae]=ue}),["from","to","data"].forEach(function(ae){t[ae]!=null&&(se[ae]=hexlify(t[ae]))}),t.accessList&&(se.accessList=accessListify(t.accessList)),se}}const logger$2=new Logger(version$8);let _nextId=1;function buildWeb3LegacyFetcher(n,t){const c="Web3LegacyFetcher";return function(ie,se){const ae={method:ie,params:se,id:_nextId++,jsonrpc:"2.0"};return new Promise((ue,de)=>{this.emit("debug",{action:"request",fetcher:c,request:deepCopy(ae),provider:this}),t(ae,(ve,ge)=>{if(ve)return this.emit("debug",{action:"response",fetcher:c,error:ve,request:ae,provider:this}),de(ve);if(this.emit("debug",{action:"response",fetcher:c,request:ae,response:ge,provider:this}),ge.error){const we=new Error(ge.error.message);return we.code=ge.error.code,we.data=ge.error.data,de(we)}ue(ge.result)})})}}function buildEip1193Fetcher(n){return function(t,c){c==null&&(c=[]);const ie={method:t,params:c};return this.emit("debug",{action:"request",fetcher:"Eip1193Fetcher",request:deepCopy(ie),provider:this}),n.request(ie).then(se=>(this.emit("debug",{action:"response",fetcher:"Eip1193Fetcher",request:ie,response:se,provider:this}),se),se=>{throw this.emit("debug",{action:"response",fetcher:"Eip1193Fetcher",request:ie,error:se,provider:this}),se})}}class Web3Provider extends JsonRpcProvider{constructor(t,c){t==null&&logger$2.throwArgumentError("missing provider","provider",t);let ie=null,se=null,ae=null;typeof t=="function"?(ie="unknown:",se=t):(ie=t.host||t.path||"",!ie&&t.isMetaMask&&(ie="metamask"),ae=t,t.request?(ie===""&&(ie="eip-1193:"),se=buildEip1193Fetcher(t)):t.sendAsync?se=buildWeb3LegacyFetcher(t,t.sendAsync.bind(t)):t.send?se=buildWeb3LegacyFetcher(t,t.send.bind(t)):logger$2.throwArgumentError("unsupported provider","provider",t),ie||(ie="unknown:")),super(ie,c),defineReadOnly(this,"jsonRpcFetchFunc",se),defineReadOnly(this,"provider",ae)}send(t,c){return this.jsonRpcFetchFunc(t,c)}}const version$7="solidity/5.8.0",regexBytes=new RegExp("^bytes([0-9]+)$"),regexNumber=new RegExp("^(u?int)([0-9]*)$"),regexArray=new RegExp("^(.*)\\[([0-9]*)\\]$"),Zeros="0000000000000000000000000000000000000000000000000000000000000000",logger$1$1=new Logger(version$7);function _pack(n,t,c){switch(n){case"address":return c?zeroPad(t,32):arrayify(t);case"string":return toUtf8Bytes(t);case"bytes":return arrayify(t);case"bool":return t=t?"0x01":"0x00",c?zeroPad(t,32):arrayify(t)}let ie=n.match(regexNumber);if(ie){let se=parseInt(ie[2]||"256");return(ie[2]&&String(se)!==ie[2]||se%8!==0||se===0||se>256)&&logger$1$1.throwArgumentError("invalid number type","type",n),c&&(se=256),t=BigNumber.from(t).toTwos(se),zeroPad(t,se/8)}if(ie=n.match(regexBytes),ie){const se=parseInt(ie[1]);return(String(se)!==ie[1]||se===0||se>32)&&logger$1$1.throwArgumentError("invalid bytes type","type",n),arrayify(t).byteLength!==se&&logger$1$1.throwArgumentError(`invalid value for ${n}`,"value",t),c?arrayify((t+Zeros).substring(0,66)):t}if(ie=n.match(regexArray),ie&&Array.isArray(t)){const se=ie[1];parseInt(ie[2]||String(t.length))!=t.length&&logger$1$1.throwArgumentError(`invalid array length for ${n}`,"value",t);const ae=[];return t.forEach(function(ue){ae.push(_pack(se,ue,!0))}),concat$1(ae)}return logger$1$1.throwArgumentError("invalid type","type",n)}function pack(n,t){n.length!=t.length&&logger$1$1.throwArgumentError("wrong number of values; expected ${ types.length }","values",t);const c=[];return n.forEach(function(ie,se){c.push(_pack(ie,t[se]))}),hexlify(concat$1(c))}function keccak256(n,t){return keccak256$1(pack(n,t))}function sha256$6(n,t){return sha256$7(pack(n,t))}const lib_esm$1=Object.freeze(Object.defineProperty({__proto__:null,keccak256,pack,sha256:sha256$6},Symbol.toStringTag,{value:"Module"})),version$6="units/5.8.0",logger$y=new Logger(version$6),names$2=["wei","kwei","mwei","gwei","szabo","finney","ether"];function commify(n){const t=String(n).split(".");(t.length>2||!t[0].match(/^-?[0-9]*$/)||t[1]&&!t[1].match(/^[0-9]*$/)||n==="."||n==="-.")&&logger$y.throwArgumentError("invalid value","value",n);let c=t[0],ie="";for(c.substring(0,1)==="-"&&(ie="-",c=c.substring(1));c.substring(0,1)==="0";)c=c.substring(1);c===""&&(c="0");let se="";for(t.length===2&&(se="."+(t[1]||"0"));se.length>2&&se[se.length-1]==="0";)se=se.substring(0,se.length-1);const ae=[];for(;c.length;)if(c.length<=3){ae.unshift(c);break}else{const ue=c.length-3;ae.unshift(c.substring(ue)),c=c.substring(0,ue)}return ie+ae.join(",")+se}function formatUnits(n,t){if(typeof t=="string"){const c=names$2.indexOf(t);c!==-1&&(t=3*c)}return formatFixed(n,t??18)}function parseUnits(n,t){if(typeof n!="string"&&logger$y.throwArgumentError("value must be a string","value",n),typeof t=="string"){const c=names$2.indexOf(t);c!==-1&&(t=3*c)}return parseFixed(n,t??18)}function formatEther(n){return formatUnits(n,18)}function parseEther(n){return parseUnits(n,18)}const lib_esm=Object.freeze(Object.defineProperty({__proto__:null,commify,formatEther,formatUnits,parseEther,parseUnits},Symbol.toStringTag,{value:"Module"}));var NFTType=(n=>(n[n.ERC1155=0]="ERC1155",n[n.ERC721=1]="ERC721",n))(NFTType||{}),ProductType=(n=>(n[n.DIGITAL=0]="DIGITAL",n[n.POD=1]="POD",n[n.PHYSICAL=2]="PHYSICAL",n))(ProductType||{});class HTTPError extends Error{constructor(t,c,ie){const se=t.status||t.status===0?t.status:"",ae=t.statusText??"",ue=`${se} ${ae}`.trim(),de=ue?`status code ${ue}`:"an unknown error";super(`Request failed with ${de}: ${c.method} ${c.url}`),Xn(this,"response"),Xn(this,"request"),Xn(this,"options"),this.name="HTTPError",this.response=t,this.request=c,this.options=ie}}class TimeoutError extends Error{constructor(t){super(`Request timed out: ${t.method} ${t.url}`),Xn(this,"request"),this.name="TimeoutError",this.request=t}}const supportsRequestStreams=(()=>{let n=!1,t=!1;const c=typeof globalThis.ReadableStream=="function",ie=typeof globalThis.Request=="function";if(c&&ie)try{t=new globalThis.Request("https://empty.invalid",{body:new globalThis.ReadableStream,method:"POST",get duplex(){return n=!0,"half"}}).headers.has("Content-Type")}catch(se){if(se instanceof Error&&se.message==="unsupported BodyInit type")return!1;throw se}return n&&!t})(),supportsAbortController=typeof globalThis.AbortController=="function",supportsAbortSignal=typeof globalThis.AbortSignal=="function"&&typeof globalThis.AbortSignal.any=="function",supportsResponseStreams=typeof globalThis.ReadableStream=="function",supportsFormData=typeof globalThis.FormData=="function",requestMethods=["get","post","put","patch","head","delete"],responseTypes={json:"application/json",text:"text/*",formData:"multipart/form-data",arrayBuffer:"*/*",blob:"*/*",bytes:"*/*"},maxSafeTimeout=2147483647,usualFormBoundarySize=new TextEncoder().encode("------WebKitFormBoundaryaxpyiPgbbPti10Rw").length,stop$1=Symbol("stop"),kyOptionKeys={json:!0,parseJson:!0,stringifyJson:!0,searchParams:!0,prefixUrl:!0,retry:!0,timeout:!0,hooks:!0,throwHttpErrors:!0,onDownloadProgress:!0,onUploadProgress:!0,fetch:!0},requestOptionsRegistry={method:!0,headers:!0,body:!0,mode:!0,credentials:!0,cache:!0,redirect:!0,referrer:!0,referrerPolicy:!0,integrity:!0,keepalive:!0,signal:!0,window:!0,dispatcher:!0,duplex:!0,priority:!0},getBodySize=n=>{if(!n)return 0;if(n instanceof FormData){let t=0;for(const[c,ie]of n)t+=usualFormBoundarySize,t+=new TextEncoder().encode(`Content-Disposition: form-data; name="${c}"`).length,t+=typeof ie=="string"?new TextEncoder().encode(ie).length:ie.size;return t}if(n instanceof Blob)return n.size;if(n instanceof ArrayBuffer)return n.byteLength;if(typeof n=="string")return new TextEncoder().encode(n).length;if(n instanceof URLSearchParams)return new TextEncoder().encode(n.toString()).length;if("byteLength"in n)return n.byteLength;if(typeof n=="object"&&n!==null)try{const t=JSON.stringify(n);return new TextEncoder().encode(t).length}catch{return 0}return 0},withProgress=(n,t,c)=>{let ie,se=0;return n.pipeThrough(new TransformStream({transform(ae,ue){if(ue.enqueue(ae),ie){se+=ie.byteLength;let de=t===0?0:se/t;de>=1&&(de=1-Number.EPSILON),c?.({percent:de,totalBytes:Math.max(t,se),transferredBytes:se},ie)}ie=ae},flush(){ie&&(se+=ie.byteLength,c?.({percent:1,totalBytes:Math.max(t,se),transferredBytes:se},ie))}}))},streamResponse=(n,t)=>{if(!n.body)return n;if(n.status===204)return new Response(null,{status:n.status,statusText:n.statusText,headers:n.headers});const c=Number(n.headers.get("content-length"))||0;return new Response(withProgress(n.body,c,t),{status:n.status,statusText:n.statusText,headers:n.headers})},streamRequest=(n,t,c)=>{if(!n.body)return n;const ie=getBodySize(c??n.body);return new Request(n,{duplex:"half",body:withProgress(n.body,ie,t)})},isObject$2$1=n=>n!==null&&typeof n=="object",validateAndMerge=(...n)=>{for(const t of n)if((!isObject$2$1(t)||Array.isArray(t))&&t!==void 0)throw new TypeError("The `options` argument must be an object");return deepMerge({},...n)},mergeHeaders=(n={},t={})=>{const c=new globalThis.Headers(n),ie=t instanceof globalThis.Headers,se=new globalThis.Headers(t);for(const[ae,ue]of se.entries())ie&&ue==="undefined"||ue===void 0?c.delete(ae):c.set(ae,ue);return c};function newHookValue(n,t,c){return Object.hasOwn(t,c)&&t[c]===void 0?[]:deepMerge(n[c]??[],t[c]??[])}const mergeHooks=(n={},t={})=>({beforeRequest:newHookValue(n,t,"beforeRequest"),beforeRetry:newHookValue(n,t,"beforeRetry"),afterResponse:newHookValue(n,t,"afterResponse"),beforeError:newHookValue(n,t,"beforeError")}),deepMerge=(...n)=>{let t={},c={},ie={};for(const se of n)if(Array.isArray(se))Array.isArray(t)||(t=[]),t=[...t,...se];else if(isObject$2$1(se)){for(let[ae,ue]of Object.entries(se))isObject$2$1(ue)&&ae in t&&(ue=deepMerge(t[ae],ue)),t={...t,[ae]:ue};isObject$2$1(se.hooks)&&(ie=mergeHooks(ie,se.hooks),t.hooks=ie),isObject$2$1(se.headers)&&(c=mergeHeaders(c,se.headers),t.headers=c)}return t},normalizeRequestMethod=n=>requestMethods.includes(n)?n.toUpperCase():n,retryMethods=["get","put","head","delete","options","trace"],retryStatusCodes=[408,413,429,500,502,503,504],retryAfterStatusCodes=[413,429,503],defaultRetryOptions={limit:2,methods:retryMethods,statusCodes:retryStatusCodes,afterStatusCodes:retryAfterStatusCodes,maxRetryAfter:Number.POSITIVE_INFINITY,backoffLimit:Number.POSITIVE_INFINITY,delay:n=>.3*2**(n-1)*1e3},normalizeRetryOptions=(n={})=>{if(typeof n=="number")return{...defaultRetryOptions,limit:n};if(n.methods&&!Array.isArray(n.methods))throw new Error("retry.methods must be an array");if(n.statusCodes&&!Array.isArray(n.statusCodes))throw new Error("retry.statusCodes must be an array");return{...defaultRetryOptions,...n}};async function timeout(n,t,c,ie){return new Promise((se,ae)=>{const ue=setTimeout(()=>{c&&c.abort(),ae(new TimeoutError(n))},ie.timeout);ie.fetch(n,t).then(se).catch(ae).then(()=>{clearTimeout(ue)})})}async function delay$1(n,{signal:t}){return new Promise((c,ie)=>{t&&(t.throwIfAborted(),t.addEventListener("abort",se,{once:!0}));function se(){clearTimeout(ae),ie(t.reason)}const ae=setTimeout(()=>{t?.removeEventListener("abort",se),c()},n)})}const findUnknownOptions=(n,t)=>{const c={};for(const ie in t)!(ie in requestOptionsRegistry)&&!(ie in kyOptionKeys)&&!(ie in n)&&(c[ie]=t[ie]);return c},hasSearchParameters=n=>n===void 0?!1:Array.isArray(n)?n.length>0:n instanceof URLSearchParams?n.size>0:typeof n=="object"?Object.keys(n).length>0:typeof n=="string"?n.trim().length>0:!!n;var ei,oi;const Yn=class oo{constructor(t,c={}){Xn(this,"request"),Xn(this,"abortController"),Xn(this,"_retryCount",0),Xn(this,"_input"),Xn(this,"_options"),Xn(this,"_originalRequest");var ie,se,ae;if(this._input=t,this._options={...c,headers:mergeHeaders(this._input.headers,c.headers),hooks:mergeHooks({beforeRequest:[],beforeRetry:[],beforeError:[],afterResponse:[]},c.hooks),method:normalizeRequestMethod(c.method??this._input.method??"GET"),prefixUrl:String(c.prefixUrl||""),retry:normalizeRetryOptions(c.retry),throwHttpErrors:c.throwHttpErrors!==!1,timeout:c.timeout??1e4,fetch:c.fetch??globalThis.fetch.bind(globalThis)},typeof this._input!="string"&&!(this._input instanceof URL||this._input instanceof globalThis.Request))throw new TypeError("`input` must be a string, URL, or Request");if(this._options.prefixUrl&&typeof this._input=="string"){if(this._input.startsWith("/"))throw new Error("`input` must not begin with a slash when using `prefixUrl`");this._options.prefixUrl.endsWith("/")||(this._options.prefixUrl+="/"),this._input=this._options.prefixUrl+this._input}if(supportsAbortController&&supportsAbortSignal){const ue=this._options.signal??this._input.signal;this.abortController=new globalThis.AbortController,this._options.signal=ue?AbortSignal.any([ue,this.abortController.signal]):this.abortController.signal}if(supportsRequestStreams&&(this._options.duplex="half"),this._options.json!==void 0&&(this._options.body=((se=(ie=this._options).stringifyJson)==null?void 0:se.call(ie,this._options.json))??JSON.stringify(this._options.json),this._options.headers.set("content-type",this._options.headers.get("content-type")??"application/json")),this.request=new globalThis.Request(this._input,this._options),hasSearchParameters(this._options.searchParams)){const ue="?"+(typeof this._options.searchParams=="string"?this._options.searchParams.replace(/^\?/,""):new URLSearchParams(ai(ae=oo,ei,oi).call(ae,this._options.searchParams)).toString()),de=this.request.url.replace(/(?:\?.*?)?(?=#|$)/,ue);(supportsFormData&&this._options.body instanceof globalThis.FormData||this._options.body instanceof URLSearchParams)&&!(this._options.headers&&this._options.headers["content-type"])&&this.request.headers.delete("content-type"),this.request=new globalThis.Request(new globalThis.Request(de,{...this.request}),this._options)}if(this._options.onUploadProgress){if(typeof this._options.onUploadProgress!="function")throw new TypeError("The `onUploadProgress` option must be a function");if(!supportsRequestStreams)throw new Error("Request streams are not supported in your environment. The `duplex` option for `Request` is not available.");this.request.body&&(this.request=streamRequest(this.request,this._options.onUploadProgress,this._options.body))}}static create(t,c){var ie,se;const ae=new oo(t,c),ue=async()=>{if(typeof ae._options.timeout=="number"&&ae._options.timeout>maxSafeTimeout)throw new RangeError(`The \`timeout\` option cannot be greater than ${maxSafeTimeout}`);await Promise.resolve();let ve=await ae._fetch();for(const ge of ae._options.hooks.afterResponse){const we=await ge(ae.request,ae._options,ae._decorateResponse(ve.clone()));we instanceof globalThis.Response&&(ve=we)}if(ae._decorateResponse(ve),!ve.ok&&ae._options.throwHttpErrors){let ge=new HTTPError(ve,ae.request,ae._options);for(const we of ae._options.hooks.beforeError)ge=await we(ge);throw ge}if(ae._options.onDownloadProgress){if(typeof ae._options.onDownloadProgress!="function")throw new TypeError("The `onDownloadProgress` option must be a function");if(!supportsResponseStreams)throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");return streamResponse(ve.clone(),ae._options.onDownloadProgress)}return ve},de=(ae._options.retry.methods.includes(ae.request.method.toLowerCase())?ae._retry(ue):ue()).finally(async()=>{var ve,ge;const we=ae._originalRequest,Te=[];we&&!we.bodyUsed&&Te.push((ve=we.body)==null?void 0:ve.cancel()),ae.request.bodyUsed||Te.push((ge=ae.request.body)==null?void 0:ge.cancel()),await Promise.all(Te)});for(const[ve,ge]of Object.entries(responseTypes))ve==="bytes"&&typeof((se=(ie=globalThis.Response)==null?void 0:ie.prototype)==null?void 0:se.bytes)!="function"||(de[ve]=async()=>{ae.request.headers.set("accept",ae.request.headers.get("accept")||ge);const we=await de;if(ve==="json"){if(we.status===204)return"";const Te=await we.text();return Te===""?"":c.parseJson?c.parseJson(Te):JSON.parse(Te)}return we[ve]()});return de}_calculateRetryDelay(t){if(this._retryCount++,this._retryCount>this._options.retry.limit||t instanceof TimeoutError)throw t;if(t instanceof HTTPError){if(!this._options.retry.statusCodes.includes(t.response.status))throw t;const ie=t.response.headers.get("Retry-After")??t.response.headers.get("RateLimit-Reset")??t.response.headers.get("X-RateLimit-Reset")??t.response.headers.get("X-Rate-Limit-Reset");if(ie&&this._options.retry.afterStatusCodes.includes(t.response.status)){let se=Number(ie)*1e3;Number.isNaN(se)?se=Date.parse(ie)-Date.now():se>=Date.parse("2024-01-01")&&(se-=Date.now());const ae=this._options.retry.maxRetryAfter??se;return se<ae?se:ae}if(t.response.status===413)throw t}const c=this._options.retry.delay(this._retryCount);return Math.min(this._options.retry.backoffLimit,c)}_decorateResponse(t){return this._options.parseJson&&(t.json=async()=>this._options.parseJson(await t.text())),t}async _retry(t){try{return await t()}catch(c){const ie=Math.min(this._calculateRetryDelay(c),maxSafeTimeout);if(this._retryCount<1)throw c;await delay$1(ie,{signal:this._options.signal});for(const se of this._options.hooks.beforeRetry)if(await se({request:this.request,options:this._options,error:c,retryCount:this._retryCount})===stop$1)return;return this._retry(t)}}async _fetch(){for(const c of this._options.hooks.beforeRequest){const ie=await c(this.request,this._options);if(ie instanceof Request){this.request=ie;break}if(ie instanceof Response)return ie}const t=findUnknownOptions(this.request,this._options);return this._originalRequest=this.request,this.request=this._originalRequest.clone(),this._options.timeout===!1?this._options.fetch(this._originalRequest,t):timeout(this._originalRequest,t,this.abortController,this._options)}};ei=new WeakSet,oi=function(n){return n&&typeof n=="object"&&!Array.isArray(n)&&!(n instanceof URLSearchParams)?Object.fromEntries(Object.entries(n).filter(([,t])=>t!==void 0)):n},ii(Yn,ei);let Ky=Yn;const createInstance$1=n=>{const t=(c,ie)=>Ky.create(c,validateAndMerge(n,ie));for(const c of requestMethods)t[c]=(ie,se)=>Ky.create(ie,validateAndMerge(n,se,{method:c}));return t.create=c=>createInstance$1(validateAndMerge(c)),t.extend=c=>(typeof c=="function"&&(c=c(n??{})),createInstance$1(validateAndMerge(n,c))),t.stop=stop$1,t},ky=createInstance$1();async function uploadMetadata(n,t,c){return(await(await c.post("uploader/cdn-upload-json",{json:{data:n,key:`record-metadata/${t}.json`}})).json()).url}async function startRecord(n,t,c,ie,se,ae){return(await(await ae.post("web3/record/transactions",{json:{uris:se,network:ie,data:{productId:n,skuIds:t},productId:n,skuIds:t,metadata:{},shopId:c,txType:"RECORD"}})).json()).data.id}async function getShopInfo(n,t,c){const ie=(await(await c.get(`shops/v2/public/${t}`)).json()).data.deployedContracts.filter(se=>se.type===n);return ie.length===0?{nftContractAddress:"",shopContractAddress:""}:{nftContractAddress:ie[0].deployedNFTAddress,shopContractAddress:ie[0].deployedShopAddress}}async function deleteRecordTransaction(n,t){await t.delete(`web3/record/transactions/${n}`)}async function web3Callback(n,t,c,ie){const se={"X-API-KEY":"ho8homr9e8p4fwii7tjiz41xs4hlbl2h4i"};return(await(await ky.create({headers:se,prefixUrl:c==="TESTNET"?"https://web3dev.droplinked.com/":"https://web3.droplinked.com/"}).post("transactions",{json:{transaction_id:n,callback_url:ie,chain:t,network:c},headers:se})).json()).data}async function getProductData(n,t){return(await(await t.get(`product-v2/public/${n}`)).json()).data}async function transformProductData(n,t){const c=await getProductData(n,t);if(!c||c.skus.length===0)throw new Error("Product not found or no SKUs available");return{productData:{acceptsManageWallet:!0,commission:c.affiliate.commissionPercent||0,description:c.description,productTitle:c.title,royalty:c.skus[0].royalty||0,type:ProductType[c.type.toUpperCase()]||ProductType.DIGITAL},skuData:c.skus.map(ie=>{var se;return{amount:ie.inventory.quantity,imageUrl:((se=c.images[c.defaultImageIndex])==null?void 0:se.original)||"",skuID:ie.id,skuProperties:ie}})}}async function updateUris(n,t,c){return(await(await c.put(`web3/record/transactions/${n}/uris`,{json:{uris:t}})).json()).data}async function updateHash(n,t,c,ie){return(await(await ie.put(`web3/${n}/transactions/${t}/hash`,{json:{transactionHash:c}})).json()).data}async function getProductDataForRecord(n,t){if(!n)throw new InvalidParametersException(Chains.BASE,"Product ID is required");let c,ie=[];try{const{productData:se,skuData:ae}=await transformProductData(n,t);c=se,ie=ae}catch(se){throw new Error(`Failed to fetch product data: ${se}`)}if(!c||ie.length===0)throw new Error("Product not found or no SKUs available");return{productData:c,skuData:ie}}async function getNonce(n,t){return await(await t.get(`web3/auth/nonce?wallet=${n}`)).json()}async function getAddress(n,t,c){const ie=se=>se.charAt(0).toUpperCase()+se.slice(1).toLowerCase();try{const se=t===Network.TESTNET?"apiv3dev":"apiv3",ae=ie(n),ue=ie(Network[t]),de=`https://${se}.droplinked.com/storage/${ae}${ue}ContractAddress${c}`;return(await await ky.get(de).json()).value}catch(se){throw console.error(`Failed to fetch ${c.toLowerCase()} address:`,se),new Error(`Unable to get ${c.toLowerCase()} address`)}}async function getDeployerAddress(n,t){return getAddress(n,t,"Deployer")}async function getProxyAddress(n,t){return getAddress(n,t,"Proxy")}async function startPayment(n,t,c,ie,se){return(await(await se.post("web3/payment/transactions",{json:{network:c,token:t,shopId:ie,orderId:n}})).json()).data.id}async function getCartData(n,t,c,ie){const se=await(await ie.get(`web3/payment/distribution/${n}/${t}/${c}`)).json();return{paymentData:se.data,orderID:se.orderID}}async function getPurchaseSignature(n,t,c){const ie=await(await c.get(`/nfts/by-order?orderId=${n}&skuId=${t}`)).json();return{signature:ie.purchaseSignature,shopContractAddress:ie.shopContractAddress,networkName:ie.networkName}}async function getShopByteCode(){try{return String((await await ky.get("https://apiv3dev.droplinked.com/storage/shopByteCodeType0").json()).value)}catch(n){throw console.error(`Failed to get shop bytecode: ${n}`),new Error("Unable to get shop bytecode")}}async function getShopDeployInfo(n,t){const c=(await(await t.get(`shops/v2/public/${n}`)).json()).data;return{name:c.name,description:c.description,logo:c.logo,url:c.url,deployedContracts:c.deployedContracts}}const shopABI=[{inputs:[{internalType:"string",name:"_shopName",type:"string"},{internalType:"string",name:"_shopAddress",type:"string"},{internalType:"address",name:"_shopOwner",type:"address"},{internalType:"string",name:"_shopLogo",type:"string"},{internalType:"string",name:"_shopDescription",type:"string"}],stateMutability:"nonpayable",type:"constructor"},{inputs:[],name:"AccessDenied",type:"error"},{inputs:[],name:"AffiliatePOD",type:"error"},{inputs:[],name:"AlreadyClaimed",type:"error"},{inputs:[{internalType:"address",name:"requester",type:"address"},{internalType:"uint256",name:"productId",type:"uint256"}],name:"AlreadyRequested",type:"error"},{inputs:[{internalType:"uint256",name:"tokenId",type:"uint256"},{internalType:"address",name:"producer",type:"address"}],name:"NotEnoughTokens",type:"error"},{inputs:[{internalType:"address",name:"owner",type:"address"}],name:"OwnableInvalidOwner",type:"error"},{inputs:[{internalType:"address",name:"account",type:"address"}],name:"OwnableUnauthorizedAccount",type:"error"},{inputs:[{internalType:"uint256",name:"productId",type:"uint256"}],name:"ProductDoesntExist",type:"error"},{inputs:[{internalType:"uint256",name:"productId",type:"uint256"}],name:"ProductExists",type:"error"},{inputs:[],name:"ReentrancyGuardReentrantCall",type:"error"},{inputs:[{internalType:"uint256",name:"requestId",type:"uint256"}],name:"RequestAlreadyConfirmed",type:"error"},{inputs:[{internalType:"uint256",name:"requestId",type:"uint256"}],name:"RequestDoesntExist",type:"error"},{inputs:[{internalType:"uint256",name:"requestId",type:"uint256"}],name:"RequestNotConfirmed",type:"error"},{inputs:[{internalType:"uint256",name:"tokenId",type:"uint256"},{internalType:"address",name:"nftAddress",type:"address"}],name:"ShopDoesNotOwnToken",type:"error"},{inputs:[],name:"oldPrice",type:"error"},{anonymous:!1,inputs:[{indexed:!0,internalType:"uint256",name:"requestId",type:"uint256"},{indexed:!0,internalType:"address",name:"approver",type:"address"}],name:"AffiliateRequestApproved",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"uint256",name:"requestId",type:"uint256"},{indexed:!0,internalType:"address",name:"disapprover",type:"address"}],name:"AffiliateRequestDisapproved",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"uint256",name:"requestId",type:"uint256"},{indexed:!0,internalType:"uint256",name:"productId",type:"uint256"},{indexed:!1,internalType:"address",name:"requester",type:"address"}],name:"AffiliateRequested",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"uint256",name:"count",type:"uint256"}],name:"BatchProductRegistered",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"previousOwner",type:"address"},{indexed:!0,internalType:"address",name:"newOwner",type:"address"}],name:"OwnershipTransferred",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"uint256",name:"productId",type:"uint256"},{indexed:!0,internalType:"address",name:"claimer",type:"address"},{indexed:!1,internalType:"uint256",name:"amount",type:"uint256"}],name:"ProductClaimed",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"uint256",name:"productId",type:"uint256"},{indexed:!1,internalType:"uint256",name:"amount",type:"uint256"},{indexed:!0,internalType:"address",name:"owner",type:"address"},{indexed:!1,internalType:"string",name:"uri",type:"string"}],name:"ProductRegistered",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"uint256",name:"productId",type:"uint256"},{indexed:!0,internalType:"address",name:"owner",type:"address"}],name:"ProductUnregistered",type:"event"},{inputs:[],name:"affiliateRequestCount",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"requestId",type:"uint256"}],name:"affiliateRequests",outputs:[{internalType:"address",name:"publisher",type:"address"},{internalType:"uint256",name:"productId",type:"uint256"},{internalType:"bool",name:"isConfirmed",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"requestId",type:"uint256"}],name:"approveRequest",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"manager",type:"address"},{internalType:"bytes",name:"signature",type:"bytes"},{components:[{components:[{internalType:"uint256",name:"amount",type:"uint256"},{internalType:"uint256",name:"productId",type:"uint256"},{internalType:"uint256",name:"nullifier",type:"uint256"}],internalType:"struct PurchasedItem[]",name:"cart",type:"tuple[]"},{internalType:"address",name:"shop",type:"address"}],internalType:"struct PurchaseSignature",name:"purchaseSignature",type:"tuple"}],name:"claimPurchase",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"requestId",type:"uint256"}],name:"disapproveRequest",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"droplinkedManagerWallet",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"requestId",type:"uint256"}],name:"getAffiliate",outputs:[{components:[{internalType:"address",name:"publisher",type:"address"},{internalType:"uint256",name:"productId",type:"uint256"},{internalType:"bool",name:"isConfirmed",type:"bool"}],internalType:"struct AffiliateRequest",name:"",type:"tuple"}],stateMutability:"view",type:"function"},{inputs:[],name:"getAffiliateRequestCount",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bytes32",name:"messageHash",type:"bytes32"}],name:"getEthSignedMessageHash",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],stateMutability:"pure",type:"function"},{inputs:[{components:[{components:[{internalType:"uint256",name:"amount",type:"uint256"},{internalType:"uint256",name:"productId",type:"uint256"},{internalType:"uint256",name:"nullifier",type:"uint256"}],internalType:"struct PurchasedItem[]",name:"cart",type:"tuple[]"},{internalType:"address",name:"shop",type:"address"}],internalType:"struct PurchaseSignature",name:"data",type:"tuple"}],name:"getMessageHash",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],stateMutability:"pure",type:"function"},{inputs:[{internalType:"uint256",name:"productId",type:"uint256"}],name:"getProduct",outputs:[{components:[{internalType:"uint256",name:"tokenId",type:"uint256"},{internalType:"address",name:"nftAddress",type:"address"},{internalType:"enum NFTType",name:"nftType",type:"uint8"},{internalType:"enum ProductType",name:"productType",type:"uint8"},{internalType:"uint256",name:"affiliatePercentage",type:"uint256"}],internalType:"struct Product",name:"",type:"tuple"}],stateMutability:"view",type:"function"},{inputs:[],name:"getProductCount",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{components:[{internalType:"uint256",name:"tokenId",type:"uint256"},{internalType:"address",name:"nftAddress",type:"address"},{internalType:"enum NFTType",name:"nftType",type:"uint8"},{internalType:"enum ProductType",name:"productType",type:"uint8"},{internalType:"uint256",name:"affiliatePercentage",type:"uint256"}],internalType:"struct Product",name:"product",type:"tuple"}],name:"getProductId",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"pure",type:"function"},{inputs:[{internalType:"address",name:"nftAddress",type:"address"},{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"getProductIdV2",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"pure",type:"function"},{inputs:[{internalType:"uint256",name:"affiliateId",type:"uint256"}],name:"getProductViaAffiliateId",outputs:[{components:[{internalType:"uint256",name:"tokenId",type:"uint256"},{internalType:"address",name:"nftAddress",type:"address"},{internalType:"enum NFTType",name:"nftType",type:"uint8"},{internalType:"enum ProductType",name:"productType",type:"uint8"},{internalType:"uint256",name:"affiliatePercentage",type:"uint256"}],internalType:"struct Product",name:"",type:"tuple"}],stateMutability:"view",type:"function"},{inputs:[],name:"getShopAddress",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"},{inputs:[],name:"getShopDescription",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"},{inputs:[],name:"getShopLogo",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"},{inputs:[],name:"getShopName",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"},{inputs:[],name:"getShopOwner",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"productId",type:"uint256"},{internalType:"address",name:"requester",type:"address"}],name:"isRequestSubmited",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"",type:"address"}],name:"managers",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[{components:[{internalType:"address",name:"nftAddress",type:"address"},{internalType:"string",name:"uri",type:"string"},{internalType:"uint256",name:"amount",type:"uint256"},{internalType:"bool",name:"accepted",type:"bool"},{internalType:"uint256",name:"affiliatePercentage",type:"uint256"},{internalType:"uint256",name:"royalty",type:"uint256"},{internalType:"enum NFTType",name:"nftType",type:"uint8"},{internalType:"enum ProductType",name:"productType",type:"uint8"}],internalType:"struct RecordData",name:"mintData",type:"tuple"}],name:"mintAndRegister",outputs:[{internalType:"uint256",name:"productId",type:"uint256"}],stateMutability:"nonpayable",type:"function"},{inputs:[{components:[{internalType:"address",name:"nftAddress",type:"address"},{internalType:"string",name:"uri",type:"string"},{internalType:"uint256",name:"amount",type:"uint256"},{internalType:"bool",name:"accepted",type:"bool"},{internalType:"uint256",name:"affiliatePercentage",type:"uint256"},{internalType:"uint256",name:"royalty",type:"uint256"},{internalType:"enum NFTType",name:"nftType",type:"uint8"},{internalType:"enum ProductType",name:"productType",type:"uint8"}],internalType:"struct RecordData[]",name:"recordData",type:"tuple[]"}],name:"mintAndRegisterBatch",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"",type:"uint256"}],name:"nullifiers",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"",type:"address"},{internalType:"address",name:"",type:"address"},{internalType:"uint256[]",name:"",type:"uint256[]"},{internalType:"uint256[]",name:"",type:"uint256[]"},{internalType:"bytes",name:"",type:"bytes"}],name:"onERC1155BatchReceived",outputs:[{internalType:"bytes4",name:"",type:"bytes4"}],stateMutability:"pure",type:"function"},{inputs:[{internalType:"address",name:"",type:"address"},{internalType:"address",name:"",type:"address"},{internalType:"uint256",name:"",type:"uint256"},{internalType:"uint256",name:"",type:"uint256"},{internalType:"bytes",name:"",type:"bytes"}],name:"onERC1155Received",outputs:[{internalType:"bytes4",name:"",type:"bytes4"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"",type:"address"},{internalType:"address",name:"",type:"address"},{internalType:"uint256",name:"",type:"uint256"},{internalType:"bytes",name:"",type:"bytes"}],name:"onERC721Received",outputs:[{internalType:"bytes4",name:"",type:"bytes4"}],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"owner",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"productCount",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"productId",type:"uint256"}],name:"products",outputs:[{internalType:"uint256",name:"tokenId",type:"uint256"},{internalType:"address",name:"nftAddress",type:"address"},{internalType:"enum NFTType",name:"nftType",type:"uint8"},{internalType:"enum ProductType",name:"productType",type:"uint8"},{internalType:"uint256",name:"affiliatePercentage",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bytes32",name:"ethSignedMessageHash",type:"bytes32"},{internalType:"bytes",name:"signature",type:"bytes"}],name:"recoverSigner",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"pure",type:"function"},{inputs:[{components:[{internalType:"uint256",name:"tokenId",type:"uint256"},{internalType:"address",name:"nftAddress",type:"address"},{internalType:"enum NFTType",name:"nftType",type:"uint8"},{internalType:"enum ProductType",name:"productType",type:"uint8"},{internalType:"uint256",name:"affiliatePercentage",type:"uint256"}],internalType:"struct Product",name:"p",type:"tuple"}],name:"registerProduct",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"renounceOwnership",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"productId",type:"uint256"}],name:"requestAffiliate",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"manager",type:"address"}],name:"revokeManager",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"manager",type:"address"}],name:"setManager",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"shopInfo",outputs:[{internalType:"string",name:"shopName",type:"string"},{internalType:"string",name:"shopAddress",type:"string"},{internalType:"string",name:"shopLogo",type:"string"},{internalType:"string",name:"shopDescription",type:"string"},{internalType:"address",name:"shopOwner",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bytes",name:"sig",type:"bytes"}],name:"splitSignature",outputs:[{internalType:"bytes32",name:"r",type:"bytes32"},{internalType:"bytes32",name:"s",type:"bytes32"},{internalType:"uint8",name:"v",type:"uint8"}],stateMutability:"pure",type:"function"},{inputs:[{internalType:"bytes4",name:"interfaceId",type:"bytes4"}],name:"supportsInterface",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"newManager",type:"address"}],name:"transferManagerShip",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"newOwner",type:"address"}],name:"transferOwnership",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"productId",type:"uint256"}],name:"unregisterProduct",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"newManagerWallet",type:"address"}],name:"updateDroplinkedManagerWallet",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"signer",type:"address"},{internalType:"bytes",name:"signature",type:"bytes"},{components:[{components:[{internalType:"uint256",name:"amount",type:"uint256"},{internalType:"uint256",name:"productId",type:"uint256"},{internalType:"uint256",name:"nullifier",type:"uint256"}],internalType:"struct PurchasedItem[]",name:"cart",type:"tuple[]"},{internalType:"address",name:"shop",type:"address"}],internalType:"struct PurchaseSignature",name:"data",type:"tuple"}],name:"verifyPurchase",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"pure",type:"function"}];function getTransactionLink({blockchain:n,transactionHash:t,isTestnet:c=!1}){const ie=t.trim();switch(n.toUpperCase()){case"CASPER":return`https://${c?"testnet.":""}cspr.live/deploy/${ie}`;case"STACKS":return`https://explorer.hiro.so/txid/${ie}?chain=${c?"testnet":"mainnet"}`;case"POLYGON":return`https://${c?"amoy.":""}polygonscan.com/tx/${ie}`;case"XRPLSIDECHAIN":return`https://evm-sidechain.xrpl.org/tx/${ie}`;case"BINANCE":return`https://${c?"testnet.":""}bscscan.com/tx/${ie}`;case"NEAR":return`https://explorer.${c?"testnet":"mainnet"}.aurora.dev/tx/${ie}`;case"BASE":return`https://base${c?"-sepolia":""}.blockscout.com/tx/${ie}`;case"LINEA":return`https://${c?"sepolia.":""}lineascan.build/tx/${ie}`;case"ETH":return`https://${c?"sepolia.":""}etherscan.io/tx/${ie}`;case"SOLANA":return`https://explorer.solana.com/tx/${ie}?cluster=${c?"devnet":"mainnet"}`;case"REDBELLY":return c?`https://redbelly.testnet.routescan.io/tx/${ie}`:`https://redbelly.routescan.io/tx/${ie}`;case"SKALE":return`https://${c?"giant-half-dual-testnet.explorer.testnet.skalenodes.com":"honorable-steel-rasalhague.explorer.mainnet.skalenodes.com"}/tx/${ie}`;case"BITLAYER":return c?`https://testnet.btrscan.com/tx/${ie}`:`https://www.btrscan.com/tx/${ie}`;default:return""}}async function ensureWalletOnChainFromConfig(n,t,c){const ie=t[c];if(!ie)throw new Error(`Network config not found for ${t.name} (${c})`);const se=n.provider;if(!(se!=null&&se.request))throw new Error("Provider does not support network switching");const ae=await n.getNetwork(),ue=Number(ie.chainId);if(ae.chainId!==ue){try{await se.request({method:"wallet_switchEthereumChain",params:[{chainId:ie.chainId}]})}catch(de){if(de.code===4902)await se.request({method:"wallet_addEthereumChain",params:[{chainId:ie.chainId,chainName:ie.chainName,rpcUrls:ie.rpcUrls,nativeCurrency:ie.nativeCurrency}]});else throw de}if((await n.getNetwork()).chainId!==ue)throw new Error(`Failed to switch to ${t.name} (${c})`)}}function getBaseUrl(n){return n===Network.MAINNET?"https://apiv3.droplinked.com":n===Network.TESTNET?"https://apiv3dev.droplinked.com":"http://127.0.0.1:3000"}async function getGasPrice(n){return(await n.getGasPrice()).toBigInt()}const deployerABI=[{inputs:[],name:"InvalidInitialization",type:"error"},{inputs:[],name:"NotInitializing",type:"error"},{inputs:[{internalType:"address",name:"owner",type:"address"}],name:"OwnableInvalidOwner",type:"error"},{inputs:[{internalType:"address",name:"account",type:"address"}],name:"OwnableUnauthorizedAccount",type:"error"},{anonymous:!1,inputs:[{indexed:!1,internalType:"uint256",name:"newFee",type:"uint256"}],name:"DroplinkedFeeUpdated",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"uint256",name:"newHeartBeat",type:"uint256"}],name:"HeartBeatUpdated",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"uint64",name:"version",type:"uint64"}],name:"Initialized",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"previousOwner",type:"address"},{indexed:!0,internalType:"address",name:"newOwner",type:"address"}],name:"OwnershipTransferred",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"address",name:"shop",type:"address"},{indexed:!1,internalType:"address",name:"nftContract",type:"address"}],name:"ShopDeployed",type:"event"},{inputs:[{internalType:"bytes",name:"bytecode",type:"bytes"},{internalType:"bytes32",name:"salt",type:"bytes32"}],name:"deployShop",outputs:[{internalType:"address",name:"shop",type:"address"},{internalType:"address",name:"nftContract",type:"address"}],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"droplinkedFee",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"droplinkedWallet",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"getDroplinkedFee",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"getHeartBeat",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"heartBeat",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"_heartBeat",type:"uint256"},{internalType:"address",name:"_droplinkedWallet",type:"address"},{internalType:"uint256",name:"_droplinkedFee",type:"uint256"}],name:"initialize",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"",type:"uint256"}],name:"nftContracts",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"shopOwner",type:"address"},{internalType:"uint256",name:"",type:"uint256"}],name:"nftOwners",outputs:[{internalType:"address",name:"nftContracts",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"owner",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"renounceOwnership",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"newFee",type:"uint256"}],name:"setDroplinkedFee",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"newHeartBeat",type:"uint256"}],name:"setHeartBeat",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"",type:"uint256"}],name:"shopAddresses",outputs:[{internalType:"contract IDropShop",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"shopCount",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"shopOwner",type:"address"},{internalType:"uint256",name:"",type:"uint256"}],name:"shopOwners",outputs:[{internalType:"address",name:"shops",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"newOwner",type:"address"}],name:"transferOwnership",outputs:[],stateMutability:"nonpayable",type:"function"}],sixify=n=>n.toString().padStart(6,"0");async function getConstructorArgs(n,t,c){return[n.shopName||"",n.shopAddress||"",c,n.shopLogo||"",n.shopDescription||"",t]}async function deployEVMShop(n,t,c){console.log({...n,...t,...c});const{modalInterface:ie}=t,{chain:se,network:ae,provider:ue}=n,de=ue.getSigner(),ve=await getDeployerAddress(se,ae),ge=new Contract(ve,deployerABI,de),we=await getShopByteCode(),Te=await de.getAddress(),Ne="0x"+Te.split("0x")[1]+"000000000000000000"+sixify(Math.floor(Math.random()*1e6)+1),qe=await getConstructorArgs(c,ve,Te),ze=defaultAbiCoder.encode(["string","string","address","string","string","address"],qe);try{let He;const Ge=we+ze.split("0x")[1];console.log({fullBytecode:Ge}),n.chain!==Chains.SKALE?(await ge.callStatic.deployShop(Ge,Ne),He=await ge.deployShop(Ge,Ne,{})):He=await ge.deployShop(Ge,Ne);const Ze=(await He.wait()).logs.map(Mt=>{try{return ge.interface.parseLog(Mt)}catch{return null}}).filter(Mt=>Mt!=null).find(Mt=>Mt.name==="ShopDeployed"),Ye=Ze.args.shop,Ft=Ze.args.nftContract;return{transactionHash:He.hash,deployedShopAddress:Ye,deployedNFTAddress:Ft}}catch(He){if(ie.error("Error during shop deployment",`${He.message||He}`),He.code.toString()==="ACTION_REJECTED")throw new UserDeniedException("Deployer");try{const Ge=ge.interface.parseError(He.data);throw ie.error("Contract error",`${Ge}`),Ge}catch(Ge){throw ie.error("Unhandled error during shop deployment.",`${Ge||He}`),new Error(Ge||"Unknown error occurred.")}}}function getRecordData(n,t,c){const{acceptsManageWallet:ie,amount:se,royalty:ae,type:ue}=n;return{nftAddress:c,uri:t,amount:se,accepted:ie,affiliatePercentage:ae,royalty:ae,nftType:NFTType.ERC1155,productType:ue}}async function prepareRecordData(n,t,c,ie){const{nftContract:se}=ie;if(!se)throw new InvalidParametersException(n.chain,"nftContract");const{description:ae}=c,{skuID:ue}=t,de={...t,...c},ve={...de.skuProperties},ge={name:de.productTitle,description:ae,image:de.imageUrl,properties:ve},we=await uploadMetadata(ge,ue,ie.axiosInstance);return getRecordData(de,we,se)}async function doRecordProduct(n,t,c,ie){const{modalInterface:se,nftContract:ae,shopContractAddress:ue}=t;if(!ae||!ue)throw se.error("Invalid Parameters","nftContract||shopContractAddress"),new InvalidParametersException(n.chain,"nftContract||shopContractAddress");se.changeStep("Connecting to wallet");const de=n.provider.getSigner(),ve=new Contract(ue,shopABI,de);try{se.changeStep("Preparing products for recording");const ge=await Promise.all(ie.map(Te=>prepareRecordData(n,Te,c,t)));let we;return n.chain!==Chains.SKALE?(await ve.callStatic.mintAndRegisterBatch(ge),se.changeStep("Recording products on blockchain"),we=await ve.mintAndRegisterBatch(ge)):(se.changeStep("Recording products on blockchain"),we=await ve.mintAndRegisterBatch(ge)),se.changeStep("Waiting for transaction confirmation"),await we.wait(),{transactionHash:we.hash,metadataUrls:ge.map(Te=>Te.uri)}}catch(ge){if(ge.code&&ge.code.toString()==="ACTION_REJECTED")throw t.modalInterface.error("Transaction Rejected","ACTION_REJECTED"),new Error("Transaction Rejected");try{if(ge.data&&ge.data!=="0x"){const we=ve.interface.parseError(ge.data);throw we.name==="OwnableUnauthorizedAccount"?(t.modalInterface.error("Unauthorized","OwnableUnauthorizedAccount"),new Unauthorized(n.chain,"record",await de.getAddress(),ue)):(t.modalInterface.error(we.name,we.args.join(", ")),t.modalInterface.error(ge,we.name),ge)}else throw se.error("Transaction reverted without reason",`${ge}`),ge}catch(we){throw se.error("Unexpected error",`${we}`),we}}}async function recordProduct({productId:n,chain:t,axiosInstance:c,shopId:ie,network:se,stepizer:ae,provider:ue}){let de="",ve="";if(ae.changeStep("Starting record process"),ie!==""){const qe=await getShopInfo(t,ie,c);de=qe.nftContractAddress,ve=qe.shopContractAddress}const ge=new Web3Provider(ue,"any");if(!de||!ve){ae.changeStep("Deploying shop contract");const qe={chain:t,network:se,provider:ge},ze={axiosInstance:c,modalInterface:ae,nftContract:"",shopContractAddress:""},{description:He,logo:Ge,name:Ze,url:Ye,deployedContracts:Ft}=await getShopDeployInfo(ie,c),{deployedNFTAddress:Mt,deployedShopAddress:Zt,transactionHash:cn}=await deployEVMShop(qe,ze,{shopName:Ze,shopAddress:Ye,shopLogo:Ge,shopDescription:He}),hn=[...Ft||[],{type:t,deployedShopAddress:Zt,transactionId:cn,deployedNFTAddress:Mt,isCircle:!1,platform:"DROPLINKED",status:"SUCCESS"}];console.log({newDeployedContracts:hn}),de=Mt,ve=Zt,ae.changeStep("Shop deployed successfully")}await ensureWalletOnChainFromConfig(ge,getChainByName(t),se);const{productData:we,skuData:Te}=await getProductDataForRecord(n,c);if(!ie)throw new InvalidParametersException(t,"shopId");const Ne=await startRecord(n,Te.map(qe=>qe.skuID),ie,t,[],c);try{const qe=await doRecordProduct({chain:t,network:se,provider:ge},{axiosInstance:c,modalInterface:ae,nftContract:de,shopContractAddress:ve},we,Te);await updateUris(Ne,qe.metadataUrls,c),await updateHash("record",Ne,qe.transactionHash,c);const ze=`${getBaseUrl(se)}/web3/record/callback/events/${Ne}`;if(!await web3Callback(qe.transactionHash,t,Network[se],ze))throw new Web3CallbackFailedException("Record");return{...qe,transactionId:Ne,transactionHashUrl:getTransactionLink({blockchain:t,transactionHash:qe.transactionHash,isTestnet:se!==Network.MAINNET})}}catch(qe){throw console.error("Error during recording process:",qe),await deleteRecordTransaction(Ne,c),qe}}var utils$e={};const require$$0$3=getAugmentedNamespace(lib_esm$b),require$$1$2=getAugmentedNamespace(lib_esm$f),require$$2$3=getAugmentedNamespace(lib_esm$d),require$$3=getAugmentedNamespace(lib_esm$8),require$$4$3=getAugmentedNamespace(lib_esm$j),require$$5=getAugmentedNamespace(lib_esm$c),require$$6$2=getAugmentedNamespace(lib_esm$6),require$$7=getAugmentedNamespace(lib_esm$4),require$$8=getAugmentedNamespace(lib_esm$h),require$$9=getAugmentedNamespace(lib_esm$k),require$$10=getAugmentedNamespace(lib_esm$7),require$$11$1=getAugmentedNamespace(lib_esm$1),require$$12=getAugmentedNamespace(lib_esm$5),require$$13=getAugmentedNamespace(lib_esm$i),require$$14=getAugmentedNamespace(lib_esm$g),require$$15=getAugmentedNamespace(lib_esm$a),require$$16=getAugmentedNamespace(lib_esm$e),require$$17$1=getAugmentedNamespace(lib_esm$9),require$$18=getAugmentedNamespace(lib_esm),require$$19=getAugmentedNamespace(lib_esm$3),require$$20=getAugmentedNamespace(lib_esm$2);(function(n){var t=commonjsGlobal&&commonjsGlobal.__createBinding||(Object.create?function(le,pe,be,xe){xe===void 0&&(xe=be),Object.defineProperty(le,xe,{enumerable:!0,get:function(){return pe[be]}})}:function(le,pe,be,xe){xe===void 0&&(xe=be),le[xe]=pe[be]}),c=commonjsGlobal&&commonjsGlobal.__setModuleDefault||(Object.create?function(le,pe){Object.defineProperty(le,"default",{enumerable:!0,value:pe})}:function(le,pe){le.default=pe}),ie=commonjsGlobal&&commonjsGlobal.__importStar||function(le){if(le&&le.__esModule)return le;var pe={};if(le!=null)for(var be in le)be!=="default"&&Object.prototype.hasOwnProperty.call(le,be)&&t(pe,le,be);return c(pe,le),pe};Object.defineProperty(n,"__esModule",{value:!0}),n.formatBytes32String=n.Utf8ErrorFuncs=n.toUtf8String=n.toUtf8CodePoints=n.toUtf8Bytes=n._toEscapedUtf8String=n.nameprep=n.hexDataSlice=n.hexDataLength=n.hexZeroPad=n.hexValue=n.hexStripZeros=n.hexConcat=n.isHexString=n.hexlify=n.base64=n.base58=n.TransactionDescription=n.LogDescription=n.Interface=n.SigningKey=n.HDNode=n.defaultPath=n.isBytesLike=n.isBytes=n.zeroPad=n.stripZeros=n.concat=n.arrayify=n.shallowCopy=n.resolveProperties=n.getStatic=n.defineReadOnly=n.deepCopy=n.checkProperties=n.poll=n.fetchJson=n._fetchData=n.RLP=n.Logger=n.checkResultErrors=n.FormatTypes=n.ParamType=n.FunctionFragment=n.EventFragment=n.ErrorFragment=n.ConstructorFragment=n.Fragment=n.defaultAbiCoder=n.AbiCoder=void 0,n.Indexed=n.Utf8ErrorReason=n.UnicodeNormalizationForm=n.SupportedAlgorithm=n.mnemonicToSeed=n.isValidMnemonic=n.entropyToMnemonic=n.mnemonicToEntropy=n.getAccountPath=n.verifyTypedData=n.verifyMessage=n.recoverPublicKey=n.computePublicKey=n.recoverAddress=n.computeAddress=n.getJsonWalletAddress=n.TransactionTypes=n.serializeTransaction=n.parseTransaction=n.accessListify=n.joinSignature=n.splitSignature=n.soliditySha256=n.solidityKeccak256=n.solidityPack=n.shuffled=n.randomBytes=n.sha512=n.sha256=n.ripemd160=n.keccak256=n.computeHmac=n.commify=n.parseUnits=n.formatUnits=n.parseEther=n.formatEther=n.isAddress=n.getCreate2Address=n.getContractAddress=n.getIcapAddress=n.getAddress=n._TypedDataEncoder=n.id=n.isValidName=n.namehash=n.hashMessage=n.dnsEncode=n.parseBytes32String=void 0;var se=require$$0$3;Object.defineProperty(n,"AbiCoder",{enumerable:!0,get:function(){return se.AbiCoder}}),Object.defineProperty(n,"checkResultErrors",{enumerable:!0,get:function(){return se.checkResultErrors}}),Object.defineProperty(n,"ConstructorFragment",{enumerable:!0,get:function(){return se.ConstructorFragment}}),Object.defineProperty(n,"defaultAbiCoder",{enumerable:!0,get:function(){return se.defaultAbiCoder}}),Object.defineProperty(n,"ErrorFragment",{enumerable:!0,get:function(){return se.ErrorFragment}}),Object.defineProperty(n,"EventFragment",{enumerable:!0,get:function(){return se.EventFragment}}),Object.defineProperty(n,"FormatTypes",{enumerable:!0,get:function(){return se.FormatTypes}}),Object.defineProperty(n,"Fragment",{enumerable:!0,get:function(){return se.Fragment}}),Object.defineProperty(n,"FunctionFragment",{enumerable:!0,get:function(){return se.FunctionFragment}}),Object.defineProperty(n,"Indexed",{enumerable:!0,get:function(){return se.Indexed}}),Object.defineProperty(n,"Interface",{enumerable:!0,get:function(){return se.Interface}}),Object.defineProperty(n,"LogDescription",{enumerable:!0,get:function(){return se.LogDescription}}),Object.defineProperty(n,"ParamType",{enumerable:!0,get:function(){return se.ParamType}}),Object.defineProperty(n,"TransactionDescription",{enumerable:!0,get:function(){return se.TransactionDescription}});var ae=require$$1$2;Object.defineProperty(n,"getAddress",{enumerable:!0,get:function(){return ae.getAddress}}),Object.defineProperty(n,"getCreate2Address",{enumerable:!0,get:function(){return ae.getCreate2Address}}),Object.defineProperty(n,"getContractAddress",{enumerable:!0,get:function(){return ae.getContractAddress}}),Object.defineProperty(n,"getIcapAddress",{enumerable:!0,get:function(){return ae.getIcapAddress}}),Object.defineProperty(n,"isAddress",{enumerable:!0,get:function(){return ae.isAddress}});var ue=ie(require$$2$3);n.base64=ue;var de=require$$3;Object.defineProperty(n,"base58",{enumerable:!0,get:function(){return de.Base58}});var ve=require$$4$3;Object.defineProperty(n,"arrayify",{enumerable:!0,get:function(){return ve.arrayify}}),Object.defineProperty(n,"concat",{enumerable:!0,get:function(){return ve.concat}}),Object.defineProperty(n,"hexConcat",{enumerable:!0,get:function(){return ve.hexConcat}}),Object.defineProperty(n,"hexDataSlice",{enumerable:!0,get:function(){return ve.hexDataSlice}}),Object.defineProperty(n,"hexDataLength",{enumerable:!0,get:function(){return ve.hexDataLength}}),Object.defineProperty(n,"hexlify",{enumerable:!0,get:function(){return ve.hexlify}}),Object.defineProperty(n,"hexStripZeros",{enumerable:!0,get:function(){return ve.hexStripZeros}}),Object.defineProperty(n,"hexValue",{enumerable:!0,get:function(){return ve.hexValue}}),Object.defineProperty(n,"hexZeroPad",{enumerable:!0,get:function(){return ve.hexZeroPad}}),Object.defineProperty(n,"isBytes",{enumerable:!0,get:function(){return ve.isBytes}}),Object.defineProperty(n,"isBytesLike",{enumerable:!0,get:function(){return ve.isBytesLike}}),Object.defineProperty(n,"isHexString",{enumerable:!0,get:function(){return ve.isHexString}}),Object.defineProperty(n,"joinSignature",{enumerable:!0,get:function(){return ve.joinSignature}}),Object.defineProperty(n,"zeroPad",{enumerable:!0,get:function(){return ve.zeroPad}}),Object.defineProperty(n,"splitSignature",{enumerable:!0,get:function(){return ve.splitSignature}}),Object.defineProperty(n,"stripZeros",{enumerable:!0,get:function(){return ve.stripZeros}});var ge=require$$5;Object.defineProperty(n,"_TypedDataEncoder",{enumerable:!0,get:function(){return ge._TypedDataEncoder}}),Object.defineProperty(n,"dnsEncode",{enumerable:!0,get:function(){return ge.dnsEncode}}),Object.defineProperty(n,"hashMessage",{enumerable:!0,get:function(){return ge.hashMessage}}),Object.defineProperty(n,"id",{enumerable:!0,get:function(){return ge.id}}),Object.defineProperty(n,"isValidName",{enumerable:!0,get:function(){return ge.isValidName}}),Object.defineProperty(n,"namehash",{enumerable:!0,get:function(){return ge.namehash}});var we=require$$6$2;Object.defineProperty(n,"defaultPath",{enumerable:!0,get:function(){return we.defaultPath}}),Object.defineProperty(n,"entropyToMnemonic",{enumerable:!0,get:function(){return we.entropyToMnemonic}}),Object.defineProperty(n,"getAccountPath",{enumerable:!0,get:function(){return we.getAccountPath}}),Object.defineProperty(n,"HDNode",{enumerable:!0,get:function(){return we.HDNode}}),Object.defineProperty(n,"isValidMnemonic",{enumerable:!0,get:function(){return we.isValidMnemonic}}),Object.defineProperty(n,"mnemonicToEntropy",{enumerable:!0,get:function(){return we.mnemonicToEntropy}}),Object.defineProperty(n,"mnemonicToSeed",{enumerable:!0,get:function(){return we.mnemonicToSeed}});var Te=require$$7;Object.defineProperty(n,"getJsonWalletAddress",{enumerable:!0,get:function(){return Te.getJsonWalletAddress}});var Ne=require$$8;Object.defineProperty(n,"keccak256",{enumerable:!0,get:function(){return Ne.keccak256}});var qe=require$$9;Object.defineProperty(n,"Logger",{enumerable:!0,get:function(){return qe.Logger}});var ze=require$$10;Object.defineProperty(n,"computeHmac",{enumerable:!0,get:function(){return ze.computeHmac}}),Object.defineProperty(n,"ripemd160",{enumerable:!0,get:function(){return ze.ripemd160}}),Object.defineProperty(n,"sha256",{enumerable:!0,get:function(){return ze.sha256}}),Object.defineProperty(n,"sha512",{enumerable:!0,get:function(){return ze.sha512}});var He=require$$11$1;Object.defineProperty(n,"solidityKeccak256",{enumerable:!0,get:function(){return He.keccak256}}),Object.defineProperty(n,"solidityPack",{enumerable:!0,get:function(){return He.pack}}),Object.defineProperty(n,"soliditySha256",{enumerable:!0,get:function(){return He.sha256}});var Ge=require$$12;Object.defineProperty(n,"randomBytes",{enumerable:!0,get:function(){return Ge.randomBytes}}),Object.defineProperty(n,"shuffled",{enumerable:!0,get:function(){return Ge.shuffled}});var Ze=require$$13;Object.defineProperty(n,"checkProperties",{enumerable:!0,get:function(){return Ze.checkProperties}}),Object.defineProperty(n,"deepCopy",{enumerable:!0,get:function(){return Ze.deepCopy}}),Object.defineProperty(n,"defineReadOnly",{enumerable:!0,get:function(){return Ze.defineReadOnly}}),Object.defineProperty(n,"getStatic",{enumerable:!0,get:function(){return Ze.getStatic}}),Object.defineProperty(n,"resolveProperties",{enumerable:!0,get:function(){return Ze.resolveProperties}}),Object.defineProperty(n,"shallowCopy",{enumerable:!0,get:function(){return Ze.shallowCopy}});var Ye=ie(require$$14);n.RLP=Ye;var Ft=require$$15;Object.defineProperty(n,"computePublicKey",{enumerable:!0,get:function(){return Ft.computePublicKey}}),Object.defineProperty(n,"recoverPublicKey",{enumerable:!0,get:function(){return Ft.recoverPublicKey}}),Object.defineProperty(n,"SigningKey",{enumerable:!0,get:function(){return Ft.SigningKey}});var Mt=require$$16;Object.defineProperty(n,"formatBytes32String",{enumerable:!0,get:function(){return Mt.formatBytes32String}}),Object.defineProperty(n,"nameprep",{enumerable:!0,get:function(){return Mt.nameprep}}),Object.defineProperty(n,"parseBytes32String",{enumerable:!0,get:function(){return Mt.parseBytes32String}}),Object.defineProperty(n,"_toEscapedUtf8String",{enumerable:!0,get:function(){return Mt._toEscapedUtf8String}}),Object.defineProperty(n,"toUtf8Bytes",{enumerable:!0,get:function(){return Mt.toUtf8Bytes}}),Object.defineProperty(n,"toUtf8CodePoints",{enumerable:!0,get:function(){return Mt.toUtf8CodePoints}}),Object.defineProperty(n,"toUtf8String",{enumerable:!0,get:function(){return Mt.toUtf8String}}),Object.defineProperty(n,"Utf8ErrorFuncs",{enumerable:!0,get:function(){return Mt.Utf8ErrorFuncs}});var Zt=require$$17$1;Object.defineProperty(n,"accessListify",{enumerable:!0,get:function(){return Zt.accessListify}}),Object.defineProperty(n,"computeAddress",{enumerable:!0,get:function(){return Zt.computeAddress}}),Object.defineProperty(n,"parseTransaction",{enumerable:!0,get:function(){return Zt.parse}}),Object.defineProperty(n,"recoverAddress",{enumerable:!0,get:function(){return Zt.recoverAddress}}),Object.defineProperty(n,"serializeTransaction",{enumerable:!0,get:function(){return Zt.serialize}}),Object.defineProperty(n,"TransactionTypes",{enumerable:!0,get:function(){return Zt.TransactionTypes}});var cn=require$$18;Object.defineProperty(n,"commify",{enumerable:!0,get:function(){return cn.commify}}),Object.defineProperty(n,"formatEther",{enumerable:!0,get:function(){return cn.formatEther}}),Object.defineProperty(n,"parseEther",{enumerable:!0,get:function(){return cn.parseEther}}),Object.defineProperty(n,"formatUnits",{enumerable:!0,get:function(){return cn.formatUnits}}),Object.defineProperty(n,"parseUnits",{enumerable:!0,get:function(){return cn.parseUnits}});var hn=require$$19;Object.defineProperty(n,"verifyMessage",{enumerable:!0,get:function(){return hn.verifyMessage}}),Object.defineProperty(n,"verifyTypedData",{enumerable:!0,get:function(){return hn.verifyTypedData}});var yn=require$$20;Object.defineProperty(n,"_fetchData",{enumerable:!0,get:function(){return yn._fetchData}}),Object.defineProperty(n,"fetchJson",{enumerable:!0,get:function(){return yn.fetchJson}}),Object.defineProperty(n,"poll",{enumerable:!0,get:function(){return yn.poll}});var Ht=require$$10;Object.defineProperty(n,"SupportedAlgorithm",{enumerable:!0,get:function(){return Ht.SupportedAlgorithm}});var Sn=require$$16;Object.defineProperty(n,"UnicodeNormalizationForm",{enumerable:!0,get:function(){return Sn.UnicodeNormalizationForm}}),Object.defineProperty(n,"Utf8ErrorReason",{enumerable:!0,get:function(){return Sn.Utf8ErrorReason}})})(utils$e);const ZERO_ADDRESS="0x0000000000000000000000000000000000000000",SkaleUsdcAddressForTestnet="0x2aebcdc4f9f9149a50422fff86198cb0939ea165",SkaleUsdcAddressForMainnet="0x7Cf76E740Cb23b99337b21F392F22c47Ad910c67",erc20ABI=[{inputs:[],stateMutability:"nonpayable",type:"constructor"},{inputs:[{internalType:"address",name:"spender",type:"address"},{internalType:"uint256",name:"allowance",type:"uint256"},{internalType:"uint256",name:"needed",type:"uint256"}],name:"ERC20InsufficientAllowance",type:"error"},{inputs:[{internalType:"address",name:"sender",type:"address"},{internalType:"uint256",name:"balance",type:"uint256"},{internalType:"uint256",name:"needed",type:"uint256"}],name:"ERC20InsufficientBalance",type:"error"},{inputs:[{internalType:"address",name:"approver",type:"address"}],name:"ERC20InvalidApprover",type:"error"},{inputs:[{internalType:"address",name:"receiver",type:"address"}],name:"ERC20InvalidReceiver",type:"error"},{inputs:[{internalType:"address",name:"sender",type:"address"}],name:"ERC20InvalidSender",type:"error"},{inputs:[{internalType:"address",name:"spender",type:"address"}],name:"ERC20InvalidSpender",type:"error"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"owner",type:"address"},{indexed:!0,internalType:"address",name:"spender",type:"address"},{indexed:!1,internalType:"uint256",name:"value",type:"uint256"}],name:"Approval",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"from",type:"address"},{indexed:!0,internalType:"address",name:"to",type:"address"},{indexed:!1,internalType:"uint256",name:"value",type:"uint256"}],name:"Transfer",type:"event"},{inputs:[{internalType:"address",name:"owner",type:"address"},{internalType:"address",name:"spender",type:"address"}],name:"allowance",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"spender",type:"address"},{internalType:"uint256",name:"value",type:"uint256"}],name:"approve",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"account",type:"address"}],name:"balanceOf",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"decimals",outputs:[{internalType:"uint8",name:"",type:"uint8"}],stateMutability:"view",type:"function"},{inputs:[],name:"name",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"},{inputs:[],name:"symbol",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"},{inputs:[],name:"totalSupply",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"value",type:"uint256"}],name:"transfer",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"from",type:"address"},{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"value",type:"uint256"}],name:"transferFrom",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"}],paymentProxyABI=[{inputs:[{internalType:"uint256",name:"_heartBeat",type:"uint256"},{internalType:"address",name:"_chainLinkProvider",type:"address"}],stateMutability:"nonpayable",type:"constructor"},{inputs:[{internalType:"address",name:"owner",type:"address"}],name:"OwnableInvalidOwner",type:"error"},{inputs:[{internalType:"address",name:"account",type:"address"}],name:"OwnableUnauthorizedAccount",type:"error"},{inputs:[{internalType:"uint256",name:"priceTimestamp",type:"uint256"},{internalType:"uint256",name:"currentTimestamp",type:"uint256"}],name:"oldPrice",type:"error"},{anonymous:!1,inputs:[{indexed:!1,internalType:"uint256",name:"newHeartBeat",type:"uint256"}],name:"HeartBeatChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"previousOwner",type:"address"},{indexed:!0,internalType:"address",name:"newOwner",type:"address"}],name:"OwnershipTransferred",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"string",name:"memo",type:"string"}],name:"ProductPurchased",type:"event"},{inputs:[{internalType:"uint256",name:"_heartBeat",type:"uint256"}],name:"changeHeartBeat",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256[]",name:"tbdValues",type:"uint256[]"},{internalType:"address[]",name:"tbdReceivers",type:"address[]"},{internalType:"address",name:"currency",type:"address"},{internalType:"uint80",name:"roundId",type:"uint80"},{internalType:"string",name:"memo",type:"string"}],name:"droplinkedPurchase",outputs:[],stateMutability:"payable",type:"function"},{inputs:[],name:"heartBeat",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"owner",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"renounceOwnership",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"newOwner",type:"address"}],name:"transferOwnership",outputs:[],stateMutability:"nonpayable",type:"function"}];async function handleCustomTokenApproval(n,t,c,ie,se){if(!n.tokenAddress)throw new InvalidParametersException(Chains.BASE,"Token address is not set");try{const ae=new Contract(n.tokenAddress,erc20ABI,c),ue=await ae.balanceOf(ie),de=n.tbdValues.reduce((ge,we)=>ge.add(BigNumber.from(we)),BigNumber.from(0));if(ue.lt(de))throw new InsufficientBalanceException;se.changeStep("Approving token");const ve=await ae.approve(t,MaxUint256$1);se.changeStep("awaiting confirmation"),await ve.wait(),se.changeStep("Token approval confirmed")}catch(ae){handleError(ae)}}const droplinkedPayment=async function(n,t,c){const{modalInterface:ie}=t,{provider:se,chain:ae,network:ue}=n;if(!c.tbdReceivers.every(utils$e.isAddress))throw new InvalidParametersException(ae,"Invalid receiver address found");c.chainLinkRoundId=c.chainLinkRoundId||"0";const de=c.tokenAddress&&c.tokenAddress!==ZERO_ADDRESS;if(de){if(!c.tbdValues.every(Ne=>BigNumber.from(Ne).gt(0)))throw new InvalidParametersException(ae,"tbdValues must be positive numbers")}else if(!c.tbdValues.every(Ne=>Ne>0))throw new InvalidParametersException(ae,"tbdValues must be positive numbers");const ve=se.getSigner(),ge=await ve.getAddress();if(!c.tbdValues)throw new InvalidParametersException(ae,`Invalid tbdValues: ${c.tbdValues}`);if(!c.tbdReceivers)throw new InvalidParametersException(ae,`Invalid tbdReceivers: ${c.tbdReceivers}`);if(!c.memo)throw new InvalidParametersException(ae,`Memo is required for payment, current memo: ${c.memo}`);if(c.tbdReceivers.length!==c.tbdValues.length)throw new InvalidParametersException(ae,"tbdReceivers and tbdValues must be the same length");let we;try{we=await getProxyAddress(ae,ue)}catch(Ne){throw new Error("Failed to get contract address: "+Ne.message)}let Te;try{Te=new Contract(we,paymentProxyABI,ve)}catch(Ne){throw new Error("Failed to create contract instance: "+Ne.message)}try{if(console.log(`
13
+ `)}static register(t,c){c||(c=t.locale)}}const words="AbandonAbilityAbleAboutAboveAbsentAbsorbAbstractAbsurdAbuseAccessAccidentAccountAccuseAchieveAcidAcousticAcquireAcrossActActionActorActressActualAdaptAddAddictAddressAdjustAdmitAdultAdvanceAdviceAerobicAffairAffordAfraidAgainAgeAgentAgreeAheadAimAirAirportAisleAlarmAlbumAlcoholAlertAlienAllAlleyAllowAlmostAloneAlphaAlreadyAlsoAlterAlwaysAmateurAmazingAmongAmountAmusedAnalystAnchorAncientAngerAngleAngryAnimalAnkleAnnounceAnnualAnotherAnswerAntennaAntiqueAnxietyAnyApartApologyAppearAppleApproveAprilArchArcticAreaArenaArgueArmArmedArmorArmyAroundArrangeArrestArriveArrowArtArtefactArtistArtworkAskAspectAssaultAssetAssistAssumeAsthmaAthleteAtomAttackAttendAttitudeAttractAuctionAuditAugustAuntAuthorAutoAutumnAverageAvocadoAvoidAwakeAwareAwayAwesomeAwfulAwkwardAxisBabyBachelorBaconBadgeBagBalanceBalconyBallBambooBananaBannerBarBarelyBargainBarrelBaseBasicBasketBattleBeachBeanBeautyBecauseBecomeBeefBeforeBeginBehaveBehindBelieveBelowBeltBenchBenefitBestBetrayBetterBetweenBeyondBicycleBidBikeBindBiologyBirdBirthBitterBlackBladeBlameBlanketBlastBleakBlessBlindBloodBlossomBlouseBlueBlurBlushBoardBoatBodyBoilBombBoneBonusBookBoostBorderBoringBorrowBossBottomBounceBoxBoyBracketBrainBrandBrassBraveBreadBreezeBrickBridgeBriefBrightBringBriskBroccoliBrokenBronzeBroomBrotherBrownBrushBubbleBuddyBudgetBuffaloBuildBulbBulkBulletBundleBunkerBurdenBurgerBurstBusBusinessBusyButterBuyerBuzzCabbageCabinCableCactusCageCakeCallCalmCameraCampCanCanalCancelCandyCannonCanoeCanvasCanyonCapableCapitalCaptainCarCarbonCardCargoCarpetCarryCartCaseCashCasinoCastleCasualCatCatalogCatchCategoryCattleCaughtCauseCautionCaveCeilingCeleryCementCensusCenturyCerealCertainChairChalkChampionChangeChaosChapterChargeChaseChatCheapCheckCheeseChefCherryChestChickenChiefChildChimneyChoiceChooseChronicChuckleChunkChurnCigarCinnamonCircleCitizenCityCivilClaimClapClarifyClawClayCleanClerkCleverClickClientCliffClimbClinicClipClockClogCloseClothCloudClownClubClumpClusterClutchCoachCoastCoconutCodeCoffeeCoilCoinCollectColorColumnCombineComeComfortComicCommonCompanyConcertConductConfirmCongressConnectConsiderControlConvinceCookCoolCopperCopyCoralCoreCornCorrectCostCottonCouchCountryCoupleCourseCousinCoverCoyoteCrackCradleCraftCramCraneCrashCraterCrawlCrazyCreamCreditCreekCrewCricketCrimeCrispCriticCropCrossCrouchCrowdCrucialCruelCruiseCrumbleCrunchCrushCryCrystalCubeCultureCupCupboardCuriousCurrentCurtainCurveCushionCustomCuteCycleDadDamageDampDanceDangerDaringDashDaughterDawnDayDealDebateDebrisDecadeDecemberDecideDeclineDecorateDecreaseDeerDefenseDefineDefyDegreeDelayDeliverDemandDemiseDenialDentistDenyDepartDependDepositDepthDeputyDeriveDescribeDesertDesignDeskDespairDestroyDetailDetectDevelopDeviceDevoteDiagramDialDiamondDiaryDiceDieselDietDifferDigitalDignityDilemmaDinnerDinosaurDirectDirtDisagreeDiscoverDiseaseDishDismissDisorderDisplayDistanceDivertDivideDivorceDizzyDoctorDocumentDogDollDolphinDomainDonateDonkeyDonorDoorDoseDoubleDoveDraftDragonDramaDrasticDrawDreamDressDriftDrillDrinkDripDriveDropDrumDryDuckDumbDuneDuringDustDutchDutyDwarfDynamicEagerEagleEarlyEarnEarthEasilyEastEasyEchoEcologyEconomyEdgeEditEducateEffortEggEightEitherElbowElderElectricElegantElementElephantElevatorEliteElseEmbarkEmbodyEmbraceEmergeEmotionEmployEmpowerEmptyEnableEnactEndEndlessEndorseEnemyEnergyEnforceEngageEngineEnhanceEnjoyEnlistEnoughEnrichEnrollEnsureEnterEntireEntryEnvelopeEpisodeEqualEquipEraEraseErodeErosionErrorEruptEscapeEssayEssenceEstateEternalEthicsEvidenceEvilEvokeEvolveExactExampleExcessExchangeExciteExcludeExcuseExecuteExerciseExhaustExhibitExileExistExitExoticExpandExpectExpireExplainExposeExpressExtendExtraEyeEyebrowFabricFaceFacultyFadeFaintFaithFallFalseFameFamilyFamousFanFancyFantasyFarmFashionFatFatalFatherFatigueFaultFavoriteFeatureFebruaryFederalFeeFeedFeelFemaleFenceFestivalFetchFeverFewFiberFictionFieldFigureFileFilmFilterFinalFindFineFingerFinishFireFirmFirstFiscalFishFitFitnessFixFlagFlameFlashFlatFlavorFleeFlightFlipFloatFlockFloorFlowerFluidFlushFlyFoamFocusFogFoilFoldFollowFoodFootForceForestForgetForkFortuneForumForwardFossilFosterFoundFoxFragileFrameFrequentFreshFriendFringeFrogFrontFrostFrownFrozenFruitFuelFunFunnyFurnaceFuryFutureGadgetGainGalaxyGalleryGameGapGarageGarbageGardenGarlicGarmentGasGaspGateGatherGaugeGazeGeneralGeniusGenreGentleGenuineGestureGhostGiantGiftGiggleGingerGiraffeGirlGiveGladGlanceGlareGlassGlideGlimpseGlobeGloomGloryGloveGlowGlueGoatGoddessGoldGoodGooseGorillaGospelGossipGovernGownGrabGraceGrainGrantGrapeGrassGravityGreatGreenGridGriefGritGroceryGroupGrowGruntGuardGuessGuideGuiltGuitarGunGymHabitHairHalfHammerHamsterHandHappyHarborHardHarshHarvestHatHaveHawkHazardHeadHealthHeartHeavyHedgehogHeightHelloHelmetHelpHenHeroHiddenHighHillHintHipHireHistoryHobbyHockeyHoldHoleHolidayHollowHomeHoneyHoodHopeHornHorrorHorseHospitalHostHotelHourHoverHubHugeHumanHumbleHumorHundredHungryHuntHurdleHurryHurtHusbandHybridIceIconIdeaIdentifyIdleIgnoreIllIllegalIllnessImageImitateImmenseImmuneImpactImposeImproveImpulseInchIncludeIncomeIncreaseIndexIndicateIndoorIndustryInfantInflictInformInhaleInheritInitialInjectInjuryInmateInnerInnocentInputInquiryInsaneInsectInsideInspireInstallIntactInterestIntoInvestInviteInvolveIronIslandIsolateIssueItemIvoryJacketJaguarJarJazzJealousJeansJellyJewelJobJoinJokeJourneyJoyJudgeJuiceJumpJungleJuniorJunkJustKangarooKeenKeepKetchupKeyKickKidKidneyKindKingdomKissKitKitchenKiteKittenKiwiKneeKnifeKnockKnowLabLabelLaborLadderLadyLakeLampLanguageLaptopLargeLaterLatinLaughLaundryLavaLawLawnLawsuitLayerLazyLeaderLeafLearnLeaveLectureLeftLegLegalLegendLeisureLemonLendLengthLensLeopardLessonLetterLevelLiarLibertyLibraryLicenseLifeLiftLightLikeLimbLimitLinkLionLiquidListLittleLiveLizardLoadLoanLobsterLocalLockLogicLonelyLongLoopLotteryLoudLoungeLoveLoyalLuckyLuggageLumberLunarLunchLuxuryLyricsMachineMadMagicMagnetMaidMailMainMajorMakeMammalManManageMandateMangoMansionManualMapleMarbleMarchMarginMarineMarketMarriageMaskMassMasterMatchMaterialMathMatrixMatterMaximumMazeMeadowMeanMeasureMeatMechanicMedalMediaMelodyMeltMemberMemoryMentionMenuMercyMergeMeritMerryMeshMessageMetalMethodMiddleMidnightMilkMillionMimicMindMinimumMinorMinuteMiracleMirrorMiseryMissMistakeMixMixedMixtureMobileModelModifyMomMomentMonitorMonkeyMonsterMonthMoonMoralMoreMorningMosquitoMotherMotionMotorMountainMouseMoveMovieMuchMuffinMuleMultiplyMuscleMuseumMushroomMusicMustMutualMyselfMysteryMythNaiveNameNapkinNarrowNastyNationNatureNearNeckNeedNegativeNeglectNeitherNephewNerveNestNetNetworkNeutralNeverNewsNextNiceNightNobleNoiseNomineeNoodleNormalNorthNoseNotableNoteNothingNoticeNovelNowNuclearNumberNurseNutOakObeyObjectObligeObscureObserveObtainObviousOccurOceanOctoberOdorOffOfferOfficeOftenOilOkayOldOliveOlympicOmitOnceOneOnionOnlineOnlyOpenOperaOpinionOpposeOptionOrangeOrbitOrchardOrderOrdinaryOrganOrientOriginalOrphanOstrichOtherOutdoorOuterOutputOutsideOvalOvenOverOwnOwnerOxygenOysterOzonePactPaddlePagePairPalacePalmPandaPanelPanicPantherPaperParadeParentParkParrotPartyPassPatchPathPatientPatrolPatternPausePavePaymentPeacePeanutPearPeasantPelicanPenPenaltyPencilPeoplePepperPerfectPermitPersonPetPhonePhotoPhrasePhysicalPianoPicnicPicturePiecePigPigeonPillPilotPinkPioneerPipePistolPitchPizzaPlacePlanetPlasticPlatePlayPleasePledgePluckPlugPlungePoemPoetPointPolarPolePolicePondPonyPoolPopularPortionPositionPossiblePostPotatoPotteryPovertyPowderPowerPracticePraisePredictPreferPreparePresentPrettyPreventPricePridePrimaryPrintPriorityPrisonPrivatePrizeProblemProcessProduceProfitProgramProjectPromoteProofPropertyProsperProtectProudProvidePublicPuddingPullPulpPulsePumpkinPunchPupilPuppyPurchasePurityPurposePursePushPutPuzzlePyramidQualityQuantumQuarterQuestionQuickQuitQuizQuoteRabbitRaccoonRaceRackRadarRadioRailRainRaiseRallyRampRanchRandomRangeRapidRareRateRatherRavenRawRazorReadyRealReasonRebelRebuildRecallReceiveRecipeRecordRecycleReduceReflectReformRefuseRegionRegretRegularRejectRelaxReleaseReliefRelyRemainRememberRemindRemoveRenderRenewRentReopenRepairRepeatReplaceReportRequireRescueResembleResistResourceResponseResultRetireRetreatReturnReunionRevealReviewRewardRhythmRibRibbonRiceRichRideRidgeRifleRightRigidRingRiotRippleRiskRitualRivalRiverRoadRoastRobotRobustRocketRomanceRoofRookieRoomRoseRotateRoughRoundRouteRoyalRubberRudeRugRuleRunRunwayRuralSadSaddleSadnessSafeSailSaladSalmonSalonSaltSaluteSameSampleSandSatisfySatoshiSauceSausageSaveSayScaleScanScareScatterSceneSchemeSchoolScienceScissorsScorpionScoutScrapScreenScriptScrubSeaSearchSeasonSeatSecondSecretSectionSecuritySeedSeekSegmentSelectSellSeminarSeniorSenseSentenceSeriesServiceSessionSettleSetupSevenShadowShaftShallowShareShedShellSheriffShieldShiftShineShipShiverShockShoeShootShopShortShoulderShoveShrimpShrugShuffleShySiblingSickSideSiegeSightSignSilentSilkSillySilverSimilarSimpleSinceSingSirenSisterSituateSixSizeSkateSketchSkiSkillSkinSkirtSkullSlabSlamSleepSlenderSliceSlideSlightSlimSloganSlotSlowSlushSmallSmartSmileSmokeSmoothSnackSnakeSnapSniffSnowSoapSoccerSocialSockSodaSoftSolarSoldierSolidSolutionSolveSomeoneSongSoonSorrySortSoulSoundSoupSourceSouthSpaceSpareSpatialSpawnSpeakSpecialSpeedSpellSpendSphereSpiceSpiderSpikeSpinSpiritSplitSpoilSponsorSpoonSportSpotSpraySpreadSpringSpySquareSqueezeSquirrelStableStadiumStaffStageStairsStampStandStartStateStaySteakSteelStemStepStereoStickStillStingStockStomachStoneStoolStoryStoveStrategyStreetStrikeStrongStruggleStudentStuffStumbleStyleSubjectSubmitSubwaySuccessSuchSuddenSufferSugarSuggestSuitSummerSunSunnySunsetSuperSupplySupremeSureSurfaceSurgeSurpriseSurroundSurveySuspectSustainSwallowSwampSwapSwarmSwearSweetSwiftSwimSwingSwitchSwordSymbolSymptomSyrupSystemTableTackleTagTailTalentTalkTankTapeTargetTaskTasteTattooTaxiTeachTeamTellTenTenantTennisTentTermTestTextThankThatThemeThenTheoryThereTheyThingThisThoughtThreeThriveThrowThumbThunderTicketTideTigerTiltTimberTimeTinyTipTiredTissueTitleToastTobaccoTodayToddlerToeTogetherToiletTokenTomatoTomorrowToneTongueTonightToolToothTopTopicToppleTorchTornadoTortoiseTossTotalTouristTowardTowerTownToyTrackTradeTrafficTragicTrainTransferTrapTrashTravelTrayTreatTreeTrendTrialTribeTrickTriggerTrimTripTrophyTroubleTruckTrueTrulyTrumpetTrustTruthTryTubeTuitionTumbleTunaTunnelTurkeyTurnTurtleTwelveTwentyTwiceTwinTwistTwoTypeTypicalUglyUmbrellaUnableUnawareUncleUncoverUnderUndoUnfairUnfoldUnhappyUniformUniqueUnitUniverseUnknownUnlockUntilUnusualUnveilUpdateUpgradeUpholdUponUpperUpsetUrbanUrgeUsageUseUsedUsefulUselessUsualUtilityVacantVacuumVagueValidValleyValveVanVanishVaporVariousVastVaultVehicleVelvetVendorVentureVenueVerbVerifyVersionVeryVesselVeteranViableVibrantViciousVictoryVideoViewVillageVintageViolinVirtualVirusVisaVisitVisualVitalVividVocalVoiceVoidVolcanoVolumeVoteVoyageWageWagonWaitWalkWallWalnutWantWarfareWarmWarriorWashWaspWasteWaterWaveWayWealthWeaponWearWeaselWeatherWebWeddingWeekendWeirdWelcomeWestWetWhaleWhatWheatWheelWhenWhereWhipWhisperWideWidthWifeWildWillWinWindowWineWingWinkWinnerWinterWireWisdomWiseWishWitnessWolfWomanWonderWoodWoolWordWorkWorldWorryWorthWrapWreckWrestleWristWriteWrongYardYearYellowYouYoungYouthZebraZeroZoneZoo";let wordlist=null;function loadWords(n){if(wordlist==null&&(wordlist=words.replace(/([A-Z])/g," $1").toLowerCase().substring(1).split(" "),Wordlist.check(n)!=="0x3c8acc1e7b08d8e76f9fda015ef48dc8c710a73cb7e0f77b2c18a9b5a7adde60"))throw wordlist=null,new Error("BIP39 Wordlist for en (English) FAILED")}class LangEn extends Wordlist{constructor(){super("en")}getWord(t){return loadWords(this),wordlist[t]}getWordIndex(t){return loadWords(this),wordlist.indexOf(t)}}const langEn=new LangEn;Wordlist.register(langEn);const wordlists={en:langEn},version$e="hdnode/5.8.0",logger$c=new Logger(version$e),N$3=BigNumber.from("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),MasterSecret=toUtf8Bytes("Bitcoin seed"),HardenedBit=2147483648;function getUpperMask(n){return(1<<n)-1<<8-n}function getLowerMask(n){return(1<<n)-1}function bytes32(n){return hexZeroPad(hexlify(n),32)}function base58check(n){return Base58.encode(concat$1([n,hexDataSlice(sha256$7(sha256$7(n)),0,4)]))}function getWordlist(n){if(n==null)return wordlists.en;if(typeof n=="string"){const t=wordlists[n];return t==null&&logger$c.throwArgumentError("unknown locale","wordlist",n),t}return n}const _constructorGuard$1={},defaultPath="m/44'/60'/0'/0/0";class HDNode{constructor(t,c,ie,se,ae,ue,de,ve){if(t!==_constructorGuard$1)throw new Error("HDNode constructor cannot be called directly");if(c){const ge=new SigningKey(c);defineReadOnly(this,"privateKey",ge.privateKey),defineReadOnly(this,"publicKey",ge.compressedPublicKey)}else defineReadOnly(this,"privateKey",null),defineReadOnly(this,"publicKey",hexlify(ie));defineReadOnly(this,"parentFingerprint",se),defineReadOnly(this,"fingerprint",hexDataSlice(ripemd160$1(sha256$7(this.publicKey)),0,4)),defineReadOnly(this,"address",computeAddress(this.publicKey)),defineReadOnly(this,"chainCode",ae),defineReadOnly(this,"index",ue),defineReadOnly(this,"depth",de),ve==null?(defineReadOnly(this,"mnemonic",null),defineReadOnly(this,"path",null)):typeof ve=="string"?(defineReadOnly(this,"mnemonic",null),defineReadOnly(this,"path",ve)):(defineReadOnly(this,"mnemonic",ve),defineReadOnly(this,"path",ve.path))}get extendedKey(){if(this.depth>=256)throw new Error("Depth too large!");return base58check(concat$1([this.privateKey!=null?"0x0488ADE4":"0x0488B21E",hexlify(this.depth),this.parentFingerprint,hexZeroPad(hexlify(this.index),4),this.chainCode,this.privateKey!=null?concat$1(["0x00",this.privateKey]):this.publicKey]))}neuter(){return new HDNode(_constructorGuard$1,null,this.publicKey,this.parentFingerprint,this.chainCode,this.index,this.depth,this.path)}_derive(t){if(t>4294967295)throw new Error("invalid index - "+String(t));let c=this.path;c&&(c+="/"+(t&~HardenedBit));const ie=new Uint8Array(37);if(t&HardenedBit){if(!this.privateKey)throw new Error("cannot derive child of neutered node");ie.set(arrayify(this.privateKey),1),c&&(c+="'")}else ie.set(arrayify(this.publicKey));for(let Te=24;Te>=0;Te-=8)ie[33+(Te>>3)]=t>>24-Te&255;const se=arrayify(computeHmac(SupportedAlgorithm.sha512,this.chainCode,ie)),ae=se.slice(0,32),ue=se.slice(32);let de=null,ve=null;this.privateKey?de=bytes32(BigNumber.from(ae).add(this.privateKey).mod(N$3)):ve=new SigningKey(hexlify(ae))._addPoint(this.publicKey);let ge=c;const we=this.mnemonic;return we&&(ge=Object.freeze({phrase:we.phrase,path:c,locale:we.locale||"en"})),new HDNode(_constructorGuard$1,de,ve,this.fingerprint,bytes32(ue),t,this.depth+1,ge)}derivePath(t){const c=t.split("/");if(c.length===0||c[0]==="m"&&this.depth!==0)throw new Error("invalid path - "+t);c[0]==="m"&&c.shift();let ie=this;for(let se=0;se<c.length;se++){const ae=c[se];if(ae.match(/^[0-9]+'$/)){const ue=parseInt(ae.substring(0,ae.length-1));if(ue>=HardenedBit)throw new Error("invalid path index - "+ae);ie=ie._derive(HardenedBit+ue)}else if(ae.match(/^[0-9]+$/)){const ue=parseInt(ae);if(ue>=HardenedBit)throw new Error("invalid path index - "+ae);ie=ie._derive(ue)}else throw new Error("invalid path component - "+ae)}return ie}static _fromSeed(t,c){const ie=arrayify(t);if(ie.length<16||ie.length>64)throw new Error("invalid seed");const se=arrayify(computeHmac(SupportedAlgorithm.sha512,MasterSecret,ie));return new HDNode(_constructorGuard$1,bytes32(se.slice(0,32)),null,"0x00000000",bytes32(se.slice(32)),0,0,c)}static fromMnemonic(t,c,ie){return ie=getWordlist(ie),t=entropyToMnemonic(mnemonicToEntropy(t,ie),ie),HDNode._fromSeed(mnemonicToSeed(t,c),{phrase:t,path:"m",locale:ie.locale})}static fromSeed(t){return HDNode._fromSeed(t,null)}static fromExtendedKey(t){const c=Base58.decode(t);(c.length!==82||base58check(c.slice(0,78))!==t)&&logger$c.throwArgumentError("invalid extended key","extendedKey","[REDACTED]");const ie=c[4],se=hexlify(c.slice(5,9)),ae=parseInt(hexlify(c.slice(9,13)).substring(2),16),ue=hexlify(c.slice(13,45)),de=c.slice(45,78);switch(hexlify(c.slice(0,4))){case"0x0488b21e":case"0x043587cf":return new HDNode(_constructorGuard$1,null,hexlify(de),se,ue,ae,ie,null);case"0x0488ade4":case"0x04358394 ":if(de[0]!==0)break;return new HDNode(_constructorGuard$1,hexlify(de.slice(1)),null,se,ue,ae,ie,null)}return logger$c.throwArgumentError("invalid extended key","extendedKey","[REDACTED]")}}function mnemonicToSeed(n,t){t||(t="");const c=toUtf8Bytes("mnemonic"+t,UnicodeNormalizationForm.NFKD);return pbkdf2$1(toUtf8Bytes(n,UnicodeNormalizationForm.NFKD),c,2048,64,"sha512")}function mnemonicToEntropy(n,t){t=getWordlist(t),logger$c.checkNormalize();const c=t.split(n);if(c.length%3!==0)throw new Error("invalid mnemonic");const ie=arrayify(new Uint8Array(Math.ceil(11*c.length/8)));let se=0;for(let ve=0;ve<c.length;ve++){let ge=t.getWordIndex(c[ve].normalize("NFKD"));if(ge===-1)throw new Error("invalid mnemonic");for(let we=0;we<11;we++)ge&1<<10-we&&(ie[se>>3]|=1<<7-se%8),se++}const ae=32*c.length/3,ue=c.length/3,de=getUpperMask(ue);if((arrayify(sha256$7(ie.slice(0,ae/8)))[0]&de)!==(ie[ie.length-1]&de))throw new Error("invalid checksum");return hexlify(ie.slice(0,ae/8))}function entropyToMnemonic(n,t){if(t=getWordlist(t),n=arrayify(n),n.length%4!==0||n.length<16||n.length>32)throw new Error("invalid entropy");const c=[0];let ie=11;for(let ue=0;ue<n.length;ue++)ie>8?(c[c.length-1]<<=8,c[c.length-1]|=n[ue],ie-=8):(c[c.length-1]<<=ie,c[c.length-1]|=n[ue]>>8-ie,c.push(n[ue]&getLowerMask(8-ie)),ie+=3);const se=n.length/4,ae=arrayify(sha256$7(n))[0]&getUpperMask(se);return c[c.length-1]<<=se,c[c.length-1]|=ae>>8-se,t.join(c.map(ue=>t.getWord(ue)))}function isValidMnemonic(n,t){try{return mnemonicToEntropy(n,t),!0}catch{}return!1}function getAccountPath(n){return(typeof n!="number"||n<0||n>=HardenedBit||n%1)&&logger$c.throwArgumentError("invalid account index","index",n),`m/44'/60'/${n}'/0/0`}const lib_esm$6=Object.freeze(Object.defineProperty({__proto__:null,HDNode,defaultPath,entropyToMnemonic,getAccountPath,isValidMnemonic,mnemonicToEntropy,mnemonicToSeed},Symbol.toStringTag,{value:"Module"})),version$d="random/5.8.0",logger$b=new Logger(version$d);function getGlobal(){if(typeof self<"u")return self;if(typeof window<"u")return window;if(typeof globalThis<"u")return globalThis;throw new Error("unable to locate global object")}const anyGlobal=getGlobal();let crypto$3=anyGlobal.crypto||anyGlobal.msCrypto;(!crypto$3||!crypto$3.getRandomValues)&&(logger$b.warn("WARNING: Missing strong random number source"),crypto$3={getRandomValues:function(n){return logger$b.throwError("no secure random source avaialble",Logger.errors.UNSUPPORTED_OPERATION,{operation:"crypto.getRandomValues"})}});function randomBytes$1(n){(n<=0||n>1024||n%1||n!=n)&&logger$b.throwArgumentError("invalid length","length",n);const t=new Uint8Array(n);return crypto$3.getRandomValues(t),arrayify(t)}function shuffled(n){n=n.slice();for(let t=n.length-1;t>0;t--){const c=Math.floor(Math.random()*(t+1)),ie=n[t];n[t]=n[c],n[c]=ie}return n}const lib_esm$5=Object.freeze(Object.defineProperty({__proto__:null,randomBytes:randomBytes$1,shuffled},Symbol.toStringTag,{value:"Module"}));var aesJs={exports:{}};(function(n,t){(function(c){function ie(We){return parseInt(We)===We}function se(We){if(!ie(We.length))return!1;for(var $t=0;$t<We.length;$t++)if(!ie(We[$t])||We[$t]<0||We[$t]>255)return!1;return!0}function ae(We,$t){if(We.buffer&&ArrayBuffer.isView(We)&&We.name==="Uint8Array")return $t&&(We.slice?We=We.slice():We=Array.prototype.slice.call(We)),We;if(Array.isArray(We)){if(!se(We))throw new Error("Array contains invalid value: "+We);return new Uint8Array(We)}if(ie(We.length)&&se(We))return new Uint8Array(We);throw new Error("unsupported array-like object")}function ue(We){return new Uint8Array(We)}function de(We,$t,dn,gn,Vt){(gn!=null||Vt!=null)&&(We.slice?We=We.slice(gn,Vt):We=Array.prototype.slice.call(We,gn,Vt)),$t.set(We,dn)}var ve=(function(){function We(dn){var gn=[],Vt=0;for(dn=encodeURI(dn);Vt<dn.length;){var Cn=dn.charCodeAt(Vt++);Cn===37?(gn.push(parseInt(dn.substr(Vt,2),16)),Vt+=2):gn.push(Cn)}return ae(gn)}function $t(dn){for(var gn=[],Vt=0;Vt<dn.length;){var Cn=dn[Vt];Cn<128?(gn.push(String.fromCharCode(Cn)),Vt++):Cn>191&&Cn<224?(gn.push(String.fromCharCode((Cn&31)<<6|dn[Vt+1]&63)),Vt+=2):(gn.push(String.fromCharCode((Cn&15)<<12|(dn[Vt+1]&63)<<6|dn[Vt+2]&63)),Vt+=3)}return gn.join("")}return{toBytes:We,fromBytes:$t}})(),ge=(function(){function We(gn){for(var Vt=[],Cn=0;Cn<gn.length;Cn+=2)Vt.push(parseInt(gn.substr(Cn,2),16));return Vt}var $t="0123456789abcdef";function dn(gn){for(var Vt=[],Cn=0;Cn<gn.length;Cn++){var un=gn[Cn];Vt.push($t[(un&240)>>4]+$t[un&15])}return Vt.join("")}return{toBytes:We,fromBytes:dn}})(),we={16:10,24:12,32:14},Te=[1,2,4,8,16,32,64,128,27,54,108,216,171,77,154,47,94,188,99,198,151,53,106,212,179,125,250,239,197,145],Ne=[99,124,119,123,242,107,111,197,48,1,103,43,254,215,171,118,202,130,201,125,250,89,71,240,173,212,162,175,156,164,114,192,183,253,147,38,54,63,247,204,52,165,229,241,113,216,49,21,4,199,35,195,24,150,5,154,7,18,128,226,235,39,178,117,9,131,44,26,27,110,90,160,82,59,214,179,41,227,47,132,83,209,0,237,32,252,177,91,106,203,190,57,74,76,88,207,208,239,170,251,67,77,51,133,69,249,2,127,80,60,159,168,81,163,64,143,146,157,56,245,188,182,218,33,16,255,243,210,205,12,19,236,95,151,68,23,196,167,126,61,100,93,25,115,96,129,79,220,34,42,144,136,70,238,184,20,222,94,11,219,224,50,58,10,73,6,36,92,194,211,172,98,145,149,228,121,231,200,55,109,141,213,78,169,108,86,244,234,101,122,174,8,186,120,37,46,28,166,180,198,232,221,116,31,75,189,139,138,112,62,181,102,72,3,246,14,97,53,87,185,134,193,29,158,225,248,152,17,105,217,142,148,155,30,135,233,206,85,40,223,140,161,137,13,191,230,66,104,65,153,45,15,176,84,187,22],qe=[82,9,106,213,48,54,165,56,191,64,163,158,129,243,215,251,124,227,57,130,155,47,255,135,52,142,67,68,196,222,233,203,84,123,148,50,166,194,35,61,238,76,149,11,66,250,195,78,8,46,161,102,40,217,36,178,118,91,162,73,109,139,209,37,114,248,246,100,134,104,152,22,212,164,92,204,93,101,182,146,108,112,72,80,253,237,185,218,94,21,70,87,167,141,157,132,144,216,171,0,140,188,211,10,247,228,88,5,184,179,69,6,208,44,30,143,202,63,15,2,193,175,189,3,1,19,138,107,58,145,17,65,79,103,220,234,151,242,207,206,240,180,230,115,150,172,116,34,231,173,53,133,226,249,55,232,28,117,223,110,71,241,26,113,29,41,197,137,111,183,98,14,170,24,190,27,252,86,62,75,198,210,121,32,154,219,192,254,120,205,90,244,31,221,168,51,136,7,199,49,177,18,16,89,39,128,236,95,96,81,127,169,25,181,74,13,45,229,122,159,147,201,156,239,160,224,59,77,174,42,245,176,200,235,187,60,131,83,153,97,23,43,4,126,186,119,214,38,225,105,20,99,85,33,12,125],ze=[3328402341,4168907908,4000806809,4135287693,4294111757,3597364157,3731845041,2445657428,1613770832,33620227,3462883241,1445669757,3892248089,3050821474,1303096294,3967186586,2412431941,528646813,2311702848,4202528135,4026202645,2992200171,2387036105,4226871307,1101901292,3017069671,1604494077,1169141738,597466303,1403299063,3832705686,2613100635,1974974402,3791519004,1033081774,1277568618,1815492186,2118074177,4126668546,2211236943,1748251740,1369810420,3521504564,4193382664,3799085459,2883115123,1647391059,706024767,134480908,2512897874,1176707941,2646852446,806885416,932615841,168101135,798661301,235341577,605164086,461406363,3756188221,3454790438,1311188841,2142417613,3933566367,302582043,495158174,1479289972,874125870,907746093,3698224818,3025820398,1537253627,2756858614,1983593293,3084310113,2108928974,1378429307,3722699582,1580150641,327451799,2790478837,3117535592,0,3253595436,1075847264,3825007647,2041688520,3059440621,3563743934,2378943302,1740553945,1916352843,2487896798,2555137236,2958579944,2244988746,3151024235,3320835882,1336584933,3992714006,2252555205,2588757463,1714631509,293963156,2319795663,3925473552,67240454,4269768577,2689618160,2017213508,631218106,1269344483,2723238387,1571005438,2151694528,93294474,1066570413,563977660,1882732616,4059428100,1673313503,2008463041,2950355573,1109467491,537923632,3858759450,4260623118,3218264685,2177748300,403442708,638784309,3287084079,3193921505,899127202,2286175436,773265209,2479146071,1437050866,4236148354,2050833735,3362022572,3126681063,840505643,3866325909,3227541664,427917720,2655997905,2749160575,1143087718,1412049534,999329963,193497219,2353415882,3354324521,1807268051,672404540,2816401017,3160301282,369822493,2916866934,3688947771,1681011286,1949973070,336202270,2454276571,201721354,1210328172,3093060836,2680341085,3184776046,1135389935,3294782118,965841320,831886756,3554993207,4068047243,3588745010,2345191491,1849112409,3664604599,26054028,2983581028,2622377682,1235855840,3630984372,2891339514,4092916743,3488279077,3395642799,4101667470,1202630377,268961816,1874508501,4034427016,1243948399,1546530418,941366308,1470539505,1941222599,2546386513,3421038627,2715671932,3899946140,1042226977,2521517021,1639824860,227249030,260737669,3765465232,2084453954,1907733956,3429263018,2420656344,100860677,4160157185,470683154,3261161891,1781871967,2924959737,1773779408,394692241,2579611992,974986535,664706745,3655459128,3958962195,731420851,571543859,3530123707,2849626480,126783113,865375399,765172662,1008606754,361203602,3387549984,2278477385,2857719295,1344809080,2782912378,59542671,1503764984,160008576,437062935,1707065306,3622233649,2218934982,3496503480,2185314755,697932208,1512910199,504303377,2075177163,2824099068,1841019862,739644986],He=[2781242211,2230877308,2582542199,2381740923,234877682,3184946027,2984144751,1418839493,1348481072,50462977,2848876391,2102799147,434634494,1656084439,3863849899,2599188086,1167051466,2636087938,1082771913,2281340285,368048890,3954334041,3381544775,201060592,3963727277,1739838676,4250903202,3930435503,3206782108,4149453988,2531553906,1536934080,3262494647,484572669,2923271059,1783375398,1517041206,1098792767,49674231,1334037708,1550332980,4098991525,886171109,150598129,2481090929,1940642008,1398944049,1059722517,201851908,1385547719,1699095331,1587397571,674240536,2704774806,252314885,3039795866,151914247,908333586,2602270848,1038082786,651029483,1766729511,3447698098,2682942837,454166793,2652734339,1951935532,775166490,758520603,3000790638,4004797018,4217086112,4137964114,1299594043,1639438038,3464344499,2068982057,1054729187,1901997871,2534638724,4121318227,1757008337,0,750906861,1614815264,535035132,3363418545,3988151131,3201591914,1183697867,3647454910,1265776953,3734260298,3566750796,3903871064,1250283471,1807470800,717615087,3847203498,384695291,3313910595,3617213773,1432761139,2484176261,3481945413,283769337,100925954,2180939647,4037038160,1148730428,3123027871,3813386408,4087501137,4267549603,3229630528,2315620239,2906624658,3156319645,1215313976,82966005,3747855548,3245848246,1974459098,1665278241,807407632,451280895,251524083,1841287890,1283575245,337120268,891687699,801369324,3787349855,2721421207,3431482436,959321879,1469301956,4065699751,2197585534,1199193405,2898814052,3887750493,724703513,2514908019,2696962144,2551808385,3516813135,2141445340,1715741218,2119445034,2872807568,2198571144,3398190662,700968686,3547052216,1009259540,2041044702,3803995742,487983883,1991105499,1004265696,1449407026,1316239930,504629770,3683797321,168560134,1816667172,3837287516,1570751170,1857934291,4014189740,2797888098,2822345105,2754712981,936633572,2347923833,852879335,1133234376,1500395319,3084545389,2348912013,1689376213,3533459022,3762923945,3034082412,4205598294,133428468,634383082,2949277029,2398386810,3913789102,403703816,3580869306,2297460856,1867130149,1918643758,607656988,4049053350,3346248884,1368901318,600565992,2090982877,2632479860,557719327,3717614411,3697393085,2249034635,2232388234,2430627952,1115438654,3295786421,2865522278,3633334344,84280067,33027830,303828494,2747425121,1600795957,4188952407,3496589753,2434238086,1486471617,658119965,3106381470,953803233,334231800,3005978776,857870609,3151128937,1890179545,2298973838,2805175444,3056442267,574365214,2450884487,550103529,1233637070,4289353045,2018519080,2057691103,2399374476,4166623649,2148108681,387583245,3664101311,836232934,3330556482,3100665960,3280093505,2955516313,2002398509,287182607,3413881008,4238890068,3597515707,975967766],Ge=[1671808611,2089089148,2006576759,2072901243,4061003762,1807603307,1873927791,3310653893,810573872,16974337,1739181671,729634347,4263110654,3613570519,2883997099,1989864566,3393556426,2191335298,3376449993,2106063485,4195741690,1508618841,1204391495,4027317232,2917941677,3563566036,2734514082,2951366063,2629772188,2767672228,1922491506,3227229120,3082974647,4246528509,2477669779,644500518,911895606,1061256767,4144166391,3427763148,878471220,2784252325,3845444069,4043897329,1905517169,3631459288,827548209,356461077,67897348,3344078279,593839651,3277757891,405286936,2527147926,84871685,2595565466,118033927,305538066,2157648768,3795705826,3945188843,661212711,2999812018,1973414517,152769033,2208177539,745822252,439235610,455947803,1857215598,1525593178,2700827552,1391895634,994932283,3596728278,3016654259,695947817,3812548067,795958831,2224493444,1408607827,3513301457,0,3979133421,543178784,4229948412,2982705585,1542305371,1790891114,3410398667,3201918910,961245753,1256100938,1289001036,1491644504,3477767631,3496721360,4012557807,2867154858,4212583931,1137018435,1305975373,861234739,2241073541,1171229253,4178635257,33948674,2139225727,1357946960,1011120188,2679776671,2833468328,1374921297,2751356323,1086357568,2408187279,2460827538,2646352285,944271416,4110742005,3168756668,3066132406,3665145818,560153121,271589392,4279952895,4077846003,3530407890,3444343245,202643468,322250259,3962553324,1608629855,2543990167,1154254916,389623319,3294073796,2817676711,2122513534,1028094525,1689045092,1575467613,422261273,1939203699,1621147744,2174228865,1339137615,3699352540,577127458,712922154,2427141008,2290289544,1187679302,3995715566,3100863416,339486740,3732514782,1591917662,186455563,3681988059,3762019296,844522546,978220090,169743370,1239126601,101321734,611076132,1558493276,3260915650,3547250131,2901361580,1655096418,2443721105,2510565781,3828863972,2039214713,3878868455,3359869896,928607799,1840765549,2374762893,3580146133,1322425422,2850048425,1823791212,1459268694,4094161908,3928346602,1706019429,2056189050,2934523822,135794696,3134549946,2022240376,628050469,779246638,472135708,2800834470,3032970164,3327236038,3894660072,3715932637,1956440180,522272287,1272813131,3185336765,2340818315,2323976074,1888542832,1044544574,3049550261,1722469478,1222152264,50660867,4127324150,236067854,1638122081,895445557,1475980887,3117443513,2257655686,3243809217,489110045,2662934430,3778599393,4162055160,2561878936,288563729,1773916777,3648039385,2391345038,2493985684,2612407707,505560094,2274497927,3911240169,3460925390,1442818645,678973480,3749357023,2358182796,2717407649,2306869641,219617805,3218761151,3862026214,1120306242,1756942440,1103331905,2578459033,762796589,252780047,2966125488,1425844308,3151392187,372911126],Ze=[1667474886,2088535288,2004326894,2071694838,4075949567,1802223062,1869591006,3318043793,808472672,16843522,1734846926,724270422,4278065639,3621216949,2880169549,1987484396,3402253711,2189597983,3385409673,2105378810,4210693615,1499065266,1195886990,4042263547,2913856577,3570689971,2728590687,2947541573,2627518243,2762274643,1920112356,3233831835,3082273397,4261223649,2475929149,640051788,909531756,1061110142,4160160501,3435941763,875846760,2779116625,3857003729,4059105529,1903268834,3638064043,825316194,353713962,67374088,3351728789,589522246,3284360861,404236336,2526454071,84217610,2593830191,117901582,303183396,2155911963,3806477791,3958056653,656894286,2998062463,1970642922,151591698,2206440989,741110872,437923380,454765878,1852748508,1515908788,2694904667,1381168804,993742198,3604373943,3014905469,690584402,3823320797,791638366,2223281939,1398011302,3520161977,0,3991743681,538992704,4244381667,2981218425,1532751286,1785380564,3419096717,3200178535,960056178,1246420628,1280103576,1482221744,3486468741,3503319995,4025428677,2863326543,4227536621,1128514950,1296947098,859002214,2240123921,1162203018,4193849577,33687044,2139062782,1347481760,1010582648,2678045221,2829640523,1364325282,2745433693,1077985408,2408548869,2459086143,2644360225,943212656,4126475505,3166494563,3065430391,3671750063,555836226,269496352,4294908645,4092792573,3537006015,3452783745,202118168,320025894,3974901699,1600119230,2543297077,1145359496,387397934,3301201811,2812801621,2122220284,1027426170,1684319432,1566435258,421079858,1936954854,1616945344,2172753945,1330631070,3705438115,572679748,707427924,2425400123,2290647819,1179044492,4008585671,3099120491,336870440,3739122087,1583276732,185277718,3688593069,3772791771,842159716,976899700,168435220,1229577106,101059084,606366792,1549591736,3267517855,3553849021,2897014595,1650632388,2442242105,2509612081,3840161747,2038008818,3890688725,3368567691,926374254,1835907034,2374863873,3587531953,1313788572,2846482505,1819063512,1448540844,4109633523,3941213647,1701162954,2054852340,2930698567,134748176,3132806511,2021165296,623210314,774795868,471606328,2795958615,3031746419,3334885783,3907527627,3722280097,1953799400,522133822,1263263126,3183336545,2341176845,2324333839,1886425312,1044267644,3048588401,1718004428,1212733584,50529542,4143317495,235803164,1633788866,892690282,1465383342,3115962473,2256965911,3250673817,488449850,2661202215,3789633753,4177007595,2560144171,286339874,1768537042,3654906025,2391705863,2492770099,2610673197,505291324,2273808917,3924369609,3469625735,1431699370,673740880,3755965093,2358021891,2711746649,2307489801,218961690,3217021541,3873845719,1111672452,1751693520,1094828930,2576986153,757954394,252645662,2964376443,1414855848,3149649517,370555436],Ye=[1374988112,2118214995,437757123,975658646,1001089995,530400753,2902087851,1273168787,540080725,2910219766,2295101073,4110568485,1340463100,3307916247,641025152,3043140495,3736164937,632953703,1172967064,1576976609,3274667266,2169303058,2370213795,1809054150,59727847,361929877,3211623147,2505202138,3569255213,1484005843,1239443753,2395588676,1975683434,4102977912,2572697195,666464733,3202437046,4035489047,3374361702,2110667444,1675577880,3843699074,2538681184,1649639237,2976151520,3144396420,4269907996,4178062228,1883793496,2403728665,2497604743,1383856311,2876494627,1917518562,3810496343,1716890410,3001755655,800440835,2261089178,3543599269,807962610,599762354,33778362,3977675356,2328828971,2809771154,4077384432,1315562145,1708848333,101039829,3509871135,3299278474,875451293,2733856160,92987698,2767645557,193195065,1080094634,1584504582,3178106961,1042385657,2531067453,3711829422,1306967366,2438237621,1908694277,67556463,1615861247,429456164,3602770327,2302690252,1742315127,2968011453,126454664,3877198648,2043211483,2709260871,2084704233,4169408201,0,159417987,841739592,504459436,1817866830,4245618683,260388950,1034867998,908933415,168810852,1750902305,2606453969,607530554,202008497,2472011535,3035535058,463180190,2160117071,1641816226,1517767529,470948374,3801332234,3231722213,1008918595,303765277,235474187,4069246893,766945465,337553864,1475418501,2943682380,4003061179,2743034109,4144047775,1551037884,1147550661,1543208500,2336434550,3408119516,3069049960,3102011747,3610369226,1113818384,328671808,2227573024,2236228733,3535486456,2935566865,3341394285,496906059,3702665459,226906860,2009195472,733156972,2842737049,294930682,1206477858,2835123396,2700099354,1451044056,573804783,2269728455,3644379585,2362090238,2564033334,2801107407,2776292904,3669462566,1068351396,742039012,1350078989,1784663195,1417561698,4136440770,2430122216,775550814,2193862645,2673705150,1775276924,1876241833,3475313331,3366754619,270040487,3902563182,3678124923,3441850377,1851332852,3969562369,2203032232,3868552805,2868897406,566021896,4011190502,3135740889,1248802510,3936291284,699432150,832877231,708780849,3332740144,899835584,1951317047,4236429990,3767586992,866637845,4043610186,1106041591,2144161806,395441711,1984812685,1139781709,3433712980,3835036895,2664543715,1282050075,3240894392,1181045119,2640243204,25965917,4203181171,4211818798,3009879386,2463879762,3910161971,1842759443,2597806476,933301370,1509430414,3943906441,3467192302,3076639029,3776767469,2051518780,2631065433,1441952575,404016761,1942435775,1408749034,1610459739,3745345300,2017778566,3400528769,3110650942,941896748,3265478751,371049330,3168937228,675039627,4279080257,967311729,135050206,3635733660,1683407248,2076935265,3576870512,1215061108,3501741890],Ft=[1347548327,1400783205,3273267108,2520393566,3409685355,4045380933,2880240216,2471224067,1428173050,4138563181,2441661558,636813900,4233094615,3620022987,2149987652,2411029155,1239331162,1730525723,2554718734,3781033664,46346101,310463728,2743944855,3328955385,3875770207,2501218972,3955191162,3667219033,768917123,3545789473,692707433,1150208456,1786102409,2029293177,1805211710,3710368113,3065962831,401639597,1724457132,3028143674,409198410,2196052529,1620529459,1164071807,3769721975,2226875310,486441376,2499348523,1483753576,428819965,2274680428,3075636216,598438867,3799141122,1474502543,711349675,129166120,53458370,2592523643,2782082824,4063242375,2988687269,3120694122,1559041666,730517276,2460449204,4042459122,2706270690,3446004468,3573941694,533804130,2328143614,2637442643,2695033685,839224033,1973745387,957055980,2856345839,106852767,1371368976,4181598602,1033297158,2933734917,1179510461,3046200461,91341917,1862534868,4284502037,605657339,2547432937,3431546947,2003294622,3182487618,2282195339,954669403,3682191598,1201765386,3917234703,3388507166,0,2198438022,1211247597,2887651696,1315723890,4227665663,1443857720,507358933,657861945,1678381017,560487590,3516619604,975451694,2970356327,261314535,3535072918,2652609425,1333838021,2724322336,1767536459,370938394,182621114,3854606378,1128014560,487725847,185469197,2918353863,3106780840,3356761769,2237133081,1286567175,3152976349,4255350624,2683765030,3160175349,3309594171,878443390,1988838185,3704300486,1756818940,1673061617,3403100636,272786309,1075025698,545572369,2105887268,4174560061,296679730,1841768865,1260232239,4091327024,3960309330,3497509347,1814803222,2578018489,4195456072,575138148,3299409036,446754879,3629546796,4011996048,3347532110,3252238545,4270639778,915985419,3483825537,681933534,651868046,2755636671,3828103837,223377554,2607439820,1649704518,3270937875,3901806776,1580087799,4118987695,3198115200,2087309459,2842678573,3016697106,1003007129,2802849917,1860738147,2077965243,164439672,4100872472,32283319,2827177882,1709610350,2125135846,136428751,3874428392,3652904859,3460984630,3572145929,3593056380,2939266226,824852259,818324884,3224740454,930369212,2801566410,2967507152,355706840,1257309336,4148292826,243256656,790073846,2373340630,1296297904,1422699085,3756299780,3818836405,457992840,3099667487,2135319889,77422314,1560382517,1945798516,788204353,1521706781,1385356242,870912086,325965383,2358957921,2050466060,2388260884,2313884476,4006521127,901210569,3990953189,1014646705,1503449823,1062597235,2031621326,3212035895,3931371469,1533017514,350174575,2256028891,2177544179,1052338372,741876788,1606591296,1914052035,213705253,2334669897,1107234197,1899603969,3725069491,2631447780,2422494913,1635502980,1893020342,1950903388,1120974935],Mt=[2807058932,1699970625,2764249623,1586903591,1808481195,1173430173,1487645946,59984867,4199882800,1844882806,1989249228,1277555970,3623636965,3419915562,1149249077,2744104290,1514790577,459744698,244860394,3235995134,1963115311,4027744588,2544078150,4190530515,1608975247,2627016082,2062270317,1507497298,2200818878,567498868,1764313568,3359936201,2305455554,2037970062,1047239e3,1910319033,1337376481,2904027272,2892417312,984907214,1243112415,830661914,861968209,2135253587,2011214180,2927934315,2686254721,731183368,1750626376,4246310725,1820824798,4172763771,3542330227,48394827,2404901663,2871682645,671593195,3254988725,2073724613,145085239,2280796200,2779915199,1790575107,2187128086,472615631,3029510009,4075877127,3802222185,4107101658,3201631749,1646252340,4270507174,1402811438,1436590835,3778151818,3950355702,3963161475,4020912224,2667994737,273792366,2331590177,104699613,95345982,3175501286,2377486676,1560637892,3564045318,369057872,4213447064,3919042237,1137477952,2658625497,1119727848,2340947849,1530455833,4007360968,172466556,266959938,516552836,0,2256734592,3980931627,1890328081,1917742170,4294704398,945164165,3575528878,958871085,3647212047,2787207260,1423022939,775562294,1739656202,3876557655,2530391278,2443058075,3310321856,547512796,1265195639,437656594,3121275539,719700128,3762502690,387781147,218828297,3350065803,2830708150,2848461854,428169201,122466165,3720081049,1627235199,648017665,4122762354,1002783846,2117360635,695634755,3336358691,4234721005,4049844452,3704280881,2232435299,574624663,287343814,612205898,1039717051,840019705,2708326185,793451934,821288114,1391201670,3822090177,376187827,3113855344,1224348052,1679968233,2361698556,1058709744,752375421,2431590963,1321699145,3519142200,2734591178,188127444,2177869557,3727205754,2384911031,3215212461,2648976442,2450346104,3432737375,1180849278,331544205,3102249176,4150144569,2952102595,2159976285,2474404304,766078933,313773861,2570832044,2108100632,1668212892,3145456443,2013908262,418672217,3070356634,2594734927,1852171925,3867060991,3473416636,3907448597,2614737639,919489135,164948639,2094410160,2997825956,590424639,2486224549,1723872674,3157750862,3399941250,3501252752,3625268135,2555048196,3673637356,1343127501,4130281361,3599595085,2957853679,1297403050,81781910,3051593425,2283490410,532201772,1367295589,3926170974,895287692,1953757831,1093597963,492483431,3528626907,1446242576,1192455638,1636604631,209336225,344873464,1015671571,669961897,3375740769,3857572124,2973530695,3747192018,1933530610,3464042516,935293895,3454686199,2858115069,1863638845,3683022916,4085369519,3292445032,875313188,1080017571,3279033885,621591778,1233856572,2504130317,24197544,3017672716,3835484340,3247465558,2220981195,3060847922,1551124588,1463996600],Zt=[4104605777,1097159550,396673818,660510266,2875968315,2638606623,4200115116,3808662347,821712160,1986918061,3430322568,38544885,3856137295,718002117,893681702,1654886325,2975484382,3122358053,3926825029,4274053469,796197571,1290801793,1184342925,3556361835,2405426947,2459735317,1836772287,1381620373,3196267988,1948373848,3764988233,3385345166,3263785589,2390325492,1480485785,3111247143,3780097726,2293045232,548169417,3459953789,3746175075,439452389,1362321559,1400849762,1685577905,1806599355,2174754046,137073913,1214797936,1174215055,3731654548,2079897426,1943217067,1258480242,529487843,1437280870,3945269170,3049390895,3313212038,923313619,679998e3,3215307299,57326082,377642221,3474729866,2041877159,133361907,1776460110,3673476453,96392454,878845905,2801699524,777231668,4082475170,2330014213,4142626212,2213296395,1626319424,1906247262,1846563261,562755902,3708173718,1040559837,3871163981,1418573201,3294430577,114585348,1343618912,2566595609,3186202582,1078185097,3651041127,3896688048,2307622919,425408743,3371096953,2081048481,1108339068,2216610296,0,2156299017,736970802,292596766,1517440620,251657213,2235061775,2933202493,758720310,265905162,1554391400,1532285339,908999204,174567692,1474760595,4002861748,2610011675,3234156416,3693126241,2001430874,303699484,2478443234,2687165888,585122620,454499602,151849742,2345119218,3064510765,514443284,4044981591,1963412655,2581445614,2137062819,19308535,1928707164,1715193156,4219352155,1126790795,600235211,3992742070,3841024952,836553431,1669664834,2535604243,3323011204,1243905413,3141400786,4180808110,698445255,2653899549,2989552604,2253581325,3252932727,3004591147,1891211689,2487810577,3915653703,4237083816,4030667424,2100090966,865136418,1229899655,953270745,3399679628,3557504664,4118925222,2061379749,3079546586,2915017791,983426092,2022837584,1607244650,2118541908,2366882550,3635996816,972512814,3283088770,1568718495,3499326569,3576539503,621982671,2895723464,410887952,2623762152,1002142683,645401037,1494807662,2595684844,1335535747,2507040230,4293295786,3167684641,367585007,3885750714,1865862730,2668221674,2960971305,2763173681,1059270954,2777952454,2724642869,1320957812,2194319100,2429595872,2815956275,77089521,3973773121,3444575871,2448830231,1305906550,4021308739,2857194700,2516901860,3518358430,1787304780,740276417,1699839814,1592394909,2352307457,2272556026,188821243,1729977011,3687994002,274084841,3594982253,3613494426,2701949495,4162096729,322734571,2837966542,1640576439,484830689,1202797690,3537852828,4067639125,349075736,3342319475,4157467219,4255800159,1030690015,1155237496,2951971274,1757691577,607398968,2738905026,499347990,3794078908,1011452712,227885567,2818666809,213114376,3034881240,1455525988,3414450555,850817237,1817998408,3092726480],cn=[0,235474187,470948374,303765277,941896748,908933415,607530554,708780849,1883793496,2118214995,1817866830,1649639237,1215061108,1181045119,1417561698,1517767529,3767586992,4003061179,4236429990,4069246893,3635733660,3602770327,3299278474,3400528769,2430122216,2664543715,2362090238,2193862645,2835123396,2801107407,3035535058,3135740889,3678124923,3576870512,3341394285,3374361702,3810496343,3977675356,4279080257,4043610186,2876494627,2776292904,3076639029,3110650942,2472011535,2640243204,2403728665,2169303058,1001089995,899835584,666464733,699432150,59727847,226906860,530400753,294930682,1273168787,1172967064,1475418501,1509430414,1942435775,2110667444,1876241833,1641816226,2910219766,2743034109,2976151520,3211623147,2505202138,2606453969,2302690252,2269728455,3711829422,3543599269,3240894392,3475313331,3843699074,3943906441,4178062228,4144047775,1306967366,1139781709,1374988112,1610459739,1975683434,2076935265,1775276924,1742315127,1034867998,866637845,566021896,800440835,92987698,193195065,429456164,395441711,1984812685,2017778566,1784663195,1683407248,1315562145,1080094634,1383856311,1551037884,101039829,135050206,437757123,337553864,1042385657,807962610,573804783,742039012,2531067453,2564033334,2328828971,2227573024,2935566865,2700099354,3001755655,3168937228,3868552805,3902563182,4203181171,4102977912,3736164937,3501741890,3265478751,3433712980,1106041591,1340463100,1576976609,1408749034,2043211483,2009195472,1708848333,1809054150,832877231,1068351396,766945465,599762354,159417987,126454664,361929877,463180190,2709260871,2943682380,3178106961,3009879386,2572697195,2538681184,2236228733,2336434550,3509871135,3745345300,3441850377,3274667266,3910161971,3877198648,4110568485,4211818798,2597806476,2497604743,2261089178,2295101073,2733856160,2902087851,3202437046,2968011453,3936291284,3835036895,4136440770,4169408201,3535486456,3702665459,3467192302,3231722213,2051518780,1951317047,1716890410,1750902305,1113818384,1282050075,1584504582,1350078989,168810852,67556463,371049330,404016761,841739592,1008918595,775550814,540080725,3969562369,3801332234,4035489047,4269907996,3569255213,3669462566,3366754619,3332740144,2631065433,2463879762,2160117071,2395588676,2767645557,2868897406,3102011747,3069049960,202008497,33778362,270040487,504459436,875451293,975658646,675039627,641025152,2084704233,1917518562,1615861247,1851332852,1147550661,1248802510,1484005843,1451044056,933301370,967311729,733156972,632953703,260388950,25965917,328671808,496906059,1206477858,1239443753,1543208500,1441952575,2144161806,1908694277,1675577880,1842759443,3610369226,3644379585,3408119516,3307916247,4011190502,3776767469,4077384432,4245618683,2809771154,2842737049,3144396420,3043140495,2673705150,2438237621,2203032232,2370213795],hn=[0,185469197,370938394,487725847,741876788,657861945,975451694,824852259,1483753576,1400783205,1315723890,1164071807,1950903388,2135319889,1649704518,1767536459,2967507152,3152976349,2801566410,2918353863,2631447780,2547432937,2328143614,2177544179,3901806776,3818836405,4270639778,4118987695,3299409036,3483825537,3535072918,3652904859,2077965243,1893020342,1841768865,1724457132,1474502543,1559041666,1107234197,1257309336,598438867,681933534,901210569,1052338372,261314535,77422314,428819965,310463728,3409685355,3224740454,3710368113,3593056380,3875770207,3960309330,4045380933,4195456072,2471224067,2554718734,2237133081,2388260884,3212035895,3028143674,2842678573,2724322336,4138563181,4255350624,3769721975,3955191162,3667219033,3516619604,3431546947,3347532110,2933734917,2782082824,3099667487,3016697106,2196052529,2313884476,2499348523,2683765030,1179510461,1296297904,1347548327,1533017514,1786102409,1635502980,2087309459,2003294622,507358933,355706840,136428751,53458370,839224033,957055980,605657339,790073846,2373340630,2256028891,2607439820,2422494913,2706270690,2856345839,3075636216,3160175349,3573941694,3725069491,3273267108,3356761769,4181598602,4063242375,4011996048,3828103837,1033297158,915985419,730517276,545572369,296679730,446754879,129166120,213705253,1709610350,1860738147,1945798516,2029293177,1239331162,1120974935,1606591296,1422699085,4148292826,4233094615,3781033664,3931371469,3682191598,3497509347,3446004468,3328955385,2939266226,2755636671,3106780840,2988687269,2198438022,2282195339,2501218972,2652609425,1201765386,1286567175,1371368976,1521706781,1805211710,1620529459,2105887268,1988838185,533804130,350174575,164439672,46346101,870912086,954669403,636813900,788204353,2358957921,2274680428,2592523643,2441661558,2695033685,2880240216,3065962831,3182487618,3572145929,3756299780,3270937875,3388507166,4174560061,4091327024,4006521127,3854606378,1014646705,930369212,711349675,560487590,272786309,457992840,106852767,223377554,1678381017,1862534868,1914052035,2031621326,1211247597,1128014560,1580087799,1428173050,32283319,182621114,401639597,486441376,768917123,651868046,1003007129,818324884,1503449823,1385356242,1333838021,1150208456,1973745387,2125135846,1673061617,1756818940,2970356327,3120694122,2802849917,2887651696,2637442643,2520393566,2334669897,2149987652,3917234703,3799141122,4284502037,4100872472,3309594171,3460984630,3545789473,3629546796,2050466060,1899603969,1814803222,1730525723,1443857720,1560382517,1075025698,1260232239,575138148,692707433,878443390,1062597235,243256656,91341917,409198410,325965383,3403100636,3252238545,3704300486,3620022987,3874428392,3990953189,4042459122,4227665663,2460449204,2578018489,2226875310,2411029155,3198115200,3046200461,2827177882,2743944855],yn=[0,218828297,437656594,387781147,875313188,958871085,775562294,590424639,1750626376,1699970625,1917742170,2135253587,1551124588,1367295589,1180849278,1265195639,3501252752,3720081049,3399941250,3350065803,3835484340,3919042237,4270507174,4085369519,3102249176,3051593425,2734591178,2952102595,2361698556,2177869557,2530391278,2614737639,3145456443,3060847922,2708326185,2892417312,2404901663,2187128086,2504130317,2555048196,3542330227,3727205754,3375740769,3292445032,3876557655,3926170974,4246310725,4027744588,1808481195,1723872674,1910319033,2094410160,1608975247,1391201670,1173430173,1224348052,59984867,244860394,428169201,344873464,935293895,984907214,766078933,547512796,1844882806,1627235199,2011214180,2062270317,1507497298,1423022939,1137477952,1321699145,95345982,145085239,532201772,313773861,830661914,1015671571,731183368,648017665,3175501286,2957853679,2807058932,2858115069,2305455554,2220981195,2474404304,2658625497,3575528878,3625268135,3473416636,3254988725,3778151818,3963161475,4213447064,4130281361,3599595085,3683022916,3432737375,3247465558,3802222185,4020912224,4172763771,4122762354,3201631749,3017672716,2764249623,2848461854,2331590177,2280796200,2431590963,2648976442,104699613,188127444,472615631,287343814,840019705,1058709744,671593195,621591778,1852171925,1668212892,1953757831,2037970062,1514790577,1463996600,1080017571,1297403050,3673637356,3623636965,3235995134,3454686199,4007360968,3822090177,4107101658,4190530515,2997825956,3215212461,2830708150,2779915199,2256734592,2340947849,2627016082,2443058075,172466556,122466165,273792366,492483431,1047239e3,861968209,612205898,695634755,1646252340,1863638845,2013908262,1963115311,1446242576,1530455833,1277555970,1093597963,1636604631,1820824798,2073724613,1989249228,1436590835,1487645946,1337376481,1119727848,164948639,81781910,331544205,516552836,1039717051,821288114,669961897,719700128,2973530695,3157750862,2871682645,2787207260,2232435299,2283490410,2667994737,2450346104,3647212047,3564045318,3279033885,3464042516,3980931627,3762502690,4150144569,4199882800,3070356634,3121275539,2904027272,2686254721,2200818878,2384911031,2570832044,2486224549,3747192018,3528626907,3310321856,3359936201,3950355702,3867060991,4049844452,4234721005,1739656202,1790575107,2108100632,1890328081,1402811438,1586903591,1233856572,1149249077,266959938,48394827,369057872,418672217,1002783846,919489135,567498868,752375421,209336225,24197544,376187827,459744698,945164165,895287692,574624663,793451934,1679968233,1764313568,2117360635,1933530610,1343127501,1560637892,1243112415,1192455638,3704280881,3519142200,3336358691,3419915562,3907448597,3857572124,4075877127,4294704398,3029510009,3113855344,2927934315,2744104290,2159976285,2377486676,2594734927,2544078150],Ht=[0,151849742,303699484,454499602,607398968,758720310,908999204,1059270954,1214797936,1097159550,1517440620,1400849762,1817998408,1699839814,2118541908,2001430874,2429595872,2581445614,2194319100,2345119218,3034881240,3186202582,2801699524,2951971274,3635996816,3518358430,3399679628,3283088770,4237083816,4118925222,4002861748,3885750714,1002142683,850817237,698445255,548169417,529487843,377642221,227885567,77089521,1943217067,2061379749,1640576439,1757691577,1474760595,1592394909,1174215055,1290801793,2875968315,2724642869,3111247143,2960971305,2405426947,2253581325,2638606623,2487810577,3808662347,3926825029,4044981591,4162096729,3342319475,3459953789,3576539503,3693126241,1986918061,2137062819,1685577905,1836772287,1381620373,1532285339,1078185097,1229899655,1040559837,923313619,740276417,621982671,439452389,322734571,137073913,19308535,3871163981,4021308739,4104605777,4255800159,3263785589,3414450555,3499326569,3651041127,2933202493,2815956275,3167684641,3049390895,2330014213,2213296395,2566595609,2448830231,1305906550,1155237496,1607244650,1455525988,1776460110,1626319424,2079897426,1928707164,96392454,213114376,396673818,514443284,562755902,679998e3,865136418,983426092,3708173718,3557504664,3474729866,3323011204,4180808110,4030667424,3945269170,3794078908,2507040230,2623762152,2272556026,2390325492,2975484382,3092726480,2738905026,2857194700,3973773121,3856137295,4274053469,4157467219,3371096953,3252932727,3673476453,3556361835,2763173681,2915017791,3064510765,3215307299,2156299017,2307622919,2459735317,2610011675,2081048481,1963412655,1846563261,1729977011,1480485785,1362321559,1243905413,1126790795,878845905,1030690015,645401037,796197571,274084841,425408743,38544885,188821243,3613494426,3731654548,3313212038,3430322568,4082475170,4200115116,3780097726,3896688048,2668221674,2516901860,2366882550,2216610296,3141400786,2989552604,2837966542,2687165888,1202797690,1320957812,1437280870,1554391400,1669664834,1787304780,1906247262,2022837584,265905162,114585348,499347990,349075736,736970802,585122620,972512814,821712160,2595684844,2478443234,2293045232,2174754046,3196267988,3079546586,2895723464,2777952454,3537852828,3687994002,3234156416,3385345166,4142626212,4293295786,3841024952,3992742070,174567692,57326082,410887952,292596766,777231668,660510266,1011452712,893681702,1108339068,1258480242,1343618912,1494807662,1715193156,1865862730,1948373848,2100090966,2701949495,2818666809,3004591147,3122358053,2235061775,2352307457,2535604243,2653899549,3915653703,3764988233,4219352155,4067639125,3444575871,3294430577,3746175075,3594982253,836553431,953270745,600235211,718002117,367585007,484830689,133361907,251657213,2041877159,1891211689,1806599355,1654886325,1568718495,1418573201,1335535747,1184342925];function Sn(We){for(var $t=[],dn=0;dn<We.length;dn+=4)$t.push(We[dn]<<24|We[dn+1]<<16|We[dn+2]<<8|We[dn+3]);return $t}var le=function(We){if(!(this instanceof le))throw Error("AES must be instanitated with `new`");Object.defineProperty(this,"key",{value:ae(We,!0)}),this._prepare()};le.prototype._prepare=function(){var We=we[this.key.length];if(We==null)throw new Error("invalid key size (must be 16, 24 or 32 bytes)");this._Ke=[],this._Kd=[];for(var $t=0;$t<=We;$t++)this._Ke.push([0,0,0,0]),this._Kd.push([0,0,0,0]);for(var dn=(We+1)*4,gn=this.key.length/4,Vt=Sn(this.key),Cn,$t=0;$t<gn;$t++)Cn=$t>>2,this._Ke[Cn][$t%4]=Vt[$t],this._Kd[We-Cn][$t%4]=Vt[$t];for(var un=0,Pt=gn,mn;Pt<dn;){if(mn=Vt[gn-1],Vt[0]^=Ne[mn>>16&255]<<24^Ne[mn>>8&255]<<16^Ne[mn&255]<<8^Ne[mn>>24&255]^Te[un]<<24,un+=1,gn!=8)for(var $t=1;$t<gn;$t++)Vt[$t]^=Vt[$t-1];else{for(var $t=1;$t<gn/2;$t++)Vt[$t]^=Vt[$t-1];mn=Vt[gn/2-1],Vt[gn/2]^=Ne[mn&255]^Ne[mn>>8&255]<<8^Ne[mn>>16&255]<<16^Ne[mn>>24&255]<<24;for(var $t=gn/2+1;$t<gn;$t++)Vt[$t]^=Vt[$t-1]}for(var $t=0,Pn,wn;$t<gn&&Pt<dn;)Pn=Pt>>2,wn=Pt%4,this._Ke[Pn][wn]=Vt[$t],this._Kd[We-Pn][wn]=Vt[$t++],Pt++}for(var Pn=1;Pn<We;Pn++)for(var wn=0;wn<4;wn++)mn=this._Kd[Pn][wn],this._Kd[Pn][wn]=cn[mn>>24&255]^hn[mn>>16&255]^yn[mn>>8&255]^Ht[mn&255]},le.prototype.encrypt=function(We){if(We.length!=16)throw new Error("invalid plaintext size (must be 16 bytes)");for(var $t=this._Ke.length-1,dn=[0,0,0,0],gn=Sn(We),Vt=0;Vt<4;Vt++)gn[Vt]^=this._Ke[0][Vt];for(var Cn=1;Cn<$t;Cn++){for(var Vt=0;Vt<4;Vt++)dn[Vt]=ze[gn[Vt]>>24&255]^He[gn[(Vt+1)%4]>>16&255]^Ge[gn[(Vt+2)%4]>>8&255]^Ze[gn[(Vt+3)%4]&255]^this._Ke[Cn][Vt];gn=dn.slice()}for(var un=ue(16),Pt,Vt=0;Vt<4;Vt++)Pt=this._Ke[$t][Vt],un[4*Vt]=(Ne[gn[Vt]>>24&255]^Pt>>24)&255,un[4*Vt+1]=(Ne[gn[(Vt+1)%4]>>16&255]^Pt>>16)&255,un[4*Vt+2]=(Ne[gn[(Vt+2)%4]>>8&255]^Pt>>8)&255,un[4*Vt+3]=(Ne[gn[(Vt+3)%4]&255]^Pt)&255;return un},le.prototype.decrypt=function(We){if(We.length!=16)throw new Error("invalid ciphertext size (must be 16 bytes)");for(var $t=this._Kd.length-1,dn=[0,0,0,0],gn=Sn(We),Vt=0;Vt<4;Vt++)gn[Vt]^=this._Kd[0][Vt];for(var Cn=1;Cn<$t;Cn++){for(var Vt=0;Vt<4;Vt++)dn[Vt]=Ye[gn[Vt]>>24&255]^Ft[gn[(Vt+3)%4]>>16&255]^Mt[gn[(Vt+2)%4]>>8&255]^Zt[gn[(Vt+1)%4]&255]^this._Kd[Cn][Vt];gn=dn.slice()}for(var un=ue(16),Pt,Vt=0;Vt<4;Vt++)Pt=this._Kd[$t][Vt],un[4*Vt]=(qe[gn[Vt]>>24&255]^Pt>>24)&255,un[4*Vt+1]=(qe[gn[(Vt+3)%4]>>16&255]^Pt>>16)&255,un[4*Vt+2]=(qe[gn[(Vt+2)%4]>>8&255]^Pt>>8)&255,un[4*Vt+3]=(qe[gn[(Vt+1)%4]&255]^Pt)&255;return un};var pe=function(We){if(!(this instanceof pe))throw Error("AES must be instanitated with `new`");this.description="Electronic Code Block",this.name="ecb",this._aes=new le(We)};pe.prototype.encrypt=function(We){if(We=ae(We),We.length%16!==0)throw new Error("invalid plaintext size (must be multiple of 16 bytes)");for(var $t=ue(We.length),dn=ue(16),gn=0;gn<We.length;gn+=16)de(We,dn,0,gn,gn+16),dn=this._aes.encrypt(dn),de(dn,$t,gn);return $t},pe.prototype.decrypt=function(We){if(We=ae(We),We.length%16!==0)throw new Error("invalid ciphertext size (must be multiple of 16 bytes)");for(var $t=ue(We.length),dn=ue(16),gn=0;gn<We.length;gn+=16)de(We,dn,0,gn,gn+16),dn=this._aes.decrypt(dn),de(dn,$t,gn);return $t};var be=function(We,$t){if(!(this instanceof be))throw Error("AES must be instanitated with `new`");if(this.description="Cipher Block Chaining",this.name="cbc",!$t)$t=ue(16);else if($t.length!=16)throw new Error("invalid initialation vector size (must be 16 bytes)");this._lastCipherblock=ae($t,!0),this._aes=new le(We)};be.prototype.encrypt=function(We){if(We=ae(We),We.length%16!==0)throw new Error("invalid plaintext size (must be multiple of 16 bytes)");for(var $t=ue(We.length),dn=ue(16),gn=0;gn<We.length;gn+=16){de(We,dn,0,gn,gn+16);for(var Vt=0;Vt<16;Vt++)dn[Vt]^=this._lastCipherblock[Vt];this._lastCipherblock=this._aes.encrypt(dn),de(this._lastCipherblock,$t,gn)}return $t},be.prototype.decrypt=function(We){if(We=ae(We),We.length%16!==0)throw new Error("invalid ciphertext size (must be multiple of 16 bytes)");for(var $t=ue(We.length),dn=ue(16),gn=0;gn<We.length;gn+=16){de(We,dn,0,gn,gn+16),dn=this._aes.decrypt(dn);for(var Vt=0;Vt<16;Vt++)$t[gn+Vt]=dn[Vt]^this._lastCipherblock[Vt];de(We,this._lastCipherblock,0,gn,gn+16)}return $t};var xe=function(We,$t,dn){if(!(this instanceof xe))throw Error("AES must be instanitated with `new`");if(this.description="Cipher Feedback",this.name="cfb",!$t)$t=ue(16);else if($t.length!=16)throw new Error("invalid initialation vector size (must be 16 size)");dn||(dn=1),this.segmentSize=dn,this._shiftRegister=ae($t,!0),this._aes=new le(We)};xe.prototype.encrypt=function(We){if(We.length%this.segmentSize!=0)throw new Error("invalid plaintext size (must be segmentSize bytes)");for(var $t=ae(We,!0),dn,gn=0;gn<$t.length;gn+=this.segmentSize){dn=this._aes.encrypt(this._shiftRegister);for(var Vt=0;Vt<this.segmentSize;Vt++)$t[gn+Vt]^=dn[Vt];de(this._shiftRegister,this._shiftRegister,0,this.segmentSize),de($t,this._shiftRegister,16-this.segmentSize,gn,gn+this.segmentSize)}return $t},xe.prototype.decrypt=function(We){if(We.length%this.segmentSize!=0)throw new Error("invalid ciphertext size (must be segmentSize bytes)");for(var $t=ae(We,!0),dn,gn=0;gn<$t.length;gn+=this.segmentSize){dn=this._aes.encrypt(this._shiftRegister);for(var Vt=0;Vt<this.segmentSize;Vt++)$t[gn+Vt]^=dn[Vt];de(this._shiftRegister,this._shiftRegister,0,this.segmentSize),de(We,this._shiftRegister,16-this.segmentSize,gn,gn+this.segmentSize)}return $t};var _e=function(We,$t){if(!(this instanceof _e))throw Error("AES must be instanitated with `new`");if(this.description="Output Feedback",this.name="ofb",!$t)$t=ue(16);else if($t.length!=16)throw new Error("invalid initialation vector size (must be 16 bytes)");this._lastPrecipher=ae($t,!0),this._lastPrecipherIndex=16,this._aes=new le(We)};_e.prototype.encrypt=function(We){for(var $t=ae(We,!0),dn=0;dn<$t.length;dn++)this._lastPrecipherIndex===16&&(this._lastPrecipher=this._aes.encrypt(this._lastPrecipher),this._lastPrecipherIndex=0),$t[dn]^=this._lastPrecipher[this._lastPrecipherIndex++];return $t},_e.prototype.decrypt=_e.prototype.encrypt;var De=function(We){if(!(this instanceof De))throw Error("Counter must be instanitated with `new`");We!==0&&!We&&(We=1),typeof We=="number"?(this._counter=ue(16),this.setValue(We)):this.setBytes(We)};De.prototype.setValue=function(We){if(typeof We!="number"||parseInt(We)!=We)throw new Error("invalid counter value (must be an integer)");for(var $t=15;$t>=0;--$t)this._counter[$t]=We%256,We=We>>8},De.prototype.setBytes=function(We){if(We=ae(We,!0),We.length!=16)throw new Error("invalid counter bytes size (must be 16 bytes)");this._counter=We},De.prototype.increment=function(){for(var We=15;We>=0;We--)if(this._counter[We]===255)this._counter[We]=0;else{this._counter[We]++;break}};var Fe=function(We,$t){if(!(this instanceof Fe))throw Error("AES must be instanitated with `new`");this.description="Counter",this.name="ctr",$t instanceof De||($t=new De($t)),this._counter=$t,this._remainingCounter=null,this._remainingCounterIndex=16,this._aes=new le(We)};Fe.prototype.encrypt=function(We){for(var $t=ae(We,!0),dn=0;dn<$t.length;dn++)this._remainingCounterIndex===16&&(this._remainingCounter=this._aes.encrypt(this._counter._counter),this._remainingCounterIndex=0,this._counter.increment()),$t[dn]^=this._remainingCounter[this._remainingCounterIndex++];return $t},Fe.prototype.decrypt=Fe.prototype.encrypt;function $e(We){We=ae(We,!0);var $t=16-We.length%16,dn=ue(We.length+$t);de(We,dn);for(var gn=We.length;gn<dn.length;gn++)dn[gn]=$t;return dn}function ce(We){if(We=ae(We,!0),We.length<16)throw new Error("PKCS#7 invalid length");var $t=We[We.length-1];if($t>16)throw new Error("PKCS#7 padding byte out of range");for(var dn=We.length-$t,gn=0;gn<$t;gn++)if(We[dn+gn]!==$t)throw new Error("PKCS#7 invalid padding byte");var Vt=ue(dn);return de(We,Vt,0,0,dn),Vt}var Me={AES:le,Counter:De,ModeOfOperation:{ecb:pe,cbc:be,cfb:xe,ofb:_e,ctr:Fe},utils:{hex:ge,utf8:ve},padding:{pkcs7:{pad:$e,strip:ce}},_arrayTest:{coerceArray:ae,createArray:ue,copyArray:de}};n.exports=Me})()})(aesJs);var aesJsExports=aesJs.exports;const aes$1=getDefaultExportFromCjs$2(aesJsExports),version$c="json-wallets/5.8.0";function looseArrayify(n){return typeof n=="string"&&n.substring(0,2)!=="0x"&&(n="0x"+n),arrayify(n)}function zpad(n,t){for(n=String(n);n.length<t;)n="0"+n;return n}function getPassword(n){return typeof n=="string"?toUtf8Bytes(n,UnicodeNormalizationForm.NFKC):arrayify(n)}function searchPath(n,t){let c=n;const ie=t.toLowerCase().split("/");for(let se=0;se<ie.length;se++){let ae=null;for(const ue in c)if(ue.toLowerCase()===ie[se]){ae=c[ue];break}if(ae===null)return null;c=ae}return c}function uuidV4(n){const t=arrayify(n);t[6]=t[6]&15|64,t[8]=t[8]&63|128;const c=hexlify(t);return[c.substring(2,10),c.substring(10,14),c.substring(14,18),c.substring(18,22),c.substring(22,34)].join("-")}const logger$a=new Logger(version$c);class CrowdsaleAccount extends Description{isCrowdsaleAccount(t){return!!(t&&t._isCrowdsaleAccount)}}function decrypt$1(n,t){const c=JSON.parse(n);t=getPassword(t);const ie=getAddress$1(searchPath(c,"ethaddr")),se=looseArrayify(searchPath(c,"encseed"));(!se||se.length%16!==0)&&logger$a.throwArgumentError("invalid encseed","json",n);const ae=arrayify(pbkdf2$1(t,t,2e3,32,"sha256")).slice(0,16),ue=se.slice(0,16),de=se.slice(16),ve=new aes$1.ModeOfOperation.cbc(ae,ue),ge=aes$1.padding.pkcs7.strip(arrayify(ve.decrypt(de)));let we="";for(let qe=0;qe<ge.length;qe++)we+=String.fromCharCode(ge[qe]);const Te=toUtf8Bytes(we),Ne=keccak256$1(Te);return new CrowdsaleAccount({_isCrowdsaleAccount:!0,address:ie,privateKey:Ne})}function isCrowdsaleWallet(n){let t=null;try{t=JSON.parse(n)}catch{return!1}return t.encseed&&t.ethaddr}function isKeystoreWallet(n){let t=null;try{t=JSON.parse(n)}catch{return!1}return!(!t.version||parseInt(t.version)!==t.version||parseInt(t.version)!==3)}function getJsonWalletAddress(n){if(isCrowdsaleWallet(n))try{return getAddress$1(JSON.parse(n).ethaddr)}catch{return null}if(isKeystoreWallet(n))try{return getAddress$1(JSON.parse(n).address)}catch{return null}return null}var scrypt$1={exports:{}};(function(n,t){(function(c){function ie(ze){const He=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]);let Ge=1779033703,Ze=3144134277,Ye=1013904242,Ft=2773480762,Mt=1359893119,Zt=2600822924,cn=528734635,hn=1541459225;const yn=new Uint32Array(64);function Ht(De){let Fe=0,$e=De.length;for(;$e>=64;){let ce=Ge,Me=Ze,We=Ye,$t=Ft,dn=Mt,gn=Zt,Vt=cn,Cn=hn,un,Pt,mn,Pn,wn;for(Pt=0;Pt<16;Pt++)mn=Fe+Pt*4,yn[Pt]=(De[mn]&255)<<24|(De[mn+1]&255)<<16|(De[mn+2]&255)<<8|De[mn+3]&255;for(Pt=16;Pt<64;Pt++)un=yn[Pt-2],Pn=(un>>>17|un<<15)^(un>>>19|un<<13)^un>>>10,un=yn[Pt-15],wn=(un>>>7|un<<25)^(un>>>18|un<<14)^un>>>3,yn[Pt]=(Pn+yn[Pt-7]|0)+(wn+yn[Pt-16]|0)|0;for(Pt=0;Pt<64;Pt++)Pn=(((dn>>>6|dn<<26)^(dn>>>11|dn<<21)^(dn>>>25|dn<<7))+(dn&gn^~dn&Vt)|0)+(Cn+(He[Pt]+yn[Pt]|0)|0)|0,wn=((ce>>>2|ce<<30)^(ce>>>13|ce<<19)^(ce>>>22|ce<<10))+(ce&Me^ce&We^Me&We)|0,Cn=Vt,Vt=gn,gn=dn,dn=$t+Pn|0,$t=We,We=Me,Me=ce,ce=Pn+wn|0;Ge=Ge+ce|0,Ze=Ze+Me|0,Ye=Ye+We|0,Ft=Ft+$t|0,Mt=Mt+dn|0,Zt=Zt+gn|0,cn=cn+Vt|0,hn=hn+Cn|0,Fe+=64,$e-=64}}Ht(ze);let Sn,le=ze.length%64,pe=ze.length/536870912|0,be=ze.length<<3,xe=le<56?56:120,_e=ze.slice(ze.length-le,ze.length);for(_e.push(128),Sn=le+1;Sn<xe;Sn++)_e.push(0);return _e.push(pe>>>24&255),_e.push(pe>>>16&255),_e.push(pe>>>8&255),_e.push(pe>>>0&255),_e.push(be>>>24&255),_e.push(be>>>16&255),_e.push(be>>>8&255),_e.push(be>>>0&255),Ht(_e),[Ge>>>24&255,Ge>>>16&255,Ge>>>8&255,Ge>>>0&255,Ze>>>24&255,Ze>>>16&255,Ze>>>8&255,Ze>>>0&255,Ye>>>24&255,Ye>>>16&255,Ye>>>8&255,Ye>>>0&255,Ft>>>24&255,Ft>>>16&255,Ft>>>8&255,Ft>>>0&255,Mt>>>24&255,Mt>>>16&255,Mt>>>8&255,Mt>>>0&255,Zt>>>24&255,Zt>>>16&255,Zt>>>8&255,Zt>>>0&255,cn>>>24&255,cn>>>16&255,cn>>>8&255,cn>>>0&255,hn>>>24&255,hn>>>16&255,hn>>>8&255,hn>>>0&255]}function se(ze,He,Ge){ze=ze.length<=64?ze:ie(ze);const Ze=64+He.length+4,Ye=new Array(Ze),Ft=new Array(64);let Mt,Zt=[];for(Mt=0;Mt<64;Mt++)Ye[Mt]=54;for(Mt=0;Mt<ze.length;Mt++)Ye[Mt]^=ze[Mt];for(Mt=0;Mt<He.length;Mt++)Ye[64+Mt]=He[Mt];for(Mt=Ze-4;Mt<Ze;Mt++)Ye[Mt]=0;for(Mt=0;Mt<64;Mt++)Ft[Mt]=92;for(Mt=0;Mt<ze.length;Mt++)Ft[Mt]^=ze[Mt];function cn(){for(let hn=Ze-1;hn>=Ze-4;hn--){if(Ye[hn]++,Ye[hn]<=255)return;Ye[hn]=0}}for(;Ge>=32;)cn(),Zt=Zt.concat(ie(Ft.concat(ie(Ye)))),Ge-=32;return Ge>0&&(cn(),Zt=Zt.concat(ie(Ft.concat(ie(Ye))).slice(0,Ge))),Zt}function ae(ze,He,Ge,Ze,Ye){let Ft;for(ge(ze,(2*Ge-1)*16,Ye,0,16),Ft=0;Ft<2*Ge;Ft++)ve(ze,Ft*16,Ye,16),de(Ye,Ze),ge(Ye,0,ze,He+Ft*16,16);for(Ft=0;Ft<Ge;Ft++)ge(ze,He+Ft*2*16,ze,Ft*16,16);for(Ft=0;Ft<Ge;Ft++)ge(ze,He+(Ft*2+1)*16,ze,(Ft+Ge)*16,16)}function ue(ze,He){return ze<<He|ze>>>32-He}function de(ze,He){ge(ze,0,He,0,16);for(let Ge=8;Ge>0;Ge-=2)He[4]^=ue(He[0]+He[12],7),He[8]^=ue(He[4]+He[0],9),He[12]^=ue(He[8]+He[4],13),He[0]^=ue(He[12]+He[8],18),He[9]^=ue(He[5]+He[1],7),He[13]^=ue(He[9]+He[5],9),He[1]^=ue(He[13]+He[9],13),He[5]^=ue(He[1]+He[13],18),He[14]^=ue(He[10]+He[6],7),He[2]^=ue(He[14]+He[10],9),He[6]^=ue(He[2]+He[14],13),He[10]^=ue(He[6]+He[2],18),He[3]^=ue(He[15]+He[11],7),He[7]^=ue(He[3]+He[15],9),He[11]^=ue(He[7]+He[3],13),He[15]^=ue(He[11]+He[7],18),He[1]^=ue(He[0]+He[3],7),He[2]^=ue(He[1]+He[0],9),He[3]^=ue(He[2]+He[1],13),He[0]^=ue(He[3]+He[2],18),He[6]^=ue(He[5]+He[4],7),He[7]^=ue(He[6]+He[5],9),He[4]^=ue(He[7]+He[6],13),He[5]^=ue(He[4]+He[7],18),He[11]^=ue(He[10]+He[9],7),He[8]^=ue(He[11]+He[10],9),He[9]^=ue(He[8]+He[11],13),He[10]^=ue(He[9]+He[8],18),He[12]^=ue(He[15]+He[14],7),He[13]^=ue(He[12]+He[15],9),He[14]^=ue(He[13]+He[12],13),He[15]^=ue(He[14]+He[13],18);for(let Ge=0;Ge<16;++Ge)ze[Ge]+=He[Ge]}function ve(ze,He,Ge,Ze){for(let Ye=0;Ye<Ze;Ye++)Ge[Ye]^=ze[He+Ye]}function ge(ze,He,Ge,Ze,Ye){for(;Ye--;)Ge[Ze++]=ze[He++]}function we(ze){if(!ze||typeof ze.length!="number")return!1;for(let He=0;He<ze.length;He++){const Ge=ze[He];if(typeof Ge!="number"||Ge%1||Ge<0||Ge>=256)return!1}return!0}function Te(ze,He){if(typeof ze!="number"||ze%1)throw new Error("invalid "+He);return ze}function Ne(ze,He,Ge,Ze,Ye,Ft,Mt){if(Ge=Te(Ge,"N"),Ze=Te(Ze,"r"),Ye=Te(Ye,"p"),Ft=Te(Ft,"dkLen"),Ge===0||Ge&Ge-1)throw new Error("N must be power of 2");if(Ge>2147483647/128/Ze)throw new Error("N too large");if(Ze>2147483647/128/Ye)throw new Error("r too large");if(!we(ze))throw new Error("password must be an array or buffer");if(ze=Array.prototype.slice.call(ze),!we(He))throw new Error("salt must be an array or buffer");He=Array.prototype.slice.call(He);let Zt=se(ze,He,Ye*128*Ze);const cn=new Uint32Array(Ye*32*Ze);for(let dn=0;dn<cn.length;dn++){const gn=dn*4;cn[dn]=(Zt[gn+3]&255)<<24|(Zt[gn+2]&255)<<16|(Zt[gn+1]&255)<<8|(Zt[gn+0]&255)<<0}const hn=new Uint32Array(64*Ze),yn=new Uint32Array(32*Ze*Ge),Ht=32*Ze,Sn=new Uint32Array(16),le=new Uint32Array(16),pe=Ye*Ge*2;let be=0,xe=null,_e=!1,De=0,Fe=0,$e,ce;const Me=Mt?parseInt(1e3/Ze):4294967295,We=typeof setImmediate<"u"?setImmediate:setTimeout,$t=function(){if(_e)return Mt(new Error("cancelled"),be/pe);let dn;switch(De){case 0:ce=Fe*32*Ze,ge(cn,ce,hn,0,Ht),De=1,$e=0;case 1:dn=Ge-$e,dn>Me&&(dn=Me);for(let Vt=0;Vt<dn;Vt++)ge(hn,0,yn,($e+Vt)*Ht,Ht),ae(hn,Ht,Ze,Sn,le);if($e+=dn,be+=dn,Mt){const Vt=parseInt(1e3*be/pe);if(Vt!==xe){if(_e=Mt(null,be/pe),_e)break;xe=Vt}}if($e<Ge)break;$e=0,De=2;case 2:dn=Ge-$e,dn>Me&&(dn=Me);for(let Vt=0;Vt<dn;Vt++){const Cn=(2*Ze-1)*16,un=hn[Cn]&Ge-1;ve(yn,un*Ht,hn,Ht),ae(hn,Ht,Ze,Sn,le)}if($e+=dn,be+=dn,Mt){const Vt=parseInt(1e3*be/pe);if(Vt!==xe){if(_e=Mt(null,be/pe),_e)break;xe=Vt}}if($e<Ge)break;if(ge(hn,0,cn,ce,Ht),Fe++,Fe<Ye){De=0;break}Zt=[];for(let Vt=0;Vt<cn.length;Vt++)Zt.push(cn[Vt]>>0&255),Zt.push(cn[Vt]>>8&255),Zt.push(cn[Vt]>>16&255),Zt.push(cn[Vt]>>24&255);const gn=se(ze,Zt,Ft);return Mt&&Mt(null,1,gn),gn}Mt&&We($t)};if(!Mt)for(;;){const dn=$t();if(dn!=null)return dn}$t()}const qe={scrypt:function(ze,He,Ge,Ze,Ye,Ft,Mt){return new Promise(function(Zt,cn){let hn=0;Mt&&Mt(0),Ne(ze,He,Ge,Ze,Ye,Ft,function(yn,Ht,Sn){if(yn)cn(yn);else if(Sn)Mt&&hn!==1&&Mt(1),Zt(new Uint8Array(Sn));else if(Mt&&Ht!==hn)return hn=Ht,Mt(Ht)})})},syncScrypt:function(ze,He,Ge,Ze,Ye,Ft){return new Uint8Array(Ne(ze,He,Ge,Ze,Ye,Ft))}};n.exports=qe})()})(scrypt$1);var scryptExports=scrypt$1.exports;const scrypt=getDefaultExportFromCjs$2(scryptExports);var __awaiter$g=function(n,t,c,ie){function se(ae){return ae instanceof c?ae:new c(function(ue){ue(ae)})}return new(c||(c=Promise))(function(ae,ue){function de(we){try{ge(ie.next(we))}catch(Te){ue(Te)}}function ve(we){try{ge(ie.throw(we))}catch(Te){ue(Te)}}function ge(we){we.done?ae(we.value):se(we.value).then(de,ve)}ge((ie=ie.apply(n,[])).next())})};const logger$9=new Logger(version$c);function hasMnemonic$1(n){return n!=null&&n.mnemonic&&n.mnemonic.phrase}class KeystoreAccount extends Description{isKeystoreAccount(t){return!!(t&&t._isKeystoreAccount)}}function _decrypt(n,t,c){if(searchPath(n,"crypto/cipher")==="aes-128-ctr"){const ie=looseArrayify(searchPath(n,"crypto/cipherparams/iv")),se=new aes$1.Counter(ie),ae=new aes$1.ModeOfOperation.ctr(t,se);return arrayify(ae.decrypt(c))}return null}function _getAccount(n,t){const c=looseArrayify(searchPath(n,"crypto/ciphertext"));if(hexlify(keccak256$1(concat$1([t.slice(16,32),c]))).substring(2)!==searchPath(n,"crypto/mac").toLowerCase())throw new Error("invalid password");const ie=_decrypt(n,t.slice(0,16),c);ie||logger$9.throwError("unsupported cipher",Logger.errors.UNSUPPORTED_OPERATION,{operation:"decrypt"});const se=t.slice(32,64),ae=computeAddress(ie);if(n.address){let de=n.address.toLowerCase();if(de.substring(0,2)!=="0x"&&(de="0x"+de),getAddress$1(de)!==ae)throw new Error("address mismatch")}const ue={_isKeystoreAccount:!0,address:ae,privateKey:hexlify(ie)};if(searchPath(n,"x-ethers/version")==="0.1"){const de=looseArrayify(searchPath(n,"x-ethers/mnemonicCiphertext")),ve=looseArrayify(searchPath(n,"x-ethers/mnemonicCounter")),ge=new aes$1.Counter(ve),we=new aes$1.ModeOfOperation.ctr(se,ge),Te=searchPath(n,"x-ethers/path")||defaultPath,Ne=searchPath(n,"x-ethers/locale")||"en",qe=arrayify(we.decrypt(de));try{const ze=entropyToMnemonic(qe,Ne),He=HDNode.fromMnemonic(ze,null,Ne).derivePath(Te);if(He.privateKey!=ue.privateKey)throw new Error("mnemonic mismatch");ue.mnemonic=He.mnemonic}catch(ze){if(ze.code!==Logger.errors.INVALID_ARGUMENT||ze.argument!=="wordlist")throw ze}}return new KeystoreAccount(ue)}function pbkdf2Sync(n,t,c,ie,se){return arrayify(pbkdf2$1(n,t,c,ie,se))}function pbkdf2(n,t,c,ie,se){return Promise.resolve(pbkdf2Sync(n,t,c,ie,se))}function _computeKdfKey(n,t,c,ie,se){const ae=getPassword(t),ue=searchPath(n,"crypto/kdf");if(ue&&typeof ue=="string"){const de=function(ve,ge){return logger$9.throwArgumentError("invalid key-derivation function parameters",ve,ge)};if(ue.toLowerCase()==="scrypt"){const ve=looseArrayify(searchPath(n,"crypto/kdfparams/salt")),ge=parseInt(searchPath(n,"crypto/kdfparams/n")),we=parseInt(searchPath(n,"crypto/kdfparams/r")),Te=parseInt(searchPath(n,"crypto/kdfparams/p"));(!ge||!we||!Te)&&de("kdf",ue),ge&ge-1&&de("N",ge);const Ne=parseInt(searchPath(n,"crypto/kdfparams/dklen"));return Ne!==32&&de("dklen",Ne),ie(ae,ve,ge,we,Te,64,se)}else if(ue.toLowerCase()==="pbkdf2"){const ve=looseArrayify(searchPath(n,"crypto/kdfparams/salt"));let ge=null;const we=searchPath(n,"crypto/kdfparams/prf");we==="hmac-sha256"?ge="sha256":we==="hmac-sha512"?ge="sha512":de("prf",we);const Te=parseInt(searchPath(n,"crypto/kdfparams/c")),Ne=parseInt(searchPath(n,"crypto/kdfparams/dklen"));return Ne!==32&&de("dklen",Ne),c(ae,ve,Te,Ne,ge)}}return logger$9.throwArgumentError("unsupported key-derivation function","kdf",ue)}function decryptSync(n,t){const c=JSON.parse(n),ie=_computeKdfKey(c,t,pbkdf2Sync,scrypt.syncScrypt);return _getAccount(c,ie)}function decrypt(n,t,c){return __awaiter$g(this,void 0,void 0,function*(){const ie=JSON.parse(n),se=yield _computeKdfKey(ie,t,pbkdf2,scrypt.scrypt,c);return _getAccount(ie,se)})}function encrypt(n,t,c,ie){try{if(getAddress$1(n.address)!==computeAddress(n.privateKey))throw new Error("address/privateKey mismatch");if(hasMnemonic$1(n)){const Ge=n.mnemonic;if(HDNode.fromMnemonic(Ge.phrase,null,Ge.locale).derivePath(Ge.path||defaultPath).privateKey!=n.privateKey)throw new Error("mnemonic mismatch")}}catch(Ge){return Promise.reject(Ge)}typeof c=="function"&&!ie&&(ie=c,c={}),c||(c={});const se=arrayify(n.privateKey),ae=getPassword(t);let ue=null,de=null,ve=null;if(hasMnemonic$1(n)){const Ge=n.mnemonic;ue=arrayify(mnemonicToEntropy(Ge.phrase,Ge.locale||"en")),de=Ge.path||defaultPath,ve=Ge.locale||"en"}let ge=c.client;ge||(ge="ethers.js");let we=null;c.salt?we=arrayify(c.salt):we=randomBytes$1(32);let Te=null;if(c.iv){if(Te=arrayify(c.iv),Te.length!==16)throw new Error("invalid iv")}else Te=randomBytes$1(16);let Ne=null;if(c.uuid){if(Ne=arrayify(c.uuid),Ne.length!==16)throw new Error("invalid uuid")}else Ne=randomBytes$1(16);let qe=1<<17,ze=8,He=1;return c.scrypt&&(c.scrypt.N&&(qe=c.scrypt.N),c.scrypt.r&&(ze=c.scrypt.r),c.scrypt.p&&(He=c.scrypt.p)),scrypt.scrypt(ae,we,qe,ze,He,64,ie).then(Ge=>{Ge=arrayify(Ge);const Ze=Ge.slice(0,16),Ye=Ge.slice(16,32),Ft=Ge.slice(32,64),Mt=new aes$1.Counter(Te),Zt=new aes$1.ModeOfOperation.ctr(Ze,Mt),cn=arrayify(Zt.encrypt(se)),hn=keccak256$1(concat$1([Ye,cn])),yn={address:n.address.substring(2).toLowerCase(),id:uuidV4(Ne),version:3,crypto:{cipher:"aes-128-ctr",cipherparams:{iv:hexlify(Te).substring(2)},ciphertext:hexlify(cn).substring(2),kdf:"scrypt",kdfparams:{salt:hexlify(we).substring(2),n:qe,dklen:32,p:He,r:ze},mac:hn.substring(2)}};if(ue){const Ht=randomBytes$1(16),Sn=new aes$1.Counter(Ht),le=new aes$1.ModeOfOperation.ctr(Ft,Sn),pe=arrayify(le.encrypt(ue)),be=new Date,xe=be.getUTCFullYear()+"-"+zpad(be.getUTCMonth()+1,2)+"-"+zpad(be.getUTCDate(),2)+"T"+zpad(be.getUTCHours(),2)+"-"+zpad(be.getUTCMinutes(),2)+"-"+zpad(be.getUTCSeconds(),2)+".0Z";yn["x-ethers"]={client:ge,gethFilename:"UTC--"+xe+"--"+yn.address,mnemonicCounter:hexlify(Ht).substring(2),mnemonicCiphertext:hexlify(pe).substring(2),path:de,locale:ve,version:"0.1"}}return JSON.stringify(yn)})}function decryptJsonWallet(n,t,c){if(isCrowdsaleWallet(n)){c&&c(0);const ie=decrypt$1(n,t);return c&&c(1),Promise.resolve(ie)}return isKeystoreWallet(n)?decrypt(n,t,c):Promise.reject(new Error("invalid JSON wallet"))}function decryptJsonWalletSync(n,t){if(isCrowdsaleWallet(n))return decrypt$1(n,t);if(isKeystoreWallet(n))return decryptSync(n,t);throw new Error("invalid JSON wallet")}const lib_esm$4=Object.freeze(Object.defineProperty({__proto__:null,decryptCrowdsale:decrypt$1,decryptJsonWallet,decryptJsonWalletSync,decryptKeystore:decrypt,decryptKeystoreSync:decryptSync,encryptKeystore:encrypt,getJsonWalletAddress,isCrowdsaleWallet,isKeystoreWallet},Symbol.toStringTag,{value:"Module"})),version$b="wallet/5.8.0";var __awaiter$f=function(n,t,c,ie){function se(ae){return ae instanceof c?ae:new c(function(ue){ue(ae)})}return new(c||(c=Promise))(function(ae,ue){function de(we){try{ge(ie.next(we))}catch(Te){ue(Te)}}function ve(we){try{ge(ie.throw(we))}catch(Te){ue(Te)}}function ge(we){we.done?ae(we.value):se(we.value).then(de,ve)}ge((ie=ie.apply(n,[])).next())})};const logger$8=new Logger(version$b);function isAccount(n){return n!=null&&isHexString(n.privateKey,32)&&n.address!=null}function hasMnemonic(n){const t=n.mnemonic;return t&&t.phrase}class Wallet extends Signer{constructor(t,c){if(super(),isAccount(t)){const ie=new SigningKey(t.privateKey);if(defineReadOnly(this,"_signingKey",()=>ie),defineReadOnly(this,"address",computeAddress(this.publicKey)),this.address!==getAddress$1(t.address)&&logger$8.throwArgumentError("privateKey/address mismatch","privateKey","[REDACTED]"),hasMnemonic(t)){const se=t.mnemonic;defineReadOnly(this,"_mnemonic",()=>({phrase:se.phrase,path:se.path||defaultPath,locale:se.locale||"en"}));const ae=this.mnemonic,ue=HDNode.fromMnemonic(ae.phrase,null,ae.locale).derivePath(ae.path);computeAddress(ue.privateKey)!==this.address&&logger$8.throwArgumentError("mnemonic/address mismatch","privateKey","[REDACTED]")}else defineReadOnly(this,"_mnemonic",()=>null)}else{if(SigningKey.isSigningKey(t))t.curve!=="secp256k1"&&logger$8.throwArgumentError("unsupported curve; must be secp256k1","privateKey","[REDACTED]"),defineReadOnly(this,"_signingKey",()=>t);else{typeof t=="string"&&t.match(/^[0-9a-f]*$/i)&&t.length===64&&(t="0x"+t);const ie=new SigningKey(t);defineReadOnly(this,"_signingKey",()=>ie)}defineReadOnly(this,"_mnemonic",()=>null),defineReadOnly(this,"address",computeAddress(this.publicKey))}c&&!Provider.isProvider(c)&&logger$8.throwArgumentError("invalid provider","provider",c),defineReadOnly(this,"provider",c||null)}get mnemonic(){return this._mnemonic()}get privateKey(){return this._signingKey().privateKey}get publicKey(){return this._signingKey().publicKey}getAddress(){return Promise.resolve(this.address)}connect(t){return new Wallet(this,t)}signTransaction(t){return resolveProperties(t).then(c=>{c.from!=null&&(getAddress$1(c.from)!==this.address&&logger$8.throwArgumentError("transaction from address mismatch","transaction.from",t.from),delete c.from);const ie=this._signingKey().signDigest(keccak256$1(serialize$1$1(c)));return serialize$1$1(c,ie)})}signMessage(t){return __awaiter$f(this,void 0,void 0,function*(){return joinSignature(this._signingKey().signDigest(hashMessage(t)))})}_signTypedData(t,c,ie){return __awaiter$f(this,void 0,void 0,function*(){const se=yield TypedDataEncoder.resolveNames(t,c,ie,ae=>(this.provider==null&&logger$8.throwError("cannot resolve ENS names without a provider",Logger.errors.UNSUPPORTED_OPERATION,{operation:"resolveName",value:ae}),this.provider.resolveName(ae)));return joinSignature(this._signingKey().signDigest(TypedDataEncoder.hash(se.domain,c,se.value)))})}encrypt(t,c,ie){if(typeof c=="function"&&!ie&&(ie=c,c={}),ie&&typeof ie!="function")throw new Error("invalid callback");return c||(c={}),encrypt(this,t,c,ie)}static createRandom(t){let c=randomBytes$1(16);t||(t={}),t.extraEntropy&&(c=arrayify(hexDataSlice(keccak256$1(concat$1([c,t.extraEntropy])),0,16)));const ie=entropyToMnemonic(c,t.locale);return Wallet.fromMnemonic(ie,t.path,t.locale)}static fromEncryptedJson(t,c,ie){return decryptJsonWallet(t,c,ie).then(se=>new Wallet(se))}static fromEncryptedJsonSync(t,c){return new Wallet(decryptJsonWalletSync(t,c))}static fromMnemonic(t,c,ie){return c||(c=defaultPath),new Wallet(HDNode.fromMnemonic(t,null,ie).derivePath(c))}}function verifyMessage(n,t){return recoverAddress(hashMessage(n),t)}function verifyTypedData(n,t,c,ie){return recoverAddress(TypedDataEncoder.hash(n,t,c),ie)}const lib_esm$3=Object.freeze(Object.defineProperty({__proto__:null,Wallet,verifyMessage,verifyTypedData},Symbol.toStringTag,{value:"Module"})),version$a="networks/5.8.0",logger$7=new Logger(version$a);function isRenetworkable(n){return n&&typeof n.renetwork=="function"}function ethDefaultProvider(n){const t=function(c,ie){ie==null&&(ie={});const se=[];if(c.InfuraProvider&&ie.infura!=="-")try{se.push(new c.InfuraProvider(n,ie.infura))}catch{}if(c.EtherscanProvider&&ie.etherscan!=="-")try{se.push(new c.EtherscanProvider(n,ie.etherscan))}catch{}if(c.AlchemyProvider&&ie.alchemy!=="-")try{se.push(new c.AlchemyProvider(n,ie.alchemy))}catch{}if(c.PocketProvider&&ie.pocket!=="-"){const ae=["goerli","ropsten","rinkeby","sepolia"];try{const ue=new c.PocketProvider(n,ie.pocket);ue.network&&ae.indexOf(ue.network.name)===-1&&se.push(ue)}catch{}}if(c.CloudflareProvider&&ie.cloudflare!=="-")try{se.push(new c.CloudflareProvider(n))}catch{}if(c.AnkrProvider&&ie.ankr!=="-")try{const ae=["ropsten"],ue=new c.AnkrProvider(n,ie.ankr);ue.network&&ae.indexOf(ue.network.name)===-1&&se.push(ue)}catch{}if(c.QuickNodeProvider&&ie.quicknode!=="-")try{se.push(new c.QuickNodeProvider(n,ie.quicknode))}catch{}if(se.length===0)return null;if(c.FallbackProvider){let ae=1;return ie.quorum!=null?ae=ie.quorum:n==="homestead"&&(ae=2),new c.FallbackProvider(se,ae)}return se[0]};return t.renetwork=function(c){return ethDefaultProvider(c)},t}function etcDefaultProvider(n,t){const c=function(ie,se){return ie.JsonRpcProvider?new ie.JsonRpcProvider(n,t):null};return c.renetwork=function(ie){return etcDefaultProvider(n,ie)},c}const homestead={chainId:1,ensAddress:"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e",name:"homestead",_defaultProvider:ethDefaultProvider("homestead")},ropsten={chainId:3,ensAddress:"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e",name:"ropsten",_defaultProvider:ethDefaultProvider("ropsten")},classicMordor={chainId:63,name:"classicMordor",_defaultProvider:etcDefaultProvider("https://www.ethercluster.com/mordor","classicMordor")},networks$2={unspecified:{chainId:0,name:"unspecified"},homestead,mainnet:homestead,morden:{chainId:2,name:"morden"},ropsten,testnet:ropsten,rinkeby:{chainId:4,ensAddress:"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e",name:"rinkeby",_defaultProvider:ethDefaultProvider("rinkeby")},kovan:{chainId:42,name:"kovan",_defaultProvider:ethDefaultProvider("kovan")},goerli:{chainId:5,ensAddress:"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e",name:"goerli",_defaultProvider:ethDefaultProvider("goerli")},kintsugi:{chainId:1337702,name:"kintsugi"},sepolia:{chainId:11155111,ensAddress:"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e",name:"sepolia",_defaultProvider:ethDefaultProvider("sepolia")},holesky:{chainId:17e3,name:"holesky",_defaultProvider:ethDefaultProvider("holesky")},classic:{chainId:61,name:"classic",_defaultProvider:etcDefaultProvider("https://www.ethercluster.com/etc","classic")},classicMorden:{chainId:62,name:"classicMorden"},classicMordor,classicTestnet:classicMordor,classicKotti:{chainId:6,name:"classicKotti",_defaultProvider:etcDefaultProvider("https://www.ethercluster.com/kotti","classicKotti")},xdai:{chainId:100,name:"xdai"},matic:{chainId:137,name:"matic",_defaultProvider:ethDefaultProvider("matic")},maticmum:{chainId:80001,name:"maticmum",_defaultProvider:ethDefaultProvider("maticmum")},optimism:{chainId:10,name:"optimism",_defaultProvider:ethDefaultProvider("optimism")},"optimism-kovan":{chainId:69,name:"optimism-kovan"},"optimism-goerli":{chainId:420,name:"optimism-goerli"},"optimism-sepolia":{chainId:11155420,name:"optimism-sepolia"},arbitrum:{chainId:42161,name:"arbitrum"},"arbitrum-rinkeby":{chainId:421611,name:"arbitrum-rinkeby"},"arbitrum-goerli":{chainId:421613,name:"arbitrum-goerli"},"arbitrum-sepolia":{chainId:421614,name:"arbitrum-sepolia"},bnb:{chainId:56,name:"bnb"},bnbt:{chainId:97,name:"bnbt"}};function getNetwork(n){if(n==null)return null;if(typeof n=="number"){for(const ie in networks$2){const se=networks$2[ie];if(se.chainId===n)return{name:se.name,chainId:se.chainId,ensAddress:se.ensAddress||null,_defaultProvider:se._defaultProvider||null}}return{chainId:n,name:"unknown"}}if(typeof n=="string"){const ie=networks$2[n];return ie==null?null:{name:ie.name,chainId:ie.chainId,ensAddress:ie.ensAddress,_defaultProvider:ie._defaultProvider||null}}const t=networks$2[n.name];if(!t)return typeof n.chainId!="number"&&logger$7.throwArgumentError("invalid network chainId","network",n),n;n.chainId!==0&&n.chainId!==t.chainId&&logger$7.throwArgumentError("network chainId mismatch","network",n);let c=n._defaultProvider||null;return c==null&&t._defaultProvider&&(isRenetworkable(t._defaultProvider)?c=t._defaultProvider.renetwork(n):c=t._defaultProvider),{name:n.name,chainId:t.chainId,ensAddress:n.ensAddress||t.ensAddress||null,_defaultProvider:c}}const version$9="web/5.8.0";var __awaiter$e=function(n,t,c,ie){function se(ae){return ae instanceof c?ae:new c(function(ue){ue(ae)})}return new(c||(c=Promise))(function(ae,ue){function de(we){try{ge(ie.next(we))}catch(Te){ue(Te)}}function ve(we){try{ge(ie.throw(we))}catch(Te){ue(Te)}}function ge(we){we.done?ae(we.value):se(we.value).then(de,ve)}ge((ie=ie.apply(n,[])).next())})};function getUrl(n,t){return __awaiter$e(this,void 0,void 0,function*(){t==null&&(t={});const c={method:t.method||"GET",headers:t.headers||{},body:t.body||void 0};if(t.skipFetchSetup!==!0&&(c.mode="cors",c.cache="no-cache",c.credentials="same-origin",c.redirect="follow",c.referrer="client"),t.fetchOptions!=null){const ue=t.fetchOptions;ue.mode&&(c.mode=ue.mode),ue.cache&&(c.cache=ue.cache),ue.credentials&&(c.credentials=ue.credentials),ue.redirect&&(c.redirect=ue.redirect),ue.referrer&&(c.referrer=ue.referrer)}const ie=yield fetch(n,c),se=yield ie.arrayBuffer(),ae={};return ie.headers.forEach?ie.headers.forEach((ue,de)=>{ae[de.toLowerCase()]=ue}):ie.headers.keys().forEach(ue=>{ae[ue.toLowerCase()]=ie.headers.get(ue)}),{headers:ae,statusCode:ie.status,statusMessage:ie.statusText,body:arrayify(new Uint8Array(se))}})}var __awaiter$d=function(n,t,c,ie){function se(ae){return ae instanceof c?ae:new c(function(ue){ue(ae)})}return new(c||(c=Promise))(function(ae,ue){function de(we){try{ge(ie.next(we))}catch(Te){ue(Te)}}function ve(we){try{ge(ie.throw(we))}catch(Te){ue(Te)}}function ge(we){we.done?ae(we.value):se(we.value).then(de,ve)}ge((ie=ie.apply(n,[])).next())})};const logger$6=new Logger(version$9);function staller(n){return new Promise(t=>{setTimeout(t,n)})}function bodyify(n,t){if(n==null)return null;if(typeof n=="string")return n;if(isBytesLike(n)){if(t&&(t.split("/")[0]==="text"||t.split(";")[0].trim()==="application/json"))try{return toUtf8String(n)}catch{}return hexlify(n)}return n}function unpercent(n){return toUtf8Bytes(n.replace(/%([0-9a-f][0-9a-f])/gi,(t,c)=>String.fromCharCode(parseInt(c,16))))}function _fetchData(n,t,c){const ie=typeof n=="object"&&n.throttleLimit!=null?n.throttleLimit:12;logger$6.assertArgument(ie>0&&ie%1===0,"invalid connection throttle limit","connection.throttleLimit",ie);const se=typeof n=="object"?n.throttleCallback:null,ae=typeof n=="object"&&typeof n.throttleSlotInterval=="number"?n.throttleSlotInterval:100;logger$6.assertArgument(ae>0&&ae%1===0,"invalid connection throttle slot interval","connection.throttleSlotInterval",ae);const ue=typeof n=="object"?!!n.errorPassThrough:!1,de={};let ve=null;const ge={method:"GET"};let we=!1,Te=120*1e3;if(typeof n=="string")ve=n;else if(typeof n=="object"){if((n==null||n.url==null)&&logger$6.throwArgumentError("missing URL","connection.url",n),ve=n.url,typeof n.timeout=="number"&&n.timeout>0&&(Te=n.timeout),n.headers)for(const Ze in n.headers)de[Ze.toLowerCase()]={key:Ze,value:String(n.headers[Ze])},["if-none-match","if-modified-since"].indexOf(Ze.toLowerCase())>=0&&(we=!0);if(ge.allowGzip=!!n.allowGzip,n.user!=null&&n.password!=null){ve.substring(0,6)!=="https:"&&n.allowInsecureAuthentication!==!0&&logger$6.throwError("basic authentication requires a secure https url",Logger.errors.INVALID_ARGUMENT,{argument:"url",url:ve,user:n.user,password:"[REDACTED]"});const Ze=n.user+":"+n.password;de.authorization={key:"Authorization",value:"Basic "+encode$5(toUtf8Bytes(Ze))}}n.skipFetchSetup!=null&&(ge.skipFetchSetup=!!n.skipFetchSetup),n.fetchOptions!=null&&(ge.fetchOptions=shallowCopy(n.fetchOptions))}const Ne=new RegExp("^data:([^;:]*)?(;base64)?,(.*)$","i"),qe=ve?ve.match(Ne):null;if(qe)try{const Ze={statusCode:200,statusMessage:"OK",headers:{"content-type":qe[1]||"text/plain"},body:qe[2]?decode$6(qe[3]):unpercent(qe[3])};let Ye=Ze.body;return c&&(Ye=c(Ze.body,Ze)),Promise.resolve(Ye)}catch(Ze){logger$6.throwError("processing response error",Logger.errors.SERVER_ERROR,{body:bodyify(qe[1],qe[2]),error:Ze,requestBody:null,requestMethod:"GET",url:ve})}t&&(ge.method="POST",ge.body=t,de["content-type"]==null&&(de["content-type"]={key:"Content-Type",value:"application/octet-stream"}),de["content-length"]==null&&(de["content-length"]={key:"Content-Length",value:String(t.length)}));const ze={};Object.keys(de).forEach(Ze=>{const Ye=de[Ze];ze[Ye.key]=Ye.value}),ge.headers=ze;const He=(function(){let Ze=null;return{promise:new Promise(function(Ye,Ft){Te&&(Ze=setTimeout(()=>{Ze!=null&&(Ze=null,Ft(logger$6.makeError("timeout",Logger.errors.TIMEOUT,{requestBody:bodyify(ge.body,ze["content-type"]),requestMethod:ge.method,timeout:Te,url:ve})))},Te))}),cancel:function(){Ze!=null&&(clearTimeout(Ze),Ze=null)}}})(),Ge=(function(){return __awaiter$d(this,void 0,void 0,function*(){for(let Ze=0;Ze<ie;Ze++){let Ye=null;try{if(Ye=yield getUrl(ve,ge),Ze<ie){if(Ye.statusCode===301||Ye.statusCode===302){const Mt=Ye.headers.location||"";if(ge.method==="GET"&&Mt.match(/^https:/)){ve=Ye.headers.location;continue}}else if(Ye.statusCode===429){let Mt=!0;if(se&&(Mt=yield se(Ze,ve)),Mt){let Zt=0;const cn=Ye.headers["retry-after"];typeof cn=="string"&&cn.match(/^[1-9][0-9]*$/)?Zt=parseInt(cn)*1e3:Zt=ae*parseInt(String(Math.random()*Math.pow(2,Ze))),yield staller(Zt);continue}}}}catch(Mt){Ye=Mt.response,Ye==null&&(He.cancel(),logger$6.throwError("missing response",Logger.errors.SERVER_ERROR,{requestBody:bodyify(ge.body,ze["content-type"]),requestMethod:ge.method,serverError:Mt,url:ve}))}let Ft=Ye.body;if(we&&Ye.statusCode===304?Ft=null:!ue&&(Ye.statusCode<200||Ye.statusCode>=300)&&(He.cancel(),logger$6.throwError("bad response",Logger.errors.SERVER_ERROR,{status:Ye.statusCode,headers:Ye.headers,body:bodyify(Ft,Ye.headers?Ye.headers["content-type"]:null),requestBody:bodyify(ge.body,ze["content-type"]),requestMethod:ge.method,url:ve})),c)try{const Mt=yield c(Ft,Ye);return He.cancel(),Mt}catch(Mt){if(Mt.throttleRetry&&Ze<ie){let Zt=!0;if(se&&(Zt=yield se(Ze,ve)),Zt){const cn=ae*parseInt(String(Math.random()*Math.pow(2,Ze)));yield staller(cn);continue}}He.cancel(),logger$6.throwError("processing response error",Logger.errors.SERVER_ERROR,{body:bodyify(Ft,Ye.headers?Ye.headers["content-type"]:null),error:Mt,requestBody:bodyify(ge.body,ze["content-type"]),requestMethod:ge.method,url:ve})}return He.cancel(),Ft}return logger$6.throwError("failed response",Logger.errors.SERVER_ERROR,{requestBody:bodyify(ge.body,ze["content-type"]),requestMethod:ge.method,url:ve})})})();return Promise.race([He.promise,Ge])}function fetchJson(n,t,c){let ie=(ae,ue)=>{let de=null;if(ae!=null)try{de=JSON.parse(toUtf8String(ae))}catch(ve){logger$6.throwError("invalid JSON",Logger.errors.SERVER_ERROR,{body:ae,error:ve})}return c&&(de=c(de,ue)),de},se=null;if(t!=null){se=toUtf8Bytes(t);const ae=typeof n=="string"?{url:n}:shallowCopy(n);ae.headers?Object.keys(ae.headers).filter(ue=>ue.toLowerCase()==="content-type").length!==0||(ae.headers=shallowCopy(ae.headers),ae.headers["content-type"]="application/json"):ae.headers={"content-type":"application/json"},n=ae}return _fetchData(n,se,ie)}function poll(n,t){return t||(t={}),t=shallowCopy(t),t.floor==null&&(t.floor=0),t.ceiling==null&&(t.ceiling=1e4),t.interval==null&&(t.interval=250),new Promise(function(c,ie){let se=null,ae=!1;const ue=()=>ae?!1:(ae=!0,se&&clearTimeout(se),!0);t.timeout&&(se=setTimeout(()=>{ue()&&ie(new Error("timeout"))},t.timeout));const de=t.retryLimit;let ve=0;function ge(){return n().then(function(we){if(we!==void 0)ue()&&c(we);else if(t.oncePoll)t.oncePoll.once("poll",ge);else if(t.onceBlock)t.onceBlock.once("block",ge);else if(!ae){if(ve++,ve>de){ue()&&ie(new Error("retry limit reached"));return}let Te=t.interval*parseInt(String(Math.random()*Math.pow(2,ve)));Te<t.floor&&(Te=t.floor),Te>t.ceiling&&(Te=t.ceiling),setTimeout(ge,Te)}return null},function(we){ue()&&ie(we)})}ge()})}const lib_esm$2=Object.freeze(Object.defineProperty({__proto__:null,_fetchData,fetchJson,poll},Symbol.toStringTag,{value:"Module"}));var ALPHABET$2="qpzry9x8gf2tvdw0s3jn54khce6mua7l",ALPHABET_MAP$1={};for(var z$3=0;z$3<ALPHABET$2.length;z$3++){var x$2=ALPHABET$2.charAt(z$3);if(ALPHABET_MAP$1[x$2]!==void 0)throw new TypeError(x$2+" is ambiguous");ALPHABET_MAP$1[x$2]=z$3}function polymodStep$1(n){var t=n>>25;return(n&33554431)<<5^-(t>>0&1)&996825010^-(t>>1&1)&642813549^-(t>>2&1)&513874426^-(t>>3&1)&1027748829^-(t>>4&1)&705979059}function prefixChk$1(n){for(var t=1,c=0;c<n.length;++c){var ie=n.charCodeAt(c);if(ie<33||ie>126)return"Invalid prefix ("+n+")";t=polymodStep$1(t)^ie>>5}for(t=polymodStep$1(t),c=0;c<n.length;++c){var se=n.charCodeAt(c);t=polymodStep$1(t)^se&31}return t}function encode$4(n,t,c){if(c=c||90,n.length+7+t.length>c)throw new TypeError("Exceeds length limit");n=n.toLowerCase();var ie=prefixChk$1(n);if(typeof ie=="string")throw new Error(ie);for(var se=n+"1",ae=0;ae<t.length;++ae){var ue=t[ae];if(ue>>5)throw new Error("Non 5-bit word");ie=polymodStep$1(ie)^ue,se+=ALPHABET$2.charAt(ue)}for(ae=0;ae<6;++ae)ie=polymodStep$1(ie);for(ie^=1,ae=0;ae<6;++ae){var de=ie>>(5-ae)*5&31;se+=ALPHABET$2.charAt(de)}return se}function __decode(n,t){if(t=t||90,n.length<8)return n+" too short";if(n.length>t)return"Exceeds length limit";var c=n.toLowerCase(),ie=n.toUpperCase();if(n!==c&&n!==ie)return"Mixed-case string "+n;n=c;var se=n.lastIndexOf("1");if(se===-1)return"No separator character for "+n;if(se===0)return"Missing prefix for "+n;var ae=n.slice(0,se),ue=n.slice(se+1);if(ue.length<6)return"Data too short";var de=prefixChk$1(ae);if(typeof de=="string")return de;for(var ve=[],ge=0;ge<ue.length;++ge){var we=ue.charAt(ge),Te=ALPHABET_MAP$1[we];if(Te===void 0)return"Unknown character "+we;de=polymodStep$1(de)^Te,!(ge+6>=ue.length)&&ve.push(Te)}return de!==1?"Invalid checksum for "+n:{prefix:ae,words:ve}}function decodeUnsafe(){var n=__decode.apply(null,arguments);if(typeof n=="object")return n}function decode$5(n){var t=__decode.apply(null,arguments);if(typeof t=="object")return t;throw new Error(t)}function convert$1(n,t,c,ie){for(var se=0,ae=0,ue=(1<<c)-1,de=[],ve=0;ve<n.length;++ve)for(se=se<<t|n[ve],ae+=t;ae>=c;)ae-=c,de.push(se>>ae&ue);if(ie)ae>0&&de.push(se<<c-ae&ue);else{if(ae>=t)return"Excess padding";if(se<<c-ae&ue)return"Non-zero padding"}return de}function toWordsUnsafe(n){var t=convert$1(n,8,5,!0);if(Array.isArray(t))return t}function toWords$1(n){var t=convert$1(n,8,5,!0);if(Array.isArray(t))return t;throw new Error(t)}function fromWordsUnsafe$1(n){var t=convert$1(n,5,8,!1);if(Array.isArray(t))return t}function fromWords$1(n){var t=convert$1(n,5,8,!1);if(Array.isArray(t))return t;throw new Error(t)}var bech32$1={decodeUnsafe,decode:decode$5,encode:encode$4,toWordsUnsafe,toWords:toWords$1,fromWordsUnsafe:fromWordsUnsafe$1,fromWords:fromWords$1};const bech32$2=getDefaultExportFromCjs$2(bech32$1),version$8="providers/5.8.0",logger$5=new Logger(version$8);class Formatter{constructor(){this.formats=this.getDefaultFormats()}getDefaultFormats(){const t={},c=this.address.bind(this),ie=this.bigNumber.bind(this),se=this.blockTag.bind(this),ae=this.data.bind(this),ue=this.hash.bind(this),de=this.hex.bind(this),ve=this.number.bind(this),ge=this.type.bind(this),we=Te=>this.data(Te,!0);return t.transaction={hash:ue,type:ge,accessList:Formatter.allowNull(this.accessList.bind(this),null),blockHash:Formatter.allowNull(ue,null),blockNumber:Formatter.allowNull(ve,null),transactionIndex:Formatter.allowNull(ve,null),confirmations:Formatter.allowNull(ve,null),from:c,gasPrice:Formatter.allowNull(ie),maxPriorityFeePerGas:Formatter.allowNull(ie),maxFeePerGas:Formatter.allowNull(ie),gasLimit:ie,to:Formatter.allowNull(c,null),value:ie,nonce:ve,data:ae,r:Formatter.allowNull(this.uint256),s:Formatter.allowNull(this.uint256),v:Formatter.allowNull(ve),creates:Formatter.allowNull(c,null),raw:Formatter.allowNull(ae)},t.transactionRequest={from:Formatter.allowNull(c),nonce:Formatter.allowNull(ve),gasLimit:Formatter.allowNull(ie),gasPrice:Formatter.allowNull(ie),maxPriorityFeePerGas:Formatter.allowNull(ie),maxFeePerGas:Formatter.allowNull(ie),to:Formatter.allowNull(c),value:Formatter.allowNull(ie),data:Formatter.allowNull(we),type:Formatter.allowNull(ve),accessList:Formatter.allowNull(this.accessList.bind(this),null)},t.receiptLog={transactionIndex:ve,blockNumber:ve,transactionHash:ue,address:c,topics:Formatter.arrayOf(ue),data:ae,logIndex:ve,blockHash:ue},t.receipt={to:Formatter.allowNull(this.address,null),from:Formatter.allowNull(this.address,null),contractAddress:Formatter.allowNull(c,null),transactionIndex:ve,root:Formatter.allowNull(de),gasUsed:ie,logsBloom:Formatter.allowNull(ae),blockHash:ue,transactionHash:ue,logs:Formatter.arrayOf(this.receiptLog.bind(this)),blockNumber:ve,confirmations:Formatter.allowNull(ve,null),cumulativeGasUsed:ie,effectiveGasPrice:Formatter.allowNull(ie),status:Formatter.allowNull(ve),type:ge},t.block={hash:Formatter.allowNull(ue),parentHash:ue,number:ve,timestamp:ve,nonce:Formatter.allowNull(de),difficulty:this.difficulty.bind(this),gasLimit:ie,gasUsed:ie,miner:Formatter.allowNull(c),extraData:ae,transactions:Formatter.allowNull(Formatter.arrayOf(ue)),baseFeePerGas:Formatter.allowNull(ie)},t.blockWithTransactions=shallowCopy(t.block),t.blockWithTransactions.transactions=Formatter.allowNull(Formatter.arrayOf(this.transactionResponse.bind(this))),t.filter={fromBlock:Formatter.allowNull(se,void 0),toBlock:Formatter.allowNull(se,void 0),blockHash:Formatter.allowNull(ue,void 0),address:Formatter.allowNull(c,void 0),topics:Formatter.allowNull(this.topics.bind(this),void 0)},t.filterLog={blockNumber:Formatter.allowNull(ve),blockHash:Formatter.allowNull(ue),transactionIndex:ve,removed:Formatter.allowNull(this.boolean.bind(this)),address:c,data:Formatter.allowFalsish(ae,"0x"),topics:Formatter.arrayOf(ue),transactionHash:ue,logIndex:ve},t}accessList(t){return accessListify(t||[])}number(t){return t==="0x"?0:BigNumber.from(t).toNumber()}type(t){return t==="0x"||t==null?0:BigNumber.from(t).toNumber()}bigNumber(t){return BigNumber.from(t)}boolean(t){if(typeof t=="boolean")return t;if(typeof t=="string"){if(t=t.toLowerCase(),t==="true")return!0;if(t==="false")return!1}throw new Error("invalid boolean - "+t)}hex(t,c){return typeof t=="string"&&(!c&&t.substring(0,2)!=="0x"&&(t="0x"+t),isHexString(t))?t.toLowerCase():logger$5.throwArgumentError("invalid hash","value",t)}data(t,c){const ie=this.hex(t,c);if(ie.length%2!==0)throw new Error("invalid data; odd-length - "+t);return ie}address(t){return getAddress$1(t)}callAddress(t){if(!isHexString(t,32))return null;const c=getAddress$1(hexDataSlice(t,12));return c===AddressZero?null:c}contractAddress(t){return getContractAddress(t)}blockTag(t){if(t==null)return"latest";if(t==="earliest")return"0x0";switch(t){case"earliest":return"0x0";case"latest":case"pending":case"safe":case"finalized":return t}if(typeof t=="number"||isHexString(t))return hexValue(t);throw new Error("invalid blockTag")}hash(t,c){const ie=this.hex(t,c);return hexDataLength(ie)!==32?logger$5.throwArgumentError("invalid hash","value",t):ie}difficulty(t){if(t==null)return null;const c=BigNumber.from(t);try{return c.toNumber()}catch{}return null}uint256(t){if(!isHexString(t))throw new Error("invalid uint256");return hexZeroPad(t,32)}_block(t,c){t.author!=null&&t.miner==null&&(t.miner=t.author);const ie=t._difficulty!=null?t._difficulty:t.difficulty,se=Formatter.check(c,t);return se._difficulty=ie==null?null:BigNumber.from(ie),se}block(t){return this._block(t,this.formats.block)}blockWithTransactions(t){return this._block(t,this.formats.blockWithTransactions)}transactionRequest(t){return Formatter.check(this.formats.transactionRequest,t)}transactionResponse(t){t.gas!=null&&t.gasLimit==null&&(t.gasLimit=t.gas),t.to&&BigNumber.from(t.to).isZero()&&(t.to="0x0000000000000000000000000000000000000000"),t.input!=null&&t.data==null&&(t.data=t.input),t.to==null&&t.creates==null&&(t.creates=this.contractAddress(t)),(t.type===1||t.type===2)&&t.accessList==null&&(t.accessList=[]);const c=Formatter.check(this.formats.transaction,t);if(t.chainId!=null){let ie=t.chainId;isHexString(ie)&&(ie=BigNumber.from(ie).toNumber()),c.chainId=ie}else{let ie=t.networkId;ie==null&&c.v==null&&(ie=t.chainId),isHexString(ie)&&(ie=BigNumber.from(ie).toNumber()),typeof ie!="number"&&c.v!=null&&(ie=(c.v-35)/2,ie<0&&(ie=0),ie=parseInt(ie)),typeof ie!="number"&&(ie=0),c.chainId=ie}return c.blockHash&&c.blockHash.replace(/0/g,"")==="x"&&(c.blockHash=null),c}transaction(t){return parse$2(t)}receiptLog(t){return Formatter.check(this.formats.receiptLog,t)}receipt(t){const c=Formatter.check(this.formats.receipt,t);if(c.root!=null)if(c.root.length<=4){const ie=BigNumber.from(c.root).toNumber();ie===0||ie===1?(c.status!=null&&c.status!==ie&&logger$5.throwArgumentError("alt-root-status/status mismatch","value",{root:c.root,status:c.status}),c.status=ie,delete c.root):logger$5.throwArgumentError("invalid alt-root-status","value.root",c.root)}else c.root.length!==66&&logger$5.throwArgumentError("invalid root hash","value.root",c.root);return c.status!=null&&(c.byzantium=!0),c}topics(t){return Array.isArray(t)?t.map(c=>this.topics(c)):t!=null?this.hash(t,!0):null}filter(t){return Formatter.check(this.formats.filter,t)}filterLog(t){return Formatter.check(this.formats.filterLog,t)}static check(t,c){const ie={};for(const se in t)try{const ae=t[se](c[se]);ae!==void 0&&(ie[se]=ae)}catch(ae){throw ae.checkKey=se,ae.checkValue=c[se],ae}return ie}static allowNull(t,c){return function(ie){return ie==null?c:t(ie)}}static allowFalsish(t,c){return function(ie){return ie?t(ie):c}}static arrayOf(t){return function(c){if(!Array.isArray(c))throw new Error("not an array");const ie=[];return c.forEach(function(se){ie.push(t(se))}),ie}}}var __awaiter$c=function(n,t,c,ie){function se(ae){return ae instanceof c?ae:new c(function(ue){ue(ae)})}return new(c||(c=Promise))(function(ae,ue){function de(we){try{ge(ie.next(we))}catch(Te){ue(Te)}}function ve(we){try{ge(ie.throw(we))}catch(Te){ue(Te)}}function ge(we){we.done?ae(we.value):se(we.value).then(de,ve)}ge((ie=ie.apply(n,[])).next())})};const logger$4=new Logger(version$8),MAX_CCIP_REDIRECTS=10;function checkTopic(n){return n==null?"null":(hexDataLength(n)!==32&&logger$4.throwArgumentError("invalid topic","topic",n),n.toLowerCase())}function serializeTopics(n){for(n=n.slice();n.length>0&&n[n.length-1]==null;)n.pop();return n.map(t=>{if(Array.isArray(t)){const c={};t.forEach(se=>{c[checkTopic(se)]=!0});const ie=Object.keys(c);return ie.sort(),ie.join("|")}else return checkTopic(t)}).join("&")}function deserializeTopics(n){return n===""?[]:n.split(/&/g).map(t=>{if(t==="")return[];const c=t.split("|").map(ie=>ie==="null"?null:ie);return c.length===1?c[0]:c})}function getEventTag(n){if(typeof n=="string"){if(n=n.toLowerCase(),hexDataLength(n)===32)return"tx:"+n;if(n.indexOf(":")===-1)return n}else{if(Array.isArray(n))return"filter:*:"+serializeTopics(n);if(ForkEvent.isForkEvent(n))throw logger$4.warn("not implemented"),new Error("not implemented");if(n&&typeof n=="object")return"filter:"+(n.address||"*")+":"+serializeTopics(n.topics||[])}throw new Error("invalid event - "+n)}function getTime(){return new Date().getTime()}function stall(n){return new Promise(t=>{setTimeout(t,n)})}const PollableEvents=["block","network","pending","poll"];let Event$1=class{constructor(n,t,c){defineReadOnly(this,"tag",n),defineReadOnly(this,"listener",t),defineReadOnly(this,"once",c),this._lastBlockNumber=-2,this._inflight=!1}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 n=this.tag.split(":");return n[0]!=="tx"?null:n[1]}get filter(){const n=this.tag.split(":");if(n[0]!=="filter")return null;const t=n[1],c=deserializeTopics(n[2]),ie={};return c.length>0&&(ie.topics=c),t&&t!=="*"&&(ie.address=t),ie}pollable(){return this.tag.indexOf(":")>=0||PollableEvents.indexOf(this.tag)>=0}};const coinInfos={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 bytes32ify(n){return hexZeroPad(BigNumber.from(n).toHexString(),32)}function base58Encode(n){return Base58.encode(concat$1([n,hexDataSlice(sha256$7(sha256$7(n)),0,4)]))}const matcherIpfs=new RegExp("^(ipfs)://(.*)$","i"),matchers=[new RegExp("^(https)://(.*)$","i"),new RegExp("^(data):(.*)$","i"),matcherIpfs,new RegExp("^eip155:[0-9]+/(erc[0-9]+):(.*)$","i")];function _parseString(n,t){try{return toUtf8String(_parseBytes(n,t))}catch{}return null}function _parseBytes(n,t){if(n==="0x")return null;const c=BigNumber.from(hexDataSlice(n,t,t+32)).toNumber(),ie=BigNumber.from(hexDataSlice(n,c,c+32)).toNumber();return hexDataSlice(n,c+32,c+32+ie)}function getIpfsLink(n){return n.match(/^ipfs:\/\/ipfs\//i)?n=n.substring(12):n.match(/^ipfs:\/\//i)?n=n.substring(7):logger$4.throwArgumentError("unsupported IPFS format","link",n),`https://gateway.ipfs.io/ipfs/${n}`}function numPad(n){const t=arrayify(n);if(t.length>32)throw new Error("internal; should not happen");const c=new Uint8Array(32);return c.set(t,32-t.length),c}function bytesPad(n){if(n.length%32===0)return n;const t=new Uint8Array(Math.ceil(n.length/32)*32);return t.set(n),t}function encodeBytes(n){const t=[];let c=0;for(let ie=0;ie<n.length;ie++)t.push(null),c+=32;for(let ie=0;ie<n.length;ie++){const se=arrayify(n[ie]);t[ie]=numPad(c),t.push(numPad(se.length)),t.push(bytesPad(se)),c+=32+Math.ceil(se.length/32)*32}return hexConcat(t)}class Resolver{constructor(t,c,ie,se){defineReadOnly(this,"provider",t),defineReadOnly(this,"name",ie),defineReadOnly(this,"address",t.formatter.address(c)),defineReadOnly(this,"_resolvedAddress",se)}supportsWildcard(){return this._supportsEip2544||(this._supportsEip2544=this.provider.call({to:this.address,data:"0x01ffc9a79061b92300000000000000000000000000000000000000000000000000000000"}).then(t=>BigNumber.from(t).eq(1)).catch(t=>{if(t.code===Logger.errors.CALL_EXCEPTION)return!1;throw this._supportsEip2544=null,t})),this._supportsEip2544}_fetch(t,c){return __awaiter$c(this,void 0,void 0,function*(){const ie={to:this.address,ccipReadEnabled:!0,data:hexConcat([t,namehash$1(this.name),c||"0x"])};let se=!1;(yield this.supportsWildcard())&&(se=!0,ie.data=hexConcat(["0x9061b923",encodeBytes([dnsEncode(this.name),ie.data])]));try{let ae=yield this.provider.call(ie);return arrayify(ae).length%32===4&&logger$4.throwError("resolver threw error",Logger.errors.CALL_EXCEPTION,{transaction:ie,data:ae}),se&&(ae=_parseBytes(ae,0)),ae}catch(ae){if(ae.code===Logger.errors.CALL_EXCEPTION)return null;throw ae}})}_fetchBytes(t,c){return __awaiter$c(this,void 0,void 0,function*(){const ie=yield this._fetch(t,c);return ie!=null?_parseBytes(ie,0):null})}_getAddress(t,c){const ie=coinInfos[String(t)];if(ie==null&&logger$4.throwError(`unsupported coin type: ${t}`,Logger.errors.UNSUPPORTED_OPERATION,{operation:`getAddress(${t})`}),ie.ilk==="eth")return this.provider.formatter.address(c);const se=arrayify(c);if(ie.p2pkh!=null){const ae=c.match(/^0x76a9([0-9a-f][0-9a-f])([0-9a-f]*)88ac$/);if(ae){const ue=parseInt(ae[1],16);if(ae[2].length===ue*2&&ue>=1&&ue<=75)return base58Encode(concat$1([[ie.p2pkh],"0x"+ae[2]]))}}if(ie.p2sh!=null){const ae=c.match(/^0xa9([0-9a-f][0-9a-f])([0-9a-f]*)87$/);if(ae){const ue=parseInt(ae[1],16);if(ae[2].length===ue*2&&ue>=1&&ue<=75)return base58Encode(concat$1([[ie.p2sh],"0x"+ae[2]]))}}if(ie.prefix!=null){const ae=se[1];let ue=se[0];if(ue===0?ae!==20&&ae!==32&&(ue=-1):ue=-1,ue>=0&&se.length===2+ae&&ae>=1&&ae<=75){const de=bech32$2.toWords(se.slice(2));return de.unshift(ue),bech32$2.encode(ie.prefix,de)}}return null}getAddress(t){return __awaiter$c(this,void 0,void 0,function*(){if(t==null&&(t=60),t===60)try{const se=yield this._fetch("0x3b3b57de");return se==="0x"||se===HashZero?null:this.provider.formatter.callAddress(se)}catch(se){if(se.code===Logger.errors.CALL_EXCEPTION)return null;throw se}const c=yield this._fetchBytes("0xf1cb7e06",bytes32ify(t));if(c==null||c==="0x")return null;const ie=this._getAddress(t,c);return ie==null&&logger$4.throwError("invalid or unsupported coin data",Logger.errors.UNSUPPORTED_OPERATION,{operation:`getAddress(${t})`,coinType:t,data:c}),ie})}getAvatar(){return __awaiter$c(this,void 0,void 0,function*(){const t=[{type:"name",content:this.name}];try{const c=yield this.getText("avatar");if(c==null)return null;for(let ie=0;ie<matchers.length;ie++){const se=c.match(matchers[ie]);if(se==null)continue;const ae=se[1].toLowerCase();switch(ae){case"https":return t.push({type:"url",content:c}),{linkage:t,url:c};case"data":return t.push({type:"data",content:c}),{linkage:t,url:c};case"ipfs":return t.push({type:"ipfs",content:c}),{linkage:t,url:getIpfsLink(c)};case"erc721":case"erc1155":{const ue=ae==="erc721"?"0xc87b56dd":"0x0e89341c";t.push({type:ae,content:c});const de=this._resolvedAddress||(yield this.getAddress()),ve=(se[2]||"").split("/");if(ve.length!==2)return null;const ge=yield this.provider.formatter.address(ve[0]),we=hexZeroPad(BigNumber.from(ve[1]).toHexString(),32);if(ae==="erc721"){const He=this.provider.formatter.callAddress(yield this.provider.call({to:ge,data:hexConcat(["0x6352211e",we])}));if(de!==He)return null;t.push({type:"owner",content:He})}else if(ae==="erc1155"){const He=BigNumber.from(yield this.provider.call({to:ge,data:hexConcat(["0x00fdd58e",hexZeroPad(de,32),we])}));if(He.isZero())return null;t.push({type:"balance",content:He.toString()})}const Te={to:this.provider.formatter.address(ve[0]),data:hexConcat([ue,we])};let Ne=_parseString(yield this.provider.call(Te),0);if(Ne==null)return null;t.push({type:"metadata-url-base",content:Ne}),ae==="erc1155"&&(Ne=Ne.replace("{id}",we.substring(2)),t.push({type:"metadata-url-expanded",content:Ne})),Ne.match(/^ipfs:/i)&&(Ne=getIpfsLink(Ne)),t.push({type:"metadata-url",content:Ne});const qe=yield fetchJson(Ne);if(!qe)return null;t.push({type:"metadata",content:JSON.stringify(qe)});let ze=qe.image;if(typeof ze!="string")return null;if(!ze.match(/^(https:\/\/|data:)/i)){if(ze.match(matcherIpfs)==null)return null;t.push({type:"url-ipfs",content:ze}),ze=getIpfsLink(ze)}return t.push({type:"url",content:ze}),{linkage:t,url:ze}}}}}catch{}return null})}getContentHash(){return __awaiter$c(this,void 0,void 0,function*(){const t=yield this._fetchBytes("0xbc1c58d1");if(t==null||t==="0x")return null;const c=t.match(/^0xe3010170(([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])([0-9a-f]*))$/);if(c){const ue=parseInt(c[3],16);if(c[4].length===ue*2)return"ipfs://"+Base58.encode("0x"+c[1])}const ie=t.match(/^0xe5010172(([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])([0-9a-f]*))$/);if(ie){const ue=parseInt(ie[3],16);if(ie[4].length===ue*2)return"ipns://"+Base58.encode("0x"+ie[1])}const se=t.match(/^0xe40101fa011b20([0-9a-f]*)$/);if(se&&se[1].length===64)return"bzz://"+se[1];const ae=t.match(/^0x90b2c605([0-9a-f]*)$/);if(ae&&ae[1].length===68){const ue={"=":"","+":"-","/":"_"};return"sia://"+encode$5("0x"+ae[1]).replace(/[=+\/]/g,de=>ue[de])}return logger$4.throwError("invalid or unsupported content hash data",Logger.errors.UNSUPPORTED_OPERATION,{operation:"getContentHash()",data:t})})}getText(t){return __awaiter$c(this,void 0,void 0,function*(){let c=toUtf8Bytes(t);c=concat$1([bytes32ify(64),bytes32ify(c.length),c]),c.length%32!==0&&(c=concat$1([c,hexZeroPad("0x",32-t.length%32)]));const ie=yield this._fetchBytes("0x59d1d43c",hexlify(c));return ie==null||ie==="0x"?null:toUtf8String(ie)})}}let defaultFormatter=null,nextPollId=1;class BaseProvider extends Provider{constructor(t){if(super(),this._events=[],this._emitted={block:-2},this.disableCcipRead=!1,this.formatter=new.target.getFormatter(),defineReadOnly(this,"anyNetwork",t==="any"),this.anyNetwork&&(t=this.detectNetwork()),t instanceof Promise)this._networkPromise=t,t.catch(c=>{}),this._ready().catch(c=>{});else{const c=getStatic(new.target,"getNetwork")(t);c?(defineReadOnly(this,"_network",c),this.emit("network",c,null)):logger$4.throwArgumentError("invalid network","network",t)}this._maxInternalBlockNumber=-1024,this._lastBlockNumber=-2,this._maxFilterBlockRange=10,this._pollingInterval=4e3,this._fastQueryDate=0}_ready(){return __awaiter$c(this,void 0,void 0,function*(){if(this._network==null){let t=null;if(this._networkPromise)try{t=yield this._networkPromise}catch{}t==null&&(t=yield this.detectNetwork()),t||logger$4.throwError("no network detected",Logger.errors.UNKNOWN_ERROR,{}),this._network==null&&(this.anyNetwork?this._network=t:defineReadOnly(this,"_network",t),this.emit("network",t,null))}return this._network})}get ready(){return poll(()=>this._ready().then(t=>t,t=>{if(!(t.code===Logger.errors.NETWORK_ERROR&&t.event==="noNetwork"))throw t}))}static getFormatter(){return defaultFormatter==null&&(defaultFormatter=new Formatter),defaultFormatter}static getNetwork(t){return getNetwork(t??"homestead")}ccipReadFetch(t,c,ie){return __awaiter$c(this,void 0,void 0,function*(){if(this.disableCcipRead||ie.length===0)return null;const se=t.to.toLowerCase(),ae=c.toLowerCase(),ue=[];for(let de=0;de<ie.length;de++){const ve=ie[de],ge=ve.replace("{sender}",se).replace("{data}",ae),we=ve.indexOf("{data}")>=0?null:JSON.stringify({data:ae,sender:se}),Te=yield fetchJson({url:ge,errorPassThrough:!0},we,(qe,ze)=>(qe.status=ze.statusCode,qe));if(Te.data)return Te.data;const Ne=Te.message||"unknown error";if(Te.status>=400&&Te.status<500)return logger$4.throwError(`response not found during CCIP fetch: ${Ne}`,Logger.errors.SERVER_ERROR,{url:ve,errorMessage:Ne});ue.push(Ne)}return logger$4.throwError(`error encountered during CCIP fetch: ${ue.map(de=>JSON.stringify(de)).join(", ")}`,Logger.errors.SERVER_ERROR,{urls:ie,errorMessages:ue})})}_getInternalBlockNumber(t){return __awaiter$c(this,void 0,void 0,function*(){if(yield this._ready(),t>0)for(;this._internalBlockNumber;){const se=this._internalBlockNumber;try{const ae=yield se;if(getTime()-ae.respTime<=t)return ae.blockNumber;break}catch{if(this._internalBlockNumber===se)break}}const c=getTime(),ie=resolveProperties({blockNumber:this.perform("getBlockNumber",{}),networkError:this.getNetwork().then(se=>null,se=>se)}).then(({blockNumber:se,networkError:ae})=>{if(ae)throw this._internalBlockNumber===ie&&(this._internalBlockNumber=null),ae;const ue=getTime();return se=BigNumber.from(se).toNumber(),se<this._maxInternalBlockNumber&&(se=this._maxInternalBlockNumber),this._maxInternalBlockNumber=se,this._setFastBlockNumber(se),{blockNumber:se,reqTime:c,respTime:ue}});return this._internalBlockNumber=ie,ie.catch(se=>{this._internalBlockNumber===ie&&(this._internalBlockNumber=null)}),(yield ie).blockNumber})}poll(){return __awaiter$c(this,void 0,void 0,function*(){const t=nextPollId++,c=[];let ie=null;try{ie=yield this._getInternalBlockNumber(100+this.pollingInterval/2)}catch(se){this.emit("error",se);return}if(this._setFastBlockNumber(ie),this.emit("poll",t,ie),ie===this._lastBlockNumber){this.emit("didPoll",t);return}if(this._emitted.block===-2&&(this._emitted.block=ie-1),Math.abs(this._emitted.block-ie)>1e3)logger$4.warn(`network block skew detected; skipping block events (emitted=${this._emitted.block} blockNumber${ie})`),this.emit("error",logger$4.makeError("network block skew detected",Logger.errors.NETWORK_ERROR,{blockNumber:ie,event:"blockSkew",previousBlockNumber:this._emitted.block})),this.emit("block",ie);else for(let se=this._emitted.block+1;se<=ie;se++)this.emit("block",se);this._emitted.block!==ie&&(this._emitted.block=ie,Object.keys(this._emitted).forEach(se=>{if(se==="block")return;const ae=this._emitted[se];ae!=="pending"&&ie-ae>12&&delete this._emitted[se]})),this._lastBlockNumber===-2&&(this._lastBlockNumber=ie-1),this._events.forEach(se=>{switch(se.type){case"tx":{const ae=se.hash;let ue=this.getTransactionReceipt(ae).then(de=>(!de||de.blockNumber==null||(this._emitted["t:"+ae]=de.blockNumber,this.emit(ae,de)),null)).catch(de=>{this.emit("error",de)});c.push(ue);break}case"filter":{if(!se._inflight){se._inflight=!0,se._lastBlockNumber===-2&&(se._lastBlockNumber=ie-1);const ae=se.filter;ae.fromBlock=se._lastBlockNumber+1,ae.toBlock=ie;const ue=ae.toBlock-this._maxFilterBlockRange;ue>ae.fromBlock&&(ae.fromBlock=ue),ae.fromBlock<0&&(ae.fromBlock=0);const de=this.getLogs(ae).then(ve=>{se._inflight=!1,ve.length!==0&&ve.forEach(ge=>{ge.blockNumber>se._lastBlockNumber&&(se._lastBlockNumber=ge.blockNumber),this._emitted["b:"+ge.blockHash]=ge.blockNumber,this._emitted["t:"+ge.transactionHash]=ge.blockNumber,this.emit(ae,ge)})}).catch(ve=>{this.emit("error",ve),se._inflight=!1});c.push(de)}break}}}),this._lastBlockNumber=ie,Promise.all(c).then(()=>{this.emit("didPoll",t)}).catch(se=>{this.emit("error",se)})})}resetEventsBlock(t){this._lastBlockNumber=t-1,this.polling&&this.poll()}get network(){return this._network}detectNetwork(){return __awaiter$c(this,void 0,void 0,function*(){return logger$4.throwError("provider does not support network detection",Logger.errors.UNSUPPORTED_OPERATION,{operation:"provider.detectNetwork"})})}getNetwork(){return __awaiter$c(this,void 0,void 0,function*(){const t=yield this._ready(),c=yield this.detectNetwork();if(t.chainId!==c.chainId){if(this.anyNetwork)return this._network=c,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",c,t),yield stall(0),this._network;const ie=logger$4.makeError("underlying network changed",Logger.errors.NETWORK_ERROR,{event:"changed",network:t,detectedNetwork:c});throw this.emit("error",ie),ie}return t})}get blockNumber(){return this._getInternalBlockNumber(100+this.pollingInterval/2).then(t=>{this._setFastBlockNumber(t)},t=>{}),this._fastBlockNumber!=null?this._fastBlockNumber:-1}get polling(){return this._poller!=null}set polling(t){t&&!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))):!t&&this._poller&&(clearInterval(this._poller),this._poller=null)}get pollingInterval(){return this._pollingInterval}set pollingInterval(t){if(typeof t!="number"||t<=0||parseInt(String(t))!=t)throw new Error("invalid polling interval");this._pollingInterval=t,this._poller&&(clearInterval(this._poller),this._poller=setInterval(()=>{this.poll()},this._pollingInterval))}_getFastBlockNumber(){const t=getTime();return t-this._fastQueryDate>2*this._pollingInterval&&(this._fastQueryDate=t,this._fastBlockNumberPromise=this.getBlockNumber().then(c=>((this._fastBlockNumber==null||c>this._fastBlockNumber)&&(this._fastBlockNumber=c),this._fastBlockNumber))),this._fastBlockNumberPromise}_setFastBlockNumber(t){this._fastBlockNumber!=null&&t<this._fastBlockNumber||(this._fastQueryDate=getTime(),(this._fastBlockNumber==null||t>this._fastBlockNumber)&&(this._fastBlockNumber=t,this._fastBlockNumberPromise=Promise.resolve(t)))}waitForTransaction(t,c,ie){return __awaiter$c(this,void 0,void 0,function*(){return this._waitForTransaction(t,c??1,ie||0,null)})}_waitForTransaction(t,c,ie,se){return __awaiter$c(this,void 0,void 0,function*(){const ae=yield this.getTransactionReceipt(t);return(ae?ae.confirmations:0)>=c?ae:new Promise((ue,de)=>{const ve=[];let ge=!1;const we=function(){return ge?!0:(ge=!0,ve.forEach(Ne=>{Ne()}),!1)},Te=Ne=>{Ne.confirmations<c||we()||ue(Ne)};if(this.on(t,Te),ve.push(()=>{this.removeListener(t,Te)}),se){let Ne=se.startBlock,qe=null;const ze=He=>__awaiter$c(this,void 0,void 0,function*(){ge||(yield stall(1e3),this.getTransactionCount(se.from).then(Ge=>__awaiter$c(this,void 0,void 0,function*(){if(!ge){if(Ge<=se.nonce)Ne=He;else{{const Ze=yield this.getTransaction(t);if(Ze&&Ze.blockNumber!=null)return}for(qe==null&&(qe=Ne-3,qe<se.startBlock&&(qe=se.startBlock));qe<=He;){if(ge)return;const Ze=yield this.getBlockWithTransactions(qe);for(let Ye=0;Ye<Ze.transactions.length;Ye++){const Ft=Ze.transactions[Ye];if(Ft.hash===t)return;if(Ft.from===se.from&&Ft.nonce===se.nonce){if(ge)return;const Mt=yield this.waitForTransaction(Ft.hash,c);if(we())return;let Zt="replaced";Ft.data===se.data&&Ft.to===se.to&&Ft.value.eq(se.value)?Zt="repriced":Ft.data==="0x"&&Ft.from===Ft.to&&Ft.value.isZero()&&(Zt="cancelled"),de(logger$4.makeError("transaction was replaced",Logger.errors.TRANSACTION_REPLACED,{cancelled:Zt==="replaced"||Zt==="cancelled",reason:Zt,replacement:this._wrapTransaction(Ft),hash:t,receipt:Mt}));return}}qe++}}ge||this.once("block",ze)}}),Ge=>{ge||this.once("block",ze)}))});if(ge)return;this.once("block",ze),ve.push(()=>{this.removeListener("block",ze)})}if(typeof ie=="number"&&ie>0){const Ne=setTimeout(()=>{we()||de(logger$4.makeError("timeout exceeded",Logger.errors.TIMEOUT,{timeout:ie}))},ie);Ne.unref&&Ne.unref(),ve.push(()=>{clearTimeout(Ne)})}})})}getBlockNumber(){return __awaiter$c(this,void 0,void 0,function*(){return this._getInternalBlockNumber(0)})}getGasPrice(){return __awaiter$c(this,void 0,void 0,function*(){yield this.getNetwork();const t=yield this.perform("getGasPrice",{});try{return BigNumber.from(t)}catch(c){return logger$4.throwError("bad result from backend",Logger.errors.SERVER_ERROR,{method:"getGasPrice",result:t,error:c})}})}getBalance(t,c){return __awaiter$c(this,void 0,void 0,function*(){yield this.getNetwork();const ie=yield resolveProperties({address:this._getAddress(t),blockTag:this._getBlockTag(c)}),se=yield this.perform("getBalance",ie);try{return BigNumber.from(se)}catch(ae){return logger$4.throwError("bad result from backend",Logger.errors.SERVER_ERROR,{method:"getBalance",params:ie,result:se,error:ae})}})}getTransactionCount(t,c){return __awaiter$c(this,void 0,void 0,function*(){yield this.getNetwork();const ie=yield resolveProperties({address:this._getAddress(t),blockTag:this._getBlockTag(c)}),se=yield this.perform("getTransactionCount",ie);try{return BigNumber.from(se).toNumber()}catch(ae){return logger$4.throwError("bad result from backend",Logger.errors.SERVER_ERROR,{method:"getTransactionCount",params:ie,result:se,error:ae})}})}getCode(t,c){return __awaiter$c(this,void 0,void 0,function*(){yield this.getNetwork();const ie=yield resolveProperties({address:this._getAddress(t),blockTag:this._getBlockTag(c)}),se=yield this.perform("getCode",ie);try{return hexlify(se)}catch(ae){return logger$4.throwError("bad result from backend",Logger.errors.SERVER_ERROR,{method:"getCode",params:ie,result:se,error:ae})}})}getStorageAt(t,c,ie){return __awaiter$c(this,void 0,void 0,function*(){yield this.getNetwork();const se=yield resolveProperties({address:this._getAddress(t),blockTag:this._getBlockTag(ie),position:Promise.resolve(c).then(ue=>hexValue(ue))}),ae=yield this.perform("getStorageAt",se);try{return hexlify(ae)}catch(ue){return logger$4.throwError("bad result from backend",Logger.errors.SERVER_ERROR,{method:"getStorageAt",params:se,result:ae,error:ue})}})}_wrapTransaction(t,c,ie){if(c!=null&&hexDataLength(c)!==32)throw new Error("invalid response - sendTransaction");const se=t;return c!=null&&t.hash!==c&&logger$4.throwError("Transaction hash mismatch from Provider.sendTransaction.",Logger.errors.UNKNOWN_ERROR,{expectedHash:t.hash,returnedHash:c}),se.wait=(ae,ue)=>__awaiter$c(this,void 0,void 0,function*(){ae==null&&(ae=1),ue==null&&(ue=0);let de;ae!==0&&ie!=null&&(de={data:t.data,from:t.from,nonce:t.nonce,to:t.to,value:t.value,startBlock:ie});const ve=yield this._waitForTransaction(t.hash,ae,ue,de);return ve==null&&ae===0?null:(this._emitted["t:"+t.hash]=ve.blockNumber,ve.status===0&&logger$4.throwError("transaction failed",Logger.errors.CALL_EXCEPTION,{transactionHash:t.hash,transaction:t,receipt:ve}),ve)}),se}sendTransaction(t){return __awaiter$c(this,void 0,void 0,function*(){yield this.getNetwork();const c=yield Promise.resolve(t).then(ae=>hexlify(ae)),ie=this.formatter.transaction(t);ie.confirmations==null&&(ie.confirmations=0);const se=yield this._getInternalBlockNumber(100+2*this.pollingInterval);try{const ae=yield this.perform("sendTransaction",{signedTransaction:c});return this._wrapTransaction(ie,ae,se)}catch(ae){throw ae.transaction=ie,ae.transactionHash=ie.hash,ae}})}_getTransactionRequest(t){return __awaiter$c(this,void 0,void 0,function*(){const c=yield t,ie={};return["from","to"].forEach(se=>{c[se]!=null&&(ie[se]=Promise.resolve(c[se]).then(ae=>ae?this._getAddress(ae):null))}),["gasLimit","gasPrice","maxFeePerGas","maxPriorityFeePerGas","value"].forEach(se=>{c[se]!=null&&(ie[se]=Promise.resolve(c[se]).then(ae=>ae?BigNumber.from(ae):null))}),["type"].forEach(se=>{c[se]!=null&&(ie[se]=Promise.resolve(c[se]).then(ae=>ae??null))}),c.accessList&&(ie.accessList=this.formatter.accessList(c.accessList)),["data"].forEach(se=>{c[se]!=null&&(ie[se]=Promise.resolve(c[se]).then(ae=>ae?hexlify(ae):null))}),this.formatter.transactionRequest(yield resolveProperties(ie))})}_getFilter(t){return __awaiter$c(this,void 0,void 0,function*(){t=yield t;const c={};return t.address!=null&&(c.address=this._getAddress(t.address)),["blockHash","topics"].forEach(ie=>{t[ie]!=null&&(c[ie]=t[ie])}),["fromBlock","toBlock"].forEach(ie=>{t[ie]!=null&&(c[ie]=this._getBlockTag(t[ie]))}),this.formatter.filter(yield resolveProperties(c))})}_call(t,c,ie){return __awaiter$c(this,void 0,void 0,function*(){ie>=MAX_CCIP_REDIRECTS&&logger$4.throwError("CCIP read exceeded maximum redirections",Logger.errors.SERVER_ERROR,{redirects:ie,transaction:t});const se=t.to,ae=yield this.perform("call",{transaction:t,blockTag:c});if(ie>=0&&c==="latest"&&se!=null&&ae.substring(0,10)==="0x556f1830"&&hexDataLength(ae)%32===4)try{const ue=hexDataSlice(ae,4),de=hexDataSlice(ue,0,32);BigNumber.from(de).eq(se)||logger$4.throwError("CCIP Read sender did not match",Logger.errors.CALL_EXCEPTION,{name:"OffchainLookup",signature:"OffchainLookup(address,string[],bytes,bytes4,bytes)",transaction:t,data:ae});const ve=[],ge=BigNumber.from(hexDataSlice(ue,32,64)).toNumber(),we=BigNumber.from(hexDataSlice(ue,ge,ge+32)).toNumber(),Te=hexDataSlice(ue,ge+32);for(let Ze=0;Ze<we;Ze++){const Ye=_parseString(Te,Ze*32);Ye==null&&logger$4.throwError("CCIP Read contained corrupt URL string",Logger.errors.CALL_EXCEPTION,{name:"OffchainLookup",signature:"OffchainLookup(address,string[],bytes,bytes4,bytes)",transaction:t,data:ae}),ve.push(Ye)}const Ne=_parseBytes(ue,64);BigNumber.from(hexDataSlice(ue,100,128)).isZero()||logger$4.throwError("CCIP Read callback selector included junk",Logger.errors.CALL_EXCEPTION,{name:"OffchainLookup",signature:"OffchainLookup(address,string[],bytes,bytes4,bytes)",transaction:t,data:ae});const qe=hexDataSlice(ue,96,100),ze=_parseBytes(ue,128),He=yield this.ccipReadFetch(t,Ne,ve);He==null&&logger$4.throwError("CCIP Read disabled or provided no URLs",Logger.errors.CALL_EXCEPTION,{name:"OffchainLookup",signature:"OffchainLookup(address,string[],bytes,bytes4,bytes)",transaction:t,data:ae});const Ge={to:se,data:hexConcat([qe,encodeBytes([He,ze])])};return this._call(Ge,c,ie+1)}catch(ue){if(ue.code===Logger.errors.SERVER_ERROR)throw ue}try{return hexlify(ae)}catch(ue){return logger$4.throwError("bad result from backend",Logger.errors.SERVER_ERROR,{method:"call",params:{transaction:t,blockTag:c},result:ae,error:ue})}})}call(t,c){return __awaiter$c(this,void 0,void 0,function*(){yield this.getNetwork();const ie=yield resolveProperties({transaction:this._getTransactionRequest(t),blockTag:this._getBlockTag(c),ccipReadEnabled:Promise.resolve(t.ccipReadEnabled)});return this._call(ie.transaction,ie.blockTag,ie.ccipReadEnabled?0:-1)})}estimateGas(t){return __awaiter$c(this,void 0,void 0,function*(){yield this.getNetwork();const c=yield resolveProperties({transaction:this._getTransactionRequest(t)}),ie=yield this.perform("estimateGas",c);try{return BigNumber.from(ie)}catch(se){return logger$4.throwError("bad result from backend",Logger.errors.SERVER_ERROR,{method:"estimateGas",params:c,result:ie,error:se})}})}_getAddress(t){return __awaiter$c(this,void 0,void 0,function*(){t=yield t,typeof t!="string"&&logger$4.throwArgumentError("invalid address or ENS name","name",t);const c=yield this.resolveName(t);return c==null&&logger$4.throwError("ENS name not configured",Logger.errors.UNSUPPORTED_OPERATION,{operation:`resolveName(${JSON.stringify(t)})`}),c})}_getBlock(t,c){return __awaiter$c(this,void 0,void 0,function*(){yield this.getNetwork(),t=yield t;let ie=-128;const se={includeTransactions:!!c};if(isHexString(t,32))se.blockHash=t;else try{se.blockTag=yield this._getBlockTag(t),isHexString(se.blockTag)&&(ie=parseInt(se.blockTag.substring(2),16))}catch{logger$4.throwArgumentError("invalid block hash or block tag","blockHashOrBlockTag",t)}return poll(()=>__awaiter$c(this,void 0,void 0,function*(){const ae=yield this.perform("getBlock",se);if(ae==null)return se.blockHash!=null&&this._emitted["b:"+se.blockHash]==null||se.blockTag!=null&&ie>this._emitted.block?null:void 0;if(c){let ue=null;for(let ve=0;ve<ae.transactions.length;ve++){const ge=ae.transactions[ve];if(ge.blockNumber==null)ge.confirmations=0;else if(ge.confirmations==null){ue==null&&(ue=yield this._getInternalBlockNumber(100+2*this.pollingInterval));let we=ue-ge.blockNumber+1;we<=0&&(we=1),ge.confirmations=we}}const de=this.formatter.blockWithTransactions(ae);return de.transactions=de.transactions.map(ve=>this._wrapTransaction(ve)),de}return this.formatter.block(ae)}),{oncePoll:this})})}getBlock(t){return this._getBlock(t,!1)}getBlockWithTransactions(t){return this._getBlock(t,!0)}getTransaction(t){return __awaiter$c(this,void 0,void 0,function*(){yield this.getNetwork(),t=yield t;const c={transactionHash:this.formatter.hash(t,!0)};return poll(()=>__awaiter$c(this,void 0,void 0,function*(){const ie=yield this.perform("getTransaction",c);if(ie==null)return this._emitted["t:"+t]==null?null:void 0;const se=this.formatter.transactionResponse(ie);if(se.blockNumber==null)se.confirmations=0;else if(se.confirmations==null){let ae=(yield this._getInternalBlockNumber(100+2*this.pollingInterval))-se.blockNumber+1;ae<=0&&(ae=1),se.confirmations=ae}return this._wrapTransaction(se)}),{oncePoll:this})})}getTransactionReceipt(t){return __awaiter$c(this,void 0,void 0,function*(){yield this.getNetwork(),t=yield t;const c={transactionHash:this.formatter.hash(t,!0)};return poll(()=>__awaiter$c(this,void 0,void 0,function*(){const ie=yield this.perform("getTransactionReceipt",c);if(ie==null)return this._emitted["t:"+t]==null?null:void 0;if(ie.blockHash==null)return;const se=this.formatter.receipt(ie);if(se.blockNumber==null)se.confirmations=0;else if(se.confirmations==null){let ae=(yield this._getInternalBlockNumber(100+2*this.pollingInterval))-se.blockNumber+1;ae<=0&&(ae=1),se.confirmations=ae}return se}),{oncePoll:this})})}getLogs(t){return __awaiter$c(this,void 0,void 0,function*(){yield this.getNetwork();const c=yield resolveProperties({filter:this._getFilter(t)}),ie=yield this.perform("getLogs",c);return ie.forEach(se=>{se.removed==null&&(se.removed=!1)}),Formatter.arrayOf(this.formatter.filterLog.bind(this.formatter))(ie)})}getEtherPrice(){return __awaiter$c(this,void 0,void 0,function*(){return yield this.getNetwork(),this.perform("getEtherPrice",{})})}_getBlockTag(t){return __awaiter$c(this,void 0,void 0,function*(){if(t=yield t,typeof t=="number"&&t<0){t%1&&logger$4.throwArgumentError("invalid BlockTag","blockTag",t);let c=yield this._getInternalBlockNumber(100+2*this.pollingInterval);return c+=t,c<0&&(c=0),this.formatter.blockTag(c)}return this.formatter.blockTag(t)})}getResolver(t){return __awaiter$c(this,void 0,void 0,function*(){let c=t;for(;;){if(c===""||c==="."||t!=="eth"&&c==="eth")return null;const ie=yield this._getResolver(c,"getResolver");if(ie!=null){const se=new Resolver(this,ie,t);return c!==t&&!(yield se.supportsWildcard())?null:se}c=c.split(".").slice(1).join(".")}})}_getResolver(t,c){return __awaiter$c(this,void 0,void 0,function*(){c==null&&(c="ENS");const ie=yield this.getNetwork();ie.ensAddress||logger$4.throwError("network does not support ENS",Logger.errors.UNSUPPORTED_OPERATION,{operation:c,network:ie.name});try{const se=yield this.call({to:ie.ensAddress,data:"0x0178b8bf"+namehash$1(t).substring(2)});return this.formatter.callAddress(se)}catch{}return null})}resolveName(t){return __awaiter$c(this,void 0,void 0,function*(){t=yield t;try{return Promise.resolve(this.formatter.address(t))}catch(ie){if(isHexString(t))throw ie}typeof t!="string"&&logger$4.throwArgumentError("invalid ENS name","name",t);const c=yield this.getResolver(t);return c?yield c.getAddress():null})}lookupAddress(t){return __awaiter$c(this,void 0,void 0,function*(){t=yield t,t=this.formatter.address(t);const c=t.substring(2).toLowerCase()+".addr.reverse",ie=yield this._getResolver(c,"lookupAddress");if(ie==null)return null;const se=_parseString(yield this.call({to:ie,data:"0x691f3431"+namehash$1(c).substring(2)}),0);return(yield this.resolveName(se))!=t?null:se})}getAvatar(t){return __awaiter$c(this,void 0,void 0,function*(){let c=null;if(isHexString(t)){const se=this.formatter.address(t).substring(2).toLowerCase()+".addr.reverse",ae=yield this._getResolver(se,"getAvatar");if(!ae)return null;c=new Resolver(this,ae,se);try{const ue=yield c.getAvatar();if(ue)return ue.url}catch(ue){if(ue.code!==Logger.errors.CALL_EXCEPTION)throw ue}try{const ue=_parseString(yield this.call({to:ae,data:"0x691f3431"+namehash$1(se).substring(2)}),0);c=yield this.getResolver(ue)}catch(ue){if(ue.code!==Logger.errors.CALL_EXCEPTION)throw ue;return null}}else if(c=yield this.getResolver(t),!c)return null;const ie=yield c.getAvatar();return ie==null?null:ie.url})}perform(t,c){return logger$4.throwError(t+" not implemented",Logger.errors.NOT_IMPLEMENTED,{operation:t})}_startEvent(t){this.polling=this._events.filter(c=>c.pollable()).length>0}_stopEvent(t){this.polling=this._events.filter(c=>c.pollable()).length>0}_addEventListener(t,c,ie){const se=new Event$1(getEventTag(t),c,ie);return this._events.push(se),this._startEvent(se),this}on(t,c){return this._addEventListener(t,c,!1)}once(t,c){return this._addEventListener(t,c,!0)}emit(t,...c){let ie=!1,se=[],ae=getEventTag(t);return this._events=this._events.filter(ue=>ue.tag!==ae?!0:(setTimeout(()=>{ue.listener.apply(this,c)},0),ie=!0,ue.once?(se.push(ue),!1):!0)),se.forEach(ue=>{this._stopEvent(ue)}),ie}listenerCount(t){if(!t)return this._events.length;let c=getEventTag(t);return this._events.filter(ie=>ie.tag===c).length}listeners(t){if(t==null)return this._events.map(ie=>ie.listener);let c=getEventTag(t);return this._events.filter(ie=>ie.tag===c).map(ie=>ie.listener)}off(t,c){if(c==null)return this.removeAllListeners(t);const ie=[];let se=!1,ae=getEventTag(t);return this._events=this._events.filter(ue=>ue.tag!==ae||ue.listener!=c||se?!0:(se=!0,ie.push(ue),!1)),ie.forEach(ue=>{this._stopEvent(ue)}),this}removeAllListeners(t){let c=[];if(t==null)c=this._events,this._events=[];else{const ie=getEventTag(t);this._events=this._events.filter(se=>se.tag!==ie?!0:(c.push(se),!1))}return c.forEach(ie=>{this._stopEvent(ie)}),this}}var __awaiter$b=function(n,t,c,ie){function se(ae){return ae instanceof c?ae:new c(function(ue){ue(ae)})}return new(c||(c=Promise))(function(ae,ue){function de(we){try{ge(ie.next(we))}catch(Te){ue(Te)}}function ve(we){try{ge(ie.throw(we))}catch(Te){ue(Te)}}function ge(we){we.done?ae(we.value):se(we.value).then(de,ve)}ge((ie=ie.apply(n,[])).next())})};const logger$3=new Logger(version$8),errorGas=["call","estimateGas"];function spelunk(n,t){if(n==null)return null;if(typeof n.message=="string"&&n.message.match("reverted")){const c=isHexString(n.data)?n.data:null;if(!t||c)return{message:n.message,data:c}}if(typeof n=="object"){for(const c in n){const ie=spelunk(n[c],t);if(ie)return ie}return null}if(typeof n=="string")try{return spelunk(JSON.parse(n),t)}catch{}return null}function checkError(n,t,c){const ie=c.transaction||c.signedTransaction;if(n==="call"){const ae=spelunk(t,!0);if(ae)return ae.data;logger$3.throwError("missing revert data in call exception; Transaction reverted without a reason string",Logger.errors.CALL_EXCEPTION,{data:"0x",transaction:ie,error:t})}if(n==="estimateGas"){let ae=spelunk(t.body,!1);ae==null&&(ae=spelunk(t,!1)),ae&&logger$3.throwError("cannot estimate gas; transaction may fail or may require manual gas limit",Logger.errors.UNPREDICTABLE_GAS_LIMIT,{reason:ae.message,method:n,transaction:ie,error:t})}let se=t.message;throw t.code===Logger.errors.SERVER_ERROR&&t.error&&typeof t.error.message=="string"?se=t.error.message:typeof t.body=="string"?se=t.body:typeof t.responseText=="string"&&(se=t.responseText),se=(se||"").toLowerCase(),se.match(/insufficient funds|base fee exceeds gas limit|InsufficientFunds/i)&&logger$3.throwError("insufficient funds for intrinsic transaction cost",Logger.errors.INSUFFICIENT_FUNDS,{error:t,method:n,transaction:ie}),se.match(/nonce (is )?too low/i)&&logger$3.throwError("nonce has already been used",Logger.errors.NONCE_EXPIRED,{error:t,method:n,transaction:ie}),se.match(/replacement transaction underpriced|transaction gas price.*too low/i)&&logger$3.throwError("replacement fee too low",Logger.errors.REPLACEMENT_UNDERPRICED,{error:t,method:n,transaction:ie}),se.match(/only replay-protected/i)&&logger$3.throwError("legacy pre-eip-155 transactions not supported",Logger.errors.UNSUPPORTED_OPERATION,{error:t,method:n,transaction:ie}),errorGas.indexOf(n)>=0&&se.match(/gas required exceeds allowance|always failing transaction|execution reverted|revert/)&&logger$3.throwError("cannot estimate gas; transaction may fail or may require manual gas limit",Logger.errors.UNPREDICTABLE_GAS_LIMIT,{error:t,method:n,transaction:ie}),t}function timer(n){return new Promise(function(t){setTimeout(t,n)})}function getResult(n){if(n.error){const t=new Error(n.error.message);throw t.code=n.error.code,t.data=n.error.data,t}return n.result}function getLowerCase(n){return n&&n.toLowerCase()}const _constructorGuard={};class JsonRpcSigner extends Signer{constructor(t,c,ie){if(super(),t!==_constructorGuard)throw new Error("do not call the JsonRpcSigner constructor directly; use provider.getSigner");defineReadOnly(this,"provider",c),ie==null&&(ie=0),typeof ie=="string"?(defineReadOnly(this,"_address",this.provider.formatter.address(ie)),defineReadOnly(this,"_index",null)):typeof ie=="number"?(defineReadOnly(this,"_index",ie),defineReadOnly(this,"_address",null)):logger$3.throwArgumentError("invalid address or index","addressOrIndex",ie)}connect(t){return logger$3.throwError("cannot alter JSON-RPC Signer connection",Logger.errors.UNSUPPORTED_OPERATION,{operation:"connect"})}connectUnchecked(){return new UncheckedJsonRpcSigner(_constructorGuard,this.provider,this._address||this._index)}getAddress(){return this._address?Promise.resolve(this._address):this.provider.send("eth_accounts",[]).then(t=>(t.length<=this._index&&logger$3.throwError("unknown account #"+this._index,Logger.errors.UNSUPPORTED_OPERATION,{operation:"getAddress"}),this.provider.formatter.address(t[this._index])))}sendUncheckedTransaction(t){t=shallowCopy(t);const c=this.getAddress().then(ie=>(ie&&(ie=ie.toLowerCase()),ie));if(t.gasLimit==null){const ie=shallowCopy(t);ie.from=c,t.gasLimit=this.provider.estimateGas(ie)}return t.to!=null&&(t.to=Promise.resolve(t.to).then(ie=>__awaiter$b(this,void 0,void 0,function*(){if(ie==null)return null;const se=yield this.provider.resolveName(ie);return se==null&&logger$3.throwArgumentError("provided ENS name resolves to null","tx.to",ie),se}))),resolveProperties({tx:resolveProperties(t),sender:c}).then(({tx:ie,sender:se})=>{ie.from!=null?ie.from.toLowerCase()!==se&&logger$3.throwArgumentError("from address mismatch","transaction",t):ie.from=se;const ae=this.provider.constructor.hexlifyTransaction(ie,{from:!0});return this.provider.send("eth_sendTransaction",[ae]).then(ue=>ue,ue=>(typeof ue.message=="string"&&ue.message.match(/user denied/i)&&logger$3.throwError("user rejected transaction",Logger.errors.ACTION_REJECTED,{action:"sendTransaction",transaction:ie}),checkError("sendTransaction",ue,ae)))})}signTransaction(t){return logger$3.throwError("signing transactions is unsupported",Logger.errors.UNSUPPORTED_OPERATION,{operation:"signTransaction"})}sendTransaction(t){return __awaiter$b(this,void 0,void 0,function*(){const c=yield this.provider._getInternalBlockNumber(100+2*this.provider.pollingInterval),ie=yield this.sendUncheckedTransaction(t);try{return yield poll(()=>__awaiter$b(this,void 0,void 0,function*(){const se=yield this.provider.getTransaction(ie);if(se!==null)return this.provider._wrapTransaction(se,ie,c)}),{oncePoll:this.provider})}catch(se){throw se.transactionHash=ie,se}})}signMessage(t){return __awaiter$b(this,void 0,void 0,function*(){const c=typeof t=="string"?toUtf8Bytes(t):t,ie=yield this.getAddress();try{return yield this.provider.send("personal_sign",[hexlify(c),ie.toLowerCase()])}catch(se){throw typeof se.message=="string"&&se.message.match(/user denied/i)&&logger$3.throwError("user rejected signing",Logger.errors.ACTION_REJECTED,{action:"signMessage",from:ie,messageData:t}),se}})}_legacySignMessage(t){return __awaiter$b(this,void 0,void 0,function*(){const c=typeof t=="string"?toUtf8Bytes(t):t,ie=yield this.getAddress();try{return yield this.provider.send("eth_sign",[ie.toLowerCase(),hexlify(c)])}catch(se){throw typeof se.message=="string"&&se.message.match(/user denied/i)&&logger$3.throwError("user rejected signing",Logger.errors.ACTION_REJECTED,{action:"_legacySignMessage",from:ie,messageData:t}),se}})}_signTypedData(t,c,ie){return __awaiter$b(this,void 0,void 0,function*(){const se=yield TypedDataEncoder.resolveNames(t,c,ie,ue=>this.provider.resolveName(ue)),ae=yield this.getAddress();try{return yield this.provider.send("eth_signTypedData_v4",[ae.toLowerCase(),JSON.stringify(TypedDataEncoder.getPayload(se.domain,c,se.value))])}catch(ue){throw typeof ue.message=="string"&&ue.message.match(/user denied/i)&&logger$3.throwError("user rejected signing",Logger.errors.ACTION_REJECTED,{action:"_signTypedData",from:ae,messageData:{domain:se.domain,types:c,value:se.value}}),ue}})}unlock(t){return __awaiter$b(this,void 0,void 0,function*(){const c=this.provider,ie=yield this.getAddress();return c.send("personal_unlockAccount",[ie.toLowerCase(),t,null])})}}class UncheckedJsonRpcSigner extends JsonRpcSigner{sendTransaction(t){return this.sendUncheckedTransaction(t).then(c=>({hash:c,nonce:null,gasLimit:null,gasPrice:null,data:null,value:null,chainId:null,confirmations:0,from:null,wait:ie=>this.provider.waitForTransaction(c,ie)}))}}const allowedTransactionKeys={chainId:!0,data:!0,gasLimit:!0,gasPrice:!0,nonce:!0,to:!0,value:!0,type:!0,accessList:!0,maxFeePerGas:!0,maxPriorityFeePerGas:!0};class JsonRpcProvider extends BaseProvider{constructor(t,c){let ie=c;ie==null&&(ie=new Promise((se,ae)=>{setTimeout(()=>{this.detectNetwork().then(ue=>{se(ue)},ue=>{ae(ue)})},0)})),super(ie),t||(t=getStatic(this.constructor,"defaultUrl")()),typeof t=="string"?defineReadOnly(this,"connection",Object.freeze({url:t})):defineReadOnly(this,"connection",Object.freeze(shallowCopy(t))),this._nextId=42}get _cache(){return this._eventLoopCache==null&&(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 __awaiter$b(this,void 0,void 0,function*(){yield timer(0);let t=null;try{t=yield this.send("eth_chainId",[])}catch{try{t=yield this.send("net_version",[])}catch{}}if(t!=null){const c=getStatic(this.constructor,"getNetwork");try{return c(BigNumber.from(t).toNumber())}catch(ie){return logger$3.throwError("could not detect network",Logger.errors.NETWORK_ERROR,{chainId:t,event:"invalidNetwork",serverError:ie})}}return logger$3.throwError("could not detect network",Logger.errors.NETWORK_ERROR,{event:"noNetwork"})})}getSigner(t){return new JsonRpcSigner(_constructorGuard,this,t)}getUncheckedSigner(t){return this.getSigner(t).connectUnchecked()}listAccounts(){return this.send("eth_accounts",[]).then(t=>t.map(c=>this.formatter.address(c)))}send(t,c){const ie={method:t,params:c,id:this._nextId++,jsonrpc:"2.0"};this.emit("debug",{action:"request",request:deepCopy(ie),provider:this});const se=["eth_chainId","eth_blockNumber"].indexOf(t)>=0;if(se&&this._cache[t])return this._cache[t];const ae=fetchJson(this.connection,JSON.stringify(ie),getResult).then(ue=>(this.emit("debug",{action:"response",request:ie,response:ue,provider:this}),ue),ue=>{throw this.emit("debug",{action:"response",error:ue,request:ie,provider:this}),ue});return se&&(this._cache[t]=ae,setTimeout(()=>{this._cache[t]=null},0)),ae}prepareRequest(t,c){switch(t){case"getBlockNumber":return["eth_blockNumber",[]];case"getGasPrice":return["eth_gasPrice",[]];case"getBalance":return["eth_getBalance",[getLowerCase(c.address),c.blockTag]];case"getTransactionCount":return["eth_getTransactionCount",[getLowerCase(c.address),c.blockTag]];case"getCode":return["eth_getCode",[getLowerCase(c.address),c.blockTag]];case"getStorageAt":return["eth_getStorageAt",[getLowerCase(c.address),hexZeroPad(c.position,32),c.blockTag]];case"sendTransaction":return["eth_sendRawTransaction",[c.signedTransaction]];case"getBlock":return c.blockTag?["eth_getBlockByNumber",[c.blockTag,!!c.includeTransactions]]:c.blockHash?["eth_getBlockByHash",[c.blockHash,!!c.includeTransactions]]:null;case"getTransaction":return["eth_getTransactionByHash",[c.transactionHash]];case"getTransactionReceipt":return["eth_getTransactionReceipt",[c.transactionHash]];case"call":return["eth_call",[getStatic(this.constructor,"hexlifyTransaction")(c.transaction,{from:!0}),c.blockTag]];case"estimateGas":return["eth_estimateGas",[getStatic(this.constructor,"hexlifyTransaction")(c.transaction,{from:!0})]];case"getLogs":return c.filter&&c.filter.address!=null&&(c.filter.address=getLowerCase(c.filter.address)),["eth_getLogs",[c.filter]]}return null}perform(t,c){return __awaiter$b(this,void 0,void 0,function*(){if(t==="call"||t==="estimateGas"){const se=c.transaction;if(se&&se.type!=null&&BigNumber.from(se.type).isZero()&&se.maxFeePerGas==null&&se.maxPriorityFeePerGas==null){const ae=yield this.getFeeData();ae.maxFeePerGas==null&&ae.maxPriorityFeePerGas==null&&(c=shallowCopy(c),c.transaction=shallowCopy(se),delete c.transaction.type)}}const ie=this.prepareRequest(t,c);ie==null&&logger$3.throwError(t+" not implemented",Logger.errors.NOT_IMPLEMENTED,{operation:t});try{return yield this.send(ie[0],ie[1])}catch(se){return checkError(t,se,c)}})}_startEvent(t){t.tag==="pending"&&this._startPending(),super._startEvent(t)}_startPending(){if(this._pendingFilter!=null)return;const t=this,c=this.send("eth_newPendingTransactionFilter",[]);this._pendingFilter=c,c.then(function(ie){function se(){t.send("eth_getFilterChanges",[ie]).then(function(ae){if(t._pendingFilter!=c)return null;let ue=Promise.resolve();return ae.forEach(function(de){t._emitted["t:"+de.toLowerCase()]="pending",ue=ue.then(function(){return t.getTransaction(de).then(function(ve){return t.emit("pending",ve),null})})}),ue.then(function(){return timer(1e3)})}).then(function(){if(t._pendingFilter!=c){t.send("eth_uninstallFilter",[ie]);return}return setTimeout(function(){se()},0),null}).catch(ae=>{})}return se(),ie}).catch(ie=>{})}_stopEvent(t){t.tag==="pending"&&this.listenerCount("pending")===0&&(this._pendingFilter=null),super._stopEvent(t)}static hexlifyTransaction(t,c){const ie=shallowCopy(allowedTransactionKeys);if(c)for(const ae in c)c[ae]&&(ie[ae]=!0);checkProperties(t,ie);const se={};return["chainId","gasLimit","gasPrice","type","maxFeePerGas","maxPriorityFeePerGas","nonce","value"].forEach(function(ae){if(t[ae]==null)return;const ue=hexValue(BigNumber.from(t[ae]));ae==="gasLimit"&&(ae="gas"),se[ae]=ue}),["from","to","data"].forEach(function(ae){t[ae]!=null&&(se[ae]=hexlify(t[ae]))}),t.accessList&&(se.accessList=accessListify(t.accessList)),se}}const logger$2=new Logger(version$8);let _nextId=1;function buildWeb3LegacyFetcher(n,t){const c="Web3LegacyFetcher";return function(ie,se){const ae={method:ie,params:se,id:_nextId++,jsonrpc:"2.0"};return new Promise((ue,de)=>{this.emit("debug",{action:"request",fetcher:c,request:deepCopy(ae),provider:this}),t(ae,(ve,ge)=>{if(ve)return this.emit("debug",{action:"response",fetcher:c,error:ve,request:ae,provider:this}),de(ve);if(this.emit("debug",{action:"response",fetcher:c,request:ae,response:ge,provider:this}),ge.error){const we=new Error(ge.error.message);return we.code=ge.error.code,we.data=ge.error.data,de(we)}ue(ge.result)})})}}function buildEip1193Fetcher(n){return function(t,c){c==null&&(c=[]);const ie={method:t,params:c};return this.emit("debug",{action:"request",fetcher:"Eip1193Fetcher",request:deepCopy(ie),provider:this}),n.request(ie).then(se=>(this.emit("debug",{action:"response",fetcher:"Eip1193Fetcher",request:ie,response:se,provider:this}),se),se=>{throw this.emit("debug",{action:"response",fetcher:"Eip1193Fetcher",request:ie,error:se,provider:this}),se})}}class Web3Provider extends JsonRpcProvider{constructor(t,c){t==null&&logger$2.throwArgumentError("missing provider","provider",t);let ie=null,se=null,ae=null;typeof t=="function"?(ie="unknown:",se=t):(ie=t.host||t.path||"",!ie&&t.isMetaMask&&(ie="metamask"),ae=t,t.request?(ie===""&&(ie="eip-1193:"),se=buildEip1193Fetcher(t)):t.sendAsync?se=buildWeb3LegacyFetcher(t,t.sendAsync.bind(t)):t.send?se=buildWeb3LegacyFetcher(t,t.send.bind(t)):logger$2.throwArgumentError("unsupported provider","provider",t),ie||(ie="unknown:")),super(ie,c),defineReadOnly(this,"jsonRpcFetchFunc",se),defineReadOnly(this,"provider",ae)}send(t,c){return this.jsonRpcFetchFunc(t,c)}}const version$7="solidity/5.8.0",regexBytes=new RegExp("^bytes([0-9]+)$"),regexNumber=new RegExp("^(u?int)([0-9]*)$"),regexArray=new RegExp("^(.*)\\[([0-9]*)\\]$"),Zeros="0000000000000000000000000000000000000000000000000000000000000000",logger$1$1=new Logger(version$7);function _pack(n,t,c){switch(n){case"address":return c?zeroPad(t,32):arrayify(t);case"string":return toUtf8Bytes(t);case"bytes":return arrayify(t);case"bool":return t=t?"0x01":"0x00",c?zeroPad(t,32):arrayify(t)}let ie=n.match(regexNumber);if(ie){let se=parseInt(ie[2]||"256");return(ie[2]&&String(se)!==ie[2]||se%8!==0||se===0||se>256)&&logger$1$1.throwArgumentError("invalid number type","type",n),c&&(se=256),t=BigNumber.from(t).toTwos(se),zeroPad(t,se/8)}if(ie=n.match(regexBytes),ie){const se=parseInt(ie[1]);return(String(se)!==ie[1]||se===0||se>32)&&logger$1$1.throwArgumentError("invalid bytes type","type",n),arrayify(t).byteLength!==se&&logger$1$1.throwArgumentError(`invalid value for ${n}`,"value",t),c?arrayify((t+Zeros).substring(0,66)):t}if(ie=n.match(regexArray),ie&&Array.isArray(t)){const se=ie[1];parseInt(ie[2]||String(t.length))!=t.length&&logger$1$1.throwArgumentError(`invalid array length for ${n}`,"value",t);const ae=[];return t.forEach(function(ue){ae.push(_pack(se,ue,!0))}),concat$1(ae)}return logger$1$1.throwArgumentError("invalid type","type",n)}function pack(n,t){n.length!=t.length&&logger$1$1.throwArgumentError("wrong number of values; expected ${ types.length }","values",t);const c=[];return n.forEach(function(ie,se){c.push(_pack(ie,t[se]))}),hexlify(concat$1(c))}function keccak256(n,t){return keccak256$1(pack(n,t))}function sha256$6(n,t){return sha256$7(pack(n,t))}const lib_esm$1=Object.freeze(Object.defineProperty({__proto__:null,keccak256,pack,sha256:sha256$6},Symbol.toStringTag,{value:"Module"})),version$6="units/5.8.0",logger$y=new Logger(version$6),names$2=["wei","kwei","mwei","gwei","szabo","finney","ether"];function commify(n){const t=String(n).split(".");(t.length>2||!t[0].match(/^-?[0-9]*$/)||t[1]&&!t[1].match(/^[0-9]*$/)||n==="."||n==="-.")&&logger$y.throwArgumentError("invalid value","value",n);let c=t[0],ie="";for(c.substring(0,1)==="-"&&(ie="-",c=c.substring(1));c.substring(0,1)==="0";)c=c.substring(1);c===""&&(c="0");let se="";for(t.length===2&&(se="."+(t[1]||"0"));se.length>2&&se[se.length-1]==="0";)se=se.substring(0,se.length-1);const ae=[];for(;c.length;)if(c.length<=3){ae.unshift(c);break}else{const ue=c.length-3;ae.unshift(c.substring(ue)),c=c.substring(0,ue)}return ie+ae.join(",")+se}function formatUnits(n,t){if(typeof t=="string"){const c=names$2.indexOf(t);c!==-1&&(t=3*c)}return formatFixed(n,t??18)}function parseUnits(n,t){if(typeof n!="string"&&logger$y.throwArgumentError("value must be a string","value",n),typeof t=="string"){const c=names$2.indexOf(t);c!==-1&&(t=3*c)}return parseFixed(n,t??18)}function formatEther(n){return formatUnits(n,18)}function parseEther(n){return parseUnits(n,18)}const lib_esm=Object.freeze(Object.defineProperty({__proto__:null,commify,formatEther,formatUnits,parseEther,parseUnits},Symbol.toStringTag,{value:"Module"}));var NFTType=(n=>(n[n.ERC1155=0]="ERC1155",n[n.ERC721=1]="ERC721",n))(NFTType||{}),ProductType=(n=>(n[n.DIGITAL=0]="DIGITAL",n[n.POD=1]="POD",n[n.PHYSICAL=2]="PHYSICAL",n))(ProductType||{});class HTTPError extends Error{constructor(t,c,ie){const se=t.status||t.status===0?t.status:"",ae=t.statusText??"",ue=`${se} ${ae}`.trim(),de=ue?`status code ${ue}`:"an unknown error";super(`Request failed with ${de}: ${c.method} ${c.url}`),Xn(this,"response"),Xn(this,"request"),Xn(this,"options"),this.name="HTTPError",this.response=t,this.request=c,this.options=ie}}class TimeoutError extends Error{constructor(t){super(`Request timed out: ${t.method} ${t.url}`),Xn(this,"request"),this.name="TimeoutError",this.request=t}}const supportsRequestStreams=(()=>{let n=!1,t=!1;const c=typeof globalThis.ReadableStream=="function",ie=typeof globalThis.Request=="function";if(c&&ie)try{t=new globalThis.Request("https://empty.invalid",{body:new globalThis.ReadableStream,method:"POST",get duplex(){return n=!0,"half"}}).headers.has("Content-Type")}catch(se){if(se instanceof Error&&se.message==="unsupported BodyInit type")return!1;throw se}return n&&!t})(),supportsAbortController=typeof globalThis.AbortController=="function",supportsAbortSignal=typeof globalThis.AbortSignal=="function"&&typeof globalThis.AbortSignal.any=="function",supportsResponseStreams=typeof globalThis.ReadableStream=="function",supportsFormData=typeof globalThis.FormData=="function",requestMethods=["get","post","put","patch","head","delete"],responseTypes={json:"application/json",text:"text/*",formData:"multipart/form-data",arrayBuffer:"*/*",blob:"*/*",bytes:"*/*"},maxSafeTimeout=2147483647,usualFormBoundarySize=new TextEncoder().encode("------WebKitFormBoundaryaxpyiPgbbPti10Rw").length,stop$1=Symbol("stop"),kyOptionKeys={json:!0,parseJson:!0,stringifyJson:!0,searchParams:!0,prefixUrl:!0,retry:!0,timeout:!0,hooks:!0,throwHttpErrors:!0,onDownloadProgress:!0,onUploadProgress:!0,fetch:!0},requestOptionsRegistry={method:!0,headers:!0,body:!0,mode:!0,credentials:!0,cache:!0,redirect:!0,referrer:!0,referrerPolicy:!0,integrity:!0,keepalive:!0,signal:!0,window:!0,dispatcher:!0,duplex:!0,priority:!0},getBodySize=n=>{if(!n)return 0;if(n instanceof FormData){let t=0;for(const[c,ie]of n)t+=usualFormBoundarySize,t+=new TextEncoder().encode(`Content-Disposition: form-data; name="${c}"`).length,t+=typeof ie=="string"?new TextEncoder().encode(ie).length:ie.size;return t}if(n instanceof Blob)return n.size;if(n instanceof ArrayBuffer)return n.byteLength;if(typeof n=="string")return new TextEncoder().encode(n).length;if(n instanceof URLSearchParams)return new TextEncoder().encode(n.toString()).length;if("byteLength"in n)return n.byteLength;if(typeof n=="object"&&n!==null)try{const t=JSON.stringify(n);return new TextEncoder().encode(t).length}catch{return 0}return 0},withProgress=(n,t,c)=>{let ie,se=0;return n.pipeThrough(new TransformStream({transform(ae,ue){if(ue.enqueue(ae),ie){se+=ie.byteLength;let de=t===0?0:se/t;de>=1&&(de=1-Number.EPSILON),c?.({percent:de,totalBytes:Math.max(t,se),transferredBytes:se},ie)}ie=ae},flush(){ie&&(se+=ie.byteLength,c?.({percent:1,totalBytes:Math.max(t,se),transferredBytes:se},ie))}}))},streamResponse=(n,t)=>{if(!n.body)return n;if(n.status===204)return new Response(null,{status:n.status,statusText:n.statusText,headers:n.headers});const c=Number(n.headers.get("content-length"))||0;return new Response(withProgress(n.body,c,t),{status:n.status,statusText:n.statusText,headers:n.headers})},streamRequest=(n,t,c)=>{if(!n.body)return n;const ie=getBodySize(c??n.body);return new Request(n,{duplex:"half",body:withProgress(n.body,ie,t)})},isObject$2$1=n=>n!==null&&typeof n=="object",validateAndMerge=(...n)=>{for(const t of n)if((!isObject$2$1(t)||Array.isArray(t))&&t!==void 0)throw new TypeError("The `options` argument must be an object");return deepMerge({},...n)},mergeHeaders=(n={},t={})=>{const c=new globalThis.Headers(n),ie=t instanceof globalThis.Headers,se=new globalThis.Headers(t);for(const[ae,ue]of se.entries())ie&&ue==="undefined"||ue===void 0?c.delete(ae):c.set(ae,ue);return c};function newHookValue(n,t,c){return Object.hasOwn(t,c)&&t[c]===void 0?[]:deepMerge(n[c]??[],t[c]??[])}const mergeHooks=(n={},t={})=>({beforeRequest:newHookValue(n,t,"beforeRequest"),beforeRetry:newHookValue(n,t,"beforeRetry"),afterResponse:newHookValue(n,t,"afterResponse"),beforeError:newHookValue(n,t,"beforeError")}),deepMerge=(...n)=>{let t={},c={},ie={};for(const se of n)if(Array.isArray(se))Array.isArray(t)||(t=[]),t=[...t,...se];else if(isObject$2$1(se)){for(let[ae,ue]of Object.entries(se))isObject$2$1(ue)&&ae in t&&(ue=deepMerge(t[ae],ue)),t={...t,[ae]:ue};isObject$2$1(se.hooks)&&(ie=mergeHooks(ie,se.hooks),t.hooks=ie),isObject$2$1(se.headers)&&(c=mergeHeaders(c,se.headers),t.headers=c)}return t},normalizeRequestMethod=n=>requestMethods.includes(n)?n.toUpperCase():n,retryMethods=["get","put","head","delete","options","trace"],retryStatusCodes=[408,413,429,500,502,503,504],retryAfterStatusCodes=[413,429,503],defaultRetryOptions={limit:2,methods:retryMethods,statusCodes:retryStatusCodes,afterStatusCodes:retryAfterStatusCodes,maxRetryAfter:Number.POSITIVE_INFINITY,backoffLimit:Number.POSITIVE_INFINITY,delay:n=>.3*2**(n-1)*1e3},normalizeRetryOptions=(n={})=>{if(typeof n=="number")return{...defaultRetryOptions,limit:n};if(n.methods&&!Array.isArray(n.methods))throw new Error("retry.methods must be an array");if(n.statusCodes&&!Array.isArray(n.statusCodes))throw new Error("retry.statusCodes must be an array");return{...defaultRetryOptions,...n}};async function timeout(n,t,c,ie){return new Promise((se,ae)=>{const ue=setTimeout(()=>{c&&c.abort(),ae(new TimeoutError(n))},ie.timeout);ie.fetch(n,t).then(se).catch(ae).then(()=>{clearTimeout(ue)})})}async function delay$1(n,{signal:t}){return new Promise((c,ie)=>{t&&(t.throwIfAborted(),t.addEventListener("abort",se,{once:!0}));function se(){clearTimeout(ae),ie(t.reason)}const ae=setTimeout(()=>{t?.removeEventListener("abort",se),c()},n)})}const findUnknownOptions=(n,t)=>{const c={};for(const ie in t)!(ie in requestOptionsRegistry)&&!(ie in kyOptionKeys)&&!(ie in n)&&(c[ie]=t[ie]);return c},hasSearchParameters=n=>n===void 0?!1:Array.isArray(n)?n.length>0:n instanceof URLSearchParams?n.size>0:typeof n=="object"?Object.keys(n).length>0:typeof n=="string"?n.trim().length>0:!!n;var ei,oi;const Yn=class oo{constructor(t,c={}){Xn(this,"request"),Xn(this,"abortController"),Xn(this,"_retryCount",0),Xn(this,"_input"),Xn(this,"_options"),Xn(this,"_originalRequest");var ie,se,ae;if(this._input=t,this._options={...c,headers:mergeHeaders(this._input.headers,c.headers),hooks:mergeHooks({beforeRequest:[],beforeRetry:[],beforeError:[],afterResponse:[]},c.hooks),method:normalizeRequestMethod(c.method??this._input.method??"GET"),prefixUrl:String(c.prefixUrl||""),retry:normalizeRetryOptions(c.retry),throwHttpErrors:c.throwHttpErrors!==!1,timeout:c.timeout??1e4,fetch:c.fetch??globalThis.fetch.bind(globalThis)},typeof this._input!="string"&&!(this._input instanceof URL||this._input instanceof globalThis.Request))throw new TypeError("`input` must be a string, URL, or Request");if(this._options.prefixUrl&&typeof this._input=="string"){if(this._input.startsWith("/"))throw new Error("`input` must not begin with a slash when using `prefixUrl`");this._options.prefixUrl.endsWith("/")||(this._options.prefixUrl+="/"),this._input=this._options.prefixUrl+this._input}if(supportsAbortController&&supportsAbortSignal){const ue=this._options.signal??this._input.signal;this.abortController=new globalThis.AbortController,this._options.signal=ue?AbortSignal.any([ue,this.abortController.signal]):this.abortController.signal}if(supportsRequestStreams&&(this._options.duplex="half"),this._options.json!==void 0&&(this._options.body=((se=(ie=this._options).stringifyJson)==null?void 0:se.call(ie,this._options.json))??JSON.stringify(this._options.json),this._options.headers.set("content-type",this._options.headers.get("content-type")??"application/json")),this.request=new globalThis.Request(this._input,this._options),hasSearchParameters(this._options.searchParams)){const ue="?"+(typeof this._options.searchParams=="string"?this._options.searchParams.replace(/^\?/,""):new URLSearchParams(ai(ae=oo,ei,oi).call(ae,this._options.searchParams)).toString()),de=this.request.url.replace(/(?:\?.*?)?(?=#|$)/,ue);(supportsFormData&&this._options.body instanceof globalThis.FormData||this._options.body instanceof URLSearchParams)&&!(this._options.headers&&this._options.headers["content-type"])&&this.request.headers.delete("content-type"),this.request=new globalThis.Request(new globalThis.Request(de,{...this.request}),this._options)}if(this._options.onUploadProgress){if(typeof this._options.onUploadProgress!="function")throw new TypeError("The `onUploadProgress` option must be a function");if(!supportsRequestStreams)throw new Error("Request streams are not supported in your environment. The `duplex` option for `Request` is not available.");this.request.body&&(this.request=streamRequest(this.request,this._options.onUploadProgress,this._options.body))}}static create(t,c){var ie,se;const ae=new oo(t,c),ue=async()=>{if(typeof ae._options.timeout=="number"&&ae._options.timeout>maxSafeTimeout)throw new RangeError(`The \`timeout\` option cannot be greater than ${maxSafeTimeout}`);await Promise.resolve();let ve=await ae._fetch();for(const ge of ae._options.hooks.afterResponse){const we=await ge(ae.request,ae._options,ae._decorateResponse(ve.clone()));we instanceof globalThis.Response&&(ve=we)}if(ae._decorateResponse(ve),!ve.ok&&ae._options.throwHttpErrors){let ge=new HTTPError(ve,ae.request,ae._options);for(const we of ae._options.hooks.beforeError)ge=await we(ge);throw ge}if(ae._options.onDownloadProgress){if(typeof ae._options.onDownloadProgress!="function")throw new TypeError("The `onDownloadProgress` option must be a function");if(!supportsResponseStreams)throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");return streamResponse(ve.clone(),ae._options.onDownloadProgress)}return ve},de=(ae._options.retry.methods.includes(ae.request.method.toLowerCase())?ae._retry(ue):ue()).finally(async()=>{var ve,ge;const we=ae._originalRequest,Te=[];we&&!we.bodyUsed&&Te.push((ve=we.body)==null?void 0:ve.cancel()),ae.request.bodyUsed||Te.push((ge=ae.request.body)==null?void 0:ge.cancel()),await Promise.all(Te)});for(const[ve,ge]of Object.entries(responseTypes))ve==="bytes"&&typeof((se=(ie=globalThis.Response)==null?void 0:ie.prototype)==null?void 0:se.bytes)!="function"||(de[ve]=async()=>{ae.request.headers.set("accept",ae.request.headers.get("accept")||ge);const we=await de;if(ve==="json"){if(we.status===204)return"";const Te=await we.text();return Te===""?"":c.parseJson?c.parseJson(Te):JSON.parse(Te)}return we[ve]()});return de}_calculateRetryDelay(t){if(this._retryCount++,this._retryCount>this._options.retry.limit||t instanceof TimeoutError)throw t;if(t instanceof HTTPError){if(!this._options.retry.statusCodes.includes(t.response.status))throw t;const ie=t.response.headers.get("Retry-After")??t.response.headers.get("RateLimit-Reset")??t.response.headers.get("X-RateLimit-Reset")??t.response.headers.get("X-Rate-Limit-Reset");if(ie&&this._options.retry.afterStatusCodes.includes(t.response.status)){let se=Number(ie)*1e3;Number.isNaN(se)?se=Date.parse(ie)-Date.now():se>=Date.parse("2024-01-01")&&(se-=Date.now());const ae=this._options.retry.maxRetryAfter??se;return se<ae?se:ae}if(t.response.status===413)throw t}const c=this._options.retry.delay(this._retryCount);return Math.min(this._options.retry.backoffLimit,c)}_decorateResponse(t){return this._options.parseJson&&(t.json=async()=>this._options.parseJson(await t.text())),t}async _retry(t){try{return await t()}catch(c){const ie=Math.min(this._calculateRetryDelay(c),maxSafeTimeout);if(this._retryCount<1)throw c;await delay$1(ie,{signal:this._options.signal});for(const se of this._options.hooks.beforeRetry)if(await se({request:this.request,options:this._options,error:c,retryCount:this._retryCount})===stop$1)return;return this._retry(t)}}async _fetch(){for(const c of this._options.hooks.beforeRequest){const ie=await c(this.request,this._options);if(ie instanceof Request){this.request=ie;break}if(ie instanceof Response)return ie}const t=findUnknownOptions(this.request,this._options);return this._originalRequest=this.request,this.request=this._originalRequest.clone(),this._options.timeout===!1?this._options.fetch(this._originalRequest,t):timeout(this._originalRequest,t,this.abortController,this._options)}};ei=new WeakSet,oi=function(n){return n&&typeof n=="object"&&!Array.isArray(n)&&!(n instanceof URLSearchParams)?Object.fromEntries(Object.entries(n).filter(([,t])=>t!==void 0)):n},ii(Yn,ei);let Ky=Yn;const createInstance$1=n=>{const t=(c,ie)=>Ky.create(c,validateAndMerge(n,ie));for(const c of requestMethods)t[c]=(ie,se)=>Ky.create(ie,validateAndMerge(n,se,{method:c}));return t.create=c=>createInstance$1(validateAndMerge(c)),t.extend=c=>(typeof c=="function"&&(c=c(n??{})),createInstance$1(validateAndMerge(n,c))),t.stop=stop$1,t},ky=createInstance$1();async function uploadMetadata(n,t,c){return(await(await c.post("uploader/cdn-upload-json",{json:{data:n,key:`record-metadata/${t}.json`}})).json()).url}async function startRecord(n,t,c,ie,se,ae){return(await(await ae.post("web3/record/transactions",{json:{uris:se,network:ie,data:{productId:n,skuIds:t},productId:n,skuIds:t,metadata:{},shopId:c,txType:"RECORD"}})).json()).data.id}async function getShopInfo(n,t,c){const ie=(await(await c.get(`shops/v2/public/${t}`)).json()).data.deployedContracts.filter(se=>se.type===n);return ie.length===0?{nftContractAddress:"",shopContractAddress:""}:{nftContractAddress:ie[0].deployedNFTAddress,shopContractAddress:ie[0].deployedShopAddress}}async function deleteRecordTransaction(n,t){await t.delete(`web3/record/transactions/${n}`)}async function web3Callback(n,t,c,ie){const se={"X-API-KEY":"ho8homr9e8p4fwii7tjiz41xs4hlbl2h4i"};return(await(await ky.create({headers:se,prefixUrl:c==="TESTNET"?"https://web3dev.droplinked.com/":"https://web3.droplinked.com/"}).post("transactions",{json:{transaction_id:n,callback_url:ie,chain:t,network:c},headers:se})).json()).data}async function getProductData(n,t){return(await(await t.get(`product-v2/public/${n}`)).json()).data}async function transformProductData(n,t){const c=await getProductData(n,t);if(!c||c.skus.length===0)throw new Error("Product not found or no SKUs available");return{productData:{acceptsManageWallet:!0,commission:c.affiliate.commissionPercent||0,description:c.description,productTitle:c.title,royalty:c.skus[0].royalty||0,type:ProductType[c.type.toUpperCase()]||ProductType.DIGITAL},skuData:c.skus.map(ie=>{var se;return{amount:ie.inventory.quantity,imageUrl:((se=c.images[c.defaultImageIndex])==null?void 0:se.original)||"",skuID:ie.id,skuProperties:ie}})}}async function updateUris(n,t,c){return(await(await c.put(`web3/record/transactions/${n}/uris`,{json:{uris:t}})).json()).data}async function updateHash(n,t,c,ie){return(await(await ie.put(`web3/${n}/transactions/${t}/hash`,{json:{transactionHash:c}})).json()).data}async function getProductDataForRecord(n,t){if(!n)throw new InvalidParametersException(Chains.BASE,"Product ID is required");let c,ie=[];try{const{productData:se,skuData:ae}=await transformProductData(n,t);c=se,ie=ae}catch(se){throw new Error(`Failed to fetch product data: ${se}`)}if(!c||ie.length===0)throw new Error("Product not found or no SKUs available");return{productData:c,skuData:ie}}async function getNonce(n,t){return await(await t.get(`web3/auth/nonce?wallet=${n}`)).json()}async function getAddress(n,t,c){const ie=se=>se.charAt(0).toUpperCase()+se.slice(1).toLowerCase();try{const se=t===Network.TESTNET?"apiv3dev":"apiv3",ae=ie(n),ue=ie(Network[t]),de=`https://${se}.droplinked.com/storage/${ae}${ue}ContractAddress${c}`;return(await await ky.get(de).json()).value}catch(se){throw console.error(`Failed to fetch ${c.toLowerCase()} address:`,se),new Error(`Unable to get ${c.toLowerCase()} address`)}}async function getDeployerAddress(n,t){return getAddress(n,t,"Deployer")}async function getProxyAddress(n,t){return getAddress(n,t,"Proxy")}async function startPayment(n,t,c,ie,se){return(await(await se.post("web3/payment/transactions",{json:{network:c,token:t,shopId:ie,orderId:n}})).json()).data.id}async function getCartData(n,t,c,ie){const se=await(await ie.get(`web3/payment/distribution/${n}/${t}/${c}`)).json();return{paymentData:se.data,orderID:se.orderID}}async function getPurchaseSignature(n,t,c){const ie=await(await c.get(`nfts/by-order?orderId=${n}&skuId=${t}`)).json();return{signature:ie.purchaseSignature,shopContractAddress:ie.shopContractAddress,networkName:ie.networkName}}async function getShopByteCode(){try{return String((await await ky.get("https://apiv3dev.droplinked.com/storage/shopByteCodeType0").json()).value)}catch(n){throw console.error(`Failed to get shop bytecode: ${n}`),new Error("Unable to get shop bytecode")}}async function getShopDeployInfo(n,t){const c=(await(await t.get(`shops/v2/public/${n}`)).json()).data;return{name:c.name,description:c.description,logo:c.logo,url:c.url,deployedContracts:c.deployedContracts}}const shopABI=[{inputs:[{internalType:"string",name:"_shopName",type:"string"},{internalType:"string",name:"_shopAddress",type:"string"},{internalType:"address",name:"_shopOwner",type:"address"},{internalType:"string",name:"_shopLogo",type:"string"},{internalType:"string",name:"_shopDescription",type:"string"}],stateMutability:"nonpayable",type:"constructor"},{inputs:[],name:"AccessDenied",type:"error"},{inputs:[],name:"AffiliatePOD",type:"error"},{inputs:[],name:"AlreadyClaimed",type:"error"},{inputs:[{internalType:"address",name:"requester",type:"address"},{internalType:"uint256",name:"productId",type:"uint256"}],name:"AlreadyRequested",type:"error"},{inputs:[{internalType:"uint256",name:"tokenId",type:"uint256"},{internalType:"address",name:"producer",type:"address"}],name:"NotEnoughTokens",type:"error"},{inputs:[{internalType:"address",name:"owner",type:"address"}],name:"OwnableInvalidOwner",type:"error"},{inputs:[{internalType:"address",name:"account",type:"address"}],name:"OwnableUnauthorizedAccount",type:"error"},{inputs:[{internalType:"uint256",name:"productId",type:"uint256"}],name:"ProductDoesntExist",type:"error"},{inputs:[{internalType:"uint256",name:"productId",type:"uint256"}],name:"ProductExists",type:"error"},{inputs:[],name:"ReentrancyGuardReentrantCall",type:"error"},{inputs:[{internalType:"uint256",name:"requestId",type:"uint256"}],name:"RequestAlreadyConfirmed",type:"error"},{inputs:[{internalType:"uint256",name:"requestId",type:"uint256"}],name:"RequestDoesntExist",type:"error"},{inputs:[{internalType:"uint256",name:"requestId",type:"uint256"}],name:"RequestNotConfirmed",type:"error"},{inputs:[{internalType:"uint256",name:"tokenId",type:"uint256"},{internalType:"address",name:"nftAddress",type:"address"}],name:"ShopDoesNotOwnToken",type:"error"},{inputs:[],name:"oldPrice",type:"error"},{anonymous:!1,inputs:[{indexed:!0,internalType:"uint256",name:"requestId",type:"uint256"},{indexed:!0,internalType:"address",name:"approver",type:"address"}],name:"AffiliateRequestApproved",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"uint256",name:"requestId",type:"uint256"},{indexed:!0,internalType:"address",name:"disapprover",type:"address"}],name:"AffiliateRequestDisapproved",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"uint256",name:"requestId",type:"uint256"},{indexed:!0,internalType:"uint256",name:"productId",type:"uint256"},{indexed:!1,internalType:"address",name:"requester",type:"address"}],name:"AffiliateRequested",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"uint256",name:"count",type:"uint256"}],name:"BatchProductRegistered",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"previousOwner",type:"address"},{indexed:!0,internalType:"address",name:"newOwner",type:"address"}],name:"OwnershipTransferred",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"uint256",name:"productId",type:"uint256"},{indexed:!0,internalType:"address",name:"claimer",type:"address"},{indexed:!1,internalType:"uint256",name:"amount",type:"uint256"}],name:"ProductClaimed",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"uint256",name:"productId",type:"uint256"},{indexed:!1,internalType:"uint256",name:"amount",type:"uint256"},{indexed:!0,internalType:"address",name:"owner",type:"address"},{indexed:!1,internalType:"string",name:"uri",type:"string"}],name:"ProductRegistered",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"uint256",name:"productId",type:"uint256"},{indexed:!0,internalType:"address",name:"owner",type:"address"}],name:"ProductUnregistered",type:"event"},{inputs:[],name:"affiliateRequestCount",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"requestId",type:"uint256"}],name:"affiliateRequests",outputs:[{internalType:"address",name:"publisher",type:"address"},{internalType:"uint256",name:"productId",type:"uint256"},{internalType:"bool",name:"isConfirmed",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"requestId",type:"uint256"}],name:"approveRequest",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"manager",type:"address"},{internalType:"bytes",name:"signature",type:"bytes"},{components:[{components:[{internalType:"uint256",name:"amount",type:"uint256"},{internalType:"uint256",name:"productId",type:"uint256"},{internalType:"uint256",name:"nullifier",type:"uint256"}],internalType:"struct PurchasedItem[]",name:"cart",type:"tuple[]"},{internalType:"address",name:"shop",type:"address"}],internalType:"struct PurchaseSignature",name:"purchaseSignature",type:"tuple"}],name:"claimPurchase",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"requestId",type:"uint256"}],name:"disapproveRequest",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"droplinkedManagerWallet",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"requestId",type:"uint256"}],name:"getAffiliate",outputs:[{components:[{internalType:"address",name:"publisher",type:"address"},{internalType:"uint256",name:"productId",type:"uint256"},{internalType:"bool",name:"isConfirmed",type:"bool"}],internalType:"struct AffiliateRequest",name:"",type:"tuple"}],stateMutability:"view",type:"function"},{inputs:[],name:"getAffiliateRequestCount",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bytes32",name:"messageHash",type:"bytes32"}],name:"getEthSignedMessageHash",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],stateMutability:"pure",type:"function"},{inputs:[{components:[{components:[{internalType:"uint256",name:"amount",type:"uint256"},{internalType:"uint256",name:"productId",type:"uint256"},{internalType:"uint256",name:"nullifier",type:"uint256"}],internalType:"struct PurchasedItem[]",name:"cart",type:"tuple[]"},{internalType:"address",name:"shop",type:"address"}],internalType:"struct PurchaseSignature",name:"data",type:"tuple"}],name:"getMessageHash",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],stateMutability:"pure",type:"function"},{inputs:[{internalType:"uint256",name:"productId",type:"uint256"}],name:"getProduct",outputs:[{components:[{internalType:"uint256",name:"tokenId",type:"uint256"},{internalType:"address",name:"nftAddress",type:"address"},{internalType:"enum NFTType",name:"nftType",type:"uint8"},{internalType:"enum ProductType",name:"productType",type:"uint8"},{internalType:"uint256",name:"affiliatePercentage",type:"uint256"}],internalType:"struct Product",name:"",type:"tuple"}],stateMutability:"view",type:"function"},{inputs:[],name:"getProductCount",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{components:[{internalType:"uint256",name:"tokenId",type:"uint256"},{internalType:"address",name:"nftAddress",type:"address"},{internalType:"enum NFTType",name:"nftType",type:"uint8"},{internalType:"enum ProductType",name:"productType",type:"uint8"},{internalType:"uint256",name:"affiliatePercentage",type:"uint256"}],internalType:"struct Product",name:"product",type:"tuple"}],name:"getProductId",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"pure",type:"function"},{inputs:[{internalType:"address",name:"nftAddress",type:"address"},{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"getProductIdV2",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"pure",type:"function"},{inputs:[{internalType:"uint256",name:"affiliateId",type:"uint256"}],name:"getProductViaAffiliateId",outputs:[{components:[{internalType:"uint256",name:"tokenId",type:"uint256"},{internalType:"address",name:"nftAddress",type:"address"},{internalType:"enum NFTType",name:"nftType",type:"uint8"},{internalType:"enum ProductType",name:"productType",type:"uint8"},{internalType:"uint256",name:"affiliatePercentage",type:"uint256"}],internalType:"struct Product",name:"",type:"tuple"}],stateMutability:"view",type:"function"},{inputs:[],name:"getShopAddress",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"},{inputs:[],name:"getShopDescription",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"},{inputs:[],name:"getShopLogo",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"},{inputs:[],name:"getShopName",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"},{inputs:[],name:"getShopOwner",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"productId",type:"uint256"},{internalType:"address",name:"requester",type:"address"}],name:"isRequestSubmited",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"",type:"address"}],name:"managers",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[{components:[{internalType:"address",name:"nftAddress",type:"address"},{internalType:"string",name:"uri",type:"string"},{internalType:"uint256",name:"amount",type:"uint256"},{internalType:"bool",name:"accepted",type:"bool"},{internalType:"uint256",name:"affiliatePercentage",type:"uint256"},{internalType:"uint256",name:"royalty",type:"uint256"},{internalType:"enum NFTType",name:"nftType",type:"uint8"},{internalType:"enum ProductType",name:"productType",type:"uint8"}],internalType:"struct RecordData",name:"mintData",type:"tuple"}],name:"mintAndRegister",outputs:[{internalType:"uint256",name:"productId",type:"uint256"}],stateMutability:"nonpayable",type:"function"},{inputs:[{components:[{internalType:"address",name:"nftAddress",type:"address"},{internalType:"string",name:"uri",type:"string"},{internalType:"uint256",name:"amount",type:"uint256"},{internalType:"bool",name:"accepted",type:"bool"},{internalType:"uint256",name:"affiliatePercentage",type:"uint256"},{internalType:"uint256",name:"royalty",type:"uint256"},{internalType:"enum NFTType",name:"nftType",type:"uint8"},{internalType:"enum ProductType",name:"productType",type:"uint8"}],internalType:"struct RecordData[]",name:"recordData",type:"tuple[]"}],name:"mintAndRegisterBatch",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"",type:"uint256"}],name:"nullifiers",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"",type:"address"},{internalType:"address",name:"",type:"address"},{internalType:"uint256[]",name:"",type:"uint256[]"},{internalType:"uint256[]",name:"",type:"uint256[]"},{internalType:"bytes",name:"",type:"bytes"}],name:"onERC1155BatchReceived",outputs:[{internalType:"bytes4",name:"",type:"bytes4"}],stateMutability:"pure",type:"function"},{inputs:[{internalType:"address",name:"",type:"address"},{internalType:"address",name:"",type:"address"},{internalType:"uint256",name:"",type:"uint256"},{internalType:"uint256",name:"",type:"uint256"},{internalType:"bytes",name:"",type:"bytes"}],name:"onERC1155Received",outputs:[{internalType:"bytes4",name:"",type:"bytes4"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"",type:"address"},{internalType:"address",name:"",type:"address"},{internalType:"uint256",name:"",type:"uint256"},{internalType:"bytes",name:"",type:"bytes"}],name:"onERC721Received",outputs:[{internalType:"bytes4",name:"",type:"bytes4"}],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"owner",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"productCount",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"productId",type:"uint256"}],name:"products",outputs:[{internalType:"uint256",name:"tokenId",type:"uint256"},{internalType:"address",name:"nftAddress",type:"address"},{internalType:"enum NFTType",name:"nftType",type:"uint8"},{internalType:"enum ProductType",name:"productType",type:"uint8"},{internalType:"uint256",name:"affiliatePercentage",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bytes32",name:"ethSignedMessageHash",type:"bytes32"},{internalType:"bytes",name:"signature",type:"bytes"}],name:"recoverSigner",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"pure",type:"function"},{inputs:[{components:[{internalType:"uint256",name:"tokenId",type:"uint256"},{internalType:"address",name:"nftAddress",type:"address"},{internalType:"enum NFTType",name:"nftType",type:"uint8"},{internalType:"enum ProductType",name:"productType",type:"uint8"},{internalType:"uint256",name:"affiliatePercentage",type:"uint256"}],internalType:"struct Product",name:"p",type:"tuple"}],name:"registerProduct",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"renounceOwnership",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"productId",type:"uint256"}],name:"requestAffiliate",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"manager",type:"address"}],name:"revokeManager",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"manager",type:"address"}],name:"setManager",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"shopInfo",outputs:[{internalType:"string",name:"shopName",type:"string"},{internalType:"string",name:"shopAddress",type:"string"},{internalType:"string",name:"shopLogo",type:"string"},{internalType:"string",name:"shopDescription",type:"string"},{internalType:"address",name:"shopOwner",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bytes",name:"sig",type:"bytes"}],name:"splitSignature",outputs:[{internalType:"bytes32",name:"r",type:"bytes32"},{internalType:"bytes32",name:"s",type:"bytes32"},{internalType:"uint8",name:"v",type:"uint8"}],stateMutability:"pure",type:"function"},{inputs:[{internalType:"bytes4",name:"interfaceId",type:"bytes4"}],name:"supportsInterface",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"newManager",type:"address"}],name:"transferManagerShip",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"newOwner",type:"address"}],name:"transferOwnership",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"productId",type:"uint256"}],name:"unregisterProduct",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"newManagerWallet",type:"address"}],name:"updateDroplinkedManagerWallet",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"signer",type:"address"},{internalType:"bytes",name:"signature",type:"bytes"},{components:[{components:[{internalType:"uint256",name:"amount",type:"uint256"},{internalType:"uint256",name:"productId",type:"uint256"},{internalType:"uint256",name:"nullifier",type:"uint256"}],internalType:"struct PurchasedItem[]",name:"cart",type:"tuple[]"},{internalType:"address",name:"shop",type:"address"}],internalType:"struct PurchaseSignature",name:"data",type:"tuple"}],name:"verifyPurchase",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"pure",type:"function"}];function getTransactionLink({blockchain:n,transactionHash:t,isTestnet:c=!1}){const ie=t.trim();switch(n.toUpperCase()){case"CASPER":return`https://${c?"testnet.":""}cspr.live/deploy/${ie}`;case"STACKS":return`https://explorer.hiro.so/txid/${ie}?chain=${c?"testnet":"mainnet"}`;case"POLYGON":return`https://${c?"amoy.":""}polygonscan.com/tx/${ie}`;case"XRPLSIDECHAIN":return`https://evm-sidechain.xrpl.org/tx/${ie}`;case"BINANCE":return`https://${c?"testnet.":""}bscscan.com/tx/${ie}`;case"NEAR":return`https://explorer.${c?"testnet":"mainnet"}.aurora.dev/tx/${ie}`;case"BASE":return`https://base${c?"-sepolia":""}.blockscout.com/tx/${ie}`;case"LINEA":return`https://${c?"sepolia.":""}lineascan.build/tx/${ie}`;case"ETH":return`https://${c?"sepolia.":""}etherscan.io/tx/${ie}`;case"SOLANA":return`https://explorer.solana.com/tx/${ie}?cluster=${c?"devnet":"mainnet"}`;case"REDBELLY":return c?`https://redbelly.testnet.routescan.io/tx/${ie}`:`https://redbelly.routescan.io/tx/${ie}`;case"SKALE":return`https://${c?"giant-half-dual-testnet.explorer.testnet.skalenodes.com":"honorable-steel-rasalhague.explorer.mainnet.skalenodes.com"}/tx/${ie}`;case"BITLAYER":return c?`https://testnet.btrscan.com/tx/${ie}`:`https://www.btrscan.com/tx/${ie}`;default:return""}}async function ensureWalletOnChainFromConfig(n,t,c){const ie=t[c];if(!ie)throw new Error(`Network config not found for ${t.name} (${c})`);const se=n.provider;if(!(se!=null&&se.request))throw new Error("Provider does not support network switching");const ae=await n.getNetwork(),ue=Number(ie.chainId);if(ae.chainId!==ue){try{await se.request({method:"wallet_switchEthereumChain",params:[{chainId:ie.chainId}]})}catch(de){if(de.code===4902)await se.request({method:"wallet_addEthereumChain",params:[{chainId:ie.chainId,chainName:ie.chainName,rpcUrls:ie.rpcUrls,nativeCurrency:ie.nativeCurrency}]});else throw de}if((await n.getNetwork()).chainId!==ue)throw new Error(`Failed to switch to ${t.name} (${c})`)}}function getBaseUrl(n){return n===Network.MAINNET?"https://apiv3.droplinked.com":n===Network.TESTNET?"https://apiv3dev.droplinked.com":"http://127.0.0.1:3000"}async function getGasPrice(n){return(await n.getGasPrice()).toBigInt()}const deployerABI=[{inputs:[],name:"InvalidInitialization",type:"error"},{inputs:[],name:"NotInitializing",type:"error"},{inputs:[{internalType:"address",name:"owner",type:"address"}],name:"OwnableInvalidOwner",type:"error"},{inputs:[{internalType:"address",name:"account",type:"address"}],name:"OwnableUnauthorizedAccount",type:"error"},{anonymous:!1,inputs:[{indexed:!1,internalType:"uint256",name:"newFee",type:"uint256"}],name:"DroplinkedFeeUpdated",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"uint256",name:"newHeartBeat",type:"uint256"}],name:"HeartBeatUpdated",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"uint64",name:"version",type:"uint64"}],name:"Initialized",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"previousOwner",type:"address"},{indexed:!0,internalType:"address",name:"newOwner",type:"address"}],name:"OwnershipTransferred",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"address",name:"shop",type:"address"},{indexed:!1,internalType:"address",name:"nftContract",type:"address"}],name:"ShopDeployed",type:"event"},{inputs:[{internalType:"bytes",name:"bytecode",type:"bytes"},{internalType:"bytes32",name:"salt",type:"bytes32"}],name:"deployShop",outputs:[{internalType:"address",name:"shop",type:"address"},{internalType:"address",name:"nftContract",type:"address"}],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"droplinkedFee",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"droplinkedWallet",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"getDroplinkedFee",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"getHeartBeat",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"heartBeat",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"_heartBeat",type:"uint256"},{internalType:"address",name:"_droplinkedWallet",type:"address"},{internalType:"uint256",name:"_droplinkedFee",type:"uint256"}],name:"initialize",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"",type:"uint256"}],name:"nftContracts",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"shopOwner",type:"address"},{internalType:"uint256",name:"",type:"uint256"}],name:"nftOwners",outputs:[{internalType:"address",name:"nftContracts",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"owner",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"renounceOwnership",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"newFee",type:"uint256"}],name:"setDroplinkedFee",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"newHeartBeat",type:"uint256"}],name:"setHeartBeat",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"",type:"uint256"}],name:"shopAddresses",outputs:[{internalType:"contract IDropShop",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"shopCount",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"shopOwner",type:"address"},{internalType:"uint256",name:"",type:"uint256"}],name:"shopOwners",outputs:[{internalType:"address",name:"shops",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"newOwner",type:"address"}],name:"transferOwnership",outputs:[],stateMutability:"nonpayable",type:"function"}],sixify=n=>n.toString().padStart(6,"0");async function getConstructorArgs(n,t,c){return[n.shopName||"",n.shopAddress||"",c,n.shopLogo||"",n.shopDescription||"",t]}async function deployEVMShop(n,t,c){console.log({...n,...t,...c});const{modalInterface:ie}=t,{chain:se,network:ae,provider:ue}=n,de=ue.getSigner(),ve=await getDeployerAddress(se,ae),ge=new Contract(ve,deployerABI,de),we=await getShopByteCode(),Te=await de.getAddress(),Ne="0x"+Te.split("0x")[1]+"000000000000000000"+sixify(Math.floor(Math.random()*1e6)+1),qe=await getConstructorArgs(c,ve,Te),ze=defaultAbiCoder.encode(["string","string","address","string","string","address"],qe);try{let He;const Ge=we+ze.split("0x")[1];console.log({fullBytecode:Ge}),n.chain!==Chains.SKALE?(await ge.callStatic.deployShop(Ge,Ne),He=await ge.deployShop(Ge,Ne,{})):He=await ge.deployShop(Ge,Ne);const Ze=(await He.wait()).logs.map(Mt=>{try{return ge.interface.parseLog(Mt)}catch{return null}}).filter(Mt=>Mt!=null).find(Mt=>Mt.name==="ShopDeployed"),Ye=Ze.args.shop,Ft=Ze.args.nftContract;return{transactionHash:He.hash,deployedShopAddress:Ye,deployedNFTAddress:Ft}}catch(He){if(ie.error("Error during shop deployment",`${He.message||He}`),He.code.toString()==="ACTION_REJECTED")throw new UserDeniedException("Deployer");try{const Ge=ge.interface.parseError(He.data);throw ie.error("Contract error",`${Ge}`),Ge}catch(Ge){throw ie.error("Unhandled error during shop deployment.",`${Ge||He}`),new Error(Ge||"Unknown error occurred.")}}}function getRecordData(n,t,c){const{acceptsManageWallet:ie,amount:se,royalty:ae,type:ue}=n;return{nftAddress:c,uri:t,amount:se,accepted:ie,affiliatePercentage:ae,royalty:ae,nftType:NFTType.ERC1155,productType:ue}}async function prepareRecordData(n,t,c,ie){const{nftContract:se}=ie;if(!se)throw new InvalidParametersException(n.chain,"nftContract");const{description:ae}=c,{skuID:ue}=t,de={...t,...c},ve={...de.skuProperties},ge={name:de.productTitle,description:ae,image:de.imageUrl,properties:ve},we=await uploadMetadata(ge,ue,ie.axiosInstance);return getRecordData(de,we,se)}async function doRecordProduct(n,t,c,ie){const{modalInterface:se,nftContract:ae,shopContractAddress:ue}=t;if(!ae||!ue)throw se.error("Invalid Parameters","nftContract||shopContractAddress"),new InvalidParametersException(n.chain,"nftContract||shopContractAddress");se.changeStep("Connecting to wallet");const de=n.provider.getSigner(),ve=new Contract(ue,shopABI,de);try{se.changeStep("Preparing products for recording");const ge=await Promise.all(ie.map(Te=>prepareRecordData(n,Te,c,t)));let we;return n.chain!==Chains.SKALE?(await ve.callStatic.mintAndRegisterBatch(ge),se.changeStep("Recording products on blockchain"),we=await ve.mintAndRegisterBatch(ge)):(se.changeStep("Recording products on blockchain"),we=await ve.mintAndRegisterBatch(ge)),se.changeStep("Waiting for transaction confirmation"),await we.wait(),{transactionHash:we.hash,metadataUrls:ge.map(Te=>Te.uri)}}catch(ge){if(ge.code&&ge.code.toString()==="ACTION_REJECTED")throw t.modalInterface.error("Transaction Rejected","ACTION_REJECTED"),new Error("Transaction Rejected");try{if(ge.data&&ge.data!=="0x"){const we=ve.interface.parseError(ge.data);throw we.name==="OwnableUnauthorizedAccount"?(t.modalInterface.error("Unauthorized","OwnableUnauthorizedAccount"),new Unauthorized(n.chain,"record",await de.getAddress(),ue)):(t.modalInterface.error(we.name,we.args.join(", ")),t.modalInterface.error(ge,we.name),ge)}else throw se.error("Transaction reverted without reason",`${ge}`),ge}catch(we){throw se.error("Unexpected error",`${we}`),we}}}async function recordProduct({productId:n,chain:t,axiosInstance:c,shopId:ie,network:se,stepizer:ae,provider:ue}){let de="",ve="";if(ae.changeStep("Starting record process"),ie!==""){const qe=await getShopInfo(t,ie,c);de=qe.nftContractAddress,ve=qe.shopContractAddress}const ge=new Web3Provider(ue,"any");if(!de||!ve){ae.changeStep("Deploying shop contract");const qe={chain:t,network:se,provider:ge},ze={axiosInstance:c,modalInterface:ae,nftContract:"",shopContractAddress:""},{description:He,logo:Ge,name:Ze,url:Ye,deployedContracts:Ft}=await getShopDeployInfo(ie,c),{deployedNFTAddress:Mt,deployedShopAddress:Zt,transactionHash:cn}=await deployEVMShop(qe,ze,{shopName:Ze,shopAddress:Ye,shopLogo:Ge,shopDescription:He}),hn=[...Ft||[],{type:t,deployedShopAddress:Zt,transactionId:cn,deployedNFTAddress:Mt,isCircle:!1,platform:"DROPLINKED",status:"SUCCESS"}];console.log({newDeployedContracts:hn}),de=Mt,ve=Zt,ae.changeStep("Shop deployed successfully")}await ensureWalletOnChainFromConfig(ge,getChainByName(t),se);const{productData:we,skuData:Te}=await getProductDataForRecord(n,c);if(!ie)throw new InvalidParametersException(t,"shopId");const Ne=await startRecord(n,Te.map(qe=>qe.skuID),ie,t,[],c);try{const qe=await doRecordProduct({chain:t,network:se,provider:ge},{axiosInstance:c,modalInterface:ae,nftContract:de,shopContractAddress:ve},we,Te);await updateUris(Ne,qe.metadataUrls,c),await updateHash("record",Ne,qe.transactionHash,c);const ze=`${getBaseUrl(se)}/web3/record/callback/events/${Ne}`;if(!await web3Callback(qe.transactionHash,t,Network[se],ze))throw new Web3CallbackFailedException("Record");return{...qe,transactionId:Ne,transactionHashUrl:getTransactionLink({blockchain:t,transactionHash:qe.transactionHash,isTestnet:se!==Network.MAINNET})}}catch(qe){throw console.error("Error during recording process:",qe),await deleteRecordTransaction(Ne,c),qe}}var utils$e={};const require$$0$3=getAugmentedNamespace(lib_esm$b),require$$1$2=getAugmentedNamespace(lib_esm$f),require$$2$3=getAugmentedNamespace(lib_esm$d),require$$3=getAugmentedNamespace(lib_esm$8),require$$4$3=getAugmentedNamespace(lib_esm$j),require$$5=getAugmentedNamespace(lib_esm$c),require$$6$2=getAugmentedNamespace(lib_esm$6),require$$7=getAugmentedNamespace(lib_esm$4),require$$8=getAugmentedNamespace(lib_esm$h),require$$9=getAugmentedNamespace(lib_esm$k),require$$10=getAugmentedNamespace(lib_esm$7),require$$11$1=getAugmentedNamespace(lib_esm$1),require$$12=getAugmentedNamespace(lib_esm$5),require$$13=getAugmentedNamespace(lib_esm$i),require$$14=getAugmentedNamespace(lib_esm$g),require$$15=getAugmentedNamespace(lib_esm$a),require$$16=getAugmentedNamespace(lib_esm$e),require$$17$1=getAugmentedNamespace(lib_esm$9),require$$18=getAugmentedNamespace(lib_esm),require$$19=getAugmentedNamespace(lib_esm$3),require$$20=getAugmentedNamespace(lib_esm$2);(function(n){var t=commonjsGlobal&&commonjsGlobal.__createBinding||(Object.create?function(le,pe,be,xe){xe===void 0&&(xe=be),Object.defineProperty(le,xe,{enumerable:!0,get:function(){return pe[be]}})}:function(le,pe,be,xe){xe===void 0&&(xe=be),le[xe]=pe[be]}),c=commonjsGlobal&&commonjsGlobal.__setModuleDefault||(Object.create?function(le,pe){Object.defineProperty(le,"default",{enumerable:!0,value:pe})}:function(le,pe){le.default=pe}),ie=commonjsGlobal&&commonjsGlobal.__importStar||function(le){if(le&&le.__esModule)return le;var pe={};if(le!=null)for(var be in le)be!=="default"&&Object.prototype.hasOwnProperty.call(le,be)&&t(pe,le,be);return c(pe,le),pe};Object.defineProperty(n,"__esModule",{value:!0}),n.formatBytes32String=n.Utf8ErrorFuncs=n.toUtf8String=n.toUtf8CodePoints=n.toUtf8Bytes=n._toEscapedUtf8String=n.nameprep=n.hexDataSlice=n.hexDataLength=n.hexZeroPad=n.hexValue=n.hexStripZeros=n.hexConcat=n.isHexString=n.hexlify=n.base64=n.base58=n.TransactionDescription=n.LogDescription=n.Interface=n.SigningKey=n.HDNode=n.defaultPath=n.isBytesLike=n.isBytes=n.zeroPad=n.stripZeros=n.concat=n.arrayify=n.shallowCopy=n.resolveProperties=n.getStatic=n.defineReadOnly=n.deepCopy=n.checkProperties=n.poll=n.fetchJson=n._fetchData=n.RLP=n.Logger=n.checkResultErrors=n.FormatTypes=n.ParamType=n.FunctionFragment=n.EventFragment=n.ErrorFragment=n.ConstructorFragment=n.Fragment=n.defaultAbiCoder=n.AbiCoder=void 0,n.Indexed=n.Utf8ErrorReason=n.UnicodeNormalizationForm=n.SupportedAlgorithm=n.mnemonicToSeed=n.isValidMnemonic=n.entropyToMnemonic=n.mnemonicToEntropy=n.getAccountPath=n.verifyTypedData=n.verifyMessage=n.recoverPublicKey=n.computePublicKey=n.recoverAddress=n.computeAddress=n.getJsonWalletAddress=n.TransactionTypes=n.serializeTransaction=n.parseTransaction=n.accessListify=n.joinSignature=n.splitSignature=n.soliditySha256=n.solidityKeccak256=n.solidityPack=n.shuffled=n.randomBytes=n.sha512=n.sha256=n.ripemd160=n.keccak256=n.computeHmac=n.commify=n.parseUnits=n.formatUnits=n.parseEther=n.formatEther=n.isAddress=n.getCreate2Address=n.getContractAddress=n.getIcapAddress=n.getAddress=n._TypedDataEncoder=n.id=n.isValidName=n.namehash=n.hashMessage=n.dnsEncode=n.parseBytes32String=void 0;var se=require$$0$3;Object.defineProperty(n,"AbiCoder",{enumerable:!0,get:function(){return se.AbiCoder}}),Object.defineProperty(n,"checkResultErrors",{enumerable:!0,get:function(){return se.checkResultErrors}}),Object.defineProperty(n,"ConstructorFragment",{enumerable:!0,get:function(){return se.ConstructorFragment}}),Object.defineProperty(n,"defaultAbiCoder",{enumerable:!0,get:function(){return se.defaultAbiCoder}}),Object.defineProperty(n,"ErrorFragment",{enumerable:!0,get:function(){return se.ErrorFragment}}),Object.defineProperty(n,"EventFragment",{enumerable:!0,get:function(){return se.EventFragment}}),Object.defineProperty(n,"FormatTypes",{enumerable:!0,get:function(){return se.FormatTypes}}),Object.defineProperty(n,"Fragment",{enumerable:!0,get:function(){return se.Fragment}}),Object.defineProperty(n,"FunctionFragment",{enumerable:!0,get:function(){return se.FunctionFragment}}),Object.defineProperty(n,"Indexed",{enumerable:!0,get:function(){return se.Indexed}}),Object.defineProperty(n,"Interface",{enumerable:!0,get:function(){return se.Interface}}),Object.defineProperty(n,"LogDescription",{enumerable:!0,get:function(){return se.LogDescription}}),Object.defineProperty(n,"ParamType",{enumerable:!0,get:function(){return se.ParamType}}),Object.defineProperty(n,"TransactionDescription",{enumerable:!0,get:function(){return se.TransactionDescription}});var ae=require$$1$2;Object.defineProperty(n,"getAddress",{enumerable:!0,get:function(){return ae.getAddress}}),Object.defineProperty(n,"getCreate2Address",{enumerable:!0,get:function(){return ae.getCreate2Address}}),Object.defineProperty(n,"getContractAddress",{enumerable:!0,get:function(){return ae.getContractAddress}}),Object.defineProperty(n,"getIcapAddress",{enumerable:!0,get:function(){return ae.getIcapAddress}}),Object.defineProperty(n,"isAddress",{enumerable:!0,get:function(){return ae.isAddress}});var ue=ie(require$$2$3);n.base64=ue;var de=require$$3;Object.defineProperty(n,"base58",{enumerable:!0,get:function(){return de.Base58}});var ve=require$$4$3;Object.defineProperty(n,"arrayify",{enumerable:!0,get:function(){return ve.arrayify}}),Object.defineProperty(n,"concat",{enumerable:!0,get:function(){return ve.concat}}),Object.defineProperty(n,"hexConcat",{enumerable:!0,get:function(){return ve.hexConcat}}),Object.defineProperty(n,"hexDataSlice",{enumerable:!0,get:function(){return ve.hexDataSlice}}),Object.defineProperty(n,"hexDataLength",{enumerable:!0,get:function(){return ve.hexDataLength}}),Object.defineProperty(n,"hexlify",{enumerable:!0,get:function(){return ve.hexlify}}),Object.defineProperty(n,"hexStripZeros",{enumerable:!0,get:function(){return ve.hexStripZeros}}),Object.defineProperty(n,"hexValue",{enumerable:!0,get:function(){return ve.hexValue}}),Object.defineProperty(n,"hexZeroPad",{enumerable:!0,get:function(){return ve.hexZeroPad}}),Object.defineProperty(n,"isBytes",{enumerable:!0,get:function(){return ve.isBytes}}),Object.defineProperty(n,"isBytesLike",{enumerable:!0,get:function(){return ve.isBytesLike}}),Object.defineProperty(n,"isHexString",{enumerable:!0,get:function(){return ve.isHexString}}),Object.defineProperty(n,"joinSignature",{enumerable:!0,get:function(){return ve.joinSignature}}),Object.defineProperty(n,"zeroPad",{enumerable:!0,get:function(){return ve.zeroPad}}),Object.defineProperty(n,"splitSignature",{enumerable:!0,get:function(){return ve.splitSignature}}),Object.defineProperty(n,"stripZeros",{enumerable:!0,get:function(){return ve.stripZeros}});var ge=require$$5;Object.defineProperty(n,"_TypedDataEncoder",{enumerable:!0,get:function(){return ge._TypedDataEncoder}}),Object.defineProperty(n,"dnsEncode",{enumerable:!0,get:function(){return ge.dnsEncode}}),Object.defineProperty(n,"hashMessage",{enumerable:!0,get:function(){return ge.hashMessage}}),Object.defineProperty(n,"id",{enumerable:!0,get:function(){return ge.id}}),Object.defineProperty(n,"isValidName",{enumerable:!0,get:function(){return ge.isValidName}}),Object.defineProperty(n,"namehash",{enumerable:!0,get:function(){return ge.namehash}});var we=require$$6$2;Object.defineProperty(n,"defaultPath",{enumerable:!0,get:function(){return we.defaultPath}}),Object.defineProperty(n,"entropyToMnemonic",{enumerable:!0,get:function(){return we.entropyToMnemonic}}),Object.defineProperty(n,"getAccountPath",{enumerable:!0,get:function(){return we.getAccountPath}}),Object.defineProperty(n,"HDNode",{enumerable:!0,get:function(){return we.HDNode}}),Object.defineProperty(n,"isValidMnemonic",{enumerable:!0,get:function(){return we.isValidMnemonic}}),Object.defineProperty(n,"mnemonicToEntropy",{enumerable:!0,get:function(){return we.mnemonicToEntropy}}),Object.defineProperty(n,"mnemonicToSeed",{enumerable:!0,get:function(){return we.mnemonicToSeed}});var Te=require$$7;Object.defineProperty(n,"getJsonWalletAddress",{enumerable:!0,get:function(){return Te.getJsonWalletAddress}});var Ne=require$$8;Object.defineProperty(n,"keccak256",{enumerable:!0,get:function(){return Ne.keccak256}});var qe=require$$9;Object.defineProperty(n,"Logger",{enumerable:!0,get:function(){return qe.Logger}});var ze=require$$10;Object.defineProperty(n,"computeHmac",{enumerable:!0,get:function(){return ze.computeHmac}}),Object.defineProperty(n,"ripemd160",{enumerable:!0,get:function(){return ze.ripemd160}}),Object.defineProperty(n,"sha256",{enumerable:!0,get:function(){return ze.sha256}}),Object.defineProperty(n,"sha512",{enumerable:!0,get:function(){return ze.sha512}});var He=require$$11$1;Object.defineProperty(n,"solidityKeccak256",{enumerable:!0,get:function(){return He.keccak256}}),Object.defineProperty(n,"solidityPack",{enumerable:!0,get:function(){return He.pack}}),Object.defineProperty(n,"soliditySha256",{enumerable:!0,get:function(){return He.sha256}});var Ge=require$$12;Object.defineProperty(n,"randomBytes",{enumerable:!0,get:function(){return Ge.randomBytes}}),Object.defineProperty(n,"shuffled",{enumerable:!0,get:function(){return Ge.shuffled}});var Ze=require$$13;Object.defineProperty(n,"checkProperties",{enumerable:!0,get:function(){return Ze.checkProperties}}),Object.defineProperty(n,"deepCopy",{enumerable:!0,get:function(){return Ze.deepCopy}}),Object.defineProperty(n,"defineReadOnly",{enumerable:!0,get:function(){return Ze.defineReadOnly}}),Object.defineProperty(n,"getStatic",{enumerable:!0,get:function(){return Ze.getStatic}}),Object.defineProperty(n,"resolveProperties",{enumerable:!0,get:function(){return Ze.resolveProperties}}),Object.defineProperty(n,"shallowCopy",{enumerable:!0,get:function(){return Ze.shallowCopy}});var Ye=ie(require$$14);n.RLP=Ye;var Ft=require$$15;Object.defineProperty(n,"computePublicKey",{enumerable:!0,get:function(){return Ft.computePublicKey}}),Object.defineProperty(n,"recoverPublicKey",{enumerable:!0,get:function(){return Ft.recoverPublicKey}}),Object.defineProperty(n,"SigningKey",{enumerable:!0,get:function(){return Ft.SigningKey}});var Mt=require$$16;Object.defineProperty(n,"formatBytes32String",{enumerable:!0,get:function(){return Mt.formatBytes32String}}),Object.defineProperty(n,"nameprep",{enumerable:!0,get:function(){return Mt.nameprep}}),Object.defineProperty(n,"parseBytes32String",{enumerable:!0,get:function(){return Mt.parseBytes32String}}),Object.defineProperty(n,"_toEscapedUtf8String",{enumerable:!0,get:function(){return Mt._toEscapedUtf8String}}),Object.defineProperty(n,"toUtf8Bytes",{enumerable:!0,get:function(){return Mt.toUtf8Bytes}}),Object.defineProperty(n,"toUtf8CodePoints",{enumerable:!0,get:function(){return Mt.toUtf8CodePoints}}),Object.defineProperty(n,"toUtf8String",{enumerable:!0,get:function(){return Mt.toUtf8String}}),Object.defineProperty(n,"Utf8ErrorFuncs",{enumerable:!0,get:function(){return Mt.Utf8ErrorFuncs}});var Zt=require$$17$1;Object.defineProperty(n,"accessListify",{enumerable:!0,get:function(){return Zt.accessListify}}),Object.defineProperty(n,"computeAddress",{enumerable:!0,get:function(){return Zt.computeAddress}}),Object.defineProperty(n,"parseTransaction",{enumerable:!0,get:function(){return Zt.parse}}),Object.defineProperty(n,"recoverAddress",{enumerable:!0,get:function(){return Zt.recoverAddress}}),Object.defineProperty(n,"serializeTransaction",{enumerable:!0,get:function(){return Zt.serialize}}),Object.defineProperty(n,"TransactionTypes",{enumerable:!0,get:function(){return Zt.TransactionTypes}});var cn=require$$18;Object.defineProperty(n,"commify",{enumerable:!0,get:function(){return cn.commify}}),Object.defineProperty(n,"formatEther",{enumerable:!0,get:function(){return cn.formatEther}}),Object.defineProperty(n,"parseEther",{enumerable:!0,get:function(){return cn.parseEther}}),Object.defineProperty(n,"formatUnits",{enumerable:!0,get:function(){return cn.formatUnits}}),Object.defineProperty(n,"parseUnits",{enumerable:!0,get:function(){return cn.parseUnits}});var hn=require$$19;Object.defineProperty(n,"verifyMessage",{enumerable:!0,get:function(){return hn.verifyMessage}}),Object.defineProperty(n,"verifyTypedData",{enumerable:!0,get:function(){return hn.verifyTypedData}});var yn=require$$20;Object.defineProperty(n,"_fetchData",{enumerable:!0,get:function(){return yn._fetchData}}),Object.defineProperty(n,"fetchJson",{enumerable:!0,get:function(){return yn.fetchJson}}),Object.defineProperty(n,"poll",{enumerable:!0,get:function(){return yn.poll}});var Ht=require$$10;Object.defineProperty(n,"SupportedAlgorithm",{enumerable:!0,get:function(){return Ht.SupportedAlgorithm}});var Sn=require$$16;Object.defineProperty(n,"UnicodeNormalizationForm",{enumerable:!0,get:function(){return Sn.UnicodeNormalizationForm}}),Object.defineProperty(n,"Utf8ErrorReason",{enumerable:!0,get:function(){return Sn.Utf8ErrorReason}})})(utils$e);const ZERO_ADDRESS="0x0000000000000000000000000000000000000000",SkaleUsdcAddressForTestnet="0x2aebcdc4f9f9149a50422fff86198cb0939ea165",SkaleUsdcAddressForMainnet="0x7Cf76E740Cb23b99337b21F392F22c47Ad910c67",erc20ABI=[{inputs:[],stateMutability:"nonpayable",type:"constructor"},{inputs:[{internalType:"address",name:"spender",type:"address"},{internalType:"uint256",name:"allowance",type:"uint256"},{internalType:"uint256",name:"needed",type:"uint256"}],name:"ERC20InsufficientAllowance",type:"error"},{inputs:[{internalType:"address",name:"sender",type:"address"},{internalType:"uint256",name:"balance",type:"uint256"},{internalType:"uint256",name:"needed",type:"uint256"}],name:"ERC20InsufficientBalance",type:"error"},{inputs:[{internalType:"address",name:"approver",type:"address"}],name:"ERC20InvalidApprover",type:"error"},{inputs:[{internalType:"address",name:"receiver",type:"address"}],name:"ERC20InvalidReceiver",type:"error"},{inputs:[{internalType:"address",name:"sender",type:"address"}],name:"ERC20InvalidSender",type:"error"},{inputs:[{internalType:"address",name:"spender",type:"address"}],name:"ERC20InvalidSpender",type:"error"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"owner",type:"address"},{indexed:!0,internalType:"address",name:"spender",type:"address"},{indexed:!1,internalType:"uint256",name:"value",type:"uint256"}],name:"Approval",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"from",type:"address"},{indexed:!0,internalType:"address",name:"to",type:"address"},{indexed:!1,internalType:"uint256",name:"value",type:"uint256"}],name:"Transfer",type:"event"},{inputs:[{internalType:"address",name:"owner",type:"address"},{internalType:"address",name:"spender",type:"address"}],name:"allowance",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"spender",type:"address"},{internalType:"uint256",name:"value",type:"uint256"}],name:"approve",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"account",type:"address"}],name:"balanceOf",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"decimals",outputs:[{internalType:"uint8",name:"",type:"uint8"}],stateMutability:"view",type:"function"},{inputs:[],name:"name",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"},{inputs:[],name:"symbol",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"},{inputs:[],name:"totalSupply",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"value",type:"uint256"}],name:"transfer",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"from",type:"address"},{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"value",type:"uint256"}],name:"transferFrom",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"}],paymentProxyABI=[{inputs:[{internalType:"uint256",name:"_heartBeat",type:"uint256"},{internalType:"address",name:"_chainLinkProvider",type:"address"}],stateMutability:"nonpayable",type:"constructor"},{inputs:[{internalType:"address",name:"owner",type:"address"}],name:"OwnableInvalidOwner",type:"error"},{inputs:[{internalType:"address",name:"account",type:"address"}],name:"OwnableUnauthorizedAccount",type:"error"},{inputs:[{internalType:"uint256",name:"priceTimestamp",type:"uint256"},{internalType:"uint256",name:"currentTimestamp",type:"uint256"}],name:"oldPrice",type:"error"},{anonymous:!1,inputs:[{indexed:!1,internalType:"uint256",name:"newHeartBeat",type:"uint256"}],name:"HeartBeatChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"previousOwner",type:"address"},{indexed:!0,internalType:"address",name:"newOwner",type:"address"}],name:"OwnershipTransferred",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"string",name:"memo",type:"string"}],name:"ProductPurchased",type:"event"},{inputs:[{internalType:"uint256",name:"_heartBeat",type:"uint256"}],name:"changeHeartBeat",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256[]",name:"tbdValues",type:"uint256[]"},{internalType:"address[]",name:"tbdReceivers",type:"address[]"},{internalType:"address",name:"currency",type:"address"},{internalType:"uint80",name:"roundId",type:"uint80"},{internalType:"string",name:"memo",type:"string"}],name:"droplinkedPurchase",outputs:[],stateMutability:"payable",type:"function"},{inputs:[],name:"heartBeat",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"owner",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"renounceOwnership",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"newOwner",type:"address"}],name:"transferOwnership",outputs:[],stateMutability:"nonpayable",type:"function"}];async function handleCustomTokenApproval(n,t,c,ie,se){if(!n.tokenAddress)throw new InvalidParametersException(Chains.BASE,"Token address is not set");try{const ae=new Contract(n.tokenAddress,erc20ABI,c),ue=await ae.balanceOf(ie),de=n.tbdValues.reduce((ge,we)=>ge.add(BigNumber.from(we)),BigNumber.from(0));if(ue.lt(de))throw new InsufficientBalanceException;se.changeStep("Approving token");const ve=await ae.approve(t,MaxUint256$1);se.changeStep("awaiting confirmation"),await ve.wait(),se.changeStep("Token approval confirmed")}catch(ae){handleError(ae)}}const droplinkedPayment=async function(n,t,c){const{modalInterface:ie}=t,{provider:se,chain:ae,network:ue}=n;if(!c.tbdReceivers.every(utils$e.isAddress))throw new InvalidParametersException(ae,"Invalid receiver address found");c.chainLinkRoundId=c.chainLinkRoundId||"0";const de=c.tokenAddress&&c.tokenAddress!==ZERO_ADDRESS;if(de){if(!c.tbdValues.every(Ne=>BigNumber.from(Ne).gt(0)))throw new InvalidParametersException(ae,"tbdValues must be positive numbers")}else if(!c.tbdValues.every(Ne=>Ne>0))throw new InvalidParametersException(ae,"tbdValues must be positive numbers");const ve=se.getSigner(),ge=await ve.getAddress();if(!c.tbdValues)throw new InvalidParametersException(ae,`Invalid tbdValues: ${c.tbdValues}`);if(!c.tbdReceivers)throw new InvalidParametersException(ae,`Invalid tbdReceivers: ${c.tbdReceivers}`);if(!c.memo)throw new InvalidParametersException(ae,`Memo is required for payment, current memo: ${c.memo}`);if(c.tbdReceivers.length!==c.tbdValues.length)throw new InvalidParametersException(ae,"tbdReceivers and tbdValues must be the same length");let we;try{we=await getProxyAddress(ae,ue)}catch(Ne){throw new Error("Failed to get contract address: "+Ne.message)}let Te;try{Te=new Contract(we,paymentProxyABI,ve)}catch(Ne){throw new Error("Failed to create contract instance: "+Ne.message)}try{if(console.log(`
14
14
  Purchase Details:
15
15
  data.tbdValues: ${c.tbdValues}
16
16
  data.tbdReceivers: ${c.tbdReceivers}