eth-connect
Version:
Ethereum TypeScript API, middleware to talk to a ethereum node using an async provider
14 lines • 83.6 kB
JavaScript
/*! eth-connect {
"date": "2024-01-01T15:10:57.542Z",
"commit": "b2fa64415d297ccce86d2a5d59d8705388f77db9",
"ref": "refs/tags/6.2.4"
} */
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define("eth-connect",["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).ethconnect={})}(this,(function(t){"use strict";function e(t){if(t.jsonrpc="2.0",!t.id||"number"!=typeof t.id||Math.floor(t.id)!==t.id)throw new Error(`Invalid RPC message(invalid id) message: ${JSON.stringify(t)}`);if(!t.method||"string"!=typeof t.method||0===t.method.trim().length)throw new Error(`Invalid RPC message(invalid method) message: ${JSON.stringify(t)}`);if(!t.params||"object"!=typeof t.params)throw new Error(`Invalid RPC message(invalid params) message: ${JSON.stringify(t)}`);return t}var n={};function r(){let t,e;const n=new Promise(((r,o)=>{t=t=>{r(t),n.isPending=!1},e=t=>{o(t),n.isPending=!1}})).catch((t=>Promise.reject(t)));return n.resolve=t,n.reject=e,"finally"in n||(n.finally=t=>{n.then(t),n.catch(t)}),n.isPending=!0,n}Object.defineProperty(n,"__esModule",{value:!0});var o=n.future=r;n.default=r;var i={exports:{}};
/**
* [js-sha3]{@link https://github.com/emn178/js-sha3}
*
* @version 0.8.0
* @author Chen, Yi-Cyuan [emn178@gmail.com]
* @copyright Chen, Yi-Cyuan 2015-2018
* @license MIT
*/!function(t){!function(){var e="input is invalid type",n="object"==typeof window,r=n?window:{};r.JS_SHA3_NO_WINDOW&&(n=!1);var o=!n&&"object"==typeof self;!r.JS_SHA3_NO_NODE_JS&&"object"==typeof process&&process.versions&&process.versions.node?r=global:o&&(r=self);var i=!r.JS_SHA3_NO_COMMON_JS&&t.exports,s=!r.JS_SHA3_NO_ARRAY_BUFFER&&"undefined"!=typeof ArrayBuffer,a="0123456789abcdef".split(""),c=[4,1024,262144,67108864],u=[0,8,16,24],l=[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],h=[224,256,384,512],p=[128,256],f=["hex","buffer","arrayBuffer","array","digest"],d={128:168,256:136};!r.JS_SHA3_NO_NODE_JS&&Array.isArray||(Array.isArray=function(t){return"[object Array]"===Object.prototype.toString.call(t)}),!s||!r.JS_SHA3_NO_ARRAY_BUFFER_IS_VIEW&&ArrayBuffer.isView||(ArrayBuffer.isView=function(t){return"object"==typeof t&&t.buffer&&t.buffer.constructor===ArrayBuffer});for(var g=function(t,e,n){return function(r){return new S(t,e,t).update(r)[n]()}},m=function(t,e,n){return function(r,o){return new S(t,e,o).update(r)[n]()}},y=function(t,e,n){return function(e,r,o,i){return F["cshake"+t].update(e,r,o,i)[n]()}},w=function(t,e,n){return function(e,r,o,i){return F["kmac"+t].update(e,r,o,i)[n]()}},v=function(t,e,n,r){for(var o=0;o<f.length;++o){var i=f[o];t[i]=e(n,r,i)}return t},b=function(t,e){var n=g(t,e,"hex");return n.create=function(){return new S(t,e,t)},n.update=function(t){return n.create().update(t)},v(n,g,t,e)},_=[{name:"keccak",padding:[1,256,65536,16777216],bits:h,createMethod:b},{name:"sha3",padding:[6,1536,393216,100663296],bits:h,createMethod:b},{name:"shake",padding:[31,7936,2031616,520093696],bits:p,createMethod:function(t,e){var n=m(t,e,"hex");return n.create=function(n){return new S(t,e,n)},n.update=function(t,e){return n.create(e).update(t)},v(n,m,t,e)}},{name:"cshake",padding:c,bits:p,createMethod:function(t,e){var n=d[t],r=y(t,0,"hex");return r.create=function(r,o,i){return o||i?new S(t,e,r).bytepad([o,i],n):F["shake"+t].create(r)},r.update=function(t,e,n,o){return r.create(e,n,o).update(t)},v(r,y,t,e)}},{name:"kmac",padding:c,bits:p,createMethod:function(t,e){var n=d[t],r=w(t,0,"hex");return r.create=function(r,o,i){return new O(t,e,o).bytepad(["KMAC",i],n).bytepad([r],n)},r.update=function(t,e,n,o){return r.create(t,n,o).update(e)},v(r,w,t,e)}}],F={},N=[],x=0;x<_.length;++x)for(var k=_[x],A=k.bits,T=0;T<A.length;++T){var B=k.name+"_"+A[T];if(N.push(B),F[B]=k.createMethod(A[T],k.padding),"sha3"!==k.name){var E=k.name+A[T];N.push(E),F[E]=F[B]}}function S(t,e,n){this.blocks=[],this.s=[],this.padding=e,this.outputBits=n,this.reset=!0,this.finalized=!1,this.block=0,this.start=0,this.blockCount=1600-(t<<1)>>5,this.byteCount=this.blockCount<<2,this.outputBlocks=n>>5,this.extraBytes=(31&n)>>3;for(var r=0;r<50;++r)this.s[r]=0}function O(t,e,n){S.call(this,t,e,n)}S.prototype.update=function(t){if(this.finalized)throw new Error("finalize already called");var n,r=typeof t;if("string"!==r){if("object"!==r)throw new Error(e);if(null===t)throw new Error(e);if(s&&t.constructor===ArrayBuffer)t=new Uint8Array(t);else if(!(Array.isArray(t)||s&&ArrayBuffer.isView(t)))throw new Error(e);n=!0}for(var o,i,a=this.blocks,c=this.byteCount,l=t.length,h=this.blockCount,p=0,f=this.s;p<l;){if(this.reset)for(this.reset=!1,a[0]=this.block,o=1;o<h+1;++o)a[o]=0;if(n)for(o=this.start;p<l&&o<c;++p)a[o>>2]|=t[p]<<u[3&o++];else for(o=this.start;p<l&&o<c;++p)(i=t.charCodeAt(p))<128?a[o>>2]|=i<<u[3&o++]:i<2048?(a[o>>2]|=(192|i>>6)<<u[3&o++],a[o>>2]|=(128|63&i)<<u[3&o++]):i<55296||i>=57344?(a[o>>2]|=(224|i>>12)<<u[3&o++],a[o>>2]|=(128|i>>6&63)<<u[3&o++],a[o>>2]|=(128|63&i)<<u[3&o++]):(i=65536+((1023&i)<<10|1023&t.charCodeAt(++p)),a[o>>2]|=(240|i>>18)<<u[3&o++],a[o>>2]|=(128|i>>12&63)<<u[3&o++],a[o>>2]|=(128|i>>6&63)<<u[3&o++],a[o>>2]|=(128|63&i)<<u[3&o++]);if(this.lastByteIndex=o,o>=c){for(this.start=o-c,this.block=a[h],o=0;o<h;++o)f[o]^=a[o];C(f),this.reset=!0}else this.start=o}return this},S.prototype.encode=function(t,e){var n=255&t,r=1,o=[n];for(n=255&(t>>=8);n>0;)o.unshift(n),n=255&(t>>=8),++r;return e?o.push(r):o.unshift(r),this.update(o),o.length},S.prototype.encodeString=function(t){var n,r=typeof t;if("string"!==r){if("object"!==r)throw new Error(e);if(null===t)throw new Error(e);if(s&&t.constructor===ArrayBuffer)t=new Uint8Array(t);else if(!(Array.isArray(t)||s&&ArrayBuffer.isView(t)))throw new Error(e);n=!0}var o=0,i=t.length;if(n)o=i;else for(var a=0;a<t.length;++a){var c=t.charCodeAt(a);c<128?o+=1:c<2048?o+=2:c<55296||c>=57344?o+=3:(c=65536+((1023&c)<<10|1023&t.charCodeAt(++a)),o+=4)}return o+=this.encode(8*o),this.update(t),o},S.prototype.bytepad=function(t,e){for(var n=this.encode(e),r=0;r<t.length;++r)n+=this.encodeString(t[r]);var o=e-n%e,i=[];return i.length=o,this.update(i),this},S.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var t=this.blocks,e=this.lastByteIndex,n=this.blockCount,r=this.s;if(t[e>>2]|=this.padding[3&e],this.lastByteIndex===this.byteCount)for(t[0]=t[n],e=1;e<n+1;++e)t[e]=0;for(t[n-1]|=2147483648,e=0;e<n;++e)r[e]^=t[e];C(r)}},S.prototype.toString=S.prototype.hex=function(){this.finalize();for(var t,e=this.blockCount,n=this.s,r=this.outputBlocks,o=this.extraBytes,i=0,s=0,c="";s<r;){for(i=0;i<e&&s<r;++i,++s)t=n[i],c+=a[t>>4&15]+a[15&t]+a[t>>12&15]+a[t>>8&15]+a[t>>20&15]+a[t>>16&15]+a[t>>28&15]+a[t>>24&15];s%e==0&&(C(n),i=0)}return o&&(t=n[i],c+=a[t>>4&15]+a[15&t],o>1&&(c+=a[t>>12&15]+a[t>>8&15]),o>2&&(c+=a[t>>20&15]+a[t>>16&15])),c},S.prototype.arrayBuffer=function(){this.finalize();var t,e=this.blockCount,n=this.s,r=this.outputBlocks,o=this.extraBytes,i=0,s=0,a=this.outputBits>>3;t=o?new ArrayBuffer(r+1<<2):new ArrayBuffer(a);for(var c=new Uint32Array(t);s<r;){for(i=0;i<e&&s<r;++i,++s)c[s]=n[i];s%e==0&&C(n)}return o&&(c[i]=n[i],t=t.slice(0,a)),t},S.prototype.buffer=S.prototype.arrayBuffer,S.prototype.digest=S.prototype.array=function(){this.finalize();for(var t,e,n=this.blockCount,r=this.s,o=this.outputBlocks,i=this.extraBytes,s=0,a=0,c=[];a<o;){for(s=0;s<n&&a<o;++s,++a)t=a<<2,e=r[s],c[t]=255&e,c[t+1]=e>>8&255,c[t+2]=e>>16&255,c[t+3]=e>>24&255;a%n==0&&C(r)}return i&&(t=a<<2,e=r[s],c[t]=255&e,i>1&&(c[t+1]=e>>8&255),i>2&&(c[t+2]=e>>16&255)),c},O.prototype=new S,O.prototype.finalize=function(){return this.encode(this.outputBits,!0),S.prototype.finalize.call(this)};var C=function(t){var e,n,r,o,i,s,a,c,u,h,p,f,d,g,m,y,w,v,b,_,F,N,x,k,A,T,B,E,S,O,C,I,P,M,R,j,U,D,q,$,H,L,G,z,J,W,V,K,Z,Y,X,Q,tt,et,nt,rt,ot,it,st,at,ct,ut,lt;for(r=0;r<48;r+=2)o=t[0]^t[10]^t[20]^t[30]^t[40],i=t[1]^t[11]^t[21]^t[31]^t[41],s=t[2]^t[12]^t[22]^t[32]^t[42],a=t[3]^t[13]^t[23]^t[33]^t[43],c=t[4]^t[14]^t[24]^t[34]^t[44],u=t[5]^t[15]^t[25]^t[35]^t[45],h=t[6]^t[16]^t[26]^t[36]^t[46],p=t[7]^t[17]^t[27]^t[37]^t[47],e=(f=t[8]^t[18]^t[28]^t[38]^t[48])^(s<<1|a>>>31),n=(d=t[9]^t[19]^t[29]^t[39]^t[49])^(a<<1|s>>>31),t[0]^=e,t[1]^=n,t[10]^=e,t[11]^=n,t[20]^=e,t[21]^=n,t[30]^=e,t[31]^=n,t[40]^=e,t[41]^=n,e=o^(c<<1|u>>>31),n=i^(u<<1|c>>>31),t[2]^=e,t[3]^=n,t[12]^=e,t[13]^=n,t[22]^=e,t[23]^=n,t[32]^=e,t[33]^=n,t[42]^=e,t[43]^=n,e=s^(h<<1|p>>>31),n=a^(p<<1|h>>>31),t[4]^=e,t[5]^=n,t[14]^=e,t[15]^=n,t[24]^=e,t[25]^=n,t[34]^=e,t[35]^=n,t[44]^=e,t[45]^=n,e=c^(f<<1|d>>>31),n=u^(d<<1|f>>>31),t[6]^=e,t[7]^=n,t[16]^=e,t[17]^=n,t[26]^=e,t[27]^=n,t[36]^=e,t[37]^=n,t[46]^=e,t[47]^=n,e=h^(o<<1|i>>>31),n=p^(i<<1|o>>>31),t[8]^=e,t[9]^=n,t[18]^=e,t[19]^=n,t[28]^=e,t[29]^=n,t[38]^=e,t[39]^=n,t[48]^=e,t[49]^=n,g=t[0],m=t[1],W=t[11]<<4|t[10]>>>28,V=t[10]<<4|t[11]>>>28,E=t[20]<<3|t[21]>>>29,S=t[21]<<3|t[20]>>>29,at=t[31]<<9|t[30]>>>23,ct=t[30]<<9|t[31]>>>23,L=t[40]<<18|t[41]>>>14,G=t[41]<<18|t[40]>>>14,M=t[2]<<1|t[3]>>>31,R=t[3]<<1|t[2]>>>31,y=t[13]<<12|t[12]>>>20,w=t[12]<<12|t[13]>>>20,K=t[22]<<10|t[23]>>>22,Z=t[23]<<10|t[22]>>>22,O=t[33]<<13|t[32]>>>19,C=t[32]<<13|t[33]>>>19,ut=t[42]<<2|t[43]>>>30,lt=t[43]<<2|t[42]>>>30,et=t[5]<<30|t[4]>>>2,nt=t[4]<<30|t[5]>>>2,j=t[14]<<6|t[15]>>>26,U=t[15]<<6|t[14]>>>26,v=t[25]<<11|t[24]>>>21,b=t[24]<<11|t[25]>>>21,Y=t[34]<<15|t[35]>>>17,X=t[35]<<15|t[34]>>>17,I=t[45]<<29|t[44]>>>3,P=t[44]<<29|t[45]>>>3,k=t[6]<<28|t[7]>>>4,A=t[7]<<28|t[6]>>>4,rt=t[17]<<23|t[16]>>>9,ot=t[16]<<23|t[17]>>>9,D=t[26]<<25|t[27]>>>7,q=t[27]<<25|t[26]>>>7,_=t[36]<<21|t[37]>>>11,F=t[37]<<21|t[36]>>>11,Q=t[47]<<24|t[46]>>>8,tt=t[46]<<24|t[47]>>>8,z=t[8]<<27|t[9]>>>5,J=t[9]<<27|t[8]>>>5,T=t[18]<<20|t[19]>>>12,B=t[19]<<20|t[18]>>>12,it=t[29]<<7|t[28]>>>25,st=t[28]<<7|t[29]>>>25,$=t[38]<<8|t[39]>>>24,H=t[39]<<8|t[38]>>>24,N=t[48]<<14|t[49]>>>18,x=t[49]<<14|t[48]>>>18,t[0]=g^~y&v,t[1]=m^~w&b,t[10]=k^~T&E,t[11]=A^~B&S,t[20]=M^~j&D,t[21]=R^~U&q,t[30]=z^~W&K,t[31]=J^~V&Z,t[40]=et^~rt&it,t[41]=nt^~ot&st,t[2]=y^~v&_,t[3]=w^~b&F,t[12]=T^~E&O,t[13]=B^~S&C,t[22]=j^~D&$,t[23]=U^~q&H,t[32]=W^~K&Y,t[33]=V^~Z&X,t[42]=rt^~it&at,t[43]=ot^~st&ct,t[4]=v^~_&N,t[5]=b^~F&x,t[14]=E^~O&I,t[15]=S^~C&P,t[24]=D^~$&L,t[25]=q^~H&G,t[34]=K^~Y&Q,t[35]=Z^~X&tt,t[44]=it^~at&ut,t[45]=st^~ct<,t[6]=_^~N&g,t[7]=F^~x&m,t[16]=O^~I&k,t[17]=C^~P&A,t[26]=$^~L&M,t[27]=H^~G&R,t[36]=Y^~Q&z,t[37]=X^~tt&J,t[46]=at^~ut&et,t[47]=ct^~lt&nt,t[8]=N^~g&y,t[9]=x^~m&w,t[18]=I^~k&T,t[19]=P^~A&B,t[28]=L^~M&j,t[29]=G^~R&U,t[38]=Q^~z&W,t[39]=tt^~J&V,t[48]=ut^~et&rt,t[49]=lt^~nt&ot,t[0]^=l[r],t[1]^=l[r+1]};if(i)t.exports=F;else for(x=0;x<N.length;++x)r[N[x]]=F[N[x]]}()}(i);var s=i.exports,a=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,c=Math.ceil,u=Math.floor,l="[BigNumber Error] ",h=l+"Number primitive has more than 15 significant digits: ",p=1e14,f=14,d=9007199254740991,g=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],m=1e7,y=1e9;function w(t){var e=0|t;return t>0||t===e?e:e-1}function v(t){for(var e,n,r=1,o=t.length,i=t[0]+"";r<o;){for(e=t[r++]+"",n=f-e.length;n--;e="0"+e);i+=e}for(o=i.length;48===i.charCodeAt(--o););return i.slice(0,o+1||1)}function b(t,e){var n,r,o=t.c,i=e.c,s=t.s,a=e.s,c=t.e,u=e.e;if(!s||!a)return null;if(n=o&&!o[0],r=i&&!i[0],n||r)return n?r?0:-a:s;if(s!=a)return s;if(n=s<0,r=c==u,!o||!i)return r?0:!o^n?1:-1;if(!r)return c>u^n?1:-1;for(a=(c=o.length)<(u=i.length)?c:u,s=0;s<a;s++)if(o[s]!=i[s])return o[s]>i[s]^n?1:-1;return c==u?0:c>u^n?1:-1}function _(t,e,n,r){if(t<e||t>n||t!==u(t))throw Error(l+(r||"Argument")+("number"==typeof t?t<e||t>n?" out of range: ":" not an integer: ":" not a primitive number: ")+String(t))}function F(t){var e=t.c.length-1;return w(t.e/f)==e&&t.c[e]%2!=0}function N(t,e){return(t.length>1?t.charAt(0)+"."+t.slice(1):t)+(e<0?"e":"e+")+e}function x(t,e,n){var r,o;if(e<0){for(o=n+".";++e;o+=n);t=o+t}else if(++e>(r=t.length)){for(o=n,e-=r;--e;o+=n);t+=o}else e<r&&(t=t.slice(0,e)+"."+t.slice(e));return t}var k=function t(e){var n,r,o,i,s,k,A,T,B,E,S=G.prototype={constructor:G,toString:null,valueOf:null},O=new G(1),C=20,I=4,P=-7,M=21,R=-1e7,j=1e7,U=!1,D=1,q=0,$={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:" ",suffix:""},H="0123456789abcdefghijklmnopqrstuvwxyz",L=!0;function G(t,e){var n,i,s,c,l,p,g,m,y=this;if(!(y instanceof G))return new G(t,e);if(null==e){if(t&&!0===t._isBigNumber)return y.s=t.s,void(!t.c||t.e>j?y.c=y.e=null:t.e<R?y.c=[y.e=0]:(y.e=t.e,y.c=t.c.slice()));if((p="number"==typeof t)&&0*t==0){if(y.s=1/t<0?(t=-t,-1):1,t===~~t){for(c=0,l=t;l>=10;l/=10,c++);return void(c>j?y.c=y.e=null:(y.e=c,y.c=[t]))}m=String(t)}else{if(!a.test(m=String(t)))return o(y,m,p);y.s=45==m.charCodeAt(0)?(m=m.slice(1),-1):1}(c=m.indexOf("."))>-1&&(m=m.replace(".","")),(l=m.search(/e/i))>0?(c<0&&(c=l),c+=+m.slice(l+1),m=m.substring(0,l)):c<0&&(c=m.length)}else{if(_(e,2,H.length,"Base"),10==e&&L)return V(y=new G(t),C+y.e+1,I);if(m=String(t),p="number"==typeof t){if(0*t!=0)return o(y,m,p,e);if(y.s=1/t<0?(m=m.slice(1),-1):1,G.DEBUG&&m.replace(/^0\.0*|\./,"").length>15)throw Error(h+t)}else y.s=45===m.charCodeAt(0)?(m=m.slice(1),-1):1;for(n=H.slice(0,e),c=l=0,g=m.length;l<g;l++)if(n.indexOf(i=m.charAt(l))<0){if("."==i){if(l>c){c=g;continue}}else if(!s&&(m==m.toUpperCase()&&(m=m.toLowerCase())||m==m.toLowerCase()&&(m=m.toUpperCase()))){s=!0,l=-1,c=0;continue}return o(y,String(t),p,e)}p=!1,(c=(m=r(m,e,10,y.s)).indexOf("."))>-1?m=m.replace(".",""):c=m.length}for(l=0;48===m.charCodeAt(l);l++);for(g=m.length;48===m.charCodeAt(--g););if(m=m.slice(l,++g)){if(g-=l,p&&G.DEBUG&&g>15&&(t>d||t!==u(t)))throw Error(h+y.s*t);if((c=c-l-1)>j)y.c=y.e=null;else if(c<R)y.c=[y.e=0];else{if(y.e=c,y.c=[],l=(c+1)%f,c<0&&(l+=f),l<g){for(l&&y.c.push(+m.slice(0,l)),g-=f;l<g;)y.c.push(+m.slice(l,l+=f));l=f-(m=m.slice(l)).length}else l-=g;for(;l--;m+="0");y.c.push(+m)}}else y.c=[y.e=0]}function z(t,e,n,r){var o,i,s,a,c;if(null==n?n=I:_(n,0,8),!t.c)return t.toString();if(o=t.c[0],s=t.e,null==e)c=v(t.c),c=1==r||2==r&&(s<=P||s>=M)?N(c,s):x(c,s,"0");else if(i=(t=V(new G(t),e,n)).e,a=(c=v(t.c)).length,1==r||2==r&&(e<=i||i<=P)){for(;a<e;c+="0",a++);c=N(c,i)}else if(e-=s,c=x(c,i,"0"),i+1>a){if(--e>0)for(c+=".";e--;c+="0");}else if((e+=i-a)>0)for(i+1==a&&(c+=".");e--;c+="0");return t.s<0&&o?"-"+c:c}function J(t,e){for(var n,r=1,o=new G(t[0]);r<t.length;r++){if(!(n=new G(t[r])).s){o=n;break}e.call(o,n)&&(o=n)}return o}function W(t,e,n){for(var r=1,o=e.length;!e[--o];e.pop());for(o=e[0];o>=10;o/=10,r++);return(n=r+n*f-1)>j?t.c=t.e=null:n<R?t.c=[t.e=0]:(t.e=n,t.c=e),t}function V(t,e,n,r){var o,i,s,a,l,h,d,m=t.c,y=g;if(m){t:{for(o=1,a=m[0];a>=10;a/=10,o++);if((i=e-o)<0)i+=f,s=e,d=(l=m[h=0])/y[o-s-1]%10|0;else if((h=c((i+1)/f))>=m.length){if(!r)break t;for(;m.length<=h;m.push(0));l=d=0,o=1,s=(i%=f)-f+1}else{for(l=a=m[h],o=1;a>=10;a/=10,o++);d=(s=(i%=f)-f+o)<0?0:l/y[o-s-1]%10|0}if(r=r||e<0||null!=m[h+1]||(s<0?l:l%y[o-s-1]),r=n<4?(d||r)&&(0==n||n==(t.s<0?3:2)):d>5||5==d&&(4==n||r||6==n&&(i>0?s>0?l/y[o-s]:0:m[h-1])%10&1||n==(t.s<0?8:7)),e<1||!m[0])return m.length=0,r?(e-=t.e+1,m[0]=y[(f-e%f)%f],t.e=-e||0):m[0]=t.e=0,t;if(0==i?(m.length=h,a=1,h--):(m.length=h+1,a=y[f-i],m[h]=s>0?u(l/y[o-s]%y[s])*a:0),r)for(;;){if(0==h){for(i=1,s=m[0];s>=10;s/=10,i++);for(s=m[0]+=a,a=1;s>=10;s/=10,a++);i!=a&&(t.e++,m[0]==p&&(m[0]=1));break}if(m[h]+=a,m[h]!=p)break;m[h--]=0,a=1}for(i=m.length;0===m[--i];m.pop());}t.e>j?t.c=t.e=null:t.e<R&&(t.c=[t.e=0])}return t}function K(t){var e,n=t.e;return null===n?t.toString():(e=v(t.c),e=n<=P||n>=M?N(e,n):x(e,n,"0"),t.s<0?"-"+e:e)}return G.clone=t,G.ROUND_UP=0,G.ROUND_DOWN=1,G.ROUND_CEIL=2,G.ROUND_FLOOR=3,G.ROUND_HALF_UP=4,G.ROUND_HALF_DOWN=5,G.ROUND_HALF_EVEN=6,G.ROUND_HALF_CEIL=7,G.ROUND_HALF_FLOOR=8,G.EUCLID=9,G.config=G.set=function(t){var e,n;if(null!=t){if("object"!=typeof t)throw Error(l+"Object expected: "+t);if(t.hasOwnProperty(e="DECIMAL_PLACES")&&(_(n=t[e],0,y,e),C=n),t.hasOwnProperty(e="ROUNDING_MODE")&&(_(n=t[e],0,8,e),I=n),t.hasOwnProperty(e="EXPONENTIAL_AT")&&((n=t[e])&&n.pop?(_(n[0],-y,0,e),_(n[1],0,y,e),P=n[0],M=n[1]):(_(n,-y,y,e),P=-(M=n<0?-n:n))),t.hasOwnProperty(e="RANGE"))if((n=t[e])&&n.pop)_(n[0],-y,-1,e),_(n[1],1,y,e),R=n[0],j=n[1];else{if(_(n,-y,y,e),!n)throw Error(l+e+" cannot be zero: "+n);R=-(j=n<0?-n:n)}if(t.hasOwnProperty(e="CRYPTO")){if((n=t[e])!==!!n)throw Error(l+e+" not true or false: "+n);if(n){if("undefined"==typeof crypto||!crypto||!crypto.getRandomValues&&!crypto.randomBytes)throw U=!n,Error(l+"crypto unavailable");U=n}else U=n}if(t.hasOwnProperty(e="MODULO_MODE")&&(_(n=t[e],0,9,e),D=n),t.hasOwnProperty(e="POW_PRECISION")&&(_(n=t[e],0,y,e),q=n),t.hasOwnProperty(e="FORMAT")){if("object"!=typeof(n=t[e]))throw Error(l+e+" not an object: "+n);$=n}if(t.hasOwnProperty(e="ALPHABET")){if("string"!=typeof(n=t[e])||/^.?$|[+\-.\s]|(.).*\1/.test(n))throw Error(l+e+" invalid: "+n);L="0123456789"==n.slice(0,10),H=n}}return{DECIMAL_PLACES:C,ROUNDING_MODE:I,EXPONENTIAL_AT:[P,M],RANGE:[R,j],CRYPTO:U,MODULO_MODE:D,POW_PRECISION:q,FORMAT:$,ALPHABET:H}},G.isBigNumber=function(t){if(!t||!0!==t._isBigNumber)return!1;if(!G.DEBUG)return!0;var e,n,r=t.c,o=t.e,i=t.s;t:if("[object Array]"=={}.toString.call(r)){if((1===i||-1===i)&&o>=-y&&o<=y&&o===u(o)){if(0===r[0]){if(0===o&&1===r.length)return!0;break t}if((e=(o+1)%f)<1&&(e+=f),String(r[0]).length==e){for(e=0;e<r.length;e++)if((n=r[e])<0||n>=p||n!==u(n))break t;if(0!==n)return!0}}}else if(null===r&&null===o&&(null===i||1===i||-1===i))return!0;throw Error(l+"Invalid BigNumber: "+t)},G.maximum=G.max=function(){return J(arguments,S.lt)},G.minimum=G.min=function(){return J(arguments,S.gt)},G.random=(i=9007199254740992,s=Math.random()*i&2097151?function(){return u(Math.random()*i)}:function(){return 8388608*(1073741824*Math.random()|0)+(8388608*Math.random()|0)},function(t){var e,n,r,o,i,a=0,h=[],p=new G(O);if(null==t?t=C:_(t,0,y),o=c(t/f),U)if(crypto.getRandomValues){for(e=crypto.getRandomValues(new Uint32Array(o*=2));a<o;)(i=131072*e[a]+(e[a+1]>>>11))>=9e15?(n=crypto.getRandomValues(new Uint32Array(2)),e[a]=n[0],e[a+1]=n[1]):(h.push(i%1e14),a+=2);a=o/2}else{if(!crypto.randomBytes)throw U=!1,Error(l+"crypto unavailable");for(e=crypto.randomBytes(o*=7);a<o;)(i=281474976710656*(31&e[a])+1099511627776*e[a+1]+4294967296*e[a+2]+16777216*e[a+3]+(e[a+4]<<16)+(e[a+5]<<8)+e[a+6])>=9e15?crypto.randomBytes(7).copy(e,a):(h.push(i%1e14),a+=7);a=o/7}if(!U)for(;a<o;)(i=s())<9e15&&(h[a++]=i%1e14);for(o=h[--a],t%=f,o&&t&&(i=g[f-t],h[a]=u(o/i)*i);0===h[a];h.pop(),a--);if(a<0)h=[r=0];else{for(r=-1;0===h[0];h.splice(0,1),r-=f);for(a=1,i=h[0];i>=10;i/=10,a++);a<f&&(r-=f-a)}return p.e=r,p.c=h,p}),G.sum=function(){for(var t=1,e=arguments,n=new G(e[0]);t<e.length;)n=n.plus(e[t++]);return n},r=function(){var t="0123456789";function e(t,e,n,r){for(var o,i,s=[0],a=0,c=t.length;a<c;){for(i=s.length;i--;s[i]*=e);for(s[0]+=r.indexOf(t.charAt(a++)),o=0;o<s.length;o++)s[o]>n-1&&(null==s[o+1]&&(s[o+1]=0),s[o+1]+=s[o]/n|0,s[o]%=n)}return s.reverse()}return function(r,o,i,s,a){var c,u,l,h,p,f,d,g,m=r.indexOf("."),y=C,w=I;for(m>=0&&(h=q,q=0,r=r.replace(".",""),f=(g=new G(o)).pow(r.length-m),q=h,g.c=e(x(v(f.c),f.e,"0"),10,i,t),g.e=g.c.length),l=h=(d=e(r,o,i,a?(c=H,t):(c=t,H))).length;0==d[--h];d.pop());if(!d[0])return c.charAt(0);if(m<0?--l:(f.c=d,f.e=l,f.s=s,d=(f=n(f,g,y,w,i)).c,p=f.r,l=f.e),m=d[u=l+y+1],h=i/2,p=p||u<0||null!=d[u+1],p=w<4?(null!=m||p)&&(0==w||w==(f.s<0?3:2)):m>h||m==h&&(4==w||p||6==w&&1&d[u-1]||w==(f.s<0?8:7)),u<1||!d[0])r=p?x(c.charAt(1),-y,c.charAt(0)):c.charAt(0);else{if(d.length=u,p)for(--i;++d[--u]>i;)d[u]=0,u||(++l,d=[1].concat(d));for(h=d.length;!d[--h];);for(m=0,r="";m<=h;r+=c.charAt(d[m++]));r=x(r,l,c.charAt(0))}return r}}(),n=function(){function t(t,e,n){var r,o,i,s,a=0,c=t.length,u=e%m,l=e/m|0;for(t=t.slice();c--;)a=((o=u*(i=t[c]%m)+(r=l*i+(s=t[c]/m|0)*u)%m*m+a)/n|0)+(r/m|0)+l*s,t[c]=o%n;return a&&(t=[a].concat(t)),t}function e(t,e,n,r){var o,i;if(n!=r)i=n>r?1:-1;else for(o=i=0;o<n;o++)if(t[o]!=e[o]){i=t[o]>e[o]?1:-1;break}return i}function n(t,e,n,r){for(var o=0;n--;)t[n]-=o,o=t[n]<e[n]?1:0,t[n]=o*r+t[n]-e[n];for(;!t[0]&&t.length>1;t.splice(0,1));}return function(r,o,i,s,a){var c,l,h,d,g,m,y,v,b,_,F,N,x,k,A,T,B,E=r.s==o.s?1:-1,S=r.c,O=o.c;if(!(S&&S[0]&&O&&O[0]))return new G(r.s&&o.s&&(S?!O||S[0]!=O[0]:O)?S&&0==S[0]||!O?0*E:E/0:NaN);for(b=(v=new G(E)).c=[],E=i+(l=r.e-o.e)+1,a||(a=p,l=w(r.e/f)-w(o.e/f),E=E/f|0),h=0;O[h]==(S[h]||0);h++);if(O[h]>(S[h]||0)&&l--,E<0)b.push(1),d=!0;else{for(k=S.length,T=O.length,h=0,E+=2,(g=u(a/(O[0]+1)))>1&&(O=t(O,g,a),S=t(S,g,a),T=O.length,k=S.length),x=T,F=(_=S.slice(0,T)).length;F<T;_[F++]=0);B=O.slice(),B=[0].concat(B),A=O[0],O[1]>=a/2&&A++;do{if(g=0,(c=e(O,_,T,F))<0){if(N=_[0],T!=F&&(N=N*a+(_[1]||0)),(g=u(N/A))>1)for(g>=a&&(g=a-1),y=(m=t(O,g,a)).length,F=_.length;1==e(m,_,y,F);)g--,n(m,T<y?B:O,y,a),y=m.length,c=1;else 0==g&&(c=g=1),y=(m=O.slice()).length;if(y<F&&(m=[0].concat(m)),n(_,m,F,a),F=_.length,-1==c)for(;e(O,_,T,F)<1;)g++,n(_,T<F?B:O,F,a),F=_.length}else 0===c&&(g++,_=[0]);b[h++]=g,_[0]?_[F++]=S[x]||0:(_=[S[x]],F=1)}while((x++<k||null!=_[0])&&E--);d=null!=_[0],b[0]||b.splice(0,1)}if(a==p){for(h=1,E=b[0];E>=10;E/=10,h++);V(v,i+(v.e=h+l*f-1)+1,s,d)}else v.e=l,v.r=+d;return v}}(),k=/^(-?)0([xbo])(?=\w[\w.]*$)/i,A=/^([^.]+)\.$/,T=/^\.([^.]+)$/,B=/^-?(Infinity|NaN)$/,E=/^\s*\+(?=[\w.])|^\s+|\s+$/g,o=function(t,e,n,r){var o,i=n?e:e.replace(E,"");if(B.test(i))t.s=isNaN(i)?null:i<0?-1:1;else{if(!n&&(i=i.replace(k,(function(t,e,n){return o="x"==(n=n.toLowerCase())?16:"b"==n?2:8,r&&r!=o?t:e})),r&&(o=r,i=i.replace(A,"$1").replace(T,"0.$1")),e!=i))return new G(i,o);if(G.DEBUG)throw Error(l+"Not a"+(r?" base "+r:"")+" number: "+e);t.s=null}t.c=t.e=null},S.absoluteValue=S.abs=function(){var t=new G(this);return t.s<0&&(t.s=1),t},S.comparedTo=function(t,e){return b(this,new G(t,e))},S.decimalPlaces=S.dp=function(t,e){var n,r,o,i=this;if(null!=t)return _(t,0,y),null==e?e=I:_(e,0,8),V(new G(i),t+i.e+1,e);if(!(n=i.c))return null;if(r=((o=n.length-1)-w(this.e/f))*f,o=n[o])for(;o%10==0;o/=10,r--);return r<0&&(r=0),r},S.dividedBy=S.div=function(t,e){return n(this,new G(t,e),C,I)},S.dividedToIntegerBy=S.idiv=function(t,e){return n(this,new G(t,e),0,1)},S.exponentiatedBy=S.pow=function(t,e){var n,r,o,i,s,a,h,p,d=this;if((t=new G(t)).c&&!t.isInteger())throw Error(l+"Exponent not an integer: "+K(t));if(null!=e&&(e=new G(e)),s=t.e>14,!d.c||!d.c[0]||1==d.c[0]&&!d.e&&1==d.c.length||!t.c||!t.c[0])return p=new G(Math.pow(+K(d),s?t.s*(2-F(t)):+K(t))),e?p.mod(e):p;if(a=t.s<0,e){if(e.c?!e.c[0]:!e.s)return new G(NaN);(r=!a&&d.isInteger()&&e.isInteger())&&(d=d.mod(e))}else{if(t.e>9&&(d.e>0||d.e<-1||(0==d.e?d.c[0]>1||s&&d.c[1]>=24e7:d.c[0]<8e13||s&&d.c[0]<=9999975e7)))return i=d.s<0&&F(t)?-0:0,d.e>-1&&(i=1/i),new G(a?1/i:i);q&&(i=c(q/f+2))}for(s?(n=new G(.5),a&&(t.s=1),h=F(t)):h=(o=Math.abs(+K(t)))%2,p=new G(O);;){if(h){if(!(p=p.times(d)).c)break;i?p.c.length>i&&(p.c.length=i):r&&(p=p.mod(e))}if(o){if(0===(o=u(o/2)))break;h=o%2}else if(V(t=t.times(n),t.e+1,1),t.e>14)h=F(t);else{if(0===(o=+K(t)))break;h=o%2}d=d.times(d),i?d.c&&d.c.length>i&&(d.c.length=i):r&&(d=d.mod(e))}return r?p:(a&&(p=O.div(p)),e?p.mod(e):i?V(p,q,I,undefined):p)},S.integerValue=function(t){var e=new G(this);return null==t?t=I:_(t,0,8),V(e,e.e+1,t)},S.isEqualTo=S.eq=function(t,e){return 0===b(this,new G(t,e))},S.isFinite=function(){return!!this.c},S.isGreaterThan=S.gt=function(t,e){return b(this,new G(t,e))>0},S.isGreaterThanOrEqualTo=S.gte=function(t,e){return 1===(e=b(this,new G(t,e)))||0===e},S.isInteger=function(){return!!this.c&&w(this.e/f)>this.c.length-2},S.isLessThan=S.lt=function(t,e){return b(this,new G(t,e))<0},S.isLessThanOrEqualTo=S.lte=function(t,e){return-1===(e=b(this,new G(t,e)))||0===e},S.isNaN=function(){return!this.s},S.isNegative=function(){return this.s<0},S.isPositive=function(){return this.s>0},S.isZero=function(){return!!this.c&&0==this.c[0]},S.minus=function(t,e){var n,r,o,i,s=this,a=s.s;if(e=(t=new G(t,e)).s,!a||!e)return new G(NaN);if(a!=e)return t.s=-e,s.plus(t);var c=s.e/f,u=t.e/f,l=s.c,h=t.c;if(!c||!u){if(!l||!h)return l?(t.s=-e,t):new G(h?s:NaN);if(!l[0]||!h[0])return h[0]?(t.s=-e,t):new G(l[0]?s:3==I?-0:0)}if(c=w(c),u=w(u),l=l.slice(),a=c-u){for((i=a<0)?(a=-a,o=l):(u=c,o=h),o.reverse(),e=a;e--;o.push(0));o.reverse()}else for(r=(i=(a=l.length)<(e=h.length))?a:e,a=e=0;e<r;e++)if(l[e]!=h[e]){i=l[e]<h[e];break}if(i&&(o=l,l=h,h=o,t.s=-t.s),(e=(r=h.length)-(n=l.length))>0)for(;e--;l[n++]=0);for(e=p-1;r>a;){if(l[--r]<h[r]){for(n=r;n&&!l[--n];l[n]=e);--l[n],l[r]+=p}l[r]-=h[r]}for(;0==l[0];l.splice(0,1),--u);return l[0]?W(t,l,u):(t.s=3==I?-1:1,t.c=[t.e=0],t)},S.modulo=S.mod=function(t,e){var r,o,i=this;return t=new G(t,e),!i.c||!t.s||t.c&&!t.c[0]?new G(NaN):!t.c||i.c&&!i.c[0]?new G(i):(9==D?(o=t.s,t.s=1,r=n(i,t,0,3),t.s=o,r.s*=o):r=n(i,t,0,D),(t=i.minus(r.times(t))).c[0]||1!=D||(t.s=i.s),t)},S.multipliedBy=S.times=function(t,e){var n,r,o,i,s,a,c,u,l,h,d,g,y,v,b,_=this,F=_.c,N=(t=new G(t,e)).c;if(!(F&&N&&F[0]&&N[0]))return!_.s||!t.s||F&&!F[0]&&!N||N&&!N[0]&&!F?t.c=t.e=t.s=null:(t.s*=_.s,F&&N?(t.c=[0],t.e=0):t.c=t.e=null),t;for(r=w(_.e/f)+w(t.e/f),t.s*=_.s,(c=F.length)<(h=N.length)&&(y=F,F=N,N=y,o=c,c=h,h=o),o=c+h,y=[];o--;y.push(0));for(v=p,b=m,o=h;--o>=0;){for(n=0,d=N[o]%b,g=N[o]/b|0,i=o+(s=c);i>o;)n=((u=d*(u=F[--s]%b)+(a=g*u+(l=F[s]/b|0)*d)%b*b+y[i]+n)/v|0)+(a/b|0)+g*l,y[i--]=u%v;y[i]=n}return n?++r:y.splice(0,1),W(t,y,r)},S.negated=function(){var t=new G(this);return t.s=-t.s||null,t},S.plus=function(t,e){var n,r=this,o=r.s;if(e=(t=new G(t,e)).s,!o||!e)return new G(NaN);if(o!=e)return t.s=-e,r.minus(t);var i=r.e/f,s=t.e/f,a=r.c,c=t.c;if(!i||!s){if(!a||!c)return new G(o/0);if(!a[0]||!c[0])return c[0]?t:new G(a[0]?r:0*o)}if(i=w(i),s=w(s),a=a.slice(),o=i-s){for(o>0?(s=i,n=c):(o=-o,n=a),n.reverse();o--;n.push(0));n.reverse()}for((o=a.length)-(e=c.length)<0&&(n=c,c=a,a=n,e=o),o=0;e;)o=(a[--e]=a[e]+c[e]+o)/p|0,a[e]=p===a[e]?0:a[e]%p;return o&&(a=[o].concat(a),++s),W(t,a,s)},S.precision=S.sd=function(t,e){var n,r,o,i=this;if(null!=t&&t!==!!t)return _(t,1,y),null==e?e=I:_(e,0,8),V(new G(i),t,e);if(!(n=i.c))return null;if(r=(o=n.length-1)*f+1,o=n[o]){for(;o%10==0;o/=10,r--);for(o=n[0];o>=10;o/=10,r++);}return t&&i.e+1>r&&(r=i.e+1),r},S.shiftedBy=function(t){return _(t,-9007199254740991,d),this.times("1e"+t)},S.squareRoot=S.sqrt=function(){var t,e,r,o,i,s=this,a=s.c,c=s.s,u=s.e,l=C+4,h=new G("0.5");if(1!==c||!a||!a[0])return new G(!c||c<0&&(!a||a[0])?NaN:a?s:1/0);if(0==(c=Math.sqrt(+K(s)))||c==1/0?(((e=v(a)).length+u)%2==0&&(e+="0"),c=Math.sqrt(+e),u=w((u+1)/2)-(u<0||u%2),r=new G(e=c==1/0?"5e"+u:(e=c.toExponential()).slice(0,e.indexOf("e")+1)+u)):r=new G(c+""),r.c[0])for((c=(u=r.e)+l)<3&&(c=0);;)if(i=r,r=h.times(i.plus(n(s,i,l,1))),v(i.c).slice(0,c)===(e=v(r.c)).slice(0,c)){if(r.e<u&&--c,"9999"!=(e=e.slice(c-3,c+1))&&(o||"4999"!=e)){+e&&(+e.slice(1)||"5"!=e.charAt(0))||(V(r,r.e+C+2,1),t=!r.times(r).eq(s));break}if(!o&&(V(i,i.e+C+2,0),i.times(i).eq(s))){r=i;break}l+=4,c+=4,o=1}return V(r,r.e+C+1,I,t)},S.toExponential=function(t,e){return null!=t&&(_(t,0,y),t++),z(this,t,e,1)},S.toFixed=function(t,e){return null!=t&&(_(t,0,y),t=t+this.e+1),z(this,t,e)},S.toFormat=function(t,e,n){var r,o=this;if(null==n)null!=t&&e&&"object"==typeof e?(n=e,e=null):t&&"object"==typeof t?(n=t,t=e=null):n=$;else if("object"!=typeof n)throw Error(l+"Argument not an object: "+n);if(r=o.toFixed(t,e),o.c){var i,s=r.split("."),a=+n.groupSize,c=+n.secondaryGroupSize,u=n.groupSeparator||"",h=s[0],p=s[1],f=o.s<0,d=f?h.slice(1):h,g=d.length;if(c&&(i=a,a=c,c=i,g-=i),a>0&&g>0){for(i=g%a||a,h=d.substr(0,i);i<g;i+=a)h+=u+d.substr(i,a);c>0&&(h+=u+d.slice(i)),f&&(h="-"+h)}r=p?h+(n.decimalSeparator||"")+((c=+n.fractionGroupSize)?p.replace(new RegExp("\\d{"+c+"}\\B","g"),"$&"+(n.fractionGroupSeparator||"")):p):h}return(n.prefix||"")+r+(n.suffix||"")},S.toFraction=function(t){var e,r,o,i,s,a,c,u,h,p,d,m,y=this,w=y.c;if(null!=t&&(!(c=new G(t)).isInteger()&&(c.c||1!==c.s)||c.lt(O)))throw Error(l+"Argument "+(c.isInteger()?"out of range: ":"not an integer: ")+K(c));if(!w)return new G(y);for(e=new G(O),h=r=new G(O),o=u=new G(O),m=v(w),s=e.e=m.length-y.e-1,e.c[0]=g[(a=s%f)<0?f+a:a],t=!t||c.comparedTo(e)>0?s>0?e:h:c,a=j,j=1/0,c=new G(m),u.c[0]=0;p=n(c,e,0,1),1!=(i=r.plus(p.times(o))).comparedTo(t);)r=o,o=i,h=u.plus(p.times(i=h)),u=i,e=c.minus(p.times(i=e)),c=i;return i=n(t.minus(r),o,0,1),u=u.plus(i.times(h)),r=r.plus(i.times(o)),u.s=h.s=y.s,d=n(h,o,s*=2,I).minus(y).abs().comparedTo(n(u,r,s,I).minus(y).abs())<1?[h,o]:[u,r],j=a,d},S.toNumber=function(){return+K(this)},S.toPrecision=function(t,e){return null!=t&&_(t,1,y),z(this,t,e,2)},S.toString=function(t){var e,n=this,o=n.s,i=n.e;return null===i?o?(e="Infinity",o<0&&(e="-"+e)):e="NaN":(null==t?e=i<=P||i>=M?N(v(n.c),i):x(v(n.c),i,"0"):10===t&&L?e=x(v((n=V(new G(n),C+i+1,I)).c),n.e,"0"):(_(t,2,H.length,"Base"),e=r(x(v(n.c),i,"0"),10,t,o,!0)),o<0&&n.c[0]&&(e="-"+e)),e},S.valueOf=S.toJSON=function(){return K(this)},S._isBigNumber=!0,S[Symbol.toStringTag]="BigNumber",S[Symbol.for("nodejs.util.inspect.custom")]=S.valueOf,null!=e&&G.set(e),G}();const A={ROUNDING_MODE:k.ROUND_DOWN};function T(t){return(new TextEncoder).encode(t)}function B(t){return"string"==typeof t?B(C(t)):(new TextDecoder).decode(t)}k.config(A);const E="UNKNOWN_ERROR",S="INVALID_ARGUMENT";function O(t,e=E,n={}){const r=[];Object.keys(n).forEach((t=>{try{r.push(t+"="+JSON.stringify(n[t]))}catch(e){r.push(t+"="+JSON.stringify(n[t].toString()))}}));const o=t;r.length&&(t+=" ("+r.join(", ")+")");const i=new Error(t);return i.reason=o,i.code=e,Object.keys(n).forEach((function(t){i[t]=n[t]})),i}function C(t){if("string"!=typeof t)throw new Error("hexToBytes only accept strings, got: "+typeof t);if("0x"===t.substr(0,2))return C(t.substr(2));const e=new Uint8Array(Math.ceil(t.length/2));let n=0;for(let r=0;r<t.length;r+=2){const o=parseInt(t.substr(r,2),16);if(isNaN(o))throw new Error("Cannot read hex string:"+JSON.stringify(t));e[n]=o,n++}return e}function I(t){return Array.from(t).map((t=>t.toString(16).padStart(2,"0"))).join("")}function P(t,e){if("string"==typeof t){if(e&&"hex"===e.encoding&&"string"==typeof t){let e=t;e.length>2&&"0x"===e.substr(0,2)&&(e=e.substr(2));const n=C(e);return s.keccak256(n)}return s.keccak256(T(t))}return s.keccak256(t)}const M={noether:"0",wei:"1",kwei:"1000",Kwei:"1000",babbage:"1000",femtoether:"1000",mwei:"1000000",Mwei:"1000000",lovelace:"1000000",picoether:"1000000",gwei:"1000000000",Gwei:"1000000000",shannon:"1000000000",nanoether:"1000000000",nano:"1000000000",szabo:"1000000000000",microether:"1000000000000",micro:"1000000000000",finney:"1000000000000000",milliether:"1000000000000000",milli:"1000000000000000",ether:"1000000000000000000",kether:"1000000000000000000000",grand:"1000000000000000000000",mether:"1000000000000000000000000",gether:"1000000000000000000000000000",tether:"1000000000000000000000000000000"};function R(t,e,n){return new Array(e-t.length+1).join(n||"0")+t}function j(t){let e="",n=0;const r=t.length;for("0x"===t.substring(0,2)&&(n=2);n<r;n+=2){const r=parseInt(t.substr(n,2),16);e+=String.fromCharCode(r)}return e}function U(t){return pt(t)&&t.name&&-1!==t.name.indexOf("(")?t.name:t.name+"("+q(!1,t.inputs||[]).join(",")+")"}function D(...t){const e=t.reduce(((t,e)=>t+e.length),0),n=new Uint8Array(e);let r=0;for(const e of t)n.set(e,r),r+=e.length;return n}function q(t,e){const n=[];return e.forEach((function(e){if("object"==typeof e.components){if("tuple"!==e.type.substring(0,5))throw new Error("components found but type is not tuple; report on GitHub");let r="";const o=e.type.indexOf("[");o>=0&&(r=e.type.substring(o));const i=q(t,e.components);dt(i)&&t?n.push("tuple("+i.join(",")+")"+r):t?n.push("("+i+")"):n.push("("+i.join(",")+")"+r)}else n.push(e.type)})),n}function $(t){const e=t.indexOf("("),n=t.indexOf(")");return-1!==e&&-1!==n?t.substr(0,e):t}function H(t){const e=t.indexOf("("),n=t.indexOf(")");return-1!==e&&-1!==n?t.substr(e+1,n-e-1).replace(" ",""):""}function L(t){return null==t?t:X(t).toNumber()}function G(t){return X(t).toNumber()}function z(t){return lt(t)?t.toString(10):""+t}function J(t){return"string"==typeof t&&!t.startsWith("0x")&&/^[A-Za-z0-9]+$/.test(t)?"0x"+t:Z(t)}function W(t){if("string"==typeof t)return t.startsWith("0x")&&/^[A-Za-z0-9]+$/.test(t)?Z(t):"0x"+I(T(t));if(t instanceof Uint8Array)return"0x"+I(t);throw new Error(`toStringData: Error trying to convert ${t} (${typeof t}) to a hex string.`)}function V(t){return"boolean"==typeof t?t:0!==X(t).toNumber()}function K(t){const e=X(t),n=e.toString(16);return e.isLessThan(0)?"-0x"+n.substr(1):"0x"+n}function Z(t){if(ft(t))return K(+t);if(lt(t))return K(t);if(ht(t)){const e=t;if(0===e.indexOf("-0x"))return K(e);if(0===e.indexOf("0x"))return e;if(!isFinite(e))return I(T(e))}if(t instanceof Uint8Array)return"0x"+I(t);if(dt(t)||pt(t))throw new Error("toHex can only be called with scalar values, not objects or arrays");return K(t)}function Y(t){const e=t?t.toLowerCase():"ether",n=M[e];if(void 0===n)throw new Error("This unit doesn't exists, please use the one of the following units"+JSON.stringify(M,null,2));return new k(n,10)}function X(t){let e=t||0;return lt(e)?e:("string"==typeof e&&(e=e.trim()),"string"!=typeof e||0!==e.indexOf("0x")&&0!==e.indexOf("-0x")?e instanceof Uint8Array?new k(I(e),16):new k(e,10):new k(e.replace("0x","").toLowerCase(),16))}function Q(t){return new k(new Array(t).fill("1").join(""),2)}function tt(t,e=256){const n=X(t).integerValue();if(n.isLessThan(0)){return Q(e).plus(n).plus(1)}return n}function et(t,e){return"1"===R(t.toString(2),e,"0")[0]}function nt(t){if("string"!=typeof t)throw O("invalid address",S,{arg:"address",value:t});if(t.trim().match(/^(0x)?[0-9a-fA-F]{40}$/))return"0x"!==t.trim().substring(0,2)&&(t="0x"+t),at(t);throw O("invalid address",S,{arg:"address",value:t})}function rt(t,e=256){if(et(t,e)){const n=Q(e);return t.minus(n).minus(1)}return t}function ot(t){return/^0x[0-9a-f]{40}$/i.test(t)}function it(t){return!!/^(0x)?[0-9a-f]{40}$/i.test(t)&&(!(!/^(0x)?[0-9a-f]{40}$/.test(t)&&!/^(0x)?[0-9A-F]{40}$/.test(t))||st(t))}function st(t){const e=t.replace("0x",""),n=P(e.toLowerCase());for(let t=0;t<40;t++)if(parseInt(n[t],16)>7&&e[t].toUpperCase()!==e[t]||parseInt(n[t],16)<=7&&e[t].toLowerCase()!==e[t])return!1;return!0}function at(t){if(void 0===t)return"";const e=t.toLowerCase().replace("0x",""),n=P(e);let r="0x";for(let t=0;t<e.length;t++)parseInt(n[t],16)>7?r+=e[t].toUpperCase():r+=e[t];return r}function ct(t){if(!Array.isArray(t))throw new Error(`Value was not an array: ${JSON.stringify(t)}`);return t}function ut(t){return ot(t)?t:/^[0-9a-f]{40}$/.test(t)?"0x"+t:"0x"+R(Z(t).substr(2),40)}function lt(t){return t instanceof k}function ht(t){return"string"==typeof t||t&&t.constructor&&"String"===t.constructor.name}function pt(t){return null!==t&&!Array.isArray(t)&&"object"==typeof t}function ft(t){return"boolean"==typeof t}function dt(t){return Array.isArray(t)}var gt,mt;function yt(e,n){if(!e)throw new Error("jsonrpc method should be specified!");if("string"!=typeof e)throw new Error(`jsonrpc must be a string, got ${typeof e}!`);return t.messageId++,{jsonrpc:"2.0",id:t.messageId,method:e,params:n||[]}}function wt(t){return Array.isArray(t)?t.every(e):e(t);function e(t){return!!t&&(void 0===t.error||null===t.error)&&"2.0"===t.jsonrpc&&null!==t.id&&"result"in t&&void 0!==t.result}}t.TransactionStatus=void 0,(gt=t.TransactionStatus||(t.TransactionStatus={})).pending="pending",gt.confirmed="confirmed",gt.failed="failed",t.TransactionType=void 0,(mt=t.TransactionType||(t.TransactionType={})).queued="queued",mt.dropped="dropped",mt.replaced="replaced",mt.pending="pending",mt.reverted="reverted",mt.confirmed="confirmed",t.messageId=0;function vt(t){return X(t)}function bt(t){return"latest"===t||"pending"===t||"earliest"===t}function _t(t){return void 0===t?"latest":Ft(t)}function Ft(t){return null==t?null:bt(t)?t:Z(t)}function Nt(t){return t.from&&(t.from=St(t.from)),t.to&&(t.to=St(t.to)),void 0!==t.gasPrice&&(t.gasPrice=K(t.gasPrice)),void 0!==t.gas&&(t.gas=K(t.gas)),void 0!==t.value&&(t.value=K(t.value)),void 0!==t.nonce&&(t.nonce=K(t.nonce)),t.data&&!t.data.startsWith("0x")&&/^[A-Za-z0-9]+$/.test(t.data)&&(t.data="0x"+t.data),t}function xt(t){if("string"!=typeof t)throw new Error("The provided input for transactionId is not a string, got: "+JSON.stringify(t));if(0!==t.indexOf("0x"))throw new Error("TransactionID must start with 0x, got: "+JSON.stringify(t));if(66!==t.length)throw new Error("TransactionID must be a 32 byte hex, got: "+JSON.stringify(t));return t}function kt(t){if("object"!=typeof t)throw new Error("Did not provide transaction options");if(!t.from)throw new Error('Missing "from" in transaction options');return t.from=St(t.from),t.to&&(t.to=St(t.to)),void 0!==t.gasPrice&&(t.gasPrice=K(t.gasPrice)),void 0!==t.gas&&(t.gas=K(t.gas)),void 0!==t.value&&(t.value=K(t.value)),void 0!==t.nonce&&(t.nonce=K(t.nonce)),t.data&&!t.data.startsWith("0x")&&/^[A-Za-z0-9]+$/.test(t.data)&&(t.data="0x"+t.data),t}function At(t){return t?(null!==t.blockNumber&&(t.blockNumber=G(t.blockNumber)),null!==t.transactionIndex&&(t.transactionIndex=G(t.transactionIndex)),t.nonce=G(t.nonce),t.gas=G(t.gas),t.gasPrice=X(t.gasPrice),t.value=X(t.value),t):null}function Tt(t){return t?(null!==t.blockNumber&&(t.blockNumber=G(t.blockNumber)),null!==t.transactionIndex&&(t.transactionIndex=G(t.transactionIndex)),t.cumulativeGasUsed=G(t.cumulativeGasUsed),t.gasUsed=G(t.gasUsed),t.logs&&dt(t.logs)&&(t.logs=t.logs.map((function(t){return Et(t)}))),t.status=G(t.status||""),t):null}function Bt(t){return t?(t.gasLimit=G(t.gasLimit),t.gasUsed=G(t.gasUsed),t.size=G(t.size),t.timestamp=G(t.timestamp),null!==t.number&&(t.number=G(t.number)),t.difficulty=X(t.difficulty),t.totalDifficulty=X(t.totalDifficulty),dt(t.transactions)&&t.transactions.forEach((function(e,n){ht(e)||(t.transactions[n]=At(e)||t.transactions[n])})),t):null}function Et(t){return t?(t.blockNumber&&(t.blockNumber=G(t.blockNumber)),t.transactionIndex&&(t.transactionIndex=G(t.transactionIndex)),t.logIndex&&(t.logIndex=G(t.logIndex)),t):t}function St(t){if(ot(t))return t;if(it(t))return"0x"+t;throw new Error(`Invalid address: ${JSON.stringify(t)}`)}function Ot(t){return t}function Ct(t){return t?(t.startingBlock=G(t.startingBlock),t.currentBlock=G(t.currentBlock),t.highestBlock=G(t.highestBlock),t.knownStates&&(t.knownStates=G(t.knownStates),t.pulledStates=G(t.pulledStates)),t):t}function It(t){if(null===t)throw O("cannot convert null value to array",S,{arg:"value",value:t});if(t instanceof Uint8Array)return new Uint8Array(t);if("string"==typeof t){const e=t.match(/^(0x)?[0-9a-fA-F]*$/);if(!e)throw O("invalid hexidecimal string",S,{arg:"value",value:t});if("0x"!==e[1])throw O("hex string must have 0x prefix",S,{arg:"value",value:t});(t=t.substring(2)).length%2&&(t="0"+t);const n=[];for(let e=0;e<t.length;e+=2)n.push(parseInt(t.substr(e,2),16));return new Uint8Array(n)}if(function(t){if(!t||parseInt(String(t.length))!==t.length||"string"==typeof t)return!1;for(let e=0;e<t.length;e++){const n=t[e];if(n<0||n>=256||parseInt(String(n))!==n)return!1}return!0}(t))return new Uint8Array(t);throw O("invalid arrayify value",void 0,{arg:"value",value:t,type:typeof t})}function Pt(t,e,n){Object.defineProperty(t,e,{enumerable:!0,value:n,writable:!1})}const Mt=new k(-1),Rt=new k(0),jt=new k(1),Ut=new k("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");function Dt(t){return function(t,e){function n(e){return new Error('unexpected character "'+t[e]+'" at position '+e+' in "'+t+'"')}const r={type:"",name:"",state:{allowType:!0}};let o=r;for(let r=0;r<t.length;r++){const i=t[r];switch(i){case"(":if(!o.state.allowParams)throw n(r);o.state.allowType=!1,o.type=qt(o.type),o.components=[{type:"",name:"",parent:o,state:{allowType:!0}}],o=o.components[0];break;case")":delete o.state,e&&"indexed"===o.name&&(o.indexed=!0,o.name=""),o.type=qt(o.type);const t=o;if(o=o.parent,!o)throw n(r);delete t.parent,o.state.allowParams=!1,o.state.allowName=!0,o.state.allowArray=!0;break;case",":delete o.state,e&&"indexed"===o.name&&(o.indexed=!0,o.name=""),o.type=qt(o.type);const s={type:"",name:"",parent:o.parent,state:{allowType:!0}};o.parent.components.push(s),delete o.parent,o=s;break;case" ":o.state.allowType&&""!==o.type&&(o.type=qt(o.type),delete o.state.allowType,o.state.allowName=!0,o.state.allowParams=!0),o.state.allowName&&""!==o.name&&(e&&"indexed"===o.name?(o.indexed=!0,o.name=""):o.state.allowName=!1);break;case"[":if(!o.state.allowArray)throw n(r);o.type+=i,o.state.allowArray=!1,o.state.allowName=!1,o.state.readArray=!0;break;case"]":if(!o.state.readArray)throw n(r);o.type+=i,o.state.readArray=!1,o.state.allowArray=!0,o.state.allowName=!0;break;default:if(o.state.allowType)o.type+=i,o.state.allowParams=!0,o.state.allowArray=!0;else if(o.state.allowName)o.name+=i,delete o.state.allowArray;else{if(!o.state.readArray)throw n(r);o.type+=i}}}if(o.parent)throw new Error("unexpected eof");delete r.state,e&&"indexed"===o.name&&(o.indexed=!0,o.name="");return r.type=qt(r.type),r}(t,!0)}function qt(t){return t.match(/^uint($|[^1-9])/)?t="uint256"+t.substring(4):t.match(/^int($|[^1-9])/)&&(t="int256"+t.substring(3)),t}const $t=new RegExp(/^bytes([0-9]*)$/),Ht=new RegExp(/^(u?int)([0-9]*)$/),Lt=new RegExp(/^(.*)\[([0-9]*)\]$/),Gt=function(t,e){const n=t.match(Ht);return n&&parseInt(n[2])<=48?e.toNumber():e};class zt{constructor(t,e,n,r="",o){this.coerceFunc=t,this.name=e,this.type=n,this.localName=r,this.dynamic=o}}class Jt extends zt{constructor(t){super(t.coerceFunc,t.name,t.type,void 0,t.dynamic),Pt(this,"coder",t)}encode(t){return this.coder.encode(t)}decode(t,e){return this.coder.decode(t,e)}}class Wt extends zt{constructor(t,e){super(t,"null","",e,!1)}encode(t){return It([])}decode(t,e){if(e>t.length)throw new Error("invalid null");return{consumed:0,value:this.coerceFunc("null",void 0)}}}function Vt(t,e){return new k(t.toString(2).substr(-e),2)}class Kt extends zt{constructor(t,e,n,r){const o=(n?"int":"uint")+8*e;super(t,o,o,r,!1),this.size=e,this.signed=n}encode(t){try{let e=X(t);if(this.signed){let t=Vt(Ut,8*this.size-1);if(e.gt(t))throw new Error("out-of-bounds");if(t=t.plus(jt).multipliedBy(Mt),e.lt(t))throw new Error("out-of-bounds")}else if(e.lt(Rt)||e.gt(Vt(Ut,8*this.size)))throw new Error("out-of-bounds");e=Vt(tt(e,8*this.size),8*this.size),this.signed&&(e=tt(rt(e,8*this.size),256));const n=R(tt(e).toString(16),64);if(-1!==n.indexOf("NaN"))throw O("invalid number value, NaN",S,{arg:this.localName,coderType:this.name,value:t,v:e,twosComplement:tt(e),twosComplement16:tt(e).toString(16),pad:R(tt(e).toString(16),64),size:this.size});return C(n)}catch(e){throw O("invalid number value",S,{arg:this.localName,coderType:this.name,value:t,message:e.toString()})}}decode(t,e){if(t.length<e+32)throw O("insufficient data for "+this.name+" type",S,{arg:this.localName,coderType:this.name,value:Z(t.slice(e,e+32))});const n=32-this.size;let r=new k(I(t.slice(e+n,e+32)),16);return r=this.signed?rt(r,8*this.size):Vt(r,8*this.size),{consumed:32,value:this.coerceFunc(this.name,r)}}}const Zt=new Kt((function(t,e){return e}),32,!1,"none");class Yt extends zt{constructor(t,e,n){const r="bytes"+e;super(t,r,r,n,!1),this.length=e}encode(t){const e=new Uint8Array(32);try{if("string"==typeof t&&t.length%2!=0)throw new Error("hex string cannot be odd-length");const n=It(t);if(n.length>this.length)throw new Error("incorrect data length");e.set(n)}catch(e){throw O("invalid "+this.name+" value. Use hex strings or Uint8Array",S,{arg:this.localName,coderType:this.name,value:e.value||t,details:e.message})}return e}decode(t,e){if(t.length<e+32)throw O("insufficient data for "+this.name+" type",S,{arg:this.localName,coderType:this.name,value:Z(t.slice(e,e+32))});return{consumed:32,value:this.coerceFunc(this.name,t.slice(e,e+this.length))}}}function Xt(t){const e=32*Math.ceil(t.length/32),n=new Uint8Array(e-t.length);return D(Zt.encode(t.length),t,n)}function Qt(t,e,n){if(t.length<e+32)throw O("insufficient data for dynamicBytes length",S,{arg:n,coderType:"dynamicBytes",value:Z(t.slice(e,e+32))});let r=Zt.decode(t,e).value;try{r=r.toNumber()}catch(t){throw t("dynamic bytes count too large",S,{arg:n,coderType:"dynamicBytes",value:r.toString()})}if(t.length<e+32+r)throw O("insufficient data for dynamicBytes type",S,{arg:n,coderType:"dynamicBytes",value:Z(t.slice(e,e+32+r))});return{consumed:32+32*Math.ceil(r/32),value:t.slice(e+32,e+32+r)}}function te(t){return 32*Math.ceil(t/32)}function ee(t,e){if(Array.isArray(e));else{if(!e||"object"!=typeof e)throw O("invalid tuple value",S,{coderType:"tuple",value:e});{const n=[];t.forEach((function(t){n.push(e[t.localName])})),e=n}}if(t.length!==e.length)throw O("types/value length mismatch",S,{coderType:"tuple",value:e});const n=[];t.forEach((function(t,r){n.push({dynamic:t.dynamic,value:t.encode(e[r])})}));let r=0,o=0;n.forEach((function(t){t.dynamic?(r+=32,o+=te(t.value.length)):r+=te(t.value.length)}));let i=0,s=r;const a=new Uint8Array(r+o);return n.forEach((function(t){t.dynamic?(a.set(Zt.encode(s),i),i+=32,a.set(t.value,s),s+=te(t.value.length)):(a.set(t.value,i),i+=te(t.value.length))})),a}class ne extends Array{}class re extends zt{constructor(t,e,n,r){super(t,"array",e.type+"["+(n>=0?n:"")+"]",r,-1===n||e.dynamic),this.coder=e,this.length=n}encode(t){if(!Array.isArray(t))throw O("expected array value",S,{arg:this.localName,coderType:"array",value:t});let e=this.length,n=new Uint8Array(0);-1===e&&(e=t.length,n=Zt.encode(e)),function(t,e,n){if(n||(n=""),t<e)throw O("missing argument"+n,"MISSING_ARGUMENT",{count:t,expectedCount:e});if(t>e)throw O("too many arguments"+n,"UNEXPECTED_ARGUMENT",{count:t,expectedCount:e})}(e,t.length,"in coder array"+(this.localName?" "+this.localName:""));const r=[];for(let e=0;e<t.length;e++)r.push(this.coder);return D(n,ee(r,t))}decode(t,e){let n=0,r=this.length;if(-1===r){let o;try{o=Zt.decode(t,e)}catch(t){throw O("insufficient data for dynamic array length",S,{arg:this.localName,coderType:"array",value:t.value})}try{r=o.value.toNumber()}catch(t){throw O("array count too large",S,{arg:this.localName,coderType:"array",value:o.value.toString()})}n+=o.consumed,e+=o.consumed}const o=[];for(let t=0;t<r;t++)o.push(new Jt(this.coder));const i=function(t,e,n){const r=n;let o=0;const i=[];return t.forEach((function(t){let s;if(t.dynamic){const o=Zt.decode(e,n);s=t.decode(e,r+o.value.toNumber()),s.consumed=o.consumed}else s=t.decode(e,n);void 0!==s.value&&i.push(s.value),n+=s.consumed,o+=s.consumed})),{value:i,consumed:o}}(o,t,e);return i.consumed+=n,i.value=this.coerceFunc(this.type,i.value),i}}class oe extends zt{constructor(t,e,n){let r=!1;const o=[];e.forEach((function(t){t.dynamic&&(r=!0),o.push(t.type)}));super(t,"tuple","tuple("+o.join(",")+")",n,r),this.coders=e}encode(t){return ee(this.coders,t)}decode(t,e){const n=function(t,e,n){const r=n;let o=0;const i=new ne;return t.forEach((function(t){let s;if(t.dynamic){const o=Zt.decode(e,n);s=t.decode(e,r+o.value.toNumber()),s.consumed=o.consumed}else s=t.decode(e,n);void 0!==s.value&&i.push(s.value),n+=s.consumed,o+=s.consumed})),t.forEach((function(t,e){let n=t.localName;n&&("length"===n&&(n="_length"),null!==i[n]&&void 0!==i[n]||(i[n]=i[e]))})),{value:i,consumed:o}}(this.coders,t,e);return n.value=this.coerceFunc(this.type,n.value),n}}const ie={address:class extends zt{constructor(t,e){super(t,"address","address",e,!1)}encode(t){const e=new Uint8Array(32),n=t.trim();if(!it(n))throw O("invalid address format",S,{arg:this.localName,coderType:"address",value:t});try{e.set(C(St(n)),12)}catch(e){throw O(`invalid address (${e.message})`,S,{arg:this.localName,coderType:"address",value:t})}return e}decode(t,e){if(t.length<e+32)throw O("insufficuent data for address type",S,{arg:this.localName,coderType:"address",value:Z(t.slice(e,e+32)),missingBytes:e+32-t.length});return{consumed:32,value:this.coerceFunc("address",nt(Z(t.slice(e+12,e+32))))}}},bool:class extends zt{constructor(t,e){super(t,"bool","bool",e,!1)}encode(t){return Zt.encode(t?1:0)}decode(t,e){try{const n=Zt.decode(t,e);return{consumed:n.consumed,value:this.coerceFunc("bool",!n.value.isZero())}}catch(t){if("insufficient data for uint256 type"===t.reason)throw O("insufficient data for boolean type",S,{arg:this.localName,coderType:"boolean",value:t.value});throw t}}},string:class extends zt{constructor(t,e){super(t,"string","string",e,!0)}encode(t){if("string"!=typeof t)throw O("invalid string value",S,{arg:this.localName,coderType:"string",value:t});return Xt(T(t))}decode(t,e){const n=Qt(t,e,this.localName);return n.value=this.coerceFunc("string",B(n.value)),n}},bytes:class extends zt{constructor(t,e){super(t,"bytes","bytes",e,!0)}encode(t){try{return Xt(It(t))}catch(t){throw t("invalid bytes value",S,{arg:this.localName,coderType:"bytes",value:t.value})}}decode(t,e){const n=Qt(t,e,this.localName);return n.value=this.coerceFunc("bytes",n.value),n}},function:class extends Yt{constructor(t,e){super(t,24,e)}}};function se(t,e){const n=ie[e.type];if(n)return new n(t,e.name);let r=e.type.match(Ht);if(r){const n=parseInt(r[2]||"256");if(0===n||n>256||n%8!=0)throw O("invalid "+r[1]+" bit length",S,{arg:"param",value:e});return new Kt(t,n/8,"int"===r[1],e.name)}if(r=e.type.match($t),r){const n=parseInt(r[1]);if(0===n||n>32)throw O("invalid bytes length",S,{arg:"param",value:e});return new Yt(t,n,e.name)}if(r=e.type.match(Lt),r){const n=Object.assign({},e),o=parseInt(r[2]||"-1");return n.type=r[1],new re(t,se(t,n),o,e.name)}if("tuple"===e.type.substring(0,5))return function(t,e,n){e||(e=[]);const r=e.map((e=>se(t,e)));r