@snapshot-labs/snapshot.js 0.12.62 → 0.12.63

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.
@@ -21,7 +21,7 @@
21
21
  * @copyright Chen, Yi-Cyuan 2015-2018
22
22
  * @license MIT
23
23
  */
24
- var Kt=a((function(t){!function(){var e="input is invalid type",r="object"==typeof window,n=r?window:{};n.JS_SHA3_NO_WINDOW&&(r=!1);var o=!r&&"object"==typeof self;!n.JS_SHA3_NO_NODE_JS&&"object"==typeof process&&process.versions&&process.versions.node?n=i:o&&(n=self);var a=!n.JS_SHA3_NO_COMMON_JS&&t.exports,s=!n.JS_SHA3_NO_ARRAY_BUFFER&&"undefined"!=typeof ArrayBuffer,h="0123456789abcdef".split(""),u=[4,1024,262144,67108864],l=[0,8,16,24],c=[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],d=[224,256,384,512],f=[128,256],m=["hex","buffer","arrayBuffer","array","digest"],p={128:168,256:136};!n.JS_SHA3_NO_NODE_JS&&Array.isArray||(Array.isArray=function(t){return"[object Array]"===Object.prototype.toString.call(t)}),!s||!n.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,r){return function(i){return new T(t,e,t).update(i)[r]()}},y=function(t,e,r){return function(i,n){return new T(t,e,n).update(i)[r]()}},w=function(t,e,r){return function(e,i,n,o){return _["cshake"+t].update(e,i,n,o)[r]()}},v=function(t,e,r){return function(e,i,n,o){return _["kmac"+t].update(e,i,n,o)[r]()}},b=function(t,e,r,i){for(var n=0;n<m.length;++n){var o=m[n];t[o]=e(r,i,o)}return t},k=function(t,e){var r=g(t,e,"hex");return r.create=function(){return new T(t,e,t)},r.update=function(t){return r.create().update(t)},b(r,g,t,e)},M=[{name:"keccak",padding:[1,256,65536,16777216],bits:d,createMethod:k},{name:"sha3",padding:[6,1536,393216,100663296],bits:d,createMethod:k},{name:"shake",padding:[31,7936,2031616,520093696],bits:f,createMethod:function(t,e){var r=y(t,e,"hex");return r.create=function(r){return new T(t,e,r)},r.update=function(t,e){return r.create(e).update(t)},b(r,y,t,e)}},{name:"cshake",padding:u,bits:f,createMethod:function(t,e){var r=p[t],i=w(t,0,"hex");return i.create=function(i,n,o){return n||o?new T(t,e,i).bytepad([n,o],r):_["shake"+t].create(i)},i.update=function(t,e,r,n){return i.create(e,r,n).update(t)},b(i,w,t,e)}},{name:"kmac",padding:u,bits:f,createMethod:function(t,e){var r=p[t],i=v(t,0,"hex");return i.create=function(i,n,o){return new C(t,e,n).bytepad(["KMAC",o],r).bytepad([i],r)},i.update=function(t,e,r,n){return i.create(t,r,n).update(e)},b(i,v,t,e)}}],_={},E=[],A=0;A<M.length;++A)for(var j=M[A],x=j.bits,S=0;S<x.length;++S){var N=j.name+"_"+x[S];if(E.push(N),_[N]=j.createMethod(x[S],j.padding),"sha3"!==j.name){var I=j.name+x[S];E.push(I),_[I]=_[N]}}function T(t,e,r){this.blocks=[],this.s=[],this.padding=e,this.outputBits=r,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=r>>5,this.extraBytes=(31&r)>>3;for(var i=0;i<50;++i)this.s[i]=0}function C(t,e,r){T.call(this,t,e,r)}T.prototype.update=function(t){if(this.finalized)throw new Error("finalize already called");var r,i=typeof t;if("string"!==i){if("object"!==i)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);r=!0}for(var n,o,a=this.blocks,h=this.byteCount,u=t.length,c=this.blockCount,d=0,f=this.s;d<u;){if(this.reset)for(this.reset=!1,a[0]=this.block,n=1;n<c+1;++n)a[n]=0;if(r)for(n=this.start;d<u&&n<h;++d)a[n>>2]|=t[d]<<l[3&n++];else for(n=this.start;d<u&&n<h;++d)(o=t.charCodeAt(d))<128?a[n>>2]|=o<<l[3&n++]:o<2048?(a[n>>2]|=(192|o>>6)<<l[3&n++],a[n>>2]|=(128|63&o)<<l[3&n++]):o<55296||o>=57344?(a[n>>2]|=(224|o>>12)<<l[3&n++],a[n>>2]|=(128|o>>6&63)<<l[3&n++],a[n>>2]|=(128|63&o)<<l[3&n++]):(o=65536+((1023&o)<<10|1023&t.charCodeAt(++d)),a[n>>2]|=(240|o>>18)<<l[3&n++],a[n>>2]|=(128|o>>12&63)<<l[3&n++],a[n>>2]|=(128|o>>6&63)<<l[3&n++],a[n>>2]|=(128|63&o)<<l[3&n++]);if(this.lastByteIndex=n,n>=h){for(this.start=n-h,this.block=a[c],n=0;n<c;++n)f[n]^=a[n];z(f),this.reset=!0}else this.start=n}return this},T.prototype.encode=function(t,e){var r=255&t,i=1,n=[r];for(r=255&(t>>=8);r>0;)n.unshift(r),r=255&(t>>=8),++i;return e?n.push(i):n.unshift(i),this.update(n),n.length},T.prototype.encodeString=function(t){var r,i=typeof t;if("string"!==i){if("object"!==i)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);r=!0}var n=0,o=t.length;if(r)n=o;else for(var a=0;a<t.length;++a){var h=t.charCodeAt(a);h<128?n+=1:h<2048?n+=2:h<55296||h>=57344?n+=3:(h=65536+((1023&h)<<10|1023&t.charCodeAt(++a)),n+=4)}return n+=this.encode(8*n),this.update(t),n},T.prototype.bytepad=function(t,e){for(var r=this.encode(e),i=0;i<t.length;++i)r+=this.encodeString(t[i]);var n=e-r%e,o=[];return o.length=n,this.update(o),this},T.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var t=this.blocks,e=this.lastByteIndex,r=this.blockCount,i=this.s;if(t[e>>2]|=this.padding[3&e],this.lastByteIndex===this.byteCount)for(t[0]=t[r],e=1;e<r+1;++e)t[e]=0;for(t[r-1]|=2147483648,e=0;e<r;++e)i[e]^=t[e];z(i)}},T.prototype.toString=T.prototype.hex=function(){this.finalize();for(var t,e=this.blockCount,r=this.s,i=this.outputBlocks,n=this.extraBytes,o=0,a=0,s="";a<i;){for(o=0;o<e&&a<i;++o,++a)t=r[o],s+=h[t>>4&15]+h[15&t]+h[t>>12&15]+h[t>>8&15]+h[t>>20&15]+h[t>>16&15]+h[t>>28&15]+h[t>>24&15];a%e==0&&(z(r),o=0)}return n&&(t=r[o],s+=h[t>>4&15]+h[15&t],n>1&&(s+=h[t>>12&15]+h[t>>8&15]),n>2&&(s+=h[t>>20&15]+h[t>>16&15])),s},T.prototype.arrayBuffer=function(){this.finalize();var t,e=this.blockCount,r=this.s,i=this.outputBlocks,n=this.extraBytes,o=0,a=0,s=this.outputBits>>3;t=n?new ArrayBuffer(i+1<<2):new ArrayBuffer(s);for(var h=new Uint32Array(t);a<i;){for(o=0;o<e&&a<i;++o,++a)h[a]=r[o];a%e==0&&z(r)}return n&&(h[o]=r[o],t=t.slice(0,s)),t},T.prototype.buffer=T.prototype.arrayBuffer,T.prototype.digest=T.prototype.array=function(){this.finalize();for(var t,e,r=this.blockCount,i=this.s,n=this.outputBlocks,o=this.extraBytes,a=0,s=0,h=[];s<n;){for(a=0;a<r&&s<n;++a,++s)t=s<<2,e=i[a],h[t]=255&e,h[t+1]=e>>8&255,h[t+2]=e>>16&255,h[t+3]=e>>24&255;s%r==0&&z(i)}return o&&(t=s<<2,e=i[a],h[t]=255&e,o>1&&(h[t+1]=e>>8&255),o>2&&(h[t+2]=e>>16&255)),h},C.prototype=new T,C.prototype.finalize=function(){return this.encode(this.outputBits,!0),T.prototype.finalize.call(this)};var z=function(t){var e,r,i,n,o,a,s,h,u,l,d,f,m,p,g,y,w,v,b,k,M,_,E,A,j,x,S,N,I,T,C,z,O,R,P,B,D,$,L,F,U,q,V,H,G,Z,K,J,W,Y,Q,X,tt,et,rt,it,nt,ot,at,st,ht,ut,lt;for(i=0;i<48;i+=2)n=t[0]^t[10]^t[20]^t[30]^t[40],o=t[1]^t[11]^t[21]^t[31]^t[41],a=t[2]^t[12]^t[22]^t[32]^t[42],s=t[3]^t[13]^t[23]^t[33]^t[43],h=t[4]^t[14]^t[24]^t[34]^t[44],u=t[5]^t[15]^t[25]^t[35]^t[45],l=t[6]^t[16]^t[26]^t[36]^t[46],d=t[7]^t[17]^t[27]^t[37]^t[47],e=(f=t[8]^t[18]^t[28]^t[38]^t[48])^(a<<1|s>>>31),r=(m=t[9]^t[19]^t[29]^t[39]^t[49])^(s<<1|a>>>31),t[0]^=e,t[1]^=r,t[10]^=e,t[11]^=r,t[20]^=e,t[21]^=r,t[30]^=e,t[31]^=r,t[40]^=e,t[41]^=r,e=n^(h<<1|u>>>31),r=o^(u<<1|h>>>31),t[2]^=e,t[3]^=r,t[12]^=e,t[13]^=r,t[22]^=e,t[23]^=r,t[32]^=e,t[33]^=r,t[42]^=e,t[43]^=r,e=a^(l<<1|d>>>31),r=s^(d<<1|l>>>31),t[4]^=e,t[5]^=r,t[14]^=e,t[15]^=r,t[24]^=e,t[25]^=r,t[34]^=e,t[35]^=r,t[44]^=e,t[45]^=r,e=h^(f<<1|m>>>31),r=u^(m<<1|f>>>31),t[6]^=e,t[7]^=r,t[16]^=e,t[17]^=r,t[26]^=e,t[27]^=r,t[36]^=e,t[37]^=r,t[46]^=e,t[47]^=r,e=l^(n<<1|o>>>31),r=d^(o<<1|n>>>31),t[8]^=e,t[9]^=r,t[18]^=e,t[19]^=r,t[28]^=e,t[29]^=r,t[38]^=e,t[39]^=r,t[48]^=e,t[49]^=r,p=t[0],g=t[1],Z=t[11]<<4|t[10]>>>28,K=t[10]<<4|t[11]>>>28,N=t[20]<<3|t[21]>>>29,I=t[21]<<3|t[20]>>>29,st=t[31]<<9|t[30]>>>23,ht=t[30]<<9|t[31]>>>23,q=t[40]<<18|t[41]>>>14,V=t[41]<<18|t[40]>>>14,R=t[2]<<1|t[3]>>>31,P=t[3]<<1|t[2]>>>31,y=t[13]<<12|t[12]>>>20,w=t[12]<<12|t[13]>>>20,J=t[22]<<10|t[23]>>>22,W=t[23]<<10|t[22]>>>22,T=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,rt=t[4]<<30|t[5]>>>2,B=t[14]<<6|t[15]>>>26,D=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,Q=t[35]<<15|t[34]>>>17,z=t[45]<<29|t[44]>>>3,O=t[44]<<29|t[45]>>>3,A=t[6]<<28|t[7]>>>4,j=t[7]<<28|t[6]>>>4,it=t[17]<<23|t[16]>>>9,nt=t[16]<<23|t[17]>>>9,$=t[26]<<25|t[27]>>>7,L=t[27]<<25|t[26]>>>7,k=t[36]<<21|t[37]>>>11,M=t[37]<<21|t[36]>>>11,X=t[47]<<24|t[46]>>>8,tt=t[46]<<24|t[47]>>>8,H=t[8]<<27|t[9]>>>5,G=t[9]<<27|t[8]>>>5,x=t[18]<<20|t[19]>>>12,S=t[19]<<20|t[18]>>>12,ot=t[29]<<7|t[28]>>>25,at=t[28]<<7|t[29]>>>25,F=t[38]<<8|t[39]>>>24,U=t[39]<<8|t[38]>>>24,_=t[48]<<14|t[49]>>>18,E=t[49]<<14|t[48]>>>18,t[0]=p^~y&v,t[1]=g^~w&b,t[10]=A^~x&N,t[11]=j^~S&I,t[20]=R^~B&$,t[21]=P^~D&L,t[30]=H^~Z&J,t[31]=G^~K&W,t[40]=et^~it&ot,t[41]=rt^~nt&at,t[2]=y^~v&k,t[3]=w^~b&M,t[12]=x^~N&T,t[13]=S^~I&C,t[22]=B^~$&F,t[23]=D^~L&U,t[32]=Z^~J&Y,t[33]=K^~W&Q,t[42]=it^~ot&st,t[43]=nt^~at&ht,t[4]=v^~k&_,t[5]=b^~M&E,t[14]=N^~T&z,t[15]=I^~C&O,t[24]=$^~F&q,t[25]=L^~U&V,t[34]=J^~Y&X,t[35]=W^~Q&tt,t[44]=ot^~st&ut,t[45]=at^~ht&lt,t[6]=k^~_&p,t[7]=M^~E&g,t[16]=T^~z&A,t[17]=C^~O&j,t[26]=F^~q&R,t[27]=U^~V&P,t[36]=Y^~X&H,t[37]=Q^~tt&G,t[46]=st^~ut&et,t[47]=ht^~lt&rt,t[8]=_^~p&y,t[9]=E^~g&w,t[18]=z^~A&x,t[19]=O^~j&S,t[28]=q^~R&B,t[29]=V^~P&D,t[38]=X^~H&Z,t[39]=tt^~G&K,t[48]=ut^~et&it,t[49]=lt^~rt&nt,t[0]^=c[i],t[1]^=c[i+1]};if(a)t.exports=_;else for(A=0;A<E.length;++A)n[E[A]]=_[E[A]]}()}));function Jt(t){return"0x"+Kt.keccak_256(A(t))}const Wt=new w("rlp/5.6.1");function Yt(t){const e=[];for(;t;)e.unshift(255&t),t>>=8;return e}function Qt(t,e,r){let i=0;for(let n=0;n<r;n++)i=256*i+t[e+n];return i}function Xt(t){if(Array.isArray(t)){let e=[];if(t.forEach((function(t){e=e.concat(Xt(t))})),e.length<=55)return e.unshift(192+e.length),e;const r=Yt(e.length);return r.unshift(247+r.length),r.concat(e)}M(t)||Wt.throwArgumentError("RLP object must be BytesLike","object",t);const e=Array.prototype.slice.call(A(t));if(1===e.length&&e[0]<=127)return e;if(e.length<=55)return e.unshift(128+e.length),e;const r=Yt(e.length);return r.unshift(183+r.length),r.concat(e)}function te(t){return I(Xt(t))}function ee(t,e,r,i){const n=[];for(;r<e+1+i;){const o=re(t,r);n.push(o.result),(r+=o.consumed)>e+1+i&&Wt.throwError("child data too short",w.errors.BUFFER_OVERRUN,{})}return{consumed:1+i,result:n}}function re(t,e){if(0===t.length&&Wt.throwError("data too short",w.errors.BUFFER_OVERRUN,{}),t[e]>=248){const r=t[e]-247;e+1+r>t.length&&Wt.throwError("data short segment too short",w.errors.BUFFER_OVERRUN,{});const i=Qt(t,e+1,r);return e+1+r+i>t.length&&Wt.throwError("data long segment too short",w.errors.BUFFER_OVERRUN,{}),ee(t,e,e+1+r,r+i)}if(t[e]>=192){const r=t[e]-192;return e+1+r>t.length&&Wt.throwError("data array too short",w.errors.BUFFER_OVERRUN,{}),ee(t,e,e+1,r)}if(t[e]>=184){const r=t[e]-183;e+1+r>t.length&&Wt.throwError("data array too short",w.errors.BUFFER_OVERRUN,{});const i=Qt(t,e+1,r);e+1+r+i>t.length&&Wt.throwError("data array too short",w.errors.BUFFER_OVERRUN,{});return{consumed:1+r+i,result:I(t.slice(e+1+r,e+1+r+i))}}if(t[e]>=128){const r=t[e]-128;e+1+r>t.length&&Wt.throwError("data too short",w.errors.BUFFER_OVERRUN,{});return{consumed:1+r,result:I(t.slice(e+1,e+1+r))}}return{consumed:1,result:I(t[e])}}function ie(t){const e=A(t),r=re(e,0);return r.consumed!==e.length&&Wt.throwArgumentError("invalid rlp data","data",t),r.result}const ne=new w("address/5.6.1");function oe(t){S(t,20)||ne.throwArgumentError("invalid address","address",t);const e=(t=t.toLowerCase()).substring(2).split(""),r=new Uint8Array(40);for(let t=0;t<40;t++)r[t]=e[t].charCodeAt(0);const i=A(Jt(r));for(let t=0;t<40;t+=2)i[t>>1]>>4>=8&&(e[t]=e[t].toUpperCase()),(15&i[t>>1])>=8&&(e[t+1]=e[t+1].toUpperCase());return"0x"+e.join("")}const ae={};for(let t=0;t<10;t++)ae[String(t)]=String(t);for(let t=0;t<26;t++)ae[String.fromCharCode(65+t)]=String(10+t);const se=Math.floor(function(t){return Math.log10?Math.log10(t):Math.log(t)/Math.LN10}(9007199254740991));function he(t){let e=null;if("string"!=typeof t&&ne.throwArgumentError("invalid address","address",t),t.match(/^(0x)?[0-9a-fA-F]{40}$/))"0x"!==t.substring(0,2)&&(t="0x"+t),e=oe(t),t.match(/([A-F].*[a-f])|([a-f].*[A-F])/)&&e!==t&&ne.throwArgumentError("bad address checksum","address",t);else if(t.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)){for(t.substring(2,4)!==function(t){let e=(t=(t=t.toUpperCase()).substring(4)+t.substring(0,2)+"00").split("").map((t=>ae[t])).join("");for(;e.length>=se;){let t=e.substring(0,se);e=parseInt(t,10)%97+e.substring(t.length)}let r=String(98-parseInt(e,10)%97);for(;r.length<2;)r="0"+r;return r}(t)&&ne.throwArgumentError("bad icap checksum","address",t),r=t.substring(4),e=new Dt(r,36).toString(16);e.length<40;)e="0"+e;e=oe("0x"+e)}else ne.throwArgumentError("invalid address","address",t);var r;return e}function ue(t){try{return he(t),!0}catch(t){}return!1}function le(t){let e=null;try{e=he(t.from)}catch(e){ne.throwArgumentError("missing from address","transaction",t)}return he(C(Jt(te([e,x(A(qt.from(t.nonce).toHexString()))])),12))}const ce={Space:[{name:"from",type:"address"},{name:"space",type:"string"},{name:"timestamp",type:"uint64"},{name:"settings",type:"string"}]},de={Proposal:[{name:"from",type:"address"},{name:"space",type:"string"},{name:"timestamp",type:"uint64"},{name:"type",type:"string"},{name:"title",type:"string"},{name:"body",type:"string"},{name:"discussion",type:"string"},{name:"choices",type:"string[]"},{name:"labels",type:"string[]"},{name:"start",type:"uint64"},{name:"end",type:"uint64"},{name:"snapshot",type:"uint64"},{name:"plugins",type:"string"},{name:"privacy",type:"string"},{name:"app",type:"string"}]},fe={UpdateProposal:[{name:"proposal",type:"string"},{name:"from",type:"address"},{name:"space",type:"string"},{name:"timestamp",type:"uint64"},{name:"type",type:"string"},{name:"title",type:"string"},{name:"body",type:"string"},{name:"discussion",type:"string"},{name:"choices",type:"string[]"},{name:"labels",type:"string[]"},{name:"plugins",type:"string"},{name:"privacy",type:"string"}]},me={FlagProposal:[{name:"from",type:"address"},{name:"space",type:"string"},{name:"proposal",type:"string"},{name:"timestamp",type:"uint64"}]},pe={CancelProposal:[{name:"from",type:"address"},{name:"space",type:"string"},{name:"timestamp",type:"uint64"},{name:"proposal",type:"string"}]},ge={CancelProposal:[{name:"from",type:"address"},{name:"space",type:"string"},{name:"timestamp",type:"uint64"},{name:"proposal",type:"bytes32"}]},ye={Vote:[{name:"from",type:"address"},{name:"space",type:"string"},{name:"timestamp",type:"uint64"},{name:"proposal",type:"string"},{name:"choice",type:"uint32"},{name:"reason",type:"string"},{name:"app",type:"string"},{name:"metadata",type:"string"}]},we={Vote:[{name:"from",type:"address"},{name:"space",type:"string"},{name:"timestamp",type:"uint64"},{name:"proposal",type:"string"},{name:"choice",type:"uint32[]"},{name:"reason",type:"string"},{name:"app",type:"string"},{name:"metadata",type:"string"}]},ve={Vote:[{name:"from",type:"address"},{name:"space",type:"string"},{name:"timestamp",type:"uint64"},{name:"proposal",type:"string"},{name:"choice",type:"string"},{name:"reason",type:"string"},{name:"app",type:"string"},{name:"metadata",type:"string"}]},be={Vote:[{name:"from",type:"address"},{name:"space",type:"string"},{name:"timestamp",type:"uint64"},{name:"proposal",type:"bytes32"},{name:"choice",type:"uint32"},{name:"reason",type:"string"},{name:"app",type:"string"},{name:"metadata",type:"string"}]},ke={Vote:[{name:"from",type:"address"},{name:"space",type:"string"},{name:"timestamp",type:"uint64"},{name:"proposal",type:"bytes32"},{name:"choice",type:"uint32[]"},{name:"reason",type:"string"},{name:"app",type:"string"},{name:"metadata",type:"string"}]},Me={Vote:[{name:"from",type:"address"},{name:"space",type:"string"},{name:"timestamp",type:"uint64"},{name:"proposal",type:"bytes32"},{name:"choice",type:"string"},{name:"reason",type:"string"},{name:"app",type:"string"},{name:"metadata",type:"string"}]},_e={Follow:[{name:"from",type:"address"},{name:"network",type:"string"},{name:"space",type:"string"},{name:"timestamp",type:"uint64"}]},Ee={Unfollow:[{name:"from",type:"address"},{name:"network",type:"string"},{name:"space",type:"string"},{name:"timestamp",type:"uint64"}]},Ae={Subscribe:[{name:"from",type:"address"},{name:"space",type:"string"},{name:"timestamp",type:"uint64"}]},je={Unsubscribe:[{name:"from",type:"address"},{name:"space",type:"string"},{name:"timestamp",type:"uint64"}]},xe={Profile:[{name:"from",type:"address"},{name:"timestamp",type:"uint64"},{name:"profile",type:"string"}]},Se={Statement:[{name:"from",type:"address"},{name:"timestamp",type:"uint64"},{name:"space",type:"string"},{name:"about",type:"string"},{name:"statement",type:"string"},{name:"discourse",type:"string"},{name:"status",type:"string"},{name:"network",type:"string"}]},Ne={Alias:[{name:"from",type:"address"},{name:"alias",type:"address"},{name:"timestamp",type:"uint64"}]},Ie={DeleteSpace:[{name:"from",type:"address"},{name:"space",type:"string"},{name:"timestamp",type:"uint64"}]};var Te={hub:"https://hub.snapshot.org",sequencer:"https://seq.snapshot.org"},Ce={hub:"https://testnet.hub.snapshot.org",sequencer:"https://testnet.seq.snapshot.org"},ze={hub:"http://localhost:3000",sequencer:"http://localhost:3001"};const Oe={name:"snapshot",version:"0.1.4"};class Re{constructor(t=Te.sequencer,e={}){t=(t=(t=t.replace(Te.hub,Te.sequencer)).replace(Ce.hub,Ce.sequencer)).replace(ze.hub,ze.sequencer),this.address=t,this.options=e}sign(t,e,i,n){return r(this,void 0,void 0,(function*(){var r;const o=(null==t?void 0:t.getSigner)?t.getSigner():t,a=he(e);i.from=i.from?he(i.from):a,i.timestamp||(i.timestamp=parseInt((Date.now()/1e3).toFixed()));const s=Object.assign({},Oe);"undefined"!=typeof window&&(null===(r=window.ethereum)||void 0===r?void 0:r.isTrust)&&(s.chainId=(yield o.provider.getNetwork()).chainId);const h={domain:s,types:n,message:i},u=yield o._signTypedData(s,h.types,i);return yield this.send({address:a,sig:u,data:h})}))}send(t){return r(this,void 0,void 0,(function*(){let e=this.address;"0x"===t.sig&&this.options.relayerURL&&(e=this.options.relayerURL);const r={method:"POST",headers:{Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify(t)};return new Promise(((t,i)=>{h(e,r).then((e=>{var r;if(e.ok)return t(e.json());if(null===(r=e.headers.get("content-type"))||void 0===r?void 0:r.includes("application/json"))return e.json().then(i).catch(i);throw e})).catch(i)}))}))}space(t,e,i){return r(this,void 0,void 0,(function*(){return yield this.sign(t,e,i,ce)}))}proposal(t,e,i){return r(this,void 0,void 0,(function*(){return i.labels||(i.labels=[]),i.discussion||(i.discussion=""),i.app||(i.app=""),i.privacy||(i.privacy=""),yield this.sign(t,e,i,de)}))}updateProposal(t,e,i){return r(this,void 0,void 0,(function*(){return i.privacy||(i.privacy=""),yield this.sign(t,e,i,fe)}))}flagProposal(t,e,i){return r(this,void 0,void 0,(function*(){return yield this.sign(t,e,i,me)}))}cancelProposal(t,e,i){return r(this,void 0,void 0,(function*(){const r=i.proposal.startsWith("0x");return yield this.sign(t,e,i,r?ge:pe)}))}vote(t,e,i){return r(this,void 0,void 0,(function*(){const r="shutter"===(null==i?void 0:i.privacy);i.reason||(i.reason=""),i.app||(i.app=""),i.metadata||(i.metadata="{}");const n=i.proposal.startsWith("0x");let o=n?be:ye;return["approval","ranked-choice"].includes(i.type)&&(o=n?ke:we),!r&&["quadratic","weighted"].includes(i.type)&&(o=n?Me:ve,i.choice=JSON.stringify(i.choice)),r&&(o=n?Me:ve),delete i.privacy,delete i.type,yield this.sign(t,e,i,o)}))}follow(t,e,i){return r(this,void 0,void 0,(function*(){return yield this.sign(t,e,i,_e)}))}unfollow(t,e,i){return r(this,void 0,void 0,(function*(){return yield this.sign(t,e,i,Ee)}))}subscribe(t,e,i){return r(this,void 0,void 0,(function*(){return yield this.sign(t,e,i,Ae)}))}unsubscribe(t,e,i){return r(this,void 0,void 0,(function*(){return yield this.sign(t,e,i,je)}))}profile(t,e,i){return r(this,void 0,void 0,(function*(){return yield this.sign(t,e,i,xe)}))}statement(t,e,i){return r(this,void 0,void 0,(function*(){return yield this.sign(t,e,i,Se)}))}alias(t,e,i){return r(this,void 0,void 0,(function*(){return yield this.sign(t,e,i,Ne)}))}deleteSpace(t,e,i){return r(this,void 0,void 0,(function*(){return yield this.sign(t,e,i,Ie)}))}}var Pe={$schema:"http://json-schema.org/draft-07/schema#",$ref:"#/definitions/Proposal",definitions:{Proposal:{title:"Proposal",type:"object",properties:{name:{type:"string",title:"name",minLength:1,maxLength:256},body:{type:"string",title:"body",minLength:0},discussion:{type:"string",format:"customUrl",title:"discussion",maxLength:256},choices:{type:"array",title:"choices",minItems:1},labels:{type:"array",title:"labels",maxItems:10,uniqueItems:!0,items:{type:"string",minLength:1,maxLength:8,pattern:"^[a-zA-Z0-9]+$"}},type:{type:"string",enum:["single-choice","approval","ranked-choice","quadratic","copeland","weighted","custom","basic"]},snapshot:{type:"number",title:"snapshot"},start:{type:"number",title:"start",minimum:1e9,maximum:2e9},end:{type:"number",title:"end",minimum:1e9,maximum:2e9},metadata:{type:"object",title:"metadata"},app:{type:"string",title:"app",maxLength:24},privacy:{type:"string",enum:["","shutter"]}},required:["name","body","choices","snapshot","start","end"],additionalProperties:!1}}},Be={$schema:"http://json-schema.org/draft-07/schema#",$ref:"#/definitions/UpdateProposal",definitions:{UpdateProposal:{title:"Update Proposal",type:"object",properties:{proposal:{type:"string",title:"proposal id"},name:{type:"string",title:"name",minLength:1,maxLength:256},body:{type:"string",title:"body",minLength:0},discussion:{type:"string",format:"customUrl",title:"discussion",maxLength:256},choices:{type:"array",title:"choices",minItems:1},labels:{type:"array",title:"labels",maxItems:10,uniqueItems:!0,items:{type:"string",minLength:1,maxLength:8,pattern:"^[a-zA-Z0-9]+$"}},type:{enum:["single-choice","approval","ranked-choice","quadratic","weighted","custom","basic"]},metadata:{type:"object",title:"metadata"},privacy:{type:"string",enum:["","shutter"]}},required:["proposal","name","body","discussion","choices","type","metadata"],additionalProperties:!1}}},De={$schema:"http://json-schema.org/draft-07/schema#",$ref:"#/definitions/Vote",definitions:{Vote:{title:"Vote",type:"object",properties:{proposal:{type:"string",title:"proposal"},choice:{type:["number","array","object","boolean","string"],title:"choice"},metadata:{type:"object",title:"metadata"},reason:{type:"string",title:"reason",maxLength:5e3},app:{type:"string",title:"app",maxLength:24}},required:["proposal","choice"],additionalProperties:!1}}},$e={$schema:"http://json-schema.org/draft-07/schema#",$ref:"#/definitions/Profile",definitions:{Profile:{title:"Profile",type:"object",properties:{name:{type:"string",title:"name",maxLength:32},about:{type:"string",title:"about",maxLength:256},avatar:{type:"string",title:"avatar",format:"customUrl",maxLength:256},cover:{type:"string",title:"avatar",format:"customUrl",maxLength:256},twitter:{type:"string",title:"twitter",pattern:"^[A-Za-z0-9_]*$",maxLength:15},github:{type:"string",title:"github",pattern:"^[A-Za-z0-9_-]*$",maxLength:39},lens:{type:"string",title:"lens",pattern:"^[A-Za-z0-9_]*$",maxLength:26},farcaster:{type:"string",title:"farcaster",pattern:"^[a-z0-9-]*$",maxLength:17}},required:[],additionalProperties:!1}}},Le={$schema:"http://json-schema.org/draft-07/schema#",$ref:"#/definitions/Statement",definitions:{Statement:{title:"Statement",type:"object",properties:{about:{type:"string",format:"long",title:"About",maxLength:140},statement:{type:"string",format:"long",title:"Statement",maxLength:1e4},discourse:{type:"string",title:"discourse",pattern:"^[A-Za-z0-9-_.]*$",maxLength:30},network:{type:"string",title:"network",pattern:"^[a-z0-9-]*$",maxLength:24},status:{enum:["ACTIVE","INACTIVE"],title:"status"}},required:[],additionalProperties:!1}}},Fe={$schema:"http://json-schema.org/draft-07/schema#",$ref:"#/definitions/Zodiac",definitions:{Zodiac:{title:"Zodiac",type:"object",properties:{safes:{title:"Safe(s)",type:"array",maxItems:8,items:{type:"object",properties:{network:{title:"Network",type:"string",snapshotNetwork:!0},multisend:{title:"Multisend contract address",type:"string"},realityAddress:{title:"Reality module address",type:"string"},umaAddress:{title:"UMA module address",type:"string"}},additionalProperties:!1}},additionalProperties:!1}}}},Ue={$schema:"http://json-schema.org/draft-07/schema#",$ref:"#/definitions/Alias",definitions:{Alias:{title:"Alias",type:"object",properties:{alias:{type:"string",format:"address"}},required:["alias"],additionalProperties:!1}}},qe={space:{$schema:"http://json-schema.org/draft-07/schema#",$ref:"#/definitions/Space",definitions:{Space:{title:"Space",type:"object",properties:{name:{type:"string",title:"name",minLength:1,maxLength:32},private:{type:"boolean"},about:{type:"string",title:"about",maxLength:160},guidelines:{type:"string",format:"customUrl",title:"guidelines",maxLength:256},template:{type:"string",title:"template",maxLength:1024},terms:{type:"string",title:"terms",format:"customUrl",maxLength:256},avatar:{type:"string",title:"avatar",format:"customUrl",maxLength:256},cover:{type:"string",title:"avatar",format:"customUrl",maxLength:256},location:{type:"string",title:"location",maxLength:24},website:{type:"string",title:"website",format:"customUrl",maxLength:256},twitter:{type:"string",title:"twitter",pattern:"^[A-Za-z0-9_]*$",maxLength:15},coingecko:{type:"string",title:"coingecko",pattern:"^[a-z0-9-]*$",maxLength:32},github:{type:"string",title:"github",pattern:"^[A-Za-z0-9_-]*$",maxLength:39},email:{type:"string",title:"email",maxLength:32},network:{type:"string",snapshotNetwork:!0,title:"network",minLength:1,maxLength:32},symbol:{type:"string",title:"symbol",maxLength:16},skin:{type:"string",title:"skin",maxLength:32},domain:{type:"string",title:"domain",maxLength:64,format:"domain"},discussions:{type:"string",format:"uri",title:"Discussions link",maxLength:256},discourseCategory:{type:"integer",minimum:1,title:"Discourse category"},strategies:{type:"array",minItems:1,uniqueItems:!0,items:{type:"object",properties:{name:{type:"string",maxLength:64,title:"name"},network:{type:"string",maxLength:12,title:"network",snapshotNetwork:!0},params:{type:"object",title:"params"}},required:["name"],additionalProperties:!1},title:"strategies"},members:{type:"array",maxItems:100,items:{type:"string",format:"evmAddress"},title:"members",uniqueItems:!0},admins:{type:"array",maxItems:100,items:{type:"string",format:"evmAddress"},title:"admins",uniqueItems:!0},moderators:{type:"array",maxItems:100,items:{type:"string",format:"evmAddress"},title:"moderators",uniqueItems:!0},filters:{type:"object",properties:{defaultTab:{type:"string"},minScore:{type:"number",minimum:0},onlyMembers:{type:"boolean"},invalids:{type:"array",items:{type:"string",maxLength:64},title:"invalids"}},additionalProperties:!1},validation:{type:"object",properties:{name:{type:"string",maxLength:64,title:"name"},params:{type:"object",title:"params"}},required:["name"],additionalProperties:!1},voteValidation:{type:"object",properties:{name:{type:"string",maxLength:32,title:"name"},params:{type:"object",title:"params"}},required:["name"],additionalProperties:!1},followValidation:{type:"object",properties:{name:{type:"string",maxLength:32,title:"name"},params:{type:"object",title:"params"}},required:["name"],additionalProperties:!1},delegationPortal:{type:"object",properties:{delegationType:{type:"string",title:"Delegation type",description:"Specify the type of delegation that you are using",anyOf:[{const:"compound-governor",title:"Compound governor"},{const:"split-delegation",title:"Split Delegation"}]},delegationContract:{type:"string",title:"Contract address",description:"The address of your delegation contract",examples:["0x3901D0fDe202aF1427216b79f5243f8A022d68cf"],anyOf:[{format:"evmAddress"},{format:"starknetAddress"}],errorMessage:"Must be a valid EVM of Starknet address"},delegationNetwork:{type:"string",title:"Delegation network",description:"The network of your delegation contract",anyOf:[{snapshotNetwork:!0},{starknetNetwork:!0}],errorMessage:"Must be a valid network"},delegationApi:{type:"string",format:"uri",title:"Delegation API",description:"The URL of your delegation API (e.g a subgraph)",examples:["https://subgrapher.snapshot.org/subgraph/arbitrum/FTzC6VrZd8JhJgWfTJnwWgH1Z1dS3GxaosKkRbCqkZAZ"]}},required:["delegationType","delegationApi","delegationContract"],additionalProperties:!1},allowAlias:{type:"boolean"},plugins:{type:"object"},voting:{type:"object",properties:{delay:{type:"integer",minimum:0,maximum:2592e3,errorMessage:{maximum:"Delay must be less than 30 days"}},period:{type:"integer",minimum:0,maximum:15552e3,errorMessage:{maximum:"Delay must be less than 180 days"}},type:{type:"string",title:"type"},quorum:{type:"number",minimum:0},quorumType:{type:"string",enum:["rejection"]},blind:{type:"boolean"},hideAbstain:{type:"boolean"},aliased:{type:"boolean"},privacy:{type:"string",enum:["","shutter","any"]}},additionalProperties:!1},categories:{type:"array",maxItems:2,items:{type:"string",enum:["protocol","social","investment","grant","service","media","creator","collector","ai-agent","gaming","wallet","music","layer-2","defai","defi","rwa","depin","meme"]}},treasuries:{type:"array",maxItems:10,uniqueItems:!0,items:{type:"object",properties:{name:{type:"string",title:"Name",examples:["e.g. Balancer DAO 1"],minLength:1,maxLength:64},address:{type:"string",title:"Contract address",examples:["e.g. 0x1f9840a85d5aF5bf1D1762F925BDADdC4201F984"],anyOf:[{format:"evmAddress"},{format:"starknetAddress"}],errorMessage:"Must be a valid EVM of Starknet address"},network:{type:"string",title:"Network",anyOf:[{snapshotNetwork:!0},{starknetNetwork:!0}],errorMessage:"Must be a valid network"}},required:["name","address","network"],additionalProperties:!1}},labels:{type:"array",maxItems:10,uniqueItems:!0,items:{type:"object",properties:{id:{type:"string",title:"Id",minLength:1,maxLength:8},name:{type:"string",title:"Name",minLength:1,maxLength:32},description:{type:"string",title:"Description",maxLength:100},color:{type:"string",title:"Color",format:"color"}},required:["id","name","color"],additionalProperties:!1}},parent:{type:"string",title:"parent"},children:{type:"array",maxItems:16,title:"children",items:{type:"string"},uniqueItems:!0},boost:{type:"object",properties:{enabled:{type:"boolean"},bribeEnabled:{type:"boolean"}},required:["enabled","bribeEnabled"],additionalProperties:!1},skinSettings:{type:"object",properties:{bg_color:{type:"string",format:"color"},link_color:{type:"string",format:"color"},text_color:{type:"string",format:"color"},content_color:{type:"string",format:"color"},border_color:{type:"string",format:"color"},heading_color:{type:"string",format:"color"},primary_color:{type:"string",format:"color"},header_color:{type:"string",format:"color"},theme:{type:"string",enum:["light","dark"]},logo:{type:"string",title:"logo",format:"customUrl",maxLength:256}},additionalProperties:!1}},required:["name","network","strategies"],additionalProperties:!1}}}.definitions.Space,proposal:Pe.definitions.Proposal,updateProposal:Be.definitions.UpdateProposal,vote:De.definitions.Vote,profile:$e.definitions.Profile,statement:Le.definitions.Statement,zodiac:Fe.definitions.Zodiac,alias:Ue.definitions.Alias},Ve=a((function(t){!function(t,e){function r(t,e){if(!t)throw new Error(e||"Assertion failed")}function i(t,e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}function n(t,e,r){if(n.isBN(t))return t;this.negative=0,this.words=null,this.length=0,this.red=null,null!==t&&("le"!==e&&"be"!==e||(r=e,e=10),this._init(t||0,e||10,r||"be"))}var o;"object"==typeof t?t.exports=n:e.BN=n,n.BN=n,n.wordSize=26;try{o="undefined"!=typeof window&&void 0!==window.Buffer?window.Buffer:Pt.Buffer}catch(t){}function a(t,e){var i=t.charCodeAt(e);return i>=48&&i<=57?i-48:i>=65&&i<=70?i-55:i>=97&&i<=102?i-87:void r(!1,"Invalid character in "+t)}function s(t,e,r){var i=a(t,r);return r-1>=e&&(i|=a(t,r-1)<<4),i}function h(t,e,i,n){for(var o=0,a=0,s=Math.min(t.length,i),h=e;h<s;h++){var u=t.charCodeAt(h)-48;o*=n,a=u>=49?u-49+10:u>=17?u-17+10:u,r(u>=0&&a<n,"Invalid character"),o+=a}return o}function u(t,e){t.words=e.words,t.length=e.length,t.negative=e.negative,t.red=e.red}if(n.isBN=function(t){return t instanceof n||null!==t&&"object"==typeof t&&t.constructor.wordSize===n.wordSize&&Array.isArray(t.words)},n.max=function(t,e){return t.cmp(e)>0?t:e},n.min=function(t,e){return t.cmp(e)<0?t:e},n.prototype._init=function(t,e,i){if("number"==typeof t)return this._initNumber(t,e,i);if("object"==typeof t)return this._initArray(t,e,i);"hex"===e&&(e=16),r(e===(0|e)&&e>=2&&e<=36);var n=0;"-"===(t=t.toString().replace(/\s+/g,""))[0]&&(n++,this.negative=1),n<t.length&&(16===e?this._parseHex(t,n,i):(this._parseBase(t,e,n),"le"===i&&this._initArray(this.toArray(),e,i)))},n.prototype._initNumber=function(t,e,i){t<0&&(this.negative=1,t=-t),t<67108864?(this.words=[67108863&t],this.length=1):t<4503599627370496?(this.words=[67108863&t,t/67108864&67108863],this.length=2):(r(t<9007199254740992),this.words=[67108863&t,t/67108864&67108863,1],this.length=3),"le"===i&&this._initArray(this.toArray(),e,i)},n.prototype._initArray=function(t,e,i){if(r("number"==typeof t.length),t.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(t.length/3),this.words=new Array(this.length);for(var n=0;n<this.length;n++)this.words[n]=0;var o,a,s=0;if("be"===i)for(n=t.length-1,o=0;n>=0;n-=3)a=t[n]|t[n-1]<<8|t[n-2]<<16,this.words[o]|=a<<s&67108863,this.words[o+1]=a>>>26-s&67108863,(s+=24)>=26&&(s-=26,o++);else if("le"===i)for(n=0,o=0;n<t.length;n+=3)a=t[n]|t[n+1]<<8|t[n+2]<<16,this.words[o]|=a<<s&67108863,this.words[o+1]=a>>>26-s&67108863,(s+=24)>=26&&(s-=26,o++);return this._strip()},n.prototype._parseHex=function(t,e,r){this.length=Math.ceil((t.length-e)/6),this.words=new Array(this.length);for(var i=0;i<this.length;i++)this.words[i]=0;var n,o=0,a=0;if("be"===r)for(i=t.length-1;i>=e;i-=2)n=s(t,e,i)<<o,this.words[a]|=67108863&n,o>=18?(o-=18,a+=1,this.words[a]|=n>>>26):o+=8;else for(i=(t.length-e)%2==0?e+1:e;i<t.length;i+=2)n=s(t,e,i)<<o,this.words[a]|=67108863&n,o>=18?(o-=18,a+=1,this.words[a]|=n>>>26):o+=8;this._strip()},n.prototype._parseBase=function(t,e,r){this.words=[0],this.length=1;for(var i=0,n=1;n<=67108863;n*=e)i++;i--,n=n/e|0;for(var o=t.length-r,a=o%i,s=Math.min(o,o-a)+r,u=0,l=r;l<s;l+=i)u=h(t,l,l+i,e),this.imuln(n),this.words[0]+u<67108864?this.words[0]+=u:this._iaddn(u);if(0!==a){var c=1;for(u=h(t,l,t.length,e),l=0;l<a;l++)c*=e;this.imuln(c),this.words[0]+u<67108864?this.words[0]+=u:this._iaddn(u)}this._strip()},n.prototype.copy=function(t){t.words=new Array(this.length);for(var e=0;e<this.length;e++)t.words[e]=this.words[e];t.length=this.length,t.negative=this.negative,t.red=this.red},n.prototype._move=function(t){u(t,this)},n.prototype.clone=function(){var t=new n(null);return this.copy(t),t},n.prototype._expand=function(t){for(;this.length<t;)this.words[this.length++]=0;return this},n.prototype._strip=function(){for(;this.length>1&&0===this.words[this.length-1];)this.length--;return this._normSign()},n.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},"undefined"!=typeof Symbol&&"function"==typeof Symbol.for)try{n.prototype[Symbol.for("nodejs.util.inspect.custom")]=l}catch(t){n.prototype.inspect=l}else n.prototype.inspect=l;function l(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"}var c=["","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"],d=[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],f=[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];n.prototype.toString=function(t,e){var i;if(e=0|e||1,16===(t=t||10)||"hex"===t){i="";for(var n=0,o=0,a=0;a<this.length;a++){var s=this.words[a],h=(16777215&(s<<n|o)).toString(16);o=s>>>24-n&16777215,(n+=2)>=26&&(n-=26,a--),i=0!==o||a!==this.length-1?c[6-h.length]+h+i:h+i}for(0!==o&&(i=o.toString(16)+i);i.length%e!=0;)i="0"+i;return 0!==this.negative&&(i="-"+i),i}if(t===(0|t)&&t>=2&&t<=36){var u=d[t],l=f[t];i="";var m=this.clone();for(m.negative=0;!m.isZero();){var p=m.modrn(l).toString(t);i=(m=m.idivn(l)).isZero()?p+i:c[u-p.length]+p+i}for(this.isZero()&&(i="0"+i);i.length%e!=0;)i="0"+i;return 0!==this.negative&&(i="-"+i),i}r(!1,"Base should be between 2 and 36")},n.prototype.toNumber=function(){var t=this.words[0];return 2===this.length?t+=67108864*this.words[1]:3===this.length&&1===this.words[2]?t+=4503599627370496+67108864*this.words[1]:this.length>2&&r(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-t:t},n.prototype.toJSON=function(){return this.toString(16,2)},o&&(n.prototype.toBuffer=function(t,e){return this.toArrayLike(o,t,e)}),n.prototype.toArray=function(t,e){return this.toArrayLike(Array,t,e)};function m(t,e,r){r.negative=e.negative^t.negative;var i=t.length+e.length|0;r.length=i,i=i-1|0;var n=0|t.words[0],o=0|e.words[0],a=n*o,s=67108863&a,h=a/67108864|0;r.words[0]=s;for(var u=1;u<i;u++){for(var l=h>>>26,c=67108863&h,d=Math.min(u,e.length-1),f=Math.max(0,u-t.length+1);f<=d;f++){var m=u-f|0;l+=(a=(n=0|t.words[m])*(o=0|e.words[f])+c)/67108864|0,c=67108863&a}r.words[u]=0|c,h=0|l}return 0!==h?r.words[u]=0|h:r.length--,r._strip()}n.prototype.toArrayLike=function(t,e,i){this._strip();var n=this.byteLength(),o=i||Math.max(1,n);r(n<=o,"byte array longer than desired length"),r(o>0,"Requested array length <= 0");var a=function(t,e){return t.allocUnsafe?t.allocUnsafe(e):new t(e)}(t,o);return this["_toArrayLike"+("le"===e?"LE":"BE")](a,n),a},n.prototype._toArrayLikeLE=function(t,e){for(var r=0,i=0,n=0,o=0;n<this.length;n++){var a=this.words[n]<<o|i;t[r++]=255&a,r<t.length&&(t[r++]=a>>8&255),r<t.length&&(t[r++]=a>>16&255),6===o?(r<t.length&&(t[r++]=a>>24&255),i=0,o=0):(i=a>>>24,o+=2)}if(r<t.length)for(t[r++]=i;r<t.length;)t[r++]=0},n.prototype._toArrayLikeBE=function(t,e){for(var r=t.length-1,i=0,n=0,o=0;n<this.length;n++){var a=this.words[n]<<o|i;t[r--]=255&a,r>=0&&(t[r--]=a>>8&255),r>=0&&(t[r--]=a>>16&255),6===o?(r>=0&&(t[r--]=a>>24&255),i=0,o=0):(i=a>>>24,o+=2)}if(r>=0)for(t[r--]=i;r>=0;)t[r--]=0},Math.clz32?n.prototype._countBits=function(t){return 32-Math.clz32(t)}:n.prototype._countBits=function(t){var e=t,r=0;return e>=4096&&(r+=13,e>>>=13),e>=64&&(r+=7,e>>>=7),e>=8&&(r+=4,e>>>=4),e>=2&&(r+=2,e>>>=2),r+e},n.prototype._zeroBits=function(t){if(0===t)return 26;var e=t,r=0;return 0==(8191&e)&&(r+=13,e>>>=13),0==(127&e)&&(r+=7,e>>>=7),0==(15&e)&&(r+=4,e>>>=4),0==(3&e)&&(r+=2,e>>>=2),0==(1&e)&&r++,r},n.prototype.bitLength=function(){var t=this.words[this.length-1],e=this._countBits(t);return 26*(this.length-1)+e},n.prototype.zeroBits=function(){if(this.isZero())return 0;for(var t=0,e=0;e<this.length;e++){var r=this._zeroBits(this.words[e]);if(t+=r,26!==r)break}return t},n.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},n.prototype.toTwos=function(t){return 0!==this.negative?this.abs().inotn(t).iaddn(1):this.clone()},n.prototype.fromTwos=function(t){return this.testn(t-1)?this.notn(t).iaddn(1).ineg():this.clone()},n.prototype.isNeg=function(){return 0!==this.negative},n.prototype.neg=function(){return this.clone().ineg()},n.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},n.prototype.iuor=function(t){for(;this.length<t.length;)this.words[this.length++]=0;for(var e=0;e<t.length;e++)this.words[e]=this.words[e]|t.words[e];return this._strip()},n.prototype.ior=function(t){return r(0==(this.negative|t.negative)),this.iuor(t)},n.prototype.or=function(t){return this.length>t.length?this.clone().ior(t):t.clone().ior(this)},n.prototype.uor=function(t){return this.length>t.length?this.clone().iuor(t):t.clone().iuor(this)},n.prototype.iuand=function(t){var e;e=this.length>t.length?t:this;for(var r=0;r<e.length;r++)this.words[r]=this.words[r]&t.words[r];return this.length=e.length,this._strip()},n.prototype.iand=function(t){return r(0==(this.negative|t.negative)),this.iuand(t)},n.prototype.and=function(t){return this.length>t.length?this.clone().iand(t):t.clone().iand(this)},n.prototype.uand=function(t){return this.length>t.length?this.clone().iuand(t):t.clone().iuand(this)},n.prototype.iuxor=function(t){var e,r;this.length>t.length?(e=this,r=t):(e=t,r=this);for(var i=0;i<r.length;i++)this.words[i]=e.words[i]^r.words[i];if(this!==e)for(;i<e.length;i++)this.words[i]=e.words[i];return this.length=e.length,this._strip()},n.prototype.ixor=function(t){return r(0==(this.negative|t.negative)),this.iuxor(t)},n.prototype.xor=function(t){return this.length>t.length?this.clone().ixor(t):t.clone().ixor(this)},n.prototype.uxor=function(t){return this.length>t.length?this.clone().iuxor(t):t.clone().iuxor(this)},n.prototype.inotn=function(t){r("number"==typeof t&&t>=0);var e=0|Math.ceil(t/26),i=t%26;this._expand(e),i>0&&e--;for(var n=0;n<e;n++)this.words[n]=67108863&~this.words[n];return i>0&&(this.words[n]=~this.words[n]&67108863>>26-i),this._strip()},n.prototype.notn=function(t){return this.clone().inotn(t)},n.prototype.setn=function(t,e){r("number"==typeof t&&t>=0);var i=t/26|0,n=t%26;return this._expand(i+1),this.words[i]=e?this.words[i]|1<<n:this.words[i]&~(1<<n),this._strip()},n.prototype.iadd=function(t){var e,r,i;if(0!==this.negative&&0===t.negative)return this.negative=0,e=this.isub(t),this.negative^=1,this._normSign();if(0===this.negative&&0!==t.negative)return t.negative=0,e=this.isub(t),t.negative=1,e._normSign();this.length>t.length?(r=this,i=t):(r=t,i=this);for(var n=0,o=0;o<i.length;o++)e=(0|r.words[o])+(0|i.words[o])+n,this.words[o]=67108863&e,n=e>>>26;for(;0!==n&&o<r.length;o++)e=(0|r.words[o])+n,this.words[o]=67108863&e,n=e>>>26;if(this.length=r.length,0!==n)this.words[this.length]=n,this.length++;else if(r!==this)for(;o<r.length;o++)this.words[o]=r.words[o];return this},n.prototype.add=function(t){var e;return 0!==t.negative&&0===this.negative?(t.negative=0,e=this.sub(t),t.negative^=1,e):0===t.negative&&0!==this.negative?(this.negative=0,e=t.sub(this),this.negative=1,e):this.length>t.length?this.clone().iadd(t):t.clone().iadd(this)},n.prototype.isub=function(t){if(0!==t.negative){t.negative=0;var e=this.iadd(t);return t.negative=1,e._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(t),this.negative=1,this._normSign();var r,i,n=this.cmp(t);if(0===n)return this.negative=0,this.length=1,this.words[0]=0,this;n>0?(r=this,i=t):(r=t,i=this);for(var o=0,a=0;a<i.length;a++)o=(e=(0|r.words[a])-(0|i.words[a])+o)>>26,this.words[a]=67108863&e;for(;0!==o&&a<r.length;a++)o=(e=(0|r.words[a])+o)>>26,this.words[a]=67108863&e;if(0===o&&a<r.length&&r!==this)for(;a<r.length;a++)this.words[a]=r.words[a];return this.length=Math.max(this.length,a),r!==this&&(this.negative=1),this._strip()},n.prototype.sub=function(t){return this.clone().isub(t)};var p=function(t,e,r){var i,n,o,a=t.words,s=e.words,h=r.words,u=0,l=0|a[0],c=8191&l,d=l>>>13,f=0|a[1],m=8191&f,p=f>>>13,g=0|a[2],y=8191&g,w=g>>>13,v=0|a[3],b=8191&v,k=v>>>13,M=0|a[4],_=8191&M,E=M>>>13,A=0|a[5],j=8191&A,x=A>>>13,S=0|a[6],N=8191&S,I=S>>>13,T=0|a[7],C=8191&T,z=T>>>13,O=0|a[8],R=8191&O,P=O>>>13,B=0|a[9],D=8191&B,$=B>>>13,L=0|s[0],F=8191&L,U=L>>>13,q=0|s[1],V=8191&q,H=q>>>13,G=0|s[2],Z=8191&G,K=G>>>13,J=0|s[3],W=8191&J,Y=J>>>13,Q=0|s[4],X=8191&Q,tt=Q>>>13,et=0|s[5],rt=8191&et,it=et>>>13,nt=0|s[6],ot=8191&nt,at=nt>>>13,st=0|s[7],ht=8191&st,ut=st>>>13,lt=0|s[8],ct=8191&lt,dt=lt>>>13,ft=0|s[9],mt=8191&ft,pt=ft>>>13;r.negative=t.negative^e.negative,r.length=19;var gt=(u+(i=Math.imul(c,F))|0)+((8191&(n=(n=Math.imul(c,U))+Math.imul(d,F)|0))<<13)|0;u=((o=Math.imul(d,U))+(n>>>13)|0)+(gt>>>26)|0,gt&=67108863,i=Math.imul(m,F),n=(n=Math.imul(m,U))+Math.imul(p,F)|0,o=Math.imul(p,U);var yt=(u+(i=i+Math.imul(c,V)|0)|0)+((8191&(n=(n=n+Math.imul(c,H)|0)+Math.imul(d,V)|0))<<13)|0;u=((o=o+Math.imul(d,H)|0)+(n>>>13)|0)+(yt>>>26)|0,yt&=67108863,i=Math.imul(y,F),n=(n=Math.imul(y,U))+Math.imul(w,F)|0,o=Math.imul(w,U),i=i+Math.imul(m,V)|0,n=(n=n+Math.imul(m,H)|0)+Math.imul(p,V)|0,o=o+Math.imul(p,H)|0;var wt=(u+(i=i+Math.imul(c,Z)|0)|0)+((8191&(n=(n=n+Math.imul(c,K)|0)+Math.imul(d,Z)|0))<<13)|0;u=((o=o+Math.imul(d,K)|0)+(n>>>13)|0)+(wt>>>26)|0,wt&=67108863,i=Math.imul(b,F),n=(n=Math.imul(b,U))+Math.imul(k,F)|0,o=Math.imul(k,U),i=i+Math.imul(y,V)|0,n=(n=n+Math.imul(y,H)|0)+Math.imul(w,V)|0,o=o+Math.imul(w,H)|0,i=i+Math.imul(m,Z)|0,n=(n=n+Math.imul(m,K)|0)+Math.imul(p,Z)|0,o=o+Math.imul(p,K)|0;var vt=(u+(i=i+Math.imul(c,W)|0)|0)+((8191&(n=(n=n+Math.imul(c,Y)|0)+Math.imul(d,W)|0))<<13)|0;u=((o=o+Math.imul(d,Y)|0)+(n>>>13)|0)+(vt>>>26)|0,vt&=67108863,i=Math.imul(_,F),n=(n=Math.imul(_,U))+Math.imul(E,F)|0,o=Math.imul(E,U),i=i+Math.imul(b,V)|0,n=(n=n+Math.imul(b,H)|0)+Math.imul(k,V)|0,o=o+Math.imul(k,H)|0,i=i+Math.imul(y,Z)|0,n=(n=n+Math.imul(y,K)|0)+Math.imul(w,Z)|0,o=o+Math.imul(w,K)|0,i=i+Math.imul(m,W)|0,n=(n=n+Math.imul(m,Y)|0)+Math.imul(p,W)|0,o=o+Math.imul(p,Y)|0;var bt=(u+(i=i+Math.imul(c,X)|0)|0)+((8191&(n=(n=n+Math.imul(c,tt)|0)+Math.imul(d,X)|0))<<13)|0;u=((o=o+Math.imul(d,tt)|0)+(n>>>13)|0)+(bt>>>26)|0,bt&=67108863,i=Math.imul(j,F),n=(n=Math.imul(j,U))+Math.imul(x,F)|0,o=Math.imul(x,U),i=i+Math.imul(_,V)|0,n=(n=n+Math.imul(_,H)|0)+Math.imul(E,V)|0,o=o+Math.imul(E,H)|0,i=i+Math.imul(b,Z)|0,n=(n=n+Math.imul(b,K)|0)+Math.imul(k,Z)|0,o=o+Math.imul(k,K)|0,i=i+Math.imul(y,W)|0,n=(n=n+Math.imul(y,Y)|0)+Math.imul(w,W)|0,o=o+Math.imul(w,Y)|0,i=i+Math.imul(m,X)|0,n=(n=n+Math.imul(m,tt)|0)+Math.imul(p,X)|0,o=o+Math.imul(p,tt)|0;var kt=(u+(i=i+Math.imul(c,rt)|0)|0)+((8191&(n=(n=n+Math.imul(c,it)|0)+Math.imul(d,rt)|0))<<13)|0;u=((o=o+Math.imul(d,it)|0)+(n>>>13)|0)+(kt>>>26)|0,kt&=67108863,i=Math.imul(N,F),n=(n=Math.imul(N,U))+Math.imul(I,F)|0,o=Math.imul(I,U),i=i+Math.imul(j,V)|0,n=(n=n+Math.imul(j,H)|0)+Math.imul(x,V)|0,o=o+Math.imul(x,H)|0,i=i+Math.imul(_,Z)|0,n=(n=n+Math.imul(_,K)|0)+Math.imul(E,Z)|0,o=o+Math.imul(E,K)|0,i=i+Math.imul(b,W)|0,n=(n=n+Math.imul(b,Y)|0)+Math.imul(k,W)|0,o=o+Math.imul(k,Y)|0,i=i+Math.imul(y,X)|0,n=(n=n+Math.imul(y,tt)|0)+Math.imul(w,X)|0,o=o+Math.imul(w,tt)|0,i=i+Math.imul(m,rt)|0,n=(n=n+Math.imul(m,it)|0)+Math.imul(p,rt)|0,o=o+Math.imul(p,it)|0;var Mt=(u+(i=i+Math.imul(c,ot)|0)|0)+((8191&(n=(n=n+Math.imul(c,at)|0)+Math.imul(d,ot)|0))<<13)|0;u=((o=o+Math.imul(d,at)|0)+(n>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,i=Math.imul(C,F),n=(n=Math.imul(C,U))+Math.imul(z,F)|0,o=Math.imul(z,U),i=i+Math.imul(N,V)|0,n=(n=n+Math.imul(N,H)|0)+Math.imul(I,V)|0,o=o+Math.imul(I,H)|0,i=i+Math.imul(j,Z)|0,n=(n=n+Math.imul(j,K)|0)+Math.imul(x,Z)|0,o=o+Math.imul(x,K)|0,i=i+Math.imul(_,W)|0,n=(n=n+Math.imul(_,Y)|0)+Math.imul(E,W)|0,o=o+Math.imul(E,Y)|0,i=i+Math.imul(b,X)|0,n=(n=n+Math.imul(b,tt)|0)+Math.imul(k,X)|0,o=o+Math.imul(k,tt)|0,i=i+Math.imul(y,rt)|0,n=(n=n+Math.imul(y,it)|0)+Math.imul(w,rt)|0,o=o+Math.imul(w,it)|0,i=i+Math.imul(m,ot)|0,n=(n=n+Math.imul(m,at)|0)+Math.imul(p,ot)|0,o=o+Math.imul(p,at)|0;var _t=(u+(i=i+Math.imul(c,ht)|0)|0)+((8191&(n=(n=n+Math.imul(c,ut)|0)+Math.imul(d,ht)|0))<<13)|0;u=((o=o+Math.imul(d,ut)|0)+(n>>>13)|0)+(_t>>>26)|0,_t&=67108863,i=Math.imul(R,F),n=(n=Math.imul(R,U))+Math.imul(P,F)|0,o=Math.imul(P,U),i=i+Math.imul(C,V)|0,n=(n=n+Math.imul(C,H)|0)+Math.imul(z,V)|0,o=o+Math.imul(z,H)|0,i=i+Math.imul(N,Z)|0,n=(n=n+Math.imul(N,K)|0)+Math.imul(I,Z)|0,o=o+Math.imul(I,K)|0,i=i+Math.imul(j,W)|0,n=(n=n+Math.imul(j,Y)|0)+Math.imul(x,W)|0,o=o+Math.imul(x,Y)|0,i=i+Math.imul(_,X)|0,n=(n=n+Math.imul(_,tt)|0)+Math.imul(E,X)|0,o=o+Math.imul(E,tt)|0,i=i+Math.imul(b,rt)|0,n=(n=n+Math.imul(b,it)|0)+Math.imul(k,rt)|0,o=o+Math.imul(k,it)|0,i=i+Math.imul(y,ot)|0,n=(n=n+Math.imul(y,at)|0)+Math.imul(w,ot)|0,o=o+Math.imul(w,at)|0,i=i+Math.imul(m,ht)|0,n=(n=n+Math.imul(m,ut)|0)+Math.imul(p,ht)|0,o=o+Math.imul(p,ut)|0;var Et=(u+(i=i+Math.imul(c,ct)|0)|0)+((8191&(n=(n=n+Math.imul(c,dt)|0)+Math.imul(d,ct)|0))<<13)|0;u=((o=o+Math.imul(d,dt)|0)+(n>>>13)|0)+(Et>>>26)|0,Et&=67108863,i=Math.imul(D,F),n=(n=Math.imul(D,U))+Math.imul($,F)|0,o=Math.imul($,U),i=i+Math.imul(R,V)|0,n=(n=n+Math.imul(R,H)|0)+Math.imul(P,V)|0,o=o+Math.imul(P,H)|0,i=i+Math.imul(C,Z)|0,n=(n=n+Math.imul(C,K)|0)+Math.imul(z,Z)|0,o=o+Math.imul(z,K)|0,i=i+Math.imul(N,W)|0,n=(n=n+Math.imul(N,Y)|0)+Math.imul(I,W)|0,o=o+Math.imul(I,Y)|0,i=i+Math.imul(j,X)|0,n=(n=n+Math.imul(j,tt)|0)+Math.imul(x,X)|0,o=o+Math.imul(x,tt)|0,i=i+Math.imul(_,rt)|0,n=(n=n+Math.imul(_,it)|0)+Math.imul(E,rt)|0,o=o+Math.imul(E,it)|0,i=i+Math.imul(b,ot)|0,n=(n=n+Math.imul(b,at)|0)+Math.imul(k,ot)|0,o=o+Math.imul(k,at)|0,i=i+Math.imul(y,ht)|0,n=(n=n+Math.imul(y,ut)|0)+Math.imul(w,ht)|0,o=o+Math.imul(w,ut)|0,i=i+Math.imul(m,ct)|0,n=(n=n+Math.imul(m,dt)|0)+Math.imul(p,ct)|0,o=o+Math.imul(p,dt)|0;var At=(u+(i=i+Math.imul(c,mt)|0)|0)+((8191&(n=(n=n+Math.imul(c,pt)|0)+Math.imul(d,mt)|0))<<13)|0;u=((o=o+Math.imul(d,pt)|0)+(n>>>13)|0)+(At>>>26)|0,At&=67108863,i=Math.imul(D,V),n=(n=Math.imul(D,H))+Math.imul($,V)|0,o=Math.imul($,H),i=i+Math.imul(R,Z)|0,n=(n=n+Math.imul(R,K)|0)+Math.imul(P,Z)|0,o=o+Math.imul(P,K)|0,i=i+Math.imul(C,W)|0,n=(n=n+Math.imul(C,Y)|0)+Math.imul(z,W)|0,o=o+Math.imul(z,Y)|0,i=i+Math.imul(N,X)|0,n=(n=n+Math.imul(N,tt)|0)+Math.imul(I,X)|0,o=o+Math.imul(I,tt)|0,i=i+Math.imul(j,rt)|0,n=(n=n+Math.imul(j,it)|0)+Math.imul(x,rt)|0,o=o+Math.imul(x,it)|0,i=i+Math.imul(_,ot)|0,n=(n=n+Math.imul(_,at)|0)+Math.imul(E,ot)|0,o=o+Math.imul(E,at)|0,i=i+Math.imul(b,ht)|0,n=(n=n+Math.imul(b,ut)|0)+Math.imul(k,ht)|0,o=o+Math.imul(k,ut)|0,i=i+Math.imul(y,ct)|0,n=(n=n+Math.imul(y,dt)|0)+Math.imul(w,ct)|0,o=o+Math.imul(w,dt)|0;var jt=(u+(i=i+Math.imul(m,mt)|0)|0)+((8191&(n=(n=n+Math.imul(m,pt)|0)+Math.imul(p,mt)|0))<<13)|0;u=((o=o+Math.imul(p,pt)|0)+(n>>>13)|0)+(jt>>>26)|0,jt&=67108863,i=Math.imul(D,Z),n=(n=Math.imul(D,K))+Math.imul($,Z)|0,o=Math.imul($,K),i=i+Math.imul(R,W)|0,n=(n=n+Math.imul(R,Y)|0)+Math.imul(P,W)|0,o=o+Math.imul(P,Y)|0,i=i+Math.imul(C,X)|0,n=(n=n+Math.imul(C,tt)|0)+Math.imul(z,X)|0,o=o+Math.imul(z,tt)|0,i=i+Math.imul(N,rt)|0,n=(n=n+Math.imul(N,it)|0)+Math.imul(I,rt)|0,o=o+Math.imul(I,it)|0,i=i+Math.imul(j,ot)|0,n=(n=n+Math.imul(j,at)|0)+Math.imul(x,ot)|0,o=o+Math.imul(x,at)|0,i=i+Math.imul(_,ht)|0,n=(n=n+Math.imul(_,ut)|0)+Math.imul(E,ht)|0,o=o+Math.imul(E,ut)|0,i=i+Math.imul(b,ct)|0,n=(n=n+Math.imul(b,dt)|0)+Math.imul(k,ct)|0,o=o+Math.imul(k,dt)|0;var xt=(u+(i=i+Math.imul(y,mt)|0)|0)+((8191&(n=(n=n+Math.imul(y,pt)|0)+Math.imul(w,mt)|0))<<13)|0;u=((o=o+Math.imul(w,pt)|0)+(n>>>13)|0)+(xt>>>26)|0,xt&=67108863,i=Math.imul(D,W),n=(n=Math.imul(D,Y))+Math.imul($,W)|0,o=Math.imul($,Y),i=i+Math.imul(R,X)|0,n=(n=n+Math.imul(R,tt)|0)+Math.imul(P,X)|0,o=o+Math.imul(P,tt)|0,i=i+Math.imul(C,rt)|0,n=(n=n+Math.imul(C,it)|0)+Math.imul(z,rt)|0,o=o+Math.imul(z,it)|0,i=i+Math.imul(N,ot)|0,n=(n=n+Math.imul(N,at)|0)+Math.imul(I,ot)|0,o=o+Math.imul(I,at)|0,i=i+Math.imul(j,ht)|0,n=(n=n+Math.imul(j,ut)|0)+Math.imul(x,ht)|0,o=o+Math.imul(x,ut)|0,i=i+Math.imul(_,ct)|0,n=(n=n+Math.imul(_,dt)|0)+Math.imul(E,ct)|0,o=o+Math.imul(E,dt)|0;var St=(u+(i=i+Math.imul(b,mt)|0)|0)+((8191&(n=(n=n+Math.imul(b,pt)|0)+Math.imul(k,mt)|0))<<13)|0;u=((o=o+Math.imul(k,pt)|0)+(n>>>13)|0)+(St>>>26)|0,St&=67108863,i=Math.imul(D,X),n=(n=Math.imul(D,tt))+Math.imul($,X)|0,o=Math.imul($,tt),i=i+Math.imul(R,rt)|0,n=(n=n+Math.imul(R,it)|0)+Math.imul(P,rt)|0,o=o+Math.imul(P,it)|0,i=i+Math.imul(C,ot)|0,n=(n=n+Math.imul(C,at)|0)+Math.imul(z,ot)|0,o=o+Math.imul(z,at)|0,i=i+Math.imul(N,ht)|0,n=(n=n+Math.imul(N,ut)|0)+Math.imul(I,ht)|0,o=o+Math.imul(I,ut)|0,i=i+Math.imul(j,ct)|0,n=(n=n+Math.imul(j,dt)|0)+Math.imul(x,ct)|0,o=o+Math.imul(x,dt)|0;var Nt=(u+(i=i+Math.imul(_,mt)|0)|0)+((8191&(n=(n=n+Math.imul(_,pt)|0)+Math.imul(E,mt)|0))<<13)|0;u=((o=o+Math.imul(E,pt)|0)+(n>>>13)|0)+(Nt>>>26)|0,Nt&=67108863,i=Math.imul(D,rt),n=(n=Math.imul(D,it))+Math.imul($,rt)|0,o=Math.imul($,it),i=i+Math.imul(R,ot)|0,n=(n=n+Math.imul(R,at)|0)+Math.imul(P,ot)|0,o=o+Math.imul(P,at)|0,i=i+Math.imul(C,ht)|0,n=(n=n+Math.imul(C,ut)|0)+Math.imul(z,ht)|0,o=o+Math.imul(z,ut)|0,i=i+Math.imul(N,ct)|0,n=(n=n+Math.imul(N,dt)|0)+Math.imul(I,ct)|0,o=o+Math.imul(I,dt)|0;var It=(u+(i=i+Math.imul(j,mt)|0)|0)+((8191&(n=(n=n+Math.imul(j,pt)|0)+Math.imul(x,mt)|0))<<13)|0;u=((o=o+Math.imul(x,pt)|0)+(n>>>13)|0)+(It>>>26)|0,It&=67108863,i=Math.imul(D,ot),n=(n=Math.imul(D,at))+Math.imul($,ot)|0,o=Math.imul($,at),i=i+Math.imul(R,ht)|0,n=(n=n+Math.imul(R,ut)|0)+Math.imul(P,ht)|0,o=o+Math.imul(P,ut)|0,i=i+Math.imul(C,ct)|0,n=(n=n+Math.imul(C,dt)|0)+Math.imul(z,ct)|0,o=o+Math.imul(z,dt)|0;var Tt=(u+(i=i+Math.imul(N,mt)|0)|0)+((8191&(n=(n=n+Math.imul(N,pt)|0)+Math.imul(I,mt)|0))<<13)|0;u=((o=o+Math.imul(I,pt)|0)+(n>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,i=Math.imul(D,ht),n=(n=Math.imul(D,ut))+Math.imul($,ht)|0,o=Math.imul($,ut),i=i+Math.imul(R,ct)|0,n=(n=n+Math.imul(R,dt)|0)+Math.imul(P,ct)|0,o=o+Math.imul(P,dt)|0;var Ct=(u+(i=i+Math.imul(C,mt)|0)|0)+((8191&(n=(n=n+Math.imul(C,pt)|0)+Math.imul(z,mt)|0))<<13)|0;u=((o=o+Math.imul(z,pt)|0)+(n>>>13)|0)+(Ct>>>26)|0,Ct&=67108863,i=Math.imul(D,ct),n=(n=Math.imul(D,dt))+Math.imul($,ct)|0,o=Math.imul($,dt);var zt=(u+(i=i+Math.imul(R,mt)|0)|0)+((8191&(n=(n=n+Math.imul(R,pt)|0)+Math.imul(P,mt)|0))<<13)|0;u=((o=o+Math.imul(P,pt)|0)+(n>>>13)|0)+(zt>>>26)|0,zt&=67108863;var Ot=(u+(i=Math.imul(D,mt))|0)+((8191&(n=(n=Math.imul(D,pt))+Math.imul($,mt)|0))<<13)|0;return u=((o=Math.imul($,pt))+(n>>>13)|0)+(Ot>>>26)|0,Ot&=67108863,h[0]=gt,h[1]=yt,h[2]=wt,h[3]=vt,h[4]=bt,h[5]=kt,h[6]=Mt,h[7]=_t,h[8]=Et,h[9]=At,h[10]=jt,h[11]=xt,h[12]=St,h[13]=Nt,h[14]=It,h[15]=Tt,h[16]=Ct,h[17]=zt,h[18]=Ot,0!==u&&(h[19]=u,r.length++),r};function g(t,e,r){r.negative=e.negative^t.negative,r.length=t.length+e.length;for(var i=0,n=0,o=0;o<r.length-1;o++){var a=n;n=0;for(var s=67108863&i,h=Math.min(o,e.length-1),u=Math.max(0,o-t.length+1);u<=h;u++){var l=o-u,c=(0|t.words[l])*(0|e.words[u]),d=67108863&c;s=67108863&(d=d+s|0),n+=(a=(a=a+(c/67108864|0)|0)+(d>>>26)|0)>>>26,a&=67108863}r.words[o]=s,i=a,a=n}return 0!==i?r.words[o]=i:r.length--,r._strip()}function y(t,e,r){return g(t,e,r)}Math.imul||(p=m),n.prototype.mulTo=function(t,e){var r=this.length+t.length;return 10===this.length&&10===t.length?p(this,t,e):r<63?m(this,t,e):r<1024?g(this,t,e):y(this,t,e)},n.prototype.mul=function(t){var e=new n(null);return e.words=new Array(this.length+t.length),this.mulTo(t,e)},n.prototype.mulf=function(t){var e=new n(null);return e.words=new Array(this.length+t.length),y(this,t,e)},n.prototype.imul=function(t){return this.clone().mulTo(t,this)},n.prototype.imuln=function(t){var e=t<0;e&&(t=-t),r("number"==typeof t),r(t<67108864);for(var i=0,n=0;n<this.length;n++){var o=(0|this.words[n])*t,a=(67108863&o)+(67108863&i);i>>=26,i+=o/67108864|0,i+=a>>>26,this.words[n]=67108863&a}return 0!==i&&(this.words[n]=i,this.length++),e?this.ineg():this},n.prototype.muln=function(t){return this.clone().imuln(t)},n.prototype.sqr=function(){return this.mul(this)},n.prototype.isqr=function(){return this.imul(this.clone())},n.prototype.pow=function(t){var e=function(t){for(var e=new Array(t.bitLength()),r=0;r<e.length;r++){var i=r/26|0,n=r%26;e[r]=t.words[i]>>>n&1}return e}(t);if(0===e.length)return new n(1);for(var r=this,i=0;i<e.length&&0===e[i];i++,r=r.sqr());if(++i<e.length)for(var o=r.sqr();i<e.length;i++,o=o.sqr())0!==e[i]&&(r=r.mul(o));return r},n.prototype.iushln=function(t){r("number"==typeof t&&t>=0);var e,i=t%26,n=(t-i)/26,o=67108863>>>26-i<<26-i;if(0!==i){var a=0;for(e=0;e<this.length;e++){var s=this.words[e]&o,h=(0|this.words[e])-s<<i;this.words[e]=h|a,a=s>>>26-i}a&&(this.words[e]=a,this.length++)}if(0!==n){for(e=this.length-1;e>=0;e--)this.words[e+n]=this.words[e];for(e=0;e<n;e++)this.words[e]=0;this.length+=n}return this._strip()},n.prototype.ishln=function(t){return r(0===this.negative),this.iushln(t)},n.prototype.iushrn=function(t,e,i){var n;r("number"==typeof t&&t>=0),n=e?(e-e%26)/26:0;var o=t%26,a=Math.min((t-o)/26,this.length),s=67108863^67108863>>>o<<o,h=i;if(n-=a,n=Math.max(0,n),h){for(var u=0;u<a;u++)h.words[u]=this.words[u];h.length=a}if(0===a);else if(this.length>a)for(this.length-=a,u=0;u<this.length;u++)this.words[u]=this.words[u+a];else this.words[0]=0,this.length=1;var l=0;for(u=this.length-1;u>=0&&(0!==l||u>=n);u--){var c=0|this.words[u];this.words[u]=l<<26-o|c>>>o,l=c&s}return h&&0!==l&&(h.words[h.length++]=l),0===this.length&&(this.words[0]=0,this.length=1),this._strip()},n.prototype.ishrn=function(t,e,i){return r(0===this.negative),this.iushrn(t,e,i)},n.prototype.shln=function(t){return this.clone().ishln(t)},n.prototype.ushln=function(t){return this.clone().iushln(t)},n.prototype.shrn=function(t){return this.clone().ishrn(t)},n.prototype.ushrn=function(t){return this.clone().iushrn(t)},n.prototype.testn=function(t){r("number"==typeof t&&t>=0);var e=t%26,i=(t-e)/26,n=1<<e;return!(this.length<=i)&&!!(this.words[i]&n)},n.prototype.imaskn=function(t){r("number"==typeof t&&t>=0);var e=t%26,i=(t-e)/26;if(r(0===this.negative,"imaskn works only with positive numbers"),this.length<=i)return this;if(0!==e&&i++,this.length=Math.min(i,this.length),0!==e){var n=67108863^67108863>>>e<<e;this.words[this.length-1]&=n}return this._strip()},n.prototype.maskn=function(t){return this.clone().imaskn(t)},n.prototype.iaddn=function(t){return r("number"==typeof t),r(t<67108864),t<0?this.isubn(-t):0!==this.negative?1===this.length&&(0|this.words[0])<=t?(this.words[0]=t-(0|this.words[0]),this.negative=0,this):(this.negative=0,this.isubn(t),this.negative=1,this):this._iaddn(t)},n.prototype._iaddn=function(t){this.words[0]+=t;for(var e=0;e<this.length&&this.words[e]>=67108864;e++)this.words[e]-=67108864,e===this.length-1?this.words[e+1]=1:this.words[e+1]++;return this.length=Math.max(this.length,e+1),this},n.prototype.isubn=function(t){if(r("number"==typeof t),r(t<67108864),t<0)return this.iaddn(-t);if(0!==this.negative)return this.negative=0,this.iaddn(t),this.negative=1,this;if(this.words[0]-=t,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var e=0;e<this.length&&this.words[e]<0;e++)this.words[e]+=67108864,this.words[e+1]-=1;return this._strip()},n.prototype.addn=function(t){return this.clone().iaddn(t)},n.prototype.subn=function(t){return this.clone().isubn(t)},n.prototype.iabs=function(){return this.negative=0,this},n.prototype.abs=function(){return this.clone().iabs()},n.prototype._ishlnsubmul=function(t,e,i){var n,o,a=t.length+i;this._expand(a);var s=0;for(n=0;n<t.length;n++){o=(0|this.words[n+i])+s;var h=(0|t.words[n])*e;s=((o-=67108863&h)>>26)-(h/67108864|0),this.words[n+i]=67108863&o}for(;n<this.length-i;n++)s=(o=(0|this.words[n+i])+s)>>26,this.words[n+i]=67108863&o;if(0===s)return this._strip();for(r(-1===s),s=0,n=0;n<this.length;n++)s=(o=-(0|this.words[n])+s)>>26,this.words[n]=67108863&o;return this.negative=1,this._strip()},n.prototype._wordDiv=function(t,e){var r=(this.length,t.length),i=this.clone(),o=t,a=0|o.words[o.length-1];0!==(r=26-this._countBits(a))&&(o=o.ushln(r),i.iushln(r),a=0|o.words[o.length-1]);var s,h=i.length-o.length;if("mod"!==e){(s=new n(null)).length=h+1,s.words=new Array(s.length);for(var u=0;u<s.length;u++)s.words[u]=0}var l=i.clone()._ishlnsubmul(o,1,h);0===l.negative&&(i=l,s&&(s.words[h]=1));for(var c=h-1;c>=0;c--){var d=67108864*(0|i.words[o.length+c])+(0|i.words[o.length+c-1]);for(d=Math.min(d/a|0,67108863),i._ishlnsubmul(o,d,c);0!==i.negative;)d--,i.negative=0,i._ishlnsubmul(o,1,c),i.isZero()||(i.negative^=1);s&&(s.words[c]=d)}return s&&s._strip(),i._strip(),"div"!==e&&0!==r&&i.iushrn(r),{div:s||null,mod:i}},n.prototype.divmod=function(t,e,i){return r(!t.isZero()),this.isZero()?{div:new n(0),mod:new n(0)}:0!==this.negative&&0===t.negative?(s=this.neg().divmod(t,e),"mod"!==e&&(o=s.div.neg()),"div"!==e&&(a=s.mod.neg(),i&&0!==a.negative&&a.iadd(t)),{div:o,mod:a}):0===this.negative&&0!==t.negative?(s=this.divmod(t.neg(),e),"mod"!==e&&(o=s.div.neg()),{div:o,mod:s.mod}):0!=(this.negative&t.negative)?(s=this.neg().divmod(t.neg(),e),"div"!==e&&(a=s.mod.neg(),i&&0!==a.negative&&a.isub(t)),{div:s.div,mod:a}):t.length>this.length||this.cmp(t)<0?{div:new n(0),mod:this}:1===t.length?"div"===e?{div:this.divn(t.words[0]),mod:null}:"mod"===e?{div:null,mod:new n(this.modrn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new n(this.modrn(t.words[0]))}:this._wordDiv(t,e);var o,a,s},n.prototype.div=function(t){return this.divmod(t,"div",!1).div},n.prototype.mod=function(t){return this.divmod(t,"mod",!1).mod},n.prototype.umod=function(t){return this.divmod(t,"mod",!0).mod},n.prototype.divRound=function(t){var e=this.divmod(t);if(e.mod.isZero())return e.div;var r=0!==e.div.negative?e.mod.isub(t):e.mod,i=t.ushrn(1),n=t.andln(1),o=r.cmp(i);return o<0||1===n&&0===o?e.div:0!==e.div.negative?e.div.isubn(1):e.div.iaddn(1)},n.prototype.modrn=function(t){var e=t<0;e&&(t=-t),r(t<=67108863);for(var i=(1<<26)%t,n=0,o=this.length-1;o>=0;o--)n=(i*n+(0|this.words[o]))%t;return e?-n:n},n.prototype.modn=function(t){return this.modrn(t)},n.prototype.idivn=function(t){var e=t<0;e&&(t=-t),r(t<=67108863);for(var i=0,n=this.length-1;n>=0;n--){var o=(0|this.words[n])+67108864*i;this.words[n]=o/t|0,i=o%t}return this._strip(),e?this.ineg():this},n.prototype.divn=function(t){return this.clone().idivn(t)},n.prototype.egcd=function(t){r(0===t.negative),r(!t.isZero());var e=this,i=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var o=new n(1),a=new n(0),s=new n(0),h=new n(1),u=0;e.isEven()&&i.isEven();)e.iushrn(1),i.iushrn(1),++u;for(var l=i.clone(),c=e.clone();!e.isZero();){for(var d=0,f=1;0==(e.words[0]&f)&&d<26;++d,f<<=1);if(d>0)for(e.iushrn(d);d-- >0;)(o.isOdd()||a.isOdd())&&(o.iadd(l),a.isub(c)),o.iushrn(1),a.iushrn(1);for(var m=0,p=1;0==(i.words[0]&p)&&m<26;++m,p<<=1);if(m>0)for(i.iushrn(m);m-- >0;)(s.isOdd()||h.isOdd())&&(s.iadd(l),h.isub(c)),s.iushrn(1),h.iushrn(1);e.cmp(i)>=0?(e.isub(i),o.isub(s),a.isub(h)):(i.isub(e),s.isub(o),h.isub(a))}return{a:s,b:h,gcd:i.iushln(u)}},n.prototype._invmp=function(t){r(0===t.negative),r(!t.isZero());var e=this,i=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var o,a=new n(1),s=new n(0),h=i.clone();e.cmpn(1)>0&&i.cmpn(1)>0;){for(var u=0,l=1;0==(e.words[0]&l)&&u<26;++u,l<<=1);if(u>0)for(e.iushrn(u);u-- >0;)a.isOdd()&&a.iadd(h),a.iushrn(1);for(var c=0,d=1;0==(i.words[0]&d)&&c<26;++c,d<<=1);if(c>0)for(i.iushrn(c);c-- >0;)s.isOdd()&&s.iadd(h),s.iushrn(1);e.cmp(i)>=0?(e.isub(i),a.isub(s)):(i.isub(e),s.isub(a))}return(o=0===e.cmpn(1)?a:s).cmpn(0)<0&&o.iadd(t),o},n.prototype.gcd=function(t){if(this.isZero())return t.abs();if(t.isZero())return this.abs();var e=this.clone(),r=t.clone();e.negative=0,r.negative=0;for(var i=0;e.isEven()&&r.isEven();i++)e.iushrn(1),r.iushrn(1);for(;;){for(;e.isEven();)e.iushrn(1);for(;r.isEven();)r.iushrn(1);var n=e.cmp(r);if(n<0){var o=e;e=r,r=o}else if(0===n||0===r.cmpn(1))break;e.isub(r)}return r.iushln(i)},n.prototype.invm=function(t){return this.egcd(t).a.umod(t)},n.prototype.isEven=function(){return 0==(1&this.words[0])},n.prototype.isOdd=function(){return 1==(1&this.words[0])},n.prototype.andln=function(t){return this.words[0]&t},n.prototype.bincn=function(t){r("number"==typeof t);var e=t%26,i=(t-e)/26,n=1<<e;if(this.length<=i)return this._expand(i+1),this.words[i]|=n,this;for(var o=n,a=i;0!==o&&a<this.length;a++){var s=0|this.words[a];o=(s+=o)>>>26,s&=67108863,this.words[a]=s}return 0!==o&&(this.words[a]=o,this.length++),this},n.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},n.prototype.cmpn=function(t){var e,i=t<0;if(0!==this.negative&&!i)return-1;if(0===this.negative&&i)return 1;if(this._strip(),this.length>1)e=1;else{i&&(t=-t),r(t<=67108863,"Number is too big");var n=0|this.words[0];e=n===t?0:n<t?-1:1}return 0!==this.negative?0|-e:e},n.prototype.cmp=function(t){if(0!==this.negative&&0===t.negative)return-1;if(0===this.negative&&0!==t.negative)return 1;var e=this.ucmp(t);return 0!==this.negative?0|-e:e},n.prototype.ucmp=function(t){if(this.length>t.length)return 1;if(this.length<t.length)return-1;for(var e=0,r=this.length-1;r>=0;r--){var i=0|this.words[r],n=0|t.words[r];if(i!==n){i<n?e=-1:i>n&&(e=1);break}}return e},n.prototype.gtn=function(t){return 1===this.cmpn(t)},n.prototype.gt=function(t){return 1===this.cmp(t)},n.prototype.gten=function(t){return this.cmpn(t)>=0},n.prototype.gte=function(t){return this.cmp(t)>=0},n.prototype.ltn=function(t){return-1===this.cmpn(t)},n.prototype.lt=function(t){return-1===this.cmp(t)},n.prototype.lten=function(t){return this.cmpn(t)<=0},n.prototype.lte=function(t){return this.cmp(t)<=0},n.prototype.eqn=function(t){return 0===this.cmpn(t)},n.prototype.eq=function(t){return 0===this.cmp(t)},n.red=function(t){return new E(t)},n.prototype.toRed=function(t){return r(!this.red,"Already a number in reduction context"),r(0===this.negative,"red works only with positives"),t.convertTo(this)._forceRed(t)},n.prototype.fromRed=function(){return r(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},n.prototype._forceRed=function(t){return this.red=t,this},n.prototype.forceRed=function(t){return r(!this.red,"Already a number in reduction context"),this._forceRed(t)},n.prototype.redAdd=function(t){return r(this.red,"redAdd works only with red numbers"),this.red.add(this,t)},n.prototype.redIAdd=function(t){return r(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,t)},n.prototype.redSub=function(t){return r(this.red,"redSub works only with red numbers"),this.red.sub(this,t)},n.prototype.redISub=function(t){return r(this.red,"redISub works only with red numbers"),this.red.isub(this,t)},n.prototype.redShl=function(t){return r(this.red,"redShl works only with red numbers"),this.red.shl(this,t)},n.prototype.redMul=function(t){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.mul(this,t)},n.prototype.redIMul=function(t){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.imul(this,t)},n.prototype.redSqr=function(){return r(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},n.prototype.redISqr=function(){return r(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},n.prototype.redSqrt=function(){return r(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},n.prototype.redInvm=function(){return r(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},n.prototype.redNeg=function(){return r(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},n.prototype.redPow=function(t){return r(this.red&&!t.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,t)};var w={k256:null,p224:null,p192:null,p25519:null};function v(t,e){this.name=t,this.p=new n(e,16),this.n=this.p.bitLength(),this.k=new n(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function b(){v.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function k(){v.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function M(){v.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function _(){v.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function E(t){if("string"==typeof t){var e=n._prime(t);this.m=e.p,this.prime=e}else r(t.gtn(1),"modulus must be greater than 1"),this.m=t,this.prime=null}function A(t){E.call(this,t),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new n(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)}v.prototype._tmp=function(){var t=new n(null);return t.words=new Array(Math.ceil(this.n/13)),t},v.prototype.ireduce=function(t){var e,r=t;do{this.split(r,this.tmp),e=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(e>this.n);var i=e<this.n?-1:r.ucmp(this.p);return 0===i?(r.words[0]=0,r.length=1):i>0?r.isub(this.p):void 0!==r.strip?r.strip():r._strip(),r},v.prototype.split=function(t,e){t.iushrn(this.n,0,e)},v.prototype.imulK=function(t){return t.imul(this.k)},i(b,v),b.prototype.split=function(t,e){for(var r=4194303,i=Math.min(t.length,9),n=0;n<i;n++)e.words[n]=t.words[n];if(e.length=i,t.length<=9)return t.words[0]=0,void(t.length=1);var o=t.words[9];for(e.words[e.length++]=o&r,n=10;n<t.length;n++){var a=0|t.words[n];t.words[n-10]=(a&r)<<4|o>>>22,o=a}o>>>=22,t.words[n-10]=o,0===o&&t.length>10?t.length-=10:t.length-=9},b.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var e=0,r=0;r<t.length;r++){var i=0|t.words[r];e+=977*i,t.words[r]=67108863&e,e=64*i+(e/67108864|0)}return 0===t.words[t.length-1]&&(t.length--,0===t.words[t.length-1]&&t.length--),t},i(k,v),i(M,v),i(_,v),_.prototype.imulK=function(t){for(var e=0,r=0;r<t.length;r++){var i=19*(0|t.words[r])+e,n=67108863&i;i>>>=26,t.words[r]=n,e=i}return 0!==e&&(t.words[t.length++]=e),t},n._prime=function(t){if(w[t])return w[t];var e;if("k256"===t)e=new b;else if("p224"===t)e=new k;else if("p192"===t)e=new M;else{if("p25519"!==t)throw new Error("Unknown prime "+t);e=new _}return w[t]=e,e},E.prototype._verify1=function(t){r(0===t.negative,"red works only with positives"),r(t.red,"red works only with red numbers")},E.prototype._verify2=function(t,e){r(0==(t.negative|e.negative),"red works only with positives"),r(t.red&&t.red===e.red,"red works only with red numbers")},E.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):(u(t,t.umod(this.m)._forceRed(this)),t)},E.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},E.prototype.add=function(t,e){this._verify2(t,e);var r=t.add(e);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},E.prototype.iadd=function(t,e){this._verify2(t,e);var r=t.iadd(e);return r.cmp(this.m)>=0&&r.isub(this.m),r},E.prototype.sub=function(t,e){this._verify2(t,e);var r=t.sub(e);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},E.prototype.isub=function(t,e){this._verify2(t,e);var r=t.isub(e);return r.cmpn(0)<0&&r.iadd(this.m),r},E.prototype.shl=function(t,e){return this._verify1(t),this.imod(t.ushln(e))},E.prototype.imul=function(t,e){return this._verify2(t,e),this.imod(t.imul(e))},E.prototype.mul=function(t,e){return this._verify2(t,e),this.imod(t.mul(e))},E.prototype.isqr=function(t){return this.imul(t,t.clone())},E.prototype.sqr=function(t){return this.mul(t,t)},E.prototype.sqrt=function(t){if(t.isZero())return t.clone();var e=this.m.andln(3);if(r(e%2==1),3===e){var i=this.m.add(new n(1)).iushrn(2);return this.pow(t,i)}for(var o=this.m.subn(1),a=0;!o.isZero()&&0===o.andln(1);)a++,o.iushrn(1);r(!o.isZero());var s=new n(1).toRed(this),h=s.redNeg(),u=this.m.subn(1).iushrn(1),l=this.m.bitLength();for(l=new n(2*l*l).toRed(this);0!==this.pow(l,u).cmp(h);)l.redIAdd(h);for(var c=this.pow(l,o),d=this.pow(t,o.addn(1).iushrn(1)),f=this.pow(t,o),m=a;0!==f.cmp(s);){for(var p=f,g=0;0!==p.cmp(s);g++)p=p.redSqr();r(g<m);var y=this.pow(c,new n(1).iushln(m-g-1));d=d.redMul(y),c=y.redSqr(),f=f.redMul(c),m=g}return d},E.prototype.invm=function(t){var e=t._invmp(this.m);return 0!==e.negative?(e.negative=0,this.imod(e).redNeg()):this.imod(e)},E.prototype.pow=function(t,e){if(e.isZero())return new n(1).toRed(this);if(0===e.cmpn(1))return t.clone();var r=new Array(16);r[0]=new n(1).toRed(this),r[1]=t;for(var i=2;i<r.length;i++)r[i]=this.mul(r[i-1],t);var o=r[0],a=0,s=0,h=e.bitLength()%26;for(0===h&&(h=26),i=e.length-1;i>=0;i--){for(var u=e.words[i],l=h-1;l>=0;l--){var c=u>>l&1;o!==r[0]&&(o=this.sqr(o)),0!==c||0!==a?(a<<=1,a|=c,(4===++s||0===i&&0===l)&&(o=this.mul(o,r[a]),s=0,a=0)):s=0}h=26}return o},E.prototype.convertTo=function(t){var e=t.umod(this.m);return e===t?e.clone():e},E.prototype.convertFrom=function(t){var e=t.clone();return e.red=null,e},n.mont=function(t){return new A(t)},i(A,E),A.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},A.prototype.convertFrom=function(t){var e=this.imod(t.mul(this.rinv));return e.red=null,e},A.prototype.imul=function(t,e){if(t.isZero()||e.isZero())return t.words[0]=0,t.length=1,t;var r=t.imul(e),i=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),n=r.isub(i).iushrn(this.shift),o=n;return n.cmp(this.m)>=0?o=n.isub(this.m):n.cmpn(0)<0&&(o=n.iadd(this.m)),o._forceRed(this)},A.prototype.mul=function(t,e){if(t.isZero()||e.isZero())return new n(0)._forceRed(this);var r=t.mul(e),i=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),o=r.isub(i).iushrn(this.shift),a=o;return o.cmp(this.m)>=0?a=o.isub(this.m):o.cmpn(0)<0&&(a=o.iadd(this.m)),a._forceRed(this)},A.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}(t,i)}));var He=Ve.BN;const Ge=new w("bignumber/5.6.2"),Ze={},Ke=9007199254740991;let Je=!1;class We{constructor(t,e){t!==Ze&&Ge.throwError("cannot call constructor directly; use BigNumber.from",w.errors.UNSUPPORTED_OPERATION,{operation:"new (BigNumber)"}),this._hex=e,this._isBigNumber=!0,Object.freeze(this)}fromTwos(t){return Qe(Xe(this).fromTwos(t))}toTwos(t){return Qe(Xe(this).toTwos(t))}abs(){return"-"===this._hex[0]?We.from(this._hex.substring(1)):this}add(t){return Qe(Xe(this).add(Xe(t)))}sub(t){return Qe(Xe(this).sub(Xe(t)))}div(t){return We.from(t).isZero()&&tr("division-by-zero","div"),Qe(Xe(this).div(Xe(t)))}mul(t){return Qe(Xe(this).mul(Xe(t)))}mod(t){const e=Xe(t);return e.isNeg()&&tr("division-by-zero","mod"),Qe(Xe(this).umod(e))}pow(t){const e=Xe(t);return e.isNeg()&&tr("negative-power","pow"),Qe(Xe(this).pow(e))}and(t){const e=Xe(t);return(this.isNegative()||e.isNeg())&&tr("unbound-bitwise-result","and"),Qe(Xe(this).and(e))}or(t){const e=Xe(t);return(this.isNegative()||e.isNeg())&&tr("unbound-bitwise-result","or"),Qe(Xe(this).or(e))}xor(t){const e=Xe(t);return(this.isNegative()||e.isNeg())&&tr("unbound-bitwise-result","xor"),Qe(Xe(this).xor(e))}mask(t){return(this.isNegative()||t<0)&&tr("negative-width","mask"),Qe(Xe(this).maskn(t))}shl(t){return(this.isNegative()||t<0)&&tr("negative-width","shl"),Qe(Xe(this).shln(t))}shr(t){return(this.isNegative()||t<0)&&tr("negative-width","shr"),Qe(Xe(this).shrn(t))}eq(t){return Xe(this).eq(Xe(t))}lt(t){return Xe(this).lt(Xe(t))}lte(t){return Xe(this).lte(Xe(t))}gt(t){return Xe(this).gt(Xe(t))}gte(t){return Xe(this).gte(Xe(t))}isNegative(){return"-"===this._hex[0]}isZero(){return Xe(this).isZero()}toNumber(){try{return Xe(this).toNumber()}catch(t){tr("overflow","toNumber",this.toString())}return null}toBigInt(){try{return BigInt(this.toString())}catch(t){}return Ge.throwError("this platform does not support BigInt",w.errors.UNSUPPORTED_OPERATION,{value:this.toString()})}toString(){return arguments.length>0&&(10===arguments[0]?Je||(Je=!0,Ge.warn("BigNumber.toString does not accept any parameters; base-10 is assumed")):16===arguments[0]?Ge.throwError("BigNumber.toString does not accept any parameters; use bigNumber.toHexString()",w.errors.UNEXPECTED_ARGUMENT,{}):Ge.throwError("BigNumber.toString does not accept parameters",w.errors.UNEXPECTED_ARGUMENT,{})),Xe(this).toString(10)}toHexString(){return this._hex}toJSON(t){return{type:"BigNumber",hex:this.toHexString()}}static from(t){if(t instanceof We)return t;if("string"==typeof t)return t.match(/^-?0x[0-9a-f]+$/i)?new We(Ze,Ye(t)):t.match(/^-?[0-9]+$/)?new We(Ze,Ye(new He(t))):Ge.throwArgumentError("invalid BigNumber string","value",t);if("number"==typeof t)return t%1&&tr("underflow","BigNumber.from",t),(t>=Ke||t<=-Ke)&&tr("overflow","BigNumber.from",t),We.from(String(t));const e=t;if("bigint"==typeof e)return We.from(e.toString());if(E(e))return We.from(I(e));if(e)if(e.toHexString){const t=e.toHexString();if("string"==typeof t)return We.from(t)}else{let t=e._hex;if(null==t&&"BigNumber"===e.type&&(t=e.hex),"string"==typeof t&&(S(t)||"-"===t[0]&&S(t.substring(1))))return We.from(t)}return Ge.throwArgumentError("invalid BigNumber value","value",t)}static isBigNumber(t){return!(!t||!t._isBigNumber)}}function Ye(t){if("string"!=typeof t)return Ye(t.toString(16));if("-"===t[0])return"-"===(t=t.substring(1))[0]&&Ge.throwArgumentError("invalid hex","value",t),"0x00"===(t=Ye(t))?t:"-"+t;if("0x"!==t.substring(0,2)&&(t="0x"+t),"0x"===t)return"0x00";for(t.length%2&&(t="0x0"+t.substring(2));t.length>4&&"0x00"===t.substring(0,4);)t="0x"+t.substring(4);return t}function Qe(t){return We.from(Ye(t))}function Xe(t){const e=We.from(t).toHexString();return"-"===e[0]?new He("-"+e.substring(3),16):new He(e.substring(2),16)}function tr(t,e,r){const i={fault:t,operation:e};return null!=r&&(i.value=r),Ge.throwError(t,w.errors.NUMERIC_FAULT,i)}var er=window&&window.__awaiter||function(t,e,r,i){return new(r||(r=Promise))((function(n,o){function a(t){try{h(i.next(t))}catch(t){o(t)}}function s(t){try{h(i.throw(t))}catch(t){o(t)}}function h(t){var e;t.done?n(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(a,s)}h((i=i.apply(t,e||[])).next())}))};const rr=new w("properties/5.6.0");function ir(t,e,r){Object.defineProperty(t,e,{enumerable:!0,value:r,writable:!1})}function nr(t,e){for(let r=0;r<32;r++){if(t[e])return t[e];if(!t.prototype||"object"!=typeof t.prototype)break;t=Object.getPrototypeOf(t.prototype).constructor}return null}function or(t){return er(this,void 0,void 0,(function*(){const e=Object.keys(t).map((e=>{const r=t[e];return Promise.resolve(r).then((t=>({key:e,value:t})))}));return(yield Promise.all(e)).reduce(((t,e)=>(t[e.key]=e.value,t)),{})}))}function ar(t){const e={};for(const r in t)e[r]=t[r];return e}const sr={bigint:!0,boolean:!0,function:!0,number:!0,string:!0};function hr(t){if(null==t||sr[typeof t])return!0;if(Array.isArray(t)||"object"==typeof t){if(!Object.isFrozen(t))return!1;const e=Object.keys(t);for(let r=0;r<e.length;r++){let i=null;try{i=t[e[r]]}catch(t){continue}if(!hr(i))return!1}return!0}return rr.throwArgumentError("Cannot deepCopy "+typeof t,"object",t)}function ur(t){if(hr(t))return t;if(Array.isArray(t))return Object.freeze(t.map((t=>lr(t))));if("object"==typeof t){const e={};for(const r in t){const i=t[r];void 0!==i&&ir(e,r,lr(i))}return e}return rr.throwArgumentError("Cannot deepCopy "+typeof t,"object",t)}function lr(t){return ur(t)}class cr{constructor(t){for(const e in t)this[e]=lr(t[e])}}const dr="abi/5.6.4",fr=new w(dr),mr={};let pr={calldata:!0,memory:!0,storage:!0},gr={calldata:!0,memory:!0};function yr(t,e){if("bytes"===t||"string"===t){if(pr[e])return!0}else if("address"===t){if("payable"===e)return!0}else if((t.indexOf("[")>=0||"tuple"===t)&&gr[e])return!0;return(pr[e]||"payable"===e)&&fr.throwArgumentError("invalid modifier","name",e),!1}function wr(t,e){for(let r in e)ir(t,r,e[r])}const vr=Object.freeze({sighash:"sighash",minimal:"minimal",full:"full",json:"json"}),br=new RegExp(/^(.*)\[([0-9]*)\]$/);class kr{constructor(t,e){t!==mr&&fr.throwError("use fromString",w.errors.UNSUPPORTED_OPERATION,{operation:"new ParamType()"}),wr(this,e);let r=this.type.match(br);wr(this,r?{arrayLength:parseInt(r[2]||"-1"),arrayChildren:kr.fromObject({type:r[1],components:this.components}),baseType:"array"}:{arrayLength:null,arrayChildren:null,baseType:null!=this.components?"tuple":this.type}),this._isParamType=!0,Object.freeze(this)}format(t){if(t||(t=vr.sighash),vr[t]||fr.throwArgumentError("invalid format type","format",t),t===vr.json){let e={type:"tuple"===this.baseType?"tuple":this.type,name:this.name||void 0};return"boolean"==typeof this.indexed&&(e.indexed=this.indexed),this.components&&(e.components=this.components.map((e=>JSON.parse(e.format(t))))),JSON.stringify(e)}let e="";return"array"===this.baseType?(e+=this.arrayChildren.format(t),e+="["+(this.arrayLength<0?"":String(this.arrayLength))+"]"):"tuple"===this.baseType?(t!==vr.sighash&&(e+=this.type),e+="("+this.components.map((e=>e.format(t))).join(t===vr.full?", ":",")+")"):e+=this.type,t!==vr.sighash&&(!0===this.indexed&&(e+=" indexed"),t===vr.full&&this.name&&(e+=" "+this.name)),e}static from(t,e){return"string"==typeof t?kr.fromString(t,e):kr.fromObject(t)}static fromObject(t){return kr.isParamType(t)?t:new kr(mr,{name:t.name||null,type:Cr(t.type),indexed:null==t.indexed?null:!!t.indexed,components:t.components?t.components.map(kr.fromObject):null})}static fromString(t,e){return r=function(t,e){let r=t;function i(e){fr.throwArgumentError(`unexpected character at position ${e}`,"param",t)}function n(t){let r={type:"",name:"",parent:t,state:{allowType:!0}};return e&&(r.indexed=!1),r}t=t.replace(/\s/g," ");let o={type:"",name:"",state:{allowType:!0}},a=o;for(let r=0;r<t.length;r++){let o=t[r];switch(o){case"(":a.state.allowType&&""===a.type?a.type="tuple":a.state.allowParams||i(r),a.state.allowType=!1,a.type=Cr(a.type),a.components=[n(a)],a=a.components[0];break;case")":delete a.state,"indexed"===a.name&&(e||i(r),a.indexed=!0,a.name=""),yr(a.type,a.name)&&(a.name=""),a.type=Cr(a.type);let t=a;a=a.parent,a||i(r),delete t.parent,a.state.allowParams=!1,a.state.allowName=!0,a.state.allowArray=!0;break;case",":delete a.state,"indexed"===a.name&&(e||i(r),a.indexed=!0,a.name=""),yr(a.type,a.name)&&(a.name=""),a.type=Cr(a.type);let s=n(a.parent);a.parent.components.push(s),delete a.parent,a=s;break;case" ":a.state.allowType&&""!==a.type&&(a.type=Cr(a.type),delete a.state.allowType,a.state.allowName=!0,a.state.allowParams=!0),a.state.allowName&&""!==a.name&&("indexed"===a.name?(e||i(r),a.indexed&&i(r),a.indexed=!0,a.name=""):yr(a.type,a.name)?a.name="":a.state.allowName=!1);break;case"[":a.state.allowArray||i(r),a.type+=o,a.state.allowArray=!1,a.state.allowName=!1,a.state.readArray=!0;break;case"]":a.state.readArray||i(r),a.type+=o,a.state.readArray=!1,a.state.allowArray=!0,a.state.allowName=!0;break;default:a.state.allowType?(a.type+=o,a.state.allowParams=!0,a.state.allowArray=!0):a.state.allowName?(a.name+=o,delete a.state.allowArray):a.state.readArray?a.type+=o:i(r)}}return a.parent&&fr.throwArgumentError("unexpected eof","param",t),delete o.state,"indexed"===a.name?(e||i(r.length-7),a.indexed&&i(r.length-7),a.indexed=!0,a.name=""):yr(a.type,a.name)&&(a.name=""),o.type=Cr(o.type),o}(t,!!e),kr.fromObject({name:r.name,type:r.type,indexed:r.indexed,components:r.components});var r}static isParamType(t){return!(null==t||!t._isParamType)}}function Mr(t,e){return function(t){t=t.trim();let e=[],r="",i=0;for(let n=0;n<t.length;n++){let o=t[n];","===o&&0===i?(e.push(r),r=""):(r+=o,"("===o?i++:")"===o&&(i--,-1===i&&fr.throwArgumentError("unbalanced parenthesis","value",t)))}r&&e.push(r);return e}(t).map((t=>kr.fromString(t,e)))}class _r{constructor(t,e){t!==mr&&fr.throwError("use a static from method",w.errors.UNSUPPORTED_OPERATION,{operation:"new Fragment()"}),wr(this,e),this._isFragment=!0,Object.freeze(this)}static from(t){return _r.isFragment(t)?t:"string"==typeof t?_r.fromString(t):_r.fromObject(t)}static fromObject(t){if(_r.isFragment(t))return t;switch(t.type){case"function":return Nr.fromObject(t);case"event":return Er.fromObject(t);case"constructor":return Sr.fromObject(t);case"error":return Tr.fromObject(t);case"fallback":case"receive":return null}return fr.throwArgumentError("invalid fragment object","value",t)}static fromString(t){return"event"===(t=(t=(t=t.replace(/\s/g," ")).replace(/\(/g," (").replace(/\)/g,") ").replace(/\s+/g," ")).trim()).split(" ")[0]?Er.fromString(t.substring(5).trim()):"function"===t.split(" ")[0]?Nr.fromString(t.substring(8).trim()):"constructor"===t.split("(")[0].trim()?Sr.fromString(t.trim()):"error"===t.split(" ")[0]?Tr.fromString(t.substring(5).trim()):fr.throwArgumentError("unsupported fragment","value",t)}static isFragment(t){return!(!t||!t._isFragment)}}class Er extends _r{format(t){if(t||(t=vr.sighash),vr[t]||fr.throwArgumentError("invalid format type","format",t),t===vr.json)return JSON.stringify({type:"event",anonymous:this.anonymous,name:this.name,inputs:this.inputs.map((e=>JSON.parse(e.format(t))))});let e="";return t!==vr.sighash&&(e+="event "),e+=this.name+"("+this.inputs.map((e=>e.format(t))).join(t===vr.full?", ":",")+") ",t!==vr.sighash&&this.anonymous&&(e+="anonymous "),e.trim()}static from(t){return"string"==typeof t?Er.fromString(t):Er.fromObject(t)}static fromObject(t){if(Er.isEventFragment(t))return t;"event"!==t.type&&fr.throwArgumentError("invalid event object","value",t);const e={name:Or(t.name),anonymous:t.anonymous,inputs:t.inputs?t.inputs.map(kr.fromObject):[],type:"event"};return new Er(mr,e)}static fromString(t){let e=t.match(Rr);e||fr.throwArgumentError("invalid event string","value",t);let r=!1;return e[3].split(" ").forEach((t=>{switch(t.trim()){case"anonymous":r=!0;break;case"":break;default:fr.warn("unknown modifier: "+t)}})),Er.fromObject({name:e[1].trim(),anonymous:r,inputs:Mr(e[2],!0),type:"event"})}static isEventFragment(t){return t&&t._isFragment&&"event"===t.type}}function Ar(t,e){e.gas=null;let r=t.split("@");return 1!==r.length?(r.length>2&&fr.throwArgumentError("invalid human-readable ABI signature","value",t),r[1].match(/^[0-9]+$/)||fr.throwArgumentError("invalid human-readable ABI signature gas","value",t),e.gas=We.from(r[1]),r[0]):t}function jr(t,e){e.constant=!1,e.payable=!1,e.stateMutability="nonpayable",t.split(" ").forEach((t=>{switch(t.trim()){case"constant":e.constant=!0;break;case"payable":e.payable=!0,e.stateMutability="payable";break;case"nonpayable":e.payable=!1,e.stateMutability="nonpayable";break;case"pure":e.constant=!0,e.stateMutability="pure";break;case"view":e.constant=!0,e.stateMutability="view";break;case"external":case"public":case"":break;default:console.log("unknown modifier: "+t)}}))}function xr(t){let e={constant:!1,payable:!0,stateMutability:"payable"};return null!=t.stateMutability?(e.stateMutability=t.stateMutability,e.constant="view"===e.stateMutability||"pure"===e.stateMutability,null!=t.constant&&!!t.constant!==e.constant&&fr.throwArgumentError("cannot have constant function with mutability "+e.stateMutability,"value",t),e.payable="payable"===e.stateMutability,null!=t.payable&&!!t.payable!==e.payable&&fr.throwArgumentError("cannot have payable function with mutability "+e.stateMutability,"value",t)):null!=t.payable?(e.payable=!!t.payable,null!=t.constant||e.payable||"constructor"===t.type||fr.throwArgumentError("unable to determine stateMutability","value",t),e.constant=!!t.constant,e.constant?e.stateMutability="view":e.stateMutability=e.payable?"payable":"nonpayable",e.payable&&e.constant&&fr.throwArgumentError("cannot have constant payable function","value",t)):null!=t.constant?(e.constant=!!t.constant,e.payable=!e.constant,e.stateMutability=e.constant?"view":"payable"):"constructor"!==t.type&&fr.throwArgumentError("unable to determine stateMutability","value",t),e}class Sr extends _r{format(t){if(t||(t=vr.sighash),vr[t]||fr.throwArgumentError("invalid format type","format",t),t===vr.json)return JSON.stringify({type:"constructor",stateMutability:"nonpayable"!==this.stateMutability?this.stateMutability:void 0,payable:this.payable,gas:this.gas?this.gas.toNumber():void 0,inputs:this.inputs.map((e=>JSON.parse(e.format(t))))});t===vr.sighash&&fr.throwError("cannot format a constructor for sighash",w.errors.UNSUPPORTED_OPERATION,{operation:"format(sighash)"});let e="constructor("+this.inputs.map((e=>e.format(t))).join(t===vr.full?", ":",")+") ";return this.stateMutability&&"nonpayable"!==this.stateMutability&&(e+=this.stateMutability+" "),e.trim()}static from(t){return"string"==typeof t?Sr.fromString(t):Sr.fromObject(t)}static fromObject(t){if(Sr.isConstructorFragment(t))return t;"constructor"!==t.type&&fr.throwArgumentError("invalid constructor object","value",t);let e=xr(t);e.constant&&fr.throwArgumentError("constructor cannot be constant","value",t);const r={name:null,type:t.type,inputs:t.inputs?t.inputs.map(kr.fromObject):[],payable:e.payable,stateMutability:e.stateMutability,gas:t.gas?We.from(t.gas):null};return new Sr(mr,r)}static fromString(t){let e={type:"constructor"},r=(t=Ar(t,e)).match(Rr);return r&&"constructor"===r[1].trim()||fr.throwArgumentError("invalid constructor string","value",t),e.inputs=Mr(r[2].trim(),!1),jr(r[3].trim(),e),Sr.fromObject(e)}static isConstructorFragment(t){return t&&t._isFragment&&"constructor"===t.type}}class Nr extends Sr{format(t){if(t||(t=vr.sighash),vr[t]||fr.throwArgumentError("invalid format type","format",t),t===vr.json)return JSON.stringify({type:"function",name:this.name,constant:this.constant,stateMutability:"nonpayable"!==this.stateMutability?this.stateMutability:void 0,payable:this.payable,gas:this.gas?this.gas.toNumber():void 0,inputs:this.inputs.map((e=>JSON.parse(e.format(t)))),outputs:this.outputs.map((e=>JSON.parse(e.format(t))))});let e="";return t!==vr.sighash&&(e+="function "),e+=this.name+"("+this.inputs.map((e=>e.format(t))).join(t===vr.full?", ":",")+") ",t!==vr.sighash&&(this.stateMutability?"nonpayable"!==this.stateMutability&&(e+=this.stateMutability+" "):this.constant&&(e+="view "),this.outputs&&this.outputs.length&&(e+="returns ("+this.outputs.map((e=>e.format(t))).join(", ")+") "),null!=this.gas&&(e+="@"+this.gas.toString()+" ")),e.trim()}static from(t){return"string"==typeof t?Nr.fromString(t):Nr.fromObject(t)}static fromObject(t){if(Nr.isFunctionFragment(t))return t;"function"!==t.type&&fr.throwArgumentError("invalid function object","value",t);let e=xr(t);const r={type:t.type,name:Or(t.name),constant:e.constant,inputs:t.inputs?t.inputs.map(kr.fromObject):[],outputs:t.outputs?t.outputs.map(kr.fromObject):[],payable:e.payable,stateMutability:e.stateMutability,gas:t.gas?We.from(t.gas):null};return new Nr(mr,r)}static fromString(t){let e={type:"function"},r=(t=Ar(t,e)).split(" returns ");r.length>2&&fr.throwArgumentError("invalid function string","value",t);let i=r[0].match(Rr);if(i||fr.throwArgumentError("invalid function signature","value",t),e.name=i[1].trim(),e.name&&Or(e.name),e.inputs=Mr(i[2],!1),jr(i[3].trim(),e),r.length>1){let i=r[1].match(Rr);""==i[1].trim()&&""==i[3].trim()||fr.throwArgumentError("unexpected tokens","value",t),e.outputs=Mr(i[2],!1)}else e.outputs=[];return Nr.fromObject(e)}static isFunctionFragment(t){return t&&t._isFragment&&"function"===t.type}}function Ir(t){const e=t.format();return"Error(string)"!==e&&"Panic(uint256)"!==e||fr.throwArgumentError(`cannot specify user defined ${e} error`,"fragment",t),t}class Tr extends _r{format(t){if(t||(t=vr.sighash),vr[t]||fr.throwArgumentError("invalid format type","format",t),t===vr.json)return JSON.stringify({type:"error",name:this.name,inputs:this.inputs.map((e=>JSON.parse(e.format(t))))});let e="";return t!==vr.sighash&&(e+="error "),e+=this.name+"("+this.inputs.map((e=>e.format(t))).join(t===vr.full?", ":",")+") ",e.trim()}static from(t){return"string"==typeof t?Tr.fromString(t):Tr.fromObject(t)}static fromObject(t){if(Tr.isErrorFragment(t))return t;"error"!==t.type&&fr.throwArgumentError("invalid error object","value",t);const e={type:t.type,name:Or(t.name),inputs:t.inputs?t.inputs.map(kr.fromObject):[]};return Ir(new Tr(mr,e))}static fromString(t){let e={type:"error"},r=t.match(Rr);return r||fr.throwArgumentError("invalid error signature","value",t),e.name=r[1].trim(),e.name&&Or(e.name),e.inputs=Mr(r[2],!1),Ir(Tr.fromObject(e))}static isErrorFragment(t){return t&&t._isFragment&&"error"===t.type}}function Cr(t){return t.match(/^uint($|[^1-9])/)?t="uint256"+t.substring(4):t.match(/^int($|[^1-9])/)&&(t="int256"+t.substring(3)),t}const zr=new RegExp("^[a-zA-Z$_][a-zA-Z0-9$_]*$");function Or(t){return t&&t.match(zr)||fr.throwArgumentError(`invalid identifier "${t}"`,"value",t),t}const Rr=new RegExp("^([^)(]*)\\((.*)\\)([^)(]*)$");const Pr=new w(dr);class Br{constructor(t,e,r,i){this.name=t,this.type=e,this.localName=r,this.dynamic=i}_throwError(t,e){Pr.throwArgumentError(t,this.localName,e)}}class Dr{constructor(t){ir(this,"wordSize",t||32),this._data=[],this._dataLength=0,this._padding=new Uint8Array(t)}get data(){return z(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(j(t._data))}writeBytes(t){let e=A(t);const r=e.length%this.wordSize;return r&&(e=j([e,this._padding.slice(r)])),this._writeData(e)}_getValue(t){let e=A(We.from(t));return e.length>this.wordSize&&Pr.throwError("value out-of-bounds",w.errors.BUFFER_OVERRUN,{length:this.wordSize,offset:e.length}),e.length%this.wordSize&&(e=j([this._padding.slice(e.length%this.wordSize),e])),e}writeValue(t){return this._writeData(this._getValue(t))}writeUpdatableValue(){const t=this._data.length;return this._data.push(this._padding),this._dataLength+=this.wordSize,e=>{this._data[t]=this._getValue(e)}}}class $r{constructor(t,e,r,i){ir(this,"_data",A(t)),ir(this,"wordSize",e||32),ir(this,"_coerceFunc",r),ir(this,"allowLoose",i),this._offset=0}get data(){return I(this._data)}get consumed(){return this._offset}static coerce(t,e){let r=t.match("^u?int([0-9]+)$");return r&&parseInt(r[1])<=48&&(e=e.toNumber()),e}coerce(t,e){return this._coerceFunc?this._coerceFunc(t,e):$r.coerce(t,e)}_peekBytes(t,e,r){let i=Math.ceil(e/this.wordSize)*this.wordSize;return this._offset+i>this._data.length&&(this.allowLoose&&r&&this._offset+e<=this._data.length?i=e:Pr.throwError("data out-of-bounds",w.errors.BUFFER_OVERRUN,{length:this._data.length,offset:this._offset+i})),this._data.slice(this._offset,this._offset+i)}subReader(t){return new $r(this._data.slice(this._offset+t),this.wordSize,this._coerceFunc,this.allowLoose)}readBytes(t,e){let r=this._peekBytes(0,t,!!e);return this._offset+=r.length,r.slice(0,t)}readValue(){return We.from(this.readBytes(this.wordSize))}}class Lr extends Br{constructor(t){super("address","address",t,!1)}defaultValue(){return"0x0000000000000000000000000000000000000000"}encode(t,e){try{e=he(e)}catch(t){this._throwError(t.message,e)}return t.writeValue(e)}decode(t){return he(R(t.readValue().toHexString(),20))}}class Fr extends Br{constructor(t){super(t.name,t.type,void 0,t.dynamic),this.coder=t}defaultValue(){return this.coder.defaultValue()}encode(t,e){return this.coder.encode(t,e)}decode(t){return this.coder.decode(t)}}const Ur=new w(dr);function qr(t,e,r){let i=null;if(Array.isArray(r))i=r;else if(r&&"object"==typeof r){let t={};i=e.map((e=>{const i=e.localName;return i||Ur.throwError("cannot encode object for signature with missing names",w.errors.INVALID_ARGUMENT,{argument:"values",coder:e,value:r}),t[i]&&Ur.throwError("cannot encode object for signature with duplicate names",w.errors.INVALID_ARGUMENT,{argument:"values",coder:e,value:r}),t[i]=!0,r[i]}))}else Ur.throwArgumentError("invalid tuple value","tuple",r);e.length!==i.length&&Ur.throwArgumentError("types/value length mismatch","tuple",r);let n=new Dr(t.wordSize),o=new Dr(t.wordSize),a=[];e.forEach(((t,e)=>{let r=i[e];if(t.dynamic){let e=o.length;t.encode(o,r);let i=n.writeUpdatableValue();a.push((t=>{i(t+e)}))}else t.encode(n,r)})),a.forEach((t=>{t(n.length)}));let s=t.appendWriter(n);return s+=t.appendWriter(o),s}function Vr(t,e){let r=[],i=t.subReader(0);e.forEach((e=>{let n=null;if(e.dynamic){let r=t.readValue(),o=i.subReader(r.toNumber());try{n=e.decode(o)}catch(t){if(t.code===w.errors.BUFFER_OVERRUN)throw t;n=t,n.baseType=e.name,n.name=e.localName,n.type=e.type}}else try{n=e.decode(t)}catch(t){if(t.code===w.errors.BUFFER_OVERRUN)throw t;n=t,n.baseType=e.name,n.name=e.localName,n.type=e.type}null!=n&&r.push(n)}));const n=e.reduce(((t,e)=>{const r=e.localName;return r&&(t[r]||(t[r]=0),t[r]++),t}),{});e.forEach(((t,e)=>{let i=t.localName;if(!i||1!==n[i])return;if("length"===i&&(i="_length"),null!=r[i])return;const o=r[e];o instanceof Error?Object.defineProperty(r,i,{enumerable:!0,get:()=>{throw o}}):r[i]=o}));for(let t=0;t<r.length;t++){const e=r[t];e instanceof Error&&Object.defineProperty(r,t,{enumerable:!0,get:()=>{throw e}})}return Object.freeze(r)}class Hr extends Br{constructor(t,e,r){super("array",t.type+"["+(e>=0?e:"")+"]",r,-1===e||t.dynamic),this.coder=t,this.length=e}defaultValue(){const t=this.coder.defaultValue(),e=[];for(let r=0;r<this.length;r++)e.push(t);return e}encode(t,e){Array.isArray(e)||this._throwError("expected array value",e);let r=this.length;-1===r&&(r=e.length,t.writeValue(e.length)),Ur.checkArgumentCount(e.length,r,"coder array"+(this.localName?" "+this.localName:""));let i=[];for(let t=0;t<e.length;t++)i.push(this.coder);return qr(t,i,e)}decode(t){let e=this.length;-1===e&&(e=t.readValue().toNumber(),32*e>t._data.length&&Ur.throwError("insufficient data length",w.errors.BUFFER_OVERRUN,{length:t._data.length,count:e}));let r=[];for(let t=0;t<e;t++)r.push(new Fr(this.coder));return t.coerce(this.name,Vr(t,r))}}class Gr extends Br{constructor(t){super("bool","bool",t,!1)}defaultValue(){return!1}encode(t,e){return t.writeValue(e?1:0)}decode(t){return t.coerce(this.type,!t.readValue().isZero())}}class Zr extends Br{constructor(t,e){super(t,t,e,!0)}defaultValue(){return"0x"}encode(t,e){e=A(e);let r=t.writeValue(e.length);return r+=t.writeBytes(e),r}decode(t){return t.readBytes(t.readValue().toNumber(),!0)}}class Kr extends Zr{constructor(t){super("bytes",t)}decode(t){return t.coerce(this.name,I(super.decode(t)))}}class Jr extends Br{constructor(t,e){let r="bytes"+String(t);super(r,r,e,!1),this.size=t}defaultValue(){return"0x0000000000000000000000000000000000000000000000000000000000000000".substring(0,2+2*this.size)}encode(t,e){let r=A(e);return r.length!==this.size&&this._throwError("incorrect data length",e),t.writeBytes(r)}decode(t){return t.coerce(this.name,I(t.readBytes(this.size)))}}class Wr extends Br{constructor(t){super("null","",t,!1)}defaultValue(){return null}encode(t,e){return null!=e&&this._throwError("not null",e),t.writeBytes([])}decode(t){return t.readBytes(0),t.coerce(this.name,null)}}var Yr=a((function(t){!function(t,e){function r(t,e){if(!t)throw new Error(e||"Assertion failed")}function i(t,e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}function n(t,e,r){if(n.isBN(t))return t;this.negative=0,this.words=null,this.length=0,this.red=null,null!==t&&("le"!==e&&"be"!==e||(r=e,e=10),this._init(t||0,e||10,r||"be"))}var o;"object"==typeof t?t.exports=n:e.BN=n,n.BN=n,n.wordSize=26;try{o="undefined"!=typeof window&&void 0!==window.Buffer?window.Buffer:Pt.Buffer}catch(t){}function a(t,e){var i=t.charCodeAt(e);return i>=48&&i<=57?i-48:i>=65&&i<=70?i-55:i>=97&&i<=102?i-87:void r(!1,"Invalid character in "+t)}function s(t,e,r){var i=a(t,r);return r-1>=e&&(i|=a(t,r-1)<<4),i}function h(t,e,i,n){for(var o=0,a=0,s=Math.min(t.length,i),h=e;h<s;h++){var u=t.charCodeAt(h)-48;o*=n,a=u>=49?u-49+10:u>=17?u-17+10:u,r(u>=0&&a<n,"Invalid character"),o+=a}return o}function u(t,e){t.words=e.words,t.length=e.length,t.negative=e.negative,t.red=e.red}if(n.isBN=function(t){return t instanceof n||null!==t&&"object"==typeof t&&t.constructor.wordSize===n.wordSize&&Array.isArray(t.words)},n.max=function(t,e){return t.cmp(e)>0?t:e},n.min=function(t,e){return t.cmp(e)<0?t:e},n.prototype._init=function(t,e,i){if("number"==typeof t)return this._initNumber(t,e,i);if("object"==typeof t)return this._initArray(t,e,i);"hex"===e&&(e=16),r(e===(0|e)&&e>=2&&e<=36);var n=0;"-"===(t=t.toString().replace(/\s+/g,""))[0]&&(n++,this.negative=1),n<t.length&&(16===e?this._parseHex(t,n,i):(this._parseBase(t,e,n),"le"===i&&this._initArray(this.toArray(),e,i)))},n.prototype._initNumber=function(t,e,i){t<0&&(this.negative=1,t=-t),t<67108864?(this.words=[67108863&t],this.length=1):t<4503599627370496?(this.words=[67108863&t,t/67108864&67108863],this.length=2):(r(t<9007199254740992),this.words=[67108863&t,t/67108864&67108863,1],this.length=3),"le"===i&&this._initArray(this.toArray(),e,i)},n.prototype._initArray=function(t,e,i){if(r("number"==typeof t.length),t.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(t.length/3),this.words=new Array(this.length);for(var n=0;n<this.length;n++)this.words[n]=0;var o,a,s=0;if("be"===i)for(n=t.length-1,o=0;n>=0;n-=3)a=t[n]|t[n-1]<<8|t[n-2]<<16,this.words[o]|=a<<s&67108863,this.words[o+1]=a>>>26-s&67108863,(s+=24)>=26&&(s-=26,o++);else if("le"===i)for(n=0,o=0;n<t.length;n+=3)a=t[n]|t[n+1]<<8|t[n+2]<<16,this.words[o]|=a<<s&67108863,this.words[o+1]=a>>>26-s&67108863,(s+=24)>=26&&(s-=26,o++);return this._strip()},n.prototype._parseHex=function(t,e,r){this.length=Math.ceil((t.length-e)/6),this.words=new Array(this.length);for(var i=0;i<this.length;i++)this.words[i]=0;var n,o=0,a=0;if("be"===r)for(i=t.length-1;i>=e;i-=2)n=s(t,e,i)<<o,this.words[a]|=67108863&n,o>=18?(o-=18,a+=1,this.words[a]|=n>>>26):o+=8;else for(i=(t.length-e)%2==0?e+1:e;i<t.length;i+=2)n=s(t,e,i)<<o,this.words[a]|=67108863&n,o>=18?(o-=18,a+=1,this.words[a]|=n>>>26):o+=8;this._strip()},n.prototype._parseBase=function(t,e,r){this.words=[0],this.length=1;for(var i=0,n=1;n<=67108863;n*=e)i++;i--,n=n/e|0;for(var o=t.length-r,a=o%i,s=Math.min(o,o-a)+r,u=0,l=r;l<s;l+=i)u=h(t,l,l+i,e),this.imuln(n),this.words[0]+u<67108864?this.words[0]+=u:this._iaddn(u);if(0!==a){var c=1;for(u=h(t,l,t.length,e),l=0;l<a;l++)c*=e;this.imuln(c),this.words[0]+u<67108864?this.words[0]+=u:this._iaddn(u)}this._strip()},n.prototype.copy=function(t){t.words=new Array(this.length);for(var e=0;e<this.length;e++)t.words[e]=this.words[e];t.length=this.length,t.negative=this.negative,t.red=this.red},n.prototype._move=function(t){u(t,this)},n.prototype.clone=function(){var t=new n(null);return this.copy(t),t},n.prototype._expand=function(t){for(;this.length<t;)this.words[this.length++]=0;return this},n.prototype._strip=function(){for(;this.length>1&&0===this.words[this.length-1];)this.length--;return this._normSign()},n.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},"undefined"!=typeof Symbol&&"function"==typeof Symbol.for)try{n.prototype[Symbol.for("nodejs.util.inspect.custom")]=l}catch(t){n.prototype.inspect=l}else n.prototype.inspect=l;function l(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"}var c=["","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"],d=[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],f=[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];n.prototype.toString=function(t,e){var i;if(e=0|e||1,16===(t=t||10)||"hex"===t){i="";for(var n=0,o=0,a=0;a<this.length;a++){var s=this.words[a],h=(16777215&(s<<n|o)).toString(16);o=s>>>24-n&16777215,(n+=2)>=26&&(n-=26,a--),i=0!==o||a!==this.length-1?c[6-h.length]+h+i:h+i}for(0!==o&&(i=o.toString(16)+i);i.length%e!=0;)i="0"+i;return 0!==this.negative&&(i="-"+i),i}if(t===(0|t)&&t>=2&&t<=36){var u=d[t],l=f[t];i="";var m=this.clone();for(m.negative=0;!m.isZero();){var p=m.modrn(l).toString(t);i=(m=m.idivn(l)).isZero()?p+i:c[u-p.length]+p+i}for(this.isZero()&&(i="0"+i);i.length%e!=0;)i="0"+i;return 0!==this.negative&&(i="-"+i),i}r(!1,"Base should be between 2 and 36")},n.prototype.toNumber=function(){var t=this.words[0];return 2===this.length?t+=67108864*this.words[1]:3===this.length&&1===this.words[2]?t+=4503599627370496+67108864*this.words[1]:this.length>2&&r(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-t:t},n.prototype.toJSON=function(){return this.toString(16,2)},o&&(n.prototype.toBuffer=function(t,e){return this.toArrayLike(o,t,e)}),n.prototype.toArray=function(t,e){return this.toArrayLike(Array,t,e)};function m(t,e,r){r.negative=e.negative^t.negative;var i=t.length+e.length|0;r.length=i,i=i-1|0;var n=0|t.words[0],o=0|e.words[0],a=n*o,s=67108863&a,h=a/67108864|0;r.words[0]=s;for(var u=1;u<i;u++){for(var l=h>>>26,c=67108863&h,d=Math.min(u,e.length-1),f=Math.max(0,u-t.length+1);f<=d;f++){var m=u-f|0;l+=(a=(n=0|t.words[m])*(o=0|e.words[f])+c)/67108864|0,c=67108863&a}r.words[u]=0|c,h=0|l}return 0!==h?r.words[u]=0|h:r.length--,r._strip()}n.prototype.toArrayLike=function(t,e,i){this._strip();var n=this.byteLength(),o=i||Math.max(1,n);r(n<=o,"byte array longer than desired length"),r(o>0,"Requested array length <= 0");var a=function(t,e){return t.allocUnsafe?t.allocUnsafe(e):new t(e)}(t,o);return this["_toArrayLike"+("le"===e?"LE":"BE")](a,n),a},n.prototype._toArrayLikeLE=function(t,e){for(var r=0,i=0,n=0,o=0;n<this.length;n++){var a=this.words[n]<<o|i;t[r++]=255&a,r<t.length&&(t[r++]=a>>8&255),r<t.length&&(t[r++]=a>>16&255),6===o?(r<t.length&&(t[r++]=a>>24&255),i=0,o=0):(i=a>>>24,o+=2)}if(r<t.length)for(t[r++]=i;r<t.length;)t[r++]=0},n.prototype._toArrayLikeBE=function(t,e){for(var r=t.length-1,i=0,n=0,o=0;n<this.length;n++){var a=this.words[n]<<o|i;t[r--]=255&a,r>=0&&(t[r--]=a>>8&255),r>=0&&(t[r--]=a>>16&255),6===o?(r>=0&&(t[r--]=a>>24&255),i=0,o=0):(i=a>>>24,o+=2)}if(r>=0)for(t[r--]=i;r>=0;)t[r--]=0},Math.clz32?n.prototype._countBits=function(t){return 32-Math.clz32(t)}:n.prototype._countBits=function(t){var e=t,r=0;return e>=4096&&(r+=13,e>>>=13),e>=64&&(r+=7,e>>>=7),e>=8&&(r+=4,e>>>=4),e>=2&&(r+=2,e>>>=2),r+e},n.prototype._zeroBits=function(t){if(0===t)return 26;var e=t,r=0;return 0==(8191&e)&&(r+=13,e>>>=13),0==(127&e)&&(r+=7,e>>>=7),0==(15&e)&&(r+=4,e>>>=4),0==(3&e)&&(r+=2,e>>>=2),0==(1&e)&&r++,r},n.prototype.bitLength=function(){var t=this.words[this.length-1],e=this._countBits(t);return 26*(this.length-1)+e},n.prototype.zeroBits=function(){if(this.isZero())return 0;for(var t=0,e=0;e<this.length;e++){var r=this._zeroBits(this.words[e]);if(t+=r,26!==r)break}return t},n.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},n.prototype.toTwos=function(t){return 0!==this.negative?this.abs().inotn(t).iaddn(1):this.clone()},n.prototype.fromTwos=function(t){return this.testn(t-1)?this.notn(t).iaddn(1).ineg():this.clone()},n.prototype.isNeg=function(){return 0!==this.negative},n.prototype.neg=function(){return this.clone().ineg()},n.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},n.prototype.iuor=function(t){for(;this.length<t.length;)this.words[this.length++]=0;for(var e=0;e<t.length;e++)this.words[e]=this.words[e]|t.words[e];return this._strip()},n.prototype.ior=function(t){return r(0==(this.negative|t.negative)),this.iuor(t)},n.prototype.or=function(t){return this.length>t.length?this.clone().ior(t):t.clone().ior(this)},n.prototype.uor=function(t){return this.length>t.length?this.clone().iuor(t):t.clone().iuor(this)},n.prototype.iuand=function(t){var e;e=this.length>t.length?t:this;for(var r=0;r<e.length;r++)this.words[r]=this.words[r]&t.words[r];return this.length=e.length,this._strip()},n.prototype.iand=function(t){return r(0==(this.negative|t.negative)),this.iuand(t)},n.prototype.and=function(t){return this.length>t.length?this.clone().iand(t):t.clone().iand(this)},n.prototype.uand=function(t){return this.length>t.length?this.clone().iuand(t):t.clone().iuand(this)},n.prototype.iuxor=function(t){var e,r;this.length>t.length?(e=this,r=t):(e=t,r=this);for(var i=0;i<r.length;i++)this.words[i]=e.words[i]^r.words[i];if(this!==e)for(;i<e.length;i++)this.words[i]=e.words[i];return this.length=e.length,this._strip()},n.prototype.ixor=function(t){return r(0==(this.negative|t.negative)),this.iuxor(t)},n.prototype.xor=function(t){return this.length>t.length?this.clone().ixor(t):t.clone().ixor(this)},n.prototype.uxor=function(t){return this.length>t.length?this.clone().iuxor(t):t.clone().iuxor(this)},n.prototype.inotn=function(t){r("number"==typeof t&&t>=0);var e=0|Math.ceil(t/26),i=t%26;this._expand(e),i>0&&e--;for(var n=0;n<e;n++)this.words[n]=67108863&~this.words[n];return i>0&&(this.words[n]=~this.words[n]&67108863>>26-i),this._strip()},n.prototype.notn=function(t){return this.clone().inotn(t)},n.prototype.setn=function(t,e){r("number"==typeof t&&t>=0);var i=t/26|0,n=t%26;return this._expand(i+1),this.words[i]=e?this.words[i]|1<<n:this.words[i]&~(1<<n),this._strip()},n.prototype.iadd=function(t){var e,r,i;if(0!==this.negative&&0===t.negative)return this.negative=0,e=this.isub(t),this.negative^=1,this._normSign();if(0===this.negative&&0!==t.negative)return t.negative=0,e=this.isub(t),t.negative=1,e._normSign();this.length>t.length?(r=this,i=t):(r=t,i=this);for(var n=0,o=0;o<i.length;o++)e=(0|r.words[o])+(0|i.words[o])+n,this.words[o]=67108863&e,n=e>>>26;for(;0!==n&&o<r.length;o++)e=(0|r.words[o])+n,this.words[o]=67108863&e,n=e>>>26;if(this.length=r.length,0!==n)this.words[this.length]=n,this.length++;else if(r!==this)for(;o<r.length;o++)this.words[o]=r.words[o];return this},n.prototype.add=function(t){var e;return 0!==t.negative&&0===this.negative?(t.negative=0,e=this.sub(t),t.negative^=1,e):0===t.negative&&0!==this.negative?(this.negative=0,e=t.sub(this),this.negative=1,e):this.length>t.length?this.clone().iadd(t):t.clone().iadd(this)},n.prototype.isub=function(t){if(0!==t.negative){t.negative=0;var e=this.iadd(t);return t.negative=1,e._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(t),this.negative=1,this._normSign();var r,i,n=this.cmp(t);if(0===n)return this.negative=0,this.length=1,this.words[0]=0,this;n>0?(r=this,i=t):(r=t,i=this);for(var o=0,a=0;a<i.length;a++)o=(e=(0|r.words[a])-(0|i.words[a])+o)>>26,this.words[a]=67108863&e;for(;0!==o&&a<r.length;a++)o=(e=(0|r.words[a])+o)>>26,this.words[a]=67108863&e;if(0===o&&a<r.length&&r!==this)for(;a<r.length;a++)this.words[a]=r.words[a];return this.length=Math.max(this.length,a),r!==this&&(this.negative=1),this._strip()},n.prototype.sub=function(t){return this.clone().isub(t)};var p=function(t,e,r){var i,n,o,a=t.words,s=e.words,h=r.words,u=0,l=0|a[0],c=8191&l,d=l>>>13,f=0|a[1],m=8191&f,p=f>>>13,g=0|a[2],y=8191&g,w=g>>>13,v=0|a[3],b=8191&v,k=v>>>13,M=0|a[4],_=8191&M,E=M>>>13,A=0|a[5],j=8191&A,x=A>>>13,S=0|a[6],N=8191&S,I=S>>>13,T=0|a[7],C=8191&T,z=T>>>13,O=0|a[8],R=8191&O,P=O>>>13,B=0|a[9],D=8191&B,$=B>>>13,L=0|s[0],F=8191&L,U=L>>>13,q=0|s[1],V=8191&q,H=q>>>13,G=0|s[2],Z=8191&G,K=G>>>13,J=0|s[3],W=8191&J,Y=J>>>13,Q=0|s[4],X=8191&Q,tt=Q>>>13,et=0|s[5],rt=8191&et,it=et>>>13,nt=0|s[6],ot=8191&nt,at=nt>>>13,st=0|s[7],ht=8191&st,ut=st>>>13,lt=0|s[8],ct=8191&lt,dt=lt>>>13,ft=0|s[9],mt=8191&ft,pt=ft>>>13;r.negative=t.negative^e.negative,r.length=19;var gt=(u+(i=Math.imul(c,F))|0)+((8191&(n=(n=Math.imul(c,U))+Math.imul(d,F)|0))<<13)|0;u=((o=Math.imul(d,U))+(n>>>13)|0)+(gt>>>26)|0,gt&=67108863,i=Math.imul(m,F),n=(n=Math.imul(m,U))+Math.imul(p,F)|0,o=Math.imul(p,U);var yt=(u+(i=i+Math.imul(c,V)|0)|0)+((8191&(n=(n=n+Math.imul(c,H)|0)+Math.imul(d,V)|0))<<13)|0;u=((o=o+Math.imul(d,H)|0)+(n>>>13)|0)+(yt>>>26)|0,yt&=67108863,i=Math.imul(y,F),n=(n=Math.imul(y,U))+Math.imul(w,F)|0,o=Math.imul(w,U),i=i+Math.imul(m,V)|0,n=(n=n+Math.imul(m,H)|0)+Math.imul(p,V)|0,o=o+Math.imul(p,H)|0;var wt=(u+(i=i+Math.imul(c,Z)|0)|0)+((8191&(n=(n=n+Math.imul(c,K)|0)+Math.imul(d,Z)|0))<<13)|0;u=((o=o+Math.imul(d,K)|0)+(n>>>13)|0)+(wt>>>26)|0,wt&=67108863,i=Math.imul(b,F),n=(n=Math.imul(b,U))+Math.imul(k,F)|0,o=Math.imul(k,U),i=i+Math.imul(y,V)|0,n=(n=n+Math.imul(y,H)|0)+Math.imul(w,V)|0,o=o+Math.imul(w,H)|0,i=i+Math.imul(m,Z)|0,n=(n=n+Math.imul(m,K)|0)+Math.imul(p,Z)|0,o=o+Math.imul(p,K)|0;var vt=(u+(i=i+Math.imul(c,W)|0)|0)+((8191&(n=(n=n+Math.imul(c,Y)|0)+Math.imul(d,W)|0))<<13)|0;u=((o=o+Math.imul(d,Y)|0)+(n>>>13)|0)+(vt>>>26)|0,vt&=67108863,i=Math.imul(_,F),n=(n=Math.imul(_,U))+Math.imul(E,F)|0,o=Math.imul(E,U),i=i+Math.imul(b,V)|0,n=(n=n+Math.imul(b,H)|0)+Math.imul(k,V)|0,o=o+Math.imul(k,H)|0,i=i+Math.imul(y,Z)|0,n=(n=n+Math.imul(y,K)|0)+Math.imul(w,Z)|0,o=o+Math.imul(w,K)|0,i=i+Math.imul(m,W)|0,n=(n=n+Math.imul(m,Y)|0)+Math.imul(p,W)|0,o=o+Math.imul(p,Y)|0;var bt=(u+(i=i+Math.imul(c,X)|0)|0)+((8191&(n=(n=n+Math.imul(c,tt)|0)+Math.imul(d,X)|0))<<13)|0;u=((o=o+Math.imul(d,tt)|0)+(n>>>13)|0)+(bt>>>26)|0,bt&=67108863,i=Math.imul(j,F),n=(n=Math.imul(j,U))+Math.imul(x,F)|0,o=Math.imul(x,U),i=i+Math.imul(_,V)|0,n=(n=n+Math.imul(_,H)|0)+Math.imul(E,V)|0,o=o+Math.imul(E,H)|0,i=i+Math.imul(b,Z)|0,n=(n=n+Math.imul(b,K)|0)+Math.imul(k,Z)|0,o=o+Math.imul(k,K)|0,i=i+Math.imul(y,W)|0,n=(n=n+Math.imul(y,Y)|0)+Math.imul(w,W)|0,o=o+Math.imul(w,Y)|0,i=i+Math.imul(m,X)|0,n=(n=n+Math.imul(m,tt)|0)+Math.imul(p,X)|0,o=o+Math.imul(p,tt)|0;var kt=(u+(i=i+Math.imul(c,rt)|0)|0)+((8191&(n=(n=n+Math.imul(c,it)|0)+Math.imul(d,rt)|0))<<13)|0;u=((o=o+Math.imul(d,it)|0)+(n>>>13)|0)+(kt>>>26)|0,kt&=67108863,i=Math.imul(N,F),n=(n=Math.imul(N,U))+Math.imul(I,F)|0,o=Math.imul(I,U),i=i+Math.imul(j,V)|0,n=(n=n+Math.imul(j,H)|0)+Math.imul(x,V)|0,o=o+Math.imul(x,H)|0,i=i+Math.imul(_,Z)|0,n=(n=n+Math.imul(_,K)|0)+Math.imul(E,Z)|0,o=o+Math.imul(E,K)|0,i=i+Math.imul(b,W)|0,n=(n=n+Math.imul(b,Y)|0)+Math.imul(k,W)|0,o=o+Math.imul(k,Y)|0,i=i+Math.imul(y,X)|0,n=(n=n+Math.imul(y,tt)|0)+Math.imul(w,X)|0,o=o+Math.imul(w,tt)|0,i=i+Math.imul(m,rt)|0,n=(n=n+Math.imul(m,it)|0)+Math.imul(p,rt)|0,o=o+Math.imul(p,it)|0;var Mt=(u+(i=i+Math.imul(c,ot)|0)|0)+((8191&(n=(n=n+Math.imul(c,at)|0)+Math.imul(d,ot)|0))<<13)|0;u=((o=o+Math.imul(d,at)|0)+(n>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,i=Math.imul(C,F),n=(n=Math.imul(C,U))+Math.imul(z,F)|0,o=Math.imul(z,U),i=i+Math.imul(N,V)|0,n=(n=n+Math.imul(N,H)|0)+Math.imul(I,V)|0,o=o+Math.imul(I,H)|0,i=i+Math.imul(j,Z)|0,n=(n=n+Math.imul(j,K)|0)+Math.imul(x,Z)|0,o=o+Math.imul(x,K)|0,i=i+Math.imul(_,W)|0,n=(n=n+Math.imul(_,Y)|0)+Math.imul(E,W)|0,o=o+Math.imul(E,Y)|0,i=i+Math.imul(b,X)|0,n=(n=n+Math.imul(b,tt)|0)+Math.imul(k,X)|0,o=o+Math.imul(k,tt)|0,i=i+Math.imul(y,rt)|0,n=(n=n+Math.imul(y,it)|0)+Math.imul(w,rt)|0,o=o+Math.imul(w,it)|0,i=i+Math.imul(m,ot)|0,n=(n=n+Math.imul(m,at)|0)+Math.imul(p,ot)|0,o=o+Math.imul(p,at)|0;var _t=(u+(i=i+Math.imul(c,ht)|0)|0)+((8191&(n=(n=n+Math.imul(c,ut)|0)+Math.imul(d,ht)|0))<<13)|0;u=((o=o+Math.imul(d,ut)|0)+(n>>>13)|0)+(_t>>>26)|0,_t&=67108863,i=Math.imul(R,F),n=(n=Math.imul(R,U))+Math.imul(P,F)|0,o=Math.imul(P,U),i=i+Math.imul(C,V)|0,n=(n=n+Math.imul(C,H)|0)+Math.imul(z,V)|0,o=o+Math.imul(z,H)|0,i=i+Math.imul(N,Z)|0,n=(n=n+Math.imul(N,K)|0)+Math.imul(I,Z)|0,o=o+Math.imul(I,K)|0,i=i+Math.imul(j,W)|0,n=(n=n+Math.imul(j,Y)|0)+Math.imul(x,W)|0,o=o+Math.imul(x,Y)|0,i=i+Math.imul(_,X)|0,n=(n=n+Math.imul(_,tt)|0)+Math.imul(E,X)|0,o=o+Math.imul(E,tt)|0,i=i+Math.imul(b,rt)|0,n=(n=n+Math.imul(b,it)|0)+Math.imul(k,rt)|0,o=o+Math.imul(k,it)|0,i=i+Math.imul(y,ot)|0,n=(n=n+Math.imul(y,at)|0)+Math.imul(w,ot)|0,o=o+Math.imul(w,at)|0,i=i+Math.imul(m,ht)|0,n=(n=n+Math.imul(m,ut)|0)+Math.imul(p,ht)|0,o=o+Math.imul(p,ut)|0;var Et=(u+(i=i+Math.imul(c,ct)|0)|0)+((8191&(n=(n=n+Math.imul(c,dt)|0)+Math.imul(d,ct)|0))<<13)|0;u=((o=o+Math.imul(d,dt)|0)+(n>>>13)|0)+(Et>>>26)|0,Et&=67108863,i=Math.imul(D,F),n=(n=Math.imul(D,U))+Math.imul($,F)|0,o=Math.imul($,U),i=i+Math.imul(R,V)|0,n=(n=n+Math.imul(R,H)|0)+Math.imul(P,V)|0,o=o+Math.imul(P,H)|0,i=i+Math.imul(C,Z)|0,n=(n=n+Math.imul(C,K)|0)+Math.imul(z,Z)|0,o=o+Math.imul(z,K)|0,i=i+Math.imul(N,W)|0,n=(n=n+Math.imul(N,Y)|0)+Math.imul(I,W)|0,o=o+Math.imul(I,Y)|0,i=i+Math.imul(j,X)|0,n=(n=n+Math.imul(j,tt)|0)+Math.imul(x,X)|0,o=o+Math.imul(x,tt)|0,i=i+Math.imul(_,rt)|0,n=(n=n+Math.imul(_,it)|0)+Math.imul(E,rt)|0,o=o+Math.imul(E,it)|0,i=i+Math.imul(b,ot)|0,n=(n=n+Math.imul(b,at)|0)+Math.imul(k,ot)|0,o=o+Math.imul(k,at)|0,i=i+Math.imul(y,ht)|0,n=(n=n+Math.imul(y,ut)|0)+Math.imul(w,ht)|0,o=o+Math.imul(w,ut)|0,i=i+Math.imul(m,ct)|0,n=(n=n+Math.imul(m,dt)|0)+Math.imul(p,ct)|0,o=o+Math.imul(p,dt)|0;var At=(u+(i=i+Math.imul(c,mt)|0)|0)+((8191&(n=(n=n+Math.imul(c,pt)|0)+Math.imul(d,mt)|0))<<13)|0;u=((o=o+Math.imul(d,pt)|0)+(n>>>13)|0)+(At>>>26)|0,At&=67108863,i=Math.imul(D,V),n=(n=Math.imul(D,H))+Math.imul($,V)|0,o=Math.imul($,H),i=i+Math.imul(R,Z)|0,n=(n=n+Math.imul(R,K)|0)+Math.imul(P,Z)|0,o=o+Math.imul(P,K)|0,i=i+Math.imul(C,W)|0,n=(n=n+Math.imul(C,Y)|0)+Math.imul(z,W)|0,o=o+Math.imul(z,Y)|0,i=i+Math.imul(N,X)|0,n=(n=n+Math.imul(N,tt)|0)+Math.imul(I,X)|0,o=o+Math.imul(I,tt)|0,i=i+Math.imul(j,rt)|0,n=(n=n+Math.imul(j,it)|0)+Math.imul(x,rt)|0,o=o+Math.imul(x,it)|0,i=i+Math.imul(_,ot)|0,n=(n=n+Math.imul(_,at)|0)+Math.imul(E,ot)|0,o=o+Math.imul(E,at)|0,i=i+Math.imul(b,ht)|0,n=(n=n+Math.imul(b,ut)|0)+Math.imul(k,ht)|0,o=o+Math.imul(k,ut)|0,i=i+Math.imul(y,ct)|0,n=(n=n+Math.imul(y,dt)|0)+Math.imul(w,ct)|0,o=o+Math.imul(w,dt)|0;var jt=(u+(i=i+Math.imul(m,mt)|0)|0)+((8191&(n=(n=n+Math.imul(m,pt)|0)+Math.imul(p,mt)|0))<<13)|0;u=((o=o+Math.imul(p,pt)|0)+(n>>>13)|0)+(jt>>>26)|0,jt&=67108863,i=Math.imul(D,Z),n=(n=Math.imul(D,K))+Math.imul($,Z)|0,o=Math.imul($,K),i=i+Math.imul(R,W)|0,n=(n=n+Math.imul(R,Y)|0)+Math.imul(P,W)|0,o=o+Math.imul(P,Y)|0,i=i+Math.imul(C,X)|0,n=(n=n+Math.imul(C,tt)|0)+Math.imul(z,X)|0,o=o+Math.imul(z,tt)|0,i=i+Math.imul(N,rt)|0,n=(n=n+Math.imul(N,it)|0)+Math.imul(I,rt)|0,o=o+Math.imul(I,it)|0,i=i+Math.imul(j,ot)|0,n=(n=n+Math.imul(j,at)|0)+Math.imul(x,ot)|0,o=o+Math.imul(x,at)|0,i=i+Math.imul(_,ht)|0,n=(n=n+Math.imul(_,ut)|0)+Math.imul(E,ht)|0,o=o+Math.imul(E,ut)|0,i=i+Math.imul(b,ct)|0,n=(n=n+Math.imul(b,dt)|0)+Math.imul(k,ct)|0,o=o+Math.imul(k,dt)|0;var xt=(u+(i=i+Math.imul(y,mt)|0)|0)+((8191&(n=(n=n+Math.imul(y,pt)|0)+Math.imul(w,mt)|0))<<13)|0;u=((o=o+Math.imul(w,pt)|0)+(n>>>13)|0)+(xt>>>26)|0,xt&=67108863,i=Math.imul(D,W),n=(n=Math.imul(D,Y))+Math.imul($,W)|0,o=Math.imul($,Y),i=i+Math.imul(R,X)|0,n=(n=n+Math.imul(R,tt)|0)+Math.imul(P,X)|0,o=o+Math.imul(P,tt)|0,i=i+Math.imul(C,rt)|0,n=(n=n+Math.imul(C,it)|0)+Math.imul(z,rt)|0,o=o+Math.imul(z,it)|0,i=i+Math.imul(N,ot)|0,n=(n=n+Math.imul(N,at)|0)+Math.imul(I,ot)|0,o=o+Math.imul(I,at)|0,i=i+Math.imul(j,ht)|0,n=(n=n+Math.imul(j,ut)|0)+Math.imul(x,ht)|0,o=o+Math.imul(x,ut)|0,i=i+Math.imul(_,ct)|0,n=(n=n+Math.imul(_,dt)|0)+Math.imul(E,ct)|0,o=o+Math.imul(E,dt)|0;var St=(u+(i=i+Math.imul(b,mt)|0)|0)+((8191&(n=(n=n+Math.imul(b,pt)|0)+Math.imul(k,mt)|0))<<13)|0;u=((o=o+Math.imul(k,pt)|0)+(n>>>13)|0)+(St>>>26)|0,St&=67108863,i=Math.imul(D,X),n=(n=Math.imul(D,tt))+Math.imul($,X)|0,o=Math.imul($,tt),i=i+Math.imul(R,rt)|0,n=(n=n+Math.imul(R,it)|0)+Math.imul(P,rt)|0,o=o+Math.imul(P,it)|0,i=i+Math.imul(C,ot)|0,n=(n=n+Math.imul(C,at)|0)+Math.imul(z,ot)|0,o=o+Math.imul(z,at)|0,i=i+Math.imul(N,ht)|0,n=(n=n+Math.imul(N,ut)|0)+Math.imul(I,ht)|0,o=o+Math.imul(I,ut)|0,i=i+Math.imul(j,ct)|0,n=(n=n+Math.imul(j,dt)|0)+Math.imul(x,ct)|0,o=o+Math.imul(x,dt)|0;var Nt=(u+(i=i+Math.imul(_,mt)|0)|0)+((8191&(n=(n=n+Math.imul(_,pt)|0)+Math.imul(E,mt)|0))<<13)|0;u=((o=o+Math.imul(E,pt)|0)+(n>>>13)|0)+(Nt>>>26)|0,Nt&=67108863,i=Math.imul(D,rt),n=(n=Math.imul(D,it))+Math.imul($,rt)|0,o=Math.imul($,it),i=i+Math.imul(R,ot)|0,n=(n=n+Math.imul(R,at)|0)+Math.imul(P,ot)|0,o=o+Math.imul(P,at)|0,i=i+Math.imul(C,ht)|0,n=(n=n+Math.imul(C,ut)|0)+Math.imul(z,ht)|0,o=o+Math.imul(z,ut)|0,i=i+Math.imul(N,ct)|0,n=(n=n+Math.imul(N,dt)|0)+Math.imul(I,ct)|0,o=o+Math.imul(I,dt)|0;var It=(u+(i=i+Math.imul(j,mt)|0)|0)+((8191&(n=(n=n+Math.imul(j,pt)|0)+Math.imul(x,mt)|0))<<13)|0;u=((o=o+Math.imul(x,pt)|0)+(n>>>13)|0)+(It>>>26)|0,It&=67108863,i=Math.imul(D,ot),n=(n=Math.imul(D,at))+Math.imul($,ot)|0,o=Math.imul($,at),i=i+Math.imul(R,ht)|0,n=(n=n+Math.imul(R,ut)|0)+Math.imul(P,ht)|0,o=o+Math.imul(P,ut)|0,i=i+Math.imul(C,ct)|0,n=(n=n+Math.imul(C,dt)|0)+Math.imul(z,ct)|0,o=o+Math.imul(z,dt)|0;var Tt=(u+(i=i+Math.imul(N,mt)|0)|0)+((8191&(n=(n=n+Math.imul(N,pt)|0)+Math.imul(I,mt)|0))<<13)|0;u=((o=o+Math.imul(I,pt)|0)+(n>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,i=Math.imul(D,ht),n=(n=Math.imul(D,ut))+Math.imul($,ht)|0,o=Math.imul($,ut),i=i+Math.imul(R,ct)|0,n=(n=n+Math.imul(R,dt)|0)+Math.imul(P,ct)|0,o=o+Math.imul(P,dt)|0;var Ct=(u+(i=i+Math.imul(C,mt)|0)|0)+((8191&(n=(n=n+Math.imul(C,pt)|0)+Math.imul(z,mt)|0))<<13)|0;u=((o=o+Math.imul(z,pt)|0)+(n>>>13)|0)+(Ct>>>26)|0,Ct&=67108863,i=Math.imul(D,ct),n=(n=Math.imul(D,dt))+Math.imul($,ct)|0,o=Math.imul($,dt);var zt=(u+(i=i+Math.imul(R,mt)|0)|0)+((8191&(n=(n=n+Math.imul(R,pt)|0)+Math.imul(P,mt)|0))<<13)|0;u=((o=o+Math.imul(P,pt)|0)+(n>>>13)|0)+(zt>>>26)|0,zt&=67108863;var Ot=(u+(i=Math.imul(D,mt))|0)+((8191&(n=(n=Math.imul(D,pt))+Math.imul($,mt)|0))<<13)|0;return u=((o=Math.imul($,pt))+(n>>>13)|0)+(Ot>>>26)|0,Ot&=67108863,h[0]=gt,h[1]=yt,h[2]=wt,h[3]=vt,h[4]=bt,h[5]=kt,h[6]=Mt,h[7]=_t,h[8]=Et,h[9]=At,h[10]=jt,h[11]=xt,h[12]=St,h[13]=Nt,h[14]=It,h[15]=Tt,h[16]=Ct,h[17]=zt,h[18]=Ot,0!==u&&(h[19]=u,r.length++),r};function g(t,e,r){r.negative=e.negative^t.negative,r.length=t.length+e.length;for(var i=0,n=0,o=0;o<r.length-1;o++){var a=n;n=0;for(var s=67108863&i,h=Math.min(o,e.length-1),u=Math.max(0,o-t.length+1);u<=h;u++){var l=o-u,c=(0|t.words[l])*(0|e.words[u]),d=67108863&c;s=67108863&(d=d+s|0),n+=(a=(a=a+(c/67108864|0)|0)+(d>>>26)|0)>>>26,a&=67108863}r.words[o]=s,i=a,a=n}return 0!==i?r.words[o]=i:r.length--,r._strip()}function y(t,e,r){return g(t,e,r)}Math.imul||(p=m),n.prototype.mulTo=function(t,e){var r=this.length+t.length;return 10===this.length&&10===t.length?p(this,t,e):r<63?m(this,t,e):r<1024?g(this,t,e):y(this,t,e)},n.prototype.mul=function(t){var e=new n(null);return e.words=new Array(this.length+t.length),this.mulTo(t,e)},n.prototype.mulf=function(t){var e=new n(null);return e.words=new Array(this.length+t.length),y(this,t,e)},n.prototype.imul=function(t){return this.clone().mulTo(t,this)},n.prototype.imuln=function(t){var e=t<0;e&&(t=-t),r("number"==typeof t),r(t<67108864);for(var i=0,n=0;n<this.length;n++){var o=(0|this.words[n])*t,a=(67108863&o)+(67108863&i);i>>=26,i+=o/67108864|0,i+=a>>>26,this.words[n]=67108863&a}return 0!==i&&(this.words[n]=i,this.length++),e?this.ineg():this},n.prototype.muln=function(t){return this.clone().imuln(t)},n.prototype.sqr=function(){return this.mul(this)},n.prototype.isqr=function(){return this.imul(this.clone())},n.prototype.pow=function(t){var e=function(t){for(var e=new Array(t.bitLength()),r=0;r<e.length;r++){var i=r/26|0,n=r%26;e[r]=t.words[i]>>>n&1}return e}(t);if(0===e.length)return new n(1);for(var r=this,i=0;i<e.length&&0===e[i];i++,r=r.sqr());if(++i<e.length)for(var o=r.sqr();i<e.length;i++,o=o.sqr())0!==e[i]&&(r=r.mul(o));return r},n.prototype.iushln=function(t){r("number"==typeof t&&t>=0);var e,i=t%26,n=(t-i)/26,o=67108863>>>26-i<<26-i;if(0!==i){var a=0;for(e=0;e<this.length;e++){var s=this.words[e]&o,h=(0|this.words[e])-s<<i;this.words[e]=h|a,a=s>>>26-i}a&&(this.words[e]=a,this.length++)}if(0!==n){for(e=this.length-1;e>=0;e--)this.words[e+n]=this.words[e];for(e=0;e<n;e++)this.words[e]=0;this.length+=n}return this._strip()},n.prototype.ishln=function(t){return r(0===this.negative),this.iushln(t)},n.prototype.iushrn=function(t,e,i){var n;r("number"==typeof t&&t>=0),n=e?(e-e%26)/26:0;var o=t%26,a=Math.min((t-o)/26,this.length),s=67108863^67108863>>>o<<o,h=i;if(n-=a,n=Math.max(0,n),h){for(var u=0;u<a;u++)h.words[u]=this.words[u];h.length=a}if(0===a);else if(this.length>a)for(this.length-=a,u=0;u<this.length;u++)this.words[u]=this.words[u+a];else this.words[0]=0,this.length=1;var l=0;for(u=this.length-1;u>=0&&(0!==l||u>=n);u--){var c=0|this.words[u];this.words[u]=l<<26-o|c>>>o,l=c&s}return h&&0!==l&&(h.words[h.length++]=l),0===this.length&&(this.words[0]=0,this.length=1),this._strip()},n.prototype.ishrn=function(t,e,i){return r(0===this.negative),this.iushrn(t,e,i)},n.prototype.shln=function(t){return this.clone().ishln(t)},n.prototype.ushln=function(t){return this.clone().iushln(t)},n.prototype.shrn=function(t){return this.clone().ishrn(t)},n.prototype.ushrn=function(t){return this.clone().iushrn(t)},n.prototype.testn=function(t){r("number"==typeof t&&t>=0);var e=t%26,i=(t-e)/26,n=1<<e;return!(this.length<=i)&&!!(this.words[i]&n)},n.prototype.imaskn=function(t){r("number"==typeof t&&t>=0);var e=t%26,i=(t-e)/26;if(r(0===this.negative,"imaskn works only with positive numbers"),this.length<=i)return this;if(0!==e&&i++,this.length=Math.min(i,this.length),0!==e){var n=67108863^67108863>>>e<<e;this.words[this.length-1]&=n}return this._strip()},n.prototype.maskn=function(t){return this.clone().imaskn(t)},n.prototype.iaddn=function(t){return r("number"==typeof t),r(t<67108864),t<0?this.isubn(-t):0!==this.negative?1===this.length&&(0|this.words[0])<=t?(this.words[0]=t-(0|this.words[0]),this.negative=0,this):(this.negative=0,this.isubn(t),this.negative=1,this):this._iaddn(t)},n.prototype._iaddn=function(t){this.words[0]+=t;for(var e=0;e<this.length&&this.words[e]>=67108864;e++)this.words[e]-=67108864,e===this.length-1?this.words[e+1]=1:this.words[e+1]++;return this.length=Math.max(this.length,e+1),this},n.prototype.isubn=function(t){if(r("number"==typeof t),r(t<67108864),t<0)return this.iaddn(-t);if(0!==this.negative)return this.negative=0,this.iaddn(t),this.negative=1,this;if(this.words[0]-=t,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var e=0;e<this.length&&this.words[e]<0;e++)this.words[e]+=67108864,this.words[e+1]-=1;return this._strip()},n.prototype.addn=function(t){return this.clone().iaddn(t)},n.prototype.subn=function(t){return this.clone().isubn(t)},n.prototype.iabs=function(){return this.negative=0,this},n.prototype.abs=function(){return this.clone().iabs()},n.prototype._ishlnsubmul=function(t,e,i){var n,o,a=t.length+i;this._expand(a);var s=0;for(n=0;n<t.length;n++){o=(0|this.words[n+i])+s;var h=(0|t.words[n])*e;s=((o-=67108863&h)>>26)-(h/67108864|0),this.words[n+i]=67108863&o}for(;n<this.length-i;n++)s=(o=(0|this.words[n+i])+s)>>26,this.words[n+i]=67108863&o;if(0===s)return this._strip();for(r(-1===s),s=0,n=0;n<this.length;n++)s=(o=-(0|this.words[n])+s)>>26,this.words[n]=67108863&o;return this.negative=1,this._strip()},n.prototype._wordDiv=function(t,e){var r=(this.length,t.length),i=this.clone(),o=t,a=0|o.words[o.length-1];0!==(r=26-this._countBits(a))&&(o=o.ushln(r),i.iushln(r),a=0|o.words[o.length-1]);var s,h=i.length-o.length;if("mod"!==e){(s=new n(null)).length=h+1,s.words=new Array(s.length);for(var u=0;u<s.length;u++)s.words[u]=0}var l=i.clone()._ishlnsubmul(o,1,h);0===l.negative&&(i=l,s&&(s.words[h]=1));for(var c=h-1;c>=0;c--){var d=67108864*(0|i.words[o.length+c])+(0|i.words[o.length+c-1]);for(d=Math.min(d/a|0,67108863),i._ishlnsubmul(o,d,c);0!==i.negative;)d--,i.negative=0,i._ishlnsubmul(o,1,c),i.isZero()||(i.negative^=1);s&&(s.words[c]=d)}return s&&s._strip(),i._strip(),"div"!==e&&0!==r&&i.iushrn(r),{div:s||null,mod:i}},n.prototype.divmod=function(t,e,i){return r(!t.isZero()),this.isZero()?{div:new n(0),mod:new n(0)}:0!==this.negative&&0===t.negative?(s=this.neg().divmod(t,e),"mod"!==e&&(o=s.div.neg()),"div"!==e&&(a=s.mod.neg(),i&&0!==a.negative&&a.iadd(t)),{div:o,mod:a}):0===this.negative&&0!==t.negative?(s=this.divmod(t.neg(),e),"mod"!==e&&(o=s.div.neg()),{div:o,mod:s.mod}):0!=(this.negative&t.negative)?(s=this.neg().divmod(t.neg(),e),"div"!==e&&(a=s.mod.neg(),i&&0!==a.negative&&a.isub(t)),{div:s.div,mod:a}):t.length>this.length||this.cmp(t)<0?{div:new n(0),mod:this}:1===t.length?"div"===e?{div:this.divn(t.words[0]),mod:null}:"mod"===e?{div:null,mod:new n(this.modrn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new n(this.modrn(t.words[0]))}:this._wordDiv(t,e);var o,a,s},n.prototype.div=function(t){return this.divmod(t,"div",!1).div},n.prototype.mod=function(t){return this.divmod(t,"mod",!1).mod},n.prototype.umod=function(t){return this.divmod(t,"mod",!0).mod},n.prototype.divRound=function(t){var e=this.divmod(t);if(e.mod.isZero())return e.div;var r=0!==e.div.negative?e.mod.isub(t):e.mod,i=t.ushrn(1),n=t.andln(1),o=r.cmp(i);return o<0||1===n&&0===o?e.div:0!==e.div.negative?e.div.isubn(1):e.div.iaddn(1)},n.prototype.modrn=function(t){var e=t<0;e&&(t=-t),r(t<=67108863);for(var i=(1<<26)%t,n=0,o=this.length-1;o>=0;o--)n=(i*n+(0|this.words[o]))%t;return e?-n:n},n.prototype.modn=function(t){return this.modrn(t)},n.prototype.idivn=function(t){var e=t<0;e&&(t=-t),r(t<=67108863);for(var i=0,n=this.length-1;n>=0;n--){var o=(0|this.words[n])+67108864*i;this.words[n]=o/t|0,i=o%t}return this._strip(),e?this.ineg():this},n.prototype.divn=function(t){return this.clone().idivn(t)},n.prototype.egcd=function(t){r(0===t.negative),r(!t.isZero());var e=this,i=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var o=new n(1),a=new n(0),s=new n(0),h=new n(1),u=0;e.isEven()&&i.isEven();)e.iushrn(1),i.iushrn(1),++u;for(var l=i.clone(),c=e.clone();!e.isZero();){for(var d=0,f=1;0==(e.words[0]&f)&&d<26;++d,f<<=1);if(d>0)for(e.iushrn(d);d-- >0;)(o.isOdd()||a.isOdd())&&(o.iadd(l),a.isub(c)),o.iushrn(1),a.iushrn(1);for(var m=0,p=1;0==(i.words[0]&p)&&m<26;++m,p<<=1);if(m>0)for(i.iushrn(m);m-- >0;)(s.isOdd()||h.isOdd())&&(s.iadd(l),h.isub(c)),s.iushrn(1),h.iushrn(1);e.cmp(i)>=0?(e.isub(i),o.isub(s),a.isub(h)):(i.isub(e),s.isub(o),h.isub(a))}return{a:s,b:h,gcd:i.iushln(u)}},n.prototype._invmp=function(t){r(0===t.negative),r(!t.isZero());var e=this,i=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var o,a=new n(1),s=new n(0),h=i.clone();e.cmpn(1)>0&&i.cmpn(1)>0;){for(var u=0,l=1;0==(e.words[0]&l)&&u<26;++u,l<<=1);if(u>0)for(e.iushrn(u);u-- >0;)a.isOdd()&&a.iadd(h),a.iushrn(1);for(var c=0,d=1;0==(i.words[0]&d)&&c<26;++c,d<<=1);if(c>0)for(i.iushrn(c);c-- >0;)s.isOdd()&&s.iadd(h),s.iushrn(1);e.cmp(i)>=0?(e.isub(i),a.isub(s)):(i.isub(e),s.isub(a))}return(o=0===e.cmpn(1)?a:s).cmpn(0)<0&&o.iadd(t),o},n.prototype.gcd=function(t){if(this.isZero())return t.abs();if(t.isZero())return this.abs();var e=this.clone(),r=t.clone();e.negative=0,r.negative=0;for(var i=0;e.isEven()&&r.isEven();i++)e.iushrn(1),r.iushrn(1);for(;;){for(;e.isEven();)e.iushrn(1);for(;r.isEven();)r.iushrn(1);var n=e.cmp(r);if(n<0){var o=e;e=r,r=o}else if(0===n||0===r.cmpn(1))break;e.isub(r)}return r.iushln(i)},n.prototype.invm=function(t){return this.egcd(t).a.umod(t)},n.prototype.isEven=function(){return 0==(1&this.words[0])},n.prototype.isOdd=function(){return 1==(1&this.words[0])},n.prototype.andln=function(t){return this.words[0]&t},n.prototype.bincn=function(t){r("number"==typeof t);var e=t%26,i=(t-e)/26,n=1<<e;if(this.length<=i)return this._expand(i+1),this.words[i]|=n,this;for(var o=n,a=i;0!==o&&a<this.length;a++){var s=0|this.words[a];o=(s+=o)>>>26,s&=67108863,this.words[a]=s}return 0!==o&&(this.words[a]=o,this.length++),this},n.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},n.prototype.cmpn=function(t){var e,i=t<0;if(0!==this.negative&&!i)return-1;if(0===this.negative&&i)return 1;if(this._strip(),this.length>1)e=1;else{i&&(t=-t),r(t<=67108863,"Number is too big");var n=0|this.words[0];e=n===t?0:n<t?-1:1}return 0!==this.negative?0|-e:e},n.prototype.cmp=function(t){if(0!==this.negative&&0===t.negative)return-1;if(0===this.negative&&0!==t.negative)return 1;var e=this.ucmp(t);return 0!==this.negative?0|-e:e},n.prototype.ucmp=function(t){if(this.length>t.length)return 1;if(this.length<t.length)return-1;for(var e=0,r=this.length-1;r>=0;r--){var i=0|this.words[r],n=0|t.words[r];if(i!==n){i<n?e=-1:i>n&&(e=1);break}}return e},n.prototype.gtn=function(t){return 1===this.cmpn(t)},n.prototype.gt=function(t){return 1===this.cmp(t)},n.prototype.gten=function(t){return this.cmpn(t)>=0},n.prototype.gte=function(t){return this.cmp(t)>=0},n.prototype.ltn=function(t){return-1===this.cmpn(t)},n.prototype.lt=function(t){return-1===this.cmp(t)},n.prototype.lten=function(t){return this.cmpn(t)<=0},n.prototype.lte=function(t){return this.cmp(t)<=0},n.prototype.eqn=function(t){return 0===this.cmpn(t)},n.prototype.eq=function(t){return 0===this.cmp(t)},n.red=function(t){return new E(t)},n.prototype.toRed=function(t){return r(!this.red,"Already a number in reduction context"),r(0===this.negative,"red works only with positives"),t.convertTo(this)._forceRed(t)},n.prototype.fromRed=function(){return r(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},n.prototype._forceRed=function(t){return this.red=t,this},n.prototype.forceRed=function(t){return r(!this.red,"Already a number in reduction context"),this._forceRed(t)},n.prototype.redAdd=function(t){return r(this.red,"redAdd works only with red numbers"),this.red.add(this,t)},n.prototype.redIAdd=function(t){return r(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,t)},n.prototype.redSub=function(t){return r(this.red,"redSub works only with red numbers"),this.red.sub(this,t)},n.prototype.redISub=function(t){return r(this.red,"redISub works only with red numbers"),this.red.isub(this,t)},n.prototype.redShl=function(t){return r(this.red,"redShl works only with red numbers"),this.red.shl(this,t)},n.prototype.redMul=function(t){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.mul(this,t)},n.prototype.redIMul=function(t){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.imul(this,t)},n.prototype.redSqr=function(){return r(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},n.prototype.redISqr=function(){return r(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},n.prototype.redSqrt=function(){return r(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},n.prototype.redInvm=function(){return r(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},n.prototype.redNeg=function(){return r(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},n.prototype.redPow=function(t){return r(this.red&&!t.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,t)};var w={k256:null,p224:null,p192:null,p25519:null};function v(t,e){this.name=t,this.p=new n(e,16),this.n=this.p.bitLength(),this.k=new n(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function b(){v.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function k(){v.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function M(){v.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function _(){v.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function E(t){if("string"==typeof t){var e=n._prime(t);this.m=e.p,this.prime=e}else r(t.gtn(1),"modulus must be greater than 1"),this.m=t,this.prime=null}function A(t){E.call(this,t),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new n(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)}v.prototype._tmp=function(){var t=new n(null);return t.words=new Array(Math.ceil(this.n/13)),t},v.prototype.ireduce=function(t){var e,r=t;do{this.split(r,this.tmp),e=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(e>this.n);var i=e<this.n?-1:r.ucmp(this.p);return 0===i?(r.words[0]=0,r.length=1):i>0?r.isub(this.p):void 0!==r.strip?r.strip():r._strip(),r},v.prototype.split=function(t,e){t.iushrn(this.n,0,e)},v.prototype.imulK=function(t){return t.imul(this.k)},i(b,v),b.prototype.split=function(t,e){for(var r=4194303,i=Math.min(t.length,9),n=0;n<i;n++)e.words[n]=t.words[n];if(e.length=i,t.length<=9)return t.words[0]=0,void(t.length=1);var o=t.words[9];for(e.words[e.length++]=o&r,n=10;n<t.length;n++){var a=0|t.words[n];t.words[n-10]=(a&r)<<4|o>>>22,o=a}o>>>=22,t.words[n-10]=o,0===o&&t.length>10?t.length-=10:t.length-=9},b.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var e=0,r=0;r<t.length;r++){var i=0|t.words[r];e+=977*i,t.words[r]=67108863&e,e=64*i+(e/67108864|0)}return 0===t.words[t.length-1]&&(t.length--,0===t.words[t.length-1]&&t.length--),t},i(k,v),i(M,v),i(_,v),_.prototype.imulK=function(t){for(var e=0,r=0;r<t.length;r++){var i=19*(0|t.words[r])+e,n=67108863&i;i>>>=26,t.words[r]=n,e=i}return 0!==e&&(t.words[t.length++]=e),t},n._prime=function(t){if(w[t])return w[t];var e;if("k256"===t)e=new b;else if("p224"===t)e=new k;else if("p192"===t)e=new M;else{if("p25519"!==t)throw new Error("Unknown prime "+t);e=new _}return w[t]=e,e},E.prototype._verify1=function(t){r(0===t.negative,"red works only with positives"),r(t.red,"red works only with red numbers")},E.prototype._verify2=function(t,e){r(0==(t.negative|e.negative),"red works only with positives"),r(t.red&&t.red===e.red,"red works only with red numbers")},E.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):(u(t,t.umod(this.m)._forceRed(this)),t)},E.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},E.prototype.add=function(t,e){this._verify2(t,e);var r=t.add(e);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},E.prototype.iadd=function(t,e){this._verify2(t,e);var r=t.iadd(e);return r.cmp(this.m)>=0&&r.isub(this.m),r},E.prototype.sub=function(t,e){this._verify2(t,e);var r=t.sub(e);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},E.prototype.isub=function(t,e){this._verify2(t,e);var r=t.isub(e);return r.cmpn(0)<0&&r.iadd(this.m),r},E.prototype.shl=function(t,e){return this._verify1(t),this.imod(t.ushln(e))},E.prototype.imul=function(t,e){return this._verify2(t,e),this.imod(t.imul(e))},E.prototype.mul=function(t,e){return this._verify2(t,e),this.imod(t.mul(e))},E.prototype.isqr=function(t){return this.imul(t,t.clone())},E.prototype.sqr=function(t){return this.mul(t,t)},E.prototype.sqrt=function(t){if(t.isZero())return t.clone();var e=this.m.andln(3);if(r(e%2==1),3===e){var i=this.m.add(new n(1)).iushrn(2);return this.pow(t,i)}for(var o=this.m.subn(1),a=0;!o.isZero()&&0===o.andln(1);)a++,o.iushrn(1);r(!o.isZero());var s=new n(1).toRed(this),h=s.redNeg(),u=this.m.subn(1).iushrn(1),l=this.m.bitLength();for(l=new n(2*l*l).toRed(this);0!==this.pow(l,u).cmp(h);)l.redIAdd(h);for(var c=this.pow(l,o),d=this.pow(t,o.addn(1).iushrn(1)),f=this.pow(t,o),m=a;0!==f.cmp(s);){for(var p=f,g=0;0!==p.cmp(s);g++)p=p.redSqr();r(g<m);var y=this.pow(c,new n(1).iushln(m-g-1));d=d.redMul(y),c=y.redSqr(),f=f.redMul(c),m=g}return d},E.prototype.invm=function(t){var e=t._invmp(this.m);return 0!==e.negative?(e.negative=0,this.imod(e).redNeg()):this.imod(e)},E.prototype.pow=function(t,e){if(e.isZero())return new n(1).toRed(this);if(0===e.cmpn(1))return t.clone();var r=new Array(16);r[0]=new n(1).toRed(this),r[1]=t;for(var i=2;i<r.length;i++)r[i]=this.mul(r[i-1],t);var o=r[0],a=0,s=0,h=e.bitLength()%26;for(0===h&&(h=26),i=e.length-1;i>=0;i--){for(var u=e.words[i],l=h-1;l>=0;l--){var c=u>>l&1;o!==r[0]&&(o=this.sqr(o)),0!==c||0!==a?(a<<=1,a|=c,(4===++s||0===i&&0===l)&&(o=this.mul(o,r[a]),s=0,a=0)):s=0}h=26}return o},E.prototype.convertTo=function(t){var e=t.umod(this.m);return e===t?e.clone():e},E.prototype.convertFrom=function(t){var e=t.clone();return e.red=null,e},n.mont=function(t){return new A(t)},i(A,E),A.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},A.prototype.convertFrom=function(t){var e=this.imod(t.mul(this.rinv));return e.red=null,e},A.prototype.imul=function(t,e){if(t.isZero()||e.isZero())return t.words[0]=0,t.length=1,t;var r=t.imul(e),i=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),n=r.isub(i).iushrn(this.shift),o=n;return n.cmp(this.m)>=0?o=n.isub(this.m):n.cmpn(0)<0&&(o=n.iadd(this.m)),o._forceRed(this)},A.prototype.mul=function(t,e){if(t.isZero()||e.isZero())return new n(0)._forceRed(this);var r=t.mul(e),i=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),o=r.isub(i).iushrn(this.shift),a=o;return o.cmp(this.m)>=0?a=o.isub(this.m):o.cmpn(0)<0&&(a=o.iadd(this.m)),a._forceRed(this)},A.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}(t,i)}));var Qr=Yr.BN;const Xr=new w("bignumber/5.6.2"),ti={},ei=9007199254740991;let ri=!1;class ii{constructor(t,e){t!==ti&&Xr.throwError("cannot call constructor directly; use BigNumber.from",w.errors.UNSUPPORTED_OPERATION,{operation:"new (BigNumber)"}),this._hex=e,this._isBigNumber=!0,Object.freeze(this)}fromTwos(t){return oi(ai(this).fromTwos(t))}toTwos(t){return oi(ai(this).toTwos(t))}abs(){return"-"===this._hex[0]?ii.from(this._hex.substring(1)):this}add(t){return oi(ai(this).add(ai(t)))}sub(t){return oi(ai(this).sub(ai(t)))}div(t){return ii.from(t).isZero()&&si("division-by-zero","div"),oi(ai(this).div(ai(t)))}mul(t){return oi(ai(this).mul(ai(t)))}mod(t){const e=ai(t);return e.isNeg()&&si("division-by-zero","mod"),oi(ai(this).umod(e))}pow(t){const e=ai(t);return e.isNeg()&&si("negative-power","pow"),oi(ai(this).pow(e))}and(t){const e=ai(t);return(this.isNegative()||e.isNeg())&&si("unbound-bitwise-result","and"),oi(ai(this).and(e))}or(t){const e=ai(t);return(this.isNegative()||e.isNeg())&&si("unbound-bitwise-result","or"),oi(ai(this).or(e))}xor(t){const e=ai(t);return(this.isNegative()||e.isNeg())&&si("unbound-bitwise-result","xor"),oi(ai(this).xor(e))}mask(t){return(this.isNegative()||t<0)&&si("negative-width","mask"),oi(ai(this).maskn(t))}shl(t){return(this.isNegative()||t<0)&&si("negative-width","shl"),oi(ai(this).shln(t))}shr(t){return(this.isNegative()||t<0)&&si("negative-width","shr"),oi(ai(this).shrn(t))}eq(t){return ai(this).eq(ai(t))}lt(t){return ai(this).lt(ai(t))}lte(t){return ai(this).lte(ai(t))}gt(t){return ai(this).gt(ai(t))}gte(t){return ai(this).gte(ai(t))}isNegative(){return"-"===this._hex[0]}isZero(){return ai(this).isZero()}toNumber(){try{return ai(this).toNumber()}catch(t){si("overflow","toNumber",this.toString())}return null}toBigInt(){try{return BigInt(this.toString())}catch(t){}return Xr.throwError("this platform does not support BigInt",w.errors.UNSUPPORTED_OPERATION,{value:this.toString()})}toString(){return arguments.length>0&&(10===arguments[0]?ri||(ri=!0,Xr.warn("BigNumber.toString does not accept any parameters; base-10 is assumed")):16===arguments[0]?Xr.throwError("BigNumber.toString does not accept any parameters; use bigNumber.toHexString()",w.errors.UNEXPECTED_ARGUMENT,{}):Xr.throwError("BigNumber.toString does not accept parameters",w.errors.UNEXPECTED_ARGUMENT,{})),ai(this).toString(10)}toHexString(){return this._hex}toJSON(t){return{type:"BigNumber",hex:this.toHexString()}}static from(t){if(t instanceof ii)return t;if("string"==typeof t)return t.match(/^-?0x[0-9a-f]+$/i)?new ii(ti,ni(t)):t.match(/^-?[0-9]+$/)?new ii(ti,ni(new Qr(t))):Xr.throwArgumentError("invalid BigNumber string","value",t);if("number"==typeof t)return t%1&&si("underflow","BigNumber.from",t),(t>=ei||t<=-ei)&&si("overflow","BigNumber.from",t),ii.from(String(t));const e=t;if("bigint"==typeof e)return ii.from(e.toString());if(E(e))return ii.from(I(e));if(e)if(e.toHexString){const t=e.toHexString();if("string"==typeof t)return ii.from(t)}else{let t=e._hex;if(null==t&&"BigNumber"===e.type&&(t=e.hex),"string"==typeof t&&(S(t)||"-"===t[0]&&S(t.substring(1))))return ii.from(t)}return Xr.throwArgumentError("invalid BigNumber value","value",t)}static isBigNumber(t){return!(!t||!t._isBigNumber)}}function ni(t){if("string"!=typeof t)return ni(t.toString(16));if("-"===t[0])return"-"===(t=t.substring(1))[0]&&Xr.throwArgumentError("invalid hex","value",t),"0x00"===(t=ni(t))?t:"-"+t;if("0x"!==t.substring(0,2)&&(t="0x"+t),"0x"===t)return"0x00";for(t.length%2&&(t="0x0"+t.substring(2));t.length>4&&"0x00"===t.substring(0,4);)t="0x"+t.substring(4);return t}function oi(t){return ii.from(ni(t))}function ai(t){const e=ii.from(t).toHexString();return"-"===e[0]?new Qr("-"+e.substring(3),16):new Qr(e.substring(2),16)}function si(t,e,r){const i={fault:t,operation:e};return null!=r&&(i.value=r),Xr.throwError(t,w.errors.NUMERIC_FAULT,i)}const hi=ii.from(-1),ui=ii.from(0),li=ii.from(1),ci=ii.from("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");class di extends Br{constructor(t,e,r){const i=(e?"int":"uint")+8*t;super(i,i,r,!1),this.size=t,this.signed=e}defaultValue(){return 0}encode(t,e){let r=We.from(e),i=ci.mask(8*t.wordSize);if(this.signed){let t=i.mask(8*this.size-1);(r.gt(t)||r.lt(t.add(li).mul(hi)))&&this._throwError("value out-of-bounds",e)}else(r.lt(ui)||r.gt(i.mask(8*this.size)))&&this._throwError("value out-of-bounds",e);return r=r.toTwos(8*this.size).mask(8*this.size),this.signed&&(r=r.fromTwos(8*this.size).toTwos(8*t.wordSize)),t.writeValue(r)}decode(t){let e=t.readValue().mask(8*this.size);return this.signed&&(e=e.fromTwos(8*this.size)),t.coerce(this.name,e)}}const fi=new w("strings/5.6.1");var mi,pi;function gi(t,e,r,i,n){if(t===pi.BAD_PREFIX||t===pi.UNEXPECTED_CONTINUE){let t=0;for(let i=e+1;i<r.length&&r[i]>>6==2;i++)t++;return t}return t===pi.OVERRUN?r.length-e-1:0}!function(t){t.current="",t.NFC="NFC",t.NFD="NFD",t.NFKC="NFKC",t.NFKD="NFKD"}(mi||(mi={})),function(t){t.UNEXPECTED_CONTINUE="unexpected continuation byte",t.BAD_PREFIX="bad codepoint prefix",t.OVERRUN="string overrun",t.MISSING_CONTINUE="missing continuation byte",t.OUT_OF_RANGE="out of UTF-8 range",t.UTF16_SURROGATE="UTF-16 surrogate",t.OVERLONG="overlong representation"}(pi||(pi={}));const yi=Object.freeze({error:function(t,e,r,i,n){return fi.throwArgumentError(`invalid codepoint at offset ${e}; ${t}`,"bytes",r)},ignore:gi,replace:function(t,e,r,i,n){return t===pi.OVERLONG?(i.push(n),0):(i.push(65533),gi(t,e,r))}});function wi(t,e){null==e&&(e=yi.error),t=A(t);const r=[];let i=0;for(;i<t.length;){const n=t[i++];if(n>>7==0){r.push(n);continue}let o=null,a=null;if(192==(224&n))o=1,a=127;else if(224==(240&n))o=2,a=2047;else{if(240!=(248&n)){i+=e(128==(192&n)?pi.UNEXPECTED_CONTINUE:pi.BAD_PREFIX,i-1,t,r);continue}o=3,a=65535}if(i-1+o>=t.length){i+=e(pi.OVERRUN,i-1,t,r);continue}let s=n&(1<<8-o-1)-1;for(let n=0;n<o;n++){let n=t[i];if(128!=(192&n)){i+=e(pi.MISSING_CONTINUE,i,t,r),s=null;break}s=s<<6|63&n,i++}null!==s&&(s>1114111?i+=e(pi.OUT_OF_RANGE,i-1-o,t,r,s):s>=55296&&s<=57343?i+=e(pi.UTF16_SURROGATE,i-1-o,t,r,s):s<=a?i+=e(pi.OVERLONG,i-1-o,t,r,s):r.push(s))}return r}function vi(t,e=mi.current){e!=mi.current&&(fi.checkNormalize(),t=t.normalize(e));let r=[];for(let e=0;e<t.length;e++){const i=t.charCodeAt(e);if(i<128)r.push(i);else if(i<2048)r.push(i>>6|192),r.push(63&i|128);else if(55296==(64512&i)){e++;const n=t.charCodeAt(e);if(e>=t.length||56320!=(64512&n))throw new Error("invalid utf-8 string");const o=65536+((1023&i)<<10)+(1023&n);r.push(o>>18|240),r.push(o>>12&63|128),r.push(o>>6&63|128),r.push(63&o|128)}else r.push(i>>12|224),r.push(i>>6&63|128),r.push(63&i|128)}return A(r)}function bi(t){return t.map((t=>t<=65535?String.fromCharCode(t):(t-=65536,String.fromCharCode(55296+(t>>10&1023),56320+(1023&t))))).join("")}function ki(t,e){return bi(wi(t,e))}function Mi(t,e=mi.current){return wi(vi(t,e))}function _i(t,e){e||(e=function(t){return[parseInt(t,16)]});let r=0,i={};return t.split(",").forEach((t=>{let n=t.split(":");r+=parseInt(n[0],16),i[r]=e(n[1])})),i}function Ei(t){let e=0;return t.split(",").map((t=>{let r=t.split("-");1===r.length?r[1]="0":""===r[1]&&(r[1]="1");let i=e+parseInt(r[0],16);return e=parseInt(r[1],16),{l:i,h:e}}))}function Ai(t,e){let r=0;for(let i=0;i<e.length;i++){let n=e[i];if(r+=n.l,t>=r&&t<=r+n.h&&(t-r)%(n.d||1)==0){if(n.e&&-1!==n.e.indexOf(t-r))continue;return n}}return null}const ji=Ei("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"),xi="ad,34f,1806,180b,180c,180d,200b,200c,200d,2060,feff".split(",").map((t=>parseInt(t,16))),Si=[{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}],Ni=_i("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"),Ii=_i("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"),Ti=_i("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",(function(t){if(t.length%4!=0)throw new Error("bad data");let e=[];for(let r=0;r<t.length;r+=4)e.push(parseInt(t.substring(r,r+4),16));return e})),Ci=Ei("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 zi(t){if(t.match(/^[a-z0-9-]*$/i)&&t.length<=59)return t.toLowerCase();let e=Mi(t);var r;r=e.map((t=>{if(xi.indexOf(t)>=0)return[];if(t>=65024&&t<=65039)return[];let e=function(t){let e=Ai(t,Si);if(e)return[t+e.s];let r=Ni[t];if(r)return r;let i=Ii[t];return i?[t+i[0]]:Ti[t]||null}(t);return e||[t]})),e=r.reduce(((t,e)=>(e.forEach((e=>{t.push(e)})),t)),[]),e=Mi(bi(e),mi.NFKC),e.forEach((t=>{if(Ai(t,Ci))throw new Error("STRINGPREP_CONTAINS_PROHIBITED")})),e.forEach((t=>{if(Ai(t,ji))throw new Error("STRINGPREP_CONTAINS_UNASSIGNED")}));let i=bi(e);if("-"===i.substring(0,1)||"--"===i.substring(2,4)||"-"===i.substring(i.length-1))throw new Error("invalid hyphen");if(i.length>63)throw new Error("too long");return i}class Oi extends Zr{constructor(t){super("string",t)}defaultValue(){return""}encode(t,e){return super.encode(t,vi(e))}decode(t){return ki(super.decode(t))}}class Ri extends Br{constructor(t,e){let r=!1;const i=[];t.forEach((t=>{t.dynamic&&(r=!0),i.push(t.type)}));super("tuple","tuple("+i.join(",")+")",e,r),this.coders=t}defaultValue(){const t=[];this.coders.forEach((e=>{t.push(e.defaultValue())}));const e=this.coders.reduce(((t,e)=>{const r=e.localName;return r&&(t[r]||(t[r]=0),t[r]++),t}),{});return this.coders.forEach(((r,i)=>{let n=r.localName;n&&1===e[n]&&("length"===n&&(n="_length"),null==t[n]&&(t[n]=t[i]))})),Object.freeze(t)}encode(t,e){return qr(t,this.coders,e)}decode(t){return t.coerce(this.name,Vr(t,this.coders))}}const Pi=new w(dr),Bi=new RegExp(/^bytes([0-9]*)$/),Di=new RegExp(/^(u?int)([0-9]*)$/);class $i{constructor(t){ir(this,"coerceFunc",t||null)}_getCoder(t){switch(t.baseType){case"address":return new Lr(t.name);case"bool":return new Gr(t.name);case"string":return new Oi(t.name);case"bytes":return new Kr(t.name);case"array":return new Hr(this._getCoder(t.arrayChildren),t.arrayLength,t.name);case"tuple":return new Ri((t.components||[]).map((t=>this._getCoder(t))),t.name);case"":return new Wr(t.name)}let e=t.type.match(Di);if(e){let r=parseInt(e[2]||"256");return(0===r||r>256||r%8!=0)&&Pi.throwArgumentError("invalid "+e[1]+" bit length","param",t),new di(r/8,"int"===e[1],t.name)}if(e=t.type.match(Bi),e){let r=parseInt(e[1]);return(0===r||r>32)&&Pi.throwArgumentError("invalid bytes length","param",t),new Jr(r,t.name)}return Pi.throwArgumentError("invalid type","type",t.type)}_getWordSize(){return 32}_getReader(t,e){return new $r(t,this._getWordSize(),this.coerceFunc,e)}_getWriter(){return new Dr(this._getWordSize())}getDefaultValue(t){const e=t.map((t=>this._getCoder(kr.from(t))));return new Ri(e,"_").defaultValue()}encode(t,e){t.length!==e.length&&Pi.throwError("types/values length mismatch",w.errors.INVALID_ARGUMENT,{count:{types:t.length,values:e.length},value:{types:t,values:e}});const r=t.map((t=>this._getCoder(kr.from(t)))),i=new Ri(r,"_"),n=this._getWriter();return i.encode(n,e),n.data}decode(t,e,r){const i=t.map((t=>this._getCoder(kr.from(t))));return new Ri(i,"_").decode(this._getReader(A(e),r))}}const Li=new $i;function Fi(t){return Jt(vi(t))}const Ui=new w(dr);class qi extends cr{}class Vi extends cr{}class Hi extends cr{}class Gi extends cr{static isIndexed(t){return!(!t||!t._isIndexed)}}const Zi={"0x08c379a0":{signature:"Error(string)",name:"Error",inputs:["string"],reason:!0},"0x4e487b71":{signature:"Panic(uint256)",name:"Panic",inputs:["uint256"]}};function Ki(t,e){const r=new Error(`deferred error during ABI decoding triggered accessing ${t}`);return r.error=e,r}class Ji{constructor(t){let e=[];e="string"==typeof t?JSON.parse(t):t,ir(this,"fragments",e.map((t=>_r.from(t))).filter((t=>null!=t))),ir(this,"_abiCoder",nr(new.target,"getAbiCoder")()),ir(this,"functions",{}),ir(this,"errors",{}),ir(this,"events",{}),ir(this,"structs",{}),this.fragments.forEach((t=>{let e=null;switch(t.type){case"constructor":return this.deploy?void Ui.warn("duplicate definition - constructor"):void ir(this,"deploy",t);case"function":e=this.functions;break;case"event":e=this.events;break;case"error":e=this.errors;break;default:return}let r=t.format();e[r]?Ui.warn("duplicate definition - "+r):e[r]=t})),this.deploy||ir(this,"deploy",Sr.from({payable:!1,type:"constructor"})),ir(this,"_isInterface",!0)}format(t){t||(t=vr.full),t===vr.sighash&&Ui.throwArgumentError("interface does not support formatting sighash","format",t);const e=this.fragments.map((e=>e.format(t)));return t===vr.json?JSON.stringify(e.map((t=>JSON.parse(t)))):e}static getAbiCoder(){return Li}static getAddress(t){return he(t)}static getSighash(t){return C(Fi(t.format()),0,4)}static getEventTopic(t){return Fi(t.format())}getFunction(t){if(S(t)){for(const e in this.functions)if(t===this.getSighash(e))return this.functions[e];Ui.throwArgumentError("no matching function","sighash",t)}if(-1===t.indexOf("(")){const e=t.trim(),r=Object.keys(this.functions).filter((t=>t.split("(")[0]===e));return 0===r.length?Ui.throwArgumentError("no matching function","name",e):r.length>1&&Ui.throwArgumentError("multiple matching functions","name",e),this.functions[r[0]]}const e=this.functions[Nr.fromString(t).format()];return e||Ui.throwArgumentError("no matching function","signature",t),e}getEvent(t){if(S(t)){const e=t.toLowerCase();for(const t in this.events)if(e===this.getEventTopic(t))return this.events[t];Ui.throwArgumentError("no matching event","topichash",e)}if(-1===t.indexOf("(")){const e=t.trim(),r=Object.keys(this.events).filter((t=>t.split("(")[0]===e));return 0===r.length?Ui.throwArgumentError("no matching event","name",e):r.length>1&&Ui.throwArgumentError("multiple matching events","name",e),this.events[r[0]]}const e=this.events[Er.fromString(t).format()];return e||Ui.throwArgumentError("no matching event","signature",t),e}getError(t){if(S(t)){const e=nr(this.constructor,"getSighash");for(const r in this.errors){if(t===e(this.errors[r]))return this.errors[r]}Ui.throwArgumentError("no matching error","sighash",t)}if(-1===t.indexOf("(")){const e=t.trim(),r=Object.keys(this.errors).filter((t=>t.split("(")[0]===e));return 0===r.length?Ui.throwArgumentError("no matching error","name",e):r.length>1&&Ui.throwArgumentError("multiple matching errors","name",e),this.errors[r[0]]}const e=this.errors[Nr.fromString(t).format()];return e||Ui.throwArgumentError("no matching error","signature",t),e}getSighash(t){if("string"==typeof t)try{t=this.getFunction(t)}catch(e){try{t=this.getError(t)}catch(t){throw e}}return nr(this.constructor,"getSighash")(t)}getEventTopic(t){return"string"==typeof t&&(t=this.getEvent(t)),nr(this.constructor,"getEventTopic")(t)}_decodeParams(t,e){return this._abiCoder.decode(t,e)}_encodeParams(t,e){return this._abiCoder.encode(t,e)}encodeDeploy(t){return this._encodeParams(this.deploy.inputs,t||[])}decodeErrorResult(t,e){"string"==typeof t&&(t=this.getError(t));const r=A(e);return I(r.slice(0,4))!==this.getSighash(t)&&Ui.throwArgumentError(`data signature does not match error ${t.name}.`,"data",I(r)),this._decodeParams(t.inputs,r.slice(4))}encodeErrorResult(t,e){return"string"==typeof t&&(t=this.getError(t)),I(j([this.getSighash(t),this._encodeParams(t.inputs,e||[])]))}decodeFunctionData(t,e){"string"==typeof t&&(t=this.getFunction(t));const r=A(e);return I(r.slice(0,4))!==this.getSighash(t)&&Ui.throwArgumentError(`data signature does not match function ${t.name}.`,"data",I(r)),this._decodeParams(t.inputs,r.slice(4))}encodeFunctionData(t,e){return"string"==typeof t&&(t=this.getFunction(t)),I(j([this.getSighash(t),this._encodeParams(t.inputs,e||[])]))}decodeFunctionResult(t,e){"string"==typeof t&&(t=this.getFunction(t));let r=A(e),i=null,n="",o=null,a=null,s=null;switch(r.length%this._abiCoder._getWordSize()){case 0:try{return this._abiCoder.decode(t.outputs,r)}catch(t){}break;case 4:{const t=I(r.slice(0,4)),e=Zi[t];if(e)o=this._abiCoder.decode(e.inputs,r.slice(4)),a=e.name,s=e.signature,e.reason&&(i=o[0]),"Error"===a?n=`; VM Exception while processing transaction: reverted with reason string ${JSON.stringify(o[0])}`:"Panic"===a&&(n=`; VM Exception while processing transaction: reverted with panic code ${o[0]}`);else try{const e=this.getError(t);o=this._abiCoder.decode(e.inputs,r.slice(4)),a=e.name,s=e.format()}catch(t){}break}}return Ui.throwError("call revert exception"+n,w.errors.CALL_EXCEPTION,{method:t.format(),data:I(e),errorArgs:o,errorName:a,errorSignature:s,reason:i})}encodeFunctionResult(t,e){return"string"==typeof t&&(t=this.getFunction(t)),I(this._abiCoder.encode(t.outputs,e||[]))}encodeFilterTopics(t,e){"string"==typeof t&&(t=this.getEvent(t)),e.length>t.inputs.length&&Ui.throwError("too many arguments for "+t.format(),w.errors.UNEXPECTED_ARGUMENT,{argument:"values",value:e});let r=[];t.anonymous||r.push(this.getEventTopic(t));const i=(t,e)=>"string"===t.type?Fi(e):"bytes"===t.type?Jt(I(e)):("bool"===t.type&&"boolean"==typeof e&&(e=e?"0x01":"0x00"),t.type.match(/^u?int/)&&(e=We.from(e).toHexString()),"address"===t.type&&this._abiCoder.encode(["address"],[e]),R(I(e),32));for(e.forEach(((e,n)=>{let o=t.inputs[n];o.indexed?null==e?r.push(null):"array"===o.baseType||"tuple"===o.baseType?Ui.throwArgumentError("filtering with tuples or arrays not supported","contract."+o.name,e):Array.isArray(e)?r.push(e.map((t=>i(o,t)))):r.push(i(o,e)):null!=e&&Ui.throwArgumentError("cannot filter non-indexed parameters; must be null","contract."+o.name,e)}));r.length&&null===r[r.length-1];)r.pop();return r}encodeEventLog(t,e){"string"==typeof t&&(t=this.getEvent(t));const r=[],i=[],n=[];return t.anonymous||r.push(this.getEventTopic(t)),e.length!==t.inputs.length&&Ui.throwArgumentError("event arguments/values mismatch","values",e),t.inputs.forEach(((t,o)=>{const a=e[o];if(t.indexed)if("string"===t.type)r.push(Fi(a));else if("bytes"===t.type)r.push(Jt(a));else{if("tuple"===t.baseType||"array"===t.baseType)throw new Error("not implemented");r.push(this._abiCoder.encode([t.type],[a]))}else i.push(t),n.push(a)})),{data:this._abiCoder.encode(i,n),topics:r}}decodeEventLog(t,e,r){if("string"==typeof t&&(t=this.getEvent(t)),null!=r&&!t.anonymous){let e=this.getEventTopic(t);S(r[0],32)&&r[0].toLowerCase()===e||Ui.throwError("fragment/topic mismatch",w.errors.INVALID_ARGUMENT,{argument:"topics[0]",expected:e,value:r[0]}),r=r.slice(1)}let i=[],n=[],o=[];t.inputs.forEach(((t,e)=>{t.indexed?"string"===t.type||"bytes"===t.type||"tuple"===t.baseType||"array"===t.baseType?(i.push(kr.fromObject({type:"bytes32",name:t.name})),o.push(!0)):(i.push(t),o.push(!1)):(n.push(t),o.push(!1))}));let a=null!=r?this._abiCoder.decode(i,j(r)):null,s=this._abiCoder.decode(n,e,!0),h=[],u=0,l=0;t.inputs.forEach(((t,e)=>{if(t.indexed)if(null==a)h[e]=new Gi({_isIndexed:!0,hash:null});else if(o[e])h[e]=new Gi({_isIndexed:!0,hash:a[l++]});else try{h[e]=a[l++]}catch(t){h[e]=t}else try{h[e]=s[u++]}catch(t){h[e]=t}if(t.name&&null==h[t.name]){const r=h[e];r instanceof Error?Object.defineProperty(h,t.name,{enumerable:!0,get:()=>{throw Ki(`property ${JSON.stringify(t.name)}`,r)}}):h[t.name]=r}}));for(let t=0;t<h.length;t++){const e=h[t];e instanceof Error&&Object.defineProperty(h,t,{enumerable:!0,get:()=>{throw Ki(`index ${t}`,e)}})}return Object.freeze(h)}parseTransaction(t){let e=this.getFunction(t.data.substring(0,10).toLowerCase());return e?new Vi({args:this._abiCoder.decode(e.inputs,"0x"+t.data.substring(10)),functionFragment:e,name:e.name,signature:e.format(),sighash:this.getSighash(e),value:We.from(t.value||"0")}):null}parseLog(t){let e=this.getEvent(t.topics[0]);return!e||e.anonymous?null:new qi({eventFragment:e,name:e.name,signature:e.format(),topic:this.getEventTopic(e),args:this.decodeEventLog(e,t.data,t.topics)})}parseError(t){const e=I(t);let r=this.getError(e.substring(0,10).toLowerCase());return r?new Hi({args:this._abiCoder.decode(r.inputs,"0x"+e.substring(10)),errorFragment:r,name:r.name,signature:r.format(),sighash:this.getSighash(r)}):null}static isInterface(t){return!(!t||!t._isInterface)}}var Wi=a((function(t){!function(t,e){function r(t,e){if(!t)throw new Error(e||"Assertion failed")}function i(t,e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}function n(t,e,r){if(n.isBN(t))return t;this.negative=0,this.words=null,this.length=0,this.red=null,null!==t&&("le"!==e&&"be"!==e||(r=e,e=10),this._init(t||0,e||10,r||"be"))}var o;"object"==typeof t?t.exports=n:e.BN=n,n.BN=n,n.wordSize=26;try{o="undefined"!=typeof window&&void 0!==window.Buffer?window.Buffer:Pt.Buffer}catch(t){}function a(t,e){var i=t.charCodeAt(e);return i>=48&&i<=57?i-48:i>=65&&i<=70?i-55:i>=97&&i<=102?i-87:void r(!1,"Invalid character in "+t)}function s(t,e,r){var i=a(t,r);return r-1>=e&&(i|=a(t,r-1)<<4),i}function h(t,e,i,n){for(var o=0,a=0,s=Math.min(t.length,i),h=e;h<s;h++){var u=t.charCodeAt(h)-48;o*=n,a=u>=49?u-49+10:u>=17?u-17+10:u,r(u>=0&&a<n,"Invalid character"),o+=a}return o}function u(t,e){t.words=e.words,t.length=e.length,t.negative=e.negative,t.red=e.red}if(n.isBN=function(t){return t instanceof n||null!==t&&"object"==typeof t&&t.constructor.wordSize===n.wordSize&&Array.isArray(t.words)},n.max=function(t,e){return t.cmp(e)>0?t:e},n.min=function(t,e){return t.cmp(e)<0?t:e},n.prototype._init=function(t,e,i){if("number"==typeof t)return this._initNumber(t,e,i);if("object"==typeof t)return this._initArray(t,e,i);"hex"===e&&(e=16),r(e===(0|e)&&e>=2&&e<=36);var n=0;"-"===(t=t.toString().replace(/\s+/g,""))[0]&&(n++,this.negative=1),n<t.length&&(16===e?this._parseHex(t,n,i):(this._parseBase(t,e,n),"le"===i&&this._initArray(this.toArray(),e,i)))},n.prototype._initNumber=function(t,e,i){t<0&&(this.negative=1,t=-t),t<67108864?(this.words=[67108863&t],this.length=1):t<4503599627370496?(this.words=[67108863&t,t/67108864&67108863],this.length=2):(r(t<9007199254740992),this.words=[67108863&t,t/67108864&67108863,1],this.length=3),"le"===i&&this._initArray(this.toArray(),e,i)},n.prototype._initArray=function(t,e,i){if(r("number"==typeof t.length),t.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(t.length/3),this.words=new Array(this.length);for(var n=0;n<this.length;n++)this.words[n]=0;var o,a,s=0;if("be"===i)for(n=t.length-1,o=0;n>=0;n-=3)a=t[n]|t[n-1]<<8|t[n-2]<<16,this.words[o]|=a<<s&67108863,this.words[o+1]=a>>>26-s&67108863,(s+=24)>=26&&(s-=26,o++);else if("le"===i)for(n=0,o=0;n<t.length;n+=3)a=t[n]|t[n+1]<<8|t[n+2]<<16,this.words[o]|=a<<s&67108863,this.words[o+1]=a>>>26-s&67108863,(s+=24)>=26&&(s-=26,o++);return this._strip()},n.prototype._parseHex=function(t,e,r){this.length=Math.ceil((t.length-e)/6),this.words=new Array(this.length);for(var i=0;i<this.length;i++)this.words[i]=0;var n,o=0,a=0;if("be"===r)for(i=t.length-1;i>=e;i-=2)n=s(t,e,i)<<o,this.words[a]|=67108863&n,o>=18?(o-=18,a+=1,this.words[a]|=n>>>26):o+=8;else for(i=(t.length-e)%2==0?e+1:e;i<t.length;i+=2)n=s(t,e,i)<<o,this.words[a]|=67108863&n,o>=18?(o-=18,a+=1,this.words[a]|=n>>>26):o+=8;this._strip()},n.prototype._parseBase=function(t,e,r){this.words=[0],this.length=1;for(var i=0,n=1;n<=67108863;n*=e)i++;i--,n=n/e|0;for(var o=t.length-r,a=o%i,s=Math.min(o,o-a)+r,u=0,l=r;l<s;l+=i)u=h(t,l,l+i,e),this.imuln(n),this.words[0]+u<67108864?this.words[0]+=u:this._iaddn(u);if(0!==a){var c=1;for(u=h(t,l,t.length,e),l=0;l<a;l++)c*=e;this.imuln(c),this.words[0]+u<67108864?this.words[0]+=u:this._iaddn(u)}this._strip()},n.prototype.copy=function(t){t.words=new Array(this.length);for(var e=0;e<this.length;e++)t.words[e]=this.words[e];t.length=this.length,t.negative=this.negative,t.red=this.red},n.prototype._move=function(t){u(t,this)},n.prototype.clone=function(){var t=new n(null);return this.copy(t),t},n.prototype._expand=function(t){for(;this.length<t;)this.words[this.length++]=0;return this},n.prototype._strip=function(){for(;this.length>1&&0===this.words[this.length-1];)this.length--;return this._normSign()},n.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},"undefined"!=typeof Symbol&&"function"==typeof Symbol.for)try{n.prototype[Symbol.for("nodejs.util.inspect.custom")]=l}catch(t){n.prototype.inspect=l}else n.prototype.inspect=l;function l(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"}var c=["","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"],d=[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],f=[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];n.prototype.toString=function(t,e){var i;if(e=0|e||1,16===(t=t||10)||"hex"===t){i="";for(var n=0,o=0,a=0;a<this.length;a++){var s=this.words[a],h=(16777215&(s<<n|o)).toString(16);o=s>>>24-n&16777215,(n+=2)>=26&&(n-=26,a--),i=0!==o||a!==this.length-1?c[6-h.length]+h+i:h+i}for(0!==o&&(i=o.toString(16)+i);i.length%e!=0;)i="0"+i;return 0!==this.negative&&(i="-"+i),i}if(t===(0|t)&&t>=2&&t<=36){var u=d[t],l=f[t];i="";var m=this.clone();for(m.negative=0;!m.isZero();){var p=m.modrn(l).toString(t);i=(m=m.idivn(l)).isZero()?p+i:c[u-p.length]+p+i}for(this.isZero()&&(i="0"+i);i.length%e!=0;)i="0"+i;return 0!==this.negative&&(i="-"+i),i}r(!1,"Base should be between 2 and 36")},n.prototype.toNumber=function(){var t=this.words[0];return 2===this.length?t+=67108864*this.words[1]:3===this.length&&1===this.words[2]?t+=4503599627370496+67108864*this.words[1]:this.length>2&&r(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-t:t},n.prototype.toJSON=function(){return this.toString(16,2)},o&&(n.prototype.toBuffer=function(t,e){return this.toArrayLike(o,t,e)}),n.prototype.toArray=function(t,e){return this.toArrayLike(Array,t,e)};function m(t,e,r){r.negative=e.negative^t.negative;var i=t.length+e.length|0;r.length=i,i=i-1|0;var n=0|t.words[0],o=0|e.words[0],a=n*o,s=67108863&a,h=a/67108864|0;r.words[0]=s;for(var u=1;u<i;u++){for(var l=h>>>26,c=67108863&h,d=Math.min(u,e.length-1),f=Math.max(0,u-t.length+1);f<=d;f++){var m=u-f|0;l+=(a=(n=0|t.words[m])*(o=0|e.words[f])+c)/67108864|0,c=67108863&a}r.words[u]=0|c,h=0|l}return 0!==h?r.words[u]=0|h:r.length--,r._strip()}n.prototype.toArrayLike=function(t,e,i){this._strip();var n=this.byteLength(),o=i||Math.max(1,n);r(n<=o,"byte array longer than desired length"),r(o>0,"Requested array length <= 0");var a=function(t,e){return t.allocUnsafe?t.allocUnsafe(e):new t(e)}(t,o);return this["_toArrayLike"+("le"===e?"LE":"BE")](a,n),a},n.prototype._toArrayLikeLE=function(t,e){for(var r=0,i=0,n=0,o=0;n<this.length;n++){var a=this.words[n]<<o|i;t[r++]=255&a,r<t.length&&(t[r++]=a>>8&255),r<t.length&&(t[r++]=a>>16&255),6===o?(r<t.length&&(t[r++]=a>>24&255),i=0,o=0):(i=a>>>24,o+=2)}if(r<t.length)for(t[r++]=i;r<t.length;)t[r++]=0},n.prototype._toArrayLikeBE=function(t,e){for(var r=t.length-1,i=0,n=0,o=0;n<this.length;n++){var a=this.words[n]<<o|i;t[r--]=255&a,r>=0&&(t[r--]=a>>8&255),r>=0&&(t[r--]=a>>16&255),6===o?(r>=0&&(t[r--]=a>>24&255),i=0,o=0):(i=a>>>24,o+=2)}if(r>=0)for(t[r--]=i;r>=0;)t[r--]=0},Math.clz32?n.prototype._countBits=function(t){return 32-Math.clz32(t)}:n.prototype._countBits=function(t){var e=t,r=0;return e>=4096&&(r+=13,e>>>=13),e>=64&&(r+=7,e>>>=7),e>=8&&(r+=4,e>>>=4),e>=2&&(r+=2,e>>>=2),r+e},n.prototype._zeroBits=function(t){if(0===t)return 26;var e=t,r=0;return 0==(8191&e)&&(r+=13,e>>>=13),0==(127&e)&&(r+=7,e>>>=7),0==(15&e)&&(r+=4,e>>>=4),0==(3&e)&&(r+=2,e>>>=2),0==(1&e)&&r++,r},n.prototype.bitLength=function(){var t=this.words[this.length-1],e=this._countBits(t);return 26*(this.length-1)+e},n.prototype.zeroBits=function(){if(this.isZero())return 0;for(var t=0,e=0;e<this.length;e++){var r=this._zeroBits(this.words[e]);if(t+=r,26!==r)break}return t},n.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},n.prototype.toTwos=function(t){return 0!==this.negative?this.abs().inotn(t).iaddn(1):this.clone()},n.prototype.fromTwos=function(t){return this.testn(t-1)?this.notn(t).iaddn(1).ineg():this.clone()},n.prototype.isNeg=function(){return 0!==this.negative},n.prototype.neg=function(){return this.clone().ineg()},n.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},n.prototype.iuor=function(t){for(;this.length<t.length;)this.words[this.length++]=0;for(var e=0;e<t.length;e++)this.words[e]=this.words[e]|t.words[e];return this._strip()},n.prototype.ior=function(t){return r(0==(this.negative|t.negative)),this.iuor(t)},n.prototype.or=function(t){return this.length>t.length?this.clone().ior(t):t.clone().ior(this)},n.prototype.uor=function(t){return this.length>t.length?this.clone().iuor(t):t.clone().iuor(this)},n.prototype.iuand=function(t){var e;e=this.length>t.length?t:this;for(var r=0;r<e.length;r++)this.words[r]=this.words[r]&t.words[r];return this.length=e.length,this._strip()},n.prototype.iand=function(t){return r(0==(this.negative|t.negative)),this.iuand(t)},n.prototype.and=function(t){return this.length>t.length?this.clone().iand(t):t.clone().iand(this)},n.prototype.uand=function(t){return this.length>t.length?this.clone().iuand(t):t.clone().iuand(this)},n.prototype.iuxor=function(t){var e,r;this.length>t.length?(e=this,r=t):(e=t,r=this);for(var i=0;i<r.length;i++)this.words[i]=e.words[i]^r.words[i];if(this!==e)for(;i<e.length;i++)this.words[i]=e.words[i];return this.length=e.length,this._strip()},n.prototype.ixor=function(t){return r(0==(this.negative|t.negative)),this.iuxor(t)},n.prototype.xor=function(t){return this.length>t.length?this.clone().ixor(t):t.clone().ixor(this)},n.prototype.uxor=function(t){return this.length>t.length?this.clone().iuxor(t):t.clone().iuxor(this)},n.prototype.inotn=function(t){r("number"==typeof t&&t>=0);var e=0|Math.ceil(t/26),i=t%26;this._expand(e),i>0&&e--;for(var n=0;n<e;n++)this.words[n]=67108863&~this.words[n];return i>0&&(this.words[n]=~this.words[n]&67108863>>26-i),this._strip()},n.prototype.notn=function(t){return this.clone().inotn(t)},n.prototype.setn=function(t,e){r("number"==typeof t&&t>=0);var i=t/26|0,n=t%26;return this._expand(i+1),this.words[i]=e?this.words[i]|1<<n:this.words[i]&~(1<<n),this._strip()},n.prototype.iadd=function(t){var e,r,i;if(0!==this.negative&&0===t.negative)return this.negative=0,e=this.isub(t),this.negative^=1,this._normSign();if(0===this.negative&&0!==t.negative)return t.negative=0,e=this.isub(t),t.negative=1,e._normSign();this.length>t.length?(r=this,i=t):(r=t,i=this);for(var n=0,o=0;o<i.length;o++)e=(0|r.words[o])+(0|i.words[o])+n,this.words[o]=67108863&e,n=e>>>26;for(;0!==n&&o<r.length;o++)e=(0|r.words[o])+n,this.words[o]=67108863&e,n=e>>>26;if(this.length=r.length,0!==n)this.words[this.length]=n,this.length++;else if(r!==this)for(;o<r.length;o++)this.words[o]=r.words[o];return this},n.prototype.add=function(t){var e;return 0!==t.negative&&0===this.negative?(t.negative=0,e=this.sub(t),t.negative^=1,e):0===t.negative&&0!==this.negative?(this.negative=0,e=t.sub(this),this.negative=1,e):this.length>t.length?this.clone().iadd(t):t.clone().iadd(this)},n.prototype.isub=function(t){if(0!==t.negative){t.negative=0;var e=this.iadd(t);return t.negative=1,e._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(t),this.negative=1,this._normSign();var r,i,n=this.cmp(t);if(0===n)return this.negative=0,this.length=1,this.words[0]=0,this;n>0?(r=this,i=t):(r=t,i=this);for(var o=0,a=0;a<i.length;a++)o=(e=(0|r.words[a])-(0|i.words[a])+o)>>26,this.words[a]=67108863&e;for(;0!==o&&a<r.length;a++)o=(e=(0|r.words[a])+o)>>26,this.words[a]=67108863&e;if(0===o&&a<r.length&&r!==this)for(;a<r.length;a++)this.words[a]=r.words[a];return this.length=Math.max(this.length,a),r!==this&&(this.negative=1),this._strip()},n.prototype.sub=function(t){return this.clone().isub(t)};var p=function(t,e,r){var i,n,o,a=t.words,s=e.words,h=r.words,u=0,l=0|a[0],c=8191&l,d=l>>>13,f=0|a[1],m=8191&f,p=f>>>13,g=0|a[2],y=8191&g,w=g>>>13,v=0|a[3],b=8191&v,k=v>>>13,M=0|a[4],_=8191&M,E=M>>>13,A=0|a[5],j=8191&A,x=A>>>13,S=0|a[6],N=8191&S,I=S>>>13,T=0|a[7],C=8191&T,z=T>>>13,O=0|a[8],R=8191&O,P=O>>>13,B=0|a[9],D=8191&B,$=B>>>13,L=0|s[0],F=8191&L,U=L>>>13,q=0|s[1],V=8191&q,H=q>>>13,G=0|s[2],Z=8191&G,K=G>>>13,J=0|s[3],W=8191&J,Y=J>>>13,Q=0|s[4],X=8191&Q,tt=Q>>>13,et=0|s[5],rt=8191&et,it=et>>>13,nt=0|s[6],ot=8191&nt,at=nt>>>13,st=0|s[7],ht=8191&st,ut=st>>>13,lt=0|s[8],ct=8191&lt,dt=lt>>>13,ft=0|s[9],mt=8191&ft,pt=ft>>>13;r.negative=t.negative^e.negative,r.length=19;var gt=(u+(i=Math.imul(c,F))|0)+((8191&(n=(n=Math.imul(c,U))+Math.imul(d,F)|0))<<13)|0;u=((o=Math.imul(d,U))+(n>>>13)|0)+(gt>>>26)|0,gt&=67108863,i=Math.imul(m,F),n=(n=Math.imul(m,U))+Math.imul(p,F)|0,o=Math.imul(p,U);var yt=(u+(i=i+Math.imul(c,V)|0)|0)+((8191&(n=(n=n+Math.imul(c,H)|0)+Math.imul(d,V)|0))<<13)|0;u=((o=o+Math.imul(d,H)|0)+(n>>>13)|0)+(yt>>>26)|0,yt&=67108863,i=Math.imul(y,F),n=(n=Math.imul(y,U))+Math.imul(w,F)|0,o=Math.imul(w,U),i=i+Math.imul(m,V)|0,n=(n=n+Math.imul(m,H)|0)+Math.imul(p,V)|0,o=o+Math.imul(p,H)|0;var wt=(u+(i=i+Math.imul(c,Z)|0)|0)+((8191&(n=(n=n+Math.imul(c,K)|0)+Math.imul(d,Z)|0))<<13)|0;u=((o=o+Math.imul(d,K)|0)+(n>>>13)|0)+(wt>>>26)|0,wt&=67108863,i=Math.imul(b,F),n=(n=Math.imul(b,U))+Math.imul(k,F)|0,o=Math.imul(k,U),i=i+Math.imul(y,V)|0,n=(n=n+Math.imul(y,H)|0)+Math.imul(w,V)|0,o=o+Math.imul(w,H)|0,i=i+Math.imul(m,Z)|0,n=(n=n+Math.imul(m,K)|0)+Math.imul(p,Z)|0,o=o+Math.imul(p,K)|0;var vt=(u+(i=i+Math.imul(c,W)|0)|0)+((8191&(n=(n=n+Math.imul(c,Y)|0)+Math.imul(d,W)|0))<<13)|0;u=((o=o+Math.imul(d,Y)|0)+(n>>>13)|0)+(vt>>>26)|0,vt&=67108863,i=Math.imul(_,F),n=(n=Math.imul(_,U))+Math.imul(E,F)|0,o=Math.imul(E,U),i=i+Math.imul(b,V)|0,n=(n=n+Math.imul(b,H)|0)+Math.imul(k,V)|0,o=o+Math.imul(k,H)|0,i=i+Math.imul(y,Z)|0,n=(n=n+Math.imul(y,K)|0)+Math.imul(w,Z)|0,o=o+Math.imul(w,K)|0,i=i+Math.imul(m,W)|0,n=(n=n+Math.imul(m,Y)|0)+Math.imul(p,W)|0,o=o+Math.imul(p,Y)|0;var bt=(u+(i=i+Math.imul(c,X)|0)|0)+((8191&(n=(n=n+Math.imul(c,tt)|0)+Math.imul(d,X)|0))<<13)|0;u=((o=o+Math.imul(d,tt)|0)+(n>>>13)|0)+(bt>>>26)|0,bt&=67108863,i=Math.imul(j,F),n=(n=Math.imul(j,U))+Math.imul(x,F)|0,o=Math.imul(x,U),i=i+Math.imul(_,V)|0,n=(n=n+Math.imul(_,H)|0)+Math.imul(E,V)|0,o=o+Math.imul(E,H)|0,i=i+Math.imul(b,Z)|0,n=(n=n+Math.imul(b,K)|0)+Math.imul(k,Z)|0,o=o+Math.imul(k,K)|0,i=i+Math.imul(y,W)|0,n=(n=n+Math.imul(y,Y)|0)+Math.imul(w,W)|0,o=o+Math.imul(w,Y)|0,i=i+Math.imul(m,X)|0,n=(n=n+Math.imul(m,tt)|0)+Math.imul(p,X)|0,o=o+Math.imul(p,tt)|0;var kt=(u+(i=i+Math.imul(c,rt)|0)|0)+((8191&(n=(n=n+Math.imul(c,it)|0)+Math.imul(d,rt)|0))<<13)|0;u=((o=o+Math.imul(d,it)|0)+(n>>>13)|0)+(kt>>>26)|0,kt&=67108863,i=Math.imul(N,F),n=(n=Math.imul(N,U))+Math.imul(I,F)|0,o=Math.imul(I,U),i=i+Math.imul(j,V)|0,n=(n=n+Math.imul(j,H)|0)+Math.imul(x,V)|0,o=o+Math.imul(x,H)|0,i=i+Math.imul(_,Z)|0,n=(n=n+Math.imul(_,K)|0)+Math.imul(E,Z)|0,o=o+Math.imul(E,K)|0,i=i+Math.imul(b,W)|0,n=(n=n+Math.imul(b,Y)|0)+Math.imul(k,W)|0,o=o+Math.imul(k,Y)|0,i=i+Math.imul(y,X)|0,n=(n=n+Math.imul(y,tt)|0)+Math.imul(w,X)|0,o=o+Math.imul(w,tt)|0,i=i+Math.imul(m,rt)|0,n=(n=n+Math.imul(m,it)|0)+Math.imul(p,rt)|0,o=o+Math.imul(p,it)|0;var Mt=(u+(i=i+Math.imul(c,ot)|0)|0)+((8191&(n=(n=n+Math.imul(c,at)|0)+Math.imul(d,ot)|0))<<13)|0;u=((o=o+Math.imul(d,at)|0)+(n>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,i=Math.imul(C,F),n=(n=Math.imul(C,U))+Math.imul(z,F)|0,o=Math.imul(z,U),i=i+Math.imul(N,V)|0,n=(n=n+Math.imul(N,H)|0)+Math.imul(I,V)|0,o=o+Math.imul(I,H)|0,i=i+Math.imul(j,Z)|0,n=(n=n+Math.imul(j,K)|0)+Math.imul(x,Z)|0,o=o+Math.imul(x,K)|0,i=i+Math.imul(_,W)|0,n=(n=n+Math.imul(_,Y)|0)+Math.imul(E,W)|0,o=o+Math.imul(E,Y)|0,i=i+Math.imul(b,X)|0,n=(n=n+Math.imul(b,tt)|0)+Math.imul(k,X)|0,o=o+Math.imul(k,tt)|0,i=i+Math.imul(y,rt)|0,n=(n=n+Math.imul(y,it)|0)+Math.imul(w,rt)|0,o=o+Math.imul(w,it)|0,i=i+Math.imul(m,ot)|0,n=(n=n+Math.imul(m,at)|0)+Math.imul(p,ot)|0,o=o+Math.imul(p,at)|0;var _t=(u+(i=i+Math.imul(c,ht)|0)|0)+((8191&(n=(n=n+Math.imul(c,ut)|0)+Math.imul(d,ht)|0))<<13)|0;u=((o=o+Math.imul(d,ut)|0)+(n>>>13)|0)+(_t>>>26)|0,_t&=67108863,i=Math.imul(R,F),n=(n=Math.imul(R,U))+Math.imul(P,F)|0,o=Math.imul(P,U),i=i+Math.imul(C,V)|0,n=(n=n+Math.imul(C,H)|0)+Math.imul(z,V)|0,o=o+Math.imul(z,H)|0,i=i+Math.imul(N,Z)|0,n=(n=n+Math.imul(N,K)|0)+Math.imul(I,Z)|0,o=o+Math.imul(I,K)|0,i=i+Math.imul(j,W)|0,n=(n=n+Math.imul(j,Y)|0)+Math.imul(x,W)|0,o=o+Math.imul(x,Y)|0,i=i+Math.imul(_,X)|0,n=(n=n+Math.imul(_,tt)|0)+Math.imul(E,X)|0,o=o+Math.imul(E,tt)|0,i=i+Math.imul(b,rt)|0,n=(n=n+Math.imul(b,it)|0)+Math.imul(k,rt)|0,o=o+Math.imul(k,it)|0,i=i+Math.imul(y,ot)|0,n=(n=n+Math.imul(y,at)|0)+Math.imul(w,ot)|0,o=o+Math.imul(w,at)|0,i=i+Math.imul(m,ht)|0,n=(n=n+Math.imul(m,ut)|0)+Math.imul(p,ht)|0,o=o+Math.imul(p,ut)|0;var Et=(u+(i=i+Math.imul(c,ct)|0)|0)+((8191&(n=(n=n+Math.imul(c,dt)|0)+Math.imul(d,ct)|0))<<13)|0;u=((o=o+Math.imul(d,dt)|0)+(n>>>13)|0)+(Et>>>26)|0,Et&=67108863,i=Math.imul(D,F),n=(n=Math.imul(D,U))+Math.imul($,F)|0,o=Math.imul($,U),i=i+Math.imul(R,V)|0,n=(n=n+Math.imul(R,H)|0)+Math.imul(P,V)|0,o=o+Math.imul(P,H)|0,i=i+Math.imul(C,Z)|0,n=(n=n+Math.imul(C,K)|0)+Math.imul(z,Z)|0,o=o+Math.imul(z,K)|0,i=i+Math.imul(N,W)|0,n=(n=n+Math.imul(N,Y)|0)+Math.imul(I,W)|0,o=o+Math.imul(I,Y)|0,i=i+Math.imul(j,X)|0,n=(n=n+Math.imul(j,tt)|0)+Math.imul(x,X)|0,o=o+Math.imul(x,tt)|0,i=i+Math.imul(_,rt)|0,n=(n=n+Math.imul(_,it)|0)+Math.imul(E,rt)|0,o=o+Math.imul(E,it)|0,i=i+Math.imul(b,ot)|0,n=(n=n+Math.imul(b,at)|0)+Math.imul(k,ot)|0,o=o+Math.imul(k,at)|0,i=i+Math.imul(y,ht)|0,n=(n=n+Math.imul(y,ut)|0)+Math.imul(w,ht)|0,o=o+Math.imul(w,ut)|0,i=i+Math.imul(m,ct)|0,n=(n=n+Math.imul(m,dt)|0)+Math.imul(p,ct)|0,o=o+Math.imul(p,dt)|0;var At=(u+(i=i+Math.imul(c,mt)|0)|0)+((8191&(n=(n=n+Math.imul(c,pt)|0)+Math.imul(d,mt)|0))<<13)|0;u=((o=o+Math.imul(d,pt)|0)+(n>>>13)|0)+(At>>>26)|0,At&=67108863,i=Math.imul(D,V),n=(n=Math.imul(D,H))+Math.imul($,V)|0,o=Math.imul($,H),i=i+Math.imul(R,Z)|0,n=(n=n+Math.imul(R,K)|0)+Math.imul(P,Z)|0,o=o+Math.imul(P,K)|0,i=i+Math.imul(C,W)|0,n=(n=n+Math.imul(C,Y)|0)+Math.imul(z,W)|0,o=o+Math.imul(z,Y)|0,i=i+Math.imul(N,X)|0,n=(n=n+Math.imul(N,tt)|0)+Math.imul(I,X)|0,o=o+Math.imul(I,tt)|0,i=i+Math.imul(j,rt)|0,n=(n=n+Math.imul(j,it)|0)+Math.imul(x,rt)|0,o=o+Math.imul(x,it)|0,i=i+Math.imul(_,ot)|0,n=(n=n+Math.imul(_,at)|0)+Math.imul(E,ot)|0,o=o+Math.imul(E,at)|0,i=i+Math.imul(b,ht)|0,n=(n=n+Math.imul(b,ut)|0)+Math.imul(k,ht)|0,o=o+Math.imul(k,ut)|0,i=i+Math.imul(y,ct)|0,n=(n=n+Math.imul(y,dt)|0)+Math.imul(w,ct)|0,o=o+Math.imul(w,dt)|0;var jt=(u+(i=i+Math.imul(m,mt)|0)|0)+((8191&(n=(n=n+Math.imul(m,pt)|0)+Math.imul(p,mt)|0))<<13)|0;u=((o=o+Math.imul(p,pt)|0)+(n>>>13)|0)+(jt>>>26)|0,jt&=67108863,i=Math.imul(D,Z),n=(n=Math.imul(D,K))+Math.imul($,Z)|0,o=Math.imul($,K),i=i+Math.imul(R,W)|0,n=(n=n+Math.imul(R,Y)|0)+Math.imul(P,W)|0,o=o+Math.imul(P,Y)|0,i=i+Math.imul(C,X)|0,n=(n=n+Math.imul(C,tt)|0)+Math.imul(z,X)|0,o=o+Math.imul(z,tt)|0,i=i+Math.imul(N,rt)|0,n=(n=n+Math.imul(N,it)|0)+Math.imul(I,rt)|0,o=o+Math.imul(I,it)|0,i=i+Math.imul(j,ot)|0,n=(n=n+Math.imul(j,at)|0)+Math.imul(x,ot)|0,o=o+Math.imul(x,at)|0,i=i+Math.imul(_,ht)|0,n=(n=n+Math.imul(_,ut)|0)+Math.imul(E,ht)|0,o=o+Math.imul(E,ut)|0,i=i+Math.imul(b,ct)|0,n=(n=n+Math.imul(b,dt)|0)+Math.imul(k,ct)|0,o=o+Math.imul(k,dt)|0;var xt=(u+(i=i+Math.imul(y,mt)|0)|0)+((8191&(n=(n=n+Math.imul(y,pt)|0)+Math.imul(w,mt)|0))<<13)|0;u=((o=o+Math.imul(w,pt)|0)+(n>>>13)|0)+(xt>>>26)|0,xt&=67108863,i=Math.imul(D,W),n=(n=Math.imul(D,Y))+Math.imul($,W)|0,o=Math.imul($,Y),i=i+Math.imul(R,X)|0,n=(n=n+Math.imul(R,tt)|0)+Math.imul(P,X)|0,o=o+Math.imul(P,tt)|0,i=i+Math.imul(C,rt)|0,n=(n=n+Math.imul(C,it)|0)+Math.imul(z,rt)|0,o=o+Math.imul(z,it)|0,i=i+Math.imul(N,ot)|0,n=(n=n+Math.imul(N,at)|0)+Math.imul(I,ot)|0,o=o+Math.imul(I,at)|0,i=i+Math.imul(j,ht)|0,n=(n=n+Math.imul(j,ut)|0)+Math.imul(x,ht)|0,o=o+Math.imul(x,ut)|0,i=i+Math.imul(_,ct)|0,n=(n=n+Math.imul(_,dt)|0)+Math.imul(E,ct)|0,o=o+Math.imul(E,dt)|0;var St=(u+(i=i+Math.imul(b,mt)|0)|0)+((8191&(n=(n=n+Math.imul(b,pt)|0)+Math.imul(k,mt)|0))<<13)|0;u=((o=o+Math.imul(k,pt)|0)+(n>>>13)|0)+(St>>>26)|0,St&=67108863,i=Math.imul(D,X),n=(n=Math.imul(D,tt))+Math.imul($,X)|0,o=Math.imul($,tt),i=i+Math.imul(R,rt)|0,n=(n=n+Math.imul(R,it)|0)+Math.imul(P,rt)|0,o=o+Math.imul(P,it)|0,i=i+Math.imul(C,ot)|0,n=(n=n+Math.imul(C,at)|0)+Math.imul(z,ot)|0,o=o+Math.imul(z,at)|0,i=i+Math.imul(N,ht)|0,n=(n=n+Math.imul(N,ut)|0)+Math.imul(I,ht)|0,o=o+Math.imul(I,ut)|0,i=i+Math.imul(j,ct)|0,n=(n=n+Math.imul(j,dt)|0)+Math.imul(x,ct)|0,o=o+Math.imul(x,dt)|0;var Nt=(u+(i=i+Math.imul(_,mt)|0)|0)+((8191&(n=(n=n+Math.imul(_,pt)|0)+Math.imul(E,mt)|0))<<13)|0;u=((o=o+Math.imul(E,pt)|0)+(n>>>13)|0)+(Nt>>>26)|0,Nt&=67108863,i=Math.imul(D,rt),n=(n=Math.imul(D,it))+Math.imul($,rt)|0,o=Math.imul($,it),i=i+Math.imul(R,ot)|0,n=(n=n+Math.imul(R,at)|0)+Math.imul(P,ot)|0,o=o+Math.imul(P,at)|0,i=i+Math.imul(C,ht)|0,n=(n=n+Math.imul(C,ut)|0)+Math.imul(z,ht)|0,o=o+Math.imul(z,ut)|0,i=i+Math.imul(N,ct)|0,n=(n=n+Math.imul(N,dt)|0)+Math.imul(I,ct)|0,o=o+Math.imul(I,dt)|0;var It=(u+(i=i+Math.imul(j,mt)|0)|0)+((8191&(n=(n=n+Math.imul(j,pt)|0)+Math.imul(x,mt)|0))<<13)|0;u=((o=o+Math.imul(x,pt)|0)+(n>>>13)|0)+(It>>>26)|0,It&=67108863,i=Math.imul(D,ot),n=(n=Math.imul(D,at))+Math.imul($,ot)|0,o=Math.imul($,at),i=i+Math.imul(R,ht)|0,n=(n=n+Math.imul(R,ut)|0)+Math.imul(P,ht)|0,o=o+Math.imul(P,ut)|0,i=i+Math.imul(C,ct)|0,n=(n=n+Math.imul(C,dt)|0)+Math.imul(z,ct)|0,o=o+Math.imul(z,dt)|0;var Tt=(u+(i=i+Math.imul(N,mt)|0)|0)+((8191&(n=(n=n+Math.imul(N,pt)|0)+Math.imul(I,mt)|0))<<13)|0;u=((o=o+Math.imul(I,pt)|0)+(n>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,i=Math.imul(D,ht),n=(n=Math.imul(D,ut))+Math.imul($,ht)|0,o=Math.imul($,ut),i=i+Math.imul(R,ct)|0,n=(n=n+Math.imul(R,dt)|0)+Math.imul(P,ct)|0,o=o+Math.imul(P,dt)|0;var Ct=(u+(i=i+Math.imul(C,mt)|0)|0)+((8191&(n=(n=n+Math.imul(C,pt)|0)+Math.imul(z,mt)|0))<<13)|0;u=((o=o+Math.imul(z,pt)|0)+(n>>>13)|0)+(Ct>>>26)|0,Ct&=67108863,i=Math.imul(D,ct),n=(n=Math.imul(D,dt))+Math.imul($,ct)|0,o=Math.imul($,dt);var zt=(u+(i=i+Math.imul(R,mt)|0)|0)+((8191&(n=(n=n+Math.imul(R,pt)|0)+Math.imul(P,mt)|0))<<13)|0;u=((o=o+Math.imul(P,pt)|0)+(n>>>13)|0)+(zt>>>26)|0,zt&=67108863;var Ot=(u+(i=Math.imul(D,mt))|0)+((8191&(n=(n=Math.imul(D,pt))+Math.imul($,mt)|0))<<13)|0;return u=((o=Math.imul($,pt))+(n>>>13)|0)+(Ot>>>26)|0,Ot&=67108863,h[0]=gt,h[1]=yt,h[2]=wt,h[3]=vt,h[4]=bt,h[5]=kt,h[6]=Mt,h[7]=_t,h[8]=Et,h[9]=At,h[10]=jt,h[11]=xt,h[12]=St,h[13]=Nt,h[14]=It,h[15]=Tt,h[16]=Ct,h[17]=zt,h[18]=Ot,0!==u&&(h[19]=u,r.length++),r};function g(t,e,r){r.negative=e.negative^t.negative,r.length=t.length+e.length;for(var i=0,n=0,o=0;o<r.length-1;o++){var a=n;n=0;for(var s=67108863&i,h=Math.min(o,e.length-1),u=Math.max(0,o-t.length+1);u<=h;u++){var l=o-u,c=(0|t.words[l])*(0|e.words[u]),d=67108863&c;s=67108863&(d=d+s|0),n+=(a=(a=a+(c/67108864|0)|0)+(d>>>26)|0)>>>26,a&=67108863}r.words[o]=s,i=a,a=n}return 0!==i?r.words[o]=i:r.length--,r._strip()}function y(t,e,r){return g(t,e,r)}Math.imul||(p=m),n.prototype.mulTo=function(t,e){var r=this.length+t.length;return 10===this.length&&10===t.length?p(this,t,e):r<63?m(this,t,e):r<1024?g(this,t,e):y(this,t,e)},n.prototype.mul=function(t){var e=new n(null);return e.words=new Array(this.length+t.length),this.mulTo(t,e)},n.prototype.mulf=function(t){var e=new n(null);return e.words=new Array(this.length+t.length),y(this,t,e)},n.prototype.imul=function(t){return this.clone().mulTo(t,this)},n.prototype.imuln=function(t){var e=t<0;e&&(t=-t),r("number"==typeof t),r(t<67108864);for(var i=0,n=0;n<this.length;n++){var o=(0|this.words[n])*t,a=(67108863&o)+(67108863&i);i>>=26,i+=o/67108864|0,i+=a>>>26,this.words[n]=67108863&a}return 0!==i&&(this.words[n]=i,this.length++),e?this.ineg():this},n.prototype.muln=function(t){return this.clone().imuln(t)},n.prototype.sqr=function(){return this.mul(this)},n.prototype.isqr=function(){return this.imul(this.clone())},n.prototype.pow=function(t){var e=function(t){for(var e=new Array(t.bitLength()),r=0;r<e.length;r++){var i=r/26|0,n=r%26;e[r]=t.words[i]>>>n&1}return e}(t);if(0===e.length)return new n(1);for(var r=this,i=0;i<e.length&&0===e[i];i++,r=r.sqr());if(++i<e.length)for(var o=r.sqr();i<e.length;i++,o=o.sqr())0!==e[i]&&(r=r.mul(o));return r},n.prototype.iushln=function(t){r("number"==typeof t&&t>=0);var e,i=t%26,n=(t-i)/26,o=67108863>>>26-i<<26-i;if(0!==i){var a=0;for(e=0;e<this.length;e++){var s=this.words[e]&o,h=(0|this.words[e])-s<<i;this.words[e]=h|a,a=s>>>26-i}a&&(this.words[e]=a,this.length++)}if(0!==n){for(e=this.length-1;e>=0;e--)this.words[e+n]=this.words[e];for(e=0;e<n;e++)this.words[e]=0;this.length+=n}return this._strip()},n.prototype.ishln=function(t){return r(0===this.negative),this.iushln(t)},n.prototype.iushrn=function(t,e,i){var n;r("number"==typeof t&&t>=0),n=e?(e-e%26)/26:0;var o=t%26,a=Math.min((t-o)/26,this.length),s=67108863^67108863>>>o<<o,h=i;if(n-=a,n=Math.max(0,n),h){for(var u=0;u<a;u++)h.words[u]=this.words[u];h.length=a}if(0===a);else if(this.length>a)for(this.length-=a,u=0;u<this.length;u++)this.words[u]=this.words[u+a];else this.words[0]=0,this.length=1;var l=0;for(u=this.length-1;u>=0&&(0!==l||u>=n);u--){var c=0|this.words[u];this.words[u]=l<<26-o|c>>>o,l=c&s}return h&&0!==l&&(h.words[h.length++]=l),0===this.length&&(this.words[0]=0,this.length=1),this._strip()},n.prototype.ishrn=function(t,e,i){return r(0===this.negative),this.iushrn(t,e,i)},n.prototype.shln=function(t){return this.clone().ishln(t)},n.prototype.ushln=function(t){return this.clone().iushln(t)},n.prototype.shrn=function(t){return this.clone().ishrn(t)},n.prototype.ushrn=function(t){return this.clone().iushrn(t)},n.prototype.testn=function(t){r("number"==typeof t&&t>=0);var e=t%26,i=(t-e)/26,n=1<<e;return!(this.length<=i)&&!!(this.words[i]&n)},n.prototype.imaskn=function(t){r("number"==typeof t&&t>=0);var e=t%26,i=(t-e)/26;if(r(0===this.negative,"imaskn works only with positive numbers"),this.length<=i)return this;if(0!==e&&i++,this.length=Math.min(i,this.length),0!==e){var n=67108863^67108863>>>e<<e;this.words[this.length-1]&=n}return this._strip()},n.prototype.maskn=function(t){return this.clone().imaskn(t)},n.prototype.iaddn=function(t){return r("number"==typeof t),r(t<67108864),t<0?this.isubn(-t):0!==this.negative?1===this.length&&(0|this.words[0])<=t?(this.words[0]=t-(0|this.words[0]),this.negative=0,this):(this.negative=0,this.isubn(t),this.negative=1,this):this._iaddn(t)},n.prototype._iaddn=function(t){this.words[0]+=t;for(var e=0;e<this.length&&this.words[e]>=67108864;e++)this.words[e]-=67108864,e===this.length-1?this.words[e+1]=1:this.words[e+1]++;return this.length=Math.max(this.length,e+1),this},n.prototype.isubn=function(t){if(r("number"==typeof t),r(t<67108864),t<0)return this.iaddn(-t);if(0!==this.negative)return this.negative=0,this.iaddn(t),this.negative=1,this;if(this.words[0]-=t,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var e=0;e<this.length&&this.words[e]<0;e++)this.words[e]+=67108864,this.words[e+1]-=1;return this._strip()},n.prototype.addn=function(t){return this.clone().iaddn(t)},n.prototype.subn=function(t){return this.clone().isubn(t)},n.prototype.iabs=function(){return this.negative=0,this},n.prototype.abs=function(){return this.clone().iabs()},n.prototype._ishlnsubmul=function(t,e,i){var n,o,a=t.length+i;this._expand(a);var s=0;for(n=0;n<t.length;n++){o=(0|this.words[n+i])+s;var h=(0|t.words[n])*e;s=((o-=67108863&h)>>26)-(h/67108864|0),this.words[n+i]=67108863&o}for(;n<this.length-i;n++)s=(o=(0|this.words[n+i])+s)>>26,this.words[n+i]=67108863&o;if(0===s)return this._strip();for(r(-1===s),s=0,n=0;n<this.length;n++)s=(o=-(0|this.words[n])+s)>>26,this.words[n]=67108863&o;return this.negative=1,this._strip()},n.prototype._wordDiv=function(t,e){var r=(this.length,t.length),i=this.clone(),o=t,a=0|o.words[o.length-1];0!==(r=26-this._countBits(a))&&(o=o.ushln(r),i.iushln(r),a=0|o.words[o.length-1]);var s,h=i.length-o.length;if("mod"!==e){(s=new n(null)).length=h+1,s.words=new Array(s.length);for(var u=0;u<s.length;u++)s.words[u]=0}var l=i.clone()._ishlnsubmul(o,1,h);0===l.negative&&(i=l,s&&(s.words[h]=1));for(var c=h-1;c>=0;c--){var d=67108864*(0|i.words[o.length+c])+(0|i.words[o.length+c-1]);for(d=Math.min(d/a|0,67108863),i._ishlnsubmul(o,d,c);0!==i.negative;)d--,i.negative=0,i._ishlnsubmul(o,1,c),i.isZero()||(i.negative^=1);s&&(s.words[c]=d)}return s&&s._strip(),i._strip(),"div"!==e&&0!==r&&i.iushrn(r),{div:s||null,mod:i}},n.prototype.divmod=function(t,e,i){return r(!t.isZero()),this.isZero()?{div:new n(0),mod:new n(0)}:0!==this.negative&&0===t.negative?(s=this.neg().divmod(t,e),"mod"!==e&&(o=s.div.neg()),"div"!==e&&(a=s.mod.neg(),i&&0!==a.negative&&a.iadd(t)),{div:o,mod:a}):0===this.negative&&0!==t.negative?(s=this.divmod(t.neg(),e),"mod"!==e&&(o=s.div.neg()),{div:o,mod:s.mod}):0!=(this.negative&t.negative)?(s=this.neg().divmod(t.neg(),e),"div"!==e&&(a=s.mod.neg(),i&&0!==a.negative&&a.isub(t)),{div:s.div,mod:a}):t.length>this.length||this.cmp(t)<0?{div:new n(0),mod:this}:1===t.length?"div"===e?{div:this.divn(t.words[0]),mod:null}:"mod"===e?{div:null,mod:new n(this.modrn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new n(this.modrn(t.words[0]))}:this._wordDiv(t,e);var o,a,s},n.prototype.div=function(t){return this.divmod(t,"div",!1).div},n.prototype.mod=function(t){return this.divmod(t,"mod",!1).mod},n.prototype.umod=function(t){return this.divmod(t,"mod",!0).mod},n.prototype.divRound=function(t){var e=this.divmod(t);if(e.mod.isZero())return e.div;var r=0!==e.div.negative?e.mod.isub(t):e.mod,i=t.ushrn(1),n=t.andln(1),o=r.cmp(i);return o<0||1===n&&0===o?e.div:0!==e.div.negative?e.div.isubn(1):e.div.iaddn(1)},n.prototype.modrn=function(t){var e=t<0;e&&(t=-t),r(t<=67108863);for(var i=(1<<26)%t,n=0,o=this.length-1;o>=0;o--)n=(i*n+(0|this.words[o]))%t;return e?-n:n},n.prototype.modn=function(t){return this.modrn(t)},n.prototype.idivn=function(t){var e=t<0;e&&(t=-t),r(t<=67108863);for(var i=0,n=this.length-1;n>=0;n--){var o=(0|this.words[n])+67108864*i;this.words[n]=o/t|0,i=o%t}return this._strip(),e?this.ineg():this},n.prototype.divn=function(t){return this.clone().idivn(t)},n.prototype.egcd=function(t){r(0===t.negative),r(!t.isZero());var e=this,i=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var o=new n(1),a=new n(0),s=new n(0),h=new n(1),u=0;e.isEven()&&i.isEven();)e.iushrn(1),i.iushrn(1),++u;for(var l=i.clone(),c=e.clone();!e.isZero();){for(var d=0,f=1;0==(e.words[0]&f)&&d<26;++d,f<<=1);if(d>0)for(e.iushrn(d);d-- >0;)(o.isOdd()||a.isOdd())&&(o.iadd(l),a.isub(c)),o.iushrn(1),a.iushrn(1);for(var m=0,p=1;0==(i.words[0]&p)&&m<26;++m,p<<=1);if(m>0)for(i.iushrn(m);m-- >0;)(s.isOdd()||h.isOdd())&&(s.iadd(l),h.isub(c)),s.iushrn(1),h.iushrn(1);e.cmp(i)>=0?(e.isub(i),o.isub(s),a.isub(h)):(i.isub(e),s.isub(o),h.isub(a))}return{a:s,b:h,gcd:i.iushln(u)}},n.prototype._invmp=function(t){r(0===t.negative),r(!t.isZero());var e=this,i=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var o,a=new n(1),s=new n(0),h=i.clone();e.cmpn(1)>0&&i.cmpn(1)>0;){for(var u=0,l=1;0==(e.words[0]&l)&&u<26;++u,l<<=1);if(u>0)for(e.iushrn(u);u-- >0;)a.isOdd()&&a.iadd(h),a.iushrn(1);for(var c=0,d=1;0==(i.words[0]&d)&&c<26;++c,d<<=1);if(c>0)for(i.iushrn(c);c-- >0;)s.isOdd()&&s.iadd(h),s.iushrn(1);e.cmp(i)>=0?(e.isub(i),a.isub(s)):(i.isub(e),s.isub(a))}return(o=0===e.cmpn(1)?a:s).cmpn(0)<0&&o.iadd(t),o},n.prototype.gcd=function(t){if(this.isZero())return t.abs();if(t.isZero())return this.abs();var e=this.clone(),r=t.clone();e.negative=0,r.negative=0;for(var i=0;e.isEven()&&r.isEven();i++)e.iushrn(1),r.iushrn(1);for(;;){for(;e.isEven();)e.iushrn(1);for(;r.isEven();)r.iushrn(1);var n=e.cmp(r);if(n<0){var o=e;e=r,r=o}else if(0===n||0===r.cmpn(1))break;e.isub(r)}return r.iushln(i)},n.prototype.invm=function(t){return this.egcd(t).a.umod(t)},n.prototype.isEven=function(){return 0==(1&this.words[0])},n.prototype.isOdd=function(){return 1==(1&this.words[0])},n.prototype.andln=function(t){return this.words[0]&t},n.prototype.bincn=function(t){r("number"==typeof t);var e=t%26,i=(t-e)/26,n=1<<e;if(this.length<=i)return this._expand(i+1),this.words[i]|=n,this;for(var o=n,a=i;0!==o&&a<this.length;a++){var s=0|this.words[a];o=(s+=o)>>>26,s&=67108863,this.words[a]=s}return 0!==o&&(this.words[a]=o,this.length++),this},n.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},n.prototype.cmpn=function(t){var e,i=t<0;if(0!==this.negative&&!i)return-1;if(0===this.negative&&i)return 1;if(this._strip(),this.length>1)e=1;else{i&&(t=-t),r(t<=67108863,"Number is too big");var n=0|this.words[0];e=n===t?0:n<t?-1:1}return 0!==this.negative?0|-e:e},n.prototype.cmp=function(t){if(0!==this.negative&&0===t.negative)return-1;if(0===this.negative&&0!==t.negative)return 1;var e=this.ucmp(t);return 0!==this.negative?0|-e:e},n.prototype.ucmp=function(t){if(this.length>t.length)return 1;if(this.length<t.length)return-1;for(var e=0,r=this.length-1;r>=0;r--){var i=0|this.words[r],n=0|t.words[r];if(i!==n){i<n?e=-1:i>n&&(e=1);break}}return e},n.prototype.gtn=function(t){return 1===this.cmpn(t)},n.prototype.gt=function(t){return 1===this.cmp(t)},n.prototype.gten=function(t){return this.cmpn(t)>=0},n.prototype.gte=function(t){return this.cmp(t)>=0},n.prototype.ltn=function(t){return-1===this.cmpn(t)},n.prototype.lt=function(t){return-1===this.cmp(t)},n.prototype.lten=function(t){return this.cmpn(t)<=0},n.prototype.lte=function(t){return this.cmp(t)<=0},n.prototype.eqn=function(t){return 0===this.cmpn(t)},n.prototype.eq=function(t){return 0===this.cmp(t)},n.red=function(t){return new E(t)},n.prototype.toRed=function(t){return r(!this.red,"Already a number in reduction context"),r(0===this.negative,"red works only with positives"),t.convertTo(this)._forceRed(t)},n.prototype.fromRed=function(){return r(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},n.prototype._forceRed=function(t){return this.red=t,this},n.prototype.forceRed=function(t){return r(!this.red,"Already a number in reduction context"),this._forceRed(t)},n.prototype.redAdd=function(t){return r(this.red,"redAdd works only with red numbers"),this.red.add(this,t)},n.prototype.redIAdd=function(t){return r(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,t)},n.prototype.redSub=function(t){return r(this.red,"redSub works only with red numbers"),this.red.sub(this,t)},n.prototype.redISub=function(t){return r(this.red,"redISub works only with red numbers"),this.red.isub(this,t)},n.prototype.redShl=function(t){return r(this.red,"redShl works only with red numbers"),this.red.shl(this,t)},n.prototype.redMul=function(t){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.mul(this,t)},n.prototype.redIMul=function(t){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.imul(this,t)},n.prototype.redSqr=function(){return r(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},n.prototype.redISqr=function(){return r(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},n.prototype.redSqrt=function(){return r(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},n.prototype.redInvm=function(){return r(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},n.prototype.redNeg=function(){return r(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},n.prototype.redPow=function(t){return r(this.red&&!t.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,t)};var w={k256:null,p224:null,p192:null,p25519:null};function v(t,e){this.name=t,this.p=new n(e,16),this.n=this.p.bitLength(),this.k=new n(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function b(){v.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function k(){v.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function M(){v.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function _(){v.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function E(t){if("string"==typeof t){var e=n._prime(t);this.m=e.p,this.prime=e}else r(t.gtn(1),"modulus must be greater than 1"),this.m=t,this.prime=null}function A(t){E.call(this,t),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new n(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)}v.prototype._tmp=function(){var t=new n(null);return t.words=new Array(Math.ceil(this.n/13)),t},v.prototype.ireduce=function(t){var e,r=t;do{this.split(r,this.tmp),e=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(e>this.n);var i=e<this.n?-1:r.ucmp(this.p);return 0===i?(r.words[0]=0,r.length=1):i>0?r.isub(this.p):void 0!==r.strip?r.strip():r._strip(),r},v.prototype.split=function(t,e){t.iushrn(this.n,0,e)},v.prototype.imulK=function(t){return t.imul(this.k)},i(b,v),b.prototype.split=function(t,e){for(var r=4194303,i=Math.min(t.length,9),n=0;n<i;n++)e.words[n]=t.words[n];if(e.length=i,t.length<=9)return t.words[0]=0,void(t.length=1);var o=t.words[9];for(e.words[e.length++]=o&r,n=10;n<t.length;n++){var a=0|t.words[n];t.words[n-10]=(a&r)<<4|o>>>22,o=a}o>>>=22,t.words[n-10]=o,0===o&&t.length>10?t.length-=10:t.length-=9},b.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var e=0,r=0;r<t.length;r++){var i=0|t.words[r];e+=977*i,t.words[r]=67108863&e,e=64*i+(e/67108864|0)}return 0===t.words[t.length-1]&&(t.length--,0===t.words[t.length-1]&&t.length--),t},i(k,v),i(M,v),i(_,v),_.prototype.imulK=function(t){for(var e=0,r=0;r<t.length;r++){var i=19*(0|t.words[r])+e,n=67108863&i;i>>>=26,t.words[r]=n,e=i}return 0!==e&&(t.words[t.length++]=e),t},n._prime=function(t){if(w[t])return w[t];var e;if("k256"===t)e=new b;else if("p224"===t)e=new k;else if("p192"===t)e=new M;else{if("p25519"!==t)throw new Error("Unknown prime "+t);e=new _}return w[t]=e,e},E.prototype._verify1=function(t){r(0===t.negative,"red works only with positives"),r(t.red,"red works only with red numbers")},E.prototype._verify2=function(t,e){r(0==(t.negative|e.negative),"red works only with positives"),r(t.red&&t.red===e.red,"red works only with red numbers")},E.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):(u(t,t.umod(this.m)._forceRed(this)),t)},E.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},E.prototype.add=function(t,e){this._verify2(t,e);var r=t.add(e);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},E.prototype.iadd=function(t,e){this._verify2(t,e);var r=t.iadd(e);return r.cmp(this.m)>=0&&r.isub(this.m),r},E.prototype.sub=function(t,e){this._verify2(t,e);var r=t.sub(e);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},E.prototype.isub=function(t,e){this._verify2(t,e);var r=t.isub(e);return r.cmpn(0)<0&&r.iadd(this.m),r},E.prototype.shl=function(t,e){return this._verify1(t),this.imod(t.ushln(e))},E.prototype.imul=function(t,e){return this._verify2(t,e),this.imod(t.imul(e))},E.prototype.mul=function(t,e){return this._verify2(t,e),this.imod(t.mul(e))},E.prototype.isqr=function(t){return this.imul(t,t.clone())},E.prototype.sqr=function(t){return this.mul(t,t)},E.prototype.sqrt=function(t){if(t.isZero())return t.clone();var e=this.m.andln(3);if(r(e%2==1),3===e){var i=this.m.add(new n(1)).iushrn(2);return this.pow(t,i)}for(var o=this.m.subn(1),a=0;!o.isZero()&&0===o.andln(1);)a++,o.iushrn(1);r(!o.isZero());var s=new n(1).toRed(this),h=s.redNeg(),u=this.m.subn(1).iushrn(1),l=this.m.bitLength();for(l=new n(2*l*l).toRed(this);0!==this.pow(l,u).cmp(h);)l.redIAdd(h);for(var c=this.pow(l,o),d=this.pow(t,o.addn(1).iushrn(1)),f=this.pow(t,o),m=a;0!==f.cmp(s);){for(var p=f,g=0;0!==p.cmp(s);g++)p=p.redSqr();r(g<m);var y=this.pow(c,new n(1).iushln(m-g-1));d=d.redMul(y),c=y.redSqr(),f=f.redMul(c),m=g}return d},E.prototype.invm=function(t){var e=t._invmp(this.m);return 0!==e.negative?(e.negative=0,this.imod(e).redNeg()):this.imod(e)},E.prototype.pow=function(t,e){if(e.isZero())return new n(1).toRed(this);if(0===e.cmpn(1))return t.clone();var r=new Array(16);r[0]=new n(1).toRed(this),r[1]=t;for(var i=2;i<r.length;i++)r[i]=this.mul(r[i-1],t);var o=r[0],a=0,s=0,h=e.bitLength()%26;for(0===h&&(h=26),i=e.length-1;i>=0;i--){for(var u=e.words[i],l=h-1;l>=0;l--){var c=u>>l&1;o!==r[0]&&(o=this.sqr(o)),0!==c||0!==a?(a<<=1,a|=c,(4===++s||0===i&&0===l)&&(o=this.mul(o,r[a]),s=0,a=0)):s=0}h=26}return o},E.prototype.convertTo=function(t){var e=t.umod(this.m);return e===t?e.clone():e},E.prototype.convertFrom=function(t){var e=t.clone();return e.red=null,e},n.mont=function(t){return new A(t)},i(A,E),A.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},A.prototype.convertFrom=function(t){var e=this.imod(t.mul(this.rinv));return e.red=null,e},A.prototype.imul=function(t,e){if(t.isZero()||e.isZero())return t.words[0]=0,t.length=1,t;var r=t.imul(e),i=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),n=r.isub(i).iushrn(this.shift),o=n;return n.cmp(this.m)>=0?o=n.isub(this.m):n.cmpn(0)<0&&(o=n.iadd(this.m)),o._forceRed(this)},A.prototype.mul=function(t,e){if(t.isZero()||e.isZero())return new n(0)._forceRed(this);var r=t.mul(e),i=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),o=r.isub(i).iushrn(this.shift),a=o;return o.cmp(this.m)>=0?a=o.isub(this.m):o.cmpn(0)<0&&(a=o.iadd(this.m)),a._forceRed(this)},A.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}(t,i)}));var Yi=Wi.BN;const Qi=new w("bignumber/5.6.2"),Xi={},tn=9007199254740991;let en=!1;class rn{constructor(t,e){t!==Xi&&Qi.throwError("cannot call constructor directly; use BigNumber.from",w.errors.UNSUPPORTED_OPERATION,{operation:"new (BigNumber)"}),this._hex=e,this._isBigNumber=!0,Object.freeze(this)}fromTwos(t){return on(an(this).fromTwos(t))}toTwos(t){return on(an(this).toTwos(t))}abs(){return"-"===this._hex[0]?rn.from(this._hex.substring(1)):this}add(t){return on(an(this).add(an(t)))}sub(t){return on(an(this).sub(an(t)))}div(t){return rn.from(t).isZero()&&sn("division-by-zero","div"),on(an(this).div(an(t)))}mul(t){return on(an(this).mul(an(t)))}mod(t){const e=an(t);return e.isNeg()&&sn("division-by-zero","mod"),on(an(this).umod(e))}pow(t){const e=an(t);return e.isNeg()&&sn("negative-power","pow"),on(an(this).pow(e))}and(t){const e=an(t);return(this.isNegative()||e.isNeg())&&sn("unbound-bitwise-result","and"),on(an(this).and(e))}or(t){const e=an(t);return(this.isNegative()||e.isNeg())&&sn("unbound-bitwise-result","or"),on(an(this).or(e))}xor(t){const e=an(t);return(this.isNegative()||e.isNeg())&&sn("unbound-bitwise-result","xor"),on(an(this).xor(e))}mask(t){return(this.isNegative()||t<0)&&sn("negative-width","mask"),on(an(this).maskn(t))}shl(t){return(this.isNegative()||t<0)&&sn("negative-width","shl"),on(an(this).shln(t))}shr(t){return(this.isNegative()||t<0)&&sn("negative-width","shr"),on(an(this).shrn(t))}eq(t){return an(this).eq(an(t))}lt(t){return an(this).lt(an(t))}lte(t){return an(this).lte(an(t))}gt(t){return an(this).gt(an(t))}gte(t){return an(this).gte(an(t))}isNegative(){return"-"===this._hex[0]}isZero(){return an(this).isZero()}toNumber(){try{return an(this).toNumber()}catch(t){sn("overflow","toNumber",this.toString())}return null}toBigInt(){try{return BigInt(this.toString())}catch(t){}return Qi.throwError("this platform does not support BigInt",w.errors.UNSUPPORTED_OPERATION,{value:this.toString()})}toString(){return arguments.length>0&&(10===arguments[0]?en||(en=!0,Qi.warn("BigNumber.toString does not accept any parameters; base-10 is assumed")):16===arguments[0]?Qi.throwError("BigNumber.toString does not accept any parameters; use bigNumber.toHexString()",w.errors.UNEXPECTED_ARGUMENT,{}):Qi.throwError("BigNumber.toString does not accept parameters",w.errors.UNEXPECTED_ARGUMENT,{})),an(this).toString(10)}toHexString(){return this._hex}toJSON(t){return{type:"BigNumber",hex:this.toHexString()}}static from(t){if(t instanceof rn)return t;if("string"==typeof t)return t.match(/^-?0x[0-9a-f]+$/i)?new rn(Xi,nn(t)):t.match(/^-?[0-9]+$/)?new rn(Xi,nn(new Yi(t))):Qi.throwArgumentError("invalid BigNumber string","value",t);if("number"==typeof t)return t%1&&sn("underflow","BigNumber.from",t),(t>=tn||t<=-tn)&&sn("overflow","BigNumber.from",t),rn.from(String(t));const e=t;if("bigint"==typeof e)return rn.from(e.toString());if(E(e))return rn.from(I(e));if(e)if(e.toHexString){const t=e.toHexString();if("string"==typeof t)return rn.from(t)}else{let t=e._hex;if(null==t&&"BigNumber"===e.type&&(t=e.hex),"string"==typeof t&&(S(t)||"-"===t[0]&&S(t.substring(1))))return rn.from(t)}return Qi.throwArgumentError("invalid BigNumber value","value",t)}static isBigNumber(t){return!(!t||!t._isBigNumber)}}function nn(t){if("string"!=typeof t)return nn(t.toString(16));if("-"===t[0])return"-"===(t=t.substring(1))[0]&&Qi.throwArgumentError("invalid hex","value",t),"0x00"===(t=nn(t))?t:"-"+t;if("0x"!==t.substring(0,2)&&(t="0x"+t),"0x"===t)return"0x00";for(t.length%2&&(t="0x0"+t.substring(2));t.length>4&&"0x00"===t.substring(0,4);)t="0x"+t.substring(4);return t}function on(t){return rn.from(nn(t))}function an(t){const e=rn.from(t).toHexString();return"-"===e[0]?new Yi("-"+e.substring(3),16):new Yi(e.substring(2),16)}function sn(t,e,r){const i={fault:t,operation:e};return null!=r&&(i.value=r),Qi.throwError(t,w.errors.NUMERIC_FAULT,i)}var hn=window&&window.__awaiter||function(t,e,r,i){return new(r||(r=Promise))((function(n,o){function a(t){try{h(i.next(t))}catch(t){o(t)}}function s(t){try{h(i.throw(t))}catch(t){o(t)}}function h(t){var e;t.done?n(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(a,s)}h((i=i.apply(t,e||[])).next())}))};const un=new w("abstract-provider/5.6.1");class ln extends cr{static isForkEvent(t){return!(!t||!t._isForkEvent)}}class cn{constructor(){un.checkAbstract(new.target,cn),ir(this,"_isProvider",!0)}getFeeData(){return hn(this,void 0,void 0,(function*(){const{block:t,gasPrice:e}=yield or({block:this.getBlock("latest"),gasPrice:this.getGasPrice().catch((t=>null))});let r=null,i=null;return t&&t.baseFeePerGas&&(i=rn.from("1500000000"),r=t.baseFeePerGas.mul(2).add(i)),{maxFeePerGas:r,maxPriorityFeePerGas:i,gasPrice:e}}))}addListener(t,e){return this.on(t,e)}removeListener(t,e){return this.off(t,e)}static isProvider(t){return!(!t||!t._isProvider)}}var dn=window&&window.__awaiter||function(t,e,r,i){return new(r||(r=Promise))((function(n,o){function a(t){try{h(i.next(t))}catch(t){o(t)}}function s(t){try{h(i.throw(t))}catch(t){o(t)}}function h(t){var e;t.done?n(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(a,s)}h((i=i.apply(t,e||[])).next())}))};const fn=new w("abstract-signer/5.6.2"),mn=["accessList","ccipReadEnabled","chainId","customData","data","from","gasLimit","gasPrice","maxFeePerGas","maxPriorityFeePerGas","nonce","to","type","value"],pn=[w.errors.INSUFFICIENT_FUNDS,w.errors.NONCE_EXPIRED,w.errors.REPLACEMENT_UNDERPRICED];class gn{constructor(){fn.checkAbstract(new.target,gn),ir(this,"_isSigner",!0)}getBalance(t){return dn(this,void 0,void 0,(function*(){return this._checkProvider("getBalance"),yield this.provider.getBalance(this.getAddress(),t)}))}getTransactionCount(t){return dn(this,void 0,void 0,(function*(){return this._checkProvider("getTransactionCount"),yield this.provider.getTransactionCount(this.getAddress(),t)}))}estimateGas(t){return dn(this,void 0,void 0,(function*(){this._checkProvider("estimateGas");const e=yield or(this.checkTransaction(t));return yield this.provider.estimateGas(e)}))}call(t,e){return dn(this,void 0,void 0,(function*(){this._checkProvider("call");const r=yield or(this.checkTransaction(t));return yield this.provider.call(r,e)}))}sendTransaction(t){return dn(this,void 0,void 0,(function*(){this._checkProvider("sendTransaction");const e=yield this.populateTransaction(t),r=yield this.signTransaction(e);return yield this.provider.sendTransaction(r)}))}getChainId(){return dn(this,void 0,void 0,(function*(){this._checkProvider("getChainId");return(yield this.provider.getNetwork()).chainId}))}getGasPrice(){return dn(this,void 0,void 0,(function*(){return this._checkProvider("getGasPrice"),yield this.provider.getGasPrice()}))}getFeeData(){return dn(this,void 0,void 0,(function*(){return this._checkProvider("getFeeData"),yield this.provider.getFeeData()}))}resolveName(t){return dn(this,void 0,void 0,(function*(){return this._checkProvider("resolveName"),yield this.provider.resolveName(t)}))}checkTransaction(t){for(const e in t)-1===mn.indexOf(e)&&fn.throwArgumentError("invalid transaction key: "+e,"transaction",t);const e=ar(t);return null==e.from?e.from=this.getAddress():e.from=Promise.all([Promise.resolve(e.from),this.getAddress()]).then((e=>(e[0].toLowerCase()!==e[1].toLowerCase()&&fn.throwArgumentError("from address mismatch","transaction",t),e[0]))),e}populateTransaction(t){return dn(this,void 0,void 0,(function*(){const e=yield or(this.checkTransaction(t));null!=e.to&&(e.to=Promise.resolve(e.to).then((t=>dn(this,void 0,void 0,(function*(){if(null==t)return null;const e=yield this.resolveName(t);return null==e&&fn.throwArgumentError("provided ENS name resolves to null","tx.to",t),e})))),e.to.catch((t=>{})));const r=null!=e.maxFeePerGas||null!=e.maxPriorityFeePerGas;if(null==e.gasPrice||2!==e.type&&!r?0!==e.type&&1!==e.type||!r||fn.throwArgumentError("pre-eip-1559 transaction do not support maxFeePerGas/maxPriorityFeePerGas","transaction",t):fn.throwArgumentError("eip-1559 transaction do not support gasPrice","transaction",t),2!==e.type&&null!=e.type||null==e.maxFeePerGas||null==e.maxPriorityFeePerGas)if(0===e.type||1===e.type)null==e.gasPrice&&(e.gasPrice=this.getGasPrice());else{const t=yield this.getFeeData();if(null==e.type)if(null!=t.maxFeePerGas&&null!=t.maxPriorityFeePerGas)if(e.type=2,null!=e.gasPrice){const t=e.gasPrice;delete e.gasPrice,e.maxFeePerGas=t,e.maxPriorityFeePerGas=t}else null==e.maxFeePerGas&&(e.maxFeePerGas=t.maxFeePerGas),null==e.maxPriorityFeePerGas&&(e.maxPriorityFeePerGas=t.maxPriorityFeePerGas);else null!=t.gasPrice?(r&&fn.throwError("network does not support EIP-1559",w.errors.UNSUPPORTED_OPERATION,{operation:"populateTransaction"}),null==e.gasPrice&&(e.gasPrice=t.gasPrice),e.type=0):fn.throwError("failed to get consistent fee data",w.errors.UNSUPPORTED_OPERATION,{operation:"signer.getFeeData"});else 2===e.type&&(null==e.maxFeePerGas&&(e.maxFeePerGas=t.maxFeePerGas),null==e.maxPriorityFeePerGas&&(e.maxPriorityFeePerGas=t.maxPriorityFeePerGas))}else e.type=2;return null==e.nonce&&(e.nonce=this.getTransactionCount("pending")),null==e.gasLimit&&(e.gasLimit=this.estimateGas(e).catch((t=>{if(pn.indexOf(t.code)>=0)throw t;return fn.throwError("cannot estimate gas; transaction may fail or may require manual gas limit",w.errors.UNPREDICTABLE_GAS_LIMIT,{error:t,tx:e})}))),null==e.chainId?e.chainId=this.getChainId():e.chainId=Promise.all([Promise.resolve(e.chainId),this.getChainId()]).then((e=>(0!==e[1]&&e[0]!==e[1]&&fn.throwArgumentError("chainId address mismatch","transaction",t),e[0]))),yield or(e)}))}_checkProvider(t){this.provider||fn.throwError("missing provider",w.errors.UNSUPPORTED_OPERATION,{operation:t||"_checkProvider"})}static isSigner(t){return!(!t||!t._isSigner)}}class yn extends gn{constructor(t,e){super(),ir(this,"address",t),ir(this,"provider",e||null)}getAddress(){return Promise.resolve(this.address)}_fail(t,e){return Promise.resolve().then((()=>{fn.throwError(t,w.errors.UNSUPPORTED_OPERATION,{operation:e})}))}signMessage(t){return this._fail("VoidSigner cannot sign messages","signMessage")}signTransaction(t){return this._fail("VoidSigner cannot sign transactions","signTransaction")}_signTypedData(t,e,r){return this._fail("VoidSigner cannot sign typed data","signTypedData")}connect(t){return new yn(this.address,t)}}var wn=a((function(t){!function(t,e){function r(t,e){if(!t)throw new Error(e||"Assertion failed")}function i(t,e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}function n(t,e,r){if(n.isBN(t))return t;this.negative=0,this.words=null,this.length=0,this.red=null,null!==t&&("le"!==e&&"be"!==e||(r=e,e=10),this._init(t||0,e||10,r||"be"))}var o;"object"==typeof t?t.exports=n:e.BN=n,n.BN=n,n.wordSize=26;try{o="undefined"!=typeof window&&void 0!==window.Buffer?window.Buffer:Pt.Buffer}catch(t){}function a(t,e){var i=t.charCodeAt(e);return i>=48&&i<=57?i-48:i>=65&&i<=70?i-55:i>=97&&i<=102?i-87:void r(!1,"Invalid character in "+t)}function s(t,e,r){var i=a(t,r);return r-1>=e&&(i|=a(t,r-1)<<4),i}function h(t,e,i,n){for(var o=0,a=0,s=Math.min(t.length,i),h=e;h<s;h++){var u=t.charCodeAt(h)-48;o*=n,a=u>=49?u-49+10:u>=17?u-17+10:u,r(u>=0&&a<n,"Invalid character"),o+=a}return o}function u(t,e){t.words=e.words,t.length=e.length,t.negative=e.negative,t.red=e.red}if(n.isBN=function(t){return t instanceof n||null!==t&&"object"==typeof t&&t.constructor.wordSize===n.wordSize&&Array.isArray(t.words)},n.max=function(t,e){return t.cmp(e)>0?t:e},n.min=function(t,e){return t.cmp(e)<0?t:e},n.prototype._init=function(t,e,i){if("number"==typeof t)return this._initNumber(t,e,i);if("object"==typeof t)return this._initArray(t,e,i);"hex"===e&&(e=16),r(e===(0|e)&&e>=2&&e<=36);var n=0;"-"===(t=t.toString().replace(/\s+/g,""))[0]&&(n++,this.negative=1),n<t.length&&(16===e?this._parseHex(t,n,i):(this._parseBase(t,e,n),"le"===i&&this._initArray(this.toArray(),e,i)))},n.prototype._initNumber=function(t,e,i){t<0&&(this.negative=1,t=-t),t<67108864?(this.words=[67108863&t],this.length=1):t<4503599627370496?(this.words=[67108863&t,t/67108864&67108863],this.length=2):(r(t<9007199254740992),this.words=[67108863&t,t/67108864&67108863,1],this.length=3),"le"===i&&this._initArray(this.toArray(),e,i)},n.prototype._initArray=function(t,e,i){if(r("number"==typeof t.length),t.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(t.length/3),this.words=new Array(this.length);for(var n=0;n<this.length;n++)this.words[n]=0;var o,a,s=0;if("be"===i)for(n=t.length-1,o=0;n>=0;n-=3)a=t[n]|t[n-1]<<8|t[n-2]<<16,this.words[o]|=a<<s&67108863,this.words[o+1]=a>>>26-s&67108863,(s+=24)>=26&&(s-=26,o++);else if("le"===i)for(n=0,o=0;n<t.length;n+=3)a=t[n]|t[n+1]<<8|t[n+2]<<16,this.words[o]|=a<<s&67108863,this.words[o+1]=a>>>26-s&67108863,(s+=24)>=26&&(s-=26,o++);return this._strip()},n.prototype._parseHex=function(t,e,r){this.length=Math.ceil((t.length-e)/6),this.words=new Array(this.length);for(var i=0;i<this.length;i++)this.words[i]=0;var n,o=0,a=0;if("be"===r)for(i=t.length-1;i>=e;i-=2)n=s(t,e,i)<<o,this.words[a]|=67108863&n,o>=18?(o-=18,a+=1,this.words[a]|=n>>>26):o+=8;else for(i=(t.length-e)%2==0?e+1:e;i<t.length;i+=2)n=s(t,e,i)<<o,this.words[a]|=67108863&n,o>=18?(o-=18,a+=1,this.words[a]|=n>>>26):o+=8;this._strip()},n.prototype._parseBase=function(t,e,r){this.words=[0],this.length=1;for(var i=0,n=1;n<=67108863;n*=e)i++;i--,n=n/e|0;for(var o=t.length-r,a=o%i,s=Math.min(o,o-a)+r,u=0,l=r;l<s;l+=i)u=h(t,l,l+i,e),this.imuln(n),this.words[0]+u<67108864?this.words[0]+=u:this._iaddn(u);if(0!==a){var c=1;for(u=h(t,l,t.length,e),l=0;l<a;l++)c*=e;this.imuln(c),this.words[0]+u<67108864?this.words[0]+=u:this._iaddn(u)}this._strip()},n.prototype.copy=function(t){t.words=new Array(this.length);for(var e=0;e<this.length;e++)t.words[e]=this.words[e];t.length=this.length,t.negative=this.negative,t.red=this.red},n.prototype._move=function(t){u(t,this)},n.prototype.clone=function(){var t=new n(null);return this.copy(t),t},n.prototype._expand=function(t){for(;this.length<t;)this.words[this.length++]=0;return this},n.prototype._strip=function(){for(;this.length>1&&0===this.words[this.length-1];)this.length--;return this._normSign()},n.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},"undefined"!=typeof Symbol&&"function"==typeof Symbol.for)try{n.prototype[Symbol.for("nodejs.util.inspect.custom")]=l}catch(t){n.prototype.inspect=l}else n.prototype.inspect=l;function l(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"}var c=["","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"],d=[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],f=[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];n.prototype.toString=function(t,e){var i;if(e=0|e||1,16===(t=t||10)||"hex"===t){i="";for(var n=0,o=0,a=0;a<this.length;a++){var s=this.words[a],h=(16777215&(s<<n|o)).toString(16);o=s>>>24-n&16777215,(n+=2)>=26&&(n-=26,a--),i=0!==o||a!==this.length-1?c[6-h.length]+h+i:h+i}for(0!==o&&(i=o.toString(16)+i);i.length%e!=0;)i="0"+i;return 0!==this.negative&&(i="-"+i),i}if(t===(0|t)&&t>=2&&t<=36){var u=d[t],l=f[t];i="";var m=this.clone();for(m.negative=0;!m.isZero();){var p=m.modrn(l).toString(t);i=(m=m.idivn(l)).isZero()?p+i:c[u-p.length]+p+i}for(this.isZero()&&(i="0"+i);i.length%e!=0;)i="0"+i;return 0!==this.negative&&(i="-"+i),i}r(!1,"Base should be between 2 and 36")},n.prototype.toNumber=function(){var t=this.words[0];return 2===this.length?t+=67108864*this.words[1]:3===this.length&&1===this.words[2]?t+=4503599627370496+67108864*this.words[1]:this.length>2&&r(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-t:t},n.prototype.toJSON=function(){return this.toString(16,2)},o&&(n.prototype.toBuffer=function(t,e){return this.toArrayLike(o,t,e)}),n.prototype.toArray=function(t,e){return this.toArrayLike(Array,t,e)};function m(t,e,r){r.negative=e.negative^t.negative;var i=t.length+e.length|0;r.length=i,i=i-1|0;var n=0|t.words[0],o=0|e.words[0],a=n*o,s=67108863&a,h=a/67108864|0;r.words[0]=s;for(var u=1;u<i;u++){for(var l=h>>>26,c=67108863&h,d=Math.min(u,e.length-1),f=Math.max(0,u-t.length+1);f<=d;f++){var m=u-f|0;l+=(a=(n=0|t.words[m])*(o=0|e.words[f])+c)/67108864|0,c=67108863&a}r.words[u]=0|c,h=0|l}return 0!==h?r.words[u]=0|h:r.length--,r._strip()}n.prototype.toArrayLike=function(t,e,i){this._strip();var n=this.byteLength(),o=i||Math.max(1,n);r(n<=o,"byte array longer than desired length"),r(o>0,"Requested array length <= 0");var a=function(t,e){return t.allocUnsafe?t.allocUnsafe(e):new t(e)}(t,o);return this["_toArrayLike"+("le"===e?"LE":"BE")](a,n),a},n.prototype._toArrayLikeLE=function(t,e){for(var r=0,i=0,n=0,o=0;n<this.length;n++){var a=this.words[n]<<o|i;t[r++]=255&a,r<t.length&&(t[r++]=a>>8&255),r<t.length&&(t[r++]=a>>16&255),6===o?(r<t.length&&(t[r++]=a>>24&255),i=0,o=0):(i=a>>>24,o+=2)}if(r<t.length)for(t[r++]=i;r<t.length;)t[r++]=0},n.prototype._toArrayLikeBE=function(t,e){for(var r=t.length-1,i=0,n=0,o=0;n<this.length;n++){var a=this.words[n]<<o|i;t[r--]=255&a,r>=0&&(t[r--]=a>>8&255),r>=0&&(t[r--]=a>>16&255),6===o?(r>=0&&(t[r--]=a>>24&255),i=0,o=0):(i=a>>>24,o+=2)}if(r>=0)for(t[r--]=i;r>=0;)t[r--]=0},Math.clz32?n.prototype._countBits=function(t){return 32-Math.clz32(t)}:n.prototype._countBits=function(t){var e=t,r=0;return e>=4096&&(r+=13,e>>>=13),e>=64&&(r+=7,e>>>=7),e>=8&&(r+=4,e>>>=4),e>=2&&(r+=2,e>>>=2),r+e},n.prototype._zeroBits=function(t){if(0===t)return 26;var e=t,r=0;return 0==(8191&e)&&(r+=13,e>>>=13),0==(127&e)&&(r+=7,e>>>=7),0==(15&e)&&(r+=4,e>>>=4),0==(3&e)&&(r+=2,e>>>=2),0==(1&e)&&r++,r},n.prototype.bitLength=function(){var t=this.words[this.length-1],e=this._countBits(t);return 26*(this.length-1)+e},n.prototype.zeroBits=function(){if(this.isZero())return 0;for(var t=0,e=0;e<this.length;e++){var r=this._zeroBits(this.words[e]);if(t+=r,26!==r)break}return t},n.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},n.prototype.toTwos=function(t){return 0!==this.negative?this.abs().inotn(t).iaddn(1):this.clone()},n.prototype.fromTwos=function(t){return this.testn(t-1)?this.notn(t).iaddn(1).ineg():this.clone()},n.prototype.isNeg=function(){return 0!==this.negative},n.prototype.neg=function(){return this.clone().ineg()},n.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},n.prototype.iuor=function(t){for(;this.length<t.length;)this.words[this.length++]=0;for(var e=0;e<t.length;e++)this.words[e]=this.words[e]|t.words[e];return this._strip()},n.prototype.ior=function(t){return r(0==(this.negative|t.negative)),this.iuor(t)},n.prototype.or=function(t){return this.length>t.length?this.clone().ior(t):t.clone().ior(this)},n.prototype.uor=function(t){return this.length>t.length?this.clone().iuor(t):t.clone().iuor(this)},n.prototype.iuand=function(t){var e;e=this.length>t.length?t:this;for(var r=0;r<e.length;r++)this.words[r]=this.words[r]&t.words[r];return this.length=e.length,this._strip()},n.prototype.iand=function(t){return r(0==(this.negative|t.negative)),this.iuand(t)},n.prototype.and=function(t){return this.length>t.length?this.clone().iand(t):t.clone().iand(this)},n.prototype.uand=function(t){return this.length>t.length?this.clone().iuand(t):t.clone().iuand(this)},n.prototype.iuxor=function(t){var e,r;this.length>t.length?(e=this,r=t):(e=t,r=this);for(var i=0;i<r.length;i++)this.words[i]=e.words[i]^r.words[i];if(this!==e)for(;i<e.length;i++)this.words[i]=e.words[i];return this.length=e.length,this._strip()},n.prototype.ixor=function(t){return r(0==(this.negative|t.negative)),this.iuxor(t)},n.prototype.xor=function(t){return this.length>t.length?this.clone().ixor(t):t.clone().ixor(this)},n.prototype.uxor=function(t){return this.length>t.length?this.clone().iuxor(t):t.clone().iuxor(this)},n.prototype.inotn=function(t){r("number"==typeof t&&t>=0);var e=0|Math.ceil(t/26),i=t%26;this._expand(e),i>0&&e--;for(var n=0;n<e;n++)this.words[n]=67108863&~this.words[n];return i>0&&(this.words[n]=~this.words[n]&67108863>>26-i),this._strip()},n.prototype.notn=function(t){return this.clone().inotn(t)},n.prototype.setn=function(t,e){r("number"==typeof t&&t>=0);var i=t/26|0,n=t%26;return this._expand(i+1),this.words[i]=e?this.words[i]|1<<n:this.words[i]&~(1<<n),this._strip()},n.prototype.iadd=function(t){var e,r,i;if(0!==this.negative&&0===t.negative)return this.negative=0,e=this.isub(t),this.negative^=1,this._normSign();if(0===this.negative&&0!==t.negative)return t.negative=0,e=this.isub(t),t.negative=1,e._normSign();this.length>t.length?(r=this,i=t):(r=t,i=this);for(var n=0,o=0;o<i.length;o++)e=(0|r.words[o])+(0|i.words[o])+n,this.words[o]=67108863&e,n=e>>>26;for(;0!==n&&o<r.length;o++)e=(0|r.words[o])+n,this.words[o]=67108863&e,n=e>>>26;if(this.length=r.length,0!==n)this.words[this.length]=n,this.length++;else if(r!==this)for(;o<r.length;o++)this.words[o]=r.words[o];return this},n.prototype.add=function(t){var e;return 0!==t.negative&&0===this.negative?(t.negative=0,e=this.sub(t),t.negative^=1,e):0===t.negative&&0!==this.negative?(this.negative=0,e=t.sub(this),this.negative=1,e):this.length>t.length?this.clone().iadd(t):t.clone().iadd(this)},n.prototype.isub=function(t){if(0!==t.negative){t.negative=0;var e=this.iadd(t);return t.negative=1,e._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(t),this.negative=1,this._normSign();var r,i,n=this.cmp(t);if(0===n)return this.negative=0,this.length=1,this.words[0]=0,this;n>0?(r=this,i=t):(r=t,i=this);for(var o=0,a=0;a<i.length;a++)o=(e=(0|r.words[a])-(0|i.words[a])+o)>>26,this.words[a]=67108863&e;for(;0!==o&&a<r.length;a++)o=(e=(0|r.words[a])+o)>>26,this.words[a]=67108863&e;if(0===o&&a<r.length&&r!==this)for(;a<r.length;a++)this.words[a]=r.words[a];return this.length=Math.max(this.length,a),r!==this&&(this.negative=1),this._strip()},n.prototype.sub=function(t){return this.clone().isub(t)};var p=function(t,e,r){var i,n,o,a=t.words,s=e.words,h=r.words,u=0,l=0|a[0],c=8191&l,d=l>>>13,f=0|a[1],m=8191&f,p=f>>>13,g=0|a[2],y=8191&g,w=g>>>13,v=0|a[3],b=8191&v,k=v>>>13,M=0|a[4],_=8191&M,E=M>>>13,A=0|a[5],j=8191&A,x=A>>>13,S=0|a[6],N=8191&S,I=S>>>13,T=0|a[7],C=8191&T,z=T>>>13,O=0|a[8],R=8191&O,P=O>>>13,B=0|a[9],D=8191&B,$=B>>>13,L=0|s[0],F=8191&L,U=L>>>13,q=0|s[1],V=8191&q,H=q>>>13,G=0|s[2],Z=8191&G,K=G>>>13,J=0|s[3],W=8191&J,Y=J>>>13,Q=0|s[4],X=8191&Q,tt=Q>>>13,et=0|s[5],rt=8191&et,it=et>>>13,nt=0|s[6],ot=8191&nt,at=nt>>>13,st=0|s[7],ht=8191&st,ut=st>>>13,lt=0|s[8],ct=8191&lt,dt=lt>>>13,ft=0|s[9],mt=8191&ft,pt=ft>>>13;r.negative=t.negative^e.negative,r.length=19;var gt=(u+(i=Math.imul(c,F))|0)+((8191&(n=(n=Math.imul(c,U))+Math.imul(d,F)|0))<<13)|0;u=((o=Math.imul(d,U))+(n>>>13)|0)+(gt>>>26)|0,gt&=67108863,i=Math.imul(m,F),n=(n=Math.imul(m,U))+Math.imul(p,F)|0,o=Math.imul(p,U);var yt=(u+(i=i+Math.imul(c,V)|0)|0)+((8191&(n=(n=n+Math.imul(c,H)|0)+Math.imul(d,V)|0))<<13)|0;u=((o=o+Math.imul(d,H)|0)+(n>>>13)|0)+(yt>>>26)|0,yt&=67108863,i=Math.imul(y,F),n=(n=Math.imul(y,U))+Math.imul(w,F)|0,o=Math.imul(w,U),i=i+Math.imul(m,V)|0,n=(n=n+Math.imul(m,H)|0)+Math.imul(p,V)|0,o=o+Math.imul(p,H)|0;var wt=(u+(i=i+Math.imul(c,Z)|0)|0)+((8191&(n=(n=n+Math.imul(c,K)|0)+Math.imul(d,Z)|0))<<13)|0;u=((o=o+Math.imul(d,K)|0)+(n>>>13)|0)+(wt>>>26)|0,wt&=67108863,i=Math.imul(b,F),n=(n=Math.imul(b,U))+Math.imul(k,F)|0,o=Math.imul(k,U),i=i+Math.imul(y,V)|0,n=(n=n+Math.imul(y,H)|0)+Math.imul(w,V)|0,o=o+Math.imul(w,H)|0,i=i+Math.imul(m,Z)|0,n=(n=n+Math.imul(m,K)|0)+Math.imul(p,Z)|0,o=o+Math.imul(p,K)|0;var vt=(u+(i=i+Math.imul(c,W)|0)|0)+((8191&(n=(n=n+Math.imul(c,Y)|0)+Math.imul(d,W)|0))<<13)|0;u=((o=o+Math.imul(d,Y)|0)+(n>>>13)|0)+(vt>>>26)|0,vt&=67108863,i=Math.imul(_,F),n=(n=Math.imul(_,U))+Math.imul(E,F)|0,o=Math.imul(E,U),i=i+Math.imul(b,V)|0,n=(n=n+Math.imul(b,H)|0)+Math.imul(k,V)|0,o=o+Math.imul(k,H)|0,i=i+Math.imul(y,Z)|0,n=(n=n+Math.imul(y,K)|0)+Math.imul(w,Z)|0,o=o+Math.imul(w,K)|0,i=i+Math.imul(m,W)|0,n=(n=n+Math.imul(m,Y)|0)+Math.imul(p,W)|0,o=o+Math.imul(p,Y)|0;var bt=(u+(i=i+Math.imul(c,X)|0)|0)+((8191&(n=(n=n+Math.imul(c,tt)|0)+Math.imul(d,X)|0))<<13)|0;u=((o=o+Math.imul(d,tt)|0)+(n>>>13)|0)+(bt>>>26)|0,bt&=67108863,i=Math.imul(j,F),n=(n=Math.imul(j,U))+Math.imul(x,F)|0,o=Math.imul(x,U),i=i+Math.imul(_,V)|0,n=(n=n+Math.imul(_,H)|0)+Math.imul(E,V)|0,o=o+Math.imul(E,H)|0,i=i+Math.imul(b,Z)|0,n=(n=n+Math.imul(b,K)|0)+Math.imul(k,Z)|0,o=o+Math.imul(k,K)|0,i=i+Math.imul(y,W)|0,n=(n=n+Math.imul(y,Y)|0)+Math.imul(w,W)|0,o=o+Math.imul(w,Y)|0,i=i+Math.imul(m,X)|0,n=(n=n+Math.imul(m,tt)|0)+Math.imul(p,X)|0,o=o+Math.imul(p,tt)|0;var kt=(u+(i=i+Math.imul(c,rt)|0)|0)+((8191&(n=(n=n+Math.imul(c,it)|0)+Math.imul(d,rt)|0))<<13)|0;u=((o=o+Math.imul(d,it)|0)+(n>>>13)|0)+(kt>>>26)|0,kt&=67108863,i=Math.imul(N,F),n=(n=Math.imul(N,U))+Math.imul(I,F)|0,o=Math.imul(I,U),i=i+Math.imul(j,V)|0,n=(n=n+Math.imul(j,H)|0)+Math.imul(x,V)|0,o=o+Math.imul(x,H)|0,i=i+Math.imul(_,Z)|0,n=(n=n+Math.imul(_,K)|0)+Math.imul(E,Z)|0,o=o+Math.imul(E,K)|0,i=i+Math.imul(b,W)|0,n=(n=n+Math.imul(b,Y)|0)+Math.imul(k,W)|0,o=o+Math.imul(k,Y)|0,i=i+Math.imul(y,X)|0,n=(n=n+Math.imul(y,tt)|0)+Math.imul(w,X)|0,o=o+Math.imul(w,tt)|0,i=i+Math.imul(m,rt)|0,n=(n=n+Math.imul(m,it)|0)+Math.imul(p,rt)|0,o=o+Math.imul(p,it)|0;var Mt=(u+(i=i+Math.imul(c,ot)|0)|0)+((8191&(n=(n=n+Math.imul(c,at)|0)+Math.imul(d,ot)|0))<<13)|0;u=((o=o+Math.imul(d,at)|0)+(n>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,i=Math.imul(C,F),n=(n=Math.imul(C,U))+Math.imul(z,F)|0,o=Math.imul(z,U),i=i+Math.imul(N,V)|0,n=(n=n+Math.imul(N,H)|0)+Math.imul(I,V)|0,o=o+Math.imul(I,H)|0,i=i+Math.imul(j,Z)|0,n=(n=n+Math.imul(j,K)|0)+Math.imul(x,Z)|0,o=o+Math.imul(x,K)|0,i=i+Math.imul(_,W)|0,n=(n=n+Math.imul(_,Y)|0)+Math.imul(E,W)|0,o=o+Math.imul(E,Y)|0,i=i+Math.imul(b,X)|0,n=(n=n+Math.imul(b,tt)|0)+Math.imul(k,X)|0,o=o+Math.imul(k,tt)|0,i=i+Math.imul(y,rt)|0,n=(n=n+Math.imul(y,it)|0)+Math.imul(w,rt)|0,o=o+Math.imul(w,it)|0,i=i+Math.imul(m,ot)|0,n=(n=n+Math.imul(m,at)|0)+Math.imul(p,ot)|0,o=o+Math.imul(p,at)|0;var _t=(u+(i=i+Math.imul(c,ht)|0)|0)+((8191&(n=(n=n+Math.imul(c,ut)|0)+Math.imul(d,ht)|0))<<13)|0;u=((o=o+Math.imul(d,ut)|0)+(n>>>13)|0)+(_t>>>26)|0,_t&=67108863,i=Math.imul(R,F),n=(n=Math.imul(R,U))+Math.imul(P,F)|0,o=Math.imul(P,U),i=i+Math.imul(C,V)|0,n=(n=n+Math.imul(C,H)|0)+Math.imul(z,V)|0,o=o+Math.imul(z,H)|0,i=i+Math.imul(N,Z)|0,n=(n=n+Math.imul(N,K)|0)+Math.imul(I,Z)|0,o=o+Math.imul(I,K)|0,i=i+Math.imul(j,W)|0,n=(n=n+Math.imul(j,Y)|0)+Math.imul(x,W)|0,o=o+Math.imul(x,Y)|0,i=i+Math.imul(_,X)|0,n=(n=n+Math.imul(_,tt)|0)+Math.imul(E,X)|0,o=o+Math.imul(E,tt)|0,i=i+Math.imul(b,rt)|0,n=(n=n+Math.imul(b,it)|0)+Math.imul(k,rt)|0,o=o+Math.imul(k,it)|0,i=i+Math.imul(y,ot)|0,n=(n=n+Math.imul(y,at)|0)+Math.imul(w,ot)|0,o=o+Math.imul(w,at)|0,i=i+Math.imul(m,ht)|0,n=(n=n+Math.imul(m,ut)|0)+Math.imul(p,ht)|0,o=o+Math.imul(p,ut)|0;var Et=(u+(i=i+Math.imul(c,ct)|0)|0)+((8191&(n=(n=n+Math.imul(c,dt)|0)+Math.imul(d,ct)|0))<<13)|0;u=((o=o+Math.imul(d,dt)|0)+(n>>>13)|0)+(Et>>>26)|0,Et&=67108863,i=Math.imul(D,F),n=(n=Math.imul(D,U))+Math.imul($,F)|0,o=Math.imul($,U),i=i+Math.imul(R,V)|0,n=(n=n+Math.imul(R,H)|0)+Math.imul(P,V)|0,o=o+Math.imul(P,H)|0,i=i+Math.imul(C,Z)|0,n=(n=n+Math.imul(C,K)|0)+Math.imul(z,Z)|0,o=o+Math.imul(z,K)|0,i=i+Math.imul(N,W)|0,n=(n=n+Math.imul(N,Y)|0)+Math.imul(I,W)|0,o=o+Math.imul(I,Y)|0,i=i+Math.imul(j,X)|0,n=(n=n+Math.imul(j,tt)|0)+Math.imul(x,X)|0,o=o+Math.imul(x,tt)|0,i=i+Math.imul(_,rt)|0,n=(n=n+Math.imul(_,it)|0)+Math.imul(E,rt)|0,o=o+Math.imul(E,it)|0,i=i+Math.imul(b,ot)|0,n=(n=n+Math.imul(b,at)|0)+Math.imul(k,ot)|0,o=o+Math.imul(k,at)|0,i=i+Math.imul(y,ht)|0,n=(n=n+Math.imul(y,ut)|0)+Math.imul(w,ht)|0,o=o+Math.imul(w,ut)|0,i=i+Math.imul(m,ct)|0,n=(n=n+Math.imul(m,dt)|0)+Math.imul(p,ct)|0,o=o+Math.imul(p,dt)|0;var At=(u+(i=i+Math.imul(c,mt)|0)|0)+((8191&(n=(n=n+Math.imul(c,pt)|0)+Math.imul(d,mt)|0))<<13)|0;u=((o=o+Math.imul(d,pt)|0)+(n>>>13)|0)+(At>>>26)|0,At&=67108863,i=Math.imul(D,V),n=(n=Math.imul(D,H))+Math.imul($,V)|0,o=Math.imul($,H),i=i+Math.imul(R,Z)|0,n=(n=n+Math.imul(R,K)|0)+Math.imul(P,Z)|0,o=o+Math.imul(P,K)|0,i=i+Math.imul(C,W)|0,n=(n=n+Math.imul(C,Y)|0)+Math.imul(z,W)|0,o=o+Math.imul(z,Y)|0,i=i+Math.imul(N,X)|0,n=(n=n+Math.imul(N,tt)|0)+Math.imul(I,X)|0,o=o+Math.imul(I,tt)|0,i=i+Math.imul(j,rt)|0,n=(n=n+Math.imul(j,it)|0)+Math.imul(x,rt)|0,o=o+Math.imul(x,it)|0,i=i+Math.imul(_,ot)|0,n=(n=n+Math.imul(_,at)|0)+Math.imul(E,ot)|0,o=o+Math.imul(E,at)|0,i=i+Math.imul(b,ht)|0,n=(n=n+Math.imul(b,ut)|0)+Math.imul(k,ht)|0,o=o+Math.imul(k,ut)|0,i=i+Math.imul(y,ct)|0,n=(n=n+Math.imul(y,dt)|0)+Math.imul(w,ct)|0,o=o+Math.imul(w,dt)|0;var jt=(u+(i=i+Math.imul(m,mt)|0)|0)+((8191&(n=(n=n+Math.imul(m,pt)|0)+Math.imul(p,mt)|0))<<13)|0;u=((o=o+Math.imul(p,pt)|0)+(n>>>13)|0)+(jt>>>26)|0,jt&=67108863,i=Math.imul(D,Z),n=(n=Math.imul(D,K))+Math.imul($,Z)|0,o=Math.imul($,K),i=i+Math.imul(R,W)|0,n=(n=n+Math.imul(R,Y)|0)+Math.imul(P,W)|0,o=o+Math.imul(P,Y)|0,i=i+Math.imul(C,X)|0,n=(n=n+Math.imul(C,tt)|0)+Math.imul(z,X)|0,o=o+Math.imul(z,tt)|0,i=i+Math.imul(N,rt)|0,n=(n=n+Math.imul(N,it)|0)+Math.imul(I,rt)|0,o=o+Math.imul(I,it)|0,i=i+Math.imul(j,ot)|0,n=(n=n+Math.imul(j,at)|0)+Math.imul(x,ot)|0,o=o+Math.imul(x,at)|0,i=i+Math.imul(_,ht)|0,n=(n=n+Math.imul(_,ut)|0)+Math.imul(E,ht)|0,o=o+Math.imul(E,ut)|0,i=i+Math.imul(b,ct)|0,n=(n=n+Math.imul(b,dt)|0)+Math.imul(k,ct)|0,o=o+Math.imul(k,dt)|0;var xt=(u+(i=i+Math.imul(y,mt)|0)|0)+((8191&(n=(n=n+Math.imul(y,pt)|0)+Math.imul(w,mt)|0))<<13)|0;u=((o=o+Math.imul(w,pt)|0)+(n>>>13)|0)+(xt>>>26)|0,xt&=67108863,i=Math.imul(D,W),n=(n=Math.imul(D,Y))+Math.imul($,W)|0,o=Math.imul($,Y),i=i+Math.imul(R,X)|0,n=(n=n+Math.imul(R,tt)|0)+Math.imul(P,X)|0,o=o+Math.imul(P,tt)|0,i=i+Math.imul(C,rt)|0,n=(n=n+Math.imul(C,it)|0)+Math.imul(z,rt)|0,o=o+Math.imul(z,it)|0,i=i+Math.imul(N,ot)|0,n=(n=n+Math.imul(N,at)|0)+Math.imul(I,ot)|0,o=o+Math.imul(I,at)|0,i=i+Math.imul(j,ht)|0,n=(n=n+Math.imul(j,ut)|0)+Math.imul(x,ht)|0,o=o+Math.imul(x,ut)|0,i=i+Math.imul(_,ct)|0,n=(n=n+Math.imul(_,dt)|0)+Math.imul(E,ct)|0,o=o+Math.imul(E,dt)|0;var St=(u+(i=i+Math.imul(b,mt)|0)|0)+((8191&(n=(n=n+Math.imul(b,pt)|0)+Math.imul(k,mt)|0))<<13)|0;u=((o=o+Math.imul(k,pt)|0)+(n>>>13)|0)+(St>>>26)|0,St&=67108863,i=Math.imul(D,X),n=(n=Math.imul(D,tt))+Math.imul($,X)|0,o=Math.imul($,tt),i=i+Math.imul(R,rt)|0,n=(n=n+Math.imul(R,it)|0)+Math.imul(P,rt)|0,o=o+Math.imul(P,it)|0,i=i+Math.imul(C,ot)|0,n=(n=n+Math.imul(C,at)|0)+Math.imul(z,ot)|0,o=o+Math.imul(z,at)|0,i=i+Math.imul(N,ht)|0,n=(n=n+Math.imul(N,ut)|0)+Math.imul(I,ht)|0,o=o+Math.imul(I,ut)|0,i=i+Math.imul(j,ct)|0,n=(n=n+Math.imul(j,dt)|0)+Math.imul(x,ct)|0,o=o+Math.imul(x,dt)|0;var Nt=(u+(i=i+Math.imul(_,mt)|0)|0)+((8191&(n=(n=n+Math.imul(_,pt)|0)+Math.imul(E,mt)|0))<<13)|0;u=((o=o+Math.imul(E,pt)|0)+(n>>>13)|0)+(Nt>>>26)|0,Nt&=67108863,i=Math.imul(D,rt),n=(n=Math.imul(D,it))+Math.imul($,rt)|0,o=Math.imul($,it),i=i+Math.imul(R,ot)|0,n=(n=n+Math.imul(R,at)|0)+Math.imul(P,ot)|0,o=o+Math.imul(P,at)|0,i=i+Math.imul(C,ht)|0,n=(n=n+Math.imul(C,ut)|0)+Math.imul(z,ht)|0,o=o+Math.imul(z,ut)|0,i=i+Math.imul(N,ct)|0,n=(n=n+Math.imul(N,dt)|0)+Math.imul(I,ct)|0,o=o+Math.imul(I,dt)|0;var It=(u+(i=i+Math.imul(j,mt)|0)|0)+((8191&(n=(n=n+Math.imul(j,pt)|0)+Math.imul(x,mt)|0))<<13)|0;u=((o=o+Math.imul(x,pt)|0)+(n>>>13)|0)+(It>>>26)|0,It&=67108863,i=Math.imul(D,ot),n=(n=Math.imul(D,at))+Math.imul($,ot)|0,o=Math.imul($,at),i=i+Math.imul(R,ht)|0,n=(n=n+Math.imul(R,ut)|0)+Math.imul(P,ht)|0,o=o+Math.imul(P,ut)|0,i=i+Math.imul(C,ct)|0,n=(n=n+Math.imul(C,dt)|0)+Math.imul(z,ct)|0,o=o+Math.imul(z,dt)|0;var Tt=(u+(i=i+Math.imul(N,mt)|0)|0)+((8191&(n=(n=n+Math.imul(N,pt)|0)+Math.imul(I,mt)|0))<<13)|0;u=((o=o+Math.imul(I,pt)|0)+(n>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,i=Math.imul(D,ht),n=(n=Math.imul(D,ut))+Math.imul($,ht)|0,o=Math.imul($,ut),i=i+Math.imul(R,ct)|0,n=(n=n+Math.imul(R,dt)|0)+Math.imul(P,ct)|0,o=o+Math.imul(P,dt)|0;var Ct=(u+(i=i+Math.imul(C,mt)|0)|0)+((8191&(n=(n=n+Math.imul(C,pt)|0)+Math.imul(z,mt)|0))<<13)|0;u=((o=o+Math.imul(z,pt)|0)+(n>>>13)|0)+(Ct>>>26)|0,Ct&=67108863,i=Math.imul(D,ct),n=(n=Math.imul(D,dt))+Math.imul($,ct)|0,o=Math.imul($,dt);var zt=(u+(i=i+Math.imul(R,mt)|0)|0)+((8191&(n=(n=n+Math.imul(R,pt)|0)+Math.imul(P,mt)|0))<<13)|0;u=((o=o+Math.imul(P,pt)|0)+(n>>>13)|0)+(zt>>>26)|0,zt&=67108863;var Ot=(u+(i=Math.imul(D,mt))|0)+((8191&(n=(n=Math.imul(D,pt))+Math.imul($,mt)|0))<<13)|0;return u=((o=Math.imul($,pt))+(n>>>13)|0)+(Ot>>>26)|0,Ot&=67108863,h[0]=gt,h[1]=yt,h[2]=wt,h[3]=vt,h[4]=bt,h[5]=kt,h[6]=Mt,h[7]=_t,h[8]=Et,h[9]=At,h[10]=jt,h[11]=xt,h[12]=St,h[13]=Nt,h[14]=It,h[15]=Tt,h[16]=Ct,h[17]=zt,h[18]=Ot,0!==u&&(h[19]=u,r.length++),r};function g(t,e,r){r.negative=e.negative^t.negative,r.length=t.length+e.length;for(var i=0,n=0,o=0;o<r.length-1;o++){var a=n;n=0;for(var s=67108863&i,h=Math.min(o,e.length-1),u=Math.max(0,o-t.length+1);u<=h;u++){var l=o-u,c=(0|t.words[l])*(0|e.words[u]),d=67108863&c;s=67108863&(d=d+s|0),n+=(a=(a=a+(c/67108864|0)|0)+(d>>>26)|0)>>>26,a&=67108863}r.words[o]=s,i=a,a=n}return 0!==i?r.words[o]=i:r.length--,r._strip()}function y(t,e,r){return g(t,e,r)}Math.imul||(p=m),n.prototype.mulTo=function(t,e){var r=this.length+t.length;return 10===this.length&&10===t.length?p(this,t,e):r<63?m(this,t,e):r<1024?g(this,t,e):y(this,t,e)},n.prototype.mul=function(t){var e=new n(null);return e.words=new Array(this.length+t.length),this.mulTo(t,e)},n.prototype.mulf=function(t){var e=new n(null);return e.words=new Array(this.length+t.length),y(this,t,e)},n.prototype.imul=function(t){return this.clone().mulTo(t,this)},n.prototype.imuln=function(t){var e=t<0;e&&(t=-t),r("number"==typeof t),r(t<67108864);for(var i=0,n=0;n<this.length;n++){var o=(0|this.words[n])*t,a=(67108863&o)+(67108863&i);i>>=26,i+=o/67108864|0,i+=a>>>26,this.words[n]=67108863&a}return 0!==i&&(this.words[n]=i,this.length++),e?this.ineg():this},n.prototype.muln=function(t){return this.clone().imuln(t)},n.prototype.sqr=function(){return this.mul(this)},n.prototype.isqr=function(){return this.imul(this.clone())},n.prototype.pow=function(t){var e=function(t){for(var e=new Array(t.bitLength()),r=0;r<e.length;r++){var i=r/26|0,n=r%26;e[r]=t.words[i]>>>n&1}return e}(t);if(0===e.length)return new n(1);for(var r=this,i=0;i<e.length&&0===e[i];i++,r=r.sqr());if(++i<e.length)for(var o=r.sqr();i<e.length;i++,o=o.sqr())0!==e[i]&&(r=r.mul(o));return r},n.prototype.iushln=function(t){r("number"==typeof t&&t>=0);var e,i=t%26,n=(t-i)/26,o=67108863>>>26-i<<26-i;if(0!==i){var a=0;for(e=0;e<this.length;e++){var s=this.words[e]&o,h=(0|this.words[e])-s<<i;this.words[e]=h|a,a=s>>>26-i}a&&(this.words[e]=a,this.length++)}if(0!==n){for(e=this.length-1;e>=0;e--)this.words[e+n]=this.words[e];for(e=0;e<n;e++)this.words[e]=0;this.length+=n}return this._strip()},n.prototype.ishln=function(t){return r(0===this.negative),this.iushln(t)},n.prototype.iushrn=function(t,e,i){var n;r("number"==typeof t&&t>=0),n=e?(e-e%26)/26:0;var o=t%26,a=Math.min((t-o)/26,this.length),s=67108863^67108863>>>o<<o,h=i;if(n-=a,n=Math.max(0,n),h){for(var u=0;u<a;u++)h.words[u]=this.words[u];h.length=a}if(0===a);else if(this.length>a)for(this.length-=a,u=0;u<this.length;u++)this.words[u]=this.words[u+a];else this.words[0]=0,this.length=1;var l=0;for(u=this.length-1;u>=0&&(0!==l||u>=n);u--){var c=0|this.words[u];this.words[u]=l<<26-o|c>>>o,l=c&s}return h&&0!==l&&(h.words[h.length++]=l),0===this.length&&(this.words[0]=0,this.length=1),this._strip()},n.prototype.ishrn=function(t,e,i){return r(0===this.negative),this.iushrn(t,e,i)},n.prototype.shln=function(t){return this.clone().ishln(t)},n.prototype.ushln=function(t){return this.clone().iushln(t)},n.prototype.shrn=function(t){return this.clone().ishrn(t)},n.prototype.ushrn=function(t){return this.clone().iushrn(t)},n.prototype.testn=function(t){r("number"==typeof t&&t>=0);var e=t%26,i=(t-e)/26,n=1<<e;return!(this.length<=i)&&!!(this.words[i]&n)},n.prototype.imaskn=function(t){r("number"==typeof t&&t>=0);var e=t%26,i=(t-e)/26;if(r(0===this.negative,"imaskn works only with positive numbers"),this.length<=i)return this;if(0!==e&&i++,this.length=Math.min(i,this.length),0!==e){var n=67108863^67108863>>>e<<e;this.words[this.length-1]&=n}return this._strip()},n.prototype.maskn=function(t){return this.clone().imaskn(t)},n.prototype.iaddn=function(t){return r("number"==typeof t),r(t<67108864),t<0?this.isubn(-t):0!==this.negative?1===this.length&&(0|this.words[0])<=t?(this.words[0]=t-(0|this.words[0]),this.negative=0,this):(this.negative=0,this.isubn(t),this.negative=1,this):this._iaddn(t)},n.prototype._iaddn=function(t){this.words[0]+=t;for(var e=0;e<this.length&&this.words[e]>=67108864;e++)this.words[e]-=67108864,e===this.length-1?this.words[e+1]=1:this.words[e+1]++;return this.length=Math.max(this.length,e+1),this},n.prototype.isubn=function(t){if(r("number"==typeof t),r(t<67108864),t<0)return this.iaddn(-t);if(0!==this.negative)return this.negative=0,this.iaddn(t),this.negative=1,this;if(this.words[0]-=t,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var e=0;e<this.length&&this.words[e]<0;e++)this.words[e]+=67108864,this.words[e+1]-=1;return this._strip()},n.prototype.addn=function(t){return this.clone().iaddn(t)},n.prototype.subn=function(t){return this.clone().isubn(t)},n.prototype.iabs=function(){return this.negative=0,this},n.prototype.abs=function(){return this.clone().iabs()},n.prototype._ishlnsubmul=function(t,e,i){var n,o,a=t.length+i;this._expand(a);var s=0;for(n=0;n<t.length;n++){o=(0|this.words[n+i])+s;var h=(0|t.words[n])*e;s=((o-=67108863&h)>>26)-(h/67108864|0),this.words[n+i]=67108863&o}for(;n<this.length-i;n++)s=(o=(0|this.words[n+i])+s)>>26,this.words[n+i]=67108863&o;if(0===s)return this._strip();for(r(-1===s),s=0,n=0;n<this.length;n++)s=(o=-(0|this.words[n])+s)>>26,this.words[n]=67108863&o;return this.negative=1,this._strip()},n.prototype._wordDiv=function(t,e){var r=(this.length,t.length),i=this.clone(),o=t,a=0|o.words[o.length-1];0!==(r=26-this._countBits(a))&&(o=o.ushln(r),i.iushln(r),a=0|o.words[o.length-1]);var s,h=i.length-o.length;if("mod"!==e){(s=new n(null)).length=h+1,s.words=new Array(s.length);for(var u=0;u<s.length;u++)s.words[u]=0}var l=i.clone()._ishlnsubmul(o,1,h);0===l.negative&&(i=l,s&&(s.words[h]=1));for(var c=h-1;c>=0;c--){var d=67108864*(0|i.words[o.length+c])+(0|i.words[o.length+c-1]);for(d=Math.min(d/a|0,67108863),i._ishlnsubmul(o,d,c);0!==i.negative;)d--,i.negative=0,i._ishlnsubmul(o,1,c),i.isZero()||(i.negative^=1);s&&(s.words[c]=d)}return s&&s._strip(),i._strip(),"div"!==e&&0!==r&&i.iushrn(r),{div:s||null,mod:i}},n.prototype.divmod=function(t,e,i){return r(!t.isZero()),this.isZero()?{div:new n(0),mod:new n(0)}:0!==this.negative&&0===t.negative?(s=this.neg().divmod(t,e),"mod"!==e&&(o=s.div.neg()),"div"!==e&&(a=s.mod.neg(),i&&0!==a.negative&&a.iadd(t)),{div:o,mod:a}):0===this.negative&&0!==t.negative?(s=this.divmod(t.neg(),e),"mod"!==e&&(o=s.div.neg()),{div:o,mod:s.mod}):0!=(this.negative&t.negative)?(s=this.neg().divmod(t.neg(),e),"div"!==e&&(a=s.mod.neg(),i&&0!==a.negative&&a.isub(t)),{div:s.div,mod:a}):t.length>this.length||this.cmp(t)<0?{div:new n(0),mod:this}:1===t.length?"div"===e?{div:this.divn(t.words[0]),mod:null}:"mod"===e?{div:null,mod:new n(this.modrn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new n(this.modrn(t.words[0]))}:this._wordDiv(t,e);var o,a,s},n.prototype.div=function(t){return this.divmod(t,"div",!1).div},n.prototype.mod=function(t){return this.divmod(t,"mod",!1).mod},n.prototype.umod=function(t){return this.divmod(t,"mod",!0).mod},n.prototype.divRound=function(t){var e=this.divmod(t);if(e.mod.isZero())return e.div;var r=0!==e.div.negative?e.mod.isub(t):e.mod,i=t.ushrn(1),n=t.andln(1),o=r.cmp(i);return o<0||1===n&&0===o?e.div:0!==e.div.negative?e.div.isubn(1):e.div.iaddn(1)},n.prototype.modrn=function(t){var e=t<0;e&&(t=-t),r(t<=67108863);for(var i=(1<<26)%t,n=0,o=this.length-1;o>=0;o--)n=(i*n+(0|this.words[o]))%t;return e?-n:n},n.prototype.modn=function(t){return this.modrn(t)},n.prototype.idivn=function(t){var e=t<0;e&&(t=-t),r(t<=67108863);for(var i=0,n=this.length-1;n>=0;n--){var o=(0|this.words[n])+67108864*i;this.words[n]=o/t|0,i=o%t}return this._strip(),e?this.ineg():this},n.prototype.divn=function(t){return this.clone().idivn(t)},n.prototype.egcd=function(t){r(0===t.negative),r(!t.isZero());var e=this,i=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var o=new n(1),a=new n(0),s=new n(0),h=new n(1),u=0;e.isEven()&&i.isEven();)e.iushrn(1),i.iushrn(1),++u;for(var l=i.clone(),c=e.clone();!e.isZero();){for(var d=0,f=1;0==(e.words[0]&f)&&d<26;++d,f<<=1);if(d>0)for(e.iushrn(d);d-- >0;)(o.isOdd()||a.isOdd())&&(o.iadd(l),a.isub(c)),o.iushrn(1),a.iushrn(1);for(var m=0,p=1;0==(i.words[0]&p)&&m<26;++m,p<<=1);if(m>0)for(i.iushrn(m);m-- >0;)(s.isOdd()||h.isOdd())&&(s.iadd(l),h.isub(c)),s.iushrn(1),h.iushrn(1);e.cmp(i)>=0?(e.isub(i),o.isub(s),a.isub(h)):(i.isub(e),s.isub(o),h.isub(a))}return{a:s,b:h,gcd:i.iushln(u)}},n.prototype._invmp=function(t){r(0===t.negative),r(!t.isZero());var e=this,i=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var o,a=new n(1),s=new n(0),h=i.clone();e.cmpn(1)>0&&i.cmpn(1)>0;){for(var u=0,l=1;0==(e.words[0]&l)&&u<26;++u,l<<=1);if(u>0)for(e.iushrn(u);u-- >0;)a.isOdd()&&a.iadd(h),a.iushrn(1);for(var c=0,d=1;0==(i.words[0]&d)&&c<26;++c,d<<=1);if(c>0)for(i.iushrn(c);c-- >0;)s.isOdd()&&s.iadd(h),s.iushrn(1);e.cmp(i)>=0?(e.isub(i),a.isub(s)):(i.isub(e),s.isub(a))}return(o=0===e.cmpn(1)?a:s).cmpn(0)<0&&o.iadd(t),o},n.prototype.gcd=function(t){if(this.isZero())return t.abs();if(t.isZero())return this.abs();var e=this.clone(),r=t.clone();e.negative=0,r.negative=0;for(var i=0;e.isEven()&&r.isEven();i++)e.iushrn(1),r.iushrn(1);for(;;){for(;e.isEven();)e.iushrn(1);for(;r.isEven();)r.iushrn(1);var n=e.cmp(r);if(n<0){var o=e;e=r,r=o}else if(0===n||0===r.cmpn(1))break;e.isub(r)}return r.iushln(i)},n.prototype.invm=function(t){return this.egcd(t).a.umod(t)},n.prototype.isEven=function(){return 0==(1&this.words[0])},n.prototype.isOdd=function(){return 1==(1&this.words[0])},n.prototype.andln=function(t){return this.words[0]&t},n.prototype.bincn=function(t){r("number"==typeof t);var e=t%26,i=(t-e)/26,n=1<<e;if(this.length<=i)return this._expand(i+1),this.words[i]|=n,this;for(var o=n,a=i;0!==o&&a<this.length;a++){var s=0|this.words[a];o=(s+=o)>>>26,s&=67108863,this.words[a]=s}return 0!==o&&(this.words[a]=o,this.length++),this},n.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},n.prototype.cmpn=function(t){var e,i=t<0;if(0!==this.negative&&!i)return-1;if(0===this.negative&&i)return 1;if(this._strip(),this.length>1)e=1;else{i&&(t=-t),r(t<=67108863,"Number is too big");var n=0|this.words[0];e=n===t?0:n<t?-1:1}return 0!==this.negative?0|-e:e},n.prototype.cmp=function(t){if(0!==this.negative&&0===t.negative)return-1;if(0===this.negative&&0!==t.negative)return 1;var e=this.ucmp(t);return 0!==this.negative?0|-e:e},n.prototype.ucmp=function(t){if(this.length>t.length)return 1;if(this.length<t.length)return-1;for(var e=0,r=this.length-1;r>=0;r--){var i=0|this.words[r],n=0|t.words[r];if(i!==n){i<n?e=-1:i>n&&(e=1);break}}return e},n.prototype.gtn=function(t){return 1===this.cmpn(t)},n.prototype.gt=function(t){return 1===this.cmp(t)},n.prototype.gten=function(t){return this.cmpn(t)>=0},n.prototype.gte=function(t){return this.cmp(t)>=0},n.prototype.ltn=function(t){return-1===this.cmpn(t)},n.prototype.lt=function(t){return-1===this.cmp(t)},n.prototype.lten=function(t){return this.cmpn(t)<=0},n.prototype.lte=function(t){return this.cmp(t)<=0},n.prototype.eqn=function(t){return 0===this.cmpn(t)},n.prototype.eq=function(t){return 0===this.cmp(t)},n.red=function(t){return new E(t)},n.prototype.toRed=function(t){return r(!this.red,"Already a number in reduction context"),r(0===this.negative,"red works only with positives"),t.convertTo(this)._forceRed(t)},n.prototype.fromRed=function(){return r(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},n.prototype._forceRed=function(t){return this.red=t,this},n.prototype.forceRed=function(t){return r(!this.red,"Already a number in reduction context"),this._forceRed(t)},n.prototype.redAdd=function(t){return r(this.red,"redAdd works only with red numbers"),this.red.add(this,t)},n.prototype.redIAdd=function(t){return r(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,t)},n.prototype.redSub=function(t){return r(this.red,"redSub works only with red numbers"),this.red.sub(this,t)},n.prototype.redISub=function(t){return r(this.red,"redISub works only with red numbers"),this.red.isub(this,t)},n.prototype.redShl=function(t){return r(this.red,"redShl works only with red numbers"),this.red.shl(this,t)},n.prototype.redMul=function(t){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.mul(this,t)},n.prototype.redIMul=function(t){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.imul(this,t)},n.prototype.redSqr=function(){return r(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},n.prototype.redISqr=function(){return r(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},n.prototype.redSqrt=function(){return r(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},n.prototype.redInvm=function(){return r(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},n.prototype.redNeg=function(){return r(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},n.prototype.redPow=function(t){return r(this.red&&!t.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,t)};var w={k256:null,p224:null,p192:null,p25519:null};function v(t,e){this.name=t,this.p=new n(e,16),this.n=this.p.bitLength(),this.k=new n(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function b(){v.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function k(){v.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function M(){v.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function _(){v.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function E(t){if("string"==typeof t){var e=n._prime(t);this.m=e.p,this.prime=e}else r(t.gtn(1),"modulus must be greater than 1"),this.m=t,this.prime=null}function A(t){E.call(this,t),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new n(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)}v.prototype._tmp=function(){var t=new n(null);return t.words=new Array(Math.ceil(this.n/13)),t},v.prototype.ireduce=function(t){var e,r=t;do{this.split(r,this.tmp),e=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(e>this.n);var i=e<this.n?-1:r.ucmp(this.p);return 0===i?(r.words[0]=0,r.length=1):i>0?r.isub(this.p):void 0!==r.strip?r.strip():r._strip(),r},v.prototype.split=function(t,e){t.iushrn(this.n,0,e)},v.prototype.imulK=function(t){return t.imul(this.k)},i(b,v),b.prototype.split=function(t,e){for(var r=4194303,i=Math.min(t.length,9),n=0;n<i;n++)e.words[n]=t.words[n];if(e.length=i,t.length<=9)return t.words[0]=0,void(t.length=1);var o=t.words[9];for(e.words[e.length++]=o&r,n=10;n<t.length;n++){var a=0|t.words[n];t.words[n-10]=(a&r)<<4|o>>>22,o=a}o>>>=22,t.words[n-10]=o,0===o&&t.length>10?t.length-=10:t.length-=9},b.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var e=0,r=0;r<t.length;r++){var i=0|t.words[r];e+=977*i,t.words[r]=67108863&e,e=64*i+(e/67108864|0)}return 0===t.words[t.length-1]&&(t.length--,0===t.words[t.length-1]&&t.length--),t},i(k,v),i(M,v),i(_,v),_.prototype.imulK=function(t){for(var e=0,r=0;r<t.length;r++){var i=19*(0|t.words[r])+e,n=67108863&i;i>>>=26,t.words[r]=n,e=i}return 0!==e&&(t.words[t.length++]=e),t},n._prime=function(t){if(w[t])return w[t];var e;if("k256"===t)e=new b;else if("p224"===t)e=new k;else if("p192"===t)e=new M;else{if("p25519"!==t)throw new Error("Unknown prime "+t);e=new _}return w[t]=e,e},E.prototype._verify1=function(t){r(0===t.negative,"red works only with positives"),r(t.red,"red works only with red numbers")},E.prototype._verify2=function(t,e){r(0==(t.negative|e.negative),"red works only with positives"),r(t.red&&t.red===e.red,"red works only with red numbers")},E.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):(u(t,t.umod(this.m)._forceRed(this)),t)},E.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},E.prototype.add=function(t,e){this._verify2(t,e);var r=t.add(e);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},E.prototype.iadd=function(t,e){this._verify2(t,e);var r=t.iadd(e);return r.cmp(this.m)>=0&&r.isub(this.m),r},E.prototype.sub=function(t,e){this._verify2(t,e);var r=t.sub(e);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},E.prototype.isub=function(t,e){this._verify2(t,e);var r=t.isub(e);return r.cmpn(0)<0&&r.iadd(this.m),r},E.prototype.shl=function(t,e){return this._verify1(t),this.imod(t.ushln(e))},E.prototype.imul=function(t,e){return this._verify2(t,e),this.imod(t.imul(e))},E.prototype.mul=function(t,e){return this._verify2(t,e),this.imod(t.mul(e))},E.prototype.isqr=function(t){return this.imul(t,t.clone())},E.prototype.sqr=function(t){return this.mul(t,t)},E.prototype.sqrt=function(t){if(t.isZero())return t.clone();var e=this.m.andln(3);if(r(e%2==1),3===e){var i=this.m.add(new n(1)).iushrn(2);return this.pow(t,i)}for(var o=this.m.subn(1),a=0;!o.isZero()&&0===o.andln(1);)a++,o.iushrn(1);r(!o.isZero());var s=new n(1).toRed(this),h=s.redNeg(),u=this.m.subn(1).iushrn(1),l=this.m.bitLength();for(l=new n(2*l*l).toRed(this);0!==this.pow(l,u).cmp(h);)l.redIAdd(h);for(var c=this.pow(l,o),d=this.pow(t,o.addn(1).iushrn(1)),f=this.pow(t,o),m=a;0!==f.cmp(s);){for(var p=f,g=0;0!==p.cmp(s);g++)p=p.redSqr();r(g<m);var y=this.pow(c,new n(1).iushln(m-g-1));d=d.redMul(y),c=y.redSqr(),f=f.redMul(c),m=g}return d},E.prototype.invm=function(t){var e=t._invmp(this.m);return 0!==e.negative?(e.negative=0,this.imod(e).redNeg()):this.imod(e)},E.prototype.pow=function(t,e){if(e.isZero())return new n(1).toRed(this);if(0===e.cmpn(1))return t.clone();var r=new Array(16);r[0]=new n(1).toRed(this),r[1]=t;for(var i=2;i<r.length;i++)r[i]=this.mul(r[i-1],t);var o=r[0],a=0,s=0,h=e.bitLength()%26;for(0===h&&(h=26),i=e.length-1;i>=0;i--){for(var u=e.words[i],l=h-1;l>=0;l--){var c=u>>l&1;o!==r[0]&&(o=this.sqr(o)),0!==c||0!==a?(a<<=1,a|=c,(4===++s||0===i&&0===l)&&(o=this.mul(o,r[a]),s=0,a=0)):s=0}h=26}return o},E.prototype.convertTo=function(t){var e=t.umod(this.m);return e===t?e.clone():e},E.prototype.convertFrom=function(t){var e=t.clone();return e.red=null,e},n.mont=function(t){return new A(t)},i(A,E),A.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},A.prototype.convertFrom=function(t){var e=this.imod(t.mul(this.rinv));return e.red=null,e},A.prototype.imul=function(t,e){if(t.isZero()||e.isZero())return t.words[0]=0,t.length=1,t;var r=t.imul(e),i=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),n=r.isub(i).iushrn(this.shift),o=n;return n.cmp(this.m)>=0?o=n.isub(this.m):n.cmpn(0)<0&&(o=n.iadd(this.m)),o._forceRed(this)},A.prototype.mul=function(t,e){if(t.isZero()||e.isZero())return new n(0)._forceRed(this);var r=t.mul(e),i=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),o=r.isub(i).iushrn(this.shift),a=o;return o.cmp(this.m)>=0?a=o.isub(this.m):o.cmpn(0)<0&&(a=o.iadd(this.m)),a._forceRed(this)},A.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}(t,i)}));var vn=wn.BN;const bn=new w("bignumber/5.6.2"),kn={},Mn=9007199254740991;let _n=!1;class En{constructor(t,e){t!==kn&&bn.throwError("cannot call constructor directly; use BigNumber.from",w.errors.UNSUPPORTED_OPERATION,{operation:"new (BigNumber)"}),this._hex=e,this._isBigNumber=!0,Object.freeze(this)}fromTwos(t){return jn(xn(this).fromTwos(t))}toTwos(t){return jn(xn(this).toTwos(t))}abs(){return"-"===this._hex[0]?En.from(this._hex.substring(1)):this}add(t){return jn(xn(this).add(xn(t)))}sub(t){return jn(xn(this).sub(xn(t)))}div(t){return En.from(t).isZero()&&Sn("division-by-zero","div"),jn(xn(this).div(xn(t)))}mul(t){return jn(xn(this).mul(xn(t)))}mod(t){const e=xn(t);return e.isNeg()&&Sn("division-by-zero","mod"),jn(xn(this).umod(e))}pow(t){const e=xn(t);return e.isNeg()&&Sn("negative-power","pow"),jn(xn(this).pow(e))}and(t){const e=xn(t);return(this.isNegative()||e.isNeg())&&Sn("unbound-bitwise-result","and"),jn(xn(this).and(e))}or(t){const e=xn(t);return(this.isNegative()||e.isNeg())&&Sn("unbound-bitwise-result","or"),jn(xn(this).or(e))}xor(t){const e=xn(t);return(this.isNegative()||e.isNeg())&&Sn("unbound-bitwise-result","xor"),jn(xn(this).xor(e))}mask(t){return(this.isNegative()||t<0)&&Sn("negative-width","mask"),jn(xn(this).maskn(t))}shl(t){return(this.isNegative()||t<0)&&Sn("negative-width","shl"),jn(xn(this).shln(t))}shr(t){return(this.isNegative()||t<0)&&Sn("negative-width","shr"),jn(xn(this).shrn(t))}eq(t){return xn(this).eq(xn(t))}lt(t){return xn(this).lt(xn(t))}lte(t){return xn(this).lte(xn(t))}gt(t){return xn(this).gt(xn(t))}gte(t){return xn(this).gte(xn(t))}isNegative(){return"-"===this._hex[0]}isZero(){return xn(this).isZero()}toNumber(){try{return xn(this).toNumber()}catch(t){Sn("overflow","toNumber",this.toString())}return null}toBigInt(){try{return BigInt(this.toString())}catch(t){}return bn.throwError("this platform does not support BigInt",w.errors.UNSUPPORTED_OPERATION,{value:this.toString()})}toString(){return arguments.length>0&&(10===arguments[0]?_n||(_n=!0,bn.warn("BigNumber.toString does not accept any parameters; base-10 is assumed")):16===arguments[0]?bn.throwError("BigNumber.toString does not accept any parameters; use bigNumber.toHexString()",w.errors.UNEXPECTED_ARGUMENT,{}):bn.throwError("BigNumber.toString does not accept parameters",w.errors.UNEXPECTED_ARGUMENT,{})),xn(this).toString(10)}toHexString(){return this._hex}toJSON(t){return{type:"BigNumber",hex:this.toHexString()}}static from(t){if(t instanceof En)return t;if("string"==typeof t)return t.match(/^-?0x[0-9a-f]+$/i)?new En(kn,An(t)):t.match(/^-?[0-9]+$/)?new En(kn,An(new vn(t))):bn.throwArgumentError("invalid BigNumber string","value",t);if("number"==typeof t)return t%1&&Sn("underflow","BigNumber.from",t),(t>=Mn||t<=-Mn)&&Sn("overflow","BigNumber.from",t),En.from(String(t));const e=t;if("bigint"==typeof e)return En.from(e.toString());if(E(e))return En.from(I(e));if(e)if(e.toHexString){const t=e.toHexString();if("string"==typeof t)return En.from(t)}else{let t=e._hex;if(null==t&&"BigNumber"===e.type&&(t=e.hex),"string"==typeof t&&(S(t)||"-"===t[0]&&S(t.substring(1))))return En.from(t)}return bn.throwArgumentError("invalid BigNumber value","value",t)}static isBigNumber(t){return!(!t||!t._isBigNumber)}}function An(t){if("string"!=typeof t)return An(t.toString(16));if("-"===t[0])return"-"===(t=t.substring(1))[0]&&bn.throwArgumentError("invalid hex","value",t),"0x00"===(t=An(t))?t:"-"+t;if("0x"!==t.substring(0,2)&&(t="0x"+t),"0x"===t)return"0x00";for(t.length%2&&(t="0x0"+t.substring(2));t.length>4&&"0x00"===t.substring(0,4);)t="0x"+t.substring(4);return t}function jn(t){return En.from(An(t))}function xn(t){const e=En.from(t).toHexString();return"-"===e[0]?new vn("-"+e.substring(3),16):new vn(e.substring(2),16)}function Sn(t,e,r){const i={fault:t,operation:e};return null!=r&&(i.value=r),bn.throwError(t,w.errors.NUMERIC_FAULT,i)}var Nn=a((function(t){!function(t,e){function r(t,e){if(!t)throw new Error(e||"Assertion failed")}function i(t,e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}function n(t,e,r){if(n.isBN(t))return t;this.negative=0,this.words=null,this.length=0,this.red=null,null!==t&&("le"!==e&&"be"!==e||(r=e,e=10),this._init(t||0,e||10,r||"be"))}var o;"object"==typeof t?t.exports=n:e.BN=n,n.BN=n,n.wordSize=26;try{o="undefined"!=typeof window&&void 0!==window.Buffer?window.Buffer:Pt.Buffer}catch(t){}function a(t,e){var i=t.charCodeAt(e);return i>=48&&i<=57?i-48:i>=65&&i<=70?i-55:i>=97&&i<=102?i-87:void r(!1,"Invalid character in "+t)}function s(t,e,r){var i=a(t,r);return r-1>=e&&(i|=a(t,r-1)<<4),i}function h(t,e,i,n){for(var o=0,a=0,s=Math.min(t.length,i),h=e;h<s;h++){var u=t.charCodeAt(h)-48;o*=n,a=u>=49?u-49+10:u>=17?u-17+10:u,r(u>=0&&a<n,"Invalid character"),o+=a}return o}function u(t,e){t.words=e.words,t.length=e.length,t.negative=e.negative,t.red=e.red}if(n.isBN=function(t){return t instanceof n||null!==t&&"object"==typeof t&&t.constructor.wordSize===n.wordSize&&Array.isArray(t.words)},n.max=function(t,e){return t.cmp(e)>0?t:e},n.min=function(t,e){return t.cmp(e)<0?t:e},n.prototype._init=function(t,e,i){if("number"==typeof t)return this._initNumber(t,e,i);if("object"==typeof t)return this._initArray(t,e,i);"hex"===e&&(e=16),r(e===(0|e)&&e>=2&&e<=36);var n=0;"-"===(t=t.toString().replace(/\s+/g,""))[0]&&(n++,this.negative=1),n<t.length&&(16===e?this._parseHex(t,n,i):(this._parseBase(t,e,n),"le"===i&&this._initArray(this.toArray(),e,i)))},n.prototype._initNumber=function(t,e,i){t<0&&(this.negative=1,t=-t),t<67108864?(this.words=[67108863&t],this.length=1):t<4503599627370496?(this.words=[67108863&t,t/67108864&67108863],this.length=2):(r(t<9007199254740992),this.words=[67108863&t,t/67108864&67108863,1],this.length=3),"le"===i&&this._initArray(this.toArray(),e,i)},n.prototype._initArray=function(t,e,i){if(r("number"==typeof t.length),t.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(t.length/3),this.words=new Array(this.length);for(var n=0;n<this.length;n++)this.words[n]=0;var o,a,s=0;if("be"===i)for(n=t.length-1,o=0;n>=0;n-=3)a=t[n]|t[n-1]<<8|t[n-2]<<16,this.words[o]|=a<<s&67108863,this.words[o+1]=a>>>26-s&67108863,(s+=24)>=26&&(s-=26,o++);else if("le"===i)for(n=0,o=0;n<t.length;n+=3)a=t[n]|t[n+1]<<8|t[n+2]<<16,this.words[o]|=a<<s&67108863,this.words[o+1]=a>>>26-s&67108863,(s+=24)>=26&&(s-=26,o++);return this._strip()},n.prototype._parseHex=function(t,e,r){this.length=Math.ceil((t.length-e)/6),this.words=new Array(this.length);for(var i=0;i<this.length;i++)this.words[i]=0;var n,o=0,a=0;if("be"===r)for(i=t.length-1;i>=e;i-=2)n=s(t,e,i)<<o,this.words[a]|=67108863&n,o>=18?(o-=18,a+=1,this.words[a]|=n>>>26):o+=8;else for(i=(t.length-e)%2==0?e+1:e;i<t.length;i+=2)n=s(t,e,i)<<o,this.words[a]|=67108863&n,o>=18?(o-=18,a+=1,this.words[a]|=n>>>26):o+=8;this._strip()},n.prototype._parseBase=function(t,e,r){this.words=[0],this.length=1;for(var i=0,n=1;n<=67108863;n*=e)i++;i--,n=n/e|0;for(var o=t.length-r,a=o%i,s=Math.min(o,o-a)+r,u=0,l=r;l<s;l+=i)u=h(t,l,l+i,e),this.imuln(n),this.words[0]+u<67108864?this.words[0]+=u:this._iaddn(u);if(0!==a){var c=1;for(u=h(t,l,t.length,e),l=0;l<a;l++)c*=e;this.imuln(c),this.words[0]+u<67108864?this.words[0]+=u:this._iaddn(u)}this._strip()},n.prototype.copy=function(t){t.words=new Array(this.length);for(var e=0;e<this.length;e++)t.words[e]=this.words[e];t.length=this.length,t.negative=this.negative,t.red=this.red},n.prototype._move=function(t){u(t,this)},n.prototype.clone=function(){var t=new n(null);return this.copy(t),t},n.prototype._expand=function(t){for(;this.length<t;)this.words[this.length++]=0;return this},n.prototype._strip=function(){for(;this.length>1&&0===this.words[this.length-1];)this.length--;return this._normSign()},n.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},"undefined"!=typeof Symbol&&"function"==typeof Symbol.for)try{n.prototype[Symbol.for("nodejs.util.inspect.custom")]=l}catch(t){n.prototype.inspect=l}else n.prototype.inspect=l;function l(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"}var c=["","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"],d=[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],f=[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];n.prototype.toString=function(t,e){var i;if(e=0|e||1,16===(t=t||10)||"hex"===t){i="";for(var n=0,o=0,a=0;a<this.length;a++){var s=this.words[a],h=(16777215&(s<<n|o)).toString(16);o=s>>>24-n&16777215,(n+=2)>=26&&(n-=26,a--),i=0!==o||a!==this.length-1?c[6-h.length]+h+i:h+i}for(0!==o&&(i=o.toString(16)+i);i.length%e!=0;)i="0"+i;return 0!==this.negative&&(i="-"+i),i}if(t===(0|t)&&t>=2&&t<=36){var u=d[t],l=f[t];i="";var m=this.clone();for(m.negative=0;!m.isZero();){var p=m.modrn(l).toString(t);i=(m=m.idivn(l)).isZero()?p+i:c[u-p.length]+p+i}for(this.isZero()&&(i="0"+i);i.length%e!=0;)i="0"+i;return 0!==this.negative&&(i="-"+i),i}r(!1,"Base should be between 2 and 36")},n.prototype.toNumber=function(){var t=this.words[0];return 2===this.length?t+=67108864*this.words[1]:3===this.length&&1===this.words[2]?t+=4503599627370496+67108864*this.words[1]:this.length>2&&r(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-t:t},n.prototype.toJSON=function(){return this.toString(16,2)},o&&(n.prototype.toBuffer=function(t,e){return this.toArrayLike(o,t,e)}),n.prototype.toArray=function(t,e){return this.toArrayLike(Array,t,e)};function m(t,e,r){r.negative=e.negative^t.negative;var i=t.length+e.length|0;r.length=i,i=i-1|0;var n=0|t.words[0],o=0|e.words[0],a=n*o,s=67108863&a,h=a/67108864|0;r.words[0]=s;for(var u=1;u<i;u++){for(var l=h>>>26,c=67108863&h,d=Math.min(u,e.length-1),f=Math.max(0,u-t.length+1);f<=d;f++){var m=u-f|0;l+=(a=(n=0|t.words[m])*(o=0|e.words[f])+c)/67108864|0,c=67108863&a}r.words[u]=0|c,h=0|l}return 0!==h?r.words[u]=0|h:r.length--,r._strip()}n.prototype.toArrayLike=function(t,e,i){this._strip();var n=this.byteLength(),o=i||Math.max(1,n);r(n<=o,"byte array longer than desired length"),r(o>0,"Requested array length <= 0");var a=function(t,e){return t.allocUnsafe?t.allocUnsafe(e):new t(e)}(t,o);return this["_toArrayLike"+("le"===e?"LE":"BE")](a,n),a},n.prototype._toArrayLikeLE=function(t,e){for(var r=0,i=0,n=0,o=0;n<this.length;n++){var a=this.words[n]<<o|i;t[r++]=255&a,r<t.length&&(t[r++]=a>>8&255),r<t.length&&(t[r++]=a>>16&255),6===o?(r<t.length&&(t[r++]=a>>24&255),i=0,o=0):(i=a>>>24,o+=2)}if(r<t.length)for(t[r++]=i;r<t.length;)t[r++]=0},n.prototype._toArrayLikeBE=function(t,e){for(var r=t.length-1,i=0,n=0,o=0;n<this.length;n++){var a=this.words[n]<<o|i;t[r--]=255&a,r>=0&&(t[r--]=a>>8&255),r>=0&&(t[r--]=a>>16&255),6===o?(r>=0&&(t[r--]=a>>24&255),i=0,o=0):(i=a>>>24,o+=2)}if(r>=0)for(t[r--]=i;r>=0;)t[r--]=0},Math.clz32?n.prototype._countBits=function(t){return 32-Math.clz32(t)}:n.prototype._countBits=function(t){var e=t,r=0;return e>=4096&&(r+=13,e>>>=13),e>=64&&(r+=7,e>>>=7),e>=8&&(r+=4,e>>>=4),e>=2&&(r+=2,e>>>=2),r+e},n.prototype._zeroBits=function(t){if(0===t)return 26;var e=t,r=0;return 0==(8191&e)&&(r+=13,e>>>=13),0==(127&e)&&(r+=7,e>>>=7),0==(15&e)&&(r+=4,e>>>=4),0==(3&e)&&(r+=2,e>>>=2),0==(1&e)&&r++,r},n.prototype.bitLength=function(){var t=this.words[this.length-1],e=this._countBits(t);return 26*(this.length-1)+e},n.prototype.zeroBits=function(){if(this.isZero())return 0;for(var t=0,e=0;e<this.length;e++){var r=this._zeroBits(this.words[e]);if(t+=r,26!==r)break}return t},n.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},n.prototype.toTwos=function(t){return 0!==this.negative?this.abs().inotn(t).iaddn(1):this.clone()},n.prototype.fromTwos=function(t){return this.testn(t-1)?this.notn(t).iaddn(1).ineg():this.clone()},n.prototype.isNeg=function(){return 0!==this.negative},n.prototype.neg=function(){return this.clone().ineg()},n.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},n.prototype.iuor=function(t){for(;this.length<t.length;)this.words[this.length++]=0;for(var e=0;e<t.length;e++)this.words[e]=this.words[e]|t.words[e];return this._strip()},n.prototype.ior=function(t){return r(0==(this.negative|t.negative)),this.iuor(t)},n.prototype.or=function(t){return this.length>t.length?this.clone().ior(t):t.clone().ior(this)},n.prototype.uor=function(t){return this.length>t.length?this.clone().iuor(t):t.clone().iuor(this)},n.prototype.iuand=function(t){var e;e=this.length>t.length?t:this;for(var r=0;r<e.length;r++)this.words[r]=this.words[r]&t.words[r];return this.length=e.length,this._strip()},n.prototype.iand=function(t){return r(0==(this.negative|t.negative)),this.iuand(t)},n.prototype.and=function(t){return this.length>t.length?this.clone().iand(t):t.clone().iand(this)},n.prototype.uand=function(t){return this.length>t.length?this.clone().iuand(t):t.clone().iuand(this)},n.prototype.iuxor=function(t){var e,r;this.length>t.length?(e=this,r=t):(e=t,r=this);for(var i=0;i<r.length;i++)this.words[i]=e.words[i]^r.words[i];if(this!==e)for(;i<e.length;i++)this.words[i]=e.words[i];return this.length=e.length,this._strip()},n.prototype.ixor=function(t){return r(0==(this.negative|t.negative)),this.iuxor(t)},n.prototype.xor=function(t){return this.length>t.length?this.clone().ixor(t):t.clone().ixor(this)},n.prototype.uxor=function(t){return this.length>t.length?this.clone().iuxor(t):t.clone().iuxor(this)},n.prototype.inotn=function(t){r("number"==typeof t&&t>=0);var e=0|Math.ceil(t/26),i=t%26;this._expand(e),i>0&&e--;for(var n=0;n<e;n++)this.words[n]=67108863&~this.words[n];return i>0&&(this.words[n]=~this.words[n]&67108863>>26-i),this._strip()},n.prototype.notn=function(t){return this.clone().inotn(t)},n.prototype.setn=function(t,e){r("number"==typeof t&&t>=0);var i=t/26|0,n=t%26;return this._expand(i+1),this.words[i]=e?this.words[i]|1<<n:this.words[i]&~(1<<n),this._strip()},n.prototype.iadd=function(t){var e,r,i;if(0!==this.negative&&0===t.negative)return this.negative=0,e=this.isub(t),this.negative^=1,this._normSign();if(0===this.negative&&0!==t.negative)return t.negative=0,e=this.isub(t),t.negative=1,e._normSign();this.length>t.length?(r=this,i=t):(r=t,i=this);for(var n=0,o=0;o<i.length;o++)e=(0|r.words[o])+(0|i.words[o])+n,this.words[o]=67108863&e,n=e>>>26;for(;0!==n&&o<r.length;o++)e=(0|r.words[o])+n,this.words[o]=67108863&e,n=e>>>26;if(this.length=r.length,0!==n)this.words[this.length]=n,this.length++;else if(r!==this)for(;o<r.length;o++)this.words[o]=r.words[o];return this},n.prototype.add=function(t){var e;return 0!==t.negative&&0===this.negative?(t.negative=0,e=this.sub(t),t.negative^=1,e):0===t.negative&&0!==this.negative?(this.negative=0,e=t.sub(this),this.negative=1,e):this.length>t.length?this.clone().iadd(t):t.clone().iadd(this)},n.prototype.isub=function(t){if(0!==t.negative){t.negative=0;var e=this.iadd(t);return t.negative=1,e._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(t),this.negative=1,this._normSign();var r,i,n=this.cmp(t);if(0===n)return this.negative=0,this.length=1,this.words[0]=0,this;n>0?(r=this,i=t):(r=t,i=this);for(var o=0,a=0;a<i.length;a++)o=(e=(0|r.words[a])-(0|i.words[a])+o)>>26,this.words[a]=67108863&e;for(;0!==o&&a<r.length;a++)o=(e=(0|r.words[a])+o)>>26,this.words[a]=67108863&e;if(0===o&&a<r.length&&r!==this)for(;a<r.length;a++)this.words[a]=r.words[a];return this.length=Math.max(this.length,a),r!==this&&(this.negative=1),this._strip()},n.prototype.sub=function(t){return this.clone().isub(t)};var p=function(t,e,r){var i,n,o,a=t.words,s=e.words,h=r.words,u=0,l=0|a[0],c=8191&l,d=l>>>13,f=0|a[1],m=8191&f,p=f>>>13,g=0|a[2],y=8191&g,w=g>>>13,v=0|a[3],b=8191&v,k=v>>>13,M=0|a[4],_=8191&M,E=M>>>13,A=0|a[5],j=8191&A,x=A>>>13,S=0|a[6],N=8191&S,I=S>>>13,T=0|a[7],C=8191&T,z=T>>>13,O=0|a[8],R=8191&O,P=O>>>13,B=0|a[9],D=8191&B,$=B>>>13,L=0|s[0],F=8191&L,U=L>>>13,q=0|s[1],V=8191&q,H=q>>>13,G=0|s[2],Z=8191&G,K=G>>>13,J=0|s[3],W=8191&J,Y=J>>>13,Q=0|s[4],X=8191&Q,tt=Q>>>13,et=0|s[5],rt=8191&et,it=et>>>13,nt=0|s[6],ot=8191&nt,at=nt>>>13,st=0|s[7],ht=8191&st,ut=st>>>13,lt=0|s[8],ct=8191&lt,dt=lt>>>13,ft=0|s[9],mt=8191&ft,pt=ft>>>13;r.negative=t.negative^e.negative,r.length=19;var gt=(u+(i=Math.imul(c,F))|0)+((8191&(n=(n=Math.imul(c,U))+Math.imul(d,F)|0))<<13)|0;u=((o=Math.imul(d,U))+(n>>>13)|0)+(gt>>>26)|0,gt&=67108863,i=Math.imul(m,F),n=(n=Math.imul(m,U))+Math.imul(p,F)|0,o=Math.imul(p,U);var yt=(u+(i=i+Math.imul(c,V)|0)|0)+((8191&(n=(n=n+Math.imul(c,H)|0)+Math.imul(d,V)|0))<<13)|0;u=((o=o+Math.imul(d,H)|0)+(n>>>13)|0)+(yt>>>26)|0,yt&=67108863,i=Math.imul(y,F),n=(n=Math.imul(y,U))+Math.imul(w,F)|0,o=Math.imul(w,U),i=i+Math.imul(m,V)|0,n=(n=n+Math.imul(m,H)|0)+Math.imul(p,V)|0,o=o+Math.imul(p,H)|0;var wt=(u+(i=i+Math.imul(c,Z)|0)|0)+((8191&(n=(n=n+Math.imul(c,K)|0)+Math.imul(d,Z)|0))<<13)|0;u=((o=o+Math.imul(d,K)|0)+(n>>>13)|0)+(wt>>>26)|0,wt&=67108863,i=Math.imul(b,F),n=(n=Math.imul(b,U))+Math.imul(k,F)|0,o=Math.imul(k,U),i=i+Math.imul(y,V)|0,n=(n=n+Math.imul(y,H)|0)+Math.imul(w,V)|0,o=o+Math.imul(w,H)|0,i=i+Math.imul(m,Z)|0,n=(n=n+Math.imul(m,K)|0)+Math.imul(p,Z)|0,o=o+Math.imul(p,K)|0;var vt=(u+(i=i+Math.imul(c,W)|0)|0)+((8191&(n=(n=n+Math.imul(c,Y)|0)+Math.imul(d,W)|0))<<13)|0;u=((o=o+Math.imul(d,Y)|0)+(n>>>13)|0)+(vt>>>26)|0,vt&=67108863,i=Math.imul(_,F),n=(n=Math.imul(_,U))+Math.imul(E,F)|0,o=Math.imul(E,U),i=i+Math.imul(b,V)|0,n=(n=n+Math.imul(b,H)|0)+Math.imul(k,V)|0,o=o+Math.imul(k,H)|0,i=i+Math.imul(y,Z)|0,n=(n=n+Math.imul(y,K)|0)+Math.imul(w,Z)|0,o=o+Math.imul(w,K)|0,i=i+Math.imul(m,W)|0,n=(n=n+Math.imul(m,Y)|0)+Math.imul(p,W)|0,o=o+Math.imul(p,Y)|0;var bt=(u+(i=i+Math.imul(c,X)|0)|0)+((8191&(n=(n=n+Math.imul(c,tt)|0)+Math.imul(d,X)|0))<<13)|0;u=((o=o+Math.imul(d,tt)|0)+(n>>>13)|0)+(bt>>>26)|0,bt&=67108863,i=Math.imul(j,F),n=(n=Math.imul(j,U))+Math.imul(x,F)|0,o=Math.imul(x,U),i=i+Math.imul(_,V)|0,n=(n=n+Math.imul(_,H)|0)+Math.imul(E,V)|0,o=o+Math.imul(E,H)|0,i=i+Math.imul(b,Z)|0,n=(n=n+Math.imul(b,K)|0)+Math.imul(k,Z)|0,o=o+Math.imul(k,K)|0,i=i+Math.imul(y,W)|0,n=(n=n+Math.imul(y,Y)|0)+Math.imul(w,W)|0,o=o+Math.imul(w,Y)|0,i=i+Math.imul(m,X)|0,n=(n=n+Math.imul(m,tt)|0)+Math.imul(p,X)|0,o=o+Math.imul(p,tt)|0;var kt=(u+(i=i+Math.imul(c,rt)|0)|0)+((8191&(n=(n=n+Math.imul(c,it)|0)+Math.imul(d,rt)|0))<<13)|0;u=((o=o+Math.imul(d,it)|0)+(n>>>13)|0)+(kt>>>26)|0,kt&=67108863,i=Math.imul(N,F),n=(n=Math.imul(N,U))+Math.imul(I,F)|0,o=Math.imul(I,U),i=i+Math.imul(j,V)|0,n=(n=n+Math.imul(j,H)|0)+Math.imul(x,V)|0,o=o+Math.imul(x,H)|0,i=i+Math.imul(_,Z)|0,n=(n=n+Math.imul(_,K)|0)+Math.imul(E,Z)|0,o=o+Math.imul(E,K)|0,i=i+Math.imul(b,W)|0,n=(n=n+Math.imul(b,Y)|0)+Math.imul(k,W)|0,o=o+Math.imul(k,Y)|0,i=i+Math.imul(y,X)|0,n=(n=n+Math.imul(y,tt)|0)+Math.imul(w,X)|0,o=o+Math.imul(w,tt)|0,i=i+Math.imul(m,rt)|0,n=(n=n+Math.imul(m,it)|0)+Math.imul(p,rt)|0,o=o+Math.imul(p,it)|0;var Mt=(u+(i=i+Math.imul(c,ot)|0)|0)+((8191&(n=(n=n+Math.imul(c,at)|0)+Math.imul(d,ot)|0))<<13)|0;u=((o=o+Math.imul(d,at)|0)+(n>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,i=Math.imul(C,F),n=(n=Math.imul(C,U))+Math.imul(z,F)|0,o=Math.imul(z,U),i=i+Math.imul(N,V)|0,n=(n=n+Math.imul(N,H)|0)+Math.imul(I,V)|0,o=o+Math.imul(I,H)|0,i=i+Math.imul(j,Z)|0,n=(n=n+Math.imul(j,K)|0)+Math.imul(x,Z)|0,o=o+Math.imul(x,K)|0,i=i+Math.imul(_,W)|0,n=(n=n+Math.imul(_,Y)|0)+Math.imul(E,W)|0,o=o+Math.imul(E,Y)|0,i=i+Math.imul(b,X)|0,n=(n=n+Math.imul(b,tt)|0)+Math.imul(k,X)|0,o=o+Math.imul(k,tt)|0,i=i+Math.imul(y,rt)|0,n=(n=n+Math.imul(y,it)|0)+Math.imul(w,rt)|0,o=o+Math.imul(w,it)|0,i=i+Math.imul(m,ot)|0,n=(n=n+Math.imul(m,at)|0)+Math.imul(p,ot)|0,o=o+Math.imul(p,at)|0;var _t=(u+(i=i+Math.imul(c,ht)|0)|0)+((8191&(n=(n=n+Math.imul(c,ut)|0)+Math.imul(d,ht)|0))<<13)|0;u=((o=o+Math.imul(d,ut)|0)+(n>>>13)|0)+(_t>>>26)|0,_t&=67108863,i=Math.imul(R,F),n=(n=Math.imul(R,U))+Math.imul(P,F)|0,o=Math.imul(P,U),i=i+Math.imul(C,V)|0,n=(n=n+Math.imul(C,H)|0)+Math.imul(z,V)|0,o=o+Math.imul(z,H)|0,i=i+Math.imul(N,Z)|0,n=(n=n+Math.imul(N,K)|0)+Math.imul(I,Z)|0,o=o+Math.imul(I,K)|0,i=i+Math.imul(j,W)|0,n=(n=n+Math.imul(j,Y)|0)+Math.imul(x,W)|0,o=o+Math.imul(x,Y)|0,i=i+Math.imul(_,X)|0,n=(n=n+Math.imul(_,tt)|0)+Math.imul(E,X)|0,o=o+Math.imul(E,tt)|0,i=i+Math.imul(b,rt)|0,n=(n=n+Math.imul(b,it)|0)+Math.imul(k,rt)|0,o=o+Math.imul(k,it)|0,i=i+Math.imul(y,ot)|0,n=(n=n+Math.imul(y,at)|0)+Math.imul(w,ot)|0,o=o+Math.imul(w,at)|0,i=i+Math.imul(m,ht)|0,n=(n=n+Math.imul(m,ut)|0)+Math.imul(p,ht)|0,o=o+Math.imul(p,ut)|0;var Et=(u+(i=i+Math.imul(c,ct)|0)|0)+((8191&(n=(n=n+Math.imul(c,dt)|0)+Math.imul(d,ct)|0))<<13)|0;u=((o=o+Math.imul(d,dt)|0)+(n>>>13)|0)+(Et>>>26)|0,Et&=67108863,i=Math.imul(D,F),n=(n=Math.imul(D,U))+Math.imul($,F)|0,o=Math.imul($,U),i=i+Math.imul(R,V)|0,n=(n=n+Math.imul(R,H)|0)+Math.imul(P,V)|0,o=o+Math.imul(P,H)|0,i=i+Math.imul(C,Z)|0,n=(n=n+Math.imul(C,K)|0)+Math.imul(z,Z)|0,o=o+Math.imul(z,K)|0,i=i+Math.imul(N,W)|0,n=(n=n+Math.imul(N,Y)|0)+Math.imul(I,W)|0,o=o+Math.imul(I,Y)|0,i=i+Math.imul(j,X)|0,n=(n=n+Math.imul(j,tt)|0)+Math.imul(x,X)|0,o=o+Math.imul(x,tt)|0,i=i+Math.imul(_,rt)|0,n=(n=n+Math.imul(_,it)|0)+Math.imul(E,rt)|0,o=o+Math.imul(E,it)|0,i=i+Math.imul(b,ot)|0,n=(n=n+Math.imul(b,at)|0)+Math.imul(k,ot)|0,o=o+Math.imul(k,at)|0,i=i+Math.imul(y,ht)|0,n=(n=n+Math.imul(y,ut)|0)+Math.imul(w,ht)|0,o=o+Math.imul(w,ut)|0,i=i+Math.imul(m,ct)|0,n=(n=n+Math.imul(m,dt)|0)+Math.imul(p,ct)|0,o=o+Math.imul(p,dt)|0;var At=(u+(i=i+Math.imul(c,mt)|0)|0)+((8191&(n=(n=n+Math.imul(c,pt)|0)+Math.imul(d,mt)|0))<<13)|0;u=((o=o+Math.imul(d,pt)|0)+(n>>>13)|0)+(At>>>26)|0,At&=67108863,i=Math.imul(D,V),n=(n=Math.imul(D,H))+Math.imul($,V)|0,o=Math.imul($,H),i=i+Math.imul(R,Z)|0,n=(n=n+Math.imul(R,K)|0)+Math.imul(P,Z)|0,o=o+Math.imul(P,K)|0,i=i+Math.imul(C,W)|0,n=(n=n+Math.imul(C,Y)|0)+Math.imul(z,W)|0,o=o+Math.imul(z,Y)|0,i=i+Math.imul(N,X)|0,n=(n=n+Math.imul(N,tt)|0)+Math.imul(I,X)|0,o=o+Math.imul(I,tt)|0,i=i+Math.imul(j,rt)|0,n=(n=n+Math.imul(j,it)|0)+Math.imul(x,rt)|0,o=o+Math.imul(x,it)|0,i=i+Math.imul(_,ot)|0,n=(n=n+Math.imul(_,at)|0)+Math.imul(E,ot)|0,o=o+Math.imul(E,at)|0,i=i+Math.imul(b,ht)|0,n=(n=n+Math.imul(b,ut)|0)+Math.imul(k,ht)|0,o=o+Math.imul(k,ut)|0,i=i+Math.imul(y,ct)|0,n=(n=n+Math.imul(y,dt)|0)+Math.imul(w,ct)|0,o=o+Math.imul(w,dt)|0;var jt=(u+(i=i+Math.imul(m,mt)|0)|0)+((8191&(n=(n=n+Math.imul(m,pt)|0)+Math.imul(p,mt)|0))<<13)|0;u=((o=o+Math.imul(p,pt)|0)+(n>>>13)|0)+(jt>>>26)|0,jt&=67108863,i=Math.imul(D,Z),n=(n=Math.imul(D,K))+Math.imul($,Z)|0,o=Math.imul($,K),i=i+Math.imul(R,W)|0,n=(n=n+Math.imul(R,Y)|0)+Math.imul(P,W)|0,o=o+Math.imul(P,Y)|0,i=i+Math.imul(C,X)|0,n=(n=n+Math.imul(C,tt)|0)+Math.imul(z,X)|0,o=o+Math.imul(z,tt)|0,i=i+Math.imul(N,rt)|0,n=(n=n+Math.imul(N,it)|0)+Math.imul(I,rt)|0,o=o+Math.imul(I,it)|0,i=i+Math.imul(j,ot)|0,n=(n=n+Math.imul(j,at)|0)+Math.imul(x,ot)|0,o=o+Math.imul(x,at)|0,i=i+Math.imul(_,ht)|0,n=(n=n+Math.imul(_,ut)|0)+Math.imul(E,ht)|0,o=o+Math.imul(E,ut)|0,i=i+Math.imul(b,ct)|0,n=(n=n+Math.imul(b,dt)|0)+Math.imul(k,ct)|0,o=o+Math.imul(k,dt)|0;var xt=(u+(i=i+Math.imul(y,mt)|0)|0)+((8191&(n=(n=n+Math.imul(y,pt)|0)+Math.imul(w,mt)|0))<<13)|0;u=((o=o+Math.imul(w,pt)|0)+(n>>>13)|0)+(xt>>>26)|0,xt&=67108863,i=Math.imul(D,W),n=(n=Math.imul(D,Y))+Math.imul($,W)|0,o=Math.imul($,Y),i=i+Math.imul(R,X)|0,n=(n=n+Math.imul(R,tt)|0)+Math.imul(P,X)|0,o=o+Math.imul(P,tt)|0,i=i+Math.imul(C,rt)|0,n=(n=n+Math.imul(C,it)|0)+Math.imul(z,rt)|0,o=o+Math.imul(z,it)|0,i=i+Math.imul(N,ot)|0,n=(n=n+Math.imul(N,at)|0)+Math.imul(I,ot)|0,o=o+Math.imul(I,at)|0,i=i+Math.imul(j,ht)|0,n=(n=n+Math.imul(j,ut)|0)+Math.imul(x,ht)|0,o=o+Math.imul(x,ut)|0,i=i+Math.imul(_,ct)|0,n=(n=n+Math.imul(_,dt)|0)+Math.imul(E,ct)|0,o=o+Math.imul(E,dt)|0;var St=(u+(i=i+Math.imul(b,mt)|0)|0)+((8191&(n=(n=n+Math.imul(b,pt)|0)+Math.imul(k,mt)|0))<<13)|0;u=((o=o+Math.imul(k,pt)|0)+(n>>>13)|0)+(St>>>26)|0,St&=67108863,i=Math.imul(D,X),n=(n=Math.imul(D,tt))+Math.imul($,X)|0,o=Math.imul($,tt),i=i+Math.imul(R,rt)|0,n=(n=n+Math.imul(R,it)|0)+Math.imul(P,rt)|0,o=o+Math.imul(P,it)|0,i=i+Math.imul(C,ot)|0,n=(n=n+Math.imul(C,at)|0)+Math.imul(z,ot)|0,o=o+Math.imul(z,at)|0,i=i+Math.imul(N,ht)|0,n=(n=n+Math.imul(N,ut)|0)+Math.imul(I,ht)|0,o=o+Math.imul(I,ut)|0,i=i+Math.imul(j,ct)|0,n=(n=n+Math.imul(j,dt)|0)+Math.imul(x,ct)|0,o=o+Math.imul(x,dt)|0;var Nt=(u+(i=i+Math.imul(_,mt)|0)|0)+((8191&(n=(n=n+Math.imul(_,pt)|0)+Math.imul(E,mt)|0))<<13)|0;u=((o=o+Math.imul(E,pt)|0)+(n>>>13)|0)+(Nt>>>26)|0,Nt&=67108863,i=Math.imul(D,rt),n=(n=Math.imul(D,it))+Math.imul($,rt)|0,o=Math.imul($,it),i=i+Math.imul(R,ot)|0,n=(n=n+Math.imul(R,at)|0)+Math.imul(P,ot)|0,o=o+Math.imul(P,at)|0,i=i+Math.imul(C,ht)|0,n=(n=n+Math.imul(C,ut)|0)+Math.imul(z,ht)|0,o=o+Math.imul(z,ut)|0,i=i+Math.imul(N,ct)|0,n=(n=n+Math.imul(N,dt)|0)+Math.imul(I,ct)|0,o=o+Math.imul(I,dt)|0;var It=(u+(i=i+Math.imul(j,mt)|0)|0)+((8191&(n=(n=n+Math.imul(j,pt)|0)+Math.imul(x,mt)|0))<<13)|0;u=((o=o+Math.imul(x,pt)|0)+(n>>>13)|0)+(It>>>26)|0,It&=67108863,i=Math.imul(D,ot),n=(n=Math.imul(D,at))+Math.imul($,ot)|0,o=Math.imul($,at),i=i+Math.imul(R,ht)|0,n=(n=n+Math.imul(R,ut)|0)+Math.imul(P,ht)|0,o=o+Math.imul(P,ut)|0,i=i+Math.imul(C,ct)|0,n=(n=n+Math.imul(C,dt)|0)+Math.imul(z,ct)|0,o=o+Math.imul(z,dt)|0;var Tt=(u+(i=i+Math.imul(N,mt)|0)|0)+((8191&(n=(n=n+Math.imul(N,pt)|0)+Math.imul(I,mt)|0))<<13)|0;u=((o=o+Math.imul(I,pt)|0)+(n>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,i=Math.imul(D,ht),n=(n=Math.imul(D,ut))+Math.imul($,ht)|0,o=Math.imul($,ut),i=i+Math.imul(R,ct)|0,n=(n=n+Math.imul(R,dt)|0)+Math.imul(P,ct)|0,o=o+Math.imul(P,dt)|0;var Ct=(u+(i=i+Math.imul(C,mt)|0)|0)+((8191&(n=(n=n+Math.imul(C,pt)|0)+Math.imul(z,mt)|0))<<13)|0;u=((o=o+Math.imul(z,pt)|0)+(n>>>13)|0)+(Ct>>>26)|0,Ct&=67108863,i=Math.imul(D,ct),n=(n=Math.imul(D,dt))+Math.imul($,ct)|0,o=Math.imul($,dt);var zt=(u+(i=i+Math.imul(R,mt)|0)|0)+((8191&(n=(n=n+Math.imul(R,pt)|0)+Math.imul(P,mt)|0))<<13)|0;u=((o=o+Math.imul(P,pt)|0)+(n>>>13)|0)+(zt>>>26)|0,zt&=67108863;var Ot=(u+(i=Math.imul(D,mt))|0)+((8191&(n=(n=Math.imul(D,pt))+Math.imul($,mt)|0))<<13)|0;return u=((o=Math.imul($,pt))+(n>>>13)|0)+(Ot>>>26)|0,Ot&=67108863,h[0]=gt,h[1]=yt,h[2]=wt,h[3]=vt,h[4]=bt,h[5]=kt,h[6]=Mt,h[7]=_t,h[8]=Et,h[9]=At,h[10]=jt,h[11]=xt,h[12]=St,h[13]=Nt,h[14]=It,h[15]=Tt,h[16]=Ct,h[17]=zt,h[18]=Ot,0!==u&&(h[19]=u,r.length++),r};function g(t,e,r){r.negative=e.negative^t.negative,r.length=t.length+e.length;for(var i=0,n=0,o=0;o<r.length-1;o++){var a=n;n=0;for(var s=67108863&i,h=Math.min(o,e.length-1),u=Math.max(0,o-t.length+1);u<=h;u++){var l=o-u,c=(0|t.words[l])*(0|e.words[u]),d=67108863&c;s=67108863&(d=d+s|0),n+=(a=(a=a+(c/67108864|0)|0)+(d>>>26)|0)>>>26,a&=67108863}r.words[o]=s,i=a,a=n}return 0!==i?r.words[o]=i:r.length--,r._strip()}function y(t,e,r){return g(t,e,r)}Math.imul||(p=m),n.prototype.mulTo=function(t,e){var r=this.length+t.length;return 10===this.length&&10===t.length?p(this,t,e):r<63?m(this,t,e):r<1024?g(this,t,e):y(this,t,e)},n.prototype.mul=function(t){var e=new n(null);return e.words=new Array(this.length+t.length),this.mulTo(t,e)},n.prototype.mulf=function(t){var e=new n(null);return e.words=new Array(this.length+t.length),y(this,t,e)},n.prototype.imul=function(t){return this.clone().mulTo(t,this)},n.prototype.imuln=function(t){var e=t<0;e&&(t=-t),r("number"==typeof t),r(t<67108864);for(var i=0,n=0;n<this.length;n++){var o=(0|this.words[n])*t,a=(67108863&o)+(67108863&i);i>>=26,i+=o/67108864|0,i+=a>>>26,this.words[n]=67108863&a}return 0!==i&&(this.words[n]=i,this.length++),e?this.ineg():this},n.prototype.muln=function(t){return this.clone().imuln(t)},n.prototype.sqr=function(){return this.mul(this)},n.prototype.isqr=function(){return this.imul(this.clone())},n.prototype.pow=function(t){var e=function(t){for(var e=new Array(t.bitLength()),r=0;r<e.length;r++){var i=r/26|0,n=r%26;e[r]=t.words[i]>>>n&1}return e}(t);if(0===e.length)return new n(1);for(var r=this,i=0;i<e.length&&0===e[i];i++,r=r.sqr());if(++i<e.length)for(var o=r.sqr();i<e.length;i++,o=o.sqr())0!==e[i]&&(r=r.mul(o));return r},n.prototype.iushln=function(t){r("number"==typeof t&&t>=0);var e,i=t%26,n=(t-i)/26,o=67108863>>>26-i<<26-i;if(0!==i){var a=0;for(e=0;e<this.length;e++){var s=this.words[e]&o,h=(0|this.words[e])-s<<i;this.words[e]=h|a,a=s>>>26-i}a&&(this.words[e]=a,this.length++)}if(0!==n){for(e=this.length-1;e>=0;e--)this.words[e+n]=this.words[e];for(e=0;e<n;e++)this.words[e]=0;this.length+=n}return this._strip()},n.prototype.ishln=function(t){return r(0===this.negative),this.iushln(t)},n.prototype.iushrn=function(t,e,i){var n;r("number"==typeof t&&t>=0),n=e?(e-e%26)/26:0;var o=t%26,a=Math.min((t-o)/26,this.length),s=67108863^67108863>>>o<<o,h=i;if(n-=a,n=Math.max(0,n),h){for(var u=0;u<a;u++)h.words[u]=this.words[u];h.length=a}if(0===a);else if(this.length>a)for(this.length-=a,u=0;u<this.length;u++)this.words[u]=this.words[u+a];else this.words[0]=0,this.length=1;var l=0;for(u=this.length-1;u>=0&&(0!==l||u>=n);u--){var c=0|this.words[u];this.words[u]=l<<26-o|c>>>o,l=c&s}return h&&0!==l&&(h.words[h.length++]=l),0===this.length&&(this.words[0]=0,this.length=1),this._strip()},n.prototype.ishrn=function(t,e,i){return r(0===this.negative),this.iushrn(t,e,i)},n.prototype.shln=function(t){return this.clone().ishln(t)},n.prototype.ushln=function(t){return this.clone().iushln(t)},n.prototype.shrn=function(t){return this.clone().ishrn(t)},n.prototype.ushrn=function(t){return this.clone().iushrn(t)},n.prototype.testn=function(t){r("number"==typeof t&&t>=0);var e=t%26,i=(t-e)/26,n=1<<e;return!(this.length<=i)&&!!(this.words[i]&n)},n.prototype.imaskn=function(t){r("number"==typeof t&&t>=0);var e=t%26,i=(t-e)/26;if(r(0===this.negative,"imaskn works only with positive numbers"),this.length<=i)return this;if(0!==e&&i++,this.length=Math.min(i,this.length),0!==e){var n=67108863^67108863>>>e<<e;this.words[this.length-1]&=n}return this._strip()},n.prototype.maskn=function(t){return this.clone().imaskn(t)},n.prototype.iaddn=function(t){return r("number"==typeof t),r(t<67108864),t<0?this.isubn(-t):0!==this.negative?1===this.length&&(0|this.words[0])<=t?(this.words[0]=t-(0|this.words[0]),this.negative=0,this):(this.negative=0,this.isubn(t),this.negative=1,this):this._iaddn(t)},n.prototype._iaddn=function(t){this.words[0]+=t;for(var e=0;e<this.length&&this.words[e]>=67108864;e++)this.words[e]-=67108864,e===this.length-1?this.words[e+1]=1:this.words[e+1]++;return this.length=Math.max(this.length,e+1),this},n.prototype.isubn=function(t){if(r("number"==typeof t),r(t<67108864),t<0)return this.iaddn(-t);if(0!==this.negative)return this.negative=0,this.iaddn(t),this.negative=1,this;if(this.words[0]-=t,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var e=0;e<this.length&&this.words[e]<0;e++)this.words[e]+=67108864,this.words[e+1]-=1;return this._strip()},n.prototype.addn=function(t){return this.clone().iaddn(t)},n.prototype.subn=function(t){return this.clone().isubn(t)},n.prototype.iabs=function(){return this.negative=0,this},n.prototype.abs=function(){return this.clone().iabs()},n.prototype._ishlnsubmul=function(t,e,i){var n,o,a=t.length+i;this._expand(a);var s=0;for(n=0;n<t.length;n++){o=(0|this.words[n+i])+s;var h=(0|t.words[n])*e;s=((o-=67108863&h)>>26)-(h/67108864|0),this.words[n+i]=67108863&o}for(;n<this.length-i;n++)s=(o=(0|this.words[n+i])+s)>>26,this.words[n+i]=67108863&o;if(0===s)return this._strip();for(r(-1===s),s=0,n=0;n<this.length;n++)s=(o=-(0|this.words[n])+s)>>26,this.words[n]=67108863&o;return this.negative=1,this._strip()},n.prototype._wordDiv=function(t,e){var r=(this.length,t.length),i=this.clone(),o=t,a=0|o.words[o.length-1];0!==(r=26-this._countBits(a))&&(o=o.ushln(r),i.iushln(r),a=0|o.words[o.length-1]);var s,h=i.length-o.length;if("mod"!==e){(s=new n(null)).length=h+1,s.words=new Array(s.length);for(var u=0;u<s.length;u++)s.words[u]=0}var l=i.clone()._ishlnsubmul(o,1,h);0===l.negative&&(i=l,s&&(s.words[h]=1));for(var c=h-1;c>=0;c--){var d=67108864*(0|i.words[o.length+c])+(0|i.words[o.length+c-1]);for(d=Math.min(d/a|0,67108863),i._ishlnsubmul(o,d,c);0!==i.negative;)d--,i.negative=0,i._ishlnsubmul(o,1,c),i.isZero()||(i.negative^=1);s&&(s.words[c]=d)}return s&&s._strip(),i._strip(),"div"!==e&&0!==r&&i.iushrn(r),{div:s||null,mod:i}},n.prototype.divmod=function(t,e,i){return r(!t.isZero()),this.isZero()?{div:new n(0),mod:new n(0)}:0!==this.negative&&0===t.negative?(s=this.neg().divmod(t,e),"mod"!==e&&(o=s.div.neg()),"div"!==e&&(a=s.mod.neg(),i&&0!==a.negative&&a.iadd(t)),{div:o,mod:a}):0===this.negative&&0!==t.negative?(s=this.divmod(t.neg(),e),"mod"!==e&&(o=s.div.neg()),{div:o,mod:s.mod}):0!=(this.negative&t.negative)?(s=this.neg().divmod(t.neg(),e),"div"!==e&&(a=s.mod.neg(),i&&0!==a.negative&&a.isub(t)),{div:s.div,mod:a}):t.length>this.length||this.cmp(t)<0?{div:new n(0),mod:this}:1===t.length?"div"===e?{div:this.divn(t.words[0]),mod:null}:"mod"===e?{div:null,mod:new n(this.modrn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new n(this.modrn(t.words[0]))}:this._wordDiv(t,e);var o,a,s},n.prototype.div=function(t){return this.divmod(t,"div",!1).div},n.prototype.mod=function(t){return this.divmod(t,"mod",!1).mod},n.prototype.umod=function(t){return this.divmod(t,"mod",!0).mod},n.prototype.divRound=function(t){var e=this.divmod(t);if(e.mod.isZero())return e.div;var r=0!==e.div.negative?e.mod.isub(t):e.mod,i=t.ushrn(1),n=t.andln(1),o=r.cmp(i);return o<0||1===n&&0===o?e.div:0!==e.div.negative?e.div.isubn(1):e.div.iaddn(1)},n.prototype.modrn=function(t){var e=t<0;e&&(t=-t),r(t<=67108863);for(var i=(1<<26)%t,n=0,o=this.length-1;o>=0;o--)n=(i*n+(0|this.words[o]))%t;return e?-n:n},n.prototype.modn=function(t){return this.modrn(t)},n.prototype.idivn=function(t){var e=t<0;e&&(t=-t),r(t<=67108863);for(var i=0,n=this.length-1;n>=0;n--){var o=(0|this.words[n])+67108864*i;this.words[n]=o/t|0,i=o%t}return this._strip(),e?this.ineg():this},n.prototype.divn=function(t){return this.clone().idivn(t)},n.prototype.egcd=function(t){r(0===t.negative),r(!t.isZero());var e=this,i=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var o=new n(1),a=new n(0),s=new n(0),h=new n(1),u=0;e.isEven()&&i.isEven();)e.iushrn(1),i.iushrn(1),++u;for(var l=i.clone(),c=e.clone();!e.isZero();){for(var d=0,f=1;0==(e.words[0]&f)&&d<26;++d,f<<=1);if(d>0)for(e.iushrn(d);d-- >0;)(o.isOdd()||a.isOdd())&&(o.iadd(l),a.isub(c)),o.iushrn(1),a.iushrn(1);for(var m=0,p=1;0==(i.words[0]&p)&&m<26;++m,p<<=1);if(m>0)for(i.iushrn(m);m-- >0;)(s.isOdd()||h.isOdd())&&(s.iadd(l),h.isub(c)),s.iushrn(1),h.iushrn(1);e.cmp(i)>=0?(e.isub(i),o.isub(s),a.isub(h)):(i.isub(e),s.isub(o),h.isub(a))}return{a:s,b:h,gcd:i.iushln(u)}},n.prototype._invmp=function(t){r(0===t.negative),r(!t.isZero());var e=this,i=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var o,a=new n(1),s=new n(0),h=i.clone();e.cmpn(1)>0&&i.cmpn(1)>0;){for(var u=0,l=1;0==(e.words[0]&l)&&u<26;++u,l<<=1);if(u>0)for(e.iushrn(u);u-- >0;)a.isOdd()&&a.iadd(h),a.iushrn(1);for(var c=0,d=1;0==(i.words[0]&d)&&c<26;++c,d<<=1);if(c>0)for(i.iushrn(c);c-- >0;)s.isOdd()&&s.iadd(h),s.iushrn(1);e.cmp(i)>=0?(e.isub(i),a.isub(s)):(i.isub(e),s.isub(a))}return(o=0===e.cmpn(1)?a:s).cmpn(0)<0&&o.iadd(t),o},n.prototype.gcd=function(t){if(this.isZero())return t.abs();if(t.isZero())return this.abs();var e=this.clone(),r=t.clone();e.negative=0,r.negative=0;for(var i=0;e.isEven()&&r.isEven();i++)e.iushrn(1),r.iushrn(1);for(;;){for(;e.isEven();)e.iushrn(1);for(;r.isEven();)r.iushrn(1);var n=e.cmp(r);if(n<0){var o=e;e=r,r=o}else if(0===n||0===r.cmpn(1))break;e.isub(r)}return r.iushln(i)},n.prototype.invm=function(t){return this.egcd(t).a.umod(t)},n.prototype.isEven=function(){return 0==(1&this.words[0])},n.prototype.isOdd=function(){return 1==(1&this.words[0])},n.prototype.andln=function(t){return this.words[0]&t},n.prototype.bincn=function(t){r("number"==typeof t);var e=t%26,i=(t-e)/26,n=1<<e;if(this.length<=i)return this._expand(i+1),this.words[i]|=n,this;for(var o=n,a=i;0!==o&&a<this.length;a++){var s=0|this.words[a];o=(s+=o)>>>26,s&=67108863,this.words[a]=s}return 0!==o&&(this.words[a]=o,this.length++),this},n.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},n.prototype.cmpn=function(t){var e,i=t<0;if(0!==this.negative&&!i)return-1;if(0===this.negative&&i)return 1;if(this._strip(),this.length>1)e=1;else{i&&(t=-t),r(t<=67108863,"Number is too big");var n=0|this.words[0];e=n===t?0:n<t?-1:1}return 0!==this.negative?0|-e:e},n.prototype.cmp=function(t){if(0!==this.negative&&0===t.negative)return-1;if(0===this.negative&&0!==t.negative)return 1;var e=this.ucmp(t);return 0!==this.negative?0|-e:e},n.prototype.ucmp=function(t){if(this.length>t.length)return 1;if(this.length<t.length)return-1;for(var e=0,r=this.length-1;r>=0;r--){var i=0|this.words[r],n=0|t.words[r];if(i!==n){i<n?e=-1:i>n&&(e=1);break}}return e},n.prototype.gtn=function(t){return 1===this.cmpn(t)},n.prototype.gt=function(t){return 1===this.cmp(t)},n.prototype.gten=function(t){return this.cmpn(t)>=0},n.prototype.gte=function(t){return this.cmp(t)>=0},n.prototype.ltn=function(t){return-1===this.cmpn(t)},n.prototype.lt=function(t){return-1===this.cmp(t)},n.prototype.lten=function(t){return this.cmpn(t)<=0},n.prototype.lte=function(t){return this.cmp(t)<=0},n.prototype.eqn=function(t){return 0===this.cmpn(t)},n.prototype.eq=function(t){return 0===this.cmp(t)},n.red=function(t){return new E(t)},n.prototype.toRed=function(t){return r(!this.red,"Already a number in reduction context"),r(0===this.negative,"red works only with positives"),t.convertTo(this)._forceRed(t)},n.prototype.fromRed=function(){return r(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},n.prototype._forceRed=function(t){return this.red=t,this},n.prototype.forceRed=function(t){return r(!this.red,"Already a number in reduction context"),this._forceRed(t)},n.prototype.redAdd=function(t){return r(this.red,"redAdd works only with red numbers"),this.red.add(this,t)},n.prototype.redIAdd=function(t){return r(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,t)},n.prototype.redSub=function(t){return r(this.red,"redSub works only with red numbers"),this.red.sub(this,t)},n.prototype.redISub=function(t){return r(this.red,"redISub works only with red numbers"),this.red.isub(this,t)},n.prototype.redShl=function(t){return r(this.red,"redShl works only with red numbers"),this.red.shl(this,t)},n.prototype.redMul=function(t){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.mul(this,t)},n.prototype.redIMul=function(t){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.imul(this,t)},n.prototype.redSqr=function(){return r(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},n.prototype.redISqr=function(){return r(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},n.prototype.redSqrt=function(){return r(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},n.prototype.redInvm=function(){return r(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},n.prototype.redNeg=function(){return r(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},n.prototype.redPow=function(t){return r(this.red&&!t.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,t)};var w={k256:null,p224:null,p192:null,p25519:null};function v(t,e){this.name=t,this.p=new n(e,16),this.n=this.p.bitLength(),this.k=new n(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function b(){v.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function k(){v.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function M(){v.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function _(){v.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function E(t){if("string"==typeof t){var e=n._prime(t);this.m=e.p,this.prime=e}else r(t.gtn(1),"modulus must be greater than 1"),this.m=t,this.prime=null}function A(t){E.call(this,t),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new n(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)}v.prototype._tmp=function(){var t=new n(null);return t.words=new Array(Math.ceil(this.n/13)),t},v.prototype.ireduce=function(t){var e,r=t;do{this.split(r,this.tmp),e=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(e>this.n);var i=e<this.n?-1:r.ucmp(this.p);return 0===i?(r.words[0]=0,r.length=1):i>0?r.isub(this.p):void 0!==r.strip?r.strip():r._strip(),r},v.prototype.split=function(t,e){t.iushrn(this.n,0,e)},v.prototype.imulK=function(t){return t.imul(this.k)},i(b,v),b.prototype.split=function(t,e){for(var r=4194303,i=Math.min(t.length,9),n=0;n<i;n++)e.words[n]=t.words[n];if(e.length=i,t.length<=9)return t.words[0]=0,void(t.length=1);var o=t.words[9];for(e.words[e.length++]=o&r,n=10;n<t.length;n++){var a=0|t.words[n];t.words[n-10]=(a&r)<<4|o>>>22,o=a}o>>>=22,t.words[n-10]=o,0===o&&t.length>10?t.length-=10:t.length-=9},b.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var e=0,r=0;r<t.length;r++){var i=0|t.words[r];e+=977*i,t.words[r]=67108863&e,e=64*i+(e/67108864|0)}return 0===t.words[t.length-1]&&(t.length--,0===t.words[t.length-1]&&t.length--),t},i(k,v),i(M,v),i(_,v),_.prototype.imulK=function(t){for(var e=0,r=0;r<t.length;r++){var i=19*(0|t.words[r])+e,n=67108863&i;i>>>=26,t.words[r]=n,e=i}return 0!==e&&(t.words[t.length++]=e),t},n._prime=function(t){if(w[t])return w[t];var e;if("k256"===t)e=new b;else if("p224"===t)e=new k;else if("p192"===t)e=new M;else{if("p25519"!==t)throw new Error("Unknown prime "+t);e=new _}return w[t]=e,e},E.prototype._verify1=function(t){r(0===t.negative,"red works only with positives"),r(t.red,"red works only with red numbers")},E.prototype._verify2=function(t,e){r(0==(t.negative|e.negative),"red works only with positives"),r(t.red&&t.red===e.red,"red works only with red numbers")},E.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):(u(t,t.umod(this.m)._forceRed(this)),t)},E.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},E.prototype.add=function(t,e){this._verify2(t,e);var r=t.add(e);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},E.prototype.iadd=function(t,e){this._verify2(t,e);var r=t.iadd(e);return r.cmp(this.m)>=0&&r.isub(this.m),r},E.prototype.sub=function(t,e){this._verify2(t,e);var r=t.sub(e);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},E.prototype.isub=function(t,e){this._verify2(t,e);var r=t.isub(e);return r.cmpn(0)<0&&r.iadd(this.m),r},E.prototype.shl=function(t,e){return this._verify1(t),this.imod(t.ushln(e))},E.prototype.imul=function(t,e){return this._verify2(t,e),this.imod(t.imul(e))},E.prototype.mul=function(t,e){return this._verify2(t,e),this.imod(t.mul(e))},E.prototype.isqr=function(t){return this.imul(t,t.clone())},E.prototype.sqr=function(t){return this.mul(t,t)},E.prototype.sqrt=function(t){if(t.isZero())return t.clone();var e=this.m.andln(3);if(r(e%2==1),3===e){var i=this.m.add(new n(1)).iushrn(2);return this.pow(t,i)}for(var o=this.m.subn(1),a=0;!o.isZero()&&0===o.andln(1);)a++,o.iushrn(1);r(!o.isZero());var s=new n(1).toRed(this),h=s.redNeg(),u=this.m.subn(1).iushrn(1),l=this.m.bitLength();for(l=new n(2*l*l).toRed(this);0!==this.pow(l,u).cmp(h);)l.redIAdd(h);for(var c=this.pow(l,o),d=this.pow(t,o.addn(1).iushrn(1)),f=this.pow(t,o),m=a;0!==f.cmp(s);){for(var p=f,g=0;0!==p.cmp(s);g++)p=p.redSqr();r(g<m);var y=this.pow(c,new n(1).iushln(m-g-1));d=d.redMul(y),c=y.redSqr(),f=f.redMul(c),m=g}return d},E.prototype.invm=function(t){var e=t._invmp(this.m);return 0!==e.negative?(e.negative=0,this.imod(e).redNeg()):this.imod(e)},E.prototype.pow=function(t,e){if(e.isZero())return new n(1).toRed(this);if(0===e.cmpn(1))return t.clone();var r=new Array(16);r[0]=new n(1).toRed(this),r[1]=t;for(var i=2;i<r.length;i++)r[i]=this.mul(r[i-1],t);var o=r[0],a=0,s=0,h=e.bitLength()%26;for(0===h&&(h=26),i=e.length-1;i>=0;i--){for(var u=e.words[i],l=h-1;l>=0;l--){var c=u>>l&1;o!==r[0]&&(o=this.sqr(o)),0!==c||0!==a?(a<<=1,a|=c,(4===++s||0===i&&0===l)&&(o=this.mul(o,r[a]),s=0,a=0)):s=0}h=26}return o},E.prototype.convertTo=function(t){var e=t.umod(this.m);return e===t?e.clone():e},E.prototype.convertFrom=function(t){var e=t.clone();return e.red=null,e},n.mont=function(t){return new A(t)},i(A,E),A.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},A.prototype.convertFrom=function(t){var e=this.imod(t.mul(this.rinv));return e.red=null,e},A.prototype.imul=function(t,e){if(t.isZero()||e.isZero())return t.words[0]=0,t.length=1,t;var r=t.imul(e),i=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),n=r.isub(i).iushrn(this.shift),o=n;return n.cmp(this.m)>=0?o=n.isub(this.m):n.cmpn(0)<0&&(o=n.iadd(this.m)),o._forceRed(this)},A.prototype.mul=function(t,e){if(t.isZero()||e.isZero())return new n(0)._forceRed(this);var r=t.mul(e),i=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),o=r.isub(i).iushrn(this.shift),a=o;return o.cmp(this.m)>=0?a=o.isub(this.m):o.cmpn(0)<0&&(a=o.iadd(this.m)),a._forceRed(this)},A.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}(t,i)}));var In=Nn.BN;const Tn=new w("bignumber/5.6.2"),Cn={},zn=9007199254740991;let On=!1;class Rn{constructor(t,e){t!==Cn&&Tn.throwError("cannot call constructor directly; use BigNumber.from",w.errors.UNSUPPORTED_OPERATION,{operation:"new (BigNumber)"}),this._hex=e,this._isBigNumber=!0,Object.freeze(this)}fromTwos(t){return Bn(Dn(this).fromTwos(t))}toTwos(t){return Bn(Dn(this).toTwos(t))}abs(){return"-"===this._hex[0]?Rn.from(this._hex.substring(1)):this}add(t){return Bn(Dn(this).add(Dn(t)))}sub(t){return Bn(Dn(this).sub(Dn(t)))}div(t){return Rn.from(t).isZero()&&$n("division-by-zero","div"),Bn(Dn(this).div(Dn(t)))}mul(t){return Bn(Dn(this).mul(Dn(t)))}mod(t){const e=Dn(t);return e.isNeg()&&$n("division-by-zero","mod"),Bn(Dn(this).umod(e))}pow(t){const e=Dn(t);return e.isNeg()&&$n("negative-power","pow"),Bn(Dn(this).pow(e))}and(t){const e=Dn(t);return(this.isNegative()||e.isNeg())&&$n("unbound-bitwise-result","and"),Bn(Dn(this).and(e))}or(t){const e=Dn(t);return(this.isNegative()||e.isNeg())&&$n("unbound-bitwise-result","or"),Bn(Dn(this).or(e))}xor(t){const e=Dn(t);return(this.isNegative()||e.isNeg())&&$n("unbound-bitwise-result","xor"),Bn(Dn(this).xor(e))}mask(t){return(this.isNegative()||t<0)&&$n("negative-width","mask"),Bn(Dn(this).maskn(t))}shl(t){return(this.isNegative()||t<0)&&$n("negative-width","shl"),Bn(Dn(this).shln(t))}shr(t){return(this.isNegative()||t<0)&&$n("negative-width","shr"),Bn(Dn(this).shrn(t))}eq(t){return Dn(this).eq(Dn(t))}lt(t){return Dn(this).lt(Dn(t))}lte(t){return Dn(this).lte(Dn(t))}gt(t){return Dn(this).gt(Dn(t))}gte(t){return Dn(this).gte(Dn(t))}isNegative(){return"-"===this._hex[0]}isZero(){return Dn(this).isZero()}toNumber(){try{return Dn(this).toNumber()}catch(t){$n("overflow","toNumber",this.toString())}return null}toBigInt(){try{return BigInt(this.toString())}catch(t){}return Tn.throwError("this platform does not support BigInt",w.errors.UNSUPPORTED_OPERATION,{value:this.toString()})}toString(){return arguments.length>0&&(10===arguments[0]?On||(On=!0,Tn.warn("BigNumber.toString does not accept any parameters; base-10 is assumed")):16===arguments[0]?Tn.throwError("BigNumber.toString does not accept any parameters; use bigNumber.toHexString()",w.errors.UNEXPECTED_ARGUMENT,{}):Tn.throwError("BigNumber.toString does not accept parameters",w.errors.UNEXPECTED_ARGUMENT,{})),Dn(this).toString(10)}toHexString(){return this._hex}toJSON(t){return{type:"BigNumber",hex:this.toHexString()}}static from(t){if(t instanceof Rn)return t;if("string"==typeof t)return t.match(/^-?0x[0-9a-f]+$/i)?new Rn(Cn,Pn(t)):t.match(/^-?[0-9]+$/)?new Rn(Cn,Pn(new In(t))):Tn.throwArgumentError("invalid BigNumber string","value",t);if("number"==typeof t)return t%1&&$n("underflow","BigNumber.from",t),(t>=zn||t<=-zn)&&$n("overflow","BigNumber.from",t),Rn.from(String(t));const e=t;if("bigint"==typeof e)return Rn.from(e.toString());if(E(e))return Rn.from(I(e));if(e)if(e.toHexString){const t=e.toHexString();if("string"==typeof t)return Rn.from(t)}else{let t=e._hex;if(null==t&&"BigNumber"===e.type&&(t=e.hex),"string"==typeof t&&(S(t)||"-"===t[0]&&S(t.substring(1))))return Rn.from(t)}return Tn.throwArgumentError("invalid BigNumber value","value",t)}static isBigNumber(t){return!(!t||!t._isBigNumber)}}function Pn(t){if("string"!=typeof t)return Pn(t.toString(16));if("-"===t[0])return"-"===(t=t.substring(1))[0]&&Tn.throwArgumentError("invalid hex","value",t),"0x00"===(t=Pn(t))?t:"-"+t;if("0x"!==t.substring(0,2)&&(t="0x"+t),"0x"===t)return"0x00";for(t.length%2&&(t="0x0"+t.substring(2));t.length>4&&"0x00"===t.substring(0,4);)t="0x"+t.substring(4);return t}function Bn(t){return Rn.from(Pn(t))}function Dn(t){const e=Rn.from(t).toHexString();return"-"===e[0]?new In("-"+e.substring(3),16):new In(e.substring(2),16)}function $n(t,e,r){const i={fault:t,operation:e};return null!=r&&(i.value=r),Tn.throwError(t,w.errors.NUMERIC_FAULT,i)}var Ln=a((function(t){!function(t,e){function r(t,e){if(!t)throw new Error(e||"Assertion failed")}function i(t,e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}function n(t,e,r){if(n.isBN(t))return t;this.negative=0,this.words=null,this.length=0,this.red=null,null!==t&&("le"!==e&&"be"!==e||(r=e,e=10),this._init(t||0,e||10,r||"be"))}var o;"object"==typeof t?t.exports=n:e.BN=n,n.BN=n,n.wordSize=26;try{o="undefined"!=typeof window&&void 0!==window.Buffer?window.Buffer:Pt.Buffer}catch(t){}function a(t,e){var i=t.charCodeAt(e);return i>=48&&i<=57?i-48:i>=65&&i<=70?i-55:i>=97&&i<=102?i-87:void r(!1,"Invalid character in "+t)}function s(t,e,r){var i=a(t,r);return r-1>=e&&(i|=a(t,r-1)<<4),i}function h(t,e,i,n){for(var o=0,a=0,s=Math.min(t.length,i),h=e;h<s;h++){var u=t.charCodeAt(h)-48;o*=n,a=u>=49?u-49+10:u>=17?u-17+10:u,r(u>=0&&a<n,"Invalid character"),o+=a}return o}function u(t,e){t.words=e.words,t.length=e.length,t.negative=e.negative,t.red=e.red}if(n.isBN=function(t){return t instanceof n||null!==t&&"object"==typeof t&&t.constructor.wordSize===n.wordSize&&Array.isArray(t.words)},n.max=function(t,e){return t.cmp(e)>0?t:e},n.min=function(t,e){return t.cmp(e)<0?t:e},n.prototype._init=function(t,e,i){if("number"==typeof t)return this._initNumber(t,e,i);if("object"==typeof t)return this._initArray(t,e,i);"hex"===e&&(e=16),r(e===(0|e)&&e>=2&&e<=36);var n=0;"-"===(t=t.toString().replace(/\s+/g,""))[0]&&(n++,this.negative=1),n<t.length&&(16===e?this._parseHex(t,n,i):(this._parseBase(t,e,n),"le"===i&&this._initArray(this.toArray(),e,i)))},n.prototype._initNumber=function(t,e,i){t<0&&(this.negative=1,t=-t),t<67108864?(this.words=[67108863&t],this.length=1):t<4503599627370496?(this.words=[67108863&t,t/67108864&67108863],this.length=2):(r(t<9007199254740992),this.words=[67108863&t,t/67108864&67108863,1],this.length=3),"le"===i&&this._initArray(this.toArray(),e,i)},n.prototype._initArray=function(t,e,i){if(r("number"==typeof t.length),t.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(t.length/3),this.words=new Array(this.length);for(var n=0;n<this.length;n++)this.words[n]=0;var o,a,s=0;if("be"===i)for(n=t.length-1,o=0;n>=0;n-=3)a=t[n]|t[n-1]<<8|t[n-2]<<16,this.words[o]|=a<<s&67108863,this.words[o+1]=a>>>26-s&67108863,(s+=24)>=26&&(s-=26,o++);else if("le"===i)for(n=0,o=0;n<t.length;n+=3)a=t[n]|t[n+1]<<8|t[n+2]<<16,this.words[o]|=a<<s&67108863,this.words[o+1]=a>>>26-s&67108863,(s+=24)>=26&&(s-=26,o++);return this._strip()},n.prototype._parseHex=function(t,e,r){this.length=Math.ceil((t.length-e)/6),this.words=new Array(this.length);for(var i=0;i<this.length;i++)this.words[i]=0;var n,o=0,a=0;if("be"===r)for(i=t.length-1;i>=e;i-=2)n=s(t,e,i)<<o,this.words[a]|=67108863&n,o>=18?(o-=18,a+=1,this.words[a]|=n>>>26):o+=8;else for(i=(t.length-e)%2==0?e+1:e;i<t.length;i+=2)n=s(t,e,i)<<o,this.words[a]|=67108863&n,o>=18?(o-=18,a+=1,this.words[a]|=n>>>26):o+=8;this._strip()},n.prototype._parseBase=function(t,e,r){this.words=[0],this.length=1;for(var i=0,n=1;n<=67108863;n*=e)i++;i--,n=n/e|0;for(var o=t.length-r,a=o%i,s=Math.min(o,o-a)+r,u=0,l=r;l<s;l+=i)u=h(t,l,l+i,e),this.imuln(n),this.words[0]+u<67108864?this.words[0]+=u:this._iaddn(u);if(0!==a){var c=1;for(u=h(t,l,t.length,e),l=0;l<a;l++)c*=e;this.imuln(c),this.words[0]+u<67108864?this.words[0]+=u:this._iaddn(u)}this._strip()},n.prototype.copy=function(t){t.words=new Array(this.length);for(var e=0;e<this.length;e++)t.words[e]=this.words[e];t.length=this.length,t.negative=this.negative,t.red=this.red},n.prototype._move=function(t){u(t,this)},n.prototype.clone=function(){var t=new n(null);return this.copy(t),t},n.prototype._expand=function(t){for(;this.length<t;)this.words[this.length++]=0;return this},n.prototype._strip=function(){for(;this.length>1&&0===this.words[this.length-1];)this.length--;return this._normSign()},n.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},"undefined"!=typeof Symbol&&"function"==typeof Symbol.for)try{n.prototype[Symbol.for("nodejs.util.inspect.custom")]=l}catch(t){n.prototype.inspect=l}else n.prototype.inspect=l;function l(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"}var c=["","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"],d=[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],f=[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];n.prototype.toString=function(t,e){var i;if(e=0|e||1,16===(t=t||10)||"hex"===t){i="";for(var n=0,o=0,a=0;a<this.length;a++){var s=this.words[a],h=(16777215&(s<<n|o)).toString(16);o=s>>>24-n&16777215,(n+=2)>=26&&(n-=26,a--),i=0!==o||a!==this.length-1?c[6-h.length]+h+i:h+i}for(0!==o&&(i=o.toString(16)+i);i.length%e!=0;)i="0"+i;return 0!==this.negative&&(i="-"+i),i}if(t===(0|t)&&t>=2&&t<=36){var u=d[t],l=f[t];i="";var m=this.clone();for(m.negative=0;!m.isZero();){var p=m.modrn(l).toString(t);i=(m=m.idivn(l)).isZero()?p+i:c[u-p.length]+p+i}for(this.isZero()&&(i="0"+i);i.length%e!=0;)i="0"+i;return 0!==this.negative&&(i="-"+i),i}r(!1,"Base should be between 2 and 36")},n.prototype.toNumber=function(){var t=this.words[0];return 2===this.length?t+=67108864*this.words[1]:3===this.length&&1===this.words[2]?t+=4503599627370496+67108864*this.words[1]:this.length>2&&r(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-t:t},n.prototype.toJSON=function(){return this.toString(16,2)},o&&(n.prototype.toBuffer=function(t,e){return this.toArrayLike(o,t,e)}),n.prototype.toArray=function(t,e){return this.toArrayLike(Array,t,e)};function m(t,e,r){r.negative=e.negative^t.negative;var i=t.length+e.length|0;r.length=i,i=i-1|0;var n=0|t.words[0],o=0|e.words[0],a=n*o,s=67108863&a,h=a/67108864|0;r.words[0]=s;for(var u=1;u<i;u++){for(var l=h>>>26,c=67108863&h,d=Math.min(u,e.length-1),f=Math.max(0,u-t.length+1);f<=d;f++){var m=u-f|0;l+=(a=(n=0|t.words[m])*(o=0|e.words[f])+c)/67108864|0,c=67108863&a}r.words[u]=0|c,h=0|l}return 0!==h?r.words[u]=0|h:r.length--,r._strip()}n.prototype.toArrayLike=function(t,e,i){this._strip();var n=this.byteLength(),o=i||Math.max(1,n);r(n<=o,"byte array longer than desired length"),r(o>0,"Requested array length <= 0");var a=function(t,e){return t.allocUnsafe?t.allocUnsafe(e):new t(e)}(t,o);return this["_toArrayLike"+("le"===e?"LE":"BE")](a,n),a},n.prototype._toArrayLikeLE=function(t,e){for(var r=0,i=0,n=0,o=0;n<this.length;n++){var a=this.words[n]<<o|i;t[r++]=255&a,r<t.length&&(t[r++]=a>>8&255),r<t.length&&(t[r++]=a>>16&255),6===o?(r<t.length&&(t[r++]=a>>24&255),i=0,o=0):(i=a>>>24,o+=2)}if(r<t.length)for(t[r++]=i;r<t.length;)t[r++]=0},n.prototype._toArrayLikeBE=function(t,e){for(var r=t.length-1,i=0,n=0,o=0;n<this.length;n++){var a=this.words[n]<<o|i;t[r--]=255&a,r>=0&&(t[r--]=a>>8&255),r>=0&&(t[r--]=a>>16&255),6===o?(r>=0&&(t[r--]=a>>24&255),i=0,o=0):(i=a>>>24,o+=2)}if(r>=0)for(t[r--]=i;r>=0;)t[r--]=0},Math.clz32?n.prototype._countBits=function(t){return 32-Math.clz32(t)}:n.prototype._countBits=function(t){var e=t,r=0;return e>=4096&&(r+=13,e>>>=13),e>=64&&(r+=7,e>>>=7),e>=8&&(r+=4,e>>>=4),e>=2&&(r+=2,e>>>=2),r+e},n.prototype._zeroBits=function(t){if(0===t)return 26;var e=t,r=0;return 0==(8191&e)&&(r+=13,e>>>=13),0==(127&e)&&(r+=7,e>>>=7),0==(15&e)&&(r+=4,e>>>=4),0==(3&e)&&(r+=2,e>>>=2),0==(1&e)&&r++,r},n.prototype.bitLength=function(){var t=this.words[this.length-1],e=this._countBits(t);return 26*(this.length-1)+e},n.prototype.zeroBits=function(){if(this.isZero())return 0;for(var t=0,e=0;e<this.length;e++){var r=this._zeroBits(this.words[e]);if(t+=r,26!==r)break}return t},n.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},n.prototype.toTwos=function(t){return 0!==this.negative?this.abs().inotn(t).iaddn(1):this.clone()},n.prototype.fromTwos=function(t){return this.testn(t-1)?this.notn(t).iaddn(1).ineg():this.clone()},n.prototype.isNeg=function(){return 0!==this.negative},n.prototype.neg=function(){return this.clone().ineg()},n.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},n.prototype.iuor=function(t){for(;this.length<t.length;)this.words[this.length++]=0;for(var e=0;e<t.length;e++)this.words[e]=this.words[e]|t.words[e];return this._strip()},n.prototype.ior=function(t){return r(0==(this.negative|t.negative)),this.iuor(t)},n.prototype.or=function(t){return this.length>t.length?this.clone().ior(t):t.clone().ior(this)},n.prototype.uor=function(t){return this.length>t.length?this.clone().iuor(t):t.clone().iuor(this)},n.prototype.iuand=function(t){var e;e=this.length>t.length?t:this;for(var r=0;r<e.length;r++)this.words[r]=this.words[r]&t.words[r];return this.length=e.length,this._strip()},n.prototype.iand=function(t){return r(0==(this.negative|t.negative)),this.iuand(t)},n.prototype.and=function(t){return this.length>t.length?this.clone().iand(t):t.clone().iand(this)},n.prototype.uand=function(t){return this.length>t.length?this.clone().iuand(t):t.clone().iuand(this)},n.prototype.iuxor=function(t){var e,r;this.length>t.length?(e=this,r=t):(e=t,r=this);for(var i=0;i<r.length;i++)this.words[i]=e.words[i]^r.words[i];if(this!==e)for(;i<e.length;i++)this.words[i]=e.words[i];return this.length=e.length,this._strip()},n.prototype.ixor=function(t){return r(0==(this.negative|t.negative)),this.iuxor(t)},n.prototype.xor=function(t){return this.length>t.length?this.clone().ixor(t):t.clone().ixor(this)},n.prototype.uxor=function(t){return this.length>t.length?this.clone().iuxor(t):t.clone().iuxor(this)},n.prototype.inotn=function(t){r("number"==typeof t&&t>=0);var e=0|Math.ceil(t/26),i=t%26;this._expand(e),i>0&&e--;for(var n=0;n<e;n++)this.words[n]=67108863&~this.words[n];return i>0&&(this.words[n]=~this.words[n]&67108863>>26-i),this._strip()},n.prototype.notn=function(t){return this.clone().inotn(t)},n.prototype.setn=function(t,e){r("number"==typeof t&&t>=0);var i=t/26|0,n=t%26;return this._expand(i+1),this.words[i]=e?this.words[i]|1<<n:this.words[i]&~(1<<n),this._strip()},n.prototype.iadd=function(t){var e,r,i;if(0!==this.negative&&0===t.negative)return this.negative=0,e=this.isub(t),this.negative^=1,this._normSign();if(0===this.negative&&0!==t.negative)return t.negative=0,e=this.isub(t),t.negative=1,e._normSign();this.length>t.length?(r=this,i=t):(r=t,i=this);for(var n=0,o=0;o<i.length;o++)e=(0|r.words[o])+(0|i.words[o])+n,this.words[o]=67108863&e,n=e>>>26;for(;0!==n&&o<r.length;o++)e=(0|r.words[o])+n,this.words[o]=67108863&e,n=e>>>26;if(this.length=r.length,0!==n)this.words[this.length]=n,this.length++;else if(r!==this)for(;o<r.length;o++)this.words[o]=r.words[o];return this},n.prototype.add=function(t){var e;return 0!==t.negative&&0===this.negative?(t.negative=0,e=this.sub(t),t.negative^=1,e):0===t.negative&&0!==this.negative?(this.negative=0,e=t.sub(this),this.negative=1,e):this.length>t.length?this.clone().iadd(t):t.clone().iadd(this)},n.prototype.isub=function(t){if(0!==t.negative){t.negative=0;var e=this.iadd(t);return t.negative=1,e._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(t),this.negative=1,this._normSign();var r,i,n=this.cmp(t);if(0===n)return this.negative=0,this.length=1,this.words[0]=0,this;n>0?(r=this,i=t):(r=t,i=this);for(var o=0,a=0;a<i.length;a++)o=(e=(0|r.words[a])-(0|i.words[a])+o)>>26,this.words[a]=67108863&e;for(;0!==o&&a<r.length;a++)o=(e=(0|r.words[a])+o)>>26,this.words[a]=67108863&e;if(0===o&&a<r.length&&r!==this)for(;a<r.length;a++)this.words[a]=r.words[a];return this.length=Math.max(this.length,a),r!==this&&(this.negative=1),this._strip()},n.prototype.sub=function(t){return this.clone().isub(t)};var p=function(t,e,r){var i,n,o,a=t.words,s=e.words,h=r.words,u=0,l=0|a[0],c=8191&l,d=l>>>13,f=0|a[1],m=8191&f,p=f>>>13,g=0|a[2],y=8191&g,w=g>>>13,v=0|a[3],b=8191&v,k=v>>>13,M=0|a[4],_=8191&M,E=M>>>13,A=0|a[5],j=8191&A,x=A>>>13,S=0|a[6],N=8191&S,I=S>>>13,T=0|a[7],C=8191&T,z=T>>>13,O=0|a[8],R=8191&O,P=O>>>13,B=0|a[9],D=8191&B,$=B>>>13,L=0|s[0],F=8191&L,U=L>>>13,q=0|s[1],V=8191&q,H=q>>>13,G=0|s[2],Z=8191&G,K=G>>>13,J=0|s[3],W=8191&J,Y=J>>>13,Q=0|s[4],X=8191&Q,tt=Q>>>13,et=0|s[5],rt=8191&et,it=et>>>13,nt=0|s[6],ot=8191&nt,at=nt>>>13,st=0|s[7],ht=8191&st,ut=st>>>13,lt=0|s[8],ct=8191&lt,dt=lt>>>13,ft=0|s[9],mt=8191&ft,pt=ft>>>13;r.negative=t.negative^e.negative,r.length=19;var gt=(u+(i=Math.imul(c,F))|0)+((8191&(n=(n=Math.imul(c,U))+Math.imul(d,F)|0))<<13)|0;u=((o=Math.imul(d,U))+(n>>>13)|0)+(gt>>>26)|0,gt&=67108863,i=Math.imul(m,F),n=(n=Math.imul(m,U))+Math.imul(p,F)|0,o=Math.imul(p,U);var yt=(u+(i=i+Math.imul(c,V)|0)|0)+((8191&(n=(n=n+Math.imul(c,H)|0)+Math.imul(d,V)|0))<<13)|0;u=((o=o+Math.imul(d,H)|0)+(n>>>13)|0)+(yt>>>26)|0,yt&=67108863,i=Math.imul(y,F),n=(n=Math.imul(y,U))+Math.imul(w,F)|0,o=Math.imul(w,U),i=i+Math.imul(m,V)|0,n=(n=n+Math.imul(m,H)|0)+Math.imul(p,V)|0,o=o+Math.imul(p,H)|0;var wt=(u+(i=i+Math.imul(c,Z)|0)|0)+((8191&(n=(n=n+Math.imul(c,K)|0)+Math.imul(d,Z)|0))<<13)|0;u=((o=o+Math.imul(d,K)|0)+(n>>>13)|0)+(wt>>>26)|0,wt&=67108863,i=Math.imul(b,F),n=(n=Math.imul(b,U))+Math.imul(k,F)|0,o=Math.imul(k,U),i=i+Math.imul(y,V)|0,n=(n=n+Math.imul(y,H)|0)+Math.imul(w,V)|0,o=o+Math.imul(w,H)|0,i=i+Math.imul(m,Z)|0,n=(n=n+Math.imul(m,K)|0)+Math.imul(p,Z)|0,o=o+Math.imul(p,K)|0;var vt=(u+(i=i+Math.imul(c,W)|0)|0)+((8191&(n=(n=n+Math.imul(c,Y)|0)+Math.imul(d,W)|0))<<13)|0;u=((o=o+Math.imul(d,Y)|0)+(n>>>13)|0)+(vt>>>26)|0,vt&=67108863,i=Math.imul(_,F),n=(n=Math.imul(_,U))+Math.imul(E,F)|0,o=Math.imul(E,U),i=i+Math.imul(b,V)|0,n=(n=n+Math.imul(b,H)|0)+Math.imul(k,V)|0,o=o+Math.imul(k,H)|0,i=i+Math.imul(y,Z)|0,n=(n=n+Math.imul(y,K)|0)+Math.imul(w,Z)|0,o=o+Math.imul(w,K)|0,i=i+Math.imul(m,W)|0,n=(n=n+Math.imul(m,Y)|0)+Math.imul(p,W)|0,o=o+Math.imul(p,Y)|0;var bt=(u+(i=i+Math.imul(c,X)|0)|0)+((8191&(n=(n=n+Math.imul(c,tt)|0)+Math.imul(d,X)|0))<<13)|0;u=((o=o+Math.imul(d,tt)|0)+(n>>>13)|0)+(bt>>>26)|0,bt&=67108863,i=Math.imul(j,F),n=(n=Math.imul(j,U))+Math.imul(x,F)|0,o=Math.imul(x,U),i=i+Math.imul(_,V)|0,n=(n=n+Math.imul(_,H)|0)+Math.imul(E,V)|0,o=o+Math.imul(E,H)|0,i=i+Math.imul(b,Z)|0,n=(n=n+Math.imul(b,K)|0)+Math.imul(k,Z)|0,o=o+Math.imul(k,K)|0,i=i+Math.imul(y,W)|0,n=(n=n+Math.imul(y,Y)|0)+Math.imul(w,W)|0,o=o+Math.imul(w,Y)|0,i=i+Math.imul(m,X)|0,n=(n=n+Math.imul(m,tt)|0)+Math.imul(p,X)|0,o=o+Math.imul(p,tt)|0;var kt=(u+(i=i+Math.imul(c,rt)|0)|0)+((8191&(n=(n=n+Math.imul(c,it)|0)+Math.imul(d,rt)|0))<<13)|0;u=((o=o+Math.imul(d,it)|0)+(n>>>13)|0)+(kt>>>26)|0,kt&=67108863,i=Math.imul(N,F),n=(n=Math.imul(N,U))+Math.imul(I,F)|0,o=Math.imul(I,U),i=i+Math.imul(j,V)|0,n=(n=n+Math.imul(j,H)|0)+Math.imul(x,V)|0,o=o+Math.imul(x,H)|0,i=i+Math.imul(_,Z)|0,n=(n=n+Math.imul(_,K)|0)+Math.imul(E,Z)|0,o=o+Math.imul(E,K)|0,i=i+Math.imul(b,W)|0,n=(n=n+Math.imul(b,Y)|0)+Math.imul(k,W)|0,o=o+Math.imul(k,Y)|0,i=i+Math.imul(y,X)|0,n=(n=n+Math.imul(y,tt)|0)+Math.imul(w,X)|0,o=o+Math.imul(w,tt)|0,i=i+Math.imul(m,rt)|0,n=(n=n+Math.imul(m,it)|0)+Math.imul(p,rt)|0,o=o+Math.imul(p,it)|0;var Mt=(u+(i=i+Math.imul(c,ot)|0)|0)+((8191&(n=(n=n+Math.imul(c,at)|0)+Math.imul(d,ot)|0))<<13)|0;u=((o=o+Math.imul(d,at)|0)+(n>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,i=Math.imul(C,F),n=(n=Math.imul(C,U))+Math.imul(z,F)|0,o=Math.imul(z,U),i=i+Math.imul(N,V)|0,n=(n=n+Math.imul(N,H)|0)+Math.imul(I,V)|0,o=o+Math.imul(I,H)|0,i=i+Math.imul(j,Z)|0,n=(n=n+Math.imul(j,K)|0)+Math.imul(x,Z)|0,o=o+Math.imul(x,K)|0,i=i+Math.imul(_,W)|0,n=(n=n+Math.imul(_,Y)|0)+Math.imul(E,W)|0,o=o+Math.imul(E,Y)|0,i=i+Math.imul(b,X)|0,n=(n=n+Math.imul(b,tt)|0)+Math.imul(k,X)|0,o=o+Math.imul(k,tt)|0,i=i+Math.imul(y,rt)|0,n=(n=n+Math.imul(y,it)|0)+Math.imul(w,rt)|0,o=o+Math.imul(w,it)|0,i=i+Math.imul(m,ot)|0,n=(n=n+Math.imul(m,at)|0)+Math.imul(p,ot)|0,o=o+Math.imul(p,at)|0;var _t=(u+(i=i+Math.imul(c,ht)|0)|0)+((8191&(n=(n=n+Math.imul(c,ut)|0)+Math.imul(d,ht)|0))<<13)|0;u=((o=o+Math.imul(d,ut)|0)+(n>>>13)|0)+(_t>>>26)|0,_t&=67108863,i=Math.imul(R,F),n=(n=Math.imul(R,U))+Math.imul(P,F)|0,o=Math.imul(P,U),i=i+Math.imul(C,V)|0,n=(n=n+Math.imul(C,H)|0)+Math.imul(z,V)|0,o=o+Math.imul(z,H)|0,i=i+Math.imul(N,Z)|0,n=(n=n+Math.imul(N,K)|0)+Math.imul(I,Z)|0,o=o+Math.imul(I,K)|0,i=i+Math.imul(j,W)|0,n=(n=n+Math.imul(j,Y)|0)+Math.imul(x,W)|0,o=o+Math.imul(x,Y)|0,i=i+Math.imul(_,X)|0,n=(n=n+Math.imul(_,tt)|0)+Math.imul(E,X)|0,o=o+Math.imul(E,tt)|0,i=i+Math.imul(b,rt)|0,n=(n=n+Math.imul(b,it)|0)+Math.imul(k,rt)|0,o=o+Math.imul(k,it)|0,i=i+Math.imul(y,ot)|0,n=(n=n+Math.imul(y,at)|0)+Math.imul(w,ot)|0,o=o+Math.imul(w,at)|0,i=i+Math.imul(m,ht)|0,n=(n=n+Math.imul(m,ut)|0)+Math.imul(p,ht)|0,o=o+Math.imul(p,ut)|0;var Et=(u+(i=i+Math.imul(c,ct)|0)|0)+((8191&(n=(n=n+Math.imul(c,dt)|0)+Math.imul(d,ct)|0))<<13)|0;u=((o=o+Math.imul(d,dt)|0)+(n>>>13)|0)+(Et>>>26)|0,Et&=67108863,i=Math.imul(D,F),n=(n=Math.imul(D,U))+Math.imul($,F)|0,o=Math.imul($,U),i=i+Math.imul(R,V)|0,n=(n=n+Math.imul(R,H)|0)+Math.imul(P,V)|0,o=o+Math.imul(P,H)|0,i=i+Math.imul(C,Z)|0,n=(n=n+Math.imul(C,K)|0)+Math.imul(z,Z)|0,o=o+Math.imul(z,K)|0,i=i+Math.imul(N,W)|0,n=(n=n+Math.imul(N,Y)|0)+Math.imul(I,W)|0,o=o+Math.imul(I,Y)|0,i=i+Math.imul(j,X)|0,n=(n=n+Math.imul(j,tt)|0)+Math.imul(x,X)|0,o=o+Math.imul(x,tt)|0,i=i+Math.imul(_,rt)|0,n=(n=n+Math.imul(_,it)|0)+Math.imul(E,rt)|0,o=o+Math.imul(E,it)|0,i=i+Math.imul(b,ot)|0,n=(n=n+Math.imul(b,at)|0)+Math.imul(k,ot)|0,o=o+Math.imul(k,at)|0,i=i+Math.imul(y,ht)|0,n=(n=n+Math.imul(y,ut)|0)+Math.imul(w,ht)|0,o=o+Math.imul(w,ut)|0,i=i+Math.imul(m,ct)|0,n=(n=n+Math.imul(m,dt)|0)+Math.imul(p,ct)|0,o=o+Math.imul(p,dt)|0;var At=(u+(i=i+Math.imul(c,mt)|0)|0)+((8191&(n=(n=n+Math.imul(c,pt)|0)+Math.imul(d,mt)|0))<<13)|0;u=((o=o+Math.imul(d,pt)|0)+(n>>>13)|0)+(At>>>26)|0,At&=67108863,i=Math.imul(D,V),n=(n=Math.imul(D,H))+Math.imul($,V)|0,o=Math.imul($,H),i=i+Math.imul(R,Z)|0,n=(n=n+Math.imul(R,K)|0)+Math.imul(P,Z)|0,o=o+Math.imul(P,K)|0,i=i+Math.imul(C,W)|0,n=(n=n+Math.imul(C,Y)|0)+Math.imul(z,W)|0,o=o+Math.imul(z,Y)|0,i=i+Math.imul(N,X)|0,n=(n=n+Math.imul(N,tt)|0)+Math.imul(I,X)|0,o=o+Math.imul(I,tt)|0,i=i+Math.imul(j,rt)|0,n=(n=n+Math.imul(j,it)|0)+Math.imul(x,rt)|0,o=o+Math.imul(x,it)|0,i=i+Math.imul(_,ot)|0,n=(n=n+Math.imul(_,at)|0)+Math.imul(E,ot)|0,o=o+Math.imul(E,at)|0,i=i+Math.imul(b,ht)|0,n=(n=n+Math.imul(b,ut)|0)+Math.imul(k,ht)|0,o=o+Math.imul(k,ut)|0,i=i+Math.imul(y,ct)|0,n=(n=n+Math.imul(y,dt)|0)+Math.imul(w,ct)|0,o=o+Math.imul(w,dt)|0;var jt=(u+(i=i+Math.imul(m,mt)|0)|0)+((8191&(n=(n=n+Math.imul(m,pt)|0)+Math.imul(p,mt)|0))<<13)|0;u=((o=o+Math.imul(p,pt)|0)+(n>>>13)|0)+(jt>>>26)|0,jt&=67108863,i=Math.imul(D,Z),n=(n=Math.imul(D,K))+Math.imul($,Z)|0,o=Math.imul($,K),i=i+Math.imul(R,W)|0,n=(n=n+Math.imul(R,Y)|0)+Math.imul(P,W)|0,o=o+Math.imul(P,Y)|0,i=i+Math.imul(C,X)|0,n=(n=n+Math.imul(C,tt)|0)+Math.imul(z,X)|0,o=o+Math.imul(z,tt)|0,i=i+Math.imul(N,rt)|0,n=(n=n+Math.imul(N,it)|0)+Math.imul(I,rt)|0,o=o+Math.imul(I,it)|0,i=i+Math.imul(j,ot)|0,n=(n=n+Math.imul(j,at)|0)+Math.imul(x,ot)|0,o=o+Math.imul(x,at)|0,i=i+Math.imul(_,ht)|0,n=(n=n+Math.imul(_,ut)|0)+Math.imul(E,ht)|0,o=o+Math.imul(E,ut)|0,i=i+Math.imul(b,ct)|0,n=(n=n+Math.imul(b,dt)|0)+Math.imul(k,ct)|0,o=o+Math.imul(k,dt)|0;var xt=(u+(i=i+Math.imul(y,mt)|0)|0)+((8191&(n=(n=n+Math.imul(y,pt)|0)+Math.imul(w,mt)|0))<<13)|0;u=((o=o+Math.imul(w,pt)|0)+(n>>>13)|0)+(xt>>>26)|0,xt&=67108863,i=Math.imul(D,W),n=(n=Math.imul(D,Y))+Math.imul($,W)|0,o=Math.imul($,Y),i=i+Math.imul(R,X)|0,n=(n=n+Math.imul(R,tt)|0)+Math.imul(P,X)|0,o=o+Math.imul(P,tt)|0,i=i+Math.imul(C,rt)|0,n=(n=n+Math.imul(C,it)|0)+Math.imul(z,rt)|0,o=o+Math.imul(z,it)|0,i=i+Math.imul(N,ot)|0,n=(n=n+Math.imul(N,at)|0)+Math.imul(I,ot)|0,o=o+Math.imul(I,at)|0,i=i+Math.imul(j,ht)|0,n=(n=n+Math.imul(j,ut)|0)+Math.imul(x,ht)|0,o=o+Math.imul(x,ut)|0,i=i+Math.imul(_,ct)|0,n=(n=n+Math.imul(_,dt)|0)+Math.imul(E,ct)|0,o=o+Math.imul(E,dt)|0;var St=(u+(i=i+Math.imul(b,mt)|0)|0)+((8191&(n=(n=n+Math.imul(b,pt)|0)+Math.imul(k,mt)|0))<<13)|0;u=((o=o+Math.imul(k,pt)|0)+(n>>>13)|0)+(St>>>26)|0,St&=67108863,i=Math.imul(D,X),n=(n=Math.imul(D,tt))+Math.imul($,X)|0,o=Math.imul($,tt),i=i+Math.imul(R,rt)|0,n=(n=n+Math.imul(R,it)|0)+Math.imul(P,rt)|0,o=o+Math.imul(P,it)|0,i=i+Math.imul(C,ot)|0,n=(n=n+Math.imul(C,at)|0)+Math.imul(z,ot)|0,o=o+Math.imul(z,at)|0,i=i+Math.imul(N,ht)|0,n=(n=n+Math.imul(N,ut)|0)+Math.imul(I,ht)|0,o=o+Math.imul(I,ut)|0,i=i+Math.imul(j,ct)|0,n=(n=n+Math.imul(j,dt)|0)+Math.imul(x,ct)|0,o=o+Math.imul(x,dt)|0;var Nt=(u+(i=i+Math.imul(_,mt)|0)|0)+((8191&(n=(n=n+Math.imul(_,pt)|0)+Math.imul(E,mt)|0))<<13)|0;u=((o=o+Math.imul(E,pt)|0)+(n>>>13)|0)+(Nt>>>26)|0,Nt&=67108863,i=Math.imul(D,rt),n=(n=Math.imul(D,it))+Math.imul($,rt)|0,o=Math.imul($,it),i=i+Math.imul(R,ot)|0,n=(n=n+Math.imul(R,at)|0)+Math.imul(P,ot)|0,o=o+Math.imul(P,at)|0,i=i+Math.imul(C,ht)|0,n=(n=n+Math.imul(C,ut)|0)+Math.imul(z,ht)|0,o=o+Math.imul(z,ut)|0,i=i+Math.imul(N,ct)|0,n=(n=n+Math.imul(N,dt)|0)+Math.imul(I,ct)|0,o=o+Math.imul(I,dt)|0;var It=(u+(i=i+Math.imul(j,mt)|0)|0)+((8191&(n=(n=n+Math.imul(j,pt)|0)+Math.imul(x,mt)|0))<<13)|0;u=((o=o+Math.imul(x,pt)|0)+(n>>>13)|0)+(It>>>26)|0,It&=67108863,i=Math.imul(D,ot),n=(n=Math.imul(D,at))+Math.imul($,ot)|0,o=Math.imul($,at),i=i+Math.imul(R,ht)|0,n=(n=n+Math.imul(R,ut)|0)+Math.imul(P,ht)|0,o=o+Math.imul(P,ut)|0,i=i+Math.imul(C,ct)|0,n=(n=n+Math.imul(C,dt)|0)+Math.imul(z,ct)|0,o=o+Math.imul(z,dt)|0;var Tt=(u+(i=i+Math.imul(N,mt)|0)|0)+((8191&(n=(n=n+Math.imul(N,pt)|0)+Math.imul(I,mt)|0))<<13)|0;u=((o=o+Math.imul(I,pt)|0)+(n>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,i=Math.imul(D,ht),n=(n=Math.imul(D,ut))+Math.imul($,ht)|0,o=Math.imul($,ut),i=i+Math.imul(R,ct)|0,n=(n=n+Math.imul(R,dt)|0)+Math.imul(P,ct)|0,o=o+Math.imul(P,dt)|0;var Ct=(u+(i=i+Math.imul(C,mt)|0)|0)+((8191&(n=(n=n+Math.imul(C,pt)|0)+Math.imul(z,mt)|0))<<13)|0;u=((o=o+Math.imul(z,pt)|0)+(n>>>13)|0)+(Ct>>>26)|0,Ct&=67108863,i=Math.imul(D,ct),n=(n=Math.imul(D,dt))+Math.imul($,ct)|0,o=Math.imul($,dt);var zt=(u+(i=i+Math.imul(R,mt)|0)|0)+((8191&(n=(n=n+Math.imul(R,pt)|0)+Math.imul(P,mt)|0))<<13)|0;u=((o=o+Math.imul(P,pt)|0)+(n>>>13)|0)+(zt>>>26)|0,zt&=67108863;var Ot=(u+(i=Math.imul(D,mt))|0)+((8191&(n=(n=Math.imul(D,pt))+Math.imul($,mt)|0))<<13)|0;return u=((o=Math.imul($,pt))+(n>>>13)|0)+(Ot>>>26)|0,Ot&=67108863,h[0]=gt,h[1]=yt,h[2]=wt,h[3]=vt,h[4]=bt,h[5]=kt,h[6]=Mt,h[7]=_t,h[8]=Et,h[9]=At,h[10]=jt,h[11]=xt,h[12]=St,h[13]=Nt,h[14]=It,h[15]=Tt,h[16]=Ct,h[17]=zt,h[18]=Ot,0!==u&&(h[19]=u,r.length++),r};function g(t,e,r){r.negative=e.negative^t.negative,r.length=t.length+e.length;for(var i=0,n=0,o=0;o<r.length-1;o++){var a=n;n=0;for(var s=67108863&i,h=Math.min(o,e.length-1),u=Math.max(0,o-t.length+1);u<=h;u++){var l=o-u,c=(0|t.words[l])*(0|e.words[u]),d=67108863&c;s=67108863&(d=d+s|0),n+=(a=(a=a+(c/67108864|0)|0)+(d>>>26)|0)>>>26,a&=67108863}r.words[o]=s,i=a,a=n}return 0!==i?r.words[o]=i:r.length--,r._strip()}function y(t,e,r){return g(t,e,r)}Math.imul||(p=m),n.prototype.mulTo=function(t,e){var r=this.length+t.length;return 10===this.length&&10===t.length?p(this,t,e):r<63?m(this,t,e):r<1024?g(this,t,e):y(this,t,e)},n.prototype.mul=function(t){var e=new n(null);return e.words=new Array(this.length+t.length),this.mulTo(t,e)},n.prototype.mulf=function(t){var e=new n(null);return e.words=new Array(this.length+t.length),y(this,t,e)},n.prototype.imul=function(t){return this.clone().mulTo(t,this)},n.prototype.imuln=function(t){var e=t<0;e&&(t=-t),r("number"==typeof t),r(t<67108864);for(var i=0,n=0;n<this.length;n++){var o=(0|this.words[n])*t,a=(67108863&o)+(67108863&i);i>>=26,i+=o/67108864|0,i+=a>>>26,this.words[n]=67108863&a}return 0!==i&&(this.words[n]=i,this.length++),e?this.ineg():this},n.prototype.muln=function(t){return this.clone().imuln(t)},n.prototype.sqr=function(){return this.mul(this)},n.prototype.isqr=function(){return this.imul(this.clone())},n.prototype.pow=function(t){var e=function(t){for(var e=new Array(t.bitLength()),r=0;r<e.length;r++){var i=r/26|0,n=r%26;e[r]=t.words[i]>>>n&1}return e}(t);if(0===e.length)return new n(1);for(var r=this,i=0;i<e.length&&0===e[i];i++,r=r.sqr());if(++i<e.length)for(var o=r.sqr();i<e.length;i++,o=o.sqr())0!==e[i]&&(r=r.mul(o));return r},n.prototype.iushln=function(t){r("number"==typeof t&&t>=0);var e,i=t%26,n=(t-i)/26,o=67108863>>>26-i<<26-i;if(0!==i){var a=0;for(e=0;e<this.length;e++){var s=this.words[e]&o,h=(0|this.words[e])-s<<i;this.words[e]=h|a,a=s>>>26-i}a&&(this.words[e]=a,this.length++)}if(0!==n){for(e=this.length-1;e>=0;e--)this.words[e+n]=this.words[e];for(e=0;e<n;e++)this.words[e]=0;this.length+=n}return this._strip()},n.prototype.ishln=function(t){return r(0===this.negative),this.iushln(t)},n.prototype.iushrn=function(t,e,i){var n;r("number"==typeof t&&t>=0),n=e?(e-e%26)/26:0;var o=t%26,a=Math.min((t-o)/26,this.length),s=67108863^67108863>>>o<<o,h=i;if(n-=a,n=Math.max(0,n),h){for(var u=0;u<a;u++)h.words[u]=this.words[u];h.length=a}if(0===a);else if(this.length>a)for(this.length-=a,u=0;u<this.length;u++)this.words[u]=this.words[u+a];else this.words[0]=0,this.length=1;var l=0;for(u=this.length-1;u>=0&&(0!==l||u>=n);u--){var c=0|this.words[u];this.words[u]=l<<26-o|c>>>o,l=c&s}return h&&0!==l&&(h.words[h.length++]=l),0===this.length&&(this.words[0]=0,this.length=1),this._strip()},n.prototype.ishrn=function(t,e,i){return r(0===this.negative),this.iushrn(t,e,i)},n.prototype.shln=function(t){return this.clone().ishln(t)},n.prototype.ushln=function(t){return this.clone().iushln(t)},n.prototype.shrn=function(t){return this.clone().ishrn(t)},n.prototype.ushrn=function(t){return this.clone().iushrn(t)},n.prototype.testn=function(t){r("number"==typeof t&&t>=0);var e=t%26,i=(t-e)/26,n=1<<e;return!(this.length<=i)&&!!(this.words[i]&n)},n.prototype.imaskn=function(t){r("number"==typeof t&&t>=0);var e=t%26,i=(t-e)/26;if(r(0===this.negative,"imaskn works only with positive numbers"),this.length<=i)return this;if(0!==e&&i++,this.length=Math.min(i,this.length),0!==e){var n=67108863^67108863>>>e<<e;this.words[this.length-1]&=n}return this._strip()},n.prototype.maskn=function(t){return this.clone().imaskn(t)},n.prototype.iaddn=function(t){return r("number"==typeof t),r(t<67108864),t<0?this.isubn(-t):0!==this.negative?1===this.length&&(0|this.words[0])<=t?(this.words[0]=t-(0|this.words[0]),this.negative=0,this):(this.negative=0,this.isubn(t),this.negative=1,this):this._iaddn(t)},n.prototype._iaddn=function(t){this.words[0]+=t;for(var e=0;e<this.length&&this.words[e]>=67108864;e++)this.words[e]-=67108864,e===this.length-1?this.words[e+1]=1:this.words[e+1]++;return this.length=Math.max(this.length,e+1),this},n.prototype.isubn=function(t){if(r("number"==typeof t),r(t<67108864),t<0)return this.iaddn(-t);if(0!==this.negative)return this.negative=0,this.iaddn(t),this.negative=1,this;if(this.words[0]-=t,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var e=0;e<this.length&&this.words[e]<0;e++)this.words[e]+=67108864,this.words[e+1]-=1;return this._strip()},n.prototype.addn=function(t){return this.clone().iaddn(t)},n.prototype.subn=function(t){return this.clone().isubn(t)},n.prototype.iabs=function(){return this.negative=0,this},n.prototype.abs=function(){return this.clone().iabs()},n.prototype._ishlnsubmul=function(t,e,i){var n,o,a=t.length+i;this._expand(a);var s=0;for(n=0;n<t.length;n++){o=(0|this.words[n+i])+s;var h=(0|t.words[n])*e;s=((o-=67108863&h)>>26)-(h/67108864|0),this.words[n+i]=67108863&o}for(;n<this.length-i;n++)s=(o=(0|this.words[n+i])+s)>>26,this.words[n+i]=67108863&o;if(0===s)return this._strip();for(r(-1===s),s=0,n=0;n<this.length;n++)s=(o=-(0|this.words[n])+s)>>26,this.words[n]=67108863&o;return this.negative=1,this._strip()},n.prototype._wordDiv=function(t,e){var r=(this.length,t.length),i=this.clone(),o=t,a=0|o.words[o.length-1];0!==(r=26-this._countBits(a))&&(o=o.ushln(r),i.iushln(r),a=0|o.words[o.length-1]);var s,h=i.length-o.length;if("mod"!==e){(s=new n(null)).length=h+1,s.words=new Array(s.length);for(var u=0;u<s.length;u++)s.words[u]=0}var l=i.clone()._ishlnsubmul(o,1,h);0===l.negative&&(i=l,s&&(s.words[h]=1));for(var c=h-1;c>=0;c--){var d=67108864*(0|i.words[o.length+c])+(0|i.words[o.length+c-1]);for(d=Math.min(d/a|0,67108863),i._ishlnsubmul(o,d,c);0!==i.negative;)d--,i.negative=0,i._ishlnsubmul(o,1,c),i.isZero()||(i.negative^=1);s&&(s.words[c]=d)}return s&&s._strip(),i._strip(),"div"!==e&&0!==r&&i.iushrn(r),{div:s||null,mod:i}},n.prototype.divmod=function(t,e,i){return r(!t.isZero()),this.isZero()?{div:new n(0),mod:new n(0)}:0!==this.negative&&0===t.negative?(s=this.neg().divmod(t,e),"mod"!==e&&(o=s.div.neg()),"div"!==e&&(a=s.mod.neg(),i&&0!==a.negative&&a.iadd(t)),{div:o,mod:a}):0===this.negative&&0!==t.negative?(s=this.divmod(t.neg(),e),"mod"!==e&&(o=s.div.neg()),{div:o,mod:s.mod}):0!=(this.negative&t.negative)?(s=this.neg().divmod(t.neg(),e),"div"!==e&&(a=s.mod.neg(),i&&0!==a.negative&&a.isub(t)),{div:s.div,mod:a}):t.length>this.length||this.cmp(t)<0?{div:new n(0),mod:this}:1===t.length?"div"===e?{div:this.divn(t.words[0]),mod:null}:"mod"===e?{div:null,mod:new n(this.modrn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new n(this.modrn(t.words[0]))}:this._wordDiv(t,e);var o,a,s},n.prototype.div=function(t){return this.divmod(t,"div",!1).div},n.prototype.mod=function(t){return this.divmod(t,"mod",!1).mod},n.prototype.umod=function(t){return this.divmod(t,"mod",!0).mod},n.prototype.divRound=function(t){var e=this.divmod(t);if(e.mod.isZero())return e.div;var r=0!==e.div.negative?e.mod.isub(t):e.mod,i=t.ushrn(1),n=t.andln(1),o=r.cmp(i);return o<0||1===n&&0===o?e.div:0!==e.div.negative?e.div.isubn(1):e.div.iaddn(1)},n.prototype.modrn=function(t){var e=t<0;e&&(t=-t),r(t<=67108863);for(var i=(1<<26)%t,n=0,o=this.length-1;o>=0;o--)n=(i*n+(0|this.words[o]))%t;return e?-n:n},n.prototype.modn=function(t){return this.modrn(t)},n.prototype.idivn=function(t){var e=t<0;e&&(t=-t),r(t<=67108863);for(var i=0,n=this.length-1;n>=0;n--){var o=(0|this.words[n])+67108864*i;this.words[n]=o/t|0,i=o%t}return this._strip(),e?this.ineg():this},n.prototype.divn=function(t){return this.clone().idivn(t)},n.prototype.egcd=function(t){r(0===t.negative),r(!t.isZero());var e=this,i=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var o=new n(1),a=new n(0),s=new n(0),h=new n(1),u=0;e.isEven()&&i.isEven();)e.iushrn(1),i.iushrn(1),++u;for(var l=i.clone(),c=e.clone();!e.isZero();){for(var d=0,f=1;0==(e.words[0]&f)&&d<26;++d,f<<=1);if(d>0)for(e.iushrn(d);d-- >0;)(o.isOdd()||a.isOdd())&&(o.iadd(l),a.isub(c)),o.iushrn(1),a.iushrn(1);for(var m=0,p=1;0==(i.words[0]&p)&&m<26;++m,p<<=1);if(m>0)for(i.iushrn(m);m-- >0;)(s.isOdd()||h.isOdd())&&(s.iadd(l),h.isub(c)),s.iushrn(1),h.iushrn(1);e.cmp(i)>=0?(e.isub(i),o.isub(s),a.isub(h)):(i.isub(e),s.isub(o),h.isub(a))}return{a:s,b:h,gcd:i.iushln(u)}},n.prototype._invmp=function(t){r(0===t.negative),r(!t.isZero());var e=this,i=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var o,a=new n(1),s=new n(0),h=i.clone();e.cmpn(1)>0&&i.cmpn(1)>0;){for(var u=0,l=1;0==(e.words[0]&l)&&u<26;++u,l<<=1);if(u>0)for(e.iushrn(u);u-- >0;)a.isOdd()&&a.iadd(h),a.iushrn(1);for(var c=0,d=1;0==(i.words[0]&d)&&c<26;++c,d<<=1);if(c>0)for(i.iushrn(c);c-- >0;)s.isOdd()&&s.iadd(h),s.iushrn(1);e.cmp(i)>=0?(e.isub(i),a.isub(s)):(i.isub(e),s.isub(a))}return(o=0===e.cmpn(1)?a:s).cmpn(0)<0&&o.iadd(t),o},n.prototype.gcd=function(t){if(this.isZero())return t.abs();if(t.isZero())return this.abs();var e=this.clone(),r=t.clone();e.negative=0,r.negative=0;for(var i=0;e.isEven()&&r.isEven();i++)e.iushrn(1),r.iushrn(1);for(;;){for(;e.isEven();)e.iushrn(1);for(;r.isEven();)r.iushrn(1);var n=e.cmp(r);if(n<0){var o=e;e=r,r=o}else if(0===n||0===r.cmpn(1))break;e.isub(r)}return r.iushln(i)},n.prototype.invm=function(t){return this.egcd(t).a.umod(t)},n.prototype.isEven=function(){return 0==(1&this.words[0])},n.prototype.isOdd=function(){return 1==(1&this.words[0])},n.prototype.andln=function(t){return this.words[0]&t},n.prototype.bincn=function(t){r("number"==typeof t);var e=t%26,i=(t-e)/26,n=1<<e;if(this.length<=i)return this._expand(i+1),this.words[i]|=n,this;for(var o=n,a=i;0!==o&&a<this.length;a++){var s=0|this.words[a];o=(s+=o)>>>26,s&=67108863,this.words[a]=s}return 0!==o&&(this.words[a]=o,this.length++),this},n.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},n.prototype.cmpn=function(t){var e,i=t<0;if(0!==this.negative&&!i)return-1;if(0===this.negative&&i)return 1;if(this._strip(),this.length>1)e=1;else{i&&(t=-t),r(t<=67108863,"Number is too big");var n=0|this.words[0];e=n===t?0:n<t?-1:1}return 0!==this.negative?0|-e:e},n.prototype.cmp=function(t){if(0!==this.negative&&0===t.negative)return-1;if(0===this.negative&&0!==t.negative)return 1;var e=this.ucmp(t);return 0!==this.negative?0|-e:e},n.prototype.ucmp=function(t){if(this.length>t.length)return 1;if(this.length<t.length)return-1;for(var e=0,r=this.length-1;r>=0;r--){var i=0|this.words[r],n=0|t.words[r];if(i!==n){i<n?e=-1:i>n&&(e=1);break}}return e},n.prototype.gtn=function(t){return 1===this.cmpn(t)},n.prototype.gt=function(t){return 1===this.cmp(t)},n.prototype.gten=function(t){return this.cmpn(t)>=0},n.prototype.gte=function(t){return this.cmp(t)>=0},n.prototype.ltn=function(t){return-1===this.cmpn(t)},n.prototype.lt=function(t){return-1===this.cmp(t)},n.prototype.lten=function(t){return this.cmpn(t)<=0},n.prototype.lte=function(t){return this.cmp(t)<=0},n.prototype.eqn=function(t){return 0===this.cmpn(t)},n.prototype.eq=function(t){return 0===this.cmp(t)},n.red=function(t){return new E(t)},n.prototype.toRed=function(t){return r(!this.red,"Already a number in reduction context"),r(0===this.negative,"red works only with positives"),t.convertTo(this)._forceRed(t)},n.prototype.fromRed=function(){return r(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},n.prototype._forceRed=function(t){return this.red=t,this},n.prototype.forceRed=function(t){return r(!this.red,"Already a number in reduction context"),this._forceRed(t)},n.prototype.redAdd=function(t){return r(this.red,"redAdd works only with red numbers"),this.red.add(this,t)},n.prototype.redIAdd=function(t){return r(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,t)},n.prototype.redSub=function(t){return r(this.red,"redSub works only with red numbers"),this.red.sub(this,t)},n.prototype.redISub=function(t){return r(this.red,"redISub works only with red numbers"),this.red.isub(this,t)},n.prototype.redShl=function(t){return r(this.red,"redShl works only with red numbers"),this.red.shl(this,t)},n.prototype.redMul=function(t){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.mul(this,t)},n.prototype.redIMul=function(t){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.imul(this,t)},n.prototype.redSqr=function(){return r(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},n.prototype.redISqr=function(){return r(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},n.prototype.redSqrt=function(){return r(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},n.prototype.redInvm=function(){return r(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},n.prototype.redNeg=function(){return r(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},n.prototype.redPow=function(t){return r(this.red&&!t.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,t)};var w={k256:null,p224:null,p192:null,p25519:null};function v(t,e){this.name=t,this.p=new n(e,16),this.n=this.p.bitLength(),this.k=new n(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function b(){v.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function k(){v.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function M(){v.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function _(){v.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function E(t){if("string"==typeof t){var e=n._prime(t);this.m=e.p,this.prime=e}else r(t.gtn(1),"modulus must be greater than 1"),this.m=t,this.prime=null}function A(t){E.call(this,t),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new n(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)}v.prototype._tmp=function(){var t=new n(null);return t.words=new Array(Math.ceil(this.n/13)),t},v.prototype.ireduce=function(t){var e,r=t;do{this.split(r,this.tmp),e=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(e>this.n);var i=e<this.n?-1:r.ucmp(this.p);return 0===i?(r.words[0]=0,r.length=1):i>0?r.isub(this.p):void 0!==r.strip?r.strip():r._strip(),r},v.prototype.split=function(t,e){t.iushrn(this.n,0,e)},v.prototype.imulK=function(t){return t.imul(this.k)},i(b,v),b.prototype.split=function(t,e){for(var r=4194303,i=Math.min(t.length,9),n=0;n<i;n++)e.words[n]=t.words[n];if(e.length=i,t.length<=9)return t.words[0]=0,void(t.length=1);var o=t.words[9];for(e.words[e.length++]=o&r,n=10;n<t.length;n++){var a=0|t.words[n];t.words[n-10]=(a&r)<<4|o>>>22,o=a}o>>>=22,t.words[n-10]=o,0===o&&t.length>10?t.length-=10:t.length-=9},b.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var e=0,r=0;r<t.length;r++){var i=0|t.words[r];e+=977*i,t.words[r]=67108863&e,e=64*i+(e/67108864|0)}return 0===t.words[t.length-1]&&(t.length--,0===t.words[t.length-1]&&t.length--),t},i(k,v),i(M,v),i(_,v),_.prototype.imulK=function(t){for(var e=0,r=0;r<t.length;r++){var i=19*(0|t.words[r])+e,n=67108863&i;i>>>=26,t.words[r]=n,e=i}return 0!==e&&(t.words[t.length++]=e),t},n._prime=function(t){if(w[t])return w[t];var e;if("k256"===t)e=new b;else if("p224"===t)e=new k;else if("p192"===t)e=new M;else{if("p25519"!==t)throw new Error("Unknown prime "+t);e=new _}return w[t]=e,e},E.prototype._verify1=function(t){r(0===t.negative,"red works only with positives"),r(t.red,"red works only with red numbers")},E.prototype._verify2=function(t,e){r(0==(t.negative|e.negative),"red works only with positives"),r(t.red&&t.red===e.red,"red works only with red numbers")},E.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):(u(t,t.umod(this.m)._forceRed(this)),t)},E.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},E.prototype.add=function(t,e){this._verify2(t,e);var r=t.add(e);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},E.prototype.iadd=function(t,e){this._verify2(t,e);var r=t.iadd(e);return r.cmp(this.m)>=0&&r.isub(this.m),r},E.prototype.sub=function(t,e){this._verify2(t,e);var r=t.sub(e);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},E.prototype.isub=function(t,e){this._verify2(t,e);var r=t.isub(e);return r.cmpn(0)<0&&r.iadd(this.m),r},E.prototype.shl=function(t,e){return this._verify1(t),this.imod(t.ushln(e))},E.prototype.imul=function(t,e){return this._verify2(t,e),this.imod(t.imul(e))},E.prototype.mul=function(t,e){return this._verify2(t,e),this.imod(t.mul(e))},E.prototype.isqr=function(t){return this.imul(t,t.clone())},E.prototype.sqr=function(t){return this.mul(t,t)},E.prototype.sqrt=function(t){if(t.isZero())return t.clone();var e=this.m.andln(3);if(r(e%2==1),3===e){var i=this.m.add(new n(1)).iushrn(2);return this.pow(t,i)}for(var o=this.m.subn(1),a=0;!o.isZero()&&0===o.andln(1);)a++,o.iushrn(1);r(!o.isZero());var s=new n(1).toRed(this),h=s.redNeg(),u=this.m.subn(1).iushrn(1),l=this.m.bitLength();for(l=new n(2*l*l).toRed(this);0!==this.pow(l,u).cmp(h);)l.redIAdd(h);for(var c=this.pow(l,o),d=this.pow(t,o.addn(1).iushrn(1)),f=this.pow(t,o),m=a;0!==f.cmp(s);){for(var p=f,g=0;0!==p.cmp(s);g++)p=p.redSqr();r(g<m);var y=this.pow(c,new n(1).iushln(m-g-1));d=d.redMul(y),c=y.redSqr(),f=f.redMul(c),m=g}return d},E.prototype.invm=function(t){var e=t._invmp(this.m);return 0!==e.negative?(e.negative=0,this.imod(e).redNeg()):this.imod(e)},E.prototype.pow=function(t,e){if(e.isZero())return new n(1).toRed(this);if(0===e.cmpn(1))return t.clone();var r=new Array(16);r[0]=new n(1).toRed(this),r[1]=t;for(var i=2;i<r.length;i++)r[i]=this.mul(r[i-1],t);var o=r[0],a=0,s=0,h=e.bitLength()%26;for(0===h&&(h=26),i=e.length-1;i>=0;i--){for(var u=e.words[i],l=h-1;l>=0;l--){var c=u>>l&1;o!==r[0]&&(o=this.sqr(o)),0!==c||0!==a?(a<<=1,a|=c,(4===++s||0===i&&0===l)&&(o=this.mul(o,r[a]),s=0,a=0)):s=0}h=26}return o},E.prototype.convertTo=function(t){var e=t.umod(this.m);return e===t?e.clone():e},E.prototype.convertFrom=function(t){var e=t.clone();return e.red=null,e},n.mont=function(t){return new A(t)},i(A,E),A.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},A.prototype.convertFrom=function(t){var e=this.imod(t.mul(this.rinv));return e.red=null,e},A.prototype.imul=function(t,e){if(t.isZero()||e.isZero())return t.words[0]=0,t.length=1,t;var r=t.imul(e),i=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),n=r.isub(i).iushrn(this.shift),o=n;return n.cmp(this.m)>=0?o=n.isub(this.m):n.cmpn(0)<0&&(o=n.iadd(this.m)),o._forceRed(this)},A.prototype.mul=function(t,e){if(t.isZero()||e.isZero())return new n(0)._forceRed(this);var r=t.mul(e),i=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),o=r.isub(i).iushrn(this.shift),a=o;return o.cmp(this.m)>=0?a=o.isub(this.m):o.cmpn(0)<0&&(a=o.iadd(this.m)),a._forceRed(this)},A.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}(t,i)})),Fn=Un;function Un(t,e){if(!t)throw new Error(e||"Assertion failed")}function qn(t,e){return 55296==(64512&t.charCodeAt(e))&&(!(e<0||e+1>=t.length)&&56320==(64512&t.charCodeAt(e+1)))}function Vn(t){return(t>>>24|t>>>8&65280|t<<8&16711680|(255&t)<<24)>>>0}function Hn(t){return 1===t.length?"0"+t:t}function Gn(t){return 7===t.length?"0"+t:6===t.length?"00"+t:5===t.length?"000"+t:4===t.length?"0000"+t:3===t.length?"00000"+t:2===t.length?"000000"+t:1===t.length?"0000000"+t:t}Un.equal=function(t,e,r){if(t!=e)throw new Error(r||"Assertion failed: "+t+" != "+e)};var Zn={inherits:a((function(t){"function"==typeof Object.create?t.exports=function(t,e){e&&(t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}))}:t.exports=function(t,e){if(e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}}})),toArray:function(t,e){if(Array.isArray(t))return t.slice();if(!t)return[];var r=[];if("string"==typeof t)if(e){if("hex"===e)for((t=t.replace(/[^a-z0-9]+/gi,"")).length%2!=0&&(t="0"+t),n=0;n<t.length;n+=2)r.push(parseInt(t[n]+t[n+1],16))}else for(var i=0,n=0;n<t.length;n++){var o=t.charCodeAt(n);o<128?r[i++]=o:o<2048?(r[i++]=o>>6|192,r[i++]=63&o|128):qn(t,n)?(o=65536+((1023&o)<<10)+(1023&t.charCodeAt(++n)),r[i++]=o>>18|240,r[i++]=o>>12&63|128,r[i++]=o>>6&63|128,r[i++]=63&o|128):(r[i++]=o>>12|224,r[i++]=o>>6&63|128,r[i++]=63&o|128)}else for(n=0;n<t.length;n++)r[n]=0|t[n];return r},toHex:function(t){for(var e="",r=0;r<t.length;r++)e+=Hn(t[r].toString(16));return e},htonl:Vn,toHex32:function(t,e){for(var r="",i=0;i<t.length;i++){var n=t[i];"little"===e&&(n=Vn(n)),r+=Gn(n.toString(16))}return r},zero2:Hn,zero8:Gn,join32:function(t,e,r,i){var n=r-e;Fn(n%4==0);for(var o=new Array(n/4),a=0,s=e;a<o.length;a++,s+=4){var h;h="big"===i?t[s]<<24|t[s+1]<<16|t[s+2]<<8|t[s+3]:t[s+3]<<24|t[s+2]<<16|t[s+1]<<8|t[s],o[a]=h>>>0}return o},split32:function(t,e){for(var r=new Array(4*t.length),i=0,n=0;i<t.length;i++,n+=4){var o=t[i];"big"===e?(r[n]=o>>>24,r[n+1]=o>>>16&255,r[n+2]=o>>>8&255,r[n+3]=255&o):(r[n+3]=o>>>24,r[n+2]=o>>>16&255,r[n+1]=o>>>8&255,r[n]=255&o)}return r},rotr32:function(t,e){return t>>>e|t<<32-e},rotl32:function(t,e){return t<<e|t>>>32-e},sum32:function(t,e){return t+e>>>0},sum32_3:function(t,e,r){return t+e+r>>>0},sum32_4:function(t,e,r,i){return t+e+r+i>>>0},sum32_5:function(t,e,r,i,n){return t+e+r+i+n>>>0},sum64:function(t,e,r,i){var n=t[e],o=i+t[e+1]>>>0,a=(o<i?1:0)+r+n;t[e]=a>>>0,t[e+1]=o},sum64_hi:function(t,e,r,i){return(e+i>>>0<e?1:0)+t+r>>>0},sum64_lo:function(t,e,r,i){return e+i>>>0},sum64_4_hi:function(t,e,r,i,n,o,a,s){var h=0,u=e;return h+=(u=u+i>>>0)<e?1:0,h+=(u=u+o>>>0)<o?1:0,t+r+n+a+(h+=(u=u+s>>>0)<s?1:0)>>>0},sum64_4_lo:function(t,e,r,i,n,o,a,s){return e+i+o+s>>>0},sum64_5_hi:function(t,e,r,i,n,o,a,s,h,u){var l=0,c=e;return l+=(c=c+i>>>0)<e?1:0,l+=(c=c+o>>>0)<o?1:0,l+=(c=c+s>>>0)<s?1:0,t+r+n+a+h+(l+=(c=c+u>>>0)<u?1:0)>>>0},sum64_5_lo:function(t,e,r,i,n,o,a,s,h,u){return e+i+o+s+u>>>0},rotr64_hi:function(t,e,r){return(e<<32-r|t>>>r)>>>0},rotr64_lo:function(t,e,r){return(t<<32-r|e>>>r)>>>0},shr64_hi:function(t,e,r){return t>>>r},shr64_lo:function(t,e,r){return(t<<32-r|e>>>r)>>>0}};function Kn(){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}var Jn=Kn;Kn.prototype.update=function(t,e){if(t=Zn.toArray(t,e),this.pending?this.pending=this.pending.concat(t):this.pending=t,this.pendingTotal+=t.length,this.pending.length>=this._delta8){var r=(t=this.pending).length%this._delta8;this.pending=t.slice(t.length-r,t.length),0===this.pending.length&&(this.pending=null),t=Zn.join32(t,0,t.length-r,this.endian);for(var i=0;i<t.length;i+=this._delta32)this._update(t,i,i+this._delta32)}return this},Kn.prototype.digest=function(t){return this.update(this._pad()),Fn(null===this.pending),this._digest(t)},Kn.prototype._pad=function(){var t=this.pendingTotal,e=this._delta8,r=e-(t+this.padLength)%e,i=new Array(r+this.padLength);i[0]=128;for(var n=1;n<r;n++)i[n]=0;if(t<<=3,"big"===this.endian){for(var o=8;o<this.padLength;o++)i[n++]=0;i[n++]=0,i[n++]=0,i[n++]=0,i[n++]=0,i[n++]=t>>>24&255,i[n++]=t>>>16&255,i[n++]=t>>>8&255,i[n++]=255&t}else for(i[n++]=255&t,i[n++]=t>>>8&255,i[n++]=t>>>16&255,i[n++]=t>>>24&255,i[n++]=0,i[n++]=0,i[n++]=0,i[n++]=0,o=8;o<this.padLength;o++)i[n++]=0;return i};var Wn={BlockHash:Jn},Yn=Zn.rotr32;var Qn=function(t,e,r,i){return 0===t?Xn(e,r,i):1===t||3===t?eo(e,r,i):2===t?to(e,r,i):void 0};function Xn(t,e,r){return t&e^~t&r}function to(t,e,r){return t&e^t&r^e&r}function eo(t,e,r){return t^e^r}var ro=function(t){return Yn(t,2)^Yn(t,13)^Yn(t,22)};var io=function(t){return Yn(t,6)^Yn(t,11)^Yn(t,25)};var no=function(t){return Yn(t,7)^Yn(t,18)^t>>>3};var oo=function(t){return Yn(t,17)^Yn(t,19)^t>>>10},ao={ft_1:Qn,ch32:Xn,maj32:to,p32:eo,s0_256:ro,s1_256:io,g0_256:no,g1_256:oo},so=Zn.rotl32,ho=Zn.sum32,uo=Zn.sum32_5,lo=ao.ft_1,co=Wn.BlockHash,fo=[1518500249,1859775393,2400959708,3395469782];function mo(){if(!(this instanceof mo))return new mo;co.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.W=new Array(80)}Zn.inherits(mo,co);var po=mo;mo.blockSize=512,mo.outSize=160,mo.hmacStrength=80,mo.padLength=64,mo.prototype._update=function(t,e){for(var r=this.W,i=0;i<16;i++)r[i]=t[e+i];for(;i<r.length;i++)r[i]=so(r[i-3]^r[i-8]^r[i-14]^r[i-16],1);var n=this.h[0],o=this.h[1],a=this.h[2],s=this.h[3],h=this.h[4];for(i=0;i<r.length;i++){var u=~~(i/20),l=uo(so(n,5),lo(u,o,a,s),h,r[i],fo[u]);h=s,s=a,a=so(o,30),o=n,n=l}this.h[0]=ho(this.h[0],n),this.h[1]=ho(this.h[1],o),this.h[2]=ho(this.h[2],a),this.h[3]=ho(this.h[3],s),this.h[4]=ho(this.h[4],h)},mo.prototype._digest=function(t){return"hex"===t?Zn.toHex32(this.h,"big"):Zn.split32(this.h,"big")};var go=Zn.sum32,yo=Zn.sum32_4,wo=Zn.sum32_5,vo=ao.ch32,bo=ao.maj32,ko=ao.s0_256,Mo=ao.s1_256,_o=ao.g0_256,Eo=ao.g1_256,Ao=Wn.BlockHash,jo=[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 xo(){if(!(this instanceof xo))return new xo;Ao.call(this),this.h=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],this.k=jo,this.W=new Array(64)}Zn.inherits(xo,Ao);var So=xo;function No(){if(!(this instanceof No))return new No;So.call(this),this.h=[3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428]}xo.blockSize=512,xo.outSize=256,xo.hmacStrength=192,xo.padLength=64,xo.prototype._update=function(t,e){for(var r=this.W,i=0;i<16;i++)r[i]=t[e+i];for(;i<r.length;i++)r[i]=yo(Eo(r[i-2]),r[i-7],_o(r[i-15]),r[i-16]);var n=this.h[0],o=this.h[1],a=this.h[2],s=this.h[3],h=this.h[4],u=this.h[5],l=this.h[6],c=this.h[7];for(Fn(this.k.length===r.length),i=0;i<r.length;i++){var d=wo(c,Mo(h),vo(h,u,l),this.k[i],r[i]),f=go(ko(n),bo(n,o,a));c=l,l=u,u=h,h=go(s,d),s=a,a=o,o=n,n=go(d,f)}this.h[0]=go(this.h[0],n),this.h[1]=go(this.h[1],o),this.h[2]=go(this.h[2],a),this.h[3]=go(this.h[3],s),this.h[4]=go(this.h[4],h),this.h[5]=go(this.h[5],u),this.h[6]=go(this.h[6],l),this.h[7]=go(this.h[7],c)},xo.prototype._digest=function(t){return"hex"===t?Zn.toHex32(this.h,"big"):Zn.split32(this.h,"big")},Zn.inherits(No,So);var Io=No;No.blockSize=512,No.outSize=224,No.hmacStrength=192,No.padLength=64,No.prototype._digest=function(t){return"hex"===t?Zn.toHex32(this.h.slice(0,7),"big"):Zn.split32(this.h.slice(0,7),"big")};var To=Zn.rotr64_hi,Co=Zn.rotr64_lo,zo=Zn.shr64_hi,Oo=Zn.shr64_lo,Ro=Zn.sum64,Po=Zn.sum64_hi,Bo=Zn.sum64_lo,Do=Zn.sum64_4_hi,$o=Zn.sum64_4_lo,Lo=Zn.sum64_5_hi,Fo=Zn.sum64_5_lo,Uo=Wn.BlockHash,qo=[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 Vo(){if(!(this instanceof Vo))return new Vo;Uo.call(this),this.h=[1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209],this.k=qo,this.W=new Array(160)}Zn.inherits(Vo,Uo);var Ho=Vo;function Go(t,e,r,i,n){var o=t&r^~t&n;return o<0&&(o+=4294967296),o}function Zo(t,e,r,i,n,o){var a=e&i^~e&o;return a<0&&(a+=4294967296),a}function Ko(t,e,r,i,n){var o=t&r^t&n^r&n;return o<0&&(o+=4294967296),o}function Jo(t,e,r,i,n,o){var a=e&i^e&o^i&o;return a<0&&(a+=4294967296),a}function Wo(t,e){var r=To(t,e,28)^To(e,t,2)^To(e,t,7);return r<0&&(r+=4294967296),r}function Yo(t,e){var r=Co(t,e,28)^Co(e,t,2)^Co(e,t,7);return r<0&&(r+=4294967296),r}function Qo(t,e){var r=To(t,e,14)^To(t,e,18)^To(e,t,9);return r<0&&(r+=4294967296),r}function Xo(t,e){var r=Co(t,e,14)^Co(t,e,18)^Co(e,t,9);return r<0&&(r+=4294967296),r}function ta(t,e){var r=To(t,e,1)^To(t,e,8)^zo(t,e,7);return r<0&&(r+=4294967296),r}function ea(t,e){var r=Co(t,e,1)^Co(t,e,8)^Oo(t,e,7);return r<0&&(r+=4294967296),r}function ra(t,e){var r=To(t,e,19)^To(e,t,29)^zo(t,e,6);return r<0&&(r+=4294967296),r}function ia(t,e){var r=Co(t,e,19)^Co(e,t,29)^Oo(t,e,6);return r<0&&(r+=4294967296),r}function na(){if(!(this instanceof na))return new na;Ho.call(this),this.h=[3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]}Vo.blockSize=1024,Vo.outSize=512,Vo.hmacStrength=192,Vo.padLength=128,Vo.prototype._prepareBlock=function(t,e){for(var r=this.W,i=0;i<32;i++)r[i]=t[e+i];for(;i<r.length;i+=2){var n=ra(r[i-4],r[i-3]),o=ia(r[i-4],r[i-3]),a=r[i-14],s=r[i-13],h=ta(r[i-30],r[i-29]),u=ea(r[i-30],r[i-29]),l=r[i-32],c=r[i-31];r[i]=Do(n,o,a,s,h,u,l,c),r[i+1]=$o(n,o,a,s,h,u,l,c)}},Vo.prototype._update=function(t,e){this._prepareBlock(t,e);var r=this.W,i=this.h[0],n=this.h[1],o=this.h[2],a=this.h[3],s=this.h[4],h=this.h[5],u=this.h[6],l=this.h[7],c=this.h[8],d=this.h[9],f=this.h[10],m=this.h[11],p=this.h[12],g=this.h[13],y=this.h[14],w=this.h[15];Fn(this.k.length===r.length);for(var v=0;v<r.length;v+=2){var b=y,k=w,M=Qo(c,d),_=Xo(c,d),E=Go(c,d,f,m,p),A=Zo(c,d,f,m,p,g),j=this.k[v],x=this.k[v+1],S=r[v],N=r[v+1],I=Lo(b,k,M,_,E,A,j,x,S,N),T=Fo(b,k,M,_,E,A,j,x,S,N);b=Wo(i,n),k=Yo(i,n),M=Ko(i,n,o,a,s),_=Jo(i,n,o,a,s,h);var C=Po(b,k,M,_),z=Bo(b,k,M,_);y=p,w=g,p=f,g=m,f=c,m=d,c=Po(u,l,I,T),d=Bo(l,l,I,T),u=s,l=h,s=o,h=a,o=i,a=n,i=Po(I,T,C,z),n=Bo(I,T,C,z)}Ro(this.h,0,i,n),Ro(this.h,2,o,a),Ro(this.h,4,s,h),Ro(this.h,6,u,l),Ro(this.h,8,c,d),Ro(this.h,10,f,m),Ro(this.h,12,p,g),Ro(this.h,14,y,w)},Vo.prototype._digest=function(t){return"hex"===t?Zn.toHex32(this.h,"big"):Zn.split32(this.h,"big")},Zn.inherits(na,Ho);var oa=na;na.blockSize=1024,na.outSize=384,na.hmacStrength=192,na.padLength=128,na.prototype._digest=function(t){return"hex"===t?Zn.toHex32(this.h.slice(0,12),"big"):Zn.split32(this.h.slice(0,12),"big")};var aa={sha1:po,sha224:Io,sha256:So,sha384:oa,sha512:Ho},sa=Zn.rotl32,ha=Zn.sum32,ua=Zn.sum32_3,la=Zn.sum32_4,ca=Wn.BlockHash;function da(){if(!(this instanceof da))return new da;ca.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.endian="little"}Zn.inherits(da,ca);var fa=da;function ma(t,e,r,i){return t<=15?e^r^i:t<=31?e&r|~e&i:t<=47?(e|~r)^i:t<=63?e&i|r&~i:e^(r|~i)}function pa(t){return t<=15?0:t<=31?1518500249:t<=47?1859775393:t<=63?2400959708:2840853838}function ga(t){return t<=15?1352829926:t<=31?1548603684:t<=47?1836072691:t<=63?2053994217:0}da.blockSize=512,da.outSize=160,da.hmacStrength=192,da.padLength=64,da.prototype._update=function(t,e){for(var r=this.h[0],i=this.h[1],n=this.h[2],o=this.h[3],a=this.h[4],s=r,h=i,u=n,l=o,c=a,d=0;d<80;d++){var f=ha(sa(la(r,ma(d,i,n,o),t[ya[d]+e],pa(d)),va[d]),a);r=a,a=o,o=sa(n,10),n=i,i=f,f=ha(sa(la(s,ma(79-d,h,u,l),t[wa[d]+e],ga(d)),ba[d]),c),s=c,c=l,l=sa(u,10),u=h,h=f}f=ua(this.h[1],n,l),this.h[1]=ua(this.h[2],o,c),this.h[2]=ua(this.h[3],a,s),this.h[3]=ua(this.h[4],r,h),this.h[4]=ua(this.h[0],i,u),this.h[0]=f},da.prototype._digest=function(t){return"hex"===t?Zn.toHex32(this.h,"little"):Zn.split32(this.h,"little")};var ya=[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],wa=[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],va=[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],ba=[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],ka={ripemd160:fa};function Ma(t,e,r){if(!(this instanceof Ma))return new Ma(t,e,r);this.Hash=t,this.blockSize=t.blockSize/8,this.outSize=t.outSize/8,this.inner=null,this.outer=null,this._init(Zn.toArray(e,r))}var _a=Ma;Ma.prototype._init=function(t){t.length>this.blockSize&&(t=(new this.Hash).update(t).digest()),Fn(t.length<=this.blockSize);for(var e=t.length;e<this.blockSize;e++)t.push(0);for(e=0;e<t.length;e++)t[e]^=54;for(this.inner=(new this.Hash).update(t),e=0;e<t.length;e++)t[e]^=106;this.outer=(new this.Hash).update(t)},Ma.prototype.update=function(t,e){return this.inner.update(t,e),this},Ma.prototype.digest=function(t){return this.outer.update(this.inner.digest()),this.outer.digest(t)};var Ea=a((function(t,e){var r=e;r.utils=Zn,r.common=Wn,r.sha=aa,r.ripemd=ka,r.hmac=_a,r.sha1=r.sha.sha1,r.sha256=r.sha.sha256,r.sha224=r.sha.sha224,r.sha384=r.sha.sha384,r.sha512=r.sha.sha512,r.ripemd160=r.ripemd.ripemd160}));function Aa(t,e,r){return r={path:e,exports:{},require:function(t,e){return function(){throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs")}(null==e&&r.path)}},t(r,r.exports),r.exports}var ja=xa;function xa(t,e){if(!t)throw new Error(e||"Assertion failed")}xa.equal=function(t,e,r){if(t!=e)throw new Error(r||"Assertion failed: "+t+" != "+e)};var Sa=Aa((function(t,e){var r=e;function i(t){return 1===t.length?"0"+t:t}function n(t){for(var e="",r=0;r<t.length;r++)e+=i(t[r].toString(16));return e}r.toArray=function(t,e){if(Array.isArray(t))return t.slice();if(!t)return[];var r=[];if("string"!=typeof t){for(var i=0;i<t.length;i++)r[i]=0|t[i];return r}if("hex"===e){(t=t.replace(/[^a-z0-9]+/gi,"")).length%2!=0&&(t="0"+t);for(i=0;i<t.length;i+=2)r.push(parseInt(t[i]+t[i+1],16))}else for(i=0;i<t.length;i++){var n=t.charCodeAt(i),o=n>>8,a=255&n;o?r.push(o,a):r.push(a)}return r},r.zero2=i,r.toHex=n,r.encode=function(t,e){return"hex"===e?n(t):t}})),Na=Aa((function(t,e){var r=e;r.assert=ja,r.toArray=Sa.toArray,r.zero2=Sa.zero2,r.toHex=Sa.toHex,r.encode=Sa.encode,r.getNAF=function(t,e,r){var i=new Array(Math.max(t.bitLength(),r)+1);i.fill(0);for(var n=1<<e+1,o=t.clone(),a=0;a<i.length;a++){var s,h=o.andln(n-1);o.isOdd()?(s=h>(n>>1)-1?(n>>1)-h:h,o.isubn(s)):s=0,i[a]=s,o.iushrn(1)}return i},r.getJSF=function(t,e){var r=[[],[]];t=t.clone(),e=e.clone();for(var i,n=0,o=0;t.cmpn(-n)>0||e.cmpn(-o)>0;){var a,s,h=t.andln(3)+n&3,u=e.andln(3)+o&3;3===h&&(h=-1),3===u&&(u=-1),a=0==(1&h)?0:3!==(i=t.andln(7)+n&7)&&5!==i||2!==u?h:-h,r[0].push(a),s=0==(1&u)?0:3!==(i=e.andln(7)+o&7)&&5!==i||2!==h?u:-u,r[1].push(s),2*n===a+1&&(n=1-n),2*o===s+1&&(o=1-o),t.iushrn(1),e.iushrn(1)}return r},r.cachedProperty=function(t,e,r){var i="_"+e;t.prototype[e]=function(){return void 0!==this[i]?this[i]:this[i]=r.call(this)}},r.parseBytes=function(t){return"string"==typeof t?r.toArray(t,"hex"):t},r.intFromLE=function(t){return new Ln(t,"hex","le")}})),Ia=Na.getNAF,Ta=Na.getJSF,Ca=Na.assert;function za(t,e){this.type=t,this.p=new Ln(e.p,16),this.red=e.prime?Ln.red(e.prime):Ln.mont(this.p),this.zero=new Ln(0).toRed(this.red),this.one=new Ln(1).toRed(this.red),this.two=new Ln(2).toRed(this.red),this.n=e.n&&new Ln(e.n,16),this.g=e.g&&this.pointFromJSON(e.g,e.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 r=this.n&&this.p.div(this.n);!r||r.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}var Oa=za;function Ra(t,e){this.curve=t,this.type=e,this.precomputed=null}za.prototype.point=function(){throw new Error("Not implemented")},za.prototype.validate=function(){throw new Error("Not implemented")},za.prototype._fixedNafMul=function(t,e){Ca(t.precomputed);var r=t._getDoubles(),i=Ia(e,1,this._bitLength),n=(1<<r.step+1)-(r.step%2==0?2:1);n/=3;var o,a,s=[];for(o=0;o<i.length;o+=r.step){a=0;for(var h=o+r.step-1;h>=o;h--)a=(a<<1)+i[h];s.push(a)}for(var u=this.jpoint(null,null,null),l=this.jpoint(null,null,null),c=n;c>0;c--){for(o=0;o<s.length;o++)(a=s[o])===c?l=l.mixedAdd(r.points[o]):a===-c&&(l=l.mixedAdd(r.points[o].neg()));u=u.add(l)}return u.toP()},za.prototype._wnafMul=function(t,e){var r=4,i=t._getNAFPoints(r);r=i.wnd;for(var n=i.points,o=Ia(e,r,this._bitLength),a=this.jpoint(null,null,null),s=o.length-1;s>=0;s--){for(var h=0;s>=0&&0===o[s];s--)h++;if(s>=0&&h++,a=a.dblp(h),s<0)break;var u=o[s];Ca(0!==u),a="affine"===t.type?u>0?a.mixedAdd(n[u-1>>1]):a.mixedAdd(n[-u-1>>1].neg()):u>0?a.add(n[u-1>>1]):a.add(n[-u-1>>1].neg())}return"affine"===t.type?a.toP():a},za.prototype._wnafMulAdd=function(t,e,r,i,n){var o,a,s,h=this._wnafT1,u=this._wnafT2,l=this._wnafT3,c=0;for(o=0;o<i;o++){var d=(s=e[o])._getNAFPoints(t);h[o]=d.wnd,u[o]=d.points}for(o=i-1;o>=1;o-=2){var f=o-1,m=o;if(1===h[f]&&1===h[m]){var p=[e[f],null,null,e[m]];0===e[f].y.cmp(e[m].y)?(p[1]=e[f].add(e[m]),p[2]=e[f].toJ().mixedAdd(e[m].neg())):0===e[f].y.cmp(e[m].y.redNeg())?(p[1]=e[f].toJ().mixedAdd(e[m]),p[2]=e[f].add(e[m].neg())):(p[1]=e[f].toJ().mixedAdd(e[m]),p[2]=e[f].toJ().mixedAdd(e[m].neg()));var g=[-3,-1,-5,-7,0,7,5,1,3],y=Ta(r[f],r[m]);for(c=Math.max(y[0].length,c),l[f]=new Array(c),l[m]=new Array(c),a=0;a<c;a++){var w=0|y[0][a],v=0|y[1][a];l[f][a]=g[3*(w+1)+(v+1)],l[m][a]=0,u[f]=p}}else l[f]=Ia(r[f],h[f],this._bitLength),l[m]=Ia(r[m],h[m],this._bitLength),c=Math.max(l[f].length,c),c=Math.max(l[m].length,c)}var b=this.jpoint(null,null,null),k=this._wnafT4;for(o=c;o>=0;o--){for(var M=0;o>=0;){var _=!0;for(a=0;a<i;a++)k[a]=0|l[a][o],0!==k[a]&&(_=!1);if(!_)break;M++,o--}if(o>=0&&M++,b=b.dblp(M),o<0)break;for(a=0;a<i;a++){var E=k[a];0!==E&&(E>0?s=u[a][E-1>>1]:E<0&&(s=u[a][-E-1>>1].neg()),b="affine"===s.type?b.mixedAdd(s):b.add(s))}}for(o=0;o<i;o++)u[o]=null;return n?b:b.toP()},za.BasePoint=Ra,Ra.prototype.eq=function(){throw new Error("Not implemented")},Ra.prototype.validate=function(){return this.curve.validate(this)},za.prototype.decodePoint=function(t,e){t=Na.toArray(t,e);var r=this.p.byteLength();if((4===t[0]||6===t[0]||7===t[0])&&t.length-1==2*r)return 6===t[0]?Ca(t[t.length-1]%2==0):7===t[0]&&Ca(t[t.length-1]%2==1),this.point(t.slice(1,1+r),t.slice(1+r,1+2*r));if((2===t[0]||3===t[0])&&t.length-1===r)return this.pointFromX(t.slice(1,1+r),3===t[0]);throw new Error("Unknown point format")},Ra.prototype.encodeCompressed=function(t){return this.encode(t,!0)},Ra.prototype._encode=function(t){var e=this.curve.p.byteLength(),r=this.getX().toArray("be",e);return t?[this.getY().isEven()?2:3].concat(r):[4].concat(r,this.getY().toArray("be",e))},Ra.prototype.encode=function(t,e){return Na.encode(this._encode(e),t)},Ra.prototype.precompute=function(t){if(this.precomputed)return this;var e={doubles:null,naf:null,beta:null};return e.naf=this._getNAFPoints(8),e.doubles=this._getDoubles(4,t),e.beta=this._getBeta(),this.precomputed=e,this},Ra.prototype._hasDoubles=function(t){if(!this.precomputed)return!1;var e=this.precomputed.doubles;return!!e&&e.points.length>=Math.ceil((t.bitLength()+1)/e.step)},Ra.prototype._getDoubles=function(t,e){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var r=[this],i=this,n=0;n<e;n+=t){for(var o=0;o<t;o++)i=i.dbl();r.push(i)}return{step:t,points:r}},Ra.prototype._getNAFPoints=function(t){if(this.precomputed&&this.precomputed.naf)return this.precomputed.naf;for(var e=[this],r=(1<<t)-1,i=1===r?null:this.dbl(),n=1;n<r;n++)e[n]=e[n-1].add(i);return{wnd:t,points:e}},Ra.prototype._getBeta=function(){return null},Ra.prototype.dblp=function(t){for(var e=this,r=0;r<t;r++)e=e.dbl();return e};var Pa=Aa((function(t){"function"==typeof Object.create?t.exports=function(t,e){e&&(t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}))}:t.exports=function(t,e){if(e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}}})),Ba=Na.assert;function Da(t){Oa.call(this,"short",t),this.a=new Ln(t.a,16).toRed(this.red),this.b=new Ln(t.b,16).toRed(this.red),this.tinv=this.two.redInvm(),this.zeroA=0===this.a.fromRed().cmpn(0),this.threeA=0===this.a.fromRed().sub(this.p).cmpn(-3),this.endo=this._getEndomorphism(t),this._endoWnafT1=new Array(4),this._endoWnafT2=new Array(4)}Pa(Da,Oa);var $a=Da;function La(t,e,r,i){Oa.BasePoint.call(this,t,"affine"),null===e&&null===r?(this.x=null,this.y=null,this.inf=!0):(this.x=new Ln(e,16),this.y=new Ln(r,16),i&&(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)}function Fa(t,e,r,i){Oa.BasePoint.call(this,t,"jacobian"),null===e&&null===r&&null===i?(this.x=this.curve.one,this.y=this.curve.one,this.z=new Ln(0)):(this.x=new Ln(e,16),this.y=new Ln(r,16),this.z=new Ln(i,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}Da.prototype._getEndomorphism=function(t){if(this.zeroA&&this.g&&this.n&&1===this.p.modn(3)){var e,r;if(t.beta)e=new Ln(t.beta,16).toRed(this.red);else{var i=this._getEndoRoots(this.p);e=(e=i[0].cmp(i[1])<0?i[0]:i[1]).toRed(this.red)}if(t.lambda)r=new Ln(t.lambda,16);else{var n=this._getEndoRoots(this.n);0===this.g.mul(n[0]).x.cmp(this.g.x.redMul(e))?r=n[0]:(r=n[1],Ba(0===this.g.mul(r).x.cmp(this.g.x.redMul(e))))}return{beta:e,lambda:r,basis:t.basis?t.basis.map((function(t){return{a:new Ln(t.a,16),b:new Ln(t.b,16)}})):this._getEndoBasis(r)}}},Da.prototype._getEndoRoots=function(t){var e=t===this.p?this.red:Ln.mont(t),r=new Ln(2).toRed(e).redInvm(),i=r.redNeg(),n=new Ln(3).toRed(e).redNeg().redSqrt().redMul(r);return[i.redAdd(n).fromRed(),i.redSub(n).fromRed()]},Da.prototype._getEndoBasis=function(t){for(var e,r,i,n,o,a,s,h,u,l=this.n.ushrn(Math.floor(this.n.bitLength()/2)),c=t,d=this.n.clone(),f=new Ln(1),m=new Ln(0),p=new Ln(0),g=new Ln(1),y=0;0!==c.cmpn(0);){var w=d.div(c);h=d.sub(w.mul(c)),u=p.sub(w.mul(f));var v=g.sub(w.mul(m));if(!i&&h.cmp(l)<0)e=s.neg(),r=f,i=h.neg(),n=u;else if(i&&2==++y)break;s=h,d=c,c=h,p=f,f=u,g=m,m=v}o=h.neg(),a=u;var b=i.sqr().add(n.sqr());return o.sqr().add(a.sqr()).cmp(b)>=0&&(o=e,a=r),i.negative&&(i=i.neg(),n=n.neg()),o.negative&&(o=o.neg(),a=a.neg()),[{a:i,b:n},{a:o,b:a}]},Da.prototype._endoSplit=function(t){var e=this.endo.basis,r=e[0],i=e[1],n=i.b.mul(t).divRound(this.n),o=r.b.neg().mul(t).divRound(this.n),a=n.mul(r.a),s=o.mul(i.a),h=n.mul(r.b),u=o.mul(i.b);return{k1:t.sub(a).sub(s),k2:h.add(u).neg()}},Da.prototype.pointFromX=function(t,e){(t=new Ln(t,16)).red||(t=t.toRed(this.red));var r=t.redSqr().redMul(t).redIAdd(t.redMul(this.a)).redIAdd(this.b),i=r.redSqrt();if(0!==i.redSqr().redSub(r).cmp(this.zero))throw new Error("invalid point");var n=i.fromRed().isOdd();return(e&&!n||!e&&n)&&(i=i.redNeg()),this.point(t,i)},Da.prototype.validate=function(t){if(t.inf)return!0;var e=t.x,r=t.y,i=this.a.redMul(e),n=e.redSqr().redMul(e).redIAdd(i).redIAdd(this.b);return 0===r.redSqr().redISub(n).cmpn(0)},Da.prototype._endoWnafMulAdd=function(t,e,r){for(var i=this._endoWnafT1,n=this._endoWnafT2,o=0;o<t.length;o++){var a=this._endoSplit(e[o]),s=t[o],h=s._getBeta();a.k1.negative&&(a.k1.ineg(),s=s.neg(!0)),a.k2.negative&&(a.k2.ineg(),h=h.neg(!0)),i[2*o]=s,i[2*o+1]=h,n[2*o]=a.k1,n[2*o+1]=a.k2}for(var u=this._wnafMulAdd(1,i,n,2*o,r),l=0;l<2*o;l++)i[l]=null,n[l]=null;return u},Pa(La,Oa.BasePoint),Da.prototype.point=function(t,e,r){return new La(this,t,e,r)},Da.prototype.pointFromJSON=function(t,e){return La.fromJSON(this,t,e)},La.prototype._getBeta=function(){if(this.curve.endo){var t=this.precomputed;if(t&&t.beta)return t.beta;var e=this.curve.point(this.x.redMul(this.curve.endo.beta),this.y);if(t){var r=this.curve,i=function(t){return r.point(t.x.redMul(r.endo.beta),t.y)};t.beta=e,e.precomputed={beta:null,naf:t.naf&&{wnd:t.naf.wnd,points:t.naf.points.map(i)},doubles:t.doubles&&{step:t.doubles.step,points:t.doubles.points.map(i)}}}return e}},La.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]},La.fromJSON=function(t,e,r){"string"==typeof e&&(e=JSON.parse(e));var i=t.point(e[0],e[1],r);if(!e[2])return i;function n(e){return t.point(e[0],e[1],r)}var o=e[2];return i.precomputed={beta:null,doubles:o.doubles&&{step:o.doubles.step,points:[i].concat(o.doubles.points.map(n))},naf:o.naf&&{wnd:o.naf.wnd,points:[i].concat(o.naf.points.map(n))}},i},La.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)+">"},La.prototype.isInfinity=function(){return this.inf},La.prototype.add=function(t){if(this.inf)return t;if(t.inf)return this;if(this.eq(t))return this.dbl();if(this.neg().eq(t))return this.curve.point(null,null);if(0===this.x.cmp(t.x))return this.curve.point(null,null);var e=this.y.redSub(t.y);0!==e.cmpn(0)&&(e=e.redMul(this.x.redSub(t.x).redInvm()));var r=e.redSqr().redISub(this.x).redISub(t.x),i=e.redMul(this.x.redSub(r)).redISub(this.y);return this.curve.point(r,i)},La.prototype.dbl=function(){if(this.inf)return this;var t=this.y.redAdd(this.y);if(0===t.cmpn(0))return this.curve.point(null,null);var e=this.curve.a,r=this.x.redSqr(),i=t.redInvm(),n=r.redAdd(r).redIAdd(r).redIAdd(e).redMul(i),o=n.redSqr().redISub(this.x.redAdd(this.x)),a=n.redMul(this.x.redSub(o)).redISub(this.y);return this.curve.point(o,a)},La.prototype.getX=function(){return this.x.fromRed()},La.prototype.getY=function(){return this.y.fromRed()},La.prototype.mul=function(t){return t=new Ln(t,16),this.isInfinity()?this:this._hasDoubles(t)?this.curve._fixedNafMul(this,t):this.curve.endo?this.curve._endoWnafMulAdd([this],[t]):this.curve._wnafMul(this,t)},La.prototype.mulAdd=function(t,e,r){var i=[this,e],n=[t,r];return this.curve.endo?this.curve._endoWnafMulAdd(i,n):this.curve._wnafMulAdd(1,i,n,2)},La.prototype.jmulAdd=function(t,e,r){var i=[this,e],n=[t,r];return this.curve.endo?this.curve._endoWnafMulAdd(i,n,!0):this.curve._wnafMulAdd(1,i,n,2,!0)},La.prototype.eq=function(t){return this===t||this.inf===t.inf&&(this.inf||0===this.x.cmp(t.x)&&0===this.y.cmp(t.y))},La.prototype.neg=function(t){if(this.inf)return this;var e=this.curve.point(this.x,this.y.redNeg());if(t&&this.precomputed){var r=this.precomputed,i=function(t){return t.neg()};e.precomputed={naf:r.naf&&{wnd:r.naf.wnd,points:r.naf.points.map(i)},doubles:r.doubles&&{step:r.doubles.step,points:r.doubles.points.map(i)}}}return e},La.prototype.toJ=function(){return this.inf?this.curve.jpoint(null,null,null):this.curve.jpoint(this.x,this.y,this.curve.one)},Pa(Fa,Oa.BasePoint),Da.prototype.jpoint=function(t,e,r){return new Fa(this,t,e,r)},Fa.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var t=this.z.redInvm(),e=t.redSqr(),r=this.x.redMul(e),i=this.y.redMul(e).redMul(t);return this.curve.point(r,i)},Fa.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},Fa.prototype.add=function(t){if(this.isInfinity())return t;if(t.isInfinity())return this;var e=t.z.redSqr(),r=this.z.redSqr(),i=this.x.redMul(e),n=t.x.redMul(r),o=this.y.redMul(e.redMul(t.z)),a=t.y.redMul(r.redMul(this.z)),s=i.redSub(n),h=o.redSub(a);if(0===s.cmpn(0))return 0!==h.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var u=s.redSqr(),l=u.redMul(s),c=i.redMul(u),d=h.redSqr().redIAdd(l).redISub(c).redISub(c),f=h.redMul(c.redISub(d)).redISub(o.redMul(l)),m=this.z.redMul(t.z).redMul(s);return this.curve.jpoint(d,f,m)},Fa.prototype.mixedAdd=function(t){if(this.isInfinity())return t.toJ();if(t.isInfinity())return this;var e=this.z.redSqr(),r=this.x,i=t.x.redMul(e),n=this.y,o=t.y.redMul(e).redMul(this.z),a=r.redSub(i),s=n.redSub(o);if(0===a.cmpn(0))return 0!==s.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var h=a.redSqr(),u=h.redMul(a),l=r.redMul(h),c=s.redSqr().redIAdd(u).redISub(l).redISub(l),d=s.redMul(l.redISub(c)).redISub(n.redMul(u)),f=this.z.redMul(a);return this.curve.jpoint(c,d,f)},Fa.prototype.dblp=function(t){if(0===t)return this;if(this.isInfinity())return this;if(!t)return this.dbl();var e;if(this.curve.zeroA||this.curve.threeA){var r=this;for(e=0;e<t;e++)r=r.dbl();return r}var i=this.curve.a,n=this.curve.tinv,o=this.x,a=this.y,s=this.z,h=s.redSqr().redSqr(),u=a.redAdd(a);for(e=0;e<t;e++){var l=o.redSqr(),c=u.redSqr(),d=c.redSqr(),f=l.redAdd(l).redIAdd(l).redIAdd(i.redMul(h)),m=o.redMul(c),p=f.redSqr().redISub(m.redAdd(m)),g=m.redISub(p),y=f.redMul(g);y=y.redIAdd(y).redISub(d);var w=u.redMul(s);e+1<t&&(h=h.redMul(d)),o=p,s=w,u=y}return this.curve.jpoint(o,u.redMul(n),s)},Fa.prototype.dbl=function(){return this.isInfinity()?this:this.curve.zeroA?this._zeroDbl():this.curve.threeA?this._threeDbl():this._dbl()},Fa.prototype._zeroDbl=function(){var t,e,r;if(this.zOne){var i=this.x.redSqr(),n=this.y.redSqr(),o=n.redSqr(),a=this.x.redAdd(n).redSqr().redISub(i).redISub(o);a=a.redIAdd(a);var s=i.redAdd(i).redIAdd(i),h=s.redSqr().redISub(a).redISub(a),u=o.redIAdd(o);u=(u=u.redIAdd(u)).redIAdd(u),t=h,e=s.redMul(a.redISub(h)).redISub(u),r=this.y.redAdd(this.y)}else{var l=this.x.redSqr(),c=this.y.redSqr(),d=c.redSqr(),f=this.x.redAdd(c).redSqr().redISub(l).redISub(d);f=f.redIAdd(f);var m=l.redAdd(l).redIAdd(l),p=m.redSqr(),g=d.redIAdd(d);g=(g=g.redIAdd(g)).redIAdd(g),t=p.redISub(f).redISub(f),e=m.redMul(f.redISub(t)).redISub(g),r=(r=this.y.redMul(this.z)).redIAdd(r)}return this.curve.jpoint(t,e,r)},Fa.prototype._threeDbl=function(){var t,e,r;if(this.zOne){var i=this.x.redSqr(),n=this.y.redSqr(),o=n.redSqr(),a=this.x.redAdd(n).redSqr().redISub(i).redISub(o);a=a.redIAdd(a);var s=i.redAdd(i).redIAdd(i).redIAdd(this.curve.a),h=s.redSqr().redISub(a).redISub(a);t=h;var u=o.redIAdd(o);u=(u=u.redIAdd(u)).redIAdd(u),e=s.redMul(a.redISub(h)).redISub(u),r=this.y.redAdd(this.y)}else{var l=this.z.redSqr(),c=this.y.redSqr(),d=this.x.redMul(c),f=this.x.redSub(l).redMul(this.x.redAdd(l));f=f.redAdd(f).redIAdd(f);var m=d.redIAdd(d),p=(m=m.redIAdd(m)).redAdd(m);t=f.redSqr().redISub(p),r=this.y.redAdd(this.z).redSqr().redISub(c).redISub(l);var g=c.redSqr();g=(g=(g=g.redIAdd(g)).redIAdd(g)).redIAdd(g),e=f.redMul(m.redISub(t)).redISub(g)}return this.curve.jpoint(t,e,r)},Fa.prototype._dbl=function(){var t=this.curve.a,e=this.x,r=this.y,i=this.z,n=i.redSqr().redSqr(),o=e.redSqr(),a=r.redSqr(),s=o.redAdd(o).redIAdd(o).redIAdd(t.redMul(n)),h=e.redAdd(e),u=(h=h.redIAdd(h)).redMul(a),l=s.redSqr().redISub(u.redAdd(u)),c=u.redISub(l),d=a.redSqr();d=(d=(d=d.redIAdd(d)).redIAdd(d)).redIAdd(d);var f=s.redMul(c).redISub(d),m=r.redAdd(r).redMul(i);return this.curve.jpoint(l,f,m)},Fa.prototype.trpl=function(){if(!this.curve.zeroA)return this.dbl().add(this);var t=this.x.redSqr(),e=this.y.redSqr(),r=this.z.redSqr(),i=e.redSqr(),n=t.redAdd(t).redIAdd(t),o=n.redSqr(),a=this.x.redAdd(e).redSqr().redISub(t).redISub(i),s=(a=(a=(a=a.redIAdd(a)).redAdd(a).redIAdd(a)).redISub(o)).redSqr(),h=i.redIAdd(i);h=(h=(h=h.redIAdd(h)).redIAdd(h)).redIAdd(h);var u=n.redIAdd(a).redSqr().redISub(o).redISub(s).redISub(h),l=e.redMul(u);l=(l=l.redIAdd(l)).redIAdd(l);var c=this.x.redMul(s).redISub(l);c=(c=c.redIAdd(c)).redIAdd(c);var d=this.y.redMul(u.redMul(h.redISub(u)).redISub(a.redMul(s)));d=(d=(d=d.redIAdd(d)).redIAdd(d)).redIAdd(d);var f=this.z.redAdd(a).redSqr().redISub(r).redISub(s);return this.curve.jpoint(c,d,f)},Fa.prototype.mul=function(t,e){return t=new Ln(t,e),this.curve._wnafMul(this,t)},Fa.prototype.eq=function(t){if("affine"===t.type)return this.eq(t.toJ());if(this===t)return!0;var e=this.z.redSqr(),r=t.z.redSqr();if(0!==this.x.redMul(r).redISub(t.x.redMul(e)).cmpn(0))return!1;var i=e.redMul(this.z),n=r.redMul(t.z);return 0===this.y.redMul(n).redISub(t.y.redMul(i)).cmpn(0)},Fa.prototype.eqXToP=function(t){var e=this.z.redSqr(),r=t.toRed(this.curve.red).redMul(e);if(0===this.x.cmp(r))return!0;for(var i=t.clone(),n=this.curve.redN.redMul(e);;){if(i.iadd(this.curve.n),i.cmp(this.curve.p)>=0)return!1;if(r.redIAdd(n),0===this.x.cmp(r))return!0}},Fa.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)+">"},Fa.prototype.isInfinity=function(){return 0===this.z.cmpn(0)};var Ua=Aa((function(t,e){var r=e;r.base=Oa,r.short=$a,r.mont=null,r.edwards=null})),qa=Aa((function(t,e){var r,i=e,n=Na.assert;function o(t){"short"===t.type?this.curve=new Ua.short(t):"edwards"===t.type?this.curve=new Ua.edwards(t):this.curve=new Ua.mont(t),this.g=this.curve.g,this.n=this.curve.n,this.hash=t.hash,n(this.g.validate(),"Invalid curve"),n(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}function a(t,e){Object.defineProperty(i,t,{configurable:!0,enumerable:!0,get:function(){var r=new o(e);return Object.defineProperty(i,t,{configurable:!0,enumerable:!0,value:r}),r}})}i.PresetCurve=o,a("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:Ea.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]}),a("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:Ea.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]}),a("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:Ea.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]}),a("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:Ea.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"]}),a("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:Ea.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"]}),a("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:Ea.sha256,gRed:!1,g:["9"]}),a("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:Ea.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});try{r=null.crash()}catch(t){r=void 0}a("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:Ea.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",r]})}));function Va(t){if(!(this instanceof Va))return new Va(t);this.hash=t.hash,this.predResist=!!t.predResist,this.outLen=this.hash.outSize,this.minEntropy=t.minEntropy||this.hash.hmacStrength,this._reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var e=Sa.toArray(t.entropy,t.entropyEnc||"hex"),r=Sa.toArray(t.nonce,t.nonceEnc||"hex"),i=Sa.toArray(t.pers,t.persEnc||"hex");ja(e.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(e,r,i)}var Ha=Va;Va.prototype._init=function(t,e,r){var i=t.concat(e).concat(r);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var n=0;n<this.V.length;n++)this.K[n]=0,this.V[n]=1;this._update(i),this._reseed=1,this.reseedInterval=281474976710656},Va.prototype._hmac=function(){return new Ea.hmac(this.hash,this.K)},Va.prototype._update=function(t){var e=this._hmac().update(this.V).update([0]);t&&(e=e.update(t)),this.K=e.digest(),this.V=this._hmac().update(this.V).digest(),t&&(this.K=this._hmac().update(this.V).update([1]).update(t).digest(),this.V=this._hmac().update(this.V).digest())},Va.prototype.reseed=function(t,e,r,i){"string"!=typeof e&&(i=r,r=e,e=null),t=Sa.toArray(t,e),r=Sa.toArray(r,i),ja(t.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(t.concat(r||[])),this._reseed=1},Va.prototype.generate=function(t,e,r,i){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");"string"!=typeof e&&(i=r,r=e,e=null),r&&(r=Sa.toArray(r,i||"hex"),this._update(r));for(var n=[];n.length<t;)this.V=this._hmac().update(this.V).digest(),n=n.concat(this.V);var o=n.slice(0,t);return this._update(r),this._reseed++,Sa.encode(o,e)};var Ga=Na.assert;function Za(t,e){this.ec=t,this.priv=null,this.pub=null,e.priv&&this._importPrivate(e.priv,e.privEnc),e.pub&&this._importPublic(e.pub,e.pubEnc)}var Ka=Za;Za.fromPublic=function(t,e,r){return e instanceof Za?e:new Za(t,{pub:e,pubEnc:r})},Za.fromPrivate=function(t,e,r){return e instanceof Za?e:new Za(t,{priv:e,privEnc:r})},Za.prototype.validate=function(){var t=this.getPublic();return t.isInfinity()?{result:!1,reason:"Invalid public key"}:t.validate()?t.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"}},Za.prototype.getPublic=function(t,e){return"string"==typeof t&&(e=t,t=null),this.pub||(this.pub=this.ec.g.mul(this.priv)),e?this.pub.encode(e,t):this.pub},Za.prototype.getPrivate=function(t){return"hex"===t?this.priv.toString(16,2):this.priv},Za.prototype._importPrivate=function(t,e){this.priv=new Ln(t,e||16),this.priv=this.priv.umod(this.ec.curve.n)},Za.prototype._importPublic=function(t,e){if(t.x||t.y)return"mont"===this.ec.curve.type?Ga(t.x,"Need x coordinate"):"short"!==this.ec.curve.type&&"edwards"!==this.ec.curve.type||Ga(t.x&&t.y,"Need both x and y coordinate"),void(this.pub=this.ec.curve.point(t.x,t.y));this.pub=this.ec.curve.decodePoint(t,e)},Za.prototype.derive=function(t){return t.validate()||Ga(t.validate(),"public point not validated"),t.mul(this.priv).getX()},Za.prototype.sign=function(t,e,r){return this.ec.sign(t,this,e,r)},Za.prototype.verify=function(t,e){return this.ec.verify(t,e,this)},Za.prototype.inspect=function(){return"<Key priv: "+(this.priv&&this.priv.toString(16,2))+" pub: "+(this.pub&&this.pub.inspect())+" >"};var Ja=Na.assert;function Wa(t,e){if(t instanceof Wa)return t;this._importDER(t,e)||(Ja(t.r&&t.s,"Signature without r or s"),this.r=new Ln(t.r,16),this.s=new Ln(t.s,16),void 0===t.recoveryParam?this.recoveryParam=null:this.recoveryParam=t.recoveryParam)}var Ya=Wa;function Qa(){this.place=0}function Xa(t,e){var r=t[e.place++];if(!(128&r))return r;var i=15&r;if(0===i||i>4)return!1;for(var n=0,o=0,a=e.place;o<i;o++,a++)n<<=8,n|=t[a],n>>>=0;return!(n<=127)&&(e.place=a,n)}function ts(t){for(var e=0,r=t.length-1;!t[e]&&!(128&t[e+1])&&e<r;)e++;return 0===e?t:t.slice(e)}function es(t,e){if(e<128)t.push(e);else{var r=1+(Math.log(e)/Math.LN2>>>3);for(t.push(128|r);--r;)t.push(e>>>(r<<3)&255);t.push(e)}}Wa.prototype._importDER=function(t,e){t=Na.toArray(t,e);var r=new Qa;if(48!==t[r.place++])return!1;var i=Xa(t,r);if(!1===i)return!1;if(i+r.place!==t.length)return!1;if(2!==t[r.place++])return!1;var n=Xa(t,r);if(!1===n)return!1;var o=t.slice(r.place,n+r.place);if(r.place+=n,2!==t[r.place++])return!1;var a=Xa(t,r);if(!1===a)return!1;if(t.length!==a+r.place)return!1;var s=t.slice(r.place,a+r.place);if(0===o[0]){if(!(128&o[1]))return!1;o=o.slice(1)}if(0===s[0]){if(!(128&s[1]))return!1;s=s.slice(1)}return this.r=new Ln(o),this.s=new Ln(s),this.recoveryParam=null,!0},Wa.prototype.toDER=function(t){var e=this.r.toArray(),r=this.s.toArray();for(128&e[0]&&(e=[0].concat(e)),128&r[0]&&(r=[0].concat(r)),e=ts(e),r=ts(r);!(r[0]||128&r[1]);)r=r.slice(1);var i=[2];es(i,e.length),(i=i.concat(e)).push(2),es(i,r.length);var n=i.concat(r),o=[48];return es(o,n.length),o=o.concat(n),Na.encode(o,t)};var rs=function(){throw new Error("unsupported")},is=Na.assert;function ns(t){if(!(this instanceof ns))return new ns(t);"string"==typeof t&&(is(Object.prototype.hasOwnProperty.call(qa,t),"Unknown curve "+t),t=qa[t]),t instanceof qa.PresetCurve&&(t={curve:t}),this.curve=t.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=t.curve.g,this.g.precompute(t.curve.n.bitLength()+1),this.hash=t.hash||t.curve.hash}var os=ns;ns.prototype.keyPair=function(t){return new Ka(this,t)},ns.prototype.keyFromPrivate=function(t,e){return Ka.fromPrivate(this,t,e)},ns.prototype.keyFromPublic=function(t,e){return Ka.fromPublic(this,t,e)},ns.prototype.genKeyPair=function(t){t||(t={});for(var e=new Ha({hash:this.hash,pers:t.pers,persEnc:t.persEnc||"utf8",entropy:t.entropy||rs(this.hash.hmacStrength),entropyEnc:t.entropy&&t.entropyEnc||"utf8",nonce:this.n.toArray()}),r=this.n.byteLength(),i=this.n.sub(new Ln(2));;){var n=new Ln(e.generate(r));if(!(n.cmp(i)>0))return n.iaddn(1),this.keyFromPrivate(n)}},ns.prototype._truncateToN=function(t,e){var r=8*t.byteLength()-this.n.bitLength();return r>0&&(t=t.ushrn(r)),!e&&t.cmp(this.n)>=0?t.sub(this.n):t},ns.prototype.sign=function(t,e,r,i){"object"==typeof r&&(i=r,r=null),i||(i={}),e=this.keyFromPrivate(e,r),t=this._truncateToN(new Ln(t,16));for(var n=this.n.byteLength(),o=e.getPrivate().toArray("be",n),a=t.toArray("be",n),s=new Ha({hash:this.hash,entropy:o,nonce:a,pers:i.pers,persEnc:i.persEnc||"utf8"}),h=this.n.sub(new Ln(1)),u=0;;u++){var l=i.k?i.k(u):new Ln(s.generate(this.n.byteLength()));if(!((l=this._truncateToN(l,!0)).cmpn(1)<=0||l.cmp(h)>=0)){var c=this.g.mul(l);if(!c.isInfinity()){var d=c.getX(),f=d.umod(this.n);if(0!==f.cmpn(0)){var m=l.invm(this.n).mul(f.mul(e.getPrivate()).iadd(t));if(0!==(m=m.umod(this.n)).cmpn(0)){var p=(c.getY().isOdd()?1:0)|(0!==d.cmp(f)?2:0);return i.canonical&&m.cmp(this.nh)>0&&(m=this.n.sub(m),p^=1),new Ya({r:f,s:m,recoveryParam:p})}}}}}},ns.prototype.verify=function(t,e,r,i){t=this._truncateToN(new Ln(t,16)),r=this.keyFromPublic(r,i);var n=(e=new Ya(e,"hex")).r,o=e.s;if(n.cmpn(1)<0||n.cmp(this.n)>=0)return!1;if(o.cmpn(1)<0||o.cmp(this.n)>=0)return!1;var a,s=o.invm(this.n),h=s.mul(t).umod(this.n),u=s.mul(n).umod(this.n);return this.curve._maxwellTrick?!(a=this.g.jmulAdd(h,r.getPublic(),u)).isInfinity()&&a.eqXToP(n):!(a=this.g.mulAdd(h,r.getPublic(),u)).isInfinity()&&0===a.getX().umod(this.n).cmp(n)},ns.prototype.recoverPubKey=function(t,e,r,i){is((3&r)===r,"The recovery param is more than two bits"),e=new Ya(e,i);var n=this.n,o=new Ln(t),a=e.r,s=e.s,h=1&r,u=r>>1;if(a.cmp(this.curve.p.umod(this.curve.n))>=0&&u)throw new Error("Unable to find sencond key candinate");a=u?this.curve.pointFromX(a.add(this.curve.n),h):this.curve.pointFromX(a,h);var l=e.r.invm(n),c=n.sub(o).mul(l).umod(n),d=s.mul(l).umod(n);return this.g.mulAdd(c,a,d)},ns.prototype.getKeyRecoveryParam=function(t,e,r,i){if(null!==(e=new Ya(e,i)).recoveryParam)return e.recoveryParam;for(var n=0;n<4;n++){var o;try{o=this.recoverPubKey(t,e,n)}catch(t){continue}if(o.eq(r))return n}throw new Error("Unable to find valid recovery factor")};var as=Aa((function(t,e){var r=e;r.version="6.5.4",r.utils=Na,r.rand=function(){throw new Error("unsupported")},r.curve=Ua,r.curves=qa,r.ec=os,r.eddsa=null})).ec;const ss=new w("signing-key/5.6.2");let hs=null;function us(){return hs||(hs=new as("secp256k1")),hs}class ls{constructor(t){ir(this,"curve","secp256k1"),ir(this,"privateKey",I(t)),32!==T(this.privateKey)&&ss.throwArgumentError("invalid private key","privateKey","[[ REDACTED ]]");const e=us().keyFromPrivate(A(this.privateKey));ir(this,"publicKey","0x"+e.getPublic(!1,"hex")),ir(this,"compressedPublicKey","0x"+e.getPublic(!0,"hex")),ir(this,"_isSigningKey",!0)}_addPoint(t){const e=us().keyFromPublic(A(this.publicKey)),r=us().keyFromPublic(A(t));return"0x"+e.pub.add(r.pub).encodeCompressed("hex")}signDigest(t){const e=us().keyFromPrivate(A(this.privateKey)),r=A(t);32!==r.length&&ss.throwArgumentError("bad digest length","digest",t);const i=e.sign(r,{canonical:!0});return P({recoveryParam:i.recoveryParam,r:R("0x"+i.r.toString(16),32),s:R("0x"+i.s.toString(16),32)})}computeSharedSecret(t){const e=us().keyFromPrivate(A(this.privateKey)),r=us().keyFromPublic(A(cs(t)));return R("0x"+e.derive(r.getPublic()).toString(16),32)}static isSigningKey(t){return!(!t||!t._isSigningKey)}}function cs(t,e){const r=A(t);if(32===r.length){const t=new ls(r);return e?"0x"+us().keyFromPrivate(r).getPublic(!0,"hex"):t.publicKey}return 33===r.length?e?I(r):"0x"+us().keyFromPublic(r).getPublic(!1,"hex"):65===r.length?e?"0x"+us().keyFromPublic(r).getPublic(!0,"hex"):I(r):ss.throwArgumentError("invalid public or private key","key","[REDACTED]")}const ds=new w("transactions/5.6.2");var fs;function ms(t){return"0x"===t?null:he(t)}function ps(t){return"0x"===t?ui:Rn.from(t)}function gs(t,e){return function(t){return he(C(Jt(C(cs(t),1)),12))}(function(t,e){const r=P(e),i={r:A(r.r),s:A(r.s)};return"0x"+us().recoverPubKey(A(t),i,r.recoveryParam).encode("hex",!1)}(A(t),e))}function ys(t,e){const r=x(Rn.from(t).toHexString());return r.length>32&&ds.throwArgumentError("invalid length for "+e,"transaction:"+e,t),r}function ws(t,e){return{address:he(t),storageKeys:(e||[]).map(((e,r)=>(32!==T(e)&&ds.throwArgumentError("invalid access list storageKey",`accessList[${t}:${r}]`,e),e.toLowerCase())))}}function vs(t){if(Array.isArray(t))return t.map(((t,e)=>Array.isArray(t)?(t.length>2&&ds.throwArgumentError("access list expected to be [ address, storageKeys[] ]",`value[${e}]`,t),ws(t[0],t[1])):ws(t.address,t.storageKeys)));const e=Object.keys(t).map((e=>{const r=t[e].reduce(((t,e)=>(t[e]=!0,t)),{});return ws(e,Object.keys(r).sort())}));return e.sort(((t,e)=>t.address.localeCompare(e.address))),e}function bs(t){return vs(t).map((t=>[t.address,t.storageKeys]))}function ks(t,e){if(null!=t.gasPrice){const e=Rn.from(t.gasPrice),r=Rn.from(t.maxFeePerGas||0);e.eq(r)||ds.throwArgumentError("mismatch EIP-1559 gasPrice != maxFeePerGas","tx",{gasPrice:e,maxFeePerGas:r})}const r=[ys(t.chainId||0,"chainId"),ys(t.nonce||0,"nonce"),ys(t.maxPriorityFeePerGas||0,"maxPriorityFeePerGas"),ys(t.maxFeePerGas||0,"maxFeePerGas"),ys(t.gasLimit||0,"gasLimit"),null!=t.to?he(t.to):"0x",ys(t.value||0,"value"),t.data||"0x",bs(t.accessList||[])];if(e){const t=P(e);r.push(ys(t.recoveryParam,"recoveryParam")),r.push(x(t.r)),r.push(x(t.s))}return z(["0x02",te(r)])}function Ms(t,e){const r=[ys(t.chainId||0,"chainId"),ys(t.nonce||0,"nonce"),ys(t.gasPrice||0,"gasPrice"),ys(t.gasLimit||0,"gasLimit"),null!=t.to?he(t.to):"0x",ys(t.value||0,"value"),t.data||"0x",bs(t.accessList||[])];if(e){const t=P(e);r.push(ys(t.recoveryParam,"recoveryParam")),r.push(x(t.r)),r.push(x(t.s))}return z(["0x01",te(r)])}function _s(t,e,r){try{const r=ps(e[0]).toNumber();if(0!==r&&1!==r)throw new Error("bad recid");t.v=r}catch(t){ds.throwArgumentError("invalid v for transaction type: 1","v",e[0])}t.r=R(e[1],32),t.s=R(e[2],32);try{const e=Jt(r(t));t.from=gs(e,{r:t.r,s:t.s,recoveryParam:t.v})}catch(t){}}function Es(t){const e=A(t);if(e[0]>127)return function(t){const e=ie(t);9!==e.length&&6!==e.length&&ds.throwArgumentError("invalid raw transaction","rawTransaction",t);const r={nonce:ps(e[0]).toNumber(),gasPrice:ps(e[1]),gasLimit:ps(e[2]),to:ms(e[3]),value:ps(e[4]),data:e[5],chainId:0};if(6===e.length)return r;try{r.v=Rn.from(e[6]).toNumber()}catch(t){return r}if(r.r=R(e[7],32),r.s=R(e[8],32),Rn.from(r.r).isZero()&&Rn.from(r.s).isZero())r.chainId=r.v,r.v=0;else{r.chainId=Math.floor((r.v-35)/2),r.chainId<0&&(r.chainId=0);let i=r.v-27;const n=e.slice(0,6);0!==r.chainId&&(n.push(I(r.chainId)),n.push("0x"),n.push("0x"),i-=2*r.chainId+8);const o=Jt(te(n));try{r.from=gs(o,{r:I(r.r),s:I(r.s),recoveryParam:i})}catch(t){}r.hash=Jt(t)}return r.type=null,r}(e);switch(e[0]){case 1:return function(t){const e=ie(t.slice(1));8!==e.length&&11!==e.length&&ds.throwArgumentError("invalid component count for transaction type: 1","payload",I(t));const r={type:1,chainId:ps(e[0]).toNumber(),nonce:ps(e[1]).toNumber(),gasPrice:ps(e[2]),gasLimit:ps(e[3]),to:ms(e[4]),value:ps(e[5]),data:e[6],accessList:vs(e[7])};return 8===e.length||(r.hash=Jt(t),_s(r,e.slice(8),Ms)),r}(e);case 2:return function(t){const e=ie(t.slice(1));9!==e.length&&12!==e.length&&ds.throwArgumentError("invalid component count for transaction type: 2","payload",I(t));const r=ps(e[2]),i=ps(e[3]),n={type:2,chainId:ps(e[0]).toNumber(),nonce:ps(e[1]).toNumber(),maxPriorityFeePerGas:r,maxFeePerGas:i,gasPrice:null,gasLimit:ps(e[4]),to:ms(e[5]),value:ps(e[6]),data:e[7],accessList:vs(e[8])};return 9===e.length||(n.hash=Jt(t),_s(n,e.slice(9),ks)),n}(e)}return ds.throwError(`unsupported transaction type: ${e[0]}`,w.errors.UNSUPPORTED_OPERATION,{operation:"parseTransaction",transactionType:e[0]})}!function(t){t[t.legacy=0]="legacy",t[t.eip2930=1]="eip2930",t[t.eip1559=2]="eip1559"}(fs||(fs={}));var As=window&&window.__awaiter||function(t,e,r,i){return new(r||(r=Promise))((function(n,o){function a(t){try{h(i.next(t))}catch(t){o(t)}}function s(t){try{h(i.throw(t))}catch(t){o(t)}}function h(t){var e;t.done?n(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(a,s)}h((i=i.apply(t,e||[])).next())}))};const js=new w("contracts/5.6.2");function xs(t,e){return As(this,void 0,void 0,(function*(){const r=yield e;"string"!=typeof r&&js.throwArgumentError("invalid address or ENS name","name",r);try{return he(r)}catch(t){}t||js.throwError("a provider or signer is needed to resolve ENS names",w.errors.UNSUPPORTED_OPERATION,{operation:"resolveName"});const i=yield t.resolveName(r);return null==i&&js.throwArgumentError("resolver or addr is not configured for ENS name","name",r),i}))}function Ss(t,e,r){return As(this,void 0,void 0,(function*(){return Array.isArray(r)?yield Promise.all(r.map(((r,i)=>Ss(t,Array.isArray(e)?e[i]:e[r.name],r)))):"address"===r.type?yield xs(t,e):"tuple"===r.type?yield Ss(t,e,r.components):"array"===r.baseType?Array.isArray(e)?yield Promise.all(e.map((e=>Ss(t,e,r.arrayChildren)))):Promise.reject(js.makeError("invalid value for array",w.errors.INVALID_ARGUMENT,{argument:"value",value:e})):e}))}function Ns(t,e,r){return As(this,void 0,void 0,(function*(){let i={};r.length===e.inputs.length+1&&"object"==typeof r[r.length-1]&&(i=ar(r.pop())),js.checkArgumentCount(r.length,e.inputs.length,"passed to contract"),t.signer?i.from?i.from=or({override:xs(t.signer,i.from),signer:t.signer.getAddress()}).then((t=>As(this,void 0,void 0,(function*(){return he(t.signer)!==t.override&&js.throwError("Contract with a Signer cannot override from",w.errors.UNSUPPORTED_OPERATION,{operation:"overrides.from"}),t.override})))):i.from=t.signer.getAddress():i.from&&(i.from=xs(t.provider,i.from));const n=yield or({args:Ss(t.signer||t.provider,r,e.inputs),address:t.resolvedAddress,overrides:or(i)||{}}),o=t.interface.encodeFunctionData(e,n.args),a={data:o,to:n.address},s=n.overrides;if(null!=s.nonce&&(a.nonce=En.from(s.nonce).toNumber()),null!=s.gasLimit&&(a.gasLimit=En.from(s.gasLimit)),null!=s.gasPrice&&(a.gasPrice=En.from(s.gasPrice)),null!=s.maxFeePerGas&&(a.maxFeePerGas=En.from(s.maxFeePerGas)),null!=s.maxPriorityFeePerGas&&(a.maxPriorityFeePerGas=En.from(s.maxPriorityFeePerGas)),null!=s.from&&(a.from=s.from),null!=s.type&&(a.type=s.type),null!=s.accessList&&(a.accessList=vs(s.accessList)),null==a.gasLimit&&null!=e.gas){let t=21e3;const r=A(o);for(let e=0;e<r.length;e++)t+=4,r[e]&&(t+=64);a.gasLimit=En.from(e.gas).add(t)}if(s.value){const t=En.from(s.value);t.isZero()||e.payable||js.throwError("non-payable method cannot override value",w.errors.UNSUPPORTED_OPERATION,{operation:"overrides.value",value:i.value}),a.value=t}s.customData&&(a.customData=ar(s.customData)),s.ccipReadEnabled&&(a.ccipReadEnabled=!!s.ccipReadEnabled),delete i.nonce,delete i.gasLimit,delete i.gasPrice,delete i.from,delete i.value,delete i.type,delete i.accessList,delete i.maxFeePerGas,delete i.maxPriorityFeePerGas,delete i.customData,delete i.ccipReadEnabled;const h=Object.keys(i).filter((t=>null!=i[t]));return h.length&&js.throwError(`cannot override ${h.map((t=>JSON.stringify(t))).join(",")}`,w.errors.UNSUPPORTED_OPERATION,{operation:"overrides",overrides:h}),a}))}function Is(t,e,r){const i=t.signer||t.provider;return function(...n){return As(this,void 0,void 0,(function*(){let o;if(n.length===e.inputs.length+1&&"object"==typeof n[n.length-1]){const t=ar(n.pop());null!=t.blockTag&&(o=yield t.blockTag),delete t.blockTag,n.push(t)}null!=t.deployTransaction&&(yield t._deployed(o));const a=yield Ns(t,e,n),s=yield i.call(a,o);try{let i=t.interface.decodeFunctionResult(e,s);return r&&1===e.outputs.length&&(i=i[0]),i}catch(e){throw e.code===w.errors.CALL_EXCEPTION&&(e.address=t.address,e.args=n,e.transaction=a),e}}))}}function Ts(t,e){return function(...r){return As(this,void 0,void 0,(function*(){t.signer||js.throwError("sending a transaction requires a signer",w.errors.UNSUPPORTED_OPERATION,{operation:"sendTransaction"}),null!=t.deployTransaction&&(yield t._deployed());const i=yield Ns(t,e,r),n=yield t.signer.sendTransaction(i);return function(t,e){const r=e.wait.bind(e);e.wait=e=>r(e).then((e=>(e.events=e.logs.map((r=>{let i=lr(r),n=null;try{n=t.interface.parseLog(r)}catch(t){}return n&&(i.args=n.args,i.decode=(e,r)=>t.interface.decodeEventLog(n.eventFragment,e,r),i.event=n.name,i.eventSignature=n.signature),i.removeListener=()=>t.provider,i.getBlock=()=>t.provider.getBlock(e.blockHash),i.getTransaction=()=>t.provider.getTransaction(e.transactionHash),i.getTransactionReceipt=()=>Promise.resolve(e),i})),e)))}(t,n),n}))}}function Cs(t,e,r){return e.constant?Is(t,e,r):Ts(t,e)}function zs(t){return!t.address||null!=t.topics&&0!==t.topics.length?(t.address||"*")+"@"+(t.topics?t.topics.map((t=>Array.isArray(t)?t.join("|"):t)).join(":"):""):"*"}class Os{constructor(t,e){ir(this,"tag",t),ir(this,"filter",e),this._listeners=[]}addListener(t,e){this._listeners.push({listener:t,once:e})}removeListener(t){let e=!1;this._listeners=this._listeners.filter((r=>!(!e&&r.listener===t)||(e=!0,!1)))}removeAllListeners(){this._listeners=[]}listeners(){return this._listeners.map((t=>t.listener))}listenerCount(){return this._listeners.length}run(t){const e=this.listenerCount();return this._listeners=this._listeners.filter((e=>{const r=t.slice();return setTimeout((()=>{e.listener.apply(this,r)}),0),!e.once})),e}prepareEvent(t){}getEmit(t){return[t]}}class Rs extends Os{constructor(){super("error",null)}}class Ps extends Os{constructor(t,e,r,i){const n={address:t};let o=e.getEventTopic(r);i?(o!==i[0]&&js.throwArgumentError("topic mismatch","topics",i),n.topics=i.slice()):n.topics=[o],super(zs(n),n),ir(this,"address",t),ir(this,"interface",e),ir(this,"fragment",r)}prepareEvent(t){super.prepareEvent(t),t.event=this.fragment.name,t.eventSignature=this.fragment.format(),t.decode=(t,e)=>this.interface.decodeEventLog(this.fragment,t,e);try{t.args=this.interface.decodeEventLog(this.fragment,t.data,t.topics)}catch(e){t.args=null,t.decodeError=e}}getEmit(t){const e=function(t){const e=[],r=function(t,i){if(Array.isArray(i))for(let n in i){const o=t.slice();o.push(n);try{r(o,i[n])}catch(t){e.push({path:o,error:t})}}};return r([],t),e}(t.args);if(e.length)throw e[0].error;const r=(t.args||[]).slice();return r.push(t),r}}class Bs extends Os{constructor(t,e){super("*",{address:t}),ir(this,"address",t),ir(this,"interface",e)}prepareEvent(t){super.prepareEvent(t);try{const e=this.interface.parseLog(t);t.event=e.name,t.eventSignature=e.signature,t.decode=(t,r)=>this.interface.decodeEventLog(e.eventFragment,t,r),t.args=e.args}catch(t){}}}class Ds extends class{constructor(t,e,r){ir(this,"interface",nr(new.target,"getInterface")(e)),null==r?(ir(this,"provider",null),ir(this,"signer",null)):gn.isSigner(r)?(ir(this,"provider",r.provider||null),ir(this,"signer",r)):cn.isProvider(r)?(ir(this,"provider",r),ir(this,"signer",null)):js.throwArgumentError("invalid signer or provider","signerOrProvider",r),ir(this,"callStatic",{}),ir(this,"estimateGas",{}),ir(this,"functions",{}),ir(this,"populateTransaction",{}),ir(this,"filters",{});{const t={};Object.keys(this.interface.events).forEach((e=>{const r=this.interface.events[e];ir(this.filters,e,((...t)=>({address:this.address,topics:this.interface.encodeFilterTopics(r,t)}))),t[r.name]||(t[r.name]=[]),t[r.name].push(e)})),Object.keys(t).forEach((e=>{const r=t[e];1===r.length?ir(this.filters,e,this.filters[r[0]]):js.warn(`Duplicate definition of ${e} (${r.join(", ")})`)}))}if(ir(this,"_runningEvents",{}),ir(this,"_wrappedEmits",{}),null==t&&js.throwArgumentError("invalid contract address or ENS name","addressOrName",t),ir(this,"address",t),this.provider)ir(this,"resolvedAddress",xs(this.provider,t));else try{ir(this,"resolvedAddress",Promise.resolve(he(t)))}catch(t){js.throwError("provider is required to use ENS name as contract address",w.errors.UNSUPPORTED_OPERATION,{operation:"new Contract"})}this.resolvedAddress.catch((t=>{}));const i={},n={};Object.keys(this.interface.functions).forEach((t=>{const e=this.interface.functions[t];if(n[t])js.warn(`Duplicate ABI entry for ${JSON.stringify(t)}`);else{n[t]=!0;{const r=e.name;i[`%${r}`]||(i[`%${r}`]=[]),i[`%${r}`].push(t)}null==this[t]&&ir(this,t,Cs(this,e,!0)),null==this.functions[t]&&ir(this.functions,t,Cs(this,e,!1)),null==this.callStatic[t]&&ir(this.callStatic,t,Is(this,e,!0)),null==this.populateTransaction[t]&&ir(this.populateTransaction,t,function(t,e){return function(...r){return Ns(t,e,r)}}(this,e)),null==this.estimateGas[t]&&ir(this.estimateGas,t,function(t,e){const r=t.signer||t.provider;return function(...i){return As(this,void 0,void 0,(function*(){r||js.throwError("estimate require a provider or signer",w.errors.UNSUPPORTED_OPERATION,{operation:"estimateGas"});const n=yield Ns(t,e,i);return yield r.estimateGas(n)}))}}(this,e))}})),Object.keys(i).forEach((t=>{const e=i[t];if(e.length>1)return;t=t.substring(1);const r=e[0];try{null==this[t]&&ir(this,t,this[r])}catch(t){}null==this.functions[t]&&ir(this.functions,t,this.functions[r]),null==this.callStatic[t]&&ir(this.callStatic,t,this.callStatic[r]),null==this.populateTransaction[t]&&ir(this.populateTransaction,t,this.populateTransaction[r]),null==this.estimateGas[t]&&ir(this.estimateGas,t,this.estimateGas[r])}))}static getContractAddress(t){return le(t)}static getInterface(t){return Ji.isInterface(t)?t:new Ji(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((t=>("0x"===t&&js.throwError("contract not deployed",w.errors.UNSUPPORTED_OPERATION,{contractAddress:this.address,operation:"getDeployed"}),this)))),this._deployedPromise}fallback(t){this.signer||js.throwError("sending a transactions require a signer",w.errors.UNSUPPORTED_OPERATION,{operation:"sendTransaction(fallback)"});const e=ar(t||{});return["from","to"].forEach((function(t){null!=e[t]&&js.throwError("cannot override "+t,w.errors.UNSUPPORTED_OPERATION,{operation:t})})),e.to=this.resolvedAddress,this.deployed().then((()=>this.signer.sendTransaction(e)))}connect(t){"string"==typeof t&&(t=new yn(t,this.provider));const e=new this.constructor(this.address,this.interface,t);return this.deployTransaction&&ir(e,"deployTransaction",this.deployTransaction),e}attach(t){return new this.constructor(t,this.interface,this.signer||this.provider)}static isIndexed(t){return Gi.isIndexed(t)}_normalizeRunningEvent(t){return this._runningEvents[t.tag]?this._runningEvents[t.tag]:t}_getRunningEvent(t){if("string"==typeof t){if("error"===t)return this._normalizeRunningEvent(new Rs);if("event"===t)return this._normalizeRunningEvent(new Os("event",null));if("*"===t)return this._normalizeRunningEvent(new Bs(this.address,this.interface));const e=this.interface.getEvent(t);return this._normalizeRunningEvent(new Ps(this.address,this.interface,e))}if(t.topics&&t.topics.length>0){try{const e=t.topics[0];if("string"!=typeof e)throw new Error("invalid topic");const r=this.interface.getEvent(e);return this._normalizeRunningEvent(new Ps(this.address,this.interface,r,t.topics))}catch(t){}const e={address:this.address,topics:t.topics};return this._normalizeRunningEvent(new Os(zs(e),e))}return this._normalizeRunningEvent(new Bs(this.address,this.interface))}_checkRunningEvents(t){if(0===t.listenerCount()){delete this._runningEvents[t.tag];const e=this._wrappedEmits[t.tag];e&&t.filter&&(this.provider.off(t.filter,e),delete this._wrappedEmits[t.tag])}}_wrapEvent(t,e,r){const i=lr(e);return i.removeListener=()=>{r&&(t.removeListener(r),this._checkRunningEvents(t))},i.getBlock=()=>this.provider.getBlock(e.blockHash),i.getTransaction=()=>this.provider.getTransaction(e.transactionHash),i.getTransactionReceipt=()=>this.provider.getTransactionReceipt(e.transactionHash),t.prepareEvent(i),i}_addEventListener(t,e,r){if(this.provider||js.throwError("events require a provider or a signer with a provider",w.errors.UNSUPPORTED_OPERATION,{operation:"once"}),t.addListener(e,r),this._runningEvents[t.tag]=t,!this._wrappedEmits[t.tag]){const r=r=>{let i=this._wrapEvent(t,r,e);if(null==i.decodeError)try{const e=t.getEmit(i);this.emit(t.filter,...e)}catch(t){i.decodeError=t.error}null!=t.filter&&this.emit("event",i),null!=i.decodeError&&this.emit("error",i.decodeError,i)};this._wrappedEmits[t.tag]=r,null!=t.filter&&this.provider.on(t.filter,r)}}queryFilter(t,e,r){const i=this._getRunningEvent(t),n=ar(i.filter);return"string"==typeof e&&S(e,32)?(null!=r&&js.throwArgumentError("cannot specify toBlock with blockhash","toBlock",r),n.blockHash=e):(n.fromBlock=null!=e?e:0,n.toBlock=null!=r?r:"latest"),this.provider.getLogs(n).then((t=>t.map((t=>this._wrapEvent(i,t,null)))))}on(t,e){return this._addEventListener(this._getRunningEvent(t),e,!1),this}once(t,e){return this._addEventListener(this._getRunningEvent(t),e,!0),this}emit(t,...e){if(!this.provider)return!1;const r=this._getRunningEvent(t),i=r.run(e)>0;return this._checkRunningEvents(r),i}listenerCount(t){return this.provider?null==t?Object.keys(this._runningEvents).reduce(((t,e)=>t+this._runningEvents[e].listenerCount()),0):this._getRunningEvent(t).listenerCount():0}listeners(t){if(!this.provider)return[];if(null==t){const t=[];for(let e in this._runningEvents)this._runningEvents[e].listeners().forEach((e=>{t.push(e)}));return t}return this._getRunningEvent(t).listeners()}removeAllListeners(t){if(!this.provider)return this;if(null==t){for(const t in this._runningEvents){const e=this._runningEvents[t];e.removeAllListeners(),this._checkRunningEvents(e)}return this}const e=this._getRunningEvent(t);return e.removeAllListeners(),this._checkRunningEvents(e),this}off(t,e){if(!this.provider)return this;const r=this._getRunningEvent(t);return r.removeListener(e),this._checkRunningEvents(r),this}removeListener(t,e){return this.off(t,e)}}{}var $s=a((function(t){!function(t,e){function r(t,e){if(!t)throw new Error(e||"Assertion failed")}function i(t,e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}function n(t,e,r){if(n.isBN(t))return t;this.negative=0,this.words=null,this.length=0,this.red=null,null!==t&&("le"!==e&&"be"!==e||(r=e,e=10),this._init(t||0,e||10,r||"be"))}var o;"object"==typeof t?t.exports=n:e.BN=n,n.BN=n,n.wordSize=26;try{o="undefined"!=typeof window&&void 0!==window.Buffer?window.Buffer:Pt.Buffer}catch(t){}function a(t,e){var i=t.charCodeAt(e);return i>=48&&i<=57?i-48:i>=65&&i<=70?i-55:i>=97&&i<=102?i-87:void r(!1,"Invalid character in "+t)}function s(t,e,r){var i=a(t,r);return r-1>=e&&(i|=a(t,r-1)<<4),i}function h(t,e,i,n){for(var o=0,a=0,s=Math.min(t.length,i),h=e;h<s;h++){var u=t.charCodeAt(h)-48;o*=n,a=u>=49?u-49+10:u>=17?u-17+10:u,r(u>=0&&a<n,"Invalid character"),o+=a}return o}function u(t,e){t.words=e.words,t.length=e.length,t.negative=e.negative,t.red=e.red}if(n.isBN=function(t){return t instanceof n||null!==t&&"object"==typeof t&&t.constructor.wordSize===n.wordSize&&Array.isArray(t.words)},n.max=function(t,e){return t.cmp(e)>0?t:e},n.min=function(t,e){return t.cmp(e)<0?t:e},n.prototype._init=function(t,e,i){if("number"==typeof t)return this._initNumber(t,e,i);if("object"==typeof t)return this._initArray(t,e,i);"hex"===e&&(e=16),r(e===(0|e)&&e>=2&&e<=36);var n=0;"-"===(t=t.toString().replace(/\s+/g,""))[0]&&(n++,this.negative=1),n<t.length&&(16===e?this._parseHex(t,n,i):(this._parseBase(t,e,n),"le"===i&&this._initArray(this.toArray(),e,i)))},n.prototype._initNumber=function(t,e,i){t<0&&(this.negative=1,t=-t),t<67108864?(this.words=[67108863&t],this.length=1):t<4503599627370496?(this.words=[67108863&t,t/67108864&67108863],this.length=2):(r(t<9007199254740992),this.words=[67108863&t,t/67108864&67108863,1],this.length=3),"le"===i&&this._initArray(this.toArray(),e,i)},n.prototype._initArray=function(t,e,i){if(r("number"==typeof t.length),t.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(t.length/3),this.words=new Array(this.length);for(var n=0;n<this.length;n++)this.words[n]=0;var o,a,s=0;if("be"===i)for(n=t.length-1,o=0;n>=0;n-=3)a=t[n]|t[n-1]<<8|t[n-2]<<16,this.words[o]|=a<<s&67108863,this.words[o+1]=a>>>26-s&67108863,(s+=24)>=26&&(s-=26,o++);else if("le"===i)for(n=0,o=0;n<t.length;n+=3)a=t[n]|t[n+1]<<8|t[n+2]<<16,this.words[o]|=a<<s&67108863,this.words[o+1]=a>>>26-s&67108863,(s+=24)>=26&&(s-=26,o++);return this._strip()},n.prototype._parseHex=function(t,e,r){this.length=Math.ceil((t.length-e)/6),this.words=new Array(this.length);for(var i=0;i<this.length;i++)this.words[i]=0;var n,o=0,a=0;if("be"===r)for(i=t.length-1;i>=e;i-=2)n=s(t,e,i)<<o,this.words[a]|=67108863&n,o>=18?(o-=18,a+=1,this.words[a]|=n>>>26):o+=8;else for(i=(t.length-e)%2==0?e+1:e;i<t.length;i+=2)n=s(t,e,i)<<o,this.words[a]|=67108863&n,o>=18?(o-=18,a+=1,this.words[a]|=n>>>26):o+=8;this._strip()},n.prototype._parseBase=function(t,e,r){this.words=[0],this.length=1;for(var i=0,n=1;n<=67108863;n*=e)i++;i--,n=n/e|0;for(var o=t.length-r,a=o%i,s=Math.min(o,o-a)+r,u=0,l=r;l<s;l+=i)u=h(t,l,l+i,e),this.imuln(n),this.words[0]+u<67108864?this.words[0]+=u:this._iaddn(u);if(0!==a){var c=1;for(u=h(t,l,t.length,e),l=0;l<a;l++)c*=e;this.imuln(c),this.words[0]+u<67108864?this.words[0]+=u:this._iaddn(u)}this._strip()},n.prototype.copy=function(t){t.words=new Array(this.length);for(var e=0;e<this.length;e++)t.words[e]=this.words[e];t.length=this.length,t.negative=this.negative,t.red=this.red},n.prototype._move=function(t){u(t,this)},n.prototype.clone=function(){var t=new n(null);return this.copy(t),t},n.prototype._expand=function(t){for(;this.length<t;)this.words[this.length++]=0;return this},n.prototype._strip=function(){for(;this.length>1&&0===this.words[this.length-1];)this.length--;return this._normSign()},n.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},"undefined"!=typeof Symbol&&"function"==typeof Symbol.for)try{n.prototype[Symbol.for("nodejs.util.inspect.custom")]=l}catch(t){n.prototype.inspect=l}else n.prototype.inspect=l;function l(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"}var c=["","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"],d=[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],f=[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];n.prototype.toString=function(t,e){var i;if(e=0|e||1,16===(t=t||10)||"hex"===t){i="";for(var n=0,o=0,a=0;a<this.length;a++){var s=this.words[a],h=(16777215&(s<<n|o)).toString(16);o=s>>>24-n&16777215,(n+=2)>=26&&(n-=26,a--),i=0!==o||a!==this.length-1?c[6-h.length]+h+i:h+i}for(0!==o&&(i=o.toString(16)+i);i.length%e!=0;)i="0"+i;return 0!==this.negative&&(i="-"+i),i}if(t===(0|t)&&t>=2&&t<=36){var u=d[t],l=f[t];i="";var m=this.clone();for(m.negative=0;!m.isZero();){var p=m.modrn(l).toString(t);i=(m=m.idivn(l)).isZero()?p+i:c[u-p.length]+p+i}for(this.isZero()&&(i="0"+i);i.length%e!=0;)i="0"+i;return 0!==this.negative&&(i="-"+i),i}r(!1,"Base should be between 2 and 36")},n.prototype.toNumber=function(){var t=this.words[0];return 2===this.length?t+=67108864*this.words[1]:3===this.length&&1===this.words[2]?t+=4503599627370496+67108864*this.words[1]:this.length>2&&r(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-t:t},n.prototype.toJSON=function(){return this.toString(16,2)},o&&(n.prototype.toBuffer=function(t,e){return this.toArrayLike(o,t,e)}),n.prototype.toArray=function(t,e){return this.toArrayLike(Array,t,e)};function m(t,e,r){r.negative=e.negative^t.negative;var i=t.length+e.length|0;r.length=i,i=i-1|0;var n=0|t.words[0],o=0|e.words[0],a=n*o,s=67108863&a,h=a/67108864|0;r.words[0]=s;for(var u=1;u<i;u++){for(var l=h>>>26,c=67108863&h,d=Math.min(u,e.length-1),f=Math.max(0,u-t.length+1);f<=d;f++){var m=u-f|0;l+=(a=(n=0|t.words[m])*(o=0|e.words[f])+c)/67108864|0,c=67108863&a}r.words[u]=0|c,h=0|l}return 0!==h?r.words[u]=0|h:r.length--,r._strip()}n.prototype.toArrayLike=function(t,e,i){this._strip();var n=this.byteLength(),o=i||Math.max(1,n);r(n<=o,"byte array longer than desired length"),r(o>0,"Requested array length <= 0");var a=function(t,e){return t.allocUnsafe?t.allocUnsafe(e):new t(e)}(t,o);return this["_toArrayLike"+("le"===e?"LE":"BE")](a,n),a},n.prototype._toArrayLikeLE=function(t,e){for(var r=0,i=0,n=0,o=0;n<this.length;n++){var a=this.words[n]<<o|i;t[r++]=255&a,r<t.length&&(t[r++]=a>>8&255),r<t.length&&(t[r++]=a>>16&255),6===o?(r<t.length&&(t[r++]=a>>24&255),i=0,o=0):(i=a>>>24,o+=2)}if(r<t.length)for(t[r++]=i;r<t.length;)t[r++]=0},n.prototype._toArrayLikeBE=function(t,e){for(var r=t.length-1,i=0,n=0,o=0;n<this.length;n++){var a=this.words[n]<<o|i;t[r--]=255&a,r>=0&&(t[r--]=a>>8&255),r>=0&&(t[r--]=a>>16&255),6===o?(r>=0&&(t[r--]=a>>24&255),i=0,o=0):(i=a>>>24,o+=2)}if(r>=0)for(t[r--]=i;r>=0;)t[r--]=0},Math.clz32?n.prototype._countBits=function(t){return 32-Math.clz32(t)}:n.prototype._countBits=function(t){var e=t,r=0;return e>=4096&&(r+=13,e>>>=13),e>=64&&(r+=7,e>>>=7),e>=8&&(r+=4,e>>>=4),e>=2&&(r+=2,e>>>=2),r+e},n.prototype._zeroBits=function(t){if(0===t)return 26;var e=t,r=0;return 0==(8191&e)&&(r+=13,e>>>=13),0==(127&e)&&(r+=7,e>>>=7),0==(15&e)&&(r+=4,e>>>=4),0==(3&e)&&(r+=2,e>>>=2),0==(1&e)&&r++,r},n.prototype.bitLength=function(){var t=this.words[this.length-1],e=this._countBits(t);return 26*(this.length-1)+e},n.prototype.zeroBits=function(){if(this.isZero())return 0;for(var t=0,e=0;e<this.length;e++){var r=this._zeroBits(this.words[e]);if(t+=r,26!==r)break}return t},n.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},n.prototype.toTwos=function(t){return 0!==this.negative?this.abs().inotn(t).iaddn(1):this.clone()},n.prototype.fromTwos=function(t){return this.testn(t-1)?this.notn(t).iaddn(1).ineg():this.clone()},n.prototype.isNeg=function(){return 0!==this.negative},n.prototype.neg=function(){return this.clone().ineg()},n.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},n.prototype.iuor=function(t){for(;this.length<t.length;)this.words[this.length++]=0;for(var e=0;e<t.length;e++)this.words[e]=this.words[e]|t.words[e];return this._strip()},n.prototype.ior=function(t){return r(0==(this.negative|t.negative)),this.iuor(t)},n.prototype.or=function(t){return this.length>t.length?this.clone().ior(t):t.clone().ior(this)},n.prototype.uor=function(t){return this.length>t.length?this.clone().iuor(t):t.clone().iuor(this)},n.prototype.iuand=function(t){var e;e=this.length>t.length?t:this;for(var r=0;r<e.length;r++)this.words[r]=this.words[r]&t.words[r];return this.length=e.length,this._strip()},n.prototype.iand=function(t){return r(0==(this.negative|t.negative)),this.iuand(t)},n.prototype.and=function(t){return this.length>t.length?this.clone().iand(t):t.clone().iand(this)},n.prototype.uand=function(t){return this.length>t.length?this.clone().iuand(t):t.clone().iuand(this)},n.prototype.iuxor=function(t){var e,r;this.length>t.length?(e=this,r=t):(e=t,r=this);for(var i=0;i<r.length;i++)this.words[i]=e.words[i]^r.words[i];if(this!==e)for(;i<e.length;i++)this.words[i]=e.words[i];return this.length=e.length,this._strip()},n.prototype.ixor=function(t){return r(0==(this.negative|t.negative)),this.iuxor(t)},n.prototype.xor=function(t){return this.length>t.length?this.clone().ixor(t):t.clone().ixor(this)},n.prototype.uxor=function(t){return this.length>t.length?this.clone().iuxor(t):t.clone().iuxor(this)},n.prototype.inotn=function(t){r("number"==typeof t&&t>=0);var e=0|Math.ceil(t/26),i=t%26;this._expand(e),i>0&&e--;for(var n=0;n<e;n++)this.words[n]=67108863&~this.words[n];return i>0&&(this.words[n]=~this.words[n]&67108863>>26-i),this._strip()},n.prototype.notn=function(t){return this.clone().inotn(t)},n.prototype.setn=function(t,e){r("number"==typeof t&&t>=0);var i=t/26|0,n=t%26;return this._expand(i+1),this.words[i]=e?this.words[i]|1<<n:this.words[i]&~(1<<n),this._strip()},n.prototype.iadd=function(t){var e,r,i;if(0!==this.negative&&0===t.negative)return this.negative=0,e=this.isub(t),this.negative^=1,this._normSign();if(0===this.negative&&0!==t.negative)return t.negative=0,e=this.isub(t),t.negative=1,e._normSign();this.length>t.length?(r=this,i=t):(r=t,i=this);for(var n=0,o=0;o<i.length;o++)e=(0|r.words[o])+(0|i.words[o])+n,this.words[o]=67108863&e,n=e>>>26;for(;0!==n&&o<r.length;o++)e=(0|r.words[o])+n,this.words[o]=67108863&e,n=e>>>26;if(this.length=r.length,0!==n)this.words[this.length]=n,this.length++;else if(r!==this)for(;o<r.length;o++)this.words[o]=r.words[o];return this},n.prototype.add=function(t){var e;return 0!==t.negative&&0===this.negative?(t.negative=0,e=this.sub(t),t.negative^=1,e):0===t.negative&&0!==this.negative?(this.negative=0,e=t.sub(this),this.negative=1,e):this.length>t.length?this.clone().iadd(t):t.clone().iadd(this)},n.prototype.isub=function(t){if(0!==t.negative){t.negative=0;var e=this.iadd(t);return t.negative=1,e._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(t),this.negative=1,this._normSign();var r,i,n=this.cmp(t);if(0===n)return this.negative=0,this.length=1,this.words[0]=0,this;n>0?(r=this,i=t):(r=t,i=this);for(var o=0,a=0;a<i.length;a++)o=(e=(0|r.words[a])-(0|i.words[a])+o)>>26,this.words[a]=67108863&e;for(;0!==o&&a<r.length;a++)o=(e=(0|r.words[a])+o)>>26,this.words[a]=67108863&e;if(0===o&&a<r.length&&r!==this)for(;a<r.length;a++)this.words[a]=r.words[a];return this.length=Math.max(this.length,a),r!==this&&(this.negative=1),this._strip()},n.prototype.sub=function(t){return this.clone().isub(t)};var p=function(t,e,r){var i,n,o,a=t.words,s=e.words,h=r.words,u=0,l=0|a[0],c=8191&l,d=l>>>13,f=0|a[1],m=8191&f,p=f>>>13,g=0|a[2],y=8191&g,w=g>>>13,v=0|a[3],b=8191&v,k=v>>>13,M=0|a[4],_=8191&M,E=M>>>13,A=0|a[5],j=8191&A,x=A>>>13,S=0|a[6],N=8191&S,I=S>>>13,T=0|a[7],C=8191&T,z=T>>>13,O=0|a[8],R=8191&O,P=O>>>13,B=0|a[9],D=8191&B,$=B>>>13,L=0|s[0],F=8191&L,U=L>>>13,q=0|s[1],V=8191&q,H=q>>>13,G=0|s[2],Z=8191&G,K=G>>>13,J=0|s[3],W=8191&J,Y=J>>>13,Q=0|s[4],X=8191&Q,tt=Q>>>13,et=0|s[5],rt=8191&et,it=et>>>13,nt=0|s[6],ot=8191&nt,at=nt>>>13,st=0|s[7],ht=8191&st,ut=st>>>13,lt=0|s[8],ct=8191&lt,dt=lt>>>13,ft=0|s[9],mt=8191&ft,pt=ft>>>13;r.negative=t.negative^e.negative,r.length=19;var gt=(u+(i=Math.imul(c,F))|0)+((8191&(n=(n=Math.imul(c,U))+Math.imul(d,F)|0))<<13)|0;u=((o=Math.imul(d,U))+(n>>>13)|0)+(gt>>>26)|0,gt&=67108863,i=Math.imul(m,F),n=(n=Math.imul(m,U))+Math.imul(p,F)|0,o=Math.imul(p,U);var yt=(u+(i=i+Math.imul(c,V)|0)|0)+((8191&(n=(n=n+Math.imul(c,H)|0)+Math.imul(d,V)|0))<<13)|0;u=((o=o+Math.imul(d,H)|0)+(n>>>13)|0)+(yt>>>26)|0,yt&=67108863,i=Math.imul(y,F),n=(n=Math.imul(y,U))+Math.imul(w,F)|0,o=Math.imul(w,U),i=i+Math.imul(m,V)|0,n=(n=n+Math.imul(m,H)|0)+Math.imul(p,V)|0,o=o+Math.imul(p,H)|0;var wt=(u+(i=i+Math.imul(c,Z)|0)|0)+((8191&(n=(n=n+Math.imul(c,K)|0)+Math.imul(d,Z)|0))<<13)|0;u=((o=o+Math.imul(d,K)|0)+(n>>>13)|0)+(wt>>>26)|0,wt&=67108863,i=Math.imul(b,F),n=(n=Math.imul(b,U))+Math.imul(k,F)|0,o=Math.imul(k,U),i=i+Math.imul(y,V)|0,n=(n=n+Math.imul(y,H)|0)+Math.imul(w,V)|0,o=o+Math.imul(w,H)|0,i=i+Math.imul(m,Z)|0,n=(n=n+Math.imul(m,K)|0)+Math.imul(p,Z)|0,o=o+Math.imul(p,K)|0;var vt=(u+(i=i+Math.imul(c,W)|0)|0)+((8191&(n=(n=n+Math.imul(c,Y)|0)+Math.imul(d,W)|0))<<13)|0;u=((o=o+Math.imul(d,Y)|0)+(n>>>13)|0)+(vt>>>26)|0,vt&=67108863,i=Math.imul(_,F),n=(n=Math.imul(_,U))+Math.imul(E,F)|0,o=Math.imul(E,U),i=i+Math.imul(b,V)|0,n=(n=n+Math.imul(b,H)|0)+Math.imul(k,V)|0,o=o+Math.imul(k,H)|0,i=i+Math.imul(y,Z)|0,n=(n=n+Math.imul(y,K)|0)+Math.imul(w,Z)|0,o=o+Math.imul(w,K)|0,i=i+Math.imul(m,W)|0,n=(n=n+Math.imul(m,Y)|0)+Math.imul(p,W)|0,o=o+Math.imul(p,Y)|0;var bt=(u+(i=i+Math.imul(c,X)|0)|0)+((8191&(n=(n=n+Math.imul(c,tt)|0)+Math.imul(d,X)|0))<<13)|0;u=((o=o+Math.imul(d,tt)|0)+(n>>>13)|0)+(bt>>>26)|0,bt&=67108863,i=Math.imul(j,F),n=(n=Math.imul(j,U))+Math.imul(x,F)|0,o=Math.imul(x,U),i=i+Math.imul(_,V)|0,n=(n=n+Math.imul(_,H)|0)+Math.imul(E,V)|0,o=o+Math.imul(E,H)|0,i=i+Math.imul(b,Z)|0,n=(n=n+Math.imul(b,K)|0)+Math.imul(k,Z)|0,o=o+Math.imul(k,K)|0,i=i+Math.imul(y,W)|0,n=(n=n+Math.imul(y,Y)|0)+Math.imul(w,W)|0,o=o+Math.imul(w,Y)|0,i=i+Math.imul(m,X)|0,n=(n=n+Math.imul(m,tt)|0)+Math.imul(p,X)|0,o=o+Math.imul(p,tt)|0;var kt=(u+(i=i+Math.imul(c,rt)|0)|0)+((8191&(n=(n=n+Math.imul(c,it)|0)+Math.imul(d,rt)|0))<<13)|0;u=((o=o+Math.imul(d,it)|0)+(n>>>13)|0)+(kt>>>26)|0,kt&=67108863,i=Math.imul(N,F),n=(n=Math.imul(N,U))+Math.imul(I,F)|0,o=Math.imul(I,U),i=i+Math.imul(j,V)|0,n=(n=n+Math.imul(j,H)|0)+Math.imul(x,V)|0,o=o+Math.imul(x,H)|0,i=i+Math.imul(_,Z)|0,n=(n=n+Math.imul(_,K)|0)+Math.imul(E,Z)|0,o=o+Math.imul(E,K)|0,i=i+Math.imul(b,W)|0,n=(n=n+Math.imul(b,Y)|0)+Math.imul(k,W)|0,o=o+Math.imul(k,Y)|0,i=i+Math.imul(y,X)|0,n=(n=n+Math.imul(y,tt)|0)+Math.imul(w,X)|0,o=o+Math.imul(w,tt)|0,i=i+Math.imul(m,rt)|0,n=(n=n+Math.imul(m,it)|0)+Math.imul(p,rt)|0,o=o+Math.imul(p,it)|0;var Mt=(u+(i=i+Math.imul(c,ot)|0)|0)+((8191&(n=(n=n+Math.imul(c,at)|0)+Math.imul(d,ot)|0))<<13)|0;u=((o=o+Math.imul(d,at)|0)+(n>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,i=Math.imul(C,F),n=(n=Math.imul(C,U))+Math.imul(z,F)|0,o=Math.imul(z,U),i=i+Math.imul(N,V)|0,n=(n=n+Math.imul(N,H)|0)+Math.imul(I,V)|0,o=o+Math.imul(I,H)|0,i=i+Math.imul(j,Z)|0,n=(n=n+Math.imul(j,K)|0)+Math.imul(x,Z)|0,o=o+Math.imul(x,K)|0,i=i+Math.imul(_,W)|0,n=(n=n+Math.imul(_,Y)|0)+Math.imul(E,W)|0,o=o+Math.imul(E,Y)|0,i=i+Math.imul(b,X)|0,n=(n=n+Math.imul(b,tt)|0)+Math.imul(k,X)|0,o=o+Math.imul(k,tt)|0,i=i+Math.imul(y,rt)|0,n=(n=n+Math.imul(y,it)|0)+Math.imul(w,rt)|0,o=o+Math.imul(w,it)|0,i=i+Math.imul(m,ot)|0,n=(n=n+Math.imul(m,at)|0)+Math.imul(p,ot)|0,o=o+Math.imul(p,at)|0;var _t=(u+(i=i+Math.imul(c,ht)|0)|0)+((8191&(n=(n=n+Math.imul(c,ut)|0)+Math.imul(d,ht)|0))<<13)|0;u=((o=o+Math.imul(d,ut)|0)+(n>>>13)|0)+(_t>>>26)|0,_t&=67108863,i=Math.imul(R,F),n=(n=Math.imul(R,U))+Math.imul(P,F)|0,o=Math.imul(P,U),i=i+Math.imul(C,V)|0,n=(n=n+Math.imul(C,H)|0)+Math.imul(z,V)|0,o=o+Math.imul(z,H)|0,i=i+Math.imul(N,Z)|0,n=(n=n+Math.imul(N,K)|0)+Math.imul(I,Z)|0,o=o+Math.imul(I,K)|0,i=i+Math.imul(j,W)|0,n=(n=n+Math.imul(j,Y)|0)+Math.imul(x,W)|0,o=o+Math.imul(x,Y)|0,i=i+Math.imul(_,X)|0,n=(n=n+Math.imul(_,tt)|0)+Math.imul(E,X)|0,o=o+Math.imul(E,tt)|0,i=i+Math.imul(b,rt)|0,n=(n=n+Math.imul(b,it)|0)+Math.imul(k,rt)|0,o=o+Math.imul(k,it)|0,i=i+Math.imul(y,ot)|0,n=(n=n+Math.imul(y,at)|0)+Math.imul(w,ot)|0,o=o+Math.imul(w,at)|0,i=i+Math.imul(m,ht)|0,n=(n=n+Math.imul(m,ut)|0)+Math.imul(p,ht)|0,o=o+Math.imul(p,ut)|0;var Et=(u+(i=i+Math.imul(c,ct)|0)|0)+((8191&(n=(n=n+Math.imul(c,dt)|0)+Math.imul(d,ct)|0))<<13)|0;u=((o=o+Math.imul(d,dt)|0)+(n>>>13)|0)+(Et>>>26)|0,Et&=67108863,i=Math.imul(D,F),n=(n=Math.imul(D,U))+Math.imul($,F)|0,o=Math.imul($,U),i=i+Math.imul(R,V)|0,n=(n=n+Math.imul(R,H)|0)+Math.imul(P,V)|0,o=o+Math.imul(P,H)|0,i=i+Math.imul(C,Z)|0,n=(n=n+Math.imul(C,K)|0)+Math.imul(z,Z)|0,o=o+Math.imul(z,K)|0,i=i+Math.imul(N,W)|0,n=(n=n+Math.imul(N,Y)|0)+Math.imul(I,W)|0,o=o+Math.imul(I,Y)|0,i=i+Math.imul(j,X)|0,n=(n=n+Math.imul(j,tt)|0)+Math.imul(x,X)|0,o=o+Math.imul(x,tt)|0,i=i+Math.imul(_,rt)|0,n=(n=n+Math.imul(_,it)|0)+Math.imul(E,rt)|0,o=o+Math.imul(E,it)|0,i=i+Math.imul(b,ot)|0,n=(n=n+Math.imul(b,at)|0)+Math.imul(k,ot)|0,o=o+Math.imul(k,at)|0,i=i+Math.imul(y,ht)|0,n=(n=n+Math.imul(y,ut)|0)+Math.imul(w,ht)|0,o=o+Math.imul(w,ut)|0,i=i+Math.imul(m,ct)|0,n=(n=n+Math.imul(m,dt)|0)+Math.imul(p,ct)|0,o=o+Math.imul(p,dt)|0;var At=(u+(i=i+Math.imul(c,mt)|0)|0)+((8191&(n=(n=n+Math.imul(c,pt)|0)+Math.imul(d,mt)|0))<<13)|0;u=((o=o+Math.imul(d,pt)|0)+(n>>>13)|0)+(At>>>26)|0,At&=67108863,i=Math.imul(D,V),n=(n=Math.imul(D,H))+Math.imul($,V)|0,o=Math.imul($,H),i=i+Math.imul(R,Z)|0,n=(n=n+Math.imul(R,K)|0)+Math.imul(P,Z)|0,o=o+Math.imul(P,K)|0,i=i+Math.imul(C,W)|0,n=(n=n+Math.imul(C,Y)|0)+Math.imul(z,W)|0,o=o+Math.imul(z,Y)|0,i=i+Math.imul(N,X)|0,n=(n=n+Math.imul(N,tt)|0)+Math.imul(I,X)|0,o=o+Math.imul(I,tt)|0,i=i+Math.imul(j,rt)|0,n=(n=n+Math.imul(j,it)|0)+Math.imul(x,rt)|0,o=o+Math.imul(x,it)|0,i=i+Math.imul(_,ot)|0,n=(n=n+Math.imul(_,at)|0)+Math.imul(E,ot)|0,o=o+Math.imul(E,at)|0,i=i+Math.imul(b,ht)|0,n=(n=n+Math.imul(b,ut)|0)+Math.imul(k,ht)|0,o=o+Math.imul(k,ut)|0,i=i+Math.imul(y,ct)|0,n=(n=n+Math.imul(y,dt)|0)+Math.imul(w,ct)|0,o=o+Math.imul(w,dt)|0;var jt=(u+(i=i+Math.imul(m,mt)|0)|0)+((8191&(n=(n=n+Math.imul(m,pt)|0)+Math.imul(p,mt)|0))<<13)|0;u=((o=o+Math.imul(p,pt)|0)+(n>>>13)|0)+(jt>>>26)|0,jt&=67108863,i=Math.imul(D,Z),n=(n=Math.imul(D,K))+Math.imul($,Z)|0,o=Math.imul($,K),i=i+Math.imul(R,W)|0,n=(n=n+Math.imul(R,Y)|0)+Math.imul(P,W)|0,o=o+Math.imul(P,Y)|0,i=i+Math.imul(C,X)|0,n=(n=n+Math.imul(C,tt)|0)+Math.imul(z,X)|0,o=o+Math.imul(z,tt)|0,i=i+Math.imul(N,rt)|0,n=(n=n+Math.imul(N,it)|0)+Math.imul(I,rt)|0,o=o+Math.imul(I,it)|0,i=i+Math.imul(j,ot)|0,n=(n=n+Math.imul(j,at)|0)+Math.imul(x,ot)|0,o=o+Math.imul(x,at)|0,i=i+Math.imul(_,ht)|0,n=(n=n+Math.imul(_,ut)|0)+Math.imul(E,ht)|0,o=o+Math.imul(E,ut)|0,i=i+Math.imul(b,ct)|0,n=(n=n+Math.imul(b,dt)|0)+Math.imul(k,ct)|0,o=o+Math.imul(k,dt)|0;var xt=(u+(i=i+Math.imul(y,mt)|0)|0)+((8191&(n=(n=n+Math.imul(y,pt)|0)+Math.imul(w,mt)|0))<<13)|0;u=((o=o+Math.imul(w,pt)|0)+(n>>>13)|0)+(xt>>>26)|0,xt&=67108863,i=Math.imul(D,W),n=(n=Math.imul(D,Y))+Math.imul($,W)|0,o=Math.imul($,Y),i=i+Math.imul(R,X)|0,n=(n=n+Math.imul(R,tt)|0)+Math.imul(P,X)|0,o=o+Math.imul(P,tt)|0,i=i+Math.imul(C,rt)|0,n=(n=n+Math.imul(C,it)|0)+Math.imul(z,rt)|0,o=o+Math.imul(z,it)|0,i=i+Math.imul(N,ot)|0,n=(n=n+Math.imul(N,at)|0)+Math.imul(I,ot)|0,o=o+Math.imul(I,at)|0,i=i+Math.imul(j,ht)|0,n=(n=n+Math.imul(j,ut)|0)+Math.imul(x,ht)|0,o=o+Math.imul(x,ut)|0,i=i+Math.imul(_,ct)|0,n=(n=n+Math.imul(_,dt)|0)+Math.imul(E,ct)|0,o=o+Math.imul(E,dt)|0;var St=(u+(i=i+Math.imul(b,mt)|0)|0)+((8191&(n=(n=n+Math.imul(b,pt)|0)+Math.imul(k,mt)|0))<<13)|0;u=((o=o+Math.imul(k,pt)|0)+(n>>>13)|0)+(St>>>26)|0,St&=67108863,i=Math.imul(D,X),n=(n=Math.imul(D,tt))+Math.imul($,X)|0,o=Math.imul($,tt),i=i+Math.imul(R,rt)|0,n=(n=n+Math.imul(R,it)|0)+Math.imul(P,rt)|0,o=o+Math.imul(P,it)|0,i=i+Math.imul(C,ot)|0,n=(n=n+Math.imul(C,at)|0)+Math.imul(z,ot)|0,o=o+Math.imul(z,at)|0,i=i+Math.imul(N,ht)|0,n=(n=n+Math.imul(N,ut)|0)+Math.imul(I,ht)|0,o=o+Math.imul(I,ut)|0,i=i+Math.imul(j,ct)|0,n=(n=n+Math.imul(j,dt)|0)+Math.imul(x,ct)|0,o=o+Math.imul(x,dt)|0;var Nt=(u+(i=i+Math.imul(_,mt)|0)|0)+((8191&(n=(n=n+Math.imul(_,pt)|0)+Math.imul(E,mt)|0))<<13)|0;u=((o=o+Math.imul(E,pt)|0)+(n>>>13)|0)+(Nt>>>26)|0,Nt&=67108863,i=Math.imul(D,rt),n=(n=Math.imul(D,it))+Math.imul($,rt)|0,o=Math.imul($,it),i=i+Math.imul(R,ot)|0,n=(n=n+Math.imul(R,at)|0)+Math.imul(P,ot)|0,o=o+Math.imul(P,at)|0,i=i+Math.imul(C,ht)|0,n=(n=n+Math.imul(C,ut)|0)+Math.imul(z,ht)|0,o=o+Math.imul(z,ut)|0,i=i+Math.imul(N,ct)|0,n=(n=n+Math.imul(N,dt)|0)+Math.imul(I,ct)|0,o=o+Math.imul(I,dt)|0;var It=(u+(i=i+Math.imul(j,mt)|0)|0)+((8191&(n=(n=n+Math.imul(j,pt)|0)+Math.imul(x,mt)|0))<<13)|0;u=((o=o+Math.imul(x,pt)|0)+(n>>>13)|0)+(It>>>26)|0,It&=67108863,i=Math.imul(D,ot),n=(n=Math.imul(D,at))+Math.imul($,ot)|0,o=Math.imul($,at),i=i+Math.imul(R,ht)|0,n=(n=n+Math.imul(R,ut)|0)+Math.imul(P,ht)|0,o=o+Math.imul(P,ut)|0,i=i+Math.imul(C,ct)|0,n=(n=n+Math.imul(C,dt)|0)+Math.imul(z,ct)|0,o=o+Math.imul(z,dt)|0;var Tt=(u+(i=i+Math.imul(N,mt)|0)|0)+((8191&(n=(n=n+Math.imul(N,pt)|0)+Math.imul(I,mt)|0))<<13)|0;u=((o=o+Math.imul(I,pt)|0)+(n>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,i=Math.imul(D,ht),n=(n=Math.imul(D,ut))+Math.imul($,ht)|0,o=Math.imul($,ut),i=i+Math.imul(R,ct)|0,n=(n=n+Math.imul(R,dt)|0)+Math.imul(P,ct)|0,o=o+Math.imul(P,dt)|0;var Ct=(u+(i=i+Math.imul(C,mt)|0)|0)+((8191&(n=(n=n+Math.imul(C,pt)|0)+Math.imul(z,mt)|0))<<13)|0;u=((o=o+Math.imul(z,pt)|0)+(n>>>13)|0)+(Ct>>>26)|0,Ct&=67108863,i=Math.imul(D,ct),n=(n=Math.imul(D,dt))+Math.imul($,ct)|0,o=Math.imul($,dt);var zt=(u+(i=i+Math.imul(R,mt)|0)|0)+((8191&(n=(n=n+Math.imul(R,pt)|0)+Math.imul(P,mt)|0))<<13)|0;u=((o=o+Math.imul(P,pt)|0)+(n>>>13)|0)+(zt>>>26)|0,zt&=67108863;var Ot=(u+(i=Math.imul(D,mt))|0)+((8191&(n=(n=Math.imul(D,pt))+Math.imul($,mt)|0))<<13)|0;return u=((o=Math.imul($,pt))+(n>>>13)|0)+(Ot>>>26)|0,Ot&=67108863,h[0]=gt,h[1]=yt,h[2]=wt,h[3]=vt,h[4]=bt,h[5]=kt,h[6]=Mt,h[7]=_t,h[8]=Et,h[9]=At,h[10]=jt,h[11]=xt,h[12]=St,h[13]=Nt,h[14]=It,h[15]=Tt,h[16]=Ct,h[17]=zt,h[18]=Ot,0!==u&&(h[19]=u,r.length++),r};function g(t,e,r){r.negative=e.negative^t.negative,r.length=t.length+e.length;for(var i=0,n=0,o=0;o<r.length-1;o++){var a=n;n=0;for(var s=67108863&i,h=Math.min(o,e.length-1),u=Math.max(0,o-t.length+1);u<=h;u++){var l=o-u,c=(0|t.words[l])*(0|e.words[u]),d=67108863&c;s=67108863&(d=d+s|0),n+=(a=(a=a+(c/67108864|0)|0)+(d>>>26)|0)>>>26,a&=67108863}r.words[o]=s,i=a,a=n}return 0!==i?r.words[o]=i:r.length--,r._strip()}function y(t,e,r){return g(t,e,r)}Math.imul||(p=m),n.prototype.mulTo=function(t,e){var r=this.length+t.length;return 10===this.length&&10===t.length?p(this,t,e):r<63?m(this,t,e):r<1024?g(this,t,e):y(this,t,e)},n.prototype.mul=function(t){var e=new n(null);return e.words=new Array(this.length+t.length),this.mulTo(t,e)},n.prototype.mulf=function(t){var e=new n(null);return e.words=new Array(this.length+t.length),y(this,t,e)},n.prototype.imul=function(t){return this.clone().mulTo(t,this)},n.prototype.imuln=function(t){var e=t<0;e&&(t=-t),r("number"==typeof t),r(t<67108864);for(var i=0,n=0;n<this.length;n++){var o=(0|this.words[n])*t,a=(67108863&o)+(67108863&i);i>>=26,i+=o/67108864|0,i+=a>>>26,this.words[n]=67108863&a}return 0!==i&&(this.words[n]=i,this.length++),e?this.ineg():this},n.prototype.muln=function(t){return this.clone().imuln(t)},n.prototype.sqr=function(){return this.mul(this)},n.prototype.isqr=function(){return this.imul(this.clone())},n.prototype.pow=function(t){var e=function(t){for(var e=new Array(t.bitLength()),r=0;r<e.length;r++){var i=r/26|0,n=r%26;e[r]=t.words[i]>>>n&1}return e}(t);if(0===e.length)return new n(1);for(var r=this,i=0;i<e.length&&0===e[i];i++,r=r.sqr());if(++i<e.length)for(var o=r.sqr();i<e.length;i++,o=o.sqr())0!==e[i]&&(r=r.mul(o));return r},n.prototype.iushln=function(t){r("number"==typeof t&&t>=0);var e,i=t%26,n=(t-i)/26,o=67108863>>>26-i<<26-i;if(0!==i){var a=0;for(e=0;e<this.length;e++){var s=this.words[e]&o,h=(0|this.words[e])-s<<i;this.words[e]=h|a,a=s>>>26-i}a&&(this.words[e]=a,this.length++)}if(0!==n){for(e=this.length-1;e>=0;e--)this.words[e+n]=this.words[e];for(e=0;e<n;e++)this.words[e]=0;this.length+=n}return this._strip()},n.prototype.ishln=function(t){return r(0===this.negative),this.iushln(t)},n.prototype.iushrn=function(t,e,i){var n;r("number"==typeof t&&t>=0),n=e?(e-e%26)/26:0;var o=t%26,a=Math.min((t-o)/26,this.length),s=67108863^67108863>>>o<<o,h=i;if(n-=a,n=Math.max(0,n),h){for(var u=0;u<a;u++)h.words[u]=this.words[u];h.length=a}if(0===a);else if(this.length>a)for(this.length-=a,u=0;u<this.length;u++)this.words[u]=this.words[u+a];else this.words[0]=0,this.length=1;var l=0;for(u=this.length-1;u>=0&&(0!==l||u>=n);u--){var c=0|this.words[u];this.words[u]=l<<26-o|c>>>o,l=c&s}return h&&0!==l&&(h.words[h.length++]=l),0===this.length&&(this.words[0]=0,this.length=1),this._strip()},n.prototype.ishrn=function(t,e,i){return r(0===this.negative),this.iushrn(t,e,i)},n.prototype.shln=function(t){return this.clone().ishln(t)},n.prototype.ushln=function(t){return this.clone().iushln(t)},n.prototype.shrn=function(t){return this.clone().ishrn(t)},n.prototype.ushrn=function(t){return this.clone().iushrn(t)},n.prototype.testn=function(t){r("number"==typeof t&&t>=0);var e=t%26,i=(t-e)/26,n=1<<e;return!(this.length<=i)&&!!(this.words[i]&n)},n.prototype.imaskn=function(t){r("number"==typeof t&&t>=0);var e=t%26,i=(t-e)/26;if(r(0===this.negative,"imaskn works only with positive numbers"),this.length<=i)return this;if(0!==e&&i++,this.length=Math.min(i,this.length),0!==e){var n=67108863^67108863>>>e<<e;this.words[this.length-1]&=n}return this._strip()},n.prototype.maskn=function(t){return this.clone().imaskn(t)},n.prototype.iaddn=function(t){return r("number"==typeof t),r(t<67108864),t<0?this.isubn(-t):0!==this.negative?1===this.length&&(0|this.words[0])<=t?(this.words[0]=t-(0|this.words[0]),this.negative=0,this):(this.negative=0,this.isubn(t),this.negative=1,this):this._iaddn(t)},n.prototype._iaddn=function(t){this.words[0]+=t;for(var e=0;e<this.length&&this.words[e]>=67108864;e++)this.words[e]-=67108864,e===this.length-1?this.words[e+1]=1:this.words[e+1]++;return this.length=Math.max(this.length,e+1),this},n.prototype.isubn=function(t){if(r("number"==typeof t),r(t<67108864),t<0)return this.iaddn(-t);if(0!==this.negative)return this.negative=0,this.iaddn(t),this.negative=1,this;if(this.words[0]-=t,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var e=0;e<this.length&&this.words[e]<0;e++)this.words[e]+=67108864,this.words[e+1]-=1;return this._strip()},n.prototype.addn=function(t){return this.clone().iaddn(t)},n.prototype.subn=function(t){return this.clone().isubn(t)},n.prototype.iabs=function(){return this.negative=0,this},n.prototype.abs=function(){return this.clone().iabs()},n.prototype._ishlnsubmul=function(t,e,i){var n,o,a=t.length+i;this._expand(a);var s=0;for(n=0;n<t.length;n++){o=(0|this.words[n+i])+s;var h=(0|t.words[n])*e;s=((o-=67108863&h)>>26)-(h/67108864|0),this.words[n+i]=67108863&o}for(;n<this.length-i;n++)s=(o=(0|this.words[n+i])+s)>>26,this.words[n+i]=67108863&o;if(0===s)return this._strip();for(r(-1===s),s=0,n=0;n<this.length;n++)s=(o=-(0|this.words[n])+s)>>26,this.words[n]=67108863&o;return this.negative=1,this._strip()},n.prototype._wordDiv=function(t,e){var r=(this.length,t.length),i=this.clone(),o=t,a=0|o.words[o.length-1];0!==(r=26-this._countBits(a))&&(o=o.ushln(r),i.iushln(r),a=0|o.words[o.length-1]);var s,h=i.length-o.length;if("mod"!==e){(s=new n(null)).length=h+1,s.words=new Array(s.length);for(var u=0;u<s.length;u++)s.words[u]=0}var l=i.clone()._ishlnsubmul(o,1,h);0===l.negative&&(i=l,s&&(s.words[h]=1));for(var c=h-1;c>=0;c--){var d=67108864*(0|i.words[o.length+c])+(0|i.words[o.length+c-1]);for(d=Math.min(d/a|0,67108863),i._ishlnsubmul(o,d,c);0!==i.negative;)d--,i.negative=0,i._ishlnsubmul(o,1,c),i.isZero()||(i.negative^=1);s&&(s.words[c]=d)}return s&&s._strip(),i._strip(),"div"!==e&&0!==r&&i.iushrn(r),{div:s||null,mod:i}},n.prototype.divmod=function(t,e,i){return r(!t.isZero()),this.isZero()?{div:new n(0),mod:new n(0)}:0!==this.negative&&0===t.negative?(s=this.neg().divmod(t,e),"mod"!==e&&(o=s.div.neg()),"div"!==e&&(a=s.mod.neg(),i&&0!==a.negative&&a.iadd(t)),{div:o,mod:a}):0===this.negative&&0!==t.negative?(s=this.divmod(t.neg(),e),"mod"!==e&&(o=s.div.neg()),{div:o,mod:s.mod}):0!=(this.negative&t.negative)?(s=this.neg().divmod(t.neg(),e),"div"!==e&&(a=s.mod.neg(),i&&0!==a.negative&&a.isub(t)),{div:s.div,mod:a}):t.length>this.length||this.cmp(t)<0?{div:new n(0),mod:this}:1===t.length?"div"===e?{div:this.divn(t.words[0]),mod:null}:"mod"===e?{div:null,mod:new n(this.modrn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new n(this.modrn(t.words[0]))}:this._wordDiv(t,e);var o,a,s},n.prototype.div=function(t){return this.divmod(t,"div",!1).div},n.prototype.mod=function(t){return this.divmod(t,"mod",!1).mod},n.prototype.umod=function(t){return this.divmod(t,"mod",!0).mod},n.prototype.divRound=function(t){var e=this.divmod(t);if(e.mod.isZero())return e.div;var r=0!==e.div.negative?e.mod.isub(t):e.mod,i=t.ushrn(1),n=t.andln(1),o=r.cmp(i);return o<0||1===n&&0===o?e.div:0!==e.div.negative?e.div.isubn(1):e.div.iaddn(1)},n.prototype.modrn=function(t){var e=t<0;e&&(t=-t),r(t<=67108863);for(var i=(1<<26)%t,n=0,o=this.length-1;o>=0;o--)n=(i*n+(0|this.words[o]))%t;return e?-n:n},n.prototype.modn=function(t){return this.modrn(t)},n.prototype.idivn=function(t){var e=t<0;e&&(t=-t),r(t<=67108863);for(var i=0,n=this.length-1;n>=0;n--){var o=(0|this.words[n])+67108864*i;this.words[n]=o/t|0,i=o%t}return this._strip(),e?this.ineg():this},n.prototype.divn=function(t){return this.clone().idivn(t)},n.prototype.egcd=function(t){r(0===t.negative),r(!t.isZero());var e=this,i=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var o=new n(1),a=new n(0),s=new n(0),h=new n(1),u=0;e.isEven()&&i.isEven();)e.iushrn(1),i.iushrn(1),++u;for(var l=i.clone(),c=e.clone();!e.isZero();){for(var d=0,f=1;0==(e.words[0]&f)&&d<26;++d,f<<=1);if(d>0)for(e.iushrn(d);d-- >0;)(o.isOdd()||a.isOdd())&&(o.iadd(l),a.isub(c)),o.iushrn(1),a.iushrn(1);for(var m=0,p=1;0==(i.words[0]&p)&&m<26;++m,p<<=1);if(m>0)for(i.iushrn(m);m-- >0;)(s.isOdd()||h.isOdd())&&(s.iadd(l),h.isub(c)),s.iushrn(1),h.iushrn(1);e.cmp(i)>=0?(e.isub(i),o.isub(s),a.isub(h)):(i.isub(e),s.isub(o),h.isub(a))}return{a:s,b:h,gcd:i.iushln(u)}},n.prototype._invmp=function(t){r(0===t.negative),r(!t.isZero());var e=this,i=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var o,a=new n(1),s=new n(0),h=i.clone();e.cmpn(1)>0&&i.cmpn(1)>0;){for(var u=0,l=1;0==(e.words[0]&l)&&u<26;++u,l<<=1);if(u>0)for(e.iushrn(u);u-- >0;)a.isOdd()&&a.iadd(h),a.iushrn(1);for(var c=0,d=1;0==(i.words[0]&d)&&c<26;++c,d<<=1);if(c>0)for(i.iushrn(c);c-- >0;)s.isOdd()&&s.iadd(h),s.iushrn(1);e.cmp(i)>=0?(e.isub(i),a.isub(s)):(i.isub(e),s.isub(a))}return(o=0===e.cmpn(1)?a:s).cmpn(0)<0&&o.iadd(t),o},n.prototype.gcd=function(t){if(this.isZero())return t.abs();if(t.isZero())return this.abs();var e=this.clone(),r=t.clone();e.negative=0,r.negative=0;for(var i=0;e.isEven()&&r.isEven();i++)e.iushrn(1),r.iushrn(1);for(;;){for(;e.isEven();)e.iushrn(1);for(;r.isEven();)r.iushrn(1);var n=e.cmp(r);if(n<0){var o=e;e=r,r=o}else if(0===n||0===r.cmpn(1))break;e.isub(r)}return r.iushln(i)},n.prototype.invm=function(t){return this.egcd(t).a.umod(t)},n.prototype.isEven=function(){return 0==(1&this.words[0])},n.prototype.isOdd=function(){return 1==(1&this.words[0])},n.prototype.andln=function(t){return this.words[0]&t},n.prototype.bincn=function(t){r("number"==typeof t);var e=t%26,i=(t-e)/26,n=1<<e;if(this.length<=i)return this._expand(i+1),this.words[i]|=n,this;for(var o=n,a=i;0!==o&&a<this.length;a++){var s=0|this.words[a];o=(s+=o)>>>26,s&=67108863,this.words[a]=s}return 0!==o&&(this.words[a]=o,this.length++),this},n.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},n.prototype.cmpn=function(t){var e,i=t<0;if(0!==this.negative&&!i)return-1;if(0===this.negative&&i)return 1;if(this._strip(),this.length>1)e=1;else{i&&(t=-t),r(t<=67108863,"Number is too big");var n=0|this.words[0];e=n===t?0:n<t?-1:1}return 0!==this.negative?0|-e:e},n.prototype.cmp=function(t){if(0!==this.negative&&0===t.negative)return-1;if(0===this.negative&&0!==t.negative)return 1;var e=this.ucmp(t);return 0!==this.negative?0|-e:e},n.prototype.ucmp=function(t){if(this.length>t.length)return 1;if(this.length<t.length)return-1;for(var e=0,r=this.length-1;r>=0;r--){var i=0|this.words[r],n=0|t.words[r];if(i!==n){i<n?e=-1:i>n&&(e=1);break}}return e},n.prototype.gtn=function(t){return 1===this.cmpn(t)},n.prototype.gt=function(t){return 1===this.cmp(t)},n.prototype.gten=function(t){return this.cmpn(t)>=0},n.prototype.gte=function(t){return this.cmp(t)>=0},n.prototype.ltn=function(t){return-1===this.cmpn(t)},n.prototype.lt=function(t){return-1===this.cmp(t)},n.prototype.lten=function(t){return this.cmpn(t)<=0},n.prototype.lte=function(t){return this.cmp(t)<=0},n.prototype.eqn=function(t){return 0===this.cmpn(t)},n.prototype.eq=function(t){return 0===this.cmp(t)},n.red=function(t){return new E(t)},n.prototype.toRed=function(t){return r(!this.red,"Already a number in reduction context"),r(0===this.negative,"red works only with positives"),t.convertTo(this)._forceRed(t)},n.prototype.fromRed=function(){return r(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},n.prototype._forceRed=function(t){return this.red=t,this},n.prototype.forceRed=function(t){return r(!this.red,"Already a number in reduction context"),this._forceRed(t)},n.prototype.redAdd=function(t){return r(this.red,"redAdd works only with red numbers"),this.red.add(this,t)},n.prototype.redIAdd=function(t){return r(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,t)},n.prototype.redSub=function(t){return r(this.red,"redSub works only with red numbers"),this.red.sub(this,t)},n.prototype.redISub=function(t){return r(this.red,"redISub works only with red numbers"),this.red.isub(this,t)},n.prototype.redShl=function(t){return r(this.red,"redShl works only with red numbers"),this.red.shl(this,t)},n.prototype.redMul=function(t){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.mul(this,t)},n.prototype.redIMul=function(t){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.imul(this,t)},n.prototype.redSqr=function(){return r(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},n.prototype.redISqr=function(){return r(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},n.prototype.redSqrt=function(){return r(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},n.prototype.redInvm=function(){return r(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},n.prototype.redNeg=function(){return r(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},n.prototype.redPow=function(t){return r(this.red&&!t.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,t)};var w={k256:null,p224:null,p192:null,p25519:null};function v(t,e){this.name=t,this.p=new n(e,16),this.n=this.p.bitLength(),this.k=new n(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function b(){v.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function k(){v.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function M(){v.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function _(){v.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function E(t){if("string"==typeof t){var e=n._prime(t);this.m=e.p,this.prime=e}else r(t.gtn(1),"modulus must be greater than 1"),this.m=t,this.prime=null}function A(t){E.call(this,t),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new n(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)}v.prototype._tmp=function(){var t=new n(null);return t.words=new Array(Math.ceil(this.n/13)),t},v.prototype.ireduce=function(t){var e,r=t;do{this.split(r,this.tmp),e=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(e>this.n);var i=e<this.n?-1:r.ucmp(this.p);return 0===i?(r.words[0]=0,r.length=1):i>0?r.isub(this.p):void 0!==r.strip?r.strip():r._strip(),r},v.prototype.split=function(t,e){t.iushrn(this.n,0,e)},v.prototype.imulK=function(t){return t.imul(this.k)},i(b,v),b.prototype.split=function(t,e){for(var r=4194303,i=Math.min(t.length,9),n=0;n<i;n++)e.words[n]=t.words[n];if(e.length=i,t.length<=9)return t.words[0]=0,void(t.length=1);var o=t.words[9];for(e.words[e.length++]=o&r,n=10;n<t.length;n++){var a=0|t.words[n];t.words[n-10]=(a&r)<<4|o>>>22,o=a}o>>>=22,t.words[n-10]=o,0===o&&t.length>10?t.length-=10:t.length-=9},b.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var e=0,r=0;r<t.length;r++){var i=0|t.words[r];e+=977*i,t.words[r]=67108863&e,e=64*i+(e/67108864|0)}return 0===t.words[t.length-1]&&(t.length--,0===t.words[t.length-1]&&t.length--),t},i(k,v),i(M,v),i(_,v),_.prototype.imulK=function(t){for(var e=0,r=0;r<t.length;r++){var i=19*(0|t.words[r])+e,n=67108863&i;i>>>=26,t.words[r]=n,e=i}return 0!==e&&(t.words[t.length++]=e),t},n._prime=function(t){if(w[t])return w[t];var e;if("k256"===t)e=new b;else if("p224"===t)e=new k;else if("p192"===t)e=new M;else{if("p25519"!==t)throw new Error("Unknown prime "+t);e=new _}return w[t]=e,e},E.prototype._verify1=function(t){r(0===t.negative,"red works only with positives"),r(t.red,"red works only with red numbers")},E.prototype._verify2=function(t,e){r(0==(t.negative|e.negative),"red works only with positives"),r(t.red&&t.red===e.red,"red works only with red numbers")},E.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):(u(t,t.umod(this.m)._forceRed(this)),t)},E.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},E.prototype.add=function(t,e){this._verify2(t,e);var r=t.add(e);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},E.prototype.iadd=function(t,e){this._verify2(t,e);var r=t.iadd(e);return r.cmp(this.m)>=0&&r.isub(this.m),r},E.prototype.sub=function(t,e){this._verify2(t,e);var r=t.sub(e);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},E.prototype.isub=function(t,e){this._verify2(t,e);var r=t.isub(e);return r.cmpn(0)<0&&r.iadd(this.m),r},E.prototype.shl=function(t,e){return this._verify1(t),this.imod(t.ushln(e))},E.prototype.imul=function(t,e){return this._verify2(t,e),this.imod(t.imul(e))},E.prototype.mul=function(t,e){return this._verify2(t,e),this.imod(t.mul(e))},E.prototype.isqr=function(t){return this.imul(t,t.clone())},E.prototype.sqr=function(t){return this.mul(t,t)},E.prototype.sqrt=function(t){if(t.isZero())return t.clone();var e=this.m.andln(3);if(r(e%2==1),3===e){var i=this.m.add(new n(1)).iushrn(2);return this.pow(t,i)}for(var o=this.m.subn(1),a=0;!o.isZero()&&0===o.andln(1);)a++,o.iushrn(1);r(!o.isZero());var s=new n(1).toRed(this),h=s.redNeg(),u=this.m.subn(1).iushrn(1),l=this.m.bitLength();for(l=new n(2*l*l).toRed(this);0!==this.pow(l,u).cmp(h);)l.redIAdd(h);for(var c=this.pow(l,o),d=this.pow(t,o.addn(1).iushrn(1)),f=this.pow(t,o),m=a;0!==f.cmp(s);){for(var p=f,g=0;0!==p.cmp(s);g++)p=p.redSqr();r(g<m);var y=this.pow(c,new n(1).iushln(m-g-1));d=d.redMul(y),c=y.redSqr(),f=f.redMul(c),m=g}return d},E.prototype.invm=function(t){var e=t._invmp(this.m);return 0!==e.negative?(e.negative=0,this.imod(e).redNeg()):this.imod(e)},E.prototype.pow=function(t,e){if(e.isZero())return new n(1).toRed(this);if(0===e.cmpn(1))return t.clone();var r=new Array(16);r[0]=new n(1).toRed(this),r[1]=t;for(var i=2;i<r.length;i++)r[i]=this.mul(r[i-1],t);var o=r[0],a=0,s=0,h=e.bitLength()%26;for(0===h&&(h=26),i=e.length-1;i>=0;i--){for(var u=e.words[i],l=h-1;l>=0;l--){var c=u>>l&1;o!==r[0]&&(o=this.sqr(o)),0!==c||0!==a?(a<<=1,a|=c,(4===++s||0===i&&0===l)&&(o=this.mul(o,r[a]),s=0,a=0)):s=0}h=26}return o},E.prototype.convertTo=function(t){var e=t.umod(this.m);return e===t?e.clone():e},E.prototype.convertFrom=function(t){var e=t.clone();return e.red=null,e},n.mont=function(t){return new A(t)},i(A,E),A.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},A.prototype.convertFrom=function(t){var e=this.imod(t.mul(this.rinv));return e.red=null,e},A.prototype.imul=function(t,e){if(t.isZero()||e.isZero())return t.words[0]=0,t.length=1,t;var r=t.imul(e),i=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),n=r.isub(i).iushrn(this.shift),o=n;return n.cmp(this.m)>=0?o=n.isub(this.m):n.cmpn(0)<0&&(o=n.iadd(this.m)),o._forceRed(this)},A.prototype.mul=function(t,e){if(t.isZero()||e.isZero())return new n(0)._forceRed(this);var r=t.mul(e),i=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),o=r.isub(i).iushrn(this.shift),a=o;return o.cmp(this.m)>=0?a=o.isub(this.m):o.cmpn(0)<0&&(a=o.iadd(this.m)),a._forceRed(this)},A.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}(t,i)}));let Ls=!1,Fs=!1;const Us={debug:1,default:2,info:2,warning:3,error:4,off:5};let qs=Us.default,Vs=null;const Hs=function(){try{const t=[];if(["NFD","NFC","NFKD","NFKC"].forEach((e=>{try{if("test"!=="test".normalize(e))throw new Error("bad normalize")}catch(r){t.push(e)}})),t.length)throw new Error("missing "+t.join(", "));if(String.fromCharCode(233).normalize("NFD")!==String.fromCharCode(101,769))throw new Error("broken implementation")}catch(t){return t.message}return null}();var Gs,Zs;!function(t){t.DEBUG="DEBUG",t.INFO="INFO",t.WARNING="WARNING",t.ERROR="ERROR",t.OFF="OFF"}(Gs||(Gs={})),function(t){t.UNKNOWN_ERROR="UNKNOWN_ERROR",t.NOT_IMPLEMENTED="NOT_IMPLEMENTED",t.UNSUPPORTED_OPERATION="UNSUPPORTED_OPERATION",t.NETWORK_ERROR="NETWORK_ERROR",t.SERVER_ERROR="SERVER_ERROR",t.TIMEOUT="TIMEOUT",t.BUFFER_OVERRUN="BUFFER_OVERRUN",t.NUMERIC_FAULT="NUMERIC_FAULT",t.MISSING_NEW="MISSING_NEW",t.INVALID_ARGUMENT="INVALID_ARGUMENT",t.MISSING_ARGUMENT="MISSING_ARGUMENT",t.UNEXPECTED_ARGUMENT="UNEXPECTED_ARGUMENT",t.CALL_EXCEPTION="CALL_EXCEPTION",t.INSUFFICIENT_FUNDS="INSUFFICIENT_FUNDS",t.NONCE_EXPIRED="NONCE_EXPIRED",t.REPLACEMENT_UNDERPRICED="REPLACEMENT_UNDERPRICED",t.UNPREDICTABLE_GAS_LIMIT="UNPREDICTABLE_GAS_LIMIT",t.TRANSACTION_REPLACED="TRANSACTION_REPLACED",t.ACTION_REJECTED="ACTION_REJECTED"}(Zs||(Zs={}));const Ks="0123456789abcdef";class Js{constructor(t){Object.defineProperty(this,"version",{enumerable:!0,value:t,writable:!1})}_log(t,e){const r=t.toLowerCase();null==Us[r]&&this.throwArgumentError("invalid log level name","logLevel",t),qs>Us[r]||console.log.apply(console,e)}debug(...t){this._log(Js.levels.DEBUG,t)}info(...t){this._log(Js.levels.INFO,t)}warn(...t){this._log(Js.levels.WARNING,t)}makeError(t,e,r){if(Fs)return this.makeError("censored error",e,{});e||(e=Js.errors.UNKNOWN_ERROR),r||(r={});const i=[];Object.keys(r).forEach((t=>{const e=r[t];try{if(e instanceof Uint8Array){let r="";for(let t=0;t<e.length;t++)r+=Ks[e[t]>>4],r+=Ks[15&e[t]];i.push(t+"=Uint8Array(0x"+r+")")}else i.push(t+"="+JSON.stringify(e))}catch(e){i.push(t+"="+JSON.stringify(r[t].toString()))}})),i.push(`code=${e}`),i.push(`version=${this.version}`);const n=t;let o="";switch(e){case Zs.NUMERIC_FAULT:{o="NUMERIC_FAULT";const e=t;switch(e){case"overflow":case"underflow":case"division-by-zero":o+="-"+e;break;case"negative-power":case"negative-width":o+="-unsupported";break;case"unbound-bitwise-result":o+="-unbound-result"}break}case Zs.CALL_EXCEPTION:case Zs.INSUFFICIENT_FUNDS:case Zs.MISSING_NEW:case Zs.NONCE_EXPIRED:case Zs.REPLACEMENT_UNDERPRICED:case Zs.TRANSACTION_REPLACED:case Zs.UNPREDICTABLE_GAS_LIMIT:o=e}o&&(t+=" [ See: https://links.ethers.org/v5-errors-"+o+" ]"),i.length&&(t+=" ("+i.join(", ")+")");const a=new Error(t);return a.reason=n,a.code=e,Object.keys(r).forEach((function(t){a[t]=r[t]})),a}throwError(t,e,r){throw this.makeError(t,e,r)}throwArgumentError(t,e,r){return this.throwError(t,Js.errors.INVALID_ARGUMENT,{argument:e,value:r})}assert(t,e,r,i){t||this.throwError(e,r,i)}assertArgument(t,e,r,i){t||this.throwArgumentError(e,r,i)}checkNormalize(t){Hs&&this.throwError("platform missing String.prototype.normalize",Js.errors.UNSUPPORTED_OPERATION,{operation:"String.prototype.normalize",form:Hs})}checkSafeUint53(t,e){"number"==typeof t&&(null==e&&(e="value not safe"),(t<0||t>=9007199254740991)&&this.throwError(e,Js.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"out-of-safe-range",value:t}),t%1&&this.throwError(e,Js.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"non-integer",value:t}))}checkArgumentCount(t,e,r){r=r?": "+r:"",t<e&&this.throwError("missing argument"+r,Js.errors.MISSING_ARGUMENT,{count:t,expectedCount:e}),t>e&&this.throwError("too many arguments"+r,Js.errors.UNEXPECTED_ARGUMENT,{count:t,expectedCount:e})}checkNew(t,e){t!==Object&&null!=t||this.throwError("missing new",Js.errors.MISSING_NEW,{name:e.name})}checkAbstract(t,e){t===e?this.throwError("cannot instantiate abstract class "+JSON.stringify(e.name)+" directly; use a sub-class",Js.errors.UNSUPPORTED_OPERATION,{name:t.name,operation:"new"}):t!==Object&&null!=t||this.throwError("missing new",Js.errors.MISSING_NEW,{name:e.name})}static globalLogger(){return Vs||(Vs=new Js("logger/5.7.0")),Vs}static setCensorship(t,e){if(!t&&e&&this.globalLogger().throwError("cannot permanently disable censorship",Js.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"}),Ls){if(!t)return;this.globalLogger().throwError("error censorship permanent",Js.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"})}Fs=!!t,Ls=!!e}static setLogLevel(t){const e=Us[t.toLowerCase()];null!=e?qs=e:Js.globalLogger().warn("invalid log level - "+t)}static from(t){return new Js(t)}}Js.errors=Zs,Js.levels=Gs;const Ws=new Js("bytes/5.7.0");function Ys(t){return!!t.toHexString}function Qs(t){return t.slice||(t.slice=function(){const e=Array.prototype.slice.call(arguments);return Qs(new Uint8Array(Array.prototype.slice.apply(t,e)))}),t}function Xs(t){return"number"==typeof t&&t==t&&t%1==0}function th(t){if(null==t)return!1;if(t.constructor===Uint8Array)return!0;if("string"==typeof t)return!1;if(!Xs(t.length)||t.length<0)return!1;for(let e=0;e<t.length;e++){const r=t[e];if(!Xs(r)||r<0||r>=256)return!1}return!0}function eh(t,e){return!("string"!=typeof t||!t.match(/^0x[0-9A-Fa-f]*$/))&&(!e||t.length===2+2*e)}const rh="0123456789abcdef";function ih(t,e){if(e||(e={}),"number"==typeof t){Ws.checkSafeUint53(t,"invalid hexlify value");let e="";for(;t;)e=rh[15&t]+e,t=Math.floor(t/16);return e.length?(e.length%2&&(e="0"+e),"0x"+e):"0x00"}if("bigint"==typeof t)return(t=t.toString(16)).length%2?"0x0"+t:"0x"+t;if(e.allowMissingPrefix&&"string"==typeof t&&"0x"!==t.substring(0,2)&&(t="0x"+t),Ys(t))return t.toHexString();if(eh(t))return t.length%2&&("left"===e.hexPad?t="0x0"+t.substring(2):"right"===e.hexPad?t+="0":Ws.throwArgumentError("hex data is odd-length","value",t)),t.toLowerCase();if(th(t)){let e="0x";for(let r=0;r<t.length;r++){let i=t[r];e+=rh[(240&i)>>4]+rh[15&i]}return e}return Ws.throwArgumentError("invalid hexlify value","value",t)}function nh(t,e){for("string"!=typeof t?t=ih(t):eh(t)||Ws.throwArgumentError("invalid hex string","value",t),t.length>2*e+2&&Ws.throwArgumentError("value out of range","value",arguments[1]);t.length<2*e+2;)t="0x0"+t.substring(2);return t}const oh="bignumber/5.7.0";var ah=$s.BN;const sh=new Js(oh),hh={},uh=9007199254740991;let lh=!1;class ch{constructor(t,e){t!==hh&&sh.throwError("cannot call constructor directly; use BigNumber.from",Js.errors.UNSUPPORTED_OPERATION,{operation:"new (BigNumber)"}),this._hex=e,this._isBigNumber=!0,Object.freeze(this)}fromTwos(t){return fh(mh(this).fromTwos(t))}toTwos(t){return fh(mh(this).toTwos(t))}abs(){return"-"===this._hex[0]?ch.from(this._hex.substring(1)):this}add(t){return fh(mh(this).add(mh(t)))}sub(t){return fh(mh(this).sub(mh(t)))}div(t){return ch.from(t).isZero()&&ph("division-by-zero","div"),fh(mh(this).div(mh(t)))}mul(t){return fh(mh(this).mul(mh(t)))}mod(t){const e=mh(t);return e.isNeg()&&ph("division-by-zero","mod"),fh(mh(this).umod(e))}pow(t){const e=mh(t);return e.isNeg()&&ph("negative-power","pow"),fh(mh(this).pow(e))}and(t){const e=mh(t);return(this.isNegative()||e.isNeg())&&ph("unbound-bitwise-result","and"),fh(mh(this).and(e))}or(t){const e=mh(t);return(this.isNegative()||e.isNeg())&&ph("unbound-bitwise-result","or"),fh(mh(this).or(e))}xor(t){const e=mh(t);return(this.isNegative()||e.isNeg())&&ph("unbound-bitwise-result","xor"),fh(mh(this).xor(e))}mask(t){return(this.isNegative()||t<0)&&ph("negative-width","mask"),fh(mh(this).maskn(t))}shl(t){return(this.isNegative()||t<0)&&ph("negative-width","shl"),fh(mh(this).shln(t))}shr(t){return(this.isNegative()||t<0)&&ph("negative-width","shr"),fh(mh(this).shrn(t))}eq(t){return mh(this).eq(mh(t))}lt(t){return mh(this).lt(mh(t))}lte(t){return mh(this).lte(mh(t))}gt(t){return mh(this).gt(mh(t))}gte(t){return mh(this).gte(mh(t))}isNegative(){return"-"===this._hex[0]}isZero(){return mh(this).isZero()}toNumber(){try{return mh(this).toNumber()}catch(t){ph("overflow","toNumber",this.toString())}return null}toBigInt(){try{return BigInt(this.toString())}catch(t){}return sh.throwError("this platform does not support BigInt",Js.errors.UNSUPPORTED_OPERATION,{value:this.toString()})}toString(){return arguments.length>0&&(10===arguments[0]?lh||(lh=!0,sh.warn("BigNumber.toString does not accept any parameters; base-10 is assumed")):16===arguments[0]?sh.throwError("BigNumber.toString does not accept any parameters; use bigNumber.toHexString()",Js.errors.UNEXPECTED_ARGUMENT,{}):sh.throwError("BigNumber.toString does not accept parameters",Js.errors.UNEXPECTED_ARGUMENT,{})),mh(this).toString(10)}toHexString(){return this._hex}toJSON(t){return{type:"BigNumber",hex:this.toHexString()}}static from(t){if(t instanceof ch)return t;if("string"==typeof t)return t.match(/^-?0x[0-9a-f]+$/i)?new ch(hh,dh(t)):t.match(/^-?[0-9]+$/)?new ch(hh,dh(new ah(t))):sh.throwArgumentError("invalid BigNumber string","value",t);if("number"==typeof t)return t%1&&ph("underflow","BigNumber.from",t),(t>=uh||t<=-uh)&&ph("overflow","BigNumber.from",t),ch.from(String(t));const e=t;if("bigint"==typeof e)return ch.from(e.toString());if(th(e))return ch.from(ih(e));if(e)if(e.toHexString){const t=e.toHexString();if("string"==typeof t)return ch.from(t)}else{let t=e._hex;if(null==t&&"BigNumber"===e.type&&(t=e.hex),"string"==typeof t&&(eh(t)||"-"===t[0]&&eh(t.substring(1))))return ch.from(t)}return sh.throwArgumentError("invalid BigNumber value","value",t)}static isBigNumber(t){return!(!t||!t._isBigNumber)}}function dh(t){if("string"!=typeof t)return dh(t.toString(16));if("-"===t[0])return"-"===(t=t.substring(1))[0]&&sh.throwArgumentError("invalid hex","value",t),"0x00"===(t=dh(t))?t:"-"+t;if("0x"!==t.substring(0,2)&&(t="0x"+t),"0x"===t)return"0x00";for(t.length%2&&(t="0x0"+t.substring(2));t.length>4&&"0x00"===t.substring(0,4);)t="0x"+t.substring(4);return t}function fh(t){return ch.from(dh(t))}function mh(t){const e=ch.from(t).toHexString();return"-"===e[0]?new ah("-"+e.substring(3),16):new ah(e.substring(2),16)}function ph(t,e,r){const i={fault:t,operation:e};return null!=r&&(i.value=r),sh.throwError(t,Js.errors.NUMERIC_FAULT,i)}const gh=new Js(oh),yh={},wh=ch.from(0),vh=ch.from(-1);function bh(t,e,r,i){const n={fault:e,operation:r};return void 0!==i&&(n.value=i),gh.throwError(t,Js.errors.NUMERIC_FAULT,n)}let kh="0";for(;kh.length<256;)kh+=kh;function Mh(t){if("number"!=typeof t)try{t=ch.from(t).toNumber()}catch(t){}return"number"==typeof t&&t>=0&&t<=256&&!(t%1)?"1"+kh.substring(0,t):gh.throwArgumentError("invalid decimal size","decimals",t)}function _h(t,e){null==e&&(e=0);const r=Mh(e),i=(t=ch.from(t)).lt(wh);i&&(t=t.mul(vh));let n=t.mod(r).toString();for(;n.length<r.length-1;)n="0"+n;n=n.match(/^([0-9]*[1-9]|0)(0*)/)[1];const o=t.div(r).toString();return t=1===r.length?o:o+"."+n,i&&(t="-"+t),t}function Eh(t,e){null==e&&(e=0);const r=Mh(e);"string"==typeof t&&t.match(/^-?[0-9.]+$/)||gh.throwArgumentError("invalid decimal value","value",t);const i="-"===t.substring(0,1);i&&(t=t.substring(1)),"."===t&&gh.throwArgumentError("missing value","value",t);const n=t.split(".");n.length>2&&gh.throwArgumentError("too many decimal points","value",t);let o=n[0],a=n[1];for(o||(o="0"),a||(a="0");"0"===a[a.length-1];)a=a.substring(0,a.length-1);for(a.length>r.length-1&&bh("fractional component exceeds decimals","underflow","parseFixed"),""===a&&(a="0");a.length<r.length-1;)a+="0";const s=ch.from(o),h=ch.from(a);let u=s.mul(r).add(h);return i&&(u=u.mul(vh)),u}class Ah{constructor(t,e,r,i){t!==yh&&gh.throwError("cannot use FixedFormat constructor; use FixedFormat.from",Js.errors.UNSUPPORTED_OPERATION,{operation:"new FixedFormat"}),this.signed=e,this.width=r,this.decimals=i,this.name=(e?"":"u")+"fixed"+String(r)+"x"+String(i),this._multiplier=Mh(i),Object.freeze(this)}static from(t){if(t instanceof Ah)return t;"number"==typeof t&&(t=`fixed128x${t}`);let e=!0,r=128,i=18;if("string"==typeof t)if("fixed"===t);else if("ufixed"===t)e=!1;else{const n=t.match(/^(u?)fixed([0-9]+)x([0-9]+)$/);n||gh.throwArgumentError("invalid fixed format","format",t),e="u"!==n[1],r=parseInt(n[2]),i=parseInt(n[3])}else if(t){const n=(e,r,i)=>null==t[e]?i:(typeof t[e]!==r&&gh.throwArgumentError("invalid fixed format ("+e+" not "+r+")","format."+e,t[e]),t[e]);e=n("signed","boolean",e),r=n("width","number",r),i=n("decimals","number",i)}return r%8&&gh.throwArgumentError("invalid fixed format width (not byte aligned)","format.width",r),i>80&&gh.throwArgumentError("invalid fixed format (decimals too large)","format.decimals",i),new Ah(yh,e,r,i)}}class jh{constructor(t,e,r,i){t!==yh&&gh.throwError("cannot use FixedNumber constructor; use FixedNumber.from",Js.errors.UNSUPPORTED_OPERATION,{operation:"new FixedFormat"}),this.format=i,this._hex=e,this._value=r,this._isFixedNumber=!0,Object.freeze(this)}_checkFormat(t){this.format.name!==t.format.name&&gh.throwArgumentError("incompatible format; use fixedNumber.toFormat","other",t)}addUnsafe(t){this._checkFormat(t);const e=Eh(this._value,this.format.decimals),r=Eh(t._value,t.format.decimals);return jh.fromValue(e.add(r),this.format.decimals,this.format)}subUnsafe(t){this._checkFormat(t);const e=Eh(this._value,this.format.decimals),r=Eh(t._value,t.format.decimals);return jh.fromValue(e.sub(r),this.format.decimals,this.format)}mulUnsafe(t){this._checkFormat(t);const e=Eh(this._value,this.format.decimals),r=Eh(t._value,t.format.decimals);return jh.fromValue(e.mul(r).div(this.format._multiplier),this.format.decimals,this.format)}divUnsafe(t){this._checkFormat(t);const e=Eh(this._value,this.format.decimals),r=Eh(t._value,t.format.decimals);return jh.fromValue(e.mul(this.format._multiplier).div(r),this.format.decimals,this.format)}floor(){const t=this.toString().split(".");1===t.length&&t.push("0");let e=jh.from(t[0],this.format);const r=!t[1].match(/^(0*)$/);return this.isNegative()&&r&&(e=e.subUnsafe(xh.toFormat(e.format))),e}ceiling(){const t=this.toString().split(".");1===t.length&&t.push("0");let e=jh.from(t[0],this.format);const r=!t[1].match(/^(0*)$/);return!this.isNegative()&&r&&(e=e.addUnsafe(xh.toFormat(e.format))),e}round(t){null==t&&(t=0);const e=this.toString().split(".");if(1===e.length&&e.push("0"),(t<0||t>80||t%1)&&gh.throwArgumentError("invalid decimal count","decimals",t),e[1].length<=t)return this;const r=jh.from("1"+kh.substring(0,t),this.format),i=Sh.toFormat(this.format);return this.mulUnsafe(r).addUnsafe(i).floor().divUnsafe(r)}isZero(){return"0.0"===this._value||"0"===this._value}isNegative(){return"-"===this._value[0]}toString(){return this._value}toHexString(t){if(null==t)return this._hex;t%8&&gh.throwArgumentError("invalid byte width","width",t);return nh(ch.from(this._hex).fromTwos(this.format.width).toTwos(t).toHexString(),t/8)}toUnsafeFloat(){return parseFloat(this.toString())}toFormat(t){return jh.fromString(this._value,t)}static fromValue(t,e,r){return null!=r||null==e||function(t){return null!=t&&(ch.isBigNumber(t)||"number"==typeof t&&t%1==0||"string"==typeof t&&!!t.match(/^-?[0-9]+$/)||eh(t)||"bigint"==typeof t||th(t))}(e)||(r=e,e=null),null==e&&(e=0),null==r&&(r="fixed"),jh.fromString(_h(t,e),Ah.from(r))}static fromString(t,e){null==e&&(e="fixed");const r=Ah.from(e),i=Eh(t,r.decimals);!r.signed&&i.lt(wh)&&bh("unsigned value cannot be negative","overflow","value",t);let n=null;r.signed?n=i.toTwos(r.width).toHexString():(n=i.toHexString(),n=nh(n,r.width/8));const o=_h(i,r.decimals);return new jh(yh,n,o,r)}static fromBytes(t,e){null==e&&(e="fixed");const r=Ah.from(e);if(function(t,e){if(e||(e={}),"number"==typeof t){Ws.checkSafeUint53(t,"invalid arrayify value");const e=[];for(;t;)e.unshift(255&t),t=parseInt(String(t/256));return 0===e.length&&e.push(0),Qs(new Uint8Array(e))}if(e.allowMissingPrefix&&"string"==typeof t&&"0x"!==t.substring(0,2)&&(t="0x"+t),Ys(t)&&(t=t.toHexString()),eh(t)){let r=t.substring(2);r.length%2&&("left"===e.hexPad?r="0"+r:"right"===e.hexPad?r+="0":Ws.throwArgumentError("hex data is odd-length","value",t));const i=[];for(let t=0;t<r.length;t+=2)i.push(parseInt(r.substring(t,t+2),16));return Qs(new Uint8Array(i))}return th(t)?Qs(new Uint8Array(t)):Ws.throwArgumentError("invalid arrayify value","value",t)}(t).length>r.width/8)throw new Error("overflow");let i=ch.from(t);r.signed&&(i=i.fromTwos(r.width));const n=i.toTwos((r.signed?0:1)+r.width).toHexString(),o=_h(i,r.decimals);return new jh(yh,n,o,r)}static from(t,e){if("string"==typeof t)return jh.fromString(t,e);if(th(t))return jh.fromBytes(t,e);try{return jh.fromValue(t,0,e)}catch(t){if(t.code!==Js.errors.INVALID_ARGUMENT)throw t}return gh.throwArgumentError("invalid FixedNumber value","value",t)}static isFixedNumber(t){return!(!t||!t._isFixedNumber)}}const xh=jh.from(1),Sh=jh.from("0.5");let Nh=!1,Ih=!1;const Th={debug:1,default:2,info:2,warning:3,error:4,off:5};let Ch=Th.default,zh=null;const Oh=function(){try{const t=[];if(["NFD","NFC","NFKD","NFKC"].forEach((e=>{try{if("test"!=="test".normalize(e))throw new Error("bad normalize")}catch(r){t.push(e)}})),t.length)throw new Error("missing "+t.join(", "));if(String.fromCharCode(233).normalize("NFD")!==String.fromCharCode(101,769))throw new Error("broken implementation")}catch(t){return t.message}return null}();var Rh,Ph;!function(t){t.DEBUG="DEBUG",t.INFO="INFO",t.WARNING="WARNING",t.ERROR="ERROR",t.OFF="OFF"}(Rh||(Rh={})),function(t){t.UNKNOWN_ERROR="UNKNOWN_ERROR",t.NOT_IMPLEMENTED="NOT_IMPLEMENTED",t.UNSUPPORTED_OPERATION="UNSUPPORTED_OPERATION",t.NETWORK_ERROR="NETWORK_ERROR",t.SERVER_ERROR="SERVER_ERROR",t.TIMEOUT="TIMEOUT",t.BUFFER_OVERRUN="BUFFER_OVERRUN",t.NUMERIC_FAULT="NUMERIC_FAULT",t.MISSING_NEW="MISSING_NEW",t.INVALID_ARGUMENT="INVALID_ARGUMENT",t.MISSING_ARGUMENT="MISSING_ARGUMENT",t.UNEXPECTED_ARGUMENT="UNEXPECTED_ARGUMENT",t.CALL_EXCEPTION="CALL_EXCEPTION",t.INSUFFICIENT_FUNDS="INSUFFICIENT_FUNDS",t.NONCE_EXPIRED="NONCE_EXPIRED",t.REPLACEMENT_UNDERPRICED="REPLACEMENT_UNDERPRICED",t.UNPREDICTABLE_GAS_LIMIT="UNPREDICTABLE_GAS_LIMIT",t.TRANSACTION_REPLACED="TRANSACTION_REPLACED",t.ACTION_REJECTED="ACTION_REJECTED"}(Ph||(Ph={}));const Bh="0123456789abcdef";class Dh{constructor(t){Object.defineProperty(this,"version",{enumerable:!0,value:t,writable:!1})}_log(t,e){const r=t.toLowerCase();null==Th[r]&&this.throwArgumentError("invalid log level name","logLevel",t),Ch>Th[r]||console.log.apply(console,e)}debug(...t){this._log(Dh.levels.DEBUG,t)}info(...t){this._log(Dh.levels.INFO,t)}warn(...t){this._log(Dh.levels.WARNING,t)}makeError(t,e,r){if(Ih)return this.makeError("censored error",e,{});e||(e=Dh.errors.UNKNOWN_ERROR),r||(r={});const i=[];Object.keys(r).forEach((t=>{const e=r[t];try{if(e instanceof Uint8Array){let r="";for(let t=0;t<e.length;t++)r+=Bh[e[t]>>4],r+=Bh[15&e[t]];i.push(t+"=Uint8Array(0x"+r+")")}else i.push(t+"="+JSON.stringify(e))}catch(e){i.push(t+"="+JSON.stringify(r[t].toString()))}})),i.push(`code=${e}`),i.push(`version=${this.version}`);const n=t;let o="";switch(e){case Ph.NUMERIC_FAULT:{o="NUMERIC_FAULT";const e=t;switch(e){case"overflow":case"underflow":case"division-by-zero":o+="-"+e;break;case"negative-power":case"negative-width":o+="-unsupported";break;case"unbound-bitwise-result":o+="-unbound-result"}break}case Ph.CALL_EXCEPTION:case Ph.INSUFFICIENT_FUNDS:case Ph.MISSING_NEW:case Ph.NONCE_EXPIRED:case Ph.REPLACEMENT_UNDERPRICED:case Ph.TRANSACTION_REPLACED:case Ph.UNPREDICTABLE_GAS_LIMIT:o=e}o&&(t+=" [ See: https://links.ethers.org/v5-errors-"+o+" ]"),i.length&&(t+=" ("+i.join(", ")+")");const a=new Error(t);return a.reason=n,a.code=e,Object.keys(r).forEach((function(t){a[t]=r[t]})),a}throwError(t,e,r){throw this.makeError(t,e,r)}throwArgumentError(t,e,r){return this.throwError(t,Dh.errors.INVALID_ARGUMENT,{argument:e,value:r})}assert(t,e,r,i){t||this.throwError(e,r,i)}assertArgument(t,e,r,i){t||this.throwArgumentError(e,r,i)}checkNormalize(t){Oh&&this.throwError("platform missing String.prototype.normalize",Dh.errors.UNSUPPORTED_OPERATION,{operation:"String.prototype.normalize",form:Oh})}checkSafeUint53(t,e){"number"==typeof t&&(null==e&&(e="value not safe"),(t<0||t>=9007199254740991)&&this.throwError(e,Dh.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"out-of-safe-range",value:t}),t%1&&this.throwError(e,Dh.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"non-integer",value:t}))}checkArgumentCount(t,e,r){r=r?": "+r:"",t<e&&this.throwError("missing argument"+r,Dh.errors.MISSING_ARGUMENT,{count:t,expectedCount:e}),t>e&&this.throwError("too many arguments"+r,Dh.errors.UNEXPECTED_ARGUMENT,{count:t,expectedCount:e})}checkNew(t,e){t!==Object&&null!=t||this.throwError("missing new",Dh.errors.MISSING_NEW,{name:e.name})}checkAbstract(t,e){t===e?this.throwError("cannot instantiate abstract class "+JSON.stringify(e.name)+" directly; use a sub-class",Dh.errors.UNSUPPORTED_OPERATION,{name:t.name,operation:"new"}):t!==Object&&null!=t||this.throwError("missing new",Dh.errors.MISSING_NEW,{name:e.name})}static globalLogger(){return zh||(zh=new Dh("logger/5.7.0")),zh}static setCensorship(t,e){if(!t&&e&&this.globalLogger().throwError("cannot permanently disable censorship",Dh.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"}),Nh){if(!t)return;this.globalLogger().throwError("error censorship permanent",Dh.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"})}Ih=!!t,Nh=!!e}static setLogLevel(t){const e=Th[t.toLowerCase()];null!=e?Ch=e:Dh.globalLogger().warn("invalid log level - "+t)}static from(t){return new Dh(t)}}Dh.errors=Ph,Dh.levels=Rh;const $h=new Dh("units/5.7.0"),Lh=["wei","kwei","mwei","gwei","szabo","finney","ether"];let Fh=!1,Uh=!1;const qh={debug:1,default:2,info:2,warning:3,error:4,off:5};let Vh=qh.default,Hh=null;const Gh=function(){try{const t=[];if(["NFD","NFC","NFKD","NFKC"].forEach((e=>{try{if("test"!=="test".normalize(e))throw new Error("bad normalize")}catch(r){t.push(e)}})),t.length)throw new Error("missing "+t.join(", "));if(String.fromCharCode(233).normalize("NFD")!==String.fromCharCode(101,769))throw new Error("broken implementation")}catch(t){return t.message}return null}();var Zh,Kh;!function(t){t.DEBUG="DEBUG",t.INFO="INFO",t.WARNING="WARNING",t.ERROR="ERROR",t.OFF="OFF"}(Zh||(Zh={})),function(t){t.UNKNOWN_ERROR="UNKNOWN_ERROR",t.NOT_IMPLEMENTED="NOT_IMPLEMENTED",t.UNSUPPORTED_OPERATION="UNSUPPORTED_OPERATION",t.NETWORK_ERROR="NETWORK_ERROR",t.SERVER_ERROR="SERVER_ERROR",t.TIMEOUT="TIMEOUT",t.BUFFER_OVERRUN="BUFFER_OVERRUN",t.NUMERIC_FAULT="NUMERIC_FAULT",t.MISSING_NEW="MISSING_NEW",t.INVALID_ARGUMENT="INVALID_ARGUMENT",t.MISSING_ARGUMENT="MISSING_ARGUMENT",t.UNEXPECTED_ARGUMENT="UNEXPECTED_ARGUMENT",t.CALL_EXCEPTION="CALL_EXCEPTION",t.INSUFFICIENT_FUNDS="INSUFFICIENT_FUNDS",t.NONCE_EXPIRED="NONCE_EXPIRED",t.REPLACEMENT_UNDERPRICED="REPLACEMENT_UNDERPRICED",t.UNPREDICTABLE_GAS_LIMIT="UNPREDICTABLE_GAS_LIMIT",t.TRANSACTION_REPLACED="TRANSACTION_REPLACED",t.ACTION_REJECTED="ACTION_REJECTED"}(Kh||(Kh={}));const Jh="0123456789abcdef";class Wh{constructor(t){Object.defineProperty(this,"version",{enumerable:!0,value:t,writable:!1})}_log(t,e){const r=t.toLowerCase();null==qh[r]&&this.throwArgumentError("invalid log level name","logLevel",t),Vh>qh[r]||console.log.apply(console,e)}debug(...t){this._log(Wh.levels.DEBUG,t)}info(...t){this._log(Wh.levels.INFO,t)}warn(...t){this._log(Wh.levels.WARNING,t)}makeError(t,e,r){if(Uh)return this.makeError("censored error",e,{});e||(e=Wh.errors.UNKNOWN_ERROR),r||(r={});const i=[];Object.keys(r).forEach((t=>{const e=r[t];try{if(e instanceof Uint8Array){let r="";for(let t=0;t<e.length;t++)r+=Jh[e[t]>>4],r+=Jh[15&e[t]];i.push(t+"=Uint8Array(0x"+r+")")}else i.push(t+"="+JSON.stringify(e))}catch(e){i.push(t+"="+JSON.stringify(r[t].toString()))}})),i.push(`code=${e}`),i.push(`version=${this.version}`);const n=t;let o="";switch(e){case Kh.NUMERIC_FAULT:{o="NUMERIC_FAULT";const e=t;switch(e){case"overflow":case"underflow":case"division-by-zero":o+="-"+e;break;case"negative-power":case"negative-width":o+="-unsupported";break;case"unbound-bitwise-result":o+="-unbound-result"}break}case Kh.CALL_EXCEPTION:case Kh.INSUFFICIENT_FUNDS:case Kh.MISSING_NEW:case Kh.NONCE_EXPIRED:case Kh.REPLACEMENT_UNDERPRICED:case Kh.TRANSACTION_REPLACED:case Kh.UNPREDICTABLE_GAS_LIMIT:o=e}o&&(t+=" [ See: https://links.ethers.org/v5-errors-"+o+" ]"),i.length&&(t+=" ("+i.join(", ")+")");const a=new Error(t);return a.reason=n,a.code=e,Object.keys(r).forEach((function(t){a[t]=r[t]})),a}throwError(t,e,r){throw this.makeError(t,e,r)}throwArgumentError(t,e,r){return this.throwError(t,Wh.errors.INVALID_ARGUMENT,{argument:e,value:r})}assert(t,e,r,i){t||this.throwError(e,r,i)}assertArgument(t,e,r,i){t||this.throwArgumentError(e,r,i)}checkNormalize(t){Gh&&this.throwError("platform missing String.prototype.normalize",Wh.errors.UNSUPPORTED_OPERATION,{operation:"String.prototype.normalize",form:Gh})}checkSafeUint53(t,e){"number"==typeof t&&(null==e&&(e="value not safe"),(t<0||t>=9007199254740991)&&this.throwError(e,Wh.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"out-of-safe-range",value:t}),t%1&&this.throwError(e,Wh.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"non-integer",value:t}))}checkArgumentCount(t,e,r){r=r?": "+r:"",t<e&&this.throwError("missing argument"+r,Wh.errors.MISSING_ARGUMENT,{count:t,expectedCount:e}),t>e&&this.throwError("too many arguments"+r,Wh.errors.UNEXPECTED_ARGUMENT,{count:t,expectedCount:e})}checkNew(t,e){t!==Object&&null!=t||this.throwError("missing new",Wh.errors.MISSING_NEW,{name:e.name})}checkAbstract(t,e){t===e?this.throwError("cannot instantiate abstract class "+JSON.stringify(e.name)+" directly; use a sub-class",Wh.errors.UNSUPPORTED_OPERATION,{name:t.name,operation:"new"}):t!==Object&&null!=t||this.throwError("missing new",Wh.errors.MISSING_NEW,{name:e.name})}static globalLogger(){return Hh||(Hh=new Wh("logger/5.7.0")),Hh}static setCensorship(t,e){if(!t&&e&&this.globalLogger().throwError("cannot permanently disable censorship",Wh.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"}),Fh){if(!t)return;this.globalLogger().throwError("error censorship permanent",Wh.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"})}Uh=!!t,Fh=!!e}static setLogLevel(t){const e=qh[t.toLowerCase()];null!=e?Vh=e:Wh.globalLogger().warn("invalid log level - "+t)}static from(t){return new Wh(t)}}Wh.errors=Kh,Wh.levels=Zh;const Yh=new Wh("bytes/5.7.0");function Qh(t){return!!t.toHexString}function Xh(t){return t.slice||(t.slice=function(){const e=Array.prototype.slice.call(arguments);return Xh(new Uint8Array(Array.prototype.slice.apply(t,e)))}),t}function tu(t){return"number"==typeof t&&t==t&&t%1==0}function eu(t){if(null==t)return!1;if(t.constructor===Uint8Array)return!0;if("string"==typeof t)return!1;if(!tu(t.length)||t.length<0)return!1;for(let e=0;e<t.length;e++){const r=t[e];if(!tu(r)||r<0||r>=256)return!1}return!0}function ru(t,e){if(e||(e={}),"number"==typeof t){Yh.checkSafeUint53(t,"invalid arrayify value");const e=[];for(;t;)e.unshift(255&t),t=parseInt(String(t/256));return 0===e.length&&e.push(0),Xh(new Uint8Array(e))}if(e.allowMissingPrefix&&"string"==typeof t&&"0x"!==t.substring(0,2)&&(t="0x"+t),Qh(t)&&(t=t.toHexString()),nu(t)){let r=t.substring(2);r.length%2&&("left"===e.hexPad?r="0"+r:"right"===e.hexPad?r+="0":Yh.throwArgumentError("hex data is odd-length","value",t));const i=[];for(let t=0;t<r.length;t+=2)i.push(parseInt(r.substring(t,t+2),16));return Xh(new Uint8Array(i))}return eu(t)?Xh(new Uint8Array(t)):Yh.throwArgumentError("invalid arrayify value","value",t)}function iu(t){const e=t.map((t=>ru(t))),r=e.reduce(((t,e)=>t+e.length),0),i=new Uint8Array(r);return e.reduce(((t,e)=>(i.set(e,t),t+e.length)),0),Xh(i)}function nu(t,e){return!("string"!=typeof t||!t.match(/^0x[0-9A-Fa-f]*$/))&&(!e||t.length===2+2*e)}const ou="0123456789abcdef";function au(t,e){if(e||(e={}),"number"==typeof t){Yh.checkSafeUint53(t,"invalid hexlify value");let e="";for(;t;)e=ou[15&t]+e,t=Math.floor(t/16);return e.length?(e.length%2&&(e="0"+e),"0x"+e):"0x00"}if("bigint"==typeof t)return(t=t.toString(16)).length%2?"0x0"+t:"0x"+t;if(e.allowMissingPrefix&&"string"==typeof t&&"0x"!==t.substring(0,2)&&(t="0x"+t),Qh(t))return t.toHexString();if(nu(t))return t.length%2&&("left"===e.hexPad?t="0x0"+t.substring(2):"right"===e.hexPad?t+="0":Yh.throwArgumentError("hex data is odd-length","value",t)),t.toLowerCase();if(eu(t)){let e="0x";for(let r=0;r<t.length;r++){let i=t[r];e+=ou[(240&i)>>4]+ou[15&i]}return e}return Yh.throwArgumentError("invalid hexlify value","value",t)}function su(t){let e="0x";return t.forEach((t=>{e+=au(t).substring(2)})),e}function hu(t,e){for("string"!=typeof t?t=au(t):nu(t)||Yh.throwArgumentError("invalid hex string","value",t),t.length>2*e+2&&Yh.throwArgumentError("value out of range","value",arguments[1]);t.length<2*e+2;)t="0x0"+t.substring(2);return t}function uu(t){return"0x"+Kt.keccak_256(ru(t))}const lu=new Wh("strings/5.7.0");var cu,du;function fu(t,e,r,i,n){if(t===du.BAD_PREFIX||t===du.UNEXPECTED_CONTINUE){let t=0;for(let i=e+1;i<r.length&&r[i]>>6==2;i++)t++;return t}return t===du.OVERRUN?r.length-e-1:0}!function(t){t.current="",t.NFC="NFC",t.NFD="NFD",t.NFKC="NFKC",t.NFKD="NFKD"}(cu||(cu={})),function(t){t.UNEXPECTED_CONTINUE="unexpected continuation byte",t.BAD_PREFIX="bad codepoint prefix",t.OVERRUN="string overrun",t.MISSING_CONTINUE="missing continuation byte",t.OUT_OF_RANGE="out of UTF-8 range",t.UTF16_SURROGATE="UTF-16 surrogate",t.OVERLONG="overlong representation"}(du||(du={}));const mu=Object.freeze({error:function(t,e,r,i,n){return lu.throwArgumentError(`invalid codepoint at offset ${e}; ${t}`,"bytes",r)},ignore:fu,replace:function(t,e,r,i,n){return t===du.OVERLONG?(i.push(n),0):(i.push(65533),fu(t,e,r))}});function pu(t,e){null==e&&(e=mu.error),t=ru(t);const r=[];let i=0;for(;i<t.length;){const n=t[i++];if(n>>7==0){r.push(n);continue}let o=null,a=null;if(192==(224&n))o=1,a=127;else if(224==(240&n))o=2,a=2047;else{if(240!=(248&n)){i+=e(128==(192&n)?du.UNEXPECTED_CONTINUE:du.BAD_PREFIX,i-1,t,r);continue}o=3,a=65535}if(i-1+o>=t.length){i+=e(du.OVERRUN,i-1,t,r);continue}let s=n&(1<<8-o-1)-1;for(let n=0;n<o;n++){let n=t[i];if(128!=(192&n)){i+=e(du.MISSING_CONTINUE,i,t,r),s=null;break}s=s<<6|63&n,i++}null!==s&&(s>1114111?i+=e(du.OUT_OF_RANGE,i-1-o,t,r,s):s>=55296&&s<=57343?i+=e(du.UTF16_SURROGATE,i-1-o,t,r,s):s<=a?i+=e(du.OVERLONG,i-1-o,t,r,s):r.push(s))}return r}function gu(t,e=cu.current){e!=cu.current&&(lu.checkNormalize(),t=t.normalize(e));let r=[];for(let e=0;e<t.length;e++){const i=t.charCodeAt(e);if(i<128)r.push(i);else if(i<2048)r.push(i>>6|192),r.push(63&i|128);else if(55296==(64512&i)){e++;const n=t.charCodeAt(e);if(e>=t.length||56320!=(64512&n))throw new Error("invalid utf-8 string");const o=65536+((1023&i)<<10)+(1023&n);r.push(o>>18|240),r.push(o>>12&63|128),r.push(o>>6&63|128),r.push(63&o|128)}else r.push(i>>12|224),r.push(i>>6&63|128),r.push(63&i|128)}return ru(r)}function yu(t,e){return pu(t,e).map((t=>t<=65535?String.fromCharCode(t):(t-=65536,String.fromCharCode(55296+(t>>10&1023),56320+(1023&t))))).join("")}function wu(t){return uu(gu(t))}const vu="hash/5.7.0";function bu(t,e){null==e&&(e=1);const r=[],i=r.forEach,n=function(t,e){i.call(t,(function(t){e>0&&Array.isArray(t)?n(t,e-1):r.push(t)}))};return n(t,e),r}function ku(t){return function(t){let e=0;return()=>t[e++]}(function(t){let e=0;function r(){return t[e++]<<8|t[e++]}let i=r(),n=1,o=[0,1];for(let t=1;t<i;t++)o.push(n+=r());let a=r(),s=e;e+=a;let h=0,u=0;function l(){return 0==h&&(u=u<<8|t[e++],h=8),u>>--h&1}const c=Math.pow(2,31),d=c>>>1,f=d>>1,m=c-1;let p=0;for(let t=0;t<31;t++)p=p<<1|l();let g=[],y=0,w=c;for(;;){let t=Math.floor(((p-y+1)*n-1)/w),e=0,r=i;for(;r-e>1;){let i=e+r>>>1;t<o[i]?r=i:e=i}if(0==e)break;g.push(e);let a=y+Math.floor(w*o[e]/n),s=y+Math.floor(w*o[e+1]/n)-1;for(;0==((a^s)&d);)p=p<<1&m|l(),a=a<<1&m,s=s<<1&m|1;for(;a&~s&f;)p=p&d|p<<1&m>>>1|l(),a=a<<1^d,s=(s^d)<<1|d|1;y=a,w=1+s-a}let v=i-4;return g.map((e=>{switch(e-v){case 3:return v+65792+(t[s++]<<16|t[s++]<<8|t[s++]);case 2:return v+256+(t[s++]<<8|t[s++]);case 1:return v+t[s++];default:return e-1}}))}(t))}function Mu(t){return 1&t?~t>>1:t>>1}function _u(t,e){let r=Array(t);for(let i=0,n=-1;i<t;i++)r[i]=n+=1+e();return r}function Eu(t,e){let r=Array(t);for(let i=0,n=0;i<t;i++)r[i]=n+=Mu(e());return r}function Au(t,e){let r=_u(t(),t),i=t(),n=_u(i,t),o=function(t,e){let r=Array(t);for(let i=0;i<t;i++)r[i]=1+e();return r}(i,t);for(let t=0;t<i;t++)for(let e=0;e<o[t];e++)r.push(n[t]+e);return e?r.map((t=>e[t])):r}function ju(t,e,r){let i=Array(t).fill(void 0).map((()=>[]));for(let n=0;n<e;n++)Eu(t,r).forEach(((t,e)=>i[e].push(t)));return i}function xu(t,e){let r=1+e(),i=e(),n=function(t){let e=[];for(;;){let r=t();if(0==r)break;e.push(r)}return e}(e);return bu(ju(n.length,1+t,e).map(((t,e)=>{const o=t[0],a=t.slice(1);return Array(n[e]).fill(void 0).map(((t,e)=>{let n=e*i;return[o+e*r,a.map((t=>t+n))]}))})))}function Su(t,e){return ju(1+e(),1+t,e).map((t=>[t[0],t.slice(1)]))}const Nu=ku(function(t){t=atob(t);const e=[];for(let r=0;r<t.length;r++)e.push(t.charCodeAt(r));return ru(e)}("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==")),Iu=new Set(Au(Nu)),Tu=new Set(Au(Nu)),Cu=function(t){let e=[];for(;;){let r=t();if(0==r)break;e.push(xu(r,t))}for(;;){let r=t()-1;if(r<0)break;e.push(Su(r,t))}return function(t){const e={};for(let r=0;r<t.length;r++){const i=t[r];e[i[0]]=i[1]}return e}(bu(e))}(Nu),zu=function(t){let e=Au(t).sort(((t,e)=>t-e));return function r(){let i=[];for(;;){let n=Au(t,e);if(0==n.length)break;i.push({set:new Set(n),node:r()})}i.sort(((t,e)=>e.set.size-t.set.size));let n=t(),o=n%3;n=n/3|0;let a=!!(1&n);return n>>=1,{branches:i,valid:o,fe0f:a,save:1==n,check:2==n}}()}(Nu);function Ou(t){return function(t,e=cu.current){return pu(gu(t,e))}(t)}function Ru(t){return t.filter((t=>65039!=t))}function Pu(t){for(let e of t.split(".")){let t=Ou(e);try{for(let e=t.lastIndexOf(95)-1;e>=0;e--)if(95!==t[e])throw new Error("underscore only allowed at start");if(t.length>=4&&t.every((t=>t<128))&&45===t[2]&&45===t[3])throw new Error("invalid label extension")}catch(t){throw new Error(`Invalid label "${e}": ${t.message}`)}}return t}function Bu(t){return Pu(function(t,e){let r=Ou(t).reverse(),i=[];for(;r.length;){let t=Du(r);if(t){i.push(...e(t));continue}let n=r.pop();if(Iu.has(n)){i.push(n);continue}if(Tu.has(n))continue;let o=Cu[n];if(!o)throw new Error(`Disallowed codepoint: 0x${n.toString(16).toUpperCase()}`);i.push(...o)}return Pu(function(t){return t.normalize("NFC")}(String.fromCodePoint(...i)))}(t,Ru))}function Du(t,e){var r;let i,n,o=zu,a=[],s=t.length;for(e&&(e.length=0);s;){let h=t[--s];if(o=null===(r=o.branches.find((t=>t.set.has(h))))||void 0===r?void 0:r.node,!o)break;if(o.save)n=h;else if(o.check&&h===n)break;a.push(h),o.fe0f&&(a.push(65039),s>0&&65039==t[s-1]&&s--),o.valid&&(i=a.slice(),2==o.valid&&i.splice(1,1),e&&e.push(...t.slice(s).reverse()),t.length=s)}return i}const $u=new Wh(vu),Lu=new Uint8Array(32);function Fu(t){if(0===t.length)throw new Error("invalid ENS name; empty component");return t}function Uu(t){const e=gu(Bu(t)),r=[];if(0===t.length)return r;let i=0;for(let t=0;t<e.length;t++){46===e[t]&&(r.push(Fu(e.slice(i,t))),i=t+1)}if(i>=e.length)throw new Error("invalid ENS name; empty component");return r.push(Fu(e.slice(i))),r}function qu(t){return Uu(t).map((t=>yu(t))).join(".")}function Vu(t){"string"!=typeof t&&$u.throwArgumentError("invalid ENS name; not a string","name",t);let e=Lu;const r=Uu(t);for(;r.length;)e=uu(iu([e,uu(r.pop())]));return au(e)}Lu.fill(0);const Hu=new Wh("address/5.7.0");function Gu(t){nu(t,20)||Hu.throwArgumentError("invalid address","address",t);const e=(t=t.toLowerCase()).substring(2).split(""),r=new Uint8Array(40);for(let t=0;t<40;t++)r[t]=e[t].charCodeAt(0);const i=ru(uu(r));for(let t=0;t<40;t+=2)i[t>>1]>>4>=8&&(e[t]=e[t].toUpperCase()),(15&i[t>>1])>=8&&(e[t+1]=e[t+1].toUpperCase());return"0x"+e.join("")}const Zu={};for(let t=0;t<10;t++)Zu[String(t)]=String(t);for(let t=0;t<26;t++)Zu[String.fromCharCode(65+t)]=String(10+t);const Ku=Math.floor(function(t){return Math.log10?Math.log10(t):Math.log(t)/Math.LN10}(9007199254740991));function Ju(t){let e=null;if("string"!=typeof t&&Hu.throwArgumentError("invalid address","address",t),t.match(/^(0x)?[0-9a-fA-F]{40}$/))"0x"!==t.substring(0,2)&&(t="0x"+t),e=Gu(t),t.match(/([A-F].*[a-f])|([a-f].*[A-F])/)&&e!==t&&Hu.throwArgumentError("bad address checksum","address",t);else if(t.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)){for(t.substring(2,4)!==function(t){let e=(t=(t=t.toUpperCase()).substring(4)+t.substring(0,2)+"00").split("").map((t=>Zu[t])).join("");for(;e.length>=Ku;){let t=e.substring(0,Ku);e=parseInt(t,10)%97+e.substring(t.length)}let r=String(98-parseInt(e,10)%97);for(;r.length<2;)r="0"+r;return r}(t)&&Hu.throwArgumentError("bad icap checksum","address",t),r=t.substring(4),e=new ah(r,36).toString(16);e.length<40;)e="0"+e;e=Gu("0x"+e)}else Hu.throwArgumentError("invalid address","address",t);var r;return e}window&&window.__awaiter;const Wu=new Wh("properties/5.7.0");function Yu(t,e,r){Object.defineProperty(t,e,{enumerable:!0,value:r,writable:!1})}function Qu(t){const e={};for(const r in t)e[r]=t[r];return e}const Xu={bigint:!0,boolean:!0,function:!0,number:!0,string:!0};function tl(t){if(null==t||Xu[typeof t])return!0;if(Array.isArray(t)||"object"==typeof t){if(!Object.isFrozen(t))return!1;const e=Object.keys(t);for(let r=0;r<e.length;r++){let i=null;try{i=t[e[r]]}catch(t){continue}if(!tl(i))return!1}return!0}return Wu.throwArgumentError("Cannot deepCopy "+typeof t,"object",t)}function el(t){if(tl(t))return t;if(Array.isArray(t))return Object.freeze(t.map((t=>rl(t))));if("object"==typeof t){const e={};for(const r in t){const i=t[r];void 0!==i&&Yu(e,r,rl(i))}return e}return Wu.throwArgumentError("Cannot deepCopy "+typeof t,"object",t)}function rl(t){return el(t)}var il=window&&window.__awaiter||function(t,e,r,i){return new(r||(r=Promise))((function(n,o){function a(t){try{h(i.next(t))}catch(t){o(t)}}function s(t){try{h(i.throw(t))}catch(t){o(t)}}function h(t){var e;t.done?n(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(a,s)}h((i=i.apply(t,e||[])).next())}))};const nl=new Wh(vu),ol=new Uint8Array(32);ol.fill(0);const al=ch.from(-1),sl=ch.from(0),hl=ch.from(1),ul=ch.from("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");const ll=hu(hl.toHexString(),32),cl=hu(sl.toHexString(),32),dl={name:"string",version:"string",chainId:"uint256",verifyingContract:"address",salt:"bytes32"},fl=["name","version","chainId","verifyingContract","salt"];function ml(t){return function(e){return"string"!=typeof e&&nl.throwArgumentError(`invalid domain value for ${JSON.stringify(t)}`,`domain.${t}`,e),e}}const pl={name:ml("name"),version:ml("version"),chainId:function(t){try{return ch.from(t).toString()}catch(t){}return nl.throwArgumentError('invalid domain value for "chainId"',"domain.chainId",t)},verifyingContract:function(t){try{return Ju(t).toLowerCase()}catch(t){}return nl.throwArgumentError('invalid domain value "verifyingContract"',"domain.verifyingContract",t)},salt:function(t){try{const e=ru(t);if(32!==e.length)throw new Error("bad length");return au(e)}catch(t){}return nl.throwArgumentError('invalid domain value "salt"',"domain.salt",t)}};function gl(t){{const e=t.match(/^(u?)int(\d*)$/);if(e){const r=""===e[1],i=parseInt(e[2]||"256");(i%8!=0||i>256||e[2]&&e[2]!==String(i))&&nl.throwArgumentError("invalid numeric width","type",t);const n=ul.mask(r?i-1:i),o=r?n.add(hl).mul(al):sl;return function(e){const r=ch.from(e);return(r.lt(o)||r.gt(n))&&nl.throwArgumentError(`value out-of-bounds for ${t}`,"value",e),hu(r.toTwos(256).toHexString(),32)}}}{const e=t.match(/^bytes(\d+)$/);if(e){const r=parseInt(e[1]);return(0===r||r>32||e[1]!==String(r))&&nl.throwArgumentError("invalid bytes width","type",t),function(e){return ru(e).length!==r&&nl.throwArgumentError(`invalid length for ${t}`,"value",e),function(t){const e=ru(t),r=e.length%32;return r?su([e,ol.slice(r)]):au(e)}(e)}}}switch(t){case"address":return function(t){return hu(Ju(t),32)};case"bool":return function(t){return t?ll:cl};case"bytes":return function(t){return uu(t)};case"string":return function(t){return wu(t)}}return null}function yl(t,e){return`${t}(${e.map((({name:t,type:e})=>e+" "+t)).join(",")})`}class wl{constructor(t){Yu(this,"types",Object.freeze(rl(t))),Yu(this,"_encoderCache",{}),Yu(this,"_types",{});const e={},r={},i={};Object.keys(t).forEach((t=>{e[t]={},r[t]=[],i[t]={}}));for(const i in t){const n={};t[i].forEach((o=>{n[o.name]&&nl.throwArgumentError(`duplicate variable name ${JSON.stringify(o.name)} in ${JSON.stringify(i)}`,"types",t),n[o.name]=!0;const a=o.type.match(/^([^\x5b]*)(\x5b|$)/)[1];a===i&&nl.throwArgumentError(`circular type reference to ${JSON.stringify(a)}`,"types",t);gl(a)||(r[a]||nl.throwArgumentError(`unknown type ${JSON.stringify(a)}`,"types",t),r[a].push(i),e[i][a]=!0)}))}const n=Object.keys(r).filter((t=>0===r[t].length));0===n.length?nl.throwArgumentError("missing primary type","types",t):n.length>1&&nl.throwArgumentError(`ambiguous primary types or unused types: ${n.map((t=>JSON.stringify(t))).join(", ")}`,"types",t),Yu(this,"primaryType",n[0]),function n(o,a){a[o]&&nl.throwArgumentError(`circular type reference to ${JSON.stringify(o)}`,"types",t),a[o]=!0,Object.keys(e[o]).forEach((t=>{r[t]&&(n(t,a),Object.keys(a).forEach((e=>{i[e][t]=!0})))})),delete a[o]}(this.primaryType,{});for(const e in i){const r=Object.keys(i[e]);r.sort(),this._types[e]=yl(e,t[e])+r.map((e=>yl(e,t[e]))).join("")}}getEncoder(t){let e=this._encoderCache[t];return e||(e=this._encoderCache[t]=this._getEncoder(t)),e}_getEncoder(t){{const e=gl(t);if(e)return e}const e=t.match(/^(.*)(\x5b(\d*)\x5d)$/);if(e){const t=e[1],r=this.getEncoder(t),i=parseInt(e[3]);return e=>{i>=0&&e.length!==i&&nl.throwArgumentError("array length mismatch; expected length ${ arrayLength }","value",e);let n=e.map(r);return this._types[t]&&(n=n.map(uu)),uu(su(n))}}const r=this.types[t];if(r){const e=wu(this._types[t]);return t=>{const i=r.map((({name:e,type:r})=>{const i=this.getEncoder(r)(t[e]);return this._types[r]?uu(i):i}));return i.unshift(e),su(i)}}return nl.throwArgumentError(`unknown type: ${t}`,"type",t)}encodeType(t){const e=this._types[t];return e||nl.throwArgumentError(`unknown type: ${JSON.stringify(t)}`,"name",t),e}encodeData(t,e){return this.getEncoder(t)(e)}hashStruct(t,e){return uu(this.encodeData(t,e))}encode(t){return this.encodeData(this.primaryType,t)}hash(t){return this.hashStruct(this.primaryType,t)}_visit(t,e,r){if(gl(t))return r(t,e);const i=t.match(/^(.*)(\x5b(\d*)\x5d)$/);if(i){const t=i[1],n=parseInt(i[3]);return n>=0&&e.length!==n&&nl.throwArgumentError("array length mismatch; expected length ${ arrayLength }","value",e),e.map((e=>this._visit(t,e,r)))}const n=this.types[t];return n?n.reduce(((t,{name:i,type:n})=>(t[i]=this._visit(n,e[i],r),t)),{}):nl.throwArgumentError(`unknown type: ${t}`,"type",t)}visit(t,e){return this._visit(this.primaryType,t,e)}static from(t){return new wl(t)}static getPrimaryType(t){return wl.from(t).primaryType}static hashStruct(t,e,r){return wl.from(e).hashStruct(t,r)}static hashDomain(t){const e=[];for(const r in t){const i=dl[r];i||nl.throwArgumentError(`invalid typed-data domain key: ${JSON.stringify(r)}`,"domain",t),e.push({name:r,type:i})}return e.sort(((t,e)=>fl.indexOf(t.name)-fl.indexOf(e.name))),wl.hashStruct("EIP712Domain",{EIP712Domain:e},t)}static encode(t,e,r){return su(["0x1901",wl.hashDomain(t),wl.from(e).hash(r)])}static hash(t,e,r){return uu(wl.encode(t,e,r))}static resolveNames(t,e,r,i){return il(this,void 0,void 0,(function*(){t=Qu(t);const n={};t.verifyingContract&&!nu(t.verifyingContract,20)&&(n[t.verifyingContract]="0x");const o=wl.from(e);o.visit(r,((t,e)=>("address"!==t||nu(e,20)||(n[e]="0x"),e)));for(const t in n)n[t]=yield i(t);return t.verifyingContract&&n[t.verifyingContract]&&(t.verifyingContract=n[t.verifyingContract]),r=o.visit(r,((t,e)=>"address"===t&&n[e]?n[e]:e)),{domain:t,value:r}}))}static getPayload(t,e,r){wl.hashDomain(t);const i={},n=[];fl.forEach((e=>{const r=t[e];null!=r&&(i[e]=pl[e](r),n.push({name:e,type:dl[e]}))}));const o=wl.from(e),a=Qu(e);return a.EIP712Domain?nl.throwArgumentError("types must not contain EIP712Domain type","types.EIP712Domain",e):a.EIP712Domain=n,o.encode(r),{types:a,domain:i,primaryType:o.primaryType,message:o.visit(r,((t,e)=>{if(t.match(/^bytes(\d*)/))return au(ru(e));if(t.match(/^u?int/))return ch.from(e).toString();switch(t){case"address":return e.toLowerCase();case"bool":return!!e;case"string":return"string"!=typeof e&&nl.throwArgumentError("invalid string","value",e),e}return nl.throwArgumentError("unsupported type","type",t)}))}}}var vl=function(t){this.value=t},bl=Object.defineProperty({EnumType:vl},"__esModule",{value:!0}),kl=function(){function t(t){this.value=t}return t.prototype.toJSON=function(){return"$"+this.value},t}(),Ml=Object.defineProperty({VariableType:kl},"__esModule",{value:!0}),_l=a((function(t,e){function r(t){if(t instanceof bl.EnumType)return t.value;if(t instanceof Ml.VariableType)return"$"+t.value;if("object"!=typeof t||null===t)return JSON.stringify(t);if(Array.isArray(t))return"["+t.map((function(t){return r(t)})).join(", ")+"]";var e=Object.keys(t).map((function(e){return e+": "+r(t[e])})).join(", ");return"{"+e+"}"}function i(t,r){return-1==e.configFields.indexOf(t)&&-1==r.indexOf(t)}function n(t,e,o,a){Object.keys(t).filter((function(t){return i(t,a.ignoreFields)})).forEach((function(s){var h=t[s];if("object"==typeof h){if(Array.isArray(h)&&!(h=h.find((function(t){return t&&"object"==typeof t}))))return void o.push([""+s,e]);var u=Object.keys(h).filter((function(t){return i(t,a.ignoreFields)})).length>0,l="object"==typeof h.__args&&Object.keys(h.__args).length>0,c="object"==typeof h.__directives,d=h.__all_on instanceof Array,f="object"==typeof h.__on,m=""+s;if("string"==typeof h.__name&&(m=m+" "+h.__name),"string"==typeof h.__aliasFor&&(m=m+": "+h.__aliasFor),"object"==typeof h.__variables&&Object.keys(h.__variables).length>0)m=m+" ("+function(t){var e=[];for(var r in t)e.push("$"+r+": "+t[r]);return e.join(", ")}(h.__variables)+")";else if(l||c){var p="",g="";c&&(g=Object.entries(h.__directives).map((function(t){var e;return"@"+function(t){var e=Object.keys(t)[0],i=t[e];if("boolean"==typeof i||"object"==typeof i&&0===Object.keys(i).length)return e;if("object"==typeof i){var n=[];for(var o in i){var a=r(i[o]).replace(/"/g,"");n.push(o+": "+a)}return e+"("+n.join(", ")+")"}throw new Error("Unsupported type for directive: "+typeof i+". Types allowed: object, boolean.\nOffending object: "+JSON.stringify(t))}(((e={})[t[0]]=t[1],e))})).join(" ")),l&&(p="("+function(t){var e=[];for(var i in t)e.push(i+": "+r(t[i]));return e.join(", ")}(h.__args)+")"),m=m+" "+p+(c&&l?" ":"")+g}if(o.push([m+(u||f||d?" {":""),e]),n(h,e+1,o,a),d&&h.__all_on.forEach((function(t){o.push(["..."+t,e+1])})),f)(h.__on instanceof Array?h.__on:[h.__on]).forEach((function(t){var r=t.__typeName;o.push(["... on "+r+" {",e+1]),n(t,e+2,o,a),o.push(["}",e+1])}));(u||f||d)&&o.push(["}",e])}else(!0===a.includeFalsyKeys||h)&&o.push([""+s,e])}))}Object.defineProperty(e,"__esModule",{value:!0}),e.configFields=["__args","__alias","__aliasFor","__variables","__directives","__on","__all_on","__typeName","__name"],e.jsonToGraphQLQuery=function(t,e){if(void 0===e&&(e={}),!t||"object"!=typeof t)throw new Error("query object not specified");if(0==Object.keys(t).length)throw new Error("query object has no data");e.ignoreFields instanceof Array||(e.ignoreFields=[]);var r=[];n(t,0,r,e);var i="";return r.forEach((function(t){var r=t[0],n=t[1];e.pretty?(i&&(i+="\n"),i+=function(t){return Array(4*t+1).join(" ")}(n)+r):(i&&(i+=" "),i+=r)})),i}})),El=a((function(t,e){Object.defineProperty(e,"__esModule",{value:!0}),function(t){for(var r in t)e.hasOwnProperty(r)||(e[r]=t[r])}(_l),e.EnumType=bl.EnumType,e.VariableType=Ml.VariableType})),Al=a((function(t,e){Object.defineProperty(e,"__esModule",{value:!0}),e.regexpCode=e.getEsmExportName=e.getProperty=e.safeStringify=e.stringify=e.strConcat=e.addCodeArg=e.str=e._=e.nil=e._Code=e.Name=e.IDENTIFIER=e._CodeOrName=void 0;class r{}e._CodeOrName=r,e.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;class i extends r{constructor(t){if(super(),!e.IDENTIFIER.test(t))throw new Error("CodeGen: name must be a valid identifier");this.str=t}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}}e.Name=i;class n extends r{constructor(t){super(),this._items="string"==typeof t?[t]:t}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;const t=this._items[0];return""===t||'""'===t}get str(){var t;return null!==(t=this._str)&&void 0!==t?t:this._str=this._items.reduce(((t,e)=>`${t}${e}`),"")}get names(){var t;return null!==(t=this._names)&&void 0!==t?t:this._names=this._items.reduce(((t,e)=>(e instanceof i&&(t[e.str]=(t[e.str]||0)+1),t)),{})}}function o(t,...e){const r=[t[0]];let i=0;for(;i<e.length;)h(r,e[i]),r.push(t[++i]);return new n(r)}e._Code=n,e.nil=new n(""),e._=o;const a=new n("+");function s(t,...e){const r=[l(t[0])];let i=0;for(;i<e.length;)r.push(a),h(r,e[i]),r.push(a,l(t[++i]));return function(t){let e=1;for(;e<t.length-1;){if(t[e]===a){const r=u(t[e-1],t[e+1]);if(void 0!==r){t.splice(e-1,3,r);continue}t[e++]="+"}e++}}(r),new n(r)}function h(t,e){e instanceof n?t.push(...e._items):e instanceof i?t.push(e):t.push(function(t){return"number"==typeof t||"boolean"==typeof t||null===t?t:l(Array.isArray(t)?t.join(","):t)}(e))}function u(t,e){if('""'===e)return t;if('""'===t)return e;if("string"==typeof t){if(e instanceof i||'"'!==t[t.length-1])return;return"string"!=typeof e?`${t.slice(0,-1)}${e}"`:'"'===e[0]?t.slice(0,-1)+e.slice(1):void 0}return"string"!=typeof e||'"'!==e[0]||t instanceof i?void 0:`"${t}${e.slice(1)}`}function l(t){return JSON.stringify(t).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}e.str=s,e.addCodeArg=h,e.strConcat=function(t,e){return e.emptyStr()?t:t.emptyStr()?e:s`${t}${e}`},e.stringify=function(t){return new n(l(t))},e.safeStringify=l,e.getProperty=function(t){return"string"==typeof t&&e.IDENTIFIER.test(t)?new n(`.${t}`):o`[${t}]`},e.getEsmExportName=function(t){if("string"==typeof t&&e.IDENTIFIER.test(t))return new n(`${t}`);throw new Error(`CodeGen: invalid export name: ${t}, use explicit $id name mapping`)},e.regexpCode=function(t){return new n(t.toString())}})),jl=a((function(t,e){Object.defineProperty(e,"__esModule",{value:!0}),e.ValueScope=e.ValueScopeName=e.Scope=e.varKinds=e.UsedValueState=void 0;class r extends Error{constructor(t){super(`CodeGen: "code" for ${t} not defined`),this.value=t.value}}var i;!function(t){t[t.Started=0]="Started",t[t.Completed=1]="Completed"}(i=e.UsedValueState||(e.UsedValueState={})),e.varKinds={const:new Al.Name("const"),let:new Al.Name("let"),var:new Al.Name("var")};class n{constructor({prefixes:t,parent:e}={}){this._names={},this._prefixes=t,this._parent=e}toName(t){return t instanceof Al.Name?t:this.name(t)}name(t){return new Al.Name(this._newName(t))}_newName(t){return`${t}${(this._names[t]||this._nameGroup(t)).index++}`}_nameGroup(t){var e,r;if((null===(r=null===(e=this._parent)||void 0===e?void 0:e._prefixes)||void 0===r?void 0:r.has(t))||this._prefixes&&!this._prefixes.has(t))throw new Error(`CodeGen: prefix "${t}" is not allowed in this scope`);return this._names[t]={prefix:t,index:0}}}e.Scope=n;class o extends Al.Name{constructor(t,e){super(e),this.prefix=t}setValue(t,{property:e,itemIndex:r}){this.value=t,this.scopePath=Al._`.${new Al.Name(e)}[${r}]`}}e.ValueScopeName=o;const a=Al._`\n`;e.ValueScope=class extends n{constructor(t){super(t),this._values={},this._scope=t.scope,this.opts={...t,_n:t.lines?a:Al.nil}}get(){return this._scope}name(t){return new o(t,this._newName(t))}value(t,e){var r;if(void 0===e.ref)throw new Error("CodeGen: ref must be passed in value");const i=this.toName(t),{prefix:n}=i,o=null!==(r=e.key)&&void 0!==r?r:e.ref;let a=this._values[n];if(a){const t=a.get(o);if(t)return t}else a=this._values[n]=new Map;a.set(o,i);const s=this._scope[n]||(this._scope[n]=[]),h=s.length;return s[h]=e.ref,i.setValue(e,{property:n,itemIndex:h}),i}getValue(t,e){const r=this._values[t];if(r)return r.get(e)}scopeRefs(t,e=this._values){return this._reduceValues(e,(e=>{if(void 0===e.scopePath)throw new Error(`CodeGen: name "${e}" has no value`);return Al._`${t}${e.scopePath}`}))}scopeCode(t=this._values,e,r){return this._reduceValues(t,(t=>{if(void 0===t.value)throw new Error(`CodeGen: name "${t}" has no value`);return t.value.code}),e,r)}_reduceValues(t,n,o={},a){let s=Al.nil;for(const h in t){const u=t[h];if(!u)continue;const l=o[h]=o[h]||new Map;u.forEach((t=>{if(l.has(t))return;l.set(t,i.Started);let o=n(t);if(o){const r=this.opts.es5?e.varKinds.var:e.varKinds.const;s=Al._`${s}${r} ${t} = ${o};${this.opts._n}`}else{if(!(o=null==a?void 0:a(t)))throw new r(t);s=Al._`${s}${o}${this.opts._n}`}l.set(t,i.Completed)}))}return s}}})),xl=a((function(t,e){Object.defineProperty(e,"__esModule",{value:!0}),e.or=e.and=e.not=e.CodeGen=e.operators=e.varKinds=e.ValueScopeName=e.ValueScope=e.Scope=e.Name=e.regexpCode=e.stringify=e.getProperty=e.nil=e.strConcat=e.str=e._=void 0;var r=Al;Object.defineProperty(e,"_",{enumerable:!0,get:function(){return r._}}),Object.defineProperty(e,"str",{enumerable:!0,get:function(){return r.str}}),Object.defineProperty(e,"strConcat",{enumerable:!0,get:function(){return r.strConcat}}),Object.defineProperty(e,"nil",{enumerable:!0,get:function(){return r.nil}}),Object.defineProperty(e,"getProperty",{enumerable:!0,get:function(){return r.getProperty}}),Object.defineProperty(e,"stringify",{enumerable:!0,get:function(){return r.stringify}}),Object.defineProperty(e,"regexpCode",{enumerable:!0,get:function(){return r.regexpCode}}),Object.defineProperty(e,"Name",{enumerable:!0,get:function(){return r.Name}});var i=jl;Object.defineProperty(e,"Scope",{enumerable:!0,get:function(){return i.Scope}}),Object.defineProperty(e,"ValueScope",{enumerable:!0,get:function(){return i.ValueScope}}),Object.defineProperty(e,"ValueScopeName",{enumerable:!0,get:function(){return i.ValueScopeName}}),Object.defineProperty(e,"varKinds",{enumerable:!0,get:function(){return i.varKinds}}),e.operators={GT:new Al._Code(">"),GTE:new Al._Code(">="),LT:new Al._Code("<"),LTE:new Al._Code("<="),EQ:new Al._Code("==="),NEQ:new Al._Code("!=="),NOT:new Al._Code("!"),OR:new Al._Code("||"),AND:new Al._Code("&&"),ADD:new Al._Code("+")};class n{optimizeNodes(){return this}optimizeNames(t,e){return this}}class o extends n{constructor(t,e,r){super(),this.varKind=t,this.name=e,this.rhs=r}render({es5:t,_n:e}){const r=t?jl.varKinds.var:this.varKind,i=void 0===this.rhs?"":` = ${this.rhs}`;return`${r} ${this.name}${i};`+e}optimizeNames(t,e){if(t[this.name.str])return this.rhs&&(this.rhs=S(this.rhs,t,e)),this}get names(){return this.rhs instanceof Al._CodeOrName?this.rhs.names:{}}}class a extends n{constructor(t,e,r){super(),this.lhs=t,this.rhs=e,this.sideEffects=r}render({_n:t}){return`${this.lhs} = ${this.rhs};`+t}optimizeNames(t,e){if(!(this.lhs instanceof Al.Name)||t[this.lhs.str]||this.sideEffects)return this.rhs=S(this.rhs,t,e),this}get names(){return x(this.lhs instanceof Al.Name?{}:{...this.lhs.names},this.rhs)}}class s extends a{constructor(t,e,r,i){super(t,r,i),this.op=e}render({_n:t}){return`${this.lhs} ${this.op}= ${this.rhs};`+t}}class h extends n{constructor(t){super(),this.label=t,this.names={}}render({_n:t}){return`${this.label}:`+t}}class u extends n{constructor(t){super(),this.label=t,this.names={}}render({_n:t}){return`break${this.label?` ${this.label}`:""};`+t}}class l extends n{constructor(t){super(),this.error=t}render({_n:t}){return`throw ${this.error};`+t}get names(){return this.error.names}}class c extends n{constructor(t){super(),this.code=t}render({_n:t}){return`${this.code};`+t}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(t,e){return this.code=S(this.code,t,e),this}get names(){return this.code instanceof Al._CodeOrName?this.code.names:{}}}class d extends n{constructor(t=[]){super(),this.nodes=t}render(t){return this.nodes.reduce(((e,r)=>e+r.render(t)),"")}optimizeNodes(){const{nodes:t}=this;let e=t.length;for(;e--;){const r=t[e].optimizeNodes();Array.isArray(r)?t.splice(e,1,...r):r?t[e]=r:t.splice(e,1)}return t.length>0?this:void 0}optimizeNames(t,e){const{nodes:r}=this;let i=r.length;for(;i--;){const n=r[i];n.optimizeNames(t,e)||(N(t,n.names),r.splice(i,1))}return r.length>0?this:void 0}get names(){return this.nodes.reduce(((t,e)=>j(t,e.names)),{})}}class f extends d{render(t){return"{"+t._n+super.render(t)+"}"+t._n}}class m extends d{}class p extends f{}p.kind="else";class g extends f{constructor(t,e){super(e),this.condition=t}render(t){let e=`if(${this.condition})`+super.render(t);return this.else&&(e+="else "+this.else.render(t)),e}optimizeNodes(){super.optimizeNodes();const t=this.condition;if(!0===t)return this.nodes;let e=this.else;if(e){const t=e.optimizeNodes();e=this.else=Array.isArray(t)?new p(t):t}return e?!1===t?e instanceof g?e:e.nodes:this.nodes.length?this:new g(I(t),e instanceof g?[e]:e.nodes):!1!==t&&this.nodes.length?this:void 0}optimizeNames(t,e){var r;if(this.else=null===(r=this.else)||void 0===r?void 0:r.optimizeNames(t,e),super.optimizeNames(t,e)||this.else)return this.condition=S(this.condition,t,e),this}get names(){const t=super.names;return x(t,this.condition),this.else&&j(t,this.else.names),t}}g.kind="if";class y extends f{}y.kind="for";class w extends y{constructor(t){super(),this.iteration=t}render(t){return`for(${this.iteration})`+super.render(t)}optimizeNames(t,e){if(super.optimizeNames(t,e))return this.iteration=S(this.iteration,t,e),this}get names(){return j(super.names,this.iteration.names)}}class v extends y{constructor(t,e,r,i){super(),this.varKind=t,this.name=e,this.from=r,this.to=i}render(t){const e=t.es5?jl.varKinds.var:this.varKind,{name:r,from:i,to:n}=this;return`for(${e} ${r}=${i}; ${r}<${n}; ${r}++)`+super.render(t)}get names(){const t=x(super.names,this.from);return x(t,this.to)}}class b extends y{constructor(t,e,r,i){super(),this.loop=t,this.varKind=e,this.name=r,this.iterable=i}render(t){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(t)}optimizeNames(t,e){if(super.optimizeNames(t,e))return this.iterable=S(this.iterable,t,e),this}get names(){return j(super.names,this.iterable.names)}}class k extends f{constructor(t,e,r){super(),this.name=t,this.args=e,this.async=r}render(t){return`${this.async?"async ":""}function ${this.name}(${this.args})`+super.render(t)}}k.kind="func";class M extends d{render(t){return"return "+super.render(t)}}M.kind="return";class _ extends f{render(t){let e="try"+super.render(t);return this.catch&&(e+=this.catch.render(t)),this.finally&&(e+=this.finally.render(t)),e}optimizeNodes(){var t,e;return super.optimizeNodes(),null===(t=this.catch)||void 0===t||t.optimizeNodes(),null===(e=this.finally)||void 0===e||e.optimizeNodes(),this}optimizeNames(t,e){var r,i;return super.optimizeNames(t,e),null===(r=this.catch)||void 0===r||r.optimizeNames(t,e),null===(i=this.finally)||void 0===i||i.optimizeNames(t,e),this}get names(){const t=super.names;return this.catch&&j(t,this.catch.names),this.finally&&j(t,this.finally.names),t}}class E extends f{constructor(t){super(),this.error=t}render(t){return`catch(${this.error})`+super.render(t)}}E.kind="catch";class A extends f{render(t){return"finally"+super.render(t)}}A.kind="finally";function j(t,e){for(const r in e)t[r]=(t[r]||0)+(e[r]||0);return t}function x(t,e){return e instanceof Al._CodeOrName?j(t,e.names):t}function S(t,e,r){return t instanceof Al.Name?n(t):(i=t)instanceof Al._Code&&i._items.some((t=>t instanceof Al.Name&&1===e[t.str]&&void 0!==r[t.str]))?new Al._Code(t._items.reduce(((t,e)=>(e instanceof Al.Name&&(e=n(e)),e instanceof Al._Code?t.push(...e._items):t.push(e),t)),[])):t;var i;function n(t){const i=r[t.str];return void 0===i||1!==e[t.str]?t:(delete e[t.str],i)}}function N(t,e){for(const r in e)t[r]=(t[r]||0)-(e[r]||0)}function I(t){return"boolean"==typeof t||"number"==typeof t||null===t?!t:Al._`!${O(t)}`}e.CodeGen=class{constructor(t,e={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...e,_n:e.lines?"\n":""},this._extScope=t,this._scope=new jl.Scope({parent:t}),this._nodes=[new m]}toString(){return this._root.render(this.opts)}name(t){return this._scope.name(t)}scopeName(t){return this._extScope.name(t)}scopeValue(t,e){const r=this._extScope.value(t,e);return(this._values[r.prefix]||(this._values[r.prefix]=new Set)).add(r),r}getScopeValue(t,e){return this._extScope.getValue(t,e)}scopeRefs(t){return this._extScope.scopeRefs(t,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(t,e,r,i){const n=this._scope.toName(e);return void 0!==r&&i&&(this._constants[n.str]=r),this._leafNode(new o(t,n,r)),n}const(t,e,r){return this._def(jl.varKinds.const,t,e,r)}let(t,e,r){return this._def(jl.varKinds.let,t,e,r)}var(t,e,r){return this._def(jl.varKinds.var,t,e,r)}assign(t,e,r){return this._leafNode(new a(t,e,r))}add(t,r){return this._leafNode(new s(t,e.operators.ADD,r))}code(t){return"function"==typeof t?t():t!==Al.nil&&this._leafNode(new c(t)),this}object(...t){const e=["{"];for(const[r,i]of t)e.length>1&&e.push(","),e.push(r),(r!==i||this.opts.es5)&&(e.push(":"),(0,Al.addCodeArg)(e,i));return e.push("}"),new Al._Code(e)}if(t,e,r){if(this._blockNode(new g(t)),e&&r)this.code(e).else().code(r).endIf();else if(e)this.code(e).endIf();else if(r)throw new Error('CodeGen: "else" body without "then" body');return this}elseIf(t){return this._elseNode(new g(t))}else(){return this._elseNode(new p)}endIf(){return this._endBlockNode(g,p)}_for(t,e){return this._blockNode(t),e&&this.code(e).endFor(),this}for(t,e){return this._for(new w(t),e)}forRange(t,e,r,i,n=(this.opts.es5?jl.varKinds.var:jl.varKinds.let)){const o=this._scope.toName(t);return this._for(new v(n,o,e,r),(()=>i(o)))}forOf(t,e,r,i=jl.varKinds.const){const n=this._scope.toName(t);if(this.opts.es5){const t=e instanceof Al.Name?e:this.var("_arr",e);return this.forRange("_i",0,Al._`${t}.length`,(e=>{this.var(n,Al._`${t}[${e}]`),r(n)}))}return this._for(new b("of",i,n,e),(()=>r(n)))}forIn(t,e,r,i=(this.opts.es5?jl.varKinds.var:jl.varKinds.const)){if(this.opts.ownProperties)return this.forOf(t,Al._`Object.keys(${e})`,r);const n=this._scope.toName(t);return this._for(new b("in",i,n,e),(()=>r(n)))}endFor(){return this._endBlockNode(y)}label(t){return this._leafNode(new h(t))}break(t){return this._leafNode(new u(t))}return(t){const e=new M;if(this._blockNode(e),this.code(t),1!==e.nodes.length)throw new Error('CodeGen: "return" should have one node');return this._endBlockNode(M)}try(t,e,r){if(!e&&!r)throw new Error('CodeGen: "try" without "catch" and "finally"');const i=new _;if(this._blockNode(i),this.code(t),e){const t=this.name("e");this._currNode=i.catch=new E(t),e(t)}return r&&(this._currNode=i.finally=new A,this.code(r)),this._endBlockNode(E,A)}throw(t){return this._leafNode(new l(t))}block(t,e){return this._blockStarts.push(this._nodes.length),t&&this.code(t).endBlock(e),this}endBlock(t){const e=this._blockStarts.pop();if(void 0===e)throw new Error("CodeGen: not in self-balancing block");const r=this._nodes.length-e;if(r<0||void 0!==t&&r!==t)throw new Error(`CodeGen: wrong number of nodes: ${r} vs ${t} expected`);return this._nodes.length=e,this}func(t,e=Al.nil,r,i){return this._blockNode(new k(t,e,r)),i&&this.code(i).endFunc(),this}endFunc(){return this._endBlockNode(k)}optimize(t=1){for(;t-- >0;)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants)}_leafNode(t){return this._currNode.nodes.push(t),this}_blockNode(t){this._currNode.nodes.push(t),this._nodes.push(t)}_endBlockNode(t,e){const r=this._currNode;if(r instanceof t||e&&r instanceof e)return this._nodes.pop(),this;throw new Error(`CodeGen: not in block "${e?`${t.kind}/${e.kind}`:t.kind}"`)}_elseNode(t){const e=this._currNode;if(!(e instanceof g))throw new Error('CodeGen: "else" without "if"');return this._currNode=e.else=t,this}get _root(){return this._nodes[0]}get _currNode(){const t=this._nodes;return t[t.length-1]}set _currNode(t){const e=this._nodes;e[e.length-1]=t}},e.not=I;const T=z(e.operators.AND);e.and=function(...t){return t.reduce(T)};const C=z(e.operators.OR);function z(t){return(e,r)=>e===Al.nil?r:r===Al.nil?e:Al._`${O(e)} ${t} ${O(r)}`}function O(t){return t instanceof Al.Name?t:Al._`(${t})`}e.or=function(...t){return t.reduce(C)}})),Sl=a((function(t,e){function r(t,e=t.schema){const{opts:r,self:i}=t;if(!r.strictSchema)return;if("boolean"==typeof e)return;const n=i.RULES.keywords;for(const r in e)n[r]||c(t,`unknown keyword: "${r}"`)}function i(t,e){if("boolean"==typeof t)return!t;for(const r in t)if(e[r])return!0;return!1}function n(t){return"number"==typeof t?`${t}`:t.replace(/~/g,"~0").replace(/\//g,"~1")}function o(t){return t.replace(/~1/g,"/").replace(/~0/g,"~")}function a({mergeNames:t,mergeToName:e,mergeValues:r,resultToName:i}){return(n,o,a,s)=>{const h=void 0===a?o:a instanceof xl.Name?(o instanceof xl.Name?t(n,o,a):e(n,o,a),a):o instanceof xl.Name?(e(n,a,o),o):r(o,a);return s!==xl.Name||h instanceof xl.Name?h:i(n,h)}}function s(t,e){if(!0===e)return t.var("props",!0);const r=t.var("props",xl._`{}`);return void 0!==e&&h(t,r,e),r}function h(t,e,r){Object.keys(r).forEach((r=>t.assign(xl._`${e}${(0,xl.getProperty)(r)}`,!0)))}Object.defineProperty(e,"__esModule",{value:!0}),e.checkStrictMode=e.getErrorPath=e.Type=e.useFunc=e.setEvaluated=e.evaluatedPropsToName=e.mergeEvaluated=e.eachItem=e.unescapeJsonPointer=e.escapeJsonPointer=e.escapeFragment=e.unescapeFragment=e.schemaRefOrVal=e.schemaHasRulesButRef=e.schemaHasRules=e.checkUnknownRules=e.alwaysValidSchema=e.toHash=void 0,e.toHash=function(t){const e={};for(const r of t)e[r]=!0;return e},e.alwaysValidSchema=function(t,e){return"boolean"==typeof e?e:0===Object.keys(e).length||(r(t,e),!i(e,t.self.RULES.all))},e.checkUnknownRules=r,e.schemaHasRules=i,e.schemaHasRulesButRef=function(t,e){if("boolean"==typeof t)return!t;for(const r in t)if("$ref"!==r&&e.all[r])return!0;return!1},e.schemaRefOrVal=function({topSchemaRef:t,schemaPath:e},r,i,n){if(!n){if("number"==typeof r||"boolean"==typeof r)return r;if("string"==typeof r)return xl._`${r}`}return xl._`${t}${e}${(0,xl.getProperty)(i)}`},e.unescapeFragment=function(t){return o(decodeURIComponent(t))},e.escapeFragment=function(t){return encodeURIComponent(n(t))},e.escapeJsonPointer=n,e.unescapeJsonPointer=o,e.eachItem=function(t,e){if(Array.isArray(t))for(const r of t)e(r);else e(t)},e.mergeEvaluated={props:a({mergeNames:(t,e,r)=>t.if(xl._`${r} !== true && ${e} !== undefined`,(()=>{t.if(xl._`${e} === true`,(()=>t.assign(r,!0)),(()=>t.assign(r,xl._`${r} || {}`).code(xl._`Object.assign(${r}, ${e})`)))})),mergeToName:(t,e,r)=>t.if(xl._`${r} !== true`,(()=>{!0===e?t.assign(r,!0):(t.assign(r,xl._`${r} || {}`),h(t,r,e))})),mergeValues:(t,e)=>!0===t||{...t,...e},resultToName:s}),items:a({mergeNames:(t,e,r)=>t.if(xl._`${r} !== true && ${e} !== undefined`,(()=>t.assign(r,xl._`${e} === true ? true : ${r} > ${e} ? ${r} : ${e}`))),mergeToName:(t,e,r)=>t.if(xl._`${r} !== true`,(()=>t.assign(r,!0===e||xl._`${r} > ${e} ? ${r} : ${e}`))),mergeValues:(t,e)=>!0===t||Math.max(t,e),resultToName:(t,e)=>t.var("items",e)})},e.evaluatedPropsToName=s,e.setEvaluated=h;const u={};var l;function c(t,e,r=t.opts.strictSchema){if(r){if(e=`strict mode: ${e}`,!0===r)throw new Error(e);t.self.logger.warn(e)}}e.useFunc=function(t,e){return t.scopeValue("func",{ref:e,code:u[e.code]||(u[e.code]=new Al._Code(e.code))})},function(t){t[t.Num=0]="Num",t[t.Str=1]="Str"}(l=e.Type||(e.Type={})),e.getErrorPath=function(t,e,r){if(t instanceof xl.Name){const i=e===l.Num;return r?i?xl._`"[" + ${t} + "]"`:xl._`"['" + ${t} + "']"`:i?xl._`"/" + ${t}`:xl._`"/" + ${t}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return r?(0,xl.getProperty)(t).toString():"/"+n(t)},e.checkStrictMode=c}));var Nl={data:new xl.Name("data"),valCxt:new xl.Name("valCxt"),instancePath:new xl.Name("instancePath"),parentData:new xl.Name("parentData"),parentDataProperty:new xl.Name("parentDataProperty"),rootData:new xl.Name("rootData"),dynamicAnchors:new xl.Name("dynamicAnchors"),vErrors:new xl.Name("vErrors"),errors:new xl.Name("errors"),this:new xl.Name("this"),self:new xl.Name("self"),scope:new xl.Name("scope"),json:new xl.Name("json"),jsonPos:new xl.Name("jsonPos"),jsonLen:new xl.Name("jsonLen"),jsonPart:new xl.Name("jsonPart")},Il=Object.defineProperty({default:Nl},"__esModule",{value:!0}),Tl=a((function(t,e){function r(t,e){const r=t.const("err",e);t.if(xl._`${Il.default.vErrors} === null`,(()=>t.assign(Il.default.vErrors,xl._`[${r}]`)),xl._`${Il.default.vErrors}.push(${r})`),t.code(xl._`${Il.default.errors}++`)}function i(t,e){const{gen:r,validateName:i,schemaEnv:n}=t;n.$async?r.throw(xl._`new ${t.ValidationError}(${e})`):(r.assign(xl._`${i}.errors`,e),r.return(!1))}Object.defineProperty(e,"__esModule",{value:!0}),e.extendErrors=e.resetErrorsCount=e.reportExtraError=e.reportError=e.keyword$DataError=e.keywordError=void 0,e.keywordError={message:({keyword:t})=>xl.str`must pass "${t}" keyword validation`},e.keyword$DataError={message:({keyword:t,schemaType:e})=>e?xl.str`"${t}" keyword must be ${e} ($data)`:xl.str`"${t}" keyword is invalid ($data)`},e.reportError=function(t,n=e.keywordError,a,s){const{it:h}=t,{gen:u,compositeRule:l,allErrors:c}=h,d=o(t,n,a);(null!=s?s:l||c)?r(u,d):i(h,xl._`[${d}]`)},e.reportExtraError=function(t,n=e.keywordError,a){const{it:s}=t,{gen:h,compositeRule:u,allErrors:l}=s;r(h,o(t,n,a)),u||l||i(s,Il.default.vErrors)},e.resetErrorsCount=function(t,e){t.assign(Il.default.errors,e),t.if(xl._`${Il.default.vErrors} !== null`,(()=>t.if(e,(()=>t.assign(xl._`${Il.default.vErrors}.length`,e)),(()=>t.assign(Il.default.vErrors,null)))))},e.extendErrors=function({gen:t,keyword:e,schemaValue:r,data:i,errsCount:n,it:o}){if(void 0===n)throw new Error("ajv implementation error");const a=t.name("err");t.forRange("i",n,Il.default.errors,(n=>{t.const(a,xl._`${Il.default.vErrors}[${n}]`),t.if(xl._`${a}.instancePath === undefined`,(()=>t.assign(xl._`${a}.instancePath`,(0,xl.strConcat)(Il.default.instancePath,o.errorPath)))),t.assign(xl._`${a}.schemaPath`,xl.str`${o.errSchemaPath}/${e}`),o.opts.verbose&&(t.assign(xl._`${a}.schema`,r),t.assign(xl._`${a}.data`,i))}))};const n={keyword:new xl.Name("keyword"),schemaPath:new xl.Name("schemaPath"),params:new xl.Name("params"),propertyName:new xl.Name("propertyName"),message:new xl.Name("message"),schema:new xl.Name("schema"),parentSchema:new xl.Name("parentSchema")};function o(t,e,r){const{createErrors:i}=t.it;return!1===i?xl._`{}`:function(t,e,r={}){const{gen:i,it:o}=t,h=[a(o,r),s(t,r)];return function(t,{params:e,message:r},i){const{keyword:o,data:a,schemaValue:s,it:h}=t,{opts:u,propertyName:l,topSchemaRef:c,schemaPath:d}=h;i.push([n.keyword,o],[n.params,"function"==typeof e?e(t):e||xl._`{}`]),u.messages&&i.push([n.message,"function"==typeof r?r(t):r]);u.verbose&&i.push([n.schema,s],[n.parentSchema,xl._`${c}${d}`],[Il.default.data,a]);l&&i.push([n.propertyName,l])}(t,e,h),i.object(...h)}(t,e,r)}function a({errorPath:t},{instancePath:e}){const r=e?xl.str`${t}${(0,Sl.getErrorPath)(e,Sl.Type.Str)}`:t;return[Il.default.instancePath,(0,xl.strConcat)(Il.default.instancePath,r)]}function s({keyword:t,it:{errSchemaPath:e}},{schemaPath:r,parentSchema:i}){let o=i?e:xl.str`${e}/${t}`;return r&&(o=xl.str`${o}${(0,Sl.getErrorPath)(r,Sl.Type.Str)}`),[n.schemaPath,o]}})),Cl=a((function(t,e){Object.defineProperty(e,"__esModule",{value:!0}),e.boolOrEmptySchema=e.topBoolOrEmptySchema=void 0;const r={message:"boolean schema is false"};function i(t,e){const{gen:i,data:n}=t,o={gen:i,keyword:"false schema",data:n,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:t};(0,Tl.reportError)(o,r,void 0,e)}e.topBoolOrEmptySchema=function(t){const{gen:e,schema:r,validateName:n}=t;!1===r?i(t,!1):"object"==typeof r&&!0===r.$async?e.return(Il.default.data):(e.assign(xl._`${n}.errors`,null),e.return(!0))},e.boolOrEmptySchema=function(t,e){const{gen:r,schema:n}=t;!1===n?(r.var(e,!1),i(t)):r.var(e,!0)}})),zl=a((function(t,e){Object.defineProperty(e,"__esModule",{value:!0}),e.getRules=e.isJSONType=void 0;const r=new Set(["string","number","integer","boolean","null","object","array"]);e.isJSONType=function(t){return"string"==typeof t&&r.has(t)},e.getRules=function(){const t={number:{type:"number",rules:[]},string:{type:"string",rules:[]},array:{type:"array",rules:[]},object:{type:"object",rules:[]}};return{types:{...t,integer:!0,boolean:!0,null:!0},rules:[{rules:[]},t.number,t.string,t.array,t.object],post:{rules:[]},all:{},keywords:{}}}})),Ol=a((function(t,e){function r(t,e){return e.rules.some((e=>i(t,e)))}function i(t,e){var r;return void 0!==t[e.keyword]||(null===(r=e.definition.implements)||void 0===r?void 0:r.some((e=>void 0!==t[e])))}Object.defineProperty(e,"__esModule",{value:!0}),e.shouldUseRule=e.shouldUseGroup=e.schemaHasRulesForType=void 0,e.schemaHasRulesForType=function({schema:t,self:e},i){const n=e.RULES.types[i];return n&&!0!==n&&r(t,n)},e.shouldUseGroup=r,e.shouldUseRule=i})),Rl=a((function(t,e){var r;function i(t){const e=Array.isArray(t)?t:t?[t]:[];if(e.every(zl.isJSONType))return e;throw new Error("type must be JSONType or JSONType[]: "+e.join(","))}Object.defineProperty(e,"__esModule",{value:!0}),e.reportTypeError=e.checkDataTypes=e.checkDataType=e.coerceAndCheckDataType=e.getJSONTypes=e.getSchemaTypes=e.DataType=void 0,function(t){t[t.Correct=0]="Correct",t[t.Wrong=1]="Wrong"}(r=e.DataType||(e.DataType={})),e.getSchemaTypes=function(t){const e=i(t.type);if(e.includes("null")){if(!1===t.nullable)throw new Error("type: null contradicts nullable: false")}else{if(!e.length&&void 0!==t.nullable)throw new Error('"nullable" cannot be used without "type"');!0===t.nullable&&e.push("null")}return e},e.getJSONTypes=i,e.coerceAndCheckDataType=function(t,e){const{gen:i,data:o,opts:s}=t,u=function(t,e){return e?t.filter((t=>n.has(t)||"array"===e&&"array"===t)):[]}(e,s.coerceTypes),l=e.length>0&&!(0===u.length&&1===e.length&&(0,Ol.schemaHasRulesForType)(t,e[0]));if(l){const l=a(e,o,s.strictNumbers,r.Wrong);i.if(l,(()=>{u.length?function(t,e,r){const{gen:i,data:o,opts:s}=t,u=i.let("dataType",xl._`typeof ${o}`),l=i.let("coerced",xl._`undefined`);"array"===s.coerceTypes&&i.if(xl._`${u} == 'object' && Array.isArray(${o}) && ${o}.length == 1`,(()=>i.assign(o,xl._`${o}[0]`).assign(u,xl._`typeof ${o}`).if(a(e,o,s.strictNumbers),(()=>i.assign(l,o)))));i.if(xl._`${l} !== undefined`);for(const t of r)(n.has(t)||"array"===t&&"array"===s.coerceTypes)&&c(t);function c(t){switch(t){case"string":return void i.elseIf(xl._`${u} == "number" || ${u} == "boolean"`).assign(l,xl._`"" + ${o}`).elseIf(xl._`${o} === null`).assign(l,xl._`""`);case"number":return void i.elseIf(xl._`${u} == "boolean" || ${o} === null
24
+ var Kt=a((function(t){!function(){var e="input is invalid type",r="object"==typeof window,n=r?window:{};n.JS_SHA3_NO_WINDOW&&(r=!1);var o=!r&&"object"==typeof self;!n.JS_SHA3_NO_NODE_JS&&"object"==typeof process&&process.versions&&process.versions.node?n=i:o&&(n=self);var a=!n.JS_SHA3_NO_COMMON_JS&&t.exports,s=!n.JS_SHA3_NO_ARRAY_BUFFER&&"undefined"!=typeof ArrayBuffer,h="0123456789abcdef".split(""),u=[4,1024,262144,67108864],l=[0,8,16,24],c=[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],d=[224,256,384,512],f=[128,256],m=["hex","buffer","arrayBuffer","array","digest"],p={128:168,256:136};!n.JS_SHA3_NO_NODE_JS&&Array.isArray||(Array.isArray=function(t){return"[object Array]"===Object.prototype.toString.call(t)}),!s||!n.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,r){return function(i){return new T(t,e,t).update(i)[r]()}},y=function(t,e,r){return function(i,n){return new T(t,e,n).update(i)[r]()}},w=function(t,e,r){return function(e,i,n,o){return _["cshake"+t].update(e,i,n,o)[r]()}},v=function(t,e,r){return function(e,i,n,o){return _["kmac"+t].update(e,i,n,o)[r]()}},b=function(t,e,r,i){for(var n=0;n<m.length;++n){var o=m[n];t[o]=e(r,i,o)}return t},k=function(t,e){var r=g(t,e,"hex");return r.create=function(){return new T(t,e,t)},r.update=function(t){return r.create().update(t)},b(r,g,t,e)},M=[{name:"keccak",padding:[1,256,65536,16777216],bits:d,createMethod:k},{name:"sha3",padding:[6,1536,393216,100663296],bits:d,createMethod:k},{name:"shake",padding:[31,7936,2031616,520093696],bits:f,createMethod:function(t,e){var r=y(t,e,"hex");return r.create=function(r){return new T(t,e,r)},r.update=function(t,e){return r.create(e).update(t)},b(r,y,t,e)}},{name:"cshake",padding:u,bits:f,createMethod:function(t,e){var r=p[t],i=w(t,0,"hex");return i.create=function(i,n,o){return n||o?new T(t,e,i).bytepad([n,o],r):_["shake"+t].create(i)},i.update=function(t,e,r,n){return i.create(e,r,n).update(t)},b(i,w,t,e)}},{name:"kmac",padding:u,bits:f,createMethod:function(t,e){var r=p[t],i=v(t,0,"hex");return i.create=function(i,n,o){return new C(t,e,n).bytepad(["KMAC",o],r).bytepad([i],r)},i.update=function(t,e,r,n){return i.create(t,r,n).update(e)},b(i,v,t,e)}}],_={},E=[],A=0;A<M.length;++A)for(var j=M[A],x=j.bits,S=0;S<x.length;++S){var N=j.name+"_"+x[S];if(E.push(N),_[N]=j.createMethod(x[S],j.padding),"sha3"!==j.name){var I=j.name+x[S];E.push(I),_[I]=_[N]}}function T(t,e,r){this.blocks=[],this.s=[],this.padding=e,this.outputBits=r,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=r>>5,this.extraBytes=(31&r)>>3;for(var i=0;i<50;++i)this.s[i]=0}function C(t,e,r){T.call(this,t,e,r)}T.prototype.update=function(t){if(this.finalized)throw new Error("finalize already called");var r,i=typeof t;if("string"!==i){if("object"!==i)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);r=!0}for(var n,o,a=this.blocks,h=this.byteCount,u=t.length,c=this.blockCount,d=0,f=this.s;d<u;){if(this.reset)for(this.reset=!1,a[0]=this.block,n=1;n<c+1;++n)a[n]=0;if(r)for(n=this.start;d<u&&n<h;++d)a[n>>2]|=t[d]<<l[3&n++];else for(n=this.start;d<u&&n<h;++d)(o=t.charCodeAt(d))<128?a[n>>2]|=o<<l[3&n++]:o<2048?(a[n>>2]|=(192|o>>6)<<l[3&n++],a[n>>2]|=(128|63&o)<<l[3&n++]):o<55296||o>=57344?(a[n>>2]|=(224|o>>12)<<l[3&n++],a[n>>2]|=(128|o>>6&63)<<l[3&n++],a[n>>2]|=(128|63&o)<<l[3&n++]):(o=65536+((1023&o)<<10|1023&t.charCodeAt(++d)),a[n>>2]|=(240|o>>18)<<l[3&n++],a[n>>2]|=(128|o>>12&63)<<l[3&n++],a[n>>2]|=(128|o>>6&63)<<l[3&n++],a[n>>2]|=(128|63&o)<<l[3&n++]);if(this.lastByteIndex=n,n>=h){for(this.start=n-h,this.block=a[c],n=0;n<c;++n)f[n]^=a[n];z(f),this.reset=!0}else this.start=n}return this},T.prototype.encode=function(t,e){var r=255&t,i=1,n=[r];for(r=255&(t>>=8);r>0;)n.unshift(r),r=255&(t>>=8),++i;return e?n.push(i):n.unshift(i),this.update(n),n.length},T.prototype.encodeString=function(t){var r,i=typeof t;if("string"!==i){if("object"!==i)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);r=!0}var n=0,o=t.length;if(r)n=o;else for(var a=0;a<t.length;++a){var h=t.charCodeAt(a);h<128?n+=1:h<2048?n+=2:h<55296||h>=57344?n+=3:(h=65536+((1023&h)<<10|1023&t.charCodeAt(++a)),n+=4)}return n+=this.encode(8*n),this.update(t),n},T.prototype.bytepad=function(t,e){for(var r=this.encode(e),i=0;i<t.length;++i)r+=this.encodeString(t[i]);var n=e-r%e,o=[];return o.length=n,this.update(o),this},T.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var t=this.blocks,e=this.lastByteIndex,r=this.blockCount,i=this.s;if(t[e>>2]|=this.padding[3&e],this.lastByteIndex===this.byteCount)for(t[0]=t[r],e=1;e<r+1;++e)t[e]=0;for(t[r-1]|=2147483648,e=0;e<r;++e)i[e]^=t[e];z(i)}},T.prototype.toString=T.prototype.hex=function(){this.finalize();for(var t,e=this.blockCount,r=this.s,i=this.outputBlocks,n=this.extraBytes,o=0,a=0,s="";a<i;){for(o=0;o<e&&a<i;++o,++a)t=r[o],s+=h[t>>4&15]+h[15&t]+h[t>>12&15]+h[t>>8&15]+h[t>>20&15]+h[t>>16&15]+h[t>>28&15]+h[t>>24&15];a%e==0&&(z(r),o=0)}return n&&(t=r[o],s+=h[t>>4&15]+h[15&t],n>1&&(s+=h[t>>12&15]+h[t>>8&15]),n>2&&(s+=h[t>>20&15]+h[t>>16&15])),s},T.prototype.arrayBuffer=function(){this.finalize();var t,e=this.blockCount,r=this.s,i=this.outputBlocks,n=this.extraBytes,o=0,a=0,s=this.outputBits>>3;t=n?new ArrayBuffer(i+1<<2):new ArrayBuffer(s);for(var h=new Uint32Array(t);a<i;){for(o=0;o<e&&a<i;++o,++a)h[a]=r[o];a%e==0&&z(r)}return n&&(h[o]=r[o],t=t.slice(0,s)),t},T.prototype.buffer=T.prototype.arrayBuffer,T.prototype.digest=T.prototype.array=function(){this.finalize();for(var t,e,r=this.blockCount,i=this.s,n=this.outputBlocks,o=this.extraBytes,a=0,s=0,h=[];s<n;){for(a=0;a<r&&s<n;++a,++s)t=s<<2,e=i[a],h[t]=255&e,h[t+1]=e>>8&255,h[t+2]=e>>16&255,h[t+3]=e>>24&255;s%r==0&&z(i)}return o&&(t=s<<2,e=i[a],h[t]=255&e,o>1&&(h[t+1]=e>>8&255),o>2&&(h[t+2]=e>>16&255)),h},C.prototype=new T,C.prototype.finalize=function(){return this.encode(this.outputBits,!0),T.prototype.finalize.call(this)};var z=function(t){var e,r,i,n,o,a,s,h,u,l,d,f,m,p,g,y,w,v,b,k,M,_,E,A,j,x,S,N,I,T,C,z,O,R,P,B,D,$,L,F,U,q,V,H,G,Z,K,J,W,Y,Q,X,tt,et,rt,it,nt,ot,at,st,ht,ut,lt;for(i=0;i<48;i+=2)n=t[0]^t[10]^t[20]^t[30]^t[40],o=t[1]^t[11]^t[21]^t[31]^t[41],a=t[2]^t[12]^t[22]^t[32]^t[42],s=t[3]^t[13]^t[23]^t[33]^t[43],h=t[4]^t[14]^t[24]^t[34]^t[44],u=t[5]^t[15]^t[25]^t[35]^t[45],l=t[6]^t[16]^t[26]^t[36]^t[46],d=t[7]^t[17]^t[27]^t[37]^t[47],e=(f=t[8]^t[18]^t[28]^t[38]^t[48])^(a<<1|s>>>31),r=(m=t[9]^t[19]^t[29]^t[39]^t[49])^(s<<1|a>>>31),t[0]^=e,t[1]^=r,t[10]^=e,t[11]^=r,t[20]^=e,t[21]^=r,t[30]^=e,t[31]^=r,t[40]^=e,t[41]^=r,e=n^(h<<1|u>>>31),r=o^(u<<1|h>>>31),t[2]^=e,t[3]^=r,t[12]^=e,t[13]^=r,t[22]^=e,t[23]^=r,t[32]^=e,t[33]^=r,t[42]^=e,t[43]^=r,e=a^(l<<1|d>>>31),r=s^(d<<1|l>>>31),t[4]^=e,t[5]^=r,t[14]^=e,t[15]^=r,t[24]^=e,t[25]^=r,t[34]^=e,t[35]^=r,t[44]^=e,t[45]^=r,e=h^(f<<1|m>>>31),r=u^(m<<1|f>>>31),t[6]^=e,t[7]^=r,t[16]^=e,t[17]^=r,t[26]^=e,t[27]^=r,t[36]^=e,t[37]^=r,t[46]^=e,t[47]^=r,e=l^(n<<1|o>>>31),r=d^(o<<1|n>>>31),t[8]^=e,t[9]^=r,t[18]^=e,t[19]^=r,t[28]^=e,t[29]^=r,t[38]^=e,t[39]^=r,t[48]^=e,t[49]^=r,p=t[0],g=t[1],Z=t[11]<<4|t[10]>>>28,K=t[10]<<4|t[11]>>>28,N=t[20]<<3|t[21]>>>29,I=t[21]<<3|t[20]>>>29,st=t[31]<<9|t[30]>>>23,ht=t[30]<<9|t[31]>>>23,q=t[40]<<18|t[41]>>>14,V=t[41]<<18|t[40]>>>14,R=t[2]<<1|t[3]>>>31,P=t[3]<<1|t[2]>>>31,y=t[13]<<12|t[12]>>>20,w=t[12]<<12|t[13]>>>20,J=t[22]<<10|t[23]>>>22,W=t[23]<<10|t[22]>>>22,T=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,rt=t[4]<<30|t[5]>>>2,B=t[14]<<6|t[15]>>>26,D=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,Q=t[35]<<15|t[34]>>>17,z=t[45]<<29|t[44]>>>3,O=t[44]<<29|t[45]>>>3,A=t[6]<<28|t[7]>>>4,j=t[7]<<28|t[6]>>>4,it=t[17]<<23|t[16]>>>9,nt=t[16]<<23|t[17]>>>9,$=t[26]<<25|t[27]>>>7,L=t[27]<<25|t[26]>>>7,k=t[36]<<21|t[37]>>>11,M=t[37]<<21|t[36]>>>11,X=t[47]<<24|t[46]>>>8,tt=t[46]<<24|t[47]>>>8,H=t[8]<<27|t[9]>>>5,G=t[9]<<27|t[8]>>>5,x=t[18]<<20|t[19]>>>12,S=t[19]<<20|t[18]>>>12,ot=t[29]<<7|t[28]>>>25,at=t[28]<<7|t[29]>>>25,F=t[38]<<8|t[39]>>>24,U=t[39]<<8|t[38]>>>24,_=t[48]<<14|t[49]>>>18,E=t[49]<<14|t[48]>>>18,t[0]=p^~y&v,t[1]=g^~w&b,t[10]=A^~x&N,t[11]=j^~S&I,t[20]=R^~B&$,t[21]=P^~D&L,t[30]=H^~Z&J,t[31]=G^~K&W,t[40]=et^~it&ot,t[41]=rt^~nt&at,t[2]=y^~v&k,t[3]=w^~b&M,t[12]=x^~N&T,t[13]=S^~I&C,t[22]=B^~$&F,t[23]=D^~L&U,t[32]=Z^~J&Y,t[33]=K^~W&Q,t[42]=it^~ot&st,t[43]=nt^~at&ht,t[4]=v^~k&_,t[5]=b^~M&E,t[14]=N^~T&z,t[15]=I^~C&O,t[24]=$^~F&q,t[25]=L^~U&V,t[34]=J^~Y&X,t[35]=W^~Q&tt,t[44]=ot^~st&ut,t[45]=at^~ht&lt,t[6]=k^~_&p,t[7]=M^~E&g,t[16]=T^~z&A,t[17]=C^~O&j,t[26]=F^~q&R,t[27]=U^~V&P,t[36]=Y^~X&H,t[37]=Q^~tt&G,t[46]=st^~ut&et,t[47]=ht^~lt&rt,t[8]=_^~p&y,t[9]=E^~g&w,t[18]=z^~A&x,t[19]=O^~j&S,t[28]=q^~R&B,t[29]=V^~P&D,t[38]=X^~H&Z,t[39]=tt^~G&K,t[48]=ut^~et&it,t[49]=lt^~rt&nt,t[0]^=c[i],t[1]^=c[i+1]};if(a)t.exports=_;else for(A=0;A<E.length;++A)n[E[A]]=_[E[A]]}()}));function Jt(t){return"0x"+Kt.keccak_256(A(t))}const Wt=new w("rlp/5.6.1");function Yt(t){const e=[];for(;t;)e.unshift(255&t),t>>=8;return e}function Qt(t,e,r){let i=0;for(let n=0;n<r;n++)i=256*i+t[e+n];return i}function Xt(t){if(Array.isArray(t)){let e=[];if(t.forEach((function(t){e=e.concat(Xt(t))})),e.length<=55)return e.unshift(192+e.length),e;const r=Yt(e.length);return r.unshift(247+r.length),r.concat(e)}M(t)||Wt.throwArgumentError("RLP object must be BytesLike","object",t);const e=Array.prototype.slice.call(A(t));if(1===e.length&&e[0]<=127)return e;if(e.length<=55)return e.unshift(128+e.length),e;const r=Yt(e.length);return r.unshift(183+r.length),r.concat(e)}function te(t){return I(Xt(t))}function ee(t,e,r,i){const n=[];for(;r<e+1+i;){const o=re(t,r);n.push(o.result),(r+=o.consumed)>e+1+i&&Wt.throwError("child data too short",w.errors.BUFFER_OVERRUN,{})}return{consumed:1+i,result:n}}function re(t,e){if(0===t.length&&Wt.throwError("data too short",w.errors.BUFFER_OVERRUN,{}),t[e]>=248){const r=t[e]-247;e+1+r>t.length&&Wt.throwError("data short segment too short",w.errors.BUFFER_OVERRUN,{});const i=Qt(t,e+1,r);return e+1+r+i>t.length&&Wt.throwError("data long segment too short",w.errors.BUFFER_OVERRUN,{}),ee(t,e,e+1+r,r+i)}if(t[e]>=192){const r=t[e]-192;return e+1+r>t.length&&Wt.throwError("data array too short",w.errors.BUFFER_OVERRUN,{}),ee(t,e,e+1,r)}if(t[e]>=184){const r=t[e]-183;e+1+r>t.length&&Wt.throwError("data array too short",w.errors.BUFFER_OVERRUN,{});const i=Qt(t,e+1,r);e+1+r+i>t.length&&Wt.throwError("data array too short",w.errors.BUFFER_OVERRUN,{});return{consumed:1+r+i,result:I(t.slice(e+1+r,e+1+r+i))}}if(t[e]>=128){const r=t[e]-128;e+1+r>t.length&&Wt.throwError("data too short",w.errors.BUFFER_OVERRUN,{});return{consumed:1+r,result:I(t.slice(e+1,e+1+r))}}return{consumed:1,result:I(t[e])}}function ie(t){const e=A(t),r=re(e,0);return r.consumed!==e.length&&Wt.throwArgumentError("invalid rlp data","data",t),r.result}const ne=new w("address/5.6.1");function oe(t){S(t,20)||ne.throwArgumentError("invalid address","address",t);const e=(t=t.toLowerCase()).substring(2).split(""),r=new Uint8Array(40);for(let t=0;t<40;t++)r[t]=e[t].charCodeAt(0);const i=A(Jt(r));for(let t=0;t<40;t+=2)i[t>>1]>>4>=8&&(e[t]=e[t].toUpperCase()),(15&i[t>>1])>=8&&(e[t+1]=e[t+1].toUpperCase());return"0x"+e.join("")}const ae={};for(let t=0;t<10;t++)ae[String(t)]=String(t);for(let t=0;t<26;t++)ae[String.fromCharCode(65+t)]=String(10+t);const se=Math.floor(function(t){return Math.log10?Math.log10(t):Math.log(t)/Math.LN10}(9007199254740991));function he(t){let e=null;if("string"!=typeof t&&ne.throwArgumentError("invalid address","address",t),t.match(/^(0x)?[0-9a-fA-F]{40}$/))"0x"!==t.substring(0,2)&&(t="0x"+t),e=oe(t),t.match(/([A-F].*[a-f])|([a-f].*[A-F])/)&&e!==t&&ne.throwArgumentError("bad address checksum","address",t);else if(t.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)){for(t.substring(2,4)!==function(t){let e=(t=(t=t.toUpperCase()).substring(4)+t.substring(0,2)+"00").split("").map((t=>ae[t])).join("");for(;e.length>=se;){let t=e.substring(0,se);e=parseInt(t,10)%97+e.substring(t.length)}let r=String(98-parseInt(e,10)%97);for(;r.length<2;)r="0"+r;return r}(t)&&ne.throwArgumentError("bad icap checksum","address",t),r=t.substring(4),e=new Dt(r,36).toString(16);e.length<40;)e="0"+e;e=oe("0x"+e)}else ne.throwArgumentError("invalid address","address",t);var r;return e}function ue(t){try{return he(t),!0}catch(t){}return!1}function le(t){let e=null;try{e=he(t.from)}catch(e){ne.throwArgumentError("missing from address","transaction",t)}return he(C(Jt(te([e,x(A(qt.from(t.nonce).toHexString()))])),12))}const ce={Space:[{name:"from",type:"address"},{name:"space",type:"string"},{name:"timestamp",type:"uint64"},{name:"settings",type:"string"}]},de={Proposal:[{name:"from",type:"address"},{name:"space",type:"string"},{name:"timestamp",type:"uint64"},{name:"type",type:"string"},{name:"title",type:"string"},{name:"body",type:"string"},{name:"discussion",type:"string"},{name:"choices",type:"string[]"},{name:"labels",type:"string[]"},{name:"start",type:"uint64"},{name:"end",type:"uint64"},{name:"snapshot",type:"uint64"},{name:"plugins",type:"string"},{name:"privacy",type:"string"},{name:"app",type:"string"}]},fe={UpdateProposal:[{name:"proposal",type:"string"},{name:"from",type:"address"},{name:"space",type:"string"},{name:"timestamp",type:"uint64"},{name:"type",type:"string"},{name:"title",type:"string"},{name:"body",type:"string"},{name:"discussion",type:"string"},{name:"choices",type:"string[]"},{name:"labels",type:"string[]"},{name:"plugins",type:"string"},{name:"privacy",type:"string"}]},me={FlagProposal:[{name:"from",type:"address"},{name:"space",type:"string"},{name:"proposal",type:"string"},{name:"timestamp",type:"uint64"}]},pe={CancelProposal:[{name:"from",type:"address"},{name:"space",type:"string"},{name:"timestamp",type:"uint64"},{name:"proposal",type:"string"}]},ge={CancelProposal:[{name:"from",type:"address"},{name:"space",type:"string"},{name:"timestamp",type:"uint64"},{name:"proposal",type:"bytes32"}]},ye={Vote:[{name:"from",type:"address"},{name:"space",type:"string"},{name:"timestamp",type:"uint64"},{name:"proposal",type:"string"},{name:"choice",type:"uint32"},{name:"reason",type:"string"},{name:"app",type:"string"},{name:"metadata",type:"string"}]},we={Vote:[{name:"from",type:"address"},{name:"space",type:"string"},{name:"timestamp",type:"uint64"},{name:"proposal",type:"string"},{name:"choice",type:"uint32[]"},{name:"reason",type:"string"},{name:"app",type:"string"},{name:"metadata",type:"string"}]},ve={Vote:[{name:"from",type:"address"},{name:"space",type:"string"},{name:"timestamp",type:"uint64"},{name:"proposal",type:"string"},{name:"choice",type:"string"},{name:"reason",type:"string"},{name:"app",type:"string"},{name:"metadata",type:"string"}]},be={Vote:[{name:"from",type:"address"},{name:"space",type:"string"},{name:"timestamp",type:"uint64"},{name:"proposal",type:"bytes32"},{name:"choice",type:"uint32"},{name:"reason",type:"string"},{name:"app",type:"string"},{name:"metadata",type:"string"}]},ke={Vote:[{name:"from",type:"address"},{name:"space",type:"string"},{name:"timestamp",type:"uint64"},{name:"proposal",type:"bytes32"},{name:"choice",type:"uint32[]"},{name:"reason",type:"string"},{name:"app",type:"string"},{name:"metadata",type:"string"}]},Me={Vote:[{name:"from",type:"address"},{name:"space",type:"string"},{name:"timestamp",type:"uint64"},{name:"proposal",type:"bytes32"},{name:"choice",type:"string"},{name:"reason",type:"string"},{name:"app",type:"string"},{name:"metadata",type:"string"}]},_e={Follow:[{name:"from",type:"address"},{name:"network",type:"string"},{name:"space",type:"string"},{name:"timestamp",type:"uint64"}]},Ee={Unfollow:[{name:"from",type:"address"},{name:"network",type:"string"},{name:"space",type:"string"},{name:"timestamp",type:"uint64"}]},Ae={Subscribe:[{name:"from",type:"address"},{name:"space",type:"string"},{name:"timestamp",type:"uint64"}]},je={Unsubscribe:[{name:"from",type:"address"},{name:"space",type:"string"},{name:"timestamp",type:"uint64"}]},xe={Profile:[{name:"from",type:"address"},{name:"timestamp",type:"uint64"},{name:"profile",type:"string"}]},Se={Statement:[{name:"from",type:"address"},{name:"timestamp",type:"uint64"},{name:"space",type:"string"},{name:"about",type:"string"},{name:"statement",type:"string"},{name:"discourse",type:"string"},{name:"status",type:"string"},{name:"network",type:"string"}]},Ne={Alias:[{name:"from",type:"address"},{name:"alias",type:"address"},{name:"timestamp",type:"uint64"}]},Ie={DeleteSpace:[{name:"from",type:"address"},{name:"space",type:"string"},{name:"timestamp",type:"uint64"}]};var Te={hub:"https://hub.snapshot.org",sequencer:"https://seq.snapshot.org"},Ce={hub:"https://testnet.hub.snapshot.org",sequencer:"https://testnet.seq.snapshot.org"},ze={hub:"http://localhost:3000",sequencer:"http://localhost:3001"};const Oe={name:"snapshot",version:"0.1.4"};class Re{constructor(t=Te.sequencer,e={}){t=(t=(t=t.replace(Te.hub,Te.sequencer)).replace(Ce.hub,Ce.sequencer)).replace(ze.hub,ze.sequencer),this.address=t,this.options=e}sign(t,e,i,n){return r(this,void 0,void 0,(function*(){var r;const o=(null==t?void 0:t.getSigner)?t.getSigner():t,a=he(e);i.from=i.from?he(i.from):a,i.timestamp||(i.timestamp=parseInt((Date.now()/1e3).toFixed()));const s=Object.assign({},Oe);"undefined"!=typeof window&&(null===(r=window.ethereum)||void 0===r?void 0:r.isTrust)&&(s.chainId=(yield o.provider.getNetwork()).chainId);const h={domain:s,types:n,message:i},u=yield o._signTypedData(s,h.types,i);return yield this.send({address:a,sig:u,data:h})}))}send(t){return r(this,void 0,void 0,(function*(){let e=this.address;"0x"===t.sig&&this.options.relayerURL&&(e=this.options.relayerURL);const r={method:"POST",headers:{Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify(t)};return new Promise(((t,i)=>{h(e,r).then((e=>{var r;if(e.ok)return t(e.json());if(null===(r=e.headers.get("content-type"))||void 0===r?void 0:r.includes("application/json"))return e.json().then(i).catch(i);throw e})).catch(i)}))}))}space(t,e,i){return r(this,void 0,void 0,(function*(){return yield this.sign(t,e,i,ce)}))}proposal(t,e,i){return r(this,void 0,void 0,(function*(){return i.labels||(i.labels=[]),i.discussion||(i.discussion=""),i.app||(i.app=""),i.privacy||(i.privacy=""),yield this.sign(t,e,i,de)}))}updateProposal(t,e,i){return r(this,void 0,void 0,(function*(){return i.privacy||(i.privacy=""),yield this.sign(t,e,i,fe)}))}flagProposal(t,e,i){return r(this,void 0,void 0,(function*(){return yield this.sign(t,e,i,me)}))}cancelProposal(t,e,i){return r(this,void 0,void 0,(function*(){const r=i.proposal.startsWith("0x");return yield this.sign(t,e,i,r?ge:pe)}))}vote(t,e,i){return r(this,void 0,void 0,(function*(){const r="shutter"===(null==i?void 0:i.privacy);i.reason||(i.reason=""),i.app||(i.app=""),i.metadata||(i.metadata="{}");const n=i.proposal.startsWith("0x");let o=n?be:ye;return["approval","ranked-choice"].includes(i.type)&&(o=n?ke:we),!r&&["quadratic","weighted"].includes(i.type)&&(o=n?Me:ve,i.choice=JSON.stringify(i.choice)),r&&(o=n?Me:ve),delete i.privacy,delete i.type,yield this.sign(t,e,i,o)}))}follow(t,e,i){return r(this,void 0,void 0,(function*(){return yield this.sign(t,e,i,_e)}))}unfollow(t,e,i){return r(this,void 0,void 0,(function*(){return yield this.sign(t,e,i,Ee)}))}subscribe(t,e,i){return r(this,void 0,void 0,(function*(){return yield this.sign(t,e,i,Ae)}))}unsubscribe(t,e,i){return r(this,void 0,void 0,(function*(){return yield this.sign(t,e,i,je)}))}profile(t,e,i){return r(this,void 0,void 0,(function*(){return yield this.sign(t,e,i,xe)}))}statement(t,e,i){return r(this,void 0,void 0,(function*(){return yield this.sign(t,e,i,Se)}))}alias(t,e,i){return r(this,void 0,void 0,(function*(){return yield this.sign(t,e,i,Ne)}))}deleteSpace(t,e,i){return r(this,void 0,void 0,(function*(){return yield this.sign(t,e,i,Ie)}))}}var Pe={$schema:"http://json-schema.org/draft-07/schema#",$ref:"#/definitions/Proposal",definitions:{Proposal:{title:"Proposal",type:"object",properties:{name:{type:"string",title:"name",minLength:1,maxLength:256},body:{type:"string",title:"body",minLength:0},discussion:{type:"string",format:"customUrl",title:"discussion",maxLength:256},choices:{type:"array",title:"choices",minItems:1},labels:{type:"array",title:"labels",maxItems:10,uniqueItems:!0,items:{type:"string",minLength:1,maxLength:8,pattern:"^[a-zA-Z0-9]+$"}},type:{type:"string",enum:["single-choice","approval","ranked-choice","quadratic","copeland","weighted","custom","basic"]},snapshot:{type:"number",title:"snapshot"},start:{type:"number",title:"start",minimum:1e9,maximum:2e9},end:{type:"number",title:"end",minimum:1e9,maximum:2e9},metadata:{type:"object",title:"metadata"},app:{type:"string",title:"app",maxLength:24},privacy:{type:"string",enum:["","shutter"]}},required:["name","body","choices","snapshot","start","end"],additionalProperties:!1}}},Be={$schema:"http://json-schema.org/draft-07/schema#",$ref:"#/definitions/UpdateProposal",definitions:{UpdateProposal:{title:"Update Proposal",type:"object",properties:{proposal:{type:"string",title:"proposal id"},name:{type:"string",title:"name",minLength:1,maxLength:256},body:{type:"string",title:"body",minLength:0},discussion:{type:"string",format:"customUrl",title:"discussion",maxLength:256},choices:{type:"array",title:"choices",minItems:1},labels:{type:"array",title:"labels",maxItems:10,uniqueItems:!0,items:{type:"string",minLength:1,maxLength:8,pattern:"^[a-zA-Z0-9]+$"}},type:{enum:["single-choice","approval","ranked-choice","quadratic","weighted","custom","basic"]},metadata:{type:"object",title:"metadata"},privacy:{type:"string",enum:["","shutter"]}},required:["proposal","name","body","discussion","choices","type","metadata"],additionalProperties:!1}}},De={$schema:"http://json-schema.org/draft-07/schema#",$ref:"#/definitions/Vote",definitions:{Vote:{title:"Vote",type:"object",properties:{proposal:{type:"string",title:"proposal"},choice:{type:["number","array","object","boolean","string"],title:"choice"},metadata:{type:"object",title:"metadata"},reason:{type:"string",title:"reason",maxLength:5e3},app:{type:"string",title:"app",maxLength:24}},required:["proposal","choice"],additionalProperties:!1}}},$e={$schema:"http://json-schema.org/draft-07/schema#",$ref:"#/definitions/Profile",definitions:{Profile:{title:"Profile",type:"object",properties:{name:{type:"string",title:"name",maxLength:32},about:{type:"string",title:"about",maxLength:256},avatar:{type:"string",title:"avatar",format:"customUrl",maxLength:256},cover:{type:"string",title:"avatar",format:"customUrl",maxLength:256},twitter:{type:"string",title:"twitter",pattern:"^[A-Za-z0-9_]*$",maxLength:15},github:{type:"string",title:"github",pattern:"^[A-Za-z0-9_-]*$",maxLength:39},lens:{type:"string",title:"lens",pattern:"^[A-Za-z0-9_]*$",maxLength:26},farcaster:{type:"string",title:"farcaster",pattern:"^[a-z0-9-]*$",maxLength:17}},required:[],additionalProperties:!1}}},Le={$schema:"http://json-schema.org/draft-07/schema#",$ref:"#/definitions/Statement",definitions:{Statement:{title:"Statement",type:"object",properties:{about:{type:"string",format:"long",title:"About",maxLength:140},statement:{type:"string",format:"long",title:"Statement",maxLength:1e4},discourse:{type:"string",title:"discourse",pattern:"^[A-Za-z0-9-_.]*$",maxLength:30},network:{type:"string",title:"network",pattern:"^[a-z0-9-]*$",maxLength:24},status:{enum:["ACTIVE","INACTIVE"],title:"status"}},required:[],additionalProperties:!1}}},Fe={$schema:"http://json-schema.org/draft-07/schema#",$ref:"#/definitions/Zodiac",definitions:{Zodiac:{title:"Zodiac",type:"object",properties:{safes:{title:"Safe(s)",type:"array",maxItems:8,items:{type:"object",properties:{network:{title:"Network",type:"string",snapshotNetwork:!0},multisend:{title:"Multisend contract address",type:"string"},realityAddress:{title:"Reality module address",type:"string"},umaAddress:{title:"UMA module address",type:"string"}},additionalProperties:!1}},additionalProperties:!1}}}},Ue={$schema:"http://json-schema.org/draft-07/schema#",$ref:"#/definitions/Alias",definitions:{Alias:{title:"Alias",type:"object",properties:{alias:{type:"string",format:"address"}},required:["alias"],additionalProperties:!1}}},qe={space:{$schema:"http://json-schema.org/draft-07/schema#",$ref:"#/definitions/Space",definitions:{Space:{title:"Space",type:"object",properties:{name:{type:"string",title:"name",minLength:1,maxLength:32},private:{type:"boolean"},about:{type:"string",title:"about",maxLength:160},guidelines:{type:"string",format:"customUrl",title:"guidelines",maxLength:256},template:{type:"string",title:"template",maxLength:1024},terms:{type:"string",title:"terms",format:"customUrl",maxLength:256},avatar:{type:"string",title:"avatar",format:"customUrl",maxLength:256},cover:{type:"string",title:"avatar",format:"customUrl",maxLength:256},location:{type:"string",title:"location",maxLength:24},website:{type:"string",title:"website",format:"customUrl",maxLength:256},twitter:{type:"string",title:"twitter",pattern:"^[A-Za-z0-9_]*$",maxLength:15},coingecko:{type:"string",title:"coingecko",pattern:"^[a-z0-9-]*$",maxLength:32},github:{type:"string",title:"github",pattern:"^[A-Za-z0-9_-]*$",maxLength:39},email:{type:"string",title:"email",maxLength:32},network:{type:"string",snapshotNetwork:!0,title:"network",minLength:1,maxLength:32},symbol:{type:"string",title:"symbol",maxLength:16},skin:{type:"string",title:"skin",maxLength:32},domain:{type:"string",title:"domain",maxLength:64,format:"domain"},discussions:{type:"string",format:"uri",title:"Discussions link",maxLength:256},discourseCategory:{type:"integer",minimum:1,title:"Discourse category"},strategies:{type:"array",minItems:1,uniqueItems:!0,items:{type:"object",properties:{name:{type:"string",maxLength:64,title:"name"},network:{type:"string",maxLength:12,title:"network",snapshotNetwork:!0},params:{type:"object",title:"params"}},required:["name"],additionalProperties:!1},title:"strategies"},members:{type:"array",maxItems:100,items:{type:"string",format:"evmAddress"},title:"members",uniqueItems:!0},admins:{type:"array",maxItems:100,items:{type:"string",format:"evmAddress"},title:"admins",uniqueItems:!0},moderators:{type:"array",maxItems:100,items:{type:"string",format:"evmAddress"},title:"moderators",uniqueItems:!0},filters:{type:"object",properties:{defaultTab:{type:"string"},minScore:{type:"number",minimum:0},onlyMembers:{type:"boolean"},invalids:{type:"array",items:{type:"string",maxLength:64},title:"invalids"}},additionalProperties:!1},validation:{type:"object",properties:{name:{type:"string",maxLength:64,title:"name"},params:{type:"object",title:"params"}},required:["name"],additionalProperties:!1},voteValidation:{type:"object",properties:{name:{type:"string",maxLength:32,title:"name"},params:{type:"object",title:"params"}},required:["name"],additionalProperties:!1},followValidation:{type:"object",properties:{name:{type:"string",maxLength:32,title:"name"},params:{type:"object",title:"params"}},required:["name"],additionalProperties:!1},delegationPortal:{type:"object",properties:{delegationType:{type:"string",title:"Delegation type",description:"Specify the type of delegation that you are using",anyOf:[{const:"compound-governor",title:"Compound governor"},{const:"split-delegation",title:"Split Delegation"}]},delegationContract:{type:"string",title:"Contract address",description:"The address of your delegation contract",examples:["0x3901D0fDe202aF1427216b79f5243f8A022d68cf"],anyOf:[{format:"evmAddress"},{format:"starknetAddress"}],errorMessage:"Must be a valid EVM of Starknet address"},delegationNetwork:{type:"string",title:"Delegation network",description:"The network of your delegation contract",anyOf:[{snapshotNetwork:!0},{starknetNetwork:!0}],errorMessage:"Must be a valid network"},delegationApi:{type:"string",format:"uri",title:"Delegation API",description:"The URL of your delegation API (e.g a subgraph)",examples:["https://subgrapher.snapshot.org/subgraph/arbitrum/FTzC6VrZd8JhJgWfTJnwWgH1Z1dS3GxaosKkRbCqkZAZ"]}},required:["delegationType","delegationApi","delegationContract"],additionalProperties:!1},allowAlias:{type:"boolean"},plugins:{type:"object"},voting:{type:"object",properties:{delay:{type:"integer",minimum:0,maximum:2592e3,errorMessage:{maximum:"Delay must be less than 30 days"}},period:{type:"integer",minimum:0,maximum:31622400,errorMessage:{maximum:"Delay must be less than a year"}},type:{type:"string",title:"type"},quorum:{type:"number",minimum:0},quorumType:{type:"string",enum:["rejection"]},blind:{type:"boolean"},hideAbstain:{type:"boolean"},aliased:{type:"boolean"},privacy:{type:"string",enum:["","shutter","any"]}},additionalProperties:!1},categories:{type:"array",maxItems:2,items:{type:"string",enum:["protocol","social","investment","grant","service","media","creator","collector","ai-agent","gaming","wallet","music","layer-2","defai","defi","rwa","depin","meme"]}},treasuries:{type:"array",maxItems:10,uniqueItems:!0,items:{type:"object",properties:{name:{type:"string",title:"Name",examples:["e.g. Balancer DAO 1"],minLength:1,maxLength:64},address:{type:"string",title:"Contract address",examples:["e.g. 0x1f9840a85d5aF5bf1D1762F925BDADdC4201F984"],anyOf:[{format:"evmAddress"},{format:"starknetAddress"}],errorMessage:"Must be a valid EVM of Starknet address"},network:{type:"string",title:"Network",anyOf:[{snapshotNetwork:!0},{starknetNetwork:!0}],errorMessage:"Must be a valid network"}},required:["name","address","network"],additionalProperties:!1}},labels:{type:"array",maxItems:10,uniqueItems:!0,items:{type:"object",properties:{id:{type:"string",title:"Id",minLength:1,maxLength:8},name:{type:"string",title:"Name",minLength:1,maxLength:32},description:{type:"string",title:"Description",maxLength:100},color:{type:"string",title:"Color",format:"color"}},required:["id","name","color"],additionalProperties:!1}},parent:{type:"string",title:"parent"},children:{type:"array",maxItems:16,title:"children",items:{type:"string"},uniqueItems:!0},boost:{type:"object",properties:{enabled:{type:"boolean"},bribeEnabled:{type:"boolean"}},required:["enabled","bribeEnabled"],additionalProperties:!1},skinSettings:{type:"object",properties:{bg_color:{type:"string",format:"color"},link_color:{type:"string",format:"color"},text_color:{type:"string",format:"color"},content_color:{type:"string",format:"color"},border_color:{type:"string",format:"color"},heading_color:{type:"string",format:"color"},primary_color:{type:"string",format:"color"},header_color:{type:"string",format:"color"},theme:{type:"string",enum:["light","dark"]},logo:{type:"string",title:"logo",format:"customUrl",maxLength:256}},additionalProperties:!1}},required:["name","network","strategies"],additionalProperties:!1}}}.definitions.Space,proposal:Pe.definitions.Proposal,updateProposal:Be.definitions.UpdateProposal,vote:De.definitions.Vote,profile:$e.definitions.Profile,statement:Le.definitions.Statement,zodiac:Fe.definitions.Zodiac,alias:Ue.definitions.Alias},Ve=a((function(t){!function(t,e){function r(t,e){if(!t)throw new Error(e||"Assertion failed")}function i(t,e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}function n(t,e,r){if(n.isBN(t))return t;this.negative=0,this.words=null,this.length=0,this.red=null,null!==t&&("le"!==e&&"be"!==e||(r=e,e=10),this._init(t||0,e||10,r||"be"))}var o;"object"==typeof t?t.exports=n:e.BN=n,n.BN=n,n.wordSize=26;try{o="undefined"!=typeof window&&void 0!==window.Buffer?window.Buffer:Pt.Buffer}catch(t){}function a(t,e){var i=t.charCodeAt(e);return i>=48&&i<=57?i-48:i>=65&&i<=70?i-55:i>=97&&i<=102?i-87:void r(!1,"Invalid character in "+t)}function s(t,e,r){var i=a(t,r);return r-1>=e&&(i|=a(t,r-1)<<4),i}function h(t,e,i,n){for(var o=0,a=0,s=Math.min(t.length,i),h=e;h<s;h++){var u=t.charCodeAt(h)-48;o*=n,a=u>=49?u-49+10:u>=17?u-17+10:u,r(u>=0&&a<n,"Invalid character"),o+=a}return o}function u(t,e){t.words=e.words,t.length=e.length,t.negative=e.negative,t.red=e.red}if(n.isBN=function(t){return t instanceof n||null!==t&&"object"==typeof t&&t.constructor.wordSize===n.wordSize&&Array.isArray(t.words)},n.max=function(t,e){return t.cmp(e)>0?t:e},n.min=function(t,e){return t.cmp(e)<0?t:e},n.prototype._init=function(t,e,i){if("number"==typeof t)return this._initNumber(t,e,i);if("object"==typeof t)return this._initArray(t,e,i);"hex"===e&&(e=16),r(e===(0|e)&&e>=2&&e<=36);var n=0;"-"===(t=t.toString().replace(/\s+/g,""))[0]&&(n++,this.negative=1),n<t.length&&(16===e?this._parseHex(t,n,i):(this._parseBase(t,e,n),"le"===i&&this._initArray(this.toArray(),e,i)))},n.prototype._initNumber=function(t,e,i){t<0&&(this.negative=1,t=-t),t<67108864?(this.words=[67108863&t],this.length=1):t<4503599627370496?(this.words=[67108863&t,t/67108864&67108863],this.length=2):(r(t<9007199254740992),this.words=[67108863&t,t/67108864&67108863,1],this.length=3),"le"===i&&this._initArray(this.toArray(),e,i)},n.prototype._initArray=function(t,e,i){if(r("number"==typeof t.length),t.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(t.length/3),this.words=new Array(this.length);for(var n=0;n<this.length;n++)this.words[n]=0;var o,a,s=0;if("be"===i)for(n=t.length-1,o=0;n>=0;n-=3)a=t[n]|t[n-1]<<8|t[n-2]<<16,this.words[o]|=a<<s&67108863,this.words[o+1]=a>>>26-s&67108863,(s+=24)>=26&&(s-=26,o++);else if("le"===i)for(n=0,o=0;n<t.length;n+=3)a=t[n]|t[n+1]<<8|t[n+2]<<16,this.words[o]|=a<<s&67108863,this.words[o+1]=a>>>26-s&67108863,(s+=24)>=26&&(s-=26,o++);return this._strip()},n.prototype._parseHex=function(t,e,r){this.length=Math.ceil((t.length-e)/6),this.words=new Array(this.length);for(var i=0;i<this.length;i++)this.words[i]=0;var n,o=0,a=0;if("be"===r)for(i=t.length-1;i>=e;i-=2)n=s(t,e,i)<<o,this.words[a]|=67108863&n,o>=18?(o-=18,a+=1,this.words[a]|=n>>>26):o+=8;else for(i=(t.length-e)%2==0?e+1:e;i<t.length;i+=2)n=s(t,e,i)<<o,this.words[a]|=67108863&n,o>=18?(o-=18,a+=1,this.words[a]|=n>>>26):o+=8;this._strip()},n.prototype._parseBase=function(t,e,r){this.words=[0],this.length=1;for(var i=0,n=1;n<=67108863;n*=e)i++;i--,n=n/e|0;for(var o=t.length-r,a=o%i,s=Math.min(o,o-a)+r,u=0,l=r;l<s;l+=i)u=h(t,l,l+i,e),this.imuln(n),this.words[0]+u<67108864?this.words[0]+=u:this._iaddn(u);if(0!==a){var c=1;for(u=h(t,l,t.length,e),l=0;l<a;l++)c*=e;this.imuln(c),this.words[0]+u<67108864?this.words[0]+=u:this._iaddn(u)}this._strip()},n.prototype.copy=function(t){t.words=new Array(this.length);for(var e=0;e<this.length;e++)t.words[e]=this.words[e];t.length=this.length,t.negative=this.negative,t.red=this.red},n.prototype._move=function(t){u(t,this)},n.prototype.clone=function(){var t=new n(null);return this.copy(t),t},n.prototype._expand=function(t){for(;this.length<t;)this.words[this.length++]=0;return this},n.prototype._strip=function(){for(;this.length>1&&0===this.words[this.length-1];)this.length--;return this._normSign()},n.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},"undefined"!=typeof Symbol&&"function"==typeof Symbol.for)try{n.prototype[Symbol.for("nodejs.util.inspect.custom")]=l}catch(t){n.prototype.inspect=l}else n.prototype.inspect=l;function l(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"}var c=["","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"],d=[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],f=[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];n.prototype.toString=function(t,e){var i;if(e=0|e||1,16===(t=t||10)||"hex"===t){i="";for(var n=0,o=0,a=0;a<this.length;a++){var s=this.words[a],h=(16777215&(s<<n|o)).toString(16);o=s>>>24-n&16777215,(n+=2)>=26&&(n-=26,a--),i=0!==o||a!==this.length-1?c[6-h.length]+h+i:h+i}for(0!==o&&(i=o.toString(16)+i);i.length%e!=0;)i="0"+i;return 0!==this.negative&&(i="-"+i),i}if(t===(0|t)&&t>=2&&t<=36){var u=d[t],l=f[t];i="";var m=this.clone();for(m.negative=0;!m.isZero();){var p=m.modrn(l).toString(t);i=(m=m.idivn(l)).isZero()?p+i:c[u-p.length]+p+i}for(this.isZero()&&(i="0"+i);i.length%e!=0;)i="0"+i;return 0!==this.negative&&(i="-"+i),i}r(!1,"Base should be between 2 and 36")},n.prototype.toNumber=function(){var t=this.words[0];return 2===this.length?t+=67108864*this.words[1]:3===this.length&&1===this.words[2]?t+=4503599627370496+67108864*this.words[1]:this.length>2&&r(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-t:t},n.prototype.toJSON=function(){return this.toString(16,2)},o&&(n.prototype.toBuffer=function(t,e){return this.toArrayLike(o,t,e)}),n.prototype.toArray=function(t,e){return this.toArrayLike(Array,t,e)};function m(t,e,r){r.negative=e.negative^t.negative;var i=t.length+e.length|0;r.length=i,i=i-1|0;var n=0|t.words[0],o=0|e.words[0],a=n*o,s=67108863&a,h=a/67108864|0;r.words[0]=s;for(var u=1;u<i;u++){for(var l=h>>>26,c=67108863&h,d=Math.min(u,e.length-1),f=Math.max(0,u-t.length+1);f<=d;f++){var m=u-f|0;l+=(a=(n=0|t.words[m])*(o=0|e.words[f])+c)/67108864|0,c=67108863&a}r.words[u]=0|c,h=0|l}return 0!==h?r.words[u]=0|h:r.length--,r._strip()}n.prototype.toArrayLike=function(t,e,i){this._strip();var n=this.byteLength(),o=i||Math.max(1,n);r(n<=o,"byte array longer than desired length"),r(o>0,"Requested array length <= 0");var a=function(t,e){return t.allocUnsafe?t.allocUnsafe(e):new t(e)}(t,o);return this["_toArrayLike"+("le"===e?"LE":"BE")](a,n),a},n.prototype._toArrayLikeLE=function(t,e){for(var r=0,i=0,n=0,o=0;n<this.length;n++){var a=this.words[n]<<o|i;t[r++]=255&a,r<t.length&&(t[r++]=a>>8&255),r<t.length&&(t[r++]=a>>16&255),6===o?(r<t.length&&(t[r++]=a>>24&255),i=0,o=0):(i=a>>>24,o+=2)}if(r<t.length)for(t[r++]=i;r<t.length;)t[r++]=0},n.prototype._toArrayLikeBE=function(t,e){for(var r=t.length-1,i=0,n=0,o=0;n<this.length;n++){var a=this.words[n]<<o|i;t[r--]=255&a,r>=0&&(t[r--]=a>>8&255),r>=0&&(t[r--]=a>>16&255),6===o?(r>=0&&(t[r--]=a>>24&255),i=0,o=0):(i=a>>>24,o+=2)}if(r>=0)for(t[r--]=i;r>=0;)t[r--]=0},Math.clz32?n.prototype._countBits=function(t){return 32-Math.clz32(t)}:n.prototype._countBits=function(t){var e=t,r=0;return e>=4096&&(r+=13,e>>>=13),e>=64&&(r+=7,e>>>=7),e>=8&&(r+=4,e>>>=4),e>=2&&(r+=2,e>>>=2),r+e},n.prototype._zeroBits=function(t){if(0===t)return 26;var e=t,r=0;return 0==(8191&e)&&(r+=13,e>>>=13),0==(127&e)&&(r+=7,e>>>=7),0==(15&e)&&(r+=4,e>>>=4),0==(3&e)&&(r+=2,e>>>=2),0==(1&e)&&r++,r},n.prototype.bitLength=function(){var t=this.words[this.length-1],e=this._countBits(t);return 26*(this.length-1)+e},n.prototype.zeroBits=function(){if(this.isZero())return 0;for(var t=0,e=0;e<this.length;e++){var r=this._zeroBits(this.words[e]);if(t+=r,26!==r)break}return t},n.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},n.prototype.toTwos=function(t){return 0!==this.negative?this.abs().inotn(t).iaddn(1):this.clone()},n.prototype.fromTwos=function(t){return this.testn(t-1)?this.notn(t).iaddn(1).ineg():this.clone()},n.prototype.isNeg=function(){return 0!==this.negative},n.prototype.neg=function(){return this.clone().ineg()},n.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},n.prototype.iuor=function(t){for(;this.length<t.length;)this.words[this.length++]=0;for(var e=0;e<t.length;e++)this.words[e]=this.words[e]|t.words[e];return this._strip()},n.prototype.ior=function(t){return r(0==(this.negative|t.negative)),this.iuor(t)},n.prototype.or=function(t){return this.length>t.length?this.clone().ior(t):t.clone().ior(this)},n.prototype.uor=function(t){return this.length>t.length?this.clone().iuor(t):t.clone().iuor(this)},n.prototype.iuand=function(t){var e;e=this.length>t.length?t:this;for(var r=0;r<e.length;r++)this.words[r]=this.words[r]&t.words[r];return this.length=e.length,this._strip()},n.prototype.iand=function(t){return r(0==(this.negative|t.negative)),this.iuand(t)},n.prototype.and=function(t){return this.length>t.length?this.clone().iand(t):t.clone().iand(this)},n.prototype.uand=function(t){return this.length>t.length?this.clone().iuand(t):t.clone().iuand(this)},n.prototype.iuxor=function(t){var e,r;this.length>t.length?(e=this,r=t):(e=t,r=this);for(var i=0;i<r.length;i++)this.words[i]=e.words[i]^r.words[i];if(this!==e)for(;i<e.length;i++)this.words[i]=e.words[i];return this.length=e.length,this._strip()},n.prototype.ixor=function(t){return r(0==(this.negative|t.negative)),this.iuxor(t)},n.prototype.xor=function(t){return this.length>t.length?this.clone().ixor(t):t.clone().ixor(this)},n.prototype.uxor=function(t){return this.length>t.length?this.clone().iuxor(t):t.clone().iuxor(this)},n.prototype.inotn=function(t){r("number"==typeof t&&t>=0);var e=0|Math.ceil(t/26),i=t%26;this._expand(e),i>0&&e--;for(var n=0;n<e;n++)this.words[n]=67108863&~this.words[n];return i>0&&(this.words[n]=~this.words[n]&67108863>>26-i),this._strip()},n.prototype.notn=function(t){return this.clone().inotn(t)},n.prototype.setn=function(t,e){r("number"==typeof t&&t>=0);var i=t/26|0,n=t%26;return this._expand(i+1),this.words[i]=e?this.words[i]|1<<n:this.words[i]&~(1<<n),this._strip()},n.prototype.iadd=function(t){var e,r,i;if(0!==this.negative&&0===t.negative)return this.negative=0,e=this.isub(t),this.negative^=1,this._normSign();if(0===this.negative&&0!==t.negative)return t.negative=0,e=this.isub(t),t.negative=1,e._normSign();this.length>t.length?(r=this,i=t):(r=t,i=this);for(var n=0,o=0;o<i.length;o++)e=(0|r.words[o])+(0|i.words[o])+n,this.words[o]=67108863&e,n=e>>>26;for(;0!==n&&o<r.length;o++)e=(0|r.words[o])+n,this.words[o]=67108863&e,n=e>>>26;if(this.length=r.length,0!==n)this.words[this.length]=n,this.length++;else if(r!==this)for(;o<r.length;o++)this.words[o]=r.words[o];return this},n.prototype.add=function(t){var e;return 0!==t.negative&&0===this.negative?(t.negative=0,e=this.sub(t),t.negative^=1,e):0===t.negative&&0!==this.negative?(this.negative=0,e=t.sub(this),this.negative=1,e):this.length>t.length?this.clone().iadd(t):t.clone().iadd(this)},n.prototype.isub=function(t){if(0!==t.negative){t.negative=0;var e=this.iadd(t);return t.negative=1,e._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(t),this.negative=1,this._normSign();var r,i,n=this.cmp(t);if(0===n)return this.negative=0,this.length=1,this.words[0]=0,this;n>0?(r=this,i=t):(r=t,i=this);for(var o=0,a=0;a<i.length;a++)o=(e=(0|r.words[a])-(0|i.words[a])+o)>>26,this.words[a]=67108863&e;for(;0!==o&&a<r.length;a++)o=(e=(0|r.words[a])+o)>>26,this.words[a]=67108863&e;if(0===o&&a<r.length&&r!==this)for(;a<r.length;a++)this.words[a]=r.words[a];return this.length=Math.max(this.length,a),r!==this&&(this.negative=1),this._strip()},n.prototype.sub=function(t){return this.clone().isub(t)};var p=function(t,e,r){var i,n,o,a=t.words,s=e.words,h=r.words,u=0,l=0|a[0],c=8191&l,d=l>>>13,f=0|a[1],m=8191&f,p=f>>>13,g=0|a[2],y=8191&g,w=g>>>13,v=0|a[3],b=8191&v,k=v>>>13,M=0|a[4],_=8191&M,E=M>>>13,A=0|a[5],j=8191&A,x=A>>>13,S=0|a[6],N=8191&S,I=S>>>13,T=0|a[7],C=8191&T,z=T>>>13,O=0|a[8],R=8191&O,P=O>>>13,B=0|a[9],D=8191&B,$=B>>>13,L=0|s[0],F=8191&L,U=L>>>13,q=0|s[1],V=8191&q,H=q>>>13,G=0|s[2],Z=8191&G,K=G>>>13,J=0|s[3],W=8191&J,Y=J>>>13,Q=0|s[4],X=8191&Q,tt=Q>>>13,et=0|s[5],rt=8191&et,it=et>>>13,nt=0|s[6],ot=8191&nt,at=nt>>>13,st=0|s[7],ht=8191&st,ut=st>>>13,lt=0|s[8],ct=8191&lt,dt=lt>>>13,ft=0|s[9],mt=8191&ft,pt=ft>>>13;r.negative=t.negative^e.negative,r.length=19;var gt=(u+(i=Math.imul(c,F))|0)+((8191&(n=(n=Math.imul(c,U))+Math.imul(d,F)|0))<<13)|0;u=((o=Math.imul(d,U))+(n>>>13)|0)+(gt>>>26)|0,gt&=67108863,i=Math.imul(m,F),n=(n=Math.imul(m,U))+Math.imul(p,F)|0,o=Math.imul(p,U);var yt=(u+(i=i+Math.imul(c,V)|0)|0)+((8191&(n=(n=n+Math.imul(c,H)|0)+Math.imul(d,V)|0))<<13)|0;u=((o=o+Math.imul(d,H)|0)+(n>>>13)|0)+(yt>>>26)|0,yt&=67108863,i=Math.imul(y,F),n=(n=Math.imul(y,U))+Math.imul(w,F)|0,o=Math.imul(w,U),i=i+Math.imul(m,V)|0,n=(n=n+Math.imul(m,H)|0)+Math.imul(p,V)|0,o=o+Math.imul(p,H)|0;var wt=(u+(i=i+Math.imul(c,Z)|0)|0)+((8191&(n=(n=n+Math.imul(c,K)|0)+Math.imul(d,Z)|0))<<13)|0;u=((o=o+Math.imul(d,K)|0)+(n>>>13)|0)+(wt>>>26)|0,wt&=67108863,i=Math.imul(b,F),n=(n=Math.imul(b,U))+Math.imul(k,F)|0,o=Math.imul(k,U),i=i+Math.imul(y,V)|0,n=(n=n+Math.imul(y,H)|0)+Math.imul(w,V)|0,o=o+Math.imul(w,H)|0,i=i+Math.imul(m,Z)|0,n=(n=n+Math.imul(m,K)|0)+Math.imul(p,Z)|0,o=o+Math.imul(p,K)|0;var vt=(u+(i=i+Math.imul(c,W)|0)|0)+((8191&(n=(n=n+Math.imul(c,Y)|0)+Math.imul(d,W)|0))<<13)|0;u=((o=o+Math.imul(d,Y)|0)+(n>>>13)|0)+(vt>>>26)|0,vt&=67108863,i=Math.imul(_,F),n=(n=Math.imul(_,U))+Math.imul(E,F)|0,o=Math.imul(E,U),i=i+Math.imul(b,V)|0,n=(n=n+Math.imul(b,H)|0)+Math.imul(k,V)|0,o=o+Math.imul(k,H)|0,i=i+Math.imul(y,Z)|0,n=(n=n+Math.imul(y,K)|0)+Math.imul(w,Z)|0,o=o+Math.imul(w,K)|0,i=i+Math.imul(m,W)|0,n=(n=n+Math.imul(m,Y)|0)+Math.imul(p,W)|0,o=o+Math.imul(p,Y)|0;var bt=(u+(i=i+Math.imul(c,X)|0)|0)+((8191&(n=(n=n+Math.imul(c,tt)|0)+Math.imul(d,X)|0))<<13)|0;u=((o=o+Math.imul(d,tt)|0)+(n>>>13)|0)+(bt>>>26)|0,bt&=67108863,i=Math.imul(j,F),n=(n=Math.imul(j,U))+Math.imul(x,F)|0,o=Math.imul(x,U),i=i+Math.imul(_,V)|0,n=(n=n+Math.imul(_,H)|0)+Math.imul(E,V)|0,o=o+Math.imul(E,H)|0,i=i+Math.imul(b,Z)|0,n=(n=n+Math.imul(b,K)|0)+Math.imul(k,Z)|0,o=o+Math.imul(k,K)|0,i=i+Math.imul(y,W)|0,n=(n=n+Math.imul(y,Y)|0)+Math.imul(w,W)|0,o=o+Math.imul(w,Y)|0,i=i+Math.imul(m,X)|0,n=(n=n+Math.imul(m,tt)|0)+Math.imul(p,X)|0,o=o+Math.imul(p,tt)|0;var kt=(u+(i=i+Math.imul(c,rt)|0)|0)+((8191&(n=(n=n+Math.imul(c,it)|0)+Math.imul(d,rt)|0))<<13)|0;u=((o=o+Math.imul(d,it)|0)+(n>>>13)|0)+(kt>>>26)|0,kt&=67108863,i=Math.imul(N,F),n=(n=Math.imul(N,U))+Math.imul(I,F)|0,o=Math.imul(I,U),i=i+Math.imul(j,V)|0,n=(n=n+Math.imul(j,H)|0)+Math.imul(x,V)|0,o=o+Math.imul(x,H)|0,i=i+Math.imul(_,Z)|0,n=(n=n+Math.imul(_,K)|0)+Math.imul(E,Z)|0,o=o+Math.imul(E,K)|0,i=i+Math.imul(b,W)|0,n=(n=n+Math.imul(b,Y)|0)+Math.imul(k,W)|0,o=o+Math.imul(k,Y)|0,i=i+Math.imul(y,X)|0,n=(n=n+Math.imul(y,tt)|0)+Math.imul(w,X)|0,o=o+Math.imul(w,tt)|0,i=i+Math.imul(m,rt)|0,n=(n=n+Math.imul(m,it)|0)+Math.imul(p,rt)|0,o=o+Math.imul(p,it)|0;var Mt=(u+(i=i+Math.imul(c,ot)|0)|0)+((8191&(n=(n=n+Math.imul(c,at)|0)+Math.imul(d,ot)|0))<<13)|0;u=((o=o+Math.imul(d,at)|0)+(n>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,i=Math.imul(C,F),n=(n=Math.imul(C,U))+Math.imul(z,F)|0,o=Math.imul(z,U),i=i+Math.imul(N,V)|0,n=(n=n+Math.imul(N,H)|0)+Math.imul(I,V)|0,o=o+Math.imul(I,H)|0,i=i+Math.imul(j,Z)|0,n=(n=n+Math.imul(j,K)|0)+Math.imul(x,Z)|0,o=o+Math.imul(x,K)|0,i=i+Math.imul(_,W)|0,n=(n=n+Math.imul(_,Y)|0)+Math.imul(E,W)|0,o=o+Math.imul(E,Y)|0,i=i+Math.imul(b,X)|0,n=(n=n+Math.imul(b,tt)|0)+Math.imul(k,X)|0,o=o+Math.imul(k,tt)|0,i=i+Math.imul(y,rt)|0,n=(n=n+Math.imul(y,it)|0)+Math.imul(w,rt)|0,o=o+Math.imul(w,it)|0,i=i+Math.imul(m,ot)|0,n=(n=n+Math.imul(m,at)|0)+Math.imul(p,ot)|0,o=o+Math.imul(p,at)|0;var _t=(u+(i=i+Math.imul(c,ht)|0)|0)+((8191&(n=(n=n+Math.imul(c,ut)|0)+Math.imul(d,ht)|0))<<13)|0;u=((o=o+Math.imul(d,ut)|0)+(n>>>13)|0)+(_t>>>26)|0,_t&=67108863,i=Math.imul(R,F),n=(n=Math.imul(R,U))+Math.imul(P,F)|0,o=Math.imul(P,U),i=i+Math.imul(C,V)|0,n=(n=n+Math.imul(C,H)|0)+Math.imul(z,V)|0,o=o+Math.imul(z,H)|0,i=i+Math.imul(N,Z)|0,n=(n=n+Math.imul(N,K)|0)+Math.imul(I,Z)|0,o=o+Math.imul(I,K)|0,i=i+Math.imul(j,W)|0,n=(n=n+Math.imul(j,Y)|0)+Math.imul(x,W)|0,o=o+Math.imul(x,Y)|0,i=i+Math.imul(_,X)|0,n=(n=n+Math.imul(_,tt)|0)+Math.imul(E,X)|0,o=o+Math.imul(E,tt)|0,i=i+Math.imul(b,rt)|0,n=(n=n+Math.imul(b,it)|0)+Math.imul(k,rt)|0,o=o+Math.imul(k,it)|0,i=i+Math.imul(y,ot)|0,n=(n=n+Math.imul(y,at)|0)+Math.imul(w,ot)|0,o=o+Math.imul(w,at)|0,i=i+Math.imul(m,ht)|0,n=(n=n+Math.imul(m,ut)|0)+Math.imul(p,ht)|0,o=o+Math.imul(p,ut)|0;var Et=(u+(i=i+Math.imul(c,ct)|0)|0)+((8191&(n=(n=n+Math.imul(c,dt)|0)+Math.imul(d,ct)|0))<<13)|0;u=((o=o+Math.imul(d,dt)|0)+(n>>>13)|0)+(Et>>>26)|0,Et&=67108863,i=Math.imul(D,F),n=(n=Math.imul(D,U))+Math.imul($,F)|0,o=Math.imul($,U),i=i+Math.imul(R,V)|0,n=(n=n+Math.imul(R,H)|0)+Math.imul(P,V)|0,o=o+Math.imul(P,H)|0,i=i+Math.imul(C,Z)|0,n=(n=n+Math.imul(C,K)|0)+Math.imul(z,Z)|0,o=o+Math.imul(z,K)|0,i=i+Math.imul(N,W)|0,n=(n=n+Math.imul(N,Y)|0)+Math.imul(I,W)|0,o=o+Math.imul(I,Y)|0,i=i+Math.imul(j,X)|0,n=(n=n+Math.imul(j,tt)|0)+Math.imul(x,X)|0,o=o+Math.imul(x,tt)|0,i=i+Math.imul(_,rt)|0,n=(n=n+Math.imul(_,it)|0)+Math.imul(E,rt)|0,o=o+Math.imul(E,it)|0,i=i+Math.imul(b,ot)|0,n=(n=n+Math.imul(b,at)|0)+Math.imul(k,ot)|0,o=o+Math.imul(k,at)|0,i=i+Math.imul(y,ht)|0,n=(n=n+Math.imul(y,ut)|0)+Math.imul(w,ht)|0,o=o+Math.imul(w,ut)|0,i=i+Math.imul(m,ct)|0,n=(n=n+Math.imul(m,dt)|0)+Math.imul(p,ct)|0,o=o+Math.imul(p,dt)|0;var At=(u+(i=i+Math.imul(c,mt)|0)|0)+((8191&(n=(n=n+Math.imul(c,pt)|0)+Math.imul(d,mt)|0))<<13)|0;u=((o=o+Math.imul(d,pt)|0)+(n>>>13)|0)+(At>>>26)|0,At&=67108863,i=Math.imul(D,V),n=(n=Math.imul(D,H))+Math.imul($,V)|0,o=Math.imul($,H),i=i+Math.imul(R,Z)|0,n=(n=n+Math.imul(R,K)|0)+Math.imul(P,Z)|0,o=o+Math.imul(P,K)|0,i=i+Math.imul(C,W)|0,n=(n=n+Math.imul(C,Y)|0)+Math.imul(z,W)|0,o=o+Math.imul(z,Y)|0,i=i+Math.imul(N,X)|0,n=(n=n+Math.imul(N,tt)|0)+Math.imul(I,X)|0,o=o+Math.imul(I,tt)|0,i=i+Math.imul(j,rt)|0,n=(n=n+Math.imul(j,it)|0)+Math.imul(x,rt)|0,o=o+Math.imul(x,it)|0,i=i+Math.imul(_,ot)|0,n=(n=n+Math.imul(_,at)|0)+Math.imul(E,ot)|0,o=o+Math.imul(E,at)|0,i=i+Math.imul(b,ht)|0,n=(n=n+Math.imul(b,ut)|0)+Math.imul(k,ht)|0,o=o+Math.imul(k,ut)|0,i=i+Math.imul(y,ct)|0,n=(n=n+Math.imul(y,dt)|0)+Math.imul(w,ct)|0,o=o+Math.imul(w,dt)|0;var jt=(u+(i=i+Math.imul(m,mt)|0)|0)+((8191&(n=(n=n+Math.imul(m,pt)|0)+Math.imul(p,mt)|0))<<13)|0;u=((o=o+Math.imul(p,pt)|0)+(n>>>13)|0)+(jt>>>26)|0,jt&=67108863,i=Math.imul(D,Z),n=(n=Math.imul(D,K))+Math.imul($,Z)|0,o=Math.imul($,K),i=i+Math.imul(R,W)|0,n=(n=n+Math.imul(R,Y)|0)+Math.imul(P,W)|0,o=o+Math.imul(P,Y)|0,i=i+Math.imul(C,X)|0,n=(n=n+Math.imul(C,tt)|0)+Math.imul(z,X)|0,o=o+Math.imul(z,tt)|0,i=i+Math.imul(N,rt)|0,n=(n=n+Math.imul(N,it)|0)+Math.imul(I,rt)|0,o=o+Math.imul(I,it)|0,i=i+Math.imul(j,ot)|0,n=(n=n+Math.imul(j,at)|0)+Math.imul(x,ot)|0,o=o+Math.imul(x,at)|0,i=i+Math.imul(_,ht)|0,n=(n=n+Math.imul(_,ut)|0)+Math.imul(E,ht)|0,o=o+Math.imul(E,ut)|0,i=i+Math.imul(b,ct)|0,n=(n=n+Math.imul(b,dt)|0)+Math.imul(k,ct)|0,o=o+Math.imul(k,dt)|0;var xt=(u+(i=i+Math.imul(y,mt)|0)|0)+((8191&(n=(n=n+Math.imul(y,pt)|0)+Math.imul(w,mt)|0))<<13)|0;u=((o=o+Math.imul(w,pt)|0)+(n>>>13)|0)+(xt>>>26)|0,xt&=67108863,i=Math.imul(D,W),n=(n=Math.imul(D,Y))+Math.imul($,W)|0,o=Math.imul($,Y),i=i+Math.imul(R,X)|0,n=(n=n+Math.imul(R,tt)|0)+Math.imul(P,X)|0,o=o+Math.imul(P,tt)|0,i=i+Math.imul(C,rt)|0,n=(n=n+Math.imul(C,it)|0)+Math.imul(z,rt)|0,o=o+Math.imul(z,it)|0,i=i+Math.imul(N,ot)|0,n=(n=n+Math.imul(N,at)|0)+Math.imul(I,ot)|0,o=o+Math.imul(I,at)|0,i=i+Math.imul(j,ht)|0,n=(n=n+Math.imul(j,ut)|0)+Math.imul(x,ht)|0,o=o+Math.imul(x,ut)|0,i=i+Math.imul(_,ct)|0,n=(n=n+Math.imul(_,dt)|0)+Math.imul(E,ct)|0,o=o+Math.imul(E,dt)|0;var St=(u+(i=i+Math.imul(b,mt)|0)|0)+((8191&(n=(n=n+Math.imul(b,pt)|0)+Math.imul(k,mt)|0))<<13)|0;u=((o=o+Math.imul(k,pt)|0)+(n>>>13)|0)+(St>>>26)|0,St&=67108863,i=Math.imul(D,X),n=(n=Math.imul(D,tt))+Math.imul($,X)|0,o=Math.imul($,tt),i=i+Math.imul(R,rt)|0,n=(n=n+Math.imul(R,it)|0)+Math.imul(P,rt)|0,o=o+Math.imul(P,it)|0,i=i+Math.imul(C,ot)|0,n=(n=n+Math.imul(C,at)|0)+Math.imul(z,ot)|0,o=o+Math.imul(z,at)|0,i=i+Math.imul(N,ht)|0,n=(n=n+Math.imul(N,ut)|0)+Math.imul(I,ht)|0,o=o+Math.imul(I,ut)|0,i=i+Math.imul(j,ct)|0,n=(n=n+Math.imul(j,dt)|0)+Math.imul(x,ct)|0,o=o+Math.imul(x,dt)|0;var Nt=(u+(i=i+Math.imul(_,mt)|0)|0)+((8191&(n=(n=n+Math.imul(_,pt)|0)+Math.imul(E,mt)|0))<<13)|0;u=((o=o+Math.imul(E,pt)|0)+(n>>>13)|0)+(Nt>>>26)|0,Nt&=67108863,i=Math.imul(D,rt),n=(n=Math.imul(D,it))+Math.imul($,rt)|0,o=Math.imul($,it),i=i+Math.imul(R,ot)|0,n=(n=n+Math.imul(R,at)|0)+Math.imul(P,ot)|0,o=o+Math.imul(P,at)|0,i=i+Math.imul(C,ht)|0,n=(n=n+Math.imul(C,ut)|0)+Math.imul(z,ht)|0,o=o+Math.imul(z,ut)|0,i=i+Math.imul(N,ct)|0,n=(n=n+Math.imul(N,dt)|0)+Math.imul(I,ct)|0,o=o+Math.imul(I,dt)|0;var It=(u+(i=i+Math.imul(j,mt)|0)|0)+((8191&(n=(n=n+Math.imul(j,pt)|0)+Math.imul(x,mt)|0))<<13)|0;u=((o=o+Math.imul(x,pt)|0)+(n>>>13)|0)+(It>>>26)|0,It&=67108863,i=Math.imul(D,ot),n=(n=Math.imul(D,at))+Math.imul($,ot)|0,o=Math.imul($,at),i=i+Math.imul(R,ht)|0,n=(n=n+Math.imul(R,ut)|0)+Math.imul(P,ht)|0,o=o+Math.imul(P,ut)|0,i=i+Math.imul(C,ct)|0,n=(n=n+Math.imul(C,dt)|0)+Math.imul(z,ct)|0,o=o+Math.imul(z,dt)|0;var Tt=(u+(i=i+Math.imul(N,mt)|0)|0)+((8191&(n=(n=n+Math.imul(N,pt)|0)+Math.imul(I,mt)|0))<<13)|0;u=((o=o+Math.imul(I,pt)|0)+(n>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,i=Math.imul(D,ht),n=(n=Math.imul(D,ut))+Math.imul($,ht)|0,o=Math.imul($,ut),i=i+Math.imul(R,ct)|0,n=(n=n+Math.imul(R,dt)|0)+Math.imul(P,ct)|0,o=o+Math.imul(P,dt)|0;var Ct=(u+(i=i+Math.imul(C,mt)|0)|0)+((8191&(n=(n=n+Math.imul(C,pt)|0)+Math.imul(z,mt)|0))<<13)|0;u=((o=o+Math.imul(z,pt)|0)+(n>>>13)|0)+(Ct>>>26)|0,Ct&=67108863,i=Math.imul(D,ct),n=(n=Math.imul(D,dt))+Math.imul($,ct)|0,o=Math.imul($,dt);var zt=(u+(i=i+Math.imul(R,mt)|0)|0)+((8191&(n=(n=n+Math.imul(R,pt)|0)+Math.imul(P,mt)|0))<<13)|0;u=((o=o+Math.imul(P,pt)|0)+(n>>>13)|0)+(zt>>>26)|0,zt&=67108863;var Ot=(u+(i=Math.imul(D,mt))|0)+((8191&(n=(n=Math.imul(D,pt))+Math.imul($,mt)|0))<<13)|0;return u=((o=Math.imul($,pt))+(n>>>13)|0)+(Ot>>>26)|0,Ot&=67108863,h[0]=gt,h[1]=yt,h[2]=wt,h[3]=vt,h[4]=bt,h[5]=kt,h[6]=Mt,h[7]=_t,h[8]=Et,h[9]=At,h[10]=jt,h[11]=xt,h[12]=St,h[13]=Nt,h[14]=It,h[15]=Tt,h[16]=Ct,h[17]=zt,h[18]=Ot,0!==u&&(h[19]=u,r.length++),r};function g(t,e,r){r.negative=e.negative^t.negative,r.length=t.length+e.length;for(var i=0,n=0,o=0;o<r.length-1;o++){var a=n;n=0;for(var s=67108863&i,h=Math.min(o,e.length-1),u=Math.max(0,o-t.length+1);u<=h;u++){var l=o-u,c=(0|t.words[l])*(0|e.words[u]),d=67108863&c;s=67108863&(d=d+s|0),n+=(a=(a=a+(c/67108864|0)|0)+(d>>>26)|0)>>>26,a&=67108863}r.words[o]=s,i=a,a=n}return 0!==i?r.words[o]=i:r.length--,r._strip()}function y(t,e,r){return g(t,e,r)}Math.imul||(p=m),n.prototype.mulTo=function(t,e){var r=this.length+t.length;return 10===this.length&&10===t.length?p(this,t,e):r<63?m(this,t,e):r<1024?g(this,t,e):y(this,t,e)},n.prototype.mul=function(t){var e=new n(null);return e.words=new Array(this.length+t.length),this.mulTo(t,e)},n.prototype.mulf=function(t){var e=new n(null);return e.words=new Array(this.length+t.length),y(this,t,e)},n.prototype.imul=function(t){return this.clone().mulTo(t,this)},n.prototype.imuln=function(t){var e=t<0;e&&(t=-t),r("number"==typeof t),r(t<67108864);for(var i=0,n=0;n<this.length;n++){var o=(0|this.words[n])*t,a=(67108863&o)+(67108863&i);i>>=26,i+=o/67108864|0,i+=a>>>26,this.words[n]=67108863&a}return 0!==i&&(this.words[n]=i,this.length++),e?this.ineg():this},n.prototype.muln=function(t){return this.clone().imuln(t)},n.prototype.sqr=function(){return this.mul(this)},n.prototype.isqr=function(){return this.imul(this.clone())},n.prototype.pow=function(t){var e=function(t){for(var e=new Array(t.bitLength()),r=0;r<e.length;r++){var i=r/26|0,n=r%26;e[r]=t.words[i]>>>n&1}return e}(t);if(0===e.length)return new n(1);for(var r=this,i=0;i<e.length&&0===e[i];i++,r=r.sqr());if(++i<e.length)for(var o=r.sqr();i<e.length;i++,o=o.sqr())0!==e[i]&&(r=r.mul(o));return r},n.prototype.iushln=function(t){r("number"==typeof t&&t>=0);var e,i=t%26,n=(t-i)/26,o=67108863>>>26-i<<26-i;if(0!==i){var a=0;for(e=0;e<this.length;e++){var s=this.words[e]&o,h=(0|this.words[e])-s<<i;this.words[e]=h|a,a=s>>>26-i}a&&(this.words[e]=a,this.length++)}if(0!==n){for(e=this.length-1;e>=0;e--)this.words[e+n]=this.words[e];for(e=0;e<n;e++)this.words[e]=0;this.length+=n}return this._strip()},n.prototype.ishln=function(t){return r(0===this.negative),this.iushln(t)},n.prototype.iushrn=function(t,e,i){var n;r("number"==typeof t&&t>=0),n=e?(e-e%26)/26:0;var o=t%26,a=Math.min((t-o)/26,this.length),s=67108863^67108863>>>o<<o,h=i;if(n-=a,n=Math.max(0,n),h){for(var u=0;u<a;u++)h.words[u]=this.words[u];h.length=a}if(0===a);else if(this.length>a)for(this.length-=a,u=0;u<this.length;u++)this.words[u]=this.words[u+a];else this.words[0]=0,this.length=1;var l=0;for(u=this.length-1;u>=0&&(0!==l||u>=n);u--){var c=0|this.words[u];this.words[u]=l<<26-o|c>>>o,l=c&s}return h&&0!==l&&(h.words[h.length++]=l),0===this.length&&(this.words[0]=0,this.length=1),this._strip()},n.prototype.ishrn=function(t,e,i){return r(0===this.negative),this.iushrn(t,e,i)},n.prototype.shln=function(t){return this.clone().ishln(t)},n.prototype.ushln=function(t){return this.clone().iushln(t)},n.prototype.shrn=function(t){return this.clone().ishrn(t)},n.prototype.ushrn=function(t){return this.clone().iushrn(t)},n.prototype.testn=function(t){r("number"==typeof t&&t>=0);var e=t%26,i=(t-e)/26,n=1<<e;return!(this.length<=i)&&!!(this.words[i]&n)},n.prototype.imaskn=function(t){r("number"==typeof t&&t>=0);var e=t%26,i=(t-e)/26;if(r(0===this.negative,"imaskn works only with positive numbers"),this.length<=i)return this;if(0!==e&&i++,this.length=Math.min(i,this.length),0!==e){var n=67108863^67108863>>>e<<e;this.words[this.length-1]&=n}return this._strip()},n.prototype.maskn=function(t){return this.clone().imaskn(t)},n.prototype.iaddn=function(t){return r("number"==typeof t),r(t<67108864),t<0?this.isubn(-t):0!==this.negative?1===this.length&&(0|this.words[0])<=t?(this.words[0]=t-(0|this.words[0]),this.negative=0,this):(this.negative=0,this.isubn(t),this.negative=1,this):this._iaddn(t)},n.prototype._iaddn=function(t){this.words[0]+=t;for(var e=0;e<this.length&&this.words[e]>=67108864;e++)this.words[e]-=67108864,e===this.length-1?this.words[e+1]=1:this.words[e+1]++;return this.length=Math.max(this.length,e+1),this},n.prototype.isubn=function(t){if(r("number"==typeof t),r(t<67108864),t<0)return this.iaddn(-t);if(0!==this.negative)return this.negative=0,this.iaddn(t),this.negative=1,this;if(this.words[0]-=t,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var e=0;e<this.length&&this.words[e]<0;e++)this.words[e]+=67108864,this.words[e+1]-=1;return this._strip()},n.prototype.addn=function(t){return this.clone().iaddn(t)},n.prototype.subn=function(t){return this.clone().isubn(t)},n.prototype.iabs=function(){return this.negative=0,this},n.prototype.abs=function(){return this.clone().iabs()},n.prototype._ishlnsubmul=function(t,e,i){var n,o,a=t.length+i;this._expand(a);var s=0;for(n=0;n<t.length;n++){o=(0|this.words[n+i])+s;var h=(0|t.words[n])*e;s=((o-=67108863&h)>>26)-(h/67108864|0),this.words[n+i]=67108863&o}for(;n<this.length-i;n++)s=(o=(0|this.words[n+i])+s)>>26,this.words[n+i]=67108863&o;if(0===s)return this._strip();for(r(-1===s),s=0,n=0;n<this.length;n++)s=(o=-(0|this.words[n])+s)>>26,this.words[n]=67108863&o;return this.negative=1,this._strip()},n.prototype._wordDiv=function(t,e){var r=(this.length,t.length),i=this.clone(),o=t,a=0|o.words[o.length-1];0!==(r=26-this._countBits(a))&&(o=o.ushln(r),i.iushln(r),a=0|o.words[o.length-1]);var s,h=i.length-o.length;if("mod"!==e){(s=new n(null)).length=h+1,s.words=new Array(s.length);for(var u=0;u<s.length;u++)s.words[u]=0}var l=i.clone()._ishlnsubmul(o,1,h);0===l.negative&&(i=l,s&&(s.words[h]=1));for(var c=h-1;c>=0;c--){var d=67108864*(0|i.words[o.length+c])+(0|i.words[o.length+c-1]);for(d=Math.min(d/a|0,67108863),i._ishlnsubmul(o,d,c);0!==i.negative;)d--,i.negative=0,i._ishlnsubmul(o,1,c),i.isZero()||(i.negative^=1);s&&(s.words[c]=d)}return s&&s._strip(),i._strip(),"div"!==e&&0!==r&&i.iushrn(r),{div:s||null,mod:i}},n.prototype.divmod=function(t,e,i){return r(!t.isZero()),this.isZero()?{div:new n(0),mod:new n(0)}:0!==this.negative&&0===t.negative?(s=this.neg().divmod(t,e),"mod"!==e&&(o=s.div.neg()),"div"!==e&&(a=s.mod.neg(),i&&0!==a.negative&&a.iadd(t)),{div:o,mod:a}):0===this.negative&&0!==t.negative?(s=this.divmod(t.neg(),e),"mod"!==e&&(o=s.div.neg()),{div:o,mod:s.mod}):0!=(this.negative&t.negative)?(s=this.neg().divmod(t.neg(),e),"div"!==e&&(a=s.mod.neg(),i&&0!==a.negative&&a.isub(t)),{div:s.div,mod:a}):t.length>this.length||this.cmp(t)<0?{div:new n(0),mod:this}:1===t.length?"div"===e?{div:this.divn(t.words[0]),mod:null}:"mod"===e?{div:null,mod:new n(this.modrn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new n(this.modrn(t.words[0]))}:this._wordDiv(t,e);var o,a,s},n.prototype.div=function(t){return this.divmod(t,"div",!1).div},n.prototype.mod=function(t){return this.divmod(t,"mod",!1).mod},n.prototype.umod=function(t){return this.divmod(t,"mod",!0).mod},n.prototype.divRound=function(t){var e=this.divmod(t);if(e.mod.isZero())return e.div;var r=0!==e.div.negative?e.mod.isub(t):e.mod,i=t.ushrn(1),n=t.andln(1),o=r.cmp(i);return o<0||1===n&&0===o?e.div:0!==e.div.negative?e.div.isubn(1):e.div.iaddn(1)},n.prototype.modrn=function(t){var e=t<0;e&&(t=-t),r(t<=67108863);for(var i=(1<<26)%t,n=0,o=this.length-1;o>=0;o--)n=(i*n+(0|this.words[o]))%t;return e?-n:n},n.prototype.modn=function(t){return this.modrn(t)},n.prototype.idivn=function(t){var e=t<0;e&&(t=-t),r(t<=67108863);for(var i=0,n=this.length-1;n>=0;n--){var o=(0|this.words[n])+67108864*i;this.words[n]=o/t|0,i=o%t}return this._strip(),e?this.ineg():this},n.prototype.divn=function(t){return this.clone().idivn(t)},n.prototype.egcd=function(t){r(0===t.negative),r(!t.isZero());var e=this,i=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var o=new n(1),a=new n(0),s=new n(0),h=new n(1),u=0;e.isEven()&&i.isEven();)e.iushrn(1),i.iushrn(1),++u;for(var l=i.clone(),c=e.clone();!e.isZero();){for(var d=0,f=1;0==(e.words[0]&f)&&d<26;++d,f<<=1);if(d>0)for(e.iushrn(d);d-- >0;)(o.isOdd()||a.isOdd())&&(o.iadd(l),a.isub(c)),o.iushrn(1),a.iushrn(1);for(var m=0,p=1;0==(i.words[0]&p)&&m<26;++m,p<<=1);if(m>0)for(i.iushrn(m);m-- >0;)(s.isOdd()||h.isOdd())&&(s.iadd(l),h.isub(c)),s.iushrn(1),h.iushrn(1);e.cmp(i)>=0?(e.isub(i),o.isub(s),a.isub(h)):(i.isub(e),s.isub(o),h.isub(a))}return{a:s,b:h,gcd:i.iushln(u)}},n.prototype._invmp=function(t){r(0===t.negative),r(!t.isZero());var e=this,i=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var o,a=new n(1),s=new n(0),h=i.clone();e.cmpn(1)>0&&i.cmpn(1)>0;){for(var u=0,l=1;0==(e.words[0]&l)&&u<26;++u,l<<=1);if(u>0)for(e.iushrn(u);u-- >0;)a.isOdd()&&a.iadd(h),a.iushrn(1);for(var c=0,d=1;0==(i.words[0]&d)&&c<26;++c,d<<=1);if(c>0)for(i.iushrn(c);c-- >0;)s.isOdd()&&s.iadd(h),s.iushrn(1);e.cmp(i)>=0?(e.isub(i),a.isub(s)):(i.isub(e),s.isub(a))}return(o=0===e.cmpn(1)?a:s).cmpn(0)<0&&o.iadd(t),o},n.prototype.gcd=function(t){if(this.isZero())return t.abs();if(t.isZero())return this.abs();var e=this.clone(),r=t.clone();e.negative=0,r.negative=0;for(var i=0;e.isEven()&&r.isEven();i++)e.iushrn(1),r.iushrn(1);for(;;){for(;e.isEven();)e.iushrn(1);for(;r.isEven();)r.iushrn(1);var n=e.cmp(r);if(n<0){var o=e;e=r,r=o}else if(0===n||0===r.cmpn(1))break;e.isub(r)}return r.iushln(i)},n.prototype.invm=function(t){return this.egcd(t).a.umod(t)},n.prototype.isEven=function(){return 0==(1&this.words[0])},n.prototype.isOdd=function(){return 1==(1&this.words[0])},n.prototype.andln=function(t){return this.words[0]&t},n.prototype.bincn=function(t){r("number"==typeof t);var e=t%26,i=(t-e)/26,n=1<<e;if(this.length<=i)return this._expand(i+1),this.words[i]|=n,this;for(var o=n,a=i;0!==o&&a<this.length;a++){var s=0|this.words[a];o=(s+=o)>>>26,s&=67108863,this.words[a]=s}return 0!==o&&(this.words[a]=o,this.length++),this},n.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},n.prototype.cmpn=function(t){var e,i=t<0;if(0!==this.negative&&!i)return-1;if(0===this.negative&&i)return 1;if(this._strip(),this.length>1)e=1;else{i&&(t=-t),r(t<=67108863,"Number is too big");var n=0|this.words[0];e=n===t?0:n<t?-1:1}return 0!==this.negative?0|-e:e},n.prototype.cmp=function(t){if(0!==this.negative&&0===t.negative)return-1;if(0===this.negative&&0!==t.negative)return 1;var e=this.ucmp(t);return 0!==this.negative?0|-e:e},n.prototype.ucmp=function(t){if(this.length>t.length)return 1;if(this.length<t.length)return-1;for(var e=0,r=this.length-1;r>=0;r--){var i=0|this.words[r],n=0|t.words[r];if(i!==n){i<n?e=-1:i>n&&(e=1);break}}return e},n.prototype.gtn=function(t){return 1===this.cmpn(t)},n.prototype.gt=function(t){return 1===this.cmp(t)},n.prototype.gten=function(t){return this.cmpn(t)>=0},n.prototype.gte=function(t){return this.cmp(t)>=0},n.prototype.ltn=function(t){return-1===this.cmpn(t)},n.prototype.lt=function(t){return-1===this.cmp(t)},n.prototype.lten=function(t){return this.cmpn(t)<=0},n.prototype.lte=function(t){return this.cmp(t)<=0},n.prototype.eqn=function(t){return 0===this.cmpn(t)},n.prototype.eq=function(t){return 0===this.cmp(t)},n.red=function(t){return new E(t)},n.prototype.toRed=function(t){return r(!this.red,"Already a number in reduction context"),r(0===this.negative,"red works only with positives"),t.convertTo(this)._forceRed(t)},n.prototype.fromRed=function(){return r(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},n.prototype._forceRed=function(t){return this.red=t,this},n.prototype.forceRed=function(t){return r(!this.red,"Already a number in reduction context"),this._forceRed(t)},n.prototype.redAdd=function(t){return r(this.red,"redAdd works only with red numbers"),this.red.add(this,t)},n.prototype.redIAdd=function(t){return r(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,t)},n.prototype.redSub=function(t){return r(this.red,"redSub works only with red numbers"),this.red.sub(this,t)},n.prototype.redISub=function(t){return r(this.red,"redISub works only with red numbers"),this.red.isub(this,t)},n.prototype.redShl=function(t){return r(this.red,"redShl works only with red numbers"),this.red.shl(this,t)},n.prototype.redMul=function(t){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.mul(this,t)},n.prototype.redIMul=function(t){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.imul(this,t)},n.prototype.redSqr=function(){return r(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},n.prototype.redISqr=function(){return r(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},n.prototype.redSqrt=function(){return r(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},n.prototype.redInvm=function(){return r(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},n.prototype.redNeg=function(){return r(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},n.prototype.redPow=function(t){return r(this.red&&!t.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,t)};var w={k256:null,p224:null,p192:null,p25519:null};function v(t,e){this.name=t,this.p=new n(e,16),this.n=this.p.bitLength(),this.k=new n(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function b(){v.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function k(){v.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function M(){v.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function _(){v.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function E(t){if("string"==typeof t){var e=n._prime(t);this.m=e.p,this.prime=e}else r(t.gtn(1),"modulus must be greater than 1"),this.m=t,this.prime=null}function A(t){E.call(this,t),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new n(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)}v.prototype._tmp=function(){var t=new n(null);return t.words=new Array(Math.ceil(this.n/13)),t},v.prototype.ireduce=function(t){var e,r=t;do{this.split(r,this.tmp),e=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(e>this.n);var i=e<this.n?-1:r.ucmp(this.p);return 0===i?(r.words[0]=0,r.length=1):i>0?r.isub(this.p):void 0!==r.strip?r.strip():r._strip(),r},v.prototype.split=function(t,e){t.iushrn(this.n,0,e)},v.prototype.imulK=function(t){return t.imul(this.k)},i(b,v),b.prototype.split=function(t,e){for(var r=4194303,i=Math.min(t.length,9),n=0;n<i;n++)e.words[n]=t.words[n];if(e.length=i,t.length<=9)return t.words[0]=0,void(t.length=1);var o=t.words[9];for(e.words[e.length++]=o&r,n=10;n<t.length;n++){var a=0|t.words[n];t.words[n-10]=(a&r)<<4|o>>>22,o=a}o>>>=22,t.words[n-10]=o,0===o&&t.length>10?t.length-=10:t.length-=9},b.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var e=0,r=0;r<t.length;r++){var i=0|t.words[r];e+=977*i,t.words[r]=67108863&e,e=64*i+(e/67108864|0)}return 0===t.words[t.length-1]&&(t.length--,0===t.words[t.length-1]&&t.length--),t},i(k,v),i(M,v),i(_,v),_.prototype.imulK=function(t){for(var e=0,r=0;r<t.length;r++){var i=19*(0|t.words[r])+e,n=67108863&i;i>>>=26,t.words[r]=n,e=i}return 0!==e&&(t.words[t.length++]=e),t},n._prime=function(t){if(w[t])return w[t];var e;if("k256"===t)e=new b;else if("p224"===t)e=new k;else if("p192"===t)e=new M;else{if("p25519"!==t)throw new Error("Unknown prime "+t);e=new _}return w[t]=e,e},E.prototype._verify1=function(t){r(0===t.negative,"red works only with positives"),r(t.red,"red works only with red numbers")},E.prototype._verify2=function(t,e){r(0==(t.negative|e.negative),"red works only with positives"),r(t.red&&t.red===e.red,"red works only with red numbers")},E.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):(u(t,t.umod(this.m)._forceRed(this)),t)},E.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},E.prototype.add=function(t,e){this._verify2(t,e);var r=t.add(e);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},E.prototype.iadd=function(t,e){this._verify2(t,e);var r=t.iadd(e);return r.cmp(this.m)>=0&&r.isub(this.m),r},E.prototype.sub=function(t,e){this._verify2(t,e);var r=t.sub(e);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},E.prototype.isub=function(t,e){this._verify2(t,e);var r=t.isub(e);return r.cmpn(0)<0&&r.iadd(this.m),r},E.prototype.shl=function(t,e){return this._verify1(t),this.imod(t.ushln(e))},E.prototype.imul=function(t,e){return this._verify2(t,e),this.imod(t.imul(e))},E.prototype.mul=function(t,e){return this._verify2(t,e),this.imod(t.mul(e))},E.prototype.isqr=function(t){return this.imul(t,t.clone())},E.prototype.sqr=function(t){return this.mul(t,t)},E.prototype.sqrt=function(t){if(t.isZero())return t.clone();var e=this.m.andln(3);if(r(e%2==1),3===e){var i=this.m.add(new n(1)).iushrn(2);return this.pow(t,i)}for(var o=this.m.subn(1),a=0;!o.isZero()&&0===o.andln(1);)a++,o.iushrn(1);r(!o.isZero());var s=new n(1).toRed(this),h=s.redNeg(),u=this.m.subn(1).iushrn(1),l=this.m.bitLength();for(l=new n(2*l*l).toRed(this);0!==this.pow(l,u).cmp(h);)l.redIAdd(h);for(var c=this.pow(l,o),d=this.pow(t,o.addn(1).iushrn(1)),f=this.pow(t,o),m=a;0!==f.cmp(s);){for(var p=f,g=0;0!==p.cmp(s);g++)p=p.redSqr();r(g<m);var y=this.pow(c,new n(1).iushln(m-g-1));d=d.redMul(y),c=y.redSqr(),f=f.redMul(c),m=g}return d},E.prototype.invm=function(t){var e=t._invmp(this.m);return 0!==e.negative?(e.negative=0,this.imod(e).redNeg()):this.imod(e)},E.prototype.pow=function(t,e){if(e.isZero())return new n(1).toRed(this);if(0===e.cmpn(1))return t.clone();var r=new Array(16);r[0]=new n(1).toRed(this),r[1]=t;for(var i=2;i<r.length;i++)r[i]=this.mul(r[i-1],t);var o=r[0],a=0,s=0,h=e.bitLength()%26;for(0===h&&(h=26),i=e.length-1;i>=0;i--){for(var u=e.words[i],l=h-1;l>=0;l--){var c=u>>l&1;o!==r[0]&&(o=this.sqr(o)),0!==c||0!==a?(a<<=1,a|=c,(4===++s||0===i&&0===l)&&(o=this.mul(o,r[a]),s=0,a=0)):s=0}h=26}return o},E.prototype.convertTo=function(t){var e=t.umod(this.m);return e===t?e.clone():e},E.prototype.convertFrom=function(t){var e=t.clone();return e.red=null,e},n.mont=function(t){return new A(t)},i(A,E),A.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},A.prototype.convertFrom=function(t){var e=this.imod(t.mul(this.rinv));return e.red=null,e},A.prototype.imul=function(t,e){if(t.isZero()||e.isZero())return t.words[0]=0,t.length=1,t;var r=t.imul(e),i=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),n=r.isub(i).iushrn(this.shift),o=n;return n.cmp(this.m)>=0?o=n.isub(this.m):n.cmpn(0)<0&&(o=n.iadd(this.m)),o._forceRed(this)},A.prototype.mul=function(t,e){if(t.isZero()||e.isZero())return new n(0)._forceRed(this);var r=t.mul(e),i=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),o=r.isub(i).iushrn(this.shift),a=o;return o.cmp(this.m)>=0?a=o.isub(this.m):o.cmpn(0)<0&&(a=o.iadd(this.m)),a._forceRed(this)},A.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}(t,i)}));var He=Ve.BN;const Ge=new w("bignumber/5.6.2"),Ze={},Ke=9007199254740991;let Je=!1;class We{constructor(t,e){t!==Ze&&Ge.throwError("cannot call constructor directly; use BigNumber.from",w.errors.UNSUPPORTED_OPERATION,{operation:"new (BigNumber)"}),this._hex=e,this._isBigNumber=!0,Object.freeze(this)}fromTwos(t){return Qe(Xe(this).fromTwos(t))}toTwos(t){return Qe(Xe(this).toTwos(t))}abs(){return"-"===this._hex[0]?We.from(this._hex.substring(1)):this}add(t){return Qe(Xe(this).add(Xe(t)))}sub(t){return Qe(Xe(this).sub(Xe(t)))}div(t){return We.from(t).isZero()&&tr("division-by-zero","div"),Qe(Xe(this).div(Xe(t)))}mul(t){return Qe(Xe(this).mul(Xe(t)))}mod(t){const e=Xe(t);return e.isNeg()&&tr("division-by-zero","mod"),Qe(Xe(this).umod(e))}pow(t){const e=Xe(t);return e.isNeg()&&tr("negative-power","pow"),Qe(Xe(this).pow(e))}and(t){const e=Xe(t);return(this.isNegative()||e.isNeg())&&tr("unbound-bitwise-result","and"),Qe(Xe(this).and(e))}or(t){const e=Xe(t);return(this.isNegative()||e.isNeg())&&tr("unbound-bitwise-result","or"),Qe(Xe(this).or(e))}xor(t){const e=Xe(t);return(this.isNegative()||e.isNeg())&&tr("unbound-bitwise-result","xor"),Qe(Xe(this).xor(e))}mask(t){return(this.isNegative()||t<0)&&tr("negative-width","mask"),Qe(Xe(this).maskn(t))}shl(t){return(this.isNegative()||t<0)&&tr("negative-width","shl"),Qe(Xe(this).shln(t))}shr(t){return(this.isNegative()||t<0)&&tr("negative-width","shr"),Qe(Xe(this).shrn(t))}eq(t){return Xe(this).eq(Xe(t))}lt(t){return Xe(this).lt(Xe(t))}lte(t){return Xe(this).lte(Xe(t))}gt(t){return Xe(this).gt(Xe(t))}gte(t){return Xe(this).gte(Xe(t))}isNegative(){return"-"===this._hex[0]}isZero(){return Xe(this).isZero()}toNumber(){try{return Xe(this).toNumber()}catch(t){tr("overflow","toNumber",this.toString())}return null}toBigInt(){try{return BigInt(this.toString())}catch(t){}return Ge.throwError("this platform does not support BigInt",w.errors.UNSUPPORTED_OPERATION,{value:this.toString()})}toString(){return arguments.length>0&&(10===arguments[0]?Je||(Je=!0,Ge.warn("BigNumber.toString does not accept any parameters; base-10 is assumed")):16===arguments[0]?Ge.throwError("BigNumber.toString does not accept any parameters; use bigNumber.toHexString()",w.errors.UNEXPECTED_ARGUMENT,{}):Ge.throwError("BigNumber.toString does not accept parameters",w.errors.UNEXPECTED_ARGUMENT,{})),Xe(this).toString(10)}toHexString(){return this._hex}toJSON(t){return{type:"BigNumber",hex:this.toHexString()}}static from(t){if(t instanceof We)return t;if("string"==typeof t)return t.match(/^-?0x[0-9a-f]+$/i)?new We(Ze,Ye(t)):t.match(/^-?[0-9]+$/)?new We(Ze,Ye(new He(t))):Ge.throwArgumentError("invalid BigNumber string","value",t);if("number"==typeof t)return t%1&&tr("underflow","BigNumber.from",t),(t>=Ke||t<=-Ke)&&tr("overflow","BigNumber.from",t),We.from(String(t));const e=t;if("bigint"==typeof e)return We.from(e.toString());if(E(e))return We.from(I(e));if(e)if(e.toHexString){const t=e.toHexString();if("string"==typeof t)return We.from(t)}else{let t=e._hex;if(null==t&&"BigNumber"===e.type&&(t=e.hex),"string"==typeof t&&(S(t)||"-"===t[0]&&S(t.substring(1))))return We.from(t)}return Ge.throwArgumentError("invalid BigNumber value","value",t)}static isBigNumber(t){return!(!t||!t._isBigNumber)}}function Ye(t){if("string"!=typeof t)return Ye(t.toString(16));if("-"===t[0])return"-"===(t=t.substring(1))[0]&&Ge.throwArgumentError("invalid hex","value",t),"0x00"===(t=Ye(t))?t:"-"+t;if("0x"!==t.substring(0,2)&&(t="0x"+t),"0x"===t)return"0x00";for(t.length%2&&(t="0x0"+t.substring(2));t.length>4&&"0x00"===t.substring(0,4);)t="0x"+t.substring(4);return t}function Qe(t){return We.from(Ye(t))}function Xe(t){const e=We.from(t).toHexString();return"-"===e[0]?new He("-"+e.substring(3),16):new He(e.substring(2),16)}function tr(t,e,r){const i={fault:t,operation:e};return null!=r&&(i.value=r),Ge.throwError(t,w.errors.NUMERIC_FAULT,i)}var er=window&&window.__awaiter||function(t,e,r,i){return new(r||(r=Promise))((function(n,o){function a(t){try{h(i.next(t))}catch(t){o(t)}}function s(t){try{h(i.throw(t))}catch(t){o(t)}}function h(t){var e;t.done?n(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(a,s)}h((i=i.apply(t,e||[])).next())}))};const rr=new w("properties/5.6.0");function ir(t,e,r){Object.defineProperty(t,e,{enumerable:!0,value:r,writable:!1})}function nr(t,e){for(let r=0;r<32;r++){if(t[e])return t[e];if(!t.prototype||"object"!=typeof t.prototype)break;t=Object.getPrototypeOf(t.prototype).constructor}return null}function or(t){return er(this,void 0,void 0,(function*(){const e=Object.keys(t).map((e=>{const r=t[e];return Promise.resolve(r).then((t=>({key:e,value:t})))}));return(yield Promise.all(e)).reduce(((t,e)=>(t[e.key]=e.value,t)),{})}))}function ar(t){const e={};for(const r in t)e[r]=t[r];return e}const sr={bigint:!0,boolean:!0,function:!0,number:!0,string:!0};function hr(t){if(null==t||sr[typeof t])return!0;if(Array.isArray(t)||"object"==typeof t){if(!Object.isFrozen(t))return!1;const e=Object.keys(t);for(let r=0;r<e.length;r++){let i=null;try{i=t[e[r]]}catch(t){continue}if(!hr(i))return!1}return!0}return rr.throwArgumentError("Cannot deepCopy "+typeof t,"object",t)}function ur(t){if(hr(t))return t;if(Array.isArray(t))return Object.freeze(t.map((t=>lr(t))));if("object"==typeof t){const e={};for(const r in t){const i=t[r];void 0!==i&&ir(e,r,lr(i))}return e}return rr.throwArgumentError("Cannot deepCopy "+typeof t,"object",t)}function lr(t){return ur(t)}class cr{constructor(t){for(const e in t)this[e]=lr(t[e])}}const dr="abi/5.6.4",fr=new w(dr),mr={};let pr={calldata:!0,memory:!0,storage:!0},gr={calldata:!0,memory:!0};function yr(t,e){if("bytes"===t||"string"===t){if(pr[e])return!0}else if("address"===t){if("payable"===e)return!0}else if((t.indexOf("[")>=0||"tuple"===t)&&gr[e])return!0;return(pr[e]||"payable"===e)&&fr.throwArgumentError("invalid modifier","name",e),!1}function wr(t,e){for(let r in e)ir(t,r,e[r])}const vr=Object.freeze({sighash:"sighash",minimal:"minimal",full:"full",json:"json"}),br=new RegExp(/^(.*)\[([0-9]*)\]$/);class kr{constructor(t,e){t!==mr&&fr.throwError("use fromString",w.errors.UNSUPPORTED_OPERATION,{operation:"new ParamType()"}),wr(this,e);let r=this.type.match(br);wr(this,r?{arrayLength:parseInt(r[2]||"-1"),arrayChildren:kr.fromObject({type:r[1],components:this.components}),baseType:"array"}:{arrayLength:null,arrayChildren:null,baseType:null!=this.components?"tuple":this.type}),this._isParamType=!0,Object.freeze(this)}format(t){if(t||(t=vr.sighash),vr[t]||fr.throwArgumentError("invalid format type","format",t),t===vr.json){let e={type:"tuple"===this.baseType?"tuple":this.type,name:this.name||void 0};return"boolean"==typeof this.indexed&&(e.indexed=this.indexed),this.components&&(e.components=this.components.map((e=>JSON.parse(e.format(t))))),JSON.stringify(e)}let e="";return"array"===this.baseType?(e+=this.arrayChildren.format(t),e+="["+(this.arrayLength<0?"":String(this.arrayLength))+"]"):"tuple"===this.baseType?(t!==vr.sighash&&(e+=this.type),e+="("+this.components.map((e=>e.format(t))).join(t===vr.full?", ":",")+")"):e+=this.type,t!==vr.sighash&&(!0===this.indexed&&(e+=" indexed"),t===vr.full&&this.name&&(e+=" "+this.name)),e}static from(t,e){return"string"==typeof t?kr.fromString(t,e):kr.fromObject(t)}static fromObject(t){return kr.isParamType(t)?t:new kr(mr,{name:t.name||null,type:Cr(t.type),indexed:null==t.indexed?null:!!t.indexed,components:t.components?t.components.map(kr.fromObject):null})}static fromString(t,e){return r=function(t,e){let r=t;function i(e){fr.throwArgumentError(`unexpected character at position ${e}`,"param",t)}function n(t){let r={type:"",name:"",parent:t,state:{allowType:!0}};return e&&(r.indexed=!1),r}t=t.replace(/\s/g," ");let o={type:"",name:"",state:{allowType:!0}},a=o;for(let r=0;r<t.length;r++){let o=t[r];switch(o){case"(":a.state.allowType&&""===a.type?a.type="tuple":a.state.allowParams||i(r),a.state.allowType=!1,a.type=Cr(a.type),a.components=[n(a)],a=a.components[0];break;case")":delete a.state,"indexed"===a.name&&(e||i(r),a.indexed=!0,a.name=""),yr(a.type,a.name)&&(a.name=""),a.type=Cr(a.type);let t=a;a=a.parent,a||i(r),delete t.parent,a.state.allowParams=!1,a.state.allowName=!0,a.state.allowArray=!0;break;case",":delete a.state,"indexed"===a.name&&(e||i(r),a.indexed=!0,a.name=""),yr(a.type,a.name)&&(a.name=""),a.type=Cr(a.type);let s=n(a.parent);a.parent.components.push(s),delete a.parent,a=s;break;case" ":a.state.allowType&&""!==a.type&&(a.type=Cr(a.type),delete a.state.allowType,a.state.allowName=!0,a.state.allowParams=!0),a.state.allowName&&""!==a.name&&("indexed"===a.name?(e||i(r),a.indexed&&i(r),a.indexed=!0,a.name=""):yr(a.type,a.name)?a.name="":a.state.allowName=!1);break;case"[":a.state.allowArray||i(r),a.type+=o,a.state.allowArray=!1,a.state.allowName=!1,a.state.readArray=!0;break;case"]":a.state.readArray||i(r),a.type+=o,a.state.readArray=!1,a.state.allowArray=!0,a.state.allowName=!0;break;default:a.state.allowType?(a.type+=o,a.state.allowParams=!0,a.state.allowArray=!0):a.state.allowName?(a.name+=o,delete a.state.allowArray):a.state.readArray?a.type+=o:i(r)}}return a.parent&&fr.throwArgumentError("unexpected eof","param",t),delete o.state,"indexed"===a.name?(e||i(r.length-7),a.indexed&&i(r.length-7),a.indexed=!0,a.name=""):yr(a.type,a.name)&&(a.name=""),o.type=Cr(o.type),o}(t,!!e),kr.fromObject({name:r.name,type:r.type,indexed:r.indexed,components:r.components});var r}static isParamType(t){return!(null==t||!t._isParamType)}}function Mr(t,e){return function(t){t=t.trim();let e=[],r="",i=0;for(let n=0;n<t.length;n++){let o=t[n];","===o&&0===i?(e.push(r),r=""):(r+=o,"("===o?i++:")"===o&&(i--,-1===i&&fr.throwArgumentError("unbalanced parenthesis","value",t)))}r&&e.push(r);return e}(t).map((t=>kr.fromString(t,e)))}class _r{constructor(t,e){t!==mr&&fr.throwError("use a static from method",w.errors.UNSUPPORTED_OPERATION,{operation:"new Fragment()"}),wr(this,e),this._isFragment=!0,Object.freeze(this)}static from(t){return _r.isFragment(t)?t:"string"==typeof t?_r.fromString(t):_r.fromObject(t)}static fromObject(t){if(_r.isFragment(t))return t;switch(t.type){case"function":return Nr.fromObject(t);case"event":return Er.fromObject(t);case"constructor":return Sr.fromObject(t);case"error":return Tr.fromObject(t);case"fallback":case"receive":return null}return fr.throwArgumentError("invalid fragment object","value",t)}static fromString(t){return"event"===(t=(t=(t=t.replace(/\s/g," ")).replace(/\(/g," (").replace(/\)/g,") ").replace(/\s+/g," ")).trim()).split(" ")[0]?Er.fromString(t.substring(5).trim()):"function"===t.split(" ")[0]?Nr.fromString(t.substring(8).trim()):"constructor"===t.split("(")[0].trim()?Sr.fromString(t.trim()):"error"===t.split(" ")[0]?Tr.fromString(t.substring(5).trim()):fr.throwArgumentError("unsupported fragment","value",t)}static isFragment(t){return!(!t||!t._isFragment)}}class Er extends _r{format(t){if(t||(t=vr.sighash),vr[t]||fr.throwArgumentError("invalid format type","format",t),t===vr.json)return JSON.stringify({type:"event",anonymous:this.anonymous,name:this.name,inputs:this.inputs.map((e=>JSON.parse(e.format(t))))});let e="";return t!==vr.sighash&&(e+="event "),e+=this.name+"("+this.inputs.map((e=>e.format(t))).join(t===vr.full?", ":",")+") ",t!==vr.sighash&&this.anonymous&&(e+="anonymous "),e.trim()}static from(t){return"string"==typeof t?Er.fromString(t):Er.fromObject(t)}static fromObject(t){if(Er.isEventFragment(t))return t;"event"!==t.type&&fr.throwArgumentError("invalid event object","value",t);const e={name:Or(t.name),anonymous:t.anonymous,inputs:t.inputs?t.inputs.map(kr.fromObject):[],type:"event"};return new Er(mr,e)}static fromString(t){let e=t.match(Rr);e||fr.throwArgumentError("invalid event string","value",t);let r=!1;return e[3].split(" ").forEach((t=>{switch(t.trim()){case"anonymous":r=!0;break;case"":break;default:fr.warn("unknown modifier: "+t)}})),Er.fromObject({name:e[1].trim(),anonymous:r,inputs:Mr(e[2],!0),type:"event"})}static isEventFragment(t){return t&&t._isFragment&&"event"===t.type}}function Ar(t,e){e.gas=null;let r=t.split("@");return 1!==r.length?(r.length>2&&fr.throwArgumentError("invalid human-readable ABI signature","value",t),r[1].match(/^[0-9]+$/)||fr.throwArgumentError("invalid human-readable ABI signature gas","value",t),e.gas=We.from(r[1]),r[0]):t}function jr(t,e){e.constant=!1,e.payable=!1,e.stateMutability="nonpayable",t.split(" ").forEach((t=>{switch(t.trim()){case"constant":e.constant=!0;break;case"payable":e.payable=!0,e.stateMutability="payable";break;case"nonpayable":e.payable=!1,e.stateMutability="nonpayable";break;case"pure":e.constant=!0,e.stateMutability="pure";break;case"view":e.constant=!0,e.stateMutability="view";break;case"external":case"public":case"":break;default:console.log("unknown modifier: "+t)}}))}function xr(t){let e={constant:!1,payable:!0,stateMutability:"payable"};return null!=t.stateMutability?(e.stateMutability=t.stateMutability,e.constant="view"===e.stateMutability||"pure"===e.stateMutability,null!=t.constant&&!!t.constant!==e.constant&&fr.throwArgumentError("cannot have constant function with mutability "+e.stateMutability,"value",t),e.payable="payable"===e.stateMutability,null!=t.payable&&!!t.payable!==e.payable&&fr.throwArgumentError("cannot have payable function with mutability "+e.stateMutability,"value",t)):null!=t.payable?(e.payable=!!t.payable,null!=t.constant||e.payable||"constructor"===t.type||fr.throwArgumentError("unable to determine stateMutability","value",t),e.constant=!!t.constant,e.constant?e.stateMutability="view":e.stateMutability=e.payable?"payable":"nonpayable",e.payable&&e.constant&&fr.throwArgumentError("cannot have constant payable function","value",t)):null!=t.constant?(e.constant=!!t.constant,e.payable=!e.constant,e.stateMutability=e.constant?"view":"payable"):"constructor"!==t.type&&fr.throwArgumentError("unable to determine stateMutability","value",t),e}class Sr extends _r{format(t){if(t||(t=vr.sighash),vr[t]||fr.throwArgumentError("invalid format type","format",t),t===vr.json)return JSON.stringify({type:"constructor",stateMutability:"nonpayable"!==this.stateMutability?this.stateMutability:void 0,payable:this.payable,gas:this.gas?this.gas.toNumber():void 0,inputs:this.inputs.map((e=>JSON.parse(e.format(t))))});t===vr.sighash&&fr.throwError("cannot format a constructor for sighash",w.errors.UNSUPPORTED_OPERATION,{operation:"format(sighash)"});let e="constructor("+this.inputs.map((e=>e.format(t))).join(t===vr.full?", ":",")+") ";return this.stateMutability&&"nonpayable"!==this.stateMutability&&(e+=this.stateMutability+" "),e.trim()}static from(t){return"string"==typeof t?Sr.fromString(t):Sr.fromObject(t)}static fromObject(t){if(Sr.isConstructorFragment(t))return t;"constructor"!==t.type&&fr.throwArgumentError("invalid constructor object","value",t);let e=xr(t);e.constant&&fr.throwArgumentError("constructor cannot be constant","value",t);const r={name:null,type:t.type,inputs:t.inputs?t.inputs.map(kr.fromObject):[],payable:e.payable,stateMutability:e.stateMutability,gas:t.gas?We.from(t.gas):null};return new Sr(mr,r)}static fromString(t){let e={type:"constructor"},r=(t=Ar(t,e)).match(Rr);return r&&"constructor"===r[1].trim()||fr.throwArgumentError("invalid constructor string","value",t),e.inputs=Mr(r[2].trim(),!1),jr(r[3].trim(),e),Sr.fromObject(e)}static isConstructorFragment(t){return t&&t._isFragment&&"constructor"===t.type}}class Nr extends Sr{format(t){if(t||(t=vr.sighash),vr[t]||fr.throwArgumentError("invalid format type","format",t),t===vr.json)return JSON.stringify({type:"function",name:this.name,constant:this.constant,stateMutability:"nonpayable"!==this.stateMutability?this.stateMutability:void 0,payable:this.payable,gas:this.gas?this.gas.toNumber():void 0,inputs:this.inputs.map((e=>JSON.parse(e.format(t)))),outputs:this.outputs.map((e=>JSON.parse(e.format(t))))});let e="";return t!==vr.sighash&&(e+="function "),e+=this.name+"("+this.inputs.map((e=>e.format(t))).join(t===vr.full?", ":",")+") ",t!==vr.sighash&&(this.stateMutability?"nonpayable"!==this.stateMutability&&(e+=this.stateMutability+" "):this.constant&&(e+="view "),this.outputs&&this.outputs.length&&(e+="returns ("+this.outputs.map((e=>e.format(t))).join(", ")+") "),null!=this.gas&&(e+="@"+this.gas.toString()+" ")),e.trim()}static from(t){return"string"==typeof t?Nr.fromString(t):Nr.fromObject(t)}static fromObject(t){if(Nr.isFunctionFragment(t))return t;"function"!==t.type&&fr.throwArgumentError("invalid function object","value",t);let e=xr(t);const r={type:t.type,name:Or(t.name),constant:e.constant,inputs:t.inputs?t.inputs.map(kr.fromObject):[],outputs:t.outputs?t.outputs.map(kr.fromObject):[],payable:e.payable,stateMutability:e.stateMutability,gas:t.gas?We.from(t.gas):null};return new Nr(mr,r)}static fromString(t){let e={type:"function"},r=(t=Ar(t,e)).split(" returns ");r.length>2&&fr.throwArgumentError("invalid function string","value",t);let i=r[0].match(Rr);if(i||fr.throwArgumentError("invalid function signature","value",t),e.name=i[1].trim(),e.name&&Or(e.name),e.inputs=Mr(i[2],!1),jr(i[3].trim(),e),r.length>1){let i=r[1].match(Rr);""==i[1].trim()&&""==i[3].trim()||fr.throwArgumentError("unexpected tokens","value",t),e.outputs=Mr(i[2],!1)}else e.outputs=[];return Nr.fromObject(e)}static isFunctionFragment(t){return t&&t._isFragment&&"function"===t.type}}function Ir(t){const e=t.format();return"Error(string)"!==e&&"Panic(uint256)"!==e||fr.throwArgumentError(`cannot specify user defined ${e} error`,"fragment",t),t}class Tr extends _r{format(t){if(t||(t=vr.sighash),vr[t]||fr.throwArgumentError("invalid format type","format",t),t===vr.json)return JSON.stringify({type:"error",name:this.name,inputs:this.inputs.map((e=>JSON.parse(e.format(t))))});let e="";return t!==vr.sighash&&(e+="error "),e+=this.name+"("+this.inputs.map((e=>e.format(t))).join(t===vr.full?", ":",")+") ",e.trim()}static from(t){return"string"==typeof t?Tr.fromString(t):Tr.fromObject(t)}static fromObject(t){if(Tr.isErrorFragment(t))return t;"error"!==t.type&&fr.throwArgumentError("invalid error object","value",t);const e={type:t.type,name:Or(t.name),inputs:t.inputs?t.inputs.map(kr.fromObject):[]};return Ir(new Tr(mr,e))}static fromString(t){let e={type:"error"},r=t.match(Rr);return r||fr.throwArgumentError("invalid error signature","value",t),e.name=r[1].trim(),e.name&&Or(e.name),e.inputs=Mr(r[2],!1),Ir(Tr.fromObject(e))}static isErrorFragment(t){return t&&t._isFragment&&"error"===t.type}}function Cr(t){return t.match(/^uint($|[^1-9])/)?t="uint256"+t.substring(4):t.match(/^int($|[^1-9])/)&&(t="int256"+t.substring(3)),t}const zr=new RegExp("^[a-zA-Z$_][a-zA-Z0-9$_]*$");function Or(t){return t&&t.match(zr)||fr.throwArgumentError(`invalid identifier "${t}"`,"value",t),t}const Rr=new RegExp("^([^)(]*)\\((.*)\\)([^)(]*)$");const Pr=new w(dr);class Br{constructor(t,e,r,i){this.name=t,this.type=e,this.localName=r,this.dynamic=i}_throwError(t,e){Pr.throwArgumentError(t,this.localName,e)}}class Dr{constructor(t){ir(this,"wordSize",t||32),this._data=[],this._dataLength=0,this._padding=new Uint8Array(t)}get data(){return z(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(j(t._data))}writeBytes(t){let e=A(t);const r=e.length%this.wordSize;return r&&(e=j([e,this._padding.slice(r)])),this._writeData(e)}_getValue(t){let e=A(We.from(t));return e.length>this.wordSize&&Pr.throwError("value out-of-bounds",w.errors.BUFFER_OVERRUN,{length:this.wordSize,offset:e.length}),e.length%this.wordSize&&(e=j([this._padding.slice(e.length%this.wordSize),e])),e}writeValue(t){return this._writeData(this._getValue(t))}writeUpdatableValue(){const t=this._data.length;return this._data.push(this._padding),this._dataLength+=this.wordSize,e=>{this._data[t]=this._getValue(e)}}}class $r{constructor(t,e,r,i){ir(this,"_data",A(t)),ir(this,"wordSize",e||32),ir(this,"_coerceFunc",r),ir(this,"allowLoose",i),this._offset=0}get data(){return I(this._data)}get consumed(){return this._offset}static coerce(t,e){let r=t.match("^u?int([0-9]+)$");return r&&parseInt(r[1])<=48&&(e=e.toNumber()),e}coerce(t,e){return this._coerceFunc?this._coerceFunc(t,e):$r.coerce(t,e)}_peekBytes(t,e,r){let i=Math.ceil(e/this.wordSize)*this.wordSize;return this._offset+i>this._data.length&&(this.allowLoose&&r&&this._offset+e<=this._data.length?i=e:Pr.throwError("data out-of-bounds",w.errors.BUFFER_OVERRUN,{length:this._data.length,offset:this._offset+i})),this._data.slice(this._offset,this._offset+i)}subReader(t){return new $r(this._data.slice(this._offset+t),this.wordSize,this._coerceFunc,this.allowLoose)}readBytes(t,e){let r=this._peekBytes(0,t,!!e);return this._offset+=r.length,r.slice(0,t)}readValue(){return We.from(this.readBytes(this.wordSize))}}class Lr extends Br{constructor(t){super("address","address",t,!1)}defaultValue(){return"0x0000000000000000000000000000000000000000"}encode(t,e){try{e=he(e)}catch(t){this._throwError(t.message,e)}return t.writeValue(e)}decode(t){return he(R(t.readValue().toHexString(),20))}}class Fr extends Br{constructor(t){super(t.name,t.type,void 0,t.dynamic),this.coder=t}defaultValue(){return this.coder.defaultValue()}encode(t,e){return this.coder.encode(t,e)}decode(t){return this.coder.decode(t)}}const Ur=new w(dr);function qr(t,e,r){let i=null;if(Array.isArray(r))i=r;else if(r&&"object"==typeof r){let t={};i=e.map((e=>{const i=e.localName;return i||Ur.throwError("cannot encode object for signature with missing names",w.errors.INVALID_ARGUMENT,{argument:"values",coder:e,value:r}),t[i]&&Ur.throwError("cannot encode object for signature with duplicate names",w.errors.INVALID_ARGUMENT,{argument:"values",coder:e,value:r}),t[i]=!0,r[i]}))}else Ur.throwArgumentError("invalid tuple value","tuple",r);e.length!==i.length&&Ur.throwArgumentError("types/value length mismatch","tuple",r);let n=new Dr(t.wordSize),o=new Dr(t.wordSize),a=[];e.forEach(((t,e)=>{let r=i[e];if(t.dynamic){let e=o.length;t.encode(o,r);let i=n.writeUpdatableValue();a.push((t=>{i(t+e)}))}else t.encode(n,r)})),a.forEach((t=>{t(n.length)}));let s=t.appendWriter(n);return s+=t.appendWriter(o),s}function Vr(t,e){let r=[],i=t.subReader(0);e.forEach((e=>{let n=null;if(e.dynamic){let r=t.readValue(),o=i.subReader(r.toNumber());try{n=e.decode(o)}catch(t){if(t.code===w.errors.BUFFER_OVERRUN)throw t;n=t,n.baseType=e.name,n.name=e.localName,n.type=e.type}}else try{n=e.decode(t)}catch(t){if(t.code===w.errors.BUFFER_OVERRUN)throw t;n=t,n.baseType=e.name,n.name=e.localName,n.type=e.type}null!=n&&r.push(n)}));const n=e.reduce(((t,e)=>{const r=e.localName;return r&&(t[r]||(t[r]=0),t[r]++),t}),{});e.forEach(((t,e)=>{let i=t.localName;if(!i||1!==n[i])return;if("length"===i&&(i="_length"),null!=r[i])return;const o=r[e];o instanceof Error?Object.defineProperty(r,i,{enumerable:!0,get:()=>{throw o}}):r[i]=o}));for(let t=0;t<r.length;t++){const e=r[t];e instanceof Error&&Object.defineProperty(r,t,{enumerable:!0,get:()=>{throw e}})}return Object.freeze(r)}class Hr extends Br{constructor(t,e,r){super("array",t.type+"["+(e>=0?e:"")+"]",r,-1===e||t.dynamic),this.coder=t,this.length=e}defaultValue(){const t=this.coder.defaultValue(),e=[];for(let r=0;r<this.length;r++)e.push(t);return e}encode(t,e){Array.isArray(e)||this._throwError("expected array value",e);let r=this.length;-1===r&&(r=e.length,t.writeValue(e.length)),Ur.checkArgumentCount(e.length,r,"coder array"+(this.localName?" "+this.localName:""));let i=[];for(let t=0;t<e.length;t++)i.push(this.coder);return qr(t,i,e)}decode(t){let e=this.length;-1===e&&(e=t.readValue().toNumber(),32*e>t._data.length&&Ur.throwError("insufficient data length",w.errors.BUFFER_OVERRUN,{length:t._data.length,count:e}));let r=[];for(let t=0;t<e;t++)r.push(new Fr(this.coder));return t.coerce(this.name,Vr(t,r))}}class Gr extends Br{constructor(t){super("bool","bool",t,!1)}defaultValue(){return!1}encode(t,e){return t.writeValue(e?1:0)}decode(t){return t.coerce(this.type,!t.readValue().isZero())}}class Zr extends Br{constructor(t,e){super(t,t,e,!0)}defaultValue(){return"0x"}encode(t,e){e=A(e);let r=t.writeValue(e.length);return r+=t.writeBytes(e),r}decode(t){return t.readBytes(t.readValue().toNumber(),!0)}}class Kr extends Zr{constructor(t){super("bytes",t)}decode(t){return t.coerce(this.name,I(super.decode(t)))}}class Jr extends Br{constructor(t,e){let r="bytes"+String(t);super(r,r,e,!1),this.size=t}defaultValue(){return"0x0000000000000000000000000000000000000000000000000000000000000000".substring(0,2+2*this.size)}encode(t,e){let r=A(e);return r.length!==this.size&&this._throwError("incorrect data length",e),t.writeBytes(r)}decode(t){return t.coerce(this.name,I(t.readBytes(this.size)))}}class Wr extends Br{constructor(t){super("null","",t,!1)}defaultValue(){return null}encode(t,e){return null!=e&&this._throwError("not null",e),t.writeBytes([])}decode(t){return t.readBytes(0),t.coerce(this.name,null)}}var Yr=a((function(t){!function(t,e){function r(t,e){if(!t)throw new Error(e||"Assertion failed")}function i(t,e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}function n(t,e,r){if(n.isBN(t))return t;this.negative=0,this.words=null,this.length=0,this.red=null,null!==t&&("le"!==e&&"be"!==e||(r=e,e=10),this._init(t||0,e||10,r||"be"))}var o;"object"==typeof t?t.exports=n:e.BN=n,n.BN=n,n.wordSize=26;try{o="undefined"!=typeof window&&void 0!==window.Buffer?window.Buffer:Pt.Buffer}catch(t){}function a(t,e){var i=t.charCodeAt(e);return i>=48&&i<=57?i-48:i>=65&&i<=70?i-55:i>=97&&i<=102?i-87:void r(!1,"Invalid character in "+t)}function s(t,e,r){var i=a(t,r);return r-1>=e&&(i|=a(t,r-1)<<4),i}function h(t,e,i,n){for(var o=0,a=0,s=Math.min(t.length,i),h=e;h<s;h++){var u=t.charCodeAt(h)-48;o*=n,a=u>=49?u-49+10:u>=17?u-17+10:u,r(u>=0&&a<n,"Invalid character"),o+=a}return o}function u(t,e){t.words=e.words,t.length=e.length,t.negative=e.negative,t.red=e.red}if(n.isBN=function(t){return t instanceof n||null!==t&&"object"==typeof t&&t.constructor.wordSize===n.wordSize&&Array.isArray(t.words)},n.max=function(t,e){return t.cmp(e)>0?t:e},n.min=function(t,e){return t.cmp(e)<0?t:e},n.prototype._init=function(t,e,i){if("number"==typeof t)return this._initNumber(t,e,i);if("object"==typeof t)return this._initArray(t,e,i);"hex"===e&&(e=16),r(e===(0|e)&&e>=2&&e<=36);var n=0;"-"===(t=t.toString().replace(/\s+/g,""))[0]&&(n++,this.negative=1),n<t.length&&(16===e?this._parseHex(t,n,i):(this._parseBase(t,e,n),"le"===i&&this._initArray(this.toArray(),e,i)))},n.prototype._initNumber=function(t,e,i){t<0&&(this.negative=1,t=-t),t<67108864?(this.words=[67108863&t],this.length=1):t<4503599627370496?(this.words=[67108863&t,t/67108864&67108863],this.length=2):(r(t<9007199254740992),this.words=[67108863&t,t/67108864&67108863,1],this.length=3),"le"===i&&this._initArray(this.toArray(),e,i)},n.prototype._initArray=function(t,e,i){if(r("number"==typeof t.length),t.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(t.length/3),this.words=new Array(this.length);for(var n=0;n<this.length;n++)this.words[n]=0;var o,a,s=0;if("be"===i)for(n=t.length-1,o=0;n>=0;n-=3)a=t[n]|t[n-1]<<8|t[n-2]<<16,this.words[o]|=a<<s&67108863,this.words[o+1]=a>>>26-s&67108863,(s+=24)>=26&&(s-=26,o++);else if("le"===i)for(n=0,o=0;n<t.length;n+=3)a=t[n]|t[n+1]<<8|t[n+2]<<16,this.words[o]|=a<<s&67108863,this.words[o+1]=a>>>26-s&67108863,(s+=24)>=26&&(s-=26,o++);return this._strip()},n.prototype._parseHex=function(t,e,r){this.length=Math.ceil((t.length-e)/6),this.words=new Array(this.length);for(var i=0;i<this.length;i++)this.words[i]=0;var n,o=0,a=0;if("be"===r)for(i=t.length-1;i>=e;i-=2)n=s(t,e,i)<<o,this.words[a]|=67108863&n,o>=18?(o-=18,a+=1,this.words[a]|=n>>>26):o+=8;else for(i=(t.length-e)%2==0?e+1:e;i<t.length;i+=2)n=s(t,e,i)<<o,this.words[a]|=67108863&n,o>=18?(o-=18,a+=1,this.words[a]|=n>>>26):o+=8;this._strip()},n.prototype._parseBase=function(t,e,r){this.words=[0],this.length=1;for(var i=0,n=1;n<=67108863;n*=e)i++;i--,n=n/e|0;for(var o=t.length-r,a=o%i,s=Math.min(o,o-a)+r,u=0,l=r;l<s;l+=i)u=h(t,l,l+i,e),this.imuln(n),this.words[0]+u<67108864?this.words[0]+=u:this._iaddn(u);if(0!==a){var c=1;for(u=h(t,l,t.length,e),l=0;l<a;l++)c*=e;this.imuln(c),this.words[0]+u<67108864?this.words[0]+=u:this._iaddn(u)}this._strip()},n.prototype.copy=function(t){t.words=new Array(this.length);for(var e=0;e<this.length;e++)t.words[e]=this.words[e];t.length=this.length,t.negative=this.negative,t.red=this.red},n.prototype._move=function(t){u(t,this)},n.prototype.clone=function(){var t=new n(null);return this.copy(t),t},n.prototype._expand=function(t){for(;this.length<t;)this.words[this.length++]=0;return this},n.prototype._strip=function(){for(;this.length>1&&0===this.words[this.length-1];)this.length--;return this._normSign()},n.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},"undefined"!=typeof Symbol&&"function"==typeof Symbol.for)try{n.prototype[Symbol.for("nodejs.util.inspect.custom")]=l}catch(t){n.prototype.inspect=l}else n.prototype.inspect=l;function l(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"}var c=["","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"],d=[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],f=[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];n.prototype.toString=function(t,e){var i;if(e=0|e||1,16===(t=t||10)||"hex"===t){i="";for(var n=0,o=0,a=0;a<this.length;a++){var s=this.words[a],h=(16777215&(s<<n|o)).toString(16);o=s>>>24-n&16777215,(n+=2)>=26&&(n-=26,a--),i=0!==o||a!==this.length-1?c[6-h.length]+h+i:h+i}for(0!==o&&(i=o.toString(16)+i);i.length%e!=0;)i="0"+i;return 0!==this.negative&&(i="-"+i),i}if(t===(0|t)&&t>=2&&t<=36){var u=d[t],l=f[t];i="";var m=this.clone();for(m.negative=0;!m.isZero();){var p=m.modrn(l).toString(t);i=(m=m.idivn(l)).isZero()?p+i:c[u-p.length]+p+i}for(this.isZero()&&(i="0"+i);i.length%e!=0;)i="0"+i;return 0!==this.negative&&(i="-"+i),i}r(!1,"Base should be between 2 and 36")},n.prototype.toNumber=function(){var t=this.words[0];return 2===this.length?t+=67108864*this.words[1]:3===this.length&&1===this.words[2]?t+=4503599627370496+67108864*this.words[1]:this.length>2&&r(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-t:t},n.prototype.toJSON=function(){return this.toString(16,2)},o&&(n.prototype.toBuffer=function(t,e){return this.toArrayLike(o,t,e)}),n.prototype.toArray=function(t,e){return this.toArrayLike(Array,t,e)};function m(t,e,r){r.negative=e.negative^t.negative;var i=t.length+e.length|0;r.length=i,i=i-1|0;var n=0|t.words[0],o=0|e.words[0],a=n*o,s=67108863&a,h=a/67108864|0;r.words[0]=s;for(var u=1;u<i;u++){for(var l=h>>>26,c=67108863&h,d=Math.min(u,e.length-1),f=Math.max(0,u-t.length+1);f<=d;f++){var m=u-f|0;l+=(a=(n=0|t.words[m])*(o=0|e.words[f])+c)/67108864|0,c=67108863&a}r.words[u]=0|c,h=0|l}return 0!==h?r.words[u]=0|h:r.length--,r._strip()}n.prototype.toArrayLike=function(t,e,i){this._strip();var n=this.byteLength(),o=i||Math.max(1,n);r(n<=o,"byte array longer than desired length"),r(o>0,"Requested array length <= 0");var a=function(t,e){return t.allocUnsafe?t.allocUnsafe(e):new t(e)}(t,o);return this["_toArrayLike"+("le"===e?"LE":"BE")](a,n),a},n.prototype._toArrayLikeLE=function(t,e){for(var r=0,i=0,n=0,o=0;n<this.length;n++){var a=this.words[n]<<o|i;t[r++]=255&a,r<t.length&&(t[r++]=a>>8&255),r<t.length&&(t[r++]=a>>16&255),6===o?(r<t.length&&(t[r++]=a>>24&255),i=0,o=0):(i=a>>>24,o+=2)}if(r<t.length)for(t[r++]=i;r<t.length;)t[r++]=0},n.prototype._toArrayLikeBE=function(t,e){for(var r=t.length-1,i=0,n=0,o=0;n<this.length;n++){var a=this.words[n]<<o|i;t[r--]=255&a,r>=0&&(t[r--]=a>>8&255),r>=0&&(t[r--]=a>>16&255),6===o?(r>=0&&(t[r--]=a>>24&255),i=0,o=0):(i=a>>>24,o+=2)}if(r>=0)for(t[r--]=i;r>=0;)t[r--]=0},Math.clz32?n.prototype._countBits=function(t){return 32-Math.clz32(t)}:n.prototype._countBits=function(t){var e=t,r=0;return e>=4096&&(r+=13,e>>>=13),e>=64&&(r+=7,e>>>=7),e>=8&&(r+=4,e>>>=4),e>=2&&(r+=2,e>>>=2),r+e},n.prototype._zeroBits=function(t){if(0===t)return 26;var e=t,r=0;return 0==(8191&e)&&(r+=13,e>>>=13),0==(127&e)&&(r+=7,e>>>=7),0==(15&e)&&(r+=4,e>>>=4),0==(3&e)&&(r+=2,e>>>=2),0==(1&e)&&r++,r},n.prototype.bitLength=function(){var t=this.words[this.length-1],e=this._countBits(t);return 26*(this.length-1)+e},n.prototype.zeroBits=function(){if(this.isZero())return 0;for(var t=0,e=0;e<this.length;e++){var r=this._zeroBits(this.words[e]);if(t+=r,26!==r)break}return t},n.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},n.prototype.toTwos=function(t){return 0!==this.negative?this.abs().inotn(t).iaddn(1):this.clone()},n.prototype.fromTwos=function(t){return this.testn(t-1)?this.notn(t).iaddn(1).ineg():this.clone()},n.prototype.isNeg=function(){return 0!==this.negative},n.prototype.neg=function(){return this.clone().ineg()},n.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},n.prototype.iuor=function(t){for(;this.length<t.length;)this.words[this.length++]=0;for(var e=0;e<t.length;e++)this.words[e]=this.words[e]|t.words[e];return this._strip()},n.prototype.ior=function(t){return r(0==(this.negative|t.negative)),this.iuor(t)},n.prototype.or=function(t){return this.length>t.length?this.clone().ior(t):t.clone().ior(this)},n.prototype.uor=function(t){return this.length>t.length?this.clone().iuor(t):t.clone().iuor(this)},n.prototype.iuand=function(t){var e;e=this.length>t.length?t:this;for(var r=0;r<e.length;r++)this.words[r]=this.words[r]&t.words[r];return this.length=e.length,this._strip()},n.prototype.iand=function(t){return r(0==(this.negative|t.negative)),this.iuand(t)},n.prototype.and=function(t){return this.length>t.length?this.clone().iand(t):t.clone().iand(this)},n.prototype.uand=function(t){return this.length>t.length?this.clone().iuand(t):t.clone().iuand(this)},n.prototype.iuxor=function(t){var e,r;this.length>t.length?(e=this,r=t):(e=t,r=this);for(var i=0;i<r.length;i++)this.words[i]=e.words[i]^r.words[i];if(this!==e)for(;i<e.length;i++)this.words[i]=e.words[i];return this.length=e.length,this._strip()},n.prototype.ixor=function(t){return r(0==(this.negative|t.negative)),this.iuxor(t)},n.prototype.xor=function(t){return this.length>t.length?this.clone().ixor(t):t.clone().ixor(this)},n.prototype.uxor=function(t){return this.length>t.length?this.clone().iuxor(t):t.clone().iuxor(this)},n.prototype.inotn=function(t){r("number"==typeof t&&t>=0);var e=0|Math.ceil(t/26),i=t%26;this._expand(e),i>0&&e--;for(var n=0;n<e;n++)this.words[n]=67108863&~this.words[n];return i>0&&(this.words[n]=~this.words[n]&67108863>>26-i),this._strip()},n.prototype.notn=function(t){return this.clone().inotn(t)},n.prototype.setn=function(t,e){r("number"==typeof t&&t>=0);var i=t/26|0,n=t%26;return this._expand(i+1),this.words[i]=e?this.words[i]|1<<n:this.words[i]&~(1<<n),this._strip()},n.prototype.iadd=function(t){var e,r,i;if(0!==this.negative&&0===t.negative)return this.negative=0,e=this.isub(t),this.negative^=1,this._normSign();if(0===this.negative&&0!==t.negative)return t.negative=0,e=this.isub(t),t.negative=1,e._normSign();this.length>t.length?(r=this,i=t):(r=t,i=this);for(var n=0,o=0;o<i.length;o++)e=(0|r.words[o])+(0|i.words[o])+n,this.words[o]=67108863&e,n=e>>>26;for(;0!==n&&o<r.length;o++)e=(0|r.words[o])+n,this.words[o]=67108863&e,n=e>>>26;if(this.length=r.length,0!==n)this.words[this.length]=n,this.length++;else if(r!==this)for(;o<r.length;o++)this.words[o]=r.words[o];return this},n.prototype.add=function(t){var e;return 0!==t.negative&&0===this.negative?(t.negative=0,e=this.sub(t),t.negative^=1,e):0===t.negative&&0!==this.negative?(this.negative=0,e=t.sub(this),this.negative=1,e):this.length>t.length?this.clone().iadd(t):t.clone().iadd(this)},n.prototype.isub=function(t){if(0!==t.negative){t.negative=0;var e=this.iadd(t);return t.negative=1,e._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(t),this.negative=1,this._normSign();var r,i,n=this.cmp(t);if(0===n)return this.negative=0,this.length=1,this.words[0]=0,this;n>0?(r=this,i=t):(r=t,i=this);for(var o=0,a=0;a<i.length;a++)o=(e=(0|r.words[a])-(0|i.words[a])+o)>>26,this.words[a]=67108863&e;for(;0!==o&&a<r.length;a++)o=(e=(0|r.words[a])+o)>>26,this.words[a]=67108863&e;if(0===o&&a<r.length&&r!==this)for(;a<r.length;a++)this.words[a]=r.words[a];return this.length=Math.max(this.length,a),r!==this&&(this.negative=1),this._strip()},n.prototype.sub=function(t){return this.clone().isub(t)};var p=function(t,e,r){var i,n,o,a=t.words,s=e.words,h=r.words,u=0,l=0|a[0],c=8191&l,d=l>>>13,f=0|a[1],m=8191&f,p=f>>>13,g=0|a[2],y=8191&g,w=g>>>13,v=0|a[3],b=8191&v,k=v>>>13,M=0|a[4],_=8191&M,E=M>>>13,A=0|a[5],j=8191&A,x=A>>>13,S=0|a[6],N=8191&S,I=S>>>13,T=0|a[7],C=8191&T,z=T>>>13,O=0|a[8],R=8191&O,P=O>>>13,B=0|a[9],D=8191&B,$=B>>>13,L=0|s[0],F=8191&L,U=L>>>13,q=0|s[1],V=8191&q,H=q>>>13,G=0|s[2],Z=8191&G,K=G>>>13,J=0|s[3],W=8191&J,Y=J>>>13,Q=0|s[4],X=8191&Q,tt=Q>>>13,et=0|s[5],rt=8191&et,it=et>>>13,nt=0|s[6],ot=8191&nt,at=nt>>>13,st=0|s[7],ht=8191&st,ut=st>>>13,lt=0|s[8],ct=8191&lt,dt=lt>>>13,ft=0|s[9],mt=8191&ft,pt=ft>>>13;r.negative=t.negative^e.negative,r.length=19;var gt=(u+(i=Math.imul(c,F))|0)+((8191&(n=(n=Math.imul(c,U))+Math.imul(d,F)|0))<<13)|0;u=((o=Math.imul(d,U))+(n>>>13)|0)+(gt>>>26)|0,gt&=67108863,i=Math.imul(m,F),n=(n=Math.imul(m,U))+Math.imul(p,F)|0,o=Math.imul(p,U);var yt=(u+(i=i+Math.imul(c,V)|0)|0)+((8191&(n=(n=n+Math.imul(c,H)|0)+Math.imul(d,V)|0))<<13)|0;u=((o=o+Math.imul(d,H)|0)+(n>>>13)|0)+(yt>>>26)|0,yt&=67108863,i=Math.imul(y,F),n=(n=Math.imul(y,U))+Math.imul(w,F)|0,o=Math.imul(w,U),i=i+Math.imul(m,V)|0,n=(n=n+Math.imul(m,H)|0)+Math.imul(p,V)|0,o=o+Math.imul(p,H)|0;var wt=(u+(i=i+Math.imul(c,Z)|0)|0)+((8191&(n=(n=n+Math.imul(c,K)|0)+Math.imul(d,Z)|0))<<13)|0;u=((o=o+Math.imul(d,K)|0)+(n>>>13)|0)+(wt>>>26)|0,wt&=67108863,i=Math.imul(b,F),n=(n=Math.imul(b,U))+Math.imul(k,F)|0,o=Math.imul(k,U),i=i+Math.imul(y,V)|0,n=(n=n+Math.imul(y,H)|0)+Math.imul(w,V)|0,o=o+Math.imul(w,H)|0,i=i+Math.imul(m,Z)|0,n=(n=n+Math.imul(m,K)|0)+Math.imul(p,Z)|0,o=o+Math.imul(p,K)|0;var vt=(u+(i=i+Math.imul(c,W)|0)|0)+((8191&(n=(n=n+Math.imul(c,Y)|0)+Math.imul(d,W)|0))<<13)|0;u=((o=o+Math.imul(d,Y)|0)+(n>>>13)|0)+(vt>>>26)|0,vt&=67108863,i=Math.imul(_,F),n=(n=Math.imul(_,U))+Math.imul(E,F)|0,o=Math.imul(E,U),i=i+Math.imul(b,V)|0,n=(n=n+Math.imul(b,H)|0)+Math.imul(k,V)|0,o=o+Math.imul(k,H)|0,i=i+Math.imul(y,Z)|0,n=(n=n+Math.imul(y,K)|0)+Math.imul(w,Z)|0,o=o+Math.imul(w,K)|0,i=i+Math.imul(m,W)|0,n=(n=n+Math.imul(m,Y)|0)+Math.imul(p,W)|0,o=o+Math.imul(p,Y)|0;var bt=(u+(i=i+Math.imul(c,X)|0)|0)+((8191&(n=(n=n+Math.imul(c,tt)|0)+Math.imul(d,X)|0))<<13)|0;u=((o=o+Math.imul(d,tt)|0)+(n>>>13)|0)+(bt>>>26)|0,bt&=67108863,i=Math.imul(j,F),n=(n=Math.imul(j,U))+Math.imul(x,F)|0,o=Math.imul(x,U),i=i+Math.imul(_,V)|0,n=(n=n+Math.imul(_,H)|0)+Math.imul(E,V)|0,o=o+Math.imul(E,H)|0,i=i+Math.imul(b,Z)|0,n=(n=n+Math.imul(b,K)|0)+Math.imul(k,Z)|0,o=o+Math.imul(k,K)|0,i=i+Math.imul(y,W)|0,n=(n=n+Math.imul(y,Y)|0)+Math.imul(w,W)|0,o=o+Math.imul(w,Y)|0,i=i+Math.imul(m,X)|0,n=(n=n+Math.imul(m,tt)|0)+Math.imul(p,X)|0,o=o+Math.imul(p,tt)|0;var kt=(u+(i=i+Math.imul(c,rt)|0)|0)+((8191&(n=(n=n+Math.imul(c,it)|0)+Math.imul(d,rt)|0))<<13)|0;u=((o=o+Math.imul(d,it)|0)+(n>>>13)|0)+(kt>>>26)|0,kt&=67108863,i=Math.imul(N,F),n=(n=Math.imul(N,U))+Math.imul(I,F)|0,o=Math.imul(I,U),i=i+Math.imul(j,V)|0,n=(n=n+Math.imul(j,H)|0)+Math.imul(x,V)|0,o=o+Math.imul(x,H)|0,i=i+Math.imul(_,Z)|0,n=(n=n+Math.imul(_,K)|0)+Math.imul(E,Z)|0,o=o+Math.imul(E,K)|0,i=i+Math.imul(b,W)|0,n=(n=n+Math.imul(b,Y)|0)+Math.imul(k,W)|0,o=o+Math.imul(k,Y)|0,i=i+Math.imul(y,X)|0,n=(n=n+Math.imul(y,tt)|0)+Math.imul(w,X)|0,o=o+Math.imul(w,tt)|0,i=i+Math.imul(m,rt)|0,n=(n=n+Math.imul(m,it)|0)+Math.imul(p,rt)|0,o=o+Math.imul(p,it)|0;var Mt=(u+(i=i+Math.imul(c,ot)|0)|0)+((8191&(n=(n=n+Math.imul(c,at)|0)+Math.imul(d,ot)|0))<<13)|0;u=((o=o+Math.imul(d,at)|0)+(n>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,i=Math.imul(C,F),n=(n=Math.imul(C,U))+Math.imul(z,F)|0,o=Math.imul(z,U),i=i+Math.imul(N,V)|0,n=(n=n+Math.imul(N,H)|0)+Math.imul(I,V)|0,o=o+Math.imul(I,H)|0,i=i+Math.imul(j,Z)|0,n=(n=n+Math.imul(j,K)|0)+Math.imul(x,Z)|0,o=o+Math.imul(x,K)|0,i=i+Math.imul(_,W)|0,n=(n=n+Math.imul(_,Y)|0)+Math.imul(E,W)|0,o=o+Math.imul(E,Y)|0,i=i+Math.imul(b,X)|0,n=(n=n+Math.imul(b,tt)|0)+Math.imul(k,X)|0,o=o+Math.imul(k,tt)|0,i=i+Math.imul(y,rt)|0,n=(n=n+Math.imul(y,it)|0)+Math.imul(w,rt)|0,o=o+Math.imul(w,it)|0,i=i+Math.imul(m,ot)|0,n=(n=n+Math.imul(m,at)|0)+Math.imul(p,ot)|0,o=o+Math.imul(p,at)|0;var _t=(u+(i=i+Math.imul(c,ht)|0)|0)+((8191&(n=(n=n+Math.imul(c,ut)|0)+Math.imul(d,ht)|0))<<13)|0;u=((o=o+Math.imul(d,ut)|0)+(n>>>13)|0)+(_t>>>26)|0,_t&=67108863,i=Math.imul(R,F),n=(n=Math.imul(R,U))+Math.imul(P,F)|0,o=Math.imul(P,U),i=i+Math.imul(C,V)|0,n=(n=n+Math.imul(C,H)|0)+Math.imul(z,V)|0,o=o+Math.imul(z,H)|0,i=i+Math.imul(N,Z)|0,n=(n=n+Math.imul(N,K)|0)+Math.imul(I,Z)|0,o=o+Math.imul(I,K)|0,i=i+Math.imul(j,W)|0,n=(n=n+Math.imul(j,Y)|0)+Math.imul(x,W)|0,o=o+Math.imul(x,Y)|0,i=i+Math.imul(_,X)|0,n=(n=n+Math.imul(_,tt)|0)+Math.imul(E,X)|0,o=o+Math.imul(E,tt)|0,i=i+Math.imul(b,rt)|0,n=(n=n+Math.imul(b,it)|0)+Math.imul(k,rt)|0,o=o+Math.imul(k,it)|0,i=i+Math.imul(y,ot)|0,n=(n=n+Math.imul(y,at)|0)+Math.imul(w,ot)|0,o=o+Math.imul(w,at)|0,i=i+Math.imul(m,ht)|0,n=(n=n+Math.imul(m,ut)|0)+Math.imul(p,ht)|0,o=o+Math.imul(p,ut)|0;var Et=(u+(i=i+Math.imul(c,ct)|0)|0)+((8191&(n=(n=n+Math.imul(c,dt)|0)+Math.imul(d,ct)|0))<<13)|0;u=((o=o+Math.imul(d,dt)|0)+(n>>>13)|0)+(Et>>>26)|0,Et&=67108863,i=Math.imul(D,F),n=(n=Math.imul(D,U))+Math.imul($,F)|0,o=Math.imul($,U),i=i+Math.imul(R,V)|0,n=(n=n+Math.imul(R,H)|0)+Math.imul(P,V)|0,o=o+Math.imul(P,H)|0,i=i+Math.imul(C,Z)|0,n=(n=n+Math.imul(C,K)|0)+Math.imul(z,Z)|0,o=o+Math.imul(z,K)|0,i=i+Math.imul(N,W)|0,n=(n=n+Math.imul(N,Y)|0)+Math.imul(I,W)|0,o=o+Math.imul(I,Y)|0,i=i+Math.imul(j,X)|0,n=(n=n+Math.imul(j,tt)|0)+Math.imul(x,X)|0,o=o+Math.imul(x,tt)|0,i=i+Math.imul(_,rt)|0,n=(n=n+Math.imul(_,it)|0)+Math.imul(E,rt)|0,o=o+Math.imul(E,it)|0,i=i+Math.imul(b,ot)|0,n=(n=n+Math.imul(b,at)|0)+Math.imul(k,ot)|0,o=o+Math.imul(k,at)|0,i=i+Math.imul(y,ht)|0,n=(n=n+Math.imul(y,ut)|0)+Math.imul(w,ht)|0,o=o+Math.imul(w,ut)|0,i=i+Math.imul(m,ct)|0,n=(n=n+Math.imul(m,dt)|0)+Math.imul(p,ct)|0,o=o+Math.imul(p,dt)|0;var At=(u+(i=i+Math.imul(c,mt)|0)|0)+((8191&(n=(n=n+Math.imul(c,pt)|0)+Math.imul(d,mt)|0))<<13)|0;u=((o=o+Math.imul(d,pt)|0)+(n>>>13)|0)+(At>>>26)|0,At&=67108863,i=Math.imul(D,V),n=(n=Math.imul(D,H))+Math.imul($,V)|0,o=Math.imul($,H),i=i+Math.imul(R,Z)|0,n=(n=n+Math.imul(R,K)|0)+Math.imul(P,Z)|0,o=o+Math.imul(P,K)|0,i=i+Math.imul(C,W)|0,n=(n=n+Math.imul(C,Y)|0)+Math.imul(z,W)|0,o=o+Math.imul(z,Y)|0,i=i+Math.imul(N,X)|0,n=(n=n+Math.imul(N,tt)|0)+Math.imul(I,X)|0,o=o+Math.imul(I,tt)|0,i=i+Math.imul(j,rt)|0,n=(n=n+Math.imul(j,it)|0)+Math.imul(x,rt)|0,o=o+Math.imul(x,it)|0,i=i+Math.imul(_,ot)|0,n=(n=n+Math.imul(_,at)|0)+Math.imul(E,ot)|0,o=o+Math.imul(E,at)|0,i=i+Math.imul(b,ht)|0,n=(n=n+Math.imul(b,ut)|0)+Math.imul(k,ht)|0,o=o+Math.imul(k,ut)|0,i=i+Math.imul(y,ct)|0,n=(n=n+Math.imul(y,dt)|0)+Math.imul(w,ct)|0,o=o+Math.imul(w,dt)|0;var jt=(u+(i=i+Math.imul(m,mt)|0)|0)+((8191&(n=(n=n+Math.imul(m,pt)|0)+Math.imul(p,mt)|0))<<13)|0;u=((o=o+Math.imul(p,pt)|0)+(n>>>13)|0)+(jt>>>26)|0,jt&=67108863,i=Math.imul(D,Z),n=(n=Math.imul(D,K))+Math.imul($,Z)|0,o=Math.imul($,K),i=i+Math.imul(R,W)|0,n=(n=n+Math.imul(R,Y)|0)+Math.imul(P,W)|0,o=o+Math.imul(P,Y)|0,i=i+Math.imul(C,X)|0,n=(n=n+Math.imul(C,tt)|0)+Math.imul(z,X)|0,o=o+Math.imul(z,tt)|0,i=i+Math.imul(N,rt)|0,n=(n=n+Math.imul(N,it)|0)+Math.imul(I,rt)|0,o=o+Math.imul(I,it)|0,i=i+Math.imul(j,ot)|0,n=(n=n+Math.imul(j,at)|0)+Math.imul(x,ot)|0,o=o+Math.imul(x,at)|0,i=i+Math.imul(_,ht)|0,n=(n=n+Math.imul(_,ut)|0)+Math.imul(E,ht)|0,o=o+Math.imul(E,ut)|0,i=i+Math.imul(b,ct)|0,n=(n=n+Math.imul(b,dt)|0)+Math.imul(k,ct)|0,o=o+Math.imul(k,dt)|0;var xt=(u+(i=i+Math.imul(y,mt)|0)|0)+((8191&(n=(n=n+Math.imul(y,pt)|0)+Math.imul(w,mt)|0))<<13)|0;u=((o=o+Math.imul(w,pt)|0)+(n>>>13)|0)+(xt>>>26)|0,xt&=67108863,i=Math.imul(D,W),n=(n=Math.imul(D,Y))+Math.imul($,W)|0,o=Math.imul($,Y),i=i+Math.imul(R,X)|0,n=(n=n+Math.imul(R,tt)|0)+Math.imul(P,X)|0,o=o+Math.imul(P,tt)|0,i=i+Math.imul(C,rt)|0,n=(n=n+Math.imul(C,it)|0)+Math.imul(z,rt)|0,o=o+Math.imul(z,it)|0,i=i+Math.imul(N,ot)|0,n=(n=n+Math.imul(N,at)|0)+Math.imul(I,ot)|0,o=o+Math.imul(I,at)|0,i=i+Math.imul(j,ht)|0,n=(n=n+Math.imul(j,ut)|0)+Math.imul(x,ht)|0,o=o+Math.imul(x,ut)|0,i=i+Math.imul(_,ct)|0,n=(n=n+Math.imul(_,dt)|0)+Math.imul(E,ct)|0,o=o+Math.imul(E,dt)|0;var St=(u+(i=i+Math.imul(b,mt)|0)|0)+((8191&(n=(n=n+Math.imul(b,pt)|0)+Math.imul(k,mt)|0))<<13)|0;u=((o=o+Math.imul(k,pt)|0)+(n>>>13)|0)+(St>>>26)|0,St&=67108863,i=Math.imul(D,X),n=(n=Math.imul(D,tt))+Math.imul($,X)|0,o=Math.imul($,tt),i=i+Math.imul(R,rt)|0,n=(n=n+Math.imul(R,it)|0)+Math.imul(P,rt)|0,o=o+Math.imul(P,it)|0,i=i+Math.imul(C,ot)|0,n=(n=n+Math.imul(C,at)|0)+Math.imul(z,ot)|0,o=o+Math.imul(z,at)|0,i=i+Math.imul(N,ht)|0,n=(n=n+Math.imul(N,ut)|0)+Math.imul(I,ht)|0,o=o+Math.imul(I,ut)|0,i=i+Math.imul(j,ct)|0,n=(n=n+Math.imul(j,dt)|0)+Math.imul(x,ct)|0,o=o+Math.imul(x,dt)|0;var Nt=(u+(i=i+Math.imul(_,mt)|0)|0)+((8191&(n=(n=n+Math.imul(_,pt)|0)+Math.imul(E,mt)|0))<<13)|0;u=((o=o+Math.imul(E,pt)|0)+(n>>>13)|0)+(Nt>>>26)|0,Nt&=67108863,i=Math.imul(D,rt),n=(n=Math.imul(D,it))+Math.imul($,rt)|0,o=Math.imul($,it),i=i+Math.imul(R,ot)|0,n=(n=n+Math.imul(R,at)|0)+Math.imul(P,ot)|0,o=o+Math.imul(P,at)|0,i=i+Math.imul(C,ht)|0,n=(n=n+Math.imul(C,ut)|0)+Math.imul(z,ht)|0,o=o+Math.imul(z,ut)|0,i=i+Math.imul(N,ct)|0,n=(n=n+Math.imul(N,dt)|0)+Math.imul(I,ct)|0,o=o+Math.imul(I,dt)|0;var It=(u+(i=i+Math.imul(j,mt)|0)|0)+((8191&(n=(n=n+Math.imul(j,pt)|0)+Math.imul(x,mt)|0))<<13)|0;u=((o=o+Math.imul(x,pt)|0)+(n>>>13)|0)+(It>>>26)|0,It&=67108863,i=Math.imul(D,ot),n=(n=Math.imul(D,at))+Math.imul($,ot)|0,o=Math.imul($,at),i=i+Math.imul(R,ht)|0,n=(n=n+Math.imul(R,ut)|0)+Math.imul(P,ht)|0,o=o+Math.imul(P,ut)|0,i=i+Math.imul(C,ct)|0,n=(n=n+Math.imul(C,dt)|0)+Math.imul(z,ct)|0,o=o+Math.imul(z,dt)|0;var Tt=(u+(i=i+Math.imul(N,mt)|0)|0)+((8191&(n=(n=n+Math.imul(N,pt)|0)+Math.imul(I,mt)|0))<<13)|0;u=((o=o+Math.imul(I,pt)|0)+(n>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,i=Math.imul(D,ht),n=(n=Math.imul(D,ut))+Math.imul($,ht)|0,o=Math.imul($,ut),i=i+Math.imul(R,ct)|0,n=(n=n+Math.imul(R,dt)|0)+Math.imul(P,ct)|0,o=o+Math.imul(P,dt)|0;var Ct=(u+(i=i+Math.imul(C,mt)|0)|0)+((8191&(n=(n=n+Math.imul(C,pt)|0)+Math.imul(z,mt)|0))<<13)|0;u=((o=o+Math.imul(z,pt)|0)+(n>>>13)|0)+(Ct>>>26)|0,Ct&=67108863,i=Math.imul(D,ct),n=(n=Math.imul(D,dt))+Math.imul($,ct)|0,o=Math.imul($,dt);var zt=(u+(i=i+Math.imul(R,mt)|0)|0)+((8191&(n=(n=n+Math.imul(R,pt)|0)+Math.imul(P,mt)|0))<<13)|0;u=((o=o+Math.imul(P,pt)|0)+(n>>>13)|0)+(zt>>>26)|0,zt&=67108863;var Ot=(u+(i=Math.imul(D,mt))|0)+((8191&(n=(n=Math.imul(D,pt))+Math.imul($,mt)|0))<<13)|0;return u=((o=Math.imul($,pt))+(n>>>13)|0)+(Ot>>>26)|0,Ot&=67108863,h[0]=gt,h[1]=yt,h[2]=wt,h[3]=vt,h[4]=bt,h[5]=kt,h[6]=Mt,h[7]=_t,h[8]=Et,h[9]=At,h[10]=jt,h[11]=xt,h[12]=St,h[13]=Nt,h[14]=It,h[15]=Tt,h[16]=Ct,h[17]=zt,h[18]=Ot,0!==u&&(h[19]=u,r.length++),r};function g(t,e,r){r.negative=e.negative^t.negative,r.length=t.length+e.length;for(var i=0,n=0,o=0;o<r.length-1;o++){var a=n;n=0;for(var s=67108863&i,h=Math.min(o,e.length-1),u=Math.max(0,o-t.length+1);u<=h;u++){var l=o-u,c=(0|t.words[l])*(0|e.words[u]),d=67108863&c;s=67108863&(d=d+s|0),n+=(a=(a=a+(c/67108864|0)|0)+(d>>>26)|0)>>>26,a&=67108863}r.words[o]=s,i=a,a=n}return 0!==i?r.words[o]=i:r.length--,r._strip()}function y(t,e,r){return g(t,e,r)}Math.imul||(p=m),n.prototype.mulTo=function(t,e){var r=this.length+t.length;return 10===this.length&&10===t.length?p(this,t,e):r<63?m(this,t,e):r<1024?g(this,t,e):y(this,t,e)},n.prototype.mul=function(t){var e=new n(null);return e.words=new Array(this.length+t.length),this.mulTo(t,e)},n.prototype.mulf=function(t){var e=new n(null);return e.words=new Array(this.length+t.length),y(this,t,e)},n.prototype.imul=function(t){return this.clone().mulTo(t,this)},n.prototype.imuln=function(t){var e=t<0;e&&(t=-t),r("number"==typeof t),r(t<67108864);for(var i=0,n=0;n<this.length;n++){var o=(0|this.words[n])*t,a=(67108863&o)+(67108863&i);i>>=26,i+=o/67108864|0,i+=a>>>26,this.words[n]=67108863&a}return 0!==i&&(this.words[n]=i,this.length++),e?this.ineg():this},n.prototype.muln=function(t){return this.clone().imuln(t)},n.prototype.sqr=function(){return this.mul(this)},n.prototype.isqr=function(){return this.imul(this.clone())},n.prototype.pow=function(t){var e=function(t){for(var e=new Array(t.bitLength()),r=0;r<e.length;r++){var i=r/26|0,n=r%26;e[r]=t.words[i]>>>n&1}return e}(t);if(0===e.length)return new n(1);for(var r=this,i=0;i<e.length&&0===e[i];i++,r=r.sqr());if(++i<e.length)for(var o=r.sqr();i<e.length;i++,o=o.sqr())0!==e[i]&&(r=r.mul(o));return r},n.prototype.iushln=function(t){r("number"==typeof t&&t>=0);var e,i=t%26,n=(t-i)/26,o=67108863>>>26-i<<26-i;if(0!==i){var a=0;for(e=0;e<this.length;e++){var s=this.words[e]&o,h=(0|this.words[e])-s<<i;this.words[e]=h|a,a=s>>>26-i}a&&(this.words[e]=a,this.length++)}if(0!==n){for(e=this.length-1;e>=0;e--)this.words[e+n]=this.words[e];for(e=0;e<n;e++)this.words[e]=0;this.length+=n}return this._strip()},n.prototype.ishln=function(t){return r(0===this.negative),this.iushln(t)},n.prototype.iushrn=function(t,e,i){var n;r("number"==typeof t&&t>=0),n=e?(e-e%26)/26:0;var o=t%26,a=Math.min((t-o)/26,this.length),s=67108863^67108863>>>o<<o,h=i;if(n-=a,n=Math.max(0,n),h){for(var u=0;u<a;u++)h.words[u]=this.words[u];h.length=a}if(0===a);else if(this.length>a)for(this.length-=a,u=0;u<this.length;u++)this.words[u]=this.words[u+a];else this.words[0]=0,this.length=1;var l=0;for(u=this.length-1;u>=0&&(0!==l||u>=n);u--){var c=0|this.words[u];this.words[u]=l<<26-o|c>>>o,l=c&s}return h&&0!==l&&(h.words[h.length++]=l),0===this.length&&(this.words[0]=0,this.length=1),this._strip()},n.prototype.ishrn=function(t,e,i){return r(0===this.negative),this.iushrn(t,e,i)},n.prototype.shln=function(t){return this.clone().ishln(t)},n.prototype.ushln=function(t){return this.clone().iushln(t)},n.prototype.shrn=function(t){return this.clone().ishrn(t)},n.prototype.ushrn=function(t){return this.clone().iushrn(t)},n.prototype.testn=function(t){r("number"==typeof t&&t>=0);var e=t%26,i=(t-e)/26,n=1<<e;return!(this.length<=i)&&!!(this.words[i]&n)},n.prototype.imaskn=function(t){r("number"==typeof t&&t>=0);var e=t%26,i=(t-e)/26;if(r(0===this.negative,"imaskn works only with positive numbers"),this.length<=i)return this;if(0!==e&&i++,this.length=Math.min(i,this.length),0!==e){var n=67108863^67108863>>>e<<e;this.words[this.length-1]&=n}return this._strip()},n.prototype.maskn=function(t){return this.clone().imaskn(t)},n.prototype.iaddn=function(t){return r("number"==typeof t),r(t<67108864),t<0?this.isubn(-t):0!==this.negative?1===this.length&&(0|this.words[0])<=t?(this.words[0]=t-(0|this.words[0]),this.negative=0,this):(this.negative=0,this.isubn(t),this.negative=1,this):this._iaddn(t)},n.prototype._iaddn=function(t){this.words[0]+=t;for(var e=0;e<this.length&&this.words[e]>=67108864;e++)this.words[e]-=67108864,e===this.length-1?this.words[e+1]=1:this.words[e+1]++;return this.length=Math.max(this.length,e+1),this},n.prototype.isubn=function(t){if(r("number"==typeof t),r(t<67108864),t<0)return this.iaddn(-t);if(0!==this.negative)return this.negative=0,this.iaddn(t),this.negative=1,this;if(this.words[0]-=t,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var e=0;e<this.length&&this.words[e]<0;e++)this.words[e]+=67108864,this.words[e+1]-=1;return this._strip()},n.prototype.addn=function(t){return this.clone().iaddn(t)},n.prototype.subn=function(t){return this.clone().isubn(t)},n.prototype.iabs=function(){return this.negative=0,this},n.prototype.abs=function(){return this.clone().iabs()},n.prototype._ishlnsubmul=function(t,e,i){var n,o,a=t.length+i;this._expand(a);var s=0;for(n=0;n<t.length;n++){o=(0|this.words[n+i])+s;var h=(0|t.words[n])*e;s=((o-=67108863&h)>>26)-(h/67108864|0),this.words[n+i]=67108863&o}for(;n<this.length-i;n++)s=(o=(0|this.words[n+i])+s)>>26,this.words[n+i]=67108863&o;if(0===s)return this._strip();for(r(-1===s),s=0,n=0;n<this.length;n++)s=(o=-(0|this.words[n])+s)>>26,this.words[n]=67108863&o;return this.negative=1,this._strip()},n.prototype._wordDiv=function(t,e){var r=(this.length,t.length),i=this.clone(),o=t,a=0|o.words[o.length-1];0!==(r=26-this._countBits(a))&&(o=o.ushln(r),i.iushln(r),a=0|o.words[o.length-1]);var s,h=i.length-o.length;if("mod"!==e){(s=new n(null)).length=h+1,s.words=new Array(s.length);for(var u=0;u<s.length;u++)s.words[u]=0}var l=i.clone()._ishlnsubmul(o,1,h);0===l.negative&&(i=l,s&&(s.words[h]=1));for(var c=h-1;c>=0;c--){var d=67108864*(0|i.words[o.length+c])+(0|i.words[o.length+c-1]);for(d=Math.min(d/a|0,67108863),i._ishlnsubmul(o,d,c);0!==i.negative;)d--,i.negative=0,i._ishlnsubmul(o,1,c),i.isZero()||(i.negative^=1);s&&(s.words[c]=d)}return s&&s._strip(),i._strip(),"div"!==e&&0!==r&&i.iushrn(r),{div:s||null,mod:i}},n.prototype.divmod=function(t,e,i){return r(!t.isZero()),this.isZero()?{div:new n(0),mod:new n(0)}:0!==this.negative&&0===t.negative?(s=this.neg().divmod(t,e),"mod"!==e&&(o=s.div.neg()),"div"!==e&&(a=s.mod.neg(),i&&0!==a.negative&&a.iadd(t)),{div:o,mod:a}):0===this.negative&&0!==t.negative?(s=this.divmod(t.neg(),e),"mod"!==e&&(o=s.div.neg()),{div:o,mod:s.mod}):0!=(this.negative&t.negative)?(s=this.neg().divmod(t.neg(),e),"div"!==e&&(a=s.mod.neg(),i&&0!==a.negative&&a.isub(t)),{div:s.div,mod:a}):t.length>this.length||this.cmp(t)<0?{div:new n(0),mod:this}:1===t.length?"div"===e?{div:this.divn(t.words[0]),mod:null}:"mod"===e?{div:null,mod:new n(this.modrn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new n(this.modrn(t.words[0]))}:this._wordDiv(t,e);var o,a,s},n.prototype.div=function(t){return this.divmod(t,"div",!1).div},n.prototype.mod=function(t){return this.divmod(t,"mod",!1).mod},n.prototype.umod=function(t){return this.divmod(t,"mod",!0).mod},n.prototype.divRound=function(t){var e=this.divmod(t);if(e.mod.isZero())return e.div;var r=0!==e.div.negative?e.mod.isub(t):e.mod,i=t.ushrn(1),n=t.andln(1),o=r.cmp(i);return o<0||1===n&&0===o?e.div:0!==e.div.negative?e.div.isubn(1):e.div.iaddn(1)},n.prototype.modrn=function(t){var e=t<0;e&&(t=-t),r(t<=67108863);for(var i=(1<<26)%t,n=0,o=this.length-1;o>=0;o--)n=(i*n+(0|this.words[o]))%t;return e?-n:n},n.prototype.modn=function(t){return this.modrn(t)},n.prototype.idivn=function(t){var e=t<0;e&&(t=-t),r(t<=67108863);for(var i=0,n=this.length-1;n>=0;n--){var o=(0|this.words[n])+67108864*i;this.words[n]=o/t|0,i=o%t}return this._strip(),e?this.ineg():this},n.prototype.divn=function(t){return this.clone().idivn(t)},n.prototype.egcd=function(t){r(0===t.negative),r(!t.isZero());var e=this,i=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var o=new n(1),a=new n(0),s=new n(0),h=new n(1),u=0;e.isEven()&&i.isEven();)e.iushrn(1),i.iushrn(1),++u;for(var l=i.clone(),c=e.clone();!e.isZero();){for(var d=0,f=1;0==(e.words[0]&f)&&d<26;++d,f<<=1);if(d>0)for(e.iushrn(d);d-- >0;)(o.isOdd()||a.isOdd())&&(o.iadd(l),a.isub(c)),o.iushrn(1),a.iushrn(1);for(var m=0,p=1;0==(i.words[0]&p)&&m<26;++m,p<<=1);if(m>0)for(i.iushrn(m);m-- >0;)(s.isOdd()||h.isOdd())&&(s.iadd(l),h.isub(c)),s.iushrn(1),h.iushrn(1);e.cmp(i)>=0?(e.isub(i),o.isub(s),a.isub(h)):(i.isub(e),s.isub(o),h.isub(a))}return{a:s,b:h,gcd:i.iushln(u)}},n.prototype._invmp=function(t){r(0===t.negative),r(!t.isZero());var e=this,i=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var o,a=new n(1),s=new n(0),h=i.clone();e.cmpn(1)>0&&i.cmpn(1)>0;){for(var u=0,l=1;0==(e.words[0]&l)&&u<26;++u,l<<=1);if(u>0)for(e.iushrn(u);u-- >0;)a.isOdd()&&a.iadd(h),a.iushrn(1);for(var c=0,d=1;0==(i.words[0]&d)&&c<26;++c,d<<=1);if(c>0)for(i.iushrn(c);c-- >0;)s.isOdd()&&s.iadd(h),s.iushrn(1);e.cmp(i)>=0?(e.isub(i),a.isub(s)):(i.isub(e),s.isub(a))}return(o=0===e.cmpn(1)?a:s).cmpn(0)<0&&o.iadd(t),o},n.prototype.gcd=function(t){if(this.isZero())return t.abs();if(t.isZero())return this.abs();var e=this.clone(),r=t.clone();e.negative=0,r.negative=0;for(var i=0;e.isEven()&&r.isEven();i++)e.iushrn(1),r.iushrn(1);for(;;){for(;e.isEven();)e.iushrn(1);for(;r.isEven();)r.iushrn(1);var n=e.cmp(r);if(n<0){var o=e;e=r,r=o}else if(0===n||0===r.cmpn(1))break;e.isub(r)}return r.iushln(i)},n.prototype.invm=function(t){return this.egcd(t).a.umod(t)},n.prototype.isEven=function(){return 0==(1&this.words[0])},n.prototype.isOdd=function(){return 1==(1&this.words[0])},n.prototype.andln=function(t){return this.words[0]&t},n.prototype.bincn=function(t){r("number"==typeof t);var e=t%26,i=(t-e)/26,n=1<<e;if(this.length<=i)return this._expand(i+1),this.words[i]|=n,this;for(var o=n,a=i;0!==o&&a<this.length;a++){var s=0|this.words[a];o=(s+=o)>>>26,s&=67108863,this.words[a]=s}return 0!==o&&(this.words[a]=o,this.length++),this},n.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},n.prototype.cmpn=function(t){var e,i=t<0;if(0!==this.negative&&!i)return-1;if(0===this.negative&&i)return 1;if(this._strip(),this.length>1)e=1;else{i&&(t=-t),r(t<=67108863,"Number is too big");var n=0|this.words[0];e=n===t?0:n<t?-1:1}return 0!==this.negative?0|-e:e},n.prototype.cmp=function(t){if(0!==this.negative&&0===t.negative)return-1;if(0===this.negative&&0!==t.negative)return 1;var e=this.ucmp(t);return 0!==this.negative?0|-e:e},n.prototype.ucmp=function(t){if(this.length>t.length)return 1;if(this.length<t.length)return-1;for(var e=0,r=this.length-1;r>=0;r--){var i=0|this.words[r],n=0|t.words[r];if(i!==n){i<n?e=-1:i>n&&(e=1);break}}return e},n.prototype.gtn=function(t){return 1===this.cmpn(t)},n.prototype.gt=function(t){return 1===this.cmp(t)},n.prototype.gten=function(t){return this.cmpn(t)>=0},n.prototype.gte=function(t){return this.cmp(t)>=0},n.prototype.ltn=function(t){return-1===this.cmpn(t)},n.prototype.lt=function(t){return-1===this.cmp(t)},n.prototype.lten=function(t){return this.cmpn(t)<=0},n.prototype.lte=function(t){return this.cmp(t)<=0},n.prototype.eqn=function(t){return 0===this.cmpn(t)},n.prototype.eq=function(t){return 0===this.cmp(t)},n.red=function(t){return new E(t)},n.prototype.toRed=function(t){return r(!this.red,"Already a number in reduction context"),r(0===this.negative,"red works only with positives"),t.convertTo(this)._forceRed(t)},n.prototype.fromRed=function(){return r(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},n.prototype._forceRed=function(t){return this.red=t,this},n.prototype.forceRed=function(t){return r(!this.red,"Already a number in reduction context"),this._forceRed(t)},n.prototype.redAdd=function(t){return r(this.red,"redAdd works only with red numbers"),this.red.add(this,t)},n.prototype.redIAdd=function(t){return r(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,t)},n.prototype.redSub=function(t){return r(this.red,"redSub works only with red numbers"),this.red.sub(this,t)},n.prototype.redISub=function(t){return r(this.red,"redISub works only with red numbers"),this.red.isub(this,t)},n.prototype.redShl=function(t){return r(this.red,"redShl works only with red numbers"),this.red.shl(this,t)},n.prototype.redMul=function(t){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.mul(this,t)},n.prototype.redIMul=function(t){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.imul(this,t)},n.prototype.redSqr=function(){return r(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},n.prototype.redISqr=function(){return r(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},n.prototype.redSqrt=function(){return r(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},n.prototype.redInvm=function(){return r(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},n.prototype.redNeg=function(){return r(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},n.prototype.redPow=function(t){return r(this.red&&!t.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,t)};var w={k256:null,p224:null,p192:null,p25519:null};function v(t,e){this.name=t,this.p=new n(e,16),this.n=this.p.bitLength(),this.k=new n(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function b(){v.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function k(){v.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function M(){v.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function _(){v.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function E(t){if("string"==typeof t){var e=n._prime(t);this.m=e.p,this.prime=e}else r(t.gtn(1),"modulus must be greater than 1"),this.m=t,this.prime=null}function A(t){E.call(this,t),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new n(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)}v.prototype._tmp=function(){var t=new n(null);return t.words=new Array(Math.ceil(this.n/13)),t},v.prototype.ireduce=function(t){var e,r=t;do{this.split(r,this.tmp),e=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(e>this.n);var i=e<this.n?-1:r.ucmp(this.p);return 0===i?(r.words[0]=0,r.length=1):i>0?r.isub(this.p):void 0!==r.strip?r.strip():r._strip(),r},v.prototype.split=function(t,e){t.iushrn(this.n,0,e)},v.prototype.imulK=function(t){return t.imul(this.k)},i(b,v),b.prototype.split=function(t,e){for(var r=4194303,i=Math.min(t.length,9),n=0;n<i;n++)e.words[n]=t.words[n];if(e.length=i,t.length<=9)return t.words[0]=0,void(t.length=1);var o=t.words[9];for(e.words[e.length++]=o&r,n=10;n<t.length;n++){var a=0|t.words[n];t.words[n-10]=(a&r)<<4|o>>>22,o=a}o>>>=22,t.words[n-10]=o,0===o&&t.length>10?t.length-=10:t.length-=9},b.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var e=0,r=0;r<t.length;r++){var i=0|t.words[r];e+=977*i,t.words[r]=67108863&e,e=64*i+(e/67108864|0)}return 0===t.words[t.length-1]&&(t.length--,0===t.words[t.length-1]&&t.length--),t},i(k,v),i(M,v),i(_,v),_.prototype.imulK=function(t){for(var e=0,r=0;r<t.length;r++){var i=19*(0|t.words[r])+e,n=67108863&i;i>>>=26,t.words[r]=n,e=i}return 0!==e&&(t.words[t.length++]=e),t},n._prime=function(t){if(w[t])return w[t];var e;if("k256"===t)e=new b;else if("p224"===t)e=new k;else if("p192"===t)e=new M;else{if("p25519"!==t)throw new Error("Unknown prime "+t);e=new _}return w[t]=e,e},E.prototype._verify1=function(t){r(0===t.negative,"red works only with positives"),r(t.red,"red works only with red numbers")},E.prototype._verify2=function(t,e){r(0==(t.negative|e.negative),"red works only with positives"),r(t.red&&t.red===e.red,"red works only with red numbers")},E.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):(u(t,t.umod(this.m)._forceRed(this)),t)},E.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},E.prototype.add=function(t,e){this._verify2(t,e);var r=t.add(e);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},E.prototype.iadd=function(t,e){this._verify2(t,e);var r=t.iadd(e);return r.cmp(this.m)>=0&&r.isub(this.m),r},E.prototype.sub=function(t,e){this._verify2(t,e);var r=t.sub(e);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},E.prototype.isub=function(t,e){this._verify2(t,e);var r=t.isub(e);return r.cmpn(0)<0&&r.iadd(this.m),r},E.prototype.shl=function(t,e){return this._verify1(t),this.imod(t.ushln(e))},E.prototype.imul=function(t,e){return this._verify2(t,e),this.imod(t.imul(e))},E.prototype.mul=function(t,e){return this._verify2(t,e),this.imod(t.mul(e))},E.prototype.isqr=function(t){return this.imul(t,t.clone())},E.prototype.sqr=function(t){return this.mul(t,t)},E.prototype.sqrt=function(t){if(t.isZero())return t.clone();var e=this.m.andln(3);if(r(e%2==1),3===e){var i=this.m.add(new n(1)).iushrn(2);return this.pow(t,i)}for(var o=this.m.subn(1),a=0;!o.isZero()&&0===o.andln(1);)a++,o.iushrn(1);r(!o.isZero());var s=new n(1).toRed(this),h=s.redNeg(),u=this.m.subn(1).iushrn(1),l=this.m.bitLength();for(l=new n(2*l*l).toRed(this);0!==this.pow(l,u).cmp(h);)l.redIAdd(h);for(var c=this.pow(l,o),d=this.pow(t,o.addn(1).iushrn(1)),f=this.pow(t,o),m=a;0!==f.cmp(s);){for(var p=f,g=0;0!==p.cmp(s);g++)p=p.redSqr();r(g<m);var y=this.pow(c,new n(1).iushln(m-g-1));d=d.redMul(y),c=y.redSqr(),f=f.redMul(c),m=g}return d},E.prototype.invm=function(t){var e=t._invmp(this.m);return 0!==e.negative?(e.negative=0,this.imod(e).redNeg()):this.imod(e)},E.prototype.pow=function(t,e){if(e.isZero())return new n(1).toRed(this);if(0===e.cmpn(1))return t.clone();var r=new Array(16);r[0]=new n(1).toRed(this),r[1]=t;for(var i=2;i<r.length;i++)r[i]=this.mul(r[i-1],t);var o=r[0],a=0,s=0,h=e.bitLength()%26;for(0===h&&(h=26),i=e.length-1;i>=0;i--){for(var u=e.words[i],l=h-1;l>=0;l--){var c=u>>l&1;o!==r[0]&&(o=this.sqr(o)),0!==c||0!==a?(a<<=1,a|=c,(4===++s||0===i&&0===l)&&(o=this.mul(o,r[a]),s=0,a=0)):s=0}h=26}return o},E.prototype.convertTo=function(t){var e=t.umod(this.m);return e===t?e.clone():e},E.prototype.convertFrom=function(t){var e=t.clone();return e.red=null,e},n.mont=function(t){return new A(t)},i(A,E),A.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},A.prototype.convertFrom=function(t){var e=this.imod(t.mul(this.rinv));return e.red=null,e},A.prototype.imul=function(t,e){if(t.isZero()||e.isZero())return t.words[0]=0,t.length=1,t;var r=t.imul(e),i=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),n=r.isub(i).iushrn(this.shift),o=n;return n.cmp(this.m)>=0?o=n.isub(this.m):n.cmpn(0)<0&&(o=n.iadd(this.m)),o._forceRed(this)},A.prototype.mul=function(t,e){if(t.isZero()||e.isZero())return new n(0)._forceRed(this);var r=t.mul(e),i=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),o=r.isub(i).iushrn(this.shift),a=o;return o.cmp(this.m)>=0?a=o.isub(this.m):o.cmpn(0)<0&&(a=o.iadd(this.m)),a._forceRed(this)},A.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}(t,i)}));var Qr=Yr.BN;const Xr=new w("bignumber/5.6.2"),ti={},ei=9007199254740991;let ri=!1;class ii{constructor(t,e){t!==ti&&Xr.throwError("cannot call constructor directly; use BigNumber.from",w.errors.UNSUPPORTED_OPERATION,{operation:"new (BigNumber)"}),this._hex=e,this._isBigNumber=!0,Object.freeze(this)}fromTwos(t){return oi(ai(this).fromTwos(t))}toTwos(t){return oi(ai(this).toTwos(t))}abs(){return"-"===this._hex[0]?ii.from(this._hex.substring(1)):this}add(t){return oi(ai(this).add(ai(t)))}sub(t){return oi(ai(this).sub(ai(t)))}div(t){return ii.from(t).isZero()&&si("division-by-zero","div"),oi(ai(this).div(ai(t)))}mul(t){return oi(ai(this).mul(ai(t)))}mod(t){const e=ai(t);return e.isNeg()&&si("division-by-zero","mod"),oi(ai(this).umod(e))}pow(t){const e=ai(t);return e.isNeg()&&si("negative-power","pow"),oi(ai(this).pow(e))}and(t){const e=ai(t);return(this.isNegative()||e.isNeg())&&si("unbound-bitwise-result","and"),oi(ai(this).and(e))}or(t){const e=ai(t);return(this.isNegative()||e.isNeg())&&si("unbound-bitwise-result","or"),oi(ai(this).or(e))}xor(t){const e=ai(t);return(this.isNegative()||e.isNeg())&&si("unbound-bitwise-result","xor"),oi(ai(this).xor(e))}mask(t){return(this.isNegative()||t<0)&&si("negative-width","mask"),oi(ai(this).maskn(t))}shl(t){return(this.isNegative()||t<0)&&si("negative-width","shl"),oi(ai(this).shln(t))}shr(t){return(this.isNegative()||t<0)&&si("negative-width","shr"),oi(ai(this).shrn(t))}eq(t){return ai(this).eq(ai(t))}lt(t){return ai(this).lt(ai(t))}lte(t){return ai(this).lte(ai(t))}gt(t){return ai(this).gt(ai(t))}gte(t){return ai(this).gte(ai(t))}isNegative(){return"-"===this._hex[0]}isZero(){return ai(this).isZero()}toNumber(){try{return ai(this).toNumber()}catch(t){si("overflow","toNumber",this.toString())}return null}toBigInt(){try{return BigInt(this.toString())}catch(t){}return Xr.throwError("this platform does not support BigInt",w.errors.UNSUPPORTED_OPERATION,{value:this.toString()})}toString(){return arguments.length>0&&(10===arguments[0]?ri||(ri=!0,Xr.warn("BigNumber.toString does not accept any parameters; base-10 is assumed")):16===arguments[0]?Xr.throwError("BigNumber.toString does not accept any parameters; use bigNumber.toHexString()",w.errors.UNEXPECTED_ARGUMENT,{}):Xr.throwError("BigNumber.toString does not accept parameters",w.errors.UNEXPECTED_ARGUMENT,{})),ai(this).toString(10)}toHexString(){return this._hex}toJSON(t){return{type:"BigNumber",hex:this.toHexString()}}static from(t){if(t instanceof ii)return t;if("string"==typeof t)return t.match(/^-?0x[0-9a-f]+$/i)?new ii(ti,ni(t)):t.match(/^-?[0-9]+$/)?new ii(ti,ni(new Qr(t))):Xr.throwArgumentError("invalid BigNumber string","value",t);if("number"==typeof t)return t%1&&si("underflow","BigNumber.from",t),(t>=ei||t<=-ei)&&si("overflow","BigNumber.from",t),ii.from(String(t));const e=t;if("bigint"==typeof e)return ii.from(e.toString());if(E(e))return ii.from(I(e));if(e)if(e.toHexString){const t=e.toHexString();if("string"==typeof t)return ii.from(t)}else{let t=e._hex;if(null==t&&"BigNumber"===e.type&&(t=e.hex),"string"==typeof t&&(S(t)||"-"===t[0]&&S(t.substring(1))))return ii.from(t)}return Xr.throwArgumentError("invalid BigNumber value","value",t)}static isBigNumber(t){return!(!t||!t._isBigNumber)}}function ni(t){if("string"!=typeof t)return ni(t.toString(16));if("-"===t[0])return"-"===(t=t.substring(1))[0]&&Xr.throwArgumentError("invalid hex","value",t),"0x00"===(t=ni(t))?t:"-"+t;if("0x"!==t.substring(0,2)&&(t="0x"+t),"0x"===t)return"0x00";for(t.length%2&&(t="0x0"+t.substring(2));t.length>4&&"0x00"===t.substring(0,4);)t="0x"+t.substring(4);return t}function oi(t){return ii.from(ni(t))}function ai(t){const e=ii.from(t).toHexString();return"-"===e[0]?new Qr("-"+e.substring(3),16):new Qr(e.substring(2),16)}function si(t,e,r){const i={fault:t,operation:e};return null!=r&&(i.value=r),Xr.throwError(t,w.errors.NUMERIC_FAULT,i)}const hi=ii.from(-1),ui=ii.from(0),li=ii.from(1),ci=ii.from("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");class di extends Br{constructor(t,e,r){const i=(e?"int":"uint")+8*t;super(i,i,r,!1),this.size=t,this.signed=e}defaultValue(){return 0}encode(t,e){let r=We.from(e),i=ci.mask(8*t.wordSize);if(this.signed){let t=i.mask(8*this.size-1);(r.gt(t)||r.lt(t.add(li).mul(hi)))&&this._throwError("value out-of-bounds",e)}else(r.lt(ui)||r.gt(i.mask(8*this.size)))&&this._throwError("value out-of-bounds",e);return r=r.toTwos(8*this.size).mask(8*this.size),this.signed&&(r=r.fromTwos(8*this.size).toTwos(8*t.wordSize)),t.writeValue(r)}decode(t){let e=t.readValue().mask(8*this.size);return this.signed&&(e=e.fromTwos(8*this.size)),t.coerce(this.name,e)}}const fi=new w("strings/5.6.1");var mi,pi;function gi(t,e,r,i,n){if(t===pi.BAD_PREFIX||t===pi.UNEXPECTED_CONTINUE){let t=0;for(let i=e+1;i<r.length&&r[i]>>6==2;i++)t++;return t}return t===pi.OVERRUN?r.length-e-1:0}!function(t){t.current="",t.NFC="NFC",t.NFD="NFD",t.NFKC="NFKC",t.NFKD="NFKD"}(mi||(mi={})),function(t){t.UNEXPECTED_CONTINUE="unexpected continuation byte",t.BAD_PREFIX="bad codepoint prefix",t.OVERRUN="string overrun",t.MISSING_CONTINUE="missing continuation byte",t.OUT_OF_RANGE="out of UTF-8 range",t.UTF16_SURROGATE="UTF-16 surrogate",t.OVERLONG="overlong representation"}(pi||(pi={}));const yi=Object.freeze({error:function(t,e,r,i,n){return fi.throwArgumentError(`invalid codepoint at offset ${e}; ${t}`,"bytes",r)},ignore:gi,replace:function(t,e,r,i,n){return t===pi.OVERLONG?(i.push(n),0):(i.push(65533),gi(t,e,r))}});function wi(t,e){null==e&&(e=yi.error),t=A(t);const r=[];let i=0;for(;i<t.length;){const n=t[i++];if(n>>7==0){r.push(n);continue}let o=null,a=null;if(192==(224&n))o=1,a=127;else if(224==(240&n))o=2,a=2047;else{if(240!=(248&n)){i+=e(128==(192&n)?pi.UNEXPECTED_CONTINUE:pi.BAD_PREFIX,i-1,t,r);continue}o=3,a=65535}if(i-1+o>=t.length){i+=e(pi.OVERRUN,i-1,t,r);continue}let s=n&(1<<8-o-1)-1;for(let n=0;n<o;n++){let n=t[i];if(128!=(192&n)){i+=e(pi.MISSING_CONTINUE,i,t,r),s=null;break}s=s<<6|63&n,i++}null!==s&&(s>1114111?i+=e(pi.OUT_OF_RANGE,i-1-o,t,r,s):s>=55296&&s<=57343?i+=e(pi.UTF16_SURROGATE,i-1-o,t,r,s):s<=a?i+=e(pi.OVERLONG,i-1-o,t,r,s):r.push(s))}return r}function vi(t,e=mi.current){e!=mi.current&&(fi.checkNormalize(),t=t.normalize(e));let r=[];for(let e=0;e<t.length;e++){const i=t.charCodeAt(e);if(i<128)r.push(i);else if(i<2048)r.push(i>>6|192),r.push(63&i|128);else if(55296==(64512&i)){e++;const n=t.charCodeAt(e);if(e>=t.length||56320!=(64512&n))throw new Error("invalid utf-8 string");const o=65536+((1023&i)<<10)+(1023&n);r.push(o>>18|240),r.push(o>>12&63|128),r.push(o>>6&63|128),r.push(63&o|128)}else r.push(i>>12|224),r.push(i>>6&63|128),r.push(63&i|128)}return A(r)}function bi(t){return t.map((t=>t<=65535?String.fromCharCode(t):(t-=65536,String.fromCharCode(55296+(t>>10&1023),56320+(1023&t))))).join("")}function ki(t,e){return bi(wi(t,e))}function Mi(t,e=mi.current){return wi(vi(t,e))}function _i(t,e){e||(e=function(t){return[parseInt(t,16)]});let r=0,i={};return t.split(",").forEach((t=>{let n=t.split(":");r+=parseInt(n[0],16),i[r]=e(n[1])})),i}function Ei(t){let e=0;return t.split(",").map((t=>{let r=t.split("-");1===r.length?r[1]="0":""===r[1]&&(r[1]="1");let i=e+parseInt(r[0],16);return e=parseInt(r[1],16),{l:i,h:e}}))}function Ai(t,e){let r=0;for(let i=0;i<e.length;i++){let n=e[i];if(r+=n.l,t>=r&&t<=r+n.h&&(t-r)%(n.d||1)==0){if(n.e&&-1!==n.e.indexOf(t-r))continue;return n}}return null}const ji=Ei("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"),xi="ad,34f,1806,180b,180c,180d,200b,200c,200d,2060,feff".split(",").map((t=>parseInt(t,16))),Si=[{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}],Ni=_i("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"),Ii=_i("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"),Ti=_i("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",(function(t){if(t.length%4!=0)throw new Error("bad data");let e=[];for(let r=0;r<t.length;r+=4)e.push(parseInt(t.substring(r,r+4),16));return e})),Ci=Ei("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 zi(t){if(t.match(/^[a-z0-9-]*$/i)&&t.length<=59)return t.toLowerCase();let e=Mi(t);var r;r=e.map((t=>{if(xi.indexOf(t)>=0)return[];if(t>=65024&&t<=65039)return[];let e=function(t){let e=Ai(t,Si);if(e)return[t+e.s];let r=Ni[t];if(r)return r;let i=Ii[t];return i?[t+i[0]]:Ti[t]||null}(t);return e||[t]})),e=r.reduce(((t,e)=>(e.forEach((e=>{t.push(e)})),t)),[]),e=Mi(bi(e),mi.NFKC),e.forEach((t=>{if(Ai(t,Ci))throw new Error("STRINGPREP_CONTAINS_PROHIBITED")})),e.forEach((t=>{if(Ai(t,ji))throw new Error("STRINGPREP_CONTAINS_UNASSIGNED")}));let i=bi(e);if("-"===i.substring(0,1)||"--"===i.substring(2,4)||"-"===i.substring(i.length-1))throw new Error("invalid hyphen");if(i.length>63)throw new Error("too long");return i}class Oi extends Zr{constructor(t){super("string",t)}defaultValue(){return""}encode(t,e){return super.encode(t,vi(e))}decode(t){return ki(super.decode(t))}}class Ri extends Br{constructor(t,e){let r=!1;const i=[];t.forEach((t=>{t.dynamic&&(r=!0),i.push(t.type)}));super("tuple","tuple("+i.join(",")+")",e,r),this.coders=t}defaultValue(){const t=[];this.coders.forEach((e=>{t.push(e.defaultValue())}));const e=this.coders.reduce(((t,e)=>{const r=e.localName;return r&&(t[r]||(t[r]=0),t[r]++),t}),{});return this.coders.forEach(((r,i)=>{let n=r.localName;n&&1===e[n]&&("length"===n&&(n="_length"),null==t[n]&&(t[n]=t[i]))})),Object.freeze(t)}encode(t,e){return qr(t,this.coders,e)}decode(t){return t.coerce(this.name,Vr(t,this.coders))}}const Pi=new w(dr),Bi=new RegExp(/^bytes([0-9]*)$/),Di=new RegExp(/^(u?int)([0-9]*)$/);class $i{constructor(t){ir(this,"coerceFunc",t||null)}_getCoder(t){switch(t.baseType){case"address":return new Lr(t.name);case"bool":return new Gr(t.name);case"string":return new Oi(t.name);case"bytes":return new Kr(t.name);case"array":return new Hr(this._getCoder(t.arrayChildren),t.arrayLength,t.name);case"tuple":return new Ri((t.components||[]).map((t=>this._getCoder(t))),t.name);case"":return new Wr(t.name)}let e=t.type.match(Di);if(e){let r=parseInt(e[2]||"256");return(0===r||r>256||r%8!=0)&&Pi.throwArgumentError("invalid "+e[1]+" bit length","param",t),new di(r/8,"int"===e[1],t.name)}if(e=t.type.match(Bi),e){let r=parseInt(e[1]);return(0===r||r>32)&&Pi.throwArgumentError("invalid bytes length","param",t),new Jr(r,t.name)}return Pi.throwArgumentError("invalid type","type",t.type)}_getWordSize(){return 32}_getReader(t,e){return new $r(t,this._getWordSize(),this.coerceFunc,e)}_getWriter(){return new Dr(this._getWordSize())}getDefaultValue(t){const e=t.map((t=>this._getCoder(kr.from(t))));return new Ri(e,"_").defaultValue()}encode(t,e){t.length!==e.length&&Pi.throwError("types/values length mismatch",w.errors.INVALID_ARGUMENT,{count:{types:t.length,values:e.length},value:{types:t,values:e}});const r=t.map((t=>this._getCoder(kr.from(t)))),i=new Ri(r,"_"),n=this._getWriter();return i.encode(n,e),n.data}decode(t,e,r){const i=t.map((t=>this._getCoder(kr.from(t))));return new Ri(i,"_").decode(this._getReader(A(e),r))}}const Li=new $i;function Fi(t){return Jt(vi(t))}const Ui=new w(dr);class qi extends cr{}class Vi extends cr{}class Hi extends cr{}class Gi extends cr{static isIndexed(t){return!(!t||!t._isIndexed)}}const Zi={"0x08c379a0":{signature:"Error(string)",name:"Error",inputs:["string"],reason:!0},"0x4e487b71":{signature:"Panic(uint256)",name:"Panic",inputs:["uint256"]}};function Ki(t,e){const r=new Error(`deferred error during ABI decoding triggered accessing ${t}`);return r.error=e,r}class Ji{constructor(t){let e=[];e="string"==typeof t?JSON.parse(t):t,ir(this,"fragments",e.map((t=>_r.from(t))).filter((t=>null!=t))),ir(this,"_abiCoder",nr(new.target,"getAbiCoder")()),ir(this,"functions",{}),ir(this,"errors",{}),ir(this,"events",{}),ir(this,"structs",{}),this.fragments.forEach((t=>{let e=null;switch(t.type){case"constructor":return this.deploy?void Ui.warn("duplicate definition - constructor"):void ir(this,"deploy",t);case"function":e=this.functions;break;case"event":e=this.events;break;case"error":e=this.errors;break;default:return}let r=t.format();e[r]?Ui.warn("duplicate definition - "+r):e[r]=t})),this.deploy||ir(this,"deploy",Sr.from({payable:!1,type:"constructor"})),ir(this,"_isInterface",!0)}format(t){t||(t=vr.full),t===vr.sighash&&Ui.throwArgumentError("interface does not support formatting sighash","format",t);const e=this.fragments.map((e=>e.format(t)));return t===vr.json?JSON.stringify(e.map((t=>JSON.parse(t)))):e}static getAbiCoder(){return Li}static getAddress(t){return he(t)}static getSighash(t){return C(Fi(t.format()),0,4)}static getEventTopic(t){return Fi(t.format())}getFunction(t){if(S(t)){for(const e in this.functions)if(t===this.getSighash(e))return this.functions[e];Ui.throwArgumentError("no matching function","sighash",t)}if(-1===t.indexOf("(")){const e=t.trim(),r=Object.keys(this.functions).filter((t=>t.split("(")[0]===e));return 0===r.length?Ui.throwArgumentError("no matching function","name",e):r.length>1&&Ui.throwArgumentError("multiple matching functions","name",e),this.functions[r[0]]}const e=this.functions[Nr.fromString(t).format()];return e||Ui.throwArgumentError("no matching function","signature",t),e}getEvent(t){if(S(t)){const e=t.toLowerCase();for(const t in this.events)if(e===this.getEventTopic(t))return this.events[t];Ui.throwArgumentError("no matching event","topichash",e)}if(-1===t.indexOf("(")){const e=t.trim(),r=Object.keys(this.events).filter((t=>t.split("(")[0]===e));return 0===r.length?Ui.throwArgumentError("no matching event","name",e):r.length>1&&Ui.throwArgumentError("multiple matching events","name",e),this.events[r[0]]}const e=this.events[Er.fromString(t).format()];return e||Ui.throwArgumentError("no matching event","signature",t),e}getError(t){if(S(t)){const e=nr(this.constructor,"getSighash");for(const r in this.errors){if(t===e(this.errors[r]))return this.errors[r]}Ui.throwArgumentError("no matching error","sighash",t)}if(-1===t.indexOf("(")){const e=t.trim(),r=Object.keys(this.errors).filter((t=>t.split("(")[0]===e));return 0===r.length?Ui.throwArgumentError("no matching error","name",e):r.length>1&&Ui.throwArgumentError("multiple matching errors","name",e),this.errors[r[0]]}const e=this.errors[Nr.fromString(t).format()];return e||Ui.throwArgumentError("no matching error","signature",t),e}getSighash(t){if("string"==typeof t)try{t=this.getFunction(t)}catch(e){try{t=this.getError(t)}catch(t){throw e}}return nr(this.constructor,"getSighash")(t)}getEventTopic(t){return"string"==typeof t&&(t=this.getEvent(t)),nr(this.constructor,"getEventTopic")(t)}_decodeParams(t,e){return this._abiCoder.decode(t,e)}_encodeParams(t,e){return this._abiCoder.encode(t,e)}encodeDeploy(t){return this._encodeParams(this.deploy.inputs,t||[])}decodeErrorResult(t,e){"string"==typeof t&&(t=this.getError(t));const r=A(e);return I(r.slice(0,4))!==this.getSighash(t)&&Ui.throwArgumentError(`data signature does not match error ${t.name}.`,"data",I(r)),this._decodeParams(t.inputs,r.slice(4))}encodeErrorResult(t,e){return"string"==typeof t&&(t=this.getError(t)),I(j([this.getSighash(t),this._encodeParams(t.inputs,e||[])]))}decodeFunctionData(t,e){"string"==typeof t&&(t=this.getFunction(t));const r=A(e);return I(r.slice(0,4))!==this.getSighash(t)&&Ui.throwArgumentError(`data signature does not match function ${t.name}.`,"data",I(r)),this._decodeParams(t.inputs,r.slice(4))}encodeFunctionData(t,e){return"string"==typeof t&&(t=this.getFunction(t)),I(j([this.getSighash(t),this._encodeParams(t.inputs,e||[])]))}decodeFunctionResult(t,e){"string"==typeof t&&(t=this.getFunction(t));let r=A(e),i=null,n="",o=null,a=null,s=null;switch(r.length%this._abiCoder._getWordSize()){case 0:try{return this._abiCoder.decode(t.outputs,r)}catch(t){}break;case 4:{const t=I(r.slice(0,4)),e=Zi[t];if(e)o=this._abiCoder.decode(e.inputs,r.slice(4)),a=e.name,s=e.signature,e.reason&&(i=o[0]),"Error"===a?n=`; VM Exception while processing transaction: reverted with reason string ${JSON.stringify(o[0])}`:"Panic"===a&&(n=`; VM Exception while processing transaction: reverted with panic code ${o[0]}`);else try{const e=this.getError(t);o=this._abiCoder.decode(e.inputs,r.slice(4)),a=e.name,s=e.format()}catch(t){}break}}return Ui.throwError("call revert exception"+n,w.errors.CALL_EXCEPTION,{method:t.format(),data:I(e),errorArgs:o,errorName:a,errorSignature:s,reason:i})}encodeFunctionResult(t,e){return"string"==typeof t&&(t=this.getFunction(t)),I(this._abiCoder.encode(t.outputs,e||[]))}encodeFilterTopics(t,e){"string"==typeof t&&(t=this.getEvent(t)),e.length>t.inputs.length&&Ui.throwError("too many arguments for "+t.format(),w.errors.UNEXPECTED_ARGUMENT,{argument:"values",value:e});let r=[];t.anonymous||r.push(this.getEventTopic(t));const i=(t,e)=>"string"===t.type?Fi(e):"bytes"===t.type?Jt(I(e)):("bool"===t.type&&"boolean"==typeof e&&(e=e?"0x01":"0x00"),t.type.match(/^u?int/)&&(e=We.from(e).toHexString()),"address"===t.type&&this._abiCoder.encode(["address"],[e]),R(I(e),32));for(e.forEach(((e,n)=>{let o=t.inputs[n];o.indexed?null==e?r.push(null):"array"===o.baseType||"tuple"===o.baseType?Ui.throwArgumentError("filtering with tuples or arrays not supported","contract."+o.name,e):Array.isArray(e)?r.push(e.map((t=>i(o,t)))):r.push(i(o,e)):null!=e&&Ui.throwArgumentError("cannot filter non-indexed parameters; must be null","contract."+o.name,e)}));r.length&&null===r[r.length-1];)r.pop();return r}encodeEventLog(t,e){"string"==typeof t&&(t=this.getEvent(t));const r=[],i=[],n=[];return t.anonymous||r.push(this.getEventTopic(t)),e.length!==t.inputs.length&&Ui.throwArgumentError("event arguments/values mismatch","values",e),t.inputs.forEach(((t,o)=>{const a=e[o];if(t.indexed)if("string"===t.type)r.push(Fi(a));else if("bytes"===t.type)r.push(Jt(a));else{if("tuple"===t.baseType||"array"===t.baseType)throw new Error("not implemented");r.push(this._abiCoder.encode([t.type],[a]))}else i.push(t),n.push(a)})),{data:this._abiCoder.encode(i,n),topics:r}}decodeEventLog(t,e,r){if("string"==typeof t&&(t=this.getEvent(t)),null!=r&&!t.anonymous){let e=this.getEventTopic(t);S(r[0],32)&&r[0].toLowerCase()===e||Ui.throwError("fragment/topic mismatch",w.errors.INVALID_ARGUMENT,{argument:"topics[0]",expected:e,value:r[0]}),r=r.slice(1)}let i=[],n=[],o=[];t.inputs.forEach(((t,e)=>{t.indexed?"string"===t.type||"bytes"===t.type||"tuple"===t.baseType||"array"===t.baseType?(i.push(kr.fromObject({type:"bytes32",name:t.name})),o.push(!0)):(i.push(t),o.push(!1)):(n.push(t),o.push(!1))}));let a=null!=r?this._abiCoder.decode(i,j(r)):null,s=this._abiCoder.decode(n,e,!0),h=[],u=0,l=0;t.inputs.forEach(((t,e)=>{if(t.indexed)if(null==a)h[e]=new Gi({_isIndexed:!0,hash:null});else if(o[e])h[e]=new Gi({_isIndexed:!0,hash:a[l++]});else try{h[e]=a[l++]}catch(t){h[e]=t}else try{h[e]=s[u++]}catch(t){h[e]=t}if(t.name&&null==h[t.name]){const r=h[e];r instanceof Error?Object.defineProperty(h,t.name,{enumerable:!0,get:()=>{throw Ki(`property ${JSON.stringify(t.name)}`,r)}}):h[t.name]=r}}));for(let t=0;t<h.length;t++){const e=h[t];e instanceof Error&&Object.defineProperty(h,t,{enumerable:!0,get:()=>{throw Ki(`index ${t}`,e)}})}return Object.freeze(h)}parseTransaction(t){let e=this.getFunction(t.data.substring(0,10).toLowerCase());return e?new Vi({args:this._abiCoder.decode(e.inputs,"0x"+t.data.substring(10)),functionFragment:e,name:e.name,signature:e.format(),sighash:this.getSighash(e),value:We.from(t.value||"0")}):null}parseLog(t){let e=this.getEvent(t.topics[0]);return!e||e.anonymous?null:new qi({eventFragment:e,name:e.name,signature:e.format(),topic:this.getEventTopic(e),args:this.decodeEventLog(e,t.data,t.topics)})}parseError(t){const e=I(t);let r=this.getError(e.substring(0,10).toLowerCase());return r?new Hi({args:this._abiCoder.decode(r.inputs,"0x"+e.substring(10)),errorFragment:r,name:r.name,signature:r.format(),sighash:this.getSighash(r)}):null}static isInterface(t){return!(!t||!t._isInterface)}}var Wi=a((function(t){!function(t,e){function r(t,e){if(!t)throw new Error(e||"Assertion failed")}function i(t,e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}function n(t,e,r){if(n.isBN(t))return t;this.negative=0,this.words=null,this.length=0,this.red=null,null!==t&&("le"!==e&&"be"!==e||(r=e,e=10),this._init(t||0,e||10,r||"be"))}var o;"object"==typeof t?t.exports=n:e.BN=n,n.BN=n,n.wordSize=26;try{o="undefined"!=typeof window&&void 0!==window.Buffer?window.Buffer:Pt.Buffer}catch(t){}function a(t,e){var i=t.charCodeAt(e);return i>=48&&i<=57?i-48:i>=65&&i<=70?i-55:i>=97&&i<=102?i-87:void r(!1,"Invalid character in "+t)}function s(t,e,r){var i=a(t,r);return r-1>=e&&(i|=a(t,r-1)<<4),i}function h(t,e,i,n){for(var o=0,a=0,s=Math.min(t.length,i),h=e;h<s;h++){var u=t.charCodeAt(h)-48;o*=n,a=u>=49?u-49+10:u>=17?u-17+10:u,r(u>=0&&a<n,"Invalid character"),o+=a}return o}function u(t,e){t.words=e.words,t.length=e.length,t.negative=e.negative,t.red=e.red}if(n.isBN=function(t){return t instanceof n||null!==t&&"object"==typeof t&&t.constructor.wordSize===n.wordSize&&Array.isArray(t.words)},n.max=function(t,e){return t.cmp(e)>0?t:e},n.min=function(t,e){return t.cmp(e)<0?t:e},n.prototype._init=function(t,e,i){if("number"==typeof t)return this._initNumber(t,e,i);if("object"==typeof t)return this._initArray(t,e,i);"hex"===e&&(e=16),r(e===(0|e)&&e>=2&&e<=36);var n=0;"-"===(t=t.toString().replace(/\s+/g,""))[0]&&(n++,this.negative=1),n<t.length&&(16===e?this._parseHex(t,n,i):(this._parseBase(t,e,n),"le"===i&&this._initArray(this.toArray(),e,i)))},n.prototype._initNumber=function(t,e,i){t<0&&(this.negative=1,t=-t),t<67108864?(this.words=[67108863&t],this.length=1):t<4503599627370496?(this.words=[67108863&t,t/67108864&67108863],this.length=2):(r(t<9007199254740992),this.words=[67108863&t,t/67108864&67108863,1],this.length=3),"le"===i&&this._initArray(this.toArray(),e,i)},n.prototype._initArray=function(t,e,i){if(r("number"==typeof t.length),t.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(t.length/3),this.words=new Array(this.length);for(var n=0;n<this.length;n++)this.words[n]=0;var o,a,s=0;if("be"===i)for(n=t.length-1,o=0;n>=0;n-=3)a=t[n]|t[n-1]<<8|t[n-2]<<16,this.words[o]|=a<<s&67108863,this.words[o+1]=a>>>26-s&67108863,(s+=24)>=26&&(s-=26,o++);else if("le"===i)for(n=0,o=0;n<t.length;n+=3)a=t[n]|t[n+1]<<8|t[n+2]<<16,this.words[o]|=a<<s&67108863,this.words[o+1]=a>>>26-s&67108863,(s+=24)>=26&&(s-=26,o++);return this._strip()},n.prototype._parseHex=function(t,e,r){this.length=Math.ceil((t.length-e)/6),this.words=new Array(this.length);for(var i=0;i<this.length;i++)this.words[i]=0;var n,o=0,a=0;if("be"===r)for(i=t.length-1;i>=e;i-=2)n=s(t,e,i)<<o,this.words[a]|=67108863&n,o>=18?(o-=18,a+=1,this.words[a]|=n>>>26):o+=8;else for(i=(t.length-e)%2==0?e+1:e;i<t.length;i+=2)n=s(t,e,i)<<o,this.words[a]|=67108863&n,o>=18?(o-=18,a+=1,this.words[a]|=n>>>26):o+=8;this._strip()},n.prototype._parseBase=function(t,e,r){this.words=[0],this.length=1;for(var i=0,n=1;n<=67108863;n*=e)i++;i--,n=n/e|0;for(var o=t.length-r,a=o%i,s=Math.min(o,o-a)+r,u=0,l=r;l<s;l+=i)u=h(t,l,l+i,e),this.imuln(n),this.words[0]+u<67108864?this.words[0]+=u:this._iaddn(u);if(0!==a){var c=1;for(u=h(t,l,t.length,e),l=0;l<a;l++)c*=e;this.imuln(c),this.words[0]+u<67108864?this.words[0]+=u:this._iaddn(u)}this._strip()},n.prototype.copy=function(t){t.words=new Array(this.length);for(var e=0;e<this.length;e++)t.words[e]=this.words[e];t.length=this.length,t.negative=this.negative,t.red=this.red},n.prototype._move=function(t){u(t,this)},n.prototype.clone=function(){var t=new n(null);return this.copy(t),t},n.prototype._expand=function(t){for(;this.length<t;)this.words[this.length++]=0;return this},n.prototype._strip=function(){for(;this.length>1&&0===this.words[this.length-1];)this.length--;return this._normSign()},n.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},"undefined"!=typeof Symbol&&"function"==typeof Symbol.for)try{n.prototype[Symbol.for("nodejs.util.inspect.custom")]=l}catch(t){n.prototype.inspect=l}else n.prototype.inspect=l;function l(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"}var c=["","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"],d=[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],f=[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];n.prototype.toString=function(t,e){var i;if(e=0|e||1,16===(t=t||10)||"hex"===t){i="";for(var n=0,o=0,a=0;a<this.length;a++){var s=this.words[a],h=(16777215&(s<<n|o)).toString(16);o=s>>>24-n&16777215,(n+=2)>=26&&(n-=26,a--),i=0!==o||a!==this.length-1?c[6-h.length]+h+i:h+i}for(0!==o&&(i=o.toString(16)+i);i.length%e!=0;)i="0"+i;return 0!==this.negative&&(i="-"+i),i}if(t===(0|t)&&t>=2&&t<=36){var u=d[t],l=f[t];i="";var m=this.clone();for(m.negative=0;!m.isZero();){var p=m.modrn(l).toString(t);i=(m=m.idivn(l)).isZero()?p+i:c[u-p.length]+p+i}for(this.isZero()&&(i="0"+i);i.length%e!=0;)i="0"+i;return 0!==this.negative&&(i="-"+i),i}r(!1,"Base should be between 2 and 36")},n.prototype.toNumber=function(){var t=this.words[0];return 2===this.length?t+=67108864*this.words[1]:3===this.length&&1===this.words[2]?t+=4503599627370496+67108864*this.words[1]:this.length>2&&r(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-t:t},n.prototype.toJSON=function(){return this.toString(16,2)},o&&(n.prototype.toBuffer=function(t,e){return this.toArrayLike(o,t,e)}),n.prototype.toArray=function(t,e){return this.toArrayLike(Array,t,e)};function m(t,e,r){r.negative=e.negative^t.negative;var i=t.length+e.length|0;r.length=i,i=i-1|0;var n=0|t.words[0],o=0|e.words[0],a=n*o,s=67108863&a,h=a/67108864|0;r.words[0]=s;for(var u=1;u<i;u++){for(var l=h>>>26,c=67108863&h,d=Math.min(u,e.length-1),f=Math.max(0,u-t.length+1);f<=d;f++){var m=u-f|0;l+=(a=(n=0|t.words[m])*(o=0|e.words[f])+c)/67108864|0,c=67108863&a}r.words[u]=0|c,h=0|l}return 0!==h?r.words[u]=0|h:r.length--,r._strip()}n.prototype.toArrayLike=function(t,e,i){this._strip();var n=this.byteLength(),o=i||Math.max(1,n);r(n<=o,"byte array longer than desired length"),r(o>0,"Requested array length <= 0");var a=function(t,e){return t.allocUnsafe?t.allocUnsafe(e):new t(e)}(t,o);return this["_toArrayLike"+("le"===e?"LE":"BE")](a,n),a},n.prototype._toArrayLikeLE=function(t,e){for(var r=0,i=0,n=0,o=0;n<this.length;n++){var a=this.words[n]<<o|i;t[r++]=255&a,r<t.length&&(t[r++]=a>>8&255),r<t.length&&(t[r++]=a>>16&255),6===o?(r<t.length&&(t[r++]=a>>24&255),i=0,o=0):(i=a>>>24,o+=2)}if(r<t.length)for(t[r++]=i;r<t.length;)t[r++]=0},n.prototype._toArrayLikeBE=function(t,e){for(var r=t.length-1,i=0,n=0,o=0;n<this.length;n++){var a=this.words[n]<<o|i;t[r--]=255&a,r>=0&&(t[r--]=a>>8&255),r>=0&&(t[r--]=a>>16&255),6===o?(r>=0&&(t[r--]=a>>24&255),i=0,o=0):(i=a>>>24,o+=2)}if(r>=0)for(t[r--]=i;r>=0;)t[r--]=0},Math.clz32?n.prototype._countBits=function(t){return 32-Math.clz32(t)}:n.prototype._countBits=function(t){var e=t,r=0;return e>=4096&&(r+=13,e>>>=13),e>=64&&(r+=7,e>>>=7),e>=8&&(r+=4,e>>>=4),e>=2&&(r+=2,e>>>=2),r+e},n.prototype._zeroBits=function(t){if(0===t)return 26;var e=t,r=0;return 0==(8191&e)&&(r+=13,e>>>=13),0==(127&e)&&(r+=7,e>>>=7),0==(15&e)&&(r+=4,e>>>=4),0==(3&e)&&(r+=2,e>>>=2),0==(1&e)&&r++,r},n.prototype.bitLength=function(){var t=this.words[this.length-1],e=this._countBits(t);return 26*(this.length-1)+e},n.prototype.zeroBits=function(){if(this.isZero())return 0;for(var t=0,e=0;e<this.length;e++){var r=this._zeroBits(this.words[e]);if(t+=r,26!==r)break}return t},n.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},n.prototype.toTwos=function(t){return 0!==this.negative?this.abs().inotn(t).iaddn(1):this.clone()},n.prototype.fromTwos=function(t){return this.testn(t-1)?this.notn(t).iaddn(1).ineg():this.clone()},n.prototype.isNeg=function(){return 0!==this.negative},n.prototype.neg=function(){return this.clone().ineg()},n.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},n.prototype.iuor=function(t){for(;this.length<t.length;)this.words[this.length++]=0;for(var e=0;e<t.length;e++)this.words[e]=this.words[e]|t.words[e];return this._strip()},n.prototype.ior=function(t){return r(0==(this.negative|t.negative)),this.iuor(t)},n.prototype.or=function(t){return this.length>t.length?this.clone().ior(t):t.clone().ior(this)},n.prototype.uor=function(t){return this.length>t.length?this.clone().iuor(t):t.clone().iuor(this)},n.prototype.iuand=function(t){var e;e=this.length>t.length?t:this;for(var r=0;r<e.length;r++)this.words[r]=this.words[r]&t.words[r];return this.length=e.length,this._strip()},n.prototype.iand=function(t){return r(0==(this.negative|t.negative)),this.iuand(t)},n.prototype.and=function(t){return this.length>t.length?this.clone().iand(t):t.clone().iand(this)},n.prototype.uand=function(t){return this.length>t.length?this.clone().iuand(t):t.clone().iuand(this)},n.prototype.iuxor=function(t){var e,r;this.length>t.length?(e=this,r=t):(e=t,r=this);for(var i=0;i<r.length;i++)this.words[i]=e.words[i]^r.words[i];if(this!==e)for(;i<e.length;i++)this.words[i]=e.words[i];return this.length=e.length,this._strip()},n.prototype.ixor=function(t){return r(0==(this.negative|t.negative)),this.iuxor(t)},n.prototype.xor=function(t){return this.length>t.length?this.clone().ixor(t):t.clone().ixor(this)},n.prototype.uxor=function(t){return this.length>t.length?this.clone().iuxor(t):t.clone().iuxor(this)},n.prototype.inotn=function(t){r("number"==typeof t&&t>=0);var e=0|Math.ceil(t/26),i=t%26;this._expand(e),i>0&&e--;for(var n=0;n<e;n++)this.words[n]=67108863&~this.words[n];return i>0&&(this.words[n]=~this.words[n]&67108863>>26-i),this._strip()},n.prototype.notn=function(t){return this.clone().inotn(t)},n.prototype.setn=function(t,e){r("number"==typeof t&&t>=0);var i=t/26|0,n=t%26;return this._expand(i+1),this.words[i]=e?this.words[i]|1<<n:this.words[i]&~(1<<n),this._strip()},n.prototype.iadd=function(t){var e,r,i;if(0!==this.negative&&0===t.negative)return this.negative=0,e=this.isub(t),this.negative^=1,this._normSign();if(0===this.negative&&0!==t.negative)return t.negative=0,e=this.isub(t),t.negative=1,e._normSign();this.length>t.length?(r=this,i=t):(r=t,i=this);for(var n=0,o=0;o<i.length;o++)e=(0|r.words[o])+(0|i.words[o])+n,this.words[o]=67108863&e,n=e>>>26;for(;0!==n&&o<r.length;o++)e=(0|r.words[o])+n,this.words[o]=67108863&e,n=e>>>26;if(this.length=r.length,0!==n)this.words[this.length]=n,this.length++;else if(r!==this)for(;o<r.length;o++)this.words[o]=r.words[o];return this},n.prototype.add=function(t){var e;return 0!==t.negative&&0===this.negative?(t.negative=0,e=this.sub(t),t.negative^=1,e):0===t.negative&&0!==this.negative?(this.negative=0,e=t.sub(this),this.negative=1,e):this.length>t.length?this.clone().iadd(t):t.clone().iadd(this)},n.prototype.isub=function(t){if(0!==t.negative){t.negative=0;var e=this.iadd(t);return t.negative=1,e._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(t),this.negative=1,this._normSign();var r,i,n=this.cmp(t);if(0===n)return this.negative=0,this.length=1,this.words[0]=0,this;n>0?(r=this,i=t):(r=t,i=this);for(var o=0,a=0;a<i.length;a++)o=(e=(0|r.words[a])-(0|i.words[a])+o)>>26,this.words[a]=67108863&e;for(;0!==o&&a<r.length;a++)o=(e=(0|r.words[a])+o)>>26,this.words[a]=67108863&e;if(0===o&&a<r.length&&r!==this)for(;a<r.length;a++)this.words[a]=r.words[a];return this.length=Math.max(this.length,a),r!==this&&(this.negative=1),this._strip()},n.prototype.sub=function(t){return this.clone().isub(t)};var p=function(t,e,r){var i,n,o,a=t.words,s=e.words,h=r.words,u=0,l=0|a[0],c=8191&l,d=l>>>13,f=0|a[1],m=8191&f,p=f>>>13,g=0|a[2],y=8191&g,w=g>>>13,v=0|a[3],b=8191&v,k=v>>>13,M=0|a[4],_=8191&M,E=M>>>13,A=0|a[5],j=8191&A,x=A>>>13,S=0|a[6],N=8191&S,I=S>>>13,T=0|a[7],C=8191&T,z=T>>>13,O=0|a[8],R=8191&O,P=O>>>13,B=0|a[9],D=8191&B,$=B>>>13,L=0|s[0],F=8191&L,U=L>>>13,q=0|s[1],V=8191&q,H=q>>>13,G=0|s[2],Z=8191&G,K=G>>>13,J=0|s[3],W=8191&J,Y=J>>>13,Q=0|s[4],X=8191&Q,tt=Q>>>13,et=0|s[5],rt=8191&et,it=et>>>13,nt=0|s[6],ot=8191&nt,at=nt>>>13,st=0|s[7],ht=8191&st,ut=st>>>13,lt=0|s[8],ct=8191&lt,dt=lt>>>13,ft=0|s[9],mt=8191&ft,pt=ft>>>13;r.negative=t.negative^e.negative,r.length=19;var gt=(u+(i=Math.imul(c,F))|0)+((8191&(n=(n=Math.imul(c,U))+Math.imul(d,F)|0))<<13)|0;u=((o=Math.imul(d,U))+(n>>>13)|0)+(gt>>>26)|0,gt&=67108863,i=Math.imul(m,F),n=(n=Math.imul(m,U))+Math.imul(p,F)|0,o=Math.imul(p,U);var yt=(u+(i=i+Math.imul(c,V)|0)|0)+((8191&(n=(n=n+Math.imul(c,H)|0)+Math.imul(d,V)|0))<<13)|0;u=((o=o+Math.imul(d,H)|0)+(n>>>13)|0)+(yt>>>26)|0,yt&=67108863,i=Math.imul(y,F),n=(n=Math.imul(y,U))+Math.imul(w,F)|0,o=Math.imul(w,U),i=i+Math.imul(m,V)|0,n=(n=n+Math.imul(m,H)|0)+Math.imul(p,V)|0,o=o+Math.imul(p,H)|0;var wt=(u+(i=i+Math.imul(c,Z)|0)|0)+((8191&(n=(n=n+Math.imul(c,K)|0)+Math.imul(d,Z)|0))<<13)|0;u=((o=o+Math.imul(d,K)|0)+(n>>>13)|0)+(wt>>>26)|0,wt&=67108863,i=Math.imul(b,F),n=(n=Math.imul(b,U))+Math.imul(k,F)|0,o=Math.imul(k,U),i=i+Math.imul(y,V)|0,n=(n=n+Math.imul(y,H)|0)+Math.imul(w,V)|0,o=o+Math.imul(w,H)|0,i=i+Math.imul(m,Z)|0,n=(n=n+Math.imul(m,K)|0)+Math.imul(p,Z)|0,o=o+Math.imul(p,K)|0;var vt=(u+(i=i+Math.imul(c,W)|0)|0)+((8191&(n=(n=n+Math.imul(c,Y)|0)+Math.imul(d,W)|0))<<13)|0;u=((o=o+Math.imul(d,Y)|0)+(n>>>13)|0)+(vt>>>26)|0,vt&=67108863,i=Math.imul(_,F),n=(n=Math.imul(_,U))+Math.imul(E,F)|0,o=Math.imul(E,U),i=i+Math.imul(b,V)|0,n=(n=n+Math.imul(b,H)|0)+Math.imul(k,V)|0,o=o+Math.imul(k,H)|0,i=i+Math.imul(y,Z)|0,n=(n=n+Math.imul(y,K)|0)+Math.imul(w,Z)|0,o=o+Math.imul(w,K)|0,i=i+Math.imul(m,W)|0,n=(n=n+Math.imul(m,Y)|0)+Math.imul(p,W)|0,o=o+Math.imul(p,Y)|0;var bt=(u+(i=i+Math.imul(c,X)|0)|0)+((8191&(n=(n=n+Math.imul(c,tt)|0)+Math.imul(d,X)|0))<<13)|0;u=((o=o+Math.imul(d,tt)|0)+(n>>>13)|0)+(bt>>>26)|0,bt&=67108863,i=Math.imul(j,F),n=(n=Math.imul(j,U))+Math.imul(x,F)|0,o=Math.imul(x,U),i=i+Math.imul(_,V)|0,n=(n=n+Math.imul(_,H)|0)+Math.imul(E,V)|0,o=o+Math.imul(E,H)|0,i=i+Math.imul(b,Z)|0,n=(n=n+Math.imul(b,K)|0)+Math.imul(k,Z)|0,o=o+Math.imul(k,K)|0,i=i+Math.imul(y,W)|0,n=(n=n+Math.imul(y,Y)|0)+Math.imul(w,W)|0,o=o+Math.imul(w,Y)|0,i=i+Math.imul(m,X)|0,n=(n=n+Math.imul(m,tt)|0)+Math.imul(p,X)|0,o=o+Math.imul(p,tt)|0;var kt=(u+(i=i+Math.imul(c,rt)|0)|0)+((8191&(n=(n=n+Math.imul(c,it)|0)+Math.imul(d,rt)|0))<<13)|0;u=((o=o+Math.imul(d,it)|0)+(n>>>13)|0)+(kt>>>26)|0,kt&=67108863,i=Math.imul(N,F),n=(n=Math.imul(N,U))+Math.imul(I,F)|0,o=Math.imul(I,U),i=i+Math.imul(j,V)|0,n=(n=n+Math.imul(j,H)|0)+Math.imul(x,V)|0,o=o+Math.imul(x,H)|0,i=i+Math.imul(_,Z)|0,n=(n=n+Math.imul(_,K)|0)+Math.imul(E,Z)|0,o=o+Math.imul(E,K)|0,i=i+Math.imul(b,W)|0,n=(n=n+Math.imul(b,Y)|0)+Math.imul(k,W)|0,o=o+Math.imul(k,Y)|0,i=i+Math.imul(y,X)|0,n=(n=n+Math.imul(y,tt)|0)+Math.imul(w,X)|0,o=o+Math.imul(w,tt)|0,i=i+Math.imul(m,rt)|0,n=(n=n+Math.imul(m,it)|0)+Math.imul(p,rt)|0,o=o+Math.imul(p,it)|0;var Mt=(u+(i=i+Math.imul(c,ot)|0)|0)+((8191&(n=(n=n+Math.imul(c,at)|0)+Math.imul(d,ot)|0))<<13)|0;u=((o=o+Math.imul(d,at)|0)+(n>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,i=Math.imul(C,F),n=(n=Math.imul(C,U))+Math.imul(z,F)|0,o=Math.imul(z,U),i=i+Math.imul(N,V)|0,n=(n=n+Math.imul(N,H)|0)+Math.imul(I,V)|0,o=o+Math.imul(I,H)|0,i=i+Math.imul(j,Z)|0,n=(n=n+Math.imul(j,K)|0)+Math.imul(x,Z)|0,o=o+Math.imul(x,K)|0,i=i+Math.imul(_,W)|0,n=(n=n+Math.imul(_,Y)|0)+Math.imul(E,W)|0,o=o+Math.imul(E,Y)|0,i=i+Math.imul(b,X)|0,n=(n=n+Math.imul(b,tt)|0)+Math.imul(k,X)|0,o=o+Math.imul(k,tt)|0,i=i+Math.imul(y,rt)|0,n=(n=n+Math.imul(y,it)|0)+Math.imul(w,rt)|0,o=o+Math.imul(w,it)|0,i=i+Math.imul(m,ot)|0,n=(n=n+Math.imul(m,at)|0)+Math.imul(p,ot)|0,o=o+Math.imul(p,at)|0;var _t=(u+(i=i+Math.imul(c,ht)|0)|0)+((8191&(n=(n=n+Math.imul(c,ut)|0)+Math.imul(d,ht)|0))<<13)|0;u=((o=o+Math.imul(d,ut)|0)+(n>>>13)|0)+(_t>>>26)|0,_t&=67108863,i=Math.imul(R,F),n=(n=Math.imul(R,U))+Math.imul(P,F)|0,o=Math.imul(P,U),i=i+Math.imul(C,V)|0,n=(n=n+Math.imul(C,H)|0)+Math.imul(z,V)|0,o=o+Math.imul(z,H)|0,i=i+Math.imul(N,Z)|0,n=(n=n+Math.imul(N,K)|0)+Math.imul(I,Z)|0,o=o+Math.imul(I,K)|0,i=i+Math.imul(j,W)|0,n=(n=n+Math.imul(j,Y)|0)+Math.imul(x,W)|0,o=o+Math.imul(x,Y)|0,i=i+Math.imul(_,X)|0,n=(n=n+Math.imul(_,tt)|0)+Math.imul(E,X)|0,o=o+Math.imul(E,tt)|0,i=i+Math.imul(b,rt)|0,n=(n=n+Math.imul(b,it)|0)+Math.imul(k,rt)|0,o=o+Math.imul(k,it)|0,i=i+Math.imul(y,ot)|0,n=(n=n+Math.imul(y,at)|0)+Math.imul(w,ot)|0,o=o+Math.imul(w,at)|0,i=i+Math.imul(m,ht)|0,n=(n=n+Math.imul(m,ut)|0)+Math.imul(p,ht)|0,o=o+Math.imul(p,ut)|0;var Et=(u+(i=i+Math.imul(c,ct)|0)|0)+((8191&(n=(n=n+Math.imul(c,dt)|0)+Math.imul(d,ct)|0))<<13)|0;u=((o=o+Math.imul(d,dt)|0)+(n>>>13)|0)+(Et>>>26)|0,Et&=67108863,i=Math.imul(D,F),n=(n=Math.imul(D,U))+Math.imul($,F)|0,o=Math.imul($,U),i=i+Math.imul(R,V)|0,n=(n=n+Math.imul(R,H)|0)+Math.imul(P,V)|0,o=o+Math.imul(P,H)|0,i=i+Math.imul(C,Z)|0,n=(n=n+Math.imul(C,K)|0)+Math.imul(z,Z)|0,o=o+Math.imul(z,K)|0,i=i+Math.imul(N,W)|0,n=(n=n+Math.imul(N,Y)|0)+Math.imul(I,W)|0,o=o+Math.imul(I,Y)|0,i=i+Math.imul(j,X)|0,n=(n=n+Math.imul(j,tt)|0)+Math.imul(x,X)|0,o=o+Math.imul(x,tt)|0,i=i+Math.imul(_,rt)|0,n=(n=n+Math.imul(_,it)|0)+Math.imul(E,rt)|0,o=o+Math.imul(E,it)|0,i=i+Math.imul(b,ot)|0,n=(n=n+Math.imul(b,at)|0)+Math.imul(k,ot)|0,o=o+Math.imul(k,at)|0,i=i+Math.imul(y,ht)|0,n=(n=n+Math.imul(y,ut)|0)+Math.imul(w,ht)|0,o=o+Math.imul(w,ut)|0,i=i+Math.imul(m,ct)|0,n=(n=n+Math.imul(m,dt)|0)+Math.imul(p,ct)|0,o=o+Math.imul(p,dt)|0;var At=(u+(i=i+Math.imul(c,mt)|0)|0)+((8191&(n=(n=n+Math.imul(c,pt)|0)+Math.imul(d,mt)|0))<<13)|0;u=((o=o+Math.imul(d,pt)|0)+(n>>>13)|0)+(At>>>26)|0,At&=67108863,i=Math.imul(D,V),n=(n=Math.imul(D,H))+Math.imul($,V)|0,o=Math.imul($,H),i=i+Math.imul(R,Z)|0,n=(n=n+Math.imul(R,K)|0)+Math.imul(P,Z)|0,o=o+Math.imul(P,K)|0,i=i+Math.imul(C,W)|0,n=(n=n+Math.imul(C,Y)|0)+Math.imul(z,W)|0,o=o+Math.imul(z,Y)|0,i=i+Math.imul(N,X)|0,n=(n=n+Math.imul(N,tt)|0)+Math.imul(I,X)|0,o=o+Math.imul(I,tt)|0,i=i+Math.imul(j,rt)|0,n=(n=n+Math.imul(j,it)|0)+Math.imul(x,rt)|0,o=o+Math.imul(x,it)|0,i=i+Math.imul(_,ot)|0,n=(n=n+Math.imul(_,at)|0)+Math.imul(E,ot)|0,o=o+Math.imul(E,at)|0,i=i+Math.imul(b,ht)|0,n=(n=n+Math.imul(b,ut)|0)+Math.imul(k,ht)|0,o=o+Math.imul(k,ut)|0,i=i+Math.imul(y,ct)|0,n=(n=n+Math.imul(y,dt)|0)+Math.imul(w,ct)|0,o=o+Math.imul(w,dt)|0;var jt=(u+(i=i+Math.imul(m,mt)|0)|0)+((8191&(n=(n=n+Math.imul(m,pt)|0)+Math.imul(p,mt)|0))<<13)|0;u=((o=o+Math.imul(p,pt)|0)+(n>>>13)|0)+(jt>>>26)|0,jt&=67108863,i=Math.imul(D,Z),n=(n=Math.imul(D,K))+Math.imul($,Z)|0,o=Math.imul($,K),i=i+Math.imul(R,W)|0,n=(n=n+Math.imul(R,Y)|0)+Math.imul(P,W)|0,o=o+Math.imul(P,Y)|0,i=i+Math.imul(C,X)|0,n=(n=n+Math.imul(C,tt)|0)+Math.imul(z,X)|0,o=o+Math.imul(z,tt)|0,i=i+Math.imul(N,rt)|0,n=(n=n+Math.imul(N,it)|0)+Math.imul(I,rt)|0,o=o+Math.imul(I,it)|0,i=i+Math.imul(j,ot)|0,n=(n=n+Math.imul(j,at)|0)+Math.imul(x,ot)|0,o=o+Math.imul(x,at)|0,i=i+Math.imul(_,ht)|0,n=(n=n+Math.imul(_,ut)|0)+Math.imul(E,ht)|0,o=o+Math.imul(E,ut)|0,i=i+Math.imul(b,ct)|0,n=(n=n+Math.imul(b,dt)|0)+Math.imul(k,ct)|0,o=o+Math.imul(k,dt)|0;var xt=(u+(i=i+Math.imul(y,mt)|0)|0)+((8191&(n=(n=n+Math.imul(y,pt)|0)+Math.imul(w,mt)|0))<<13)|0;u=((o=o+Math.imul(w,pt)|0)+(n>>>13)|0)+(xt>>>26)|0,xt&=67108863,i=Math.imul(D,W),n=(n=Math.imul(D,Y))+Math.imul($,W)|0,o=Math.imul($,Y),i=i+Math.imul(R,X)|0,n=(n=n+Math.imul(R,tt)|0)+Math.imul(P,X)|0,o=o+Math.imul(P,tt)|0,i=i+Math.imul(C,rt)|0,n=(n=n+Math.imul(C,it)|0)+Math.imul(z,rt)|0,o=o+Math.imul(z,it)|0,i=i+Math.imul(N,ot)|0,n=(n=n+Math.imul(N,at)|0)+Math.imul(I,ot)|0,o=o+Math.imul(I,at)|0,i=i+Math.imul(j,ht)|0,n=(n=n+Math.imul(j,ut)|0)+Math.imul(x,ht)|0,o=o+Math.imul(x,ut)|0,i=i+Math.imul(_,ct)|0,n=(n=n+Math.imul(_,dt)|0)+Math.imul(E,ct)|0,o=o+Math.imul(E,dt)|0;var St=(u+(i=i+Math.imul(b,mt)|0)|0)+((8191&(n=(n=n+Math.imul(b,pt)|0)+Math.imul(k,mt)|0))<<13)|0;u=((o=o+Math.imul(k,pt)|0)+(n>>>13)|0)+(St>>>26)|0,St&=67108863,i=Math.imul(D,X),n=(n=Math.imul(D,tt))+Math.imul($,X)|0,o=Math.imul($,tt),i=i+Math.imul(R,rt)|0,n=(n=n+Math.imul(R,it)|0)+Math.imul(P,rt)|0,o=o+Math.imul(P,it)|0,i=i+Math.imul(C,ot)|0,n=(n=n+Math.imul(C,at)|0)+Math.imul(z,ot)|0,o=o+Math.imul(z,at)|0,i=i+Math.imul(N,ht)|0,n=(n=n+Math.imul(N,ut)|0)+Math.imul(I,ht)|0,o=o+Math.imul(I,ut)|0,i=i+Math.imul(j,ct)|0,n=(n=n+Math.imul(j,dt)|0)+Math.imul(x,ct)|0,o=o+Math.imul(x,dt)|0;var Nt=(u+(i=i+Math.imul(_,mt)|0)|0)+((8191&(n=(n=n+Math.imul(_,pt)|0)+Math.imul(E,mt)|0))<<13)|0;u=((o=o+Math.imul(E,pt)|0)+(n>>>13)|0)+(Nt>>>26)|0,Nt&=67108863,i=Math.imul(D,rt),n=(n=Math.imul(D,it))+Math.imul($,rt)|0,o=Math.imul($,it),i=i+Math.imul(R,ot)|0,n=(n=n+Math.imul(R,at)|0)+Math.imul(P,ot)|0,o=o+Math.imul(P,at)|0,i=i+Math.imul(C,ht)|0,n=(n=n+Math.imul(C,ut)|0)+Math.imul(z,ht)|0,o=o+Math.imul(z,ut)|0,i=i+Math.imul(N,ct)|0,n=(n=n+Math.imul(N,dt)|0)+Math.imul(I,ct)|0,o=o+Math.imul(I,dt)|0;var It=(u+(i=i+Math.imul(j,mt)|0)|0)+((8191&(n=(n=n+Math.imul(j,pt)|0)+Math.imul(x,mt)|0))<<13)|0;u=((o=o+Math.imul(x,pt)|0)+(n>>>13)|0)+(It>>>26)|0,It&=67108863,i=Math.imul(D,ot),n=(n=Math.imul(D,at))+Math.imul($,ot)|0,o=Math.imul($,at),i=i+Math.imul(R,ht)|0,n=(n=n+Math.imul(R,ut)|0)+Math.imul(P,ht)|0,o=o+Math.imul(P,ut)|0,i=i+Math.imul(C,ct)|0,n=(n=n+Math.imul(C,dt)|0)+Math.imul(z,ct)|0,o=o+Math.imul(z,dt)|0;var Tt=(u+(i=i+Math.imul(N,mt)|0)|0)+((8191&(n=(n=n+Math.imul(N,pt)|0)+Math.imul(I,mt)|0))<<13)|0;u=((o=o+Math.imul(I,pt)|0)+(n>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,i=Math.imul(D,ht),n=(n=Math.imul(D,ut))+Math.imul($,ht)|0,o=Math.imul($,ut),i=i+Math.imul(R,ct)|0,n=(n=n+Math.imul(R,dt)|0)+Math.imul(P,ct)|0,o=o+Math.imul(P,dt)|0;var Ct=(u+(i=i+Math.imul(C,mt)|0)|0)+((8191&(n=(n=n+Math.imul(C,pt)|0)+Math.imul(z,mt)|0))<<13)|0;u=((o=o+Math.imul(z,pt)|0)+(n>>>13)|0)+(Ct>>>26)|0,Ct&=67108863,i=Math.imul(D,ct),n=(n=Math.imul(D,dt))+Math.imul($,ct)|0,o=Math.imul($,dt);var zt=(u+(i=i+Math.imul(R,mt)|0)|0)+((8191&(n=(n=n+Math.imul(R,pt)|0)+Math.imul(P,mt)|0))<<13)|0;u=((o=o+Math.imul(P,pt)|0)+(n>>>13)|0)+(zt>>>26)|0,zt&=67108863;var Ot=(u+(i=Math.imul(D,mt))|0)+((8191&(n=(n=Math.imul(D,pt))+Math.imul($,mt)|0))<<13)|0;return u=((o=Math.imul($,pt))+(n>>>13)|0)+(Ot>>>26)|0,Ot&=67108863,h[0]=gt,h[1]=yt,h[2]=wt,h[3]=vt,h[4]=bt,h[5]=kt,h[6]=Mt,h[7]=_t,h[8]=Et,h[9]=At,h[10]=jt,h[11]=xt,h[12]=St,h[13]=Nt,h[14]=It,h[15]=Tt,h[16]=Ct,h[17]=zt,h[18]=Ot,0!==u&&(h[19]=u,r.length++),r};function g(t,e,r){r.negative=e.negative^t.negative,r.length=t.length+e.length;for(var i=0,n=0,o=0;o<r.length-1;o++){var a=n;n=0;for(var s=67108863&i,h=Math.min(o,e.length-1),u=Math.max(0,o-t.length+1);u<=h;u++){var l=o-u,c=(0|t.words[l])*(0|e.words[u]),d=67108863&c;s=67108863&(d=d+s|0),n+=(a=(a=a+(c/67108864|0)|0)+(d>>>26)|0)>>>26,a&=67108863}r.words[o]=s,i=a,a=n}return 0!==i?r.words[o]=i:r.length--,r._strip()}function y(t,e,r){return g(t,e,r)}Math.imul||(p=m),n.prototype.mulTo=function(t,e){var r=this.length+t.length;return 10===this.length&&10===t.length?p(this,t,e):r<63?m(this,t,e):r<1024?g(this,t,e):y(this,t,e)},n.prototype.mul=function(t){var e=new n(null);return e.words=new Array(this.length+t.length),this.mulTo(t,e)},n.prototype.mulf=function(t){var e=new n(null);return e.words=new Array(this.length+t.length),y(this,t,e)},n.prototype.imul=function(t){return this.clone().mulTo(t,this)},n.prototype.imuln=function(t){var e=t<0;e&&(t=-t),r("number"==typeof t),r(t<67108864);for(var i=0,n=0;n<this.length;n++){var o=(0|this.words[n])*t,a=(67108863&o)+(67108863&i);i>>=26,i+=o/67108864|0,i+=a>>>26,this.words[n]=67108863&a}return 0!==i&&(this.words[n]=i,this.length++),e?this.ineg():this},n.prototype.muln=function(t){return this.clone().imuln(t)},n.prototype.sqr=function(){return this.mul(this)},n.prototype.isqr=function(){return this.imul(this.clone())},n.prototype.pow=function(t){var e=function(t){for(var e=new Array(t.bitLength()),r=0;r<e.length;r++){var i=r/26|0,n=r%26;e[r]=t.words[i]>>>n&1}return e}(t);if(0===e.length)return new n(1);for(var r=this,i=0;i<e.length&&0===e[i];i++,r=r.sqr());if(++i<e.length)for(var o=r.sqr();i<e.length;i++,o=o.sqr())0!==e[i]&&(r=r.mul(o));return r},n.prototype.iushln=function(t){r("number"==typeof t&&t>=0);var e,i=t%26,n=(t-i)/26,o=67108863>>>26-i<<26-i;if(0!==i){var a=0;for(e=0;e<this.length;e++){var s=this.words[e]&o,h=(0|this.words[e])-s<<i;this.words[e]=h|a,a=s>>>26-i}a&&(this.words[e]=a,this.length++)}if(0!==n){for(e=this.length-1;e>=0;e--)this.words[e+n]=this.words[e];for(e=0;e<n;e++)this.words[e]=0;this.length+=n}return this._strip()},n.prototype.ishln=function(t){return r(0===this.negative),this.iushln(t)},n.prototype.iushrn=function(t,e,i){var n;r("number"==typeof t&&t>=0),n=e?(e-e%26)/26:0;var o=t%26,a=Math.min((t-o)/26,this.length),s=67108863^67108863>>>o<<o,h=i;if(n-=a,n=Math.max(0,n),h){for(var u=0;u<a;u++)h.words[u]=this.words[u];h.length=a}if(0===a);else if(this.length>a)for(this.length-=a,u=0;u<this.length;u++)this.words[u]=this.words[u+a];else this.words[0]=0,this.length=1;var l=0;for(u=this.length-1;u>=0&&(0!==l||u>=n);u--){var c=0|this.words[u];this.words[u]=l<<26-o|c>>>o,l=c&s}return h&&0!==l&&(h.words[h.length++]=l),0===this.length&&(this.words[0]=0,this.length=1),this._strip()},n.prototype.ishrn=function(t,e,i){return r(0===this.negative),this.iushrn(t,e,i)},n.prototype.shln=function(t){return this.clone().ishln(t)},n.prototype.ushln=function(t){return this.clone().iushln(t)},n.prototype.shrn=function(t){return this.clone().ishrn(t)},n.prototype.ushrn=function(t){return this.clone().iushrn(t)},n.prototype.testn=function(t){r("number"==typeof t&&t>=0);var e=t%26,i=(t-e)/26,n=1<<e;return!(this.length<=i)&&!!(this.words[i]&n)},n.prototype.imaskn=function(t){r("number"==typeof t&&t>=0);var e=t%26,i=(t-e)/26;if(r(0===this.negative,"imaskn works only with positive numbers"),this.length<=i)return this;if(0!==e&&i++,this.length=Math.min(i,this.length),0!==e){var n=67108863^67108863>>>e<<e;this.words[this.length-1]&=n}return this._strip()},n.prototype.maskn=function(t){return this.clone().imaskn(t)},n.prototype.iaddn=function(t){return r("number"==typeof t),r(t<67108864),t<0?this.isubn(-t):0!==this.negative?1===this.length&&(0|this.words[0])<=t?(this.words[0]=t-(0|this.words[0]),this.negative=0,this):(this.negative=0,this.isubn(t),this.negative=1,this):this._iaddn(t)},n.prototype._iaddn=function(t){this.words[0]+=t;for(var e=0;e<this.length&&this.words[e]>=67108864;e++)this.words[e]-=67108864,e===this.length-1?this.words[e+1]=1:this.words[e+1]++;return this.length=Math.max(this.length,e+1),this},n.prototype.isubn=function(t){if(r("number"==typeof t),r(t<67108864),t<0)return this.iaddn(-t);if(0!==this.negative)return this.negative=0,this.iaddn(t),this.negative=1,this;if(this.words[0]-=t,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var e=0;e<this.length&&this.words[e]<0;e++)this.words[e]+=67108864,this.words[e+1]-=1;return this._strip()},n.prototype.addn=function(t){return this.clone().iaddn(t)},n.prototype.subn=function(t){return this.clone().isubn(t)},n.prototype.iabs=function(){return this.negative=0,this},n.prototype.abs=function(){return this.clone().iabs()},n.prototype._ishlnsubmul=function(t,e,i){var n,o,a=t.length+i;this._expand(a);var s=0;for(n=0;n<t.length;n++){o=(0|this.words[n+i])+s;var h=(0|t.words[n])*e;s=((o-=67108863&h)>>26)-(h/67108864|0),this.words[n+i]=67108863&o}for(;n<this.length-i;n++)s=(o=(0|this.words[n+i])+s)>>26,this.words[n+i]=67108863&o;if(0===s)return this._strip();for(r(-1===s),s=0,n=0;n<this.length;n++)s=(o=-(0|this.words[n])+s)>>26,this.words[n]=67108863&o;return this.negative=1,this._strip()},n.prototype._wordDiv=function(t,e){var r=(this.length,t.length),i=this.clone(),o=t,a=0|o.words[o.length-1];0!==(r=26-this._countBits(a))&&(o=o.ushln(r),i.iushln(r),a=0|o.words[o.length-1]);var s,h=i.length-o.length;if("mod"!==e){(s=new n(null)).length=h+1,s.words=new Array(s.length);for(var u=0;u<s.length;u++)s.words[u]=0}var l=i.clone()._ishlnsubmul(o,1,h);0===l.negative&&(i=l,s&&(s.words[h]=1));for(var c=h-1;c>=0;c--){var d=67108864*(0|i.words[o.length+c])+(0|i.words[o.length+c-1]);for(d=Math.min(d/a|0,67108863),i._ishlnsubmul(o,d,c);0!==i.negative;)d--,i.negative=0,i._ishlnsubmul(o,1,c),i.isZero()||(i.negative^=1);s&&(s.words[c]=d)}return s&&s._strip(),i._strip(),"div"!==e&&0!==r&&i.iushrn(r),{div:s||null,mod:i}},n.prototype.divmod=function(t,e,i){return r(!t.isZero()),this.isZero()?{div:new n(0),mod:new n(0)}:0!==this.negative&&0===t.negative?(s=this.neg().divmod(t,e),"mod"!==e&&(o=s.div.neg()),"div"!==e&&(a=s.mod.neg(),i&&0!==a.negative&&a.iadd(t)),{div:o,mod:a}):0===this.negative&&0!==t.negative?(s=this.divmod(t.neg(),e),"mod"!==e&&(o=s.div.neg()),{div:o,mod:s.mod}):0!=(this.negative&t.negative)?(s=this.neg().divmod(t.neg(),e),"div"!==e&&(a=s.mod.neg(),i&&0!==a.negative&&a.isub(t)),{div:s.div,mod:a}):t.length>this.length||this.cmp(t)<0?{div:new n(0),mod:this}:1===t.length?"div"===e?{div:this.divn(t.words[0]),mod:null}:"mod"===e?{div:null,mod:new n(this.modrn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new n(this.modrn(t.words[0]))}:this._wordDiv(t,e);var o,a,s},n.prototype.div=function(t){return this.divmod(t,"div",!1).div},n.prototype.mod=function(t){return this.divmod(t,"mod",!1).mod},n.prototype.umod=function(t){return this.divmod(t,"mod",!0).mod},n.prototype.divRound=function(t){var e=this.divmod(t);if(e.mod.isZero())return e.div;var r=0!==e.div.negative?e.mod.isub(t):e.mod,i=t.ushrn(1),n=t.andln(1),o=r.cmp(i);return o<0||1===n&&0===o?e.div:0!==e.div.negative?e.div.isubn(1):e.div.iaddn(1)},n.prototype.modrn=function(t){var e=t<0;e&&(t=-t),r(t<=67108863);for(var i=(1<<26)%t,n=0,o=this.length-1;o>=0;o--)n=(i*n+(0|this.words[o]))%t;return e?-n:n},n.prototype.modn=function(t){return this.modrn(t)},n.prototype.idivn=function(t){var e=t<0;e&&(t=-t),r(t<=67108863);for(var i=0,n=this.length-1;n>=0;n--){var o=(0|this.words[n])+67108864*i;this.words[n]=o/t|0,i=o%t}return this._strip(),e?this.ineg():this},n.prototype.divn=function(t){return this.clone().idivn(t)},n.prototype.egcd=function(t){r(0===t.negative),r(!t.isZero());var e=this,i=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var o=new n(1),a=new n(0),s=new n(0),h=new n(1),u=0;e.isEven()&&i.isEven();)e.iushrn(1),i.iushrn(1),++u;for(var l=i.clone(),c=e.clone();!e.isZero();){for(var d=0,f=1;0==(e.words[0]&f)&&d<26;++d,f<<=1);if(d>0)for(e.iushrn(d);d-- >0;)(o.isOdd()||a.isOdd())&&(o.iadd(l),a.isub(c)),o.iushrn(1),a.iushrn(1);for(var m=0,p=1;0==(i.words[0]&p)&&m<26;++m,p<<=1);if(m>0)for(i.iushrn(m);m-- >0;)(s.isOdd()||h.isOdd())&&(s.iadd(l),h.isub(c)),s.iushrn(1),h.iushrn(1);e.cmp(i)>=0?(e.isub(i),o.isub(s),a.isub(h)):(i.isub(e),s.isub(o),h.isub(a))}return{a:s,b:h,gcd:i.iushln(u)}},n.prototype._invmp=function(t){r(0===t.negative),r(!t.isZero());var e=this,i=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var o,a=new n(1),s=new n(0),h=i.clone();e.cmpn(1)>0&&i.cmpn(1)>0;){for(var u=0,l=1;0==(e.words[0]&l)&&u<26;++u,l<<=1);if(u>0)for(e.iushrn(u);u-- >0;)a.isOdd()&&a.iadd(h),a.iushrn(1);for(var c=0,d=1;0==(i.words[0]&d)&&c<26;++c,d<<=1);if(c>0)for(i.iushrn(c);c-- >0;)s.isOdd()&&s.iadd(h),s.iushrn(1);e.cmp(i)>=0?(e.isub(i),a.isub(s)):(i.isub(e),s.isub(a))}return(o=0===e.cmpn(1)?a:s).cmpn(0)<0&&o.iadd(t),o},n.prototype.gcd=function(t){if(this.isZero())return t.abs();if(t.isZero())return this.abs();var e=this.clone(),r=t.clone();e.negative=0,r.negative=0;for(var i=0;e.isEven()&&r.isEven();i++)e.iushrn(1),r.iushrn(1);for(;;){for(;e.isEven();)e.iushrn(1);for(;r.isEven();)r.iushrn(1);var n=e.cmp(r);if(n<0){var o=e;e=r,r=o}else if(0===n||0===r.cmpn(1))break;e.isub(r)}return r.iushln(i)},n.prototype.invm=function(t){return this.egcd(t).a.umod(t)},n.prototype.isEven=function(){return 0==(1&this.words[0])},n.prototype.isOdd=function(){return 1==(1&this.words[0])},n.prototype.andln=function(t){return this.words[0]&t},n.prototype.bincn=function(t){r("number"==typeof t);var e=t%26,i=(t-e)/26,n=1<<e;if(this.length<=i)return this._expand(i+1),this.words[i]|=n,this;for(var o=n,a=i;0!==o&&a<this.length;a++){var s=0|this.words[a];o=(s+=o)>>>26,s&=67108863,this.words[a]=s}return 0!==o&&(this.words[a]=o,this.length++),this},n.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},n.prototype.cmpn=function(t){var e,i=t<0;if(0!==this.negative&&!i)return-1;if(0===this.negative&&i)return 1;if(this._strip(),this.length>1)e=1;else{i&&(t=-t),r(t<=67108863,"Number is too big");var n=0|this.words[0];e=n===t?0:n<t?-1:1}return 0!==this.negative?0|-e:e},n.prototype.cmp=function(t){if(0!==this.negative&&0===t.negative)return-1;if(0===this.negative&&0!==t.negative)return 1;var e=this.ucmp(t);return 0!==this.negative?0|-e:e},n.prototype.ucmp=function(t){if(this.length>t.length)return 1;if(this.length<t.length)return-1;for(var e=0,r=this.length-1;r>=0;r--){var i=0|this.words[r],n=0|t.words[r];if(i!==n){i<n?e=-1:i>n&&(e=1);break}}return e},n.prototype.gtn=function(t){return 1===this.cmpn(t)},n.prototype.gt=function(t){return 1===this.cmp(t)},n.prototype.gten=function(t){return this.cmpn(t)>=0},n.prototype.gte=function(t){return this.cmp(t)>=0},n.prototype.ltn=function(t){return-1===this.cmpn(t)},n.prototype.lt=function(t){return-1===this.cmp(t)},n.prototype.lten=function(t){return this.cmpn(t)<=0},n.prototype.lte=function(t){return this.cmp(t)<=0},n.prototype.eqn=function(t){return 0===this.cmpn(t)},n.prototype.eq=function(t){return 0===this.cmp(t)},n.red=function(t){return new E(t)},n.prototype.toRed=function(t){return r(!this.red,"Already a number in reduction context"),r(0===this.negative,"red works only with positives"),t.convertTo(this)._forceRed(t)},n.prototype.fromRed=function(){return r(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},n.prototype._forceRed=function(t){return this.red=t,this},n.prototype.forceRed=function(t){return r(!this.red,"Already a number in reduction context"),this._forceRed(t)},n.prototype.redAdd=function(t){return r(this.red,"redAdd works only with red numbers"),this.red.add(this,t)},n.prototype.redIAdd=function(t){return r(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,t)},n.prototype.redSub=function(t){return r(this.red,"redSub works only with red numbers"),this.red.sub(this,t)},n.prototype.redISub=function(t){return r(this.red,"redISub works only with red numbers"),this.red.isub(this,t)},n.prototype.redShl=function(t){return r(this.red,"redShl works only with red numbers"),this.red.shl(this,t)},n.prototype.redMul=function(t){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.mul(this,t)},n.prototype.redIMul=function(t){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.imul(this,t)},n.prototype.redSqr=function(){return r(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},n.prototype.redISqr=function(){return r(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},n.prototype.redSqrt=function(){return r(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},n.prototype.redInvm=function(){return r(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},n.prototype.redNeg=function(){return r(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},n.prototype.redPow=function(t){return r(this.red&&!t.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,t)};var w={k256:null,p224:null,p192:null,p25519:null};function v(t,e){this.name=t,this.p=new n(e,16),this.n=this.p.bitLength(),this.k=new n(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function b(){v.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function k(){v.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function M(){v.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function _(){v.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function E(t){if("string"==typeof t){var e=n._prime(t);this.m=e.p,this.prime=e}else r(t.gtn(1),"modulus must be greater than 1"),this.m=t,this.prime=null}function A(t){E.call(this,t),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new n(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)}v.prototype._tmp=function(){var t=new n(null);return t.words=new Array(Math.ceil(this.n/13)),t},v.prototype.ireduce=function(t){var e,r=t;do{this.split(r,this.tmp),e=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(e>this.n);var i=e<this.n?-1:r.ucmp(this.p);return 0===i?(r.words[0]=0,r.length=1):i>0?r.isub(this.p):void 0!==r.strip?r.strip():r._strip(),r},v.prototype.split=function(t,e){t.iushrn(this.n,0,e)},v.prototype.imulK=function(t){return t.imul(this.k)},i(b,v),b.prototype.split=function(t,e){for(var r=4194303,i=Math.min(t.length,9),n=0;n<i;n++)e.words[n]=t.words[n];if(e.length=i,t.length<=9)return t.words[0]=0,void(t.length=1);var o=t.words[9];for(e.words[e.length++]=o&r,n=10;n<t.length;n++){var a=0|t.words[n];t.words[n-10]=(a&r)<<4|o>>>22,o=a}o>>>=22,t.words[n-10]=o,0===o&&t.length>10?t.length-=10:t.length-=9},b.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var e=0,r=0;r<t.length;r++){var i=0|t.words[r];e+=977*i,t.words[r]=67108863&e,e=64*i+(e/67108864|0)}return 0===t.words[t.length-1]&&(t.length--,0===t.words[t.length-1]&&t.length--),t},i(k,v),i(M,v),i(_,v),_.prototype.imulK=function(t){for(var e=0,r=0;r<t.length;r++){var i=19*(0|t.words[r])+e,n=67108863&i;i>>>=26,t.words[r]=n,e=i}return 0!==e&&(t.words[t.length++]=e),t},n._prime=function(t){if(w[t])return w[t];var e;if("k256"===t)e=new b;else if("p224"===t)e=new k;else if("p192"===t)e=new M;else{if("p25519"!==t)throw new Error("Unknown prime "+t);e=new _}return w[t]=e,e},E.prototype._verify1=function(t){r(0===t.negative,"red works only with positives"),r(t.red,"red works only with red numbers")},E.prototype._verify2=function(t,e){r(0==(t.negative|e.negative),"red works only with positives"),r(t.red&&t.red===e.red,"red works only with red numbers")},E.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):(u(t,t.umod(this.m)._forceRed(this)),t)},E.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},E.prototype.add=function(t,e){this._verify2(t,e);var r=t.add(e);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},E.prototype.iadd=function(t,e){this._verify2(t,e);var r=t.iadd(e);return r.cmp(this.m)>=0&&r.isub(this.m),r},E.prototype.sub=function(t,e){this._verify2(t,e);var r=t.sub(e);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},E.prototype.isub=function(t,e){this._verify2(t,e);var r=t.isub(e);return r.cmpn(0)<0&&r.iadd(this.m),r},E.prototype.shl=function(t,e){return this._verify1(t),this.imod(t.ushln(e))},E.prototype.imul=function(t,e){return this._verify2(t,e),this.imod(t.imul(e))},E.prototype.mul=function(t,e){return this._verify2(t,e),this.imod(t.mul(e))},E.prototype.isqr=function(t){return this.imul(t,t.clone())},E.prototype.sqr=function(t){return this.mul(t,t)},E.prototype.sqrt=function(t){if(t.isZero())return t.clone();var e=this.m.andln(3);if(r(e%2==1),3===e){var i=this.m.add(new n(1)).iushrn(2);return this.pow(t,i)}for(var o=this.m.subn(1),a=0;!o.isZero()&&0===o.andln(1);)a++,o.iushrn(1);r(!o.isZero());var s=new n(1).toRed(this),h=s.redNeg(),u=this.m.subn(1).iushrn(1),l=this.m.bitLength();for(l=new n(2*l*l).toRed(this);0!==this.pow(l,u).cmp(h);)l.redIAdd(h);for(var c=this.pow(l,o),d=this.pow(t,o.addn(1).iushrn(1)),f=this.pow(t,o),m=a;0!==f.cmp(s);){for(var p=f,g=0;0!==p.cmp(s);g++)p=p.redSqr();r(g<m);var y=this.pow(c,new n(1).iushln(m-g-1));d=d.redMul(y),c=y.redSqr(),f=f.redMul(c),m=g}return d},E.prototype.invm=function(t){var e=t._invmp(this.m);return 0!==e.negative?(e.negative=0,this.imod(e).redNeg()):this.imod(e)},E.prototype.pow=function(t,e){if(e.isZero())return new n(1).toRed(this);if(0===e.cmpn(1))return t.clone();var r=new Array(16);r[0]=new n(1).toRed(this),r[1]=t;for(var i=2;i<r.length;i++)r[i]=this.mul(r[i-1],t);var o=r[0],a=0,s=0,h=e.bitLength()%26;for(0===h&&(h=26),i=e.length-1;i>=0;i--){for(var u=e.words[i],l=h-1;l>=0;l--){var c=u>>l&1;o!==r[0]&&(o=this.sqr(o)),0!==c||0!==a?(a<<=1,a|=c,(4===++s||0===i&&0===l)&&(o=this.mul(o,r[a]),s=0,a=0)):s=0}h=26}return o},E.prototype.convertTo=function(t){var e=t.umod(this.m);return e===t?e.clone():e},E.prototype.convertFrom=function(t){var e=t.clone();return e.red=null,e},n.mont=function(t){return new A(t)},i(A,E),A.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},A.prototype.convertFrom=function(t){var e=this.imod(t.mul(this.rinv));return e.red=null,e},A.prototype.imul=function(t,e){if(t.isZero()||e.isZero())return t.words[0]=0,t.length=1,t;var r=t.imul(e),i=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),n=r.isub(i).iushrn(this.shift),o=n;return n.cmp(this.m)>=0?o=n.isub(this.m):n.cmpn(0)<0&&(o=n.iadd(this.m)),o._forceRed(this)},A.prototype.mul=function(t,e){if(t.isZero()||e.isZero())return new n(0)._forceRed(this);var r=t.mul(e),i=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),o=r.isub(i).iushrn(this.shift),a=o;return o.cmp(this.m)>=0?a=o.isub(this.m):o.cmpn(0)<0&&(a=o.iadd(this.m)),a._forceRed(this)},A.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}(t,i)}));var Yi=Wi.BN;const Qi=new w("bignumber/5.6.2"),Xi={},tn=9007199254740991;let en=!1;class rn{constructor(t,e){t!==Xi&&Qi.throwError("cannot call constructor directly; use BigNumber.from",w.errors.UNSUPPORTED_OPERATION,{operation:"new (BigNumber)"}),this._hex=e,this._isBigNumber=!0,Object.freeze(this)}fromTwos(t){return on(an(this).fromTwos(t))}toTwos(t){return on(an(this).toTwos(t))}abs(){return"-"===this._hex[0]?rn.from(this._hex.substring(1)):this}add(t){return on(an(this).add(an(t)))}sub(t){return on(an(this).sub(an(t)))}div(t){return rn.from(t).isZero()&&sn("division-by-zero","div"),on(an(this).div(an(t)))}mul(t){return on(an(this).mul(an(t)))}mod(t){const e=an(t);return e.isNeg()&&sn("division-by-zero","mod"),on(an(this).umod(e))}pow(t){const e=an(t);return e.isNeg()&&sn("negative-power","pow"),on(an(this).pow(e))}and(t){const e=an(t);return(this.isNegative()||e.isNeg())&&sn("unbound-bitwise-result","and"),on(an(this).and(e))}or(t){const e=an(t);return(this.isNegative()||e.isNeg())&&sn("unbound-bitwise-result","or"),on(an(this).or(e))}xor(t){const e=an(t);return(this.isNegative()||e.isNeg())&&sn("unbound-bitwise-result","xor"),on(an(this).xor(e))}mask(t){return(this.isNegative()||t<0)&&sn("negative-width","mask"),on(an(this).maskn(t))}shl(t){return(this.isNegative()||t<0)&&sn("negative-width","shl"),on(an(this).shln(t))}shr(t){return(this.isNegative()||t<0)&&sn("negative-width","shr"),on(an(this).shrn(t))}eq(t){return an(this).eq(an(t))}lt(t){return an(this).lt(an(t))}lte(t){return an(this).lte(an(t))}gt(t){return an(this).gt(an(t))}gte(t){return an(this).gte(an(t))}isNegative(){return"-"===this._hex[0]}isZero(){return an(this).isZero()}toNumber(){try{return an(this).toNumber()}catch(t){sn("overflow","toNumber",this.toString())}return null}toBigInt(){try{return BigInt(this.toString())}catch(t){}return Qi.throwError("this platform does not support BigInt",w.errors.UNSUPPORTED_OPERATION,{value:this.toString()})}toString(){return arguments.length>0&&(10===arguments[0]?en||(en=!0,Qi.warn("BigNumber.toString does not accept any parameters; base-10 is assumed")):16===arguments[0]?Qi.throwError("BigNumber.toString does not accept any parameters; use bigNumber.toHexString()",w.errors.UNEXPECTED_ARGUMENT,{}):Qi.throwError("BigNumber.toString does not accept parameters",w.errors.UNEXPECTED_ARGUMENT,{})),an(this).toString(10)}toHexString(){return this._hex}toJSON(t){return{type:"BigNumber",hex:this.toHexString()}}static from(t){if(t instanceof rn)return t;if("string"==typeof t)return t.match(/^-?0x[0-9a-f]+$/i)?new rn(Xi,nn(t)):t.match(/^-?[0-9]+$/)?new rn(Xi,nn(new Yi(t))):Qi.throwArgumentError("invalid BigNumber string","value",t);if("number"==typeof t)return t%1&&sn("underflow","BigNumber.from",t),(t>=tn||t<=-tn)&&sn("overflow","BigNumber.from",t),rn.from(String(t));const e=t;if("bigint"==typeof e)return rn.from(e.toString());if(E(e))return rn.from(I(e));if(e)if(e.toHexString){const t=e.toHexString();if("string"==typeof t)return rn.from(t)}else{let t=e._hex;if(null==t&&"BigNumber"===e.type&&(t=e.hex),"string"==typeof t&&(S(t)||"-"===t[0]&&S(t.substring(1))))return rn.from(t)}return Qi.throwArgumentError("invalid BigNumber value","value",t)}static isBigNumber(t){return!(!t||!t._isBigNumber)}}function nn(t){if("string"!=typeof t)return nn(t.toString(16));if("-"===t[0])return"-"===(t=t.substring(1))[0]&&Qi.throwArgumentError("invalid hex","value",t),"0x00"===(t=nn(t))?t:"-"+t;if("0x"!==t.substring(0,2)&&(t="0x"+t),"0x"===t)return"0x00";for(t.length%2&&(t="0x0"+t.substring(2));t.length>4&&"0x00"===t.substring(0,4);)t="0x"+t.substring(4);return t}function on(t){return rn.from(nn(t))}function an(t){const e=rn.from(t).toHexString();return"-"===e[0]?new Yi("-"+e.substring(3),16):new Yi(e.substring(2),16)}function sn(t,e,r){const i={fault:t,operation:e};return null!=r&&(i.value=r),Qi.throwError(t,w.errors.NUMERIC_FAULT,i)}var hn=window&&window.__awaiter||function(t,e,r,i){return new(r||(r=Promise))((function(n,o){function a(t){try{h(i.next(t))}catch(t){o(t)}}function s(t){try{h(i.throw(t))}catch(t){o(t)}}function h(t){var e;t.done?n(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(a,s)}h((i=i.apply(t,e||[])).next())}))};const un=new w("abstract-provider/5.6.1");class ln extends cr{static isForkEvent(t){return!(!t||!t._isForkEvent)}}class cn{constructor(){un.checkAbstract(new.target,cn),ir(this,"_isProvider",!0)}getFeeData(){return hn(this,void 0,void 0,(function*(){const{block:t,gasPrice:e}=yield or({block:this.getBlock("latest"),gasPrice:this.getGasPrice().catch((t=>null))});let r=null,i=null;return t&&t.baseFeePerGas&&(i=rn.from("1500000000"),r=t.baseFeePerGas.mul(2).add(i)),{maxFeePerGas:r,maxPriorityFeePerGas:i,gasPrice:e}}))}addListener(t,e){return this.on(t,e)}removeListener(t,e){return this.off(t,e)}static isProvider(t){return!(!t||!t._isProvider)}}var dn=window&&window.__awaiter||function(t,e,r,i){return new(r||(r=Promise))((function(n,o){function a(t){try{h(i.next(t))}catch(t){o(t)}}function s(t){try{h(i.throw(t))}catch(t){o(t)}}function h(t){var e;t.done?n(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(a,s)}h((i=i.apply(t,e||[])).next())}))};const fn=new w("abstract-signer/5.6.2"),mn=["accessList","ccipReadEnabled","chainId","customData","data","from","gasLimit","gasPrice","maxFeePerGas","maxPriorityFeePerGas","nonce","to","type","value"],pn=[w.errors.INSUFFICIENT_FUNDS,w.errors.NONCE_EXPIRED,w.errors.REPLACEMENT_UNDERPRICED];class gn{constructor(){fn.checkAbstract(new.target,gn),ir(this,"_isSigner",!0)}getBalance(t){return dn(this,void 0,void 0,(function*(){return this._checkProvider("getBalance"),yield this.provider.getBalance(this.getAddress(),t)}))}getTransactionCount(t){return dn(this,void 0,void 0,(function*(){return this._checkProvider("getTransactionCount"),yield this.provider.getTransactionCount(this.getAddress(),t)}))}estimateGas(t){return dn(this,void 0,void 0,(function*(){this._checkProvider("estimateGas");const e=yield or(this.checkTransaction(t));return yield this.provider.estimateGas(e)}))}call(t,e){return dn(this,void 0,void 0,(function*(){this._checkProvider("call");const r=yield or(this.checkTransaction(t));return yield this.provider.call(r,e)}))}sendTransaction(t){return dn(this,void 0,void 0,(function*(){this._checkProvider("sendTransaction");const e=yield this.populateTransaction(t),r=yield this.signTransaction(e);return yield this.provider.sendTransaction(r)}))}getChainId(){return dn(this,void 0,void 0,(function*(){this._checkProvider("getChainId");return(yield this.provider.getNetwork()).chainId}))}getGasPrice(){return dn(this,void 0,void 0,(function*(){return this._checkProvider("getGasPrice"),yield this.provider.getGasPrice()}))}getFeeData(){return dn(this,void 0,void 0,(function*(){return this._checkProvider("getFeeData"),yield this.provider.getFeeData()}))}resolveName(t){return dn(this,void 0,void 0,(function*(){return this._checkProvider("resolveName"),yield this.provider.resolveName(t)}))}checkTransaction(t){for(const e in t)-1===mn.indexOf(e)&&fn.throwArgumentError("invalid transaction key: "+e,"transaction",t);const e=ar(t);return null==e.from?e.from=this.getAddress():e.from=Promise.all([Promise.resolve(e.from),this.getAddress()]).then((e=>(e[0].toLowerCase()!==e[1].toLowerCase()&&fn.throwArgumentError("from address mismatch","transaction",t),e[0]))),e}populateTransaction(t){return dn(this,void 0,void 0,(function*(){const e=yield or(this.checkTransaction(t));null!=e.to&&(e.to=Promise.resolve(e.to).then((t=>dn(this,void 0,void 0,(function*(){if(null==t)return null;const e=yield this.resolveName(t);return null==e&&fn.throwArgumentError("provided ENS name resolves to null","tx.to",t),e})))),e.to.catch((t=>{})));const r=null!=e.maxFeePerGas||null!=e.maxPriorityFeePerGas;if(null==e.gasPrice||2!==e.type&&!r?0!==e.type&&1!==e.type||!r||fn.throwArgumentError("pre-eip-1559 transaction do not support maxFeePerGas/maxPriorityFeePerGas","transaction",t):fn.throwArgumentError("eip-1559 transaction do not support gasPrice","transaction",t),2!==e.type&&null!=e.type||null==e.maxFeePerGas||null==e.maxPriorityFeePerGas)if(0===e.type||1===e.type)null==e.gasPrice&&(e.gasPrice=this.getGasPrice());else{const t=yield this.getFeeData();if(null==e.type)if(null!=t.maxFeePerGas&&null!=t.maxPriorityFeePerGas)if(e.type=2,null!=e.gasPrice){const t=e.gasPrice;delete e.gasPrice,e.maxFeePerGas=t,e.maxPriorityFeePerGas=t}else null==e.maxFeePerGas&&(e.maxFeePerGas=t.maxFeePerGas),null==e.maxPriorityFeePerGas&&(e.maxPriorityFeePerGas=t.maxPriorityFeePerGas);else null!=t.gasPrice?(r&&fn.throwError("network does not support EIP-1559",w.errors.UNSUPPORTED_OPERATION,{operation:"populateTransaction"}),null==e.gasPrice&&(e.gasPrice=t.gasPrice),e.type=0):fn.throwError("failed to get consistent fee data",w.errors.UNSUPPORTED_OPERATION,{operation:"signer.getFeeData"});else 2===e.type&&(null==e.maxFeePerGas&&(e.maxFeePerGas=t.maxFeePerGas),null==e.maxPriorityFeePerGas&&(e.maxPriorityFeePerGas=t.maxPriorityFeePerGas))}else e.type=2;return null==e.nonce&&(e.nonce=this.getTransactionCount("pending")),null==e.gasLimit&&(e.gasLimit=this.estimateGas(e).catch((t=>{if(pn.indexOf(t.code)>=0)throw t;return fn.throwError("cannot estimate gas; transaction may fail or may require manual gas limit",w.errors.UNPREDICTABLE_GAS_LIMIT,{error:t,tx:e})}))),null==e.chainId?e.chainId=this.getChainId():e.chainId=Promise.all([Promise.resolve(e.chainId),this.getChainId()]).then((e=>(0!==e[1]&&e[0]!==e[1]&&fn.throwArgumentError("chainId address mismatch","transaction",t),e[0]))),yield or(e)}))}_checkProvider(t){this.provider||fn.throwError("missing provider",w.errors.UNSUPPORTED_OPERATION,{operation:t||"_checkProvider"})}static isSigner(t){return!(!t||!t._isSigner)}}class yn extends gn{constructor(t,e){super(),ir(this,"address",t),ir(this,"provider",e||null)}getAddress(){return Promise.resolve(this.address)}_fail(t,e){return Promise.resolve().then((()=>{fn.throwError(t,w.errors.UNSUPPORTED_OPERATION,{operation:e})}))}signMessage(t){return this._fail("VoidSigner cannot sign messages","signMessage")}signTransaction(t){return this._fail("VoidSigner cannot sign transactions","signTransaction")}_signTypedData(t,e,r){return this._fail("VoidSigner cannot sign typed data","signTypedData")}connect(t){return new yn(this.address,t)}}var wn=a((function(t){!function(t,e){function r(t,e){if(!t)throw new Error(e||"Assertion failed")}function i(t,e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}function n(t,e,r){if(n.isBN(t))return t;this.negative=0,this.words=null,this.length=0,this.red=null,null!==t&&("le"!==e&&"be"!==e||(r=e,e=10),this._init(t||0,e||10,r||"be"))}var o;"object"==typeof t?t.exports=n:e.BN=n,n.BN=n,n.wordSize=26;try{o="undefined"!=typeof window&&void 0!==window.Buffer?window.Buffer:Pt.Buffer}catch(t){}function a(t,e){var i=t.charCodeAt(e);return i>=48&&i<=57?i-48:i>=65&&i<=70?i-55:i>=97&&i<=102?i-87:void r(!1,"Invalid character in "+t)}function s(t,e,r){var i=a(t,r);return r-1>=e&&(i|=a(t,r-1)<<4),i}function h(t,e,i,n){for(var o=0,a=0,s=Math.min(t.length,i),h=e;h<s;h++){var u=t.charCodeAt(h)-48;o*=n,a=u>=49?u-49+10:u>=17?u-17+10:u,r(u>=0&&a<n,"Invalid character"),o+=a}return o}function u(t,e){t.words=e.words,t.length=e.length,t.negative=e.negative,t.red=e.red}if(n.isBN=function(t){return t instanceof n||null!==t&&"object"==typeof t&&t.constructor.wordSize===n.wordSize&&Array.isArray(t.words)},n.max=function(t,e){return t.cmp(e)>0?t:e},n.min=function(t,e){return t.cmp(e)<0?t:e},n.prototype._init=function(t,e,i){if("number"==typeof t)return this._initNumber(t,e,i);if("object"==typeof t)return this._initArray(t,e,i);"hex"===e&&(e=16),r(e===(0|e)&&e>=2&&e<=36);var n=0;"-"===(t=t.toString().replace(/\s+/g,""))[0]&&(n++,this.negative=1),n<t.length&&(16===e?this._parseHex(t,n,i):(this._parseBase(t,e,n),"le"===i&&this._initArray(this.toArray(),e,i)))},n.prototype._initNumber=function(t,e,i){t<0&&(this.negative=1,t=-t),t<67108864?(this.words=[67108863&t],this.length=1):t<4503599627370496?(this.words=[67108863&t,t/67108864&67108863],this.length=2):(r(t<9007199254740992),this.words=[67108863&t,t/67108864&67108863,1],this.length=3),"le"===i&&this._initArray(this.toArray(),e,i)},n.prototype._initArray=function(t,e,i){if(r("number"==typeof t.length),t.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(t.length/3),this.words=new Array(this.length);for(var n=0;n<this.length;n++)this.words[n]=0;var o,a,s=0;if("be"===i)for(n=t.length-1,o=0;n>=0;n-=3)a=t[n]|t[n-1]<<8|t[n-2]<<16,this.words[o]|=a<<s&67108863,this.words[o+1]=a>>>26-s&67108863,(s+=24)>=26&&(s-=26,o++);else if("le"===i)for(n=0,o=0;n<t.length;n+=3)a=t[n]|t[n+1]<<8|t[n+2]<<16,this.words[o]|=a<<s&67108863,this.words[o+1]=a>>>26-s&67108863,(s+=24)>=26&&(s-=26,o++);return this._strip()},n.prototype._parseHex=function(t,e,r){this.length=Math.ceil((t.length-e)/6),this.words=new Array(this.length);for(var i=0;i<this.length;i++)this.words[i]=0;var n,o=0,a=0;if("be"===r)for(i=t.length-1;i>=e;i-=2)n=s(t,e,i)<<o,this.words[a]|=67108863&n,o>=18?(o-=18,a+=1,this.words[a]|=n>>>26):o+=8;else for(i=(t.length-e)%2==0?e+1:e;i<t.length;i+=2)n=s(t,e,i)<<o,this.words[a]|=67108863&n,o>=18?(o-=18,a+=1,this.words[a]|=n>>>26):o+=8;this._strip()},n.prototype._parseBase=function(t,e,r){this.words=[0],this.length=1;for(var i=0,n=1;n<=67108863;n*=e)i++;i--,n=n/e|0;for(var o=t.length-r,a=o%i,s=Math.min(o,o-a)+r,u=0,l=r;l<s;l+=i)u=h(t,l,l+i,e),this.imuln(n),this.words[0]+u<67108864?this.words[0]+=u:this._iaddn(u);if(0!==a){var c=1;for(u=h(t,l,t.length,e),l=0;l<a;l++)c*=e;this.imuln(c),this.words[0]+u<67108864?this.words[0]+=u:this._iaddn(u)}this._strip()},n.prototype.copy=function(t){t.words=new Array(this.length);for(var e=0;e<this.length;e++)t.words[e]=this.words[e];t.length=this.length,t.negative=this.negative,t.red=this.red},n.prototype._move=function(t){u(t,this)},n.prototype.clone=function(){var t=new n(null);return this.copy(t),t},n.prototype._expand=function(t){for(;this.length<t;)this.words[this.length++]=0;return this},n.prototype._strip=function(){for(;this.length>1&&0===this.words[this.length-1];)this.length--;return this._normSign()},n.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},"undefined"!=typeof Symbol&&"function"==typeof Symbol.for)try{n.prototype[Symbol.for("nodejs.util.inspect.custom")]=l}catch(t){n.prototype.inspect=l}else n.prototype.inspect=l;function l(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"}var c=["","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"],d=[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],f=[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];n.prototype.toString=function(t,e){var i;if(e=0|e||1,16===(t=t||10)||"hex"===t){i="";for(var n=0,o=0,a=0;a<this.length;a++){var s=this.words[a],h=(16777215&(s<<n|o)).toString(16);o=s>>>24-n&16777215,(n+=2)>=26&&(n-=26,a--),i=0!==o||a!==this.length-1?c[6-h.length]+h+i:h+i}for(0!==o&&(i=o.toString(16)+i);i.length%e!=0;)i="0"+i;return 0!==this.negative&&(i="-"+i),i}if(t===(0|t)&&t>=2&&t<=36){var u=d[t],l=f[t];i="";var m=this.clone();for(m.negative=0;!m.isZero();){var p=m.modrn(l).toString(t);i=(m=m.idivn(l)).isZero()?p+i:c[u-p.length]+p+i}for(this.isZero()&&(i="0"+i);i.length%e!=0;)i="0"+i;return 0!==this.negative&&(i="-"+i),i}r(!1,"Base should be between 2 and 36")},n.prototype.toNumber=function(){var t=this.words[0];return 2===this.length?t+=67108864*this.words[1]:3===this.length&&1===this.words[2]?t+=4503599627370496+67108864*this.words[1]:this.length>2&&r(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-t:t},n.prototype.toJSON=function(){return this.toString(16,2)},o&&(n.prototype.toBuffer=function(t,e){return this.toArrayLike(o,t,e)}),n.prototype.toArray=function(t,e){return this.toArrayLike(Array,t,e)};function m(t,e,r){r.negative=e.negative^t.negative;var i=t.length+e.length|0;r.length=i,i=i-1|0;var n=0|t.words[0],o=0|e.words[0],a=n*o,s=67108863&a,h=a/67108864|0;r.words[0]=s;for(var u=1;u<i;u++){for(var l=h>>>26,c=67108863&h,d=Math.min(u,e.length-1),f=Math.max(0,u-t.length+1);f<=d;f++){var m=u-f|0;l+=(a=(n=0|t.words[m])*(o=0|e.words[f])+c)/67108864|0,c=67108863&a}r.words[u]=0|c,h=0|l}return 0!==h?r.words[u]=0|h:r.length--,r._strip()}n.prototype.toArrayLike=function(t,e,i){this._strip();var n=this.byteLength(),o=i||Math.max(1,n);r(n<=o,"byte array longer than desired length"),r(o>0,"Requested array length <= 0");var a=function(t,e){return t.allocUnsafe?t.allocUnsafe(e):new t(e)}(t,o);return this["_toArrayLike"+("le"===e?"LE":"BE")](a,n),a},n.prototype._toArrayLikeLE=function(t,e){for(var r=0,i=0,n=0,o=0;n<this.length;n++){var a=this.words[n]<<o|i;t[r++]=255&a,r<t.length&&(t[r++]=a>>8&255),r<t.length&&(t[r++]=a>>16&255),6===o?(r<t.length&&(t[r++]=a>>24&255),i=0,o=0):(i=a>>>24,o+=2)}if(r<t.length)for(t[r++]=i;r<t.length;)t[r++]=0},n.prototype._toArrayLikeBE=function(t,e){for(var r=t.length-1,i=0,n=0,o=0;n<this.length;n++){var a=this.words[n]<<o|i;t[r--]=255&a,r>=0&&(t[r--]=a>>8&255),r>=0&&(t[r--]=a>>16&255),6===o?(r>=0&&(t[r--]=a>>24&255),i=0,o=0):(i=a>>>24,o+=2)}if(r>=0)for(t[r--]=i;r>=0;)t[r--]=0},Math.clz32?n.prototype._countBits=function(t){return 32-Math.clz32(t)}:n.prototype._countBits=function(t){var e=t,r=0;return e>=4096&&(r+=13,e>>>=13),e>=64&&(r+=7,e>>>=7),e>=8&&(r+=4,e>>>=4),e>=2&&(r+=2,e>>>=2),r+e},n.prototype._zeroBits=function(t){if(0===t)return 26;var e=t,r=0;return 0==(8191&e)&&(r+=13,e>>>=13),0==(127&e)&&(r+=7,e>>>=7),0==(15&e)&&(r+=4,e>>>=4),0==(3&e)&&(r+=2,e>>>=2),0==(1&e)&&r++,r},n.prototype.bitLength=function(){var t=this.words[this.length-1],e=this._countBits(t);return 26*(this.length-1)+e},n.prototype.zeroBits=function(){if(this.isZero())return 0;for(var t=0,e=0;e<this.length;e++){var r=this._zeroBits(this.words[e]);if(t+=r,26!==r)break}return t},n.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},n.prototype.toTwos=function(t){return 0!==this.negative?this.abs().inotn(t).iaddn(1):this.clone()},n.prototype.fromTwos=function(t){return this.testn(t-1)?this.notn(t).iaddn(1).ineg():this.clone()},n.prototype.isNeg=function(){return 0!==this.negative},n.prototype.neg=function(){return this.clone().ineg()},n.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},n.prototype.iuor=function(t){for(;this.length<t.length;)this.words[this.length++]=0;for(var e=0;e<t.length;e++)this.words[e]=this.words[e]|t.words[e];return this._strip()},n.prototype.ior=function(t){return r(0==(this.negative|t.negative)),this.iuor(t)},n.prototype.or=function(t){return this.length>t.length?this.clone().ior(t):t.clone().ior(this)},n.prototype.uor=function(t){return this.length>t.length?this.clone().iuor(t):t.clone().iuor(this)},n.prototype.iuand=function(t){var e;e=this.length>t.length?t:this;for(var r=0;r<e.length;r++)this.words[r]=this.words[r]&t.words[r];return this.length=e.length,this._strip()},n.prototype.iand=function(t){return r(0==(this.negative|t.negative)),this.iuand(t)},n.prototype.and=function(t){return this.length>t.length?this.clone().iand(t):t.clone().iand(this)},n.prototype.uand=function(t){return this.length>t.length?this.clone().iuand(t):t.clone().iuand(this)},n.prototype.iuxor=function(t){var e,r;this.length>t.length?(e=this,r=t):(e=t,r=this);for(var i=0;i<r.length;i++)this.words[i]=e.words[i]^r.words[i];if(this!==e)for(;i<e.length;i++)this.words[i]=e.words[i];return this.length=e.length,this._strip()},n.prototype.ixor=function(t){return r(0==(this.negative|t.negative)),this.iuxor(t)},n.prototype.xor=function(t){return this.length>t.length?this.clone().ixor(t):t.clone().ixor(this)},n.prototype.uxor=function(t){return this.length>t.length?this.clone().iuxor(t):t.clone().iuxor(this)},n.prototype.inotn=function(t){r("number"==typeof t&&t>=0);var e=0|Math.ceil(t/26),i=t%26;this._expand(e),i>0&&e--;for(var n=0;n<e;n++)this.words[n]=67108863&~this.words[n];return i>0&&(this.words[n]=~this.words[n]&67108863>>26-i),this._strip()},n.prototype.notn=function(t){return this.clone().inotn(t)},n.prototype.setn=function(t,e){r("number"==typeof t&&t>=0);var i=t/26|0,n=t%26;return this._expand(i+1),this.words[i]=e?this.words[i]|1<<n:this.words[i]&~(1<<n),this._strip()},n.prototype.iadd=function(t){var e,r,i;if(0!==this.negative&&0===t.negative)return this.negative=0,e=this.isub(t),this.negative^=1,this._normSign();if(0===this.negative&&0!==t.negative)return t.negative=0,e=this.isub(t),t.negative=1,e._normSign();this.length>t.length?(r=this,i=t):(r=t,i=this);for(var n=0,o=0;o<i.length;o++)e=(0|r.words[o])+(0|i.words[o])+n,this.words[o]=67108863&e,n=e>>>26;for(;0!==n&&o<r.length;o++)e=(0|r.words[o])+n,this.words[o]=67108863&e,n=e>>>26;if(this.length=r.length,0!==n)this.words[this.length]=n,this.length++;else if(r!==this)for(;o<r.length;o++)this.words[o]=r.words[o];return this},n.prototype.add=function(t){var e;return 0!==t.negative&&0===this.negative?(t.negative=0,e=this.sub(t),t.negative^=1,e):0===t.negative&&0!==this.negative?(this.negative=0,e=t.sub(this),this.negative=1,e):this.length>t.length?this.clone().iadd(t):t.clone().iadd(this)},n.prototype.isub=function(t){if(0!==t.negative){t.negative=0;var e=this.iadd(t);return t.negative=1,e._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(t),this.negative=1,this._normSign();var r,i,n=this.cmp(t);if(0===n)return this.negative=0,this.length=1,this.words[0]=0,this;n>0?(r=this,i=t):(r=t,i=this);for(var o=0,a=0;a<i.length;a++)o=(e=(0|r.words[a])-(0|i.words[a])+o)>>26,this.words[a]=67108863&e;for(;0!==o&&a<r.length;a++)o=(e=(0|r.words[a])+o)>>26,this.words[a]=67108863&e;if(0===o&&a<r.length&&r!==this)for(;a<r.length;a++)this.words[a]=r.words[a];return this.length=Math.max(this.length,a),r!==this&&(this.negative=1),this._strip()},n.prototype.sub=function(t){return this.clone().isub(t)};var p=function(t,e,r){var i,n,o,a=t.words,s=e.words,h=r.words,u=0,l=0|a[0],c=8191&l,d=l>>>13,f=0|a[1],m=8191&f,p=f>>>13,g=0|a[2],y=8191&g,w=g>>>13,v=0|a[3],b=8191&v,k=v>>>13,M=0|a[4],_=8191&M,E=M>>>13,A=0|a[5],j=8191&A,x=A>>>13,S=0|a[6],N=8191&S,I=S>>>13,T=0|a[7],C=8191&T,z=T>>>13,O=0|a[8],R=8191&O,P=O>>>13,B=0|a[9],D=8191&B,$=B>>>13,L=0|s[0],F=8191&L,U=L>>>13,q=0|s[1],V=8191&q,H=q>>>13,G=0|s[2],Z=8191&G,K=G>>>13,J=0|s[3],W=8191&J,Y=J>>>13,Q=0|s[4],X=8191&Q,tt=Q>>>13,et=0|s[5],rt=8191&et,it=et>>>13,nt=0|s[6],ot=8191&nt,at=nt>>>13,st=0|s[7],ht=8191&st,ut=st>>>13,lt=0|s[8],ct=8191&lt,dt=lt>>>13,ft=0|s[9],mt=8191&ft,pt=ft>>>13;r.negative=t.negative^e.negative,r.length=19;var gt=(u+(i=Math.imul(c,F))|0)+((8191&(n=(n=Math.imul(c,U))+Math.imul(d,F)|0))<<13)|0;u=((o=Math.imul(d,U))+(n>>>13)|0)+(gt>>>26)|0,gt&=67108863,i=Math.imul(m,F),n=(n=Math.imul(m,U))+Math.imul(p,F)|0,o=Math.imul(p,U);var yt=(u+(i=i+Math.imul(c,V)|0)|0)+((8191&(n=(n=n+Math.imul(c,H)|0)+Math.imul(d,V)|0))<<13)|0;u=((o=o+Math.imul(d,H)|0)+(n>>>13)|0)+(yt>>>26)|0,yt&=67108863,i=Math.imul(y,F),n=(n=Math.imul(y,U))+Math.imul(w,F)|0,o=Math.imul(w,U),i=i+Math.imul(m,V)|0,n=(n=n+Math.imul(m,H)|0)+Math.imul(p,V)|0,o=o+Math.imul(p,H)|0;var wt=(u+(i=i+Math.imul(c,Z)|0)|0)+((8191&(n=(n=n+Math.imul(c,K)|0)+Math.imul(d,Z)|0))<<13)|0;u=((o=o+Math.imul(d,K)|0)+(n>>>13)|0)+(wt>>>26)|0,wt&=67108863,i=Math.imul(b,F),n=(n=Math.imul(b,U))+Math.imul(k,F)|0,o=Math.imul(k,U),i=i+Math.imul(y,V)|0,n=(n=n+Math.imul(y,H)|0)+Math.imul(w,V)|0,o=o+Math.imul(w,H)|0,i=i+Math.imul(m,Z)|0,n=(n=n+Math.imul(m,K)|0)+Math.imul(p,Z)|0,o=o+Math.imul(p,K)|0;var vt=(u+(i=i+Math.imul(c,W)|0)|0)+((8191&(n=(n=n+Math.imul(c,Y)|0)+Math.imul(d,W)|0))<<13)|0;u=((o=o+Math.imul(d,Y)|0)+(n>>>13)|0)+(vt>>>26)|0,vt&=67108863,i=Math.imul(_,F),n=(n=Math.imul(_,U))+Math.imul(E,F)|0,o=Math.imul(E,U),i=i+Math.imul(b,V)|0,n=(n=n+Math.imul(b,H)|0)+Math.imul(k,V)|0,o=o+Math.imul(k,H)|0,i=i+Math.imul(y,Z)|0,n=(n=n+Math.imul(y,K)|0)+Math.imul(w,Z)|0,o=o+Math.imul(w,K)|0,i=i+Math.imul(m,W)|0,n=(n=n+Math.imul(m,Y)|0)+Math.imul(p,W)|0,o=o+Math.imul(p,Y)|0;var bt=(u+(i=i+Math.imul(c,X)|0)|0)+((8191&(n=(n=n+Math.imul(c,tt)|0)+Math.imul(d,X)|0))<<13)|0;u=((o=o+Math.imul(d,tt)|0)+(n>>>13)|0)+(bt>>>26)|0,bt&=67108863,i=Math.imul(j,F),n=(n=Math.imul(j,U))+Math.imul(x,F)|0,o=Math.imul(x,U),i=i+Math.imul(_,V)|0,n=(n=n+Math.imul(_,H)|0)+Math.imul(E,V)|0,o=o+Math.imul(E,H)|0,i=i+Math.imul(b,Z)|0,n=(n=n+Math.imul(b,K)|0)+Math.imul(k,Z)|0,o=o+Math.imul(k,K)|0,i=i+Math.imul(y,W)|0,n=(n=n+Math.imul(y,Y)|0)+Math.imul(w,W)|0,o=o+Math.imul(w,Y)|0,i=i+Math.imul(m,X)|0,n=(n=n+Math.imul(m,tt)|0)+Math.imul(p,X)|0,o=o+Math.imul(p,tt)|0;var kt=(u+(i=i+Math.imul(c,rt)|0)|0)+((8191&(n=(n=n+Math.imul(c,it)|0)+Math.imul(d,rt)|0))<<13)|0;u=((o=o+Math.imul(d,it)|0)+(n>>>13)|0)+(kt>>>26)|0,kt&=67108863,i=Math.imul(N,F),n=(n=Math.imul(N,U))+Math.imul(I,F)|0,o=Math.imul(I,U),i=i+Math.imul(j,V)|0,n=(n=n+Math.imul(j,H)|0)+Math.imul(x,V)|0,o=o+Math.imul(x,H)|0,i=i+Math.imul(_,Z)|0,n=(n=n+Math.imul(_,K)|0)+Math.imul(E,Z)|0,o=o+Math.imul(E,K)|0,i=i+Math.imul(b,W)|0,n=(n=n+Math.imul(b,Y)|0)+Math.imul(k,W)|0,o=o+Math.imul(k,Y)|0,i=i+Math.imul(y,X)|0,n=(n=n+Math.imul(y,tt)|0)+Math.imul(w,X)|0,o=o+Math.imul(w,tt)|0,i=i+Math.imul(m,rt)|0,n=(n=n+Math.imul(m,it)|0)+Math.imul(p,rt)|0,o=o+Math.imul(p,it)|0;var Mt=(u+(i=i+Math.imul(c,ot)|0)|0)+((8191&(n=(n=n+Math.imul(c,at)|0)+Math.imul(d,ot)|0))<<13)|0;u=((o=o+Math.imul(d,at)|0)+(n>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,i=Math.imul(C,F),n=(n=Math.imul(C,U))+Math.imul(z,F)|0,o=Math.imul(z,U),i=i+Math.imul(N,V)|0,n=(n=n+Math.imul(N,H)|0)+Math.imul(I,V)|0,o=o+Math.imul(I,H)|0,i=i+Math.imul(j,Z)|0,n=(n=n+Math.imul(j,K)|0)+Math.imul(x,Z)|0,o=o+Math.imul(x,K)|0,i=i+Math.imul(_,W)|0,n=(n=n+Math.imul(_,Y)|0)+Math.imul(E,W)|0,o=o+Math.imul(E,Y)|0,i=i+Math.imul(b,X)|0,n=(n=n+Math.imul(b,tt)|0)+Math.imul(k,X)|0,o=o+Math.imul(k,tt)|0,i=i+Math.imul(y,rt)|0,n=(n=n+Math.imul(y,it)|0)+Math.imul(w,rt)|0,o=o+Math.imul(w,it)|0,i=i+Math.imul(m,ot)|0,n=(n=n+Math.imul(m,at)|0)+Math.imul(p,ot)|0,o=o+Math.imul(p,at)|0;var _t=(u+(i=i+Math.imul(c,ht)|0)|0)+((8191&(n=(n=n+Math.imul(c,ut)|0)+Math.imul(d,ht)|0))<<13)|0;u=((o=o+Math.imul(d,ut)|0)+(n>>>13)|0)+(_t>>>26)|0,_t&=67108863,i=Math.imul(R,F),n=(n=Math.imul(R,U))+Math.imul(P,F)|0,o=Math.imul(P,U),i=i+Math.imul(C,V)|0,n=(n=n+Math.imul(C,H)|0)+Math.imul(z,V)|0,o=o+Math.imul(z,H)|0,i=i+Math.imul(N,Z)|0,n=(n=n+Math.imul(N,K)|0)+Math.imul(I,Z)|0,o=o+Math.imul(I,K)|0,i=i+Math.imul(j,W)|0,n=(n=n+Math.imul(j,Y)|0)+Math.imul(x,W)|0,o=o+Math.imul(x,Y)|0,i=i+Math.imul(_,X)|0,n=(n=n+Math.imul(_,tt)|0)+Math.imul(E,X)|0,o=o+Math.imul(E,tt)|0,i=i+Math.imul(b,rt)|0,n=(n=n+Math.imul(b,it)|0)+Math.imul(k,rt)|0,o=o+Math.imul(k,it)|0,i=i+Math.imul(y,ot)|0,n=(n=n+Math.imul(y,at)|0)+Math.imul(w,ot)|0,o=o+Math.imul(w,at)|0,i=i+Math.imul(m,ht)|0,n=(n=n+Math.imul(m,ut)|0)+Math.imul(p,ht)|0,o=o+Math.imul(p,ut)|0;var Et=(u+(i=i+Math.imul(c,ct)|0)|0)+((8191&(n=(n=n+Math.imul(c,dt)|0)+Math.imul(d,ct)|0))<<13)|0;u=((o=o+Math.imul(d,dt)|0)+(n>>>13)|0)+(Et>>>26)|0,Et&=67108863,i=Math.imul(D,F),n=(n=Math.imul(D,U))+Math.imul($,F)|0,o=Math.imul($,U),i=i+Math.imul(R,V)|0,n=(n=n+Math.imul(R,H)|0)+Math.imul(P,V)|0,o=o+Math.imul(P,H)|0,i=i+Math.imul(C,Z)|0,n=(n=n+Math.imul(C,K)|0)+Math.imul(z,Z)|0,o=o+Math.imul(z,K)|0,i=i+Math.imul(N,W)|0,n=(n=n+Math.imul(N,Y)|0)+Math.imul(I,W)|0,o=o+Math.imul(I,Y)|0,i=i+Math.imul(j,X)|0,n=(n=n+Math.imul(j,tt)|0)+Math.imul(x,X)|0,o=o+Math.imul(x,tt)|0,i=i+Math.imul(_,rt)|0,n=(n=n+Math.imul(_,it)|0)+Math.imul(E,rt)|0,o=o+Math.imul(E,it)|0,i=i+Math.imul(b,ot)|0,n=(n=n+Math.imul(b,at)|0)+Math.imul(k,ot)|0,o=o+Math.imul(k,at)|0,i=i+Math.imul(y,ht)|0,n=(n=n+Math.imul(y,ut)|0)+Math.imul(w,ht)|0,o=o+Math.imul(w,ut)|0,i=i+Math.imul(m,ct)|0,n=(n=n+Math.imul(m,dt)|0)+Math.imul(p,ct)|0,o=o+Math.imul(p,dt)|0;var At=(u+(i=i+Math.imul(c,mt)|0)|0)+((8191&(n=(n=n+Math.imul(c,pt)|0)+Math.imul(d,mt)|0))<<13)|0;u=((o=o+Math.imul(d,pt)|0)+(n>>>13)|0)+(At>>>26)|0,At&=67108863,i=Math.imul(D,V),n=(n=Math.imul(D,H))+Math.imul($,V)|0,o=Math.imul($,H),i=i+Math.imul(R,Z)|0,n=(n=n+Math.imul(R,K)|0)+Math.imul(P,Z)|0,o=o+Math.imul(P,K)|0,i=i+Math.imul(C,W)|0,n=(n=n+Math.imul(C,Y)|0)+Math.imul(z,W)|0,o=o+Math.imul(z,Y)|0,i=i+Math.imul(N,X)|0,n=(n=n+Math.imul(N,tt)|0)+Math.imul(I,X)|0,o=o+Math.imul(I,tt)|0,i=i+Math.imul(j,rt)|0,n=(n=n+Math.imul(j,it)|0)+Math.imul(x,rt)|0,o=o+Math.imul(x,it)|0,i=i+Math.imul(_,ot)|0,n=(n=n+Math.imul(_,at)|0)+Math.imul(E,ot)|0,o=o+Math.imul(E,at)|0,i=i+Math.imul(b,ht)|0,n=(n=n+Math.imul(b,ut)|0)+Math.imul(k,ht)|0,o=o+Math.imul(k,ut)|0,i=i+Math.imul(y,ct)|0,n=(n=n+Math.imul(y,dt)|0)+Math.imul(w,ct)|0,o=o+Math.imul(w,dt)|0;var jt=(u+(i=i+Math.imul(m,mt)|0)|0)+((8191&(n=(n=n+Math.imul(m,pt)|0)+Math.imul(p,mt)|0))<<13)|0;u=((o=o+Math.imul(p,pt)|0)+(n>>>13)|0)+(jt>>>26)|0,jt&=67108863,i=Math.imul(D,Z),n=(n=Math.imul(D,K))+Math.imul($,Z)|0,o=Math.imul($,K),i=i+Math.imul(R,W)|0,n=(n=n+Math.imul(R,Y)|0)+Math.imul(P,W)|0,o=o+Math.imul(P,Y)|0,i=i+Math.imul(C,X)|0,n=(n=n+Math.imul(C,tt)|0)+Math.imul(z,X)|0,o=o+Math.imul(z,tt)|0,i=i+Math.imul(N,rt)|0,n=(n=n+Math.imul(N,it)|0)+Math.imul(I,rt)|0,o=o+Math.imul(I,it)|0,i=i+Math.imul(j,ot)|0,n=(n=n+Math.imul(j,at)|0)+Math.imul(x,ot)|0,o=o+Math.imul(x,at)|0,i=i+Math.imul(_,ht)|0,n=(n=n+Math.imul(_,ut)|0)+Math.imul(E,ht)|0,o=o+Math.imul(E,ut)|0,i=i+Math.imul(b,ct)|0,n=(n=n+Math.imul(b,dt)|0)+Math.imul(k,ct)|0,o=o+Math.imul(k,dt)|0;var xt=(u+(i=i+Math.imul(y,mt)|0)|0)+((8191&(n=(n=n+Math.imul(y,pt)|0)+Math.imul(w,mt)|0))<<13)|0;u=((o=o+Math.imul(w,pt)|0)+(n>>>13)|0)+(xt>>>26)|0,xt&=67108863,i=Math.imul(D,W),n=(n=Math.imul(D,Y))+Math.imul($,W)|0,o=Math.imul($,Y),i=i+Math.imul(R,X)|0,n=(n=n+Math.imul(R,tt)|0)+Math.imul(P,X)|0,o=o+Math.imul(P,tt)|0,i=i+Math.imul(C,rt)|0,n=(n=n+Math.imul(C,it)|0)+Math.imul(z,rt)|0,o=o+Math.imul(z,it)|0,i=i+Math.imul(N,ot)|0,n=(n=n+Math.imul(N,at)|0)+Math.imul(I,ot)|0,o=o+Math.imul(I,at)|0,i=i+Math.imul(j,ht)|0,n=(n=n+Math.imul(j,ut)|0)+Math.imul(x,ht)|0,o=o+Math.imul(x,ut)|0,i=i+Math.imul(_,ct)|0,n=(n=n+Math.imul(_,dt)|0)+Math.imul(E,ct)|0,o=o+Math.imul(E,dt)|0;var St=(u+(i=i+Math.imul(b,mt)|0)|0)+((8191&(n=(n=n+Math.imul(b,pt)|0)+Math.imul(k,mt)|0))<<13)|0;u=((o=o+Math.imul(k,pt)|0)+(n>>>13)|0)+(St>>>26)|0,St&=67108863,i=Math.imul(D,X),n=(n=Math.imul(D,tt))+Math.imul($,X)|0,o=Math.imul($,tt),i=i+Math.imul(R,rt)|0,n=(n=n+Math.imul(R,it)|0)+Math.imul(P,rt)|0,o=o+Math.imul(P,it)|0,i=i+Math.imul(C,ot)|0,n=(n=n+Math.imul(C,at)|0)+Math.imul(z,ot)|0,o=o+Math.imul(z,at)|0,i=i+Math.imul(N,ht)|0,n=(n=n+Math.imul(N,ut)|0)+Math.imul(I,ht)|0,o=o+Math.imul(I,ut)|0,i=i+Math.imul(j,ct)|0,n=(n=n+Math.imul(j,dt)|0)+Math.imul(x,ct)|0,o=o+Math.imul(x,dt)|0;var Nt=(u+(i=i+Math.imul(_,mt)|0)|0)+((8191&(n=(n=n+Math.imul(_,pt)|0)+Math.imul(E,mt)|0))<<13)|0;u=((o=o+Math.imul(E,pt)|0)+(n>>>13)|0)+(Nt>>>26)|0,Nt&=67108863,i=Math.imul(D,rt),n=(n=Math.imul(D,it))+Math.imul($,rt)|0,o=Math.imul($,it),i=i+Math.imul(R,ot)|0,n=(n=n+Math.imul(R,at)|0)+Math.imul(P,ot)|0,o=o+Math.imul(P,at)|0,i=i+Math.imul(C,ht)|0,n=(n=n+Math.imul(C,ut)|0)+Math.imul(z,ht)|0,o=o+Math.imul(z,ut)|0,i=i+Math.imul(N,ct)|0,n=(n=n+Math.imul(N,dt)|0)+Math.imul(I,ct)|0,o=o+Math.imul(I,dt)|0;var It=(u+(i=i+Math.imul(j,mt)|0)|0)+((8191&(n=(n=n+Math.imul(j,pt)|0)+Math.imul(x,mt)|0))<<13)|0;u=((o=o+Math.imul(x,pt)|0)+(n>>>13)|0)+(It>>>26)|0,It&=67108863,i=Math.imul(D,ot),n=(n=Math.imul(D,at))+Math.imul($,ot)|0,o=Math.imul($,at),i=i+Math.imul(R,ht)|0,n=(n=n+Math.imul(R,ut)|0)+Math.imul(P,ht)|0,o=o+Math.imul(P,ut)|0,i=i+Math.imul(C,ct)|0,n=(n=n+Math.imul(C,dt)|0)+Math.imul(z,ct)|0,o=o+Math.imul(z,dt)|0;var Tt=(u+(i=i+Math.imul(N,mt)|0)|0)+((8191&(n=(n=n+Math.imul(N,pt)|0)+Math.imul(I,mt)|0))<<13)|0;u=((o=o+Math.imul(I,pt)|0)+(n>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,i=Math.imul(D,ht),n=(n=Math.imul(D,ut))+Math.imul($,ht)|0,o=Math.imul($,ut),i=i+Math.imul(R,ct)|0,n=(n=n+Math.imul(R,dt)|0)+Math.imul(P,ct)|0,o=o+Math.imul(P,dt)|0;var Ct=(u+(i=i+Math.imul(C,mt)|0)|0)+((8191&(n=(n=n+Math.imul(C,pt)|0)+Math.imul(z,mt)|0))<<13)|0;u=((o=o+Math.imul(z,pt)|0)+(n>>>13)|0)+(Ct>>>26)|0,Ct&=67108863,i=Math.imul(D,ct),n=(n=Math.imul(D,dt))+Math.imul($,ct)|0,o=Math.imul($,dt);var zt=(u+(i=i+Math.imul(R,mt)|0)|0)+((8191&(n=(n=n+Math.imul(R,pt)|0)+Math.imul(P,mt)|0))<<13)|0;u=((o=o+Math.imul(P,pt)|0)+(n>>>13)|0)+(zt>>>26)|0,zt&=67108863;var Ot=(u+(i=Math.imul(D,mt))|0)+((8191&(n=(n=Math.imul(D,pt))+Math.imul($,mt)|0))<<13)|0;return u=((o=Math.imul($,pt))+(n>>>13)|0)+(Ot>>>26)|0,Ot&=67108863,h[0]=gt,h[1]=yt,h[2]=wt,h[3]=vt,h[4]=bt,h[5]=kt,h[6]=Mt,h[7]=_t,h[8]=Et,h[9]=At,h[10]=jt,h[11]=xt,h[12]=St,h[13]=Nt,h[14]=It,h[15]=Tt,h[16]=Ct,h[17]=zt,h[18]=Ot,0!==u&&(h[19]=u,r.length++),r};function g(t,e,r){r.negative=e.negative^t.negative,r.length=t.length+e.length;for(var i=0,n=0,o=0;o<r.length-1;o++){var a=n;n=0;for(var s=67108863&i,h=Math.min(o,e.length-1),u=Math.max(0,o-t.length+1);u<=h;u++){var l=o-u,c=(0|t.words[l])*(0|e.words[u]),d=67108863&c;s=67108863&(d=d+s|0),n+=(a=(a=a+(c/67108864|0)|0)+(d>>>26)|0)>>>26,a&=67108863}r.words[o]=s,i=a,a=n}return 0!==i?r.words[o]=i:r.length--,r._strip()}function y(t,e,r){return g(t,e,r)}Math.imul||(p=m),n.prototype.mulTo=function(t,e){var r=this.length+t.length;return 10===this.length&&10===t.length?p(this,t,e):r<63?m(this,t,e):r<1024?g(this,t,e):y(this,t,e)},n.prototype.mul=function(t){var e=new n(null);return e.words=new Array(this.length+t.length),this.mulTo(t,e)},n.prototype.mulf=function(t){var e=new n(null);return e.words=new Array(this.length+t.length),y(this,t,e)},n.prototype.imul=function(t){return this.clone().mulTo(t,this)},n.prototype.imuln=function(t){var e=t<0;e&&(t=-t),r("number"==typeof t),r(t<67108864);for(var i=0,n=0;n<this.length;n++){var o=(0|this.words[n])*t,a=(67108863&o)+(67108863&i);i>>=26,i+=o/67108864|0,i+=a>>>26,this.words[n]=67108863&a}return 0!==i&&(this.words[n]=i,this.length++),e?this.ineg():this},n.prototype.muln=function(t){return this.clone().imuln(t)},n.prototype.sqr=function(){return this.mul(this)},n.prototype.isqr=function(){return this.imul(this.clone())},n.prototype.pow=function(t){var e=function(t){for(var e=new Array(t.bitLength()),r=0;r<e.length;r++){var i=r/26|0,n=r%26;e[r]=t.words[i]>>>n&1}return e}(t);if(0===e.length)return new n(1);for(var r=this,i=0;i<e.length&&0===e[i];i++,r=r.sqr());if(++i<e.length)for(var o=r.sqr();i<e.length;i++,o=o.sqr())0!==e[i]&&(r=r.mul(o));return r},n.prototype.iushln=function(t){r("number"==typeof t&&t>=0);var e,i=t%26,n=(t-i)/26,o=67108863>>>26-i<<26-i;if(0!==i){var a=0;for(e=0;e<this.length;e++){var s=this.words[e]&o,h=(0|this.words[e])-s<<i;this.words[e]=h|a,a=s>>>26-i}a&&(this.words[e]=a,this.length++)}if(0!==n){for(e=this.length-1;e>=0;e--)this.words[e+n]=this.words[e];for(e=0;e<n;e++)this.words[e]=0;this.length+=n}return this._strip()},n.prototype.ishln=function(t){return r(0===this.negative),this.iushln(t)},n.prototype.iushrn=function(t,e,i){var n;r("number"==typeof t&&t>=0),n=e?(e-e%26)/26:0;var o=t%26,a=Math.min((t-o)/26,this.length),s=67108863^67108863>>>o<<o,h=i;if(n-=a,n=Math.max(0,n),h){for(var u=0;u<a;u++)h.words[u]=this.words[u];h.length=a}if(0===a);else if(this.length>a)for(this.length-=a,u=0;u<this.length;u++)this.words[u]=this.words[u+a];else this.words[0]=0,this.length=1;var l=0;for(u=this.length-1;u>=0&&(0!==l||u>=n);u--){var c=0|this.words[u];this.words[u]=l<<26-o|c>>>o,l=c&s}return h&&0!==l&&(h.words[h.length++]=l),0===this.length&&(this.words[0]=0,this.length=1),this._strip()},n.prototype.ishrn=function(t,e,i){return r(0===this.negative),this.iushrn(t,e,i)},n.prototype.shln=function(t){return this.clone().ishln(t)},n.prototype.ushln=function(t){return this.clone().iushln(t)},n.prototype.shrn=function(t){return this.clone().ishrn(t)},n.prototype.ushrn=function(t){return this.clone().iushrn(t)},n.prototype.testn=function(t){r("number"==typeof t&&t>=0);var e=t%26,i=(t-e)/26,n=1<<e;return!(this.length<=i)&&!!(this.words[i]&n)},n.prototype.imaskn=function(t){r("number"==typeof t&&t>=0);var e=t%26,i=(t-e)/26;if(r(0===this.negative,"imaskn works only with positive numbers"),this.length<=i)return this;if(0!==e&&i++,this.length=Math.min(i,this.length),0!==e){var n=67108863^67108863>>>e<<e;this.words[this.length-1]&=n}return this._strip()},n.prototype.maskn=function(t){return this.clone().imaskn(t)},n.prototype.iaddn=function(t){return r("number"==typeof t),r(t<67108864),t<0?this.isubn(-t):0!==this.negative?1===this.length&&(0|this.words[0])<=t?(this.words[0]=t-(0|this.words[0]),this.negative=0,this):(this.negative=0,this.isubn(t),this.negative=1,this):this._iaddn(t)},n.prototype._iaddn=function(t){this.words[0]+=t;for(var e=0;e<this.length&&this.words[e]>=67108864;e++)this.words[e]-=67108864,e===this.length-1?this.words[e+1]=1:this.words[e+1]++;return this.length=Math.max(this.length,e+1),this},n.prototype.isubn=function(t){if(r("number"==typeof t),r(t<67108864),t<0)return this.iaddn(-t);if(0!==this.negative)return this.negative=0,this.iaddn(t),this.negative=1,this;if(this.words[0]-=t,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var e=0;e<this.length&&this.words[e]<0;e++)this.words[e]+=67108864,this.words[e+1]-=1;return this._strip()},n.prototype.addn=function(t){return this.clone().iaddn(t)},n.prototype.subn=function(t){return this.clone().isubn(t)},n.prototype.iabs=function(){return this.negative=0,this},n.prototype.abs=function(){return this.clone().iabs()},n.prototype._ishlnsubmul=function(t,e,i){var n,o,a=t.length+i;this._expand(a);var s=0;for(n=0;n<t.length;n++){o=(0|this.words[n+i])+s;var h=(0|t.words[n])*e;s=((o-=67108863&h)>>26)-(h/67108864|0),this.words[n+i]=67108863&o}for(;n<this.length-i;n++)s=(o=(0|this.words[n+i])+s)>>26,this.words[n+i]=67108863&o;if(0===s)return this._strip();for(r(-1===s),s=0,n=0;n<this.length;n++)s=(o=-(0|this.words[n])+s)>>26,this.words[n]=67108863&o;return this.negative=1,this._strip()},n.prototype._wordDiv=function(t,e){var r=(this.length,t.length),i=this.clone(),o=t,a=0|o.words[o.length-1];0!==(r=26-this._countBits(a))&&(o=o.ushln(r),i.iushln(r),a=0|o.words[o.length-1]);var s,h=i.length-o.length;if("mod"!==e){(s=new n(null)).length=h+1,s.words=new Array(s.length);for(var u=0;u<s.length;u++)s.words[u]=0}var l=i.clone()._ishlnsubmul(o,1,h);0===l.negative&&(i=l,s&&(s.words[h]=1));for(var c=h-1;c>=0;c--){var d=67108864*(0|i.words[o.length+c])+(0|i.words[o.length+c-1]);for(d=Math.min(d/a|0,67108863),i._ishlnsubmul(o,d,c);0!==i.negative;)d--,i.negative=0,i._ishlnsubmul(o,1,c),i.isZero()||(i.negative^=1);s&&(s.words[c]=d)}return s&&s._strip(),i._strip(),"div"!==e&&0!==r&&i.iushrn(r),{div:s||null,mod:i}},n.prototype.divmod=function(t,e,i){return r(!t.isZero()),this.isZero()?{div:new n(0),mod:new n(0)}:0!==this.negative&&0===t.negative?(s=this.neg().divmod(t,e),"mod"!==e&&(o=s.div.neg()),"div"!==e&&(a=s.mod.neg(),i&&0!==a.negative&&a.iadd(t)),{div:o,mod:a}):0===this.negative&&0!==t.negative?(s=this.divmod(t.neg(),e),"mod"!==e&&(o=s.div.neg()),{div:o,mod:s.mod}):0!=(this.negative&t.negative)?(s=this.neg().divmod(t.neg(),e),"div"!==e&&(a=s.mod.neg(),i&&0!==a.negative&&a.isub(t)),{div:s.div,mod:a}):t.length>this.length||this.cmp(t)<0?{div:new n(0),mod:this}:1===t.length?"div"===e?{div:this.divn(t.words[0]),mod:null}:"mod"===e?{div:null,mod:new n(this.modrn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new n(this.modrn(t.words[0]))}:this._wordDiv(t,e);var o,a,s},n.prototype.div=function(t){return this.divmod(t,"div",!1).div},n.prototype.mod=function(t){return this.divmod(t,"mod",!1).mod},n.prototype.umod=function(t){return this.divmod(t,"mod",!0).mod},n.prototype.divRound=function(t){var e=this.divmod(t);if(e.mod.isZero())return e.div;var r=0!==e.div.negative?e.mod.isub(t):e.mod,i=t.ushrn(1),n=t.andln(1),o=r.cmp(i);return o<0||1===n&&0===o?e.div:0!==e.div.negative?e.div.isubn(1):e.div.iaddn(1)},n.prototype.modrn=function(t){var e=t<0;e&&(t=-t),r(t<=67108863);for(var i=(1<<26)%t,n=0,o=this.length-1;o>=0;o--)n=(i*n+(0|this.words[o]))%t;return e?-n:n},n.prototype.modn=function(t){return this.modrn(t)},n.prototype.idivn=function(t){var e=t<0;e&&(t=-t),r(t<=67108863);for(var i=0,n=this.length-1;n>=0;n--){var o=(0|this.words[n])+67108864*i;this.words[n]=o/t|0,i=o%t}return this._strip(),e?this.ineg():this},n.prototype.divn=function(t){return this.clone().idivn(t)},n.prototype.egcd=function(t){r(0===t.negative),r(!t.isZero());var e=this,i=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var o=new n(1),a=new n(0),s=new n(0),h=new n(1),u=0;e.isEven()&&i.isEven();)e.iushrn(1),i.iushrn(1),++u;for(var l=i.clone(),c=e.clone();!e.isZero();){for(var d=0,f=1;0==(e.words[0]&f)&&d<26;++d,f<<=1);if(d>0)for(e.iushrn(d);d-- >0;)(o.isOdd()||a.isOdd())&&(o.iadd(l),a.isub(c)),o.iushrn(1),a.iushrn(1);for(var m=0,p=1;0==(i.words[0]&p)&&m<26;++m,p<<=1);if(m>0)for(i.iushrn(m);m-- >0;)(s.isOdd()||h.isOdd())&&(s.iadd(l),h.isub(c)),s.iushrn(1),h.iushrn(1);e.cmp(i)>=0?(e.isub(i),o.isub(s),a.isub(h)):(i.isub(e),s.isub(o),h.isub(a))}return{a:s,b:h,gcd:i.iushln(u)}},n.prototype._invmp=function(t){r(0===t.negative),r(!t.isZero());var e=this,i=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var o,a=new n(1),s=new n(0),h=i.clone();e.cmpn(1)>0&&i.cmpn(1)>0;){for(var u=0,l=1;0==(e.words[0]&l)&&u<26;++u,l<<=1);if(u>0)for(e.iushrn(u);u-- >0;)a.isOdd()&&a.iadd(h),a.iushrn(1);for(var c=0,d=1;0==(i.words[0]&d)&&c<26;++c,d<<=1);if(c>0)for(i.iushrn(c);c-- >0;)s.isOdd()&&s.iadd(h),s.iushrn(1);e.cmp(i)>=0?(e.isub(i),a.isub(s)):(i.isub(e),s.isub(a))}return(o=0===e.cmpn(1)?a:s).cmpn(0)<0&&o.iadd(t),o},n.prototype.gcd=function(t){if(this.isZero())return t.abs();if(t.isZero())return this.abs();var e=this.clone(),r=t.clone();e.negative=0,r.negative=0;for(var i=0;e.isEven()&&r.isEven();i++)e.iushrn(1),r.iushrn(1);for(;;){for(;e.isEven();)e.iushrn(1);for(;r.isEven();)r.iushrn(1);var n=e.cmp(r);if(n<0){var o=e;e=r,r=o}else if(0===n||0===r.cmpn(1))break;e.isub(r)}return r.iushln(i)},n.prototype.invm=function(t){return this.egcd(t).a.umod(t)},n.prototype.isEven=function(){return 0==(1&this.words[0])},n.prototype.isOdd=function(){return 1==(1&this.words[0])},n.prototype.andln=function(t){return this.words[0]&t},n.prototype.bincn=function(t){r("number"==typeof t);var e=t%26,i=(t-e)/26,n=1<<e;if(this.length<=i)return this._expand(i+1),this.words[i]|=n,this;for(var o=n,a=i;0!==o&&a<this.length;a++){var s=0|this.words[a];o=(s+=o)>>>26,s&=67108863,this.words[a]=s}return 0!==o&&(this.words[a]=o,this.length++),this},n.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},n.prototype.cmpn=function(t){var e,i=t<0;if(0!==this.negative&&!i)return-1;if(0===this.negative&&i)return 1;if(this._strip(),this.length>1)e=1;else{i&&(t=-t),r(t<=67108863,"Number is too big");var n=0|this.words[0];e=n===t?0:n<t?-1:1}return 0!==this.negative?0|-e:e},n.prototype.cmp=function(t){if(0!==this.negative&&0===t.negative)return-1;if(0===this.negative&&0!==t.negative)return 1;var e=this.ucmp(t);return 0!==this.negative?0|-e:e},n.prototype.ucmp=function(t){if(this.length>t.length)return 1;if(this.length<t.length)return-1;for(var e=0,r=this.length-1;r>=0;r--){var i=0|this.words[r],n=0|t.words[r];if(i!==n){i<n?e=-1:i>n&&(e=1);break}}return e},n.prototype.gtn=function(t){return 1===this.cmpn(t)},n.prototype.gt=function(t){return 1===this.cmp(t)},n.prototype.gten=function(t){return this.cmpn(t)>=0},n.prototype.gte=function(t){return this.cmp(t)>=0},n.prototype.ltn=function(t){return-1===this.cmpn(t)},n.prototype.lt=function(t){return-1===this.cmp(t)},n.prototype.lten=function(t){return this.cmpn(t)<=0},n.prototype.lte=function(t){return this.cmp(t)<=0},n.prototype.eqn=function(t){return 0===this.cmpn(t)},n.prototype.eq=function(t){return 0===this.cmp(t)},n.red=function(t){return new E(t)},n.prototype.toRed=function(t){return r(!this.red,"Already a number in reduction context"),r(0===this.negative,"red works only with positives"),t.convertTo(this)._forceRed(t)},n.prototype.fromRed=function(){return r(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},n.prototype._forceRed=function(t){return this.red=t,this},n.prototype.forceRed=function(t){return r(!this.red,"Already a number in reduction context"),this._forceRed(t)},n.prototype.redAdd=function(t){return r(this.red,"redAdd works only with red numbers"),this.red.add(this,t)},n.prototype.redIAdd=function(t){return r(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,t)},n.prototype.redSub=function(t){return r(this.red,"redSub works only with red numbers"),this.red.sub(this,t)},n.prototype.redISub=function(t){return r(this.red,"redISub works only with red numbers"),this.red.isub(this,t)},n.prototype.redShl=function(t){return r(this.red,"redShl works only with red numbers"),this.red.shl(this,t)},n.prototype.redMul=function(t){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.mul(this,t)},n.prototype.redIMul=function(t){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.imul(this,t)},n.prototype.redSqr=function(){return r(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},n.prototype.redISqr=function(){return r(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},n.prototype.redSqrt=function(){return r(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},n.prototype.redInvm=function(){return r(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},n.prototype.redNeg=function(){return r(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},n.prototype.redPow=function(t){return r(this.red&&!t.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,t)};var w={k256:null,p224:null,p192:null,p25519:null};function v(t,e){this.name=t,this.p=new n(e,16),this.n=this.p.bitLength(),this.k=new n(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function b(){v.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function k(){v.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function M(){v.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function _(){v.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function E(t){if("string"==typeof t){var e=n._prime(t);this.m=e.p,this.prime=e}else r(t.gtn(1),"modulus must be greater than 1"),this.m=t,this.prime=null}function A(t){E.call(this,t),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new n(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)}v.prototype._tmp=function(){var t=new n(null);return t.words=new Array(Math.ceil(this.n/13)),t},v.prototype.ireduce=function(t){var e,r=t;do{this.split(r,this.tmp),e=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(e>this.n);var i=e<this.n?-1:r.ucmp(this.p);return 0===i?(r.words[0]=0,r.length=1):i>0?r.isub(this.p):void 0!==r.strip?r.strip():r._strip(),r},v.prototype.split=function(t,e){t.iushrn(this.n,0,e)},v.prototype.imulK=function(t){return t.imul(this.k)},i(b,v),b.prototype.split=function(t,e){for(var r=4194303,i=Math.min(t.length,9),n=0;n<i;n++)e.words[n]=t.words[n];if(e.length=i,t.length<=9)return t.words[0]=0,void(t.length=1);var o=t.words[9];for(e.words[e.length++]=o&r,n=10;n<t.length;n++){var a=0|t.words[n];t.words[n-10]=(a&r)<<4|o>>>22,o=a}o>>>=22,t.words[n-10]=o,0===o&&t.length>10?t.length-=10:t.length-=9},b.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var e=0,r=0;r<t.length;r++){var i=0|t.words[r];e+=977*i,t.words[r]=67108863&e,e=64*i+(e/67108864|0)}return 0===t.words[t.length-1]&&(t.length--,0===t.words[t.length-1]&&t.length--),t},i(k,v),i(M,v),i(_,v),_.prototype.imulK=function(t){for(var e=0,r=0;r<t.length;r++){var i=19*(0|t.words[r])+e,n=67108863&i;i>>>=26,t.words[r]=n,e=i}return 0!==e&&(t.words[t.length++]=e),t},n._prime=function(t){if(w[t])return w[t];var e;if("k256"===t)e=new b;else if("p224"===t)e=new k;else if("p192"===t)e=new M;else{if("p25519"!==t)throw new Error("Unknown prime "+t);e=new _}return w[t]=e,e},E.prototype._verify1=function(t){r(0===t.negative,"red works only with positives"),r(t.red,"red works only with red numbers")},E.prototype._verify2=function(t,e){r(0==(t.negative|e.negative),"red works only with positives"),r(t.red&&t.red===e.red,"red works only with red numbers")},E.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):(u(t,t.umod(this.m)._forceRed(this)),t)},E.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},E.prototype.add=function(t,e){this._verify2(t,e);var r=t.add(e);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},E.prototype.iadd=function(t,e){this._verify2(t,e);var r=t.iadd(e);return r.cmp(this.m)>=0&&r.isub(this.m),r},E.prototype.sub=function(t,e){this._verify2(t,e);var r=t.sub(e);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},E.prototype.isub=function(t,e){this._verify2(t,e);var r=t.isub(e);return r.cmpn(0)<0&&r.iadd(this.m),r},E.prototype.shl=function(t,e){return this._verify1(t),this.imod(t.ushln(e))},E.prototype.imul=function(t,e){return this._verify2(t,e),this.imod(t.imul(e))},E.prototype.mul=function(t,e){return this._verify2(t,e),this.imod(t.mul(e))},E.prototype.isqr=function(t){return this.imul(t,t.clone())},E.prototype.sqr=function(t){return this.mul(t,t)},E.prototype.sqrt=function(t){if(t.isZero())return t.clone();var e=this.m.andln(3);if(r(e%2==1),3===e){var i=this.m.add(new n(1)).iushrn(2);return this.pow(t,i)}for(var o=this.m.subn(1),a=0;!o.isZero()&&0===o.andln(1);)a++,o.iushrn(1);r(!o.isZero());var s=new n(1).toRed(this),h=s.redNeg(),u=this.m.subn(1).iushrn(1),l=this.m.bitLength();for(l=new n(2*l*l).toRed(this);0!==this.pow(l,u).cmp(h);)l.redIAdd(h);for(var c=this.pow(l,o),d=this.pow(t,o.addn(1).iushrn(1)),f=this.pow(t,o),m=a;0!==f.cmp(s);){for(var p=f,g=0;0!==p.cmp(s);g++)p=p.redSqr();r(g<m);var y=this.pow(c,new n(1).iushln(m-g-1));d=d.redMul(y),c=y.redSqr(),f=f.redMul(c),m=g}return d},E.prototype.invm=function(t){var e=t._invmp(this.m);return 0!==e.negative?(e.negative=0,this.imod(e).redNeg()):this.imod(e)},E.prototype.pow=function(t,e){if(e.isZero())return new n(1).toRed(this);if(0===e.cmpn(1))return t.clone();var r=new Array(16);r[0]=new n(1).toRed(this),r[1]=t;for(var i=2;i<r.length;i++)r[i]=this.mul(r[i-1],t);var o=r[0],a=0,s=0,h=e.bitLength()%26;for(0===h&&(h=26),i=e.length-1;i>=0;i--){for(var u=e.words[i],l=h-1;l>=0;l--){var c=u>>l&1;o!==r[0]&&(o=this.sqr(o)),0!==c||0!==a?(a<<=1,a|=c,(4===++s||0===i&&0===l)&&(o=this.mul(o,r[a]),s=0,a=0)):s=0}h=26}return o},E.prototype.convertTo=function(t){var e=t.umod(this.m);return e===t?e.clone():e},E.prototype.convertFrom=function(t){var e=t.clone();return e.red=null,e},n.mont=function(t){return new A(t)},i(A,E),A.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},A.prototype.convertFrom=function(t){var e=this.imod(t.mul(this.rinv));return e.red=null,e},A.prototype.imul=function(t,e){if(t.isZero()||e.isZero())return t.words[0]=0,t.length=1,t;var r=t.imul(e),i=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),n=r.isub(i).iushrn(this.shift),o=n;return n.cmp(this.m)>=0?o=n.isub(this.m):n.cmpn(0)<0&&(o=n.iadd(this.m)),o._forceRed(this)},A.prototype.mul=function(t,e){if(t.isZero()||e.isZero())return new n(0)._forceRed(this);var r=t.mul(e),i=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),o=r.isub(i).iushrn(this.shift),a=o;return o.cmp(this.m)>=0?a=o.isub(this.m):o.cmpn(0)<0&&(a=o.iadd(this.m)),a._forceRed(this)},A.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}(t,i)}));var vn=wn.BN;const bn=new w("bignumber/5.6.2"),kn={},Mn=9007199254740991;let _n=!1;class En{constructor(t,e){t!==kn&&bn.throwError("cannot call constructor directly; use BigNumber.from",w.errors.UNSUPPORTED_OPERATION,{operation:"new (BigNumber)"}),this._hex=e,this._isBigNumber=!0,Object.freeze(this)}fromTwos(t){return jn(xn(this).fromTwos(t))}toTwos(t){return jn(xn(this).toTwos(t))}abs(){return"-"===this._hex[0]?En.from(this._hex.substring(1)):this}add(t){return jn(xn(this).add(xn(t)))}sub(t){return jn(xn(this).sub(xn(t)))}div(t){return En.from(t).isZero()&&Sn("division-by-zero","div"),jn(xn(this).div(xn(t)))}mul(t){return jn(xn(this).mul(xn(t)))}mod(t){const e=xn(t);return e.isNeg()&&Sn("division-by-zero","mod"),jn(xn(this).umod(e))}pow(t){const e=xn(t);return e.isNeg()&&Sn("negative-power","pow"),jn(xn(this).pow(e))}and(t){const e=xn(t);return(this.isNegative()||e.isNeg())&&Sn("unbound-bitwise-result","and"),jn(xn(this).and(e))}or(t){const e=xn(t);return(this.isNegative()||e.isNeg())&&Sn("unbound-bitwise-result","or"),jn(xn(this).or(e))}xor(t){const e=xn(t);return(this.isNegative()||e.isNeg())&&Sn("unbound-bitwise-result","xor"),jn(xn(this).xor(e))}mask(t){return(this.isNegative()||t<0)&&Sn("negative-width","mask"),jn(xn(this).maskn(t))}shl(t){return(this.isNegative()||t<0)&&Sn("negative-width","shl"),jn(xn(this).shln(t))}shr(t){return(this.isNegative()||t<0)&&Sn("negative-width","shr"),jn(xn(this).shrn(t))}eq(t){return xn(this).eq(xn(t))}lt(t){return xn(this).lt(xn(t))}lte(t){return xn(this).lte(xn(t))}gt(t){return xn(this).gt(xn(t))}gte(t){return xn(this).gte(xn(t))}isNegative(){return"-"===this._hex[0]}isZero(){return xn(this).isZero()}toNumber(){try{return xn(this).toNumber()}catch(t){Sn("overflow","toNumber",this.toString())}return null}toBigInt(){try{return BigInt(this.toString())}catch(t){}return bn.throwError("this platform does not support BigInt",w.errors.UNSUPPORTED_OPERATION,{value:this.toString()})}toString(){return arguments.length>0&&(10===arguments[0]?_n||(_n=!0,bn.warn("BigNumber.toString does not accept any parameters; base-10 is assumed")):16===arguments[0]?bn.throwError("BigNumber.toString does not accept any parameters; use bigNumber.toHexString()",w.errors.UNEXPECTED_ARGUMENT,{}):bn.throwError("BigNumber.toString does not accept parameters",w.errors.UNEXPECTED_ARGUMENT,{})),xn(this).toString(10)}toHexString(){return this._hex}toJSON(t){return{type:"BigNumber",hex:this.toHexString()}}static from(t){if(t instanceof En)return t;if("string"==typeof t)return t.match(/^-?0x[0-9a-f]+$/i)?new En(kn,An(t)):t.match(/^-?[0-9]+$/)?new En(kn,An(new vn(t))):bn.throwArgumentError("invalid BigNumber string","value",t);if("number"==typeof t)return t%1&&Sn("underflow","BigNumber.from",t),(t>=Mn||t<=-Mn)&&Sn("overflow","BigNumber.from",t),En.from(String(t));const e=t;if("bigint"==typeof e)return En.from(e.toString());if(E(e))return En.from(I(e));if(e)if(e.toHexString){const t=e.toHexString();if("string"==typeof t)return En.from(t)}else{let t=e._hex;if(null==t&&"BigNumber"===e.type&&(t=e.hex),"string"==typeof t&&(S(t)||"-"===t[0]&&S(t.substring(1))))return En.from(t)}return bn.throwArgumentError("invalid BigNumber value","value",t)}static isBigNumber(t){return!(!t||!t._isBigNumber)}}function An(t){if("string"!=typeof t)return An(t.toString(16));if("-"===t[0])return"-"===(t=t.substring(1))[0]&&bn.throwArgumentError("invalid hex","value",t),"0x00"===(t=An(t))?t:"-"+t;if("0x"!==t.substring(0,2)&&(t="0x"+t),"0x"===t)return"0x00";for(t.length%2&&(t="0x0"+t.substring(2));t.length>4&&"0x00"===t.substring(0,4);)t="0x"+t.substring(4);return t}function jn(t){return En.from(An(t))}function xn(t){const e=En.from(t).toHexString();return"-"===e[0]?new vn("-"+e.substring(3),16):new vn(e.substring(2),16)}function Sn(t,e,r){const i={fault:t,operation:e};return null!=r&&(i.value=r),bn.throwError(t,w.errors.NUMERIC_FAULT,i)}var Nn=a((function(t){!function(t,e){function r(t,e){if(!t)throw new Error(e||"Assertion failed")}function i(t,e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}function n(t,e,r){if(n.isBN(t))return t;this.negative=0,this.words=null,this.length=0,this.red=null,null!==t&&("le"!==e&&"be"!==e||(r=e,e=10),this._init(t||0,e||10,r||"be"))}var o;"object"==typeof t?t.exports=n:e.BN=n,n.BN=n,n.wordSize=26;try{o="undefined"!=typeof window&&void 0!==window.Buffer?window.Buffer:Pt.Buffer}catch(t){}function a(t,e){var i=t.charCodeAt(e);return i>=48&&i<=57?i-48:i>=65&&i<=70?i-55:i>=97&&i<=102?i-87:void r(!1,"Invalid character in "+t)}function s(t,e,r){var i=a(t,r);return r-1>=e&&(i|=a(t,r-1)<<4),i}function h(t,e,i,n){for(var o=0,a=0,s=Math.min(t.length,i),h=e;h<s;h++){var u=t.charCodeAt(h)-48;o*=n,a=u>=49?u-49+10:u>=17?u-17+10:u,r(u>=0&&a<n,"Invalid character"),o+=a}return o}function u(t,e){t.words=e.words,t.length=e.length,t.negative=e.negative,t.red=e.red}if(n.isBN=function(t){return t instanceof n||null!==t&&"object"==typeof t&&t.constructor.wordSize===n.wordSize&&Array.isArray(t.words)},n.max=function(t,e){return t.cmp(e)>0?t:e},n.min=function(t,e){return t.cmp(e)<0?t:e},n.prototype._init=function(t,e,i){if("number"==typeof t)return this._initNumber(t,e,i);if("object"==typeof t)return this._initArray(t,e,i);"hex"===e&&(e=16),r(e===(0|e)&&e>=2&&e<=36);var n=0;"-"===(t=t.toString().replace(/\s+/g,""))[0]&&(n++,this.negative=1),n<t.length&&(16===e?this._parseHex(t,n,i):(this._parseBase(t,e,n),"le"===i&&this._initArray(this.toArray(),e,i)))},n.prototype._initNumber=function(t,e,i){t<0&&(this.negative=1,t=-t),t<67108864?(this.words=[67108863&t],this.length=1):t<4503599627370496?(this.words=[67108863&t,t/67108864&67108863],this.length=2):(r(t<9007199254740992),this.words=[67108863&t,t/67108864&67108863,1],this.length=3),"le"===i&&this._initArray(this.toArray(),e,i)},n.prototype._initArray=function(t,e,i){if(r("number"==typeof t.length),t.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(t.length/3),this.words=new Array(this.length);for(var n=0;n<this.length;n++)this.words[n]=0;var o,a,s=0;if("be"===i)for(n=t.length-1,o=0;n>=0;n-=3)a=t[n]|t[n-1]<<8|t[n-2]<<16,this.words[o]|=a<<s&67108863,this.words[o+1]=a>>>26-s&67108863,(s+=24)>=26&&(s-=26,o++);else if("le"===i)for(n=0,o=0;n<t.length;n+=3)a=t[n]|t[n+1]<<8|t[n+2]<<16,this.words[o]|=a<<s&67108863,this.words[o+1]=a>>>26-s&67108863,(s+=24)>=26&&(s-=26,o++);return this._strip()},n.prototype._parseHex=function(t,e,r){this.length=Math.ceil((t.length-e)/6),this.words=new Array(this.length);for(var i=0;i<this.length;i++)this.words[i]=0;var n,o=0,a=0;if("be"===r)for(i=t.length-1;i>=e;i-=2)n=s(t,e,i)<<o,this.words[a]|=67108863&n,o>=18?(o-=18,a+=1,this.words[a]|=n>>>26):o+=8;else for(i=(t.length-e)%2==0?e+1:e;i<t.length;i+=2)n=s(t,e,i)<<o,this.words[a]|=67108863&n,o>=18?(o-=18,a+=1,this.words[a]|=n>>>26):o+=8;this._strip()},n.prototype._parseBase=function(t,e,r){this.words=[0],this.length=1;for(var i=0,n=1;n<=67108863;n*=e)i++;i--,n=n/e|0;for(var o=t.length-r,a=o%i,s=Math.min(o,o-a)+r,u=0,l=r;l<s;l+=i)u=h(t,l,l+i,e),this.imuln(n),this.words[0]+u<67108864?this.words[0]+=u:this._iaddn(u);if(0!==a){var c=1;for(u=h(t,l,t.length,e),l=0;l<a;l++)c*=e;this.imuln(c),this.words[0]+u<67108864?this.words[0]+=u:this._iaddn(u)}this._strip()},n.prototype.copy=function(t){t.words=new Array(this.length);for(var e=0;e<this.length;e++)t.words[e]=this.words[e];t.length=this.length,t.negative=this.negative,t.red=this.red},n.prototype._move=function(t){u(t,this)},n.prototype.clone=function(){var t=new n(null);return this.copy(t),t},n.prototype._expand=function(t){for(;this.length<t;)this.words[this.length++]=0;return this},n.prototype._strip=function(){for(;this.length>1&&0===this.words[this.length-1];)this.length--;return this._normSign()},n.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},"undefined"!=typeof Symbol&&"function"==typeof Symbol.for)try{n.prototype[Symbol.for("nodejs.util.inspect.custom")]=l}catch(t){n.prototype.inspect=l}else n.prototype.inspect=l;function l(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"}var c=["","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"],d=[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],f=[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];n.prototype.toString=function(t,e){var i;if(e=0|e||1,16===(t=t||10)||"hex"===t){i="";for(var n=0,o=0,a=0;a<this.length;a++){var s=this.words[a],h=(16777215&(s<<n|o)).toString(16);o=s>>>24-n&16777215,(n+=2)>=26&&(n-=26,a--),i=0!==o||a!==this.length-1?c[6-h.length]+h+i:h+i}for(0!==o&&(i=o.toString(16)+i);i.length%e!=0;)i="0"+i;return 0!==this.negative&&(i="-"+i),i}if(t===(0|t)&&t>=2&&t<=36){var u=d[t],l=f[t];i="";var m=this.clone();for(m.negative=0;!m.isZero();){var p=m.modrn(l).toString(t);i=(m=m.idivn(l)).isZero()?p+i:c[u-p.length]+p+i}for(this.isZero()&&(i="0"+i);i.length%e!=0;)i="0"+i;return 0!==this.negative&&(i="-"+i),i}r(!1,"Base should be between 2 and 36")},n.prototype.toNumber=function(){var t=this.words[0];return 2===this.length?t+=67108864*this.words[1]:3===this.length&&1===this.words[2]?t+=4503599627370496+67108864*this.words[1]:this.length>2&&r(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-t:t},n.prototype.toJSON=function(){return this.toString(16,2)},o&&(n.prototype.toBuffer=function(t,e){return this.toArrayLike(o,t,e)}),n.prototype.toArray=function(t,e){return this.toArrayLike(Array,t,e)};function m(t,e,r){r.negative=e.negative^t.negative;var i=t.length+e.length|0;r.length=i,i=i-1|0;var n=0|t.words[0],o=0|e.words[0],a=n*o,s=67108863&a,h=a/67108864|0;r.words[0]=s;for(var u=1;u<i;u++){for(var l=h>>>26,c=67108863&h,d=Math.min(u,e.length-1),f=Math.max(0,u-t.length+1);f<=d;f++){var m=u-f|0;l+=(a=(n=0|t.words[m])*(o=0|e.words[f])+c)/67108864|0,c=67108863&a}r.words[u]=0|c,h=0|l}return 0!==h?r.words[u]=0|h:r.length--,r._strip()}n.prototype.toArrayLike=function(t,e,i){this._strip();var n=this.byteLength(),o=i||Math.max(1,n);r(n<=o,"byte array longer than desired length"),r(o>0,"Requested array length <= 0");var a=function(t,e){return t.allocUnsafe?t.allocUnsafe(e):new t(e)}(t,o);return this["_toArrayLike"+("le"===e?"LE":"BE")](a,n),a},n.prototype._toArrayLikeLE=function(t,e){for(var r=0,i=0,n=0,o=0;n<this.length;n++){var a=this.words[n]<<o|i;t[r++]=255&a,r<t.length&&(t[r++]=a>>8&255),r<t.length&&(t[r++]=a>>16&255),6===o?(r<t.length&&(t[r++]=a>>24&255),i=0,o=0):(i=a>>>24,o+=2)}if(r<t.length)for(t[r++]=i;r<t.length;)t[r++]=0},n.prototype._toArrayLikeBE=function(t,e){for(var r=t.length-1,i=0,n=0,o=0;n<this.length;n++){var a=this.words[n]<<o|i;t[r--]=255&a,r>=0&&(t[r--]=a>>8&255),r>=0&&(t[r--]=a>>16&255),6===o?(r>=0&&(t[r--]=a>>24&255),i=0,o=0):(i=a>>>24,o+=2)}if(r>=0)for(t[r--]=i;r>=0;)t[r--]=0},Math.clz32?n.prototype._countBits=function(t){return 32-Math.clz32(t)}:n.prototype._countBits=function(t){var e=t,r=0;return e>=4096&&(r+=13,e>>>=13),e>=64&&(r+=7,e>>>=7),e>=8&&(r+=4,e>>>=4),e>=2&&(r+=2,e>>>=2),r+e},n.prototype._zeroBits=function(t){if(0===t)return 26;var e=t,r=0;return 0==(8191&e)&&(r+=13,e>>>=13),0==(127&e)&&(r+=7,e>>>=7),0==(15&e)&&(r+=4,e>>>=4),0==(3&e)&&(r+=2,e>>>=2),0==(1&e)&&r++,r},n.prototype.bitLength=function(){var t=this.words[this.length-1],e=this._countBits(t);return 26*(this.length-1)+e},n.prototype.zeroBits=function(){if(this.isZero())return 0;for(var t=0,e=0;e<this.length;e++){var r=this._zeroBits(this.words[e]);if(t+=r,26!==r)break}return t},n.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},n.prototype.toTwos=function(t){return 0!==this.negative?this.abs().inotn(t).iaddn(1):this.clone()},n.prototype.fromTwos=function(t){return this.testn(t-1)?this.notn(t).iaddn(1).ineg():this.clone()},n.prototype.isNeg=function(){return 0!==this.negative},n.prototype.neg=function(){return this.clone().ineg()},n.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},n.prototype.iuor=function(t){for(;this.length<t.length;)this.words[this.length++]=0;for(var e=0;e<t.length;e++)this.words[e]=this.words[e]|t.words[e];return this._strip()},n.prototype.ior=function(t){return r(0==(this.negative|t.negative)),this.iuor(t)},n.prototype.or=function(t){return this.length>t.length?this.clone().ior(t):t.clone().ior(this)},n.prototype.uor=function(t){return this.length>t.length?this.clone().iuor(t):t.clone().iuor(this)},n.prototype.iuand=function(t){var e;e=this.length>t.length?t:this;for(var r=0;r<e.length;r++)this.words[r]=this.words[r]&t.words[r];return this.length=e.length,this._strip()},n.prototype.iand=function(t){return r(0==(this.negative|t.negative)),this.iuand(t)},n.prototype.and=function(t){return this.length>t.length?this.clone().iand(t):t.clone().iand(this)},n.prototype.uand=function(t){return this.length>t.length?this.clone().iuand(t):t.clone().iuand(this)},n.prototype.iuxor=function(t){var e,r;this.length>t.length?(e=this,r=t):(e=t,r=this);for(var i=0;i<r.length;i++)this.words[i]=e.words[i]^r.words[i];if(this!==e)for(;i<e.length;i++)this.words[i]=e.words[i];return this.length=e.length,this._strip()},n.prototype.ixor=function(t){return r(0==(this.negative|t.negative)),this.iuxor(t)},n.prototype.xor=function(t){return this.length>t.length?this.clone().ixor(t):t.clone().ixor(this)},n.prototype.uxor=function(t){return this.length>t.length?this.clone().iuxor(t):t.clone().iuxor(this)},n.prototype.inotn=function(t){r("number"==typeof t&&t>=0);var e=0|Math.ceil(t/26),i=t%26;this._expand(e),i>0&&e--;for(var n=0;n<e;n++)this.words[n]=67108863&~this.words[n];return i>0&&(this.words[n]=~this.words[n]&67108863>>26-i),this._strip()},n.prototype.notn=function(t){return this.clone().inotn(t)},n.prototype.setn=function(t,e){r("number"==typeof t&&t>=0);var i=t/26|0,n=t%26;return this._expand(i+1),this.words[i]=e?this.words[i]|1<<n:this.words[i]&~(1<<n),this._strip()},n.prototype.iadd=function(t){var e,r,i;if(0!==this.negative&&0===t.negative)return this.negative=0,e=this.isub(t),this.negative^=1,this._normSign();if(0===this.negative&&0!==t.negative)return t.negative=0,e=this.isub(t),t.negative=1,e._normSign();this.length>t.length?(r=this,i=t):(r=t,i=this);for(var n=0,o=0;o<i.length;o++)e=(0|r.words[o])+(0|i.words[o])+n,this.words[o]=67108863&e,n=e>>>26;for(;0!==n&&o<r.length;o++)e=(0|r.words[o])+n,this.words[o]=67108863&e,n=e>>>26;if(this.length=r.length,0!==n)this.words[this.length]=n,this.length++;else if(r!==this)for(;o<r.length;o++)this.words[o]=r.words[o];return this},n.prototype.add=function(t){var e;return 0!==t.negative&&0===this.negative?(t.negative=0,e=this.sub(t),t.negative^=1,e):0===t.negative&&0!==this.negative?(this.negative=0,e=t.sub(this),this.negative=1,e):this.length>t.length?this.clone().iadd(t):t.clone().iadd(this)},n.prototype.isub=function(t){if(0!==t.negative){t.negative=0;var e=this.iadd(t);return t.negative=1,e._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(t),this.negative=1,this._normSign();var r,i,n=this.cmp(t);if(0===n)return this.negative=0,this.length=1,this.words[0]=0,this;n>0?(r=this,i=t):(r=t,i=this);for(var o=0,a=0;a<i.length;a++)o=(e=(0|r.words[a])-(0|i.words[a])+o)>>26,this.words[a]=67108863&e;for(;0!==o&&a<r.length;a++)o=(e=(0|r.words[a])+o)>>26,this.words[a]=67108863&e;if(0===o&&a<r.length&&r!==this)for(;a<r.length;a++)this.words[a]=r.words[a];return this.length=Math.max(this.length,a),r!==this&&(this.negative=1),this._strip()},n.prototype.sub=function(t){return this.clone().isub(t)};var p=function(t,e,r){var i,n,o,a=t.words,s=e.words,h=r.words,u=0,l=0|a[0],c=8191&l,d=l>>>13,f=0|a[1],m=8191&f,p=f>>>13,g=0|a[2],y=8191&g,w=g>>>13,v=0|a[3],b=8191&v,k=v>>>13,M=0|a[4],_=8191&M,E=M>>>13,A=0|a[5],j=8191&A,x=A>>>13,S=0|a[6],N=8191&S,I=S>>>13,T=0|a[7],C=8191&T,z=T>>>13,O=0|a[8],R=8191&O,P=O>>>13,B=0|a[9],D=8191&B,$=B>>>13,L=0|s[0],F=8191&L,U=L>>>13,q=0|s[1],V=8191&q,H=q>>>13,G=0|s[2],Z=8191&G,K=G>>>13,J=0|s[3],W=8191&J,Y=J>>>13,Q=0|s[4],X=8191&Q,tt=Q>>>13,et=0|s[5],rt=8191&et,it=et>>>13,nt=0|s[6],ot=8191&nt,at=nt>>>13,st=0|s[7],ht=8191&st,ut=st>>>13,lt=0|s[8],ct=8191&lt,dt=lt>>>13,ft=0|s[9],mt=8191&ft,pt=ft>>>13;r.negative=t.negative^e.negative,r.length=19;var gt=(u+(i=Math.imul(c,F))|0)+((8191&(n=(n=Math.imul(c,U))+Math.imul(d,F)|0))<<13)|0;u=((o=Math.imul(d,U))+(n>>>13)|0)+(gt>>>26)|0,gt&=67108863,i=Math.imul(m,F),n=(n=Math.imul(m,U))+Math.imul(p,F)|0,o=Math.imul(p,U);var yt=(u+(i=i+Math.imul(c,V)|0)|0)+((8191&(n=(n=n+Math.imul(c,H)|0)+Math.imul(d,V)|0))<<13)|0;u=((o=o+Math.imul(d,H)|0)+(n>>>13)|0)+(yt>>>26)|0,yt&=67108863,i=Math.imul(y,F),n=(n=Math.imul(y,U))+Math.imul(w,F)|0,o=Math.imul(w,U),i=i+Math.imul(m,V)|0,n=(n=n+Math.imul(m,H)|0)+Math.imul(p,V)|0,o=o+Math.imul(p,H)|0;var wt=(u+(i=i+Math.imul(c,Z)|0)|0)+((8191&(n=(n=n+Math.imul(c,K)|0)+Math.imul(d,Z)|0))<<13)|0;u=((o=o+Math.imul(d,K)|0)+(n>>>13)|0)+(wt>>>26)|0,wt&=67108863,i=Math.imul(b,F),n=(n=Math.imul(b,U))+Math.imul(k,F)|0,o=Math.imul(k,U),i=i+Math.imul(y,V)|0,n=(n=n+Math.imul(y,H)|0)+Math.imul(w,V)|0,o=o+Math.imul(w,H)|0,i=i+Math.imul(m,Z)|0,n=(n=n+Math.imul(m,K)|0)+Math.imul(p,Z)|0,o=o+Math.imul(p,K)|0;var vt=(u+(i=i+Math.imul(c,W)|0)|0)+((8191&(n=(n=n+Math.imul(c,Y)|0)+Math.imul(d,W)|0))<<13)|0;u=((o=o+Math.imul(d,Y)|0)+(n>>>13)|0)+(vt>>>26)|0,vt&=67108863,i=Math.imul(_,F),n=(n=Math.imul(_,U))+Math.imul(E,F)|0,o=Math.imul(E,U),i=i+Math.imul(b,V)|0,n=(n=n+Math.imul(b,H)|0)+Math.imul(k,V)|0,o=o+Math.imul(k,H)|0,i=i+Math.imul(y,Z)|0,n=(n=n+Math.imul(y,K)|0)+Math.imul(w,Z)|0,o=o+Math.imul(w,K)|0,i=i+Math.imul(m,W)|0,n=(n=n+Math.imul(m,Y)|0)+Math.imul(p,W)|0,o=o+Math.imul(p,Y)|0;var bt=(u+(i=i+Math.imul(c,X)|0)|0)+((8191&(n=(n=n+Math.imul(c,tt)|0)+Math.imul(d,X)|0))<<13)|0;u=((o=o+Math.imul(d,tt)|0)+(n>>>13)|0)+(bt>>>26)|0,bt&=67108863,i=Math.imul(j,F),n=(n=Math.imul(j,U))+Math.imul(x,F)|0,o=Math.imul(x,U),i=i+Math.imul(_,V)|0,n=(n=n+Math.imul(_,H)|0)+Math.imul(E,V)|0,o=o+Math.imul(E,H)|0,i=i+Math.imul(b,Z)|0,n=(n=n+Math.imul(b,K)|0)+Math.imul(k,Z)|0,o=o+Math.imul(k,K)|0,i=i+Math.imul(y,W)|0,n=(n=n+Math.imul(y,Y)|0)+Math.imul(w,W)|0,o=o+Math.imul(w,Y)|0,i=i+Math.imul(m,X)|0,n=(n=n+Math.imul(m,tt)|0)+Math.imul(p,X)|0,o=o+Math.imul(p,tt)|0;var kt=(u+(i=i+Math.imul(c,rt)|0)|0)+((8191&(n=(n=n+Math.imul(c,it)|0)+Math.imul(d,rt)|0))<<13)|0;u=((o=o+Math.imul(d,it)|0)+(n>>>13)|0)+(kt>>>26)|0,kt&=67108863,i=Math.imul(N,F),n=(n=Math.imul(N,U))+Math.imul(I,F)|0,o=Math.imul(I,U),i=i+Math.imul(j,V)|0,n=(n=n+Math.imul(j,H)|0)+Math.imul(x,V)|0,o=o+Math.imul(x,H)|0,i=i+Math.imul(_,Z)|0,n=(n=n+Math.imul(_,K)|0)+Math.imul(E,Z)|0,o=o+Math.imul(E,K)|0,i=i+Math.imul(b,W)|0,n=(n=n+Math.imul(b,Y)|0)+Math.imul(k,W)|0,o=o+Math.imul(k,Y)|0,i=i+Math.imul(y,X)|0,n=(n=n+Math.imul(y,tt)|0)+Math.imul(w,X)|0,o=o+Math.imul(w,tt)|0,i=i+Math.imul(m,rt)|0,n=(n=n+Math.imul(m,it)|0)+Math.imul(p,rt)|0,o=o+Math.imul(p,it)|0;var Mt=(u+(i=i+Math.imul(c,ot)|0)|0)+((8191&(n=(n=n+Math.imul(c,at)|0)+Math.imul(d,ot)|0))<<13)|0;u=((o=o+Math.imul(d,at)|0)+(n>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,i=Math.imul(C,F),n=(n=Math.imul(C,U))+Math.imul(z,F)|0,o=Math.imul(z,U),i=i+Math.imul(N,V)|0,n=(n=n+Math.imul(N,H)|0)+Math.imul(I,V)|0,o=o+Math.imul(I,H)|0,i=i+Math.imul(j,Z)|0,n=(n=n+Math.imul(j,K)|0)+Math.imul(x,Z)|0,o=o+Math.imul(x,K)|0,i=i+Math.imul(_,W)|0,n=(n=n+Math.imul(_,Y)|0)+Math.imul(E,W)|0,o=o+Math.imul(E,Y)|0,i=i+Math.imul(b,X)|0,n=(n=n+Math.imul(b,tt)|0)+Math.imul(k,X)|0,o=o+Math.imul(k,tt)|0,i=i+Math.imul(y,rt)|0,n=(n=n+Math.imul(y,it)|0)+Math.imul(w,rt)|0,o=o+Math.imul(w,it)|0,i=i+Math.imul(m,ot)|0,n=(n=n+Math.imul(m,at)|0)+Math.imul(p,ot)|0,o=o+Math.imul(p,at)|0;var _t=(u+(i=i+Math.imul(c,ht)|0)|0)+((8191&(n=(n=n+Math.imul(c,ut)|0)+Math.imul(d,ht)|0))<<13)|0;u=((o=o+Math.imul(d,ut)|0)+(n>>>13)|0)+(_t>>>26)|0,_t&=67108863,i=Math.imul(R,F),n=(n=Math.imul(R,U))+Math.imul(P,F)|0,o=Math.imul(P,U),i=i+Math.imul(C,V)|0,n=(n=n+Math.imul(C,H)|0)+Math.imul(z,V)|0,o=o+Math.imul(z,H)|0,i=i+Math.imul(N,Z)|0,n=(n=n+Math.imul(N,K)|0)+Math.imul(I,Z)|0,o=o+Math.imul(I,K)|0,i=i+Math.imul(j,W)|0,n=(n=n+Math.imul(j,Y)|0)+Math.imul(x,W)|0,o=o+Math.imul(x,Y)|0,i=i+Math.imul(_,X)|0,n=(n=n+Math.imul(_,tt)|0)+Math.imul(E,X)|0,o=o+Math.imul(E,tt)|0,i=i+Math.imul(b,rt)|0,n=(n=n+Math.imul(b,it)|0)+Math.imul(k,rt)|0,o=o+Math.imul(k,it)|0,i=i+Math.imul(y,ot)|0,n=(n=n+Math.imul(y,at)|0)+Math.imul(w,ot)|0,o=o+Math.imul(w,at)|0,i=i+Math.imul(m,ht)|0,n=(n=n+Math.imul(m,ut)|0)+Math.imul(p,ht)|0,o=o+Math.imul(p,ut)|0;var Et=(u+(i=i+Math.imul(c,ct)|0)|0)+((8191&(n=(n=n+Math.imul(c,dt)|0)+Math.imul(d,ct)|0))<<13)|0;u=((o=o+Math.imul(d,dt)|0)+(n>>>13)|0)+(Et>>>26)|0,Et&=67108863,i=Math.imul(D,F),n=(n=Math.imul(D,U))+Math.imul($,F)|0,o=Math.imul($,U),i=i+Math.imul(R,V)|0,n=(n=n+Math.imul(R,H)|0)+Math.imul(P,V)|0,o=o+Math.imul(P,H)|0,i=i+Math.imul(C,Z)|0,n=(n=n+Math.imul(C,K)|0)+Math.imul(z,Z)|0,o=o+Math.imul(z,K)|0,i=i+Math.imul(N,W)|0,n=(n=n+Math.imul(N,Y)|0)+Math.imul(I,W)|0,o=o+Math.imul(I,Y)|0,i=i+Math.imul(j,X)|0,n=(n=n+Math.imul(j,tt)|0)+Math.imul(x,X)|0,o=o+Math.imul(x,tt)|0,i=i+Math.imul(_,rt)|0,n=(n=n+Math.imul(_,it)|0)+Math.imul(E,rt)|0,o=o+Math.imul(E,it)|0,i=i+Math.imul(b,ot)|0,n=(n=n+Math.imul(b,at)|0)+Math.imul(k,ot)|0,o=o+Math.imul(k,at)|0,i=i+Math.imul(y,ht)|0,n=(n=n+Math.imul(y,ut)|0)+Math.imul(w,ht)|0,o=o+Math.imul(w,ut)|0,i=i+Math.imul(m,ct)|0,n=(n=n+Math.imul(m,dt)|0)+Math.imul(p,ct)|0,o=o+Math.imul(p,dt)|0;var At=(u+(i=i+Math.imul(c,mt)|0)|0)+((8191&(n=(n=n+Math.imul(c,pt)|0)+Math.imul(d,mt)|0))<<13)|0;u=((o=o+Math.imul(d,pt)|0)+(n>>>13)|0)+(At>>>26)|0,At&=67108863,i=Math.imul(D,V),n=(n=Math.imul(D,H))+Math.imul($,V)|0,o=Math.imul($,H),i=i+Math.imul(R,Z)|0,n=(n=n+Math.imul(R,K)|0)+Math.imul(P,Z)|0,o=o+Math.imul(P,K)|0,i=i+Math.imul(C,W)|0,n=(n=n+Math.imul(C,Y)|0)+Math.imul(z,W)|0,o=o+Math.imul(z,Y)|0,i=i+Math.imul(N,X)|0,n=(n=n+Math.imul(N,tt)|0)+Math.imul(I,X)|0,o=o+Math.imul(I,tt)|0,i=i+Math.imul(j,rt)|0,n=(n=n+Math.imul(j,it)|0)+Math.imul(x,rt)|0,o=o+Math.imul(x,it)|0,i=i+Math.imul(_,ot)|0,n=(n=n+Math.imul(_,at)|0)+Math.imul(E,ot)|0,o=o+Math.imul(E,at)|0,i=i+Math.imul(b,ht)|0,n=(n=n+Math.imul(b,ut)|0)+Math.imul(k,ht)|0,o=o+Math.imul(k,ut)|0,i=i+Math.imul(y,ct)|0,n=(n=n+Math.imul(y,dt)|0)+Math.imul(w,ct)|0,o=o+Math.imul(w,dt)|0;var jt=(u+(i=i+Math.imul(m,mt)|0)|0)+((8191&(n=(n=n+Math.imul(m,pt)|0)+Math.imul(p,mt)|0))<<13)|0;u=((o=o+Math.imul(p,pt)|0)+(n>>>13)|0)+(jt>>>26)|0,jt&=67108863,i=Math.imul(D,Z),n=(n=Math.imul(D,K))+Math.imul($,Z)|0,o=Math.imul($,K),i=i+Math.imul(R,W)|0,n=(n=n+Math.imul(R,Y)|0)+Math.imul(P,W)|0,o=o+Math.imul(P,Y)|0,i=i+Math.imul(C,X)|0,n=(n=n+Math.imul(C,tt)|0)+Math.imul(z,X)|0,o=o+Math.imul(z,tt)|0,i=i+Math.imul(N,rt)|0,n=(n=n+Math.imul(N,it)|0)+Math.imul(I,rt)|0,o=o+Math.imul(I,it)|0,i=i+Math.imul(j,ot)|0,n=(n=n+Math.imul(j,at)|0)+Math.imul(x,ot)|0,o=o+Math.imul(x,at)|0,i=i+Math.imul(_,ht)|0,n=(n=n+Math.imul(_,ut)|0)+Math.imul(E,ht)|0,o=o+Math.imul(E,ut)|0,i=i+Math.imul(b,ct)|0,n=(n=n+Math.imul(b,dt)|0)+Math.imul(k,ct)|0,o=o+Math.imul(k,dt)|0;var xt=(u+(i=i+Math.imul(y,mt)|0)|0)+((8191&(n=(n=n+Math.imul(y,pt)|0)+Math.imul(w,mt)|0))<<13)|0;u=((o=o+Math.imul(w,pt)|0)+(n>>>13)|0)+(xt>>>26)|0,xt&=67108863,i=Math.imul(D,W),n=(n=Math.imul(D,Y))+Math.imul($,W)|0,o=Math.imul($,Y),i=i+Math.imul(R,X)|0,n=(n=n+Math.imul(R,tt)|0)+Math.imul(P,X)|0,o=o+Math.imul(P,tt)|0,i=i+Math.imul(C,rt)|0,n=(n=n+Math.imul(C,it)|0)+Math.imul(z,rt)|0,o=o+Math.imul(z,it)|0,i=i+Math.imul(N,ot)|0,n=(n=n+Math.imul(N,at)|0)+Math.imul(I,ot)|0,o=o+Math.imul(I,at)|0,i=i+Math.imul(j,ht)|0,n=(n=n+Math.imul(j,ut)|0)+Math.imul(x,ht)|0,o=o+Math.imul(x,ut)|0,i=i+Math.imul(_,ct)|0,n=(n=n+Math.imul(_,dt)|0)+Math.imul(E,ct)|0,o=o+Math.imul(E,dt)|0;var St=(u+(i=i+Math.imul(b,mt)|0)|0)+((8191&(n=(n=n+Math.imul(b,pt)|0)+Math.imul(k,mt)|0))<<13)|0;u=((o=o+Math.imul(k,pt)|0)+(n>>>13)|0)+(St>>>26)|0,St&=67108863,i=Math.imul(D,X),n=(n=Math.imul(D,tt))+Math.imul($,X)|0,o=Math.imul($,tt),i=i+Math.imul(R,rt)|0,n=(n=n+Math.imul(R,it)|0)+Math.imul(P,rt)|0,o=o+Math.imul(P,it)|0,i=i+Math.imul(C,ot)|0,n=(n=n+Math.imul(C,at)|0)+Math.imul(z,ot)|0,o=o+Math.imul(z,at)|0,i=i+Math.imul(N,ht)|0,n=(n=n+Math.imul(N,ut)|0)+Math.imul(I,ht)|0,o=o+Math.imul(I,ut)|0,i=i+Math.imul(j,ct)|0,n=(n=n+Math.imul(j,dt)|0)+Math.imul(x,ct)|0,o=o+Math.imul(x,dt)|0;var Nt=(u+(i=i+Math.imul(_,mt)|0)|0)+((8191&(n=(n=n+Math.imul(_,pt)|0)+Math.imul(E,mt)|0))<<13)|0;u=((o=o+Math.imul(E,pt)|0)+(n>>>13)|0)+(Nt>>>26)|0,Nt&=67108863,i=Math.imul(D,rt),n=(n=Math.imul(D,it))+Math.imul($,rt)|0,o=Math.imul($,it),i=i+Math.imul(R,ot)|0,n=(n=n+Math.imul(R,at)|0)+Math.imul(P,ot)|0,o=o+Math.imul(P,at)|0,i=i+Math.imul(C,ht)|0,n=(n=n+Math.imul(C,ut)|0)+Math.imul(z,ht)|0,o=o+Math.imul(z,ut)|0,i=i+Math.imul(N,ct)|0,n=(n=n+Math.imul(N,dt)|0)+Math.imul(I,ct)|0,o=o+Math.imul(I,dt)|0;var It=(u+(i=i+Math.imul(j,mt)|0)|0)+((8191&(n=(n=n+Math.imul(j,pt)|0)+Math.imul(x,mt)|0))<<13)|0;u=((o=o+Math.imul(x,pt)|0)+(n>>>13)|0)+(It>>>26)|0,It&=67108863,i=Math.imul(D,ot),n=(n=Math.imul(D,at))+Math.imul($,ot)|0,o=Math.imul($,at),i=i+Math.imul(R,ht)|0,n=(n=n+Math.imul(R,ut)|0)+Math.imul(P,ht)|0,o=o+Math.imul(P,ut)|0,i=i+Math.imul(C,ct)|0,n=(n=n+Math.imul(C,dt)|0)+Math.imul(z,ct)|0,o=o+Math.imul(z,dt)|0;var Tt=(u+(i=i+Math.imul(N,mt)|0)|0)+((8191&(n=(n=n+Math.imul(N,pt)|0)+Math.imul(I,mt)|0))<<13)|0;u=((o=o+Math.imul(I,pt)|0)+(n>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,i=Math.imul(D,ht),n=(n=Math.imul(D,ut))+Math.imul($,ht)|0,o=Math.imul($,ut),i=i+Math.imul(R,ct)|0,n=(n=n+Math.imul(R,dt)|0)+Math.imul(P,ct)|0,o=o+Math.imul(P,dt)|0;var Ct=(u+(i=i+Math.imul(C,mt)|0)|0)+((8191&(n=(n=n+Math.imul(C,pt)|0)+Math.imul(z,mt)|0))<<13)|0;u=((o=o+Math.imul(z,pt)|0)+(n>>>13)|0)+(Ct>>>26)|0,Ct&=67108863,i=Math.imul(D,ct),n=(n=Math.imul(D,dt))+Math.imul($,ct)|0,o=Math.imul($,dt);var zt=(u+(i=i+Math.imul(R,mt)|0)|0)+((8191&(n=(n=n+Math.imul(R,pt)|0)+Math.imul(P,mt)|0))<<13)|0;u=((o=o+Math.imul(P,pt)|0)+(n>>>13)|0)+(zt>>>26)|0,zt&=67108863;var Ot=(u+(i=Math.imul(D,mt))|0)+((8191&(n=(n=Math.imul(D,pt))+Math.imul($,mt)|0))<<13)|0;return u=((o=Math.imul($,pt))+(n>>>13)|0)+(Ot>>>26)|0,Ot&=67108863,h[0]=gt,h[1]=yt,h[2]=wt,h[3]=vt,h[4]=bt,h[5]=kt,h[6]=Mt,h[7]=_t,h[8]=Et,h[9]=At,h[10]=jt,h[11]=xt,h[12]=St,h[13]=Nt,h[14]=It,h[15]=Tt,h[16]=Ct,h[17]=zt,h[18]=Ot,0!==u&&(h[19]=u,r.length++),r};function g(t,e,r){r.negative=e.negative^t.negative,r.length=t.length+e.length;for(var i=0,n=0,o=0;o<r.length-1;o++){var a=n;n=0;for(var s=67108863&i,h=Math.min(o,e.length-1),u=Math.max(0,o-t.length+1);u<=h;u++){var l=o-u,c=(0|t.words[l])*(0|e.words[u]),d=67108863&c;s=67108863&(d=d+s|0),n+=(a=(a=a+(c/67108864|0)|0)+(d>>>26)|0)>>>26,a&=67108863}r.words[o]=s,i=a,a=n}return 0!==i?r.words[o]=i:r.length--,r._strip()}function y(t,e,r){return g(t,e,r)}Math.imul||(p=m),n.prototype.mulTo=function(t,e){var r=this.length+t.length;return 10===this.length&&10===t.length?p(this,t,e):r<63?m(this,t,e):r<1024?g(this,t,e):y(this,t,e)},n.prototype.mul=function(t){var e=new n(null);return e.words=new Array(this.length+t.length),this.mulTo(t,e)},n.prototype.mulf=function(t){var e=new n(null);return e.words=new Array(this.length+t.length),y(this,t,e)},n.prototype.imul=function(t){return this.clone().mulTo(t,this)},n.prototype.imuln=function(t){var e=t<0;e&&(t=-t),r("number"==typeof t),r(t<67108864);for(var i=0,n=0;n<this.length;n++){var o=(0|this.words[n])*t,a=(67108863&o)+(67108863&i);i>>=26,i+=o/67108864|0,i+=a>>>26,this.words[n]=67108863&a}return 0!==i&&(this.words[n]=i,this.length++),e?this.ineg():this},n.prototype.muln=function(t){return this.clone().imuln(t)},n.prototype.sqr=function(){return this.mul(this)},n.prototype.isqr=function(){return this.imul(this.clone())},n.prototype.pow=function(t){var e=function(t){for(var e=new Array(t.bitLength()),r=0;r<e.length;r++){var i=r/26|0,n=r%26;e[r]=t.words[i]>>>n&1}return e}(t);if(0===e.length)return new n(1);for(var r=this,i=0;i<e.length&&0===e[i];i++,r=r.sqr());if(++i<e.length)for(var o=r.sqr();i<e.length;i++,o=o.sqr())0!==e[i]&&(r=r.mul(o));return r},n.prototype.iushln=function(t){r("number"==typeof t&&t>=0);var e,i=t%26,n=(t-i)/26,o=67108863>>>26-i<<26-i;if(0!==i){var a=0;for(e=0;e<this.length;e++){var s=this.words[e]&o,h=(0|this.words[e])-s<<i;this.words[e]=h|a,a=s>>>26-i}a&&(this.words[e]=a,this.length++)}if(0!==n){for(e=this.length-1;e>=0;e--)this.words[e+n]=this.words[e];for(e=0;e<n;e++)this.words[e]=0;this.length+=n}return this._strip()},n.prototype.ishln=function(t){return r(0===this.negative),this.iushln(t)},n.prototype.iushrn=function(t,e,i){var n;r("number"==typeof t&&t>=0),n=e?(e-e%26)/26:0;var o=t%26,a=Math.min((t-o)/26,this.length),s=67108863^67108863>>>o<<o,h=i;if(n-=a,n=Math.max(0,n),h){for(var u=0;u<a;u++)h.words[u]=this.words[u];h.length=a}if(0===a);else if(this.length>a)for(this.length-=a,u=0;u<this.length;u++)this.words[u]=this.words[u+a];else this.words[0]=0,this.length=1;var l=0;for(u=this.length-1;u>=0&&(0!==l||u>=n);u--){var c=0|this.words[u];this.words[u]=l<<26-o|c>>>o,l=c&s}return h&&0!==l&&(h.words[h.length++]=l),0===this.length&&(this.words[0]=0,this.length=1),this._strip()},n.prototype.ishrn=function(t,e,i){return r(0===this.negative),this.iushrn(t,e,i)},n.prototype.shln=function(t){return this.clone().ishln(t)},n.prototype.ushln=function(t){return this.clone().iushln(t)},n.prototype.shrn=function(t){return this.clone().ishrn(t)},n.prototype.ushrn=function(t){return this.clone().iushrn(t)},n.prototype.testn=function(t){r("number"==typeof t&&t>=0);var e=t%26,i=(t-e)/26,n=1<<e;return!(this.length<=i)&&!!(this.words[i]&n)},n.prototype.imaskn=function(t){r("number"==typeof t&&t>=0);var e=t%26,i=(t-e)/26;if(r(0===this.negative,"imaskn works only with positive numbers"),this.length<=i)return this;if(0!==e&&i++,this.length=Math.min(i,this.length),0!==e){var n=67108863^67108863>>>e<<e;this.words[this.length-1]&=n}return this._strip()},n.prototype.maskn=function(t){return this.clone().imaskn(t)},n.prototype.iaddn=function(t){return r("number"==typeof t),r(t<67108864),t<0?this.isubn(-t):0!==this.negative?1===this.length&&(0|this.words[0])<=t?(this.words[0]=t-(0|this.words[0]),this.negative=0,this):(this.negative=0,this.isubn(t),this.negative=1,this):this._iaddn(t)},n.prototype._iaddn=function(t){this.words[0]+=t;for(var e=0;e<this.length&&this.words[e]>=67108864;e++)this.words[e]-=67108864,e===this.length-1?this.words[e+1]=1:this.words[e+1]++;return this.length=Math.max(this.length,e+1),this},n.prototype.isubn=function(t){if(r("number"==typeof t),r(t<67108864),t<0)return this.iaddn(-t);if(0!==this.negative)return this.negative=0,this.iaddn(t),this.negative=1,this;if(this.words[0]-=t,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var e=0;e<this.length&&this.words[e]<0;e++)this.words[e]+=67108864,this.words[e+1]-=1;return this._strip()},n.prototype.addn=function(t){return this.clone().iaddn(t)},n.prototype.subn=function(t){return this.clone().isubn(t)},n.prototype.iabs=function(){return this.negative=0,this},n.prototype.abs=function(){return this.clone().iabs()},n.prototype._ishlnsubmul=function(t,e,i){var n,o,a=t.length+i;this._expand(a);var s=0;for(n=0;n<t.length;n++){o=(0|this.words[n+i])+s;var h=(0|t.words[n])*e;s=((o-=67108863&h)>>26)-(h/67108864|0),this.words[n+i]=67108863&o}for(;n<this.length-i;n++)s=(o=(0|this.words[n+i])+s)>>26,this.words[n+i]=67108863&o;if(0===s)return this._strip();for(r(-1===s),s=0,n=0;n<this.length;n++)s=(o=-(0|this.words[n])+s)>>26,this.words[n]=67108863&o;return this.negative=1,this._strip()},n.prototype._wordDiv=function(t,e){var r=(this.length,t.length),i=this.clone(),o=t,a=0|o.words[o.length-1];0!==(r=26-this._countBits(a))&&(o=o.ushln(r),i.iushln(r),a=0|o.words[o.length-1]);var s,h=i.length-o.length;if("mod"!==e){(s=new n(null)).length=h+1,s.words=new Array(s.length);for(var u=0;u<s.length;u++)s.words[u]=0}var l=i.clone()._ishlnsubmul(o,1,h);0===l.negative&&(i=l,s&&(s.words[h]=1));for(var c=h-1;c>=0;c--){var d=67108864*(0|i.words[o.length+c])+(0|i.words[o.length+c-1]);for(d=Math.min(d/a|0,67108863),i._ishlnsubmul(o,d,c);0!==i.negative;)d--,i.negative=0,i._ishlnsubmul(o,1,c),i.isZero()||(i.negative^=1);s&&(s.words[c]=d)}return s&&s._strip(),i._strip(),"div"!==e&&0!==r&&i.iushrn(r),{div:s||null,mod:i}},n.prototype.divmod=function(t,e,i){return r(!t.isZero()),this.isZero()?{div:new n(0),mod:new n(0)}:0!==this.negative&&0===t.negative?(s=this.neg().divmod(t,e),"mod"!==e&&(o=s.div.neg()),"div"!==e&&(a=s.mod.neg(),i&&0!==a.negative&&a.iadd(t)),{div:o,mod:a}):0===this.negative&&0!==t.negative?(s=this.divmod(t.neg(),e),"mod"!==e&&(o=s.div.neg()),{div:o,mod:s.mod}):0!=(this.negative&t.negative)?(s=this.neg().divmod(t.neg(),e),"div"!==e&&(a=s.mod.neg(),i&&0!==a.negative&&a.isub(t)),{div:s.div,mod:a}):t.length>this.length||this.cmp(t)<0?{div:new n(0),mod:this}:1===t.length?"div"===e?{div:this.divn(t.words[0]),mod:null}:"mod"===e?{div:null,mod:new n(this.modrn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new n(this.modrn(t.words[0]))}:this._wordDiv(t,e);var o,a,s},n.prototype.div=function(t){return this.divmod(t,"div",!1).div},n.prototype.mod=function(t){return this.divmod(t,"mod",!1).mod},n.prototype.umod=function(t){return this.divmod(t,"mod",!0).mod},n.prototype.divRound=function(t){var e=this.divmod(t);if(e.mod.isZero())return e.div;var r=0!==e.div.negative?e.mod.isub(t):e.mod,i=t.ushrn(1),n=t.andln(1),o=r.cmp(i);return o<0||1===n&&0===o?e.div:0!==e.div.negative?e.div.isubn(1):e.div.iaddn(1)},n.prototype.modrn=function(t){var e=t<0;e&&(t=-t),r(t<=67108863);for(var i=(1<<26)%t,n=0,o=this.length-1;o>=0;o--)n=(i*n+(0|this.words[o]))%t;return e?-n:n},n.prototype.modn=function(t){return this.modrn(t)},n.prototype.idivn=function(t){var e=t<0;e&&(t=-t),r(t<=67108863);for(var i=0,n=this.length-1;n>=0;n--){var o=(0|this.words[n])+67108864*i;this.words[n]=o/t|0,i=o%t}return this._strip(),e?this.ineg():this},n.prototype.divn=function(t){return this.clone().idivn(t)},n.prototype.egcd=function(t){r(0===t.negative),r(!t.isZero());var e=this,i=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var o=new n(1),a=new n(0),s=new n(0),h=new n(1),u=0;e.isEven()&&i.isEven();)e.iushrn(1),i.iushrn(1),++u;for(var l=i.clone(),c=e.clone();!e.isZero();){for(var d=0,f=1;0==(e.words[0]&f)&&d<26;++d,f<<=1);if(d>0)for(e.iushrn(d);d-- >0;)(o.isOdd()||a.isOdd())&&(o.iadd(l),a.isub(c)),o.iushrn(1),a.iushrn(1);for(var m=0,p=1;0==(i.words[0]&p)&&m<26;++m,p<<=1);if(m>0)for(i.iushrn(m);m-- >0;)(s.isOdd()||h.isOdd())&&(s.iadd(l),h.isub(c)),s.iushrn(1),h.iushrn(1);e.cmp(i)>=0?(e.isub(i),o.isub(s),a.isub(h)):(i.isub(e),s.isub(o),h.isub(a))}return{a:s,b:h,gcd:i.iushln(u)}},n.prototype._invmp=function(t){r(0===t.negative),r(!t.isZero());var e=this,i=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var o,a=new n(1),s=new n(0),h=i.clone();e.cmpn(1)>0&&i.cmpn(1)>0;){for(var u=0,l=1;0==(e.words[0]&l)&&u<26;++u,l<<=1);if(u>0)for(e.iushrn(u);u-- >0;)a.isOdd()&&a.iadd(h),a.iushrn(1);for(var c=0,d=1;0==(i.words[0]&d)&&c<26;++c,d<<=1);if(c>0)for(i.iushrn(c);c-- >0;)s.isOdd()&&s.iadd(h),s.iushrn(1);e.cmp(i)>=0?(e.isub(i),a.isub(s)):(i.isub(e),s.isub(a))}return(o=0===e.cmpn(1)?a:s).cmpn(0)<0&&o.iadd(t),o},n.prototype.gcd=function(t){if(this.isZero())return t.abs();if(t.isZero())return this.abs();var e=this.clone(),r=t.clone();e.negative=0,r.negative=0;for(var i=0;e.isEven()&&r.isEven();i++)e.iushrn(1),r.iushrn(1);for(;;){for(;e.isEven();)e.iushrn(1);for(;r.isEven();)r.iushrn(1);var n=e.cmp(r);if(n<0){var o=e;e=r,r=o}else if(0===n||0===r.cmpn(1))break;e.isub(r)}return r.iushln(i)},n.prototype.invm=function(t){return this.egcd(t).a.umod(t)},n.prototype.isEven=function(){return 0==(1&this.words[0])},n.prototype.isOdd=function(){return 1==(1&this.words[0])},n.prototype.andln=function(t){return this.words[0]&t},n.prototype.bincn=function(t){r("number"==typeof t);var e=t%26,i=(t-e)/26,n=1<<e;if(this.length<=i)return this._expand(i+1),this.words[i]|=n,this;for(var o=n,a=i;0!==o&&a<this.length;a++){var s=0|this.words[a];o=(s+=o)>>>26,s&=67108863,this.words[a]=s}return 0!==o&&(this.words[a]=o,this.length++),this},n.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},n.prototype.cmpn=function(t){var e,i=t<0;if(0!==this.negative&&!i)return-1;if(0===this.negative&&i)return 1;if(this._strip(),this.length>1)e=1;else{i&&(t=-t),r(t<=67108863,"Number is too big");var n=0|this.words[0];e=n===t?0:n<t?-1:1}return 0!==this.negative?0|-e:e},n.prototype.cmp=function(t){if(0!==this.negative&&0===t.negative)return-1;if(0===this.negative&&0!==t.negative)return 1;var e=this.ucmp(t);return 0!==this.negative?0|-e:e},n.prototype.ucmp=function(t){if(this.length>t.length)return 1;if(this.length<t.length)return-1;for(var e=0,r=this.length-1;r>=0;r--){var i=0|this.words[r],n=0|t.words[r];if(i!==n){i<n?e=-1:i>n&&(e=1);break}}return e},n.prototype.gtn=function(t){return 1===this.cmpn(t)},n.prototype.gt=function(t){return 1===this.cmp(t)},n.prototype.gten=function(t){return this.cmpn(t)>=0},n.prototype.gte=function(t){return this.cmp(t)>=0},n.prototype.ltn=function(t){return-1===this.cmpn(t)},n.prototype.lt=function(t){return-1===this.cmp(t)},n.prototype.lten=function(t){return this.cmpn(t)<=0},n.prototype.lte=function(t){return this.cmp(t)<=0},n.prototype.eqn=function(t){return 0===this.cmpn(t)},n.prototype.eq=function(t){return 0===this.cmp(t)},n.red=function(t){return new E(t)},n.prototype.toRed=function(t){return r(!this.red,"Already a number in reduction context"),r(0===this.negative,"red works only with positives"),t.convertTo(this)._forceRed(t)},n.prototype.fromRed=function(){return r(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},n.prototype._forceRed=function(t){return this.red=t,this},n.prototype.forceRed=function(t){return r(!this.red,"Already a number in reduction context"),this._forceRed(t)},n.prototype.redAdd=function(t){return r(this.red,"redAdd works only with red numbers"),this.red.add(this,t)},n.prototype.redIAdd=function(t){return r(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,t)},n.prototype.redSub=function(t){return r(this.red,"redSub works only with red numbers"),this.red.sub(this,t)},n.prototype.redISub=function(t){return r(this.red,"redISub works only with red numbers"),this.red.isub(this,t)},n.prototype.redShl=function(t){return r(this.red,"redShl works only with red numbers"),this.red.shl(this,t)},n.prototype.redMul=function(t){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.mul(this,t)},n.prototype.redIMul=function(t){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.imul(this,t)},n.prototype.redSqr=function(){return r(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},n.prototype.redISqr=function(){return r(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},n.prototype.redSqrt=function(){return r(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},n.prototype.redInvm=function(){return r(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},n.prototype.redNeg=function(){return r(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},n.prototype.redPow=function(t){return r(this.red&&!t.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,t)};var w={k256:null,p224:null,p192:null,p25519:null};function v(t,e){this.name=t,this.p=new n(e,16),this.n=this.p.bitLength(),this.k=new n(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function b(){v.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function k(){v.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function M(){v.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function _(){v.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function E(t){if("string"==typeof t){var e=n._prime(t);this.m=e.p,this.prime=e}else r(t.gtn(1),"modulus must be greater than 1"),this.m=t,this.prime=null}function A(t){E.call(this,t),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new n(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)}v.prototype._tmp=function(){var t=new n(null);return t.words=new Array(Math.ceil(this.n/13)),t},v.prototype.ireduce=function(t){var e,r=t;do{this.split(r,this.tmp),e=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(e>this.n);var i=e<this.n?-1:r.ucmp(this.p);return 0===i?(r.words[0]=0,r.length=1):i>0?r.isub(this.p):void 0!==r.strip?r.strip():r._strip(),r},v.prototype.split=function(t,e){t.iushrn(this.n,0,e)},v.prototype.imulK=function(t){return t.imul(this.k)},i(b,v),b.prototype.split=function(t,e){for(var r=4194303,i=Math.min(t.length,9),n=0;n<i;n++)e.words[n]=t.words[n];if(e.length=i,t.length<=9)return t.words[0]=0,void(t.length=1);var o=t.words[9];for(e.words[e.length++]=o&r,n=10;n<t.length;n++){var a=0|t.words[n];t.words[n-10]=(a&r)<<4|o>>>22,o=a}o>>>=22,t.words[n-10]=o,0===o&&t.length>10?t.length-=10:t.length-=9},b.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var e=0,r=0;r<t.length;r++){var i=0|t.words[r];e+=977*i,t.words[r]=67108863&e,e=64*i+(e/67108864|0)}return 0===t.words[t.length-1]&&(t.length--,0===t.words[t.length-1]&&t.length--),t},i(k,v),i(M,v),i(_,v),_.prototype.imulK=function(t){for(var e=0,r=0;r<t.length;r++){var i=19*(0|t.words[r])+e,n=67108863&i;i>>>=26,t.words[r]=n,e=i}return 0!==e&&(t.words[t.length++]=e),t},n._prime=function(t){if(w[t])return w[t];var e;if("k256"===t)e=new b;else if("p224"===t)e=new k;else if("p192"===t)e=new M;else{if("p25519"!==t)throw new Error("Unknown prime "+t);e=new _}return w[t]=e,e},E.prototype._verify1=function(t){r(0===t.negative,"red works only with positives"),r(t.red,"red works only with red numbers")},E.prototype._verify2=function(t,e){r(0==(t.negative|e.negative),"red works only with positives"),r(t.red&&t.red===e.red,"red works only with red numbers")},E.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):(u(t,t.umod(this.m)._forceRed(this)),t)},E.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},E.prototype.add=function(t,e){this._verify2(t,e);var r=t.add(e);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},E.prototype.iadd=function(t,e){this._verify2(t,e);var r=t.iadd(e);return r.cmp(this.m)>=0&&r.isub(this.m),r},E.prototype.sub=function(t,e){this._verify2(t,e);var r=t.sub(e);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},E.prototype.isub=function(t,e){this._verify2(t,e);var r=t.isub(e);return r.cmpn(0)<0&&r.iadd(this.m),r},E.prototype.shl=function(t,e){return this._verify1(t),this.imod(t.ushln(e))},E.prototype.imul=function(t,e){return this._verify2(t,e),this.imod(t.imul(e))},E.prototype.mul=function(t,e){return this._verify2(t,e),this.imod(t.mul(e))},E.prototype.isqr=function(t){return this.imul(t,t.clone())},E.prototype.sqr=function(t){return this.mul(t,t)},E.prototype.sqrt=function(t){if(t.isZero())return t.clone();var e=this.m.andln(3);if(r(e%2==1),3===e){var i=this.m.add(new n(1)).iushrn(2);return this.pow(t,i)}for(var o=this.m.subn(1),a=0;!o.isZero()&&0===o.andln(1);)a++,o.iushrn(1);r(!o.isZero());var s=new n(1).toRed(this),h=s.redNeg(),u=this.m.subn(1).iushrn(1),l=this.m.bitLength();for(l=new n(2*l*l).toRed(this);0!==this.pow(l,u).cmp(h);)l.redIAdd(h);for(var c=this.pow(l,o),d=this.pow(t,o.addn(1).iushrn(1)),f=this.pow(t,o),m=a;0!==f.cmp(s);){for(var p=f,g=0;0!==p.cmp(s);g++)p=p.redSqr();r(g<m);var y=this.pow(c,new n(1).iushln(m-g-1));d=d.redMul(y),c=y.redSqr(),f=f.redMul(c),m=g}return d},E.prototype.invm=function(t){var e=t._invmp(this.m);return 0!==e.negative?(e.negative=0,this.imod(e).redNeg()):this.imod(e)},E.prototype.pow=function(t,e){if(e.isZero())return new n(1).toRed(this);if(0===e.cmpn(1))return t.clone();var r=new Array(16);r[0]=new n(1).toRed(this),r[1]=t;for(var i=2;i<r.length;i++)r[i]=this.mul(r[i-1],t);var o=r[0],a=0,s=0,h=e.bitLength()%26;for(0===h&&(h=26),i=e.length-1;i>=0;i--){for(var u=e.words[i],l=h-1;l>=0;l--){var c=u>>l&1;o!==r[0]&&(o=this.sqr(o)),0!==c||0!==a?(a<<=1,a|=c,(4===++s||0===i&&0===l)&&(o=this.mul(o,r[a]),s=0,a=0)):s=0}h=26}return o},E.prototype.convertTo=function(t){var e=t.umod(this.m);return e===t?e.clone():e},E.prototype.convertFrom=function(t){var e=t.clone();return e.red=null,e},n.mont=function(t){return new A(t)},i(A,E),A.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},A.prototype.convertFrom=function(t){var e=this.imod(t.mul(this.rinv));return e.red=null,e},A.prototype.imul=function(t,e){if(t.isZero()||e.isZero())return t.words[0]=0,t.length=1,t;var r=t.imul(e),i=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),n=r.isub(i).iushrn(this.shift),o=n;return n.cmp(this.m)>=0?o=n.isub(this.m):n.cmpn(0)<0&&(o=n.iadd(this.m)),o._forceRed(this)},A.prototype.mul=function(t,e){if(t.isZero()||e.isZero())return new n(0)._forceRed(this);var r=t.mul(e),i=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),o=r.isub(i).iushrn(this.shift),a=o;return o.cmp(this.m)>=0?a=o.isub(this.m):o.cmpn(0)<0&&(a=o.iadd(this.m)),a._forceRed(this)},A.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}(t,i)}));var In=Nn.BN;const Tn=new w("bignumber/5.6.2"),Cn={},zn=9007199254740991;let On=!1;class Rn{constructor(t,e){t!==Cn&&Tn.throwError("cannot call constructor directly; use BigNumber.from",w.errors.UNSUPPORTED_OPERATION,{operation:"new (BigNumber)"}),this._hex=e,this._isBigNumber=!0,Object.freeze(this)}fromTwos(t){return Bn(Dn(this).fromTwos(t))}toTwos(t){return Bn(Dn(this).toTwos(t))}abs(){return"-"===this._hex[0]?Rn.from(this._hex.substring(1)):this}add(t){return Bn(Dn(this).add(Dn(t)))}sub(t){return Bn(Dn(this).sub(Dn(t)))}div(t){return Rn.from(t).isZero()&&$n("division-by-zero","div"),Bn(Dn(this).div(Dn(t)))}mul(t){return Bn(Dn(this).mul(Dn(t)))}mod(t){const e=Dn(t);return e.isNeg()&&$n("division-by-zero","mod"),Bn(Dn(this).umod(e))}pow(t){const e=Dn(t);return e.isNeg()&&$n("negative-power","pow"),Bn(Dn(this).pow(e))}and(t){const e=Dn(t);return(this.isNegative()||e.isNeg())&&$n("unbound-bitwise-result","and"),Bn(Dn(this).and(e))}or(t){const e=Dn(t);return(this.isNegative()||e.isNeg())&&$n("unbound-bitwise-result","or"),Bn(Dn(this).or(e))}xor(t){const e=Dn(t);return(this.isNegative()||e.isNeg())&&$n("unbound-bitwise-result","xor"),Bn(Dn(this).xor(e))}mask(t){return(this.isNegative()||t<0)&&$n("negative-width","mask"),Bn(Dn(this).maskn(t))}shl(t){return(this.isNegative()||t<0)&&$n("negative-width","shl"),Bn(Dn(this).shln(t))}shr(t){return(this.isNegative()||t<0)&&$n("negative-width","shr"),Bn(Dn(this).shrn(t))}eq(t){return Dn(this).eq(Dn(t))}lt(t){return Dn(this).lt(Dn(t))}lte(t){return Dn(this).lte(Dn(t))}gt(t){return Dn(this).gt(Dn(t))}gte(t){return Dn(this).gte(Dn(t))}isNegative(){return"-"===this._hex[0]}isZero(){return Dn(this).isZero()}toNumber(){try{return Dn(this).toNumber()}catch(t){$n("overflow","toNumber",this.toString())}return null}toBigInt(){try{return BigInt(this.toString())}catch(t){}return Tn.throwError("this platform does not support BigInt",w.errors.UNSUPPORTED_OPERATION,{value:this.toString()})}toString(){return arguments.length>0&&(10===arguments[0]?On||(On=!0,Tn.warn("BigNumber.toString does not accept any parameters; base-10 is assumed")):16===arguments[0]?Tn.throwError("BigNumber.toString does not accept any parameters; use bigNumber.toHexString()",w.errors.UNEXPECTED_ARGUMENT,{}):Tn.throwError("BigNumber.toString does not accept parameters",w.errors.UNEXPECTED_ARGUMENT,{})),Dn(this).toString(10)}toHexString(){return this._hex}toJSON(t){return{type:"BigNumber",hex:this.toHexString()}}static from(t){if(t instanceof Rn)return t;if("string"==typeof t)return t.match(/^-?0x[0-9a-f]+$/i)?new Rn(Cn,Pn(t)):t.match(/^-?[0-9]+$/)?new Rn(Cn,Pn(new In(t))):Tn.throwArgumentError("invalid BigNumber string","value",t);if("number"==typeof t)return t%1&&$n("underflow","BigNumber.from",t),(t>=zn||t<=-zn)&&$n("overflow","BigNumber.from",t),Rn.from(String(t));const e=t;if("bigint"==typeof e)return Rn.from(e.toString());if(E(e))return Rn.from(I(e));if(e)if(e.toHexString){const t=e.toHexString();if("string"==typeof t)return Rn.from(t)}else{let t=e._hex;if(null==t&&"BigNumber"===e.type&&(t=e.hex),"string"==typeof t&&(S(t)||"-"===t[0]&&S(t.substring(1))))return Rn.from(t)}return Tn.throwArgumentError("invalid BigNumber value","value",t)}static isBigNumber(t){return!(!t||!t._isBigNumber)}}function Pn(t){if("string"!=typeof t)return Pn(t.toString(16));if("-"===t[0])return"-"===(t=t.substring(1))[0]&&Tn.throwArgumentError("invalid hex","value",t),"0x00"===(t=Pn(t))?t:"-"+t;if("0x"!==t.substring(0,2)&&(t="0x"+t),"0x"===t)return"0x00";for(t.length%2&&(t="0x0"+t.substring(2));t.length>4&&"0x00"===t.substring(0,4);)t="0x"+t.substring(4);return t}function Bn(t){return Rn.from(Pn(t))}function Dn(t){const e=Rn.from(t).toHexString();return"-"===e[0]?new In("-"+e.substring(3),16):new In(e.substring(2),16)}function $n(t,e,r){const i={fault:t,operation:e};return null!=r&&(i.value=r),Tn.throwError(t,w.errors.NUMERIC_FAULT,i)}var Ln=a((function(t){!function(t,e){function r(t,e){if(!t)throw new Error(e||"Assertion failed")}function i(t,e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}function n(t,e,r){if(n.isBN(t))return t;this.negative=0,this.words=null,this.length=0,this.red=null,null!==t&&("le"!==e&&"be"!==e||(r=e,e=10),this._init(t||0,e||10,r||"be"))}var o;"object"==typeof t?t.exports=n:e.BN=n,n.BN=n,n.wordSize=26;try{o="undefined"!=typeof window&&void 0!==window.Buffer?window.Buffer:Pt.Buffer}catch(t){}function a(t,e){var i=t.charCodeAt(e);return i>=48&&i<=57?i-48:i>=65&&i<=70?i-55:i>=97&&i<=102?i-87:void r(!1,"Invalid character in "+t)}function s(t,e,r){var i=a(t,r);return r-1>=e&&(i|=a(t,r-1)<<4),i}function h(t,e,i,n){for(var o=0,a=0,s=Math.min(t.length,i),h=e;h<s;h++){var u=t.charCodeAt(h)-48;o*=n,a=u>=49?u-49+10:u>=17?u-17+10:u,r(u>=0&&a<n,"Invalid character"),o+=a}return o}function u(t,e){t.words=e.words,t.length=e.length,t.negative=e.negative,t.red=e.red}if(n.isBN=function(t){return t instanceof n||null!==t&&"object"==typeof t&&t.constructor.wordSize===n.wordSize&&Array.isArray(t.words)},n.max=function(t,e){return t.cmp(e)>0?t:e},n.min=function(t,e){return t.cmp(e)<0?t:e},n.prototype._init=function(t,e,i){if("number"==typeof t)return this._initNumber(t,e,i);if("object"==typeof t)return this._initArray(t,e,i);"hex"===e&&(e=16),r(e===(0|e)&&e>=2&&e<=36);var n=0;"-"===(t=t.toString().replace(/\s+/g,""))[0]&&(n++,this.negative=1),n<t.length&&(16===e?this._parseHex(t,n,i):(this._parseBase(t,e,n),"le"===i&&this._initArray(this.toArray(),e,i)))},n.prototype._initNumber=function(t,e,i){t<0&&(this.negative=1,t=-t),t<67108864?(this.words=[67108863&t],this.length=1):t<4503599627370496?(this.words=[67108863&t,t/67108864&67108863],this.length=2):(r(t<9007199254740992),this.words=[67108863&t,t/67108864&67108863,1],this.length=3),"le"===i&&this._initArray(this.toArray(),e,i)},n.prototype._initArray=function(t,e,i){if(r("number"==typeof t.length),t.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(t.length/3),this.words=new Array(this.length);for(var n=0;n<this.length;n++)this.words[n]=0;var o,a,s=0;if("be"===i)for(n=t.length-1,o=0;n>=0;n-=3)a=t[n]|t[n-1]<<8|t[n-2]<<16,this.words[o]|=a<<s&67108863,this.words[o+1]=a>>>26-s&67108863,(s+=24)>=26&&(s-=26,o++);else if("le"===i)for(n=0,o=0;n<t.length;n+=3)a=t[n]|t[n+1]<<8|t[n+2]<<16,this.words[o]|=a<<s&67108863,this.words[o+1]=a>>>26-s&67108863,(s+=24)>=26&&(s-=26,o++);return this._strip()},n.prototype._parseHex=function(t,e,r){this.length=Math.ceil((t.length-e)/6),this.words=new Array(this.length);for(var i=0;i<this.length;i++)this.words[i]=0;var n,o=0,a=0;if("be"===r)for(i=t.length-1;i>=e;i-=2)n=s(t,e,i)<<o,this.words[a]|=67108863&n,o>=18?(o-=18,a+=1,this.words[a]|=n>>>26):o+=8;else for(i=(t.length-e)%2==0?e+1:e;i<t.length;i+=2)n=s(t,e,i)<<o,this.words[a]|=67108863&n,o>=18?(o-=18,a+=1,this.words[a]|=n>>>26):o+=8;this._strip()},n.prototype._parseBase=function(t,e,r){this.words=[0],this.length=1;for(var i=0,n=1;n<=67108863;n*=e)i++;i--,n=n/e|0;for(var o=t.length-r,a=o%i,s=Math.min(o,o-a)+r,u=0,l=r;l<s;l+=i)u=h(t,l,l+i,e),this.imuln(n),this.words[0]+u<67108864?this.words[0]+=u:this._iaddn(u);if(0!==a){var c=1;for(u=h(t,l,t.length,e),l=0;l<a;l++)c*=e;this.imuln(c),this.words[0]+u<67108864?this.words[0]+=u:this._iaddn(u)}this._strip()},n.prototype.copy=function(t){t.words=new Array(this.length);for(var e=0;e<this.length;e++)t.words[e]=this.words[e];t.length=this.length,t.negative=this.negative,t.red=this.red},n.prototype._move=function(t){u(t,this)},n.prototype.clone=function(){var t=new n(null);return this.copy(t),t},n.prototype._expand=function(t){for(;this.length<t;)this.words[this.length++]=0;return this},n.prototype._strip=function(){for(;this.length>1&&0===this.words[this.length-1];)this.length--;return this._normSign()},n.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},"undefined"!=typeof Symbol&&"function"==typeof Symbol.for)try{n.prototype[Symbol.for("nodejs.util.inspect.custom")]=l}catch(t){n.prototype.inspect=l}else n.prototype.inspect=l;function l(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"}var c=["","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"],d=[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],f=[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];n.prototype.toString=function(t,e){var i;if(e=0|e||1,16===(t=t||10)||"hex"===t){i="";for(var n=0,o=0,a=0;a<this.length;a++){var s=this.words[a],h=(16777215&(s<<n|o)).toString(16);o=s>>>24-n&16777215,(n+=2)>=26&&(n-=26,a--),i=0!==o||a!==this.length-1?c[6-h.length]+h+i:h+i}for(0!==o&&(i=o.toString(16)+i);i.length%e!=0;)i="0"+i;return 0!==this.negative&&(i="-"+i),i}if(t===(0|t)&&t>=2&&t<=36){var u=d[t],l=f[t];i="";var m=this.clone();for(m.negative=0;!m.isZero();){var p=m.modrn(l).toString(t);i=(m=m.idivn(l)).isZero()?p+i:c[u-p.length]+p+i}for(this.isZero()&&(i="0"+i);i.length%e!=0;)i="0"+i;return 0!==this.negative&&(i="-"+i),i}r(!1,"Base should be between 2 and 36")},n.prototype.toNumber=function(){var t=this.words[0];return 2===this.length?t+=67108864*this.words[1]:3===this.length&&1===this.words[2]?t+=4503599627370496+67108864*this.words[1]:this.length>2&&r(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-t:t},n.prototype.toJSON=function(){return this.toString(16,2)},o&&(n.prototype.toBuffer=function(t,e){return this.toArrayLike(o,t,e)}),n.prototype.toArray=function(t,e){return this.toArrayLike(Array,t,e)};function m(t,e,r){r.negative=e.negative^t.negative;var i=t.length+e.length|0;r.length=i,i=i-1|0;var n=0|t.words[0],o=0|e.words[0],a=n*o,s=67108863&a,h=a/67108864|0;r.words[0]=s;for(var u=1;u<i;u++){for(var l=h>>>26,c=67108863&h,d=Math.min(u,e.length-1),f=Math.max(0,u-t.length+1);f<=d;f++){var m=u-f|0;l+=(a=(n=0|t.words[m])*(o=0|e.words[f])+c)/67108864|0,c=67108863&a}r.words[u]=0|c,h=0|l}return 0!==h?r.words[u]=0|h:r.length--,r._strip()}n.prototype.toArrayLike=function(t,e,i){this._strip();var n=this.byteLength(),o=i||Math.max(1,n);r(n<=o,"byte array longer than desired length"),r(o>0,"Requested array length <= 0");var a=function(t,e){return t.allocUnsafe?t.allocUnsafe(e):new t(e)}(t,o);return this["_toArrayLike"+("le"===e?"LE":"BE")](a,n),a},n.prototype._toArrayLikeLE=function(t,e){for(var r=0,i=0,n=0,o=0;n<this.length;n++){var a=this.words[n]<<o|i;t[r++]=255&a,r<t.length&&(t[r++]=a>>8&255),r<t.length&&(t[r++]=a>>16&255),6===o?(r<t.length&&(t[r++]=a>>24&255),i=0,o=0):(i=a>>>24,o+=2)}if(r<t.length)for(t[r++]=i;r<t.length;)t[r++]=0},n.prototype._toArrayLikeBE=function(t,e){for(var r=t.length-1,i=0,n=0,o=0;n<this.length;n++){var a=this.words[n]<<o|i;t[r--]=255&a,r>=0&&(t[r--]=a>>8&255),r>=0&&(t[r--]=a>>16&255),6===o?(r>=0&&(t[r--]=a>>24&255),i=0,o=0):(i=a>>>24,o+=2)}if(r>=0)for(t[r--]=i;r>=0;)t[r--]=0},Math.clz32?n.prototype._countBits=function(t){return 32-Math.clz32(t)}:n.prototype._countBits=function(t){var e=t,r=0;return e>=4096&&(r+=13,e>>>=13),e>=64&&(r+=7,e>>>=7),e>=8&&(r+=4,e>>>=4),e>=2&&(r+=2,e>>>=2),r+e},n.prototype._zeroBits=function(t){if(0===t)return 26;var e=t,r=0;return 0==(8191&e)&&(r+=13,e>>>=13),0==(127&e)&&(r+=7,e>>>=7),0==(15&e)&&(r+=4,e>>>=4),0==(3&e)&&(r+=2,e>>>=2),0==(1&e)&&r++,r},n.prototype.bitLength=function(){var t=this.words[this.length-1],e=this._countBits(t);return 26*(this.length-1)+e},n.prototype.zeroBits=function(){if(this.isZero())return 0;for(var t=0,e=0;e<this.length;e++){var r=this._zeroBits(this.words[e]);if(t+=r,26!==r)break}return t},n.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},n.prototype.toTwos=function(t){return 0!==this.negative?this.abs().inotn(t).iaddn(1):this.clone()},n.prototype.fromTwos=function(t){return this.testn(t-1)?this.notn(t).iaddn(1).ineg():this.clone()},n.prototype.isNeg=function(){return 0!==this.negative},n.prototype.neg=function(){return this.clone().ineg()},n.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},n.prototype.iuor=function(t){for(;this.length<t.length;)this.words[this.length++]=0;for(var e=0;e<t.length;e++)this.words[e]=this.words[e]|t.words[e];return this._strip()},n.prototype.ior=function(t){return r(0==(this.negative|t.negative)),this.iuor(t)},n.prototype.or=function(t){return this.length>t.length?this.clone().ior(t):t.clone().ior(this)},n.prototype.uor=function(t){return this.length>t.length?this.clone().iuor(t):t.clone().iuor(this)},n.prototype.iuand=function(t){var e;e=this.length>t.length?t:this;for(var r=0;r<e.length;r++)this.words[r]=this.words[r]&t.words[r];return this.length=e.length,this._strip()},n.prototype.iand=function(t){return r(0==(this.negative|t.negative)),this.iuand(t)},n.prototype.and=function(t){return this.length>t.length?this.clone().iand(t):t.clone().iand(this)},n.prototype.uand=function(t){return this.length>t.length?this.clone().iuand(t):t.clone().iuand(this)},n.prototype.iuxor=function(t){var e,r;this.length>t.length?(e=this,r=t):(e=t,r=this);for(var i=0;i<r.length;i++)this.words[i]=e.words[i]^r.words[i];if(this!==e)for(;i<e.length;i++)this.words[i]=e.words[i];return this.length=e.length,this._strip()},n.prototype.ixor=function(t){return r(0==(this.negative|t.negative)),this.iuxor(t)},n.prototype.xor=function(t){return this.length>t.length?this.clone().ixor(t):t.clone().ixor(this)},n.prototype.uxor=function(t){return this.length>t.length?this.clone().iuxor(t):t.clone().iuxor(this)},n.prototype.inotn=function(t){r("number"==typeof t&&t>=0);var e=0|Math.ceil(t/26),i=t%26;this._expand(e),i>0&&e--;for(var n=0;n<e;n++)this.words[n]=67108863&~this.words[n];return i>0&&(this.words[n]=~this.words[n]&67108863>>26-i),this._strip()},n.prototype.notn=function(t){return this.clone().inotn(t)},n.prototype.setn=function(t,e){r("number"==typeof t&&t>=0);var i=t/26|0,n=t%26;return this._expand(i+1),this.words[i]=e?this.words[i]|1<<n:this.words[i]&~(1<<n),this._strip()},n.prototype.iadd=function(t){var e,r,i;if(0!==this.negative&&0===t.negative)return this.negative=0,e=this.isub(t),this.negative^=1,this._normSign();if(0===this.negative&&0!==t.negative)return t.negative=0,e=this.isub(t),t.negative=1,e._normSign();this.length>t.length?(r=this,i=t):(r=t,i=this);for(var n=0,o=0;o<i.length;o++)e=(0|r.words[o])+(0|i.words[o])+n,this.words[o]=67108863&e,n=e>>>26;for(;0!==n&&o<r.length;o++)e=(0|r.words[o])+n,this.words[o]=67108863&e,n=e>>>26;if(this.length=r.length,0!==n)this.words[this.length]=n,this.length++;else if(r!==this)for(;o<r.length;o++)this.words[o]=r.words[o];return this},n.prototype.add=function(t){var e;return 0!==t.negative&&0===this.negative?(t.negative=0,e=this.sub(t),t.negative^=1,e):0===t.negative&&0!==this.negative?(this.negative=0,e=t.sub(this),this.negative=1,e):this.length>t.length?this.clone().iadd(t):t.clone().iadd(this)},n.prototype.isub=function(t){if(0!==t.negative){t.negative=0;var e=this.iadd(t);return t.negative=1,e._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(t),this.negative=1,this._normSign();var r,i,n=this.cmp(t);if(0===n)return this.negative=0,this.length=1,this.words[0]=0,this;n>0?(r=this,i=t):(r=t,i=this);for(var o=0,a=0;a<i.length;a++)o=(e=(0|r.words[a])-(0|i.words[a])+o)>>26,this.words[a]=67108863&e;for(;0!==o&&a<r.length;a++)o=(e=(0|r.words[a])+o)>>26,this.words[a]=67108863&e;if(0===o&&a<r.length&&r!==this)for(;a<r.length;a++)this.words[a]=r.words[a];return this.length=Math.max(this.length,a),r!==this&&(this.negative=1),this._strip()},n.prototype.sub=function(t){return this.clone().isub(t)};var p=function(t,e,r){var i,n,o,a=t.words,s=e.words,h=r.words,u=0,l=0|a[0],c=8191&l,d=l>>>13,f=0|a[1],m=8191&f,p=f>>>13,g=0|a[2],y=8191&g,w=g>>>13,v=0|a[3],b=8191&v,k=v>>>13,M=0|a[4],_=8191&M,E=M>>>13,A=0|a[5],j=8191&A,x=A>>>13,S=0|a[6],N=8191&S,I=S>>>13,T=0|a[7],C=8191&T,z=T>>>13,O=0|a[8],R=8191&O,P=O>>>13,B=0|a[9],D=8191&B,$=B>>>13,L=0|s[0],F=8191&L,U=L>>>13,q=0|s[1],V=8191&q,H=q>>>13,G=0|s[2],Z=8191&G,K=G>>>13,J=0|s[3],W=8191&J,Y=J>>>13,Q=0|s[4],X=8191&Q,tt=Q>>>13,et=0|s[5],rt=8191&et,it=et>>>13,nt=0|s[6],ot=8191&nt,at=nt>>>13,st=0|s[7],ht=8191&st,ut=st>>>13,lt=0|s[8],ct=8191&lt,dt=lt>>>13,ft=0|s[9],mt=8191&ft,pt=ft>>>13;r.negative=t.negative^e.negative,r.length=19;var gt=(u+(i=Math.imul(c,F))|0)+((8191&(n=(n=Math.imul(c,U))+Math.imul(d,F)|0))<<13)|0;u=((o=Math.imul(d,U))+(n>>>13)|0)+(gt>>>26)|0,gt&=67108863,i=Math.imul(m,F),n=(n=Math.imul(m,U))+Math.imul(p,F)|0,o=Math.imul(p,U);var yt=(u+(i=i+Math.imul(c,V)|0)|0)+((8191&(n=(n=n+Math.imul(c,H)|0)+Math.imul(d,V)|0))<<13)|0;u=((o=o+Math.imul(d,H)|0)+(n>>>13)|0)+(yt>>>26)|0,yt&=67108863,i=Math.imul(y,F),n=(n=Math.imul(y,U))+Math.imul(w,F)|0,o=Math.imul(w,U),i=i+Math.imul(m,V)|0,n=(n=n+Math.imul(m,H)|0)+Math.imul(p,V)|0,o=o+Math.imul(p,H)|0;var wt=(u+(i=i+Math.imul(c,Z)|0)|0)+((8191&(n=(n=n+Math.imul(c,K)|0)+Math.imul(d,Z)|0))<<13)|0;u=((o=o+Math.imul(d,K)|0)+(n>>>13)|0)+(wt>>>26)|0,wt&=67108863,i=Math.imul(b,F),n=(n=Math.imul(b,U))+Math.imul(k,F)|0,o=Math.imul(k,U),i=i+Math.imul(y,V)|0,n=(n=n+Math.imul(y,H)|0)+Math.imul(w,V)|0,o=o+Math.imul(w,H)|0,i=i+Math.imul(m,Z)|0,n=(n=n+Math.imul(m,K)|0)+Math.imul(p,Z)|0,o=o+Math.imul(p,K)|0;var vt=(u+(i=i+Math.imul(c,W)|0)|0)+((8191&(n=(n=n+Math.imul(c,Y)|0)+Math.imul(d,W)|0))<<13)|0;u=((o=o+Math.imul(d,Y)|0)+(n>>>13)|0)+(vt>>>26)|0,vt&=67108863,i=Math.imul(_,F),n=(n=Math.imul(_,U))+Math.imul(E,F)|0,o=Math.imul(E,U),i=i+Math.imul(b,V)|0,n=(n=n+Math.imul(b,H)|0)+Math.imul(k,V)|0,o=o+Math.imul(k,H)|0,i=i+Math.imul(y,Z)|0,n=(n=n+Math.imul(y,K)|0)+Math.imul(w,Z)|0,o=o+Math.imul(w,K)|0,i=i+Math.imul(m,W)|0,n=(n=n+Math.imul(m,Y)|0)+Math.imul(p,W)|0,o=o+Math.imul(p,Y)|0;var bt=(u+(i=i+Math.imul(c,X)|0)|0)+((8191&(n=(n=n+Math.imul(c,tt)|0)+Math.imul(d,X)|0))<<13)|0;u=((o=o+Math.imul(d,tt)|0)+(n>>>13)|0)+(bt>>>26)|0,bt&=67108863,i=Math.imul(j,F),n=(n=Math.imul(j,U))+Math.imul(x,F)|0,o=Math.imul(x,U),i=i+Math.imul(_,V)|0,n=(n=n+Math.imul(_,H)|0)+Math.imul(E,V)|0,o=o+Math.imul(E,H)|0,i=i+Math.imul(b,Z)|0,n=(n=n+Math.imul(b,K)|0)+Math.imul(k,Z)|0,o=o+Math.imul(k,K)|0,i=i+Math.imul(y,W)|0,n=(n=n+Math.imul(y,Y)|0)+Math.imul(w,W)|0,o=o+Math.imul(w,Y)|0,i=i+Math.imul(m,X)|0,n=(n=n+Math.imul(m,tt)|0)+Math.imul(p,X)|0,o=o+Math.imul(p,tt)|0;var kt=(u+(i=i+Math.imul(c,rt)|0)|0)+((8191&(n=(n=n+Math.imul(c,it)|0)+Math.imul(d,rt)|0))<<13)|0;u=((o=o+Math.imul(d,it)|0)+(n>>>13)|0)+(kt>>>26)|0,kt&=67108863,i=Math.imul(N,F),n=(n=Math.imul(N,U))+Math.imul(I,F)|0,o=Math.imul(I,U),i=i+Math.imul(j,V)|0,n=(n=n+Math.imul(j,H)|0)+Math.imul(x,V)|0,o=o+Math.imul(x,H)|0,i=i+Math.imul(_,Z)|0,n=(n=n+Math.imul(_,K)|0)+Math.imul(E,Z)|0,o=o+Math.imul(E,K)|0,i=i+Math.imul(b,W)|0,n=(n=n+Math.imul(b,Y)|0)+Math.imul(k,W)|0,o=o+Math.imul(k,Y)|0,i=i+Math.imul(y,X)|0,n=(n=n+Math.imul(y,tt)|0)+Math.imul(w,X)|0,o=o+Math.imul(w,tt)|0,i=i+Math.imul(m,rt)|0,n=(n=n+Math.imul(m,it)|0)+Math.imul(p,rt)|0,o=o+Math.imul(p,it)|0;var Mt=(u+(i=i+Math.imul(c,ot)|0)|0)+((8191&(n=(n=n+Math.imul(c,at)|0)+Math.imul(d,ot)|0))<<13)|0;u=((o=o+Math.imul(d,at)|0)+(n>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,i=Math.imul(C,F),n=(n=Math.imul(C,U))+Math.imul(z,F)|0,o=Math.imul(z,U),i=i+Math.imul(N,V)|0,n=(n=n+Math.imul(N,H)|0)+Math.imul(I,V)|0,o=o+Math.imul(I,H)|0,i=i+Math.imul(j,Z)|0,n=(n=n+Math.imul(j,K)|0)+Math.imul(x,Z)|0,o=o+Math.imul(x,K)|0,i=i+Math.imul(_,W)|0,n=(n=n+Math.imul(_,Y)|0)+Math.imul(E,W)|0,o=o+Math.imul(E,Y)|0,i=i+Math.imul(b,X)|0,n=(n=n+Math.imul(b,tt)|0)+Math.imul(k,X)|0,o=o+Math.imul(k,tt)|0,i=i+Math.imul(y,rt)|0,n=(n=n+Math.imul(y,it)|0)+Math.imul(w,rt)|0,o=o+Math.imul(w,it)|0,i=i+Math.imul(m,ot)|0,n=(n=n+Math.imul(m,at)|0)+Math.imul(p,ot)|0,o=o+Math.imul(p,at)|0;var _t=(u+(i=i+Math.imul(c,ht)|0)|0)+((8191&(n=(n=n+Math.imul(c,ut)|0)+Math.imul(d,ht)|0))<<13)|0;u=((o=o+Math.imul(d,ut)|0)+(n>>>13)|0)+(_t>>>26)|0,_t&=67108863,i=Math.imul(R,F),n=(n=Math.imul(R,U))+Math.imul(P,F)|0,o=Math.imul(P,U),i=i+Math.imul(C,V)|0,n=(n=n+Math.imul(C,H)|0)+Math.imul(z,V)|0,o=o+Math.imul(z,H)|0,i=i+Math.imul(N,Z)|0,n=(n=n+Math.imul(N,K)|0)+Math.imul(I,Z)|0,o=o+Math.imul(I,K)|0,i=i+Math.imul(j,W)|0,n=(n=n+Math.imul(j,Y)|0)+Math.imul(x,W)|0,o=o+Math.imul(x,Y)|0,i=i+Math.imul(_,X)|0,n=(n=n+Math.imul(_,tt)|0)+Math.imul(E,X)|0,o=o+Math.imul(E,tt)|0,i=i+Math.imul(b,rt)|0,n=(n=n+Math.imul(b,it)|0)+Math.imul(k,rt)|0,o=o+Math.imul(k,it)|0,i=i+Math.imul(y,ot)|0,n=(n=n+Math.imul(y,at)|0)+Math.imul(w,ot)|0,o=o+Math.imul(w,at)|0,i=i+Math.imul(m,ht)|0,n=(n=n+Math.imul(m,ut)|0)+Math.imul(p,ht)|0,o=o+Math.imul(p,ut)|0;var Et=(u+(i=i+Math.imul(c,ct)|0)|0)+((8191&(n=(n=n+Math.imul(c,dt)|0)+Math.imul(d,ct)|0))<<13)|0;u=((o=o+Math.imul(d,dt)|0)+(n>>>13)|0)+(Et>>>26)|0,Et&=67108863,i=Math.imul(D,F),n=(n=Math.imul(D,U))+Math.imul($,F)|0,o=Math.imul($,U),i=i+Math.imul(R,V)|0,n=(n=n+Math.imul(R,H)|0)+Math.imul(P,V)|0,o=o+Math.imul(P,H)|0,i=i+Math.imul(C,Z)|0,n=(n=n+Math.imul(C,K)|0)+Math.imul(z,Z)|0,o=o+Math.imul(z,K)|0,i=i+Math.imul(N,W)|0,n=(n=n+Math.imul(N,Y)|0)+Math.imul(I,W)|0,o=o+Math.imul(I,Y)|0,i=i+Math.imul(j,X)|0,n=(n=n+Math.imul(j,tt)|0)+Math.imul(x,X)|0,o=o+Math.imul(x,tt)|0,i=i+Math.imul(_,rt)|0,n=(n=n+Math.imul(_,it)|0)+Math.imul(E,rt)|0,o=o+Math.imul(E,it)|0,i=i+Math.imul(b,ot)|0,n=(n=n+Math.imul(b,at)|0)+Math.imul(k,ot)|0,o=o+Math.imul(k,at)|0,i=i+Math.imul(y,ht)|0,n=(n=n+Math.imul(y,ut)|0)+Math.imul(w,ht)|0,o=o+Math.imul(w,ut)|0,i=i+Math.imul(m,ct)|0,n=(n=n+Math.imul(m,dt)|0)+Math.imul(p,ct)|0,o=o+Math.imul(p,dt)|0;var At=(u+(i=i+Math.imul(c,mt)|0)|0)+((8191&(n=(n=n+Math.imul(c,pt)|0)+Math.imul(d,mt)|0))<<13)|0;u=((o=o+Math.imul(d,pt)|0)+(n>>>13)|0)+(At>>>26)|0,At&=67108863,i=Math.imul(D,V),n=(n=Math.imul(D,H))+Math.imul($,V)|0,o=Math.imul($,H),i=i+Math.imul(R,Z)|0,n=(n=n+Math.imul(R,K)|0)+Math.imul(P,Z)|0,o=o+Math.imul(P,K)|0,i=i+Math.imul(C,W)|0,n=(n=n+Math.imul(C,Y)|0)+Math.imul(z,W)|0,o=o+Math.imul(z,Y)|0,i=i+Math.imul(N,X)|0,n=(n=n+Math.imul(N,tt)|0)+Math.imul(I,X)|0,o=o+Math.imul(I,tt)|0,i=i+Math.imul(j,rt)|0,n=(n=n+Math.imul(j,it)|0)+Math.imul(x,rt)|0,o=o+Math.imul(x,it)|0,i=i+Math.imul(_,ot)|0,n=(n=n+Math.imul(_,at)|0)+Math.imul(E,ot)|0,o=o+Math.imul(E,at)|0,i=i+Math.imul(b,ht)|0,n=(n=n+Math.imul(b,ut)|0)+Math.imul(k,ht)|0,o=o+Math.imul(k,ut)|0,i=i+Math.imul(y,ct)|0,n=(n=n+Math.imul(y,dt)|0)+Math.imul(w,ct)|0,o=o+Math.imul(w,dt)|0;var jt=(u+(i=i+Math.imul(m,mt)|0)|0)+((8191&(n=(n=n+Math.imul(m,pt)|0)+Math.imul(p,mt)|0))<<13)|0;u=((o=o+Math.imul(p,pt)|0)+(n>>>13)|0)+(jt>>>26)|0,jt&=67108863,i=Math.imul(D,Z),n=(n=Math.imul(D,K))+Math.imul($,Z)|0,o=Math.imul($,K),i=i+Math.imul(R,W)|0,n=(n=n+Math.imul(R,Y)|0)+Math.imul(P,W)|0,o=o+Math.imul(P,Y)|0,i=i+Math.imul(C,X)|0,n=(n=n+Math.imul(C,tt)|0)+Math.imul(z,X)|0,o=o+Math.imul(z,tt)|0,i=i+Math.imul(N,rt)|0,n=(n=n+Math.imul(N,it)|0)+Math.imul(I,rt)|0,o=o+Math.imul(I,it)|0,i=i+Math.imul(j,ot)|0,n=(n=n+Math.imul(j,at)|0)+Math.imul(x,ot)|0,o=o+Math.imul(x,at)|0,i=i+Math.imul(_,ht)|0,n=(n=n+Math.imul(_,ut)|0)+Math.imul(E,ht)|0,o=o+Math.imul(E,ut)|0,i=i+Math.imul(b,ct)|0,n=(n=n+Math.imul(b,dt)|0)+Math.imul(k,ct)|0,o=o+Math.imul(k,dt)|0;var xt=(u+(i=i+Math.imul(y,mt)|0)|0)+((8191&(n=(n=n+Math.imul(y,pt)|0)+Math.imul(w,mt)|0))<<13)|0;u=((o=o+Math.imul(w,pt)|0)+(n>>>13)|0)+(xt>>>26)|0,xt&=67108863,i=Math.imul(D,W),n=(n=Math.imul(D,Y))+Math.imul($,W)|0,o=Math.imul($,Y),i=i+Math.imul(R,X)|0,n=(n=n+Math.imul(R,tt)|0)+Math.imul(P,X)|0,o=o+Math.imul(P,tt)|0,i=i+Math.imul(C,rt)|0,n=(n=n+Math.imul(C,it)|0)+Math.imul(z,rt)|0,o=o+Math.imul(z,it)|0,i=i+Math.imul(N,ot)|0,n=(n=n+Math.imul(N,at)|0)+Math.imul(I,ot)|0,o=o+Math.imul(I,at)|0,i=i+Math.imul(j,ht)|0,n=(n=n+Math.imul(j,ut)|0)+Math.imul(x,ht)|0,o=o+Math.imul(x,ut)|0,i=i+Math.imul(_,ct)|0,n=(n=n+Math.imul(_,dt)|0)+Math.imul(E,ct)|0,o=o+Math.imul(E,dt)|0;var St=(u+(i=i+Math.imul(b,mt)|0)|0)+((8191&(n=(n=n+Math.imul(b,pt)|0)+Math.imul(k,mt)|0))<<13)|0;u=((o=o+Math.imul(k,pt)|0)+(n>>>13)|0)+(St>>>26)|0,St&=67108863,i=Math.imul(D,X),n=(n=Math.imul(D,tt))+Math.imul($,X)|0,o=Math.imul($,tt),i=i+Math.imul(R,rt)|0,n=(n=n+Math.imul(R,it)|0)+Math.imul(P,rt)|0,o=o+Math.imul(P,it)|0,i=i+Math.imul(C,ot)|0,n=(n=n+Math.imul(C,at)|0)+Math.imul(z,ot)|0,o=o+Math.imul(z,at)|0,i=i+Math.imul(N,ht)|0,n=(n=n+Math.imul(N,ut)|0)+Math.imul(I,ht)|0,o=o+Math.imul(I,ut)|0,i=i+Math.imul(j,ct)|0,n=(n=n+Math.imul(j,dt)|0)+Math.imul(x,ct)|0,o=o+Math.imul(x,dt)|0;var Nt=(u+(i=i+Math.imul(_,mt)|0)|0)+((8191&(n=(n=n+Math.imul(_,pt)|0)+Math.imul(E,mt)|0))<<13)|0;u=((o=o+Math.imul(E,pt)|0)+(n>>>13)|0)+(Nt>>>26)|0,Nt&=67108863,i=Math.imul(D,rt),n=(n=Math.imul(D,it))+Math.imul($,rt)|0,o=Math.imul($,it),i=i+Math.imul(R,ot)|0,n=(n=n+Math.imul(R,at)|0)+Math.imul(P,ot)|0,o=o+Math.imul(P,at)|0,i=i+Math.imul(C,ht)|0,n=(n=n+Math.imul(C,ut)|0)+Math.imul(z,ht)|0,o=o+Math.imul(z,ut)|0,i=i+Math.imul(N,ct)|0,n=(n=n+Math.imul(N,dt)|0)+Math.imul(I,ct)|0,o=o+Math.imul(I,dt)|0;var It=(u+(i=i+Math.imul(j,mt)|0)|0)+((8191&(n=(n=n+Math.imul(j,pt)|0)+Math.imul(x,mt)|0))<<13)|0;u=((o=o+Math.imul(x,pt)|0)+(n>>>13)|0)+(It>>>26)|0,It&=67108863,i=Math.imul(D,ot),n=(n=Math.imul(D,at))+Math.imul($,ot)|0,o=Math.imul($,at),i=i+Math.imul(R,ht)|0,n=(n=n+Math.imul(R,ut)|0)+Math.imul(P,ht)|0,o=o+Math.imul(P,ut)|0,i=i+Math.imul(C,ct)|0,n=(n=n+Math.imul(C,dt)|0)+Math.imul(z,ct)|0,o=o+Math.imul(z,dt)|0;var Tt=(u+(i=i+Math.imul(N,mt)|0)|0)+((8191&(n=(n=n+Math.imul(N,pt)|0)+Math.imul(I,mt)|0))<<13)|0;u=((o=o+Math.imul(I,pt)|0)+(n>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,i=Math.imul(D,ht),n=(n=Math.imul(D,ut))+Math.imul($,ht)|0,o=Math.imul($,ut),i=i+Math.imul(R,ct)|0,n=(n=n+Math.imul(R,dt)|0)+Math.imul(P,ct)|0,o=o+Math.imul(P,dt)|0;var Ct=(u+(i=i+Math.imul(C,mt)|0)|0)+((8191&(n=(n=n+Math.imul(C,pt)|0)+Math.imul(z,mt)|0))<<13)|0;u=((o=o+Math.imul(z,pt)|0)+(n>>>13)|0)+(Ct>>>26)|0,Ct&=67108863,i=Math.imul(D,ct),n=(n=Math.imul(D,dt))+Math.imul($,ct)|0,o=Math.imul($,dt);var zt=(u+(i=i+Math.imul(R,mt)|0)|0)+((8191&(n=(n=n+Math.imul(R,pt)|0)+Math.imul(P,mt)|0))<<13)|0;u=((o=o+Math.imul(P,pt)|0)+(n>>>13)|0)+(zt>>>26)|0,zt&=67108863;var Ot=(u+(i=Math.imul(D,mt))|0)+((8191&(n=(n=Math.imul(D,pt))+Math.imul($,mt)|0))<<13)|0;return u=((o=Math.imul($,pt))+(n>>>13)|0)+(Ot>>>26)|0,Ot&=67108863,h[0]=gt,h[1]=yt,h[2]=wt,h[3]=vt,h[4]=bt,h[5]=kt,h[6]=Mt,h[7]=_t,h[8]=Et,h[9]=At,h[10]=jt,h[11]=xt,h[12]=St,h[13]=Nt,h[14]=It,h[15]=Tt,h[16]=Ct,h[17]=zt,h[18]=Ot,0!==u&&(h[19]=u,r.length++),r};function g(t,e,r){r.negative=e.negative^t.negative,r.length=t.length+e.length;for(var i=0,n=0,o=0;o<r.length-1;o++){var a=n;n=0;for(var s=67108863&i,h=Math.min(o,e.length-1),u=Math.max(0,o-t.length+1);u<=h;u++){var l=o-u,c=(0|t.words[l])*(0|e.words[u]),d=67108863&c;s=67108863&(d=d+s|0),n+=(a=(a=a+(c/67108864|0)|0)+(d>>>26)|0)>>>26,a&=67108863}r.words[o]=s,i=a,a=n}return 0!==i?r.words[o]=i:r.length--,r._strip()}function y(t,e,r){return g(t,e,r)}Math.imul||(p=m),n.prototype.mulTo=function(t,e){var r=this.length+t.length;return 10===this.length&&10===t.length?p(this,t,e):r<63?m(this,t,e):r<1024?g(this,t,e):y(this,t,e)},n.prototype.mul=function(t){var e=new n(null);return e.words=new Array(this.length+t.length),this.mulTo(t,e)},n.prototype.mulf=function(t){var e=new n(null);return e.words=new Array(this.length+t.length),y(this,t,e)},n.prototype.imul=function(t){return this.clone().mulTo(t,this)},n.prototype.imuln=function(t){var e=t<0;e&&(t=-t),r("number"==typeof t),r(t<67108864);for(var i=0,n=0;n<this.length;n++){var o=(0|this.words[n])*t,a=(67108863&o)+(67108863&i);i>>=26,i+=o/67108864|0,i+=a>>>26,this.words[n]=67108863&a}return 0!==i&&(this.words[n]=i,this.length++),e?this.ineg():this},n.prototype.muln=function(t){return this.clone().imuln(t)},n.prototype.sqr=function(){return this.mul(this)},n.prototype.isqr=function(){return this.imul(this.clone())},n.prototype.pow=function(t){var e=function(t){for(var e=new Array(t.bitLength()),r=0;r<e.length;r++){var i=r/26|0,n=r%26;e[r]=t.words[i]>>>n&1}return e}(t);if(0===e.length)return new n(1);for(var r=this,i=0;i<e.length&&0===e[i];i++,r=r.sqr());if(++i<e.length)for(var o=r.sqr();i<e.length;i++,o=o.sqr())0!==e[i]&&(r=r.mul(o));return r},n.prototype.iushln=function(t){r("number"==typeof t&&t>=0);var e,i=t%26,n=(t-i)/26,o=67108863>>>26-i<<26-i;if(0!==i){var a=0;for(e=0;e<this.length;e++){var s=this.words[e]&o,h=(0|this.words[e])-s<<i;this.words[e]=h|a,a=s>>>26-i}a&&(this.words[e]=a,this.length++)}if(0!==n){for(e=this.length-1;e>=0;e--)this.words[e+n]=this.words[e];for(e=0;e<n;e++)this.words[e]=0;this.length+=n}return this._strip()},n.prototype.ishln=function(t){return r(0===this.negative),this.iushln(t)},n.prototype.iushrn=function(t,e,i){var n;r("number"==typeof t&&t>=0),n=e?(e-e%26)/26:0;var o=t%26,a=Math.min((t-o)/26,this.length),s=67108863^67108863>>>o<<o,h=i;if(n-=a,n=Math.max(0,n),h){for(var u=0;u<a;u++)h.words[u]=this.words[u];h.length=a}if(0===a);else if(this.length>a)for(this.length-=a,u=0;u<this.length;u++)this.words[u]=this.words[u+a];else this.words[0]=0,this.length=1;var l=0;for(u=this.length-1;u>=0&&(0!==l||u>=n);u--){var c=0|this.words[u];this.words[u]=l<<26-o|c>>>o,l=c&s}return h&&0!==l&&(h.words[h.length++]=l),0===this.length&&(this.words[0]=0,this.length=1),this._strip()},n.prototype.ishrn=function(t,e,i){return r(0===this.negative),this.iushrn(t,e,i)},n.prototype.shln=function(t){return this.clone().ishln(t)},n.prototype.ushln=function(t){return this.clone().iushln(t)},n.prototype.shrn=function(t){return this.clone().ishrn(t)},n.prototype.ushrn=function(t){return this.clone().iushrn(t)},n.prototype.testn=function(t){r("number"==typeof t&&t>=0);var e=t%26,i=(t-e)/26,n=1<<e;return!(this.length<=i)&&!!(this.words[i]&n)},n.prototype.imaskn=function(t){r("number"==typeof t&&t>=0);var e=t%26,i=(t-e)/26;if(r(0===this.negative,"imaskn works only with positive numbers"),this.length<=i)return this;if(0!==e&&i++,this.length=Math.min(i,this.length),0!==e){var n=67108863^67108863>>>e<<e;this.words[this.length-1]&=n}return this._strip()},n.prototype.maskn=function(t){return this.clone().imaskn(t)},n.prototype.iaddn=function(t){return r("number"==typeof t),r(t<67108864),t<0?this.isubn(-t):0!==this.negative?1===this.length&&(0|this.words[0])<=t?(this.words[0]=t-(0|this.words[0]),this.negative=0,this):(this.negative=0,this.isubn(t),this.negative=1,this):this._iaddn(t)},n.prototype._iaddn=function(t){this.words[0]+=t;for(var e=0;e<this.length&&this.words[e]>=67108864;e++)this.words[e]-=67108864,e===this.length-1?this.words[e+1]=1:this.words[e+1]++;return this.length=Math.max(this.length,e+1),this},n.prototype.isubn=function(t){if(r("number"==typeof t),r(t<67108864),t<0)return this.iaddn(-t);if(0!==this.negative)return this.negative=0,this.iaddn(t),this.negative=1,this;if(this.words[0]-=t,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var e=0;e<this.length&&this.words[e]<0;e++)this.words[e]+=67108864,this.words[e+1]-=1;return this._strip()},n.prototype.addn=function(t){return this.clone().iaddn(t)},n.prototype.subn=function(t){return this.clone().isubn(t)},n.prototype.iabs=function(){return this.negative=0,this},n.prototype.abs=function(){return this.clone().iabs()},n.prototype._ishlnsubmul=function(t,e,i){var n,o,a=t.length+i;this._expand(a);var s=0;for(n=0;n<t.length;n++){o=(0|this.words[n+i])+s;var h=(0|t.words[n])*e;s=((o-=67108863&h)>>26)-(h/67108864|0),this.words[n+i]=67108863&o}for(;n<this.length-i;n++)s=(o=(0|this.words[n+i])+s)>>26,this.words[n+i]=67108863&o;if(0===s)return this._strip();for(r(-1===s),s=0,n=0;n<this.length;n++)s=(o=-(0|this.words[n])+s)>>26,this.words[n]=67108863&o;return this.negative=1,this._strip()},n.prototype._wordDiv=function(t,e){var r=(this.length,t.length),i=this.clone(),o=t,a=0|o.words[o.length-1];0!==(r=26-this._countBits(a))&&(o=o.ushln(r),i.iushln(r),a=0|o.words[o.length-1]);var s,h=i.length-o.length;if("mod"!==e){(s=new n(null)).length=h+1,s.words=new Array(s.length);for(var u=0;u<s.length;u++)s.words[u]=0}var l=i.clone()._ishlnsubmul(o,1,h);0===l.negative&&(i=l,s&&(s.words[h]=1));for(var c=h-1;c>=0;c--){var d=67108864*(0|i.words[o.length+c])+(0|i.words[o.length+c-1]);for(d=Math.min(d/a|0,67108863),i._ishlnsubmul(o,d,c);0!==i.negative;)d--,i.negative=0,i._ishlnsubmul(o,1,c),i.isZero()||(i.negative^=1);s&&(s.words[c]=d)}return s&&s._strip(),i._strip(),"div"!==e&&0!==r&&i.iushrn(r),{div:s||null,mod:i}},n.prototype.divmod=function(t,e,i){return r(!t.isZero()),this.isZero()?{div:new n(0),mod:new n(0)}:0!==this.negative&&0===t.negative?(s=this.neg().divmod(t,e),"mod"!==e&&(o=s.div.neg()),"div"!==e&&(a=s.mod.neg(),i&&0!==a.negative&&a.iadd(t)),{div:o,mod:a}):0===this.negative&&0!==t.negative?(s=this.divmod(t.neg(),e),"mod"!==e&&(o=s.div.neg()),{div:o,mod:s.mod}):0!=(this.negative&t.negative)?(s=this.neg().divmod(t.neg(),e),"div"!==e&&(a=s.mod.neg(),i&&0!==a.negative&&a.isub(t)),{div:s.div,mod:a}):t.length>this.length||this.cmp(t)<0?{div:new n(0),mod:this}:1===t.length?"div"===e?{div:this.divn(t.words[0]),mod:null}:"mod"===e?{div:null,mod:new n(this.modrn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new n(this.modrn(t.words[0]))}:this._wordDiv(t,e);var o,a,s},n.prototype.div=function(t){return this.divmod(t,"div",!1).div},n.prototype.mod=function(t){return this.divmod(t,"mod",!1).mod},n.prototype.umod=function(t){return this.divmod(t,"mod",!0).mod},n.prototype.divRound=function(t){var e=this.divmod(t);if(e.mod.isZero())return e.div;var r=0!==e.div.negative?e.mod.isub(t):e.mod,i=t.ushrn(1),n=t.andln(1),o=r.cmp(i);return o<0||1===n&&0===o?e.div:0!==e.div.negative?e.div.isubn(1):e.div.iaddn(1)},n.prototype.modrn=function(t){var e=t<0;e&&(t=-t),r(t<=67108863);for(var i=(1<<26)%t,n=0,o=this.length-1;o>=0;o--)n=(i*n+(0|this.words[o]))%t;return e?-n:n},n.prototype.modn=function(t){return this.modrn(t)},n.prototype.idivn=function(t){var e=t<0;e&&(t=-t),r(t<=67108863);for(var i=0,n=this.length-1;n>=0;n--){var o=(0|this.words[n])+67108864*i;this.words[n]=o/t|0,i=o%t}return this._strip(),e?this.ineg():this},n.prototype.divn=function(t){return this.clone().idivn(t)},n.prototype.egcd=function(t){r(0===t.negative),r(!t.isZero());var e=this,i=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var o=new n(1),a=new n(0),s=new n(0),h=new n(1),u=0;e.isEven()&&i.isEven();)e.iushrn(1),i.iushrn(1),++u;for(var l=i.clone(),c=e.clone();!e.isZero();){for(var d=0,f=1;0==(e.words[0]&f)&&d<26;++d,f<<=1);if(d>0)for(e.iushrn(d);d-- >0;)(o.isOdd()||a.isOdd())&&(o.iadd(l),a.isub(c)),o.iushrn(1),a.iushrn(1);for(var m=0,p=1;0==(i.words[0]&p)&&m<26;++m,p<<=1);if(m>0)for(i.iushrn(m);m-- >0;)(s.isOdd()||h.isOdd())&&(s.iadd(l),h.isub(c)),s.iushrn(1),h.iushrn(1);e.cmp(i)>=0?(e.isub(i),o.isub(s),a.isub(h)):(i.isub(e),s.isub(o),h.isub(a))}return{a:s,b:h,gcd:i.iushln(u)}},n.prototype._invmp=function(t){r(0===t.negative),r(!t.isZero());var e=this,i=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var o,a=new n(1),s=new n(0),h=i.clone();e.cmpn(1)>0&&i.cmpn(1)>0;){for(var u=0,l=1;0==(e.words[0]&l)&&u<26;++u,l<<=1);if(u>0)for(e.iushrn(u);u-- >0;)a.isOdd()&&a.iadd(h),a.iushrn(1);for(var c=0,d=1;0==(i.words[0]&d)&&c<26;++c,d<<=1);if(c>0)for(i.iushrn(c);c-- >0;)s.isOdd()&&s.iadd(h),s.iushrn(1);e.cmp(i)>=0?(e.isub(i),a.isub(s)):(i.isub(e),s.isub(a))}return(o=0===e.cmpn(1)?a:s).cmpn(0)<0&&o.iadd(t),o},n.prototype.gcd=function(t){if(this.isZero())return t.abs();if(t.isZero())return this.abs();var e=this.clone(),r=t.clone();e.negative=0,r.negative=0;for(var i=0;e.isEven()&&r.isEven();i++)e.iushrn(1),r.iushrn(1);for(;;){for(;e.isEven();)e.iushrn(1);for(;r.isEven();)r.iushrn(1);var n=e.cmp(r);if(n<0){var o=e;e=r,r=o}else if(0===n||0===r.cmpn(1))break;e.isub(r)}return r.iushln(i)},n.prototype.invm=function(t){return this.egcd(t).a.umod(t)},n.prototype.isEven=function(){return 0==(1&this.words[0])},n.prototype.isOdd=function(){return 1==(1&this.words[0])},n.prototype.andln=function(t){return this.words[0]&t},n.prototype.bincn=function(t){r("number"==typeof t);var e=t%26,i=(t-e)/26,n=1<<e;if(this.length<=i)return this._expand(i+1),this.words[i]|=n,this;for(var o=n,a=i;0!==o&&a<this.length;a++){var s=0|this.words[a];o=(s+=o)>>>26,s&=67108863,this.words[a]=s}return 0!==o&&(this.words[a]=o,this.length++),this},n.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},n.prototype.cmpn=function(t){var e,i=t<0;if(0!==this.negative&&!i)return-1;if(0===this.negative&&i)return 1;if(this._strip(),this.length>1)e=1;else{i&&(t=-t),r(t<=67108863,"Number is too big");var n=0|this.words[0];e=n===t?0:n<t?-1:1}return 0!==this.negative?0|-e:e},n.prototype.cmp=function(t){if(0!==this.negative&&0===t.negative)return-1;if(0===this.negative&&0!==t.negative)return 1;var e=this.ucmp(t);return 0!==this.negative?0|-e:e},n.prototype.ucmp=function(t){if(this.length>t.length)return 1;if(this.length<t.length)return-1;for(var e=0,r=this.length-1;r>=0;r--){var i=0|this.words[r],n=0|t.words[r];if(i!==n){i<n?e=-1:i>n&&(e=1);break}}return e},n.prototype.gtn=function(t){return 1===this.cmpn(t)},n.prototype.gt=function(t){return 1===this.cmp(t)},n.prototype.gten=function(t){return this.cmpn(t)>=0},n.prototype.gte=function(t){return this.cmp(t)>=0},n.prototype.ltn=function(t){return-1===this.cmpn(t)},n.prototype.lt=function(t){return-1===this.cmp(t)},n.prototype.lten=function(t){return this.cmpn(t)<=0},n.prototype.lte=function(t){return this.cmp(t)<=0},n.prototype.eqn=function(t){return 0===this.cmpn(t)},n.prototype.eq=function(t){return 0===this.cmp(t)},n.red=function(t){return new E(t)},n.prototype.toRed=function(t){return r(!this.red,"Already a number in reduction context"),r(0===this.negative,"red works only with positives"),t.convertTo(this)._forceRed(t)},n.prototype.fromRed=function(){return r(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},n.prototype._forceRed=function(t){return this.red=t,this},n.prototype.forceRed=function(t){return r(!this.red,"Already a number in reduction context"),this._forceRed(t)},n.prototype.redAdd=function(t){return r(this.red,"redAdd works only with red numbers"),this.red.add(this,t)},n.prototype.redIAdd=function(t){return r(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,t)},n.prototype.redSub=function(t){return r(this.red,"redSub works only with red numbers"),this.red.sub(this,t)},n.prototype.redISub=function(t){return r(this.red,"redISub works only with red numbers"),this.red.isub(this,t)},n.prototype.redShl=function(t){return r(this.red,"redShl works only with red numbers"),this.red.shl(this,t)},n.prototype.redMul=function(t){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.mul(this,t)},n.prototype.redIMul=function(t){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.imul(this,t)},n.prototype.redSqr=function(){return r(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},n.prototype.redISqr=function(){return r(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},n.prototype.redSqrt=function(){return r(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},n.prototype.redInvm=function(){return r(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},n.prototype.redNeg=function(){return r(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},n.prototype.redPow=function(t){return r(this.red&&!t.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,t)};var w={k256:null,p224:null,p192:null,p25519:null};function v(t,e){this.name=t,this.p=new n(e,16),this.n=this.p.bitLength(),this.k=new n(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function b(){v.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function k(){v.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function M(){v.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function _(){v.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function E(t){if("string"==typeof t){var e=n._prime(t);this.m=e.p,this.prime=e}else r(t.gtn(1),"modulus must be greater than 1"),this.m=t,this.prime=null}function A(t){E.call(this,t),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new n(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)}v.prototype._tmp=function(){var t=new n(null);return t.words=new Array(Math.ceil(this.n/13)),t},v.prototype.ireduce=function(t){var e,r=t;do{this.split(r,this.tmp),e=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(e>this.n);var i=e<this.n?-1:r.ucmp(this.p);return 0===i?(r.words[0]=0,r.length=1):i>0?r.isub(this.p):void 0!==r.strip?r.strip():r._strip(),r},v.prototype.split=function(t,e){t.iushrn(this.n,0,e)},v.prototype.imulK=function(t){return t.imul(this.k)},i(b,v),b.prototype.split=function(t,e){for(var r=4194303,i=Math.min(t.length,9),n=0;n<i;n++)e.words[n]=t.words[n];if(e.length=i,t.length<=9)return t.words[0]=0,void(t.length=1);var o=t.words[9];for(e.words[e.length++]=o&r,n=10;n<t.length;n++){var a=0|t.words[n];t.words[n-10]=(a&r)<<4|o>>>22,o=a}o>>>=22,t.words[n-10]=o,0===o&&t.length>10?t.length-=10:t.length-=9},b.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var e=0,r=0;r<t.length;r++){var i=0|t.words[r];e+=977*i,t.words[r]=67108863&e,e=64*i+(e/67108864|0)}return 0===t.words[t.length-1]&&(t.length--,0===t.words[t.length-1]&&t.length--),t},i(k,v),i(M,v),i(_,v),_.prototype.imulK=function(t){for(var e=0,r=0;r<t.length;r++){var i=19*(0|t.words[r])+e,n=67108863&i;i>>>=26,t.words[r]=n,e=i}return 0!==e&&(t.words[t.length++]=e),t},n._prime=function(t){if(w[t])return w[t];var e;if("k256"===t)e=new b;else if("p224"===t)e=new k;else if("p192"===t)e=new M;else{if("p25519"!==t)throw new Error("Unknown prime "+t);e=new _}return w[t]=e,e},E.prototype._verify1=function(t){r(0===t.negative,"red works only with positives"),r(t.red,"red works only with red numbers")},E.prototype._verify2=function(t,e){r(0==(t.negative|e.negative),"red works only with positives"),r(t.red&&t.red===e.red,"red works only with red numbers")},E.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):(u(t,t.umod(this.m)._forceRed(this)),t)},E.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},E.prototype.add=function(t,e){this._verify2(t,e);var r=t.add(e);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},E.prototype.iadd=function(t,e){this._verify2(t,e);var r=t.iadd(e);return r.cmp(this.m)>=0&&r.isub(this.m),r},E.prototype.sub=function(t,e){this._verify2(t,e);var r=t.sub(e);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},E.prototype.isub=function(t,e){this._verify2(t,e);var r=t.isub(e);return r.cmpn(0)<0&&r.iadd(this.m),r},E.prototype.shl=function(t,e){return this._verify1(t),this.imod(t.ushln(e))},E.prototype.imul=function(t,e){return this._verify2(t,e),this.imod(t.imul(e))},E.prototype.mul=function(t,e){return this._verify2(t,e),this.imod(t.mul(e))},E.prototype.isqr=function(t){return this.imul(t,t.clone())},E.prototype.sqr=function(t){return this.mul(t,t)},E.prototype.sqrt=function(t){if(t.isZero())return t.clone();var e=this.m.andln(3);if(r(e%2==1),3===e){var i=this.m.add(new n(1)).iushrn(2);return this.pow(t,i)}for(var o=this.m.subn(1),a=0;!o.isZero()&&0===o.andln(1);)a++,o.iushrn(1);r(!o.isZero());var s=new n(1).toRed(this),h=s.redNeg(),u=this.m.subn(1).iushrn(1),l=this.m.bitLength();for(l=new n(2*l*l).toRed(this);0!==this.pow(l,u).cmp(h);)l.redIAdd(h);for(var c=this.pow(l,o),d=this.pow(t,o.addn(1).iushrn(1)),f=this.pow(t,o),m=a;0!==f.cmp(s);){for(var p=f,g=0;0!==p.cmp(s);g++)p=p.redSqr();r(g<m);var y=this.pow(c,new n(1).iushln(m-g-1));d=d.redMul(y),c=y.redSqr(),f=f.redMul(c),m=g}return d},E.prototype.invm=function(t){var e=t._invmp(this.m);return 0!==e.negative?(e.negative=0,this.imod(e).redNeg()):this.imod(e)},E.prototype.pow=function(t,e){if(e.isZero())return new n(1).toRed(this);if(0===e.cmpn(1))return t.clone();var r=new Array(16);r[0]=new n(1).toRed(this),r[1]=t;for(var i=2;i<r.length;i++)r[i]=this.mul(r[i-1],t);var o=r[0],a=0,s=0,h=e.bitLength()%26;for(0===h&&(h=26),i=e.length-1;i>=0;i--){for(var u=e.words[i],l=h-1;l>=0;l--){var c=u>>l&1;o!==r[0]&&(o=this.sqr(o)),0!==c||0!==a?(a<<=1,a|=c,(4===++s||0===i&&0===l)&&(o=this.mul(o,r[a]),s=0,a=0)):s=0}h=26}return o},E.prototype.convertTo=function(t){var e=t.umod(this.m);return e===t?e.clone():e},E.prototype.convertFrom=function(t){var e=t.clone();return e.red=null,e},n.mont=function(t){return new A(t)},i(A,E),A.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},A.prototype.convertFrom=function(t){var e=this.imod(t.mul(this.rinv));return e.red=null,e},A.prototype.imul=function(t,e){if(t.isZero()||e.isZero())return t.words[0]=0,t.length=1,t;var r=t.imul(e),i=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),n=r.isub(i).iushrn(this.shift),o=n;return n.cmp(this.m)>=0?o=n.isub(this.m):n.cmpn(0)<0&&(o=n.iadd(this.m)),o._forceRed(this)},A.prototype.mul=function(t,e){if(t.isZero()||e.isZero())return new n(0)._forceRed(this);var r=t.mul(e),i=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),o=r.isub(i).iushrn(this.shift),a=o;return o.cmp(this.m)>=0?a=o.isub(this.m):o.cmpn(0)<0&&(a=o.iadd(this.m)),a._forceRed(this)},A.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}(t,i)})),Fn=Un;function Un(t,e){if(!t)throw new Error(e||"Assertion failed")}function qn(t,e){return 55296==(64512&t.charCodeAt(e))&&(!(e<0||e+1>=t.length)&&56320==(64512&t.charCodeAt(e+1)))}function Vn(t){return(t>>>24|t>>>8&65280|t<<8&16711680|(255&t)<<24)>>>0}function Hn(t){return 1===t.length?"0"+t:t}function Gn(t){return 7===t.length?"0"+t:6===t.length?"00"+t:5===t.length?"000"+t:4===t.length?"0000"+t:3===t.length?"00000"+t:2===t.length?"000000"+t:1===t.length?"0000000"+t:t}Un.equal=function(t,e,r){if(t!=e)throw new Error(r||"Assertion failed: "+t+" != "+e)};var Zn={inherits:a((function(t){"function"==typeof Object.create?t.exports=function(t,e){e&&(t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}))}:t.exports=function(t,e){if(e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}}})),toArray:function(t,e){if(Array.isArray(t))return t.slice();if(!t)return[];var r=[];if("string"==typeof t)if(e){if("hex"===e)for((t=t.replace(/[^a-z0-9]+/gi,"")).length%2!=0&&(t="0"+t),n=0;n<t.length;n+=2)r.push(parseInt(t[n]+t[n+1],16))}else for(var i=0,n=0;n<t.length;n++){var o=t.charCodeAt(n);o<128?r[i++]=o:o<2048?(r[i++]=o>>6|192,r[i++]=63&o|128):qn(t,n)?(o=65536+((1023&o)<<10)+(1023&t.charCodeAt(++n)),r[i++]=o>>18|240,r[i++]=o>>12&63|128,r[i++]=o>>6&63|128,r[i++]=63&o|128):(r[i++]=o>>12|224,r[i++]=o>>6&63|128,r[i++]=63&o|128)}else for(n=0;n<t.length;n++)r[n]=0|t[n];return r},toHex:function(t){for(var e="",r=0;r<t.length;r++)e+=Hn(t[r].toString(16));return e},htonl:Vn,toHex32:function(t,e){for(var r="",i=0;i<t.length;i++){var n=t[i];"little"===e&&(n=Vn(n)),r+=Gn(n.toString(16))}return r},zero2:Hn,zero8:Gn,join32:function(t,e,r,i){var n=r-e;Fn(n%4==0);for(var o=new Array(n/4),a=0,s=e;a<o.length;a++,s+=4){var h;h="big"===i?t[s]<<24|t[s+1]<<16|t[s+2]<<8|t[s+3]:t[s+3]<<24|t[s+2]<<16|t[s+1]<<8|t[s],o[a]=h>>>0}return o},split32:function(t,e){for(var r=new Array(4*t.length),i=0,n=0;i<t.length;i++,n+=4){var o=t[i];"big"===e?(r[n]=o>>>24,r[n+1]=o>>>16&255,r[n+2]=o>>>8&255,r[n+3]=255&o):(r[n+3]=o>>>24,r[n+2]=o>>>16&255,r[n+1]=o>>>8&255,r[n]=255&o)}return r},rotr32:function(t,e){return t>>>e|t<<32-e},rotl32:function(t,e){return t<<e|t>>>32-e},sum32:function(t,e){return t+e>>>0},sum32_3:function(t,e,r){return t+e+r>>>0},sum32_4:function(t,e,r,i){return t+e+r+i>>>0},sum32_5:function(t,e,r,i,n){return t+e+r+i+n>>>0},sum64:function(t,e,r,i){var n=t[e],o=i+t[e+1]>>>0,a=(o<i?1:0)+r+n;t[e]=a>>>0,t[e+1]=o},sum64_hi:function(t,e,r,i){return(e+i>>>0<e?1:0)+t+r>>>0},sum64_lo:function(t,e,r,i){return e+i>>>0},sum64_4_hi:function(t,e,r,i,n,o,a,s){var h=0,u=e;return h+=(u=u+i>>>0)<e?1:0,h+=(u=u+o>>>0)<o?1:0,t+r+n+a+(h+=(u=u+s>>>0)<s?1:0)>>>0},sum64_4_lo:function(t,e,r,i,n,o,a,s){return e+i+o+s>>>0},sum64_5_hi:function(t,e,r,i,n,o,a,s,h,u){var l=0,c=e;return l+=(c=c+i>>>0)<e?1:0,l+=(c=c+o>>>0)<o?1:0,l+=(c=c+s>>>0)<s?1:0,t+r+n+a+h+(l+=(c=c+u>>>0)<u?1:0)>>>0},sum64_5_lo:function(t,e,r,i,n,o,a,s,h,u){return e+i+o+s+u>>>0},rotr64_hi:function(t,e,r){return(e<<32-r|t>>>r)>>>0},rotr64_lo:function(t,e,r){return(t<<32-r|e>>>r)>>>0},shr64_hi:function(t,e,r){return t>>>r},shr64_lo:function(t,e,r){return(t<<32-r|e>>>r)>>>0}};function Kn(){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}var Jn=Kn;Kn.prototype.update=function(t,e){if(t=Zn.toArray(t,e),this.pending?this.pending=this.pending.concat(t):this.pending=t,this.pendingTotal+=t.length,this.pending.length>=this._delta8){var r=(t=this.pending).length%this._delta8;this.pending=t.slice(t.length-r,t.length),0===this.pending.length&&(this.pending=null),t=Zn.join32(t,0,t.length-r,this.endian);for(var i=0;i<t.length;i+=this._delta32)this._update(t,i,i+this._delta32)}return this},Kn.prototype.digest=function(t){return this.update(this._pad()),Fn(null===this.pending),this._digest(t)},Kn.prototype._pad=function(){var t=this.pendingTotal,e=this._delta8,r=e-(t+this.padLength)%e,i=new Array(r+this.padLength);i[0]=128;for(var n=1;n<r;n++)i[n]=0;if(t<<=3,"big"===this.endian){for(var o=8;o<this.padLength;o++)i[n++]=0;i[n++]=0,i[n++]=0,i[n++]=0,i[n++]=0,i[n++]=t>>>24&255,i[n++]=t>>>16&255,i[n++]=t>>>8&255,i[n++]=255&t}else for(i[n++]=255&t,i[n++]=t>>>8&255,i[n++]=t>>>16&255,i[n++]=t>>>24&255,i[n++]=0,i[n++]=0,i[n++]=0,i[n++]=0,o=8;o<this.padLength;o++)i[n++]=0;return i};var Wn={BlockHash:Jn},Yn=Zn.rotr32;var Qn=function(t,e,r,i){return 0===t?Xn(e,r,i):1===t||3===t?eo(e,r,i):2===t?to(e,r,i):void 0};function Xn(t,e,r){return t&e^~t&r}function to(t,e,r){return t&e^t&r^e&r}function eo(t,e,r){return t^e^r}var ro=function(t){return Yn(t,2)^Yn(t,13)^Yn(t,22)};var io=function(t){return Yn(t,6)^Yn(t,11)^Yn(t,25)};var no=function(t){return Yn(t,7)^Yn(t,18)^t>>>3};var oo=function(t){return Yn(t,17)^Yn(t,19)^t>>>10},ao={ft_1:Qn,ch32:Xn,maj32:to,p32:eo,s0_256:ro,s1_256:io,g0_256:no,g1_256:oo},so=Zn.rotl32,ho=Zn.sum32,uo=Zn.sum32_5,lo=ao.ft_1,co=Wn.BlockHash,fo=[1518500249,1859775393,2400959708,3395469782];function mo(){if(!(this instanceof mo))return new mo;co.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.W=new Array(80)}Zn.inherits(mo,co);var po=mo;mo.blockSize=512,mo.outSize=160,mo.hmacStrength=80,mo.padLength=64,mo.prototype._update=function(t,e){for(var r=this.W,i=0;i<16;i++)r[i]=t[e+i];for(;i<r.length;i++)r[i]=so(r[i-3]^r[i-8]^r[i-14]^r[i-16],1);var n=this.h[0],o=this.h[1],a=this.h[2],s=this.h[3],h=this.h[4];for(i=0;i<r.length;i++){var u=~~(i/20),l=uo(so(n,5),lo(u,o,a,s),h,r[i],fo[u]);h=s,s=a,a=so(o,30),o=n,n=l}this.h[0]=ho(this.h[0],n),this.h[1]=ho(this.h[1],o),this.h[2]=ho(this.h[2],a),this.h[3]=ho(this.h[3],s),this.h[4]=ho(this.h[4],h)},mo.prototype._digest=function(t){return"hex"===t?Zn.toHex32(this.h,"big"):Zn.split32(this.h,"big")};var go=Zn.sum32,yo=Zn.sum32_4,wo=Zn.sum32_5,vo=ao.ch32,bo=ao.maj32,ko=ao.s0_256,Mo=ao.s1_256,_o=ao.g0_256,Eo=ao.g1_256,Ao=Wn.BlockHash,jo=[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 xo(){if(!(this instanceof xo))return new xo;Ao.call(this),this.h=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],this.k=jo,this.W=new Array(64)}Zn.inherits(xo,Ao);var So=xo;function No(){if(!(this instanceof No))return new No;So.call(this),this.h=[3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428]}xo.blockSize=512,xo.outSize=256,xo.hmacStrength=192,xo.padLength=64,xo.prototype._update=function(t,e){for(var r=this.W,i=0;i<16;i++)r[i]=t[e+i];for(;i<r.length;i++)r[i]=yo(Eo(r[i-2]),r[i-7],_o(r[i-15]),r[i-16]);var n=this.h[0],o=this.h[1],a=this.h[2],s=this.h[3],h=this.h[4],u=this.h[5],l=this.h[6],c=this.h[7];for(Fn(this.k.length===r.length),i=0;i<r.length;i++){var d=wo(c,Mo(h),vo(h,u,l),this.k[i],r[i]),f=go(ko(n),bo(n,o,a));c=l,l=u,u=h,h=go(s,d),s=a,a=o,o=n,n=go(d,f)}this.h[0]=go(this.h[0],n),this.h[1]=go(this.h[1],o),this.h[2]=go(this.h[2],a),this.h[3]=go(this.h[3],s),this.h[4]=go(this.h[4],h),this.h[5]=go(this.h[5],u),this.h[6]=go(this.h[6],l),this.h[7]=go(this.h[7],c)},xo.prototype._digest=function(t){return"hex"===t?Zn.toHex32(this.h,"big"):Zn.split32(this.h,"big")},Zn.inherits(No,So);var Io=No;No.blockSize=512,No.outSize=224,No.hmacStrength=192,No.padLength=64,No.prototype._digest=function(t){return"hex"===t?Zn.toHex32(this.h.slice(0,7),"big"):Zn.split32(this.h.slice(0,7),"big")};var To=Zn.rotr64_hi,Co=Zn.rotr64_lo,zo=Zn.shr64_hi,Oo=Zn.shr64_lo,Ro=Zn.sum64,Po=Zn.sum64_hi,Bo=Zn.sum64_lo,Do=Zn.sum64_4_hi,$o=Zn.sum64_4_lo,Lo=Zn.sum64_5_hi,Fo=Zn.sum64_5_lo,Uo=Wn.BlockHash,qo=[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 Vo(){if(!(this instanceof Vo))return new Vo;Uo.call(this),this.h=[1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209],this.k=qo,this.W=new Array(160)}Zn.inherits(Vo,Uo);var Ho=Vo;function Go(t,e,r,i,n){var o=t&r^~t&n;return o<0&&(o+=4294967296),o}function Zo(t,e,r,i,n,o){var a=e&i^~e&o;return a<0&&(a+=4294967296),a}function Ko(t,e,r,i,n){var o=t&r^t&n^r&n;return o<0&&(o+=4294967296),o}function Jo(t,e,r,i,n,o){var a=e&i^e&o^i&o;return a<0&&(a+=4294967296),a}function Wo(t,e){var r=To(t,e,28)^To(e,t,2)^To(e,t,7);return r<0&&(r+=4294967296),r}function Yo(t,e){var r=Co(t,e,28)^Co(e,t,2)^Co(e,t,7);return r<0&&(r+=4294967296),r}function Qo(t,e){var r=To(t,e,14)^To(t,e,18)^To(e,t,9);return r<0&&(r+=4294967296),r}function Xo(t,e){var r=Co(t,e,14)^Co(t,e,18)^Co(e,t,9);return r<0&&(r+=4294967296),r}function ta(t,e){var r=To(t,e,1)^To(t,e,8)^zo(t,e,7);return r<0&&(r+=4294967296),r}function ea(t,e){var r=Co(t,e,1)^Co(t,e,8)^Oo(t,e,7);return r<0&&(r+=4294967296),r}function ra(t,e){var r=To(t,e,19)^To(e,t,29)^zo(t,e,6);return r<0&&(r+=4294967296),r}function ia(t,e){var r=Co(t,e,19)^Co(e,t,29)^Oo(t,e,6);return r<0&&(r+=4294967296),r}function na(){if(!(this instanceof na))return new na;Ho.call(this),this.h=[3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]}Vo.blockSize=1024,Vo.outSize=512,Vo.hmacStrength=192,Vo.padLength=128,Vo.prototype._prepareBlock=function(t,e){for(var r=this.W,i=0;i<32;i++)r[i]=t[e+i];for(;i<r.length;i+=2){var n=ra(r[i-4],r[i-3]),o=ia(r[i-4],r[i-3]),a=r[i-14],s=r[i-13],h=ta(r[i-30],r[i-29]),u=ea(r[i-30],r[i-29]),l=r[i-32],c=r[i-31];r[i]=Do(n,o,a,s,h,u,l,c),r[i+1]=$o(n,o,a,s,h,u,l,c)}},Vo.prototype._update=function(t,e){this._prepareBlock(t,e);var r=this.W,i=this.h[0],n=this.h[1],o=this.h[2],a=this.h[3],s=this.h[4],h=this.h[5],u=this.h[6],l=this.h[7],c=this.h[8],d=this.h[9],f=this.h[10],m=this.h[11],p=this.h[12],g=this.h[13],y=this.h[14],w=this.h[15];Fn(this.k.length===r.length);for(var v=0;v<r.length;v+=2){var b=y,k=w,M=Qo(c,d),_=Xo(c,d),E=Go(c,d,f,m,p),A=Zo(c,d,f,m,p,g),j=this.k[v],x=this.k[v+1],S=r[v],N=r[v+1],I=Lo(b,k,M,_,E,A,j,x,S,N),T=Fo(b,k,M,_,E,A,j,x,S,N);b=Wo(i,n),k=Yo(i,n),M=Ko(i,n,o,a,s),_=Jo(i,n,o,a,s,h);var C=Po(b,k,M,_),z=Bo(b,k,M,_);y=p,w=g,p=f,g=m,f=c,m=d,c=Po(u,l,I,T),d=Bo(l,l,I,T),u=s,l=h,s=o,h=a,o=i,a=n,i=Po(I,T,C,z),n=Bo(I,T,C,z)}Ro(this.h,0,i,n),Ro(this.h,2,o,a),Ro(this.h,4,s,h),Ro(this.h,6,u,l),Ro(this.h,8,c,d),Ro(this.h,10,f,m),Ro(this.h,12,p,g),Ro(this.h,14,y,w)},Vo.prototype._digest=function(t){return"hex"===t?Zn.toHex32(this.h,"big"):Zn.split32(this.h,"big")},Zn.inherits(na,Ho);var oa=na;na.blockSize=1024,na.outSize=384,na.hmacStrength=192,na.padLength=128,na.prototype._digest=function(t){return"hex"===t?Zn.toHex32(this.h.slice(0,12),"big"):Zn.split32(this.h.slice(0,12),"big")};var aa={sha1:po,sha224:Io,sha256:So,sha384:oa,sha512:Ho},sa=Zn.rotl32,ha=Zn.sum32,ua=Zn.sum32_3,la=Zn.sum32_4,ca=Wn.BlockHash;function da(){if(!(this instanceof da))return new da;ca.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.endian="little"}Zn.inherits(da,ca);var fa=da;function ma(t,e,r,i){return t<=15?e^r^i:t<=31?e&r|~e&i:t<=47?(e|~r)^i:t<=63?e&i|r&~i:e^(r|~i)}function pa(t){return t<=15?0:t<=31?1518500249:t<=47?1859775393:t<=63?2400959708:2840853838}function ga(t){return t<=15?1352829926:t<=31?1548603684:t<=47?1836072691:t<=63?2053994217:0}da.blockSize=512,da.outSize=160,da.hmacStrength=192,da.padLength=64,da.prototype._update=function(t,e){for(var r=this.h[0],i=this.h[1],n=this.h[2],o=this.h[3],a=this.h[4],s=r,h=i,u=n,l=o,c=a,d=0;d<80;d++){var f=ha(sa(la(r,ma(d,i,n,o),t[ya[d]+e],pa(d)),va[d]),a);r=a,a=o,o=sa(n,10),n=i,i=f,f=ha(sa(la(s,ma(79-d,h,u,l),t[wa[d]+e],ga(d)),ba[d]),c),s=c,c=l,l=sa(u,10),u=h,h=f}f=ua(this.h[1],n,l),this.h[1]=ua(this.h[2],o,c),this.h[2]=ua(this.h[3],a,s),this.h[3]=ua(this.h[4],r,h),this.h[4]=ua(this.h[0],i,u),this.h[0]=f},da.prototype._digest=function(t){return"hex"===t?Zn.toHex32(this.h,"little"):Zn.split32(this.h,"little")};var ya=[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],wa=[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],va=[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],ba=[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],ka={ripemd160:fa};function Ma(t,e,r){if(!(this instanceof Ma))return new Ma(t,e,r);this.Hash=t,this.blockSize=t.blockSize/8,this.outSize=t.outSize/8,this.inner=null,this.outer=null,this._init(Zn.toArray(e,r))}var _a=Ma;Ma.prototype._init=function(t){t.length>this.blockSize&&(t=(new this.Hash).update(t).digest()),Fn(t.length<=this.blockSize);for(var e=t.length;e<this.blockSize;e++)t.push(0);for(e=0;e<t.length;e++)t[e]^=54;for(this.inner=(new this.Hash).update(t),e=0;e<t.length;e++)t[e]^=106;this.outer=(new this.Hash).update(t)},Ma.prototype.update=function(t,e){return this.inner.update(t,e),this},Ma.prototype.digest=function(t){return this.outer.update(this.inner.digest()),this.outer.digest(t)};var Ea=a((function(t,e){var r=e;r.utils=Zn,r.common=Wn,r.sha=aa,r.ripemd=ka,r.hmac=_a,r.sha1=r.sha.sha1,r.sha256=r.sha.sha256,r.sha224=r.sha.sha224,r.sha384=r.sha.sha384,r.sha512=r.sha.sha512,r.ripemd160=r.ripemd.ripemd160}));function Aa(t,e,r){return r={path:e,exports:{},require:function(t,e){return function(){throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs")}(null==e&&r.path)}},t(r,r.exports),r.exports}var ja=xa;function xa(t,e){if(!t)throw new Error(e||"Assertion failed")}xa.equal=function(t,e,r){if(t!=e)throw new Error(r||"Assertion failed: "+t+" != "+e)};var Sa=Aa((function(t,e){var r=e;function i(t){return 1===t.length?"0"+t:t}function n(t){for(var e="",r=0;r<t.length;r++)e+=i(t[r].toString(16));return e}r.toArray=function(t,e){if(Array.isArray(t))return t.slice();if(!t)return[];var r=[];if("string"!=typeof t){for(var i=0;i<t.length;i++)r[i]=0|t[i];return r}if("hex"===e){(t=t.replace(/[^a-z0-9]+/gi,"")).length%2!=0&&(t="0"+t);for(i=0;i<t.length;i+=2)r.push(parseInt(t[i]+t[i+1],16))}else for(i=0;i<t.length;i++){var n=t.charCodeAt(i),o=n>>8,a=255&n;o?r.push(o,a):r.push(a)}return r},r.zero2=i,r.toHex=n,r.encode=function(t,e){return"hex"===e?n(t):t}})),Na=Aa((function(t,e){var r=e;r.assert=ja,r.toArray=Sa.toArray,r.zero2=Sa.zero2,r.toHex=Sa.toHex,r.encode=Sa.encode,r.getNAF=function(t,e,r){var i=new Array(Math.max(t.bitLength(),r)+1);i.fill(0);for(var n=1<<e+1,o=t.clone(),a=0;a<i.length;a++){var s,h=o.andln(n-1);o.isOdd()?(s=h>(n>>1)-1?(n>>1)-h:h,o.isubn(s)):s=0,i[a]=s,o.iushrn(1)}return i},r.getJSF=function(t,e){var r=[[],[]];t=t.clone(),e=e.clone();for(var i,n=0,o=0;t.cmpn(-n)>0||e.cmpn(-o)>0;){var a,s,h=t.andln(3)+n&3,u=e.andln(3)+o&3;3===h&&(h=-1),3===u&&(u=-1),a=0==(1&h)?0:3!==(i=t.andln(7)+n&7)&&5!==i||2!==u?h:-h,r[0].push(a),s=0==(1&u)?0:3!==(i=e.andln(7)+o&7)&&5!==i||2!==h?u:-u,r[1].push(s),2*n===a+1&&(n=1-n),2*o===s+1&&(o=1-o),t.iushrn(1),e.iushrn(1)}return r},r.cachedProperty=function(t,e,r){var i="_"+e;t.prototype[e]=function(){return void 0!==this[i]?this[i]:this[i]=r.call(this)}},r.parseBytes=function(t){return"string"==typeof t?r.toArray(t,"hex"):t},r.intFromLE=function(t){return new Ln(t,"hex","le")}})),Ia=Na.getNAF,Ta=Na.getJSF,Ca=Na.assert;function za(t,e){this.type=t,this.p=new Ln(e.p,16),this.red=e.prime?Ln.red(e.prime):Ln.mont(this.p),this.zero=new Ln(0).toRed(this.red),this.one=new Ln(1).toRed(this.red),this.two=new Ln(2).toRed(this.red),this.n=e.n&&new Ln(e.n,16),this.g=e.g&&this.pointFromJSON(e.g,e.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 r=this.n&&this.p.div(this.n);!r||r.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}var Oa=za;function Ra(t,e){this.curve=t,this.type=e,this.precomputed=null}za.prototype.point=function(){throw new Error("Not implemented")},za.prototype.validate=function(){throw new Error("Not implemented")},za.prototype._fixedNafMul=function(t,e){Ca(t.precomputed);var r=t._getDoubles(),i=Ia(e,1,this._bitLength),n=(1<<r.step+1)-(r.step%2==0?2:1);n/=3;var o,a,s=[];for(o=0;o<i.length;o+=r.step){a=0;for(var h=o+r.step-1;h>=o;h--)a=(a<<1)+i[h];s.push(a)}for(var u=this.jpoint(null,null,null),l=this.jpoint(null,null,null),c=n;c>0;c--){for(o=0;o<s.length;o++)(a=s[o])===c?l=l.mixedAdd(r.points[o]):a===-c&&(l=l.mixedAdd(r.points[o].neg()));u=u.add(l)}return u.toP()},za.prototype._wnafMul=function(t,e){var r=4,i=t._getNAFPoints(r);r=i.wnd;for(var n=i.points,o=Ia(e,r,this._bitLength),a=this.jpoint(null,null,null),s=o.length-1;s>=0;s--){for(var h=0;s>=0&&0===o[s];s--)h++;if(s>=0&&h++,a=a.dblp(h),s<0)break;var u=o[s];Ca(0!==u),a="affine"===t.type?u>0?a.mixedAdd(n[u-1>>1]):a.mixedAdd(n[-u-1>>1].neg()):u>0?a.add(n[u-1>>1]):a.add(n[-u-1>>1].neg())}return"affine"===t.type?a.toP():a},za.prototype._wnafMulAdd=function(t,e,r,i,n){var o,a,s,h=this._wnafT1,u=this._wnafT2,l=this._wnafT3,c=0;for(o=0;o<i;o++){var d=(s=e[o])._getNAFPoints(t);h[o]=d.wnd,u[o]=d.points}for(o=i-1;o>=1;o-=2){var f=o-1,m=o;if(1===h[f]&&1===h[m]){var p=[e[f],null,null,e[m]];0===e[f].y.cmp(e[m].y)?(p[1]=e[f].add(e[m]),p[2]=e[f].toJ().mixedAdd(e[m].neg())):0===e[f].y.cmp(e[m].y.redNeg())?(p[1]=e[f].toJ().mixedAdd(e[m]),p[2]=e[f].add(e[m].neg())):(p[1]=e[f].toJ().mixedAdd(e[m]),p[2]=e[f].toJ().mixedAdd(e[m].neg()));var g=[-3,-1,-5,-7,0,7,5,1,3],y=Ta(r[f],r[m]);for(c=Math.max(y[0].length,c),l[f]=new Array(c),l[m]=new Array(c),a=0;a<c;a++){var w=0|y[0][a],v=0|y[1][a];l[f][a]=g[3*(w+1)+(v+1)],l[m][a]=0,u[f]=p}}else l[f]=Ia(r[f],h[f],this._bitLength),l[m]=Ia(r[m],h[m],this._bitLength),c=Math.max(l[f].length,c),c=Math.max(l[m].length,c)}var b=this.jpoint(null,null,null),k=this._wnafT4;for(o=c;o>=0;o--){for(var M=0;o>=0;){var _=!0;for(a=0;a<i;a++)k[a]=0|l[a][o],0!==k[a]&&(_=!1);if(!_)break;M++,o--}if(o>=0&&M++,b=b.dblp(M),o<0)break;for(a=0;a<i;a++){var E=k[a];0!==E&&(E>0?s=u[a][E-1>>1]:E<0&&(s=u[a][-E-1>>1].neg()),b="affine"===s.type?b.mixedAdd(s):b.add(s))}}for(o=0;o<i;o++)u[o]=null;return n?b:b.toP()},za.BasePoint=Ra,Ra.prototype.eq=function(){throw new Error("Not implemented")},Ra.prototype.validate=function(){return this.curve.validate(this)},za.prototype.decodePoint=function(t,e){t=Na.toArray(t,e);var r=this.p.byteLength();if((4===t[0]||6===t[0]||7===t[0])&&t.length-1==2*r)return 6===t[0]?Ca(t[t.length-1]%2==0):7===t[0]&&Ca(t[t.length-1]%2==1),this.point(t.slice(1,1+r),t.slice(1+r,1+2*r));if((2===t[0]||3===t[0])&&t.length-1===r)return this.pointFromX(t.slice(1,1+r),3===t[0]);throw new Error("Unknown point format")},Ra.prototype.encodeCompressed=function(t){return this.encode(t,!0)},Ra.prototype._encode=function(t){var e=this.curve.p.byteLength(),r=this.getX().toArray("be",e);return t?[this.getY().isEven()?2:3].concat(r):[4].concat(r,this.getY().toArray("be",e))},Ra.prototype.encode=function(t,e){return Na.encode(this._encode(e),t)},Ra.prototype.precompute=function(t){if(this.precomputed)return this;var e={doubles:null,naf:null,beta:null};return e.naf=this._getNAFPoints(8),e.doubles=this._getDoubles(4,t),e.beta=this._getBeta(),this.precomputed=e,this},Ra.prototype._hasDoubles=function(t){if(!this.precomputed)return!1;var e=this.precomputed.doubles;return!!e&&e.points.length>=Math.ceil((t.bitLength()+1)/e.step)},Ra.prototype._getDoubles=function(t,e){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var r=[this],i=this,n=0;n<e;n+=t){for(var o=0;o<t;o++)i=i.dbl();r.push(i)}return{step:t,points:r}},Ra.prototype._getNAFPoints=function(t){if(this.precomputed&&this.precomputed.naf)return this.precomputed.naf;for(var e=[this],r=(1<<t)-1,i=1===r?null:this.dbl(),n=1;n<r;n++)e[n]=e[n-1].add(i);return{wnd:t,points:e}},Ra.prototype._getBeta=function(){return null},Ra.prototype.dblp=function(t){for(var e=this,r=0;r<t;r++)e=e.dbl();return e};var Pa=Aa((function(t){"function"==typeof Object.create?t.exports=function(t,e){e&&(t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}))}:t.exports=function(t,e){if(e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}}})),Ba=Na.assert;function Da(t){Oa.call(this,"short",t),this.a=new Ln(t.a,16).toRed(this.red),this.b=new Ln(t.b,16).toRed(this.red),this.tinv=this.two.redInvm(),this.zeroA=0===this.a.fromRed().cmpn(0),this.threeA=0===this.a.fromRed().sub(this.p).cmpn(-3),this.endo=this._getEndomorphism(t),this._endoWnafT1=new Array(4),this._endoWnafT2=new Array(4)}Pa(Da,Oa);var $a=Da;function La(t,e,r,i){Oa.BasePoint.call(this,t,"affine"),null===e&&null===r?(this.x=null,this.y=null,this.inf=!0):(this.x=new Ln(e,16),this.y=new Ln(r,16),i&&(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)}function Fa(t,e,r,i){Oa.BasePoint.call(this,t,"jacobian"),null===e&&null===r&&null===i?(this.x=this.curve.one,this.y=this.curve.one,this.z=new Ln(0)):(this.x=new Ln(e,16),this.y=new Ln(r,16),this.z=new Ln(i,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}Da.prototype._getEndomorphism=function(t){if(this.zeroA&&this.g&&this.n&&1===this.p.modn(3)){var e,r;if(t.beta)e=new Ln(t.beta,16).toRed(this.red);else{var i=this._getEndoRoots(this.p);e=(e=i[0].cmp(i[1])<0?i[0]:i[1]).toRed(this.red)}if(t.lambda)r=new Ln(t.lambda,16);else{var n=this._getEndoRoots(this.n);0===this.g.mul(n[0]).x.cmp(this.g.x.redMul(e))?r=n[0]:(r=n[1],Ba(0===this.g.mul(r).x.cmp(this.g.x.redMul(e))))}return{beta:e,lambda:r,basis:t.basis?t.basis.map((function(t){return{a:new Ln(t.a,16),b:new Ln(t.b,16)}})):this._getEndoBasis(r)}}},Da.prototype._getEndoRoots=function(t){var e=t===this.p?this.red:Ln.mont(t),r=new Ln(2).toRed(e).redInvm(),i=r.redNeg(),n=new Ln(3).toRed(e).redNeg().redSqrt().redMul(r);return[i.redAdd(n).fromRed(),i.redSub(n).fromRed()]},Da.prototype._getEndoBasis=function(t){for(var e,r,i,n,o,a,s,h,u,l=this.n.ushrn(Math.floor(this.n.bitLength()/2)),c=t,d=this.n.clone(),f=new Ln(1),m=new Ln(0),p=new Ln(0),g=new Ln(1),y=0;0!==c.cmpn(0);){var w=d.div(c);h=d.sub(w.mul(c)),u=p.sub(w.mul(f));var v=g.sub(w.mul(m));if(!i&&h.cmp(l)<0)e=s.neg(),r=f,i=h.neg(),n=u;else if(i&&2==++y)break;s=h,d=c,c=h,p=f,f=u,g=m,m=v}o=h.neg(),a=u;var b=i.sqr().add(n.sqr());return o.sqr().add(a.sqr()).cmp(b)>=0&&(o=e,a=r),i.negative&&(i=i.neg(),n=n.neg()),o.negative&&(o=o.neg(),a=a.neg()),[{a:i,b:n},{a:o,b:a}]},Da.prototype._endoSplit=function(t){var e=this.endo.basis,r=e[0],i=e[1],n=i.b.mul(t).divRound(this.n),o=r.b.neg().mul(t).divRound(this.n),a=n.mul(r.a),s=o.mul(i.a),h=n.mul(r.b),u=o.mul(i.b);return{k1:t.sub(a).sub(s),k2:h.add(u).neg()}},Da.prototype.pointFromX=function(t,e){(t=new Ln(t,16)).red||(t=t.toRed(this.red));var r=t.redSqr().redMul(t).redIAdd(t.redMul(this.a)).redIAdd(this.b),i=r.redSqrt();if(0!==i.redSqr().redSub(r).cmp(this.zero))throw new Error("invalid point");var n=i.fromRed().isOdd();return(e&&!n||!e&&n)&&(i=i.redNeg()),this.point(t,i)},Da.prototype.validate=function(t){if(t.inf)return!0;var e=t.x,r=t.y,i=this.a.redMul(e),n=e.redSqr().redMul(e).redIAdd(i).redIAdd(this.b);return 0===r.redSqr().redISub(n).cmpn(0)},Da.prototype._endoWnafMulAdd=function(t,e,r){for(var i=this._endoWnafT1,n=this._endoWnafT2,o=0;o<t.length;o++){var a=this._endoSplit(e[o]),s=t[o],h=s._getBeta();a.k1.negative&&(a.k1.ineg(),s=s.neg(!0)),a.k2.negative&&(a.k2.ineg(),h=h.neg(!0)),i[2*o]=s,i[2*o+1]=h,n[2*o]=a.k1,n[2*o+1]=a.k2}for(var u=this._wnafMulAdd(1,i,n,2*o,r),l=0;l<2*o;l++)i[l]=null,n[l]=null;return u},Pa(La,Oa.BasePoint),Da.prototype.point=function(t,e,r){return new La(this,t,e,r)},Da.prototype.pointFromJSON=function(t,e){return La.fromJSON(this,t,e)},La.prototype._getBeta=function(){if(this.curve.endo){var t=this.precomputed;if(t&&t.beta)return t.beta;var e=this.curve.point(this.x.redMul(this.curve.endo.beta),this.y);if(t){var r=this.curve,i=function(t){return r.point(t.x.redMul(r.endo.beta),t.y)};t.beta=e,e.precomputed={beta:null,naf:t.naf&&{wnd:t.naf.wnd,points:t.naf.points.map(i)},doubles:t.doubles&&{step:t.doubles.step,points:t.doubles.points.map(i)}}}return e}},La.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]},La.fromJSON=function(t,e,r){"string"==typeof e&&(e=JSON.parse(e));var i=t.point(e[0],e[1],r);if(!e[2])return i;function n(e){return t.point(e[0],e[1],r)}var o=e[2];return i.precomputed={beta:null,doubles:o.doubles&&{step:o.doubles.step,points:[i].concat(o.doubles.points.map(n))},naf:o.naf&&{wnd:o.naf.wnd,points:[i].concat(o.naf.points.map(n))}},i},La.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)+">"},La.prototype.isInfinity=function(){return this.inf},La.prototype.add=function(t){if(this.inf)return t;if(t.inf)return this;if(this.eq(t))return this.dbl();if(this.neg().eq(t))return this.curve.point(null,null);if(0===this.x.cmp(t.x))return this.curve.point(null,null);var e=this.y.redSub(t.y);0!==e.cmpn(0)&&(e=e.redMul(this.x.redSub(t.x).redInvm()));var r=e.redSqr().redISub(this.x).redISub(t.x),i=e.redMul(this.x.redSub(r)).redISub(this.y);return this.curve.point(r,i)},La.prototype.dbl=function(){if(this.inf)return this;var t=this.y.redAdd(this.y);if(0===t.cmpn(0))return this.curve.point(null,null);var e=this.curve.a,r=this.x.redSqr(),i=t.redInvm(),n=r.redAdd(r).redIAdd(r).redIAdd(e).redMul(i),o=n.redSqr().redISub(this.x.redAdd(this.x)),a=n.redMul(this.x.redSub(o)).redISub(this.y);return this.curve.point(o,a)},La.prototype.getX=function(){return this.x.fromRed()},La.prototype.getY=function(){return this.y.fromRed()},La.prototype.mul=function(t){return t=new Ln(t,16),this.isInfinity()?this:this._hasDoubles(t)?this.curve._fixedNafMul(this,t):this.curve.endo?this.curve._endoWnafMulAdd([this],[t]):this.curve._wnafMul(this,t)},La.prototype.mulAdd=function(t,e,r){var i=[this,e],n=[t,r];return this.curve.endo?this.curve._endoWnafMulAdd(i,n):this.curve._wnafMulAdd(1,i,n,2)},La.prototype.jmulAdd=function(t,e,r){var i=[this,e],n=[t,r];return this.curve.endo?this.curve._endoWnafMulAdd(i,n,!0):this.curve._wnafMulAdd(1,i,n,2,!0)},La.prototype.eq=function(t){return this===t||this.inf===t.inf&&(this.inf||0===this.x.cmp(t.x)&&0===this.y.cmp(t.y))},La.prototype.neg=function(t){if(this.inf)return this;var e=this.curve.point(this.x,this.y.redNeg());if(t&&this.precomputed){var r=this.precomputed,i=function(t){return t.neg()};e.precomputed={naf:r.naf&&{wnd:r.naf.wnd,points:r.naf.points.map(i)},doubles:r.doubles&&{step:r.doubles.step,points:r.doubles.points.map(i)}}}return e},La.prototype.toJ=function(){return this.inf?this.curve.jpoint(null,null,null):this.curve.jpoint(this.x,this.y,this.curve.one)},Pa(Fa,Oa.BasePoint),Da.prototype.jpoint=function(t,e,r){return new Fa(this,t,e,r)},Fa.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var t=this.z.redInvm(),e=t.redSqr(),r=this.x.redMul(e),i=this.y.redMul(e).redMul(t);return this.curve.point(r,i)},Fa.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},Fa.prototype.add=function(t){if(this.isInfinity())return t;if(t.isInfinity())return this;var e=t.z.redSqr(),r=this.z.redSqr(),i=this.x.redMul(e),n=t.x.redMul(r),o=this.y.redMul(e.redMul(t.z)),a=t.y.redMul(r.redMul(this.z)),s=i.redSub(n),h=o.redSub(a);if(0===s.cmpn(0))return 0!==h.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var u=s.redSqr(),l=u.redMul(s),c=i.redMul(u),d=h.redSqr().redIAdd(l).redISub(c).redISub(c),f=h.redMul(c.redISub(d)).redISub(o.redMul(l)),m=this.z.redMul(t.z).redMul(s);return this.curve.jpoint(d,f,m)},Fa.prototype.mixedAdd=function(t){if(this.isInfinity())return t.toJ();if(t.isInfinity())return this;var e=this.z.redSqr(),r=this.x,i=t.x.redMul(e),n=this.y,o=t.y.redMul(e).redMul(this.z),a=r.redSub(i),s=n.redSub(o);if(0===a.cmpn(0))return 0!==s.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var h=a.redSqr(),u=h.redMul(a),l=r.redMul(h),c=s.redSqr().redIAdd(u).redISub(l).redISub(l),d=s.redMul(l.redISub(c)).redISub(n.redMul(u)),f=this.z.redMul(a);return this.curve.jpoint(c,d,f)},Fa.prototype.dblp=function(t){if(0===t)return this;if(this.isInfinity())return this;if(!t)return this.dbl();var e;if(this.curve.zeroA||this.curve.threeA){var r=this;for(e=0;e<t;e++)r=r.dbl();return r}var i=this.curve.a,n=this.curve.tinv,o=this.x,a=this.y,s=this.z,h=s.redSqr().redSqr(),u=a.redAdd(a);for(e=0;e<t;e++){var l=o.redSqr(),c=u.redSqr(),d=c.redSqr(),f=l.redAdd(l).redIAdd(l).redIAdd(i.redMul(h)),m=o.redMul(c),p=f.redSqr().redISub(m.redAdd(m)),g=m.redISub(p),y=f.redMul(g);y=y.redIAdd(y).redISub(d);var w=u.redMul(s);e+1<t&&(h=h.redMul(d)),o=p,s=w,u=y}return this.curve.jpoint(o,u.redMul(n),s)},Fa.prototype.dbl=function(){return this.isInfinity()?this:this.curve.zeroA?this._zeroDbl():this.curve.threeA?this._threeDbl():this._dbl()},Fa.prototype._zeroDbl=function(){var t,e,r;if(this.zOne){var i=this.x.redSqr(),n=this.y.redSqr(),o=n.redSqr(),a=this.x.redAdd(n).redSqr().redISub(i).redISub(o);a=a.redIAdd(a);var s=i.redAdd(i).redIAdd(i),h=s.redSqr().redISub(a).redISub(a),u=o.redIAdd(o);u=(u=u.redIAdd(u)).redIAdd(u),t=h,e=s.redMul(a.redISub(h)).redISub(u),r=this.y.redAdd(this.y)}else{var l=this.x.redSqr(),c=this.y.redSqr(),d=c.redSqr(),f=this.x.redAdd(c).redSqr().redISub(l).redISub(d);f=f.redIAdd(f);var m=l.redAdd(l).redIAdd(l),p=m.redSqr(),g=d.redIAdd(d);g=(g=g.redIAdd(g)).redIAdd(g),t=p.redISub(f).redISub(f),e=m.redMul(f.redISub(t)).redISub(g),r=(r=this.y.redMul(this.z)).redIAdd(r)}return this.curve.jpoint(t,e,r)},Fa.prototype._threeDbl=function(){var t,e,r;if(this.zOne){var i=this.x.redSqr(),n=this.y.redSqr(),o=n.redSqr(),a=this.x.redAdd(n).redSqr().redISub(i).redISub(o);a=a.redIAdd(a);var s=i.redAdd(i).redIAdd(i).redIAdd(this.curve.a),h=s.redSqr().redISub(a).redISub(a);t=h;var u=o.redIAdd(o);u=(u=u.redIAdd(u)).redIAdd(u),e=s.redMul(a.redISub(h)).redISub(u),r=this.y.redAdd(this.y)}else{var l=this.z.redSqr(),c=this.y.redSqr(),d=this.x.redMul(c),f=this.x.redSub(l).redMul(this.x.redAdd(l));f=f.redAdd(f).redIAdd(f);var m=d.redIAdd(d),p=(m=m.redIAdd(m)).redAdd(m);t=f.redSqr().redISub(p),r=this.y.redAdd(this.z).redSqr().redISub(c).redISub(l);var g=c.redSqr();g=(g=(g=g.redIAdd(g)).redIAdd(g)).redIAdd(g),e=f.redMul(m.redISub(t)).redISub(g)}return this.curve.jpoint(t,e,r)},Fa.prototype._dbl=function(){var t=this.curve.a,e=this.x,r=this.y,i=this.z,n=i.redSqr().redSqr(),o=e.redSqr(),a=r.redSqr(),s=o.redAdd(o).redIAdd(o).redIAdd(t.redMul(n)),h=e.redAdd(e),u=(h=h.redIAdd(h)).redMul(a),l=s.redSqr().redISub(u.redAdd(u)),c=u.redISub(l),d=a.redSqr();d=(d=(d=d.redIAdd(d)).redIAdd(d)).redIAdd(d);var f=s.redMul(c).redISub(d),m=r.redAdd(r).redMul(i);return this.curve.jpoint(l,f,m)},Fa.prototype.trpl=function(){if(!this.curve.zeroA)return this.dbl().add(this);var t=this.x.redSqr(),e=this.y.redSqr(),r=this.z.redSqr(),i=e.redSqr(),n=t.redAdd(t).redIAdd(t),o=n.redSqr(),a=this.x.redAdd(e).redSqr().redISub(t).redISub(i),s=(a=(a=(a=a.redIAdd(a)).redAdd(a).redIAdd(a)).redISub(o)).redSqr(),h=i.redIAdd(i);h=(h=(h=h.redIAdd(h)).redIAdd(h)).redIAdd(h);var u=n.redIAdd(a).redSqr().redISub(o).redISub(s).redISub(h),l=e.redMul(u);l=(l=l.redIAdd(l)).redIAdd(l);var c=this.x.redMul(s).redISub(l);c=(c=c.redIAdd(c)).redIAdd(c);var d=this.y.redMul(u.redMul(h.redISub(u)).redISub(a.redMul(s)));d=(d=(d=d.redIAdd(d)).redIAdd(d)).redIAdd(d);var f=this.z.redAdd(a).redSqr().redISub(r).redISub(s);return this.curve.jpoint(c,d,f)},Fa.prototype.mul=function(t,e){return t=new Ln(t,e),this.curve._wnafMul(this,t)},Fa.prototype.eq=function(t){if("affine"===t.type)return this.eq(t.toJ());if(this===t)return!0;var e=this.z.redSqr(),r=t.z.redSqr();if(0!==this.x.redMul(r).redISub(t.x.redMul(e)).cmpn(0))return!1;var i=e.redMul(this.z),n=r.redMul(t.z);return 0===this.y.redMul(n).redISub(t.y.redMul(i)).cmpn(0)},Fa.prototype.eqXToP=function(t){var e=this.z.redSqr(),r=t.toRed(this.curve.red).redMul(e);if(0===this.x.cmp(r))return!0;for(var i=t.clone(),n=this.curve.redN.redMul(e);;){if(i.iadd(this.curve.n),i.cmp(this.curve.p)>=0)return!1;if(r.redIAdd(n),0===this.x.cmp(r))return!0}},Fa.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)+">"},Fa.prototype.isInfinity=function(){return 0===this.z.cmpn(0)};var Ua=Aa((function(t,e){var r=e;r.base=Oa,r.short=$a,r.mont=null,r.edwards=null})),qa=Aa((function(t,e){var r,i=e,n=Na.assert;function o(t){"short"===t.type?this.curve=new Ua.short(t):"edwards"===t.type?this.curve=new Ua.edwards(t):this.curve=new Ua.mont(t),this.g=this.curve.g,this.n=this.curve.n,this.hash=t.hash,n(this.g.validate(),"Invalid curve"),n(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}function a(t,e){Object.defineProperty(i,t,{configurable:!0,enumerable:!0,get:function(){var r=new o(e);return Object.defineProperty(i,t,{configurable:!0,enumerable:!0,value:r}),r}})}i.PresetCurve=o,a("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:Ea.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]}),a("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:Ea.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]}),a("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:Ea.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]}),a("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:Ea.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"]}),a("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:Ea.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"]}),a("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:Ea.sha256,gRed:!1,g:["9"]}),a("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:Ea.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});try{r=null.crash()}catch(t){r=void 0}a("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:Ea.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",r]})}));function Va(t){if(!(this instanceof Va))return new Va(t);this.hash=t.hash,this.predResist=!!t.predResist,this.outLen=this.hash.outSize,this.minEntropy=t.minEntropy||this.hash.hmacStrength,this._reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var e=Sa.toArray(t.entropy,t.entropyEnc||"hex"),r=Sa.toArray(t.nonce,t.nonceEnc||"hex"),i=Sa.toArray(t.pers,t.persEnc||"hex");ja(e.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(e,r,i)}var Ha=Va;Va.prototype._init=function(t,e,r){var i=t.concat(e).concat(r);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var n=0;n<this.V.length;n++)this.K[n]=0,this.V[n]=1;this._update(i),this._reseed=1,this.reseedInterval=281474976710656},Va.prototype._hmac=function(){return new Ea.hmac(this.hash,this.K)},Va.prototype._update=function(t){var e=this._hmac().update(this.V).update([0]);t&&(e=e.update(t)),this.K=e.digest(),this.V=this._hmac().update(this.V).digest(),t&&(this.K=this._hmac().update(this.V).update([1]).update(t).digest(),this.V=this._hmac().update(this.V).digest())},Va.prototype.reseed=function(t,e,r,i){"string"!=typeof e&&(i=r,r=e,e=null),t=Sa.toArray(t,e),r=Sa.toArray(r,i),ja(t.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(t.concat(r||[])),this._reseed=1},Va.prototype.generate=function(t,e,r,i){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");"string"!=typeof e&&(i=r,r=e,e=null),r&&(r=Sa.toArray(r,i||"hex"),this._update(r));for(var n=[];n.length<t;)this.V=this._hmac().update(this.V).digest(),n=n.concat(this.V);var o=n.slice(0,t);return this._update(r),this._reseed++,Sa.encode(o,e)};var Ga=Na.assert;function Za(t,e){this.ec=t,this.priv=null,this.pub=null,e.priv&&this._importPrivate(e.priv,e.privEnc),e.pub&&this._importPublic(e.pub,e.pubEnc)}var Ka=Za;Za.fromPublic=function(t,e,r){return e instanceof Za?e:new Za(t,{pub:e,pubEnc:r})},Za.fromPrivate=function(t,e,r){return e instanceof Za?e:new Za(t,{priv:e,privEnc:r})},Za.prototype.validate=function(){var t=this.getPublic();return t.isInfinity()?{result:!1,reason:"Invalid public key"}:t.validate()?t.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"}},Za.prototype.getPublic=function(t,e){return"string"==typeof t&&(e=t,t=null),this.pub||(this.pub=this.ec.g.mul(this.priv)),e?this.pub.encode(e,t):this.pub},Za.prototype.getPrivate=function(t){return"hex"===t?this.priv.toString(16,2):this.priv},Za.prototype._importPrivate=function(t,e){this.priv=new Ln(t,e||16),this.priv=this.priv.umod(this.ec.curve.n)},Za.prototype._importPublic=function(t,e){if(t.x||t.y)return"mont"===this.ec.curve.type?Ga(t.x,"Need x coordinate"):"short"!==this.ec.curve.type&&"edwards"!==this.ec.curve.type||Ga(t.x&&t.y,"Need both x and y coordinate"),void(this.pub=this.ec.curve.point(t.x,t.y));this.pub=this.ec.curve.decodePoint(t,e)},Za.prototype.derive=function(t){return t.validate()||Ga(t.validate(),"public point not validated"),t.mul(this.priv).getX()},Za.prototype.sign=function(t,e,r){return this.ec.sign(t,this,e,r)},Za.prototype.verify=function(t,e){return this.ec.verify(t,e,this)},Za.prototype.inspect=function(){return"<Key priv: "+(this.priv&&this.priv.toString(16,2))+" pub: "+(this.pub&&this.pub.inspect())+" >"};var Ja=Na.assert;function Wa(t,e){if(t instanceof Wa)return t;this._importDER(t,e)||(Ja(t.r&&t.s,"Signature without r or s"),this.r=new Ln(t.r,16),this.s=new Ln(t.s,16),void 0===t.recoveryParam?this.recoveryParam=null:this.recoveryParam=t.recoveryParam)}var Ya=Wa;function Qa(){this.place=0}function Xa(t,e){var r=t[e.place++];if(!(128&r))return r;var i=15&r;if(0===i||i>4)return!1;for(var n=0,o=0,a=e.place;o<i;o++,a++)n<<=8,n|=t[a],n>>>=0;return!(n<=127)&&(e.place=a,n)}function ts(t){for(var e=0,r=t.length-1;!t[e]&&!(128&t[e+1])&&e<r;)e++;return 0===e?t:t.slice(e)}function es(t,e){if(e<128)t.push(e);else{var r=1+(Math.log(e)/Math.LN2>>>3);for(t.push(128|r);--r;)t.push(e>>>(r<<3)&255);t.push(e)}}Wa.prototype._importDER=function(t,e){t=Na.toArray(t,e);var r=new Qa;if(48!==t[r.place++])return!1;var i=Xa(t,r);if(!1===i)return!1;if(i+r.place!==t.length)return!1;if(2!==t[r.place++])return!1;var n=Xa(t,r);if(!1===n)return!1;var o=t.slice(r.place,n+r.place);if(r.place+=n,2!==t[r.place++])return!1;var a=Xa(t,r);if(!1===a)return!1;if(t.length!==a+r.place)return!1;var s=t.slice(r.place,a+r.place);if(0===o[0]){if(!(128&o[1]))return!1;o=o.slice(1)}if(0===s[0]){if(!(128&s[1]))return!1;s=s.slice(1)}return this.r=new Ln(o),this.s=new Ln(s),this.recoveryParam=null,!0},Wa.prototype.toDER=function(t){var e=this.r.toArray(),r=this.s.toArray();for(128&e[0]&&(e=[0].concat(e)),128&r[0]&&(r=[0].concat(r)),e=ts(e),r=ts(r);!(r[0]||128&r[1]);)r=r.slice(1);var i=[2];es(i,e.length),(i=i.concat(e)).push(2),es(i,r.length);var n=i.concat(r),o=[48];return es(o,n.length),o=o.concat(n),Na.encode(o,t)};var rs=function(){throw new Error("unsupported")},is=Na.assert;function ns(t){if(!(this instanceof ns))return new ns(t);"string"==typeof t&&(is(Object.prototype.hasOwnProperty.call(qa,t),"Unknown curve "+t),t=qa[t]),t instanceof qa.PresetCurve&&(t={curve:t}),this.curve=t.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=t.curve.g,this.g.precompute(t.curve.n.bitLength()+1),this.hash=t.hash||t.curve.hash}var os=ns;ns.prototype.keyPair=function(t){return new Ka(this,t)},ns.prototype.keyFromPrivate=function(t,e){return Ka.fromPrivate(this,t,e)},ns.prototype.keyFromPublic=function(t,e){return Ka.fromPublic(this,t,e)},ns.prototype.genKeyPair=function(t){t||(t={});for(var e=new Ha({hash:this.hash,pers:t.pers,persEnc:t.persEnc||"utf8",entropy:t.entropy||rs(this.hash.hmacStrength),entropyEnc:t.entropy&&t.entropyEnc||"utf8",nonce:this.n.toArray()}),r=this.n.byteLength(),i=this.n.sub(new Ln(2));;){var n=new Ln(e.generate(r));if(!(n.cmp(i)>0))return n.iaddn(1),this.keyFromPrivate(n)}},ns.prototype._truncateToN=function(t,e){var r=8*t.byteLength()-this.n.bitLength();return r>0&&(t=t.ushrn(r)),!e&&t.cmp(this.n)>=0?t.sub(this.n):t},ns.prototype.sign=function(t,e,r,i){"object"==typeof r&&(i=r,r=null),i||(i={}),e=this.keyFromPrivate(e,r),t=this._truncateToN(new Ln(t,16));for(var n=this.n.byteLength(),o=e.getPrivate().toArray("be",n),a=t.toArray("be",n),s=new Ha({hash:this.hash,entropy:o,nonce:a,pers:i.pers,persEnc:i.persEnc||"utf8"}),h=this.n.sub(new Ln(1)),u=0;;u++){var l=i.k?i.k(u):new Ln(s.generate(this.n.byteLength()));if(!((l=this._truncateToN(l,!0)).cmpn(1)<=0||l.cmp(h)>=0)){var c=this.g.mul(l);if(!c.isInfinity()){var d=c.getX(),f=d.umod(this.n);if(0!==f.cmpn(0)){var m=l.invm(this.n).mul(f.mul(e.getPrivate()).iadd(t));if(0!==(m=m.umod(this.n)).cmpn(0)){var p=(c.getY().isOdd()?1:0)|(0!==d.cmp(f)?2:0);return i.canonical&&m.cmp(this.nh)>0&&(m=this.n.sub(m),p^=1),new Ya({r:f,s:m,recoveryParam:p})}}}}}},ns.prototype.verify=function(t,e,r,i){t=this._truncateToN(new Ln(t,16)),r=this.keyFromPublic(r,i);var n=(e=new Ya(e,"hex")).r,o=e.s;if(n.cmpn(1)<0||n.cmp(this.n)>=0)return!1;if(o.cmpn(1)<0||o.cmp(this.n)>=0)return!1;var a,s=o.invm(this.n),h=s.mul(t).umod(this.n),u=s.mul(n).umod(this.n);return this.curve._maxwellTrick?!(a=this.g.jmulAdd(h,r.getPublic(),u)).isInfinity()&&a.eqXToP(n):!(a=this.g.mulAdd(h,r.getPublic(),u)).isInfinity()&&0===a.getX().umod(this.n).cmp(n)},ns.prototype.recoverPubKey=function(t,e,r,i){is((3&r)===r,"The recovery param is more than two bits"),e=new Ya(e,i);var n=this.n,o=new Ln(t),a=e.r,s=e.s,h=1&r,u=r>>1;if(a.cmp(this.curve.p.umod(this.curve.n))>=0&&u)throw new Error("Unable to find sencond key candinate");a=u?this.curve.pointFromX(a.add(this.curve.n),h):this.curve.pointFromX(a,h);var l=e.r.invm(n),c=n.sub(o).mul(l).umod(n),d=s.mul(l).umod(n);return this.g.mulAdd(c,a,d)},ns.prototype.getKeyRecoveryParam=function(t,e,r,i){if(null!==(e=new Ya(e,i)).recoveryParam)return e.recoveryParam;for(var n=0;n<4;n++){var o;try{o=this.recoverPubKey(t,e,n)}catch(t){continue}if(o.eq(r))return n}throw new Error("Unable to find valid recovery factor")};var as=Aa((function(t,e){var r=e;r.version="6.5.4",r.utils=Na,r.rand=function(){throw new Error("unsupported")},r.curve=Ua,r.curves=qa,r.ec=os,r.eddsa=null})).ec;const ss=new w("signing-key/5.6.2");let hs=null;function us(){return hs||(hs=new as("secp256k1")),hs}class ls{constructor(t){ir(this,"curve","secp256k1"),ir(this,"privateKey",I(t)),32!==T(this.privateKey)&&ss.throwArgumentError("invalid private key","privateKey","[[ REDACTED ]]");const e=us().keyFromPrivate(A(this.privateKey));ir(this,"publicKey","0x"+e.getPublic(!1,"hex")),ir(this,"compressedPublicKey","0x"+e.getPublic(!0,"hex")),ir(this,"_isSigningKey",!0)}_addPoint(t){const e=us().keyFromPublic(A(this.publicKey)),r=us().keyFromPublic(A(t));return"0x"+e.pub.add(r.pub).encodeCompressed("hex")}signDigest(t){const e=us().keyFromPrivate(A(this.privateKey)),r=A(t);32!==r.length&&ss.throwArgumentError("bad digest length","digest",t);const i=e.sign(r,{canonical:!0});return P({recoveryParam:i.recoveryParam,r:R("0x"+i.r.toString(16),32),s:R("0x"+i.s.toString(16),32)})}computeSharedSecret(t){const e=us().keyFromPrivate(A(this.privateKey)),r=us().keyFromPublic(A(cs(t)));return R("0x"+e.derive(r.getPublic()).toString(16),32)}static isSigningKey(t){return!(!t||!t._isSigningKey)}}function cs(t,e){const r=A(t);if(32===r.length){const t=new ls(r);return e?"0x"+us().keyFromPrivate(r).getPublic(!0,"hex"):t.publicKey}return 33===r.length?e?I(r):"0x"+us().keyFromPublic(r).getPublic(!1,"hex"):65===r.length?e?"0x"+us().keyFromPublic(r).getPublic(!0,"hex"):I(r):ss.throwArgumentError("invalid public or private key","key","[REDACTED]")}const ds=new w("transactions/5.6.2");var fs;function ms(t){return"0x"===t?null:he(t)}function ps(t){return"0x"===t?ui:Rn.from(t)}function gs(t,e){return function(t){return he(C(Jt(C(cs(t),1)),12))}(function(t,e){const r=P(e),i={r:A(r.r),s:A(r.s)};return"0x"+us().recoverPubKey(A(t),i,r.recoveryParam).encode("hex",!1)}(A(t),e))}function ys(t,e){const r=x(Rn.from(t).toHexString());return r.length>32&&ds.throwArgumentError("invalid length for "+e,"transaction:"+e,t),r}function ws(t,e){return{address:he(t),storageKeys:(e||[]).map(((e,r)=>(32!==T(e)&&ds.throwArgumentError("invalid access list storageKey",`accessList[${t}:${r}]`,e),e.toLowerCase())))}}function vs(t){if(Array.isArray(t))return t.map(((t,e)=>Array.isArray(t)?(t.length>2&&ds.throwArgumentError("access list expected to be [ address, storageKeys[] ]",`value[${e}]`,t),ws(t[0],t[1])):ws(t.address,t.storageKeys)));const e=Object.keys(t).map((e=>{const r=t[e].reduce(((t,e)=>(t[e]=!0,t)),{});return ws(e,Object.keys(r).sort())}));return e.sort(((t,e)=>t.address.localeCompare(e.address))),e}function bs(t){return vs(t).map((t=>[t.address,t.storageKeys]))}function ks(t,e){if(null!=t.gasPrice){const e=Rn.from(t.gasPrice),r=Rn.from(t.maxFeePerGas||0);e.eq(r)||ds.throwArgumentError("mismatch EIP-1559 gasPrice != maxFeePerGas","tx",{gasPrice:e,maxFeePerGas:r})}const r=[ys(t.chainId||0,"chainId"),ys(t.nonce||0,"nonce"),ys(t.maxPriorityFeePerGas||0,"maxPriorityFeePerGas"),ys(t.maxFeePerGas||0,"maxFeePerGas"),ys(t.gasLimit||0,"gasLimit"),null!=t.to?he(t.to):"0x",ys(t.value||0,"value"),t.data||"0x",bs(t.accessList||[])];if(e){const t=P(e);r.push(ys(t.recoveryParam,"recoveryParam")),r.push(x(t.r)),r.push(x(t.s))}return z(["0x02",te(r)])}function Ms(t,e){const r=[ys(t.chainId||0,"chainId"),ys(t.nonce||0,"nonce"),ys(t.gasPrice||0,"gasPrice"),ys(t.gasLimit||0,"gasLimit"),null!=t.to?he(t.to):"0x",ys(t.value||0,"value"),t.data||"0x",bs(t.accessList||[])];if(e){const t=P(e);r.push(ys(t.recoveryParam,"recoveryParam")),r.push(x(t.r)),r.push(x(t.s))}return z(["0x01",te(r)])}function _s(t,e,r){try{const r=ps(e[0]).toNumber();if(0!==r&&1!==r)throw new Error("bad recid");t.v=r}catch(t){ds.throwArgumentError("invalid v for transaction type: 1","v",e[0])}t.r=R(e[1],32),t.s=R(e[2],32);try{const e=Jt(r(t));t.from=gs(e,{r:t.r,s:t.s,recoveryParam:t.v})}catch(t){}}function Es(t){const e=A(t);if(e[0]>127)return function(t){const e=ie(t);9!==e.length&&6!==e.length&&ds.throwArgumentError("invalid raw transaction","rawTransaction",t);const r={nonce:ps(e[0]).toNumber(),gasPrice:ps(e[1]),gasLimit:ps(e[2]),to:ms(e[3]),value:ps(e[4]),data:e[5],chainId:0};if(6===e.length)return r;try{r.v=Rn.from(e[6]).toNumber()}catch(t){return r}if(r.r=R(e[7],32),r.s=R(e[8],32),Rn.from(r.r).isZero()&&Rn.from(r.s).isZero())r.chainId=r.v,r.v=0;else{r.chainId=Math.floor((r.v-35)/2),r.chainId<0&&(r.chainId=0);let i=r.v-27;const n=e.slice(0,6);0!==r.chainId&&(n.push(I(r.chainId)),n.push("0x"),n.push("0x"),i-=2*r.chainId+8);const o=Jt(te(n));try{r.from=gs(o,{r:I(r.r),s:I(r.s),recoveryParam:i})}catch(t){}r.hash=Jt(t)}return r.type=null,r}(e);switch(e[0]){case 1:return function(t){const e=ie(t.slice(1));8!==e.length&&11!==e.length&&ds.throwArgumentError("invalid component count for transaction type: 1","payload",I(t));const r={type:1,chainId:ps(e[0]).toNumber(),nonce:ps(e[1]).toNumber(),gasPrice:ps(e[2]),gasLimit:ps(e[3]),to:ms(e[4]),value:ps(e[5]),data:e[6],accessList:vs(e[7])};return 8===e.length||(r.hash=Jt(t),_s(r,e.slice(8),Ms)),r}(e);case 2:return function(t){const e=ie(t.slice(1));9!==e.length&&12!==e.length&&ds.throwArgumentError("invalid component count for transaction type: 2","payload",I(t));const r=ps(e[2]),i=ps(e[3]),n={type:2,chainId:ps(e[0]).toNumber(),nonce:ps(e[1]).toNumber(),maxPriorityFeePerGas:r,maxFeePerGas:i,gasPrice:null,gasLimit:ps(e[4]),to:ms(e[5]),value:ps(e[6]),data:e[7],accessList:vs(e[8])};return 9===e.length||(n.hash=Jt(t),_s(n,e.slice(9),ks)),n}(e)}return ds.throwError(`unsupported transaction type: ${e[0]}`,w.errors.UNSUPPORTED_OPERATION,{operation:"parseTransaction",transactionType:e[0]})}!function(t){t[t.legacy=0]="legacy",t[t.eip2930=1]="eip2930",t[t.eip1559=2]="eip1559"}(fs||(fs={}));var As=window&&window.__awaiter||function(t,e,r,i){return new(r||(r=Promise))((function(n,o){function a(t){try{h(i.next(t))}catch(t){o(t)}}function s(t){try{h(i.throw(t))}catch(t){o(t)}}function h(t){var e;t.done?n(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(a,s)}h((i=i.apply(t,e||[])).next())}))};const js=new w("contracts/5.6.2");function xs(t,e){return As(this,void 0,void 0,(function*(){const r=yield e;"string"!=typeof r&&js.throwArgumentError("invalid address or ENS name","name",r);try{return he(r)}catch(t){}t||js.throwError("a provider or signer is needed to resolve ENS names",w.errors.UNSUPPORTED_OPERATION,{operation:"resolveName"});const i=yield t.resolveName(r);return null==i&&js.throwArgumentError("resolver or addr is not configured for ENS name","name",r),i}))}function Ss(t,e,r){return As(this,void 0,void 0,(function*(){return Array.isArray(r)?yield Promise.all(r.map(((r,i)=>Ss(t,Array.isArray(e)?e[i]:e[r.name],r)))):"address"===r.type?yield xs(t,e):"tuple"===r.type?yield Ss(t,e,r.components):"array"===r.baseType?Array.isArray(e)?yield Promise.all(e.map((e=>Ss(t,e,r.arrayChildren)))):Promise.reject(js.makeError("invalid value for array",w.errors.INVALID_ARGUMENT,{argument:"value",value:e})):e}))}function Ns(t,e,r){return As(this,void 0,void 0,(function*(){let i={};r.length===e.inputs.length+1&&"object"==typeof r[r.length-1]&&(i=ar(r.pop())),js.checkArgumentCount(r.length,e.inputs.length,"passed to contract"),t.signer?i.from?i.from=or({override:xs(t.signer,i.from),signer:t.signer.getAddress()}).then((t=>As(this,void 0,void 0,(function*(){return he(t.signer)!==t.override&&js.throwError("Contract with a Signer cannot override from",w.errors.UNSUPPORTED_OPERATION,{operation:"overrides.from"}),t.override})))):i.from=t.signer.getAddress():i.from&&(i.from=xs(t.provider,i.from));const n=yield or({args:Ss(t.signer||t.provider,r,e.inputs),address:t.resolvedAddress,overrides:or(i)||{}}),o=t.interface.encodeFunctionData(e,n.args),a={data:o,to:n.address},s=n.overrides;if(null!=s.nonce&&(a.nonce=En.from(s.nonce).toNumber()),null!=s.gasLimit&&(a.gasLimit=En.from(s.gasLimit)),null!=s.gasPrice&&(a.gasPrice=En.from(s.gasPrice)),null!=s.maxFeePerGas&&(a.maxFeePerGas=En.from(s.maxFeePerGas)),null!=s.maxPriorityFeePerGas&&(a.maxPriorityFeePerGas=En.from(s.maxPriorityFeePerGas)),null!=s.from&&(a.from=s.from),null!=s.type&&(a.type=s.type),null!=s.accessList&&(a.accessList=vs(s.accessList)),null==a.gasLimit&&null!=e.gas){let t=21e3;const r=A(o);for(let e=0;e<r.length;e++)t+=4,r[e]&&(t+=64);a.gasLimit=En.from(e.gas).add(t)}if(s.value){const t=En.from(s.value);t.isZero()||e.payable||js.throwError("non-payable method cannot override value",w.errors.UNSUPPORTED_OPERATION,{operation:"overrides.value",value:i.value}),a.value=t}s.customData&&(a.customData=ar(s.customData)),s.ccipReadEnabled&&(a.ccipReadEnabled=!!s.ccipReadEnabled),delete i.nonce,delete i.gasLimit,delete i.gasPrice,delete i.from,delete i.value,delete i.type,delete i.accessList,delete i.maxFeePerGas,delete i.maxPriorityFeePerGas,delete i.customData,delete i.ccipReadEnabled;const h=Object.keys(i).filter((t=>null!=i[t]));return h.length&&js.throwError(`cannot override ${h.map((t=>JSON.stringify(t))).join(",")}`,w.errors.UNSUPPORTED_OPERATION,{operation:"overrides",overrides:h}),a}))}function Is(t,e,r){const i=t.signer||t.provider;return function(...n){return As(this,void 0,void 0,(function*(){let o;if(n.length===e.inputs.length+1&&"object"==typeof n[n.length-1]){const t=ar(n.pop());null!=t.blockTag&&(o=yield t.blockTag),delete t.blockTag,n.push(t)}null!=t.deployTransaction&&(yield t._deployed(o));const a=yield Ns(t,e,n),s=yield i.call(a,o);try{let i=t.interface.decodeFunctionResult(e,s);return r&&1===e.outputs.length&&(i=i[0]),i}catch(e){throw e.code===w.errors.CALL_EXCEPTION&&(e.address=t.address,e.args=n,e.transaction=a),e}}))}}function Ts(t,e){return function(...r){return As(this,void 0,void 0,(function*(){t.signer||js.throwError("sending a transaction requires a signer",w.errors.UNSUPPORTED_OPERATION,{operation:"sendTransaction"}),null!=t.deployTransaction&&(yield t._deployed());const i=yield Ns(t,e,r),n=yield t.signer.sendTransaction(i);return function(t,e){const r=e.wait.bind(e);e.wait=e=>r(e).then((e=>(e.events=e.logs.map((r=>{let i=lr(r),n=null;try{n=t.interface.parseLog(r)}catch(t){}return n&&(i.args=n.args,i.decode=(e,r)=>t.interface.decodeEventLog(n.eventFragment,e,r),i.event=n.name,i.eventSignature=n.signature),i.removeListener=()=>t.provider,i.getBlock=()=>t.provider.getBlock(e.blockHash),i.getTransaction=()=>t.provider.getTransaction(e.transactionHash),i.getTransactionReceipt=()=>Promise.resolve(e),i})),e)))}(t,n),n}))}}function Cs(t,e,r){return e.constant?Is(t,e,r):Ts(t,e)}function zs(t){return!t.address||null!=t.topics&&0!==t.topics.length?(t.address||"*")+"@"+(t.topics?t.topics.map((t=>Array.isArray(t)?t.join("|"):t)).join(":"):""):"*"}class Os{constructor(t,e){ir(this,"tag",t),ir(this,"filter",e),this._listeners=[]}addListener(t,e){this._listeners.push({listener:t,once:e})}removeListener(t){let e=!1;this._listeners=this._listeners.filter((r=>!(!e&&r.listener===t)||(e=!0,!1)))}removeAllListeners(){this._listeners=[]}listeners(){return this._listeners.map((t=>t.listener))}listenerCount(){return this._listeners.length}run(t){const e=this.listenerCount();return this._listeners=this._listeners.filter((e=>{const r=t.slice();return setTimeout((()=>{e.listener.apply(this,r)}),0),!e.once})),e}prepareEvent(t){}getEmit(t){return[t]}}class Rs extends Os{constructor(){super("error",null)}}class Ps extends Os{constructor(t,e,r,i){const n={address:t};let o=e.getEventTopic(r);i?(o!==i[0]&&js.throwArgumentError("topic mismatch","topics",i),n.topics=i.slice()):n.topics=[o],super(zs(n),n),ir(this,"address",t),ir(this,"interface",e),ir(this,"fragment",r)}prepareEvent(t){super.prepareEvent(t),t.event=this.fragment.name,t.eventSignature=this.fragment.format(),t.decode=(t,e)=>this.interface.decodeEventLog(this.fragment,t,e);try{t.args=this.interface.decodeEventLog(this.fragment,t.data,t.topics)}catch(e){t.args=null,t.decodeError=e}}getEmit(t){const e=function(t){const e=[],r=function(t,i){if(Array.isArray(i))for(let n in i){const o=t.slice();o.push(n);try{r(o,i[n])}catch(t){e.push({path:o,error:t})}}};return r([],t),e}(t.args);if(e.length)throw e[0].error;const r=(t.args||[]).slice();return r.push(t),r}}class Bs extends Os{constructor(t,e){super("*",{address:t}),ir(this,"address",t),ir(this,"interface",e)}prepareEvent(t){super.prepareEvent(t);try{const e=this.interface.parseLog(t);t.event=e.name,t.eventSignature=e.signature,t.decode=(t,r)=>this.interface.decodeEventLog(e.eventFragment,t,r),t.args=e.args}catch(t){}}}class Ds extends class{constructor(t,e,r){ir(this,"interface",nr(new.target,"getInterface")(e)),null==r?(ir(this,"provider",null),ir(this,"signer",null)):gn.isSigner(r)?(ir(this,"provider",r.provider||null),ir(this,"signer",r)):cn.isProvider(r)?(ir(this,"provider",r),ir(this,"signer",null)):js.throwArgumentError("invalid signer or provider","signerOrProvider",r),ir(this,"callStatic",{}),ir(this,"estimateGas",{}),ir(this,"functions",{}),ir(this,"populateTransaction",{}),ir(this,"filters",{});{const t={};Object.keys(this.interface.events).forEach((e=>{const r=this.interface.events[e];ir(this.filters,e,((...t)=>({address:this.address,topics:this.interface.encodeFilterTopics(r,t)}))),t[r.name]||(t[r.name]=[]),t[r.name].push(e)})),Object.keys(t).forEach((e=>{const r=t[e];1===r.length?ir(this.filters,e,this.filters[r[0]]):js.warn(`Duplicate definition of ${e} (${r.join(", ")})`)}))}if(ir(this,"_runningEvents",{}),ir(this,"_wrappedEmits",{}),null==t&&js.throwArgumentError("invalid contract address or ENS name","addressOrName",t),ir(this,"address",t),this.provider)ir(this,"resolvedAddress",xs(this.provider,t));else try{ir(this,"resolvedAddress",Promise.resolve(he(t)))}catch(t){js.throwError("provider is required to use ENS name as contract address",w.errors.UNSUPPORTED_OPERATION,{operation:"new Contract"})}this.resolvedAddress.catch((t=>{}));const i={},n={};Object.keys(this.interface.functions).forEach((t=>{const e=this.interface.functions[t];if(n[t])js.warn(`Duplicate ABI entry for ${JSON.stringify(t)}`);else{n[t]=!0;{const r=e.name;i[`%${r}`]||(i[`%${r}`]=[]),i[`%${r}`].push(t)}null==this[t]&&ir(this,t,Cs(this,e,!0)),null==this.functions[t]&&ir(this.functions,t,Cs(this,e,!1)),null==this.callStatic[t]&&ir(this.callStatic,t,Is(this,e,!0)),null==this.populateTransaction[t]&&ir(this.populateTransaction,t,function(t,e){return function(...r){return Ns(t,e,r)}}(this,e)),null==this.estimateGas[t]&&ir(this.estimateGas,t,function(t,e){const r=t.signer||t.provider;return function(...i){return As(this,void 0,void 0,(function*(){r||js.throwError("estimate require a provider or signer",w.errors.UNSUPPORTED_OPERATION,{operation:"estimateGas"});const n=yield Ns(t,e,i);return yield r.estimateGas(n)}))}}(this,e))}})),Object.keys(i).forEach((t=>{const e=i[t];if(e.length>1)return;t=t.substring(1);const r=e[0];try{null==this[t]&&ir(this,t,this[r])}catch(t){}null==this.functions[t]&&ir(this.functions,t,this.functions[r]),null==this.callStatic[t]&&ir(this.callStatic,t,this.callStatic[r]),null==this.populateTransaction[t]&&ir(this.populateTransaction,t,this.populateTransaction[r]),null==this.estimateGas[t]&&ir(this.estimateGas,t,this.estimateGas[r])}))}static getContractAddress(t){return le(t)}static getInterface(t){return Ji.isInterface(t)?t:new Ji(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((t=>("0x"===t&&js.throwError("contract not deployed",w.errors.UNSUPPORTED_OPERATION,{contractAddress:this.address,operation:"getDeployed"}),this)))),this._deployedPromise}fallback(t){this.signer||js.throwError("sending a transactions require a signer",w.errors.UNSUPPORTED_OPERATION,{operation:"sendTransaction(fallback)"});const e=ar(t||{});return["from","to"].forEach((function(t){null!=e[t]&&js.throwError("cannot override "+t,w.errors.UNSUPPORTED_OPERATION,{operation:t})})),e.to=this.resolvedAddress,this.deployed().then((()=>this.signer.sendTransaction(e)))}connect(t){"string"==typeof t&&(t=new yn(t,this.provider));const e=new this.constructor(this.address,this.interface,t);return this.deployTransaction&&ir(e,"deployTransaction",this.deployTransaction),e}attach(t){return new this.constructor(t,this.interface,this.signer||this.provider)}static isIndexed(t){return Gi.isIndexed(t)}_normalizeRunningEvent(t){return this._runningEvents[t.tag]?this._runningEvents[t.tag]:t}_getRunningEvent(t){if("string"==typeof t){if("error"===t)return this._normalizeRunningEvent(new Rs);if("event"===t)return this._normalizeRunningEvent(new Os("event",null));if("*"===t)return this._normalizeRunningEvent(new Bs(this.address,this.interface));const e=this.interface.getEvent(t);return this._normalizeRunningEvent(new Ps(this.address,this.interface,e))}if(t.topics&&t.topics.length>0){try{const e=t.topics[0];if("string"!=typeof e)throw new Error("invalid topic");const r=this.interface.getEvent(e);return this._normalizeRunningEvent(new Ps(this.address,this.interface,r,t.topics))}catch(t){}const e={address:this.address,topics:t.topics};return this._normalizeRunningEvent(new Os(zs(e),e))}return this._normalizeRunningEvent(new Bs(this.address,this.interface))}_checkRunningEvents(t){if(0===t.listenerCount()){delete this._runningEvents[t.tag];const e=this._wrappedEmits[t.tag];e&&t.filter&&(this.provider.off(t.filter,e),delete this._wrappedEmits[t.tag])}}_wrapEvent(t,e,r){const i=lr(e);return i.removeListener=()=>{r&&(t.removeListener(r),this._checkRunningEvents(t))},i.getBlock=()=>this.provider.getBlock(e.blockHash),i.getTransaction=()=>this.provider.getTransaction(e.transactionHash),i.getTransactionReceipt=()=>this.provider.getTransactionReceipt(e.transactionHash),t.prepareEvent(i),i}_addEventListener(t,e,r){if(this.provider||js.throwError("events require a provider or a signer with a provider",w.errors.UNSUPPORTED_OPERATION,{operation:"once"}),t.addListener(e,r),this._runningEvents[t.tag]=t,!this._wrappedEmits[t.tag]){const r=r=>{let i=this._wrapEvent(t,r,e);if(null==i.decodeError)try{const e=t.getEmit(i);this.emit(t.filter,...e)}catch(t){i.decodeError=t.error}null!=t.filter&&this.emit("event",i),null!=i.decodeError&&this.emit("error",i.decodeError,i)};this._wrappedEmits[t.tag]=r,null!=t.filter&&this.provider.on(t.filter,r)}}queryFilter(t,e,r){const i=this._getRunningEvent(t),n=ar(i.filter);return"string"==typeof e&&S(e,32)?(null!=r&&js.throwArgumentError("cannot specify toBlock with blockhash","toBlock",r),n.blockHash=e):(n.fromBlock=null!=e?e:0,n.toBlock=null!=r?r:"latest"),this.provider.getLogs(n).then((t=>t.map((t=>this._wrapEvent(i,t,null)))))}on(t,e){return this._addEventListener(this._getRunningEvent(t),e,!1),this}once(t,e){return this._addEventListener(this._getRunningEvent(t),e,!0),this}emit(t,...e){if(!this.provider)return!1;const r=this._getRunningEvent(t),i=r.run(e)>0;return this._checkRunningEvents(r),i}listenerCount(t){return this.provider?null==t?Object.keys(this._runningEvents).reduce(((t,e)=>t+this._runningEvents[e].listenerCount()),0):this._getRunningEvent(t).listenerCount():0}listeners(t){if(!this.provider)return[];if(null==t){const t=[];for(let e in this._runningEvents)this._runningEvents[e].listeners().forEach((e=>{t.push(e)}));return t}return this._getRunningEvent(t).listeners()}removeAllListeners(t){if(!this.provider)return this;if(null==t){for(const t in this._runningEvents){const e=this._runningEvents[t];e.removeAllListeners(),this._checkRunningEvents(e)}return this}const e=this._getRunningEvent(t);return e.removeAllListeners(),this._checkRunningEvents(e),this}off(t,e){if(!this.provider)return this;const r=this._getRunningEvent(t);return r.removeListener(e),this._checkRunningEvents(r),this}removeListener(t,e){return this.off(t,e)}}{}var $s=a((function(t){!function(t,e){function r(t,e){if(!t)throw new Error(e||"Assertion failed")}function i(t,e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}function n(t,e,r){if(n.isBN(t))return t;this.negative=0,this.words=null,this.length=0,this.red=null,null!==t&&("le"!==e&&"be"!==e||(r=e,e=10),this._init(t||0,e||10,r||"be"))}var o;"object"==typeof t?t.exports=n:e.BN=n,n.BN=n,n.wordSize=26;try{o="undefined"!=typeof window&&void 0!==window.Buffer?window.Buffer:Pt.Buffer}catch(t){}function a(t,e){var i=t.charCodeAt(e);return i>=48&&i<=57?i-48:i>=65&&i<=70?i-55:i>=97&&i<=102?i-87:void r(!1,"Invalid character in "+t)}function s(t,e,r){var i=a(t,r);return r-1>=e&&(i|=a(t,r-1)<<4),i}function h(t,e,i,n){for(var o=0,a=0,s=Math.min(t.length,i),h=e;h<s;h++){var u=t.charCodeAt(h)-48;o*=n,a=u>=49?u-49+10:u>=17?u-17+10:u,r(u>=0&&a<n,"Invalid character"),o+=a}return o}function u(t,e){t.words=e.words,t.length=e.length,t.negative=e.negative,t.red=e.red}if(n.isBN=function(t){return t instanceof n||null!==t&&"object"==typeof t&&t.constructor.wordSize===n.wordSize&&Array.isArray(t.words)},n.max=function(t,e){return t.cmp(e)>0?t:e},n.min=function(t,e){return t.cmp(e)<0?t:e},n.prototype._init=function(t,e,i){if("number"==typeof t)return this._initNumber(t,e,i);if("object"==typeof t)return this._initArray(t,e,i);"hex"===e&&(e=16),r(e===(0|e)&&e>=2&&e<=36);var n=0;"-"===(t=t.toString().replace(/\s+/g,""))[0]&&(n++,this.negative=1),n<t.length&&(16===e?this._parseHex(t,n,i):(this._parseBase(t,e,n),"le"===i&&this._initArray(this.toArray(),e,i)))},n.prototype._initNumber=function(t,e,i){t<0&&(this.negative=1,t=-t),t<67108864?(this.words=[67108863&t],this.length=1):t<4503599627370496?(this.words=[67108863&t,t/67108864&67108863],this.length=2):(r(t<9007199254740992),this.words=[67108863&t,t/67108864&67108863,1],this.length=3),"le"===i&&this._initArray(this.toArray(),e,i)},n.prototype._initArray=function(t,e,i){if(r("number"==typeof t.length),t.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(t.length/3),this.words=new Array(this.length);for(var n=0;n<this.length;n++)this.words[n]=0;var o,a,s=0;if("be"===i)for(n=t.length-1,o=0;n>=0;n-=3)a=t[n]|t[n-1]<<8|t[n-2]<<16,this.words[o]|=a<<s&67108863,this.words[o+1]=a>>>26-s&67108863,(s+=24)>=26&&(s-=26,o++);else if("le"===i)for(n=0,o=0;n<t.length;n+=3)a=t[n]|t[n+1]<<8|t[n+2]<<16,this.words[o]|=a<<s&67108863,this.words[o+1]=a>>>26-s&67108863,(s+=24)>=26&&(s-=26,o++);return this._strip()},n.prototype._parseHex=function(t,e,r){this.length=Math.ceil((t.length-e)/6),this.words=new Array(this.length);for(var i=0;i<this.length;i++)this.words[i]=0;var n,o=0,a=0;if("be"===r)for(i=t.length-1;i>=e;i-=2)n=s(t,e,i)<<o,this.words[a]|=67108863&n,o>=18?(o-=18,a+=1,this.words[a]|=n>>>26):o+=8;else for(i=(t.length-e)%2==0?e+1:e;i<t.length;i+=2)n=s(t,e,i)<<o,this.words[a]|=67108863&n,o>=18?(o-=18,a+=1,this.words[a]|=n>>>26):o+=8;this._strip()},n.prototype._parseBase=function(t,e,r){this.words=[0],this.length=1;for(var i=0,n=1;n<=67108863;n*=e)i++;i--,n=n/e|0;for(var o=t.length-r,a=o%i,s=Math.min(o,o-a)+r,u=0,l=r;l<s;l+=i)u=h(t,l,l+i,e),this.imuln(n),this.words[0]+u<67108864?this.words[0]+=u:this._iaddn(u);if(0!==a){var c=1;for(u=h(t,l,t.length,e),l=0;l<a;l++)c*=e;this.imuln(c),this.words[0]+u<67108864?this.words[0]+=u:this._iaddn(u)}this._strip()},n.prototype.copy=function(t){t.words=new Array(this.length);for(var e=0;e<this.length;e++)t.words[e]=this.words[e];t.length=this.length,t.negative=this.negative,t.red=this.red},n.prototype._move=function(t){u(t,this)},n.prototype.clone=function(){var t=new n(null);return this.copy(t),t},n.prototype._expand=function(t){for(;this.length<t;)this.words[this.length++]=0;return this},n.prototype._strip=function(){for(;this.length>1&&0===this.words[this.length-1];)this.length--;return this._normSign()},n.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},"undefined"!=typeof Symbol&&"function"==typeof Symbol.for)try{n.prototype[Symbol.for("nodejs.util.inspect.custom")]=l}catch(t){n.prototype.inspect=l}else n.prototype.inspect=l;function l(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"}var c=["","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"],d=[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],f=[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];n.prototype.toString=function(t,e){var i;if(e=0|e||1,16===(t=t||10)||"hex"===t){i="";for(var n=0,o=0,a=0;a<this.length;a++){var s=this.words[a],h=(16777215&(s<<n|o)).toString(16);o=s>>>24-n&16777215,(n+=2)>=26&&(n-=26,a--),i=0!==o||a!==this.length-1?c[6-h.length]+h+i:h+i}for(0!==o&&(i=o.toString(16)+i);i.length%e!=0;)i="0"+i;return 0!==this.negative&&(i="-"+i),i}if(t===(0|t)&&t>=2&&t<=36){var u=d[t],l=f[t];i="";var m=this.clone();for(m.negative=0;!m.isZero();){var p=m.modrn(l).toString(t);i=(m=m.idivn(l)).isZero()?p+i:c[u-p.length]+p+i}for(this.isZero()&&(i="0"+i);i.length%e!=0;)i="0"+i;return 0!==this.negative&&(i="-"+i),i}r(!1,"Base should be between 2 and 36")},n.prototype.toNumber=function(){var t=this.words[0];return 2===this.length?t+=67108864*this.words[1]:3===this.length&&1===this.words[2]?t+=4503599627370496+67108864*this.words[1]:this.length>2&&r(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-t:t},n.prototype.toJSON=function(){return this.toString(16,2)},o&&(n.prototype.toBuffer=function(t,e){return this.toArrayLike(o,t,e)}),n.prototype.toArray=function(t,e){return this.toArrayLike(Array,t,e)};function m(t,e,r){r.negative=e.negative^t.negative;var i=t.length+e.length|0;r.length=i,i=i-1|0;var n=0|t.words[0],o=0|e.words[0],a=n*o,s=67108863&a,h=a/67108864|0;r.words[0]=s;for(var u=1;u<i;u++){for(var l=h>>>26,c=67108863&h,d=Math.min(u,e.length-1),f=Math.max(0,u-t.length+1);f<=d;f++){var m=u-f|0;l+=(a=(n=0|t.words[m])*(o=0|e.words[f])+c)/67108864|0,c=67108863&a}r.words[u]=0|c,h=0|l}return 0!==h?r.words[u]=0|h:r.length--,r._strip()}n.prototype.toArrayLike=function(t,e,i){this._strip();var n=this.byteLength(),o=i||Math.max(1,n);r(n<=o,"byte array longer than desired length"),r(o>0,"Requested array length <= 0");var a=function(t,e){return t.allocUnsafe?t.allocUnsafe(e):new t(e)}(t,o);return this["_toArrayLike"+("le"===e?"LE":"BE")](a,n),a},n.prototype._toArrayLikeLE=function(t,e){for(var r=0,i=0,n=0,o=0;n<this.length;n++){var a=this.words[n]<<o|i;t[r++]=255&a,r<t.length&&(t[r++]=a>>8&255),r<t.length&&(t[r++]=a>>16&255),6===o?(r<t.length&&(t[r++]=a>>24&255),i=0,o=0):(i=a>>>24,o+=2)}if(r<t.length)for(t[r++]=i;r<t.length;)t[r++]=0},n.prototype._toArrayLikeBE=function(t,e){for(var r=t.length-1,i=0,n=0,o=0;n<this.length;n++){var a=this.words[n]<<o|i;t[r--]=255&a,r>=0&&(t[r--]=a>>8&255),r>=0&&(t[r--]=a>>16&255),6===o?(r>=0&&(t[r--]=a>>24&255),i=0,o=0):(i=a>>>24,o+=2)}if(r>=0)for(t[r--]=i;r>=0;)t[r--]=0},Math.clz32?n.prototype._countBits=function(t){return 32-Math.clz32(t)}:n.prototype._countBits=function(t){var e=t,r=0;return e>=4096&&(r+=13,e>>>=13),e>=64&&(r+=7,e>>>=7),e>=8&&(r+=4,e>>>=4),e>=2&&(r+=2,e>>>=2),r+e},n.prototype._zeroBits=function(t){if(0===t)return 26;var e=t,r=0;return 0==(8191&e)&&(r+=13,e>>>=13),0==(127&e)&&(r+=7,e>>>=7),0==(15&e)&&(r+=4,e>>>=4),0==(3&e)&&(r+=2,e>>>=2),0==(1&e)&&r++,r},n.prototype.bitLength=function(){var t=this.words[this.length-1],e=this._countBits(t);return 26*(this.length-1)+e},n.prototype.zeroBits=function(){if(this.isZero())return 0;for(var t=0,e=0;e<this.length;e++){var r=this._zeroBits(this.words[e]);if(t+=r,26!==r)break}return t},n.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},n.prototype.toTwos=function(t){return 0!==this.negative?this.abs().inotn(t).iaddn(1):this.clone()},n.prototype.fromTwos=function(t){return this.testn(t-1)?this.notn(t).iaddn(1).ineg():this.clone()},n.prototype.isNeg=function(){return 0!==this.negative},n.prototype.neg=function(){return this.clone().ineg()},n.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},n.prototype.iuor=function(t){for(;this.length<t.length;)this.words[this.length++]=0;for(var e=0;e<t.length;e++)this.words[e]=this.words[e]|t.words[e];return this._strip()},n.prototype.ior=function(t){return r(0==(this.negative|t.negative)),this.iuor(t)},n.prototype.or=function(t){return this.length>t.length?this.clone().ior(t):t.clone().ior(this)},n.prototype.uor=function(t){return this.length>t.length?this.clone().iuor(t):t.clone().iuor(this)},n.prototype.iuand=function(t){var e;e=this.length>t.length?t:this;for(var r=0;r<e.length;r++)this.words[r]=this.words[r]&t.words[r];return this.length=e.length,this._strip()},n.prototype.iand=function(t){return r(0==(this.negative|t.negative)),this.iuand(t)},n.prototype.and=function(t){return this.length>t.length?this.clone().iand(t):t.clone().iand(this)},n.prototype.uand=function(t){return this.length>t.length?this.clone().iuand(t):t.clone().iuand(this)},n.prototype.iuxor=function(t){var e,r;this.length>t.length?(e=this,r=t):(e=t,r=this);for(var i=0;i<r.length;i++)this.words[i]=e.words[i]^r.words[i];if(this!==e)for(;i<e.length;i++)this.words[i]=e.words[i];return this.length=e.length,this._strip()},n.prototype.ixor=function(t){return r(0==(this.negative|t.negative)),this.iuxor(t)},n.prototype.xor=function(t){return this.length>t.length?this.clone().ixor(t):t.clone().ixor(this)},n.prototype.uxor=function(t){return this.length>t.length?this.clone().iuxor(t):t.clone().iuxor(this)},n.prototype.inotn=function(t){r("number"==typeof t&&t>=0);var e=0|Math.ceil(t/26),i=t%26;this._expand(e),i>0&&e--;for(var n=0;n<e;n++)this.words[n]=67108863&~this.words[n];return i>0&&(this.words[n]=~this.words[n]&67108863>>26-i),this._strip()},n.prototype.notn=function(t){return this.clone().inotn(t)},n.prototype.setn=function(t,e){r("number"==typeof t&&t>=0);var i=t/26|0,n=t%26;return this._expand(i+1),this.words[i]=e?this.words[i]|1<<n:this.words[i]&~(1<<n),this._strip()},n.prototype.iadd=function(t){var e,r,i;if(0!==this.negative&&0===t.negative)return this.negative=0,e=this.isub(t),this.negative^=1,this._normSign();if(0===this.negative&&0!==t.negative)return t.negative=0,e=this.isub(t),t.negative=1,e._normSign();this.length>t.length?(r=this,i=t):(r=t,i=this);for(var n=0,o=0;o<i.length;o++)e=(0|r.words[o])+(0|i.words[o])+n,this.words[o]=67108863&e,n=e>>>26;for(;0!==n&&o<r.length;o++)e=(0|r.words[o])+n,this.words[o]=67108863&e,n=e>>>26;if(this.length=r.length,0!==n)this.words[this.length]=n,this.length++;else if(r!==this)for(;o<r.length;o++)this.words[o]=r.words[o];return this},n.prototype.add=function(t){var e;return 0!==t.negative&&0===this.negative?(t.negative=0,e=this.sub(t),t.negative^=1,e):0===t.negative&&0!==this.negative?(this.negative=0,e=t.sub(this),this.negative=1,e):this.length>t.length?this.clone().iadd(t):t.clone().iadd(this)},n.prototype.isub=function(t){if(0!==t.negative){t.negative=0;var e=this.iadd(t);return t.negative=1,e._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(t),this.negative=1,this._normSign();var r,i,n=this.cmp(t);if(0===n)return this.negative=0,this.length=1,this.words[0]=0,this;n>0?(r=this,i=t):(r=t,i=this);for(var o=0,a=0;a<i.length;a++)o=(e=(0|r.words[a])-(0|i.words[a])+o)>>26,this.words[a]=67108863&e;for(;0!==o&&a<r.length;a++)o=(e=(0|r.words[a])+o)>>26,this.words[a]=67108863&e;if(0===o&&a<r.length&&r!==this)for(;a<r.length;a++)this.words[a]=r.words[a];return this.length=Math.max(this.length,a),r!==this&&(this.negative=1),this._strip()},n.prototype.sub=function(t){return this.clone().isub(t)};var p=function(t,e,r){var i,n,o,a=t.words,s=e.words,h=r.words,u=0,l=0|a[0],c=8191&l,d=l>>>13,f=0|a[1],m=8191&f,p=f>>>13,g=0|a[2],y=8191&g,w=g>>>13,v=0|a[3],b=8191&v,k=v>>>13,M=0|a[4],_=8191&M,E=M>>>13,A=0|a[5],j=8191&A,x=A>>>13,S=0|a[6],N=8191&S,I=S>>>13,T=0|a[7],C=8191&T,z=T>>>13,O=0|a[8],R=8191&O,P=O>>>13,B=0|a[9],D=8191&B,$=B>>>13,L=0|s[0],F=8191&L,U=L>>>13,q=0|s[1],V=8191&q,H=q>>>13,G=0|s[2],Z=8191&G,K=G>>>13,J=0|s[3],W=8191&J,Y=J>>>13,Q=0|s[4],X=8191&Q,tt=Q>>>13,et=0|s[5],rt=8191&et,it=et>>>13,nt=0|s[6],ot=8191&nt,at=nt>>>13,st=0|s[7],ht=8191&st,ut=st>>>13,lt=0|s[8],ct=8191&lt,dt=lt>>>13,ft=0|s[9],mt=8191&ft,pt=ft>>>13;r.negative=t.negative^e.negative,r.length=19;var gt=(u+(i=Math.imul(c,F))|0)+((8191&(n=(n=Math.imul(c,U))+Math.imul(d,F)|0))<<13)|0;u=((o=Math.imul(d,U))+(n>>>13)|0)+(gt>>>26)|0,gt&=67108863,i=Math.imul(m,F),n=(n=Math.imul(m,U))+Math.imul(p,F)|0,o=Math.imul(p,U);var yt=(u+(i=i+Math.imul(c,V)|0)|0)+((8191&(n=(n=n+Math.imul(c,H)|0)+Math.imul(d,V)|0))<<13)|0;u=((o=o+Math.imul(d,H)|0)+(n>>>13)|0)+(yt>>>26)|0,yt&=67108863,i=Math.imul(y,F),n=(n=Math.imul(y,U))+Math.imul(w,F)|0,o=Math.imul(w,U),i=i+Math.imul(m,V)|0,n=(n=n+Math.imul(m,H)|0)+Math.imul(p,V)|0,o=o+Math.imul(p,H)|0;var wt=(u+(i=i+Math.imul(c,Z)|0)|0)+((8191&(n=(n=n+Math.imul(c,K)|0)+Math.imul(d,Z)|0))<<13)|0;u=((o=o+Math.imul(d,K)|0)+(n>>>13)|0)+(wt>>>26)|0,wt&=67108863,i=Math.imul(b,F),n=(n=Math.imul(b,U))+Math.imul(k,F)|0,o=Math.imul(k,U),i=i+Math.imul(y,V)|0,n=(n=n+Math.imul(y,H)|0)+Math.imul(w,V)|0,o=o+Math.imul(w,H)|0,i=i+Math.imul(m,Z)|0,n=(n=n+Math.imul(m,K)|0)+Math.imul(p,Z)|0,o=o+Math.imul(p,K)|0;var vt=(u+(i=i+Math.imul(c,W)|0)|0)+((8191&(n=(n=n+Math.imul(c,Y)|0)+Math.imul(d,W)|0))<<13)|0;u=((o=o+Math.imul(d,Y)|0)+(n>>>13)|0)+(vt>>>26)|0,vt&=67108863,i=Math.imul(_,F),n=(n=Math.imul(_,U))+Math.imul(E,F)|0,o=Math.imul(E,U),i=i+Math.imul(b,V)|0,n=(n=n+Math.imul(b,H)|0)+Math.imul(k,V)|0,o=o+Math.imul(k,H)|0,i=i+Math.imul(y,Z)|0,n=(n=n+Math.imul(y,K)|0)+Math.imul(w,Z)|0,o=o+Math.imul(w,K)|0,i=i+Math.imul(m,W)|0,n=(n=n+Math.imul(m,Y)|0)+Math.imul(p,W)|0,o=o+Math.imul(p,Y)|0;var bt=(u+(i=i+Math.imul(c,X)|0)|0)+((8191&(n=(n=n+Math.imul(c,tt)|0)+Math.imul(d,X)|0))<<13)|0;u=((o=o+Math.imul(d,tt)|0)+(n>>>13)|0)+(bt>>>26)|0,bt&=67108863,i=Math.imul(j,F),n=(n=Math.imul(j,U))+Math.imul(x,F)|0,o=Math.imul(x,U),i=i+Math.imul(_,V)|0,n=(n=n+Math.imul(_,H)|0)+Math.imul(E,V)|0,o=o+Math.imul(E,H)|0,i=i+Math.imul(b,Z)|0,n=(n=n+Math.imul(b,K)|0)+Math.imul(k,Z)|0,o=o+Math.imul(k,K)|0,i=i+Math.imul(y,W)|0,n=(n=n+Math.imul(y,Y)|0)+Math.imul(w,W)|0,o=o+Math.imul(w,Y)|0,i=i+Math.imul(m,X)|0,n=(n=n+Math.imul(m,tt)|0)+Math.imul(p,X)|0,o=o+Math.imul(p,tt)|0;var kt=(u+(i=i+Math.imul(c,rt)|0)|0)+((8191&(n=(n=n+Math.imul(c,it)|0)+Math.imul(d,rt)|0))<<13)|0;u=((o=o+Math.imul(d,it)|0)+(n>>>13)|0)+(kt>>>26)|0,kt&=67108863,i=Math.imul(N,F),n=(n=Math.imul(N,U))+Math.imul(I,F)|0,o=Math.imul(I,U),i=i+Math.imul(j,V)|0,n=(n=n+Math.imul(j,H)|0)+Math.imul(x,V)|0,o=o+Math.imul(x,H)|0,i=i+Math.imul(_,Z)|0,n=(n=n+Math.imul(_,K)|0)+Math.imul(E,Z)|0,o=o+Math.imul(E,K)|0,i=i+Math.imul(b,W)|0,n=(n=n+Math.imul(b,Y)|0)+Math.imul(k,W)|0,o=o+Math.imul(k,Y)|0,i=i+Math.imul(y,X)|0,n=(n=n+Math.imul(y,tt)|0)+Math.imul(w,X)|0,o=o+Math.imul(w,tt)|0,i=i+Math.imul(m,rt)|0,n=(n=n+Math.imul(m,it)|0)+Math.imul(p,rt)|0,o=o+Math.imul(p,it)|0;var Mt=(u+(i=i+Math.imul(c,ot)|0)|0)+((8191&(n=(n=n+Math.imul(c,at)|0)+Math.imul(d,ot)|0))<<13)|0;u=((o=o+Math.imul(d,at)|0)+(n>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,i=Math.imul(C,F),n=(n=Math.imul(C,U))+Math.imul(z,F)|0,o=Math.imul(z,U),i=i+Math.imul(N,V)|0,n=(n=n+Math.imul(N,H)|0)+Math.imul(I,V)|0,o=o+Math.imul(I,H)|0,i=i+Math.imul(j,Z)|0,n=(n=n+Math.imul(j,K)|0)+Math.imul(x,Z)|0,o=o+Math.imul(x,K)|0,i=i+Math.imul(_,W)|0,n=(n=n+Math.imul(_,Y)|0)+Math.imul(E,W)|0,o=o+Math.imul(E,Y)|0,i=i+Math.imul(b,X)|0,n=(n=n+Math.imul(b,tt)|0)+Math.imul(k,X)|0,o=o+Math.imul(k,tt)|0,i=i+Math.imul(y,rt)|0,n=(n=n+Math.imul(y,it)|0)+Math.imul(w,rt)|0,o=o+Math.imul(w,it)|0,i=i+Math.imul(m,ot)|0,n=(n=n+Math.imul(m,at)|0)+Math.imul(p,ot)|0,o=o+Math.imul(p,at)|0;var _t=(u+(i=i+Math.imul(c,ht)|0)|0)+((8191&(n=(n=n+Math.imul(c,ut)|0)+Math.imul(d,ht)|0))<<13)|0;u=((o=o+Math.imul(d,ut)|0)+(n>>>13)|0)+(_t>>>26)|0,_t&=67108863,i=Math.imul(R,F),n=(n=Math.imul(R,U))+Math.imul(P,F)|0,o=Math.imul(P,U),i=i+Math.imul(C,V)|0,n=(n=n+Math.imul(C,H)|0)+Math.imul(z,V)|0,o=o+Math.imul(z,H)|0,i=i+Math.imul(N,Z)|0,n=(n=n+Math.imul(N,K)|0)+Math.imul(I,Z)|0,o=o+Math.imul(I,K)|0,i=i+Math.imul(j,W)|0,n=(n=n+Math.imul(j,Y)|0)+Math.imul(x,W)|0,o=o+Math.imul(x,Y)|0,i=i+Math.imul(_,X)|0,n=(n=n+Math.imul(_,tt)|0)+Math.imul(E,X)|0,o=o+Math.imul(E,tt)|0,i=i+Math.imul(b,rt)|0,n=(n=n+Math.imul(b,it)|0)+Math.imul(k,rt)|0,o=o+Math.imul(k,it)|0,i=i+Math.imul(y,ot)|0,n=(n=n+Math.imul(y,at)|0)+Math.imul(w,ot)|0,o=o+Math.imul(w,at)|0,i=i+Math.imul(m,ht)|0,n=(n=n+Math.imul(m,ut)|0)+Math.imul(p,ht)|0,o=o+Math.imul(p,ut)|0;var Et=(u+(i=i+Math.imul(c,ct)|0)|0)+((8191&(n=(n=n+Math.imul(c,dt)|0)+Math.imul(d,ct)|0))<<13)|0;u=((o=o+Math.imul(d,dt)|0)+(n>>>13)|0)+(Et>>>26)|0,Et&=67108863,i=Math.imul(D,F),n=(n=Math.imul(D,U))+Math.imul($,F)|0,o=Math.imul($,U),i=i+Math.imul(R,V)|0,n=(n=n+Math.imul(R,H)|0)+Math.imul(P,V)|0,o=o+Math.imul(P,H)|0,i=i+Math.imul(C,Z)|0,n=(n=n+Math.imul(C,K)|0)+Math.imul(z,Z)|0,o=o+Math.imul(z,K)|0,i=i+Math.imul(N,W)|0,n=(n=n+Math.imul(N,Y)|0)+Math.imul(I,W)|0,o=o+Math.imul(I,Y)|0,i=i+Math.imul(j,X)|0,n=(n=n+Math.imul(j,tt)|0)+Math.imul(x,X)|0,o=o+Math.imul(x,tt)|0,i=i+Math.imul(_,rt)|0,n=(n=n+Math.imul(_,it)|0)+Math.imul(E,rt)|0,o=o+Math.imul(E,it)|0,i=i+Math.imul(b,ot)|0,n=(n=n+Math.imul(b,at)|0)+Math.imul(k,ot)|0,o=o+Math.imul(k,at)|0,i=i+Math.imul(y,ht)|0,n=(n=n+Math.imul(y,ut)|0)+Math.imul(w,ht)|0,o=o+Math.imul(w,ut)|0,i=i+Math.imul(m,ct)|0,n=(n=n+Math.imul(m,dt)|0)+Math.imul(p,ct)|0,o=o+Math.imul(p,dt)|0;var At=(u+(i=i+Math.imul(c,mt)|0)|0)+((8191&(n=(n=n+Math.imul(c,pt)|0)+Math.imul(d,mt)|0))<<13)|0;u=((o=o+Math.imul(d,pt)|0)+(n>>>13)|0)+(At>>>26)|0,At&=67108863,i=Math.imul(D,V),n=(n=Math.imul(D,H))+Math.imul($,V)|0,o=Math.imul($,H),i=i+Math.imul(R,Z)|0,n=(n=n+Math.imul(R,K)|0)+Math.imul(P,Z)|0,o=o+Math.imul(P,K)|0,i=i+Math.imul(C,W)|0,n=(n=n+Math.imul(C,Y)|0)+Math.imul(z,W)|0,o=o+Math.imul(z,Y)|0,i=i+Math.imul(N,X)|0,n=(n=n+Math.imul(N,tt)|0)+Math.imul(I,X)|0,o=o+Math.imul(I,tt)|0,i=i+Math.imul(j,rt)|0,n=(n=n+Math.imul(j,it)|0)+Math.imul(x,rt)|0,o=o+Math.imul(x,it)|0,i=i+Math.imul(_,ot)|0,n=(n=n+Math.imul(_,at)|0)+Math.imul(E,ot)|0,o=o+Math.imul(E,at)|0,i=i+Math.imul(b,ht)|0,n=(n=n+Math.imul(b,ut)|0)+Math.imul(k,ht)|0,o=o+Math.imul(k,ut)|0,i=i+Math.imul(y,ct)|0,n=(n=n+Math.imul(y,dt)|0)+Math.imul(w,ct)|0,o=o+Math.imul(w,dt)|0;var jt=(u+(i=i+Math.imul(m,mt)|0)|0)+((8191&(n=(n=n+Math.imul(m,pt)|0)+Math.imul(p,mt)|0))<<13)|0;u=((o=o+Math.imul(p,pt)|0)+(n>>>13)|0)+(jt>>>26)|0,jt&=67108863,i=Math.imul(D,Z),n=(n=Math.imul(D,K))+Math.imul($,Z)|0,o=Math.imul($,K),i=i+Math.imul(R,W)|0,n=(n=n+Math.imul(R,Y)|0)+Math.imul(P,W)|0,o=o+Math.imul(P,Y)|0,i=i+Math.imul(C,X)|0,n=(n=n+Math.imul(C,tt)|0)+Math.imul(z,X)|0,o=o+Math.imul(z,tt)|0,i=i+Math.imul(N,rt)|0,n=(n=n+Math.imul(N,it)|0)+Math.imul(I,rt)|0,o=o+Math.imul(I,it)|0,i=i+Math.imul(j,ot)|0,n=(n=n+Math.imul(j,at)|0)+Math.imul(x,ot)|0,o=o+Math.imul(x,at)|0,i=i+Math.imul(_,ht)|0,n=(n=n+Math.imul(_,ut)|0)+Math.imul(E,ht)|0,o=o+Math.imul(E,ut)|0,i=i+Math.imul(b,ct)|0,n=(n=n+Math.imul(b,dt)|0)+Math.imul(k,ct)|0,o=o+Math.imul(k,dt)|0;var xt=(u+(i=i+Math.imul(y,mt)|0)|0)+((8191&(n=(n=n+Math.imul(y,pt)|0)+Math.imul(w,mt)|0))<<13)|0;u=((o=o+Math.imul(w,pt)|0)+(n>>>13)|0)+(xt>>>26)|0,xt&=67108863,i=Math.imul(D,W),n=(n=Math.imul(D,Y))+Math.imul($,W)|0,o=Math.imul($,Y),i=i+Math.imul(R,X)|0,n=(n=n+Math.imul(R,tt)|0)+Math.imul(P,X)|0,o=o+Math.imul(P,tt)|0,i=i+Math.imul(C,rt)|0,n=(n=n+Math.imul(C,it)|0)+Math.imul(z,rt)|0,o=o+Math.imul(z,it)|0,i=i+Math.imul(N,ot)|0,n=(n=n+Math.imul(N,at)|0)+Math.imul(I,ot)|0,o=o+Math.imul(I,at)|0,i=i+Math.imul(j,ht)|0,n=(n=n+Math.imul(j,ut)|0)+Math.imul(x,ht)|0,o=o+Math.imul(x,ut)|0,i=i+Math.imul(_,ct)|0,n=(n=n+Math.imul(_,dt)|0)+Math.imul(E,ct)|0,o=o+Math.imul(E,dt)|0;var St=(u+(i=i+Math.imul(b,mt)|0)|0)+((8191&(n=(n=n+Math.imul(b,pt)|0)+Math.imul(k,mt)|0))<<13)|0;u=((o=o+Math.imul(k,pt)|0)+(n>>>13)|0)+(St>>>26)|0,St&=67108863,i=Math.imul(D,X),n=(n=Math.imul(D,tt))+Math.imul($,X)|0,o=Math.imul($,tt),i=i+Math.imul(R,rt)|0,n=(n=n+Math.imul(R,it)|0)+Math.imul(P,rt)|0,o=o+Math.imul(P,it)|0,i=i+Math.imul(C,ot)|0,n=(n=n+Math.imul(C,at)|0)+Math.imul(z,ot)|0,o=o+Math.imul(z,at)|0,i=i+Math.imul(N,ht)|0,n=(n=n+Math.imul(N,ut)|0)+Math.imul(I,ht)|0,o=o+Math.imul(I,ut)|0,i=i+Math.imul(j,ct)|0,n=(n=n+Math.imul(j,dt)|0)+Math.imul(x,ct)|0,o=o+Math.imul(x,dt)|0;var Nt=(u+(i=i+Math.imul(_,mt)|0)|0)+((8191&(n=(n=n+Math.imul(_,pt)|0)+Math.imul(E,mt)|0))<<13)|0;u=((o=o+Math.imul(E,pt)|0)+(n>>>13)|0)+(Nt>>>26)|0,Nt&=67108863,i=Math.imul(D,rt),n=(n=Math.imul(D,it))+Math.imul($,rt)|0,o=Math.imul($,it),i=i+Math.imul(R,ot)|0,n=(n=n+Math.imul(R,at)|0)+Math.imul(P,ot)|0,o=o+Math.imul(P,at)|0,i=i+Math.imul(C,ht)|0,n=(n=n+Math.imul(C,ut)|0)+Math.imul(z,ht)|0,o=o+Math.imul(z,ut)|0,i=i+Math.imul(N,ct)|0,n=(n=n+Math.imul(N,dt)|0)+Math.imul(I,ct)|0,o=o+Math.imul(I,dt)|0;var It=(u+(i=i+Math.imul(j,mt)|0)|0)+((8191&(n=(n=n+Math.imul(j,pt)|0)+Math.imul(x,mt)|0))<<13)|0;u=((o=o+Math.imul(x,pt)|0)+(n>>>13)|0)+(It>>>26)|0,It&=67108863,i=Math.imul(D,ot),n=(n=Math.imul(D,at))+Math.imul($,ot)|0,o=Math.imul($,at),i=i+Math.imul(R,ht)|0,n=(n=n+Math.imul(R,ut)|0)+Math.imul(P,ht)|0,o=o+Math.imul(P,ut)|0,i=i+Math.imul(C,ct)|0,n=(n=n+Math.imul(C,dt)|0)+Math.imul(z,ct)|0,o=o+Math.imul(z,dt)|0;var Tt=(u+(i=i+Math.imul(N,mt)|0)|0)+((8191&(n=(n=n+Math.imul(N,pt)|0)+Math.imul(I,mt)|0))<<13)|0;u=((o=o+Math.imul(I,pt)|0)+(n>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,i=Math.imul(D,ht),n=(n=Math.imul(D,ut))+Math.imul($,ht)|0,o=Math.imul($,ut),i=i+Math.imul(R,ct)|0,n=(n=n+Math.imul(R,dt)|0)+Math.imul(P,ct)|0,o=o+Math.imul(P,dt)|0;var Ct=(u+(i=i+Math.imul(C,mt)|0)|0)+((8191&(n=(n=n+Math.imul(C,pt)|0)+Math.imul(z,mt)|0))<<13)|0;u=((o=o+Math.imul(z,pt)|0)+(n>>>13)|0)+(Ct>>>26)|0,Ct&=67108863,i=Math.imul(D,ct),n=(n=Math.imul(D,dt))+Math.imul($,ct)|0,o=Math.imul($,dt);var zt=(u+(i=i+Math.imul(R,mt)|0)|0)+((8191&(n=(n=n+Math.imul(R,pt)|0)+Math.imul(P,mt)|0))<<13)|0;u=((o=o+Math.imul(P,pt)|0)+(n>>>13)|0)+(zt>>>26)|0,zt&=67108863;var Ot=(u+(i=Math.imul(D,mt))|0)+((8191&(n=(n=Math.imul(D,pt))+Math.imul($,mt)|0))<<13)|0;return u=((o=Math.imul($,pt))+(n>>>13)|0)+(Ot>>>26)|0,Ot&=67108863,h[0]=gt,h[1]=yt,h[2]=wt,h[3]=vt,h[4]=bt,h[5]=kt,h[6]=Mt,h[7]=_t,h[8]=Et,h[9]=At,h[10]=jt,h[11]=xt,h[12]=St,h[13]=Nt,h[14]=It,h[15]=Tt,h[16]=Ct,h[17]=zt,h[18]=Ot,0!==u&&(h[19]=u,r.length++),r};function g(t,e,r){r.negative=e.negative^t.negative,r.length=t.length+e.length;for(var i=0,n=0,o=0;o<r.length-1;o++){var a=n;n=0;for(var s=67108863&i,h=Math.min(o,e.length-1),u=Math.max(0,o-t.length+1);u<=h;u++){var l=o-u,c=(0|t.words[l])*(0|e.words[u]),d=67108863&c;s=67108863&(d=d+s|0),n+=(a=(a=a+(c/67108864|0)|0)+(d>>>26)|0)>>>26,a&=67108863}r.words[o]=s,i=a,a=n}return 0!==i?r.words[o]=i:r.length--,r._strip()}function y(t,e,r){return g(t,e,r)}Math.imul||(p=m),n.prototype.mulTo=function(t,e){var r=this.length+t.length;return 10===this.length&&10===t.length?p(this,t,e):r<63?m(this,t,e):r<1024?g(this,t,e):y(this,t,e)},n.prototype.mul=function(t){var e=new n(null);return e.words=new Array(this.length+t.length),this.mulTo(t,e)},n.prototype.mulf=function(t){var e=new n(null);return e.words=new Array(this.length+t.length),y(this,t,e)},n.prototype.imul=function(t){return this.clone().mulTo(t,this)},n.prototype.imuln=function(t){var e=t<0;e&&(t=-t),r("number"==typeof t),r(t<67108864);for(var i=0,n=0;n<this.length;n++){var o=(0|this.words[n])*t,a=(67108863&o)+(67108863&i);i>>=26,i+=o/67108864|0,i+=a>>>26,this.words[n]=67108863&a}return 0!==i&&(this.words[n]=i,this.length++),e?this.ineg():this},n.prototype.muln=function(t){return this.clone().imuln(t)},n.prototype.sqr=function(){return this.mul(this)},n.prototype.isqr=function(){return this.imul(this.clone())},n.prototype.pow=function(t){var e=function(t){for(var e=new Array(t.bitLength()),r=0;r<e.length;r++){var i=r/26|0,n=r%26;e[r]=t.words[i]>>>n&1}return e}(t);if(0===e.length)return new n(1);for(var r=this,i=0;i<e.length&&0===e[i];i++,r=r.sqr());if(++i<e.length)for(var o=r.sqr();i<e.length;i++,o=o.sqr())0!==e[i]&&(r=r.mul(o));return r},n.prototype.iushln=function(t){r("number"==typeof t&&t>=0);var e,i=t%26,n=(t-i)/26,o=67108863>>>26-i<<26-i;if(0!==i){var a=0;for(e=0;e<this.length;e++){var s=this.words[e]&o,h=(0|this.words[e])-s<<i;this.words[e]=h|a,a=s>>>26-i}a&&(this.words[e]=a,this.length++)}if(0!==n){for(e=this.length-1;e>=0;e--)this.words[e+n]=this.words[e];for(e=0;e<n;e++)this.words[e]=0;this.length+=n}return this._strip()},n.prototype.ishln=function(t){return r(0===this.negative),this.iushln(t)},n.prototype.iushrn=function(t,e,i){var n;r("number"==typeof t&&t>=0),n=e?(e-e%26)/26:0;var o=t%26,a=Math.min((t-o)/26,this.length),s=67108863^67108863>>>o<<o,h=i;if(n-=a,n=Math.max(0,n),h){for(var u=0;u<a;u++)h.words[u]=this.words[u];h.length=a}if(0===a);else if(this.length>a)for(this.length-=a,u=0;u<this.length;u++)this.words[u]=this.words[u+a];else this.words[0]=0,this.length=1;var l=0;for(u=this.length-1;u>=0&&(0!==l||u>=n);u--){var c=0|this.words[u];this.words[u]=l<<26-o|c>>>o,l=c&s}return h&&0!==l&&(h.words[h.length++]=l),0===this.length&&(this.words[0]=0,this.length=1),this._strip()},n.prototype.ishrn=function(t,e,i){return r(0===this.negative),this.iushrn(t,e,i)},n.prototype.shln=function(t){return this.clone().ishln(t)},n.prototype.ushln=function(t){return this.clone().iushln(t)},n.prototype.shrn=function(t){return this.clone().ishrn(t)},n.prototype.ushrn=function(t){return this.clone().iushrn(t)},n.prototype.testn=function(t){r("number"==typeof t&&t>=0);var e=t%26,i=(t-e)/26,n=1<<e;return!(this.length<=i)&&!!(this.words[i]&n)},n.prototype.imaskn=function(t){r("number"==typeof t&&t>=0);var e=t%26,i=(t-e)/26;if(r(0===this.negative,"imaskn works only with positive numbers"),this.length<=i)return this;if(0!==e&&i++,this.length=Math.min(i,this.length),0!==e){var n=67108863^67108863>>>e<<e;this.words[this.length-1]&=n}return this._strip()},n.prototype.maskn=function(t){return this.clone().imaskn(t)},n.prototype.iaddn=function(t){return r("number"==typeof t),r(t<67108864),t<0?this.isubn(-t):0!==this.negative?1===this.length&&(0|this.words[0])<=t?(this.words[0]=t-(0|this.words[0]),this.negative=0,this):(this.negative=0,this.isubn(t),this.negative=1,this):this._iaddn(t)},n.prototype._iaddn=function(t){this.words[0]+=t;for(var e=0;e<this.length&&this.words[e]>=67108864;e++)this.words[e]-=67108864,e===this.length-1?this.words[e+1]=1:this.words[e+1]++;return this.length=Math.max(this.length,e+1),this},n.prototype.isubn=function(t){if(r("number"==typeof t),r(t<67108864),t<0)return this.iaddn(-t);if(0!==this.negative)return this.negative=0,this.iaddn(t),this.negative=1,this;if(this.words[0]-=t,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var e=0;e<this.length&&this.words[e]<0;e++)this.words[e]+=67108864,this.words[e+1]-=1;return this._strip()},n.prototype.addn=function(t){return this.clone().iaddn(t)},n.prototype.subn=function(t){return this.clone().isubn(t)},n.prototype.iabs=function(){return this.negative=0,this},n.prototype.abs=function(){return this.clone().iabs()},n.prototype._ishlnsubmul=function(t,e,i){var n,o,a=t.length+i;this._expand(a);var s=0;for(n=0;n<t.length;n++){o=(0|this.words[n+i])+s;var h=(0|t.words[n])*e;s=((o-=67108863&h)>>26)-(h/67108864|0),this.words[n+i]=67108863&o}for(;n<this.length-i;n++)s=(o=(0|this.words[n+i])+s)>>26,this.words[n+i]=67108863&o;if(0===s)return this._strip();for(r(-1===s),s=0,n=0;n<this.length;n++)s=(o=-(0|this.words[n])+s)>>26,this.words[n]=67108863&o;return this.negative=1,this._strip()},n.prototype._wordDiv=function(t,e){var r=(this.length,t.length),i=this.clone(),o=t,a=0|o.words[o.length-1];0!==(r=26-this._countBits(a))&&(o=o.ushln(r),i.iushln(r),a=0|o.words[o.length-1]);var s,h=i.length-o.length;if("mod"!==e){(s=new n(null)).length=h+1,s.words=new Array(s.length);for(var u=0;u<s.length;u++)s.words[u]=0}var l=i.clone()._ishlnsubmul(o,1,h);0===l.negative&&(i=l,s&&(s.words[h]=1));for(var c=h-1;c>=0;c--){var d=67108864*(0|i.words[o.length+c])+(0|i.words[o.length+c-1]);for(d=Math.min(d/a|0,67108863),i._ishlnsubmul(o,d,c);0!==i.negative;)d--,i.negative=0,i._ishlnsubmul(o,1,c),i.isZero()||(i.negative^=1);s&&(s.words[c]=d)}return s&&s._strip(),i._strip(),"div"!==e&&0!==r&&i.iushrn(r),{div:s||null,mod:i}},n.prototype.divmod=function(t,e,i){return r(!t.isZero()),this.isZero()?{div:new n(0),mod:new n(0)}:0!==this.negative&&0===t.negative?(s=this.neg().divmod(t,e),"mod"!==e&&(o=s.div.neg()),"div"!==e&&(a=s.mod.neg(),i&&0!==a.negative&&a.iadd(t)),{div:o,mod:a}):0===this.negative&&0!==t.negative?(s=this.divmod(t.neg(),e),"mod"!==e&&(o=s.div.neg()),{div:o,mod:s.mod}):0!=(this.negative&t.negative)?(s=this.neg().divmod(t.neg(),e),"div"!==e&&(a=s.mod.neg(),i&&0!==a.negative&&a.isub(t)),{div:s.div,mod:a}):t.length>this.length||this.cmp(t)<0?{div:new n(0),mod:this}:1===t.length?"div"===e?{div:this.divn(t.words[0]),mod:null}:"mod"===e?{div:null,mod:new n(this.modrn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new n(this.modrn(t.words[0]))}:this._wordDiv(t,e);var o,a,s},n.prototype.div=function(t){return this.divmod(t,"div",!1).div},n.prototype.mod=function(t){return this.divmod(t,"mod",!1).mod},n.prototype.umod=function(t){return this.divmod(t,"mod",!0).mod},n.prototype.divRound=function(t){var e=this.divmod(t);if(e.mod.isZero())return e.div;var r=0!==e.div.negative?e.mod.isub(t):e.mod,i=t.ushrn(1),n=t.andln(1),o=r.cmp(i);return o<0||1===n&&0===o?e.div:0!==e.div.negative?e.div.isubn(1):e.div.iaddn(1)},n.prototype.modrn=function(t){var e=t<0;e&&(t=-t),r(t<=67108863);for(var i=(1<<26)%t,n=0,o=this.length-1;o>=0;o--)n=(i*n+(0|this.words[o]))%t;return e?-n:n},n.prototype.modn=function(t){return this.modrn(t)},n.prototype.idivn=function(t){var e=t<0;e&&(t=-t),r(t<=67108863);for(var i=0,n=this.length-1;n>=0;n--){var o=(0|this.words[n])+67108864*i;this.words[n]=o/t|0,i=o%t}return this._strip(),e?this.ineg():this},n.prototype.divn=function(t){return this.clone().idivn(t)},n.prototype.egcd=function(t){r(0===t.negative),r(!t.isZero());var e=this,i=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var o=new n(1),a=new n(0),s=new n(0),h=new n(1),u=0;e.isEven()&&i.isEven();)e.iushrn(1),i.iushrn(1),++u;for(var l=i.clone(),c=e.clone();!e.isZero();){for(var d=0,f=1;0==(e.words[0]&f)&&d<26;++d,f<<=1);if(d>0)for(e.iushrn(d);d-- >0;)(o.isOdd()||a.isOdd())&&(o.iadd(l),a.isub(c)),o.iushrn(1),a.iushrn(1);for(var m=0,p=1;0==(i.words[0]&p)&&m<26;++m,p<<=1);if(m>0)for(i.iushrn(m);m-- >0;)(s.isOdd()||h.isOdd())&&(s.iadd(l),h.isub(c)),s.iushrn(1),h.iushrn(1);e.cmp(i)>=0?(e.isub(i),o.isub(s),a.isub(h)):(i.isub(e),s.isub(o),h.isub(a))}return{a:s,b:h,gcd:i.iushln(u)}},n.prototype._invmp=function(t){r(0===t.negative),r(!t.isZero());var e=this,i=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var o,a=new n(1),s=new n(0),h=i.clone();e.cmpn(1)>0&&i.cmpn(1)>0;){for(var u=0,l=1;0==(e.words[0]&l)&&u<26;++u,l<<=1);if(u>0)for(e.iushrn(u);u-- >0;)a.isOdd()&&a.iadd(h),a.iushrn(1);for(var c=0,d=1;0==(i.words[0]&d)&&c<26;++c,d<<=1);if(c>0)for(i.iushrn(c);c-- >0;)s.isOdd()&&s.iadd(h),s.iushrn(1);e.cmp(i)>=0?(e.isub(i),a.isub(s)):(i.isub(e),s.isub(a))}return(o=0===e.cmpn(1)?a:s).cmpn(0)<0&&o.iadd(t),o},n.prototype.gcd=function(t){if(this.isZero())return t.abs();if(t.isZero())return this.abs();var e=this.clone(),r=t.clone();e.negative=0,r.negative=0;for(var i=0;e.isEven()&&r.isEven();i++)e.iushrn(1),r.iushrn(1);for(;;){for(;e.isEven();)e.iushrn(1);for(;r.isEven();)r.iushrn(1);var n=e.cmp(r);if(n<0){var o=e;e=r,r=o}else if(0===n||0===r.cmpn(1))break;e.isub(r)}return r.iushln(i)},n.prototype.invm=function(t){return this.egcd(t).a.umod(t)},n.prototype.isEven=function(){return 0==(1&this.words[0])},n.prototype.isOdd=function(){return 1==(1&this.words[0])},n.prototype.andln=function(t){return this.words[0]&t},n.prototype.bincn=function(t){r("number"==typeof t);var e=t%26,i=(t-e)/26,n=1<<e;if(this.length<=i)return this._expand(i+1),this.words[i]|=n,this;for(var o=n,a=i;0!==o&&a<this.length;a++){var s=0|this.words[a];o=(s+=o)>>>26,s&=67108863,this.words[a]=s}return 0!==o&&(this.words[a]=o,this.length++),this},n.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},n.prototype.cmpn=function(t){var e,i=t<0;if(0!==this.negative&&!i)return-1;if(0===this.negative&&i)return 1;if(this._strip(),this.length>1)e=1;else{i&&(t=-t),r(t<=67108863,"Number is too big");var n=0|this.words[0];e=n===t?0:n<t?-1:1}return 0!==this.negative?0|-e:e},n.prototype.cmp=function(t){if(0!==this.negative&&0===t.negative)return-1;if(0===this.negative&&0!==t.negative)return 1;var e=this.ucmp(t);return 0!==this.negative?0|-e:e},n.prototype.ucmp=function(t){if(this.length>t.length)return 1;if(this.length<t.length)return-1;for(var e=0,r=this.length-1;r>=0;r--){var i=0|this.words[r],n=0|t.words[r];if(i!==n){i<n?e=-1:i>n&&(e=1);break}}return e},n.prototype.gtn=function(t){return 1===this.cmpn(t)},n.prototype.gt=function(t){return 1===this.cmp(t)},n.prototype.gten=function(t){return this.cmpn(t)>=0},n.prototype.gte=function(t){return this.cmp(t)>=0},n.prototype.ltn=function(t){return-1===this.cmpn(t)},n.prototype.lt=function(t){return-1===this.cmp(t)},n.prototype.lten=function(t){return this.cmpn(t)<=0},n.prototype.lte=function(t){return this.cmp(t)<=0},n.prototype.eqn=function(t){return 0===this.cmpn(t)},n.prototype.eq=function(t){return 0===this.cmp(t)},n.red=function(t){return new E(t)},n.prototype.toRed=function(t){return r(!this.red,"Already a number in reduction context"),r(0===this.negative,"red works only with positives"),t.convertTo(this)._forceRed(t)},n.prototype.fromRed=function(){return r(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},n.prototype._forceRed=function(t){return this.red=t,this},n.prototype.forceRed=function(t){return r(!this.red,"Already a number in reduction context"),this._forceRed(t)},n.prototype.redAdd=function(t){return r(this.red,"redAdd works only with red numbers"),this.red.add(this,t)},n.prototype.redIAdd=function(t){return r(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,t)},n.prototype.redSub=function(t){return r(this.red,"redSub works only with red numbers"),this.red.sub(this,t)},n.prototype.redISub=function(t){return r(this.red,"redISub works only with red numbers"),this.red.isub(this,t)},n.prototype.redShl=function(t){return r(this.red,"redShl works only with red numbers"),this.red.shl(this,t)},n.prototype.redMul=function(t){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.mul(this,t)},n.prototype.redIMul=function(t){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.imul(this,t)},n.prototype.redSqr=function(){return r(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},n.prototype.redISqr=function(){return r(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},n.prototype.redSqrt=function(){return r(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},n.prototype.redInvm=function(){return r(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},n.prototype.redNeg=function(){return r(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},n.prototype.redPow=function(t){return r(this.red&&!t.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,t)};var w={k256:null,p224:null,p192:null,p25519:null};function v(t,e){this.name=t,this.p=new n(e,16),this.n=this.p.bitLength(),this.k=new n(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function b(){v.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function k(){v.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function M(){v.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function _(){v.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function E(t){if("string"==typeof t){var e=n._prime(t);this.m=e.p,this.prime=e}else r(t.gtn(1),"modulus must be greater than 1"),this.m=t,this.prime=null}function A(t){E.call(this,t),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new n(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)}v.prototype._tmp=function(){var t=new n(null);return t.words=new Array(Math.ceil(this.n/13)),t},v.prototype.ireduce=function(t){var e,r=t;do{this.split(r,this.tmp),e=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(e>this.n);var i=e<this.n?-1:r.ucmp(this.p);return 0===i?(r.words[0]=0,r.length=1):i>0?r.isub(this.p):void 0!==r.strip?r.strip():r._strip(),r},v.prototype.split=function(t,e){t.iushrn(this.n,0,e)},v.prototype.imulK=function(t){return t.imul(this.k)},i(b,v),b.prototype.split=function(t,e){for(var r=4194303,i=Math.min(t.length,9),n=0;n<i;n++)e.words[n]=t.words[n];if(e.length=i,t.length<=9)return t.words[0]=0,void(t.length=1);var o=t.words[9];for(e.words[e.length++]=o&r,n=10;n<t.length;n++){var a=0|t.words[n];t.words[n-10]=(a&r)<<4|o>>>22,o=a}o>>>=22,t.words[n-10]=o,0===o&&t.length>10?t.length-=10:t.length-=9},b.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var e=0,r=0;r<t.length;r++){var i=0|t.words[r];e+=977*i,t.words[r]=67108863&e,e=64*i+(e/67108864|0)}return 0===t.words[t.length-1]&&(t.length--,0===t.words[t.length-1]&&t.length--),t},i(k,v),i(M,v),i(_,v),_.prototype.imulK=function(t){for(var e=0,r=0;r<t.length;r++){var i=19*(0|t.words[r])+e,n=67108863&i;i>>>=26,t.words[r]=n,e=i}return 0!==e&&(t.words[t.length++]=e),t},n._prime=function(t){if(w[t])return w[t];var e;if("k256"===t)e=new b;else if("p224"===t)e=new k;else if("p192"===t)e=new M;else{if("p25519"!==t)throw new Error("Unknown prime "+t);e=new _}return w[t]=e,e},E.prototype._verify1=function(t){r(0===t.negative,"red works only with positives"),r(t.red,"red works only with red numbers")},E.prototype._verify2=function(t,e){r(0==(t.negative|e.negative),"red works only with positives"),r(t.red&&t.red===e.red,"red works only with red numbers")},E.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):(u(t,t.umod(this.m)._forceRed(this)),t)},E.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},E.prototype.add=function(t,e){this._verify2(t,e);var r=t.add(e);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},E.prototype.iadd=function(t,e){this._verify2(t,e);var r=t.iadd(e);return r.cmp(this.m)>=0&&r.isub(this.m),r},E.prototype.sub=function(t,e){this._verify2(t,e);var r=t.sub(e);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},E.prototype.isub=function(t,e){this._verify2(t,e);var r=t.isub(e);return r.cmpn(0)<0&&r.iadd(this.m),r},E.prototype.shl=function(t,e){return this._verify1(t),this.imod(t.ushln(e))},E.prototype.imul=function(t,e){return this._verify2(t,e),this.imod(t.imul(e))},E.prototype.mul=function(t,e){return this._verify2(t,e),this.imod(t.mul(e))},E.prototype.isqr=function(t){return this.imul(t,t.clone())},E.prototype.sqr=function(t){return this.mul(t,t)},E.prototype.sqrt=function(t){if(t.isZero())return t.clone();var e=this.m.andln(3);if(r(e%2==1),3===e){var i=this.m.add(new n(1)).iushrn(2);return this.pow(t,i)}for(var o=this.m.subn(1),a=0;!o.isZero()&&0===o.andln(1);)a++,o.iushrn(1);r(!o.isZero());var s=new n(1).toRed(this),h=s.redNeg(),u=this.m.subn(1).iushrn(1),l=this.m.bitLength();for(l=new n(2*l*l).toRed(this);0!==this.pow(l,u).cmp(h);)l.redIAdd(h);for(var c=this.pow(l,o),d=this.pow(t,o.addn(1).iushrn(1)),f=this.pow(t,o),m=a;0!==f.cmp(s);){for(var p=f,g=0;0!==p.cmp(s);g++)p=p.redSqr();r(g<m);var y=this.pow(c,new n(1).iushln(m-g-1));d=d.redMul(y),c=y.redSqr(),f=f.redMul(c),m=g}return d},E.prototype.invm=function(t){var e=t._invmp(this.m);return 0!==e.negative?(e.negative=0,this.imod(e).redNeg()):this.imod(e)},E.prototype.pow=function(t,e){if(e.isZero())return new n(1).toRed(this);if(0===e.cmpn(1))return t.clone();var r=new Array(16);r[0]=new n(1).toRed(this),r[1]=t;for(var i=2;i<r.length;i++)r[i]=this.mul(r[i-1],t);var o=r[0],a=0,s=0,h=e.bitLength()%26;for(0===h&&(h=26),i=e.length-1;i>=0;i--){for(var u=e.words[i],l=h-1;l>=0;l--){var c=u>>l&1;o!==r[0]&&(o=this.sqr(o)),0!==c||0!==a?(a<<=1,a|=c,(4===++s||0===i&&0===l)&&(o=this.mul(o,r[a]),s=0,a=0)):s=0}h=26}return o},E.prototype.convertTo=function(t){var e=t.umod(this.m);return e===t?e.clone():e},E.prototype.convertFrom=function(t){var e=t.clone();return e.red=null,e},n.mont=function(t){return new A(t)},i(A,E),A.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},A.prototype.convertFrom=function(t){var e=this.imod(t.mul(this.rinv));return e.red=null,e},A.prototype.imul=function(t,e){if(t.isZero()||e.isZero())return t.words[0]=0,t.length=1,t;var r=t.imul(e),i=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),n=r.isub(i).iushrn(this.shift),o=n;return n.cmp(this.m)>=0?o=n.isub(this.m):n.cmpn(0)<0&&(o=n.iadd(this.m)),o._forceRed(this)},A.prototype.mul=function(t,e){if(t.isZero()||e.isZero())return new n(0)._forceRed(this);var r=t.mul(e),i=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),o=r.isub(i).iushrn(this.shift),a=o;return o.cmp(this.m)>=0?a=o.isub(this.m):o.cmpn(0)<0&&(a=o.iadd(this.m)),a._forceRed(this)},A.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}(t,i)}));let Ls=!1,Fs=!1;const Us={debug:1,default:2,info:2,warning:3,error:4,off:5};let qs=Us.default,Vs=null;const Hs=function(){try{const t=[];if(["NFD","NFC","NFKD","NFKC"].forEach((e=>{try{if("test"!=="test".normalize(e))throw new Error("bad normalize")}catch(r){t.push(e)}})),t.length)throw new Error("missing "+t.join(", "));if(String.fromCharCode(233).normalize("NFD")!==String.fromCharCode(101,769))throw new Error("broken implementation")}catch(t){return t.message}return null}();var Gs,Zs;!function(t){t.DEBUG="DEBUG",t.INFO="INFO",t.WARNING="WARNING",t.ERROR="ERROR",t.OFF="OFF"}(Gs||(Gs={})),function(t){t.UNKNOWN_ERROR="UNKNOWN_ERROR",t.NOT_IMPLEMENTED="NOT_IMPLEMENTED",t.UNSUPPORTED_OPERATION="UNSUPPORTED_OPERATION",t.NETWORK_ERROR="NETWORK_ERROR",t.SERVER_ERROR="SERVER_ERROR",t.TIMEOUT="TIMEOUT",t.BUFFER_OVERRUN="BUFFER_OVERRUN",t.NUMERIC_FAULT="NUMERIC_FAULT",t.MISSING_NEW="MISSING_NEW",t.INVALID_ARGUMENT="INVALID_ARGUMENT",t.MISSING_ARGUMENT="MISSING_ARGUMENT",t.UNEXPECTED_ARGUMENT="UNEXPECTED_ARGUMENT",t.CALL_EXCEPTION="CALL_EXCEPTION",t.INSUFFICIENT_FUNDS="INSUFFICIENT_FUNDS",t.NONCE_EXPIRED="NONCE_EXPIRED",t.REPLACEMENT_UNDERPRICED="REPLACEMENT_UNDERPRICED",t.UNPREDICTABLE_GAS_LIMIT="UNPREDICTABLE_GAS_LIMIT",t.TRANSACTION_REPLACED="TRANSACTION_REPLACED",t.ACTION_REJECTED="ACTION_REJECTED"}(Zs||(Zs={}));const Ks="0123456789abcdef";class Js{constructor(t){Object.defineProperty(this,"version",{enumerable:!0,value:t,writable:!1})}_log(t,e){const r=t.toLowerCase();null==Us[r]&&this.throwArgumentError("invalid log level name","logLevel",t),qs>Us[r]||console.log.apply(console,e)}debug(...t){this._log(Js.levels.DEBUG,t)}info(...t){this._log(Js.levels.INFO,t)}warn(...t){this._log(Js.levels.WARNING,t)}makeError(t,e,r){if(Fs)return this.makeError("censored error",e,{});e||(e=Js.errors.UNKNOWN_ERROR),r||(r={});const i=[];Object.keys(r).forEach((t=>{const e=r[t];try{if(e instanceof Uint8Array){let r="";for(let t=0;t<e.length;t++)r+=Ks[e[t]>>4],r+=Ks[15&e[t]];i.push(t+"=Uint8Array(0x"+r+")")}else i.push(t+"="+JSON.stringify(e))}catch(e){i.push(t+"="+JSON.stringify(r[t].toString()))}})),i.push(`code=${e}`),i.push(`version=${this.version}`);const n=t;let o="";switch(e){case Zs.NUMERIC_FAULT:{o="NUMERIC_FAULT";const e=t;switch(e){case"overflow":case"underflow":case"division-by-zero":o+="-"+e;break;case"negative-power":case"negative-width":o+="-unsupported";break;case"unbound-bitwise-result":o+="-unbound-result"}break}case Zs.CALL_EXCEPTION:case Zs.INSUFFICIENT_FUNDS:case Zs.MISSING_NEW:case Zs.NONCE_EXPIRED:case Zs.REPLACEMENT_UNDERPRICED:case Zs.TRANSACTION_REPLACED:case Zs.UNPREDICTABLE_GAS_LIMIT:o=e}o&&(t+=" [ See: https://links.ethers.org/v5-errors-"+o+" ]"),i.length&&(t+=" ("+i.join(", ")+")");const a=new Error(t);return a.reason=n,a.code=e,Object.keys(r).forEach((function(t){a[t]=r[t]})),a}throwError(t,e,r){throw this.makeError(t,e,r)}throwArgumentError(t,e,r){return this.throwError(t,Js.errors.INVALID_ARGUMENT,{argument:e,value:r})}assert(t,e,r,i){t||this.throwError(e,r,i)}assertArgument(t,e,r,i){t||this.throwArgumentError(e,r,i)}checkNormalize(t){Hs&&this.throwError("platform missing String.prototype.normalize",Js.errors.UNSUPPORTED_OPERATION,{operation:"String.prototype.normalize",form:Hs})}checkSafeUint53(t,e){"number"==typeof t&&(null==e&&(e="value not safe"),(t<0||t>=9007199254740991)&&this.throwError(e,Js.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"out-of-safe-range",value:t}),t%1&&this.throwError(e,Js.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"non-integer",value:t}))}checkArgumentCount(t,e,r){r=r?": "+r:"",t<e&&this.throwError("missing argument"+r,Js.errors.MISSING_ARGUMENT,{count:t,expectedCount:e}),t>e&&this.throwError("too many arguments"+r,Js.errors.UNEXPECTED_ARGUMENT,{count:t,expectedCount:e})}checkNew(t,e){t!==Object&&null!=t||this.throwError("missing new",Js.errors.MISSING_NEW,{name:e.name})}checkAbstract(t,e){t===e?this.throwError("cannot instantiate abstract class "+JSON.stringify(e.name)+" directly; use a sub-class",Js.errors.UNSUPPORTED_OPERATION,{name:t.name,operation:"new"}):t!==Object&&null!=t||this.throwError("missing new",Js.errors.MISSING_NEW,{name:e.name})}static globalLogger(){return Vs||(Vs=new Js("logger/5.7.0")),Vs}static setCensorship(t,e){if(!t&&e&&this.globalLogger().throwError("cannot permanently disable censorship",Js.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"}),Ls){if(!t)return;this.globalLogger().throwError("error censorship permanent",Js.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"})}Fs=!!t,Ls=!!e}static setLogLevel(t){const e=Us[t.toLowerCase()];null!=e?qs=e:Js.globalLogger().warn("invalid log level - "+t)}static from(t){return new Js(t)}}Js.errors=Zs,Js.levels=Gs;const Ws=new Js("bytes/5.7.0");function Ys(t){return!!t.toHexString}function Qs(t){return t.slice||(t.slice=function(){const e=Array.prototype.slice.call(arguments);return Qs(new Uint8Array(Array.prototype.slice.apply(t,e)))}),t}function Xs(t){return"number"==typeof t&&t==t&&t%1==0}function th(t){if(null==t)return!1;if(t.constructor===Uint8Array)return!0;if("string"==typeof t)return!1;if(!Xs(t.length)||t.length<0)return!1;for(let e=0;e<t.length;e++){const r=t[e];if(!Xs(r)||r<0||r>=256)return!1}return!0}function eh(t,e){return!("string"!=typeof t||!t.match(/^0x[0-9A-Fa-f]*$/))&&(!e||t.length===2+2*e)}const rh="0123456789abcdef";function ih(t,e){if(e||(e={}),"number"==typeof t){Ws.checkSafeUint53(t,"invalid hexlify value");let e="";for(;t;)e=rh[15&t]+e,t=Math.floor(t/16);return e.length?(e.length%2&&(e="0"+e),"0x"+e):"0x00"}if("bigint"==typeof t)return(t=t.toString(16)).length%2?"0x0"+t:"0x"+t;if(e.allowMissingPrefix&&"string"==typeof t&&"0x"!==t.substring(0,2)&&(t="0x"+t),Ys(t))return t.toHexString();if(eh(t))return t.length%2&&("left"===e.hexPad?t="0x0"+t.substring(2):"right"===e.hexPad?t+="0":Ws.throwArgumentError("hex data is odd-length","value",t)),t.toLowerCase();if(th(t)){let e="0x";for(let r=0;r<t.length;r++){let i=t[r];e+=rh[(240&i)>>4]+rh[15&i]}return e}return Ws.throwArgumentError("invalid hexlify value","value",t)}function nh(t,e){for("string"!=typeof t?t=ih(t):eh(t)||Ws.throwArgumentError("invalid hex string","value",t),t.length>2*e+2&&Ws.throwArgumentError("value out of range","value",arguments[1]);t.length<2*e+2;)t="0x0"+t.substring(2);return t}const oh="bignumber/5.7.0";var ah=$s.BN;const sh=new Js(oh),hh={},uh=9007199254740991;let lh=!1;class ch{constructor(t,e){t!==hh&&sh.throwError("cannot call constructor directly; use BigNumber.from",Js.errors.UNSUPPORTED_OPERATION,{operation:"new (BigNumber)"}),this._hex=e,this._isBigNumber=!0,Object.freeze(this)}fromTwos(t){return fh(mh(this).fromTwos(t))}toTwos(t){return fh(mh(this).toTwos(t))}abs(){return"-"===this._hex[0]?ch.from(this._hex.substring(1)):this}add(t){return fh(mh(this).add(mh(t)))}sub(t){return fh(mh(this).sub(mh(t)))}div(t){return ch.from(t).isZero()&&ph("division-by-zero","div"),fh(mh(this).div(mh(t)))}mul(t){return fh(mh(this).mul(mh(t)))}mod(t){const e=mh(t);return e.isNeg()&&ph("division-by-zero","mod"),fh(mh(this).umod(e))}pow(t){const e=mh(t);return e.isNeg()&&ph("negative-power","pow"),fh(mh(this).pow(e))}and(t){const e=mh(t);return(this.isNegative()||e.isNeg())&&ph("unbound-bitwise-result","and"),fh(mh(this).and(e))}or(t){const e=mh(t);return(this.isNegative()||e.isNeg())&&ph("unbound-bitwise-result","or"),fh(mh(this).or(e))}xor(t){const e=mh(t);return(this.isNegative()||e.isNeg())&&ph("unbound-bitwise-result","xor"),fh(mh(this).xor(e))}mask(t){return(this.isNegative()||t<0)&&ph("negative-width","mask"),fh(mh(this).maskn(t))}shl(t){return(this.isNegative()||t<0)&&ph("negative-width","shl"),fh(mh(this).shln(t))}shr(t){return(this.isNegative()||t<0)&&ph("negative-width","shr"),fh(mh(this).shrn(t))}eq(t){return mh(this).eq(mh(t))}lt(t){return mh(this).lt(mh(t))}lte(t){return mh(this).lte(mh(t))}gt(t){return mh(this).gt(mh(t))}gte(t){return mh(this).gte(mh(t))}isNegative(){return"-"===this._hex[0]}isZero(){return mh(this).isZero()}toNumber(){try{return mh(this).toNumber()}catch(t){ph("overflow","toNumber",this.toString())}return null}toBigInt(){try{return BigInt(this.toString())}catch(t){}return sh.throwError("this platform does not support BigInt",Js.errors.UNSUPPORTED_OPERATION,{value:this.toString()})}toString(){return arguments.length>0&&(10===arguments[0]?lh||(lh=!0,sh.warn("BigNumber.toString does not accept any parameters; base-10 is assumed")):16===arguments[0]?sh.throwError("BigNumber.toString does not accept any parameters; use bigNumber.toHexString()",Js.errors.UNEXPECTED_ARGUMENT,{}):sh.throwError("BigNumber.toString does not accept parameters",Js.errors.UNEXPECTED_ARGUMENT,{})),mh(this).toString(10)}toHexString(){return this._hex}toJSON(t){return{type:"BigNumber",hex:this.toHexString()}}static from(t){if(t instanceof ch)return t;if("string"==typeof t)return t.match(/^-?0x[0-9a-f]+$/i)?new ch(hh,dh(t)):t.match(/^-?[0-9]+$/)?new ch(hh,dh(new ah(t))):sh.throwArgumentError("invalid BigNumber string","value",t);if("number"==typeof t)return t%1&&ph("underflow","BigNumber.from",t),(t>=uh||t<=-uh)&&ph("overflow","BigNumber.from",t),ch.from(String(t));const e=t;if("bigint"==typeof e)return ch.from(e.toString());if(th(e))return ch.from(ih(e));if(e)if(e.toHexString){const t=e.toHexString();if("string"==typeof t)return ch.from(t)}else{let t=e._hex;if(null==t&&"BigNumber"===e.type&&(t=e.hex),"string"==typeof t&&(eh(t)||"-"===t[0]&&eh(t.substring(1))))return ch.from(t)}return sh.throwArgumentError("invalid BigNumber value","value",t)}static isBigNumber(t){return!(!t||!t._isBigNumber)}}function dh(t){if("string"!=typeof t)return dh(t.toString(16));if("-"===t[0])return"-"===(t=t.substring(1))[0]&&sh.throwArgumentError("invalid hex","value",t),"0x00"===(t=dh(t))?t:"-"+t;if("0x"!==t.substring(0,2)&&(t="0x"+t),"0x"===t)return"0x00";for(t.length%2&&(t="0x0"+t.substring(2));t.length>4&&"0x00"===t.substring(0,4);)t="0x"+t.substring(4);return t}function fh(t){return ch.from(dh(t))}function mh(t){const e=ch.from(t).toHexString();return"-"===e[0]?new ah("-"+e.substring(3),16):new ah(e.substring(2),16)}function ph(t,e,r){const i={fault:t,operation:e};return null!=r&&(i.value=r),sh.throwError(t,Js.errors.NUMERIC_FAULT,i)}const gh=new Js(oh),yh={},wh=ch.from(0),vh=ch.from(-1);function bh(t,e,r,i){const n={fault:e,operation:r};return void 0!==i&&(n.value=i),gh.throwError(t,Js.errors.NUMERIC_FAULT,n)}let kh="0";for(;kh.length<256;)kh+=kh;function Mh(t){if("number"!=typeof t)try{t=ch.from(t).toNumber()}catch(t){}return"number"==typeof t&&t>=0&&t<=256&&!(t%1)?"1"+kh.substring(0,t):gh.throwArgumentError("invalid decimal size","decimals",t)}function _h(t,e){null==e&&(e=0);const r=Mh(e),i=(t=ch.from(t)).lt(wh);i&&(t=t.mul(vh));let n=t.mod(r).toString();for(;n.length<r.length-1;)n="0"+n;n=n.match(/^([0-9]*[1-9]|0)(0*)/)[1];const o=t.div(r).toString();return t=1===r.length?o:o+"."+n,i&&(t="-"+t),t}function Eh(t,e){null==e&&(e=0);const r=Mh(e);"string"==typeof t&&t.match(/^-?[0-9.]+$/)||gh.throwArgumentError("invalid decimal value","value",t);const i="-"===t.substring(0,1);i&&(t=t.substring(1)),"."===t&&gh.throwArgumentError("missing value","value",t);const n=t.split(".");n.length>2&&gh.throwArgumentError("too many decimal points","value",t);let o=n[0],a=n[1];for(o||(o="0"),a||(a="0");"0"===a[a.length-1];)a=a.substring(0,a.length-1);for(a.length>r.length-1&&bh("fractional component exceeds decimals","underflow","parseFixed"),""===a&&(a="0");a.length<r.length-1;)a+="0";const s=ch.from(o),h=ch.from(a);let u=s.mul(r).add(h);return i&&(u=u.mul(vh)),u}class Ah{constructor(t,e,r,i){t!==yh&&gh.throwError("cannot use FixedFormat constructor; use FixedFormat.from",Js.errors.UNSUPPORTED_OPERATION,{operation:"new FixedFormat"}),this.signed=e,this.width=r,this.decimals=i,this.name=(e?"":"u")+"fixed"+String(r)+"x"+String(i),this._multiplier=Mh(i),Object.freeze(this)}static from(t){if(t instanceof Ah)return t;"number"==typeof t&&(t=`fixed128x${t}`);let e=!0,r=128,i=18;if("string"==typeof t)if("fixed"===t);else if("ufixed"===t)e=!1;else{const n=t.match(/^(u?)fixed([0-9]+)x([0-9]+)$/);n||gh.throwArgumentError("invalid fixed format","format",t),e="u"!==n[1],r=parseInt(n[2]),i=parseInt(n[3])}else if(t){const n=(e,r,i)=>null==t[e]?i:(typeof t[e]!==r&&gh.throwArgumentError("invalid fixed format ("+e+" not "+r+")","format."+e,t[e]),t[e]);e=n("signed","boolean",e),r=n("width","number",r),i=n("decimals","number",i)}return r%8&&gh.throwArgumentError("invalid fixed format width (not byte aligned)","format.width",r),i>80&&gh.throwArgumentError("invalid fixed format (decimals too large)","format.decimals",i),new Ah(yh,e,r,i)}}class jh{constructor(t,e,r,i){t!==yh&&gh.throwError("cannot use FixedNumber constructor; use FixedNumber.from",Js.errors.UNSUPPORTED_OPERATION,{operation:"new FixedFormat"}),this.format=i,this._hex=e,this._value=r,this._isFixedNumber=!0,Object.freeze(this)}_checkFormat(t){this.format.name!==t.format.name&&gh.throwArgumentError("incompatible format; use fixedNumber.toFormat","other",t)}addUnsafe(t){this._checkFormat(t);const e=Eh(this._value,this.format.decimals),r=Eh(t._value,t.format.decimals);return jh.fromValue(e.add(r),this.format.decimals,this.format)}subUnsafe(t){this._checkFormat(t);const e=Eh(this._value,this.format.decimals),r=Eh(t._value,t.format.decimals);return jh.fromValue(e.sub(r),this.format.decimals,this.format)}mulUnsafe(t){this._checkFormat(t);const e=Eh(this._value,this.format.decimals),r=Eh(t._value,t.format.decimals);return jh.fromValue(e.mul(r).div(this.format._multiplier),this.format.decimals,this.format)}divUnsafe(t){this._checkFormat(t);const e=Eh(this._value,this.format.decimals),r=Eh(t._value,t.format.decimals);return jh.fromValue(e.mul(this.format._multiplier).div(r),this.format.decimals,this.format)}floor(){const t=this.toString().split(".");1===t.length&&t.push("0");let e=jh.from(t[0],this.format);const r=!t[1].match(/^(0*)$/);return this.isNegative()&&r&&(e=e.subUnsafe(xh.toFormat(e.format))),e}ceiling(){const t=this.toString().split(".");1===t.length&&t.push("0");let e=jh.from(t[0],this.format);const r=!t[1].match(/^(0*)$/);return!this.isNegative()&&r&&(e=e.addUnsafe(xh.toFormat(e.format))),e}round(t){null==t&&(t=0);const e=this.toString().split(".");if(1===e.length&&e.push("0"),(t<0||t>80||t%1)&&gh.throwArgumentError("invalid decimal count","decimals",t),e[1].length<=t)return this;const r=jh.from("1"+kh.substring(0,t),this.format),i=Sh.toFormat(this.format);return this.mulUnsafe(r).addUnsafe(i).floor().divUnsafe(r)}isZero(){return"0.0"===this._value||"0"===this._value}isNegative(){return"-"===this._value[0]}toString(){return this._value}toHexString(t){if(null==t)return this._hex;t%8&&gh.throwArgumentError("invalid byte width","width",t);return nh(ch.from(this._hex).fromTwos(this.format.width).toTwos(t).toHexString(),t/8)}toUnsafeFloat(){return parseFloat(this.toString())}toFormat(t){return jh.fromString(this._value,t)}static fromValue(t,e,r){return null!=r||null==e||function(t){return null!=t&&(ch.isBigNumber(t)||"number"==typeof t&&t%1==0||"string"==typeof t&&!!t.match(/^-?[0-9]+$/)||eh(t)||"bigint"==typeof t||th(t))}(e)||(r=e,e=null),null==e&&(e=0),null==r&&(r="fixed"),jh.fromString(_h(t,e),Ah.from(r))}static fromString(t,e){null==e&&(e="fixed");const r=Ah.from(e),i=Eh(t,r.decimals);!r.signed&&i.lt(wh)&&bh("unsigned value cannot be negative","overflow","value",t);let n=null;r.signed?n=i.toTwos(r.width).toHexString():(n=i.toHexString(),n=nh(n,r.width/8));const o=_h(i,r.decimals);return new jh(yh,n,o,r)}static fromBytes(t,e){null==e&&(e="fixed");const r=Ah.from(e);if(function(t,e){if(e||(e={}),"number"==typeof t){Ws.checkSafeUint53(t,"invalid arrayify value");const e=[];for(;t;)e.unshift(255&t),t=parseInt(String(t/256));return 0===e.length&&e.push(0),Qs(new Uint8Array(e))}if(e.allowMissingPrefix&&"string"==typeof t&&"0x"!==t.substring(0,2)&&(t="0x"+t),Ys(t)&&(t=t.toHexString()),eh(t)){let r=t.substring(2);r.length%2&&("left"===e.hexPad?r="0"+r:"right"===e.hexPad?r+="0":Ws.throwArgumentError("hex data is odd-length","value",t));const i=[];for(let t=0;t<r.length;t+=2)i.push(parseInt(r.substring(t,t+2),16));return Qs(new Uint8Array(i))}return th(t)?Qs(new Uint8Array(t)):Ws.throwArgumentError("invalid arrayify value","value",t)}(t).length>r.width/8)throw new Error("overflow");let i=ch.from(t);r.signed&&(i=i.fromTwos(r.width));const n=i.toTwos((r.signed?0:1)+r.width).toHexString(),o=_h(i,r.decimals);return new jh(yh,n,o,r)}static from(t,e){if("string"==typeof t)return jh.fromString(t,e);if(th(t))return jh.fromBytes(t,e);try{return jh.fromValue(t,0,e)}catch(t){if(t.code!==Js.errors.INVALID_ARGUMENT)throw t}return gh.throwArgumentError("invalid FixedNumber value","value",t)}static isFixedNumber(t){return!(!t||!t._isFixedNumber)}}const xh=jh.from(1),Sh=jh.from("0.5");let Nh=!1,Ih=!1;const Th={debug:1,default:2,info:2,warning:3,error:4,off:5};let Ch=Th.default,zh=null;const Oh=function(){try{const t=[];if(["NFD","NFC","NFKD","NFKC"].forEach((e=>{try{if("test"!=="test".normalize(e))throw new Error("bad normalize")}catch(r){t.push(e)}})),t.length)throw new Error("missing "+t.join(", "));if(String.fromCharCode(233).normalize("NFD")!==String.fromCharCode(101,769))throw new Error("broken implementation")}catch(t){return t.message}return null}();var Rh,Ph;!function(t){t.DEBUG="DEBUG",t.INFO="INFO",t.WARNING="WARNING",t.ERROR="ERROR",t.OFF="OFF"}(Rh||(Rh={})),function(t){t.UNKNOWN_ERROR="UNKNOWN_ERROR",t.NOT_IMPLEMENTED="NOT_IMPLEMENTED",t.UNSUPPORTED_OPERATION="UNSUPPORTED_OPERATION",t.NETWORK_ERROR="NETWORK_ERROR",t.SERVER_ERROR="SERVER_ERROR",t.TIMEOUT="TIMEOUT",t.BUFFER_OVERRUN="BUFFER_OVERRUN",t.NUMERIC_FAULT="NUMERIC_FAULT",t.MISSING_NEW="MISSING_NEW",t.INVALID_ARGUMENT="INVALID_ARGUMENT",t.MISSING_ARGUMENT="MISSING_ARGUMENT",t.UNEXPECTED_ARGUMENT="UNEXPECTED_ARGUMENT",t.CALL_EXCEPTION="CALL_EXCEPTION",t.INSUFFICIENT_FUNDS="INSUFFICIENT_FUNDS",t.NONCE_EXPIRED="NONCE_EXPIRED",t.REPLACEMENT_UNDERPRICED="REPLACEMENT_UNDERPRICED",t.UNPREDICTABLE_GAS_LIMIT="UNPREDICTABLE_GAS_LIMIT",t.TRANSACTION_REPLACED="TRANSACTION_REPLACED",t.ACTION_REJECTED="ACTION_REJECTED"}(Ph||(Ph={}));const Bh="0123456789abcdef";class Dh{constructor(t){Object.defineProperty(this,"version",{enumerable:!0,value:t,writable:!1})}_log(t,e){const r=t.toLowerCase();null==Th[r]&&this.throwArgumentError("invalid log level name","logLevel",t),Ch>Th[r]||console.log.apply(console,e)}debug(...t){this._log(Dh.levels.DEBUG,t)}info(...t){this._log(Dh.levels.INFO,t)}warn(...t){this._log(Dh.levels.WARNING,t)}makeError(t,e,r){if(Ih)return this.makeError("censored error",e,{});e||(e=Dh.errors.UNKNOWN_ERROR),r||(r={});const i=[];Object.keys(r).forEach((t=>{const e=r[t];try{if(e instanceof Uint8Array){let r="";for(let t=0;t<e.length;t++)r+=Bh[e[t]>>4],r+=Bh[15&e[t]];i.push(t+"=Uint8Array(0x"+r+")")}else i.push(t+"="+JSON.stringify(e))}catch(e){i.push(t+"="+JSON.stringify(r[t].toString()))}})),i.push(`code=${e}`),i.push(`version=${this.version}`);const n=t;let o="";switch(e){case Ph.NUMERIC_FAULT:{o="NUMERIC_FAULT";const e=t;switch(e){case"overflow":case"underflow":case"division-by-zero":o+="-"+e;break;case"negative-power":case"negative-width":o+="-unsupported";break;case"unbound-bitwise-result":o+="-unbound-result"}break}case Ph.CALL_EXCEPTION:case Ph.INSUFFICIENT_FUNDS:case Ph.MISSING_NEW:case Ph.NONCE_EXPIRED:case Ph.REPLACEMENT_UNDERPRICED:case Ph.TRANSACTION_REPLACED:case Ph.UNPREDICTABLE_GAS_LIMIT:o=e}o&&(t+=" [ See: https://links.ethers.org/v5-errors-"+o+" ]"),i.length&&(t+=" ("+i.join(", ")+")");const a=new Error(t);return a.reason=n,a.code=e,Object.keys(r).forEach((function(t){a[t]=r[t]})),a}throwError(t,e,r){throw this.makeError(t,e,r)}throwArgumentError(t,e,r){return this.throwError(t,Dh.errors.INVALID_ARGUMENT,{argument:e,value:r})}assert(t,e,r,i){t||this.throwError(e,r,i)}assertArgument(t,e,r,i){t||this.throwArgumentError(e,r,i)}checkNormalize(t){Oh&&this.throwError("platform missing String.prototype.normalize",Dh.errors.UNSUPPORTED_OPERATION,{operation:"String.prototype.normalize",form:Oh})}checkSafeUint53(t,e){"number"==typeof t&&(null==e&&(e="value not safe"),(t<0||t>=9007199254740991)&&this.throwError(e,Dh.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"out-of-safe-range",value:t}),t%1&&this.throwError(e,Dh.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"non-integer",value:t}))}checkArgumentCount(t,e,r){r=r?": "+r:"",t<e&&this.throwError("missing argument"+r,Dh.errors.MISSING_ARGUMENT,{count:t,expectedCount:e}),t>e&&this.throwError("too many arguments"+r,Dh.errors.UNEXPECTED_ARGUMENT,{count:t,expectedCount:e})}checkNew(t,e){t!==Object&&null!=t||this.throwError("missing new",Dh.errors.MISSING_NEW,{name:e.name})}checkAbstract(t,e){t===e?this.throwError("cannot instantiate abstract class "+JSON.stringify(e.name)+" directly; use a sub-class",Dh.errors.UNSUPPORTED_OPERATION,{name:t.name,operation:"new"}):t!==Object&&null!=t||this.throwError("missing new",Dh.errors.MISSING_NEW,{name:e.name})}static globalLogger(){return zh||(zh=new Dh("logger/5.7.0")),zh}static setCensorship(t,e){if(!t&&e&&this.globalLogger().throwError("cannot permanently disable censorship",Dh.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"}),Nh){if(!t)return;this.globalLogger().throwError("error censorship permanent",Dh.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"})}Ih=!!t,Nh=!!e}static setLogLevel(t){const e=Th[t.toLowerCase()];null!=e?Ch=e:Dh.globalLogger().warn("invalid log level - "+t)}static from(t){return new Dh(t)}}Dh.errors=Ph,Dh.levels=Rh;const $h=new Dh("units/5.7.0"),Lh=["wei","kwei","mwei","gwei","szabo","finney","ether"];let Fh=!1,Uh=!1;const qh={debug:1,default:2,info:2,warning:3,error:4,off:5};let Vh=qh.default,Hh=null;const Gh=function(){try{const t=[];if(["NFD","NFC","NFKD","NFKC"].forEach((e=>{try{if("test"!=="test".normalize(e))throw new Error("bad normalize")}catch(r){t.push(e)}})),t.length)throw new Error("missing "+t.join(", "));if(String.fromCharCode(233).normalize("NFD")!==String.fromCharCode(101,769))throw new Error("broken implementation")}catch(t){return t.message}return null}();var Zh,Kh;!function(t){t.DEBUG="DEBUG",t.INFO="INFO",t.WARNING="WARNING",t.ERROR="ERROR",t.OFF="OFF"}(Zh||(Zh={})),function(t){t.UNKNOWN_ERROR="UNKNOWN_ERROR",t.NOT_IMPLEMENTED="NOT_IMPLEMENTED",t.UNSUPPORTED_OPERATION="UNSUPPORTED_OPERATION",t.NETWORK_ERROR="NETWORK_ERROR",t.SERVER_ERROR="SERVER_ERROR",t.TIMEOUT="TIMEOUT",t.BUFFER_OVERRUN="BUFFER_OVERRUN",t.NUMERIC_FAULT="NUMERIC_FAULT",t.MISSING_NEW="MISSING_NEW",t.INVALID_ARGUMENT="INVALID_ARGUMENT",t.MISSING_ARGUMENT="MISSING_ARGUMENT",t.UNEXPECTED_ARGUMENT="UNEXPECTED_ARGUMENT",t.CALL_EXCEPTION="CALL_EXCEPTION",t.INSUFFICIENT_FUNDS="INSUFFICIENT_FUNDS",t.NONCE_EXPIRED="NONCE_EXPIRED",t.REPLACEMENT_UNDERPRICED="REPLACEMENT_UNDERPRICED",t.UNPREDICTABLE_GAS_LIMIT="UNPREDICTABLE_GAS_LIMIT",t.TRANSACTION_REPLACED="TRANSACTION_REPLACED",t.ACTION_REJECTED="ACTION_REJECTED"}(Kh||(Kh={}));const Jh="0123456789abcdef";class Wh{constructor(t){Object.defineProperty(this,"version",{enumerable:!0,value:t,writable:!1})}_log(t,e){const r=t.toLowerCase();null==qh[r]&&this.throwArgumentError("invalid log level name","logLevel",t),Vh>qh[r]||console.log.apply(console,e)}debug(...t){this._log(Wh.levels.DEBUG,t)}info(...t){this._log(Wh.levels.INFO,t)}warn(...t){this._log(Wh.levels.WARNING,t)}makeError(t,e,r){if(Uh)return this.makeError("censored error",e,{});e||(e=Wh.errors.UNKNOWN_ERROR),r||(r={});const i=[];Object.keys(r).forEach((t=>{const e=r[t];try{if(e instanceof Uint8Array){let r="";for(let t=0;t<e.length;t++)r+=Jh[e[t]>>4],r+=Jh[15&e[t]];i.push(t+"=Uint8Array(0x"+r+")")}else i.push(t+"="+JSON.stringify(e))}catch(e){i.push(t+"="+JSON.stringify(r[t].toString()))}})),i.push(`code=${e}`),i.push(`version=${this.version}`);const n=t;let o="";switch(e){case Kh.NUMERIC_FAULT:{o="NUMERIC_FAULT";const e=t;switch(e){case"overflow":case"underflow":case"division-by-zero":o+="-"+e;break;case"negative-power":case"negative-width":o+="-unsupported";break;case"unbound-bitwise-result":o+="-unbound-result"}break}case Kh.CALL_EXCEPTION:case Kh.INSUFFICIENT_FUNDS:case Kh.MISSING_NEW:case Kh.NONCE_EXPIRED:case Kh.REPLACEMENT_UNDERPRICED:case Kh.TRANSACTION_REPLACED:case Kh.UNPREDICTABLE_GAS_LIMIT:o=e}o&&(t+=" [ See: https://links.ethers.org/v5-errors-"+o+" ]"),i.length&&(t+=" ("+i.join(", ")+")");const a=new Error(t);return a.reason=n,a.code=e,Object.keys(r).forEach((function(t){a[t]=r[t]})),a}throwError(t,e,r){throw this.makeError(t,e,r)}throwArgumentError(t,e,r){return this.throwError(t,Wh.errors.INVALID_ARGUMENT,{argument:e,value:r})}assert(t,e,r,i){t||this.throwError(e,r,i)}assertArgument(t,e,r,i){t||this.throwArgumentError(e,r,i)}checkNormalize(t){Gh&&this.throwError("platform missing String.prototype.normalize",Wh.errors.UNSUPPORTED_OPERATION,{operation:"String.prototype.normalize",form:Gh})}checkSafeUint53(t,e){"number"==typeof t&&(null==e&&(e="value not safe"),(t<0||t>=9007199254740991)&&this.throwError(e,Wh.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"out-of-safe-range",value:t}),t%1&&this.throwError(e,Wh.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"non-integer",value:t}))}checkArgumentCount(t,e,r){r=r?": "+r:"",t<e&&this.throwError("missing argument"+r,Wh.errors.MISSING_ARGUMENT,{count:t,expectedCount:e}),t>e&&this.throwError("too many arguments"+r,Wh.errors.UNEXPECTED_ARGUMENT,{count:t,expectedCount:e})}checkNew(t,e){t!==Object&&null!=t||this.throwError("missing new",Wh.errors.MISSING_NEW,{name:e.name})}checkAbstract(t,e){t===e?this.throwError("cannot instantiate abstract class "+JSON.stringify(e.name)+" directly; use a sub-class",Wh.errors.UNSUPPORTED_OPERATION,{name:t.name,operation:"new"}):t!==Object&&null!=t||this.throwError("missing new",Wh.errors.MISSING_NEW,{name:e.name})}static globalLogger(){return Hh||(Hh=new Wh("logger/5.7.0")),Hh}static setCensorship(t,e){if(!t&&e&&this.globalLogger().throwError("cannot permanently disable censorship",Wh.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"}),Fh){if(!t)return;this.globalLogger().throwError("error censorship permanent",Wh.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"})}Uh=!!t,Fh=!!e}static setLogLevel(t){const e=qh[t.toLowerCase()];null!=e?Vh=e:Wh.globalLogger().warn("invalid log level - "+t)}static from(t){return new Wh(t)}}Wh.errors=Kh,Wh.levels=Zh;const Yh=new Wh("bytes/5.7.0");function Qh(t){return!!t.toHexString}function Xh(t){return t.slice||(t.slice=function(){const e=Array.prototype.slice.call(arguments);return Xh(new Uint8Array(Array.prototype.slice.apply(t,e)))}),t}function tu(t){return"number"==typeof t&&t==t&&t%1==0}function eu(t){if(null==t)return!1;if(t.constructor===Uint8Array)return!0;if("string"==typeof t)return!1;if(!tu(t.length)||t.length<0)return!1;for(let e=0;e<t.length;e++){const r=t[e];if(!tu(r)||r<0||r>=256)return!1}return!0}function ru(t,e){if(e||(e={}),"number"==typeof t){Yh.checkSafeUint53(t,"invalid arrayify value");const e=[];for(;t;)e.unshift(255&t),t=parseInt(String(t/256));return 0===e.length&&e.push(0),Xh(new Uint8Array(e))}if(e.allowMissingPrefix&&"string"==typeof t&&"0x"!==t.substring(0,2)&&(t="0x"+t),Qh(t)&&(t=t.toHexString()),nu(t)){let r=t.substring(2);r.length%2&&("left"===e.hexPad?r="0"+r:"right"===e.hexPad?r+="0":Yh.throwArgumentError("hex data is odd-length","value",t));const i=[];for(let t=0;t<r.length;t+=2)i.push(parseInt(r.substring(t,t+2),16));return Xh(new Uint8Array(i))}return eu(t)?Xh(new Uint8Array(t)):Yh.throwArgumentError("invalid arrayify value","value",t)}function iu(t){const e=t.map((t=>ru(t))),r=e.reduce(((t,e)=>t+e.length),0),i=new Uint8Array(r);return e.reduce(((t,e)=>(i.set(e,t),t+e.length)),0),Xh(i)}function nu(t,e){return!("string"!=typeof t||!t.match(/^0x[0-9A-Fa-f]*$/))&&(!e||t.length===2+2*e)}const ou="0123456789abcdef";function au(t,e){if(e||(e={}),"number"==typeof t){Yh.checkSafeUint53(t,"invalid hexlify value");let e="";for(;t;)e=ou[15&t]+e,t=Math.floor(t/16);return e.length?(e.length%2&&(e="0"+e),"0x"+e):"0x00"}if("bigint"==typeof t)return(t=t.toString(16)).length%2?"0x0"+t:"0x"+t;if(e.allowMissingPrefix&&"string"==typeof t&&"0x"!==t.substring(0,2)&&(t="0x"+t),Qh(t))return t.toHexString();if(nu(t))return t.length%2&&("left"===e.hexPad?t="0x0"+t.substring(2):"right"===e.hexPad?t+="0":Yh.throwArgumentError("hex data is odd-length","value",t)),t.toLowerCase();if(eu(t)){let e="0x";for(let r=0;r<t.length;r++){let i=t[r];e+=ou[(240&i)>>4]+ou[15&i]}return e}return Yh.throwArgumentError("invalid hexlify value","value",t)}function su(t){let e="0x";return t.forEach((t=>{e+=au(t).substring(2)})),e}function hu(t,e){for("string"!=typeof t?t=au(t):nu(t)||Yh.throwArgumentError("invalid hex string","value",t),t.length>2*e+2&&Yh.throwArgumentError("value out of range","value",arguments[1]);t.length<2*e+2;)t="0x0"+t.substring(2);return t}function uu(t){return"0x"+Kt.keccak_256(ru(t))}const lu=new Wh("strings/5.7.0");var cu,du;function fu(t,e,r,i,n){if(t===du.BAD_PREFIX||t===du.UNEXPECTED_CONTINUE){let t=0;for(let i=e+1;i<r.length&&r[i]>>6==2;i++)t++;return t}return t===du.OVERRUN?r.length-e-1:0}!function(t){t.current="",t.NFC="NFC",t.NFD="NFD",t.NFKC="NFKC",t.NFKD="NFKD"}(cu||(cu={})),function(t){t.UNEXPECTED_CONTINUE="unexpected continuation byte",t.BAD_PREFIX="bad codepoint prefix",t.OVERRUN="string overrun",t.MISSING_CONTINUE="missing continuation byte",t.OUT_OF_RANGE="out of UTF-8 range",t.UTF16_SURROGATE="UTF-16 surrogate",t.OVERLONG="overlong representation"}(du||(du={}));const mu=Object.freeze({error:function(t,e,r,i,n){return lu.throwArgumentError(`invalid codepoint at offset ${e}; ${t}`,"bytes",r)},ignore:fu,replace:function(t,e,r,i,n){return t===du.OVERLONG?(i.push(n),0):(i.push(65533),fu(t,e,r))}});function pu(t,e){null==e&&(e=mu.error),t=ru(t);const r=[];let i=0;for(;i<t.length;){const n=t[i++];if(n>>7==0){r.push(n);continue}let o=null,a=null;if(192==(224&n))o=1,a=127;else if(224==(240&n))o=2,a=2047;else{if(240!=(248&n)){i+=e(128==(192&n)?du.UNEXPECTED_CONTINUE:du.BAD_PREFIX,i-1,t,r);continue}o=3,a=65535}if(i-1+o>=t.length){i+=e(du.OVERRUN,i-1,t,r);continue}let s=n&(1<<8-o-1)-1;for(let n=0;n<o;n++){let n=t[i];if(128!=(192&n)){i+=e(du.MISSING_CONTINUE,i,t,r),s=null;break}s=s<<6|63&n,i++}null!==s&&(s>1114111?i+=e(du.OUT_OF_RANGE,i-1-o,t,r,s):s>=55296&&s<=57343?i+=e(du.UTF16_SURROGATE,i-1-o,t,r,s):s<=a?i+=e(du.OVERLONG,i-1-o,t,r,s):r.push(s))}return r}function gu(t,e=cu.current){e!=cu.current&&(lu.checkNormalize(),t=t.normalize(e));let r=[];for(let e=0;e<t.length;e++){const i=t.charCodeAt(e);if(i<128)r.push(i);else if(i<2048)r.push(i>>6|192),r.push(63&i|128);else if(55296==(64512&i)){e++;const n=t.charCodeAt(e);if(e>=t.length||56320!=(64512&n))throw new Error("invalid utf-8 string");const o=65536+((1023&i)<<10)+(1023&n);r.push(o>>18|240),r.push(o>>12&63|128),r.push(o>>6&63|128),r.push(63&o|128)}else r.push(i>>12|224),r.push(i>>6&63|128),r.push(63&i|128)}return ru(r)}function yu(t,e){return pu(t,e).map((t=>t<=65535?String.fromCharCode(t):(t-=65536,String.fromCharCode(55296+(t>>10&1023),56320+(1023&t))))).join("")}function wu(t){return uu(gu(t))}const vu="hash/5.7.0";function bu(t,e){null==e&&(e=1);const r=[],i=r.forEach,n=function(t,e){i.call(t,(function(t){e>0&&Array.isArray(t)?n(t,e-1):r.push(t)}))};return n(t,e),r}function ku(t){return function(t){let e=0;return()=>t[e++]}(function(t){let e=0;function r(){return t[e++]<<8|t[e++]}let i=r(),n=1,o=[0,1];for(let t=1;t<i;t++)o.push(n+=r());let a=r(),s=e;e+=a;let h=0,u=0;function l(){return 0==h&&(u=u<<8|t[e++],h=8),u>>--h&1}const c=Math.pow(2,31),d=c>>>1,f=d>>1,m=c-1;let p=0;for(let t=0;t<31;t++)p=p<<1|l();let g=[],y=0,w=c;for(;;){let t=Math.floor(((p-y+1)*n-1)/w),e=0,r=i;for(;r-e>1;){let i=e+r>>>1;t<o[i]?r=i:e=i}if(0==e)break;g.push(e);let a=y+Math.floor(w*o[e]/n),s=y+Math.floor(w*o[e+1]/n)-1;for(;0==((a^s)&d);)p=p<<1&m|l(),a=a<<1&m,s=s<<1&m|1;for(;a&~s&f;)p=p&d|p<<1&m>>>1|l(),a=a<<1^d,s=(s^d)<<1|d|1;y=a,w=1+s-a}let v=i-4;return g.map((e=>{switch(e-v){case 3:return v+65792+(t[s++]<<16|t[s++]<<8|t[s++]);case 2:return v+256+(t[s++]<<8|t[s++]);case 1:return v+t[s++];default:return e-1}}))}(t))}function Mu(t){return 1&t?~t>>1:t>>1}function _u(t,e){let r=Array(t);for(let i=0,n=-1;i<t;i++)r[i]=n+=1+e();return r}function Eu(t,e){let r=Array(t);for(let i=0,n=0;i<t;i++)r[i]=n+=Mu(e());return r}function Au(t,e){let r=_u(t(),t),i=t(),n=_u(i,t),o=function(t,e){let r=Array(t);for(let i=0;i<t;i++)r[i]=1+e();return r}(i,t);for(let t=0;t<i;t++)for(let e=0;e<o[t];e++)r.push(n[t]+e);return e?r.map((t=>e[t])):r}function ju(t,e,r){let i=Array(t).fill(void 0).map((()=>[]));for(let n=0;n<e;n++)Eu(t,r).forEach(((t,e)=>i[e].push(t)));return i}function xu(t,e){let r=1+e(),i=e(),n=function(t){let e=[];for(;;){let r=t();if(0==r)break;e.push(r)}return e}(e);return bu(ju(n.length,1+t,e).map(((t,e)=>{const o=t[0],a=t.slice(1);return Array(n[e]).fill(void 0).map(((t,e)=>{let n=e*i;return[o+e*r,a.map((t=>t+n))]}))})))}function Su(t,e){return ju(1+e(),1+t,e).map((t=>[t[0],t.slice(1)]))}const Nu=ku(function(t){t=atob(t);const e=[];for(let r=0;r<t.length;r++)e.push(t.charCodeAt(r));return ru(e)}("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==")),Iu=new Set(Au(Nu)),Tu=new Set(Au(Nu)),Cu=function(t){let e=[];for(;;){let r=t();if(0==r)break;e.push(xu(r,t))}for(;;){let r=t()-1;if(r<0)break;e.push(Su(r,t))}return function(t){const e={};for(let r=0;r<t.length;r++){const i=t[r];e[i[0]]=i[1]}return e}(bu(e))}(Nu),zu=function(t){let e=Au(t).sort(((t,e)=>t-e));return function r(){let i=[];for(;;){let n=Au(t,e);if(0==n.length)break;i.push({set:new Set(n),node:r()})}i.sort(((t,e)=>e.set.size-t.set.size));let n=t(),o=n%3;n=n/3|0;let a=!!(1&n);return n>>=1,{branches:i,valid:o,fe0f:a,save:1==n,check:2==n}}()}(Nu);function Ou(t){return function(t,e=cu.current){return pu(gu(t,e))}(t)}function Ru(t){return t.filter((t=>65039!=t))}function Pu(t){for(let e of t.split(".")){let t=Ou(e);try{for(let e=t.lastIndexOf(95)-1;e>=0;e--)if(95!==t[e])throw new Error("underscore only allowed at start");if(t.length>=4&&t.every((t=>t<128))&&45===t[2]&&45===t[3])throw new Error("invalid label extension")}catch(t){throw new Error(`Invalid label "${e}": ${t.message}`)}}return t}function Bu(t){return Pu(function(t,e){let r=Ou(t).reverse(),i=[];for(;r.length;){let t=Du(r);if(t){i.push(...e(t));continue}let n=r.pop();if(Iu.has(n)){i.push(n);continue}if(Tu.has(n))continue;let o=Cu[n];if(!o)throw new Error(`Disallowed codepoint: 0x${n.toString(16).toUpperCase()}`);i.push(...o)}return Pu(function(t){return t.normalize("NFC")}(String.fromCodePoint(...i)))}(t,Ru))}function Du(t,e){var r;let i,n,o=zu,a=[],s=t.length;for(e&&(e.length=0);s;){let h=t[--s];if(o=null===(r=o.branches.find((t=>t.set.has(h))))||void 0===r?void 0:r.node,!o)break;if(o.save)n=h;else if(o.check&&h===n)break;a.push(h),o.fe0f&&(a.push(65039),s>0&&65039==t[s-1]&&s--),o.valid&&(i=a.slice(),2==o.valid&&i.splice(1,1),e&&e.push(...t.slice(s).reverse()),t.length=s)}return i}const $u=new Wh(vu),Lu=new Uint8Array(32);function Fu(t){if(0===t.length)throw new Error("invalid ENS name; empty component");return t}function Uu(t){const e=gu(Bu(t)),r=[];if(0===t.length)return r;let i=0;for(let t=0;t<e.length;t++){46===e[t]&&(r.push(Fu(e.slice(i,t))),i=t+1)}if(i>=e.length)throw new Error("invalid ENS name; empty component");return r.push(Fu(e.slice(i))),r}function qu(t){return Uu(t).map((t=>yu(t))).join(".")}function Vu(t){"string"!=typeof t&&$u.throwArgumentError("invalid ENS name; not a string","name",t);let e=Lu;const r=Uu(t);for(;r.length;)e=uu(iu([e,uu(r.pop())]));return au(e)}Lu.fill(0);const Hu=new Wh("address/5.7.0");function Gu(t){nu(t,20)||Hu.throwArgumentError("invalid address","address",t);const e=(t=t.toLowerCase()).substring(2).split(""),r=new Uint8Array(40);for(let t=0;t<40;t++)r[t]=e[t].charCodeAt(0);const i=ru(uu(r));for(let t=0;t<40;t+=2)i[t>>1]>>4>=8&&(e[t]=e[t].toUpperCase()),(15&i[t>>1])>=8&&(e[t+1]=e[t+1].toUpperCase());return"0x"+e.join("")}const Zu={};for(let t=0;t<10;t++)Zu[String(t)]=String(t);for(let t=0;t<26;t++)Zu[String.fromCharCode(65+t)]=String(10+t);const Ku=Math.floor(function(t){return Math.log10?Math.log10(t):Math.log(t)/Math.LN10}(9007199254740991));function Ju(t){let e=null;if("string"!=typeof t&&Hu.throwArgumentError("invalid address","address",t),t.match(/^(0x)?[0-9a-fA-F]{40}$/))"0x"!==t.substring(0,2)&&(t="0x"+t),e=Gu(t),t.match(/([A-F].*[a-f])|([a-f].*[A-F])/)&&e!==t&&Hu.throwArgumentError("bad address checksum","address",t);else if(t.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)){for(t.substring(2,4)!==function(t){let e=(t=(t=t.toUpperCase()).substring(4)+t.substring(0,2)+"00").split("").map((t=>Zu[t])).join("");for(;e.length>=Ku;){let t=e.substring(0,Ku);e=parseInt(t,10)%97+e.substring(t.length)}let r=String(98-parseInt(e,10)%97);for(;r.length<2;)r="0"+r;return r}(t)&&Hu.throwArgumentError("bad icap checksum","address",t),r=t.substring(4),e=new ah(r,36).toString(16);e.length<40;)e="0"+e;e=Gu("0x"+e)}else Hu.throwArgumentError("invalid address","address",t);var r;return e}window&&window.__awaiter;const Wu=new Wh("properties/5.7.0");function Yu(t,e,r){Object.defineProperty(t,e,{enumerable:!0,value:r,writable:!1})}function Qu(t){const e={};for(const r in t)e[r]=t[r];return e}const Xu={bigint:!0,boolean:!0,function:!0,number:!0,string:!0};function tl(t){if(null==t||Xu[typeof t])return!0;if(Array.isArray(t)||"object"==typeof t){if(!Object.isFrozen(t))return!1;const e=Object.keys(t);for(let r=0;r<e.length;r++){let i=null;try{i=t[e[r]]}catch(t){continue}if(!tl(i))return!1}return!0}return Wu.throwArgumentError("Cannot deepCopy "+typeof t,"object",t)}function el(t){if(tl(t))return t;if(Array.isArray(t))return Object.freeze(t.map((t=>rl(t))));if("object"==typeof t){const e={};for(const r in t){const i=t[r];void 0!==i&&Yu(e,r,rl(i))}return e}return Wu.throwArgumentError("Cannot deepCopy "+typeof t,"object",t)}function rl(t){return el(t)}var il=window&&window.__awaiter||function(t,e,r,i){return new(r||(r=Promise))((function(n,o){function a(t){try{h(i.next(t))}catch(t){o(t)}}function s(t){try{h(i.throw(t))}catch(t){o(t)}}function h(t){var e;t.done?n(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(a,s)}h((i=i.apply(t,e||[])).next())}))};const nl=new Wh(vu),ol=new Uint8Array(32);ol.fill(0);const al=ch.from(-1),sl=ch.from(0),hl=ch.from(1),ul=ch.from("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");const ll=hu(hl.toHexString(),32),cl=hu(sl.toHexString(),32),dl={name:"string",version:"string",chainId:"uint256",verifyingContract:"address",salt:"bytes32"},fl=["name","version","chainId","verifyingContract","salt"];function ml(t){return function(e){return"string"!=typeof e&&nl.throwArgumentError(`invalid domain value for ${JSON.stringify(t)}`,`domain.${t}`,e),e}}const pl={name:ml("name"),version:ml("version"),chainId:function(t){try{return ch.from(t).toString()}catch(t){}return nl.throwArgumentError('invalid domain value for "chainId"',"domain.chainId",t)},verifyingContract:function(t){try{return Ju(t).toLowerCase()}catch(t){}return nl.throwArgumentError('invalid domain value "verifyingContract"',"domain.verifyingContract",t)},salt:function(t){try{const e=ru(t);if(32!==e.length)throw new Error("bad length");return au(e)}catch(t){}return nl.throwArgumentError('invalid domain value "salt"',"domain.salt",t)}};function gl(t){{const e=t.match(/^(u?)int(\d*)$/);if(e){const r=""===e[1],i=parseInt(e[2]||"256");(i%8!=0||i>256||e[2]&&e[2]!==String(i))&&nl.throwArgumentError("invalid numeric width","type",t);const n=ul.mask(r?i-1:i),o=r?n.add(hl).mul(al):sl;return function(e){const r=ch.from(e);return(r.lt(o)||r.gt(n))&&nl.throwArgumentError(`value out-of-bounds for ${t}`,"value",e),hu(r.toTwos(256).toHexString(),32)}}}{const e=t.match(/^bytes(\d+)$/);if(e){const r=parseInt(e[1]);return(0===r||r>32||e[1]!==String(r))&&nl.throwArgumentError("invalid bytes width","type",t),function(e){return ru(e).length!==r&&nl.throwArgumentError(`invalid length for ${t}`,"value",e),function(t){const e=ru(t),r=e.length%32;return r?su([e,ol.slice(r)]):au(e)}(e)}}}switch(t){case"address":return function(t){return hu(Ju(t),32)};case"bool":return function(t){return t?ll:cl};case"bytes":return function(t){return uu(t)};case"string":return function(t){return wu(t)}}return null}function yl(t,e){return`${t}(${e.map((({name:t,type:e})=>e+" "+t)).join(",")})`}class wl{constructor(t){Yu(this,"types",Object.freeze(rl(t))),Yu(this,"_encoderCache",{}),Yu(this,"_types",{});const e={},r={},i={};Object.keys(t).forEach((t=>{e[t]={},r[t]=[],i[t]={}}));for(const i in t){const n={};t[i].forEach((o=>{n[o.name]&&nl.throwArgumentError(`duplicate variable name ${JSON.stringify(o.name)} in ${JSON.stringify(i)}`,"types",t),n[o.name]=!0;const a=o.type.match(/^([^\x5b]*)(\x5b|$)/)[1];a===i&&nl.throwArgumentError(`circular type reference to ${JSON.stringify(a)}`,"types",t);gl(a)||(r[a]||nl.throwArgumentError(`unknown type ${JSON.stringify(a)}`,"types",t),r[a].push(i),e[i][a]=!0)}))}const n=Object.keys(r).filter((t=>0===r[t].length));0===n.length?nl.throwArgumentError("missing primary type","types",t):n.length>1&&nl.throwArgumentError(`ambiguous primary types or unused types: ${n.map((t=>JSON.stringify(t))).join(", ")}`,"types",t),Yu(this,"primaryType",n[0]),function n(o,a){a[o]&&nl.throwArgumentError(`circular type reference to ${JSON.stringify(o)}`,"types",t),a[o]=!0,Object.keys(e[o]).forEach((t=>{r[t]&&(n(t,a),Object.keys(a).forEach((e=>{i[e][t]=!0})))})),delete a[o]}(this.primaryType,{});for(const e in i){const r=Object.keys(i[e]);r.sort(),this._types[e]=yl(e,t[e])+r.map((e=>yl(e,t[e]))).join("")}}getEncoder(t){let e=this._encoderCache[t];return e||(e=this._encoderCache[t]=this._getEncoder(t)),e}_getEncoder(t){{const e=gl(t);if(e)return e}const e=t.match(/^(.*)(\x5b(\d*)\x5d)$/);if(e){const t=e[1],r=this.getEncoder(t),i=parseInt(e[3]);return e=>{i>=0&&e.length!==i&&nl.throwArgumentError("array length mismatch; expected length ${ arrayLength }","value",e);let n=e.map(r);return this._types[t]&&(n=n.map(uu)),uu(su(n))}}const r=this.types[t];if(r){const e=wu(this._types[t]);return t=>{const i=r.map((({name:e,type:r})=>{const i=this.getEncoder(r)(t[e]);return this._types[r]?uu(i):i}));return i.unshift(e),su(i)}}return nl.throwArgumentError(`unknown type: ${t}`,"type",t)}encodeType(t){const e=this._types[t];return e||nl.throwArgumentError(`unknown type: ${JSON.stringify(t)}`,"name",t),e}encodeData(t,e){return this.getEncoder(t)(e)}hashStruct(t,e){return uu(this.encodeData(t,e))}encode(t){return this.encodeData(this.primaryType,t)}hash(t){return this.hashStruct(this.primaryType,t)}_visit(t,e,r){if(gl(t))return r(t,e);const i=t.match(/^(.*)(\x5b(\d*)\x5d)$/);if(i){const t=i[1],n=parseInt(i[3]);return n>=0&&e.length!==n&&nl.throwArgumentError("array length mismatch; expected length ${ arrayLength }","value",e),e.map((e=>this._visit(t,e,r)))}const n=this.types[t];return n?n.reduce(((t,{name:i,type:n})=>(t[i]=this._visit(n,e[i],r),t)),{}):nl.throwArgumentError(`unknown type: ${t}`,"type",t)}visit(t,e){return this._visit(this.primaryType,t,e)}static from(t){return new wl(t)}static getPrimaryType(t){return wl.from(t).primaryType}static hashStruct(t,e,r){return wl.from(e).hashStruct(t,r)}static hashDomain(t){const e=[];for(const r in t){const i=dl[r];i||nl.throwArgumentError(`invalid typed-data domain key: ${JSON.stringify(r)}`,"domain",t),e.push({name:r,type:i})}return e.sort(((t,e)=>fl.indexOf(t.name)-fl.indexOf(e.name))),wl.hashStruct("EIP712Domain",{EIP712Domain:e},t)}static encode(t,e,r){return su(["0x1901",wl.hashDomain(t),wl.from(e).hash(r)])}static hash(t,e,r){return uu(wl.encode(t,e,r))}static resolveNames(t,e,r,i){return il(this,void 0,void 0,(function*(){t=Qu(t);const n={};t.verifyingContract&&!nu(t.verifyingContract,20)&&(n[t.verifyingContract]="0x");const o=wl.from(e);o.visit(r,((t,e)=>("address"!==t||nu(e,20)||(n[e]="0x"),e)));for(const t in n)n[t]=yield i(t);return t.verifyingContract&&n[t.verifyingContract]&&(t.verifyingContract=n[t.verifyingContract]),r=o.visit(r,((t,e)=>"address"===t&&n[e]?n[e]:e)),{domain:t,value:r}}))}static getPayload(t,e,r){wl.hashDomain(t);const i={},n=[];fl.forEach((e=>{const r=t[e];null!=r&&(i[e]=pl[e](r),n.push({name:e,type:dl[e]}))}));const o=wl.from(e),a=Qu(e);return a.EIP712Domain?nl.throwArgumentError("types must not contain EIP712Domain type","types.EIP712Domain",e):a.EIP712Domain=n,o.encode(r),{types:a,domain:i,primaryType:o.primaryType,message:o.visit(r,((t,e)=>{if(t.match(/^bytes(\d*)/))return au(ru(e));if(t.match(/^u?int/))return ch.from(e).toString();switch(t){case"address":return e.toLowerCase();case"bool":return!!e;case"string":return"string"!=typeof e&&nl.throwArgumentError("invalid string","value",e),e}return nl.throwArgumentError("unsupported type","type",t)}))}}}var vl=function(t){this.value=t},bl=Object.defineProperty({EnumType:vl},"__esModule",{value:!0}),kl=function(){function t(t){this.value=t}return t.prototype.toJSON=function(){return"$"+this.value},t}(),Ml=Object.defineProperty({VariableType:kl},"__esModule",{value:!0}),_l=a((function(t,e){function r(t){if(t instanceof bl.EnumType)return t.value;if(t instanceof Ml.VariableType)return"$"+t.value;if("object"!=typeof t||null===t)return JSON.stringify(t);if(Array.isArray(t))return"["+t.map((function(t){return r(t)})).join(", ")+"]";var e=Object.keys(t).map((function(e){return e+": "+r(t[e])})).join(", ");return"{"+e+"}"}function i(t,r){return-1==e.configFields.indexOf(t)&&-1==r.indexOf(t)}function n(t,e,o,a){Object.keys(t).filter((function(t){return i(t,a.ignoreFields)})).forEach((function(s){var h=t[s];if("object"==typeof h){if(Array.isArray(h)&&!(h=h.find((function(t){return t&&"object"==typeof t}))))return void o.push([""+s,e]);var u=Object.keys(h).filter((function(t){return i(t,a.ignoreFields)})).length>0,l="object"==typeof h.__args&&Object.keys(h.__args).length>0,c="object"==typeof h.__directives,d=h.__all_on instanceof Array,f="object"==typeof h.__on,m=""+s;if("string"==typeof h.__name&&(m=m+" "+h.__name),"string"==typeof h.__aliasFor&&(m=m+": "+h.__aliasFor),"object"==typeof h.__variables&&Object.keys(h.__variables).length>0)m=m+" ("+function(t){var e=[];for(var r in t)e.push("$"+r+": "+t[r]);return e.join(", ")}(h.__variables)+")";else if(l||c){var p="",g="";c&&(g=Object.entries(h.__directives).map((function(t){var e;return"@"+function(t){var e=Object.keys(t)[0],i=t[e];if("boolean"==typeof i||"object"==typeof i&&0===Object.keys(i).length)return e;if("object"==typeof i){var n=[];for(var o in i){var a=r(i[o]).replace(/"/g,"");n.push(o+": "+a)}return e+"("+n.join(", ")+")"}throw new Error("Unsupported type for directive: "+typeof i+". Types allowed: object, boolean.\nOffending object: "+JSON.stringify(t))}(((e={})[t[0]]=t[1],e))})).join(" ")),l&&(p="("+function(t){var e=[];for(var i in t)e.push(i+": "+r(t[i]));return e.join(", ")}(h.__args)+")"),m=m+" "+p+(c&&l?" ":"")+g}if(o.push([m+(u||f||d?" {":""),e]),n(h,e+1,o,a),d&&h.__all_on.forEach((function(t){o.push(["..."+t,e+1])})),f)(h.__on instanceof Array?h.__on:[h.__on]).forEach((function(t){var r=t.__typeName;o.push(["... on "+r+" {",e+1]),n(t,e+2,o,a),o.push(["}",e+1])}));(u||f||d)&&o.push(["}",e])}else(!0===a.includeFalsyKeys||h)&&o.push([""+s,e])}))}Object.defineProperty(e,"__esModule",{value:!0}),e.configFields=["__args","__alias","__aliasFor","__variables","__directives","__on","__all_on","__typeName","__name"],e.jsonToGraphQLQuery=function(t,e){if(void 0===e&&(e={}),!t||"object"!=typeof t)throw new Error("query object not specified");if(0==Object.keys(t).length)throw new Error("query object has no data");e.ignoreFields instanceof Array||(e.ignoreFields=[]);var r=[];n(t,0,r,e);var i="";return r.forEach((function(t){var r=t[0],n=t[1];e.pretty?(i&&(i+="\n"),i+=function(t){return Array(4*t+1).join(" ")}(n)+r):(i&&(i+=" "),i+=r)})),i}})),El=a((function(t,e){Object.defineProperty(e,"__esModule",{value:!0}),function(t){for(var r in t)e.hasOwnProperty(r)||(e[r]=t[r])}(_l),e.EnumType=bl.EnumType,e.VariableType=Ml.VariableType})),Al=a((function(t,e){Object.defineProperty(e,"__esModule",{value:!0}),e.regexpCode=e.getEsmExportName=e.getProperty=e.safeStringify=e.stringify=e.strConcat=e.addCodeArg=e.str=e._=e.nil=e._Code=e.Name=e.IDENTIFIER=e._CodeOrName=void 0;class r{}e._CodeOrName=r,e.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;class i extends r{constructor(t){if(super(),!e.IDENTIFIER.test(t))throw new Error("CodeGen: name must be a valid identifier");this.str=t}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}}e.Name=i;class n extends r{constructor(t){super(),this._items="string"==typeof t?[t]:t}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;const t=this._items[0];return""===t||'""'===t}get str(){var t;return null!==(t=this._str)&&void 0!==t?t:this._str=this._items.reduce(((t,e)=>`${t}${e}`),"")}get names(){var t;return null!==(t=this._names)&&void 0!==t?t:this._names=this._items.reduce(((t,e)=>(e instanceof i&&(t[e.str]=(t[e.str]||0)+1),t)),{})}}function o(t,...e){const r=[t[0]];let i=0;for(;i<e.length;)h(r,e[i]),r.push(t[++i]);return new n(r)}e._Code=n,e.nil=new n(""),e._=o;const a=new n("+");function s(t,...e){const r=[l(t[0])];let i=0;for(;i<e.length;)r.push(a),h(r,e[i]),r.push(a,l(t[++i]));return function(t){let e=1;for(;e<t.length-1;){if(t[e]===a){const r=u(t[e-1],t[e+1]);if(void 0!==r){t.splice(e-1,3,r);continue}t[e++]="+"}e++}}(r),new n(r)}function h(t,e){e instanceof n?t.push(...e._items):e instanceof i?t.push(e):t.push(function(t){return"number"==typeof t||"boolean"==typeof t||null===t?t:l(Array.isArray(t)?t.join(","):t)}(e))}function u(t,e){if('""'===e)return t;if('""'===t)return e;if("string"==typeof t){if(e instanceof i||'"'!==t[t.length-1])return;return"string"!=typeof e?`${t.slice(0,-1)}${e}"`:'"'===e[0]?t.slice(0,-1)+e.slice(1):void 0}return"string"!=typeof e||'"'!==e[0]||t instanceof i?void 0:`"${t}${e.slice(1)}`}function l(t){return JSON.stringify(t).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}e.str=s,e.addCodeArg=h,e.strConcat=function(t,e){return e.emptyStr()?t:t.emptyStr()?e:s`${t}${e}`},e.stringify=function(t){return new n(l(t))},e.safeStringify=l,e.getProperty=function(t){return"string"==typeof t&&e.IDENTIFIER.test(t)?new n(`.${t}`):o`[${t}]`},e.getEsmExportName=function(t){if("string"==typeof t&&e.IDENTIFIER.test(t))return new n(`${t}`);throw new Error(`CodeGen: invalid export name: ${t}, use explicit $id name mapping`)},e.regexpCode=function(t){return new n(t.toString())}})),jl=a((function(t,e){Object.defineProperty(e,"__esModule",{value:!0}),e.ValueScope=e.ValueScopeName=e.Scope=e.varKinds=e.UsedValueState=void 0;class r extends Error{constructor(t){super(`CodeGen: "code" for ${t} not defined`),this.value=t.value}}var i;!function(t){t[t.Started=0]="Started",t[t.Completed=1]="Completed"}(i=e.UsedValueState||(e.UsedValueState={})),e.varKinds={const:new Al.Name("const"),let:new Al.Name("let"),var:new Al.Name("var")};class n{constructor({prefixes:t,parent:e}={}){this._names={},this._prefixes=t,this._parent=e}toName(t){return t instanceof Al.Name?t:this.name(t)}name(t){return new Al.Name(this._newName(t))}_newName(t){return`${t}${(this._names[t]||this._nameGroup(t)).index++}`}_nameGroup(t){var e,r;if((null===(r=null===(e=this._parent)||void 0===e?void 0:e._prefixes)||void 0===r?void 0:r.has(t))||this._prefixes&&!this._prefixes.has(t))throw new Error(`CodeGen: prefix "${t}" is not allowed in this scope`);return this._names[t]={prefix:t,index:0}}}e.Scope=n;class o extends Al.Name{constructor(t,e){super(e),this.prefix=t}setValue(t,{property:e,itemIndex:r}){this.value=t,this.scopePath=Al._`.${new Al.Name(e)}[${r}]`}}e.ValueScopeName=o;const a=Al._`\n`;e.ValueScope=class extends n{constructor(t){super(t),this._values={},this._scope=t.scope,this.opts={...t,_n:t.lines?a:Al.nil}}get(){return this._scope}name(t){return new o(t,this._newName(t))}value(t,e){var r;if(void 0===e.ref)throw new Error("CodeGen: ref must be passed in value");const i=this.toName(t),{prefix:n}=i,o=null!==(r=e.key)&&void 0!==r?r:e.ref;let a=this._values[n];if(a){const t=a.get(o);if(t)return t}else a=this._values[n]=new Map;a.set(o,i);const s=this._scope[n]||(this._scope[n]=[]),h=s.length;return s[h]=e.ref,i.setValue(e,{property:n,itemIndex:h}),i}getValue(t,e){const r=this._values[t];if(r)return r.get(e)}scopeRefs(t,e=this._values){return this._reduceValues(e,(e=>{if(void 0===e.scopePath)throw new Error(`CodeGen: name "${e}" has no value`);return Al._`${t}${e.scopePath}`}))}scopeCode(t=this._values,e,r){return this._reduceValues(t,(t=>{if(void 0===t.value)throw new Error(`CodeGen: name "${t}" has no value`);return t.value.code}),e,r)}_reduceValues(t,n,o={},a){let s=Al.nil;for(const h in t){const u=t[h];if(!u)continue;const l=o[h]=o[h]||new Map;u.forEach((t=>{if(l.has(t))return;l.set(t,i.Started);let o=n(t);if(o){const r=this.opts.es5?e.varKinds.var:e.varKinds.const;s=Al._`${s}${r} ${t} = ${o};${this.opts._n}`}else{if(!(o=null==a?void 0:a(t)))throw new r(t);s=Al._`${s}${o}${this.opts._n}`}l.set(t,i.Completed)}))}return s}}})),xl=a((function(t,e){Object.defineProperty(e,"__esModule",{value:!0}),e.or=e.and=e.not=e.CodeGen=e.operators=e.varKinds=e.ValueScopeName=e.ValueScope=e.Scope=e.Name=e.regexpCode=e.stringify=e.getProperty=e.nil=e.strConcat=e.str=e._=void 0;var r=Al;Object.defineProperty(e,"_",{enumerable:!0,get:function(){return r._}}),Object.defineProperty(e,"str",{enumerable:!0,get:function(){return r.str}}),Object.defineProperty(e,"strConcat",{enumerable:!0,get:function(){return r.strConcat}}),Object.defineProperty(e,"nil",{enumerable:!0,get:function(){return r.nil}}),Object.defineProperty(e,"getProperty",{enumerable:!0,get:function(){return r.getProperty}}),Object.defineProperty(e,"stringify",{enumerable:!0,get:function(){return r.stringify}}),Object.defineProperty(e,"regexpCode",{enumerable:!0,get:function(){return r.regexpCode}}),Object.defineProperty(e,"Name",{enumerable:!0,get:function(){return r.Name}});var i=jl;Object.defineProperty(e,"Scope",{enumerable:!0,get:function(){return i.Scope}}),Object.defineProperty(e,"ValueScope",{enumerable:!0,get:function(){return i.ValueScope}}),Object.defineProperty(e,"ValueScopeName",{enumerable:!0,get:function(){return i.ValueScopeName}}),Object.defineProperty(e,"varKinds",{enumerable:!0,get:function(){return i.varKinds}}),e.operators={GT:new Al._Code(">"),GTE:new Al._Code(">="),LT:new Al._Code("<"),LTE:new Al._Code("<="),EQ:new Al._Code("==="),NEQ:new Al._Code("!=="),NOT:new Al._Code("!"),OR:new Al._Code("||"),AND:new Al._Code("&&"),ADD:new Al._Code("+")};class n{optimizeNodes(){return this}optimizeNames(t,e){return this}}class o extends n{constructor(t,e,r){super(),this.varKind=t,this.name=e,this.rhs=r}render({es5:t,_n:e}){const r=t?jl.varKinds.var:this.varKind,i=void 0===this.rhs?"":` = ${this.rhs}`;return`${r} ${this.name}${i};`+e}optimizeNames(t,e){if(t[this.name.str])return this.rhs&&(this.rhs=S(this.rhs,t,e)),this}get names(){return this.rhs instanceof Al._CodeOrName?this.rhs.names:{}}}class a extends n{constructor(t,e,r){super(),this.lhs=t,this.rhs=e,this.sideEffects=r}render({_n:t}){return`${this.lhs} = ${this.rhs};`+t}optimizeNames(t,e){if(!(this.lhs instanceof Al.Name)||t[this.lhs.str]||this.sideEffects)return this.rhs=S(this.rhs,t,e),this}get names(){return x(this.lhs instanceof Al.Name?{}:{...this.lhs.names},this.rhs)}}class s extends a{constructor(t,e,r,i){super(t,r,i),this.op=e}render({_n:t}){return`${this.lhs} ${this.op}= ${this.rhs};`+t}}class h extends n{constructor(t){super(),this.label=t,this.names={}}render({_n:t}){return`${this.label}:`+t}}class u extends n{constructor(t){super(),this.label=t,this.names={}}render({_n:t}){return`break${this.label?` ${this.label}`:""};`+t}}class l extends n{constructor(t){super(),this.error=t}render({_n:t}){return`throw ${this.error};`+t}get names(){return this.error.names}}class c extends n{constructor(t){super(),this.code=t}render({_n:t}){return`${this.code};`+t}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(t,e){return this.code=S(this.code,t,e),this}get names(){return this.code instanceof Al._CodeOrName?this.code.names:{}}}class d extends n{constructor(t=[]){super(),this.nodes=t}render(t){return this.nodes.reduce(((e,r)=>e+r.render(t)),"")}optimizeNodes(){const{nodes:t}=this;let e=t.length;for(;e--;){const r=t[e].optimizeNodes();Array.isArray(r)?t.splice(e,1,...r):r?t[e]=r:t.splice(e,1)}return t.length>0?this:void 0}optimizeNames(t,e){const{nodes:r}=this;let i=r.length;for(;i--;){const n=r[i];n.optimizeNames(t,e)||(N(t,n.names),r.splice(i,1))}return r.length>0?this:void 0}get names(){return this.nodes.reduce(((t,e)=>j(t,e.names)),{})}}class f extends d{render(t){return"{"+t._n+super.render(t)+"}"+t._n}}class m extends d{}class p extends f{}p.kind="else";class g extends f{constructor(t,e){super(e),this.condition=t}render(t){let e=`if(${this.condition})`+super.render(t);return this.else&&(e+="else "+this.else.render(t)),e}optimizeNodes(){super.optimizeNodes();const t=this.condition;if(!0===t)return this.nodes;let e=this.else;if(e){const t=e.optimizeNodes();e=this.else=Array.isArray(t)?new p(t):t}return e?!1===t?e instanceof g?e:e.nodes:this.nodes.length?this:new g(I(t),e instanceof g?[e]:e.nodes):!1!==t&&this.nodes.length?this:void 0}optimizeNames(t,e){var r;if(this.else=null===(r=this.else)||void 0===r?void 0:r.optimizeNames(t,e),super.optimizeNames(t,e)||this.else)return this.condition=S(this.condition,t,e),this}get names(){const t=super.names;return x(t,this.condition),this.else&&j(t,this.else.names),t}}g.kind="if";class y extends f{}y.kind="for";class w extends y{constructor(t){super(),this.iteration=t}render(t){return`for(${this.iteration})`+super.render(t)}optimizeNames(t,e){if(super.optimizeNames(t,e))return this.iteration=S(this.iteration,t,e),this}get names(){return j(super.names,this.iteration.names)}}class v extends y{constructor(t,e,r,i){super(),this.varKind=t,this.name=e,this.from=r,this.to=i}render(t){const e=t.es5?jl.varKinds.var:this.varKind,{name:r,from:i,to:n}=this;return`for(${e} ${r}=${i}; ${r}<${n}; ${r}++)`+super.render(t)}get names(){const t=x(super.names,this.from);return x(t,this.to)}}class b extends y{constructor(t,e,r,i){super(),this.loop=t,this.varKind=e,this.name=r,this.iterable=i}render(t){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(t)}optimizeNames(t,e){if(super.optimizeNames(t,e))return this.iterable=S(this.iterable,t,e),this}get names(){return j(super.names,this.iterable.names)}}class k extends f{constructor(t,e,r){super(),this.name=t,this.args=e,this.async=r}render(t){return`${this.async?"async ":""}function ${this.name}(${this.args})`+super.render(t)}}k.kind="func";class M extends d{render(t){return"return "+super.render(t)}}M.kind="return";class _ extends f{render(t){let e="try"+super.render(t);return this.catch&&(e+=this.catch.render(t)),this.finally&&(e+=this.finally.render(t)),e}optimizeNodes(){var t,e;return super.optimizeNodes(),null===(t=this.catch)||void 0===t||t.optimizeNodes(),null===(e=this.finally)||void 0===e||e.optimizeNodes(),this}optimizeNames(t,e){var r,i;return super.optimizeNames(t,e),null===(r=this.catch)||void 0===r||r.optimizeNames(t,e),null===(i=this.finally)||void 0===i||i.optimizeNames(t,e),this}get names(){const t=super.names;return this.catch&&j(t,this.catch.names),this.finally&&j(t,this.finally.names),t}}class E extends f{constructor(t){super(),this.error=t}render(t){return`catch(${this.error})`+super.render(t)}}E.kind="catch";class A extends f{render(t){return"finally"+super.render(t)}}A.kind="finally";function j(t,e){for(const r in e)t[r]=(t[r]||0)+(e[r]||0);return t}function x(t,e){return e instanceof Al._CodeOrName?j(t,e.names):t}function S(t,e,r){return t instanceof Al.Name?n(t):(i=t)instanceof Al._Code&&i._items.some((t=>t instanceof Al.Name&&1===e[t.str]&&void 0!==r[t.str]))?new Al._Code(t._items.reduce(((t,e)=>(e instanceof Al.Name&&(e=n(e)),e instanceof Al._Code?t.push(...e._items):t.push(e),t)),[])):t;var i;function n(t){const i=r[t.str];return void 0===i||1!==e[t.str]?t:(delete e[t.str],i)}}function N(t,e){for(const r in e)t[r]=(t[r]||0)-(e[r]||0)}function I(t){return"boolean"==typeof t||"number"==typeof t||null===t?!t:Al._`!${O(t)}`}e.CodeGen=class{constructor(t,e={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...e,_n:e.lines?"\n":""},this._extScope=t,this._scope=new jl.Scope({parent:t}),this._nodes=[new m]}toString(){return this._root.render(this.opts)}name(t){return this._scope.name(t)}scopeName(t){return this._extScope.name(t)}scopeValue(t,e){const r=this._extScope.value(t,e);return(this._values[r.prefix]||(this._values[r.prefix]=new Set)).add(r),r}getScopeValue(t,e){return this._extScope.getValue(t,e)}scopeRefs(t){return this._extScope.scopeRefs(t,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(t,e,r,i){const n=this._scope.toName(e);return void 0!==r&&i&&(this._constants[n.str]=r),this._leafNode(new o(t,n,r)),n}const(t,e,r){return this._def(jl.varKinds.const,t,e,r)}let(t,e,r){return this._def(jl.varKinds.let,t,e,r)}var(t,e,r){return this._def(jl.varKinds.var,t,e,r)}assign(t,e,r){return this._leafNode(new a(t,e,r))}add(t,r){return this._leafNode(new s(t,e.operators.ADD,r))}code(t){return"function"==typeof t?t():t!==Al.nil&&this._leafNode(new c(t)),this}object(...t){const e=["{"];for(const[r,i]of t)e.length>1&&e.push(","),e.push(r),(r!==i||this.opts.es5)&&(e.push(":"),(0,Al.addCodeArg)(e,i));return e.push("}"),new Al._Code(e)}if(t,e,r){if(this._blockNode(new g(t)),e&&r)this.code(e).else().code(r).endIf();else if(e)this.code(e).endIf();else if(r)throw new Error('CodeGen: "else" body without "then" body');return this}elseIf(t){return this._elseNode(new g(t))}else(){return this._elseNode(new p)}endIf(){return this._endBlockNode(g,p)}_for(t,e){return this._blockNode(t),e&&this.code(e).endFor(),this}for(t,e){return this._for(new w(t),e)}forRange(t,e,r,i,n=(this.opts.es5?jl.varKinds.var:jl.varKinds.let)){const o=this._scope.toName(t);return this._for(new v(n,o,e,r),(()=>i(o)))}forOf(t,e,r,i=jl.varKinds.const){const n=this._scope.toName(t);if(this.opts.es5){const t=e instanceof Al.Name?e:this.var("_arr",e);return this.forRange("_i",0,Al._`${t}.length`,(e=>{this.var(n,Al._`${t}[${e}]`),r(n)}))}return this._for(new b("of",i,n,e),(()=>r(n)))}forIn(t,e,r,i=(this.opts.es5?jl.varKinds.var:jl.varKinds.const)){if(this.opts.ownProperties)return this.forOf(t,Al._`Object.keys(${e})`,r);const n=this._scope.toName(t);return this._for(new b("in",i,n,e),(()=>r(n)))}endFor(){return this._endBlockNode(y)}label(t){return this._leafNode(new h(t))}break(t){return this._leafNode(new u(t))}return(t){const e=new M;if(this._blockNode(e),this.code(t),1!==e.nodes.length)throw new Error('CodeGen: "return" should have one node');return this._endBlockNode(M)}try(t,e,r){if(!e&&!r)throw new Error('CodeGen: "try" without "catch" and "finally"');const i=new _;if(this._blockNode(i),this.code(t),e){const t=this.name("e");this._currNode=i.catch=new E(t),e(t)}return r&&(this._currNode=i.finally=new A,this.code(r)),this._endBlockNode(E,A)}throw(t){return this._leafNode(new l(t))}block(t,e){return this._blockStarts.push(this._nodes.length),t&&this.code(t).endBlock(e),this}endBlock(t){const e=this._blockStarts.pop();if(void 0===e)throw new Error("CodeGen: not in self-balancing block");const r=this._nodes.length-e;if(r<0||void 0!==t&&r!==t)throw new Error(`CodeGen: wrong number of nodes: ${r} vs ${t} expected`);return this._nodes.length=e,this}func(t,e=Al.nil,r,i){return this._blockNode(new k(t,e,r)),i&&this.code(i).endFunc(),this}endFunc(){return this._endBlockNode(k)}optimize(t=1){for(;t-- >0;)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants)}_leafNode(t){return this._currNode.nodes.push(t),this}_blockNode(t){this._currNode.nodes.push(t),this._nodes.push(t)}_endBlockNode(t,e){const r=this._currNode;if(r instanceof t||e&&r instanceof e)return this._nodes.pop(),this;throw new Error(`CodeGen: not in block "${e?`${t.kind}/${e.kind}`:t.kind}"`)}_elseNode(t){const e=this._currNode;if(!(e instanceof g))throw new Error('CodeGen: "else" without "if"');return this._currNode=e.else=t,this}get _root(){return this._nodes[0]}get _currNode(){const t=this._nodes;return t[t.length-1]}set _currNode(t){const e=this._nodes;e[e.length-1]=t}},e.not=I;const T=z(e.operators.AND);e.and=function(...t){return t.reduce(T)};const C=z(e.operators.OR);function z(t){return(e,r)=>e===Al.nil?r:r===Al.nil?e:Al._`${O(e)} ${t} ${O(r)}`}function O(t){return t instanceof Al.Name?t:Al._`(${t})`}e.or=function(...t){return t.reduce(C)}})),Sl=a((function(t,e){function r(t,e=t.schema){const{opts:r,self:i}=t;if(!r.strictSchema)return;if("boolean"==typeof e)return;const n=i.RULES.keywords;for(const r in e)n[r]||c(t,`unknown keyword: "${r}"`)}function i(t,e){if("boolean"==typeof t)return!t;for(const r in t)if(e[r])return!0;return!1}function n(t){return"number"==typeof t?`${t}`:t.replace(/~/g,"~0").replace(/\//g,"~1")}function o(t){return t.replace(/~1/g,"/").replace(/~0/g,"~")}function a({mergeNames:t,mergeToName:e,mergeValues:r,resultToName:i}){return(n,o,a,s)=>{const h=void 0===a?o:a instanceof xl.Name?(o instanceof xl.Name?t(n,o,a):e(n,o,a),a):o instanceof xl.Name?(e(n,a,o),o):r(o,a);return s!==xl.Name||h instanceof xl.Name?h:i(n,h)}}function s(t,e){if(!0===e)return t.var("props",!0);const r=t.var("props",xl._`{}`);return void 0!==e&&h(t,r,e),r}function h(t,e,r){Object.keys(r).forEach((r=>t.assign(xl._`${e}${(0,xl.getProperty)(r)}`,!0)))}Object.defineProperty(e,"__esModule",{value:!0}),e.checkStrictMode=e.getErrorPath=e.Type=e.useFunc=e.setEvaluated=e.evaluatedPropsToName=e.mergeEvaluated=e.eachItem=e.unescapeJsonPointer=e.escapeJsonPointer=e.escapeFragment=e.unescapeFragment=e.schemaRefOrVal=e.schemaHasRulesButRef=e.schemaHasRules=e.checkUnknownRules=e.alwaysValidSchema=e.toHash=void 0,e.toHash=function(t){const e={};for(const r of t)e[r]=!0;return e},e.alwaysValidSchema=function(t,e){return"boolean"==typeof e?e:0===Object.keys(e).length||(r(t,e),!i(e,t.self.RULES.all))},e.checkUnknownRules=r,e.schemaHasRules=i,e.schemaHasRulesButRef=function(t,e){if("boolean"==typeof t)return!t;for(const r in t)if("$ref"!==r&&e.all[r])return!0;return!1},e.schemaRefOrVal=function({topSchemaRef:t,schemaPath:e},r,i,n){if(!n){if("number"==typeof r||"boolean"==typeof r)return r;if("string"==typeof r)return xl._`${r}`}return xl._`${t}${e}${(0,xl.getProperty)(i)}`},e.unescapeFragment=function(t){return o(decodeURIComponent(t))},e.escapeFragment=function(t){return encodeURIComponent(n(t))},e.escapeJsonPointer=n,e.unescapeJsonPointer=o,e.eachItem=function(t,e){if(Array.isArray(t))for(const r of t)e(r);else e(t)},e.mergeEvaluated={props:a({mergeNames:(t,e,r)=>t.if(xl._`${r} !== true && ${e} !== undefined`,(()=>{t.if(xl._`${e} === true`,(()=>t.assign(r,!0)),(()=>t.assign(r,xl._`${r} || {}`).code(xl._`Object.assign(${r}, ${e})`)))})),mergeToName:(t,e,r)=>t.if(xl._`${r} !== true`,(()=>{!0===e?t.assign(r,!0):(t.assign(r,xl._`${r} || {}`),h(t,r,e))})),mergeValues:(t,e)=>!0===t||{...t,...e},resultToName:s}),items:a({mergeNames:(t,e,r)=>t.if(xl._`${r} !== true && ${e} !== undefined`,(()=>t.assign(r,xl._`${e} === true ? true : ${r} > ${e} ? ${r} : ${e}`))),mergeToName:(t,e,r)=>t.if(xl._`${r} !== true`,(()=>t.assign(r,!0===e||xl._`${r} > ${e} ? ${r} : ${e}`))),mergeValues:(t,e)=>!0===t||Math.max(t,e),resultToName:(t,e)=>t.var("items",e)})},e.evaluatedPropsToName=s,e.setEvaluated=h;const u={};var l;function c(t,e,r=t.opts.strictSchema){if(r){if(e=`strict mode: ${e}`,!0===r)throw new Error(e);t.self.logger.warn(e)}}e.useFunc=function(t,e){return t.scopeValue("func",{ref:e,code:u[e.code]||(u[e.code]=new Al._Code(e.code))})},function(t){t[t.Num=0]="Num",t[t.Str=1]="Str"}(l=e.Type||(e.Type={})),e.getErrorPath=function(t,e,r){if(t instanceof xl.Name){const i=e===l.Num;return r?i?xl._`"[" + ${t} + "]"`:xl._`"['" + ${t} + "']"`:i?xl._`"/" + ${t}`:xl._`"/" + ${t}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return r?(0,xl.getProperty)(t).toString():"/"+n(t)},e.checkStrictMode=c}));var Nl={data:new xl.Name("data"),valCxt:new xl.Name("valCxt"),instancePath:new xl.Name("instancePath"),parentData:new xl.Name("parentData"),parentDataProperty:new xl.Name("parentDataProperty"),rootData:new xl.Name("rootData"),dynamicAnchors:new xl.Name("dynamicAnchors"),vErrors:new xl.Name("vErrors"),errors:new xl.Name("errors"),this:new xl.Name("this"),self:new xl.Name("self"),scope:new xl.Name("scope"),json:new xl.Name("json"),jsonPos:new xl.Name("jsonPos"),jsonLen:new xl.Name("jsonLen"),jsonPart:new xl.Name("jsonPart")},Il=Object.defineProperty({default:Nl},"__esModule",{value:!0}),Tl=a((function(t,e){function r(t,e){const r=t.const("err",e);t.if(xl._`${Il.default.vErrors} === null`,(()=>t.assign(Il.default.vErrors,xl._`[${r}]`)),xl._`${Il.default.vErrors}.push(${r})`),t.code(xl._`${Il.default.errors}++`)}function i(t,e){const{gen:r,validateName:i,schemaEnv:n}=t;n.$async?r.throw(xl._`new ${t.ValidationError}(${e})`):(r.assign(xl._`${i}.errors`,e),r.return(!1))}Object.defineProperty(e,"__esModule",{value:!0}),e.extendErrors=e.resetErrorsCount=e.reportExtraError=e.reportError=e.keyword$DataError=e.keywordError=void 0,e.keywordError={message:({keyword:t})=>xl.str`must pass "${t}" keyword validation`},e.keyword$DataError={message:({keyword:t,schemaType:e})=>e?xl.str`"${t}" keyword must be ${e} ($data)`:xl.str`"${t}" keyword is invalid ($data)`},e.reportError=function(t,n=e.keywordError,a,s){const{it:h}=t,{gen:u,compositeRule:l,allErrors:c}=h,d=o(t,n,a);(null!=s?s:l||c)?r(u,d):i(h,xl._`[${d}]`)},e.reportExtraError=function(t,n=e.keywordError,a){const{it:s}=t,{gen:h,compositeRule:u,allErrors:l}=s;r(h,o(t,n,a)),u||l||i(s,Il.default.vErrors)},e.resetErrorsCount=function(t,e){t.assign(Il.default.errors,e),t.if(xl._`${Il.default.vErrors} !== null`,(()=>t.if(e,(()=>t.assign(xl._`${Il.default.vErrors}.length`,e)),(()=>t.assign(Il.default.vErrors,null)))))},e.extendErrors=function({gen:t,keyword:e,schemaValue:r,data:i,errsCount:n,it:o}){if(void 0===n)throw new Error("ajv implementation error");const a=t.name("err");t.forRange("i",n,Il.default.errors,(n=>{t.const(a,xl._`${Il.default.vErrors}[${n}]`),t.if(xl._`${a}.instancePath === undefined`,(()=>t.assign(xl._`${a}.instancePath`,(0,xl.strConcat)(Il.default.instancePath,o.errorPath)))),t.assign(xl._`${a}.schemaPath`,xl.str`${o.errSchemaPath}/${e}`),o.opts.verbose&&(t.assign(xl._`${a}.schema`,r),t.assign(xl._`${a}.data`,i))}))};const n={keyword:new xl.Name("keyword"),schemaPath:new xl.Name("schemaPath"),params:new xl.Name("params"),propertyName:new xl.Name("propertyName"),message:new xl.Name("message"),schema:new xl.Name("schema"),parentSchema:new xl.Name("parentSchema")};function o(t,e,r){const{createErrors:i}=t.it;return!1===i?xl._`{}`:function(t,e,r={}){const{gen:i,it:o}=t,h=[a(o,r),s(t,r)];return function(t,{params:e,message:r},i){const{keyword:o,data:a,schemaValue:s,it:h}=t,{opts:u,propertyName:l,topSchemaRef:c,schemaPath:d}=h;i.push([n.keyword,o],[n.params,"function"==typeof e?e(t):e||xl._`{}`]),u.messages&&i.push([n.message,"function"==typeof r?r(t):r]);u.verbose&&i.push([n.schema,s],[n.parentSchema,xl._`${c}${d}`],[Il.default.data,a]);l&&i.push([n.propertyName,l])}(t,e,h),i.object(...h)}(t,e,r)}function a({errorPath:t},{instancePath:e}){const r=e?xl.str`${t}${(0,Sl.getErrorPath)(e,Sl.Type.Str)}`:t;return[Il.default.instancePath,(0,xl.strConcat)(Il.default.instancePath,r)]}function s({keyword:t,it:{errSchemaPath:e}},{schemaPath:r,parentSchema:i}){let o=i?e:xl.str`${e}/${t}`;return r&&(o=xl.str`${o}${(0,Sl.getErrorPath)(r,Sl.Type.Str)}`),[n.schemaPath,o]}})),Cl=a((function(t,e){Object.defineProperty(e,"__esModule",{value:!0}),e.boolOrEmptySchema=e.topBoolOrEmptySchema=void 0;const r={message:"boolean schema is false"};function i(t,e){const{gen:i,data:n}=t,o={gen:i,keyword:"false schema",data:n,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:t};(0,Tl.reportError)(o,r,void 0,e)}e.topBoolOrEmptySchema=function(t){const{gen:e,schema:r,validateName:n}=t;!1===r?i(t,!1):"object"==typeof r&&!0===r.$async?e.return(Il.default.data):(e.assign(xl._`${n}.errors`,null),e.return(!0))},e.boolOrEmptySchema=function(t,e){const{gen:r,schema:n}=t;!1===n?(r.var(e,!1),i(t)):r.var(e,!0)}})),zl=a((function(t,e){Object.defineProperty(e,"__esModule",{value:!0}),e.getRules=e.isJSONType=void 0;const r=new Set(["string","number","integer","boolean","null","object","array"]);e.isJSONType=function(t){return"string"==typeof t&&r.has(t)},e.getRules=function(){const t={number:{type:"number",rules:[]},string:{type:"string",rules:[]},array:{type:"array",rules:[]},object:{type:"object",rules:[]}};return{types:{...t,integer:!0,boolean:!0,null:!0},rules:[{rules:[]},t.number,t.string,t.array,t.object],post:{rules:[]},all:{},keywords:{}}}})),Ol=a((function(t,e){function r(t,e){return e.rules.some((e=>i(t,e)))}function i(t,e){var r;return void 0!==t[e.keyword]||(null===(r=e.definition.implements)||void 0===r?void 0:r.some((e=>void 0!==t[e])))}Object.defineProperty(e,"__esModule",{value:!0}),e.shouldUseRule=e.shouldUseGroup=e.schemaHasRulesForType=void 0,e.schemaHasRulesForType=function({schema:t,self:e},i){const n=e.RULES.types[i];return n&&!0!==n&&r(t,n)},e.shouldUseGroup=r,e.shouldUseRule=i})),Rl=a((function(t,e){var r;function i(t){const e=Array.isArray(t)?t:t?[t]:[];if(e.every(zl.isJSONType))return e;throw new Error("type must be JSONType or JSONType[]: "+e.join(","))}Object.defineProperty(e,"__esModule",{value:!0}),e.reportTypeError=e.checkDataTypes=e.checkDataType=e.coerceAndCheckDataType=e.getJSONTypes=e.getSchemaTypes=e.DataType=void 0,function(t){t[t.Correct=0]="Correct",t[t.Wrong=1]="Wrong"}(r=e.DataType||(e.DataType={})),e.getSchemaTypes=function(t){const e=i(t.type);if(e.includes("null")){if(!1===t.nullable)throw new Error("type: null contradicts nullable: false")}else{if(!e.length&&void 0!==t.nullable)throw new Error('"nullable" cannot be used without "type"');!0===t.nullable&&e.push("null")}return e},e.getJSONTypes=i,e.coerceAndCheckDataType=function(t,e){const{gen:i,data:o,opts:s}=t,u=function(t,e){return e?t.filter((t=>n.has(t)||"array"===e&&"array"===t)):[]}(e,s.coerceTypes),l=e.length>0&&!(0===u.length&&1===e.length&&(0,Ol.schemaHasRulesForType)(t,e[0]));if(l){const l=a(e,o,s.strictNumbers,r.Wrong);i.if(l,(()=>{u.length?function(t,e,r){const{gen:i,data:o,opts:s}=t,u=i.let("dataType",xl._`typeof ${o}`),l=i.let("coerced",xl._`undefined`);"array"===s.coerceTypes&&i.if(xl._`${u} == 'object' && Array.isArray(${o}) && ${o}.length == 1`,(()=>i.assign(o,xl._`${o}[0]`).assign(u,xl._`typeof ${o}`).if(a(e,o,s.strictNumbers),(()=>i.assign(l,o)))));i.if(xl._`${l} !== undefined`);for(const t of r)(n.has(t)||"array"===t&&"array"===s.coerceTypes)&&c(t);function c(t){switch(t){case"string":return void i.elseIf(xl._`${u} == "number" || ${u} == "boolean"`).assign(l,xl._`"" + ${o}`).elseIf(xl._`${o} === null`).assign(l,xl._`""`);case"number":return void i.elseIf(xl._`${u} == "boolean" || ${o} === null
25
25
  || (${u} == "string" && ${o} && ${o} == +${o})`).assign(l,xl._`+${o}`);case"integer":return void i.elseIf(xl._`${u} === "boolean" || ${o} === null
26
26
  || (${u} === "string" && ${o} && ${o} == +${o} && !(${o} % 1))`).assign(l,xl._`+${o}`);case"boolean":return void i.elseIf(xl._`${o} === "false" || ${o} === 0 || ${o} === null`).assign(l,!1).elseIf(xl._`${o} === "true" || ${o} === 1`).assign(l,!0);case"null":return i.elseIf(xl._`${o} === "" || ${o} === 0 || ${o} === false`),void i.assign(l,null);case"array":i.elseIf(xl._`${u} === "string" || ${u} === "number"
27
27
  || ${u} === "boolean" || ${o} === null`).assign(l,xl._`[${o}]`)}}i.else(),h(t),i.endIf(),i.if(xl._`${l} !== undefined`,(()=>{i.assign(o,l),function({gen:t,parentData:e,parentDataProperty:r},i){t.if(xl._`${e} !== undefined`,(()=>t.assign(xl._`${e}[${r}]`,i)))}(t,l)}))}(t,e,u):h(t)}))}return l};const n=new Set(["string","number","integer","boolean","null"]);function o(t,e,i,n=r.Correct){const o=n===r.Correct?xl.operators.EQ:xl.operators.NEQ;let a;switch(t){case"null":return xl._`${e} ${o} null`;case"array":a=xl._`Array.isArray(${e})`;break;case"object":a=xl._`${e} && typeof ${e} == "object" && !Array.isArray(${e})`;break;case"integer":a=s(xl._`!(${e} % 1) && !isNaN(${e})`);break;case"number":a=s();break;default:return xl._`typeof ${e} ${o} ${t}`}return n===r.Correct?a:(0,xl.not)(a);function s(t=xl.nil){return(0,xl.and)(xl._`typeof ${e} == "number"`,t,i?xl._`isFinite(${e})`:xl.nil)}}function a(t,e,r,i){if(1===t.length)return o(t[0],e,r,i);let n;const a=(0,Sl.toHash)(t);if(a.array&&a.object){const t=xl._`typeof ${e} != "object"`;n=a.null?t:xl._`!${e} || ${t}`,delete a.null,delete a.array,delete a.object}else n=xl.nil;a.number&&delete a.integer;for(const t in a)n=(0,xl.and)(n,o(t,e,r,i));return n}e.checkDataType=o,e.checkDataTypes=a;const s={message:({schema:t})=>`must be ${t}`,params:({schema:t,schemaValue:e})=>"string"==typeof t?xl._`{type: ${t}}`:xl._`{type: ${e}}`};function h(t){const e=function(t){const{gen:e,data:r,schema:i}=t,n=(0,Sl.schemaRefOrVal)(t,i,"type");return{gen:e,keyword:"type",data:r,schema:i.type,schemaCode:n,schemaValue:n,parentSchema:i,params:{},it:t}}(t);(0,Tl.reportError)(e,s)}e.reportTypeError=h})),Pl=a((function(t,e){function r(t,e,r){const{gen:i,compositeRule:n,data:o,opts:a}=t;if(void 0===r)return;const s=xl._`${o}${(0,xl.getProperty)(e)}`;if(n)return void(0,Sl.checkStrictMode)(t,`default is ignored for: ${s}`);let h=xl._`${s} === undefined`;"empty"===a.useDefaults&&(h=xl._`${h} || ${s} === null || ${s} === ""`),i.if(h,xl._`${s} = ${(0,xl.stringify)(r)}`)}Object.defineProperty(e,"__esModule",{value:!0}),e.assignDefaults=void 0,e.assignDefaults=function(t,e){const{properties:i,items:n}=t.schema;if("object"===e&&i)for(const e in i)r(t,e,i[e].default);else"array"===e&&Array.isArray(n)&&n.forEach(((e,i)=>r(t,i,e.default)))}})),Bl=a((function(t,e){Object.defineProperty(e,"__esModule",{value:!0}),e.validateUnion=e.validateArray=e.usePattern=e.callValidateCode=e.schemaProperties=e.allSchemaProperties=e.noPropertyInData=e.propertyInData=e.isOwnProperty=e.hasPropFunc=e.reportMissingProp=e.checkMissingProp=e.checkReportMissingProp=void 0;const r=Sl;function i(t){return t.scopeValue("func",{ref:Object.prototype.hasOwnProperty,code:xl._`Object.prototype.hasOwnProperty`})}function n(t,e,r){return xl._`${i(t)}.call(${e}, ${r})`}function o(t,e,r,i){const o=xl._`${e}${(0,xl.getProperty)(r)} === undefined`;return i?(0,xl.or)(o,(0,xl.not)(n(t,e,r))):o}function a(t){return t?Object.keys(t).filter((t=>"__proto__"!==t)):[]}e.checkReportMissingProp=function(t,e){const{gen:r,data:i,it:n}=t;r.if(o(r,i,e,n.opts.ownProperties),(()=>{t.setParams({missingProperty:xl._`${e}`},!0),t.error()}))},e.checkMissingProp=function({gen:t,data:e,it:{opts:r}},i,n){return(0,xl.or)(...i.map((i=>(0,xl.and)(o(t,e,i,r.ownProperties),xl._`${n} = ${i}`))))},e.reportMissingProp=function(t,e){t.setParams({missingProperty:e},!0),t.error()},e.hasPropFunc=i,e.isOwnProperty=n,e.propertyInData=function(t,e,r,i){const o=xl._`${e}${(0,xl.getProperty)(r)} !== undefined`;return i?xl._`${o} && ${n(t,e,r)}`:o},e.noPropertyInData=o,e.allSchemaProperties=a,e.schemaProperties=function(t,e){return a(e).filter((r=>!(0,Sl.alwaysValidSchema)(t,e[r])))},e.callValidateCode=function({schemaCode:t,data:e,it:{gen:r,topSchemaRef:i,schemaPath:n,errorPath:o},it:a},s,h,u){const l=u?xl._`${t}, ${e}, ${i}${n}`:e,c=[[Il.default.instancePath,(0,xl.strConcat)(Il.default.instancePath,o)],[Il.default.parentData,a.parentData],[Il.default.parentDataProperty,a.parentDataProperty],[Il.default.rootData,Il.default.rootData]];a.opts.dynamicRef&&c.push([Il.default.dynamicAnchors,Il.default.dynamicAnchors]);const d=xl._`${l}, ${r.object(...c)}`;return h!==xl.nil?xl._`${s}.call(${h}, ${d})`:xl._`${s}(${d})`};const s=xl._`new RegExp`;e.usePattern=function({gen:t,it:{opts:e}},i){const n=e.unicodeRegExp?"u":"",{regExp:o}=e.code,a=o(i,n);return t.scopeValue("pattern",{key:a.toString(),ref:a,code:xl._`${"new RegExp"===o.code?s:(0,r.useFunc)(t,o)}(${i}, ${n})`})},e.validateArray=function(t){const{gen:e,data:r,keyword:i,it:n}=t,o=e.name("valid");if(n.allErrors){const t=e.let("valid",!0);return a((()=>e.assign(t,!1))),t}return e.var(o,!0),a((()=>e.break())),o;function a(n){const a=e.const("len",xl._`${r}.length`);e.forRange("i",0,a,(r=>{t.subschema({keyword:i,dataProp:r,dataPropType:Sl.Type.Num},o),e.if((0,xl.not)(o),n)}))}},e.validateUnion=function(t){const{gen:e,schema:r,keyword:i,it:n}=t;if(!Array.isArray(r))throw new Error("ajv implementation error");if(r.some((t=>(0,Sl.alwaysValidSchema)(n,t)))&&!n.opts.unevaluated)return;const o=e.let("valid",!1),a=e.name("_valid");e.block((()=>r.forEach(((r,n)=>{const s=t.subschema({keyword:i,schemaProp:n,compositeRule:!0},a);e.assign(o,xl._`${o} || ${a}`);t.mergeValidEvaluated(s,a)||e.if((0,xl.not)(o))})))),t.result(o,(()=>t.reset()),(()=>t.error(!0)))}})),Dl=a((function(t,e){function r(t){const{gen:e,data:r,it:i}=t;e.if(i.parentData,(()=>e.assign(r,xl._`${i.parentData}[${i.parentDataProperty}]`)))}function i(t,e,r){if(void 0===r)throw new Error(`keyword "${e}" failed to compile`);return t.scopeValue("keyword","function"==typeof r?{ref:r}:{ref:r,code:(0,xl.stringify)(r)})}Object.defineProperty(e,"__esModule",{value:!0}),e.validateKeywordUsage=e.validSchemaType=e.funcKeywordCode=e.macroKeywordCode=void 0,e.macroKeywordCode=function(t,e){const{gen:r,keyword:n,schema:o,parentSchema:a,it:s}=t,h=e.macro.call(s.self,o,a,s),u=i(r,n,h);!1!==s.opts.validateSchema&&s.self.validateSchema(h,!0);const l=r.name("valid");t.subschema({schema:h,schemaPath:xl.nil,errSchemaPath:`${s.errSchemaPath}/${n}`,topSchemaRef:u,compositeRule:!0},l),t.pass(l,(()=>t.error(!0)))},e.funcKeywordCode=function(t,e){var n;const{gen:o,keyword:a,schema:s,parentSchema:h,$data:u,it:l}=t;!function({schemaEnv:t},e){if(e.async&&!t.$async)throw new Error("async keyword in sync schema")}(l,e);const c=!u&&e.compile?e.compile.call(l.self,s,h,l):e.validate,d=i(o,a,c),f=o.let("valid");function m(r=(e.async?xl._`await `:xl.nil)){const i=l.opts.passContext?Il.default.this:Il.default.self,n=!("compile"in e&&!u||!1===e.schema);o.assign(f,xl._`${r}${(0,Bl.callValidateCode)(t,d,i,n)}`,e.modifying)}function p(t){var r;o.if((0,xl.not)(null!==(r=e.valid)&&void 0!==r?r:f),t)}t.block$data(f,(function(){if(!1===e.errors)m(),e.modifying&&r(t),p((()=>t.error()));else{const i=e.async?function(){const t=o.let("ruleErrs",null);return o.try((()=>m(xl._`await `)),(e=>o.assign(f,!1).if(xl._`${e} instanceof ${l.ValidationError}`,(()=>o.assign(t,xl._`${e}.errors`)),(()=>o.throw(e))))),t}():function(){const t=xl._`${d}.errors`;return o.assign(t,null),m(xl.nil),t}();e.modifying&&r(t),p((()=>function(t,e){const{gen:r}=t;r.if(xl._`Array.isArray(${e})`,(()=>{r.assign(Il.default.vErrors,xl._`${Il.default.vErrors} === null ? ${e} : ${Il.default.vErrors}.concat(${e})`).assign(Il.default.errors,xl._`${Il.default.vErrors}.length`),(0,Tl.extendErrors)(t)}),(()=>t.error()))}(t,i)))}})),t.ok(null!==(n=e.valid)&&void 0!==n?n:f)},e.validSchemaType=function(t,e,r=!1){return!e.length||e.some((e=>"array"===e?Array.isArray(t):"object"===e?t&&"object"==typeof t&&!Array.isArray(t):typeof t==e||r&&void 0===t))},e.validateKeywordUsage=function({schema:t,opts:e,self:r,errSchemaPath:i},n,o){if(Array.isArray(n.keyword)?!n.keyword.includes(o):n.keyword!==o)throw new Error("ajv implementation error");const a=n.dependencies;if(null==a?void 0:a.some((e=>!Object.prototype.hasOwnProperty.call(t,e))))throw new Error(`parent schema must have dependencies of ${o}: ${a.join(",")}`);if(n.validateSchema){if(!n.validateSchema(t[o])){const t=`keyword "${o}" value is invalid at path "${i}": `+r.errorsText(n.validateSchema.errors);if("log"!==e.validateSchema)throw new Error(t);r.logger.error(t)}}}})),$l=a((function(t,e){Object.defineProperty(e,"__esModule",{value:!0}),e.extendSubschemaMode=e.extendSubschemaData=e.getSubschema=void 0,e.getSubschema=function(t,{keyword:e,schemaProp:r,schema:i,schemaPath:n,errSchemaPath:o,topSchemaRef:a}){if(void 0!==e&&void 0!==i)throw new Error('both "keyword" and "schema" passed, only one allowed');if(void 0!==e){const i=t.schema[e];return void 0===r?{schema:i,schemaPath:xl._`${t.schemaPath}${(0,xl.getProperty)(e)}`,errSchemaPath:`${t.errSchemaPath}/${e}`}:{schema:i[r],schemaPath:xl._`${t.schemaPath}${(0,xl.getProperty)(e)}${(0,xl.getProperty)(r)}`,errSchemaPath:`${t.errSchemaPath}/${e}/${(0,Sl.escapeFragment)(r)}`}}if(void 0!==i){if(void 0===n||void 0===o||void 0===a)throw new Error('"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"');return{schema:i,schemaPath:n,topSchemaRef:a,errSchemaPath:o}}throw new Error('either "keyword" or "schema" must be passed')},e.extendSubschemaData=function(t,e,{dataProp:r,dataPropType:i,data:n,dataTypes:o,propertyName:a}){if(void 0!==n&&void 0!==r)throw new Error('both "data" and "dataProp" passed, only one allowed');const{gen:s}=e;if(void 0!==r){const{errorPath:n,dataPathArr:o,opts:a}=e;h(s.let("data",xl._`${e.data}${(0,xl.getProperty)(r)}`,!0)),t.errorPath=xl.str`${n}${(0,Sl.getErrorPath)(r,i,a.jsPropertySyntax)}`,t.parentDataProperty=xl._`${r}`,t.dataPathArr=[...o,t.parentDataProperty]}if(void 0!==n){h(n instanceof xl.Name?n:s.let("data",n,!0)),void 0!==a&&(t.propertyName=a)}function h(r){t.data=r,t.dataLevel=e.dataLevel+1,t.dataTypes=[],e.definedProperties=new Set,t.parentData=e.data,t.dataNames=[...e.dataNames,r]}o&&(t.dataTypes=o)},e.extendSubschemaMode=function(t,{jtdDiscriminator:e,jtdMetadata:r,compositeRule:i,createErrors:n,allErrors:o}){void 0!==i&&(t.compositeRule=i),void 0!==n&&(t.createErrors=n),void 0!==o&&(t.allErrors=o),t.jtdDiscriminator=e,t.jtdMetadata=r}})),Ll=function t(e,r){if(e===r)return!0;if(e&&r&&"object"==typeof e&&"object"==typeof r){if(e.constructor!==r.constructor)return!1;var i,n,o;if(Array.isArray(e)){if((i=e.length)!=r.length)return!1;for(n=i;0!=n--;)if(!t(e[n],r[n]))return!1;return!0}if(e.constructor===RegExp)return e.source===r.source&&e.flags===r.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===r.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===r.toString();if((i=(o=Object.keys(e)).length)!==Object.keys(r).length)return!1;for(n=i;0!=n--;)if(!Object.prototype.hasOwnProperty.call(r,o[n]))return!1;for(n=i;0!=n--;){var a=o[n];if(!t(e[a],r[a]))return!1}return!0}return e!=e&&r!=r},Fl=a((function(t){var e=t.exports=function(t,e,i){"function"==typeof e&&(i=e,e={}),r(e,"function"==typeof(i=e.cb||i)?i:i.pre||function(){},i.post||function(){},t,"",t)};function r(t,i,n,o,a,s,h,u,l,c){if(o&&"object"==typeof o&&!Array.isArray(o)){for(var d in i(o,a,s,h,u,l,c),o){var f=o[d];if(Array.isArray(f)){if(d in e.arrayKeywords)for(var m=0;m<f.length;m++)r(t,i,n,f[m],a+"/"+d+"/"+m,s,a,d,o,m)}else if(d in e.propsKeywords){if(f&&"object"==typeof f)for(var p in f)r(t,i,n,f[p],a+"/"+d+"/"+p.replace(/~/g,"~0").replace(/\//g,"~1"),s,a,d,o,p)}else(d in e.keywords||t.allKeys&&!(d in e.skipKeywords))&&r(t,i,n,f,a+"/"+d,s,a,d,o)}n(o,a,s,h,u,l,c)}}e.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0,if:!0,then:!0,else:!0},e.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0},e.propsKeywords={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependencies:!0},e.skipKeywords={default:!0,enum:!0,const:!0,required:!0,maximum:!0,minimum:!0,exclusiveMaximum:!0,exclusiveMinimum:!0,multipleOf:!0,maxLength:!0,minLength:!0,pattern:!0,format:!0,maxItems:!0,minItems:!0,uniqueItems:!0,maxProperties:!0,minProperties:!0}})),Ul=a((function(t,e){Object.defineProperty(e,"__esModule",{value:!0}),e.getSchemaRefs=e.resolveUrl=e.normalizeId=e._getFullPath=e.getFullPath=e.inlineRef=void 0;const r=new Set(["type","format","pattern","maxLength","minLength","maxProperties","minProperties","maxItems","minItems","maximum","minimum","uniqueItems","multipleOf","required","enum","const"]);e.inlineRef=function(t,e=!0){return"boolean"==typeof t||(!0===e?!n(t):!!e&&o(t)<=e)};const i=new Set(["$ref","$recursiveRef","$recursiveAnchor","$dynamicRef","$dynamicAnchor"]);function n(t){for(const e in t){if(i.has(e))return!0;const r=t[e];if(Array.isArray(r)&&r.some(n))return!0;if("object"==typeof r&&n(r))return!0}return!1}function o(t){let e=0;for(const i in t){if("$ref"===i)return 1/0;if(e++,!r.has(i)&&("object"==typeof t[i]&&(0,Sl.eachItem)(t[i],(t=>e+=o(t))),e===1/0))return 1/0}return e}function a(t,e="",r){!1!==r&&(e=u(e));const i=t.parse(e);return s(t,i)}function s(t,e){return t.serialize(e).split("#")[0]+"#"}e.getFullPath=a,e._getFullPath=s;const h=/#\/?$/;function u(t){return t?t.replace(h,""):""}e.normalizeId=u,e.resolveUrl=function(t,e,r){return r=u(r),t.resolve(e,r)};const l=/^[a-z_][-a-z0-9._]*$/i;e.getSchemaRefs=function(t,e){if("boolean"==typeof t)return{};const{schemaId:r,uriResolver:i}=this.opts,n=u(t[r]||e),o={"":n},s=a(i,n,!1),h={},c=new Set;return Fl(t,{allKeys:!0},((t,e,i,n)=>{if(void 0===n)return;const a=s+e;let m=o[n];function p(e){const r=this.opts.uriResolver.resolve;if(e=u(m?r(m,e):e),c.has(e))throw f(e);c.add(e);let i=this.refs[e];return"string"==typeof i&&(i=this.refs[i]),"object"==typeof i?d(t,i.schema,e):e!==u(a)&&("#"===e[0]?(d(t,h[e],e),h[e]=t):this.refs[e]=a),e}function g(t){if("string"==typeof t){if(!l.test(t))throw new Error(`invalid anchor "${t}"`);p.call(this,`#${t}`)}}"string"==typeof t[r]&&(m=p.call(this,t[r])),g.call(this,t.$anchor),g.call(this,t.$dynamicAnchor),o[e]=m})),h;function d(t,e,r){if(void 0!==e&&!Ll(t,e))throw f(r)}function f(t){return new Error(`reference "${t}" resolves to more than one schema`)}}})),ql=a((function(t,e){Object.defineProperty(e,"__esModule",{value:!0}),e.getData=e.KeywordCxt=e.validateFunctionCode=void 0;const r=Rl;function i({gen:t,validateName:e,schema:r,schemaEnv:i,opts:o},a){o.code.es5?t.func(e,xl._`${Il.default.data}, ${Il.default.valCxt}`,i.$async,(()=>{t.code(xl._`"use strict"; ${n(r,o)}`),function(t,e){t.if(Il.default.valCxt,(()=>{t.var(Il.default.instancePath,xl._`${Il.default.valCxt}.${Il.default.instancePath}`),t.var(Il.default.parentData,xl._`${Il.default.valCxt}.${Il.default.parentData}`),t.var(Il.default.parentDataProperty,xl._`${Il.default.valCxt}.${Il.default.parentDataProperty}`),t.var(Il.default.rootData,xl._`${Il.default.valCxt}.${Il.default.rootData}`),e.dynamicRef&&t.var(Il.default.dynamicAnchors,xl._`${Il.default.valCxt}.${Il.default.dynamicAnchors}`)}),(()=>{t.var(Il.default.instancePath,xl._`""`),t.var(Il.default.parentData,xl._`undefined`),t.var(Il.default.parentDataProperty,xl._`undefined`),t.var(Il.default.rootData,Il.default.data),e.dynamicRef&&t.var(Il.default.dynamicAnchors,xl._`{}`)}))}(t,o),t.code(a)})):t.func(e,xl._`${Il.default.data}, ${function(t){return xl._`{${Il.default.instancePath}="", ${Il.default.parentData}, ${Il.default.parentDataProperty}, ${Il.default.rootData}=${Il.default.data}${t.dynamicRef?xl._`, ${Il.default.dynamicAnchors}={}`:xl.nil}}={}`}(o)}`,i.$async,(()=>t.code(n(r,o)).code(a)))}function n(t,e){const r="object"==typeof t&&t[e.schemaId];return r&&(e.code.source||e.code.process)?xl._`/*# sourceURL=${r} */`:xl.nil}function o(t,e){s(t)&&(h(t),a(t))?function(t,e){const{schema:r,gen:i,opts:n}=t;n.$comment&&r.$comment&&l(t);(function(t){const e=t.schema[t.opts.schemaId];e&&(t.baseId=(0,Ul.resolveUrl)(t.opts.uriResolver,t.baseId,e))})(t),function(t){if(t.schema.$async&&!t.schemaEnv.$async)throw new Error("async schema in sync schema")}(t);const o=i.const("_errs",Il.default.errors);u(t,o),i.var(e,xl._`${o} === ${Il.default.errors}`)}(t,e):(0,Cl.boolOrEmptySchema)(t,e)}function a({schema:t,self:e}){if("boolean"==typeof t)return!t;for(const r in t)if(e.RULES.all[r])return!0;return!1}function s(t){return"boolean"!=typeof t.schema}function h(t){(0,Sl.checkUnknownRules)(t),function(t){const{schema:e,errSchemaPath:r,opts:i,self:n}=t;e.$ref&&i.ignoreKeywordsWithRef&&(0,Sl.schemaHasRulesButRef)(e,n.RULES)&&n.logger.warn(`$ref: keywords ignored in schema at path "${r}"`)}(t)}function u(t,e){if(t.opts.jtd)return c(t,[],!1,e);const r=(0,Rl.getSchemaTypes)(t.schema);c(t,r,!(0,Rl.coerceAndCheckDataType)(t,r),e)}function l({gen:t,schemaEnv:e,schema:r,errSchemaPath:i,opts:n}){const o=r.$comment;if(!0===n.$comment)t.code(xl._`${Il.default.self}.logger.log(${o})`);else if("function"==typeof n.$comment){const r=xl.str`${i}/$comment`,n=t.scopeValue("root",{ref:e.root});t.code(xl._`${Il.default.self}.opts.$comment(${o}, ${r}, ${n}.schema)`)}}function c(t,e,i,n){const{gen:o,schema:a,data:s,allErrors:h,opts:u,self:l}=t,{RULES:c}=l;function g(l){(0,Ol.shouldUseGroup)(a,l)&&(l.type?(o.if((0,r.checkDataType)(l.type,s,u.strictNumbers)),d(t,l),1===e.length&&e[0]===l.type&&i&&(o.else(),(0,r.reportTypeError)(t)),o.endIf()):d(t,l),h||o.if(xl._`${Il.default.errors} === ${n||0}`))}!a.$ref||!u.ignoreKeywordsWithRef&&(0,Sl.schemaHasRulesButRef)(a,c)?(u.jtd||function(t,e){if(t.schemaEnv.meta||!t.opts.strictTypes)return;(function(t,e){if(!e.length)return;if(!t.dataTypes.length)return void(t.dataTypes=e);e.forEach((e=>{m(t.dataTypes,e)||p(t,`type "${e}" not allowed by context "${t.dataTypes.join(",")}"`)})),t.dataTypes=t.dataTypes.filter((t=>m(e,t)))})(t,e),t.opts.allowUnionTypes||function(t,e){e.length>1&&(2!==e.length||!e.includes("null"))&&p(t,"use allowUnionTypes to allow union type keyword")}(t,e);!function(t,e){const r=t.self.RULES.all;for(const i in r){const n=r[i];if("object"==typeof n&&(0,Ol.shouldUseRule)(t.schema,n)){const{type:r}=n.definition;r.length&&!r.some((t=>f(e,t)))&&p(t,`missing type "${r.join(",")}" for keyword "${i}"`)}}}(t,t.dataTypes)}(t,e),o.block((()=>{for(const t of c.rules)g(t);g(c.post)}))):o.block((()=>y(t,"$ref",c.all.$ref.definition)))}function d(t,e){const{gen:r,schema:i,opts:{useDefaults:n}}=t;n&&(0,Pl.assignDefaults)(t,e.type),r.block((()=>{for(const r of e.rules)(0,Ol.shouldUseRule)(i,r)&&y(t,r.keyword,r.definition,e.type)}))}function f(t,e){return t.includes(e)||"number"===e&&t.includes("integer")}function m(t,e){return t.includes(e)||"integer"===e&&t.includes("number")}function p(t,e){e+=` at "${t.schemaEnv.baseId+t.errSchemaPath}" (strictTypes)`,(0,Sl.checkStrictMode)(t,e,t.opts.strictTypes)}e.validateFunctionCode=function(t){s(t)&&(h(t),a(t))?function(t){const{schema:e,opts:r,gen:n}=t;i(t,(()=>{r.$comment&&e.$comment&&l(t),function(t){const{schema:e,opts:r}=t;void 0!==e.default&&r.useDefaults&&r.strictSchema&&(0,Sl.checkStrictMode)(t,"default is ignored in the schema root")}(t),n.let(Il.default.vErrors,null),n.let(Il.default.errors,0),r.unevaluated&&function(t){const{gen:e,validateName:r}=t;t.evaluated=e.const("evaluated",xl._`${r}.evaluated`),e.if(xl._`${t.evaluated}.dynamicProps`,(()=>e.assign(xl._`${t.evaluated}.props`,xl._`undefined`))),e.if(xl._`${t.evaluated}.dynamicItems`,(()=>e.assign(xl._`${t.evaluated}.items`,xl._`undefined`)))}(t),u(t),function(t){const{gen:e,schemaEnv:r,validateName:i,ValidationError:n,opts:o}=t;r.$async?e.if(xl._`${Il.default.errors} === 0`,(()=>e.return(Il.default.data)),(()=>e.throw(xl._`new ${n}(${Il.default.vErrors})`))):(e.assign(xl._`${i}.errors`,Il.default.vErrors),o.unevaluated&&function({gen:t,evaluated:e,props:r,items:i}){r instanceof xl.Name&&t.assign(xl._`${e}.props`,r);i instanceof xl.Name&&t.assign(xl._`${e}.items`,i)}(t),e.return(xl._`${Il.default.errors} === 0`))}(t)}))}(t):i(t,(()=>(0,Cl.topBoolOrEmptySchema)(t)))};class g{constructor(t,e,r){if((0,Dl.validateKeywordUsage)(t,e,r),this.gen=t.gen,this.allErrors=t.allErrors,this.keyword=r,this.data=t.data,this.schema=t.schema[r],this.$data=e.$data&&t.opts.$data&&this.schema&&this.schema.$data,this.schemaValue=(0,Sl.schemaRefOrVal)(t,this.schema,r,this.$data),this.schemaType=e.schemaType,this.parentSchema=t.schema,this.params={},this.it=t,this.def=e,this.$data)this.schemaCode=t.gen.const("vSchema",b(this.$data,t));else if(this.schemaCode=this.schemaValue,!(0,Dl.validSchemaType)(this.schema,e.schemaType,e.allowUndefined))throw new Error(`${r} value must be ${JSON.stringify(e.schemaType)}`);("code"in e?e.trackErrors:!1!==e.errors)&&(this.errsCount=t.gen.const("_errs",Il.default.errors))}result(t,e,r){this.failResult((0,xl.not)(t),e,r)}failResult(t,e,r){this.gen.if(t),r?r():this.error(),e?(this.gen.else(),e(),this.allErrors&&this.gen.endIf()):this.allErrors?this.gen.endIf():this.gen.else()}pass(t,e){this.failResult((0,xl.not)(t),void 0,e)}fail(t){if(void 0===t)return this.error(),void(this.allErrors||this.gen.if(!1));this.gen.if(t),this.error(),this.allErrors?this.gen.endIf():this.gen.else()}fail$data(t){if(!this.$data)return this.fail(t);const{schemaCode:e}=this;this.fail(xl._`${e} !== undefined && (${(0,xl.or)(this.invalid$data(),t)})`)}error(t,e,r){if(e)return this.setParams(e),this._error(t,r),void this.setParams({});this._error(t,r)}_error(t,e){(t?Tl.reportExtraError:Tl.reportError)(this,this.def.error,e)}$dataError(){(0,Tl.reportError)(this,this.def.$dataError||Tl.keyword$DataError)}reset(){if(void 0===this.errsCount)throw new Error('add "trackErrors" to keyword definition');(0,Tl.resetErrorsCount)(this.gen,this.errsCount)}ok(t){this.allErrors||this.gen.if(t)}setParams(t,e){e?Object.assign(this.params,t):this.params=t}block$data(t,e,r=xl.nil){this.gen.block((()=>{this.check$data(t,r),e()}))}check$data(t=xl.nil,e=xl.nil){if(!this.$data)return;const{gen:r,schemaCode:i,schemaType:n,def:o}=this;r.if((0,xl.or)(xl._`${i} === undefined`,e)),t!==xl.nil&&r.assign(t,!0),(n.length||o.validateSchema)&&(r.elseIf(this.invalid$data()),this.$dataError(),t!==xl.nil&&r.assign(t,!1)),r.else()}invalid$data(){const{gen:t,schemaCode:e,schemaType:i,def:n,it:o}=this;return(0,xl.or)(function(){if(i.length){if(!(e instanceof xl.Name))throw new Error("ajv implementation error");const t=Array.isArray(i)?i:[i];return xl._`${(0,r.checkDataTypes)(t,e,o.opts.strictNumbers,r.DataType.Wrong)}`}return xl.nil}(),function(){if(n.validateSchema){const r=t.scopeValue("validate$data",{ref:n.validateSchema});return xl._`!${r}(${e})`}return xl.nil}())}subschema(t,e){const r=(0,$l.getSubschema)(this.it,t);(0,$l.extendSubschemaData)(r,this.it,t),(0,$l.extendSubschemaMode)(r,t);const i={...this.it,...r,items:void 0,props:void 0};return o(i,e),i}mergeEvaluated(t,e){const{it:r,gen:i}=this;r.opts.unevaluated&&(!0!==r.props&&void 0!==t.props&&(r.props=Sl.mergeEvaluated.props(i,t.props,r.props,e)),!0!==r.items&&void 0!==t.items&&(r.items=Sl.mergeEvaluated.items(i,t.items,r.items,e)))}mergeValidEvaluated(t,e){const{it:r,gen:i}=this;if(r.opts.unevaluated&&(!0!==r.props||!0!==r.items))return i.if(e,(()=>this.mergeEvaluated(t,xl.Name))),!0}}function y(t,e,r,i){const n=new g(t,r,e);"code"in r?r.code(n,i):n.$data&&r.validate?(0,Dl.funcKeywordCode)(n,r):"macro"in r?(0,Dl.macroKeywordCode)(n,r):(r.compile||r.validate)&&(0,Dl.funcKeywordCode)(n,r)}e.KeywordCxt=g;const w=/^\/(?:[^~]|~0|~1)*$/,v=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function b(t,{dataLevel:e,dataNames:r,dataPathArr:i}){let n,o;if(""===t)return Il.default.rootData;if("/"===t[0]){if(!w.test(t))throw new Error(`Invalid JSON-pointer: ${t}`);n=t,o=Il.default.rootData}else{const a=v.exec(t);if(!a)throw new Error(`Invalid JSON-pointer: ${t}`);const s=+a[1];if(n=a[2],"#"===n){if(s>=e)throw new Error(h("property/index",s));return i[e-s]}if(s>e)throw new Error(h("data",s));if(o=r[e-s],!n)return o}let a=o;const s=n.split("/");for(const t of s)t&&(o=xl._`${o}${(0,xl.getProperty)((0,Sl.unescapeJsonPointer)(t))}`,a=xl._`${a} && ${o}`);return a;function h(t,r){return`Cannot access ${t} ${r} levels up, current level is ${e}`}}e.getData=b}));class Vl extends Error{constructor(t){super("validation failed"),this.errors=t,this.ajv=this.validation=!0}}var Hl=Vl,Gl=Object.defineProperty({default:Hl},"__esModule",{value:!0});class Zl extends Error{constructor(t,e,r,i){super(i||`can't resolve reference ${r} from id ${e}`),this.missingRef=(0,Ul.resolveUrl)(t,e,r),this.missingSchema=(0,Ul.normalizeId)((0,Ul.getFullPath)(t,this.missingRef))}}var Kl=Zl,Jl=Object.defineProperty({default:Kl},"__esModule",{value:!0}),Wl=a((function(t,e){Object.defineProperty(e,"__esModule",{value:!0}),e.resolveSchema=e.getCompilingSchema=e.resolveRef=e.compileSchema=e.SchemaEnv=void 0;class r{constructor(t){var e;let r;this.refs={},this.dynamicAnchors={},"object"==typeof t.schema&&(r=t.schema),this.schema=t.schema,this.schemaId=t.schemaId,this.root=t.root||this,this.baseId=null!==(e=t.baseId)&&void 0!==e?e:(0,Ul.normalizeId)(null==r?void 0:r[t.schemaId||"$id"]),this.schemaPath=t.schemaPath,this.localRefs=t.localRefs,this.meta=t.meta,this.$async=null==r?void 0:r.$async,this.refs={}}}function i(t){const e=o.call(this,t);if(e)return e;const r=(0,Ul.getFullPath)(this.opts.uriResolver,t.root.baseId),{es5:i,lines:n}=this.opts.code,{ownProperties:a}=this.opts,s=new xl.CodeGen(this.scope,{es5:i,lines:n,ownProperties:a});let h;t.$async&&(h=s.scopeValue("Error",{ref:Gl.default,code:xl._`require("ajv/dist/runtime/validation_error").default`}));const u=s.scopeName("validate");t.validateName=u;const l={gen:s,allErrors:this.opts.allErrors,data:Il.default.data,parentData:Il.default.parentData,parentDataProperty:Il.default.parentDataProperty,dataNames:[Il.default.data],dataPathArr:[xl.nil],dataLevel:0,dataTypes:[],definedProperties:new Set,topSchemaRef:s.scopeValue("schema",!0===this.opts.code.source?{ref:t.schema,code:(0,xl.stringify)(t.schema)}:{ref:t.schema}),validateName:u,ValidationError:h,schema:t.schema,schemaEnv:t,rootId:r,baseId:t.baseId||r,schemaPath:xl.nil,errSchemaPath:t.schemaPath||(this.opts.jtd?"":"#"),errorPath:xl._`""`,opts:this.opts,self:this};let c;try{this._compilations.add(t),(0,ql.validateFunctionCode)(l),s.optimize(this.opts.code.optimize);const e=s.toString();c=`${s.scopeRefs(Il.default.scope)}return ${e}`,this.opts.code.process&&(c=this.opts.code.process(c,t));const r=new Function(`${Il.default.self}`,`${Il.default.scope}`,c)(this,this.scope.get());if(this.scope.value(u,{ref:r}),r.errors=null,r.schema=t.schema,r.schemaEnv=t,t.$async&&(r.$async=!0),!0===this.opts.code.source&&(r.source={validateName:u,validateCode:e,scopeValues:s._values}),this.opts.unevaluated){const{props:t,items:e}=l;r.evaluated={props:t instanceof xl.Name?void 0:t,items:e instanceof xl.Name?void 0:e,dynamicProps:t instanceof xl.Name,dynamicItems:e instanceof xl.Name},r.source&&(r.source.evaluated=(0,xl.stringify)(r.evaluated))}return t.validate=r,t}catch(e){throw delete t.validate,delete t.validateName,c&&this.logger.error("Error compiling schema, function code:",c),e}finally{this._compilations.delete(t)}}function n(t){return(0,Ul.inlineRef)(t.schema,this.opts.inlineRefs)?t.schema:t.validate?t:i.call(this,t)}function o(t){for(const i of this._compilations)if(r=t,(e=i).schema===r.schema&&e.root===r.root&&e.baseId===r.baseId)return i;var e,r}function a(t,e){let r;for(;"string"==typeof(r=this.refs[e]);)e=r;return r||this.schemas[e]||s.call(this,t,e)}function s(t,e){const n=this.opts.uriResolver.parse(e),o=(0,Ul._getFullPath)(this.opts.uriResolver,n);let a=(0,Ul.getFullPath)(this.opts.uriResolver,t.baseId,void 0);if(Object.keys(t.schema).length>0&&o===a)return u.call(this,n,t);const h=(0,Ul.normalizeId)(o),l=this.refs[h]||this.schemas[h];if("string"==typeof l){const e=s.call(this,t,l);if("object"!=typeof(null==e?void 0:e.schema))return;return u.call(this,n,e)}if("object"==typeof(null==l?void 0:l.schema)){if(l.validate||i.call(this,l),h===(0,Ul.normalizeId)(e)){const{schema:e}=l,{schemaId:i}=this.opts,n=e[i];return n&&(a=(0,Ul.resolveUrl)(this.opts.uriResolver,a,n)),new r({schema:e,schemaId:i,root:t,baseId:a})}return u.call(this,n,l)}}e.SchemaEnv=r,e.compileSchema=i,e.resolveRef=function(t,e,i){var o;i=(0,Ul.resolveUrl)(this.opts.uriResolver,e,i);const s=t.refs[i];if(s)return s;let h=a.call(this,t,i);if(void 0===h){const n=null===(o=t.localRefs)||void 0===o?void 0:o[i],{schemaId:a}=this.opts;n&&(h=new r({schema:n,schemaId:a,root:t,baseId:e}))}return void 0!==h?t.refs[i]=n.call(this,h):void 0},e.getCompilingSchema=o,e.resolveSchema=s;const h=new Set(["properties","patternProperties","enum","dependencies","definitions"]);function u(t,{baseId:e,schema:i,root:n}){var o;if("/"!==(null===(o=t.fragment)||void 0===o?void 0:o[0]))return;for(const r of t.fragment.slice(1).split("/")){if("boolean"==typeof i)return;const t=i[(0,Sl.unescapeFragment)(r)];if(void 0===t)return;const n="object"==typeof(i=t)&&i[this.opts.schemaId];!h.has(r)&&n&&(e=(0,Ul.resolveUrl)(this.opts.uriResolver,e,n))}let a;if("boolean"!=typeof i&&i.$ref&&!(0,Sl.schemaHasRulesButRef)(i,this.RULES)){const t=(0,Ul.resolveUrl)(this.opts.uriResolver,e,i.$ref);a=s.call(this,n,t)}const{schemaId:u}=this.opts;return a=a||new r({schema:i,schemaId:u,root:n,baseId:e}),a.schema!==a.root.schema?a:void 0}})),Yl={$id:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#",description:"Meta-schema for $data reference (JSON AnySchema extension proposal)",type:"object",required:["$data"],properties:{$data:{type:"string",anyOf:[{format:"relative-json-pointer"},{format:"json-pointer"}]}},additionalProperties:!1},Ql=a((function(t,e){!function(t){function e(){for(var t=arguments.length,e=Array(t),r=0;r<t;r++)e[r]=arguments[r];if(e.length>1){e[0]=e[0].slice(0,-1);for(var i=e.length-1,n=1;n<i;++n)e[n]=e[n].slice(1,-1);return e[i]=e[i].slice(1),e.join("")}return e[0]}function r(t){return"(?:"+t+")"}function i(t){return void 0===t?"undefined":null===t?"null":Object.prototype.toString.call(t).split(" ").pop().split("]").shift().toLowerCase()}function n(t){return t.toUpperCase()}function o(t){return null!=t?t instanceof Array?t:"number"!=typeof t.length||t.split||t.setInterval||t.call?[t]:Array.prototype.slice.call(t):[]}function a(t,e){var r=t;if(e)for(var i in e)r[i]=e[i];return r}function s(t){var i="[A-Za-z]",n="[0-9]",o=e(n,"[A-Fa-f]"),a=r(r("%[EFef]"+o+"%"+o+o+"%"+o+o)+"|"+r("%[89A-Fa-f]"+o+"%"+o+o)+"|"+r("%"+o+o)),s="[\\!\\$\\&\\'\\(\\)\\*\\+\\,\\;\\=]",h=e("[\\:\\/\\?\\#\\[\\]\\@]",s),u=t?"[\\uE000-\\uF8FF]":"[]",l=e(i,n,"[\\-\\.\\_\\~]",t?"[\\xA0-\\u200D\\u2010-\\u2029\\u202F-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF]":"[]"),c=(r(i+e(i,n,"[\\+\\-\\.]")+"*"),r(r(a+"|"+e(l,s,"[\\:]"))+"*"),r(r("25[0-5]")+"|"+r("2[0-4]"+n)+"|"+r("1"+n+n)+"|"+r("0?[1-9]"+n)+"|0?0?"+n)),d=r(c+"\\."+c+"\\."+c+"\\."+c),f=r(o+"{1,4}"),m=r(r(f+"\\:"+f)+"|"+d),p=r(r(f+"\\:")+"{6}"+m),g=r("\\:\\:"+r(f+"\\:")+"{5}"+m),y=r(r(f)+"?\\:\\:"+r(f+"\\:")+"{4}"+m),w=r(r(r(f+"\\:")+"{0,1}"+f)+"?\\:\\:"+r(f+"\\:")+"{3}"+m),v=r(r(r(f+"\\:")+"{0,2}"+f)+"?\\:\\:"+r(f+"\\:")+"{2}"+m),b=r(r(r(f+"\\:")+"{0,3}"+f)+"?\\:\\:"+f+"\\:"+m),k=r(r(r(f+"\\:")+"{0,4}"+f)+"?\\:\\:"+m),M=r(r(r(f+"\\:")+"{0,5}"+f)+"?\\:\\:"+f),_=r(r(r(f+"\\:")+"{0,6}"+f)+"?\\:\\:"),E=r([p,g,y,w,v,b,k,M,_].join("|")),A=r(r(l+"|"+a)+"+"),j=(r("[vV]"+o+"+\\."+e(l,s,"[\\:]")+"+"),r(r(a+"|"+e(l,s))+"*"),r(a+"|"+e(l,s,"[\\:\\@]")));return r(r(a+"|"+e(l,s,"[\\@]"))+"+"),r(r(j+"|"+e("[\\/\\?]",u))+"*"),{NOT_SCHEME:new RegExp(e("[^]",i,n,"[\\+\\-\\.]"),"g"),NOT_USERINFO:new RegExp(e("[^\\%\\:]",l,s),"g"),NOT_HOST:new RegExp(e("[^\\%\\[\\]\\:]",l,s),"g"),NOT_PATH:new RegExp(e("[^\\%\\/\\:\\@]",l,s),"g"),NOT_PATH_NOSCHEME:new RegExp(e("[^\\%\\/\\@]",l,s),"g"),NOT_QUERY:new RegExp(e("[^\\%]",l,s,"[\\:\\@\\/\\?]",u),"g"),NOT_FRAGMENT:new RegExp(e("[^\\%]",l,s,"[\\:\\@\\/\\?]"),"g"),ESCAPE:new RegExp(e("[^]",l,s),"g"),UNRESERVED:new RegExp(l,"g"),OTHER_CHARS:new RegExp(e("[^\\%]",l,h),"g"),PCT_ENCODED:new RegExp(a,"g"),IPV4ADDRESS:new RegExp("^("+d+")$"),IPV6ADDRESS:new RegExp("^\\[?("+E+")"+r(r("\\%25|\\%(?!"+o+"{2})")+"("+A+")")+"?\\]?$")}}var h=s(!1),u=s(!0),l=function(){function t(t,e){var r=[],i=!0,n=!1,o=void 0;try{for(var a,s=t[Symbol.iterator]();!(i=(a=s.next()).done)&&(r.push(a.value),!e||r.length!==e);i=!0);}catch(t){n=!0,o=t}finally{try{!i&&s.return&&s.return()}finally{if(n)throw o}}return r}return function(e,r){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e))return t(e,r);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),c=function(t){if(Array.isArray(t)){for(var e=0,r=Array(t.length);e<t.length;e++)r[e]=t[e];return r}return Array.from(t)},d=2147483647,f=36,m=1,p=26,g=38,y=700,w=72,v=128,b="-",k=/^xn--/,M=/[^\0-\x7E]/,_=/[\x2E\u3002\uFF0E\uFF61]/g,E={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},A=f-m,j=Math.floor,x=String.fromCharCode;function S(t){throw new RangeError(E[t])}function N(t,e){for(var r=[],i=t.length;i--;)r[i]=e(t[i]);return r}function I(t,e){var r=t.split("@"),i="";return r.length>1&&(i=r[0]+"@",t=r[1]),i+N((t=t.replace(_,".")).split("."),e).join(".")}function T(t){for(var e=[],r=0,i=t.length;r<i;){var n=t.charCodeAt(r++);if(n>=55296&&n<=56319&&r<i){var o=t.charCodeAt(r++);56320==(64512&o)?e.push(((1023&n)<<10)+(1023&o)+65536):(e.push(n),r--)}else e.push(n)}return e}var C=function(t){return t-48<10?t-22:t-65<26?t-65:t-97<26?t-97:f},z=function(t,e){return t+22+75*(t<26)-((0!=e)<<5)},O=function(t,e,r){var i=0;for(t=r?j(t/y):t>>1,t+=j(t/e);t>A*p>>1;i+=f)t=j(t/A);return j(i+(A+1)*t/(t+g))},R=function(t){var e=[],r=t.length,i=0,n=v,o=w,a=t.lastIndexOf(b);a<0&&(a=0);for(var s=0;s<a;++s)t.charCodeAt(s)>=128&&S("not-basic"),e.push(t.charCodeAt(s));for(var h=a>0?a+1:0;h<r;){for(var u=i,l=1,c=f;;c+=f){h>=r&&S("invalid-input");var g=C(t.charCodeAt(h++));(g>=f||g>j((d-i)/l))&&S("overflow"),i+=g*l;var y=c<=o?m:c>=o+p?p:c-o;if(g<y)break;var k=f-y;l>j(d/k)&&S("overflow"),l*=k}var M=e.length+1;o=O(i-u,M,0==u),j(i/M)>d-n&&S("overflow"),n+=j(i/M),i%=M,e.splice(i++,0,n)}return String.fromCodePoint.apply(String,e)},P=function(t){var e=[],r=(t=T(t)).length,i=v,n=0,o=w,a=!0,s=!1,h=void 0;try{for(var u,l=t[Symbol.iterator]();!(a=(u=l.next()).done);a=!0){var c=u.value;c<128&&e.push(x(c))}}catch(t){s=!0,h=t}finally{try{!a&&l.return&&l.return()}finally{if(s)throw h}}var g=e.length,y=g;for(g&&e.push(b);y<r;){var k=d,M=!0,_=!1,E=void 0;try{for(var A,N=t[Symbol.iterator]();!(M=(A=N.next()).done);M=!0){var I=A.value;I>=i&&I<k&&(k=I)}}catch(t){_=!0,E=t}finally{try{!M&&N.return&&N.return()}finally{if(_)throw E}}var C=y+1;k-i>j((d-n)/C)&&S("overflow"),n+=(k-i)*C,i=k;var R=!0,P=!1,B=void 0;try{for(var D,$=t[Symbol.iterator]();!(R=(D=$.next()).done);R=!0){var L=D.value;if(L<i&&++n>d&&S("overflow"),L==i){for(var F=n,U=f;;U+=f){var q=U<=o?m:U>=o+p?p:U-o;if(F<q)break;var V=F-q,H=f-q;e.push(x(z(q+V%H,0))),F=j(V/H)}e.push(x(z(F,0))),o=O(n,C,y==g),n=0,++y}}}catch(t){P=!0,B=t}finally{try{!R&&$.return&&$.return()}finally{if(P)throw B}}++n,++i}return e.join("")},B=function(t){return I(t,(function(t){return k.test(t)?R(t.slice(4).toLowerCase()):t}))},D=function(t){return I(t,(function(t){return M.test(t)?"xn--"+P(t):t}))},$={version:"2.1.0",ucs2:{decode:T,encode:function(t){return String.fromCodePoint.apply(String,c(t))}},decode:R,encode:P,toASCII:D,toUnicode:B},L={};function F(t){var e=t.charCodeAt(0);return e<16?"%0"+e.toString(16).toUpperCase():e<128?"%"+e.toString(16).toUpperCase():e<2048?"%"+(e>>6|192).toString(16).toUpperCase()+"%"+(63&e|128).toString(16).toUpperCase():"%"+(e>>12|224).toString(16).toUpperCase()+"%"+(e>>6&63|128).toString(16).toUpperCase()+"%"+(63&e|128).toString(16).toUpperCase()}function U(t){for(var e="",r=0,i=t.length;r<i;){var n=parseInt(t.substr(r+1,2),16);if(n<128)e+=String.fromCharCode(n),r+=3;else if(n>=194&&n<224){if(i-r>=6){var o=parseInt(t.substr(r+4,2),16);e+=String.fromCharCode((31&n)<<6|63&o)}else e+=t.substr(r,6);r+=6}else if(n>=224){if(i-r>=9){var a=parseInt(t.substr(r+4,2),16),s=parseInt(t.substr(r+7,2),16);e+=String.fromCharCode((15&n)<<12|(63&a)<<6|63&s)}else e+=t.substr(r,9);r+=9}else e+=t.substr(r,3),r+=3}return e}function q(t,e){function r(t){var r=U(t);return r.match(e.UNRESERVED)?r:t}return t.scheme&&(t.scheme=String(t.scheme).replace(e.PCT_ENCODED,r).toLowerCase().replace(e.NOT_SCHEME,"")),void 0!==t.userinfo&&(t.userinfo=String(t.userinfo).replace(e.PCT_ENCODED,r).replace(e.NOT_USERINFO,F).replace(e.PCT_ENCODED,n)),void 0!==t.host&&(t.host=String(t.host).replace(e.PCT_ENCODED,r).toLowerCase().replace(e.NOT_HOST,F).replace(e.PCT_ENCODED,n)),void 0!==t.path&&(t.path=String(t.path).replace(e.PCT_ENCODED,r).replace(t.scheme?e.NOT_PATH:e.NOT_PATH_NOSCHEME,F).replace(e.PCT_ENCODED,n)),void 0!==t.query&&(t.query=String(t.query).replace(e.PCT_ENCODED,r).replace(e.NOT_QUERY,F).replace(e.PCT_ENCODED,n)),void 0!==t.fragment&&(t.fragment=String(t.fragment).replace(e.PCT_ENCODED,r).replace(e.NOT_FRAGMENT,F).replace(e.PCT_ENCODED,n)),t}function V(t){return t.replace(/^0*(.*)/,"$1")||"0"}function H(t,e){var r=t.match(e.IPV4ADDRESS)||[],i=l(r,2)[1];return i?i.split(".").map(V).join("."):t}function G(t,e){var r=t.match(e.IPV6ADDRESS)||[],i=l(r,3),n=i[1],o=i[2];if(n){for(var a=n.toLowerCase().split("::").reverse(),s=l(a,2),h=s[0],u=s[1],c=u?u.split(":").map(V):[],d=h.split(":").map(V),f=e.IPV4ADDRESS.test(d[d.length-1]),m=f?7:8,p=d.length-m,g=Array(m),y=0;y<m;++y)g[y]=c[y]||d[p+y]||"";f&&(g[m-1]=H(g[m-1],e));var w=g.reduce((function(t,e,r){if(!e||"0"===e){var i=t[t.length-1];i&&i.index+i.length===r?i.length++:t.push({index:r,length:1})}return t}),[]),v=w.sort((function(t,e){return e.length-t.length}))[0],b=void 0;if(v&&v.length>1){var k=g.slice(0,v.index),M=g.slice(v.index+v.length);b=k.join(":")+"::"+M.join(":")}else b=g.join(":");return o&&(b+="%"+o),b}return t}var Z=/^(?:([^:\/?#]+):)?(?:\/\/((?:([^\/?#@]*)@)?(\[[^\/?#\]]+\]|[^\/?#:]*)(?:\:(\d*))?))?([^?#]*)(?:\?([^#]*))?(?:#((?:.|\n|\r)*))?/i,K=void 0==="".match(/(){0}/)[1];function J(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r={},i=!1!==e.iri?u:h;"suffix"===e.reference&&(t=(e.scheme?e.scheme+":":"")+"//"+t);var n=t.match(Z);if(n){K?(r.scheme=n[1],r.userinfo=n[3],r.host=n[4],r.port=parseInt(n[5],10),r.path=n[6]||"",r.query=n[7],r.fragment=n[8],isNaN(r.port)&&(r.port=n[5])):(r.scheme=n[1]||void 0,r.userinfo=-1!==t.indexOf("@")?n[3]:void 0,r.host=-1!==t.indexOf("//")?n[4]:void 0,r.port=parseInt(n[5],10),r.path=n[6]||"",r.query=-1!==t.indexOf("?")?n[7]:void 0,r.fragment=-1!==t.indexOf("#")?n[8]:void 0,isNaN(r.port)&&(r.port=t.match(/\/\/(?:.|\n)*\:(?:\/|\?|\#|$)/)?n[4]:void 0)),r.host&&(r.host=G(H(r.host,i),i)),void 0!==r.scheme||void 0!==r.userinfo||void 0!==r.host||void 0!==r.port||r.path||void 0!==r.query?void 0===r.scheme?r.reference="relative":void 0===r.fragment?r.reference="absolute":r.reference="uri":r.reference="same-document",e.reference&&"suffix"!==e.reference&&e.reference!==r.reference&&(r.error=r.error||"URI is not a "+e.reference+" reference.");var o=L[(e.scheme||r.scheme||"").toLowerCase()];if(e.unicodeSupport||o&&o.unicodeSupport)q(r,i);else{if(r.host&&(e.domainHost||o&&o.domainHost))try{r.host=$.toASCII(r.host.replace(i.PCT_ENCODED,U).toLowerCase())}catch(t){r.error=r.error||"Host's domain name can not be converted to ASCII via punycode: "+t}q(r,h)}o&&o.parse&&o.parse(r,e)}else r.error=r.error||"URI can not be parsed.";return r}function W(t,e){var r=!1!==e.iri?u:h,i=[];return void 0!==t.userinfo&&(i.push(t.userinfo),i.push("@")),void 0!==t.host&&i.push(G(H(String(t.host),r),r).replace(r.IPV6ADDRESS,(function(t,e,r){return"["+e+(r?"%25"+r:"")+"]"}))),"number"!=typeof t.port&&"string"!=typeof t.port||(i.push(":"),i.push(String(t.port))),i.length?i.join(""):void 0}var Y=/^\.\.?\//,Q=/^\/\.(\/|$)/,X=/^\/\.\.(\/|$)/,tt=/^\/?(?:.|\n)*?(?=\/|$)/;function et(t){for(var e=[];t.length;)if(t.match(Y))t=t.replace(Y,"");else if(t.match(Q))t=t.replace(Q,"/");else if(t.match(X))t=t.replace(X,"/"),e.pop();else if("."===t||".."===t)t="";else{var r=t.match(tt);if(!r)throw new Error("Unexpected dot segment condition");var i=r[0];t=t.slice(i.length),e.push(i)}return e.join("")}function rt(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=e.iri?u:h,i=[],n=L[(e.scheme||t.scheme||"").toLowerCase()];if(n&&n.serialize&&n.serialize(t,e),t.host)if(r.IPV6ADDRESS.test(t.host));else if(e.domainHost||n&&n.domainHost)try{t.host=e.iri?$.toUnicode(t.host):$.toASCII(t.host.replace(r.PCT_ENCODED,U).toLowerCase())}catch(r){t.error=t.error||"Host's domain name can not be converted to "+(e.iri?"Unicode":"ASCII")+" via punycode: "+r}q(t,r),"suffix"!==e.reference&&t.scheme&&(i.push(t.scheme),i.push(":"));var o=W(t,e);if(void 0!==o&&("suffix"!==e.reference&&i.push("//"),i.push(o),t.path&&"/"!==t.path.charAt(0)&&i.push("/")),void 0!==t.path){var a=t.path;e.absolutePath||n&&n.absolutePath||(a=et(a)),void 0===o&&(a=a.replace(/^\/\//,"/%2F")),i.push(a)}return void 0!==t.query&&(i.push("?"),i.push(t.query)),void 0!==t.fragment&&(i.push("#"),i.push(t.fragment)),i.join("")}function it(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i={};return arguments[3]||(t=J(rt(t,r),r),e=J(rt(e,r),r)),!(r=r||{}).tolerant&&e.scheme?(i.scheme=e.scheme,i.userinfo=e.userinfo,i.host=e.host,i.port=e.port,i.path=et(e.path||""),i.query=e.query):(void 0!==e.userinfo||void 0!==e.host||void 0!==e.port?(i.userinfo=e.userinfo,i.host=e.host,i.port=e.port,i.path=et(e.path||""),i.query=e.query):(e.path?("/"===e.path.charAt(0)?i.path=et(e.path):(void 0===t.userinfo&&void 0===t.host&&void 0===t.port||t.path?t.path?i.path=t.path.slice(0,t.path.lastIndexOf("/")+1)+e.path:i.path=e.path:i.path="/"+e.path,i.path=et(i.path)),i.query=e.query):(i.path=t.path,void 0!==e.query?i.query=e.query:i.query=t.query),i.userinfo=t.userinfo,i.host=t.host,i.port=t.port),i.scheme=t.scheme),i.fragment=e.fragment,i}function nt(t,e,r){var i=a({scheme:"null"},r);return rt(it(J(t,i),J(e,i),i,!0),i)}function ot(t,e){return"string"==typeof t?t=rt(J(t,e),e):"object"===i(t)&&(t=J(rt(t,e),e)),t}function at(t,e,r){return"string"==typeof t?t=rt(J(t,r),r):"object"===i(t)&&(t=rt(t,r)),"string"==typeof e?e=rt(J(e,r),r):"object"===i(e)&&(e=rt(e,r)),t===e}function st(t,e){return t&&t.toString().replace(e&&e.iri?u.ESCAPE:h.ESCAPE,F)}function ht(t,e){return t&&t.toString().replace(e&&e.iri?u.PCT_ENCODED:h.PCT_ENCODED,U)}var ut={scheme:"http",domainHost:!0,parse:function(t,e){return t.host||(t.error=t.error||"HTTP URIs must have a host."),t},serialize:function(t,e){var r="https"===String(t.scheme).toLowerCase();return t.port!==(r?443:80)&&""!==t.port||(t.port=void 0),t.path||(t.path="/"),t}},lt={scheme:"https",domainHost:ut.domainHost,parse:ut.parse,serialize:ut.serialize};function ct(t){return"boolean"==typeof t.secure?t.secure:"wss"===String(t.scheme).toLowerCase()}var dt={scheme:"ws",domainHost:!0,parse:function(t,e){var r=t;return r.secure=ct(r),r.resourceName=(r.path||"/")+(r.query?"?"+r.query:""),r.path=void 0,r.query=void 0,r},serialize:function(t,e){if(t.port!==(ct(t)?443:80)&&""!==t.port||(t.port=void 0),"boolean"==typeof t.secure&&(t.scheme=t.secure?"wss":"ws",t.secure=void 0),t.resourceName){var r=t.resourceName.split("?"),i=l(r,2),n=i[0],o=i[1];t.path=n&&"/"!==n?n:void 0,t.query=o,t.resourceName=void 0}return t.fragment=void 0,t}},ft={scheme:"wss",domainHost:dt.domainHost,parse:dt.parse,serialize:dt.serialize},mt={},pt="[A-Za-z0-9\\-\\.\\_\\~\\xA0-\\u200D\\u2010-\\u2029\\u202F-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF]",gt="[0-9A-Fa-f]",yt=r(r("%[EFef]"+gt+"%"+gt+gt+"%"+gt+gt)+"|"+r("%[89A-Fa-f]"+gt+"%"+gt+gt)+"|"+r("%"+gt+gt)),wt="[A-Za-z0-9\\!\\$\\%\\'\\*\\+\\-\\^\\_\\`\\{\\|\\}\\~]",vt=e("[\\!\\$\\%\\'\\(\\)\\*\\+\\,\\-\\.0-9\\<\\>A-Z\\x5E-\\x7E]",'[\\"\\\\]'),bt="[\\!\\$\\'\\(\\)\\*\\+\\,\\;\\:\\@]",kt=new RegExp(pt,"g"),Mt=new RegExp(yt,"g"),_t=new RegExp(e("[^]",wt,"[\\.]",'[\\"]',vt),"g"),Et=new RegExp(e("[^]",pt,bt),"g"),At=Et;function jt(t){var e=U(t);return e.match(kt)?e:t}var xt={scheme:"mailto",parse:function(t,e){var r=t,i=r.to=r.path?r.path.split(","):[];if(r.path=void 0,r.query){for(var n=!1,o={},a=r.query.split("&"),s=0,h=a.length;s<h;++s){var u=a[s].split("=");switch(u[0]){case"to":for(var l=u[1].split(","),c=0,d=l.length;c<d;++c)i.push(l[c]);break;case"subject":r.subject=ht(u[1],e);break;case"body":r.body=ht(u[1],e);break;default:n=!0,o[ht(u[0],e)]=ht(u[1],e)}}n&&(r.headers=o)}r.query=void 0;for(var f=0,m=i.length;f<m;++f){var p=i[f].split("@");if(p[0]=ht(p[0]),e.unicodeSupport)p[1]=ht(p[1],e).toLowerCase();else try{p[1]=$.toASCII(ht(p[1],e).toLowerCase())}catch(t){r.error=r.error||"Email address's domain name can not be converted to ASCII via punycode: "+t}i[f]=p.join("@")}return r},serialize:function(t,e){var r=t,i=o(t.to);if(i){for(var a=0,s=i.length;a<s;++a){var h=String(i[a]),u=h.lastIndexOf("@"),l=h.slice(0,u).replace(Mt,jt).replace(Mt,n).replace(_t,F),c=h.slice(u+1);try{c=e.iri?$.toUnicode(c):$.toASCII(ht(c,e).toLowerCase())}catch(t){r.error=r.error||"Email address's domain name can not be converted to "+(e.iri?"Unicode":"ASCII")+" via punycode: "+t}i[a]=l+"@"+c}r.path=i.join(",")}var d=t.headers=t.headers||{};t.subject&&(d.subject=t.subject),t.body&&(d.body=t.body);var f=[];for(var m in d)d[m]!==mt[m]&&f.push(m.replace(Mt,jt).replace(Mt,n).replace(Et,F)+"="+d[m].replace(Mt,jt).replace(Mt,n).replace(At,F));return f.length&&(r.query=f.join("&")),r}},St=/^([^\:]+)\:(.*)/,Nt={scheme:"urn",parse:function(t,e){var r=t.path&&t.path.match(St),i=t;if(r){var n=e.scheme||i.scheme||"urn",o=r[1].toLowerCase(),a=r[2],s=n+":"+(e.nid||o),h=L[s];i.nid=o,i.nss=a,i.path=void 0,h&&(i=h.parse(i,e))}else i.error=i.error||"URN can not be parsed.";return i},serialize:function(t,e){var r=e.scheme||t.scheme||"urn",i=t.nid,n=r+":"+(e.nid||i),o=L[n];o&&(t=o.serialize(t,e));var a=t,s=t.nss;return a.path=(i||e.nid)+":"+s,a}},It=/^[0-9A-Fa-f]{8}(?:\-[0-9A-Fa-f]{4}){3}\-[0-9A-Fa-f]{12}$/,Tt={scheme:"urn:uuid",parse:function(t,e){var r=t;return r.uuid=r.nss,r.nss=void 0,e.tolerant||r.uuid&&r.uuid.match(It)||(r.error=r.error||"UUID is not valid."),r},serialize:function(t,e){var r=t;return r.nss=(t.uuid||"").toLowerCase(),r}};L[ut.scheme]=ut,L[lt.scheme]=lt,L[dt.scheme]=dt,L[ft.scheme]=ft,L[xt.scheme]=xt,L[Nt.scheme]=Nt,L[Tt.scheme]=Tt,t.SCHEMES=L,t.pctEncChar=F,t.pctDecChars=U,t.parse=J,t.removeDotSegments=et,t.serialize=rt,t.resolveComponents=it,t.resolve=nt,t.normalize=ot,t.equal=at,t.escapeComponent=st,t.unescapeComponent=ht,Object.defineProperty(t,"__esModule",{value:!0})}(e)}));Ql.code='require("ajv/dist/runtime/uri").default';var Xl=Ql,tc=Object.defineProperty({default:Xl},"__esModule",{value:!0}),ec=a((function(t,e){Object.defineProperty(e,"__esModule",{value:!0}),e.CodeGen=e.Name=e.nil=e.stringify=e.str=e._=e.KeywordCxt=void 0,Object.defineProperty(e,"KeywordCxt",{enumerable:!0,get:function(){return ql.KeywordCxt}}),Object.defineProperty(e,"_",{enumerable:!0,get:function(){return xl._}}),Object.defineProperty(e,"str",{enumerable:!0,get:function(){return xl.str}}),Object.defineProperty(e,"stringify",{enumerable:!0,get:function(){return xl.stringify}}),Object.defineProperty(e,"nil",{enumerable:!0,get:function(){return xl.nil}}),Object.defineProperty(e,"Name",{enumerable:!0,get:function(){return xl.Name}}),Object.defineProperty(e,"CodeGen",{enumerable:!0,get:function(){return xl.CodeGen}});const r=xl,i=(t,e)=>new RegExp(t,e);i.code="new RegExp";const n=["removeAdditional","useDefaults","coerceTypes"],o=new Set(["validate","serialize","parse","wrapper","root","schema","keyword","pattern","formats","validate$data","func","obj","Error"]),a={errorDataPath:"",format:"`validateFormats: false` can be used instead.",nullable:'"nullable" keyword is supported by default.',jsonPointers:"Deprecated jsPropertySyntax can be used instead.",extendRefs:"Deprecated ignoreKeywordsWithRef can be used instead.",missingRefs:"Pass empty schema with $id that should be ignored to ajv.addSchema.",processCode:"Use option `code: {process: (code, schemaEnv: object) => string}`",sourceCode:"Use option `code: {source: true}`",strictDefaults:"It is default now, see option `strict`.",strictKeywords:"It is default now, see option `strict`.",uniqueItems:'"uniqueItems" keyword is always validated.',unknownFormats:"Disable strict mode or pass `true` to `ajv.addFormat` (or `formats` option).",cache:"Map is used as cache, schema object as key.",serialize:"Map is used as cache, schema object as key.",ajvErrors:"It is default now."},s={ignoreKeywordsWithRef:"",jsPropertySyntax:"",unicode:'"minLength"/"maxLength" account for unicode characters by default.'};function h(t){var e,r,n,o,a,s,h,u,l,c,d,f,m,p,g,y,w,v,b,k,M,_,E,A,j;const x=t.strict,S=null===(e=t.code)||void 0===e?void 0:e.optimize,N=!0===S||void 0===S?1:S||0,I=null!==(n=null===(r=t.code)||void 0===r?void 0:r.regExp)&&void 0!==n?n:i,T=null!==(o=t.uriResolver)&&void 0!==o?o:tc.default;return{strictSchema:null===(s=null!==(a=t.strictSchema)&&void 0!==a?a:x)||void 0===s||s,strictNumbers:null===(u=null!==(h=t.strictNumbers)&&void 0!==h?h:x)||void 0===u||u,strictTypes:null!==(c=null!==(l=t.strictTypes)&&void 0!==l?l:x)&&void 0!==c?c:"log",strictTuples:null!==(f=null!==(d=t.strictTuples)&&void 0!==d?d:x)&&void 0!==f?f:"log",strictRequired:null!==(p=null!==(m=t.strictRequired)&&void 0!==m?m:x)&&void 0!==p&&p,code:t.code?{...t.code,optimize:N,regExp:I}:{optimize:N,regExp:I},loopRequired:null!==(g=t.loopRequired)&&void 0!==g?g:200,loopEnum:null!==(y=t.loopEnum)&&void 0!==y?y:200,meta:null===(w=t.meta)||void 0===w||w,messages:null===(v=t.messages)||void 0===v||v,inlineRefs:null===(b=t.inlineRefs)||void 0===b||b,schemaId:null!==(k=t.schemaId)&&void 0!==k?k:"$id",addUsedSchema:null===(M=t.addUsedSchema)||void 0===M||M,validateSchema:null===(_=t.validateSchema)||void 0===_||_,validateFormats:null===(E=t.validateFormats)||void 0===E||E,unicodeRegExp:null===(A=t.unicodeRegExp)||void 0===A||A,int32range:null===(j=t.int32range)||void 0===j||j,uriResolver:T}}class u{constructor(t={}){this.schemas={},this.refs={},this.formats={},this._compilations=new Set,this._loading={},this._cache=new Map,t=this.opts={...t,...h(t)};const{es5:e,lines:i}=this.opts.code;this.scope=new r.ValueScope({scope:{},prefixes:o,es5:e,lines:i}),this.logger=function(t){if(!1===t)return g;if(void 0===t)return console;if(t.log&&t.warn&&t.error)return t;throw new Error("logger must implement log, warn and error methods")}(t.logger);const n=t.validateFormats;t.validateFormats=!1,this.RULES=(0,zl.getRules)(),l.call(this,a,t,"NOT SUPPORTED"),l.call(this,s,t,"DEPRECATED","warn"),this._metaOpts=p.call(this),t.formats&&f.call(this),this._addVocabularies(),this._addDefaultMetaSchema(),t.keywords&&m.call(this,t.keywords),"object"==typeof t.meta&&this.addMetaSchema(t.meta),d.call(this),t.validateFormats=n}_addVocabularies(){this.addKeyword("$async")}_addDefaultMetaSchema(){const{$data:t,meta:e,schemaId:r}=this.opts;let i=Yl;"id"===r&&(i={...Yl},i.id=i.$id,delete i.$id),e&&t&&this.addMetaSchema(i,i[r],!1)}defaultMeta(){const{meta:t,schemaId:e}=this.opts;return this.opts.defaultMeta="object"==typeof t?t[e]||t:void 0}validate(t,e){let r;if("string"==typeof t){if(r=this.getSchema(t),!r)throw new Error(`no schema with key or ref "${t}"`)}else r=this.compile(t);const i=r(e);return"$async"in r||(this.errors=r.errors),i}compile(t,e){const r=this._addSchema(t,e);return r.validate||this._compileSchemaEnv(r)}compileAsync(t,e){if("function"!=typeof this.opts.loadSchema)throw new Error("options.loadSchema should be a function");const{loadSchema:r}=this.opts;return i.call(this,t,e);async function i(t,e){await n.call(this,t.$schema);const r=this._addSchema(t,e);return r.validate||o.call(this,r)}async function n(t){t&&!this.getSchema(t)&&await i.call(this,{$ref:t},!0)}async function o(t){try{return this._compileSchemaEnv(t)}catch(e){if(!(e instanceof Jl.default))throw e;return a.call(this,e),await s.call(this,e.missingSchema),o.call(this,t)}}function a({missingSchema:t,missingRef:e}){if(this.refs[t])throw new Error(`AnySchema ${t} is loaded but ${e} cannot be resolved`)}async function s(t){const r=await h.call(this,t);this.refs[t]||await n.call(this,r.$schema),this.refs[t]||this.addSchema(r,t,e)}async function h(t){const e=this._loading[t];if(e)return e;try{return await(this._loading[t]=r(t))}finally{delete this._loading[t]}}}addSchema(t,e,r,i=this.opts.validateSchema){if(Array.isArray(t)){for(const e of t)this.addSchema(e,void 0,r,i);return this}let n;if("object"==typeof t){const{schemaId:e}=this.opts;if(n=t[e],void 0!==n&&"string"!=typeof n)throw new Error(`schema ${e} must be string`)}return e=(0,Ul.normalizeId)(e||n),this._checkUnique(e),this.schemas[e]=this._addSchema(t,r,e,i,!0),this}addMetaSchema(t,e,r=this.opts.validateSchema){return this.addSchema(t,e,!0,r),this}validateSchema(t,e){if("boolean"==typeof t)return!0;let r;if(r=t.$schema,void 0!==r&&"string"!=typeof r)throw new Error("$schema must be a string");if(r=r||this.opts.defaultMeta||this.defaultMeta(),!r)return this.logger.warn("meta-schema not available"),this.errors=null,!0;const i=this.validate(r,t);if(!i&&e){const t="schema is invalid: "+this.errorsText();if("log"!==this.opts.validateSchema)throw new Error(t);this.logger.error(t)}return i}getSchema(t){let e;for(;"string"==typeof(e=c.call(this,t));)t=e;if(void 0===e){const{schemaId:r}=this.opts,i=new Wl.SchemaEnv({schema:{},schemaId:r});if(e=Wl.resolveSchema.call(this,i,t),!e)return;this.refs[t]=e}return e.validate||this._compileSchemaEnv(e)}removeSchema(t){if(t instanceof RegExp)return this._removeAllSchemas(this.schemas,t),this._removeAllSchemas(this.refs,t),this;switch(typeof t){case"undefined":return this._removeAllSchemas(this.schemas),this._removeAllSchemas(this.refs),this._cache.clear(),this;case"string":{const e=c.call(this,t);return"object"==typeof e&&this._cache.delete(e.schema),delete this.schemas[t],delete this.refs[t],this}case"object":{const e=t;this._cache.delete(e);let r=t[this.opts.schemaId];return r&&(r=(0,Ul.normalizeId)(r),delete this.schemas[r],delete this.refs[r]),this}default:throw new Error("ajv.removeSchema: invalid parameter")}}addVocabulary(t){for(const e of t)this.addKeyword(e);return this}addKeyword(t,e){let r;if("string"==typeof t)r=t,"object"==typeof e&&(this.logger.warn("these parameters are deprecated, see docs for addKeyword"),e.keyword=r);else{if("object"!=typeof t||void 0!==e)throw new Error("invalid addKeywords parameters");if(r=(e=t).keyword,Array.isArray(r)&&!r.length)throw new Error("addKeywords: keyword must be string or non-empty array")}if(w.call(this,r,e),!e)return(0,Sl.eachItem)(r,(t=>v.call(this,t))),this;k.call(this,e);const i={...e,type:(0,Rl.getJSONTypes)(e.type),schemaType:(0,Rl.getJSONTypes)(e.schemaType)};return(0,Sl.eachItem)(r,0===i.type.length?t=>v.call(this,t,i):t=>i.type.forEach((e=>v.call(this,t,i,e)))),this}getKeyword(t){const e=this.RULES.all[t];return"object"==typeof e?e.definition:!!e}removeKeyword(t){const{RULES:e}=this;delete e.keywords[t],delete e.all[t];for(const r of e.rules){const e=r.rules.findIndex((e=>e.keyword===t));e>=0&&r.rules.splice(e,1)}return this}addFormat(t,e){return"string"==typeof e&&(e=new RegExp(e)),this.formats[t]=e,this}errorsText(t=this.errors,{separator:e=", ",dataVar:r="data"}={}){return t&&0!==t.length?t.map((t=>`${r}${t.instancePath} ${t.message}`)).reduce(((t,r)=>t+e+r)):"No errors"}$dataMetaSchema(t,e){const r=this.RULES.all;t=JSON.parse(JSON.stringify(t));for(const i of e){const e=i.split("/").slice(1);let n=t;for(const t of e)n=n[t];for(const t in r){const e=r[t];if("object"!=typeof e)continue;const{$data:i}=e.definition,o=n[t];i&&o&&(n[t]=_(o))}}return t}_removeAllSchemas(t,e){for(const r in t){const i=t[r];e&&!e.test(r)||("string"==typeof i?delete t[r]:i&&!i.meta&&(this._cache.delete(i.schema),delete t[r]))}}_addSchema(t,e,r,i=this.opts.validateSchema,n=this.opts.addUsedSchema){let o;const{schemaId:a}=this.opts;if("object"==typeof t)o=t[a];else{if(this.opts.jtd)throw new Error("schema must be object");if("boolean"!=typeof t)throw new Error("schema must be object or boolean")}let s=this._cache.get(t);if(void 0!==s)return s;r=(0,Ul.normalizeId)(o||r);const h=Ul.getSchemaRefs.call(this,t,r);return s=new Wl.SchemaEnv({schema:t,schemaId:a,meta:e,baseId:r,localRefs:h}),this._cache.set(s.schema,s),n&&!r.startsWith("#")&&(r&&this._checkUnique(r),this.refs[r]=s),i&&this.validateSchema(t,!0),s}_checkUnique(t){if(this.schemas[t]||this.refs[t])throw new Error(`schema with key or id "${t}" already exists`)}_compileSchemaEnv(t){if(t.meta?this._compileMetaSchema(t):Wl.compileSchema.call(this,t),!t.validate)throw new Error("ajv implementation error");return t.validate}_compileMetaSchema(t){const e=this.opts;this.opts=this._metaOpts;try{Wl.compileSchema.call(this,t)}finally{this.opts=e}}}function l(t,e,r,i="error"){for(const n in t){const o=n;o in e&&this.logger[i](`${r}: option ${n}. ${t[o]}`)}}function c(t){return t=(0,Ul.normalizeId)(t),this.schemas[t]||this.refs[t]}function d(){const t=this.opts.schemas;if(t)if(Array.isArray(t))this.addSchema(t);else for(const e in t)this.addSchema(t[e],e)}function f(){for(const t in this.opts.formats){const e=this.opts.formats[t];e&&this.addFormat(t,e)}}function m(t){if(Array.isArray(t))this.addVocabulary(t);else{this.logger.warn("keywords option as map is deprecated, pass array");for(const e in t){const r=t[e];r.keyword||(r.keyword=e),this.addKeyword(r)}}}function p(){const t={...this.opts};for(const e of n)delete t[e];return t}e.default=u,u.ValidationError=Gl.default,u.MissingRefError=Jl.default;const g={log(){},warn(){},error(){}};const y=/^[a-z_$][a-z0-9_$:-]*$/i;function w(t,e){const{RULES:r}=this;if((0,Sl.eachItem)(t,(t=>{if(r.keywords[t])throw new Error(`Keyword ${t} is already defined`);if(!y.test(t))throw new Error(`Keyword ${t} has invalid name`)})),e&&e.$data&&!("code"in e)&&!("validate"in e))throw new Error('$data keyword must have "code" or "validate" function')}function v(t,e,r){var i;const n=null==e?void 0:e.post;if(r&&n)throw new Error('keyword with "post" flag cannot have "type"');const{RULES:o}=this;let a=n?o.post:o.rules.find((({type:t})=>t===r));if(a||(a={type:r,rules:[]},o.rules.push(a)),o.keywords[t]=!0,!e)return;const s={keyword:t,definition:{...e,type:(0,Rl.getJSONTypes)(e.type),schemaType:(0,Rl.getJSONTypes)(e.schemaType)}};e.before?b.call(this,a,s,e.before):a.rules.push(s),o.all[t]=s,null===(i=e.implements)||void 0===i||i.forEach((t=>this.addKeyword(t)))}function b(t,e,r){const i=t.rules.findIndex((t=>t.keyword===r));i>=0?t.rules.splice(i,0,e):(t.rules.push(e),this.logger.warn(`rule ${r} is not defined`))}function k(t){let{metaSchema:e}=t;void 0!==e&&(t.$data&&this.opts.$data&&(e=_(e)),t.validateSchema=this.compile(e,!0))}const M={$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"};function _(t){return{anyOf:[t,M]}}}));var rc={keyword:"id",code(){throw new Error('NOT SUPPORTED: keyword "id", use "$id" for schema ID')}},ic=Object.defineProperty({default:rc},"__esModule",{value:!0}),nc=a((function(t,e){Object.defineProperty(e,"__esModule",{value:!0}),e.callRef=e.getValidate=void 0;const r={keyword:"$ref",schemaType:"string",code(t){const{gen:e,schema:r,it:o}=t,{baseId:a,schemaEnv:s,validateName:h,opts:u,self:l}=o,{root:c}=s;if(("#"===r||"#/"===r)&&a===c.baseId)return function(){if(s===c)return n(t,h,s,s.$async);const r=e.scopeValue("root",{ref:c});return n(t,xl._`${r}.validate`,c,c.$async)}();const d=Wl.resolveRef.call(l,c,a,r);if(void 0===d)throw new Jl.default(o.opts.uriResolver,a,r);return d instanceof Wl.SchemaEnv?function(e){const r=i(t,e);n(t,r,e,e.$async)}(d):function(i){const n=e.scopeValue("schema",!0===u.code.source?{ref:i,code:(0,xl.stringify)(i)}:{ref:i}),o=e.name("valid"),a=t.subschema({schema:i,dataTypes:[],schemaPath:xl.nil,topSchemaRef:n,errSchemaPath:r},o);t.mergeEvaluated(a),t.ok(o)}(d)}};function i(t,e){const{gen:r}=t;return e.validate?r.scopeValue("validate",{ref:e.validate}):xl._`${r.scopeValue("wrapper",{ref:e})}.validate`}function n(t,e,r,i){const{gen:n,it:o}=t,{allErrors:a,schemaEnv:s,opts:h}=o,u=h.passContext?Il.default.this:xl.nil;function l(t){const e=xl._`${t}.errors`;n.assign(Il.default.vErrors,xl._`${Il.default.vErrors} === null ? ${e} : ${Il.default.vErrors}.concat(${e})`),n.assign(Il.default.errors,xl._`${Il.default.vErrors}.length`)}function c(t){var e;if(!o.opts.unevaluated)return;const i=null===(e=null==r?void 0:r.validate)||void 0===e?void 0:e.evaluated;if(!0!==o.props)if(i&&!i.dynamicProps)void 0!==i.props&&(o.props=Sl.mergeEvaluated.props(n,i.props,o.props));else{const e=n.var("props",xl._`${t}.evaluated.props`);o.props=Sl.mergeEvaluated.props(n,e,o.props,xl.Name)}if(!0!==o.items)if(i&&!i.dynamicItems)void 0!==i.items&&(o.items=Sl.mergeEvaluated.items(n,i.items,o.items));else{const e=n.var("items",xl._`${t}.evaluated.items`);o.items=Sl.mergeEvaluated.items(n,e,o.items,xl.Name)}}i?function(){if(!s.$async)throw new Error("async schema referenced by sync schema");const r=n.let("valid");n.try((()=>{n.code(xl._`await ${(0,Bl.callValidateCode)(t,e,u)}`),c(e),a||n.assign(r,!0)}),(t=>{n.if(xl._`!(${t} instanceof ${o.ValidationError})`,(()=>n.throw(t))),l(t),a||n.assign(r,!1)})),t.ok(r)}():t.result((0,Bl.callValidateCode)(t,e,u),(()=>c(e)),(()=>l(e)))}e.getValidate=i,e.callRef=n,e.default=r}));var oc=["$schema","$id","$defs","$vocabulary",{keyword:"$comment"},"definitions",ic.default,nc.default],ac=Object.defineProperty({default:oc},"__esModule",{value:!0});const sc=xl.operators,hc={maximum:{okStr:"<=",ok:sc.LTE,fail:sc.GT},minimum:{okStr:">=",ok:sc.GTE,fail:sc.LT},exclusiveMaximum:{okStr:"<",ok:sc.LT,fail:sc.GTE},exclusiveMinimum:{okStr:">",ok:sc.GT,fail:sc.LTE}},uc={message:({keyword:t,schemaCode:e})=>xl.str`must be ${hc[t].okStr} ${e}`,params:({keyword:t,schemaCode:e})=>xl._`{comparison: ${hc[t].okStr}, limit: ${e}}`},lc={keyword:Object.keys(hc),type:"number",schemaType:"number",$data:!0,error:uc,code(t){const{keyword:e,data:r,schemaCode:i}=t;t.fail$data(xl._`${r} ${hc[e].fail} ${i} || isNaN(${r})`)}};var cc=lc,dc=Object.defineProperty({default:cc},"__esModule",{value:!0});const fc={keyword:"multipleOf",type:"number",schemaType:"number",$data:!0,error:{message:({schemaCode:t})=>xl.str`must be multiple of ${t}`,params:({schemaCode:t})=>xl._`{multipleOf: ${t}}`},code(t){const{gen:e,data:r,schemaCode:i,it:n}=t,o=n.opts.multipleOfPrecision,a=e.let("res"),s=o?xl._`Math.abs(Math.round(${a}) - ${a}) > 1e-${o}`:xl._`${a} !== parseInt(${a})`;t.fail$data(xl._`(${i} === 0 || (${a} = ${r}/${i}, ${s}))`)}};var mc=fc,pc=Object.defineProperty({default:mc},"__esModule",{value:!0});function gc(t){const e=t.length;let r,i=0,n=0;for(;n<e;)i++,r=t.charCodeAt(n++),r>=55296&&r<=56319&&n<e&&(r=t.charCodeAt(n),56320==(64512&r)&&n++);return i}var yc=gc;gc.code='require("ajv/dist/runtime/ucs2length").default';var wc=Object.defineProperty({default:yc},"__esModule",{value:!0});const vc={message({keyword:t,schemaCode:e}){const r="maxLength"===t?"more":"fewer";return xl.str`must NOT have ${r} than ${e} characters`},params:({schemaCode:t})=>xl._`{limit: ${t}}`},bc={keyword:["maxLength","minLength"],type:"string",schemaType:"number",$data:!0,error:vc,code(t){const{keyword:e,data:r,schemaCode:i,it:n}=t,o="maxLength"===e?xl.operators.GT:xl.operators.LT,a=!1===n.opts.unicode?xl._`${r}.length`:xl._`${(0,Sl.useFunc)(t.gen,wc.default)}(${r})`;t.fail$data(xl._`${a} ${o} ${i}`)}};var kc=bc,Mc=Object.defineProperty({default:kc},"__esModule",{value:!0});var _c={keyword:"pattern",type:"string",schemaType:"string",$data:!0,error:{message:({schemaCode:t})=>xl.str`must match pattern "${t}"`,params:({schemaCode:t})=>xl._`{pattern: ${t}}`},code(t){const{data:e,$data:r,schema:i,schemaCode:n,it:o}=t,a=o.opts.unicodeRegExp?"u":"",s=r?xl._`(new RegExp(${n}, ${a}))`:(0,Bl.usePattern)(t,i);t.fail$data(xl._`!${s}.test(${e})`)}},Ec=Object.defineProperty({default:_c},"__esModule",{value:!0});const Ac={message({keyword:t,schemaCode:e}){const r="maxProperties"===t?"more":"fewer";return xl.str`must NOT have ${r} than ${e} properties`},params:({schemaCode:t})=>xl._`{limit: ${t}}`},jc={keyword:["maxProperties","minProperties"],type:"object",schemaType:"number",$data:!0,error:Ac,code(t){const{keyword:e,data:r,schemaCode:i}=t,n="maxProperties"===e?xl.operators.GT:xl.operators.LT;t.fail$data(xl._`Object.keys(${r}).length ${n} ${i}`)}};var xc=jc,Sc=Object.defineProperty({default:xc},"__esModule",{value:!0});const Nc={keyword:"required",type:"object",schemaType:"array",$data:!0,error:{message:({params:{missingProperty:t}})=>xl.str`must have required property '${t}'`,params:({params:{missingProperty:t}})=>xl._`{missingProperty: ${t}}`},code(t){const{gen:e,schema:r,schemaCode:i,data:n,$data:o,it:a}=t,{opts:s}=a;if(!o&&0===r.length)return;const h=r.length>=s.loopRequired;if(a.allErrors?function(){if(h||o)t.block$data(xl.nil,u);else for(const e of r)(0,Bl.checkReportMissingProp)(t,e)}():function(){const a=e.let("missing");if(h||o){const r=e.let("valid",!0);t.block$data(r,(()=>function(r,o){t.setParams({missingProperty:r}),e.forOf(r,i,(()=>{e.assign(o,(0,Bl.propertyInData)(e,n,r,s.ownProperties)),e.if((0,xl.not)(o),(()=>{t.error(),e.break()}))}),xl.nil)}(a,r))),t.ok(r)}else e.if((0,Bl.checkMissingProp)(t,r,a)),(0,Bl.reportMissingProp)(t,a),e.else()}(),s.strictRequired){const e=t.parentSchema.properties,{definedProperties:i}=t.it;for(const t of r)if(void 0===(null==e?void 0:e[t])&&!i.has(t)){const e=`required property "${t}" is not defined at "${a.schemaEnv.baseId+a.errSchemaPath}" (strictRequired)`;(0,Sl.checkStrictMode)(a,e,a.opts.strictRequired)}}function u(){e.forOf("prop",i,(r=>{t.setParams({missingProperty:r}),e.if((0,Bl.noPropertyInData)(e,n,r,s.ownProperties),(()=>t.error()))}))}}};var Ic=Nc,Tc=Object.defineProperty({default:Ic},"__esModule",{value:!0});const Cc={message({keyword:t,schemaCode:e}){const r="maxItems"===t?"more":"fewer";return xl.str`must NOT have ${r} than ${e} items`},params:({schemaCode:t})=>xl._`{limit: ${t}}`},zc={keyword:["maxItems","minItems"],type:"array",schemaType:"number",$data:!0,error:Cc,code(t){const{keyword:e,data:r,schemaCode:i}=t,n="maxItems"===e?xl.operators.GT:xl.operators.LT;t.fail$data(xl._`${r}.length ${n} ${i}`)}};var Oc=zc,Rc=Object.defineProperty({default:Oc},"__esModule",{value:!0});Ll.code='require("ajv/dist/runtime/equal").default';var Pc=Ll,Bc=Object.defineProperty({default:Pc},"__esModule",{value:!0});const Dc={keyword:"uniqueItems",type:"array",schemaType:"boolean",$data:!0,error:{message:({params:{i:t,j:e}})=>xl.str`must NOT have duplicate items (items ## ${e} and ${t} are identical)`,params:({params:{i:t,j:e}})=>xl._`{i: ${t}, j: ${e}}`},code(t){const{gen:e,data:r,$data:i,schema:n,parentSchema:o,schemaCode:a,it:s}=t;if(!i&&!n)return;const h=e.let("valid"),u=o.items?(0,Rl.getSchemaTypes)(o.items):[];function l(i,n){const o=e.name("item"),a=(0,Rl.checkDataTypes)(u,o,s.opts.strictNumbers,Rl.DataType.Wrong),l=e.const("indices",xl._`{}`);e.for(xl._`;${i}--;`,(()=>{e.let(o,xl._`${r}[${i}]`),e.if(a,xl._`continue`),u.length>1&&e.if(xl._`typeof ${o} == "string"`,xl._`${o} += "_"`),e.if(xl._`typeof ${l}[${o}] == "number"`,(()=>{e.assign(n,xl._`${l}[${o}]`),t.error(),e.assign(h,!1).break()})).code(xl._`${l}[${o}] = ${i}`)}))}function c(i,n){const o=(0,Sl.useFunc)(e,Bc.default),a=e.name("outer");e.label(a).for(xl._`;${i}--;`,(()=>e.for(xl._`${n} = ${i}; ${n}--;`,(()=>e.if(xl._`${o}(${r}[${i}], ${r}[${n}])`,(()=>{t.error(),e.assign(h,!1).break(a)}))))))}t.block$data(h,(function(){const i=e.let("i",xl._`${r}.length`),n=e.let("j");t.setParams({i:i,j:n}),e.assign(h,!0),e.if(xl._`${i} > 1`,(()=>(u.length>0&&!u.some((t=>"object"===t||"array"===t))?l:c)(i,n)))}),xl._`${a} === false`),t.ok(h)}};var $c=Dc,Lc=Object.defineProperty({default:$c},"__esModule",{value:!0});const Fc={keyword:"const",$data:!0,error:{message:"must be equal to constant",params:({schemaCode:t})=>xl._`{allowedValue: ${t}}`},code(t){const{gen:e,data:r,$data:i,schemaCode:n,schema:o}=t;i||o&&"object"==typeof o?t.fail$data(xl._`!${(0,Sl.useFunc)(e,Bc.default)}(${r}, ${n})`):t.fail(xl._`${o} !== ${r}`)}};var Uc=Fc,qc=Object.defineProperty({default:Uc},"__esModule",{value:!0});const Vc={keyword:"enum",schemaType:"array",$data:!0,error:{message:"must be equal to one of the allowed values",params:({schemaCode:t})=>xl._`{allowedValues: ${t}}`},code(t){const{gen:e,data:r,$data:i,schema:n,schemaCode:o,it:a}=t;if(!i&&0===n.length)throw new Error("enum must have non-empty array");const s=n.length>=a.opts.loopEnum;let h;const u=()=>null!=h?h:h=(0,Sl.useFunc)(e,Bc.default);let l;if(s||i)l=e.let("valid"),t.block$data(l,(function(){e.assign(l,!1),e.forOf("v",o,(t=>e.if(xl._`${u()}(${r}, ${t})`,(()=>e.assign(l,!0).break()))))}));else{if(!Array.isArray(n))throw new Error("ajv implementation error");const t=e.const("vSchema",o);l=(0,xl.or)(...n.map(((e,i)=>function(t,e){const i=n[e];return"object"==typeof i&&null!==i?xl._`${u()}(${r}, ${t}[${e}])`:xl._`${r} === ${i}`}(t,i))))}t.pass(l)}};var Hc=Vc,Gc=Object.defineProperty({default:Hc},"__esModule",{value:!0});var Zc=[dc.default,pc.default,Mc.default,Ec.default,Sc.default,Tc.default,Rc.default,Lc.default,{keyword:"type",schemaType:["string","array"]},{keyword:"nullable",schemaType:"boolean"},qc.default,Gc.default],Kc=Object.defineProperty({default:Zc},"__esModule",{value:!0}),Jc=a((function(t,e){Object.defineProperty(e,"__esModule",{value:!0}),e.validateAdditionalItems=void 0;const r={keyword:"additionalItems",type:"array",schemaType:["boolean","object"],before:"uniqueItems",error:{message:({params:{len:t}})=>xl.str`must NOT have more than ${t} items`,params:({params:{len:t}})=>xl._`{limit: ${t}}`},code(t){const{parentSchema:e,it:r}=t,{items:n}=e;Array.isArray(n)?i(t,n):(0,Sl.checkStrictMode)(r,'"additionalItems" is ignored when "items" is not an array of schemas')}};function i(t,e){const{gen:r,schema:i,data:n,keyword:o,it:a}=t;a.items=!0;const s=r.const("len",xl._`${n}.length`);if(!1===i)t.setParams({len:e.length}),t.pass(xl._`${s} <= ${e.length}`);else if("object"==typeof i&&!(0,Sl.alwaysValidSchema)(a,i)){const i=r.var("valid",xl._`${s} <= ${e.length}`);r.if((0,xl.not)(i),(()=>function(i){r.forRange("i",e.length,s,(e=>{t.subschema({keyword:o,dataProp:e,dataPropType:Sl.Type.Num},i),a.allErrors||r.if((0,xl.not)(i),(()=>r.break()))}))}(i))),t.ok(i)}}e.validateAdditionalItems=i,e.default=r})),Wc=a((function(t,e){Object.defineProperty(e,"__esModule",{value:!0}),e.validateTuple=void 0;const r={keyword:"items",type:"array",schemaType:["object","array","boolean"],before:"uniqueItems",code(t){const{schema:e,it:r}=t;if(Array.isArray(e))return i(t,"additionalItems",e);r.items=!0,(0,Sl.alwaysValidSchema)(r,e)||t.ok((0,Bl.validateArray)(t))}};function i(t,e,r=t.schema){const{gen:i,parentSchema:n,data:o,keyword:a,it:s}=t;!function(t){const{opts:i,errSchemaPath:n}=s,o=r.length,h=o===t.minItems&&(o===t.maxItems||!1===t[e]);if(i.strictTuples&&!h){const t=`"${a}" is ${o}-tuple, but minItems or maxItems/${e} are not specified or different at path "${n}"`;(0,Sl.checkStrictMode)(s,t,i.strictTuples)}}(n),s.opts.unevaluated&&r.length&&!0!==s.items&&(s.items=Sl.mergeEvaluated.items(i,r.length,s.items));const h=i.name("valid"),u=i.const("len",xl._`${o}.length`);r.forEach(((e,r)=>{(0,Sl.alwaysValidSchema)(s,e)||(i.if(xl._`${u} > ${r}`,(()=>t.subschema({keyword:a,schemaProp:r,dataProp:r},h))),t.ok(h))}))}e.validateTuple=i,e.default=r}));var Yc={keyword:"prefixItems",type:"array",schemaType:["array"],before:"uniqueItems",code:t=>(0,Wc.validateTuple)(t,"items")},Qc=Object.defineProperty({default:Yc},"__esModule",{value:!0});const Xc={keyword:"items",type:"array",schemaType:["object","boolean"],before:"uniqueItems",error:{message:({params:{len:t}})=>xl.str`must NOT have more than ${t} items`,params:({params:{len:t}})=>xl._`{limit: ${t}}`},code(t){const{schema:e,parentSchema:r,it:i}=t,{prefixItems:n}=r;i.items=!0,(0,Sl.alwaysValidSchema)(i,e)||(n?(0,Jc.validateAdditionalItems)(t,n):t.ok((0,Bl.validateArray)(t)))}};var td=Xc,ed=Object.defineProperty({default:td},"__esModule",{value:!0});const rd={keyword:"contains",type:"array",schemaType:["object","boolean"],before:"uniqueItems",trackErrors:!0,error:{message:({params:{min:t,max:e}})=>void 0===e?xl.str`must contain at least ${t} valid item(s)`:xl.str`must contain at least ${t} and no more than ${e} valid item(s)`,params:({params:{min:t,max:e}})=>void 0===e?xl._`{minContains: ${t}}`:xl._`{minContains: ${t}, maxContains: ${e}}`},code(t){const{gen:e,schema:r,parentSchema:i,data:n,it:o}=t;let a,s;const{minContains:h,maxContains:u}=i;o.opts.next?(a=void 0===h?1:h,s=u):a=1;const l=e.const("len",xl._`${n}.length`);if(t.setParams({min:a,max:s}),void 0===s&&0===a)return void(0,Sl.checkStrictMode)(o,'"minContains" == 0 without "maxContains": "contains" keyword ignored');if(void 0!==s&&a>s)return(0,Sl.checkStrictMode)(o,'"minContains" > "maxContains" is always invalid'),void t.fail();if((0,Sl.alwaysValidSchema)(o,r)){let e=xl._`${l} >= ${a}`;return void 0!==s&&(e=xl._`${e} && ${l} <= ${s}`),void t.pass(e)}o.items=!0;const c=e.name("valid");function d(){const t=e.name("_valid"),r=e.let("count",0);f(t,(()=>e.if(t,(()=>function(t){e.code(xl._`${t}++`),void 0===s?e.if(xl._`${t} >= ${a}`,(()=>e.assign(c,!0).break())):(e.if(xl._`${t} > ${s}`,(()=>e.assign(c,!1).break())),1===a?e.assign(c,!0):e.if(xl._`${t} >= ${a}`,(()=>e.assign(c,!0))))}(r)))))}function f(r,i){e.forRange("i",0,l,(e=>{t.subschema({keyword:"contains",dataProp:e,dataPropType:Sl.Type.Num,compositeRule:!0},r),i()}))}void 0===s&&1===a?f(c,(()=>e.if(c,(()=>e.break())))):0===a?(e.let(c,!0),void 0!==s&&e.if(xl._`${n}.length > 0`,d)):(e.let(c,!1),d()),t.result(c,(()=>t.reset()))}};var id=rd,nd=Object.defineProperty({default:id},"__esModule",{value:!0}),od=a((function(t,e){Object.defineProperty(e,"__esModule",{value:!0}),e.validateSchemaDeps=e.validatePropertyDeps=e.error=void 0,e.error={message:({params:{property:t,depsCount:e,deps:r}})=>{const i=1===e?"property":"properties";return xl.str`must have ${i} ${r} when property ${t} is present`},params:({params:{property:t,depsCount:e,deps:r,missingProperty:i}})=>xl._`{property: ${t},
@@ -229,4 +229,4 @@ const{fromCallback:Lj}=WA,Fj=JA.Store,Uj=QA.permuteDomain,qj=XA.pathMatch,{getCu
229
229
  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
230
230
  * POSSIBILITY OF SUCH DAMAGE.
231
231
  */
232
- const ox=JA.Store,ax=Kj.MemoryCookieStore,sx=XA.pathMatch,{fromCallback:hx}=WA,{getCustomInspectSymbol:ux}=$j,lx=/^[\x21\x23-\x2B\x2D-\x3A\x3C-\x5B\x5D-\x7E]+$/,cx=/[\x00-\x1F]/,dx=["\n","\r","\0"],fx=/[\x20-\x3A\x3C-\x7E]+/,mx=/[\x09\x20-\x2F\x3B-\x40\x5B-\x60\x7B-\x7E]/,px={jan:0,feb:1,mar:2,apr:3,may:4,jun:5,jul:6,aug:7,sep:8,oct:9,nov:10,dec:11},gx=2147483647e3,yx='Invalid sameSiteContext option for getCookies(); expected one of "strict", "lax", or "none"';function wx(t){rx.validate(rx.isNonEmptyString(t),t);const e=String(t).toLowerCase();return"none"===e||"lax"===e||"strict"===e?e:null}const vx=Object.freeze({SILENT:"silent",STRICT:"strict",DISABLED:"unsafe-disabled"}),bx=/(?:^(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)){3}$)|(?:^(?:(?:[a-f\d]{1,4}:){7}(?:[a-f\d]{1,4}|:)|(?:[a-f\d]{1,4}:){6}(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)){3}|:[a-f\d]{1,4}|:)|(?:[a-f\d]{1,4}:){5}(?::(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)){3}|(?::[a-f\d]{1,4}){1,2}|:)|(?:[a-f\d]{1,4}:){4}(?:(?::[a-f\d]{1,4}){0,1}:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)){3}|(?::[a-f\d]{1,4}){1,3}|:)|(?:[a-f\d]{1,4}:){3}(?:(?::[a-f\d]{1,4}){0,2}:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)){3}|(?::[a-f\d]{1,4}){1,4}|:)|(?:[a-f\d]{1,4}:){2}(?:(?::[a-f\d]{1,4}){0,3}:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)){3}|(?::[a-f\d]{1,4}){1,5}|:)|(?:[a-f\d]{1,4}:){1}(?:(?::[a-f\d]{1,4}){0,4}:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)){3}|(?::[a-f\d]{1,4}){1,6}|:)|(?::(?:(?::[a-f\d]{1,4}){0,5}:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)){3}|(?::[a-f\d]{1,4}){1,7}|:)))$)/,kx="\n\\[?(?:\n(?:[a-fA-F\\d]{1,4}:){7}(?:[a-fA-F\\d]{1,4}|:)|\n(?:[a-fA-F\\d]{1,4}:){6}(?:(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)(?:\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)){3}|:[a-fA-F\\d]{1,4}|:)|\n(?:[a-fA-F\\d]{1,4}:){5}(?::(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)(?:\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)){3}|(?::[a-fA-F\\d]{1,4}){1,2}|:)|\n(?:[a-fA-F\\d]{1,4}:){4}(?:(?::[a-fA-F\\d]{1,4}){0,1}:(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)(?:\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)){3}|(?::[a-fA-F\\d]{1,4}){1,3}|:)|\n(?:[a-fA-F\\d]{1,4}:){3}(?:(?::[a-fA-F\\d]{1,4}){0,2}:(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)(?:\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)){3}|(?::[a-fA-F\\d]{1,4}){1,4}|:)|\n(?:[a-fA-F\\d]{1,4}:){2}(?:(?::[a-fA-F\\d]{1,4}){0,3}:(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)(?:\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)){3}|(?::[a-fA-F\\d]{1,4}){1,5}|:)|\n(?:[a-fA-F\\d]{1,4}:){1}(?:(?::[a-fA-F\\d]{1,4}){0,4}:(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)(?:\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)){3}|(?::[a-fA-F\\d]{1,4}){1,6}|:)|\n(?::(?:(?::[a-fA-F\\d]{1,4}){0,5}:(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)(?:\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)){3}|(?::[a-fA-F\\d]{1,4}){1,7}|:))\n)(?:%[0-9a-zA-Z]{1,})?\\]?\n".replace(/\s*\/\/.*$/gm,"").replace(/\n/g,"").trim(),Mx=new RegExp(`^${kx}$`);function _x(t,e,r,i){let n=0;for(;n<t.length;){const e=t.charCodeAt(n);if(e<=47||e>=58)break;n++}return n<e||n>r?null:i||n==t.length?parseInt(t.substr(0,n),10):null}function Ex(t){const e=t.split(":"),r=[0,0,0];if(3!==e.length)return null;for(let t=0;t<3;t++){const i=2==t,n=_x(e[t],1,2,i);if(null===n)return null;r[t]=n}return r}function Ax(t){t=String(t).substr(0,3).toLowerCase();const e=px[t];return e>=0?e:null}function jx(t){if(!t)return;const e=t.split(mx);if(!e)return;let r=null,i=null,n=null,o=null,a=null,s=null;for(let t=0;t<e.length;t++){const h=e[t].trim();if(!h.length)continue;let u;null===n&&(u=Ex(h),u)?(r=u[0],i=u[1],n=u[2]):null!==o||(u=_x(h,1,2,!0),null===u)?null!==a||(u=Ax(h),null===u)?null===s&&(u=_x(h,2,4,!0),null!==u&&(s=u,s>=70&&s<=99?s+=1900:s>=0&&s<=69&&(s+=2e3))):a=u:o=u}return null===o||null===a||null===s||null===n||o<1||o>31||s<1601||r>23||i>59||n>59?void 0:new Date(Date.UTC(s,a,o,r,i,n))}function xx(t){return rx.validate(rx.isDate(t),t),t.toUTCString()}function Sx(t){return null==t?null:(t=t.trim().replace(/^\./,""),Mx.test(t)&&(t=t.replace("[","").replace("]","")),nx&&/[^\u0001-\u007f]/.test(t)&&(t=nx.toASCII(t)),t.toLowerCase())}function Nx(t,e,r){if(null==t||null==e)return null;if(!1!==r&&(t=Sx(t),e=Sx(e)),t==e)return!0;const i=t.lastIndexOf(e);return!(i<=0)&&(t.length===e.length+i&&("."===t.substr(i-1,1)&&!bx.test(t)))}function Ix(t){if(!t||"/"!==t.substr(0,1))return"/";if("/"===t)return t;const e=t.lastIndexOf("/");return 0===e?"/":t.slice(0,e)}function Tx(t,e){t=function(t){if(rx.isEmptyString(t))return t;for(let e=0;e<dx.length;e++){const r=t.indexOf(dx[e]);-1!==r&&(t=t.substr(0,r))}return t}(t),rx.validate(rx.isString(t),t);let r,i,n=t.indexOf("=");if(e)0===n&&(n=(t=t.substr(1)).indexOf("="));else if(n<=0)return;if(n<=0?(r="",i=t.trim()):(r=t.substr(0,n).trim(),i=t.substr(n+1).trim()),cx.test(r)||cx.test(i))return;const o=new Dx;return o.key=r,o.value=i,o}function Cx(t,e){if(e&&"object"==typeof e||(e={}),rx.isEmptyString(t)||!rx.isString(t))return null;const r=(t=t.trim()).indexOf(";"),i=Tx(-1===r?t:t.substr(0,r),!!e.loose);if(!i)return;if(-1===r)return i;const n=t.slice(r+1).trim();if(0===n.length)return i;const o=n.split(";");for(;o.length;){const t=o.shift().trim();if(0===t.length)continue;const e=t.indexOf("=");let r,n;switch(-1===e?(r=t,n=null):(r=t.substr(0,e),n=t.substr(e+1)),r=r.trim().toLowerCase(),n&&(n=n.trim()),r){case"expires":if(n){const t=jx(n);t&&(i.expires=t)}break;case"max-age":if(n&&/^-?[0-9]+$/.test(n)){const t=parseInt(n,10);i.setMaxAge(t)}break;case"domain":if(n){const t=n.trim().replace(/^\./,"");t&&(i.domain=t.toLowerCase())}break;case"path":i.path=n&&"/"===n[0]?n:null;break;case"secure":i.secure=!0;break;case"httponly":i.httpOnly=!0;break;case"samesite":switch(n?n.toLowerCase():""){case"strict":i.sameSite="strict";break;case"lax":i.sameSite="lax";break;case"none":i.sameSite="none";break;default:i.sameSite=void 0}break;default:i.extensions=i.extensions||[],i.extensions.push(t)}}return i}function zx(t){let e;try{e=JSON.parse(t)}catch(t){return t}return e}function Ox(t){if(!t||rx.isEmptyString(t))return null;let e;if("string"==typeof t){if(e=zx(t),e instanceof Error)return null}else e=t;const r=new Dx;for(let t=0;t<Dx.serializableProperties.length;t++){const i=Dx.serializableProperties[t];void 0!==e[i]&&e[i]!==Bx[i]&&("expires"===i||"creation"===i||"lastAccessed"===i?null===e[i]?r[i]=null:r[i]="Infinity"==e[i]?"Infinity":new Date(e[i]):r[i]=e[i])}return r}function Rx(t,e){rx.validate(rx.isObject(t),t),rx.validate(rx.isObject(e),e);let r=0;const i=t.path?t.path.length:0;if(r=(e.path?e.path.length:0)-i,0!==r)return r;return r=(t.creation?t.creation.getTime():gx)-(e.creation?e.creation.getTime():gx),0!==r||(r=t.creationIndex-e.creationIndex),r}function Px(t){if(t instanceof Object)return t;try{t=decodeURI(t)}catch(t){}return qA(t)}const Bx={key:"",value:"",expires:"Infinity",maxAge:null,domain:null,path:null,secure:!1,httpOnly:!1,extensions:null,hostOnly:null,pathIsDefault:null,creation:null,lastAccessed:null,sameSite:void 0};class Dx{constructor(t={}){const e=ux();e&&(this[e]=this.inspect),Object.assign(this,Bx,t),this.creation=this.creation||new Date,Object.defineProperty(this,"creationIndex",{configurable:!1,enumerable:!1,writable:!0,value:++Dx.cookiesCreated})}inspect(){const t=Date.now(),e=null!=this.hostOnly?this.hostOnly:"?",r=this.creation?t-this.creation.getTime()+"ms":"?",i=this.lastAccessed?t-this.lastAccessed.getTime()+"ms":"?";return`Cookie="${this.toString()}; hostOnly=${e}; aAge=${i}; cAge=${r}"`}toJSON(){const t={};for(const e of Dx.serializableProperties)this[e]!==Bx[e]&&("expires"===e||"creation"===e||"lastAccessed"===e?null===this[e]?t[e]=null:t[e]="Infinity"==this[e]?"Infinity":this[e].toISOString():"maxAge"===e?null!==this[e]&&(t[e]=this[e]==1/0||this[e]==-1/0?this[e].toString():this[e]):this[e]!==Bx[e]&&(t[e]=this[e]));return t}clone(){return Ox(this.toJSON())}validate(){if(!lx.test(this.value))return!1;if(!(this.expires==1/0||this.expires instanceof Date||jx(this.expires)))return!1;if(null!=this.maxAge&&this.maxAge<=0)return!1;if(null!=this.path&&!fx.test(this.path))return!1;const t=this.cdomain();if(t){if(t.match(/\.$/))return!1;if(null==KA.getPublicSuffix(t))return!1}return!0}setExpires(t){t instanceof Date?this.expires=t:this.expires=jx(t)||"Infinity"}setMaxAge(t){this.maxAge=t===1/0||t===-1/0?t.toString():t}cookieString(){let t=this.value;return null==t&&(t=""),""===this.key?t:`${this.key}=${t}`}toString(){let t=this.cookieString();if(this.expires!=1/0&&(this.expires instanceof Date?t+=`; Expires=${xx(this.expires)}`:t+=`; Expires=${this.expires}`),null!=this.maxAge&&this.maxAge!=1/0&&(t+=`; Max-Age=${this.maxAge}`),this.domain&&!this.hostOnly&&(t+=`; Domain=${this.domain}`),this.path&&(t+=`; Path=${this.path}`),this.secure&&(t+="; Secure"),this.httpOnly&&(t+="; HttpOnly"),this.sameSite&&"none"!==this.sameSite){const e=Dx.sameSiteCanonical[this.sameSite.toLowerCase()];t+=`; SameSite=${e||this.sameSite}`}return this.extensions&&this.extensions.forEach((e=>{t+=`; ${e}`})),t}TTL(t){if(null!=this.maxAge)return this.maxAge<=0?0:1e3*this.maxAge;let e=this.expires;return e!=1/0?(e instanceof Date||(e=jx(e)||1/0),e==1/0?1/0:e.getTime()-(t||Date.now())):1/0}expiryTime(t){if(null!=this.maxAge){const e=t||this.creation||new Date,r=this.maxAge<=0?-1/0:1e3*this.maxAge;return e.getTime()+r}return this.expires==1/0?1/0:this.expires.getTime()}expiryDate(t){const e=this.expiryTime(t);return e==1/0?new Date(gx):e==-1/0?new Date(0):new Date(e)}isPersistent(){return null!=this.maxAge||this.expires!=1/0}canonicalizedDomain(){return null==this.domain?null:Sx(this.domain)}cdomain(){return this.canonicalizedDomain()}}function $x(t){if(null!=t){const e=t.toLowerCase();switch(e){case vx.STRICT:case vx.SILENT:case vx.DISABLED:return e}}return vx.SILENT}Dx.cookiesCreated=0,Dx.parse=Cx,Dx.fromJSON=Ox,Dx.serializableProperties=Object.keys(Bx),Dx.sameSiteLevel={strict:3,lax:2,none:1},Dx.sameSiteCanonical={strict:"Strict",lax:"Lax"};class Lx{constructor(t,e={rejectPublicSuffixes:!0}){"boolean"==typeof e&&(e={rejectPublicSuffixes:e}),rx.validate(rx.isObject(e),e),this.rejectPublicSuffixes=e.rejectPublicSuffixes,this.enableLooseMode=!!e.looseMode,this.allowSpecialUseDomain="boolean"!=typeof e.allowSpecialUseDomain||e.allowSpecialUseDomain,this.store=t||new ax,this.prefixSecurity=$x(e.prefixSecurity),this._cloneSync=Fx("clone"),this._importCookiesSync=Fx("_importCookies"),this.getCookiesSync=Fx("getCookies"),this.getCookieStringSync=Fx("getCookieString"),this.getSetCookieStringsSync=Fx("getSetCookieStrings"),this.removeAllCookiesSync=Fx("removeAllCookies"),this.setCookieSync=Fx("setCookie"),this.serializeSync=Fx("serialize")}setCookie(t,e,r,i){let n;if(rx.validate(rx.isUrlStringOrObject(e),i,r),rx.isFunction(e))return(i=e)(new Error("No URL was specified"));const o=Px(e);if(rx.isFunction(r)&&(i=r,r={}),rx.validate(rx.isFunction(i),i),!rx.isNonEmptyString(t)&&!rx.isObject(t)&&t instanceof String&&0==t.length)return i(null);const a=Sx(o.hostname),s=r.loose||this.enableLooseMode;let h=null;if(r.sameSiteContext&&(h=wx(r.sameSiteContext),!h))return i(new Error(yx));if("string"==typeof t||t instanceof String){if(!(t=Dx.parse(t,{loose:s})))return n=new Error("Cookie failed to parse"),i(r.ignoreError?null:n)}else if(!(t instanceof Dx))return n=new Error("First argument to setCookie must be a Cookie object or string"),i(r.ignoreError?null:n);const u=r.now||new Date;if(this.rejectPublicSuffixes&&t.domain){if(null==KA.getPublicSuffix(t.cdomain(),{allowSpecialUseDomain:this.allowSpecialUseDomain,ignoreError:r.ignoreError})&&!Mx.test(t.domain))return n=new Error("Cookie has domain set to a public suffix"),i(r.ignoreError?null:n)}if(t.domain){if(!Nx(a,t.cdomain(),!1))return n=new Error(`Cookie not in this host's domain. Cookie:${t.cdomain()} Request:${a}`),i(r.ignoreError?null:n);null==t.hostOnly&&(t.hostOnly=!1)}else t.hostOnly=!0,t.domain=a;if(t.path&&"/"===t.path[0]||(t.path=Ix(o.pathname),t.pathIsDefault=!0),!1===r.http&&t.httpOnly)return n=new Error("Cookie is HttpOnly and this isn't an HTTP API"),i(r.ignoreError?null:n);if("none"!==t.sameSite&&void 0!==t.sameSite&&h&&"none"===h)return n=new Error("Cookie is SameSite but this is a cross-origin request"),i(r.ignoreError?null:n);const l=this.prefixSecurity===vx.SILENT;if(!(this.prefixSecurity===vx.DISABLED)){let e,n=!1;if(!function(t){return rx.validate(rx.isObject(t),t),!t.key.startsWith("__Secure-")||t.secure}(t)?(n=!0,e="Cookie has __Secure prefix but Secure attribute is not set"):function(t){return rx.validate(rx.isObject(t)),!t.key.startsWith("__Host-")||t.secure&&t.hostOnly&&null!=t.path&&"/"===t.path}(t)||(n=!0,e="Cookie has __Host prefix but either Secure or HostOnly attribute is not set or Path is not '/'"),n)return i(r.ignoreError||l?null:new Error(e))}const c=this.store;c.updateCookie||(c.updateCookie=function(t,e,r){this.putCookie(e,r)}),c.findCookie(t.domain,t.path,t.key,(function(e,n){if(e)return i(e);const o=function(e){if(e)return i(e);i(null,t)};if(n){if(!1===r.http&&n.httpOnly)return e=new Error("old Cookie is HttpOnly and this isn't an HTTP API"),i(r.ignoreError?null:e);t.creation=n.creation,t.creationIndex=n.creationIndex,t.lastAccessed=u,c.updateCookie(n,t,o)}else t.creation=t.lastAccessed=u,c.putCookie(t,o)}))}getCookies(t,e,r){rx.validate(rx.isUrlStringOrObject(t),r,t);const i=Px(t);rx.isFunction(e)&&(r=e,e={}),rx.validate(rx.isObject(e),r,e),rx.validate(rx.isFunction(r),r);const n=Sx(i.hostname),o=i.pathname||"/";let a=e.secure;null!=a||!i.protocol||"https:"!=i.protocol&&"wss:"!=i.protocol||(a=!0);let s=0;if(e.sameSiteContext){const t=wx(e.sameSiteContext);if(s=Dx.sameSiteLevel[t],!s)return r(new Error(yx))}let h=e.http;null==h&&(h=!0);const u=e.now||Date.now(),l=!1!==e.expire,c=!!e.allPaths,d=this.store;function f(t){if(t.hostOnly){if(t.domain!=n)return!1}else if(!Nx(n,t.domain,!1))return!1;if(!c&&!sx(o,t.path))return!1;if(t.secure&&!a)return!1;if(t.httpOnly&&!h)return!1;if(s){if(Dx.sameSiteLevel[t.sameSite||"none"]>s)return!1}return!(l&&t.expiryTime()<=u)||(d.removeCookie(t.domain,t.path,t.key,(()=>{})),!1)}d.findCookies(n,c?null:o,this.allowSpecialUseDomain,((t,i)=>{if(t)return r(t);i=i.filter(f),!1!==e.sort&&(i=i.sort(Rx));const n=new Date;for(const t of i)t.lastAccessed=n;r(null,i)}))}getCookieString(...t){const e=t.pop();rx.validate(rx.isFunction(e),e);t.push((function(t,r){t?e(t):e(null,r.sort(Rx).map((t=>t.cookieString())).join("; "))})),this.getCookies.apply(this,t)}getSetCookieStrings(...t){const e=t.pop();rx.validate(rx.isFunction(e),e);t.push((function(t,r){t?e(t):e(null,r.map((t=>t.toString())))})),this.getCookies.apply(this,t)}serialize(t){rx.validate(rx.isFunction(t),t);let e=this.store.constructor.name;rx.isObject(e)&&(e=null);const r={version:"tough-cookie@4.1.4",storeType:e,rejectPublicSuffixes:!!this.rejectPublicSuffixes,enableLooseMode:!!this.enableLooseMode,allowSpecialUseDomain:!!this.allowSpecialUseDomain,prefixSecurity:$x(this.prefixSecurity),cookies:[]};if(!this.store.getAllCookies||"function"!=typeof this.store.getAllCookies)return t(new Error("store does not support getAllCookies and cannot be serialized"));this.store.getAllCookies(((e,i)=>e?t(e):(r.cookies=i.map((t=>(delete(t=t instanceof Dx?t.toJSON():t).creationIndex,t))),t(null,r))))}toJSON(){return this.serializeSync()}_importCookies(t,e){let r=t.cookies;if(!r||!Array.isArray(r))return e(new Error("serialized jar has no cookies array"));r=r.slice();const i=t=>{if(t)return e(t);if(!r.length)return e(t,this);let n;try{n=Ox(r.shift())}catch(t){return e(t)}if(null===n)return i(null);this.store.putCookie(n,i)};i()}clone(t,e){1===arguments.length&&(e=t,t=null),this.serialize(((r,i)=>{if(r)return e(r);Lx.deserialize(i,t,e)}))}cloneSync(t){if(0===arguments.length)return this._cloneSync();if(!t.synchronous)throw new Error("CookieJar clone destination store is not synchronous; use async API instead.");return this._cloneSync(t)}removeAllCookies(t){rx.validate(rx.isFunction(t),t);const e=this.store;if("function"==typeof e.removeAllCookies&&e.removeAllCookies!==ox.prototype.removeAllCookies)return e.removeAllCookies(t);e.getAllCookies(((r,i)=>{if(r)return t(r);if(0===i.length)return t(null);let n=0;const o=[];function a(e){if(e&&o.push(e),n++,n===i.length)return t(o.length?o[0]:null)}i.forEach((t=>{e.removeCookie(t.domain,t.path,t.key,a)}))}))}static deserialize(t,e,r){let i;if(3!==arguments.length&&(r=e,e=null),rx.validate(rx.isFunction(r),r),"string"==typeof t){if(i=zx(t),i instanceof Error)return r(i)}else i=t;const n=new Lx(e,{rejectPublicSuffixes:i.rejectPublicSuffixes,looseMode:i.enableLooseMode,allowSpecialUseDomain:i.allowSpecialUseDomain,prefixSecurity:i.prefixSecurity});n._importCookies(i,(t=>{if(t)return r(t);r(null,n)}))}static deserializeSync(t,e){const r="string"==typeof t?JSON.parse(t):t,i=new Lx(e,{rejectPublicSuffixes:r.rejectPublicSuffixes,looseMode:r.enableLooseMode});if(!i.store.synchronous)throw new Error("CookieJar store is not synchronous; use async API instead.");return i._importCookiesSync(r),i}}function Fx(t){return function(...e){if(!this.store.synchronous)throw new Error("CookieJar store is not synchronous; use async API instead.");let r,i;if(this[t](...e,((t,e)=>{r=t,i=e})),r)throw r;return i}}Lx.fromJSON=Lx.deserializeSync,["_importCookies","clone","getCookies","getCookieString","getSetCookieStrings","removeAllCookies","serialize","setCookie"].forEach((t=>{Lx.prototype[t]=hx(Lx.prototype[t])})),Lx.deserialize=hx(Lx.deserialize);var Ux=ix,qx=Lx,Vx=Dx,Hx=ox,Gx=ax,Zx=jx,Kx=xx,Jx=Cx,Wx=Ox,Yx=Nx,Qx=Ix,Xx=sx,tS=KA.getPublicSuffix,eS=Rx,rS=QA.permuteDomain,iS=function(t){if(rx.validate(rx.isString(t)),"/"===t)return["/"];const e=[t];for(;t.length>1;){const r=t.lastIndexOf("/");if(0===r)break;t=t.substr(0,r),e.push(t)}return e.push("/"),e},nS=Sx,oS=vx,aS=rx.ParameterError,sS={version:Ux,CookieJar:qx,Cookie:Vx,Store:Hx,MemoryCookieStore:Gx,parseDate:Zx,formatDate:Kx,parse:Jx,fromJSON:Wx,domainMatch:Yx,defaultPath:Qx,pathMatch:Xx,getPublicSuffix:tS,cookieCompare:eS,permuteDomain:rS,permutePath:iS,canonicalDomain:nS,PrefixSecurityEnum:oS,ParameterError:aS},hS=Object.freeze(Object.assign(Object.create(null),sS,{default:sS,version:Ux,CookieJar:qx,Cookie:Vx,Store:Hx,MemoryCookieStore:Gx,parseDate:Zx,formatDate:Kx,parse:Jx,fromJSON:Wx,domainMatch:Yx,defaultPath:Qx,pathMatch:Xx,getPublicSuffix:tS,cookieCompare:eS,permuteDomain:rS,permutePath:iS,canonicalDomain:nS,PrefixSecurityEnum:oS,ParameterError:aS}));var uS=function(t){if(Array.isArray(t))return t;if("string"!=typeof t)return[];var e,r,i,n,o,a=[],s=0;function h(){for(;s<t.length&&/\s/.test(t.charAt(s));)s+=1;return s<t.length}for(;s<t.length;){for(e=s,o=!1;h();)if(","===(r=t.charAt(s))){for(i=s,s+=1,h(),n=s;s<t.length&&"="!==(r=t.charAt(s))&&";"!==r&&","!==r;)s+=1;s<t.length&&"="===t.charAt(s)?(o=!0,s=n,a.push(t.substring(e,i)),e=s):s=i+1}else s+=1;(!o||s>=t.length)&&a.push(t.substring(e,t.length))}return a};const lS=new Set(["","no-referrer","no-referrer-when-downgrade","same-origin","origin","strict-origin","origin-when-cross-origin","strict-origin-when-cross-origin","unsafe-url"]);function cS(t,e){}function dS(t,e){t.headers.delete(e)}function fS(t,e){const r=t.headers;for(const t of Object.keys(r))t.toLowerCase()===e&&delete r[t]}const mS=new Set([301,302,303,307,308]);async function pS(t,e,r){switch(e.redirect??"follow"){case"error":throw new TypeError(`URI requested responded with a redirect and redirect mode is set to error: ${r.url}`);case"manual":return r;case"follow":break;default:throw new TypeError(`Invalid redirect option: ${e.redirect}`)}const i=r.headers.get("location");if(null===i)return r;const n=r.url,o=new URL(i,n).toString(),a=e.redirectCount??0,s=e.maxRedirect??20;if(a>=s)throw new TypeError(`Reached maximum redirect of ${s} for URL: ${n}`);const h=function(t){return null==t.headers?cS:"function"==typeof t.headers.delete?dS:fS}(e={...e,redirectCount:a+1});if(!function(t,e){const r=new URL(e).hostname,i=new URL(t).hostname;return r===i||r.endsWith(`.${i}`)}(n,o))for(const t of["authorization","www-authenticate","cookie","cookie2"])h(e,t);const u=e.body,l=e.body;if(303!==r.status&&null!=e.body&&("function"==typeof u.pipe||"function"==typeof l.pipeTo))throw new TypeError("Cannot follow redirect with body being a readable stream");return 303!==r.status&&(301!==r.status&&302!==r.status||"POST"!==e.method)||(e.method="GET",e.body=void 0,h(e,"content-length")),r.headers.has("referrer-policy")&&(e.referrerPolicy=function(t){const e=t.split(/[,\s]+/);let r="";for(const t of e)""!==t&&lS.has(t)&&(r=t);return r}(r.headers.get("referrer-policy"))),await t(o,e)}function gS(t,e,r=!0){const i=t,n=e??new qx;async function o(t,e){const a=e??{};e={...e,redirect:"manual"};const s="string"==typeof t?t:t.url??t.href;e=function(t,e,r){if(""===r)return e;const i=t,n=e.headers;return i.headers&&"function"==typeof i.headers.append?i.headers.append("cookie",r):n&&"function"==typeof n.append?n.append("cookie",r):e={...e,headers:{...e.headers,cookie:r}},e}(t,e,await n.getCookieString(s));const h=await i(t,e),u=function(t){const e=t.headers;if("function"==typeof e.getAll)return e.getAll("set-cookie");if("function"==typeof e.raw){const t=e.raw();return Array.isArray(t["set-cookie"])?t["set-cookie"]:[]}const r=t.headers.get("set-cookie");return null!==r?uS(r):[]}(h);return await Promise.all(u.map((async t=>await n.setCookie(t,h.url,{ignoreError:r})))),(e.redirectCount??0)>0&&Object.defineProperty(h,"redirected",{value:!0}),l=h.status,mS.has(l)?await pS(o,a,h):h;var l}return o.toughCookie=hS,o}gS.toughCookie=hS;var yS="undefined"!=typeof globalThis&&globalThis||"undefined"!=typeof self&&self||void 0!==t&&t||{},wS="URLSearchParams"in yS,vS="Symbol"in yS&&"iterator"in Symbol,bS="FileReader"in yS&&"Blob"in yS&&function(){try{return new Blob,!0}catch(t){return!1}}(),kS="FormData"in yS,MS="ArrayBuffer"in yS;if(MS)var _S=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],ES=ArrayBuffer.isView||function(t){return t&&_S.indexOf(Object.prototype.toString.call(t))>-1};function AS(t){if("string"!=typeof t&&(t=String(t)),/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(t)||""===t)throw new TypeError('Invalid character in header field name: "'+t+'"');return t.toLowerCase()}function jS(t){return"string"!=typeof t&&(t=String(t)),t}function xS(t){var e={next:function(){var e=t.shift();return{done:void 0===e,value:e}}};return vS&&(e[Symbol.iterator]=function(){return e}),e}function SS(t){this.map={},t instanceof SS?t.forEach((function(t,e){this.append(e,t)}),this):Array.isArray(t)?t.forEach((function(t){if(2!=t.length)throw new TypeError("Headers constructor: expected name/value pair to be length 2, found"+t.length);this.append(t[0],t[1])}),this):t&&Object.getOwnPropertyNames(t).forEach((function(e){this.append(e,t[e])}),this)}function NS(t){if(!t._noBody)return t.bodyUsed?Promise.reject(new TypeError("Already read")):void(t.bodyUsed=!0)}function IS(t){return new Promise((function(e,r){t.onload=function(){e(t.result)},t.onerror=function(){r(t.error)}}))}function TS(t){var e=new FileReader,r=IS(e);return e.readAsArrayBuffer(t),r}function CS(t){if(t.slice)return t.slice(0);var e=new Uint8Array(t.byteLength);return e.set(new Uint8Array(t)),e.buffer}function zS(){return this.bodyUsed=!1,this._initBody=function(t){var e;this.bodyUsed=this.bodyUsed,this._bodyInit=t,t?"string"==typeof t?this._bodyText=t:bS&&Blob.prototype.isPrototypeOf(t)?this._bodyBlob=t:kS&&FormData.prototype.isPrototypeOf(t)?this._bodyFormData=t:wS&&URLSearchParams.prototype.isPrototypeOf(t)?this._bodyText=t.toString():MS&&bS&&((e=t)&&DataView.prototype.isPrototypeOf(e))?(this._bodyArrayBuffer=CS(t.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):MS&&(ArrayBuffer.prototype.isPrototypeOf(t)||ES(t))?this._bodyArrayBuffer=CS(t):this._bodyText=t=Object.prototype.toString.call(t):(this._noBody=!0,this._bodyText=""),this.headers.get("content-type")||("string"==typeof t?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):wS&&URLSearchParams.prototype.isPrototypeOf(t)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},bS&&(this.blob=function(){var t=NS(this);if(t)return t;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))}),this.arrayBuffer=function(){if(this._bodyArrayBuffer){var t=NS(this);return t||(ArrayBuffer.isView(this._bodyArrayBuffer)?Promise.resolve(this._bodyArrayBuffer.buffer.slice(this._bodyArrayBuffer.byteOffset,this._bodyArrayBuffer.byteOffset+this._bodyArrayBuffer.byteLength)):Promise.resolve(this._bodyArrayBuffer))}if(bS)return this.blob().then(TS);throw new Error("could not read as ArrayBuffer")},this.text=function(){var t,e,r,i,n,o=NS(this);if(o)return o;if(this._bodyBlob)return t=this._bodyBlob,e=new FileReader,r=IS(e),i=/charset=([A-Za-z0-9_-]+)/.exec(t.type),n=i?i[1]:"utf-8",e.readAsText(t,n),r;if(this._bodyArrayBuffer)return Promise.resolve(function(t){for(var e=new Uint8Array(t),r=new Array(e.length),i=0;i<e.length;i++)r[i]=String.fromCharCode(e[i]);return r.join("")}(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},kS&&(this.formData=function(){return this.text().then(PS)}),this.json=function(){return this.text().then(JSON.parse)},this}SS.prototype.append=function(t,e){t=AS(t),e=jS(e);var r=this.map[t];this.map[t]=r?r+", "+e:e},SS.prototype.delete=function(t){delete this.map[AS(t)]},SS.prototype.get=function(t){return t=AS(t),this.has(t)?this.map[t]:null},SS.prototype.has=function(t){return this.map.hasOwnProperty(AS(t))},SS.prototype.set=function(t,e){this.map[AS(t)]=jS(e)},SS.prototype.forEach=function(t,e){for(var r in this.map)this.map.hasOwnProperty(r)&&t.call(e,this.map[r],r,this)},SS.prototype.keys=function(){var t=[];return this.forEach((function(e,r){t.push(r)})),xS(t)},SS.prototype.values=function(){var t=[];return this.forEach((function(e){t.push(e)})),xS(t)},SS.prototype.entries=function(){var t=[];return this.forEach((function(e,r){t.push([r,e])})),xS(t)},vS&&(SS.prototype[Symbol.iterator]=SS.prototype.entries);var OS=["CONNECT","DELETE","GET","HEAD","OPTIONS","PATCH","POST","PUT","TRACE"];function RS(t,e){if(!(this instanceof RS))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');var r,i,n=(e=e||{}).body;if(t instanceof RS){if(t.bodyUsed)throw new TypeError("Already read");this.url=t.url,this.credentials=t.credentials,e.headers||(this.headers=new SS(t.headers)),this.method=t.method,this.mode=t.mode,this.signal=t.signal,n||null==t._bodyInit||(n=t._bodyInit,t.bodyUsed=!0)}else this.url=String(t);if(this.credentials=e.credentials||this.credentials||"same-origin",!e.headers&&this.headers||(this.headers=new SS(e.headers)),this.method=(r=e.method||this.method||"GET",i=r.toUpperCase(),OS.indexOf(i)>-1?i:r),this.mode=e.mode||this.mode||null,this.signal=e.signal||this.signal||function(){if("AbortController"in yS)return(new AbortController).signal}(),this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&n)throw new TypeError("Body not allowed for GET or HEAD requests");if(this._initBody(n),!("GET"!==this.method&&"HEAD"!==this.method||"no-store"!==e.cache&&"no-cache"!==e.cache)){var o=/([?&])_=[^&]*/;if(o.test(this.url))this.url=this.url.replace(o,"$1_="+(new Date).getTime());else{this.url+=(/\?/.test(this.url)?"&":"?")+"_="+(new Date).getTime()}}}function PS(t){var e=new FormData;return t.trim().split("&").forEach((function(t){if(t){var r=t.split("="),i=r.shift().replace(/\+/g," "),n=r.join("=").replace(/\+/g," ");e.append(decodeURIComponent(i),decodeURIComponent(n))}})),e}function BS(t,e){if(!(this instanceof BS))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');if(e||(e={}),this.type="default",this.status=void 0===e.status?200:e.status,this.status<200||this.status>599)throw new RangeError("Failed to construct 'Response': The status provided (0) is outside the range [200, 599].");this.ok=this.status>=200&&this.status<300,this.statusText=void 0===e.statusText?"":""+e.statusText,this.headers=new SS(e.headers),this.url=e.url||"",this._initBody(t)}RS.prototype.clone=function(){return new RS(this,{body:this._bodyInit})},zS.call(RS.prototype),zS.call(BS.prototype),BS.prototype.clone=function(){return new BS(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new SS(this.headers),url:this.url})},BS.error=function(){var t=new BS(null,{status:200,statusText:""});return t.ok=!1,t.status=0,t.type="error",t};var DS=[301,302,303,307,308];BS.redirect=function(t,e){if(-1===DS.indexOf(e))throw new RangeError("Invalid status code");return new BS(null,{status:e,headers:{location:t}})};var $S=yS.DOMException;try{new $S}catch(GM){$S=function(t,e){this.message=t,this.name=e;var r=Error(t);this.stack=r.stack},$S.prototype=Object.create(Error.prototype),$S.prototype.constructor=$S}function LS(t,e){return new Promise((function(r,i){var n=new RS(t,e);if(n.signal&&n.signal.aborted)return i(new $S("Aborted","AbortError"));var o=new XMLHttpRequest;function a(){o.abort()}if(o.onload=function(){var t,e,i={statusText:o.statusText,headers:(t=o.getAllResponseHeaders()||"",e=new SS,t.replace(/\r?\n[\t ]+/g," ").split("\r").map((function(t){return 0===t.indexOf("\n")?t.substr(1,t.length):t})).forEach((function(t){var r=t.split(":"),i=r.shift().trim();if(i){var n=r.join(":").trim();try{e.append(i,n)}catch(t){console.warn("Response "+t.message)}}})),e)};0===n.url.indexOf("file://")&&(o.status<200||o.status>599)?i.status=200:i.status=o.status,i.url="responseURL"in o?o.responseURL:i.headers.get("X-Request-URL");var a="response"in o?o.response:o.responseText;setTimeout((function(){r(new BS(a,i))}),0)},o.onerror=function(){setTimeout((function(){i(new TypeError("Network request failed"))}),0)},o.ontimeout=function(){setTimeout((function(){i(new TypeError("Network request timed out"))}),0)},o.onabort=function(){setTimeout((function(){i(new $S("Aborted","AbortError"))}),0)},o.open(n.method,function(t){try{return""===t&&yS.location.href?yS.location.href:t}catch(e){return t}}(n.url),!0),"include"===n.credentials?o.withCredentials=!0:"omit"===n.credentials&&(o.withCredentials=!1),"responseType"in o&&(bS?o.responseType="blob":MS&&(o.responseType="arraybuffer")),e&&"object"==typeof e.headers&&!(e.headers instanceof SS||yS.Headers&&e.headers instanceof yS.Headers)){var s=[];Object.getOwnPropertyNames(e.headers).forEach((function(t){s.push(AS(t)),o.setRequestHeader(t,jS(e.headers[t]))})),n.headers.forEach((function(t,e){-1===s.indexOf(e)&&o.setRequestHeader(e,t)}))}else n.headers.forEach((function(t,e){o.setRequestHeader(e,t)}));n.signal&&(n.signal.addEventListener("abort",a),o.onreadystatechange=function(){4===o.readyState&&n.signal.removeEventListener("abort",a)}),o.send(void 0===n._bodyInit?null:n._bodyInit)}))}LS.polyfill=!0,yS.fetch||(yS.fetch=LS,yS.Headers=SS,yS.Request=RS,yS.Response=BS);var FS=self.fetch.bind(self);const US=(t,e,r=[])=>{const i=Object.getOwnPropertyDescriptors(e);for(let t of r)delete i[t];Object.defineProperties(t,i)},qS=(t,e=[t])=>{const r=Object.getPrototypeOf(t);return null===r?e:qS(r,[...e,r])},VS=(t,e,r=[])=>{var i;const n=null!==(i=((...t)=>{if(0===t.length)return;let e;const r=t.map((t=>qS(t)));for(;r.every((t=>t.length>0));){const t=r.map((t=>t.pop())),i=t[0];if(!t.every((t=>t===i)))break;e=i}return e})(...t))&&void 0!==i?i:Object.prototype,o=Object.create(n),a=qS(n);for(let e of t){let t=qS(e);for(let e=t.length-1;e>=0;e--){let i=t[e];-1===a.indexOf(i)&&(US(o,i,["constructor",...r]),a.push(i))}}return o.constructor=e,o},HS=t=>t.filter(((e,r)=>t.indexOf(e)==r)),GS=new WeakMap,ZS=t=>GS.get(t),KS=(t,e)=>{var r,i;const n=HS([...Object.getOwnPropertyNames(t),...Object.getOwnPropertyNames(e)]),o={};for(let a of n)o[a]=HS([...null!==(r=null==t?void 0:t[a])&&void 0!==r?r:[],...null!==(i=null==e?void 0:e[a])&&void 0!==i?i:[]]);return o},JS=(t,e)=>{var r,i,n,o;return{property:KS(null!==(r=null==t?void 0:t.property)&&void 0!==r?r:{},null!==(i=null==e?void 0:e.property)&&void 0!==i?i:{}),method:KS(null!==(n=null==t?void 0:t.method)&&void 0!==n?n:{},null!==(o=null==e?void 0:e.method)&&void 0!==o?o:{})}},WS=new Map,YS=(...t)=>{const e=((...t)=>{var e;const r=new Set,i=new Set([...t]);for(;i.size>0;)for(let t of i){const n=[...qS(t.prototype).map((t=>t.constructor)),...null!==(e=ZS(t))&&void 0!==e?e:[]].filter((t=>!r.has(t)));for(let t of n)i.add(t);r.add(t),i.delete(t)}return[...r]})(...t).map((t=>WS.get(t))).filter((t=>!!t));return 0==e.length?{}:1==e.length?e[0]:e.reduce(((t,e)=>((t,e)=>{var r,i,n,o,a,s;return{class:HS([...null!==(r=null==t?void 0:t.class)&&void 0!==r?r:[],...null!==(i=null==e?void 0:e.class)&&void 0!==i?i:[]]),static:JS(null!==(n=null==t?void 0:t.static)&&void 0!==n?n:{},null!==(o=null==e?void 0:e.static)&&void 0!==o?o:{}),instance:JS(null!==(a=null==t?void 0:t.instance)&&void 0!==a?a:{},null!==(s=null==e?void 0:e.instance)&&void 0!==s?s:{})}})(t,e)))};function QS(...t){var e,r,i;const n=t.map((t=>t.prototype));function o(...e){for(const r of t)US(this,new r(...e))}o.prototype=VS(n,o),Object.setPrototypeOf(o,VS(t,null,["prototype"]));let a=o;{const n=YS(...t);for(let t of null!==(e=null==n?void 0:n.class)&&void 0!==e?e:[]){const e=t(a);e&&(a=e)}XS(null!==(r=null==n?void 0:n.static)&&void 0!==r?r:{},a),XS(null!==(i=null==n?void 0:n.instance)&&void 0!==i?i:{},a.prototype)}var s,h;return s=a,h=t,GS.set(s,h),a}const XS=(t,e)=>{const r=t.property,i=t.method;if(r)for(let t in r)for(let i of r[t])i(e,t);if(i)for(let t in i)for(let r of i[t])r(e,t,Object.getOwnPropertyDescriptor(e,t))};var tN=Object.defineProperty,eN=Object.getOwnPropertyDescriptor,rN=Object.getOwnPropertyNames,iN=Object.prototype.hasOwnProperty,nN=(t,e)=>{for(var r in e)tN(t,r,{get:e[r],enumerable:!0})},oN=(t,e,r,i)=>{if(e&&"object"==typeof e||"function"==typeof e)for(let n of rN(e))iN.call(t,n)||n===r||tN(t,n,{get:()=>e[n],enumerable:!(i=eN(e,n))||i.enumerable});return t};nN({},{ADDR_BOUND:()=>VN,API_VERSION:()=>FN,BaseUrl:()=>JN,DEFAULT_GLOBAL_CONFIG:()=>hI,FeeMarginPercentage:()=>XN,HARDENING_4BYTES:()=>sI,HARDENING_BYTE:()=>aI,IS_BROWSER:()=>MN,MASK_250:()=>$N,MASK_31:()=>LN,MAX_STORAGE_ITEM_SIZE:()=>qN,NetworkName:()=>WN,OutsideExecutionCallerAny:()=>iI,PRIME:()=>UN,RANGE_FELT:()=>GN,RANGE_I128:()=>ZN,RANGE_U128:()=>KN,RPC_DEFAULT_VERSION:()=>eI,RPC_NODES:()=>rI,SNIP9_V1_INTERFACE_ID:()=>nI,SNIP9_V2_INTERFACE_ID:()=>oI,SYSTEM_MESSAGES:()=>uI,StarknetChainId:()=>YN,TEXT_TO_FELT_MAX_LEN:()=>BN,TRANSACTION_VERSION:()=>aN.ETransactionVersion,TransactionHashPrefix:()=>QN,UDC:()=>tI,ZERO:()=>DN});var aN={};nN(aN,{JRPC:()=>sN,RPCSPEC06:()=>hN,RPCSPEC07:()=>yg});var sN={},hN={};nN(hN,{EBlockTag:()=>gN,EDAMode:()=>wN,EDataAvailabilityMode:()=>yN,ESimulationFlag:()=>dN,ETransactionExecutionStatus:()=>pN,ETransactionFinalityStatus:()=>mN,ETransactionStatus:()=>fN,ETransactionType:()=>cN,ETransactionVersion:()=>vN,ETransactionVersion2:()=>bN,ETransactionVersion3:()=>kN,Errors:()=>uN,SPEC:()=>lN});var uN={},lN={},cN={DECLARE:"DECLARE",DEPLOY:"DEPLOY",DEPLOY_ACCOUNT:"DEPLOY_ACCOUNT",INVOKE:"INVOKE",L1_HANDLER:"L1_HANDLER"},dN={SKIP_VALIDATE:"SKIP_VALIDATE",SKIP_FEE_CHARGE:"SKIP_FEE_CHARGE"},fN={RECEIVED:"RECEIVED",REJECTED:"REJECTED",ACCEPTED_ON_L2:"ACCEPTED_ON_L2",ACCEPTED_ON_L1:"ACCEPTED_ON_L1"},mN={ACCEPTED_ON_L2:"ACCEPTED_ON_L2",ACCEPTED_ON_L1:"ACCEPTED_ON_L1"},pN={SUCCEEDED:"SUCCEEDED",REVERTED:"REVERTED"},gN={PENDING:"pending",LATEST:"latest"},yN={L1:"L1",L2:"L2"},wN={L1:0,L2:1},vN={V0:"0x0",V1:"0x1",V2:"0x2",V3:"0x3",F0:"0x100000000000000000000000000000000",F1:"0x100000000000000000000000000000001",F2:"0x100000000000000000000000000000002",F3:"0x100000000000000000000000000000003"},bN={V0:"0x0",V1:"0x1",V2:"0x2",F0:"0x100000000000000000000000000000000",F1:"0x100000000000000000000000000000001",F2:"0x100000000000000000000000000000002"},kN={V3:"0x3",F3:"0x100000000000000000000000000000003"};((t,e,r)=>{oN(t,e,"default"),r&&oN(r,e,"default")})(aN,yg);nN({},{IS_BROWSER:()=>MN,addHexPrefix:()=>IN,arrayBufferToString:()=>_N,atobUniversal:()=>jN,btoaUniversal:()=>xN,buf2hex:()=>SN,calcByteLength:()=>CN,concatenateArrayBuffer:()=>PN,padLeft:()=>TN,pascalToSnake:()=>RN,removeHexPrefix:()=>NN,sanitizeBytes:()=>zN,sanitizeHex:()=>ON,stringToArrayBuffer:()=>AN,utf8ToArray:()=>EN});var MN="undefined"!=typeof window;function _N(t){return new Uint8Array(t).reduce(((t,e)=>t+String.fromCharCode(e)),"")}function EN(t){return(new TextEncoder).encode(t)}function AN(t){return EN(t)}function jN(t){return Dg.decode(t)}function xN(t){return Dg.encode(new Uint8Array(t))}function SN(t){return t.reduce(((t,e)=>t+e.toString(16).padStart(2,"0")),"")}function NN(t){return t.replace(/^0x/i,"")}function IN(t){return`0x${NN(t)}`}function TN(t,e,r="0"){return function(t,e,r,i="0"){const n=e-t.length;let o=t;if(n>0){const e=i.repeat(n);o=r?e+t:t+e}return o}(t,e,!0,r)}function CN(t,e=8){const{length:r}=t,i=r%e;return i?(r-i)/e*e+e:r}function zN(t,e=8,r="0"){return TN(t,CN(t,e),r)}function ON(t){const e=zN(NN(t),2);return e?IN(e):e}var RN=t=>/[a-z]/.test(t)?t.split(/(?=[A-Z])/).join("_").toUpperCase():t;function PN(t){const e=t.reduce(((t,e)=>t+e.byteLength),0),r=new Uint8Array(e);let i=0;return t.forEach((t=>{r.set(t,i),i+=t.byteLength})),r}var BN=31,DN=0n,$N=2n**250n-1n,LN=2n**31n-1n,FN=DN,UN=2n**251n+17n*2n**192n+1n,qN=256n,VN=2n**251n-qN,HN=(t,e)=>({min:t,max:e}),GN=HN(DN,UN-1n),ZN=HN(-(2n**127n),2n**127n-1n),KN=HN(DN,2n**128n-1n),JN=(t=>(t.SN_MAIN="https://alpha-mainnet.starknet.io",t.SN_SEPOLIA="https://alpha-sepolia.starknet.io",t))(JN||{}),WN=(t=>(t.SN_MAIN="SN_MAIN",t.SN_SEPOLIA="SN_SEPOLIA",t))(WN||{}),YN=(t=>(t.SN_MAIN="0x534e5f4d41494e",t.SN_SEPOLIA="0x534e5f5345504f4c4941",t))(YN||{}),QN=(t=>(t.DECLARE="0x6465636c617265",t.DEPLOY="0x6465706c6f79",t.DEPLOY_ACCOUNT="0x6465706c6f795f6163636f756e74",t.INVOKE="0x696e766f6b65",t.L1_HANDLER="0x6c315f68616e646c6572",t))(QN||{}),XN=(t=>(t[t.L1_BOUND_MAX_AMOUNT=50]="L1_BOUND_MAX_AMOUNT",t[t.L1_BOUND_MAX_PRICE_PER_UNIT=50]="L1_BOUND_MAX_PRICE_PER_UNIT",t[t.MAX_FEE=50]="MAX_FEE",t))(XN||{}),tI={ADDRESS:"0x041a78e741e5af2fec34b695679bc6891742439f7afb8484ecd7766661ad02bf",ENTRYPOINT:"deployContract"},eI="v0_7",rI={SN_MAIN:[`https://starknet-mainnet.public.blastapi.io/rpc/${eI}`,`https://free-rpc.nethermind.io/mainnet-juno/${eI}`],SN_SEPOLIA:[`https://starknet-sepolia.public.blastapi.io/rpc/${eI}`,`https://free-rpc.nethermind.io/sepolia-juno/${eI}`]},iI="0x414e595f43414c4c4552",nI="0x68cfd18b92d1907b8ba3cc324900277f5a3622099431ea85dd8089255e4181",oI="0x1d1144bb2138366ff28d8e9ab57456b1d332ac42196230c3a602003c89872",aI=128,sI=2147483648n,hI={legacyMode:!1,logLevel:"INFO",accountTxVersion:aN.ETransactionVersion.V2},uI={legacyTxWarningMessage:"You are using a deprecated transaction version (V0,V1,V2)!\nUpdate to the latest V3 transactions!"},lI={};nN(lI,{RpcChannel:()=>pO});nN({},{parse:()=>dI,parseAlwaysAsBig:()=>fI,stringify:()=>mI,stringifyAlwaysAsBig:()=>pI});var cI=t=>{if(!Hg(t))return parseFloat(t);const e=parseInt(t,10);return Number.isSafeInteger(e)?e:BigInt(t)},dI=t=>sy(String(t),void 0,cI),fI=t=>sy(String(t),void 0,ny),mI=(t,e,r,i)=>Ly(t,e,r,i),pI=mI,gI={FAILED_TO_RECEIVE_TXN:1,NO_TRACE_AVAILABLE:10,CONTRACT_NOT_FOUND:20,BLOCK_NOT_FOUND:24,INVALID_TXN_INDEX:27,CLASS_HASH_NOT_FOUND:28,TXN_HASH_NOT_FOUND:29,PAGE_SIZE_TOO_BIG:31,NO_BLOCKS:32,INVALID_CONTINUATION_TOKEN:33,TOO_MANY_KEYS_IN_FILTER:34,CONTRACT_ERROR:40,TRANSACTION_EXECUTION_ERROR:41,CLASS_ALREADY_DECLARED:51,INVALID_TRANSACTION_NONCE:52,INSUFFICIENT_MAX_FEE:53,INSUFFICIENT_ACCOUNT_BALANCE:54,VALIDATION_FAILURE:55,COMPILATION_FAILED:56,CONTRACT_CLASS_SIZE_IS_TOO_LARGE:57,NON_ACCOUNT:58,DUPLICATE_TX:59,COMPILED_CLASS_HASH_MISMATCH:60,UNSUPPORTED_TX_VERSION:61,UNSUPPORTED_CONTRACT_CLASS_VERSION:62,UNEXPECTED_ERROR:63};var yI=class extends Error{name;constructor(t){super(t),Object.defineProperty(this,"name",{value:new.target.name,enumerable:!1,configurable:!0}),function(t,e){const{setPrototypeOf:r}=Object;r?r(t,e):t.__proto__=e}(this,new.target.prototype),function(t,e=t.constructor){const{captureStackTrace:r}=Error;r&&r(t,e)}(this)}},wI=class extends yI{},vI=class extends wI{constructor(t,e,r){super(`RPC: ${e} with params ${mI(r,null,2)}\n\n ${t.code}: ${t.message}: ${mI(t.data)}`),this.baseError=t,this.request={method:e,params:r}}request;get code(){return this.baseError.code}isType(t){return gI[t]===this.code}};nN({},{BlockStatus:()=>AI,BlockTag:()=>jI,ETH_ADDRESS:()=>II,EntryPointType:()=>bI,Literal:()=>NI,NON_ZERO_PREFIX:()=>TI,OutsideExecutionTypesV1:()=>CI,OutsideExecutionTypesV2:()=>zI,OutsideExecutionVersion:()=>OI,RPC:()=>aN,TransactionExecutionStatus:()=>EI,TransactionFinalityStatus:()=>_I,TransactionStatus:()=>MI,TransactionType:()=>kI,TypedDataRevision:()=>pg,Uint:()=>SI,ValidateType:()=>xI});var bI={EXTERNAL:"EXTERNAL",L1_HANDLER:"L1_HANDLER",CONSTRUCTOR:"CONSTRUCTOR"},kI={DECLARE:"DECLARE",DEPLOY:"DEPLOY",DEPLOY_ACCOUNT:"DEPLOY_ACCOUNT",INVOKE:"INVOKE_FUNCTION"},MI={NOT_RECEIVED:"NOT_RECEIVED",RECEIVED:"RECEIVED",ACCEPTED_ON_L2:"ACCEPTED_ON_L2",ACCEPTED_ON_L1:"ACCEPTED_ON_L1",REJECTED:"REJECTED",REVERTED:"REVERTED"},_I={NOT_RECEIVED:"NOT_RECEIVED",RECEIVED:"RECEIVED",ACCEPTED_ON_L2:"ACCEPTED_ON_L2",ACCEPTED_ON_L1:"ACCEPTED_ON_L1"},EI={REJECTED:"REJECTED",REVERTED:"REVERTED",SUCCEEDED:"SUCCEEDED"},AI={PENDING:"PENDING",ACCEPTED_ON_L1:"ACCEPTED_ON_L1",ACCEPTED_ON_L2:"ACCEPTED_ON_L2",REJECTED:"REJECTED"},jI={PENDING:"pending",LATEST:"latest"},xI={DEPLOY:"DEPLOY",CALL:"CALL",INVOKE:"INVOKE"},SI={u8:"core::integer::u8",u16:"core::integer::u16",u32:"core::integer::u32",u64:"core::integer::u64",u128:"core::integer::u128",u256:"core::integer::u256",u512:"core::integer::u512"},NI={ClassHash:"core::starknet::class_hash::ClassHash",ContractAddress:"core::starknet::contract_address::ContractAddress",Secp256k1Point:"core::starknet::secp256k1::Secp256k1Point",U96:"core::internal::bounded_int::BoundedInt::<0, 79228162514264337593543950335>"},II="core::starknet::eth_address::EthAddress",TI="core::zeroable::NonZero::",CI={StarkNetDomain:[{name:"name",type:"felt"},{name:"version",type:"felt"},{name:"chainId",type:"felt"}],OutsideExecution:[{name:"caller",type:"felt"},{name:"nonce",type:"felt"},{name:"execute_after",type:"felt"},{name:"execute_before",type:"felt"},{name:"calls_len",type:"felt"},{name:"calls",type:"OutsideCall*"}],OutsideCall:[{name:"to",type:"felt"},{name:"selector",type:"felt"},{name:"calldata_len",type:"felt"},{name:"calldata",type:"felt*"}]},zI={StarknetDomain:[{name:"name",type:"shortstring"},{name:"version",type:"shortstring"},{name:"chainId",type:"shortstring"},{name:"revision",type:"shortstring"}],OutsideExecution:[{name:"Caller",type:"ContractAddress"},{name:"Nonce",type:"felt"},{name:"Execute After",type:"u128"},{name:"Execute Before",type:"u128"},{name:"Calls",type:"Call*"}],Call:[{name:"To",type:"ContractAddress"},{name:"Selector",type:"selector"},{name:"Calldata",type:"felt*"}]},OI=(t=>(t.UNSUPPORTED="0",t.V1="1",t.V2="2",t))(OI||{}),RI=class{nodeUrl;headers;interval;requestId=0;pendingRequests={};batchPromises={};delayTimer;delayPromise;delayPromiseResolve;baseFetch;constructor(t){this.nodeUrl=t.nodeUrl,this.headers=t.headers,this.interval=t.interval,this.baseFetch=t.baseFetch}async wait(){return this.delayPromise&&this.delayPromiseResolve||(this.delayPromise=new Promise((t=>{this.delayPromiseResolve=t}))),this.delayTimer&&(clearTimeout(this.delayTimer),this.delayTimer=void 0),this.delayTimer=setTimeout((()=>{this.delayPromiseResolve&&(this.delayPromiseResolve(),this.delayPromise=void 0,this.delayPromiseResolve=void 0)}),this.interval),this.delayPromise}addPendingRequest(t,e,r){const i={id:r??`batched_${this.requestId+=1}`,jsonrpc:"2.0",method:t,params:e??void 0};return this.pendingRequests[i.id]=i,i.id}async sendBatch(t){return(await this.baseFetch(this.nodeUrl,{method:"POST",body:mI(t),headers:this.headers})).json()}async fetch(t,e,r){const i=this.addPendingRequest(t,e,r);await this.wait();const n=this.pendingRequests;if(this.pendingRequests={},!this.batchPromises[i]){const t=this.sendBatch(Object.values(n));Object.keys(n).forEach((e=>{this.batchPromises[e]=t}))}const o=await this.batchPromises[i];delete this.batchPromises[i];const a=o.find((t=>t.id===i));if(!a)throw new Error(`Couldn't find the result for the request. Method: ${t}`);return a}};function PI(t,e){if(!t)throw new Error(e||"Assertion failure")}nN({},{addPercent:()=>aT,assertInRange:()=>YI,bigNumberishArrayToDecimalStringArray:()=>QI,bigNumberishArrayToHexadecimalStringArray:()=>XI,cleanHex:()=>WI,getDecimalString:()=>eT,getHexString:()=>rT,getHexStringArray:()=>iT,hexToBytes:()=>oT,hexToDecimalString:()=>JI,isBigNumberish:()=>hT,isHex:()=>qI,isStringWholeNumber:()=>tT,stringToSha256ToArrayBuff4:()=>sT,toBigInt:()=>VI,toCairoBool:()=>nT,toHex:()=>HI,toHex64:()=>KI,toHexString:()=>GI,toStorageKey:()=>ZI});var BI=t=>void 0===t||void 0===t;function DI(t){return"number"==typeof t}function $I(t){return"boolean"==typeof t}function LI(t){return"bigint"==typeof t}function FI(t){return"string"==typeof t}function UI(t){return!!t&&"object"==typeof t&&!Array.isArray(t)}function qI(t){return/^0x[0-9a-f]*$/i.test(t)}function VI(t){return BigInt(t)}function HI(t){return IN(VI(t).toString(16))}var GI=HI;function ZI(t){return IN(VI(t).toString(16).padStart(64,"0"))}function KI(t){const e=IN(VI(t).toString(16).padStart(64,"0"));if(66!==e.length)throw TypeError("number is too big for hex 0x(64) representation");return e}function JI(t){return BigInt(IN(t)).toString(10)}function WI(t){return t.toLowerCase().replace(/^(0x)0+/,"$1")}function YI(t,e,r,i=""){const n=""===i?"invalid length":`invalid ${i} length`,o=BigInt(t),a=BigInt(e),s=BigInt(r);PI(o>=a&&o<=s,`Message not signable, ${n}.`)}function QI(t){return t.map((t=>VI(t).toString(10)))}function XI(t){return t.map((t=>HI(t)))}function tT(t){return/^\d+$/.test(t)}function eT(t){if(qI(t))return JI(t);if(tT(t))return t;throw new Error(`${t} needs to be a hex-string or whole-number-string`)}function rT(t){if(qI(t))return t;if(tT(t))return GI(t);throw new Error(`${t} needs to be a hex-string or whole-number-string`)}function iT(t){return t.map(rT)}function nT(t){return(+t).toString()}function oT(t){if(!qI(t))throw new Error(`${t} needs to be a hex-string`);let e=NN(t);return e.length%2!=0&&(e=`0${e}`),nw(e)}function aT(t,e){const r=BigInt(t);return r+r*BigInt(e)/100n}function sT(t){var e;return oT(HI((e=BigInt(IN(SN(qw(t)))),Number(e&LN))))}function hT(t){return DI(t)||LI(t)||FI(t)&&(qI(t)||tT(t))}function uT(t){const e=NN(HI(BigInt(t))),r=e.length%2==0?e:`0${e}`;return IN(Yb(oT(IN(r))).toString(16))}function lT(t){const e=BigInt(function(t){return IN(Yb(EN(t)).toString(16))}(t));return e&$N}function cT(t){return HI(lT(t))}function dT(t){return DI(t)||LI(t)?HI(t):qI(t)?t:tT(t)?HI(t):cT(t)}function fT(t){const e=IN(t.reduce(((t,e)=>t+NN(HI(e)).padStart(64,"0")),""));return IN(Ky(Ak(oT(e))))}function mT(t,e,r,i,n){return fT([t,e,n,r,i.length,...i])}nN({},{getL2MessageHash:()=>mT,getSelector:()=>dT,getSelectorFromName:()=>cT,keccakBn:()=>uT,solidityUint256PackedKeccak256:()=>fT,starknetKeccak:()=>lT});function pT(t){return/^[\x00-\x7F]*$/.test(t)}function gT(t){return t.length<=BN}function yT(t){return/^[0-9]*$/i.test(t)}function wT(t){return FI(t)&&!qI(t)&&!tT(t)}nN({},{decodeShortString:()=>_T,encodeShortString:()=>MT,isASCII:()=>pT,isDecimalString:()=>yT,isLongText:()=>bT,isShortString:()=>gT,isShortText:()=>vT,isText:()=>wT,splitLongString:()=>kT});var vT=t=>wT(t)&&gT(t),bT=t=>wT(t)&&!gT(t);function kT(t){const e=RegExp(`[^]{1,${BN}}`,"g");return t.match(e)||[]}function MT(t){if(!pT(t))throw new Error(`${t} is not an ASCII string`);if(!gT(t))throw new Error(`${t} is too long`);return IN(t.replace(/./g,(t=>t.charCodeAt(0).toString(16))))}function _T(t){if(!pT(t))throw new Error(`${t} is not an ASCII string`);if(qI(t))return NN(t).replace(/.{2}/g,(t=>String.fromCharCode(parseInt(t,16))));if(yT(t))return _T("0X".concat(BigInt(t).toString(16)));throw new Error(`${t} is not Hex or decimal`)}function ET(t){const e=0n===BigInt(t.pending_word)?"":_T(HI(t.pending_word));return t.data.reduce(((t,e)=>t+(0n===BigInt(e)?"":_T(HI(e)))),"")+e}function AT(t){const e=kT(t),r=e[e.length-1],i=e.map(MT),[n,o]=void 0===r||31===r.length?["0x00",0]:[i.pop(),r.length];return{data:0===i.length?[]:i,pending_word:n,pending_word_len:o}}nN({},{byteArrayFromString:()=>AT,stringFromByteArray:()=>ET});var jT={};function xT(t){if(LI(t)||Number.isInteger(t))return t.toString();if(FI(t)){if(qI(t))return BigInt(t).toString();if(wT(t)){if(!gT(t))throw new Error(`${t} is a long string > 31 chars. Please split it into an array of short strings.`);return BigInt(MT(t)).toString()}if(tT(t))return t}if($I(t))return""+ +t;throw new Error(`${t} can't be computed by felt()`)}nN(jT,{felt:()=>fC,getAbiContractVersion:()=>uC,getArrayType:()=>aC,isCairo1Abi:()=>sC,isCairo1Type:()=>oC,isLen:()=>LT,isTypeArray:()=>UT,isTypeBool:()=>QT,isTypeByteArray:()=>rC,isTypeBytes31:()=>eC,isTypeContractAddress:()=>XT,isTypeEnum:()=>GT,isTypeEthAddress:()=>tC,isTypeFelt:()=>FT,isTypeLiteral:()=>YT,isTypeNamedTuple:()=>VT,isTypeNonZero:()=>hC,isTypeOption:()=>ZT,isTypeResult:()=>KT,isTypeSecp256k1Point:()=>nC,isTypeStruct:()=>HT,isTypeTuple:()=>qT,isTypeU96:()=>iC,isTypeUint:()=>JT,isTypeUint256:()=>WT,tuple:()=>dC,uint256:()=>lC,uint512:()=>cC});var ST=(1n<<128n)-1n,NT=(1n<<256n)-1n,IT=0n,TT=340282366920938463463374607431768211455n,CT=340282366920938463463374607431768211455n,zT=0n,OT=0n,RT=class t{low;high;static abiSelector="core::integer::u256";constructor(...e){if("object"==typeof e[0]&&1===e.length&&"low"in e[0]&&"high"in e[0]){const r=t.validateProps(e[0].low,e[0].high);this.low=r.low,this.high=r.high}else if(1===e.length){const r=t.validate(e[0]);this.low=r&ST,this.high=r>>128n}else{if(2!==e.length)throw Error("Incorrect constructor parameters");{const r=t.validateProps(e[0],e[1]);this.low=r.low,this.high=r.high}}}static validate(t){const e=BigInt(t);if(e<IT)throw Error("bigNumberish is smaller than UINT_256_MIN");if(e>NT)throw new Error("bigNumberish is bigger than UINT_256_MAX");return e}static validateProps(t,e){const r=BigInt(t),i=BigInt(e);if(r<zT||r>TT)throw new Error("low is out of range UINT_256_LOW_MIN - UINT_256_LOW_MAX");if(i<OT||i>CT)throw new Error("high is out of range UINT_256_HIGH_MIN - UINT_256_HIGH_MAX");return{low:r,high:i}}static is(e){try{t.validate(e)}catch(t){return!1}return!0}static isAbiType(e){return e===t.abiSelector}toBigInt(){return(this.high<<128n)+this.low}toUint256HexString(){return{low:IN(this.low.toString(16)),high:IN(this.high.toString(16))}}toUint256DecimalString(){return{low:this.low.toString(10),high:this.high.toString(10)}}toApiRequest(){return[xT(this.low),xT(this.high)]}},PT=(1n<<512n)-1n,BT=0n,DT=0n,$T=class t{limb0;limb1;limb2;limb3;static abiSelector="core::integer::u512";constructor(...e){if("object"==typeof e[0]&&1===e.length&&"limb0"in e[0]&&"limb1"in e[0]&&"limb2"in e[0]&&"limb3"in e[0]){const r=t.validateProps(e[0].limb0,e[0].limb1,e[0].limb2,e[0].limb3);this.limb0=r.limb0,this.limb1=r.limb1,this.limb2=r.limb2,this.limb3=r.limb3}else if(1===e.length){const r=t.validate(e[0]);this.limb0=r&ST,this.limb1=(r&ST<<128n)>>128n,this.limb2=(r&ST<<256n)>>256n,this.limb3=r>>384n}else{if(4!==e.length)throw Error("Incorrect Uint512 constructor parameters");{const r=t.validateProps(e[0],e[1],e[2],e[3]);this.limb0=r.limb0,this.limb1=r.limb1,this.limb2=r.limb2,this.limb3=r.limb3}}}static validate(t){const e=BigInt(t);if(e<BT)throw Error("bigNumberish is smaller than UINT_512_MIN.");if(e>PT)throw Error("bigNumberish is bigger than UINT_512_MAX.");return e}static validateProps(t,e,r,i){const n=BigInt(t),o=BigInt(e),a=BigInt(r),s=BigInt(i);return[n,o,a,s].forEach(((t,e)=>{if(t<DT||t>ST)throw Error(`limb${e} is not in the range of a u128 number`)})),{limb0:n,limb1:o,limb2:a,limb3:s}}static is(e){try{t.validate(e)}catch(t){return!1}return!0}static isAbiType(e){return e===t.abiSelector}toBigInt(){return(this.limb3<<384n)+(this.limb2<<256n)+(this.limb1<<128n)+this.limb0}toUint512HexString(){return{limb0:IN(this.limb0.toString(16)),limb1:IN(this.limb1.toString(16)),limb2:IN(this.limb2.toString(16)),limb3:IN(this.limb3.toString(16))}}toUint512DecimalString(){return{limb0:this.limb0.toString(10),limb1:this.limb1.toString(10),limb2:this.limb2.toString(10),limb3:this.limb3.toString(10)}}toApiRequest(){return[xT(this.limb0),xT(this.limb1),xT(this.limb2),xT(this.limb3)]}},LT=t=>/_len$/.test(t),FT=t=>"felt"===t||"core::felt252"===t,UT=t=>/\*/.test(t)||t.startsWith("core::array::Array::")||t.startsWith("core::array::Span::"),qT=t=>/^\(.*\)$/i.test(t),VT=t=>/\(.*\)/i.test(t)&&t.includes(":"),HT=(t,e)=>t in e,GT=(t,e)=>t in e,ZT=t=>t.startsWith("core::option::Option::"),KT=t=>t.startsWith("core::result::Result::"),JT=t=>Object.values(SI).includes(t),WT=t=>RT.isAbiType(t),YT=t=>Object.values(NI).includes(t),QT=t=>"core::bool"===t,XT=t=>t===NI.ContractAddress,tC=t=>t===II,eC=t=>"core::bytes_31::bytes31"===t,rC=t=>"core::byte_array::ByteArray"===t,iC=t=>"core::internal::bounded_int::BoundedInt::<0, 79228162514264337593543950335>"===t,nC=t=>t===NI.Secp256k1Point,oC=t=>t.includes("::"),aC=t=>oC(t)?t.substring(t.indexOf("<")+1,t.lastIndexOf(">")):t.replace("*","");function sC(t){const{cairo:e}=uC(t);if(void 0===e)throw Error("Unable to determine Cairo version");return"1"===e}function hC(t){return t.startsWith(TI)}function uC(t){if(t.find((t=>"interface"===t.type)))return{cairo:"1",compiler:"2"};const e=t.find((t=>("function"===t.type||"constructor"===t.type)&&(t.inputs.length||t.outputs.length)));if(!e)return{cairo:void 0,compiler:void 0};const r=e.inputs.length?e.inputs:e.outputs;return oC(r[0].type)?{cairo:"1",compiler:"1"}:{cairo:"0",compiler:"0"}}var lC=t=>new RT(t).toUint256DecimalString(),cC=t=>new $T(t).toUint512DecimalString(),dC=(...t)=>({...t});function fC(t){return xT(t)}var mC=class{variant;constructor(t){const e=Object.values(t);if(0===e.length)throw new Error("This Enum must have at least 1 variant");if(1!==e.filter((t=>!BI(t))).length)throw new Error("This Enum must have exactly one active variant");this.variant=t}unwrap(){return Object.values(this.variant).find((t=>!BI(t)))}activeVariant(){const t=Object.entries(this.variant).find((t=>!BI(t[1])));return BI(t)?"":t[0]}},pC={Some:0,None:1},gC=class{Some;None;constructor(t,e){if(!(t in Object.values(pC)))throw new Error("Wrong variant! It should be CairoOptionVariant.Some or .None.");if(t===pC.Some){if(BI(e))throw new Error('The creation of a Cairo Option with "Some" variant needs a content as input.');this.Some=e,this.None=void 0}else this.Some=void 0,this.None=!0}unwrap(){return this.None?void 0:this.Some}isSome(){return!BI(this.Some)}isNone(){return!0===this.None}},yC={Ok:0,Err:1},wC=class{Ok;Err;constructor(t,e){if(!(t in Object.values(yC)))throw new Error("Wrong variant! It should be CairoResultVariant.Ok or .Err.");t===yC.Ok?(this.Ok=e,this.Err=void 0):(this.Ok=void 0,this.Err=e)}unwrap(){if(!BI(this.Ok))return this.Ok;if(!BI(this.Err))return this.Err;throw new Error("Both Result.Ok and .Err are undefined. Not authorized.")}isOk(){return!BI(this.Ok)}isErr(){return!BI(this.Err)}},vC=(t,e,r)=>{if(!LI(t[r]))throw new Error(`Data and formatter mismatch on ${r}:${e[r]}, expected response data ${r}:${t[r]} to be BN instead it is ${typeof t[r]}`)},bC=(t,e,r)=>{throw new Error(`Unhandled formatter type on ${r}:${e[r]} for data ${r}:${t[r]}`)};function kC(t,e,r){return Object.entries(t).reduce(((i,[n,o])=>{const a=r??e[n];if(!(n in e)&&!r)return i[n]=o,i;if("string"===a){if(Array.isArray(t[n])){const e=kC(t[n],t[n].map((t=>a)));return i[n]=Object.values(e).join(""),i}return vC(t,e,n),i[n]=_T(o),i}if("number"===a)return vC(t,e,n),i[n]=Number(o),i;if("function"==typeof a)return i[n]=a(o),i;if(Array.isArray(a)){const e=kC(t[n],a,a[0]);return i[n]=Object.values(e),i}return UI(a)?(i[n]=kC(t[n],a),i):(bC(t,e,n),i)}),{})}function MC(t){const e=function(t){return t.find((t=>"interface"===t.type))?2:sC(t)?1:0}(t);if(0===e||1===e)return new class{abi;constructor(t){this.abi=t}methodInputsLength(t){return t.inputs.reduce(((t,e)=>LT(e.name)?t:t+1),0)}getMethod(t){return this.abi.find((e=>e.name===t))}getLegacyFormat(){return this.abi}}(t);if(2===e)return new class{abi;constructor(t){this.abi=t}methodInputsLength(t){return t.inputs.length}getMethod(t){return this.abi.find((t=>"interface"===t.type))?.items?.find((e=>e.name===t))}getLegacyFormat(){return this.abi.flatMap((t=>"interface"===t.type?t.items:t))}}(t);throw Error(`Unsupported ABI version ${e}`)}function _C(t,e,r){return"constructor"===t&&!r&&!e.length}function EC(t,e,r){for(let i=0,n=0;i<t.length;i++)if(t[i]===e)n++;else if(t[i]===r&&0==--n)return i;return Number.POSITIVE_INFINITY}function AC(t){return oC(t)?function(t){const e=t.slice(1,-1),r=[];let i,n=0;for(;n<e.length;){switch(!0){case"("===e[n]:i=n+EC(e.slice(n),"(",")")+1;break;case e.startsWith("core::result::Result::<",n)||e.startsWith("core::array::Array::<",n)||e.startsWith("core::option::Option::<",n):i=n+EC(e.slice(n),"<",">")+1;break;default:{const t=e.indexOf(",",n);i=-1!==t?t:Number.POSITIVE_INFINITY}}r.push(e.slice(n,i)),n=i+2}return r}(t):function(t){const e=t.replace(/\s/g,"").slice(1,-1),{subTuple:r,result:i}=function(t){if(!t.includes("("))return{subTuple:[],result:t};const e=[];let r="",i=0;for(;i<t.length;){if("("===t[i]){let n=1;const o=i;for(i++;n;)")"===t[i]&&n--,"("===t[i]&&n++,i++;e.push(t.substring(o,i)),r+=" ",i--}else r+=t[i];i++}return{subTuple:e,result:r}}(e);let n=i.split(",").map((t=>r.length?t.replace(" ",r.shift()):t));return VT(t)&&(n=n.reduce(((t,e)=>t.concat(function(t){const e=t.substring(0,t.indexOf(":"));return{name:e,type:t.substring(e.length+":".length)}}(e))),[])),n}(t)}var jC=class t{content;arrayType;constructor(e,r){PI(t.isTypeFixedArray(r),`The type ${r} is not a Cairo fixed array. Needs [type; length].`);try{t.getFixedArrayType(r)}catch{throw new Error(`The type ${r} do not includes any content type. Needs [type; length].`)}try{t.getFixedArraySize(r)}catch{throw new Error(`The type ${r} type do not includes any length. Needs [type; length].`)}PI(t.getFixedArraySize(r)===e.length,`The ABI type ${r} is expecting ${t.getFixedArraySize(r)} items. ${e.length} items provided.`),this.content=e,this.arrayType=r}static getFixedArraySize(t){const e=t.match(/(?<=; )\d+(?=\])/);if(null===e)throw new Error(`ABI type ${t} do not includes a valid number after ';' character.`);return Number(e[0])}getFixedArraySize(){return t.getFixedArraySize(this.arrayType)}static getFixedArrayType=t=>{const e=t.match(/(?<=\[).+(?=;)/);if(null===e)throw new Error(`ABI type ${t} do not includes a valid type of data.`);return e[0]};getFixedArrayType(){return t.getFixedArrayType(this.arrayType)}static compile(t){return t.reduce(((t,e,r)=>(t[r]=e,t)),{})}compile(){return t.compile(this.content)}static isTypeFixedArray(t){return/^\[.*;\s.*\]$/.test(t)&&/(?<=\[).+(?=;)/.test(t)&&/(?<=; )\d+(?=\])/.test(t)}};function xC(t,e,r,i){const n=(t,e)=>{if(jC.isTypeFixedArray(e))return function(t,e){const r=jC.getFixedArrayType(e),i=jC.getFixedArraySize(e);if(Array.isArray(t)){if(i!==t.length)throw new Error(`ABI type ${e}: array provided do not includes ${i} items. ${t.length} items provided.`);return t.map((t=>n(t,r)))}if(i!==Object.keys(t).length)throw new Error(`ABI type ${e}: object provided do not includes ${i} properties. ${Object.keys(t).length} items provided.`);return n(t,r)}(t,e);if(UT(e))return function(t,e){const r=aC(e);if(FI(t))return t;return t.map((t=>n(t,r)))}(t,e);if(GT(e,i)){const r=i[e];return a(t,r)}if(qT(e))return function(t,e){const r=AC(e).reduce(((e,r,i)=>{const o=Object.keys(t),a=r=>Object.defineProperty(e,i.toString(),{enumerable:!0,value:r??t[o[i]]}),s=r?.type?r.type:r;return a(n(t[o[i]],s)),e}),{});return r}(t,e);if(tC(e))return t;if(hC(e))return t;if(rC(e))return t;if(iC(e))return t;if(nC(e))return t;if(RT.isAbiType(e)){const r=t;if("object"!=typeof r)return r;if(!("low"in r)||!("high"in r))throw function(t){return Error(`Your object includes the property : ${t}, containing an Uint256 object without the 'low' and 'high' keys.`)}(e);return{low:r.low,high:r.high}}if($T.isAbiType(e)){const r=t;if("object"!=typeof r)return r;if(!["limb0","limb1","limb2","limb3"].every((t=>t in r)))throw function(t){return Error(`Your object includes the property : ${t}, containing an Uint512 object without the 'limb0' to 'limb3' keys.`)}(e);return{limb0:r.limb0,limb1:r.limb1,limb2:r.limb2,limb3:r.limb3}}if(HT(e,r)){const i=r[e].members;return o(t,i)}return t},o=(t,e)=>e.reduce(((e,r)=>{if("undefined"===t[r.name]&&(oC(r.type)||!LT(r.name)))throw Error(`Your object needs a property with key : ${r.name} .`);var i;return i=n(t[r.name],r.type),Object.defineProperty(e,r.name,{enumerable:!0,value:i??t[r.name]}),e}),{});const a=(t,e)=>{if(KT(e.name)){const r=t,i=e.name.substring(e.name.indexOf("<")+1,e.name.lastIndexOf(",")),o=e.name.substring(e.name.indexOf(",")+1,e.name.lastIndexOf(">"));return r.isOk()?new wC(yC.Ok,n(t.unwrap(),i)):new wC(yC.Err,n(t.unwrap(),o))}if(ZT(e.name)){const r=t,i=e.name.substring(e.name.indexOf("<")+1,e.name.lastIndexOf(">"));return r.isSome()?new gC(pC.Some,n(r.unwrap(),i)):new gC(pC.None,{})}const r=t,i=Object.entries(r.variant).map((t=>{if(BI(t[1]))return t;const i=e.type.substring(e.type.lastIndexOf("<")+1,e.type.lastIndexOf(">"));return"()"===i?t:[t[0],n(r.unwrap(),i)]}));return new mC(Object.fromEntries(i))};return e.reduce(((e,r)=>{return LT(r.name)&&!oC(r.type)||(i=n(t[r.name],r.type),Object.defineProperty(e,r.name,{enumerable:!0,value:i})),e;var i}),{})}function SC(t,e){switch(!0){case RT.isAbiType(t):return new RT(e).toApiRequest();case $T.isAbiType(t):return new $T(e).toApiRequest();case eC(t):return MT(e.toString());case nC(t):{const t=NN(HI(e)).padStart(128,"0"),r=lC(IN(t.slice(-64))),i=lC(IN(t.slice(0,-64)));return[fC(i.low),fC(i.high),fC(r.low),fC(r.high)]}default:return fC(e)}}function NC(t,e,r,i){if(void 0===t)throw Error(`Missing parameter for type ${e}`);if(jC.isTypeFixedArray(e)){const n=jC.getFixedArrayType(e);let o=[];if(Array.isArray(t)){o=new jC(t,e).content}else{if("object"!=typeof t)throw new Error(`ABI type ${e}: not an Array representing a cairo.fixedArray() provided.`);o=Object.values(t),PI(o.length===jC.getFixedArraySize(e),`ABI type ${e}: object provided do not includes ${jC.getFixedArraySize(e)} items. ${o.length} items provided.`)}return o.reduce(((t,e)=>t.concat(NC(e,n,r,i))),[])}if(Array.isArray(t)){const n=[];n.push(fC(t.length));const o=aC(e);return t.reduce(((t,e)=>t.concat(NC(e,o,r,i))),n)}if(r[e]&&r[e].members.length){if(RT.isAbiType(e))return new RT(t).toApiRequest();if($T.isAbiType(e))return new $T(t).toApiRequest();if(tC(e))return SC(e,t);if(rC(e))return function(t){const e=AT(t);return[e.data.length.toString(),...e.data.map((t=>t.toString())),e.pending_word.toString(),e.pending_word_len.toString()]}(t);const{members:n}=r[e],o=t;return n.reduce(((t,e)=>t.concat(NC(o[e.name],e.type,r,i))),[])}if(qT(e)){const n=function(t,e){const r=AC(e),i=Object.values(t);if(i.length!==r.length)throw Error(`ParseTuple: provided and expected abi tuple size do not match.\n provided: ${i}\n expected: ${r}`);return r.map(((t,e)=>({element:i[e],type:t.type??t})))}(t,e);return n.reduce(((t,e)=>{const n=NC(e.element,e.type,r,i);return t.concat(n)}),[])}if(RT.isAbiType(e))return new RT(t).toApiRequest();if($T.isAbiType(e))return new $T(t).toApiRequest();if(GT(e,i)){const{variants:n}=i[e];if(ZT(e)){const e=t;if(e.isSome()){const t=n.find((t=>"Some"===t.name));if(BI(t))throw Error("Error in abi : Option has no 'Some' variant.");const o=t.type;if("()"===o)return pC.Some.toString();const a=NC(e.unwrap(),o,r,i);return Array.isArray(a)?[pC.Some.toString(),...a]:[pC.Some.toString(),a]}return pC.None.toString()}if(KT(e)){const e=t;if(e.isOk()){const t=n.find((t=>"Ok"===t.name));if(BI(t))throw Error("Error in abi : Result has no 'Ok' variant.");const o=t.type;if("()"===o)return yC.Ok.toString();const a=NC(e.unwrap(),o,r,i);return Array.isArray(a)?[yC.Ok.toString(),...a]:[yC.Ok.toString(),a]}const o=n.find((t=>"Err"===t.name));if(BI(o))throw Error("Error in abi : Result has no 'Err' variant.");const a=o.type;if("()"===a)return yC.Err.toString();const s=NC(e.unwrap(),a,r,i);return Array.isArray(s)?[yC.Err.toString(),...s]:[yC.Err.toString(),s]}const o=t,a=o.activeVariant(),s=n.find((t=>t.name===a));if(BI(s))throw Error(`Not find in abi : Enum has no '${a}' variant.`);const h=s.type,u=n.findIndex((t=>t.name===a));if("()"===h)return u.toString();const l=NC(o.unwrap(),h,r,i);return Array.isArray(l)?[u.toString(),...l]:[u.toString(),l]}if(hC(e))return SC(aC(e),t);if("object"==typeof t)throw Error(`Parameter ${t} do not align with abi parameter ${e}`);return SC(e,t)}function IC(t,e){let r;switch(!0){case QT(t):return r=e.next().value,Boolean(BigInt(r));case RT.isAbiType(t):const i=e.next().value,n=e.next().value;return new RT(i,n).toBigInt();case $T.isAbiType(t):const o=e.next().value,a=e.next().value,s=e.next().value,h=e.next().value;return new $T(o,a,s,h).toBigInt();case tC(t):return r=e.next().value,BigInt(r);case eC(t):return r=e.next().value,_T(r);case nC(t):const u=NN(e.next().value).padStart(32,"0"),l=NN(e.next().value).padStart(32,"0"),c=NN(e.next().value).padStart(32,"0"),d=NN(e.next().value).padStart(32,"0");return BigInt(IN(l+u+d+c));default:return r=e.next().value,BigInt(r)}}function TC(t,e,r,i){if("()"===e.type)return{};if(RT.isAbiType(e.type)){const e=t.next().value,r=t.next().value;return new RT(e,r).toBigInt()}if($T.isAbiType(e.type)){const e=t.next().value,r=t.next().value,i=t.next().value,n=t.next().value;return new $T(e,r,i,n).toBigInt()}if(rC(e.type)){const e=[],r=BigInt(t.next().value);for(;e.length<r;)e.push(HI(t.next().value));return ET({data:e,pending_word:HI(t.next().value),pending_word_len:BigInt(t.next().value)})}if(jC.isTypeFixedArray(e.type)){const n=[],o={name:"",type:jC.getFixedArrayType(e.type)},a=jC.getFixedArraySize(e.type);for(;n.length<a;)n.push(TC(t,o,r,i));return n}if(UT(e.type)){const n=[],o={name:"",type:aC(e.type)},a=BigInt(t.next().value);for(;n.length<a;)n.push(TC(t,o,r,i));return n}if(hC(e.type)){const n={name:"",type:aC(e.type)};return TC(t,n,r,i)}if(r&&e.type in r&&r[e.type])return tC(e.type)?IC(e.type,t):r[e.type].members.reduce(((e,n)=>(e[n.name]=TC(t,n,r,i),e)),{});if(i&&e.type in i&&i[e.type]){const n=Number(t.next().value),o=i[e.type].variants.reduce(((e,o,a)=>a===n?(e[o.name]=TC(t,{name:"",type:o.type},r,i),e):(e[o.name]=void 0,e)),{});if(e.type.startsWith("core::option::Option")){const t=n===pC.Some?o.Some:void 0;return new gC(n,t)}if(e.type.startsWith("core::result::Result")){let t;return t=n===yC.Ok?o.Ok:o.Err,new wC(n,t)}return new mC(o)}if(qT(e.type)){return AC(e.type).reduce(((e,n,o)=>{const a=n?.name?n.name:o,s={name:a,type:n?.type?n.type:n};return e[a]=TC(t,s,r,i),e}),{})}if(UT(e.type)){const n=[],o={name:"",type:aC(e.type)},a=BigInt(t.next().value);for(;n.length<a;)n.push(TC(t,o,r,i));return n}return IC(e.type,t)}function CC(t,e,r,i,n){const{name:o,type:a}=e;let s;switch(!0){case LT(o):return s=t.next().value,BigInt(s);case r&&a in r||qT(a):case i&&GT(a,i):case jC.isTypeFixedArray(a):return TC(t,e,r,i);case UT(a):if(oC(a))return TC(t,e,r,i);const h=[];if(n&&n[`${o}_len`]){const a=n[`${o}_len`];for(;h.length<a;)h.push(TC(t,{name:o,type:e.type.replace("*","")},r,i))}return h;case hC(a):return TC(t,e,r,i);default:return IC(a,t)}}var zC=(t,e)=>{if(PI(FI(t)||DI(t)||LI(t),`Validate: arg ${e.name} should be a felt typed as (String, Number or BigInt)`),FI(t)&&!qI(t))return;const r=BigInt(t.toString(10));PI(r>=0n&&r<=2n**252n-1n,`Validate: arg ${e.name} cairo typed ${e.type} should be in range [0, 2^252-1]`)},OC=(t,e)=>{let r;switch(DI(t)&&PI(t<=Number.MAX_SAFE_INTEGER,"Validation: Parameter is too large to be typed as Number use (BigInt or String)"),PI(FI(t)||DI(t)||LI(t)||UI(t)&&"low"in t&&"high"in t||UI(t)&&["limb0","limb1","limb2","limb3"].every((e=>e in t)),`Validate: arg ${e.name} of cairo type ${e.type} should be type (String, Number or BigInt), but is ${typeof t} ${t}.`),e.type){case SI.u256:r=new RT(t).toBigInt();break;case SI.u512:r=new $T(t).toBigInt();break;default:r=VI(t)}switch(e.type){case SI.u8:PI(r>=0n&&r<=255n,`Validate: arg ${e.name} cairo typed ${e.type} should be in range [0 - 255]`);break;case SI.u16:PI(r>=0n&&r<=65535n,`Validate: arg ${e.name} cairo typed ${e.type} should be in range [0, 65535]`);break;case SI.u32:PI(r>=0n&&r<=4294967295n,`Validate: arg ${e.name} cairo typed ${e.type} should be in range [0, 4294967295]`);break;case SI.u64:PI(r>=0n&&r<=2n**64n-1n,`Validate: arg ${e.name} cairo typed ${e.type} should be in range [0, 2^64-1]`);break;case SI.u128:PI(r>=0n&&r<=2n**128n-1n,`Validate: arg ${e.name} cairo typed ${e.type} should be in range [0, 2^128-1]`);break;case SI.u256:PI(r>=0n&&r<=2n**256n-1n,`Validate: arg ${e.name} is ${e.type} should be in range 0 - 2^256-1`);break;case SI.u512:PI($T.is(r),`Validate: arg ${e.name} is ${e.type} should be in range 0 - 2^512-1`);break;case NI.ClassHash:case NI.ContractAddress:PI(r>=0n&&r<=2n**252n-1n,`Validate: arg ${e.name} cairo typed ${e.type} should be in range [0, 2^252-1]`);break;case NI.Secp256k1Point:PI(r>=0n&&r<=2n**512n-1n,`Validate: arg ${e.name} must be ${e.type} : a 512 bits number.`);break;case NI.U96:PI(r>=0n&&r<=2n**96n-1n,`Validate: arg ${e.name} must be ${e.type} : a 96 bits number.`)}},RC=(t,e)=>{PI($I(t),`Validate: arg ${e.name} of cairo type ${e.type} should be type (Boolean)`)},PC=(t,e,r)=>{if(e.type!==SI.u256&&e.type!==SI.u512)if(tC(e.type)){PI(!UI(t),`EthAddress type is waiting a BigNumberish. Got "${t}"`);const r=BigInt(t.toString(10));PI(r>=0n&&r<=2n**160n-1n,`Validate: arg ${e.name} cairo typed ${e.type} should be in range [0, 2^160-1]`)}else PI(UI(t),`Validate: arg ${e.name} is cairo type struct (${e.type}), and should be defined as a js object (not array)`),r[e.type].members.forEach((({name:r})=>{PI(Object.keys(t).includes(r),`Validate: arg ${e.name} should have a property ${r}`)}));else OC(t,e)},BC=(t,e)=>{PI(UI(t),`Validate: arg ${e.name} is cairo type Enum (${e.type}), and should be defined as a js object (not array)`);const r=Object.getOwnPropertyNames(Object.getPrototypeOf(t)),i=[...Object.getOwnPropertyNames(t),...r];if(!(ZT(e.type)&&i.includes("isSome")&&i.includes("isNone")||KT(e.type)&&i.includes("isOk")&&i.includes("isErr")||i.includes("variant")&&i.includes("activeVariant")))throw new Error(`Validate Enum: argument ${e.name}, type ${e.type}, value received "${t}", is not an Enum.`)},DC=(t,e)=>{PI(UI(t),`Validate: arg ${e.name} should be a tuple (defined as object)`)},$C=(t,e,r,i)=>{const n=UT(e.type),o=n?aC(e.type):jC.getFixedArrayType(e.type);if(n&&FT(o)&&bT(t))return;let a=[];if(n)PI(Array.isArray(t),`Validate: arg ${e.name} should be an Array`),a=t;else switch(!0){case Array.isArray(t):a=t;break;case"object"==typeof t:a=Object.values(t);break;default:throw new Error(`Validate: arg ${e.name} should be an Array or an object.`)}switch(!0){case FT(o):a.forEach((t=>zC(t,e)));break;case qT(o):a.forEach((t=>DC(t,{name:e.name,type:o})));break;case UT(o):a.forEach((t=>$C(t,{name:"",type:o},r,i)));break;case HT(o,r):a.forEach((t=>PC(t,{name:e.name,type:o},r)));break;case GT(o,i):a.forEach((t=>BC(t,{name:e.name,type:o})));break;case JT(o)||YT(o):a.forEach((t=>OC(t,{name:"",type:o})));break;case QT(o):a.forEach((t=>RC(t,e)));break;default:throw new Error(`Validate Unhandled: argument ${e.name}, type ${e.type}, value ${a}`)}};function LC(t,e,r,i){t.inputs.reduce(((t,n)=>{const o=e[t];switch(!0){case LT(n.name):return t;case FT(n.type):zC(o,n);break;case eC(n.type):((t,e)=>{PI(FI(t),`Validate: arg ${e.name} should be a string.`),PI(t.length<32,`Validate: arg ${e.name} cairo typed ${e.type} should be a string of less than 32 characters.`)})(o,n);break;case JT(n.type)||YT(n.type):OC(o,n);break;case QT(n.type):RC(o,n);break;case rC(n.type):((t,e)=>{PI(FI(t),`Validate: arg ${e.name} should be a string.`)})(o,n);break;case UT(n.type)||jC.isTypeFixedArray(n.type):$C(o,n,r,i);break;case HT(n.type,r):PC(o,n,r);break;case GT(n.type,i):BC(o,n);break;case qT(n.type):DC(o,n);break;case hC(n.type):((t,e)=>{const r=aC(e.type);switch(PI(JT(r)&&r!==$T.abiSelector||FT(r),`Validate: ${e.name} type is not authorized for NonZero type.`),!0){case FT(r):zC(t,e),PI(BigInt(t.toString(10))>0,"Validate: value 0 is not authorized in NonZero felt252 type.");break;case JT(r):OC(t,{name:"",type:r}),r===SI.u256?PI(new RT(t).toBigInt()>0,"Validate: value 0 is not authorized in NonZero uint256 type."):PI(VI(t)>0,"Validate: value 0 is not authorized in NonZero uint type.");break;default:throw new Error(`Validate Unhandled: argument ${e.name}, type ${e.type}, value "${t}"`)}})(o,n);break;default:throw new Error(`Validate Unhandled: argument ${n.name}, type ${n.type}, value ${o}`)}return t+1}),0)}var FC=class t{abi;parser;structs;enums;constructor(e){this.structs=t.getAbiStruct(e),this.enums=t.getAbiEnum(e),this.parser=MC(e),this.abi=this.parser.getLegacyFormat()}validate(t,e,r=[]){if(t!==xI.DEPLOY){PI(this.abi.filter((e=>{if("function"!==e.type)return!1;const r="view"===e.stateMutability||"view"===e.state_mutability;return t===xI.INVOKE?!r:r})).map((t=>t.name)).includes(e),(t===xI.INVOKE?"invocable":"viewable")+" method not found in abi")}const i=this.abi.find((r=>t===xI.DEPLOY?r.name===e&&"constructor"===r.type:r.name===e&&"function"===r.type));if(_C(e,r,i))return;const n=this.parser.methodInputsLength(i);if(r.length!==n)throw Error(`Invalid number of arguments, expected ${n} arguments, but got ${r.length}`);LC(i,r,this.structs,this.enums)}compile(t,e){const r=this.abi.find((e=>e.name===t));if(_C(t,e,r))return[];let i;if(Array.isArray(e))i=e;else{const t=xC(e,r.inputs,this.structs,this.enums);i=Object.values(t),LC(r,i,this.structs,this.enums)}const n=i[Symbol.iterator](),o=r.inputs.reduce(((t,e)=>LT(e.name)&&!oC(e.type)?t:t.concat(function(t,e,r,i){const{name:n,type:o}=e;let{value:a}=t.next();switch(!0){case jC.isTypeFixedArray(o):if(!Array.isArray(a)&&"object"!=typeof a)throw Error(`ABI expected parameter ${n} to be an array or an object, got ${a}`);return NC(a,e.type,r,i);case UT(o):if(!Array.isArray(a)&&!wT(a))throw Error(`ABI expected parameter ${n} to be array or long string, got ${a}`);return FI(a)&&(a=kT(a)),NC(a,e.type,r,i);case hC(o):return SC(aC(o),a);case tC(o):return SC(o,a);case HT(o,r)||qT(o)||RT.isAbiType(o):case GT(o,i):return NC(a,o,r,i);default:return SC(o,a)}}(n,e,this.structs,this.enums))),[]);return Object.defineProperty(o,"__compiled__",{enumerable:!1,writable:!1,value:!0}),o}static compile(t){const e=t=>{const e=(t,r=".")=>{const i=Array.isArray(t)?[t.length.toString(),...t]:t;return Object.entries(i).flatMap((([t,n])=>{let o=n;"entrypoint"===t?o=cT(o):bT(o)&&(o=AT(o));const a=Array.isArray(i)&&"0"===t?"$$len":t;if(LI(o))return[[`${r}${a}`,fC(o)]];if(Object(o)===o){const t=Object.getOwnPropertyNames(Object.getPrototypeOf(o)),i=[...Object.getOwnPropertyNames(o),...t];if(i.includes("isSome")&&i.includes("isNone")){const t=o,i=t.isSome()?pC.Some:pC.None;return t.isSome()?e({0:i,1:t.unwrap()},`${r}${a}.`):[[`${r}${a}`,fC(i)]]}if(i.includes("isOk")&&i.includes("isErr")){const t=o,i=t.isOk()?yC.Ok:yC.Err;return e({0:i,1:t.unwrap()},`${r}${a}.`)}if(i.includes("variant")&&i.includes("activeVariant")){const t=o,i=t.activeVariant(),n=Object.keys(t.variant).findIndex((t=>t===i));return"object"==typeof t.unwrap()&&0===Object.keys(t.unwrap()).length?[[`${r}${a}`,fC(n)]]:e({0:n,1:t.unwrap()},`${r}${a}.`)}return e(o,`${r}${a}.`)}return[[`${r}${a}`,fC(o)]]}))};return Object.fromEntries(e(t))};let r;if(Array.isArray(t)){const i=e({...t});r=Object.values(i)}else{const i=e(t);r=Object.values(i)}return Object.defineProperty(r,"__compiled__",{enumerable:!1,writable:!1,value:!0}),r}parse(t,e){const{outputs:r}=this.abi.find((e=>e.name===t)),i=e.flat()[Symbol.iterator](),n=r.flat().reduce(((t,e,r)=>{const n=e.name??r;return t[n]=CC(i,e,this.structs,this.enums,t),t[n]&&t[`${n}_len`]&&delete t[`${n}_len`],t}),{});return 1===Object.keys(n).length&&0 in n?n[0]:n}format(t,e,r){return kC(this.parse(t,e),r)}static getAbiStruct(t){return t.filter((t=>"struct"===t.type)).reduce(((t,e)=>({...t,[e.name]:e})),{})}static getAbiEnum(t){const e=t.filter((t=>"enum"===t.type)).reduce(((t,e)=>({...t,[e.name]:e})),{});return delete e["core::bool"],e}static toCalldata(e=[]){return t.compile(e)}static toHex(e=[]){return t.compile(e).map((t=>HI(t)))}decodeParameters(t,e){const r=Array.isArray(t)?t:[t],i=e.flat()[Symbol.iterator](),n=r.map((t=>CC(i,{name:"",type:t},this.structs,this.enums)));return 1===n.length?n[0]:n}};nN({},{calculateContractAddressFromHash:()=>gz,calculateDeclareTransactionHash:()=>uz,calculateDeployAccountTransactionHash:()=>lz,calculateInvokeTransactionHash:()=>hz,calculateL2MessageTxHash:()=>ZC,computeCompiledClassHash:()=>_z,computeContractClassHash:()=>jz,computeHashOnElements:()=>fz,computeHintedClassHash:()=>vz,computeLegacyContractClassHash:()=>bz,computePedersenHash:()=>cz,computePedersenHashOnElements:()=>mz,computePoseidonHash:()=>dz,computePoseidonHashOnElements:()=>pz,computeSierraContractClassHash:()=>Az,formatSpaces:()=>wz,getL2MessageHash:()=>mT,getSelector:()=>dT,getSelectorFromName:()=>cT,hashByteCodeSegments:()=>Mz,keccakBn:()=>uT,poseidon:()=>Jv,solidityUint256PackedKeccak256:()=>fT,starknetKeccak:()=>lT});nN({},{calculateDeclareTransactionHash:()=>VC,calculateDeployAccountTransactionHash:()=>HC,calculateL2MessageTxHash:()=>ZC,calculateTransactionHash:()=>GC,calculateTransactionHashCommon:()=>qC,computeHashOnElements:()=>UC});function UC(t){return[...t,t.length].reduce(((t,e)=>Jb(VI(t),VI(e))),0).toString()}function qC(t,e,r,i,n,o,a,s=[]){const h=UC(n);return UC([t,e,r,i,h,o,a,...s])}function VC(t,e,r,i,n,o,a){return qC("0x6465636c617265",r,e,0,[t],i,n,[o,...a?[a]:[]])}function HC(t,e,r,i,n,o,a,s){return qC("0x6465706c6f795f6163636f756e74",n,t,0,[e,i,...r],o,a,[s])}function GC(t,e,r,i,n,o){return qC("0x696e766f6b65",e,t,0,r,i,n,[o])}function ZC(t,e,r,i,n,o){const a=[t,...i];return qC("0x6c315f68616e646c6572",0,e,dT(r),a,0,n,[o])}nN({},{starkCurve:()=>ak,weierstrass:()=>wb});nN({},{calculateDeclareTransactionHash:()=>az,calculateDeployAccountTransactionHash:()=>oz,calculateInvokeTransactionHash:()=>sz,calculateTransactionHashCommon:()=>nz,encodeResourceBoundsL1:()=>ez,encodeResourceBoundsL2:()=>rz,hashDAMode:()=>tz,hashFeeField:()=>iz});var KC=t=>t.map((t=>BigInt(t))),JC=32n,WC=128n,YC=64n+WC,QC=BigInt(MT("L1_GAS")),XC=BigInt(MT("L2_GAS"));function tz(t,e){return(BigInt(t)<<JC)+BigInt(e)}function ez(t){return(QC<<YC)+(BigInt(t.l1_gas.max_amount)<<WC)+BigInt(t.l1_gas.max_price_per_unit)}function rz(t){return(XC<<YC)+(BigInt(t.l2_gas.max_amount)<<WC)+BigInt(t.l2_gas.max_price_per_unit)}function iz(t,e){const r=ez(e),i=rz(e);return ok([BigInt(t),r,i])}function nz(t,e,r,i,n,o,a,s,h,u,l=[]){const c=iz(o,u),d=tz(s,h),f=KC([t,e,r,c,ok(KC(a)),i,n,d,...KC(l)]);return HI(ok(f))}function oz(t,e,r,i,n,o,a,s,h,u,l,c){return nz("0x6465706c6f795f6163636f756e74",n,t,o,a,l,c,s,h,u,[ok(KC(r)),e,i])}function az(t,e,r,i,n,o,a,s,h,u,l,c){return nz("0x6465636c617265",i,r,n,o,l,KC(c),s,h,u,[ok(KC(a)),t,e])}function sz(t,e,r,i,n,o,a,s,h,u,l){return nz("0x696e766f6b65",e,t,i,n,u,l,a,s,h,[ok(KC(o)),ok(KC(r))])}function hz(t){return function(t){return[aN.ETransactionVersion.V3,aN.ETransactionVersion.F3].includes(t.version)}(t)?sz(t.senderAddress,t.version,t.compiledCalldata,t.chainId,t.nonce,t.accountDeploymentData,t.nonceDataAvailabilityMode,t.feeDataAvailabilityMode,t.resourceBounds,t.tip,t.paymasterData):GC(t.senderAddress,t.version,t.compiledCalldata,t.maxFee,t.chainId,t.nonce)}function uz(t){return function(t){return[aN.ETransactionVersion.V3,aN.ETransactionVersion.F3].includes(t.version)}(t)?az(t.classHash,t.compiledClassHash,t.senderAddress,t.version,t.chainId,t.nonce,t.accountDeploymentData,t.nonceDataAvailabilityMode,t.feeDataAvailabilityMode,t.resourceBounds,t.tip,t.paymasterData):VC(t.classHash,t.senderAddress,t.version,t.maxFee,t.chainId,t.nonce,t.compiledClassHash)}function lz(t){return function(t){return[aN.ETransactionVersion.V3,aN.ETransactionVersion.F3].includes(t.version)}(t)?oz(t.contractAddress,t.classHash,t.compiledConstructorCalldata,t.salt,t.version,t.chainId,t.nonce,t.nonceDataAvailabilityMode,t.feeDataAvailabilityMode,t.resourceBounds,t.tip,t.paymasterData):HC(t.contractAddress,t.classHash,t.constructorCalldata,t.salt,t.version,t.maxFee,t.chainId,t.nonce)}function cz(t,e){return Jb(BigInt(t),BigInt(e))}function dz(t,e){return HI(nk(BigInt(t),BigInt(e)))}function fz(t){return[...t,t.length].reduce(((t,e)=>Jb(BigInt(t),BigInt(e))),0).toString()}var mz=fz;function pz(t){return HI(ok(t.map((t=>BigInt(t)))))}function gz(t,e,r,i){const n=fz(FC.compile(r)),o=fz([fC("0x535441524b4e45545f434f4e54524143545f41444452455353"),i,t,e,n]);return HI(BigInt(o)%VN)}function yz(t,e){return"attributes"===t||"accessible_scopes"===t?Array.isArray(e)&&0===e.length?void 0:e:"debug_info"===t?null:null===e?void 0:e}function wz(t){let e=!1;const r=[];for(const i of t)'"'===i&&!1==(r.length>0&&"\\"===r.slice(-1)[0])&&(e=!e),e?r.push(i):r.push(":"===i?": ":","===i?", ":i);return r.join("")}function vz(t){const{abi:e,program:r}=t,i=wz(mI({abi:e,program:r},yz));return IN(Yb(EN(i)).toString(16))}function bz(t){const e=FI(t)?dI(t):t,r=HI(FN),i=fz(e.entry_points_by_type.EXTERNAL.flatMap((t=>[t.selector,t.offset]))),n=fz(e.entry_points_by_type.L1_HANDLER.flatMap((t=>[t.selector,t.offset]))),o=fz(e.entry_points_by_type.CONSTRUCTOR.flatMap((t=>[t.selector,t.offset]))),a=fz(e.program.builtins.map((t=>MT(t)))),s=vz(e),h=fz(e.program.data);return fz([r,i,n,o,a,s,h])}function kz(t){const e=t.flatMap((t=>{return[BigInt(t.selector),BigInt(t.offset),(e=t.builtins,ok(e.flatMap((t=>BigInt(MT(t))))))];var e}));return ok(e)}function Mz(t){const e=t.bytecode.map((t=>BigInt(t))),r=t.bytecode_segment_lengths??[];let i=0;const n=r.flatMap((t=>{const r=e.slice(i,i+=t);return[BigInt(t),ok(r)]}));return 1n+ok(n)}function _z(t){const e=BigInt(MT("COMPILED_CLASS_V1")),r=kz(t.entry_points_by_type.EXTERNAL),i=kz(t.entry_points_by_type.L1_HANDLER),n=kz(t.entry_points_by_type.CONSTRUCTOR),o=t.bytecode_segment_lengths?Mz(t):ok(t.bytecode.map((t=>BigInt(t))));return HI(ok([e,r,i,n,o]))}function Ez(t){return ok(t.flatMap((t=>[BigInt(t.selector),BigInt(t.function_idx)])))}function Az(t){const e=BigInt(MT("CONTRACT_CLASS_V0.1.0")),r=Ez(t.entry_points_by_type.EXTERNAL),i=Ez(t.entry_points_by_type.L1_HANDLER),n=Ez(t.entry_points_by_type.CONSTRUCTOR),o=function(t){const e=wz(mI(t.abi,null));return BigInt(IN(Yb(EN(e)).toString(16)))}(t),a=ok(t.sierra_program.map((t=>BigInt(t))));return HI(ok([e,r,i,n,o,a]))}function jz(t){const e=FI(t)?dI(t):t;return"sierra_program"in e?Az(e):bz(e)}function xz(t){const e=FI(t)?t:mI(t);return xN(KE(e))}function Sz(t){if(Array.isArray(t))return t;const e=_N(JE(jN(t)));return dI(e)}function Nz(){return Fb(Bb.randomPrivateKey())}function Iz(t){return IN(t).toLowerCase()}function Tz(t){if(!t)throw Error("formatSignature: provided signature is undefined");if(Array.isArray(t))return t.map((t=>HI(t)));try{const{r:e,s:r}=t;return[HI(e),HI(r)]}catch(t){throw new Error("Signature need to be weierstrass.SignatureType or an array for custom")}}function Cz(t){return QI(Tz(t))}function zz(t){return XI(Tz(t))}function Oz(t,e=50){return aT(t,e)}function Rz(t,e=50,r=50){if(LI(t))return{l2_gas:{max_amount:"0x0",max_price_per_unit:"0x0"},l1_gas:{max_amount:"0x0",max_price_per_unit:"0x0"}};if(BI(t.gas_consumed)||BI(t.gas_price))throw Error("estimateFeeToBounds: estimate is undefined");return{l2_gas:{max_amount:"0x0",max_price_per_unit:"0x0"},l1_gas:{max_amount:void 0!==t.data_gas_consumed&&void 0!==t.data_gas_price?HI(aT(BigInt(t.overall_fee)/BigInt(t.gas_price),e)):HI(aT(t.gas_consumed,e)),max_price_per_unit:HI(aT(t.gas_price,r))}}}function Pz(t){if(t===aN.EDataAvailabilityMode.L1)return aN.EDAMode.L1;if(t===aN.EDataAvailabilityMode.L2)return aN.EDAMode.L2;throw Error("EDAM conversion")}function Bz(t,e){const r=e?HI(e):void 0,i=HI(t);if(e&&!Object.values(aN.ETransactionVersion).includes(r))throw Error(`providedVersion ${e} is not ETransactionVersion`);if(!Object.values(aN.ETransactionVersion).includes(i))throw Error(`defaultVersion ${t} is not ETransactionVersion`);return e?r:i}function Dz(t){if(!t)return;const e=HI(t);if(e===aN.ETransactionVersion.V0)return aN.ETransactionVersion.F0;if(e===aN.ETransactionVersion.V1)return aN.ETransactionVersion.F1;if(e===aN.ETransactionVersion.V2)return aN.ETransactionVersion.F2;if(e===aN.ETransactionVersion.V3)return aN.ETransactionVersion.F3;throw Error(`toFeeVersion: ${e} is not supported`)}function $z(t){return{tip:t.tip||0,paymasterData:t.paymasterData||[],accountDeploymentData:t.accountDeploymentData||[],nonceDataAvailabilityMode:t.nonceDataAvailabilityMode||aN.EDataAvailabilityMode.L1,feeDataAvailabilityMode:t.feeDataAvailabilityMode||aN.EDataAvailabilityMode.L1,resourceBounds:t.resourceBounds??Rz(DN)}}function Lz(t){return t===aN.ETransactionVersion.F2?aN.ETransactionVersion.F1:t===aN.ETransactionVersion.V2?aN.ETransactionVersion.V1:t}function Fz(t){return IN(SN(Ib(HI(t),!1)))}function Uz(t){return"sierra_program"in(FI(t)?dI(t):t)}nN({},{compressProgram:()=>xz,decompressProgram:()=>Sz,estimateFeeToBounds:()=>Rz,estimatedFeeToMaxFee:()=>Oz,formatSignature:()=>Tz,getFullPublicKey:()=>Fz,intDAM:()=>Pz,makeAddress:()=>Iz,randomAddress:()=>Nz,reduceV2:()=>Lz,signatureToDecimalArray:()=>Cz,signatureToHexArray:()=>zz,toFeeVersion:()=>Dz,toTransactionVersion:()=>Bz,v3Details:()=>$z});function qz(){return ON(SN(rA.utils.randomPrivateKey()))}function Vz(t){YI(t,DN,2n**160n-1n,"Ethereum Address ");const e=IN(NN(HI(t)).padStart(40,"0"));return PI(Boolean(e.match(/^(0x)?[0-9a-f]{40}$/)),"Invalid Ethereum Address Format"),e}nN({},{ethRandomPrivateKey:()=>qz,validateAndParseEthAddress:()=>Vz});var Hz=MN&&window.fetch.bind(window)||!BI(t)&&gS(t.fetch)||FS;nN({},{Block:()=>tO,createSierraContractClass:()=>Wz,getDefaultNodeUrl:()=>Qz,isPendingBlock:()=>iO,isPendingStateUpdate:()=>oO,isPendingTransaction:()=>nO,isV3Tx:()=>eO,isVersion:()=>rO,parseContract:()=>Yz,validBlockTags:()=>Xz,wait:()=>Jz});var Gz=class t{static instance;config;constructor(){this.initialize()}initialize(){this.config={...hI}}static getInstance(){return t.instance||(t.instance=new t),t.instance}get(t,e){return this.config[t]??e}set(t,e){this.config[t]=e}update(t){this.config={...this.config,...t}}getAll(){return{...this.config}}reset(){this.initialize()}delete(t){delete this.config[t]}hasKey(t){return t in this.config}}.getInstance(),Zz={DEBUG:5,INFO:4,WARN:3,ERROR:2,FATAL:1,OFF:0},Kz=class t{static instance;config;constructor(){this.config=Gz}static getInstance(){return t.instance||(t.instance=new t),t.instance}getTimestamp(){return(new Date).toISOString()}shouldLog(t){const e=this.config.get("logLevel","INFO");return t<=Zz[e]}formatMessage(t){const{level:e,message:r,timestamp:i,data:n}=t;let o=`[${i}] ${e}: ${r}`;if(n)try{o+=`\n${JSON.stringify(n,null,2)}`}catch(t){o+=`\n[JSON.stringify Error/Circular]: ${t}`}return o}log(t,e,r){if(!this.shouldLog(Zz[t]))return;const i={level:t,message:e,timestamp:this.getTimestamp(),data:r},n=this.formatMessage(i);switch(t){case"DEBUG":console.debug(n);break;case"INFO":console.info(n);break;case"WARN":console.warn(n);break;case"ERROR":case"FATAL":console.error(n);break;case"OFF":break;default:console.log(n)}}debug(t,e){this.log("DEBUG",t,e)}info(t,e){this.log("INFO",t,e)}warn(t,e){this.log("WARN",t,e)}error(t,e){this.log("ERROR",t,e)}fatal(t,e){this.log("FATAL",t,e)}setLogLevel(t){this.config.set("logLevel",t)}getLogLevel(){return this.config.get("logLevel","INFO")}getEnabledLogLevels(){return Object.keys(Zz).filter((t=>this.shouldLog(Zz[t])&&"OFF"!==t))}}.getInstance();function Jz(t){return new Promise((e=>{setTimeout(e,t)}))}function Wz(t){const e={...t};return delete e.sierra_program_debug_info,e.abi=wz(mI(t.abi)),e.sierra_program=wz(mI(t.sierra_program)),e.sierra_program=xz(e.sierra_program),e}function Yz(t){const e=FI(t)?dI(t):t;return Uz(t)?Wz(e):{...e,..."program"in e&&{program:xz(e.program)}}}var Qz=(t,e=!1)=>{e||Kz.info("Using default public node url, please provide nodeUrl in provider options!");const r=rI[t??"SN_SEPOLIA"];return r[Math.floor(Math.random()*r.length)]},Xz=Object.values(jI),tO=class{hash=null;number=null;tag=null;setIdentifier(t){if(FI(t))if(yT(t))this.number=parseInt(t,10);else if(qI(t))this.hash=t;else{if(!Xz.includes(t))throw TypeError(`Block identifier unmanaged: ${t}`);this.tag=t}else LI(t)?this.hash=HI(t):DI(t)?this.number=t:this.tag=jI.PENDING;if(DI(this.number)&&this.number<0)throw TypeError(`Block number (${this.number}) can't be negative`)}constructor(t){this.setIdentifier(t)}get queryIdentifier(){return null!==this.number?`blockNumber=${this.number}`:null!==this.hash?`blockHash=${this.hash}`:`blockNumber=${this.tag}`}get identifier(){return null!==this.number?{block_number:this.number}:null!==this.hash?{block_hash:this.hash}:this.tag}set identifier(t){this.setIdentifier(t)}valueOf=()=>this.number;toString=()=>this.hash};function eO(t){const e=t.version?HI(t.version):aN.ETransactionVersion.V3;return e===aN.ETransactionVersion.V3||e===aN.ETransactionVersion.F3}function rO(t,e){const[r,i]=t.split("."),[n,o]=e.split(".");return r===n&&i===o}function iO(t){return"PENDING"===t.status}function nO(t){return!("block_hash"in t)}function oO(t){return!("block_hash"in t)}nN({},{buildUDCCall:()=>dO,fromCallsToExecuteCalldata:()=>sO,fromCallsToExecuteCalldataWithNonce:()=>hO,fromCallsToExecuteCalldata_cairo1:()=>lO,getExecuteCalldata:()=>cO,getVersionsByType:()=>fO,transformCallsToMulticallArrays:()=>aO,transformCallsToMulticallArrays_cairo1:()=>uO});var aO=t=>{const e=[],r=[];return t.forEach((t=>{const i=FC.compile(t.calldata||[]);e.push({to:VI(t.contractAddress).toString(10),selector:VI(cT(t.entrypoint)).toString(10),data_offset:r.length.toString(),data_len:i.length.toString()}),r.push(...i)})),{callArray:e,calldata:FC.compile({calldata:r})}},sO=t=>{const{callArray:e,calldata:r}=aO(t);return[...FC.compile({callArray:e}),...r]},hO=(t,e)=>[...sO(t),VI(e).toString()],uO=t=>{const e=t.map((t=>({to:VI(t.contractAddress).toString(10),selector:VI(cT(t.entrypoint)).toString(10),calldata:FC.compile(t.calldata||[])})));return e},lO=t=>{const e=t.map((t=>({contractAddress:t.contractAddress,entrypoint:t.entrypoint,calldata:Array.isArray(t.calldata)&&"__compiled__"in t.calldata?t.calldata:FC.compile(t.calldata)})));return FC.compile({orderCalls:e})},cO=(t,e="0")=>"1"===e?lO(t):sO(t);function dO(t,e){const r=[].concat(t).map((t=>{const{classHash:r,salt:i,unique:n=!0,constructorCalldata:o=[]}=t,a=FC.compile(o),s=i??Nz();return{call:{contractAddress:tI.ADDRESS,entrypoint:tI.ENTRYPOINT,calldata:[r,s,nT(n),a.length,...a]},address:gz(n?Jb(e,s):s,r,a,n?tI.ADDRESS:0)}}));return{calls:r.map((t=>t.call)),addresses:r.map((t=>t.address))}}function fO(t){return"fee"===t?{v1:aN.ETransactionVersion.F1,v2:aN.ETransactionVersion.F2,v3:aN.ETransactionVersion.F3}:{v1:aN.ETransactionVersion.V1,v2:aN.ETransactionVersion.V2,v3:aN.ETransactionVersion.V3}}var mO={headers:{"Content-Type":"application/json"},blockIdentifier:jI.PENDING,retries:200},pO=class{nodeUrl;headers;requestId;blockIdentifier;retries;waitMode;chainId;specVersion;transactionRetryIntervalFallback;batchClient;baseFetch;constructor(t){const{baseFetch:e,batch:r,blockIdentifier:i,chainId:n,headers:o,nodeUrl:a,retries:s,specVersion:h,transactionRetryIntervalFallback:u,waitMode:l}=t||{};Object.values(WN).includes(a)?this.nodeUrl=Qz(a,t?.default):this.nodeUrl=a||Qz(void 0,t?.default),this.baseFetch=e??Hz,this.blockIdentifier=i??mO.blockIdentifier,this.chainId=n,this.headers={...mO.headers,...o},this.retries=s??mO.retries,this.specVersion=h,this.transactionRetryIntervalFallback=u,this.waitMode=l??!1,this.requestId=0,"number"==typeof r&&(this.batchClient=new RI({nodeUrl:this.nodeUrl,headers:this.headers,interval:r,baseFetch:this.baseFetch}))}get transactionRetryIntervalDefault(){return this.transactionRetryIntervalFallback??5e3}setChainId(t){this.chainId=t}fetch(t,e,r=0){const i={id:r,jsonrpc:"2.0",method:t,...e&&{params:e}};return this.baseFetch(this.nodeUrl,{method:"POST",body:mI(i),headers:this.headers})}errorHandler(t,e,r,i){if(r)throw new vI(r,t,e);if(i instanceof wI)throw i;if(i)throw Error(i.message)}async fetchEndpoint(t,e){try{if(this.batchClient){const{error:r,result:i}=await this.batchClient.fetch(t,e,this.requestId+=1);return this.errorHandler(t,e,r),i}const r=await this.fetch(t,e,this.requestId+=1),{error:i,result:n}=await r.json();return this.errorHandler(t,e,i),n}catch(r){throw this.errorHandler(t,e,r?.response?.data,r),r}}async getChainId(){return this.chainId??=await this.fetchEndpoint("starknet_chainId"),this.chainId}async getSpecVersion(){return this.specVersion??=await this.fetchEndpoint("starknet_specVersion"),this.specVersion}getNonceForAddress(t,e=this.blockIdentifier){const r=HI(t),i=new tO(e).identifier;return this.fetchEndpoint("starknet_getNonce",{contract_address:r,block_id:i})}getBlockLatestAccepted(){return this.fetchEndpoint("starknet_blockHashAndNumber")}getBlockNumber(){return this.fetchEndpoint("starknet_blockNumber")}getBlockWithTxHashes(t=this.blockIdentifier){const e=new tO(t).identifier;return this.fetchEndpoint("starknet_getBlockWithTxHashes",{block_id:e})}getBlockWithTxs(t=this.blockIdentifier){const e=new tO(t).identifier;return this.fetchEndpoint("starknet_getBlockWithTxs",{block_id:e})}getBlockStateUpdate(t=this.blockIdentifier){const e=new tO(t).identifier;return this.fetchEndpoint("starknet_getStateUpdate",{block_id:e})}getBlockTransactionsTraces(t=this.blockIdentifier){const e=new tO(t).identifier;return this.fetchEndpoint("starknet_traceBlockTransactions",{block_id:e})}getBlockTransactionCount(t=this.blockIdentifier){const e=new tO(t).identifier;return this.fetchEndpoint("starknet_getBlockTransactionCount",{block_id:e})}getTransactionByHash(t){const e=HI(t);return this.fetchEndpoint("starknet_getTransactionByHash",{transaction_hash:e})}getTransactionByBlockIdAndIndex(t,e){const r=new tO(t).identifier;return this.fetchEndpoint("starknet_getTransactionByBlockIdAndIndex",{block_id:r,index:e})}getTransactionReceipt(t){const e=HI(t);return this.fetchEndpoint("starknet_getTransactionReceipt",{transaction_hash:e})}getTransactionTrace(t){const e=HI(t);return this.fetchEndpoint("starknet_traceTransaction",{transaction_hash:e})}getTransactionStatus(t){const e=HI(t);return this.fetchEndpoint("starknet_getTransactionStatus",{transaction_hash:e})}simulateTransaction(t,e={}){const{blockIdentifier:r=this.blockIdentifier,skipValidate:i=!0,skipFeeCharge:n=!0}=e,o=new tO(r).identifier,a=[];return i&&a.push(hN.ESimulationFlag.SKIP_VALIDATE),n&&a.push(hN.ESimulationFlag.SKIP_FEE_CHARGE),this.fetchEndpoint("starknet_simulateTransactions",{block_id:o,transactions:t.map((t=>this.buildTransaction(t))),simulation_flags:a})}async waitForTransaction(t,e){const r=HI(t);let{retries:i}=this,n=!1,o=!1;const a=e?.retryInterval??this.transactionRetryIntervalDefault,s=e?.errorStates??[hN.ETransactionStatus.REJECTED],h=e?.successStates??[hN.ETransactionExecutionStatus.SUCCEEDED,hN.ETransactionStatus.ACCEPTED_ON_L2,hN.ETransactionStatus.ACCEPTED_ON_L1];let u;for(;!n;){await Jz(a);try{u=await this.getTransactionStatus(r);const t=u.execution_status,e=u.finality_status;if(!e){throw new Error("waiting for transaction status")}if(s.includes(t)||s.includes(e)){const r=`${t}: ${e}`,i=new Error(r);throw i.response=u,o=!0,i}(h.includes(t)||h.includes(e))&&(n=!0)}catch(t){if(t instanceof Error&&o)throw t;if(i<=0)throw new Error(`waitForTransaction timed-out with retries ${this.retries}`)}i-=1}let l=null;for(;null===l;){try{l=await this.getTransactionReceipt(r)}catch(t){if(i<=0)throw new Error(`waitForTransaction timed-out with retries ${this.retries}`)}i-=1,await Jz(a)}return l}getStorageAt(t,e,r=this.blockIdentifier){const i=HI(t),n=ZI(e),o=new tO(r).identifier;return this.fetchEndpoint("starknet_getStorageAt",{contract_address:i,key:n,block_id:o})}getClassHashAt(t,e=this.blockIdentifier){const r=HI(t),i=new tO(e).identifier;return this.fetchEndpoint("starknet_getClassHashAt",{block_id:i,contract_address:r})}getClass(t,e=this.blockIdentifier){const r=HI(t),i=new tO(e).identifier;return this.fetchEndpoint("starknet_getClass",{class_hash:r,block_id:i})}getClassAt(t,e=this.blockIdentifier){const r=HI(t),i=new tO(e).identifier;return this.fetchEndpoint("starknet_getClassAt",{block_id:i,contract_address:r})}async getEstimateFee(t,{blockIdentifier:e=this.blockIdentifier,skipValidate:r=!0}){const i=new tO(e).identifier;let n={};return rO("0.5",await this.getSpecVersion())||(n={simulation_flags:r?[hN.ESimulationFlag.SKIP_VALIDATE]:[]}),this.fetchEndpoint("starknet_estimateFee",{request:t.map((t=>this.buildTransaction(t,"fee"))),block_id:i,...n})}async invoke(t,e){let r;return eO(e)?r=this.fetchEndpoint("starknet_addInvokeTransaction",{invoke_transaction:{type:hN.ETransactionType.INVOKE,sender_address:t.contractAddress,calldata:FC.toHex(t.calldata),version:hN.ETransactionVersion.V3,signature:zz(t.signature),nonce:HI(e.nonce),resource_bounds:e.resourceBounds,tip:HI(e.tip),paymaster_data:e.paymasterData.map((t=>HI(t))),account_deployment_data:e.accountDeploymentData.map((t=>HI(t))),nonce_data_availability_mode:e.nonceDataAvailabilityMode,fee_data_availability_mode:e.feeDataAvailabilityMode}}):(r=this.fetchEndpoint("starknet_addInvokeTransaction",{invoke_transaction:{sender_address:t.contractAddress,calldata:FC.toHex(t.calldata),type:hN.ETransactionType.INVOKE,max_fee:HI(e.maxFee||0),version:hN.ETransactionVersion.V1,signature:zz(t.signature),nonce:HI(e.nonce)}}),Kz.warn(uI.legacyTxWarningMessage,{version:hN.ETransactionVersion.V1,type:hN.ETransactionType.INVOKE})),this.waitMode?this.waitForTransaction((await r).transaction_hash):r}async declare({contract:t,signature:e,senderAddress:r,compiledClassHash:i},n){let o;if(Uz(t)||eO(n))if(Uz(t)&&!eO(n))o=this.fetchEndpoint("starknet_addDeclareTransaction",{declare_transaction:{type:hN.ETransactionType.DECLARE,contract_class:{sierra_program:Sz(t.sierra_program),contract_class_version:t.contract_class_version,entry_points_by_type:t.entry_points_by_type,abi:t.abi},compiled_class_hash:i||"",version:hN.ETransactionVersion.V2,max_fee:HI(n.maxFee||0),signature:zz(e),sender_address:r,nonce:HI(n.nonce)}}),Kz.warn(uI.legacyTxWarningMessage,{version:hN.ETransactionVersion.V2,type:hN.ETransactionType.DECLARE});else{if(!Uz(t)||!eO(n))throw Error("declare unspotted parameters");o=this.fetchEndpoint("starknet_addDeclareTransaction",{declare_transaction:{type:hN.ETransactionType.DECLARE,sender_address:r,compiled_class_hash:i||"",version:hN.ETransactionVersion.V3,signature:zz(e),nonce:HI(n.nonce),contract_class:{sierra_program:Sz(t.sierra_program),contract_class_version:t.contract_class_version,entry_points_by_type:t.entry_points_by_type,abi:t.abi},resource_bounds:n.resourceBounds,tip:HI(n.tip),paymaster_data:n.paymasterData.map((t=>HI(t))),account_deployment_data:n.accountDeploymentData.map((t=>HI(t))),nonce_data_availability_mode:n.nonceDataAvailabilityMode,fee_data_availability_mode:n.feeDataAvailabilityMode}})}else o=this.fetchEndpoint("starknet_addDeclareTransaction",{declare_transaction:{type:hN.ETransactionType.DECLARE,contract_class:{program:t.program,entry_points_by_type:t.entry_points_by_type,abi:t.abi},version:hN.ETransactionVersion.V1,max_fee:HI(n.maxFee||0),signature:zz(e),sender_address:r,nonce:HI(n.nonce)}}),Kz.warn(uI.legacyTxWarningMessage,{version:hN.ETransactionVersion.V1,type:hN.ETransactionType.DECLARE});return this.waitMode?this.waitForTransaction((await o).transaction_hash):o}async deployAccount({classHash:t,constructorCalldata:e,addressSalt:r,signature:i},n){let o;return eO(n)?o=this.fetchEndpoint("starknet_addDeployAccountTransaction",{deploy_account_transaction:{type:hN.ETransactionType.DEPLOY_ACCOUNT,version:hN.ETransactionVersion.V3,signature:zz(i),nonce:HI(n.nonce),contract_address_salt:HI(r||0),constructor_calldata:FC.toHex(e||[]),class_hash:HI(t),resource_bounds:n.resourceBounds,tip:HI(n.tip),paymaster_data:n.paymasterData.map((t=>HI(t))),nonce_data_availability_mode:n.nonceDataAvailabilityMode,fee_data_availability_mode:n.feeDataAvailabilityMode}}):(o=this.fetchEndpoint("starknet_addDeployAccountTransaction",{deploy_account_transaction:{constructor_calldata:FC.toHex(e||[]),class_hash:HI(t),contract_address_salt:HI(r||0),type:hN.ETransactionType.DEPLOY_ACCOUNT,max_fee:HI(n.maxFee||0),version:hN.ETransactionVersion.V1,signature:zz(i),nonce:HI(n.nonce)}}),Kz.warn(uI.legacyTxWarningMessage,{version:hN.ETransactionVersion.V1,type:hN.ETransactionType.DEPLOY_ACCOUNT})),this.waitMode?this.waitForTransaction((await o).transaction_hash):o}callContract(t,e=this.blockIdentifier){const r=new tO(e).identifier;return this.fetchEndpoint("starknet_call",{request:{contract_address:t.contractAddress,entry_point_selector:cT(t.entrypoint),calldata:FC.toHex(t.calldata)},block_id:r})}estimateMessageFee(t,e=this.blockIdentifier){const{from_address:r,to_address:i,entry_point_selector:n,payload:o}=t,a={from_address:Vz(r),to_address:HI(i),entry_point_selector:dT(n),payload:iT(o)},s=new tO(e).identifier;return this.fetchEndpoint("starknet_estimateMessageFee",{message:a,block_id:s})}getSyncingStats(){return this.fetchEndpoint("starknet_syncing")}getEvents(t){return this.fetchEndpoint("starknet_getEvents",{filter:t})}buildTransaction(t,e){const r=fO(e);let i;if(eO(t)?i={signature:zz(t.signature),nonce:HI(t.nonce),resource_bounds:t.resourceBounds,tip:HI(t.tip),paymaster_data:t.paymasterData.map((t=>HI(t))),nonce_data_availability_mode:t.nonceDataAvailabilityMode,fee_data_availability_mode:t.feeDataAvailabilityMode,account_deployment_data:t.accountDeploymentData.map((t=>HI(t)))}:(i={signature:zz(t.signature),nonce:HI(t.nonce),max_fee:HI(t.maxFee||0)},Kz.warn(uI.legacyTxWarningMessage,{version:t.version,type:t.type})),t.type===kI.INVOKE)return{type:hN.ETransactionType.INVOKE,sender_address:t.contractAddress,calldata:FC.toHex(t.calldata),version:HI(t.version||r.v3),...i};if(t.type===kI.DECLARE)return Uz(t.contract)?{type:t.type,contract_class:{...t.contract,sierra_program:Sz(t.contract.sierra_program)},compiled_class_hash:t.compiledClassHash||"",sender_address:t.senderAddress,version:HI(t.version||r.v3),...i}:{type:t.type,contract_class:t.contract,sender_address:t.senderAddress,version:HI(t.version||r.v1),...i};if(t.type===kI.DEPLOY_ACCOUNT){const{account_deployment_data:e,...n}=i;return{type:t.type,constructor_calldata:FC.toHex(t.constructorCalldata||[]),class_hash:HI(t.classHash),contract_address_salt:HI(t.addressSalt||0),version:HI(t.version||r.v3),...n}}throw Error("RPC buildTransaction received unknown TransactionType")}};nN({},{RpcChannel:()=>yO});var gO={headers:{"Content-Type":"application/json"},blockIdentifier:jI.PENDING,retries:200},yO=class{nodeUrl;headers;requestId;blockIdentifier;retries;waitMode;chainId;specVersion;transactionRetryIntervalFallback;batchClient;baseFetch;constructor(t){const{baseFetch:e,batch:r,blockIdentifier:i,chainId:n,headers:o,nodeUrl:a,retries:s,specVersion:h,transactionRetryIntervalFallback:u,waitMode:l}=t||{};Object.values(WN).includes(a)?this.nodeUrl=Qz(a,t?.default):this.nodeUrl=a||Qz(void 0,t?.default),this.baseFetch=e??Hz,this.blockIdentifier=i??gO.blockIdentifier,this.chainId=n,this.headers={...gO.headers,...o},this.retries=s??gO.retries,this.specVersion=h,this.transactionRetryIntervalFallback=u,this.waitMode=l??!1,this.requestId=0,"number"==typeof r&&(this.batchClient=new RI({nodeUrl:this.nodeUrl,headers:this.headers,interval:r,baseFetch:this.baseFetch}))}get transactionRetryIntervalDefault(){return this.transactionRetryIntervalFallback??5e3}setChainId(t){this.chainId=t}fetch(t,e,r=0){const i={id:r,jsonrpc:"2.0",method:t,...e&&{params:e}};return this.baseFetch(this.nodeUrl,{method:"POST",body:mI(i),headers:this.headers})}errorHandler(t,e,r,i){if(r)throw new vI(r,t,e);if(i instanceof wI)throw i;if(i)throw Error(i.message)}async fetchEndpoint(t,e){try{if(this.batchClient){const{error:r,result:i}=await this.batchClient.fetch(t,e,this.requestId+=1);return this.errorHandler(t,e,r),i}const r=await this.fetch(t,e,this.requestId+=1),{error:i,result:n}=await r.json();return this.errorHandler(t,e,i),n}catch(r){throw this.errorHandler(t,e,r?.response?.data,r),r}}async getChainId(){return this.chainId??=await this.fetchEndpoint("starknet_chainId"),this.chainId}async getSpecVersion(){return this.specVersion??=await this.fetchEndpoint("starknet_specVersion"),this.specVersion}getNonceForAddress(t,e=this.blockIdentifier){const r=HI(t),i=new tO(e).identifier;return this.fetchEndpoint("starknet_getNonce",{contract_address:r,block_id:i})}getBlockLatestAccepted(){return this.fetchEndpoint("starknet_blockHashAndNumber")}getBlockNumber(){return this.fetchEndpoint("starknet_blockNumber")}getBlockWithTxHashes(t=this.blockIdentifier){const e=new tO(t).identifier;return this.fetchEndpoint("starknet_getBlockWithTxHashes",{block_id:e})}getBlockWithTxs(t=this.blockIdentifier){const e=new tO(t).identifier;return this.fetchEndpoint("starknet_getBlockWithTxs",{block_id:e})}getBlockWithReceipts(t=this.blockIdentifier){const e=new tO(t).identifier;return this.fetchEndpoint("starknet_getBlockWithReceipts",{block_id:e})}getBlockStateUpdate(t=this.blockIdentifier){const e=new tO(t).identifier;return this.fetchEndpoint("starknet_getStateUpdate",{block_id:e})}getBlockTransactionsTraces(t=this.blockIdentifier){const e=new tO(t).identifier;return this.fetchEndpoint("starknet_traceBlockTransactions",{block_id:e})}getBlockTransactionCount(t=this.blockIdentifier){const e=new tO(t).identifier;return this.fetchEndpoint("starknet_getBlockTransactionCount",{block_id:e})}getTransactionByHash(t){const e=HI(t);return this.fetchEndpoint("starknet_getTransactionByHash",{transaction_hash:e})}getTransactionByBlockIdAndIndex(t,e){const r=new tO(t).identifier;return this.fetchEndpoint("starknet_getTransactionByBlockIdAndIndex",{block_id:r,index:e})}getTransactionReceipt(t){const e=HI(t);return this.fetchEndpoint("starknet_getTransactionReceipt",{transaction_hash:e})}getTransactionTrace(t){const e=HI(t);return this.fetchEndpoint("starknet_traceTransaction",{transaction_hash:e})}getTransactionStatus(t){const e=HI(t);return this.fetchEndpoint("starknet_getTransactionStatus",{transaction_hash:e})}simulateTransaction(t,e={}){const{blockIdentifier:r=this.blockIdentifier,skipValidate:i=!0,skipFeeCharge:n=!0}=e,o=new tO(r).identifier,a=[];return i&&a.push(ig.SKIP_VALIDATE),n&&a.push(ig.SKIP_FEE_CHARGE),this.fetchEndpoint("starknet_simulateTransactions",{block_id:o,transactions:t.map((t=>this.buildTransaction(t))),simulation_flags:a})}async waitForTransaction(t,e){const r=HI(t);let{retries:i}=this,n=!1,o=!1;const a=e?.retryInterval??this.transactionRetryIntervalDefault,s=e?.errorStates??[ng.REJECTED],h=e?.successStates??[ag.SUCCEEDED,ng.ACCEPTED_ON_L2,ng.ACCEPTED_ON_L1];let u;for(;!n;){await Jz(a);try{u=await this.getTransactionStatus(r);const t=u.execution_status,e=u.finality_status;if(!e){throw new Error("waiting for transaction status")}if(s.includes(t)||s.includes(e)){const r=`${t}: ${e}`,i=new Error(r);throw i.response=u,o=!0,i}(h.includes(t)||h.includes(e))&&(n=!0)}catch(t){if(t instanceof Error&&o)throw t;if(i<=0)throw new Error(`waitForTransaction timed-out with retries ${this.retries}`)}i-=1}let l=null;for(;null===l;){try{l=await this.getTransactionReceipt(r)}catch(t){if(i<=0)throw new Error(`waitForTransaction timed-out with retries ${this.retries}`)}i-=1,await Jz(a)}return l}getStorageAt(t,e,r=this.blockIdentifier){const i=HI(t),n=ZI(e),o=new tO(r).identifier;return this.fetchEndpoint("starknet_getStorageAt",{contract_address:i,key:n,block_id:o})}getClassHashAt(t,e=this.blockIdentifier){const r=HI(t),i=new tO(e).identifier;return this.fetchEndpoint("starknet_getClassHashAt",{block_id:i,contract_address:r})}getClass(t,e=this.blockIdentifier){const r=HI(t),i=new tO(e).identifier;return this.fetchEndpoint("starknet_getClass",{class_hash:r,block_id:i})}getClassAt(t,e=this.blockIdentifier){const r=HI(t),i=new tO(e).identifier;return this.fetchEndpoint("starknet_getClassAt",{block_id:i,contract_address:r})}async getEstimateFee(t,{blockIdentifier:e=this.blockIdentifier,skipValidate:r=!0}){const i=new tO(e).identifier;let n={};return rO("0.5",await this.getSpecVersion())||(n={simulation_flags:r?[ig.SKIP_VALIDATE]:[]}),this.fetchEndpoint("starknet_estimateFee",{request:t.map((t=>this.buildTransaction(t,"fee"))),block_id:i,...n})}async invoke(t,e){let r;return eO(e)?r=this.fetchEndpoint("starknet_addInvokeTransaction",{invoke_transaction:{type:rg.INVOKE,sender_address:t.contractAddress,calldata:FC.toHex(t.calldata),version:lg.V3,signature:zz(t.signature),nonce:HI(e.nonce),resource_bounds:e.resourceBounds,tip:HI(e.tip),paymaster_data:e.paymasterData.map((t=>HI(t))),account_deployment_data:e.accountDeploymentData.map((t=>HI(t))),nonce_data_availability_mode:e.nonceDataAvailabilityMode,fee_data_availability_mode:e.feeDataAvailabilityMode}}):(r=this.fetchEndpoint("starknet_addInvokeTransaction",{invoke_transaction:{sender_address:t.contractAddress,calldata:FC.toHex(t.calldata),type:rg.INVOKE,max_fee:HI(e.maxFee||0),version:lg.V1,signature:zz(t.signature),nonce:HI(e.nonce)}}),Kz.warn(uI.legacyTxWarningMessage,{version:lg.V1,type:rg.INVOKE})),this.waitMode?this.waitForTransaction((await r).transaction_hash):r}async declare({contract:t,signature:e,senderAddress:r,compiledClassHash:i},n){let o;if(Uz(t)||eO(n))if(Uz(t)&&!eO(n))o=this.fetchEndpoint("starknet_addDeclareTransaction",{declare_transaction:{type:rg.DECLARE,contract_class:{sierra_program:Sz(t.sierra_program),contract_class_version:t.contract_class_version,entry_points_by_type:t.entry_points_by_type,abi:t.abi},compiled_class_hash:i||"",version:lg.V2,max_fee:HI(n.maxFee||0),signature:zz(e),sender_address:r,nonce:HI(n.nonce)}}),Kz.warn(uI.legacyTxWarningMessage,{version:lg.V2,type:rg.DECLARE});else{if(!Uz(t)||!eO(n))throw Error("declare unspotted parameters");o=this.fetchEndpoint("starknet_addDeclareTransaction",{declare_transaction:{type:rg.DECLARE,sender_address:r,compiled_class_hash:i||"",version:lg.V3,signature:zz(e),nonce:HI(n.nonce),contract_class:{sierra_program:Sz(t.sierra_program),contract_class_version:t.contract_class_version,entry_points_by_type:t.entry_points_by_type,abi:t.abi},resource_bounds:n.resourceBounds,tip:HI(n.tip),paymaster_data:n.paymasterData.map((t=>HI(t))),account_deployment_data:n.accountDeploymentData.map((t=>HI(t))),nonce_data_availability_mode:n.nonceDataAvailabilityMode,fee_data_availability_mode:n.feeDataAvailabilityMode}})}else o=this.fetchEndpoint("starknet_addDeclareTransaction",{declare_transaction:{type:rg.DECLARE,contract_class:{program:t.program,entry_points_by_type:t.entry_points_by_type,abi:t.abi},version:lg.V1,max_fee:HI(n.maxFee||0),signature:zz(e),sender_address:r,nonce:HI(n.nonce)}}),Kz.warn(uI.legacyTxWarningMessage,{version:lg.V1,type:rg.DECLARE});return this.waitMode?this.waitForTransaction((await o).transaction_hash):o}async deployAccount({classHash:t,constructorCalldata:e,addressSalt:r,signature:i},n){let o;return eO(n)?o=this.fetchEndpoint("starknet_addDeployAccountTransaction",{deploy_account_transaction:{type:rg.DEPLOY_ACCOUNT,version:lg.V3,signature:zz(i),nonce:HI(n.nonce),contract_address_salt:HI(r||0),constructor_calldata:FC.toHex(e||[]),class_hash:HI(t),resource_bounds:n.resourceBounds,tip:HI(n.tip),paymaster_data:n.paymasterData.map((t=>HI(t))),nonce_data_availability_mode:n.nonceDataAvailabilityMode,fee_data_availability_mode:n.feeDataAvailabilityMode}}):(o=this.fetchEndpoint("starknet_addDeployAccountTransaction",{deploy_account_transaction:{constructor_calldata:FC.toHex(e||[]),class_hash:HI(t),contract_address_salt:HI(r||0),type:rg.DEPLOY_ACCOUNT,max_fee:HI(n.maxFee||0),version:lg.V1,signature:zz(i),nonce:HI(n.nonce)}}),Kz.warn(uI.legacyTxWarningMessage,{version:lg.V1,type:rg.DEPLOY_ACCOUNT})),this.waitMode?this.waitForTransaction((await o).transaction_hash):o}callContract(t,e=this.blockIdentifier){const r=new tO(e).identifier;return this.fetchEndpoint("starknet_call",{request:{contract_address:t.contractAddress,entry_point_selector:cT(t.entrypoint),calldata:FC.toHex(t.calldata)},block_id:r})}estimateMessageFee(t,e=this.blockIdentifier){const{from_address:r,to_address:i,entry_point_selector:n,payload:o}=t,a={from_address:Vz(r),to_address:HI(i),entry_point_selector:dT(n),payload:iT(o)},s=new tO(e).identifier;return this.fetchEndpoint("starknet_estimateMessageFee",{message:a,block_id:s})}getSyncingStats(){return this.fetchEndpoint("starknet_syncing")}getEvents(t){return this.fetchEndpoint("starknet_getEvents",{filter:t})}buildTransaction(t,e){const r=fO(e);let i;if(eO(t)?i={signature:zz(t.signature),nonce:HI(t.nonce),resource_bounds:t.resourceBounds,tip:HI(t.tip),paymaster_data:t.paymasterData.map((t=>HI(t))),nonce_data_availability_mode:t.nonceDataAvailabilityMode,fee_data_availability_mode:t.feeDataAvailabilityMode,account_deployment_data:t.accountDeploymentData.map((t=>HI(t)))}:(i={signature:zz(t.signature),nonce:HI(t.nonce),max_fee:HI(t.maxFee||0)},Kz.warn(uI.legacyTxWarningMessage,{version:t.version,type:t.type})),t.type===kI.INVOKE)return{type:rg.INVOKE,sender_address:t.contractAddress,calldata:FC.toHex(t.calldata),version:HI(t.version||r.v3),...i};if(t.type===kI.DECLARE)return Uz(t.contract)?{type:t.type,contract_class:{...t.contract,sierra_program:Sz(t.contract.sierra_program)},compiled_class_hash:t.compiledClassHash||"",sender_address:t.senderAddress,version:HI(t.version||r.v3),...i}:{type:t.type,contract_class:t.contract,sender_address:t.senderAddress,version:HI(t.version||r.v1),...i};if(t.type===kI.DEPLOY_ACCOUNT){const{account_deployment_data:e,...n}=i;return{type:t.type,constructor_calldata:FC.toHex(t.constructorCalldata||[]),class_hash:HI(t.classHash),contract_address_salt:HI(t.addressSalt||0),version:HI(t.version||r.v3),...n}}throw Error("RPC buildTransaction received unknown TransactionType")}},wO=class{margin;constructor(t){this.margin=t}estimatedFeeToMaxFee(t){return Oz(t,this.margin?.maxFee)}estimateFeeToBounds(t){return Rz(t,this.margin?.l1BoundMaxAmount,this.margin?.l1BoundMaxPricePerUnit)}parseGetBlockResponse(t){return{status:"PENDING",...t}}parseTransactionReceipt(t){return"actual_fee"in t&&FI(t.actual_fee)?{...t,actual_fee:{amount:t.actual_fee,unit:"FRI"}}:t}parseFeeEstimateResponse(t){const e=t[0];return{overall_fee:VI(e.overall_fee),gas_consumed:VI(e.gas_consumed),gas_price:VI(e.gas_price),unit:e.unit,suggestedMaxFee:this.estimatedFeeToMaxFee(e.overall_fee),resourceBounds:this.estimateFeeToBounds(e),data_gas_consumed:e.data_gas_consumed?VI(e.data_gas_consumed):0n,data_gas_price:e.data_gas_price?VI(e.data_gas_price):0n}}parseFeeEstimateBulkResponse(t){return t.map((t=>({overall_fee:VI(t.overall_fee),gas_consumed:VI(t.gas_consumed),gas_price:VI(t.gas_price),unit:t.unit,suggestedMaxFee:this.estimatedFeeToMaxFee(t.overall_fee),resourceBounds:this.estimateFeeToBounds(t),data_gas_consumed:t.data_gas_consumed?VI(t.data_gas_consumed):0n,data_gas_price:t.data_gas_price?VI(t.data_gas_price):0n})))}parseSimulateTransactionResponse(t){return t.map((t=>({...t,suggestedMaxFee:this.estimatedFeeToMaxFee(t.fee_estimation.overall_fee),resourceBounds:this.estimateFeeToBounds(t.fee_estimation)})))}parseContractClassResponse(t){return{...t,abi:FI(t.abi)?JSON.parse(t.abi):t.abi}}parseL1GasPriceResponse(t){return t.l1_gas_price.price_in_wei}},vO=class t{statusReceipt;value;constructor(e){[this.statusReceipt,this.value]=t.isSuccess(e)?["success",e]:t.isReverted(e)?["reverted",e]:t.isRejected(e)?["rejected",e]:["error",new Error("Unknown response type")];for(const[t]of Object.entries(this))Object.defineProperty(this,t,{enumerable:!1});for(const[t,r]of Object.entries(e))Object.defineProperty(this,t,{enumerable:!0,writable:!1,value:r})}match(t){return this.statusReceipt in t?t[this.statusReceipt](this.value):t._()}isSuccess(){return"success"===this.statusReceipt}isReverted(){return"reverted"===this.statusReceipt}isRejected(){return"rejected"===this.statusReceipt}isError(){return"error"===this.statusReceipt}static isSuccess(t){return t.execution_status===EI.SUCCEEDED}static isReverted(t){return t.execution_status===EI.REVERTED}static isRejected(t){return t.status===EI.REJECTED}},bO={};nN(bO,{TypedDataRevision:()=>pg,encodeData:()=>RO,encodeType:()=>CO,encodeValue:()=>OO,getDependencies:()=>TO,getMessageHash:()=>BO,getStructHash:()=>PO,getTypeHash:()=>zO,isMerkleTreeType:()=>IO,prepareSelector:()=>NO,validateTypedData:()=>SO,verifyMessage:()=>DO});nN({},{MerkleTree:()=>kO,proofMerklePath:()=>MO});var kO=class t{leaves;branches=[];root;hashMethod;constructor(t,e=cz){this.hashMethod=e,this.leaves=t,this.root=this.build(t)}build(e){if(1===e.length)return e[0];e.length!==this.leaves.length&&this.branches.push(e);const r=[];for(let i=0;i<e.length;i+=2)i+1===e.length?r.push(t.hash(e[i],"0x0",this.hashMethod)):r.push(t.hash(e[i],e[i+1],this.hashMethod));return this.build(r)}static hash(t,e,r=cz){const[i,n]=[BigInt(t),BigInt(e)].sort(((t,e)=>t>=e?1:-1));return r(i,n)}getProof(e,r=this.leaves,i=[]){const n=r.indexOf(e);if(-1===n)throw new Error("leaf not found");if(1===r.length)return i;const o=n%2==0,a=(o?r[n+1]:r[n-1])??"0x0",s=[...i,a],h=this.leaves.length===r.length?-1:this.branches.findIndex((t=>t.length===r.length)),u=this.branches[h+1]??[this.root];return this.getProof(t.hash(o?e:a,o?a:e,this.hashMethod),u,s)}};function MO(t,e,r,i=cz){if(0===r.length)return t===e;const[n,...o]=r;return MO(t,kO.hash(e,n,i),o,i)}var _O={u256:JSON.parse('[{ "name": "low", "type": "u128" }, { "name": "high", "type": "u128" }]'),TokenAmount:JSON.parse('[{ "name": "token_address", "type": "ContractAddress" }, { "name": "amount", "type": "u256" }]'),NftId:JSON.parse('[{ "name": "collection_address", "type": "ContractAddress" }, { "name": "token_id", "type": "u256" }]')},EO={[pg.ACTIVE]:{domain:"StarknetDomain",hashMethod:pz,hashMerkleMethod:dz,escapeTypeString:t=>`"${t}"`,presetTypes:_O},[pg.LEGACY]:{domain:"StarkNetDomain",hashMethod:mz,hashMerkleMethod:cz,escapeTypeString:t=>t,presetTypes:{}}};function AO(t,e,{min:r,max:i}){const n=BigInt(t);PI(n>=r&&n<=i,`${n} (${e}) is out of bounds [${r}, ${i}]`)}function jO({types:t,domain:e}){return EO[pg.ACTIVE].domain in t&&e.revision===pg.ACTIVE?pg.ACTIVE:EO[pg.LEGACY].domain in t&&(e.revision??pg.LEGACY)===pg.LEGACY?pg.LEGACY:void 0}function xO(t){try{return HI(t)}catch(e){if(FI(t))return HI(MT(t));throw new Error(`Invalid BigNumberish: ${t}`)}}function SO(t){const e=t;return Boolean(e.message&&e.primaryType&&e.types&&jO(e))}function NO(t){return qI(t)?t:cT(t)}function IO(t){return"merkletree"===t.type}function TO(t,e,r=[],i="",n=pg.LEGACY){let o=[e];return"*"===e[e.length-1]?o=[e.slice(0,-1)]:n===pg.ACTIVE&&("enum"===e?o=[i]:e.match(/^\(.*\)$/)&&(o=e.slice(1,-1).split(",").map((t=>"*"===t[t.length-1]?t.slice(0,-1):t)))),o.filter((e=>!r.includes(e)&&t[e])).reduce(((e,r)=>[...e,...[r,...t[r].reduce(((e,r)=>[...e,...TO(t,r.type,e,r.contains,n).filter((t=>!e.includes(t)))]),[])].filter((t=>!e.includes(t)))]),[])}function CO(t,e,r=pg.LEGACY){const i=r===pg.ACTIVE?{...t,...EO[r].presetTypes}:t,[n,...o]=TO(i,e,void 0,void 0,r),a=n?[n,...o.sort()]:[],s=EO[r].escapeTypeString;return a.map((t=>{const e=i[t].map((t=>{const e="enum"===t.type&&r===pg.ACTIVE?t.contains:t.type,i=e.match(/^\(.*\)$/)?`(${e.slice(1,-1).split(",").map((t=>t?s(t):t)).join(",")})`:s(e);return`${s(t.name)}:${i}`}));return`${s(t)}(${e})`})).join("")}function zO(t,e,r=pg.LEGACY){return cT(CO(t,e,r))}function OO(t,e,r,i={},n=pg.LEGACY){if(t[e])return[e,PO(t,e,r,n)];if(EO[n].presetTypes[e])return[e,PO(EO[n].presetTypes,e,r,n)];if(e.endsWith("*")){const i=r.map((r=>OO(t,e.slice(0,-1),r,void 0,n)[1]));return[e,EO[n].hashMethod(i)]}switch(e){case"enum":if(n===pg.ACTIVE){const[o,a]=Object.entries(r)[0],s=t[i.parent].find((t=>t.name===i.key)),h=t[s.contains],u=h.find((t=>t.name===o)),l=h.indexOf(u),c=u.type.slice(1,-1).split(",").map(((e,r)=>{if(!e)return e;const i=a[r];return OO(t,e,i,void 0,n)[1]}));return[e,EO[n].hashMethod([l,...c])]}return[e,xO(r)];case"merkletree":{const e=function(t,e){if(e.parent&&e.key){const r=t[e.parent].find((t=>t.name===e.key));if(!IO(r))throw new Error(`${e.key} is not a merkle tree`);if(r.contains.endsWith("*"))throw new Error(`Merkle tree contain property must not be an array but was given ${e.key}`);return r.contains}return"raw"}(t,i),o=r.map((r=>OO(t,e,r,void 0,n)[1])),{root:a}=new kO(o,EO[n].hashMerkleMethod);return["felt",a]}case"selector":return["felt",NO(r)];case"string":if(n===pg.ACTIVE){const t=AT(r),i=[t.data.length,...t.data,t.pending_word,t.pending_word_len];return[e,EO[n].hashMethod(i)]}return[e,xO(r)];case"i128":if(n===pg.ACTIVE){const t=BigInt(r);return AO(t,e,ZN),[e,xO(t<0n?UN+t:t)]}return[e,xO(r)];case"timestamp":case"u128":return n===pg.ACTIVE&&AO(r,e,KN),[e,xO(r)];case"felt":case"shortstring":return n===pg.ACTIVE&&AO(xO(r),e,GN),[e,xO(r)];case"ClassHash":case"ContractAddress":return n===pg.ACTIVE&&AO(r,e,GN),[e,xO(r)];case"bool":return n===pg.ACTIVE&&PI($I(r),`Type mismatch for ${e} ${r}`),[e,xO(r)];default:if(n===pg.ACTIVE)throw new Error(`Unsupported type: ${e}`);return[e,xO(r)]}}function RO(t,e,r,i=pg.LEGACY){const n=t[e]??EO[i].presetTypes[e],[o,a]=n.reduce((([n,o],a)=>{if(void 0===r[a.name]||null===r[a.name]&&"enum"!==a.type)throw new Error(`Cannot encode data: missing data for '${a.name}'`);const s=r[a.name],h={parent:e,key:a.name},[u,l]=OO(t,a.type,s,h,i);return[[...n,u],[...o,l]]}),[["felt"],[zO(t,e,i)]]);return[o,a]}function PO(t,e,r,i=pg.LEGACY){return EO[i].hashMethod(RO(t,e,r,i)[1])}function BO(t,e){if(!SO(t))throw new Error("Typed data does not match JSON schema");const r=jO(t),{domain:i,hashMethod:n}=EO[r];return n([MT("StarkNet Message"),PO(t.types,i,t.domain,r),e,PO(t.types,t.primaryType,t.message,r)])}function DO(t,e,r,i){const n=SO(t);if(!hT(t)&&!n)throw new Error("message has a wrong format.");if(n&&void 0===i)throw new Error("When providing a TypedData in message parameter, the accountAddress parameter has to be provided.");if(n&&!hT(i))throw new Error("accountAddress shall be a BigNumberish");const o=n?BO(t,i):HI(t);return zb(Array.isArray(e)?new Pb(BigInt(e[0]),BigInt(e[1])):e,o,HI(r))}var $O=class{responseParser;channel;constructor(t){t&&"channel"in t?(this.channel=t.channel,this.responseParser="responseParser"in t?t.responseParser:new wO):(this.channel=new yO({...t,waitMode:!1}),this.responseParser=new wO(t?.feeMarginPercentage))}fetch(t,e,r=0){return this.channel.fetch(t,e,r)}async getChainId(){return this.channel.getChainId()}async getSpecVersion(){return this.channel.getSpecVersion()}async getNonceForAddress(t,e){return this.channel.getNonceForAddress(t,e)}async getBlock(t){return this.channel.getBlockWithTxHashes(t).then(this.responseParser.parseGetBlockResponse)}async getBlockLatestAccepted(){return this.channel.getBlockLatestAccepted()}async getBlockNumber(){return this.channel.getBlockNumber()}async getBlockWithTxHashes(t){return this.channel.getBlockWithTxHashes(t)}async getBlockWithTxs(t){return this.channel.getBlockWithTxs(t)}async waitForBlock(t="pending",e=5e3){if(t===jI.LATEST)return;const r=await this.getBlockNumber(),i=t===jI.PENDING?r+1:Number(HI(t));if(i<=r)return;const{retries:n}=this.channel;let o=n,a=!1;for(;!a;){if(await this.getBlockNumber()===i?a=!0:await Jz(e),o-=1,o<=0)throw new Error(`waitForBlock() timed-out after ${n} tries.`)}}async getL1GasPrice(t){return this.channel.getBlockWithTxHashes(t).then(this.responseParser.parseL1GasPriceResponse)}async getL1MessageHash(t){const e=await this.channel.getTransactionByHash(t);PI("L1_HANDLER"===e.type,"This L2 transaction is not a L1 message.");const{calldata:r,contract_address:i,entry_point_selector:n,nonce:o}=e;return fT([r[0],i,o,n,r.length-1,...r.slice(1)])}async getBlockWithReceipts(t){if(this.channel instanceof lI.RpcChannel)throw new wI("Unsupported method for RPC version");return this.channel.getBlockWithReceipts(t)}getStateUpdate=this.getBlockStateUpdate;async getBlockStateUpdate(t){return this.channel.getBlockStateUpdate(t)}async getBlockTransactionsTraces(t){return this.channel.getBlockTransactionsTraces(t)}async getBlockTransactionCount(t){return this.channel.getBlockTransactionCount(t)}async getPendingTransactions(){const{transactions:t}=await this.getBlockWithTxHashes(jI.PENDING).then(this.responseParser.parseGetBlockResponse);return Promise.all(t.map((t=>this.getTransactionByHash(t))))}async getTransaction(t){return this.channel.getTransactionByHash(t)}async getTransactionByHash(t){return this.channel.getTransactionByHash(t)}async getTransactionByBlockIdAndIndex(t,e){return this.channel.getTransactionByBlockIdAndIndex(t,e)}async getTransactionReceipt(t){const e=await this.channel.getTransactionReceipt(t),r=this.responseParser.parseTransactionReceipt(e);return new vO(r)}async getTransactionTrace(t){return this.channel.getTransactionTrace(t)}async getTransactionStatus(t){return this.channel.getTransactionStatus(t)}async getSimulateTransaction(t,e){return this.channel.simulateTransaction(t,e).then((t=>this.responseParser.parseSimulateTransactionResponse(t)))}async waitForTransaction(t,e){const r=await this.channel.waitForTransaction(t,e);return new vO(r)}async getStorageAt(t,e,r){return this.channel.getStorageAt(t,e,r)}async getClassHashAt(t,e){return this.channel.getClassHashAt(t,e)}async getClassByHash(t){return this.getClass(t)}async getClass(t,e){return this.channel.getClass(t,e).then(this.responseParser.parseContractClassResponse)}async getClassAt(t,e){return this.channel.getClassAt(t,e).then(this.responseParser.parseContractClassResponse)}async getContractVersion(t,e,{blockIdentifier:r=this.channel.blockIdentifier,compiler:i=!0}={}){let n;if(t)n=await this.getClassAt(t,r);else{if(!e)throw Error("getContractVersion require contractAddress or classHash");n=await this.getClass(e,r)}if(Uz(n)){if(i){return{cairo:"1",compiler:uC(n.abi).compiler}}return{cairo:"1",compiler:void 0}}return{cairo:"0",compiler:"0"}}async getEstimateFee(t,e,r,i){return this.getInvokeEstimateFee(t,e,r,i)}async getInvokeEstimateFee(t,e,r,i){return this.channel.getEstimateFee([{type:kI.INVOKE,...t,...e}],{blockIdentifier:r,skipValidate:i}).then((t=>this.responseParser.parseFeeEstimateResponse(t)))}async getDeclareEstimateFee(t,e,r,i){return this.channel.getEstimateFee([{type:kI.DECLARE,...t,...e}],{blockIdentifier:r,skipValidate:i}).then((t=>this.responseParser.parseFeeEstimateResponse(t)))}async getDeployAccountEstimateFee(t,e,r,i){return this.channel.getEstimateFee([{type:kI.DEPLOY_ACCOUNT,...t,...e}],{blockIdentifier:r,skipValidate:i}).then((t=>this.responseParser.parseFeeEstimateResponse(t)))}async getEstimateFeeBulk(t,e){return this.channel.getEstimateFee(t,e).then((t=>this.responseParser.parseFeeEstimateBulkResponse(t)))}async invokeFunction(t,e){return this.channel.invoke(t,e)}async declareContract(t,e){return this.channel.declare(t,e)}async deployAccountContract(t,e){return this.channel.deployAccount(t,e)}async callContract(t,e){return this.channel.callContract(t,e)}async estimateMessageFee(t,e){return this.channel.estimateMessageFee(t,e)}async getSyncingStats(){return this.channel.getSyncingStats()}async getEvents(t){return this.channel.getEvents(t)}async verifyMessageInStarknet(t,e,r,i,n){const o=SO(t);if(!hT(t)&&!o)throw new Error("message has a wrong format.");if(!hT(r))throw new Error("accountAddress shall be a BigNumberish");const a=o?BO(t,r):HI(t),s=i?[i]:["isValidSignature","is_valid_signature"],h=n||{okResponse:[],nokResponse:["0x0","0x00"],error:["argent/invalid-signature","is invalid, with respect to the public key","INVALID_SIG"]};let u;for(const t of s)try{const i=await this.callContract({contractAddress:HI(r),entrypoint:t,calldata:FC.compile({hash:VI(a).toString(),signature:Tz(e)})});if(h.nokResponse.includes(i[0].toString()))return!1;if(0===h.okResponse.length||h.okResponse.includes(i[0].toString()))return!0;throw Error("signatureVerificationResponse Error: response is not part of known responses")}catch(t){if(h.error.some((e=>t.message.includes(e))))return!1;u=t}throw Error(`Signature verification Error: ${u}`)}async isClassDeclared(t,e){let r;if(!t.classHash&&"contract"in t){r=function(t){const e={...t};if(Uz(t.contract)&&(!t.compiledClassHash&&t.casm&&(e.compiledClassHash=_z(t.casm)),!e.compiledClassHash))throw new Error("Extract compiledClassHash failed, provide (CairoAssembly).casm file or compiledClassHash");if(e.classHash=t.classHash??jz(t.contract),!e.classHash)throw new Error("Extract classHash failed, provide (CompiledContract).json file or classHash");return e}(t).classHash}else{if(!t.classHash)throw Error("contractClassIdentifier type not satisfied");r=t.classHash}try{return await this.getClass(r,e)instanceof Object}catch(t){if(t instanceof wI)return!1;throw t}}async prepareInvocations(t){const e=[];for(const r of t)if(r.type===kI.DECLARE){await this.isClassDeclared("payload"in r?r.payload:r)||e.unshift(r)}else e.push(r);return e}};nN({},{StarknetIdContract:()=>JO,StarknetIdIdentityContract:()=>YO,StarknetIdMulticallContract:()=>XO,StarknetIdPfpContract:()=>iR,StarknetIdPopContract:()=>oR,StarknetIdVerifierContract:()=>eR,dynamicCallData:()=>uR,dynamicFelt:()=>hR,execution:()=>sR,getStarknetIdContract:()=>WO,getStarknetIdIdentityContract:()=>QO,getStarknetIdMulticallContract:()=>tR,getStarknetIdPfpContract:()=>nR,getStarknetIdPopContract:()=>aR,getStarknetIdVerifierContract:()=>rR,isStarkDomain:()=>lR,useDecoded:()=>ZO,useEncoded:()=>KO});var LO="abcdefghijklmnopqrstuvwxyz0123456789-",FO=BigInt(LO.length+1),UO="这来",qO=BigInt(LO.length),VO=BigInt(UO.length),HO=BigInt(UO.length+1);function GO(t){let e=0;for(;t.endsWith(UO[UO.length-1]);)t=t.substring(0,t.length-1),e+=1;return[t,e]}function ZO(t){let e="";return t.forEach((t=>{for(;t!==DN;){const r=t%FO;if(t/=FO,r===BigInt(LO.length)){const r=t/HO;if(r===DN){const i=t%HO;t=r,e+=i===DN?LO[0]:UO[Number(i)-1]}else{e+=UO[Number(t%VO)],t/=VO}}else e+=LO[Number(r)]}const[r,i]=GO(e);i&&(e=r+(i%2==0?UO[UO.length-1].repeat(i/2-1)+UO[0]+LO[1]:UO[UO.length-1].repeat((i-1)/2+1))),e+="."})),e?e.concat("stark"):e}function KO(t){let e=BigInt(0),r=BigInt(1);if(t.endsWith(UO[0]+LO[1])){const[e,r]=GO(t.substring(0,t.length-2));t=e+UO[UO.length-1].repeat(2*(r+1))}else{const[e,r]=GO(t);r&&(t=e+UO[UO.length-1].repeat(1+2*(r-1)))}for(let i=0;i<t.length;i+=1){const n=t[i],o=LO.indexOf(n),a=BigInt(LO.indexOf(n));if(-1!==o)i===t.length-1&&t[i]===LO[0]?(e+=r*qO,r*=FO,r*=FO):(e+=r*a,r*=FO);else if(-1!==UO.indexOf(n)){e+=r*qO,r*=FO;const o=(i===t.length-1?1:0)+UO.indexOf(n);e+=r*BigInt(o),r*=VO}}return e}var JO={MAINNET:"0x6ac597f8116f886fa1c97a23fa4e08299975ecaf6b598873ca6792b9bbfb678",TESTNET_SEPOLIA:"0x154bc2e1af9260b9e66af0e9c46fc757ff893b3ff6a85718a810baf1474"};function WO(t){switch(t){case"0x534e5f4d41494e":return JO.MAINNET;case"0x534e5f5345504f4c4941":return JO.TESTNET_SEPOLIA;default:throw new Error("Starknet.id is not yet deployed on this network")}}var YO={MAINNET:"0x05dbdedc203e92749e2e746e2d40a768d966bd243df04a6b712e222bc040a9af",TESTNET_SEPOLIA:"0x3697660a0981d734780731949ecb2b4a38d6a58fc41629ed611e8defda"};function QO(t){switch(t){case"0x534e5f4d41494e":return YO.MAINNET;case"0x534e5f5345504f4c4941":return YO.TESTNET_SEPOLIA;default:throw new Error("Starknet.id verifier contract is not yet deployed on this network")}}var XO="0x034ffb8f4452df7a613a0210824d6414dbadcddce6c6e19bf4ddc9e22ce5f970";function tR(t){switch(t){case"0x534e5f4d41494e":case"0x534e5f5345504f4c4941":return XO;default:throw new Error("Starknet.id multicall contract is not yet deployed on this network")}}var eR={MAINNET:"0x07d14dfd8ee95b41fce179170d88ba1f0d5a512e13aeb232f19cfeec0a88f8bf",TESTNET_SEPOLIA:"0x60B94fEDe525f815AE5E8377A463e121C787cCCf3a36358Aa9B18c12c4D566"};function rR(t){switch(t){case"0x534e5f4d41494e":return eR.MAINNET;case"0x534e5f5345504f4c4941":return eR.TESTNET_SEPOLIA;default:throw new Error("Starknet.id verifier contract is not yet deployed on this network")}}var iR={MAINNET:"0x070aaa20ec4a46da57c932d9fd89ca5e6bb9ca3188d3df361a32306aff7d59c7",TESTNET_SEPOLIA:"0x9e7bdb8dabd02ea8cfc23b1d1c5278e46490f193f87516ed5ff2dfec02"};function nR(t){switch(t){case"0x534e5f4d41494e":return iR.MAINNET;case"0x534e5f5345504f4c4941":return iR.TESTNET_SEPOLIA;default:throw new Error("Starknet.id profile picture verifier contract is not yet deployed on this network")}}var oR={MAINNET:"0x0293eb2ba9862f762bd3036586d5755a782bd22e6f5028320f1d0405fd47bff4",TESTNET_SEPOLIA:"0x15ae88ae054caa74090b89025c1595683f12edf7a4ed2ad0274de3e1d4a"};function aR(t){switch(t){case"0x534e5f4d41494e":return oR.MAINNET;case"0x534e5f5345504f4c4941":return oR.TESTNET_SEPOLIA;default:throw new Error("Starknet.id proof of personhood verifier contract is not yet deployed on this network")}}function sR(t,e,r){return new mC({Static:t,IfEqual:e?dC(e[0],e[1],e[2]):void 0,IfNotEqual:r?dC(r[0],r[1],r[2]):void 0})}function hR(t,e){return new mC({Hardcoded:t,Reference:e?dC(e[0],e[1]):void 0})}function uR(t,e,r){return new mC({Hardcoded:t,Reference:e?dC(e[0],e[1]):void 0,ArrayReference:r?dC(r[0],r[1]):void 0})}function lR(t){return/^(?:[a-z0-9-]{1,48}(?:[a-z0-9-]{1,48}[a-z0-9-])?\.)*[a-z0-9-]{1,48}\.stark$/.test(t)}var cR=class extends(QS($O,class t{async getStarkName(e,r){return t.getStarkName(this,e,r)}async getAddressFromStarkName(e,r){return t.getAddressFromStarkName(this,e,r)}async getStarkProfile(e,r,i,n,o,a,s){return t.getStarkProfile(this,e,r,i,n,o,a,s)}static async getStarkName(t,e,r){const i=await t.getChainId(),n=r??WO(i);try{const r=await t.callContract({contractAddress:n,entrypoint:"address_to_domain",calldata:FC.compile({address:e,hint:[]})}),i=ZO(r.map((t=>BigInt(t))).slice(1));if(!i)throw Error("Starkname not found");return i}catch(t){if(t instanceof Error&&"Starkname not found"===t.message)throw t;throw Error("Could not get stark name")}}static async getAddressFromStarkName(t,e,r){const i=e.endsWith(".stark")?e:`${e}.stark`;if(!lR(i))throw new Error("Invalid domain, must be a valid .stark domain");const n=await t.getChainId(),o=r??WO(n);try{const e=i.replace(".stark","").split(".").map((t=>KO(t).toString(10)));return(await t.callContract({contractAddress:o,entrypoint:"domain_to_address",calldata:FC.compile({domain:e,hint:[]})}))[0]}catch{throw Error("Could not get address from stark name")}}static async getStarkProfile(t,e,r,i,n,o,a,s){const h=await t.getChainId(),u=r??WO(h),l=i??QO(h),c=n??rR(h),d=o??nR(h),f=a??aR(h),m=s??tR(h);try{const r=[{execution:sR({}),to:uR(u),selector:uR(cT("address_to_domain")),calldata:[uR(e),uR("0")]},{execution:sR({}),to:hR(u),selector:hR(cT("domain_to_id")),calldata:[uR(void 0,void 0,[0,0])]},{execution:sR({}),to:hR(l),selector:hR(cT("get_verifier_data")),calldata:[uR(void 0,[1,0]),uR(MT("twitter")),uR(c),uR("0")]},{execution:sR({}),to:hR(l),selector:hR(cT("get_verifier_data")),calldata:[uR(void 0,[1,0]),uR(MT("github")),uR(c),uR("0")]},{execution:sR({}),to:hR(l),selector:hR(cT("get_verifier_data")),calldata:[uR(void 0,[1,0]),uR(MT("discord")),uR(c),uR("0")]},{execution:sR({}),to:hR(l),selector:hR(cT("get_verifier_data")),calldata:[uR(void 0,[1,0]),uR(MT("proof_of_personhood")),uR(f),uR("0")]},{execution:sR({}),to:hR(l),selector:hR(cT("get_verifier_data")),calldata:[uR(void 0,[1,0]),uR(MT("nft_pp_contract")),uR(d),uR("0")]},{execution:sR({}),to:hR(l),selector:hR(cT("get_extended_verifier_data")),calldata:[uR(void 0,[1,0]),uR(MT("nft_pp_id")),uR("2"),uR(d),uR("0")]},{execution:sR(void 0,void 0,[6,0,0]),to:hR(void 0,[6,0]),selector:hR(cT("tokenURI")),calldata:[uR(void 0,[7,1]),uR(void 0,[7,2])]}],i=await t.callContract({contractAddress:m,entrypoint:"aggregate",calldata:FC.compile({calls:r})});if(Array.isArray(i)){const t=parseInt(i[0],16),e=[];let r=1;for(let n=0;n<t&&r<i.length;n+=1){const t=parseInt(i[r],16);r+=1;const n=i.slice(r,r+t);e.push(n),r+=t}const n=ZO(e[0].slice(1).map((t=>BigInt(t)))),o="0x0"!==e[2][0]?BigInt(e[2][0]).toString():void 0,a="0x0"!==e[3][0]?BigInt(e[3][0]).toString():void 0,s="0x0"!==e[4][0]?BigInt(e[4][0]).toString():void 0,h="0x1"===e[5][0],u="0x9"===i[0]?e[8].slice(1).map((t=>_T(t))).join(""):void 0;return{name:n,twitter:o,github:a,discord:s,proofOfPersonhood:h,profilePicture:u||`https://starknet.id/api/identicons/${BigInt(e[1][0]).toString()}`}}throw Error("Error while calling aggregate function")}catch(t){if(t instanceof Error)throw t;throw Error("Could not get user stark profile data from address")}}})){},dR=new $O({default:!0});function fR(t){return new RT(t).toBigInt()}function mR(t){return RT.is(t)}function pR(t){return new RT(t).toUint256HexString()}function gR(t){const e=function(t){const e=HI(IN(t.toString()));return IN(NN(e).padStart(64,"0"))}(t);if(!e.match(/^(0x)?[0-9a-fA-F]{64}$/))throw new Error("Invalid Address Format");return YI(e,DN,VN-1n,"Starknet Address"),e}nN({},{UINT_128_MAX:()=>ST,UINT_256_MAX:()=>NT,bnToUint256:()=>pR,isUint256:()=>mR,uint256ToBN:()=>fR});function yR(t){return"event"===t.type}function wR(t){const e=t.filter((t=>yR(t)&&"struct"===t.kind)),r=t.filter((t=>yR(t)&&"enum"===t.kind)),i=e.reduce(((t,e)=>{let i=[],{name:n}=e,o=!1;const a=t=>t.type===n;for(;;){const t=r.find((t=>t.variants.some(a)));if(BI(t))break;const e=t.variants.find(a);i.unshift(e.name),"flat"===e.kind&&(o=!0),n=t.name}if(0===i.length)throw new Error("inconsistency in ABI events definition.");o&&(i=[i[i.length-1]]);const s=i.pop();let h={[IN(Yb(EN(s)).toString(16))]:e};for(;i.length>0;)h={[IN(Yb(EN(i.pop())).toString(16))]:h};return h={...h},bR(t,h)}),{});return i}function vR(t){return sC(t)?wR(t):function(t){return t.filter((t=>"event"===t.type)).reduce(((t,e)=>{const r=e.name,i={...e};return i.name=r,{...t,[IN(Yb(EN(r)).toString(16))]:i}}),{})}(t)}function bR(t,e){const r={...t};return UI(t)&&UI(e)&&Object.keys(e).forEach((i=>{UI(e[i])?i in t?r[i]=bR(t[i],e[i]):Object.assign(r,{[i]:e[i]}):Object.assign(r,{[i]:e[i]})})),r}function kR(t,e,r,i){const n=t.flat().reduce(((t,n)=>{let o=e[n.keys.shift()??0];if(!o)return t;for(;!o.name;){const t=n.keys.shift();PI(!!t,'Not enough data in "keys" property of this event.'),o=o[t]}const a={};a[o.name]={};const s=n.keys[Symbol.iterator](),h=n.data[Symbol.iterator](),u=o.members?.filter((t=>"key"===t.kind))||o.keys,l=o.members?.filter((t=>"data"===t.kind))||o.data;return u.forEach((t=>{a[o.name][t.name]=CC(s,t,r,i,a[o.name])})),l.forEach((t=>{a[o.name][t.name]=CC(h,t,r,i,a[o.name])})),"block_hash"in n&&(a.block_hash=n.block_hash),"block_number"in n&&(a.block_number=n.block_number),"transaction_hash"in n&&(a.transaction_hash=n.transaction_hash),t.push(a),t}),[]);return n}function MR(t){if(!t.events?.length)throw new Error("UDC emitted event is empty");const e=t.events.find((t=>WI(t.from_address)===WI(tI.ADDRESS)))||{data:[]};return{transaction_hash:t.transaction_hash,contract_address:e.data[0],address:e.data[0],deployer:e.data[1],unique:e.data[2],classHash:e.data[3],calldata_len:e.data[4],calldata:e.data.slice(5,5+parseInt(e.data[4],16)),salt:e.data[e.data.length-1]}}nN({},{getAbiEvents:()=>vR,isAbiEvent:()=>yR,parseEvents:()=>kR,parseUDCEvent:()=>MR});function _R(t){const e=t.calldata??[],r=Array.isArray(e)?e:FC.compile(e);return{to:t.contractAddress,selector:cT(t.entrypoint),calldata:r}}function ER(t,e){const r=_R(t);return"1"===e?{...r,calldata_len:r.calldata.length,calldata:r.calldata}:{To:r.to,Selector:r.selector,Calldata:r.calldata}}function AR(t,e){return{name:"Account.execute_from_outside",version:e,chainId:t,..."2"===e?{revision:"1"}:{}}}function jR(t,e,r,i,n){return"1"===n?{types:CI,primaryType:"OutsideExecution",domain:AR(t,n),message:{...e,nonce:r,calls_len:i.length,calls:i.map((t=>ER(t,n)))}}:{types:zI,primaryType:"OutsideExecution",domain:AR(t,n),message:{Caller:e.caller,Nonce:r,"Execute After":e.execute_after,"Execute Before":e.execute_before,Calls:i.map((t=>ER(t,n)))}}}function xR(t){const e=t.outsideExecution,r=Tz(t.signature);return FC.compile({outside_execution:e,signature:r})}function SR(t){return(Array.isArray(t)?t:[t]).map((t=>{let e;if("1"===t.version)e="execute_from_outside";else{if("2"!==t.version)throw new Error("Unsupported OutsideExecution version");e="execute_from_outside_v2"}return{contractAddress:HI(t.signerAddress),entrypoint:e,calldata:xR(t)}}))}nN({},{buildExecuteFromOutsideCall:()=>SR,buildExecuteFromOutsideCallData:()=>xR,getOutsideCall:()=>_R,getTypedData:()=>jR});async function NR(t,e,r){const i={contractAddress:HI(e),entrypoint:"supports_interface",calldata:[HI(r)]};try{const e=await t.callContract(i);return 0n!==BigInt(e[0])}catch{return!1}}nN({},{supportsInterface:()=>NR});function IR(t,e=!1){return t.request({type:"wallet_requestAccounts",params:{silent_mode:e}})}function TR(t){return t.request({type:"wallet_getPermissions"})}function CR(t,e){return t.request({type:"wallet_watchAsset",params:e})}function zR(t,e){return t.request({type:"wallet_addStarknetChain",params:e})}function OR(t,e){return t.request({type:"wallet_switchStarknetChain",params:{chainId:e}})}function RR(t){return t.request({type:"wallet_requestChainId"})}function PR(t){return t.request({type:"wallet_deploymentData"})}function BR(t,e){return t.request({type:"wallet_addInvokeTransaction",params:e})}function DR(t,e){return t.request({type:"wallet_addDeclareTransaction",params:e})}function $R(t,e){return t.request({type:"wallet_signTypedData",params:e})}function LR(t){return t.request({type:"wallet_supportedSpecs"})}function FR(t,e){t.on("accountsChanged",e)}function UR(t,e){t.on("networkChanged",e)}nN({},{addDeclareTransaction:()=>DR,addInvokeTransaction:()=>BR,addStarknetChain:()=>zR,deploymentData:()=>PR,getPermissions:()=>TR,onAccountChange:()=>FR,onNetworkChanged:()=>UR,requestAccounts:()=>IR,requestChainId:()=>RR,signMessage:()=>$R,supportedSpecs:()=>LR,switchStarknetChain:()=>OR,watchAsset:()=>CR});var qR=t=>{const e=t[t.length-1];return"object"==typeof e&&["blockIdentifier","parseRequest","parseResponse","formatResponse","maxFee","nonce","signature","addressSalt"].some((t=>t in e))?{args:t,options:t.pop()}:{args:t}};function VR(t,e){return async function(...r){const i=qR(r);return t.call(e.name,i.args,{parseRequest:!0,parseResponse:!0,...i.options})}}function HR(t,e){return"view"===e.stateMutability||"view"===e.state_mutability?VR(t,e):function(t,e){return async function(...r){const i=qR(r);return t.invoke(e.name,i.args,{parseRequest:!0,...i.options})}}(t,e)}function GR(t,e){return function(...r){return t.estimate(e.name,r)}}function ZR(t,e){return Array.isArray(t)&&"__compiled__"in t?t:Array.isArray(t)&&Array.isArray(t[0])&&"__compiled__"in t[0]?t[0]:e()}var KR=class{abi;address;providerOrAccount;deployTransactionHash;structs;events;functions;callStatic;populateTransaction;estimateFee;callData;constructor(t,e,r=dR){this.address=e&&e.toLowerCase(),this.providerOrAccount=r,this.callData=new FC(t),this.structs=FC.getAbiStruct(t),this.events=vR(t);const i=MC(t);this.abi=i.getLegacyFormat();const n={enumerable:!0,value:{},writable:!1};Object.defineProperties(this,{functions:{enumerable:!0,value:{},writable:!1},callStatic:{enumerable:!0,value:{},writable:!1},populateTransaction:{enumerable:!0,value:{},writable:!1},estimateFee:{enumerable:!0,value:{},writable:!1}}),this.abi.forEach((t=>{if("function"!==t.type)return;const e=t.name;var r,i;this[e]||Object.defineProperty(this,e,{...n,value:HR(this,t)}),this.functions[e]||Object.defineProperty(this.functions,e,{...n,value:HR(this,t)}),this.callStatic[e]||Object.defineProperty(this.callStatic,e,{...n,value:VR(this,t)}),this.populateTransaction[e]||Object.defineProperty(this.populateTransaction,e,{...n,value:(r=this,i=t,function(...t){return r.populate(i.name,t)})}),this.estimateFee[e]||Object.defineProperty(this.estimateFee,e,{...n,value:GR(this,t)})}))}attach(t){this.address=t}connect(t){this.providerOrAccount=t}async deployed(){return this.deployTransactionHash&&(await this.providerOrAccount.waitForTransaction(this.deployTransactionHash),this.deployTransactionHash=void 0),this}async call(t,e=[],{parseRequest:r=!0,parseResponse:i=!0,formatResponse:n,blockIdentifier:o}={}){PI(null!==this.address,"contract is not connected to an address");const a=ZR(e,(()=>r?(this.callData.validate(xI.CALL,t,e),this.callData.compile(t,e)):(Kz.warn("Call skipped parsing but provided rawArgs, possible malfunction request"),e)));return this.providerOrAccount.callContract({contractAddress:this.address,calldata:a,entrypoint:t},o).then((e=>i?n?this.callData.format(t,e,n):this.callData.parse(t,e):e))}invoke(t,e=[],{parseRequest:r=!0,maxFee:i,nonce:n,signature:o}={}){PI(null!==this.address,"contract is not connected to an address");const a=ZR(e,(()=>r?(this.callData.validate(xI.INVOKE,t,e),this.callData.compile(t,e)):(Kz.warn("Invoke skipped parsing but provided rawArgs, possible malfunction request"),e))),s={contractAddress:this.address,calldata:a,entrypoint:t};if("execute"in this.providerOrAccount)return this.providerOrAccount.execute(s,void 0,{maxFee:i,nonce:n});if(!n)throw new Error("Nonce is required when invoking a function without an account");return Kz.warn(`Invoking ${t} without an account. This will not work on a public node.`),this.providerOrAccount.invokeFunction({...s,signature:o},{nonce:n})}async estimate(t,e=[]){PI(null!==this.address,"contract is not connected to an address"),ZR(e,(()=>!1))||this.callData.validate(xI.INVOKE,t,e);const r=this.populate(t,e);if("estimateInvokeFee"in this.providerOrAccount)return this.providerOrAccount.estimateInvokeFee(r);throw Error("Contract must be connected to the account contract to estimate")}populate(t,e=[]){const r=ZR(e,(()=>this.callData.compile(t,e)));return{contractAddress:this.address,entrypoint:t,calldata:r}}parseEvents(t){let e;return t.match({success:t=>{const r=t.events?.map((e=>({block_hash:t.block_hash,block_number:t.block_number,transaction_hash:t.transaction_hash,...e}))).filter((t=>WI(t.from_address)===WI(this.address)),[])||[];e=kR(r,this.events,this.structs,FC.getAbiEnum(this.abi))},_:()=>{throw Error("This transaction was not successful.")}}),e}isCairo1(){return jT.isCairo1Abi(this.abi)}async getVersion(){return this.providerOrAccount.getContractVersion(this.address)}typedv2(t){return this}};const JR={SN_MAIN:"https://starknet-mainnet.public.blastapi.io",SN_SEPOLIA:"https://starknet-sepolia.public.blastapi.io"},WR=[{name:"argent::common::account::IAccount",type:"interface",items:[{name:"is_valid_signature",type:"function",inputs:[{name:"hash",type:"core::felt252"},{name:"signature",type:"core::array::Array::<core::felt252>"}],outputs:[{type:"core::felt252"}],state_mutability:"view"}]}];function YR(t,e){var r;if(!JR[t])throw new Error("Invalid network");return new cR({nodeUrl:null!==(r=null==e?void 0:e.broviderUrl)&&void 0!==r?r:JR[t]})}function QR(t){return!!t.primaryType&&!!t.types.StarkNetDomain}function XR(t,e){const{domain:r,types:i,primaryType:n,message:o}=t;return bO.getMessageHash({types:i,primaryType:n,domain:r,message:o},e)}var tP=Object.freeze({__proto__:null,isStarknetMessage:QR,getHash:XR,default:function(t,e,i){return r(this,arguments,void 0,(function*(t,e,r,i="SN_MAIN",n={}){try{const o=new KR(WR,t,YR(i,n));if(e.length<2)throw new Error("Invalid signature format");const a=yield o.is_valid_signature(XR(r,t),e.slice(-2));return ch.from(a).eq(ch.from("370462705988"))}catch(t){if(t.message.includes("Contract not found"))throw new Error("Contract not deployed");throw t}}))}});function eP(t){return Jt(vi(t))}var rP=a((function(t){!function(t,e){function r(t,e){if(!t)throw new Error(e||"Assertion failed")}function i(t,e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}function n(t,e,r){if(n.isBN(t))return t;this.negative=0,this.words=null,this.length=0,this.red=null,null!==t&&("le"!==e&&"be"!==e||(r=e,e=10),this._init(t||0,e||10,r||"be"))}var o;"object"==typeof t?t.exports=n:e.BN=n,n.BN=n,n.wordSize=26;try{o="undefined"!=typeof window&&void 0!==window.Buffer?window.Buffer:Pt.Buffer}catch(t){}function a(t,e){var i=t.charCodeAt(e);return i>=48&&i<=57?i-48:i>=65&&i<=70?i-55:i>=97&&i<=102?i-87:void r(!1,"Invalid character in "+t)}function s(t,e,r){var i=a(t,r);return r-1>=e&&(i|=a(t,r-1)<<4),i}function h(t,e,i,n){for(var o=0,a=0,s=Math.min(t.length,i),h=e;h<s;h++){var u=t.charCodeAt(h)-48;o*=n,a=u>=49?u-49+10:u>=17?u-17+10:u,r(u>=0&&a<n,"Invalid character"),o+=a}return o}function u(t,e){t.words=e.words,t.length=e.length,t.negative=e.negative,t.red=e.red}if(n.isBN=function(t){return t instanceof n||null!==t&&"object"==typeof t&&t.constructor.wordSize===n.wordSize&&Array.isArray(t.words)},n.max=function(t,e){return t.cmp(e)>0?t:e},n.min=function(t,e){return t.cmp(e)<0?t:e},n.prototype._init=function(t,e,i){if("number"==typeof t)return this._initNumber(t,e,i);if("object"==typeof t)return this._initArray(t,e,i);"hex"===e&&(e=16),r(e===(0|e)&&e>=2&&e<=36);var n=0;"-"===(t=t.toString().replace(/\s+/g,""))[0]&&(n++,this.negative=1),n<t.length&&(16===e?this._parseHex(t,n,i):(this._parseBase(t,e,n),"le"===i&&this._initArray(this.toArray(),e,i)))},n.prototype._initNumber=function(t,e,i){t<0&&(this.negative=1,t=-t),t<67108864?(this.words=[67108863&t],this.length=1):t<4503599627370496?(this.words=[67108863&t,t/67108864&67108863],this.length=2):(r(t<9007199254740992),this.words=[67108863&t,t/67108864&67108863,1],this.length=3),"le"===i&&this._initArray(this.toArray(),e,i)},n.prototype._initArray=function(t,e,i){if(r("number"==typeof t.length),t.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(t.length/3),this.words=new Array(this.length);for(var n=0;n<this.length;n++)this.words[n]=0;var o,a,s=0;if("be"===i)for(n=t.length-1,o=0;n>=0;n-=3)a=t[n]|t[n-1]<<8|t[n-2]<<16,this.words[o]|=a<<s&67108863,this.words[o+1]=a>>>26-s&67108863,(s+=24)>=26&&(s-=26,o++);else if("le"===i)for(n=0,o=0;n<t.length;n+=3)a=t[n]|t[n+1]<<8|t[n+2]<<16,this.words[o]|=a<<s&67108863,this.words[o+1]=a>>>26-s&67108863,(s+=24)>=26&&(s-=26,o++);return this._strip()},n.prototype._parseHex=function(t,e,r){this.length=Math.ceil((t.length-e)/6),this.words=new Array(this.length);for(var i=0;i<this.length;i++)this.words[i]=0;var n,o=0,a=0;if("be"===r)for(i=t.length-1;i>=e;i-=2)n=s(t,e,i)<<o,this.words[a]|=67108863&n,o>=18?(o-=18,a+=1,this.words[a]|=n>>>26):o+=8;else for(i=(t.length-e)%2==0?e+1:e;i<t.length;i+=2)n=s(t,e,i)<<o,this.words[a]|=67108863&n,o>=18?(o-=18,a+=1,this.words[a]|=n>>>26):o+=8;this._strip()},n.prototype._parseBase=function(t,e,r){this.words=[0],this.length=1;for(var i=0,n=1;n<=67108863;n*=e)i++;i--,n=n/e|0;for(var o=t.length-r,a=o%i,s=Math.min(o,o-a)+r,u=0,l=r;l<s;l+=i)u=h(t,l,l+i,e),this.imuln(n),this.words[0]+u<67108864?this.words[0]+=u:this._iaddn(u);if(0!==a){var c=1;for(u=h(t,l,t.length,e),l=0;l<a;l++)c*=e;this.imuln(c),this.words[0]+u<67108864?this.words[0]+=u:this._iaddn(u)}this._strip()},n.prototype.copy=function(t){t.words=new Array(this.length);for(var e=0;e<this.length;e++)t.words[e]=this.words[e];t.length=this.length,t.negative=this.negative,t.red=this.red},n.prototype._move=function(t){u(t,this)},n.prototype.clone=function(){var t=new n(null);return this.copy(t),t},n.prototype._expand=function(t){for(;this.length<t;)this.words[this.length++]=0;return this},n.prototype._strip=function(){for(;this.length>1&&0===this.words[this.length-1];)this.length--;return this._normSign()},n.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},"undefined"!=typeof Symbol&&"function"==typeof Symbol.for)try{n.prototype[Symbol.for("nodejs.util.inspect.custom")]=l}catch(t){n.prototype.inspect=l}else n.prototype.inspect=l;function l(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"}var c=["","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"],d=[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],f=[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];n.prototype.toString=function(t,e){var i;if(e=0|e||1,16===(t=t||10)||"hex"===t){i="";for(var n=0,o=0,a=0;a<this.length;a++){var s=this.words[a],h=(16777215&(s<<n|o)).toString(16);o=s>>>24-n&16777215,(n+=2)>=26&&(n-=26,a--),i=0!==o||a!==this.length-1?c[6-h.length]+h+i:h+i}for(0!==o&&(i=o.toString(16)+i);i.length%e!=0;)i="0"+i;return 0!==this.negative&&(i="-"+i),i}if(t===(0|t)&&t>=2&&t<=36){var u=d[t],l=f[t];i="";var m=this.clone();for(m.negative=0;!m.isZero();){var p=m.modrn(l).toString(t);i=(m=m.idivn(l)).isZero()?p+i:c[u-p.length]+p+i}for(this.isZero()&&(i="0"+i);i.length%e!=0;)i="0"+i;return 0!==this.negative&&(i="-"+i),i}r(!1,"Base should be between 2 and 36")},n.prototype.toNumber=function(){var t=this.words[0];return 2===this.length?t+=67108864*this.words[1]:3===this.length&&1===this.words[2]?t+=4503599627370496+67108864*this.words[1]:this.length>2&&r(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-t:t},n.prototype.toJSON=function(){return this.toString(16,2)},o&&(n.prototype.toBuffer=function(t,e){return this.toArrayLike(o,t,e)}),n.prototype.toArray=function(t,e){return this.toArrayLike(Array,t,e)};function m(t,e,r){r.negative=e.negative^t.negative;var i=t.length+e.length|0;r.length=i,i=i-1|0;var n=0|t.words[0],o=0|e.words[0],a=n*o,s=67108863&a,h=a/67108864|0;r.words[0]=s;for(var u=1;u<i;u++){for(var l=h>>>26,c=67108863&h,d=Math.min(u,e.length-1),f=Math.max(0,u-t.length+1);f<=d;f++){var m=u-f|0;l+=(a=(n=0|t.words[m])*(o=0|e.words[f])+c)/67108864|0,c=67108863&a}r.words[u]=0|c,h=0|l}return 0!==h?r.words[u]=0|h:r.length--,r._strip()}n.prototype.toArrayLike=function(t,e,i){this._strip();var n=this.byteLength(),o=i||Math.max(1,n);r(n<=o,"byte array longer than desired length"),r(o>0,"Requested array length <= 0");var a=function(t,e){return t.allocUnsafe?t.allocUnsafe(e):new t(e)}(t,o);return this["_toArrayLike"+("le"===e?"LE":"BE")](a,n),a},n.prototype._toArrayLikeLE=function(t,e){for(var r=0,i=0,n=0,o=0;n<this.length;n++){var a=this.words[n]<<o|i;t[r++]=255&a,r<t.length&&(t[r++]=a>>8&255),r<t.length&&(t[r++]=a>>16&255),6===o?(r<t.length&&(t[r++]=a>>24&255),i=0,o=0):(i=a>>>24,o+=2)}if(r<t.length)for(t[r++]=i;r<t.length;)t[r++]=0},n.prototype._toArrayLikeBE=function(t,e){for(var r=t.length-1,i=0,n=0,o=0;n<this.length;n++){var a=this.words[n]<<o|i;t[r--]=255&a,r>=0&&(t[r--]=a>>8&255),r>=0&&(t[r--]=a>>16&255),6===o?(r>=0&&(t[r--]=a>>24&255),i=0,o=0):(i=a>>>24,o+=2)}if(r>=0)for(t[r--]=i;r>=0;)t[r--]=0},Math.clz32?n.prototype._countBits=function(t){return 32-Math.clz32(t)}:n.prototype._countBits=function(t){var e=t,r=0;return e>=4096&&(r+=13,e>>>=13),e>=64&&(r+=7,e>>>=7),e>=8&&(r+=4,e>>>=4),e>=2&&(r+=2,e>>>=2),r+e},n.prototype._zeroBits=function(t){if(0===t)return 26;var e=t,r=0;return 0==(8191&e)&&(r+=13,e>>>=13),0==(127&e)&&(r+=7,e>>>=7),0==(15&e)&&(r+=4,e>>>=4),0==(3&e)&&(r+=2,e>>>=2),0==(1&e)&&r++,r},n.prototype.bitLength=function(){var t=this.words[this.length-1],e=this._countBits(t);return 26*(this.length-1)+e},n.prototype.zeroBits=function(){if(this.isZero())return 0;for(var t=0,e=0;e<this.length;e++){var r=this._zeroBits(this.words[e]);if(t+=r,26!==r)break}return t},n.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},n.prototype.toTwos=function(t){return 0!==this.negative?this.abs().inotn(t).iaddn(1):this.clone()},n.prototype.fromTwos=function(t){return this.testn(t-1)?this.notn(t).iaddn(1).ineg():this.clone()},n.prototype.isNeg=function(){return 0!==this.negative},n.prototype.neg=function(){return this.clone().ineg()},n.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},n.prototype.iuor=function(t){for(;this.length<t.length;)this.words[this.length++]=0;for(var e=0;e<t.length;e++)this.words[e]=this.words[e]|t.words[e];return this._strip()},n.prototype.ior=function(t){return r(0==(this.negative|t.negative)),this.iuor(t)},n.prototype.or=function(t){return this.length>t.length?this.clone().ior(t):t.clone().ior(this)},n.prototype.uor=function(t){return this.length>t.length?this.clone().iuor(t):t.clone().iuor(this)},n.prototype.iuand=function(t){var e;e=this.length>t.length?t:this;for(var r=0;r<e.length;r++)this.words[r]=this.words[r]&t.words[r];return this.length=e.length,this._strip()},n.prototype.iand=function(t){return r(0==(this.negative|t.negative)),this.iuand(t)},n.prototype.and=function(t){return this.length>t.length?this.clone().iand(t):t.clone().iand(this)},n.prototype.uand=function(t){return this.length>t.length?this.clone().iuand(t):t.clone().iuand(this)},n.prototype.iuxor=function(t){var e,r;this.length>t.length?(e=this,r=t):(e=t,r=this);for(var i=0;i<r.length;i++)this.words[i]=e.words[i]^r.words[i];if(this!==e)for(;i<e.length;i++)this.words[i]=e.words[i];return this.length=e.length,this._strip()},n.prototype.ixor=function(t){return r(0==(this.negative|t.negative)),this.iuxor(t)},n.prototype.xor=function(t){return this.length>t.length?this.clone().ixor(t):t.clone().ixor(this)},n.prototype.uxor=function(t){return this.length>t.length?this.clone().iuxor(t):t.clone().iuxor(this)},n.prototype.inotn=function(t){r("number"==typeof t&&t>=0);var e=0|Math.ceil(t/26),i=t%26;this._expand(e),i>0&&e--;for(var n=0;n<e;n++)this.words[n]=67108863&~this.words[n];return i>0&&(this.words[n]=~this.words[n]&67108863>>26-i),this._strip()},n.prototype.notn=function(t){return this.clone().inotn(t)},n.prototype.setn=function(t,e){r("number"==typeof t&&t>=0);var i=t/26|0,n=t%26;return this._expand(i+1),this.words[i]=e?this.words[i]|1<<n:this.words[i]&~(1<<n),this._strip()},n.prototype.iadd=function(t){var e,r,i;if(0!==this.negative&&0===t.negative)return this.negative=0,e=this.isub(t),this.negative^=1,this._normSign();if(0===this.negative&&0!==t.negative)return t.negative=0,e=this.isub(t),t.negative=1,e._normSign();this.length>t.length?(r=this,i=t):(r=t,i=this);for(var n=0,o=0;o<i.length;o++)e=(0|r.words[o])+(0|i.words[o])+n,this.words[o]=67108863&e,n=e>>>26;for(;0!==n&&o<r.length;o++)e=(0|r.words[o])+n,this.words[o]=67108863&e,n=e>>>26;if(this.length=r.length,0!==n)this.words[this.length]=n,this.length++;else if(r!==this)for(;o<r.length;o++)this.words[o]=r.words[o];return this},n.prototype.add=function(t){var e;return 0!==t.negative&&0===this.negative?(t.negative=0,e=this.sub(t),t.negative^=1,e):0===t.negative&&0!==this.negative?(this.negative=0,e=t.sub(this),this.negative=1,e):this.length>t.length?this.clone().iadd(t):t.clone().iadd(this)},n.prototype.isub=function(t){if(0!==t.negative){t.negative=0;var e=this.iadd(t);return t.negative=1,e._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(t),this.negative=1,this._normSign();var r,i,n=this.cmp(t);if(0===n)return this.negative=0,this.length=1,this.words[0]=0,this;n>0?(r=this,i=t):(r=t,i=this);for(var o=0,a=0;a<i.length;a++)o=(e=(0|r.words[a])-(0|i.words[a])+o)>>26,this.words[a]=67108863&e;for(;0!==o&&a<r.length;a++)o=(e=(0|r.words[a])+o)>>26,this.words[a]=67108863&e;if(0===o&&a<r.length&&r!==this)for(;a<r.length;a++)this.words[a]=r.words[a];return this.length=Math.max(this.length,a),r!==this&&(this.negative=1),this._strip()},n.prototype.sub=function(t){return this.clone().isub(t)};var p=function(t,e,r){var i,n,o,a=t.words,s=e.words,h=r.words,u=0,l=0|a[0],c=8191&l,d=l>>>13,f=0|a[1],m=8191&f,p=f>>>13,g=0|a[2],y=8191&g,w=g>>>13,v=0|a[3],b=8191&v,k=v>>>13,M=0|a[4],_=8191&M,E=M>>>13,A=0|a[5],j=8191&A,x=A>>>13,S=0|a[6],N=8191&S,I=S>>>13,T=0|a[7],C=8191&T,z=T>>>13,O=0|a[8],R=8191&O,P=O>>>13,B=0|a[9],D=8191&B,$=B>>>13,L=0|s[0],F=8191&L,U=L>>>13,q=0|s[1],V=8191&q,H=q>>>13,G=0|s[2],Z=8191&G,K=G>>>13,J=0|s[3],W=8191&J,Y=J>>>13,Q=0|s[4],X=8191&Q,tt=Q>>>13,et=0|s[5],rt=8191&et,it=et>>>13,nt=0|s[6],ot=8191&nt,at=nt>>>13,st=0|s[7],ht=8191&st,ut=st>>>13,lt=0|s[8],ct=8191&lt,dt=lt>>>13,ft=0|s[9],mt=8191&ft,pt=ft>>>13;r.negative=t.negative^e.negative,r.length=19;var gt=(u+(i=Math.imul(c,F))|0)+((8191&(n=(n=Math.imul(c,U))+Math.imul(d,F)|0))<<13)|0;u=((o=Math.imul(d,U))+(n>>>13)|0)+(gt>>>26)|0,gt&=67108863,i=Math.imul(m,F),n=(n=Math.imul(m,U))+Math.imul(p,F)|0,o=Math.imul(p,U);var yt=(u+(i=i+Math.imul(c,V)|0)|0)+((8191&(n=(n=n+Math.imul(c,H)|0)+Math.imul(d,V)|0))<<13)|0;u=((o=o+Math.imul(d,H)|0)+(n>>>13)|0)+(yt>>>26)|0,yt&=67108863,i=Math.imul(y,F),n=(n=Math.imul(y,U))+Math.imul(w,F)|0,o=Math.imul(w,U),i=i+Math.imul(m,V)|0,n=(n=n+Math.imul(m,H)|0)+Math.imul(p,V)|0,o=o+Math.imul(p,H)|0;var wt=(u+(i=i+Math.imul(c,Z)|0)|0)+((8191&(n=(n=n+Math.imul(c,K)|0)+Math.imul(d,Z)|0))<<13)|0;u=((o=o+Math.imul(d,K)|0)+(n>>>13)|0)+(wt>>>26)|0,wt&=67108863,i=Math.imul(b,F),n=(n=Math.imul(b,U))+Math.imul(k,F)|0,o=Math.imul(k,U),i=i+Math.imul(y,V)|0,n=(n=n+Math.imul(y,H)|0)+Math.imul(w,V)|0,o=o+Math.imul(w,H)|0,i=i+Math.imul(m,Z)|0,n=(n=n+Math.imul(m,K)|0)+Math.imul(p,Z)|0,o=o+Math.imul(p,K)|0;var vt=(u+(i=i+Math.imul(c,W)|0)|0)+((8191&(n=(n=n+Math.imul(c,Y)|0)+Math.imul(d,W)|0))<<13)|0;u=((o=o+Math.imul(d,Y)|0)+(n>>>13)|0)+(vt>>>26)|0,vt&=67108863,i=Math.imul(_,F),n=(n=Math.imul(_,U))+Math.imul(E,F)|0,o=Math.imul(E,U),i=i+Math.imul(b,V)|0,n=(n=n+Math.imul(b,H)|0)+Math.imul(k,V)|0,o=o+Math.imul(k,H)|0,i=i+Math.imul(y,Z)|0,n=(n=n+Math.imul(y,K)|0)+Math.imul(w,Z)|0,o=o+Math.imul(w,K)|0,i=i+Math.imul(m,W)|0,n=(n=n+Math.imul(m,Y)|0)+Math.imul(p,W)|0,o=o+Math.imul(p,Y)|0;var bt=(u+(i=i+Math.imul(c,X)|0)|0)+((8191&(n=(n=n+Math.imul(c,tt)|0)+Math.imul(d,X)|0))<<13)|0;u=((o=o+Math.imul(d,tt)|0)+(n>>>13)|0)+(bt>>>26)|0,bt&=67108863,i=Math.imul(j,F),n=(n=Math.imul(j,U))+Math.imul(x,F)|0,o=Math.imul(x,U),i=i+Math.imul(_,V)|0,n=(n=n+Math.imul(_,H)|0)+Math.imul(E,V)|0,o=o+Math.imul(E,H)|0,i=i+Math.imul(b,Z)|0,n=(n=n+Math.imul(b,K)|0)+Math.imul(k,Z)|0,o=o+Math.imul(k,K)|0,i=i+Math.imul(y,W)|0,n=(n=n+Math.imul(y,Y)|0)+Math.imul(w,W)|0,o=o+Math.imul(w,Y)|0,i=i+Math.imul(m,X)|0,n=(n=n+Math.imul(m,tt)|0)+Math.imul(p,X)|0,o=o+Math.imul(p,tt)|0;var kt=(u+(i=i+Math.imul(c,rt)|0)|0)+((8191&(n=(n=n+Math.imul(c,it)|0)+Math.imul(d,rt)|0))<<13)|0;u=((o=o+Math.imul(d,it)|0)+(n>>>13)|0)+(kt>>>26)|0,kt&=67108863,i=Math.imul(N,F),n=(n=Math.imul(N,U))+Math.imul(I,F)|0,o=Math.imul(I,U),i=i+Math.imul(j,V)|0,n=(n=n+Math.imul(j,H)|0)+Math.imul(x,V)|0,o=o+Math.imul(x,H)|0,i=i+Math.imul(_,Z)|0,n=(n=n+Math.imul(_,K)|0)+Math.imul(E,Z)|0,o=o+Math.imul(E,K)|0,i=i+Math.imul(b,W)|0,n=(n=n+Math.imul(b,Y)|0)+Math.imul(k,W)|0,o=o+Math.imul(k,Y)|0,i=i+Math.imul(y,X)|0,n=(n=n+Math.imul(y,tt)|0)+Math.imul(w,X)|0,o=o+Math.imul(w,tt)|0,i=i+Math.imul(m,rt)|0,n=(n=n+Math.imul(m,it)|0)+Math.imul(p,rt)|0,o=o+Math.imul(p,it)|0;var Mt=(u+(i=i+Math.imul(c,ot)|0)|0)+((8191&(n=(n=n+Math.imul(c,at)|0)+Math.imul(d,ot)|0))<<13)|0;u=((o=o+Math.imul(d,at)|0)+(n>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,i=Math.imul(C,F),n=(n=Math.imul(C,U))+Math.imul(z,F)|0,o=Math.imul(z,U),i=i+Math.imul(N,V)|0,n=(n=n+Math.imul(N,H)|0)+Math.imul(I,V)|0,o=o+Math.imul(I,H)|0,i=i+Math.imul(j,Z)|0,n=(n=n+Math.imul(j,K)|0)+Math.imul(x,Z)|0,o=o+Math.imul(x,K)|0,i=i+Math.imul(_,W)|0,n=(n=n+Math.imul(_,Y)|0)+Math.imul(E,W)|0,o=o+Math.imul(E,Y)|0,i=i+Math.imul(b,X)|0,n=(n=n+Math.imul(b,tt)|0)+Math.imul(k,X)|0,o=o+Math.imul(k,tt)|0,i=i+Math.imul(y,rt)|0,n=(n=n+Math.imul(y,it)|0)+Math.imul(w,rt)|0,o=o+Math.imul(w,it)|0,i=i+Math.imul(m,ot)|0,n=(n=n+Math.imul(m,at)|0)+Math.imul(p,ot)|0,o=o+Math.imul(p,at)|0;var _t=(u+(i=i+Math.imul(c,ht)|0)|0)+((8191&(n=(n=n+Math.imul(c,ut)|0)+Math.imul(d,ht)|0))<<13)|0;u=((o=o+Math.imul(d,ut)|0)+(n>>>13)|0)+(_t>>>26)|0,_t&=67108863,i=Math.imul(R,F),n=(n=Math.imul(R,U))+Math.imul(P,F)|0,o=Math.imul(P,U),i=i+Math.imul(C,V)|0,n=(n=n+Math.imul(C,H)|0)+Math.imul(z,V)|0,o=o+Math.imul(z,H)|0,i=i+Math.imul(N,Z)|0,n=(n=n+Math.imul(N,K)|0)+Math.imul(I,Z)|0,o=o+Math.imul(I,K)|0,i=i+Math.imul(j,W)|0,n=(n=n+Math.imul(j,Y)|0)+Math.imul(x,W)|0,o=o+Math.imul(x,Y)|0,i=i+Math.imul(_,X)|0,n=(n=n+Math.imul(_,tt)|0)+Math.imul(E,X)|0,o=o+Math.imul(E,tt)|0,i=i+Math.imul(b,rt)|0,n=(n=n+Math.imul(b,it)|0)+Math.imul(k,rt)|0,o=o+Math.imul(k,it)|0,i=i+Math.imul(y,ot)|0,n=(n=n+Math.imul(y,at)|0)+Math.imul(w,ot)|0,o=o+Math.imul(w,at)|0,i=i+Math.imul(m,ht)|0,n=(n=n+Math.imul(m,ut)|0)+Math.imul(p,ht)|0,o=o+Math.imul(p,ut)|0;var Et=(u+(i=i+Math.imul(c,ct)|0)|0)+((8191&(n=(n=n+Math.imul(c,dt)|0)+Math.imul(d,ct)|0))<<13)|0;u=((o=o+Math.imul(d,dt)|0)+(n>>>13)|0)+(Et>>>26)|0,Et&=67108863,i=Math.imul(D,F),n=(n=Math.imul(D,U))+Math.imul($,F)|0,o=Math.imul($,U),i=i+Math.imul(R,V)|0,n=(n=n+Math.imul(R,H)|0)+Math.imul(P,V)|0,o=o+Math.imul(P,H)|0,i=i+Math.imul(C,Z)|0,n=(n=n+Math.imul(C,K)|0)+Math.imul(z,Z)|0,o=o+Math.imul(z,K)|0,i=i+Math.imul(N,W)|0,n=(n=n+Math.imul(N,Y)|0)+Math.imul(I,W)|0,o=o+Math.imul(I,Y)|0,i=i+Math.imul(j,X)|0,n=(n=n+Math.imul(j,tt)|0)+Math.imul(x,X)|0,o=o+Math.imul(x,tt)|0,i=i+Math.imul(_,rt)|0,n=(n=n+Math.imul(_,it)|0)+Math.imul(E,rt)|0,o=o+Math.imul(E,it)|0,i=i+Math.imul(b,ot)|0,n=(n=n+Math.imul(b,at)|0)+Math.imul(k,ot)|0,o=o+Math.imul(k,at)|0,i=i+Math.imul(y,ht)|0,n=(n=n+Math.imul(y,ut)|0)+Math.imul(w,ht)|0,o=o+Math.imul(w,ut)|0,i=i+Math.imul(m,ct)|0,n=(n=n+Math.imul(m,dt)|0)+Math.imul(p,ct)|0,o=o+Math.imul(p,dt)|0;var At=(u+(i=i+Math.imul(c,mt)|0)|0)+((8191&(n=(n=n+Math.imul(c,pt)|0)+Math.imul(d,mt)|0))<<13)|0;u=((o=o+Math.imul(d,pt)|0)+(n>>>13)|0)+(At>>>26)|0,At&=67108863,i=Math.imul(D,V),n=(n=Math.imul(D,H))+Math.imul($,V)|0,o=Math.imul($,H),i=i+Math.imul(R,Z)|0,n=(n=n+Math.imul(R,K)|0)+Math.imul(P,Z)|0,o=o+Math.imul(P,K)|0,i=i+Math.imul(C,W)|0,n=(n=n+Math.imul(C,Y)|0)+Math.imul(z,W)|0,o=o+Math.imul(z,Y)|0,i=i+Math.imul(N,X)|0,n=(n=n+Math.imul(N,tt)|0)+Math.imul(I,X)|0,o=o+Math.imul(I,tt)|0,i=i+Math.imul(j,rt)|0,n=(n=n+Math.imul(j,it)|0)+Math.imul(x,rt)|0,o=o+Math.imul(x,it)|0,i=i+Math.imul(_,ot)|0,n=(n=n+Math.imul(_,at)|0)+Math.imul(E,ot)|0,o=o+Math.imul(E,at)|0,i=i+Math.imul(b,ht)|0,n=(n=n+Math.imul(b,ut)|0)+Math.imul(k,ht)|0,o=o+Math.imul(k,ut)|0,i=i+Math.imul(y,ct)|0,n=(n=n+Math.imul(y,dt)|0)+Math.imul(w,ct)|0,o=o+Math.imul(w,dt)|0;var jt=(u+(i=i+Math.imul(m,mt)|0)|0)+((8191&(n=(n=n+Math.imul(m,pt)|0)+Math.imul(p,mt)|0))<<13)|0;u=((o=o+Math.imul(p,pt)|0)+(n>>>13)|0)+(jt>>>26)|0,jt&=67108863,i=Math.imul(D,Z),n=(n=Math.imul(D,K))+Math.imul($,Z)|0,o=Math.imul($,K),i=i+Math.imul(R,W)|0,n=(n=n+Math.imul(R,Y)|0)+Math.imul(P,W)|0,o=o+Math.imul(P,Y)|0,i=i+Math.imul(C,X)|0,n=(n=n+Math.imul(C,tt)|0)+Math.imul(z,X)|0,o=o+Math.imul(z,tt)|0,i=i+Math.imul(N,rt)|0,n=(n=n+Math.imul(N,it)|0)+Math.imul(I,rt)|0,o=o+Math.imul(I,it)|0,i=i+Math.imul(j,ot)|0,n=(n=n+Math.imul(j,at)|0)+Math.imul(x,ot)|0,o=o+Math.imul(x,at)|0,i=i+Math.imul(_,ht)|0,n=(n=n+Math.imul(_,ut)|0)+Math.imul(E,ht)|0,o=o+Math.imul(E,ut)|0,i=i+Math.imul(b,ct)|0,n=(n=n+Math.imul(b,dt)|0)+Math.imul(k,ct)|0,o=o+Math.imul(k,dt)|0;var xt=(u+(i=i+Math.imul(y,mt)|0)|0)+((8191&(n=(n=n+Math.imul(y,pt)|0)+Math.imul(w,mt)|0))<<13)|0;u=((o=o+Math.imul(w,pt)|0)+(n>>>13)|0)+(xt>>>26)|0,xt&=67108863,i=Math.imul(D,W),n=(n=Math.imul(D,Y))+Math.imul($,W)|0,o=Math.imul($,Y),i=i+Math.imul(R,X)|0,n=(n=n+Math.imul(R,tt)|0)+Math.imul(P,X)|0,o=o+Math.imul(P,tt)|0,i=i+Math.imul(C,rt)|0,n=(n=n+Math.imul(C,it)|0)+Math.imul(z,rt)|0,o=o+Math.imul(z,it)|0,i=i+Math.imul(N,ot)|0,n=(n=n+Math.imul(N,at)|0)+Math.imul(I,ot)|0,o=o+Math.imul(I,at)|0,i=i+Math.imul(j,ht)|0,n=(n=n+Math.imul(j,ut)|0)+Math.imul(x,ht)|0,o=o+Math.imul(x,ut)|0,i=i+Math.imul(_,ct)|0,n=(n=n+Math.imul(_,dt)|0)+Math.imul(E,ct)|0,o=o+Math.imul(E,dt)|0;var St=(u+(i=i+Math.imul(b,mt)|0)|0)+((8191&(n=(n=n+Math.imul(b,pt)|0)+Math.imul(k,mt)|0))<<13)|0;u=((o=o+Math.imul(k,pt)|0)+(n>>>13)|0)+(St>>>26)|0,St&=67108863,i=Math.imul(D,X),n=(n=Math.imul(D,tt))+Math.imul($,X)|0,o=Math.imul($,tt),i=i+Math.imul(R,rt)|0,n=(n=n+Math.imul(R,it)|0)+Math.imul(P,rt)|0,o=o+Math.imul(P,it)|0,i=i+Math.imul(C,ot)|0,n=(n=n+Math.imul(C,at)|0)+Math.imul(z,ot)|0,o=o+Math.imul(z,at)|0,i=i+Math.imul(N,ht)|0,n=(n=n+Math.imul(N,ut)|0)+Math.imul(I,ht)|0,o=o+Math.imul(I,ut)|0,i=i+Math.imul(j,ct)|0,n=(n=n+Math.imul(j,dt)|0)+Math.imul(x,ct)|0,o=o+Math.imul(x,dt)|0;var Nt=(u+(i=i+Math.imul(_,mt)|0)|0)+((8191&(n=(n=n+Math.imul(_,pt)|0)+Math.imul(E,mt)|0))<<13)|0;u=((o=o+Math.imul(E,pt)|0)+(n>>>13)|0)+(Nt>>>26)|0,Nt&=67108863,i=Math.imul(D,rt),n=(n=Math.imul(D,it))+Math.imul($,rt)|0,o=Math.imul($,it),i=i+Math.imul(R,ot)|0,n=(n=n+Math.imul(R,at)|0)+Math.imul(P,ot)|0,o=o+Math.imul(P,at)|0,i=i+Math.imul(C,ht)|0,n=(n=n+Math.imul(C,ut)|0)+Math.imul(z,ht)|0,o=o+Math.imul(z,ut)|0,i=i+Math.imul(N,ct)|0,n=(n=n+Math.imul(N,dt)|0)+Math.imul(I,ct)|0,o=o+Math.imul(I,dt)|0;var It=(u+(i=i+Math.imul(j,mt)|0)|0)+((8191&(n=(n=n+Math.imul(j,pt)|0)+Math.imul(x,mt)|0))<<13)|0;u=((o=o+Math.imul(x,pt)|0)+(n>>>13)|0)+(It>>>26)|0,It&=67108863,i=Math.imul(D,ot),n=(n=Math.imul(D,at))+Math.imul($,ot)|0,o=Math.imul($,at),i=i+Math.imul(R,ht)|0,n=(n=n+Math.imul(R,ut)|0)+Math.imul(P,ht)|0,o=o+Math.imul(P,ut)|0,i=i+Math.imul(C,ct)|0,n=(n=n+Math.imul(C,dt)|0)+Math.imul(z,ct)|0,o=o+Math.imul(z,dt)|0;var Tt=(u+(i=i+Math.imul(N,mt)|0)|0)+((8191&(n=(n=n+Math.imul(N,pt)|0)+Math.imul(I,mt)|0))<<13)|0;u=((o=o+Math.imul(I,pt)|0)+(n>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,i=Math.imul(D,ht),n=(n=Math.imul(D,ut))+Math.imul($,ht)|0,o=Math.imul($,ut),i=i+Math.imul(R,ct)|0,n=(n=n+Math.imul(R,dt)|0)+Math.imul(P,ct)|0,o=o+Math.imul(P,dt)|0;var Ct=(u+(i=i+Math.imul(C,mt)|0)|0)+((8191&(n=(n=n+Math.imul(C,pt)|0)+Math.imul(z,mt)|0))<<13)|0;u=((o=o+Math.imul(z,pt)|0)+(n>>>13)|0)+(Ct>>>26)|0,Ct&=67108863,i=Math.imul(D,ct),n=(n=Math.imul(D,dt))+Math.imul($,ct)|0,o=Math.imul($,dt);var zt=(u+(i=i+Math.imul(R,mt)|0)|0)+((8191&(n=(n=n+Math.imul(R,pt)|0)+Math.imul(P,mt)|0))<<13)|0;u=((o=o+Math.imul(P,pt)|0)+(n>>>13)|0)+(zt>>>26)|0,zt&=67108863;var Ot=(u+(i=Math.imul(D,mt))|0)+((8191&(n=(n=Math.imul(D,pt))+Math.imul($,mt)|0))<<13)|0;return u=((o=Math.imul($,pt))+(n>>>13)|0)+(Ot>>>26)|0,Ot&=67108863,h[0]=gt,h[1]=yt,h[2]=wt,h[3]=vt,h[4]=bt,h[5]=kt,h[6]=Mt,h[7]=_t,h[8]=Et,h[9]=At,h[10]=jt,h[11]=xt,h[12]=St,h[13]=Nt,h[14]=It,h[15]=Tt,h[16]=Ct,h[17]=zt,h[18]=Ot,0!==u&&(h[19]=u,r.length++),r};function g(t,e,r){r.negative=e.negative^t.negative,r.length=t.length+e.length;for(var i=0,n=0,o=0;o<r.length-1;o++){var a=n;n=0;for(var s=67108863&i,h=Math.min(o,e.length-1),u=Math.max(0,o-t.length+1);u<=h;u++){var l=o-u,c=(0|t.words[l])*(0|e.words[u]),d=67108863&c;s=67108863&(d=d+s|0),n+=(a=(a=a+(c/67108864|0)|0)+(d>>>26)|0)>>>26,a&=67108863}r.words[o]=s,i=a,a=n}return 0!==i?r.words[o]=i:r.length--,r._strip()}function y(t,e,r){return g(t,e,r)}Math.imul||(p=m),n.prototype.mulTo=function(t,e){var r=this.length+t.length;return 10===this.length&&10===t.length?p(this,t,e):r<63?m(this,t,e):r<1024?g(this,t,e):y(this,t,e)},n.prototype.mul=function(t){var e=new n(null);return e.words=new Array(this.length+t.length),this.mulTo(t,e)},n.prototype.mulf=function(t){var e=new n(null);return e.words=new Array(this.length+t.length),y(this,t,e)},n.prototype.imul=function(t){return this.clone().mulTo(t,this)},n.prototype.imuln=function(t){var e=t<0;e&&(t=-t),r("number"==typeof t),r(t<67108864);for(var i=0,n=0;n<this.length;n++){var o=(0|this.words[n])*t,a=(67108863&o)+(67108863&i);i>>=26,i+=o/67108864|0,i+=a>>>26,this.words[n]=67108863&a}return 0!==i&&(this.words[n]=i,this.length++),e?this.ineg():this},n.prototype.muln=function(t){return this.clone().imuln(t)},n.prototype.sqr=function(){return this.mul(this)},n.prototype.isqr=function(){return this.imul(this.clone())},n.prototype.pow=function(t){var e=function(t){for(var e=new Array(t.bitLength()),r=0;r<e.length;r++){var i=r/26|0,n=r%26;e[r]=t.words[i]>>>n&1}return e}(t);if(0===e.length)return new n(1);for(var r=this,i=0;i<e.length&&0===e[i];i++,r=r.sqr());if(++i<e.length)for(var o=r.sqr();i<e.length;i++,o=o.sqr())0!==e[i]&&(r=r.mul(o));return r},n.prototype.iushln=function(t){r("number"==typeof t&&t>=0);var e,i=t%26,n=(t-i)/26,o=67108863>>>26-i<<26-i;if(0!==i){var a=0;for(e=0;e<this.length;e++){var s=this.words[e]&o,h=(0|this.words[e])-s<<i;this.words[e]=h|a,a=s>>>26-i}a&&(this.words[e]=a,this.length++)}if(0!==n){for(e=this.length-1;e>=0;e--)this.words[e+n]=this.words[e];for(e=0;e<n;e++)this.words[e]=0;this.length+=n}return this._strip()},n.prototype.ishln=function(t){return r(0===this.negative),this.iushln(t)},n.prototype.iushrn=function(t,e,i){var n;r("number"==typeof t&&t>=0),n=e?(e-e%26)/26:0;var o=t%26,a=Math.min((t-o)/26,this.length),s=67108863^67108863>>>o<<o,h=i;if(n-=a,n=Math.max(0,n),h){for(var u=0;u<a;u++)h.words[u]=this.words[u];h.length=a}if(0===a);else if(this.length>a)for(this.length-=a,u=0;u<this.length;u++)this.words[u]=this.words[u+a];else this.words[0]=0,this.length=1;var l=0;for(u=this.length-1;u>=0&&(0!==l||u>=n);u--){var c=0|this.words[u];this.words[u]=l<<26-o|c>>>o,l=c&s}return h&&0!==l&&(h.words[h.length++]=l),0===this.length&&(this.words[0]=0,this.length=1),this._strip()},n.prototype.ishrn=function(t,e,i){return r(0===this.negative),this.iushrn(t,e,i)},n.prototype.shln=function(t){return this.clone().ishln(t)},n.prototype.ushln=function(t){return this.clone().iushln(t)},n.prototype.shrn=function(t){return this.clone().ishrn(t)},n.prototype.ushrn=function(t){return this.clone().iushrn(t)},n.prototype.testn=function(t){r("number"==typeof t&&t>=0);var e=t%26,i=(t-e)/26,n=1<<e;return!(this.length<=i)&&!!(this.words[i]&n)},n.prototype.imaskn=function(t){r("number"==typeof t&&t>=0);var e=t%26,i=(t-e)/26;if(r(0===this.negative,"imaskn works only with positive numbers"),this.length<=i)return this;if(0!==e&&i++,this.length=Math.min(i,this.length),0!==e){var n=67108863^67108863>>>e<<e;this.words[this.length-1]&=n}return this._strip()},n.prototype.maskn=function(t){return this.clone().imaskn(t)},n.prototype.iaddn=function(t){return r("number"==typeof t),r(t<67108864),t<0?this.isubn(-t):0!==this.negative?1===this.length&&(0|this.words[0])<=t?(this.words[0]=t-(0|this.words[0]),this.negative=0,this):(this.negative=0,this.isubn(t),this.negative=1,this):this._iaddn(t)},n.prototype._iaddn=function(t){this.words[0]+=t;for(var e=0;e<this.length&&this.words[e]>=67108864;e++)this.words[e]-=67108864,e===this.length-1?this.words[e+1]=1:this.words[e+1]++;return this.length=Math.max(this.length,e+1),this},n.prototype.isubn=function(t){if(r("number"==typeof t),r(t<67108864),t<0)return this.iaddn(-t);if(0!==this.negative)return this.negative=0,this.iaddn(t),this.negative=1,this;if(this.words[0]-=t,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var e=0;e<this.length&&this.words[e]<0;e++)this.words[e]+=67108864,this.words[e+1]-=1;return this._strip()},n.prototype.addn=function(t){return this.clone().iaddn(t)},n.prototype.subn=function(t){return this.clone().isubn(t)},n.prototype.iabs=function(){return this.negative=0,this},n.prototype.abs=function(){return this.clone().iabs()},n.prototype._ishlnsubmul=function(t,e,i){var n,o,a=t.length+i;this._expand(a);var s=0;for(n=0;n<t.length;n++){o=(0|this.words[n+i])+s;var h=(0|t.words[n])*e;s=((o-=67108863&h)>>26)-(h/67108864|0),this.words[n+i]=67108863&o}for(;n<this.length-i;n++)s=(o=(0|this.words[n+i])+s)>>26,this.words[n+i]=67108863&o;if(0===s)return this._strip();for(r(-1===s),s=0,n=0;n<this.length;n++)s=(o=-(0|this.words[n])+s)>>26,this.words[n]=67108863&o;return this.negative=1,this._strip()},n.prototype._wordDiv=function(t,e){var r=(this.length,t.length),i=this.clone(),o=t,a=0|o.words[o.length-1];0!==(r=26-this._countBits(a))&&(o=o.ushln(r),i.iushln(r),a=0|o.words[o.length-1]);var s,h=i.length-o.length;if("mod"!==e){(s=new n(null)).length=h+1,s.words=new Array(s.length);for(var u=0;u<s.length;u++)s.words[u]=0}var l=i.clone()._ishlnsubmul(o,1,h);0===l.negative&&(i=l,s&&(s.words[h]=1));for(var c=h-1;c>=0;c--){var d=67108864*(0|i.words[o.length+c])+(0|i.words[o.length+c-1]);for(d=Math.min(d/a|0,67108863),i._ishlnsubmul(o,d,c);0!==i.negative;)d--,i.negative=0,i._ishlnsubmul(o,1,c),i.isZero()||(i.negative^=1);s&&(s.words[c]=d)}return s&&s._strip(),i._strip(),"div"!==e&&0!==r&&i.iushrn(r),{div:s||null,mod:i}},n.prototype.divmod=function(t,e,i){return r(!t.isZero()),this.isZero()?{div:new n(0),mod:new n(0)}:0!==this.negative&&0===t.negative?(s=this.neg().divmod(t,e),"mod"!==e&&(o=s.div.neg()),"div"!==e&&(a=s.mod.neg(),i&&0!==a.negative&&a.iadd(t)),{div:o,mod:a}):0===this.negative&&0!==t.negative?(s=this.divmod(t.neg(),e),"mod"!==e&&(o=s.div.neg()),{div:o,mod:s.mod}):0!=(this.negative&t.negative)?(s=this.neg().divmod(t.neg(),e),"div"!==e&&(a=s.mod.neg(),i&&0!==a.negative&&a.isub(t)),{div:s.div,mod:a}):t.length>this.length||this.cmp(t)<0?{div:new n(0),mod:this}:1===t.length?"div"===e?{div:this.divn(t.words[0]),mod:null}:"mod"===e?{div:null,mod:new n(this.modrn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new n(this.modrn(t.words[0]))}:this._wordDiv(t,e);var o,a,s},n.prototype.div=function(t){return this.divmod(t,"div",!1).div},n.prototype.mod=function(t){return this.divmod(t,"mod",!1).mod},n.prototype.umod=function(t){return this.divmod(t,"mod",!0).mod},n.prototype.divRound=function(t){var e=this.divmod(t);if(e.mod.isZero())return e.div;var r=0!==e.div.negative?e.mod.isub(t):e.mod,i=t.ushrn(1),n=t.andln(1),o=r.cmp(i);return o<0||1===n&&0===o?e.div:0!==e.div.negative?e.div.isubn(1):e.div.iaddn(1)},n.prototype.modrn=function(t){var e=t<0;e&&(t=-t),r(t<=67108863);for(var i=(1<<26)%t,n=0,o=this.length-1;o>=0;o--)n=(i*n+(0|this.words[o]))%t;return e?-n:n},n.prototype.modn=function(t){return this.modrn(t)},n.prototype.idivn=function(t){var e=t<0;e&&(t=-t),r(t<=67108863);for(var i=0,n=this.length-1;n>=0;n--){var o=(0|this.words[n])+67108864*i;this.words[n]=o/t|0,i=o%t}return this._strip(),e?this.ineg():this},n.prototype.divn=function(t){return this.clone().idivn(t)},n.prototype.egcd=function(t){r(0===t.negative),r(!t.isZero());var e=this,i=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var o=new n(1),a=new n(0),s=new n(0),h=new n(1),u=0;e.isEven()&&i.isEven();)e.iushrn(1),i.iushrn(1),++u;for(var l=i.clone(),c=e.clone();!e.isZero();){for(var d=0,f=1;0==(e.words[0]&f)&&d<26;++d,f<<=1);if(d>0)for(e.iushrn(d);d-- >0;)(o.isOdd()||a.isOdd())&&(o.iadd(l),a.isub(c)),o.iushrn(1),a.iushrn(1);for(var m=0,p=1;0==(i.words[0]&p)&&m<26;++m,p<<=1);if(m>0)for(i.iushrn(m);m-- >0;)(s.isOdd()||h.isOdd())&&(s.iadd(l),h.isub(c)),s.iushrn(1),h.iushrn(1);e.cmp(i)>=0?(e.isub(i),o.isub(s),a.isub(h)):(i.isub(e),s.isub(o),h.isub(a))}return{a:s,b:h,gcd:i.iushln(u)}},n.prototype._invmp=function(t){r(0===t.negative),r(!t.isZero());var e=this,i=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var o,a=new n(1),s=new n(0),h=i.clone();e.cmpn(1)>0&&i.cmpn(1)>0;){for(var u=0,l=1;0==(e.words[0]&l)&&u<26;++u,l<<=1);if(u>0)for(e.iushrn(u);u-- >0;)a.isOdd()&&a.iadd(h),a.iushrn(1);for(var c=0,d=1;0==(i.words[0]&d)&&c<26;++c,d<<=1);if(c>0)for(i.iushrn(c);c-- >0;)s.isOdd()&&s.iadd(h),s.iushrn(1);e.cmp(i)>=0?(e.isub(i),a.isub(s)):(i.isub(e),s.isub(a))}return(o=0===e.cmpn(1)?a:s).cmpn(0)<0&&o.iadd(t),o},n.prototype.gcd=function(t){if(this.isZero())return t.abs();if(t.isZero())return this.abs();var e=this.clone(),r=t.clone();e.negative=0,r.negative=0;for(var i=0;e.isEven()&&r.isEven();i++)e.iushrn(1),r.iushrn(1);for(;;){for(;e.isEven();)e.iushrn(1);for(;r.isEven();)r.iushrn(1);var n=e.cmp(r);if(n<0){var o=e;e=r,r=o}else if(0===n||0===r.cmpn(1))break;e.isub(r)}return r.iushln(i)},n.prototype.invm=function(t){return this.egcd(t).a.umod(t)},n.prototype.isEven=function(){return 0==(1&this.words[0])},n.prototype.isOdd=function(){return 1==(1&this.words[0])},n.prototype.andln=function(t){return this.words[0]&t},n.prototype.bincn=function(t){r("number"==typeof t);var e=t%26,i=(t-e)/26,n=1<<e;if(this.length<=i)return this._expand(i+1),this.words[i]|=n,this;for(var o=n,a=i;0!==o&&a<this.length;a++){var s=0|this.words[a];o=(s+=o)>>>26,s&=67108863,this.words[a]=s}return 0!==o&&(this.words[a]=o,this.length++),this},n.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},n.prototype.cmpn=function(t){var e,i=t<0;if(0!==this.negative&&!i)return-1;if(0===this.negative&&i)return 1;if(this._strip(),this.length>1)e=1;else{i&&(t=-t),r(t<=67108863,"Number is too big");var n=0|this.words[0];e=n===t?0:n<t?-1:1}return 0!==this.negative?0|-e:e},n.prototype.cmp=function(t){if(0!==this.negative&&0===t.negative)return-1;if(0===this.negative&&0!==t.negative)return 1;var e=this.ucmp(t);return 0!==this.negative?0|-e:e},n.prototype.ucmp=function(t){if(this.length>t.length)return 1;if(this.length<t.length)return-1;for(var e=0,r=this.length-1;r>=0;r--){var i=0|this.words[r],n=0|t.words[r];if(i!==n){i<n?e=-1:i>n&&(e=1);break}}return e},n.prototype.gtn=function(t){return 1===this.cmpn(t)},n.prototype.gt=function(t){return 1===this.cmp(t)},n.prototype.gten=function(t){return this.cmpn(t)>=0},n.prototype.gte=function(t){return this.cmp(t)>=0},n.prototype.ltn=function(t){return-1===this.cmpn(t)},n.prototype.lt=function(t){return-1===this.cmp(t)},n.prototype.lten=function(t){return this.cmpn(t)<=0},n.prototype.lte=function(t){return this.cmp(t)<=0},n.prototype.eqn=function(t){return 0===this.cmpn(t)},n.prototype.eq=function(t){return 0===this.cmp(t)},n.red=function(t){return new E(t)},n.prototype.toRed=function(t){return r(!this.red,"Already a number in reduction context"),r(0===this.negative,"red works only with positives"),t.convertTo(this)._forceRed(t)},n.prototype.fromRed=function(){return r(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},n.prototype._forceRed=function(t){return this.red=t,this},n.prototype.forceRed=function(t){return r(!this.red,"Already a number in reduction context"),this._forceRed(t)},n.prototype.redAdd=function(t){return r(this.red,"redAdd works only with red numbers"),this.red.add(this,t)},n.prototype.redIAdd=function(t){return r(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,t)},n.prototype.redSub=function(t){return r(this.red,"redSub works only with red numbers"),this.red.sub(this,t)},n.prototype.redISub=function(t){return r(this.red,"redISub works only with red numbers"),this.red.isub(this,t)},n.prototype.redShl=function(t){return r(this.red,"redShl works only with red numbers"),this.red.shl(this,t)},n.prototype.redMul=function(t){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.mul(this,t)},n.prototype.redIMul=function(t){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.imul(this,t)},n.prototype.redSqr=function(){return r(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},n.prototype.redISqr=function(){return r(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},n.prototype.redSqrt=function(){return r(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},n.prototype.redInvm=function(){return r(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},n.prototype.redNeg=function(){return r(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},n.prototype.redPow=function(t){return r(this.red&&!t.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,t)};var w={k256:null,p224:null,p192:null,p25519:null};function v(t,e){this.name=t,this.p=new n(e,16),this.n=this.p.bitLength(),this.k=new n(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function b(){v.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function k(){v.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function M(){v.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function _(){v.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function E(t){if("string"==typeof t){var e=n._prime(t);this.m=e.p,this.prime=e}else r(t.gtn(1),"modulus must be greater than 1"),this.m=t,this.prime=null}function A(t){E.call(this,t),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new n(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)}v.prototype._tmp=function(){var t=new n(null);return t.words=new Array(Math.ceil(this.n/13)),t},v.prototype.ireduce=function(t){var e,r=t;do{this.split(r,this.tmp),e=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(e>this.n);var i=e<this.n?-1:r.ucmp(this.p);return 0===i?(r.words[0]=0,r.length=1):i>0?r.isub(this.p):void 0!==r.strip?r.strip():r._strip(),r},v.prototype.split=function(t,e){t.iushrn(this.n,0,e)},v.prototype.imulK=function(t){return t.imul(this.k)},i(b,v),b.prototype.split=function(t,e){for(var r=4194303,i=Math.min(t.length,9),n=0;n<i;n++)e.words[n]=t.words[n];if(e.length=i,t.length<=9)return t.words[0]=0,void(t.length=1);var o=t.words[9];for(e.words[e.length++]=o&r,n=10;n<t.length;n++){var a=0|t.words[n];t.words[n-10]=(a&r)<<4|o>>>22,o=a}o>>>=22,t.words[n-10]=o,0===o&&t.length>10?t.length-=10:t.length-=9},b.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var e=0,r=0;r<t.length;r++){var i=0|t.words[r];e+=977*i,t.words[r]=67108863&e,e=64*i+(e/67108864|0)}return 0===t.words[t.length-1]&&(t.length--,0===t.words[t.length-1]&&t.length--),t},i(k,v),i(M,v),i(_,v),_.prototype.imulK=function(t){for(var e=0,r=0;r<t.length;r++){var i=19*(0|t.words[r])+e,n=67108863&i;i>>>=26,t.words[r]=n,e=i}return 0!==e&&(t.words[t.length++]=e),t},n._prime=function(t){if(w[t])return w[t];var e;if("k256"===t)e=new b;else if("p224"===t)e=new k;else if("p192"===t)e=new M;else{if("p25519"!==t)throw new Error("Unknown prime "+t);e=new _}return w[t]=e,e},E.prototype._verify1=function(t){r(0===t.negative,"red works only with positives"),r(t.red,"red works only with red numbers")},E.prototype._verify2=function(t,e){r(0==(t.negative|e.negative),"red works only with positives"),r(t.red&&t.red===e.red,"red works only with red numbers")},E.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):(u(t,t.umod(this.m)._forceRed(this)),t)},E.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},E.prototype.add=function(t,e){this._verify2(t,e);var r=t.add(e);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},E.prototype.iadd=function(t,e){this._verify2(t,e);var r=t.iadd(e);return r.cmp(this.m)>=0&&r.isub(this.m),r},E.prototype.sub=function(t,e){this._verify2(t,e);var r=t.sub(e);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},E.prototype.isub=function(t,e){this._verify2(t,e);var r=t.isub(e);return r.cmpn(0)<0&&r.iadd(this.m),r},E.prototype.shl=function(t,e){return this._verify1(t),this.imod(t.ushln(e))},E.prototype.imul=function(t,e){return this._verify2(t,e),this.imod(t.imul(e))},E.prototype.mul=function(t,e){return this._verify2(t,e),this.imod(t.mul(e))},E.prototype.isqr=function(t){return this.imul(t,t.clone())},E.prototype.sqr=function(t){return this.mul(t,t)},E.prototype.sqrt=function(t){if(t.isZero())return t.clone();var e=this.m.andln(3);if(r(e%2==1),3===e){var i=this.m.add(new n(1)).iushrn(2);return this.pow(t,i)}for(var o=this.m.subn(1),a=0;!o.isZero()&&0===o.andln(1);)a++,o.iushrn(1);r(!o.isZero());var s=new n(1).toRed(this),h=s.redNeg(),u=this.m.subn(1).iushrn(1),l=this.m.bitLength();for(l=new n(2*l*l).toRed(this);0!==this.pow(l,u).cmp(h);)l.redIAdd(h);for(var c=this.pow(l,o),d=this.pow(t,o.addn(1).iushrn(1)),f=this.pow(t,o),m=a;0!==f.cmp(s);){for(var p=f,g=0;0!==p.cmp(s);g++)p=p.redSqr();r(g<m);var y=this.pow(c,new n(1).iushln(m-g-1));d=d.redMul(y),c=y.redSqr(),f=f.redMul(c),m=g}return d},E.prototype.invm=function(t){var e=t._invmp(this.m);return 0!==e.negative?(e.negative=0,this.imod(e).redNeg()):this.imod(e)},E.prototype.pow=function(t,e){if(e.isZero())return new n(1).toRed(this);if(0===e.cmpn(1))return t.clone();var r=new Array(16);r[0]=new n(1).toRed(this),r[1]=t;for(var i=2;i<r.length;i++)r[i]=this.mul(r[i-1],t);var o=r[0],a=0,s=0,h=e.bitLength()%26;for(0===h&&(h=26),i=e.length-1;i>=0;i--){for(var u=e.words[i],l=h-1;l>=0;l--){var c=u>>l&1;o!==r[0]&&(o=this.sqr(o)),0!==c||0!==a?(a<<=1,a|=c,(4===++s||0===i&&0===l)&&(o=this.mul(o,r[a]),s=0,a=0)):s=0}h=26}return o},E.prototype.convertTo=function(t){var e=t.umod(this.m);return e===t?e.clone():e},E.prototype.convertFrom=function(t){var e=t.clone();return e.red=null,e},n.mont=function(t){return new A(t)},i(A,E),A.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},A.prototype.convertFrom=function(t){var e=this.imod(t.mul(this.rinv));return e.red=null,e},A.prototype.imul=function(t,e){if(t.isZero()||e.isZero())return t.words[0]=0,t.length=1,t;var r=t.imul(e),i=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),n=r.isub(i).iushrn(this.shift),o=n;return n.cmp(this.m)>=0?o=n.isub(this.m):n.cmpn(0)<0&&(o=n.iadd(this.m)),o._forceRed(this)},A.prototype.mul=function(t,e){if(t.isZero()||e.isZero())return new n(0)._forceRed(this);var r=t.mul(e),i=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),o=r.isub(i).iushrn(this.shift),a=o;return o.cmp(this.m)>=0?a=o.isub(this.m):o.cmpn(0)<0&&(a=o.iadd(this.m)),a._forceRed(this)},A.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}(t,i)}));var iP=rP.BN;const nP=new w("bignumber/5.6.2"),oP={},aP=9007199254740991;let sP=!1;class hP{constructor(t,e){t!==oP&&nP.throwError("cannot call constructor directly; use BigNumber.from",w.errors.UNSUPPORTED_OPERATION,{operation:"new (BigNumber)"}),this._hex=e,this._isBigNumber=!0,Object.freeze(this)}fromTwos(t){return lP(cP(this).fromTwos(t))}toTwos(t){return lP(cP(this).toTwos(t))}abs(){return"-"===this._hex[0]?hP.from(this._hex.substring(1)):this}add(t){return lP(cP(this).add(cP(t)))}sub(t){return lP(cP(this).sub(cP(t)))}div(t){return hP.from(t).isZero()&&dP("division-by-zero","div"),lP(cP(this).div(cP(t)))}mul(t){return lP(cP(this).mul(cP(t)))}mod(t){const e=cP(t);return e.isNeg()&&dP("division-by-zero","mod"),lP(cP(this).umod(e))}pow(t){const e=cP(t);return e.isNeg()&&dP("negative-power","pow"),lP(cP(this).pow(e))}and(t){const e=cP(t);return(this.isNegative()||e.isNeg())&&dP("unbound-bitwise-result","and"),lP(cP(this).and(e))}or(t){const e=cP(t);return(this.isNegative()||e.isNeg())&&dP("unbound-bitwise-result","or"),lP(cP(this).or(e))}xor(t){const e=cP(t);return(this.isNegative()||e.isNeg())&&dP("unbound-bitwise-result","xor"),lP(cP(this).xor(e))}mask(t){return(this.isNegative()||t<0)&&dP("negative-width","mask"),lP(cP(this).maskn(t))}shl(t){return(this.isNegative()||t<0)&&dP("negative-width","shl"),lP(cP(this).shln(t))}shr(t){return(this.isNegative()||t<0)&&dP("negative-width","shr"),lP(cP(this).shrn(t))}eq(t){return cP(this).eq(cP(t))}lt(t){return cP(this).lt(cP(t))}lte(t){return cP(this).lte(cP(t))}gt(t){return cP(this).gt(cP(t))}gte(t){return cP(this).gte(cP(t))}isNegative(){return"-"===this._hex[0]}isZero(){return cP(this).isZero()}toNumber(){try{return cP(this).toNumber()}catch(t){dP("overflow","toNumber",this.toString())}return null}toBigInt(){try{return BigInt(this.toString())}catch(t){}return nP.throwError("this platform does not support BigInt",w.errors.UNSUPPORTED_OPERATION,{value:this.toString()})}toString(){return arguments.length>0&&(10===arguments[0]?sP||(sP=!0,nP.warn("BigNumber.toString does not accept any parameters; base-10 is assumed")):16===arguments[0]?nP.throwError("BigNumber.toString does not accept any parameters; use bigNumber.toHexString()",w.errors.UNEXPECTED_ARGUMENT,{}):nP.throwError("BigNumber.toString does not accept parameters",w.errors.UNEXPECTED_ARGUMENT,{})),cP(this).toString(10)}toHexString(){return this._hex}toJSON(t){return{type:"BigNumber",hex:this.toHexString()}}static from(t){if(t instanceof hP)return t;if("string"==typeof t)return t.match(/^-?0x[0-9a-f]+$/i)?new hP(oP,uP(t)):t.match(/^-?[0-9]+$/)?new hP(oP,uP(new iP(t))):nP.throwArgumentError("invalid BigNumber string","value",t);if("number"==typeof t)return t%1&&dP("underflow","BigNumber.from",t),(t>=aP||t<=-aP)&&dP("overflow","BigNumber.from",t),hP.from(String(t));const e=t;if("bigint"==typeof e)return hP.from(e.toString());if(E(e))return hP.from(I(e));if(e)if(e.toHexString){const t=e.toHexString();if("string"==typeof t)return hP.from(t)}else{let t=e._hex;if(null==t&&"BigNumber"===e.type&&(t=e.hex),"string"==typeof t&&(S(t)||"-"===t[0]&&S(t.substring(1))))return hP.from(t)}return nP.throwArgumentError("invalid BigNumber value","value",t)}static isBigNumber(t){return!(!t||!t._isBigNumber)}}function uP(t){if("string"!=typeof t)return uP(t.toString(16));if("-"===t[0])return"-"===(t=t.substring(1))[0]&&nP.throwArgumentError("invalid hex","value",t),"0x00"===(t=uP(t))?t:"-"+t;if("0x"!==t.substring(0,2)&&(t="0x"+t),"0x"===t)return"0x00";for(t.length%2&&(t="0x0"+t.substring(2));t.length>4&&"0x00"===t.substring(0,4);)t="0x"+t.substring(4);return t}function lP(t){return hP.from(uP(t))}function cP(t){const e=hP.from(t).toHexString();return"-"===e[0]?new iP("-"+e.substring(3),16):new iP(e.substring(2),16)}function dP(t,e,r){const i={fault:t,operation:e};return null!=r&&(i.value=r),nP.throwError(t,w.errors.NUMERIC_FAULT,i)}var fP=window&&window.__awaiter||function(t,e,r,i){return new(r||(r=Promise))((function(n,o){function a(t){try{h(i.next(t))}catch(t){o(t)}}function s(t){try{h(i.throw(t))}catch(t){o(t)}}function h(t){var e;t.done?n(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(a,s)}h((i=i.apply(t,e||[])).next())}))};const mP=new w("hash/5.6.1"),pP=new Uint8Array(32);pP.fill(0);const gP=hP.from(-1),yP=hP.from(0),wP=hP.from(1),vP=hP.from("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");const bP=R(wP.toHexString(),32),kP=R(yP.toHexString(),32),MP={name:"string",version:"string",chainId:"uint256",verifyingContract:"address",salt:"bytes32"},_P=["name","version","chainId","verifyingContract","salt"];function EP(t){return function(e){return"string"!=typeof e&&mP.throwArgumentError(`invalid domain value for ${JSON.stringify(t)}`,`domain.${t}`,e),e}}const AP={name:EP("name"),version:EP("version"),chainId:function(t){try{return hP.from(t).toString()}catch(t){}return mP.throwArgumentError('invalid domain value for "chainId"',"domain.chainId",t)},verifyingContract:function(t){try{return he(t).toLowerCase()}catch(t){}return mP.throwArgumentError('invalid domain value "verifyingContract"',"domain.verifyingContract",t)},salt:function(t){try{const e=A(t);if(32!==e.length)throw new Error("bad length");return I(e)}catch(t){}return mP.throwArgumentError('invalid domain value "salt"',"domain.salt",t)}};function jP(t){{const e=t.match(/^(u?)int(\d*)$/);if(e){const r=""===e[1],i=parseInt(e[2]||"256");(i%8!=0||i>256||e[2]&&e[2]!==String(i))&&mP.throwArgumentError("invalid numeric width","type",t);const n=vP.mask(r?i-1:i),o=r?n.add(wP).mul(gP):yP;return function(e){const r=hP.from(e);return(r.lt(o)||r.gt(n))&&mP.throwArgumentError(`value out-of-bounds for ${t}`,"value",e),R(r.toTwos(256).toHexString(),32)}}}{const e=t.match(/^bytes(\d+)$/);if(e){const r=parseInt(e[1]);return(0===r||r>32||e[1]!==String(r))&&mP.throwArgumentError("invalid bytes width","type",t),function(e){return A(e).length!==r&&mP.throwArgumentError(`invalid length for ${t}`,"value",e),function(t){const e=A(t),r=e.length%32;return r?z([e,pP.slice(r)]):I(e)}(e)}}}switch(t){case"address":return function(t){return R(he(t),32)};case"bool":return function(t){return t?bP:kP};case"bytes":return function(t){return Jt(t)};case"string":return function(t){return eP(t)}}return null}function xP(t,e){return`${t}(${e.map((({name:t,type:e})=>e+" "+t)).join(",")})`}class SP{constructor(t){ir(this,"types",Object.freeze(lr(t))),ir(this,"_encoderCache",{}),ir(this,"_types",{});const e={},r={},i={};Object.keys(t).forEach((t=>{e[t]={},r[t]=[],i[t]={}}));for(const i in t){const n={};t[i].forEach((o=>{n[o.name]&&mP.throwArgumentError(`duplicate variable name ${JSON.stringify(o.name)} in ${JSON.stringify(i)}`,"types",t),n[o.name]=!0;const a=o.type.match(/^([^\x5b]*)(\x5b|$)/)[1];a===i&&mP.throwArgumentError(`circular type reference to ${JSON.stringify(a)}`,"types",t);jP(a)||(r[a]||mP.throwArgumentError(`unknown type ${JSON.stringify(a)}`,"types",t),r[a].push(i),e[i][a]=!0)}))}const n=Object.keys(r).filter((t=>0===r[t].length));0===n.length?mP.throwArgumentError("missing primary type","types",t):n.length>1&&mP.throwArgumentError(`ambiguous primary types or unused types: ${n.map((t=>JSON.stringify(t))).join(", ")}`,"types",t),ir(this,"primaryType",n[0]),function n(o,a){a[o]&&mP.throwArgumentError(`circular type reference to ${JSON.stringify(o)}`,"types",t),a[o]=!0,Object.keys(e[o]).forEach((t=>{r[t]&&(n(t,a),Object.keys(a).forEach((e=>{i[e][t]=!0})))})),delete a[o]}(this.primaryType,{});for(const e in i){const r=Object.keys(i[e]);r.sort(),this._types[e]=xP(e,t[e])+r.map((e=>xP(e,t[e]))).join("")}}getEncoder(t){let e=this._encoderCache[t];return e||(e=this._encoderCache[t]=this._getEncoder(t)),e}_getEncoder(t){{const e=jP(t);if(e)return e}const e=t.match(/^(.*)(\x5b(\d*)\x5d)$/);if(e){const t=e[1],r=this.getEncoder(t),i=parseInt(e[3]);return e=>{i>=0&&e.length!==i&&mP.throwArgumentError("array length mismatch; expected length ${ arrayLength }","value",e);let n=e.map(r);return this._types[t]&&(n=n.map(Jt)),Jt(z(n))}}const r=this.types[t];if(r){const e=eP(this._types[t]);return t=>{const i=r.map((({name:e,type:r})=>{const i=this.getEncoder(r)(t[e]);return this._types[r]?Jt(i):i}));return i.unshift(e),z(i)}}return mP.throwArgumentError(`unknown type: ${t}`,"type",t)}encodeType(t){const e=this._types[t];return e||mP.throwArgumentError(`unknown type: ${JSON.stringify(t)}`,"name",t),e}encodeData(t,e){return this.getEncoder(t)(e)}hashStruct(t,e){return Jt(this.encodeData(t,e))}encode(t){return this.encodeData(this.primaryType,t)}hash(t){return this.hashStruct(this.primaryType,t)}_visit(t,e,r){if(jP(t))return r(t,e);const i=t.match(/^(.*)(\x5b(\d*)\x5d)$/);if(i){const t=i[1],n=parseInt(i[3]);return n>=0&&e.length!==n&&mP.throwArgumentError("array length mismatch; expected length ${ arrayLength }","value",e),e.map((e=>this._visit(t,e,r)))}const n=this.types[t];return n?n.reduce(((t,{name:i,type:n})=>(t[i]=this._visit(n,e[i],r),t)),{}):mP.throwArgumentError(`unknown type: ${t}`,"type",t)}visit(t,e){return this._visit(this.primaryType,t,e)}static from(t){return new SP(t)}static getPrimaryType(t){return SP.from(t).primaryType}static hashStruct(t,e,r){return SP.from(e).hashStruct(t,r)}static hashDomain(t){const e=[];for(const r in t){const i=MP[r];i||mP.throwArgumentError(`invalid typed-data domain key: ${JSON.stringify(r)}`,"domain",t),e.push({name:r,type:i})}return e.sort(((t,e)=>_P.indexOf(t.name)-_P.indexOf(e.name))),SP.hashStruct("EIP712Domain",{EIP712Domain:e},t)}static encode(t,e,r){return z(["0x1901",SP.hashDomain(t),SP.from(e).hash(r)])}static hash(t,e,r){return Jt(SP.encode(t,e,r))}static resolveNames(t,e,r,i){return fP(this,void 0,void 0,(function*(){t=ar(t);const n={};t.verifyingContract&&!S(t.verifyingContract,20)&&(n[t.verifyingContract]="0x");const o=SP.from(e);o.visit(r,((t,e)=>("address"!==t||S(e,20)||(n[e]="0x"),e)));for(const t in n)n[t]=yield i(t);return t.verifyingContract&&n[t.verifyingContract]&&(t.verifyingContract=n[t.verifyingContract]),r=o.visit(r,((t,e)=>"address"===t&&n[e]?n[e]:e)),{domain:t,value:r}}))}static getPayload(t,e,r){SP.hashDomain(t);const i={},n=[];_P.forEach((e=>{const r=t[e];null!=r&&(i[e]=AP[e](r),n.push({name:e,type:MP[e]}))}));const o=SP.from(e),a=ar(e);return a.EIP712Domain?mP.throwArgumentError("types must not contain EIP712Domain type","types.EIP712Domain",e):a.EIP712Domain=n,o.encode(r),{types:a,domain:i,primaryType:o.primaryType,message:o.visit(r,((t,e)=>{if(t.match(/^bytes(\d*)/))return I(A(e));if(t.match(/^u?int/))return hP.from(e).toString();switch(t){case"address":return e.toLowerCase();case"bool":return!!e;case"string":return"string"!=typeof e&&mP.throwArgumentError("invalid string","value",e),e}return mP.throwArgumentError("unsupported type","type",t)}))}}}window&&window.__awaiter;new w("wallet/5.6.2");function NP(t,e,r,i){return gs(SP.hash(t,e,r),i)}const IP="6492649264926492649264926492649264926492649264926492649264926492";function TP(t,e){return t.toLowerCase()===e.toLowerCase()}function CP(t){const{domain:e,types:r,message:i}=t;return wl.hash(e,r,i)}function zP(t,e,i,n){return r(this,void 0,void 0,(function*(){let r;try{r=yield vB(n,["function isValidSignature(bytes32 _hash, bytes memory _signature) public view returns (bytes4 magicValue)"],[t,"isValidSignature",[A(i),e]])}catch(t){if(t.message.startsWith("missing revert data in call exception"))return!1;throw t}return TP(r,"0x1626ba7e")}))}function OP(t,e,i,n){return r(this,void 0,void 0,(function*(){return TP(yield vB(n,["function isValidSignature(bytes _hash, bytes memory _signature) public view returns (bytes4 magicValue)"],[t,"isValidSignature",[A(i),e]]),"0x20c13b0b")}))}var RP=Object.freeze({__proto__:null,getHash:CP,default:function(t,e,i){return r(this,arguments,void 0,(function*(t,e,r,i="1",n={}){const{domain:o,types:a,message:s}=r;try{if(TP(t,NP(o,a,s,e)))return!0}catch(t){}const h=Xp(i,n),u=CP(r);if(e.endsWith(IP))try{return"0x01"===(yield h.call({data:j(["0x60806040523480156200001157600080fd5b50604051620007003803806200070083398101604081905262000034916200056f565b6000620000438484846200004f565b9050806000526001601ff35b600080846001600160a01b0316803b806020016040519081016040528181526000908060200190933c90507f6492649264926492649264926492649264926492649264926492649264926492620000a68462000451565b036200021f57600060608085806020019051810190620000c79190620005ce565b8651929550909350915060000362000192576000836001600160a01b031683604051620000f5919062000643565b6000604051808303816000865af19150503d806000811462000134576040519150601f19603f3d011682016040523d82523d6000602084013e62000139565b606091505b5050905080620001905760405162461bcd60e51b815260206004820152601e60248201527f5369676e617475726556616c696461746f723a206465706c6f796d656e74000060448201526064015b60405180910390fd5b505b604051630b135d3f60e11b808252906001600160a01b038a1690631626ba7e90620001c4908b90869060040162000661565b602060405180830381865afa158015620001e2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200020891906200069d565b6001600160e01b031916149450505050506200044a565b805115620002b157604051630b135d3f60e11b808252906001600160a01b03871690631626ba7e9062000259908890889060040162000661565b602060405180830381865afa15801562000277573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200029d91906200069d565b6001600160e01b031916149150506200044a565b8251604114620003195760405162461bcd60e51b815260206004820152603a6024820152600080516020620006e083398151915260448201527f3a20696e76616c6964207369676e6174757265206c656e677468000000000000606482015260840162000187565b620003236200046b565b506020830151604080850151855186939260009185919081106200034b576200034b620006c9565b016020015160f81c9050601b81148015906200036b57508060ff16601c14155b15620003cf5760405162461bcd60e51b815260206004820152603b6024820152600080516020620006e083398151915260448201527f3a20696e76616c6964207369676e617475726520762076616c75650000000000606482015260840162000187565b6040805160008152602081018083528a905260ff83169181019190915260608101849052608081018390526001600160a01b038a169060019060a0016020604051602081039080840390855afa1580156200042e573d6000803e3d6000fd5b505050602060405103516001600160a01b031614955050505050505b9392505050565b60006020825110156200046357600080fd5b508051015190565b60405180606001604052806003906020820280368337509192915050565b6001600160a01b03811681146200049f57600080fd5b50565b634e487b7160e01b600052604160045260246000fd5b60005b83811015620004d5578181015183820152602001620004bb565b50506000910152565b600082601f830112620004f057600080fd5b81516001600160401b03808211156200050d576200050d620004a2565b604051601f8301601f19908116603f01168101908282118183101715620005385762000538620004a2565b816040528381528660208588010111156200055257600080fd5b62000565846020830160208901620004b8565b9695505050505050565b6000806000606084860312156200058557600080fd5b8351620005928162000489565b6020850151604086015191945092506001600160401b03811115620005b657600080fd5b620005c486828701620004de565b9150509250925092565b600080600060608486031215620005e457600080fd5b8351620005f18162000489565b60208501519093506001600160401b03808211156200060f57600080fd5b6200061d87838801620004de565b935060408601519150808211156200063457600080fd5b50620005c486828701620004de565b6000825162000657818460208701620004b8565b9190910192915050565b828152604060208201526000825180604084015262000688816060850160208701620004b8565b601f01601f1916919091016060019392505050565b600060208284031215620006b057600080fd5b81516001600160e01b0319811681146200044a57600080fd5b634e487b7160e01b600052603260045260246000fdfe5369676e617475726556616c696461746f72237265636f7665725369676e6572",(new $i).encode(["address","bytes32","bytes"],[t,A(u),e])])}))}catch(t){return!1}return!!(yield zP(t,e,u,h))||(yield OP(t,e,u,h))}))}});var PP=["ipfs.snapshot.box","snapshot.4everland.link","ipfs.io","ipfs.fleek.co","gateway.pinata.cloud","dweb.link","ipfs.infura.io"],BP={1:{key:"1",name:"Ethereum",chainId:1,network:"homestead",multicall:"0xeefba1e63905ef1d7acba5a8513c70307c1ce441",ensResolvers:["0x231b0Ee14048e9dCcD1d247744d114a4EB5E8E63","0x4976fb03C32e5B8cfe2b6cCB31c09Ba78EBaBa41"],ensNameWrapper:"0xD4416b13d2b3a9aBae7AcD5D6C2BbDBE25686401",ensSubgraph:"https://subgrapher.snapshot.org/subgraph/arbitrum/5XqPmWe6gjyrJtFn9cLy237i4cWw2j9HcUJEXsP5qGtH",rpc:["https://rpc.ankr.com/eth",{url:"https://api-geth-archive.ankr.com",user:"balancer_user",password:"balancerAnkr20201015"},"https://speedy-nodes-nyc.moralis.io/b9aed21e7bb7bdeb35972c9a/eth/mainnet/archive","https://apis.ankr.com/e62bc219f9c9462b8749defe472d2dc5/6106d4a3ec1d1bcc87ec72158f8fd089/eth/archive/main","https://eth-archival.gateway.pokt.network/v1/5f76124fb90218002e9ce985","https://eth-mainnet.alchemyapi.io/v2/4bdDVB5QAaorY2UE-GBUbM2yQB3QJqzv"],light:["https://cloudflare-eth.com"],ws:["wss://eth-mainnet.ws.alchemyapi.io/v2/4bdDVB5QAaorY2UE-GBUbM2yQB3QJqzv"],explorer:{url:"https://etherscan.io",apiUrl:"https://api.etherscan.io"},start:7929876,logo:"ipfs://bafkreid7ndxh6y2ljw2jhbisodiyrhcy2udvnwqgon5wgells3kh4si5z4"},8:{key:"8",name:"Ubiq",chainId:8,network:"Ubiq",multicall:"0x6668750957e4083725926B71C41bDF1434C73262",rpc:["https://rpc.octano.dev"],ws:["wss://ws.octano.dev"],explorer:{url:"https://ubiqscan.io"},start:1,logo:"ipfs://Qmec3HLoN4QhwZAhw4XTi2aN8Wwmcko5hHN22sHARzb9tw"},10:{key:"10",name:"OP Mainnet",chainId:10,network:"OP Mainnet",multicall:"0x35A6Cdb2C9AD4a45112df4a04147EB07dFA01aB7",rpc:["https://opt-mainnet.g.alchemy.com/v2/JzmIL4Q3jBj7it2duxLFeuCa9Wobmm7D"],explorer:{url:"https://optimistic.etherscan.io",apiUrl:"https://api-optimistic.etherscan.io"},start:657806,logo:"ipfs://bafkreifu2remiqfpsb4hgisbwb3qxedrzpwsea7ik4el45znjcf56xf2ku"},19:{key:"19",name:"Songbird Canary-Network",shortName:"Songbird",chainId:19,network:"songbird",multicall:"0x17032Ea9c3a13Ed337665145364c0d2aD1108c91",rpc:["https://songbird-api.flare.network/ext/C/rpc"],explorer:{url:"https://songbird-explorer.flare.network"},start:21807126,logo:"ipfs://QmXyvnrZY8FUxSULfnKKA99sAEkjAHtvhRx5WeHixgaEdu"},24:{key:"24",name:"KardiaChain Mainnet",shortName:"KAI",chainId:24,network:"mainnet",multicall:"0xd9c92F2287B7802A37eC9BEce96Aa65fb5f31E1b",rpc:["https://kai-internal.kardiachain.io"],explorer:{url:"https://explorer.kardiachain.io"},start:8260245,logo:"ipfs://bafkreig73yfyqzbxydv6e3dbj5nks3f57px2iez7tywayey4rilfhhrr34"},25:{key:"25",name:"Cronos",shortName:"Cronos",chainId:25,network:"mainnet",multicall:"0x6F522a3982e8F9A50A2EDc9E46ed1A3aE2B3FD3a",rpc:["https://evm-cronos.crypto.org"],explorer:{url:"https://cronos.crypto.org/explorer"},start:4067,logo:"ipfs://QmfSJbtirJoa3Pt7o5Fdm85wbyw9V1hpzqLr5PQbdnfsAj"},30:{key:"30",name:"RSK",chainId:30,network:"rsk mainnet",multicall:"0x4eeebb5580769ba6d26bfd07be636300076d1831",rpc:["https://public-node.rsk.co"],explorer:{url:"https://explorer.rsk.co"},start:2516442,logo:"ipfs://QmXTwpE1SqoNZmyY4c3fYWy6qUgQELsyWKbgJo2Pg6K6V9"},46:{key:"46",name:"Darwinia Network",shortName:"Darwinia",chainId:46,network:"mainnet",multicall:"0x67f9ae42EaA9a8aBf065D60ec6Ab3C1A11370607",rpc:["https://rpc.darwinia.network"],explorer:{url:"https://darwinia.subscan.io"},start:141853,logo:"ipfs://bafkreicf55maidhx46pyu3mwsshlr43xbewr6tkckkonh4nesbkp7krwkm"},56:{key:"56",name:"BNB Smart Chain",shortName:"BSC",chainId:56,network:"mainnet",multicall:"0x1ee38d535d541c55c9dae27b12edf090c608e6fb",rpc:["https://speedy-nodes-nyc.moralis.io/b9aed21e7bb7bdeb35972c9a/bsc/mainnet/archive","https://rpc.ankr.com/bsc","https://bsc.getblock.io/mainnet/?api_key=91f8195f-bf46-488f-846a-73d6853790e7","https://bsc-private-dataseed1.nariox.org","https://bsc-dataseed1.ninicoin.io","https://bsc-dataseed1.binance.org"],explorer:{url:"https://bscscan.com"},start:461230,logo:"ipfs://bafkreibll4la7wqerzs7zwxjne2j7ayynbg2wlenemssoahxxj5rbt6c64"},61:{key:"61",name:"Ethereum Classic",shortName:"Ethereum Classic",chainId:61,network:"mainnet",multicall:"0x51be3a92C56ae7E207C5b5Fd87F7798Ce82C1AC2",rpc:["https://www.ethercluster.com/etc"],explorer:{url:"https://blockscout.com/etc/mainnet"},start:13307544,logo:"ipfs://QmVegc28DvA7LjKUFysab81c9BSuN4wQVDQkRXyAtuEBis"},66:{key:"66",name:"OKExChain",shortName:"OEC Mainnet",chainId:66,network:"oec mainnet",multicall:"0x6EB187d8197Ac265c945b69f3c3064A6f3831866",rpc:["https://exchainrpc.okex.org"],ws:["wss://exchainws.okex.org:8443"],explorer:{url:"https://www.oklink.com/okexchain"},start:5076543,logo:"ipfs://Qmd7dKnNwHRZ4HRCbCXUbkNV7gP28fGqPdjbHtjRtT9sQF"},75:{key:"75",name:"Decimal",shortName:"mainnet",chainId:75,network:"mainnet",multicall:"0x949d1A0757803C51F2EfFFEb5472C861A898B8E8",rpc:[],explorer:{url:"https://explorer.decimalchain.com"},start:16031065,logo:"ipfs://bafkreihkdhbce5rkogl63xegaarlirjrvbfarxbtbf5mqme3s5grvbjyxm"},81:{key:"81",name:"Shibuya Network",shortName:"Shibuya",chainId:81,network:"testnet",testnet:!0,multicall:"0x3E90A35839ff0Aa32992d33d861f24dC95BBf74d",rpc:["https://rpc.shibuya.astar.network:8545"],explorer:{url:"https://blockscout.com/shibuya"},start:856303,logo:"ipfs://QmZLQVsUqHBDXutu6ywTvcYXDZG2xBstMfHkfJSzUNpZsc"},82:{key:"82",name:"Meter",shortName:"Meter",chainId:82,network:"mainnet",multicall:"0x579De77CAEd0614e3b158cb738fcD5131B9719Ae",rpc:["https://rpc.meter.io"],explorer:{url:"https://scan.meter.io"},start:4992871,logo:"ipfs://QmSZvT9w9eUDvV1YVaq3BKKEbubtNVqu1Rin44FuN4wz11"},97:{key:"97",name:"BNB Smart Chain Testnet",shortName:"BSC Testnet",chainId:97,network:"testnet",testnet:!0,multicall:"0x8b54247c6BAe96A6ccAFa468ebae96c4D7445e46",rpc:["https://data-seed-prebsc-1-s1.binance.org:8545","https://speedy-nodes-nyc.moralis.io/f2963e29bec0de5787da3164/bsc/testnet/archive"],explorer:{url:"https://testnet.bscscan.com"},start:3599656,logo:"ipfs://bafkreibll4la7wqerzs7zwxjne2j7ayynbg2wlenemssoahxxj5rbt6c64"},100:{key:"100",name:"Gnosis Chain",shortName:"xDAI",chainId:100,network:"mainnet",multicall:"0xb5b692a88bdfc81ca69dcb1d924f59f0413a602a",rpc:["https://gno.getblock.io/mainnet/6c1d1e6e-75d9-452f-a863-a694bff93d5c/","https://xdai-archive.blockscout.com","https://poa-xdai.gateway.pokt.network/v1/5f76124fb90218002e9ce985","https://rpc.gnosischain.com"],light:["https://rpc.gnosischain.com"],ws:["wss://rpc.xdaichain.com/wss"],explorer:{url:"https://gnosis.blockscout.com"},start:4108192,logo:"ipfs://QmZeiy8Ax4133wzxUQM9ky8z5XFVf6YLFjJMmTWbWVniZR"},108:{key:"108",name:"Thundercore",chainId:108,network:"mainnet",multicall:"0x3017086deef56679e267f67f66c4415109b7a97f",rpc:["https://mainnet-rpc.thundercore.com/archived/SNAPSHOTEuR82a75fLYA"],explorer:{url:"https://viewblock.io/thundercore"},start:94425385,logo:"ipfs://bafkreifc5z5vtvqx2luzgateyvoocwpd2ifv2hwufxdnyl2a767wa6icli"},109:{key:"109",name:"Shibarium",shortName:"mainnet",chainId:109,network:"mainnet",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:[],explorer:{url:"https://shibariumscan.io"},start:3485946,logo:"ipfs://bafkreig57igai5phg4icywc5yoockd52jo3hlvbkyi6wiufrmu4p2lmenm"},122:{key:"122",name:"Fuse",shortName:"Fuse",chainId:122,network:"mainnet",multicall:"0x7a59441fb06666F6d2D766393d876945D06a169c",rpc:["https://explorer-node.fuse.io/","https://oefusefull1.liquify.info/"],explorer:{url:"https://explorer.fuse.io"},start:11923459,logo:"ipfs://QmXjWb64nako7voaVEifgdjAbDbswpTY8bghsiHpv8yWtb"},137:{key:"137",name:"Polygon PoS",shortName:"Polygon",chainId:137,network:"mainnet",multicall:"0xCBca837161be50EfA5925bB9Cc77406468e76751",rpc:["https://rpc.ankr.com/polygon","https://speedy-nodes-nyc.moralis.io/b9aed21e7bb7bdeb35972c9a/polygon/mainnet/archive","https://speedy-nodes-nyc.moralis.io/f2963e29bec0de5787da3164/polygon/mainnet/archive","https://rpc-mainnet.maticvigil.com/v1/1cfd7598e5ba6dcf0b4db58e8be484badc6ea08e"],ws:["wss://ws-mainnet.matic.network"],explorer:{url:"https://polygonscan.com",apiUrl:"https://api.polygonscan.com"},start:9834491,logo:"ipfs://bafkreihgr7zy7vi5kqddybfaezwuhvssg57qluwmyan4qq7l57nr7w7wey"},144:{key:"144",name:"PHI Network",shortName:"PHI",chainId:144,network:"mainnet",multicall:"0xc2f41B404a6757863AAeF49ff93039421acCd630",rpc:["https://connect.phi.network"],explorer:{url:"https://phiscan.com"},start:360030,logo:"ipfs://bafkreid6pm3mic7izp3a6zlfwhhe7etd276bjfsq2xash6a4s2vmcdf65a"},146:{key:"146",name:"Sonic",shortName:"mainnet",chainId:146,network:"mainnet",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:[],explorer:{url:"https://explorer.soniclabs.com"},start:60,logo:"ipfs://bafkreic5fffatwy2gzf6y5iymje6ijii43tz4wlxl35da36guurhibjx44"},148:{key:"148",name:"ShimmerEVM",shortName:"ShimmerEVM",chainId:148,network:"mainnet",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:[],explorer:{url:"https://explorer.evm.shimmer.network"},start:1290,logo:"ipfs://bafkreib4xhbgbhrwkmizp4d4nz3wzbpyhdm6wpz2v2pbkk7jxsgg3hdt74"},157:{key:"157",name:"Shibarium Puppynet Testnet",shortName:"testnet",chainId:157,network:"testnet",multicall:"0xA4029b74FBA366c926eDFA7Dd10B21C621170a4c",rpc:[],explorer:{url:"https://puppyscan.shib.io"},start:3035769,logo:"ipfs://bafkreig57igai5phg4icywc5yoockd52jo3hlvbkyi6wiufrmu4p2lmenm",testnet:!0},169:{key:"169",name:"Manta Pacific",shortName:"Manta",chainId:169,network:"mainnet",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:[],explorer:{url:"https://www.oklink.com/manta"},start:332890,logo:"ipfs://bafkreibbrwgwdcfh755dqh4ndta6tja77qbaa36bfv4pstub6prhhore7a"},204:{key:"204",name:"opBNB",shortName:"mainnet",chainId:204,network:"mainnet",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:[],explorer:{url:"http://opbnbscan.com"},start:512881,logo:"ipfs://bafkreibll4la7wqerzs7zwxjne2j7ayynbg2wlenemssoahxxj5rbt6c64"},246:{key:"246",name:"Energy Web Chain",shortName:"EWC",chainId:246,network:"mainnet",multicall:"0x0767F26d0D568aB61A98b279C0b28a4164A6f05e",rpc:["https://voting-rpc.carbonswap.exchange"],explorer:{url:"https://explorer.energyweb.org"},start:12086501,logo:"ipfs://Qmai7AGHgs8NpeGeXgbMZz7pS2i4kw44qubCJYGrZW2f3a"},250:{key:"250",name:"Fantom Opera",shortName:"fantom",chainId:250,network:"Mainnet",multicall:"0x7f6A10218264a22B4309F3896745687E712962a0",rpc:["https://rpc.ankr.com/fantom","https://rpc.ftm.tools","https://rpcapi.fantom.network"],explorer:{url:"https://ftmscan.com"},start:2497732,logo:"ipfs://QmVEgNeQDKnXygeGxfY9FywZpNGQu98ktZtRJ9bToYF6g7"},252:{key:"252",name:"Fraxtal",shortName:"mainnet",chainId:252,network:"mainnet",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:[],explorer:{url:"https://fraxscan.com"},start:1,logo:"ipfs://bafkreieflj4wq6tx7k5kq47z3xnsrdrn2xgm4bxa3uovrnndcb2vqqwlyu"},269:{key:"269",name:"High Performance Blockchain",shortName:"HPB",chainId:269,network:"mainnet",multicall:"0x67D0f263aef2F6167FA77353695D75b582Ff4Bca",rpc:["https://hpbnode.com"],ws:["wss://ws.hpbnode.com"],explorer:{url:"https://hscan.org"},start:13960096,logo:"ipfs://QmU7f1MyRz8rLELFfypnWZQjGbDGYgZtC9rjw47jYMYrnu"},296:{key:"296",name:"Hedera Testnet",shortName:"testnet",chainId:296,network:"testnet",multicall:"0xADE3166b0afA89b2CDB64870D70ADeD330Eab015",rpc:[],explorer:{url:"https://hashscan.io/testnet"},start:17561901,logo:"ipfs://bafkreia5gpitwgo4sspvvtwqcxosq2krrqo5dbrnvylgibvmypzotfmbuu",testnet:!0},300:{key:"300",name:"zkSync Sepolia Testnet",shortName:"testnet",chainId:300,network:"testnet",multicall:"0xF9cda624FBC7e059355ce98a31693d299FACd963",rpc:[],explorer:{url:"https://sepolia.explorer.zksync.dev"},start:2292,logo:"ipfs://bafkreih6y7ri7h667cwxe5miisxghfheiidtbw2747y75stoxt3gp3a2yy",testnet:!0},314:{key:"314",name:"Filecoin",shortName:"mainnet",chainId:314,network:"mainnet",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:[],explorer:{url:"https://filfox.io"},start:3328594,logo:"ipfs://bafybeibyvjfmk6aqlfdrczvth55jkmnoadtrch7ht3rdmvqmy2bfxynecm"},321:{key:"321",name:"KCC",shortName:"KCC",chainId:321,network:"mainnet",multicall:"0xa64D6AFb48225BDA3259246cfb418c0b91de6D7a",rpc:["https://rpc-mainnet.kcc.network"],ws:["wss://rpc-ws-mainnet.kcc.network"],explorer:{url:"https://explorer.kcc.io"},start:1487453,logo:"ipfs://QmRdzYGhFRG8QLzMJahHrw3vETE2YZ9sywQbEkenSjKEvb"},324:{key:"324",name:"zkSync Era",shortName:"zkSync-era",chainId:324,network:"zkSync Era Mainnet",multicall:"0xF9cda624FBC7e059355ce98a31693d299FACd963",rpc:["https://mainnet.era.zksync.io"],explorer:{url:"https://explorer.zksync.io"},start:3908235,logo:"ipfs://bafkreih6y7ri7h667cwxe5miisxghfheiidtbw2747y75stoxt3gp3a2yy"},336:{key:"336",name:"Shiden Network",shortName:"Shiden",chainId:336,network:"mainnet",multicall:"0x3E90A35839ff0Aa32992d33d861f24dC95BBf74d",rpc:["https://rpc.shiden.astar.network:8545","https://shiden.api.onfinality.io/public"],explorer:{url:"https://blockscout.com/shiden"},start:1170016,logo:"ipfs://QmcqGQE4Sk73zXc3e91TUFFefKBVeaNgbxV141XkSNE4xj"},369:{key:"369",name:"Pulsechain",shortName:"Pulsechain",chainId:369,network:"mainnet",multicall:"0xdbdd0FD8B16F0092f306392b699D7fbddaA9011B",rpc:["https://rpc.pulsechain.com"],explorer:{url:"https://scan.pulsechain.com"},start:17657774,logo:"ipfs://QmWUsiEWdejtHZ9B9981TYXn7Ds8C7fkB1S4h5rP3kCCZR"},416:{key:"416",name:"SX Network",shortName:"SX",chainId:416,network:"mainnet",multicall:"0x834a005DDCF990Ba1a79f259e840e58F2D14F49a",rpc:["https://rpc.sx.technology"],ws:["wss://rpc.sx.technology/ws"],explorer:{url:"https://explorer.sx.technology"},start:2680605,logo:"ipfs://QmSXLXqyr2H6Ja5XrmznXbWTEvF2gFaL8RXNXgyLmDHjAF"},592:{key:"592",name:"Astar Network",shortName:"Astar",chainId:592,network:"mainnet",multicall:"0x3E90A35839ff0Aa32992d33d861f24dC95BBf74d",rpc:["https://astar.api.onfinality.io/public","https://rpc.astar.network:8545"],explorer:{url:"https://blockscout.com/astar"},start:366482,logo:"ipfs://QmZLQVsUqHBDXutu6ywTvcYXDZG2xBstMfHkfJSzUNpZsc"},813:{key:"813",name:"Qitmeer",shortName:"MEER",chainId:813,network:"mainnet",multicall:"0x55034b2cF530ae3A8fC1e2e4523F58496796610F",rpc:["https://evm-dataseed1.meerscan.io","https://evm-dataseed.meerscan.com","https://evm-dataseed2.meerscan.io","https://evm-dataseed3.meerscan.io"],explorer:{url:"https://evm.meerscan.io"},start:43317,logo:"ipfs://QmXvum7SNVaAqAc2jNzR1NpNZN1GGvNaKWydg8a1GEDQ7y"},841:{key:"841",name:"Taraxa",shortName:"841",chainId:841,network:"mainnet",multicall:"0xFCe7a3121B42664AaD145712e1c2Bf2e38f60AA1",rpc:["https://rpc.mainnet.taraxa.io"],ws:["wss://ws.mainnet.taraxa.io"],explorer:{url:"https://mainnet.explorer.taraxa.io"},start:1515906,logo:"ipfs://Qmcc6ZCAGESMzZzoj5LsTVcCo2E35x3Ydk71uPJyov6Mwx"},888:{key:"888",name:"Wanchain",chainId:888,network:"mainnet",multicall:"0xba5934ab3056fca1fa458d30fbb3810c3eb5145f",rpc:["https://gwan-ssl.wandevs.org:56891"],ws:["wss://api.wanchain.org:8443/ws/v3/ddd16770c68f30350a21114802d5418eafe039b722de52b488e7eee1ee2cd73f"],explorer:{url:"https://www.wanscan.org"},start:11302663,logo:"ipfs://QmewFFN44rkxESFsHG8edaLt1znr62hjvZhGynfXqruzX3"},1001:{key:"1001",name:"Kaia Kairos Testnet",shortName:"kaia-kairos",chainId:1001,network:"testnet",testnet:!0,multicall:"0x40643B8Aeaaca0b87Ea1A1E596e64a0e14B1d244",rpc:["https://archive-en-kairos.node.kaia.io"],ws:["wss://archive-en-kairos.node.kaia.io/ws"],explorer:{url:"https://kairos.kaiascan.com"},start:87232478,logo:"ipfs://bafkreifm6l67f4blcv7qwuszalwoxzptt5ad2f3t472lytr3d2hmi626ju"},1072:{key:"1072",name:"Shimmer EVM Testnet",shortName:"ShimmerEVM",chainId:1072,network:"testnet",testnet:!0,multicall:"0x751d21047C116413895c259f3f305e38C10B7cF6",rpc:["https://archive.evm.testnet.shimmer.network/v1/chains/rms1pr75wa5xuepg2hew44vnr28wz5h6n6x99zptk2g68sp2wuu2karywgrztx3/evm"],explorer:{url:"https://explorer.evm.testnet.shimmer.network"},start:10614,logo:"ipfs://bafkreihtwfwrue7klzedwx4rqlk6agklz4lbbk7owsyw6xzn6c2m4t5tgy"},1088:{key:"1088",name:"Metis",shortName:"metis",chainId:1088,network:"mainnet",multicall:"0xc39aBB6c4451089dE48Cffb013c39d3110530e5C",rpc:["https://andromeda.metis.io/?owner=1088"],explorer:{url:"https://andromeda-explorer.metis.io"},start:451,logo:"ipfs://bafkreiaqr4atnjpdnk3c4vu4377ai7bzqpgaefefbl5j5imfsvr4puimtu"},1101:{key:"1101",name:"Polygon zkEVM",shortName:"mainnet",chainId:1101,network:"mainnet",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:[],explorer:{url:"https://zkevm.polygonscan.com"},start:57746,logo:"ipfs://bafkreibfiyvhqnme2vbxxfcku7qkxgjpkg6ywdkplxh4oxlkqsbznyorfm"},1116:{key:"1116",name:"Core Chain",shortName:"Core",chainId:1116,network:"mainnet",multicall:"0x024f0041b76B598c2A0a75004F8447FaF67BD004",rpc:["https://rpcar.coredao.org/"],explorer:{url:"https://scan.coredao.org"},start:853908,logo:"ipfs://bafkreigjv5yb7uhlrryzib7j2f73nnwqan2tmfnwjdu26vkk365fyesoiu"},1284:{key:"1284",name:"Moonbeam",shortName:"GLMR",chainId:1284,network:"mainnet",multicall:"0x83e3b61886770de2F64AAcaD2724ED4f08F7f36B",rpc:["https://rpc.api.moonbeam.network"],explorer:{url:"https://moonscan.io"},start:171135,logo:"ipfs://QmWKTEK2pj5sBBbHnMHQbWgw6euVdBrk2Ligpi2chrWASk"},1285:{key:"1285",name:"Moonriver (Kusama)",shortName:"Moonriver",chainId:1285,network:"mainnet",multicall:"0x537004440ffFE1D4AE9F009031Fc2b0385FCA9F1",rpc:["https://rpc.api.moonriver.moonbeam.network"],explorer:{url:"https://blockscout.moonriver.moonbeam.network"},start:413539,logo:"ipfs://QmXtgPesL87Ejhq2Y7yxsaPYpf4RcnoTYPJWPcv6iiYhoi"},1287:{key:"1287",name:"Moonbase Alpha TestNet",shortName:"Moonbase",chainId:1287,network:"testnet",testnet:!0,multicall:"0xf09FD6B6FF3f41614b9d6be2166A0D07045A3A97",rpc:["https://rpc.testnet.moonbeam.network"],explorer:{url:"https://moonbase-blockscout.testnet.moonbeam.network"},start:859041,logo:"ipfs://QmeGbNTU2Jqwg8qLTMGW8n8HSi2VdgCncAaeGzLx6gYnD7"},1315:{key:"1315",name:"Story Aeneid Testnet",shortName:"testnet",chainId:1315,network:"testnet",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:[],explorer:{url:"https://aeneid.storyscan.io"},start:1792,logo:"ipfs://bafkreiaicdywqkmej6htv4e4lnq5fzajb3qfoxslkrbf5byvqc2aalxcne",testnet:!0},1328:{key:"1328",name:"Sei atlantic testnet",shortName:"testnet",chainId:1328,network:"testnet",multicall:"0xc454132B017b55b427f45078E335549A7124f5f7",rpc:[],explorer:{url:"https://seitrace.com"},start:96978658,logo:"ipfs://bafkreiammyt7uztbztqbcqv4bydnczsh2fqmnjf6jxj4xnskzzl6sjrigq",testnet:!0},1329:{key:"1329",name:"Sei",shortName:"mainnet",chainId:1329,network:"mainnet",multicall:"0xe033Bed7cae4114Af84Be1e9F1CA7DEa07Dfe1Cf",rpc:[],explorer:{url:"https://seitrace.com"},start:79164574,logo:"ipfs://bafkreiammyt7uztbztqbcqv4bydnczsh2fqmnjf6jxj4xnskzzl6sjrigq"},1480:{key:"1480",name:"Vana",shortName:"mainnet",chainId:1480,network:"mainnet",multicall:"0xD8d2dFca27E8797fd779F8547166A2d3B29d360E",rpc:[],explorer:{url:"https://islander.vanascan.io"},start:716763,logo:"ipfs://bafkreibotel3dmc5og5rf3tpt7l74awkene7x6q3oxtwhptt4y4rpa7vsa"},1514:{key:"1514",name:"Story",shortName:"mainnet",chainId:1514,network:"mainnet",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:[],explorer:{url:"https://www.storyscan.io"},start:340998,logo:"ipfs://bafkreiaicdywqkmej6htv4e4lnq5fzajb3qfoxslkrbf5byvqc2aalxcne"},1559:{key:"1559",name:"Tenet",shortName:"tenet",chainId:1559,network:"mainnet",multicall:"0xcCB3F00bE353950E4C08501ac8Af48765EAAa738",rpc:[],explorer:{url:"https://tenetscan.io"},start:944415,logo:"ipfs://Qmc1gqjWTzNo4pyFSGtQuCu7kRSZZBUVybtTjHn2nNEEPA"},1663:{key:"1663",name:"Horizen Gobi Testnet",shortName:"Gobi",chainId:1663,network:"testnet",testnet:!0,multicall:"0xC743e4910Bdd4e5aBacCA38F74cdA270281C5eef",rpc:["https://gobi-testnet.horizenlabs.io/ethv1"],explorer:{url:"https://gobi-explorer.horizen.io"},start:1,logo:"ipfs://QmUYQdsnkUoiDiQ3WaWrtH7fsc5yQDC7kZJCHmC2qWPTPt"},2e3:{key:"2000",name:"Doge Chain",shortName:"dogechain",chainId:2e3,network:"mainnet",multicall:"0x6f9D3f3932B417bd4957585D236Cbc32b32C0BDc",rpc:["https://rpc.dogechain.dog"],explorer:{url:"https://explorer.dogechain.dog"},start:877115,logo:"ipfs://bafkreigovfh3pinsdih777issfgaflwu2yjzroljs2642gbvwikcd3nm4i"},2109:{key:"2109",name:"Exosama Network",shortName:"EXN",chainId:2109,network:"mainnet",multicall:"0x2feFC828e2fEfdE0C9f7740919c6A9139F886067",rpc:["https://rpc.exosama.com"],explorer:{url:"https://explorer.exosama.com"},start:94085,logo:"ipfs://QmaQxfwpXYTomUd24PMx5tKjosupXcm99z1jL1XLq9LWBS"},2152:{key:"2152",name:"Findora",shortName:"Findora",chainId:2152,network:"mainnet",multicall:"0xCF7D1e21CBe9bdEF235aef06C5d8051B3d4DF0f5",rpc:["https://archive.prod.findora.org:8545/"],explorer:{url:"https://evm.findorascan.io"},start:4219343,logo:"ipfs://QmXkneyRB6HbHTHRLCZpZqSsawiyJY7b2kZ2V8ydvKYAgv"},2192:{key:"2192",name:"SnaxChain",shortName:"mainnet",chainId:2192,network:"mainnet",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:[],explorer:{url:"https://explorer.snaxchain.io"},start:1554893,logo:"ipfs://bafkreibzz757piho2llzkbiszpvalf5k5hpmxcwhvrmgp7vpz2vp4vj7ly"},2221:{key:"2221",name:"Kava Testnet",shortName:"testnet",chainId:2221,network:"testnet",multicall:"0xc7193EFE367DF0C9349a1149F4E95A2A35604262",rpc:[],explorer:{url:"https://testnet.kavascan.com"},start:6193104,logo:"ipfs://bafkreibpfubharx32fjqkqbfdhygwdjb2khxdg6meaasrcxsgvowos26f4",testnet:!0},2222:{key:"2222",name:"Kava",shortName:"mainnet",chainId:2222,network:"mainnet",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:[],explorer:{url:"https://kavascan.com"},start:3661165,logo:"ipfs://bafkreibpfubharx32fjqkqbfdhygwdjb2khxdg6meaasrcxsgvowos26f4"},2400:{key:"2400",name:"TCG Verse",shortName:"TCGV",chainId:2400,network:"mainnet",multicall:"0xceC65DEE0b5012F1b7321b2647681F997c7204FC",rpc:["https://rpc.tcgverse.xyz"],explorer:{url:"https://explorer.tcgverse.xyz"},start:57500,logo:"ipfs://bafkreidg4wpewve5mdxrofneqblydkrjl3oevtgpdf3fk3z3vjqam6ocoe"},2522:{key:"2522",name:"Fraxtal Testnet",shortName:"testnet",chainId:2522,network:"testnet",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:[],explorer:{url:"https://holesky.fraxscan.com"},start:1,logo:"ipfs://bafkreieflj4wq6tx7k5kq47z3xnsrdrn2xgm4bxa3uovrnndcb2vqqwlyu",testnet:!0},3338:{key:"3338",name:"peaq",shortName:"mainnet",chainId:3338,network:"mainnet",multicall:"0xc454132B017b55b427f45078E335549A7124f5f7",rpc:[],explorer:{url:"https://peaq.subscan.io"},start:3525964,logo:"ipfs://bafkreidqkleori7pmilesz4t52iebebaqf3oflzmoz646qfuaznanb3sgm"},4162:{key:"4162",name:"SX Rollup",shortName:"mainnet",chainId:4162,network:"mainnet",multicall:"0x46997eb05F6A6A0bD5C140ABed09Cb02CA36b98c",rpc:[],explorer:{url:"https://explorerl2.sx.technology"},start:1847483,logo:"ipfs://bafkreibjkjx7evbw74e3sx65dtmcdr4g2rrbcorb2ivd6jz6yh6on6ozw4"},4200:{key:"4200",name:"Merlin",shortName:"merlin",chainId:4200,network:"mainnet",multicall:"0x830E7E548F4D80947a40A7Cf3a2a53166a0C3980",rpc:[],explorer:{url:"https://scan.merlinchain.io"},start:589494,logo:"ipfs://bafkreicew2qv3m756m7xs2nrjezinghps7rlessrqjqetvox74w4hov2xe"},4337:{key:"4337",name:"Beam",shortName:"Beam",chainId:4337,network:"mainnet",multicall:"0x4956F15eFdc3dC16645e90Cc356eAFA65fFC65Ec",rpc:[],explorer:{url:"https://subnets.avax.network/beam"},start:1,logo:"ipfs://QmaKRLxXPdeTsLx7MFLS3CJbhpSbResgoeL4fCgHB1mTsF"},4689:{key:"4689",name:"IoTeX",shortName:"IoTeX",chainId:4689,network:"mainnet",multicall:"0x9c8B105c94282CDB0F3ecF27e3cfA96A35c07be6",rpc:["https://babel-api.mainnet.iotex.io"],explorer:{url:"https://iotexscan.io"},start:11533283,logo:"ipfs://QmNkr1UPcBYbvLp7d7Pk4eF3YCsHpaNkfusKZNtykL2EQC"},5e3:{key:"5000",name:"Mantle",chainId:5e3,network:"mainnet",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:["https://rpc.mantle.xyz"],explorer:{url:"https://mantlescan.xyz"},start:304717,logo:"ipfs://bafkreidkucwfn4mzo2gtydrt2wogk3je5xpugom67vhi4h4comaxxjzoz4"},5555:{key:"5555",name:"Chain Verse",shortName:"ChainVerse",chainId:5555,network:"ChainVerse",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:["https://rpc.chainverse.info"],explorer:{url:"https://explorer.chainverse.info"},start:6334180,logo:"ipfs://QmQyJt28h4wN3QHPXUQJQYQqGiFUD77han3zibZPzHbitk"},5611:{key:"5611",name:"opBNB Testnet",shortName:"testnet",chainId:5611,network:"testnet",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:[],explorer:{url:"https://opbnb-testnet.bscscan.com"},start:3705108,logo:"ipfs://bafkreibll4la7wqerzs7zwxjne2j7ayynbg2wlenemssoahxxj5rbt6c64",testnet:!0},6102:{key:"6102",name:"Cascadia Testnet",shortName:"Cascadia",chainId:6102,network:"testnet",multicall:"0x728989819bAD588F193563008E0a03E8cD6a3e4a",rpc:["https://testnet.cascadia.foundation"],explorer:{url:"https://explorer.cascadia.foundation"},testnet:!0,start:370457,logo:"ipfs://QmWkhZYhReYyaa5pQXj32hEGxoRcBqarFMcfQScELmjYQj"},6900:{key:"6900",name:"Animechain Testnet",shortName:"testnet",chainId:6900,network:"testnet",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:[],explorer:{url:"https://explorer-animechain-testnet-i8yja6a1a0.t.conduit.xyz"},start:1666749,logo:"ipfs://bafkreihm7dy6jzkd3nh6mokq4vshuzwkoeyjmbb3qkskn77rt5iufn7egi",testnet:!0},7332:{key:"7332",name:"Horizen EON",shortName:"EON",chainId:7332,network:"mainnet",multicall:"0xC743e4910Bdd4e5aBacCA38F74cdA270281C5eef",rpc:[],explorer:{url:"https://eon-explorer.horizenlabs.io"},start:85108,logo:"ipfs://QmUYQdsnkUoiDiQ3WaWrtH7fsc5yQDC7kZJCHmC2qWPTPt"},7341:{key:"7341",name:"Shyft",shortName:"Shyft",chainId:7341,network:"mainnet",multicall:"0xceb10e9133D771cA93c8002Be527A465E85381a2",rpc:["https://rpc.shyft.network"],explorer:{url:"https://bx.shyft.network"},start:3673983,logo:"ipfs://bafkreifwxnnfk6koabzmxgcxcwlrwt6b5gijdain2gyqee77q4ajfb7fu4"},7560:{key:"7560",name:"Cyber",shortName:"mainnet",chainId:7560,network:"mainnet",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:[],explorer:{url:"https://cyberscan.co"},start:1731707,logo:"ipfs://bafkreifm2bbehoqpz4454o7gixnxfi6cgvqlxigqr3f6ipj7l2omtgfgnm"},8217:{key:"8217",name:"Kaia Mainnet",shortName:"kaia-mainnet",chainId:8217,network:"mainnet",multicall:"0x5f5f0d1b9ff8b3dcace308e39b13b203354906e9",rpc:["https://archive-en.node.kaia.io"],ws:["wss://archive-en.node.kaia.io/ws"],explorer:{url:"https://kaiascan.com"},start:91582357,logo:"ipfs://bafkreifm6l67f4blcv7qwuszalwoxzptt5ad2f3t472lytr3d2hmi626ju"},8453:{key:"8453",name:"Base",shortName:"mainnet",chainId:8453,network:"mainnet",multicall:"0xca11bde05977b3631167028862be2a173976ca11",rpc:[],explorer:{url:"https://basescan.org"},start:5022,logo:"ipfs://QmaxRoHpxZd8PqccAynherrMznMufG6sdmHZLihkECXmZv"},9001:{key:"9001",name:"Evmos Network",shortName:"Evmos",chainId:9001,network:"mainnet",multicall:"0x37763d16f8dBf6F185368E0f256350cAb7E24b26",rpc:["https://eth.bd.evmos.org:8545"],ws:["wss://eth.bd.evmos.org:8546"],explorer:{url:"https://escan.live"},start:13959539,logo:"ipfs://bafkreif4obrdoiretpozdd56seziywc6clha7wwkbldng3ovry2bpzly34"},9990:{key:"9990",name:"Agung testnet",shortName:"testnet",chainId:9990,network:"testnet",multicall:"0xc454132B017b55b427f45078E335549A7124f5f7",rpc:[],explorer:{url:"https://agung-testnet.subscan.io"},start:2031789,logo:"ipfs://bafkreidqkleori7pmilesz4t52iebebaqf3oflzmoz646qfuaznanb3sgm",testnet:!0},1e4:{key:"10000",name:"smartBCH",shortName:"BCH",chainId:1e4,network:"mainnet",multicall:"0x1b38EBAd553f218e2962Cb1C0539Abb5d6A37774",rpc:["https://smartbch.greyh.at/"],explorer:{url:"https://smartbch-explorer.web.app"},start:268248,logo:"ipfs://QmWG1p7om4hZ4Yi4uQvDpxg4si7qVYhtppGbcDGrhVFvMd"},10243:{key:"10243",name:"Arthera Testnet",shortName:"Arthera_",chainId:10243,network:"testnet",testnet:!0,multicall:"0x27c7FC597aD2E81C4c1cA1769972f79DaF042Da7",rpc:["https://rpc-test.arthera.net"],explorer:{url:"https://explorer-test.arthera.net"},start:10523,logo:"ipfs://QmYQp3e52KjkT4bYdAvB6ACEEpXs2D8DozsDitaADRY2Ak"},13337:{key:"13337",name:"Beam Testnet",shortName:"testnet",chainId:13337,network:"testnet",multicall:"0x9BF49b704EE2A095b95c1f2D4EB9010510c41C9E",rpc:[],explorer:{url:"https://subnets-test.avax.network/beam"},start:3,logo:"ipfs://QmaKRLxXPdeTsLx7MFLS3CJbhpSbResgoeL4fCgHB1mTsF",testnet:!0},13371:{key:"13371",name:"Immutable zkEVM",shortName:"mainnet",chainId:13371,network:"mainnet",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:[],explorer:{url:"https://explorer.immutable.com"},start:3680945,logo:"ipfs://bafkreiepnhfv3hgexddjpyaeemxo3byhtxxit6t4zsponyczee6ddjqxwi"},13473:{key:"13473",name:"Immutable zkEVM Testnet",shortName:"testnet",chainId:13473,network:"testnet",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:[],explorer:{url:"https://explorer.testnet.immutable.com"},start:5307209,logo:"ipfs://bafkreiepnhfv3hgexddjpyaeemxo3byhtxxit6t4zsponyczee6ddjqxwi",testnet:!0},14800:{key:"14800",name:"Vana Moksha Testnet",shortName:"testnet",chainId:14800,network:"testnet",multicall:"0xD8d2dFca27E8797fd779F8547166A2d3B29d360E",rpc:[],explorer:{url:"https://moksha.vanascan.io"},start:732283,logo:"ipfs://bafkreibotel3dmc5og5rf3tpt7l74awkene7x6q3oxtwhptt4y4rpa7vsa",testnet:!0},16718:{key:"16718",name:"AirDAO",chainId:16718,network:"mainnet",multicall:"0x25e81aC81A8B03389D78CB45faB78353aB528574",rpc:["https://network-archive.ambrosus.io"],ws:["wss://network-archive.ambrosus.io/ws"],explorer:{url:"https://airdao.io/explorer"},start:22922566,logo:"ipfs://QmSxXjvWng3Diz4YwXDV2VqSPgMyzLYBNfkjJcr7rzkxom"},29548:{key:"29548",name:"MCH Verse",shortName:"mainnet",chainId:29548,network:"mainnet",multicall:"0x1d39652386488CE1fE4254E105F5A42a04d43dB2",rpc:[],explorer:{url:"https://explorer.oasys.mycryptoheroes.net"},start:27458402,logo:"ipfs://QmZZnwR1y6cU1sare2TQmwqkNDLXQxD4GdPrmHLmUoPtbU"},33111:{key:"33111",name:"Curtis",shortName:"apechain",chainId:33111,network:"testnet",multicall:"0xc454132B017b55b427f45078E335549A7124f5f7",rpc:[],explorer:{url:"https://curtis.apescan.io"},start:6661339,logo:"ipfs://bafkreicljxttjq2xkgfwwpii5xegirgq2ctrnsjnzelxudjj33qzq65apu",testnet:!0},33139:{key:"33139",name:"ApeChain",shortName:"mainnet",chainId:33139,network:"mainnet",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:[],explorer:{url:"https://apescan.io"},start:20889,logo:"ipfs://bafkreielbgcox2jsw3g6pqulqb7pyjgx7czjt6ahnibihaij6lozoy53w4"},42161:{key:"42161",name:"Arbitrum One",chainId:42161,network:"Arbitrum mainnet",multicall:"0x7A7443F8c577d537f1d8cD4a629d40a3148Dd7ee",rpc:["https://rpc.ankr.com/arbitrum","https://speedy-nodes-nyc.moralis.io/9e03baabdc27be2a35bdec4a/arbitrum/mainnet","https://arb-mainnet.g.alchemy.com/v2/JDvtNGwnHhTltIwfnxQocKwKkCTKA1DL"],explorer:{url:"https://arbiscan.io"},start:256508,logo:"ipfs://QmWZ5SMRfvcK8tycsDqojQaSiKedgtVkS7CkZdxPgeCVsZ"},42170:{key:"42170",name:"Arbitrum Nova",chainId:42170,network:"Arbitrum Nova",multicall:"0x4E74EBd9CABff51cE9a43EFe059bA8c5A28E4A14",rpc:["https://nova.arbitrum.io/rpc","https://arbitrum-nova.public.blastapi.io"],explorer:{url:"https://nova.arbiscan.io"},start:6006607,logo:"ipfs://bafkreie5xsqt3mrrwu7v32qpmmctibhzhgxf4emfzzddsdhdlfsa7fmplu"},42220:{key:"42220",name:"Celo",shortName:"Celo",chainId:42220,network:"mainnet",multicall:"0xb8d0d2C1391eeB350d2Cd39EfABBaaEC297368D9",rpc:["https://celo.snapshot.org","https://forno.celo.org","https://celo-mainnet--rpc.datahub.figment.io/apikey/e892a66dc36e4d2d98a5d6406d609796/"],explorer:{url:"https://explorer.celo.org"},start:6599803,logo:"ipfs://QmS2tVJ7rdJRe1NHXAi2L86yCbUwVVrmB2mHQeNdJxvQti"},43113:{key:"43113",name:"Avalanche FUJI Testnet",chainId:43113,network:"testnet",testnet:!0,multicall:"0x984476ea55e32e785A9D8FF14329f99D74E3d2A2",rpc:["https://api.avax-test.network/ext/bc/C/rpc"],explorer:{url:"https://testnet.snowtrace.io"},start:10528153,logo:"ipfs://QmeS75uS7XLR8o8uUzhLRVYPX9vMFf4DXgKxQeCzyy7vM2"},43114:{key:"43114",name:"Avalanche",chainId:43114,network:"mainnet",multicall:"0x7E9985aE4C8248fdB07607648406a48C76e9e7eD",rpc:["https://nd-784-543-849.p2pify.com/aa7b29fc5fed65b34f0ee6b8de33f8c0/ext/bc/C/rpc","https://rpc.ankr.com/avalanche","https://api.avax.network/ext/bc/C/rpc"],explorer:{url:"https://snowtrace.io"},start:536483,logo:"ipfs://QmeS75uS7XLR8o8uUzhLRVYPX9vMFf4DXgKxQeCzyy7vM2"},47805:{key:"47805",name:"REI Mainnet",chainId:47805,network:"mainnet",multicall:"0x9eE9904815B80C39C1a27294E69a8626EAa7952d",rpc:["https://rpc.rei.network"],explorer:{url:"https://scan.rei.network"},start:1715902,logo:"ipfs://QmTogMDLmDgJjDjUKDHDuc2KVTVDbXf8bXJLFiVe8PRxgo"},53935:{key:"53935",name:"DFK Chain",chainId:53935,network:"mainnet",multicall:"0x5b24224dC16508DAD755756639E420817DD4c99E",rpc:["https://subnets.avax.network/defi-kingdoms/dfk-chain/rpc"],explorer:{url:"https://subnets.avax.network/defi-kingdoms"},start:62,logo:"ipfs://QmZNkpVgPbuVbDcsi6arwH1om3456FGnwfDqYQJWUfHDEx"},57054:{key:"57054",name:"Sonic Blaze Testnet",shortName:"testnet",chainId:57054,network:"testnet",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:[],explorer:{url:"https://testnet.sonicscan.org"},start:60,logo:"ipfs://bafkreic5fffatwy2gzf6y5iymje6ijii43tz4wlxl35da36guurhibjx44",testnet:!0},57073:{key:"57073",name:"Ink",shortName:"mainnet",chainId:57073,network:"mainnet",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:[],explorer:{url:"https://explorer.inkonchain.com"},start:6659154,logo:"ipfs://bafkreics2duafru4mw36wftcmklgrsgq6fz4lgcjctzmov34bxjzuuypju"},59141:{key:"59141",name:"Linea Sepolia",shortName:"testnet",chainId:59141,network:"testnet",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:[],explorer:{url:"https://sepolia.lineascan.build"},start:227427,logo:"ipfs://bafkreihtyzolub3sejuwc32hpdpjnt7ksowaguni2yuho3kyihhcqrtqce",testnet:!0},59144:{key:"59144",name:"Linea",shortName:"linea",chainId:59144,network:"mainnet",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:[],explorer:{url:"https://lineascan.build"},start:42,logo:"ipfs://bafkreihtyzolub3sejuwc32hpdpjnt7ksowaguni2yuho3kyihhcqrtqce"},69e3:{key:"69000",name:"Animechain",shortName:"mainnet",chainId:69e3,network:"mainnet",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:[],explorer:{url:"https://explorer-animechain-39xf6m45e3.t.conduit.xyz"},start:23482,logo:"ipfs://bafkreihm7dy6jzkd3nh6mokq4vshuzwkoeyjmbb3qkskn77rt5iufn7egi"},80001:{key:"80001",name:"Polygon Mumbai",chainId:80001,network:"testnet",testnet:!0,multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:["https://speedy-nodes-nyc.moralis.io/9e03baabdc27be2a35bdec4a/polygon/mumbai/archive","https://rpc-mumbai.matic.today"],ws:["wss://ws-mumbai.matic.today"],explorer:{url:"https://mumbai.polygonscan.com",apiUrl:"https://api-mumbai.polygonscan.com"},start:12011090,logo:"ipfs://bafkreihgr7zy7vi5kqddybfaezwuhvssg57qluwmyan4qq7l57nr7w7wey"},80002:{key:"80002",name:"Polygon Amoy Testnet",shortName:"testnet",chainId:80002,network:"testnet",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:[],explorer:{url:"https://amoy.polygonscan.com"},start:3127388,logo:"ipfs://bafkreibfiyvhqnme2vbxxfcku7qkxgjpkg6ywdkplxh4oxlkqsbznyorfm",testnet:!0},81457:{key:"81457",name:"Blast",shortName:"mainnet",chainId:81457,network:"mainnet",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:[],explorer:{url:"https://blastscan.io"},start:88189,logo:"ipfs://bafkreicqhrimt2zyp2kvhmbpvffxlmxovkg5vw6zkissyzibcfy45kbvrm"},84532:{key:"84532",name:"Base Sepolia",shortName:"testnet",chainId:84532,network:"testnet",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:[],explorer:{url:"https://base-sepolia.blockscout.com"},start:1059647,logo:"ipfs://QmaxRoHpxZd8PqccAynherrMznMufG6sdmHZLihkECXmZv",testnet:!0},314159:{key:"314159",name:"Filecoin Calibration Testnet",shortName:"testnet",chainId:314159,network:"testnet",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:[],explorer:{url:"https://calibration.filscan.io/en"},start:1446201,logo:"ipfs://bafkreiffbopdjior7li3nlemzko7rjua6wd2hfh2vhdbenqbv4tfsbnzwu",testnet:!0},686868:{key:"686868",name:"Merlin Testnet",shortName:"merlin",chainId:686868,network:"testnet",multicall:"0x758BC6321b7c68F4986d62a4D46E83A2DCb58c80",rpc:[],explorer:{url:"https://testnet-scan.merlinchain.io"},start:3562021,logo:"ipfs://bafkreicew2qv3m756m7xs2nrjezinghps7rlessrqjqetvox74w4hov2xe",testnet:!0},713715:{key:"713715",name:"Sei EVM Devnet",shortName:"devnet",chainId:713715,network:"testnet",multicall:"0xEe8d287B844959ADe40d718Dc23077ba920e2f07",rpc:[],explorer:{url:"https://seitrace.com"},start:1463669,logo:"ipfs://bafkreiammyt7uztbztqbcqv4bydnczsh2fqmnjf6jxj4xnskzzl6sjrigq",testnet:!0},763373:{key:"763373",name:"Ink Sepolia",shortName:"testnet",chainId:763373,network:"testnet",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:[],explorer:{url:"https://explorer-sepolia.inkonchain.com"},start:9701940,logo:"ipfs://bafkreics2duafru4mw36wftcmklgrsgq6fz4lgcjctzmov34bxjzuuypju",testnet:!0},810180:{key:"810180",name:"zkLink Nova",shortName:"zlink",chainId:810180,network:"mainnet",multicall:"0x825267E0fA5CAe92F98540828a54198dcB3Eaeb5",rpc:[],explorer:{url:"https://explorer.zklink.io"},start:146055,logo:"ipfs://bafkreic6c3iems5235qapyhyrygha7akqrsfact2nok3y2uhljpzxrdu74"},810181:{key:"810181",name:"zkLink Nova Sepolia",shortName:"testnet",chainId:810181,network:"testnet",multicall:"0x97148F8fDdd9A1620f72EC1Bb2932916623d9da5",rpc:[],explorer:{url:"https://sepolia.explorer.zklink.io"},start:43723,logo:"ipfs://bafkreic6c3iems5235qapyhyrygha7akqrsfact2nok3y2uhljpzxrdu74",testnet:!0},11155111:{key:"11155111",name:"Sepolia testnet",shortName:"Sepolia",chainId:11155111,network:"sepolia",testnet:!0,multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:["https://sepolia.infura.io/v3/d26b4fd748814fe994b05899fd89e667"],ensResolvers:["0x8FADE66B79cC9f707aB26799354482EB93a5B7dD"],ensNameWrapper:"0x0635513f179D50A207757E05759CbD106d7dFcE8",ensSubgraph:"https://subgrapher.snapshot.org/subgraph/arbitrum/DmMXLtMZnGbQXASJ7p1jfzLUbBYnYUD9zNBTxpkjHYXV",explorer:{url:"https://sepolia.etherscan.io",apiUrl:"https://api-sepolia.etherscan.io"},start:751532,logo:"ipfs://bafkreid7ndxh6y2ljw2jhbisodiyrhcy2udvnwqgon5wgells3kh4si5z4"},11155420:{key:"11155420",name:"OP Sepolia",shortName:"testnet",chainId:11155420,network:"testnet",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:[],explorer:{url:"https://sepolia-optimism.etherscan.io"},start:1620204,logo:"ipfs://QmfF4kwhGL8QosUXvgq2KWCmavhKBvwD6kbhs7L4p5ZAWb",testnet:!0},111557560:{key:"111557560",name:"Cyber Testnet",shortName:"testnet",chainId:111557560,network:"testnet",multicall:"0xffc391F0018269d4758AEA1a144772E8FB99545E",rpc:[],explorer:{url:"https://testnet.cyberscan.co"},start:304545,logo:"ipfs://bafkreifm2bbehoqpz4454o7gixnxfi6cgvqlxigqr3f6ipj7l2omtgfgnm",testnet:!0},168587773:{key:"168587773",name:"Blast Sepolia",shortName:"testnet",chainId:168587773,network:"testnet",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:[],explorer:{url:"https://sepolia.blastexplorer.io"},start:756690,logo:"ipfs://bafkreibfmkjg22cozxppzcoxswj45clvh2rqhxzax57cmmgudbtkf4dkce",testnet:!0},245022926:{key:"245022926",name:"Neon Devnet",shortName:"devnet",chainId:245022926,network:"testnet",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:[],explorer:{url:"https://devnet.neonscan.org"},start:205206112,logo:"ipfs://QmecRPQGa4bU7tybg1sUQY48Md9rWnmhrT6WW5ueqvhg6P",testnet:!0},1313161554:{key:"1313161554",name:"Aurora",shortName:"Aurora",chainId:1313161554,network:"mainnet",multicall:"0x32b50c286DEFd2932a0247b8bb940b78c063F16c",rpc:["https://mainnet.aurora.dev"],explorer:{url:"https://explorer.mainnet.aurora.dev"},start:57190533,logo:"ipfs://QmeRhsR1UPRTQCizdhmgr2XxphXebVKU5di97uCV2UMFpa"},16666e5:{key:"1666600000",name:"Harmony",shortName:"HarmonyMainnet",chainId:16666e5,network:"mainnet",multicall:"0x9c31392D2e0229dC4Aa250F043d46B9E82074BF8",rpc:["https://a.api.s0.t.hmny.io"],ws:["wss://ws.s0.t.hmny.io"],explorer:{url:"https://explorer.harmony.one"},start:10911984,logo:"ipfs://QmNnGPr1CNvj12SSGzKARtUHv9FyEfE5nES73U4vBWQSJL"},16667e5:{key:"1666700000",name:"Harmony Testnet",shortName:"HarmonyTestnet",chainId:16667e5,network:"testnet",testnet:!0,multicall:"0x9923589503Fd205feE3d367DDFF2378f0F7dD2d4",rpc:["https://api.s0.b.hmny.io"],ws:["wss://ws.s0.b.hmny.io"],explorer:{url:"https://explorer.pops.one"},start:7521509,logo:"ipfs://QmNnGPr1CNvj12SSGzKARtUHv9FyEfE5nES73U4vBWQSJL"}};class DP{constructor(t,e,r,i){this.proposal=t,this.votes=e,this.strategies=r,this.selected=i}static isValidChoice(t,e){return"number"==typeof t&&void 0!==(null==e?void 0:e[t-1])}getValidVotes(){return this.votes.filter((t=>DP.isValidChoice(t.choice,this.proposal.choices)))}getScores(){return this.proposal.choices.map(((t,e)=>{const r=this.getValidVotes().filter((t=>t.choice===e+1));return r.reduce(((t,e)=>t+e.balance),0)}))}getScoresByStrategy(){return this.proposal.choices.map(((t,e)=>{const r=this.strategies.map(((t,r)=>{const i=this.getValidVotes().filter((t=>t.choice===e+1));return i.reduce(((t,e)=>t+e.scores[r]),0)}));return r}))}getScoresTotal(){return this.votes.reduce(((t,e)=>t+e.balance),0)}getChoiceString(){return this.proposal.choices[this.selected-1]}}class $P{constructor(t,e,r,i){this.proposal=t,this.votes=e,this.strategies=r,this.selected=i}static isValidChoice(t,e){return Array.isArray(t)&&t.every((t=>void 0!==(null==e?void 0:e[t-1])))&&t.length===new Set(t).size}getValidVotes(){return this.votes.filter((t=>$P.isValidChoice(t.choice,this.proposal.choices)))}getScores(){return this.proposal.choices.map(((t,e)=>this.getValidVotes().filter((t=>t.choice.includes(e+1))).reduce(((t,e)=>t+e.balance),0)))}getScoresByStrategy(){return this.proposal.choices.map(((t,e)=>this.strategies.map(((t,r)=>this.getValidVotes().filter((t=>t.choice.includes(e+1))).reduce(((t,e)=>t+e.scores[r]),0)))))}getScoresTotal(){return this.votes.reduce(((t,e)=>t+e.balance),0)}getChoiceString(){return this.selected?this.proposal.choices.filter(((t,e)=>this.selected.includes(e+1))).join(", "):""}}function LP(t,e){const r=t/e.reduce(((t,e)=>t+e),0);return isNaN(r)?0:r}function FP(t,e){return Math.sqrt(t*e)}function UP(t){return t*t}function qP(t,e){return t.map((t=>e*t))}class VP{constructor(t,e,r,i){this.proposal=t,this.votes=e,this.strategies=r,this.selected=i}static isValidChoice(t,e){return"object"==typeof t&&!Array.isArray(t)&&null!==t&&Object.keys(t).every((t=>void 0!==(null==e?void 0:e[Number(t)-1])))&&Object.keys(t).length>0&&Object.values(t).every((t=>"number"==typeof t&&t>=0))&&Object.values(t).some((t=>"number"==typeof t&&t>0))}getValidVotes(){return this.votes.filter((t=>VP.isValidChoice(t.choice,this.proposal.choices)))}getScores(){const t=this.getValidVotes(),e=this.getValidVotes().reduce(((t,e)=>t+e.balance),0),r=this.proposal.choices.map(((e,r)=>{const i=t.map((t=>FP(LP(t.choice[r+1],Object.values(t.choice)),t.balance))).reduce(((t,e)=>t+e),0);return UP(i)}));return qP(r.map(((t,e)=>LP(r[e],r))),e)}getScoresByStrategy(){const t=this.getValidVotes(),e=this.getValidVotes().reduce(((t,e)=>t+e.balance),0),r=this.proposal.choices.map(((e,r)=>this.strategies.map(((e,i)=>t.map((t=>FP(LP(t.choice[r+1],Object.values(t.choice)),t.scores[i]))).reduce(((t,e)=>t+e),0))))).map((t=>t.map((t=>[UP(t)]))));return r.map(((t,i)=>qP(this.strategies.map(((t,e)=>LP(r[i][e][0],r.flat(2)))),e)))}getScoresTotal(){return this.votes.reduce(((t,e)=>t+e.balance),0)}getChoiceString(){return this.proposal.choices.map(((t,e)=>{if(this.selected[e+1]){const r=LP(this.selected[e+1],Object.values(this.selected));return`${Math.round(1e3*r)/10}% for ${t}`}})).filter((t=>null!=t)).join(", ")}}function HP(t,e){const r=[...new Set(t.map((t=>t[0])).flat())],i=Object.entries(t.reduce(((t,[e],r,i)=>{const n=i[r][1];t[e[0]][0]+=n;const o=i[r][2];return o.length>1?t[e[0]][1]=o.map(((r,i)=>r+t[e[0]][1][i]||r)):t[e[0]][1]=[t[e[0]][1].concat(o).reduce(((t,e)=>t+e),0)],t}),Object.assign({},...r.map((t=>({[t]:[0,[]]})))))),n=i.map((t=>[t[0],t[1][0]])),[o,a]=n.reduce((([t,e],[r,i])=>i>e?[r,i]:[t,e]),["?",-1/0]),[s,h]=n.reduce((([t,e],[r,i])=>i<e?[r,i]:[t,e]),["?",1/0]),u=i.sort(((t,e)=>e[1][0]-t[1][0])),l=t.map((t=>t[1])).reduce(((t,e)=>t+e),0);return e.push({round:e.length+1,sortedByHighest:u}),a>l/2||u.length<3?e:HP(t.map((t=>[t[0].filter((t=>t!=s)),t[1],t[2]])).filter((t=>t[0].length>0)),e)}function GP(t){const e=HP(t.map((t=>[t.choice,t.balance,t.scores])),[]);return e[e.length-1].sortedByHighest}class ZP{constructor(t,e,r,i){this.proposal=t,this.votes=e,this.strategies=r,this.selected=i}static isValidChoice(t,e){return Array.isArray(t)&&t.every((t=>void 0!==(null==e?void 0:e[t-1])))&&t.length===new Set(t).size&&t.length>0&&t.length===e.length}getValidVotes(){return this.votes.filter((t=>ZP.isValidChoice(t.choice,this.proposal.choices)))}getScores(){return function(t,e){const r=GP(t);return e.choices.map(((t,e)=>r.filter((t=>Number(t[0])===e+1)).reduce(((t,e)=>t+e[1][0]),0)))}(this.getValidVotes(),this.proposal)}getScoresByStrategy(){const t=GP(this.getValidVotes());return this.proposal.choices.map(((e,r)=>this.strategies.map(((e,i)=>t.filter((t=>Number(t[0])===r+1)).reduce(((t,e)=>t+e[1][1][i]),0)))))}getScoresTotal(){return this.votes.reduce(((t,e)=>t+e.balance),0)}getChoiceString(){return this.selected.map((t=>{if(this.proposal.choices[t-1])return this.proposal.choices[t-1]})).map(((t,e)=>`(${SB(e+1)}) ${t}`)).join(", ")}}class KP{constructor(t,e,r,i){this.proposal=t,this.votes=e,this.strategies=r,this.selected=i}static isValidChoice(t,e){return!(!Array.isArray(t)||0===t.length||t.length>e.length||new Set(t).size!==t.length)&&t.every((t=>Number.isInteger(t)&&t>=1&&t<=e.length))}getValidVotes(){return this.votes.filter((t=>KP.isValidChoice(t.choice,this.proposal.choices)))}getScores(){const t=this.getValidVotes(),e=this.proposal.choices.length,r=Array.from({length:e},(()=>Array(e).fill(0))),i=this.getScoresTotal();for(const e of t)for(let t=0;t<e.choice.length;t++)for(let i=t+1;i<e.choice.length;i++){const n=e.choice[t]-1,o=e.choice[i]-1;r[n][o]+=e.balance,r[o][n]-=e.balance}const n=Array(e).fill(0);let o=0;for(let t=0;t<e;t++)for(let i=0;i<e;i++)if(t!==i){const e=r[t][i];e>0?n[t]++:e<0?n[i]++:(n[t]+=.5,n[i]+=.5)}return o=n.reduce(((t,e)=>t+e),0),o>0?n.map((t=>t/o*i)):n.map((()=>i/e))}getScoresByStrategy(){const t=this.getValidVotes(),e=this.proposal.choices.length,r=this.strategies.length,i=Array.from({length:e},(()=>Array.from({length:e},(()=>Array(r).fill(0))))),n=Array(r).fill(0);for(const e of t)for(let t=0;t<r;t++)n[t]+=e.scores[t];for(const e of t)for(let t=0;t<e.choice.length;t++)for(let n=t+1;n<e.choice.length;n++){const o=e.choice[t]-1,a=e.choice[n]-1;for(let t=0;t<r;t++)i[o][a][t]+=e.scores[t],i[a][o][t]-=e.scores[t]}const o=Array.from({length:e},(()=>Array(r).fill(0)));for(let t=0;t<e;t++)for(let n=0;n<e;n++)if(t!==n)for(let e=0;e<r;e++){const r=i[t][n][e];r>0?o[t][e]++:r<0?o[n][e]++:(o[t][e]+=.5,o[n][e]+=.5)}const a=Array.from({length:e},(()=>Array(r).fill(0)));for(let t=0;t<r;t++){let r=0;for(let i=0;i<e;i++)r+=o[i][t];if(r>0)for(let i=0;i<e;i++)a[i][t]=o[i][t]/r*n[t];else if(n[t]>0)for(let r=0;r<e;r++)a[r][t]=n[t]/e}return a}getScoresTotal(){return this.getValidVotes().reduce(((t,e)=>t+e.balance),0)}getChoiceString(){return this.selected.map((t=>this.proposal.choices[t-1])).join(", ")}}function JP(t,e,r){const i=r.reduce(((t,e)=>t+e),0),n=e[t]/i*100;return isNaN(n)?0:n}function WP(t,e,r){return JP(t+1,e,Object.values(e))/100*r}class YP{constructor(t,e,r,i){this.proposal=t,this.votes=e,this.strategies=r,this.selected=i}static isValidChoice(t,e){return"object"==typeof t&&!Array.isArray(t)&&null!==t&&Object.keys(t).every((t=>void 0!==(null==e?void 0:e[Number(t)-1])))&&Object.keys(t).length>0&&Object.values(t).every((t=>"number"==typeof t&&t>=0))&&Object.values(t).some((t=>"number"==typeof t&&t>0))}getValidVotes(){return this.votes.filter((t=>YP.isValidChoice(t.choice,this.proposal.choices)))}getScores(){const t=this.proposal.choices.map(((t,e)=>this.getValidVotes().map((t=>WP(e,t.choice,t.balance))).reduce(((t,e)=>t+e),0))),e=this.getValidVotes().reduce(((t,e)=>t+e.balance),0);return t.map(((e,r)=>JP(r,t,t))).map((t=>e/100*t))}getScoresByStrategy(){const t=this.proposal.choices.map(((t,e)=>this.strategies.map(((t,r)=>this.getValidVotes().map((t=>WP(e,t.choice,t.scores[r]))).reduce(((t,e)=>t+e),0))))).map((t=>t.map((t=>[t])))),e=this.getValidVotes().reduce(((t,e)=>t+e.balance),0);return t.map(((r,i)=>this.strategies.map(((e,r)=>JP(0,t[i][r],t.flat(2)))).map((t=>[e/100*t])).flat()))}getScoresTotal(){return this.votes.reduce(((t,e)=>t+e.balance),0)}getChoiceString(){return this.proposal.choices.map(((t,e)=>{if(this.selected[e+1])return`${Math.round(10*JP(e+1,this.selected,Object.values(this.selected)))/10}% for ${t}`})).filter((t=>null!=t)).join(", ")}}var QP={"single-choice":DP,approval:$P,quadratic:VP,"ranked-choice":ZP,copeland:KP,weighted:YP,basic:DP};const XP={1:"https://subgrapher.snapshot.org/delegation/1",10:"https://subgrapher.snapshot.org/delegation/10",56:"https://subgrapher.snapshot.org/delegation/56",100:"https://subgrapher.snapshot.org/delegation/100",137:"https://subgrapher.snapshot.org/delegation/137",146:"https://subgrapher.snapshot.org/delegation/146",250:"https://subgrapher.snapshot.org/delegation/250",5e3:"https://subgrapher.snapshot.org/delegation/5000",8453:"https://subgrapher.snapshot.org/delegation/8453",42161:"https://subgrapher.snapshot.org/delegation/42161",59144:"https://subgrapher.snapshot.org/delegation/59144",81457:"https://subgrapher.snapshot.org/delegation/81457",84532:"https://subgrapher.snapshot.org/delegation/84532",11155111:"https://subgrapher.snapshot.org/delegation/11155111"},tB=1e3;function eB(t){return t.length===tB&&t[0].timestamp===t[t.length-1].timestamp}function rB(t,e){const r=function(t){return`${t.delegator}-${t.delegate}-${t.space}`}(e);t.has(r)||t.set(r,e)}function iB(t){const e=["",t];return t.includes(".eth")&&e.push(t.replace(".eth","")),e}function nB(t){return r(this,arguments,void 0,(function*({url:t,spaces:e,pivot:r,snapshot:i}){const n={delegations:{__args:{where:{timestamp_gte:r},first:tB,skip:0,orderBy:"timestamp",orderDirection:"asc"},delegator:!0,space:!0,delegate:!0,timestamp:!0}};return"latest"!==i&&(n.delegations.__args.block={number:i}),null!==e&&(n.delegations.__args.where.space_in=e),(yield kB(t,n)).delegations||[]}))}const oB=["response not found during CCIP fetch","UNSUPPORTED_OPERATION"],aB="0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e",sB=["function text(bytes32 node, string calldata key) external view returns (string memory)","function resolver(bytes32 node) view returns (address)"],hB="0x0000000000000000000000000000000000000000",uB={"0x534e5f4d41494e":{name:"Starknet",testnet:!1},"0x534e5f5345504f4c4941":{name:"Starknet Sepolia",testnet:!0}},lB={Accept:"application/json","Content-Type":"application/json"},cB="https://score.snapshot.org";function dB(t=cB,e={path:""}){const r=new URL(t);e.path&&(r.pathname=e.path);const i=r.searchParams.get("apiKey");let n=Object.assign({},lB);return i&&(r.searchParams.delete("apiKey"),n=Object.assign(Object.assign({},lB),{"X-API-KEY":i})),{url:r.toString(),headers:n}}function fB(t){return r(this,void 0,void 0,(function*(){let e=yield t.text();try{e=JSON.parse(e)}catch(r){return Promise.reject({code:t.status||500,message:"Failed to parse response from score API",data:e})}return e.error?Promise.reject(e.error):e}))}const mB=new Qd({allErrors:!0,allowUnionTypes:!0,$data:!0,passContext:!0});rf(mB),of(mB),mB.addFormat("address",{validate:t=>{try{return t===he(t)}catch(t){return!1}}}),mB.addFormat("evmAddress",{validate:t=>{try{return he(t),!0}catch(t){return!1}}}),mB.addFormat("starknetAddress",{validate:t=>{try{return gR(t)===t}catch(t){return!1}}}),mB.addFormat("long",{validate:()=>!0}),mB.addFormat("lowercase",{validate:t=>t===t.toLowerCase()}),mB.addFormat("color",{validate:t=>!!t&&!!t.match(/^#[0-9A-F]{6}$/)}),mB.addFormat("ethValue",{validate:t=>{if(!t.match(/^([0-9]|[1-9][0-9]+)(\.[0-9]+)?$/))return!1;try{return function(t,e){if("string"!=typeof t&&$h.throwArgumentError("value must be a string","value",t),"string"==typeof e){const t=Lh.indexOf(e);-1!==t&&(e=3*t)}Eh(t,null!=e?e:18)}(t,18),!0}catch(t){return!1}}});const pB=Object.keys(BP),gB=Object.keys(BP).filter((t=>!BP[t].testnet));function yB(t){const e=t.endsWith(".eth"),r=t.split(".");if(1===r.length)return"tld";if(2!==r.length||e){if(r.length>2)return"subdomain";if(e)return"ens";throw new Error("Invalid domain")}return"other-tld"}function wB(t){return r(this,void 0,void 0,(function*(){var e;const r=yield h(`https://cloudflare-dns.com/dns-query?name=${t}&type=TXT`,{headers:{accept:"application/dns-json"}}),i=yield r.json();if(3===i.Status)return hB;if(0!==i.Status)throw new Error("Failed to fetch DNS Owner");const n=null===(e=i.Answer)||void 0===e?void 0:e.find((t=>t.data.includes("ENS1")));return n?he(n.data.replace(new RegExp('"',"g"),"").split(" ").pop()):hB}))}function vB(t,e,i,n){return r(this,void 0,void 0,(function*(){const r=new Ds(i[0],e,t);try{const t=i[2]||[];return yield r[i[1]](...t,n||{})}catch(t){return Promise.reject(t)}}))}function bB(t,e,i,n,o){return r(this,void 0,void 0,(function*(){const r=(null==o?void 0:o.multicallAddress)||BP[t].multicall,a=new Ds(r,["function aggregate(tuple(address target, bytes callData)[] calls) view returns (uint256 blockNumber, bytes[] returnData)"],e),s=new Ji(i);try{const t=(null==o?void 0:o.limit)||500;(null==o?void 0:o.limit)&&delete o.limit;const e=Math.ceil(n.length/t),r=[];Array.from(Array(e)).forEach(((e,i)=>{const h=n.slice(t*i,t*(i+1));r.push(a.aggregate(h.map((t=>[t[0].toLowerCase(),s.encodeFunctionData(t[1],t[2])])),o||{}))}));let i=yield Promise.all(r);return i=i.reduce(((t,[,e])=>t.concat(e)),[]),i.map(((t,e)=>s.decodeFunctionResult(n[e][1],t)))}catch(t){return Promise.reject(t)}}))}function kB(t,e){return r(this,arguments,void 0,(function*(t,e,r={}){const i={query:El.jsonToGraphQLQuery({query:e})};r.variables&&(i.variables=r.variables);const n=yield h(t,{method:"POST",headers:Object.assign({Accept:"application/json","Content-Type":"application/json"},null==r?void 0:r.headers),body:JSON.stringify(i)});let o=yield n.text();try{o=JSON.parse(o)}catch(e){throw new Error(`Errors found in subgraphRequest: URL: ${t}, Status: ${n.status}, Response: ${o.substring(0,400)}`)}if(o.errors)throw new Error(`Errors found in subgraphRequest: URL: ${t}, Status: ${n.status}, Response: ${JSON.stringify(o.errors).substring(0,400)}`);const{data:a}=o;return a||{}}))}function MB(t,e=PP[0]){const r=`https://${e}`;if(!t)return null;if(!(t.startsWith("ipfs://")||t.startsWith("ipns://")||t.startsWith("https://")||t.startsWith("http://")))return`${r}/ipfs/${t}`;const i=t.split("://")[0];return"ipfs"===i?t.replace("ipfs://",`${r}/ipfs/`):"ipns"===i?t.replace("ipns://",`${r}/ipns/`):t}function _B(t,i){return r(this,arguments,void 0,(function*(t,r,i="1",n={}){var o,a;const{ensResolvers:s=(null===(o=BP[i])||void 0===o?void 0:o.ensResolvers)||BP[1].ensResolvers,broviderUrl:h}=n,u=e(n,["ensResolvers","broviderUrl"]);let l;try{l=Vu(qu(t))}catch(t){return null}const c=Xp(i,{broviderUrl:h}),d=[[aB,"resolver",[l]],...s.map((t=>[t,"text",[l,r]]))],[[f],...m]=yield bB(i,c,sB,d,u),p=s.indexOf(f);return-1!==p?null===(a=m[p])||void 0===a?void 0:a[0]:null}))}function EB(t){return r(this,arguments,void 0,(function*(t,e="1",r={}){try{return yield _B(t,"snapshot",e,r)}catch(t){return console.log(t),null}}))}function AB(t){return r(this,arguments,void 0,(function*(t,e="1",r={}){var i,n;if(!(null===(n=null===(i=BP[e])||void 0===i?void 0:i.ensResolvers)||void 0===n?void 0:n.length))throw new Error("Network not supported");const o=yB(t),a=Xp(e,r),s=new Ds(aB,["function owner(bytes32) view returns (address)"],a);let h;try{h=Vu(qu(t))}catch(t){return hB}const u=r.ensNameWrapper||BP[e].ensNameWrapper;let l=yield s.owner(h);if(l===u){const t=new Ds(u,["function ownerOf(uint256) view returns (address)"],a);l=yield t.ownerOf(h)}if(l===hB&&"other-tld"===o){(yield a.resolveName(t))&&(l=yield wB(t))}if(l===hB&&"subdomain"===o)try{l=yield a.resolveName(t)}catch(t){if(oB.every((e=>!t.message.includes(e))))throw t;l=hB}return l||hB}))}function jB(t,e){return r(this,arguments,void 0,(function*(t,e,r={}){const i=yield EB(t,e,r);if(i){let t=ue(i);if(t)return i;const e=i.split("/"),r=e.includes("testnet")?5:4,n=e[r];if(t=ue(n),t)return n}return yield AB(t,e,r)}))}function xB(t,e){return r(this,void 0,void 0,(function*(){if(!t.endsWith(".shib"))return hB;const r=yield h("https://stamp.fyi",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({method:"get_owner",params:t,network:e})});return(yield r.json()).result}))}function SB(t){const e=["th","st","nd","rd"],r=t%100;return t+(e[(r-20)%10]||e[r]||e[0])}function NB(t){return!!BP[t]}function IB(t){return t!==hB&&(ue(t)||CB(t))}function TB(t,e){return"latest"===t||"number"==typeof t&&t>=BP[e].start}function CB(t){if(!t)return!1;try{return gR(t),!0}catch(t){return!1}}function zB(t){return ue(t)}function OB(t){return Promise.reject(new Error(t))}mB.addKeyword({keyword:"snapshotNetwork",validate:function(t,e){return"mainnet"===(this.snapshotEnv||"default")?gB.includes(e):pB.includes(e)},error:{message:"network not allowed"}}),mB.addKeyword({keyword:"starknetNetwork",validate:function(t,e){return"mainnet"===(this.snapshotEnv||"default")?Object.keys(uB).filter((t=>!uB[t].testnet)).includes(e):Object.keys(uB).includes(e)},error:{message:"network not allowed"}}),mB.addFormat("customUrl",{type:"string",validate:t=>!t.length||(t.startsWith("http://")||t.startsWith("https://")||t.startsWith("ipfs://")||t.startsWith("ipns://")||t.startsWith("snapshot://"))}),mB.addFormat("domain",{validate:t=>!!t&&!!t.match(/^(https:\/\/)?([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,}(\/)?$/)});var RB={call:vB,multicall:bB,subgraphRequest:kB,ipfsGet:function(t,e){return r(this,arguments,void 0,(function*(t,e,r="ipfs"){return h(`https://${t}/${r}/${e}`).then((t=>t.json()))}))},getUrl:MB,getJSON:function(t){return r(this,arguments,void 0,(function*(t,e={}){const r=MB(t,e.gateways);return h(r).then((t=>t.json()))}))},sendTransaction:function(t,e,i,n,o){return r(this,arguments,void 0,(function*(t,e,r,i,n,o={}){const a=t.getSigner(),s=new Ds(e,r,t).connect(a);return yield s[i](...n,o)}))},getScores:function(t,e,i,n){return r(this,arguments,void 0,(function*(t,e,r,i,n="latest",o=cB,a={}){if(!Array.isArray(i))return OB("addresses should be an array of addresses");if(0===i.length)return OB("addresses can not be empty");const s=i.find((t=>!IB(t)));if(s)return OB(`Invalid address: ${s}`);if(!NB(r))return OB(`Invalid network: ${r}`);const u=e.find((t=>t.network&&!NB(t.network)));if(u)return OB(`Invalid network (${u.network}) in strategy ${u.name}`);if(!TB(n,r))return OB(`Snapshot (${n}) must be 'latest' or greater than network start block (${BP[r].start})`);new URL(o).pathname="/api/scores";const{url:l,headers:c}=dB(o,{path:"/api/scores"});try{const o={space:t,network:r,snapshot:n,strategies:e,addresses:i},s=yield h(l,{method:"POST",headers:c,body:JSON.stringify({params:o})}),u=yield fB(s);return"all"===a.returnValue?u.result:u.result[a.returnValue||"scores"]}catch(t){return t.errno?Promise.reject({code:t.errno,message:t.toString(),data:""}):Promise.reject(t)}}))},getVp:function(t,e,i,n,o,a,s){return r(this,void 0,void 0,(function*(){const{url:r,headers:u}=dB(null==s?void 0:s.url);if(!IB(t))return OB(`Invalid voter address: ${t}`);if(!NB(e))return OB(`Invalid network: ${e}`);const l=i.find((t=>t.network&&!NB(t.network)));if(l)return OB(`Invalid network (${l.network}) in strategy ${l.name}`);if(!TB(n,e))return OB(`Snapshot (${n}) must be 'latest' or greater than network start block (${BP[e].start})`);const c={method:"POST",headers:u,body:JSON.stringify({jsonrpc:"2.0",method:"get_vp",params:{address:t,network:e,strategies:i,snapshot:n,space:o,delegation:a}})};try{const t=yield h(r,c);return(yield fB(t)).result}catch(t){return t.errno?Promise.reject({code:t.errno,message:t.toString(),data:""}):Promise.reject(t)}}))},validateSchema:function(t,e,r={snapshotEnv:"default",spaceType:"default"}){const i=mB.compile(t),n=i.call(r,e);return n||i.errors},getEnsTextRecord:_B,getSpaceUri:EB,getEnsOwner:AB,getSpaceController:function(t){return r(this,arguments,void 0,(function*(t,e="1",r={}){if(["1","11155111"].includes(e))return jB(t,e,r);if(["109","157"].includes(e))return xB(t,e);throw new Error(`Network not supported: ${e}`)}))},getDelegatesBySpace:function(t,e){return r(this,arguments,void 0,(function*(t,e,r="latest",i={}){const n=i.subgraphUrl||XP[t];if(!n)return Promise.reject(`Delegation subgraph not available for network ${t}`);let o=0;const a=new Map,s=e?iB(e):null;for(;;){const t=yield nB({url:n,spaces:s,pivot:o,snapshot:r});if(eB(t))throw new Error("Unable to paginate delegation");if(t.forEach((t=>{rB(a,t),o=t.timestamp})),t.length<tB)break}return[...a.values()]}))},clone:function(t){return JSON.parse(JSON.stringify(t))},sleep:function(t){return r(this,void 0,void 0,(function*(){return new Promise((e=>{setTimeout(e,t)}))}))},getNumberWithOrdinal:SB,voting:QP,getProvider:Xp,signMessage:function(t,e,i){return r(this,void 0,void 0,(function*(){return e=I(new Y(e,"utf8")),yield t.send("personal_sign",[e,i])}))},getBlockNumber:function(t){return r(this,void 0,void 0,(function*(){try{const e=yield t.getBlockNumber();return parseInt(e)}catch(t){return Promise.reject()}}))},Multicaller:class{constructor(t,e,r,i){this.options={},this.calls=[],this.paths=[],this.network=t,this.provider=e,this.abi=r,this.options=i||{}}call(t,e,r,i){return this.calls.push([e,r,i]),this.paths.push(t),this}execute(t){return r(this,void 0,void 0,(function*(){const e=t||{};return(yield bB(this.network,this.provider,this.abi,this.calls,this.options)).forEach(((t,r)=>Qf(e,this.paths[r],t.length>1?t:t[0]))),this.calls=[],this.paths=[],e}))}},getSnapshots:function(t,e,i,n){return r(this,arguments,void 0,(function*(t,e,r,i,n={}){const o={};if(i.forEach((t=>o[t]="latest")),"latest"===e)return o;const a=`${t}-${e}-${i.join("-")}`,s=Xf[a],h=Date.now();if(s&&tm>h)return s;tm<h&&(Xf={},tm=h+36e5-h%36e5),o[t]=e;const u=Object.keys(o).filter((e=>t!==e));if(0===u.length)return o;const l={blocks:{__args:{where:{ts:(yield r.getBlock(e)).timestamp,network_in:u}},network:!0,number:!0}},c=n.blockFinderUrl||"https://blockfinder.snapshot.org";return(yield kB(c,l)).blocks.forEach((t=>o[t.network]=t.number)),Xf[a]=o,o}))},getHash:function(t,e){return(QR(t)?tP:RP).getHash(t,e)},verify:function(t,e,i){return r(this,arguments,void 0,(function*(t,e,r,i="1",n={}){if(!CB(t)&&!zB(t))throw new Error("Invalid address");const o=QR(r)?tP:RP;return yield o.default(t,e,r,i,n)}))},validate:function(t,e,i,n,o,a,s){return r(this,void 0,void 0,(function*(){if(!IB(e))return OB(`Invalid author: ${e}`);if(!NB(n))return OB(`Invalid network: ${n}`);if(!TB(o,n))return OB(`Snapshot (${o}) must be 'latest' or greater than network start block (${BP[n].start})`);s||(s={});const{url:r,headers:u}=dB(s.url),l={method:"POST",headers:u,body:JSON.stringify({jsonrpc:"2.0",method:"validate",params:{validation:t,author:e,space:i,network:n,snapshot:o,params:a}})};try{const t=yield h(r,l);return(yield fB(t)).result}catch(t){return t.errno?Promise.reject({code:t.errno,message:t.toString(),data:""}):Promise.reject(t)}}))},isStarknetAddress:CB,isEvmAddress:zB,getFormattedAddress:function(t,e){if("evm"===e&&zB(t))return he(t);if("starknet"===e&&CB(t))return gR(t);throw new Error(`Invalid address: ${t}`)},SNAPSHOT_SUBGRAPH_URL:XP};return{Client:Re,Client712:Re,schemas:qe,utils:RB}}));
232
+ const ox=JA.Store,ax=Kj.MemoryCookieStore,sx=XA.pathMatch,{fromCallback:hx}=WA,{getCustomInspectSymbol:ux}=$j,lx=/^[\x21\x23-\x2B\x2D-\x3A\x3C-\x5B\x5D-\x7E]+$/,cx=/[\x00-\x1F]/,dx=["\n","\r","\0"],fx=/[\x20-\x3A\x3C-\x7E]+/,mx=/[\x09\x20-\x2F\x3B-\x40\x5B-\x60\x7B-\x7E]/,px={jan:0,feb:1,mar:2,apr:3,may:4,jun:5,jul:6,aug:7,sep:8,oct:9,nov:10,dec:11},gx=2147483647e3,yx='Invalid sameSiteContext option for getCookies(); expected one of "strict", "lax", or "none"';function wx(t){rx.validate(rx.isNonEmptyString(t),t);const e=String(t).toLowerCase();return"none"===e||"lax"===e||"strict"===e?e:null}const vx=Object.freeze({SILENT:"silent",STRICT:"strict",DISABLED:"unsafe-disabled"}),bx=/(?:^(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)){3}$)|(?:^(?:(?:[a-f\d]{1,4}:){7}(?:[a-f\d]{1,4}|:)|(?:[a-f\d]{1,4}:){6}(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)){3}|:[a-f\d]{1,4}|:)|(?:[a-f\d]{1,4}:){5}(?::(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)){3}|(?::[a-f\d]{1,4}){1,2}|:)|(?:[a-f\d]{1,4}:){4}(?:(?::[a-f\d]{1,4}){0,1}:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)){3}|(?::[a-f\d]{1,4}){1,3}|:)|(?:[a-f\d]{1,4}:){3}(?:(?::[a-f\d]{1,4}){0,2}:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)){3}|(?::[a-f\d]{1,4}){1,4}|:)|(?:[a-f\d]{1,4}:){2}(?:(?::[a-f\d]{1,4}){0,3}:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)){3}|(?::[a-f\d]{1,4}){1,5}|:)|(?:[a-f\d]{1,4}:){1}(?:(?::[a-f\d]{1,4}){0,4}:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)){3}|(?::[a-f\d]{1,4}){1,6}|:)|(?::(?:(?::[a-f\d]{1,4}){0,5}:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)){3}|(?::[a-f\d]{1,4}){1,7}|:)))$)/,kx="\n\\[?(?:\n(?:[a-fA-F\\d]{1,4}:){7}(?:[a-fA-F\\d]{1,4}|:)|\n(?:[a-fA-F\\d]{1,4}:){6}(?:(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)(?:\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)){3}|:[a-fA-F\\d]{1,4}|:)|\n(?:[a-fA-F\\d]{1,4}:){5}(?::(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)(?:\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)){3}|(?::[a-fA-F\\d]{1,4}){1,2}|:)|\n(?:[a-fA-F\\d]{1,4}:){4}(?:(?::[a-fA-F\\d]{1,4}){0,1}:(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)(?:\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)){3}|(?::[a-fA-F\\d]{1,4}){1,3}|:)|\n(?:[a-fA-F\\d]{1,4}:){3}(?:(?::[a-fA-F\\d]{1,4}){0,2}:(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)(?:\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)){3}|(?::[a-fA-F\\d]{1,4}){1,4}|:)|\n(?:[a-fA-F\\d]{1,4}:){2}(?:(?::[a-fA-F\\d]{1,4}){0,3}:(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)(?:\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)){3}|(?::[a-fA-F\\d]{1,4}){1,5}|:)|\n(?:[a-fA-F\\d]{1,4}:){1}(?:(?::[a-fA-F\\d]{1,4}){0,4}:(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)(?:\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)){3}|(?::[a-fA-F\\d]{1,4}){1,6}|:)|\n(?::(?:(?::[a-fA-F\\d]{1,4}){0,5}:(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)(?:\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)){3}|(?::[a-fA-F\\d]{1,4}){1,7}|:))\n)(?:%[0-9a-zA-Z]{1,})?\\]?\n".replace(/\s*\/\/.*$/gm,"").replace(/\n/g,"").trim(),Mx=new RegExp(`^${kx}$`);function _x(t,e,r,i){let n=0;for(;n<t.length;){const e=t.charCodeAt(n);if(e<=47||e>=58)break;n++}return n<e||n>r?null:i||n==t.length?parseInt(t.substr(0,n),10):null}function Ex(t){const e=t.split(":"),r=[0,0,0];if(3!==e.length)return null;for(let t=0;t<3;t++){const i=2==t,n=_x(e[t],1,2,i);if(null===n)return null;r[t]=n}return r}function Ax(t){t=String(t).substr(0,3).toLowerCase();const e=px[t];return e>=0?e:null}function jx(t){if(!t)return;const e=t.split(mx);if(!e)return;let r=null,i=null,n=null,o=null,a=null,s=null;for(let t=0;t<e.length;t++){const h=e[t].trim();if(!h.length)continue;let u;null===n&&(u=Ex(h),u)?(r=u[0],i=u[1],n=u[2]):null!==o||(u=_x(h,1,2,!0),null===u)?null!==a||(u=Ax(h),null===u)?null===s&&(u=_x(h,2,4,!0),null!==u&&(s=u,s>=70&&s<=99?s+=1900:s>=0&&s<=69&&(s+=2e3))):a=u:o=u}return null===o||null===a||null===s||null===n||o<1||o>31||s<1601||r>23||i>59||n>59?void 0:new Date(Date.UTC(s,a,o,r,i,n))}function xx(t){return rx.validate(rx.isDate(t),t),t.toUTCString()}function Sx(t){return null==t?null:(t=t.trim().replace(/^\./,""),Mx.test(t)&&(t=t.replace("[","").replace("]","")),nx&&/[^\u0001-\u007f]/.test(t)&&(t=nx.toASCII(t)),t.toLowerCase())}function Nx(t,e,r){if(null==t||null==e)return null;if(!1!==r&&(t=Sx(t),e=Sx(e)),t==e)return!0;const i=t.lastIndexOf(e);return!(i<=0)&&(t.length===e.length+i&&("."===t.substr(i-1,1)&&!bx.test(t)))}function Ix(t){if(!t||"/"!==t.substr(0,1))return"/";if("/"===t)return t;const e=t.lastIndexOf("/");return 0===e?"/":t.slice(0,e)}function Tx(t,e){t=function(t){if(rx.isEmptyString(t))return t;for(let e=0;e<dx.length;e++){const r=t.indexOf(dx[e]);-1!==r&&(t=t.substr(0,r))}return t}(t),rx.validate(rx.isString(t),t);let r,i,n=t.indexOf("=");if(e)0===n&&(n=(t=t.substr(1)).indexOf("="));else if(n<=0)return;if(n<=0?(r="",i=t.trim()):(r=t.substr(0,n).trim(),i=t.substr(n+1).trim()),cx.test(r)||cx.test(i))return;const o=new Dx;return o.key=r,o.value=i,o}function Cx(t,e){if(e&&"object"==typeof e||(e={}),rx.isEmptyString(t)||!rx.isString(t))return null;const r=(t=t.trim()).indexOf(";"),i=Tx(-1===r?t:t.substr(0,r),!!e.loose);if(!i)return;if(-1===r)return i;const n=t.slice(r+1).trim();if(0===n.length)return i;const o=n.split(";");for(;o.length;){const t=o.shift().trim();if(0===t.length)continue;const e=t.indexOf("=");let r,n;switch(-1===e?(r=t,n=null):(r=t.substr(0,e),n=t.substr(e+1)),r=r.trim().toLowerCase(),n&&(n=n.trim()),r){case"expires":if(n){const t=jx(n);t&&(i.expires=t)}break;case"max-age":if(n&&/^-?[0-9]+$/.test(n)){const t=parseInt(n,10);i.setMaxAge(t)}break;case"domain":if(n){const t=n.trim().replace(/^\./,"");t&&(i.domain=t.toLowerCase())}break;case"path":i.path=n&&"/"===n[0]?n:null;break;case"secure":i.secure=!0;break;case"httponly":i.httpOnly=!0;break;case"samesite":switch(n?n.toLowerCase():""){case"strict":i.sameSite="strict";break;case"lax":i.sameSite="lax";break;case"none":i.sameSite="none";break;default:i.sameSite=void 0}break;default:i.extensions=i.extensions||[],i.extensions.push(t)}}return i}function zx(t){let e;try{e=JSON.parse(t)}catch(t){return t}return e}function Ox(t){if(!t||rx.isEmptyString(t))return null;let e;if("string"==typeof t){if(e=zx(t),e instanceof Error)return null}else e=t;const r=new Dx;for(let t=0;t<Dx.serializableProperties.length;t++){const i=Dx.serializableProperties[t];void 0!==e[i]&&e[i]!==Bx[i]&&("expires"===i||"creation"===i||"lastAccessed"===i?null===e[i]?r[i]=null:r[i]="Infinity"==e[i]?"Infinity":new Date(e[i]):r[i]=e[i])}return r}function Rx(t,e){rx.validate(rx.isObject(t),t),rx.validate(rx.isObject(e),e);let r=0;const i=t.path?t.path.length:0;if(r=(e.path?e.path.length:0)-i,0!==r)return r;return r=(t.creation?t.creation.getTime():gx)-(e.creation?e.creation.getTime():gx),0!==r||(r=t.creationIndex-e.creationIndex),r}function Px(t){if(t instanceof Object)return t;try{t=decodeURI(t)}catch(t){}return qA(t)}const Bx={key:"",value:"",expires:"Infinity",maxAge:null,domain:null,path:null,secure:!1,httpOnly:!1,extensions:null,hostOnly:null,pathIsDefault:null,creation:null,lastAccessed:null,sameSite:void 0};class Dx{constructor(t={}){const e=ux();e&&(this[e]=this.inspect),Object.assign(this,Bx,t),this.creation=this.creation||new Date,Object.defineProperty(this,"creationIndex",{configurable:!1,enumerable:!1,writable:!0,value:++Dx.cookiesCreated})}inspect(){const t=Date.now(),e=null!=this.hostOnly?this.hostOnly:"?",r=this.creation?t-this.creation.getTime()+"ms":"?",i=this.lastAccessed?t-this.lastAccessed.getTime()+"ms":"?";return`Cookie="${this.toString()}; hostOnly=${e}; aAge=${i}; cAge=${r}"`}toJSON(){const t={};for(const e of Dx.serializableProperties)this[e]!==Bx[e]&&("expires"===e||"creation"===e||"lastAccessed"===e?null===this[e]?t[e]=null:t[e]="Infinity"==this[e]?"Infinity":this[e].toISOString():"maxAge"===e?null!==this[e]&&(t[e]=this[e]==1/0||this[e]==-1/0?this[e].toString():this[e]):this[e]!==Bx[e]&&(t[e]=this[e]));return t}clone(){return Ox(this.toJSON())}validate(){if(!lx.test(this.value))return!1;if(!(this.expires==1/0||this.expires instanceof Date||jx(this.expires)))return!1;if(null!=this.maxAge&&this.maxAge<=0)return!1;if(null!=this.path&&!fx.test(this.path))return!1;const t=this.cdomain();if(t){if(t.match(/\.$/))return!1;if(null==KA.getPublicSuffix(t))return!1}return!0}setExpires(t){t instanceof Date?this.expires=t:this.expires=jx(t)||"Infinity"}setMaxAge(t){this.maxAge=t===1/0||t===-1/0?t.toString():t}cookieString(){let t=this.value;return null==t&&(t=""),""===this.key?t:`${this.key}=${t}`}toString(){let t=this.cookieString();if(this.expires!=1/0&&(this.expires instanceof Date?t+=`; Expires=${xx(this.expires)}`:t+=`; Expires=${this.expires}`),null!=this.maxAge&&this.maxAge!=1/0&&(t+=`; Max-Age=${this.maxAge}`),this.domain&&!this.hostOnly&&(t+=`; Domain=${this.domain}`),this.path&&(t+=`; Path=${this.path}`),this.secure&&(t+="; Secure"),this.httpOnly&&(t+="; HttpOnly"),this.sameSite&&"none"!==this.sameSite){const e=Dx.sameSiteCanonical[this.sameSite.toLowerCase()];t+=`; SameSite=${e||this.sameSite}`}return this.extensions&&this.extensions.forEach((e=>{t+=`; ${e}`})),t}TTL(t){if(null!=this.maxAge)return this.maxAge<=0?0:1e3*this.maxAge;let e=this.expires;return e!=1/0?(e instanceof Date||(e=jx(e)||1/0),e==1/0?1/0:e.getTime()-(t||Date.now())):1/0}expiryTime(t){if(null!=this.maxAge){const e=t||this.creation||new Date,r=this.maxAge<=0?-1/0:1e3*this.maxAge;return e.getTime()+r}return this.expires==1/0?1/0:this.expires.getTime()}expiryDate(t){const e=this.expiryTime(t);return e==1/0?new Date(gx):e==-1/0?new Date(0):new Date(e)}isPersistent(){return null!=this.maxAge||this.expires!=1/0}canonicalizedDomain(){return null==this.domain?null:Sx(this.domain)}cdomain(){return this.canonicalizedDomain()}}function $x(t){if(null!=t){const e=t.toLowerCase();switch(e){case vx.STRICT:case vx.SILENT:case vx.DISABLED:return e}}return vx.SILENT}Dx.cookiesCreated=0,Dx.parse=Cx,Dx.fromJSON=Ox,Dx.serializableProperties=Object.keys(Bx),Dx.sameSiteLevel={strict:3,lax:2,none:1},Dx.sameSiteCanonical={strict:"Strict",lax:"Lax"};class Lx{constructor(t,e={rejectPublicSuffixes:!0}){"boolean"==typeof e&&(e={rejectPublicSuffixes:e}),rx.validate(rx.isObject(e),e),this.rejectPublicSuffixes=e.rejectPublicSuffixes,this.enableLooseMode=!!e.looseMode,this.allowSpecialUseDomain="boolean"!=typeof e.allowSpecialUseDomain||e.allowSpecialUseDomain,this.store=t||new ax,this.prefixSecurity=$x(e.prefixSecurity),this._cloneSync=Fx("clone"),this._importCookiesSync=Fx("_importCookies"),this.getCookiesSync=Fx("getCookies"),this.getCookieStringSync=Fx("getCookieString"),this.getSetCookieStringsSync=Fx("getSetCookieStrings"),this.removeAllCookiesSync=Fx("removeAllCookies"),this.setCookieSync=Fx("setCookie"),this.serializeSync=Fx("serialize")}setCookie(t,e,r,i){let n;if(rx.validate(rx.isUrlStringOrObject(e),i,r),rx.isFunction(e))return(i=e)(new Error("No URL was specified"));const o=Px(e);if(rx.isFunction(r)&&(i=r,r={}),rx.validate(rx.isFunction(i),i),!rx.isNonEmptyString(t)&&!rx.isObject(t)&&t instanceof String&&0==t.length)return i(null);const a=Sx(o.hostname),s=r.loose||this.enableLooseMode;let h=null;if(r.sameSiteContext&&(h=wx(r.sameSiteContext),!h))return i(new Error(yx));if("string"==typeof t||t instanceof String){if(!(t=Dx.parse(t,{loose:s})))return n=new Error("Cookie failed to parse"),i(r.ignoreError?null:n)}else if(!(t instanceof Dx))return n=new Error("First argument to setCookie must be a Cookie object or string"),i(r.ignoreError?null:n);const u=r.now||new Date;if(this.rejectPublicSuffixes&&t.domain){if(null==KA.getPublicSuffix(t.cdomain(),{allowSpecialUseDomain:this.allowSpecialUseDomain,ignoreError:r.ignoreError})&&!Mx.test(t.domain))return n=new Error("Cookie has domain set to a public suffix"),i(r.ignoreError?null:n)}if(t.domain){if(!Nx(a,t.cdomain(),!1))return n=new Error(`Cookie not in this host's domain. Cookie:${t.cdomain()} Request:${a}`),i(r.ignoreError?null:n);null==t.hostOnly&&(t.hostOnly=!1)}else t.hostOnly=!0,t.domain=a;if(t.path&&"/"===t.path[0]||(t.path=Ix(o.pathname),t.pathIsDefault=!0),!1===r.http&&t.httpOnly)return n=new Error("Cookie is HttpOnly and this isn't an HTTP API"),i(r.ignoreError?null:n);if("none"!==t.sameSite&&void 0!==t.sameSite&&h&&"none"===h)return n=new Error("Cookie is SameSite but this is a cross-origin request"),i(r.ignoreError?null:n);const l=this.prefixSecurity===vx.SILENT;if(!(this.prefixSecurity===vx.DISABLED)){let e,n=!1;if(!function(t){return rx.validate(rx.isObject(t),t),!t.key.startsWith("__Secure-")||t.secure}(t)?(n=!0,e="Cookie has __Secure prefix but Secure attribute is not set"):function(t){return rx.validate(rx.isObject(t)),!t.key.startsWith("__Host-")||t.secure&&t.hostOnly&&null!=t.path&&"/"===t.path}(t)||(n=!0,e="Cookie has __Host prefix but either Secure or HostOnly attribute is not set or Path is not '/'"),n)return i(r.ignoreError||l?null:new Error(e))}const c=this.store;c.updateCookie||(c.updateCookie=function(t,e,r){this.putCookie(e,r)}),c.findCookie(t.domain,t.path,t.key,(function(e,n){if(e)return i(e);const o=function(e){if(e)return i(e);i(null,t)};if(n){if(!1===r.http&&n.httpOnly)return e=new Error("old Cookie is HttpOnly and this isn't an HTTP API"),i(r.ignoreError?null:e);t.creation=n.creation,t.creationIndex=n.creationIndex,t.lastAccessed=u,c.updateCookie(n,t,o)}else t.creation=t.lastAccessed=u,c.putCookie(t,o)}))}getCookies(t,e,r){rx.validate(rx.isUrlStringOrObject(t),r,t);const i=Px(t);rx.isFunction(e)&&(r=e,e={}),rx.validate(rx.isObject(e),r,e),rx.validate(rx.isFunction(r),r);const n=Sx(i.hostname),o=i.pathname||"/";let a=e.secure;null!=a||!i.protocol||"https:"!=i.protocol&&"wss:"!=i.protocol||(a=!0);let s=0;if(e.sameSiteContext){const t=wx(e.sameSiteContext);if(s=Dx.sameSiteLevel[t],!s)return r(new Error(yx))}let h=e.http;null==h&&(h=!0);const u=e.now||Date.now(),l=!1!==e.expire,c=!!e.allPaths,d=this.store;function f(t){if(t.hostOnly){if(t.domain!=n)return!1}else if(!Nx(n,t.domain,!1))return!1;if(!c&&!sx(o,t.path))return!1;if(t.secure&&!a)return!1;if(t.httpOnly&&!h)return!1;if(s){if(Dx.sameSiteLevel[t.sameSite||"none"]>s)return!1}return!(l&&t.expiryTime()<=u)||(d.removeCookie(t.domain,t.path,t.key,(()=>{})),!1)}d.findCookies(n,c?null:o,this.allowSpecialUseDomain,((t,i)=>{if(t)return r(t);i=i.filter(f),!1!==e.sort&&(i=i.sort(Rx));const n=new Date;for(const t of i)t.lastAccessed=n;r(null,i)}))}getCookieString(...t){const e=t.pop();rx.validate(rx.isFunction(e),e);t.push((function(t,r){t?e(t):e(null,r.sort(Rx).map((t=>t.cookieString())).join("; "))})),this.getCookies.apply(this,t)}getSetCookieStrings(...t){const e=t.pop();rx.validate(rx.isFunction(e),e);t.push((function(t,r){t?e(t):e(null,r.map((t=>t.toString())))})),this.getCookies.apply(this,t)}serialize(t){rx.validate(rx.isFunction(t),t);let e=this.store.constructor.name;rx.isObject(e)&&(e=null);const r={version:"tough-cookie@4.1.4",storeType:e,rejectPublicSuffixes:!!this.rejectPublicSuffixes,enableLooseMode:!!this.enableLooseMode,allowSpecialUseDomain:!!this.allowSpecialUseDomain,prefixSecurity:$x(this.prefixSecurity),cookies:[]};if(!this.store.getAllCookies||"function"!=typeof this.store.getAllCookies)return t(new Error("store does not support getAllCookies and cannot be serialized"));this.store.getAllCookies(((e,i)=>e?t(e):(r.cookies=i.map((t=>(delete(t=t instanceof Dx?t.toJSON():t).creationIndex,t))),t(null,r))))}toJSON(){return this.serializeSync()}_importCookies(t,e){let r=t.cookies;if(!r||!Array.isArray(r))return e(new Error("serialized jar has no cookies array"));r=r.slice();const i=t=>{if(t)return e(t);if(!r.length)return e(t,this);let n;try{n=Ox(r.shift())}catch(t){return e(t)}if(null===n)return i(null);this.store.putCookie(n,i)};i()}clone(t,e){1===arguments.length&&(e=t,t=null),this.serialize(((r,i)=>{if(r)return e(r);Lx.deserialize(i,t,e)}))}cloneSync(t){if(0===arguments.length)return this._cloneSync();if(!t.synchronous)throw new Error("CookieJar clone destination store is not synchronous; use async API instead.");return this._cloneSync(t)}removeAllCookies(t){rx.validate(rx.isFunction(t),t);const e=this.store;if("function"==typeof e.removeAllCookies&&e.removeAllCookies!==ox.prototype.removeAllCookies)return e.removeAllCookies(t);e.getAllCookies(((r,i)=>{if(r)return t(r);if(0===i.length)return t(null);let n=0;const o=[];function a(e){if(e&&o.push(e),n++,n===i.length)return t(o.length?o[0]:null)}i.forEach((t=>{e.removeCookie(t.domain,t.path,t.key,a)}))}))}static deserialize(t,e,r){let i;if(3!==arguments.length&&(r=e,e=null),rx.validate(rx.isFunction(r),r),"string"==typeof t){if(i=zx(t),i instanceof Error)return r(i)}else i=t;const n=new Lx(e,{rejectPublicSuffixes:i.rejectPublicSuffixes,looseMode:i.enableLooseMode,allowSpecialUseDomain:i.allowSpecialUseDomain,prefixSecurity:i.prefixSecurity});n._importCookies(i,(t=>{if(t)return r(t);r(null,n)}))}static deserializeSync(t,e){const r="string"==typeof t?JSON.parse(t):t,i=new Lx(e,{rejectPublicSuffixes:r.rejectPublicSuffixes,looseMode:r.enableLooseMode});if(!i.store.synchronous)throw new Error("CookieJar store is not synchronous; use async API instead.");return i._importCookiesSync(r),i}}function Fx(t){return function(...e){if(!this.store.synchronous)throw new Error("CookieJar store is not synchronous; use async API instead.");let r,i;if(this[t](...e,((t,e)=>{r=t,i=e})),r)throw r;return i}}Lx.fromJSON=Lx.deserializeSync,["_importCookies","clone","getCookies","getCookieString","getSetCookieStrings","removeAllCookies","serialize","setCookie"].forEach((t=>{Lx.prototype[t]=hx(Lx.prototype[t])})),Lx.deserialize=hx(Lx.deserialize);var Ux=ix,qx=Lx,Vx=Dx,Hx=ox,Gx=ax,Zx=jx,Kx=xx,Jx=Cx,Wx=Ox,Yx=Nx,Qx=Ix,Xx=sx,tS=KA.getPublicSuffix,eS=Rx,rS=QA.permuteDomain,iS=function(t){if(rx.validate(rx.isString(t)),"/"===t)return["/"];const e=[t];for(;t.length>1;){const r=t.lastIndexOf("/");if(0===r)break;t=t.substr(0,r),e.push(t)}return e.push("/"),e},nS=Sx,oS=vx,aS=rx.ParameterError,sS={version:Ux,CookieJar:qx,Cookie:Vx,Store:Hx,MemoryCookieStore:Gx,parseDate:Zx,formatDate:Kx,parse:Jx,fromJSON:Wx,domainMatch:Yx,defaultPath:Qx,pathMatch:Xx,getPublicSuffix:tS,cookieCompare:eS,permuteDomain:rS,permutePath:iS,canonicalDomain:nS,PrefixSecurityEnum:oS,ParameterError:aS},hS=Object.freeze(Object.assign(Object.create(null),sS,{default:sS,version:Ux,CookieJar:qx,Cookie:Vx,Store:Hx,MemoryCookieStore:Gx,parseDate:Zx,formatDate:Kx,parse:Jx,fromJSON:Wx,domainMatch:Yx,defaultPath:Qx,pathMatch:Xx,getPublicSuffix:tS,cookieCompare:eS,permuteDomain:rS,permutePath:iS,canonicalDomain:nS,PrefixSecurityEnum:oS,ParameterError:aS}));var uS=function(t){if(Array.isArray(t))return t;if("string"!=typeof t)return[];var e,r,i,n,o,a=[],s=0;function h(){for(;s<t.length&&/\s/.test(t.charAt(s));)s+=1;return s<t.length}for(;s<t.length;){for(e=s,o=!1;h();)if(","===(r=t.charAt(s))){for(i=s,s+=1,h(),n=s;s<t.length&&"="!==(r=t.charAt(s))&&";"!==r&&","!==r;)s+=1;s<t.length&&"="===t.charAt(s)?(o=!0,s=n,a.push(t.substring(e,i)),e=s):s=i+1}else s+=1;(!o||s>=t.length)&&a.push(t.substring(e,t.length))}return a};const lS=new Set(["","no-referrer","no-referrer-when-downgrade","same-origin","origin","strict-origin","origin-when-cross-origin","strict-origin-when-cross-origin","unsafe-url"]);function cS(t,e){}function dS(t,e){t.headers.delete(e)}function fS(t,e){const r=t.headers;for(const t of Object.keys(r))t.toLowerCase()===e&&delete r[t]}const mS=new Set([301,302,303,307,308]);async function pS(t,e,r){switch(e.redirect??"follow"){case"error":throw new TypeError(`URI requested responded with a redirect and redirect mode is set to error: ${r.url}`);case"manual":return r;case"follow":break;default:throw new TypeError(`Invalid redirect option: ${e.redirect}`)}const i=r.headers.get("location");if(null===i)return r;const n=r.url,o=new URL(i,n).toString(),a=e.redirectCount??0,s=e.maxRedirect??20;if(a>=s)throw new TypeError(`Reached maximum redirect of ${s} for URL: ${n}`);const h=function(t){return null==t.headers?cS:"function"==typeof t.headers.delete?dS:fS}(e={...e,redirectCount:a+1});if(!function(t,e){const r=new URL(e).hostname,i=new URL(t).hostname;return r===i||r.endsWith(`.${i}`)}(n,o))for(const t of["authorization","www-authenticate","cookie","cookie2"])h(e,t);const u=e.body,l=e.body;if(303!==r.status&&null!=e.body&&("function"==typeof u.pipe||"function"==typeof l.pipeTo))throw new TypeError("Cannot follow redirect with body being a readable stream");return 303!==r.status&&(301!==r.status&&302!==r.status||"POST"!==e.method)||(e.method="GET",e.body=void 0,h(e,"content-length")),r.headers.has("referrer-policy")&&(e.referrerPolicy=function(t){const e=t.split(/[,\s]+/);let r="";for(const t of e)""!==t&&lS.has(t)&&(r=t);return r}(r.headers.get("referrer-policy"))),await t(o,e)}function gS(t,e,r=!0){const i=t,n=e??new qx;async function o(t,e){const a=e??{};e={...e,redirect:"manual"};const s="string"==typeof t?t:t.url??t.href;e=function(t,e,r){if(""===r)return e;const i=t,n=e.headers;return i.headers&&"function"==typeof i.headers.append?i.headers.append("cookie",r):n&&"function"==typeof n.append?n.append("cookie",r):e={...e,headers:{...e.headers,cookie:r}},e}(t,e,await n.getCookieString(s));const h=await i(t,e),u=function(t){const e=t.headers;if("function"==typeof e.getAll)return e.getAll("set-cookie");if("function"==typeof e.raw){const t=e.raw();return Array.isArray(t["set-cookie"])?t["set-cookie"]:[]}const r=t.headers.get("set-cookie");return null!==r?uS(r):[]}(h);return await Promise.all(u.map((async t=>await n.setCookie(t,h.url,{ignoreError:r})))),(e.redirectCount??0)>0&&Object.defineProperty(h,"redirected",{value:!0}),l=h.status,mS.has(l)?await pS(o,a,h):h;var l}return o.toughCookie=hS,o}gS.toughCookie=hS;var yS="undefined"!=typeof globalThis&&globalThis||"undefined"!=typeof self&&self||void 0!==t&&t||{},wS="URLSearchParams"in yS,vS="Symbol"in yS&&"iterator"in Symbol,bS="FileReader"in yS&&"Blob"in yS&&function(){try{return new Blob,!0}catch(t){return!1}}(),kS="FormData"in yS,MS="ArrayBuffer"in yS;if(MS)var _S=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],ES=ArrayBuffer.isView||function(t){return t&&_S.indexOf(Object.prototype.toString.call(t))>-1};function AS(t){if("string"!=typeof t&&(t=String(t)),/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(t)||""===t)throw new TypeError('Invalid character in header field name: "'+t+'"');return t.toLowerCase()}function jS(t){return"string"!=typeof t&&(t=String(t)),t}function xS(t){var e={next:function(){var e=t.shift();return{done:void 0===e,value:e}}};return vS&&(e[Symbol.iterator]=function(){return e}),e}function SS(t){this.map={},t instanceof SS?t.forEach((function(t,e){this.append(e,t)}),this):Array.isArray(t)?t.forEach((function(t){if(2!=t.length)throw new TypeError("Headers constructor: expected name/value pair to be length 2, found"+t.length);this.append(t[0],t[1])}),this):t&&Object.getOwnPropertyNames(t).forEach((function(e){this.append(e,t[e])}),this)}function NS(t){if(!t._noBody)return t.bodyUsed?Promise.reject(new TypeError("Already read")):void(t.bodyUsed=!0)}function IS(t){return new Promise((function(e,r){t.onload=function(){e(t.result)},t.onerror=function(){r(t.error)}}))}function TS(t){var e=new FileReader,r=IS(e);return e.readAsArrayBuffer(t),r}function CS(t){if(t.slice)return t.slice(0);var e=new Uint8Array(t.byteLength);return e.set(new Uint8Array(t)),e.buffer}function zS(){return this.bodyUsed=!1,this._initBody=function(t){var e;this.bodyUsed=this.bodyUsed,this._bodyInit=t,t?"string"==typeof t?this._bodyText=t:bS&&Blob.prototype.isPrototypeOf(t)?this._bodyBlob=t:kS&&FormData.prototype.isPrototypeOf(t)?this._bodyFormData=t:wS&&URLSearchParams.prototype.isPrototypeOf(t)?this._bodyText=t.toString():MS&&bS&&((e=t)&&DataView.prototype.isPrototypeOf(e))?(this._bodyArrayBuffer=CS(t.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):MS&&(ArrayBuffer.prototype.isPrototypeOf(t)||ES(t))?this._bodyArrayBuffer=CS(t):this._bodyText=t=Object.prototype.toString.call(t):(this._noBody=!0,this._bodyText=""),this.headers.get("content-type")||("string"==typeof t?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):wS&&URLSearchParams.prototype.isPrototypeOf(t)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},bS&&(this.blob=function(){var t=NS(this);if(t)return t;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))}),this.arrayBuffer=function(){if(this._bodyArrayBuffer){var t=NS(this);return t||(ArrayBuffer.isView(this._bodyArrayBuffer)?Promise.resolve(this._bodyArrayBuffer.buffer.slice(this._bodyArrayBuffer.byteOffset,this._bodyArrayBuffer.byteOffset+this._bodyArrayBuffer.byteLength)):Promise.resolve(this._bodyArrayBuffer))}if(bS)return this.blob().then(TS);throw new Error("could not read as ArrayBuffer")},this.text=function(){var t,e,r,i,n,o=NS(this);if(o)return o;if(this._bodyBlob)return t=this._bodyBlob,e=new FileReader,r=IS(e),i=/charset=([A-Za-z0-9_-]+)/.exec(t.type),n=i?i[1]:"utf-8",e.readAsText(t,n),r;if(this._bodyArrayBuffer)return Promise.resolve(function(t){for(var e=new Uint8Array(t),r=new Array(e.length),i=0;i<e.length;i++)r[i]=String.fromCharCode(e[i]);return r.join("")}(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},kS&&(this.formData=function(){return this.text().then(PS)}),this.json=function(){return this.text().then(JSON.parse)},this}SS.prototype.append=function(t,e){t=AS(t),e=jS(e);var r=this.map[t];this.map[t]=r?r+", "+e:e},SS.prototype.delete=function(t){delete this.map[AS(t)]},SS.prototype.get=function(t){return t=AS(t),this.has(t)?this.map[t]:null},SS.prototype.has=function(t){return this.map.hasOwnProperty(AS(t))},SS.prototype.set=function(t,e){this.map[AS(t)]=jS(e)},SS.prototype.forEach=function(t,e){for(var r in this.map)this.map.hasOwnProperty(r)&&t.call(e,this.map[r],r,this)},SS.prototype.keys=function(){var t=[];return this.forEach((function(e,r){t.push(r)})),xS(t)},SS.prototype.values=function(){var t=[];return this.forEach((function(e){t.push(e)})),xS(t)},SS.prototype.entries=function(){var t=[];return this.forEach((function(e,r){t.push([r,e])})),xS(t)},vS&&(SS.prototype[Symbol.iterator]=SS.prototype.entries);var OS=["CONNECT","DELETE","GET","HEAD","OPTIONS","PATCH","POST","PUT","TRACE"];function RS(t,e){if(!(this instanceof RS))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');var r,i,n=(e=e||{}).body;if(t instanceof RS){if(t.bodyUsed)throw new TypeError("Already read");this.url=t.url,this.credentials=t.credentials,e.headers||(this.headers=new SS(t.headers)),this.method=t.method,this.mode=t.mode,this.signal=t.signal,n||null==t._bodyInit||(n=t._bodyInit,t.bodyUsed=!0)}else this.url=String(t);if(this.credentials=e.credentials||this.credentials||"same-origin",!e.headers&&this.headers||(this.headers=new SS(e.headers)),this.method=(r=e.method||this.method||"GET",i=r.toUpperCase(),OS.indexOf(i)>-1?i:r),this.mode=e.mode||this.mode||null,this.signal=e.signal||this.signal||function(){if("AbortController"in yS)return(new AbortController).signal}(),this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&n)throw new TypeError("Body not allowed for GET or HEAD requests");if(this._initBody(n),!("GET"!==this.method&&"HEAD"!==this.method||"no-store"!==e.cache&&"no-cache"!==e.cache)){var o=/([?&])_=[^&]*/;if(o.test(this.url))this.url=this.url.replace(o,"$1_="+(new Date).getTime());else{this.url+=(/\?/.test(this.url)?"&":"?")+"_="+(new Date).getTime()}}}function PS(t){var e=new FormData;return t.trim().split("&").forEach((function(t){if(t){var r=t.split("="),i=r.shift().replace(/\+/g," "),n=r.join("=").replace(/\+/g," ");e.append(decodeURIComponent(i),decodeURIComponent(n))}})),e}function BS(t,e){if(!(this instanceof BS))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');if(e||(e={}),this.type="default",this.status=void 0===e.status?200:e.status,this.status<200||this.status>599)throw new RangeError("Failed to construct 'Response': The status provided (0) is outside the range [200, 599].");this.ok=this.status>=200&&this.status<300,this.statusText=void 0===e.statusText?"":""+e.statusText,this.headers=new SS(e.headers),this.url=e.url||"",this._initBody(t)}RS.prototype.clone=function(){return new RS(this,{body:this._bodyInit})},zS.call(RS.prototype),zS.call(BS.prototype),BS.prototype.clone=function(){return new BS(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new SS(this.headers),url:this.url})},BS.error=function(){var t=new BS(null,{status:200,statusText:""});return t.ok=!1,t.status=0,t.type="error",t};var DS=[301,302,303,307,308];BS.redirect=function(t,e){if(-1===DS.indexOf(e))throw new RangeError("Invalid status code");return new BS(null,{status:e,headers:{location:t}})};var $S=yS.DOMException;try{new $S}catch(GM){$S=function(t,e){this.message=t,this.name=e;var r=Error(t);this.stack=r.stack},$S.prototype=Object.create(Error.prototype),$S.prototype.constructor=$S}function LS(t,e){return new Promise((function(r,i){var n=new RS(t,e);if(n.signal&&n.signal.aborted)return i(new $S("Aborted","AbortError"));var o=new XMLHttpRequest;function a(){o.abort()}if(o.onload=function(){var t,e,i={statusText:o.statusText,headers:(t=o.getAllResponseHeaders()||"",e=new SS,t.replace(/\r?\n[\t ]+/g," ").split("\r").map((function(t){return 0===t.indexOf("\n")?t.substr(1,t.length):t})).forEach((function(t){var r=t.split(":"),i=r.shift().trim();if(i){var n=r.join(":").trim();try{e.append(i,n)}catch(t){console.warn("Response "+t.message)}}})),e)};0===n.url.indexOf("file://")&&(o.status<200||o.status>599)?i.status=200:i.status=o.status,i.url="responseURL"in o?o.responseURL:i.headers.get("X-Request-URL");var a="response"in o?o.response:o.responseText;setTimeout((function(){r(new BS(a,i))}),0)},o.onerror=function(){setTimeout((function(){i(new TypeError("Network request failed"))}),0)},o.ontimeout=function(){setTimeout((function(){i(new TypeError("Network request timed out"))}),0)},o.onabort=function(){setTimeout((function(){i(new $S("Aborted","AbortError"))}),0)},o.open(n.method,function(t){try{return""===t&&yS.location.href?yS.location.href:t}catch(e){return t}}(n.url),!0),"include"===n.credentials?o.withCredentials=!0:"omit"===n.credentials&&(o.withCredentials=!1),"responseType"in o&&(bS?o.responseType="blob":MS&&(o.responseType="arraybuffer")),e&&"object"==typeof e.headers&&!(e.headers instanceof SS||yS.Headers&&e.headers instanceof yS.Headers)){var s=[];Object.getOwnPropertyNames(e.headers).forEach((function(t){s.push(AS(t)),o.setRequestHeader(t,jS(e.headers[t]))})),n.headers.forEach((function(t,e){-1===s.indexOf(e)&&o.setRequestHeader(e,t)}))}else n.headers.forEach((function(t,e){o.setRequestHeader(e,t)}));n.signal&&(n.signal.addEventListener("abort",a),o.onreadystatechange=function(){4===o.readyState&&n.signal.removeEventListener("abort",a)}),o.send(void 0===n._bodyInit?null:n._bodyInit)}))}LS.polyfill=!0,yS.fetch||(yS.fetch=LS,yS.Headers=SS,yS.Request=RS,yS.Response=BS);var FS=self.fetch.bind(self);const US=(t,e,r=[])=>{const i=Object.getOwnPropertyDescriptors(e);for(let t of r)delete i[t];Object.defineProperties(t,i)},qS=(t,e=[t])=>{const r=Object.getPrototypeOf(t);return null===r?e:qS(r,[...e,r])},VS=(t,e,r=[])=>{var i;const n=null!==(i=((...t)=>{if(0===t.length)return;let e;const r=t.map((t=>qS(t)));for(;r.every((t=>t.length>0));){const t=r.map((t=>t.pop())),i=t[0];if(!t.every((t=>t===i)))break;e=i}return e})(...t))&&void 0!==i?i:Object.prototype,o=Object.create(n),a=qS(n);for(let e of t){let t=qS(e);for(let e=t.length-1;e>=0;e--){let i=t[e];-1===a.indexOf(i)&&(US(o,i,["constructor",...r]),a.push(i))}}return o.constructor=e,o},HS=t=>t.filter(((e,r)=>t.indexOf(e)==r)),GS=new WeakMap,ZS=t=>GS.get(t),KS=(t,e)=>{var r,i;const n=HS([...Object.getOwnPropertyNames(t),...Object.getOwnPropertyNames(e)]),o={};for(let a of n)o[a]=HS([...null!==(r=null==t?void 0:t[a])&&void 0!==r?r:[],...null!==(i=null==e?void 0:e[a])&&void 0!==i?i:[]]);return o},JS=(t,e)=>{var r,i,n,o;return{property:KS(null!==(r=null==t?void 0:t.property)&&void 0!==r?r:{},null!==(i=null==e?void 0:e.property)&&void 0!==i?i:{}),method:KS(null!==(n=null==t?void 0:t.method)&&void 0!==n?n:{},null!==(o=null==e?void 0:e.method)&&void 0!==o?o:{})}},WS=new Map,YS=(...t)=>{const e=((...t)=>{var e;const r=new Set,i=new Set([...t]);for(;i.size>0;)for(let t of i){const n=[...qS(t.prototype).map((t=>t.constructor)),...null!==(e=ZS(t))&&void 0!==e?e:[]].filter((t=>!r.has(t)));for(let t of n)i.add(t);r.add(t),i.delete(t)}return[...r]})(...t).map((t=>WS.get(t))).filter((t=>!!t));return 0==e.length?{}:1==e.length?e[0]:e.reduce(((t,e)=>((t,e)=>{var r,i,n,o,a,s;return{class:HS([...null!==(r=null==t?void 0:t.class)&&void 0!==r?r:[],...null!==(i=null==e?void 0:e.class)&&void 0!==i?i:[]]),static:JS(null!==(n=null==t?void 0:t.static)&&void 0!==n?n:{},null!==(o=null==e?void 0:e.static)&&void 0!==o?o:{}),instance:JS(null!==(a=null==t?void 0:t.instance)&&void 0!==a?a:{},null!==(s=null==e?void 0:e.instance)&&void 0!==s?s:{})}})(t,e)))};function QS(...t){var e,r,i;const n=t.map((t=>t.prototype));function o(...e){for(const r of t)US(this,new r(...e))}o.prototype=VS(n,o),Object.setPrototypeOf(o,VS(t,null,["prototype"]));let a=o;{const n=YS(...t);for(let t of null!==(e=null==n?void 0:n.class)&&void 0!==e?e:[]){const e=t(a);e&&(a=e)}XS(null!==(r=null==n?void 0:n.static)&&void 0!==r?r:{},a),XS(null!==(i=null==n?void 0:n.instance)&&void 0!==i?i:{},a.prototype)}var s,h;return s=a,h=t,GS.set(s,h),a}const XS=(t,e)=>{const r=t.property,i=t.method;if(r)for(let t in r)for(let i of r[t])i(e,t);if(i)for(let t in i)for(let r of i[t])r(e,t,Object.getOwnPropertyDescriptor(e,t))};var tN=Object.defineProperty,eN=Object.getOwnPropertyDescriptor,rN=Object.getOwnPropertyNames,iN=Object.prototype.hasOwnProperty,nN=(t,e)=>{for(var r in e)tN(t,r,{get:e[r],enumerable:!0})},oN=(t,e,r,i)=>{if(e&&"object"==typeof e||"function"==typeof e)for(let n of rN(e))iN.call(t,n)||n===r||tN(t,n,{get:()=>e[n],enumerable:!(i=eN(e,n))||i.enumerable});return t};nN({},{ADDR_BOUND:()=>VN,API_VERSION:()=>FN,BaseUrl:()=>JN,DEFAULT_GLOBAL_CONFIG:()=>hI,FeeMarginPercentage:()=>XN,HARDENING_4BYTES:()=>sI,HARDENING_BYTE:()=>aI,IS_BROWSER:()=>MN,MASK_250:()=>$N,MASK_31:()=>LN,MAX_STORAGE_ITEM_SIZE:()=>qN,NetworkName:()=>WN,OutsideExecutionCallerAny:()=>iI,PRIME:()=>UN,RANGE_FELT:()=>GN,RANGE_I128:()=>ZN,RANGE_U128:()=>KN,RPC_DEFAULT_VERSION:()=>eI,RPC_NODES:()=>rI,SNIP9_V1_INTERFACE_ID:()=>nI,SNIP9_V2_INTERFACE_ID:()=>oI,SYSTEM_MESSAGES:()=>uI,StarknetChainId:()=>YN,TEXT_TO_FELT_MAX_LEN:()=>BN,TRANSACTION_VERSION:()=>aN.ETransactionVersion,TransactionHashPrefix:()=>QN,UDC:()=>tI,ZERO:()=>DN});var aN={};nN(aN,{JRPC:()=>sN,RPCSPEC06:()=>hN,RPCSPEC07:()=>yg});var sN={},hN={};nN(hN,{EBlockTag:()=>gN,EDAMode:()=>wN,EDataAvailabilityMode:()=>yN,ESimulationFlag:()=>dN,ETransactionExecutionStatus:()=>pN,ETransactionFinalityStatus:()=>mN,ETransactionStatus:()=>fN,ETransactionType:()=>cN,ETransactionVersion:()=>vN,ETransactionVersion2:()=>bN,ETransactionVersion3:()=>kN,Errors:()=>uN,SPEC:()=>lN});var uN={},lN={},cN={DECLARE:"DECLARE",DEPLOY:"DEPLOY",DEPLOY_ACCOUNT:"DEPLOY_ACCOUNT",INVOKE:"INVOKE",L1_HANDLER:"L1_HANDLER"},dN={SKIP_VALIDATE:"SKIP_VALIDATE",SKIP_FEE_CHARGE:"SKIP_FEE_CHARGE"},fN={RECEIVED:"RECEIVED",REJECTED:"REJECTED",ACCEPTED_ON_L2:"ACCEPTED_ON_L2",ACCEPTED_ON_L1:"ACCEPTED_ON_L1"},mN={ACCEPTED_ON_L2:"ACCEPTED_ON_L2",ACCEPTED_ON_L1:"ACCEPTED_ON_L1"},pN={SUCCEEDED:"SUCCEEDED",REVERTED:"REVERTED"},gN={PENDING:"pending",LATEST:"latest"},yN={L1:"L1",L2:"L2"},wN={L1:0,L2:1},vN={V0:"0x0",V1:"0x1",V2:"0x2",V3:"0x3",F0:"0x100000000000000000000000000000000",F1:"0x100000000000000000000000000000001",F2:"0x100000000000000000000000000000002",F3:"0x100000000000000000000000000000003"},bN={V0:"0x0",V1:"0x1",V2:"0x2",F0:"0x100000000000000000000000000000000",F1:"0x100000000000000000000000000000001",F2:"0x100000000000000000000000000000002"},kN={V3:"0x3",F3:"0x100000000000000000000000000000003"};((t,e,r)=>{oN(t,e,"default"),r&&oN(r,e,"default")})(aN,yg);nN({},{IS_BROWSER:()=>MN,addHexPrefix:()=>IN,arrayBufferToString:()=>_N,atobUniversal:()=>jN,btoaUniversal:()=>xN,buf2hex:()=>SN,calcByteLength:()=>CN,concatenateArrayBuffer:()=>PN,padLeft:()=>TN,pascalToSnake:()=>RN,removeHexPrefix:()=>NN,sanitizeBytes:()=>zN,sanitizeHex:()=>ON,stringToArrayBuffer:()=>AN,utf8ToArray:()=>EN});var MN="undefined"!=typeof window;function _N(t){return new Uint8Array(t).reduce(((t,e)=>t+String.fromCharCode(e)),"")}function EN(t){return(new TextEncoder).encode(t)}function AN(t){return EN(t)}function jN(t){return Dg.decode(t)}function xN(t){return Dg.encode(new Uint8Array(t))}function SN(t){return t.reduce(((t,e)=>t+e.toString(16).padStart(2,"0")),"")}function NN(t){return t.replace(/^0x/i,"")}function IN(t){return`0x${NN(t)}`}function TN(t,e,r="0"){return function(t,e,r,i="0"){const n=e-t.length;let o=t;if(n>0){const e=i.repeat(n);o=r?e+t:t+e}return o}(t,e,!0,r)}function CN(t,e=8){const{length:r}=t,i=r%e;return i?(r-i)/e*e+e:r}function zN(t,e=8,r="0"){return TN(t,CN(t,e),r)}function ON(t){const e=zN(NN(t),2);return e?IN(e):e}var RN=t=>/[a-z]/.test(t)?t.split(/(?=[A-Z])/).join("_").toUpperCase():t;function PN(t){const e=t.reduce(((t,e)=>t+e.byteLength),0),r=new Uint8Array(e);let i=0;return t.forEach((t=>{r.set(t,i),i+=t.byteLength})),r}var BN=31,DN=0n,$N=2n**250n-1n,LN=2n**31n-1n,FN=DN,UN=2n**251n+17n*2n**192n+1n,qN=256n,VN=2n**251n-qN,HN=(t,e)=>({min:t,max:e}),GN=HN(DN,UN-1n),ZN=HN(-(2n**127n),2n**127n-1n),KN=HN(DN,2n**128n-1n),JN=(t=>(t.SN_MAIN="https://alpha-mainnet.starknet.io",t.SN_SEPOLIA="https://alpha-sepolia.starknet.io",t))(JN||{}),WN=(t=>(t.SN_MAIN="SN_MAIN",t.SN_SEPOLIA="SN_SEPOLIA",t))(WN||{}),YN=(t=>(t.SN_MAIN="0x534e5f4d41494e",t.SN_SEPOLIA="0x534e5f5345504f4c4941",t))(YN||{}),QN=(t=>(t.DECLARE="0x6465636c617265",t.DEPLOY="0x6465706c6f79",t.DEPLOY_ACCOUNT="0x6465706c6f795f6163636f756e74",t.INVOKE="0x696e766f6b65",t.L1_HANDLER="0x6c315f68616e646c6572",t))(QN||{}),XN=(t=>(t[t.L1_BOUND_MAX_AMOUNT=50]="L1_BOUND_MAX_AMOUNT",t[t.L1_BOUND_MAX_PRICE_PER_UNIT=50]="L1_BOUND_MAX_PRICE_PER_UNIT",t[t.MAX_FEE=50]="MAX_FEE",t))(XN||{}),tI={ADDRESS:"0x041a78e741e5af2fec34b695679bc6891742439f7afb8484ecd7766661ad02bf",ENTRYPOINT:"deployContract"},eI="v0_7",rI={SN_MAIN:[`https://starknet-mainnet.public.blastapi.io/rpc/${eI}`,`https://free-rpc.nethermind.io/mainnet-juno/${eI}`],SN_SEPOLIA:[`https://starknet-sepolia.public.blastapi.io/rpc/${eI}`,`https://free-rpc.nethermind.io/sepolia-juno/${eI}`]},iI="0x414e595f43414c4c4552",nI="0x68cfd18b92d1907b8ba3cc324900277f5a3622099431ea85dd8089255e4181",oI="0x1d1144bb2138366ff28d8e9ab57456b1d332ac42196230c3a602003c89872",aI=128,sI=2147483648n,hI={legacyMode:!1,logLevel:"INFO",accountTxVersion:aN.ETransactionVersion.V2},uI={legacyTxWarningMessage:"You are using a deprecated transaction version (V0,V1,V2)!\nUpdate to the latest V3 transactions!"},lI={};nN(lI,{RpcChannel:()=>pO});nN({},{parse:()=>dI,parseAlwaysAsBig:()=>fI,stringify:()=>mI,stringifyAlwaysAsBig:()=>pI});var cI=t=>{if(!Hg(t))return parseFloat(t);const e=parseInt(t,10);return Number.isSafeInteger(e)?e:BigInt(t)},dI=t=>sy(String(t),void 0,cI),fI=t=>sy(String(t),void 0,ny),mI=(t,e,r,i)=>Ly(t,e,r,i),pI=mI,gI={FAILED_TO_RECEIVE_TXN:1,NO_TRACE_AVAILABLE:10,CONTRACT_NOT_FOUND:20,BLOCK_NOT_FOUND:24,INVALID_TXN_INDEX:27,CLASS_HASH_NOT_FOUND:28,TXN_HASH_NOT_FOUND:29,PAGE_SIZE_TOO_BIG:31,NO_BLOCKS:32,INVALID_CONTINUATION_TOKEN:33,TOO_MANY_KEYS_IN_FILTER:34,CONTRACT_ERROR:40,TRANSACTION_EXECUTION_ERROR:41,CLASS_ALREADY_DECLARED:51,INVALID_TRANSACTION_NONCE:52,INSUFFICIENT_MAX_FEE:53,INSUFFICIENT_ACCOUNT_BALANCE:54,VALIDATION_FAILURE:55,COMPILATION_FAILED:56,CONTRACT_CLASS_SIZE_IS_TOO_LARGE:57,NON_ACCOUNT:58,DUPLICATE_TX:59,COMPILED_CLASS_HASH_MISMATCH:60,UNSUPPORTED_TX_VERSION:61,UNSUPPORTED_CONTRACT_CLASS_VERSION:62,UNEXPECTED_ERROR:63};var yI=class extends Error{name;constructor(t){super(t),Object.defineProperty(this,"name",{value:new.target.name,enumerable:!1,configurable:!0}),function(t,e){const{setPrototypeOf:r}=Object;r?r(t,e):t.__proto__=e}(this,new.target.prototype),function(t,e=t.constructor){const{captureStackTrace:r}=Error;r&&r(t,e)}(this)}},wI=class extends yI{},vI=class extends wI{constructor(t,e,r){super(`RPC: ${e} with params ${mI(r,null,2)}\n\n ${t.code}: ${t.message}: ${mI(t.data)}`),this.baseError=t,this.request={method:e,params:r}}request;get code(){return this.baseError.code}isType(t){return gI[t]===this.code}};nN({},{BlockStatus:()=>AI,BlockTag:()=>jI,ETH_ADDRESS:()=>II,EntryPointType:()=>bI,Literal:()=>NI,NON_ZERO_PREFIX:()=>TI,OutsideExecutionTypesV1:()=>CI,OutsideExecutionTypesV2:()=>zI,OutsideExecutionVersion:()=>OI,RPC:()=>aN,TransactionExecutionStatus:()=>EI,TransactionFinalityStatus:()=>_I,TransactionStatus:()=>MI,TransactionType:()=>kI,TypedDataRevision:()=>pg,Uint:()=>SI,ValidateType:()=>xI});var bI={EXTERNAL:"EXTERNAL",L1_HANDLER:"L1_HANDLER",CONSTRUCTOR:"CONSTRUCTOR"},kI={DECLARE:"DECLARE",DEPLOY:"DEPLOY",DEPLOY_ACCOUNT:"DEPLOY_ACCOUNT",INVOKE:"INVOKE_FUNCTION"},MI={NOT_RECEIVED:"NOT_RECEIVED",RECEIVED:"RECEIVED",ACCEPTED_ON_L2:"ACCEPTED_ON_L2",ACCEPTED_ON_L1:"ACCEPTED_ON_L1",REJECTED:"REJECTED",REVERTED:"REVERTED"},_I={NOT_RECEIVED:"NOT_RECEIVED",RECEIVED:"RECEIVED",ACCEPTED_ON_L2:"ACCEPTED_ON_L2",ACCEPTED_ON_L1:"ACCEPTED_ON_L1"},EI={REJECTED:"REJECTED",REVERTED:"REVERTED",SUCCEEDED:"SUCCEEDED"},AI={PENDING:"PENDING",ACCEPTED_ON_L1:"ACCEPTED_ON_L1",ACCEPTED_ON_L2:"ACCEPTED_ON_L2",REJECTED:"REJECTED"},jI={PENDING:"pending",LATEST:"latest"},xI={DEPLOY:"DEPLOY",CALL:"CALL",INVOKE:"INVOKE"},SI={u8:"core::integer::u8",u16:"core::integer::u16",u32:"core::integer::u32",u64:"core::integer::u64",u128:"core::integer::u128",u256:"core::integer::u256",u512:"core::integer::u512"},NI={ClassHash:"core::starknet::class_hash::ClassHash",ContractAddress:"core::starknet::contract_address::ContractAddress",Secp256k1Point:"core::starknet::secp256k1::Secp256k1Point",U96:"core::internal::bounded_int::BoundedInt::<0, 79228162514264337593543950335>"},II="core::starknet::eth_address::EthAddress",TI="core::zeroable::NonZero::",CI={StarkNetDomain:[{name:"name",type:"felt"},{name:"version",type:"felt"},{name:"chainId",type:"felt"}],OutsideExecution:[{name:"caller",type:"felt"},{name:"nonce",type:"felt"},{name:"execute_after",type:"felt"},{name:"execute_before",type:"felt"},{name:"calls_len",type:"felt"},{name:"calls",type:"OutsideCall*"}],OutsideCall:[{name:"to",type:"felt"},{name:"selector",type:"felt"},{name:"calldata_len",type:"felt"},{name:"calldata",type:"felt*"}]},zI={StarknetDomain:[{name:"name",type:"shortstring"},{name:"version",type:"shortstring"},{name:"chainId",type:"shortstring"},{name:"revision",type:"shortstring"}],OutsideExecution:[{name:"Caller",type:"ContractAddress"},{name:"Nonce",type:"felt"},{name:"Execute After",type:"u128"},{name:"Execute Before",type:"u128"},{name:"Calls",type:"Call*"}],Call:[{name:"To",type:"ContractAddress"},{name:"Selector",type:"selector"},{name:"Calldata",type:"felt*"}]},OI=(t=>(t.UNSUPPORTED="0",t.V1="1",t.V2="2",t))(OI||{}),RI=class{nodeUrl;headers;interval;requestId=0;pendingRequests={};batchPromises={};delayTimer;delayPromise;delayPromiseResolve;baseFetch;constructor(t){this.nodeUrl=t.nodeUrl,this.headers=t.headers,this.interval=t.interval,this.baseFetch=t.baseFetch}async wait(){return this.delayPromise&&this.delayPromiseResolve||(this.delayPromise=new Promise((t=>{this.delayPromiseResolve=t}))),this.delayTimer&&(clearTimeout(this.delayTimer),this.delayTimer=void 0),this.delayTimer=setTimeout((()=>{this.delayPromiseResolve&&(this.delayPromiseResolve(),this.delayPromise=void 0,this.delayPromiseResolve=void 0)}),this.interval),this.delayPromise}addPendingRequest(t,e,r){const i={id:r??`batched_${this.requestId+=1}`,jsonrpc:"2.0",method:t,params:e??void 0};return this.pendingRequests[i.id]=i,i.id}async sendBatch(t){return(await this.baseFetch(this.nodeUrl,{method:"POST",body:mI(t),headers:this.headers})).json()}async fetch(t,e,r){const i=this.addPendingRequest(t,e,r);await this.wait();const n=this.pendingRequests;if(this.pendingRequests={},!this.batchPromises[i]){const t=this.sendBatch(Object.values(n));Object.keys(n).forEach((e=>{this.batchPromises[e]=t}))}const o=await this.batchPromises[i];delete this.batchPromises[i];const a=o.find((t=>t.id===i));if(!a)throw new Error(`Couldn't find the result for the request. Method: ${t}`);return a}};function PI(t,e){if(!t)throw new Error(e||"Assertion failure")}nN({},{addPercent:()=>aT,assertInRange:()=>YI,bigNumberishArrayToDecimalStringArray:()=>QI,bigNumberishArrayToHexadecimalStringArray:()=>XI,cleanHex:()=>WI,getDecimalString:()=>eT,getHexString:()=>rT,getHexStringArray:()=>iT,hexToBytes:()=>oT,hexToDecimalString:()=>JI,isBigNumberish:()=>hT,isHex:()=>qI,isStringWholeNumber:()=>tT,stringToSha256ToArrayBuff4:()=>sT,toBigInt:()=>VI,toCairoBool:()=>nT,toHex:()=>HI,toHex64:()=>KI,toHexString:()=>GI,toStorageKey:()=>ZI});var BI=t=>void 0===t||void 0===t;function DI(t){return"number"==typeof t}function $I(t){return"boolean"==typeof t}function LI(t){return"bigint"==typeof t}function FI(t){return"string"==typeof t}function UI(t){return!!t&&"object"==typeof t&&!Array.isArray(t)}function qI(t){return/^0x[0-9a-f]*$/i.test(t)}function VI(t){return BigInt(t)}function HI(t){return IN(VI(t).toString(16))}var GI=HI;function ZI(t){return IN(VI(t).toString(16).padStart(64,"0"))}function KI(t){const e=IN(VI(t).toString(16).padStart(64,"0"));if(66!==e.length)throw TypeError("number is too big for hex 0x(64) representation");return e}function JI(t){return BigInt(IN(t)).toString(10)}function WI(t){return t.toLowerCase().replace(/^(0x)0+/,"$1")}function YI(t,e,r,i=""){const n=""===i?"invalid length":`invalid ${i} length`,o=BigInt(t),a=BigInt(e),s=BigInt(r);PI(o>=a&&o<=s,`Message not signable, ${n}.`)}function QI(t){return t.map((t=>VI(t).toString(10)))}function XI(t){return t.map((t=>HI(t)))}function tT(t){return/^\d+$/.test(t)}function eT(t){if(qI(t))return JI(t);if(tT(t))return t;throw new Error(`${t} needs to be a hex-string or whole-number-string`)}function rT(t){if(qI(t))return t;if(tT(t))return GI(t);throw new Error(`${t} needs to be a hex-string or whole-number-string`)}function iT(t){return t.map(rT)}function nT(t){return(+t).toString()}function oT(t){if(!qI(t))throw new Error(`${t} needs to be a hex-string`);let e=NN(t);return e.length%2!=0&&(e=`0${e}`),nw(e)}function aT(t,e){const r=BigInt(t);return r+r*BigInt(e)/100n}function sT(t){var e;return oT(HI((e=BigInt(IN(SN(qw(t)))),Number(e&LN))))}function hT(t){return DI(t)||LI(t)||FI(t)&&(qI(t)||tT(t))}function uT(t){const e=NN(HI(BigInt(t))),r=e.length%2==0?e:`0${e}`;return IN(Yb(oT(IN(r))).toString(16))}function lT(t){const e=BigInt(function(t){return IN(Yb(EN(t)).toString(16))}(t));return e&$N}function cT(t){return HI(lT(t))}function dT(t){return DI(t)||LI(t)?HI(t):qI(t)?t:tT(t)?HI(t):cT(t)}function fT(t){const e=IN(t.reduce(((t,e)=>t+NN(HI(e)).padStart(64,"0")),""));return IN(Ky(Ak(oT(e))))}function mT(t,e,r,i,n){return fT([t,e,n,r,i.length,...i])}nN({},{getL2MessageHash:()=>mT,getSelector:()=>dT,getSelectorFromName:()=>cT,keccakBn:()=>uT,solidityUint256PackedKeccak256:()=>fT,starknetKeccak:()=>lT});function pT(t){return/^[\x00-\x7F]*$/.test(t)}function gT(t){return t.length<=BN}function yT(t){return/^[0-9]*$/i.test(t)}function wT(t){return FI(t)&&!qI(t)&&!tT(t)}nN({},{decodeShortString:()=>_T,encodeShortString:()=>MT,isASCII:()=>pT,isDecimalString:()=>yT,isLongText:()=>bT,isShortString:()=>gT,isShortText:()=>vT,isText:()=>wT,splitLongString:()=>kT});var vT=t=>wT(t)&&gT(t),bT=t=>wT(t)&&!gT(t);function kT(t){const e=RegExp(`[^]{1,${BN}}`,"g");return t.match(e)||[]}function MT(t){if(!pT(t))throw new Error(`${t} is not an ASCII string`);if(!gT(t))throw new Error(`${t} is too long`);return IN(t.replace(/./g,(t=>t.charCodeAt(0).toString(16))))}function _T(t){if(!pT(t))throw new Error(`${t} is not an ASCII string`);if(qI(t))return NN(t).replace(/.{2}/g,(t=>String.fromCharCode(parseInt(t,16))));if(yT(t))return _T("0X".concat(BigInt(t).toString(16)));throw new Error(`${t} is not Hex or decimal`)}function ET(t){const e=0n===BigInt(t.pending_word)?"":_T(HI(t.pending_word));return t.data.reduce(((t,e)=>t+(0n===BigInt(e)?"":_T(HI(e)))),"")+e}function AT(t){const e=kT(t),r=e[e.length-1],i=e.map(MT),[n,o]=void 0===r||31===r.length?["0x00",0]:[i.pop(),r.length];return{data:0===i.length?[]:i,pending_word:n,pending_word_len:o}}nN({},{byteArrayFromString:()=>AT,stringFromByteArray:()=>ET});var jT={};function xT(t){if(LI(t)||Number.isInteger(t))return t.toString();if(FI(t)){if(qI(t))return BigInt(t).toString();if(wT(t)){if(!gT(t))throw new Error(`${t} is a long string > 31 chars. Please split it into an array of short strings.`);return BigInt(MT(t)).toString()}if(tT(t))return t}if($I(t))return""+ +t;throw new Error(`${t} can't be computed by felt()`)}nN(jT,{felt:()=>fC,getAbiContractVersion:()=>uC,getArrayType:()=>aC,isCairo1Abi:()=>sC,isCairo1Type:()=>oC,isLen:()=>LT,isTypeArray:()=>UT,isTypeBool:()=>QT,isTypeByteArray:()=>rC,isTypeBytes31:()=>eC,isTypeContractAddress:()=>XT,isTypeEnum:()=>GT,isTypeEthAddress:()=>tC,isTypeFelt:()=>FT,isTypeLiteral:()=>YT,isTypeNamedTuple:()=>VT,isTypeNonZero:()=>hC,isTypeOption:()=>ZT,isTypeResult:()=>KT,isTypeSecp256k1Point:()=>nC,isTypeStruct:()=>HT,isTypeTuple:()=>qT,isTypeU96:()=>iC,isTypeUint:()=>JT,isTypeUint256:()=>WT,tuple:()=>dC,uint256:()=>lC,uint512:()=>cC});var ST=(1n<<128n)-1n,NT=(1n<<256n)-1n,IT=0n,TT=340282366920938463463374607431768211455n,CT=340282366920938463463374607431768211455n,zT=0n,OT=0n,RT=class t{low;high;static abiSelector="core::integer::u256";constructor(...e){if("object"==typeof e[0]&&1===e.length&&"low"in e[0]&&"high"in e[0]){const r=t.validateProps(e[0].low,e[0].high);this.low=r.low,this.high=r.high}else if(1===e.length){const r=t.validate(e[0]);this.low=r&ST,this.high=r>>128n}else{if(2!==e.length)throw Error("Incorrect constructor parameters");{const r=t.validateProps(e[0],e[1]);this.low=r.low,this.high=r.high}}}static validate(t){const e=BigInt(t);if(e<IT)throw Error("bigNumberish is smaller than UINT_256_MIN");if(e>NT)throw new Error("bigNumberish is bigger than UINT_256_MAX");return e}static validateProps(t,e){const r=BigInt(t),i=BigInt(e);if(r<zT||r>TT)throw new Error("low is out of range UINT_256_LOW_MIN - UINT_256_LOW_MAX");if(i<OT||i>CT)throw new Error("high is out of range UINT_256_HIGH_MIN - UINT_256_HIGH_MAX");return{low:r,high:i}}static is(e){try{t.validate(e)}catch(t){return!1}return!0}static isAbiType(e){return e===t.abiSelector}toBigInt(){return(this.high<<128n)+this.low}toUint256HexString(){return{low:IN(this.low.toString(16)),high:IN(this.high.toString(16))}}toUint256DecimalString(){return{low:this.low.toString(10),high:this.high.toString(10)}}toApiRequest(){return[xT(this.low),xT(this.high)]}},PT=(1n<<512n)-1n,BT=0n,DT=0n,$T=class t{limb0;limb1;limb2;limb3;static abiSelector="core::integer::u512";constructor(...e){if("object"==typeof e[0]&&1===e.length&&"limb0"in e[0]&&"limb1"in e[0]&&"limb2"in e[0]&&"limb3"in e[0]){const r=t.validateProps(e[0].limb0,e[0].limb1,e[0].limb2,e[0].limb3);this.limb0=r.limb0,this.limb1=r.limb1,this.limb2=r.limb2,this.limb3=r.limb3}else if(1===e.length){const r=t.validate(e[0]);this.limb0=r&ST,this.limb1=(r&ST<<128n)>>128n,this.limb2=(r&ST<<256n)>>256n,this.limb3=r>>384n}else{if(4!==e.length)throw Error("Incorrect Uint512 constructor parameters");{const r=t.validateProps(e[0],e[1],e[2],e[3]);this.limb0=r.limb0,this.limb1=r.limb1,this.limb2=r.limb2,this.limb3=r.limb3}}}static validate(t){const e=BigInt(t);if(e<BT)throw Error("bigNumberish is smaller than UINT_512_MIN.");if(e>PT)throw Error("bigNumberish is bigger than UINT_512_MAX.");return e}static validateProps(t,e,r,i){const n=BigInt(t),o=BigInt(e),a=BigInt(r),s=BigInt(i);return[n,o,a,s].forEach(((t,e)=>{if(t<DT||t>ST)throw Error(`limb${e} is not in the range of a u128 number`)})),{limb0:n,limb1:o,limb2:a,limb3:s}}static is(e){try{t.validate(e)}catch(t){return!1}return!0}static isAbiType(e){return e===t.abiSelector}toBigInt(){return(this.limb3<<384n)+(this.limb2<<256n)+(this.limb1<<128n)+this.limb0}toUint512HexString(){return{limb0:IN(this.limb0.toString(16)),limb1:IN(this.limb1.toString(16)),limb2:IN(this.limb2.toString(16)),limb3:IN(this.limb3.toString(16))}}toUint512DecimalString(){return{limb0:this.limb0.toString(10),limb1:this.limb1.toString(10),limb2:this.limb2.toString(10),limb3:this.limb3.toString(10)}}toApiRequest(){return[xT(this.limb0),xT(this.limb1),xT(this.limb2),xT(this.limb3)]}},LT=t=>/_len$/.test(t),FT=t=>"felt"===t||"core::felt252"===t,UT=t=>/\*/.test(t)||t.startsWith("core::array::Array::")||t.startsWith("core::array::Span::"),qT=t=>/^\(.*\)$/i.test(t),VT=t=>/\(.*\)/i.test(t)&&t.includes(":"),HT=(t,e)=>t in e,GT=(t,e)=>t in e,ZT=t=>t.startsWith("core::option::Option::"),KT=t=>t.startsWith("core::result::Result::"),JT=t=>Object.values(SI).includes(t),WT=t=>RT.isAbiType(t),YT=t=>Object.values(NI).includes(t),QT=t=>"core::bool"===t,XT=t=>t===NI.ContractAddress,tC=t=>t===II,eC=t=>"core::bytes_31::bytes31"===t,rC=t=>"core::byte_array::ByteArray"===t,iC=t=>"core::internal::bounded_int::BoundedInt::<0, 79228162514264337593543950335>"===t,nC=t=>t===NI.Secp256k1Point,oC=t=>t.includes("::"),aC=t=>oC(t)?t.substring(t.indexOf("<")+1,t.lastIndexOf(">")):t.replace("*","");function sC(t){const{cairo:e}=uC(t);if(void 0===e)throw Error("Unable to determine Cairo version");return"1"===e}function hC(t){return t.startsWith(TI)}function uC(t){if(t.find((t=>"interface"===t.type)))return{cairo:"1",compiler:"2"};const e=t.find((t=>("function"===t.type||"constructor"===t.type)&&(t.inputs.length||t.outputs.length)));if(!e)return{cairo:void 0,compiler:void 0};const r=e.inputs.length?e.inputs:e.outputs;return oC(r[0].type)?{cairo:"1",compiler:"1"}:{cairo:"0",compiler:"0"}}var lC=t=>new RT(t).toUint256DecimalString(),cC=t=>new $T(t).toUint512DecimalString(),dC=(...t)=>({...t});function fC(t){return xT(t)}var mC=class{variant;constructor(t){const e=Object.values(t);if(0===e.length)throw new Error("This Enum must have at least 1 variant");if(1!==e.filter((t=>!BI(t))).length)throw new Error("This Enum must have exactly one active variant");this.variant=t}unwrap(){return Object.values(this.variant).find((t=>!BI(t)))}activeVariant(){const t=Object.entries(this.variant).find((t=>!BI(t[1])));return BI(t)?"":t[0]}},pC={Some:0,None:1},gC=class{Some;None;constructor(t,e){if(!(t in Object.values(pC)))throw new Error("Wrong variant! It should be CairoOptionVariant.Some or .None.");if(t===pC.Some){if(BI(e))throw new Error('The creation of a Cairo Option with "Some" variant needs a content as input.');this.Some=e,this.None=void 0}else this.Some=void 0,this.None=!0}unwrap(){return this.None?void 0:this.Some}isSome(){return!BI(this.Some)}isNone(){return!0===this.None}},yC={Ok:0,Err:1},wC=class{Ok;Err;constructor(t,e){if(!(t in Object.values(yC)))throw new Error("Wrong variant! It should be CairoResultVariant.Ok or .Err.");t===yC.Ok?(this.Ok=e,this.Err=void 0):(this.Ok=void 0,this.Err=e)}unwrap(){if(!BI(this.Ok))return this.Ok;if(!BI(this.Err))return this.Err;throw new Error("Both Result.Ok and .Err are undefined. Not authorized.")}isOk(){return!BI(this.Ok)}isErr(){return!BI(this.Err)}},vC=(t,e,r)=>{if(!LI(t[r]))throw new Error(`Data and formatter mismatch on ${r}:${e[r]}, expected response data ${r}:${t[r]} to be BN instead it is ${typeof t[r]}`)},bC=(t,e,r)=>{throw new Error(`Unhandled formatter type on ${r}:${e[r]} for data ${r}:${t[r]}`)};function kC(t,e,r){return Object.entries(t).reduce(((i,[n,o])=>{const a=r??e[n];if(!(n in e)&&!r)return i[n]=o,i;if("string"===a){if(Array.isArray(t[n])){const e=kC(t[n],t[n].map((t=>a)));return i[n]=Object.values(e).join(""),i}return vC(t,e,n),i[n]=_T(o),i}if("number"===a)return vC(t,e,n),i[n]=Number(o),i;if("function"==typeof a)return i[n]=a(o),i;if(Array.isArray(a)){const e=kC(t[n],a,a[0]);return i[n]=Object.values(e),i}return UI(a)?(i[n]=kC(t[n],a),i):(bC(t,e,n),i)}),{})}function MC(t){const e=function(t){return t.find((t=>"interface"===t.type))?2:sC(t)?1:0}(t);if(0===e||1===e)return new class{abi;constructor(t){this.abi=t}methodInputsLength(t){return t.inputs.reduce(((t,e)=>LT(e.name)?t:t+1),0)}getMethod(t){return this.abi.find((e=>e.name===t))}getLegacyFormat(){return this.abi}}(t);if(2===e)return new class{abi;constructor(t){this.abi=t}methodInputsLength(t){return t.inputs.length}getMethod(t){return this.abi.find((t=>"interface"===t.type))?.items?.find((e=>e.name===t))}getLegacyFormat(){return this.abi.flatMap((t=>"interface"===t.type?t.items:t))}}(t);throw Error(`Unsupported ABI version ${e}`)}function _C(t,e,r){return"constructor"===t&&!r&&!e.length}function EC(t,e,r){for(let i=0,n=0;i<t.length;i++)if(t[i]===e)n++;else if(t[i]===r&&0==--n)return i;return Number.POSITIVE_INFINITY}function AC(t){return oC(t)?function(t){const e=t.slice(1,-1),r=[];let i,n=0;for(;n<e.length;){switch(!0){case"("===e[n]:i=n+EC(e.slice(n),"(",")")+1;break;case e.startsWith("core::result::Result::<",n)||e.startsWith("core::array::Array::<",n)||e.startsWith("core::option::Option::<",n):i=n+EC(e.slice(n),"<",">")+1;break;default:{const t=e.indexOf(",",n);i=-1!==t?t:Number.POSITIVE_INFINITY}}r.push(e.slice(n,i)),n=i+2}return r}(t):function(t){const e=t.replace(/\s/g,"").slice(1,-1),{subTuple:r,result:i}=function(t){if(!t.includes("("))return{subTuple:[],result:t};const e=[];let r="",i=0;for(;i<t.length;){if("("===t[i]){let n=1;const o=i;for(i++;n;)")"===t[i]&&n--,"("===t[i]&&n++,i++;e.push(t.substring(o,i)),r+=" ",i--}else r+=t[i];i++}return{subTuple:e,result:r}}(e);let n=i.split(",").map((t=>r.length?t.replace(" ",r.shift()):t));return VT(t)&&(n=n.reduce(((t,e)=>t.concat(function(t){const e=t.substring(0,t.indexOf(":"));return{name:e,type:t.substring(e.length+":".length)}}(e))),[])),n}(t)}var jC=class t{content;arrayType;constructor(e,r){PI(t.isTypeFixedArray(r),`The type ${r} is not a Cairo fixed array. Needs [type; length].`);try{t.getFixedArrayType(r)}catch{throw new Error(`The type ${r} do not includes any content type. Needs [type; length].`)}try{t.getFixedArraySize(r)}catch{throw new Error(`The type ${r} type do not includes any length. Needs [type; length].`)}PI(t.getFixedArraySize(r)===e.length,`The ABI type ${r} is expecting ${t.getFixedArraySize(r)} items. ${e.length} items provided.`),this.content=e,this.arrayType=r}static getFixedArraySize(t){const e=t.match(/(?<=; )\d+(?=\])/);if(null===e)throw new Error(`ABI type ${t} do not includes a valid number after ';' character.`);return Number(e[0])}getFixedArraySize(){return t.getFixedArraySize(this.arrayType)}static getFixedArrayType=t=>{const e=t.match(/(?<=\[).+(?=;)/);if(null===e)throw new Error(`ABI type ${t} do not includes a valid type of data.`);return e[0]};getFixedArrayType(){return t.getFixedArrayType(this.arrayType)}static compile(t){return t.reduce(((t,e,r)=>(t[r]=e,t)),{})}compile(){return t.compile(this.content)}static isTypeFixedArray(t){return/^\[.*;\s.*\]$/.test(t)&&/(?<=\[).+(?=;)/.test(t)&&/(?<=; )\d+(?=\])/.test(t)}};function xC(t,e,r,i){const n=(t,e)=>{if(jC.isTypeFixedArray(e))return function(t,e){const r=jC.getFixedArrayType(e),i=jC.getFixedArraySize(e);if(Array.isArray(t)){if(i!==t.length)throw new Error(`ABI type ${e}: array provided do not includes ${i} items. ${t.length} items provided.`);return t.map((t=>n(t,r)))}if(i!==Object.keys(t).length)throw new Error(`ABI type ${e}: object provided do not includes ${i} properties. ${Object.keys(t).length} items provided.`);return n(t,r)}(t,e);if(UT(e))return function(t,e){const r=aC(e);if(FI(t))return t;return t.map((t=>n(t,r)))}(t,e);if(GT(e,i)){const r=i[e];return a(t,r)}if(qT(e))return function(t,e){const r=AC(e).reduce(((e,r,i)=>{const o=Object.keys(t),a=r=>Object.defineProperty(e,i.toString(),{enumerable:!0,value:r??t[o[i]]}),s=r?.type?r.type:r;return a(n(t[o[i]],s)),e}),{});return r}(t,e);if(tC(e))return t;if(hC(e))return t;if(rC(e))return t;if(iC(e))return t;if(nC(e))return t;if(RT.isAbiType(e)){const r=t;if("object"!=typeof r)return r;if(!("low"in r)||!("high"in r))throw function(t){return Error(`Your object includes the property : ${t}, containing an Uint256 object without the 'low' and 'high' keys.`)}(e);return{low:r.low,high:r.high}}if($T.isAbiType(e)){const r=t;if("object"!=typeof r)return r;if(!["limb0","limb1","limb2","limb3"].every((t=>t in r)))throw function(t){return Error(`Your object includes the property : ${t}, containing an Uint512 object without the 'limb0' to 'limb3' keys.`)}(e);return{limb0:r.limb0,limb1:r.limb1,limb2:r.limb2,limb3:r.limb3}}if(HT(e,r)){const i=r[e].members;return o(t,i)}return t},o=(t,e)=>e.reduce(((e,r)=>{if("undefined"===t[r.name]&&(oC(r.type)||!LT(r.name)))throw Error(`Your object needs a property with key : ${r.name} .`);var i;return i=n(t[r.name],r.type),Object.defineProperty(e,r.name,{enumerable:!0,value:i??t[r.name]}),e}),{});const a=(t,e)=>{if(KT(e.name)){const r=t,i=e.name.substring(e.name.indexOf("<")+1,e.name.lastIndexOf(",")),o=e.name.substring(e.name.indexOf(",")+1,e.name.lastIndexOf(">"));return r.isOk()?new wC(yC.Ok,n(t.unwrap(),i)):new wC(yC.Err,n(t.unwrap(),o))}if(ZT(e.name)){const r=t,i=e.name.substring(e.name.indexOf("<")+1,e.name.lastIndexOf(">"));return r.isSome()?new gC(pC.Some,n(r.unwrap(),i)):new gC(pC.None,{})}const r=t,i=Object.entries(r.variant).map((t=>{if(BI(t[1]))return t;const i=e.type.substring(e.type.lastIndexOf("<")+1,e.type.lastIndexOf(">"));return"()"===i?t:[t[0],n(r.unwrap(),i)]}));return new mC(Object.fromEntries(i))};return e.reduce(((e,r)=>{return LT(r.name)&&!oC(r.type)||(i=n(t[r.name],r.type),Object.defineProperty(e,r.name,{enumerable:!0,value:i})),e;var i}),{})}function SC(t,e){switch(!0){case RT.isAbiType(t):return new RT(e).toApiRequest();case $T.isAbiType(t):return new $T(e).toApiRequest();case eC(t):return MT(e.toString());case nC(t):{const t=NN(HI(e)).padStart(128,"0"),r=lC(IN(t.slice(-64))),i=lC(IN(t.slice(0,-64)));return[fC(i.low),fC(i.high),fC(r.low),fC(r.high)]}default:return fC(e)}}function NC(t,e,r,i){if(void 0===t)throw Error(`Missing parameter for type ${e}`);if(jC.isTypeFixedArray(e)){const n=jC.getFixedArrayType(e);let o=[];if(Array.isArray(t)){o=new jC(t,e).content}else{if("object"!=typeof t)throw new Error(`ABI type ${e}: not an Array representing a cairo.fixedArray() provided.`);o=Object.values(t),PI(o.length===jC.getFixedArraySize(e),`ABI type ${e}: object provided do not includes ${jC.getFixedArraySize(e)} items. ${o.length} items provided.`)}return o.reduce(((t,e)=>t.concat(NC(e,n,r,i))),[])}if(Array.isArray(t)){const n=[];n.push(fC(t.length));const o=aC(e);return t.reduce(((t,e)=>t.concat(NC(e,o,r,i))),n)}if(r[e]&&r[e].members.length){if(RT.isAbiType(e))return new RT(t).toApiRequest();if($T.isAbiType(e))return new $T(t).toApiRequest();if(tC(e))return SC(e,t);if(rC(e))return function(t){const e=AT(t);return[e.data.length.toString(),...e.data.map((t=>t.toString())),e.pending_word.toString(),e.pending_word_len.toString()]}(t);const{members:n}=r[e],o=t;return n.reduce(((t,e)=>t.concat(NC(o[e.name],e.type,r,i))),[])}if(qT(e)){const n=function(t,e){const r=AC(e),i=Object.values(t);if(i.length!==r.length)throw Error(`ParseTuple: provided and expected abi tuple size do not match.\n provided: ${i}\n expected: ${r}`);return r.map(((t,e)=>({element:i[e],type:t.type??t})))}(t,e);return n.reduce(((t,e)=>{const n=NC(e.element,e.type,r,i);return t.concat(n)}),[])}if(RT.isAbiType(e))return new RT(t).toApiRequest();if($T.isAbiType(e))return new $T(t).toApiRequest();if(GT(e,i)){const{variants:n}=i[e];if(ZT(e)){const e=t;if(e.isSome()){const t=n.find((t=>"Some"===t.name));if(BI(t))throw Error("Error in abi : Option has no 'Some' variant.");const o=t.type;if("()"===o)return pC.Some.toString();const a=NC(e.unwrap(),o,r,i);return Array.isArray(a)?[pC.Some.toString(),...a]:[pC.Some.toString(),a]}return pC.None.toString()}if(KT(e)){const e=t;if(e.isOk()){const t=n.find((t=>"Ok"===t.name));if(BI(t))throw Error("Error in abi : Result has no 'Ok' variant.");const o=t.type;if("()"===o)return yC.Ok.toString();const a=NC(e.unwrap(),o,r,i);return Array.isArray(a)?[yC.Ok.toString(),...a]:[yC.Ok.toString(),a]}const o=n.find((t=>"Err"===t.name));if(BI(o))throw Error("Error in abi : Result has no 'Err' variant.");const a=o.type;if("()"===a)return yC.Err.toString();const s=NC(e.unwrap(),a,r,i);return Array.isArray(s)?[yC.Err.toString(),...s]:[yC.Err.toString(),s]}const o=t,a=o.activeVariant(),s=n.find((t=>t.name===a));if(BI(s))throw Error(`Not find in abi : Enum has no '${a}' variant.`);const h=s.type,u=n.findIndex((t=>t.name===a));if("()"===h)return u.toString();const l=NC(o.unwrap(),h,r,i);return Array.isArray(l)?[u.toString(),...l]:[u.toString(),l]}if(hC(e))return SC(aC(e),t);if("object"==typeof t)throw Error(`Parameter ${t} do not align with abi parameter ${e}`);return SC(e,t)}function IC(t,e){let r;switch(!0){case QT(t):return r=e.next().value,Boolean(BigInt(r));case RT.isAbiType(t):const i=e.next().value,n=e.next().value;return new RT(i,n).toBigInt();case $T.isAbiType(t):const o=e.next().value,a=e.next().value,s=e.next().value,h=e.next().value;return new $T(o,a,s,h).toBigInt();case tC(t):return r=e.next().value,BigInt(r);case eC(t):return r=e.next().value,_T(r);case nC(t):const u=NN(e.next().value).padStart(32,"0"),l=NN(e.next().value).padStart(32,"0"),c=NN(e.next().value).padStart(32,"0"),d=NN(e.next().value).padStart(32,"0");return BigInt(IN(l+u+d+c));default:return r=e.next().value,BigInt(r)}}function TC(t,e,r,i){if("()"===e.type)return{};if(RT.isAbiType(e.type)){const e=t.next().value,r=t.next().value;return new RT(e,r).toBigInt()}if($T.isAbiType(e.type)){const e=t.next().value,r=t.next().value,i=t.next().value,n=t.next().value;return new $T(e,r,i,n).toBigInt()}if(rC(e.type)){const e=[],r=BigInt(t.next().value);for(;e.length<r;)e.push(HI(t.next().value));return ET({data:e,pending_word:HI(t.next().value),pending_word_len:BigInt(t.next().value)})}if(jC.isTypeFixedArray(e.type)){const n=[],o={name:"",type:jC.getFixedArrayType(e.type)},a=jC.getFixedArraySize(e.type);for(;n.length<a;)n.push(TC(t,o,r,i));return n}if(UT(e.type)){const n=[],o={name:"",type:aC(e.type)},a=BigInt(t.next().value);for(;n.length<a;)n.push(TC(t,o,r,i));return n}if(hC(e.type)){const n={name:"",type:aC(e.type)};return TC(t,n,r,i)}if(r&&e.type in r&&r[e.type])return tC(e.type)?IC(e.type,t):r[e.type].members.reduce(((e,n)=>(e[n.name]=TC(t,n,r,i),e)),{});if(i&&e.type in i&&i[e.type]){const n=Number(t.next().value),o=i[e.type].variants.reduce(((e,o,a)=>a===n?(e[o.name]=TC(t,{name:"",type:o.type},r,i),e):(e[o.name]=void 0,e)),{});if(e.type.startsWith("core::option::Option")){const t=n===pC.Some?o.Some:void 0;return new gC(n,t)}if(e.type.startsWith("core::result::Result")){let t;return t=n===yC.Ok?o.Ok:o.Err,new wC(n,t)}return new mC(o)}if(qT(e.type)){return AC(e.type).reduce(((e,n,o)=>{const a=n?.name?n.name:o,s={name:a,type:n?.type?n.type:n};return e[a]=TC(t,s,r,i),e}),{})}if(UT(e.type)){const n=[],o={name:"",type:aC(e.type)},a=BigInt(t.next().value);for(;n.length<a;)n.push(TC(t,o,r,i));return n}return IC(e.type,t)}function CC(t,e,r,i,n){const{name:o,type:a}=e;let s;switch(!0){case LT(o):return s=t.next().value,BigInt(s);case r&&a in r||qT(a):case i&&GT(a,i):case jC.isTypeFixedArray(a):return TC(t,e,r,i);case UT(a):if(oC(a))return TC(t,e,r,i);const h=[];if(n&&n[`${o}_len`]){const a=n[`${o}_len`];for(;h.length<a;)h.push(TC(t,{name:o,type:e.type.replace("*","")},r,i))}return h;case hC(a):return TC(t,e,r,i);default:return IC(a,t)}}var zC=(t,e)=>{if(PI(FI(t)||DI(t)||LI(t),`Validate: arg ${e.name} should be a felt typed as (String, Number or BigInt)`),FI(t)&&!qI(t))return;const r=BigInt(t.toString(10));PI(r>=0n&&r<=2n**252n-1n,`Validate: arg ${e.name} cairo typed ${e.type} should be in range [0, 2^252-1]`)},OC=(t,e)=>{let r;switch(DI(t)&&PI(t<=Number.MAX_SAFE_INTEGER,"Validation: Parameter is too large to be typed as Number use (BigInt or String)"),PI(FI(t)||DI(t)||LI(t)||UI(t)&&"low"in t&&"high"in t||UI(t)&&["limb0","limb1","limb2","limb3"].every((e=>e in t)),`Validate: arg ${e.name} of cairo type ${e.type} should be type (String, Number or BigInt), but is ${typeof t} ${t}.`),e.type){case SI.u256:r=new RT(t).toBigInt();break;case SI.u512:r=new $T(t).toBigInt();break;default:r=VI(t)}switch(e.type){case SI.u8:PI(r>=0n&&r<=255n,`Validate: arg ${e.name} cairo typed ${e.type} should be in range [0 - 255]`);break;case SI.u16:PI(r>=0n&&r<=65535n,`Validate: arg ${e.name} cairo typed ${e.type} should be in range [0, 65535]`);break;case SI.u32:PI(r>=0n&&r<=4294967295n,`Validate: arg ${e.name} cairo typed ${e.type} should be in range [0, 4294967295]`);break;case SI.u64:PI(r>=0n&&r<=2n**64n-1n,`Validate: arg ${e.name} cairo typed ${e.type} should be in range [0, 2^64-1]`);break;case SI.u128:PI(r>=0n&&r<=2n**128n-1n,`Validate: arg ${e.name} cairo typed ${e.type} should be in range [0, 2^128-1]`);break;case SI.u256:PI(r>=0n&&r<=2n**256n-1n,`Validate: arg ${e.name} is ${e.type} should be in range 0 - 2^256-1`);break;case SI.u512:PI($T.is(r),`Validate: arg ${e.name} is ${e.type} should be in range 0 - 2^512-1`);break;case NI.ClassHash:case NI.ContractAddress:PI(r>=0n&&r<=2n**252n-1n,`Validate: arg ${e.name} cairo typed ${e.type} should be in range [0, 2^252-1]`);break;case NI.Secp256k1Point:PI(r>=0n&&r<=2n**512n-1n,`Validate: arg ${e.name} must be ${e.type} : a 512 bits number.`);break;case NI.U96:PI(r>=0n&&r<=2n**96n-1n,`Validate: arg ${e.name} must be ${e.type} : a 96 bits number.`)}},RC=(t,e)=>{PI($I(t),`Validate: arg ${e.name} of cairo type ${e.type} should be type (Boolean)`)},PC=(t,e,r)=>{if(e.type!==SI.u256&&e.type!==SI.u512)if(tC(e.type)){PI(!UI(t),`EthAddress type is waiting a BigNumberish. Got "${t}"`);const r=BigInt(t.toString(10));PI(r>=0n&&r<=2n**160n-1n,`Validate: arg ${e.name} cairo typed ${e.type} should be in range [0, 2^160-1]`)}else PI(UI(t),`Validate: arg ${e.name} is cairo type struct (${e.type}), and should be defined as a js object (not array)`),r[e.type].members.forEach((({name:r})=>{PI(Object.keys(t).includes(r),`Validate: arg ${e.name} should have a property ${r}`)}));else OC(t,e)},BC=(t,e)=>{PI(UI(t),`Validate: arg ${e.name} is cairo type Enum (${e.type}), and should be defined as a js object (not array)`);const r=Object.getOwnPropertyNames(Object.getPrototypeOf(t)),i=[...Object.getOwnPropertyNames(t),...r];if(!(ZT(e.type)&&i.includes("isSome")&&i.includes("isNone")||KT(e.type)&&i.includes("isOk")&&i.includes("isErr")||i.includes("variant")&&i.includes("activeVariant")))throw new Error(`Validate Enum: argument ${e.name}, type ${e.type}, value received "${t}", is not an Enum.`)},DC=(t,e)=>{PI(UI(t),`Validate: arg ${e.name} should be a tuple (defined as object)`)},$C=(t,e,r,i)=>{const n=UT(e.type),o=n?aC(e.type):jC.getFixedArrayType(e.type);if(n&&FT(o)&&bT(t))return;let a=[];if(n)PI(Array.isArray(t),`Validate: arg ${e.name} should be an Array`),a=t;else switch(!0){case Array.isArray(t):a=t;break;case"object"==typeof t:a=Object.values(t);break;default:throw new Error(`Validate: arg ${e.name} should be an Array or an object.`)}switch(!0){case FT(o):a.forEach((t=>zC(t,e)));break;case qT(o):a.forEach((t=>DC(t,{name:e.name,type:o})));break;case UT(o):a.forEach((t=>$C(t,{name:"",type:o},r,i)));break;case HT(o,r):a.forEach((t=>PC(t,{name:e.name,type:o},r)));break;case GT(o,i):a.forEach((t=>BC(t,{name:e.name,type:o})));break;case JT(o)||YT(o):a.forEach((t=>OC(t,{name:"",type:o})));break;case QT(o):a.forEach((t=>RC(t,e)));break;default:throw new Error(`Validate Unhandled: argument ${e.name}, type ${e.type}, value ${a}`)}};function LC(t,e,r,i){t.inputs.reduce(((t,n)=>{const o=e[t];switch(!0){case LT(n.name):return t;case FT(n.type):zC(o,n);break;case eC(n.type):((t,e)=>{PI(FI(t),`Validate: arg ${e.name} should be a string.`),PI(t.length<32,`Validate: arg ${e.name} cairo typed ${e.type} should be a string of less than 32 characters.`)})(o,n);break;case JT(n.type)||YT(n.type):OC(o,n);break;case QT(n.type):RC(o,n);break;case rC(n.type):((t,e)=>{PI(FI(t),`Validate: arg ${e.name} should be a string.`)})(o,n);break;case UT(n.type)||jC.isTypeFixedArray(n.type):$C(o,n,r,i);break;case HT(n.type,r):PC(o,n,r);break;case GT(n.type,i):BC(o,n);break;case qT(n.type):DC(o,n);break;case hC(n.type):((t,e)=>{const r=aC(e.type);switch(PI(JT(r)&&r!==$T.abiSelector||FT(r),`Validate: ${e.name} type is not authorized for NonZero type.`),!0){case FT(r):zC(t,e),PI(BigInt(t.toString(10))>0,"Validate: value 0 is not authorized in NonZero felt252 type.");break;case JT(r):OC(t,{name:"",type:r}),r===SI.u256?PI(new RT(t).toBigInt()>0,"Validate: value 0 is not authorized in NonZero uint256 type."):PI(VI(t)>0,"Validate: value 0 is not authorized in NonZero uint type.");break;default:throw new Error(`Validate Unhandled: argument ${e.name}, type ${e.type}, value "${t}"`)}})(o,n);break;default:throw new Error(`Validate Unhandled: argument ${n.name}, type ${n.type}, value ${o}`)}return t+1}),0)}var FC=class t{abi;parser;structs;enums;constructor(e){this.structs=t.getAbiStruct(e),this.enums=t.getAbiEnum(e),this.parser=MC(e),this.abi=this.parser.getLegacyFormat()}validate(t,e,r=[]){if(t!==xI.DEPLOY){PI(this.abi.filter((e=>{if("function"!==e.type)return!1;const r="view"===e.stateMutability||"view"===e.state_mutability;return t===xI.INVOKE?!r:r})).map((t=>t.name)).includes(e),(t===xI.INVOKE?"invocable":"viewable")+" method not found in abi")}const i=this.abi.find((r=>t===xI.DEPLOY?r.name===e&&"constructor"===r.type:r.name===e&&"function"===r.type));if(_C(e,r,i))return;const n=this.parser.methodInputsLength(i);if(r.length!==n)throw Error(`Invalid number of arguments, expected ${n} arguments, but got ${r.length}`);LC(i,r,this.structs,this.enums)}compile(t,e){const r=this.abi.find((e=>e.name===t));if(_C(t,e,r))return[];let i;if(Array.isArray(e))i=e;else{const t=xC(e,r.inputs,this.structs,this.enums);i=Object.values(t),LC(r,i,this.structs,this.enums)}const n=i[Symbol.iterator](),o=r.inputs.reduce(((t,e)=>LT(e.name)&&!oC(e.type)?t:t.concat(function(t,e,r,i){const{name:n,type:o}=e;let{value:a}=t.next();switch(!0){case jC.isTypeFixedArray(o):if(!Array.isArray(a)&&"object"!=typeof a)throw Error(`ABI expected parameter ${n} to be an array or an object, got ${a}`);return NC(a,e.type,r,i);case UT(o):if(!Array.isArray(a)&&!wT(a))throw Error(`ABI expected parameter ${n} to be array or long string, got ${a}`);return FI(a)&&(a=kT(a)),NC(a,e.type,r,i);case hC(o):return SC(aC(o),a);case tC(o):return SC(o,a);case HT(o,r)||qT(o)||RT.isAbiType(o):case GT(o,i):return NC(a,o,r,i);default:return SC(o,a)}}(n,e,this.structs,this.enums))),[]);return Object.defineProperty(o,"__compiled__",{enumerable:!1,writable:!1,value:!0}),o}static compile(t){const e=t=>{const e=(t,r=".")=>{const i=Array.isArray(t)?[t.length.toString(),...t]:t;return Object.entries(i).flatMap((([t,n])=>{let o=n;"entrypoint"===t?o=cT(o):bT(o)&&(o=AT(o));const a=Array.isArray(i)&&"0"===t?"$$len":t;if(LI(o))return[[`${r}${a}`,fC(o)]];if(Object(o)===o){const t=Object.getOwnPropertyNames(Object.getPrototypeOf(o)),i=[...Object.getOwnPropertyNames(o),...t];if(i.includes("isSome")&&i.includes("isNone")){const t=o,i=t.isSome()?pC.Some:pC.None;return t.isSome()?e({0:i,1:t.unwrap()},`${r}${a}.`):[[`${r}${a}`,fC(i)]]}if(i.includes("isOk")&&i.includes("isErr")){const t=o,i=t.isOk()?yC.Ok:yC.Err;return e({0:i,1:t.unwrap()},`${r}${a}.`)}if(i.includes("variant")&&i.includes("activeVariant")){const t=o,i=t.activeVariant(),n=Object.keys(t.variant).findIndex((t=>t===i));return"object"==typeof t.unwrap()&&0===Object.keys(t.unwrap()).length?[[`${r}${a}`,fC(n)]]:e({0:n,1:t.unwrap()},`${r}${a}.`)}return e(o,`${r}${a}.`)}return[[`${r}${a}`,fC(o)]]}))};return Object.fromEntries(e(t))};let r;if(Array.isArray(t)){const i=e({...t});r=Object.values(i)}else{const i=e(t);r=Object.values(i)}return Object.defineProperty(r,"__compiled__",{enumerable:!1,writable:!1,value:!0}),r}parse(t,e){const{outputs:r}=this.abi.find((e=>e.name===t)),i=e.flat()[Symbol.iterator](),n=r.flat().reduce(((t,e,r)=>{const n=e.name??r;return t[n]=CC(i,e,this.structs,this.enums,t),t[n]&&t[`${n}_len`]&&delete t[`${n}_len`],t}),{});return 1===Object.keys(n).length&&0 in n?n[0]:n}format(t,e,r){return kC(this.parse(t,e),r)}static getAbiStruct(t){return t.filter((t=>"struct"===t.type)).reduce(((t,e)=>({...t,[e.name]:e})),{})}static getAbiEnum(t){const e=t.filter((t=>"enum"===t.type)).reduce(((t,e)=>({...t,[e.name]:e})),{});return delete e["core::bool"],e}static toCalldata(e=[]){return t.compile(e)}static toHex(e=[]){return t.compile(e).map((t=>HI(t)))}decodeParameters(t,e){const r=Array.isArray(t)?t:[t],i=e.flat()[Symbol.iterator](),n=r.map((t=>CC(i,{name:"",type:t},this.structs,this.enums)));return 1===n.length?n[0]:n}};nN({},{calculateContractAddressFromHash:()=>gz,calculateDeclareTransactionHash:()=>uz,calculateDeployAccountTransactionHash:()=>lz,calculateInvokeTransactionHash:()=>hz,calculateL2MessageTxHash:()=>ZC,computeCompiledClassHash:()=>_z,computeContractClassHash:()=>jz,computeHashOnElements:()=>fz,computeHintedClassHash:()=>vz,computeLegacyContractClassHash:()=>bz,computePedersenHash:()=>cz,computePedersenHashOnElements:()=>mz,computePoseidonHash:()=>dz,computePoseidonHashOnElements:()=>pz,computeSierraContractClassHash:()=>Az,formatSpaces:()=>wz,getL2MessageHash:()=>mT,getSelector:()=>dT,getSelectorFromName:()=>cT,hashByteCodeSegments:()=>Mz,keccakBn:()=>uT,poseidon:()=>Jv,solidityUint256PackedKeccak256:()=>fT,starknetKeccak:()=>lT});nN({},{calculateDeclareTransactionHash:()=>VC,calculateDeployAccountTransactionHash:()=>HC,calculateL2MessageTxHash:()=>ZC,calculateTransactionHash:()=>GC,calculateTransactionHashCommon:()=>qC,computeHashOnElements:()=>UC});function UC(t){return[...t,t.length].reduce(((t,e)=>Jb(VI(t),VI(e))),0).toString()}function qC(t,e,r,i,n,o,a,s=[]){const h=UC(n);return UC([t,e,r,i,h,o,a,...s])}function VC(t,e,r,i,n,o,a){return qC("0x6465636c617265",r,e,0,[t],i,n,[o,...a?[a]:[]])}function HC(t,e,r,i,n,o,a,s){return qC("0x6465706c6f795f6163636f756e74",n,t,0,[e,i,...r],o,a,[s])}function GC(t,e,r,i,n,o){return qC("0x696e766f6b65",e,t,0,r,i,n,[o])}function ZC(t,e,r,i,n,o){const a=[t,...i];return qC("0x6c315f68616e646c6572",0,e,dT(r),a,0,n,[o])}nN({},{starkCurve:()=>ak,weierstrass:()=>wb});nN({},{calculateDeclareTransactionHash:()=>az,calculateDeployAccountTransactionHash:()=>oz,calculateInvokeTransactionHash:()=>sz,calculateTransactionHashCommon:()=>nz,encodeResourceBoundsL1:()=>ez,encodeResourceBoundsL2:()=>rz,hashDAMode:()=>tz,hashFeeField:()=>iz});var KC=t=>t.map((t=>BigInt(t))),JC=32n,WC=128n,YC=64n+WC,QC=BigInt(MT("L1_GAS")),XC=BigInt(MT("L2_GAS"));function tz(t,e){return(BigInt(t)<<JC)+BigInt(e)}function ez(t){return(QC<<YC)+(BigInt(t.l1_gas.max_amount)<<WC)+BigInt(t.l1_gas.max_price_per_unit)}function rz(t){return(XC<<YC)+(BigInt(t.l2_gas.max_amount)<<WC)+BigInt(t.l2_gas.max_price_per_unit)}function iz(t,e){const r=ez(e),i=rz(e);return ok([BigInt(t),r,i])}function nz(t,e,r,i,n,o,a,s,h,u,l=[]){const c=iz(o,u),d=tz(s,h),f=KC([t,e,r,c,ok(KC(a)),i,n,d,...KC(l)]);return HI(ok(f))}function oz(t,e,r,i,n,o,a,s,h,u,l,c){return nz("0x6465706c6f795f6163636f756e74",n,t,o,a,l,c,s,h,u,[ok(KC(r)),e,i])}function az(t,e,r,i,n,o,a,s,h,u,l,c){return nz("0x6465636c617265",i,r,n,o,l,KC(c),s,h,u,[ok(KC(a)),t,e])}function sz(t,e,r,i,n,o,a,s,h,u,l){return nz("0x696e766f6b65",e,t,i,n,u,l,a,s,h,[ok(KC(o)),ok(KC(r))])}function hz(t){return function(t){return[aN.ETransactionVersion.V3,aN.ETransactionVersion.F3].includes(t.version)}(t)?sz(t.senderAddress,t.version,t.compiledCalldata,t.chainId,t.nonce,t.accountDeploymentData,t.nonceDataAvailabilityMode,t.feeDataAvailabilityMode,t.resourceBounds,t.tip,t.paymasterData):GC(t.senderAddress,t.version,t.compiledCalldata,t.maxFee,t.chainId,t.nonce)}function uz(t){return function(t){return[aN.ETransactionVersion.V3,aN.ETransactionVersion.F3].includes(t.version)}(t)?az(t.classHash,t.compiledClassHash,t.senderAddress,t.version,t.chainId,t.nonce,t.accountDeploymentData,t.nonceDataAvailabilityMode,t.feeDataAvailabilityMode,t.resourceBounds,t.tip,t.paymasterData):VC(t.classHash,t.senderAddress,t.version,t.maxFee,t.chainId,t.nonce,t.compiledClassHash)}function lz(t){return function(t){return[aN.ETransactionVersion.V3,aN.ETransactionVersion.F3].includes(t.version)}(t)?oz(t.contractAddress,t.classHash,t.compiledConstructorCalldata,t.salt,t.version,t.chainId,t.nonce,t.nonceDataAvailabilityMode,t.feeDataAvailabilityMode,t.resourceBounds,t.tip,t.paymasterData):HC(t.contractAddress,t.classHash,t.constructorCalldata,t.salt,t.version,t.maxFee,t.chainId,t.nonce)}function cz(t,e){return Jb(BigInt(t),BigInt(e))}function dz(t,e){return HI(nk(BigInt(t),BigInt(e)))}function fz(t){return[...t,t.length].reduce(((t,e)=>Jb(BigInt(t),BigInt(e))),0).toString()}var mz=fz;function pz(t){return HI(ok(t.map((t=>BigInt(t)))))}function gz(t,e,r,i){const n=fz(FC.compile(r)),o=fz([fC("0x535441524b4e45545f434f4e54524143545f41444452455353"),i,t,e,n]);return HI(BigInt(o)%VN)}function yz(t,e){return"attributes"===t||"accessible_scopes"===t?Array.isArray(e)&&0===e.length?void 0:e:"debug_info"===t?null:null===e?void 0:e}function wz(t){let e=!1;const r=[];for(const i of t)'"'===i&&!1==(r.length>0&&"\\"===r.slice(-1)[0])&&(e=!e),e?r.push(i):r.push(":"===i?": ":","===i?", ":i);return r.join("")}function vz(t){const{abi:e,program:r}=t,i=wz(mI({abi:e,program:r},yz));return IN(Yb(EN(i)).toString(16))}function bz(t){const e=FI(t)?dI(t):t,r=HI(FN),i=fz(e.entry_points_by_type.EXTERNAL.flatMap((t=>[t.selector,t.offset]))),n=fz(e.entry_points_by_type.L1_HANDLER.flatMap((t=>[t.selector,t.offset]))),o=fz(e.entry_points_by_type.CONSTRUCTOR.flatMap((t=>[t.selector,t.offset]))),a=fz(e.program.builtins.map((t=>MT(t)))),s=vz(e),h=fz(e.program.data);return fz([r,i,n,o,a,s,h])}function kz(t){const e=t.flatMap((t=>{return[BigInt(t.selector),BigInt(t.offset),(e=t.builtins,ok(e.flatMap((t=>BigInt(MT(t))))))];var e}));return ok(e)}function Mz(t){const e=t.bytecode.map((t=>BigInt(t))),r=t.bytecode_segment_lengths??[];let i=0;const n=r.flatMap((t=>{const r=e.slice(i,i+=t);return[BigInt(t),ok(r)]}));return 1n+ok(n)}function _z(t){const e=BigInt(MT("COMPILED_CLASS_V1")),r=kz(t.entry_points_by_type.EXTERNAL),i=kz(t.entry_points_by_type.L1_HANDLER),n=kz(t.entry_points_by_type.CONSTRUCTOR),o=t.bytecode_segment_lengths?Mz(t):ok(t.bytecode.map((t=>BigInt(t))));return HI(ok([e,r,i,n,o]))}function Ez(t){return ok(t.flatMap((t=>[BigInt(t.selector),BigInt(t.function_idx)])))}function Az(t){const e=BigInt(MT("CONTRACT_CLASS_V0.1.0")),r=Ez(t.entry_points_by_type.EXTERNAL),i=Ez(t.entry_points_by_type.L1_HANDLER),n=Ez(t.entry_points_by_type.CONSTRUCTOR),o=function(t){const e=wz(mI(t.abi,null));return BigInt(IN(Yb(EN(e)).toString(16)))}(t),a=ok(t.sierra_program.map((t=>BigInt(t))));return HI(ok([e,r,i,n,o,a]))}function jz(t){const e=FI(t)?dI(t):t;return"sierra_program"in e?Az(e):bz(e)}function xz(t){const e=FI(t)?t:mI(t);return xN(KE(e))}function Sz(t){if(Array.isArray(t))return t;const e=_N(JE(jN(t)));return dI(e)}function Nz(){return Fb(Bb.randomPrivateKey())}function Iz(t){return IN(t).toLowerCase()}function Tz(t){if(!t)throw Error("formatSignature: provided signature is undefined");if(Array.isArray(t))return t.map((t=>HI(t)));try{const{r:e,s:r}=t;return[HI(e),HI(r)]}catch(t){throw new Error("Signature need to be weierstrass.SignatureType or an array for custom")}}function Cz(t){return QI(Tz(t))}function zz(t){return XI(Tz(t))}function Oz(t,e=50){return aT(t,e)}function Rz(t,e=50,r=50){if(LI(t))return{l2_gas:{max_amount:"0x0",max_price_per_unit:"0x0"},l1_gas:{max_amount:"0x0",max_price_per_unit:"0x0"}};if(BI(t.gas_consumed)||BI(t.gas_price))throw Error("estimateFeeToBounds: estimate is undefined");return{l2_gas:{max_amount:"0x0",max_price_per_unit:"0x0"},l1_gas:{max_amount:void 0!==t.data_gas_consumed&&void 0!==t.data_gas_price?HI(aT(BigInt(t.overall_fee)/BigInt(t.gas_price),e)):HI(aT(t.gas_consumed,e)),max_price_per_unit:HI(aT(t.gas_price,r))}}}function Pz(t){if(t===aN.EDataAvailabilityMode.L1)return aN.EDAMode.L1;if(t===aN.EDataAvailabilityMode.L2)return aN.EDAMode.L2;throw Error("EDAM conversion")}function Bz(t,e){const r=e?HI(e):void 0,i=HI(t);if(e&&!Object.values(aN.ETransactionVersion).includes(r))throw Error(`providedVersion ${e} is not ETransactionVersion`);if(!Object.values(aN.ETransactionVersion).includes(i))throw Error(`defaultVersion ${t} is not ETransactionVersion`);return e?r:i}function Dz(t){if(!t)return;const e=HI(t);if(e===aN.ETransactionVersion.V0)return aN.ETransactionVersion.F0;if(e===aN.ETransactionVersion.V1)return aN.ETransactionVersion.F1;if(e===aN.ETransactionVersion.V2)return aN.ETransactionVersion.F2;if(e===aN.ETransactionVersion.V3)return aN.ETransactionVersion.F3;throw Error(`toFeeVersion: ${e} is not supported`)}function $z(t){return{tip:t.tip||0,paymasterData:t.paymasterData||[],accountDeploymentData:t.accountDeploymentData||[],nonceDataAvailabilityMode:t.nonceDataAvailabilityMode||aN.EDataAvailabilityMode.L1,feeDataAvailabilityMode:t.feeDataAvailabilityMode||aN.EDataAvailabilityMode.L1,resourceBounds:t.resourceBounds??Rz(DN)}}function Lz(t){return t===aN.ETransactionVersion.F2?aN.ETransactionVersion.F1:t===aN.ETransactionVersion.V2?aN.ETransactionVersion.V1:t}function Fz(t){return IN(SN(Ib(HI(t),!1)))}function Uz(t){return"sierra_program"in(FI(t)?dI(t):t)}nN({},{compressProgram:()=>xz,decompressProgram:()=>Sz,estimateFeeToBounds:()=>Rz,estimatedFeeToMaxFee:()=>Oz,formatSignature:()=>Tz,getFullPublicKey:()=>Fz,intDAM:()=>Pz,makeAddress:()=>Iz,randomAddress:()=>Nz,reduceV2:()=>Lz,signatureToDecimalArray:()=>Cz,signatureToHexArray:()=>zz,toFeeVersion:()=>Dz,toTransactionVersion:()=>Bz,v3Details:()=>$z});function qz(){return ON(SN(rA.utils.randomPrivateKey()))}function Vz(t){YI(t,DN,2n**160n-1n,"Ethereum Address ");const e=IN(NN(HI(t)).padStart(40,"0"));return PI(Boolean(e.match(/^(0x)?[0-9a-f]{40}$/)),"Invalid Ethereum Address Format"),e}nN({},{ethRandomPrivateKey:()=>qz,validateAndParseEthAddress:()=>Vz});var Hz=MN&&window.fetch.bind(window)||!BI(t)&&gS(t.fetch)||FS;nN({},{Block:()=>tO,createSierraContractClass:()=>Wz,getDefaultNodeUrl:()=>Qz,isPendingBlock:()=>iO,isPendingStateUpdate:()=>oO,isPendingTransaction:()=>nO,isV3Tx:()=>eO,isVersion:()=>rO,parseContract:()=>Yz,validBlockTags:()=>Xz,wait:()=>Jz});var Gz=class t{static instance;config;constructor(){this.initialize()}initialize(){this.config={...hI}}static getInstance(){return t.instance||(t.instance=new t),t.instance}get(t,e){return this.config[t]??e}set(t,e){this.config[t]=e}update(t){this.config={...this.config,...t}}getAll(){return{...this.config}}reset(){this.initialize()}delete(t){delete this.config[t]}hasKey(t){return t in this.config}}.getInstance(),Zz={DEBUG:5,INFO:4,WARN:3,ERROR:2,FATAL:1,OFF:0},Kz=class t{static instance;config;constructor(){this.config=Gz}static getInstance(){return t.instance||(t.instance=new t),t.instance}getTimestamp(){return(new Date).toISOString()}shouldLog(t){const e=this.config.get("logLevel","INFO");return t<=Zz[e]}formatMessage(t){const{level:e,message:r,timestamp:i,data:n}=t;let o=`[${i}] ${e}: ${r}`;if(n)try{o+=`\n${JSON.stringify(n,null,2)}`}catch(t){o+=`\n[JSON.stringify Error/Circular]: ${t}`}return o}log(t,e,r){if(!this.shouldLog(Zz[t]))return;const i={level:t,message:e,timestamp:this.getTimestamp(),data:r},n=this.formatMessage(i);switch(t){case"DEBUG":console.debug(n);break;case"INFO":console.info(n);break;case"WARN":console.warn(n);break;case"ERROR":case"FATAL":console.error(n);break;case"OFF":break;default:console.log(n)}}debug(t,e){this.log("DEBUG",t,e)}info(t,e){this.log("INFO",t,e)}warn(t,e){this.log("WARN",t,e)}error(t,e){this.log("ERROR",t,e)}fatal(t,e){this.log("FATAL",t,e)}setLogLevel(t){this.config.set("logLevel",t)}getLogLevel(){return this.config.get("logLevel","INFO")}getEnabledLogLevels(){return Object.keys(Zz).filter((t=>this.shouldLog(Zz[t])&&"OFF"!==t))}}.getInstance();function Jz(t){return new Promise((e=>{setTimeout(e,t)}))}function Wz(t){const e={...t};return delete e.sierra_program_debug_info,e.abi=wz(mI(t.abi)),e.sierra_program=wz(mI(t.sierra_program)),e.sierra_program=xz(e.sierra_program),e}function Yz(t){const e=FI(t)?dI(t):t;return Uz(t)?Wz(e):{...e,..."program"in e&&{program:xz(e.program)}}}var Qz=(t,e=!1)=>{e||Kz.info("Using default public node url, please provide nodeUrl in provider options!");const r=rI[t??"SN_SEPOLIA"];return r[Math.floor(Math.random()*r.length)]},Xz=Object.values(jI),tO=class{hash=null;number=null;tag=null;setIdentifier(t){if(FI(t))if(yT(t))this.number=parseInt(t,10);else if(qI(t))this.hash=t;else{if(!Xz.includes(t))throw TypeError(`Block identifier unmanaged: ${t}`);this.tag=t}else LI(t)?this.hash=HI(t):DI(t)?this.number=t:this.tag=jI.PENDING;if(DI(this.number)&&this.number<0)throw TypeError(`Block number (${this.number}) can't be negative`)}constructor(t){this.setIdentifier(t)}get queryIdentifier(){return null!==this.number?`blockNumber=${this.number}`:null!==this.hash?`blockHash=${this.hash}`:`blockNumber=${this.tag}`}get identifier(){return null!==this.number?{block_number:this.number}:null!==this.hash?{block_hash:this.hash}:this.tag}set identifier(t){this.setIdentifier(t)}valueOf=()=>this.number;toString=()=>this.hash};function eO(t){const e=t.version?HI(t.version):aN.ETransactionVersion.V3;return e===aN.ETransactionVersion.V3||e===aN.ETransactionVersion.F3}function rO(t,e){const[r,i]=t.split("."),[n,o]=e.split(".");return r===n&&i===o}function iO(t){return"PENDING"===t.status}function nO(t){return!("block_hash"in t)}function oO(t){return!("block_hash"in t)}nN({},{buildUDCCall:()=>dO,fromCallsToExecuteCalldata:()=>sO,fromCallsToExecuteCalldataWithNonce:()=>hO,fromCallsToExecuteCalldata_cairo1:()=>lO,getExecuteCalldata:()=>cO,getVersionsByType:()=>fO,transformCallsToMulticallArrays:()=>aO,transformCallsToMulticallArrays_cairo1:()=>uO});var aO=t=>{const e=[],r=[];return t.forEach((t=>{const i=FC.compile(t.calldata||[]);e.push({to:VI(t.contractAddress).toString(10),selector:VI(cT(t.entrypoint)).toString(10),data_offset:r.length.toString(),data_len:i.length.toString()}),r.push(...i)})),{callArray:e,calldata:FC.compile({calldata:r})}},sO=t=>{const{callArray:e,calldata:r}=aO(t);return[...FC.compile({callArray:e}),...r]},hO=(t,e)=>[...sO(t),VI(e).toString()],uO=t=>{const e=t.map((t=>({to:VI(t.contractAddress).toString(10),selector:VI(cT(t.entrypoint)).toString(10),calldata:FC.compile(t.calldata||[])})));return e},lO=t=>{const e=t.map((t=>({contractAddress:t.contractAddress,entrypoint:t.entrypoint,calldata:Array.isArray(t.calldata)&&"__compiled__"in t.calldata?t.calldata:FC.compile(t.calldata)})));return FC.compile({orderCalls:e})},cO=(t,e="0")=>"1"===e?lO(t):sO(t);function dO(t,e){const r=[].concat(t).map((t=>{const{classHash:r,salt:i,unique:n=!0,constructorCalldata:o=[]}=t,a=FC.compile(o),s=i??Nz();return{call:{contractAddress:tI.ADDRESS,entrypoint:tI.ENTRYPOINT,calldata:[r,s,nT(n),a.length,...a]},address:gz(n?Jb(e,s):s,r,a,n?tI.ADDRESS:0)}}));return{calls:r.map((t=>t.call)),addresses:r.map((t=>t.address))}}function fO(t){return"fee"===t?{v1:aN.ETransactionVersion.F1,v2:aN.ETransactionVersion.F2,v3:aN.ETransactionVersion.F3}:{v1:aN.ETransactionVersion.V1,v2:aN.ETransactionVersion.V2,v3:aN.ETransactionVersion.V3}}var mO={headers:{"Content-Type":"application/json"},blockIdentifier:jI.PENDING,retries:200},pO=class{nodeUrl;headers;requestId;blockIdentifier;retries;waitMode;chainId;specVersion;transactionRetryIntervalFallback;batchClient;baseFetch;constructor(t){const{baseFetch:e,batch:r,blockIdentifier:i,chainId:n,headers:o,nodeUrl:a,retries:s,specVersion:h,transactionRetryIntervalFallback:u,waitMode:l}=t||{};Object.values(WN).includes(a)?this.nodeUrl=Qz(a,t?.default):this.nodeUrl=a||Qz(void 0,t?.default),this.baseFetch=e??Hz,this.blockIdentifier=i??mO.blockIdentifier,this.chainId=n,this.headers={...mO.headers,...o},this.retries=s??mO.retries,this.specVersion=h,this.transactionRetryIntervalFallback=u,this.waitMode=l??!1,this.requestId=0,"number"==typeof r&&(this.batchClient=new RI({nodeUrl:this.nodeUrl,headers:this.headers,interval:r,baseFetch:this.baseFetch}))}get transactionRetryIntervalDefault(){return this.transactionRetryIntervalFallback??5e3}setChainId(t){this.chainId=t}fetch(t,e,r=0){const i={id:r,jsonrpc:"2.0",method:t,...e&&{params:e}};return this.baseFetch(this.nodeUrl,{method:"POST",body:mI(i),headers:this.headers})}errorHandler(t,e,r,i){if(r)throw new vI(r,t,e);if(i instanceof wI)throw i;if(i)throw Error(i.message)}async fetchEndpoint(t,e){try{if(this.batchClient){const{error:r,result:i}=await this.batchClient.fetch(t,e,this.requestId+=1);return this.errorHandler(t,e,r),i}const r=await this.fetch(t,e,this.requestId+=1),{error:i,result:n}=await r.json();return this.errorHandler(t,e,i),n}catch(r){throw this.errorHandler(t,e,r?.response?.data,r),r}}async getChainId(){return this.chainId??=await this.fetchEndpoint("starknet_chainId"),this.chainId}async getSpecVersion(){return this.specVersion??=await this.fetchEndpoint("starknet_specVersion"),this.specVersion}getNonceForAddress(t,e=this.blockIdentifier){const r=HI(t),i=new tO(e).identifier;return this.fetchEndpoint("starknet_getNonce",{contract_address:r,block_id:i})}getBlockLatestAccepted(){return this.fetchEndpoint("starknet_blockHashAndNumber")}getBlockNumber(){return this.fetchEndpoint("starknet_blockNumber")}getBlockWithTxHashes(t=this.blockIdentifier){const e=new tO(t).identifier;return this.fetchEndpoint("starknet_getBlockWithTxHashes",{block_id:e})}getBlockWithTxs(t=this.blockIdentifier){const e=new tO(t).identifier;return this.fetchEndpoint("starknet_getBlockWithTxs",{block_id:e})}getBlockStateUpdate(t=this.blockIdentifier){const e=new tO(t).identifier;return this.fetchEndpoint("starknet_getStateUpdate",{block_id:e})}getBlockTransactionsTraces(t=this.blockIdentifier){const e=new tO(t).identifier;return this.fetchEndpoint("starknet_traceBlockTransactions",{block_id:e})}getBlockTransactionCount(t=this.blockIdentifier){const e=new tO(t).identifier;return this.fetchEndpoint("starknet_getBlockTransactionCount",{block_id:e})}getTransactionByHash(t){const e=HI(t);return this.fetchEndpoint("starknet_getTransactionByHash",{transaction_hash:e})}getTransactionByBlockIdAndIndex(t,e){const r=new tO(t).identifier;return this.fetchEndpoint("starknet_getTransactionByBlockIdAndIndex",{block_id:r,index:e})}getTransactionReceipt(t){const e=HI(t);return this.fetchEndpoint("starknet_getTransactionReceipt",{transaction_hash:e})}getTransactionTrace(t){const e=HI(t);return this.fetchEndpoint("starknet_traceTransaction",{transaction_hash:e})}getTransactionStatus(t){const e=HI(t);return this.fetchEndpoint("starknet_getTransactionStatus",{transaction_hash:e})}simulateTransaction(t,e={}){const{blockIdentifier:r=this.blockIdentifier,skipValidate:i=!0,skipFeeCharge:n=!0}=e,o=new tO(r).identifier,a=[];return i&&a.push(hN.ESimulationFlag.SKIP_VALIDATE),n&&a.push(hN.ESimulationFlag.SKIP_FEE_CHARGE),this.fetchEndpoint("starknet_simulateTransactions",{block_id:o,transactions:t.map((t=>this.buildTransaction(t))),simulation_flags:a})}async waitForTransaction(t,e){const r=HI(t);let{retries:i}=this,n=!1,o=!1;const a=e?.retryInterval??this.transactionRetryIntervalDefault,s=e?.errorStates??[hN.ETransactionStatus.REJECTED],h=e?.successStates??[hN.ETransactionExecutionStatus.SUCCEEDED,hN.ETransactionStatus.ACCEPTED_ON_L2,hN.ETransactionStatus.ACCEPTED_ON_L1];let u;for(;!n;){await Jz(a);try{u=await this.getTransactionStatus(r);const t=u.execution_status,e=u.finality_status;if(!e){throw new Error("waiting for transaction status")}if(s.includes(t)||s.includes(e)){const r=`${t}: ${e}`,i=new Error(r);throw i.response=u,o=!0,i}(h.includes(t)||h.includes(e))&&(n=!0)}catch(t){if(t instanceof Error&&o)throw t;if(i<=0)throw new Error(`waitForTransaction timed-out with retries ${this.retries}`)}i-=1}let l=null;for(;null===l;){try{l=await this.getTransactionReceipt(r)}catch(t){if(i<=0)throw new Error(`waitForTransaction timed-out with retries ${this.retries}`)}i-=1,await Jz(a)}return l}getStorageAt(t,e,r=this.blockIdentifier){const i=HI(t),n=ZI(e),o=new tO(r).identifier;return this.fetchEndpoint("starknet_getStorageAt",{contract_address:i,key:n,block_id:o})}getClassHashAt(t,e=this.blockIdentifier){const r=HI(t),i=new tO(e).identifier;return this.fetchEndpoint("starknet_getClassHashAt",{block_id:i,contract_address:r})}getClass(t,e=this.blockIdentifier){const r=HI(t),i=new tO(e).identifier;return this.fetchEndpoint("starknet_getClass",{class_hash:r,block_id:i})}getClassAt(t,e=this.blockIdentifier){const r=HI(t),i=new tO(e).identifier;return this.fetchEndpoint("starknet_getClassAt",{block_id:i,contract_address:r})}async getEstimateFee(t,{blockIdentifier:e=this.blockIdentifier,skipValidate:r=!0}){const i=new tO(e).identifier;let n={};return rO("0.5",await this.getSpecVersion())||(n={simulation_flags:r?[hN.ESimulationFlag.SKIP_VALIDATE]:[]}),this.fetchEndpoint("starknet_estimateFee",{request:t.map((t=>this.buildTransaction(t,"fee"))),block_id:i,...n})}async invoke(t,e){let r;return eO(e)?r=this.fetchEndpoint("starknet_addInvokeTransaction",{invoke_transaction:{type:hN.ETransactionType.INVOKE,sender_address:t.contractAddress,calldata:FC.toHex(t.calldata),version:hN.ETransactionVersion.V3,signature:zz(t.signature),nonce:HI(e.nonce),resource_bounds:e.resourceBounds,tip:HI(e.tip),paymaster_data:e.paymasterData.map((t=>HI(t))),account_deployment_data:e.accountDeploymentData.map((t=>HI(t))),nonce_data_availability_mode:e.nonceDataAvailabilityMode,fee_data_availability_mode:e.feeDataAvailabilityMode}}):(r=this.fetchEndpoint("starknet_addInvokeTransaction",{invoke_transaction:{sender_address:t.contractAddress,calldata:FC.toHex(t.calldata),type:hN.ETransactionType.INVOKE,max_fee:HI(e.maxFee||0),version:hN.ETransactionVersion.V1,signature:zz(t.signature),nonce:HI(e.nonce)}}),Kz.warn(uI.legacyTxWarningMessage,{version:hN.ETransactionVersion.V1,type:hN.ETransactionType.INVOKE})),this.waitMode?this.waitForTransaction((await r).transaction_hash):r}async declare({contract:t,signature:e,senderAddress:r,compiledClassHash:i},n){let o;if(Uz(t)||eO(n))if(Uz(t)&&!eO(n))o=this.fetchEndpoint("starknet_addDeclareTransaction",{declare_transaction:{type:hN.ETransactionType.DECLARE,contract_class:{sierra_program:Sz(t.sierra_program),contract_class_version:t.contract_class_version,entry_points_by_type:t.entry_points_by_type,abi:t.abi},compiled_class_hash:i||"",version:hN.ETransactionVersion.V2,max_fee:HI(n.maxFee||0),signature:zz(e),sender_address:r,nonce:HI(n.nonce)}}),Kz.warn(uI.legacyTxWarningMessage,{version:hN.ETransactionVersion.V2,type:hN.ETransactionType.DECLARE});else{if(!Uz(t)||!eO(n))throw Error("declare unspotted parameters");o=this.fetchEndpoint("starknet_addDeclareTransaction",{declare_transaction:{type:hN.ETransactionType.DECLARE,sender_address:r,compiled_class_hash:i||"",version:hN.ETransactionVersion.V3,signature:zz(e),nonce:HI(n.nonce),contract_class:{sierra_program:Sz(t.sierra_program),contract_class_version:t.contract_class_version,entry_points_by_type:t.entry_points_by_type,abi:t.abi},resource_bounds:n.resourceBounds,tip:HI(n.tip),paymaster_data:n.paymasterData.map((t=>HI(t))),account_deployment_data:n.accountDeploymentData.map((t=>HI(t))),nonce_data_availability_mode:n.nonceDataAvailabilityMode,fee_data_availability_mode:n.feeDataAvailabilityMode}})}else o=this.fetchEndpoint("starknet_addDeclareTransaction",{declare_transaction:{type:hN.ETransactionType.DECLARE,contract_class:{program:t.program,entry_points_by_type:t.entry_points_by_type,abi:t.abi},version:hN.ETransactionVersion.V1,max_fee:HI(n.maxFee||0),signature:zz(e),sender_address:r,nonce:HI(n.nonce)}}),Kz.warn(uI.legacyTxWarningMessage,{version:hN.ETransactionVersion.V1,type:hN.ETransactionType.DECLARE});return this.waitMode?this.waitForTransaction((await o).transaction_hash):o}async deployAccount({classHash:t,constructorCalldata:e,addressSalt:r,signature:i},n){let o;return eO(n)?o=this.fetchEndpoint("starknet_addDeployAccountTransaction",{deploy_account_transaction:{type:hN.ETransactionType.DEPLOY_ACCOUNT,version:hN.ETransactionVersion.V3,signature:zz(i),nonce:HI(n.nonce),contract_address_salt:HI(r||0),constructor_calldata:FC.toHex(e||[]),class_hash:HI(t),resource_bounds:n.resourceBounds,tip:HI(n.tip),paymaster_data:n.paymasterData.map((t=>HI(t))),nonce_data_availability_mode:n.nonceDataAvailabilityMode,fee_data_availability_mode:n.feeDataAvailabilityMode}}):(o=this.fetchEndpoint("starknet_addDeployAccountTransaction",{deploy_account_transaction:{constructor_calldata:FC.toHex(e||[]),class_hash:HI(t),contract_address_salt:HI(r||0),type:hN.ETransactionType.DEPLOY_ACCOUNT,max_fee:HI(n.maxFee||0),version:hN.ETransactionVersion.V1,signature:zz(i),nonce:HI(n.nonce)}}),Kz.warn(uI.legacyTxWarningMessage,{version:hN.ETransactionVersion.V1,type:hN.ETransactionType.DEPLOY_ACCOUNT})),this.waitMode?this.waitForTransaction((await o).transaction_hash):o}callContract(t,e=this.blockIdentifier){const r=new tO(e).identifier;return this.fetchEndpoint("starknet_call",{request:{contract_address:t.contractAddress,entry_point_selector:cT(t.entrypoint),calldata:FC.toHex(t.calldata)},block_id:r})}estimateMessageFee(t,e=this.blockIdentifier){const{from_address:r,to_address:i,entry_point_selector:n,payload:o}=t,a={from_address:Vz(r),to_address:HI(i),entry_point_selector:dT(n),payload:iT(o)},s=new tO(e).identifier;return this.fetchEndpoint("starknet_estimateMessageFee",{message:a,block_id:s})}getSyncingStats(){return this.fetchEndpoint("starknet_syncing")}getEvents(t){return this.fetchEndpoint("starknet_getEvents",{filter:t})}buildTransaction(t,e){const r=fO(e);let i;if(eO(t)?i={signature:zz(t.signature),nonce:HI(t.nonce),resource_bounds:t.resourceBounds,tip:HI(t.tip),paymaster_data:t.paymasterData.map((t=>HI(t))),nonce_data_availability_mode:t.nonceDataAvailabilityMode,fee_data_availability_mode:t.feeDataAvailabilityMode,account_deployment_data:t.accountDeploymentData.map((t=>HI(t)))}:(i={signature:zz(t.signature),nonce:HI(t.nonce),max_fee:HI(t.maxFee||0)},Kz.warn(uI.legacyTxWarningMessage,{version:t.version,type:t.type})),t.type===kI.INVOKE)return{type:hN.ETransactionType.INVOKE,sender_address:t.contractAddress,calldata:FC.toHex(t.calldata),version:HI(t.version||r.v3),...i};if(t.type===kI.DECLARE)return Uz(t.contract)?{type:t.type,contract_class:{...t.contract,sierra_program:Sz(t.contract.sierra_program)},compiled_class_hash:t.compiledClassHash||"",sender_address:t.senderAddress,version:HI(t.version||r.v3),...i}:{type:t.type,contract_class:t.contract,sender_address:t.senderAddress,version:HI(t.version||r.v1),...i};if(t.type===kI.DEPLOY_ACCOUNT){const{account_deployment_data:e,...n}=i;return{type:t.type,constructor_calldata:FC.toHex(t.constructorCalldata||[]),class_hash:HI(t.classHash),contract_address_salt:HI(t.addressSalt||0),version:HI(t.version||r.v3),...n}}throw Error("RPC buildTransaction received unknown TransactionType")}};nN({},{RpcChannel:()=>yO});var gO={headers:{"Content-Type":"application/json"},blockIdentifier:jI.PENDING,retries:200},yO=class{nodeUrl;headers;requestId;blockIdentifier;retries;waitMode;chainId;specVersion;transactionRetryIntervalFallback;batchClient;baseFetch;constructor(t){const{baseFetch:e,batch:r,blockIdentifier:i,chainId:n,headers:o,nodeUrl:a,retries:s,specVersion:h,transactionRetryIntervalFallback:u,waitMode:l}=t||{};Object.values(WN).includes(a)?this.nodeUrl=Qz(a,t?.default):this.nodeUrl=a||Qz(void 0,t?.default),this.baseFetch=e??Hz,this.blockIdentifier=i??gO.blockIdentifier,this.chainId=n,this.headers={...gO.headers,...o},this.retries=s??gO.retries,this.specVersion=h,this.transactionRetryIntervalFallback=u,this.waitMode=l??!1,this.requestId=0,"number"==typeof r&&(this.batchClient=new RI({nodeUrl:this.nodeUrl,headers:this.headers,interval:r,baseFetch:this.baseFetch}))}get transactionRetryIntervalDefault(){return this.transactionRetryIntervalFallback??5e3}setChainId(t){this.chainId=t}fetch(t,e,r=0){const i={id:r,jsonrpc:"2.0",method:t,...e&&{params:e}};return this.baseFetch(this.nodeUrl,{method:"POST",body:mI(i),headers:this.headers})}errorHandler(t,e,r,i){if(r)throw new vI(r,t,e);if(i instanceof wI)throw i;if(i)throw Error(i.message)}async fetchEndpoint(t,e){try{if(this.batchClient){const{error:r,result:i}=await this.batchClient.fetch(t,e,this.requestId+=1);return this.errorHandler(t,e,r),i}const r=await this.fetch(t,e,this.requestId+=1),{error:i,result:n}=await r.json();return this.errorHandler(t,e,i),n}catch(r){throw this.errorHandler(t,e,r?.response?.data,r),r}}async getChainId(){return this.chainId??=await this.fetchEndpoint("starknet_chainId"),this.chainId}async getSpecVersion(){return this.specVersion??=await this.fetchEndpoint("starknet_specVersion"),this.specVersion}getNonceForAddress(t,e=this.blockIdentifier){const r=HI(t),i=new tO(e).identifier;return this.fetchEndpoint("starknet_getNonce",{contract_address:r,block_id:i})}getBlockLatestAccepted(){return this.fetchEndpoint("starknet_blockHashAndNumber")}getBlockNumber(){return this.fetchEndpoint("starknet_blockNumber")}getBlockWithTxHashes(t=this.blockIdentifier){const e=new tO(t).identifier;return this.fetchEndpoint("starknet_getBlockWithTxHashes",{block_id:e})}getBlockWithTxs(t=this.blockIdentifier){const e=new tO(t).identifier;return this.fetchEndpoint("starknet_getBlockWithTxs",{block_id:e})}getBlockWithReceipts(t=this.blockIdentifier){const e=new tO(t).identifier;return this.fetchEndpoint("starknet_getBlockWithReceipts",{block_id:e})}getBlockStateUpdate(t=this.blockIdentifier){const e=new tO(t).identifier;return this.fetchEndpoint("starknet_getStateUpdate",{block_id:e})}getBlockTransactionsTraces(t=this.blockIdentifier){const e=new tO(t).identifier;return this.fetchEndpoint("starknet_traceBlockTransactions",{block_id:e})}getBlockTransactionCount(t=this.blockIdentifier){const e=new tO(t).identifier;return this.fetchEndpoint("starknet_getBlockTransactionCount",{block_id:e})}getTransactionByHash(t){const e=HI(t);return this.fetchEndpoint("starknet_getTransactionByHash",{transaction_hash:e})}getTransactionByBlockIdAndIndex(t,e){const r=new tO(t).identifier;return this.fetchEndpoint("starknet_getTransactionByBlockIdAndIndex",{block_id:r,index:e})}getTransactionReceipt(t){const e=HI(t);return this.fetchEndpoint("starknet_getTransactionReceipt",{transaction_hash:e})}getTransactionTrace(t){const e=HI(t);return this.fetchEndpoint("starknet_traceTransaction",{transaction_hash:e})}getTransactionStatus(t){const e=HI(t);return this.fetchEndpoint("starknet_getTransactionStatus",{transaction_hash:e})}simulateTransaction(t,e={}){const{blockIdentifier:r=this.blockIdentifier,skipValidate:i=!0,skipFeeCharge:n=!0}=e,o=new tO(r).identifier,a=[];return i&&a.push(ig.SKIP_VALIDATE),n&&a.push(ig.SKIP_FEE_CHARGE),this.fetchEndpoint("starknet_simulateTransactions",{block_id:o,transactions:t.map((t=>this.buildTransaction(t))),simulation_flags:a})}async waitForTransaction(t,e){const r=HI(t);let{retries:i}=this,n=!1,o=!1;const a=e?.retryInterval??this.transactionRetryIntervalDefault,s=e?.errorStates??[ng.REJECTED],h=e?.successStates??[ag.SUCCEEDED,ng.ACCEPTED_ON_L2,ng.ACCEPTED_ON_L1];let u;for(;!n;){await Jz(a);try{u=await this.getTransactionStatus(r);const t=u.execution_status,e=u.finality_status;if(!e){throw new Error("waiting for transaction status")}if(s.includes(t)||s.includes(e)){const r=`${t}: ${e}`,i=new Error(r);throw i.response=u,o=!0,i}(h.includes(t)||h.includes(e))&&(n=!0)}catch(t){if(t instanceof Error&&o)throw t;if(i<=0)throw new Error(`waitForTransaction timed-out with retries ${this.retries}`)}i-=1}let l=null;for(;null===l;){try{l=await this.getTransactionReceipt(r)}catch(t){if(i<=0)throw new Error(`waitForTransaction timed-out with retries ${this.retries}`)}i-=1,await Jz(a)}return l}getStorageAt(t,e,r=this.blockIdentifier){const i=HI(t),n=ZI(e),o=new tO(r).identifier;return this.fetchEndpoint("starknet_getStorageAt",{contract_address:i,key:n,block_id:o})}getClassHashAt(t,e=this.blockIdentifier){const r=HI(t),i=new tO(e).identifier;return this.fetchEndpoint("starknet_getClassHashAt",{block_id:i,contract_address:r})}getClass(t,e=this.blockIdentifier){const r=HI(t),i=new tO(e).identifier;return this.fetchEndpoint("starknet_getClass",{class_hash:r,block_id:i})}getClassAt(t,e=this.blockIdentifier){const r=HI(t),i=new tO(e).identifier;return this.fetchEndpoint("starknet_getClassAt",{block_id:i,contract_address:r})}async getEstimateFee(t,{blockIdentifier:e=this.blockIdentifier,skipValidate:r=!0}){const i=new tO(e).identifier;let n={};return rO("0.5",await this.getSpecVersion())||(n={simulation_flags:r?[ig.SKIP_VALIDATE]:[]}),this.fetchEndpoint("starknet_estimateFee",{request:t.map((t=>this.buildTransaction(t,"fee"))),block_id:i,...n})}async invoke(t,e){let r;return eO(e)?r=this.fetchEndpoint("starknet_addInvokeTransaction",{invoke_transaction:{type:rg.INVOKE,sender_address:t.contractAddress,calldata:FC.toHex(t.calldata),version:lg.V3,signature:zz(t.signature),nonce:HI(e.nonce),resource_bounds:e.resourceBounds,tip:HI(e.tip),paymaster_data:e.paymasterData.map((t=>HI(t))),account_deployment_data:e.accountDeploymentData.map((t=>HI(t))),nonce_data_availability_mode:e.nonceDataAvailabilityMode,fee_data_availability_mode:e.feeDataAvailabilityMode}}):(r=this.fetchEndpoint("starknet_addInvokeTransaction",{invoke_transaction:{sender_address:t.contractAddress,calldata:FC.toHex(t.calldata),type:rg.INVOKE,max_fee:HI(e.maxFee||0),version:lg.V1,signature:zz(t.signature),nonce:HI(e.nonce)}}),Kz.warn(uI.legacyTxWarningMessage,{version:lg.V1,type:rg.INVOKE})),this.waitMode?this.waitForTransaction((await r).transaction_hash):r}async declare({contract:t,signature:e,senderAddress:r,compiledClassHash:i},n){let o;if(Uz(t)||eO(n))if(Uz(t)&&!eO(n))o=this.fetchEndpoint("starknet_addDeclareTransaction",{declare_transaction:{type:rg.DECLARE,contract_class:{sierra_program:Sz(t.sierra_program),contract_class_version:t.contract_class_version,entry_points_by_type:t.entry_points_by_type,abi:t.abi},compiled_class_hash:i||"",version:lg.V2,max_fee:HI(n.maxFee||0),signature:zz(e),sender_address:r,nonce:HI(n.nonce)}}),Kz.warn(uI.legacyTxWarningMessage,{version:lg.V2,type:rg.DECLARE});else{if(!Uz(t)||!eO(n))throw Error("declare unspotted parameters");o=this.fetchEndpoint("starknet_addDeclareTransaction",{declare_transaction:{type:rg.DECLARE,sender_address:r,compiled_class_hash:i||"",version:lg.V3,signature:zz(e),nonce:HI(n.nonce),contract_class:{sierra_program:Sz(t.sierra_program),contract_class_version:t.contract_class_version,entry_points_by_type:t.entry_points_by_type,abi:t.abi},resource_bounds:n.resourceBounds,tip:HI(n.tip),paymaster_data:n.paymasterData.map((t=>HI(t))),account_deployment_data:n.accountDeploymentData.map((t=>HI(t))),nonce_data_availability_mode:n.nonceDataAvailabilityMode,fee_data_availability_mode:n.feeDataAvailabilityMode}})}else o=this.fetchEndpoint("starknet_addDeclareTransaction",{declare_transaction:{type:rg.DECLARE,contract_class:{program:t.program,entry_points_by_type:t.entry_points_by_type,abi:t.abi},version:lg.V1,max_fee:HI(n.maxFee||0),signature:zz(e),sender_address:r,nonce:HI(n.nonce)}}),Kz.warn(uI.legacyTxWarningMessage,{version:lg.V1,type:rg.DECLARE});return this.waitMode?this.waitForTransaction((await o).transaction_hash):o}async deployAccount({classHash:t,constructorCalldata:e,addressSalt:r,signature:i},n){let o;return eO(n)?o=this.fetchEndpoint("starknet_addDeployAccountTransaction",{deploy_account_transaction:{type:rg.DEPLOY_ACCOUNT,version:lg.V3,signature:zz(i),nonce:HI(n.nonce),contract_address_salt:HI(r||0),constructor_calldata:FC.toHex(e||[]),class_hash:HI(t),resource_bounds:n.resourceBounds,tip:HI(n.tip),paymaster_data:n.paymasterData.map((t=>HI(t))),nonce_data_availability_mode:n.nonceDataAvailabilityMode,fee_data_availability_mode:n.feeDataAvailabilityMode}}):(o=this.fetchEndpoint("starknet_addDeployAccountTransaction",{deploy_account_transaction:{constructor_calldata:FC.toHex(e||[]),class_hash:HI(t),contract_address_salt:HI(r||0),type:rg.DEPLOY_ACCOUNT,max_fee:HI(n.maxFee||0),version:lg.V1,signature:zz(i),nonce:HI(n.nonce)}}),Kz.warn(uI.legacyTxWarningMessage,{version:lg.V1,type:rg.DEPLOY_ACCOUNT})),this.waitMode?this.waitForTransaction((await o).transaction_hash):o}callContract(t,e=this.blockIdentifier){const r=new tO(e).identifier;return this.fetchEndpoint("starknet_call",{request:{contract_address:t.contractAddress,entry_point_selector:cT(t.entrypoint),calldata:FC.toHex(t.calldata)},block_id:r})}estimateMessageFee(t,e=this.blockIdentifier){const{from_address:r,to_address:i,entry_point_selector:n,payload:o}=t,a={from_address:Vz(r),to_address:HI(i),entry_point_selector:dT(n),payload:iT(o)},s=new tO(e).identifier;return this.fetchEndpoint("starknet_estimateMessageFee",{message:a,block_id:s})}getSyncingStats(){return this.fetchEndpoint("starknet_syncing")}getEvents(t){return this.fetchEndpoint("starknet_getEvents",{filter:t})}buildTransaction(t,e){const r=fO(e);let i;if(eO(t)?i={signature:zz(t.signature),nonce:HI(t.nonce),resource_bounds:t.resourceBounds,tip:HI(t.tip),paymaster_data:t.paymasterData.map((t=>HI(t))),nonce_data_availability_mode:t.nonceDataAvailabilityMode,fee_data_availability_mode:t.feeDataAvailabilityMode,account_deployment_data:t.accountDeploymentData.map((t=>HI(t)))}:(i={signature:zz(t.signature),nonce:HI(t.nonce),max_fee:HI(t.maxFee||0)},Kz.warn(uI.legacyTxWarningMessage,{version:t.version,type:t.type})),t.type===kI.INVOKE)return{type:rg.INVOKE,sender_address:t.contractAddress,calldata:FC.toHex(t.calldata),version:HI(t.version||r.v3),...i};if(t.type===kI.DECLARE)return Uz(t.contract)?{type:t.type,contract_class:{...t.contract,sierra_program:Sz(t.contract.sierra_program)},compiled_class_hash:t.compiledClassHash||"",sender_address:t.senderAddress,version:HI(t.version||r.v3),...i}:{type:t.type,contract_class:t.contract,sender_address:t.senderAddress,version:HI(t.version||r.v1),...i};if(t.type===kI.DEPLOY_ACCOUNT){const{account_deployment_data:e,...n}=i;return{type:t.type,constructor_calldata:FC.toHex(t.constructorCalldata||[]),class_hash:HI(t.classHash),contract_address_salt:HI(t.addressSalt||0),version:HI(t.version||r.v3),...n}}throw Error("RPC buildTransaction received unknown TransactionType")}},wO=class{margin;constructor(t){this.margin=t}estimatedFeeToMaxFee(t){return Oz(t,this.margin?.maxFee)}estimateFeeToBounds(t){return Rz(t,this.margin?.l1BoundMaxAmount,this.margin?.l1BoundMaxPricePerUnit)}parseGetBlockResponse(t){return{status:"PENDING",...t}}parseTransactionReceipt(t){return"actual_fee"in t&&FI(t.actual_fee)?{...t,actual_fee:{amount:t.actual_fee,unit:"FRI"}}:t}parseFeeEstimateResponse(t){const e=t[0];return{overall_fee:VI(e.overall_fee),gas_consumed:VI(e.gas_consumed),gas_price:VI(e.gas_price),unit:e.unit,suggestedMaxFee:this.estimatedFeeToMaxFee(e.overall_fee),resourceBounds:this.estimateFeeToBounds(e),data_gas_consumed:e.data_gas_consumed?VI(e.data_gas_consumed):0n,data_gas_price:e.data_gas_price?VI(e.data_gas_price):0n}}parseFeeEstimateBulkResponse(t){return t.map((t=>({overall_fee:VI(t.overall_fee),gas_consumed:VI(t.gas_consumed),gas_price:VI(t.gas_price),unit:t.unit,suggestedMaxFee:this.estimatedFeeToMaxFee(t.overall_fee),resourceBounds:this.estimateFeeToBounds(t),data_gas_consumed:t.data_gas_consumed?VI(t.data_gas_consumed):0n,data_gas_price:t.data_gas_price?VI(t.data_gas_price):0n})))}parseSimulateTransactionResponse(t){return t.map((t=>({...t,suggestedMaxFee:this.estimatedFeeToMaxFee(t.fee_estimation.overall_fee),resourceBounds:this.estimateFeeToBounds(t.fee_estimation)})))}parseContractClassResponse(t){return{...t,abi:FI(t.abi)?JSON.parse(t.abi):t.abi}}parseL1GasPriceResponse(t){return t.l1_gas_price.price_in_wei}},vO=class t{statusReceipt;value;constructor(e){[this.statusReceipt,this.value]=t.isSuccess(e)?["success",e]:t.isReverted(e)?["reverted",e]:t.isRejected(e)?["rejected",e]:["error",new Error("Unknown response type")];for(const[t]of Object.entries(this))Object.defineProperty(this,t,{enumerable:!1});for(const[t,r]of Object.entries(e))Object.defineProperty(this,t,{enumerable:!0,writable:!1,value:r})}match(t){return this.statusReceipt in t?t[this.statusReceipt](this.value):t._()}isSuccess(){return"success"===this.statusReceipt}isReverted(){return"reverted"===this.statusReceipt}isRejected(){return"rejected"===this.statusReceipt}isError(){return"error"===this.statusReceipt}static isSuccess(t){return t.execution_status===EI.SUCCEEDED}static isReverted(t){return t.execution_status===EI.REVERTED}static isRejected(t){return t.status===EI.REJECTED}},bO={};nN(bO,{TypedDataRevision:()=>pg,encodeData:()=>RO,encodeType:()=>CO,encodeValue:()=>OO,getDependencies:()=>TO,getMessageHash:()=>BO,getStructHash:()=>PO,getTypeHash:()=>zO,isMerkleTreeType:()=>IO,prepareSelector:()=>NO,validateTypedData:()=>SO,verifyMessage:()=>DO});nN({},{MerkleTree:()=>kO,proofMerklePath:()=>MO});var kO=class t{leaves;branches=[];root;hashMethod;constructor(t,e=cz){this.hashMethod=e,this.leaves=t,this.root=this.build(t)}build(e){if(1===e.length)return e[0];e.length!==this.leaves.length&&this.branches.push(e);const r=[];for(let i=0;i<e.length;i+=2)i+1===e.length?r.push(t.hash(e[i],"0x0",this.hashMethod)):r.push(t.hash(e[i],e[i+1],this.hashMethod));return this.build(r)}static hash(t,e,r=cz){const[i,n]=[BigInt(t),BigInt(e)].sort(((t,e)=>t>=e?1:-1));return r(i,n)}getProof(e,r=this.leaves,i=[]){const n=r.indexOf(e);if(-1===n)throw new Error("leaf not found");if(1===r.length)return i;const o=n%2==0,a=(o?r[n+1]:r[n-1])??"0x0",s=[...i,a],h=this.leaves.length===r.length?-1:this.branches.findIndex((t=>t.length===r.length)),u=this.branches[h+1]??[this.root];return this.getProof(t.hash(o?e:a,o?a:e,this.hashMethod),u,s)}};function MO(t,e,r,i=cz){if(0===r.length)return t===e;const[n,...o]=r;return MO(t,kO.hash(e,n,i),o,i)}var _O={u256:JSON.parse('[{ "name": "low", "type": "u128" }, { "name": "high", "type": "u128" }]'),TokenAmount:JSON.parse('[{ "name": "token_address", "type": "ContractAddress" }, { "name": "amount", "type": "u256" }]'),NftId:JSON.parse('[{ "name": "collection_address", "type": "ContractAddress" }, { "name": "token_id", "type": "u256" }]')},EO={[pg.ACTIVE]:{domain:"StarknetDomain",hashMethod:pz,hashMerkleMethod:dz,escapeTypeString:t=>`"${t}"`,presetTypes:_O},[pg.LEGACY]:{domain:"StarkNetDomain",hashMethod:mz,hashMerkleMethod:cz,escapeTypeString:t=>t,presetTypes:{}}};function AO(t,e,{min:r,max:i}){const n=BigInt(t);PI(n>=r&&n<=i,`${n} (${e}) is out of bounds [${r}, ${i}]`)}function jO({types:t,domain:e}){return EO[pg.ACTIVE].domain in t&&e.revision===pg.ACTIVE?pg.ACTIVE:EO[pg.LEGACY].domain in t&&(e.revision??pg.LEGACY)===pg.LEGACY?pg.LEGACY:void 0}function xO(t){try{return HI(t)}catch(e){if(FI(t))return HI(MT(t));throw new Error(`Invalid BigNumberish: ${t}`)}}function SO(t){const e=t;return Boolean(e.message&&e.primaryType&&e.types&&jO(e))}function NO(t){return qI(t)?t:cT(t)}function IO(t){return"merkletree"===t.type}function TO(t,e,r=[],i="",n=pg.LEGACY){let o=[e];return"*"===e[e.length-1]?o=[e.slice(0,-1)]:n===pg.ACTIVE&&("enum"===e?o=[i]:e.match(/^\(.*\)$/)&&(o=e.slice(1,-1).split(",").map((t=>"*"===t[t.length-1]?t.slice(0,-1):t)))),o.filter((e=>!r.includes(e)&&t[e])).reduce(((e,r)=>[...e,...[r,...t[r].reduce(((e,r)=>[...e,...TO(t,r.type,e,r.contains,n).filter((t=>!e.includes(t)))]),[])].filter((t=>!e.includes(t)))]),[])}function CO(t,e,r=pg.LEGACY){const i=r===pg.ACTIVE?{...t,...EO[r].presetTypes}:t,[n,...o]=TO(i,e,void 0,void 0,r),a=n?[n,...o.sort()]:[],s=EO[r].escapeTypeString;return a.map((t=>{const e=i[t].map((t=>{const e="enum"===t.type&&r===pg.ACTIVE?t.contains:t.type,i=e.match(/^\(.*\)$/)?`(${e.slice(1,-1).split(",").map((t=>t?s(t):t)).join(",")})`:s(e);return`${s(t.name)}:${i}`}));return`${s(t)}(${e})`})).join("")}function zO(t,e,r=pg.LEGACY){return cT(CO(t,e,r))}function OO(t,e,r,i={},n=pg.LEGACY){if(t[e])return[e,PO(t,e,r,n)];if(EO[n].presetTypes[e])return[e,PO(EO[n].presetTypes,e,r,n)];if(e.endsWith("*")){const i=r.map((r=>OO(t,e.slice(0,-1),r,void 0,n)[1]));return[e,EO[n].hashMethod(i)]}switch(e){case"enum":if(n===pg.ACTIVE){const[o,a]=Object.entries(r)[0],s=t[i.parent].find((t=>t.name===i.key)),h=t[s.contains],u=h.find((t=>t.name===o)),l=h.indexOf(u),c=u.type.slice(1,-1).split(",").map(((e,r)=>{if(!e)return e;const i=a[r];return OO(t,e,i,void 0,n)[1]}));return[e,EO[n].hashMethod([l,...c])]}return[e,xO(r)];case"merkletree":{const e=function(t,e){if(e.parent&&e.key){const r=t[e.parent].find((t=>t.name===e.key));if(!IO(r))throw new Error(`${e.key} is not a merkle tree`);if(r.contains.endsWith("*"))throw new Error(`Merkle tree contain property must not be an array but was given ${e.key}`);return r.contains}return"raw"}(t,i),o=r.map((r=>OO(t,e,r,void 0,n)[1])),{root:a}=new kO(o,EO[n].hashMerkleMethod);return["felt",a]}case"selector":return["felt",NO(r)];case"string":if(n===pg.ACTIVE){const t=AT(r),i=[t.data.length,...t.data,t.pending_word,t.pending_word_len];return[e,EO[n].hashMethod(i)]}return[e,xO(r)];case"i128":if(n===pg.ACTIVE){const t=BigInt(r);return AO(t,e,ZN),[e,xO(t<0n?UN+t:t)]}return[e,xO(r)];case"timestamp":case"u128":return n===pg.ACTIVE&&AO(r,e,KN),[e,xO(r)];case"felt":case"shortstring":return n===pg.ACTIVE&&AO(xO(r),e,GN),[e,xO(r)];case"ClassHash":case"ContractAddress":return n===pg.ACTIVE&&AO(r,e,GN),[e,xO(r)];case"bool":return n===pg.ACTIVE&&PI($I(r),`Type mismatch for ${e} ${r}`),[e,xO(r)];default:if(n===pg.ACTIVE)throw new Error(`Unsupported type: ${e}`);return[e,xO(r)]}}function RO(t,e,r,i=pg.LEGACY){const n=t[e]??EO[i].presetTypes[e],[o,a]=n.reduce((([n,o],a)=>{if(void 0===r[a.name]||null===r[a.name]&&"enum"!==a.type)throw new Error(`Cannot encode data: missing data for '${a.name}'`);const s=r[a.name],h={parent:e,key:a.name},[u,l]=OO(t,a.type,s,h,i);return[[...n,u],[...o,l]]}),[["felt"],[zO(t,e,i)]]);return[o,a]}function PO(t,e,r,i=pg.LEGACY){return EO[i].hashMethod(RO(t,e,r,i)[1])}function BO(t,e){if(!SO(t))throw new Error("Typed data does not match JSON schema");const r=jO(t),{domain:i,hashMethod:n}=EO[r];return n([MT("StarkNet Message"),PO(t.types,i,t.domain,r),e,PO(t.types,t.primaryType,t.message,r)])}function DO(t,e,r,i){const n=SO(t);if(!hT(t)&&!n)throw new Error("message has a wrong format.");if(n&&void 0===i)throw new Error("When providing a TypedData in message parameter, the accountAddress parameter has to be provided.");if(n&&!hT(i))throw new Error("accountAddress shall be a BigNumberish");const o=n?BO(t,i):HI(t);return zb(Array.isArray(e)?new Pb(BigInt(e[0]),BigInt(e[1])):e,o,HI(r))}var $O=class{responseParser;channel;constructor(t){t&&"channel"in t?(this.channel=t.channel,this.responseParser="responseParser"in t?t.responseParser:new wO):(this.channel=new yO({...t,waitMode:!1}),this.responseParser=new wO(t?.feeMarginPercentage))}fetch(t,e,r=0){return this.channel.fetch(t,e,r)}async getChainId(){return this.channel.getChainId()}async getSpecVersion(){return this.channel.getSpecVersion()}async getNonceForAddress(t,e){return this.channel.getNonceForAddress(t,e)}async getBlock(t){return this.channel.getBlockWithTxHashes(t).then(this.responseParser.parseGetBlockResponse)}async getBlockLatestAccepted(){return this.channel.getBlockLatestAccepted()}async getBlockNumber(){return this.channel.getBlockNumber()}async getBlockWithTxHashes(t){return this.channel.getBlockWithTxHashes(t)}async getBlockWithTxs(t){return this.channel.getBlockWithTxs(t)}async waitForBlock(t="pending",e=5e3){if(t===jI.LATEST)return;const r=await this.getBlockNumber(),i=t===jI.PENDING?r+1:Number(HI(t));if(i<=r)return;const{retries:n}=this.channel;let o=n,a=!1;for(;!a;){if(await this.getBlockNumber()===i?a=!0:await Jz(e),o-=1,o<=0)throw new Error(`waitForBlock() timed-out after ${n} tries.`)}}async getL1GasPrice(t){return this.channel.getBlockWithTxHashes(t).then(this.responseParser.parseL1GasPriceResponse)}async getL1MessageHash(t){const e=await this.channel.getTransactionByHash(t);PI("L1_HANDLER"===e.type,"This L2 transaction is not a L1 message.");const{calldata:r,contract_address:i,entry_point_selector:n,nonce:o}=e;return fT([r[0],i,o,n,r.length-1,...r.slice(1)])}async getBlockWithReceipts(t){if(this.channel instanceof lI.RpcChannel)throw new wI("Unsupported method for RPC version");return this.channel.getBlockWithReceipts(t)}getStateUpdate=this.getBlockStateUpdate;async getBlockStateUpdate(t){return this.channel.getBlockStateUpdate(t)}async getBlockTransactionsTraces(t){return this.channel.getBlockTransactionsTraces(t)}async getBlockTransactionCount(t){return this.channel.getBlockTransactionCount(t)}async getPendingTransactions(){const{transactions:t}=await this.getBlockWithTxHashes(jI.PENDING).then(this.responseParser.parseGetBlockResponse);return Promise.all(t.map((t=>this.getTransactionByHash(t))))}async getTransaction(t){return this.channel.getTransactionByHash(t)}async getTransactionByHash(t){return this.channel.getTransactionByHash(t)}async getTransactionByBlockIdAndIndex(t,e){return this.channel.getTransactionByBlockIdAndIndex(t,e)}async getTransactionReceipt(t){const e=await this.channel.getTransactionReceipt(t),r=this.responseParser.parseTransactionReceipt(e);return new vO(r)}async getTransactionTrace(t){return this.channel.getTransactionTrace(t)}async getTransactionStatus(t){return this.channel.getTransactionStatus(t)}async getSimulateTransaction(t,e){return this.channel.simulateTransaction(t,e).then((t=>this.responseParser.parseSimulateTransactionResponse(t)))}async waitForTransaction(t,e){const r=await this.channel.waitForTransaction(t,e);return new vO(r)}async getStorageAt(t,e,r){return this.channel.getStorageAt(t,e,r)}async getClassHashAt(t,e){return this.channel.getClassHashAt(t,e)}async getClassByHash(t){return this.getClass(t)}async getClass(t,e){return this.channel.getClass(t,e).then(this.responseParser.parseContractClassResponse)}async getClassAt(t,e){return this.channel.getClassAt(t,e).then(this.responseParser.parseContractClassResponse)}async getContractVersion(t,e,{blockIdentifier:r=this.channel.blockIdentifier,compiler:i=!0}={}){let n;if(t)n=await this.getClassAt(t,r);else{if(!e)throw Error("getContractVersion require contractAddress or classHash");n=await this.getClass(e,r)}if(Uz(n)){if(i){return{cairo:"1",compiler:uC(n.abi).compiler}}return{cairo:"1",compiler:void 0}}return{cairo:"0",compiler:"0"}}async getEstimateFee(t,e,r,i){return this.getInvokeEstimateFee(t,e,r,i)}async getInvokeEstimateFee(t,e,r,i){return this.channel.getEstimateFee([{type:kI.INVOKE,...t,...e}],{blockIdentifier:r,skipValidate:i}).then((t=>this.responseParser.parseFeeEstimateResponse(t)))}async getDeclareEstimateFee(t,e,r,i){return this.channel.getEstimateFee([{type:kI.DECLARE,...t,...e}],{blockIdentifier:r,skipValidate:i}).then((t=>this.responseParser.parseFeeEstimateResponse(t)))}async getDeployAccountEstimateFee(t,e,r,i){return this.channel.getEstimateFee([{type:kI.DEPLOY_ACCOUNT,...t,...e}],{blockIdentifier:r,skipValidate:i}).then((t=>this.responseParser.parseFeeEstimateResponse(t)))}async getEstimateFeeBulk(t,e){return this.channel.getEstimateFee(t,e).then((t=>this.responseParser.parseFeeEstimateBulkResponse(t)))}async invokeFunction(t,e){return this.channel.invoke(t,e)}async declareContract(t,e){return this.channel.declare(t,e)}async deployAccountContract(t,e){return this.channel.deployAccount(t,e)}async callContract(t,e){return this.channel.callContract(t,e)}async estimateMessageFee(t,e){return this.channel.estimateMessageFee(t,e)}async getSyncingStats(){return this.channel.getSyncingStats()}async getEvents(t){return this.channel.getEvents(t)}async verifyMessageInStarknet(t,e,r,i,n){const o=SO(t);if(!hT(t)&&!o)throw new Error("message has a wrong format.");if(!hT(r))throw new Error("accountAddress shall be a BigNumberish");const a=o?BO(t,r):HI(t),s=i?[i]:["isValidSignature","is_valid_signature"],h=n||{okResponse:[],nokResponse:["0x0","0x00"],error:["argent/invalid-signature","is invalid, with respect to the public key","INVALID_SIG"]};let u;for(const t of s)try{const i=await this.callContract({contractAddress:HI(r),entrypoint:t,calldata:FC.compile({hash:VI(a).toString(),signature:Tz(e)})});if(h.nokResponse.includes(i[0].toString()))return!1;if(0===h.okResponse.length||h.okResponse.includes(i[0].toString()))return!0;throw Error("signatureVerificationResponse Error: response is not part of known responses")}catch(t){if(h.error.some((e=>t.message.includes(e))))return!1;u=t}throw Error(`Signature verification Error: ${u}`)}async isClassDeclared(t,e){let r;if(!t.classHash&&"contract"in t){r=function(t){const e={...t};if(Uz(t.contract)&&(!t.compiledClassHash&&t.casm&&(e.compiledClassHash=_z(t.casm)),!e.compiledClassHash))throw new Error("Extract compiledClassHash failed, provide (CairoAssembly).casm file or compiledClassHash");if(e.classHash=t.classHash??jz(t.contract),!e.classHash)throw new Error("Extract classHash failed, provide (CompiledContract).json file or classHash");return e}(t).classHash}else{if(!t.classHash)throw Error("contractClassIdentifier type not satisfied");r=t.classHash}try{return await this.getClass(r,e)instanceof Object}catch(t){if(t instanceof wI)return!1;throw t}}async prepareInvocations(t){const e=[];for(const r of t)if(r.type===kI.DECLARE){await this.isClassDeclared("payload"in r?r.payload:r)||e.unshift(r)}else e.push(r);return e}};nN({},{StarknetIdContract:()=>JO,StarknetIdIdentityContract:()=>YO,StarknetIdMulticallContract:()=>XO,StarknetIdPfpContract:()=>iR,StarknetIdPopContract:()=>oR,StarknetIdVerifierContract:()=>eR,dynamicCallData:()=>uR,dynamicFelt:()=>hR,execution:()=>sR,getStarknetIdContract:()=>WO,getStarknetIdIdentityContract:()=>QO,getStarknetIdMulticallContract:()=>tR,getStarknetIdPfpContract:()=>nR,getStarknetIdPopContract:()=>aR,getStarknetIdVerifierContract:()=>rR,isStarkDomain:()=>lR,useDecoded:()=>ZO,useEncoded:()=>KO});var LO="abcdefghijklmnopqrstuvwxyz0123456789-",FO=BigInt(LO.length+1),UO="这来",qO=BigInt(LO.length),VO=BigInt(UO.length),HO=BigInt(UO.length+1);function GO(t){let e=0;for(;t.endsWith(UO[UO.length-1]);)t=t.substring(0,t.length-1),e+=1;return[t,e]}function ZO(t){let e="";return t.forEach((t=>{for(;t!==DN;){const r=t%FO;if(t/=FO,r===BigInt(LO.length)){const r=t/HO;if(r===DN){const i=t%HO;t=r,e+=i===DN?LO[0]:UO[Number(i)-1]}else{e+=UO[Number(t%VO)],t/=VO}}else e+=LO[Number(r)]}const[r,i]=GO(e);i&&(e=r+(i%2==0?UO[UO.length-1].repeat(i/2-1)+UO[0]+LO[1]:UO[UO.length-1].repeat((i-1)/2+1))),e+="."})),e?e.concat("stark"):e}function KO(t){let e=BigInt(0),r=BigInt(1);if(t.endsWith(UO[0]+LO[1])){const[e,r]=GO(t.substring(0,t.length-2));t=e+UO[UO.length-1].repeat(2*(r+1))}else{const[e,r]=GO(t);r&&(t=e+UO[UO.length-1].repeat(1+2*(r-1)))}for(let i=0;i<t.length;i+=1){const n=t[i],o=LO.indexOf(n),a=BigInt(LO.indexOf(n));if(-1!==o)i===t.length-1&&t[i]===LO[0]?(e+=r*qO,r*=FO,r*=FO):(e+=r*a,r*=FO);else if(-1!==UO.indexOf(n)){e+=r*qO,r*=FO;const o=(i===t.length-1?1:0)+UO.indexOf(n);e+=r*BigInt(o),r*=VO}}return e}var JO={MAINNET:"0x6ac597f8116f886fa1c97a23fa4e08299975ecaf6b598873ca6792b9bbfb678",TESTNET_SEPOLIA:"0x154bc2e1af9260b9e66af0e9c46fc757ff893b3ff6a85718a810baf1474"};function WO(t){switch(t){case"0x534e5f4d41494e":return JO.MAINNET;case"0x534e5f5345504f4c4941":return JO.TESTNET_SEPOLIA;default:throw new Error("Starknet.id is not yet deployed on this network")}}var YO={MAINNET:"0x05dbdedc203e92749e2e746e2d40a768d966bd243df04a6b712e222bc040a9af",TESTNET_SEPOLIA:"0x3697660a0981d734780731949ecb2b4a38d6a58fc41629ed611e8defda"};function QO(t){switch(t){case"0x534e5f4d41494e":return YO.MAINNET;case"0x534e5f5345504f4c4941":return YO.TESTNET_SEPOLIA;default:throw new Error("Starknet.id verifier contract is not yet deployed on this network")}}var XO="0x034ffb8f4452df7a613a0210824d6414dbadcddce6c6e19bf4ddc9e22ce5f970";function tR(t){switch(t){case"0x534e5f4d41494e":case"0x534e5f5345504f4c4941":return XO;default:throw new Error("Starknet.id multicall contract is not yet deployed on this network")}}var eR={MAINNET:"0x07d14dfd8ee95b41fce179170d88ba1f0d5a512e13aeb232f19cfeec0a88f8bf",TESTNET_SEPOLIA:"0x60B94fEDe525f815AE5E8377A463e121C787cCCf3a36358Aa9B18c12c4D566"};function rR(t){switch(t){case"0x534e5f4d41494e":return eR.MAINNET;case"0x534e5f5345504f4c4941":return eR.TESTNET_SEPOLIA;default:throw new Error("Starknet.id verifier contract is not yet deployed on this network")}}var iR={MAINNET:"0x070aaa20ec4a46da57c932d9fd89ca5e6bb9ca3188d3df361a32306aff7d59c7",TESTNET_SEPOLIA:"0x9e7bdb8dabd02ea8cfc23b1d1c5278e46490f193f87516ed5ff2dfec02"};function nR(t){switch(t){case"0x534e5f4d41494e":return iR.MAINNET;case"0x534e5f5345504f4c4941":return iR.TESTNET_SEPOLIA;default:throw new Error("Starknet.id profile picture verifier contract is not yet deployed on this network")}}var oR={MAINNET:"0x0293eb2ba9862f762bd3036586d5755a782bd22e6f5028320f1d0405fd47bff4",TESTNET_SEPOLIA:"0x15ae88ae054caa74090b89025c1595683f12edf7a4ed2ad0274de3e1d4a"};function aR(t){switch(t){case"0x534e5f4d41494e":return oR.MAINNET;case"0x534e5f5345504f4c4941":return oR.TESTNET_SEPOLIA;default:throw new Error("Starknet.id proof of personhood verifier contract is not yet deployed on this network")}}function sR(t,e,r){return new mC({Static:t,IfEqual:e?dC(e[0],e[1],e[2]):void 0,IfNotEqual:r?dC(r[0],r[1],r[2]):void 0})}function hR(t,e){return new mC({Hardcoded:t,Reference:e?dC(e[0],e[1]):void 0})}function uR(t,e,r){return new mC({Hardcoded:t,Reference:e?dC(e[0],e[1]):void 0,ArrayReference:r?dC(r[0],r[1]):void 0})}function lR(t){return/^(?:[a-z0-9-]{1,48}(?:[a-z0-9-]{1,48}[a-z0-9-])?\.)*[a-z0-9-]{1,48}\.stark$/.test(t)}var cR=class extends(QS($O,class t{async getStarkName(e,r){return t.getStarkName(this,e,r)}async getAddressFromStarkName(e,r){return t.getAddressFromStarkName(this,e,r)}async getStarkProfile(e,r,i,n,o,a,s){return t.getStarkProfile(this,e,r,i,n,o,a,s)}static async getStarkName(t,e,r){const i=await t.getChainId(),n=r??WO(i);try{const r=await t.callContract({contractAddress:n,entrypoint:"address_to_domain",calldata:FC.compile({address:e,hint:[]})}),i=ZO(r.map((t=>BigInt(t))).slice(1));if(!i)throw Error("Starkname not found");return i}catch(t){if(t instanceof Error&&"Starkname not found"===t.message)throw t;throw Error("Could not get stark name")}}static async getAddressFromStarkName(t,e,r){const i=e.endsWith(".stark")?e:`${e}.stark`;if(!lR(i))throw new Error("Invalid domain, must be a valid .stark domain");const n=await t.getChainId(),o=r??WO(n);try{const e=i.replace(".stark","").split(".").map((t=>KO(t).toString(10)));return(await t.callContract({contractAddress:o,entrypoint:"domain_to_address",calldata:FC.compile({domain:e,hint:[]})}))[0]}catch{throw Error("Could not get address from stark name")}}static async getStarkProfile(t,e,r,i,n,o,a,s){const h=await t.getChainId(),u=r??WO(h),l=i??QO(h),c=n??rR(h),d=o??nR(h),f=a??aR(h),m=s??tR(h);try{const r=[{execution:sR({}),to:uR(u),selector:uR(cT("address_to_domain")),calldata:[uR(e),uR("0")]},{execution:sR({}),to:hR(u),selector:hR(cT("domain_to_id")),calldata:[uR(void 0,void 0,[0,0])]},{execution:sR({}),to:hR(l),selector:hR(cT("get_verifier_data")),calldata:[uR(void 0,[1,0]),uR(MT("twitter")),uR(c),uR("0")]},{execution:sR({}),to:hR(l),selector:hR(cT("get_verifier_data")),calldata:[uR(void 0,[1,0]),uR(MT("github")),uR(c),uR("0")]},{execution:sR({}),to:hR(l),selector:hR(cT("get_verifier_data")),calldata:[uR(void 0,[1,0]),uR(MT("discord")),uR(c),uR("0")]},{execution:sR({}),to:hR(l),selector:hR(cT("get_verifier_data")),calldata:[uR(void 0,[1,0]),uR(MT("proof_of_personhood")),uR(f),uR("0")]},{execution:sR({}),to:hR(l),selector:hR(cT("get_verifier_data")),calldata:[uR(void 0,[1,0]),uR(MT("nft_pp_contract")),uR(d),uR("0")]},{execution:sR({}),to:hR(l),selector:hR(cT("get_extended_verifier_data")),calldata:[uR(void 0,[1,0]),uR(MT("nft_pp_id")),uR("2"),uR(d),uR("0")]},{execution:sR(void 0,void 0,[6,0,0]),to:hR(void 0,[6,0]),selector:hR(cT("tokenURI")),calldata:[uR(void 0,[7,1]),uR(void 0,[7,2])]}],i=await t.callContract({contractAddress:m,entrypoint:"aggregate",calldata:FC.compile({calls:r})});if(Array.isArray(i)){const t=parseInt(i[0],16),e=[];let r=1;for(let n=0;n<t&&r<i.length;n+=1){const t=parseInt(i[r],16);r+=1;const n=i.slice(r,r+t);e.push(n),r+=t}const n=ZO(e[0].slice(1).map((t=>BigInt(t)))),o="0x0"!==e[2][0]?BigInt(e[2][0]).toString():void 0,a="0x0"!==e[3][0]?BigInt(e[3][0]).toString():void 0,s="0x0"!==e[4][0]?BigInt(e[4][0]).toString():void 0,h="0x1"===e[5][0],u="0x9"===i[0]?e[8].slice(1).map((t=>_T(t))).join(""):void 0;return{name:n,twitter:o,github:a,discord:s,proofOfPersonhood:h,profilePicture:u||`https://starknet.id/api/identicons/${BigInt(e[1][0]).toString()}`}}throw Error("Error while calling aggregate function")}catch(t){if(t instanceof Error)throw t;throw Error("Could not get user stark profile data from address")}}})){},dR=new $O({default:!0});function fR(t){return new RT(t).toBigInt()}function mR(t){return RT.is(t)}function pR(t){return new RT(t).toUint256HexString()}function gR(t){const e=function(t){const e=HI(IN(t.toString()));return IN(NN(e).padStart(64,"0"))}(t);if(!e.match(/^(0x)?[0-9a-fA-F]{64}$/))throw new Error("Invalid Address Format");return YI(e,DN,VN-1n,"Starknet Address"),e}nN({},{UINT_128_MAX:()=>ST,UINT_256_MAX:()=>NT,bnToUint256:()=>pR,isUint256:()=>mR,uint256ToBN:()=>fR});function yR(t){return"event"===t.type}function wR(t){const e=t.filter((t=>yR(t)&&"struct"===t.kind)),r=t.filter((t=>yR(t)&&"enum"===t.kind)),i=e.reduce(((t,e)=>{let i=[],{name:n}=e,o=!1;const a=t=>t.type===n;for(;;){const t=r.find((t=>t.variants.some(a)));if(BI(t))break;const e=t.variants.find(a);i.unshift(e.name),"flat"===e.kind&&(o=!0),n=t.name}if(0===i.length)throw new Error("inconsistency in ABI events definition.");o&&(i=[i[i.length-1]]);const s=i.pop();let h={[IN(Yb(EN(s)).toString(16))]:e};for(;i.length>0;)h={[IN(Yb(EN(i.pop())).toString(16))]:h};return h={...h},bR(t,h)}),{});return i}function vR(t){return sC(t)?wR(t):function(t){return t.filter((t=>"event"===t.type)).reduce(((t,e)=>{const r=e.name,i={...e};return i.name=r,{...t,[IN(Yb(EN(r)).toString(16))]:i}}),{})}(t)}function bR(t,e){const r={...t};return UI(t)&&UI(e)&&Object.keys(e).forEach((i=>{UI(e[i])?i in t?r[i]=bR(t[i],e[i]):Object.assign(r,{[i]:e[i]}):Object.assign(r,{[i]:e[i]})})),r}function kR(t,e,r,i){const n=t.flat().reduce(((t,n)=>{let o=e[n.keys.shift()??0];if(!o)return t;for(;!o.name;){const t=n.keys.shift();PI(!!t,'Not enough data in "keys" property of this event.'),o=o[t]}const a={};a[o.name]={};const s=n.keys[Symbol.iterator](),h=n.data[Symbol.iterator](),u=o.members?.filter((t=>"key"===t.kind))||o.keys,l=o.members?.filter((t=>"data"===t.kind))||o.data;return u.forEach((t=>{a[o.name][t.name]=CC(s,t,r,i,a[o.name])})),l.forEach((t=>{a[o.name][t.name]=CC(h,t,r,i,a[o.name])})),"block_hash"in n&&(a.block_hash=n.block_hash),"block_number"in n&&(a.block_number=n.block_number),"transaction_hash"in n&&(a.transaction_hash=n.transaction_hash),t.push(a),t}),[]);return n}function MR(t){if(!t.events?.length)throw new Error("UDC emitted event is empty");const e=t.events.find((t=>WI(t.from_address)===WI(tI.ADDRESS)))||{data:[]};return{transaction_hash:t.transaction_hash,contract_address:e.data[0],address:e.data[0],deployer:e.data[1],unique:e.data[2],classHash:e.data[3],calldata_len:e.data[4],calldata:e.data.slice(5,5+parseInt(e.data[4],16)),salt:e.data[e.data.length-1]}}nN({},{getAbiEvents:()=>vR,isAbiEvent:()=>yR,parseEvents:()=>kR,parseUDCEvent:()=>MR});function _R(t){const e=t.calldata??[],r=Array.isArray(e)?e:FC.compile(e);return{to:t.contractAddress,selector:cT(t.entrypoint),calldata:r}}function ER(t,e){const r=_R(t);return"1"===e?{...r,calldata_len:r.calldata.length,calldata:r.calldata}:{To:r.to,Selector:r.selector,Calldata:r.calldata}}function AR(t,e){return{name:"Account.execute_from_outside",version:e,chainId:t,..."2"===e?{revision:"1"}:{}}}function jR(t,e,r,i,n){return"1"===n?{types:CI,primaryType:"OutsideExecution",domain:AR(t,n),message:{...e,nonce:r,calls_len:i.length,calls:i.map((t=>ER(t,n)))}}:{types:zI,primaryType:"OutsideExecution",domain:AR(t,n),message:{Caller:e.caller,Nonce:r,"Execute After":e.execute_after,"Execute Before":e.execute_before,Calls:i.map((t=>ER(t,n)))}}}function xR(t){const e=t.outsideExecution,r=Tz(t.signature);return FC.compile({outside_execution:e,signature:r})}function SR(t){return(Array.isArray(t)?t:[t]).map((t=>{let e;if("1"===t.version)e="execute_from_outside";else{if("2"!==t.version)throw new Error("Unsupported OutsideExecution version");e="execute_from_outside_v2"}return{contractAddress:HI(t.signerAddress),entrypoint:e,calldata:xR(t)}}))}nN({},{buildExecuteFromOutsideCall:()=>SR,buildExecuteFromOutsideCallData:()=>xR,getOutsideCall:()=>_R,getTypedData:()=>jR});async function NR(t,e,r){const i={contractAddress:HI(e),entrypoint:"supports_interface",calldata:[HI(r)]};try{const e=await t.callContract(i);return 0n!==BigInt(e[0])}catch{return!1}}nN({},{supportsInterface:()=>NR});function IR(t,e=!1){return t.request({type:"wallet_requestAccounts",params:{silent_mode:e}})}function TR(t){return t.request({type:"wallet_getPermissions"})}function CR(t,e){return t.request({type:"wallet_watchAsset",params:e})}function zR(t,e){return t.request({type:"wallet_addStarknetChain",params:e})}function OR(t,e){return t.request({type:"wallet_switchStarknetChain",params:{chainId:e}})}function RR(t){return t.request({type:"wallet_requestChainId"})}function PR(t){return t.request({type:"wallet_deploymentData"})}function BR(t,e){return t.request({type:"wallet_addInvokeTransaction",params:e})}function DR(t,e){return t.request({type:"wallet_addDeclareTransaction",params:e})}function $R(t,e){return t.request({type:"wallet_signTypedData",params:e})}function LR(t){return t.request({type:"wallet_supportedSpecs"})}function FR(t,e){t.on("accountsChanged",e)}function UR(t,e){t.on("networkChanged",e)}nN({},{addDeclareTransaction:()=>DR,addInvokeTransaction:()=>BR,addStarknetChain:()=>zR,deploymentData:()=>PR,getPermissions:()=>TR,onAccountChange:()=>FR,onNetworkChanged:()=>UR,requestAccounts:()=>IR,requestChainId:()=>RR,signMessage:()=>$R,supportedSpecs:()=>LR,switchStarknetChain:()=>OR,watchAsset:()=>CR});var qR=t=>{const e=t[t.length-1];return"object"==typeof e&&["blockIdentifier","parseRequest","parseResponse","formatResponse","maxFee","nonce","signature","addressSalt"].some((t=>t in e))?{args:t,options:t.pop()}:{args:t}};function VR(t,e){return async function(...r){const i=qR(r);return t.call(e.name,i.args,{parseRequest:!0,parseResponse:!0,...i.options})}}function HR(t,e){return"view"===e.stateMutability||"view"===e.state_mutability?VR(t,e):function(t,e){return async function(...r){const i=qR(r);return t.invoke(e.name,i.args,{parseRequest:!0,...i.options})}}(t,e)}function GR(t,e){return function(...r){return t.estimate(e.name,r)}}function ZR(t,e){return Array.isArray(t)&&"__compiled__"in t?t:Array.isArray(t)&&Array.isArray(t[0])&&"__compiled__"in t[0]?t[0]:e()}var KR=class{abi;address;providerOrAccount;deployTransactionHash;structs;events;functions;callStatic;populateTransaction;estimateFee;callData;constructor(t,e,r=dR){this.address=e&&e.toLowerCase(),this.providerOrAccount=r,this.callData=new FC(t),this.structs=FC.getAbiStruct(t),this.events=vR(t);const i=MC(t);this.abi=i.getLegacyFormat();const n={enumerable:!0,value:{},writable:!1};Object.defineProperties(this,{functions:{enumerable:!0,value:{},writable:!1},callStatic:{enumerable:!0,value:{},writable:!1},populateTransaction:{enumerable:!0,value:{},writable:!1},estimateFee:{enumerable:!0,value:{},writable:!1}}),this.abi.forEach((t=>{if("function"!==t.type)return;const e=t.name;var r,i;this[e]||Object.defineProperty(this,e,{...n,value:HR(this,t)}),this.functions[e]||Object.defineProperty(this.functions,e,{...n,value:HR(this,t)}),this.callStatic[e]||Object.defineProperty(this.callStatic,e,{...n,value:VR(this,t)}),this.populateTransaction[e]||Object.defineProperty(this.populateTransaction,e,{...n,value:(r=this,i=t,function(...t){return r.populate(i.name,t)})}),this.estimateFee[e]||Object.defineProperty(this.estimateFee,e,{...n,value:GR(this,t)})}))}attach(t){this.address=t}connect(t){this.providerOrAccount=t}async deployed(){return this.deployTransactionHash&&(await this.providerOrAccount.waitForTransaction(this.deployTransactionHash),this.deployTransactionHash=void 0),this}async call(t,e=[],{parseRequest:r=!0,parseResponse:i=!0,formatResponse:n,blockIdentifier:o}={}){PI(null!==this.address,"contract is not connected to an address");const a=ZR(e,(()=>r?(this.callData.validate(xI.CALL,t,e),this.callData.compile(t,e)):(Kz.warn("Call skipped parsing but provided rawArgs, possible malfunction request"),e)));return this.providerOrAccount.callContract({contractAddress:this.address,calldata:a,entrypoint:t},o).then((e=>i?n?this.callData.format(t,e,n):this.callData.parse(t,e):e))}invoke(t,e=[],{parseRequest:r=!0,maxFee:i,nonce:n,signature:o}={}){PI(null!==this.address,"contract is not connected to an address");const a=ZR(e,(()=>r?(this.callData.validate(xI.INVOKE,t,e),this.callData.compile(t,e)):(Kz.warn("Invoke skipped parsing but provided rawArgs, possible malfunction request"),e))),s={contractAddress:this.address,calldata:a,entrypoint:t};if("execute"in this.providerOrAccount)return this.providerOrAccount.execute(s,void 0,{maxFee:i,nonce:n});if(!n)throw new Error("Nonce is required when invoking a function without an account");return Kz.warn(`Invoking ${t} without an account. This will not work on a public node.`),this.providerOrAccount.invokeFunction({...s,signature:o},{nonce:n})}async estimate(t,e=[]){PI(null!==this.address,"contract is not connected to an address"),ZR(e,(()=>!1))||this.callData.validate(xI.INVOKE,t,e);const r=this.populate(t,e);if("estimateInvokeFee"in this.providerOrAccount)return this.providerOrAccount.estimateInvokeFee(r);throw Error("Contract must be connected to the account contract to estimate")}populate(t,e=[]){const r=ZR(e,(()=>this.callData.compile(t,e)));return{contractAddress:this.address,entrypoint:t,calldata:r}}parseEvents(t){let e;return t.match({success:t=>{const r=t.events?.map((e=>({block_hash:t.block_hash,block_number:t.block_number,transaction_hash:t.transaction_hash,...e}))).filter((t=>WI(t.from_address)===WI(this.address)),[])||[];e=kR(r,this.events,this.structs,FC.getAbiEnum(this.abi))},_:()=>{throw Error("This transaction was not successful.")}}),e}isCairo1(){return jT.isCairo1Abi(this.abi)}async getVersion(){return this.providerOrAccount.getContractVersion(this.address)}typedv2(t){return this}};const JR={SN_MAIN:"https://starknet-mainnet.public.blastapi.io",SN_SEPOLIA:"https://starknet-sepolia.public.blastapi.io"},WR=[{name:"argent::common::account::IAccount",type:"interface",items:[{name:"is_valid_signature",type:"function",inputs:[{name:"hash",type:"core::felt252"},{name:"signature",type:"core::array::Array::<core::felt252>"}],outputs:[{type:"core::felt252"}],state_mutability:"view"}]}];function YR(t,e){var r;if(!JR[t])throw new Error("Invalid network");return new cR({nodeUrl:null!==(r=null==e?void 0:e.broviderUrl)&&void 0!==r?r:JR[t]})}function QR(t){return!!t.primaryType&&!!t.types.StarkNetDomain}function XR(t,e){const{domain:r,types:i,primaryType:n,message:o}=t;return bO.getMessageHash({types:i,primaryType:n,domain:r,message:o},e)}var tP=Object.freeze({__proto__:null,isStarknetMessage:QR,getHash:XR,default:function(t,e,i){return r(this,arguments,void 0,(function*(t,e,r,i="SN_MAIN",n={}){try{const o=new KR(WR,t,YR(i,n));if(e.length<2)throw new Error("Invalid signature format");const a=yield o.is_valid_signature(XR(r,t),e.slice(-2));return ch.from(a).eq(ch.from("370462705988"))}catch(t){if(t.message.includes("Contract not found"))throw new Error("Contract not deployed");throw t}}))}});function eP(t){return Jt(vi(t))}var rP=a((function(t){!function(t,e){function r(t,e){if(!t)throw new Error(e||"Assertion failed")}function i(t,e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}function n(t,e,r){if(n.isBN(t))return t;this.negative=0,this.words=null,this.length=0,this.red=null,null!==t&&("le"!==e&&"be"!==e||(r=e,e=10),this._init(t||0,e||10,r||"be"))}var o;"object"==typeof t?t.exports=n:e.BN=n,n.BN=n,n.wordSize=26;try{o="undefined"!=typeof window&&void 0!==window.Buffer?window.Buffer:Pt.Buffer}catch(t){}function a(t,e){var i=t.charCodeAt(e);return i>=48&&i<=57?i-48:i>=65&&i<=70?i-55:i>=97&&i<=102?i-87:void r(!1,"Invalid character in "+t)}function s(t,e,r){var i=a(t,r);return r-1>=e&&(i|=a(t,r-1)<<4),i}function h(t,e,i,n){for(var o=0,a=0,s=Math.min(t.length,i),h=e;h<s;h++){var u=t.charCodeAt(h)-48;o*=n,a=u>=49?u-49+10:u>=17?u-17+10:u,r(u>=0&&a<n,"Invalid character"),o+=a}return o}function u(t,e){t.words=e.words,t.length=e.length,t.negative=e.negative,t.red=e.red}if(n.isBN=function(t){return t instanceof n||null!==t&&"object"==typeof t&&t.constructor.wordSize===n.wordSize&&Array.isArray(t.words)},n.max=function(t,e){return t.cmp(e)>0?t:e},n.min=function(t,e){return t.cmp(e)<0?t:e},n.prototype._init=function(t,e,i){if("number"==typeof t)return this._initNumber(t,e,i);if("object"==typeof t)return this._initArray(t,e,i);"hex"===e&&(e=16),r(e===(0|e)&&e>=2&&e<=36);var n=0;"-"===(t=t.toString().replace(/\s+/g,""))[0]&&(n++,this.negative=1),n<t.length&&(16===e?this._parseHex(t,n,i):(this._parseBase(t,e,n),"le"===i&&this._initArray(this.toArray(),e,i)))},n.prototype._initNumber=function(t,e,i){t<0&&(this.negative=1,t=-t),t<67108864?(this.words=[67108863&t],this.length=1):t<4503599627370496?(this.words=[67108863&t,t/67108864&67108863],this.length=2):(r(t<9007199254740992),this.words=[67108863&t,t/67108864&67108863,1],this.length=3),"le"===i&&this._initArray(this.toArray(),e,i)},n.prototype._initArray=function(t,e,i){if(r("number"==typeof t.length),t.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(t.length/3),this.words=new Array(this.length);for(var n=0;n<this.length;n++)this.words[n]=0;var o,a,s=0;if("be"===i)for(n=t.length-1,o=0;n>=0;n-=3)a=t[n]|t[n-1]<<8|t[n-2]<<16,this.words[o]|=a<<s&67108863,this.words[o+1]=a>>>26-s&67108863,(s+=24)>=26&&(s-=26,o++);else if("le"===i)for(n=0,o=0;n<t.length;n+=3)a=t[n]|t[n+1]<<8|t[n+2]<<16,this.words[o]|=a<<s&67108863,this.words[o+1]=a>>>26-s&67108863,(s+=24)>=26&&(s-=26,o++);return this._strip()},n.prototype._parseHex=function(t,e,r){this.length=Math.ceil((t.length-e)/6),this.words=new Array(this.length);for(var i=0;i<this.length;i++)this.words[i]=0;var n,o=0,a=0;if("be"===r)for(i=t.length-1;i>=e;i-=2)n=s(t,e,i)<<o,this.words[a]|=67108863&n,o>=18?(o-=18,a+=1,this.words[a]|=n>>>26):o+=8;else for(i=(t.length-e)%2==0?e+1:e;i<t.length;i+=2)n=s(t,e,i)<<o,this.words[a]|=67108863&n,o>=18?(o-=18,a+=1,this.words[a]|=n>>>26):o+=8;this._strip()},n.prototype._parseBase=function(t,e,r){this.words=[0],this.length=1;for(var i=0,n=1;n<=67108863;n*=e)i++;i--,n=n/e|0;for(var o=t.length-r,a=o%i,s=Math.min(o,o-a)+r,u=0,l=r;l<s;l+=i)u=h(t,l,l+i,e),this.imuln(n),this.words[0]+u<67108864?this.words[0]+=u:this._iaddn(u);if(0!==a){var c=1;for(u=h(t,l,t.length,e),l=0;l<a;l++)c*=e;this.imuln(c),this.words[0]+u<67108864?this.words[0]+=u:this._iaddn(u)}this._strip()},n.prototype.copy=function(t){t.words=new Array(this.length);for(var e=0;e<this.length;e++)t.words[e]=this.words[e];t.length=this.length,t.negative=this.negative,t.red=this.red},n.prototype._move=function(t){u(t,this)},n.prototype.clone=function(){var t=new n(null);return this.copy(t),t},n.prototype._expand=function(t){for(;this.length<t;)this.words[this.length++]=0;return this},n.prototype._strip=function(){for(;this.length>1&&0===this.words[this.length-1];)this.length--;return this._normSign()},n.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},"undefined"!=typeof Symbol&&"function"==typeof Symbol.for)try{n.prototype[Symbol.for("nodejs.util.inspect.custom")]=l}catch(t){n.prototype.inspect=l}else n.prototype.inspect=l;function l(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"}var c=["","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"],d=[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],f=[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];n.prototype.toString=function(t,e){var i;if(e=0|e||1,16===(t=t||10)||"hex"===t){i="";for(var n=0,o=0,a=0;a<this.length;a++){var s=this.words[a],h=(16777215&(s<<n|o)).toString(16);o=s>>>24-n&16777215,(n+=2)>=26&&(n-=26,a--),i=0!==o||a!==this.length-1?c[6-h.length]+h+i:h+i}for(0!==o&&(i=o.toString(16)+i);i.length%e!=0;)i="0"+i;return 0!==this.negative&&(i="-"+i),i}if(t===(0|t)&&t>=2&&t<=36){var u=d[t],l=f[t];i="";var m=this.clone();for(m.negative=0;!m.isZero();){var p=m.modrn(l).toString(t);i=(m=m.idivn(l)).isZero()?p+i:c[u-p.length]+p+i}for(this.isZero()&&(i="0"+i);i.length%e!=0;)i="0"+i;return 0!==this.negative&&(i="-"+i),i}r(!1,"Base should be between 2 and 36")},n.prototype.toNumber=function(){var t=this.words[0];return 2===this.length?t+=67108864*this.words[1]:3===this.length&&1===this.words[2]?t+=4503599627370496+67108864*this.words[1]:this.length>2&&r(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-t:t},n.prototype.toJSON=function(){return this.toString(16,2)},o&&(n.prototype.toBuffer=function(t,e){return this.toArrayLike(o,t,e)}),n.prototype.toArray=function(t,e){return this.toArrayLike(Array,t,e)};function m(t,e,r){r.negative=e.negative^t.negative;var i=t.length+e.length|0;r.length=i,i=i-1|0;var n=0|t.words[0],o=0|e.words[0],a=n*o,s=67108863&a,h=a/67108864|0;r.words[0]=s;for(var u=1;u<i;u++){for(var l=h>>>26,c=67108863&h,d=Math.min(u,e.length-1),f=Math.max(0,u-t.length+1);f<=d;f++){var m=u-f|0;l+=(a=(n=0|t.words[m])*(o=0|e.words[f])+c)/67108864|0,c=67108863&a}r.words[u]=0|c,h=0|l}return 0!==h?r.words[u]=0|h:r.length--,r._strip()}n.prototype.toArrayLike=function(t,e,i){this._strip();var n=this.byteLength(),o=i||Math.max(1,n);r(n<=o,"byte array longer than desired length"),r(o>0,"Requested array length <= 0");var a=function(t,e){return t.allocUnsafe?t.allocUnsafe(e):new t(e)}(t,o);return this["_toArrayLike"+("le"===e?"LE":"BE")](a,n),a},n.prototype._toArrayLikeLE=function(t,e){for(var r=0,i=0,n=0,o=0;n<this.length;n++){var a=this.words[n]<<o|i;t[r++]=255&a,r<t.length&&(t[r++]=a>>8&255),r<t.length&&(t[r++]=a>>16&255),6===o?(r<t.length&&(t[r++]=a>>24&255),i=0,o=0):(i=a>>>24,o+=2)}if(r<t.length)for(t[r++]=i;r<t.length;)t[r++]=0},n.prototype._toArrayLikeBE=function(t,e){for(var r=t.length-1,i=0,n=0,o=0;n<this.length;n++){var a=this.words[n]<<o|i;t[r--]=255&a,r>=0&&(t[r--]=a>>8&255),r>=0&&(t[r--]=a>>16&255),6===o?(r>=0&&(t[r--]=a>>24&255),i=0,o=0):(i=a>>>24,o+=2)}if(r>=0)for(t[r--]=i;r>=0;)t[r--]=0},Math.clz32?n.prototype._countBits=function(t){return 32-Math.clz32(t)}:n.prototype._countBits=function(t){var e=t,r=0;return e>=4096&&(r+=13,e>>>=13),e>=64&&(r+=7,e>>>=7),e>=8&&(r+=4,e>>>=4),e>=2&&(r+=2,e>>>=2),r+e},n.prototype._zeroBits=function(t){if(0===t)return 26;var e=t,r=0;return 0==(8191&e)&&(r+=13,e>>>=13),0==(127&e)&&(r+=7,e>>>=7),0==(15&e)&&(r+=4,e>>>=4),0==(3&e)&&(r+=2,e>>>=2),0==(1&e)&&r++,r},n.prototype.bitLength=function(){var t=this.words[this.length-1],e=this._countBits(t);return 26*(this.length-1)+e},n.prototype.zeroBits=function(){if(this.isZero())return 0;for(var t=0,e=0;e<this.length;e++){var r=this._zeroBits(this.words[e]);if(t+=r,26!==r)break}return t},n.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},n.prototype.toTwos=function(t){return 0!==this.negative?this.abs().inotn(t).iaddn(1):this.clone()},n.prototype.fromTwos=function(t){return this.testn(t-1)?this.notn(t).iaddn(1).ineg():this.clone()},n.prototype.isNeg=function(){return 0!==this.negative},n.prototype.neg=function(){return this.clone().ineg()},n.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},n.prototype.iuor=function(t){for(;this.length<t.length;)this.words[this.length++]=0;for(var e=0;e<t.length;e++)this.words[e]=this.words[e]|t.words[e];return this._strip()},n.prototype.ior=function(t){return r(0==(this.negative|t.negative)),this.iuor(t)},n.prototype.or=function(t){return this.length>t.length?this.clone().ior(t):t.clone().ior(this)},n.prototype.uor=function(t){return this.length>t.length?this.clone().iuor(t):t.clone().iuor(this)},n.prototype.iuand=function(t){var e;e=this.length>t.length?t:this;for(var r=0;r<e.length;r++)this.words[r]=this.words[r]&t.words[r];return this.length=e.length,this._strip()},n.prototype.iand=function(t){return r(0==(this.negative|t.negative)),this.iuand(t)},n.prototype.and=function(t){return this.length>t.length?this.clone().iand(t):t.clone().iand(this)},n.prototype.uand=function(t){return this.length>t.length?this.clone().iuand(t):t.clone().iuand(this)},n.prototype.iuxor=function(t){var e,r;this.length>t.length?(e=this,r=t):(e=t,r=this);for(var i=0;i<r.length;i++)this.words[i]=e.words[i]^r.words[i];if(this!==e)for(;i<e.length;i++)this.words[i]=e.words[i];return this.length=e.length,this._strip()},n.prototype.ixor=function(t){return r(0==(this.negative|t.negative)),this.iuxor(t)},n.prototype.xor=function(t){return this.length>t.length?this.clone().ixor(t):t.clone().ixor(this)},n.prototype.uxor=function(t){return this.length>t.length?this.clone().iuxor(t):t.clone().iuxor(this)},n.prototype.inotn=function(t){r("number"==typeof t&&t>=0);var e=0|Math.ceil(t/26),i=t%26;this._expand(e),i>0&&e--;for(var n=0;n<e;n++)this.words[n]=67108863&~this.words[n];return i>0&&(this.words[n]=~this.words[n]&67108863>>26-i),this._strip()},n.prototype.notn=function(t){return this.clone().inotn(t)},n.prototype.setn=function(t,e){r("number"==typeof t&&t>=0);var i=t/26|0,n=t%26;return this._expand(i+1),this.words[i]=e?this.words[i]|1<<n:this.words[i]&~(1<<n),this._strip()},n.prototype.iadd=function(t){var e,r,i;if(0!==this.negative&&0===t.negative)return this.negative=0,e=this.isub(t),this.negative^=1,this._normSign();if(0===this.negative&&0!==t.negative)return t.negative=0,e=this.isub(t),t.negative=1,e._normSign();this.length>t.length?(r=this,i=t):(r=t,i=this);for(var n=0,o=0;o<i.length;o++)e=(0|r.words[o])+(0|i.words[o])+n,this.words[o]=67108863&e,n=e>>>26;for(;0!==n&&o<r.length;o++)e=(0|r.words[o])+n,this.words[o]=67108863&e,n=e>>>26;if(this.length=r.length,0!==n)this.words[this.length]=n,this.length++;else if(r!==this)for(;o<r.length;o++)this.words[o]=r.words[o];return this},n.prototype.add=function(t){var e;return 0!==t.negative&&0===this.negative?(t.negative=0,e=this.sub(t),t.negative^=1,e):0===t.negative&&0!==this.negative?(this.negative=0,e=t.sub(this),this.negative=1,e):this.length>t.length?this.clone().iadd(t):t.clone().iadd(this)},n.prototype.isub=function(t){if(0!==t.negative){t.negative=0;var e=this.iadd(t);return t.negative=1,e._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(t),this.negative=1,this._normSign();var r,i,n=this.cmp(t);if(0===n)return this.negative=0,this.length=1,this.words[0]=0,this;n>0?(r=this,i=t):(r=t,i=this);for(var o=0,a=0;a<i.length;a++)o=(e=(0|r.words[a])-(0|i.words[a])+o)>>26,this.words[a]=67108863&e;for(;0!==o&&a<r.length;a++)o=(e=(0|r.words[a])+o)>>26,this.words[a]=67108863&e;if(0===o&&a<r.length&&r!==this)for(;a<r.length;a++)this.words[a]=r.words[a];return this.length=Math.max(this.length,a),r!==this&&(this.negative=1),this._strip()},n.prototype.sub=function(t){return this.clone().isub(t)};var p=function(t,e,r){var i,n,o,a=t.words,s=e.words,h=r.words,u=0,l=0|a[0],c=8191&l,d=l>>>13,f=0|a[1],m=8191&f,p=f>>>13,g=0|a[2],y=8191&g,w=g>>>13,v=0|a[3],b=8191&v,k=v>>>13,M=0|a[4],_=8191&M,E=M>>>13,A=0|a[5],j=8191&A,x=A>>>13,S=0|a[6],N=8191&S,I=S>>>13,T=0|a[7],C=8191&T,z=T>>>13,O=0|a[8],R=8191&O,P=O>>>13,B=0|a[9],D=8191&B,$=B>>>13,L=0|s[0],F=8191&L,U=L>>>13,q=0|s[1],V=8191&q,H=q>>>13,G=0|s[2],Z=8191&G,K=G>>>13,J=0|s[3],W=8191&J,Y=J>>>13,Q=0|s[4],X=8191&Q,tt=Q>>>13,et=0|s[5],rt=8191&et,it=et>>>13,nt=0|s[6],ot=8191&nt,at=nt>>>13,st=0|s[7],ht=8191&st,ut=st>>>13,lt=0|s[8],ct=8191&lt,dt=lt>>>13,ft=0|s[9],mt=8191&ft,pt=ft>>>13;r.negative=t.negative^e.negative,r.length=19;var gt=(u+(i=Math.imul(c,F))|0)+((8191&(n=(n=Math.imul(c,U))+Math.imul(d,F)|0))<<13)|0;u=((o=Math.imul(d,U))+(n>>>13)|0)+(gt>>>26)|0,gt&=67108863,i=Math.imul(m,F),n=(n=Math.imul(m,U))+Math.imul(p,F)|0,o=Math.imul(p,U);var yt=(u+(i=i+Math.imul(c,V)|0)|0)+((8191&(n=(n=n+Math.imul(c,H)|0)+Math.imul(d,V)|0))<<13)|0;u=((o=o+Math.imul(d,H)|0)+(n>>>13)|0)+(yt>>>26)|0,yt&=67108863,i=Math.imul(y,F),n=(n=Math.imul(y,U))+Math.imul(w,F)|0,o=Math.imul(w,U),i=i+Math.imul(m,V)|0,n=(n=n+Math.imul(m,H)|0)+Math.imul(p,V)|0,o=o+Math.imul(p,H)|0;var wt=(u+(i=i+Math.imul(c,Z)|0)|0)+((8191&(n=(n=n+Math.imul(c,K)|0)+Math.imul(d,Z)|0))<<13)|0;u=((o=o+Math.imul(d,K)|0)+(n>>>13)|0)+(wt>>>26)|0,wt&=67108863,i=Math.imul(b,F),n=(n=Math.imul(b,U))+Math.imul(k,F)|0,o=Math.imul(k,U),i=i+Math.imul(y,V)|0,n=(n=n+Math.imul(y,H)|0)+Math.imul(w,V)|0,o=o+Math.imul(w,H)|0,i=i+Math.imul(m,Z)|0,n=(n=n+Math.imul(m,K)|0)+Math.imul(p,Z)|0,o=o+Math.imul(p,K)|0;var vt=(u+(i=i+Math.imul(c,W)|0)|0)+((8191&(n=(n=n+Math.imul(c,Y)|0)+Math.imul(d,W)|0))<<13)|0;u=((o=o+Math.imul(d,Y)|0)+(n>>>13)|0)+(vt>>>26)|0,vt&=67108863,i=Math.imul(_,F),n=(n=Math.imul(_,U))+Math.imul(E,F)|0,o=Math.imul(E,U),i=i+Math.imul(b,V)|0,n=(n=n+Math.imul(b,H)|0)+Math.imul(k,V)|0,o=o+Math.imul(k,H)|0,i=i+Math.imul(y,Z)|0,n=(n=n+Math.imul(y,K)|0)+Math.imul(w,Z)|0,o=o+Math.imul(w,K)|0,i=i+Math.imul(m,W)|0,n=(n=n+Math.imul(m,Y)|0)+Math.imul(p,W)|0,o=o+Math.imul(p,Y)|0;var bt=(u+(i=i+Math.imul(c,X)|0)|0)+((8191&(n=(n=n+Math.imul(c,tt)|0)+Math.imul(d,X)|0))<<13)|0;u=((o=o+Math.imul(d,tt)|0)+(n>>>13)|0)+(bt>>>26)|0,bt&=67108863,i=Math.imul(j,F),n=(n=Math.imul(j,U))+Math.imul(x,F)|0,o=Math.imul(x,U),i=i+Math.imul(_,V)|0,n=(n=n+Math.imul(_,H)|0)+Math.imul(E,V)|0,o=o+Math.imul(E,H)|0,i=i+Math.imul(b,Z)|0,n=(n=n+Math.imul(b,K)|0)+Math.imul(k,Z)|0,o=o+Math.imul(k,K)|0,i=i+Math.imul(y,W)|0,n=(n=n+Math.imul(y,Y)|0)+Math.imul(w,W)|0,o=o+Math.imul(w,Y)|0,i=i+Math.imul(m,X)|0,n=(n=n+Math.imul(m,tt)|0)+Math.imul(p,X)|0,o=o+Math.imul(p,tt)|0;var kt=(u+(i=i+Math.imul(c,rt)|0)|0)+((8191&(n=(n=n+Math.imul(c,it)|0)+Math.imul(d,rt)|0))<<13)|0;u=((o=o+Math.imul(d,it)|0)+(n>>>13)|0)+(kt>>>26)|0,kt&=67108863,i=Math.imul(N,F),n=(n=Math.imul(N,U))+Math.imul(I,F)|0,o=Math.imul(I,U),i=i+Math.imul(j,V)|0,n=(n=n+Math.imul(j,H)|0)+Math.imul(x,V)|0,o=o+Math.imul(x,H)|0,i=i+Math.imul(_,Z)|0,n=(n=n+Math.imul(_,K)|0)+Math.imul(E,Z)|0,o=o+Math.imul(E,K)|0,i=i+Math.imul(b,W)|0,n=(n=n+Math.imul(b,Y)|0)+Math.imul(k,W)|0,o=o+Math.imul(k,Y)|0,i=i+Math.imul(y,X)|0,n=(n=n+Math.imul(y,tt)|0)+Math.imul(w,X)|0,o=o+Math.imul(w,tt)|0,i=i+Math.imul(m,rt)|0,n=(n=n+Math.imul(m,it)|0)+Math.imul(p,rt)|0,o=o+Math.imul(p,it)|0;var Mt=(u+(i=i+Math.imul(c,ot)|0)|0)+((8191&(n=(n=n+Math.imul(c,at)|0)+Math.imul(d,ot)|0))<<13)|0;u=((o=o+Math.imul(d,at)|0)+(n>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,i=Math.imul(C,F),n=(n=Math.imul(C,U))+Math.imul(z,F)|0,o=Math.imul(z,U),i=i+Math.imul(N,V)|0,n=(n=n+Math.imul(N,H)|0)+Math.imul(I,V)|0,o=o+Math.imul(I,H)|0,i=i+Math.imul(j,Z)|0,n=(n=n+Math.imul(j,K)|0)+Math.imul(x,Z)|0,o=o+Math.imul(x,K)|0,i=i+Math.imul(_,W)|0,n=(n=n+Math.imul(_,Y)|0)+Math.imul(E,W)|0,o=o+Math.imul(E,Y)|0,i=i+Math.imul(b,X)|0,n=(n=n+Math.imul(b,tt)|0)+Math.imul(k,X)|0,o=o+Math.imul(k,tt)|0,i=i+Math.imul(y,rt)|0,n=(n=n+Math.imul(y,it)|0)+Math.imul(w,rt)|0,o=o+Math.imul(w,it)|0,i=i+Math.imul(m,ot)|0,n=(n=n+Math.imul(m,at)|0)+Math.imul(p,ot)|0,o=o+Math.imul(p,at)|0;var _t=(u+(i=i+Math.imul(c,ht)|0)|0)+((8191&(n=(n=n+Math.imul(c,ut)|0)+Math.imul(d,ht)|0))<<13)|0;u=((o=o+Math.imul(d,ut)|0)+(n>>>13)|0)+(_t>>>26)|0,_t&=67108863,i=Math.imul(R,F),n=(n=Math.imul(R,U))+Math.imul(P,F)|0,o=Math.imul(P,U),i=i+Math.imul(C,V)|0,n=(n=n+Math.imul(C,H)|0)+Math.imul(z,V)|0,o=o+Math.imul(z,H)|0,i=i+Math.imul(N,Z)|0,n=(n=n+Math.imul(N,K)|0)+Math.imul(I,Z)|0,o=o+Math.imul(I,K)|0,i=i+Math.imul(j,W)|0,n=(n=n+Math.imul(j,Y)|0)+Math.imul(x,W)|0,o=o+Math.imul(x,Y)|0,i=i+Math.imul(_,X)|0,n=(n=n+Math.imul(_,tt)|0)+Math.imul(E,X)|0,o=o+Math.imul(E,tt)|0,i=i+Math.imul(b,rt)|0,n=(n=n+Math.imul(b,it)|0)+Math.imul(k,rt)|0,o=o+Math.imul(k,it)|0,i=i+Math.imul(y,ot)|0,n=(n=n+Math.imul(y,at)|0)+Math.imul(w,ot)|0,o=o+Math.imul(w,at)|0,i=i+Math.imul(m,ht)|0,n=(n=n+Math.imul(m,ut)|0)+Math.imul(p,ht)|0,o=o+Math.imul(p,ut)|0;var Et=(u+(i=i+Math.imul(c,ct)|0)|0)+((8191&(n=(n=n+Math.imul(c,dt)|0)+Math.imul(d,ct)|0))<<13)|0;u=((o=o+Math.imul(d,dt)|0)+(n>>>13)|0)+(Et>>>26)|0,Et&=67108863,i=Math.imul(D,F),n=(n=Math.imul(D,U))+Math.imul($,F)|0,o=Math.imul($,U),i=i+Math.imul(R,V)|0,n=(n=n+Math.imul(R,H)|0)+Math.imul(P,V)|0,o=o+Math.imul(P,H)|0,i=i+Math.imul(C,Z)|0,n=(n=n+Math.imul(C,K)|0)+Math.imul(z,Z)|0,o=o+Math.imul(z,K)|0,i=i+Math.imul(N,W)|0,n=(n=n+Math.imul(N,Y)|0)+Math.imul(I,W)|0,o=o+Math.imul(I,Y)|0,i=i+Math.imul(j,X)|0,n=(n=n+Math.imul(j,tt)|0)+Math.imul(x,X)|0,o=o+Math.imul(x,tt)|0,i=i+Math.imul(_,rt)|0,n=(n=n+Math.imul(_,it)|0)+Math.imul(E,rt)|0,o=o+Math.imul(E,it)|0,i=i+Math.imul(b,ot)|0,n=(n=n+Math.imul(b,at)|0)+Math.imul(k,ot)|0,o=o+Math.imul(k,at)|0,i=i+Math.imul(y,ht)|0,n=(n=n+Math.imul(y,ut)|0)+Math.imul(w,ht)|0,o=o+Math.imul(w,ut)|0,i=i+Math.imul(m,ct)|0,n=(n=n+Math.imul(m,dt)|0)+Math.imul(p,ct)|0,o=o+Math.imul(p,dt)|0;var At=(u+(i=i+Math.imul(c,mt)|0)|0)+((8191&(n=(n=n+Math.imul(c,pt)|0)+Math.imul(d,mt)|0))<<13)|0;u=((o=o+Math.imul(d,pt)|0)+(n>>>13)|0)+(At>>>26)|0,At&=67108863,i=Math.imul(D,V),n=(n=Math.imul(D,H))+Math.imul($,V)|0,o=Math.imul($,H),i=i+Math.imul(R,Z)|0,n=(n=n+Math.imul(R,K)|0)+Math.imul(P,Z)|0,o=o+Math.imul(P,K)|0,i=i+Math.imul(C,W)|0,n=(n=n+Math.imul(C,Y)|0)+Math.imul(z,W)|0,o=o+Math.imul(z,Y)|0,i=i+Math.imul(N,X)|0,n=(n=n+Math.imul(N,tt)|0)+Math.imul(I,X)|0,o=o+Math.imul(I,tt)|0,i=i+Math.imul(j,rt)|0,n=(n=n+Math.imul(j,it)|0)+Math.imul(x,rt)|0,o=o+Math.imul(x,it)|0,i=i+Math.imul(_,ot)|0,n=(n=n+Math.imul(_,at)|0)+Math.imul(E,ot)|0,o=o+Math.imul(E,at)|0,i=i+Math.imul(b,ht)|0,n=(n=n+Math.imul(b,ut)|0)+Math.imul(k,ht)|0,o=o+Math.imul(k,ut)|0,i=i+Math.imul(y,ct)|0,n=(n=n+Math.imul(y,dt)|0)+Math.imul(w,ct)|0,o=o+Math.imul(w,dt)|0;var jt=(u+(i=i+Math.imul(m,mt)|0)|0)+((8191&(n=(n=n+Math.imul(m,pt)|0)+Math.imul(p,mt)|0))<<13)|0;u=((o=o+Math.imul(p,pt)|0)+(n>>>13)|0)+(jt>>>26)|0,jt&=67108863,i=Math.imul(D,Z),n=(n=Math.imul(D,K))+Math.imul($,Z)|0,o=Math.imul($,K),i=i+Math.imul(R,W)|0,n=(n=n+Math.imul(R,Y)|0)+Math.imul(P,W)|0,o=o+Math.imul(P,Y)|0,i=i+Math.imul(C,X)|0,n=(n=n+Math.imul(C,tt)|0)+Math.imul(z,X)|0,o=o+Math.imul(z,tt)|0,i=i+Math.imul(N,rt)|0,n=(n=n+Math.imul(N,it)|0)+Math.imul(I,rt)|0,o=o+Math.imul(I,it)|0,i=i+Math.imul(j,ot)|0,n=(n=n+Math.imul(j,at)|0)+Math.imul(x,ot)|0,o=o+Math.imul(x,at)|0,i=i+Math.imul(_,ht)|0,n=(n=n+Math.imul(_,ut)|0)+Math.imul(E,ht)|0,o=o+Math.imul(E,ut)|0,i=i+Math.imul(b,ct)|0,n=(n=n+Math.imul(b,dt)|0)+Math.imul(k,ct)|0,o=o+Math.imul(k,dt)|0;var xt=(u+(i=i+Math.imul(y,mt)|0)|0)+((8191&(n=(n=n+Math.imul(y,pt)|0)+Math.imul(w,mt)|0))<<13)|0;u=((o=o+Math.imul(w,pt)|0)+(n>>>13)|0)+(xt>>>26)|0,xt&=67108863,i=Math.imul(D,W),n=(n=Math.imul(D,Y))+Math.imul($,W)|0,o=Math.imul($,Y),i=i+Math.imul(R,X)|0,n=(n=n+Math.imul(R,tt)|0)+Math.imul(P,X)|0,o=o+Math.imul(P,tt)|0,i=i+Math.imul(C,rt)|0,n=(n=n+Math.imul(C,it)|0)+Math.imul(z,rt)|0,o=o+Math.imul(z,it)|0,i=i+Math.imul(N,ot)|0,n=(n=n+Math.imul(N,at)|0)+Math.imul(I,ot)|0,o=o+Math.imul(I,at)|0,i=i+Math.imul(j,ht)|0,n=(n=n+Math.imul(j,ut)|0)+Math.imul(x,ht)|0,o=o+Math.imul(x,ut)|0,i=i+Math.imul(_,ct)|0,n=(n=n+Math.imul(_,dt)|0)+Math.imul(E,ct)|0,o=o+Math.imul(E,dt)|0;var St=(u+(i=i+Math.imul(b,mt)|0)|0)+((8191&(n=(n=n+Math.imul(b,pt)|0)+Math.imul(k,mt)|0))<<13)|0;u=((o=o+Math.imul(k,pt)|0)+(n>>>13)|0)+(St>>>26)|0,St&=67108863,i=Math.imul(D,X),n=(n=Math.imul(D,tt))+Math.imul($,X)|0,o=Math.imul($,tt),i=i+Math.imul(R,rt)|0,n=(n=n+Math.imul(R,it)|0)+Math.imul(P,rt)|0,o=o+Math.imul(P,it)|0,i=i+Math.imul(C,ot)|0,n=(n=n+Math.imul(C,at)|0)+Math.imul(z,ot)|0,o=o+Math.imul(z,at)|0,i=i+Math.imul(N,ht)|0,n=(n=n+Math.imul(N,ut)|0)+Math.imul(I,ht)|0,o=o+Math.imul(I,ut)|0,i=i+Math.imul(j,ct)|0,n=(n=n+Math.imul(j,dt)|0)+Math.imul(x,ct)|0,o=o+Math.imul(x,dt)|0;var Nt=(u+(i=i+Math.imul(_,mt)|0)|0)+((8191&(n=(n=n+Math.imul(_,pt)|0)+Math.imul(E,mt)|0))<<13)|0;u=((o=o+Math.imul(E,pt)|0)+(n>>>13)|0)+(Nt>>>26)|0,Nt&=67108863,i=Math.imul(D,rt),n=(n=Math.imul(D,it))+Math.imul($,rt)|0,o=Math.imul($,it),i=i+Math.imul(R,ot)|0,n=(n=n+Math.imul(R,at)|0)+Math.imul(P,ot)|0,o=o+Math.imul(P,at)|0,i=i+Math.imul(C,ht)|0,n=(n=n+Math.imul(C,ut)|0)+Math.imul(z,ht)|0,o=o+Math.imul(z,ut)|0,i=i+Math.imul(N,ct)|0,n=(n=n+Math.imul(N,dt)|0)+Math.imul(I,ct)|0,o=o+Math.imul(I,dt)|0;var It=(u+(i=i+Math.imul(j,mt)|0)|0)+((8191&(n=(n=n+Math.imul(j,pt)|0)+Math.imul(x,mt)|0))<<13)|0;u=((o=o+Math.imul(x,pt)|0)+(n>>>13)|0)+(It>>>26)|0,It&=67108863,i=Math.imul(D,ot),n=(n=Math.imul(D,at))+Math.imul($,ot)|0,o=Math.imul($,at),i=i+Math.imul(R,ht)|0,n=(n=n+Math.imul(R,ut)|0)+Math.imul(P,ht)|0,o=o+Math.imul(P,ut)|0,i=i+Math.imul(C,ct)|0,n=(n=n+Math.imul(C,dt)|0)+Math.imul(z,ct)|0,o=o+Math.imul(z,dt)|0;var Tt=(u+(i=i+Math.imul(N,mt)|0)|0)+((8191&(n=(n=n+Math.imul(N,pt)|0)+Math.imul(I,mt)|0))<<13)|0;u=((o=o+Math.imul(I,pt)|0)+(n>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,i=Math.imul(D,ht),n=(n=Math.imul(D,ut))+Math.imul($,ht)|0,o=Math.imul($,ut),i=i+Math.imul(R,ct)|0,n=(n=n+Math.imul(R,dt)|0)+Math.imul(P,ct)|0,o=o+Math.imul(P,dt)|0;var Ct=(u+(i=i+Math.imul(C,mt)|0)|0)+((8191&(n=(n=n+Math.imul(C,pt)|0)+Math.imul(z,mt)|0))<<13)|0;u=((o=o+Math.imul(z,pt)|0)+(n>>>13)|0)+(Ct>>>26)|0,Ct&=67108863,i=Math.imul(D,ct),n=(n=Math.imul(D,dt))+Math.imul($,ct)|0,o=Math.imul($,dt);var zt=(u+(i=i+Math.imul(R,mt)|0)|0)+((8191&(n=(n=n+Math.imul(R,pt)|0)+Math.imul(P,mt)|0))<<13)|0;u=((o=o+Math.imul(P,pt)|0)+(n>>>13)|0)+(zt>>>26)|0,zt&=67108863;var Ot=(u+(i=Math.imul(D,mt))|0)+((8191&(n=(n=Math.imul(D,pt))+Math.imul($,mt)|0))<<13)|0;return u=((o=Math.imul($,pt))+(n>>>13)|0)+(Ot>>>26)|0,Ot&=67108863,h[0]=gt,h[1]=yt,h[2]=wt,h[3]=vt,h[4]=bt,h[5]=kt,h[6]=Mt,h[7]=_t,h[8]=Et,h[9]=At,h[10]=jt,h[11]=xt,h[12]=St,h[13]=Nt,h[14]=It,h[15]=Tt,h[16]=Ct,h[17]=zt,h[18]=Ot,0!==u&&(h[19]=u,r.length++),r};function g(t,e,r){r.negative=e.negative^t.negative,r.length=t.length+e.length;for(var i=0,n=0,o=0;o<r.length-1;o++){var a=n;n=0;for(var s=67108863&i,h=Math.min(o,e.length-1),u=Math.max(0,o-t.length+1);u<=h;u++){var l=o-u,c=(0|t.words[l])*(0|e.words[u]),d=67108863&c;s=67108863&(d=d+s|0),n+=(a=(a=a+(c/67108864|0)|0)+(d>>>26)|0)>>>26,a&=67108863}r.words[o]=s,i=a,a=n}return 0!==i?r.words[o]=i:r.length--,r._strip()}function y(t,e,r){return g(t,e,r)}Math.imul||(p=m),n.prototype.mulTo=function(t,e){var r=this.length+t.length;return 10===this.length&&10===t.length?p(this,t,e):r<63?m(this,t,e):r<1024?g(this,t,e):y(this,t,e)},n.prototype.mul=function(t){var e=new n(null);return e.words=new Array(this.length+t.length),this.mulTo(t,e)},n.prototype.mulf=function(t){var e=new n(null);return e.words=new Array(this.length+t.length),y(this,t,e)},n.prototype.imul=function(t){return this.clone().mulTo(t,this)},n.prototype.imuln=function(t){var e=t<0;e&&(t=-t),r("number"==typeof t),r(t<67108864);for(var i=0,n=0;n<this.length;n++){var o=(0|this.words[n])*t,a=(67108863&o)+(67108863&i);i>>=26,i+=o/67108864|0,i+=a>>>26,this.words[n]=67108863&a}return 0!==i&&(this.words[n]=i,this.length++),e?this.ineg():this},n.prototype.muln=function(t){return this.clone().imuln(t)},n.prototype.sqr=function(){return this.mul(this)},n.prototype.isqr=function(){return this.imul(this.clone())},n.prototype.pow=function(t){var e=function(t){for(var e=new Array(t.bitLength()),r=0;r<e.length;r++){var i=r/26|0,n=r%26;e[r]=t.words[i]>>>n&1}return e}(t);if(0===e.length)return new n(1);for(var r=this,i=0;i<e.length&&0===e[i];i++,r=r.sqr());if(++i<e.length)for(var o=r.sqr();i<e.length;i++,o=o.sqr())0!==e[i]&&(r=r.mul(o));return r},n.prototype.iushln=function(t){r("number"==typeof t&&t>=0);var e,i=t%26,n=(t-i)/26,o=67108863>>>26-i<<26-i;if(0!==i){var a=0;for(e=0;e<this.length;e++){var s=this.words[e]&o,h=(0|this.words[e])-s<<i;this.words[e]=h|a,a=s>>>26-i}a&&(this.words[e]=a,this.length++)}if(0!==n){for(e=this.length-1;e>=0;e--)this.words[e+n]=this.words[e];for(e=0;e<n;e++)this.words[e]=0;this.length+=n}return this._strip()},n.prototype.ishln=function(t){return r(0===this.negative),this.iushln(t)},n.prototype.iushrn=function(t,e,i){var n;r("number"==typeof t&&t>=0),n=e?(e-e%26)/26:0;var o=t%26,a=Math.min((t-o)/26,this.length),s=67108863^67108863>>>o<<o,h=i;if(n-=a,n=Math.max(0,n),h){for(var u=0;u<a;u++)h.words[u]=this.words[u];h.length=a}if(0===a);else if(this.length>a)for(this.length-=a,u=0;u<this.length;u++)this.words[u]=this.words[u+a];else this.words[0]=0,this.length=1;var l=0;for(u=this.length-1;u>=0&&(0!==l||u>=n);u--){var c=0|this.words[u];this.words[u]=l<<26-o|c>>>o,l=c&s}return h&&0!==l&&(h.words[h.length++]=l),0===this.length&&(this.words[0]=0,this.length=1),this._strip()},n.prototype.ishrn=function(t,e,i){return r(0===this.negative),this.iushrn(t,e,i)},n.prototype.shln=function(t){return this.clone().ishln(t)},n.prototype.ushln=function(t){return this.clone().iushln(t)},n.prototype.shrn=function(t){return this.clone().ishrn(t)},n.prototype.ushrn=function(t){return this.clone().iushrn(t)},n.prototype.testn=function(t){r("number"==typeof t&&t>=0);var e=t%26,i=(t-e)/26,n=1<<e;return!(this.length<=i)&&!!(this.words[i]&n)},n.prototype.imaskn=function(t){r("number"==typeof t&&t>=0);var e=t%26,i=(t-e)/26;if(r(0===this.negative,"imaskn works only with positive numbers"),this.length<=i)return this;if(0!==e&&i++,this.length=Math.min(i,this.length),0!==e){var n=67108863^67108863>>>e<<e;this.words[this.length-1]&=n}return this._strip()},n.prototype.maskn=function(t){return this.clone().imaskn(t)},n.prototype.iaddn=function(t){return r("number"==typeof t),r(t<67108864),t<0?this.isubn(-t):0!==this.negative?1===this.length&&(0|this.words[0])<=t?(this.words[0]=t-(0|this.words[0]),this.negative=0,this):(this.negative=0,this.isubn(t),this.negative=1,this):this._iaddn(t)},n.prototype._iaddn=function(t){this.words[0]+=t;for(var e=0;e<this.length&&this.words[e]>=67108864;e++)this.words[e]-=67108864,e===this.length-1?this.words[e+1]=1:this.words[e+1]++;return this.length=Math.max(this.length,e+1),this},n.prototype.isubn=function(t){if(r("number"==typeof t),r(t<67108864),t<0)return this.iaddn(-t);if(0!==this.negative)return this.negative=0,this.iaddn(t),this.negative=1,this;if(this.words[0]-=t,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var e=0;e<this.length&&this.words[e]<0;e++)this.words[e]+=67108864,this.words[e+1]-=1;return this._strip()},n.prototype.addn=function(t){return this.clone().iaddn(t)},n.prototype.subn=function(t){return this.clone().isubn(t)},n.prototype.iabs=function(){return this.negative=0,this},n.prototype.abs=function(){return this.clone().iabs()},n.prototype._ishlnsubmul=function(t,e,i){var n,o,a=t.length+i;this._expand(a);var s=0;for(n=0;n<t.length;n++){o=(0|this.words[n+i])+s;var h=(0|t.words[n])*e;s=((o-=67108863&h)>>26)-(h/67108864|0),this.words[n+i]=67108863&o}for(;n<this.length-i;n++)s=(o=(0|this.words[n+i])+s)>>26,this.words[n+i]=67108863&o;if(0===s)return this._strip();for(r(-1===s),s=0,n=0;n<this.length;n++)s=(o=-(0|this.words[n])+s)>>26,this.words[n]=67108863&o;return this.negative=1,this._strip()},n.prototype._wordDiv=function(t,e){var r=(this.length,t.length),i=this.clone(),o=t,a=0|o.words[o.length-1];0!==(r=26-this._countBits(a))&&(o=o.ushln(r),i.iushln(r),a=0|o.words[o.length-1]);var s,h=i.length-o.length;if("mod"!==e){(s=new n(null)).length=h+1,s.words=new Array(s.length);for(var u=0;u<s.length;u++)s.words[u]=0}var l=i.clone()._ishlnsubmul(o,1,h);0===l.negative&&(i=l,s&&(s.words[h]=1));for(var c=h-1;c>=0;c--){var d=67108864*(0|i.words[o.length+c])+(0|i.words[o.length+c-1]);for(d=Math.min(d/a|0,67108863),i._ishlnsubmul(o,d,c);0!==i.negative;)d--,i.negative=0,i._ishlnsubmul(o,1,c),i.isZero()||(i.negative^=1);s&&(s.words[c]=d)}return s&&s._strip(),i._strip(),"div"!==e&&0!==r&&i.iushrn(r),{div:s||null,mod:i}},n.prototype.divmod=function(t,e,i){return r(!t.isZero()),this.isZero()?{div:new n(0),mod:new n(0)}:0!==this.negative&&0===t.negative?(s=this.neg().divmod(t,e),"mod"!==e&&(o=s.div.neg()),"div"!==e&&(a=s.mod.neg(),i&&0!==a.negative&&a.iadd(t)),{div:o,mod:a}):0===this.negative&&0!==t.negative?(s=this.divmod(t.neg(),e),"mod"!==e&&(o=s.div.neg()),{div:o,mod:s.mod}):0!=(this.negative&t.negative)?(s=this.neg().divmod(t.neg(),e),"div"!==e&&(a=s.mod.neg(),i&&0!==a.negative&&a.isub(t)),{div:s.div,mod:a}):t.length>this.length||this.cmp(t)<0?{div:new n(0),mod:this}:1===t.length?"div"===e?{div:this.divn(t.words[0]),mod:null}:"mod"===e?{div:null,mod:new n(this.modrn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new n(this.modrn(t.words[0]))}:this._wordDiv(t,e);var o,a,s},n.prototype.div=function(t){return this.divmod(t,"div",!1).div},n.prototype.mod=function(t){return this.divmod(t,"mod",!1).mod},n.prototype.umod=function(t){return this.divmod(t,"mod",!0).mod},n.prototype.divRound=function(t){var e=this.divmod(t);if(e.mod.isZero())return e.div;var r=0!==e.div.negative?e.mod.isub(t):e.mod,i=t.ushrn(1),n=t.andln(1),o=r.cmp(i);return o<0||1===n&&0===o?e.div:0!==e.div.negative?e.div.isubn(1):e.div.iaddn(1)},n.prototype.modrn=function(t){var e=t<0;e&&(t=-t),r(t<=67108863);for(var i=(1<<26)%t,n=0,o=this.length-1;o>=0;o--)n=(i*n+(0|this.words[o]))%t;return e?-n:n},n.prototype.modn=function(t){return this.modrn(t)},n.prototype.idivn=function(t){var e=t<0;e&&(t=-t),r(t<=67108863);for(var i=0,n=this.length-1;n>=0;n--){var o=(0|this.words[n])+67108864*i;this.words[n]=o/t|0,i=o%t}return this._strip(),e?this.ineg():this},n.prototype.divn=function(t){return this.clone().idivn(t)},n.prototype.egcd=function(t){r(0===t.negative),r(!t.isZero());var e=this,i=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var o=new n(1),a=new n(0),s=new n(0),h=new n(1),u=0;e.isEven()&&i.isEven();)e.iushrn(1),i.iushrn(1),++u;for(var l=i.clone(),c=e.clone();!e.isZero();){for(var d=0,f=1;0==(e.words[0]&f)&&d<26;++d,f<<=1);if(d>0)for(e.iushrn(d);d-- >0;)(o.isOdd()||a.isOdd())&&(o.iadd(l),a.isub(c)),o.iushrn(1),a.iushrn(1);for(var m=0,p=1;0==(i.words[0]&p)&&m<26;++m,p<<=1);if(m>0)for(i.iushrn(m);m-- >0;)(s.isOdd()||h.isOdd())&&(s.iadd(l),h.isub(c)),s.iushrn(1),h.iushrn(1);e.cmp(i)>=0?(e.isub(i),o.isub(s),a.isub(h)):(i.isub(e),s.isub(o),h.isub(a))}return{a:s,b:h,gcd:i.iushln(u)}},n.prototype._invmp=function(t){r(0===t.negative),r(!t.isZero());var e=this,i=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var o,a=new n(1),s=new n(0),h=i.clone();e.cmpn(1)>0&&i.cmpn(1)>0;){for(var u=0,l=1;0==(e.words[0]&l)&&u<26;++u,l<<=1);if(u>0)for(e.iushrn(u);u-- >0;)a.isOdd()&&a.iadd(h),a.iushrn(1);for(var c=0,d=1;0==(i.words[0]&d)&&c<26;++c,d<<=1);if(c>0)for(i.iushrn(c);c-- >0;)s.isOdd()&&s.iadd(h),s.iushrn(1);e.cmp(i)>=0?(e.isub(i),a.isub(s)):(i.isub(e),s.isub(a))}return(o=0===e.cmpn(1)?a:s).cmpn(0)<0&&o.iadd(t),o},n.prototype.gcd=function(t){if(this.isZero())return t.abs();if(t.isZero())return this.abs();var e=this.clone(),r=t.clone();e.negative=0,r.negative=0;for(var i=0;e.isEven()&&r.isEven();i++)e.iushrn(1),r.iushrn(1);for(;;){for(;e.isEven();)e.iushrn(1);for(;r.isEven();)r.iushrn(1);var n=e.cmp(r);if(n<0){var o=e;e=r,r=o}else if(0===n||0===r.cmpn(1))break;e.isub(r)}return r.iushln(i)},n.prototype.invm=function(t){return this.egcd(t).a.umod(t)},n.prototype.isEven=function(){return 0==(1&this.words[0])},n.prototype.isOdd=function(){return 1==(1&this.words[0])},n.prototype.andln=function(t){return this.words[0]&t},n.prototype.bincn=function(t){r("number"==typeof t);var e=t%26,i=(t-e)/26,n=1<<e;if(this.length<=i)return this._expand(i+1),this.words[i]|=n,this;for(var o=n,a=i;0!==o&&a<this.length;a++){var s=0|this.words[a];o=(s+=o)>>>26,s&=67108863,this.words[a]=s}return 0!==o&&(this.words[a]=o,this.length++),this},n.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},n.prototype.cmpn=function(t){var e,i=t<0;if(0!==this.negative&&!i)return-1;if(0===this.negative&&i)return 1;if(this._strip(),this.length>1)e=1;else{i&&(t=-t),r(t<=67108863,"Number is too big");var n=0|this.words[0];e=n===t?0:n<t?-1:1}return 0!==this.negative?0|-e:e},n.prototype.cmp=function(t){if(0!==this.negative&&0===t.negative)return-1;if(0===this.negative&&0!==t.negative)return 1;var e=this.ucmp(t);return 0!==this.negative?0|-e:e},n.prototype.ucmp=function(t){if(this.length>t.length)return 1;if(this.length<t.length)return-1;for(var e=0,r=this.length-1;r>=0;r--){var i=0|this.words[r],n=0|t.words[r];if(i!==n){i<n?e=-1:i>n&&(e=1);break}}return e},n.prototype.gtn=function(t){return 1===this.cmpn(t)},n.prototype.gt=function(t){return 1===this.cmp(t)},n.prototype.gten=function(t){return this.cmpn(t)>=0},n.prototype.gte=function(t){return this.cmp(t)>=0},n.prototype.ltn=function(t){return-1===this.cmpn(t)},n.prototype.lt=function(t){return-1===this.cmp(t)},n.prototype.lten=function(t){return this.cmpn(t)<=0},n.prototype.lte=function(t){return this.cmp(t)<=0},n.prototype.eqn=function(t){return 0===this.cmpn(t)},n.prototype.eq=function(t){return 0===this.cmp(t)},n.red=function(t){return new E(t)},n.prototype.toRed=function(t){return r(!this.red,"Already a number in reduction context"),r(0===this.negative,"red works only with positives"),t.convertTo(this)._forceRed(t)},n.prototype.fromRed=function(){return r(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},n.prototype._forceRed=function(t){return this.red=t,this},n.prototype.forceRed=function(t){return r(!this.red,"Already a number in reduction context"),this._forceRed(t)},n.prototype.redAdd=function(t){return r(this.red,"redAdd works only with red numbers"),this.red.add(this,t)},n.prototype.redIAdd=function(t){return r(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,t)},n.prototype.redSub=function(t){return r(this.red,"redSub works only with red numbers"),this.red.sub(this,t)},n.prototype.redISub=function(t){return r(this.red,"redISub works only with red numbers"),this.red.isub(this,t)},n.prototype.redShl=function(t){return r(this.red,"redShl works only with red numbers"),this.red.shl(this,t)},n.prototype.redMul=function(t){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.mul(this,t)},n.prototype.redIMul=function(t){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.imul(this,t)},n.prototype.redSqr=function(){return r(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},n.prototype.redISqr=function(){return r(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},n.prototype.redSqrt=function(){return r(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},n.prototype.redInvm=function(){return r(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},n.prototype.redNeg=function(){return r(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},n.prototype.redPow=function(t){return r(this.red&&!t.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,t)};var w={k256:null,p224:null,p192:null,p25519:null};function v(t,e){this.name=t,this.p=new n(e,16),this.n=this.p.bitLength(),this.k=new n(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function b(){v.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function k(){v.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function M(){v.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function _(){v.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function E(t){if("string"==typeof t){var e=n._prime(t);this.m=e.p,this.prime=e}else r(t.gtn(1),"modulus must be greater than 1"),this.m=t,this.prime=null}function A(t){E.call(this,t),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new n(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)}v.prototype._tmp=function(){var t=new n(null);return t.words=new Array(Math.ceil(this.n/13)),t},v.prototype.ireduce=function(t){var e,r=t;do{this.split(r,this.tmp),e=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(e>this.n);var i=e<this.n?-1:r.ucmp(this.p);return 0===i?(r.words[0]=0,r.length=1):i>0?r.isub(this.p):void 0!==r.strip?r.strip():r._strip(),r},v.prototype.split=function(t,e){t.iushrn(this.n,0,e)},v.prototype.imulK=function(t){return t.imul(this.k)},i(b,v),b.prototype.split=function(t,e){for(var r=4194303,i=Math.min(t.length,9),n=0;n<i;n++)e.words[n]=t.words[n];if(e.length=i,t.length<=9)return t.words[0]=0,void(t.length=1);var o=t.words[9];for(e.words[e.length++]=o&r,n=10;n<t.length;n++){var a=0|t.words[n];t.words[n-10]=(a&r)<<4|o>>>22,o=a}o>>>=22,t.words[n-10]=o,0===o&&t.length>10?t.length-=10:t.length-=9},b.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var e=0,r=0;r<t.length;r++){var i=0|t.words[r];e+=977*i,t.words[r]=67108863&e,e=64*i+(e/67108864|0)}return 0===t.words[t.length-1]&&(t.length--,0===t.words[t.length-1]&&t.length--),t},i(k,v),i(M,v),i(_,v),_.prototype.imulK=function(t){for(var e=0,r=0;r<t.length;r++){var i=19*(0|t.words[r])+e,n=67108863&i;i>>>=26,t.words[r]=n,e=i}return 0!==e&&(t.words[t.length++]=e),t},n._prime=function(t){if(w[t])return w[t];var e;if("k256"===t)e=new b;else if("p224"===t)e=new k;else if("p192"===t)e=new M;else{if("p25519"!==t)throw new Error("Unknown prime "+t);e=new _}return w[t]=e,e},E.prototype._verify1=function(t){r(0===t.negative,"red works only with positives"),r(t.red,"red works only with red numbers")},E.prototype._verify2=function(t,e){r(0==(t.negative|e.negative),"red works only with positives"),r(t.red&&t.red===e.red,"red works only with red numbers")},E.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):(u(t,t.umod(this.m)._forceRed(this)),t)},E.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},E.prototype.add=function(t,e){this._verify2(t,e);var r=t.add(e);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},E.prototype.iadd=function(t,e){this._verify2(t,e);var r=t.iadd(e);return r.cmp(this.m)>=0&&r.isub(this.m),r},E.prototype.sub=function(t,e){this._verify2(t,e);var r=t.sub(e);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},E.prototype.isub=function(t,e){this._verify2(t,e);var r=t.isub(e);return r.cmpn(0)<0&&r.iadd(this.m),r},E.prototype.shl=function(t,e){return this._verify1(t),this.imod(t.ushln(e))},E.prototype.imul=function(t,e){return this._verify2(t,e),this.imod(t.imul(e))},E.prototype.mul=function(t,e){return this._verify2(t,e),this.imod(t.mul(e))},E.prototype.isqr=function(t){return this.imul(t,t.clone())},E.prototype.sqr=function(t){return this.mul(t,t)},E.prototype.sqrt=function(t){if(t.isZero())return t.clone();var e=this.m.andln(3);if(r(e%2==1),3===e){var i=this.m.add(new n(1)).iushrn(2);return this.pow(t,i)}for(var o=this.m.subn(1),a=0;!o.isZero()&&0===o.andln(1);)a++,o.iushrn(1);r(!o.isZero());var s=new n(1).toRed(this),h=s.redNeg(),u=this.m.subn(1).iushrn(1),l=this.m.bitLength();for(l=new n(2*l*l).toRed(this);0!==this.pow(l,u).cmp(h);)l.redIAdd(h);for(var c=this.pow(l,o),d=this.pow(t,o.addn(1).iushrn(1)),f=this.pow(t,o),m=a;0!==f.cmp(s);){for(var p=f,g=0;0!==p.cmp(s);g++)p=p.redSqr();r(g<m);var y=this.pow(c,new n(1).iushln(m-g-1));d=d.redMul(y),c=y.redSqr(),f=f.redMul(c),m=g}return d},E.prototype.invm=function(t){var e=t._invmp(this.m);return 0!==e.negative?(e.negative=0,this.imod(e).redNeg()):this.imod(e)},E.prototype.pow=function(t,e){if(e.isZero())return new n(1).toRed(this);if(0===e.cmpn(1))return t.clone();var r=new Array(16);r[0]=new n(1).toRed(this),r[1]=t;for(var i=2;i<r.length;i++)r[i]=this.mul(r[i-1],t);var o=r[0],a=0,s=0,h=e.bitLength()%26;for(0===h&&(h=26),i=e.length-1;i>=0;i--){for(var u=e.words[i],l=h-1;l>=0;l--){var c=u>>l&1;o!==r[0]&&(o=this.sqr(o)),0!==c||0!==a?(a<<=1,a|=c,(4===++s||0===i&&0===l)&&(o=this.mul(o,r[a]),s=0,a=0)):s=0}h=26}return o},E.prototype.convertTo=function(t){var e=t.umod(this.m);return e===t?e.clone():e},E.prototype.convertFrom=function(t){var e=t.clone();return e.red=null,e},n.mont=function(t){return new A(t)},i(A,E),A.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},A.prototype.convertFrom=function(t){var e=this.imod(t.mul(this.rinv));return e.red=null,e},A.prototype.imul=function(t,e){if(t.isZero()||e.isZero())return t.words[0]=0,t.length=1,t;var r=t.imul(e),i=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),n=r.isub(i).iushrn(this.shift),o=n;return n.cmp(this.m)>=0?o=n.isub(this.m):n.cmpn(0)<0&&(o=n.iadd(this.m)),o._forceRed(this)},A.prototype.mul=function(t,e){if(t.isZero()||e.isZero())return new n(0)._forceRed(this);var r=t.mul(e),i=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),o=r.isub(i).iushrn(this.shift),a=o;return o.cmp(this.m)>=0?a=o.isub(this.m):o.cmpn(0)<0&&(a=o.iadd(this.m)),a._forceRed(this)},A.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}(t,i)}));var iP=rP.BN;const nP=new w("bignumber/5.6.2"),oP={},aP=9007199254740991;let sP=!1;class hP{constructor(t,e){t!==oP&&nP.throwError("cannot call constructor directly; use BigNumber.from",w.errors.UNSUPPORTED_OPERATION,{operation:"new (BigNumber)"}),this._hex=e,this._isBigNumber=!0,Object.freeze(this)}fromTwos(t){return lP(cP(this).fromTwos(t))}toTwos(t){return lP(cP(this).toTwos(t))}abs(){return"-"===this._hex[0]?hP.from(this._hex.substring(1)):this}add(t){return lP(cP(this).add(cP(t)))}sub(t){return lP(cP(this).sub(cP(t)))}div(t){return hP.from(t).isZero()&&dP("division-by-zero","div"),lP(cP(this).div(cP(t)))}mul(t){return lP(cP(this).mul(cP(t)))}mod(t){const e=cP(t);return e.isNeg()&&dP("division-by-zero","mod"),lP(cP(this).umod(e))}pow(t){const e=cP(t);return e.isNeg()&&dP("negative-power","pow"),lP(cP(this).pow(e))}and(t){const e=cP(t);return(this.isNegative()||e.isNeg())&&dP("unbound-bitwise-result","and"),lP(cP(this).and(e))}or(t){const e=cP(t);return(this.isNegative()||e.isNeg())&&dP("unbound-bitwise-result","or"),lP(cP(this).or(e))}xor(t){const e=cP(t);return(this.isNegative()||e.isNeg())&&dP("unbound-bitwise-result","xor"),lP(cP(this).xor(e))}mask(t){return(this.isNegative()||t<0)&&dP("negative-width","mask"),lP(cP(this).maskn(t))}shl(t){return(this.isNegative()||t<0)&&dP("negative-width","shl"),lP(cP(this).shln(t))}shr(t){return(this.isNegative()||t<0)&&dP("negative-width","shr"),lP(cP(this).shrn(t))}eq(t){return cP(this).eq(cP(t))}lt(t){return cP(this).lt(cP(t))}lte(t){return cP(this).lte(cP(t))}gt(t){return cP(this).gt(cP(t))}gte(t){return cP(this).gte(cP(t))}isNegative(){return"-"===this._hex[0]}isZero(){return cP(this).isZero()}toNumber(){try{return cP(this).toNumber()}catch(t){dP("overflow","toNumber",this.toString())}return null}toBigInt(){try{return BigInt(this.toString())}catch(t){}return nP.throwError("this platform does not support BigInt",w.errors.UNSUPPORTED_OPERATION,{value:this.toString()})}toString(){return arguments.length>0&&(10===arguments[0]?sP||(sP=!0,nP.warn("BigNumber.toString does not accept any parameters; base-10 is assumed")):16===arguments[0]?nP.throwError("BigNumber.toString does not accept any parameters; use bigNumber.toHexString()",w.errors.UNEXPECTED_ARGUMENT,{}):nP.throwError("BigNumber.toString does not accept parameters",w.errors.UNEXPECTED_ARGUMENT,{})),cP(this).toString(10)}toHexString(){return this._hex}toJSON(t){return{type:"BigNumber",hex:this.toHexString()}}static from(t){if(t instanceof hP)return t;if("string"==typeof t)return t.match(/^-?0x[0-9a-f]+$/i)?new hP(oP,uP(t)):t.match(/^-?[0-9]+$/)?new hP(oP,uP(new iP(t))):nP.throwArgumentError("invalid BigNumber string","value",t);if("number"==typeof t)return t%1&&dP("underflow","BigNumber.from",t),(t>=aP||t<=-aP)&&dP("overflow","BigNumber.from",t),hP.from(String(t));const e=t;if("bigint"==typeof e)return hP.from(e.toString());if(E(e))return hP.from(I(e));if(e)if(e.toHexString){const t=e.toHexString();if("string"==typeof t)return hP.from(t)}else{let t=e._hex;if(null==t&&"BigNumber"===e.type&&(t=e.hex),"string"==typeof t&&(S(t)||"-"===t[0]&&S(t.substring(1))))return hP.from(t)}return nP.throwArgumentError("invalid BigNumber value","value",t)}static isBigNumber(t){return!(!t||!t._isBigNumber)}}function uP(t){if("string"!=typeof t)return uP(t.toString(16));if("-"===t[0])return"-"===(t=t.substring(1))[0]&&nP.throwArgumentError("invalid hex","value",t),"0x00"===(t=uP(t))?t:"-"+t;if("0x"!==t.substring(0,2)&&(t="0x"+t),"0x"===t)return"0x00";for(t.length%2&&(t="0x0"+t.substring(2));t.length>4&&"0x00"===t.substring(0,4);)t="0x"+t.substring(4);return t}function lP(t){return hP.from(uP(t))}function cP(t){const e=hP.from(t).toHexString();return"-"===e[0]?new iP("-"+e.substring(3),16):new iP(e.substring(2),16)}function dP(t,e,r){const i={fault:t,operation:e};return null!=r&&(i.value=r),nP.throwError(t,w.errors.NUMERIC_FAULT,i)}var fP=window&&window.__awaiter||function(t,e,r,i){return new(r||(r=Promise))((function(n,o){function a(t){try{h(i.next(t))}catch(t){o(t)}}function s(t){try{h(i.throw(t))}catch(t){o(t)}}function h(t){var e;t.done?n(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(a,s)}h((i=i.apply(t,e||[])).next())}))};const mP=new w("hash/5.6.1"),pP=new Uint8Array(32);pP.fill(0);const gP=hP.from(-1),yP=hP.from(0),wP=hP.from(1),vP=hP.from("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");const bP=R(wP.toHexString(),32),kP=R(yP.toHexString(),32),MP={name:"string",version:"string",chainId:"uint256",verifyingContract:"address",salt:"bytes32"},_P=["name","version","chainId","verifyingContract","salt"];function EP(t){return function(e){return"string"!=typeof e&&mP.throwArgumentError(`invalid domain value for ${JSON.stringify(t)}`,`domain.${t}`,e),e}}const AP={name:EP("name"),version:EP("version"),chainId:function(t){try{return hP.from(t).toString()}catch(t){}return mP.throwArgumentError('invalid domain value for "chainId"',"domain.chainId",t)},verifyingContract:function(t){try{return he(t).toLowerCase()}catch(t){}return mP.throwArgumentError('invalid domain value "verifyingContract"',"domain.verifyingContract",t)},salt:function(t){try{const e=A(t);if(32!==e.length)throw new Error("bad length");return I(e)}catch(t){}return mP.throwArgumentError('invalid domain value "salt"',"domain.salt",t)}};function jP(t){{const e=t.match(/^(u?)int(\d*)$/);if(e){const r=""===e[1],i=parseInt(e[2]||"256");(i%8!=0||i>256||e[2]&&e[2]!==String(i))&&mP.throwArgumentError("invalid numeric width","type",t);const n=vP.mask(r?i-1:i),o=r?n.add(wP).mul(gP):yP;return function(e){const r=hP.from(e);return(r.lt(o)||r.gt(n))&&mP.throwArgumentError(`value out-of-bounds for ${t}`,"value",e),R(r.toTwos(256).toHexString(),32)}}}{const e=t.match(/^bytes(\d+)$/);if(e){const r=parseInt(e[1]);return(0===r||r>32||e[1]!==String(r))&&mP.throwArgumentError("invalid bytes width","type",t),function(e){return A(e).length!==r&&mP.throwArgumentError(`invalid length for ${t}`,"value",e),function(t){const e=A(t),r=e.length%32;return r?z([e,pP.slice(r)]):I(e)}(e)}}}switch(t){case"address":return function(t){return R(he(t),32)};case"bool":return function(t){return t?bP:kP};case"bytes":return function(t){return Jt(t)};case"string":return function(t){return eP(t)}}return null}function xP(t,e){return`${t}(${e.map((({name:t,type:e})=>e+" "+t)).join(",")})`}class SP{constructor(t){ir(this,"types",Object.freeze(lr(t))),ir(this,"_encoderCache",{}),ir(this,"_types",{});const e={},r={},i={};Object.keys(t).forEach((t=>{e[t]={},r[t]=[],i[t]={}}));for(const i in t){const n={};t[i].forEach((o=>{n[o.name]&&mP.throwArgumentError(`duplicate variable name ${JSON.stringify(o.name)} in ${JSON.stringify(i)}`,"types",t),n[o.name]=!0;const a=o.type.match(/^([^\x5b]*)(\x5b|$)/)[1];a===i&&mP.throwArgumentError(`circular type reference to ${JSON.stringify(a)}`,"types",t);jP(a)||(r[a]||mP.throwArgumentError(`unknown type ${JSON.stringify(a)}`,"types",t),r[a].push(i),e[i][a]=!0)}))}const n=Object.keys(r).filter((t=>0===r[t].length));0===n.length?mP.throwArgumentError("missing primary type","types",t):n.length>1&&mP.throwArgumentError(`ambiguous primary types or unused types: ${n.map((t=>JSON.stringify(t))).join(", ")}`,"types",t),ir(this,"primaryType",n[0]),function n(o,a){a[o]&&mP.throwArgumentError(`circular type reference to ${JSON.stringify(o)}`,"types",t),a[o]=!0,Object.keys(e[o]).forEach((t=>{r[t]&&(n(t,a),Object.keys(a).forEach((e=>{i[e][t]=!0})))})),delete a[o]}(this.primaryType,{});for(const e in i){const r=Object.keys(i[e]);r.sort(),this._types[e]=xP(e,t[e])+r.map((e=>xP(e,t[e]))).join("")}}getEncoder(t){let e=this._encoderCache[t];return e||(e=this._encoderCache[t]=this._getEncoder(t)),e}_getEncoder(t){{const e=jP(t);if(e)return e}const e=t.match(/^(.*)(\x5b(\d*)\x5d)$/);if(e){const t=e[1],r=this.getEncoder(t),i=parseInt(e[3]);return e=>{i>=0&&e.length!==i&&mP.throwArgumentError("array length mismatch; expected length ${ arrayLength }","value",e);let n=e.map(r);return this._types[t]&&(n=n.map(Jt)),Jt(z(n))}}const r=this.types[t];if(r){const e=eP(this._types[t]);return t=>{const i=r.map((({name:e,type:r})=>{const i=this.getEncoder(r)(t[e]);return this._types[r]?Jt(i):i}));return i.unshift(e),z(i)}}return mP.throwArgumentError(`unknown type: ${t}`,"type",t)}encodeType(t){const e=this._types[t];return e||mP.throwArgumentError(`unknown type: ${JSON.stringify(t)}`,"name",t),e}encodeData(t,e){return this.getEncoder(t)(e)}hashStruct(t,e){return Jt(this.encodeData(t,e))}encode(t){return this.encodeData(this.primaryType,t)}hash(t){return this.hashStruct(this.primaryType,t)}_visit(t,e,r){if(jP(t))return r(t,e);const i=t.match(/^(.*)(\x5b(\d*)\x5d)$/);if(i){const t=i[1],n=parseInt(i[3]);return n>=0&&e.length!==n&&mP.throwArgumentError("array length mismatch; expected length ${ arrayLength }","value",e),e.map((e=>this._visit(t,e,r)))}const n=this.types[t];return n?n.reduce(((t,{name:i,type:n})=>(t[i]=this._visit(n,e[i],r),t)),{}):mP.throwArgumentError(`unknown type: ${t}`,"type",t)}visit(t,e){return this._visit(this.primaryType,t,e)}static from(t){return new SP(t)}static getPrimaryType(t){return SP.from(t).primaryType}static hashStruct(t,e,r){return SP.from(e).hashStruct(t,r)}static hashDomain(t){const e=[];for(const r in t){const i=MP[r];i||mP.throwArgumentError(`invalid typed-data domain key: ${JSON.stringify(r)}`,"domain",t),e.push({name:r,type:i})}return e.sort(((t,e)=>_P.indexOf(t.name)-_P.indexOf(e.name))),SP.hashStruct("EIP712Domain",{EIP712Domain:e},t)}static encode(t,e,r){return z(["0x1901",SP.hashDomain(t),SP.from(e).hash(r)])}static hash(t,e,r){return Jt(SP.encode(t,e,r))}static resolveNames(t,e,r,i){return fP(this,void 0,void 0,(function*(){t=ar(t);const n={};t.verifyingContract&&!S(t.verifyingContract,20)&&(n[t.verifyingContract]="0x");const o=SP.from(e);o.visit(r,((t,e)=>("address"!==t||S(e,20)||(n[e]="0x"),e)));for(const t in n)n[t]=yield i(t);return t.verifyingContract&&n[t.verifyingContract]&&(t.verifyingContract=n[t.verifyingContract]),r=o.visit(r,((t,e)=>"address"===t&&n[e]?n[e]:e)),{domain:t,value:r}}))}static getPayload(t,e,r){SP.hashDomain(t);const i={},n=[];_P.forEach((e=>{const r=t[e];null!=r&&(i[e]=AP[e](r),n.push({name:e,type:MP[e]}))}));const o=SP.from(e),a=ar(e);return a.EIP712Domain?mP.throwArgumentError("types must not contain EIP712Domain type","types.EIP712Domain",e):a.EIP712Domain=n,o.encode(r),{types:a,domain:i,primaryType:o.primaryType,message:o.visit(r,((t,e)=>{if(t.match(/^bytes(\d*)/))return I(A(e));if(t.match(/^u?int/))return hP.from(e).toString();switch(t){case"address":return e.toLowerCase();case"bool":return!!e;case"string":return"string"!=typeof e&&mP.throwArgumentError("invalid string","value",e),e}return mP.throwArgumentError("unsupported type","type",t)}))}}}window&&window.__awaiter;new w("wallet/5.6.2");function NP(t,e,r,i){return gs(SP.hash(t,e,r),i)}const IP="6492649264926492649264926492649264926492649264926492649264926492";function TP(t,e){return t.toLowerCase()===e.toLowerCase()}function CP(t){const{domain:e,types:r,message:i}=t;return wl.hash(e,r,i)}function zP(t,e,i,n){return r(this,void 0,void 0,(function*(){let r;try{r=yield vB(n,["function isValidSignature(bytes32 _hash, bytes memory _signature) public view returns (bytes4 magicValue)"],[t,"isValidSignature",[A(i),e]])}catch(t){if(t.message.startsWith("missing revert data in call exception"))return!1;throw t}return TP(r,"0x1626ba7e")}))}function OP(t,e,i,n){return r(this,void 0,void 0,(function*(){return TP(yield vB(n,["function isValidSignature(bytes _hash, bytes memory _signature) public view returns (bytes4 magicValue)"],[t,"isValidSignature",[A(i),e]]),"0x20c13b0b")}))}var RP=Object.freeze({__proto__:null,getHash:CP,default:function(t,e,i){return r(this,arguments,void 0,(function*(t,e,r,i="1",n={}){const{domain:o,types:a,message:s}=r;try{if(TP(t,NP(o,a,s,e)))return!0}catch(t){}const h=Xp(i,n),u=CP(r);if(e.endsWith(IP))try{return"0x01"===(yield h.call({data:j(["0x60806040523480156200001157600080fd5b50604051620007003803806200070083398101604081905262000034916200056f565b6000620000438484846200004f565b9050806000526001601ff35b600080846001600160a01b0316803b806020016040519081016040528181526000908060200190933c90507f6492649264926492649264926492649264926492649264926492649264926492620000a68462000451565b036200021f57600060608085806020019051810190620000c79190620005ce565b8651929550909350915060000362000192576000836001600160a01b031683604051620000f5919062000643565b6000604051808303816000865af19150503d806000811462000134576040519150601f19603f3d011682016040523d82523d6000602084013e62000139565b606091505b5050905080620001905760405162461bcd60e51b815260206004820152601e60248201527f5369676e617475726556616c696461746f723a206465706c6f796d656e74000060448201526064015b60405180910390fd5b505b604051630b135d3f60e11b808252906001600160a01b038a1690631626ba7e90620001c4908b90869060040162000661565b602060405180830381865afa158015620001e2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200020891906200069d565b6001600160e01b031916149450505050506200044a565b805115620002b157604051630b135d3f60e11b808252906001600160a01b03871690631626ba7e9062000259908890889060040162000661565b602060405180830381865afa15801562000277573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200029d91906200069d565b6001600160e01b031916149150506200044a565b8251604114620003195760405162461bcd60e51b815260206004820152603a6024820152600080516020620006e083398151915260448201527f3a20696e76616c6964207369676e6174757265206c656e677468000000000000606482015260840162000187565b620003236200046b565b506020830151604080850151855186939260009185919081106200034b576200034b620006c9565b016020015160f81c9050601b81148015906200036b57508060ff16601c14155b15620003cf5760405162461bcd60e51b815260206004820152603b6024820152600080516020620006e083398151915260448201527f3a20696e76616c6964207369676e617475726520762076616c75650000000000606482015260840162000187565b6040805160008152602081018083528a905260ff83169181019190915260608101849052608081018390526001600160a01b038a169060019060a0016020604051602081039080840390855afa1580156200042e573d6000803e3d6000fd5b505050602060405103516001600160a01b031614955050505050505b9392505050565b60006020825110156200046357600080fd5b508051015190565b60405180606001604052806003906020820280368337509192915050565b6001600160a01b03811681146200049f57600080fd5b50565b634e487b7160e01b600052604160045260246000fd5b60005b83811015620004d5578181015183820152602001620004bb565b50506000910152565b600082601f830112620004f057600080fd5b81516001600160401b03808211156200050d576200050d620004a2565b604051601f8301601f19908116603f01168101908282118183101715620005385762000538620004a2565b816040528381528660208588010111156200055257600080fd5b62000565846020830160208901620004b8565b9695505050505050565b6000806000606084860312156200058557600080fd5b8351620005928162000489565b6020850151604086015191945092506001600160401b03811115620005b657600080fd5b620005c486828701620004de565b9150509250925092565b600080600060608486031215620005e457600080fd5b8351620005f18162000489565b60208501519093506001600160401b03808211156200060f57600080fd5b6200061d87838801620004de565b935060408601519150808211156200063457600080fd5b50620005c486828701620004de565b6000825162000657818460208701620004b8565b9190910192915050565b828152604060208201526000825180604084015262000688816060850160208701620004b8565b601f01601f1916919091016060019392505050565b600060208284031215620006b057600080fd5b81516001600160e01b0319811681146200044a57600080fd5b634e487b7160e01b600052603260045260246000fdfe5369676e617475726556616c696461746f72237265636f7665725369676e6572",(new $i).encode(["address","bytes32","bytes"],[t,A(u),e])])}))}catch(t){return!1}return!!(yield zP(t,e,u,h))||(yield OP(t,e,u,h))}))}});var PP=["ipfs.snapshot.box","snapshot.4everland.link","ipfs.io","ipfs.fleek.co","gateway.pinata.cloud","dweb.link","ipfs.infura.io"],BP={1:{key:"1",name:"Ethereum",chainId:1,network:"homestead",multicall:"0xeefba1e63905ef1d7acba5a8513c70307c1ce441",ensResolvers:["0x231b0Ee14048e9dCcD1d247744d114a4EB5E8E63","0x4976fb03C32e5B8cfe2b6cCB31c09Ba78EBaBa41"],ensNameWrapper:"0xD4416b13d2b3a9aBae7AcD5D6C2BbDBE25686401",ensSubgraph:"https://subgrapher.snapshot.org/subgraph/arbitrum/5XqPmWe6gjyrJtFn9cLy237i4cWw2j9HcUJEXsP5qGtH",rpc:["https://rpc.ankr.com/eth",{url:"https://api-geth-archive.ankr.com",user:"balancer_user",password:"balancerAnkr20201015"},"https://speedy-nodes-nyc.moralis.io/b9aed21e7bb7bdeb35972c9a/eth/mainnet/archive","https://apis.ankr.com/e62bc219f9c9462b8749defe472d2dc5/6106d4a3ec1d1bcc87ec72158f8fd089/eth/archive/main","https://eth-archival.gateway.pokt.network/v1/5f76124fb90218002e9ce985","https://eth-mainnet.alchemyapi.io/v2/4bdDVB5QAaorY2UE-GBUbM2yQB3QJqzv"],light:["https://cloudflare-eth.com"],ws:["wss://eth-mainnet.ws.alchemyapi.io/v2/4bdDVB5QAaorY2UE-GBUbM2yQB3QJqzv"],explorer:{url:"https://etherscan.io",apiUrl:"https://api.etherscan.io"},start:7929876,logo:"ipfs://bafkreid7ndxh6y2ljw2jhbisodiyrhcy2udvnwqgon5wgells3kh4si5z4"},8:{key:"8",name:"Ubiq",chainId:8,network:"Ubiq",multicall:"0x6668750957e4083725926B71C41bDF1434C73262",rpc:["https://rpc.octano.dev"],ws:["wss://ws.octano.dev"],explorer:{url:"https://ubiqscan.io"},start:1,logo:"ipfs://Qmec3HLoN4QhwZAhw4XTi2aN8Wwmcko5hHN22sHARzb9tw"},10:{key:"10",name:"OP Mainnet",chainId:10,network:"OP Mainnet",multicall:"0x35A6Cdb2C9AD4a45112df4a04147EB07dFA01aB7",rpc:["https://opt-mainnet.g.alchemy.com/v2/JzmIL4Q3jBj7it2duxLFeuCa9Wobmm7D"],explorer:{url:"https://optimistic.etherscan.io",apiUrl:"https://api-optimistic.etherscan.io"},start:657806,logo:"ipfs://bafkreifu2remiqfpsb4hgisbwb3qxedrzpwsea7ik4el45znjcf56xf2ku"},19:{key:"19",name:"Songbird Canary-Network",shortName:"Songbird",chainId:19,network:"songbird",multicall:"0x17032Ea9c3a13Ed337665145364c0d2aD1108c91",rpc:["https://songbird-api.flare.network/ext/C/rpc"],explorer:{url:"https://songbird-explorer.flare.network"},start:21807126,logo:"ipfs://QmXyvnrZY8FUxSULfnKKA99sAEkjAHtvhRx5WeHixgaEdu"},24:{key:"24",name:"KardiaChain Mainnet",shortName:"KAI",chainId:24,network:"mainnet",multicall:"0xd9c92F2287B7802A37eC9BEce96Aa65fb5f31E1b",rpc:["https://kai-internal.kardiachain.io"],explorer:{url:"https://explorer.kardiachain.io"},start:8260245,logo:"ipfs://bafkreig73yfyqzbxydv6e3dbj5nks3f57px2iez7tywayey4rilfhhrr34"},25:{key:"25",name:"Cronos",shortName:"Cronos",chainId:25,network:"mainnet",multicall:"0x6F522a3982e8F9A50A2EDc9E46ed1A3aE2B3FD3a",rpc:["https://evm-cronos.crypto.org"],explorer:{url:"https://cronos.crypto.org/explorer"},start:4067,logo:"ipfs://QmfSJbtirJoa3Pt7o5Fdm85wbyw9V1hpzqLr5PQbdnfsAj"},30:{key:"30",name:"RSK",chainId:30,network:"rsk mainnet",multicall:"0x4eeebb5580769ba6d26bfd07be636300076d1831",rpc:["https://public-node.rsk.co"],explorer:{url:"https://explorer.rsk.co"},start:2516442,logo:"ipfs://QmXTwpE1SqoNZmyY4c3fYWy6qUgQELsyWKbgJo2Pg6K6V9"},46:{key:"46",name:"Darwinia Network",shortName:"Darwinia",chainId:46,network:"mainnet",multicall:"0x67f9ae42EaA9a8aBf065D60ec6Ab3C1A11370607",rpc:["https://rpc.darwinia.network"],explorer:{url:"https://darwinia.subscan.io"},start:141853,logo:"ipfs://bafkreicf55maidhx46pyu3mwsshlr43xbewr6tkckkonh4nesbkp7krwkm"},56:{key:"56",name:"BNB Smart Chain",shortName:"BSC",chainId:56,network:"mainnet",multicall:"0x1ee38d535d541c55c9dae27b12edf090c608e6fb",rpc:["https://speedy-nodes-nyc.moralis.io/b9aed21e7bb7bdeb35972c9a/bsc/mainnet/archive","https://rpc.ankr.com/bsc","https://bsc.getblock.io/mainnet/?api_key=91f8195f-bf46-488f-846a-73d6853790e7","https://bsc-private-dataseed1.nariox.org","https://bsc-dataseed1.ninicoin.io","https://bsc-dataseed1.binance.org"],explorer:{url:"https://bscscan.com"},start:461230,logo:"ipfs://bafkreibll4la7wqerzs7zwxjne2j7ayynbg2wlenemssoahxxj5rbt6c64"},61:{key:"61",name:"Ethereum Classic",shortName:"Ethereum Classic",chainId:61,network:"mainnet",multicall:"0x51be3a92C56ae7E207C5b5Fd87F7798Ce82C1AC2",rpc:["https://www.ethercluster.com/etc"],explorer:{url:"https://blockscout.com/etc/mainnet"},start:13307544,logo:"ipfs://QmVegc28DvA7LjKUFysab81c9BSuN4wQVDQkRXyAtuEBis"},66:{key:"66",name:"OKExChain",shortName:"OEC Mainnet",chainId:66,network:"oec mainnet",multicall:"0x6EB187d8197Ac265c945b69f3c3064A6f3831866",rpc:["https://exchainrpc.okex.org"],ws:["wss://exchainws.okex.org:8443"],explorer:{url:"https://www.oklink.com/okexchain"},start:5076543,logo:"ipfs://Qmd7dKnNwHRZ4HRCbCXUbkNV7gP28fGqPdjbHtjRtT9sQF"},75:{key:"75",name:"Decimal",shortName:"mainnet",chainId:75,network:"mainnet",multicall:"0x949d1A0757803C51F2EfFFEb5472C861A898B8E8",rpc:[],explorer:{url:"https://explorer.decimalchain.com"},start:16031065,logo:"ipfs://bafkreihkdhbce5rkogl63xegaarlirjrvbfarxbtbf5mqme3s5grvbjyxm"},81:{key:"81",name:"Shibuya Network",shortName:"Shibuya",chainId:81,network:"testnet",testnet:!0,multicall:"0x3E90A35839ff0Aa32992d33d861f24dC95BBf74d",rpc:["https://rpc.shibuya.astar.network:8545"],explorer:{url:"https://blockscout.com/shibuya"},start:856303,logo:"ipfs://QmZLQVsUqHBDXutu6ywTvcYXDZG2xBstMfHkfJSzUNpZsc"},82:{key:"82",name:"Meter",shortName:"Meter",chainId:82,network:"mainnet",multicall:"0x579De77CAEd0614e3b158cb738fcD5131B9719Ae",rpc:["https://rpc.meter.io"],explorer:{url:"https://scan.meter.io"},start:4992871,logo:"ipfs://QmSZvT9w9eUDvV1YVaq3BKKEbubtNVqu1Rin44FuN4wz11"},97:{key:"97",name:"BNB Smart Chain Testnet",shortName:"BSC Testnet",chainId:97,network:"testnet",testnet:!0,multicall:"0x8b54247c6BAe96A6ccAFa468ebae96c4D7445e46",rpc:["https://data-seed-prebsc-1-s1.binance.org:8545","https://speedy-nodes-nyc.moralis.io/f2963e29bec0de5787da3164/bsc/testnet/archive"],explorer:{url:"https://testnet.bscscan.com"},start:3599656,logo:"ipfs://bafkreibll4la7wqerzs7zwxjne2j7ayynbg2wlenemssoahxxj5rbt6c64"},100:{key:"100",name:"Gnosis Chain",shortName:"xDAI",chainId:100,network:"mainnet",multicall:"0xb5b692a88bdfc81ca69dcb1d924f59f0413a602a",rpc:["https://gno.getblock.io/mainnet/6c1d1e6e-75d9-452f-a863-a694bff93d5c/","https://xdai-archive.blockscout.com","https://poa-xdai.gateway.pokt.network/v1/5f76124fb90218002e9ce985","https://rpc.gnosischain.com"],light:["https://rpc.gnosischain.com"],ws:["wss://rpc.xdaichain.com/wss"],explorer:{url:"https://gnosis.blockscout.com"},start:4108192,logo:"ipfs://QmZeiy8Ax4133wzxUQM9ky8z5XFVf6YLFjJMmTWbWVniZR"},108:{key:"108",name:"Thundercore",chainId:108,network:"mainnet",multicall:"0x3017086deef56679e267f67f66c4415109b7a97f",rpc:["https://mainnet-rpc.thundercore.com/archived/SNAPSHOTEuR82a75fLYA"],explorer:{url:"https://viewblock.io/thundercore"},start:94425385,logo:"ipfs://bafkreifc5z5vtvqx2luzgateyvoocwpd2ifv2hwufxdnyl2a767wa6icli"},109:{key:"109",name:"Shibarium",shortName:"mainnet",chainId:109,network:"mainnet",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:[],explorer:{url:"https://shibariumscan.io"},start:3485946,logo:"ipfs://bafkreig57igai5phg4icywc5yoockd52jo3hlvbkyi6wiufrmu4p2lmenm"},122:{key:"122",name:"Fuse",shortName:"Fuse",chainId:122,network:"mainnet",multicall:"0x7a59441fb06666F6d2D766393d876945D06a169c",rpc:["https://explorer-node.fuse.io/","https://oefusefull1.liquify.info/"],explorer:{url:"https://explorer.fuse.io"},start:11923459,logo:"ipfs://QmXjWb64nako7voaVEifgdjAbDbswpTY8bghsiHpv8yWtb"},137:{key:"137",name:"Polygon PoS",shortName:"Polygon",chainId:137,network:"mainnet",multicall:"0xCBca837161be50EfA5925bB9Cc77406468e76751",rpc:["https://rpc.ankr.com/polygon","https://speedy-nodes-nyc.moralis.io/b9aed21e7bb7bdeb35972c9a/polygon/mainnet/archive","https://speedy-nodes-nyc.moralis.io/f2963e29bec0de5787da3164/polygon/mainnet/archive","https://rpc-mainnet.maticvigil.com/v1/1cfd7598e5ba6dcf0b4db58e8be484badc6ea08e"],ws:["wss://ws-mainnet.matic.network"],explorer:{url:"https://polygonscan.com",apiUrl:"https://api.polygonscan.com"},start:9834491,logo:"ipfs://bafkreihgr7zy7vi5kqddybfaezwuhvssg57qluwmyan4qq7l57nr7w7wey"},144:{key:"144",name:"PHI Network",shortName:"PHI",chainId:144,network:"mainnet",multicall:"0xc2f41B404a6757863AAeF49ff93039421acCd630",rpc:["https://connect.phi.network"],explorer:{url:"https://phiscan.com"},start:360030,logo:"ipfs://bafkreid6pm3mic7izp3a6zlfwhhe7etd276bjfsq2xash6a4s2vmcdf65a"},146:{key:"146",name:"Sonic",shortName:"mainnet",chainId:146,network:"mainnet",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:[],explorer:{url:"https://explorer.soniclabs.com"},start:60,logo:"ipfs://bafkreic5fffatwy2gzf6y5iymje6ijii43tz4wlxl35da36guurhibjx44"},148:{key:"148",name:"ShimmerEVM",shortName:"ShimmerEVM",chainId:148,network:"mainnet",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:[],explorer:{url:"https://explorer.evm.shimmer.network"},start:1290,logo:"ipfs://bafkreib4xhbgbhrwkmizp4d4nz3wzbpyhdm6wpz2v2pbkk7jxsgg3hdt74"},157:{key:"157",name:"Shibarium Puppynet Testnet",shortName:"testnet",chainId:157,network:"testnet",multicall:"0xA4029b74FBA366c926eDFA7Dd10B21C621170a4c",rpc:[],explorer:{url:"https://puppyscan.shib.io"},start:3035769,logo:"ipfs://bafkreig57igai5phg4icywc5yoockd52jo3hlvbkyi6wiufrmu4p2lmenm",testnet:!0},169:{key:"169",name:"Manta Pacific",shortName:"Manta",chainId:169,network:"mainnet",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:[],explorer:{url:"https://www.oklink.com/manta"},start:332890,logo:"ipfs://bafkreibbrwgwdcfh755dqh4ndta6tja77qbaa36bfv4pstub6prhhore7a"},204:{key:"204",name:"opBNB",shortName:"mainnet",chainId:204,network:"mainnet",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:[],explorer:{url:"http://opbnbscan.com"},start:512881,logo:"ipfs://bafkreibll4la7wqerzs7zwxjne2j7ayynbg2wlenemssoahxxj5rbt6c64"},246:{key:"246",name:"Energy Web Chain",shortName:"EWC",chainId:246,network:"mainnet",multicall:"0x0767F26d0D568aB61A98b279C0b28a4164A6f05e",rpc:["https://voting-rpc.carbonswap.exchange"],explorer:{url:"https://explorer.energyweb.org"},start:12086501,logo:"ipfs://Qmai7AGHgs8NpeGeXgbMZz7pS2i4kw44qubCJYGrZW2f3a"},250:{key:"250",name:"Fantom Opera",shortName:"fantom",chainId:250,network:"Mainnet",multicall:"0x7f6A10218264a22B4309F3896745687E712962a0",rpc:["https://rpc.ankr.com/fantom","https://rpc.ftm.tools","https://rpcapi.fantom.network"],explorer:{url:"https://ftmscan.com"},start:2497732,logo:"ipfs://QmVEgNeQDKnXygeGxfY9FywZpNGQu98ktZtRJ9bToYF6g7"},252:{key:"252",name:"Fraxtal",shortName:"mainnet",chainId:252,network:"mainnet",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:[],explorer:{url:"https://fraxscan.com"},start:1,logo:"ipfs://bafkreieflj4wq6tx7k5kq47z3xnsrdrn2xgm4bxa3uovrnndcb2vqqwlyu"},269:{key:"269",name:"High Performance Blockchain",shortName:"HPB",chainId:269,network:"mainnet",multicall:"0x67D0f263aef2F6167FA77353695D75b582Ff4Bca",rpc:["https://hpbnode.com"],ws:["wss://ws.hpbnode.com"],explorer:{url:"https://hscan.org"},start:13960096,logo:"ipfs://QmU7f1MyRz8rLELFfypnWZQjGbDGYgZtC9rjw47jYMYrnu"},296:{key:"296",name:"Hedera Testnet",shortName:"testnet",chainId:296,network:"testnet",multicall:"0xADE3166b0afA89b2CDB64870D70ADeD330Eab015",rpc:[],explorer:{url:"https://hashscan.io/testnet"},start:17561901,logo:"ipfs://bafkreia5gpitwgo4sspvvtwqcxosq2krrqo5dbrnvylgibvmypzotfmbuu",testnet:!0},300:{key:"300",name:"zkSync Sepolia Testnet",shortName:"testnet",chainId:300,network:"testnet",multicall:"0xF9cda624FBC7e059355ce98a31693d299FACd963",rpc:[],explorer:{url:"https://sepolia.explorer.zksync.dev"},start:2292,logo:"ipfs://bafkreih6y7ri7h667cwxe5miisxghfheiidtbw2747y75stoxt3gp3a2yy",testnet:!0},314:{key:"314",name:"Filecoin",shortName:"mainnet",chainId:314,network:"mainnet",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:[],explorer:{url:"https://filfox.io"},start:3328594,logo:"ipfs://bafybeibyvjfmk6aqlfdrczvth55jkmnoadtrch7ht3rdmvqmy2bfxynecm"},321:{key:"321",name:"KCC",shortName:"KCC",chainId:321,network:"mainnet",multicall:"0xa64D6AFb48225BDA3259246cfb418c0b91de6D7a",rpc:["https://rpc-mainnet.kcc.network"],ws:["wss://rpc-ws-mainnet.kcc.network"],explorer:{url:"https://explorer.kcc.io"},start:1487453,logo:"ipfs://QmRdzYGhFRG8QLzMJahHrw3vETE2YZ9sywQbEkenSjKEvb"},324:{key:"324",name:"zkSync Era",shortName:"zkSync-era",chainId:324,network:"zkSync Era Mainnet",multicall:"0xF9cda624FBC7e059355ce98a31693d299FACd963",rpc:["https://mainnet.era.zksync.io"],explorer:{url:"https://explorer.zksync.io"},start:3908235,logo:"ipfs://bafkreih6y7ri7h667cwxe5miisxghfheiidtbw2747y75stoxt3gp3a2yy"},336:{key:"336",name:"Shiden Network",shortName:"Shiden",chainId:336,network:"mainnet",multicall:"0x3E90A35839ff0Aa32992d33d861f24dC95BBf74d",rpc:["https://rpc.shiden.astar.network:8545","https://shiden.api.onfinality.io/public"],explorer:{url:"https://blockscout.com/shiden"},start:1170016,logo:"ipfs://QmcqGQE4Sk73zXc3e91TUFFefKBVeaNgbxV141XkSNE4xj"},369:{key:"369",name:"Pulsechain",shortName:"Pulsechain",chainId:369,network:"mainnet",multicall:"0xdbdd0FD8B16F0092f306392b699D7fbddaA9011B",rpc:["https://rpc.pulsechain.com"],explorer:{url:"https://scan.pulsechain.com"},start:17657774,logo:"ipfs://QmWUsiEWdejtHZ9B9981TYXn7Ds8C7fkB1S4h5rP3kCCZR"},416:{key:"416",name:"SX Network",shortName:"SX",chainId:416,network:"mainnet",multicall:"0x834a005DDCF990Ba1a79f259e840e58F2D14F49a",rpc:["https://rpc.sx.technology"],ws:["wss://rpc.sx.technology/ws"],explorer:{url:"https://explorer.sx.technology"},start:2680605,logo:"ipfs://QmSXLXqyr2H6Ja5XrmznXbWTEvF2gFaL8RXNXgyLmDHjAF"},592:{key:"592",name:"Astar Network",shortName:"Astar",chainId:592,network:"mainnet",multicall:"0x3E90A35839ff0Aa32992d33d861f24dC95BBf74d",rpc:["https://astar.api.onfinality.io/public","https://rpc.astar.network:8545"],explorer:{url:"https://blockscout.com/astar"},start:366482,logo:"ipfs://QmZLQVsUqHBDXutu6ywTvcYXDZG2xBstMfHkfJSzUNpZsc"},813:{key:"813",name:"Qitmeer",shortName:"MEER",chainId:813,network:"mainnet",multicall:"0x55034b2cF530ae3A8fC1e2e4523F58496796610F",rpc:["https://evm-dataseed1.meerscan.io","https://evm-dataseed.meerscan.com","https://evm-dataseed2.meerscan.io","https://evm-dataseed3.meerscan.io"],explorer:{url:"https://evm.meerscan.io"},start:43317,logo:"ipfs://QmXvum7SNVaAqAc2jNzR1NpNZN1GGvNaKWydg8a1GEDQ7y"},841:{key:"841",name:"Taraxa",shortName:"841",chainId:841,network:"mainnet",multicall:"0xFCe7a3121B42664AaD145712e1c2Bf2e38f60AA1",rpc:["https://rpc.mainnet.taraxa.io"],ws:["wss://ws.mainnet.taraxa.io"],explorer:{url:"https://mainnet.explorer.taraxa.io"},start:1515906,logo:"ipfs://Qmcc6ZCAGESMzZzoj5LsTVcCo2E35x3Ydk71uPJyov6Mwx"},888:{key:"888",name:"Wanchain",chainId:888,network:"mainnet",multicall:"0xba5934ab3056fca1fa458d30fbb3810c3eb5145f",rpc:["https://gwan-ssl.wandevs.org:56891"],ws:["wss://api.wanchain.org:8443/ws/v3/ddd16770c68f30350a21114802d5418eafe039b722de52b488e7eee1ee2cd73f"],explorer:{url:"https://www.wanscan.org"},start:11302663,logo:"ipfs://QmewFFN44rkxESFsHG8edaLt1znr62hjvZhGynfXqruzX3"},1001:{key:"1001",name:"Kaia Kairos Testnet",shortName:"kaia-kairos",chainId:1001,network:"testnet",testnet:!0,multicall:"0x40643B8Aeaaca0b87Ea1A1E596e64a0e14B1d244",rpc:["https://archive-en-kairos.node.kaia.io"],ws:["wss://archive-en-kairos.node.kaia.io/ws"],explorer:{url:"https://kairos.kaiascan.com"},start:87232478,logo:"ipfs://bafkreifm6l67f4blcv7qwuszalwoxzptt5ad2f3t472lytr3d2hmi626ju"},1072:{key:"1072",name:"Shimmer EVM Testnet",shortName:"ShimmerEVM",chainId:1072,network:"testnet",testnet:!0,multicall:"0x751d21047C116413895c259f3f305e38C10B7cF6",rpc:["https://archive.evm.testnet.shimmer.network/v1/chains/rms1pr75wa5xuepg2hew44vnr28wz5h6n6x99zptk2g68sp2wuu2karywgrztx3/evm"],explorer:{url:"https://explorer.evm.testnet.shimmer.network"},start:10614,logo:"ipfs://bafkreihtwfwrue7klzedwx4rqlk6agklz4lbbk7owsyw6xzn6c2m4t5tgy"},1088:{key:"1088",name:"Metis",shortName:"metis",chainId:1088,network:"mainnet",multicall:"0xc39aBB6c4451089dE48Cffb013c39d3110530e5C",rpc:["https://andromeda.metis.io/?owner=1088"],explorer:{url:"https://andromeda-explorer.metis.io"},start:451,logo:"ipfs://bafkreiaqr4atnjpdnk3c4vu4377ai7bzqpgaefefbl5j5imfsvr4puimtu"},1101:{key:"1101",name:"Polygon zkEVM",shortName:"mainnet",chainId:1101,network:"mainnet",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:[],explorer:{url:"https://zkevm.polygonscan.com"},start:57746,logo:"ipfs://bafkreibfiyvhqnme2vbxxfcku7qkxgjpkg6ywdkplxh4oxlkqsbznyorfm"},1116:{key:"1116",name:"Core Chain",shortName:"Core",chainId:1116,network:"mainnet",multicall:"0x024f0041b76B598c2A0a75004F8447FaF67BD004",rpc:["https://rpcar.coredao.org/"],explorer:{url:"https://scan.coredao.org"},start:853908,logo:"ipfs://bafkreigjv5yb7uhlrryzib7j2f73nnwqan2tmfnwjdu26vkk365fyesoiu"},1284:{key:"1284",name:"Moonbeam",shortName:"GLMR",chainId:1284,network:"mainnet",multicall:"0x83e3b61886770de2F64AAcaD2724ED4f08F7f36B",rpc:["https://rpc.api.moonbeam.network"],explorer:{url:"https://moonscan.io"},start:171135,logo:"ipfs://QmWKTEK2pj5sBBbHnMHQbWgw6euVdBrk2Ligpi2chrWASk"},1285:{key:"1285",name:"Moonriver (Kusama)",shortName:"Moonriver",chainId:1285,network:"mainnet",multicall:"0x537004440ffFE1D4AE9F009031Fc2b0385FCA9F1",rpc:["https://rpc.api.moonriver.moonbeam.network"],explorer:{url:"https://blockscout.moonriver.moonbeam.network"},start:413539,logo:"ipfs://QmXtgPesL87Ejhq2Y7yxsaPYpf4RcnoTYPJWPcv6iiYhoi"},1287:{key:"1287",name:"Moonbase Alpha TestNet",shortName:"Moonbase",chainId:1287,network:"testnet",testnet:!0,multicall:"0xf09FD6B6FF3f41614b9d6be2166A0D07045A3A97",rpc:["https://rpc.testnet.moonbeam.network"],explorer:{url:"https://moonbase-blockscout.testnet.moonbeam.network"},start:859041,logo:"ipfs://QmeGbNTU2Jqwg8qLTMGW8n8HSi2VdgCncAaeGzLx6gYnD7"},1315:{key:"1315",name:"Story Aeneid Testnet",shortName:"testnet",chainId:1315,network:"testnet",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:[],explorer:{url:"https://aeneid.storyscan.io"},start:1792,logo:"ipfs://bafkreiaicdywqkmej6htv4e4lnq5fzajb3qfoxslkrbf5byvqc2aalxcne",testnet:!0},1328:{key:"1328",name:"Sei atlantic testnet",shortName:"testnet",chainId:1328,network:"testnet",multicall:"0xc454132B017b55b427f45078E335549A7124f5f7",rpc:[],explorer:{url:"https://seitrace.com"},start:96978658,logo:"ipfs://bafkreiammyt7uztbztqbcqv4bydnczsh2fqmnjf6jxj4xnskzzl6sjrigq",testnet:!0},1329:{key:"1329",name:"Sei",shortName:"mainnet",chainId:1329,network:"mainnet",multicall:"0xe033Bed7cae4114Af84Be1e9F1CA7DEa07Dfe1Cf",rpc:[],explorer:{url:"https://seitrace.com"},start:79164574,logo:"ipfs://bafkreiammyt7uztbztqbcqv4bydnczsh2fqmnjf6jxj4xnskzzl6sjrigq"},1480:{key:"1480",name:"Vana",shortName:"mainnet",chainId:1480,network:"mainnet",multicall:"0xD8d2dFca27E8797fd779F8547166A2d3B29d360E",rpc:[],explorer:{url:"https://islander.vanascan.io"},start:716763,logo:"ipfs://bafkreibotel3dmc5og5rf3tpt7l74awkene7x6q3oxtwhptt4y4rpa7vsa"},1514:{key:"1514",name:"Story",shortName:"mainnet",chainId:1514,network:"mainnet",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:[],explorer:{url:"https://www.storyscan.io"},start:340998,logo:"ipfs://bafkreiaicdywqkmej6htv4e4lnq5fzajb3qfoxslkrbf5byvqc2aalxcne"},1559:{key:"1559",name:"Tenet",shortName:"tenet",chainId:1559,network:"mainnet",multicall:"0xcCB3F00bE353950E4C08501ac8Af48765EAAa738",rpc:[],explorer:{url:"https://tenetscan.io"},start:944415,logo:"ipfs://Qmc1gqjWTzNo4pyFSGtQuCu7kRSZZBUVybtTjHn2nNEEPA"},1663:{key:"1663",name:"Horizen Gobi Testnet",shortName:"Gobi",chainId:1663,network:"testnet",testnet:!0,multicall:"0xC743e4910Bdd4e5aBacCA38F74cdA270281C5eef",rpc:["https://gobi-testnet.horizenlabs.io/ethv1"],explorer:{url:"https://gobi-explorer.horizen.io"},start:1,logo:"ipfs://QmUYQdsnkUoiDiQ3WaWrtH7fsc5yQDC7kZJCHmC2qWPTPt"},2e3:{key:"2000",name:"Doge Chain",shortName:"dogechain",chainId:2e3,network:"mainnet",multicall:"0x6f9D3f3932B417bd4957585D236Cbc32b32C0BDc",rpc:["https://rpc.dogechain.dog"],explorer:{url:"https://explorer.dogechain.dog"},start:877115,logo:"ipfs://bafkreigovfh3pinsdih777issfgaflwu2yjzroljs2642gbvwikcd3nm4i"},2109:{key:"2109",name:"Exosama Network",shortName:"EXN",chainId:2109,network:"mainnet",multicall:"0x2feFC828e2fEfdE0C9f7740919c6A9139F886067",rpc:["https://rpc.exosama.com"],explorer:{url:"https://explorer.exosama.com"},start:94085,logo:"ipfs://QmaQxfwpXYTomUd24PMx5tKjosupXcm99z1jL1XLq9LWBS"},2152:{key:"2152",name:"Findora",shortName:"Findora",chainId:2152,network:"mainnet",multicall:"0xCF7D1e21CBe9bdEF235aef06C5d8051B3d4DF0f5",rpc:["https://archive.prod.findora.org:8545/"],explorer:{url:"https://evm.findorascan.io"},start:4219343,logo:"ipfs://QmXkneyRB6HbHTHRLCZpZqSsawiyJY7b2kZ2V8ydvKYAgv"},2192:{key:"2192",name:"SnaxChain",shortName:"mainnet",chainId:2192,network:"mainnet",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:[],explorer:{url:"https://explorer.snaxchain.io"},start:1554893,logo:"ipfs://bafkreibzz757piho2llzkbiszpvalf5k5hpmxcwhvrmgp7vpz2vp4vj7ly"},2221:{key:"2221",name:"Kava Testnet",shortName:"testnet",chainId:2221,network:"testnet",multicall:"0xc7193EFE367DF0C9349a1149F4E95A2A35604262",rpc:[],explorer:{url:"https://testnet.kavascan.com"},start:6193104,logo:"ipfs://bafkreibpfubharx32fjqkqbfdhygwdjb2khxdg6meaasrcxsgvowos26f4",testnet:!0},2222:{key:"2222",name:"Kava",shortName:"mainnet",chainId:2222,network:"mainnet",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:[],explorer:{url:"https://kavascan.com"},start:3661165,logo:"ipfs://bafkreibpfubharx32fjqkqbfdhygwdjb2khxdg6meaasrcxsgvowos26f4"},2400:{key:"2400",name:"TCG Verse",shortName:"TCGV",chainId:2400,network:"mainnet",multicall:"0xceC65DEE0b5012F1b7321b2647681F997c7204FC",rpc:["https://rpc.tcgverse.xyz"],explorer:{url:"https://explorer.tcgverse.xyz"},start:57500,logo:"ipfs://bafkreidg4wpewve5mdxrofneqblydkrjl3oevtgpdf3fk3z3vjqam6ocoe"},2522:{key:"2522",name:"Fraxtal Testnet",shortName:"testnet",chainId:2522,network:"testnet",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:[],explorer:{url:"https://holesky.fraxscan.com"},start:1,logo:"ipfs://bafkreieflj4wq6tx7k5kq47z3xnsrdrn2xgm4bxa3uovrnndcb2vqqwlyu",testnet:!0},3338:{key:"3338",name:"peaq",shortName:"mainnet",chainId:3338,network:"mainnet",multicall:"0xc454132B017b55b427f45078E335549A7124f5f7",rpc:[],explorer:{url:"https://peaq.subscan.io"},start:3525964,logo:"ipfs://bafkreidqkleori7pmilesz4t52iebebaqf3oflzmoz646qfuaznanb3sgm"},4162:{key:"4162",name:"SX Rollup",shortName:"mainnet",chainId:4162,network:"mainnet",multicall:"0x46997eb05F6A6A0bD5C140ABed09Cb02CA36b98c",rpc:[],explorer:{url:"https://explorerl2.sx.technology"},start:1847483,logo:"ipfs://bafkreibjkjx7evbw74e3sx65dtmcdr4g2rrbcorb2ivd6jz6yh6on6ozw4"},4200:{key:"4200",name:"Merlin",shortName:"merlin",chainId:4200,network:"mainnet",multicall:"0x830E7E548F4D80947a40A7Cf3a2a53166a0C3980",rpc:[],explorer:{url:"https://scan.merlinchain.io"},start:589494,logo:"ipfs://bafkreicew2qv3m756m7xs2nrjezinghps7rlessrqjqetvox74w4hov2xe"},4337:{key:"4337",name:"Beam",shortName:"Beam",chainId:4337,network:"mainnet",multicall:"0x4956F15eFdc3dC16645e90Cc356eAFA65fFC65Ec",rpc:[],explorer:{url:"https://subnets.avax.network/beam"},start:1,logo:"ipfs://QmaKRLxXPdeTsLx7MFLS3CJbhpSbResgoeL4fCgHB1mTsF"},4689:{key:"4689",name:"IoTeX",shortName:"IoTeX",chainId:4689,network:"mainnet",multicall:"0x9c8B105c94282CDB0F3ecF27e3cfA96A35c07be6",rpc:["https://babel-api.mainnet.iotex.io"],explorer:{url:"https://iotexscan.io"},start:11533283,logo:"ipfs://QmNkr1UPcBYbvLp7d7Pk4eF3YCsHpaNkfusKZNtykL2EQC"},5e3:{key:"5000",name:"Mantle",chainId:5e3,network:"mainnet",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:["https://rpc.mantle.xyz"],explorer:{url:"https://mantlescan.xyz"},start:304717,logo:"ipfs://bafkreidkucwfn4mzo2gtydrt2wogk3je5xpugom67vhi4h4comaxxjzoz4"},5555:{key:"5555",name:"Chain Verse",shortName:"ChainVerse",chainId:5555,network:"ChainVerse",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:["https://rpc.chainverse.info"],explorer:{url:"https://explorer.chainverse.info"},start:6334180,logo:"ipfs://QmQyJt28h4wN3QHPXUQJQYQqGiFUD77han3zibZPzHbitk"},5611:{key:"5611",name:"opBNB Testnet",shortName:"testnet",chainId:5611,network:"testnet",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:[],explorer:{url:"https://opbnb-testnet.bscscan.com"},start:3705108,logo:"ipfs://bafkreibll4la7wqerzs7zwxjne2j7ayynbg2wlenemssoahxxj5rbt6c64",testnet:!0},6102:{key:"6102",name:"Cascadia Testnet",shortName:"Cascadia",chainId:6102,network:"testnet",multicall:"0x728989819bAD588F193563008E0a03E8cD6a3e4a",rpc:["https://testnet.cascadia.foundation"],explorer:{url:"https://explorer.cascadia.foundation"},testnet:!0,start:370457,logo:"ipfs://QmWkhZYhReYyaa5pQXj32hEGxoRcBqarFMcfQScELmjYQj"},6900:{key:"6900",name:"Animechain Testnet",shortName:"testnet",chainId:6900,network:"testnet",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:[],explorer:{url:"https://explorer-animechain-testnet-i8yja6a1a0.t.conduit.xyz"},start:1666749,logo:"ipfs://bafkreihm7dy6jzkd3nh6mokq4vshuzwkoeyjmbb3qkskn77rt5iufn7egi",testnet:!0},7332:{key:"7332",name:"Horizen EON",shortName:"EON",chainId:7332,network:"mainnet",multicall:"0xC743e4910Bdd4e5aBacCA38F74cdA270281C5eef",rpc:[],explorer:{url:"https://eon-explorer.horizenlabs.io"},start:85108,logo:"ipfs://QmUYQdsnkUoiDiQ3WaWrtH7fsc5yQDC7kZJCHmC2qWPTPt"},7341:{key:"7341",name:"Shyft",shortName:"Shyft",chainId:7341,network:"mainnet",multicall:"0xceb10e9133D771cA93c8002Be527A465E85381a2",rpc:["https://rpc.shyft.network"],explorer:{url:"https://bx.shyft.network"},start:3673983,logo:"ipfs://bafkreifwxnnfk6koabzmxgcxcwlrwt6b5gijdain2gyqee77q4ajfb7fu4"},7560:{key:"7560",name:"Cyber",shortName:"mainnet",chainId:7560,network:"mainnet",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:[],explorer:{url:"https://cyberscan.co"},start:1731707,logo:"ipfs://bafkreifm2bbehoqpz4454o7gixnxfi6cgvqlxigqr3f6ipj7l2omtgfgnm"},8217:{key:"8217",name:"Kaia Mainnet",shortName:"kaia-mainnet",chainId:8217,network:"mainnet",multicall:"0x5f5f0d1b9ff8b3dcace308e39b13b203354906e9",rpc:["https://archive-en.node.kaia.io"],ws:["wss://archive-en.node.kaia.io/ws"],explorer:{url:"https://kaiascan.com"},start:91582357,logo:"ipfs://bafkreifm6l67f4blcv7qwuszalwoxzptt5ad2f3t472lytr3d2hmi626ju"},8453:{key:"8453",name:"Base",shortName:"mainnet",chainId:8453,network:"mainnet",multicall:"0xca11bde05977b3631167028862be2a173976ca11",rpc:[],explorer:{url:"https://basescan.org"},start:5022,logo:"ipfs://QmaxRoHpxZd8PqccAynherrMznMufG6sdmHZLihkECXmZv"},9001:{key:"9001",name:"Evmos Network",shortName:"Evmos",chainId:9001,network:"mainnet",multicall:"0x37763d16f8dBf6F185368E0f256350cAb7E24b26",rpc:["https://eth.bd.evmos.org:8545"],ws:["wss://eth.bd.evmos.org:8546"],explorer:{url:"https://escan.live"},start:13959539,logo:"ipfs://bafkreif4obrdoiretpozdd56seziywc6clha7wwkbldng3ovry2bpzly34"},9990:{key:"9990",name:"Agung testnet",shortName:"testnet",chainId:9990,network:"testnet",multicall:"0xc454132B017b55b427f45078E335549A7124f5f7",rpc:[],explorer:{url:"https://agung-testnet.subscan.io"},start:2031789,logo:"ipfs://bafkreidqkleori7pmilesz4t52iebebaqf3oflzmoz646qfuaznanb3sgm",testnet:!0},1e4:{key:"10000",name:"smartBCH",shortName:"BCH",chainId:1e4,network:"mainnet",multicall:"0x1b38EBAd553f218e2962Cb1C0539Abb5d6A37774",rpc:["https://smartbch.greyh.at/"],explorer:{url:"https://smartbch-explorer.web.app"},start:268248,logo:"ipfs://QmWG1p7om4hZ4Yi4uQvDpxg4si7qVYhtppGbcDGrhVFvMd"},10243:{key:"10243",name:"Arthera Testnet",shortName:"Arthera_",chainId:10243,network:"testnet",testnet:!0,multicall:"0x27c7FC597aD2E81C4c1cA1769972f79DaF042Da7",rpc:["https://rpc-test.arthera.net"],explorer:{url:"https://explorer-test.arthera.net"},start:10523,logo:"ipfs://QmYQp3e52KjkT4bYdAvB6ACEEpXs2D8DozsDitaADRY2Ak"},13337:{key:"13337",name:"Beam Testnet",shortName:"testnet",chainId:13337,network:"testnet",multicall:"0x9BF49b704EE2A095b95c1f2D4EB9010510c41C9E",rpc:[],explorer:{url:"https://subnets-test.avax.network/beam"},start:3,logo:"ipfs://QmaKRLxXPdeTsLx7MFLS3CJbhpSbResgoeL4fCgHB1mTsF",testnet:!0},13371:{key:"13371",name:"Immutable zkEVM",shortName:"mainnet",chainId:13371,network:"mainnet",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:[],explorer:{url:"https://explorer.immutable.com"},start:3680945,logo:"ipfs://bafkreiepnhfv3hgexddjpyaeemxo3byhtxxit6t4zsponyczee6ddjqxwi"},13473:{key:"13473",name:"Immutable zkEVM Testnet",shortName:"testnet",chainId:13473,network:"testnet",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:[],explorer:{url:"https://explorer.testnet.immutable.com"},start:5307209,logo:"ipfs://bafkreiepnhfv3hgexddjpyaeemxo3byhtxxit6t4zsponyczee6ddjqxwi",testnet:!0},14800:{key:"14800",name:"Vana Moksha Testnet",shortName:"testnet",chainId:14800,network:"testnet",multicall:"0xD8d2dFca27E8797fd779F8547166A2d3B29d360E",rpc:[],explorer:{url:"https://moksha.vanascan.io"},start:732283,logo:"ipfs://bafkreibotel3dmc5og5rf3tpt7l74awkene7x6q3oxtwhptt4y4rpa7vsa",testnet:!0},16718:{key:"16718",name:"AirDAO",chainId:16718,network:"mainnet",multicall:"0x25e81aC81A8B03389D78CB45faB78353aB528574",rpc:["https://network-archive.ambrosus.io"],ws:["wss://network-archive.ambrosus.io/ws"],explorer:{url:"https://airdao.io/explorer"},start:22922566,logo:"ipfs://QmSxXjvWng3Diz4YwXDV2VqSPgMyzLYBNfkjJcr7rzkxom"},29548:{key:"29548",name:"MCH Verse",shortName:"mainnet",chainId:29548,network:"mainnet",multicall:"0x1d39652386488CE1fE4254E105F5A42a04d43dB2",rpc:[],explorer:{url:"https://explorer.oasys.mycryptoheroes.net"},start:27458402,logo:"ipfs://QmZZnwR1y6cU1sare2TQmwqkNDLXQxD4GdPrmHLmUoPtbU"},33111:{key:"33111",name:"Curtis",shortName:"apechain",chainId:33111,network:"testnet",multicall:"0xc454132B017b55b427f45078E335549A7124f5f7",rpc:[],explorer:{url:"https://curtis.apescan.io"},start:6661339,logo:"ipfs://bafkreicljxttjq2xkgfwwpii5xegirgq2ctrnsjnzelxudjj33qzq65apu",testnet:!0},33139:{key:"33139",name:"ApeChain",shortName:"mainnet",chainId:33139,network:"mainnet",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:[],explorer:{url:"https://apescan.io"},start:20889,logo:"ipfs://bafkreielbgcox2jsw3g6pqulqb7pyjgx7czjt6ahnibihaij6lozoy53w4"},42161:{key:"42161",name:"Arbitrum One",chainId:42161,network:"Arbitrum mainnet",multicall:"0x7A7443F8c577d537f1d8cD4a629d40a3148Dd7ee",rpc:["https://rpc.ankr.com/arbitrum","https://speedy-nodes-nyc.moralis.io/9e03baabdc27be2a35bdec4a/arbitrum/mainnet","https://arb-mainnet.g.alchemy.com/v2/JDvtNGwnHhTltIwfnxQocKwKkCTKA1DL"],explorer:{url:"https://arbiscan.io"},start:256508,logo:"ipfs://QmWZ5SMRfvcK8tycsDqojQaSiKedgtVkS7CkZdxPgeCVsZ"},42170:{key:"42170",name:"Arbitrum Nova",chainId:42170,network:"Arbitrum Nova",multicall:"0x4E74EBd9CABff51cE9a43EFe059bA8c5A28E4A14",rpc:["https://nova.arbitrum.io/rpc","https://arbitrum-nova.public.blastapi.io"],explorer:{url:"https://nova.arbiscan.io"},start:6006607,logo:"ipfs://bafkreie5xsqt3mrrwu7v32qpmmctibhzhgxf4emfzzddsdhdlfsa7fmplu"},42220:{key:"42220",name:"Celo",shortName:"Celo",chainId:42220,network:"mainnet",multicall:"0xb8d0d2C1391eeB350d2Cd39EfABBaaEC297368D9",rpc:["https://celo.snapshot.org","https://forno.celo.org","https://celo-mainnet--rpc.datahub.figment.io/apikey/e892a66dc36e4d2d98a5d6406d609796/"],explorer:{url:"https://explorer.celo.org"},start:6599803,logo:"ipfs://QmS2tVJ7rdJRe1NHXAi2L86yCbUwVVrmB2mHQeNdJxvQti"},43113:{key:"43113",name:"Avalanche FUJI Testnet",chainId:43113,network:"testnet",testnet:!0,multicall:"0x984476ea55e32e785A9D8FF14329f99D74E3d2A2",rpc:["https://api.avax-test.network/ext/bc/C/rpc"],explorer:{url:"https://testnet.snowtrace.io"},start:10528153,logo:"ipfs://QmeS75uS7XLR8o8uUzhLRVYPX9vMFf4DXgKxQeCzyy7vM2"},43114:{key:"43114",name:"Avalanche",chainId:43114,network:"mainnet",multicall:"0x7E9985aE4C8248fdB07607648406a48C76e9e7eD",rpc:["https://nd-784-543-849.p2pify.com/aa7b29fc5fed65b34f0ee6b8de33f8c0/ext/bc/C/rpc","https://rpc.ankr.com/avalanche","https://api.avax.network/ext/bc/C/rpc"],explorer:{url:"https://snowtrace.io"},start:536483,logo:"ipfs://QmeS75uS7XLR8o8uUzhLRVYPX9vMFf4DXgKxQeCzyy7vM2"},47805:{key:"47805",name:"REI Mainnet",chainId:47805,network:"mainnet",multicall:"0x9eE9904815B80C39C1a27294E69a8626EAa7952d",rpc:["https://rpc.rei.network"],explorer:{url:"https://scan.rei.network"},start:1715902,logo:"ipfs://QmTogMDLmDgJjDjUKDHDuc2KVTVDbXf8bXJLFiVe8PRxgo"},53935:{key:"53935",name:"DFK Chain",chainId:53935,network:"mainnet",multicall:"0x5b24224dC16508DAD755756639E420817DD4c99E",rpc:["https://subnets.avax.network/defi-kingdoms/dfk-chain/rpc"],explorer:{url:"https://subnets.avax.network/defi-kingdoms"},start:62,logo:"ipfs://QmZNkpVgPbuVbDcsi6arwH1om3456FGnwfDqYQJWUfHDEx"},57054:{key:"57054",name:"Sonic Blaze Testnet",shortName:"testnet",chainId:57054,network:"testnet",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:[],explorer:{url:"https://testnet.sonicscan.org"},start:60,logo:"ipfs://bafkreic5fffatwy2gzf6y5iymje6ijii43tz4wlxl35da36guurhibjx44",testnet:!0},57073:{key:"57073",name:"Ink",shortName:"mainnet",chainId:57073,network:"mainnet",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:[],explorer:{url:"https://explorer.inkonchain.com"},start:6659154,logo:"ipfs://bafkreics2duafru4mw36wftcmklgrsgq6fz4lgcjctzmov34bxjzuuypju"},59141:{key:"59141",name:"Linea Sepolia",shortName:"testnet",chainId:59141,network:"testnet",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:[],explorer:{url:"https://sepolia.lineascan.build"},start:227427,logo:"ipfs://bafkreihtyzolub3sejuwc32hpdpjnt7ksowaguni2yuho3kyihhcqrtqce",testnet:!0},59144:{key:"59144",name:"Linea",shortName:"linea",chainId:59144,network:"mainnet",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:[],explorer:{url:"https://lineascan.build"},start:42,logo:"ipfs://bafkreihtyzolub3sejuwc32hpdpjnt7ksowaguni2yuho3kyihhcqrtqce"},69e3:{key:"69000",name:"Animechain",shortName:"mainnet",chainId:69e3,network:"mainnet",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:[],explorer:{url:"https://explorer-animechain-39xf6m45e3.t.conduit.xyz"},start:23482,logo:"ipfs://bafkreihm7dy6jzkd3nh6mokq4vshuzwkoeyjmbb3qkskn77rt5iufn7egi"},80001:{key:"80001",name:"Polygon Mumbai",chainId:80001,network:"testnet",testnet:!0,multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:["https://speedy-nodes-nyc.moralis.io/9e03baabdc27be2a35bdec4a/polygon/mumbai/archive","https://rpc-mumbai.matic.today"],ws:["wss://ws-mumbai.matic.today"],explorer:{url:"https://mumbai.polygonscan.com",apiUrl:"https://api-mumbai.polygonscan.com"},start:12011090,logo:"ipfs://bafkreihgr7zy7vi5kqddybfaezwuhvssg57qluwmyan4qq7l57nr7w7wey"},80002:{key:"80002",name:"Polygon Amoy Testnet",shortName:"testnet",chainId:80002,network:"testnet",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:[],explorer:{url:"https://amoy.polygonscan.com"},start:3127388,logo:"ipfs://bafkreibfiyvhqnme2vbxxfcku7qkxgjpkg6ywdkplxh4oxlkqsbznyorfm",testnet:!0},81457:{key:"81457",name:"Blast",shortName:"mainnet",chainId:81457,network:"mainnet",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:[],explorer:{url:"https://blastscan.io"},start:88189,logo:"ipfs://bafkreicqhrimt2zyp2kvhmbpvffxlmxovkg5vw6zkissyzibcfy45kbvrm"},84532:{key:"84532",name:"Base Sepolia",shortName:"testnet",chainId:84532,network:"testnet",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:[],explorer:{url:"https://base-sepolia.blockscout.com"},start:1059647,logo:"ipfs://QmaxRoHpxZd8PqccAynherrMznMufG6sdmHZLihkECXmZv",testnet:!0},314159:{key:"314159",name:"Filecoin Calibration Testnet",shortName:"testnet",chainId:314159,network:"testnet",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:[],explorer:{url:"https://calibration.filscan.io/en"},start:1446201,logo:"ipfs://bafkreiffbopdjior7li3nlemzko7rjua6wd2hfh2vhdbenqbv4tfsbnzwu",testnet:!0},686868:{key:"686868",name:"Merlin Testnet",shortName:"merlin",chainId:686868,network:"testnet",multicall:"0x758BC6321b7c68F4986d62a4D46E83A2DCb58c80",rpc:[],explorer:{url:"https://testnet-scan.merlinchain.io"},start:3562021,logo:"ipfs://bafkreicew2qv3m756m7xs2nrjezinghps7rlessrqjqetvox74w4hov2xe",testnet:!0},713715:{key:"713715",name:"Sei EVM Devnet",shortName:"devnet",chainId:713715,network:"testnet",multicall:"0xEe8d287B844959ADe40d718Dc23077ba920e2f07",rpc:[],explorer:{url:"https://seitrace.com"},start:1463669,logo:"ipfs://bafkreiammyt7uztbztqbcqv4bydnczsh2fqmnjf6jxj4xnskzzl6sjrigq",testnet:!0},763373:{key:"763373",name:"Ink Sepolia",shortName:"testnet",chainId:763373,network:"testnet",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:[],explorer:{url:"https://explorer-sepolia.inkonchain.com"},start:9701940,logo:"ipfs://bafkreics2duafru4mw36wftcmklgrsgq6fz4lgcjctzmov34bxjzuuypju",testnet:!0},810180:{key:"810180",name:"zkLink Nova",shortName:"zlink",chainId:810180,network:"mainnet",multicall:"0x825267E0fA5CAe92F98540828a54198dcB3Eaeb5",rpc:[],explorer:{url:"https://explorer.zklink.io"},start:146055,logo:"ipfs://bafkreic6c3iems5235qapyhyrygha7akqrsfact2nok3y2uhljpzxrdu74"},810181:{key:"810181",name:"zkLink Nova Sepolia",shortName:"testnet",chainId:810181,network:"testnet",multicall:"0x97148F8fDdd9A1620f72EC1Bb2932916623d9da5",rpc:[],explorer:{url:"https://sepolia.explorer.zklink.io"},start:43723,logo:"ipfs://bafkreic6c3iems5235qapyhyrygha7akqrsfact2nok3y2uhljpzxrdu74",testnet:!0},11155111:{key:"11155111",name:"Sepolia testnet",shortName:"Sepolia",chainId:11155111,network:"sepolia",testnet:!0,multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:["https://sepolia.infura.io/v3/d26b4fd748814fe994b05899fd89e667"],ensResolvers:["0x8FADE66B79cC9f707aB26799354482EB93a5B7dD"],ensNameWrapper:"0x0635513f179D50A207757E05759CbD106d7dFcE8",ensSubgraph:"https://subgrapher.snapshot.org/subgraph/arbitrum/DmMXLtMZnGbQXASJ7p1jfzLUbBYnYUD9zNBTxpkjHYXV",explorer:{url:"https://sepolia.etherscan.io",apiUrl:"https://api-sepolia.etherscan.io"},start:751532,logo:"ipfs://bafkreid7ndxh6y2ljw2jhbisodiyrhcy2udvnwqgon5wgells3kh4si5z4"},11155420:{key:"11155420",name:"OP Sepolia",shortName:"testnet",chainId:11155420,network:"testnet",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:[],explorer:{url:"https://sepolia-optimism.etherscan.io"},start:1620204,logo:"ipfs://QmfF4kwhGL8QosUXvgq2KWCmavhKBvwD6kbhs7L4p5ZAWb",testnet:!0},111557560:{key:"111557560",name:"Cyber Testnet",shortName:"testnet",chainId:111557560,network:"testnet",multicall:"0xffc391F0018269d4758AEA1a144772E8FB99545E",rpc:[],explorer:{url:"https://testnet.cyberscan.co"},start:304545,logo:"ipfs://bafkreifm2bbehoqpz4454o7gixnxfi6cgvqlxigqr3f6ipj7l2omtgfgnm",testnet:!0},168587773:{key:"168587773",name:"Blast Sepolia",shortName:"testnet",chainId:168587773,network:"testnet",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:[],explorer:{url:"https://sepolia.blastexplorer.io"},start:756690,logo:"ipfs://bafkreibfmkjg22cozxppzcoxswj45clvh2rqhxzax57cmmgudbtkf4dkce",testnet:!0},245022926:{key:"245022926",name:"Neon Devnet",shortName:"devnet",chainId:245022926,network:"testnet",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:[],explorer:{url:"https://devnet.neonscan.org"},start:205206112,logo:"ipfs://QmecRPQGa4bU7tybg1sUQY48Md9rWnmhrT6WW5ueqvhg6P",testnet:!0},1313161554:{key:"1313161554",name:"Aurora",shortName:"Aurora",chainId:1313161554,network:"mainnet",multicall:"0x32b50c286DEFd2932a0247b8bb940b78c063F16c",rpc:["https://mainnet.aurora.dev"],explorer:{url:"https://explorer.mainnet.aurora.dev"},start:57190533,logo:"ipfs://QmeRhsR1UPRTQCizdhmgr2XxphXebVKU5di97uCV2UMFpa"},16666e5:{key:"1666600000",name:"Harmony",shortName:"HarmonyMainnet",chainId:16666e5,network:"mainnet",multicall:"0x9c31392D2e0229dC4Aa250F043d46B9E82074BF8",rpc:["https://a.api.s0.t.hmny.io"],ws:["wss://ws.s0.t.hmny.io"],explorer:{url:"https://explorer.harmony.one"},start:10911984,logo:"ipfs://QmNnGPr1CNvj12SSGzKARtUHv9FyEfE5nES73U4vBWQSJL"},16667e5:{key:"1666700000",name:"Harmony Testnet",shortName:"HarmonyTestnet",chainId:16667e5,network:"testnet",testnet:!0,multicall:"0x9923589503Fd205feE3d367DDFF2378f0F7dD2d4",rpc:["https://api.s0.b.hmny.io"],ws:["wss://ws.s0.b.hmny.io"],explorer:{url:"https://explorer.pops.one"},start:7521509,logo:"ipfs://QmNnGPr1CNvj12SSGzKARtUHv9FyEfE5nES73U4vBWQSJL"}};class DP{constructor(t,e,r,i){this.proposal=t,this.votes=e,this.strategies=r,this.selected=i}static isValidChoice(t,e){return"number"==typeof t&&void 0!==(null==e?void 0:e[t-1])}getValidVotes(){return this.votes.filter((t=>DP.isValidChoice(t.choice,this.proposal.choices)))}getScores(){return this.proposal.choices.map(((t,e)=>{const r=this.getValidVotes().filter((t=>t.choice===e+1));return r.reduce(((t,e)=>t+e.balance),0)}))}getScoresByStrategy(){return this.proposal.choices.map(((t,e)=>{const r=this.strategies.map(((t,r)=>{const i=this.getValidVotes().filter((t=>t.choice===e+1));return i.reduce(((t,e)=>t+e.scores[r]),0)}));return r}))}getScoresTotal(){return this.votes.reduce(((t,e)=>t+e.balance),0)}getChoiceString(){return this.proposal.choices[this.selected-1]}}class $P{constructor(t,e,r,i){this.proposal=t,this.votes=e,this.strategies=r,this.selected=i}static isValidChoice(t,e){return Array.isArray(t)&&t.every((t=>void 0!==(null==e?void 0:e[t-1])))&&t.length===new Set(t).size}getValidVotes(){return this.votes.filter((t=>$P.isValidChoice(t.choice,this.proposal.choices)))}getScores(){return this.proposal.choices.map(((t,e)=>this.getValidVotes().filter((t=>t.choice.includes(e+1))).reduce(((t,e)=>t+e.balance),0)))}getScoresByStrategy(){return this.proposal.choices.map(((t,e)=>this.strategies.map(((t,r)=>this.getValidVotes().filter((t=>t.choice.includes(e+1))).reduce(((t,e)=>t+e.scores[r]),0)))))}getScoresTotal(){return this.votes.reduce(((t,e)=>t+e.balance),0)}getChoiceString(){return this.selected?this.proposal.choices.filter(((t,e)=>this.selected.includes(e+1))).join(", "):""}}function LP(t,e){const r=t/e.reduce(((t,e)=>t+e),0);return isNaN(r)?0:r}function FP(t,e){return Math.sqrt(t*e)}function UP(t){return t*t}function qP(t,e){return t.map((t=>e*t))}class VP{constructor(t,e,r,i){this.proposal=t,this.votes=e,this.strategies=r,this.selected=i}static isValidChoice(t,e){return"object"==typeof t&&!Array.isArray(t)&&null!==t&&Object.keys(t).every((t=>void 0!==(null==e?void 0:e[Number(t)-1])))&&Object.keys(t).length>0&&Object.values(t).every((t=>"number"==typeof t&&t>=0))&&Object.values(t).some((t=>"number"==typeof t&&t>0))}getValidVotes(){return this.votes.filter((t=>VP.isValidChoice(t.choice,this.proposal.choices)))}getScores(){const t=this.getValidVotes(),e=this.getValidVotes().reduce(((t,e)=>t+e.balance),0),r=this.proposal.choices.map(((e,r)=>{const i=t.map((t=>FP(LP(t.choice[r+1],Object.values(t.choice)),t.balance))).reduce(((t,e)=>t+e),0);return UP(i)}));return qP(r.map(((t,e)=>LP(r[e],r))),e)}getScoresByStrategy(){const t=this.getValidVotes(),e=this.getValidVotes().reduce(((t,e)=>t+e.balance),0),r=this.proposal.choices.map(((e,r)=>this.strategies.map(((e,i)=>t.map((t=>FP(LP(t.choice[r+1],Object.values(t.choice)),t.scores[i]))).reduce(((t,e)=>t+e),0))))).map((t=>t.map((t=>[UP(t)]))));return r.map(((t,i)=>qP(this.strategies.map(((t,e)=>LP(r[i][e][0],r.flat(2)))),e)))}getScoresTotal(){return this.votes.reduce(((t,e)=>t+e.balance),0)}getChoiceString(){return this.proposal.choices.map(((t,e)=>{if(this.selected[e+1]){const r=LP(this.selected[e+1],Object.values(this.selected));return`${Math.round(1e3*r)/10}% for ${t}`}})).filter((t=>null!=t)).join(", ")}}function HP(t,e){const r=[...new Set(t.map((t=>t[0])).flat())],i=Object.entries(t.reduce(((t,[e],r,i)=>{const n=i[r][1];t[e[0]][0]+=n;const o=i[r][2];return o.length>1?t[e[0]][1]=o.map(((r,i)=>r+t[e[0]][1][i]||r)):t[e[0]][1]=[t[e[0]][1].concat(o).reduce(((t,e)=>t+e),0)],t}),Object.assign({},...r.map((t=>({[t]:[0,[]]})))))),n=i.map((t=>[t[0],t[1][0]])),[o,a]=n.reduce((([t,e],[r,i])=>i>e?[r,i]:[t,e]),["?",-1/0]),[s,h]=n.reduce((([t,e],[r,i])=>i<e?[r,i]:[t,e]),["?",1/0]),u=i.sort(((t,e)=>e[1][0]-t[1][0])),l=t.map((t=>t[1])).reduce(((t,e)=>t+e),0);return e.push({round:e.length+1,sortedByHighest:u}),a>l/2||u.length<3?e:HP(t.map((t=>[t[0].filter((t=>t!=s)),t[1],t[2]])).filter((t=>t[0].length>0)),e)}function GP(t){const e=HP(t.map((t=>[t.choice,t.balance,t.scores])),[]);return e[e.length-1].sortedByHighest}class ZP{constructor(t,e,r,i){this.proposal=t,this.votes=e,this.strategies=r,this.selected=i}static isValidChoice(t,e){return Array.isArray(t)&&t.every((t=>void 0!==(null==e?void 0:e[t-1])))&&t.length===new Set(t).size&&t.length>0&&t.length===e.length}getValidVotes(){return this.votes.filter((t=>ZP.isValidChoice(t.choice,this.proposal.choices)))}getScores(){return function(t,e){const r=GP(t);return e.choices.map(((t,e)=>r.filter((t=>Number(t[0])===e+1)).reduce(((t,e)=>t+e[1][0]),0)))}(this.getValidVotes(),this.proposal)}getScoresByStrategy(){const t=GP(this.getValidVotes());return this.proposal.choices.map(((e,r)=>this.strategies.map(((e,i)=>t.filter((t=>Number(t[0])===r+1)).reduce(((t,e)=>t+e[1][1][i]),0)))))}getScoresTotal(){return this.votes.reduce(((t,e)=>t+e.balance),0)}getChoiceString(){return this.selected.map((t=>{if(this.proposal.choices[t-1])return this.proposal.choices[t-1]})).map(((t,e)=>`(${SB(e+1)}) ${t}`)).join(", ")}}class KP{constructor(t,e,r,i){this.proposal=t,this.votes=e,this.strategies=r,this.selected=i}static isValidChoice(t,e){return!(!Array.isArray(t)||0===t.length||t.length>e.length||new Set(t).size!==t.length)&&t.every((t=>Number.isInteger(t)&&t>=1&&t<=e.length))}getValidVotes(){return this.votes.filter((t=>KP.isValidChoice(t.choice,this.proposal.choices)))}getScores(){const t=this.getValidVotes(),e=this.proposal.choices.length,r=Array.from({length:e},(()=>Array(e).fill(0))),i=this.getScoresTotal();for(const e of t)for(let t=0;t<e.choice.length;t++)for(let i=t+1;i<e.choice.length;i++){const n=e.choice[t]-1,o=e.choice[i]-1;r[n][o]+=e.balance,r[o][n]-=e.balance}const n=Array(e).fill(0);let o=0;for(let t=0;t<e;t++)for(let i=0;i<e;i++)if(t!==i){const e=r[t][i];e>0?n[t]++:e<0?n[i]++:(n[t]+=.5,n[i]+=.5)}return o=n.reduce(((t,e)=>t+e),0),o>0?n.map((t=>t/o*i)):n.map((()=>i/e))}getScoresByStrategy(){const t=this.getValidVotes(),e=this.proposal.choices.length,r=this.strategies.length,i=Array.from({length:e},(()=>Array.from({length:e},(()=>Array(r).fill(0))))),n=Array(r).fill(0);for(const e of t)for(let t=0;t<r;t++)n[t]+=e.scores[t];for(const e of t)for(let t=0;t<e.choice.length;t++)for(let n=t+1;n<e.choice.length;n++){const o=e.choice[t]-1,a=e.choice[n]-1;for(let t=0;t<r;t++)i[o][a][t]+=e.scores[t],i[a][o][t]-=e.scores[t]}const o=Array.from({length:e},(()=>Array(r).fill(0)));for(let t=0;t<e;t++)for(let n=0;n<e;n++)if(t!==n)for(let e=0;e<r;e++){const r=i[t][n][e];r>0?o[t][e]++:r<0?o[n][e]++:(o[t][e]+=.5,o[n][e]+=.5)}const a=Array.from({length:e},(()=>Array(r).fill(0)));for(let t=0;t<r;t++){let r=0;for(let i=0;i<e;i++)r+=o[i][t];if(r>0)for(let i=0;i<e;i++)a[i][t]=o[i][t]/r*n[t];else if(n[t]>0)for(let r=0;r<e;r++)a[r][t]=n[t]/e}return a}getScoresTotal(){return this.getValidVotes().reduce(((t,e)=>t+e.balance),0)}getChoiceString(){return this.selected.map((t=>this.proposal.choices[t-1])).join(", ")}}function JP(t,e,r){const i=r.reduce(((t,e)=>t+e),0),n=e[t]/i*100;return isNaN(n)?0:n}function WP(t,e,r){return JP(t+1,e,Object.values(e))/100*r}class YP{constructor(t,e,r,i){this.proposal=t,this.votes=e,this.strategies=r,this.selected=i}static isValidChoice(t,e){return"object"==typeof t&&!Array.isArray(t)&&null!==t&&Object.keys(t).every((t=>void 0!==(null==e?void 0:e[Number(t)-1])))&&Object.keys(t).length>0&&Object.values(t).every((t=>"number"==typeof t&&t>=0))&&Object.values(t).some((t=>"number"==typeof t&&t>0))}getValidVotes(){return this.votes.filter((t=>YP.isValidChoice(t.choice,this.proposal.choices)))}getScores(){const t=this.proposal.choices.map(((t,e)=>this.getValidVotes().map((t=>WP(e,t.choice,t.balance))).reduce(((t,e)=>t+e),0))),e=this.getValidVotes().reduce(((t,e)=>t+e.balance),0);return t.map(((e,r)=>JP(r,t,t))).map((t=>e/100*t))}getScoresByStrategy(){const t=this.proposal.choices.map(((t,e)=>this.strategies.map(((t,r)=>this.getValidVotes().map((t=>WP(e,t.choice,t.scores[r]))).reduce(((t,e)=>t+e),0))))).map((t=>t.map((t=>[t])))),e=this.getValidVotes().reduce(((t,e)=>t+e.balance),0);return t.map(((r,i)=>this.strategies.map(((e,r)=>JP(0,t[i][r],t.flat(2)))).map((t=>[e/100*t])).flat()))}getScoresTotal(){return this.votes.reduce(((t,e)=>t+e.balance),0)}getChoiceString(){return this.proposal.choices.map(((t,e)=>{if(this.selected[e+1])return`${Math.round(10*JP(e+1,this.selected,Object.values(this.selected)))/10}% for ${t}`})).filter((t=>null!=t)).join(", ")}}var QP={"single-choice":DP,approval:$P,quadratic:VP,"ranked-choice":ZP,copeland:KP,weighted:YP,basic:DP};const XP={1:"https://subgrapher.snapshot.org/delegation/1",10:"https://subgrapher.snapshot.org/delegation/10",56:"https://subgrapher.snapshot.org/delegation/56",100:"https://subgrapher.snapshot.org/delegation/100",137:"https://subgrapher.snapshot.org/delegation/137",146:"https://subgrapher.snapshot.org/delegation/146",250:"https://subgrapher.snapshot.org/delegation/250",5e3:"https://subgrapher.snapshot.org/delegation/5000",8453:"https://subgrapher.snapshot.org/delegation/8453",42161:"https://subgrapher.snapshot.org/delegation/42161",59144:"https://subgrapher.snapshot.org/delegation/59144",81457:"https://subgrapher.snapshot.org/delegation/81457",84532:"https://subgrapher.snapshot.org/delegation/84532",11155111:"https://subgrapher.snapshot.org/delegation/11155111"},tB=1e3;function eB(t){return t.length===tB&&t[0].timestamp===t[t.length-1].timestamp}function rB(t,e){const r=function(t){return`${t.delegator}-${t.delegate}-${t.space}`}(e);t.has(r)||t.set(r,e)}function iB(t){const e=["",t];return t.includes(".eth")&&e.push(t.replace(".eth","")),e}function nB(t){return r(this,arguments,void 0,(function*({url:t,spaces:e,pivot:r,snapshot:i}){const n={delegations:{__args:{where:{timestamp_gte:r},first:tB,skip:0,orderBy:"timestamp",orderDirection:"asc"},delegator:!0,space:!0,delegate:!0,timestamp:!0}};return"latest"!==i&&(n.delegations.__args.block={number:i}),null!==e&&(n.delegations.__args.where.space_in=e),(yield kB(t,n)).delegations||[]}))}const oB=["response not found during CCIP fetch","UNSUPPORTED_OPERATION"],aB="0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e",sB=["function text(bytes32 node, string calldata key) external view returns (string memory)","function resolver(bytes32 node) view returns (address)"],hB="0x0000000000000000000000000000000000000000",uB={"0x534e5f4d41494e":{name:"Starknet",testnet:!1},"0x534e5f5345504f4c4941":{name:"Starknet Sepolia",testnet:!0}},lB={Accept:"application/json","Content-Type":"application/json"},cB="https://score.snapshot.org";function dB(t=cB,e={path:""}){const r=new URL(t);e.path&&(r.pathname=e.path);const i=r.searchParams.get("apiKey");let n=Object.assign({},lB);return i&&(r.searchParams.delete("apiKey"),n=Object.assign(Object.assign({},lB),{"X-API-KEY":i})),{url:r.toString(),headers:n}}function fB(t){return r(this,void 0,void 0,(function*(){let e=yield t.text();try{e=JSON.parse(e)}catch(r){return Promise.reject({code:t.status||500,message:"Failed to parse response from score API",data:e})}return e.error?Promise.reject(e.error):e}))}const mB=new Qd({allErrors:!0,allowUnionTypes:!0,$data:!0,passContext:!0});rf(mB),of(mB),mB.addFormat("address",{validate:t=>{try{return t===he(t)}catch(t){return!1}}}),mB.addFormat("evmAddress",{validate:t=>{try{return he(t),!0}catch(t){return!1}}}),mB.addFormat("starknetAddress",{validate:t=>{try{return gR(t).toLowerCase()===t.toLowerCase()}catch(t){return!1}}}),mB.addFormat("long",{validate:()=>!0}),mB.addFormat("lowercase",{validate:t=>t===t.toLowerCase()}),mB.addFormat("color",{validate:t=>!!t&&!!t.match(/^#[0-9A-F]{6}$/)}),mB.addFormat("ethValue",{validate:t=>{if(!t.match(/^([0-9]|[1-9][0-9]+)(\.[0-9]+)?$/))return!1;try{return function(t,e){if("string"!=typeof t&&$h.throwArgumentError("value must be a string","value",t),"string"==typeof e){const t=Lh.indexOf(e);-1!==t&&(e=3*t)}Eh(t,null!=e?e:18)}(t,18),!0}catch(t){return!1}}});const pB=Object.keys(BP),gB=Object.keys(BP).filter((t=>!BP[t].testnet));function yB(t){const e=t.endsWith(".eth"),r=t.split(".");if(1===r.length)return"tld";if(2!==r.length||e){if(r.length>2)return"subdomain";if(e)return"ens";throw new Error("Invalid domain")}return"other-tld"}function wB(t){return r(this,void 0,void 0,(function*(){var e;const r=yield h(`https://cloudflare-dns.com/dns-query?name=${t}&type=TXT`,{headers:{accept:"application/dns-json"}}),i=yield r.json();if(3===i.Status)return hB;if(0!==i.Status)throw new Error("Failed to fetch DNS Owner");const n=null===(e=i.Answer)||void 0===e?void 0:e.find((t=>t.data.includes("ENS1")));return n?he(n.data.replace(new RegExp('"',"g"),"").split(" ").pop()):hB}))}function vB(t,e,i,n){return r(this,void 0,void 0,(function*(){const r=new Ds(i[0],e,t);try{const t=i[2]||[];return yield r[i[1]](...t,n||{})}catch(t){return Promise.reject(t)}}))}function bB(t,e,i,n,o){return r(this,void 0,void 0,(function*(){const r=(null==o?void 0:o.multicallAddress)||BP[t].multicall,a=new Ds(r,["function aggregate(tuple(address target, bytes callData)[] calls) view returns (uint256 blockNumber, bytes[] returnData)"],e),s=new Ji(i);try{const t=(null==o?void 0:o.limit)||500;(null==o?void 0:o.limit)&&delete o.limit;const e=Math.ceil(n.length/t),r=[];Array.from(Array(e)).forEach(((e,i)=>{const h=n.slice(t*i,t*(i+1));r.push(a.aggregate(h.map((t=>[t[0].toLowerCase(),s.encodeFunctionData(t[1],t[2])])),o||{}))}));let i=yield Promise.all(r);return i=i.reduce(((t,[,e])=>t.concat(e)),[]),i.map(((t,e)=>s.decodeFunctionResult(n[e][1],t)))}catch(t){return Promise.reject(t)}}))}function kB(t,e){return r(this,arguments,void 0,(function*(t,e,r={}){const i={query:El.jsonToGraphQLQuery({query:e})};r.variables&&(i.variables=r.variables);const n=yield h(t,{method:"POST",headers:Object.assign({Accept:"application/json","Content-Type":"application/json"},null==r?void 0:r.headers),body:JSON.stringify(i)});let o=yield n.text();try{o=JSON.parse(o)}catch(e){throw new Error(`Errors found in subgraphRequest: URL: ${t}, Status: ${n.status}, Response: ${o.substring(0,400)}`)}if(o.errors)throw new Error(`Errors found in subgraphRequest: URL: ${t}, Status: ${n.status}, Response: ${JSON.stringify(o.errors).substring(0,400)}`);const{data:a}=o;return a||{}}))}function MB(t,e=PP[0]){const r=`https://${e}`;if(!t)return null;if(!(t.startsWith("ipfs://")||t.startsWith("ipns://")||t.startsWith("https://")||t.startsWith("http://")))return`${r}/ipfs/${t}`;const i=t.split("://")[0];return"ipfs"===i?t.replace("ipfs://",`${r}/ipfs/`):"ipns"===i?t.replace("ipns://",`${r}/ipns/`):t}function _B(t,i){return r(this,arguments,void 0,(function*(t,r,i="1",n={}){var o,a;const{ensResolvers:s=(null===(o=BP[i])||void 0===o?void 0:o.ensResolvers)||BP[1].ensResolvers,broviderUrl:h}=n,u=e(n,["ensResolvers","broviderUrl"]);let l;try{l=Vu(qu(t))}catch(t){return null}const c=Xp(i,{broviderUrl:h}),d=[[aB,"resolver",[l]],...s.map((t=>[t,"text",[l,r]]))],[[f],...m]=yield bB(i,c,sB,d,u),p=s.indexOf(f);return-1!==p?null===(a=m[p])||void 0===a?void 0:a[0]:null}))}function EB(t){return r(this,arguments,void 0,(function*(t,e="1",r={}){try{return yield _B(t,"snapshot",e,r)}catch(t){return console.log(t),null}}))}function AB(t){return r(this,arguments,void 0,(function*(t,e="1",r={}){var i,n;if(!(null===(n=null===(i=BP[e])||void 0===i?void 0:i.ensResolvers)||void 0===n?void 0:n.length))throw new Error("Network not supported");const o=yB(t),a=Xp(e,r),s=new Ds(aB,["function owner(bytes32) view returns (address)"],a);let h;try{h=Vu(qu(t))}catch(t){return hB}const u=r.ensNameWrapper||BP[e].ensNameWrapper;let l=yield s.owner(h);if(l===u){const t=new Ds(u,["function ownerOf(uint256) view returns (address)"],a);l=yield t.ownerOf(h)}if(l===hB&&"other-tld"===o){(yield a.resolveName(t))&&(l=yield wB(t))}if(l===hB&&"subdomain"===o)try{l=yield a.resolveName(t)}catch(t){if(oB.every((e=>!t.message.includes(e))))throw t;l=hB}return l||hB}))}function jB(t,e){return r(this,arguments,void 0,(function*(t,e,r={}){const i=yield EB(t,e,r);if(i){let t=ue(i);if(t)return i;const e=i.split("/"),r=e.includes("testnet")?5:4,n=e[r];if(t=ue(n),t)return n}return yield AB(t,e,r)}))}function xB(t,e){return r(this,void 0,void 0,(function*(){if(!t.endsWith(".shib"))return hB;const r=yield h("https://stamp.fyi",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({method:"get_owner",params:t,network:e})});return(yield r.json()).result}))}function SB(t){const e=["th","st","nd","rd"],r=t%100;return t+(e[(r-20)%10]||e[r]||e[0])}function NB(t){return!!BP[t]}function IB(t){return t!==hB&&(ue(t)||CB(t))}function TB(t,e){return"latest"===t||"number"==typeof t&&t>=BP[e].start}function CB(t){if(!t)return!1;try{return gR(t),!0}catch(t){return!1}}function zB(t){return ue(t)}function OB(t){return Promise.reject(new Error(t))}mB.addKeyword({keyword:"snapshotNetwork",validate:function(t,e){return"mainnet"===(this.snapshotEnv||"default")?gB.includes(e):pB.includes(e)},error:{message:"network not allowed"}}),mB.addKeyword({keyword:"starknetNetwork",validate:function(t,e){return"mainnet"===(this.snapshotEnv||"default")?Object.keys(uB).filter((t=>!uB[t].testnet)).includes(e):Object.keys(uB).includes(e)},error:{message:"network not allowed"}}),mB.addFormat("customUrl",{type:"string",validate:t=>!t.length||(t.startsWith("http://")||t.startsWith("https://")||t.startsWith("ipfs://")||t.startsWith("ipns://")||t.startsWith("snapshot://"))}),mB.addFormat("domain",{validate:t=>!!t&&!!t.match(/^(https:\/\/)?([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,}(\/)?$/)});var RB={call:vB,multicall:bB,subgraphRequest:kB,ipfsGet:function(t,e){return r(this,arguments,void 0,(function*(t,e,r="ipfs"){return h(`https://${t}/${r}/${e}`).then((t=>t.json()))}))},getUrl:MB,getJSON:function(t){return r(this,arguments,void 0,(function*(t,e={}){const r=MB(t,e.gateways);return h(r).then((t=>t.json()))}))},sendTransaction:function(t,e,i,n,o){return r(this,arguments,void 0,(function*(t,e,r,i,n,o={}){const a=t.getSigner(),s=new Ds(e,r,t).connect(a);return yield s[i](...n,o)}))},getScores:function(t,e,i,n){return r(this,arguments,void 0,(function*(t,e,r,i,n="latest",o=cB,a={}){if(!Array.isArray(i))return OB("addresses should be an array of addresses");if(0===i.length)return OB("addresses can not be empty");const s=i.find((t=>!IB(t)));if(s)return OB(`Invalid address: ${s}`);if(!NB(r))return OB(`Invalid network: ${r}`);const u=e.find((t=>t.network&&!NB(t.network)));if(u)return OB(`Invalid network (${u.network}) in strategy ${u.name}`);if(!TB(n,r))return OB(`Snapshot (${n}) must be 'latest' or greater than network start block (${BP[r].start})`);new URL(o).pathname="/api/scores";const{url:l,headers:c}=dB(o,{path:"/api/scores"});try{const o={space:t,network:r,snapshot:n,strategies:e,addresses:i},s=yield h(l,{method:"POST",headers:c,body:JSON.stringify({params:o})}),u=yield fB(s);return"all"===a.returnValue?u.result:u.result[a.returnValue||"scores"]}catch(t){return t.errno?Promise.reject({code:t.errno,message:t.toString(),data:""}):Promise.reject(t)}}))},getVp:function(t,e,i,n,o,a,s){return r(this,void 0,void 0,(function*(){const{url:r,headers:u}=dB(null==s?void 0:s.url);if(!IB(t))return OB(`Invalid voter address: ${t}`);if(!NB(e))return OB(`Invalid network: ${e}`);const l=i.find((t=>t.network&&!NB(t.network)));if(l)return OB(`Invalid network (${l.network}) in strategy ${l.name}`);if(!TB(n,e))return OB(`Snapshot (${n}) must be 'latest' or greater than network start block (${BP[e].start})`);const c={method:"POST",headers:u,body:JSON.stringify({jsonrpc:"2.0",method:"get_vp",params:{address:t,network:e,strategies:i,snapshot:n,space:o,delegation:a}})};try{const t=yield h(r,c);return(yield fB(t)).result}catch(t){return t.errno?Promise.reject({code:t.errno,message:t.toString(),data:""}):Promise.reject(t)}}))},validateSchema:function(t,e,r={snapshotEnv:"default",spaceType:"default"}){const i=mB.compile(t),n=i.call(r,e);return n||i.errors},getEnsTextRecord:_B,getSpaceUri:EB,getEnsOwner:AB,getSpaceController:function(t){return r(this,arguments,void 0,(function*(t,e="1",r={}){if(["1","11155111"].includes(e))return jB(t,e,r);if(["109","157"].includes(e))return xB(t,e);throw new Error(`Network not supported: ${e}`)}))},getDelegatesBySpace:function(t,e){return r(this,arguments,void 0,(function*(t,e,r="latest",i={}){const n=i.subgraphUrl||XP[t];if(!n)return Promise.reject(`Delegation subgraph not available for network ${t}`);let o=0;const a=new Map,s=e?iB(e):null;for(;;){const t=yield nB({url:n,spaces:s,pivot:o,snapshot:r});if(eB(t))throw new Error("Unable to paginate delegation");if(t.forEach((t=>{rB(a,t),o=t.timestamp})),t.length<tB)break}return[...a.values()]}))},clone:function(t){return JSON.parse(JSON.stringify(t))},sleep:function(t){return r(this,void 0,void 0,(function*(){return new Promise((e=>{setTimeout(e,t)}))}))},getNumberWithOrdinal:SB,voting:QP,getProvider:Xp,signMessage:function(t,e,i){return r(this,void 0,void 0,(function*(){return e=I(new Y(e,"utf8")),yield t.send("personal_sign",[e,i])}))},getBlockNumber:function(t){return r(this,void 0,void 0,(function*(){try{const e=yield t.getBlockNumber();return parseInt(e)}catch(t){return Promise.reject()}}))},Multicaller:class{constructor(t,e,r,i){this.options={},this.calls=[],this.paths=[],this.network=t,this.provider=e,this.abi=r,this.options=i||{}}call(t,e,r,i){return this.calls.push([e,r,i]),this.paths.push(t),this}execute(t){return r(this,void 0,void 0,(function*(){const e=t||{};return(yield bB(this.network,this.provider,this.abi,this.calls,this.options)).forEach(((t,r)=>Qf(e,this.paths[r],t.length>1?t:t[0]))),this.calls=[],this.paths=[],e}))}},getSnapshots:function(t,e,i,n){return r(this,arguments,void 0,(function*(t,e,r,i,n={}){const o={};if(i.forEach((t=>o[t]="latest")),"latest"===e)return o;const a=`${t}-${e}-${i.join("-")}`,s=Xf[a],h=Date.now();if(s&&tm>h)return s;tm<h&&(Xf={},tm=h+36e5-h%36e5),o[t]=e;const u=Object.keys(o).filter((e=>t!==e));if(0===u.length)return o;const l={blocks:{__args:{where:{ts:(yield r.getBlock(e)).timestamp,network_in:u}},network:!0,number:!0}},c=n.blockFinderUrl||"https://blockfinder.snapshot.org";return(yield kB(c,l)).blocks.forEach((t=>o[t.network]=t.number)),Xf[a]=o,o}))},getHash:function(t,e){return(QR(t)?tP:RP).getHash(t,e)},verify:function(t,e,i){return r(this,arguments,void 0,(function*(t,e,r,i="1",n={}){if(!CB(t)&&!zB(t))throw new Error("Invalid address");const o=QR(r)?tP:RP;return yield o.default(t,e,r,i,n)}))},validate:function(t,e,i,n,o,a,s){return r(this,void 0,void 0,(function*(){if(!IB(e))return OB(`Invalid author: ${e}`);if(!NB(n))return OB(`Invalid network: ${n}`);if(!TB(o,n))return OB(`Snapshot (${o}) must be 'latest' or greater than network start block (${BP[n].start})`);s||(s={});const{url:r,headers:u}=dB(s.url),l={method:"POST",headers:u,body:JSON.stringify({jsonrpc:"2.0",method:"validate",params:{validation:t,author:e,space:i,network:n,snapshot:o,params:a}})};try{const t=yield h(r,l);return(yield fB(t)).result}catch(t){return t.errno?Promise.reject({code:t.errno,message:t.toString(),data:""}):Promise.reject(t)}}))},isStarknetAddress:CB,isEvmAddress:zB,getFormattedAddress:function(t,e){if("evm"===e&&zB(t))return he(t);if("starknet"===e&&CB(t))return gR(t);throw new Error(`Invalid address: ${t}`)},SNAPSHOT_SUBGRAPH_URL:XP};return{Client:Re,Client712:Re,schemas:qe,utils:RB}}));